Merge remote branch 'origin/master' into lp-binning
authorJosé Fonseca <jfonseca@vmware.com>
Fri, 8 Jan 2010 15:42:57 +0000 (15:42 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Fri, 8 Jan 2010 15:42:57 +0000 (15:42 +0000)
Conflicts:
src/gallium/auxiliary/util/u_surface.c
src/gallium/drivers/llvmpipe/Makefile
src/gallium/drivers/llvmpipe/SConscript
src/gallium/drivers/llvmpipe/lp_bld_arit.c
src/gallium/drivers/llvmpipe/lp_bld_flow.c
src/gallium/drivers/llvmpipe/lp_bld_interp.c
src/gallium/drivers/llvmpipe/lp_clear.c
src/gallium/drivers/llvmpipe/lp_context.c
src/gallium/drivers/llvmpipe/lp_context.h
src/gallium/drivers/llvmpipe/lp_draw_arrays.c
src/gallium/drivers/llvmpipe/lp_jit.c
src/gallium/drivers/llvmpipe/lp_jit.h
src/gallium/drivers/llvmpipe/lp_prim_vbuf.c
src/gallium/drivers/llvmpipe/lp_setup.c
src/gallium/drivers/llvmpipe/lp_setup_point.c
src/gallium/drivers/llvmpipe/lp_state.h
src/gallium/drivers/llvmpipe/lp_state_blend.c
src/gallium/drivers/llvmpipe/lp_state_derived.c
src/gallium/drivers/llvmpipe/lp_state_fs.c
src/gallium/drivers/llvmpipe/lp_state_sampler.c
src/gallium/drivers/llvmpipe/lp_state_surface.c
src/gallium/drivers/llvmpipe/lp_tex_cache.c
src/gallium/drivers/llvmpipe/lp_tex_cache.h
src/gallium/drivers/llvmpipe/lp_tex_sample.h
src/gallium/drivers/llvmpipe/lp_tile_cache.c

2026 files changed:
.gitignore
Makefile
SConstruct
bin/mklib
bin/win32kprof.py [deleted file]
configs/autoconf.in
configs/darwin
configs/default
configs/linux
configs/linux-cell
configs/linux-debug
configs/linux-dri
configs/linux-dri-debug
configs/linux-dri-xcb
configs/linux-i965 [new file with mode: 0644]
configs/linux-llvm
configure.ac
docs/GL3.txt [new file with mode: 0644]
docs/README.WIN32
docs/envvars.html
docs/install.html
docs/libGL.txt [new file with mode: 0644]
docs/news.html
docs/relnotes-7.6.1.html
docs/relnotes-7.7.1.html [new file with mode: 0644]
docs/relnotes-7.7.html
docs/relnotes-7.8.html [new file with mode: 0644]
docs/relnotes.html
docs/shading.html
doxygen/gallium.doc
include/EGL/eglplatform.h
include/GL/gl.h
include/GL/gl_mangle.h
include/GL/glew.h
include/GL/glext.h
include/GL/glut.h
include/GL/glx_mangle.h
include/GL/glxew.h
include/GL/glxext.h
include/GL/wglew.h
include/GL/wglext.h
progs/.gitignore [new file with mode: 0644]
progs/Makefile
progs/SConscript
progs/SConstruct [deleted file]
progs/demos/SConscript
progs/demos/arbfplight.c
progs/demos/arbfslight.c
progs/demos/arbocclude.c
progs/demos/bounce.c
progs/demos/clearspd.c
progs/demos/copypix.c
progs/demos/cubemap.c
progs/demos/drawpix.c
progs/demos/engine.c
progs/demos/fbo_firecube.c
progs/demos/fire.c
progs/demos/fogcoord.c
progs/demos/fplight.c
progs/demos/fslight.c
progs/demos/gamma.c
progs/demos/gearbox.c
progs/demos/gears.c
progs/demos/geartrain.c
progs/demos/gloss.c
progs/demos/gltestperf.c
progs/demos/ipers.c
progs/demos/isosurf.c
progs/demos/lodbias.c
progs/demos/morph3d.c
progs/demos/multiarb.c
progs/demos/paltex.c
progs/demos/pointblast.c
progs/demos/projtex.c
progs/demos/ray.c
progs/demos/readpix.c
progs/demos/renormal.c
progs/demos/shadowtex.c
progs/demos/spectex.c
progs/demos/spriteblast.c
progs/demos/teapot.c
progs/demos/terrain.c
progs/demos/tessdemo.c
progs/demos/texcyl.c
progs/demos/texenv.c
progs/demos/textures.c
progs/demos/trispd.c
progs/demos/tunnel.c
progs/demos/tunnel2.c
progs/demos/vao_demo.c
progs/demos/winpos.c
progs/egl/eglgears.c
progs/egl/eglscreen.c
progs/egl/egltri.c
progs/egl/peglgears.c
progs/egl/xeglgears.c
progs/fp/Makefile
progs/fp/SConscript
progs/fp/fp-tri.c
progs/fp/mov-imm.txt [new file with mode: 0644]
progs/fp/mov-param.txt [new file with mode: 0644]
progs/fp/point-position.c
progs/fp/tri-depth.c
progs/fp/tri-depth2.c
progs/fp/tri-depthwrite.c
progs/fp/tri-depthwrite2.c
progs/fp/tri-inv.c
progs/fp/tri-param.c
progs/fp/tri-tex.c
progs/glsl/CH11-bumpmaptex.frag [new file with mode: 0644]
progs/glsl/CH18-mandel.frag
progs/glsl/SConscript
progs/glsl/bump.c
progs/glsl/convolutions.c
progs/glsl/deriv.c
progs/glsl/multinoise.c
progs/glsl/multitex.c
progs/glsl/noise.c
progs/glsl/shtest.c
progs/glsl/texaaline.c
progs/glsl/texdemo1.c
progs/glsl/trirast.c
progs/glsl/vert-tex.c
progs/objviewer/.gitignore [new file with mode: 0644]
progs/osdemos/Makefile
progs/perf/.gitignore [new file with mode: 0644]
progs/perf/SConscript
progs/perf/genmipmap.c
progs/rbug/bin_to_bmp.c
progs/rbug/simple_server.c
progs/rbug/tex_dump.c
progs/redbook/SConscript
progs/redbook/aaindex.c
progs/redbook/aapoly.c
progs/redbook/aargb.c
progs/redbook/accanti.c
progs/redbook/accpersp.c
progs/redbook/alpha.c
progs/redbook/alpha3D.c
progs/redbook/anti.c
progs/redbook/bezcurve.c
progs/redbook/bezmesh.c
progs/redbook/checker.c
progs/redbook/clip.c
progs/redbook/colormat.c
progs/redbook/cube.c
progs/redbook/depthcue.c
progs/redbook/dof.c
progs/redbook/double.c
progs/redbook/drawf.c
progs/redbook/feedback.c
progs/redbook/fog.c
progs/redbook/fogindex.c
progs/redbook/font.c
progs/redbook/hello.c
progs/redbook/image.c
progs/redbook/light.c
progs/redbook/lines.c
progs/redbook/list.c
progs/redbook/material.c
progs/redbook/mipmap.c
progs/redbook/model.c
progs/redbook/movelight.c
progs/redbook/nurbs.c
progs/redbook/pickdepth.c
progs/redbook/picksquare.c
progs/redbook/plane.c
progs/redbook/planet.c
progs/redbook/polyoff.c
progs/redbook/polys.c
progs/redbook/quadric.c
progs/redbook/robot.c
progs/redbook/sccolorlight.c
progs/redbook/scene.c
progs/redbook/scenebamb.c
progs/redbook/sceneflat.c
progs/redbook/select.c
progs/redbook/smooth.c
progs/redbook/stencil.c
progs/redbook/stroke.c
progs/redbook/surface.c
progs/redbook/teaambient.c
progs/redbook/teapots.c
progs/redbook/tess.c
progs/redbook/tesswind.c
progs/redbook/texbind.c
progs/redbook/texgen.c
progs/redbook/texprox.c
progs/redbook/texsub.c
progs/redbook/texturesurf.c
progs/redbook/torus.c
progs/redbook/trim.c
progs/redbook/unproject.c
progs/redbook/varray.c
progs/redbook/wrap.c
progs/samples/.gitignore
progs/samples/Makefile
progs/samples/SConscript
progs/samples/olympic.c
progs/samples/overlay.c
progs/samples/rgbtoppm.c
progs/samples/sphere.c
progs/samples/star.c
progs/samples/stretch.c
progs/samples/wave.c
progs/slang/cltest.c
progs/slang/vstest.c
progs/tests/Makefile
progs/tests/SConscript
progs/tests/arbgpuprog.c
progs/tests/arraytexture.c
progs/tests/blitfb.c [new file with mode: 0644]
progs/tests/bug_texstore_i8.c
progs/tests/condrender.c [new file with mode: 0644]
progs/tests/crossbar.c
progs/tests/cva.c
progs/tests/drawbuffers.c
progs/tests/drawbuffers2.c [new file with mode: 0644]
progs/tests/fptest1.c
progs/tests/getprocaddress.c
progs/tests/getteximage.c
progs/tests/invert.c
progs/tests/minmag.c
progs/tests/mipmap_comp.c
progs/tests/packedpixels.c
progs/tests/prog_parameter.c
progs/tests/quads.c
progs/tests/scissor-viewport.c
progs/tests/scissor.c
progs/tests/shader_api.c
progs/tests/sharedtex.c
progs/tests/stencil_twoside.c
progs/tests/stencilwrap.c
progs/tests/tex1d.c
progs/tests/texcmp.c
progs/tests/texcomp_image.h
progs/tests/texcompsub.c
progs/tests/texdown.c
progs/tests/texleak.c [new file with mode: 0644]
progs/tests/unfilledclip.c
progs/tests/vao-01.c
progs/tests/vao-02.c
progs/tests/vparray.c
progs/tests/vpeval.c
progs/tests/zreaddraw.c
progs/trivial/.gitignore
progs/trivial/Makefile
progs/trivial/SConscript
progs/trivial/clear-fbo-tex.c
progs/trivial/clear-fbo.c
progs/trivial/clear-random.c
progs/trivial/clear-scissor.c
progs/trivial/clear.c
progs/trivial/createwin.c
progs/trivial/dlist-begin-call-end.c
progs/trivial/dlist-dangling.c
progs/trivial/dlist-edgeflag-dangling.c
progs/trivial/dlist-edgeflag.c
progs/trivial/dlist-flat-tri.c
progs/trivial/dlist-mat-tri.c
progs/trivial/dlist-recursive-call.c
progs/trivial/dlist-tri-flat-tri.c
progs/trivial/dlist-tri-mat-tri.c
progs/trivial/draw2arrays.c
progs/trivial/drawarrays.c
progs/trivial/line-clip.c
progs/trivial/line-cull.c
progs/trivial/line-flat.c
progs/trivial/line-stipple-wide.c
progs/trivial/line-userclip-clip.c
progs/trivial/line-userclip-nop-clip.c
progs/trivial/line-userclip-nop.c
progs/trivial/line-userclip.c
progs/trivial/line-wide.c
progs/trivial/line.c
progs/trivial/lineloop-clip.c
progs/trivial/lineloop.c
progs/trivial/linestrip-clip.c
progs/trivial/linestrip-flat-stipple.c
progs/trivial/linestrip-stipple-wide.c
progs/trivial/linestrip-stipple.c
progs/trivial/linestrip.c
progs/trivial/point-clip.c
progs/trivial/point-param.c
progs/trivial/point-sprite.c
progs/trivial/point-wide-smooth.c
progs/trivial/point-wide.c
progs/trivial/point.c
progs/trivial/poly-flat-clip.c
progs/trivial/poly-flat-unfilled-clip.c
progs/trivial/poly-flat.c
progs/trivial/poly-unfilled.c
progs/trivial/poly.c
progs/trivial/psb_context.c [deleted file]
progs/trivial/quad-clip-all-vertices.c
progs/trivial/quad-clip.c
progs/trivial/quad-degenerate.c
progs/trivial/quad-flat.c
progs/trivial/quad-offset-factor.c
progs/trivial/quad-offset-unfilled.c
progs/trivial/quad-offset-units.c
progs/trivial/quad-tex-alpha.c
progs/trivial/quad-tex-pbo.c
progs/trivial/quad-unfilled-clip.c
progs/trivial/quad-unfilled-stipple.c
progs/trivial/quad-unfilled.c
progs/trivial/quad.c
progs/trivial/quads.c
progs/trivial/quadstrip-cont.c
progs/trivial/quadstrip-flat.c
progs/trivial/quadstrip.c
progs/trivial/readpixels.c
progs/trivial/tri-alpha-tex.c
progs/trivial/tri-alpha.c
progs/trivial/tri-blend-color.c
progs/trivial/tri-blend-max.c
progs/trivial/tri-blend-min.c
progs/trivial/tri-blend-revsub.c
progs/trivial/tri-blend-sub.c
progs/trivial/tri-blend.c
progs/trivial/tri-clear.c
progs/trivial/tri-clip.c
progs/trivial/tri-cull-both.c
progs/trivial/tri-dlist.c
progs/trivial/tri-fbo-tex.c
progs/trivial/tri-fbo.c
progs/trivial/tri-flat-clip.c
progs/trivial/tri-flat.c
progs/trivial/tri-fog.c
progs/trivial/tri-fp-const-imm.c
progs/trivial/tri-fp.c
progs/trivial/tri-lit-material.c
progs/trivial/tri-lit.c
progs/trivial/tri-logicop-none.c
progs/trivial/tri-logicop-xor.c
progs/trivial/tri-multitex-vbo.c
progs/trivial/tri-orig.c
progs/trivial/tri-query.c
progs/trivial/tri-scissor-tri.c
progs/trivial/tri-square.c
progs/trivial/tri-stipple.c
progs/trivial/tri-tex-3d.c
progs/trivial/tri-tex.c
progs/trivial/tri-tri.c
progs/trivial/tri-unfilled-clip.c
progs/trivial/tri-unfilled-edgeflag.c
progs/trivial/tri-unfilled-point.c
progs/trivial/tri-unfilled-smooth.c
progs/trivial/tri-unfilled-tri-lit.c
progs/trivial/tri-unfilled-tri.c
progs/trivial/tri-unfilled-userclip-stip.c
progs/trivial/tri-unfilled-userclip.c
progs/trivial/tri-unfilled.c
progs/trivial/tri-userclip.c
progs/trivial/tri-z-9.c
progs/trivial/tri-z-eq.c
progs/trivial/tri-z.c
progs/trivial/trifan-flat-clip.c
progs/trivial/trifan-flat-unfilled-clip.c
progs/trivial/trifan-flat.c
progs/trivial/trifan-unfilled.c
progs/trivial/trifan.c
progs/trivial/tristrip-clip.c
progs/trivial/tristrip-flat.c
progs/trivial/tristrip.c
progs/trivial/vbo-drawarrays.c
progs/trivial/vbo-noninterleaved.c
progs/trivial/vbo-tri.c [new file with mode: 0644]
progs/trivial/vp-tri-cb-pos.c
progs/trivial/vp-tri-cb-tex.c
progs/trivial/vp-tri-invariant.c
progs/util/readtex.c
progs/util/shaderutil.c
progs/vp/SConscript
progs/vp/add-param-imm.txt [new file with mode: 0644]
progs/vp/vp-tris.c
progs/vpglsl/SConscript
progs/vpglsl/psiz-mul.glsl
progs/vpglsl/vp-tris.c
progs/wgl/SConscript
progs/xdemos/Makefile
progs/xdemos/corender.c
progs/xdemos/glsync.c
progs/xdemos/glxinfo.c
progs/xdemos/glxpbdemo.c
progs/xdemos/offset.c
progs/xdemos/pbdemo.c
progs/xdemos/pbinfo.c
progs/xdemos/sharedtex_mt.c
scons/custom.py [new file with mode: 0644]
scons/gallium.py
scons/generic.py [deleted file]
scons/llvm.py
scons/mslib_sa.py
scons/mslink_sa.py
scons/msvc_sa.py
src/SConscript
src/egl/drivers/dri/egldri.c
src/egl/drivers/glx/egl_glx.c
src/egl/main/eglapi.c
src/egl/main/eglapi.h
src/egl/main/eglcompiler.h
src/egl/main/eglconfig.c
src/egl/main/eglconfig.h
src/egl/main/eglconfigutil.c
src/egl/main/eglconfigutil.h
src/egl/main/eglcontext.h
src/egl/main/eglcurrent.c
src/egl/main/eglcurrent.h
src/egl/main/egldisplay.h
src/egl/main/egldriver.c
src/egl/main/egldriver.h
src/egl/main/eglglobals.c
src/egl/main/eglglobals.h
src/egl/main/egllog.c
src/egl/main/egllog.h
src/egl/main/eglmisc.c
src/egl/main/eglmisc.h
src/egl/main/eglmode.h
src/egl/main/eglscreen.h
src/egl/main/eglsurface.c
src/egl/main/eglsurface.h
src/gallium/Makefile.template
src/gallium/SConscript
src/gallium/auxiliary/Makefile
src/gallium/auxiliary/SConscript [new file with mode: 0644]
src/gallium/auxiliary/cso_cache/Makefile [deleted file]
src/gallium/auxiliary/cso_cache/SConscript [deleted file]
src/gallium/auxiliary/cso_cache/cso_context.c
src/gallium/auxiliary/cso_cache/cso_context.h
src/gallium/auxiliary/draw/Makefile [deleted file]
src/gallium/auxiliary/draw/SConscript [deleted file]
src/gallium/auxiliary/draw/draw_context.c
src/gallium/auxiliary/draw/draw_context.h
src/gallium/auxiliary/draw/draw_gs.c [new file with mode: 0644]
src/gallium/auxiliary/draw/draw_gs.h [new file with mode: 0644]
src/gallium/auxiliary/draw/draw_pipe_aaline.c
src/gallium/auxiliary/draw/draw_pipe_aapoint.c
src/gallium/auxiliary/draw/draw_pipe_clip.c
src/gallium/auxiliary/draw/draw_pipe_cull.c
src/gallium/auxiliary/draw/draw_pipe_offset.c
src/gallium/auxiliary/draw/draw_pipe_pstipple.c
src/gallium/auxiliary/draw/draw_pipe_stipple.c
src/gallium/auxiliary/draw/draw_pipe_wide_line.c
src/gallium/auxiliary/draw/draw_pipe_wide_point.c
src/gallium/auxiliary/draw/draw_private.h
src/gallium/auxiliary/draw/draw_pt.c
src/gallium/auxiliary/draw/draw_pt.h
src/gallium/auxiliary/draw/draw_pt_fetch.c
src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
src/gallium/auxiliary/draw/draw_pt_post_vs.c
src/gallium/auxiliary/draw/draw_pt_util.c
src/gallium/auxiliary/draw/draw_pt_varray_tmp_linear.h
src/gallium/auxiliary/draw/draw_pt_vcache.c
src/gallium/auxiliary/draw/draw_vs.c
src/gallium/auxiliary/draw/draw_vs.h
src/gallium/auxiliary/draw/draw_vs_aos.c
src/gallium/auxiliary/draw/draw_vs_varient.c
src/gallium/auxiliary/gallivm/Makefile [deleted file]
src/gallium/auxiliary/gallivm/SConscript [deleted file]
src/gallium/auxiliary/gallivm/tgsitollvm.cpp
src/gallium/auxiliary/indices/Makefile [deleted file]
src/gallium/auxiliary/indices/SConscript [deleted file]
src/gallium/auxiliary/pipebuffer/Makefile [deleted file]
src/gallium/auxiliary/pipebuffer/SConscript [deleted file]
src/gallium/auxiliary/pipebuffer/pb_buffer.h
src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
src/gallium/auxiliary/pipebuffer/pb_validate.c
src/gallium/auxiliary/pipebuffer/pb_validate.h
src/gallium/auxiliary/rbug/Makefile [deleted file]
src/gallium/auxiliary/rbug/README
src/gallium/auxiliary/rbug/SConscript [deleted file]
src/gallium/auxiliary/rbug/rbug_connection.c
src/gallium/auxiliary/rbug/rbug_context.h
src/gallium/auxiliary/rbug/rbug_proto.h
src/gallium/auxiliary/rtasm/Makefile [deleted file]
src/gallium/auxiliary/rtasm/SConscript [deleted file]
src/gallium/auxiliary/rtasm/rtasm_execmem.c
src/gallium/auxiliary/sct/Makefile [deleted file]
src/gallium/auxiliary/sct/SConscript [deleted file]
src/gallium/auxiliary/sct/sct.c [deleted file]
src/gallium/auxiliary/sct/sct.h [deleted file]
src/gallium/auxiliary/sct/usage.c [deleted file]
src/gallium/auxiliary/tgsi/Makefile [deleted file]
src/gallium/auxiliary/tgsi/SConscript [deleted file]
src/gallium/auxiliary/tgsi/tgsi-instruction-set.txt
src/gallium/auxiliary/tgsi/tgsi_build.c
src/gallium/auxiliary/tgsi/tgsi_build.h
src/gallium/auxiliary/tgsi/tgsi_dump.c
src/gallium/auxiliary/tgsi/tgsi_dump.h
src/gallium/auxiliary/tgsi/tgsi_dump_c.c
src/gallium/auxiliary/tgsi/tgsi_exec.c
src/gallium/auxiliary/tgsi/tgsi_exec.h
src/gallium/auxiliary/tgsi/tgsi_info.c
src/gallium/auxiliary/tgsi/tgsi_iterate.c
src/gallium/auxiliary/tgsi/tgsi_iterate.h
src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h
src/gallium/auxiliary/tgsi/tgsi_parse.c
src/gallium/auxiliary/tgsi/tgsi_parse.h
src/gallium/auxiliary/tgsi/tgsi_ppc.c
src/gallium/auxiliary/tgsi/tgsi_sanity.c
src/gallium/auxiliary/tgsi/tgsi_scan.c
src/gallium/auxiliary/tgsi/tgsi_scan.h
src/gallium/auxiliary/tgsi/tgsi_sse2.c
src/gallium/auxiliary/tgsi/tgsi_text.c
src/gallium/auxiliary/tgsi/tgsi_transform.c
src/gallium/auxiliary/tgsi/tgsi_transform.h
src/gallium/auxiliary/tgsi/tgsi_ureg.c
src/gallium/auxiliary/tgsi/tgsi_ureg.h
src/gallium/auxiliary/tgsi/tgsi_util.c
src/gallium/auxiliary/tgsi/tgsi_util.h
src/gallium/auxiliary/translate/Makefile [deleted file]
src/gallium/auxiliary/translate/SConscript [deleted file]
src/gallium/auxiliary/util/Makefile [deleted file]
src/gallium/auxiliary/util/SConscript [deleted file]
src/gallium/auxiliary/util/u_bitmask.c
src/gallium/auxiliary/util/u_blit.c
src/gallium/auxiliary/util/u_blitter.c [new file with mode: 0644]
src/gallium/auxiliary/util/u_blitter.h [new file with mode: 0644]
src/gallium/auxiliary/util/u_clear.h
src/gallium/auxiliary/util/u_cpu_detect.c
src/gallium/auxiliary/util/u_cpu_detect.h
src/gallium/auxiliary/util/u_debug.c
src/gallium/auxiliary/util/u_debug.h
src/gallium/auxiliary/util/u_debug_dump.c
src/gallium/auxiliary/util/u_debug_dump.h
src/gallium/auxiliary/util/u_debug_memory.c
src/gallium/auxiliary/util/u_debug_profile.c [deleted file]
src/gallium/auxiliary/util/u_dl.c [new file with mode: 0644]
src/gallium/auxiliary/util/u_dl.h [new file with mode: 0644]
src/gallium/auxiliary/util/u_format.c
src/gallium/auxiliary/util/u_format.csv
src/gallium/auxiliary/util/u_format.h
src/gallium/auxiliary/util/u_format_access.py
src/gallium/auxiliary/util/u_format_table.py
src/gallium/auxiliary/util/u_gen_mipmap.c
src/gallium/auxiliary/util/u_hash_table.c
src/gallium/auxiliary/util/u_hash_table.h
src/gallium/auxiliary/util/u_keymap.c
src/gallium/auxiliary/util/u_linear.c
src/gallium/auxiliary/util/u_linear.h
src/gallium/auxiliary/util/u_math.h
src/gallium/auxiliary/util/u_mm.c
src/gallium/auxiliary/util/u_network.c
src/gallium/auxiliary/util/u_network.h
src/gallium/auxiliary/util/u_pack_color.h
src/gallium/auxiliary/util/u_prim.h
src/gallium/auxiliary/util/u_rect.c
src/gallium/auxiliary/util/u_rect.h
src/gallium/auxiliary/util/u_simple_shaders.c
src/gallium/auxiliary/util/u_simple_shaders.h
src/gallium/auxiliary/util/u_stream_stdc.c
src/gallium/auxiliary/util/u_surface.c
src/gallium/auxiliary/util/u_texture.c [new file with mode: 0644]
src/gallium/auxiliary/util/u_texture.h [new file with mode: 0644]
src/gallium/auxiliary/util/u_tile.c
src/gallium/auxiliary/util/u_upload_mgr.c
src/gallium/auxiliary/util/u_upload_mgr.h
src/gallium/auxiliary/vl/Makefile [deleted file]
src/gallium/auxiliary/vl/SConscript [deleted file]
src/gallium/auxiliary/vl/vl_compositor.c
src/gallium/auxiliary/vl/vl_compositor.h
src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.h
src/gallium/auxiliary/vl/vl_shader_build.c
src/gallium/docs/Makefile [new file with mode: 0644]
src/gallium/docs/make.bat [new file with mode: 0644]
src/gallium/docs/source/conf.py [new file with mode: 0644]
src/gallium/docs/source/context.rst [new file with mode: 0644]
src/gallium/docs/source/cso.rst [new file with mode: 0644]
src/gallium/docs/source/cso/blend.rst [new file with mode: 0644]
src/gallium/docs/source/cso/dsa.rst [new file with mode: 0644]
src/gallium/docs/source/cso/rasterizer.rst [new file with mode: 0644]
src/gallium/docs/source/cso/sampler.rst [new file with mode: 0644]
src/gallium/docs/source/cso/shader.rst [new file with mode: 0644]
src/gallium/docs/source/distro.rst [new file with mode: 0644]
src/gallium/docs/source/glossary.rst [new file with mode: 0644]
src/gallium/docs/source/index.rst [new file with mode: 0644]
src/gallium/docs/source/intro.rst [new file with mode: 0644]
src/gallium/docs/source/screen.rst [new file with mode: 0644]
src/gallium/docs/source/tgsi.rst [new file with mode: 0644]
src/gallium/drivers/cell/ppu/cell_clear.c
src/gallium/drivers/cell/ppu/cell_draw_arrays.c
src/gallium/drivers/cell/ppu/cell_gen_fp.c
src/gallium/drivers/cell/ppu/cell_pipe_state.c
src/gallium/drivers/cell/ppu/cell_state_derived.c
src/gallium/drivers/cell/ppu/cell_state_emit.c
src/gallium/drivers/cell/ppu/cell_texture.c
src/gallium/drivers/cell/spu/spu_command.c
src/gallium/drivers/cell/spu/spu_exec.c
src/gallium/drivers/cell/spu/spu_util.c
src/gallium/drivers/failover/fo_context.c
src/gallium/drivers/failover/fo_context.h
src/gallium/drivers/failover/fo_state.c
src/gallium/drivers/failover/fo_state_emit.c
src/gallium/drivers/failover/fo_winsys.h
src/gallium/drivers/i915/i915_buffer.c
src/gallium/drivers/i915/i915_context.c
src/gallium/drivers/i915/i915_debug.c
src/gallium/drivers/i915/i915_fpc_translate.c
src/gallium/drivers/i915/i915_screen.c
src/gallium/drivers/i915/i915_state.c
src/gallium/drivers/i915/i915_state_derived.c
src/gallium/drivers/i915/i915_state_sampler.c
src/gallium/drivers/i915/i915_surface.c
src/gallium/drivers/i915/i915_texture.c
src/gallium/drivers/i915/intel_winsys.h
src/gallium/drivers/i965/Makefile [new file with mode: 0644]
src/gallium/drivers/i965/SConscript [new file with mode: 0644]
src/gallium/drivers/i965/brw_batchbuffer.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_batchbuffer.h [new file with mode: 0644]
src/gallium/drivers/i965/brw_cc.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_clip.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_clip.h [new file with mode: 0644]
src/gallium/drivers/i965/brw_clip_line.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_clip_point.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_clip_state.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_clip_tri.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_clip_unfilled.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_clip_util.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_context.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_context.h [new file with mode: 0644]
src/gallium/drivers/i965/brw_curbe.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_debug.h [new file with mode: 0644]
src/gallium/drivers/i965/brw_defines.h [new file with mode: 0644]
src/gallium/drivers/i965/brw_disasm.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_disasm.h [new file with mode: 0644]
src/gallium/drivers/i965/brw_draw.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_draw.h [new file with mode: 0644]
src/gallium/drivers/i965/brw_draw_upload.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_eu.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_eu.h [new file with mode: 0644]
src/gallium/drivers/i965/brw_eu_debug.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_eu_emit.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_eu_util.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_gs.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_gs.h [new file with mode: 0644]
src/gallium/drivers/i965/brw_gs_emit.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_gs_state.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_misc_state.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_pipe_blend.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_pipe_clear.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_pipe_depth.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_pipe_fb.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_pipe_flush.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_pipe_misc.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_pipe_query.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_pipe_rast.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_pipe_rast.h [new file with mode: 0644]
src/gallium/drivers/i965/brw_pipe_sampler.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_pipe_shader.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_pipe_vertex.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_reg.h [new file with mode: 0644]
src/gallium/drivers/i965/brw_screen.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_screen.h [new file with mode: 0644]
src/gallium/drivers/i965/brw_screen_buffers.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_screen_surface.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_screen_tex_layout.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_screen_texture.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_sf.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_sf.h [new file with mode: 0644]
src/gallium/drivers/i965/brw_sf_emit.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_sf_state.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_state.h [new file with mode: 0644]
src/gallium/drivers/i965/brw_state_batch.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_state_cache.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_state_debug.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_state_upload.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_structs.h [new file with mode: 0644]
src/gallium/drivers/i965/brw_structs_dump.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_structs_dump.h [new file with mode: 0644]
src/gallium/drivers/i965/brw_structs_dump.py [new file with mode: 0755]
src/gallium/drivers/i965/brw_swtnl.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_types.h [new file with mode: 0644]
src/gallium/drivers/i965/brw_urb.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_util.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_util.h [new file with mode: 0644]
src/gallium/drivers/i965/brw_vs.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_vs.h [new file with mode: 0644]
src/gallium/drivers/i965/brw_vs_emit.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_vs_state.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_vs_surface_state.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_winsys.h [new file with mode: 0644]
src/gallium/drivers/i965/brw_winsys_debug.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_wm.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_wm.h [new file with mode: 0644]
src/gallium/drivers/i965/brw_wm_constant_buffer.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_wm_debug.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_wm_emit.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_wm_fp.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_wm_glsl.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_wm_iz.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_wm_pass0.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_wm_pass1.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_wm_pass2.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_wm_sampler_state.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_wm_state.c [new file with mode: 0644]
src/gallium/drivers/i965/brw_wm_surface_state.c [new file with mode: 0644]
src/gallium/drivers/i965/intel_decode.c [new file with mode: 0644]
src/gallium/drivers/i965/intel_decode.h [new file with mode: 0644]
src/gallium/drivers/i965/intel_structs.h [new file with mode: 0644]
src/gallium/drivers/identity/id_context.c
src/gallium/drivers/identity/id_objects.c
src/gallium/drivers/identity/id_objects.h
src/gallium/drivers/identity/id_public.h
src/gallium/drivers/identity/id_screen.c
src/gallium/drivers/llvmpipe/Makefile
src/gallium/drivers/llvmpipe/README
src/gallium/drivers/llvmpipe/SConscript
src/gallium/drivers/llvmpipe/lp_bld_arit.c
src/gallium/drivers/llvmpipe/lp_bld_arit.h
src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
src/gallium/drivers/llvmpipe/lp_bld_const.h
src/gallium/drivers/llvmpipe/lp_bld_conv.c
src/gallium/drivers/llvmpipe/lp_bld_conv.h
src/gallium/drivers/llvmpipe/lp_bld_debug.c
src/gallium/drivers/llvmpipe/lp_bld_depth.c
src/gallium/drivers/llvmpipe/lp_bld_format.h
src/gallium/drivers/llvmpipe/lp_bld_format_aos.c
src/gallium/drivers/llvmpipe/lp_bld_format_query.c [new file with mode: 0644]
src/gallium/drivers/llvmpipe/lp_bld_format_soa.c
src/gallium/drivers/llvmpipe/lp_bld_interp.c
src/gallium/drivers/llvmpipe/lp_bld_logic.h
src/gallium/drivers/llvmpipe/lp_bld_misc.cpp [new file with mode: 0644]
src/gallium/drivers/llvmpipe/lp_bld_misc.h [new file with mode: 0644]
src/gallium/drivers/llvmpipe/lp_bld_pack.c [new file with mode: 0644]
src/gallium/drivers/llvmpipe/lp_bld_pack.h [new file with mode: 0644]
src/gallium/drivers/llvmpipe/lp_bld_sample.c [new file with mode: 0644]
src/gallium/drivers/llvmpipe/lp_bld_sample.h
src/gallium/drivers/llvmpipe/lp_bld_sample_soa.c
src/gallium/drivers/llvmpipe/lp_bld_swizzle.h
src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c
src/gallium/drivers/llvmpipe/lp_bld_type.c
src/gallium/drivers/llvmpipe/lp_bld_type.h
src/gallium/drivers/llvmpipe/lp_context.c
src/gallium/drivers/llvmpipe/lp_context.h
src/gallium/drivers/llvmpipe/lp_draw_arrays.c
src/gallium/drivers/llvmpipe/lp_fence.c
src/gallium/drivers/llvmpipe/lp_jit.c
src/gallium/drivers/llvmpipe/lp_jit.h
src/gallium/drivers/llvmpipe/lp_rast.c
src/gallium/drivers/llvmpipe/lp_screen.c
src/gallium/drivers/llvmpipe/lp_setup.c
src/gallium/drivers/llvmpipe/lp_setup_tri.c
src/gallium/drivers/llvmpipe/lp_state.h
src/gallium/drivers/llvmpipe/lp_state_blend.c
src/gallium/drivers/llvmpipe/lp_state_derived.c
src/gallium/drivers/llvmpipe/lp_state_fs.c
src/gallium/drivers/llvmpipe/lp_state_rasterizer.c
src/gallium/drivers/llvmpipe/lp_state_sampler.c
src/gallium/drivers/llvmpipe/lp_state_surface.c
src/gallium/drivers/llvmpipe/lp_state_vs.c
src/gallium/drivers/llvmpipe/lp_test.h
src/gallium/drivers/llvmpipe/lp_test_blend.c
src/gallium/drivers/llvmpipe/lp_test_conv.c
src/gallium/drivers/llvmpipe/lp_test_format.c
src/gallium/drivers/llvmpipe/lp_test_main.c
src/gallium/drivers/llvmpipe/lp_tex_sample.h
src/gallium/drivers/llvmpipe/lp_texture.c
src/gallium/drivers/llvmpipe/lp_tile_soa.h
src/gallium/drivers/llvmpipe/lp_winsys.h
src/gallium/drivers/nouveau/Makefile
src/gallium/drivers/nouveau/nouveau_context.c [new file with mode: 0644]
src/gallium/drivers/nouveau/nouveau_context.h [new file with mode: 0644]
src/gallium/drivers/nouveau/nouveau_push.h [deleted file]
src/gallium/drivers/nouveau/nouveau_screen.c
src/gallium/drivers/nouveau/nouveau_screen.h
src/gallium/drivers/nouveau/nouveau_stateobj.h
src/gallium/drivers/nouveau/nouveau_winsys.h
src/gallium/drivers/nv04/nv04_context.c
src/gallium/drivers/nv04/nv04_context.h
src/gallium/drivers/nv04/nv04_fragtex.c
src/gallium/drivers/nv04/nv04_miptree.c
src/gallium/drivers/nv04/nv04_prim_vbuf.c
src/gallium/drivers/nv04/nv04_screen.c
src/gallium/drivers/nv04/nv04_state.c
src/gallium/drivers/nv04/nv04_state.h
src/gallium/drivers/nv04/nv04_state_emit.c
src/gallium/drivers/nv04/nv04_surface_2d.c
src/gallium/drivers/nv04/nv04_surface_2d.h
src/gallium/drivers/nv04/nv04_transfer.c
src/gallium/drivers/nv04/nv04_vbo.c
src/gallium/drivers/nv10/nv10_context.c
src/gallium/drivers/nv10/nv10_context.h
src/gallium/drivers/nv10/nv10_fragtex.c
src/gallium/drivers/nv10/nv10_miptree.c
src/gallium/drivers/nv10/nv10_prim_vbuf.c
src/gallium/drivers/nv10/nv10_screen.c
src/gallium/drivers/nv10/nv10_state.c
src/gallium/drivers/nv10/nv10_state.h
src/gallium/drivers/nv10/nv10_state_emit.c
src/gallium/drivers/nv10/nv10_transfer.c
src/gallium/drivers/nv10/nv10_vbo.c
src/gallium/drivers/nv20/nv20_context.c
src/gallium/drivers/nv20/nv20_context.h
src/gallium/drivers/nv20/nv20_fragtex.c
src/gallium/drivers/nv20/nv20_miptree.c
src/gallium/drivers/nv20/nv20_prim_vbuf.c
src/gallium/drivers/nv20/nv20_screen.c
src/gallium/drivers/nv20/nv20_state.c
src/gallium/drivers/nv20/nv20_state.h
src/gallium/drivers/nv20/nv20_state_emit.c
src/gallium/drivers/nv20/nv20_transfer.c
src/gallium/drivers/nv20/nv20_vbo.c
src/gallium/drivers/nv20/nv20_vertprog.c
src/gallium/drivers/nv30/nv30_context.c
src/gallium/drivers/nv30/nv30_context.h
src/gallium/drivers/nv30/nv30_fragprog.c
src/gallium/drivers/nv30/nv30_fragtex.c
src/gallium/drivers/nv30/nv30_miptree.c
src/gallium/drivers/nv30/nv30_query.c
src/gallium/drivers/nv30/nv30_screen.c
src/gallium/drivers/nv30/nv30_state.c
src/gallium/drivers/nv30/nv30_state.h
src/gallium/drivers/nv30/nv30_state_blend.c
src/gallium/drivers/nv30/nv30_state_emit.c
src/gallium/drivers/nv30/nv30_state_fb.c
src/gallium/drivers/nv30/nv30_state_scissor.c
src/gallium/drivers/nv30/nv30_state_stipple.c
src/gallium/drivers/nv30/nv30_state_viewport.c
src/gallium/drivers/nv30/nv30_transfer.c
src/gallium/drivers/nv30/nv30_vbo.c
src/gallium/drivers/nv30/nv30_vertprog.c
src/gallium/drivers/nv40/nv40_context.c
src/gallium/drivers/nv40/nv40_context.h
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_miptree.c
src/gallium/drivers/nv40/nv40_query.c
src/gallium/drivers/nv40/nv40_screen.c
src/gallium/drivers/nv40/nv40_state.c
src/gallium/drivers/nv40/nv40_state.h
src/gallium/drivers/nv40/nv40_state_blend.c
src/gallium/drivers/nv40/nv40_state_emit.c
src/gallium/drivers/nv40/nv40_state_fb.c
src/gallium/drivers/nv40/nv40_state_scissor.c
src/gallium/drivers/nv40/nv40_state_stipple.c
src/gallium/drivers/nv40/nv40_state_viewport.c
src/gallium/drivers/nv40/nv40_transfer.c
src/gallium/drivers/nv40/nv40_vbo.c
src/gallium/drivers/nv40/nv40_vertprog.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_texture.h
src/gallium/drivers/nv50/nv50_transfer.c
src/gallium/drivers/nv50/nv50_vbo.c
src/gallium/drivers/r300/Makefile
src/gallium/drivers/r300/SConscript
src/gallium/drivers/r300/r300_blit.c [new file with mode: 0644]
src/gallium/drivers/r300/r300_blit.h [new file with mode: 0644]
src/gallium/drivers/r300/r300_chipset.c
src/gallium/drivers/r300/r300_chipset.h
src/gallium/drivers/r300/r300_clear.c [deleted file]
src/gallium/drivers/r300/r300_clear.h [deleted file]
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_emit.c
src/gallium/drivers/r300/r300_emit.h
src/gallium/drivers/r300/r300_flush.c
src/gallium/drivers/r300/r300_flush.h
src/gallium/drivers/r300/r300_fs.c
src/gallium/drivers/r300/r300_fs.h
src/gallium/drivers/r300/r300_query.c
src/gallium/drivers/r300/r300_query.h
src/gallium/drivers/r300/r300_reg.h
src/gallium/drivers/r300/r300_render.c
src/gallium/drivers/r300/r300_render.h [new file with mode: 0644]
src/gallium/drivers/r300/r300_screen.c
src/gallium/drivers/r300/r300_screen.h
src/gallium/drivers/r300/r300_shader_inlines.h [deleted file]
src/gallium/drivers/r300/r300_shader_semantics.h [new file with mode: 0644]
src/gallium/drivers/r300/r300_state.c
src/gallium/drivers/r300/r300_state_derived.c
src/gallium/drivers/r300/r300_state_derived.h
src/gallium/drivers/r300/r300_state_inlines.h
src/gallium/drivers/r300/r300_state_invariant.c
src/gallium/drivers/r300/r300_state_invariant.h
src/gallium/drivers/r300/r300_surface.c [deleted file]
src/gallium/drivers/r300/r300_surface.h [deleted file]
src/gallium/drivers/r300/r300_texture.c
src/gallium/drivers/r300/r300_texture.h
src/gallium/drivers/r300/r300_tgsi_to_rc.c
src/gallium/drivers/r300/r300_vs.c
src/gallium/drivers/r300/r300_vs.h
src/gallium/drivers/r300/r300_winsys.h
src/gallium/drivers/r300/r3xx_fs.c [deleted file]
src/gallium/drivers/r300/r3xx_fs.h [deleted file]
src/gallium/drivers/r300/r5xx_fs.c [deleted file]
src/gallium/drivers/r300/r5xx_fs.h [deleted file]
src/gallium/drivers/softpipe/sp_clear.c
src/gallium/drivers/softpipe/sp_context.c
src/gallium/drivers/softpipe/sp_context.h
src/gallium/drivers/softpipe/sp_draw_arrays.c
src/gallium/drivers/softpipe/sp_flush.c
src/gallium/drivers/softpipe/sp_fs_exec.c
src/gallium/drivers/softpipe/sp_prim_vbuf.c
src/gallium/drivers/softpipe/sp_quad_blend.c
src/gallium/drivers/softpipe/sp_query.c
src/gallium/drivers/softpipe/sp_query.h
src/gallium/drivers/softpipe/sp_screen.c
src/gallium/drivers/softpipe/sp_setup.c
src/gallium/drivers/softpipe/sp_state.h
src/gallium/drivers/softpipe/sp_state_blend.c
src/gallium/drivers/softpipe/sp_state_derived.c
src/gallium/drivers/softpipe/sp_state_fs.c
src/gallium/drivers/softpipe/sp_state_rasterizer.c
src/gallium/drivers/softpipe/sp_state_sampler.c
src/gallium/drivers/softpipe/sp_state_surface.c
src/gallium/drivers/softpipe/sp_tex_sample.c
src/gallium/drivers/softpipe/sp_tex_sample.h
src/gallium/drivers/softpipe/sp_tex_tile_cache.c
src/gallium/drivers/softpipe/sp_texture.c
src/gallium/drivers/softpipe/sp_tile_cache.c
src/gallium/drivers/softpipe/sp_winsys.h
src/gallium/drivers/svga/Makefile [new file with mode: 0644]
src/gallium/drivers/svga/SConscript [new file with mode: 0644]
src/gallium/drivers/svga/include/README [new file with mode: 0644]
src/gallium/drivers/svga/include/svga3d_caps.h [new file with mode: 0644]
src/gallium/drivers/svga/include/svga3d_reg.h [new file with mode: 0644]
src/gallium/drivers/svga/include/svga3d_shaderdefs.h [new file with mode: 0644]
src/gallium/drivers/svga/include/svga_escape.h [new file with mode: 0644]
src/gallium/drivers/svga/include/svga_overlay.h [new file with mode: 0644]
src/gallium/drivers/svga/include/svga_reg.h [new file with mode: 0644]
src/gallium/drivers/svga/include/svga_types.h [new file with mode: 0644]
src/gallium/drivers/svga/svga_cmd.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_cmd.h [new file with mode: 0644]
src/gallium/drivers/svga/svga_context.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_context.h [new file with mode: 0644]
src/gallium/drivers/svga/svga_debug.h [new file with mode: 0644]
src/gallium/drivers/svga/svga_draw.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_draw.h [new file with mode: 0644]
src/gallium/drivers/svga/svga_draw_arrays.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_draw_elements.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_draw_private.h [new file with mode: 0644]
src/gallium/drivers/svga/svga_hw_reg.h [new file with mode: 0644]
src/gallium/drivers/svga/svga_pipe_blend.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_pipe_blit.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_pipe_clear.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_pipe_constants.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_pipe_depthstencil.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_pipe_draw.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_pipe_flush.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_pipe_fs.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_pipe_misc.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_pipe_query.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_pipe_rasterizer.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_pipe_sampler.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_pipe_vertex.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_pipe_vs.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_screen.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_screen.h [new file with mode: 0644]
src/gallium/drivers/svga/svga_screen_buffer.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_screen_buffer.h [new file with mode: 0644]
src/gallium/drivers/svga/svga_screen_cache.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_screen_cache.h [new file with mode: 0644]
src/gallium/drivers/svga/svga_screen_texture.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_screen_texture.h [new file with mode: 0644]
src/gallium/drivers/svga/svga_state.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_state.h [new file with mode: 0644]
src/gallium/drivers/svga/svga_state_constants.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_state_framebuffer.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_state_fs.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_state_need_swtnl.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_state_rss.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_state_tss.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_state_vdecl.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_state_vs.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_swtnl.h [new file with mode: 0644]
src/gallium/drivers/svga/svga_swtnl_backend.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_swtnl_draw.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_swtnl_private.h [new file with mode: 0644]
src/gallium/drivers/svga/svga_swtnl_state.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_tgsi.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_tgsi.h [new file with mode: 0644]
src/gallium/drivers/svga/svga_tgsi_decl_sm20.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_tgsi_decl_sm30.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_tgsi_emit.h [new file with mode: 0644]
src/gallium/drivers/svga/svga_tgsi_insn.c [new file with mode: 0644]
src/gallium/drivers/svga/svga_winsys.h [new file with mode: 0644]
src/gallium/drivers/svga/svgadump/svga_dump.c [new file with mode: 0644]
src/gallium/drivers/svga/svgadump/svga_dump.h [new file with mode: 0644]
src/gallium/drivers/svga/svgadump/svga_dump.py [new file with mode: 0755]
src/gallium/drivers/svga/svgadump/svga_shader.h [new file with mode: 0644]
src/gallium/drivers/svga/svgadump/svga_shader_dump.c [new file with mode: 0644]
src/gallium/drivers/svga/svgadump/svga_shader_dump.h [new file with mode: 0644]
src/gallium/drivers/svga/svgadump/svga_shader_op.c [new file with mode: 0644]
src/gallium/drivers/svga/svgadump/svga_shader_op.h [new file with mode: 0644]
src/gallium/drivers/trace/README
src/gallium/drivers/trace/tr_context.c
src/gallium/drivers/trace/tr_context.h
src/gallium/drivers/trace/tr_drm.c
src/gallium/drivers/trace/tr_dump.c
src/gallium/drivers/trace/tr_dump_state.c
src/gallium/drivers/trace/tr_dump_state.h
src/gallium/drivers/trace/tr_rbug.c
src/gallium/drivers/trace/tr_screen.c
src/gallium/drivers/trace/tr_state.h
src/gallium/include/pipe/p_compiler.h
src/gallium/include/pipe/p_config.h
src/gallium/include/pipe/p_context.h
src/gallium/include/pipe/p_defines.h
src/gallium/include/pipe/p_error.h [deleted file]
src/gallium/include/pipe/p_format.h
src/gallium/include/pipe/p_refcnt.h
src/gallium/include/pipe/p_shader_tokens.h
src/gallium/include/pipe/p_state.h
src/gallium/include/pipe/p_video_state.h
src/gallium/state_trackers/dri/dri_context.c
src/gallium/state_trackers/dri/dri_context.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/dri/dri_screen.c
src/gallium/state_trackers/dri/dri_screen.h
src/gallium/state_trackers/egl/egl_context.c
src/gallium/state_trackers/egl/egl_surface.c
src/gallium/state_trackers/egl/egl_tracker.c
src/gallium/state_trackers/glx/xlib/glx_api.c
src/gallium/state_trackers/glx/xlib/xm_api.c
src/gallium/state_trackers/python/SConscript
src/gallium/state_trackers/python/gallium.i
src/gallium/state_trackers/python/p_context.i
src/gallium/state_trackers/python/p_device.i
src/gallium/state_trackers/python/p_format.i
src/gallium/state_trackers/python/p_texture.i
src/gallium/state_trackers/python/retrace/interpreter.py
src/gallium/state_trackers/python/samples/gs.py [new file with mode: 0644]
src/gallium/state_trackers/python/samples/tri.py
src/gallium/state_trackers/python/st_device.c
src/gallium/state_trackers/python/st_device.h
src/gallium/state_trackers/python/st_sample.c
src/gallium/state_trackers/python/st_sample.h
src/gallium/state_trackers/python/st_softpipe_winsys.c
src/gallium/state_trackers/python/tests/base.py
src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-abs.sh
src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-add.sh
src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-dp3.sh
src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-dp4.sh
src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-dst.sh
src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-ex2.sh
src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-flr.sh
src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-frc.sh
src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-lg2.sh
src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-lit.sh
src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-lrp.sh
src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-mad.sh
src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-max.sh
src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-min.sh
src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-mov.sh
src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-mul.sh
src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-rcp.sh
src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-rsq.sh
src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-sge.sh
src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-srcmod-abs.sh
src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-srcmod-absneg.sh
src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-srcmod-neg.sh
src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-srcmod-swz.sh
src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-sub.sh
src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-xpd.sh
src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py
src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-abs.sh
src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-add.sh
src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-arl.sh
src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-arr.sh
src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp3.sh
src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp4.sh
src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dst.sh
src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-ex2.sh
src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-flr.sh
src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-frc.sh
src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-lg2.sh
src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-lit.sh
src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-lrp.sh
src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mad.sh
src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-max.sh
src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-min.sh
src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mov.sh
src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mul.sh
src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-rcp.sh
src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-rsq.sh
src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-sge.sh
src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-slt.sh
src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-srcmod-abs.sh
src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-srcmod-absneg.sh
src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-srcmod-neg.sh
src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-srcmod-swz.sh
src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-sub.sh
src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-xpd.sh
src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py
src/gallium/state_trackers/python/tests/surface_copy.py
src/gallium/state_trackers/python/tests/texture_render.py
src/gallium/state_trackers/python/tests/texture_sample.py
src/gallium/state_trackers/python/tests/texture_transfer.py
src/gallium/state_trackers/vega/Makefile
src/gallium/state_trackers/vega/api_filters.c
src/gallium/state_trackers/vega/api_path.c
src/gallium/state_trackers/vega/arc.c
src/gallium/state_trackers/vega/asm_filters.h
src/gallium/state_trackers/vega/asm_util.h
src/gallium/state_trackers/vega/bezier.c
src/gallium/state_trackers/vega/image.c
src/gallium/state_trackers/vega/mask.c
src/gallium/state_trackers/vega/paint.c
src/gallium/state_trackers/vega/renderer.c
src/gallium/state_trackers/vega/shaders_cache.c
src/gallium/state_trackers/vega/stroker.c
src/gallium/state_trackers/vega/vg_context.c
src/gallium/state_trackers/vega/vg_tracker.c
src/gallium/state_trackers/vega/vg_translate.c
src/gallium/state_trackers/wgl/SConscript
src/gallium/state_trackers/wgl/stw_device.c
src/gallium/state_trackers/wgl/stw_framebuffer.c
src/gallium/state_trackers/wgl/stw_framebuffer.h
src/gallium/state_trackers/wgl/stw_pixelformat.c
src/gallium/state_trackers/wgl/stw_winsys.h
src/gallium/state_trackers/xorg/Makefile
src/gallium/state_trackers/xorg/SConscript
src/gallium/state_trackers/xorg/xorg_composite.c
src/gallium/state_trackers/xorg/xorg_composite.h
src/gallium/state_trackers/xorg/xorg_crtc.c
src/gallium/state_trackers/xorg/xorg_dri2.c
src/gallium/state_trackers/xorg/xorg_driver.c
src/gallium/state_trackers/xorg/xorg_exa.c
src/gallium/state_trackers/xorg/xorg_exa.h
src/gallium/state_trackers/xorg/xorg_exa_tgsi.c
src/gallium/state_trackers/xorg/xorg_exa_tgsi.h
src/gallium/state_trackers/xorg/xorg_output.c
src/gallium/state_trackers/xorg/xorg_renderer.c [new file with mode: 0644]
src/gallium/state_trackers/xorg/xorg_renderer.h [new file with mode: 0644]
src/gallium/state_trackers/xorg/xorg_tracker.h
src/gallium/state_trackers/xorg/xorg_xv.c
src/gallium/state_trackers/xorg/xvmc/context.c
src/gallium/state_trackers/xorg/xvmc/surface.c
src/gallium/winsys/drm/SConscript
src/gallium/winsys/drm/i965/Makefile [new file with mode: 0644]
src/gallium/winsys/drm/i965/SConscript [new file with mode: 0644]
src/gallium/winsys/drm/i965/dri/Makefile [new file with mode: 0644]
src/gallium/winsys/drm/i965/dri/SConscript [new file with mode: 0644]
src/gallium/winsys/drm/i965/egl/Makefile [new file with mode: 0644]
src/gallium/winsys/drm/i965/gem/Makefile [new file with mode: 0644]
src/gallium/winsys/drm/i965/gem/SConscript [new file with mode: 0644]
src/gallium/winsys/drm/i965/gem/i965_drm_api.c [new file with mode: 0644]
src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c [new file with mode: 0644]
src/gallium/winsys/drm/i965/gem/i965_drm_winsys.h [new file with mode: 0644]
src/gallium/winsys/drm/i965/xlib/Makefile [new file with mode: 0644]
src/gallium/winsys/drm/i965/xlib/xlib_i965.c [new file with mode: 0644]
src/gallium/winsys/drm/i965/xorg/Makefile [new file with mode: 0644]
src/gallium/winsys/drm/i965/xorg/intel_xorg.c [new file with mode: 0644]
src/gallium/winsys/drm/intel/dri/Makefile
src/gallium/winsys/drm/intel/dri/SConscript
src/gallium/winsys/drm/intel/gem/intel_drm_api.c
src/gallium/winsys/drm/intel/gem/intel_drm_fence.c
src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c
src/gallium/winsys/drm/radeon/core/Makefile
src/gallium/winsys/drm/radeon/core/SConscript
src/gallium/winsys/drm/radeon/core/radeon_buffer.c
src/gallium/winsys/drm/radeon/core/radeon_buffer.h
src/gallium/winsys/drm/radeon/core/radeon_drm.c
src/gallium/winsys/drm/radeon/core/radeon_drm.h
src/gallium/winsys/drm/radeon/core/radeon_r300.c
src/gallium/winsys/drm/radeon/core/radeon_r300.h
src/gallium/winsys/drm/radeon/core/radeon_winsys.h [new file with mode: 0644]
src/gallium/winsys/drm/radeon/core/radeon_winsys_softpipe.c [deleted file]
src/gallium/winsys/drm/radeon/core/radeon_winsys_softpipe.h [deleted file]
src/gallium/winsys/drm/radeon/dri/SConscript
src/gallium/winsys/drm/radeon/python/SConscript
src/gallium/winsys/drm/radeon/xorg/Makefile
src/gallium/winsys/drm/radeon/xorg/radeon_xorg.c
src/gallium/winsys/drm/vmware/Makefile [new file with mode: 0644]
src/gallium/winsys/drm/vmware/SConscript [new file with mode: 0644]
src/gallium/winsys/drm/vmware/core/Makefile [new file with mode: 0644]
src/gallium/winsys/drm/vmware/core/SConscript [new file with mode: 0644]
src/gallium/winsys/drm/vmware/core/vmw_buffer.c [new file with mode: 0644]
src/gallium/winsys/drm/vmware/core/vmw_buffer.h [new file with mode: 0644]
src/gallium/winsys/drm/vmware/core/vmw_context.c [new file with mode: 0644]
src/gallium/winsys/drm/vmware/core/vmw_context.h [new file with mode: 0644]
src/gallium/winsys/drm/vmware/core/vmw_fence.c [new file with mode: 0644]
src/gallium/winsys/drm/vmware/core/vmw_fence.h [new file with mode: 0644]
src/gallium/winsys/drm/vmware/core/vmw_screen.c [new file with mode: 0644]
src/gallium/winsys/drm/vmware/core/vmw_screen.h [new file with mode: 0644]
src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c [new file with mode: 0644]
src/gallium/winsys/drm/vmware/core/vmw_screen_ioctl.c [new file with mode: 0644]
src/gallium/winsys/drm/vmware/core/vmw_screen_pools.c [new file with mode: 0644]
src/gallium/winsys/drm/vmware/core/vmw_screen_svga.c [new file with mode: 0644]
src/gallium/winsys/drm/vmware/core/vmw_surface.c [new file with mode: 0644]
src/gallium/winsys/drm/vmware/core/vmw_surface.h [new file with mode: 0644]
src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h [new file with mode: 0644]
src/gallium/winsys/drm/vmware/dri/Makefile [new file with mode: 0644]
src/gallium/winsys/drm/vmware/dri/SConscript [new file with mode: 0644]
src/gallium/winsys/drm/vmware/egl/Makefile [new file with mode: 0644]
src/gallium/winsys/drm/vmware/xorg/Makefile [new file with mode: 0644]
src/gallium/winsys/drm/vmware/xorg/SConscript [new file with mode: 0644]
src/gallium/winsys/drm/vmware/xorg/vmw_driver.h [new file with mode: 0644]
src/gallium/winsys/drm/vmware/xorg/vmw_hook.h [new file with mode: 0644]
src/gallium/winsys/drm/vmware/xorg/vmw_ioctl.c [new file with mode: 0644]
src/gallium/winsys/drm/vmware/xorg/vmw_screen.c [new file with mode: 0644]
src/gallium/winsys/drm/vmware/xorg/vmw_video.c [new file with mode: 0644]
src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c [new file with mode: 0644]
src/gallium/winsys/egl_xlib/egl_xlib.c
src/gallium/winsys/egl_xlib/sw_winsys.c
src/gallium/winsys/g3dvl/nouveau/Makefile
src/gallium/winsys/g3dvl/vl_winsys.h
src/gallium/winsys/g3dvl/xlib/Makefile
src/gallium/winsys/g3dvl/xlib/xsp_winsys.c
src/gallium/winsys/gdi/SConscript
src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c
src/gallium/winsys/gdi/gdi_softpipe_winsys.c
src/gallium/winsys/xlib/Makefile
src/gallium/winsys/xlib/SConscript
src/gallium/winsys/xlib/xlib.c
src/gallium/winsys/xlib/xlib.h
src/gallium/winsys/xlib/xlib_brw_context.c [new file with mode: 0644]
src/gallium/winsys/xlib/xlib_cell.c
src/gallium/winsys/xlib/xlib_llvmpipe.c
src/gallium/winsys/xlib/xlib_softpipe.c
src/gallium/winsys/xlib/xlib_trace.c [deleted file]
src/glew/SConscript
src/glew/glew.c
src/glew/glewinfo.c
src/glew/visualinfo.c
src/glsl/Makefile [new file with mode: 0644]
src/glsl/Makefile.template [new file with mode: 0644]
src/glsl/SConscript [new file with mode: 0644]
src/glsl/apps/.gitignore [new file with mode: 0644]
src/glsl/apps/Makefile [new file with mode: 0644]
src/glsl/apps/compile.c [new file with mode: 0644]
src/glsl/apps/process.c [new file with mode: 0644]
src/glsl/apps/purify.c [new file with mode: 0644]
src/glsl/apps/tokenise.c [new file with mode: 0644]
src/glsl/apps/version.c [new file with mode: 0644]
src/glsl/cl/Makefile [new file with mode: 0644]
src/glsl/cl/sl_cl_parse.c [new file with mode: 0644]
src/glsl/cl/sl_cl_parse.h [new file with mode: 0644]
src/glsl/pp/Makefile [new file with mode: 0644]
src/glsl/pp/sl_pp_context.c [new file with mode: 0644]
src/glsl/pp/sl_pp_context.h [new file with mode: 0644]
src/glsl/pp/sl_pp_define.c [new file with mode: 0644]
src/glsl/pp/sl_pp_dict.c [new file with mode: 0644]
src/glsl/pp/sl_pp_dict.h [new file with mode: 0644]
src/glsl/pp/sl_pp_error.c [new file with mode: 0644]
src/glsl/pp/sl_pp_expression.c [new file with mode: 0644]
src/glsl/pp/sl_pp_expression.h [new file with mode: 0644]
src/glsl/pp/sl_pp_extension.c [new file with mode: 0644]
src/glsl/pp/sl_pp_if.c [new file with mode: 0644]
src/glsl/pp/sl_pp_line.c [new file with mode: 0644]
src/glsl/pp/sl_pp_macro.c [new file with mode: 0644]
src/glsl/pp/sl_pp_macro.h [new file with mode: 0644]
src/glsl/pp/sl_pp_pragma.c [new file with mode: 0644]
src/glsl/pp/sl_pp_process.c [new file with mode: 0644]
src/glsl/pp/sl_pp_process.h [new file with mode: 0644]
src/glsl/pp/sl_pp_public.h [new file with mode: 0644]
src/glsl/pp/sl_pp_purify.c [new file with mode: 0644]
src/glsl/pp/sl_pp_purify.h [new file with mode: 0644]
src/glsl/pp/sl_pp_token.c [new file with mode: 0644]
src/glsl/pp/sl_pp_token.h [new file with mode: 0644]
src/glsl/pp/sl_pp_token_util.c [new file with mode: 0644]
src/glsl/pp/sl_pp_token_util.h [new file with mode: 0644]
src/glsl/pp/sl_pp_version.c [new file with mode: 0644]
src/glu/sgi/libnurbs/internals/arcsorter.h
src/glu/sgi/libnurbs/internals/displaylist.h
src/glu/sgi/libnurbs/internals/gridvertex.h
src/glu/sgi/libnurbs/internals/knotvector.cc
src/glu/sgi/libnurbs/internals/reader.h
src/glu/sgi/libnurbs/internals/subdivider.cc
src/glu/sgi/libnurbs/internals/varray.cc
src/glu/sgi/libnurbs/nurbtess/directedLine.cc
src/glu/sgi/libnurbs/nurbtess/monoChain.cc
src/glu/sgi/libnurbs/nurbtess/partitionY.cc
src/glu/sgi/libnurbs/nurbtess/sampleCompBot.cc
src/glu/sgi/libnurbs/nurbtess/sampleCompTop.cc
src/glu/sgi/libnurbs/nurbtess/sampledLine.cc
src/glu/sgi/libtess/mesh.c
src/glu/sgi/libutil/mipmap.c
src/glut/glx/SConscript
src/glut/glx/capturexfont.c
src/glut/glx/glut_8x13.c
src/glut/glx/glut_9x15.c
src/glut/glx/glut_hel10.c
src/glut/glx/glut_hel12.c
src/glut/glx/glut_hel18.c
src/glut/glx/glut_menu.c
src/glut/glx/glut_mroman.c
src/glut/glx/glut_roman.c
src/glut/glx/glut_tr10.c
src/glut/glx/glut_tr24.c
src/glut/glx/glutstroke.h
src/glx/mini/miniglx.c
src/glx/x11/dri2.c
src/glx/x11/dri_glx.c
src/glx/x11/drisw_glx.c
src/glx/x11/glxcmds.c
src/glx/x11/glxcurrent.c
src/glx/x11/glxext.c
src/glx/x11/glxextensions.c
src/glx/x11/glxextensions.h
src/glx/x11/indirect.c
src/glx/x11/indirect.h
src/glx/x11/indirect_init.c
src/glx/x11/xf86dri.h
src/mesa/Makefile
src/mesa/Makefile.mgw
src/mesa/SConscript
src/mesa/drivers/common/driverfuncs.c
src/mesa/drivers/common/meta.c
src/mesa/drivers/directfb/idirectfbgl_mesa.c
src/mesa/drivers/dri/Makefile
src/mesa/drivers/dri/Makefile.template
src/mesa/drivers/dri/common/dri_util.c
src/mesa/drivers/dri/common/dri_util.h
src/mesa/drivers/dri/common/drirenderbuffer.c
src/mesa/drivers/dri/common/drirenderbuffer.h
src/mesa/drivers/dri/common/extension_helper.h [deleted file]
src/mesa/drivers/dri/common/spantmp2.h
src/mesa/drivers/dri/common/texmem.c
src/mesa/drivers/dri/common/texmem.h
src/mesa/drivers/dri/common/utils.c
src/mesa/drivers/dri/common/utils.h
src/mesa/drivers/dri/common/vblank.c
src/mesa/drivers/dri/common/vblank.h
src/mesa/drivers/dri/fb/Makefile
src/mesa/drivers/dri/fb/fb_dri.c
src/mesa/drivers/dri/fb/fb_egl.c
src/mesa/drivers/dri/ffb/Makefile
src/mesa/drivers/dri/ffb/ffb_bitmap.c
src/mesa/drivers/dri/ffb/ffb_clear.c
src/mesa/drivers/dri/ffb/ffb_context.h
src/mesa/drivers/dri/ffb/ffb_depth.c
src/mesa/drivers/dri/ffb/ffb_span.c
src/mesa/drivers/dri/ffb/ffb_state.c
src/mesa/drivers/dri/ffb/ffb_stencil.c
src/mesa/drivers/dri/ffb/ffb_tris.c
src/mesa/drivers/dri/ffb/ffb_vbtmp.h
src/mesa/drivers/dri/ffb/ffb_xmesa.c
src/mesa/drivers/dri/ffb/ffb_xmesa.h
src/mesa/drivers/dri/gamma/Makefile
src/mesa/drivers/dri/gamma/gamma_context.c
src/mesa/drivers/dri/gamma/gamma_context.h
src/mesa/drivers/dri/gamma/gamma_lock.c
src/mesa/drivers/dri/gamma/gamma_macros.h
src/mesa/drivers/dri/gamma/gamma_render.c
src/mesa/drivers/dri/gamma/gamma_screen.c
src/mesa/drivers/dri/gamma/gamma_screen.h
src/mesa/drivers/dri/gamma/gamma_span.c
src/mesa/drivers/dri/gamma/gamma_state.c
src/mesa/drivers/dri/gamma/gamma_tex.c
src/mesa/drivers/dri/gamma/gamma_xmesa.c
src/mesa/drivers/dri/i810/Makefile
src/mesa/drivers/dri/i810/i810context.c
src/mesa/drivers/dri/i810/i810context.h
src/mesa/drivers/dri/i810/i810ioctl.c
src/mesa/drivers/dri/i810/i810ioctl.h
src/mesa/drivers/dri/i810/i810screen.c
src/mesa/drivers/dri/i810/i810screen.h
src/mesa/drivers/dri/i810/i810span.c
src/mesa/drivers/dri/i810/i810state.c
src/mesa/drivers/dri/i810/i810tex.c
src/mesa/drivers/dri/i810/i810tex.h
src/mesa/drivers/dri/i810/i810texmem.c
src/mesa/drivers/dri/i810/i810texstate.c
src/mesa/drivers/dri/i810/i810tris.c
src/mesa/drivers/dri/i915/Makefile
src/mesa/drivers/dri/i915/i830_context.c
src/mesa/drivers/dri/i915/i830_context.h
src/mesa/drivers/dri/i915/i830_state.c
src/mesa/drivers/dri/i915/i830_texblend.c
src/mesa/drivers/dri/i915/i830_texstate.c
src/mesa/drivers/dri/i915/i830_vtbl.c
src/mesa/drivers/dri/i915/i915_context.c
src/mesa/drivers/dri/i915/i915_context.h
src/mesa/drivers/dri/i915/i915_debug.c
src/mesa/drivers/dri/i915/i915_fragprog.c
src/mesa/drivers/dri/i915/i915_program.c
src/mesa/drivers/dri/i915/i915_reg.h
src/mesa/drivers/dri/i915/i915_state.c
src/mesa/drivers/dri/i915/i915_texstate.c
src/mesa/drivers/dri/i915/i915_vtbl.c
src/mesa/drivers/dri/i915/intel_render.c
src/mesa/drivers/dri/i915/intel_swapbuffers.c [deleted symlink]
src/mesa/drivers/dri/i915/intel_tris.c
src/mesa/drivers/dri/i965/Makefile
src/mesa/drivers/dri/i965/brw_cc.c
src/mesa/drivers/dri/i965/brw_clip.c
src/mesa/drivers/dri/i965/brw_clip.h
src/mesa/drivers/dri/i965/brw_clip_line.c
src/mesa/drivers/dri/i965/brw_clip_state.c
src/mesa/drivers/dri/i965/brw_clip_tri.c
src/mesa/drivers/dri/i965/brw_clip_util.c
src/mesa/drivers/dri/i965/brw_context.c
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_curbe.c
src/mesa/drivers/dri/i965/brw_defines.h
src/mesa/drivers/dri/i965/brw_disasm.c
src/mesa/drivers/dri/i965/brw_draw.c
src/mesa/drivers/dri/i965/brw_draw_upload.c
src/mesa/drivers/dri/i965/brw_eu.h
src/mesa/drivers/dri/i965/brw_eu_emit.c
src/mesa/drivers/dri/i965/brw_fallback.c
src/mesa/drivers/dri/i965/brw_gs.c
src/mesa/drivers/dri/i965/brw_gs.h
src/mesa/drivers/dri/i965/brw_gs_emit.c
src/mesa/drivers/dri/i965/brw_gs_state.c
src/mesa/drivers/dri/i965/brw_misc_state.c
src/mesa/drivers/dri/i965/brw_queryobj.c
src/mesa/drivers/dri/i965/brw_sf.c
src/mesa/drivers/dri/i965/brw_sf.h
src/mesa/drivers/dri/i965/brw_sf_emit.c
src/mesa/drivers/dri/i965/brw_sf_state.c
src/mesa/drivers/dri/i965/brw_state.h
src/mesa/drivers/dri/i965/brw_state_batch.c
src/mesa/drivers/dri/i965/brw_state_cache.c
src/mesa/drivers/dri/i965/brw_state_upload.c
src/mesa/drivers/dri/i965/brw_tex_layout.c
src/mesa/drivers/dri/i965/brw_urb.c
src/mesa/drivers/dri/i965/brw_util.c
src/mesa/drivers/dri/i965/brw_util.h
src/mesa/drivers/dri/i965/brw_vs.c
src/mesa/drivers/dri/i965/brw_vs_emit.c
src/mesa/drivers/dri/i965/brw_vs_state.c
src/mesa/drivers/dri/i965/brw_vs_surface_state.c
src/mesa/drivers/dri/i965/brw_vtbl.c
src/mesa/drivers/dri/i965/brw_wm.c
src/mesa/drivers/dri/i965/brw_wm.h
src/mesa/drivers/dri/i965/brw_wm_emit.c
src/mesa/drivers/dri/i965/brw_wm_fp.c
src/mesa/drivers/dri/i965/brw_wm_glsl.c
src/mesa/drivers/dri/i965/brw_wm_pass0.c
src/mesa/drivers/dri/i965/brw_wm_pass2.c
src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
src/mesa/drivers/dri/i965/brw_wm_state.c
src/mesa/drivers/dri/i965/brw_wm_surface_state.c
src/mesa/drivers/dri/i965/intel_swapbuffers.c [deleted symlink]
src/mesa/drivers/dri/intel/intel_batchbuffer.c
src/mesa/drivers/dri/intel/intel_batchbuffer.h
src/mesa/drivers/dri/intel/intel_blit.c
src/mesa/drivers/dri/intel/intel_blit.h
src/mesa/drivers/dri/intel/intel_buffer_objects.c
src/mesa/drivers/dri/intel/intel_buffers.c
src/mesa/drivers/dri/intel/intel_buffers.h
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_depthtmp.h
src/mesa/drivers/dri/intel/intel_extensions.c
src/mesa/drivers/dri/intel/intel_extensions.h
src/mesa/drivers/dri/intel/intel_fbo.c
src/mesa/drivers/dri/intel/intel_fbo.h
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_bitmap.c
src/mesa/drivers/dri/intel/intel_pixel_copy.c
src/mesa/drivers/dri/intel/intel_pixel_draw.c
src/mesa/drivers/dri/intel/intel_pixel_read.c
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_screen.h
src/mesa/drivers/dri/intel/intel_span.c
src/mesa/drivers/dri/intel/intel_spantmp.h
src/mesa/drivers/dri/intel/intel_state.c
src/mesa/drivers/dri/intel/intel_swapbuffers.c [deleted file]
src/mesa/drivers/dri/intel/intel_swapbuffers.h [deleted file]
src/mesa/drivers/dri/intel/intel_syncobj.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_format.c
src/mesa/drivers/dri/intel/intel_tex_image.c
src/mesa/drivers/dri/intel/intel_tex_layout.h
src/mesa/drivers/dri/intel/intel_tex_obj.h
src/mesa/drivers/dri/intel/intel_tex_subimage.c
src/mesa/drivers/dri/intel/intel_tex_validate.c
src/mesa/drivers/dri/mach64/Makefile
src/mesa/drivers/dri/mach64/mach64_context.c
src/mesa/drivers/dri/mach64/mach64_context.h
src/mesa/drivers/dri/mach64/mach64_ioctl.c
src/mesa/drivers/dri/mach64/mach64_ioctl.h
src/mesa/drivers/dri/mach64/mach64_lock.c
src/mesa/drivers/dri/mach64/mach64_native_vb.c
src/mesa/drivers/dri/mach64/mach64_native_vbtmp.h
src/mesa/drivers/dri/mach64/mach64_screen.c
src/mesa/drivers/dri/mach64/mach64_screen.h
src/mesa/drivers/dri/mach64/mach64_span.c
src/mesa/drivers/dri/mach64/mach64_state.c
src/mesa/drivers/dri/mach64/mach64_tex.c
src/mesa/drivers/dri/mach64/mach64_texmem.c
src/mesa/drivers/dri/mach64/mach64_texstate.c
src/mesa/drivers/dri/mach64/mach64_tris.c
src/mesa/drivers/dri/mach64/mach64_vbtmp.h
src/mesa/drivers/dri/mga/Makefile
src/mesa/drivers/dri/mga/mga_texstate.c
src/mesa/drivers/dri/mga/mga_xmesa.c
src/mesa/drivers/dri/mga/mga_xmesa.h
src/mesa/drivers/dri/mga/mgacontext.h
src/mesa/drivers/dri/mga/mgaioctl.c
src/mesa/drivers/dri/mga/mgaioctl.h
src/mesa/drivers/dri/mga/mgapixel.c
src/mesa/drivers/dri/mga/mgaspan.c
src/mesa/drivers/dri/mga/mgastate.c
src/mesa/drivers/dri/mga/mgatex.c
src/mesa/drivers/dri/mga/mgatexmem.c
src/mesa/drivers/dri/mga/mgatris.c
src/mesa/drivers/dri/r128/Makefile
src/mesa/drivers/dri/r128/r128_context.c
src/mesa/drivers/dri/r128/r128_context.h
src/mesa/drivers/dri/r128/r128_ioctl.c
src/mesa/drivers/dri/r128/r128_ioctl.h
src/mesa/drivers/dri/r128/r128_lock.c
src/mesa/drivers/dri/r128/r128_screen.c
src/mesa/drivers/dri/r128/r128_screen.h
src/mesa/drivers/dri/r128/r128_span.c
src/mesa/drivers/dri/r128/r128_state.c
src/mesa/drivers/dri/r128/r128_tex.c
src/mesa/drivers/dri/r128/r128_texmem.c
src/mesa/drivers/dri/r128/r128_texstate.c
src/mesa/drivers/dri/r128/r128_tris.c
src/mesa/drivers/dri/r200/Makefile
src/mesa/drivers/dri/r200/r200_context.c
src/mesa/drivers/dri/r200/r200_context.h
src/mesa/drivers/dri/r200/r200_ioctl.c
src/mesa/drivers/dri/r200/r200_maos_arrays.c
src/mesa/drivers/dri/r200/r200_pixel.c
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_tcl.c
src/mesa/drivers/dri/r200/r200_tex.c
src/mesa/drivers/dri/r200/r200_texstate.c
src/mesa/drivers/dri/r200/radeon_bo.c [new symlink]
src/mesa/drivers/dri/r200/radeon_bo_int_drm.h [new symlink]
src/mesa/drivers/dri/r200/radeon_cs.c [new symlink]
src/mesa/drivers/dri/r200/radeon_cs_int_drm.h [new symlink]
src/mesa/drivers/dri/r300/Makefile
src/mesa/drivers/dri/r300/compiler/memory_pool.c
src/mesa/drivers/dri/r300/compiler/radeon_code.c
src/mesa/drivers/dri/r300/compiler/radeon_code.h
src/mesa/drivers/dri/r300/compiler/radeon_compiler.c
src/mesa/drivers/dri/r300/compiler/radeon_compiler.h
src/mesa/drivers/dri/r300/compiler/radeon_pair_regalloc.c
src/mesa/drivers/dri/r300/compiler/radeon_program.h
src/mesa/drivers/dri/r300/compiler/radeon_program_alu.c
src/mesa/drivers/dri/r300/compiler/radeon_program_pair.h
src/mesa/drivers/dri/r300/r300_blit.c [new file with mode: 0644]
src/mesa/drivers/dri/r300/r300_blit.h [new file with mode: 0644]
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
src/mesa/drivers/dri/r300/r300_emit.c
src/mesa/drivers/dri/r300/r300_emit.h
src/mesa/drivers/dri/r300/r300_fragprog_common.c
src/mesa/drivers/dri/r300/r300_ioctl.c [deleted file]
src/mesa/drivers/dri/r300/r300_ioctl.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_state.c
src/mesa/drivers/dri/r300/r300_swtcl.c
src/mesa/drivers/dri/r300/r300_tex.c
src/mesa/drivers/dri/r300/r300_tex.h
src/mesa/drivers/dri/r300/r300_texcopy.c [new file with mode: 0644]
src/mesa/drivers/dri/r300/r300_texstate.c
src/mesa/drivers/dri/r300/r300_vertprog.c
src/mesa/drivers/dri/r300/radeon_bo.c [new symlink]
src/mesa/drivers/dri/r300/radeon_bo_int_drm.h [new symlink]
src/mesa/drivers/dri/r300/radeon_cs.c [new symlink]
src/mesa/drivers/dri/r300/radeon_cs_int_drm.h [new symlink]
src/mesa/drivers/dri/r600/Makefile
src/mesa/drivers/dri/r600/r600_cmdbuf.c
src/mesa/drivers/dri/r600/r600_cmdbuf.h
src/mesa/drivers/dri/r600/r600_context.c
src/mesa/drivers/dri/r600/r600_context.h
src/mesa/drivers/dri/r600/r600_reg_r6xx.h
src/mesa/drivers/dri/r600/r600_reg_r7xx.h
src/mesa/drivers/dri/r600/r600_tex.c
src/mesa/drivers/dri/r600/r600_texstate.c
src/mesa/drivers/dri/r600/r700_assembler.c
src/mesa/drivers/dri/r600/r700_assembler.h
src/mesa/drivers/dri/r600/r700_chip.c
src/mesa/drivers/dri/r600/r700_clear.c
src/mesa/drivers/dri/r600/r700_fragprog.c
src/mesa/drivers/dri/r600/r700_fragprog.h
src/mesa/drivers/dri/r600/r700_oglprog.c
src/mesa/drivers/dri/r600/r700_render.c
src/mesa/drivers/dri/r600/r700_shader.c
src/mesa/drivers/dri/r600/r700_shader.h
src/mesa/drivers/dri/r600/r700_shaderinst.h
src/mesa/drivers/dri/r600/r700_state.c
src/mesa/drivers/dri/r600/r700_state.h
src/mesa/drivers/dri/r600/r700_vertprog.c
src/mesa/drivers/dri/r600/r700_vertprog.h
src/mesa/drivers/dri/r600/radeon_bo.c [new symlink]
src/mesa/drivers/dri/r600/radeon_bo_int_drm.h [new symlink]
src/mesa/drivers/dri/r600/radeon_cs.c [new symlink]
src/mesa/drivers/dri/r600/radeon_cs_int_drm.h [new symlink]
src/mesa/drivers/dri/radeon/Makefile
src/mesa/drivers/dri/radeon/radeon_bo.c [new file with mode: 0644]
src/mesa/drivers/dri/radeon/radeon_bo_drm.h
src/mesa/drivers/dri/radeon/radeon_bo_int_drm.h [new file with mode: 0644]
src/mesa/drivers/dri/radeon/radeon_bo_legacy.c
src/mesa/drivers/dri/radeon/radeon_bocs_wrapper.h
src/mesa/drivers/dri/radeon/radeon_buffer_objects.c
src/mesa/drivers/dri/radeon/radeon_common.c
src/mesa/drivers/dri/radeon/radeon_common.h
src/mesa/drivers/dri/radeon/radeon_common_context.c
src/mesa/drivers/dri/radeon/radeon_common_context.h
src/mesa/drivers/dri/radeon/radeon_context.c
src/mesa/drivers/dri/radeon/radeon_context.h
src/mesa/drivers/dri/radeon/radeon_cs.c [new file with mode: 0644]
src/mesa/drivers/dri/radeon/radeon_cs_drm.h
src/mesa/drivers/dri/radeon/radeon_cs_int_drm.h [new file with mode: 0644]
src/mesa/drivers/dri/radeon/radeon_cs_legacy.c
src/mesa/drivers/dri/radeon/radeon_cs_space_drm.c
src/mesa/drivers/dri/radeon/radeon_dma.c
src/mesa/drivers/dri/radeon/radeon_fbo.c
src/mesa/drivers/dri/radeon/radeon_ioctl.c
src/mesa/drivers/dri/radeon/radeon_lock.c
src/mesa/drivers/dri/radeon/radeon_maos_arrays.c
src/mesa/drivers/dri/radeon/radeon_maos_vbtmp.h
src/mesa/drivers/dri/radeon/radeon_maos_verts.c
src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
src/mesa/drivers/dri/radeon/radeon_mipmap_tree.h
src/mesa/drivers/dri/radeon/radeon_queryobj.c
src/mesa/drivers/dri/radeon/radeon_screen.c
src/mesa/drivers/dri/radeon/radeon_screen.h
src/mesa/drivers/dri/radeon/radeon_span.c
src/mesa/drivers/dri/radeon/radeon_state.c
src/mesa/drivers/dri/radeon/radeon_state_init.c
src/mesa/drivers/dri/radeon/radeon_swtcl.c
src/mesa/drivers/dri/radeon/radeon_tex.c
src/mesa/drivers/dri/radeon/radeon_texstate.c
src/mesa/drivers/dri/radeon/radeon_texture.c
src/mesa/drivers/dri/radeon/radeon_texture.h
src/mesa/drivers/dri/s3v/Makefile [deleted file]
src/mesa/drivers/dri/s3v/s3v_common.h [deleted file]
src/mesa/drivers/dri/s3v/s3v_context.c [deleted file]
src/mesa/drivers/dri/s3v/s3v_context.h [deleted file]
src/mesa/drivers/dri/s3v/s3v_dd.c [deleted file]
src/mesa/drivers/dri/s3v/s3v_dri.h [deleted file]
src/mesa/drivers/dri/s3v/s3v_inithw.c [deleted file]
src/mesa/drivers/dri/s3v/s3v_lock.c [deleted file]
src/mesa/drivers/dri/s3v/s3v_lock.h [deleted file]
src/mesa/drivers/dri/s3v/s3v_macros.h [deleted file]
src/mesa/drivers/dri/s3v/s3v_regs.h [deleted file]
src/mesa/drivers/dri/s3v/s3v_render.c [deleted file]
src/mesa/drivers/dri/s3v/s3v_screen.c [deleted file]
src/mesa/drivers/dri/s3v/s3v_screen.h [deleted file]
src/mesa/drivers/dri/s3v/s3v_span.c [deleted file]
src/mesa/drivers/dri/s3v/s3v_state.c [deleted file]
src/mesa/drivers/dri/s3v/s3v_tex.c [deleted file]
src/mesa/drivers/dri/s3v/s3v_tex.h [deleted file]
src/mesa/drivers/dri/s3v/s3v_texmem.c [deleted file]
src/mesa/drivers/dri/s3v/s3v_texstate.c [deleted file]
src/mesa/drivers/dri/s3v/s3v_tris.c [deleted file]
src/mesa/drivers/dri/s3v/s3v_tris.h [deleted file]
src/mesa/drivers/dri/s3v/s3v_tritmp.h [deleted file]
src/mesa/drivers/dri/s3v/s3v_vb.c [deleted file]
src/mesa/drivers/dri/s3v/s3v_vb.h [deleted file]
src/mesa/drivers/dri/s3v/s3v_xmesa.c [deleted file]
src/mesa/drivers/dri/s3v/s3virgetri.h [deleted file]
src/mesa/drivers/dri/savage/Makefile
src/mesa/drivers/dri/savage/savage_init.h
src/mesa/drivers/dri/savage/savage_xmesa.c
src/mesa/drivers/dri/savage/savagecontext.h
src/mesa/drivers/dri/savage/savageioctl.c
src/mesa/drivers/dri/savage/savageioctl.h
src/mesa/drivers/dri/savage/savagerender.c
src/mesa/drivers/dri/savage/savagespan.c
src/mesa/drivers/dri/savage/savagetex.c
src/mesa/drivers/dri/savage/savagetris.c
src/mesa/drivers/dri/sis/Makefile
src/mesa/drivers/dri/sis/sis_clear.c
src/mesa/drivers/dri/sis/sis_context.c
src/mesa/drivers/dri/sis/sis_context.h
src/mesa/drivers/dri/sis/sis_dd.c
src/mesa/drivers/dri/sis/sis_lock.c
src/mesa/drivers/dri/sis/sis_screen.c
src/mesa/drivers/dri/sis/sis_screen.h
src/mesa/drivers/dri/sis/sis_span.c
src/mesa/drivers/dri/sis/sis_tex.c
src/mesa/drivers/dri/sis/sis_texstate.c
src/mesa/drivers/dri/sis/sis_tris.c
src/mesa/drivers/dri/swrast/Makefile
src/mesa/drivers/dri/swrast/swrast.c
src/mesa/drivers/dri/swrast/swrast_span.c
src/mesa/drivers/dri/tdfx/Makefile
src/mesa/drivers/dri/tdfx/tdfx_context.c
src/mesa/drivers/dri/tdfx/tdfx_context.h
src/mesa/drivers/dri/tdfx/tdfx_lock.c
src/mesa/drivers/dri/tdfx/tdfx_pixels.c
src/mesa/drivers/dri/tdfx/tdfx_render.c
src/mesa/drivers/dri/tdfx/tdfx_screen.c
src/mesa/drivers/dri/tdfx/tdfx_screen.h
src/mesa/drivers/dri/tdfx/tdfx_span.c
src/mesa/drivers/dri/tdfx/tdfx_state.c
src/mesa/drivers/dri/tdfx/tdfx_tex.c
src/mesa/drivers/dri/tdfx/tdfx_texstate.c
src/mesa/drivers/dri/tdfx/tdfx_vb.c
src/mesa/drivers/dri/tdfx/tdfx_vbtmp.h
src/mesa/drivers/dri/trident/Makefile [deleted file]
src/mesa/drivers/dri/trident/trident_context.c [deleted file]
src/mesa/drivers/dri/trident/trident_context.h [deleted file]
src/mesa/drivers/dri/trident/trident_dd.c [deleted file]
src/mesa/drivers/dri/trident/trident_dri.h [deleted file]
src/mesa/drivers/dri/trident/trident_lock.h [deleted file]
src/mesa/drivers/dri/trident/trident_state.c [deleted file]
src/mesa/drivers/dri/trident/trident_tris.c [deleted file]
src/mesa/drivers/dri/trident/trident_vb.c [deleted file]
src/mesa/drivers/dri/unichrome/Makefile
src/mesa/drivers/dri/unichrome/via_context.c
src/mesa/drivers/dri/unichrome/via_context.h
src/mesa/drivers/dri/unichrome/via_ioctl.c
src/mesa/drivers/dri/unichrome/via_ioctl.h
src/mesa/drivers/dri/unichrome/via_screen.c
src/mesa/drivers/dri/unichrome/via_screen.h
src/mesa/drivers/dri/unichrome/via_span.c
src/mesa/drivers/dri/unichrome/via_state.c
src/mesa/drivers/dri/unichrome/via_tex.c
src/mesa/drivers/dri/unichrome/via_tris.c
src/mesa/drivers/glide/fxddtex.c
src/mesa/drivers/glide/fxsetup.c
src/mesa/drivers/glide/fxvb.c
src/mesa/drivers/glide/fxvbtmp.h
src/mesa/drivers/glslcompiler/Makefile
src/mesa/drivers/osmesa/Makefile
src/mesa/drivers/osmesa/osmesa.c
src/mesa/drivers/windows/gdi/mesa.def
src/mesa/drivers/windows/gdi/wmesa.c
src/mesa/drivers/windows/gldirect/dx7/gld_driver_dx7.c
src/mesa/drivers/windows/gldirect/dx7/gld_primitive_dx7.c
src/mesa/drivers/windows/gldirect/dx7/gld_vb_d3d_render_dx7.c
src/mesa/drivers/windows/gldirect/dx8/gld_driver_dx8.c
src/mesa/drivers/windows/gldirect/dx8/gld_primitive_dx8.c
src/mesa/drivers/windows/gldirect/dx8/gld_vb_d3d_render_dx8.c
src/mesa/drivers/windows/gldirect/dx9/gld_driver_dx9.c
src/mesa/drivers/windows/gldirect/dx9/gld_primitive_dx9.c
src/mesa/drivers/windows/gldirect/dx9/gld_vb_d3d_render_dx9.c
src/mesa/drivers/x11/fakeglx.c
src/mesa/drivers/x11/xm_api.c
src/mesa/drivers/x11/xm_buffer.c
src/mesa/drivers/x11/xm_dd.c
src/mesa/drivers/x11/xm_span.c
src/mesa/glapi/ARB_framebuffer_object.xml
src/mesa/glapi/ARB_sync.xml
src/mesa/glapi/EXT_draw_buffers2.xml [new file with mode: 0644]
src/mesa/glapi/EXT_framebuffer_object.xml
src/mesa/glapi/EXT_packed_depth_stencil.xml [new file with mode: 0644]
src/mesa/glapi/EXT_texture_array.xml
src/mesa/glapi/Makefile
src/mesa/glapi/NV_conditional_render.xml [new file with mode: 0644]
src/mesa/glapi/dispatch.h
src/mesa/glapi/gl_API.xml
src/mesa/glapi/gl_offsets.py
src/mesa/glapi/gl_table.py
src/mesa/glapi/glapi.c
src/mesa/glapi/glapi_getproc.c
src/mesa/glapi/glapidispatch.h [new file with mode: 0644]
src/mesa/glapi/glapioffsets.h
src/mesa/glapi/glapitable.h
src/mesa/glapi/glapitemp.h
src/mesa/glapi/glprocs.h
src/mesa/glapi/glthread.c
src/mesa/glapi/remap_helper.py [new file with mode: 0644]
src/mesa/main/api_arrayelt.c
src/mesa/main/api_exec.c
src/mesa/main/attrib.c
src/mesa/main/blend.c
src/mesa/main/blend.h
src/mesa/main/bufferobj.c
src/mesa/main/bufferobj.h
src/mesa/main/buffers.c
src/mesa/main/clear.c
src/mesa/main/clear.h
src/mesa/main/colormac.h
src/mesa/main/compiler.h
src/mesa/main/condrender.c [new file with mode: 0644]
src/mesa/main/condrender.h [new file with mode: 0644]
src/mesa/main/config.h
src/mesa/main/context.c
src/mesa/main/context.h
src/mesa/main/dd.h
src/mesa/main/debug.c
src/mesa/main/debug.h
src/mesa/main/depth.c
src/mesa/main/depthstencil.c
src/mesa/main/dispatch.c
src/mesa/main/dlist.c
src/mesa/main/dlist.h
src/mesa/main/dlopen.c
src/mesa/main/enable.c
src/mesa/main/enable.h
src/mesa/main/enums.c
src/mesa/main/extensions.c
src/mesa/main/extensions.h
src/mesa/main/fbobject.c
src/mesa/main/ffvertex_prog.c
src/mesa/main/fog.c
src/mesa/main/formats.c [new file with mode: 0644]
src/mesa/main/formats.h [new file with mode: 0644]
src/mesa/main/framebuffer.c
src/mesa/main/framebuffer.h
src/mesa/main/get.c
src/mesa/main/get.h
src/mesa/main/get_gen.py
src/mesa/main/getstring.c
src/mesa/main/histogram.c
src/mesa/main/image.c
src/mesa/main/imports.c
src/mesa/main/imports.h
src/mesa/main/light.c
src/mesa/main/macros.h
src/mesa/main/mfeatures.h
src/mesa/main/mipmap.c
src/mesa/main/mtypes.h
src/mesa/main/points.c
src/mesa/main/queryobj.c
src/mesa/main/queryobj.h
src/mesa/main/rbadaptors.c
src/mesa/main/remap.c [new file with mode: 0644]
src/mesa/main/remap.h [new file with mode: 0644]
src/mesa/main/remap_helper.h [new file with mode: 0644]
src/mesa/main/renderbuffer.c
src/mesa/main/shaders.c
src/mesa/main/texcompress.c
src/mesa/main/texcompress.h
src/mesa/main/texcompress_fxt1.c
src/mesa/main/texcompress_fxt1.h [new file with mode: 0644]
src/mesa/main/texcompress_s3tc.c
src/mesa/main/texcompress_s3tc.h [new file with mode: 0644]
src/mesa/main/texenv.c
src/mesa/main/texenvprogram.c
src/mesa/main/texfetch.c [new file with mode: 0644]
src/mesa/main/texfetch.h [new file with mode: 0644]
src/mesa/main/texfetch_tmp.h [new file with mode: 0644]
src/mesa/main/texformat.c
src/mesa/main/texformat.h
src/mesa/main/texformat_tmp.h [deleted file]
src/mesa/main/texgen.c
src/mesa/main/texgetimage.c
src/mesa/main/teximage.c
src/mesa/main/teximage.h
src/mesa/main/texobj.c
src/mesa/main/texparam.c
src/mesa/main/texparam.h
src/mesa/main/texrender.c
src/mesa/main/texstate.c
src/mesa/main/texstore.c
src/mesa/main/texstore.h
src/mesa/main/varray.c
src/mesa/main/version.c [new file with mode: 0644]
src/mesa/main/version.h
src/mesa/main/vtxfmt_tmp.h
src/mesa/math/m_debug_norm.c
src/mesa/shader/arbprogparse.c
src/mesa/shader/arbprogram.c
src/mesa/shader/atifragshader.c
src/mesa/shader/descrip.mms
src/mesa/shader/grammar/grammar.c [deleted file]
src/mesa/shader/grammar/grammar.h [deleted file]
src/mesa/shader/grammar/grammar.syn [deleted file]
src/mesa/shader/grammar/grammar_crt.c [deleted file]
src/mesa/shader/grammar/grammar_crt.h [deleted file]
src/mesa/shader/grammar/grammar_mesa.c [deleted file]
src/mesa/shader/grammar/grammar_mesa.h [deleted file]
src/mesa/shader/grammar/grammar_syn.h [deleted file]
src/mesa/shader/hash_table.c
src/mesa/shader/lex.yy.c
src/mesa/shader/nvfragparse.c
src/mesa/shader/nvprogram.c
src/mesa/shader/prog_execute.c
src/mesa/shader/prog_instruction.h
src/mesa/shader/prog_optimize.c
src/mesa/shader/prog_parameter.c
src/mesa/shader/prog_parameter_layout.c
src/mesa/shader/prog_print.c
src/mesa/shader/program.c
src/mesa/shader/program_lexer.l
src/mesa/shader/program_parse.tab.c
src/mesa/shader/program_parse.tab.h
src/mesa/shader/program_parse.y
src/mesa/shader/program_parser.h
src/mesa/shader/programopt.c
src/mesa/shader/shader_api.c
src/mesa/shader/slang/descrip.mms
src/mesa/shader/slang/library/.gitignore [new file with mode: 0644]
src/mesa/shader/slang/library/Makefile
src/mesa/shader/slang/library/SConscript [new file with mode: 0644]
src/mesa/shader/slang/library/gc_to_bin.c [deleted file]
src/mesa/shader/slang/library/slang_120_core_gc.h [deleted file]
src/mesa/shader/slang/library/slang_builtin_120_common_gc.h [deleted file]
src/mesa/shader/slang/library/slang_builtin_120_fragment_gc.h [deleted file]
src/mesa/shader/slang/library/slang_common_builtin_gc.h [deleted file]
src/mesa/shader/slang/library/slang_core_gc.h [deleted file]
src/mesa/shader/slang/library/slang_fragment_builtin_gc.h [deleted file]
src/mesa/shader/slang/library/slang_pp_directives.syn [deleted file]
src/mesa/shader/slang/library/slang_pp_directives_syn.h [deleted file]
src/mesa/shader/slang/library/slang_pp_expression.syn [deleted file]
src/mesa/shader/slang/library/slang_pp_expression_syn.h [deleted file]
src/mesa/shader/slang/library/slang_pp_version.syn [deleted file]
src/mesa/shader/slang/library/slang_pp_version_syn.h [deleted file]
src/mesa/shader/slang/library/slang_shader.syn [deleted file]
src/mesa/shader/slang/library/slang_shader_syn.h [deleted file]
src/mesa/shader/slang/library/slang_version.syn [deleted file]
src/mesa/shader/slang/library/slang_vertex_builtin_gc.h [deleted file]
src/mesa/shader/slang/library/syn_to_c.c [deleted file]
src/mesa/shader/slang/slang_codegen.c
src/mesa/shader/slang/slang_codegen.h
src/mesa/shader/slang/slang_compile.c
src/mesa/shader/slang/slang_compile_operation.c
src/mesa/shader/slang/slang_compile_operation.h
src/mesa/shader/slang/slang_emit.c
src/mesa/shader/slang/slang_link.c
src/mesa/shader/slang/slang_preprocess.c [deleted file]
src/mesa/shader/slang/slang_preprocess.h [deleted file]
src/mesa/shader/slang/slang_simplify.c
src/mesa/shader/slang/slang_vartable.c
src/mesa/shader/symbol_table.c
src/mesa/sources.mak
src/mesa/sparc/glapi_sparc.S
src/mesa/sparc/xform.S
src/mesa/state_tracker/st_atom.c
src/mesa/state_tracker/st_atom.h
src/mesa/state_tracker/st_atom_blend.c
src/mesa/state_tracker/st_atom_framebuffer.c
src/mesa/state_tracker/st_atom_pixeltransfer.c
src/mesa/state_tracker/st_atom_sampler.c
src/mesa/state_tracker/st_atom_shader.c
src/mesa/state_tracker/st_atom_texture.c
src/mesa/state_tracker/st_cb_accum.c
src/mesa/state_tracker/st_cb_bitmap.c
src/mesa/state_tracker/st_cb_blit.c
src/mesa/state_tracker/st_cb_bufferobjects.c
src/mesa/state_tracker/st_cb_clear.c
src/mesa/state_tracker/st_cb_condrender.c [new file with mode: 0644]
src/mesa/state_tracker/st_cb_condrender.h [new file with mode: 0644]
src/mesa/state_tracker/st_cb_drawpixels.c
src/mesa/state_tracker/st_cb_fbo.c
src/mesa/state_tracker/st_cb_get.c [deleted file]
src/mesa/state_tracker/st_cb_get.h [deleted file]
src/mesa/state_tracker/st_cb_program.c
src/mesa/state_tracker/st_cb_queryobj.c
src/mesa/state_tracker/st_cb_queryobj.h
src/mesa/state_tracker/st_cb_readpixels.c
src/mesa/state_tracker/st_cb_texture.c
src/mesa/state_tracker/st_context.c
src/mesa/state_tracker/st_context.h
src/mesa/state_tracker/st_debug.c
src/mesa/state_tracker/st_draw.c
src/mesa/state_tracker/st_draw_feedback.c
src/mesa/state_tracker/st_extensions.c
src/mesa/state_tracker/st_format.c
src/mesa/state_tracker/st_format.h
src/mesa/state_tracker/st_framebuffer.c
src/mesa/state_tracker/st_gen_mipmap.c
src/mesa/state_tracker/st_mesa_to_tgsi.c
src/mesa/state_tracker/st_mesa_to_tgsi.h
src/mesa/state_tracker/st_program.c
src/mesa/state_tracker/st_program.h
src/mesa/state_tracker/st_texture.c
src/mesa/swrast/s_accum.c
src/mesa/swrast/s_atifragshader.c
src/mesa/swrast/s_bitmap.c
src/mesa/swrast/s_blit.c
src/mesa/swrast/s_clear.c
src/mesa/swrast/s_context.c
src/mesa/swrast/s_copypix.c
src/mesa/swrast/s_depth.c
src/mesa/swrast/s_drawpix.c
src/mesa/swrast/s_fragprog.c
src/mesa/swrast/s_masking.c
src/mesa/swrast/s_masking.h
src/mesa/swrast/s_readpix.c
src/mesa/swrast/s_span.c
src/mesa/swrast/s_texfilter.c
src/mesa/swrast/s_triangle.c
src/mesa/swrast_setup/ss_tritmp.h
src/mesa/tnl/t_context.c
src/mesa/tnl/t_context.h
src/mesa/tnl/t_draw.c
src/mesa/tnl/t_pipeline.c
src/mesa/tnl/t_vb_fog.c
src/mesa/tnl/t_vb_light.c
src/mesa/tnl/t_vb_lighttmp.h
src/mesa/tnl/t_vb_normals.c
src/mesa/tnl/t_vb_program.c
src/mesa/tnl/t_vb_texgen.c
src/mesa/tnl/t_vb_texmat.c
src/mesa/tnl/t_vb_vertex.c
src/mesa/tnl/t_vertex_generic.c
src/mesa/tnl_dd/t_dd_dmatmp.h
src/mesa/tnl_dd/t_dd_dmatmp2.h
src/mesa/tnl_dd/t_dd_tritmp.h
src/mesa/tnl_dd/t_dd_vb.c
src/mesa/tnl_dd/t_dd_vbtmp.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_exec_eval.c
src/mesa/vbo/vbo_save_api.c
src/mesa/vf/vf_generic.c
src/mesa/x86-64/glapi_x86-64.S
src/mesa/x86/gen_matypes.c
src/mesa/x86/glapi_x86.S
src/mesa/x86/read_rgba_span_x86.S
src/mesa/x86/rtasm/x86sse.c
windows/VC6/progs/glut/glut.dsp [deleted file]
windows/VC7/mesa/mesa/mesa.vcproj
windows/VC8/mesa/mesa/mesa.vcproj

index 1c3d44665e0778ab94b271d26e680ca7c28be047..f43ff3766cbb4acdb56ddf05361e1d663f116922 100644 (file)
@@ -4,6 +4,7 @@
 *.ilk
 *.o
 *.obj
+*.os
 *.pc
 *.pdb
 *.pyc
index 934f85b5ab1c0d17e60c27fb51885294aff2d925..340747d5609c75f7e8df82873124448e451af67d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -105,6 +105,7 @@ irix6-n32-static \
 irix6-o32 \
 irix6-o32-static \
 linux \
+linux-i965 \
 linux-alpha \
 linux-alpha-static \
 linux-cell \
@@ -183,7 +184,7 @@ ultrix-gcc:
 
 # Rules for making release tarballs
 
-VERSION=7.7-devel
+VERSION=7.7
 DIRECTORY = Mesa-$(VERSION)
 LIB_NAME = MesaLib-$(VERSION)
 DEMO_NAME = MesaDemos-$(VERSION)
@@ -226,6 +227,11 @@ MAIN_FILES = \
        $(DIRECTORY)/include/GL/vms_x_fix.h                             \
        $(DIRECTORY)/include/GL/wglext.h                                \
        $(DIRECTORY)/include/GL/wmesa.h                                 \
+       $(DIRECTORY)/src/glsl/Makefile                                  \
+       $(DIRECTORY)/src/glsl/Makefile.template                         \
+       $(DIRECTORY)/src/glsl/*/Makefile                                \
+       $(DIRECTORY)/src/glsl/*/SConscript                              \
+       $(DIRECTORY)/src/glsl/*/*.[ch]                                  \
        $(DIRECTORY)/src/Makefile                                       \
        $(DIRECTORY)/src/mesa/Makefile*                                 \
        $(DIRECTORY)/src/mesa/sources.mak                               \
@@ -241,7 +247,6 @@ MAIN_FILES = \
        $(DIRECTORY)/src/mesa/shader/*.[chly]                           \
        $(DIRECTORY)/src/mesa/shader/Makefile                           \
        $(DIRECTORY)/src/mesa/shader/descrip.mms                        \
-       $(DIRECTORY)/src/mesa/shader/grammar/*.[ch]                     \
        $(DIRECTORY)/src/mesa/shader/slang/*.[ch]                       \
        $(DIRECTORY)/src/mesa/shader/slang/descrip.mms                  \
        $(DIRECTORY)/src/mesa/shader/slang/library/*.[ch]               \
@@ -440,8 +445,7 @@ DEMO_FILES = \
        $(DIRECTORY)/progs/windml/Makefile.ugl          \
        $(DIRECTORY)/progs/windml/*.c                   \
        $(DIRECTORY)/progs/windml/*.bmp                 \
-       $(DIRECTORY)/progs/ggi/*.c                      \
-       $(DIRECTORY)/windows/VC7/progs/progs.sln
+       $(DIRECTORY)/progs/ggi/*.c
 
 GLUT_FILES = \
        $(DIRECTORY)/include/GL/glut.h                  \
@@ -464,9 +468,7 @@ GLUT_FILES = \
        $(DIRECTORY)/src/glut/mini/glut.pc.in           \
        $(DIRECTORY)/src/glut/directfb/Makefile         \
        $(DIRECTORY)/src/glut/directfb/NOTES            \
-       $(DIRECTORY)/src/glut/directfb/*[ch]            \
-       $(DIRECTORY)/windows/VC6/progs/glut/glut.dsp    \
-       $(DIRECTORY)/windows/VC7/progs/glut/glut.vcproj
+       $(DIRECTORY)/src/glut/directfb/*[ch]
 
 DEPEND_FILES = \
        $(TOP)/src/mesa/depend          \
@@ -506,9 +508,11 @@ rm_depend:
                touch $$dep ; \
        done
 
-lib_gz:
-       rm -f configs/current ; \
-       rm -f configs/autoconf ; \
+rm_config:
+       rm -f configs/current
+       rm -f configs/autoconf
+
+lib_gz: rm_config
        cd .. ; \
        tar -cf $(LIB_NAME).tar $(LIB_FILES) ; \
        gzip $(LIB_NAME).tar ; \
@@ -526,9 +530,7 @@ glut_gz:
        gzip $(GLUT_NAME).tar ; \
        mv $(GLUT_NAME).tar.gz $(DIRECTORY)
 
-lib_bz2:
-       rm -f configs/current ; \
-       rm -f configs/autoconf ; \
+lib_bz2: rm_config
        cd .. ; \
        tar -cf $(LIB_NAME).tar $(LIB_FILES) ; \
        bzip2 $(LIB_NAME).tar ; \
@@ -546,9 +548,7 @@ glut_bz2:
        bzip2 $(GLUT_NAME).tar ; \
        mv $(GLUT_NAME).tar.bz2 $(DIRECTORY)
 
-lib_zip:
-       rm -f configs/current ; \
-       rm -f configs/autoconf ; \
+lib_zip: rm_config
        rm -f $(LIB_NAME).zip ; \
        cd .. ; \
        zip -qr $(LIB_NAME).zip $(LIB_FILES) ; \
@@ -577,5 +577,7 @@ md5:
        @-md5sum $(GLUT_NAME).tar.bz2
        @-md5sum $(GLUT_NAME).zip
 
-.PHONY: tarballs rm_depend lib_gz demo_gz glut_gz lib_bz2 demo_bz2 \
-       glut_bz2 lib_zip demo_zip glut_zip md5
+.PHONY: tarballs rm_depend rm_config md5 \
+       lib_gz demo_gz glut_gz \
+       lib_bz2 demo_bz2 glut_bz2 \
+       lib_zip demo_zip glut_zip
index d53f4401e5ac0074e091ff79ab6f735d600ed60b..787ff6e2d6b3e1d28a01cb0031031c3032681f22 100644 (file)
@@ -32,10 +32,10 @@ import common
 default_statetrackers = 'mesa'
 
 if common.default_platform in ('linux', 'freebsd', 'darwin'):
-       default_drivers = 'softpipe,failover,i915,trace,identity,llvmpipe'
+       default_drivers = 'softpipe,failover,svga,i915,i965,trace,identity,llvmpipe'
        default_winsys = 'xlib'
 elif common.default_platform in ('winddk',):
-       default_drivers = 'softpipe,i915,trace,identity'
+       default_drivers = 'softpipe,svga,i915,i965,trace,identity'
        default_winsys = 'all'
 else:
        default_drivers = 'all'
@@ -46,9 +46,9 @@ common.AddOptions(opts)
 opts.Add(ListVariable('statetrackers', 'state trackers to build', default_statetrackers,
                      ['mesa', 'python', 'xorg']))
 opts.Add(ListVariable('drivers', 'pipe drivers to build', default_drivers,
-                     ['softpipe', 'failover', 'i915', 'cell', 'trace', 'r300', 'identity', 'llvmpipe']))
+                     ['softpipe', 'failover', 'svga', 'i915', 'i965', 'trace', 'r300', 'identity', 'llvmpipe']))
 opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys,
-                     ['xlib', 'intel', 'gdi', 'radeon']))
+                     ['xlib', 'vmware', 'intel', 'i965', 'gdi', 'radeon']))
 
 opts.Add(EnumVariable('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0')))
 
@@ -160,8 +160,36 @@ Export('env')
 # TODO: Build several variants at the same time?
 # http://www.scons.org/wiki/SimultaneousVariantBuilds
 
+if env['platform'] != common.default_platform:
+    # GLSL code has to be built twice -- one for the host OS, another for the target OS...
+
+    host_env = Environment(
+        # options are ignored
+        # default tool is used
+        tools = ['default', 'custom'],
+        toolpath = ['#scons'], 
+        ENV = os.environ,
+    )
+
+    host_env['platform'] = common.default_platform
+    host_env['machine'] = common.default_machine
+    host_env['debug'] = env['debug']
+
+    SConscript(
+        'src/glsl/SConscript',
+        variant_dir = os.path.join(env['build'], 'host'),
+        duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
+        exports={'env':host_env},
+    )
+
 SConscript(
        'src/SConscript',
        variant_dir = env['build'],
        duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
 )
+
+SConscript(
+       'progs/SConscript',
+       variant_dir = os.path.join('progs', env['build']),
+       duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
+)
index db97087c0a614c24ef9ee90b600a193173bf1466..9799a4ed2772061fe6b85a91ee024a44432b3f9b 100755 (executable)
--- a/bin/mklib
+++ b/bin/mklib
 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 
+# Given a list of files, look for .a archives and unpack them.
+# Return the original list of files minus the .a files plus the unpacked files.
+expand_archives() {
+    DIR=$1
+    shift
+    FILES=$@
+    NEWFILES=""
+    ORIG_DIR=`pwd`
+    mkdir -p "$DIR"
+    cd "$DIR"
+    for FILE in $FILES ; do
+        case $FILE in
+            *.a)
+                # extract the .o files from this .a archive
+                case $FILE in
+                    /*) ;;
+                    *)  FILE="$ORIG_DIR/$FILE" ;;
+                esac
+                MEMBERS=`ar t $FILE`
+                ar x $FILE
+                for MEMBER in $MEMBERS ; do
+                    NEWFILES="$NEWFILES $DIR/$MEMBER"
+                done
+                ;;
+            *)
+                # other file type, just add to list
+                NEWFILES="$NEWFILES $FILE"
+                ;;
+        esac
+    done
+    cd "$ORIG_DIR"
+    echo $NEWFILES
+}
+
+
+# Given a list of files, look for .a archives and return a list of all objects
+# in the .a archives.
+contents_of_archives() {
+    FILES=$@
+    NEWFILES=""
+    for FILE in $FILES ; do
+        case $FILE in
+            *.a)
+                # get list of members in this .a archive
+                MEMBERS=`ar t $FILE`
+                NEWFILES="$NEWFILES $MEMBERS"
+                ;;
+            *)
+                # skip other file types
+                ;;
+        esac
+    done
+    echo $NEWFILES
+}
+
+
+# Make static library with 'ar'
+# params:
+#    options to ar
+#    1 or 0 to indicate if ranlib should be run
+#    libname to make
+#    list of object files
+# Return name of library we made
+# Example: "make_ar_static_lib -ru 1 libfoo.a foo.o bar.o"
+make_ar_static_lib() {
+    OPTS=$1
+    shift;
+    RANLIB=$1
+    shift;
+    LIBNAME=$1
+    shift;
+    OBJECTS=$@
+
+    # remove existing lib, if present
+    rm -f ${LIBNAME}
+
+    # make static lib
+    ar ${OPTS} ${LIBNAME} ${OBJECTS}
+
+    # run ranlib
+    if [ ${RANLIB} = 1 ] ; then
+        ranlib ${LIBNAME}
+    fi
+
+    echo ${LIBNAME}
+}
+
+
+# Print usage info.
+usage() {
+    echo 'Usage: mklib [options] objects'
+    echo 'Create a shared library from object files.'
+    echo '  -o LIBRARY    specifies the name of the resulting library, without'
+    echo '                the leading "lib" or any suffix.'
+    echo '                (eg: "-o GL" might result in "libGL.so" being made)'
+    echo '  -major N      specifies major version number (default is 1)'
+    echo '  -minor N      specifies minor version number (default is 0)'
+    echo '  -patch N      specifies patch version number (default is 0)'
+    echo '  -lLIBRARY     specifies a dependency on LIBRARY'
+    echo '  -LDIR         search in DIR for library dependencies at build time'
+    echo '  -RDIR         search in DIR for library dependencies at run time'
+    echo '  -linker L     explicity specify the linker program to use (eg: gcc, g++)'
+    echo '                Not observed on all systems at this time.'
+    echo '  -ldflags OPT  specify any additional linker flags in OPT'
+    echo '  -cplusplus    link with C++ runtime'
+    echo '  -static       make a static library (default is dynamic/shared)'
+    echo '  -dlopen       make a shared library suitable for dynamic loading'
+    echo '  -install DIR  put resulting library file(s) in DIR'
+    echo '  -arch ARCH    override using `uname` to determine host system'
+    echo '  -archopt OPT  specify an extra achitecture-specific option OPT'
+    echo '  -altopts OPTS alternate options to override all others'
+    echo "  -noprefix     don't prefix library name with 'lib' nor add any suffix"
+    echo '  -exports FILE only export the symbols listed in FILE'
+    echo '  -id NAME      Sets the id of the dylib (Darwin)'
+    echo '  -h, --help    display this information and exit'
+}
+
+
 #
 # Option defaults
 #
@@ -52,31 +170,7 @@ while true
 do
     case $1 in
        '-h' | '--help')
-           echo 'Usage: mklib [options] objects'
-           echo 'Create a shared library from object files.'
-           echo '  -o LIBRARY    specifies the name of the resulting library, without'
-           echo '                the leading "lib" or any suffix.'
-           echo '                (eg: "-o GL" might result in "libGL.so" being made)'
-           echo '  -major N      specifies major version number (default is 1)'
-           echo '  -minor N      specifies minor version number (default is 0)'
-           echo '  -patch N      specifies patch version number (default is 0)'
-           echo '  -lLIBRARY     specifies a dependency on LIBRARY'
-           echo '  -LDIR         search in DIR for library dependencies at build time'
-           echo '  -RDIR         search in DIR for library dependencies at run time'
-           echo '  -linker L     explicity specify the linker program to use (eg: gcc, g++)'
-           echo '                Not observed on all systems at this time.'
-           echo '  -ldflags OPT  specify any additional linker flags in OPT'
-           echo '  -cplusplus    link with C++ runtime'
-           echo '  -static       make a static library (default is dynamic/shared)'
-           echo '  -dlopen       make a shared library suitable for dynamic loading'
-           echo '  -install DIR  put resulting library file(s) in DIR'
-           echo '  -arch ARCH    override using `uname` to determine host system'
-           echo '  -archopt OPT  specify an extra achitecture-specific option OPT'
-           echo '  -altopts OPTS alternate options to override all others'
-           echo "  -noprefix     don't prefix library name with 'lib' nor add any suffix"
-           echo '  -exports FILE only export the symbols listed in FILE'
-           echo '  -id NAME      Sets the id of the dylib (Darwin)'
-           echo '  -h, --help    display this information and exit'
+           usage
            exit 1
            ;;
        '-o')
@@ -197,11 +291,11 @@ fi
 # Error checking
 #
 if [ "x${LIBNAME}" = "x" ] ; then
-    echo "mklib: Error: no library name specified"
+    echo "mklib: Error: no library name specified (-h for help)"
     exit 1
 fi
 if [ "x${OBJECTS}" = "x" ] ; then
-    echo "mklib: Error: no object files specified"
+    echo "mklib: Error: no object files specified (-h for help)"
     exit 1
 fi
 
@@ -269,45 +363,24 @@ case $ARCH in
             # finish up
             FINAL_LIBS="${LIBNAME}"
         elif [ $STATIC = 1 ] ; then
+           # make a static .a library
             LIBNAME="lib${LIBNAME}.a"     # prefix with "lib", suffix with ".a"
             echo "mklib: Making" $ARCH "static library: " ${LIBNAME}
-            LINK="ar"
             OPTS="-ru"
             if [ "${ALTOPTS}" ] ; then
                 OPTS=${ALTOPTS}
             fi
-            rm -f ${LIBNAME}
 
-           # expand any .a objects into constituent .o files.
-           NEWOBJECTS=""
-           DELETIA=""
-           for OBJ in $OBJECTS ; do
-               case $OBJ in
-                   *.a)
-                       # extract the .o files from this .a archive
-                       FILES=`ar t $OBJ`
-                       ar x $OBJ
-                       NEWOBJECTS="$NEWOBJECTS $FILES"
-                       # keep track of temporary .o files and delete them below
-                       DELETIA="$DELETIA $FILES"
-                       ;;
-                   *)
-                       # ordinary .o file
-                       NEWOBJECTS="$NEWOBJECTS $OBJ"
-                       ;;
-               esac
-           done
+           # expand .a into .o files
+           NEW_OBJECTS=`expand_archives ${LIBNAME}.obj $OBJECTS`
 
-            # make lib
-            ${LINK} ${OPTS} ${LIBNAME} ${NEWOBJECTS}
-            ranlib ${LIBNAME}
+            # make static lib
+           FINAL_LIBS=`make_ar_static_lib ${OPTS} 1 ${LIBNAME} ${NEW_OBJECTS}`
 
            # remove temporary extracted .o files
-           rm -f ${DELETIA}
-
-            # finish up
-            FINAL_LIBS=${LIBNAME}
+           rm -rf ${LIBNAME}.obj
         else
+           # make dynamic library
            LIBNAME="lib${LIBNAME}"     # prefix with "lib"
            case $ARCH in 'Linux' | 'GNU' | GNU/*)
                OPTS="-Xlinker -Bsymbolic -shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
@@ -368,9 +441,7 @@ case $ARCH in
         if [ $STATIC = 1 ] ; then
            LIBNAME="lib${LIBNAME}.a"
            echo "mklib: Making SunOS static library: " ${LIBNAME}
-           rm -f ${LIBNAME}
-           ar -ruv ${LIBNAME} ${OBJECTS}
-           FINAL_LIBS=${LIBNAME}
+           FINAL_LIBS=`make_ar_static_lib -ruv 0 ${LIBNAME} ${OBJECTS}`
        else
            if [ $NOPREFIX = 0 ] ; then
                LIBNAME="lib${LIBNAME}.so"
@@ -489,13 +560,19 @@ case $ARCH in
            ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
            FINAL_LIBS=${LIBNAME}
         elif [ $STATIC = 1 ] ; then
+           # make a static .a library
            STLIB="lib${LIBNAME}.a"
            echo "mklib: Making FreeBSD static library: " ${STLIB}
-           rm -f ${STLIB}
-           ar cq ${STLIB} ${OBJECTS}
-           ranlib ${STLIB}
-           FINAL_LIBS=${STLIB}
+
+           # expand .a into .o files
+           NEW_OBJECTS=`expand_archives ${STLIB}.obj $OBJECTS`
+
+           FINAL_LIBS=`make_ar_static_lib cq 1 ${STLIB} ${NEW_OBJECTS}`
+
+           # remove temporary extracted .o files
+           rm -rf ${STLIB}.obj
        else
+           # make dynamic library
            SHLIB="lib${LIBNAME}.so.${MAJOR}"
            OPTS="-shared -Wl,-soname,${SHLIB}"
             if [ "${ALTOPTS}" ] ; then
@@ -513,10 +590,7 @@ case $ARCH in
         if [ $STATIC = 1 ] ; then
            LIBNAME="lib${LIBNAME}_pic.a"
            echo "mklib: Making NetBSD PIC static library: " ${LIBNAME}
-           rm -f ${LIBNAME}
-           ar cq ${LIBNAME} ${OBJECTS}
-           ranlib ${LIBNAME}
-           FINAL_LIBS=${LIBNAME}
+           FINAL_LIBS=`make_ar_static_lib cq 1 ${LIBNAME} ${OBJECTS}`
        else
            LIBNAME="lib${LIBNAME}.so.${MAJOR}.${MINOR}"
            echo "mklib: Making NetBSD PIC shared library: " ${LIBNAME}
@@ -529,9 +603,7 @@ case $ARCH in
     'IRIX' | 'IRIX64')
         if [ $STATIC = 1 ] ; then
            LIBNAME="lib${LIBNAME}.a"
-           rm -f ${LIBNAME}
-           ar rc ${LIBNAME} ${OBJECTS}
-           FINAL_LIBS=${LIBNAME}
+           FINAL_LIBS=`make_ar_static_lib rc 0 ${LIBNAME} ${OBJECTS}`
        else
            LIBNAME="lib${LIBNAME}.so"  # prefix with "lib", suffix with ".so"
 
@@ -582,9 +654,7 @@ case $ARCH in
         if [ $STATIC = 1 ] ; then
            LIBNAME="lib${LIBNAME}.a"
            echo "mklib: Making HP-UX static library: " ${LIBNAME}
-           rm -f ${LIBNAME}
-           ar -ruv ${LIBNAME} ${OBJECTS}
-           FINAL_LIBS=${LIBNAME}
+           FINAL_LIBS=`make_ar_static_lib -ruv 0 ${LIBNAME} ${OBJECTS}`
        else
             # HP uses a .2 for their current GL/GLU libraries
            if [ ${LIBNAME} = "GL" -o ${LIBNAME} = "GLU" ] ; then
@@ -614,8 +684,7 @@ case $ARCH in
        if [ $STATIC = 1 ] ; then
            LIBNAME="lib${LIBNAME}.a"
            echo "mklib: Making AIX static library: " ${LIBNAME}
-           ar -ruv ${X64} ${LIBNAME} ${OBJECTS}
-           FINAL_LIBS=${LIBNAME}
+           FINAL_LIBS=`make_ar_static_lib -ruv 0 ${LIBNAME} ${OBJECTS}`
        else
            EXPFILE="lib${LIBNAME}.exp"
            LIBNAME="lib${LIBNAME}.a"  # shared objects are still stored in the .a libraries
@@ -666,9 +735,7 @@ case $ARCH in
         if [ $STATIC = 1 ] ; then
            LIBNAME="lib${LIBNAME}.a"
            echo "mklib: Making OSF/1 static library: " ${LIBNAME}
-           rm -f ${LIBNAME}
-           ar -ruv ${LIBNAME} ${OBJECTS}
-           FINAL_LIBS=${LIBNAME}
+           FINAL_LIBS=`make_ar_static_lib -ruv 0 ${LIBNAME} ${OBJECTS}`
        else
            VERSION="${MAJOR}.${MINOR}"
            LIBNAME="lib${LIBNAME}.so"
@@ -724,22 +791,10 @@ case $ARCH in
 
            # examine first object to determine ABI
            set ${OBJECTS}
-            ABI_PPC=`file $1 | grep ' ppc'`
-            ABI_I386=`file $1 | grep ' i386'`
-            ABI_PPC64=`file $1 | grep ' ppc64'`
-            ABI_X86_64=`file $1 | grep ' x86_64'`
-            if [ "${ABI_PPC}" ] ; then
-                OPTS="${OPTS} -arch ppc"
-            fi
-            if [ "${ABI_I386}" ] ; then
-                OPTS="${OPTS} -arch i386"
-            fi
-            if [ "${ABI_PPC64}" ] ; then
-                OPTS="${OPTS} -arch ppc64"
-            fi
-            if [ "${ABI_X86_64}" ] ; then
-                OPTS="${OPTS} -arch x86_64"
-            fi
+            ABIS=`lipo -info $1 | sed s/.*://`
+            for ABI in $ABIS; do
+                OPTS="${OPTS} -arch ${ABI}"
+            done
 
             if [ "${ALTOPTS}" ] ; then
                 OPTS=${ALTOPTS}
@@ -767,16 +822,14 @@ case $ARCH in
     'LynxOS')
        LIBNAME="lib${LIBNAME}.a"
        echo "mklib: Making LynxOS static library: " ${LIBNAME}
-       rm -f ${LIBNAME}
-       ar ru ${LIBNAME} ${OBJECTS}
-       FINAL_LIBS=${LIBNAME}
+        FINAL_LIBS=`make_ar_static_lib -ru 0 ${LIBNAME} ${OBJECTS}`
        ;;
 
     'BeOS')
         if [ $STATIC = 1 ] ; then
             LIBNAME="lib${LIBNAME}.a"
             echo "mklib: Making BeOS static library: " ${LIBNAME}
-            ar -cru "${LIBNAME}" ${OBJECTS}
+            FINAL_LIBS=`make_ar_static_lib -cru 0 ${LIBNAME} ${OBJECTS}`
         else
            LIBNAME="lib${LIBNAME}.so"
            echo "mklib: Making BeOS shared library: " ${LIBNAME}
@@ -855,9 +908,7 @@ case $ARCH in
         if [ $STATIC = 1 ] ; then
            LIBNAME="lib${LIBNAME}.a"
            echo "mklib: Making AIX GCC static library: " ${LIBNAME}
-           rm -f ${LIBNAME}
-           ar ru ${LIBNAME} ${OBJECTS}
-           FINAL_LIBS=${LIBNAME}
+            FINAL_LIBS=`make_ar_static_lib ru 0 ${LIBNAME} ${OBJECTS}`
        else
            LIBNAME="lib${LIBNAME}.so"  # prefix with "lib", suffix with ".so"
            echo "mklib: Making AIX GCC shared library: " ${LIBNAME}
@@ -878,9 +929,7 @@ case $ARCH in
        fi
        LIBNAME="lib${LIBNAME}.a"
        echo "mklib: Making static library for Ultrix: " ${LIBNAME}
-       rm -f ${LIBNAME}
-       ar ru ${LIBNAME} ${OBJECTS}
-       FINAL_LIBS="${LIBNAME}"
+        FINAL_LIBS=`make_ar_static_lib ru 0 ${LIBNAME} ${OBJECTS}`
        ;;
 
      CYGWIN*)
@@ -900,17 +949,13 @@ case $ARCH in
        LIBNAME="lib${LIBNAME}"     # prefix with "lib"
 
         if [ $STATIC = 1 ] ; then
-            echo "mklib: Making" $ARCH "static library: " ${LIBNAME}.a
-            LINK="ar"
+           LIBNAME=${LIBNAME}.a
+            echo "mklib: Making" $ARCH "static library: " ${LIBNAME}
             OPTS="-ru"
             if [ "${ALTOPTS}" ] ; then
                 OPTS=${ALTOPTS}
             fi
-            # make lib
-            ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
-           ranlib ${LIBNAME}.a
-            # finish up
-            FINAL_LIBS=${LIBNAME}.a
+            FINAL_LIBS=`make_ar_static_lib ${OPTS} 1 ${LIBNAME} ${OBJECTS}`
         else
            OPTS="-shared -Wl,--enable-auto-image-base -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a"
             if [ "${ALTOPTS}" ] ; then
@@ -948,9 +993,7 @@ case $ARCH in
         if [ $STATIC = 1 ] ; then
            LIBNAME="lib${LIBNAME}.a"
            echo "mklib: Making static library for example arch: " ${LIBNAME}
-           rm -f ${LIBNAME}
-           ar rv ${LIBNAME} ${OBJECTS}
-           FINAL_LIBS="${LIBNAME}"
+            FINAL_LIBS=`make_ar_static_lib rv 0 ${LIBNAME} ${OBJECTS}`
        else
            LIBNAME="lib${LIBNAME}.so"  # prefix with "lib", suffix with ".so"
            echo "mklib: Making shared library for example arch: " ${LIBNAME}
diff --git a/bin/win32kprof.py b/bin/win32kprof.py
deleted file mode 100755 (executable)
index c36317d..0000000
+++ /dev/null
@@ -1,309 +0,0 @@
-#!/usr/bin/env python
-##########################################################################
-# 
-# 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.
-# 
-##########################################################################
-
-
-import sys
-import optparse
-import re
-import struct
-
-from gprof2dot import Call, Function, Profile
-from gprof2dot import CALLS, SAMPLES, TIME, TIME_RATIO, TOTAL_TIME, TOTAL_TIME_RATIO
-from gprof2dot import DotWriter, TEMPERATURE_COLORMAP
-
-
-__version__ = '0.1'
-
-
-class ParseError(Exception):
-    pass
-
-
-class MsvcDemangler:
-    # http://www.kegel.com/mangle.html
-
-    def __init__(self, symbol):
-        self._symbol = symbol
-        self._pos = 0
-
-    def lookahead(self):
-        return self._symbol[self._pos]
-
-    def consume(self):
-        ret = self.lookahead()
-        self._pos += 1
-        return ret
-    
-    def match(self, c):
-        if self.lookahead() != c:
-            raise ParseError
-        self.consume()
-
-    def parse(self):
-        self.match('?')
-        name = self.parse_name()
-        qualifications = self.parse_qualifications()
-        return '::'.join(qualifications + [name])
-
-    def parse_name(self):
-        if self.lookahead() == '?':
-            return self.consume() + self.consume()
-        else:
-            name = self.parse_id()
-            self.match('@')
-            return name
-
-    def parse_qualifications(self):
-        qualifications = []
-        while self.lookahead() != '@':
-            name = self.parse_id()
-            qualifications.append(name)
-            self.match('@')
-        return qualifications
-
-    def parse_id(self):
-        s = ''
-        while True:
-            c = self.lookahead()
-            if c.isalnum() or c in '_':
-                s += c
-                self.consume()
-            else:
-                break
-        return s
-
-
-def demangle(name):
-    if name.startswith('_'):
-        name = name[1:]
-        idx = name.rfind('@')
-        if idx != -1 and name[idx+1:].isdigit():
-            name = name[:idx]
-        return name
-    if name.startswith('?'):
-        demangler = MsvcDemangler(name)
-        return demangler.parse()
-    return name
-
-
-class Reader:
-
-    def __init__(self):
-        self.symbols = []
-        self.symbol_cache = {}
-        self.base_addr = None
-    
-    def read_map(self, mapfile):
-        # See http://msdn.microsoft.com/en-us/library/k7xkk3e2.aspx
-        last_addr = 0
-        last_name = 0
-        for line in file(mapfile, "rt"):
-            fields = line.split()
-            try:
-                section_offset, name, addr, type, lib_object = fields
-            except ValueError:
-                continue
-            if type != 'f':
-                continue
-            section, offset = section_offset.split(':')
-            addr = int(offset, 16)
-            self.symbols.append((addr, name))
-            last_addr = addr
-            last_name = name
-
-        # sort symbols
-        self.symbols.sort(key = lambda (addr, name): addr)
-
-    def lookup_addr(self, addr):
-        try:
-            return self.symbol_cache[addr]
-        except KeyError:
-            pass
-
-        tolerance = 4196
-        s, e = 0, len(self.symbols)
-        while s != e:
-            i = (s + e)//2
-            start_addr, name = self.symbols[i]
-            try:
-                end_addr, next_name = self.symbols[i + 1]
-            except IndexError:
-                end_addr = start_addr + tolerance
-            if addr < start_addr:
-                e = i
-                continue
-            if addr == end_addr:
-                return next_name, addr - start_addr
-            if addr > end_addr:
-                s = i
-                continue
-            return name, addr - start_addr
-        raise ValueError
-
-    def lookup_symbol(self, name):
-        for symbol_addr, symbol_name in self.symbols:
-            if name == symbol_name:
-                return symbol_addr
-        return 0
-
-    def read_data(self, data):
-        profile = Profile()
-
-        fp = file(data, "rb")
-        entry_format = "IIII"
-        entry_size = struct.calcsize(entry_format)
-        caller = None
-        caller_stack = []
-        while True:
-            entry = fp.read(entry_size)
-            if len(entry) < entry_size:
-                break
-            caller_addr, callee_addr, samples_lo, samples_hi = struct.unpack(entry_format, entry)
-            if caller_addr == 0 and callee_addr == 0:
-                continue
-
-            if self.base_addr is None:
-                ref_addr = self.lookup_symbol('___debug_profile_reference@0')
-                if ref_addr:
-                    self.base_addr = (caller_addr - ref_addr) & ~(options.align - 1)
-                else:
-                    self.base_addr = 0
-                sys.stderr.write('Base addr: %08x\n' % self.base_addr)
-
-            samples = (samples_hi << 32) | samples_lo
-            
-            try:
-                caller_raddr = caller_addr - self.base_addr
-                caller_sym, caller_ofs = self.lookup_addr(caller_raddr)
-
-                try:
-                    caller = profile.functions[caller_sym]
-                except KeyError:
-                    caller_name = demangle(caller_sym)
-                    caller = Function(caller_sym, caller_name)
-                    profile.add_function(caller)
-                    caller[CALLS] = 0
-                    caller[SAMPLES] = 0
-            except ValueError:
-                caller = None
-
-            if not callee_addr:
-                if caller:
-                    caller[SAMPLES] += samples
-            else:
-                callee_raddr = callee_addr - self.base_addr
-                callee_sym, callee_ofs = self.lookup_addr(callee_raddr)
-
-                try:
-                    callee = profile.functions[callee_sym]
-                except KeyError:
-                    callee_name = demangle(callee_sym)
-                    callee = Function(callee_sym, callee_name)
-                    profile.add_function(callee)
-                    callee[CALLS] = samples
-                    callee[SAMPLES] = 0
-                else:
-                    callee[CALLS] += samples
-
-                if caller is not None:
-                    try:
-                        call = caller.calls[callee.id]
-                    except KeyError:
-                        call = Call(callee.id)
-                        call[CALLS] = samples
-                        caller.add_call(call)
-                    else:
-                        call[CALLS] += samples
-            
-            if options.verbose:
-                if not callee_addr:
-                    sys.stderr.write('%s+%u: %u\n' % (caller_sym, caller_ofs, samples))
-                else:
-                    sys.stderr.write('%s+%u -> %s+%u: %u\n' % (caller_sym, caller_ofs, callee_sym, callee_ofs, samples))
-
-        # compute derived data
-        profile.validate()
-        profile.find_cycles()
-        profile.aggregate(SAMPLES)
-        profile.ratio(TIME_RATIO, SAMPLES)
-        profile.call_ratios(CALLS)
-        profile.integrate(TOTAL_TIME_RATIO, TIME_RATIO)
-
-        return profile
-
-
-def main():
-    parser = optparse.OptionParser(
-        usage="\n\t%prog [options] [file] ...",
-        version="%%prog %s" % __version__)
-    parser.add_option(
-        '-a', '--align', metavar='NUMBER',
-        type="int", dest="align", default=16,
-        help="section alignment")
-    parser.add_option(
-        '-m', '--map', metavar='FILE',
-        type="string", dest="map",
-        help="map file")
-    parser.add_option(
-        '-b', '--base', metavar='FILE',
-        type="string", dest="base",
-        help="base addr")
-    parser.add_option(
-        '-n', '--node-thres', metavar='PERCENTAGE',
-        type="float", dest="node_thres", default=0.5,
-        help="eliminate nodes below this threshold [default: %default]")
-    parser.add_option(
-        '-e', '--edge-thres', metavar='PERCENTAGE',
-        type="float", dest="edge_thres", default=0.1,
-        help="eliminate edges below this threshold [default: %default]")
-    parser.add_option(
-        '-v', '--verbose',
-        action="count",
-        dest="verbose", default=0,
-        help="verbose output")
-
-    global options
-    (options, args) = parser.parse_args(sys.argv[1:])
-
-    reader = Reader()
-    if options.base is not None:
-        reader.base_addr = int(options.base, 16)
-    if options.map is not None:
-        reader.read_map(options.map)
-    for arg in args:
-        profile = reader.read_data(arg)
-        profile.prune(options.node_thres/100.0, options.edge_thres/100.0)
-        output = sys.stdout
-        dot = DotWriter(output)
-        colormap = TEMPERATURE_COLORMAP
-        dot.graph(profile, colormap)
-
-
-if __name__ == '__main__':
-    main()
-
index 83737e3a7df8e8e4fb334ea504b8daf79f305538..f63618ebea2bcdfe9599a82edb4d3bc488dbf90d 100644 (file)
@@ -22,6 +22,8 @@ LDFLAGS = @LDFLAGS@
 EXTRA_LIB_PATH = @EXTRA_LIB_PATH@
 RADEON_CFLAGS = @RADEON_CFLAGS@
 RADEON_LDFLAGS = @RADEON_LDFLAGS@
+INTEL_LIBS = @INTEL_LIBS@
+INTEL_CFLAGS = @INTEL_CFLAGS@
 
 # Assembler
 MESA_ASM_SOURCES = @MESA_ASM_SOURCES@
@@ -66,12 +68,11 @@ SRC_DIRS = @SRC_DIRS@
 GLU_DIRS = @GLU_DIRS@
 DRIVER_DIRS = @DRIVER_DIRS@
 GALLIUM_DIRS = @GALLIUM_DIRS@
-GALLIUM_AUXILIARY_DIRS = @GALLIUM_AUXILIARY_DIRS@
 GALLIUM_DRIVERS_DIRS = @GALLIUM_DRIVERS_DIRS@
 GALLIUM_WINSYS_DIRS = @GALLIUM_WINSYS_DIRS@
 GALLIUM_WINSYS_DRM_DIRS = @GALLIUM_WINSYS_DRM_DIRS@
 GALLIUM_STATE_TRACKERS_DIRS = @GALLIUM_STATE_TRACKERS_DIRS@
-GALLIUM_AUXILIARIES = $(foreach DIR,$(GALLIUM_AUXILIARY_DIRS),$(TOP)/src/gallium/auxiliary/$(DIR)/lib$(DIR).a)
+GALLIUM_AUXILIARIES = $(TOP)/src/gallium/auxiliary/libgallium.a
 GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVERS_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a)
 
 # Which subdirs under $(TOP)/progs/ to enter:
@@ -124,7 +125,7 @@ INSTALL_INC_DIR = $(includedir)
 DRI_DRIVER_INSTALL_DIR = @DRI_DRIVER_INSTALL_DIR@
 
 # Where libGL will look for DRI hardware drivers
-DRI_DRIVER_SEARCH_DIR = $(DRI_DRIVER_INSTALL_DIR)
+DRI_DRIVER_SEARCH_DIR = @DRI_DRIVER_SEARCH_DIR@
 
 # Xorg driver install directory (for xorg state-tracker)
 XORG_DRIVER_INSTALL_DIR = @XORG_DRIVER_INSTALL_DIR@
index 213c397287e9f2a0bca2d11d5a460a0b8c1a4af9..7556688fe6dd431c74a7f731b3d0402be4600db5 100644 (file)
@@ -12,10 +12,10 @@ X11_DIR = $(INSTALL_DIR)
 CC = gcc
 CXX = g++
 PIC_FLAGS = -fPIC
-DEFINES =  -D_DARWIN_C_SOURCE -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L \
-          -D_BSD_SOURCE -D_SVID_SOURCE -D_GNU_SOURCE -DPTHREADS \
+DEFINES =  -D_DARWIN_C_SOURCE -DPTHREADS -D_GNU_SOURCE \
           -DGLX_ALIAS_UNSUPPORTED -DGLX_INDIRECT_RENDERING
 
+# -D_GNU_SOURCE          - for src/mesa/main ...
 # -DGLX_DIRECT_RENDERING - pulls in libdrm stuff in glx/x11
 # -DGLX_USE_APPLEGL      - supposed to be used with GLX_DIRECT_RENDERING to use AGL rather than DRM, but doesn't compile
 # -DIN_DRI_DRIVER
@@ -49,7 +49,7 @@ GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L$(INSTALL_DIR)/$(LIB_DIR) -L$(X
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L$(INSTALL_DIR)/$(LIB_DIR) -L$(X11_DIR)/$(LIB_DIR) -lX11 -lXmu -lXt -lXi -lm
 
 # omit glw lib for now:
-SRC_DIRS = glx/x11 mesa glu glut/glx glew
+SRC_DIRS = glsl glx/x11 mesa gallium glu glut/glx glew
 GLU_DIRS = sgi
 DRIVER_DIRS = osmesa
 #DRIVER_DIRS = dri
index c3bb47e70df109b8f817c92fe64e5c44174ab6a2..94beca4fa670657ca69e215223a18bec30e6e86b 100644 (file)
@@ -9,7 +9,7 @@ CONFIG_NAME = default
 
 # Version info
 MESA_MAJOR=7
-MESA_MINOR=7
+MESA_MINOR=8
 MESA_TINY=0
 MESA_VERSION = $(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY)
 
@@ -83,7 +83,7 @@ MOTIF_CFLAGS = -I/usr/include/Motif1.2
 
 # Directories to build
 LIB_DIR = lib
-SRC_DIRS = mesa gallium egl gallium/winsys glu glut/glx glew glw
+SRC_DIRS = glsl mesa gallium egl gallium/winsys glu glut/glx glew glw
 GLU_DIRS = sgi
 DRIVER_DIRS = x11 osmesa
 # Which subdirs under $(TOP)/progs/ to enter:
@@ -94,9 +94,8 @@ EGL_DRIVERS_DIRS = demo
 
 # Gallium directories and 
 GALLIUM_DIRS = auxiliary drivers state_trackers
-GALLIUM_AUXILIARY_DIRS = rbug draw translate cso_cache pipebuffer tgsi sct rtasm util indices vl
-GALLIUM_AUXILIARIES = $(foreach DIR,$(GALLIUM_AUXILIARY_DIRS),$(TOP)/src/gallium/auxiliary/$(DIR)/lib$(DIR).a)
-GALLIUM_DRIVERS_DIRS = softpipe i915 failover trace identity
+GALLIUM_AUXILIARIES = $(TOP)/src/gallium/auxiliary/libgallium.a
+GALLIUM_DRIVERS_DIRS = softpipe failover svga i915 i965 trace identity
 GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVERS_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a)
 GALLIUM_WINSYS_DIRS = xlib egl_xlib
 GALLIUM_WINSYS_DRM_DIRS =
index 73a6b61b2f603f299b3eeb652358196561ae417b..c60f0d8ac3b3db496a20bdee2d83b151191449f8 100644 (file)
@@ -23,11 +23,11 @@ DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE \
 X11_INCLUDES = -I/usr/X11R6/include
 
 CFLAGS = -Wall -Wmissing-prototypes -Wdeclaration-after-statement \
-       $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) \
-       $(DEFINES) $(ASM_FLAGS) $(X11_INCLUDES) -std=c99 -ffast-math 
+       -Wpointer-arith $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) \
+       $(DEFINES) $(ASM_FLAGS) $(X11_INCLUDES) -std=c99 -ffast-math
 
-CXXFLAGS = -Wall $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES) \
-       $(X11_INCLUDES) 
+CXXFLAGS = -Wall -Wpointer-arith $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) \
+       $(DEFINES) $(X11_INCLUDES)
 
 # Work around aliasing bugs - developers should comment this out
 CFLAGS += -fno-strict-aliasing
index 19d435fecce8c542128a2f02e3797a66904ed1c9..221655c35dc0c6b51f2217ddb43714245466ca3e 100644 (file)
@@ -33,7 +33,7 @@ CFLAGS = $(OPT_FLAGS) -Wall -Winline -Wmissing-prototypes \
 CXXFLAGS = $(CFLAGS)
 
 # Omitting glw here:
-SRC_DIRS = gallium mesa gallium/winsys glu glut/glx glew
+SRC_DIRS = glsl mesa gallium gallium/winsys glu glut/glx glew
 
 # Build no traditional Mesa drivers:
 DRIVER_DIRS =
index bc6d2336fc33b9a6d83cbd04e91184f2fb57ff1c..8b0b3126db6e800a04c48237f7c9de6e16a1a186 100644 (file)
@@ -4,5 +4,6 @@ include $(TOP)/configs/linux
 
 CONFIG_NAME = linux-debug
 
-OPT_FLAGS = -g -ansi -pedantic
+OPT_FLAGS = -g
+CFLAGS += -ansi -pedantic
 DEFINES += -DDEBUG -DDEBUG_MATH
index 0998ba8549d9dc5a6ad741a48b350cb05d3cfaaf..ff9bcc9396a03ac8696613d3f5af5b25e3307354 100644 (file)
@@ -60,8 +60,14 @@ EGL_DRIVERS_DIRS = demo glx
 DRIVER_DIRS = dri
 WINDOW_SYSTEM = dri
 GALLIUM_WINSYS_DIRS = drm
-GALLIUM_WINSYS_DRM_DIRS = intel
+GALLIUM_WINSYS_DRM_DIRS = vmware intel i965
 GALLIUM_STATE_TRACKERS_DIRS = egl
 
-DRI_DIRS = i810 i915 i965 mach64 mga r128 r200 r300 radeon s3v \
-       savage sis tdfx trident unichrome ffb swrast
+DRI_DIRS = i810 i915 i965 mach64 mga r128 r200 r300 radeon \
+       savage sis tdfx unichrome ffb swrast
+
+INTEL_LIBS = `pkg-config --libs libdrm_intel`
+INTEL_CFLAGS = `pkg-config --cflags libdrm_intel`
+
+RADEON_LIBS = `pkg-config --libs libdrm_radeon`
+RADEON_CFLAGS = `pkg-config --cflags libdrm_radeon`
index c3a458459d851a60fd1319f9c49ddb5853a52e1f..0dbf428830a0b69968dc18240d2a51bcdd73af29 100644 (file)
@@ -11,6 +11,6 @@ ARCH_FLAGS = -DDEBUG
 #DRI_DIRS = i915tex i915 
 #DRI_DIRS = i965
 #DRI_DIRS = radeon r200 r300
-#DRI_DIRS = unichrome sis trident
+#DRI_DIRS = unichrome sis
 #DRI_DIRS = i810 mga r128 tdfx
 
index e9c15a82e4262f4a0f80a00173c24b364d2a6ca9..827fb97330801deafcbbd651fd290c077baa4985 100644 (file)
@@ -68,5 +68,5 @@ WINDOW_SYSTEM=dri
 
 # gamma are missing because they have not been converted to use the new
 # interface.
-DRI_DIRS = i810 i915 mach64 mga r128 r200 r300 radeon s3v \
-       savage sis tdfx trident unichrome ffb 
+DRI_DIRS = i810 i915 mach64 mga r128 r200 r300 radeon \
+       savage sis tdfx unichrome ffb 
diff --git a/configs/linux-i965 b/configs/linux-i965
new file mode 100644 (file)
index 0000000..e66abc3
--- /dev/null
@@ -0,0 +1,8 @@
+# Configuration for standalone mode i965 debug
+
+include $(TOP)/configs/linux-debug
+
+CONFIG_NAME = linux-i965
+
+GALLIUM_DRIVER_DIRS = i965
+GALLIUM_WINSYS_DIRS = drm/i965/xlib
index ace4619b36ee2d82d2a5cff3a5eae58e39808e41..988b7057d4efcbf9d48a1e68e35bd38c81ee9d19 100644 (file)
@@ -6,8 +6,6 @@ include $(TOP)/configs/linux
 
 CONFIG_NAME = linux-llvm
 
-#GALLIUM_AUXILIARY_DIRS += gallivm
-
 # Add llvmpipe driver
 GALLIUM_DRIVERS_DIRS += llvmpipe
 
index 95497af15fcd2fd12eea2ffff0e3ce812f01142a..d8af5ea9ef98b3e398cedbff1b2bf093b23fc2b5 100644 (file)
@@ -18,7 +18,8 @@ AC_CONFIG_AUX_DIR([bin])
 AC_CANONICAL_HOST
 
 dnl Versions for external dependencies
-LIBDRM_REQUIRED=2.4.3
+LIBDRM_REQUIRED=2.4.15
+LIBDRM_RADEON_REQUIRED=2.4.17
 DRI2PROTO_REQUIRED=1.99.3
 
 dnl Check for progs
@@ -94,7 +95,7 @@ esac
 
 dnl Add flags for gcc and g++
 if test "x$GCC" = xyes; then
-    CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99 -ffast-math"
+    CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99 -ffast-math -fvisibility=hidden"
 
     # Work around aliasing bugs - developers should comment this out
     CFLAGS="$CFLAGS -fno-strict-aliasing"
@@ -230,6 +231,8 @@ else
         LIB_EXTENSION='dylib' ;;
     cygwin* )
         LIB_EXTENSION='dll' ;;
+    aix* )
+        LIB_EXTENSION='a' ;;
     * )
         LIB_EXTENSION='so' ;;
     esac
@@ -411,13 +414,12 @@ esac
 dnl
 dnl Driver specific build directories
 dnl
-SRC_DIRS="mesa glew"
+SRC_DIRS="glsl mesa glew"
 GLU_DIRS="sgi"
 WINDOW_SYSTEM=""
 GALLIUM_DIRS="auxiliary drivers state_trackers"
 GALLIUM_WINSYS_DIRS=""
 GALLIUM_WINSYS_DRM_DIRS=""
-GALLIUM_AUXILIARY_DIRS="rbug draw translate cso_cache pipebuffer tgsi sct rtasm util indices vl"
 GALLIUM_DRIVERS_DIRS="softpipe failover trace identity"
 GALLIUM_STATE_TRACKERS_DIRS=""
 
@@ -444,10 +446,7 @@ AC_SUBST([GALLIUM_DIRS])
 AC_SUBST([GALLIUM_WINSYS_DIRS])
 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
@@ -575,13 +574,6 @@ 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
@@ -647,6 +639,13 @@ AC_ARG_WITH([dri-driverdir],
     [DRI_DRIVER_INSTALL_DIR="$withval"],
     [DRI_DRIVER_INSTALL_DIR='${libdir}/dri'])
 AC_SUBST([DRI_DRIVER_INSTALL_DIR])
+dnl Extra search path for DRI drivers
+AC_ARG_WITH([dri-searchpath],
+    [AS_HELP_STRING([--with-dri-searchpath=DIRS...],
+        [semicolon delimited DRI driver search directories @<:@${libdir}/dri@:>@])],
+    [DRI_DRIVER_SEARCH_DIR="$withval"],
+    [DRI_DRIVER_SEARCH_DIR='${DRI_DRIVER_INSTALL_DIR}'])
+AC_SUBST([DRI_DRIVER_SEARCH_DIR])
 dnl Direct rendering or just indirect rendering
 AC_ARG_ENABLE([driglx-direct],
     [AS_HELP_STRING([--disable-driglx-direct],
@@ -766,8 +765,8 @@ if test "$mesa_driver" = dri; then
 
     # default drivers
     if test "x$DRI_DIRS" = "xyes"; then
-        DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 r600 radeon s3v \
-            savage sis tdfx trident unichrome ffb swrast"
+        DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 r600 radeon \
+            savage sis tdfx unichrome ffb swrast"
     fi
 
     DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/  */ /g'`
@@ -794,6 +793,29 @@ AC_SUBST([DRI_DIRS])
 AC_SUBST([EXPAT_INCLUDES])
 AC_SUBST([DRI_LIB_DEPS])
 
+case $DRI_DIRS in
+*i915*|*i965*)
+    PKG_CHECK_MODULES([INTEL], [libdrm_intel])
+    ;;
+esac
+
+case $DRI_DIRS in
+*radeon*|*r200*|*r300*|*r600*)
+    PKG_CHECK_MODULES([LIBDRM_RADEON],
+                     [libdrm_radeon libdrm >= $LIBDRM_RADEON_REQUIRED],
+                     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
+    ;;
+esac
+AC_SUBST([RADEON_CFLAGS])
+AC_SUBST([RADEON_LDFLAGS])
+
+
 dnl
 dnl OSMesa configuration
 dnl
@@ -1134,7 +1156,14 @@ yes)
         GALLIUM_STATE_TRACKERS_DIRS=glx
         ;;
     dri)
-        test "x$enable_egl" = xyes && GALLIUM_STATE_TRACKERS_DIRS=egl
+        GALLIUM_STATE_TRACKERS_DIRS="dri"
+        if test "x$enable_egl" = xyes; then
+            GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS egl"
+        fi
+        # Have only tested st/xorg on 1.6.0 servers
+        PKG_CHECK_MODULES(XORG, [xorg-server >= 1.6.0],
+            HAVE_XORG="yes"; GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS xorg",
+            HAVE_XORG="no")
         ;;
     esac
     ;;
@@ -1150,9 +1179,9 @@ yes)
         fi
         if test "$tracker" = xorg; then
            PKG_CHECK_MODULES(XEXT, [xextproto >= 7.0.99.1],
-                  HAVE_XEXTPROTO_71="yes"; DEFINES="$DEFINES -DHAVE_XEXTPROTO_71"
+                  HAVE_XEXTPROTO_71="yes"; DEFINES="$DEFINES -DHAVE_XEXTPROTO_71",
                   HAVE_XEXTPROTO_71="no")
-       fi
+        fi
     done
     GALLIUM_STATE_TRACKERS_DIRS="$state_trackers"
     ;;
@@ -1180,17 +1209,34 @@ AC_ARG_WITH([max-height],
            [AC_MSG_WARN([Large framebuffer: see s_tritemp.h comments.])])]
 )
 
+dnl
+dnl Gallium SVGA configuration
+dnl
+AC_ARG_ENABLE([gallium-svga],
+    [AS_HELP_STRING([--enable-gallium-svga],
+        [build gallium SVGA @<:@default=disabled@:>@])],
+    [enable_gallium_svga="$enableval"],
+    [enable_gallium_svga=auto])
+if test "x$enable_gallium_svga" = xyes; then
+    GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS vmware"
+    GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga"
+elif test "x$enable_gallium_svga" = xauto; then
+    GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga"
+fi
+
 dnl
 dnl Gallium Intel configuration
 dnl
 AC_ARG_ENABLE([gallium-intel],
-    [AS_HELP_STRING([--disable-gallium-intel],
-        [build gallium intel @<:@default=enabled@:>@])],
+    [AS_HELP_STRING([--enable-gallium-intel],
+        [build gallium intel @<:@default=disabled@:>@])],
     [enable_gallium_intel="$enableval"],
-    [enable_gallium_intel=yes])
+    [enable_gallium_intel=auto])
 if test "x$enable_gallium_intel" = xyes; then
-    GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS intel"
-    GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915"
+    GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS intel i965"
+    GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915 i965"
+elif test "x$enable_gallium_intel" = xauto; then
+    GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915 i965"
 fi
 
 dnl
@@ -1272,7 +1318,6 @@ if echo "$SRC_DIRS" | grep 'gallium' >/dev/null 2>&1; then
     echo "        Gallium dirs:    $GALLIUM_DIRS"
     echo "        Winsys dirs:     $GALLIUM_WINSYS_DIRS"
     echo "        Winsys drm dirs:$GALLIUM_WINSYS_DRM_DIRS"
-    echo "        Auxiliary dirs:  $GALLIUM_AUXILIARY_DIRS"
     echo "        Driver dirs:     $GALLIUM_DRIVERS_DIRS"
     echo "        Trackers dirs:   $GALLIUM_STATE_TRACKERS_DIRS"
 else
diff --git a/docs/GL3.txt b/docs/GL3.txt
new file mode 100644 (file)
index 0000000..df3fd74
--- /dev/null
@@ -0,0 +1,69 @@
+
+Status of OpenGL 3.x features in Mesa
+
+
+Note: when an item is marked as "DONE" it means all the core Mesa
+infrastructure is complete but it may be the case that few (if any) drivers
+implement the features.
+
+
+Feature                                               Status
+----------------------------------------------------- ------------------------
+
+GL 3.0:
+
+GLSL changes (GL_EXT_gpu_shader4, etc)                not started
+Conditional rendering (GL_NV_conditional_render)      DONE (swrast & softpipe)
+Map buffer subranges (GL_APPLE_flush_buffer_range)    not started
+Float textures, renderbuffers                         some infrastructure done
+Framebuffer objects (GL_EXT_framebuffer_object)       DONE
+Half-float                                            some infrastructure done
+Multisample blit                                      DONE
+Non-normalized Integer texture/framebuffer formats    not started
+1D/2D Texture arrays                                  mostly done
+Packed depth/stencil formats                          DONE
+Per-buffer blend and masks (GL_EXT_draw_buffers2)     DONE
+GL_EXT_texture_compression_rgtc                       not started
+Red and red/green texture formats                     Ian?
+Transform feedback (GL_EXT_transform_feedback)        not started
+Vertex array objects (GL_APPLE_vertex_array_object)   DONE
+sRGB framebuffer format (GL_EXT_framebuffer_sRGB)     not started
+glClearBuffer commands                                DONE, except for dispatch
+glGetStringi command                                  DONE, except for dispatch
+glTexParameterI, glGetTexParameterI commands          DONE, except for dispatch
+glVertexAttribI commands                              not started
+glBindFragDataLocation, glGetFragDataLocation cmds    not started
+glBindBufferRange, glBindBufferBase commands          not started
+
+
+GL 3.1:
+
+GLSL 1.30 and 1.40                                    not started
+Instanced drawing (GL_ARB_draw_instanced)             not started
+Buffer copying (GL_ARB_copy_buffer)                   DONE
+Primitive restart (GL_NV_primitive_restart)           not started
+16 vertex texture image units                         not started
+Texture buffer objs (GL_ARB_textur_buffer_object)     not started
+Rectangular textures (GL_ARB_texture_rectangle)       DONE
+Uniform buffer objs (GL_ARB_uniform_buffer_object)    not started
+Signed normalized texture formats                     not started
+
+
+GL 3.2:
+
+Core/compatibility profiles                           not started
+GLSL 1.50                                             not started
+Geometry shaders (GL_ARB_geometry_shader4)            partially done (Zack)
+BGRA vertex order (GL_ARB_vertex_array_bgra)          DONE
+Base vertex offset(GL_ARB_draw_elements_base_vertex)  DONE
+Frag shader coord (GL_ARB_fragment_coord_conventions) not started
+Provoking vertex (GL_ARB_provoking_vertex)            DONE
+Seamless cubemaps (GL_ARB_seamless_cube_map)          DONE, mostly?
+Multisample textures (GL_ARB_texture_multisample)     not started
+Frag depth clamp (GL_ARB_depth_clamp)                 DONE
+Fence objects (GL_ARB_sync)                           DONE
+
+
+
+More info about these features and the work involved can be found at
+http://dri.freedesktop.org/wiki/MissingFunctionality
index 97e1ffb7a754d7a40fbdca5a01a188193cc41c85..204b8e6604184d8562ef3cb400af0d4fdcbe905a 100644 (file)
@@ -27,12 +27,6 @@ using the SDK with Visual Studio Express can be found at
 
 http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/
 
-If you are stuck using VC6 or VC7, you may start with these project
-files, but you may need to modify them to reflect changes in the
-Mesa source code tree.  If you sucessfully update the project files,
-please submit them to the author of this document so that they may
-be included in the next distribution. 
-
 The project files to build the core Mesa library, Windows Mesa
 drivers, OSMesa, and GLU are in the mesa directory.  The project files
 to build GLUT and some demo programs are in the progs directory.
@@ -106,23 +100,6 @@ should build all the demos.
 Build System Notes
 ----- ------ -----
 
-VC6 (not actively supported)
----
-
-Visual Studio 6 does not recognize files with the .cc extension as C++
-language files, without a lot of unnatural tweaking.  So, the VC6
-build process uses custom build steps to compile these files in the
-GLU library.
-
-Two additional configurations are provided, Debug x86 and Release x86
-that activate the shader code compilation by defining SLANG_86.  It is
-unknown if and how this works.
-
-VC7 (not actively supported)
----
-
-The above-mentioned .cc problem does not exist in this version.
-
 VC8
 ---
 
index 6d7a321da9fb577c39e87adaea57a314ec2c402b..b2c0e01ee321cb7b5c66fd09a9a41d172f8711eb 100644 (file)
@@ -28,6 +28,7 @@ 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.
+<li>MESA_GLSL - <a href="shading.html#envvars">shading language options</a>
 </ul>
 
 <p>
index 953d2094d5b314dd87bb3899953fdc18cad45866..5aea92e0b5119dbbb526fee67d665435f6b84187 100644 (file)
 <h3>1.1 Prerequisites for DRI and hardware acceleration</h3>
 
 <p>
-The following are required for DRI-based hardware acceleration with Mesa 7.3:
+The following are required for DRI-based hardware acceleration with Mesa:
 </p>
 
 <ul>
 <li><a href="http://xorg.freedesktop.org/releases/individual/proto/">dri2proto</a> version 1.99.3 or later
 <li>Linux 2.6.28
 <li><a href="http://dri.freedesktop.org/libdrm/" target="_parent">libDRM</a>
-version 2.4.3 or later
+version 2.4.15 or later
 <li>Xorg server version 1.5 or later
 </ul>
 </p>
@@ -351,20 +351,11 @@ example linux or windows, <i>machine</i> is x86 or x86_64, optionally followed
 by -debug for debug builds.
 </p>
 
-<p>
-The sample programs are built seperately. To build them do
-<pre>
-    scons -C progs
-</pre>
-And the build output will be placed in progs/build/...
-</p>
-
 <p>
 To build Mesa with SCons for Windows on Linux using the MinGW crosscompiler toolchain do
 </p>
 <pre>
     scons platform=windows toolchain=crossmingw machine=x86 statetrackers=mesa drivers=softpipe,trace winsys=gdi
-    scons -C progs platform=windows toolchain=crossmingw machine=x86 -k
 </pre>
 <p>
 This will create:
diff --git a/docs/libGL.txt b/docs/libGL.txt
new file mode 100644 (file)
index 0000000..cb98840
--- /dev/null
@@ -0,0 +1,197 @@
+
+
+
+Introduction
+------------
+
+This document describes the implementation of the XFree86 4.0 libGL.so
+library defined by the Linux/OpenGL Base specification found at
+http://reality.sgi.com/opengl/linux/linuxbase.html.
+
+The documentation is divided into two sections:
+    User's Guide
+    Driver Developer's Guide
+
+Author:  Brian Paul     (brian@precisioninsight.com)
+Date:    February 2000
+
+
+
+User's Guide
+------------
+
+Using libGL.so
+
+The libGL.so library defines the gl- and glX-prefixed functions needed to
+run OpenGL programs.  OpenGL client applications should link with the
+-lGL option to use it.
+
+libGL.so serves two primary functions: GLX protocol generation for indirect
+rendering and loading/management of hardware drivers for direct rendering.
+
+When libGL.so initializes itself it uses the DRI to determine the
+appropriate hardware driver for each screen on the local X display.
+The hardware drivers are expected to be in the /usr/X11R6/lib/modules/dri/
+directory.  Drivers are named with the convention <name>_dri.so where
+<name> is a driver such as "tdfx", "i810", "gamma", etc.
+
+The LIBGL_DRIVERS_DIR environment variable may be used to specify a
+different DRI modules directory, overriding /usr/X11R6/lib/modules/dri/.
+This environment variable is ignored in setuid programs for security
+reasons.
+
+When libGL.so is unable to locate appropriate hardware drivers it will
+fall back to using indirect GLX rendering.
+
+To aid in solving problems, libGL.so will print diagnostic messages to
+stderr if the LIBGL_DEBUG environment variable is defined.
+
+libGL.so is thread safe.  The overhead of thread safety for common,
+single-thread clients is negligible.  However, the overhead of thread
+safety for multi-threaded clients is significant.  Each GL API call
+requires two calls to pthread_get_specific() which can noticably
+impact performance.  Warning:  libGL.so is thread safe but individual
+DRI drivers may not be.  Please consult the documentation for a driver
+to learn if it is thread safe.
+
+
+
+Indirect Rendering
+
+You can force indirect rendering mode by setting the LIBGL_ALWAYS_INDIRECT
+environment variable.  Hardware acceleration will not be used.
+
+
+
+libGL.so Extensibility
+
+libGL.so is designed to be extended without upgrading.  That is,
+drivers may install new OpenGL extension functions into libGL.so
+without requiring libGL.so to be replaced.  Clients of libGL.so should
+use the glXGetProcAddressEXT() function to obtain the address of
+functions by name.  For more details of GLX_ARB_get_proc_address see
+http://oss.sgi.com/projects/ogl-sample/registry/ARB/get_proc_address.spec
+
+libGL.so is also designed with flexibility such that it may be used
+with many generations of hardware drivers to come.
+
+
+
+
+Driver Developer's Guide
+------------------------
+
+This section describes the requirements to make an XFree86 4.0
+libGL.so-compatible hardware driver.  It is not intended for end
+users of libGL.so.
+
+
+XFree86 source files
+
+libGL.so is built inside XFree86 with sources found in xc/lib/GL/.
+Specifically, libGL.so is built from:
+
+       xc/lib/GL/glx/*.c
+       xc/lib/dri/XF86dri.c
+       xc/lib/dri/dri_glx.c
+       xc/lib/GL/mesa/src/glapi.c
+       xc/lib/GL/mesa/src/glapitemp.h
+       xc/lib/GL/mesa/src/glapitable.h
+       xc/lib/GL/mesa/src/glapioffsets.h
+       xc/lib/GL/mesa/src/glapinoop.c
+       xc/lib/GL/mesa/src/glheader.h
+       xc/lib/GL/mesa/src/glthread.c
+       xc/lib/GL/mesa/src/glthread.h
+       xc/lib/GL/mesa/src/X86/glapi_x86.S
+       xc/lib/GL/mesa/src/X86/assyntax.h
+
+Understand that the mesa/src/gl*.[ch] files are not tied to Mesa.  They
+have no dependencies on the rest of Mesa and are designed to be reusable
+in a number of projects.
+
+The glapi_x86.X and assyntax.h files implement x86-optimized dispatch
+of GL functions.  They are not required; C-based dispatch can be used
+instead, with a slight performance penalty.
+
+
+
+Driver loading and binding
+
+When libGL.so initializes itself (via the __glXInitialize function) a
+call is made to driCreateDisplay().  This function uses DRI facilities
+to determine the driver file appropriate for each screen on the local
+display.  Each screen's driver is then opened with dlopen() and asked
+for its __driCreateScreen() function.  The pointers to the __driCreateScreen()
+functions are kept in an array, indexed by screen number, in the
+__DRIdisplayRec struct.
+
+When a driver's __driCreateScreen() function is called, it must initialize
+a __DRIscreenRec struct.  This struct acts as the root of a tree of
+function pointers which are called to create and destroy contexts and
+drawables and perform all the operations needed by the GLX interface.
+See the xc/lib/GL/glx/glxclient.h file for details.
+
+
+
+Dynamic Extension Function Registration
+
+In order to provide forward compatibility with future drivers, libGL.so
+allows drivers to register new OpenGL extension functions which weren't
+known when libGL.so was built.
+
+The register_extensions() function in xc/lib/GL/dri/dri_glx.c is called
+as soon as libGL.so is loaded.  This is done with gcc's constructor
+attribute.  This mechanism will likely have to be changed for other compilers.
+
+register_extensions() loops over all local displays and screens, determines
+the DRI driver for each, and calls the driver's __driRegisterExtensions()
+function, if present.
+
+The __driRegisterExtensions() function can add new entrypoints to libGL
+by calling:
+
+    GLboolean _glapi_add_entrypoint(const char *funcName, GLuint offset)
+
+The parameters are the name of the function (such as "glFoobarEXT") and the
+offset of the dispatch slot in the API dispatch table.  The return value
+indicates success (GL_TRUE) or failure (GL_FALSE).
+
+_glapi_add_entrypoint() will synthesize entrypoint code in assembly
+language.  Assembly languages is required since parameter passing
+can't be handled correctly using a C-based solution.
+
+The address of the new entrypoint is obtained by calling the
+glXGetProcAddressARB() function.
+
+The dispatch offset number MUST be a number allocated by SGI in the same
+manner in which new GL_* constants are allocated.  Using an arbitrary
+offset number will result in many problems.
+
+
+
+Dispatch Management
+
+When a GL context is made current, the driver must install its dispatch
+table as the current dispatch table.  This is done by calling
+
+       void _glapi_set_dispatch(struct _glapi_table *dispatch);
+
+This will install the named dispatch table for the calling thread.
+The current dispatch table for a thread can be obtained by calling
+
+       struct _glapi_table *_glapi_get_dispatch(void);
+
+For higher performance in the common single-thread case, the global
+variable _glapi_Dispatch will point to the current dispatch table.
+This variable will be NULL when in multi-thread mode.
+
+
+
+Context Management
+
+libGL.so uses the XFree86 xthreads package to manage a thread-specific
+current context pointer.  See __glXGet/SetCurrentContext() in glext.c
+
+Drivers may use the _glapi_set/get_context() functions to maintain
+a private thread-specific context pointer.
+
index 93da56a5c330d6b8a5011ba7af91a5976f699bc5..0a0be715c1be226181a9822eaf55c50fc67d7399 100644 (file)
 
 <H1>News</H1>
 
+<h2>December 21, 2009</h2>
+<p>
+<a href="relnotes-7.6.1.html">Mesa 7.6.1</a> is released.  This is a bug-fix
+release fixing issues found in the 7.6 release.
+</p>
+<p>
+Also, <a href="relnotes-7.7.html">Mesa 7.7</a> is released.  This is a new
+development release.
+</p>
+
+
 <h2>September 28, 2009</h2>
 <p>
 <a href="relnotes-7.6.html">Mesa 7.6</a> is released.  This is a new feature
index 52a4728133ef3077362d12cb01bb1883a8a9e1b8..1d0ecd2ac09b6bd79099f43acc2287f5b7c01e89 100644 (file)
@@ -8,7 +8,7 @@
 
 <body bgcolor="#eeeeee">
 
-<H1>Mesa 7.6.1 Release Notes, (date tbd)</H1>
+<H1>Mesa 7.6.1 Release Notes, 21 December 2009</H1>
 
 <p>
 Mesa 7.6.1 is a bug-fix release fixing issues since version 7.6.
@@ -26,12 +26,23 @@ for DRI hardware acceleration.
 
 <h2>MD5 checksums</h2>
 <pre>
-tbd
+e80fabad2e3eb7990adae773d6aeacba  MesaLib-7.6.1.tar.gz
+7db4617e9e10ad3aca1b64339fd71b7d  MesaLib-7.6.1.tar.bz2
+dd3275dbf9833480d2e92d0c69b22abd  MesaLib-7.6.1.zip
+f7fdcfe3c0f363e571c60f02f74368fb  MesaDemos-7.6.1.tar.gz
+a4226f06732a02556fcf6be290b86dff  MesaDemos-7.6.1.tar.bz2
+849425f356bd940726cebedfa79de176  MesaDemos-7.6.1.zip
+d40cc7c5e337a85b674e27a8e494f52f  MesaGLUT-7.6.1.tar.gz
+ca9aecb91f05b1da9fd7d5eeb19d47d7  MesaGLUT-7.6.1.tar.bz2
+23fad8398004c977a1d8953079b72ca6  MesaGLUT-7.6.1.zip
 </pre>
 
 
 <h2>New features</h2>
 <ul>
+<li>Upgraded GL/glext.h to version 56, GL/glxext.h to version 25,
+    GL/wglext.h to version 17
+<li>New 3D driver, r600, for Radeon R6xx, R7xx hardware
 </ul>
 
 
@@ -43,7 +54,27 @@ tbd
 <li>Fixed default texture binding bug when a bound texture was deleted.
 <li>r300: Work around an issue with very large fragment programs on R500.
 <li>Fake glXQueryDrawable() didn't return good values (bug 24320)
+<li>Fixed AUX buffer breakage (bug 24426).
+<li>Fixed locale-dependent float parsing bug in GLSL compiler (bug 24531)
+<li>Fixed Gallium Cell driver compilation failure.
+<li>Fixed glGetTexLevelParameter(GL_TEXTURE_INTERNAL_FORMAT) query so that
+    it returns the actual compressed format chosen.
+<li>Fixed glBitmap bugs in Intel drivers.
+<li>Fixed a number of Microsoft Visual Studio compilation problems.
+<li>Fixed clipping / provoking vertex bugs in i965 driver.
+<li>Assorted build fixes for AIX.
+<li>Endianness fixes for the DRI swrast driver (bug 22767).</li>
+<li>Point sprite fixes for i915/945 driver.
+<li>Fixed assorted memory leaks (usually on error paths)
+<li>Fixed some GLSL compiler bugs (ex: 25579)
+<li>Assorted build fixes for BlueGene
 </ul>
 
+<h2>Changes</h2>
+<ul>
+<li>Removed old VC6, VC7 project files for Windows
+</ul>
+
+
 </body>
 </html>
diff --git a/docs/relnotes-7.7.1.html b/docs/relnotes-7.7.1.html
new file mode 100644 (file)
index 0000000..61a1167
--- /dev/null
@@ -0,0 +1,48 @@
+<HTML>
+
+<TITLE>Mesa Release Notes</TITLE>
+
+<head><link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<body bgcolor="#eeeeee">
+
+<H1>Mesa 7.7.1 Release Notes / date tbd</H1>
+
+<p>
+Mesa 7.7.1 is a bug-fix release.
+</p>
+<p>
+Mesa 7.7.1 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>tbd
+</ul>
+
+
+<h2>Bug fixes</h2>
+<ul>
+<li>Assorted fixes to VMware SVGA gallium driver.
+<li>Fixed broken blending to multiple color buffers in swrast driver.
+<li>Allocate constants more tightly in GL_ARB_vertex/fragment parser.
+</ul>
+
+
+</body>
+</html>
index 856b8fae3d7b175cfa3d71ead205fe6fb9b043d9..c1ed6546135d7b5ae2c8036a63027d4e29104cbf 100644 (file)
@@ -8,7 +8,7 @@
 
 <body bgcolor="#eeeeee">
 
-<H1>Mesa 7.7 Release Notes / date TBD</H1>
+<H1>Mesa 7.7 Release Notes / 21 December 2009</H1>
 
 <p>
 Mesa 7.7 is a new development release.
@@ -28,12 +28,23 @@ for DRI hardware acceleration.
 
 <h2>MD5 checksums</h2>
 <pre>
-tbd
+395c9516edf1ad54b0934d8db15557bf  MesaLib-7.7.tar.gz
+e3fa64a1508bc23dd9de9dd2cea7cfb1  MesaLib-7.7.tar.bz2
+e54903eb5e49c3969821fa16b32da245  MesaLib-7.7.zip
+53b5b6f78e55de170d43c98cb6aaab7e  MesaDemos-7.7.tar.gz
+6fd616b27b9826d0faa23e08e05d9435  MesaDemos-7.7.tar.bz2
+240fe06159ad73d5e22c27033b66c80a  MesaDemos-7.7.zip
+9fe11a904b2a9d8cd06cc52bc330b716  MesaGLUT-7.7.tar.gz
+e8dceed05a59a2d3c2619d7d734587e3  MesaGLUT-7.7.tar.bz2
+96af041d435349ee23ead4667ec36363  MesaGLUT-7.7.zip
 </pre>
 
 
 <h2>New features</h2>
 <ul>
+<li>VMware "SVGA" Gallium driver.  This is a Gallium3D driver which targets the
+    VMware virtual graphics device.  It allows Linux OpenGL guest applications
+    to utilize the 3D graphics hardware of the host operating system.
 <li>GL_ARB_draw_elements_base_vertex (supported in Intel i965 and software drivers)</li>
 <li>GL_ARB_depth_clamp (supported in Intel i965 DRI and software drivers)</li>
 <li>GL_NV_depth_clamp (supported in Intel i965 DRI and software drivers)</li>
@@ -44,11 +55,15 @@ tbd
 
 <h2>Bug fixes</h2>
 <ul>
+<li>Many assorted i965 driver fixes.
+<li>Many r300-gallium driver fixes; this driver is now considered unstable-quality instead of experimental-quality.
 </ul>
 
 
 <h2>Changes</h2>
 <ul>
+<li>New Mesa texture/surface format infrastructure
+<li>Removed some unused Mesa device driver hooks
 </ul>
 
 </body>
diff --git a/docs/relnotes-7.8.html b/docs/relnotes-7.8.html
new file mode 100644 (file)
index 0000000..717b962
--- /dev/null
@@ -0,0 +1,54 @@
+<HTML>
+
+<TITLE>Mesa Release Notes</TITLE>
+
+<head><link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<body bgcolor="#eeeeee">
+
+<H1>Mesa 7.8 Release Notes / date TBD</H1>
+
+<p>
+Mesa 7.8 is a new development release.
+People who are concerned with stability and reliability should stick
+with a previous release or wait for Mesa 7.8.1.
+</p>
+<p>
+Mesa 7.8 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>GL_NV_conditional_render extension (swrast driver only)
+<li>GL_EXT_draw_buffers2 extension (swrast driver only)
+</ul>
+
+
+<h2>Bug fixes</h2>
+<ul>
+<li>TBD
+</ul>
+
+
+<h2>Changes</h2>
+<ul>
+<li>TBD
+</ul>
+
+</body>
+</html>
index b301ee046a70606e6e93a042e46d05f4e43fe9f1..f1f95c5d3cad184ddc8ce3c5cbd7cf71d64c49e5 100644 (file)
@@ -13,6 +13,9 @@ The release notes summarize what's new or changed in each Mesa release.
 </p>
 
 <UL>
+<<<<<<< HEAD:docs/relnotes.html
+<LI><A HREF="relnotes-7.8.html">7.8 release notes</A>
+<LI><A HREF="relnotes-7.7.1.html">7.7.1 release notes</A>
 <LI><A HREF="relnotes-7.7.html">7.7 release notes</A>
 <LI><A HREF="relnotes-7.6.1.html">7.6.1 release notes</A>
 <LI><A HREF="relnotes-7.6.html">7.6 release notes</A>
index 77c86be3aa63e2e55109757d41b5550410b90885..bd02335a803d0ccd4bb9512c9b8bc0b59e0f1f16 100644 (file)
@@ -39,7 +39,8 @@ Contents
 
 <p>
 The <b>MESA_GLSL</b> environment variable can be set to a comma-separated
-list of keywords to control some aspects of the GLSL compiler:
+list of keywords to control some aspects of the GLSL compiler and shader
+execution.  These are generally used for debugging.
 </p>
 <ul>
 <li>dump - print GLSL shader code to stdout at link time
@@ -49,6 +50,12 @@ list of keywords to control some aspects of the GLSL compiler:
 <li>nopt - disable compiler optimizations
 <li>opt - force compiler optimizations
 <li>uniform - print message to stdout when glUniform is called
+<li>nopvert - force vertex shaders to be a simple shader that just transforms
+    the vertex position with ftransform() and passes through the color and
+    texcoord[0] attributes.
+<li>nopfrag - force fragment shader to be a simple shader that passes
+    through the color attribute.
+<li>useprog - log glUseProgram calls to stderr
 </ul>
 <p>
 Example:  export MESA_GLSL=dump,nopt
index 4c1434460e9ee9bb955ed53764765c6c6110a5db..f0ff36075a5aa2a78d03972043d503fea8b29804 100644 (file)
@@ -33,8 +33,7 @@
   
   - Pipe drivers:
     - \ref softpipe
-    - \ref i915simple
-    - Simple 965 driver (brw_context.h, brw_winsys.h)
+    - \ref i915g
     - Cell driver (cell_context.h, cell_winsys.h)
     - \ref failover
 
   \sa sp_winsys.h
 */
 
-/** \page i915simple Simple i915 Driver
+/** \page i915g i915 Driver
 
   The i915 Gallium3D Driver is an initial hardware driver implementation within
   the Gallium3D driver architecture. We expect that once complete this driver
   The Draw module is effectively the part of \ref softpipe which is concerned with
   vertex processing, split off into a separate module so that it can be reused
   by drivers for rasterization-only hardware. As such it is also instantiated
-  by the \ref i915simple driver.
+  by the \ref i915g driver.
 
   Additionally, there are cases in the Mesa OpenGL state_tracker where it is
   required to obtain transformed vertices and yet it is anticipated that using
index 9e83b600035e8774f01c1e94e384e982c1419784..09abb5d844a360056a080492ad26af9d05a48eee 100644 (file)
 #include <stdint.h>
 #endif
 
+#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303
+#  define EGLAPI __attribute__((visibility("default")))
+#  define EGLAPIENTRY
+#endif
+
 /* Macros used in EGL function prototype declarations.
  *
  * EGLAPI return-type EGLAPIENTRY eglFunction(arguments);
index 5f8bc2b708c4a08186c569925c311c541ee28bc7..c163171dc763bd3674081cba0f8d144a895c604c 100644 (file)
@@ -85,7 +85,9 @@
  * glut.h or gl.h.
  */
 #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__)
+#ifndef WIN32_LEAN_AND_MEAN
 #define WIN32_LEAN_AND_MEAN 1
+#endif
 #include <windows.h>
 #endif
 
index 54147f73382a0aab694b48eaddbac9146bfce344..b292840f917d94ab33733fd21102f9f09443a68d 100644 (file)
@@ -30,6 +30,7 @@
 /*REGENERATE_TO_END-----------ALL LINES BELOW HERE GET REPLACED ON REGENERATION */
 
 #define glAccum                MANGLE(Accum)
+#define glActiveProgramEXT             MANGLE(ActiveProgramEXT)
 #define glActiveStencilFaceEXT         MANGLE(ActiveStencilFaceEXT)
 #define glActiveTextureARB             MANGLE(ActiveTextureARB)
 #define glActiveTexture                MANGLE(ActiveTexture)
@@ -60,6 +61,7 @@
 #define glBeginTransformFeedback               MANGLE(BeginTransformFeedback)
 #define glBeginTransformFeedbackNV             MANGLE(BeginTransformFeedbackNV)
 #define glBeginVertexShaderEXT         MANGLE(BeginVertexShaderEXT)
+#define glBeginVideoCaptureNV          MANGLE(BeginVideoCaptureNV)
 #define glBindAttribLocationARB                MANGLE(BindAttribLocationARB)
 #define glBindAttribLocation           MANGLE(BindAttribLocation)
 #define glBindBufferARB                MANGLE(BindBufferARB)
@@ -93,6 +95,8 @@
 #define glBindVertexArrayAPPLE         MANGLE(BindVertexArrayAPPLE)
 #define glBindVertexArray              MANGLE(BindVertexArray)
 #define glBindVertexShaderEXT          MANGLE(BindVertexShaderEXT)
+#define glBindVideoCaptureStreamBufferNV               MANGLE(BindVideoCaptureStreamBufferNV)
+#define glBindVideoCaptureStreamTextureNV              MANGLE(BindVideoCaptureStreamTextureNV)
 #define glBinormal3bEXT                MANGLE(Binormal3bEXT)
 #define glBinormal3bvEXT               MANGLE(Binormal3bvEXT)
 #define glBinormal3dEXT                MANGLE(Binormal3dEXT)
 #define glBlendColorEXT                MANGLE(BlendColorEXT)
 #define glBlendColor           MANGLE(BlendColor)
 #define glBlendEquationEXT             MANGLE(BlendEquationEXT)
+#define glBlendEquationi               MANGLE(BlendEquationi)
+#define glBlendEquationIndexedAMD              MANGLE(BlendEquationIndexedAMD)
 #define glBlendEquation                MANGLE(BlendEquation)
 #define glBlendEquationSeparateATI             MANGLE(BlendEquationSeparateATI)
 #define glBlendEquationSeparateEXT             MANGLE(BlendEquationSeparateEXT)
+#define glBlendEquationSeparatei               MANGLE(BlendEquationSeparatei)
+#define glBlendEquationSeparateIndexedAMD              MANGLE(BlendEquationSeparateIndexedAMD)
 #define glBlendEquationSeparate                MANGLE(BlendEquationSeparate)
+#define glBlendFunci           MANGLE(BlendFunci)
+#define glBlendFuncIndexedAMD          MANGLE(BlendFuncIndexedAMD)
 #define glBlendFunc            MANGLE(BlendFunc)
 #define glBlendFuncSeparateEXT         MANGLE(BlendFuncSeparateEXT)
+#define glBlendFuncSeparatei           MANGLE(BlendFuncSeparatei)
+#define glBlendFuncSeparateIndexedAMD          MANGLE(BlendFuncSeparateIndexedAMD)
 #define glBlendFuncSeparateINGR                MANGLE(BlendFuncSeparateINGR)
 #define glBlendFuncSeparate            MANGLE(BlendFuncSeparate)
 #define glBlitFramebufferEXT           MANGLE(BlitFramebufferEXT)
 #define glBlitFramebuffer              MANGLE(BlitFramebuffer)
+#define glBufferAddressRangeNV         MANGLE(BufferAddressRangeNV)
 #define glBufferDataARB                MANGLE(BufferDataARB)
 #define glBufferData           MANGLE(BufferData)
 #define glBufferParameteriAPPLE                MANGLE(BufferParameteriAPPLE)
 #define glClientActiveTexture          MANGLE(ClientActiveTexture)
 #define glClientActiveVertexStreamATI          MANGLE(ClientActiveVertexStreamATI)
 #define glClientAttribDefaultEXT               MANGLE(ClientAttribDefaultEXT)
+#define glClientWaitSync               MANGLE(ClientWaitSync)
 #define glClipPlane            MANGLE(ClipPlane)
 #define glColor3b              MANGLE(Color3b)
 #define glColor3bv             MANGLE(Color3bv)
 #define glColor4uiv            MANGLE(Color4uiv)
 #define glColor4us             MANGLE(Color4us)
 #define glColor4usv            MANGLE(Color4usv)
+#define glColorFormatNV                MANGLE(ColorFormatNV)
 #define glColorFragmentOp1ATI          MANGLE(ColorFragmentOp1ATI)
 #define glColorFragmentOp2ATI          MANGLE(ColorFragmentOp2ATI)
 #define glColorFragmentOp3ATI          MANGLE(ColorFragmentOp3ATI)
 #define glCopyConvolutionFilter1D              MANGLE(CopyConvolutionFilter1D)
 #define glCopyConvolutionFilter2DEXT           MANGLE(CopyConvolutionFilter2DEXT)
 #define glCopyConvolutionFilter2D              MANGLE(CopyConvolutionFilter2D)
+#define glCopyImageSubDataNV           MANGLE(CopyImageSubDataNV)
 #define glCopyMultiTexImage1DEXT               MANGLE(CopyMultiTexImage1DEXT)
 #define glCopyMultiTexImage2DEXT               MANGLE(CopyMultiTexImage2DEXT)
 #define glCopyMultiTexSubImage1DEXT            MANGLE(CopyMultiTexSubImage1DEXT)
 #define glCreateProgramObjectARB               MANGLE(CreateProgramObjectARB)
 #define glCreateShader         MANGLE(CreateShader)
 #define glCreateShaderObjectARB                MANGLE(CreateShaderObjectARB)
+#define glCreateShaderProgramEXT               MANGLE(CreateShaderProgramEXT)
 #define glCullFace             MANGLE(CullFace)
 #define glCullParameterdvEXT           MANGLE(CullParameterdvEXT)
 #define glCullParameterfvEXT           MANGLE(CullParameterfvEXT)
 #define glDeleteRenderbuffersEXT               MANGLE(DeleteRenderbuffersEXT)
 #define glDeleteRenderbuffers          MANGLE(DeleteRenderbuffers)
 #define glDeleteShader         MANGLE(DeleteShader)
+#define glDeleteSync           MANGLE(DeleteSync)
 #define glDeleteTexturesEXT            MANGLE(DeleteTexturesEXT)
 #define glDeleteTextures               MANGLE(DeleteTextures)
 #define glDeleteTransformFeedbacksNV           MANGLE(DeleteTransformFeedbacksNV)
 #define glDisableIndexedEXT            MANGLE(DisableIndexedEXT)
 #define glDisable              MANGLE(Disable)
 #define glDisableVariantClientStateEXT         MANGLE(DisableVariantClientStateEXT)
+#define glDisableVertexAttribAPPLE             MANGLE(DisableVertexAttribAPPLE)
 #define glDisableVertexAttribArrayARB          MANGLE(DisableVertexAttribArrayARB)
 #define glDisableVertexAttribArray             MANGLE(DisableVertexAttribArray)
 #define glDrawArraysEXT                MANGLE(DrawArraysEXT)
 #define glDrawBuffers          MANGLE(DrawBuffers)
 #define glDrawElementArrayAPPLE                MANGLE(DrawElementArrayAPPLE)
 #define glDrawElementArrayATI          MANGLE(DrawElementArrayATI)
+#define glDrawElementsBaseVertex               MANGLE(DrawElementsBaseVertex)
 #define glDrawElementsInstancedARB             MANGLE(DrawElementsInstancedARB)
+#define glDrawElementsInstancedBaseVertex              MANGLE(DrawElementsInstancedBaseVertex)
 #define glDrawElementsInstancedEXT             MANGLE(DrawElementsInstancedEXT)
 #define glDrawElementsInstanced                MANGLE(DrawElementsInstanced)
 #define glDrawElements         MANGLE(DrawElements)
 #define glDrawPixels           MANGLE(DrawPixels)
 #define glDrawRangeElementArrayAPPLE           MANGLE(DrawRangeElementArrayAPPLE)
 #define glDrawRangeElementArrayATI             MANGLE(DrawRangeElementArrayATI)
+#define glDrawRangeElementsBaseVertex          MANGLE(DrawRangeElementsBaseVertex)
 #define glDrawRangeElementsEXT         MANGLE(DrawRangeElementsEXT)
 #define glDrawRangeElements            MANGLE(DrawRangeElements)
 #define glDrawTransformFeedbackNV              MANGLE(DrawTransformFeedbackNV)
+#define glEdgeFlagFormatNV             MANGLE(EdgeFlagFormatNV)
 #define glEdgeFlag             MANGLE(EdgeFlag)
 #define glEdgeFlagPointerEXT           MANGLE(EdgeFlagPointerEXT)
 #define glEdgeFlagPointerListIBM               MANGLE(EdgeFlagPointerListIBM)
 #define glEnableIndexedEXT             MANGLE(EnableIndexedEXT)
 #define glEnable               MANGLE(Enable)
 #define glEnableVariantClientStateEXT          MANGLE(EnableVariantClientStateEXT)
+#define glEnableVertexAttribAPPLE              MANGLE(EnableVertexAttribAPPLE)
 #define glEnableVertexAttribArrayARB           MANGLE(EnableVertexAttribArrayARB)
 #define glEnableVertexAttribArray              MANGLE(EnableVertexAttribArray)
 #define glEndConditionalRender         MANGLE(EndConditionalRender)
 #define glEndTransformFeedback         MANGLE(EndTransformFeedback)
 #define glEndTransformFeedbackNV               MANGLE(EndTransformFeedbackNV)
 #define glEndVertexShaderEXT           MANGLE(EndVertexShaderEXT)
+#define glEndVideoCaptureNV            MANGLE(EndVideoCaptureNV)
 #define glEvalCoord1d          MANGLE(EvalCoord1d)
 #define glEvalCoord1dv         MANGLE(EvalCoord1dv)
 #define glEvalCoord1f          MANGLE(EvalCoord1f)
 #define glExecuteProgramNV             MANGLE(ExecuteProgramNV)
 #define glExtractComponentEXT          MANGLE(ExtractComponentEXT)
 #define glFeedbackBuffer               MANGLE(FeedbackBuffer)
+#define glFenceSync            MANGLE(FenceSync)
 #define glFinalCombinerInputNV         MANGLE(FinalCombinerInputNV)
 #define glFinishAsyncSGIX              MANGLE(FinishAsyncSGIX)
 #define glFinishFenceAPPLE             MANGLE(FinishFenceAPPLE)
 #define glFogCoorddv           MANGLE(FogCoorddv)
 #define glFogCoordfEXT         MANGLE(FogCoordfEXT)
 #define glFogCoordf            MANGLE(FogCoordf)
+#define glFogCoordFormatNV             MANGLE(FogCoordFormatNV)
 #define glFogCoordfvEXT                MANGLE(FogCoordfvEXT)
 #define glFogCoordfv           MANGLE(FogCoordfv)
 #define glFogCoordhNV          MANGLE(FogCoordhNV)
 #define glFramebufferTextureEXT                MANGLE(FramebufferTextureEXT)
 #define glFramebufferTextureFaceARB            MANGLE(FramebufferTextureFaceARB)
 #define glFramebufferTextureFaceEXT            MANGLE(FramebufferTextureFaceEXT)
+#define glFramebufferTextureFace               MANGLE(FramebufferTextureFace)
 #define glFramebufferTextureLayerARB           MANGLE(FramebufferTextureLayerARB)
 #define glFramebufferTextureLayerEXT           MANGLE(FramebufferTextureLayerEXT)
 #define glFramebufferTextureLayer              MANGLE(FramebufferTextureLayer)
+#define glFramebufferTexture           MANGLE(FramebufferTexture)
 #define glFrameTerminatorGREMEDY               MANGLE(FrameTerminatorGREMEDY)
 #define glFrameZoomSGIX                MANGLE(FrameZoomSGIX)
 #define glFreeObjectBufferATI          MANGLE(FreeObjectBufferATI)
 #define glGetBooleanIndexedvEXT                MANGLE(GetBooleanIndexedvEXT)
 #define glGetBooleani_v                MANGLE(GetBooleani_v)
 #define glGetBooleanv          MANGLE(GetBooleanv)
+#define glGetBufferParameteri64v               MANGLE(GetBufferParameteri64v)
 #define glGetBufferParameterivARB              MANGLE(GetBufferParameterivARB)
 #define glGetBufferParameteriv         MANGLE(GetBufferParameteriv)
+#define glGetBufferParameterui64vNV            MANGLE(GetBufferParameterui64vNV)
 #define glGetBufferPointervARB         MANGLE(GetBufferPointervARB)
 #define glGetBufferPointerv            MANGLE(GetBufferPointerv)
 #define glGetBufferSubDataARB          MANGLE(GetBufferSubDataARB)
 #define glGetImageTransformParameterivHP               MANGLE(GetImageTransformParameterivHP)
 #define glGetInfoLogARB                MANGLE(GetInfoLogARB)
 #define glGetInstrumentsSGIX           MANGLE(GetInstrumentsSGIX)
+#define glGetInteger64i_v              MANGLE(GetInteger64i_v)
+#define glGetInteger64v                MANGLE(GetInteger64v)
 #define glGetIntegerIndexedvEXT                MANGLE(GetIntegerIndexedvEXT)
 #define glGetIntegeri_v                MANGLE(GetIntegeri_v)
+#define glGetIntegerui64i_vNV          MANGLE(GetIntegerui64i_vNV)
+#define glGetIntegerui64vNV            MANGLE(GetIntegerui64vNV)
 #define glGetIntegerv          MANGLE(GetIntegerv)
 #define glGetInvariantBooleanvEXT              MANGLE(GetInvariantBooleanvEXT)
 #define glGetInvariantFloatvEXT                MANGLE(GetInvariantFloatvEXT)
 #define glGetMinmaxParameterfv         MANGLE(GetMinmaxParameterfv)
 #define glGetMinmaxParameterivEXT              MANGLE(GetMinmaxParameterivEXT)
 #define glGetMinmaxParameteriv         MANGLE(GetMinmaxParameteriv)
+#define glGetMultisamplefv             MANGLE(GetMultisamplefv)
 #define glGetMultisamplefvNV           MANGLE(GetMultisamplefvNV)
 #define glGetMultiTexEnvfvEXT          MANGLE(GetMultiTexEnvfvEXT)
 #define glGetMultiTexEnvivEXT          MANGLE(GetMultiTexEnvivEXT)
 #define glGetMultiTexParameterIuivEXT          MANGLE(GetMultiTexParameterIuivEXT)
 #define glGetMultiTexParameterivEXT            MANGLE(GetMultiTexParameterivEXT)
 #define glGetNamedBufferParameterivEXT         MANGLE(GetNamedBufferParameterivEXT)
+#define glGetNamedBufferParameterui64vNV               MANGLE(GetNamedBufferParameterui64vNV)
 #define glGetNamedBufferPointervEXT            MANGLE(GetNamedBufferPointervEXT)
 #define glGetNamedBufferSubDataEXT             MANGLE(GetNamedBufferSubDataEXT)
 #define glGetNamedFramebufferAttachmentParameterivEXT          MANGLE(GetNamedFramebufferAttachmentParameterivEXT)
 #define glGetObjectBufferfvATI         MANGLE(GetObjectBufferfvATI)
 #define glGetObjectBufferivATI         MANGLE(GetObjectBufferivATI)
 #define glGetObjectParameterfvARB              MANGLE(GetObjectParameterfvARB)
+#define glGetObjectParameterivAPPLE            MANGLE(GetObjectParameterivAPPLE)
 #define glGetObjectParameterivARB              MANGLE(GetObjectParameterivARB)
 #define glGetOcclusionQueryivNV                MANGLE(GetOcclusionQueryivNV)
 #define glGetOcclusionQueryuivNV               MANGLE(GetOcclusionQueryuivNV)
 #define glGetSharpenTexFuncSGIS                MANGLE(GetSharpenTexFuncSGIS)
 #define glGetStringi           MANGLE(GetStringi)
 #define glGetString            MANGLE(GetString)
+#define glGetSynciv            MANGLE(GetSynciv)
 #define glGetTexBumpParameterfvATI             MANGLE(GetTexBumpParameterfvATI)
 #define glGetTexBumpParameterivATI             MANGLE(GetTexBumpParameterivATI)
 #define glGetTexEnvfv          MANGLE(GetTexEnvfv)
 #define glGetTexParameterIuivEXT               MANGLE(GetTexParameterIuivEXT)
 #define glGetTexParameterIuiv          MANGLE(GetTexParameterIuiv)
 #define glGetTexParameteriv            MANGLE(GetTexParameteriv)
+#define glGetTexParameterPointervAPPLE         MANGLE(GetTexParameterPointervAPPLE)
 #define glGetTextureImageEXT           MANGLE(GetTextureImageEXT)
 #define glGetTextureLevelParameterfvEXT                MANGLE(GetTextureLevelParameterfvEXT)
 #define glGetTextureLevelParameterivEXT                MANGLE(GetTextureLevelParameterivEXT)
 #define glGetUniformLocationARB                MANGLE(GetUniformLocationARB)
 #define glGetUniformLocation           MANGLE(GetUniformLocation)
 #define glGetUniformOffsetEXT          MANGLE(GetUniformOffsetEXT)
+#define glGetUniformui64vNV            MANGLE(GetUniformui64vNV)
 #define glGetUniformuivEXT             MANGLE(GetUniformuivEXT)
 #define glGetUniformuiv                MANGLE(GetUniformuiv)
 #define glGetVariantArrayObjectfvATI           MANGLE(GetVariantArrayObjectfvATI)
 #define glGetVertexAttribPointervARB           MANGLE(GetVertexAttribPointervARB)
 #define glGetVertexAttribPointerv              MANGLE(GetVertexAttribPointerv)
 #define glGetVertexAttribPointervNV            MANGLE(GetVertexAttribPointervNV)
+#define glGetVideoCaptureivNV          MANGLE(GetVideoCaptureivNV)
+#define glGetVideoCaptureStreamdvNV            MANGLE(GetVideoCaptureStreamdvNV)
+#define glGetVideoCaptureStreamfvNV            MANGLE(GetVideoCaptureStreamfvNV)
+#define glGetVideoCaptureStreamivNV            MANGLE(GetVideoCaptureStreamivNV)
 #define glGetVideoi64vNV               MANGLE(GetVideoi64vNV)
 #define glGetVideoivNV         MANGLE(GetVideoivNV)
 #define glGetVideoui64vNV              MANGLE(GetVideoui64vNV)
 #define glIndexd               MANGLE(Indexd)
 #define glIndexdv              MANGLE(Indexdv)
 #define glIndexf               MANGLE(Indexf)
+#define glIndexFormatNV                MANGLE(IndexFormatNV)
 #define glIndexFuncEXT         MANGLE(IndexFuncEXT)
 #define glIndexfv              MANGLE(Indexfv)
 #define glIndexi               MANGLE(Indexi)
 #define glIsAsyncMarkerSGIX            MANGLE(IsAsyncMarkerSGIX)
 #define glIsBufferARB          MANGLE(IsBufferARB)
 #define glIsBuffer             MANGLE(IsBuffer)
+#define glIsBufferResidentNV           MANGLE(IsBufferResidentNV)
 #define glIsEnabledi           MANGLE(IsEnabledi)
 #define glIsEnabledIndexedEXT          MANGLE(IsEnabledIndexedEXT)
 #define glIsEnabled            MANGLE(IsEnabled)
 #define glIsFramebufferEXT             MANGLE(IsFramebufferEXT)
 #define glIsFramebuffer                MANGLE(IsFramebuffer)
 #define glIsList               MANGLE(IsList)
+#define glIsNamedBufferResidentNV              MANGLE(IsNamedBufferResidentNV)
 #define glIsObjectBufferATI            MANGLE(IsObjectBufferATI)
 #define glIsOcclusionQueryNV           MANGLE(IsOcclusionQueryNV)
 #define glIsProgramARB         MANGLE(IsProgramARB)
 #define glIsRenderbufferEXT            MANGLE(IsRenderbufferEXT)
 #define glIsRenderbuffer               MANGLE(IsRenderbuffer)
 #define glIsShader             MANGLE(IsShader)
+#define glIsSync               MANGLE(IsSync)
 #define glIsTextureEXT         MANGLE(IsTextureEXT)
 #define glIsTexture            MANGLE(IsTexture)
 #define glIsTransformFeedbackNV                MANGLE(IsTransformFeedbackNV)
 #define glIsVariantEnabledEXT          MANGLE(IsVariantEnabledEXT)
 #define glIsVertexArrayAPPLE           MANGLE(IsVertexArrayAPPLE)
 #define glIsVertexArray                MANGLE(IsVertexArray)
+#define glIsVertexAttribEnabledAPPLE           MANGLE(IsVertexAttribEnabledAPPLE)
 #define glLightEnviSGIX                MANGLE(LightEnviSGIX)
 #define glLightf               MANGLE(Lightf)
 #define glLightfv              MANGLE(Lightfv)
 #define glLoadTransposeMatrixf         MANGLE(LoadTransposeMatrixf)
 #define glLockArraysEXT                MANGLE(LockArraysEXT)
 #define glLogicOp              MANGLE(LogicOp)
+#define glMakeBufferNonResidentNV              MANGLE(MakeBufferNonResidentNV)
+#define glMakeBufferResidentNV         MANGLE(MakeBufferResidentNV)
 #define glMap1d                MANGLE(Map1d)
 #define glMap1f                MANGLE(Map1f)
 #define glMap2d                MANGLE(Map2d)
 #define glMapObjectBufferATI           MANGLE(MapObjectBufferATI)
 #define glMapParameterfvNV             MANGLE(MapParameterfvNV)
 #define glMapParameterivNV             MANGLE(MapParameterivNV)
+#define glMapVertexAttrib1dAPPLE               MANGLE(MapVertexAttrib1dAPPLE)
+#define glMapVertexAttrib1fAPPLE               MANGLE(MapVertexAttrib1fAPPLE)
+#define glMapVertexAttrib2dAPPLE               MANGLE(MapVertexAttrib2dAPPLE)
+#define glMapVertexAttrib2fAPPLE               MANGLE(MapVertexAttrib2fAPPLE)
 #define glMaterialf            MANGLE(Materialf)
 #define glMaterialfv           MANGLE(Materialfv)
 #define glMateriali            MANGLE(Materiali)
 #define glMatrixTranslatefEXT          MANGLE(MatrixTranslatefEXT)
 #define glMinmaxEXT            MANGLE(MinmaxEXT)
 #define glMinmax               MANGLE(Minmax)
+#define glMinSampleShading             MANGLE(MinSampleShading)
 #define glMultiDrawArraysEXT           MANGLE(MultiDrawArraysEXT)
 #define glMultiDrawArrays              MANGLE(MultiDrawArrays)
 #define glMultiDrawElementArrayAPPLE           MANGLE(MultiDrawElementArrayAPPLE)
+#define glMultiDrawElementsBaseVertex          MANGLE(MultiDrawElementsBaseVertex)
 #define glMultiDrawElementsEXT         MANGLE(MultiDrawElementsEXT)
 #define glMultiDrawElements            MANGLE(MultiDrawElements)
 #define glMultiDrawRangeElementArrayAPPLE              MANGLE(MultiDrawRangeElementArrayAPPLE)
 #define glNamedFramebufferTextureEXT           MANGLE(NamedFramebufferTextureEXT)
 #define glNamedFramebufferTextureFaceEXT               MANGLE(NamedFramebufferTextureFaceEXT)
 #define glNamedFramebufferTextureLayerEXT              MANGLE(NamedFramebufferTextureLayerEXT)
+#define glNamedMakeBufferNonResidentNV         MANGLE(NamedMakeBufferNonResidentNV)
+#define glNamedMakeBufferResidentNV            MANGLE(NamedMakeBufferResidentNV)
 #define glNamedProgramLocalParameter4dEXT              MANGLE(NamedProgramLocalParameter4dEXT)
 #define glNamedProgramLocalParameter4dvEXT             MANGLE(NamedProgramLocalParameter4dvEXT)
 #define glNamedProgramLocalParameter4fEXT              MANGLE(NamedProgramLocalParameter4fEXT)
 #define glNormal3iv            MANGLE(Normal3iv)
 #define glNormal3s             MANGLE(Normal3s)
 #define glNormal3sv            MANGLE(Normal3sv)
+#define glNormalFormatNV               MANGLE(NormalFormatNV)
 #define glNormalPointerEXT             MANGLE(NormalPointerEXT)
 #define glNormalPointerListIBM         MANGLE(NormalPointerListIBM)
 #define glNormalPointer                MANGLE(NormalPointer)
 #define glNormalStream3ivATI           MANGLE(NormalStream3ivATI)
 #define glNormalStream3sATI            MANGLE(NormalStream3sATI)
 #define glNormalStream3svATI           MANGLE(NormalStream3svATI)
+#define glObjectPurgeableAPPLE         MANGLE(ObjectPurgeableAPPLE)
+#define glObjectUnpurgeableAPPLE               MANGLE(ObjectUnpurgeableAPPLE)
 #define glOrtho                MANGLE(Ortho)
 #define glPassTexCoordATI              MANGLE(PassTexCoordATI)
 #define glPassThrough          MANGLE(PassThrough)
 #define glProgramParameter4fvNV                MANGLE(ProgramParameter4fvNV)
 #define glProgramParameteriARB         MANGLE(ProgramParameteriARB)
 #define glProgramParameteriEXT         MANGLE(ProgramParameteriEXT)
+#define glProgramParameteri            MANGLE(ProgramParameteri)
 #define glProgramParameters4dvNV               MANGLE(ProgramParameters4dvNV)
 #define glProgramParameters4fvNV               MANGLE(ProgramParameters4fvNV)
 #define glProgramStringARB             MANGLE(ProgramStringARB)
 #define glProgramUniformMatrix4fvEXT           MANGLE(ProgramUniformMatrix4fvEXT)
 #define glProgramUniformMatrix4x2fvEXT         MANGLE(ProgramUniformMatrix4x2fvEXT)
 #define glProgramUniformMatrix4x3fvEXT         MANGLE(ProgramUniformMatrix4x3fvEXT)
+#define glProgramUniformui64NV         MANGLE(ProgramUniformui64NV)
+#define glProgramUniformui64vNV                MANGLE(ProgramUniformui64vNV)
 #define glProgramVertexLimitNV         MANGLE(ProgramVertexLimitNV)
 #define glProvokingVertexEXT           MANGLE(ProvokingVertexEXT)
+#define glProvokingVertex              MANGLE(ProvokingVertex)
 #define glPushAttrib           MANGLE(PushAttrib)
 #define glPushClientAttribDefaultEXT           MANGLE(PushClientAttribDefaultEXT)
 #define glPushClientAttrib             MANGLE(PushClientAttrib)
 #define glSampleCoverage               MANGLE(SampleCoverage)
 #define glSampleMapATI         MANGLE(SampleMapATI)
 #define glSampleMaskEXT                MANGLE(SampleMaskEXT)
+#define glSampleMaski          MANGLE(SampleMaski)
 #define glSampleMaskIndexedNV          MANGLE(SampleMaskIndexedNV)
 #define glSampleMaskSGIS               MANGLE(SampleMaskSGIS)
 #define glSamplePatternEXT             MANGLE(SamplePatternEXT)
 #define glSecondaryColor3us            MANGLE(SecondaryColor3us)
 #define glSecondaryColor3usvEXT                MANGLE(SecondaryColor3usvEXT)
 #define glSecondaryColor3usv           MANGLE(SecondaryColor3usv)
+#define glSecondaryColorFormatNV               MANGLE(SecondaryColorFormatNV)
 #define glSecondaryColorPointerEXT             MANGLE(SecondaryColorPointerEXT)
 #define glSecondaryColorPointerListIBM         MANGLE(SecondaryColorPointerListIBM)
 #define glSecondaryColorPointer                MANGLE(SecondaryColorPointer)
 #define glTexCoord4iv          MANGLE(TexCoord4iv)
 #define glTexCoord4s           MANGLE(TexCoord4s)
 #define glTexCoord4sv          MANGLE(TexCoord4sv)
+#define glTexCoordFormatNV             MANGLE(TexCoordFormatNV)
 #define glTexCoordPointerEXT           MANGLE(TexCoordPointerEXT)
 #define glTexCoordPointerListIBM               MANGLE(TexCoordPointerListIBM)
 #define glTexCoordPointer              MANGLE(TexCoordPointer)
 #define glTexGeniv             MANGLE(TexGeniv)
 #define glTexImage1D           MANGLE(TexImage1D)
 #define glTexImage2D           MANGLE(TexImage2D)
+#define glTexImage2DMultisample                MANGLE(TexImage2DMultisample)
 #define glTexImage3DEXT                MANGLE(TexImage3DEXT)
 #define glTexImage3D           MANGLE(TexImage3D)
+#define glTexImage3DMultisample                MANGLE(TexImage3DMultisample)
 #define glTexImage4DSGIS               MANGLE(TexImage4DSGIS)
 #define glTexParameterf                MANGLE(TexParameterf)
 #define glTexParameterfv               MANGLE(TexParameterfv)
 #define glTexSubImage3DEXT             MANGLE(TexSubImage3DEXT)
 #define glTexSubImage3D                MANGLE(TexSubImage3D)
 #define glTexSubImage4DSGIS            MANGLE(TexSubImage4DSGIS)
+#define glTextureBarrierNV             MANGLE(TextureBarrierNV)
 #define glTextureBufferEXT             MANGLE(TextureBufferEXT)
 #define glTextureColorMaskSGIS         MANGLE(TextureColorMaskSGIS)
 #define glTextureImage1DEXT            MANGLE(TextureImage1DEXT)
 #define glTextureParameterIivEXT               MANGLE(TextureParameterIivEXT)
 #define glTextureParameterIuivEXT              MANGLE(TextureParameterIuivEXT)
 #define glTextureParameterivEXT                MANGLE(TextureParameterivEXT)
+#define glTextureRangeAPPLE            MANGLE(TextureRangeAPPLE)
 #define glTextureRenderbufferEXT               MANGLE(TextureRenderbufferEXT)
 #define glTextureSubImage1DEXT         MANGLE(TextureSubImage1DEXT)
 #define glTextureSubImage2DEXT         MANGLE(TextureSubImage2DEXT)
 #define glUniformMatrix4fv             MANGLE(UniformMatrix4fv)
 #define glUniformMatrix4x2fv           MANGLE(UniformMatrix4x2fv)
 #define glUniformMatrix4x3fv           MANGLE(UniformMatrix4x3fv)
+#define glUniformui64NV                MANGLE(Uniformui64NV)
+#define glUniformui64vNV               MANGLE(Uniformui64vNV)
 #define glUnlockArraysEXT              MANGLE(UnlockArraysEXT)
 #define glUnmapBufferARB               MANGLE(UnmapBufferARB)
 #define glUnmapBuffer          MANGLE(UnmapBuffer)
 #define glUpdateObjectBufferATI                MANGLE(UpdateObjectBufferATI)
 #define glUseProgram           MANGLE(UseProgram)
 #define glUseProgramObjectARB          MANGLE(UseProgramObjectARB)
+#define glUseShaderProgramEXT          MANGLE(UseShaderProgramEXT)
 #define glValidateProgramARB           MANGLE(ValidateProgramARB)
 #define glValidateProgram              MANGLE(ValidateProgram)
 #define glVariantArrayObjectATI                MANGLE(VariantArrayObjectATI)
 #define glVertexAttrib4usv             MANGLE(VertexAttrib4usv)
 #define glVertexAttribArrayObjectATI           MANGLE(VertexAttribArrayObjectATI)
 #define glVertexAttribDivisorARB               MANGLE(VertexAttribDivisorARB)
+#define glVertexAttribFormatNV         MANGLE(VertexAttribFormatNV)
 #define glVertexAttribI1iEXT           MANGLE(VertexAttribI1iEXT)
 #define glVertexAttribI1i              MANGLE(VertexAttribI1i)
 #define glVertexAttribI1ivEXT          MANGLE(VertexAttribI1ivEXT)
 #define glVertexAttribI4uiv            MANGLE(VertexAttribI4uiv)
 #define glVertexAttribI4usvEXT         MANGLE(VertexAttribI4usvEXT)
 #define glVertexAttribI4usv            MANGLE(VertexAttribI4usv)
+#define glVertexAttribIFormatNV                MANGLE(VertexAttribIFormatNV)
 #define glVertexAttribIPointerEXT              MANGLE(VertexAttribIPointerEXT)
 #define glVertexAttribIPointer         MANGLE(VertexAttribIPointer)
 #define glVertexAttribPointerARB               MANGLE(VertexAttribPointerARB)
 #define glVertexBlendARB               MANGLE(VertexBlendARB)
 #define glVertexBlendEnvfATI           MANGLE(VertexBlendEnvfATI)
 #define glVertexBlendEnviATI           MANGLE(VertexBlendEnviATI)
+#define glVertexFormatNV               MANGLE(VertexFormatNV)
 #define glVertexPointerEXT             MANGLE(VertexPointerEXT)
 #define glVertexPointerListIBM         MANGLE(VertexPointerListIBM)
 #define glVertexPointer                MANGLE(VertexPointer)
 #define glVertexWeighthNV              MANGLE(VertexWeighthNV)
 #define glVertexWeighthvNV             MANGLE(VertexWeighthvNV)
 #define glVertexWeightPointerEXT               MANGLE(VertexWeightPointerEXT)
+#define glVideoCaptureNV               MANGLE(VideoCaptureNV)
+#define glVideoCaptureStreamParameterdvNV              MANGLE(VideoCaptureStreamParameterdvNV)
+#define glVideoCaptureStreamParameterfvNV              MANGLE(VideoCaptureStreamParameterfvNV)
+#define glVideoCaptureStreamParameterivNV              MANGLE(VideoCaptureStreamParameterivNV)
 #define glViewport             MANGLE(Viewport)
+#define glWaitSync             MANGLE(WaitSync)
 #define glWeightbvARB          MANGLE(WeightbvARB)
 #define glWeightdvARB          MANGLE(WeightdvARB)
 #define glWeightfvARB          MANGLE(WeightfvARB)
index 7932a1ce1993b42b2ca1e055876c4f7a70867d3a..04b8f7ed21fef731d4a4373b1dbb517874d57903 100644 (file)
@@ -80,7 +80,7 @@
 #define __glew_h__
 #define __GLEW_H__
 
-#if defined(__gl_h_) || defined(__GL_H__)
+#if defined(__gl_h_) || defined(__GL_H__) || defined(__X_GL_H)
 #error gl.h included before glew.h
 #endif
 #if defined(__glext_h_) || defined(__GLEXT_H_)
@@ -92,6 +92,7 @@
 
 #define __gl_h_
 #define __GL_H__
+#define __X_GL_H
 #define __glext_h_
 #define __GLEXT_H_
 #define __gl_ATI_h_
 /* <windef.h> */
 #ifndef APIENTRY
 #define GLEW_APIENTRY_DEFINED
-#  if defined(__MINGW32__)
+#  if defined(__MINGW32__) || defined(__CYGWIN__)
 #    define APIENTRY __stdcall
 #  elif (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__BORLANDC__)
 #    define APIENTRY __stdcall
 #  endif
 #endif
 #ifndef GLAPI
-#  if defined(__MINGW32__)
+#  if defined(__MINGW32__) || defined(__CYGWIN__)
 #    define GLAPI extern
 #  endif
 #endif
 /* <winnt.h> */
 #ifndef CALLBACK
 #define GLEW_CALLBACK_DEFINED
-#  if defined(__MINGW32__)
+#  if defined(__MINGW32__) || defined(__CYGWIN__)
 #    define CALLBACK __attribute__ ((__stdcall__))
 #  elif (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS)
 #    define CALLBACK __stdcall
@@ -159,7 +160,7 @@ typedef _W64 int ptrdiff_t;
 #endif
 
 #ifndef GLAPI
-#  if defined(__MINGW32__)
+#  if defined(__MINGW32__) || defined(__CYGWIN__)
 #    define GLAPI extern
 #  else
 #    define GLAPI WINGDIAPI
@@ -246,12 +247,15 @@ typedef signed long long GLint64EXT;
 typedef unsigned long long GLuint64EXT;
 #  endif
 #else
-#  if defined(__MINGW32__)
+#  if defined(__MINGW32__) || defined(__CYGWIN__)
 #include <inttypes.h>
 #  endif
 typedef int64_t GLint64EXT;
 typedef uint64_t GLuint64EXT;
 #endif
+typedef GLint64EXT  GLint64;
+typedef GLuint64EXT GLuint64;
+typedef struct __GLsync *GLsync;
 
 #define GL_ACCUM 0x0100
 #define GL_LOAD 0x0101
@@ -2094,8 +2098,6 @@ typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei
 
 typedef void (GLAPIENTRY * PFNGLBEGINCONDITIONALRENDERPROC) (GLuint, GLenum);
 typedef void (GLAPIENTRY * PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum);
-typedef void (GLAPIENTRY * PFNGLBINDBUFFERBASEPROC) (GLenum, GLuint, GLuint);
-typedef void (GLAPIENTRY * PFNGLBINDBUFFERRANGEPROC) (GLenum, GLuint, GLuint, GLintptr, GLsizeiptr);
 typedef void (GLAPIENTRY * PFNGLBINDFRAGDATALOCATIONPROC) (GLuint, GLuint, const GLchar*);
 typedef void (GLAPIENTRY * PFNGLCLAMPCOLORPROC) (GLenum, GLenum);
 typedef void (GLAPIENTRY * PFNGLCLEARBUFFERFIPROC) (GLenum, GLint, GLfloat, GLint);
@@ -2109,7 +2111,6 @@ typedef void (GLAPIENTRY * PFNGLENDCONDITIONALRENDERPROC) (void);
 typedef void (GLAPIENTRY * PFNGLENDTRANSFORMFEEDBACKPROC) (void);
 typedef void (GLAPIENTRY * PFNGLGETBOOLEANI_VPROC) (GLenum, GLuint, GLboolean*);
 typedef GLint (GLAPIENTRY * PFNGLGETFRAGDATALOCATIONPROC) (GLuint, const GLchar*);
-typedef void (GLAPIENTRY * PFNGLGETINTEGERI_VPROC) (GLenum, GLuint, GLint*);
 typedef const GLubyte* (GLAPIENTRY * PFNGLGETSTRINGIPROC) (GLenum, GLuint);
 typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIIVPROC) (GLenum, GLenum, GLint*);
 typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIUIVPROC) (GLenum, GLenum, GLuint*);
@@ -2120,7 +2121,7 @@ typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint, GLenum, GLuint
 typedef GLboolean (GLAPIENTRY * PFNGLISENABLEDIPROC) (GLenum, GLuint);
 typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIIVPROC) (GLenum, GLenum, const GLint*);
 typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIUIVPROC) (GLenum, GLenum, const GLuint*);
-typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint, GLsizei, const GLint*, GLenum);
+typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint, GLsizei, const GLchar **, GLenum);
 typedef void (GLAPIENTRY * PFNGLUNIFORM1UIPROC) (GLint, GLuint);
 typedef void (GLAPIENTRY * PFNGLUNIFORM1UIVPROC) (GLint, GLsizei, const GLuint*);
 typedef void (GLAPIENTRY * PFNGLUNIFORM2UIPROC) (GLint, GLuint, GLuint);
@@ -2153,8 +2154,6 @@ typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint, GLint, GLenum
 
 #define glBeginConditionalRender GLEW_GET_FUN(__glewBeginConditionalRender)
 #define glBeginTransformFeedback GLEW_GET_FUN(__glewBeginTransformFeedback)
-#define glBindBufferBase GLEW_GET_FUN(__glewBindBufferBase)
-#define glBindBufferRange GLEW_GET_FUN(__glewBindBufferRange)
 #define glBindFragDataLocation GLEW_GET_FUN(__glewBindFragDataLocation)
 #define glClampColor GLEW_GET_FUN(__glewClampColor)
 #define glClearBufferfi GLEW_GET_FUN(__glewClearBufferfi)
@@ -2168,7 +2167,6 @@ typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint, GLint, GLenum
 #define glEndTransformFeedback GLEW_GET_FUN(__glewEndTransformFeedback)
 #define glGetBooleani_v GLEW_GET_FUN(__glewGetBooleani_v)
 #define glGetFragDataLocation GLEW_GET_FUN(__glewGetFragDataLocation)
-#define glGetIntegeri_v GLEW_GET_FUN(__glewGetIntegeri_v)
 #define glGetStringi GLEW_GET_FUN(__glewGetStringi)
 #define glGetTexParameterIiv GLEW_GET_FUN(__glewGetTexParameterIiv)
 #define glGetTexParameterIuiv GLEW_GET_FUN(__glewGetTexParameterIuiv)
@@ -2214,6 +2212,97 @@ typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint, GLint, GLenum
 
 #endif /* GL_VERSION_3_0 */
 
+/* ----------------------------- GL_VERSION_3_1 ---------------------------- */
+
+#ifndef GL_VERSION_3_1
+#define GL_VERSION_3_1 1
+
+#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_SAMPLER_2D_RECT 0x8B63
+#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64
+#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_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_RED_SNORM 0x8F90
+#define GL_RG_SNORM 0x8F91
+#define GL_RGB_SNORM 0x8F92
+#define GL_RGBA_SNORM 0x8F93
+#define GL_R8_SNORM 0x8F94
+#define GL_RG8_SNORM 0x8F95
+#define GL_RGB8_SNORM 0x8F96
+#define GL_RGBA8_SNORM 0x8F97
+#define GL_R16_SNORM 0x8F98
+#define GL_RG16_SNORM 0x8F99
+#define GL_RGB16_SNORM 0x8F9A
+#define GL_RGBA16_SNORM 0x8F9B
+#define GL_SIGNED_NORMALIZED 0x8F9C
+#define GL_PRIMITIVE_RESTART 0x8F9D
+#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E
+
+typedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum, GLint, GLsizei, GLsizei);
+typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum, GLsizei, GLenum, const GLvoid*, GLsizei);
+typedef void (GLAPIENTRY * PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint);
+typedef void (GLAPIENTRY * PFNGLTEXBUFFERPROC) (GLenum, GLenum, GLuint);
+
+#define glDrawArraysInstanced GLEW_GET_FUN(__glewDrawArraysInstanced)
+#define glDrawElementsInstanced GLEW_GET_FUN(__glewDrawElementsInstanced)
+#define glPrimitiveRestartIndex GLEW_GET_FUN(__glewPrimitiveRestartIndex)
+#define glTexBuffer GLEW_GET_FUN(__glewTexBuffer)
+
+#define GLEW_VERSION_3_1 GLEW_GET_VAR(__GLEW_VERSION_3_1)
+
+#endif /* GL_VERSION_3_1 */
+
+/* ----------------------------- GL_VERSION_3_2 ---------------------------- */
+
+#ifndef GL_VERSION_3_2
+#define GL_VERSION_3_2 1
+
+#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001
+#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002
+#define GL_LINES_ADJACENCY 0x000A
+#define GL_LINE_STRIP_ADJACENCY 0x000B
+#define GL_TRIANGLES_ADJACENCY 0x000C
+#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D
+#define GL_PROGRAM_POINT_SIZE 0x8642
+#define GL_GEOMETRY_VERTICES_OUT 0x8916
+#define GL_GEOMETRY_INPUT_TYPE 0x8917
+#define GL_GEOMETRY_OUTPUT_TYPE 0x8918
+#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29
+#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7
+#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8
+#define GL_GEOMETRY_SHADER 0x8DD9
+#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF
+#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0
+#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1
+#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122
+#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123
+#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124
+#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125
+#define GL_CONTEXT_PROFILE_MASK 0x9126
+
+typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum, GLenum, GLuint, GLint);
+typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum, GLenum, GLint64 *);
+typedef void (GLAPIENTRY * PFNGLGETINTEGER64I_VPROC) (GLenum, GLuint, GLint64 *);
+
+#define glFramebufferTexture GLEW_GET_FUN(__glewFramebufferTexture)
+#define glGetBufferParameteri64v GLEW_GET_FUN(__glewGetBufferParameteri64v)
+#define glGetInteger64i_v GLEW_GET_FUN(__glewGetInteger64i_v)
+
+#define GLEW_VERSION_3_2 GLEW_GET_VAR(__GLEW_VERSION_3_2)
+
+#endif /* GL_VERSION_3_2 */
+
 /* -------------------------- GL_3DFX_multisample -------------------------- */
 
 #ifndef GL_3DFX_multisample
@@ -2253,6 +2342,111 @@ typedef void (GLAPIENTRY * PFNGLTBUFFERMASK3DFXPROC) (GLuint mask);
 
 #endif /* GL_3DFX_texture_compression_FXT1 */
 
+/* ----------------------- GL_AMD_draw_buffers_blend ----------------------- */
+
+#ifndef GL_AMD_draw_buffers_blend
+#define GL_AMD_draw_buffers_blend 1
+
+typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode);
+typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha);
+typedef void (GLAPIENTRY * PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst);
+typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+
+#define glBlendEquationIndexedAMD GLEW_GET_FUN(__glewBlendEquationIndexedAMD)
+#define glBlendEquationSeparateIndexedAMD GLEW_GET_FUN(__glewBlendEquationSeparateIndexedAMD)
+#define glBlendFuncIndexedAMD GLEW_GET_FUN(__glewBlendFuncIndexedAMD)
+#define glBlendFuncSeparateIndexedAMD GLEW_GET_FUN(__glewBlendFuncSeparateIndexedAMD)
+
+#define GLEW_AMD_draw_buffers_blend GLEW_GET_VAR(__GLEW_AMD_draw_buffers_blend)
+
+#endif /* GL_AMD_draw_buffers_blend */
+
+/* ----------------------- GL_AMD_performance_monitor ---------------------- */
+
+#ifndef GL_AMD_performance_monitor
+#define GL_AMD_performance_monitor 1
+
+#define GL_UNSIGNED_INT 0x1405
+#define GL_FLOAT 0x1406
+#define GL_COUNTER_TYPE_AMD 0x8BC0
+#define GL_COUNTER_RANGE_AMD 0x8BC1
+#define GL_UNSIGNED_INT64_AMD 0x8BC2
+#define GL_PERCENTAGE_AMD 0x8BC3
+#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4
+#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5
+#define GL_PERFMON_RESULT_AMD 0x8BC6
+
+typedef void (GLAPIENTRY * PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor);
+typedef void (GLAPIENTRY * PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint* monitors);
+typedef void (GLAPIENTRY * PFNGLENDPERFMONITORAMDPROC) (GLuint monitor);
+typedef void (GLAPIENTRY * PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint* monitors);
+typedef void (GLAPIENTRY * PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint* data, GLint *bytesWritten);
+typedef void (GLAPIENTRY * PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, void* data);
+typedef void (GLAPIENTRY * PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei* length, char *counterString);
+typedef void (GLAPIENTRY * PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint* numCounters, GLint *maxActiveCounters, GLsizei countersSize, GLuint *counters);
+typedef void (GLAPIENTRY * PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei* length, char *groupString);
+typedef void (GLAPIENTRY * PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint* numGroups, GLsizei groupsSize, GLuint *groups);
+typedef void (GLAPIENTRY * PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint* counterList);
+
+#define glBeginPerfMonitorAMD GLEW_GET_FUN(__glewBeginPerfMonitorAMD)
+#define glDeletePerfMonitorsAMD GLEW_GET_FUN(__glewDeletePerfMonitorsAMD)
+#define glEndPerfMonitorAMD GLEW_GET_FUN(__glewEndPerfMonitorAMD)
+#define glGenPerfMonitorsAMD GLEW_GET_FUN(__glewGenPerfMonitorsAMD)
+#define glGetPerfMonitorCounterDataAMD GLEW_GET_FUN(__glewGetPerfMonitorCounterDataAMD)
+#define glGetPerfMonitorCounterInfoAMD GLEW_GET_FUN(__glewGetPerfMonitorCounterInfoAMD)
+#define glGetPerfMonitorCounterStringAMD GLEW_GET_FUN(__glewGetPerfMonitorCounterStringAMD)
+#define glGetPerfMonitorCountersAMD GLEW_GET_FUN(__glewGetPerfMonitorCountersAMD)
+#define glGetPerfMonitorGroupStringAMD GLEW_GET_FUN(__glewGetPerfMonitorGroupStringAMD)
+#define glGetPerfMonitorGroupsAMD GLEW_GET_FUN(__glewGetPerfMonitorGroupsAMD)
+#define glSelectPerfMonitorCountersAMD GLEW_GET_FUN(__glewSelectPerfMonitorCountersAMD)
+
+#define GLEW_AMD_performance_monitor GLEW_GET_VAR(__GLEW_AMD_performance_monitor)
+
+#endif /* GL_AMD_performance_monitor */
+
+/* ------------------------ GL_AMD_texture_texture4 ------------------------ */
+
+#ifndef GL_AMD_texture_texture4
+#define GL_AMD_texture_texture4 1
+
+#define GLEW_AMD_texture_texture4 GLEW_GET_VAR(__GLEW_AMD_texture_texture4)
+
+#endif /* GL_AMD_texture_texture4 */
+
+/* -------------------- GL_AMD_vertex_shader_tessellator ------------------- */
+
+#ifndef GL_AMD_vertex_shader_tessellator
+#define GL_AMD_vertex_shader_tessellator 1
+
+#define GL_SAMPLER_BUFFER_AMD 0x9001
+#define GL_INT_SAMPLER_BUFFER_AMD 0x9002
+#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003
+#define GL_TESSELLATION_MODE_AMD 0x9004
+#define GL_TESSELLATION_FACTOR_AMD 0x9005
+#define GL_DISCRETE_AMD 0x9006
+#define GL_CONTINUOUS_AMD 0x9007
+
+typedef void (GLAPIENTRY * PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor);
+typedef void (GLAPIENTRY * PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode);
+
+#define glTessellationFactorAMD GLEW_GET_FUN(__glewTessellationFactorAMD)
+#define glTessellationModeAMD GLEW_GET_FUN(__glewTessellationModeAMD)
+
+#define GLEW_AMD_vertex_shader_tessellator GLEW_GET_VAR(__GLEW_AMD_vertex_shader_tessellator)
+
+#endif /* GL_AMD_vertex_shader_tessellator */
+
+/* ----------------------- GL_APPLE_aux_depth_stencil ---------------------- */
+
+#ifndef GL_APPLE_aux_depth_stencil
+#define GL_APPLE_aux_depth_stencil 1
+
+#define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14
+
+#define GLEW_APPLE_aux_depth_stencil GLEW_GET_VAR(__GLEW_APPLE_aux_depth_stencil)
+
+#endif /* GL_APPLE_aux_depth_stencil */
+
 /* ------------------------ GL_APPLE_client_storage ------------------------ */
 
 #ifndef GL_APPLE_client_storage
@@ -2361,6 +2555,30 @@ typedef void (GLAPIENTRY * PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target,
 
 #endif /* GL_APPLE_flush_buffer_range */
 
+/* ----------------------- GL_APPLE_object_purgeable ----------------------- */
+
+#ifndef GL_APPLE_object_purgeable
+#define GL_APPLE_object_purgeable 1
+
+#define GL_BUFFER_OBJECT_APPLE 0x85B3
+#define GL_RELEASED_APPLE 0x8A19
+#define GL_VOLATILE_APPLE 0x8A1A
+#define GL_RETAINED_APPLE 0x8A1B
+#define GL_UNDEFINED_APPLE 0x8A1C
+#define GL_PURGEABLE_APPLE 0x8A1D
+
+typedef void (GLAPIENTRY * PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint* params);
+typedef GLenum (GLAPIENTRY * PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option);
+typedef GLenum (GLAPIENTRY * PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option);
+
+#define glGetObjectParameterivAPPLE GLEW_GET_FUN(__glewGetObjectParameterivAPPLE)
+#define glObjectPurgeableAPPLE GLEW_GET_FUN(__glewObjectPurgeableAPPLE)
+#define glObjectUnpurgeableAPPLE GLEW_GET_FUN(__glewObjectUnpurgeableAPPLE)
+
+#define GLEW_APPLE_object_purgeable GLEW_GET_VAR(__GLEW_APPLE_object_purgeable)
+
+#endif /* GL_APPLE_object_purgeable */
+
 /* ------------------------- GL_APPLE_pixel_buffer ------------------------- */
 
 #ifndef GL_APPLE_pixel_buffer
@@ -2372,6 +2590,31 @@ typedef void (GLAPIENTRY * PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target,
 
 #endif /* GL_APPLE_pixel_buffer */
 
+/* ---------------------------- GL_APPLE_rgb_422 --------------------------- */
+
+#ifndef GL_APPLE_rgb_422
+#define GL_APPLE_rgb_422 1
+
+#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA
+#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB
+#define GL_RGB_422_APPLE 0x8A1F
+
+#define GLEW_APPLE_rgb_422 GLEW_GET_VAR(__GLEW_APPLE_rgb_422)
+
+#endif /* GL_APPLE_rgb_422 */
+
+/* --------------------------- GL_APPLE_row_bytes -------------------------- */
+
+#ifndef GL_APPLE_row_bytes
+#define GL_APPLE_row_bytes 1
+
+#define GL_PACK_ROW_BYTES_APPLE 0x8A15
+#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16
+
+#define GLEW_APPLE_row_bytes GLEW_GET_VAR(__GLEW_APPLE_row_bytes)
+
+#endif /* GL_APPLE_row_bytes */
+
 /* ------------------------ GL_APPLE_specular_vector ----------------------- */
 
 #ifndef GL_APPLE_specular_vector
@@ -2462,6 +2705,42 @@ typedef void (GLAPIENTRY * PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void
 
 #endif /* GL_APPLE_vertex_array_range */
 
+/* ------------------- GL_APPLE_vertex_program_evaluators ------------------ */
+
+#ifndef GL_APPLE_vertex_program_evaluators
+#define GL_APPLE_vertex_program_evaluators 1
+
+#define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00
+#define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01
+#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02
+#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03
+#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04
+#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05
+#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06
+#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07
+#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08
+#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09
+
+typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname);
+typedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname);
+typedef GLboolean (GLAPIENTRY * PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname);
+typedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble* points);
+typedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat* points);
+typedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble* points);
+typedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat* points);
+
+#define glDisableVertexAttribAPPLE GLEW_GET_FUN(__glewDisableVertexAttribAPPLE)
+#define glEnableVertexAttribAPPLE GLEW_GET_FUN(__glewEnableVertexAttribAPPLE)
+#define glIsVertexAttribEnabledAPPLE GLEW_GET_FUN(__glewIsVertexAttribEnabledAPPLE)
+#define glMapVertexAttrib1dAPPLE GLEW_GET_FUN(__glewMapVertexAttrib1dAPPLE)
+#define glMapVertexAttrib1fAPPLE GLEW_GET_FUN(__glewMapVertexAttrib1fAPPLE)
+#define glMapVertexAttrib2dAPPLE GLEW_GET_FUN(__glewMapVertexAttrib2dAPPLE)
+#define glMapVertexAttrib2fAPPLE GLEW_GET_FUN(__glewMapVertexAttrib2fAPPLE)
+
+#define GLEW_APPLE_vertex_program_evaluators GLEW_GET_VAR(__GLEW_APPLE_vertex_program_evaluators)
+
+#endif /* GL_APPLE_vertex_program_evaluators */
+
 /* --------------------------- GL_APPLE_ycbcr_422 -------------------------- */
 
 #ifndef GL_APPLE_ycbcr_422
@@ -2494,6 +2773,31 @@ typedef void (GLAPIENTRY * PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp)
 
 #endif /* GL_ARB_color_buffer_float */
 
+/* -------------------------- GL_ARB_compatibility ------------------------- */
+
+#ifndef GL_ARB_compatibility
+#define GL_ARB_compatibility 1
+
+#define GLEW_ARB_compatibility GLEW_GET_VAR(__GLEW_ARB_compatibility)
+
+#endif /* GL_ARB_compatibility */
+
+/* --------------------------- GL_ARB_copy_buffer -------------------------- */
+
+#ifndef GL_ARB_copy_buffer
+#define GL_ARB_copy_buffer 1
+
+#define GL_COPY_READ_BUFFER 0x8F36
+#define GL_COPY_WRITE_BUFFER 0x8F37
+
+typedef void (GLAPIENTRY * PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readtarget, GLenum writetarget, GLintptr readoffset, GLintptr writeoffset, GLsizeiptr size);
+
+#define glCopyBufferSubData GLEW_GET_FUN(__glewCopyBufferSubData)
+
+#define GLEW_ARB_copy_buffer GLEW_GET_VAR(__GLEW_ARB_copy_buffer)
+
+#endif /* GL_ARB_copy_buffer */
+
 /* ----------------------- GL_ARB_depth_buffer_float ----------------------- */
 
 #ifndef GL_ARB_depth_buffer_float
@@ -2507,6 +2811,17 @@ typedef void (GLAPIENTRY * PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp)
 
 #endif /* GL_ARB_depth_buffer_float */
 
+/* --------------------------- GL_ARB_depth_clamp -------------------------- */
+
+#ifndef GL_ARB_depth_clamp
+#define GL_ARB_depth_clamp 1
+
+#define GL_DEPTH_CLAMP 0x864F
+
+#define GLEW_ARB_depth_clamp GLEW_GET_VAR(__GLEW_ARB_depth_clamp)
+
+#endif /* GL_ARB_depth_clamp */
+
 /* -------------------------- GL_ARB_depth_texture ------------------------- */
 
 #ifndef GL_ARB_depth_texture
@@ -2553,6 +2868,44 @@ typedef void (GLAPIENTRY * PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum* bu
 
 #endif /* GL_ARB_draw_buffers */
 
+/* ----------------------- GL_ARB_draw_buffers_blend ----------------------- */
+
+#ifndef GL_ARB_draw_buffers_blend
+#define GL_ARB_draw_buffers_blend 1
+
+typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha);
+typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode);
+typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+typedef void (GLAPIENTRY * PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst);
+
+#define glBlendEquationSeparateiARB GLEW_GET_FUN(__glewBlendEquationSeparateiARB)
+#define glBlendEquationiARB GLEW_GET_FUN(__glewBlendEquationiARB)
+#define glBlendFuncSeparateiARB GLEW_GET_FUN(__glewBlendFuncSeparateiARB)
+#define glBlendFunciARB GLEW_GET_FUN(__glewBlendFunciARB)
+
+#define GLEW_ARB_draw_buffers_blend GLEW_GET_VAR(__GLEW_ARB_draw_buffers_blend)
+
+#endif /* GL_ARB_draw_buffers_blend */
+
+/* -------------------- GL_ARB_draw_elements_base_vertex ------------------- */
+
+#ifndef GL_ARB_draw_elements_base_vertex
+#define GL_ARB_draw_elements_base_vertex 1
+
+typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, void* indices, GLint basevertex);
+typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei primcount, GLint basevertex);
+typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, void* indices, GLint basevertex);
+typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei* count, GLenum type, GLvoid**indices, GLsizei primcount, GLint *basevertex);
+
+#define glDrawElementsBaseVertex GLEW_GET_FUN(__glewDrawElementsBaseVertex)
+#define glDrawElementsInstancedBaseVertex GLEW_GET_FUN(__glewDrawElementsInstancedBaseVertex)
+#define glDrawRangeElementsBaseVertex GLEW_GET_FUN(__glewDrawRangeElementsBaseVertex)
+#define glMultiDrawElementsBaseVertex GLEW_GET_FUN(__glewMultiDrawElementsBaseVertex)
+
+#define GLEW_ARB_draw_elements_base_vertex GLEW_GET_VAR(__GLEW_ARB_draw_elements_base_vertex)
+
+#endif /* GL_ARB_draw_elements_base_vertex */
+
 /* ------------------------- GL_ARB_draw_instanced ------------------------- */
 
 #ifndef GL_ARB_draw_instanced
@@ -2568,6 +2921,15 @@ typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsi
 
 #endif /* GL_ARB_draw_instanced */
 
+/* ------------------- GL_ARB_fragment_coord_conventions ------------------- */
+
+#ifndef GL_ARB_fragment_coord_conventions
+#define GL_ARB_fragment_coord_conventions 1
+
+#define GLEW_ARB_fragment_coord_conventions GLEW_GET_VAR(__GLEW_ARB_fragment_coord_conventions)
+
+#endif /* GL_ARB_fragment_coord_conventions */
+
 /* ------------------------ GL_ARB_fragment_program ------------------------ */
 
 #ifndef GL_ARB_fragment_program
@@ -2702,10 +3064,10 @@ typedef GLenum (GLAPIENTRY * PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target);
 typedef void (GLAPIENTRY * PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint* framebuffers);
 typedef void (GLAPIENTRY * PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint* renderbuffers);
 typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
-typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target,GLenum attachment, GLuint texture,GLint level,GLint layer);
 typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
 typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
 typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint layer);
+typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target,GLenum attachment, GLuint texture,GLint level,GLint layer);
 typedef void (GLAPIENTRY * PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint* framebuffers);
 typedef void (GLAPIENTRY * PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint* renderbuffers);
 typedef void (GLAPIENTRY * PFNGLGENERATEMIPMAPPROC) (GLenum target);
@@ -2723,10 +3085,10 @@ typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum targ
 #define glDeleteFramebuffers GLEW_GET_FUN(__glewDeleteFramebuffers)
 #define glDeleteRenderbuffers GLEW_GET_FUN(__glewDeleteRenderbuffers)
 #define glFramebufferRenderbuffer GLEW_GET_FUN(__glewFramebufferRenderbuffer)
-#define glFramebufferTextureLayer GLEW_GET_FUN(__glewFramebufferTextureLayer)
 #define glFramebufferTexture1D GLEW_GET_FUN(__glewFramebufferTexture1D)
 #define glFramebufferTexture2D GLEW_GET_FUN(__glewFramebufferTexture2D)
 #define glFramebufferTexture3D GLEW_GET_FUN(__glewFramebufferTexture3D)
+#define glFramebufferTextureLayer GLEW_GET_FUN(__glewFramebufferTextureLayer)
 #define glGenFramebuffers GLEW_GET_FUN(__glewGenFramebuffers)
 #define glGenRenderbuffers GLEW_GET_FUN(__glewGenRenderbuffers)
 #define glGenerateMipmap GLEW_GET_FUN(__glewGenerateMipmap)
@@ -3252,6 +3614,51 @@ typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, GLfloat*
 
 #endif /* GL_ARB_point_sprite */
 
+/* ------------------------ GL_ARB_provoking_vertex ------------------------ */
+
+#ifndef GL_ARB_provoking_vertex
+#define GL_ARB_provoking_vertex 1
+
+#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C
+#define GL_FIRST_VERTEX_CONVENTION 0x8E4D
+#define GL_LAST_VERTEX_CONVENTION 0x8E4E
+#define GL_PROVOKING_VERTEX 0x8E4F
+
+typedef void (GLAPIENTRY * PFNGLPROVOKINGVERTEXPROC) (GLenum mode);
+
+#define glProvokingVertex GLEW_GET_FUN(__glewProvokingVertex)
+
+#define GLEW_ARB_provoking_vertex GLEW_GET_VAR(__GLEW_ARB_provoking_vertex)
+
+#endif /* GL_ARB_provoking_vertex */
+
+/* ------------------------- GL_ARB_sample_shading ------------------------- */
+
+#ifndef GL_ARB_sample_shading
+#define GL_ARB_sample_shading 1
+
+#define GL_SAMPLE_SHADING_ARB 0x8C36
+#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37
+
+typedef void (GLAPIENTRY * PFNGLMINSAMPLESHADINGARBPROC) (GLclampf value);
+
+#define glMinSampleShadingARB GLEW_GET_FUN(__glewMinSampleShadingARB)
+
+#define GLEW_ARB_sample_shading GLEW_GET_VAR(__GLEW_ARB_sample_shading)
+
+#endif /* GL_ARB_sample_shading */
+
+/* ------------------------ GL_ARB_seamless_cube_map ----------------------- */
+
+#ifndef GL_ARB_seamless_cube_map
+#define GL_ARB_seamless_cube_map 1
+
+#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F
+
+#define GLEW_ARB_seamless_cube_map GLEW_GET_VAR(__GLEW_ARB_seamless_cube_map)
+
+#endif /* GL_ARB_seamless_cube_map */
+
 /* ------------------------- GL_ARB_shader_objects ------------------------- */
 
 #ifndef GL_ARB_shader_objects
@@ -3379,6 +3786,15 @@ typedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj)
 
 #endif /* GL_ARB_shader_objects */
 
+/* ----------------------- GL_ARB_shader_texture_lod ----------------------- */
+
+#ifndef GL_ARB_shader_texture_lod
+#define GL_ARB_shader_texture_lod 1
+
+#define GLEW_ARB_shader_texture_lod GLEW_GET_VAR(__GLEW_ARB_shader_texture_lod)
+
+#endif /* GL_ARB_shader_texture_lod */
+
 /* ---------------------- GL_ARB_shading_language_100 ---------------------- */
 
 #ifndef GL_ARB_shading_language_100
@@ -3414,6 +3830,47 @@ typedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj)
 
 #endif /* GL_ARB_shadow_ambient */
 
+/* ------------------------------ GL_ARB_sync ------------------------------ */
+
+#ifndef GL_ARB_sync
+#define GL_ARB_sync 1
+
+#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001
+#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111
+#define GL_OBJECT_TYPE 0x9112
+#define GL_SYNC_CONDITION 0x9113
+#define GL_SYNC_STATUS 0x9114
+#define GL_SYNC_FLAGS 0x9115
+#define GL_SYNC_FENCE 0x9116
+#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117
+#define GL_UNSIGNALED 0x9118
+#define GL_SIGNALED 0x9119
+#define GL_ALREADY_SIGNALED 0x911A
+#define GL_TIMEOUT_EXPIRED 0x911B
+#define GL_CONDITION_SATISFIED 0x911C
+#define GL_WAIT_FAILED 0x911D
+#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFF
+
+typedef GLenum (GLAPIENTRY * PFNGLCLIENTWAITSYNCPROC) (GLsync GLsync,GLbitfield flags,GLuint64 timeout);
+typedef void (GLAPIENTRY * PFNGLDELETESYNCPROC) (GLsync GLsync);
+typedef GLsync (GLAPIENTRY * PFNGLFENCESYNCPROC) (GLenum condition,GLbitfield flags);
+typedef void (GLAPIENTRY * PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64* params);
+typedef void (GLAPIENTRY * PFNGLGETSYNCIVPROC) (GLsync GLsync,GLenum pname,GLsizei bufSize,GLsizei* length, GLint *values);
+typedef GLboolean (GLAPIENTRY * PFNGLISSYNCPROC) (GLsync GLsync);
+typedef void (GLAPIENTRY * PFNGLWAITSYNCPROC) (GLsync GLsync,GLbitfield flags,GLuint64 timeout);
+
+#define glClientWaitSync GLEW_GET_FUN(__glewClientWaitSync)
+#define glDeleteSync GLEW_GET_FUN(__glewDeleteSync)
+#define glFenceSync GLEW_GET_FUN(__glewFenceSync)
+#define glGetInteger64v GLEW_GET_FUN(__glewGetInteger64v)
+#define glGetSynciv GLEW_GET_FUN(__glewGetSynciv)
+#define glIsSync GLEW_GET_FUN(__glewIsSync)
+#define glWaitSync GLEW_GET_FUN(__glewWaitSync)
+
+#define GLEW_ARB_sync GLEW_GET_VAR(__GLEW_ARB_sync)
+
+#endif /* GL_ARB_sync */
+
 /* ---------------------- GL_ARB_texture_border_clamp ---------------------- */
 
 #ifndef GL_ARB_texture_border_clamp
@@ -3517,6 +3974,23 @@ typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GL
 
 #endif /* GL_ARB_texture_cube_map */
 
+/* --------------------- GL_ARB_texture_cube_map_array --------------------- */
+
+#ifndef GL_ARB_texture_cube_map_array
+#define GL_ARB_texture_cube_map_array 1
+
+#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009
+#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A
+#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B
+#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C
+#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D
+#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E
+#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F
+
+#define GLEW_ARB_texture_cube_map_array GLEW_GET_VAR(__GLEW_ARB_texture_cube_map_array)
+
+#endif /* GL_ARB_texture_cube_map_array */
+
 /* ------------------------- GL_ARB_texture_env_add ------------------------ */
 
 #ifndef GL_ARB_texture_env_add
@@ -3609,6 +4083,19 @@ typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GL
 
 #endif /* GL_ARB_texture_float */
 
+/* ------------------------- GL_ARB_texture_gather ------------------------- */
+
+#ifndef GL_ARB_texture_gather
+#define GL_ARB_texture_gather 1
+
+#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E
+#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F
+#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB 0x8F9F
+
+#define GLEW_ARB_texture_gather GLEW_GET_VAR(__GLEW_ARB_texture_gather)
+
+#endif /* GL_ARB_texture_gather */
+
 /* --------------------- GL_ARB_texture_mirrored_repeat -------------------- */
 
 #ifndef GL_ARB_texture_mirrored_repeat
@@ -3620,6 +4107,47 @@ typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GL
 
 #endif /* GL_ARB_texture_mirrored_repeat */
 
+/* ----------------------- GL_ARB_texture_multisample ---------------------- */
+
+#ifndef GL_ARB_texture_multisample
+#define GL_ARB_texture_multisample 1
+
+#define GL_SAMPLE_POSITION 0x8E50
+#define GL_SAMPLE_MASK 0x8E51
+#define GL_SAMPLE_MASK_VALUE 0x8E52
+#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59
+#define GL_TEXTURE_2D_MULTISAMPLE 0x9100
+#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101
+#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102
+#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103
+#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104
+#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105
+#define GL_TEXTURE_SAMPLES 0x9106
+#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107
+#define GL_SAMPLER_2D_MULTISAMPLE 0x9108
+#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109
+#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A
+#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B
+#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C
+#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D
+#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E
+#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F
+#define GL_MAX_INTEGER_SAMPLES 0x9110
+
+typedef void (GLAPIENTRY * PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat* val);
+typedef void (GLAPIENTRY * PFNGLSAMPLEMASKIPROC) (GLuint index, GLbitfield mask);
+typedef void (GLAPIENTRY * PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
+typedef void (GLAPIENTRY * PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
+
+#define glGetMultisamplefv GLEW_GET_FUN(__glewGetMultisamplefv)
+#define glSampleMaski GLEW_GET_FUN(__glewSampleMaski)
+#define glTexImage2DMultisample GLEW_GET_FUN(__glewTexImage2DMultisample)
+#define glTexImage3DMultisample GLEW_GET_FUN(__glewTexImage3DMultisample)
+
+#define GLEW_ARB_texture_multisample GLEW_GET_VAR(__GLEW_ARB_texture_multisample)
+
+#endif /* GL_ARB_texture_multisample */
+
 /* -------------------- GL_ARB_texture_non_power_of_two -------------------- */
 
 #ifndef GL_ARB_texture_non_power_of_two
@@ -3629,6 +4157,15 @@ typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GL
 
 #endif /* GL_ARB_texture_non_power_of_two */
 
+/* ------------------------ GL_ARB_texture_query_lod ----------------------- */
+
+#ifndef GL_ARB_texture_query_lod
+#define GL_ARB_texture_query_lod 1
+
+#define GLEW_ARB_texture_query_lod GLEW_GET_VAR(__GLEW_ARB_texture_query_lod)
+
+#endif /* GL_ARB_texture_query_lod */
+
 /* ------------------------ GL_ARB_texture_rectangle ----------------------- */
 
 #ifndef GL_ARB_texture_rectangle
@@ -3651,6 +4188,8 @@ typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GL
 #define GL_ARB_texture_rg 1
 
 #define GL_RED 0x1903
+#define GL_COMPRESSED_RED 0x8225
+#define GL_COMPRESSED_RG 0x8226
 #define GL_RG 0x8227
 #define GL_RG_INTEGER 0x8228
 #define GL_R8 0x8229
@@ -3702,6 +4241,82 @@ typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXFARBPROC) (GLfloat m[16]);
 
 #endif /* GL_ARB_transpose_matrix */
 
+/* ---------------------- GL_ARB_uniform_buffer_object --------------------- */
+
+#ifndef GL_ARB_uniform_buffer_object
+#define GL_ARB_uniform_buffer_object 1
+
+#define GL_UNIFORM_BUFFER 0x8A11
+#define GL_UNIFORM_BUFFER_BINDING 0x8A28
+#define GL_UNIFORM_BUFFER_START 0x8A29
+#define GL_UNIFORM_BUFFER_SIZE 0x8A2A
+#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B
+#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C
+#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D
+#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E
+#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F
+#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30
+#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31
+#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32
+#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33
+#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34
+#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35
+#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36
+#define GL_UNIFORM_TYPE 0x8A37
+#define GL_UNIFORM_SIZE 0x8A38
+#define GL_UNIFORM_NAME_LENGTH 0x8A39
+#define GL_UNIFORM_BLOCK_INDEX 0x8A3A
+#define GL_UNIFORM_OFFSET 0x8A3B
+#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C
+#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D
+#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E
+#define GL_UNIFORM_BLOCK_BINDING 0x8A3F
+#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40
+#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41
+#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42
+#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43
+#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 0xFFFFFFFF
+
+typedef void (GLAPIENTRY * PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer);
+typedef void (GLAPIENTRY * PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
+typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, char* uniformBlockName);
+typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params);
+typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei* length, char* uniformName);
+typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params);
+typedef void (GLAPIENTRY * PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint* data);
+typedef GLuint (GLAPIENTRY * PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const char* uniformBlockName);
+typedef void (GLAPIENTRY * PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const char** uniformNames, GLuint* uniformIndices);
+typedef void (GLAPIENTRY * PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
+
+#define glBindBufferBase GLEW_GET_FUN(__glewBindBufferBase)
+#define glBindBufferRange GLEW_GET_FUN(__glewBindBufferRange)
+#define glGetActiveUniformBlockName GLEW_GET_FUN(__glewGetActiveUniformBlockName)
+#define glGetActiveUniformBlockiv GLEW_GET_FUN(__glewGetActiveUniformBlockiv)
+#define glGetActiveUniformName GLEW_GET_FUN(__glewGetActiveUniformName)
+#define glGetActiveUniformsiv GLEW_GET_FUN(__glewGetActiveUniformsiv)
+#define glGetIntegeri_v GLEW_GET_FUN(__glewGetIntegeri_v)
+#define glGetUniformBlockIndex GLEW_GET_FUN(__glewGetUniformBlockIndex)
+#define glGetUniformIndices GLEW_GET_FUN(__glewGetUniformIndices)
+#define glUniformBlockBinding GLEW_GET_FUN(__glewUniformBlockBinding)
+
+#define GLEW_ARB_uniform_buffer_object GLEW_GET_VAR(__GLEW_ARB_uniform_buffer_object)
+
+#endif /* GL_ARB_uniform_buffer_object */
+
+/* ------------------------ GL_ARB_vertex_array_bgra ----------------------- */
+
+#ifndef GL_ARB_vertex_array_bgra
+#define GL_ARB_vertex_array_bgra 1
+
+#define GL_BGRA 0x80E1
+
+#define GLEW_ARB_vertex_array_bgra GLEW_GET_VAR(__GLEW_ARB_vertex_array_bgra)
+
+#endif /* GL_ARB_vertex_array_bgra */
+
 /* ----------------------- GL_ARB_vertex_array_object ---------------------- */
 
 #ifndef GL_ARB_vertex_array_object
@@ -4390,6 +5005,19 @@ typedef void (GLAPIENTRY * PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer);
 
 #endif /* GL_ATI_map_object_buffer */
 
+/* ----------------------------- GL_ATI_meminfo ---------------------------- */
+
+#ifndef GL_ATI_meminfo
+#define GL_ATI_meminfo 1
+
+#define GL_VBO_FREE_MEMORY_ATI 0x87FB
+#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC
+#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD
+
+#define GLEW_ATI_meminfo GLEW_GET_VAR(__GLEW_ATI_meminfo)
+
+#endif /* GL_ATI_meminfo */
+
 /* -------------------------- GL_ATI_pn_triangles -------------------------- */
 
 #ifndef GL_ATI_pn_triangles
@@ -5068,7 +5696,14 @@ typedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, G
 typedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
 typedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
 typedef void (GLAPIENTRY * PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index);
+typedef void (GLAPIENTRY * PFNGLDISABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index);
+typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index);
+typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array);
 typedef void (GLAPIENTRY * PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index);
+typedef void (GLAPIENTRY * PFNGLENABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index);
+typedef void (GLAPIENTRY * PFNGLENABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index);
+typedef void (GLAPIENTRY * PFNGLENABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array);
+typedef void (GLAPIENTRY * PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length);
 typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode);
 typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum* bufs);
 typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode);
@@ -5076,8 +5711,10 @@ typedef void (GLAPIENTRY * PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit,
 typedef void (GLAPIENTRY * PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target);
 typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, void* img);
 typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, void* img);
-typedef void (GLAPIENTRY * PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum pname, GLuint index, GLdouble* params);
-typedef void (GLAPIENTRY * PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum pname, GLuint index, GLfloat* params);
+typedef void (GLAPIENTRY * PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble* params);
+typedef void (GLAPIENTRY * PFNGLGETDOUBLEI_VEXTPROC) (GLenum pname, GLuint index, GLdouble* params);
+typedef void (GLAPIENTRY * PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat* params);
+typedef void (GLAPIENTRY * PFNGLGETFLOATI_VEXTPROC) (GLenum pname, GLuint index, GLfloat* params);
 typedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint* param);
 typedef void (GLAPIENTRY * PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat* params);
 typedef void (GLAPIENTRY * PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint* params);
@@ -5102,7 +5739,8 @@ typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint
 typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, void* string);
 typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint* params);
 typedef void (GLAPIENTRY * PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint* params);
-typedef void (GLAPIENTRY * PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum pname, GLuint index, GLvoid** params);
+typedef void (GLAPIENTRY * PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLvoid** params);
+typedef void (GLAPIENTRY * PFNGLGETPOINTERI_VEXTPROC) (GLenum pname, GLuint index, GLvoid** params);
 typedef void (GLAPIENTRY * PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void* pixels);
 typedef void (GLAPIENTRY * PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat* params);
 typedef void (GLAPIENTRY * PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint* params);
@@ -5110,7 +5748,12 @@ typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture,
 typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint* params);
 typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat* params);
 typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint* params);
+typedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint* param);
+typedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYINTEGERVEXTPROC) (GLuint vaobj, GLenum pname, GLint* param);
+typedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLvoid** param);
+typedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYPOINTERVEXTPROC) (GLuint vaobj, GLenum pname, GLvoid** param);
 typedef GLvoid * (GLAPIENTRY * PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access);
+typedef GLvoid * (GLAPIENTRY * PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access);
 typedef void (GLAPIENTRY * PFNGLMATRIXFRUSTUMEXTPROC) (GLenum matrixMode, GLdouble l, GLdouble r, GLdouble b, GLdouble t, GLdouble n, GLdouble f);
 typedef void (GLAPIENTRY * PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum matrixMode);
 typedef void (GLAPIENTRY * PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum matrixMode, const GLdouble* m);
@@ -5157,6 +5800,7 @@ typedef void (GLAPIENTRY * PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLen
 typedef void (GLAPIENTRY * PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* pixels);
 typedef void (GLAPIENTRY * PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const void* data, GLenum usage);
 typedef void (GLAPIENTRY * PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void* data);
+typedef void (GLAPIENTRY * PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
 typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
 typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
 typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
@@ -5228,6 +5872,17 @@ typedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenu
 typedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels);
 typedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* pixels);
 typedef GLboolean (GLAPIENTRY * PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer);
+typedef void (GLAPIENTRY * PFNGLVERTEXARRAYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset);
+typedef void (GLAPIENTRY * PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset);
+typedef void (GLAPIENTRY * PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset);
+typedef void (GLAPIENTRY * PFNGLVERTEXARRAYINDEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset);
+typedef void (GLAPIENTRY * PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset);
+typedef void (GLAPIENTRY * PFNGLVERTEXARRAYNORMALOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset);
+typedef void (GLAPIENTRY * PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset);
+typedef void (GLAPIENTRY * PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset);
+typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset);
+typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset);
+typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset);
 
 #define glBindMultiTextureEXT GLEW_GET_FUN(__glewBindMultiTextureEXT)
 #define glCheckNamedFramebufferStatusEXT GLEW_GET_FUN(__glewCheckNamedFramebufferStatusEXT)
@@ -5255,7 +5910,14 @@ typedef GLboolean (GLAPIENTRY * PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer);
 #define glCopyTextureSubImage2DEXT GLEW_GET_FUN(__glewCopyTextureSubImage2DEXT)
 #define glCopyTextureSubImage3DEXT GLEW_GET_FUN(__glewCopyTextureSubImage3DEXT)
 #define glDisableClientStateIndexedEXT GLEW_GET_FUN(__glewDisableClientStateIndexedEXT)
+#define glDisableClientStateiEXT GLEW_GET_FUN(__glewDisableClientStateiEXT)
+#define glDisableVertexArrayAttribEXT GLEW_GET_FUN(__glewDisableVertexArrayAttribEXT)
+#define glDisableVertexArrayEXT GLEW_GET_FUN(__glewDisableVertexArrayEXT)
 #define glEnableClientStateIndexedEXT GLEW_GET_FUN(__glewEnableClientStateIndexedEXT)
+#define glEnableClientStateiEXT GLEW_GET_FUN(__glewEnableClientStateiEXT)
+#define glEnableVertexArrayAttribEXT GLEW_GET_FUN(__glewEnableVertexArrayAttribEXT)
+#define glEnableVertexArrayEXT GLEW_GET_FUN(__glewEnableVertexArrayEXT)
+#define glFlushMappedNamedBufferRangeEXT GLEW_GET_FUN(__glewFlushMappedNamedBufferRangeEXT)
 #define glFramebufferDrawBufferEXT GLEW_GET_FUN(__glewFramebufferDrawBufferEXT)
 #define glFramebufferDrawBuffersEXT GLEW_GET_FUN(__glewFramebufferDrawBuffersEXT)
 #define glFramebufferReadBufferEXT GLEW_GET_FUN(__glewFramebufferReadBufferEXT)
@@ -5264,7 +5926,9 @@ typedef GLboolean (GLAPIENTRY * PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer);
 #define glGetCompressedMultiTexImageEXT GLEW_GET_FUN(__glewGetCompressedMultiTexImageEXT)
 #define glGetCompressedTextureImageEXT GLEW_GET_FUN(__glewGetCompressedTextureImageEXT)
 #define glGetDoubleIndexedvEXT GLEW_GET_FUN(__glewGetDoubleIndexedvEXT)
+#define glGetDoublei_vEXT GLEW_GET_FUN(__glewGetDoublei_vEXT)
 #define glGetFloatIndexedvEXT GLEW_GET_FUN(__glewGetFloatIndexedvEXT)
+#define glGetFloati_vEXT GLEW_GET_FUN(__glewGetFloati_vEXT)
 #define glGetFramebufferParameterivEXT GLEW_GET_FUN(__glewGetFramebufferParameterivEXT)
 #define glGetMultiTexEnvfvEXT GLEW_GET_FUN(__glewGetMultiTexEnvfvEXT)
 #define glGetMultiTexEnvivEXT GLEW_GET_FUN(__glewGetMultiTexEnvivEXT)
@@ -5290,6 +5954,7 @@ typedef GLboolean (GLAPIENTRY * PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer);
 #define glGetNamedProgramivEXT GLEW_GET_FUN(__glewGetNamedProgramivEXT)
 #define glGetNamedRenderbufferParameterivEXT GLEW_GET_FUN(__glewGetNamedRenderbufferParameterivEXT)
 #define glGetPointerIndexedvEXT GLEW_GET_FUN(__glewGetPointerIndexedvEXT)
+#define glGetPointeri_vEXT GLEW_GET_FUN(__glewGetPointeri_vEXT)
 #define glGetTextureImageEXT GLEW_GET_FUN(__glewGetTextureImageEXT)
 #define glGetTextureLevelParameterfvEXT GLEW_GET_FUN(__glewGetTextureLevelParameterfvEXT)
 #define glGetTextureLevelParameterivEXT GLEW_GET_FUN(__glewGetTextureLevelParameterivEXT)
@@ -5297,7 +5962,12 @@ typedef GLboolean (GLAPIENTRY * PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer);
 #define glGetTextureParameterIuivEXT GLEW_GET_FUN(__glewGetTextureParameterIuivEXT)
 #define glGetTextureParameterfvEXT GLEW_GET_FUN(__glewGetTextureParameterfvEXT)
 #define glGetTextureParameterivEXT GLEW_GET_FUN(__glewGetTextureParameterivEXT)
+#define glGetVertexArrayIntegeri_vEXT GLEW_GET_FUN(__glewGetVertexArrayIntegeri_vEXT)
+#define glGetVertexArrayIntegervEXT GLEW_GET_FUN(__glewGetVertexArrayIntegervEXT)
+#define glGetVertexArrayPointeri_vEXT GLEW_GET_FUN(__glewGetVertexArrayPointeri_vEXT)
+#define glGetVertexArrayPointervEXT GLEW_GET_FUN(__glewGetVertexArrayPointervEXT)
 #define glMapNamedBufferEXT GLEW_GET_FUN(__glewMapNamedBufferEXT)
+#define glMapNamedBufferRangeEXT GLEW_GET_FUN(__glewMapNamedBufferRangeEXT)
 #define glMatrixFrustumEXT GLEW_GET_FUN(__glewMatrixFrustumEXT)
 #define glMatrixLoadIdentityEXT GLEW_GET_FUN(__glewMatrixLoadIdentityEXT)
 #define glMatrixLoadTransposedEXT GLEW_GET_FUN(__glewMatrixLoadTransposedEXT)
@@ -5344,6 +6014,7 @@ typedef GLboolean (GLAPIENTRY * PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer);
 #define glMultiTexSubImage3DEXT GLEW_GET_FUN(__glewMultiTexSubImage3DEXT)
 #define glNamedBufferDataEXT GLEW_GET_FUN(__glewNamedBufferDataEXT)
 #define glNamedBufferSubDataEXT GLEW_GET_FUN(__glewNamedBufferSubDataEXT)
+#define glNamedCopyBufferSubDataEXT GLEW_GET_FUN(__glewNamedCopyBufferSubDataEXT)
 #define glNamedFramebufferRenderbufferEXT GLEW_GET_FUN(__glewNamedFramebufferRenderbufferEXT)
 #define glNamedFramebufferTexture1DEXT GLEW_GET_FUN(__glewNamedFramebufferTexture1DEXT)
 #define glNamedFramebufferTexture2DEXT GLEW_GET_FUN(__glewNamedFramebufferTexture2DEXT)
@@ -5415,6 +6086,17 @@ typedef GLboolean (GLAPIENTRY * PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer);
 #define glTextureSubImage2DEXT GLEW_GET_FUN(__glewTextureSubImage2DEXT)
 #define glTextureSubImage3DEXT GLEW_GET_FUN(__glewTextureSubImage3DEXT)
 #define glUnmapNamedBufferEXT GLEW_GET_FUN(__glewUnmapNamedBufferEXT)
+#define glVertexArrayColorOffsetEXT GLEW_GET_FUN(__glewVertexArrayColorOffsetEXT)
+#define glVertexArrayEdgeFlagOffsetEXT GLEW_GET_FUN(__glewVertexArrayEdgeFlagOffsetEXT)
+#define glVertexArrayFogCoordOffsetEXT GLEW_GET_FUN(__glewVertexArrayFogCoordOffsetEXT)
+#define glVertexArrayIndexOffsetEXT GLEW_GET_FUN(__glewVertexArrayIndexOffsetEXT)
+#define glVertexArrayMultiTexCoordOffsetEXT GLEW_GET_FUN(__glewVertexArrayMultiTexCoordOffsetEXT)
+#define glVertexArrayNormalOffsetEXT GLEW_GET_FUN(__glewVertexArrayNormalOffsetEXT)
+#define glVertexArraySecondaryColorOffsetEXT GLEW_GET_FUN(__glewVertexArraySecondaryColorOffsetEXT)
+#define glVertexArrayTexCoordOffsetEXT GLEW_GET_FUN(__glewVertexArrayTexCoordOffsetEXT)
+#define glVertexArrayVertexAttribIOffsetEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribIOffsetEXT)
+#define glVertexArrayVertexAttribOffsetEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribOffsetEXT)
+#define glVertexArrayVertexOffsetEXT GLEW_GET_FUN(__glewVertexArrayVertexOffsetEXT)
 
 #define GLEW_EXT_direct_state_access GLEW_GET_VAR(__GLEW_EXT_direct_state_access)
 
@@ -6223,6 +6905,24 @@ typedef void (GLAPIENTRY * PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat b
 
 #endif /* GL_EXT_polygon_offset */
 
+/* ------------------------ GL_EXT_provoking_vertex ------------------------ */
+
+#ifndef GL_EXT_provoking_vertex
+#define GL_EXT_provoking_vertex 1
+
+#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C
+#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D
+#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E
+#define GL_PROVOKING_VERTEX_EXT 0x8E4F
+
+typedef void (GLAPIENTRY * PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode);
+
+#define glProvokingVertexEXT GLEW_GET_FUN(__glewProvokingVertexEXT)
+
+#define GLEW_EXT_provoking_vertex GLEW_GET_VAR(__GLEW_EXT_provoking_vertex)
+
+#endif /* GL_EXT_provoking_vertex */
+
 /* ------------------------- GL_EXT_rescale_normal ------------------------- */
 
 #ifndef GL_EXT_rescale_normal
@@ -6302,6 +7002,25 @@ typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenu
 
 #endif /* GL_EXT_secondary_color */
 
+/* --------------------- GL_EXT_separate_shader_objects -------------------- */
+
+#ifndef GL_EXT_separate_shader_objects
+#define GL_EXT_separate_shader_objects 1
+
+#define GL_ACTIVE_PROGRAM_EXT 0x8B8D
+
+typedef void (GLAPIENTRY * PFNGLACTIVEPROGRAMEXTPROC) (GLuint program);
+typedef GLuint (GLAPIENTRY * PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const char* string);
+typedef void (GLAPIENTRY * PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program);
+
+#define glActiveProgramEXT GLEW_GET_FUN(__glewActiveProgramEXT)
+#define glCreateShaderProgramEXT GLEW_GET_FUN(__glewCreateShaderProgramEXT)
+#define glUseShaderProgramEXT GLEW_GET_FUN(__glewUseShaderProgramEXT)
+
+#define GLEW_EXT_separate_shader_objects GLEW_GET_VAR(__GLEW_EXT_separate_shader_objects)
+
+#endif /* GL_EXT_separate_shader_objects */
+
 /* --------------------- GL_EXT_separate_specular_color -------------------- */
 
 #ifndef GL_EXT_separate_specular_color
@@ -6871,6 +7590,41 @@ typedef void (GLAPIENTRY * PFNGLTEXTURENORMALEXTPROC) (GLenum mode);
 
 #endif /* GL_EXT_texture_shared_exponent */
 
+/* -------------------------- GL_EXT_texture_snorm ------------------------- */
+
+#ifndef GL_EXT_texture_snorm
+#define GL_EXT_texture_snorm 1
+
+#define GL_RED_SNORM 0x8F90
+#define GL_RG_SNORM 0x8F91
+#define GL_RGB_SNORM 0x8F92
+#define GL_RGBA_SNORM 0x8F93
+#define GL_R8_SNORM 0x8F94
+#define GL_RG8_SNORM 0x8F95
+#define GL_RGB8_SNORM 0x8F96
+#define GL_RGBA8_SNORM 0x8F97
+#define GL_R16_SNORM 0x8F98
+#define GL_RG16_SNORM 0x8F99
+#define GL_RGB16_SNORM 0x8F9A
+#define GL_RGBA16_SNORM 0x8F9B
+#define GL_SIGNED_NORMALIZED 0x8F9C
+#define GL_ALPHA_SNORM 0x9010
+#define GL_LUMINANCE_SNORM 0x9011
+#define GL_LUMINANCE_ALPHA_SNORM 0x9012
+#define GL_INTENSITY_SNORM 0x9013
+#define GL_ALPHA8_SNORM 0x9014
+#define GL_LUMINANCE8_SNORM 0x9015
+#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016
+#define GL_INTENSITY8_SNORM 0x9017
+#define GL_ALPHA16_SNORM 0x9018
+#define GL_LUMINANCE16_SNORM 0x9019
+#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A
+#define GL_INTENSITY16_SNORM 0x901B
+
+#define GLEW_EXT_texture_snorm GLEW_GET_VAR(__GLEW_EXT_texture_snorm)
+
+#endif /* GL_EXT_texture_snorm */
+
 /* ------------------------- GL_EXT_texture_swizzle ------------------------ */
 
 #ifndef GL_EXT_texture_swizzle
@@ -7686,6 +8440,19 @@ typedef void (GLAPIENTRY * PFNGLENDCONDITIONALRENDERNVPROC) (void);
 
 #endif /* GL_NV_copy_depth_to_color */
 
+/* ---------------------------- GL_NV_copy_image --------------------------- */
+
+#ifndef GL_NV_copy_image
+#define GL_NV_copy_image 1
+
+typedef void (GLAPIENTRY * PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
+
+#define glCopyImageSubDataNV GLEW_GET_FUN(__glewCopyImageSubDataNV)
+
+#define GLEW_NV_copy_image GLEW_GET_VAR(__GLEW_NV_copy_image)
+
+#endif /* GL_NV_copy_image */
+
 /* ------------------------ GL_NV_depth_buffer_float ----------------------- */
 
 #ifndef GL_NV_depth_buffer_float
@@ -8229,6 +8996,15 @@ typedef void (GLAPIENTRY * PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target,
 
 #endif /* GL_NV_parameter_buffer_object */
 
+/* --------------------- GL_NV_parameter_buffer_object2 -------------------- */
+
+#ifndef GL_NV_parameter_buffer_object2
+#define GL_NV_parameter_buffer_object2 1
+
+#define GLEW_NV_parameter_buffer_object2 GLEW_GET_VAR(__GLEW_NV_parameter_buffer_object2)
+
+#endif /* GL_NV_parameter_buffer_object2 */
+
 /* ------------------------- GL_NV_pixel_data_range ------------------------ */
 
 #ifndef GL_NV_pixel_data_range
@@ -8288,7 +9064,6 @@ typedef void (GLAPIENTRY * PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum
 typedef void (GLAPIENTRY * PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint* params);
 typedef void (GLAPIENTRY * 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);
 typedef void (GLAPIENTRY * 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 (GLAPIENTRY * PFNGLVIDEOPARAMETERIVNVPROC) (GLuint video_slot, GLenum pname, const GLint* params);
 
 #define glGetVideoi64vNV GLEW_GET_FUN(__glewGetVideoi64vNV)
 #define glGetVideoivNV GLEW_GET_FUN(__glewGetVideoivNV)
@@ -8296,7 +9071,6 @@ typedef void (GLAPIENTRY * PFNGLVIDEOPARAMETERIVNVPROC) (GLuint video_slot, GLen
 #define glGetVideouivNV GLEW_GET_FUN(__glewGetVideouivNV)
 #define glPresentFrameDualFillNV GLEW_GET_FUN(__glewPresentFrameDualFillNV)
 #define glPresentFrameKeyedNV GLEW_GET_FUN(__glewPresentFrameKeyedNV)
-#define glVideoParameterivNV GLEW_GET_FUN(__glewVideoParameterivNV)
 
 #define GLEW_NV_present_video GLEW_GET_VAR(__GLEW_NV_present_video)
 
@@ -8426,6 +9200,49 @@ typedef void (GLAPIENTRY * PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage
 
 #endif /* GL_NV_register_combiners2 */
 
+/* ------------------------ GL_NV_shader_buffer_load ----------------------- */
+
+#ifndef GL_NV_shader_buffer_load
+#define GL_NV_shader_buffer_load 1
+
+#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D
+#define GL_GPU_ADDRESS_NV 0x8F34
+#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35
+
+typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT* params);
+typedef void (GLAPIENTRY * PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT* result);
+typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT* params);
+typedef void (GLAPIENTRY * PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT* params);
+typedef GLboolean (GLAPIENTRY * PFNGLISBUFFERRESIDENTNVPROC) (GLenum target);
+typedef GLboolean (GLAPIENTRY * PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer);
+typedef void (GLAPIENTRY * PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target);
+typedef void (GLAPIENTRY * PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access);
+typedef void (GLAPIENTRY * PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer);
+typedef void (GLAPIENTRY * PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access);
+typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value);
+typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT* value);
+typedef void (GLAPIENTRY * PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value);
+typedef void (GLAPIENTRY * PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT* value);
+
+#define glGetBufferParameterui64vNV GLEW_GET_FUN(__glewGetBufferParameterui64vNV)
+#define glGetIntegerui64vNV GLEW_GET_FUN(__glewGetIntegerui64vNV)
+#define glGetNamedBufferParameterui64vNV GLEW_GET_FUN(__glewGetNamedBufferParameterui64vNV)
+#define glGetUniformui64vNV GLEW_GET_FUN(__glewGetUniformui64vNV)
+#define glIsBufferResidentNV GLEW_GET_FUN(__glewIsBufferResidentNV)
+#define glIsNamedBufferResidentNV GLEW_GET_FUN(__glewIsNamedBufferResidentNV)
+#define glMakeBufferNonResidentNV GLEW_GET_FUN(__glewMakeBufferNonResidentNV)
+#define glMakeBufferResidentNV GLEW_GET_FUN(__glewMakeBufferResidentNV)
+#define glMakeNamedBufferNonResidentNV GLEW_GET_FUN(__glewMakeNamedBufferNonResidentNV)
+#define glMakeNamedBufferResidentNV GLEW_GET_FUN(__glewMakeNamedBufferResidentNV)
+#define glProgramUniformui64NV GLEW_GET_FUN(__glewProgramUniformui64NV)
+#define glProgramUniformui64vNV GLEW_GET_FUN(__glewProgramUniformui64vNV)
+#define glUniformui64NV GLEW_GET_FUN(__glewUniformui64NV)
+#define glUniformui64vNV GLEW_GET_FUN(__glewUniformui64vNV)
+
+#define GLEW_NV_shader_buffer_load GLEW_GET_VAR(__GLEW_NV_shader_buffer_load)
+
+#endif /* GL_NV_shader_buffer_load */
+
 /* -------------------------- GL_NV_texgen_emboss -------------------------- */
 
 #ifndef GL_NV_texgen_emboss
@@ -8451,6 +9268,19 @@ typedef void (GLAPIENTRY * PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage
 
 #endif /* GL_NV_texgen_reflection */
 
+/* ------------------------- GL_NV_texture_barrier ------------------------- */
+
+#ifndef GL_NV_texture_barrier
+#define GL_NV_texture_barrier 1
+
+typedef void (GLAPIENTRY * PFNGLTEXTUREBARRIERNVPROC) (void);
+
+#define glTextureBarrierNV GLEW_GET_FUN(__glewTextureBarrierNV)
+
+#define GLEW_NV_texture_barrier GLEW_GET_VAR(__GLEW_NV_texture_barrier)
+
+#endif /* GL_NV_texture_barrier */
+
 /* --------------------- GL_NV_texture_compression_vtc --------------------- */
 
 #ifndef GL_NV_texture_compression_vtc
@@ -8707,6 +9537,36 @@ typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program
 
 #endif /* GL_NV_transform_feedback */
 
+/* ----------------------- GL_NV_transform_feedback2 ----------------------- */
+
+#ifndef GL_NV_transform_feedback2
+#define GL_NV_transform_feedback2 1
+
+#define GL_TRANSFORM_FEEDBACK_NV 0x8E22
+#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23
+#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24
+#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25
+
+typedef void (GLAPIENTRY * PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id);
+typedef void (GLAPIENTRY * PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint* ids);
+typedef void (GLAPIENTRY * PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id);
+typedef void (GLAPIENTRY * PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint* ids);
+typedef GLboolean (GLAPIENTRY * PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id);
+typedef void (GLAPIENTRY * PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void);
+typedef void (GLAPIENTRY * PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void);
+
+#define glBindTransformFeedbackNV GLEW_GET_FUN(__glewBindTransformFeedbackNV)
+#define glDeleteTransformFeedbacksNV GLEW_GET_FUN(__glewDeleteTransformFeedbacksNV)
+#define glDrawTransformFeedbackNV GLEW_GET_FUN(__glewDrawTransformFeedbackNV)
+#define glGenTransformFeedbacksNV GLEW_GET_FUN(__glewGenTransformFeedbacksNV)
+#define glIsTransformFeedbackNV GLEW_GET_FUN(__glewIsTransformFeedbackNV)
+#define glPauseTransformFeedbackNV GLEW_GET_FUN(__glewPauseTransformFeedbackNV)
+#define glResumeTransformFeedbackNV GLEW_GET_FUN(__glewResumeTransformFeedbackNV)
+
+#define GLEW_NV_transform_feedback2 GLEW_GET_VAR(__GLEW_NV_transform_feedback2)
+
+#endif /* GL_NV_transform_feedback2 */
+
 /* ------------------------ GL_NV_vertex_array_range ----------------------- */
 
 #ifndef GL_NV_vertex_array_range
@@ -8739,6 +9599,64 @@ typedef void (GLAPIENTRY * PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, void* p
 
 #endif /* GL_NV_vertex_array_range2 */
 
+/* ------------------- GL_NV_vertex_buffer_unified_memory ------------------ */
+
+#ifndef GL_NV_vertex_buffer_unified_memory
+#define GL_NV_vertex_buffer_unified_memory 1
+
+#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E
+#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F
+#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20
+#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21
+#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22
+#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23
+#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24
+#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25
+#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26
+#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27
+#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28
+#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29
+#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A
+#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B
+#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C
+#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D
+#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E
+#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F
+#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30
+#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31
+#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32
+#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33
+
+typedef void (GLAPIENTRY * PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length);
+typedef void (GLAPIENTRY * PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);
+typedef void (GLAPIENTRY * PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride);
+typedef void (GLAPIENTRY * PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride);
+typedef void (GLAPIENTRY * PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT result[]);
+typedef void (GLAPIENTRY * PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride);
+typedef void (GLAPIENTRY * PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride);
+typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);
+typedef void (GLAPIENTRY * PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);
+typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride);
+typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride);
+typedef void (GLAPIENTRY * PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);
+
+#define glBufferAddressRangeNV GLEW_GET_FUN(__glewBufferAddressRangeNV)
+#define glColorFormatNV GLEW_GET_FUN(__glewColorFormatNV)
+#define glEdgeFlagFormatNV GLEW_GET_FUN(__glewEdgeFlagFormatNV)
+#define glFogCoordFormatNV GLEW_GET_FUN(__glewFogCoordFormatNV)
+#define glGetIntegerui64i_vNV GLEW_GET_FUN(__glewGetIntegerui64i_vNV)
+#define glIndexFormatNV GLEW_GET_FUN(__glewIndexFormatNV)
+#define glNormalFormatNV GLEW_GET_FUN(__glewNormalFormatNV)
+#define glSecondaryColorFormatNV GLEW_GET_FUN(__glewSecondaryColorFormatNV)
+#define glTexCoordFormatNV GLEW_GET_FUN(__glewTexCoordFormatNV)
+#define glVertexAttribFormatNV GLEW_GET_FUN(__glewVertexAttribFormatNV)
+#define glVertexAttribIFormatNV GLEW_GET_FUN(__glewVertexAttribIFormatNV)
+#define glVertexFormatNV GLEW_GET_FUN(__glewVertexFormatNV)
+
+#define GLEW_NV_vertex_buffer_unified_memory GLEW_GET_VAR(__GLEW_NV_vertex_buffer_unified_memory)
+
+#endif /* GL_NV_vertex_buffer_unified_memory */
+
 /* -------------------------- GL_NV_vertex_program ------------------------- */
 
 #ifndef GL_NV_vertex_program
@@ -10460,8 +11378,6 @@ GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4X3FVPROC __glewUniformMatrix4x3fv;
 
 GLEW_FUN_EXPORT PFNGLBEGINCONDITIONALRENDERPROC __glewBeginConditionalRender;
 GLEW_FUN_EXPORT PFNGLBEGINTRANSFORMFEEDBACKPROC __glewBeginTransformFeedback;
-GLEW_FUN_EXPORT PFNGLBINDBUFFERBASEPROC __glewBindBufferBase;
-GLEW_FUN_EXPORT PFNGLBINDBUFFERRANGEPROC __glewBindBufferRange;
 GLEW_FUN_EXPORT PFNGLBINDFRAGDATALOCATIONPROC __glewBindFragDataLocation;
 GLEW_FUN_EXPORT PFNGLCLAMPCOLORPROC __glewClampColor;
 GLEW_FUN_EXPORT PFNGLCLEARBUFFERFIPROC __glewClearBufferfi;
@@ -10475,7 +11391,6 @@ GLEW_FUN_EXPORT PFNGLENDCONDITIONALRENDERPROC __glewEndConditionalRender;
 GLEW_FUN_EXPORT PFNGLENDTRANSFORMFEEDBACKPROC __glewEndTransformFeedback;
 GLEW_FUN_EXPORT PFNGLGETBOOLEANI_VPROC __glewGetBooleani_v;
 GLEW_FUN_EXPORT PFNGLGETFRAGDATALOCATIONPROC __glewGetFragDataLocation;
-GLEW_FUN_EXPORT PFNGLGETINTEGERI_VPROC __glewGetIntegeri_v;
 GLEW_FUN_EXPORT PFNGLGETSTRINGIPROC __glewGetStringi;
 GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIIVPROC __glewGetTexParameterIiv;
 GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIUIVPROC __glewGetTexParameterIuiv;
@@ -10517,8 +11432,37 @@ GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIVPROC __glewVertexAttribI4uiv;
 GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4USVPROC __glewVertexAttribI4usv;
 GLEW_FUN_EXPORT PFNGLVERTEXATTRIBIPOINTERPROC __glewVertexAttribIPointer;
 
+GLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDPROC __glewDrawArraysInstanced;
+GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDPROC __glewDrawElementsInstanced;
+GLEW_FUN_EXPORT PFNGLPRIMITIVERESTARTINDEXPROC __glewPrimitiveRestartIndex;
+GLEW_FUN_EXPORT PFNGLTEXBUFFERPROC __glewTexBuffer;
+
+GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREPROC __glewFramebufferTexture;
+GLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERI64VPROC __glewGetBufferParameteri64v;
+GLEW_FUN_EXPORT PFNGLGETINTEGER64I_VPROC __glewGetInteger64i_v;
+
 GLEW_FUN_EXPORT PFNGLTBUFFERMASK3DFXPROC __glewTbufferMask3DFX;
 
+GLEW_FUN_EXPORT PFNGLBLENDEQUATIONINDEXEDAMDPROC __glewBlendEquationIndexedAMD;
+GLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC __glewBlendEquationSeparateIndexedAMD;
+GLEW_FUN_EXPORT PFNGLBLENDFUNCINDEXEDAMDPROC __glewBlendFuncIndexedAMD;
+GLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC __glewBlendFuncSeparateIndexedAMD;
+
+GLEW_FUN_EXPORT PFNGLBEGINPERFMONITORAMDPROC __glewBeginPerfMonitorAMD;
+GLEW_FUN_EXPORT PFNGLDELETEPERFMONITORSAMDPROC __glewDeletePerfMonitorsAMD;
+GLEW_FUN_EXPORT PFNGLENDPERFMONITORAMDPROC __glewEndPerfMonitorAMD;
+GLEW_FUN_EXPORT PFNGLGENPERFMONITORSAMDPROC __glewGenPerfMonitorsAMD;
+GLEW_FUN_EXPORT PFNGLGETPERFMONITORCOUNTERDATAAMDPROC __glewGetPerfMonitorCounterDataAMD;
+GLEW_FUN_EXPORT PFNGLGETPERFMONITORCOUNTERINFOAMDPROC __glewGetPerfMonitorCounterInfoAMD;
+GLEW_FUN_EXPORT PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC __glewGetPerfMonitorCounterStringAMD;
+GLEW_FUN_EXPORT PFNGLGETPERFMONITORCOUNTERSAMDPROC __glewGetPerfMonitorCountersAMD;
+GLEW_FUN_EXPORT PFNGLGETPERFMONITORGROUPSTRINGAMDPROC __glewGetPerfMonitorGroupStringAMD;
+GLEW_FUN_EXPORT PFNGLGETPERFMONITORGROUPSAMDPROC __glewGetPerfMonitorGroupsAMD;
+GLEW_FUN_EXPORT PFNGLSELECTPERFMONITORCOUNTERSAMDPROC __glewSelectPerfMonitorCountersAMD;
+
+GLEW_FUN_EXPORT PFNGLTESSELLATIONFACTORAMDPROC __glewTessellationFactorAMD;
+GLEW_FUN_EXPORT PFNGLTESSELLATIONMODEAMDPROC __glewTessellationModeAMD;
+
 GLEW_FUN_EXPORT PFNGLDRAWELEMENTARRAYAPPLEPROC __glewDrawElementArrayAPPLE;
 GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC __glewDrawRangeElementArrayAPPLE;
 GLEW_FUN_EXPORT PFNGLELEMENTPOINTERAPPLEPROC __glewElementPointerAPPLE;
@@ -10537,6 +11481,10 @@ GLEW_FUN_EXPORT PFNGLTESTOBJECTAPPLEPROC __glewTestObjectAPPLE;
 GLEW_FUN_EXPORT PFNGLBUFFERPARAMETERIAPPLEPROC __glewBufferParameteriAPPLE;
 GLEW_FUN_EXPORT PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC __glewFlushMappedBufferRangeAPPLE;
 
+GLEW_FUN_EXPORT PFNGLGETOBJECTPARAMETERIVAPPLEPROC __glewGetObjectParameterivAPPLE;
+GLEW_FUN_EXPORT PFNGLOBJECTPURGEABLEAPPLEPROC __glewObjectPurgeableAPPLE;
+GLEW_FUN_EXPORT PFNGLOBJECTUNPURGEABLEAPPLEPROC __glewObjectUnpurgeableAPPLE;
+
 GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC __glewGetTexParameterPointervAPPLE;
 GLEW_FUN_EXPORT PFNGLTEXTURERANGEAPPLEPROC __glewTextureRangeAPPLE;
 
@@ -10549,10 +11497,30 @@ GLEW_FUN_EXPORT PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC __glewFlushVertexArrayRangeA
 GLEW_FUN_EXPORT PFNGLVERTEXARRAYPARAMETERIAPPLEPROC __glewVertexArrayParameteriAPPLE;
 GLEW_FUN_EXPORT PFNGLVERTEXARRAYRANGEAPPLEPROC __glewVertexArrayRangeAPPLE;
 
+GLEW_FUN_EXPORT PFNGLDISABLEVERTEXATTRIBAPPLEPROC __glewDisableVertexAttribAPPLE;
+GLEW_FUN_EXPORT PFNGLENABLEVERTEXATTRIBAPPLEPROC __glewEnableVertexAttribAPPLE;
+GLEW_FUN_EXPORT PFNGLISVERTEXATTRIBENABLEDAPPLEPROC __glewIsVertexAttribEnabledAPPLE;
+GLEW_FUN_EXPORT PFNGLMAPVERTEXATTRIB1DAPPLEPROC __glewMapVertexAttrib1dAPPLE;
+GLEW_FUN_EXPORT PFNGLMAPVERTEXATTRIB1FAPPLEPROC __glewMapVertexAttrib1fAPPLE;
+GLEW_FUN_EXPORT PFNGLMAPVERTEXATTRIB2DAPPLEPROC __glewMapVertexAttrib2dAPPLE;
+GLEW_FUN_EXPORT PFNGLMAPVERTEXATTRIB2FAPPLEPROC __glewMapVertexAttrib2fAPPLE;
+
 GLEW_FUN_EXPORT PFNGLCLAMPCOLORARBPROC __glewClampColorARB;
 
+GLEW_FUN_EXPORT PFNGLCOPYBUFFERSUBDATAPROC __glewCopyBufferSubData;
+
 GLEW_FUN_EXPORT PFNGLDRAWBUFFERSARBPROC __glewDrawBuffersARB;
 
+GLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEIARBPROC __glewBlendEquationSeparateiARB;
+GLEW_FUN_EXPORT PFNGLBLENDEQUATIONIARBPROC __glewBlendEquationiARB;
+GLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEIARBPROC __glewBlendFuncSeparateiARB;
+GLEW_FUN_EXPORT PFNGLBLENDFUNCIARBPROC __glewBlendFunciARB;
+
+GLEW_FUN_EXPORT PFNGLDRAWELEMENTSBASEVERTEXPROC __glewDrawElementsBaseVertex;
+GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC __glewDrawElementsInstancedBaseVertex;
+GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC __glewDrawRangeElementsBaseVertex;
+GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC __glewMultiDrawElementsBaseVertex;
+
 GLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDARBPROC __glewDrawArraysInstancedARB;
 GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDARBPROC __glewDrawElementsInstancedARB;
 
@@ -10563,10 +11531,10 @@ GLEW_FUN_EXPORT PFNGLCHECKFRAMEBUFFERSTATUSPROC __glewCheckFramebufferStatus;
 GLEW_FUN_EXPORT PFNGLDELETEFRAMEBUFFERSPROC __glewDeleteFramebuffers;
 GLEW_FUN_EXPORT PFNGLDELETERENDERBUFFERSPROC __glewDeleteRenderbuffers;
 GLEW_FUN_EXPORT PFNGLFRAMEBUFFERRENDERBUFFERPROC __glewFramebufferRenderbuffer;
-GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURELAYERPROC __glewFramebufferTextureLayer;
 GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE1DPROC __glewFramebufferTexture1D;
 GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE2DPROC __glewFramebufferTexture2D;
 GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE3DPROC __glewFramebufferTexture3D;
+GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURELAYERPROC __glewFramebufferTextureLayer;
 GLEW_FUN_EXPORT PFNGLGENFRAMEBUFFERSPROC __glewGenFramebuffers;
 GLEW_FUN_EXPORT PFNGLGENRENDERBUFFERSPROC __glewGenRenderbuffers;
 GLEW_FUN_EXPORT PFNGLGENERATEMIPMAPPROC __glewGenerateMipmap;
@@ -10675,6 +11643,10 @@ GLEW_FUN_EXPORT PFNGLISQUERYARBPROC __glewIsQueryARB;
 GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFARBPROC __glewPointParameterfARB;
 GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFVARBPROC __glewPointParameterfvARB;
 
+GLEW_FUN_EXPORT PFNGLPROVOKINGVERTEXPROC __glewProvokingVertex;
+
+GLEW_FUN_EXPORT PFNGLMINSAMPLESHADINGARBPROC __glewMinSampleShadingARB;
+
 GLEW_FUN_EXPORT PFNGLATTACHOBJECTARBPROC __glewAttachObjectARB;
 GLEW_FUN_EXPORT PFNGLCOMPILESHADERARBPROC __glewCompileShaderARB;
 GLEW_FUN_EXPORT PFNGLCREATEPROGRAMOBJECTARBPROC __glewCreateProgramObjectARB;
@@ -10715,6 +11687,14 @@ GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4FVARBPROC __glewUniformMatrix4fvARB;
 GLEW_FUN_EXPORT PFNGLUSEPROGRAMOBJECTARBPROC __glewUseProgramObjectARB;
 GLEW_FUN_EXPORT PFNGLVALIDATEPROGRAMARBPROC __glewValidateProgramARB;
 
+GLEW_FUN_EXPORT PFNGLCLIENTWAITSYNCPROC __glewClientWaitSync;
+GLEW_FUN_EXPORT PFNGLDELETESYNCPROC __glewDeleteSync;
+GLEW_FUN_EXPORT PFNGLFENCESYNCPROC __glewFenceSync;
+GLEW_FUN_EXPORT PFNGLGETINTEGER64VPROC __glewGetInteger64v;
+GLEW_FUN_EXPORT PFNGLGETSYNCIVPROC __glewGetSynciv;
+GLEW_FUN_EXPORT PFNGLISSYNCPROC __glewIsSync;
+GLEW_FUN_EXPORT PFNGLWAITSYNCPROC __glewWaitSync;
+
 GLEW_FUN_EXPORT PFNGLTEXBUFFERARBPROC __glewTexBufferARB;
 
 GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE1DARBPROC __glewCompressedTexImage1DARB;
@@ -10725,11 +11705,27 @@ GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC __glewCompressedTexSubImage2
 GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC __glewCompressedTexSubImage3DARB;
 GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXIMAGEARBPROC __glewGetCompressedTexImageARB;
 
+GLEW_FUN_EXPORT PFNGLGETMULTISAMPLEFVPROC __glewGetMultisamplefv;
+GLEW_FUN_EXPORT PFNGLSAMPLEMASKIPROC __glewSampleMaski;
+GLEW_FUN_EXPORT PFNGLTEXIMAGE2DMULTISAMPLEPROC __glewTexImage2DMultisample;
+GLEW_FUN_EXPORT PFNGLTEXIMAGE3DMULTISAMPLEPROC __glewTexImage3DMultisample;
+
 GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXDARBPROC __glewLoadTransposeMatrixdARB;
 GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXFARBPROC __glewLoadTransposeMatrixfARB;
 GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXDARBPROC __glewMultTransposeMatrixdARB;
 GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXFARBPROC __glewMultTransposeMatrixfARB;
 
+GLEW_FUN_EXPORT PFNGLBINDBUFFERBASEPROC __glewBindBufferBase;
+GLEW_FUN_EXPORT PFNGLBINDBUFFERRANGEPROC __glewBindBufferRange;
+GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC __glewGetActiveUniformBlockName;
+GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMBLOCKIVPROC __glewGetActiveUniformBlockiv;
+GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMNAMEPROC __glewGetActiveUniformName;
+GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMSIVPROC __glewGetActiveUniformsiv;
+GLEW_FUN_EXPORT PFNGLGETINTEGERI_VPROC __glewGetIntegeri_v;
+GLEW_FUN_EXPORT PFNGLGETUNIFORMBLOCKINDEXPROC __glewGetUniformBlockIndex;
+GLEW_FUN_EXPORT PFNGLGETUNIFORMINDICESPROC __glewGetUniformIndices;
+GLEW_FUN_EXPORT PFNGLUNIFORMBLOCKBINDINGPROC __glewUniformBlockBinding;
+
 GLEW_FUN_EXPORT PFNGLBINDVERTEXARRAYPROC __glewBindVertexArray;
 GLEW_FUN_EXPORT PFNGLDELETEVERTEXARRAYSPROC __glewDeleteVertexArrays;
 GLEW_FUN_EXPORT PFNGLGENVERTEXARRAYSPROC __glewGenVertexArrays;
@@ -11004,7 +12000,14 @@ GLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC __glewCopyTextureSubImage1DEXT
 GLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC __glewCopyTextureSubImage2DEXT;
 GLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC __glewCopyTextureSubImage3DEXT;
 GLEW_FUN_EXPORT PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC __glewDisableClientStateIndexedEXT;
+GLEW_FUN_EXPORT PFNGLDISABLECLIENTSTATEIEXTPROC __glewDisableClientStateiEXT;
+GLEW_FUN_EXPORT PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC __glewDisableVertexArrayAttribEXT;
+GLEW_FUN_EXPORT PFNGLDISABLEVERTEXARRAYEXTPROC __glewDisableVertexArrayEXT;
 GLEW_FUN_EXPORT PFNGLENABLECLIENTSTATEINDEXEDEXTPROC __glewEnableClientStateIndexedEXT;
+GLEW_FUN_EXPORT PFNGLENABLECLIENTSTATEIEXTPROC __glewEnableClientStateiEXT;
+GLEW_FUN_EXPORT PFNGLENABLEVERTEXARRAYATTRIBEXTPROC __glewEnableVertexArrayAttribEXT;
+GLEW_FUN_EXPORT PFNGLENABLEVERTEXARRAYEXTPROC __glewEnableVertexArrayEXT;
+GLEW_FUN_EXPORT PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC __glewFlushMappedNamedBufferRangeEXT;
 GLEW_FUN_EXPORT PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC __glewFramebufferDrawBufferEXT;
 GLEW_FUN_EXPORT PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC __glewFramebufferDrawBuffersEXT;
 GLEW_FUN_EXPORT PFNGLFRAMEBUFFERREADBUFFEREXTPROC __glewFramebufferReadBufferEXT;
@@ -11013,7 +12016,9 @@ GLEW_FUN_EXPORT PFNGLGENERATETEXTUREMIPMAPEXTPROC __glewGenerateTextureMipmapEXT
 GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC __glewGetCompressedMultiTexImageEXT;
 GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC __glewGetCompressedTextureImageEXT;
 GLEW_FUN_EXPORT PFNGLGETDOUBLEINDEXEDVEXTPROC __glewGetDoubleIndexedvEXT;
+GLEW_FUN_EXPORT PFNGLGETDOUBLEI_VEXTPROC __glewGetDoublei_vEXT;
 GLEW_FUN_EXPORT PFNGLGETFLOATINDEXEDVEXTPROC __glewGetFloatIndexedvEXT;
+GLEW_FUN_EXPORT PFNGLGETFLOATI_VEXTPROC __glewGetFloati_vEXT;
 GLEW_FUN_EXPORT PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC __glewGetFramebufferParameterivEXT;
 GLEW_FUN_EXPORT PFNGLGETMULTITEXENVFVEXTPROC __glewGetMultiTexEnvfvEXT;
 GLEW_FUN_EXPORT PFNGLGETMULTITEXENVIVEXTPROC __glewGetMultiTexEnvivEXT;
@@ -11039,6 +12044,7 @@ GLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMSTRINGEXTPROC __glewGetNamedProgramStringEXT
 GLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMIVEXTPROC __glewGetNamedProgramivEXT;
 GLEW_FUN_EXPORT PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC __glewGetNamedRenderbufferParameterivEXT;
 GLEW_FUN_EXPORT PFNGLGETPOINTERINDEXEDVEXTPROC __glewGetPointerIndexedvEXT;
+GLEW_FUN_EXPORT PFNGLGETPOINTERI_VEXTPROC __glewGetPointeri_vEXT;
 GLEW_FUN_EXPORT PFNGLGETTEXTUREIMAGEEXTPROC __glewGetTextureImageEXT;
 GLEW_FUN_EXPORT PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC __glewGetTextureLevelParameterfvEXT;
 GLEW_FUN_EXPORT PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC __glewGetTextureLevelParameterivEXT;
@@ -11046,7 +12052,12 @@ GLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIIVEXTPROC __glewGetTextureParameterIivE
 GLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIUIVEXTPROC __glewGetTextureParameterIuivEXT;
 GLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERFVEXTPROC __glewGetTextureParameterfvEXT;
 GLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIVEXTPROC __glewGetTextureParameterivEXT;
+GLEW_FUN_EXPORT PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC __glewGetVertexArrayIntegeri_vEXT;
+GLEW_FUN_EXPORT PFNGLGETVERTEXARRAYINTEGERVEXTPROC __glewGetVertexArrayIntegervEXT;
+GLEW_FUN_EXPORT PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC __glewGetVertexArrayPointeri_vEXT;
+GLEW_FUN_EXPORT PFNGLGETVERTEXARRAYPOINTERVEXTPROC __glewGetVertexArrayPointervEXT;
 GLEW_FUN_EXPORT PFNGLMAPNAMEDBUFFEREXTPROC __glewMapNamedBufferEXT;
+GLEW_FUN_EXPORT PFNGLMAPNAMEDBUFFERRANGEEXTPROC __glewMapNamedBufferRangeEXT;
 GLEW_FUN_EXPORT PFNGLMATRIXFRUSTUMEXTPROC __glewMatrixFrustumEXT;
 GLEW_FUN_EXPORT PFNGLMATRIXLOADIDENTITYEXTPROC __glewMatrixLoadIdentityEXT;
 GLEW_FUN_EXPORT PFNGLMATRIXLOADTRANSPOSEDEXTPROC __glewMatrixLoadTransposedEXT;
@@ -11093,6 +12104,7 @@ GLEW_FUN_EXPORT PFNGLMULTITEXSUBIMAGE2DEXTPROC __glewMultiTexSubImage2DEXT;
 GLEW_FUN_EXPORT PFNGLMULTITEXSUBIMAGE3DEXTPROC __glewMultiTexSubImage3DEXT;
 GLEW_FUN_EXPORT PFNGLNAMEDBUFFERDATAEXTPROC __glewNamedBufferDataEXT;
 GLEW_FUN_EXPORT PFNGLNAMEDBUFFERSUBDATAEXTPROC __glewNamedBufferSubDataEXT;
+GLEW_FUN_EXPORT PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC __glewNamedCopyBufferSubDataEXT;
 GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC __glewNamedFramebufferRenderbufferEXT;
 GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC __glewNamedFramebufferTexture1DEXT;
 GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC __glewNamedFramebufferTexture2DEXT;
@@ -11164,6 +12176,17 @@ GLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE1DEXTPROC __glewTextureSubImage1DEXT;
 GLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE2DEXTPROC __glewTextureSubImage2DEXT;
 GLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE3DEXTPROC __glewTextureSubImage3DEXT;
 GLEW_FUN_EXPORT PFNGLUNMAPNAMEDBUFFEREXTPROC __glewUnmapNamedBufferEXT;
+GLEW_FUN_EXPORT PFNGLVERTEXARRAYCOLOROFFSETEXTPROC __glewVertexArrayColorOffsetEXT;
+GLEW_FUN_EXPORT PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC __glewVertexArrayEdgeFlagOffsetEXT;
+GLEW_FUN_EXPORT PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC __glewVertexArrayFogCoordOffsetEXT;
+GLEW_FUN_EXPORT PFNGLVERTEXARRAYINDEXOFFSETEXTPROC __glewVertexArrayIndexOffsetEXT;
+GLEW_FUN_EXPORT PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC __glewVertexArrayMultiTexCoordOffsetEXT;
+GLEW_FUN_EXPORT PFNGLVERTEXARRAYNORMALOFFSETEXTPROC __glewVertexArrayNormalOffsetEXT;
+GLEW_FUN_EXPORT PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC __glewVertexArraySecondaryColorOffsetEXT;
+GLEW_FUN_EXPORT PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC __glewVertexArrayTexCoordOffsetEXT;
+GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC __glewVertexArrayVertexAttribIOffsetEXT;
+GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC __glewVertexArrayVertexAttribOffsetEXT;
+GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC __glewVertexArrayVertexOffsetEXT;
 
 GLEW_FUN_EXPORT PFNGLCOLORMASKINDEXEDEXTPROC __glewColorMaskIndexedEXT;
 GLEW_FUN_EXPORT PFNGLDISABLEINDEXEDEXTPROC __glewDisableIndexedEXT;
@@ -11309,6 +12332,8 @@ GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFVEXTPROC __glewPointParameterfvEXT;
 
 GLEW_FUN_EXPORT PFNGLPOLYGONOFFSETEXTPROC __glewPolygonOffsetEXT;
 
+GLEW_FUN_EXPORT PFNGLPROVOKINGVERTEXEXTPROC __glewProvokingVertexEXT;
+
 GLEW_FUN_EXPORT PFNGLBEGINSCENEEXTPROC __glewBeginSceneEXT;
 GLEW_FUN_EXPORT PFNGLENDSCENEEXTPROC __glewEndSceneEXT;
 
@@ -11330,6 +12355,10 @@ GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USEXTPROC __glewSecondaryColor3usEXT;
 GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USVEXTPROC __glewSecondaryColor3usvEXT;
 GLEW_FUN_EXPORT PFNGLSECONDARYCOLORPOINTEREXTPROC __glewSecondaryColorPointerEXT;
 
+GLEW_FUN_EXPORT PFNGLACTIVEPROGRAMEXTPROC __glewActiveProgramEXT;
+GLEW_FUN_EXPORT PFNGLCREATESHADERPROGRAMEXTPROC __glewCreateShaderProgramEXT;
+GLEW_FUN_EXPORT PFNGLUSESHADERPROGRAMEXTPROC __glewUseShaderProgramEXT;
+
 GLEW_FUN_EXPORT PFNGLACTIVESTENCILFACEEXTPROC __glewActiveStencilFaceEXT;
 
 GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE1DEXTPROC __glewTexSubImage1DEXT;
@@ -11491,6 +12520,8 @@ GLEW_FUN_EXPORT PFNGLWINDOWPOS4SVMESAPROC __glewWindowPos4svMESA;
 GLEW_FUN_EXPORT PFNGLBEGINCONDITIONALRENDERNVPROC __glewBeginConditionalRenderNV;
 GLEW_FUN_EXPORT PFNGLENDCONDITIONALRENDERNVPROC __glewEndConditionalRenderNV;
 
+GLEW_FUN_EXPORT PFNGLCOPYIMAGESUBDATANVPROC __glewCopyImageSubDataNV;
+
 GLEW_FUN_EXPORT PFNGLCLEARDEPTHDNVPROC __glewClearDepthdNV;
 GLEW_FUN_EXPORT PFNGLDEPTHBOUNDSDNVPROC __glewDepthBoundsdNV;
 GLEW_FUN_EXPORT PFNGLDEPTHRANGEDNVPROC __glewDepthRangedNV;
@@ -11612,7 +12643,6 @@ GLEW_FUN_EXPORT PFNGLGETVIDEOUI64VNVPROC __glewGetVideoui64vNV;
 GLEW_FUN_EXPORT PFNGLGETVIDEOUIVNVPROC __glewGetVideouivNV;
 GLEW_FUN_EXPORT PFNGLPRESENTFRAMEDUALFILLNVPROC __glewPresentFrameDualFillNV;
 GLEW_FUN_EXPORT PFNGLPRESENTFRAMEKEYEDNVPROC __glewPresentFrameKeyedNV;
-GLEW_FUN_EXPORT PFNGLVIDEOPARAMETERIVNVPROC __glewVideoParameterivNV;
 
 GLEW_FUN_EXPORT PFNGLPRIMITIVERESTARTINDEXNVPROC __glewPrimitiveRestartIndexNV;
 GLEW_FUN_EXPORT PFNGLPRIMITIVERESTARTNVPROC __glewPrimitiveRestartNV;
@@ -11634,6 +12664,23 @@ GLEW_FUN_EXPORT PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC __glewGetFinalCombin
 GLEW_FUN_EXPORT PFNGLCOMBINERSTAGEPARAMETERFVNVPROC __glewCombinerStageParameterfvNV;
 GLEW_FUN_EXPORT PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC __glewGetCombinerStageParameterfvNV;
 
+GLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERUI64VNVPROC __glewGetBufferParameterui64vNV;
+GLEW_FUN_EXPORT PFNGLGETINTEGERUI64VNVPROC __glewGetIntegerui64vNV;
+GLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC __glewGetNamedBufferParameterui64vNV;
+GLEW_FUN_EXPORT PFNGLGETUNIFORMUI64VNVPROC __glewGetUniformui64vNV;
+GLEW_FUN_EXPORT PFNGLISBUFFERRESIDENTNVPROC __glewIsBufferResidentNV;
+GLEW_FUN_EXPORT PFNGLISNAMEDBUFFERRESIDENTNVPROC __glewIsNamedBufferResidentNV;
+GLEW_FUN_EXPORT PFNGLMAKEBUFFERNONRESIDENTNVPROC __glewMakeBufferNonResidentNV;
+GLEW_FUN_EXPORT PFNGLMAKEBUFFERRESIDENTNVPROC __glewMakeBufferResidentNV;
+GLEW_FUN_EXPORT PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC __glewMakeNamedBufferNonResidentNV;
+GLEW_FUN_EXPORT PFNGLMAKENAMEDBUFFERRESIDENTNVPROC __glewMakeNamedBufferResidentNV;
+GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMUI64NVPROC __glewProgramUniformui64NV;
+GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMUI64VNVPROC __glewProgramUniformui64vNV;
+GLEW_FUN_EXPORT PFNGLUNIFORMUI64NVPROC __glewUniformui64NV;
+GLEW_FUN_EXPORT PFNGLUNIFORMUI64VNVPROC __glewUniformui64vNV;
+
+GLEW_FUN_EXPORT PFNGLTEXTUREBARRIERNVPROC __glewTextureBarrierNV;
+
 GLEW_FUN_EXPORT PFNGLACTIVEVARYINGNVPROC __glewActiveVaryingNV;
 GLEW_FUN_EXPORT PFNGLBEGINTRANSFORMFEEDBACKNVPROC __glewBeginTransformFeedbackNV;
 GLEW_FUN_EXPORT PFNGLBINDBUFFERBASENVPROC __glewBindBufferBaseNV;
@@ -11646,9 +12693,30 @@ GLEW_FUN_EXPORT PFNGLGETVARYINGLOCATIONNVPROC __glewGetVaryingLocationNV;
 GLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC __glewTransformFeedbackAttribsNV;
 GLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC __glewTransformFeedbackVaryingsNV;
 
+GLEW_FUN_EXPORT PFNGLBINDTRANSFORMFEEDBACKNVPROC __glewBindTransformFeedbackNV;
+GLEW_FUN_EXPORT PFNGLDELETETRANSFORMFEEDBACKSNVPROC __glewDeleteTransformFeedbacksNV;
+GLEW_FUN_EXPORT PFNGLDRAWTRANSFORMFEEDBACKNVPROC __glewDrawTransformFeedbackNV;
+GLEW_FUN_EXPORT PFNGLGENTRANSFORMFEEDBACKSNVPROC __glewGenTransformFeedbacksNV;
+GLEW_FUN_EXPORT PFNGLISTRANSFORMFEEDBACKNVPROC __glewIsTransformFeedbackNV;
+GLEW_FUN_EXPORT PFNGLPAUSETRANSFORMFEEDBACKNVPROC __glewPauseTransformFeedbackNV;
+GLEW_FUN_EXPORT PFNGLRESUMETRANSFORMFEEDBACKNVPROC __glewResumeTransformFeedbackNV;
+
 GLEW_FUN_EXPORT PFNGLFLUSHVERTEXARRAYRANGENVPROC __glewFlushVertexArrayRangeNV;
 GLEW_FUN_EXPORT PFNGLVERTEXARRAYRANGENVPROC __glewVertexArrayRangeNV;
 
+GLEW_FUN_EXPORT PFNGLBUFFERADDRESSRANGENVPROC __glewBufferAddressRangeNV;
+GLEW_FUN_EXPORT PFNGLCOLORFORMATNVPROC __glewColorFormatNV;
+GLEW_FUN_EXPORT PFNGLEDGEFLAGFORMATNVPROC __glewEdgeFlagFormatNV;
+GLEW_FUN_EXPORT PFNGLFOGCOORDFORMATNVPROC __glewFogCoordFormatNV;
+GLEW_FUN_EXPORT PFNGLGETINTEGERUI64I_VNVPROC __glewGetIntegerui64i_vNV;
+GLEW_FUN_EXPORT PFNGLINDEXFORMATNVPROC __glewIndexFormatNV;
+GLEW_FUN_EXPORT PFNGLNORMALFORMATNVPROC __glewNormalFormatNV;
+GLEW_FUN_EXPORT PFNGLSECONDARYCOLORFORMATNVPROC __glewSecondaryColorFormatNV;
+GLEW_FUN_EXPORT PFNGLTEXCOORDFORMATNVPROC __glewTexCoordFormatNV;
+GLEW_FUN_EXPORT PFNGLVERTEXATTRIBFORMATNVPROC __glewVertexAttribFormatNV;
+GLEW_FUN_EXPORT PFNGLVERTEXATTRIBIFORMATNVPROC __glewVertexAttribIFormatNV;
+GLEW_FUN_EXPORT PFNGLVERTEXFORMATNVPROC __glewVertexFormatNV;
+
 GLEW_FUN_EXPORT PFNGLAREPROGRAMSRESIDENTNVPROC __glewAreProgramsResidentNV;
 GLEW_FUN_EXPORT PFNGLBINDPROGRAMNVPROC __glewBindProgramNV;
 GLEW_FUN_EXPORT PFNGLDELETEPROGRAMSNVPROC __glewDeleteProgramsNV;
@@ -11866,26 +12934,43 @@ GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_5;
 GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_2_0;
 GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_2_1;
 GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_3_0;
+GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_3_1;
+GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_3_2;
 GLEW_VAR_EXPORT GLboolean __GLEW_3DFX_multisample;
 GLEW_VAR_EXPORT GLboolean __GLEW_3DFX_tbuffer;
 GLEW_VAR_EXPORT GLboolean __GLEW_3DFX_texture_compression_FXT1;
+GLEW_VAR_EXPORT GLboolean __GLEW_AMD_draw_buffers_blend;
+GLEW_VAR_EXPORT GLboolean __GLEW_AMD_performance_monitor;
+GLEW_VAR_EXPORT GLboolean __GLEW_AMD_texture_texture4;
+GLEW_VAR_EXPORT GLboolean __GLEW_AMD_vertex_shader_tessellator;
+GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_aux_depth_stencil;
 GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_client_storage;
 GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_element_array;
 GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_fence;
 GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_float_pixels;
 GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_flush_buffer_range;
+GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_object_purgeable;
 GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_pixel_buffer;
+GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_rgb_422;
+GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_row_bytes;
 GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_specular_vector;
 GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_texture_range;
 GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_transform_hint;
 GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_vertex_array_object;
 GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_vertex_array_range;
+GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_vertex_program_evaluators;
 GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_ycbcr_422;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_color_buffer_float;
+GLEW_VAR_EXPORT GLboolean __GLEW_ARB_compatibility;
+GLEW_VAR_EXPORT GLboolean __GLEW_ARB_copy_buffer;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_depth_buffer_float;
+GLEW_VAR_EXPORT GLboolean __GLEW_ARB_depth_clamp;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_depth_texture;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_buffers;
+GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_buffers_blend;
+GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_elements_base_vertex;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_instanced;
+GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_coord_conventions;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_program;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_program_shadow;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_shader;
@@ -11904,25 +12989,36 @@ GLEW_VAR_EXPORT GLboolean __GLEW_ARB_occlusion_query;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_pixel_buffer_object;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_point_parameters;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_point_sprite;
+GLEW_VAR_EXPORT GLboolean __GLEW_ARB_provoking_vertex;
+GLEW_VAR_EXPORT GLboolean __GLEW_ARB_sample_shading;
+GLEW_VAR_EXPORT GLboolean __GLEW_ARB_seamless_cube_map;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_objects;
+GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_texture_lod;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shading_language_100;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shadow;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shadow_ambient;
+GLEW_VAR_EXPORT GLboolean __GLEW_ARB_sync;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_border_clamp;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_buffer_object;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_compression;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_compression_rgtc;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_cube_map;
+GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_cube_map_array;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_add;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_combine;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_crossbar;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_dot3;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_float;
+GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_gather;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_mirrored_repeat;
+GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_multisample;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_non_power_of_two;
+GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_query_lod;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_rectangle;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_rg;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_transpose_matrix;
+GLEW_VAR_EXPORT GLboolean __GLEW_ARB_uniform_buffer_object;
+GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_array_bgra;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_array_object;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_blend;
 GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_buffer_object;
@@ -11938,6 +13034,7 @@ GLEW_VAR_EXPORT GLboolean __GLEW_ATI_element_array;
 GLEW_VAR_EXPORT GLboolean __GLEW_ATI_envmap_bumpmap;
 GLEW_VAR_EXPORT GLboolean __GLEW_ATI_fragment_shader;
 GLEW_VAR_EXPORT GLboolean __GLEW_ATI_map_object_buffer;
+GLEW_VAR_EXPORT GLboolean __GLEW_ATI_meminfo;
 GLEW_VAR_EXPORT GLboolean __GLEW_ATI_pn_triangles;
 GLEW_VAR_EXPORT GLboolean __GLEW_ATI_separate_stencil;
 GLEW_VAR_EXPORT GLboolean __GLEW_ATI_shader_texture_lod;
@@ -12000,9 +13097,11 @@ GLEW_VAR_EXPORT GLboolean __GLEW_EXT_pixel_transform;
 GLEW_VAR_EXPORT GLboolean __GLEW_EXT_pixel_transform_color_table;
 GLEW_VAR_EXPORT GLboolean __GLEW_EXT_point_parameters;
 GLEW_VAR_EXPORT GLboolean __GLEW_EXT_polygon_offset;
+GLEW_VAR_EXPORT GLboolean __GLEW_EXT_provoking_vertex;
 GLEW_VAR_EXPORT GLboolean __GLEW_EXT_rescale_normal;
 GLEW_VAR_EXPORT GLboolean __GLEW_EXT_scene_marker;
 GLEW_VAR_EXPORT GLboolean __GLEW_EXT_secondary_color;
+GLEW_VAR_EXPORT GLboolean __GLEW_EXT_separate_shader_objects;
 GLEW_VAR_EXPORT GLboolean __GLEW_EXT_separate_specular_color;
 GLEW_VAR_EXPORT GLboolean __GLEW_EXT_shadow_funcs;
 GLEW_VAR_EXPORT GLboolean __GLEW_EXT_shared_texture_palette;
@@ -12033,6 +13132,7 @@ GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_perturb_normal;
 GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_rectangle;
 GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_sRGB;
 GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_shared_exponent;
+GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_snorm;
 GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_swizzle;
 GLEW_VAR_EXPORT GLboolean __GLEW_EXT_timer_query;
 GLEW_VAR_EXPORT GLboolean __GLEW_EXT_transform_feedback;
@@ -12065,6 +13165,7 @@ GLEW_VAR_EXPORT GLboolean __GLEW_MESA_ycbcr_texture;
 GLEW_VAR_EXPORT GLboolean __GLEW_NV_blend_square;
 GLEW_VAR_EXPORT GLboolean __GLEW_NV_conditional_render;
 GLEW_VAR_EXPORT GLboolean __GLEW_NV_copy_depth_to_color;
+GLEW_VAR_EXPORT GLboolean __GLEW_NV_copy_image;
 GLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_buffer_float;
 GLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_clamp;
 GLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_range_unclamped;
@@ -12087,14 +13188,17 @@ GLEW_VAR_EXPORT GLboolean __GLEW_NV_multisample_filter_hint;
 GLEW_VAR_EXPORT GLboolean __GLEW_NV_occlusion_query;
 GLEW_VAR_EXPORT GLboolean __GLEW_NV_packed_depth_stencil;
 GLEW_VAR_EXPORT GLboolean __GLEW_NV_parameter_buffer_object;
+GLEW_VAR_EXPORT GLboolean __GLEW_NV_parameter_buffer_object2;
 GLEW_VAR_EXPORT GLboolean __GLEW_NV_pixel_data_range;
 GLEW_VAR_EXPORT GLboolean __GLEW_NV_point_sprite;
 GLEW_VAR_EXPORT GLboolean __GLEW_NV_present_video;
 GLEW_VAR_EXPORT GLboolean __GLEW_NV_primitive_restart;
 GLEW_VAR_EXPORT GLboolean __GLEW_NV_register_combiners;
 GLEW_VAR_EXPORT GLboolean __GLEW_NV_register_combiners2;
+GLEW_VAR_EXPORT GLboolean __GLEW_NV_shader_buffer_load;
 GLEW_VAR_EXPORT GLboolean __GLEW_NV_texgen_emboss;
 GLEW_VAR_EXPORT GLboolean __GLEW_NV_texgen_reflection;
+GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_barrier;
 GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_compression_vtc;
 GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_env_combine4;
 GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_expand_normal;
@@ -12103,8 +13207,10 @@ GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader;
 GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader2;
 GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader3;
 GLEW_VAR_EXPORT GLboolean __GLEW_NV_transform_feedback;
+GLEW_VAR_EXPORT GLboolean __GLEW_NV_transform_feedback2;
 GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_array_range;
 GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_array_range2;
+GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_buffer_unified_memory;
 GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program;
 GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program1_1;
 GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program2;
@@ -12244,6 +13350,7 @@ GLEWAPI const GLubyte* glewGetString (GLenum name);
 #undef GLEW_APIENTRY_DEFINED
 #undef APIENTRY
 #undef GLAPIENTRY
+#define GLAPIENTRY
 #endif
 
 #ifdef GLEW_CALLBACK_DEFINED
index 24e6c5dc80bef7df3ccbebb7bde6683392ecc94b..473b22aea6321e1488e6cc4592f46cb1f9f91e29 100644 (file)
@@ -29,9 +29,9 @@ extern "C" {
 */
 
 /* Header file version number, required by OpenGL ABI for Linux */
-/* glext.h last updated $Date: 2009-08-03 02:13:51 -0700 (Mon, 03 Aug 2009) $ */
+/* glext.h last updated $Date: 2009-09-24 13:55:03 -0700 (Thu, 24 Sep 2009) $ */
 /* Current version at http://www.opengl.org/registry/ */
-#define GL_GLEXT_VERSION 54
+#define GL_GLEXT_VERSION 56
 
 /* Function declaration macros - to move into glplatform.h */
 
@@ -4236,7 +4236,7 @@ extern "C" {
 #define GL_LUMINANCE16_SNORM              0x9019
 #define GL_LUMINANCE16_ALPHA16_SNORM      0x901A
 #define GL_INTENSITY16_SNORM              0x901B
-/* reuse GL_R_SNORM */
+/* reuse GL_RED_SNORM */
 /* reuse GL_RG_SNORM */
 /* reuse GL_RGB_SNORM */
 /* reuse GL_RGBA_SNORM */
@@ -4311,6 +4311,88 @@ extern "C" {
 #define GL_UNPACK_ROW_BYTES_APPLE         0x8A16
 #endif
 
+#ifndef GL_APPLE_rgb_422
+#define GL_RGB_422_APPLE                  0x8A1F
+/* reuse GL_UNSIGNED_SHORT_8_8_APPLE */
+/* reuse GL_UNSIGNED_SHORT_8_8_REV_APPLE */
+#endif
+
+#ifndef GL_NV_video_capture
+#define GL_VIDEO_BUFFER_NV                0x9020
+#define GL_VIDEO_BUFFER_BINDING_NV        0x9021
+#define GL_FIELD_UPPER_NV                 0x9022
+#define GL_FIELD_LOWER_NV                 0x9023
+#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV   0x9024
+#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025
+#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026
+#define GL_LAST_VIDEO_CAPTURE_STATUS_NV   0x9027
+#define GL_VIDEO_BUFFER_PITCH_NV          0x9028
+#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029
+#define GL_VIDEO_COLOR_CONVERSION_MAX_NV  0x902A
+#define GL_VIDEO_COLOR_CONVERSION_MIN_NV  0x902B
+#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C
+#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D
+#define GL_PARTIAL_SUCCESS_NV             0x902E
+#define GL_SUCCESS_NV                     0x902F
+#define GL_FAILURE_NV                     0x9030
+#define GL_YCBYCR8_422_NV                 0x9031
+#define GL_YCBAYCR8A_4224_NV              0x9032
+#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV  0x9033
+#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034
+#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV  0x9035
+#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036
+#define GL_Z4Y12Z4CB12Z4CR12_444_NV       0x9037
+#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV   0x9038
+#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV  0x9039
+#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A
+#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B
+#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C
+#endif
+
+#ifndef GL_NV_copy_image
+#endif
+
+#ifndef GL_EXT_separate_shader_objects
+#define GL_ACTIVE_PROGRAM_EXT             0x8B8D
+#endif
+
+#ifndef GL_NV_parameter_buffer_object2
+#endif
+
+#ifndef GL_NV_shader_buffer_load
+#define GL_BUFFER_GPU_ADDRESS_NV          0x8F1D
+#define GL_GPU_ADDRESS_NV                 0x8F34
+#define GL_MAX_SHADER_BUFFER_ADDRESS_NV   0x8F35
+#endif
+
+#ifndef GL_NV_vertex_buffer_unified_memory
+#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E
+#define GL_ELEMENT_ARRAY_UNIFIED_NV       0x8F1F
+#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20
+#define GL_VERTEX_ARRAY_ADDRESS_NV        0x8F21
+#define GL_NORMAL_ARRAY_ADDRESS_NV        0x8F22
+#define GL_COLOR_ARRAY_ADDRESS_NV         0x8F23
+#define GL_INDEX_ARRAY_ADDRESS_NV         0x8F24
+#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25
+#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV     0x8F26
+#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27
+#define GL_FOG_COORD_ARRAY_ADDRESS_NV     0x8F28
+#define GL_ELEMENT_ARRAY_ADDRESS_NV       0x8F29
+#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV  0x8F2A
+#define GL_VERTEX_ARRAY_LENGTH_NV         0x8F2B
+#define GL_NORMAL_ARRAY_LENGTH_NV         0x8F2C
+#define GL_COLOR_ARRAY_LENGTH_NV          0x8F2D
+#define GL_INDEX_ARRAY_LENGTH_NV          0x8F2E
+#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV  0x8F2F
+#define GL_EDGE_FLAG_ARRAY_LENGTH_NV      0x8F30
+#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31
+#define GL_FOG_COORD_ARRAY_LENGTH_NV      0x8F32
+#define GL_ELEMENT_ARRAY_LENGTH_NV        0x8F33
+#endif
+
+#ifndef GL_NV_texture_barrier
+#endif
+
 
 /*************************************************************/
 
@@ -9245,6 +9327,136 @@ typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType,
 #define GL_APPLE_row_bytes 1
 #endif
 
+#ifndef GL_APPLE_rgb_422
+#define GL_APPLE_rgb_422 1
+#endif
+
+#ifndef GL_NV_video_capture
+#define GL_NV_video_capture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBeginVideoCaptureNV (GLuint);
+GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint, GLuint, GLenum, GLintptrARB);
+GLAPI void APIENTRY glBindVideoCaptureStreamTextureNV (GLuint, GLuint, GLenum, GLenum, GLuint);
+GLAPI void APIENTRY glEndVideoCaptureNV (GLuint);
+GLAPI void APIENTRY glGetVideoCaptureivNV (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetVideoCaptureStreamivNV (GLuint, GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetVideoCaptureStreamfvNV (GLuint, GLuint, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetVideoCaptureStreamdvNV (GLuint, GLuint, GLenum, GLdouble *);
+GLAPI GLenum APIENTRY glVideoCaptureNV (GLuint, GLuint *, GLuint64EXT *);
+GLAPI void APIENTRY glVideoCaptureStreamParameterivNV (GLuint, GLuint, GLenum, const GLint *);
+GLAPI void APIENTRY glVideoCaptureStreamParameterfvNV (GLuint, GLuint, GLenum, const GLfloat *);
+GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint, GLuint, GLenum, const GLdouble *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot);
+typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset);
+typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture);
+typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot);
+typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params);
+typedef GLenum (APIENTRYP PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time);
+typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params);
+#endif
+
+#ifndef GL_NV_copy_image
+#define GL_NV_copy_image 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glCopyImageSubDataNV (GLuint, GLenum, GLint, GLint, GLint, GLint, GLuint, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
+#endif
+
+#ifndef GL_EXT_separate_shader_objects
+#define GL_EXT_separate_shader_objects 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glUseShaderProgramEXT (GLenum, GLuint);
+GLAPI void APIENTRY glActiveProgramEXT (GLuint);
+GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum, const GLchar *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program);
+typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program);
+typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string);
+#endif
+
+#ifndef GL_NV_parameter_buffer_object2
+#define GL_NV_parameter_buffer_object2 1
+#endif
+
+#ifndef GL_NV_shader_buffer_load
+#define GL_NV_shader_buffer_load 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glMakeBufferResidentNV (GLenum, GLenum);
+GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum);
+GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum);
+GLAPI void APIENTRY glNamedMakeBufferResidentNV (GLuint, GLenum);
+GLAPI void APIENTRY glNamedMakeBufferNonResidentNV (GLuint);
+GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint);
+GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum, GLenum, GLuint64EXT *);
+GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint, GLenum, GLuint64EXT *);
+GLAPI void APIENTRY glGetIntegerui64vNV (GLenum, GLuint64EXT *);
+GLAPI void APIENTRY glUniformui64NV (GLint, GLuint64EXT);
+GLAPI void APIENTRY glUniformui64vNV (GLint, GLsizei, const GLuint64EXT *);
+GLAPI void APIENTRY glGetUniformui64vNV (GLuint, GLint, GLuint64EXT *);
+GLAPI void APIENTRY glProgramUniformui64NV (GLuint, GLint, GLuint64EXT);
+GLAPI void APIENTRY glProgramUniformui64vNV (GLuint, GLint, GLsizei, const GLuint64EXT *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access);
+typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target);
+typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLNAMEDMAKEBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access);
+typedef void (APIENTRYP PFNGLNAMEDMAKEBUFFERNONRESIDENTNVPROC) (GLuint buffer);
+typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer);
+typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params);
+typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params);
+typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result);
+typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value);
+typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value);
+typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
+#endif
+
+#ifndef GL_NV_vertex_buffer_unified_memory
+#define GL_NV_vertex_buffer_unified_memory 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBufferAddressRangeNV (GLenum, GLuint, GLuint64EXT, GLsizeiptr);
+GLAPI void APIENTRY glVertexFormatNV (GLint, GLenum, GLsizei);
+GLAPI void APIENTRY glNormalFormatNV (GLenum, GLsizei);
+GLAPI void APIENTRY glColorFormatNV (GLint, GLenum, GLsizei);
+GLAPI void APIENTRY glIndexFormatNV (GLenum, GLsizei);
+GLAPI void APIENTRY glTexCoordFormatNV (GLint, GLenum, GLsizei);
+GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei);
+GLAPI void APIENTRY glSecondaryColorFormatNV (GLint, GLenum, GLsizei);
+GLAPI void APIENTRY glFogCoordFormatNV (GLenum, GLsizei);
+GLAPI void APIENTRY glVertexAttribFormatNV (GLuint, GLint, GLenum, GLboolean, GLsizei);
+GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint, GLint, GLenum, GLsizei);
+GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum, GLuint, GLuint64EXT *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length);
+typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);
+typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride);
+typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);
+typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride);
+typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);
+typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride);
+typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);
+typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride);
+typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result);
+#endif
+
+#ifndef GL_NV_texture_barrier
+#define GL_NV_texture_barrier 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTextureBarrierNV (void);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void);
+#endif
+
 
 #ifdef __cplusplus
 }
index 9fdb9cfdfa976adb3fee0db777fa2d5166c852bd..d9fc938dc7a357007d2eaba31fca4823e11e4ab0 100644 (file)
@@ -452,8 +452,7 @@ GLUTAPI void GLUTAPIENTRY glutInit(int *argcp, char **argv);
 #if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK)
 GLUTAPI void GLUTAPIENTRY __glutInitWithExit(int *argcp, char **argv, void (__cdecl *exitfunc)(int));
 #ifndef GLUT_BUILDING_LIB
-static void GLUTAPIENTRY glutInit_ATEXIT_HACK(int *argcp, char **argv) { __glutInitWithExit(argcp, argv, exit); }
-#define glutInit glutInit_ATEXIT_HACK
+#define glutInit(__argcp, __argv) __glutInitWithExit(__argcp, __argv, exit)
 #endif
 #endif
 GLUTAPI void GLUTAPIENTRY glutInitDisplayMode(unsigned int mode);
@@ -469,8 +468,7 @@ GLUTAPI int GLUTAPIENTRY glutCreateWindow(const char *title);
 #if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK)
 GLUTAPI int GLUTAPIENTRY __glutCreateWindowWithExit(const char *title, void (__cdecl *exitfunc)(int));
 #ifndef GLUT_BUILDING_LIB
-static int GLUTAPIENTRY glutCreateWindow_ATEXIT_HACK(const char *title) { return __glutCreateWindowWithExit(title, exit); }
-#define glutCreateWindow glutCreateWindow_ATEXIT_HACK
+#define glutCreateWindow(__title) __glutCreateWindowWithExit(__title, exit)
 #endif
 #endif
 GLUTAPI int GLUTAPIENTRY glutCreateSubWindow(int win, int x, int y, int width, int height);
@@ -515,8 +513,7 @@ GLUTAPI int GLUTAPIENTRY glutCreateMenu(void (GLUTCALLBACK *func)(int));
 #if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK)
 GLUTAPI int GLUTAPIENTRY __glutCreateMenuWithExit(void (GLUTCALLBACK *func)(int), void (__cdecl *exitfunc)(int));
 #ifndef GLUT_BUILDING_LIB
-static int GLUTAPIENTRY glutCreateMenu_ATEXIT_HACK(void (GLUTCALLBACK *func)(int)) { return __glutCreateMenuWithExit(func, exit); }
-#define glutCreateMenu glutCreateMenu_ATEXIT_HACK
+#define glutCreateMenu(__func) __glutCreateMenuWithExit(__func, exit)
 #endif
 #endif
 GLUTAPI void GLUTAPIENTRY glutDestroyMenu(int menu);
index 4439a96b5d2e98fa8ea5babc94d31bfe9074a8c2..fa664a7f59e1b0baabd911bf072732ab2d69a588 100644 (file)
@@ -76,6 +76,7 @@
 
 /* GLX 1.4 */
 #define glXGetProcAddress mglXGetProcAddress
+#define glXGetProcAddressARB mglXGetProcAddressARB
 
 
 #endif
index a29030da3cbeb435ceb66f488315621a74913954..f19e573f84d31d6d485e710a400774253934518b 100644 (file)
@@ -362,6 +362,19 @@ typedef GLXContext ( * PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display* dpy, GLXFBCo
 
 #endif /* GLX_ARB_create_context */
 
+/* --------------------- GLX_ARB_create_context_profile -------------------- */
+
+#ifndef GLX_ARB_create_context_profile
+#define GLX_ARB_create_context_profile 1
+
+#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
+#define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
+#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126
+
+#define GLXEW_ARB_create_context_profile GLXEW_GET_VAR(__GLXEW_ARB_create_context_profile)
+
+#endif /* GLX_ARB_create_context_profile */
+
 /* ------------------------- GLX_ARB_fbconfig_float ------------------------ */
 
 #ifndef GLX_ARB_fbconfig_float
@@ -529,6 +542,22 @@ typedef int ( * PFNGLXQUERYCONTEXTINFOEXTPROC) (Display* dpy, GLXContext context
 
 #endif /* GLX_EXT_scene_marker */
 
+/* -------------------------- GLX_EXT_swap_control ------------------------- */
+
+#ifndef GLX_EXT_swap_control
+#define GLX_EXT_swap_control 1
+
+#define GLX_SWAP_INTERVAL_EXT 0x20F1
+#define GLX_MAX_SWAP_INTERVAL_EXT 0x20F2
+
+typedef void ( * PFNGLXSWAPINTERVALEXTPROC) (Display* dpy, GLXDrawable drawable, int interval);
+
+#define glXSwapIntervalEXT GLXEW_GET_FUN(__glewXSwapIntervalEXT)
+
+#define GLXEW_EXT_swap_control GLXEW_GET_VAR(__GLXEW_EXT_swap_control)
+
+#endif /* GLX_EXT_swap_control */
+
 /* ---------------------- GLX_EXT_texture_from_pixmap ---------------------- */
 
 #ifndef GLX_EXT_texture_from_pixmap
@@ -683,6 +712,19 @@ typedef GLboolean ( * PFNGLXSET3DFXMODEMESAPROC) (GLint mode);
 
 #endif /* GLX_MESA_set_3dfx_mode */
 
+/* --------------------------- GLX_NV_copy_image --------------------------- */
+
+#ifndef GLX_NV_copy_image
+#define GLX_NV_copy_image 1
+
+typedef void ( * PFNGLXCOPYIMAGESUBDATANVPROC) (Display *dpy, GLXContext srcCtx, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLXContext dstCtx, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
+
+#define glXCopyImageSubDataNV GLXEW_GET_FUN(__glewXCopyImageSubDataNV)
+
+#define GLXEW_NV_copy_image GLXEW_GET_VAR(__GLXEW_NV_copy_image)
+
+#endif /* GLX_NV_copy_image */
+
 /* -------------------------- GLX_NV_float_buffer -------------------------- */
 
 #ifndef GLX_NV_float_buffer
@@ -1217,6 +1259,8 @@ extern PFNGLXGETCONTEXTIDEXTPROC __glewXGetContextIDEXT;
 extern PFNGLXIMPORTCONTEXTEXTPROC __glewXImportContextEXT;
 extern PFNGLXQUERYCONTEXTINFOEXTPROC __glewXQueryContextInfoEXT;
 
+extern PFNGLXSWAPINTERVALEXTPROC __glewXSwapIntervalEXT;
+
 extern PFNGLXBINDTEXIMAGEEXTPROC __glewXBindTexImageEXT;
 extern PFNGLXRELEASETEXIMAGEEXTPROC __glewXReleaseTexImageEXT;
 
@@ -1230,6 +1274,8 @@ extern PFNGLXRELEASEBUFFERSMESAPROC __glewXReleaseBuffersMESA;
 
 extern PFNGLXSET3DFXMODEMESAPROC __glewXSet3DfxModeMESA;
 
+extern PFNGLXCOPYIMAGESUBDATANVPROC __glewXCopyImageSubDataNV;
+
 extern PFNGLXBINDVIDEODEVICENVPROC __glewXBindVideoDeviceNV;
 extern PFNGLXENUMERATEVIDEODEVICESNVPROC __glewXEnumerateVideoDevicesNV;
 
@@ -1318,6 +1364,7 @@ GLXEW_EXPORT GLboolean __GLXEW_VERSION_1_3;
 GLXEW_EXPORT GLboolean __GLXEW_VERSION_1_4;
 GLXEW_EXPORT GLboolean __GLXEW_3DFX_multisample;
 GLXEW_EXPORT GLboolean __GLXEW_ARB_create_context;
+GLXEW_EXPORT GLboolean __GLXEW_ARB_create_context_profile;
 GLXEW_EXPORT GLboolean __GLXEW_ARB_fbconfig_float;
 GLXEW_EXPORT GLboolean __GLXEW_ARB_framebuffer_sRGB;
 GLXEW_EXPORT GLboolean __GLXEW_ARB_get_proc_address;
@@ -1328,6 +1375,7 @@ GLXEW_EXPORT GLboolean __GLXEW_EXT_fbconfig_packed_float;
 GLXEW_EXPORT GLboolean __GLXEW_EXT_framebuffer_sRGB;
 GLXEW_EXPORT GLboolean __GLXEW_EXT_import_context;
 GLXEW_EXPORT GLboolean __GLXEW_EXT_scene_marker;
+GLXEW_EXPORT GLboolean __GLXEW_EXT_swap_control;
 GLXEW_EXPORT GLboolean __GLXEW_EXT_texture_from_pixmap;
 GLXEW_EXPORT GLboolean __GLXEW_EXT_visual_info;
 GLXEW_EXPORT GLboolean __GLXEW_EXT_visual_rating;
@@ -1336,6 +1384,7 @@ GLXEW_EXPORT GLboolean __GLXEW_MESA_copy_sub_buffer;
 GLXEW_EXPORT GLboolean __GLXEW_MESA_pixmap_colormap;
 GLXEW_EXPORT GLboolean __GLXEW_MESA_release_buffers;
 GLXEW_EXPORT GLboolean __GLXEW_MESA_set_3dfx_mode;
+GLXEW_EXPORT GLboolean __GLXEW_NV_copy_image;
 GLXEW_EXPORT GLboolean __GLXEW_NV_float_buffer;
 GLXEW_EXPORT GLboolean __GLXEW_NV_present_video;
 GLXEW_EXPORT GLboolean __GLXEW_NV_swap_group;
index eac09f94fa3ae359888315899440031bc3cf27b2..9ac0592e0533edf097682a6fc204f8f31a62bbe5 100644 (file)
@@ -48,9 +48,9 @@ extern "C" {
 /*************************************************************/
 
 /* Header file version number, required by OpenGL ABI for Linux */
-/* glxext.h last updated 2009/08/03 */
+/* glxext.h last updated 2009/10/08 */
 /* Current version at http://www.opengl.org/registry/ */
-#define GLX_GLXEXT_VERSION 23
+#define GLX_GLXEXT_VERSION 25
 
 #ifndef GLX_VERSION_1_3
 #define GLX_WINDOW_BIT                     0x00000001
@@ -382,6 +382,20 @@ extern "C" {
 #ifndef GLX_NV_swap_group
 #endif
 
+#ifndef GLX_NV_video_capture
+#define GLX_DEVICE_ID_NV                   0x20CD
+#define GLX_UNIQUE_ID_NV                   0x20CE
+#define GLX_NUM_VIDEO_CAPTURE_SLOTS_NV     0x20CF
+#endif
+
+#ifndef GLX_EXT_swap_control
+#define GLX_SWAP_INTERVAL_EXT              0x20F1
+#define GLX_MAX_SWAP_INTERVAL_EXT          0x20F2
+#endif
+
+#ifndef GLX_NV_copy_image
+#endif
+
 
 /*************************************************************/
 
@@ -415,6 +429,14 @@ typedef struct {
 } GLXBufferClobberEventSGIX;
 #endif
 
+#ifndef GLX_NV_video_output
+typedef unsigned int GLXVideoDeviceNV;
+#endif
+
+#ifndef GLX_NV_video_capture
+typedef XID GLXVideoCaptureDeviceNV;
+#endif
+
 #ifndef GLEXT_64_TYPES_DEFINED
 /* This code block is duplicated in glext.h, so must be protected */
 #define GLEXT_64_TYPES_DEFINED
@@ -827,14 +849,80 @@ typedef void ( * PFNGLXRELEASETEXIMAGEEXTPROC) (Display *dpy, GLXDrawable drawab
 
 #ifndef GLX_NV_present_video
 #define GLX_NV_present_video 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern unsigned int * glXEnumerateVideoDevicesNV (Display *, int, int *);
+extern int glXBindVideoDeviceNV (Display *, unsigned int, unsigned int, const int *);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef unsigned int * ( * PFNGLXENUMERATEVIDEODEVICESNVPROC) (Display *dpy, int screen, int *nelements);
+typedef int ( * PFNGLXBINDVIDEODEVICENVPROC) (Display *dpy, unsigned int video_slot, unsigned int video_device, const int *attrib_list);
 #endif
 
-#ifndef GLX_NV_video_out
-#define GLX_NV_video_out 1
+#ifndef GLX_NV_video_output
+#define GLX_NV_video_output 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern int glXGetVideoDeviceNV (Display *, int, int, GLXVideoDeviceNV *);
+extern int glXReleaseVideoDeviceNV (Display *, int, GLXVideoDeviceNV);
+extern int glXBindVideoImageNV (Display *, GLXVideoDeviceNV, GLXPbuffer, int);
+extern int glXReleaseVideoImageNV (Display *, GLXPbuffer);
+extern int glXSendPbufferToVideoNV (Display *, GLXPbuffer, int, unsigned long *, GLboolean);
+extern int glXGetVideoInfoNV (Display *, int, GLXVideoDeviceNV, unsigned long *, unsigned long *);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef int ( * PFNGLXGETVIDEODEVICENVPROC) (Display *dpy, int screen, int numVideoDevices, GLXVideoDeviceNV *pVideoDevice);
+typedef int ( * PFNGLXRELEASEVIDEODEVICENVPROC) (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice);
+typedef int ( * PFNGLXBINDVIDEOIMAGENVPROC) (Display *dpy, GLXVideoDeviceNV VideoDevice, GLXPbuffer pbuf, int iVideoBuffer);
+typedef int ( * PFNGLXRELEASEVIDEOIMAGENVPROC) (Display *dpy, GLXPbuffer pbuf);
+typedef int ( * PFNGLXSENDPBUFFERTOVIDEONVPROC) (Display *dpy, GLXPbuffer pbuf, int iBufferType, unsigned long *pulCounterPbuffer, GLboolean bBlock);
+typedef int ( * PFNGLXGETVIDEOINFONVPROC) (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);
 #endif
 
 #ifndef GLX_NV_swap_group
 #define GLX_NV_swap_group 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern Bool glXJoinSwapGroupNV (Display *, GLXDrawable, GLuint);
+extern Bool glXBindSwapBarrierNV (Display *, GLuint, GLuint);
+extern Bool glXQuerySwapGroupNV (Display *, GLXDrawable, GLuint *, GLuint *);
+extern Bool glXQueryMaxSwapGroupsNV (Display *, int, GLuint *, GLuint *);
+extern Bool glXQueryFrameCountNV (Display *, int, GLuint *);
+extern Bool glXResetFrameCountNV (Display *, int);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef Bool ( * PFNGLXJOINSWAPGROUPNVPROC) (Display *dpy, GLXDrawable drawable, GLuint group);
+typedef Bool ( * PFNGLXBINDSWAPBARRIERNVPROC) (Display *dpy, GLuint group, GLuint barrier);
+typedef Bool ( * PFNGLXQUERYSWAPGROUPNVPROC) (Display *dpy, GLXDrawable drawable, GLuint *group, GLuint *barrier);
+typedef Bool ( * PFNGLXQUERYMAXSWAPGROUPSNVPROC) (Display *dpy, int screen, GLuint *maxGroups, GLuint *maxBarriers);
+typedef Bool ( * PFNGLXQUERYFRAMECOUNTNVPROC) (Display *dpy, int screen, GLuint *count);
+typedef Bool ( * PFNGLXRESETFRAMECOUNTNVPROC) (Display *dpy, int screen);
+#endif
+
+#ifndef GLX_NV_video_capture
+#define GLX_NV_video_capture 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern int glXBindVideoCaptureDeviceNV (Display *, unsigned int, GLXVideoCaptureDeviceNV);
+extern GLXVideoCaptureDeviceNV * glXEnumerateVideoCaptureDevicesNV (Display *, int, int *);
+extern void glXLockVideoCaptureDeviceNV (Display *, GLXVideoCaptureDeviceNV);
+extern int glXQueryVideoCaptureDeviceNV (Display *, GLXVideoCaptureDeviceNV, int, int *);
+extern void glXReleaseVideoCaptureDeviceNV (Display *, GLXVideoCaptureDeviceNV);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef int ( * PFNGLXBINDVIDEOCAPTUREDEVICENVPROC) (Display *dpy, unsigned int video_capture_slot, GLXVideoCaptureDeviceNV device);
+typedef GLXVideoCaptureDeviceNV * ( * PFNGLXENUMERATEVIDEOCAPTUREDEVICESNVPROC) (Display *dpy, int screen, int *nelements);
+typedef void ( * PFNGLXLOCKVIDEOCAPTUREDEVICENVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device);
+typedef int ( * PFNGLXQUERYVIDEOCAPTUREDEVICENVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device, int attribute, int *value);
+typedef void ( * PFNGLXRELEASEVIDEOCAPTUREDEVICENVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device);
+#endif
+
+#ifndef GLX_EXT_swap_control
+#define GLX_EXT_swap_control 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern int glXSwapIntervalEXT (Display *, GLXDrawable, int);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef int ( * PFNGLXSWAPINTERVALEXTPROC) (Display *dpy, GLXDrawable drawable, int interval);
+#endif
+
+#ifndef GLX_NV_copy_image
+#define GLX_NV_copy_image 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern void glXCopyImageSubDataNV (Display *, GLXContext, GLuint, GLenum, GLint, GLint, GLint, GLint, GLXContext, GLuint, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef void ( * PFNGLXCOPYIMAGESUBDATANVPROC) (Display *dpy, GLXContext srcCtx, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLXContext dstCtx, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
 #endif
 
 
index 2eaad3651acfeb06cbd5ff6ca218e9fb7afab7a1..7c7a3804794cbe861bbaefe67a2d01a4f965c14a 100644 (file)
 
 #define __wglext_h_
 
-#if !defined(APIENTRY) && !defined(__CYGWIN__)
+#if !defined(WINAPI)
 #  ifndef WIN32_LEAN_AND_MEAN
 #    define WIN32_LEAN_AND_MEAN 1
 #  endif
 #include <windows.h>
+#  undef WIN32_LEAN_AND_MEAN
 #endif
 
 /*
@@ -117,6 +118,46 @@ typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState
 
 #endif /* WGL_3DL_stereo_control */
 
+/* ------------------------ WGL_AMD_gpu_association ------------------------ */
+
+#ifndef WGL_AMD_gpu_association
+#define WGL_AMD_gpu_association 1
+
+#define WGL_GPU_VENDOR_AMD 0x1F00
+#define WGL_GPU_RENDERER_STRING_AMD 0x1F01
+#define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02
+#define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2
+#define WGL_GPU_RAM_AMD 0x21A3
+#define WGL_GPU_CLOCK_AMD 0x21A4
+#define WGL_GPU_NUM_PIPES_AMD 0x21A5
+#define WGL_GPU_NUM_SIMD_AMD 0x21A6
+#define WGL_GPU_NUM_RB_AMD 0x21A7
+#define WGL_GPU_NUM_SPI_AMD 0x21A8
+
+typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id);
+typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int* attribList);
+typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc);
+typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc);
+typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void);
+typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT* ids);
+typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, INT property, GLenum dataType, UINT size, void* data);
+typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc);
+
+#define wglBlitContextFramebufferAMD WGLEW_GET_FUN(__wglewBlitContextFramebufferAMD)
+#define wglCreateAssociatedContextAMD WGLEW_GET_FUN(__wglewCreateAssociatedContextAMD)
+#define wglCreateAssociatedContextAttribsAMD WGLEW_GET_FUN(__wglewCreateAssociatedContextAttribsAMD)
+#define wglDeleteAssociatedContextAMD WGLEW_GET_FUN(__wglewDeleteAssociatedContextAMD)
+#define wglGetContextGPUIDAMD WGLEW_GET_FUN(__wglewGetContextGPUIDAMD)
+#define wglGetCurrentAssociatedContextAMD WGLEW_GET_FUN(__wglewGetCurrentAssociatedContextAMD)
+#define wglGetGPUIDsAMD WGLEW_GET_FUN(__wglewGetGPUIDsAMD)
+#define wglGetGPUInfoAMD WGLEW_GET_FUN(__wglewGetGPUInfoAMD)
+#define wglMakeAssociatedContextCurrentAMD WGLEW_GET_FUN(__wglewMakeAssociatedContextCurrentAMD)
+
+#define WGLEW_AMD_gpu_association WGLEW_GET_VAR(__WGLEW_AMD_gpu_association)
+
+#endif /* WGL_AMD_gpu_association */
+
 /* ------------------------- WGL_ARB_buffer_region ------------------------- */
 
 #ifndef WGL_ARB_buffer_region
@@ -161,6 +202,19 @@ typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShar
 
 #endif /* WGL_ARB_create_context */
 
+/* --------------------- WGL_ARB_create_context_profile -------------------- */
+
+#ifndef WGL_ARB_create_context_profile
+#define WGL_ARB_create_context_profile 1
+
+#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
+#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
+#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
+
+#define WGLEW_ARB_create_context_profile WGLEW_GET_VAR(__WGLEW_ARB_create_context_profile)
+
+#endif /* WGL_ARB_create_context_profile */
+
 /* ----------------------- WGL_ARB_extensions_string ----------------------- */
 
 #ifndef WGL_ARB_extensions_string
@@ -752,6 +806,19 @@ typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD* pFrameCount, DWO
 
 #endif /* WGL_I3D_swap_frame_usage */
 
+/* --------------------------- WGL_NV_copy_image --------------------------- */
+
+#ifndef WGL_NV_copy_image
+#define WGL_NV_copy_image 1
+
+typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
+
+#define wglCopyImageSubDataNV WGLEW_GET_FUN(__wglewCopyImageSubDataNV)
+
+#define WGLEW_NV_copy_image WGLEW_GET_VAR(__WGLEW_NV_copy_image)
+
+#endif /* WGL_NV_copy_image */
+
 /* -------------------------- WGL_NV_float_buffer -------------------------- */
 
 #ifndef WGL_NV_float_buffer
@@ -863,7 +930,7 @@ typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrie
 typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group);
 typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint* count);
 typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint* maxGroups, GLuint *maxBarriers);
-typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint* group);
+typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint* group, GLuint *barrier);
 typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC);
 
 #define wglBindSwapBarrierNV WGLEW_GET_FUN(__wglewBindSwapBarrierNV)
@@ -969,6 +1036,16 @@ struct WGLEWContextStruct
 
 WGLEW_EXPORT PFNWGLSETSTEREOEMITTERSTATE3DLPROC __wglewSetStereoEmitterState3DL;
 
+WGLEW_EXPORT PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC __wglewBlitContextFramebufferAMD;
+WGLEW_EXPORT PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC __wglewCreateAssociatedContextAMD;
+WGLEW_EXPORT PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC __wglewCreateAssociatedContextAttribsAMD;
+WGLEW_EXPORT PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC __wglewDeleteAssociatedContextAMD;
+WGLEW_EXPORT PFNWGLGETCONTEXTGPUIDAMDPROC __wglewGetContextGPUIDAMD;
+WGLEW_EXPORT PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC __wglewGetCurrentAssociatedContextAMD;
+WGLEW_EXPORT PFNWGLGETGPUIDSAMDPROC __wglewGetGPUIDsAMD;
+WGLEW_EXPORT PFNWGLGETGPUINFOAMDPROC __wglewGetGPUInfoAMD;
+WGLEW_EXPORT PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC __wglewMakeAssociatedContextCurrentAMD;
+
 WGLEW_EXPORT PFNWGLCREATEBUFFERREGIONARBPROC __wglewCreateBufferRegionARB;
 WGLEW_EXPORT PFNWGLDELETEBUFFERREGIONARBPROC __wglewDeleteBufferRegionARB;
 WGLEW_EXPORT PFNWGLRESTOREBUFFERREGIONARBPROC __wglewRestoreBufferRegionARB;
@@ -1054,6 +1131,8 @@ WGLEW_EXPORT PFNWGLENDFRAMETRACKINGI3DPROC __wglewEndFrameTrackingI3D;
 WGLEW_EXPORT PFNWGLGETFRAMEUSAGEI3DPROC __wglewGetFrameUsageI3D;
 WGLEW_EXPORT PFNWGLQUERYFRAMETRACKINGI3DPROC __wglewQueryFrameTrackingI3D;
 
+WGLEW_EXPORT PFNWGLCOPYIMAGESUBDATANVPROC __wglewCopyImageSubDataNV;
+
 WGLEW_EXPORT PFNWGLCREATEAFFINITYDCNVPROC __wglewCreateAffinityDCNV;
 WGLEW_EXPORT PFNWGLDELETEDCNVPROC __wglewDeleteDCNV;
 WGLEW_EXPORT PFNWGLENUMGPUDEVICESNVPROC __wglewEnumGpuDevicesNV;
@@ -1089,8 +1168,10 @@ WGLEW_EXPORT PFNWGLWAITFORMSCOMLPROC __wglewWaitForMscOML;
 WGLEW_EXPORT PFNWGLWAITFORSBCOMLPROC __wglewWaitForSbcOML;
 WGLEW_EXPORT GLboolean __WGLEW_3DFX_multisample;
 WGLEW_EXPORT GLboolean __WGLEW_3DL_stereo_control;
+WGLEW_EXPORT GLboolean __WGLEW_AMD_gpu_association;
 WGLEW_EXPORT GLboolean __WGLEW_ARB_buffer_region;
 WGLEW_EXPORT GLboolean __WGLEW_ARB_create_context;
+WGLEW_EXPORT GLboolean __WGLEW_ARB_create_context_profile;
 WGLEW_EXPORT GLboolean __WGLEW_ARB_extensions_string;
 WGLEW_EXPORT GLboolean __WGLEW_ARB_framebuffer_sRGB;
 WGLEW_EXPORT GLboolean __WGLEW_ARB_make_current_read;
@@ -1117,6 +1198,7 @@ WGLEW_EXPORT GLboolean __WGLEW_I3D_genlock;
 WGLEW_EXPORT GLboolean __WGLEW_I3D_image_buffer;
 WGLEW_EXPORT GLboolean __WGLEW_I3D_swap_frame_lock;
 WGLEW_EXPORT GLboolean __WGLEW_I3D_swap_frame_usage;
+WGLEW_EXPORT GLboolean __WGLEW_NV_copy_image;
 WGLEW_EXPORT GLboolean __WGLEW_NV_float_buffer;
 WGLEW_EXPORT GLboolean __WGLEW_NV_gpu_affinity;
 WGLEW_EXPORT GLboolean __WGLEW_NV_present_video;
index 1f096fb919360cf99c5c8d287c2cfb48fb979e5e..df96fbebb37fe49af38e8014bc6a8271865f9bdf 100644 (file)
@@ -48,9 +48,9 @@ extern "C" {
 /*************************************************************/
 
 /* Header file version number */
-/* wglext.h last updated 2009/08/03 */
+/* wglext.h last updated 2009/09/16 */
 /* Current version at http://www.opengl.org/registry/ */
-#define WGL_WGLEXT_VERSION 15
+#define WGL_WGLEXT_VERSION 17
 
 #ifndef WGL_ARB_buffer_region
 #define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001
@@ -388,6 +388,14 @@ extern "C" {
 #define WGL_GPU_NUM_SPI_AMD            0x21A8
 #endif
 
+#ifndef NV_video_capture
+#define WGL_UNIQUE_ID_NV               0x20CE
+#define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF
+#endif
+
+#ifndef NV_copy_image
+#endif
+
 
 /*************************************************************/
 
@@ -400,7 +408,7 @@ DECLARE_HANDLE(HPBUFFEREXT);
 #ifndef WGL_NV_present_video
 DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV);
 #endif
-#ifndef WGL_NV_video_out
+#ifndef WGL_NV_video_output
 DECLARE_HANDLE(HPVIDEODEV);
 #endif
 #ifndef WGL_NV_gpu_affinity
@@ -415,6 +423,9 @@ typedef struct _GPU_DEVICE {
     RECT   rcVirtualScreen;
 } GPU_DEVICE, *PGPU_DEVICE;
 #endif
+#ifndef WGL_NV_video_capture
+DECLARE_HANDLE(HVIDEOINPUTDEVICENV);
+#endif
 
 #ifndef WGL_ARB_buffer_region
 #define WGL_ARB_buffer_region 1
@@ -750,8 +761,8 @@ typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDC, unsigned int uVide
 typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue);
 #endif
 
-#ifndef WGL_NV_video_out
-#define WGL_NV_video_out 1
+#ifndef WGL_NV_video_output
+#define WGL_NV_video_output 1
 #ifdef WGL_WGLEXT_PROTOTYPES
 extern BOOL WINAPI wglGetVideoDeviceNV (HDC, int, HPVIDEODEV *);
 extern BOOL WINAPI wglReleaseVideoDeviceNV (HPVIDEODEV);
@@ -826,6 +837,30 @@ typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void);
 typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
 #endif
 
+#ifndef WGL_NV_video_capture
+#define WGL_NV_video_capture 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglBindVideoCaptureDeviceNV (UINT, HVIDEOINPUTDEVICENV);
+extern UINT WINAPI wglEnumerateVideoCaptureDevicesNV (HDC, HVIDEOINPUTDEVICENV *);
+extern BOOL WINAPI wglLockVideoCaptureDeviceNV (HDC, HVIDEOINPUTDEVICENV);
+extern BOOL WINAPI wglQueryVideoCaptureDeviceNV (HDC, HVIDEOINPUTDEVICENV, int, int *);
+extern BOOL WINAPI wglReleaseVideoCaptureDeviceNV (HDC, HVIDEOINPUTDEVICENV);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice);
+typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList);
+typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
+typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue);
+typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
+#endif
+
+#ifndef WGL_NV_copy_image
+#define WGL_NV_copy_image 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglCopyImageSubDataNV (HGLRC, GLuint, GLenum, GLint, GLint, GLint, GLint, HGLRC, GLuint, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
+#endif
+
 
 #ifdef __cplusplus
 }
diff --git a/progs/.gitignore b/progs/.gitignore
new file mode 100644 (file)
index 0000000..cb77d18
--- /dev/null
@@ -0,0 +1 @@
+*.dSYM
index c99f4eebcc1be56d27de779c55efab1c72acddef..5bc444e952425d52ca50038329688d6ba36ceb97 100644 (file)
@@ -15,7 +15,7 @@ message:
 
 
 subdirs:
-       @for dir in $(SUBDIRS) ; do \
+       @list='$(SUBDIRS)'; for dir in $$list ; do \
                if [ -d $$dir ] ; then \
                        (cd $$dir && $(MAKE)) || exit 1 ; \
                fi \
@@ -25,7 +25,7 @@ subdirs:
 install:
 
 clean:
-       -@for dir in $(SUBDIRS) tests ; do \
+       @list='$(SUBDIRS)'; for dir in $$list tests ; do \
                if [ -d $$dir ] ; then \
                        (cd $$dir && $(MAKE) clean) ; \
                fi \
index 66eaf9e54104678b8bed4a9775528b7e371200a7..3b180d00bc2396af24e44f8b63392422a379601d 100644 (file)
@@ -1,5 +1,43 @@
 SConscript([
     'util/SConscript',
+])
+
+Import('*')
+
+progs_env = env.Clone()
+
+if progs_env['platform'] == 'windows':
+    progs_env.Append(CPPDEFINES = ['NOMINMAX'])
+    progs_env.Prepend(LIBS = [
+        'winmm',
+        'kernel32',
+        'user32',
+        'gdi32',
+    ])
+
+# OpenGL
+if progs_env['platform'] == 'windows':
+    progs_env.Prepend(LIBS = ['glu32', 'opengl32'])
+else:
+    progs_env.Prepend(LIBS = ['GLU', 'GL'])
+
+# Glut
+progs_env.Prepend(LIBS = [glut])
+
+# GLEW
+progs_env.Prepend(LIBS = [glew])
+
+progs_env.Prepend(CPPPATH = [
+       '#progs/util',
+])
+
+progs_env.Prepend(LIBS = [
+       util,
+])
+
+Export('progs_env')
+
+SConscript([
     'demos/SConscript',
     'glsl/SConscript',
     'redbook/SConscript',
diff --git a/progs/SConstruct b/progs/SConstruct
deleted file mode 100644 (file)
index 4d268cc..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-import os
-import os.path
-import sys
-
-env = Environment(
-    tools = ['generic'],
-    toolpath = ['../scons'],
-    ENV = os.environ,
-)
-
-
-# Use Mesa's headers and libs
-if 1:
-    build_topdir = 'build'
-    build_subdir = env['platform']
-    if env['machine'] != 'generic':
-        build_subdir += '-' + env['machine']
-    if env['debug']:
-        build_subdir += "-debug"
-    if env['profile']:
-        build_subdir += "-profile"
-    build_dir = os.path.join(build_topdir, build_subdir)
-
-    env.Append(CPPDEFINES = ['GLEW_STATIC'])
-    env.Append(CPPPATH = ['#../include'])
-    env.Append(LIBPATH = [
-        '#../' + build_dir + '/glew/',
-        '#../' + build_dir + '/glut/glx',
-    ])
-
-
-conf = Configure(env)
-
-# OpenGL
-if env['platform'] == 'windows':
-    env.Prepend(LIBS = ['glu32', 'opengl32'])
-else:
-    env.Prepend(LIBS = ['GLU', 'GL'])
-
-# Glut
-env['GLUT'] = False
-if conf.CheckCHeader('GL/glut.h'):
-    if env['platform'] == 'windows':
-        env['GLUT_LIB'] = 'glut32'
-    else:
-        env['GLUT_LIB'] = 'glut'
-    env['GLUT'] = True
-
-# GLEW
-env['GLEW'] = False
-if conf.CheckCHeader('GL/glew.h'):
-    env['GLEW_LIB'] = 'glew'
-    env['GLEW'] = True
-    env.Prepend(LIBS = ['glew'])
-
-conf.Finish()
-
-
-Export('env')
-
-SConscript(
-    'SConscript',
-    build_dir = env['build'],
-    duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
-)
index f851870bcf3b7bb53f34f02f32b10124ec290e08..742dd66f36f2dbcee6dda4888c1d80a85268b42e 100644 (file)
@@ -1,84 +1,66 @@
 Import('*')
 
-if not env['GLUT']:
-    Return()
-
-env = env.Clone()
-
-env.Prepend(CPPPATH = [
-       '../util',
-])
-
-env.Prepend(LIBS = [
-       util,
-       '$GLUT_LIB'
-])
-
-if env['platform'] == 'windows':
-    env.Append(CPPDEFINES = ['NOMINMAX'])
-    env.Prepend(LIBS = ['winmm'])
-
 progs = [
-       'arbfplight',
-       'arbfslight',
-       'arbocclude',
-       'bounce',
-       'clearspd',
-       'copypix',
-       'cubemap',
-       'drawpix',
-       'engine',
-       'fbo_firecube',
-       'fire',
-       'fogcoord',
-       'fplight',
-       'fslight',
-       'gamma',
-       'gearbox',
-       'gears',
-       'geartrain',
-       'glinfo',
-       'gloss',
-       'gltestperf',
-       'ipers',
-       'isosurf',
-       'lodbias',
-       'morph3d',
-       'multiarb',
-       'paltex',
-       'pointblast',
-       'ray',
-       'readpix',
-       'reflect',
-       'renormal',
-       'shadowtex',
-       'singlebuffer',
-       'spectex',
-       'spriteblast',
-       'stex3d',
-       'teapot',
-       'terrain',
-       'tessdemo',
-       'texcyl',
-       'texenv',
-       'textures',
-       'trispd',
-       'tunnel',
-       'tunnel2',
-       'vao_demo',
-       'winpos',
-        'dinoshade',
-        'fbotexture',
-        'projtex',
+    'arbfplight',
+    'arbfslight',
+    'arbocclude',
+    'bounce',
+    'clearspd',
+    'copypix',
+    'cubemap',
+    'drawpix',
+    'engine',
+    'fbo_firecube',
+    'fire',
+    'fogcoord',
+    'fplight',
+    'fslight',
+    'gamma',
+    'gearbox',
+    'gears',
+    'geartrain',
+    'glinfo',
+    'gloss',
+    'gltestperf',
+    'ipers',
+    'isosurf',
+    'lodbias',
+    'morph3d',
+    'multiarb',
+    'paltex',
+    'pointblast',
+    'ray',
+    'readpix',
+    'reflect',
+    'renormal',
+    'shadowtex',
+    'singlebuffer',
+    'spectex',
+    'spriteblast',
+    'stex3d',
+    'teapot',
+    'terrain',
+    'tessdemo',
+    'texcyl',
+    'texenv',
+    'textures',
+    'trispd',
+    'tunnel',
+    'tunnel2',
+    'vao_demo',
+    'winpos',
+    'dinoshade',
+    'fbotexture',
+    'projtex',
 ]
 
 for prog in progs:
-    env.Program(
+    progs_env.Program(
         target = prog,
         source = prog + '.c',
     )
     
-env.Program(
+progs_env.Program(
     target = 'rain',
     source = [
         'rain.cxx',
index 7b7a12bf88dc6a1af79b2e90167fd365e5a51482..861b3b72522cb7f3b9603dd9e340c771222c7222 100644 (file)
@@ -388,9 +388,8 @@ static void Init( void )
 
 int main( int argc, char *argv[] )
 {
-   glutInit( &argc, argv );
-   glutInitWindowPosition( 0, 0 );
    glutInitWindowSize( 200, 200 );
+   glutInit( &argc, argv );
    glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
    Win = glutCreateWindow(argv[0]);
    glutReshapeFunc( Reshape );
index 275c85105ede20ba13bd7d7744dd434f964314bc..a0ce7f3f5bce3de68597f0d293b04b86e8d500e6 100644 (file)
@@ -311,9 +311,8 @@ static void Init (void)
 
 int main (int argc, char *argv[])
 {
-       glutInit (&argc, argv);
-       glutInitWindowPosition ( 0, 0);
        glutInitWindowSize (200, 200);
+       glutInit (&argc, argv);
        glutInitDisplayMode (GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
        glutCreateWindow (argv[0]);
        glutReshapeFunc (Reshape);
index 9188ad5a5658743c1fb3e3edaaffe0dd004e8f74..f669a1f26ba328d49904dd2738ccc5f684da7415 100644 (file)
@@ -268,9 +268,8 @@ static void Init( void )
 
 int main( int argc, char *argv[] )
 {
-   glutInit( &argc, argv );
-   glutInitWindowPosition( 0, 0 );
    glutInitWindowSize( 400, 400 );
+   glutInit( &argc, argv );
    glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
    Win = glutCreateWindow(argv[0]);
    glewInit();
index 436bc7d1fb880813b711aba663f5ee5f0ce19262..a9a291e0a6f573ae1849eb544090fab6992d7d41 100644 (file)
@@ -192,10 +192,8 @@ visible(int vis)
 
 int main(int argc, char *argv[])
 {
-  glutInit(&argc, argv);
-  glutInitWindowPosition(0, 0);
   glutInitWindowSize(600, 450);
-
+  glutInit(&argc, argv);
 
   IndexMode = argc > 1 && strcmp(argv[1], "-ci") == 0;
   if (IndexMode)
index 42953f6675e01bd5fa3458f19d5e1515925c6437..c40f118a64bf5cf72521d8610bc269352d4979a0 100644 (file)
@@ -187,9 +187,8 @@ int main( int argc, char *argv[] )
 
    Init( argc, argv );
 
-   glutInit( &argc, argv );
    glutInitWindowSize( (int) Width, (int) Height );
-   glutInitWindowPosition( 0, 0 );
+   glutInit( &argc, argv );
 
    mode = ColorMode | GLUT_DOUBLE;
    if (BufferMask & GL_STENCIL_BUFFER_BIT)
index a13339ea62f86a803f6cd017a31ab92c92045e99..98c835f44f83f3ce21811aca054c5def22e177ef 100644 (file)
@@ -237,6 +237,9 @@ int main( int argc, char *argv[] )
    const char *filename = IMAGE_FILE;
    int i = 1;
 
+   glutInitWindowSize( WinWidth, WinHeight );
+   glutInit( &argc, argv );
+
    if (argc > i && strcmp(argv[i], "-ci")==0) {
       ciMode = GL_TRUE;
       i++;
@@ -245,10 +248,6 @@ int main( int argc, char *argv[] )
       filename = argv[i];
    }
 
-   glutInit( &argc, argv );
-   glutInitWindowPosition( 0, 0 );
-   glutInitWindowSize( WinWidth, WinHeight );
-
    if (ciMode)
       glutInitDisplayMode( GLUT_INDEX | GLUT_DOUBLE );
    else
index 20332b1d96026a7f6c96f698a6d35512ca748132..3e79d6a55890ce513ee6a0425a459c7642b3196c 100644 (file)
@@ -613,9 +613,8 @@ static void parse_args(int argc, char *argv[])
 
 int main( int argc, char *argv[] )
 {
-   glutInit(&argc, argv);
-   glutInitWindowPosition(0, 0);
    glutInitWindowSize(600, 500);
+   glutInit(&argc, argv);
    glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
    glutCreateWindow("Texture Cube Mapping");
    glewInit();
index 5490bcc6355fd486fa451fce9e70f9105837da06..9bc7086e04b4cfcdb4bd051200ffaba073c9ebab 100644 (file)
@@ -328,6 +328,9 @@ int main( int argc, char *argv[] )
    const char *filename = IMAGE_FILE;
    int i = 1;
 
+   glutInitWindowSize( 500, 400 );
+   glutInit( &argc, argv );
+
    if (argc > i && strcmp(argv[i], "-ci")==0) {
       ciMode = GL_TRUE;
       i++;
@@ -336,10 +339,6 @@ int main( int argc, char *argv[] )
       filename = argv[i];
    }
 
-   glutInit( &argc, argv );
-   glutInitWindowPosition( 0, 0 );
-   glutInitWindowSize( 500, 400 );
-
    if (ciMode)
       glutInitDisplayMode( GLUT_INDEX | GLUT_DOUBLE );
    else
index 3cf311e7782ce139d56c65fa4fd3fef5018231a0..c54e3b8fb80f01c76ee5be62744ed58d62b23e31 100644 (file)
@@ -1308,8 +1308,8 @@ Init(void)
 int
 main(int argc, char *argv[])
 {
-   glutInit(&argc, argv);
    glutInitWindowSize(WinWidth, WinHeight);
+   glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("OpenGL Engine Demo");
    glewInit();
index 4e42924a09eff19d25ffd011934babcf41e6bad0..17767a148f9efb9097b9c2966f4c7385fac1bfc8 100644 (file)
@@ -938,7 +938,14 @@ reshape(int width, int height)
 static void 
 init_fbotexture()
 {
+   static const GLenum depthFormats[] = {
+      GL_DEPTH_COMPONENT,
+      GL_DEPTH_COMPONENT16,
+      GL_DEPTH_COMPONENT32
+   };
+   static int numDepthFormats = sizeof(depthFormats) / sizeof(depthFormats[0]);
    GLint i;
+   GLenum stat;
 
    /* gen framebuffer id, delete it, do some assertions, just for testing */
    glGenFramebuffersEXT(1, &MyFB);
@@ -969,18 +976,31 @@ init_fbotexture()
    /* make depth renderbuffer */
    glGenRenderbuffersEXT(1, &DepthRB);
    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, DepthRB);
-   glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT16,
-                           TexWidth, TexHeight);
-   CheckError(__LINE__);
+   /* we may have to try several formats */
+   for (i = 0; i < numDepthFormats; i++) {
+      glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, depthFormats[i],
+                               TexWidth, TexHeight);
+      CheckError(__LINE__);
+
+      glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
+                                   GL_RENDERBUFFER_EXT, DepthRB);
+      CheckError(__LINE__);
+      stat = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
+      if (stat == GL_FRAMEBUFFER_COMPLETE_EXT) {
+         break;
+      }
+   }
+
+   if (stat != GL_FRAMEBUFFER_COMPLETE_EXT) {
+      fprintf(stderr, "Error: unable to get usable FBO combination!\n");
+      exit(1);
+   }
+
    glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
-                                  GL_RENDERBUFFER_DEPTH_SIZE_EXT, &i);
+                                   GL_RENDERBUFFER_DEPTH_SIZE_EXT, &i);
    CheckError(__LINE__);
    printf("Depth renderbuffer size = %d bits\n", i);
 
-   /* attach DepthRB to MyFB */
-   glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
-                               GL_RENDERBUFFER_EXT, DepthRB);
-   CheckError(__LINE__);
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
 
    /*
@@ -1031,11 +1051,11 @@ visible(int vis)
 int
 main(int argc, char *argv[])
 {
+   glutInitWindowSize(WinWidth, WinHeight);
    glutInit(&argc, argv);
 
    glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
 
-   glutInitWindowSize(WinWidth, WinHeight);
    Win = glutCreateWindow("fbo_firecube");
    glewInit();
    init(argc, argv);
index dd70f6141dba4817452073aeb7a55cbf45fff744..3db45418fadfc559fd5761ea1fd5ab4bd3238307 100644 (file)
@@ -733,7 +733,6 @@ main(int ac, char **av)
       HEIGHT = atoi(av[3]);
    }
 
-   glutInitWindowPosition(0, 0);
    glutInitWindowSize(WIDTH, HEIGHT);
    glutInit(&ac, av);
 
index 6f50993c98fc6044ecde304472b1392ccc7072f2..336aa580755f4456ff688408dd1d4b8d22cd6015 100644 (file)
@@ -15,8 +15,6 @@
 
 #define DEPTH 5.0f
 
-static PFNGLFOGCOORDPOINTEREXTPROC glFogCoordPointer_ext;
-
 static GLfloat camz;
 
 static GLint fogMode;
@@ -406,8 +404,8 @@ Init(void)
 int
 main( int argc, char *argv[] )
 {
-   glutInit( &argc, argv );
    glutInitWindowSize( 600, 600 );
+   glutInit( &argc, argv );
    glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
    glutCreateWindow(argv[0]);
    glewInit();
index c297354103fedefa7c7599098bb7f3192edb2329..f52a4f7868669f3b7377e85649c52f9fdc570e59 100644 (file)
@@ -268,9 +268,8 @@ static void Init( void )
 
 int main( int argc, char *argv[] )
 {
-   glutInit( &argc, argv );
-   glutInitWindowPosition( 0, 0 );
    glutInitWindowSize( 200, 200 );
+   glutInit( &argc, argv );
    glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
    Win = glutCreateWindow(argv[0]);
    glewInit();
index f0d76a4a06fb50de4ec40ba530cf4c3bf179b229..395b7caa2c1355f29c74b5b3b09488eabf4663c0 100644 (file)
@@ -353,6 +353,7 @@ MakeSphere(void)
    glNewList(SphereList, GL_COMPILE);
    gluSphere(obj, 2.0f, 10, 5);
    glEndList();
+   gluDeleteQuadric(obj);
 }
 
 static void
@@ -599,9 +600,8 @@ ParseOptions(int argc, char *argv[])
 int
 main(int argc, char *argv[])
 {
-   glutInit(&argc, argv);
-   glutInitWindowPosition( 0, 0);
    glutInitWindowSize(200, 200);
+   glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
    win = glutCreateWindow(argv[0]);
    glutReshapeFunc(Reshape);
index 9b2c3e1052b148abd2a88455e6368016eeaffc75..61c6d125fbe294888c8149cc96c4a1c6a3bef2f0 100644 (file)
@@ -146,12 +146,9 @@ display(void)
 int
 main(int argc, char **argv)
 {
+  glutInitWindowSize(500, 400);
   glutInit(&argc, argv);
   glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
-
-  glutInitWindowPosition(50, 50);
-  glutInitWindowSize(500, 400);
-
   glutCreateWindow("gamma test patterns");
   glutReshapeFunc(Reshape);
   glutDisplayFunc(display);
index 2dcf32f92ff64460414506c6d171c8c86df72625..71d0281904be08eb170d63ea1b918ff355893763 100644 (file)
@@ -474,10 +474,10 @@ visible(int vis)
 int
 main(int argc, char *argv[])
 {
+   glutInitWindowSize(WinWidth, WinHeight);
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
 
-   glutInitWindowSize(WinWidth, WinHeight);
    Win = glutCreateWindow("gearbox");
    init(argc, argv);
 
index 6016162d6f74c6973bf80113269a7af87c587c4e..31a5b79eab969ec6bece56f90350a343f473b908 100644 (file)
@@ -385,11 +385,9 @@ visible(int vis)
 
 int main(int argc, char *argv[])
 {
+  glutInitWindowSize(300, 300);
   glutInit(&argc, argv);
   glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
-
-  glutInitWindowPosition(0, 0);
-  glutInitWindowSize(300, 300);
   win = glutCreateWindow("Gears");
   init(argc, argv);
 
index 8fe405e80760e32d8c1d7c9f4330223b1f0d900f..00b6e78b724000f098b84b8e2041b18ac2037f30 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 
+#include <assert.h>
 #include <math.h>
 #include <stdlib.h>
 #include <GL/glut.h>
@@ -129,8 +130,10 @@ Clear_Buffers ()
 static void
 LoadTriplet (TDA A)
 {
+    int result;
     Clear_Buffers ();
-    fscanf (mainfile, "%s %s %s %s", Buf1, Buf2, Buf3, Buf4);
+    result = fscanf (mainfile, "%s %s %s %s", Buf1, Buf2, Buf3, Buf4);
+    assert(result != EOF);
     A[0] = atof (Buf2);
     A[1] = atof (Buf3);
     A[2] = atof (Buf4);
@@ -140,8 +143,10 @@ LoadTriplet (TDA A)
 static void
 LoadReal (float *a)
 {
+    int result;
     Clear_Buffers ();
-    fscanf (mainfile, "%s %s", Buf1, Buf2);
+    result = fscanf (mainfile, "%s %s", Buf1, Buf2);
+    assert(result != EOF);
     *a = atof (Buf2);
 }
 
@@ -149,8 +154,10 @@ LoadReal (float *a)
 static void
 LoadInteger (int *a)
 {
+    int result;
     Clear_Buffers ();
-    fscanf (mainfile, "%s %s", Buf1, Buf2);
+    result = fscanf (mainfile, "%s %s", Buf1, Buf2);
+    assert(result != EOF);
     *a = atoi (Buf2);
 }
 
@@ -158,8 +165,10 @@ LoadInteger (int *a)
 static void
 LoadText (char *a)
 {
+    int result;
     Clear_Buffers ();
-    fscanf (mainfile, "%s %s", Buf1, Buf2);
+    result = fscanf (mainfile, "%s %s", Buf1, Buf2);
+    assert(result != EOF);
     strcpy (a, Buf2);
 }
 
@@ -177,8 +186,10 @@ getdata (char filename[])
 
     do
     {
+       int result;
        Clear_Buffers ();
-       fscanf (mainfile, "%s", Buf1);
+       result = fscanf (mainfile, "%s", Buf1);
+       (void) result;
        if (ferror (mainfile))
        {
            printf ("\nError opening file !\n");
@@ -1049,19 +1060,18 @@ main (int argc, char *argv[])
 {
     char *file;
 
-    if (argc < 2)
-       file = "geartrain.dat";
-    else
-       file = argv[1];
-
-    glutInit(&argc, argv); 
-    glutInitWindowPosition (0, 0);
     glutInitWindowSize(640,480);
+    glutInit(&argc, argv); 
     glutInitDisplayMode (GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
 
     if (glutCreateWindow ("Gear Train Simulation") == GL_FALSE)
       exit (1);
 
+    if (argc < 2)
+       file = "geartrain.dat";
+    else
+       file = argv[1];
+
     getdata (file);
     process ();
     init ();
index d32e8f8c68bec9d2132dcc0a50eddb972f047a6c..450861e57781934cdcebb9788c4cf391a6d3e249 100644 (file)
@@ -441,8 +441,8 @@ static void Init( int argc, char *argv[] )
 
 int main( int argc, char *argv[] )
 {
-   glutInit( &argc, argv );
    glutInitWindowSize(WinWidth, WinHeight);
+   glutInit( &argc, argv );
    glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
    Win = glutCreateWindow(argv[0] );
    glewInit();
index 2188b0241924034f42f545c3f45237df9b8b1462..3658a395988a0ac33eb9fbed6fd9f71db5b4972a 100644 (file)
@@ -569,10 +569,9 @@ main(int ac, char **av)
    if (ac == 2)
       frontbuffer = 0;
 
+   glutInitWindowSize(640, 480);
    glutInit(&ac, av);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
-   glutInitWindowPosition(0, 0);
-   glutInitWindowSize(640, 480);
    glutCreateWindow("OpenGL/Mesa Performances");
    glutDisplayFunc(display);
    glutMainLoop();
index 5d82b0dc9249bb6d1707848f72884e57b41af230..265378b90a9b883b4c2770c165859ca5a84c8cad 100644 (file)
@@ -133,6 +133,8 @@ initdlists(void)
 
       glEndList();
    }
+
+   gluDeleteQuadric(obj);
 }
 
 static void
@@ -680,7 +682,6 @@ main(int ac, char **av)
    fprintf(stderr,
           "IperS V1.0\nWritten by David Bucciarelli (tech.hmw@plus.it)\n");
 
-   glutInitWindowPosition(0, 0);
    glutInitWindowSize(WIDTH, HEIGHT);
    glutInit(&ac, av);
 
index 2e9dff172613b1da5688a74d2dadf740a498ac27..dbe4d8d172aa2d85a1b0a9fdcc1653638c6e5a38 100644 (file)
@@ -132,9 +132,11 @@ static void read_surface( char *filename )
 
    numverts = 0;
    while (!feof(f) && numverts<maxverts) {
-      fscanf( f, "%f %f %f  %f %f %f",
-             &data[numverts][0], &data[numverts][1], &data[numverts][2],
-             &data[numverts][3], &data[numverts][4], &data[numverts][5] );
+      int result;
+      result = fscanf( f, "%f %f %f  %f %f %f",
+                      &data[numverts][0], &data[numverts][1], &data[numverts][2],
+                      &data[numverts][3], &data[numverts][4], &data[numverts][5] );
+      (void) result;
       numverts++;
    }
    numverts--;
@@ -1061,9 +1063,8 @@ int main(int argc, char **argv)
 
    read_surface( "isosurf.dat" );
 
-   glutInit( &argc, argv);
-   glutInitWindowPosition(0, 0);
    glutInitWindowSize(400, 400);
+   glutInit( &argc, argv);
 
    type = GLUT_DEPTH;
    type |= GLUT_RGB;
index 8d39bd605a7da472958b3656b7de3a5495e7b26a..23488b1616e0feeccef0f827b11be738510870f3 100644 (file)
@@ -282,9 +282,8 @@ static void Init( void )
 
 int main( int argc, char *argv[] )
 {
-   glutInit( &argc, argv );
-   glutInitWindowPosition( 0, 0 );
    glutInitWindowSize( 350, 350 );
+   glutInit( &argc, argv );
    glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
    win = glutCreateWindow(argv[0]);
    glutReshapeFunc( Reshape );
index 6aca8270ff515a250505fc44759dbc2b0a674797..0f8ac426f33d4238d4db0fc7a96e029d9ff88cfc 100644 (file)
@@ -841,9 +841,8 @@ int main(int argc, char **argv)
 
   object=1;
 
-  glutInit(&argc, argv);
-  glutInitWindowPosition(0,0);
   glutInitWindowSize(640,480);
+  glutInit(&argc, argv);
 
   glutInitDisplayMode( GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGB );
 
@@ -887,5 +886,6 @@ int main(int argc, char **argv)
   glutIdleFunc( idle_ );
   glutDisplayFunc( draw );
   glutMainLoop();
-  
+
+  return 0;
 }
index 85c4e3a266c7f9cd2d9152060d3fa0da580ac05f..82796a0c3f4f4341c96b2ebac2d5cfe5575886d8 100644 (file)
@@ -27,6 +27,8 @@
 #define ANIMATE 10
 #define QUIT 100
 
+static GLint T0 = 0;
+static GLint Frames = 0;
 static GLboolean Animate = GL_TRUE;
 static GLint NumUnits = 1;
 static GLboolean TexEnabled[8];
@@ -105,6 +107,20 @@ static void Display( void )
    glPopMatrix();
 
    glutSwapBuffers();
+
+   Frames++;
+
+   {
+      GLint t = glutGet(GLUT_ELAPSED_TIME);
+      if (t - T0 >= 5000) {
+        GLfloat seconds = (t - T0) / 1000.0;
+        GLfloat fps = Frames / seconds;
+        printf("%d frames in %6.3f seconds = %6.3f FPS\n", Frames, seconds, fps);
+        fflush(stdout);
+        T0 = t;
+        Frames = 0;
+      }
+   }
 }
 
 
@@ -322,9 +338,8 @@ int main( int argc, char *argv[] )
 {
    GLint i;
 
-   glutInit( &argc, argv );
    glutInitWindowSize( 300, 300 );
-   glutInitWindowPosition( 0, 0 );
+   glutInit( &argc, argv );
    glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
    glutCreateWindow(argv[0] );
    glewInit();
index d0cbcfb5e9a3b130de18850a2228e601e59ee686..5d4b8662b5cb8d050f9522be2ec9bfc9943eca02 100644 (file)
@@ -248,12 +248,9 @@ static void Init2( void )
 
 int main( int argc, char *argv[] )
 {
-   glutInit( &argc, argv );
-   glutInitWindowPosition( 0, 0 );
    glutInitWindowSize( 400, 300 );
-
+   glutInit( &argc, argv );
    glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
-
    glutCreateWindow(argv[0]);
    glewInit();
 
index 2d70b72589418fdd389642fc6ba8f4ecb7aadca7..b4d0a67f9930d075327603d76a52eb895b4f9ec5 100644 (file)
@@ -427,10 +427,10 @@ int
 main(int argc, char **argv)
 {
   int i;
+
+  glutInitWindowSize(300, 300);
   glutInit(&argc, argv);
   glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_MULTISAMPLE);
-  glutInitWindowPosition(0, 0);
-  glutInitWindowSize(300, 300);
 
   for (i=1; i<argc; i++) {
     if(!strcmp("-noms", argv[i])) {
index 99154d7bdc8b2439b865924e32f8a901c8f0b6f7..d162568b9f0913720d3558ddfaa11aa47c0fcb97 100644 (file)
@@ -245,6 +245,10 @@ loadImageTextures(void)
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
      }
      glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor);
+
+     free(texData3);
+     free(texData4);
+     free(image);
   }
 }
 
@@ -994,18 +998,17 @@ menu(int selection)
 int
 main(int argc, char **argv)
 {
+  glutInitWindowSize(500,500);
   glutInit(&argc, argv);
+  glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE);
+  (void) glutCreateWindow("projtex");
+  glewInit();
 
   if (argc > 1) {
      NumTextures = atoi(argv[1]);
   }
   assert(NumTextures <= MAX_TEX);
 
-  glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE);
-  glutInitWindowSize(500,500);
-  (void) glutCreateWindow("projtex");
-  glewInit();
-
   loadTexture = loadImageTextures;
   drawObject = drawCube;
   initialize();
index c2d8e4f545e352207f7628e470388eb97a73b828..9cc464d2390a5722b812d830e7f2924a0aa0ab18 100644 (file)
@@ -834,6 +834,8 @@ initdlists(void)
    gluQuadricTexture(obj, GL_TRUE);
    gluSphere(obj, SPHERE_RADIUS, 16, 16);
    glEndList();
+
+   gluDeleteQuadric(obj);
 }
 
 int
@@ -854,7 +856,6 @@ main(int ac, char **av)
       }
     */
 
-   glutInitWindowPosition(0, 0);
    glutInitWindowSize(WIDTH, HEIGHT);
    glutInit(&ac, av);
 
index bbb3a68effaeb0d5cbb310bb931d219198a5f1b1..cc4e4902694d0681a61dbe13c657dad4fcc9290f 100644 (file)
@@ -219,7 +219,7 @@ Display( void )
       GLint reads = 0;
       GLint endTime;
       GLint startTime = glutGet(GLUT_ELAPSED_TIME);
-      GLdouble seconds, pixelsPerSecond;
+      GLdouble seconds, mpixels, mpixelsPerSecond;
       printf("Benchmarking...\n");
       do {
          glReadPixels(APosX, APosY, ImgWidth, ImgHeight,
@@ -228,9 +228,10 @@ Display( void )
          endTime = glutGet(GLUT_ELAPSED_TIME);
       } while (endTime - startTime < 4000);   /* 4 seconds */
       seconds = (double) (endTime - startTime) / 1000.0;
-      pixelsPerSecond = reads * ImgWidth * ImgHeight / seconds;
-      printf("Result:  %d reads in %f seconds = %f pixels/sec\n",
-             reads, seconds, pixelsPerSecond);
+      mpixels = reads * (ImgWidth * ImgHeight / (1000.0 * 1000.0));
+      mpixelsPerSecond = mpixels / seconds;
+      printf("Result:  %d reads in %f seconds = %f Mpixels/sec\n",
+             reads, seconds, mpixelsPerSecond);
       Benchmark = GL_FALSE;
    }
    else {
@@ -382,12 +383,11 @@ int
 main( int argc, char *argv[] )
 {
    GLboolean ciMode = GL_FALSE;
+   glutInitWindowSize( 750, 250 );
+   glutInit( &argc, argv );
    if (argc > 1 && strcmp(argv[1], "-ci")==0) {
       ciMode = GL_TRUE;
    }
-   glutInit( &argc, argv );
-   glutInitWindowPosition( 0, 0 );
-   glutInitWindowSize( 750, 250 );
    if (ciMode)
       glutInitDisplayMode( GLUT_INDEX | GLUT_DOUBLE );
    else
index 9e5da95484c810dabde1df372b424daf59c82e59..61dd860ddbe29ce92407e02b6432b393da8c81a7 100644 (file)
@@ -112,12 +112,9 @@ key(unsigned char k, int x, int y)
 
 int main( int argc, char *argv[] )
 {
-   glutInit( &argc, argv );
-   glutInitWindowPosition(0, 0);
    glutInitWindowSize( 400, 400 );
-
+   glutInit( &argc, argv );
    glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
-
    glutCreateWindow(argv[0]);
 
    Init();
index dc5a4bbc480b8e4a4c780af0a7b62958ed449e48..036f73d40b6650b563cbe94b47ccb05fb2393989 100644 (file)
@@ -1022,9 +1022,8 @@ PrintHelp(void)
 int
 main(int argc, char *argv[])
 {
-   glutInit(&argc, argv);
-   glutInitWindowPosition(0, 0);
    glutInitWindowSize(WindowWidth, WindowHeight);
+   glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_STENCIL);
    glutCreateWindow(argv[0]);
    glewInit();
index 6ab1191579c3be6d41e43329c40e84c8e2a057b7..c1dada9d634784b16f14bb931008a7d1644d772b 100644 (file)
@@ -239,13 +239,9 @@ static void ModeMenu(int entry)
 
 int main( int argc, char *argv[] )
 {
-
-   glutInit( &argc, argv );
-   glutInitWindowPosition( 0, 0 );
    glutInitWindowSize( 300, 300 );
-
+   glutInit( &argc, argv );
    glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
-
    glutCreateWindow( "spectex" );
 
    Init();
index d73b680b791dfd568a0ef5718a46e17eead88e68..36e226e1d07929ae7befb6700b8fb7ec6250e207 100644 (file)
@@ -493,6 +493,8 @@ int
 main(int argc, char **argv)
 {
   int i;
+
+  glutInitWindowSize(600,300);
   glutInit(&argc, argv);
   glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_MULTISAMPLE);
 
@@ -506,8 +508,6 @@ main(int argc, char **argv)
       linearFiltering = 0;
     }
   }
-  glutInitWindowPosition(0, 0);
-  glutInitWindowSize(600,300);
   glutCreateWindow("sprite blast");
   glewInit();
   glutReshapeFunc(reshape);
index 6bf6e06409513d688e53c2c2b109f2646adb6b3a..04a675f36e615123e16da90ef4fc101b26b05c0f 100644 (file)
@@ -638,7 +638,6 @@ int main(int ac, char **av)
     }
     */
 
-  glutInitWindowPosition(0,0);
   glutInitWindowSize(WIDTH,HEIGHT);
   glutInit(&ac,av);
 
index be78ea4950f7a959096de6fd1564993aa368b95a..a72c8d3caeaae5c823b8c8af4ff5be98c42eb57c 100644 (file)
@@ -8,6 +8,7 @@
  * based on a Mikael SkiZoWalker's (MoDEL) / France (Skizo@Hol.Fr) demo
  */
 
+#include <assert.h>
 #include <stdio.h>
 #include <math.h>
 #include <stdlib.h>
@@ -559,12 +560,14 @@ loadpic(void)
    FILE *FilePic;
    int i, tmp;
    GLenum gluerr;
+   size_t result;
 
    if ((FilePic = fopen("terrain.dat", "r")) == NULL) {
       fprintf(stderr, "Error loading terrain.dat\n");
       exit(-1);
    }
-   fread(bufferter, 256 * 256, 1, FilePic);
+   result = fread(bufferter, 256 * 256, 1, FilePic);
+   assert(result == 1);
    fclose(FilePic);
 
    for (i = 0; i < (256 * 256); i++) {
@@ -623,7 +626,6 @@ init(void)
 int
 main(int ac, char **av)
 {
-   glutInitWindowPosition(0, 0);
    glutInitWindowSize(WIDTH, HEIGHT);
    glutInit(&ac, av);
 
index f71cea127448ca09e15ad2c416950db21969cbc1..8b988e36c136202b3fe15806f0f5e2de25d0e68e 100644 (file)
@@ -503,10 +503,9 @@ int main( int argc, char **argv )
 
    usage();
 
+   glutInitWindowSize( 400, 400 );
    glutInit( &argc, argv );
    glutInitDisplayMode( GLUT_SINGLE | GLUT_RGB );
-   glutInitWindowPosition(0, 0);
-   glutInitWindowSize( 400, 400 );
    glutCreateWindow( argv[0] );
 
    /* GH: Bit of a hack...
index 0e6089bced54e977eefff53845d16e28b5cc9686..4df97ec4f502593f44518e067b0c58c4bf2db26b 100644 (file)
@@ -261,10 +261,8 @@ static void Init( int argc, char *argv[] )
 
 int main( int argc, char *argv[] )
 {
-   glutInit( &argc, argv );
    glutInitWindowSize( 400, 400 );
-   glutInitWindowPosition( 0, 0 );
-
+   glutInit( &argc, argv );
    glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
 
    Win = glutCreateWindow(argv[0] );
index c5a8b13f35fbcc692988daadaf8f52b4f55f4bb0..260ca8718f0e3be0675bfe1e94f2569c79a8ee29 100644 (file)
@@ -765,6 +765,7 @@ int main( int argc, char *argv[] )
    GLboolean info = GL_FALSE;
    int i;
 
+   glutInitWindowSize( winWidth, winHeight );
    glutInit( &argc, argv );
 
    for ( i = 1 ; i < argc ; i++ ) {
@@ -786,8 +787,6 @@ int main( int argc, char *argv[] )
       glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE );
    }
 
-   glutInitWindowSize( winWidth, winHeight );
-   glutInitWindowPosition( 0, 0 );
    Win = glutCreateWindow( "Texture Environment Test" );
 
    initialize();
index b7bf135d21905b21e65a1658cb8f36695d40981a..1415ef1c43cfb5b05b4e85d0b28a5190e45c4986 100644 (file)
@@ -57,7 +57,7 @@ Idle(void)
 {
    Xrot = glutGet(GLUT_ELAPSED_TIME) * 0.02;
    Yrot = glutGet(GLUT_ELAPSED_TIME) * 0.04;
-   //Zrot += 2.0;
+   /* Zrot += 2.0; */
    glutPostRedisplay();
 }
 
@@ -356,9 +356,8 @@ Usage(void)
 int
 main(int argc, char *argv[])
 {
-   glutInit(&argc, argv);
-   glutInitWindowPosition(0, 0);
    glutInitWindowSize(700, 700);
+   glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
    Win = glutCreateWindow(argv[0]);
    glutReshapeFunc(Reshape);
index 165d088e3d306bb245192288c97ae25ded11fb64..c07c3409472d4414c071ce9ed824eb4fc4b2c5d5 100644 (file)
@@ -227,15 +227,12 @@ static void Help( const char *program )
 
 int main( int argc, char *argv[] )
 {
-   printf("For options:  %s -help\n", argv[0]);
-   glutInit( &argc, argv );
    glutInitWindowSize( (int) Width, (int) Height );
-   glutInitWindowPosition( 0, 0 );
-
+   glutInit( &argc, argv );
    glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
-
    glutCreateWindow( argv[0] );
 
+   printf("For options:  %s -help\n", argv[0]);
    if (argc==2 && strcmp(argv[1],"-help")==0) {
       Help(argv[0]);
       return 0;
index 6981da32988db505d92f2b112a6423c7418a4b50..efc007c79aa5af29cc46f6d97b887f24a11423a5 100644 (file)
@@ -491,7 +491,6 @@ main(int ac, char **av)
    fprintf(stderr,
           "Tunnel V1.5\nWritten by David Bucciarelli (tech.hmw@plus.it)\n");
 
-   glutInitWindowPosition(0, 0);
    glutInitWindowSize(WIDTH, HEIGHT);
    glutInit(&ac, av);
 
index 0288ea0f8ceaede6de5f4e5aee1d99f825ec1a55..f15da95b18bea25edd7f377d39c445571a68b66d 100644 (file)
@@ -559,7 +559,6 @@ main(int ac, char **av)
    fprintf(stderr,
           "Tunnel2 V1.0\nWritten by David Bucciarelli (tech.hmw@plus.it)\n");
 
-   glutInitWindowPosition(0, 0);
    glutInitWindowSize(WIDTHC0, HEIGHTC0);
    glutInit(&ac, av);
 
index 206e06fc6c7141d255e3c06c07b7551985893e2c..5ce07ecc63b8ceba64db64f9e7044ce1567ff105 100644 (file)
@@ -317,9 +317,8 @@ static void Init( void )
 
 int main( int argc, char *argv[] )
 {
-   glutInit( &argc, argv );
-   glutInitWindowPosition( 0, 0 );
    glutInitWindowSize( Width, Height );
+   glutInit( &argc, argv );
    glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
    Win = glutCreateWindow( "GL_APPLE_vertex_array_object demo" );
    glutReshapeFunc( Reshape );
index 13a9c7e9a8f7e1382661db85805ececf7145c5f7..f935f9bee0f1ae829fb67b9743bc755f0cd3d1fa 100644 (file)
@@ -96,9 +96,8 @@ static void init( void )
 
 int main( int argc, char *argv[] )
 {
-   glutInit(&argc, argv);
-   glutInitWindowPosition(0, 0);
    glutInitWindowSize(500, 500);
+   glutInit(&argc, argv);
    glutInitDisplayMode( GLUT_RGB );
 
    if (glutCreateWindow("winpos") <= 0) {
index 0eee9ecf4da2dca747c6d92cd2fa0f8b1a1e2e1f..2d9b8cac7f712902824673338eb0a1e3c36c8944 100644 (file)
@@ -274,10 +274,10 @@ draw(void)
 static void
 reshape(int width, int height)
 {
-   glViewport(0, 0, (GLint) width, (GLint) height);
-
    GLfloat h = (GLfloat) height / (GLfloat) width;
 
+   glViewport(0, 0, (GLint) width, (GLint) height);
+
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0);
@@ -333,6 +333,8 @@ static void run_gears(EGLDisplay dpy, EGLSurface surf, int ttr)
        double st = current_time();
        double ct = st;
        int frames = 0;
+       GLfloat seconds, fps;
+
        while (ct - st < ttr)
        {
                double tt = current_time();
@@ -352,8 +354,8 @@ static void run_gears(EGLDisplay dpy, EGLSurface surf, int ttr)
                frames++;
        }
        
-       GLfloat seconds = ct - st;
-       GLfloat fps = frames / seconds;
+       seconds = ct - st;
+       fps = frames / seconds;
        printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds, fps);
        
 }
@@ -372,7 +374,8 @@ main(int argc, char *argv[])
        EGLint screenAttribs[10];
        EGLModeMESA mode[MAX_MODES];
        EGLScreenMESA screen;
-       EGLint count, chosenMode;
+       EGLint count;
+       EGLint chosenMode = 0;
        GLboolean printInfo = GL_FALSE;
        EGLint width = 0, height = 0;
        
index 47b3ce3366fae2ace50c159663a03f2838d65311..520f76ea036e6c0b7f6f5c0b2f74d97f38ddaf1c 100644 (file)
@@ -52,7 +52,8 @@ main(int argc, char *argv[])
        EGLint screenAttribs[10];
        EGLModeMESA mode[MAX_MODES];
        EGLScreenMESA screen;
-       EGLint count, chosenMode;
+       EGLint count;
+       EGLint chosenMode = 0;
        EGLint width = 0, height = 0;
 
        d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
index 79f6702007e736b108dcbca3038e21e60ae07596..9bbc3cddaf1a351930d68e278ffaff5a00f88b4e 100644 (file)
@@ -127,6 +127,7 @@ static void run(EGLDisplay dpy, EGLSurface surf, int ttr)
        double st = current_time();
        double ct = st;
        int frames = 0;
+       GLfloat seconds, fps;
 
        while (ct - st < ttr)
        {
@@ -139,8 +140,8 @@ static void run(EGLDisplay dpy, EGLSurface surf, int ttr)
                frames++;
        }
 
-       GLfloat seconds = ct - st;
-       GLfloat fps = frames / seconds;
+       seconds = ct - st;
+       fps = frames / seconds;
        printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds, fps);
 }
 
index 1ddb691677f1418b91940a0d3b1193ca73c5b41e..212d1acf692fc775a6ec585521df1eb87016bcee 100644 (file)
@@ -274,10 +274,10 @@ draw(void)
 static void
 reshape(int width, int height)
 {
-   glViewport(0, 0, (GLint) width, (GLint) height);
-
    GLfloat h = (GLfloat) height / (GLfloat) width;
 
+   glViewport(0, 0, (GLint) width, (GLint) height);
+
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0);
@@ -333,6 +333,8 @@ static void run_gears(EGLDisplay dpy, EGLSurface surf, int ttr)
        double st = current_time();
        double ct = st;
        int frames = 0;
+       GLfloat seconds, fps;
+
        while (ct - st < ttr)
        {
                double tt = current_time();
@@ -352,8 +354,8 @@ static void run_gears(EGLDisplay dpy, EGLSurface surf, int ttr)
                frames++;
        }
        
-       GLfloat seconds = ct - st;
-       GLfloat fps = frames / seconds;
+       seconds = ct - st;
+       fps = frames / seconds;
        printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds, fps);
        
 }
index 72ed0052832f8dae55dd19612e1f59d839ce335d..614a6256037d8f21c6eec12998564acc8b4d4598 100644 (file)
@@ -95,9 +95,6 @@ static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0;
 static GLint gear1, gear2, gear3;
 static GLfloat angle = 0.0;
 
-static GLboolean fullscreen = GL_FALSE;        /* Create a single fullscreen window */
-
-
 /*
  *
  *  Draw a gear wheel.  You'll probably want to call this function when
@@ -327,122 +324,235 @@ init(void)
 }
 
 
-/*
- * Create an RGB, double-buffered X window.
- * Return the window and context handles.
- */
-static void
-make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
-              const char *name,
-              int x, int y, int width, int height,
-              Window *winRet,
-              EGLContext *ctxRet,
-              EGLSurface *surfRet)
-{
-   static const EGLint attribs[] = {
-      EGL_RED_SIZE, 1,
-      EGL_GREEN_SIZE, 1,
-      EGL_BLUE_SIZE, 1,
-      /*EGL_DOUBLEBUFFER,*/
-      EGL_DEPTH_SIZE, 1,
-      EGL_NONE
-   };
+struct egl_manager {
+   EGLNativeDisplayType xdpy;
+   EGLNativeWindowType xwin;
+   EGLNativePixmapType xpix;
 
-   int scrnum;
-   XSetWindowAttributes attr;
-   unsigned long mask;
-   Window root;
-   Window win;
-   XVisualInfo *visInfo, visTemplate;
-   int num_visuals;
+   EGLDisplay dpy;
+   EGLConfig conf;
    EGLContext ctx;
-   EGLConfig config;
-   EGLint num_configs, vid;
 
-   scrnum = DefaultScreen( x_dpy );
-   root = RootWindow( x_dpy, scrnum );
+   EGLSurface win;
+   EGLSurface pix;
+   EGLSurface pbuf;
 
-   if (fullscreen) {
-      x = 0; y = 0;
-      width = DisplayWidth( x_dpy, scrnum );
-      height = DisplayHeight( x_dpy, scrnum );
+   EGLBoolean verbose;
+   EGLint major, minor;
+};
+
+static struct egl_manager *
+egl_manager_new(EGLNativeDisplayType xdpy, const EGLint *attrib_list,
+                EGLBoolean verbose)
+{
+   struct egl_manager *eman;
+   const char *ver;
+   EGLint num_conf;
+
+   eman = calloc(1, sizeof(*eman));
+   if (!eman)
+      return NULL;
+
+   eman->verbose = verbose;
+   eman->xdpy = xdpy;
+
+   eman->dpy = eglGetDisplay(eman->xdpy);
+   if (eman->dpy == EGL_NO_DISPLAY) {
+      printf("eglGetDisplay() failed\n");
+      free(eman);
+      return NULL;
    }
 
-   if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) {
-      printf("Error: couldn't get an EGL visual config\n");
-      exit(1);
+   if (!eglInitialize(eman->dpy, &eman->major, &eman->minor)) {
+      printf("eglInitialize() failed\n");
+      free(eman);
+      return NULL;
    }
 
-   if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
-      printf("Error: eglGetConfigAttrib() failed\n");
-      exit(1);
+   ver = eglQueryString(eman->dpy, EGL_VERSION);
+   printf("EGL_VERSION = %s\n", ver);
+
+   if (!eglChooseConfig(eman->dpy, attrib_list, &eman->conf, 1, &num_conf) ||
+       !num_conf) {
+      printf("eglChooseConfig() failed\n");
+      eglTerminate(eman->dpy);
+      free(eman);
+      return NULL;
    }
 
-   /* The X window visual must match the EGL config */
-   visTemplate.visualid = vid;
-   visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals);
-   if (!visInfo) {
-      printf("Error: couldn't get X visual\n");
-      exit(1);
+   eman->ctx = eglCreateContext(eman->dpy, eman->conf, EGL_NO_CONTEXT, NULL);
+   if (eman->ctx == EGL_NO_CONTEXT) {
+      printf("eglCreateContext() failed\n");
+      eglTerminate(eman->dpy);
+      free(eman);
+      return NULL;
+   }
+
+   return eman;
+}
+
+static EGLBoolean
+egl_manager_create_window(struct egl_manager *eman, const char *name,
+                          EGLint w, EGLint h, EGLBoolean need_surface,
+                          EGLBoolean fullscreen, const EGLint *attrib_list)
+{
+   XVisualInfo vinfo_template, *vinfo = NULL;
+   EGLint val, num_vinfo;
+   Window root;
+   XSetWindowAttributes attrs;
+   unsigned long mask;
+   EGLint x = 0, y = 0;
+
+   if (!eglGetConfigAttrib(eman->dpy, eman->conf,
+                           EGL_NATIVE_VISUAL_ID, &val)) {
+      printf("eglGetConfigAttrib() failed\n");
+      return EGL_FALSE;
+   }
+   if (val) {
+      vinfo_template.visualid = (VisualID) val;
+      vinfo = XGetVisualInfo(eman->xdpy, VisualIDMask, &vinfo_template, &num_vinfo);
+   }
+   /* try harder if window surface is not needed */
+   if (!vinfo && !need_surface &&
+       eglGetConfigAttrib(eman->dpy, eman->conf, EGL_BUFFER_SIZE, &val)) {
+      if (val == 32)
+         val = 24;
+      vinfo_template.depth = val;
+      vinfo = XGetVisualInfo(eman->xdpy, VisualDepthMask, &vinfo_template, &num_vinfo);
+   }
+
+   if (!vinfo) {
+      printf("XGetVisualInfo() failed\n");
+      return EGL_FALSE;
+   }
+
+   root = DefaultRootWindow(eman->xdpy);
+   if (fullscreen) {
+      x = y = 0;
+      w = DisplayWidth(eman->xdpy, DefaultScreen(eman->xdpy));
+      h = DisplayHeight(eman->xdpy, DefaultScreen(eman->xdpy));
    }
 
    /* window attributes */
-   attr.background_pixel = 0;
-   attr.border_pixel = 0;
-   attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone);
-   attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
-   attr.override_redirect = fullscreen;
+   attrs.background_pixel = 0;
+   attrs.border_pixel = 0;
+   attrs.colormap = XCreateColormap(eman->xdpy, root, vinfo->visual, AllocNone);
+   attrs.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
+   attrs.override_redirect = fullscreen;
    mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect;
 
-   win = XCreateWindow( x_dpy, root, 0, 0, width, height,
-                       0, visInfo->depth, InputOutput,
-                       visInfo->visual, mask, &attr );
+   eman->xwin = XCreateWindow(eman->xdpy, root, x, y, w, h,
+                              0, vinfo->depth, InputOutput,
+                              vinfo->visual, mask, &attrs);
+   XFree(vinfo);
 
    /* set hints and properties */
    {
       XSizeHints sizehints;
       sizehints.x = x;
       sizehints.y = y;
-      sizehints.width  = width;
-      sizehints.height = height;
+      sizehints.width  = w;
+      sizehints.height = h;
       sizehints.flags = USSize | USPosition;
-      XSetNormalHints(x_dpy, win, &sizehints);
-      XSetStandardProperties(x_dpy, win, name, name,
-                              None, (char **)NULL, 0, &sizehints);
+      XSetNormalHints(eman->xdpy, eman->xwin, &sizehints);
+      XSetStandardProperties(eman->xdpy, eman->xwin, name, name,
+                             None, (char **)NULL, 0, &sizehints);
    }
 
-   eglBindAPI(EGL_OPENGL_API);
+   if (need_surface) {
+      eman->win = eglCreateWindowSurface(eman->dpy, eman->conf,
+                                         eman->xwin, attrib_list);
+      if (eman->win == EGL_NO_SURFACE) {
+         printf("eglCreateWindowSurface() failed\n");
+         XDestroyWindow(eman->xdpy, eman->xwin);
+         eman->xwin = None;
+         return EGL_FALSE;
+      }
+   }
+
+   XMapWindow(eman->xdpy, eman->xwin);
+
+   return EGL_TRUE;
+}
 
-   ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, NULL );
-   if (!ctx) {
-      printf("Error: glXCreateContext failed\n");
-      exit(1);
+static EGLBoolean
+egl_manager_create_pixmap(struct egl_manager *eman, EGLNativeWindowType xwin,
+                          EGLBoolean need_surface, const EGLint *attrib_list)
+{
+   XWindowAttributes attrs;
+
+   if (!XGetWindowAttributes(eman->xdpy, xwin, &attrs)) {
+      printf("XGetWindowAttributes() failed\n");
+      return EGL_FALSE;
+   }
+
+   eman->xpix = XCreatePixmap(eman->xdpy, xwin,
+                              attrs.width, attrs.height, attrs.depth);
+
+   if (need_surface) {
+      eman->pix = eglCreatePixmapSurface(eman->dpy, eman->conf,
+                                         eman->xpix, attrib_list);
+      if (eman->pix == EGL_NO_SURFACE) {
+         printf("eglCreatePixmapSurface() failed\n");
+         XFreePixmap(eman->xdpy, eman->xpix);
+         eman->xpix = None;
+         return EGL_FALSE;
+      }
    }
 
-   *surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL);
+   return EGL_TRUE;
+}
 
-   XFree(visInfo);
+static EGLBoolean
+egl_manager_create_pbuffer(struct egl_manager *eman, const EGLint *attrib_list)
+{
+   eman->pbuf = eglCreatePbufferSurface(eman->dpy, eman->conf, attrib_list);
+   if (eman->pbuf == EGL_NO_SURFACE) {
+      printf("eglCreatePbufferSurface() failed\n");
+      return EGL_FALSE;
+   }
 
-   *winRet = win;
-   *ctxRet = ctx;
+   return EGL_TRUE;
 }
 
+static void
+egl_manager_destroy(struct egl_manager *eman)
+{
+   eglMakeCurrent(eman->dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+   eglTerminate(eman->dpy);
+
+   if (eman->xwin != None)
+      XDestroyWindow(eman->xdpy, eman->xwin);
+   if (eman->xpix != None)
+      XFreePixmap(eman->xdpy, eman->xpix);
+
+   free(eman);
+}
 
 static void
-event_loop(Display *dpy, Window win,
-           EGLDisplay egl_dpy, EGLSurface egl_surf)
+event_loop(struct egl_manager *eman, EGLint surface_type, EGLint w, EGLint h)
 {
+   GC gc = XCreateGC(eman->xdpy, eman->xwin, 0, NULL);
+   EGLint orig_w = w, orig_h = h;
+
+   if (surface_type == EGL_PBUFFER_BIT)
+      printf("there will be no screen update if "
+             "eglCopyBuffers() is not implemented\n");
+
    while (1) {
-      while (XPending(dpy) > 0) {
+      while (XPending(eman->xdpy) > 0) {
          XEvent event;
-         XNextEvent(dpy, &event);
+         XNextEvent(eman->xdpy, &event);
          switch (event.type) {
-        case Expose:
+         case Expose:
             /* we'll redraw below */
-           break;
-        case ConfigureNotify:
-           reshape(event.xconfigure.width, event.xconfigure.height);
-           break;
+            break;
+         case ConfigureNotify:
+            w = event.xconfigure.width;
+            h = event.xconfigure.height;
+            if (surface_type == EGL_WINDOW_BIT)
+               reshape(w, h);
+            break;
          case KeyPress:
             {
                char buffer[10];
@@ -476,6 +586,7 @@ event_loop(Display *dpy, Window win,
          static int frames = 0;
          static double tRot0 = -1.0, tRate0 = -1.0;
          double dt, t = current_time();
+         int x, y;
          if (tRot0 < 0.0)
             tRot0 = t;
          dt = t - tRot0;
@@ -487,7 +598,25 @@ event_loop(Display *dpy, Window win,
              angle -= 3600.0;
 
          draw();
-         eglSwapBuffers(egl_dpy, egl_surf);
+         switch (surface_type) {
+         case EGL_WINDOW_BIT:
+            eglSwapBuffers(eman->dpy, eman->win);
+            break;
+         case EGL_PBUFFER_BIT:
+            eglWaitClient();
+            if (!eglCopyBuffers(eman->xdpy, eman->pbuf, eman->xpix))
+               break;
+            /* fall through */
+         case EGL_PIXMAP_BIT:
+            eglWaitClient();
+            for (x = 0; x < w; x += orig_w) {
+               for (y = 0; y < h; y += orig_h) {
+                  XCopyArea(eman->xdpy, eman->xpix, eman->xwin, gc,
+                            0, 0, orig_w, orig_h, x, y);
+               }
+            }
+            break;
+         }
 
          frames++;
 
@@ -503,6 +632,8 @@ event_loop(Display *dpy, Window win,
          }
       }
    }
+
+   XFreeGC(eman->xdpy, gc);
 }
 
 
@@ -513,6 +644,8 @@ usage(void)
    printf("  -display <displayname>  set the display to run on\n");
    printf("  -fullscreen             run in fullscreen mode\n");
    printf("  -info                   display OpenGL renderer info\n");
+   printf("  -pixmap                 use pixmap surface\n");
+   printf("  -pbuffer                use pbuffer surface\n");
 }
  
 
@@ -521,15 +654,23 @@ main(int argc, char *argv[])
 {
    const int winWidth = 300, winHeight = 300;
    Display *x_dpy;
-   Window win;
-   EGLSurface egl_surf;
-   EGLContext egl_ctx;
-   EGLDisplay egl_dpy;
    char *dpyName = NULL;
+   struct egl_manager *eman;
+   EGLint attribs[] = {
+      EGL_SURFACE_TYPE, 0, /* filled later */
+      EGL_RED_SIZE, 1,
+      EGL_GREEN_SIZE, 1,
+      EGL_BLUE_SIZE, 1,
+      EGL_DEPTH_SIZE, 1,
+      EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
+      EGL_NONE
+   };
+   char win_title[] = "xeglgears (window/pixmap/pbuffer)";
+   EGLint surface_type = EGL_WINDOW_BIT;
    GLboolean printInfo = GL_FALSE;
-   EGLint egl_major, egl_minor;
+   GLboolean fullscreen = GL_FALSE;
+   EGLBoolean ret;
    int i;
-   const char *s;
 
    for (i = 1; i < argc; i++) {
       if (strcmp(argv[i], "-display") == 0) {
@@ -542,12 +683,21 @@ main(int argc, char *argv[])
       else if (strcmp(argv[i], "-fullscreen") == 0) {
          fullscreen = GL_TRUE;
       }
+      else if (strcmp(argv[i], "-pixmap") == 0) {
+         surface_type = EGL_PIXMAP_BIT;
+      }
+      else if (strcmp(argv[i], "-pbuffer") == 0) {
+         surface_type = EGL_PBUFFER_BIT;
+      }
       else {
          usage();
          return -1;
       }
    }
 
+   /* set surface type */
+   attribs[1] = surface_type;
+
    x_dpy = XOpenDisplay(dpyName);
    if (!x_dpy) {
       printf("Error: couldn't open display %s\n",
@@ -555,26 +705,60 @@ main(int argc, char *argv[])
       return -1;
    }
 
-   egl_dpy = eglGetDisplay(x_dpy);
-   if (!egl_dpy) {
-      printf("Error: eglGetDisplay() failed\n");
-      return -1;
-   }
+   eglBindAPI(EGL_OPENGL_API);
 
-   if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) {
-      printf("Error: eglInitialize() failed\n");
+   eman = egl_manager_new(x_dpy, attribs, printInfo);
+   if (!eman) {
+      XCloseDisplay(x_dpy);
       return -1;
    }
 
-   s = eglQueryString(egl_dpy, EGL_VERSION);
-   printf("EGL_VERSION = %s\n", s);
-
-   make_x_window(x_dpy, egl_dpy,
-                 "glxgears", 0, 0, winWidth, winHeight,
-                 &win, &egl_ctx, &egl_surf);
+   snprintf(win_title, sizeof(win_title), "xeglgears (%s)",
+            (surface_type == EGL_WINDOW_BIT) ? "window" :
+            (surface_type == EGL_PIXMAP_BIT) ? "pixmap" : "pbuffer");
+
+   /* create surface(s) */
+   switch (surface_type) {
+   case EGL_WINDOW_BIT:
+      ret = egl_manager_create_window(eman, win_title, winWidth, winHeight,
+                                      EGL_TRUE, fullscreen, NULL);
+      if (ret)
+         ret = eglMakeCurrent(eman->dpy, eman->win, eman->win, eman->ctx);
+      break;
+   case EGL_PIXMAP_BIT:
+      ret = (egl_manager_create_window(eman, win_title, winWidth, winHeight,
+                                       EGL_FALSE, fullscreen, NULL) &&
+             egl_manager_create_pixmap(eman, eman->xwin,
+                                       EGL_TRUE, NULL));
+      if (ret)
+         ret = eglMakeCurrent(eman->dpy, eman->pix, eman->pix, eman->ctx);
+      break;
+   case EGL_PBUFFER_BIT:
+      {
+         EGLint pbuf_attribs[] = {
+            EGL_WIDTH, winWidth,
+            EGL_HEIGHT, winHeight,
+            EGL_NONE
+         };
+         ret = (egl_manager_create_window(eman, win_title, winWidth, winHeight,
+                                          EGL_FALSE, fullscreen, NULL) &&
+                egl_manager_create_pixmap(eman, eman->xwin,
+                                          EGL_FALSE, NULL) &&
+                egl_manager_create_pbuffer(eman, pbuf_attribs));
+         if (ret)
+            ret = eglMakeCurrent(eman->dpy, eman->pbuf, eman->pbuf, eman->ctx);
+      }
+      break;
+   default:
+      ret = EGL_FALSE;
+      break;
+   }
 
-   XMapWindow(x_dpy, win);
-   eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx);
+   if (!ret) {
+      egl_manager_destroy(eman);
+      XCloseDisplay(x_dpy);
+      return -1;
+   }
 
    if (printInfo) {
       printf("GL_RENDERER   = %s\n", (char *) glGetString(GL_RENDERER));
@@ -590,18 +774,13 @@ main(int argc, char *argv[])
     */
    reshape(winWidth, winHeight);
 
-   event_loop(x_dpy, win, egl_dpy, egl_surf);
+   event_loop(eman, surface_type, winWidth, winHeight);
 
    glDeleteLists(gear1, 1);
    glDeleteLists(gear2, 1);
    glDeleteLists(gear3, 1);
 
-   eglDestroyContext(egl_dpy, egl_ctx);
-   eglDestroySurface(egl_dpy, egl_surf);
-   eglTerminate(egl_dpy);
-
-
-   XDestroyWindow(x_dpy, win);
+   egl_manager_destroy(eman);
    XCloseDisplay(x_dpy);
 
    return 0;
index 681928cf26022a227224d70eab79fdcf3ad35829..d77cd32b4df673bba1298fa754f8d7e62b1506d0 100755 (executable)
@@ -17,6 +17,7 @@ SOURCES = \
        tri-depth2.c \
        tri-depthwrite.c \
        tri-depthwrite2.c \
+       tri-inv.c \
         tri-param.c \
         fp-tri.c
 
index a78318542c1605f3090b7fcacabb721a372c097c..113e11ab54e7f759ce7425f27f2b52ad1e69a5ed 100644 (file)
@@ -1,15 +1,4 @@
-Import('env')
-
-if not env['GLUT']:
-    Return()
-
-env = env.Clone()
-
-env.Prepend(CPPPATH = [
-       '../util',
-])
-
-env.Prepend(LIBS = ['$GLUT_LIB'])
+Import('*')
 
 progs = [
     'fp-tri',
@@ -24,7 +13,7 @@ progs = [
 ]
 
 for prog in progs:
-    env.Program(
+    progs_env.Program(
         target = prog,
         source = [prog + '.c'],
     )
index 52a8fcfc22ac683fdba9ebdcaf1d565747569ee1..70676d4c400c14a0b6cb50704e7e56a2a3c04781 100644 (file)
@@ -73,7 +73,7 @@ static void Init( void )
    GLuint Texture;
    GLint errno;
    GLuint prognum;
-   char buf[4096];
+   char buf[50000];
    GLuint sz;
    FILE *f;
 
@@ -176,6 +176,17 @@ static void Init( void )
    }
 
 
+   {
+      const float Ambient[4] = { 0.0, 1.0, 0.0, 0.0 };
+      const float Diffuse[4] = { 1.0, 0.0, 0.0, 0.0 };
+      const float Specular[4] = { 0.0, 0.0, 1.0, 0.0 };
+      const float Emission[4] = { 0.0, 0.0, 0.0, 1.0 };
+      glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, Ambient);
+      glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, Diffuse);
+      glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, Specular);
+      glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, Emission);
+   }
+
    glClearColor(.1, .3, .5, 0);
 }
 
@@ -197,7 +208,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
diff --git a/progs/fp/mov-imm.txt b/progs/fp/mov-imm.txt
new file mode 100644 (file)
index 0000000..38e4807
--- /dev/null
@@ -0,0 +1,3 @@
+!!ARBfp1.0
+MOV result.color, {0.5, 0.8, 0.3, 1.0};
+END
diff --git a/progs/fp/mov-param.txt b/progs/fp/mov-param.txt
new file mode 100644 (file)
index 0000000..13d82fe
--- /dev/null
@@ -0,0 +1,4 @@
+!!ARBfp1.0
+PARAM Diffuse = state.material.diffuse; 
+MOV result.color, Diffuse;
+END
index c0963d7a0b5a9a67d34baf2ddc9e744f44eb7c0e..1ae753c1d053b9a835ee574087bd26d15029e5f4 100644 (file)
@@ -55,7 +55,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 5488469e806d1b80cf94791d44f12ed856657d4b..a9f3a6a5be3678a02f549eaee01b1634210b0888 100644 (file)
@@ -57,7 +57,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 6ed23071157ce02f0e17cc08b882d9789689ecfc..8c4336817beab077ddedc75016f5e97f70c24c72 100644 (file)
@@ -59,7 +59,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 8e4f3e62451b4759eb1625d4aaaa940cc8c8000e..7b9d70f292af5e7e275277df410f06c7a867063d 100644 (file)
@@ -55,7 +55,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 3c0b4d30c97ae319ddd612e1dd4c41f5aefea7c7..599949551d179b6125f8cc5c7ea009c7d106a27e 100644 (file)
@@ -55,7 +55,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 7e8d8c5ce2960c3a4d3dbfdc58d4232d0f8421f7..7e490fa61ca75049037f8792620c21d9b83ac0d6 100644 (file)
@@ -56,7 +56,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 57443d71bd08bc8a968e115ec7adc980582615e0..26a804d4b3875d33b6018a5a90f15b3c94565472 100644 (file)
@@ -54,7 +54,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 1dbbb201cef2e48f2a20a5efc983e26521839604..64299e945314afdce1b67bfb309ec70bba5bf40e 100644 (file)
@@ -76,7 +76,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
diff --git a/progs/glsl/CH11-bumpmaptex.frag b/progs/glsl/CH11-bumpmaptex.frag
new file mode 100644 (file)
index 0000000..b1f93b7
--- /dev/null
@@ -0,0 +1,47 @@
+//
+// Fragment shader for procedural bumps
+//
+// Authors: John Kessenich, Randi Rost
+//
+// Copyright (c) 2002-2006 3Dlabs Inc. Ltd. 
+//
+// See 3Dlabs-License.txt for license information
+//
+// Texture mapping/modulation added by Brian Paul
+//
+
+varying vec3 LightDir;
+varying vec3 EyeDir;
+
+uniform float BumpDensity;     // = 16.0
+uniform float BumpSize;        // = 0.15
+uniform float SpecularFactor;  // = 0.5
+
+sampler2D Tex;
+
+void main()
+{
+    vec3 ambient = vec3(0.25);
+    vec3 litColor;
+    vec2 c = BumpDensity * gl_TexCoord[0].st;
+    vec2 p = fract(c) - vec2(0.5);
+
+    float d, f;
+    d = p.x * p.x + p.y * p.y;
+    f = inversesqrt(d + 1.0);
+
+    if (d >= BumpSize)
+        { p = vec2(0.0); f = 1.0; }
+
+    vec3 SurfaceColor = texture2D(Tex, gl_TexCoord[0].st).xyz;
+
+    vec3 normDelta = vec3(p.x, p.y, 1.0) * f;
+    litColor = SurfaceColor * (ambient + max(dot(normDelta, LightDir), 0.0));
+    vec3 reflectDir = reflect(LightDir, normDelta);
+    
+    float spec = max(dot(EyeDir, reflectDir), 0.0);
+    spec *= SpecularFactor;
+    litColor = min(litColor + spec, vec3(1.0));
+
+    gl_FragColor = vec4(litColor, 1.0);
+}
index a472d812526de0924d0490f1f0800a65f2cd00b5..a972d68bcfb0be13d99fa551e3a2bb5af48c7505 100644 (file)
@@ -31,7 +31,7 @@ void main()
     float iter;
 
 //    for (iter = 0.0; iter < MaxIterations && r2 < 4.0; ++iter)
-    for (iter = 0.0; iter < 12 && r2 < 4.0; ++iter)
+    for (iter = 0.0; iter < 12.0 && r2 < 4.0; ++iter)
     {
         float tempreal = real;
 
index 7a4549cd705e08e20ea2a269ab8427b954e04371..8f2ebcf69c42619ca85f96d5a2533334e784845b 100644 (file)
@@ -1,23 +1,5 @@
 Import('*')
 
-if not env['GLUT']:
-    Return()
-
-env = env.Clone()
-
-env.Prepend(CPPPATH = [
-       '../util',
-])
-
-env.Prepend(LIBS = [
-       util,
-       '$GLUT_LIB'
-])
-
-if env['platform'] == 'windows':
-    env.Append(CPPDEFINES = ['NOMINMAX'])
-    env.Prepend(LIBS = ['winmm'])
-
 progs = [
       'array',
       'bitmap',
@@ -48,7 +30,7 @@ progs = [
 ]
 
 for prog in progs:
-    env.Program(
+    progs_env.Program(
         target = prog,
         source = prog + '.c',
     )
index 87669aec736078cbf38b1c7738d31478769373b0..e31afab9392e4f78388446cc42306764661aa112 100644 (file)
 #include <GL/glew.h>
 #include <GL/glut.h>
 #include "shaderutil.h"
+#include "readtex.h"
 
 
 static char *FragProgFile = "CH11-bumpmap.frag";
+static char *FragTexProgFile = "CH11-bumpmaptex.frag";
 static char *VertProgFile = "CH11-bumpmap.vert";
+static char *TextureFile = "../images/tile.rgb";
 
 /* program/shader objects */
 static GLuint fragShader;
+static GLuint fragTexShader;
 static GLuint vertShader;
 static GLuint program;
+static GLuint texProgram;
 
 
 static struct uniform_info Uniforms[] = {
@@ -32,13 +37,26 @@ static struct uniform_info Uniforms[] = {
    END_OF_UNIFORMS
 };
 
+static struct uniform_info TexUniforms[] = {
+   { "LightPosition",  1, GL_FLOAT_VEC3, { 0.57737, 0.57735, 0.57735, 0.0 }, -1 },
+   { "Tex",            1, GL_INT,   { 0, 0, 0, 0 }, -1 },
+   { "BumpDensity",    1, GL_FLOAT, { 10.0, 0, 0, 0 }, -1 },
+   { "BumpSize",       1, GL_FLOAT, { 0.125, 0, 0, 0 }, -1 },
+   { "SpecularFactor", 1, GL_FLOAT, { 0.5, 0, 0, 0 }, -1 },
+   END_OF_UNIFORMS
+};
+
 static GLint win = 0;
 
 static GLfloat xRot = 20.0f, yRot = 0.0f, zRot = 0.0f;
 
-static GLuint tangentAttrib;
+static GLint tangentAttrib;
+static GLint tangentAttribTex;
+
+static GLuint Texture;
 
 static GLboolean Anim = GL_FALSE;
+static GLboolean Textured = GL_FALSE;
 
 
 static void
@@ -135,6 +153,11 @@ Redisplay(void)
    glRotatef(yRot, 0.0f, 1.0f, 0.0f);
    glRotatef(zRot, 0.0f, 0.0f, 1.0f);
 
+   if (Textured)
+      glUseProgram(texProgram);
+   else
+      glUseProgram(program);
+
    Cube(1.5);
 
    glPopMatrix();
@@ -163,8 +186,10 @@ static void
 CleanUp(void)
 {
    glDeleteShader(fragShader);
+   glDeleteShader(fragTexShader);
    glDeleteShader(vertShader);
    glDeleteProgram(program);
+   glDeleteProgram(texProgram);
    glutDestroyWindow(win);
 }
 
@@ -181,6 +206,9 @@ Key(unsigned char key, int x, int y)
       Anim = !Anim;
       glutIdleFunc(Anim ? Idle : NULL);
       break;
+   case 't':
+      Textured = !Textured;
+      break;
    case 'z':
       zRot += step;
       break;
@@ -254,6 +282,26 @@ Init(void)
 
    CheckError(__LINE__);
 
+
+   /*
+    * As above, but fragment shader also uses a texture map.
+    */
+   fragTexShader = CompileShaderFile(GL_FRAGMENT_SHADER, FragTexProgFile);
+   texProgram = LinkShaders(vertShader, fragTexShader);
+   glUseProgram(texProgram);
+   assert(glIsProgram(texProgram));
+   assert(glIsShader(fragTexShader));
+   SetUniformValues(texProgram, TexUniforms);
+   PrintUniforms(TexUniforms);
+
+   /*
+    * Load tex image.
+    */
+   glGenTextures(1, &Texture);
+   glBindTexture(GL_TEXTURE_2D, Texture);
+   LoadRGBMipmaps(TextureFile, GL_RGB);
+
+
    glClearColor(0.4f, 0.4f, 0.8f, 0.0f);
 
    glEnable(GL_DEPTH_TEST);
@@ -268,10 +316,13 @@ ParseOptions(int argc, char *argv[])
    int i;
    for (i = 1; i < argc; i++) {
       if (strcmp(argv[i], "-fs") == 0) {
-         FragProgFile = argv[i+1];
+         FragProgFile = argv[++i];
       }
       else if (strcmp(argv[i], "-vs") == 0) {
-         VertProgFile = argv[i+1];
+         VertProgFile = argv[++i];
+      }
+      else if (strcmp(argv[i], "-t") == 0) {
+         TextureFile = argv[++i];
       }
    }
 }
index c2fb76e1aa5a91737cf2bf0714b5c34a6c70e8f5..350e61bbdc5d08288f974b3b9da00fec07b04e43 100644 (file)
@@ -369,7 +369,7 @@ static void keyPress(unsigned char key, int x, int y)
    case 27:
       exit(0);
    default:
-      return;
+      break;
    }
    glutPostRedisplay();
 }
index 265a51571548b5bae3fefb4da59884af28f7ba39..588246b71ac6b2079fe4eaa2ad62ac4de1ed623b 100644 (file)
@@ -27,11 +27,15 @@ static GLuint SphereList, RectList, CurList;
 static GLint win = 0;
 static GLboolean anim = GL_TRUE;
 static GLfloat xRot = 0.0f, yRot = 0.0f;
+static GLint WinSize[2];
+static GLint WinSizeUniform = -1;
 
 
 static void
 Redisplay(void)
 {
+   glUniform2iv(WinSizeUniform, 1, WinSize);
+
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
    glPushMatrix();
@@ -55,6 +59,8 @@ Idle(void)
 static void
 Reshape(int width, int height)
 {
+   WinSize[0] = width;
+   WinSize[1] = height;
    glViewport(0, 0, width, height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
@@ -140,6 +146,7 @@ MakeSphere(void)
    glNewList(SphereList, GL_COMPILE);
    gluSphere(obj, 2.0f, 30, 15);
    glEndList();
+   gluDeleteQuadric(obj);
 }
 
 
@@ -162,8 +169,10 @@ static void
 Init(void)
 {
    static const char *fragShaderText =
+      "uniform ivec2 WinSize; \n"
       "void main() {\n"
-      "   gl_FragColor = abs(dFdy(gl_TexCoord[0])) * 50.0;\n"
+      "   vec2 d = dFdy(gl_TexCoord[0].xy) * vec2(WinSize); \n"
+      "   gl_FragColor =  vec4(d.x, d.y, 0.0, 1.0);\n"
       "  // gl_FragColor = gl_TexCoord[0];\n"
       "}\n";
    static const char *vertShaderText =
@@ -180,6 +189,7 @@ Init(void)
    program = LinkShaders(vertShader, fragShader);
 
    glUseProgram(program);
+   WinSizeUniform = glGetUniformLocation(program, "WinSize");
 
    /*assert(glGetError() == 0);*/
 
@@ -219,8 +229,10 @@ ParseOptions(int argc, char *argv[])
 int
 main(int argc, char *argv[])
 {
+   WinSize[0] = WinSize[1] = 200;
+
    glutInit(&argc, argv);
-   glutInitWindowSize(200, 200);
+   glutInitWindowSize(WinSize[0], WinSize[1]);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
    win = glutCreateWindow(argv[0]);
    glewInit();
index 0d4026e29cfdb2deca24de3b82140d815b982c4b..d504ba1cc4e55a2b7fcf4996612325295fb3fc75 100644 (file)
@@ -22,22 +22,22 @@ static const char *FragShaderText[ 4 ] = {
    "void main()\n"
    "{\n"
    "   gl_FragColor.rgb = noise3( gl_TexCoord[ 0 ].w ) * 0.5 + 0.5;\n"
-   "   gl_FragColor.a = 1;\n"
+   "   gl_FragColor.a = 1.0;\n"
    "}\n",
    "void main()\n"
    "{\n"
    "   gl_FragColor.rgb = noise3( gl_TexCoord[ 0 ].xw ) * 0.5 + 0.5;\n"
-   "   gl_FragColor.a = 1;\n"
+   "   gl_FragColor.a = 1.0;\n"
    "}\n",
    "void main()\n"
    "{\n"
    "   gl_FragColor.rgb = noise3( gl_TexCoord[ 0 ].xyw ) * 0.5 + 0.5;\n"
-   "   gl_FragColor.a = 1;\n"
+   "   gl_FragColor.a = 1.0;\n"
    "}\n",
    "void main()\n"
    "{\n"
    "   gl_FragColor.rgb = noise3( gl_TexCoord[ 0 ].xyzw ) * 0.5 + 0.5;\n"
-   "   gl_FragColor.a = 1;\n"
+   "   gl_FragColor.a = 1.0;\n"
    "}\n"
 };
     
@@ -125,6 +125,7 @@ Key(unsigned char key, int x, int y)
    case 'a':
       Anim = !Anim;
       glutIdleFunc(Anim ? Idle : NULL);
+      break;
    case 's':
       Slice -= step;
       break;
@@ -193,7 +194,7 @@ LoadAndCompileShader(GLuint shader, const char *text)
       GLchar log[1000];
       GLsizei len;
       glGetShaderInfoLog(shader, 1000, &len, log);
-      fprintf(stderr, "noise: problem compiling shader: %s\n", log);
+      fprintf(stderr, "multinoise: problem compiling shader: %s\n", log);
       exit(1);
    }
    else {
index bf46fd5210e2de044b6bcc64d51805514374974c..49b32253eed860a652cd19d6ae004a7ca5e93e1a 100644 (file)
@@ -369,12 +369,9 @@ InitPrograms(void)
 static void
 InitGL(void)
 {
-   const char *version = (const char *) glGetString(GL_VERSION);
+   if (!ShadersSupported())
+      exit(1);
 
-   if (version[0] != '2' || version[1] != '.') {
-      printf("Warning: this program expects OpenGL 2.0\n");
-      /*exit(1);*/
-   }
    printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
    printf("Usage:\n");
    printf("  a     - toggle arrays vs. immediate mode rendering\n");
index fdab263ea6a144503168058a55c51c7ff02c3ba8..1148580ff4d60e5e97332104b4e25d7a6b1a20cf 100644 (file)
@@ -28,7 +28,7 @@ static const char *FragShaderText =
    "   vec4 p;\n"
    "   p.xy = gl_TexCoord[0].xy;\n"
    "   p.z = Slice;\n"
-   "   p.w = 0;\n"
+   "   p.w = 0.0;\n"
    "   vec4 n = noise4(p * scale);\n"
    "   gl_FragColor = n * Scale + Bias;\n"
    "}\n";
@@ -119,6 +119,7 @@ Key(unsigned char key, int x, int y)
    case 'a':
       Anim = !Anim;
       glutIdleFunc(Anim ? Idle : NULL);
+      break;
    case 's':
       Slice -= step;
       break;
index 628a7dd5b98684b9d44ca438e1486d3b3d13c9f7..e9800c307f3f092b405fcd007493f3ef757b0911 100644 (file)
@@ -492,9 +492,8 @@ ReadConfigFile(const char *filename, struct config_file *conf)
    conf->num_uniforms = 0;
 
    /* ugly but functional parser */
-   while (!feof(f)) {
-      fgets(line, sizeof(line), f);
-      if (!feof(f) && line[0]) {
+   while (fgets(line, sizeof(line), f) != NULL) {
+      if (line[0]) {
          if (strncmp(line, "vs ", 3) == 0) {
             VertShaderFile = strdup(line + 3);
             VertShaderFile[strlen(VertShaderFile) - 1] = 0;
@@ -627,7 +626,7 @@ Init(void)
    NumAttribs = GetAttribs(Program, Attribs);
    PrintAttribs(Attribs);
 
-   //assert(glGetError() == 0);
+   /* assert(glGetError() == 0); */
 
    glClearColor(0.4f, 0.4f, 0.8f, 0.0f);
 
index 2e4f932ad6068707ac6e485c92de4dbd9d874c29..00edab731088fbf0f8573c461a9a41538874fbf8 100644 (file)
@@ -310,8 +310,8 @@ MakeMipmap(void)
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-   //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 4);
-   ////glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 5);
+   /* glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 4); */
+   /* glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 5); */
 
    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
 #undef SZ
index 5b1913a722ba5a5dbe2e5637e781261f7c74de3d..2076e6aef94508ea214f16cc5406a5b0dccf7ea1 100644 (file)
@@ -400,11 +400,8 @@ InitPrograms(void)
 static void
 Init(GLboolean useImageFiles)
 {
-   const char *version = (const char *) glGetString(GL_VERSION);
-
-   if (version[0] != '2' || version[1] != '.') {
-      printf("Warning: this program expects OpenGL 2.0\n");
-      /*exit(1);*/
+   if (!ShadersSupported()) {
+      exit(1);
    }
    printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
 
index 53bd91ef976f916c0f0d456bc95e7bacc62e04d5..857342636dc8ca41ab972f58b8b319ffacd1a543 100644 (file)
@@ -179,9 +179,9 @@ Init(void)
       "\n"
       "void main() {\n"
       "   vec2 p = gl_FragCoord.xy; \n"
-      "   if (crs(v1 - v0, p - v0) >= 0 && \n"
-      "       crs(v2 - v1, p - v1) >= 0 && \n"
-      "       crs(v0 - v2, p - v2) >= 0) \n"
+      "   if (crs(v1 - v0, p - v0) >= 0.0 && \n"
+      "       crs(v2 - v1, p - v1) >= 0.0 && \n"
+      "       crs(v0 - v2, p - v2) >= 0.0) \n"
       "      gl_FragColor = vec4(1.0); \n"
       "   else \n"
       "      gl_FragColor = vec4(0.5); \n"
index 4c8bfa587aaf9009234924e075a599190c4cdf63..2b93c78888940a9c9d788c0bb06ae8cceb78aaca 100644 (file)
@@ -40,15 +40,6 @@ static GLboolean Anim = GL_TRUE;
 static GLboolean WireFrame = GL_TRUE;
 static GLfloat xRot = -70.0f, yRot = 0.0f, zRot = 0.0f;
 
-
-/* value[0] = tex unit */
-static struct uniform_info Uniforms[] = {
-   { "tex1",  1, GL_SAMPLER_2D, { 0, 0, 0, 0 }, -1 },
-   END_OF_UNIFORMS
-};
-
-
-
 static void
 Idle(void)
 {
diff --git a/progs/objviewer/.gitignore b/progs/objviewer/.gitignore
new file mode 100644 (file)
index 0000000..ff094f8
--- /dev/null
@@ -0,0 +1,8 @@
+extfuncs.h
+objview
+readtex.c
+readtex.h
+shaderutil.c
+shaderutil.h
+trackball.c
+trackball.h
index 023ea02ae27021abbf97d81fda0556ac8d73beb9..f53515cb0a76397c9d605a7b22f91571b1e0ec97 100644 (file)
@@ -5,7 +5,7 @@ include $(TOP)/configs/current
 
 INCDIR = $(TOP)/include
 
-OSMESA_LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(OSMESA_LIB) $(APP_LIB_DEPS)
+OSMESA_LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -l$(OSMESA_LIB) $(APP_LIB_DEPS)
 
 OSMESA16_LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -lOSMesa16 -l$(GLU_LIB) \
        -l$(GL_LIB) $(APP_LIB_DEPS)
@@ -13,12 +13,6 @@ OSMESA16_LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -lOSMesa16 -l$(GLU_LIB) \
 OSMESA32_LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -lOSMesa32 -l$(GLU_LIB) \
        -l$(GL_LIB) $(APP_LIB_DEPS)
 
-LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \
-       $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
-
-LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) \
-       $(APP_LIB_DEPS)
-
 PROGS = \
        osdemo \
        ostest1
@@ -30,11 +24,6 @@ PROGS = \
 .SUFFIXES: .c
 
 
-# make executable from .c file:
-.c: $(LIB_DEP) readtex.o
-       $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< readtex.o $(LIBS) -o $@
-
-
 ##### TARGETS #####
 
 default: readtex.o $(PROGS)
diff --git a/progs/perf/.gitignore b/progs/perf/.gitignore
new file mode 100644 (file)
index 0000000..7e8fe61
--- /dev/null
@@ -0,0 +1,10 @@
+copytex
+drawoverhead
+fbobind
+fill
+genmipmap
+readpixels
+swapbuffers
+teximage
+vbo
+vertexrate
index a5ec9a7c2a064446c987490f937d521a1296cac0..691478ab64d83987b16e918c963bfc57551c6ed8 100644 (file)
@@ -1,11 +1,4 @@
-Import('env')
-
-if not env['GLUT']:
-    Return()
-
-env = env.Clone()
-
-env.Prepend(LIBS = ['$GLUT_LIB'])
+Import('*')
 
 progs = [
       'copytex',
@@ -21,7 +14,7 @@ progs = [
 ]
 
 for prog in progs:
-    env.Program(
+    progs_env.Program(
         target = prog,
         source = [
             prog + '.c',
index 4b7d6ad155b73b0cba0f113c3aa4c9dd61599ea3..20e2fa34107c398e2ea3cf4c45952dae710d8942 100644 (file)
@@ -27,6 +27,7 @@
  */
 
 #include <string.h>
+#include <stdio.h>
 #include "glmain.h"
 #include "common.h"
 
@@ -53,6 +54,11 @@ static const struct vertex vertices[1] = {
 void
 PerfInit(void)
 {
+   if (!PerfExtensionSupported("GL_ARB_framebuffer_object")) {
+      printf("Sorry, this test requires GL_ARB_framebuffer_object\n");
+      exit(1);
+   }
+
    /* setup VBO w/ vertex data */
    glGenBuffersARB(1, &VBO);
    glBindBufferARB(GL_ARRAY_BUFFER_ARB, VBO);
index cdae3486ce008e80cc2d9bb277673872ab0a16e0..49a5416787a6d7c1726281028467bc81931eeb22 100644 (file)
 #include "pipe/p_compiler.h"
 #include "pipe/p_format.h"
 #include "pipe/p_state.h"
+#include "util/u_format.h"
 #include "util/u_memory.h"
 #include "util/u_debug.h"
+#include "util/u_format.h"
 #include "util/u_network.h"
 #include "util/u_tile.h"
 
@@ -54,10 +56,7 @@ 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;
@@ -65,20 +64,17 @@ static void dump(unsigned width, unsigned height,
    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));
+      assert(src_stride >= util_format_get_stride(src_format, 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);
+      dst_stride = util_format_get_stride(dst_format, width);
+      dst_size = util_format_get_2d_size(dst_format, dst_stride, width);
       rgba = MALLOC(dst_size);
    }
 
    util_snprintf(filename, 512, "%s.bmp", pf_name(src_format));
 
-   if (pf_is_compressed(src_format)) {
+   if (util_format_is_compressed(src_format)) {
       debug_printf("skipping: %s\n", filename);
       return;
    }
index 04380c33109692a70b04917730ab604915592942..3a842c06c4e020fe110d0033f7ecae8c3b2da4f7 100644 (file)
@@ -29,7 +29,7 @@
 
 #include "rbug/rbug.h"
 
-static void wait()
+static void rbug_wait()
 {
    int s = u_socket_listen_on_port(13370);
    int c = u_socket_accept(s);
@@ -57,6 +57,6 @@ static void wait()
 
 int main(int argc, char** argv)
 {
-   wait();
+   rbug_wait();
    return 0;
 }
index f9e06ee994aa030c82d6ba3db49fc8e7590eb406..963f8eeedea684bfa4ba8666e6fe0207c4e7412e 100644 (file)
@@ -27,6 +27,7 @@
 #include "pipe/p_state.h"
 #include "util/u_memory.h"
 #include "util/u_debug.h"
+#include "util/u_format.h"
 #include "util/u_network.h"
 #include "util/u_tile.h"
 #include "rbug/rbug.h"
@@ -49,7 +50,7 @@ static void dump(rbug_texture_t tex,
    util_snprintf(filename, 512, "%llu_%s_%u.bmp",
                  (unsigned long long)tex, pf_name(info->format), mip);
 
-   if (pf_is_compressed(info->format)) {
+   if (util_format_is_compressed(info->format)) {
       debug_printf("skipping: %s\n", filename);
       return;
    }
index 242cb6647fc72f52b662076e4be640cb7d5b9921..24d7cff1b6755c98a68f2f34dc62236b6b54e122 100644 (file)
@@ -1,23 +1,5 @@
 Import('*')
 
-if not env['GLUT']:
-    Return()
-
-env = env.Clone()
-
-env.Prepend(CPPPATH = [
-       '../util',
-])
-
-env.Prepend(LIBS = [
-       util,
-       '$GLUT_LIB'
-])
-
-if env['platform'] == 'windows':
-    env.Append(CPPDEFINES = ['NOMINMAX'])
-    env.Prepend(LIBS = ['winmm'])
-
 progs = [
     'aaindex',
     'aapoly',
@@ -85,7 +67,7 @@ progs = [
 ]
 
 for prog in progs:
-    env.Program(
+    progs_env.Program(
         target = prog,
         source = prog + '.c',
     )
index 7dbc7b4b9b211d078d44baa4e414b4ac965c183a..6011ec44b677a4a25a803a5aae78ac51b9575a04 100644 (file)
@@ -56,7 +56,7 @@ static float rotAngle = 0.;
  *  at RAMP1START, and a blue color ramp starting
  *  at RAMP2START. The ramps must be a multiple of 16.
  */
-void init(void)
+static void init(void)
 {
    int i;
 
@@ -76,7 +76,7 @@ void init(void)
 
 /*  Draw 2 diagonal lines to form an X
  */
-void display(void)
+static void display(void)
 {
    glClear(GL_COLOR_BUFFER_BIT);
 
@@ -101,7 +101,7 @@ void display(void)
    glFlush();
 }
 
-void reshape(int w, int h)
+static void reshape(int w, int h)
 {
    glViewport(0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode(GL_PROJECTION);
@@ -117,7 +117,7 @@ void reshape(int w, int h)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 'r':
index 757f0f48c43278f8a94f0ec95bece2a0186cae1b..b7b2b270902f5cd792c3a7e0baaa79d16769163b 100644 (file)
@@ -59,7 +59,7 @@ static void init(void)
 
 #define NFACE 6
 #define NVERT 8
-void drawCube(GLdouble x0, GLdouble x1, GLdouble y0, GLdouble y1,
+static void drawCube(GLdouble x0, GLdouble x1, GLdouble y0, GLdouble y1,
         GLdouble z0, GLdouble z1)
 {
    static GLfloat v[8][3];
@@ -101,7 +101,7 @@ void drawCube(GLdouble x0, GLdouble x1, GLdouble y0, GLdouble y1,
 /*  Note:  polygons must be drawn from front to back
  *  for proper blending.
  */
-void display(void)
+static void display(void)
 {
    if (polySmooth) {
       glClear (GL_COLOR_BUFFER_BIT);
@@ -126,7 +126,7 @@ void display(void)
    glFlush ();
 }
 
-void reshape(int w, int h)
+static void reshape(int w, int h)
 {
    glViewport(0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode(GL_PROJECTION);
@@ -137,7 +137,7 @@ void reshape(int w, int h)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 't':
index f51984170e6811b607d627e67777c42044a76f75..0021b549c2e502c0f88353fd0dbacd8594bed4bb 100644 (file)
@@ -51,7 +51,7 @@ static float rotAngle = 0.;
  *  blending, hint, and line width.  Print out implementation
  *  specific info on line width granularity and width.
  */
-void init(void)
+static void init(void)
 {
    GLfloat values[2];
    glGetFloatv (GL_LINE_WIDTH_GRANULARITY, values);
@@ -72,7 +72,7 @@ void init(void)
 
 /* Draw 2 diagonal lines to form an X
  */
-void display(void)
+static void display(void)
 {
    glClear(GL_COLOR_BUFFER_BIT);
 
@@ -97,7 +97,7 @@ void display(void)
    glFlush();
 }
 
-void reshape(int w, int h)
+static void reshape(int w, int h)
 {
    glViewport(0, 0, w, h);
    glMatrixMode(GL_PROJECTION);
@@ -113,7 +113,7 @@ void reshape(int w, int h)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 'r':
index 12ca16f7a52d3841242adff9a3b5f594453e091c..d1b25678419fcf59ab1774dfde655366f2806fdc 100644 (file)
@@ -45,7 +45,7 @@
 
 /*  Initialize lighting and other values.
  */
-void myinit(void)
+static void myinit(void)
 {
     GLfloat mat_ambient[] = { 1.0, 1.0, 1.0, 1.0 };
     GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
@@ -68,7 +68,7 @@ void myinit(void)
     glClearAccum(0.0, 0.0, 0.0, 0.0);
 }
 
-void displayObjects(void)
+static void displayObjects(void)
 {
     GLfloat torus_diffuse[] = { 0.7, 0.7, 0.0, 1.0 };
     GLfloat cube_diffuse[] = { 0.0, 0.7, 0.7, 1.0 };
@@ -111,7 +111,7 @@ void displayObjects(void)
 
 #define ACSIZE 8
 
-void display(void)
+static void display(void)
 {
     GLint viewport[4];
     int jitter;
@@ -137,7 +137,7 @@ void display(void)
     glFlush();
 }
 
-void myReshape(int w, int h)
+static void myReshape(int w, int h)
 {
     glViewport(0, 0, w, h);
     glMatrixMode(GL_PROJECTION);
index 46e369ae631163a6c10d42d5a9deac3d6cb03510..e172d0a917f76a2806ca98e8a8016ee23bbb8808 100644 (file)
@@ -62,7 +62,7 @@
  * probably want to insure that your ModelView matrix has been 
  * initialized to identity before calling accFrustum().
  */
-void accFrustum(GLdouble left, GLdouble right, GLdouble bottom, 
+static void accFrustum(GLdouble left, GLdouble right, GLdouble bottom, 
    GLdouble top, GLdouble nnear, GLdouble ffar, GLdouble pixdx, 
    GLdouble pixdy, GLdouble eyedx, GLdouble eyedy, GLdouble focus)
 {
@@ -99,7 +99,7 @@ void accFrustum(GLdouble left, GLdouble right, GLdouble bottom,
  *
  * Note that accPerspective() calls accFrustum().
  */
-void accPerspective(GLdouble fovy, GLdouble aspect, 
+static void accPerspective(GLdouble fovy, GLdouble aspect, 
    GLdouble nnear, GLdouble ffar, GLdouble pixdx, GLdouble pixdy, 
    GLdouble eyedx, GLdouble eyedy, GLdouble focus)
 {
@@ -119,7 +119,7 @@ void accPerspective(GLdouble fovy, GLdouble aspect,
 
 /*  Initialize lighting and other values.
  */
-void init(void)
+static void init(void)
 {
    GLfloat mat_ambient[] = { 1.0, 1.0, 1.0, 1.0 };
    GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
@@ -141,7 +141,7 @@ void init(void)
    glClearAccum(0.0, 0.0, 0.0, 0.0);
 }
 
-void displayObjects(void) 
+static void displayObjects(void) 
 {
    GLfloat torus_diffuse[] = { 0.7, 0.7, 0.0, 1.0 };
    GLfloat cube_diffuse[] = { 0.0, 0.7, 0.7, 1.0 };
@@ -185,7 +185,7 @@ void displayObjects(void)
 
 #define ACSIZE 8
 
-void display(void)
+static void display(void)
 {
    GLint viewport[4];
    int jitter;
@@ -205,13 +205,13 @@ void display(void)
    glFlush();
 }
 
-void reshape(int w, int h)
+static void reshape(int w, int h)
 {
    glViewport(0, 0, (GLsizei) w, (GLsizei) h);
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 27:
index 6eeb45b96f1812dbba1d4df10c68c44630e475f2..b77c65e2c8346a5b5751e2a921cc1f3c0990894d 100644 (file)
@@ -80,7 +80,7 @@ static void drawRightTriangle(void)
    glEnd();
 }
 
-void display(void)
+static void display(void)
 {
    glClear(GL_COLOR_BUFFER_BIT);
 
@@ -96,7 +96,7 @@ void display(void)
    glFlush();
 }
 
-void reshape(int w, int h)
+static void reshape(int w, int h)
 {
    glViewport(0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode(GL_PROJECTION);
@@ -108,7 +108,7 @@ void reshape(int w, int h)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 't':
index 6169bd162beeed3dc67b0e63eb0ae432215dd2d5..494b1879d228fb002396300410cca4c7b449ff2f 100644 (file)
@@ -80,7 +80,7 @@ static void init(void)
    glEndList();
 }
 
-void display(void)
+static void display(void)
 {
    GLfloat mat_solid[] = { 0.75, 0.75, 0.0, 1.0 };
    GLfloat mat_zero[] = { 0.0, 0.0, 0.0, 1.0 };
@@ -113,7 +113,7 @@ void display(void)
    glutSwapBuffers();
 }
 
-void reshape(int w, int h)
+static void reshape(int w, int h)
 {
    glViewport(0, 0, (GLint) w, (GLint) h);
    glMatrixMode(GL_PROJECTION);
@@ -128,7 +128,7 @@ void reshape(int w, int h)
    glLoadIdentity();
 }
 
-void animate(void)
+static void animate(void)
 {
    static double t0 = -1.;
    if (solidZ <= MINZ || transparentZ >= MAXZ)
@@ -150,7 +150,7 @@ void animate(void)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 'a':
index 9eab0bc35111bc85da4a3a0d67a1869a3185a32f..a97a3ebc948c7ba54f58e68a915106a53629d18c 100644 (file)
@@ -49,7 +49,7 @@
  *  blending, hint, and line width.  Print out implementation
  *  specific info on line width granularity and width.
  */
-void myinit(void)
+static void myinit(void)
 {
     GLfloat values[2];
     glGetFloatv (GL_LINE_WIDTH_GRANULARITY, values);
@@ -73,7 +73,7 @@ void myinit(void)
 
 /*  display() draws an icosahedron with a large alpha value, 1.0.
  */
-void display(void)
+static void display(void)
 {
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     glColor4f (1.0, 1.0, 1.0, 1.0);
@@ -81,7 +81,7 @@ void display(void)
     glFlush();
 }
 
-void myReshape(int w, int h)
+static void myReshape(int w, int h)
 {
     glViewport(0, 0, w, h);
     glMatrixMode(GL_PROJECTION);
index 5dee440396b8a0973b2142931080dc9946640357..60a9c680802a802de9c12f0569f37467503db17a 100644 (file)
@@ -45,7 +45,7 @@ GLfloat ctrlpoints[4][3] = {
        { -4.0, -4.0, 0.0}, { -2.0, 4.0, 0.0}, 
        {2.0, -4.0, 0.0}, {4.0, 4.0, 0.0}};
 
-void init(void)
+static void init(void)
 {
    glClearColor(0.0, 0.0, 0.0, 0.0);
    glShadeModel(GL_FLAT);
@@ -53,7 +53,7 @@ void init(void)
    glEnable(GL_MAP1_VERTEX_3);
 }
 
-void display(void)
+static void display(void)
 {
    int i;
 
@@ -73,7 +73,7 @@ void display(void)
    glFlush();
 }
 
-void reshape(int w, int h)
+static void reshape(int w, int h)
 {
    glViewport(0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode(GL_PROJECTION);
@@ -89,7 +89,7 @@ void reshape(int w, int h)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 27:
index 55e7e827f2b4aa632e712ad1d9756560be0b9013..1abc7488bcb642da04174edf0449e0f6deea1d92 100644 (file)
@@ -68,7 +68,7 @@ GLfloat ctrlpoints[4][4][3] =
         {1.5, 1.5, -1.0}}
 };
 
-void
+static void
 initlights(void)
 {
     GLfloat ambient[] =
@@ -93,7 +93,7 @@ initlights(void)
     glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
 }
 
-void
+static void
 display(void)
 {
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -104,7 +104,7 @@ display(void)
     glFlush();
 }
 
-void
+static void
 myinit(void)
 {
     glClearColor(0.0, 0.0, 0.0, 1.0);
@@ -118,7 +118,7 @@ myinit(void)
     initlights();       /* for lighted version only */
 }
 
-void
+static void
 myReshape(int w, int h)
 {
     glViewport(0, 0, w, h);
index 06cbae7dd7eee193b8a8368a6d7030f6815c6e82..60e6f7b60c818e802d4c68844ec8fbac736345d4 100644 (file)
@@ -50,7 +50,7 @@
 #define        checkImageHeight 64
 GLubyte checkImage[checkImageWidth][checkImageHeight][3];
 
-void makeCheckImage(void)
+static void makeCheckImage(void)
 {
     int i, j, c;
 
@@ -64,7 +64,7 @@ void makeCheckImage(void)
     }
 }
 
-void myinit(void)
+static void myinit(void)
 {
     glClearColor (0.0, 0.0, 0.0, 0.0);
     glEnable(GL_DEPTH_TEST);
@@ -84,7 +84,7 @@ void myinit(void)
     glShadeModel(GL_FLAT);
 }
 
-void display(void)
+static void display(void)
 {
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     glBegin(GL_QUADS);
@@ -101,7 +101,7 @@ void display(void)
     glutSwapBuffers();
 }
 
-void myReshape(int w, int h)
+static void myReshape(int w, int h)
 {
     glViewport(0, 0, w, h);
     glMatrixMode(GL_PROJECTION);
index 90816f2e278cbb09bc7708bdb428b4c49f291ef6..85c464720db64a7776bd749afd36acd92962c958 100644 (file)
 #include <GL/glut.h>
 #include <stdlib.h>
 
-void init(void) 
+static void init(void) 
 {
    glClearColor (0.0, 0.0, 0.0, 0.0);
    glShadeModel (GL_FLAT);
 }
 
-void display(void)
+static void display(void)
 {
    GLdouble eqn[4] = {0.0, 1.0, 0.0, 0.0};
    GLdouble eqn2[4] = {1.0, 0.0, 0.0, 0.0};
@@ -73,7 +73,7 @@ void display(void)
    glFlush ();
 }
 
-void reshape (int w, int h)
+static void reshape (int w, int h)
 {
    glViewport (0, 0, (GLsizei) w, (GLsizei) h); 
    glMatrixMode (GL_PROJECTION);
@@ -83,7 +83,7 @@ void reshape (int w, int h)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 27:
index 9db4491bac5b5c41722b4681718570aff1f50607..d77fcb1ed46739d26945b49995bd86e0ea3bc725 100644 (file)
@@ -49,7 +49,7 @@ GLfloat diffuseMaterial[4] = { 0.5, 0.5, 0.5, 1.0 };
 /*  Initialize material property, light source, lighting model,
  *  and depth buffer.
  */
-void init(void) 
+static void init(void) 
 {
    GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
    GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 };
@@ -68,14 +68,14 @@ void init(void)
    glEnable(GL_COLOR_MATERIAL);
 }
 
-void display(void)
+static void display(void)
 {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glutSolidSphere(1.0, 20, 16);
    glFlush ();
 }
 
-void reshape (int w, int h)
+static void reshape (int w, int h)
 {
    glViewport (0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode (GL_PROJECTION);
@@ -91,7 +91,7 @@ void reshape (int w, int h)
 }
 
 /* ARGSUSED2 */
-void mouse(int button, int state, int x, int y)
+static void mouse(int button, int state, int x, int y)
 {
    switch (button) {
       case GLUT_LEFT_BUTTON:
@@ -127,7 +127,7 @@ void mouse(int button, int state, int x, int y)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 27:
index 5ecc6280f3315370107b407394ab8dce1c451402..3c6becb2157ed3b87c3f83fbd5d2cd2f97d7f665 100644 (file)
 #include <GL/glut.h>
 #include <stdlib.h>
 
-void init(void) 
+static void init(void) 
 {
    glClearColor (0.0, 0.0, 0.0, 0.0);
    glShadeModel (GL_FLAT);
 }
 
-void display(void)
+static void display(void)
 {
    glClear (GL_COLOR_BUFFER_BIT);
    glColor3f (1.0, 1.0, 1.0);
@@ -62,7 +62,7 @@ void display(void)
    glFlush ();
 }
 
-void reshape (int w, int h)
+static void reshape (int w, int h)
 {
    glViewport (0, 0, (GLsizei) w, (GLsizei) h); 
    glMatrixMode (GL_PROJECTION);
@@ -72,7 +72,7 @@ void reshape (int w, int h)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 27:
index a3e5b743aa724f366985b466dee2e2419ae1ac79..d4b604baf134271010b4517895b80e6c2cfac0e6 100644 (file)
@@ -48,7 +48,7 @@
 
 /*  Initialize linear fog for depth cueing.
  */
-void myinit(void)
+static void myinit(void)
 {
     GLfloat fogColor[4] = {0.0, 0.0, 0.0, 1.0};
 
@@ -67,7 +67,7 @@ void myinit(void)
 
 /*  display() draws an icosahedron.
  */
-void display(void)
+static void display(void)
 {
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     glColor3f (1.0, 1.0, 1.0);
@@ -75,7 +75,7 @@ void display(void)
     glFlush();
 }
 
-void myReshape(int w, int h)
+static void myReshape(int w, int h)
 {
     glViewport(0, 0, w, h);
     glMatrixMode(GL_PROJECTION);
index 6673dc2d54f7284a0f6e3741f052a24b18903b57..8558f02deea0e8c39eeaf1c9669dacbf5417b677 100644 (file)
@@ -68,7 +68,7 @@
  *  probably want to insure that your ModelView matrix has been
  *  initialized to identity before calling accFrustum().
  */
-void accFrustum(GLdouble left, GLdouble right, GLdouble bottom,
+static void accFrustum(GLdouble left, GLdouble right, GLdouble bottom,
     GLdouble top, GLdouble nnear, GLdouble ffar, GLdouble pixdx,
     GLdouble pixdy, GLdouble eyedx, GLdouble eyedy, GLdouble focus)
 {
@@ -105,7 +105,7 @@ void accFrustum(GLdouble left, GLdouble right, GLdouble bottom,
  *
  *  Note that accPerspective() calls accFrustum().
  */
-void accPerspective(GLdouble fovy, GLdouble aspect,
+static void accPerspective(GLdouble fovy, GLdouble aspect,
     GLdouble nnear, GLdouble ffar, GLdouble pixdx, GLdouble pixdy,
     GLdouble eyedx, GLdouble eyedy, GLdouble focus)
 {
@@ -123,7 +123,7 @@ void accPerspective(GLdouble fovy, GLdouble aspect,
        pixdx, pixdy, eyedx, eyedy, focus);
 }
 
-void myinit(void)
+static void myinit(void)
 {
     GLfloat ambient[] = { 0.0, 0.0, 0.0, 1.0 };
     GLfloat diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
@@ -155,7 +155,7 @@ void myinit(void)
     glClearAccum(0.0, 0.0, 0.0, 0.0);
 }
 
-void renderTeapot (GLfloat x, GLfloat y, GLfloat z,
+static void renderTeapot (GLfloat x, GLfloat y, GLfloat z,
     GLfloat ambr, GLfloat ambg, GLfloat ambb,
     GLfloat difr, GLfloat difg, GLfloat difb,
     GLfloat specr, GLfloat specg, GLfloat specb, GLfloat shine)
@@ -182,7 +182,7 @@ void renderTeapot (GLfloat x, GLfloat y, GLfloat z,
  *  magnitude of the accPerspective() jitter; in this example, 0.33.
  *  In this example, the teapots are drawn 8 times.  See jitter.h
  */
-void display(void)
+static void display(void)
 {
     int jitter;
     GLint viewport[4];
@@ -214,7 +214,7 @@ void display(void)
     glFlush();
 }
 
-void myReshape(int w, int h)
+static void myReshape(int w, int h)
 {
     glViewport(0, 0, w, h);
 }
index 3153c70cc1d60c7b99d13ca1d608d1d15e30d165..c4ead224dc8b1d91d8757407fcbda4efcac8727e 100644 (file)
@@ -47,7 +47,7 @@
 static GLfloat spin = 0.0;
 static GLdouble t0 = 0.;
 
-void display(void)
+static void display(void)
 {
    glClear(GL_COLOR_BUFFER_BIT);
    glPushMatrix();
@@ -59,12 +59,12 @@ void display(void)
    glutSwapBuffers();
 }
 
-GLdouble gettime(void)
+static GLdouble gettime(void)
 {
     return (GLdouble)(glutGet(GLUT_ELAPSED_TIME)) / 1000.;
 }
 
-void spinDisplay(void)
+static void spinDisplay(void)
 {
    GLdouble t, dt;
    t = gettime();
@@ -76,13 +76,13 @@ void spinDisplay(void)
    glutPostRedisplay();
 }
 
-void init(void)
+static void init(void)
 {
    glClearColor (0.0, 0.0, 0.0, 0.0);
    glShadeModel (GL_FLAT);
 }
 
-void reshape(int w, int h)
+static void reshape(int w, int h)
 {
    glViewport (0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode(GL_PROJECTION);
@@ -93,7 +93,7 @@ void reshape(int w, int h)
 }
 
 /* ARGSUSED2 */
-void mouse(int button, int state, int x, int y)
+static void mouse(int button, int state, int x, int y)
 {
    switch (button) {
       case GLUT_LEFT_BUTTON:
index 5bcccb6aeac3ed555c6f79318d1a5a1a871fd2a7..6c048be784492fd8745abc85c31444187a80d57e 100644 (file)
@@ -48,13 +48,13 @@ GLubyte rasters[24] = {
    0xff, 0x00, 0xff, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00,
    0xff, 0xc0, 0xff, 0xc0};
 
-void init(void)
+static void init(void)
 {
    glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
    glClearColor (0.0, 0.0, 0.0, 0.0);
 }
 
-void display(void)
+static void display(void)
 {
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f (1.0, 1.0, 1.0);
@@ -65,7 +65,7 @@ void display(void)
    glFlush();
 }
 
-void reshape(int w, int h)
+static void reshape(int w, int h)
 {
    glViewport(0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode(GL_PROJECTION);
@@ -75,7 +75,7 @@ void reshape(int w, int h)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 27:
index cc685d55d34d7a5c837f4ff2c892d2772f745ed0..3c8c8cc7eaf90532b3503b74cb77f722f08d79d9 100644 (file)
@@ -48,7 +48,7 @@
 
 /*  Initialize lighting.
  */
-void init(void)
+static void init(void)
 {
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
@@ -58,7 +58,7 @@ void init(void)
  * be clipped.  If in feedback mode, a passthrough token 
  * is issued between the each primitive.
  */
-void drawGeometry (GLenum mode)
+static void drawGeometry (GLenum mode)
 {
    glBegin (GL_LINE_STRIP);
    glNormal3f (0.0, 0.0, 1.0);
@@ -80,8 +80,8 @@ void drawGeometry (GLenum mode)
 }
 
 /* Write contents of one vertex to stdout.     */
-void print3DcolorVertex (GLint size, GLint *count, 
-                         GLfloat *buffer)
+static void print3DcolorVertex (GLint size, GLint *count, 
+                                GLfloat *buffer)
 {
    int i;
 
@@ -94,7 +94,7 @@ void print3DcolorVertex (GLint size, GLint *count,
 }
 
 /*  Write contents of entire buffer.  (Parse tokens!)  */
-void printBuffer(GLint size, GLfloat *buffer)
+static void printBuffer(GLint size, GLfloat *buffer)
 {
    GLint count;
    GLfloat token;
@@ -124,7 +124,7 @@ void printBuffer(GLint size, GLfloat *buffer)
    }
 }
 
-void display(void)
+static void display(void)
 {
    GLfloat feedBuffer[1024];
    GLint size;
@@ -148,7 +148,7 @@ void display(void)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 27:
index 14c7700eccfe960f4413fc73247807b8e816c725..4f4b8e3cc0af26b8a85ac1760b226f9e9f62ad84 100644 (file)
@@ -52,7 +52,7 @@
 
 GLint fogMode;
 
-void
+static void
 selectFog(int mode)
 {
     switch(mode) {
@@ -73,7 +73,7 @@ selectFog(int mode)
 /*  Initialize z-buffer, projection matrix, light source,
  *  and lighting model.  Do not specify a material property here.
  */
-void
+static void
 myinit(void)
 {
     GLfloat position[] =
@@ -106,7 +106,7 @@ myinit(void)
     }
 }
 
-void
+static void
 renderRedTeapot(GLfloat x, GLfloat y, GLfloat z)
 {
     float mat[4];
@@ -133,7 +133,7 @@ renderRedTeapot(GLfloat x, GLfloat y, GLfloat z)
 
 /*  display() draws 5 teapots at different z positions.
  */
-void
+static void
 display(void)
 {
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -145,7 +145,7 @@ display(void)
     glFlush();
 }
 
-void
+static void
 myReshape(int w, int h)
 {
     glViewport(0, 0, w, h);
index b8bb691e2886fb38023b5efc023209137bc61b2b..6b5aa353caa070ced5daaf6858a7a5304b942a8f 100644 (file)
@@ -53,7 +53,7 @@
 #define NUM_COLORS 32
 #define RAMPSTART 16
 
-void
+static void
 myinit(void)
 {
   int i;
@@ -77,7 +77,7 @@ myinit(void)
 
 /*  display() renders 3 cones at different z positions.
  */
-void
+static void
 display(void)
 {
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -104,7 +104,7 @@ display(void)
   glFlush();
 }
 
-void
+static void
 myReshape(int w, int h)
 {
   glViewport(0, 0, w, h);
index 2d92e9b600395bb5eda9b2c2b45274abe16f6707..c7a1035aa99ae1ef66151f40725e920cfebf7bbc 100644 (file)
@@ -80,7 +80,7 @@ GLubyte letters[][13] = {
 
 GLuint fontOffset;
 
-void makeRasterFont(void)
+static void makeRasterFont(void)
 {
    GLuint i, j;
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
@@ -96,13 +96,13 @@ void makeRasterFont(void)
    glEndList();
 }
 
-void init(void)
+static void init(void)
 {
    glShadeModel (GL_FLAT);
    makeRasterFont();
 }
 
-void printString(char *s)
+static void printString(char *s)
 {
    glPushAttrib (GL_LIST_BIT);
    glListBase(fontOffset);
@@ -115,7 +115,7 @@ void printString(char *s)
  * to call makeRasterFont() before you start making 
  * calls to printString().
  */
-void display(void)
+static void display(void)
 {
    GLfloat white[3] = { 1.0, 1.0, 1.0 };
 
@@ -129,7 +129,7 @@ void display(void)
    glFlush ();
 }
 
-void reshape(int w, int h)
+static void reshape(int w, int h)
 {
    glViewport(0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode(GL_PROJECTION);
@@ -139,7 +139,7 @@ void reshape(int w, int h)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 27:
index fb3dae13252abdec3fe7175d34bd7a9358cd170e..84183b25b9fa1096a8f8840dcbccabb484380f56 100644 (file)
@@ -42,7 +42,7 @@
 #include <stdlib.h>
 #include <GL/glut.h>
 
-void display(void)
+static void display(void)
 {
 /* clear all pixels  */
    glClear (GL_COLOR_BUFFER_BIT);
@@ -64,7 +64,7 @@ void display(void)
    glFlush ();
 }
 
-void init (void)
+static void init (void)
 {
 /* select clearing color       */
    glClearColor (0.0, 0.0, 0.0, 0.0);
index dc1a7246eba9a11c61678f5ee36963634f616487..fa3b46f5ed4464b805e84ce69a943b98ad65bea7 100644 (file)
@@ -58,7 +58,7 @@ GLubyte checkImage[checkImageHeight][checkImageWidth][3];
 static GLdouble zoomFactor = 1.0;
 static GLint height;
 
-void makeCheckImage(void)
+static void makeCheckImage(void)
 {
    int i, j, c;
     
@@ -72,7 +72,7 @@ void makeCheckImage(void)
    }
 }
 
-void init(void)
+static void init(void)
 {    
    glClearColor (0.0, 0.0, 0.0, 0.0);
    glShadeModel(GL_FLAT);
@@ -80,7 +80,7 @@ void init(void)
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
 }
 
-void display(void)
+static void display(void)
 {
    glClear(GL_COLOR_BUFFER_BIT);
    glRasterPos2i(0, 0);
@@ -89,7 +89,7 @@ void display(void)
    glFlush();
 }
 
-void reshape(int w, int h)
+static void reshape(int w, int h)
 {
    glViewport(0, 0, (GLsizei) w, (GLsizei) h);
    height = (GLint) h;
@@ -100,7 +100,7 @@ void reshape(int w, int h)
    glLoadIdentity();
 }
 
-void motion(int x, int y)
+static void motion(int x, int y)
 {
    static GLint screeny;
    
@@ -113,7 +113,7 @@ void motion(int x, int y)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 'r':
index 0eed85e10c2043cd71eecab10a096ccd189589e6..9431dce508e19eafe20d983dcd55b986a756a585 100644 (file)
@@ -47,7 +47,7 @@
 /*  Initialize material property, light source, lighting model,
  *  and depth buffer.
  */
-void init(void) 
+static void init(void) 
 {
    GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
    GLfloat mat_shininess[] = { 50.0 };
@@ -65,14 +65,14 @@ void init(void)
    glEnable(GL_DEPTH_TEST);
 }
 
-void display(void)
+static void display(void)
 {
    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glutSolidSphere (1.0, 20, 16);
    glFlush ();
 }
 
-void reshape (int w, int h)
+static void reshape (int w, int h)
 {
    glViewport (0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode (GL_PROJECTION);
@@ -88,7 +88,7 @@ void reshape (int w, int h)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 27:
index b34d4c418c698baa7a58685879a945de55bc7dc0..9f12da9acfebaea1453467197b350485679e6661 100644 (file)
 #define drawOneLine(x1,y1,x2,y2)  glBegin(GL_LINES);  \
    glVertex2f ((x1),(y1)); glVertex2f ((x2),(y2)); glEnd();
 
-void init(void) 
+static void init(void) 
 {
    glClearColor (0.0, 0.0, 0.0, 0.0);
    glShadeModel (GL_FLAT);
 }
 
-void display(void)
+static void display(void)
 {
    int i;
 
@@ -104,7 +104,7 @@ void display(void)
    glFlush ();
 }
 
-void reshape (int w, int h)
+static void reshape (int w, int h)
 {
    glViewport (0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode (GL_PROJECTION);
@@ -113,7 +113,7 @@ void reshape (int w, int h)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 27:
index 3b4f44bd6dace54a744098816b7286ca7e892be2..5dea26fcad129bd946a1251c5cb416ec1177002a 100644 (file)
@@ -69,7 +69,7 @@ static void drawLine (void)
    glEnd ();
 }
 
-void display(void)
+static void display(void)
 {
    GLuint i;
 
@@ -82,7 +82,7 @@ void display(void)
    glFlush ();
 }
 
-void reshape(int w, int h)
+static void reshape(int w, int h)
 {
    glViewport(0, 0, w, h);
    glMatrixMode(GL_PROJECTION);
@@ -97,7 +97,7 @@ void reshape(int w, int h)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 27:
index f9a4fc59288a1898b2b7183f1c48dec4579894e9..5edddd9ef8420f51722c599c59190e4fdb2839ef 100644 (file)
@@ -49,7 +49,7 @@
 /*  Initialize z-buffer, projection matrix, light source,
  *  and lighting model.  Do not specify a material property here.
  */
-void myinit(void)
+static void myinit(void)
 {
     GLfloat ambient[] = { 0.0, 0.0, 0.0, 1.0 };
     GLfloat diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
@@ -87,7 +87,7 @@ void myinit(void)
  *  glTranslatef() is used to move spheres to their appropriate locations.
  */
 
-void display(void)
+static void display(void)
 {
     GLfloat no_mat[] = { 0.0, 0.0, 0.0, 1.0 };
     GLfloat mat_ambient[] = { 0.7, 0.7, 0.7, 1.0 };
@@ -260,7 +260,7 @@ void display(void)
     glFlush();
 }
 
-void myReshape(int w, int h)
+static void myReshape(int w, int h)
 {
     glViewport(0, 0, w, h);
     glMatrixMode(GL_PROJECTION);
index d32dd725f4b432005650695672007e21ab847b53..dadde055bef3d9a8b6bd1edca42bf51902e2afd9 100644 (file)
@@ -54,7 +54,7 @@ GLubyte mipmapImage4[4][4][3];
 GLubyte mipmapImage2[2][2][3];
 GLubyte mipmapImage1[1][1][3];
 
-void makeImages(void)
+static void makeImages(void)
 {
     int i, j;
 
@@ -98,7 +98,7 @@ void makeImages(void)
     mipmapImage1[0][0][2] = 255;
 }
 
-void myinit(void)
+static void myinit(void)
 {
     glEnable(GL_DEPTH_TEST);
     glDepthFunc(GL_LESS);
@@ -128,7 +128,7 @@ void myinit(void)
     glEnable(GL_TEXTURE_2D);
 }
 
-void display(void)
+static void display(void)
 {
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     glBegin(GL_QUADS);
@@ -140,7 +140,7 @@ void display(void)
     glFlush();
 }
 
-void myReshape(int w, int h)
+static void myReshape(int w, int h)
 {
     glViewport(0, 0, w, h);
     glMatrixMode(GL_PROJECTION);
index 8411ef355f12688c5fe816743f752bd8cf95c638..f7c92f4f87caf9e7f067d633d60fa1562353e269 100644 (file)
 #include <GL/glut.h>
 #include <stdlib.h>
 
-void init(void) 
+static void init(void) 
 {
    glClearColor (0.0, 0.0, 0.0, 0.0);
    glShadeModel (GL_FLAT);
 }
 
-void draw_triangle(void)
+static void draw_triangle(void)
 {
    glBegin (GL_LINE_LOOP);
    glVertex2f(0.0, 25.0);
@@ -57,7 +57,7 @@ void draw_triangle(void)
    glEnd();
 }
 
-void display(void)
+static void display(void)
 {
    glClear (GL_COLOR_BUFFER_BIT);
    glColor3f (1.0, 1.0, 1.0);
@@ -86,7 +86,7 @@ void display(void)
    glFlush ();
 }
 
-void reshape (int w, int h)
+static void reshape (int w, int h)
 {
    glViewport (0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode (GL_PROJECTION);
@@ -101,7 +101,7 @@ void reshape (int w, int h)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 27:
index a108cad439aa4c04ec6ca715d872f101fa5723ce..93758a222a430f9a6b1a2b3fb1bbb353e18f0fed 100644 (file)
@@ -58,7 +58,7 @@ static int spin = 0;
 /*  Initialize material property, light source, lighting model,
  *  and depth buffer.
  */
-void init(void) 
+static void init(void) 
 {
    glClearColor (0.0, 0.0, 0.0, 0.0);
    glShadeModel (GL_SMOOTH);
@@ -72,7 +72,7 @@ void init(void)
  *  light at a new position in world coordinates.  The cube
  *  represents the position of the light.
  */
-void display(void)
+static void display(void)
 {
    GLfloat position[] = { 0.0, 0.0, 1.5, 1.0 };
 
@@ -96,7 +96,7 @@ void display(void)
    glFlush ();
 }
 
-void reshape (int w, int h)
+static void reshape (int w, int h)
 {
    glViewport (0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode (GL_PROJECTION);
@@ -107,7 +107,7 @@ void reshape (int w, int h)
 }
 
 /* ARGSUSED2 */
-void mouse(int button, int state, int x, int y)
+static void mouse(int button, int state, int x, int y)
 {
    switch (button) {
       case GLUT_LEFT_BUTTON:
@@ -122,7 +122,7 @@ void mouse(int button, int state, int x, int y)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 27:
index a7c6f0c696e348dcf8ae90d001fbdc1ea21a62f7..fe03ce667ed796dfe54bfdb77d409464f02c0a84 100644 (file)
@@ -89,7 +89,7 @@ GLUnurbsObj *theNurb;
 /*  Initialize material property, light source, lighting model,
  *  and depth buffer.
  */
-void myinit(void)
+static void myinit(void)
 {
     GLfloat mat_ambient[] = { 1.0, 1.0, 1.0, 1.0 };
     GLfloat mat_diffuse[] = { 1.0, 0.2, 1.0, 1.0 };
@@ -122,7 +122,7 @@ void myinit(void)
     gluNurbsProperty(theNurb, GLU_DISPLAY_MODE, GLU_FILL);
 }
 
-void display(void)
+static void display(void)
 {
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
@@ -147,7 +147,7 @@ void display(void)
     glFlush();
 }
 
-void myReshape(int w, int h)
+static void myReshape(int w, int h)
 {
     glViewport(0, 0, w, h);
     glMatrixMode(GL_PROJECTION);
index ad5bdc81994cb6466a07e69dc305cd6b24124e57..91d44a38c0a5fdd494a1e1ac483f307632485d75 100644 (file)
@@ -51,7 +51,7 @@
 #include <stdio.h>
 #include <GL/glut.h>
 
-void
+static void
 myinit(void)
 {
   glClearColor(0.0, 0.0, 0.0, 0.0);
@@ -65,7 +65,7 @@ myinit(void)
  *  each rectangle is given the same name.  Note that
  *  each rectangle is drawn with a different z value.
  */
-void
+static void
 drawRects(GLenum mode)
 {
   if (mode == GL_SELECT)
@@ -100,7 +100,7 @@ drawRects(GLenum mode)
 /*  processHits() prints out the contents of the
  *  selection array.
  */
-void
+static void
 processHits(GLint hits, GLuint buffer[])
 {
   GLint i;
@@ -131,7 +131,7 @@ processHits(GLint hits, GLuint buffer[])
  */
 #define BUFSIZE 512
 
-void
+static void
 pickRects(int button, int state, int x, int y)
 {
   GLuint selectBuf[BUFSIZE];
@@ -164,7 +164,7 @@ pickRects(int button, int state, int x, int y)
   processHits(hits, selectBuf);
 }
 
-void
+static void
 display(void)
 {
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -172,7 +172,7 @@ display(void)
   glutSwapBuffers();
 }
 
-void
+static void
 myReshape(int w, int h)
 {
   glViewport(0, 0, w, h);
index 636edc97b4bf181af212b5335aee91b56f526770..cc092dbf53803112765bb81b30142caecb830346 100644 (file)
@@ -49,7 +49,7 @@
 int board[3][3];   /*  amount of color for each square */
 
 /*  Clear color value for every square on the board   */
-void init(void)
+static void init(void)
 {
    int i, j;
    for (i = 0; i < 3; i++) 
@@ -64,7 +64,7 @@ void init(void)
  *  square is determined by its position on the grid, and 
  *  the value in the board[][] array.
  */
-void drawSquares(GLenum mode)
+static void drawSquares(GLenum mode)
 {
    GLuint i, j;
    for (i = 0; i < 3; i++) {
@@ -85,7 +85,7 @@ void drawSquares(GLenum mode)
 /*  processHits prints out the contents of the 
  *  selection array.
  */
-void processHits (GLint hits, GLuint buffer[])
+static void processHits (GLint hits, GLuint buffer[])
 {
    GLint i;
    GLuint j, ii = 0, jj = 0, names, *ptr;
@@ -117,7 +117,7 @@ void processHits (GLint hits, GLuint buffer[])
  */
 #define BUFSIZE 512
 
-void pickSquares(int button, int state, int x, int y)
+static void pickSquares(int button, int state, int x, int y)
 {
    GLuint selectBuf[BUFSIZE];
    GLint hits;
@@ -152,14 +152,14 @@ void pickSquares(int button, int state, int x, int y)
    glutPostRedisplay();
 } 
 
-void display(void)
+static void display(void)
 {
    glClear(GL_COLOR_BUFFER_BIT);
    drawSquares (GL_RENDER);
    glFlush();
 }
 
-void reshape(int w, int h)
+static void reshape(int w, int h)
 {
    glViewport(0, 0, w, h);
    glMatrixMode(GL_PROJECTION);
@@ -170,7 +170,7 @@ void reshape(int w, int h)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 27:
index dc17f7b2386710a6fa7bdd9d319bf1783d474638..2c2e2d24d937edfeb2176ccf07444b4af76df4df 100644 (file)
@@ -47,7 +47,7 @@
 
 /*  Initialize material property, light source, and lighting model.
  */
-void myinit(void)
+static void myinit(void)
 {
     GLfloat mat_ambient[] = { 0.0, 0.0, 0.0, 1.0 };
 /*   mat_specular and mat_shininess are NOT default values     */
@@ -75,7 +75,7 @@ void myinit(void)
     glEnable(GL_DEPTH_TEST);
 }
 
-void drawPlane(void)
+static void drawPlane(void)
 {
     glBegin (GL_QUADS);
     glNormal3f (0.0, 0.0, 1.0);
@@ -104,7 +104,7 @@ void drawPlane(void)
     glEnd();
 }
 
-void display (void)
+static void display (void)
 {
     GLfloat infinite_light[] = { 1.0, 1.0, 1.0, 0.0 };
     GLfloat local_light[] = { 1.0, 1.0, 1.0, 1.0 };
@@ -125,7 +125,7 @@ void display (void)
     glFlush ();
 }
 
-void myReshape(int w, int h)
+static void myReshape(int w, int h)
 {
     glViewport (0, 0, w, h);
     glMatrixMode (GL_PROJECTION);
index e13672d3f631cf6aa464651a7c4914e5df73bb0a..cc428b4e4275438e220ff0db59e366a14ee4929a 100644 (file)
 
 static int year = 0, day = 0;
 
-void init(void) 
+static void init(void) 
 {
    glClearColor (0.0, 0.0, 0.0, 0.0);
    glShadeModel (GL_FLAT);
 }
 
-void display(void)
+static void display(void)
 {
    glClear (GL_COLOR_BUFFER_BIT);
    glColor3f (1.0, 1.0, 1.0);
@@ -68,7 +68,7 @@ void display(void)
    glutSwapBuffers();
 }
 
-void reshape (int w, int h)
+static void reshape (int w, int h)
 {
    glViewport (0, 0, (GLsizei) w, (GLsizei) h); 
    glMatrixMode (GL_PROJECTION);
@@ -80,7 +80,7 @@ void reshape (int w, int h)
 }
 
 /* ARGSUSED1 */
-void keyboard (unsigned char key, int x, int y)
+static void keyboard (unsigned char key, int x, int y)
 {
    switch (key) {
       case 'd':
index de34b2e7675b2d55cf769631a176fc679e7f1688..0e0ce86ec91c74a1c6df02bcde55904f05b48f9b 100644 (file)
@@ -60,7 +60,7 @@ GLboolean doubleBuffer;
 /*  display() draws two spheres, one with a gray, diffuse material,
  *  the other sphere with a magenta material with a specular highlight.
  */
-void display (void)
+static void display (void)
 {
     GLfloat gray[] = { 0.8, 0.8, 0.8, 1.0 };
     GLfloat black[] = { 0.0, 0.0, 0.0, 1.0 };
@@ -108,7 +108,7 @@ void display (void)
  *  create display list with sphere
  *  initialize lighting and depth buffer
  */
-void gfxinit (void)
+static void gfxinit (void)
 {
     GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 };
     GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
@@ -134,7 +134,7 @@ void gfxinit (void)
 }
 
 /*  call when window is resized  */
-void reshape(int width, int height)
+static void reshape(int width, int height)
 {
     glViewport (0, 0, width, height);
     glMatrixMode (GL_PROJECTION);
@@ -176,7 +176,7 @@ static void Benchmark( float xdiff, float ydiff )
 
 /*  call when mouse button is pressed  */
 /* ARGSUSED2 */
-void mouse(int button, int state, int x, int y) {
+static void mouse(int button, int state, int x, int y) {
     switch (button) {
        case GLUT_LEFT_BUTTON:
            switch (state) {
@@ -213,7 +213,7 @@ void mouse(int button, int state, int x, int y) {
 }
 
 /* ARGSUSED1 */
-void keyboard (unsigned char key, int x, int y)
+static void keyboard (unsigned char key, int x, int y)
 {
    switch (key) {
       case 't':
@@ -268,20 +268,7 @@ void keyboard (unsigned char key, int x, int y)
    fflush(stdout);
 }
 
-static void
-key(unsigned char k, int x, int y)
-{
-  switch (k) {
-  case 27:  /* Escape */
-    exit(0);
-    break;
-  default:
-    return;
-  }
-  glutPostRedisplay();
-}
-
-GLenum Args(int argc, char **argv)
+static GLenum Args(int argc, char **argv)
 {
     GLint i;
 
index 409abd1753181b6989d9bfa37b527cd486536517..eeffe2301ce4c0639dc9a740cc128150e85ec571 100644 (file)
@@ -44,7 +44,7 @@
 #include <stdlib.h>
 #include <GL/glut.h>
 
-void display(void)
+static void display(void)
 {
     GLubyte fly[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 0x03, 0x80, 0x01, 0xC0, 0x06, 0xC0, 0x03, 0x60, 0x04, 0x60, 0x06, 0x20,
@@ -89,7 +89,7 @@ void display(void)
     glFlush ();
 }
 
-void myinit (void)
+static void myinit (void)
 {
 /*  clear background to black  */
     glClearColor (0.0, 0.0, 0.0, 0.0);
index 4e46c85f829a33de13441ee44534595932c16d84..1cbd395e47be5959f766100a42d00e1fb695f8c1 100644 (file)
@@ -54,7 +54,7 @@
 
 GLuint startList;
 
-void CALLBACK errorCallback(GLenum errorCode)
+static void CALLBACK errorCallback(GLenum errorCode)
 {
    const GLubyte *estring;
 
@@ -63,7 +63,7 @@ void CALLBACK errorCallback(GLenum errorCode)
    exit(0);
 }
 
-void init(void) 
+static void init(void) 
 {
    GLUquadricObj *qobj;
    GLfloat mat_ambient[] = { 0.5, 0.5, 0.5, 1.0 };
@@ -116,9 +116,11 @@ void init(void)
    glNewList(startList+3, GL_COMPILE);
       gluPartialDisk(qobj, 0.0, 1.0, 20, 4, 0.0, 225.0);
    glEndList();
+
+   gluDeleteQuadric(qobj);
 }
 
-void display(void)
+static void display(void)
 {
    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
@@ -148,7 +150,7 @@ void display(void)
    glFlush();
 }
 
-void reshape (int w, int h)
+static void reshape (int w, int h)
 {
    glViewport(0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode(GL_PROJECTION);
@@ -164,7 +166,7 @@ void reshape (int w, int h)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 27:
index 94e20ac71eb08b9bf96f9a50d3f3019654984c22..c90b72ab3ea3605362fd529c4819a2988ec510e8 100644 (file)
 
 static int shoulder = 0, elbow = 0;
 
-void init(void) 
+static void init(void) 
 {
   glClearColor (0.0, 0.0, 0.0, 0.0);
   glShadeModel (GL_FLAT);
 }
 
-void display(void)
+static void display(void)
 {
    glClear (GL_COLOR_BUFFER_BIT);
    glPushMatrix();
@@ -77,7 +77,7 @@ void display(void)
    glutSwapBuffers();
 }
 
-void reshape (int w, int h)
+static void reshape (int w, int h)
 {
    glViewport (0, 0, (GLsizei) w, (GLsizei) h); 
    glMatrixMode (GL_PROJECTION);
@@ -89,7 +89,7 @@ void reshape (int w, int h)
 }
 
 /* ARGSUSED1 */
-void keyboard (unsigned char key, int x, int y)
+static void keyboard (unsigned char key, int x, int y)
 {
    switch (key) {
       case 's':
index 0ea750e5846f2febfa74dbeac7472fcf2ca66725..d9e0a254e908eff9239136f244ddc1be56bba159 100644 (file)
@@ -49,7 +49,7 @@
 
 /*  Initialize material property and light source.
  */
-void myinit(void)
+static void myinit(void)
 {
     GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 };
     GLfloat light_diffuse[] = { 1.0, 0.0, 1.0, 1.0 };
@@ -68,7 +68,7 @@ void myinit(void)
     glEnable(GL_DEPTH_TEST);
 }
 
-void display(void)
+static void display(void)
 {
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     glPushMatrix ();
@@ -95,7 +95,7 @@ void display(void)
     glFlush();
 }
 
-void myReshape(int w, int h)
+static void myReshape(int w, int h)
 {
     glViewport(0, 0, w, h);
     glMatrixMode(GL_PROJECTION);
index c3abc727b783bcbcca14d25d626bf2d23372fe7b..6f336a8db4662c8f464a09f16dcabebaab0cb361 100644 (file)
@@ -48,7 +48,7 @@
 
 /*  Initialize material property and light source.
  */
-void myinit (void)
+static void myinit (void)
 {
     GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 };
     GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
@@ -67,7 +67,7 @@ void myinit (void)
     glEnable(GL_DEPTH_TEST);
 }
 
-void display (void)
+static void display (void)
 {
     glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
@@ -95,7 +95,7 @@ void display (void)
     glFlush ();
 }
 
-void myReshape(int w, int h)
+static void myReshape(int w, int h)
 {
     glViewport (0, 0, w, h);
     glMatrixMode (GL_PROJECTION);
index e7264d2003fcb9988d63bd89199ab266841728b7..ea605f8c73768cd5bd1c310ff8163960f32cb411 100644 (file)
@@ -47,7 +47,7 @@
 
 /*  Initialize light source and lighting.
  */
-void myinit(void)
+static void myinit(void)
 {
     GLfloat light_ambient[] = { 0.0, 0.0, 1.0, 1.0 };
     GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
@@ -66,7 +66,7 @@ void myinit(void)
     glEnable(GL_DEPTH_TEST);
 }
 
-void display(void)
+static void display(void)
 {
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
@@ -94,7 +94,7 @@ void display(void)
     glFlush();
 }
 
-void myReshape(int w, int h)
+static void myReshape(int w, int h)
 {
     glViewport(0, 0, w, h);
     glMatrixMode(GL_PROJECTION);
index 10891fb99777be8c9d8d5a5873552635c02a41e2..1b277334f5c98e504453aa9f28a4e2f05bc43fa9 100644 (file)
@@ -46,7 +46,7 @@
 
 /*  Initialize light source and shading model (GL_FLAT).
  */
-void myinit(void)
+static void myinit(void)
 {
     GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 };
     GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
@@ -66,7 +66,7 @@ void myinit(void)
     glShadeModel (GL_FLAT);
 }
 
-void display(void)
+static void display(void)
 {
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
@@ -94,7 +94,7 @@ void display(void)
     glFlush();
 }
 
-void myReshape(int w, int h)
+static void myReshape(int w, int h)
 {
     glViewport(0, 0, w, h);
     glMatrixMode(GL_PROJECTION);
index 928373b8796cbfaac5bda95fe4cc5b6d91415dbe..537d5194d46ae20704b42bb8f07e98a63ac27311 100644 (file)
@@ -57,7 +57,7 @@
 /* draw a triangle with vertices at (x1, y1), (x2, y2) 
  * and (x3, y3) at z units away from the origin.
  */
-void drawTriangle (GLfloat x1, GLfloat y1, GLfloat x2, 
+static void drawTriangle (GLfloat x1, GLfloat y1, GLfloat x2, 
     GLfloat y2, GLfloat x3, GLfloat y3, GLfloat z)
 {
    glBegin (GL_TRIANGLES);
@@ -68,8 +68,8 @@ void drawTriangle (GLfloat x1, GLfloat y1, GLfloat x2,
 }
 
 /* draw a rectangular box with these outer x, y, and z values */
-void drawViewVolume (GLfloat x1, GLfloat x2, GLfloat y1, 
-                     GLfloat y2, GLfloat z1, GLfloat z2)
+static void drawViewVolume (GLfloat x1, GLfloat x2, GLfloat y1, 
+                            GLfloat y2, GLfloat z1, GLfloat z2)
 {
    glColor3f (1.0, 1.0, 1.0);
    glBegin (GL_LINE_LOOP);
@@ -101,7 +101,7 @@ void drawViewVolume (GLfloat x1, GLfloat x2, GLfloat y1,
 /* drawScene draws 4 triangles and a wire frame
  * which represents the viewing volume.
  */
-void drawScene (void)
+static void drawScene (void)
 {
    glMatrixMode (GL_PROJECTION);
    glLoadIdentity ();
@@ -122,7 +122,7 @@ void drawScene (void)
 
 /* processHits prints out the contents of the selection array
  */
-void processHits (GLint hits, GLuint buffer[])
+static void processHits (GLint hits, GLuint buffer[])
 {
    GLint i;
    GLuint j, names, *ptr;
@@ -150,7 +150,7 @@ void processHits (GLint hits, GLuint buffer[])
  */
 #define BUFSIZE 512
 
-void selectObjects(void)
+static void selectObjects(void)
 {
    GLuint selectBuf[BUFSIZE];
    GLint hits;
@@ -181,13 +181,13 @@ void selectObjects(void)
    processHits (hits, selectBuf);
 } 
 
-void init (void) 
+static void init (void) 
 {
    glEnable(GL_DEPTH_TEST);
    glShadeModel(GL_FLAT);
 }
 
-void display(void)
+static void display(void)
 {
    glClearColor (0.0, 0.0, 0.0, 0.0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -197,7 +197,7 @@ void display(void)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 27:
index 9d22fc90251bb68d78cf81ea59f1e5f10cf52e27..874033d5adf0f22e543e87b9e34eb633677febe9 100644 (file)
 #include <GL/glut.h>
 #include <stdlib.h>
 
-void init(void) 
+static void init(void) 
 {
    glClearColor (0.0, 0.0, 0.0, 0.0);
    glShadeModel (GL_SMOOTH);
 }
 
-void triangle(void)
+static void triangle(void)
 {
    glBegin (GL_TRIANGLES);
    glColor3f (1.0, 0.0, 0.0);
@@ -61,14 +61,14 @@ void triangle(void)
    glEnd();
 }
 
-void display(void)
+static void display(void)
 {
    glClear (GL_COLOR_BUFFER_BIT);
    triangle ();
    glFlush ();
 }
 
-void reshape (int w, int h)
+static void reshape (int w, int h)
 {
    glViewport (0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode (GL_PROJECTION);
@@ -81,7 +81,7 @@ void reshape (int w, int h)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 27:
index b33e40a03072be00d3139aed63766c9ac320060b..5325abf8b773f9fbc893f9ef6b737e4e0b2647a6 100644 (file)
@@ -64,7 +64,7 @@
 #define YELLOWMAT   1
 #define BLUEMAT 2
 
-void myinit (void)
+static void myinit (void)
 {
     GLfloat yellow_diffuse[] = { 0.7, 0.7, 0.0, 1.0 };
     GLfloat yellow_specular[] = { 1.0, 1.0, 1.0, 1.0 };
@@ -101,7 +101,7 @@ void myinit (void)
 /*  Draw a sphere in a diamond-shaped section in the
  *  middle of a window with 2 tori.
  */
-void display(void)
+static void display(void)
 {
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
@@ -132,7 +132,7 @@ void display(void)
 /*  Whenever the window is reshaped, redefine the
  *  coordinate system and redraw the stencil area.
  */
-void myReshape(int w, int h)
+static void myReshape(int w, int h)
 {
     glViewport(0, 0, w, h);
 
index 19b0391cbae79fbb257ae923560a4fd2731e415e..68b639abf4fc5e246cb4e102e7823eca8a57c20c 100644 (file)
@@ -87,7 +87,7 @@ CP Sdata[] = {
 /*  drawLetter() interprets the instructions from the array
  *  for that letter and renders the letter with line segments.
  */
-void drawLetter(CP *l)
+static void drawLetter(CP *l)
 {
     glBegin(GL_LINE_STRIP);
     for (;;) {
@@ -111,7 +111,7 @@ void drawLetter(CP *l)
 }
 
 /*  Create a display list for each of 6 characters     */
-void myinit (void)
+static void myinit (void)
 {
     GLuint base;
 
@@ -130,13 +130,13 @@ void myinit (void)
 char *test1 = "A SPARE SERAPE APPEARS AS";
 char *test2 = "APES PREPARE RARE PEPPERS";
 
-void printStrokedString(char *s)
+static void printStrokedString(char *s)
 {
     GLsizei len = (GLsizei) strlen(s);
     glCallLists(len, GL_BYTE, (GLbyte *)s);
 }
 
-void display(void)
+static void display(void)
 {
     glClear(GL_COLOR_BUFFER_BIT);
     glColor3f(1.0, 1.0, 1.0);
index e33ce14f4fc4f1309885116f151560d351c8f8f6..f0c5ab0b47c4080938a018e2500cda2450dce546 100644 (file)
@@ -53,7 +53,7 @@ GLUnurbsObj *theNurb;
  *  Initializes the control points of the surface to a small hill.
  *  The control points range from -3 to +3 in x, y, and z
  */
-void init_surface(void)
+static void init_surface(void)
 {
     int u, v;
     for (u = 0; u < 4; u++) {
@@ -71,7 +71,7 @@ void init_surface(void)
 
 /*  Initialize material property and depth buffer.
  */
-void myinit(void)
+static void myinit(void)
 {
     GLfloat mat_diffuse[] = { 0.7, 0.7, 0.7, 1.0 };
     GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
@@ -100,7 +100,7 @@ void myinit(void)
     glTranslatef (0.0, 0.0, -5.0);
 }
 
-void display(void)
+static void display(void)
 {
     GLfloat knots[8] = {0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0};
     int i, j;
@@ -140,7 +140,7 @@ void display(void)
     glutSwapBuffers();
 }
 
-void reshape(int w, int h)
+static void reshape(int w, int h)
 {
     glViewport(0, 0, w, h);
     glMatrixMode(GL_PROJECTION);
@@ -150,7 +150,7 @@ void reshape(int w, int h)
     glMatrixMode(GL_MODELVIEW);
 }
 
-void
+static void
 menu(int value)
 {
     switch (value) {
@@ -171,7 +171,7 @@ menu(int value)
 int down = 0, lastx;
 
 /* ARGSUSED1 */
-void
+static void
 motion(int x, int y)
 {
     if (down) {
@@ -182,7 +182,7 @@ motion(int x, int y)
 }
 
 /* ARGSUSED3 */
-void
+static void
 mouse(int button, int state, int x, int y)
 {
     if (button == GLUT_LEFT_BUTTON) {
index 53b5111752fa12b6c38fcde3d822db7be821b24b..20ff1a4a33bcdbdd9b20decf4179d1ad89ae1418 100644 (file)
@@ -47,7 +47,7 @@
 
 /*  Initialize light source and lighting model.
  */
-void
+static void
 myinit(void)
 {
     GLfloat light_ambient[] =
@@ -78,7 +78,7 @@ myinit(void)
     glEnable(GL_DEPTH_TEST);
 }
 
-void
+static void
 display(void)
 {
     GLfloat low_ambient[] =
@@ -114,7 +114,7 @@ display(void)
     glFlush();
 }
 
-void
+static void
 myReshape(int w, int h)
 {
     glViewport(0, 0, w, h);
index fb7aed380ebc74ca34ef7b5edd359790c4d0a5cc..102c18a3e33fc664db1e83f609ab1d5fd5e9326e 100644 (file)
@@ -49,7 +49,7 @@
  * Initialize depth buffer, projection matrix, light source, and lighting
  * model.  Do not specify a material property here.
  */
-void
+static void
 myinit(void)
 {
   GLfloat ambient[] =
@@ -83,7 +83,7 @@ myinit(void)
  * Move object into position.  Use 3rd through 12th parameters to specify the
  * material property.  Draw a teapot.
  */
-void
+static void
 renderTeapot(GLfloat x, GLfloat y,
   GLfloat ambr, GLfloat ambg, GLfloat ambb,
   GLfloat difr, GLfloat difg, GLfloat difb,
@@ -117,7 +117,7 @@ renderTeapot(GLfloat x, GLfloat y,
  *  3rd column:  black, cyan, green, red, white, yellow plastic
  *  4th column:  black, cyan, green, red, white, yellow rubber
  */
-void
+static void
 display(void)
 {
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -173,7 +173,7 @@ display(void)
   glFlush();
 }
 
-void
+static void
 myReshape(int w, int h)
 {
   glViewport(0, 0, w, h);
index 238a469aff20d759a31eb274fe0b9a79e3f70e28..0bf8a8eb9867d31fc512e6b789d382d6e92601db 100644 (file)
@@ -61,7 +61,7 @@
 
 GLuint startList;
 
-void display (void) {
+static void display (void) {
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(1.0, 1.0, 1.0);
    glCallList(startList);
@@ -69,12 +69,12 @@ void display (void) {
    glFlush();
 }
 
-void CALLBACK beginCallback(GLenum which)
+static void CALLBACK beginCallback(GLenum which)
 {
    glBegin(which);
 }
 
-void CALLBACK errorCallback(GLenum errorCode)
+static void CALLBACK errorCallback(GLenum errorCode)
 {
    const GLubyte *estring;
 
@@ -83,12 +83,12 @@ void CALLBACK errorCallback(GLenum errorCode)
    exit(0);
 }
 
-void CALLBACK endCallback(void)
+static void CALLBACK endCallback(void)
 {
    glEnd();
 }
 
-void CALLBACK vertexCallback(GLvoid *vertex)
+static void CALLBACK vertexCallback(GLvoid *vertex)
 {
    const GLdouble *pointer;
 
@@ -102,7 +102,7 @@ void CALLBACK vertexCallback(GLvoid *vertex)
  *  but weight[4] may be used to average color, normal, or texture
  *  coordinate data.  In this program, color is weighted.
  */
-void CALLBACK combineCallback(GLdouble coords[3],
+static void CALLBACK combineCallback(GLdouble coords[3],
                      GLdouble *vertex_data[4],
                      GLfloat weight[4], GLdouble **dataOut )
 {
@@ -122,7 +122,7 @@ void CALLBACK combineCallback(GLdouble coords[3],
    *dataOut = vertex;
 }
 
-void init (void)
+static void init (void)
 {
    GLUtesselator *tobj;
    GLdouble rect[4][3] = {{50.0, 50.0, 0.0},
@@ -199,7 +199,7 @@ void init (void)
    gluDeleteTess(tobj);
 }
 
-void reshape (int w, int h)
+static void reshape (int w, int h)
 {
    glViewport(0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode(GL_PROJECTION);
@@ -208,7 +208,7 @@ void reshape (int w, int h)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 27:
index 7d00c9f907d432c8b68370a1ff61df02105405c5..4729880a57e5ee91a8eaa784b11049cfdc8ca394 100644 (file)
@@ -61,7 +61,7 @@ GLuint list;
 /*  Make four display lists, 
  *  each with a different tessellated object. 
  */
-void makeNewLists (void) {
+static void makeNewLists (void) {
    int i;
    static GLdouble rects[12][3] = 
       {{ 50.0,  50.0, 0.0}, {300.0,  50.0, 0.0}, 
@@ -153,7 +153,7 @@ void makeNewLists (void) {
    glEndList();
 }
 
-void display (void) {
+static void display (void) {
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(1.0, 1.0, 1.0);
    glPushMatrix(); 
@@ -168,12 +168,12 @@ void display (void) {
    glFlush();
 }
 
-void CALLBACK beginCallback(GLenum which)
+static void CALLBACK beginCallback(GLenum which)
 {
    glBegin(which);
 }
 
-void CALLBACK errorCallback(GLenum errorCode)
+static void CALLBACK errorCallback(GLenum errorCode)
 {
    const GLubyte *estring;
 
@@ -182,7 +182,7 @@ void CALLBACK errorCallback(GLenum errorCode)
    exit(0);
 }
 
-void CALLBACK endCallback(void)
+static void CALLBACK endCallback(void)
 {
    glEnd();
 }
@@ -193,7 +193,7 @@ void CALLBACK endCallback(void)
  *  coordinate data.
  */
 /* ARGSUSED */
-void CALLBACK combineCallback(GLdouble coords[3], GLdouble *data[4],
+static void CALLBACK combineCallback(GLdouble coords[3], GLdouble *data[4],
                      GLfloat weight[4], GLdouble **dataOut )
 {
    GLdouble *vertex;
@@ -205,7 +205,7 @@ void CALLBACK combineCallback(GLdouble coords[3], GLdouble *data[4],
    *dataOut = vertex;
 }
 
-void init(void) 
+static void init(void) 
 {
    glClearColor(0.0, 0.0, 0.0, 0.0);
    glShadeModel(GL_FLAT);    
@@ -226,7 +226,7 @@ void init(void)
    makeNewLists();
 }
 
-void reshape(int w, int h)
+static void reshape(int w, int h)
 {
    glViewport(0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode(GL_PROJECTION);
@@ -240,7 +240,7 @@ void reshape(int w, int h)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 'w':
index 6a828ab2bdf2af803538b46aa70aef48d7319926..b6404b32d8cfdd57ce20ee57ecd4fb4bbf689f3a 100644 (file)
@@ -52,7 +52,7 @@ static GLubyte otherImage[checkImageHeight][checkImageWidth][4];
 
 static GLuint texName[2];
 
-void makeCheckImages(void)
+static void makeCheckImages(void)
 {
    int i, j, c;
 
@@ -72,7 +72,7 @@ void makeCheckImages(void)
    }
 }
 
-void init(void)
+static void init(void)
 {
    glClearColor (0.0, 0.0, 0.0, 0.0);
    glShadeModel(GL_FLAT);
@@ -105,7 +105,7 @@ void init(void)
    glEnable(GL_TEXTURE_2D);
 }
 
-void display(void)
+static void display(void)
 {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glBindTexture(GL_TEXTURE_2D, texName[0]);
@@ -125,7 +125,7 @@ void display(void)
    glFlush();
 }
 
-void reshape(int w, int h)
+static void reshape(int w, int h)
 {
    glViewport(0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode(GL_PROJECTION);
@@ -137,7 +137,7 @@ void reshape(int w, int h)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 27:
index 7c1802a3be9455bfaed29af9eefabc495f891dad..5cb97e5a43d2b20ab42eaff1ee87dc09c733dfff 100644 (file)
@@ -60,7 +60,7 @@ GLubyte stripeImage[4*stripeImageWidth];
 static GLuint texName;
 #endif
 
-void makeStripeImage(void)
+static void makeStripeImage(void)
 {
    int j;
     
@@ -79,7 +79,7 @@ static GLfloat *currentCoeff;
 static GLenum currentPlane;
 static GLint currentGenMode;
 
-void init(void)
+static void init(void)
 {
    glClearColor (0.0, 0.0, 0.0, 0.0);
    glEnable(GL_DEPTH_TEST);
@@ -122,7 +122,7 @@ void init(void)
    glMaterialf (GL_FRONT, GL_SHININESS, 64.0);
 }
 
-void display(void)
+static void display(void)
 {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
@@ -136,7 +136,7 @@ void display(void)
    glFlush();
 }
 
-void reshape(int w, int h)
+static void reshape(int w, int h)
 {
    glViewport(0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode(GL_PROJECTION);
@@ -152,7 +152,7 @@ void reshape(int w, int h)
 }
 
 /* ARGSUSED1 */
-void keyboard (unsigned char key, int x, int y)
+static void keyboard (unsigned char key, int x, int y)
 {
    switch (key) {
       case 'e':
index 6f1e853facdf334dd966a27609b075a2e693e89f..c2d699a71b2278210b4a266de99652e03623fa66 100644 (file)
@@ -53,7 +53,7 @@
 #define GL_TEXTURE_INTERNAL_FORMAT GL_TEXTURE_COMPONENTS
 #endif
 
-void init(void) 
+static void init(void) 
 {
    GLint proxyComponents;
 
@@ -84,12 +84,12 @@ void init(void)
    putchar('\n');
 }
 
-void display(void)
+static void display(void)
 {
    exit(0);
 }
 
-void reshape (int w, int h)
+static void reshape (int w, int h)
 {
    glViewport (0, 0, (GLsizei) w, (GLsizei) h); 
    glMatrixMode (GL_PROJECTION);
index 4e829675aba84cbef312f760e44c91385e0fbd36..7827d5a45f37bcbd9ad2048339b82b70867c9f84 100644 (file)
@@ -58,7 +58,7 @@ static GLubyte subImage[subImageHeight][subImageWidth][4];
 
 static GLuint texName;
 
-void makeCheckImages(void)
+static void makeCheckImages(void)
 {
    int i, j, c;
 
@@ -82,7 +82,7 @@ void makeCheckImages(void)
    }
 }
 
-void init(void)
+static void init(void)
 {
    glClearColor (0.0, 0.0, 0.0, 0.0);
    glShadeModel(GL_FLAT);
@@ -102,7 +102,7 @@ void init(void)
                 0, GL_RGBA, GL_UNSIGNED_BYTE, checkImage);
 }
 
-void display(void)
+static void display(void)
 {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glEnable(GL_TEXTURE_2D);
@@ -123,7 +123,7 @@ void display(void)
    glDisable(GL_TEXTURE_2D);
 }
 
-void reshape(int w, int h)
+static void reshape(int w, int h)
 {
    glViewport(0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode(GL_PROJECTION);
@@ -135,7 +135,7 @@ void reshape(int w, int h)
 }
 
 /* ARGSUSED1 */
-void keyboard (unsigned char key, int x, int y)
+static void keyboard (unsigned char key, int x, int y)
 {
    switch (key) {
       case 's':
index 0170070eaa5eb109531aea94ed580c7a8a9ca57e..2023072dba8422761a38e57ade928f4b26d9fddf 100644 (file)
@@ -60,7 +60,7 @@ GLfloat ctrlpoints[4][4][3] = {
 GLfloat texpts[2][2][2] = {{{0.0, 0.0}, {0.0, 1.0}},
                        {{1.0, 0.0}, {1.0, 1.0}}};
 
-void display(void)
+static void display(void)
 {
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     glColor3f(1.0, 1.0, 1.0);
@@ -72,7 +72,7 @@ void display(void)
 #define        imageHeight 64
 GLubyte image[3*imageWidth*imageHeight];
 
-void makeImage(void)
+static void makeImage(void)
 {
     int i, j;
     float ti, tj;
@@ -89,7 +89,7 @@ void makeImage(void)
     }
 }
 
-void myinit(void)
+static void myinit(void)
 {
     glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4,
            0, 1, 12, 4, &ctrlpoints[0][0][0]);
@@ -112,7 +112,7 @@ void myinit(void)
     glShadeModel (GL_FLAT);
 }
 
-void myReshape(int w, int h)
+static void myReshape(int w, int h)
 {
     glViewport(0, 0, w, h);
     glMatrixMode(GL_PROJECTION);
index 7ae4d41e263ba7a691edac77110a4347730a4fc4..a67d48e0f594b251d64aaa480ddc4bf4147a3d9a 100644 (file)
@@ -89,7 +89,7 @@ static void init(void)
 }
 
 /* Clear window and draw torus */
-void display(void)
+static void display(void)
 {
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f (1.0, 1.0, 1.0);
@@ -98,7 +98,7 @@ void display(void)
 }
 
 /* Handle window resize */
-void reshape(int w, int h)
+static void reshape(int w, int h)
 {
    glViewport(0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode(GL_PROJECTION);
@@ -112,7 +112,7 @@ void reshape(int w, int h)
 /* Rotate about x-axis when "x" typed; rotate about y-axis
    when "y" typed; "i" returns torus to original view */
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
    case 'x':
index f17674f68409534e04cbd1c093318be9b87ad24d..216f62a7c2fb7d68d5a90c7e7e242e3349cbfe95 100644 (file)
@@ -59,7 +59,7 @@ GLUnurbsObj *theNurb;
  *  Initializes the control points of the surface to a small hill.
  *  The control points range from -3 to +3 in x, y, and z
  */
-void init_surface(void)
+static void init_surface(void)
 {
    int u, v;
    for (u = 0; u < 4; u++) {
@@ -75,7 +75,7 @@ void init_surface(void)
    }
 }
 
-void nurbsError(GLenum errorCode)
+static void nurbsError(GLenum errorCode)
 {
    const GLubyte *estring;
 
@@ -86,7 +86,7 @@ void nurbsError(GLenum errorCode)
                        
 /*  Initialize material property and depth buffer.
  */
-void init(void)
+static void init(void)
 {
    GLfloat mat_diffuse[] = { 0.7, 0.7, 0.7, 1.0 };
    GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
@@ -112,7 +112,7 @@ void init(void)
                     (GLvoid (CALLBACK*) ()) nurbsError);
 }
 
-void display(void)
+static void display(void)
 {
    GLfloat knots[8] = {0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0};
    GLfloat edgePt[5][2] = /* counter clockwise */
@@ -147,7 +147,7 @@ void display(void)
    glFlush();
 }
 
-void reshape(int w, int h)
+static void reshape(int w, int h)
 {
    glViewport(0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode(GL_PROJECTION);
@@ -160,7 +160,7 @@ void reshape(int w, int h)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 27:
index 134c361bac550957cff7f9a00079aa02e8fb47ae..6d1c7dbededf8547a985530a5f43d36db52d17f5 100644 (file)
 #include <stdlib.h>
 #include <stdio.h>
 
-void display(void)
+static void display(void)
 {
    glClear(GL_COLOR_BUFFER_BIT);
    glFlush();
 }
 
 /* Change these values for a different transformation  */
-void reshape(int w, int h)
+static void reshape(int w, int h)
 {
    glViewport (0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode(GL_PROJECTION);
@@ -62,7 +62,7 @@ void reshape(int w, int h)
    glLoadIdentity();
 }
 
-void mouse(int button, int state, int x, int y) 
+static void mouse(int button, int state, int x, int y) 
 {
    GLint viewport[4];
    GLdouble mvmatrix[16], projmatrix[16];
@@ -98,7 +98,7 @@ void mouse(int button, int state, int x, int y)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 27:
index b22e723e0ec66dc8e7dbb9fd3a1422c0a8f21898..8ce39d776330e1e213c9d30bd830d05a6bbf7cd6 100644 (file)
@@ -54,7 +54,7 @@
 int setupMethod = POINTER;
 int derefMethod = DRAWARRAY;
 
-void setupPointers(void)
+static void setupPointers(void)
 {
    static GLint vertices[] = {25, 25,
                        100, 325,
@@ -76,7 +76,7 @@ void setupPointers(void)
    glColorPointer (3, GL_FLOAT, 0, colors);
 }
 
-void setupInterleave(void)
+static void setupInterleave(void)
 {
    static GLfloat intertwined[] =
       {1.0, 0.2, 1.0, 100.0, 100.0, 0.0,
@@ -89,14 +89,14 @@ void setupInterleave(void)
    glInterleavedArrays (GL_C3F_V3F, 0, intertwined);
 }
 
-void init(void) 
+static void init(void) 
 {
    glClearColor (0.0, 0.0, 0.0, 0.0);
    glShadeModel (GL_SMOOTH);
    setupPointers ();
 }
 
-void display(void)
+static void display(void)
 {
    glClear (GL_COLOR_BUFFER_BIT);
 
@@ -117,7 +117,7 @@ void display(void)
    glFlush ();
 }
 
-void reshape (int w, int h)
+static void reshape (int w, int h)
 {
    glViewport (0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode (GL_PROJECTION);
@@ -126,7 +126,7 @@ void reshape (int w, int h)
 }
 
 /* ARGSUSED2 */
-void mouse (int button, int state, int x, int y)
+static void mouse (int button, int state, int x, int y)
 {
    switch (button) {
       case GLUT_LEFT_BUTTON:
@@ -160,7 +160,7 @@ void mouse (int button, int state, int x, int y)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 27:
index f9a1f162ab6a8fa2ba6a619fab131b13252422c1..67749716e836d39611c0e788e1de5e3bad21450f 100644 (file)
@@ -59,7 +59,7 @@ static GLubyte checkImage[checkImageHeight][checkImageWidth][4];
 static GLuint texName;
 #endif
 
-void makeCheckImage(void)
+static void makeCheckImage(void)
 {
    int i, j, c;
     
@@ -74,7 +74,7 @@ void makeCheckImage(void)
    }
 }
 
-void init(void)
+static void init(void)
 {    
    glClearColor (0.0, 0.0, 0.0, 0.0);
    glShadeModel(GL_FLAT);
@@ -101,7 +101,7 @@ void init(void)
 #endif
 }
 
-void display(void)
+static void display(void)
 {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glEnable(GL_TEXTURE_2D);
@@ -125,7 +125,7 @@ void display(void)
    glDisable(GL_TEXTURE_2D);
 }
 
-void reshape(int w, int h)
+static void reshape(int w, int h)
 {
    glViewport(0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode(GL_PROJECTION);
@@ -137,7 +137,7 @@ void reshape(int w, int h)
 }
 
 /* ARGSUSED1 */
-void keyboard (unsigned char key, int x, int y)
+static void keyboard (unsigned char key, int x, int y)
 {
    switch (key) {
       case 's':
index f60d6e94eac8c0a54af5d493359041f53d5c2459..c15b886b884115c20b9ef9e5b05b39de831a9ebb 100644 (file)
@@ -36,6 +36,7 @@ prim
 quad
 readtex.c
 readtex.h
+rgbtoppm
 select
 shape
 sphere
index b300e38b9c203585094acc7bc4d40bffdf766345..64fa47addb5796fbe43f5c29a5aa8ddd2db4d009 100644 (file)
@@ -10,7 +10,7 @@ LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(T
 LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
 
 PROGS = accum bitmap1 bitmap2 blendeq blendxor copy cursor depth eval fog \
-       font line logo nurb olympic overlay point prim quad select \
+       font line logo nurb olympic overlay point prim rgbtoppm quad select \
        shape sphere star stencil stretch texture tri wave
 
 
index 7a8a0d62d81c1b00726d81ee730900b7c73b1bab..134dfa99807f47d2fb69bf4d55ae08ef34104d61 100644 (file)
@@ -1,23 +1,5 @@
 Import('*')
 
-if not env['GLUT']:
-    Return()
-
-env = env.Clone()
-
-env.Prepend(CPPPATH = [
-       '../util',
-])
-
-env.Prepend(LIBS = [
-       util,
-       '$GLUT_LIB'
-])
-
-if env['platform'] == 'windows':
-    env.Append(CPPDEFINES = ['NOMINMAX'])
-    env.Prepend(LIBS = ['winmm'])
-
 progs = [
     'accum',
     'bitmap1',
@@ -52,7 +34,7 @@ progs = [
 ]
 
 for prog in progs:
-    env.Program(
+    progs_env.Program(
         target = prog,
         source = prog + '.c',
     )
index 5385e487026f110b027e2b0541d34b336c4e3a8e..209a8c141b2f144af886329aeda7e3b924159810 100644 (file)
@@ -74,7 +74,7 @@ int iters[RINGS];
 GLuint theTorus;
 
 
-void FillTorus(float rc, int numc, float rt, int numt)
+static void FillTorus(float rc, int numc, float rt, int numt)
 {
     int i, j, k;
     double s, t;
@@ -106,7 +106,7 @@ void FillTorus(float rc, int numc, float rt, int numt)
     }
 }
 
-float Clamp(int iters_left, float t)
+static float Clamp(int iters_left, float t)
 {
     if (iters_left < 3) {
        return 0.0;
@@ -114,7 +114,7 @@ float Clamp(int iters_left, float t)
     return (iters_left-2)*t/iters_left;
 }
 
-void DrawScene(void)
+static void DrawScene(void)
 {
     int i, j;
     GLboolean goIdle;
@@ -172,7 +172,7 @@ void DrawScene(void)
     }
 }
 
-float MyRand(void)
+static float MyRand(void)
 {
    return 10.0 * ( (float) rand() / (float) RAND_MAX - 0.5 );
 }
@@ -181,12 +181,12 @@ float MyRand(void)
 #define GLUTCALLBACK
 #endif
 
-void GLUTCALLBACK glut_post_redisplay_p(void)
+static void GLUTCALLBACK glut_post_redisplay_p(void)
 {
       glutPostRedisplay();
 }
 
-void ReInit(void)
+static void ReInit(void)
 {
     int i;
     float deviation;
@@ -206,7 +206,7 @@ void ReInit(void)
     glutIdleFunc(glut_post_redisplay_p);
 }
 
-void Init(void)
+static void Init(void)
 {
     float base, height;
     float aspect, x, y;
@@ -312,13 +312,13 @@ void Init(void)
     glMatrixMode(GL_MODELVIEW);
 }
 
-void Reshape(int width, int height)
+static void Reshape(int width, int height)
 {
 
     glViewport(0, 0, width, height);
 }
 
-void Key(unsigned char key, int x, int y)
+static void Key(unsigned char key, int x, int y)
 {
 
     switch (key) {
@@ -330,7 +330,7 @@ void Key(unsigned char key, int x, int y)
     }
 }
 
-GLenum Args(int argc, char **argv)
+static GLenum Args(int argc, char **argv)
 {
     GLint i;
 
index 23b5a4793baff62eedda6cd05f62fa745f805f39..6087cef281547eb97b5ee5e730d79867c656c265 100644 (file)
@@ -69,19 +69,19 @@ starRec stars[MAXSTARS];
 float sinTable[MAXANGLES];
 
 
-float Sin(float angle)
+static float Sin(float angle)
 {
 
     return (sinTable[(GLint)angle]);
 }
 
-float Cos(float angle)
+static float Cos(float angle)
 {
 
     return (sinTable[((GLint)angle+(MAXANGLES/4))%MAXANGLES]);
 }
 
-void NewStar(GLint n, GLint d)
+static void NewStar(GLint n, GLint d)
 {
 
     if (rand()%4 == 0) {
@@ -103,7 +103,7 @@ void NewStar(GLint n, GLint d)
     }
 }
 
-void RotatePoint(float *x, float *y, float rotation)
+static void RotatePoint(float *x, float *y, float rotation)
 {
     float tmpX, tmpY;
 
@@ -113,7 +113,7 @@ void RotatePoint(float *x, float *y, float rotation)
     *y = tmpY;
 }
 
-void MoveStars(void)
+static void MoveStars(void)
 {
     float offset;
     GLint n;
@@ -134,7 +134,7 @@ void MoveStars(void)
     }
 }
 
-GLenum StarPoint(GLint n)
+static GLenum StarPoint(GLint n)
 {
     float x0, y0, x1, y1, width;
     GLint i;
@@ -182,7 +182,7 @@ GLenum StarPoint(GLint n)
     }
 }
 
-void ShowStars(void)
+static void ShowStars(void)
 {
     GLint n;
 
@@ -221,7 +221,7 @@ static void Init(void)
     glDisable(GL_DITHER);
 }
 
-void Reshape(int width, int height)
+static void Reshape(int width, int height)
 {
 
     windW = (GLint)width;
@@ -262,7 +262,7 @@ static void Key(unsigned char key, int x, int y)
     }
 }
 
-void Idle(void)
+static void Idle(void)
 {
 
     if (overlayInit == GL_FALSE) {
index 116d9a8cfa5b64eb825a4d4c3e603f4101f7affd..403578ef423db5cbe9e25a9201614a54ca68556f 100644 (file)
@@ -3,6 +3,7 @@
 
 /* texload is a simplistic routine for reading an SGI .rgb image file. */
 
+#include <assert.h>
 #include <stdio.h>
 #include <stdlib.h> 
 #include <string.h>
@@ -25,7 +26,7 @@ typedef struct _ImageRec {
     int *rowSize;
 } ImageRec;
 
-void
+static void
 rgbtorgb(unsigned char *r,unsigned char *g,unsigned char *b,unsigned char *l,int n) {
     while(n--) {
         l[0] = r[0];
@@ -72,6 +73,7 @@ static ImageRec *ImageOpen(char *fileName)
     ImageRec *image;
     int swapFlag;
     int x;
+    int result;
 
     endianTest.testWord = 1;
     if (endianTest.testByte[0] == 1) {
@@ -86,13 +88,20 @@ static ImageRec *ImageOpen(char *fileName)
         exit(1);
     }
     if ((image->file = fopen(fileName, "rb")) == NULL) {
-       return NULL;
+        free(image);
+        return NULL;
     }
 
-    fread(image, 1, 12, image->file);
+    result = fread(image, 1, 12, image->file);
+    assert(result == 12);
 
     if (swapFlag) {
-        ConvertShort(&image->imagic, 6);
+        ConvertShort(&image->imagic, 1);
+        ConvertShort(&image->type, 1);
+        ConvertShort(&image->dim, 1);
+        ConvertShort(&image->xsize, 1);
+        ConvertShort(&image->ysize, 1);
+        ConvertShort(&image->zsize, 1);
     }
 
     image->tmp = (unsigned char *)malloc(image->xsize*256);
@@ -111,8 +120,10 @@ static ImageRec *ImageOpen(char *fileName)
         }
         image->rleEnd = 512 + (2 * x);
         fseek(image->file, 512, SEEK_SET);
-        fread(image->rowStart, 1, x, image->file);
-        fread(image->rowSize, 1, x, image->file);
+        result = fread(image->rowStart, 1, x, image->file);
+        assert(result == x);
+        result = fread(image->rowSize, 1, x, image->file);
+        assert(result == x);
         if (swapFlag) {
             ConvertUint(image->rowStart, x/(int) sizeof(unsigned));
             ConvertUint((unsigned *)image->rowSize, x/(int) sizeof(int));
@@ -132,11 +143,13 @@ static void
 ImageGetRow(ImageRec *image, unsigned char *buf, int y, int z) {
     unsigned char *iPtr, *oPtr, pixel;
     int count;
+    int result;
 
     if ((image->type & 0xFF00) == 0x0100) {
         fseek(image->file, (long) image->rowStart[y+z*image->ysize], SEEK_SET);
-        fread(image->tmp, 1, (unsigned int)image->rowSize[y+z*image->ysize],
-              image->file);
+        result = fread(image->tmp, 1, (unsigned int)image->rowSize[y+z*image->ysize],
+                       image->file);
+        assert(result == (unsigned int)image->rowSize[y+z*image->ysize]);
 
         iPtr = image->tmp;
         oPtr = buf;
@@ -160,11 +173,13 @@ ImageGetRow(ImageRec *image, unsigned char *buf, int y, int z) {
     } else {
         fseek(image->file, 512+(y*image->xsize)+(z*image->xsize*image->ysize),
               SEEK_SET);
-        fread(buf, 1, image->xsize, image->file);
+        result = fread(buf, 1, image->xsize, image->file);
+        assert(result == image->xsize);
     }
 }
 
-GLubyte *
+#if 0
+static GLubyte *
 read_alpha_texture(char *name, int *width, int *height)
 {
     unsigned char *base, *lptr;
@@ -193,8 +208,9 @@ read_alpha_texture(char *name, int *width, int *height)
 
     return (unsigned char *) base;
 }
+#endif
 
-GLubyte *
+static GLubyte *
 read_rgb_texture(char *name, int *width, int *height)
 {
     unsigned char *base, *ptr;
@@ -224,6 +240,7 @@ read_rgb_texture(char *name, int *width, int *height)
       if (gbuf) free(gbuf);
       if (bbuf) free(bbuf);
       if (abuf) free(abuf);
+      ImageClose(image); 
       return NULL;
     }
     ptr = base;
@@ -254,7 +271,8 @@ read_rgb_texture(char *name, int *width, int *height)
 
 int main(int argc, char **argv)
 {
-       int width, height;
+       int width = 0;
+       int height = 0;
        GLubyte *data;
         char buff[32];
         int n;
index 7d0508dee9f1934e44b4aa20fc1a47ef3b1872aa..23d4fe32c02df1d410cdba081f0ccfdb95888563 100644 (file)
@@ -445,7 +445,7 @@ GLfloat identity[16] = {
 };
 
 
-void BuildCylinder(int numEdges)
+static void BuildCylinder(int numEdges)
 {
     int i, top = 1.0, bottom = -1.0;
     float x[100], y[100], angle;
@@ -481,7 +481,7 @@ void BuildCylinder(int numEdges)
     glEndList();
 }
 
-void BuildTorus(float rc, int numc, float rt, int numt)
+static void BuildTorus(float rc, int numc, float rt, int numt)
 {
     int i, j, k;
     double s, t;
@@ -515,7 +515,7 @@ void BuildTorus(float rc, int numc, float rt, int numt)
     glEndList();
 }
 
-void BuildCage(void)
+static void BuildCage(void)
 {
     int i;
     float inc;
@@ -609,7 +609,7 @@ void BuildCage(void)
     glEndList();
 }
 
-void BuildCube(void)
+static void BuildCube(void)
 {
     int i, j;
 
@@ -628,7 +628,7 @@ void BuildCube(void)
     glEndList();
 }
 
-void BuildLists(void)
+static void BuildLists(void)
 {
 
     cube = glGenLists(1);
@@ -646,7 +646,7 @@ void BuildLists(void)
     genericObject = torus;
 }
 
-void SetDefaultSettings(void)
+static void SetDefaultSettings(void)
 {
 
     magFilter = nnearest;
@@ -657,7 +657,7 @@ void SetDefaultSettings(void)
     autoRotate = GL_TRUE;
 }
 
-unsigned char *AlphaPadImage(int bufSize, unsigned char *inData, int alpha)
+static unsigned char *AlphaPadImage(int bufSize, unsigned char *inData, int alpha)
 {
     unsigned char *outData, *out_ptr, *in_ptr;
     int i;
@@ -677,7 +677,7 @@ unsigned char *AlphaPadImage(int bufSize, unsigned char *inData, int alpha)
     return outData;
 }
 
-void Init(void)
+static void Init(void)
 {
     float ambient[] = {0.0, 0.0, 0.0, 1.0};
     float diffuse[] = {1.0, 1.0, 1.0, 1.0};
@@ -753,7 +753,7 @@ void Init(void)
     BuildLists();
 }
 
-void ReInit(void)
+static void ReInit(void)
 {
     if (genericObject == torus) {
        glEnable(GL_DEPTH_TEST);
@@ -773,7 +773,7 @@ void ReInit(void)
     glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, textureEnvironment);
 }
 
-void Draw(void)
+static void Draw(void)
 {
     glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
 
@@ -806,7 +806,7 @@ void Draw(void)
     glutSwapBuffers();
 }
 
-void Reshape(int width, int height)
+static void Reshape(int width, int height)
 {
     W = width;
     H = height;
@@ -818,7 +818,7 @@ void Reshape(int width, int height)
     glMatrixMode(GL_MODELVIEW);
 }
 
-void Idle(void)
+static void Idle(void)
 {
    static double t0 = -1.;
    double t, dt;
@@ -833,7 +833,7 @@ void Idle(void)
    glutPostRedisplay();
 }
 
-void Key2(int key, int x, int y)
+static void Key2(int key, int x, int y)
 {
 
     switch (key) {
@@ -863,7 +863,7 @@ void Key2(int key, int x, int y)
     glutPostRedisplay();
 }
 
-void Key(unsigned char key, int x, int y)
+static void Key(unsigned char key, int x, int y)
 {
 
     switch (key) {
@@ -950,7 +950,7 @@ void Key(unsigned char key, int x, int y)
     glutPostRedisplay();
 }
 
-GLenum Args(int argc, char **argv)
+static GLenum Args(int argc, char **argv)
 {
     GLint i;
 
index 2cf470e2a2f7d412e89d8eced46b9ee0c58e74f5..2c44ebfd49e95fec5a56a7030a23eb38a8b7cf72 100644 (file)
@@ -67,19 +67,19 @@ starRec stars[MAXSTARS];
 float sinTable[MAXANGLES];
 
 
-float Sin(float angle)
+static float Sin(float angle)
 {
 
     return (sinTable[(GLint)angle]);
 }
 
-float Cos(float angle)
+static float Cos(float angle)
 {
 
     return (sinTable[((GLint)angle+(MAXANGLES/4))%MAXANGLES]);
 }
 
-void NewStar(GLint n, GLint d)
+static void NewStar(GLint n, GLint d)
 {
 
     if (rand()%4 == 0) {
@@ -101,7 +101,7 @@ void NewStar(GLint n, GLint d)
     }
 }
 
-void RotatePoint(float *x, float *y, float rotation)
+static void RotatePoint(float *x, float *y, float rotation)
 {
     float tmpX, tmpY;
 
@@ -111,7 +111,7 @@ void RotatePoint(float *x, float *y, float rotation)
     *y = tmpY;
 }
 
-void MoveStars(void)
+static void MoveStars(void)
 {
     float offset;
     GLint n;
@@ -142,7 +142,7 @@ void MoveStars(void)
     }
 }
 
-GLenum StarPoint(GLint n)
+static GLenum StarPoint(GLint n)
 {
     float x0, y0, x1, y1, width;
     GLint i;
@@ -190,7 +190,7 @@ GLenum StarPoint(GLint n)
     }
 }
 
-void ShowStars(void)
+static void ShowStars(void)
 {
     GLint n;
 
@@ -229,7 +229,7 @@ static void Init(void)
     glDisable(GL_DITHER);
 }
 
-void Reshape(int width, int height)
+static void Reshape(int width, int height)
 {
 
     windW = (GLint)width;
@@ -260,7 +260,7 @@ static void Key(unsigned char key, int x, int y)
     }
 }
 
-void Draw(void)
+static void Draw(void)
 {
 
     MoveStars();
@@ -307,7 +307,7 @@ static GLenum Args(int argc, char **argv)
 #define GLUTCALLBACK
 #endif
 
-void GLUTCALLBACK glut_post_redisplay_p(void)
+static void GLUTCALLBACK glut_post_redisplay_p(void)
 {
       glutPostRedisplay();
 }
index 1fd015d794a051e9ee0ce2751d80d8fad5e16951..11201dca230601353b3cb3954ad4ae85cfae0a61 100644 (file)
@@ -67,7 +67,7 @@ int cCount, cIndex[2], cStep;
 GLenum op = OP_NOOP;
 
 
-void DrawImage(void)
+static void DrawImage(void)
 {
 
     glRasterPos2i(0, 0);
@@ -84,7 +84,7 @@ void DrawImage(void)
                 image->data);
 }
 
-void DrawPoint(void)
+static void DrawPoint(void)
 {
     int i;
 
@@ -102,7 +102,7 @@ void DrawPoint(void)
     }
 }
 
-void InitVList(void)
+static void InitVList(void)
 {
 
     vList[0].x = 0.0;
@@ -141,7 +141,7 @@ void InitVList(void)
     vList[4].tY = cList[0].y / (float)imageSizeY;
 }
 
-void ScaleImage(int sizeX, int sizeY)
+static void ScaleImage(int sizeX, int sizeY)
 {
     GLubyte *buf;
 
@@ -154,7 +154,7 @@ void ScaleImage(int sizeX, int sizeY)
     image->sizeY = sizeY;
 }
 
-void SetPoint(int x, int y)
+static void SetPoint(int x, int y)
 {
 
     cList[cCount].x = (float)x;
@@ -162,7 +162,7 @@ void SetPoint(int x, int y)
     cCount++;
 }
 
-void Stretch(void)
+static void Stretch(void)
 {
 
     glBegin(GL_TRIANGLES);
@@ -221,7 +221,7 @@ void Stretch(void)
     }
 }
 
-void Key(unsigned char key, int x, int y)
+static void Key(unsigned char key, int x, int y)
 {
 
     switch (key) {
@@ -245,7 +245,7 @@ void Key(unsigned char key, int x, int y)
     glutPostRedisplay();
 }
 
-void Mouse(int button, int state, int mouseX, int mouseY)
+static void Mouse(int button, int state, int mouseX, int mouseY)
 {
 
     if (state != GLUT_DOWN)
@@ -263,7 +263,7 @@ void Mouse(int button, int state, int mouseX, int mouseY)
     glutPostRedisplay();
 }
 
-void Animate(void)
+static void Animate(void)
 {
     static double t0 = -1.;
     double t, dt;
@@ -322,7 +322,7 @@ static GLenum Args(int argc, char **argv)
 #define GLUTCALLBACK
 #endif
 
-void GLUTCALLBACK glut_post_redisplay_p(void)
+static void GLUTCALLBACK glut_post_redisplay_p(void)
 {
       glutPostRedisplay();
 }
index d3c4687459ebe32112355315becd10d8be76b33a..396a6943e33f35d5a537be0a2e5e5ec5fc978243 100644 (file)
@@ -92,7 +92,7 @@ GLubyte contourTexture2[] = {
 #endif
 
 
-void GLUTCALLBACK glut_post_redisplay_p(void)
+static void GLUTCALLBACK glut_post_redisplay_p(void)
 {
     static double t0 = -1.;
     double t, dt;
index 2753f59f85b5477a14882b071946db7e18bc8be7..dfff6cb226a1b8eb7494cdef5360cd6ebd3b3198 100644 (file)
@@ -237,7 +237,7 @@ void RenderScene (void)
       if (p != NULL)
          p++;
    }
-   if (*p != '\0')
+   if (p && *p != '\0')
       printf ("*** %s\n", "I/O error");
 
    nextprogram = program->next;
index 472ea9b62e2abecb5015122f0bc3f93c81a9b34c..33c6f09dc5521f3615e3b4f808189565b481bd54 100644 (file)
@@ -220,6 +220,12 @@ static void load_test_file (const char *filename)
 
    fseek (f, 0, SEEK_END);
    size = ftell (f);
+
+   if (size == -1) {
+      fclose (f);
+      return;
+   }
+
    fseek (f, 0, SEEK_SET);
 
    code = (char *) (malloc (size));
index 4d9b4e8388c003f1fcc1a946b8ec1bf452774b34..836396b24995a5699d2582377bc0cd35f96ce6d6 100644 (file)
@@ -25,9 +25,11 @@ SOURCES = \
        arbvptorus.c \
        arbvpwarpmesh.c \
        arraytexture.c \
+       auxbuffer.c \
        blendminmax.c \
        blendsquare.c \
        blendxor.c \
+       blitfb.c \
        bufferobj.c \
        bumpmap.c \
        bug_3050.c \
@@ -35,11 +37,14 @@ SOURCES = \
        bug_3195.c \
        bug_texstore_i8.c \
        calibrate_rast.c \
+       condrender.c \
        copypixrate.c \
        crossbar.c \
        cva.c \
        drawbuffers.c \
+       drawbuffers2.c \
        exactrast.c \
+       ext422square.c \
        floattex.c \
        fbotest1.c \
        fbotest2.c \
@@ -65,6 +70,8 @@ SOURCES = \
        mipmap_limits.c \
        mipmap_view.c \
        multipal.c \
+       multitexarray.c \
+       multiwindow.c \
        no_s3tc.c \
        packedpixels.c \
        pbo.c \
@@ -87,10 +94,13 @@ SOURCES = \
        subtex \
        subtexrate.c \
        tex1d.c \
+       texcmp.c \
        texcompress2.c \
        texcompsub.c \
        texdown \
        texfilt.c \
+       texgenmix.c \
+       texleak.c \
        texline.c \
        texobj.c \
        texobjshare.c \
@@ -100,6 +110,7 @@ SOURCES = \
        vao-01.c \
        vao-02.c \
        vparray.c \
+       vpeval.c \
        vptest1.c \
        vptest2.c \
        vptest3.c \
index bb6a1d2b8a99bcb1f8edbb7d541204cf30567d2e..e2c6538288746cae531dd33e91e8296dab6bb251 100644 (file)
@@ -1,23 +1,5 @@
 Import('*')
 
-if not env['GLUT']:
-    Return()
-
-env = env.Clone()
-
-env.Prepend(CPPPATH = [
-       '../util',
-])
-
-env.Prepend(LIBS = [
-       util,
-       '$GLUT_LIB'
-])
-
-if env['platform'] == 'windows':
-    env.Append(CPPDEFINES = ['NOMINMAX'])
-    env.Prepend(LIBS = ['winmm'])
-
 linux_progs = [
     'api_speed',
 ]
@@ -52,16 +34,19 @@ progs = [
     'blendminmax',
     'blendsquare',
     'blendxor',
+    'blitfb',
     'bufferobj',
     'bug_3050',
     'bug_3101',
     'bug_3195',
     'bug_texstore_i8',
     'calibrate_rast',
+    'condrender',
     'copypixrate',
     'crossbar',
     'cva',
     'drawbuffers',
+    'drawbuffers2',
     'exactrast',
     'ext422square',
     'fbotest1',
@@ -137,7 +122,7 @@ progs = [
 ]
 
 for prog in progs:
-    env.Program(
+    progs_env.Program(
         target = prog,
         source = prog + '.c',
     )
index 23aa899d9634b2a68b4a2ef971b068e83d40144b..6098dca787b4a9eaf9b181507fc43e6aa0be2fc1 100644 (file)
@@ -134,6 +134,8 @@ static void Init( const char *vertProgFile,
       }
 
       len = fread(buf, 1, 10*1000,f);
+      fclose(f);
+
       glProgramStringARB_func(GL_VERTEX_PROGRAM_ARB,
                               GL_PROGRAM_FORMAT_ASCII_ARB,
                               len,
@@ -170,6 +172,8 @@ static void Init( const char *vertProgFile,
       }
 
       len = fread(buf, 1, 10*1000,f);
+      fclose(f);
+
       glProgramStringARB_func(GL_FRAGMENT_PROGRAM_ARB,
                               GL_PROGRAM_FORMAT_ASCII_ARB,
                               len,
index 6c0484df0de69d70c7b78ce65c95ddf9430de882..28252a354bffbf60ecfc86b672a2f74d484f5115 100644 (file)
@@ -77,10 +77,6 @@ static GLfloat texZ = 0.0;
 static GLfloat texZ_dir = 0.01;
 static GLint num_layers;
 
-static PFNGLBINDPROGRAMARBPROC bind_program;
-static PFNGLPROGRAMSTRINGARBPROC program_string;
-static PFNGLGENPROGRAMSARBPROC gen_programs;
-
 
 static void
 PrintString(const char *s)
@@ -125,13 +121,13 @@ static void Display(void)
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
 
-   (*bind_program)(GL_FRAGMENT_PROGRAM_ARB, 0);
+   glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0);
    glColor3f(1,1,1);
    glRasterPos3f(-0.9, -0.9, 0.0);
    sprintf(str, "Texture Z coordinate = %4.1f", texZ);
    PrintString(str);
 
-   (*bind_program)(GL_FRAGMENT_PROGRAM_ARB, 1);
+   glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 1);
    GL_CHECK_ERROR();
    glEnable(GL_TEXTURE_2D_ARRAY_EXT);
    GL_CHECK_ERROR();
@@ -159,7 +155,7 @@ static void Display(void)
 
    glDisable(GL_TEXTURE_2D_ARRAY_EXT);
    GL_CHECK_ERROR();
-   (*bind_program)(GL_FRAGMENT_PROGRAM_ARB, 0);
+   glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0);
    GL_CHECK_ERROR();
 
    glutSwapBuffers();
@@ -226,8 +222,8 @@ compile_fragment_program(GLuint id, const char *prog)
    int err;
 
    err = glGetError();
-   (*bind_program)(GL_FRAGMENT_PROGRAM_ARB, id);
-   (*program_string)(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
+   glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, id);
+   glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
                      strlen(prog), (const GLubyte *) prog);
 
    glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorPos);
@@ -264,11 +260,6 @@ static void Init(void)
    require_extension("GL_MESA_texture_array");
    require_extension("GL_SGIS_generate_mipmap");
 
-   bind_program = glutGetProcAddress("glBindProgramARB");
-   program_string = glutGetProcAddress("glProgramStringARB");
-   gen_programs = glutGetProcAddress("glGenProgramsARB");
-
-
    for (num_layers = 0; textures[num_layers] != NULL; num_layers++)
       /* empty */ ;
 
diff --git a/progs/tests/blitfb.c b/progs/tests/blitfb.c
new file mode 100644 (file)
index 0000000..18c8380
--- /dev/null
@@ -0,0 +1,259 @@
+/**
+ * Test glFramebufferBlit()
+ * Brian Paul
+ * 27 Oct 2009
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <GL/glew.h>
+#include <GL/glut.h>
+
+
+static int Win;
+static int WinWidth = 1100, WinHeight = 600;
+
+static int SrcWidth = 512, SrcHeight = 512;
+static int DstWidth = 512, DstHeight = 512;
+
+static GLuint SrcFB, DstFB;
+static GLuint SrcTex, DstTex;
+
+#if 0
+static GLenum SrcTexTarget = GL_TEXTURE_2D, SrcTexFace = GL_TEXTURE_2D;
+#else
+static GLenum SrcTexTarget = GL_TEXTURE_CUBE_MAP, SrcTexFace = GL_TEXTURE_CUBE_MAP_POSITIVE_X;
+#endif
+
+static GLenum DstTexTarget = GL_TEXTURE_2D, DstTexFace = GL_TEXTURE_2D;
+
+static GLuint SrcTexLevel = 01, DstTexLevel = 0;
+
+
+static void
+Draw(void)
+{
+   GLboolean rp = GL_FALSE;
+   GLubyte *buf;
+   GLint srcWidth = SrcWidth >> SrcTexLevel;
+   GLint srcHeight = SrcHeight >> SrcTexLevel;
+   GLint dstWidth = DstWidth >> DstTexLevel;
+   GLint dstHeight = DstHeight >> DstTexLevel;
+   GLenum status;
+
+   /* clear window */
+   glBindFramebufferEXT(GL_FRAMEBUFFER, 0);
+   glClearColor(0.5, 0.5, 0.5, 1.0);
+   glClear(GL_COLOR_BUFFER_BIT);
+
+
+   /* clear src buf */
+   glBindFramebufferEXT(GL_FRAMEBUFFER, SrcFB);
+   status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
+   assert(status == GL_FRAMEBUFFER_COMPLETE_EXT);
+   glClearColor(0, 1, 0, 0);
+   glClear(GL_COLOR_BUFFER_BIT);
+
+   /* clear dst buf */
+   glBindFramebufferEXT(GL_FRAMEBUFFER, DstFB);
+   status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
+   assert(status == GL_FRAMEBUFFER_COMPLETE_EXT);
+   glClearColor(1, 0, 0, 0);
+   glClear(GL_COLOR_BUFFER_BIT);
+
+   /* blit src -> dst */
+   glBindFramebufferEXT(GL_READ_FRAMEBUFFER, SrcFB);
+   glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, DstFB);
+   glBlitFramebufferEXT(0, 0, srcWidth, srcHeight,
+                        0, 0, dstWidth, dstHeight,
+                        GL_COLOR_BUFFER_BIT, GL_NEAREST);
+
+#if 01
+   /* read src results */
+   buf = malloc(4 * srcWidth * srcHeight);
+   memset(buf, 0x88, 4 * srcWidth * srcHeight);
+   glBindFramebufferEXT(GL_FRAMEBUFFER, SrcFB);
+   if (rp)
+      glReadPixels(0, 0, srcWidth, srcHeight, GL_RGBA, GL_UNSIGNED_BYTE, buf);
+   else {
+      glBindTexture(SrcTexTarget, SrcTex);
+      glGetTexImage(SrcTexFace, SrcTexLevel, GL_RGBA, GL_UNSIGNED_BYTE, buf);
+   }
+
+   /* draw dst in window */
+   glBindFramebufferEXT(GL_FRAMEBUFFER, 0);
+   glWindowPos2i(0, 0);
+   glDrawPixels(srcWidth, srcHeight, GL_RGBA, GL_UNSIGNED_BYTE, buf);
+
+   printf("Src Pix[0] = %d %d %d %d\n", buf[0], buf[1], buf[2], buf[3]);
+   free(buf);
+#endif
+
+   glFinish();
+
+   /* read dst results */
+   buf = malloc(4 * dstWidth * dstHeight);
+   memset(buf, 0x88, 4 * dstWidth * dstHeight);
+   glBindFramebufferEXT(GL_FRAMEBUFFER, DstFB);
+   if (rp)
+      glReadPixels(0, 0, dstWidth, dstHeight, GL_RGBA, GL_UNSIGNED_BYTE, buf);
+   else {
+      glBindTexture(DstTexTarget, DstTex);
+      glGetTexImage(DstTexFace, DstTexLevel, GL_RGBA, GL_UNSIGNED_BYTE, buf);
+   }
+
+   /* draw dst in window */
+   glBindFramebufferEXT(GL_FRAMEBUFFER, 0);
+   glWindowPos2i(srcWidth + 2, 0);
+   glDrawPixels(dstWidth, dstHeight, GL_RGBA, GL_UNSIGNED_BYTE, buf);
+
+   printf("Dst Pix[0] = %d %d %d %d\n", buf[0], buf[1], buf[2], buf[3]);
+   free(buf);
+
+   glFinish();
+
+   glutSwapBuffers();
+}
+
+
+static void
+Reshape(int width, int height)
+{
+   WinWidth = width;
+   WinHeight = height;
+   glViewport(0, 0, width, height);
+   glMatrixMode(GL_PROJECTION);
+   glLoadIdentity();
+   glFrustum(-1.0, 1.0, -1.0, 1.0, 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
+SpecialKey(int key, int x, int y)
+{
+   (void) x;
+   (void) y;
+   switch (key) {
+   }
+   glutPostRedisplay();
+}
+
+
+static void
+InitFBOs(void)
+{
+   GLuint w, h, lvl;
+
+   /* Src */
+   glGenTextures(1, &SrcTex);
+   glBindTexture(SrcTexTarget, SrcTex);
+   w = SrcWidth;
+   h = SrcHeight;
+   lvl = 0;
+   for (lvl = 0; ; lvl++) {
+      if (SrcTexTarget == GL_TEXTURE_CUBE_MAP) {
+         GLuint f;
+         for (f = 0; f < 6; f++) {
+            glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + f, lvl, GL_RGBA8,
+                         w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+         }
+      }
+      else {
+         /* single face */
+         glTexImage2D(SrcTexFace, lvl, GL_RGBA8, w, h, 0,
+                      GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+      }
+      if (w == 1 && h == 1)
+         break;
+      if (w > 1)
+         w /= 2;
+      if (h > 1)
+         h /= 2;
+   }
+
+   glGenFramebuffersEXT(1, &SrcFB);
+   glBindFramebufferEXT(GL_FRAMEBUFFER, SrcFB);
+   glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
+                             SrcTexFace, SrcTex, SrcTexLevel);
+
+   /* Dst */
+   glGenTextures(1, &DstTex);
+   glBindTexture(DstTexTarget, DstTex);
+   w = DstWidth;
+   h = DstHeight;
+   lvl = 0;
+   for (lvl = 0; ; lvl++) {
+      glTexImage2D(DstTexFace, lvl, GL_RGBA8, w, h, 0,
+                   GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+      if (w == 1 && h == 1)
+         break;
+      if (w > 1)
+         w /= 2;
+      if (h > 1)
+         h /= 2;
+   }
+
+   glGenFramebuffersEXT(1, &DstFB);
+   glBindFramebufferEXT(GL_FRAMEBUFFER, DstFB);
+   glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
+                             DstTexFace, DstTex, DstTexLevel);
+}
+
+
+static void
+Init(void)
+{
+   if (!glutExtensionSupported("GL_EXT_framebuffer_object")) {
+      fprintf(stderr, "This test requires GL_EXT_framebuffer_object\n");
+      exit(1);
+   }
+
+   if (!glutExtensionSupported("GL_EXT_framebuffer_blit")) {
+      fprintf(stderr, "This test requires GL_EXT_framebuffer_blit,\n");
+      exit(1);
+   }
+
+   InitFBOs();
+
+   printf("Left rect = src FBO, Right rect = dst FBO.\n");
+   printf("Both should be green.\n");
+}
+
+
+int
+main(int argc, char *argv[])
+{
+   glutInit(&argc, argv);
+   glutInitWindowSize(WinWidth, WinHeight);
+   glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
+   Win = glutCreateWindow(argv[0]);
+   glewInit();
+   glutReshapeFunc(Reshape);
+   glutKeyboardFunc(Key);
+   glutSpecialFunc(SpecialKey);
+   glutDisplayFunc(Draw);
+   Init();
+   glutMainLoop();
+   return 0;
+}
index 10e5eba7c5e0eace8764ae987d90d7752ca192bb..b070011bd2ea452b6fdb18a46659b78c529a9d15 100644 (file)
@@ -73,7 +73,7 @@ static void Init(void)
                        0,
                        sourceFormat,
                        GL_UNSIGNED_BYTE,
-                       //GL_UNSIGNED_INT,
+                       /* GL_UNSIGNED_INT, */
                        tex2d);
 
                glEnable(Target);
diff --git a/progs/tests/condrender.c b/progs/tests/condrender.c
new file mode 100644 (file)
index 0000000..1db8a7c
--- /dev/null
@@ -0,0 +1,242 @@
+/*
+ * Test GL_NV_conditional_render
+ *
+ * Brian Paul
+ * 30 Dec 2009
+ *
+ * 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"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <GL/glew.h>
+#include <GL/glut.h>
+
+#define TEST_DISPLAY_LISTS 0
+
+static GLboolean Anim = GL_TRUE;
+static GLfloat Xpos = 0;
+static GLuint OccQuery;
+static GLint Win = 0;
+
+
+static void Idle(void)
+{
+   static int lastTime = 0;
+   static int sign = +1;
+   int time = glutGet(GLUT_ELAPSED_TIME);
+   float step;
+
+   if (lastTime == 0)
+      lastTime = time;
+   else if (time - lastTime < 20)  /* 50Hz update */
+      return;
+
+   step = (time - lastTime) / 1000.0 * sign;
+   lastTime = time;
+
+   Xpos += step;
+
+   if (Xpos > 2.5) {
+      Xpos = 2.5;
+      sign = -1;
+   }
+   else if (Xpos < -2.5) {
+      Xpos = -2.5;
+      sign = +1;
+   }
+   glutPostRedisplay();
+}
+
+
+static void Display( void )
+{
+   glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+   glEnable(GL_DEPTH_TEST);
+
+   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 );
+
+   /* draw the occluding polygons */
+   glColor3f(0, 0.6, 0.8);
+   glBegin(GL_QUADS);
+   glVertex2f(-1.6, -1.5);
+   glVertex2f(-0.4, -1.5);
+   glVertex2f(-0.4,  1.5);
+   glVertex2f(-1.6,  1.5);
+
+   glVertex2f( 0.4, -1.5);
+   glVertex2f( 1.6, -1.5);
+   glVertex2f( 1.6,  1.5);
+   glVertex2f( 0.4,  1.5);
+   glEnd();
+
+   /* draw the test polygon with occlusion testing */
+   glPushMatrix();
+   glTranslatef(Xpos, 0, -0.5);
+   glScalef(0.3, 0.3, 1.0);
+   glRotatef(-90.0 * Xpos, 0, 0, 1);
+
+#if TEST_DISPLAY_LISTS
+   glNewList(10, GL_COMPILE);
+   glBeginQueryARB(GL_SAMPLES_PASSED_ARB, OccQuery);
+   glEndList();
+   glCallList(10);
+#else
+   glBeginQueryARB(GL_SAMPLES_PASSED_ARB, OccQuery);
+#endif
+
+   glColorMask(0, 0, 0, 0);
+   glDepthMask(GL_FALSE);
+
+   glBegin(GL_POLYGON);
+   glVertex3f(-1, -1, 0);
+   glVertex3f( 1, -1, 0);
+   glVertex3f( 1,  1, 0);
+   glVertex3f(-1,  1, 0);
+   glEnd();
+
+#if TEST_DISPLAY_LISTS
+   glNewList(11, GL_COMPILE);
+   glEndQueryARB(GL_SAMPLES_PASSED_ARB);
+   glEndList();
+   glCallList(11);
+#else
+   glEndQueryARB(GL_SAMPLES_PASSED_ARB);
+#endif
+
+   glColorMask(1, 1, 1, 1);
+   glDepthMask(GL_TRUE);
+
+   /* Note: disable depth test here so that we'll always see the orange
+    * box, except when it's totally culled.
+    */
+   glDisable(GL_DEPTH_TEST);
+
+   glBeginConditionalRenderNV(OccQuery, GL_QUERY_WAIT_NV);
+      /* draw the orange rect, so we can see what's going on */
+      glColor3f(0.8, 0.5, 0);
+      glBegin(GL_POLYGON);
+         glVertex3f(-1, -1, 0);
+         glVertex3f( 1, -1, 0);
+         glVertex3f( 1,  1, 0);
+         glVertex3f(-1,  1, 0);
+      glEnd();
+   glEndConditionalRenderNV();
+
+   /* always draw white outline around orange box */
+   glColor3f(1.0, 1.0, 1.0);
+   glBegin(GL_LINE_LOOP);
+      glVertex3f(-1, -1, 0);
+      glVertex3f( 1, -1, 0);
+      glVertex3f( 1,  1, 0);
+       glVertex3f(-1,  1, 0);
+   glEnd();
+
+   glPopMatrix();
+
+   glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+   glViewport( 0, 0, width, height );
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+   (void) x;
+   (void) y;
+   switch (key) {
+   case 27:
+      glDeleteQueriesARB(1, &OccQuery);
+      glutDestroyWindow(Win);
+      exit(0);
+      break;
+   case ' ':
+      Anim = !Anim;
+      if (Anim)
+         glutIdleFunc(Idle);
+      else
+         glutIdleFunc(NULL);
+      break;
+   }
+   glutPostRedisplay();
+}
+
+
+static void SpecialKey( int key, int x, int y )
+{
+   const GLfloat step = 0.1;
+   (void) x;
+   (void) y;
+   switch (key) {
+   case GLUT_KEY_LEFT:
+      Xpos -= step;
+      break;
+   case GLUT_KEY_RIGHT:
+      Xpos += step;
+      break;
+   }
+   glutPostRedisplay();
+}
+
+
+static void Init( void )
+{
+   if (!glutExtensionSupported("GL_ARB_occlusion_query") ||
+       !glutExtensionSupported("GL_NV_conditional_render")) {
+      printf("Sorry, this demo requires the extensions:\n");
+      printf("  GL_ARB_occlusion_query\n");
+      printf("  GL_NV_conditional_render\n");
+      exit(-1);
+   }
+
+   glGenQueriesARB(1, &OccQuery);
+   assert(OccQuery > 0);
+}
+
+
+int main( int argc, char *argv[] )
+{
+   glutInitWindowSize( 400, 400 );
+   glutInit( &argc, argv );
+   glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
+   Win = glutCreateWindow(argv[0]);
+   glewInit();
+   glutReshapeFunc( Reshape );
+   glutKeyboardFunc( Key );
+   glutSpecialFunc( SpecialKey );
+   glutIdleFunc( Idle );
+   glutDisplayFunc( Display );
+   Init();
+   glutMainLoop();
+   return 0;
+}
index 3dd21372f9a80f3d2458e059952eb4e214f474a1..2988e20920026078c1240c072ad5ecc9e67546fa 100644 (file)
@@ -145,7 +145,7 @@ static void Init( void )
 {
    const char * const ver_string = (const char * const)
        glGetString( GL_VERSION );
-   float ver = strtof( ver_string, NULL );
+   float ver = strtod( ver_string, NULL );
    GLint tex_units;
    GLint temp[ 256 ];
 
@@ -174,7 +174,7 @@ static void Init( void )
       exit(1);
    }
 
-   printf("\nAll %u squares should be the same color.\n", NUM_TESTS + 1);
+   printf("\nAll %lu squares should be the same color.\n", (unsigned long) NUM_TESTS + 1);
    
    (void) memset( temp, 0x00, sizeof( temp ) );
    glBindTexture( GL_TEXTURE_2D, 1 );
index 80483900cb7d077bb80aed85de9c9438533546f4..02d1dcba2ec5806ae74a90a6dc58e7cbf22a4166 100644 (file)
@@ -39,7 +39,7 @@ GLboolean compiled = GL_TRUE;
 GLboolean doubleBuffer = GL_TRUE;
 
 
-void init( void )
+static void init( void )
 {
    glClearColor( 0.0, 0.0, 0.0, 0.0 );
    glShadeModel( GL_SMOOTH );
@@ -69,7 +69,7 @@ void init( void )
 #endif
 }
 
-void display( void )
+static void display( void )
 {
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
 
@@ -81,7 +81,7 @@ void display( void )
    }
 }
 
-void keyboard( unsigned char key, int x, int y )
+static void keyboard( unsigned char key, int x, int y )
 {
    switch ( key ) {
       case 27:
@@ -92,7 +92,7 @@ void keyboard( unsigned char key, int x, int y )
    glutPostRedisplay();
 }
 
-GLboolean args( int argc, char **argv )
+static GLboolean args( int argc, char **argv )
 {
     GLint i;
 
index d75a870c26bcf32778beefde5edaa3a337e53151..7a19933e6273e7795825846297bc118795f5d2ca 100644 (file)
@@ -43,6 +43,8 @@ Display(void)
 
    glUseProgram_func(Program);
 
+   glEnable(GL_DEPTH_TEST);
+
    /* draw to user framebuffer */
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBobject);
 
@@ -68,18 +70,23 @@ Display(void)
    glPopMatrix();
 
    /* read from user framebuffer */
-   /* bottom half = colorbuffer 0 */
+   /* left half = colorbuffer 0 */
    glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
-   glReadPixels(0, 0, Width, Height / 2, GL_RGBA, GL_UNSIGNED_BYTE,
+   glPixelStorei(GL_PACK_ROW_LENGTH, Width);
+   glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
+   glReadPixels(0, 0, Width / 2, Height, GL_RGBA, GL_UNSIGNED_BYTE,
                 buffer);
-   /* top half = colorbuffer 1 */
+
+   /* right half = colorbuffer 1 */
    glReadBuffer(GL_COLOR_ATTACHMENT1_EXT);
-   glReadPixels(0, Height/2, Width, Height - Height / 2,
+   glPixelStorei(GL_PACK_SKIP_PIXELS, Width / 2);
+   glReadPixels(Width / 2, 0, Width - Width / 2, Height,
                 GL_RGBA, GL_UNSIGNED_BYTE,
-                buffer + Width * (Height / 2) * 4);
+                buffer);
 
    /* draw to window */
    glUseProgram_func(0);
+   glDisable(GL_DEPTH_TEST);
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    glWindowPos2iARB(0, 0);
    glDrawPixels(Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
diff --git a/progs/tests/drawbuffers2.c b/progs/tests/drawbuffers2.c
new file mode 100644 (file)
index 0000000..7b8cc5c
--- /dev/null
@@ -0,0 +1,364 @@
+/*
+ * Test GL_ARB_draw_buffers2, GL_ARB_draw_buffers, GL_EXT_framebuffer_object
+ * and GLSL's gl_FragData[].
+ *
+ * We draw to two color buffers and show the left half of the first
+ * color buffer on the left side of the window, and show the right
+ * half of the second color buffer on the right side of the window.
+ *
+ * Different color masks are used for the two color buffers.
+ * Blending is enabled for the second buffer only.
+ *
+ * Brian Paul
+ * 31 Dec 2009
+ */
+
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glew.h>
+#include <GL/glut.h>
+#include "extfuncs.h"
+
+static int Win;
+static int Width = 400, Height = 400;
+static GLuint FBobject, RBobjects[3];
+static GLfloat Xrot = 0.0, Yrot = 0.0;
+static GLuint Program;
+static GLboolean Anim = GL_TRUE;
+
+
+static void
+CheckError(int line)
+{
+   GLenum err = glGetError();
+   if (err) {
+      printf("GL Error 0x%x at line %d\n", (int) err, line);
+   }
+}
+
+
+static void
+Display(void)
+{
+   GLubyte *buffer = malloc(Width * Height * 4);
+   static const GLenum buffers[2] = {
+      GL_COLOR_ATTACHMENT0_EXT,
+      GL_COLOR_ATTACHMENT1_EXT
+   };
+
+   glUseProgram_func(Program);
+
+   glEnable(GL_DEPTH_TEST);
+
+   /* draw to user framebuffer */
+   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBobject);
+
+   /* Clear color buffer 0 (blue) */
+   glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
+   glClear(GL_COLOR_BUFFER_BIT);
+
+   /* Clear color buffer 1 (1 - blue) */
+   glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT);
+   glClear(GL_COLOR_BUFFER_BIT);
+
+   glClear(GL_DEPTH_BUFFER_BIT);
+
+   /* draw to two buffers w/ fragment shader */
+   glDrawBuffersARB(2, buffers);
+
+   /* different color masks for each buffer */
+   if (1) {
+   glColorMaskIndexedEXT(0, GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE);
+   glColorMaskIndexedEXT(1, GL_FALSE, GL_TRUE, GL_FALSE, GL_FALSE);
+   }
+
+   glPushMatrix();
+   glRotatef(Xrot, 1, 0, 0);
+   glRotatef(Yrot, 0, 1, 0);
+   glPushMatrix();
+   glTranslatef(1, 0, 0);
+   glutSolidTorus(1.0, 2.0, 10, 20);
+   glPopMatrix();
+   glPushMatrix();
+   glTranslatef(-1, 0, 0);
+   glRotatef(90, 1, 0, 0);
+   glutSolidTorus(1.0, 2.0, 10, 20);
+   glPopMatrix();
+   glPopMatrix();
+
+   /* restore default color masks */
+   glColorMaskIndexedEXT(0, GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+   glColorMaskIndexedEXT(1, GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+
+   /* read from user framebuffer */
+   /* left half = colorbuffer 0 */
+   glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
+   glPixelStorei(GL_PACK_ROW_LENGTH, Width);
+   glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
+   glReadPixels(0, 0, Width / 2, Height, GL_RGBA, GL_UNSIGNED_BYTE,
+                buffer);
+
+   /* right half = colorbuffer 1 */
+   glReadBuffer(GL_COLOR_ATTACHMENT1_EXT);
+   glPixelStorei(GL_PACK_SKIP_PIXELS, Width / 2);
+   glReadPixels(Width / 2, 0, Width - Width / 2, Height,
+                GL_RGBA, GL_UNSIGNED_BYTE,
+                buffer);
+
+   /* draw to window */
+   glUseProgram_func(0);
+   glDisable(GL_DEPTH_TEST);
+   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+   glWindowPos2iARB(0, 0);
+   glDrawPixels(Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
+
+   free(buffer);
+   glutSwapBuffers();
+   CheckError(__LINE__);
+}
+
+
+static void
+Idle(void)
+{
+   Xrot = glutGet(GLUT_ELAPSED_TIME) * 0.05;
+   glutPostRedisplay();
+}
+
+
+static void
+Reshape(int width, int height)
+{
+   float ar = (float) width / (float) height;
+
+   glViewport(0, 0, width, height);
+   glMatrixMode(GL_PROJECTION);
+   glLoadIdentity();
+   glFrustum(-ar, ar, -1.0, 1.0, 5.0, 35.0);
+   glMatrixMode(GL_MODELVIEW);
+   glLoadIdentity();
+   glTranslatef(0.0, 0.0, -20.0);
+
+   Width = width;
+   Height = height;
+
+   glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RBobjects[0]);
+   glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height);
+   glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RBobjects[1]);
+   glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height);
+   glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RBobjects[2]);
+   glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT,
+                            Width, Height);
+}
+
+
+static void
+CleanUp(void)
+{
+   glDeleteFramebuffersEXT(1, &FBobject);
+   glDeleteRenderbuffersEXT(3, RBobjects);
+   glutDestroyWindow(Win);
+   exit(0);
+}
+
+
+static void
+Key(unsigned char key, int x, int y)
+{
+   (void) x;
+   (void) y;
+   switch (key) {
+   case ' ':
+      Anim = !Anim;
+      glutIdleFunc(Anim ? Idle : NULL);
+      break;
+   case 'x':
+      Xrot += 5.0;
+      break;
+   case 'X':
+      Xrot -= 5.0;
+      break;
+   case 'y':
+      Yrot += 5.0;
+      break;
+   case 'Y':
+      Yrot -= 5.0;
+      break;
+   case 27:
+      CleanUp();
+      break;
+   }
+   glutPostRedisplay();
+}
+
+
+static void
+CheckExtensions(void)
+{
+   const char *req[] = {
+      "GL_EXT_framebuffer_object",
+      "GL_ARB_draw_buffers",
+      "GL_EXT_draw_buffers2"
+   };
+
+   const char *version = (const char *) glGetString(GL_VERSION);
+   GLint numBuf;
+   GLint i;
+
+   for (i = 0; i < 3; i++) {
+      if (!glutExtensionSupported(req[i])) {
+         printf("Sorry, %s extension is required!\n", req[i]);
+         exit(1);
+      }
+   }
+   if (version[0] != '2') {
+      printf("Sorry, OpenGL 2.0 is required!\n");
+      exit(1);
+   }
+
+   glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &numBuf);
+   printf("GL_MAX_DRAW_BUFFERS_ARB = %d\n", numBuf);
+   if (numBuf < 2) {
+      printf("Sorry, GL_MAX_DRAW_BUFFERS_ARB needs to be >= 2\n");
+      exit(1);
+   }
+
+   printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+}
+
+
+static void
+SetupRenderbuffers(void)
+{
+   glGenFramebuffersEXT(1, &FBobject);
+   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBobject);
+
+   glGenRenderbuffersEXT(3, RBobjects);
+
+   glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RBobjects[0]);
+   glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height);
+
+   glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RBobjects[1]);
+   glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height);
+
+   glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RBobjects[2]);
+   glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT,
+                            Width, Height);
+
+   glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
+                                GL_RENDERBUFFER_EXT, RBobjects[0]);
+   glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT,
+                                GL_RENDERBUFFER_EXT, RBobjects[1]);
+   glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
+                                GL_RENDERBUFFER_EXT, RBobjects[2]);
+
+   CheckError(__LINE__);
+}
+
+
+static GLuint
+LoadAndCompileShader(GLenum target, const char *text)
+{
+   GLint stat;
+   GLuint shader = glCreateShader_func(target);
+   glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
+   glCompileShader_func(shader);
+   glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
+   if (!stat) {
+      GLchar log[1000];
+      GLsizei len;
+      glGetShaderInfoLog_func(shader, 1000, &len, log);
+      fprintf(stderr, "drawbuffers: problem compiling shader:\n%s\n", log);
+      exit(1);
+   }
+   return shader;
+}
+
+
+static void
+CheckLink(GLuint prog)
+{
+   GLint stat;
+   glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
+   if (!stat) {
+      GLchar log[1000];
+      GLsizei len;
+      glGetProgramInfoLog_func(prog, 1000, &len, log);
+      fprintf(stderr, "drawbuffers: shader link error:\n%s\n", log);
+   }
+}
+
+
+static void
+SetupShaders(void)
+{
+   /* emit same color to both draw buffers */
+   static const char *fragShaderText =
+      "void main() {\n"
+      "   gl_FragData[0] = gl_Color; \n"
+      "   gl_FragData[1] = gl_Color; \n"
+      "}\n";
+
+   GLuint fragShader;
+
+   fragShader = LoadAndCompileShader(GL_FRAGMENT_SHADER, fragShaderText);
+   Program = glCreateProgram_func();
+
+   glAttachShader_func(Program, fragShader);
+   glLinkProgram_func(Program);
+   CheckLink(Program);
+   glUseProgram_func(Program);
+}
+
+
+static void
+SetupLighting(void)
+{
+   static const GLfloat ambient[4] = { 0.0, 0.0, 0.0, 0.0 };
+   static const GLfloat diffuse[4] = { 1.0, 1.0, 1.0, 0.75 };
+
+   glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient);
+   glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient);
+   glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse);
+
+   glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0);
+   glEnable(GL_LIGHT0);
+   glEnable(GL_LIGHTING);
+}
+
+
+static void
+Init(void)
+{
+   CheckExtensions();
+   GetExtensionFuncs();
+   SetupRenderbuffers();
+   SetupShaders();
+   SetupLighting();
+   glEnable(GL_DEPTH_TEST);
+
+   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+   glEnableIndexedEXT(GL_BLEND, 1);
+}
+
+
+int
+main(int argc, char *argv[])
+{
+   glutInit(&argc, argv);
+   glutInitWindowPosition(0, 0);
+   glutInitWindowSize(Width, Height);
+   glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
+   Win = glutCreateWindow(argv[0]);
+   glewInit();
+   glutIdleFunc(Anim ? Idle : NULL);
+   glutReshapeFunc(Reshape);
+   glutKeyboardFunc(Key);
+   glutDisplayFunc(Display);
+   Init();
+   glutMainLoop();
+   return 0;
+}
index 2b8f8d0f5ec30529025039fdc491a5a2a073502f..1f30d5733e7051d8fefb269e0c8c0634e11e5da0 100644 (file)
@@ -57,6 +57,7 @@ static void Key( unsigned char key, int x, int y )
 
 static void Init( void )
 {
+#if 0
    static const char *prog0 =
       "!!FP1.0\n"
       "MUL   o[COLR], R0, f[WPOS]; \n"
@@ -73,6 +74,7 @@ static void Init( void )
       "MOV   HC, H2; \n"
       "END \n"
       ;
+#endif
 
    /* masked updates, defines, declarations */
    static const char *prog1 =
index a09ea58e1da64e9802b3bad115d040b53ff0d262..e699baf44bc0810be71725fd329e02c88e6ace14 100644 (file)
@@ -1188,7 +1188,7 @@ exercise_buffer_objects(enum Map_Buffer_Usage usage)
    GLuint bufferID;
    GLint bufferMapped;
    static GLubyte data[BUFFER_DATA_SIZE] = {0};
-   float *dataPtr;
+   float *dataPtr = NULL;
 
    /* Get the function pointers we need.  These are from
     * GL_ARB_vertex_buffer_object and are required in all
@@ -3516,7 +3516,7 @@ check_functions( const char *extensions )
    struct name_test_pair *entry;
    int failures = 0, passes = 0, untested = 0;
    int totalFail = 0, totalPass = 0, totalUntested = 0, totalUnsupported = 0;
-   int doTests;
+   int doTests = 0;
    const char *version = (const char *) glGetString(GL_VERSION);
 
    /* The functions list will have "real" entries (consisting of
index 71f29b4ac843a45811f95cb5f17c664e63795639..e4053b8de1a5e43ba47330df58d813d0a55d1992 100644 (file)
@@ -58,6 +58,26 @@ TestGetTexImage(GLboolean npot)
             abort();
          }
       }
+
+      /* get as BGRA */
+      glGetTexImage(GL_TEXTURE_2D, level, GL_BGRA, GL_UNSIGNED_BYTE, data2);
+
+      /* compare */
+      {
+         const GLubyte *rgba = (GLubyte *) data;
+         const GLubyte *bgra = (GLubyte *) data2;
+         for (i = 0; i < w * h; i += 4) {
+            if (rgba[i+0] != bgra[i+2] ||
+                rgba[i+1] != bgra[i+1] ||
+                rgba[i+2] != bgra[i+0] ||
+                rgba[i+3] != bgra[i+3]) {
+               printf("glTexImage + glGetTexImage(GL_BGRA) failure!\n");
+               printf("Expected value %d, found %d\n", data[i], data2[i]);
+               abort();
+            }
+         }
+      }
+
    }
 
    printf("Passed\n");
index 63099fbd22105063e8a9836a5a22966a74c4dbef..45001b44d0798b0275858ac5c1ce5abf2451089b 100644 (file)
@@ -128,7 +128,7 @@ static void Init( void )
 {
    const char * const ver_string = (const char * const)
        glGetString( GL_VERSION );
-   const float ver = strtof( ver_string, NULL );
+   const float ver = strtod( ver_string, NULL );
 
 
    printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
@@ -165,7 +165,7 @@ static void Init( void )
          "square should look upside-down.\n");
    
 
-   image = LoadRGBImage( IMAGE_FILE, & img_width, & img_height,
+   image = LoadRGBImage( IMAGE_FILE, (GLint *) & img_width, (GLint *) & img_height,
                         & img_format );
    if ( image == NULL ) {
       printf( "Could not open image file \"%s\".\n", IMAGE_FILE );
index 03019f94faa6c276747d6a52cfc167ada46ccfe2..179be511207fa4a480d3151fa2976b9abf2df4a0 100644 (file)
@@ -16,7 +16,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 #include <GL/glew.h>
 #include <GL/glut.h>
 
index 5842e2b8805301fa3cfdc83a15cf599caec78534..dd2232113b671c1314c6ed1e3ab598daa38de558 100644 (file)
@@ -285,6 +285,12 @@ main(int argc, char** argv)
     glutInitWindowSize (600, 600);
     glutCreateWindow (argv[0]);
     glewInit();
+
+    if (!glutExtensionSupported("GL_EXT_texture_compression_s3tc")) {
+       fprintf(stderr, "This test requires GL_EXT_texture_compression_s3tc.\n");
+       exit(1);
+    }
+
     myInit();
     glutReshapeFunc (myReshape);
     glutDisplayFunc(display);
index 1703b271cb03011f40ff27ce072160cea78e1953..34df95549a65494b51a65f8f9b3be24b8a832761 100644 (file)
@@ -17,53 +17,53 @@ struct pixel_format {
    GLenum format;
    GLenum type;
    GLint bytes;
-   GLuint redTexel, greenTexel;
+   GLuint redTexel, greenTexel; /* with approx 51% alpha, when applicable */
 };
 
 static const struct pixel_format Formats[] = {
 
    { "GL_RGBA/GL_UNSIGNED_INT_8_8_8_8",
-     GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, 4, 0xff000000, 0x00ff0000 },
+     GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, 4, 0xff000080, 0x00ff0080 },
    { "GL_RGBA/GL_UNSIGNED_INT_8_8_8_8_REV",
-     GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0x000000ff, 0x0000ff00 },
+     GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0x800000ff, 0x8000ff00 },
    { "GL_RGBA/GL_UNSIGNED_INT_10_10_10_2",
-     GL_RGBA, GL_UNSIGNED_INT_10_10_10_2, 4, 0xffc00000, 0x3ff000 },
+     GL_RGBA, GL_UNSIGNED_INT_10_10_10_2, 4, 0xffc00002, 0x3ff002 },
    { "GL_RGBA/GL_UNSIGNED_INT_2_10_10_10_REV",
-     GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, 4, 0x3ff, 0xffc00 },
+     GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, 4, 0xc00003ff, 0xc00ffc00 },
    { "GL_RGBA/GL_UNSIGNED_SHORT_4_4_4_4",
-     GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0xf000, 0x0f00 },
+     GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0xf008, 0x0f08 },
    { "GL_RGBA/GL_UNSIGNED_SHORT_4_4_4_4_REV",
-     GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0x000f, 0x00f0 },
+     GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0x800f, 0x80f0 },
    { "GL_RGBA/GL_UNSIGNED_SHORT_5_5_5_1",
-     GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0xf800, 0x7c0 },
+     GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0xf801, 0x7c1 },
    { "GL_RGBA/GL_UNSIGNED_SHORT_1_5_5_5_REV",
-     GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0x1f, 0x3e0 },
+     GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0x801f, 0x83e0 },
 
    { "GL_BGRA/GL_UNSIGNED_INT_8_8_8_8",
-     GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, 4, 0x0000ff00, 0x00ff0000 },
+     GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, 4, 0x0000ff80, 0x00ff0080 },
    { "GL_BGRA/GL_UNSIGNED_INT_8_8_8_8_REV",
-     GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0x00ff0000, 0x0000ff00 },
+     GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0x80ff0000, 0x8000ff00 },
    { "GL_BGRA/GL_UNSIGNED_SHORT_4_4_4_4",
-     GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0x00f0, 0x0f00 },
+     GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0x00f8, 0x0f08 },
    { "GL_BGRA/GL_UNSIGNED_SHORT_4_4_4_4_REV",
-     GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0x0f00, 0x00f0 },
+     GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0x8f00, 0x80f0 },
    { "GL_BGRA/GL_UNSIGNED_SHORT_5_5_5_1",
-     GL_BGRA, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0x3e, 0x7c0 },
+     GL_BGRA, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0x3f, 0x7c1 },
    { "GL_BGRA/GL_UNSIGNED_SHORT_1_5_5_5_REV",
-     GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0x7c00, 0x3e0 },
+     GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0xfc00, 0x83e0 },
 
    { "GL_ABGR_EXT/GL_UNSIGNED_INT_8_8_8_8",
-     GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8, 4, 0x000000ff, 0x0000ff00 },
+     GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8, 4, 0x800000ff, 0x8000ff00 },
    { "GL_ABGR_EXT/GL_UNSIGNED_INT_8_8_8_8_REV",
-     GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0xff000000, 0x00ff0000 },
+     GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0xff000080, 0x00ff0080 },
    { "GL_ABGR_EXT/GL_UNSIGNED_SHORT_4_4_4_4",
-     GL_ABGR_EXT, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0x000f, 0x00f0 },
+     GL_ABGR_EXT, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0x800f, 0x80f0 },
    { "GL_ABGR_EXT/GL_UNSIGNED_SHORT_4_4_4_4_REV",
-     GL_ABGR_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0xf000, 0x0f00 },
+     GL_ABGR_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0xf008, 0x0f08 },
    { "GL_ABGR_EXT/GL_UNSIGNED_SHORT_5_5_5_1",
-     GL_ABGR_EXT, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0x1, 0x3e },
+     GL_ABGR_EXT, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0xf801, 0xf83e },
    { "GL_ABGR_EXT/GL_UNSIGNED_SHORT_1_5_5_5_REV",
-     GL_ABGR_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0x8000, 0x7c00 },
+     GL_ABGR_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0x800f, 0x7c0f },
 
    { "GL_RGB/GL_UNSIGNED_SHORT_5_6_5",
      GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 2, 0xf800, 0x7e0 },
@@ -108,7 +108,7 @@ static const struct name_format IntFormats[] = {
 static GLuint CurFormat = 0;
 
 static GLboolean Test3D = GL_FALSE;
-
+static GLboolean Blend = GL_FALSE;
 
 
 static void
@@ -191,6 +191,19 @@ MakeTexture(const struct pixel_format *format, GLenum intFormat, GLboolean swap)
                    format->format, format->type, texBuffer);
    }
 
+   if (0) {
+      GLint r, g, b, a, l, i;
+      glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_RED_SIZE, &r);
+      glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_GREEN_SIZE, &g);
+      glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_BLUE_SIZE, &b);
+      glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_SIZE, &a);
+      glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_LUMINANCE_SIZE, &l);
+      glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTENSITY_SIZE, &i);
+      printf("IntFormat: 0x%x  R %d  G %d  B %d  A %d  L %d  I %d\n",
+             intFormat, r, g, b, a, l, i);
+      glGetError();
+   }                              
+
    if (glGetError()) {
       printf("GL Error for %s\n", format->name);
       memset(texBuffer, 255, 1000);
@@ -221,6 +234,10 @@ Draw(void)
            glEnable(GL_TEXTURE_3D);
         else
            glEnable(GL_TEXTURE_2D);
+
+        if (Blend)
+           glEnable(GL_BLEND);
+
         glBegin(GL_POLYGON);
         glTexCoord3f(0, 0, 0.5);  glVertex2f(0, 0);
         glTexCoord3f(1, 0, 0.5);  glVertex2f(w, 0);
@@ -232,6 +249,9 @@ Draw(void)
            glDisable(GL_TEXTURE_3D);
         else
            glDisable(GL_TEXTURE_2D);
+
+        glDisable(GL_BLEND);
+
         glColor3f(0, 0, 0);
         glRasterPos2i(8, 6);
         PrintString(Formats[i].name);
@@ -252,8 +272,8 @@ Draw(void)
    glPushMatrix();
    glTranslatef(2, (i + 1) * (h + 2), 0);
    glRasterPos2i(8, 6);
-   sprintf(s, "Internal Texture Format [f/F]: %s (%d of %d)",
-           IntFormats[CurFormat].name, CurFormat + 1, NUM_INT_FORMATS);
+   sprintf(s, "Internal Texture Format [f/F]: %s (%d of %lu)",
+           IntFormats[CurFormat].name, CurFormat + 1, (unsigned long) NUM_INT_FORMATS);
    PrintString(s);
    glPopMatrix();
 
@@ -266,6 +286,15 @@ Draw(void)
       PrintString("Target [2/3]: GL_TEXTURE_2D");
    glPopMatrix();
 
+   glPushMatrix();
+   glTranslatef(2, (i + 3) * (h + 2), 0);
+   glRasterPos2i(8, 6);
+   if (Blend)
+      PrintString("Blend: Yes");
+   else
+      PrintString("Blend: No");
+   glPopMatrix();
+
    glutSwapBuffers();
 }
 
@@ -288,6 +317,9 @@ Key(unsigned char key, int x, int y)
    (void) x;
    (void) y;
    switch (key) {
+      case 'b':
+         Blend = !Blend;
+         break;
       case 'F':
          if (CurFormat == 0)
             CurFormat = NUM_INT_FORMATS - 1;
@@ -323,6 +355,7 @@ Init(void)
    glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 }
 
 
index 6dd956c4023570aa143b2c5e16de6be88ddf916c..2de7e2994af994d5ab350f784098fe03ad2035bb 100644 (file)
@@ -116,7 +116,7 @@ static int set_parameter_batch( GLsizei count, GLfloat * param,
 
 
    for ( i = 0 ; i < (4 * count) ; i++ ) {
-      param[i] = (GLfloat) random() / (GLfloat) random();
+      param[i] = (GLfloat) rand() / (GLfloat) rand();
    }
 
    /* Try using the "classic" interface.
@@ -153,7 +153,7 @@ static int set_parameter_batch( GLsizei count, GLfloat * param,
 
 
    for ( i = 0 ; i < (4 * count) ; i++ ) {
-      param[i] = (GLfloat) random() / (GLfloat) random();
+      param[i] = (GLfloat) rand() / (GLfloat) rand();
    }
 
    printf("Testing glProgram%sParameters4fvEXT (count = %u)...\n", name, count);
@@ -192,6 +192,7 @@ static void Init( void )
    GLfloat * params;
    GLint max_program_env_parameters;
    GLint max_program_local_parameters;
+   int i;
 
 
    printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
@@ -203,20 +204,20 @@ static void Init( void )
    }
 
 
-   program_local_parameter4fv = glutGetProcAddress( "glProgramLocalParameter4fvARB" );
-   program_env_parameter4fv = glutGetProcAddress( "glProgramEnvParameter4fvARB" );
+   program_local_parameter4fv = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) glutGetProcAddress( "glProgramLocalParameter4fvARB" );
+   program_env_parameter4fv = (PFNGLPROGRAMENVPARAMETER4FVARBPROC) glutGetProcAddress( "glProgramEnvParameter4fvARB" );
 
-   get_program_local_parameterfv = glutGetProcAddress( "glGetProgramLocalParameterfvARB" );
-   get_program_env_parameterfv = glutGetProcAddress( "glGetProgramEnvParameterfvARB" );
+   get_program_local_parameterfv = (PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) glutGetProcAddress( "glGetProgramLocalParameterfvARB" );
+   get_program_env_parameterfv = (PFNGLGETPROGRAMENVPARAMETERFVARBPROC) glutGetProcAddress( "glGetProgramEnvParameterfvARB" );
 
-   bind_program = glutGetProcAddress( "glBindProgramARB" );
-   get_program = glutGetProcAddress( "glGetProgramivARB" );
+   bind_program = (PFNGLBINDPROGRAMARBPROC) glutGetProcAddress( "glBindProgramARB" );
+   get_program = (PFNGLGETPROGRAMIVARBPROC) glutGetProcAddress( "glGetProgramivARB" );
 
    if ( glutExtensionSupported("GL_EXT_gpu_program_parameters") ) {
       printf("GL_EXT_gpu_program_parameters available, testing that path.\n");
 
-      program_local_parameters4fv = glutGetProcAddress( "glProgramLocalParameters4fvEXT" );
-      program_env_parameters4fv = glutGetProcAddress( "glProgramEnvParameters4fvEXT" );
+      program_local_parameters4fv = (PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) glutGetProcAddress( "glProgramLocalParameters4fvEXT" );
+      program_env_parameters4fv = (PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) glutGetProcAddress( "glProgramEnvParameters4fvEXT" );
    }
    else {
       printf("GL_EXT_gpu_program_parameters not available.\n");
@@ -238,6 +239,10 @@ static void Init( void )
 
    params = malloc(max_program_env_parameters * 4 * sizeof(GLfloat));
 
+   for (i = 0; i < max_program_env_parameters * 4; i++) {
+      params[i] = 0.0F;
+   }
+
    pass &= set_parameter_batch(max_program_env_parameters, params, "Env",
                               program_env_parameter4fv,
                               program_env_parameters4fv,
index 2098b51ccd21f3e2923047af2cb1b9117e5c6576..e5b9920b66d5f2a5e20b2957f31fac475c10ca48 100644 (file)
@@ -17,7 +17,10 @@ static GLfloat Xrot = 40, Yrot = 0, Zrot = 0;
 static GLboolean Anim = GL_TRUE;
 static GLuint Vbuffer = 0;
 
+#if 1
+#else
 static GLfloat buf[NUM_QUADS * 6 * 4];
+#endif
 
 static GLboolean doSwapBuffers = GL_TRUE;
 
index 582e65fb72b5d343a8788a98d35e965e79f273cf..4ef307b424e9814a505339af46bba87d335a503a 100644 (file)
@@ -104,7 +104,7 @@ static void draw(void)
 
    glDisable(GL_SCISSOR_TEST);
 
-   //glutSwapBuffers();
+   /* glutSwapBuffers(); */
    glFlush();
 }
 
@@ -120,7 +120,7 @@ int main(int argc, char **argv)
    glutInitWindowPosition(100, 0);
    glutInitWindowSize(prog.width, prog.height);
 
-   //type = GLUT_RGB | GLUT_DOUBLE;
+   /* type = GLUT_RGB | GLUT_DOUBLE; */
    type = GLUT_RGB | GLUT_SINGLE;
    glutInitDisplayMode(type);
 
index 2dfd2174e8210e1b99c3ff03e4bb80b471d90259..e5a68ffabd36b672f915497a40c3ad6a99050c78 100644 (file)
@@ -134,7 +134,7 @@ static void draw(void)
 
    glDisable(GL_SCISSOR_TEST);
 
-   //glutSwapBuffers();
+   /* glutSwapBuffers(); */
    glFlush();
 }
 
@@ -150,7 +150,7 @@ int main(int argc, char **argv)
    glutInitWindowPosition(100, 0);
    glutInitWindowSize(prog.width, prog.height);
 
-   //type = GLUT_RGB | GLUT_DOUBLE;
+   /* type = GLUT_RGB | GLUT_DOUBLE; */
    type = GLUT_RGB | GLUT_SINGLE;
    glutInitDisplayMode(type);
 
index 6453856345c70e1614569ac08f9bdd9f15205a31..fa0a992540c73b19de2e1c18c4dc8d06a8a05ad8 100644 (file)
@@ -8,6 +8,10 @@
 #include <GL/glew.h>
 #include <GL/glut.h>
 
+#ifndef APIENTRY
+#define APIENTRY
+#endif
+
 static void assert_test(const char *file, int line, int cond, const char *msg)
 {
    if (!cond)
@@ -42,7 +46,7 @@ static void assert_error_test(const char *file, int line, GLenum expect)
 
 #define assert_error(err) assert_error_test(__FILE__, __LINE__, (err))
 
-static void check_status(GLuint id, GLenum pname, void (*query)(GLuint, GLenum, GLint *))
+static void check_status(GLuint id, GLenum pname, void (APIENTRY *query)(GLuint, GLenum, GLint *))
 {
     GLint status;
 
index c07ebd719c7c1cce59efa91dfa17093d4cfba33c..2337b88d3ffe84868dafa844a435c698919c0a12 100644 (file)
@@ -424,13 +424,13 @@ main(int argc, char *argv[])
 {
    const char *dpyName = XDisplayName(NULL);
 
-   struct window *h0, *h1, *h2, *h3;
+   struct window *h0;
 
    /* four windows and contexts sharing display lists and texture objects */
    h0 = AddWindow(dpyName,  10,  10, NULL);
-   h1 = AddWindow(dpyName, 330,  10, h0);
-   h2 = AddWindow(dpyName,  10, 350, h0);
-   h3 = AddWindow(dpyName, 330, 350, h0);
+   (void) AddWindow(dpyName, 330,  10, h0);
+   (void) AddWindow(dpyName,  10, 350, h0);
+   (void) AddWindow(dpyName, 330, 350, h0);
 
    InitGLstuff(h0);
 
index 1e18ca6b5eafec199d0c779635db7ef99eb787d1..7d871e5877fa9336cd32fb988034c665fe58d6d1 100644 (file)
@@ -274,9 +274,9 @@ static void Init( void )
    if (atof( ver_string ) < 2.0) {
       use20syntax = 0;
    }
-   stencil_func_separate = glutGetProcAddress( "glStencilFuncSeparate" );
-   stencil_func_separate_ati = glutGetProcAddress( "glStencilFuncSeparateATI" );
-   stencil_op_separate = glutGetProcAddress( "glStencilOpSeparate" );
+   stencil_func_separate = (PFNGLSTENCILFUNCSEPARATEPROC) glutGetProcAddress( "glStencilFuncSeparate" );
+   stencil_func_separate_ati = (PFNGLSTENCILFUNCSEPARATEATIPROC) glutGetProcAddress( "glStencilFuncSeparateATI" );
+   stencil_op_separate = (PFNGLSTENCILOPSEPARATEPROC) glutGetProcAddress( "glStencilOpSeparate" );
 
    printf("\nAll 5 squares should be the same color.\n");
 }
index 2e219fd8b503dace5fb74c870a756b943ccf64a4..d396fc2a5333b379a3b73ec207e0743e11d16f9d 100644 (file)
@@ -257,7 +257,7 @@ static void Init( void )
     * part of GL 1.4.
     */
 
-   ver_str = glGetString( GL_VERSION );
+   ver_str = (char *) glGetString( GL_VERSION );
    version = (ver_str == NULL) ? 1.0 : atof( ver_str );
 
    wrapping = (glutExtensionSupported("GL_EXT_stencil_wrap") || (version >= 1.4));
index 4abe1068c7b9c20372f49e2654b50b9c300c7676..7d67451c0da5153d6a337c175d9cc663869ab054 100644 (file)
@@ -39,11 +39,13 @@ static void draw( void )
 
 
 
+/*
 static void idle( void )
 {
    Angle += 2.0;
    glutPostRedisplay();
 }
+*/
 
 
 
index d1e829d1b73670eb3ea053552c1395ebc258bd68..c5d352fdaede7a53f5986cb3c65d41a5c477da0e 100644 (file)
@@ -106,6 +106,8 @@ static void Display( void )
    glRotatef(Rot, 0, 0, 1);
 
    glEnable(GL_TEXTURE_2D);
+   glEnable(GL_BLEND);
+
    glBegin(GL_POLYGON);
    glTexCoord2f(0, 1);  glVertex2f(-1, -0.5);
    glTexCoord2f(1, 1);  glVertex2f( 1, -0.5);
@@ -115,7 +117,10 @@ static void Display( void )
 
    glPopMatrix();
 
+   glDisable(GL_TEXTURE_2D);
+
    /* info */
+   glDisable(GL_BLEND);
    glColor4f(1, 1, 1, 1);
 
    glRasterPos3f(-1.2, -0.7, 0);
@@ -149,7 +154,7 @@ static void Reshape( int width, int height )
 
 static void ReInit( GLenum TC, TEXTURE *Tx )
 {
-   GLint rv;
+   GLint rv, v;
 
    if ((Tx->TC == TC) && (Tx->cData != NULL)) {
       glCompressedTexImage2DARB(GL_TEXTURE_2D, /* target */
@@ -170,6 +175,24 @@ static void ReInit( GLenum TC, TEXTURE *Tx )
                    GL_UNSIGNED_BYTE, /* texture type */
                    Tx->data);        /* the texture */
 
+
+      v = 0;
+      glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
+                               GL_TEXTURE_INTERNAL_FORMAT, &v);
+      printf("Requested internal format = 0x%x, actual = 0x%x\n", TC, v);
+
+      if (0) {
+         GLint r, g, b, a, l, i;
+         glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_RED_SIZE, &r);
+         glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_GREEN_SIZE, &g);
+         glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_BLUE_SIZE, &b);
+         glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_SIZE, &a);
+         glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_LUMINANCE_SIZE, &l);
+         glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTENSITY_SIZE, &i);
+         printf("Compressed Bits per R: %d  G: %d  B: %d  A: %d  L: %d  I: %d\n",
+                r, g, b, a, l, i);
+      }
+
       /* okay, now cache the compressed texture */
       Tx->TC = TC;
       if (Tx->cData != NULL) {
index e63a56774f38204a9540613cb39fc3c55aa57213..a3884d4d0df56e8f8aa1fbc3f0323930ce2c550a 100644 (file)
@@ -1,4 +1,4 @@
-static int ImgSize = 131072;
+#define ImgSize 131072
 static unsigned char ImgData[131072] =
 {
    0x4d, 0xbc, 0x0b, 0xb4, 0xda, 0x0a, 0x78, 0xa8, 0x8d, 0xbc, 0x0c, 0xac, 0x8b, 0x7f, 0xeb, 0xf7, 0x8d, 0xbc, 0xeb, 0xab, 0xba, 0xb7, 0x82, 0xa2, 0x8d, 0xbc, 0x2b, 0xb4, 0xa2, 0xfd, 0xee, 0x2f,
index 50106bf1e22dc41cd7a9a25cbf916bb952c04f46..215f5711d9530aee8052f0484b77c9dd16d1aee5 100644 (file)
@@ -35,6 +35,8 @@ LoadCompressedImage(void)
    unsigned char ImgDataTemp[ImgSize / 4];
    unsigned i;
    const GLenum filter = GL_LINEAR;
+   const int half = ImgSize / 2;
+
    glTexImage2D(Target, 0, CompFormat, ImgWidth, ImgHeight, 0,
                 GL_RGB, GL_UNSIGNED_BYTE, NULL);
 
@@ -42,11 +44,11 @@ LoadCompressedImage(void)
    glCompressedTexSubImage2DARB(Target, 0,
                                 0, 0, /* pos */
                                 ImgWidth, ImgHeight / 2,
-                                CompFormat, ImgSize / 2, ImgData + ImgSize / 2);
+                                CompFormat, ImgSize / 2, ImgData /*+ ImgSize / 2*/);
 
    /* top left */
    for (i = 0; i < ImgHeight / 8; i++) {
-      memcpy(&ImgDataTemp[i * ImgWidth], &ImgData[i * 2 * ImgWidth], ImgWidth);
+      memcpy(&ImgDataTemp[i * ImgWidth], &ImgData[half + i * 2 * ImgWidth], ImgWidth);
    }
    glCompressedTexSubImage2DARB(Target, 0,
                                 0, ImgHeight / 2, /* pos */
@@ -55,7 +57,7 @@ LoadCompressedImage(void)
 
    /* top right */
    for (i = 0; i < ImgHeight / 8; i++) {
-      memcpy(&ImgDataTemp[i * ImgWidth], &ImgData[i * 2 * ImgWidth + ImgWidth], ImgWidth);
+      memcpy(&ImgDataTemp[i * ImgWidth], &ImgData[half + i * 2 * ImgWidth + ImgWidth], ImgWidth);
    }
    glCompressedTexSubImage2DARB(Target, 0,
                                 ImgWidth / 2, ImgHeight / 2, /* pos */
index 7e46045832545f9fe43c7a08ddd334a0ad709bec..92df01b83d2acde1e6b8eb7899747af27f93c60d 100644 (file)
@@ -162,7 +162,7 @@ MeasureDownloadRate(void)
    const int image_bytes = align(w * h * BytesPerTexel(Format), ALIGN);
    const int bytes = image_bytes * NR_TEXOBJ;
    GLubyte *orig_texImage, *orig_getImage;
-   GLubyte *texImage, *getImage;
+   GLubyte *texImage;
    GLdouble t0, t1, time;
    int count;
    int i;
@@ -176,13 +176,14 @@ MeasureDownloadRate(void)
    orig_getImage = (GLubyte *) malloc(image_bytes + ALIGN);
    if (!orig_texImage || !orig_getImage) {
       DownloadRate = 0.0;
+      free(orig_texImage);
+      free(orig_getImage);
       return;
    }
 
    printf("alloc %p %p\n", orig_texImage, orig_getImage);
 
    texImage = (GLubyte *)align((unsigned long)orig_texImage, ALIGN);
-   getImage = (GLubyte *)align((unsigned long)orig_getImage, ALIGN);   
 
    for (i = 1; !(((unsigned long)texImage) & i); i<<=1)
       ;
diff --git a/progs/tests/texleak.c b/progs/tests/texleak.c
new file mode 100644 (file)
index 0000000..5cf4ff3
--- /dev/null
@@ -0,0 +1,140 @@
+/*
+ * 'Texture leak' test
+ *
+ * Allocates and uses an additional texture of the maximum supported size for
+ * each frame. This tests the system's ability to cope with using increasing
+ * amounts of texture memory.
+ *
+ * Michel Dänzer  July 2009  This program is in the public domain.
+ */
+
+
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <GL/glew.h>
+#include <GL/glut.h>
+
+
+GLint size;
+GLvoid *image;
+static GLuint numTexObj;
+static GLuint *texObj;
+
+
+static void Idle( void )
+{
+   glutPostRedisplay();
+}
+
+
+static void DrawObject(void)
+{
+   static const GLfloat tex_coords[] = {  0.0,  0.0,  1.0,  1.0,  0.0 };
+   static const GLfloat vtx_coords[] = { -1.0, -1.0,  1.0,  1.0, -1.0 };
+   GLint i, j;
+
+   glEnable(GL_TEXTURE_2D);
+
+   for (i = 0; i < numTexObj; i++) {
+      glBindTexture(GL_TEXTURE_2D, texObj[i]);
+      glBegin(GL_QUADS);
+      for (j = 0; j < 4; j++ ) {
+         glTexCoord2f(tex_coords[j], tex_coords[j+1]);
+         glVertex2f( vtx_coords[j], vtx_coords[j+1] );
+      }
+      glEnd();
+   }
+}
+
+
+static void Display( void )
+{
+   struct timeval start, end;
+
+   texObj = realloc(texObj, ++numTexObj * sizeof(*texObj));
+
+   /* allocate a texture object */
+   glGenTextures(1, texObj + (numTexObj - 1));
+
+   glBindTexture(GL_TEXTURE_2D, texObj[numTexObj - 1]);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+   memset(image, (16 * numTexObj) & 0xff, 4 * size * size);
+   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size, size, 0,
+                GL_RGBA, GL_UNSIGNED_BYTE, image);
+
+   gettimeofday(&start, NULL);
+
+   glClear( GL_COLOR_BUFFER_BIT );
+
+   glPushMatrix();
+      glScalef(5.0, 5.0, 5.0);
+      DrawObject();
+   glPopMatrix();
+
+   glutSwapBuffers();
+
+   glFinish();
+   gettimeofday(&end, NULL);
+   printf("Rendering frame took %lu ms using %u MB of textures\n",
+         end.tv_sec * 1000 + end.tv_usec / 1000 - start.tv_sec * 1000 -
+         start.tv_usec / 1000, numTexObj * 4 * size / 1024 * size / 1024);
+
+   sleep(1);
+}
+
+
+static void Reshape( int width, int height )
+{
+   glViewport( 0, 0, width, height );
+   glMatrixMode( GL_PROJECTION );
+   glLoadIdentity();
+   glOrtho( -6.0, 6.0, -6.0, 6.0, 10.0, 100.0 );
+   glMatrixMode( GL_MODELVIEW );
+   glLoadIdentity();
+   glTranslatef( 0.0, 0.0, -70.0 );
+}
+
+
+static void Init( int argc, char *argv[] )
+{
+   glGetIntegerv(GL_MAX_TEXTURE_SIZE, &size);
+   printf("%d x %d max texture size\n", size, size);
+
+   image = malloc(4 * size * size);
+   if (!image) {
+      fprintf(stderr, "Failed to allocate %u bytes of memory\n", 4 * size * size);
+      exit(1);
+   }
+
+   glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+   glShadeModel(GL_FLAT);
+   glClearColor(0.3, 0.3, 0.4, 1.0);
+
+   Idle();
+}
+
+
+int main( int argc, char *argv[] )
+{
+   glutInit( &argc, argv );
+   glutInitWindowSize( 300, 300 );
+   glutInitWindowPosition( 0, 0 );
+   glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
+   glutCreateWindow(argv[0] );
+   glewInit();
+
+   Init( argc, argv );
+
+   glutReshapeFunc( Reshape );
+   glutDisplayFunc( Display );
+   glutIdleFunc(Idle);
+
+   glutMainLoop();
+   return 0;
+}
index db6fffa3e8953f6701a8f4303826f7df3deea1f8..331cbf2f6b1611d4b50ffcd8b6b48767e50ef804 100644 (file)
@@ -31,6 +31,7 @@
 
 static int win_width, win_height;
 
+#if 0
 static void
 line(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)
 {
@@ -39,6 +40,7 @@ line(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)
        glVertex2f(x2, y2);
        glEnd();
 }
+#endif
 
 static void
 line3(GLfloat x1, GLfloat y1, GLfloat z1, GLfloat x2, GLfloat y2, GLfloat z2)
index 117fae8bd9e3abf64776bd7c5b89edec9b11b3d7..e4a89cb19db4976b87e0d6d049958b52395158fd 100644 (file)
@@ -124,10 +124,10 @@ static void Init( void )
       exit(2);
    }
 
-   bind_vertex_array = glutGetProcAddress( "glBindVertexArrayAPPLE" );
-   gen_vertex_arrays = glutGetProcAddress( "glGenVertexArraysAPPLE" );
-   delete_vertex_arrays = glutGetProcAddress( "glDeleteVertexArraysAPPLE" );
-   is_vertex_array = glutGetProcAddress( "glIsVertexArrayAPPLE" );
+   bind_vertex_array = (PFNGLBINDVERTEXARRAYAPPLEPROC) glutGetProcAddress( "glBindVertexArrayAPPLE" );
+   gen_vertex_arrays = (PFNGLGENVERTEXARRAYSAPPLEPROC) glutGetProcAddress( "glGenVertexArraysAPPLE" );
+   delete_vertex_arrays = (PFNGLDELETEVERTEXARRAYSAPPLEPROC) glutGetProcAddress( "glDeleteVertexArraysAPPLE" );
+   is_vertex_array = (PFNGLISVERTEXARRAYAPPLEPROC) glutGetProcAddress( "glIsVertexArrayAPPLE" );
 
 
    (*gen_vertex_arrays)( 1, & obj );
index 7764ed51061df7e2c09bff9a0109b26fcbec8ff9..9f7f5c27792ba72b4b37454fe1a61a935a362382 100644 (file)
@@ -125,10 +125,10 @@ static void Init( void )
       exit(2);
    }
 
-   bind_vertex_array = glutGetProcAddress( "glBindVertexArrayAPPLE" );
-   gen_vertex_arrays = glutGetProcAddress( "glGenVertexArraysAPPLE" );
-   delete_vertex_arrays = glutGetProcAddress( "glDeleteVertexArraysAPPLE" );
-   is_vertex_array = glutGetProcAddress( "glIsVertexArrayAPPLE" );
+   bind_vertex_array = (PFNGLBINDVERTEXARRAYAPPLEPROC) glutGetProcAddress( "glBindVertexArrayAPPLE" );
+   gen_vertex_arrays = (PFNGLGENVERTEXARRAYSAPPLEPROC) glutGetProcAddress( "glGenVertexArraysAPPLE" );
+   delete_vertex_arrays = (PFNGLDELETEVERTEXARRAYSAPPLEPROC) glutGetProcAddress( "glDeleteVertexArraysAPPLE" );
+   is_vertex_array = (PFNGLISVERTEXARRAYAPPLEPROC) glutGetProcAddress( "glIsVertexArrayAPPLE" );
 
 
    (*gen_vertex_arrays)( 1, & obj );
index af9b62d33e6b5a23e46ff59df4b930ba76a7fa61..fe168c6cd56dca27644d8191d09c5ff0ef2e11b0 100644 (file)
@@ -37,13 +37,16 @@ static void read_surface( char *filename )
    }
 
    numverts = 0;
-   while (!feof(f) && numverts < MAXVERTS) {
-      fscanf( f, "%f %f %f  %f %f %f",
-             &data[numverts][0], &data[numverts][1], &data[numverts][2],
-             &data[numverts][3], &data[numverts][4], &data[numverts][5] );
+   while (numverts < MAXVERTS) {
+      int result;
+      result = fscanf( f, "%f %f %f  %f %f %f",
+                      &data[numverts][0], &data[numverts][1], &data[numverts][2],
+                      &data[numverts][3], &data[numverts][4], &data[numverts][5] );
+      if (result == EOF) {
+         break;
+      }
       numverts++;
    }
-   numverts--;
 
    printf("%d vertices, %d triangles\n", numverts, numverts-2);
    printf("data = %p\n", (void *) data);
index f07737f9736aafd6d96128f22eef2bf6fb82c5d9..3e8a732df59be2196d86201b28a39e153fc07ec7 100644 (file)
@@ -94,16 +94,16 @@ GLfloat colorPoints[4][4][4] =
 };
 
 
-void
+static void
 initlights(void)
 {
+#if 0 /* no lighting for now */
     GLfloat ambient[] = {0.2, 0.2, 0.2, 1.0};
     GLfloat position[] = {0.0, 0.0, 2.0, 1.0};
     GLfloat mat_diffuse[] = {0.6, 0.6, 0.6, 1.0};
     GLfloat mat_specular[] = {1.0, 1.0, 1.0, 1.0};
     GLfloat mat_shininess[] = {50.0};
 
-#if 0 /* no lighting for now */
     glEnable(GL_LIGHTING);
     glEnable(GL_LIGHT0);
 
@@ -116,7 +116,7 @@ initlights(void)
 #endif
 }
 
-void
+static void
 display(void)
 {
    glClearColor(.3, .3, .3, 0);
@@ -130,7 +130,7 @@ display(void)
     glFlush();
 }
 
-void
+static void
 myinit(int argc, char *argv[])
 {
     glClearColor(0.0, 0.0, 0.0, 1.0);
@@ -186,7 +186,7 @@ myinit(int argc, char *argv[])
     }
 }
 
-void
+static void
 myReshape(int w, int h)
 {
     glViewport(0, 0, w, h);
index 7dfed20cfb9d2b2236c2b8b68aac37c4026cc3d9..7740695bb669914fccca6a806e5873cc88c58947 100644 (file)
@@ -58,6 +58,10 @@ static void Display(void)
       printf("Depth value range: [%f, %f]\n", min, max);
    }
 
+   /* Draw the Z image as luminance above original rendering */
+   glWindowPos2i(0, 100);
+   glDrawPixels(100, 100, GL_LUMINANCE, depthType, depth);
+
    if (TestPacking) {
       glPixelStorei(GL_PACK_ROW_LENGTH, 0);
       glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
@@ -100,6 +104,7 @@ static void Display(void)
    glReadPixels(100, 0, 400, 400, GL_DEPTH_COMPONENT, GL_FLOAT, depth2);
    /* draw as luminance */
    glPixelZoom(1.0, 1.0);
+   glWindowPos2i(100, 0);
    glDrawPixels(400, 400, GL_LUMINANCE, GL_FLOAT, depth2);
 
    glutSwapBuffers();
index 4d6e405c500e394f7071d91848411502b1d089bd..4317eb607feef093f322572b5ac0123b81acde6a 100644 (file)
@@ -147,6 +147,7 @@ vbo-drawarrays
 vbo-drawelements
 vbo-drawrange
 vbo-noninterleaved
+vbo-tri
 vp-array
 vp-array-int
 vp-clip
index a78837611c19aecd003c9a2718b32a895c4874bc..784715db1620b1c2a783dad13699e3a2fb53c962 100644 (file)
@@ -155,6 +155,7 @@ SOURCES = \
        tristrip-clip.c \
        tristrip-flat.c \
        tristrip.c \
+       vbo-tri.c \
        vbo-drawarrays.c \
        vbo-noninterleaved.c \
        vbo-drawelements.c \
index 37a53293bfc1ccd009937d7ec1b973a83d66e7e1..29062564adc6eed3c9585a88070ac557dc0bd73e 100644 (file)
@@ -1,11 +1,4 @@
-Import('env')
-
-if not env['GLUT']:
-    Return()
-
-env = env.Clone()
-
-env.Prepend(LIBS = ['$GLUT_LIB'])
+Import('*')
 
 progs = [
     'clear-fbo-tex',
@@ -156,7 +149,7 @@ progs = [
 ]
 
 for prog in progs:
-    prog = env.Program(
+    prog = progs_env.Program(
         target = prog,
         source = prog + '.c',
     )
index a206676e48e1837c6339b9ddca7b5dd0c492bb48..ff31706fd1cc9d6bca4c2269bb6d58111b1fcec9 100644 (file)
@@ -88,7 +88,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
@@ -102,8 +102,8 @@ static void Draw( void )
 
    /* draw to texture image */
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB);
-//   glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT);
-//   glReadBuffer(GL_COLOR_ATTACHMENT1_EXT);
+   /* glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT); */
+   /* glReadBuffer(GL_COLOR_ATTACHMENT1_EXT); */
 
    
    glViewport(0, 0, TexWidth, TexHeight);
index 0aeb45489f2982f4769db1f5740b8839427bfb3f..6435c901adcea4b05b0203242bdab855881ad90b 100644 (file)
@@ -73,7 +73,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index e3da23a8f55576b511b45a508b58170b94ca7b68..ab67f84518da35f364e0d0474ffe69962d745c51 100644 (file)
@@ -61,7 +61,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(0);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 01735327480f6b76c70ca421dad54c07bc9f36b2..2b6dee77a96d1d669e972cd9bff24f30eb2b09d5 100644 (file)
@@ -38,7 +38,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
     glutPostRedisplay();
 }
index 03857b4b8934115d72a1cabd07f9ebbd89f79268..56c3ea52e6a13072f82ea4ba11f7e63772b56ea6 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(0);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index f2cc6f1cffc7e4992a502c5314f1a937d8e89194..93da30ee29439f0460a545141100d6d429abe7a2 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
@@ -116,6 +116,6 @@ int main(int argc, char **argv)
     glutReshapeFunc(Reshape);
     glutKeyboardFunc(Key);
     glutDisplayFunc(Draw);
-//    glutMainLoop();
+    /* glutMainLoop(); */
        return 0;
 }
index 0d0aed7c729c8261a3b2816b715c64e44aba9593..dbfaef3978ff5bb0fb41a59474a97918506bbb00 100644 (file)
@@ -49,7 +49,7 @@ static void Init(void)
     */
    first_list = glGenLists(1);
    glNewList(first_list, GL_COMPILE); 
-//   glColor3f(0,1,0);
+   /* glColor3f(0,1,0); */
    glEndList();
 
 
@@ -87,7 +87,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index de106280092669c85f574d33f9174757cb2cf81d..756ab93f8709d8ca08bc1f5eae72acbe334f011f 100644 (file)
@@ -74,7 +74,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 3d3aaeb6944b113293f64152b7f87bd4faedaa84..51504471e2c291e73e452a0d53bbe5edb085797a 100644 (file)
@@ -76,7 +76,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 8002129ed147709398cb0986ab7e0b4524236f20..9456b964732f82cbc95a3ea3968c53fe476f3d7a 100644 (file)
@@ -81,7 +81,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index c3dd7921e3931f92109622975d96771d2abc54dd..3ee9b283a4452fc909f62334a36e9ed2d80adecc 100644 (file)
@@ -93,7 +93,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index ed3a4c5981a13f81b78679c3165ef29b4753f153..d17c4b913b8f1fd6bc7a25714974c61da781d9c2 100644 (file)
@@ -103,7 +103,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index fe06b2bbd72091d376b0fb193cfbb29de41b60ee..90224f63cb223068039a010b42c302fbd1d8436f 100644 (file)
@@ -118,7 +118,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 4dbb7884869d3199f6e2373dd3bcfcfbda68f393..3265a4d6dcd08724aa3ad14e52ba5874822d618e 100644 (file)
@@ -99,7 +99,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index f69854ae58625219b64f5c631e5d25e63ecc8d42..053bb124a238c6dc1927f92b5276e3e96626a851 100644 (file)
@@ -102,7 +102,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 95a89981d3a859c1189a4f57ae02e9df7623220b..2345ae9e9edb89f7cd2b02e636f5c50ac45d810b 100644 (file)
@@ -66,7 +66,7 @@ static void Display( void )
 
    glEnable(GL_VERTEX_PROGRAM_ARB);
 
-//   glDrawArrays( GL_TRIANGLES, 0, 3 );
+   /* glDrawArrays( GL_TRIANGLES, 0, 3 ); */
    glDrawArrays( GL_TRIANGLES, 1, 3 );
 
    glFlush(); 
index 27d86682f75fa9584db30292b981de56cd80487e..f5c0a50f9a9faa19907c4c61e2ac62a1d8eebbe6 100644 (file)
@@ -77,7 +77,7 @@ static void Display( void )
 
    glEnable(GL_VERTEX_PROGRAM_ARB);
 
-//   glDrawArrays( GL_TRIANGLES, 0, 3 );
+   /* glDrawArrays( GL_TRIANGLES, 0, 3 ); */
    glDrawArrays( GL_TRIANGLES, 1, 3 );
 
    glFlush(); 
index 5276baffd5d356b5e5bde7ee8c9e85c67077f488..e4e388ed5cdcb7bfe03a19d161e99c944a285044 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 1e1b77a942c3775c63b214741070d55ed69bdacb..c531ff132f59ee50badc8fae9c5d862f0a995ec9 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 14f0ac078259073e978f1f607f71203d8582b175..e2ddb87b9ef449a0a6a2da53530df4a2d023ec0c 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 1804ffad3f027b565f3dfc9fb25685dd2c8d0c3f..767583bbea5fec07dfc079576462277eda309310 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 8e030b47cea9e4a9a3bc8c136d1a67266ed530b6..3265b2c3bfe369d6bb69f9068d983e3462cf1085 100644 (file)
@@ -66,7 +66,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 6fcd4bcfe734508998638f49a902df31fd03c341..0198e27807e67e25db5b847428412e423865a3fc 100644 (file)
@@ -66,7 +66,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index e59fd133a5fc8c57755c280ddfa88e39e29a1a70..6c863a3c82b14a392a6922042b5c829dd2444205 100644 (file)
@@ -66,7 +66,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index e30be5580bd88a6921575cd6d2d025d9a509f98a..6cfcb6fc73246579e7df92c2b6da78770ecefa43 100644 (file)
@@ -66,7 +66,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index b74021dea7336fd92b49087d8289db046e85406e..1945712c5d0f52c5ff844847d879e91ef90470b6 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index e1d73280bfc528fc84b30567a1a7c852ee0dbb65..58ab96836f8e8a5d898fb0b9bb05dadecd9fdec0 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 45fa47491f865acbef0a6ba23544ea912d767cf2..5e6b6217a1aade4a52f3bd41c5495e5b82a2e23b 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index c290dbd8cb3513ecbcff6bbe57aed44e1b4e331a..82eccd24f8f53c91900db3a8783d7443f2adb327 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index f2528229218ab171ae6bbd984955c689aa4edbf2..5e90ea2eb05e423a21b17e740cb791848cbd2e90 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 5caa7244235d49c86538a150e8f4f5da7b33aeb8..bae5c3a1c3bf7ba677d24a2eb2901f5031d9cbd3 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 701c82c266ac6124a00b3c3104b9bc2e7f9ae077..0296941a0deb2707b32bb0a7e1e0a9073191c3bb 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index df2eef96b5d5e17174211243414a22dcc425e911..a847d47deeb1818336b7f910383034eecf4446aa 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 0219b1ab70e1e813db70e86f1136e93ae81e5f12..b6d688214631c4d22f5dc1832e6c70fea3d5caba 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 4c89ba598d7f5ea4cd3ab63f858c7c82d863ad4f..23cfd778637c5135f6347d073548492678eedadc 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 6f43720a8927a3d43395d9d0d1194ff59f3d6cb6..46bd773265f24edf1aa567d97e449417ddd7c9fb 100644 (file)
@@ -59,7 +59,7 @@ static void Key(unsigned char key, int x, int y)
     case 27:
        exit(1);
     default:
-       return;
+       break;
     }
     glutPostRedisplay();
 }
index 5d29a6a3cf965a24d61938ab7ae1efb1db162167..16e6771514beb2ee3c9005457c5b12e4ba4174c8 100644 (file)
@@ -96,7 +96,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index f6e9b8df5f9c3ac9f66d33f8c1ec43c951782632..752cb8aee38a5b577fd6c45487ae99b1cf695ff5 100644 (file)
@@ -63,7 +63,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 8abd64c6a998239159a6ca832ad3848f2869d6bc..3b00ee9e500732f405d83dd58b5d80fdeb4d6119 100644 (file)
@@ -63,7 +63,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 49959dcc48705326796dd17da0c7f39c56fb3699..8f5299cf6b5c59114f3105f77175d843a2065a30 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 5490068b08e0f4f1c2cea2e70bc9a55181c86ae7..2a968bed40e05784cd835a24b384cb9c3dc90266 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 26b90ef96458892157028e98746eab4d9a935915..89f4e0656abdf89faa72721000a17d2bad0b8fa8 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index a4e3cdb6334e0508610dc421634cafe50c07bbc4..33c2e04e0f8e1a87b4abf2116269581f31467821 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 2ad443dc159e99687329857e5f9a7f59068d73f6..c8c0d7a9e370d34c6a712640ee1b61be1aa10f08 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index e5b788ea5beffb3bf0164071f1a3510dc2aa6a44..964eb42d7895820d85f340368dc8fa3c5f208163 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
diff --git a/progs/trivial/psb_context.c b/progs/trivial/psb_context.c
deleted file mode 100644 (file)
index e69de29..0000000
index 60c87fc9ce1c954096d03df9d4d33c63e74c6a44..7712d8ca5b7d2e627401f885774a3fe947e1c07e 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 063de6106a61a880f16fc67de53446a5d92c8d00..2847c9f9608ac7d74a72e3ff5cfc53d7b7b16c76 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index fdc142bcd6123957cdbedab7d6f9ddbc8e1f9d69..85e129d4be2e1f37711c42930a49867a85503a03 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index e3147b3b3fefce0f33887b5c11dd581d81995f8d..bed98e31a4efa546a98919e189956050603e1c6f 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index dfe99bbae6813290e7cb6b6eb10afb8ac1644eb3..1fc57a54ae7210c9dae5622de3375b8868271197 100644 (file)
@@ -55,7 +55,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 06590021fedfc2307de9be909d363c83ee795cb8..62f50fb98cc380b8b1d53ae4cc4eebc39934bbe3 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 922529d977eae5aaf82e95a0bb0dd7643b3fc87b..1ac2338692f1e022a64de583cbbb2f174ac3eaab 100644 (file)
@@ -55,7 +55,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index eebaf9170ec3f5c884736a2ed21506f159e24332..9db6792fad39e39bee79479bab587767b9d59395 100644 (file)
@@ -88,7 +88,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index ad41a9a22e58d04712b20bb0b8e0628567cc780e..b7aa1db4360ea98115b5fb8188b809895cb0f37d 100644 (file)
@@ -105,7 +105,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 761878bd4b6ad211bd7826c6004dff6d21891caf..d2e871877510047459af0ea8628aad67502101e1 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index cd7d2769284743a1b58f45cb063cf58e8f69d170..8c1737e6756ff8e2ad00a87e3b021b4e5057377b 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index d64f17fdf959398075763205d6c3fd67c2ab8af7..b756449d7a8fb3bd0aeb1d43c194988ec6bb3fbd 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index d360e309d30b7c0c3918781690a96bc078abbfb4..582de783d593b2ac72a17dd0bfde4bccdebefe88 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index fe11fef207c09730e87f4a0d7c94931cda9e6d9e..de7854a255e2ba68bb4b3e93738344be39ccaf78 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 329523531aa0b67f33cd388e42b24b834998b7fa..44412698dc55de960b67587aa012af6bf258dd7c 100644 (file)
@@ -57,7 +57,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 228c6c255e52a202678cc229327ca016e7450cde..0e0b3b49fa6f2ed423a1c5fde3fcde5b0dc75c39 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index d49a9a530201e3a7162626fe18723343467da98d..1be815fb8cd9d6e679ce077083bc8157255aebd5 100644 (file)
@@ -57,7 +57,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 5671618446a05ee8b399752f1a552689a27dd395..b063f179569a3ca8a6776d8d87042014d2e950d9 100644 (file)
@@ -39,7 +39,7 @@ static void Key(unsigned char key, int x, int y)
    case 27:
       exit(0);
    default:
-      return;
+      break;
    }
    glutPostRedisplay();
 }
index 780ebe6be5bd8f6b6f35fa2e005968c08a74186f..853d564ae7bbe48cb9123cd581d5b5ce5376399e 100644 (file)
@@ -88,7 +88,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index aec1cbb3772ccd29ea8ad5925d1079417067b3a5..bd1c88ecf8eda3c64e90480f421b271c31923100 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 92f019259ecab90f5bdee61978509a81c8f168e8..629b35c4abb1f3a1e6b650f8bd2e61deb10cf839 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index b39f8f3f12ae8d84436ce0655cbcccc616d83f66..b173dab8ec1125ea93c764c99df4ee5ea401570b 100644 (file)
@@ -83,7 +83,7 @@ static void drawRightTriangle(void)
    glDisable (GL_BLEND);
 }
 
-void display(void)
+static void display(void)
 {
    glClear(GL_COLOR_BUFFER_BIT);
 
@@ -99,7 +99,7 @@ void display(void)
    glFlush();
 }
 
-void reshape(int w, int h)
+static void reshape(int w, int h)
 {
    glViewport(0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode(GL_PROJECTION);
@@ -111,7 +111,7 @@ void reshape(int w, int h)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 't':
index 656297c0ce0fff35819d79d9414ffbbdf6a5d443..629139acae75ee0513faf4ff3f45d09e20dd1610 100644 (file)
@@ -83,7 +83,7 @@ static void drawRightTriangle(void)
    glDisable (GL_BLEND);
 }
 
-void display(void)
+static void display(void)
 {
    glClear(GL_COLOR_BUFFER_BIT);
 
@@ -99,7 +99,7 @@ void display(void)
    glFlush();
 }
 
-void reshape(int w, int h)
+static void reshape(int w, int h)
 {
    glViewport(0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode(GL_PROJECTION);
@@ -111,7 +111,7 @@ void reshape(int w, int h)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 't':
index fe225f1f4e0d428d5b033798ce2fa1308af5c2cf..ef1e92c85dc47c1731a6e42fb0931614fdf782ea 100644 (file)
@@ -83,7 +83,7 @@ static void drawRightTriangle(void)
    glDisable (GL_BLEND);
 }
 
-void display(void)
+static void display(void)
 {
    glClear(GL_COLOR_BUFFER_BIT);
 
@@ -99,7 +99,7 @@ void display(void)
    glFlush();
 }
 
-void reshape(int w, int h)
+static void reshape(int w, int h)
 {
    glViewport(0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode(GL_PROJECTION);
@@ -111,7 +111,7 @@ void reshape(int w, int h)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 't':
index cc1aeaf4a484304b7a00fe7dc161fb407058cda5..3c560ae6ef79d12f165363031a7b9f72823a505f 100644 (file)
@@ -83,7 +83,7 @@ static void drawRightTriangle(void)
    glDisable (GL_BLEND);
 }
 
-void display(void)
+static void display(void)
 {
    glClear(GL_COLOR_BUFFER_BIT);
 
@@ -99,7 +99,7 @@ void display(void)
    glFlush();
 }
 
-void reshape(int w, int h)
+static void reshape(int w, int h)
 {
    glViewport(0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode(GL_PROJECTION);
@@ -111,7 +111,7 @@ void reshape(int w, int h)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 't':
index 58c451c976935966ca4198db56c1a256e8c03df3..f41be89b097fa9f9da56123b6028a7326b5491f5 100644 (file)
@@ -81,7 +81,7 @@ static void drawRightTriangle(void)
    glDisable (GL_BLEND);
 }
 
-void display(void)
+static void display(void)
 {
    glClear(GL_COLOR_BUFFER_BIT);
 
@@ -97,7 +97,7 @@ void display(void)
    glFlush();
 }
 
-void reshape(int w, int h)
+static void reshape(int w, int h)
 {
    glViewport(0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode(GL_PROJECTION);
@@ -109,7 +109,7 @@ void reshape(int w, int h)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 't':
index f49186bd8ae67e27ef8e3a18006f2663eaf811fe..e52ed81bf4495740836e9d61e7aae555648cd9ce 100644 (file)
@@ -63,7 +63,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index e1deca1bdcf01ba4ded73525262816a69f48c4eb..3e3879c9859762311959b60b410b2855045d8199 100644 (file)
@@ -56,7 +56,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
     glutPostRedisplay();
 }
index 864be710c2a44a74eef49b447c0563baa418e851..809599d4a6dc822d6ca4fefd61f42f58439675af 100644 (file)
@@ -65,7 +65,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index c410be221a703fb13b0c748ba793c2b80e0f674b..62d0a965d82dd7880423fc12a505bc63d67a7e9f 100644 (file)
@@ -75,7 +75,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 72b4cf3683dbd3fd2dd10a28b9efd846a3efde4a..8d1f871328d8eaf06e358a209cdce525e648c7c9 100644 (file)
@@ -189,9 +189,6 @@ Key(unsigned char key, int x, int y)
 static void
 Init(int argc, char *argv[])
 {
-   static const GLfloat mat[4] = { 1.0, 0.5, 0.5, 1.0 };
-   GLint i;
-
    if (!glutExtensionSupported("GL_EXT_framebuffer_object")) {
       printf("GL_EXT_framebuffer_object not found!\n");
       exit(0);
index 1ed177ffdfb23ed79bc0312a8711406923187707..089180f97ad125e9bd21629be49fd650aead096d 100644 (file)
@@ -75,7 +75,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 2aab5ba00a5a4a501749cee7f613531ff650b0e6..a23f8a382b0702915ba1c050c189c2a012283c41 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index ea703ec6f3fa9b5b8c8d6115481cb98fcc485647..0614321844e7222709aa952ee68c1d753eaf2be4 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 0cea3d325829ba01901a2ceb5f4aaa27736f36b3..7fc254a46758c4be799da90cd352378c7328a804 100644 (file)
@@ -72,7 +72,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index d2df442abfce336aa176ddfa8d6d841472f9df32..accea62042d6a5029897df6859bc82591a5451c2 100644 (file)
@@ -92,7 +92,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 4d1508120ea2a4f2a33c10fabc6af169dc2e30a8..6ecfef4d2ac5a803994e78cf4c4738dcf91da4ae 100644 (file)
@@ -42,7 +42,7 @@ static void Init(void)
    static const char *prog1 =
       "!!ARBfp1.0\n"
       "MOV  result.color, fragment.texcoord[1];\n"
-//      "MOV  result.color, fragment.color;\n"
+      /* "MOV  result.color, fragment.color;\n" */
       "END\n";
 
 
@@ -90,7 +90,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index ff9fb2c4dd69aae00c1c82d338073e37d1e64546..16cebb2b984a591c19728debaebaa9fa0e29400e 100644 (file)
@@ -65,7 +65,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 15a7ad24c515f0d3966259cf02ba531eeebab722..26ebd99d9179207216381f5d9ed572ba437c4d8f 100644 (file)
@@ -65,7 +65,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 53c2614ac32bf9ef53892e7256375e80491c0140..2b6a3d6f5c8e71e813eaa1c144c70959db29a1c3 100644 (file)
@@ -101,7 +101,7 @@ static void Draw(void)
    glVertex3f( 0.5, -0.5, -30.0);
    glEnd();
 
-//   glLineWidth(12.0);
+   /* glLineWidth(12.0); */
 
    /* Redraw parts of the lines:
     */
index f018a851ace16e51a6d8e64342823ae70a1d3108..b8207cd6d8a6511e2f01c2b78e95241df9db7a1a 100644 (file)
@@ -105,7 +105,7 @@ static void Draw(void)
    glVertex3f( 0.5, -0.5, -30.0);
    glEnd();
 
-//   glLineWidth(12.0);
+   /* glLineWidth(12.0); */
 
    /* Redraw parts of the lines to remove them:
     */
index e319447ac15be354a041410e9c23d6c7f61a1931..ca4edaa5ddceb5f37bb32c1ef2144dd9d572dc5a 100644 (file)
@@ -192,7 +192,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index e7cfee3a3679f10ce7934381aa35f918df7b0a3a..f86ac52a02649fdfca003f8e765ba0268abbcb5a 100644 (file)
@@ -51,7 +51,7 @@ static void Reshape(int width, int height)
 
     glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
-/*     glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); */
+    glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
     glMatrixMode(GL_MODELVIEW);
 }
 
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
@@ -74,11 +74,11 @@ static void Draw(void)
 
    glBegin(GL_TRIANGLES);
    glColor3f(0,0,.7); 
-   glVertex3f( 0.9, -0.9, -0.0);
+   glVertex3f( 0.9, -0.9, -30.0);
    glColor3f(.8,0,0); 
-   glVertex3f( 0.9,  0.9, -0.0);
+   glVertex3f( 0.9,  0.9, -30.0);
    glColor3f(0,.9,0); 
-   glVertex3f(-0.9,  0.0, -0.0);
+   glVertex3f(-0.9,  0.0, -30.0);
    glEnd();
 
    glFlush();
@@ -119,7 +119,7 @@ int main(int argc, char **argv)
 
     glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
 
-    type = GLUT_RGB | GLUT_ALPHA;
+    type = GLUT_RGB;
     type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
     glutInitDisplayMode(type);
 
index 85e39df2dfaf1d99adec63ba0c2401186af43f38..8898f182c78d623bdccdaf46a4d1baaa2285ed22 100644 (file)
@@ -39,6 +39,11 @@ GLenum doubleBuffer;
 
 static void Init(void)
 {
+   if (!glutExtensionSupported("GL_ARB_occlusion_query")) {
+      fprintf(stderr, "Sorry, this program requires GL_ARB_occlusion_query\n");
+      exit(1);
+   }
+
    fprintf(stderr, "GL_RENDERER   = %s\n", (char *) glGetString(GL_RENDERER));
    fprintf(stderr, "GL_VERSION    = %s\n", (char *) glGetString(GL_VERSION));
    fprintf(stderr, "GL_VENDOR     = %s\n", (char *) glGetString(GL_VENDOR));
@@ -67,7 +72,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 608ebf29cff5ba2338344cb2e57730f415da6074..d65502d91b959688496123b50d2a08cc297bae6e 100644 (file)
@@ -63,7 +63,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 0b82a1dd8e3a49ca53f5744d421ad7c89ef46399..2014bd489c37a17c1b407a78ced5b0e4007e8f18 100644 (file)
@@ -63,7 +63,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index aa94fa224b73f70e83893e48c6b150ff158bb5b1..15a08fec7c81fbcb199249ad414eb3a02490e72f 100644 (file)
@@ -77,7 +77,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 3ccbe12510575a3605d0bf0006f863e952c8f24f..073a080d7a71bf195608769cf167581955972f60 100644 (file)
@@ -97,7 +97,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 56afb4748d76f738207c012833f1c5f4566e2005..244e154504275890c220ac1ec34ba471dce5895e 100644 (file)
@@ -94,7 +94,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index f996bd01a168d83d48bc86af3cf83ed49a82c131..7bf400793ea9d1fb46185fa06b03bf9398c2ccf6 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 2fd894a49a819c81a6568fca0f0cc84db6c98eb7..585919e16d13660f13f4ee84c68b6d178b2dc8b2 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 11c21d1bf68885330da0b888a6fe11de49914153..f536f6422961de84b24b2999775366d053fa4cdf 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 750a254669aa7cc0676a5dfd5f0efd1648240ccc..11e276e1a5bdc6987b78c58c37581f0a65be2984 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index eddae176e5fec22e6733584e60d91c27acc80493..fa31667e6582c575e8a58254152074f22de8a192 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 1d42b40b713bf58da55c962b441297745dadb435..d6baeb46978abdef910e02053fd3aa1ee785dcc4 100644 (file)
@@ -65,7 +65,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 695cc890955c60865738b0473a6f8dd56dd3dbd4..75a70b8a4129a0a4f37b480ecce10ba2f887eb05 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index ddc0dffd4f4ae6abbe94ca21b40764da7d7919b6..02bfa92f835836be34c5b6315be87247e7fab3fc 100644 (file)
@@ -67,7 +67,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 0dec0bfc9b41b90dabe708dbed16b71bebb95fd3..11e53fc7cc94c225d5d51874391cb39269acb1f3 100644 (file)
@@ -66,7 +66,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index b98cb9a842a2ae1a75f9a28084924873d6bd0c5a..afa1058dad46ce0b68cc483113c2fba756b9fc90 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 8f37e0fae2085a22eda4d607433ba0de2e228c2d..5651c73832586edf41bc983057113426af7a1d8c 100644 (file)
@@ -66,7 +66,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 099e89f6f4ac56b005f12b8976e789dbb0a65141..37b9e2f8732ac700c98adee85119268f9f45eea6 100644 (file)
@@ -61,7 +61,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 195e8a26f6dd200f28569d3ea7b62574eeeaf112..c04ffae7f1a34b69f1ef251c2bf89ae27908510b 100644 (file)
@@ -61,7 +61,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 014aaa071a51efaf28a531b7cc108c15eb5e4bb5..092249dd765151d4b47c020257b1e953e8f69994 100644 (file)
@@ -101,7 +101,7 @@ static void drawRightTriangle(void)
    glEnd();
 }
 
-void display(void)
+static void display(void)
 {
    printf("GL_CLEAR_DEPTH = %.2f,  GL_DEPTH_FUNC = %s,  DepthRange(%.1f, %.1f)\n",
           clearVal, funcs[curFunc].str, minZ, maxZ);
@@ -124,7 +124,7 @@ void display(void)
    glFlush();
 }
 
-void reshape(int w, int h)
+static void reshape(int w, int h)
 {
    glViewport(0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode(GL_PROJECTION);
@@ -136,7 +136,7 @@ void reshape(int w, int h)
 }
 
 /* ARGSUSED1 */
-void keyboard(unsigned char key, int x, int y)
+static void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
       case 'n':
index 199f91a637e57003211d76958d2a4204eec42dd4..89bc471191efdb35a7a54e137eb55109723a3756 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index ea3e15538728e63f12f4763a115f1a1ab71dc3e6..3a1a226e546bb7d861d1171909773f22974a4ecb 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index d69b4887e39753e7ac4add5dfdd467568b9fc1ad..d25abdf49ebaea084bf69d2fc8d28b2f6203b540 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 91447e4e44d8ee3a23a3b24227bd9156fd286fa6..2e3ff8218f0bec229632195802cf81b8af1041b7 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 84eb4172de18c005ef814cb3bee0f3eb71b2b07c..b8a76151148c6b6331a3349e96158605f6cc004e 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 343e2938049bfac79244c07856c3dd05b6901048..4e6ee1fbca2718e309828b5644a8e6306220dc63 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 02da97efcea73ddb0770ddedd35d576dab1877f4..a90b8b6cb68cbee5aab8504ec7b1bcdbf8bc17d5 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 77bf2fad282d9e78d741e801c4cd95fec92feb07..29915ff111d8b44343308a6d8ec952d54d87333b 100644 (file)
@@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index c29954b90330b9b0f20422ff3f1a23539612d657..cb26e841156d02d2e279c29a3f3e15fdfd620deb 100644 (file)
@@ -83,7 +83,7 @@ static void Display( void )
 
    glEnable(GL_VERTEX_PROGRAM_ARB);
 
-//   glDrawArrays( GL_TRIANGLES, 0, 3 );
+   /* glDrawArrays( GL_TRIANGLES, 0, 3 ); */
    glDrawArrays( GL_TRIANGLES, 1, 3 );
 
    glFlush(); 
index 0672ca50ff193a11b88f4d7b53a7269267be673a..f7c42a89818273176dc6df6b0d2408f20df9bde3 100644 (file)
@@ -87,8 +87,8 @@ static void Display( void )
 
    glEnable(GL_VERTEX_PROGRAM_ARB);
 
-//   glDrawArrays( GL_TRIANGLES, 0, 3 );
-//   glDrawArrays( GL_TRIANGLES, 1, 3 );
+   /* glDrawArrays( GL_TRIANGLES, 0, 3 ); */
+   /* glDrawArrays( GL_TRIANGLES, 1, 3 ); */
    glDrawArrays( GL_QUADS, 0, 4 );
 
    glFlush(); 
diff --git a/progs/trivial/vbo-tri.c b/progs/trivial/vbo-tri.c
new file mode 100644 (file)
index 0000000..d4cba14
--- /dev/null
@@ -0,0 +1,131 @@
+/* Even simpler for many drivers than trivial/tri -- pass-through
+ * vertex shader and vertex data in a VBO.
+ */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glew.h>
+#include <GL/glut.h>
+
+
+struct {
+   GLfloat pos[4];
+   GLfloat color[4];
+} verts[] =  
+{
+   { {  -0.9, -0.9, 0.0, 1.0 },
+     {.8,0,0, 1}, 
+   },
+
+   { {  0.9,  -0.9, 0.0, 1.0 },
+     { 0, .9, 0, 1 },
+   },
+
+   { { 0,  0.9, 0.0, 1.0 },
+     {0,0,.7, 1}, 
+   },
+};
+
+GLuint arrayObj;
+
+static void Init( void )
+{
+   GLint errno;
+   GLuint prognum;
+   
+   static const char *prog1 =
+      "!!ARBvp1.0\n"
+      "MOV  result.color, vertex.color;\n"
+      "MOV  result.position, vertex.position;\n"
+      "END\n";
+
+
+   glGenProgramsARB(1, &prognum);
+
+   glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum);
+   glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
+                     strlen(prog1), (const GLubyte *) prog1);
+
+   assert(glIsProgramARB(prognum));
+   errno = glGetError();
+   printf("glGetError = %d\n", errno);
+   if (errno != GL_NO_ERROR)
+   {
+      GLint errorpos;
+
+      glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos);
+      printf("errorpos: %d\n", errorpos);
+      printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB));
+   }
+
+
+   glEnableClientState( GL_VERTEX_ARRAY );
+   glEnableClientState( GL_COLOR_ARRAY );
+
+   glGenBuffersARB(1, &arrayObj);
+   glBindBufferARB(GL_ARRAY_BUFFER_ARB, arrayObj);
+   glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(verts), verts, GL_STATIC_DRAW_ARB);
+
+   glVertexPointer( 4, GL_FLOAT, sizeof(verts[0]), 0 );
+   glColorPointer( 4, GL_FLOAT, sizeof(verts[0]), (void *)(4*sizeof(float)) );
+}
+
+
+
+static void Display( void )
+{
+   glClearColor(0.3, 0.3, 0.3, 1);
+   glClear( GL_COLOR_BUFFER_BIT );
+
+   glEnable(GL_VERTEX_PROGRAM_NV);
+   glDrawArrays( GL_TRIANGLES, 0, 3 );
+
+   glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+   glViewport( 0, 0, width, height );
+   glMatrixMode( GL_PROJECTION );
+   glLoadIdentity();
+   glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.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:
+         exit(0);
+         break;
+   }
+   glutPostRedisplay();
+}
+
+
+
+
+int main( int argc, char *argv[] )
+{
+   glutInit( &argc, argv );
+   glutInitWindowPosition( 0, 0 );
+   glutInitWindowSize( 250, 250 );
+   glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
+   glutCreateWindow(argv[0]);
+   glewInit();
+   glutReshapeFunc( Reshape );
+   glutKeyboardFunc( Key );
+   glutDisplayFunc( Display );
+   Init();
+   glutMainLoop();
+   return 0;
+}
index 42bf9806b19ef7ecd93a75f6e3d9f3d03006cc2a..9cbc4d1193a0bd2d1ea690bba9916ae08f8d15d3 100644 (file)
@@ -81,7 +81,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 8290226675ecbd3894d0630028d5b09c7b36e89c..e543e2ec3fd8962598da106dec0c84dbac64a110 100644 (file)
@@ -114,7 +114,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index ff241393659835d098ef1b0a756ad2a2e968b26b..4dbe95eb9a1ff457672b296d02903b4edf6f93a3 100644 (file)
@@ -69,7 +69,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
index 8e923b6eb47126952e9dd5cf2caa2b858bcc5d50..f6f511481ca30ddf85ac412fca80154fb69aec51 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <GL/gl.h>
 #include <GL/glu.h>
+#include <assert.h>
 #include <stdio.h>
 #include <stdlib.h> 
 #include <string.h>
@@ -89,6 +90,7 @@ static rawImageRec *RawImageOpen(const char *fileName)
    rawImageRec *raw;
    GLenum swapFlag;
    int x;
+   size_t result;
 
    endianTest.testWord = 1;
    if (endianTest.testByte[0] == 1) {
@@ -109,14 +111,21 @@ static rawImageRec *RawImageOpen(const char *fileName)
          raw->file = fopen(baseName + 1, "rb");
       if(raw->file == NULL) {
          perror(fileName);
+         free(raw);
          return NULL;
       }
    }
 
-   fread(raw, 1, 12, raw->file);
+   result = fread(raw, 1, 12, raw->file);
+   assert(result == 12);
 
    if (swapFlag) {
-      ConvertShort(&raw->imagic, 6);
+      ConvertShort(&raw->imagic, 1);
+      ConvertShort(&raw->type, 1);
+      ConvertShort(&raw->dim, 1);
+      ConvertShort(&raw->sizeX, 1);
+      ConvertShort(&raw->sizeY, 1);
+      ConvertShort(&raw->sizeZ, 1);
    }
 
    raw->tmp = (unsigned char *)malloc(raw->sizeX*256);
@@ -129,6 +138,12 @@ static rawImageRec *RawImageOpen(const char *fileName)
    if (raw->tmp == NULL || raw->tmpR == NULL || raw->tmpG == NULL ||
        raw->tmpB == NULL) {
       fprintf(stderr, "Out of memory!\n");
+      free(raw->tmp);
+      free(raw->tmpR);
+      free(raw->tmpG);
+      free(raw->tmpB);
+      free(raw->tmpA);
+      free(raw);
       return NULL;
    }
 
@@ -138,12 +153,22 @@ static rawImageRec *RawImageOpen(const char *fileName)
       raw->rowSize = (GLint *)malloc(x);
       if (raw->rowStart == NULL || raw->rowSize == NULL) {
          fprintf(stderr, "Out of memory!\n");
+         free(raw->tmp);
+         free(raw->tmpR);
+         free(raw->tmpG);
+         free(raw->tmpB);
+         free(raw->tmpA);
+         free(raw->rowStart);
+         free(raw->rowSize);
+         free(raw);
          return NULL;
       }
       raw->rleEnd = 512 + (2 * x);
       fseek(raw->file, 512, SEEK_SET);
-      fread(raw->rowStart, 1, x, raw->file);
-      fread(raw->rowSize, 1, x, raw->file);
+      result = fread(raw->rowStart, 1, x, raw->file);
+      assert(result == x);
+      result = fread(raw->rowSize, 1, x, raw->file);
+      assert(result == x);
       if (swapFlag) {
          ConvertLong(raw->rowStart, (long) (x/sizeof(GLuint)));
          ConvertLong((GLuint *)raw->rowSize, (long) (x/sizeof(GLint)));
@@ -173,11 +198,13 @@ static void RawImageGetRow(rawImageRec *raw, unsigned char *buf, int y, int z)
 {
    unsigned char *iPtr, *oPtr, pixel;
    int count, done = 0;
+   size_t result;
 
    if ((raw->type & 0xFF00) == 0x0100) {
       fseek(raw->file, (long) raw->rowStart[y+z*raw->sizeY], SEEK_SET);
-      fread(raw->tmp, 1, (unsigned int)raw->rowSize[y+z*raw->sizeY],
-            raw->file);
+      result = fread(raw->tmp, 1, (unsigned int)raw->rowSize[y+z*raw->sizeY],
+                     raw->file);
+      assert(result == (unsigned int)raw->rowSize[y+z*raw->sizeY]);
       
       iPtr = raw->tmp;
       oPtr = buf;
@@ -202,7 +229,8 @@ static void RawImageGetRow(rawImageRec *raw, unsigned char *buf, int y, int z)
    } else {
       fseek(raw->file, 512+(y*raw->sizeX)+(z*raw->sizeX*raw->sizeY),
             SEEK_SET);
-      fread(buf, 1, raw->sizeX, raw->file);
+      result = fread(buf, 1, raw->sizeX, raw->file);
+      assert(result == raw->sizeX);
    }
 }
 
@@ -215,6 +243,7 @@ static void RawImageGetData(rawImageRec *raw, TK_RGBImageRec *final)
    final->data = (unsigned char *)malloc((raw->sizeX+1)*(raw->sizeY+1)*4);
    if (final->data == NULL) {
       fprintf(stderr, "Out of memory!\n");
+      return;
    }
 
    ptr = final->data;
@@ -250,6 +279,7 @@ static TK_RGBImageRec *tkRGBImageLoad(const char *fileName)
    final = (TK_RGBImageRec *)malloc(sizeof(TK_RGBImageRec));
    if (final == NULL) {
       fprintf(stderr, "Out of memory!\n");
+      RawImageClose(raw);
       return NULL;
    }
    final->sizeX = raw->sizeX;
@@ -305,6 +335,7 @@ GLboolean LoadRGBMipmaps2( const char *imageFile, GLenum target,
       fprintf(stderr,
               "Error in LoadRGBMipmaps %d-component images not implemented\n",
               image->components );
+      FreeImage(image);
       return GL_FALSE;
    }
 
@@ -356,6 +387,7 @@ GLubyte *LoadRGBImage( const char *imageFile, GLint *width, GLint *height,
       fprintf(stderr,
               "Error in LoadRGBImage %d-component images not implemented\n",
               image->components );
+      FreeImage(image);
       return NULL;
    }
 
@@ -364,8 +396,10 @@ GLubyte *LoadRGBImage( const char *imageFile, GLint *width, GLint *height,
 
    bytes = image->sizeX * image->sizeY * image->components;
    buffer = (GLubyte *) malloc(bytes);
-   if (!buffer)
+   if (!buffer) {
+      FreeImage(image);
       return NULL;
+   }
 
    memcpy( (void *) buffer, (void *) image->data, bytes );
 
@@ -438,6 +472,7 @@ GLushort *LoadYUVImage( const char *imageFile, GLint *width, GLint *height )
       fprintf(stderr,
               "Error in LoadYUVImage %d-component images not implemented\n",
               image->components );
+      FreeImage(image);
       return NULL;
    }
 
index 4db950016b890149506250f2f66c3cb723733edb..2f44c388d8a3b7769851de09d6be8bd546ca32e3 100644 (file)
@@ -25,7 +25,11 @@ GLboolean
 ShadersSupported(void)
 {
    const char *version = (const char *) glGetString(GL_VERSION);
-   if (version[0] == '2' && version[1] == '.') {
+
+   /* NVIDIA binary drivers will return "3.0.0", and they clearly support
+    * shaders.
+    */
+   if (version[0] >= '2' && version[1] == '.') {
       return GL_TRUE;
    }
    else if (glutExtensionSupported("GL_ARB_vertex_shader")
@@ -34,7 +38,8 @@ ShadersSupported(void)
       fprintf(stderr, "Warning: Trying ARB GLSL instead of OpenGL 2.x.  This may not work.\n");
       return GL_TRUE;
    }
-   return GL_TRUE;
+   fprintf(stderr, "Sorry, GLSL not supported with this OpenGL.\n");
+   return GL_FALSE;
 }
 
 
@@ -84,6 +89,7 @@ CompileShaderFile(GLenum shaderType, const char *filename)
    f = fopen(filename, "r");
    if (!f) {
       fprintf(stderr, "Unable to open shader file %s\n", filename);
+      free(buffer);
       return 0;
    }
 
@@ -94,6 +100,8 @@ CompileShaderFile(GLenum shaderType, const char *filename)
       shader = CompileShaderText(shaderType, buffer);
    }
    else {
+      fclose(f);
+      free(buffer);
       return 0;
    }
 
index 640c5dd847069b5940f0f50d5bae74c11bd4c653..787cb793af28c1d195471cbf1224dcf25ee532dd 100644 (file)
@@ -1,13 +1,6 @@
-Import('env')
+Import('*')
 
-if not env['GLUT']:
-    Return()
-
-env = env.Clone()
-
-env.Prepend(LIBS = ['$GLUT_LIB'])
-
-env.Program(
+progs_env.Program(
         target = 'vp-tris',
         source = ['vp-tris.c'],
     )
diff --git a/progs/vp/add-param-imm.txt b/progs/vp/add-param-imm.txt
new file mode 100644 (file)
index 0000000..90bcf96
--- /dev/null
@@ -0,0 +1,7 @@
+!!ARBvp1.0
+TEMP R0;
+PARAM Emission = state.material.emission; 
+ADD R0, vertex.color, {-0.5}.x;
+ADD result.color, R0, Emission.w;
+MOV  result.position, vertex.position;
+END
index 1356242d971d9c57405d4c1a898fa9fa8e0048f6..09236c296f7e5f5ec7fbc0e78a961d965f3d560e 100644 (file)
@@ -96,12 +96,15 @@ static void Init( void )
       exit(1);
    }
 
-   sz = (GLuint) fread(buf, 1, sizeof(buf), f);
+   sz = (GLuint) fread(buf, 1, sizeof(buf) - 1, f);
+   buf[sizeof(buf) - 1] = '\0';
    if (!feof(f)) {
       fprintf(stderr, "file too long\n");
+      fclose(f);
       exit(1);
    }
 
+   fclose(f);
    fprintf(stderr, "%.*s\n", sz, buf);
 
    if (strncmp( buf, "!!VP", 4 ) == 0) {
index 640c5dd847069b5940f0f50d5bae74c11bd4c653..787cb793af28c1d195471cbf1224dcf25ee532dd 100644 (file)
@@ -1,13 +1,6 @@
-Import('env')
+Import('*')
 
-if not env['GLUT']:
-    Return()
-
-env = env.Clone()
-
-env.Prepend(LIBS = ['$GLUT_LIB'])
-
-env.Program(
+progs_env.Program(
         target = 'vp-tris',
         source = ['vp-tris.c'],
     )
index 77f4a46b52022995aa6f27ff9df335ee425cab1c..d2a90d8578eede50b9a770656d6eb87ca18d98e9 100644 (file)
@@ -1,6 +1,6 @@
 
 void main() {
     gl_FrontColor = gl_Color;
-    gl_PointSize = 10 * gl_Color.x;
+    gl_PointSize = 10.0 * gl_Color.x;
     gl_Position = gl_Vertex;
 }
index b2b050809107236bdcd70e85f8de4e6f30b7ac9e..6a1fa3d3bf065531bc4dc730bc8a3d73a75be752 100644 (file)
@@ -84,9 +84,9 @@ static void check_link(GLuint prog)
 static void setup_uniforms()
 {
    {
-      GLuint loc1f = glGetUniformLocationARB(program, "Offset1f");
-      GLuint loc2f = glGetUniformLocationARB(program, "Offset2f");
-      GLuint loc4f = glGetUniformLocationARB(program, "Offset4f");
+      GLint loc1f = glGetUniformLocationARB(program, "Offset1f");
+      GLint loc2f = glGetUniformLocationARB(program, "Offset2f");
+      GLint loc4f = glGetUniformLocationARB(program, "Offset4f");
       GLfloat vecKer[] =
          { 1.0, 0.0, 0.0,  1.0,
            0.0, 1.0, 0.0,  1.0,
@@ -105,9 +105,9 @@ static void setup_uniforms()
    }
 
    {
-      GLuint loc1f = glGetUniformLocationARB(program, "KernelValue1f");
-      GLuint loc2f = glGetUniformLocationARB(program, "KernelValue2f");
-      GLuint loc4f = glGetUniformLocationARB(program, "KernelValue4f");
+      GLint loc1f = glGetUniformLocationARB(program, "KernelValue1f");
+      GLint loc2f = glGetUniformLocationARB(program, "KernelValue2f");
+      GLint loc4f = glGetUniformLocationARB(program, "KernelValue4f");
       GLfloat vecKer[] =
          { 1.0, 0.0, 0.0,  0.25,
            0.0, 1.0, 0.0,  0.25,
index 31f61676dec9f4fb52884c2aec1e5c8c9f22218f..248cc53a8d723d66911e84a24f23bd761c550f05 100644 (file)
@@ -1,25 +1,17 @@
 Import('*')
 
-if env['platform'] != 'windows':
+if progs_env['platform'] != 'windows':
     Return()
 
-env = env.Clone()
-
-env.Append(LIBS = [
-    'kernel32',
-    'user32',
-    'gdi32',
-])
-
 progs = [
     'sharedtex_mt',
     'wglthreads',
 ]
 
 for prog in progs:
-    env.Program(
+    progs_env.Program(
         target = prog,
         source = prog + '/' + prog + '.c',
     )
 
-env.Program('wglinfo', ['wglinfo.c'])
+progs_env.Program('wglinfo', ['wglinfo.c'])
index 53e1c54ef3cbee9529b4c1b625c1847d59348796..77f667978ce1b2cbf5563d157056267e67e7dd0f 100644 (file)
@@ -8,6 +8,9 @@ INCDIR = $(TOP)/include
 
 LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)
 
+# Add X11 and pthread libs to satisfy GNU gold.
+APP_LIB_DEPS += -lX11 -lpthread
+
 LIBS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) $(APP_LIB_DEPS)
 
 PROGS = \
index f2b8145e52b4ac297e32d1f41bf9d50ed8f282bc..640c902c136c140fab1f964b46eee1d197fdc016 100644 (file)
@@ -55,6 +55,7 @@ setup_ipc(void)
 
       printf("Waiting for connection from another 'corender'\n");
       Sock = AcceptConnection(k);
+      assert(Sock != -1);
 
       printf("Got connection, sending windowID\n");
 
@@ -186,7 +187,7 @@ redraw(Display *dpy)
        * Without this glClear(), depth buffer for the second process
        * is pretty much broken.
        */
-      //glClear(GL_DEPTH_BUFFER_BIT);
+      /* glClear(GL_DEPTH_BUFFER_BIT); */
 
       glPushMatrix();
       glTranslatef(1, 0, 0);
index 34167d339f391011df039e5e318596c6c7e01855..da87306cf2af10227fddf2c91c85834cf32e0373 100644 (file)
@@ -95,7 +95,7 @@ enum sync_type {
 static void usage(char *name)
 {
        printf("usage: %s [-w <width>] [-h <height>] [-s<sync method>] "
-              "[-vc]\n", name);
+              "[-v]\n", name);
        printf("\t-s<sync method>:\n");
        printf("\t\tn: none\n");
        printf("\t\ts: SGI video sync extension\n");
index 445d3ea94b6d851d9a7de65a17242c039155cbb1..30cd5680642a9e630978d881f65f98046a32a130 100644 (file)
@@ -116,7 +116,7 @@ print_extension_list(const char *ext)
       return;
 
    width = indent;
-   printf(indentString);
+   printf("%s", indentString);
    i = j = 0;
    while (1) {
       if (ext[j] == ' ' || ext[j] == 0) {
@@ -126,7 +126,7 @@ print_extension_list(const char *ext)
             /* start a new line */
             printf("\n");
             width = indent;
-            printf(indentString);
+            printf("%s", indentString);
          }
          /* print the extension name between ext[i] and ext[j] */
          while (i < j) {
@@ -401,6 +401,10 @@ print_screen_info(Display *dpy, int scrnum, Bool allowDirect, GLboolean limits)
 
    root = RootWindow(dpy, scrnum);
 
+   /*
+    * Find a basic GLX visual.  We'll then create a rendering context and
+    * query various info strings.
+    */
    visinfo = glXChooseVisual(dpy, scrnum, attribSingle);
    if (!visinfo)
       visinfo = glXChooseVisual(dpy, scrnum, attribDouble);
@@ -409,26 +413,29 @@ print_screen_info(Display *dpy, int scrnum, Bool allowDirect, GLboolean limits)
       ctx = glXCreateContext( dpy, visinfo, NULL, allowDirect );
 
 #ifdef GLX_VERSION_1_3
-   {
+   /* Try glXChooseFBConfig() if glXChooseVisual didn't work.
+    * XXX when would that happen?
+    */
+   if (!visinfo) {
       int fbAttribSingle[] = {
         GLX_RENDER_TYPE,   GLX_RGBA_BIT,
         GLX_RED_SIZE,      1,
         GLX_GREEN_SIZE,    1,
         GLX_BLUE_SIZE,     1,
-        GLX_DOUBLEBUFFER,  GL_TRUE,
+        GLX_DOUBLEBUFFER,  GL_FALSE,
         None };
       int fbAttribDouble[] = {
         GLX_RENDER_TYPE,   GLX_RGBA_BIT,
         GLX_RED_SIZE,      1,
         GLX_GREEN_SIZE,    1,
         GLX_BLUE_SIZE,     1,
+        GLX_DOUBLEBUFFER,  GL_TRUE,
         None };
       GLXFBConfig *configs = NULL;
       int nConfigs;
 
-      if (!visinfo)
-        configs = glXChooseFBConfig(dpy, scrnum, fbAttribSingle, &nConfigs);
-      if (!visinfo)
+      configs = glXChooseFBConfig(dpy, scrnum, fbAttribSingle, &nConfigs);
+      if (!configs)
         configs = glXChooseFBConfig(dpy, scrnum, fbAttribDouble, &nConfigs);
 
       if (configs) {
@@ -964,8 +971,10 @@ print_fbconfig_info(Display *dpy, int scrnum, InfoMode mode)
    /* get list of all fbconfigs on this screen */
    fbconfigs = glXGetFBConfigs(dpy, scrnum, &numFBConfigs);
 
-   if (numFBConfigs == 0)
+   if (numFBConfigs == 0) {
+      XFree(fbconfigs);
       return;
+   }
 
    printf("%d GLXFBConfigs:\n", numFBConfigs);
    if (mode == Normal)
index 91fd30dcaa693afc949229407323a472033e837d..ecf318ec6a7bc3efa13a7b13c7bd7c9a45d4b324 100644 (file)
@@ -106,6 +106,7 @@ MakePbuffer( Display *dpy, int screen, int width, int height )
 
    if (0 == nConfigs || !fbConfigs) {
       printf("Error: glxChooseFBConfig failed\n");
+      XFree(fbConfigs);
       XCloseDisplay(dpy);
       return 0;
    }
index 6c5abf383be7640ccd460077e0e1bb9f08f6c229..314a4fcdd179d7cb6b113dac8ec94692ccbe1171 100644 (file)
@@ -294,6 +294,7 @@ process_input(Display *dpy, Window win) {
            default:
                break;
            }
+           break;
        case ButtonPress:
            prevx = event.xbutton.x;
            prevy = event.xbutton.y;
index 2573209336cc6b09f798bd6e5c13c4b6b91408bc..277df729246bea3853d512f19597d35e15053c1e 100644 (file)
@@ -131,6 +131,7 @@ MakePbuffer( Display *dpy, int screen, int width, int height )
       fbConfigs = ChooseFBConfig(dpy, screen, fbAttribs[attempt], &nConfigs);
       if (nConfigs==0 || !fbConfigs) {
          printf("Note: glXChooseFBConfig(%s) failed\n", fbString[attempt]);
+         XFree(fbConfigs);
          continue;
       }
 
index b43adf1bb70130b90c0b46637d0285c43e5da2b6..edfa9c1f3b0392300909b65c46ae0b98fa70eaae 100644 (file)
@@ -27,6 +27,7 @@ PrintConfigs(Display *dpy, int screen, Bool horizFormat)
    fbConfigs = GetAllFBConfigs(dpy, screen, &nConfigs);
    if (!nConfigs || !fbConfigs) {
       printf("Error: glxGetFBConfigs failed\n");
+      XFree(fbConfigs);
       return;
    }
 
index 07c1bfcc38842d6574f57f45d76a8dd50a885b7b..f924448cc436444b520bf3f52297b314f53a69d3 100644 (file)
@@ -447,7 +447,7 @@ main(int argc, char *argv[])
    const char *dpyName = XDisplayName(NULL);
    pthread_t t0, t1, t2, t3;
    struct thread_init_arg tia0, tia1, tia2, tia3;
-   struct window *h0, *h1, *h2, *h3;
+   struct window *h0;
 
    XInitThreads();
 
@@ -462,9 +462,9 @@ main(int argc, char *argv[])
 
    /* four windows and contexts sharing display lists and texture objects */
    h0 = AddWindow(gDpy, dpyName,  10,  10, gCtx);
-   h1 = AddWindow(gDpy, dpyName, 330,  10, gCtx);
-   h2 = AddWindow(gDpy, dpyName,  10, 350, gCtx);
-   h3 = AddWindow(gDpy, dpyName, 330, 350, gCtx);
+   (void) AddWindow(gDpy, dpyName, 330,  10, gCtx);
+   (void) AddWindow(gDpy, dpyName,  10, 350, gCtx);
+   (void) AddWindow(gDpy, dpyName, 330, 350, gCtx);
 
    if (!glXMakeCurrent(gDpy, h0->Win, gCtx)) {
       Error(dpyName, "glXMakeCurrent failed for init thread.");
diff --git a/scons/custom.py b/scons/custom.py
new file mode 100644 (file)
index 0000000..572b963
--- /dev/null
@@ -0,0 +1,167 @@
+"""custom
+
+Custom builders and methods.
+
+"""
+
+#
+# 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.
+#
+
+
+import os
+import os.path
+import re
+
+import SCons.Action
+import SCons.Builder
+import SCons.Scanner
+
+import fixes
+
+
+def quietCommandLines(env):
+    # Quiet command lines
+    # See also http://www.scons.org/wiki/HidingCommandLinesInOutput
+    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):
+    """This is a utility function that creates the ConvenienceLibrary
+    Builder in an Environment if it is not there already.
+
+    If it is already there, we return the existing one.
+
+    Based on the stock StaticLibrary and SharedLibrary builders.
+    """
+
+    try:
+        convenience_lib = env['BUILDERS']['ConvenienceLibrary']
+    except KeyError:
+        action_list = [ SCons.Action.Action("$ARCOM", "$ARCOMSTR") ]
+        if env.Detect('ranlib'):
+            ranlib_action = SCons.Action.Action("$RANLIBCOM", "$RANLIBCOMSTR")
+            action_list.append(ranlib_action)
+
+        convenience_lib = SCons.Builder.Builder(action = action_list,
+                                  emitter = '$LIBEMITTER',
+                                  prefix = '$LIBPREFIX',
+                                  suffix = '$LIBSUFFIX',
+                                  src_suffix = '$SHOBJSUFFIX',
+                                  src_builder = 'SharedObject')
+        env['BUILDERS']['ConvenienceLibrary'] = convenience_lib
+
+    return convenience_lib
+
+
+# TODO: handle import statements with multiple modules
+# TODO: handle from import statements
+import_re = re.compile(r'^import\s+(\S+)$', re.M)
+
+def python_scan(node, env, path):
+    # http://www.scons.org/doc/0.98.5/HTML/scons-user/c2781.html#AEN2789
+    contents = node.get_contents()
+    source_dir = node.get_dir()
+    imports = import_re.findall(contents)
+    results = []
+    for imp in imports:
+        for dir in path:
+            file = os.path.join(str(dir), imp.replace('.', os.sep) + '.py')
+            if os.path.exists(file):
+                results.append(env.File(file))
+                break
+            file = os.path.join(str(dir), imp.replace('.', os.sep), '__init__.py')
+            if os.path.exists(file):
+                results.append(env.File(file))
+                break
+    return results
+
+python_scanner = SCons.Scanner.Scanner(function = python_scan, skeys = ['.py'])
+
+
+def code_generate(env, script, target, source, command):
+    """Method to simplify code generation via python scripts.
+
+    http://www.scons.org/wiki/UsingCodeGenerators
+    http://www.scons.org/doc/0.98.5/HTML/scons-user/c2768.html
+    """
+
+    # We're generating code using Python scripts, so we have to be
+    # careful with our scons elements.  This entry represents
+    # the generator file *in the source directory*.
+    script_src = env.File(script).srcnode()
+
+    # This command creates generated code *in the build directory*.
+    command = command.replace('$SCRIPT', script_src.path)
+    code = env.Command(target, source, command)
+
+    # Explicitly mark that the generated code depends on the generator,
+    # and on implicitly imported python modules
+    path = (script_src.get_dir(),)
+    deps = [script_src]
+    deps += script_src.get_implicit_deps(env, python_scanner, path)
+    env.Depends(code, deps)
+
+    # Running the Python script causes .pyc files to be generated in the
+    # source directory.  When we clean up, they should go too. So add side
+    # effects for .pyc files
+    for dep in deps:
+        pyc = env.File(str(dep) + 'c')
+        env.SideEffect(pyc, code)
+
+    return code
+
+
+def createCodeGenerateMethod(env):
+    env.Append(SCANNERS = python_scanner)
+    env.AddMethod(code_generate, 'CodeGenerate')
+
+
+def generate(env):
+    """Common environment generation code"""
+
+    if env.get('quiet', True):
+        quietCommandLines(env)
+
+    # Custom builders and methods
+    createConvenienceLibBuilder(env)
+    createCodeGenerateMethod(env)
+
+    # for debugging
+    #print env.Dump()
+
+
+def exists(env):
+    return 1
index 38782ac7266f5535d3f006de9e8a2757a945fbb6..69a356908fb07a926600210ed47f5a642537269d 100644 (file)
@@ -38,116 +38,6 @@ import SCons.Action
 import SCons.Builder
 import SCons.Scanner
 
-import fixes
-
-
-def quietCommandLines(env):
-    # Quiet command lines
-    # See also http://www.scons.org/wiki/HidingCommandLinesInOutput
-    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):
-    """This is a utility function that creates the ConvenienceLibrary
-    Builder in an Environment if it is not there already.
-
-    If it is already there, we return the existing one.
-
-    Based on the stock StaticLibrary and SharedLibrary builders.
-    """
-
-    try:
-        convenience_lib = env['BUILDERS']['ConvenienceLibrary']
-    except KeyError:
-        action_list = [ SCons.Action.Action("$ARCOM", "$ARCOMSTR") ]
-        if env.Detect('ranlib'):
-            ranlib_action = SCons.Action.Action("$RANLIBCOM", "$RANLIBCOMSTR")
-            action_list.append(ranlib_action)
-
-        convenience_lib = SCons.Builder.Builder(action = action_list,
-                                  emitter = '$LIBEMITTER',
-                                  prefix = '$LIBPREFIX',
-                                  suffix = '$LIBSUFFIX',
-                                  src_suffix = '$SHOBJSUFFIX',
-                                  src_builder = 'SharedObject')
-        env['BUILDERS']['ConvenienceLibrary'] = convenience_lib
-
-    return convenience_lib
-
-
-# TODO: handle import statements with multiple modules
-# TODO: handle from import statements
-import_re = re.compile(r'^import\s+(\S+)$', re.M)
-
-def python_scan(node, env, path):
-    # http://www.scons.org/doc/0.98.5/HTML/scons-user/c2781.html#AEN2789
-    contents = node.get_contents()
-    source_dir = node.get_dir()
-    imports = import_re.findall(contents)
-    results = []
-    for imp in imports:
-        for dir in path:
-            file = os.path.join(str(dir), imp.replace('.', os.sep) + '.py')
-            if os.path.exists(file):
-                results.append(env.File(file))
-                break
-            file = os.path.join(str(dir), imp.replace('.', os.sep), '__init__.py')
-            if os.path.exists(file):
-                results.append(env.File(file))
-                break
-    return results
-
-python_scanner = SCons.Scanner.Scanner(function = python_scan, skeys = ['.py'])
-
-
-def code_generate(env, script, target, source, command):
-    """Method to simplify code generation via python scripts.
-
-    http://www.scons.org/wiki/UsingCodeGenerators
-    http://www.scons.org/doc/0.98.5/HTML/scons-user/c2768.html
-    """
-
-    # We're generating code using Python scripts, so we have to be
-    # careful with our scons elements.  This entry represents
-    # the generator file *in the source directory*.
-    script_src = env.File(script).srcnode()
-
-    # This command creates generated code *in the build directory*.
-    command = command.replace('$SCRIPT', script_src.path)
-    code = env.Command(target, source, command)
-
-    # Explicitly mark that the generated code depends on the generator,
-    # and on implicitly imported python modules
-    path = (script_src.get_dir(),)
-    deps = [script_src]
-    deps += script_src.get_implicit_deps(env, python_scanner, path)
-    env.Depends(code, deps)
-
-    # Running the Python script causes .pyc files to be generated in the
-    # source directory.  When we clean up, they should go too. So add side
-    # effects for .pyc files
-    for dep in deps:
-        pyc = env.File(str(dep) + 'c')
-        env.SideEffect(pyc, code)
-
-    return code
-
-
-def createCodeGenerateMethod(env):
-    env.Append(SCANNERS = python_scanner)
-    env.AddMethod(code_generate, 'CodeGenerate')
-
 
 def symlink(target, source, env):
     target = str(target[0])
@@ -156,19 +46,34 @@ def symlink(target, source, env):
         os.remove(target)
     os.symlink(os.path.basename(source), target)
 
-def install_shared_library(env, source, version = ()):
-    source = str(source[0])
+def install(env, source, subdir):
+    target_dir = os.path.join(env.Dir('#.').srcnode().abspath, env['build'], subdir)
+    env.Install(target_dir, source)
+
+def install_program(env, source):
+    install(env, source, 'bin')
+
+def install_shared_library(env, sources, version = ()):
+    install_dir = os.path.join(env.Dir('#.').srcnode().abspath, env['build'])
     version = tuple(map(str, version))
-    target_dir =  os.path.join(env.Dir('#.').srcnode().abspath, env['build'], 'lib')
-    target_name = '.'.join((str(source),) + version)
-    last = env.InstallAs(os.path.join(target_dir, target_name), source)
-    while len(version):
-        version = version[:-1]
-        target_name = '.'.join((str(source),) + version)
-        action = SCons.Action.Action(symlink, "$TARGET -> $SOURCE")
-        last = env.Command(os.path.join(target_dir, target_name), last, action) 
+    if env['SHLIBSUFFIX'] == '.dll':
+        dlls = env.FindIxes(sources, 'SHLIBPREFIX', 'SHLIBSUFFIX')
+        install(env, dlls, 'bin')
+        libs = env.FindIxes(sources, 'LIBPREFIX', 'LIBSUFFIX')
+        install(env, libs, 'lib')
+    else:
+        for source in sources:
+            target_dir =  os.path.join(install_dir, 'lib')
+            target_name = '.'.join((str(source),) + version)
+            last = env.InstallAs(os.path.join(target_dir, target_name), source)
+            while len(version):
+                version = version[:-1]
+                target_name = '.'.join((str(source),) + version)
+                action = SCons.Action.Action(symlink, "$TARGET -> $SOURCE")
+                last = env.Command(os.path.join(target_dir, target_name), last, action) 
 
 def createInstallMethods(env):
+    env.AddMethod(install_program, 'InstallProgram')
     env.AddMethod(install_shared_library, 'InstallSharedLibrary')
 
 
@@ -194,9 +99,6 @@ def num_jobs():
 def generate(env):
     """Common environment generation code"""
 
-    if env.get('quiet', True):
-        quietCommandLines(env)
-
     # Toolchain
     platform = env['platform']
     if env['toolchain'] == 'default':
@@ -236,6 +138,8 @@ def generate(env):
     env['build'] = build_dir
     env.SConsignFile(os.path.join(build_dir, '.sconsign'))
     env.CacheDir('build/cache')
+    env['CONFIGUREDIR'] = os.path.join(build_dir, 'conf')
+    env['CONFIGURELOG'] = os.path.join(os.path.abspath(build_dir), 'config.log')
 
     # Parallel build
     if env.GetOption('num_jobs') <= 1:
@@ -257,13 +161,15 @@ def generate(env):
             #'UNICODE',
             ('_WIN32_WINNT', '0x0501'), # minimum required OS version
             ('WINVER', '0x0501'),
-            # http://msdn2.microsoft.com/en-us/library/6dwk3a1z.aspx,
-            'WIN32_LEAN_AND_MEAN',
         ]
         if msvc and env['toolchain'] != 'winddk':
             cppdefines += [
                 'VC_EXTRALEAN',
+                '_USE_MATH_DEFINES',
+                '_CRT_SECURE_NO_WARNINGS',
                 '_CRT_SECURE_NO_DEPRECATE',
+                '_SCL_SECURE_NO_WARNINGS',
+                '_SCL_SECURE_NO_DEPRECATE',
             ]
         if debug:
             cppdefines += ['_DEBUG']
@@ -343,10 +249,18 @@ def generate(env):
             ccflags += [
                 '-m32',
                 #'-march=pentium4',
-                '-mmmx', '-msse', '-msse2', # enable SIMD intrinsics
-                '-mstackrealign', # ensure stack is aligned -- do not enabled -msse without it!
                 #'-mfpmath=sse',
             ]
+            if platform != 'windows':
+                # XXX: -mstackrealign causes stack corruption on MinGW. Ditto
+                # for -mincoming-stack-boundary=2.  Still enable it on other
+                # platforms for now, but we can't rely on it for cross platform
+                # code. We have to use __attribute__((force_align_arg_pointer))
+                # instead.
+                ccflags += [
+                    '-mmmx', '-msse', '-msse2', # enable SIMD intrinsics
+                    '-mstackrealign', # ensure stack is aligned
+                ]
         if env['machine'] == 'x86_64':
             ccflags += ['-m64']
         # See also:
@@ -354,7 +268,7 @@ def generate(env):
         ccflags += [
             '-Wall',
             '-Wmissing-field-initializers',
-            '-Wpointer-arith',
+            '-Werror=pointer-arith',
             '-Wno-long-long',
             '-ffast-math',
             '-fmessage-length=0', # be nice to Eclipse
@@ -378,20 +292,15 @@ def generate(env):
         else:
             ccflags += [
                 '/O2', # optimize for speed
-                #'/fp:fast', # fast floating point 
-            ]
-        if env['profile']:
-            ccflags += [
-                '/Gh', # enable _penter hook function
-                '/GH', # enable _pexit hook function
+                '/GL', # enable whole program optimization
             ]
         ccflags += [
+            '/fp:fast', # fast floating point 
             '/W3', # warning level
             #'/Wp64', # enable 64 bit porting warnings
         ]
         if env['machine'] == 'x86':
             ccflags += [
-                #'/QIfist', # Suppress _ftol
                 #'/arch:SSE2', # use the SSE2 instructions
             ]
         if platform == 'windows':
@@ -469,6 +378,11 @@ def generate(env):
         ]
         # Handle circular dependencies in the libraries
         env['_LIBFLAGS'] = '-Wl,--start-group ' + env['_LIBFLAGS'] + ' -Wl,--end-group'
+    if msvc:
+        if not env['debug']:
+            # enable Link-time Code Generation
+            linkflags += ['/LTCG']
+            env.Append(ARFLAGS = ['/LTCG'])
     if platform == 'windows' and msvc:
         # See also:
         # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx
@@ -522,8 +436,7 @@ def generate(env):
     env.Append(LIBS = [])
 
     # Custom builders and methods
-    createConvenienceLibBuilder(env)
-    createCodeGenerateMethod(env)
+    env.Tool('custom')
     createInstallMethods(env)
 
     # for debugging
diff --git a/scons/generic.py b/scons/generic.py
deleted file mode 100644 (file)
index a9c2244..0000000
+++ /dev/null
@@ -1,593 +0,0 @@
-"""generic
-
-Generic tool that provides a commmon ground for all platforms.
-
-"""
-
-#
-# 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.
-#
-
-
-import os
-import os.path
-import re
-import platform as _platform
-import sys
-
-import SCons.Action
-import SCons.Builder
-import SCons.Scanner
-
-
-def quietCommandLines(env):
-    # Quiet command lines
-    # See also http://www.scons.org/wiki/HidingCommandLinesInOutput
-    env['CCCOMSTR'] = "Compiling $SOURCE ..."
-    env['CXXCOMSTR'] = "Compiling $SOURCE ..."
-    env['ARCOMSTR'] = "Archiving $TARGET ..."
-    env['RANLIBCOMSTR'] = ""
-    env['LINKCOMSTR'] = "Linking $TARGET ..."
-
-
-def createConvenienceLibBuilder(env):
-    """This is a utility function that creates the ConvenienceLibrary
-    Builder in an Environment if it is not there already.
-
-    If it is already there, we return the existing one.
-
-    Based on the stock StaticLibrary and SharedLibrary builders.
-    """
-
-    try:
-        convenience_lib = env['BUILDERS']['ConvenienceLibrary']
-    except KeyError:
-        action_list = [ SCons.Action.Action("$ARCOM", "$ARCOMSTR") ]
-        if env.Detect('ranlib'):
-            ranlib_action = SCons.Action.Action("$RANLIBCOM", "$RANLIBCOMSTR")
-            action_list.append(ranlib_action)
-
-        convenience_lib = SCons.Builder.Builder(action = action_list,
-                                  emitter = '$LIBEMITTER',
-                                  prefix = '$LIBPREFIX',
-                                  suffix = '$LIBSUFFIX',
-                                  src_suffix = '$SHOBJSUFFIX',
-                                  src_builder = 'SharedObject')
-        env['BUILDERS']['ConvenienceLibrary'] = convenience_lib
-
-    return convenience_lib
-
-
-# TODO: handle import statements with multiple modules
-# TODO: handle from import statements
-import_re = re.compile(r'^import\s+(\S+)$', re.M)
-
-def python_scan(node, env, path):
-    # http://www.scons.org/doc/0.98.5/HTML/scons-user/c2781.html#AEN2789
-    contents = node.get_contents()
-    source_dir = node.get_dir()
-    imports = import_re.findall(contents)
-    results = []
-    for imp in imports:
-        for dir in path:
-            file = os.path.join(str(dir), imp.replace('.', os.sep) + '.py')
-            if os.path.exists(file):
-                results.append(env.File(file))
-                break
-            file = os.path.join(str(dir), imp.replace('.', os.sep), '__init__.py')
-            if os.path.exists(file):
-                results.append(env.File(file))
-                break
-    return results
-
-python_scanner = SCons.Scanner.Scanner(function = python_scan, skeys = ['.py'])
-
-
-def code_generate(env, script, target, source, command):
-    """Method to simplify code generation via python scripts.
-
-    http://www.scons.org/wiki/UsingCodeGenerators
-    http://www.scons.org/doc/0.98.5/HTML/scons-user/c2768.html
-    """
-
-    # We're generating code using Python scripts, so we have to be
-    # careful with our scons elements.  This entry represents
-    # the generator file *in the source directory*.
-    script_src = env.File(script).srcnode()
-
-    # This command creates generated code *in the build directory*.
-    command = command.replace('$SCRIPT', script_src.path)
-    code = env.Command(target, source, command)
-
-    # Explicitly mark that the generated code depends on the generator,
-    # and on implicitly imported python modules
-    path = (script_src.get_dir(),)
-    deps = [script_src]
-    deps += script_src.get_implicit_deps(env, python_scanner, path)
-    env.Depends(code, deps)
-
-    # Running the Python script causes .pyc files to be generated in the
-    # source directory.  When we clean up, they should go too. So add side
-    # effects for .pyc files
-    for dep in deps:
-        pyc = env.File(str(dep) + 'c')
-        env.SideEffect(pyc, code)
-
-    return code
-
-
-def createCodeGenerateMethod(env):
-    env.Append(SCANNERS = python_scanner)
-    env.AddMethod(code_generate, 'CodeGenerate')
-
-
-def symlink(target, source, env):
-    target = str(target[0])
-    source = str(source[0])
-    if os.path.islink(target) or os.path.exists(target):
-        os.remove(target)
-    os.symlink(os.path.basename(source), target)
-
-def install_shared_library(env, source, version = ()):
-    source = str(source[0])
-    version = tuple(map(str, version))
-    target_dir =  os.path.join(env.Dir('#.').srcnode().abspath, env['build'], 'lib')
-    target_name = '.'.join((str(source),) + version)
-    last = env.InstallAs(os.path.join(target_dir, target_name), source)
-    while len(version):
-        version = version[:-1]
-        target_name = '.'.join((str(source),) + version)
-        action = SCons.Action.Action(symlink, "$TARGET -> $SOURCE")
-        last = env.Command(os.path.join(target_dir, target_name), last, action) 
-
-def createInstallMethods(env):
-    env.AddMethod(install_shared_library, 'InstallSharedLibrary')
-
-
-_platform_map = {
-    'linux2': 'linux',
-    'win32': 'windows',
-}
-
-
-_machine_map = {
-       'x86': 'x86',
-       'i386': 'x86',
-       'i486': 'x86',
-       'i586': 'x86',
-       'i686': 'x86',
-       'ppc': 'ppc',
-       'x86_64': 'x86_64',
-}
-
-
-_toolchain_map = {
-    'winddk': 'winddk',
-    'wince': 'wcesdk',
-}
-
-
-_bool_map = {
-    'y': 1, 
-    'yes': 1,
-    't': 1, 
-    'true': 1, 
-    '1': 1,
-    'on': 1,
-    'all': 1, 
-    'n': 0, 
-    'no': 0, 
-    'f': 0, 
-    'false': 0, 
-    '0': 0,
-    'off': 0,
-    'none': 0,
-}
-
-
-def num_jobs():
-    try:
-        return int(os.environ['NUMBER_OF_PROCESSORS'])
-    except (ValueError, KeyError):
-        pass
-
-    try:
-        return os.sysconf('SC_NPROCESSORS_ONLN')
-    except (ValueError, OSError, AttributeError):
-        pass
-
-    try:
-        return int(os.popen2("sysctl -n hw.ncpu")[1].read())
-    except ValueError:
-        pass
-
-    return 1
-
-
-def generate(env):
-    """Common environment generation code"""
-
-    from SCons.Script import ARGUMENTS
-
-    # FIXME: this is already too late
-    #if env.get('quiet', False):
-    #    quietCommandLines(env)
-
-
-    # Platform
-    try:
-        env['platform'] = ARGUMENTS['platform']
-    except KeyError:
-        env['platform'] = _platform_map.get(sys.platform, sys.platform)
-
-    # Machine
-    try:
-        env['machine'] = ARGUMENTS['machine']
-    except KeyError:
-        env['machine'] = _machine_map.get(os.environ.get('PROCESSOR_ARCHITECTURE', _platform.machine()), 'generic')
-
-    # Toolchain
-    try:
-        env['toolchain'] = ARGUMENTS['toolchain']
-    except KeyError:
-        if env['platform'] in ('windows', 'winddk', 'wince') and sys.platform != 'win32':
-            env['toolchain'] = 'crossmingw'
-        else:
-            env['toolchain'] = _toolchain_map.get(env['platform'], 'default')
-    if env['toolchain'] == 'crossmingw' and env['machine'] not in ('generic', 'x86'):
-            env['machine'] = 'x86'
-
-    try:
-        env['MSVS_VERSION'] = ARGUMENTS['MSVS_VERSION']
-    except KeyError:
-        pass
-
-    # Build type
-    env['debug'] = _bool_map[ARGUMENTS.get('debug', 'no')]
-    env['profile'] = _bool_map[ARGUMENTS.get('profile', 'no')]
-
-    # Put build output in a separate dir, which depends on the current
-    # configuration. See also http://www.scons.org/wiki/AdvancedBuildExample
-    try:
-        env['build'] = ARGUMENTS['build']
-    except KeyError:
-        build_topdir = 'build'
-        build_subdir = env['platform']
-        if env['machine'] != 'generic':
-            build_subdir += '-' + env['machine']
-        if env['debug']:
-            build_subdir += "-debug"
-        if env['profile']:
-            build_subdir += "-profile"
-        env['build'] = os.path.join(build_topdir, build_subdir)
-    # Place the .sconsign file in the build dir too, to avoid issues with
-    # different scons versions building the same source file
-    env.SConsignFile(os.path.join(env['build'], '.sconsign'))
-
-    # Parallel build
-    if env.GetOption('num_jobs') <= 1:
-        env.SetOption('num_jobs', num_jobs())
-
-    # Summary
-    print
-    print '  platform=%s' % env['platform']
-    print '  machine=%s' % env['machine']
-    print '  toolchain=%s' % env['toolchain']
-    print '  debug=%s' % ['no', 'yes'][env['debug']]
-    print '  profile=%s' % ['no', 'yes'][env['profile']]
-    print '  build=%s' % env['build']
-    print '  %s jobs' % env.GetOption('num_jobs')
-    print
-
-    # Load tool chain
-    env.Tool(env['toolchain'])
-
-    env['gcc'] = 'gcc' in os.path.basename(env['CC']).split('-')
-    env['msvc'] = env['CC'] == 'cl'
-
-    # shortcuts
-    debug = env['debug']
-    machine = env['machine']
-    platform = env['platform']
-    x86 = env['machine'] == 'x86'
-    ppc = env['machine'] == 'ppc'
-    gcc = env['gcc']
-    msvc = env['msvc']
-
-    # C preprocessor options
-    cppdefines = []
-    if debug:
-        cppdefines += ['DEBUG']
-    else:
-        cppdefines += ['NDEBUG']
-    if env['profile']:
-        cppdefines += ['PROFILE']
-    if platform == 'windows':
-        cppdefines += [
-            'WIN32',
-            '_WINDOWS',
-            #'_UNICODE',
-            #'UNICODE',
-            # http://msdn2.microsoft.com/en-us/library/6dwk3a1z.aspx,
-            #'WIN32_LEAN_AND_MEAN',
-        ]
-        if msvc:
-            cppdefines += [
-                'VC_EXTRALEAN',
-                '_CRT_SECURE_NO_DEPRECATE',
-            ]
-        if debug:
-            cppdefines += ['_DEBUG']
-    if platform == 'winddk':
-        # Mimic WINDDK's builtin flags. See also:
-        # - WINDDK's bin/makefile.new i386mk.inc for more info.
-        # - buildchk_wxp_x86.log files, generated by the WINDDK's build
-        # - http://alter.org.ua/docs/nt_kernel/vc8_proj/
-        cppdefines += [
-            ('_X86_', '1'),
-            ('i386', '1'),
-            'STD_CALL',
-            ('CONDITION_HANDLING', '1'),
-            ('NT_INST', '0'),
-            ('WIN32', '100'),
-            ('_NT1X_', '100'),
-            ('WINNT', '1'),
-            ('_WIN32_WINNT', '0x0501'), # minimum required OS version
-            ('WINVER', '0x0501'),
-            ('_WIN32_IE', '0x0603'),
-            ('WIN32_LEAN_AND_MEAN', '1'),
-            ('DEVL', '1'),
-            ('__BUILDMACHINE__', 'WinDDK'),
-            ('FPO', '0'),
-        ]
-        if debug:
-            cppdefines += [('DBG', 1)]
-    if platform == 'wince':
-        cppdefines += [
-            '_CRT_SECURE_NO_DEPRECATE',
-            '_USE_32BIT_TIME_T',
-            'UNICODE',
-            '_UNICODE',
-            ('UNDER_CE', '600'),
-            ('_WIN32_WCE', '0x600'),
-            'WINCEOEM',
-            'WINCEINTERNAL',
-            'WIN32',
-            'STRICT',
-            'x86',
-            '_X86_',
-            'INTERNATIONAL',
-            ('INTLMSG_CODEPAGE', '1252'),
-        ]
-    env.Append(CPPDEFINES = cppdefines)
-
-    # C preprocessor includes
-    if platform == 'winddk':
-        env.Append(CPPPATH = [
-            env['SDK_INC_PATH'],
-            env['DDK_INC_PATH'],
-            env['WDM_INC_PATH'],
-            env['CRT_INC_PATH'],
-        ])
-
-    # C compiler options
-    cflags = [] # C
-    cxxflags = [] # C++
-    ccflags = [] # C & C++
-    if gcc:
-        if debug:
-            ccflags += ['-O0', '-g3']
-        elif env['toolchain'] == 'crossmingw':
-            ccflags += ['-O0', '-g3'] # mingw 4.2.1 optimizer is broken
-        else:
-            ccflags += ['-O3', '-g0']
-        if env['profile']:
-            ccflags += ['-pg']
-        if env['machine'] == 'x86':
-            ccflags += [
-                '-m32',
-                #'-march=pentium4',
-                '-mmmx', '-msse', '-msse2', # enable SIMD intrinsics
-                #'-mfpmath=sse',
-            ]
-        if env['machine'] == 'x86_64':
-            ccflags += ['-m64']
-        # See also:
-        # - http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
-        ccflags += [
-            '-Wall',
-            '-Wmissing-field-initializers',
-            '-Wpointer-arith',
-            '-Wno-long-long',
-            '-ffast-math',
-            '-fmessage-length=0', # be nice to Eclipse
-        ]
-        cflags += [
-            '-Werror=declaration-after-statement',
-            '-Wmissing-prototypes',
-            '-std=gnu99',
-        ]
-    if msvc:
-        # See also:
-        # - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx
-        # - cl /?
-        if debug:
-            ccflags += [
-              '/Od', # disable optimizations
-              '/Oi', # enable intrinsic functions
-              '/Oy-', # disable frame pointer omission
-              '/GL-', # disable whole program optimization
-            ]
-        else:
-            ccflags += [
-              '/Ox', # maximum optimizations
-              '/Oi', # enable intrinsic functions
-              '/Ot', # favor code speed
-              #'/fp:fast', # fast floating point 
-            ]
-        if env['profile']:
-            ccflags += [
-                '/Gh', # enable _penter hook function
-                '/GH', # enable _pexit hook function
-            ]
-        ccflags += [
-            '/W3', # warning level
-            #'/Wp64', # enable 64 bit porting warnings
-        ]
-        if env['machine'] == 'x86':
-            ccflags += [
-                #'/QIfist', # Suppress _ftol
-                #'/arch:SSE2', # use the SSE2 instructions
-            ]
-        if platform == 'windows':
-            ccflags += [
-                # TODO
-            ]
-        if platform == 'winddk':
-            ccflags += [
-                '/Zl', # omit default library name in .OBJ
-                '/Zp8', # 8bytes struct member alignment
-                '/Gy', # separate functions for linker
-                '/Gm-', # disable minimal rebuild
-                '/WX', # treat warnings as errors
-                '/Gz', # __stdcall Calling convention
-                '/GX-', # disable C++ EH
-                '/GR-', # disable C++ RTTI
-                '/GF', # enable read-only string pooling
-                '/G6', # optimize for PPro, P-II, P-III
-                '/Ze', # enable extensions
-                '/Gi-', # disable incremental compilation
-                '/QIfdiv-', # disable Pentium FDIV fix
-                '/hotpatch', # prepares an image for hotpatching.
-                #'/Z7', #enable old-style debug info
-            ]
-        if platform == 'wince':
-            # See also C:\WINCE600\public\common\oak\misc\makefile.def
-            ccflags += [
-                '/Zl', # omit default library name in .OBJ
-                '/GF', # enable read-only string pooling
-                '/GR-', # disable C++ RTTI
-                '/GS', # enable security checks
-                # Allow disabling language conformance to maintain backward compat
-                #'/Zc:wchar_t-', # don't force wchar_t as native type, instead of typedef
-                #'/Zc:forScope-', # don't enforce Standard C++ for scoping rules
-                #'/wd4867',
-                #'/wd4430',
-                #'/MT',
-                #'/U_MT',
-            ]
-        # Automatic pdb generation
-        # See http://scons.tigris.org/issues/show_bug.cgi?id=1656
-        env.EnsureSConsVersion(0, 98, 0)
-        env['PDB'] = '${TARGET.base}.pdb'
-    env.Append(CCFLAGS = ccflags)
-    env.Append(CFLAGS = cflags)
-    env.Append(CXXFLAGS = cxxflags)
-
-    if env['platform'] == 'windows' and msvc:
-        # Choose the appropriate MSVC CRT
-        # http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
-        if env['debug']:
-            env.Append(CCFLAGS = ['/MTd'])
-            env.Append(SHCCFLAGS = ['/LDd'])
-        else:
-            env.Append(CCFLAGS = ['/MT'])
-            env.Append(SHCCFLAGS = ['/LD'])
-    
-    # Assembler options
-    if gcc:
-        if env['machine'] == 'x86':
-            env.Append(ASFLAGS = ['-m32'])
-        if env['machine'] == 'x86_64':
-            env.Append(ASFLAGS = ['-m64'])
-
-    # Linker options
-    linkflags = []
-    if gcc:
-        if env['machine'] == 'x86':
-            linkflags += ['-m32']
-        if env['machine'] == 'x86_64':
-            linkflags += ['-m64']
-    if platform == 'windows' and msvc:
-        # See also:
-        # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx
-        linkflags += [
-            '/fixed:no',
-            '/incremental:no',
-        ]
-    if platform == 'winddk':
-        linkflags += [
-            '/merge:_PAGE=PAGE',
-            '/merge:_TEXT=.text',
-            '/section:INIT,d',
-            '/opt:ref',
-            '/opt:icf',
-            '/ignore:4198,4010,4037,4039,4065,4070,4078,4087,4089,4221',
-            '/incremental:no',
-            '/fullbuild',
-            '/release',
-            '/nodefaultlib',
-            '/wx',
-            '/debug',
-            '/debugtype:cv',
-            '/version:5.1',
-            '/osversion:5.1',
-            '/functionpadmin:5',
-            '/safeseh',
-            '/pdbcompress',
-            '/stack:0x40000,0x1000',
-            '/driver',
-            '/align:0x80',
-            '/subsystem:native,5.01',
-            '/base:0x10000',
-
-            '/entry:DrvEnableDriver',
-        ]
-        if env['debug'] or env['profile']:
-            linkflags += [
-                '/MAP', # http://msdn.microsoft.com/en-us/library/k7xkk3e2.aspx
-            ]
-    if platform == 'wince':
-        linkflags += [
-            '/nodefaultlib',
-            #'/incremental:no',
-            #'/fullbuild',
-            '/entry:_DllMainCRTStartup',
-        ]
-    env.Append(LINKFLAGS = linkflags)
-
-    # Default libs
-    env.Append(LIBS = [])
-
-    # Custom builders and methods
-    createConvenienceLibBuilder(env)
-    createCodeGenerateMethod(env)
-    createInstallMethods(env)
-
-    # for debugging
-    #print env.Dump()
-
-
-def exists(env):
-    return 1
index d3293bb404fedc514239ec1533ad9e8466941e89..7b266502907fd47be168038d1d8a8f717a7ebe0d 100644 (file)
@@ -29,6 +29,7 @@ Tool-specific initialization for LLVM
 
 import os
 import os.path
+import sys
 
 import SCons.Errors
 import SCons.Util
@@ -39,7 +40,7 @@ def generate(env):
         llvm_dir = os.environ['LLVM']
     except KeyError:
         # Do nothing -- use the system headers/libs
-        pass
+        llvm_dir = None
     else:
         if not os.path.isdir(llvm_dir):
             raise SCons.Errors.InternalError, "Specified LLVM directory not found"
@@ -57,7 +58,49 @@ def generate(env):
 
         env.PrependENVPath('PATH', llvm_bin_dir)
 
-    if env.Detect('llvm-config'):
+    if env['platform'] == 'windows':
+        # XXX: There is no llvm-config on Windows, so assume a standard layout
+        if llvm_dir is not None:
+            env.Prepend(CPPPATH = [os.path.join(llvm_dir, 'include')])
+            env.AppendUnique(CPPDEFINES = [
+                '__STDC_LIMIT_MACROS', 
+                '__STDC_CONSTANT_MACROS',
+            ])
+            env.Prepend(LIBPATH = [os.path.join(llvm_dir, 'lib')])
+            env.Prepend(LIBS = [
+                'LLVMX86AsmParser',
+                'LLVMX86AsmPrinter',
+                'LLVMX86CodeGen',
+                'LLVMX86Info',
+                'LLVMLinker',
+                'LLVMipo',
+                'LLVMInterpreter',
+                'LLVMInstrumentation',
+                'LLVMJIT',
+                'LLVMExecutionEngine',
+                'LLVMDebugger',
+                'LLVMBitWriter',
+                'LLVMAsmParser',
+                'LLVMArchive',
+                'LLVMBitReader',
+                'LLVMSelectionDAG',
+                'LLVMAsmPrinter',
+                'LLVMCodeGen',
+                'LLVMScalarOpts',
+                'LLVMTransformUtils',
+                'LLVMipa',
+                'LLVMAnalysis',
+                'LLVMTarget',
+                'LLVMMC',
+                'LLVMCore',
+                'LLVMSupport',
+                'LLVMSystem',
+                'imagehlp',
+                'psapi',
+            ])
+            env['LLVM_VERSION'] = '2.6'
+        return
+    elif env.Detect('llvm-config'):
         version = env.backtick('llvm-config --version').rstrip()
 
         try:
index 50d47ee37bd95a7ee59d9517633794e65cf855e1..bdc0dd9251170f318cdeed27aa76b7b8e52f1506 100644 (file)
@@ -7,7 +7,7 @@ Based on SCons.Tool.mslib, without the MSVC detection.
 """
 
 #
-# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 The SCons Foundation
+# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons Foundation
 #
 # Permission is hereby granted, free of charge, to any person obtaining
 # a copy of this software and associated documentation files (the
@@ -130,4 +130,8 @@ def generate(env):
 def exists(env):
     return env.Detect('lib') or env.Detect('link')
 
-# vim:set ts=4 sw=4 et:
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
index 53331def1aaa123b8cf1960b5c1ccc16baf9c8c3..0ecdf24a92942bbc40c80089c5a3e2a4539530c9 100644 (file)
@@ -7,7 +7,7 @@ Based on SCons.Tool.mslink, without the MSVS detection.
 """
 
 #
-# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 The SCons Foundation
+# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons Foundation
 #
 # Permission is hereby granted, free of charge, to any person obtaining
 # a copy of this software and associated documentation files (the
@@ -45,9 +45,9 @@ def pdbGenerator(env, target, source, for_signature):
     except (AttributeError, IndexError):
         return None
 
-def windowsShlinkTargets(target, source, env, for_signature):
+def _dllTargets(target, source, env, for_signature, paramtp):
     listCmd = []
-    dll = env.FindIxes(target, 'SHLIBPREFIX', 'SHLIBSUFFIX')
+    dll = env.FindIxes(target, '%sPREFIX' % paramtp, '%sSUFFIX' % paramtp)
     if dll: listCmd.append("/out:%s"%dll.get_string(for_signature))
 
     implib = env.FindIxes(target, 'LIBPREFIX', 'LIBSUFFIX')
@@ -55,12 +55,15 @@ def windowsShlinkTargets(target, source, env, for_signature):
 
     return listCmd
 
-def windowsShlinkSources(target, source, env, for_signature):
+def _dllSources(target, source, env, for_signature, paramtp):
     listCmd = []
 
     deffile = env.FindIxes(source, "WINDOWSDEFPREFIX", "WINDOWSDEFSUFFIX")
     for src in source:
-        if src == deffile:
+        # Check explicitly for a non-None deffile so that the __cmp__
+        # method of the base SCons.Util.Proxy class used for some Node
+        # proxies doesn't try to use a non-existent __dict__ attribute.
+        if deffile and src == deffile:
             # Treat this source as a .def file.
             listCmd.append("/def:%s" % src.get_string(for_signature))
         else:
@@ -68,17 +71,32 @@ def windowsShlinkSources(target, source, env, for_signature):
             listCmd.append(src)
     return listCmd
 
-def windowsLibEmitter(target, source, env):
+def windowsShlinkTargets(target, source, env, for_signature):
+    return _dllTargets(target, source, env, for_signature, 'SHLIB')
+
+def windowsShlinkSources(target, source, env, for_signature):
+    return _dllSources(target, source, env, for_signature, 'SHLIB')
+
+def _windowsLdmodTargets(target, source, env, for_signature):
+    """Get targets for loadable modules."""
+    return _dllTargets(target, source, env, for_signature, 'LDMODULE')
+
+def _windowsLdmodSources(target, source, env, for_signature):
+    """Get sources for loadable modules."""
+    return _dllSources(target, source, env, for_signature, 'LDMODULE')
+
+def _dllEmitter(target, source, env, paramtp):
+    """Common implementation of dll emitter."""
     SCons.Tool.msvc.validate_vars(env)
 
     extratargets = []
     extrasources = []
 
-    dll = env.FindIxes(target, "SHLIBPREFIX", "SHLIBSUFFIX")
+    dll = env.FindIxes(target, '%sPREFIX' % paramtp, '%sSUFFIX' % paramtp)
     no_import_lib = env.get('no_import_lib', 0)
 
     if not dll:
-        raise SCons.Errors.UserError, "A shared library should have exactly one target with the suffix: %s" % env.subst("$SHLIBSUFFIX")
+        raise SCons.Errors.UserError, 'A shared library should have exactly one target with the suffix: %s' % env.subst('$%sSUFFIX' % paramtp)
 
     insert_def = env.subst("$WINDOWS_INSERT_DEF")
     if not insert_def in ['', '0', 0] and \
@@ -87,7 +105,7 @@ def windowsLibEmitter(target, source, env):
         # append a def file to the list of sources
         extrasources.append(
             env.ReplaceIxes(dll,
-                            "SHLIBPREFIX", "SHLIBSUFFIX",
+                            '%sPREFIX' % paramtp, '%sSUFFIX' % paramtp,
                             "WINDOWSDEFPREFIX", "WINDOWSDEFSUFFIX"))
 
     if env.has_key('PDB') and env['PDB']:
@@ -100,16 +118,27 @@ def windowsLibEmitter(target, source, env):
         # Append an import library to the list of targets.
         extratargets.append(
             env.ReplaceIxes(dll,
-                            "SHLIBPREFIX", "SHLIBSUFFIX",
+                            '%sPREFIX' % paramtp, '%sSUFFIX' % paramtp,
                             "LIBPREFIX", "LIBSUFFIX"))
         # and .exp file is created if there are exports from a DLL
         extratargets.append(
             env.ReplaceIxes(dll,
-                            "SHLIBPREFIX", "SHLIBSUFFIX",
+                            '%sPREFIX' % paramtp, '%sSUFFIX' % paramtp,
                             "WINDOWSEXPPREFIX", "WINDOWSEXPSUFFIX"))
 
     return (target+extratargets, source+extrasources)
 
+def windowsLibEmitter(target, source, env):
+    return _dllEmitter(target, source, env, 'SHLIB')
+
+def ldmodEmitter(target, source, env):
+    """Emitter for loadable modules.
+    
+    Loadable modules are identical to shared libraries on Windows, but building
+    them is subject to different parameters (LDMODULE*).
+    """
+    return _dllEmitter(target, source, env, 'LDMODULE')
+
 def prog_emitter(target, source, env):
     SCons.Tool.msvc.validate_vars(env)
 
@@ -138,8 +167,10 @@ def RegServerFunc(target, source, env):
 
 regServerAction = SCons.Action.Action("$REGSVRCOM", "$REGSVRCOMSTR")
 regServerCheck = SCons.Action.Action(RegServerFunc, None)
-shlibLinkAction = SCons.Action.Action('${TEMPFILE("$SHLINK $SHLINKFLAGS $_SHLINK_TARGETS $( $_LIBDIRFLAGS $) $_LIBFLAGS $_PDB $_SHLINK_SOURCES")}')
-compositeLinkAction = shlibLinkAction + regServerCheck
+shlibLinkAction = SCons.Action.Action('${TEMPFILE("$SHLINK $SHLINKFLAGS $_SHLINK_TARGETS $_LIBDIRFLAGS $_LIBFLAGS $_PDB $_SHLINK_SOURCES")}')
+compositeShLinkAction = shlibLinkAction + regServerCheck
+ldmodLinkAction = SCons.Action.Action('${TEMPFILE("$LDMODULE $LDMODULEFLAGS $_LDMODULE_TARGETS $_LIBDIRFLAGS $_LIBFLAGS $_PDB $_LDMODULE_SOURCES")}')
+compositeLdmodAction = ldmodLinkAction + regServerCheck
 
 def generate(env):
     """Add Builders and construction variables for ar to an Environment."""
@@ -150,12 +181,12 @@ def generate(env):
     env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS /dll')
     env['_SHLINK_TARGETS'] = windowsShlinkTargets
     env['_SHLINK_SOURCES'] = windowsShlinkSources
-    env['SHLINKCOM']   =  compositeLinkAction
+    env['SHLINKCOM']   =  compositeShLinkAction
     env.Append(SHLIBEMITTER = [windowsLibEmitter])
     env['LINK']        = 'link'
     env['LINKFLAGS']   = SCons.Util.CLVar('/nologo')
     env['_PDB'] = pdbGenerator
-    env['LINKCOM'] = '${TEMPFILE("$LINK $LINKFLAGS /OUT:$TARGET.windows $( $_LIBDIRFLAGS $) $_LIBFLAGS $_PDB $SOURCES.windows")}'
+    env['LINKCOM'] = '${TEMPFILE("$LINK $LINKFLAGS /OUT:$TARGET.windows $_LIBDIRFLAGS $_LIBFLAGS $_PDB $SOURCES.windows")}'
     env.Append(PROGEMITTER = [prog_emitter])
     env['LIBDIRPREFIX']='/LIBPATH:'
     env['LIBDIRSUFFIX']=''
@@ -184,19 +215,19 @@ def generate(env):
     env['REGSVRFLAGS'] = '/s '
     env['REGSVRCOM'] = '$REGSVR $REGSVRFLAGS ${TARGET.windows}'
 
-    # For most platforms, a loadable module is the same as a shared
-    # library.  Platforms which are different can override these, but
-    # setting them the same means that LoadableModule works everywhere.
+    # Loadable modules are on Windows the same as shared libraries, but they
+    # are subject to different build parameters (LDMODULE* variables).
+    # Therefore LDMODULE* variables correspond as much as possible to
+    # SHLINK*/SHLIB* ones.
     SCons.Tool.createLoadableModuleBuilder(env)
     env['LDMODULE'] = '$SHLINK'
     env['LDMODULEPREFIX'] = '$SHLIBPREFIX'
     env['LDMODULESUFFIX'] = '$SHLIBSUFFIX'
     env['LDMODULEFLAGS'] = '$SHLINKFLAGS'
-    # We can't use '$SHLINKCOM' here because that will stringify the
-    # action list on expansion, and will then try to execute expanded
-    # strings, with the upshot that it would try to execute RegServerFunc
-    # as a command.
-    env['LDMODULECOM'] = compositeLinkAction
+    env['_LDMODULE_TARGETS'] = _windowsLdmodTargets
+    env['_LDMODULE_SOURCES'] = _windowsLdmodSources
+    env['LDMODULEEMITTER'] = [ldmodEmitter]
+    env['LDMODULECOM'] = compositeLdmodAction
 
 def exists(env):
     platform = env.get('PLATFORM', '')
@@ -208,4 +239,8 @@ def exists(env):
         return env.Detect('link')
     return None
 
-# vim:set ts=4 sw=4 et:
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
index 136d3052656e7dccdb447feb36280d8dc3a23ce5..a91366292033865321aef4def4a4ea86235f153d 100644 (file)
@@ -7,7 +7,7 @@ Based on SCons.Tool.msvc, without the MSVS detection.
 """
 
 #
-# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 The SCons Foundation
+# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons Foundation
 #
 # Permission is hereby granted, free of charge, to any person obtaining
 # a copy of this software and associated documentation files (the
@@ -40,6 +40,7 @@ import SCons.Platform.win32
 import SCons.Tool
 import SCons.Util
 import SCons.Warnings
+import SCons.Scanner.RC
 
 CSuffixes = ['.c', '.C']
 CXXSuffixes = ['.cc', '.cpp', '.cxx', '.c++', '.C++']
@@ -97,47 +98,114 @@ pch_action = SCons.Action.Action('$PCHCOM', '$PCHCOMSTR')
 pch_builder = SCons.Builder.Builder(action=pch_action, suffix='.pch',
                                     emitter=pch_emitter,
                                     source_scanner=SCons.Tool.SourceFileScanner)
+
+
+# Logic to build .rc files into .res files (resource files)
+res_scanner = SCons.Scanner.RC.RCScan()
 res_action = SCons.Action.Action('$RCCOM', '$RCCOMSTR')
 res_builder = SCons.Builder.Builder(action=res_action,
                                     src_suffix='.rc',
                                     suffix='.res',
                                     src_builder=[],
-                                    source_scanner=SCons.Tool.SourceFileScanner)
-SCons.Tool.SourceFileScanner.add_scanner('.rc', SCons.Defaults.CScan)
+                                    source_scanner=res_scanner)
+
+def msvc_batch_key(action, env, target, source):
+    """
+    Returns a key to identify unique batches of sources for compilation.
+
+    If batching is enabled (via the $MSVC_BATCH setting), then all
+    target+source pairs that use the same action, defined by the same
+    environment, and have the same target and source directories, will
+    be batched.
+
+    Returning None specifies that the specified target+source should not
+    be batched with other compilations.
+    """
+    b = env.subst('$MSVC_BATCH')
+    if b in (None, '', '0'):
+        # We're not using batching; return no key.
+        return None
+    t = target[0]
+    s = source[0]
+    if os.path.splitext(t.name)[0] != os.path.splitext(s.name)[0]:
+        # The base names are different, so this *must* be compiled
+        # separately; return no key.
+        return None
+    return (id(action), id(env), t.dir, s.dir)
+
+def msvc_output_flag(target, source, env, for_signature):
+    """
+    Returns the correct /Fo flag for batching.
+
+    If batching is disabled or there's only one source file, then we
+    return an /Fo string that specifies the target explicitly.  Otherwise,
+    we return an /Fo string that just specifies the first target's
+    directory (where the Visual C/C++ compiler will put the .obj files).
+    """
+    b = env.subst('$MSVC_BATCH')
+    if b in (None, '', '0') or len(source) == 1:
+        return '/Fo$TARGET'
+    else:
+        # The Visual C/C++ compiler requires a \ at the end of the /Fo
+        # option to indicate an output directory.  We use os.sep here so
+        # that the test(s) for this can be run on non-Windows systems
+        # without having a hard-coded backslash mess up command-line
+        # argument parsing.
+        return '/Fo${TARGET.dir}' + os.sep
+
+CAction = SCons.Action.Action("$CCCOM", "$CCCOMSTR",
+                              batch_key=msvc_batch_key,
+                              targets='$CHANGED_TARGETS')
+ShCAction = SCons.Action.Action("$SHCCCOM", "$SHCCCOMSTR",
+                                batch_key=msvc_batch_key,
+                                targets='$CHANGED_TARGETS')
+CXXAction = SCons.Action.Action("$CXXCOM", "$CXXCOMSTR",
+                                batch_key=msvc_batch_key,
+                                targets='$CHANGED_TARGETS')
+ShCXXAction = SCons.Action.Action("$SHCXXCOM", "$SHCXXCOMSTR",
+                                  batch_key=msvc_batch_key,
+                                  targets='$CHANGED_TARGETS')
 
 def generate(env):
     """Add Builders and construction variables for MSVC++ to an Environment."""
     static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
 
+    # TODO(batch):  shouldn't reach in to cmdgen this way; necessary
+    # for now to bypass the checks in Builder.DictCmdGenerator.__call__()
+    # and allow .cc and .cpp to be compiled in the same command line.
+    static_obj.cmdgen.source_ext_match = False
+    shared_obj.cmdgen.source_ext_match = False
+
     for suffix in CSuffixes:
-        static_obj.add_action(suffix, SCons.Defaults.CAction)
-        shared_obj.add_action(suffix, SCons.Defaults.ShCAction)
+        static_obj.add_action(suffix, CAction)
+        shared_obj.add_action(suffix, ShCAction)
         static_obj.add_emitter(suffix, static_object_emitter)
         shared_obj.add_emitter(suffix, shared_object_emitter)
 
     for suffix in CXXSuffixes:
-        static_obj.add_action(suffix, SCons.Defaults.CXXAction)
-        shared_obj.add_action(suffix, SCons.Defaults.ShCXXAction)
+        static_obj.add_action(suffix, CXXAction)
+        shared_obj.add_action(suffix, ShCXXAction)
         static_obj.add_emitter(suffix, static_object_emitter)
         shared_obj.add_emitter(suffix, shared_object_emitter)
 
     env['CCPDBFLAGS'] = SCons.Util.CLVar(['${(PDB and "/Z7") or ""}'])
     env['CCPCHFLAGS'] = SCons.Util.CLVar(['${(PCH and "/Yu%s /Fp%s"%(PCHSTOP or "",File(PCH))) or ""}'])
-    env['CCCOMFLAGS'] = '$CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS /c $SOURCES /Fo$TARGET $CCPCHFLAGS $CCPDBFLAGS'
+    env['_MSVC_OUTPUT_FLAG'] = msvc_output_flag
+    env['_CCCOMCOM']  = '$CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS $CCPCHFLAGS $CCPDBFLAGS'
     env['CC']         = 'cl'
     env['CCFLAGS']    = SCons.Util.CLVar('/nologo')
     env['CFLAGS']     = SCons.Util.CLVar('')
-    env['CCCOM']      = '$CC $CFLAGS $CCFLAGS $CCCOMFLAGS'
+    env['CCCOM']      = '$CC $_MSVC_OUTPUT_FLAG /c $CHANGED_SOURCES $CFLAGS $CCFLAGS $_CCCOMCOM'
     env['SHCC']       = '$CC'
     env['SHCCFLAGS']  = SCons.Util.CLVar('$CCFLAGS')
     env['SHCFLAGS']   = SCons.Util.CLVar('$CFLAGS')
-    env['SHCCCOM']    = '$SHCC $SHCFLAGS $SHCCFLAGS $CCCOMFLAGS'
+    env['SHCCCOM']    = '$SHCC $_MSVC_OUTPUT_FLAG /c $CHANGED_SOURCES $SHCFLAGS $SHCCFLAGS $_CCCOMCOM'
     env['CXX']        = '$CC'
-    env['CXXFLAGS']   = SCons.Util.CLVar('$CCFLAGS $( /TP $)')
-    env['CXXCOM']     = '$CXX $CXXFLAGS $CCCOMFLAGS'
+    env['CXXFLAGS']   = SCons.Util.CLVar('$( /TP $)')
+    env['CXXCOM']     = '$CXX $_MSVC_OUTPUT_FLAG /c $CHANGED_SOURCES $CXXFLAGS $CCFLAGS $_CCCOMCOM'
     env['SHCXX']      = '$CXX'
     env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS')
-    env['SHCXXCOM']   = '$SHCXX $SHCXXFLAGS $CCCOMFLAGS'
+    env['SHCXXCOM']   = '$SHCXX $_MSVC_OUTPUT_FLAG /c $CHANGED_SOURCES $SHCXXFLAGS $SHCCFLAGS $_CCCOMCOM'
     env['CPPDEFPREFIX']  = '/D'
     env['CPPDEFSUFFIX']  = ''
     env['INCPREFIX']  = '/I'
@@ -148,6 +216,7 @@ def generate(env):
 
     env['RC'] = 'rc'
     env['RCFLAGS'] = SCons.Util.CLVar('')
+    env['RCSUFFIXES']=['.rc','.rc2']
     env['RCCOM'] = '$RC $_CPPDEFFLAGS $_CPPINCFLAGS $RCFLAGS /fo$TARGET $SOURCES'
     env['BUILDERS']['RES'] = res_builder
     env['OBJPREFIX']      = ''
@@ -159,7 +228,7 @@ def generate(env):
     env['CXXFILESUFFIX'] = '.cc'
 
     env['PCHPDBFLAGS'] = SCons.Util.CLVar(['${(PDB and "/Yd") or ""}'])
-    env['PCHCOM'] = '$CXX $CXXFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS /c $SOURCES /Fo${TARGETS[1]} /Yc$PCHSTOP /Fp${TARGETS[0]} $CCPDBFLAGS $PCHPDBFLAGS'
+    env['PCHCOM'] = '$CXX /Fo${TARGETS[1]} $CXXFLAGS $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS /c $SOURCES /Yc$PCHSTOP /Fp${TARGETS[0]} $CCPDBFLAGS $PCHPDBFLAGS'
     env['BUILDERS']['PCH'] = pch_builder
 
     if not env.has_key('ENV'):
@@ -170,4 +239,8 @@ def generate(env):
 def exists(env):
     return env.Detect('cl')
 
-# vim:set ts=4 sw=4 et:
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
index 5440acd1351f57de3064b6890346f456d2fcf49f..6083fcbec98cc903930696e7a5572eedf0067f19 100644 (file)
@@ -1,5 +1,6 @@
 Import('*')
 
+SConscript('glsl/SConscript')
 SConscript('gallium/SConscript')
 
 if 'mesa' in env['statetrackers']:
index 9e400be6248b805b0f445703a88953eb79cc3b00..ca6821dad069ee55d558c2724c9d079018833960 100644 (file)
@@ -675,13 +675,13 @@ __eglCreateContextWithConfig(__DRInativeDisplay* ndpy, int screen,
                              drm_context_t * hHWContext)
 {
     __DRIscreen *pDRIScreen;
-    __DRIscreenPrivate *psp;
+    __DRIscreen *psp;
 
     pDRIScreen = __eglFindDRIScreen(ndpy, screen);
     if ( (pDRIScreen == NULL) || (pDRIScreen->private == NULL) ) {
         return GL_FALSE;
     }
-    psp = (__DRIscreenPrivate *) pDRIScreen->private;
+    psp = (__DRIscreen *) pDRIScreen->private;
     if (psp->fd) {
         if (drmCreateContext(psp->fd, hHWContext)) {
             _eglLog(_EGL_WARNING, "drmCreateContext failed.");
@@ -691,14 +691,14 @@ __eglCreateContextWithConfig(__DRInativeDisplay* ndpy, int screen,
     }
 #if 0
     __DRIscreen *pDRIScreen;
-    __DRIscreenPrivate *psp;
+    __DRIscreen *psp;
 
     pDRIScreen = __glXFindDRIScreen(dpy, screen);
     if ( (pDRIScreen == NULL) || (pDRIScreen->private == NULL) ) {
         return GL_FALSE;
     }
 
-    psp = (__DRIscreenPrivate *) pDRIScreen->private;
+    psp = (__DRIscreen *) pDRIScreen->private;
 
     if (psp->fd) {
         if (drmCreateContext(psp->fd, hHWContext)) {
@@ -716,13 +716,13 @@ static GLboolean
 __eglDestroyContext( __DRInativeDisplay * ndpy, int screen,  __DRIid context )
 {
     __DRIscreen *pDRIScreen;
-    __DRIscreenPrivate *psp;
+    __DRIscreen *psp;
 
     pDRIScreen = __eglFindDRIScreen(ndpy, screen);
     if ( (pDRIScreen == NULL) || (pDRIScreen->private == NULL) ) {
         return GL_FALSE;
     }
-    psp = (__DRIscreenPrivate *) pDRIScreen->private;
+    psp = (__DRIscreen *) pDRIScreen->private;
     if (psp->fd)
       drmDestroyContext(psp->fd, context);
 
@@ -735,13 +735,13 @@ __eglCreateDrawable(__DRInativeDisplay * ndpy, int screen,
                     __DRIid drawable, drm_drawable_t * hHWDrawable)
 {
     __DRIscreen *pDRIScreen;
-    __DRIscreenPrivate *psp;
+    __DRIscreen *psp;
 
     pDRIScreen = __eglFindDRIScreen(ndpy, screen);
     if ( (pDRIScreen == NULL) || (pDRIScreen->private == NULL) ) {
         return GL_FALSE;
     }
-    psp = (__DRIscreenPrivate *) pDRIScreen->private;
+    psp = (__DRIscreen *) pDRIScreen->private;
     if (psp->fd) {
         if (drmCreateDrawable(psp->fd, hHWDrawable)) {
             _eglLog(_EGL_WARNING, "drmCreateDrawable failed.");
@@ -756,13 +756,13 @@ static GLboolean
 __eglDestroyDrawable( __DRInativeDisplay * ndpy, int screen, __DRIid drawable )
 {
     __DRIscreen *pDRIScreen;
-    __DRIscreenPrivate *psp;
+    __DRIscreen *psp;
 
     pDRIScreen = __eglFindDRIScreen(ndpy, screen);
     if ( (pDRIScreen == NULL) || (pDRIScreen->private == NULL) ) {
         return GL_FALSE;
     }
-    psp = (__DRIscreenPrivate *) pDRIScreen->private;
+    psp = (__DRIscreen *) pDRIScreen->private;
     if (psp->fd)
       drmDestroyDrawable(psp->fd, drawable);
 
@@ -778,7 +778,7 @@ __eglGetDrawableInfo(__DRInativeDisplay * ndpy, int screen, __DRIid drawable,
                      int* numBackClipRects, drm_clip_rect_t ** pBackClipRects )
 {
     __DRIscreen *pDRIScreen;
-    __DRIscreenPrivate *psp;
+    __DRIscreen *psp;
     driSurface *surf = Lookup_driSurface((EGLSurface) drawable);
 
    pDRIScreen = __eglFindDRIScreen(ndpy, screen);
@@ -786,7 +786,7 @@ __eglGetDrawableInfo(__DRInativeDisplay * ndpy, int screen, __DRIid drawable,
    if ( (pDRIScreen == NULL) || (pDRIScreen->private == NULL) ) {
        return GL_FALSE;
    }
-   psp = (__DRIscreenPrivate *) pDRIScreen->private;
+   psp = (__DRIscreen *) pDRIScreen->private;
    *X = 0;
    *Y = 0;
    *W = surf->Base.Width;
@@ -807,7 +807,7 @@ __eglGetDrawableInfo(__DRInativeDisplay * ndpy, int screen, __DRIid drawable,
     GLXDrawable drawable = (GLXDrawable) draw;
     drm_clip_rect_t * cliprect;
     Display* display = (Display*)dpy;
-    __DRIcontextPrivate *pcp = (__DRIcontextPrivate *)CurrentContext->driContext.private;
+    __DRIcontext *pcp = (__DRIcontext *)CurrentContext->driContext.private;
     if (drawable == 0) {
         return GL_FALSE;
     }
index 4685f600e29d7eeaf4b810c96fe4cc2ecd7842a8..96292b0e9e867f8479980a32c01777d495ee9f8c 100644 (file)
  * Authors: Alan Hourihane <alanh@tungstengraphics.com>
  */
 
-/*
- * TODO: 
- *
- * test eglBind/ReleaseTexImage
- */
-
-
-#include <assert.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include "dlfcn.h"
+#include <stdlib.h>
+#include <string.h>
 #include <X11/Xlib.h>
-#include <GL/gl.h>
-#include "glxclient.h"
+#include <GL/glx.h>
 
+#include "eglconfigutil.h"
 #include "eglconfig.h"
 #include "eglcontext.h"
 #include "egldisplay.h"
 #include "egllog.h"
 #include "eglsurface.h"
 
-#include <GL/gl.h>
-
 #define CALLOC_STRUCT(T)   (struct T *) calloc(1, sizeof(struct T))
+#define ARRAY_SIZE(a)      (sizeof(a) / sizeof(a[0]))
 
-static const EGLint all_apis = (EGL_OPENGL_ES_BIT
-                                | EGL_OPENGL_ES2_BIT
-                                | EGL_OPENVG_BIT
-                                /* | EGL_OPENGL_BIT */); /* can't do */
+#ifndef GLX_VERSION_1_4
+#error "GL/glx.h must be equal to or greater than GLX 1.4"
+#endif
+
+/*
+ * report OpenGL ES bits because apps usually forget to specify
+ * EGL_RENDERABLE_TYPE when choosing configs
+ */
+#define GLX_EGL_APIS (EGL_OPENGL_BIT | EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT)
 
-struct visual_attribs
-{
-   /* X visual attribs */
-   int id;
-   int klass;
-   int depth;
-   int redMask, greenMask, blueMask;
-   int colormapSize;
-   int bitsPerRGB;
-
-   /* GL visual attribs */
-   int supportsGL;
-   int transparentType;
-   int transparentRedValue;
-   int transparentGreenValue;
-   int transparentBlueValue;
-   int transparentAlphaValue;
-   int transparentIndexValue;
-   int bufferSize;
-   int level;
-   int render_type;
-   int doubleBuffer;
-   int stereo;
-   int auxBuffers;
-   int redSize, greenSize, blueSize, alphaSize;
-   int depthSize;
-   int stencilSize;
-   int accumRedSize, accumGreenSize, accumBlueSize, accumAlphaSize;
-   int numSamples, numMultisample;
-   int visualCaveat;
-};
 
 /** subclass of _EGLDriver */
 struct GLX_egl_driver
@@ -114,6 +76,21 @@ struct GLX_egl_display
    GLXFBConfig *fbconfigs;
 
    int glx_maj, glx_min;
+
+   const char *extensions;
+   EGLBoolean have_1_3;
+   EGLBoolean have_make_current_read;
+   EGLBoolean have_fbconfig;
+   EGLBoolean have_pbuffer;
+
+   /* GLX_SGIX_pbuffer */
+   PFNGLXCREATEGLXPBUFFERSGIXPROC glXCreateGLXPbufferSGIX;
+   PFNGLXDESTROYGLXPBUFFERSGIXPROC glXDestroyGLXPbufferSGIX;
+
+   /* workaround quirks of different GLX implementations */
+   EGLBoolean single_buffered_quirk;
+   EGLBoolean glx_window_quirk;
+
 };
 
 
@@ -131,7 +108,8 @@ struct GLX_egl_surface
 {
    _EGLSurface Base;   /**< base class */
 
-   GLXDrawable drawable;
+   Drawable drawable;
+   GLXDrawable glx_drawable;
 };
 
 
@@ -139,6 +117,7 @@ struct GLX_egl_surface
 struct GLX_egl_config
 {
    _EGLConfig Base;   /**< base class */
+   EGLBoolean double_buffered;
    int index;
 };
 
@@ -173,288 +152,369 @@ GLX_egl_config_index(_EGLConfig *conf)
    return ((struct GLX_egl_config *) conf)->index;
 }
 
-static GLboolean
-get_visual_attribs(Display *dpy, XVisualInfo *vInfo,
-                   struct visual_attribs *attribs)
-{
-   const char *ext = glXQueryExtensionsString(dpy, vInfo->screen);
-   int rgba;
 
-   memset(attribs, 0, sizeof(struct visual_attribs));
+#define MAP_ATTRIB(attr, memb) \
+   { attr, offsetof(__GLcontextModes, memb) }
+
+
+static const struct {
+   int attr;
+   int offset;
+} fbconfig_attributes[] = {
+   /* table 3.1 of GLX 1.4 */
+   MAP_ATTRIB(GLX_FBCONFIG_ID,                  fbconfigID),
+   MAP_ATTRIB(GLX_BUFFER_SIZE,                  rgbBits),
+   MAP_ATTRIB(GLX_LEVEL,                        level),
+   MAP_ATTRIB(GLX_DOUBLEBUFFER,                 doubleBufferMode),
+   MAP_ATTRIB(GLX_STEREO,                       stereoMode),
+   MAP_ATTRIB(GLX_AUX_BUFFERS,                  numAuxBuffers),
+   MAP_ATTRIB(GLX_RED_SIZE,                     redBits),
+   MAP_ATTRIB(GLX_GREEN_SIZE,                   greenBits),
+   MAP_ATTRIB(GLX_BLUE_SIZE,                    blueBits),
+   MAP_ATTRIB(GLX_ALPHA_SIZE,                   alphaBits),
+   MAP_ATTRIB(GLX_DEPTH_SIZE,                   depthBits),
+   MAP_ATTRIB(GLX_STENCIL_SIZE,                 stencilBits),
+   MAP_ATTRIB(GLX_ACCUM_RED_SIZE,               accumRedBits),
+   MAP_ATTRIB(GLX_ACCUM_GREEN_SIZE,             accumGreenBits),
+   MAP_ATTRIB(GLX_ACCUM_BLUE_SIZE,              accumBlueBits),
+   MAP_ATTRIB(GLX_ACCUM_ALPHA_SIZE,             accumAlphaBits),
+   MAP_ATTRIB(GLX_SAMPLE_BUFFERS,               sampleBuffers),
+   MAP_ATTRIB(GLX_SAMPLES,                      samples),
+   MAP_ATTRIB(GLX_RENDER_TYPE,                  renderType),
+   MAP_ATTRIB(GLX_DRAWABLE_TYPE,                drawableType),
+   MAP_ATTRIB(GLX_X_RENDERABLE,                 xRenderable),
+   MAP_ATTRIB(GLX_X_VISUAL_TYPE,                visualType),
+   MAP_ATTRIB(GLX_CONFIG_CAVEAT,                visualRating),
+   MAP_ATTRIB(GLX_TRANSPARENT_TYPE,             transparentPixel),
+   MAP_ATTRIB(GLX_TRANSPARENT_INDEX_VALUE,      transparentIndex),
+   MAP_ATTRIB(GLX_TRANSPARENT_RED_VALUE,        transparentRed),
+   MAP_ATTRIB(GLX_TRANSPARENT_GREEN_VALUE,      transparentGreen),
+   MAP_ATTRIB(GLX_TRANSPARENT_BLUE_VALUE,       transparentBlue),
+   MAP_ATTRIB(GLX_TRANSPARENT_ALPHA_VALUE,      transparentAlpha),
+   MAP_ATTRIB(GLX_MAX_PBUFFER_WIDTH,            maxPbufferWidth),
+   MAP_ATTRIB(GLX_MAX_PBUFFER_HEIGHT,           maxPbufferHeight),
+   MAP_ATTRIB(GLX_MAX_PBUFFER_PIXELS,           maxPbufferPixels),
+   MAP_ATTRIB(GLX_VISUAL_ID,                    visualID),
+};
 
-   attribs->id = vInfo->visualid;
-#if defined(__cplusplus) || defined(c_plusplus)
-   attribs->klass = vInfo->c_class;
-#else
-   attribs->klass = vInfo->class;
-#endif
-   attribs->depth = vInfo->depth;
-   attribs->redMask = vInfo->red_mask;
-   attribs->greenMask = vInfo->green_mask;
-   attribs->blueMask = vInfo->blue_mask;
-   attribs->colormapSize = vInfo->colormap_size;
-   attribs->bitsPerRGB = vInfo->bits_per_rgb;
-
-   if (glXGetConfig(dpy, vInfo, GLX_USE_GL, &attribs->supportsGL) != 0 ||
-       !attribs->supportsGL)
-      return GL_FALSE;
-   glXGetConfig(dpy, vInfo, GLX_BUFFER_SIZE, &attribs->bufferSize);
-   glXGetConfig(dpy, vInfo, GLX_LEVEL, &attribs->level);
-   glXGetConfig(dpy, vInfo, GLX_RGBA, &rgba);
-   if (!rgba)
-      return GL_FALSE;
-   attribs->render_type = GLX_RGBA_BIT;
-   
-   glXGetConfig(dpy, vInfo, GLX_DOUBLEBUFFER, &attribs->doubleBuffer);
-   if (!attribs->doubleBuffer)
-      return GL_FALSE;
-
-   glXGetConfig(dpy, vInfo, GLX_STEREO, &attribs->stereo);
-   glXGetConfig(dpy, vInfo, GLX_AUX_BUFFERS, &attribs->auxBuffers);
-   glXGetConfig(dpy, vInfo, GLX_RED_SIZE, &attribs->redSize);
-   glXGetConfig(dpy, vInfo, GLX_GREEN_SIZE, &attribs->greenSize);
-   glXGetConfig(dpy, vInfo, GLX_BLUE_SIZE, &attribs->blueSize);
-   glXGetConfig(dpy, vInfo, GLX_ALPHA_SIZE, &attribs->alphaSize);
-   glXGetConfig(dpy, vInfo, GLX_DEPTH_SIZE, &attribs->depthSize);
-   glXGetConfig(dpy, vInfo, GLX_STENCIL_SIZE, &attribs->stencilSize);
-   glXGetConfig(dpy, vInfo, GLX_ACCUM_RED_SIZE, &attribs->accumRedSize);
-   glXGetConfig(dpy, vInfo, GLX_ACCUM_GREEN_SIZE, &attribs->accumGreenSize);
-   glXGetConfig(dpy, vInfo, GLX_ACCUM_BLUE_SIZE, &attribs->accumBlueSize);
-   glXGetConfig(dpy, vInfo, GLX_ACCUM_ALPHA_SIZE, &attribs->accumAlphaSize);
-
-   /* get transparent pixel stuff */
-   glXGetConfig(dpy, vInfo,GLX_TRANSPARENT_TYPE, &attribs->transparentType);
-   if (attribs->transparentType == GLX_TRANSPARENT_RGB) {
-     glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_RED_VALUE, &attribs->transparentRedValue);
-     glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_GREEN_VALUE, &attribs->transparentGreenValue);
-     glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_BLUE_VALUE, &attribs->transparentBlueValue);
-     glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_ALPHA_VALUE, &attribs->transparentAlphaValue);
-   }
-   else if (attribs->transparentType == GLX_TRANSPARENT_INDEX) {
-     glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_INDEX_VALUE, &attribs->transparentIndexValue);
-   }
-
-   /* multisample attribs */
-#ifdef GLX_ARB_multisample
-   if (ext && strstr(ext, "GLX_ARB_multisample")) {
-      glXGetConfig(dpy, vInfo, GLX_SAMPLE_BUFFERS_ARB, &attribs->numMultisample);
-      glXGetConfig(dpy, vInfo, GLX_SAMPLES_ARB, &attribs->numSamples);
-   }
-#endif
-   else {
-      attribs->numSamples = 0;
-      attribs->numMultisample = 0;
-   }
 
-#if defined(GLX_EXT_visual_rating)
-   if (ext && strstr(ext, "GLX_EXT_visual_rating")) {
-      glXGetConfig(dpy, vInfo, GLX_VISUAL_CAVEAT_EXT, &attribs->visualCaveat);
-   }
-   else {
-      attribs->visualCaveat = GLX_NONE_EXT;
+static EGLBoolean
+convert_fbconfig(Display *dpy, GLXFBConfig fbconfig,
+                 struct GLX_egl_config *GLX_conf)
+{
+   __GLcontextModes mode;
+   int err = 0, attr, val, i;
+
+   memset(&mode, 0, sizeof(mode));
+
+   for (i = 0; i < ARRAY_SIZE(fbconfig_attributes); i++) {
+      int offset = fbconfig_attributes[i].offset;
+      attr = fbconfig_attributes[i].attr;
+      err = glXGetFBConfigAttrib(dpy, fbconfig, attr, &val);
+      if (err) {
+         if (err == GLX_BAD_ATTRIBUTE) {
+            err = 0;
+            continue;
+         }
+         break;
+      }
+      *((int *) ((char *) &mode + offset)) = val;
    }
-#else
-   attribs->visualCaveat = 0;
-#endif
-
-   return GL_TRUE;
-}
+   if (err)
+      return EGL_FALSE;
 
-#ifdef GLX_VERSION_1_3
+   /* must have rgba bit */
+   if (!(mode.renderType & GLX_RGBA_BIT))
+      return EGL_FALSE;
 
-static int
-glx_token_to_visual_class(int visual_type)
-{
-   switch (visual_type) {
-   case GLX_TRUE_COLOR:
-      return TrueColor;
-   case GLX_DIRECT_COLOR:
-      return DirectColor;
-   case GLX_PSEUDO_COLOR:
-      return PseudoColor;
-   case GLX_STATIC_COLOR:
-      return StaticColor;
-   case GLX_GRAY_SCALE:
-      return GrayScale;
-   case GLX_STATIC_GRAY:
-      return StaticGray;
-   case GLX_NONE:
-   default:
-      return None;
+   /* pixmap and pbuffer surfaces must be single-buffered in EGL */
+   if (mode.doubleBufferMode) {
+      mode.drawableType &= ~(GLX_PIXMAP_BIT | GLX_PBUFFER_BIT);
+      if (!mode.drawableType)
+         return EGL_FALSE;
    }
+
+   mode.rgbMode = GL_TRUE;
+   mode.haveAccumBuffer = (mode.accumRedBits +
+                           mode.accumGreenBits +
+                           mode.accumBlueBits +
+                           mode.accumAlphaBits > 0);
+   mode.haveDepthBuffer = (mode.depthBits > 0);
+   mode.haveStencilBuffer = (mode.stencilBits > 0);
+
+   GLX_conf->double_buffered = (mode.doubleBufferMode != 0);
+   return _eglConfigFromContextModesRec(&GLX_conf->Base, &mode,
+                                        GLX_EGL_APIS, GLX_EGL_APIS);
 }
 
-static int
-get_fbconfig_attribs(Display *dpy, GLXFBConfig fbconfig,
-                    struct visual_attribs *attribs)
-{
-   int visual_type;
-   int fbconfig_id;
 
-   memset(attribs, 0, sizeof(struct visual_attribs));
+static const struct {
+   int attr;
+   int offset;
+} visual_attributes[] = {
+   /* table 3.7 of GLX 1.4 */
+   /* no GLX_USE_GL */
+   MAP_ATTRIB(GLX_BUFFER_SIZE,         rgbBits),
+   MAP_ATTRIB(GLX_LEVEL,               level),
+   MAP_ATTRIB(GLX_RGBA,                rgbMode),
+   MAP_ATTRIB(GLX_DOUBLEBUFFER,        doubleBufferMode),
+   MAP_ATTRIB(GLX_STEREO,              stereoMode),
+   MAP_ATTRIB(GLX_AUX_BUFFERS,         numAuxBuffers),
+   MAP_ATTRIB(GLX_RED_SIZE,            redBits),
+   MAP_ATTRIB(GLX_GREEN_SIZE,          greenBits),
+   MAP_ATTRIB(GLX_BLUE_SIZE,           blueBits),
+   MAP_ATTRIB(GLX_ALPHA_SIZE,          alphaBits),
+   MAP_ATTRIB(GLX_DEPTH_SIZE,          depthBits),
+   MAP_ATTRIB(GLX_STENCIL_SIZE,        stencilBits),
+   MAP_ATTRIB(GLX_ACCUM_RED_SIZE,      accumRedBits),
+   MAP_ATTRIB(GLX_ACCUM_GREEN_SIZE,    accumGreenBits),
+   MAP_ATTRIB(GLX_ACCUM_BLUE_SIZE,     accumBlueBits),
+   MAP_ATTRIB(GLX_ACCUM_ALPHA_SIZE,    accumAlphaBits),
+   MAP_ATTRIB(GLX_SAMPLE_BUFFERS,      sampleBuffers),
+   MAP_ATTRIB(GLX_SAMPLES,             samples),
+   MAP_ATTRIB(GLX_FBCONFIG_ID,         fbconfigID),
+   /* GLX_EXT_visual_rating */
+   MAP_ATTRIB(GLX_VISUAL_CAVEAT_EXT,   visualRating),
+};
 
-   glXGetFBConfigAttrib(dpy, fbconfig, GLX_FBCONFIG_ID, &fbconfig_id);
 
-   glXGetFBConfigAttrib(dpy, fbconfig, GLX_VISUAL_ID, &attribs->id);
+static int
+get_visual_type(const XVisualInfo *vis)
+{
+   int klass;
 
-#if 0
-   attribs->depth = vInfo->depth;
-   attribs->redMask = vInfo->red_mask;
-   attribs->greenMask = vInfo->green_mask;
-   attribs->blueMask = vInfo->blue_mask;
-   attribs->colormapSize = vInfo->colormap_size;
-   attribs->bitsPerRGB = vInfo->bits_per_rgb;
+#if defined(__cplusplus) || defined(c_plusplus)
+   klass = vis->c_class;
+#else
+   klass = vis->class;
 #endif
 
-   glXGetFBConfigAttrib(dpy, fbconfig, GLX_X_VISUAL_TYPE, &visual_type);
-   attribs->klass = glx_token_to_visual_class(visual_type);
+   switch (klass) {
+   case TrueColor:
+      return GLX_TRUE_COLOR;
+   case DirectColor:
+      return GLX_DIRECT_COLOR;
+   case PseudoColor:
+      return GLX_PSEUDO_COLOR;
+   case StaticColor:
+      return GLX_STATIC_COLOR;
+   case GrayScale:
+      return GLX_GRAY_SCALE;
+   case StaticGray:
+      return GLX_STATIC_GRAY;
+   default:
+      return GLX_NONE;
+   }
+}
 
-   glXGetFBConfigAttrib(dpy, fbconfig, GLX_BUFFER_SIZE, &attribs->bufferSize);
-   glXGetFBConfigAttrib(dpy, fbconfig, GLX_LEVEL, &attribs->level);
-   glXGetFBConfigAttrib(dpy, fbconfig, GLX_RENDER_TYPE, &attribs->render_type);
-   if (!(attribs->render_type & GLX_RGBA_BIT))
-      return 0;
 
-   glXGetFBConfigAttrib(dpy, fbconfig, GLX_DOUBLEBUFFER, &attribs->doubleBuffer);
-   if (!attribs->doubleBuffer)
-      return 0;
+static EGLBoolean
+convert_visual(Display *dpy, XVisualInfo *vinfo,
+               struct GLX_egl_config *GLX_conf)
+{
+   __GLcontextModes mode;
+   int err, attr, val, i;
 
-   glXGetFBConfigAttrib(dpy, fbconfig, GLX_STEREO, &attribs->stereo);
-   glXGetFBConfigAttrib(dpy, fbconfig, GLX_AUX_BUFFERS, &attribs->auxBuffers);
+   /* the visual must support OpenGL */
+   err = glXGetConfig(dpy, vinfo, GLX_USE_GL, &val);
+   if (err || !val)
+      return EGL_FALSE;
 
-   glXGetFBConfigAttrib(dpy, fbconfig, GLX_RED_SIZE, &attribs->redSize);
-   glXGetFBConfigAttrib(dpy, fbconfig, GLX_GREEN_SIZE, &attribs->greenSize);
-   glXGetFBConfigAttrib(dpy, fbconfig, GLX_BLUE_SIZE, &attribs->blueSize);
-   glXGetFBConfigAttrib(dpy, fbconfig, GLX_ALPHA_SIZE, &attribs->alphaSize);
-   glXGetFBConfigAttrib(dpy, fbconfig, GLX_DEPTH_SIZE, &attribs->depthSize);
-   glXGetFBConfigAttrib(dpy, fbconfig, GLX_STENCIL_SIZE, &attribs->stencilSize);
+   memset(&mode, 0, sizeof(mode));
+
+   for (i = 0; i < ARRAY_SIZE(visual_attributes); i++) {
+      int offset = visual_attributes[i].offset;
+      attr = visual_attributes[i].attr;
+      err = glXGetConfig(dpy, vinfo, attr, &val);
+      if (err) {
+         if (err == GLX_BAD_ATTRIBUTE) {
+            err = 0;
+            continue;
+         }
+         break;
+      }
+      *((int *) ((char *) &mode + offset)) = val;
+   }
+   if (err)
+      return EGL_FALSE;
 
-   glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_RED_SIZE, &attribs->accumRedSize);
-   glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_GREEN_SIZE, &attribs->accumGreenSize);
-   glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_BLUE_SIZE, &attribs->accumBlueSize);
-   glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_ALPHA_SIZE, &attribs->accumAlphaSize);
+   /* must be RGB mode */
+   if (!mode.rgbMode)
+      return EGL_FALSE;
 
-   /* get transparent pixel stuff */
-   glXGetFBConfigAttrib(dpy, fbconfig,GLX_TRANSPARENT_TYPE, &attribs->transparentType);
-   if (attribs->transparentType == GLX_TRANSPARENT_RGB) {
-     glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_RED_VALUE, &attribs->transparentRedValue);
-     glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_GREEN_VALUE, &attribs->transparentGreenValue);
-     glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_BLUE_VALUE, &attribs->transparentBlueValue);
-     glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_ALPHA_VALUE, &attribs->transparentAlphaValue);
-   }
-   else if (attribs->transparentType == GLX_TRANSPARENT_INDEX) {
-     glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_INDEX_VALUE, &attribs->transparentIndexValue);
-   }
+   mode.visualID = vinfo->visualid;
+   mode.visualType = get_visual_type(vinfo);
+   mode.redMask = vinfo->red_mask;
+   mode.greenMask = vinfo->green_mask;
+   mode.blueMask = vinfo->blue_mask;
+
+   mode.drawableType = GLX_WINDOW_BIT;
+   /* pixmap surfaces must be single-buffered in EGL */
+   if (!mode.doubleBufferMode)
+      mode.drawableType |= GLX_PIXMAP_BIT;
+
+   mode.renderType = GLX_RGBA_BIT;
+   mode.xRenderable = GL_TRUE;
+   mode.haveAccumBuffer = (mode.accumRedBits +
+                           mode.accumGreenBits +
+                           mode.accumBlueBits +
+                           mode.accumAlphaBits > 0);
+   mode.haveDepthBuffer = (mode.depthBits > 0);
+   mode.haveStencilBuffer = (mode.stencilBits > 0);
+
+   GLX_conf->double_buffered = (mode.doubleBufferMode != 0);
+   return _eglConfigFromContextModesRec(&GLX_conf->Base, &mode,
+                                        GLX_EGL_APIS, GLX_EGL_APIS);
+}
 
-   glXGetFBConfigAttrib(dpy, fbconfig, GLX_SAMPLE_BUFFERS, &attribs->numMultisample);
-   glXGetFBConfigAttrib(dpy, fbconfig, GLX_SAMPLES, &attribs->numSamples);
 
-   glXGetFBConfigAttrib(dpy, fbconfig, GLX_CONFIG_CAVEAT, &attribs->visualCaveat);
+static void
+fix_config(struct GLX_egl_display *GLX_dpy, struct GLX_egl_config *GLX_conf)
+{
+   _EGLConfig *conf = &GLX_conf->Base;
+   EGLint surface_type, r, g, b, a;
+
+   surface_type = GET_CONFIG_ATTRIB(conf, EGL_SURFACE_TYPE);
+   if (!GLX_conf->double_buffered && GLX_dpy->single_buffered_quirk) {
+      /* some GLX impls do not like single-buffered window surface */
+      surface_type &= ~EGL_WINDOW_BIT;
+      /* pbuffer bit is usually not set */
+      if (GLX_dpy->have_pbuffer)
+         surface_type |= EGL_PBUFFER_BIT;
+      SET_CONFIG_ATTRIB(conf, EGL_SURFACE_TYPE, surface_type);
+   }
 
-   if (attribs->id == 0) {
-      attribs->id = fbconfig_id;
-      return EGL_PBUFFER_BIT | EGL_PIXMAP_BIT;
+   /* no visual attribs unless window bit is set */
+   if (!(surface_type & EGL_WINDOW_BIT)) {
+      SET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_ID, 0);
+      SET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_TYPE, EGL_NONE);
    }
 
-   return EGL_WINDOW_BIT;
+   /* make sure buffer size is set correctly */
+   r = GET_CONFIG_ATTRIB(conf, EGL_RED_SIZE);
+   g = GET_CONFIG_ATTRIB(conf, EGL_GREEN_SIZE);
+   b = GET_CONFIG_ATTRIB(conf, EGL_BLUE_SIZE);
+   a = GET_CONFIG_ATTRIB(conf, EGL_ALPHA_SIZE);
+   SET_CONFIG_ATTRIB(conf, EGL_BUFFER_SIZE, r + g + b + a);
 }
 
-#endif
 
 static EGLBoolean
-create_configs(_EGLDisplay *disp, struct GLX_egl_display *GLX_dpy)
+create_configs(_EGLDisplay *dpy, struct GLX_egl_display *GLX_dpy,
+               EGLint screen)
 {
-   XVisualInfo theTemplate;
-   int numVisuals;
-   long mask;
-   int i;
-   struct visual_attribs attribs;
+   EGLint num_configs = 0, i;
+   EGLint id = 1;
 
-   GLX_dpy->fbconfigs = NULL;
-
-#ifdef GLX_VERSION_1_3
-   /* get list of all fbconfigs on this screen */
-   GLX_dpy->fbconfigs = glXGetFBConfigs(GLX_dpy->dpy, DefaultScreen(GLX_dpy->dpy), &numVisuals);
+   if (GLX_dpy->have_fbconfig) {
+      GLX_dpy->fbconfigs = glXGetFBConfigs(GLX_dpy->dpy, screen, &num_configs);
+   }
+   else {
+      XVisualInfo vinfo_template;
+      long mask;
 
-   if (numVisuals == 0) {
-      GLX_dpy->fbconfigs = NULL;
-      goto xvisual;
+      vinfo_template.screen = screen;
+      mask = VisualScreenMask;
+      GLX_dpy->visuals = XGetVisualInfo(GLX_dpy->dpy, mask, &vinfo_template,
+                                        &num_configs);
    }
 
-   for (i = 0; i < numVisuals; i++) {
-      struct GLX_egl_config *config;
-      int bit;
+   if (!num_configs)
+      return EGL_FALSE;
 
-      bit = get_fbconfig_attribs(GLX_dpy->dpy, GLX_dpy->fbconfigs[i], &attribs);
-      if (!bit)
+   for (i = 0; i < num_configs; i++) {
+      struct GLX_egl_config *GLX_conf, template;
+      EGLBoolean ok;
+
+      memset(&template, 0, sizeof(template));
+      _eglInitConfig(&template.Base, id);
+      if (GLX_dpy->have_fbconfig)
+         ok = convert_fbconfig(GLX_dpy->dpy, GLX_dpy->fbconfigs[i], &template);
+      else
+         ok = convert_visual(GLX_dpy->dpy, &GLX_dpy->visuals[i], &template);
+      if (!ok)
+        continue;
+
+      fix_config(GLX_dpy, &template);
+      if (!_eglValidateConfig(&template.Base, EGL_FALSE)) {
+         _eglLog(_EGL_DEBUG, "GLX: failed to validate config %d", i);
          continue;
+      }
 
-      config = CALLOC_STRUCT(GLX_egl_config);
-
-      config->index = i;
-      _eglInitConfig(&config->Base, (i+1));
-      SET_CONFIG_ATTRIB(&config->Base, EGL_NATIVE_VISUAL_ID, attribs.id);
-      SET_CONFIG_ATTRIB(&config->Base, EGL_BUFFER_SIZE, attribs.bufferSize);
-      SET_CONFIG_ATTRIB(&config->Base, EGL_RED_SIZE, attribs.redSize);
-      SET_CONFIG_ATTRIB(&config->Base, EGL_GREEN_SIZE, attribs.greenSize);
-      SET_CONFIG_ATTRIB(&config->Base, EGL_BLUE_SIZE, attribs.blueSize);
-      SET_CONFIG_ATTRIB(&config->Base, EGL_ALPHA_SIZE, attribs.alphaSize);
-      SET_CONFIG_ATTRIB(&config->Base, EGL_DEPTH_SIZE, attribs.depthSize);
-      SET_CONFIG_ATTRIB(&config->Base, EGL_STENCIL_SIZE, attribs.stencilSize);
-      SET_CONFIG_ATTRIB(&config->Base, EGL_SAMPLES, attribs.numSamples);
-      SET_CONFIG_ATTRIB(&config->Base, EGL_SAMPLE_BUFFERS, attribs.numMultisample);
-      SET_CONFIG_ATTRIB(&config->Base, EGL_CONFORMANT, all_apis);
-      SET_CONFIG_ATTRIB(&config->Base, EGL_RENDERABLE_TYPE, all_apis);
-      SET_CONFIG_ATTRIB(&config->Base, EGL_SURFACE_TYPE, bit);
-
-      /* XXX possibly other things to init... */
+      GLX_conf = CALLOC_STRUCT(GLX_egl_config);
+      if (GLX_conf) {
+         memcpy(GLX_conf, &template, sizeof(template));
+         GLX_conf->index = i;
 
-      _eglAddConfig(disp, &config->Base);
+         _eglAddConfig(dpy, &GLX_conf->Base);
+         id++;
+      }
    }
 
-   goto end;
-#endif
-
-xvisual:
-   /* get list of all visuals on this screen */
-   theTemplate.screen = DefaultScreen(GLX_dpy->dpy);
-   mask = VisualScreenMask;
-   GLX_dpy->visuals = XGetVisualInfo(GLX_dpy->dpy, mask, &theTemplate, &numVisuals);
+   return EGL_TRUE;
+}
 
-   for (i = 0; i < numVisuals; i++) {
-      struct GLX_egl_config *config;
 
-      if (!get_visual_attribs(GLX_dpy->dpy, &GLX_dpy->visuals[i], &attribs))
-        continue;
+static void
+check_extensions(struct GLX_egl_display *GLX_dpy, EGLint screen)
+{
+   GLX_dpy->extensions =
+      glXQueryExtensionsString(GLX_dpy->dpy, screen);
+   if (GLX_dpy->extensions) {
+      /* glXGetProcAddress is assumed */
+
+      if (strstr(GLX_dpy->extensions, "GLX_SGI_make_current_read")) {
+         /* GLX 1.3 entry points are used */
+         GLX_dpy->have_make_current_read = EGL_TRUE;
+      }
 
-      config = CALLOC_STRUCT(GLX_egl_config);
+      if (strstr(GLX_dpy->extensions, "GLX_SGIX_fbconfig")) {
+         /* GLX 1.3 entry points are used */
+         GLX_dpy->have_fbconfig = EGL_TRUE;
+      }
 
-      config->index = i;
-      _eglInitConfig(&config->Base, (i+1));
-      SET_CONFIG_ATTRIB(&config->Base, EGL_NATIVE_VISUAL_ID, attribs.id);
-      SET_CONFIG_ATTRIB(&config->Base, EGL_BUFFER_SIZE, attribs.bufferSize);
-      SET_CONFIG_ATTRIB(&config->Base, EGL_RED_SIZE, attribs.redSize);
-      SET_CONFIG_ATTRIB(&config->Base, EGL_GREEN_SIZE, attribs.greenSize);
-      SET_CONFIG_ATTRIB(&config->Base, EGL_BLUE_SIZE, attribs.blueSize);
-      SET_CONFIG_ATTRIB(&config->Base, EGL_ALPHA_SIZE, attribs.alphaSize);
-      SET_CONFIG_ATTRIB(&config->Base, EGL_DEPTH_SIZE, attribs.depthSize);
-      SET_CONFIG_ATTRIB(&config->Base, EGL_STENCIL_SIZE, attribs.stencilSize);
-      SET_CONFIG_ATTRIB(&config->Base, EGL_SAMPLES, attribs.numSamples);
-      SET_CONFIG_ATTRIB(&config->Base, EGL_SAMPLE_BUFFERS, attribs.numMultisample);
-      SET_CONFIG_ATTRIB(&config->Base, EGL_CONFORMANT, all_apis);
-      SET_CONFIG_ATTRIB(&config->Base, EGL_RENDERABLE_TYPE, all_apis);
-      SET_CONFIG_ATTRIB(&config->Base, EGL_SURFACE_TYPE,
-                        (EGL_WINDOW_BIT /*| EGL_PBUFFER_BIT | EGL_PIXMAP_BIT*/));
+      if (strstr(GLX_dpy->extensions, "GLX_SGIX_pbuffer")) {
+         GLX_dpy->glXCreateGLXPbufferSGIX = (PFNGLXCREATEGLXPBUFFERSGIXPROC)
+            glXGetProcAddress((const GLubyte *) "glXCreateGLXPbufferSGIX");
+         GLX_dpy->glXDestroyGLXPbufferSGIX = (PFNGLXDESTROYGLXPBUFFERSGIXPROC)
+            glXGetProcAddress((const GLubyte *) "glXDestroyGLXPbufferSGIX");
 
-      /* XXX possibly other things to init... */
+         if (GLX_dpy->glXCreateGLXPbufferSGIX &&
+             GLX_dpy->glXDestroyGLXPbufferSGIX &&
+             GLX_dpy->have_fbconfig)
+            GLX_dpy->have_pbuffer = EGL_TRUE;
+      }
+   }
 
-      _eglAddConfig(disp, &config->Base);
+   if (GLX_dpy->glx_maj == 1 && GLX_dpy->glx_min >= 3) {
+      GLX_dpy->have_1_3 = EGL_TRUE;
+      GLX_dpy->have_make_current_read = EGL_TRUE;
+      GLX_dpy->have_fbconfig = EGL_TRUE;
+      GLX_dpy->have_pbuffer = EGL_TRUE;
    }
+}
 
-end:
-   return EGL_TRUE;
+
+static void
+check_quirks(struct GLX_egl_display *GLX_dpy, EGLint screen)
+{
+   const char *vendor;
+
+   GLX_dpy->single_buffered_quirk = EGL_TRUE;
+   GLX_dpy->glx_window_quirk = EGL_TRUE;
+
+   vendor = glXGetClientString(GLX_dpy->dpy, GLX_VENDOR);
+   if (vendor && strstr(vendor, "NVIDIA")) {
+      vendor = glXQueryServerString(GLX_dpy->dpy, screen, GLX_VENDOR);
+      if (vendor && strstr(vendor, "NVIDIA")) {
+         _eglLog(_EGL_DEBUG, "disable quirks");
+         GLX_dpy->single_buffered_quirk = EGL_FALSE;
+         GLX_dpy->glx_window_quirk = EGL_FALSE;
+      }
+   }
 }
 
+
 /**
  * Called via eglInitialize(), GLX_drv->API.Initialize().
  */
@@ -478,17 +538,33 @@ GLX_eglInitialize(_EGLDriver *drv, _EGLDisplay *disp,
       }
    }
 
-   disp->DriverData = (void *) GLX_dpy;
-   disp->ClientAPIsMask = all_apis;
+   if (!glXQueryVersion(GLX_dpy->dpy, &GLX_dpy->glx_maj, &GLX_dpy->glx_min)) {
+      _eglLog(_EGL_WARNING, "GLX: glXQueryVersion failed");
+      if (!disp->NativeDisplay)
+         XCloseDisplay(GLX_dpy->dpy);
+      free(GLX_dpy);
+      return EGL_FALSE;
+   }
 
-   glXQueryVersion(GLX_dpy->dpy, &GLX_dpy->glx_maj, &GLX_dpy->glx_min);
+   check_extensions(GLX_dpy, DefaultScreen(GLX_dpy->dpy));
+   check_quirks(GLX_dpy, DefaultScreen(GLX_dpy->dpy));
+
+   create_configs(disp, GLX_dpy, DefaultScreen(GLX_dpy->dpy));
+   if (!disp->NumConfigs) {
+      _eglLog(_EGL_WARNING, "GLX: failed to create any config");
+      if (!disp->NativeDisplay)
+         XCloseDisplay(GLX_dpy->dpy);
+      free(GLX_dpy);
+      return EGL_FALSE;
+   }
+
+   disp->DriverData = (void *) GLX_dpy;
+   disp->ClientAPIsMask = GLX_EGL_APIS;
 
    /* we're supporting EGL 1.4 */
    *major = 1;
    *minor = 4;
 
-   create_configs(disp, GLX_dpy);
-
    return EGL_TRUE;
 }
 
@@ -539,8 +615,7 @@ GLX_eglCreateContext(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
       return NULL;
    }
 
-#ifdef GLX_VERSION_1_3
-   if (GLX_dpy->fbconfigs)
+   if (GLX_dpy->have_fbconfig)
       GLX_ctx->context =
          glXCreateNewContext(GLX_dpy->dpy,
                              GLX_dpy->fbconfigs[GLX_egl_config_index(conf)],
@@ -548,7 +623,6 @@ GLX_eglCreateContext(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
                              GLX_ctx_shared ? GLX_ctx_shared->context : NULL,
                              GL_TRUE);
    else
-#endif
       GLX_ctx->context =
          glXCreateContext(GLX_dpy->dpy,
                           &GLX_dpy->visuals[GLX_egl_config_index(conf)],
@@ -559,15 +633,6 @@ GLX_eglCreateContext(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
       return NULL;
    }
 
-#if 1
-   /* (maybe?) need to have a direct rendering context */
-   if (!glXIsDirect(GLX_dpy->dpy, GLX_ctx->context)) {
-      glXDestroyContext(GLX_dpy->dpy, GLX_ctx->context);
-      free(GLX_ctx);
-      return NULL;
-   }
-#endif
-
    return &GLX_ctx->Base;
 }
 
@@ -589,17 +654,14 @@ GLX_eglMakeCurrent(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf,
    if (!_eglMakeCurrent(drv, disp, dsurf, rsurf, ctx))
       return EGL_FALSE;
 
-   ddraw = (GLX_dsurf) ? GLX_dsurf->drawable : None;
-   rdraw = (GLX_rsurf) ? GLX_rsurf->drawable : None;
+   ddraw = (GLX_dsurf) ? GLX_dsurf->glx_drawable : None;
+   rdraw = (GLX_rsurf) ? GLX_rsurf->glx_drawable : None;
    cctx = (GLX_ctx) ? GLX_ctx->context : NULL;
 
-#ifdef GLX_VERSION_1_3
-   if (glXMakeContextCurrent(GLX_dpy->dpy, ddraw, rdraw, cctx))
-      return EGL_TRUE;
-#endif
-
-   if (ddraw == rdraw && glXMakeCurrent(GLX_dpy->dpy, ddraw, cctx))
-      return EGL_TRUE;
+   if (GLX_dpy->have_make_current_read)
+      return glXMakeContextCurrent(GLX_dpy->dpy, ddraw, rdraw, cctx);
+   else if (ddraw == rdraw)
+      return glXMakeCurrent(GLX_dpy->dpy, ddraw, cctx);
 
    return EGL_FALSE;
 }
@@ -642,6 +704,20 @@ GLX_eglCreateWindowSurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
    }
 
    GLX_surf->drawable = window;
+
+   if (GLX_dpy->have_1_3 && !GLX_dpy->glx_window_quirk)
+      GLX_surf->glx_drawable =
+         glXCreateWindow(GLX_dpy->dpy,
+                         GLX_dpy->fbconfigs[GLX_egl_config_index(conf)],
+                         GLX_surf->drawable, NULL);
+   else
+      GLX_surf->glx_drawable = GLX_surf->drawable;
+
+   if (!GLX_surf->glx_drawable) {
+      free(GLX_surf);
+      return NULL;
+   }
+
    get_drawable_size(GLX_dpy->dpy, window, &width, &height);
    GLX_surf->Base.Width = width;
    GLX_surf->Base.Height = height;
@@ -649,18 +725,13 @@ GLX_eglCreateWindowSurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
    return &GLX_surf->Base;
 }
 
-#ifdef GLX_VERSION_1_3
 static _EGLSurface *
 GLX_eglCreatePixmapSurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
                           NativePixmapType pixmap, const EGLint *attrib_list)
 {
    struct GLX_egl_display *GLX_dpy = GLX_egl_display(disp);
    struct GLX_egl_surface *GLX_surf;
-   int i;
-
-   /* GLX must >= 1.3 */
-   if (!(GLX_dpy->glx_maj == 1 && GLX_dpy->glx_min >= 3))
-      return NULL;
+   uint width, height;
 
    GLX_surf = CALLOC_STRUCT(GLX_egl_surface);
    if (!GLX_surf) {
@@ -674,25 +745,39 @@ GLX_eglCreatePixmapSurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
       return NULL;
    }
 
-   for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) {
-      switch (attrib_list[i]) {
-         /* no attribs at this time */
-      default:
-         _eglError(EGL_BAD_ATTRIBUTE, "eglCreatePixmapSurface");
-         free(GLX_surf);
-         return NULL;
+   GLX_surf->drawable = pixmap;
+
+   if (GLX_dpy->have_1_3) {
+      GLX_surf->glx_drawable =
+         glXCreatePixmap(GLX_dpy->dpy,
+                         GLX_dpy->fbconfigs[GLX_egl_config_index(conf)],
+                         GLX_surf->drawable, NULL);
+   }
+   else if (GLX_dpy->have_fbconfig) {
+      GLXFBConfig fbconfig = GLX_dpy->fbconfigs[GLX_egl_config_index(conf)];
+      XVisualInfo *vinfo = glXGetVisualFromFBConfig(GLX_dpy->dpy, fbconfig);
+      if (vinfo) {
+         GLX_surf->glx_drawable =
+            glXCreateGLXPixmap(GLX_dpy->dpy, vinfo, GLX_surf->drawable);
+         XFree(vinfo);
       }
    }
+   else {
+      GLX_surf->glx_drawable =
+         glXCreateGLXPixmap(GLX_dpy->dpy,
+                            &GLX_dpy->visuals[GLX_egl_config_index(conf)],
+                            GLX_surf->drawable);
+   }
 
-   GLX_surf->drawable =
-      glXCreatePixmap(GLX_dpy->dpy,
-                      GLX_dpy->fbconfigs[GLX_egl_config_index(conf)],
-                      pixmap, NULL);
-   if (!GLX_surf->drawable) {
+   if (!GLX_surf->glx_drawable) {
       free(GLX_surf);
       return NULL;
    }
 
+   get_drawable_size(GLX_dpy->dpy, pixmap, &width, &height);
+   GLX_surf->Base.Width = width;
+   GLX_surf->Base.Height = height;
+
    return &GLX_surf->Base;
 }
 
@@ -703,11 +788,7 @@ GLX_eglCreatePbufferSurface(_EGLDriver *drv, _EGLDisplay *disp,
    struct GLX_egl_display *GLX_dpy = GLX_egl_display(disp);
    struct GLX_egl_surface *GLX_surf;
    int attribs[5];
-   int i = 0, j = 0;
-
-   /* GLX must >= 1.3 */
-   if (!(GLX_dpy->glx_maj == 1 && GLX_dpy->glx_min >= 3))
-      return NULL;
+   int i;
 
    GLX_surf = CALLOC_STRUCT(GLX_egl_surface);
    if (!GLX_surf) {
@@ -721,33 +802,44 @@ GLX_eglCreatePbufferSurface(_EGLDriver *drv, _EGLDisplay *disp,
       return NULL;
    }
 
-   while(attrib_list[i] != EGL_NONE) {
-      switch (attrib_list[i]) {
-         case EGL_WIDTH:
-           attribs[j++] = GLX_PBUFFER_WIDTH;
-           attribs[j++] = attrib_list[i+1];
-           break;
-        case EGL_HEIGHT:
-           attribs[j++] = GLX_PBUFFER_HEIGHT;
-           attribs[j++] = attrib_list[i+1];
-           break;
+   i = 0;
+   attribs[i] = None;
+
+   GLX_surf->drawable = None;
+
+   if (GLX_dpy->have_1_3) {
+      /* put geometry in attribs */
+      if (GLX_surf->Base.Width) {
+         attribs[i++] = GLX_PBUFFER_WIDTH;
+         attribs[i++] = GLX_surf->Base.Width;
+      }
+      if (GLX_surf->Base.Height) {
+         attribs[i++] = GLX_PBUFFER_HEIGHT;
+         attribs[i++] = GLX_surf->Base.Height;
       }
-      i++;
+      attribs[i] = None;
+
+      GLX_surf->glx_drawable =
+         glXCreatePbuffer(GLX_dpy->dpy,
+                          GLX_dpy->fbconfigs[GLX_egl_config_index(conf)],
+                          attribs);
+   }
+   else if (GLX_dpy->have_pbuffer) {
+      GLX_surf->glx_drawable = GLX_dpy->glXCreateGLXPbufferSGIX(
+            GLX_dpy->dpy,
+            GLX_dpy->fbconfigs[GLX_egl_config_index(conf)],
+            GLX_surf->Base.Width,
+            GLX_surf->Base.Height,
+            attribs);
    }
-   attribs[j++] = 0;
 
-   GLX_surf->drawable =
-      glXCreatePbuffer(GLX_dpy->dpy,
-                       GLX_dpy->fbconfigs[GLX_egl_config_index(conf)],
-                       attribs);
-   if (!GLX_surf->drawable) {
+   if (!GLX_surf->glx_drawable) {
       free(GLX_surf);
       return NULL;
    }
 
    return &GLX_surf->Base;
 }
-#endif
 
 static EGLBoolean
 GLX_eglDestroySurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
@@ -755,15 +847,35 @@ GLX_eglDestroySurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
    struct GLX_egl_display *GLX_dpy = GLX_egl_display(disp);
    if (!_eglIsSurfaceBound(surf)) {
       struct GLX_egl_surface *GLX_surf = GLX_egl_surface(surf);
-      switch (surf->Type) {
-      case EGL_PBUFFER_BIT:
-         glXDestroyPbuffer(GLX_dpy->dpy, GLX_surf->drawable);
-         break;
-      case EGL_PIXMAP_BIT:
-         glXDestroyPixmap(GLX_dpy->dpy, GLX_surf->drawable);
-         break;
-      default:
-         break;
+
+      if (GLX_dpy->have_1_3) {
+         switch (surf->Type) {
+         case EGL_WINDOW_BIT:
+            if (!GLX_dpy->glx_window_quirk)
+               glXDestroyWindow(GLX_dpy->dpy, GLX_surf->glx_drawable);
+            break;
+         case EGL_PBUFFER_BIT:
+            glXDestroyPbuffer(GLX_dpy->dpy, GLX_surf->glx_drawable);
+            break;
+         case EGL_PIXMAP_BIT:
+            glXDestroyPixmap(GLX_dpy->dpy, GLX_surf->glx_drawable);
+            break;
+         default:
+            break;
+         }
+      }
+      else {
+         switch (surf->Type) {
+         case EGL_PBUFFER_BIT:
+            GLX_dpy->glXDestroyGLXPbufferSGIX(GLX_dpy->dpy,
+                                              GLX_surf->glx_drawable);
+            break;
+         case EGL_PIXMAP_BIT:
+            glXDestroyGLXPixmap(GLX_dpy->dpy, GLX_surf->glx_drawable);
+            break;
+         default:
+            break;
+         }
       }
       free(surf);
    }
@@ -772,45 +884,13 @@ GLX_eglDestroySurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
 }
 
 
-static EGLBoolean
-GLX_eglBindTexImage(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf,
-                     EGLint buffer)
-{
-   struct GLX_egl_display *GLX_dpy = GLX_egl_display(disp);
-   struct GLX_egl_surface *GLX_surf = GLX_egl_surface(surf);
-
-   /* buffer ?? */
-   glXBindTexImageEXT(GLX_dpy->dpy, GLX_surf->drawable,
-                      GLX_FRONT_LEFT_EXT, NULL);
-
-   return EGL_TRUE;
-}
-
-
-static EGLBoolean
-GLX_eglReleaseTexImage(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf,
-                        EGLint buffer)
-{
-   struct GLX_egl_display *GLX_dpy = GLX_egl_display(disp);
-   struct GLX_egl_surface *GLX_surf = GLX_egl_surface(surf);
-
-   /* buffer ?? */
-   glXReleaseTexImageEXT(GLX_dpy->dpy, GLX_surf->drawable,
-                         GLX_FRONT_LEFT_EXT);
-
-   return EGL_TRUE;
-}
-
-
 static EGLBoolean
 GLX_eglSwapBuffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
 {
    struct GLX_egl_display *GLX_dpy = GLX_egl_display(disp);
    struct GLX_egl_surface *GLX_surf = GLX_egl_surface(draw);
 
-   _eglLog(_EGL_DEBUG, "GLX: EGL SwapBuffers 0x%x",draw);
-
-   glXSwapBuffers(GLX_dpy->dpy, GLX_surf->drawable);
+   glXSwapBuffers(GLX_dpy->dpy, GLX_surf->glx_drawable);
 
    return EGL_TRUE;
 }
@@ -821,23 +901,24 @@ GLX_eglSwapBuffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
 static _EGLProc
 GLX_eglGetProcAddress(const char *procname)
 {
-   /* This is a bit of a hack to get at the gallium/Mesa state tracker
-    * function st_get_proc_address().  This will probably change at
-    * some point.
-    */
-   _EGLProc (*get_proc_addr)(const char *procname);
-   _EGLProc proc_addr;
-   get_proc_addr = dlsym(NULL, "st_get_proc_address");
-   if (get_proc_addr)
-      return get_proc_addr(procname);
-
-   proc_addr = glXGetProcAddress((const GLubyte *)procname);
-   if (proc_addr)
-      return proc_addr;
-
-   return (_EGLProc)dlsym(NULL, procname);
+   return (_EGLProc) glXGetProcAddress((const GLubyte *) procname);
 }
 
+static EGLBoolean
+GLX_eglWaitClient(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx)
+{
+   glXWaitGL();
+   return EGL_TRUE;
+}
+
+static EGLBoolean
+GLX_eglWaitNative(_EGLDriver *drv, _EGLDisplay *dpy, EGLint engine)
+{
+   if (engine != EGL_CORE_NATIVE_ENGINE)
+      return _eglError(EGL_BAD_PARAMETER, "eglWaitNative");
+   glXWaitX();
+   return EGL_TRUE;
+}
 
 static void
 GLX_Unload(_EGLDriver *drv)
@@ -865,15 +946,13 @@ _eglMain(const char *args)
    GLX_drv->Base.API.CreateContext = GLX_eglCreateContext;
    GLX_drv->Base.API.MakeCurrent = GLX_eglMakeCurrent;
    GLX_drv->Base.API.CreateWindowSurface = GLX_eglCreateWindowSurface;
-#ifdef GLX_VERSION_1_3
    GLX_drv->Base.API.CreatePixmapSurface = GLX_eglCreatePixmapSurface;
    GLX_drv->Base.API.CreatePbufferSurface = GLX_eglCreatePbufferSurface;
-#endif
    GLX_drv->Base.API.DestroySurface = GLX_eglDestroySurface;
-   GLX_drv->Base.API.BindTexImage = GLX_eglBindTexImage;
-   GLX_drv->Base.API.ReleaseTexImage = GLX_eglReleaseTexImage;
    GLX_drv->Base.API.SwapBuffers = GLX_eglSwapBuffers;
    GLX_drv->Base.API.GetProcAddress = GLX_eglGetProcAddress;
+   GLX_drv->Base.API.WaitClient = GLX_eglWaitClient;
+   GLX_drv->Base.API.WaitNative = GLX_eglWaitNative;
 
    GLX_drv->Base.Name = "GLX";
    GLX_drv->Base.Unload = GLX_Unload;
index 29617b7afff0b164eb1210a0438c6d1aa9590566..14cc5fa6137fad45b0206aac58f0c4a16f38b5c5 100644 (file)
@@ -9,12 +9,36 @@
  * heterogeneous hardware devices in the future.
  *
  * The EGLDisplay, EGLConfig, EGLContext and EGLSurface types are
- * opaque handles implemented with 32-bit unsigned integers.
- * It's up to the driver function or fallback function to look up the
- * handle and get an object.
- * By using opaque handles, we leave open the possibility of having
- * indirect rendering in the future, like GLX.
+ * opaque handles. Internal objects are linked to a display to
+ * create the handles.
  *
+ * For each public API entry point, the opaque handles are looked up
+ * before being dispatched to the drivers.  When it fails to look up
+ * a handle, one of
+ *
+ * EGL_BAD_DISPLAY
+ * EGL_BAD_CONFIG
+ * EGL_BAD_CONTEXT
+ * EGL_BAD_SURFACE
+ * EGL_BAD_SCREEN_MESA
+ * EGL_BAD_MODE_MESA
+ *
+ * is generated and the driver function is not called. An
+ * uninitialized EGLDisplay has no driver associated with it. When
+ * such display is detected,
+ *
+ * EGL_NOT_INITIALIZED
+ *
+ * is generated.
+ *
+ * Some of the entry points use current display, context, or surface
+ * implicitly.  For such entry points, the implicit objects are also
+ * checked before calling the driver function.  Other than the
+ * errors listed above,
+ *
+ * EGL_BAD_CURRENT_SURFACE
+ *
+ * may also be generated.
  *
  * Notes on naming conventions:
  *
@@ -92,8 +116,8 @@ eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
       snprintf(disp->Version, sizeof(disp->Version),
                "%d.%d (%s)", major_int, minor_int, drv->Name);
 
-      /* update the global notion of supported APIs */
-      _eglGlobal.ClientAPIsMask |= disp->ClientAPIsMask;
+      /* limit to APIs supported by core */
+      disp->ClientAPIsMask &= _EGL_API_ALL_BITS;
 
       disp->Driver = drv;
    } else {
@@ -496,15 +520,31 @@ eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
 EGLBoolean EGLAPIENTRY
 eglSwapInterval(EGLDisplay dpy, EGLint interval)
 {
+   _EGLContext *ctx = _eglGetCurrentContext();
+   _EGLSurface *surf;
    _EGL_DECLARE_DD(dpy);
-   return drv->API.SwapInterval(drv, disp, interval);
+
+   if (!ctx || !_eglIsContextLinked(ctx) || ctx->Display != disp)
+      return _eglError(EGL_BAD_CONTEXT, __FUNCTION__);
+
+   surf = ctx->DrawSurface;
+   if (!_eglIsSurfaceLinked(surf))
+      return _eglError(EGL_BAD_SURFACE, __FUNCTION__);
+
+   return drv->API.SwapInterval(drv, disp, surf, interval);
 }
 
 
 EGLBoolean EGLAPIENTRY
 eglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
 {
+   _EGLContext *ctx = _eglGetCurrentContext();
    _EGL_DECLARE_DD_AND_SURFACE(dpy, surface);
+
+   /* surface must be bound to current context in EGL 1.4 */
+   if (!ctx || !_eglIsContextLinked(ctx) || surf != ctx->DrawSurface)
+      return _eglError(EGL_BAD_SURFACE, __FUNCTION__);
+
    return drv->API.SwapBuffers(drv, disp, surf);
 }
 
@@ -518,32 +558,66 @@ eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, NativePixmapType target)
 
 
 EGLBoolean EGLAPIENTRY
-eglWaitGL(void)
+eglWaitClient(void)
 {
-   _EGLDisplay *disp = _eglGetCurrentDisplay();
+   _EGLContext *ctx = _eglGetCurrentContext();
+   _EGLDisplay *disp;
    _EGLDriver *drv;
 
-   if (!disp)
+   if (!ctx)
       return EGL_TRUE;
+   /* let bad current context imply bad current surface */
+   if (!_eglIsContextLinked(ctx) || !_eglIsSurfaceLinked(ctx->DrawSurface))
+      return _eglError(EGL_BAD_CURRENT_SURFACE, __FUNCTION__);
 
-   /* a current display is always initialized */
+   /* a valid current context implies an initialized current display */
+   disp = ctx->Display;
    drv = disp->Driver;
+   assert(drv);
 
-   return drv->API.WaitGL(drv, disp);
+   return drv->API.WaitClient(drv, disp, ctx);
+}
+
+
+EGLBoolean EGLAPIENTRY
+eglWaitGL(void)
+{
+#ifdef EGL_VERSION_1_2
+   _EGLThreadInfo *t = _eglGetCurrentThread();
+   EGLint api_index = t->CurrentAPIIndex;
+   EGLint es_index = _eglConvertApiToIndex(EGL_OPENGL_ES_API);
+   EGLBoolean ret;
+
+   if (api_index != es_index && _eglIsCurrentThreadDummy())
+      return _eglError(EGL_BAD_ALLOC, "eglWaitGL");
+
+   t->CurrentAPIIndex = es_index;
+   ret = eglWaitClient();
+   t->CurrentAPIIndex = api_index;
+   return ret;
+#else
+   return eglWaitClient();
+#endif
 }
 
 
 EGLBoolean EGLAPIENTRY
 eglWaitNative(EGLint engine)
 {
-   _EGLDisplay *disp = _eglGetCurrentDisplay();
+   _EGLContext *ctx = _eglGetCurrentContext();
+   _EGLDisplay *disp;
    _EGLDriver *drv;
 
-   if (!disp)
+   if (!ctx)
       return EGL_TRUE;
+   /* let bad current context imply bad current surface */
+   if (!_eglIsContextLinked(ctx) || !_eglIsSurfaceLinked(ctx->DrawSurface))
+      return _eglError(EGL_BAD_CURRENT_SURFACE, __FUNCTION__);
 
-   /* a current display is always initialized */
+   /* a valid current context implies an initialized current display */
+   disp = ctx->Display;
    drv = disp->Driver;
+   assert(drv);
 
    return drv->API.WaitNative(drv, disp, engine);
 }
@@ -568,8 +642,26 @@ eglGetCurrentContext(void)
 EGLSurface EGLAPIENTRY
 eglGetCurrentSurface(EGLint readdraw)
 {
-   _EGLSurface *s = _eglGetCurrentSurface(readdraw);
-   return _eglGetSurfaceHandle(s);
+   _EGLContext *ctx = _eglGetCurrentContext();
+   _EGLSurface *surf;
+
+   if (!ctx)
+      return EGL_NO_SURFACE;
+
+   switch (readdraw) {
+   case EGL_DRAW:
+      surf = ctx->DrawSurface;
+      break;
+   case EGL_READ:
+      surf = ctx->ReadSurface;
+      break;
+   default:
+      _eglError(EGL_BAD_PARAMETER, __FUNCTION__);
+      surf = NULL;
+      break;
+   }
+
+   return _eglGetSurfaceHandle(surf);
 }
 
 
@@ -586,43 +678,11 @@ eglGetError(void)
 
 void (* EGLAPIENTRY eglGetProcAddress(const char *procname))()
 {
-   typedef void (*genericFunc)();
-   struct name_function {
+   static const struct {
       const char *name;
       _EGLProc function;
-   };
-   static struct name_function egl_functions[] = {
-      /* alphabetical order */
-      { "eglBindTexImage", (_EGLProc) eglBindTexImage },
-      { "eglChooseConfig", (_EGLProc) eglChooseConfig },
-      { "eglCopyBuffers", (_EGLProc) eglCopyBuffers },
-      { "eglCreateContext", (_EGLProc) eglCreateContext },
-      { "eglCreatePbufferSurface", (_EGLProc) eglCreatePbufferSurface },
-      { "eglCreatePixmapSurface", (_EGLProc) eglCreatePixmapSurface },
-      { "eglCreateWindowSurface", (_EGLProc) eglCreateWindowSurface },
-      { "eglDestroyContext", (_EGLProc) eglDestroyContext },
-      { "eglDestroySurface", (_EGLProc) eglDestroySurface },
-      { "eglGetConfigAttrib", (_EGLProc) eglGetConfigAttrib },
-      { "eglGetConfigs", (_EGLProc) eglGetConfigs },
-      { "eglGetCurrentContext", (_EGLProc) eglGetCurrentContext },
-      { "eglGetCurrentDisplay", (_EGLProc) eglGetCurrentDisplay },
-      { "eglGetCurrentSurface", (_EGLProc) eglGetCurrentSurface },
-      { "eglGetDisplay", (_EGLProc) eglGetDisplay },
-      { "eglGetError", (_EGLProc) eglGetError },
-      { "eglGetProcAddress", (_EGLProc) eglGetProcAddress },
-      { "eglInitialize", (_EGLProc) eglInitialize },
-      { "eglMakeCurrent", (_EGLProc) eglMakeCurrent },
-      { "eglQueryContext", (_EGLProc) eglQueryContext },
-      { "eglQueryString", (_EGLProc) eglQueryString },
-      { "eglQuerySurface", (_EGLProc) eglQuerySurface },
-      { "eglReleaseTexImage", (_EGLProc) eglReleaseTexImage },
-      { "eglSurfaceAttrib", (_EGLProc) eglSurfaceAttrib },
-      { "eglSwapBuffers", (_EGLProc) eglSwapBuffers },
-      { "eglSwapInterval", (_EGLProc) eglSwapInterval },
-      { "eglTerminate", (_EGLProc) eglTerminate },
-      { "eglWaitGL", (_EGLProc) eglWaitGL },
-      { "eglWaitNative", (_EGLProc) eglWaitNative },
-      /* Extensions */
+   } egl_functions[] = {
+      /* extensions only */
 #ifdef EGL_MESA_screen_surface
       { "eglChooseModeMESA", (_EGLProc) eglChooseModeMESA },
       { "eglGetModesMESA", (_EGLProc) eglGetModesMESA },
@@ -637,22 +697,23 @@ void (* EGLAPIENTRY eglGetProcAddress(const char *procname))()
       { "eglQueryScreenModeMESA", (_EGLProc) eglQueryScreenModeMESA },
       { "eglQueryModeStringMESA", (_EGLProc) eglQueryModeStringMESA },
 #endif /* EGL_MESA_screen_surface */
-#ifdef EGL_VERSION_1_2
-      { "eglBindAPI", (_EGLProc) eglBindAPI },
-      { "eglCreatePbufferFromClientBuffer", (_EGLProc) eglCreatePbufferFromClientBuffer },
-      { "eglQueryAPI", (_EGLProc) eglQueryAPI },
-      { "eglReleaseThread", (_EGLProc) eglReleaseThread },
-      { "eglWaitClient", (_EGLProc) eglWaitClient },
-#endif /* EGL_VERSION_1_2 */
       { NULL, NULL }
    };
    EGLint i;
-   for (i = 0; egl_functions[i].name; i++) {
-      if (strcmp(egl_functions[i].name, procname) == 0) {
-         return (genericFunc) egl_functions[i].function;
+
+   if (!procname)
+      return NULL;
+   if (strncmp(procname, "egl", 3) == 0) {
+      for (i = 0; egl_functions[i].name; i++) {
+         if (strcmp(egl_functions[i].name, procname) == 0)
+            return egl_functions[i].function;
       }
    }
 
+   /* preload a driver if there isn't one */
+   if (!_eglGlobal.NumDrivers)
+      _eglPreloadDriver(NULL);
+
    /* now loop over drivers to query their procs */
    for (i = 0; i < _eglGlobal.NumDrivers; i++) {
       _EGLProc p = _eglGlobal.Drivers[i]->API.GetProcAddress(procname);
@@ -664,6 +725,9 @@ void (* EGLAPIENTRY eglGetProcAddress(const char *procname))()
 }
 
 
+#ifdef EGL_MESA_screen_surface
+
+
 /*
  * EGL_MESA_screen extension
  */
@@ -838,6 +902,9 @@ eglQueryModeStringMESA(EGLDisplay dpy, EGLModeMESA mode)
 }
 
 
+#endif /* EGL_MESA_screen_surface */
+
+
 /**
  ** EGL 1.2
  **/
@@ -867,33 +934,7 @@ eglBindAPI(EGLenum api)
    if (!_eglIsApiValid(api))
       return _eglError(EGL_BAD_PARAMETER, "eglBindAPI");
 
-   switch (api) {
-#ifdef EGL_VERSION_1_4
-   case EGL_OPENGL_API:
-      if (_eglGlobal.ClientAPIsMask & EGL_OPENGL_BIT) {
-         t->CurrentAPIIndex = _eglConvertApiToIndex(api);
-         return EGL_TRUE;
-      }
-      _eglError(EGL_BAD_PARAMETER, "eglBindAPI");
-      return EGL_FALSE;
-#endif
-   case EGL_OPENGL_ES_API:
-      if (_eglGlobal.ClientAPIsMask & (EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT)) {
-         t->CurrentAPIIndex = _eglConvertApiToIndex(api);
-         return EGL_TRUE;
-      }
-      _eglError(EGL_BAD_PARAMETER, "eglBindAPI");
-      return EGL_FALSE;
-   case EGL_OPENVG_API:
-      if (_eglGlobal.ClientAPIsMask & EGL_OPENVG_BIT) {
-         t->CurrentAPIIndex = _eglConvertApiToIndex(api);
-         return EGL_TRUE;
-      }
-      _eglError(EGL_BAD_PARAMETER, "eglBindAPI");
-      return EGL_FALSE;
-   default:
-      return EGL_FALSE;
-   }
+   t->CurrentAPIIndex = _eglConvertApiToIndex(api);
    return EGL_TRUE;
 }
 
@@ -951,20 +992,4 @@ eglReleaseThread(void)
 }
 
 
-EGLBoolean
-eglWaitClient(void)
-{
-   _EGLDisplay *disp = _eglGetCurrentDisplay();
-   _EGLDriver *drv;
-
-   if (!disp)
-      return EGL_TRUE;
-
-   /* a current display is always initialized */
-   drv = disp->Driver;
-
-   return drv->API.WaitClient(drv, disp);
-}
-
-
 #endif /* EGL_VERSION_1_2 */
index 6081e588928959ecca0f5d5a9973433763aa3b20..aa0abe3eb6bfdd3b0f068d4c85454d4f8816a825 100644 (file)
@@ -35,13 +35,13 @@ typedef EGLBoolean (*QuerySurface_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurf
 typedef EGLBoolean (*SurfaceAttrib_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLint attribute, EGLint value);
 typedef EGLBoolean (*BindTexImage_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLint buffer);
 typedef EGLBoolean (*ReleaseTexImage_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLint buffer);
-typedef EGLBoolean (*SwapInterval_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLint interval);
+typedef EGLBoolean (*SwapInterval_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint interval);
 typedef EGLBoolean (*SwapBuffers_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw);
 typedef EGLBoolean (*CopyBuffers_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, NativePixmapType target);
 
 /* misc funcs */
 typedef const char *(*QueryString_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLint name);
-typedef EGLBoolean (*WaitGL_t)(_EGLDriver *drv, _EGLDisplay *dpy);
+typedef EGLBoolean (*WaitClient_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx);
 typedef EGLBoolean (*WaitNative_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLint engine);
 
 typedef _EGLProc (*GetProcAddress_t)(const char *procname);
@@ -65,7 +65,6 @@ typedef const char * (*QueryModeStringMESA_t)(_EGLDriver *drv, _EGLDisplay *dpy,
 
 
 #ifdef EGL_VERSION_1_2
-typedef EGLBoolean (*WaitClient_t)(_EGLDriver *drv, _EGLDisplay *dpy);
 typedef _EGLSurface *(*CreatePbufferFromClientBuffer_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLenum buftype, EGLClientBuffer buffer, _EGLConfig *config, const EGLint *attrib_list);
 #endif /* EGL_VERSION_1_2 */
 
@@ -101,7 +100,7 @@ struct _egl_api
    CopyBuffers_t CopyBuffers;
 
    QueryString_t QueryString;
-   WaitGL_t WaitGL;
+   WaitClient_t WaitClient;
    WaitNative_t WaitNative;
    GetProcAddress_t GetProcAddress;
 
@@ -120,7 +119,6 @@ struct _egl_api
    QueryModeStringMESA_t QueryModeStringMESA;
 
 #ifdef EGL_VERSION_1_2
-   WaitClient_t WaitClient;
    CreatePbufferFromClientBuffer_t CreatePbufferFromClientBuffer;
 #endif
 };
index 6b639b75c6632076fd4c947875a5a59c9e33fe1f..f7c93f14ce22072f99c8ba04197511253c9dbdf3 100644 (file)
 #endif
 
 
+/**
+ * Function visibility
+ */
+#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303
+#  define PUBLIC __attribute__((visibility("default")))
+#else
+#  define PUBLIC
+#endif
+
+
 #endif /* EGLCOMPILER_INCLUDED */
index 2c8d1c4055bf475ff57bab49357da9d9f6ff6d40..31d69a770808e2463f87908c117a6fd3335630c3 100644 (file)
@@ -82,18 +82,17 @@ _eglAddConfig(_EGLDisplay *dpy, _EGLConfig *conf)
 EGLBoolean
 _eglCheckConfigHandle(EGLConfig config, _EGLDisplay *dpy)
 {
-   _EGLConfig *conf = NULL;
+   EGLint num_configs = (dpy) ? dpy->NumConfigs : 0;
    EGLint i;
 
-   for (i = 0; dpy && i < dpy->NumConfigs; i++) {
-      conf = dpy->Configs[i];
+   for (i = 0; i < num_configs; i++) {
+      _EGLConfig *conf = dpy->Configs[i];
       if (conf == (_EGLConfig *) config) {
          assert(conf->Display == dpy);
          break;
       }
    }
-
-   return (conf != NULL);
+   return (i < num_configs);
 }
 
 
index 6b8a259984e04f2e1efb3be2674bccf46c384eaa..799bf4ee2424e557a18d0195bc476e6b6633e4a1 100644 (file)
@@ -91,11 +91,11 @@ _eglSetConfigAttrib(_EGLConfig *conf, EGLint attr, EGLint val)
 }
 
 
-extern void
+PUBLIC void
 _eglInitConfig(_EGLConfig *config, EGLint id);
 
 
-extern EGLConfig
+PUBLIC EGLConfig
 _eglAddConfig(_EGLDisplay *dpy, _EGLConfig *conf);
 
 
@@ -144,24 +144,24 @@ _eglGetConfigHandle(_EGLConfig *conf)
 }
 
 
-extern EGLBoolean
+PUBLIC EGLBoolean
 _eglValidateConfig(const _EGLConfig *conf, EGLBoolean for_matching);
 
 
-extern EGLBoolean
+PUBLIC EGLBoolean
 _eglMatchConfig(const _EGLConfig *conf, const _EGLConfig *criteria);
 
 
-extern EGLBoolean
+PUBLIC EGLBoolean
 _eglParseConfigAttribList(_EGLConfig *conf, const EGLint *attrib_list);
 
 
-extern EGLint
+PUBLIC EGLint
 _eglCompareConfigs(const _EGLConfig *conf1, const _EGLConfig *conf2,
                    const _EGLConfig *criteria, EGLBoolean compare_id);
 
 
-extern void
+PUBLIC void
 _eglSortConfigs(const _EGLConfig **configs, EGLint count,
                 EGLint (*compare)(const _EGLConfig *, const _EGLConfig *,
                                   void *),
index a5fcdcd2876ebfceedf76b72f592cbb61e3564ad..36e94f0d2de841203db50eccb0e7951209594793 100644 (file)
@@ -102,7 +102,12 @@ _eglConfigFromContextModesRec(_EGLConfig *conf, const __GLcontextModes *m,
 
    SET_CONFIG_ATTRIB(conf, EGL_NATIVE_RENDERABLE, m->xRenderable);
    SET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_ID, m->visualID);
-   SET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_TYPE, m->visualType);
+
+   if (m->visualType != GLX_NONE)
+      SET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_TYPE, m->visualType);
+   else
+      SET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_TYPE, EGL_NONE);
+
    SET_CONFIG_ATTRIB(conf, EGL_RENDERABLE_TYPE, renderable_type);
    SET_CONFIG_ATTRIB(conf, EGL_SAMPLE_BUFFERS, m->sampleBuffers);
    SET_CONFIG_ATTRIB(conf, EGL_SAMPLES, m->samples);
index ad850798908e9d6d25c0e91e54b3ca90a6229e80..9f8906dedb65c8f99e2a81d92f957789c4cbd883 100644 (file)
@@ -2,21 +2,21 @@
 #define EGLCONFIGUTIL_INCLUDED
 
 
-#include "GLES/gl.h"
+#include "GL/gl.h"
 #include "GL/internal/glcore.h"
 #include "eglconfig.h"
 
 
-extern void
+PUBLIC void
 _eglConfigToContextModesRec(const _EGLConfig *config, __GLcontextModes *mode);
 
 
-extern EGLBoolean
+PUBLIC EGLBoolean
 _eglConfigFromContextModesRec(_EGLConfig *conf, const __GLcontextModes *m,
                               EGLint conformant, EGLint renderable_type);
 
 
-extern EGLBoolean
+PUBLIC EGLBoolean
 _eglFillInConfigs( _EGLConfig *configs,
                    EGLenum fb_format, EGLenum fb_type,
                    const uint8_t * depth_bits, const uint8_t * stencil_bits,
index 45c7b4717b7ab3bccc84e77337bee943ce5c2495..cb9e3f4a892584efc419981c188e71f0928f55ce 100644 (file)
@@ -30,7 +30,7 @@ struct _egl_context
 };
 
 
-extern EGLBoolean
+PUBLIC EGLBoolean
 _eglInitContext(_EGLDriver *drv, _EGLContext *ctx,
                 _EGLConfig *config, const EGLint *attrib_list);
 
@@ -47,7 +47,7 @@ extern EGLBoolean
 _eglQueryContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, EGLint attribute, EGLint *value);
 
 
-extern EGLBoolean
+PUBLIC EGLBoolean
 _eglMakeCurrent(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw, _EGLSurface *read, _EGLContext *ctx);
 
 
index 4431f964f69bce0e851b3bbb7d99d0a5ac261f3e..df506151b587cf98fab6e21a1d4f4ae70370e0d4 100644 (file)
@@ -9,14 +9,14 @@
 
 /* This should be kept in sync with _eglInitThreadInfo() */
 #define _EGL_THREAD_INFO_INITIALIZER \
-   { EGL_SUCCESS, { NULL }, 1 }
+   { EGL_SUCCESS, { NULL }, 0 }
 
 /* a fallback thread info to guarantee that every thread always has one */
 static _EGLThreadInfo dummy_thread = _EGL_THREAD_INFO_INITIALIZER;
 
 
 #ifdef GLX_USE_TLS
-static __thread const _EGLThreadInfo *_egl_TSD;
+static __thread const _EGLThreadInfo *_egl_TSD
    __attribute__ ((tls_model("initial-exec")));
 
 static INLINE void _eglSetTSD(const _EGLThreadInfo *t)
index 8eb241029eca096644bfa9d680fb749b7101ca04..c4478b389146049ecab3d4cd448cda982ff458b6 100644 (file)
@@ -4,8 +4,16 @@
 #include "egltypedefs.h"
 
 
-#define _EGL_API_NUM_INDICES \
-   (EGL_OPENGL_API - EGL_OPENGL_ES_API + 2) /* idx 0 is for EGL_NONE */
+#define _EGL_API_ALL_BITS \
+   (EGL_OPENGL_ES_BIT   | \
+    EGL_OPENVG_BIT      | \
+    EGL_OPENGL_ES2_BIT  | \
+    EGL_OPENGL_BIT)
+
+
+#define _EGL_API_FIRST_API EGL_OPENGL_ES_API
+#define _EGL_API_LAST_API EGL_OPENGL_API
+#define _EGL_API_NUM_APIS (_EGL_API_LAST_API - _EGL_API_FIRST_API + 1)
 
 
 /**
 struct _egl_thread_info
 {
    EGLint LastError;
-   _EGLContext *CurrentContexts[_EGL_API_NUM_INDICES];
+   _EGLContext *CurrentContexts[_EGL_API_NUM_APIS];
    /* use index for fast access to current context */
    EGLint CurrentAPIIndex;
 };
 
 
 /**
- * Return true if a client API enum can be converted to an index.
+ * Return true if a client API enum is recognized.
  */
 static INLINE EGLBoolean
 _eglIsApiValid(EGLenum api)
 {
-   return ((api >= EGL_OPENGL_ES_API && api <= EGL_OPENGL_API) ||
-           api == EGL_NONE);
+   return (api >= _EGL_API_FIRST_API && api <= _EGL_API_LAST_API);
 }
 
 
@@ -38,7 +45,7 @@ _eglIsApiValid(EGLenum api)
 static INLINE EGLint
 _eglConvertApiToIndex(EGLenum api)
 {
-   return (api != EGL_NONE) ? api - EGL_OPENGL_ES_API + 1 : 0;
+   return api - _EGL_API_FIRST_API;
 }
 
 
@@ -49,11 +56,11 @@ _eglConvertApiToIndex(EGLenum api)
 static INLINE EGLenum
 _eglConvertApiFromIndex(EGLint idx)
 {
-   return (idx) ? EGL_OPENGL_ES_API + idx - 1 : EGL_NONE;
+   return _EGL_API_FIRST_API + idx;
 }
 
 
-extern _EGLThreadInfo *
+PUBLIC _EGLThreadInfo *
 _eglGetCurrentThread(void);
 
 
@@ -65,19 +72,19 @@ extern EGLBoolean
 _eglIsCurrentThreadDummy(void);
 
 
-extern _EGLContext *
+PUBLIC _EGLContext *
 _eglGetCurrentContext(void);
 
 
-extern _EGLDisplay *
+PUBLIC _EGLDisplay *
 _eglGetCurrentDisplay(void);
 
 
-extern _EGLSurface *
+PUBLIC _EGLSurface *
 _eglGetCurrentSurface(EGLint readdraw);
 
 
-extern EGLBoolean
+PUBLIC EGLBoolean
 _eglError(EGLint errCode, const char *msg);
 
 
index ea4e35a8b3f6a84e7b1467abdcdc9b5f002d1a66..4f619e5371043672b54d8121a6e13363ac53a7e1 100644 (file)
@@ -78,11 +78,11 @@ extern _EGLDisplay *
 _eglFindDisplay(NativeDisplayType nativeDisplay);
 
 
-extern void
+PUBLIC void
 _eglReleaseDisplayResources(_EGLDriver *drv, _EGLDisplay *dpy);
 
 
-extern void
+PUBLIC void
 _eglCleanupDisplay(_EGLDisplay *disp);
 
 
index 87786e36bbf06ea82156607fe3fd73ea619c1645..018b06d3bea77022566413aa47e14fef8f6441f0 100644 (file)
 
 #if defined(_EGL_PLATFORM_X)
 #include <dlfcn.h>
-#elif defined(_EGL_PLATFORM_WINDOWS)
-/* Use static linking on Windows for now */
-#define WINDOWS_STATIC_LINK
 #endif
 
+
 /**
  * Wrappers for dlopen/dlclose()
  */
 #if defined(_EGL_PLATFORM_WINDOWS)
-#ifdef WINDOWS_STATIC_LINK
-   static const char *DefaultDriverName = "Windows EGL Static Library";
-#else
-   /* XXX Need to decide how to do dynamic name lookup on Windows */
-   static const char *DefaultDriverName = "TBD";
-#endif
-   typedef HMODULE lib_handle;
-
-   static HMODULE
-   open_library(const char *filename)
-   {
-#ifdef WINDOWS_STATIC_LINK
-      return 0;
-#else
-      return LoadLibrary(filename);
-#endif
-   }
 
-   static void
-   close_library(HMODULE lib)
-   {
-#ifdef WINDOWS_STATIC_LINK
-#else
-      FreeLibrary(lib);
-#endif
-   }
+
+/* XXX Need to decide how to do dynamic name lookup on Windows */
+static const char DefaultDriverName[] = "TBD";
+
+typedef HMODULE lib_handle;
+
+static HMODULE
+open_library(const char *filename)
+{
+   return LoadLibrary(filename);
+}
+
+static void
+close_library(HMODULE lib)
+{
+   FreeLibrary(lib);
+}
+
 
 #elif defined(_EGL_PLATFORM_X)
-   static const char *DefaultDriverName = "egl_softpipe";
 
-   typedef void * lib_handle;
 
-   static void *
-   open_library(const char *filename)
-   {
-      return dlopen(filename, RTLD_LAZY);
-   }
+static const char DefaultDriverName[] = "egl_softpipe";
+
+typedef void * lib_handle;
+
+static void *
+open_library(const char *filename)
+{
+   return dlopen(filename, RTLD_LAZY);
+}
+
+static void
+close_library(void *lib)
+{
+   dlclose(lib);
+}
+
+#else /* _EGL_PLATFORM_NO_OS */
+
+static const char DefaultDriverName[] = "builtin";
+
+typedef void *lib_handle;
+
+static INLINE void *
+open_library(const char *filename)
+{
+   return (void *) filename;
+}
+
+static INLINE void
+close_library(void *lib)
+{
+}
+
 
-   static void
-   close_library(void *lib)
-   {
-      dlclose(lib);
-   }
-   
 #endif
 
 
@@ -95,14 +106,22 @@ _eglChooseDriver(_EGLDisplay *dpy, char **argsRet)
       path = _eglstrdup(path);
 
 #if defined(_EGL_PLATFORM_X)
-   if (!path && dpy->NativeDisplay) {
+   if (!path && dpy && dpy->NativeDisplay) {
       /* assume (wrongly!) that the native display is a display string */
       path = _eglSplitDisplayString((const char *) dpy->NativeDisplay, &args);
    }
    suffix = "so";
 #elif defined(_EGL_PLATFORM_WINDOWS)
    suffix = "dll";
-#endif /* _EGL_PLATFORM_X */
+#else /* _EGL_PLATFORM_NO_OS */
+   if (path) {
+      /* force the use of the default driver */
+      _eglLog(_EGL_DEBUG, "ignore EGL_DRIVER");
+      free(path);
+      path = NULL;
+   }
+   suffix = NULL;
+#endif
 
    if (!path)
       path = _eglstrdup(DefaultDriverName);
@@ -136,43 +155,48 @@ _eglChooseDriver(_EGLDisplay *dpy, char **argsRet)
 static _EGLMain_t
 _eglOpenLibrary(const char *driverPath, lib_handle *handle)
 {
-   _EGLMain_t mainFunc;
    lib_handle lib;
+   _EGLMain_t mainFunc = NULL;
+   const char *error = "unknown error";
 
    assert(driverPath);
 
-#if defined(_EGL_PLATFORM_WINDOWS)
-/* Use static linking on Windows for now */
-#ifdef WINDOWS_STATIC_LINK
-   lib = 0;
-   mainFunc = (_EGLMain_t)_eglMain;
-#else
-   /* XXX untested */
    _eglLog(_EGL_DEBUG, "dlopen(%s)", driverPath);
    lib = open_library(driverPath);
-   if (!lib) {
-      _eglLog(_EGL_WARNING, "Could not open %s",
-              driverPath);
-      return NULL;
+
+#if defined(_EGL_PLATFORM_WINDOWS)
+   /* XXX untested */
+   if (lib)
+      mainFunc = (_EGLMain_t) GetProcAddress(lib, "_eglMain");
+#elif defined(_EGL_PLATFORM_X)
+   if (lib) {
+      mainFunc = (_EGLMain_t) dlsym(lib, "_eglMain");
+      if (!mainFunc)
+         error = dlerror();
+   }
+   else {
+      error = dlerror();
    }
-   mainFunc = (_EGLMain_t) GetProcAddress(lib, "_eglMain");
+#else /* _EGL_PLATFORM_NO_OS */
+   /* must be the default driver name */
+   if (strcmp(driverPath, DefaultDriverName) == 0)
+      mainFunc = (_EGLMain_t) _eglMain;
+   else
+      error = "not builtin driver";
 #endif
-#elif defined(_EGL_PLATFORM_X)
-   _eglLog(_EGL_DEBUG, "dlopen(%s)", driverPath);
-   lib = open_library(driverPath);
+
    if (!lib) {
-      _eglLog(_EGL_WARNING, "Could not open %s (%s)",
-              driverPath, dlerror());
+      _eglLog(_EGL_WARNING, "Could not open driver %s (%s)",
+              driverPath, error);
       if (!getenv("EGL_DRIVER"))
          _eglLog(_EGL_WARNING,
                  "The driver can be overridden by setting EGL_DRIVER");
       return NULL;
    }
-   mainFunc = (_EGLMain_t) dlsym(lib, "_eglMain");
-#endif
 
    if (!mainFunc) {
-      _eglLog(_EGL_WARNING, "_eglMain not found in %s", driverPath);
+      _eglLog(_EGL_WARNING, "_eglMain not found in %s (%s)",
+              driverPath, error);
       if (lib)
          close_library(lib);
       return NULL;
@@ -384,7 +408,7 @@ _eglInitDriverFallbacks(_EGLDriver *drv)
    drv->API.CopyBuffers = _eglCopyBuffers;
 
    drv->API.QueryString = _eglQueryString;
-   drv->API.WaitGL = _eglWaitGL;
+   drv->API.WaitClient = _eglWaitClient;
    drv->API.WaitNative = _eglWaitNative;
 
 #ifdef EGL_MESA_screen_surface
@@ -428,6 +452,11 @@ _eglFindAPIs(void)
    const char *es2_libname = "libGLESv2.so";
    const char *gl_libname = "libGL.so";
    const char *vg_libname = "libOpenVG.so";
+#else /* _EGL_PLATFORM_NO_OS */
+   const char *es1_libname = NULL;
+   const char *es2_libname = NULL;
+   const char *gl_libname = NULL;
+   const char *vg_libname = NULL;
 #endif
 
    if ((lib = open_library(es1_libname))) {
index 6c848eb35eab5f2fe72d7bd08c936ff5c68c8861..59bd1954aa87585e09fef23e305e44ee3230c13f 100644 (file)
@@ -25,7 +25,8 @@ struct _egl_driver
 };
 
 
-extern _EGLDriver *_eglMain(const char *args);
+PUBLIC _EGLDriver *
+_eglMain(const char *args);
 
 
 extern const char *
@@ -48,11 +49,11 @@ extern _EGLDriver *
 _eglLookupDriver(EGLDisplay d);
 
 
-extern void
+PUBLIC void
 _eglInitDriverFallbacks(_EGLDriver *drv);
 
 
-extern EGLint
+PUBLIC EGLint
 _eglFindAPIs(void);
 
 
index 3ae4c1ad3a3223a5814ab2f2a77159359319166e..443d0f072cfee087ea259d0fcca1f1d688f54b60 100644 (file)
@@ -15,13 +15,13 @@ struct _egl_global _eglGlobal =
    &_eglGlobalMutex,       /* Mutex */
    NULL,                   /* DisplayList */
    1,                      /* FreeScreenHandle */
-   0x0,                    /* ClientAPIsMask */
    0,                      /* NumDrivers */
    { NULL },               /* Drivers */
    2,                      /* NumAtExitCalls */
-   {                       /* AtExitCalls */
-      _eglFiniDisplay,
-      _eglUnloadDrivers
+   {
+      /* default AtExitCalls, called in reverse order */
+      _eglUnloadDrivers, /* always called last */
+      _eglFiniDisplay
    },
 };
 
index 58511076d452b1315eaa3dde873536d492523af6..5ebb914ca723c97af8730e7dc0b99ad16f3a60d5 100644 (file)
@@ -19,9 +19,6 @@ struct _egl_global
 
    EGLScreenMESA FreeScreenHandle;
 
-   /* bitmaks of supported APIs (supported by _some_ driver) */
-   EGLint ClientAPIsMask;
-
    EGLint NumDrivers;
    _EGLDriver *Drivers[10];
 
index 1d7a0a388c6923c88cacf782833b47c1944ccf9d..11a9bf7275cd3dcf76bb34a50003318b3ec75d4d 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+
 #include "egllog.h"
+#include "eglmutex.h"
 
 #define MAXSTRING 1000
-#define FALLBACK_LOG_LEVEL      _EGL_WARNING
-#define FALLBACK_LOG_LEVEL_STR  "warning"
+#define FALLBACK_LOG_LEVEL _EGL_WARNING
 
-static EGLint ReportingLevel = -1;
 
+static struct {
+   _EGLMutex mutex;
 
-static void
-log_level_initialize(void)
+   EGLBoolean initialized;
+   EGLint level;
+   _EGLLogProc logger;
+   EGLint num_messages;
+} logging = {
+   _EGL_MUTEX_INITIALIZER,
+   EGL_FALSE,
+   FALLBACK_LOG_LEVEL,
+   NULL,
+   0
+};
+
+static const char *level_strings[] = {
+   /* the order is important */
+   "fatal",
+   "warning",
+   "info",
+   "debug",
+   NULL
+};
+
+
+/**
+ * Set the function to be called when there is a message to log.
+ * Note that the function will be called with an internal lock held.
+ * Recursive logging is not allowed.
+ */
+void
+_eglSetLogProc(_EGLLogProc logger)
 {
-#if defined(_EGL_PLATFORM_X)  
-   char *log_env = getenv("EGL_LOG_LEVEL");
-#else
-   char *log_env = NULL;
-#endif
-
-   if (log_env == NULL) {
-      ReportingLevel = FALLBACK_LOG_LEVEL;
-   }
-   else if (strcasecmp(log_env, "fatal") == 0) {
-      ReportingLevel = _EGL_FATAL;
-   }
-   else if (strcasecmp(log_env, "warning") == 0) {
-      ReportingLevel = _EGL_WARNING;
+   EGLint num_messages = 0;
+
+   _eglLockMutex(&logging.mutex);
+
+   if (logging.logger != logger) {
+      logging.logger = logger;
+
+      num_messages = logging.num_messages;
+      logging.num_messages = 0;
    }
-   else if (strcasecmp(log_env, "info") == 0) {
-      ReportingLevel = _EGL_INFO;
+
+   _eglUnlockMutex(&logging.mutex);
+
+   if (num_messages)
+      _eglLog(_EGL_DEBUG,
+              "New logger installed. "
+              "Messages before the new logger might not be available.");
+}
+
+
+/**
+ * Set the log reporting level.
+ */
+void
+_eglSetLogLevel(EGLint level)
+{
+   switch (level) {
+   case _EGL_FATAL:
+   case _EGL_WARNING:
+   case _EGL_INFO:
+   case _EGL_DEBUG:
+      _eglLockMutex(&logging.mutex);
+      logging.level = level;
+      _eglUnlockMutex(&logging.mutex);
+      break;
+   default:
+      break;
    }
-   else if (strcasecmp(log_env, "debug") == 0) {
-      ReportingLevel = _EGL_DEBUG;
+}
+
+
+/**
+ * The default logger.  It prints the message to stderr.
+ */
+static void
+_eglDefaultLogger(EGLint level, const char *msg)
+{
+   fprintf(stderr, "libEGL %s: %s\n", level_strings[level], msg);
+}
+
+
+/**
+ * Initialize the logging facility.
+ */
+static void
+_eglInitLogger(void)
+{
+   const char *log_env;
+   EGLint i, level = -1;
+
+   if (logging.initialized)
+      return;
+
+   log_env = getenv("EGL_LOG_LEVEL");
+   if (log_env) {
+      for (i = 0; level_strings[i]; i++) {
+         if (strcasecmp(log_env, level_strings[i]) == 0) {
+            level = i;
+            break;
+         }
+      }
    }
    else {
-      fprintf(stderr, "Unrecognized EGL_LOG_LEVEL environment variable value. "
+      level = FALLBACK_LOG_LEVEL;
+   }
+
+   logging.logger = _eglDefaultLogger;
+   logging.level = (level >= 0) ? level : FALLBACK_LOG_LEVEL;
+   logging.initialized = EGL_TRUE;
+
+   /* it is fine to call _eglLog now */
+   if (log_env && level < 0) {
+      _eglLog(_EGL_WARNING,
+              "Unrecognized EGL_LOG_LEVEL environment variable value. "
               "Expected one of \"fatal\", \"warning\", \"info\", \"debug\". "
-              "Got \"%s\". Falling back to \"%s\".\n",
-              log_env, FALLBACK_LOG_LEVEL_STR);
-      ReportingLevel = FALLBACK_LOG_LEVEL;
+              "Got \"%s\". Falling back to \"%s\".",
+              log_env, level_strings[FALLBACK_LOG_LEVEL]);
    }
 }
 
 
 /**
- * Log a message to stderr.
+ * Log a message with message logger.
  * \param level one of _EGL_FATAL, _EGL_WARNING, _EGL_INFO, _EGL_DEBUG.
  */
 void
@@ -61,40 +150,26 @@ _eglLog(EGLint level, const char *fmtStr, ...)
 {
    va_list args;
    char msg[MAXSTRING];
-   const char *levelStr;
-   static int log_level_initialized = 0;
 
-   if (!log_level_initialized) {
-      log_level_initialize();
-      log_level_initialized = 1;
-   }
+   /* one-time initialization; a little race here is fine */
+   if (!logging.initialized)
+      _eglInitLogger();
+   if (level > logging.level || level < 0)
+      return;
 
-   if (level <= ReportingLevel) {
-      switch (level) {
-      case _EGL_FATAL:
-         levelStr = "Fatal";
-         break;
-      case _EGL_WARNING:
-         levelStr = "Warning";
-         break;
-      case _EGL_INFO:
-         levelStr = "Info";
-         break;
-      case _EGL_DEBUG:
-         levelStr = "Debug";
-         break;
-      default:
-         levelStr = "";
-      }
+   _eglLockMutex(&logging.mutex);
 
+   if (logging.logger) {
       va_start(args, fmtStr);
       vsnprintf(msg, MAXSTRING, fmtStr, args);
       va_end(args);
 
-      fprintf(stderr, "libEGL %s: %s\n", levelStr, msg);
-
-      if (level == _EGL_FATAL) {
-         exit(1); /* or abort()? */
-      }
+      logging.logger(level, msg);
+      logging.num_messages++;
    }
+
+   _eglUnlockMutex(&logging.mutex);
+
+   if (level == _EGL_FATAL)
+      exit(1); /* or abort()? */
 }
index 2fa352f155d43bad7d98497855fbad5177905fe4..3a99bfea4b759da8b2a01ec7a68d3c723cf3ecb6 100644 (file)
@@ -9,7 +9,18 @@
 #define _EGL_DEBUG   3   /* useful info for debugging */
 
 
-extern void
+typedef void (*_EGLLogProc)(EGLint level, const char *msg);
+
+
+PUBLIC void
+_eglSetLogProc(_EGLLogProc logger);
+
+
+PUBLIC void
+_eglSetLogLevel(EGLint level);
+
+
+PUBLIC void
 _eglLog(EGLint level, const char *fmtStr, ...);
 
 
index b37213faf1019d3e28f7ea5887069916de9c0e70..e66913320b237e41bba93e0d803d03b73c44f5fc 100644 (file)
@@ -108,11 +108,12 @@ _eglQueryString(_EGLDriver *drv, _EGLDisplay *dpy, EGLint name)
 
 
 EGLBoolean
-_eglWaitGL(_EGLDriver *drv, _EGLDisplay *dpy)
+_eglWaitClient(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx)
 {
    /* just a placeholder */
    (void) drv;
    (void) dpy;
+   (void) ctx;
    return EGL_TRUE;
 }
 
index a15c839be2b2d51b5473d2062f0aeb5ad807a25d..829d4cde792c7f171d70513943c0dafea383c6e4 100644 (file)
@@ -37,7 +37,7 @@ _eglQueryString(_EGLDriver *drv, _EGLDisplay *dpy, EGLint name);
 
 
 extern EGLBoolean
-_eglWaitGL(_EGLDriver *drv, _EGLDisplay *dpy);
+_eglWaitClient(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx);
 
 
 extern EGLBoolean
index af7c2c56d33c407f3a7a6f97d5b3a3c5ad1ee34d..a089a5e194349770ab45ee9083199468d5a4aefb 100644 (file)
@@ -29,7 +29,7 @@ extern _EGLMode *
 _eglLookupMode(EGLModeMESA mode, _EGLDisplay *dpy);
 
 
-extern _EGLMode *
+PUBLIC _EGLMode *
 _eglAddNewMode(_EGLScreen *screen, EGLint width, EGLint height,
                EGLint refreshRate, const char *name);
 
index 8860a2aa7f699104d27df12782498502577e2a81..d52e5388c3426f0e2e923c2cc3b2be3ed7b65c52 100644 (file)
@@ -30,7 +30,7 @@ extern EGLScreenMESA
 _eglAllocScreenHandle(void);
 
 
-extern void
+PUBLIC void
 _eglInitScreen(_EGLScreen *screen);
 
 
@@ -38,7 +38,7 @@ extern _EGLScreen *
 _eglLookupScreen(EGLScreenMESA screen, _EGLDisplay *dpy);
 
 
-extern void
+PUBLIC void
 _eglAddScreen(_EGLDisplay *display, _EGLScreen *screen);
 
 
@@ -83,7 +83,7 @@ extern void
 _eglDestroyScreenModes(_EGLScreen *scrn);
 
 
-extern void
+PUBLIC void
 _eglDestroyScreen(_EGLScreen *scrn);
 
 
index e7a1a8329e1807a24b15241e3807055a3ba01fb9..940a1b760cf1321844e7d52608deb464882f4580 100644 (file)
 #include "eglsurface.h"
 
 
+static void
+_eglClampSwapInterval(_EGLSurface *surf, EGLint interval)
+{
+   EGLint bound = GET_CONFIG_ATTRIB(surf->Config, EGL_MAX_SWAP_INTERVAL);
+   if (interval >= bound) {
+      interval = bound;
+   }
+   else {
+      bound = GET_CONFIG_ATTRIB(surf->Config, EGL_MIN_SWAP_INTERVAL);
+      if (interval < bound)
+         interval = bound;
+   }
+   surf->SwapInterval = interval;
+}
+
+
 /**
  * Do error check on parameters and initialize the given _EGLSurface object.
  * \return EGL_TRUE if no errors, EGL_FALSE otherwise.
@@ -194,7 +210,9 @@ _eglInitSurface(_EGLDriver *drv, _EGLSurface *surf, EGLint type,
    surf->TextureTarget = texTarget;
    surf->MipmapTexture = mipmapTex;
    surf->MipmapLevel = 0;
-   surf->SwapInterval = 0;
+   /* the default swap interval is 1 */
+   _eglClampSwapInterval(surf, 1);
+
 #ifdef EGL_VERSION_1_2
    surf->SwapBehavior = EGL_BUFFER_DESTROYED; /* XXX ok? */
    surf->HorizontalResolution = EGL_UNKNOWN; /* set by caller */
@@ -466,11 +484,10 @@ _eglReleaseTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface,
 
 
 EGLBoolean
-_eglSwapInterval(_EGLDriver *drv, _EGLDisplay *dpy, EGLint interval)
+_eglSwapInterval(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
+                 EGLint interval)
 {
-   _EGLSurface *surf = _eglGetCurrentSurface(EGL_DRAW);
-   if (surf)
-      surf->SwapInterval = interval;
+   _eglClampSwapInterval(surf, interval);
    return EGL_TRUE;
 }
 
index f6d44b5922e0c826548bf4fc9cc6c2d178b9a317..dacdf7e63ce742e661bb9341b2e13a403e69cf64 100644 (file)
@@ -40,7 +40,7 @@ struct _egl_surface
 };
 
 
-extern EGLBoolean
+PUBLIC EGLBoolean
 _eglInitSurface(_EGLDriver *drv, _EGLSurface *surf, EGLint type,
                 _EGLConfig *config, const EGLint *attrib_list);
 
@@ -86,7 +86,7 @@ _eglReleaseTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint
 
 
 extern EGLBoolean
-_eglSwapInterval(_EGLDriver *drv, _EGLDisplay *dpy, EGLint interval);
+_eglSwapInterval(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint interval);
 
 
 #ifdef EGL_VERSION_1_2
index 63983c52201ffcbd397a5fc50ec57749916d80d8..136423513c633ebc51b00267e740b1c8a56f578a 100644 (file)
@@ -54,13 +54,13 @@ install:
 ##### RULES #####
 
 .c.o:
-       $(CC) -c $(INCLUDES) $(CFLAGS) $(LIBRARY_DEFINES) $< -o $@
+       $(CC) -c $(INCLUDES) $(DEFINES) $(CFLAGS) $(LIBRARY_DEFINES) $< -o $@
 
 .cpp.o:
-       $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(LIBRARY_DEFINES) $< -o $@
+       $(CXX) -c $(INCLUDES) $(DEFINES) $(CXXFLAGS) $(LIBRARY_DEFINES) $< -o $@
 
 .S.o:
-       $(CC) -c $(INCLUDES) $(CFLAGS) $(LIBRARY_DEFINES)  $< -o $@
+       $(CC) -c $(INCLUDES) $(DEFINES) $(CFLAGS) $(LIBRARY_DEFINES)  $< -o $@
 
 
 sinclude depend
index 8be84cddbe727df6187556b9fdda6a12bb31633c..eea32b1314b1a28e4b906095a17c5f7bb14550a5 100644 (file)
@@ -2,29 +2,7 @@ import os
 
 Import('*')
 
-env = env.Clone()
-
-auxiliaries = []
-
-Export('auxiliaries')
-
-
-if llvm:
-       SConscript(['auxiliary/gallivm/SConscript'])
-
-SConscript([
-       # NOTE: order matters!
-       'auxiliary/util/SConscript',
-       'auxiliary/rtasm/SConscript',
-       'auxiliary/tgsi/SConscript',
-       'auxiliary/cso_cache/SConscript',
-       'auxiliary/translate/SConscript',
-       'auxiliary/draw/SConscript',
-       'auxiliary/pipebuffer/SConscript',
-       'auxiliary/indices/SConscript',
-       'auxiliary/rbug/SConscript',
-       'auxiliary/vl/SConscript',
-])
+SConscript('auxiliary/SConscript')
 
 for driver in env['drivers']:
        SConscript(os.path.join('drivers', driver, 'SConscript'))
index 5446eb68a985f445980df4a975591ce0c3bb0a15..e3af41c6e04486f77da9e6f039c06d511fa7fb6e 100644 (file)
-# src/gallium/auxiliary/Makefile
 TOP = ../../..
 include $(TOP)/configs/current
 
-SUBDIRS = $(GALLIUM_AUXILIARY_DIRS)
+LIBNAME = gallium
 
-default install clean:
-       @for dir in $(SUBDIRS) ; do \
-               if [ -d $$dir ] ; then \
-                       (cd $$dir && $(MAKE) $@) || exit 1; \
-               fi \
-       done
+C_SOURCES = \
+       cso_cache/cso_context.c \
+       cso_cache/cso_cache.c \
+       cso_cache/cso_hash.c \
+       draw/draw_context.c \
+       draw/draw_gs.c \
+       draw/draw_pipe.c \
+       draw/draw_pipe_aaline.c \
+       draw/draw_pipe_aapoint.c \
+       draw/draw_pipe_clip.c \
+       draw/draw_pipe_cull.c \
+       draw/draw_pipe_flatshade.c \
+       draw/draw_pipe_offset.c \
+       draw/draw_pipe_pstipple.c \
+       draw/draw_pipe_stipple.c \
+       draw/draw_pipe_twoside.c \
+       draw/draw_pipe_unfilled.c \
+       draw/draw_pipe_util.c \
+       draw/draw_pipe_validate.c \
+       draw/draw_pipe_vbuf.c \
+       draw/draw_pipe_wide_line.c \
+       draw/draw_pipe_wide_point.c \
+       draw/draw_pt.c \
+       draw/draw_pt_elts.c \
+       draw/draw_pt_emit.c \
+       draw/draw_pt_fetch.c \
+       draw/draw_pt_fetch_emit.c \
+       draw/draw_pt_fetch_shade_emit.c \
+       draw/draw_pt_fetch_shade_pipeline.c \
+       draw/draw_pt_post_vs.c \
+       draw/draw_pt_util.c \
+       draw/draw_pt_varray.c \
+       draw/draw_pt_vcache.c \
+       draw/draw_vertex.c \
+       draw/draw_vs.c \
+       draw/draw_vs_varient.c \
+       draw/draw_vs_aos.c \
+       draw/draw_vs_aos_io.c \
+       draw/draw_vs_aos_machine.c \
+       draw/draw_vs_exec.c \
+       draw/draw_vs_llvm.c \
+       draw/draw_vs_ppc.c \
+       draw/draw_vs_sse.c \
+       indices/u_indices_gen.c \
+       indices/u_unfilled_gen.c \
+       pipebuffer/pb_buffer_fenced.c \
+       pipebuffer/pb_buffer_malloc.c \
+       pipebuffer/pb_bufmgr_alt.c \
+       pipebuffer/pb_bufmgr_cache.c \
+       pipebuffer/pb_bufmgr_debug.c \
+       pipebuffer/pb_bufmgr_fenced.c \
+       pipebuffer/pb_bufmgr_mm.c \
+       pipebuffer/pb_bufmgr_ondemand.c \
+       pipebuffer/pb_bufmgr_pool.c \
+       pipebuffer/pb_bufmgr_slab.c \
+       pipebuffer/pb_validate.c \
+       rbug/rbug_connection.c \
+       rbug/rbug_core.c \
+       rbug/rbug_texture.c \
+       rbug/rbug_context.c \
+       rbug/rbug_shader.c \
+       rbug/rbug_demarshal.c \
+       rtasm/rtasm_cpu.c \
+       rtasm/rtasm_execmem.c \
+       rtasm/rtasm_x86sse.c \
+       rtasm/rtasm_ppc.c \
+       rtasm/rtasm_ppc_spe.c \
+       tgsi/tgsi_sanity.c \
+       tgsi/tgsi_build.c \
+       tgsi/tgsi_dump.c \
+       tgsi/tgsi_exec.c \
+       tgsi/tgsi_info.c \
+       tgsi/tgsi_iterate.c \
+       tgsi/tgsi_parse.c \
+       tgsi/tgsi_ppc.c \
+       tgsi/tgsi_scan.c \
+       tgsi/tgsi_sse2.c \
+       tgsi/tgsi_text.c \
+       tgsi/tgsi_transform.c \
+       tgsi/tgsi_ureg.c \
+       tgsi/tgsi_util.c \
+       translate/translate_generic.c \
+       translate/translate_sse.c \
+       translate/translate.c \
+       translate/translate_cache.c \
+       util/u_debug.c \
+       util/u_debug_dump.c \
+       util/u_debug_symbol.c \
+       util/u_debug_stack.c \
+       util/u_blit.c \
+       util/u_blitter.c \
+       util/u_cache.c \
+       util/u_cpu_detect.c \
+       util/u_dl.c \
+       util/u_draw_quad.c \
+       util/u_format.c \
+       util/u_format_access.c \
+       util/u_format_table.c \
+       util/u_gen_mipmap.c \
+       util/u_handle_table.c \
+       util/u_hash_table.c \
+       util/u_hash.c \
+       util/u_keymap.c \
+       util/u_linear.c \
+       util/u_network.c \
+       util/u_math.c \
+       util/u_mm.c \
+       util/u_rect.c \
+       util/u_simple_shaders.c \
+       util/u_snprintf.c \
+       util/u_stream_stdc.c \
+       util/u_stream_wd.c \
+       util/u_surface.c \
+       util/u_texture.c \
+       util/u_tile.c \
+       util/u_time.c \
+       util/u_timed_winsys.c \
+       util/u_upload_mgr.c \
+       util/u_simple_screen.c \
+       vl/vl_bitstream_parser.c \
+       vl/vl_mpeg12_mc_renderer.c \
+       vl/vl_compositor.c \
+       vl/vl_csc.c \
+       vl/vl_shader_build.c
+
+GALLIVM_SOURCES = \
+       gallivm/gallivm.cpp  \
+       gallivm/gallivm_cpu.cpp \
+       gallivm/instructions.cpp  \
+       gallivm/loweringpass.cpp \
+       gallivm/tgsitollvm.cpp \
+       gallivm/storage.cpp \
+       gallivm/storagesoa.cpp \
+       gallivm/instructionssoa.cpp
+
+INC_SOURCES = \
+       gallivm/gallivm_builtins.cpp \
+       gallivm/gallivmsoabuiltins.cpp
+
+# XXX: gallivm doesn't build correctly so disable for now
+#ifeq ($(MESA_LLVM),1)
+#DEFINES += -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS
+#CPP_SOURCES += \
+#      $(GALLIVM_SOURCES)
+#endif
+
+
+include ../Makefile.template
+
+
+gallivm/gallivm_builtins.cpp: gallivm/llvm_builtins.c
+       clang --emit-llvm < $< |llvm-as|opt -std-compile-opts > temp1.bin
+       (echo "static const unsigned char llvm_builtins_data[] = {"; od -txC temp1.bin | sed -e "s/^[0-9]*//" -e s"/ \([0-9a-f][0-9a-f]\)/0x\1,/g" -e"\$$d" | sed -e"\$$s/,$$/,0x00};/") >$@
+       rm temp1.bin
+
+gallivm/gallivmsoabuiltins.cpp: gallivm/soabuiltins.c
+       clang --emit-llvm < $< |llvm-as|opt -std-compile-opts > temp2.bin
+       (echo "static const unsigned char soabuiltins_data[] = {"; od -txC temp2.bin | sed -e "s/^[0-9]*//" -e s"/ \([0-9a-f][0-9a-f]\)/0x\1,/g" -e"\$$d" | sed -e"\$$s/,$$/,0x00};/") >$@
+       rm temp2.bin
+
+
+indices/u_indices_gen.c: indices/u_indices_gen.py
+       python $< > $@
+
+indices/u_unfilled_gen.c: indices/u_unfilled_gen.py
+       python $< > $@
+
+util/u_format_table.c: util/u_format_table.py util/u_format_parse.py util/u_format.csv
+       python util/u_format_table.py util/u_format.csv > $@
+
+util/u_format_access.c: util/u_format_access.py util/u_format_parse.py util/u_format.csv
+       python util/u_format_access.py util/u_format.csv > $@
diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript
new file mode 100644 (file)
index 0000000..782eb53
--- /dev/null
@@ -0,0 +1,185 @@
+Import('*')
+
+from sys import executable as python_cmd
+
+env.Append(CPPPATH = [
+    'indices',
+    'util',
+])
+
+env.CodeGenerate(
+    target = 'indices/u_indices_gen.c', 
+    script = 'indices/u_indices_gen.py', 
+    source = [],
+    command = python_cmd + ' $SCRIPT > $TARGET'
+)
+
+env.CodeGenerate(
+    target = 'indices/u_unfilled_gen.c', 
+    script = 'indices/u_unfilled_gen.py', 
+    source = [],
+    command = python_cmd + ' $SCRIPT > $TARGET'
+)
+
+env.CodeGenerate(
+    target = 'util/u_format_table.c',
+    script = 'util/u_format_table.py',
+    source = ['util/u_format.csv'],
+    command = 'python $SCRIPT $SOURCE > $TARGET'
+)
+
+env.CodeGenerate(
+    target = 'util/u_format_access.c',
+    script = 'util/u_format_access.py',
+    source = ['util/u_format.csv'],
+    command = 'python $SCRIPT $SOURCE > $TARGET'
+)
+
+source = [
+    'cso_cache/cso_context.c',
+    'cso_cache/cso_cache.c',
+    'cso_cache/cso_hash.c',
+    'draw/draw_context.c',
+    'draw/draw_pipe.c',
+    'draw/draw_pipe_aaline.c',
+    'draw/draw_pipe_aapoint.c',
+    'draw/draw_pipe_clip.c',
+    'draw/draw_pipe_cull.c',
+    'draw/draw_pipe_flatshade.c',
+    'draw/draw_pipe_offset.c',
+    'draw/draw_pipe_pstipple.c',
+    'draw/draw_pipe_stipple.c',
+    'draw/draw_pipe_twoside.c',
+    'draw/draw_pipe_unfilled.c',
+    'draw/draw_pipe_util.c',
+    'draw/draw_pipe_validate.c',
+    'draw/draw_pipe_vbuf.c',
+    'draw/draw_pipe_wide_line.c',
+    'draw/draw_pipe_wide_point.c',
+    'draw/draw_pt.c',
+    'draw/draw_pt_elts.c',
+    'draw/draw_pt_emit.c',
+    'draw/draw_pt_fetch.c',
+    'draw/draw_pt_fetch_emit.c',
+    'draw/draw_pt_fetch_shade_emit.c',
+    'draw/draw_pt_fetch_shade_pipeline.c',
+    'draw/draw_pt_post_vs.c',
+    'draw/draw_pt_util.c',
+    'draw/draw_pt_varray.c',
+    'draw/draw_pt_vcache.c',
+    'draw/draw_vertex.c',
+    'draw/draw_vs.c',
+    'draw/draw_vs_aos.c',
+    'draw/draw_vs_aos_io.c',
+    'draw/draw_vs_aos_machine.c',
+    'draw/draw_vs_exec.c',
+    'draw/draw_vs_llvm.c',
+    'draw/draw_vs_ppc.c',
+    'draw/draw_vs_sse.c',
+    'draw/draw_vs_varient.c',
+    'draw/draw_gs.c',
+    #'indices/u_indices.c',
+    #'indices/u_unfilled_indices.c',
+    'indices/u_indices_gen.c',
+    'indices/u_unfilled_gen.c',
+    'pipebuffer/pb_buffer_fenced.c',
+    'pipebuffer/pb_buffer_malloc.c',
+    'pipebuffer/pb_bufmgr_alt.c',
+    'pipebuffer/pb_bufmgr_cache.c',
+    'pipebuffer/pb_bufmgr_debug.c',
+    'pipebuffer/pb_bufmgr_fenced.c',
+    'pipebuffer/pb_bufmgr_mm.c',
+    'pipebuffer/pb_bufmgr_ondemand.c',
+    'pipebuffer/pb_bufmgr_pool.c',
+    'pipebuffer/pb_bufmgr_slab.c',
+    'pipebuffer/pb_validate.c',
+    'rbug/rbug_core.c',
+    'rbug/rbug_shader.c',
+    'rbug/rbug_context.c',
+    'rbug/rbug_texture.c',
+    'rbug/rbug_demarshal.c',
+    'rbug/rbug_connection.c',
+    'rtasm/rtasm_cpu.c',
+    'rtasm/rtasm_execmem.c',
+    'rtasm/rtasm_x86sse.c',
+    'rtasm/rtasm_ppc.c',
+    'rtasm/rtasm_ppc_spe.c',
+    'tgsi/tgsi_build.c',
+    'tgsi/tgsi_dump.c',
+    'tgsi/tgsi_dump_c.c',
+    'tgsi/tgsi_exec.c',
+    'tgsi/tgsi_info.c',
+    'tgsi/tgsi_iterate.c',
+    'tgsi/tgsi_parse.c',
+    'tgsi/tgsi_sanity.c',
+    'tgsi/tgsi_scan.c',
+    'tgsi/tgsi_ppc.c',
+    'tgsi/tgsi_sse2.c',
+    'tgsi/tgsi_text.c',
+    'tgsi/tgsi_transform.c',
+    'tgsi/tgsi_ureg.c',
+    'tgsi/tgsi_util.c',
+    'translate/translate_generic.c',
+    'translate/translate_sse.c',
+    'translate/translate.c',
+    'translate/translate_cache.c',
+    'util/u_bitmask.c',
+    'util/u_blit.c',
+    'util/u_blitter.c',
+    'util/u_cache.c',
+    'util/u_cpu_detect.c',
+    'util/u_debug.c',
+    'util/u_debug_dump.c',
+    'util/u_debug_memory.c',
+    'util/u_debug_stack.c',
+    'util/u_debug_symbol.c',
+    'util/u_dl.c',
+    'util/u_draw_quad.c',
+    'util/u_format.c',
+    'util/u_format_access.c',
+    'util/u_format_table.c',
+    'util/u_gen_mipmap.c',
+    'util/u_handle_table.c',
+    'util/u_hash.c',
+    'util/u_hash_table.c',
+    'util/u_keymap.c',
+    'util/u_network.c',
+    'util/u_math.c',
+    'util/u_mm.c',
+    'util/u_rect.c',
+    'util/u_simple_shaders.c',
+    'util/u_snprintf.c',
+    'util/u_stream_stdc.c',
+    'util/u_stream_wd.c',
+    'util/u_surface.c',
+    'util/u_texture.c',
+    'util/u_tile.c',
+    'util/u_time.c',
+    'util/u_timed_winsys.c',
+    'util/u_upload_mgr.c',
+    'util/u_simple_screen.c',
+    'vl/vl_bitstream_parser.c',
+    'vl/vl_mpeg12_mc_renderer.c',
+    'vl/vl_compositor.c',
+    'vl/vl_csc.c',
+    'vl/vl_shader_build.c',
+]
+
+if env['llvm']:
+    source += [
+        'gallivm/gallivm.cpp',
+        'gallivm/gallivm_cpu.cpp',
+        'gallivm/instructions.cpp',
+        'gallivm/loweringpass.cpp',
+        'gallivm/tgsitollvm.cpp',
+        'gallivm/storage.cpp',
+        'gallivm/storagesoa.cpp',
+        'gallivm/instructionssoa.cpp',
+    ]
+
+gallium = env.ConvenienceLibrary(
+    target = 'gallium',
+    source = source,
+)
+
+Export('gallium')
diff --git a/src/gallium/auxiliary/cso_cache/Makefile b/src/gallium/auxiliary/cso_cache/Makefile
deleted file mode 100644 (file)
index 8726afc..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = cso_cache
-
-C_SOURCES = \
-       cso_context.c \
-       cso_cache.c \
-       cso_hash.c
-
-include ../../Makefile.template
diff --git a/src/gallium/auxiliary/cso_cache/SConscript b/src/gallium/auxiliary/cso_cache/SConscript
deleted file mode 100644 (file)
index 651e68a..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-Import('*')
-
-cso_cache = env.ConvenienceLibrary(
-       target = 'cso_cache',
-       source = [
-               'cso_context.c',
-               'cso_cache.c',
-               'cso_hash.c',
-       ])
-
-auxiliaries.insert(0, cso_cache)
index 4f13b3e2baddf4935c0e74c5bd3350a4e2902844..2b16332e14324e1fed46ff50e28e4a823bc557a4 100644 (file)
@@ -42,6 +42,7 @@
 #include "cso_cache/cso_context.h"
 #include "cso_cache/cso_cache.h"
 #include "cso_cache/cso_hash.h"
+#include "cso_context.h"
 
 struct cso_context {
    struct pipe_context *pipe;
@@ -50,28 +51,43 @@ struct cso_context {
    struct {
       void *samplers[PIPE_MAX_SAMPLERS];
       unsigned nr_samplers;
+
+      void *vertex_samplers[PIPE_MAX_VERTEX_SAMPLERS];
+      unsigned nr_vertex_samplers;
    } hw;
 
    void *samplers[PIPE_MAX_SAMPLERS];
    unsigned nr_samplers;
 
+   void *vertex_samplers[PIPE_MAX_VERTEX_SAMPLERS];
+   unsigned nr_vertex_samplers;
+
    unsigned nr_samplers_saved;
    void *samplers_saved[PIPE_MAX_SAMPLERS];
 
+   unsigned nr_vertex_samplers_saved;
+   void *vertex_samplers_saved[PIPE_MAX_VERTEX_SAMPLERS];
+
    struct pipe_texture *textures[PIPE_MAX_SAMPLERS];
    uint nr_textures;
 
+   struct pipe_texture *vertex_textures[PIPE_MAX_VERTEX_SAMPLERS];
+   uint nr_vertex_textures;
+
    uint nr_textures_saved;
    struct pipe_texture *textures_saved[PIPE_MAX_SAMPLERS];
 
+   uint nr_vertex_textures_saved;
+   struct pipe_texture *vertex_textures_saved[PIPE_MAX_SAMPLERS];
+
    /** Current and saved state.
     * The saved state is used as a 1-deep stack.
     */
    void *blend, *blend_saved;
    void *depth_stencil, *depth_stencil_saved;
    void *rasterizer, *rasterizer_saved;
-   void *fragment_shader, *fragment_shader_saved;
-   void *vertex_shader, *vertex_shader_saved;
+   void *fragment_shader, *fragment_shader_saved, *geometry_shader;
+   void *vertex_shader, *vertex_shader_saved, *geometry_shader_saved;
 
    struct pipe_framebuffer_state fb, fb_saved;
    struct pipe_viewport_state vp, vp_saved;
@@ -244,7 +260,9 @@ void cso_release_all( struct cso_context *ctx )
    if (ctx->pipe) {
       ctx->pipe->bind_blend_state( ctx->pipe, NULL );
       ctx->pipe->bind_rasterizer_state( ctx->pipe, NULL );
-      ctx->pipe->bind_sampler_states( ctx->pipe, 0, NULL );
+      ctx->pipe->bind_fragment_sampler_states( ctx->pipe, 0, NULL );
+      if (ctx->pipe->bind_vertex_sampler_states)
+         ctx->pipe->bind_vertex_sampler_states(ctx->pipe, 0, NULL);
       ctx->pipe->bind_depth_stencil_alpha_state( ctx->pipe, NULL );
       ctx->pipe->bind_fs_state( ctx->pipe, NULL );
       ctx->pipe->bind_vs_state( ctx->pipe, NULL );
@@ -255,6 +273,11 @@ void cso_release_all( struct cso_context *ctx )
       pipe_texture_reference(&ctx->textures_saved[i], NULL);
    }
 
+   for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
+      pipe_texture_reference(&ctx->vertex_textures[i], NULL);
+      pipe_texture_reference(&ctx->vertex_textures_saved[i], NULL);
+   }
+
    free_framebuffer_state(&ctx->fb);
    free_framebuffer_state(&ctx->fb_saved);
 
@@ -378,6 +401,46 @@ enum pipe_error cso_single_sampler(struct cso_context *ctx,
    return PIPE_OK;
 }
 
+enum pipe_error
+cso_single_vertex_sampler(struct cso_context *ctx,
+                          unsigned idx,
+                          const struct pipe_sampler_state *templ)
+{
+   void *handle = NULL;
+
+   if (templ != NULL) {
+      unsigned hash_key = cso_construct_key((void*)templ, sizeof(struct pipe_sampler_state));
+      struct cso_hash_iter iter = cso_find_state_template(ctx->cache,
+                                                          hash_key, CSO_SAMPLER,
+                                                          (void*)templ);
+
+      if (cso_hash_iter_is_null(iter)) {
+         struct cso_sampler *cso = MALLOC(sizeof(struct cso_sampler));
+         if (!cso)
+            return PIPE_ERROR_OUT_OF_MEMORY;
+
+         memcpy(&cso->state, templ, sizeof(*templ));
+         cso->data = ctx->pipe->create_sampler_state(ctx->pipe, &cso->state);
+         cso->delete_state = (cso_state_callback)ctx->pipe->delete_sampler_state;
+         cso->context = ctx->pipe;
+
+         iter = cso_insert_state(ctx->cache, hash_key, CSO_SAMPLER, cso);
+         if (cso_hash_iter_is_null(iter)) {
+            FREE(cso);
+            return PIPE_ERROR_OUT_OF_MEMORY;
+         }
+
+         handle = cso->data;
+      }
+      else {
+         handle = ((struct cso_sampler *)cso_hash_iter_data(iter))->data;
+      }
+   }
+
+   ctx->vertex_samplers[idx] = handle;
+   return PIPE_OK;
+}
+
 void cso_single_sampler_done( struct cso_context *ctx )
 {
    unsigned i;
@@ -398,7 +461,36 @@ void cso_single_sampler_done( struct cso_context *ctx )
       memcpy(ctx->hw.samplers, ctx->samplers, ctx->nr_samplers * sizeof(void *));
       ctx->hw.nr_samplers = ctx->nr_samplers;
 
-      ctx->pipe->bind_sampler_states(ctx->pipe, ctx->nr_samplers, ctx->samplers);
+      ctx->pipe->bind_fragment_sampler_states(ctx->pipe, ctx->nr_samplers, ctx->samplers);
+   }
+}
+
+void
+cso_single_vertex_sampler_done(struct cso_context *ctx)
+{
+   unsigned i;
+
+   /* find highest non-null sampler */
+   for (i = PIPE_MAX_VERTEX_SAMPLERS; i > 0; i--) {
+      if (ctx->vertex_samplers[i - 1] != NULL)
+         break;
+   }
+
+   ctx->nr_vertex_samplers = i;
+
+   if (ctx->hw.nr_vertex_samplers != ctx->nr_vertex_samplers ||
+       memcmp(ctx->hw.vertex_samplers,
+              ctx->vertex_samplers,
+              ctx->nr_vertex_samplers * sizeof(void *)) != 0) 
+   {
+      memcpy(ctx->hw.vertex_samplers,
+             ctx->vertex_samplers,
+             ctx->nr_vertex_samplers * sizeof(void *));
+      ctx->hw.nr_vertex_samplers = ctx->nr_vertex_samplers;
+
+      ctx->pipe->bind_vertex_sampler_states(ctx->pipe,
+                                            ctx->nr_vertex_samplers,
+                                            ctx->vertex_samplers);
    }
 }
 
@@ -447,6 +539,21 @@ void cso_restore_samplers(struct cso_context *ctx)
    cso_single_sampler_done( ctx );
 }
 
+void
+cso_save_vertex_samplers(struct cso_context *ctx)
+{
+   ctx->nr_vertex_samplers_saved = ctx->nr_vertex_samplers;
+   memcpy(ctx->vertex_samplers_saved, ctx->vertex_samplers, sizeof(ctx->vertex_samplers));
+}
+
+void
+cso_restore_vertex_samplers(struct cso_context *ctx)
+{
+   ctx->nr_vertex_samplers = ctx->nr_vertex_samplers_saved;
+   memcpy(ctx->vertex_samplers, ctx->vertex_samplers_saved, sizeof(ctx->vertex_samplers));
+   cso_single_vertex_sampler_done(ctx);
+}
+
 
 enum pipe_error cso_set_sampler_textures( struct cso_context *ctx,
                                           uint count,
@@ -461,7 +568,7 @@ enum pipe_error cso_set_sampler_textures( struct cso_context *ctx,
    for ( ; i < PIPE_MAX_SAMPLERS; i++)
       pipe_texture_reference(&ctx->textures[i], NULL);
 
-   ctx->pipe->set_sampler_textures(ctx->pipe, count, textures);
+   ctx->pipe->set_fragment_sampler_textures(ctx->pipe, count, textures);
 
    return PIPE_OK;
 }
@@ -491,13 +598,71 @@ void cso_restore_sampler_textures( struct cso_context *ctx )
    for ( ; i < PIPE_MAX_SAMPLERS; i++)
       pipe_texture_reference(&ctx->textures[i], NULL);
 
-   ctx->pipe->set_sampler_textures(ctx->pipe, ctx->nr_textures, ctx->textures);
+   ctx->pipe->set_fragment_sampler_textures(ctx->pipe, ctx->nr_textures, ctx->textures);
 
    ctx->nr_textures_saved = 0;
 }
 
 
 
+enum pipe_error
+cso_set_vertex_sampler_textures(struct cso_context *ctx,
+                                uint count,
+                                struct pipe_texture **textures)
+{
+   uint i;
+
+   ctx->nr_vertex_textures = count;
+
+   for (i = 0; i < count; i++) {
+      pipe_texture_reference(&ctx->vertex_textures[i], textures[i]);
+   }
+   for ( ; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
+      pipe_texture_reference(&ctx->vertex_textures[i], NULL);
+   }
+
+   ctx->pipe->set_vertex_sampler_textures(ctx->pipe, count, textures);
+
+   return PIPE_OK;
+}
+
+void
+cso_save_vertex_sampler_textures(struct cso_context *ctx)
+{
+   uint i;
+
+   ctx->nr_vertex_textures_saved = ctx->nr_vertex_textures;
+   for (i = 0; i < ctx->nr_vertex_textures; i++) {
+      assert(!ctx->vertex_textures_saved[i]);
+      pipe_texture_reference(&ctx->vertex_textures_saved[i], ctx->vertex_textures[i]);
+   }
+}
+
+void
+cso_restore_vertex_sampler_textures(struct cso_context *ctx)
+{
+   uint i;
+
+   ctx->nr_vertex_textures = ctx->nr_vertex_textures_saved;
+
+   for (i = 0; i < ctx->nr_vertex_textures; i++) {
+      pipe_texture_reference(&ctx->vertex_textures[i], NULL);
+      ctx->vertex_textures[i] = ctx->vertex_textures_saved[i];
+      ctx->vertex_textures_saved[i] = NULL;
+   }
+   for ( ; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
+      pipe_texture_reference(&ctx->vertex_textures[i], NULL);
+   }
+
+   ctx->pipe->set_vertex_sampler_textures(ctx->pipe,
+                                          ctx->nr_vertex_textures,
+                                          ctx->vertex_textures);
+
+   ctx->nr_vertex_textures_saved = 0;
+}
+
+
+
 enum pipe_error cso_set_depth_stencil_alpha(struct cso_context *ctx,
                                             const struct pipe_depth_stencil_alpha_state *templ)
 {
@@ -863,3 +1028,38 @@ enum pipe_error cso_set_blend_color(struct cso_context *ctx,
    }
    return PIPE_OK;
 }
+
+enum pipe_error cso_set_geometry_shader_handle(struct cso_context *ctx,
+                                               void *handle)
+{
+   if (ctx->geometry_shader != handle) {
+      ctx->geometry_shader = handle;
+      ctx->pipe->bind_gs_state(ctx->pipe, handle);
+   }
+   return PIPE_OK;
+}
+
+void cso_delete_geometry_shader(struct cso_context *ctx, void *handle)
+{
+    if (handle == ctx->geometry_shader) {
+      /* unbind before deleting */
+      ctx->pipe->bind_gs_state(ctx->pipe, NULL);
+      ctx->geometry_shader = NULL;
+   }
+   ctx->pipe->delete_gs_state(ctx->pipe, handle);
+}
+
+void cso_save_geometry_shader(struct cso_context *ctx)
+{
+   assert(!ctx->geometry_shader_saved);
+   ctx->geometry_shader_saved = ctx->geometry_shader;
+}
+
+void cso_restore_geometry_shader(struct cso_context *ctx)
+{
+   if (ctx->geometry_shader_saved != ctx->geometry_shader) {
+      ctx->pipe->bind_gs_state(ctx->pipe, ctx->geometry_shader_saved);
+      ctx->geometry_shader = ctx->geometry_shader_saved;
+   }
+   ctx->geometry_shader_saved = NULL;
+}
index b04e98bfa12903346c5822527cad585721a483c2..b9e313e32d6cff726c975a6469d862b16b6836b9 100644 (file)
@@ -31,7 +31,7 @@
 
 #include "pipe/p_context.h"
 #include "pipe/p_state.h"
-#include "pipe/p_error.h"
+#include "pipe/p_defines.h"
 
 
 #ifdef __cplusplus
@@ -84,6 +84,20 @@ enum pipe_error cso_single_sampler( struct cso_context *cso,
 
 void cso_single_sampler_done( struct cso_context *cso );
 
+void
+cso_save_vertex_samplers(struct cso_context *cso);
+
+void
+cso_restore_vertex_samplers(struct cso_context *cso);
+
+enum pipe_error
+cso_single_vertex_sampler(struct cso_context *cso,
+                          unsigned nr,
+                          const struct pipe_sampler_state *states);
+
+void
+cso_single_vertex_sampler_done(struct cso_context *cso);
+
 
 
 enum pipe_error cso_set_sampler_textures( struct cso_context *cso,
@@ -94,6 +108,17 @@ void cso_restore_sampler_textures( struct cso_context *cso );
 
 
 
+enum pipe_error
+cso_set_vertex_sampler_textures(struct cso_context *cso,
+                                uint count,
+                                struct pipe_texture **textures);
+void
+cso_save_vertex_sampler_textures(struct cso_context *cso);
+void
+cso_restore_vertex_sampler_textures(struct cso_context *cso);
+
+
+
 /* These aren't really sensible -- most of the time the api provides
  * object semantics for shaders anyway, and the cases where it doesn't
  * (eg mesa's internall-generated texenv programs), it will be up to
@@ -121,6 +146,13 @@ void cso_save_vertex_shader(struct cso_context *cso);
 void cso_restore_vertex_shader(struct cso_context *cso);
 
 
+enum pipe_error cso_set_geometry_shader_handle(struct cso_context *ctx,
+                                               void *handle);
+void cso_delete_geometry_shader(struct cso_context *ctx, void *handle);
+void cso_save_geometry_shader(struct cso_context *cso);
+void cso_restore_geometry_shader(struct cso_context *cso);
+
+
 
 enum pipe_error cso_set_framebuffer(struct cso_context *cso,
                                     const struct pipe_framebuffer_state *fb);
diff --git a/src/gallium/auxiliary/draw/Makefile b/src/gallium/auxiliary/draw/Makefile
deleted file mode 100644 (file)
index 5041dcc..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = draw
-
-C_SOURCES = \
-       draw_context.c \
-       draw_pipe.c \
-       draw_pipe_aaline.c \
-       draw_pipe_aapoint.c \
-       draw_pipe_clip.c \
-       draw_pipe_cull.c \
-       draw_pipe_flatshade.c \
-       draw_pipe_offset.c \
-       draw_pipe_pstipple.c \
-       draw_pipe_stipple.c \
-       draw_pipe_twoside.c \
-       draw_pipe_unfilled.c \
-       draw_pipe_util.c \
-       draw_pipe_validate.c \
-       draw_pipe_vbuf.c \
-       draw_pipe_wide_line.c \
-       draw_pipe_wide_point.c \
-       draw_pt.c \
-       draw_pt_elts.c \
-       draw_pt_emit.c \
-       draw_pt_fetch.c \
-       draw_pt_fetch_emit.c \
-       draw_pt_fetch_shade_emit.c \
-       draw_pt_fetch_shade_pipeline.c \
-       draw_pt_post_vs.c \
-        draw_pt_util.c \
-        draw_pt_varray.c \
-       draw_pt_vcache.c \
-       draw_vertex.c \
-       draw_vs.c \
-       draw_vs_varient.c \
-       draw_vs_aos.c \
-       draw_vs_aos_io.c \
-       draw_vs_aos_machine.c \
-       draw_vs_exec.c \
-       draw_vs_llvm.c \
-       draw_vs_ppc.c  \
-       draw_vs_sse.c 
-
-include ../../Makefile.template
diff --git a/src/gallium/auxiliary/draw/SConscript b/src/gallium/auxiliary/draw/SConscript
deleted file mode 100644 (file)
index 5f05aa3..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-Import('*')
-
-draw = env.ConvenienceLibrary(
-       target = 'draw',
-       source = [
-               'draw_context.c',
-               'draw_pipe.c',
-               'draw_pipe_aaline.c',
-               'draw_pipe_aapoint.c',
-               'draw_pipe_clip.c',
-               'draw_pipe_cull.c',
-               'draw_pipe_flatshade.c',
-               'draw_pipe_offset.c',
-               'draw_pipe_pstipple.c',
-               'draw_pipe_stipple.c',
-               'draw_pipe_twoside.c',
-               'draw_pipe_unfilled.c',
-               'draw_pipe_util.c',
-               'draw_pipe_validate.c',
-               'draw_pipe_vbuf.c',
-               'draw_pipe_wide_line.c',
-               'draw_pipe_wide_point.c',
-               'draw_pt.c',
-               'draw_pt_elts.c',
-               'draw_pt_emit.c',
-               'draw_pt_fetch.c',
-               'draw_pt_fetch_emit.c',
-               'draw_pt_fetch_shade_emit.c',
-               'draw_pt_fetch_shade_pipeline.c',
-               'draw_pt_post_vs.c',
-               'draw_pt_util.c',
-               'draw_pt_varray.c',
-               'draw_pt_vcache.c',
-               'draw_vertex.c',
-               'draw_vs.c',
-               'draw_vs_aos.c',
-               'draw_vs_aos_io.c',
-               'draw_vs_aos_machine.c',
-               'draw_vs_exec.c',
-               'draw_vs_llvm.c',
-               'draw_vs_ppc.c',
-               'draw_vs_sse.c',
-               'draw_vs_varient.c'
-       ])
-
-auxiliaries.insert(0, draw)
index a4f1fcddc1a0cd6f9de25be4bd0c21c791f5da4e..667aa46b208ce3f4bc90fcc56b0d0087c053ff13 100644 (file)
@@ -36,6 +36,7 @@
 #include "draw_context.h"
 #include "draw_vbuf.h"
 #include "draw_vs.h"
+#include "draw_gs.h"
 #include "draw_pt.h"
 #include "draw_pipe.h"
 
@@ -67,6 +68,9 @@ struct draw_context *draw_create( void )
    if (!draw_vs_init( draw ))
       goto fail;
 
+   if (!draw_gs_init( draw ))
+      goto fail;
+
    return draw;
 
 fail:
@@ -231,11 +235,19 @@ draw_set_mapped_vertex_buffer(struct draw_context *draw,
 
 void
 draw_set_mapped_constant_buffer(struct draw_context *draw,
-                                const void *buffer, 
+                                unsigned shader_type,
+                                const void *buffer,
                                 unsigned size )
 {
-   draw->pt.user.constants = buffer;
-   draw_vs_set_constants( draw, (const float (*)[4])buffer, size );
+   debug_assert(shader_type == PIPE_SHADER_VERTEX ||
+                shader_type == PIPE_SHADER_GEOMETRY);
+   if (shader_type == PIPE_SHADER_VERTEX) {
+      draw->pt.user.vs_constants = buffer;
+      draw_vs_set_constants( draw, (const float (*)[4])buffer, size );
+   } else if (shader_type == PIPE_SHADER_GEOMETRY) {
+      draw->pt.user.gs_constants = buffer;
+      draw_gs_set_constants( draw, (const float (*)[4])buffer, size );
+   }
 }
 
 
@@ -298,7 +310,7 @@ draw_set_force_passthrough( struct draw_context *draw, boolean enable )
  * a post-transformed vertex.
  *
  * With this function, drivers that use the draw module should have no reason
- * to track the current vertex shader.
+ * to track the current vertex/geometry shader.
  *
  * Note that the draw module may sometimes generate vertices with extra
  * attributes (such as texcoords for AA lines).  The driver can call this
@@ -309,43 +321,59 @@ draw_set_force_passthrough( struct draw_context *draw, boolean enable )
  * work for the drivers.
  */
 int
-draw_find_vs_output(const struct draw_context *draw,
-                    uint semantic_name, uint semantic_index)
+draw_find_shader_output(const struct draw_context *draw,
+                        uint semantic_name, uint semantic_index)
 {
    const struct draw_vertex_shader *vs = draw->vs.vertex_shader;
+   const struct draw_geometry_shader *gs = draw->gs.geometry_shader;
    uint i;
-   for (i = 0; i < vs->info.num_outputs; i++) {
-      if (vs->info.output_semantic_name[i] == semantic_name &&
-          vs->info.output_semantic_index[i] == semantic_index)
+   const struct tgsi_shader_info *info = &vs->info;
+
+   if (gs)
+      info = &gs->info;
+
+   for (i = 0; i < info->num_outputs; i++) {
+      if (info->output_semantic_name[i] == semantic_name &&
+          info->output_semantic_index[i] == semantic_index)
          return i;
    }
 
    /* XXX there may be more than one extra vertex attrib.
     * For example, simulated gl_FragCoord and gl_PointCoord.
     */
-   if (draw->extra_vp_outputs.semantic_name == semantic_name &&
-       draw->extra_vp_outputs.semantic_index == semantic_index) {
-      return draw->extra_vp_outputs.slot;
+   if (draw->extra_shader_outputs.semantic_name == semantic_name &&
+       draw->extra_shader_outputs.semantic_index == semantic_index) {
+      return draw->extra_shader_outputs.slot;
    }
+
    return 0;
 }
 
 
 /**
- * Return number of vertex shader outputs.
+ * Return number of the shader outputs.
+ *
+ * If geometry shader is present, its output will be returned,
+ * if not vertex shader is used.
  */
 uint
-draw_num_vs_outputs(const struct draw_context *draw)
+draw_num_shader_outputs(const struct draw_context *draw)
 {
    uint count = draw->vs.vertex_shader->info.num_outputs;
-   if (draw->extra_vp_outputs.slot > 0)
+
+   /* if geometry shader is present, its outputs go to te
+    * driver, not the vertex shaders */
+   if (draw->gs.geometry_shader)
+      count = draw->gs.geometry_shader->info.num_outputs;
+
+   if (draw->extra_shader_outputs.slot > 0)
       count++;
    return count;
 }
 
 
 /**
- * Provide TGSI sampler objects for vertex shaders that use texture fetches.
+ * Provide TGSI sampler objects for vertex/geometry shaders that use texture fetches.
  * This might only be used by software drivers for the time being.
  */
 void
@@ -355,6 +383,8 @@ draw_texture_samplers(struct draw_context *draw,
 {
    draw->vs.num_samplers = num_samplers;
    draw->vs.samplers = samplers;
+   draw->gs.num_samplers = num_samplers;
+   draw->gs.samplers = samplers;
 }
 
 
@@ -366,13 +396,6 @@ void draw_set_render( struct draw_context *draw,
    draw->render = render;
 }
 
-void draw_set_edgeflags( struct draw_context *draw,
-                         const unsigned *edgeflag )
-{
-   draw->pt.user.edgeflag = edgeflag;
-}
-
-
 
 
 /**
@@ -428,3 +451,18 @@ void draw_do_flush( struct draw_context *draw, unsigned flags )
       draw->flushing = FALSE;
    }
 }
+
+
+int draw_current_shader_outputs(struct draw_context *draw)
+{
+   if (draw->gs.geometry_shader)
+      return draw->gs.num_gs_outputs;
+   return draw->vs.num_vs_outputs;
+}
+
+int draw_current_shader_position_output(struct draw_context *draw)
+{
+   if (draw->gs.geometry_shader)
+      return draw->gs.position_output;
+   return draw->vs.position_output;
+}
index d529e4e9a27f7e3f35c7eb24b0732f6fff1cc722..b716209df299019b0c309ff94730507b235522c0 100644 (file)
@@ -45,6 +45,7 @@ struct pipe_context;
 struct draw_context;
 struct draw_stage;
 struct draw_vertex_shader;
+struct draw_geometry_shader;
 struct tgsi_sampler;
 
 
@@ -85,11 +86,11 @@ draw_install_pstipple_stage(struct draw_context *draw, struct pipe_context *pipe
 
 
 int
-draw_find_vs_output(const struct draw_context *draw,
-                    uint semantic_name, uint semantic_index);
+draw_find_shader_output(const struct draw_context *draw,
+                        uint semantic_name, uint semantic_index);
 
 uint
-draw_num_vs_outputs(const struct draw_context *draw);
+draw_num_shader_outputs(const struct draw_context *draw);
 
 
 void
@@ -112,6 +113,17 @@ void draw_delete_vertex_shader(struct draw_context *draw,
                                struct draw_vertex_shader *dvs);
 
 
+/*
+ * Geometry shader functions
+ */
+struct draw_geometry_shader *
+draw_create_geometry_shader(struct draw_context *draw,
+                            const struct pipe_shader_state *shader);
+void draw_bind_geometry_shader(struct draw_context *draw,
+                               struct draw_geometry_shader *dvs);
+void draw_delete_geometry_shader(struct draw_context *draw,
+                                 struct draw_geometry_shader *dvs);
+
 
 /*
  * Vertex data functions
@@ -140,12 +152,10 @@ void draw_set_mapped_vertex_buffer(struct draw_context *draw,
                                    unsigned attr, const void *buffer);
 
 void draw_set_mapped_constant_buffer(struct draw_context *draw,
+                                     unsigned shader_type,
                                      const void *buffer,
                                      unsigned size );
 
-void draw_set_edgeflags( struct draw_context *draw,
-                         const unsigned *edgeflag );
-
 
 /***********************************************************************
  * draw_prim.c 
diff --git a/src/gallium/auxiliary/draw/draw_gs.c b/src/gallium/auxiliary/draw/draw_gs.c
new file mode 100644 (file)
index 0000000..5db2e75
--- /dev/null
@@ -0,0 +1,338 @@
+/**************************************************************************
+ *
+ * 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 "draw_gs.h"
+
+#include "draw_private.h"
+#include "draw_context.h"
+
+#include "tgsi/tgsi_parse.h"
+#include "tgsi/tgsi_exec.h"
+
+#include "pipe/p_shader_tokens.h"
+
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
+#define MAX_PRIM_VERTICES 6
+/* fixme: move it from here */
+#define MAX_PRIMITIVES 64
+
+boolean
+draw_gs_init( struct draw_context *draw )
+{
+   draw->gs.machine = tgsi_exec_machine_create();
+   if (!draw->gs.machine)
+      return FALSE;
+
+   draw->gs.machine->Primitives = align_malloc(
+      MAX_PRIMITIVES * sizeof(struct tgsi_exec_vector), 16);
+   if (!draw->gs.machine->Primitives)
+      return FALSE;
+   memset(draw->gs.machine->Primitives, 0,
+          MAX_PRIMITIVES * sizeof(struct tgsi_exec_vector));
+
+   return TRUE;
+}
+
+
+void draw_gs_set_constants( struct draw_context *draw,
+                            const float (*constants)[4],
+                            unsigned size )
+{
+}
+
+
+struct draw_geometry_shader *
+draw_create_geometry_shader(struct draw_context *draw,
+                            const struct pipe_shader_state *state)
+{
+   struct draw_geometry_shader *gs;
+   int i;
+
+   gs = CALLOC_STRUCT(draw_geometry_shader);
+
+   if (!gs)
+      return NULL;
+
+   gs->state = *state;
+   gs->state.tokens = tgsi_dup_tokens(state->tokens);
+   if (!gs->state.tokens) {
+      FREE(gs);
+      return NULL;
+   }
+
+   tgsi_scan_shader(state->tokens, &gs->info);
+
+   /* setup the defaults */
+   gs->input_primitive = PIPE_PRIM_TRIANGLES;
+   gs->output_primitive = PIPE_PRIM_TRIANGLE_STRIP;
+   gs->max_output_vertices = 32;
+
+   for (i = 0; i < gs->info.num_properties; ++i) {
+      if (gs->info.properties[i].name ==
+          TGSI_PROPERTY_GS_INPUT_PRIM)
+         gs->input_primitive = gs->info.properties[i].data[0];
+      else if (gs->info.properties[i].name ==
+               TGSI_PROPERTY_GS_OUTPUT_PRIM)
+         gs->output_primitive = gs->info.properties[i].data[0];
+      else if (gs->info.properties[i].name ==
+               TGSI_PROPERTY_GS_MAX_VERTICES)
+         gs->max_output_vertices = gs->info.properties[i].data[0];
+   }
+
+   gs->machine = draw->gs.machine;
+
+   if (gs)
+   {
+      uint i;
+      for (i = 0; i < gs->info.num_outputs; i++) {
+         if (gs->info.output_semantic_name[i] == TGSI_SEMANTIC_POSITION &&
+             gs->info.output_semantic_index[i] == 0)
+            gs->position_output = i;
+      }
+   }
+
+   return gs;
+}
+
+void draw_bind_geometry_shader(struct draw_context *draw,
+                               struct draw_geometry_shader *dgs)
+{
+   draw_do_flush(draw, DRAW_FLUSH_STATE_CHANGE);
+
+   if (dgs) {
+      draw->gs.geometry_shader = dgs;
+      draw->gs.num_gs_outputs = dgs->info.num_outputs;
+      draw->gs.position_output = dgs->position_output;
+      draw_geometry_shader_prepare(dgs, draw);
+   }
+   else {
+      draw->gs.geometry_shader = NULL;
+      draw->gs.num_gs_outputs = 0;
+   }
+}
+
+void draw_delete_geometry_shader(struct draw_context *draw,
+                                 struct draw_geometry_shader *dgs)
+{
+   FREE(dgs);
+}
+
+static INLINE int num_vertices_for_prim(int prim)
+{
+   switch(prim) {
+   case PIPE_PRIM_POINTS:
+      return 1;
+   case PIPE_PRIM_LINES:
+      return 2;
+   case PIPE_PRIM_LINE_LOOP:
+      return 2;
+   case PIPE_PRIM_LINE_STRIP:
+      return 2;
+   case PIPE_PRIM_TRIANGLES:
+      return 3;
+   case PIPE_PRIM_TRIANGLE_STRIP:
+      return 3;
+   case PIPE_PRIM_TRIANGLE_FAN:
+      return 3;
+   case PIPE_PRIM_LINES_ADJACENCY:
+   case PIPE_PRIM_LINE_STRIP_ADJACENCY:
+      return 4;
+   case PIPE_PRIM_TRIANGLES_ADJACENCY:
+   case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY:
+      return 6;
+   default:
+      assert(!"Bad geometry shader input");
+      return 0;
+   }
+}
+
+static void draw_fetch_geometry_input(struct draw_geometry_shader *shader,
+                                      int start_primitive,
+                                      int num_primitives,
+                                      const float (*input_ptr)[4],
+                                      unsigned input_vertex_stride,
+                                      unsigned inputs_from_vs)
+{
+   struct tgsi_exec_machine *machine = shader->machine;
+   unsigned slot, vs_slot, k, j;
+   unsigned num_vertices = num_vertices_for_prim(shader->input_primitive);
+   int idx = 0;
+
+   for (slot = 0, vs_slot = 0; slot < shader->info.num_inputs; slot++) {
+      /*debug_printf("Slot = %d (semantic = %d)\n", slot,
+        shader->info.input_semantic_name[slot]);*/
+      if (shader->info.input_semantic_name[slot] ==
+          TGSI_SEMANTIC_PRIMID) {
+         for (j = 0; j < num_primitives; ++j) {
+            machine->Inputs[idx].xyzw[0].f[j] = (float)start_primitive + j;
+            machine->Inputs[idx].xyzw[1].f[j] = (float)start_primitive + j;
+            machine->Inputs[idx].xyzw[2].f[j] = (float)start_primitive + j;
+            machine->Inputs[idx].xyzw[3].f[j] = (float)start_primitive + j;
+         }
+         ++idx;
+      } else {
+         for (j = 0; j < num_primitives; ++j) {
+            int vidx = idx;
+            const float (*prim_ptr)[4];
+            /*debug_printf("    %d) Prim (num_verts = %d)\n", start_primitive + j,
+              num_vertices);*/
+            prim_ptr = (const float (*)[4])(
+               (const char *)input_ptr +
+               (j * num_vertices * input_vertex_stride));
+
+            for (k = 0; k < num_vertices; ++k, ++vidx) {
+               const float (*input)[4];
+               input = (const float (*)[4])(
+                  (const char *)prim_ptr + (k * input_vertex_stride));
+               vidx = k * TGSI_EXEC_MAX_INPUT_ATTRIBS + slot;
+               /*debug_printf("\t%d)(%d) Input vert:\n", vidx, k);*/
+#if 1
+               assert(!util_is_inf_or_nan(input[vs_slot][0]));
+               assert(!util_is_inf_or_nan(input[vs_slot][1]));
+               assert(!util_is_inf_or_nan(input[vs_slot][2]));
+               assert(!util_is_inf_or_nan(input[vs_slot][3]));
+#endif
+               machine->Inputs[vidx].xyzw[0].f[j] = input[vs_slot][0];
+               machine->Inputs[vidx].xyzw[1].f[j] = input[vs_slot][1];
+               machine->Inputs[vidx].xyzw[2].f[j] = input[vs_slot][2];
+               machine->Inputs[vidx].xyzw[3].f[j] = input[vs_slot][3];
+#if 0
+               debug_printf("\t\t%d %f %f %f %f\n", slot,
+                            machine->Inputs[vidx].xyzw[0].f[j],
+                            machine->Inputs[vidx].xyzw[1].f[j],
+                            machine->Inputs[vidx].xyzw[2].f[j],
+                            machine->Inputs[vidx].xyzw[3].f[j]);
+#endif
+            }
+         }
+         ++vs_slot;
+         idx += num_vertices;
+      }
+   }
+}
+
+static INLINE void
+draw_geometry_fetch_outputs(struct draw_geometry_shader *shader,
+                            int num_primitives,
+                            float (*output)[4],
+                            unsigned vertex_size)
+{
+   struct tgsi_exec_machine *machine = shader->machine;
+   unsigned prim_idx, j, slot;
+
+   /* Unswizzle all output results.
+    */
+   /* FIXME: handle all the primitives produced by the gs, not just
+    * the first one
+    unsigned prim_count =
+    mach->Temps[TEMP_PRIMITIVE_I].xyzw[TEMP_PRIMITIVE_C].u[0];*/
+   for (prim_idx = 0; prim_idx < num_primitives; ++prim_idx) {
+      unsigned num_verts_per_prim = machine->Primitives[0];
+      for (j = 0; j < num_verts_per_prim; j++) {
+         int idx = (prim_idx * num_verts_per_prim + j) *
+                   shader->info.num_outputs;
+#ifdef DEBUG_OUTPUTS
+         debug_printf("%d) Output vert:\n", idx);
+#endif
+         for (slot = 0; slot < shader->info.num_outputs; slot++) {
+            output[slot][0] = machine->Outputs[idx + slot].xyzw[0].f[prim_idx];
+            output[slot][1] = machine->Outputs[idx + slot].xyzw[1].f[prim_idx];
+            output[slot][2] = machine->Outputs[idx + slot].xyzw[2].f[prim_idx];
+            output[slot][3] = machine->Outputs[idx + slot].xyzw[3].f[prim_idx];
+#ifdef DEBUG_OUTPUTS
+            debug_printf("\t%d: %f %f %f %f\n", slot,
+                         output[slot][0],
+                         output[slot][1],
+                         output[slot][2],
+                         output[slot][3]);
+#endif
+            debug_assert(!util_is_inf_or_nan(output[slot][0]));
+         }
+         output = (float (*)[4])((char *)output + vertex_size);
+      }
+   }
+}
+
+void draw_geometry_shader_run(struct draw_geometry_shader *shader,
+                              const float (*input)[4],
+                              float (*output)[4],
+                              const float (*constants)[4],
+                              unsigned count,
+                              unsigned input_stride,
+                              unsigned vertex_size)
+{
+   struct tgsi_exec_machine *machine = shader->machine;
+   unsigned int i;
+   unsigned num_vertices = num_vertices_for_prim(shader->input_primitive);
+   unsigned num_primitives = count/num_vertices;
+   unsigned inputs_from_vs = 0;
+
+   machine->Consts = constants;
+
+   for (i = 0; i < shader->info.num_inputs; ++i) {
+      if (shader->info.input_semantic_name[i] != TGSI_SEMANTIC_PRIMID)
+         ++inputs_from_vs;
+   }
+
+   for (i = 0; i < num_primitives; ++i) {
+      unsigned int max_primitives = 1;
+
+      draw_fetch_geometry_input(shader, i, max_primitives, input,
+                                input_stride, inputs_from_vs);
+
+      tgsi_set_exec_mask(machine,
+                         1,
+                         max_primitives > 1,
+                         max_primitives > 2,
+                         max_primitives > 3);
+
+      /* run interpreter */
+      tgsi_exec_machine_run(machine);
+
+      draw_geometry_fetch_outputs(shader, max_primitives,
+                                  output, vertex_size);
+   }
+}
+
+void draw_geometry_shader_delete(struct draw_geometry_shader *shader)
+{
+   FREE((void*) shader->state.tokens);
+   FREE(shader);
+}
+
+void draw_geometry_shader_prepare(struct draw_geometry_shader *shader,
+                                  struct draw_context *draw)
+{
+    if (shader->machine->Tokens != shader->state.tokens) {
+       tgsi_exec_machine_bind_shader(shader->machine,
+                                     shader->state.tokens,
+                                     draw->gs.num_samplers,
+                                     draw->gs.samplers);
+    }
+}
diff --git a/src/gallium/auxiliary/draw/draw_gs.h b/src/gallium/auxiliary/draw/draw_gs.h
new file mode 100644 (file)
index 0000000..d6a97d9
--- /dev/null
@@ -0,0 +1,76 @@
+/**************************************************************************
+ * 
+ * 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.
+ * 
+ **************************************************************************/
+
+#ifndef DRAW_GS_H
+#define DRAW_GS_H
+
+#include "draw_context.h"
+#include "draw_private.h"
+
+
+#define MAX_TGSI_PRIMITIVES 4
+
+struct draw_context;
+
+/**
+ * Private version of the compiled geometry shader
+ */
+struct draw_geometry_shader {
+   struct draw_context *draw;
+
+   struct tgsi_exec_machine *machine;
+
+   /* This member will disappear shortly:*/
+   struct pipe_shader_state state;
+
+   struct tgsi_shader_info info;
+   unsigned position_output;
+
+   unsigned max_output_vertices;
+   unsigned input_primitive;
+   unsigned output_primitive;
+
+   /* Extracted from shader:
+    */
+   const float (*immediates)[4];
+};
+
+void draw_geometry_shader_run(struct draw_geometry_shader *shader,
+                              const float (*input)[4],
+                              float (*output)[4],
+                              const float (*constants)[4],
+                              unsigned count,
+                              unsigned input_stride,
+                              unsigned output_stride);
+
+void draw_geometry_shader_prepare(struct draw_geometry_shader *shader,
+                                  struct draw_context *draw);
+
+void draw_geometry_shader_delete(struct draw_geometry_shader *shader);
+
+
+#endif
index 9f956715a228135df0459358ef0ff8242cf789e3..4585dcdb48ab8f39dc911d868e0d4fb5a67db27f 100644 (file)
@@ -35,6 +35,8 @@
 #include "pipe/p_context.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_shader_tokens.h"
+
+#include "util/u_format.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
 
@@ -139,29 +141,29 @@ aa_transform_decl(struct tgsi_transform_context *ctx,
    struct aa_transform_context *aactx = (struct aa_transform_context *) ctx;
 
    if (decl->Declaration.File == TGSI_FILE_OUTPUT &&
-       decl->Semantic.SemanticName == TGSI_SEMANTIC_COLOR &&
-       decl->Semantic.SemanticIndex == 0) {
-      aactx->colorOutput = decl->DeclarationRange.First;
+       decl->Semantic.Name == TGSI_SEMANTIC_COLOR &&
+       decl->Semantic.Index == 0) {
+      aactx->colorOutput = decl->Range.First;
    }
    else if (decl->Declaration.File == TGSI_FILE_SAMPLER) {
       uint i;
-      for (i = decl->DeclarationRange.First;
-           i <= decl->DeclarationRange.Last; i++) {
+      for (i = decl->Range.First;
+           i <= decl->Range.Last; i++) {
          aactx->samplersUsed |= 1 << i;
       }
    }
    else if (decl->Declaration.File == TGSI_FILE_INPUT) {
-      if ((int) decl->DeclarationRange.Last > aactx->maxInput)
-         aactx->maxInput = decl->DeclarationRange.Last;
-      if (decl->Semantic.SemanticName == TGSI_SEMANTIC_GENERIC &&
-           (int) decl->Semantic.SemanticIndex > aactx->maxGeneric) {
-         aactx->maxGeneric = decl->Semantic.SemanticIndex;
+      if ((int) decl->Range.Last > aactx->maxInput)
+         aactx->maxInput = decl->Range.Last;
+      if (decl->Semantic.Name == TGSI_SEMANTIC_GENERIC &&
+           (int) decl->Semantic.Index > aactx->maxGeneric) {
+         aactx->maxGeneric = decl->Semantic.Index;
       }
    }
    else if (decl->Declaration.File == TGSI_FILE_TEMPORARY) {
       uint i;
-      for (i = decl->DeclarationRange.First;
-           i <= decl->DeclarationRange.Last; i++) {
+      for (i = decl->Range.First;
+           i <= decl->Range.Last; i++) {
          aactx->tempsUsed |= (1 << i);
       }
    }
@@ -228,30 +230,30 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
       /* XXX this could be linear... */
       decl.Declaration.Interpolate = TGSI_INTERPOLATE_PERSPECTIVE;
       decl.Declaration.Semantic = 1;
-      decl.Semantic.SemanticName = TGSI_SEMANTIC_GENERIC;
-      decl.Semantic.SemanticIndex = aactx->maxGeneric + 1;
-      decl.DeclarationRange.First = 
-      decl.DeclarationRange.Last = aactx->maxInput + 1;
+      decl.Semantic.Name = TGSI_SEMANTIC_GENERIC;
+      decl.Semantic.Index = aactx->maxGeneric + 1;
+      decl.Range.First = 
+      decl.Range.Last = aactx->maxInput + 1;
       ctx->emit_declaration(ctx, &decl);
 
       /* declare new sampler */
       decl = tgsi_default_full_declaration();
       decl.Declaration.File = TGSI_FILE_SAMPLER;
-      decl.DeclarationRange.First = 
-      decl.DeclarationRange.Last = aactx->freeSampler;
+      decl.Range.First = 
+      decl.Range.Last = aactx->freeSampler;
       ctx->emit_declaration(ctx, &decl);
 
       /* declare new temp regs */
       decl = tgsi_default_full_declaration();
       decl.Declaration.File = TGSI_FILE_TEMPORARY;
-      decl.DeclarationRange.First = 
-      decl.DeclarationRange.Last = aactx->texTemp;
+      decl.Range.First = 
+      decl.Range.Last = aactx->texTemp;
       ctx->emit_declaration(ctx, &decl);
 
       decl = tgsi_default_full_declaration();
       decl.Declaration.File = TGSI_FILE_TEMPORARY;
-      decl.DeclarationRange.First = 
-      decl.DeclarationRange.Last = aactx->colorTemp;
+      decl.Range.First = 
+      decl.Range.Last = aactx->colorTemp;
       ctx->emit_declaration(ctx, &decl);
 
       aactx->firstInstruction = FALSE;
@@ -265,14 +267,15 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
       newInst = tgsi_default_full_instruction();
       newInst.Instruction.Opcode = TGSI_OPCODE_TEX;
       newInst.Instruction.NumDstRegs = 1;
-      newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullDstRegisters[0].DstRegister.Index = aactx->texTemp;
+      newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Dst[0].Register.Index = aactx->texTemp;
       newInst.Instruction.NumSrcRegs = 2;
-      newInst.InstructionExtTexture.Texture = TGSI_TEXTURE_2D;
-      newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_INPUT;
-      newInst.FullSrcRegisters[0].SrcRegister.Index = aactx->maxInput + 1;
-      newInst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_SAMPLER;
-      newInst.FullSrcRegisters[1].SrcRegister.Index = aactx->freeSampler;
+      newInst.Instruction.Texture = TRUE;
+      newInst.Texture.Texture = TGSI_TEXTURE_2D;
+      newInst.Src[0].Register.File = TGSI_FILE_INPUT;
+      newInst.Src[0].Register.Index = aactx->maxInput + 1;
+      newInst.Src[1].Register.File = TGSI_FILE_SAMPLER;
+      newInst.Src[1].Register.Index = aactx->freeSampler;
 
       ctx->emit_instruction(ctx, &newInst);
 
@@ -280,26 +283,26 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
       newInst = tgsi_default_full_instruction();
       newInst.Instruction.Opcode = TGSI_OPCODE_MOV;
       newInst.Instruction.NumDstRegs = 1;
-      newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_OUTPUT;
-      newInst.FullDstRegisters[0].DstRegister.Index = aactx->colorOutput;
-      newInst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_XYZ;
+      newInst.Dst[0].Register.File = TGSI_FILE_OUTPUT;
+      newInst.Dst[0].Register.Index = aactx->colorOutput;
+      newInst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_XYZ;
       newInst.Instruction.NumSrcRegs = 1;
-      newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullSrcRegisters[0].SrcRegister.Index = aactx->colorTemp;
+      newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Src[0].Register.Index = aactx->colorTemp;
       ctx->emit_instruction(ctx, &newInst);
 
       /* MUL alpha */
       newInst = tgsi_default_full_instruction();
       newInst.Instruction.Opcode = TGSI_OPCODE_MUL;
       newInst.Instruction.NumDstRegs = 1;
-      newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_OUTPUT;
-      newInst.FullDstRegisters[0].DstRegister.Index = aactx->colorOutput;
-      newInst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_W;
+      newInst.Dst[0].Register.File = TGSI_FILE_OUTPUT;
+      newInst.Dst[0].Register.Index = aactx->colorOutput;
+      newInst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_W;
       newInst.Instruction.NumSrcRegs = 2;
-      newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullSrcRegisters[0].SrcRegister.Index = aactx->colorTemp;
-      newInst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullSrcRegisters[1].SrcRegister.Index = aactx->texTemp;
+      newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Src[0].Register.Index = aactx->colorTemp;
+      newInst.Src[1].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Src[1].Register.Index = aactx->texTemp;
       ctx->emit_instruction(ctx, &newInst);
 
       /* END */
@@ -316,11 +319,11 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
       uint i;
 
       for (i = 0; i < inst->Instruction.NumDstRegs; i++) {
-         struct tgsi_full_dst_register *dst = &inst->FullDstRegisters[i];
-         if (dst->DstRegister.File == TGSI_FILE_OUTPUT &&
-             dst->DstRegister.Index == aactx->colorOutput) {
-            dst->DstRegister.File = TGSI_FILE_TEMPORARY;
-            dst->DstRegister.Index = aactx->colorTemp;
+         struct tgsi_full_dst_register *dst = &inst->Dst[i];
+         if (dst->Register.File == TGSI_FILE_OUTPUT &&
+             dst->Register.Index == aactx->colorOutput) {
+            dst->Register.File = TGSI_FILE_TEMPORARY;
+            dst->Register.Index = aactx->colorTemp;
          }
       }
 
@@ -398,10 +401,9 @@ aaline_create_texture(struct aaline_stage *aaline)
    texTemp.target = PIPE_TEXTURE_2D;
    texTemp.format = PIPE_FORMAT_A8_UNORM; /* XXX verify supported by driver! */
    texTemp.last_level = MAX_TEXTURE_LEVEL;
-   texTemp.width[0] = 1 << MAX_TEXTURE_LEVEL;
-   texTemp.height[0] = 1 << MAX_TEXTURE_LEVEL;
-   texTemp.depth[0] = 1;
-   pf_get_block(texTemp.format, &texTemp.block);
+   texTemp.width0 = 1 << MAX_TEXTURE_LEVEL;
+   texTemp.height0 = 1 << MAX_TEXTURE_LEVEL;
+   texTemp.depth0 = 1;
 
    aaline->texture = screen->texture_create(screen, &texTemp);
    if (!aaline->texture)
@@ -413,11 +415,11 @@ aaline_create_texture(struct aaline_stage *aaline)
     */
    for (level = 0; level <= MAX_TEXTURE_LEVEL; level++) {
       struct pipe_transfer *transfer;
-      const uint size = aaline->texture->width[level];
+      const uint size = u_minify(aaline->texture->width0, level);
       ubyte *data;
       uint i, j;
 
-      assert(aaline->texture->width[level] == aaline->texture->height[level]);
+      assert(aaline->texture->width0 == aaline->texture->height0);
 
       /* This texture is new, no need to flush. 
        */
@@ -658,13 +660,13 @@ aaline_first_line(struct draw_stage *stage, struct prim_header *header)
    }
 
    /* update vertex attrib info */
-   aaline->tex_slot = draw->vs.num_vs_outputs;
-   aaline->pos_slot = draw->vs.position_output;
+   aaline->tex_slot = draw_current_shader_outputs(draw);
+   aaline->pos_slot = draw_current_shader_position_output(draw);;
 
    /* advertise the extra post-transformed vertex attribute */
-   draw->extra_vp_outputs.semantic_name = TGSI_SEMANTIC_GENERIC;
-   draw->extra_vp_outputs.semantic_index = aaline->fs->generic_attrib;
-   draw->extra_vp_outputs.slot = aaline->tex_slot;
+   draw->extra_shader_outputs.semantic_name = TGSI_SEMANTIC_GENERIC;
+   draw->extra_shader_outputs.semantic_index = aaline->fs->generic_attrib;
+   draw->extra_shader_outputs.slot = aaline->tex_slot;
 
    /* how many samplers? */
    /* we'll use sampler/texture[pstip->sampler_unit] for the stipple */
@@ -705,7 +707,7 @@ aaline_flush(struct draw_stage *stage, unsigned flags)
                                        aaline->state.texture);
    draw->suspend_flushing = FALSE;
 
-   draw->extra_vp_outputs.slot = 0;
+   draw->extra_shader_outputs.slot = 0;
 }
 
 
@@ -896,16 +898,16 @@ draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe)
    aaline->driver_bind_fs_state = pipe->bind_fs_state;
    aaline->driver_delete_fs_state = pipe->delete_fs_state;
 
-   aaline->driver_bind_sampler_states = pipe->bind_sampler_states;
-   aaline->driver_set_sampler_textures = pipe->set_sampler_textures;
+   aaline->driver_bind_sampler_states = pipe->bind_fragment_sampler_states;
+   aaline->driver_set_sampler_textures = pipe->set_fragment_sampler_textures;
 
    /* override the driver's functions */
    pipe->create_fs_state = aaline_create_fs_state;
    pipe->bind_fs_state = aaline_bind_fs_state;
    pipe->delete_fs_state = aaline_delete_fs_state;
 
-   pipe->bind_sampler_states = aaline_bind_sampler_states;
-   pipe->set_sampler_textures = aaline_set_sampler_textures;
+   pipe->bind_fragment_sampler_states = aaline_bind_sampler_states;
+   pipe->set_fragment_sampler_textures = aaline_set_sampler_textures;
    
    /* Install once everything is known to be OK:
     */
index ae1712fe122a901bcfafda05c98d32b927299c28..d86717e5182bbe5e23207f0bfcfe4381dfed04c3 100644 (file)
@@ -131,22 +131,22 @@ aa_transform_decl(struct tgsi_transform_context *ctx,
    struct aa_transform_context *aactx = (struct aa_transform_context *) ctx;
 
    if (decl->Declaration.File == TGSI_FILE_OUTPUT &&
-       decl->Semantic.SemanticName == TGSI_SEMANTIC_COLOR &&
-       decl->Semantic.SemanticIndex == 0) {
-      aactx->colorOutput = decl->DeclarationRange.First;
+       decl->Semantic.Name == TGSI_SEMANTIC_COLOR &&
+       decl->Semantic.Index == 0) {
+      aactx->colorOutput = decl->Range.First;
    }
    else if (decl->Declaration.File == TGSI_FILE_INPUT) {
-      if ((int) decl->DeclarationRange.Last > aactx->maxInput)
-         aactx->maxInput = decl->DeclarationRange.Last;
-      if (decl->Semantic.SemanticName == TGSI_SEMANTIC_GENERIC &&
-           (int) decl->Semantic.SemanticIndex > aactx->maxGeneric) {
-         aactx->maxGeneric = decl->Semantic.SemanticIndex;
+      if ((int) decl->Range.Last > aactx->maxInput)
+         aactx->maxInput = decl->Range.Last;
+      if (decl->Semantic.Name == TGSI_SEMANTIC_GENERIC &&
+           (int) decl->Semantic.Index > aactx->maxGeneric) {
+         aactx->maxGeneric = decl->Semantic.Index;
       }
    }
    else if (decl->Declaration.File == TGSI_FILE_TEMPORARY) {
       uint i;
-      for (i = decl->DeclarationRange.First;
-           i <= decl->DeclarationRange.Last; i++) {
+      for (i = decl->Range.First;
+           i <= decl->Range.Last; i++) {
          aactx->tempsUsed |= (1 << i);
       }
    }
@@ -198,23 +198,23 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
       /* XXX this could be linear... */
       decl.Declaration.Interpolate = TGSI_INTERPOLATE_PERSPECTIVE;
       decl.Declaration.Semantic = 1;
-      decl.Semantic.SemanticName = TGSI_SEMANTIC_GENERIC;
-      decl.Semantic.SemanticIndex = aactx->maxGeneric + 1;
-      decl.DeclarationRange.First = 
-      decl.DeclarationRange.Last = texInput;
+      decl.Semantic.Name = TGSI_SEMANTIC_GENERIC;
+      decl.Semantic.Index = aactx->maxGeneric + 1;
+      decl.Range.First = 
+      decl.Range.Last = texInput;
       ctx->emit_declaration(ctx, &decl);
 
       /* declare new temp regs */
       decl = tgsi_default_full_declaration();
       decl.Declaration.File = TGSI_FILE_TEMPORARY;
-      decl.DeclarationRange.First = 
-      decl.DeclarationRange.Last = tmp0;
+      decl.Range.First = 
+      decl.Range.Last = tmp0;
       ctx->emit_declaration(ctx, &decl);
 
       decl = tgsi_default_full_declaration();
       decl.Declaration.File = TGSI_FILE_TEMPORARY;
-      decl.DeclarationRange.First = 
-      decl.DeclarationRange.Last = aactx->colorTemp;
+      decl.Range.First = 
+      decl.Range.Last = aactx->colorTemp;
       ctx->emit_declaration(ctx, &decl);
 
       aactx->firstInstruction = FALSE;
@@ -234,30 +234,30 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
       newInst = tgsi_default_full_instruction();
       newInst.Instruction.Opcode = TGSI_OPCODE_MUL;
       newInst.Instruction.NumDstRegs = 1;
-      newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullDstRegisters[0].DstRegister.Index = tmp0;
-      newInst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_XY;
+      newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Dst[0].Register.Index = tmp0;
+      newInst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_XY;
       newInst.Instruction.NumSrcRegs = 2;
-      newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_INPUT;
-      newInst.FullSrcRegisters[0].SrcRegister.Index = texInput;
-      newInst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_INPUT;
-      newInst.FullSrcRegisters[1].SrcRegister.Index = texInput;
+      newInst.Src[0].Register.File = TGSI_FILE_INPUT;
+      newInst.Src[0].Register.Index = texInput;
+      newInst.Src[1].Register.File = TGSI_FILE_INPUT;
+      newInst.Src[1].Register.Index = texInput;
       ctx->emit_instruction(ctx, &newInst);
 
       /* ADD t0.x, t0.x, t0.y;  # x^2 + y^2 */
       newInst = tgsi_default_full_instruction();
       newInst.Instruction.Opcode = TGSI_OPCODE_ADD;
       newInst.Instruction.NumDstRegs = 1;
-      newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullDstRegisters[0].DstRegister.Index = tmp0;
-      newInst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_X;
+      newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Dst[0].Register.Index = tmp0;
+      newInst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_X;
       newInst.Instruction.NumSrcRegs = 2;
-      newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullSrcRegisters[0].SrcRegister.Index = tmp0;
-      newInst.FullSrcRegisters[0].SrcRegister.SwizzleX = TGSI_SWIZZLE_X;
-      newInst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullSrcRegisters[1].SrcRegister.Index = tmp0;
-      newInst.FullSrcRegisters[1].SrcRegister.SwizzleX = TGSI_SWIZZLE_Y;
+      newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Src[0].Register.Index = tmp0;
+      newInst.Src[0].Register.SwizzleX = TGSI_SWIZZLE_X;
+      newInst.Src[1].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Src[1].Register.Index = tmp0;
+      newInst.Src[1].Register.SwizzleX = TGSI_SWIZZLE_Y;
       ctx->emit_instruction(ctx, &newInst);
 
 #if NORMALIZE  /* OPTIONAL normalization of length */
@@ -265,24 +265,24 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
       newInst = tgsi_default_full_instruction();
       newInst.Instruction.Opcode = TGSI_OPCODE_RSQ;
       newInst.Instruction.NumDstRegs = 1;
-      newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullDstRegisters[0].DstRegister.Index = tmp0;
-      newInst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_X;
+      newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Dst[0].Register.Index = tmp0;
+      newInst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_X;
       newInst.Instruction.NumSrcRegs = 1;
-      newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullSrcRegisters[0].SrcRegister.Index = tmp0;
+      newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Src[0].Register.Index = tmp0;
       ctx->emit_instruction(ctx, &newInst);
 
       /* RCP t0.x, t0.x; */
       newInst = tgsi_default_full_instruction();
       newInst.Instruction.Opcode = TGSI_OPCODE_RCP;
       newInst.Instruction.NumDstRegs = 1;
-      newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullDstRegisters[0].DstRegister.Index = tmp0;
-      newInst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_X;
+      newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Dst[0].Register.Index = tmp0;
+      newInst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_X;
       newInst.Instruction.NumSrcRegs = 1;
-      newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullSrcRegisters[0].SrcRegister.Index = tmp0;
+      newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Src[0].Register.Index = tmp0;
       ctx->emit_instruction(ctx, &newInst);
 #endif
 
@@ -290,16 +290,16 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
       newInst = tgsi_default_full_instruction();
       newInst.Instruction.Opcode = TGSI_OPCODE_SGT;
       newInst.Instruction.NumDstRegs = 1;
-      newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullDstRegisters[0].DstRegister.Index = tmp0;
-      newInst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_Y;
+      newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Dst[0].Register.Index = tmp0;
+      newInst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_Y;
       newInst.Instruction.NumSrcRegs = 2;
-      newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullSrcRegisters[0].SrcRegister.Index = tmp0;
-      newInst.FullSrcRegisters[0].SrcRegister.SwizzleY = TGSI_SWIZZLE_X;
-      newInst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_INPUT;
-      newInst.FullSrcRegisters[1].SrcRegister.Index = texInput;
-      newInst.FullSrcRegisters[1].SrcRegister.SwizzleY = TGSI_SWIZZLE_W;
+      newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Src[0].Register.Index = tmp0;
+      newInst.Src[0].Register.SwizzleY = TGSI_SWIZZLE_X;
+      newInst.Src[1].Register.File = TGSI_FILE_INPUT;
+      newInst.Src[1].Register.Index = texInput;
+      newInst.Src[1].Register.SwizzleY = TGSI_SWIZZLE_W;
       ctx->emit_instruction(ctx, &newInst);
 
       /* KIL -tmp0.yyyy;   # if -tmp0.y < 0, KILL */
@@ -307,13 +307,13 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
       newInst.Instruction.Opcode = TGSI_OPCODE_KIL;
       newInst.Instruction.NumDstRegs = 0;
       newInst.Instruction.NumSrcRegs = 1;
-      newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullSrcRegisters[0].SrcRegister.Index = tmp0;
-      newInst.FullSrcRegisters[0].SrcRegister.SwizzleX = TGSI_SWIZZLE_Y;
-      newInst.FullSrcRegisters[0].SrcRegister.SwizzleY = TGSI_SWIZZLE_Y;
-      newInst.FullSrcRegisters[0].SrcRegister.SwizzleZ = TGSI_SWIZZLE_Y;
-      newInst.FullSrcRegisters[0].SrcRegister.SwizzleW = TGSI_SWIZZLE_Y;
-      newInst.FullSrcRegisters[0].SrcRegister.Negate = 1;
+      newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Src[0].Register.Index = tmp0;
+      newInst.Src[0].Register.SwizzleX = TGSI_SWIZZLE_Y;
+      newInst.Src[0].Register.SwizzleY = TGSI_SWIZZLE_Y;
+      newInst.Src[0].Register.SwizzleZ = TGSI_SWIZZLE_Y;
+      newInst.Src[0].Register.SwizzleW = TGSI_SWIZZLE_Y;
+      newInst.Src[0].Register.Negate = 1;
       ctx->emit_instruction(ctx, &newInst);
 
 
@@ -323,77 +323,77 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
       newInst = tgsi_default_full_instruction();
       newInst.Instruction.Opcode = TGSI_OPCODE_SUB;
       newInst.Instruction.NumDstRegs = 1;
-      newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullDstRegisters[0].DstRegister.Index = tmp0;
-      newInst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_Z;
+      newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Dst[0].Register.Index = tmp0;
+      newInst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_Z;
       newInst.Instruction.NumSrcRegs = 2;
-      newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_INPUT;
-      newInst.FullSrcRegisters[0].SrcRegister.Index = texInput;
-      newInst.FullSrcRegisters[0].SrcRegister.SwizzleZ = TGSI_SWIZZLE_W;
-      newInst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_INPUT;
-      newInst.FullSrcRegisters[1].SrcRegister.Index = texInput;
-      newInst.FullSrcRegisters[1].SrcRegister.SwizzleZ = TGSI_SWIZZLE_Z;
+      newInst.Src[0].Register.File = TGSI_FILE_INPUT;
+      newInst.Src[0].Register.Index = texInput;
+      newInst.Src[0].Register.SwizzleZ = TGSI_SWIZZLE_W;
+      newInst.Src[1].Register.File = TGSI_FILE_INPUT;
+      newInst.Src[1].Register.Index = texInput;
+      newInst.Src[1].Register.SwizzleZ = TGSI_SWIZZLE_Z;
       ctx->emit_instruction(ctx, &newInst);
 
       /* RCP t0.z, t0.z;  # t0.z = 1 / m */
       newInst = tgsi_default_full_instruction();
       newInst.Instruction.Opcode = TGSI_OPCODE_RCP;
       newInst.Instruction.NumDstRegs = 1;
-      newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullDstRegisters[0].DstRegister.Index = tmp0;
-      newInst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_Z;
+      newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Dst[0].Register.Index = tmp0;
+      newInst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_Z;
       newInst.Instruction.NumSrcRegs = 1;
-      newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullSrcRegisters[0].SrcRegister.Index = tmp0;
-      newInst.FullSrcRegisters[0].SrcRegister.SwizzleX = TGSI_SWIZZLE_Z;
+      newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Src[0].Register.Index = tmp0;
+      newInst.Src[0].Register.SwizzleX = TGSI_SWIZZLE_Z;
       ctx->emit_instruction(ctx, &newInst);
 
       /* SUB t0.y, 1, t0.x;  # d = 1 - d */
       newInst = tgsi_default_full_instruction();
       newInst.Instruction.Opcode = TGSI_OPCODE_SUB;
       newInst.Instruction.NumDstRegs = 1;
-      newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullDstRegisters[0].DstRegister.Index = tmp0;
-      newInst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_Y;
+      newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Dst[0].Register.Index = tmp0;
+      newInst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_Y;
       newInst.Instruction.NumSrcRegs = 2;
-      newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_INPUT;
-      newInst.FullSrcRegisters[0].SrcRegister.Index = texInput;
-      newInst.FullSrcRegisters[0].SrcRegister.SwizzleY = TGSI_SWIZZLE_W;
-      newInst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullSrcRegisters[1].SrcRegister.Index = tmp0;
-      newInst.FullSrcRegisters[1].SrcRegister.SwizzleY = TGSI_SWIZZLE_X;
+      newInst.Src[0].Register.File = TGSI_FILE_INPUT;
+      newInst.Src[0].Register.Index = texInput;
+      newInst.Src[0].Register.SwizzleY = TGSI_SWIZZLE_W;
+      newInst.Src[1].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Src[1].Register.Index = tmp0;
+      newInst.Src[1].Register.SwizzleY = TGSI_SWIZZLE_X;
       ctx->emit_instruction(ctx, &newInst);
 
       /* MUL t0.w, t0.y, t0.z;   # coverage = d * m */
       newInst = tgsi_default_full_instruction();
       newInst.Instruction.Opcode = TGSI_OPCODE_MUL;
       newInst.Instruction.NumDstRegs = 1;
-      newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullDstRegisters[0].DstRegister.Index = tmp0;
-      newInst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_W;
+      newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Dst[0].Register.Index = tmp0;
+      newInst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_W;
       newInst.Instruction.NumSrcRegs = 2;
-      newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullSrcRegisters[0].SrcRegister.Index = tmp0;
-      newInst.FullSrcRegisters[0].SrcRegister.SwizzleW = TGSI_SWIZZLE_Y;
-      newInst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullSrcRegisters[1].SrcRegister.Index = tmp0;
-      newInst.FullSrcRegisters[1].SrcRegister.SwizzleW = TGSI_SWIZZLE_Z;
+      newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Src[0].Register.Index = tmp0;
+      newInst.Src[0].Register.SwizzleW = TGSI_SWIZZLE_Y;
+      newInst.Src[1].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Src[1].Register.Index = tmp0;
+      newInst.Src[1].Register.SwizzleW = TGSI_SWIZZLE_Z;
       ctx->emit_instruction(ctx, &newInst);
 
       /* SLE t0.y, t0.x, tex.z;  # bool b = distance <= k */
       newInst = tgsi_default_full_instruction();
       newInst.Instruction.Opcode = TGSI_OPCODE_SLE;
       newInst.Instruction.NumDstRegs = 1;
-      newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullDstRegisters[0].DstRegister.Index = tmp0;
-      newInst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_Y;
+      newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Dst[0].Register.Index = tmp0;
+      newInst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_Y;
       newInst.Instruction.NumSrcRegs = 2;
-      newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullSrcRegisters[0].SrcRegister.Index = tmp0;
-      newInst.FullSrcRegisters[0].SrcRegister.SwizzleY = TGSI_SWIZZLE_X;
-      newInst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_INPUT;
-      newInst.FullSrcRegisters[1].SrcRegister.Index = texInput;
-      newInst.FullSrcRegisters[1].SrcRegister.SwizzleY = TGSI_SWIZZLE_Z;
+      newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Src[0].Register.Index = tmp0;
+      newInst.Src[0].Register.SwizzleY = TGSI_SWIZZLE_X;
+      newInst.Src[1].Register.File = TGSI_FILE_INPUT;
+      newInst.Src[1].Register.Index = texInput;
+      newInst.Src[1].Register.SwizzleY = TGSI_SWIZZLE_Z;
       ctx->emit_instruction(ctx, &newInst);
 
       /* CMP t0.w, -t0.y, tex.w, t0.w;
@@ -405,29 +405,29 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
       newInst = tgsi_default_full_instruction();
       newInst.Instruction.Opcode = TGSI_OPCODE_CMP;
       newInst.Instruction.NumDstRegs = 1;
-      newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullDstRegisters[0].DstRegister.Index = tmp0;
-      newInst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_W;
+      newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Dst[0].Register.Index = tmp0;
+      newInst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_W;
       newInst.Instruction.NumSrcRegs = 3;
-      newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullSrcRegisters[0].SrcRegister.Index = tmp0;
-      newInst.FullSrcRegisters[0].SrcRegister.SwizzleX = TGSI_SWIZZLE_Y;
-      newInst.FullSrcRegisters[0].SrcRegister.SwizzleY = TGSI_SWIZZLE_Y;
-      newInst.FullSrcRegisters[0].SrcRegister.SwizzleZ = TGSI_SWIZZLE_Y;
-      newInst.FullSrcRegisters[0].SrcRegister.SwizzleW = TGSI_SWIZZLE_Y;
-      newInst.FullSrcRegisters[0].SrcRegister.Negate = 1;
-      newInst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_INPUT;
-      newInst.FullSrcRegisters[1].SrcRegister.Index = texInput;
-      newInst.FullSrcRegisters[1].SrcRegister.SwizzleX = TGSI_SWIZZLE_W;
-      newInst.FullSrcRegisters[1].SrcRegister.SwizzleY = TGSI_SWIZZLE_W;
-      newInst.FullSrcRegisters[1].SrcRegister.SwizzleZ = TGSI_SWIZZLE_W;
-      newInst.FullSrcRegisters[1].SrcRegister.SwizzleW = TGSI_SWIZZLE_W;
-      newInst.FullSrcRegisters[2].SrcRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullSrcRegisters[2].SrcRegister.Index = tmp0;
-      newInst.FullSrcRegisters[2].SrcRegister.SwizzleX = TGSI_SWIZZLE_W;
-      newInst.FullSrcRegisters[2].SrcRegister.SwizzleY = TGSI_SWIZZLE_W;
-      newInst.FullSrcRegisters[2].SrcRegister.SwizzleZ = TGSI_SWIZZLE_W;
-      newInst.FullSrcRegisters[2].SrcRegister.SwizzleW = TGSI_SWIZZLE_W;
+      newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Src[0].Register.Index = tmp0;
+      newInst.Src[0].Register.SwizzleX = TGSI_SWIZZLE_Y;
+      newInst.Src[0].Register.SwizzleY = TGSI_SWIZZLE_Y;
+      newInst.Src[0].Register.SwizzleZ = TGSI_SWIZZLE_Y;
+      newInst.Src[0].Register.SwizzleW = TGSI_SWIZZLE_Y;
+      newInst.Src[0].Register.Negate = 1;
+      newInst.Src[1].Register.File = TGSI_FILE_INPUT;
+      newInst.Src[1].Register.Index = texInput;
+      newInst.Src[1].Register.SwizzleX = TGSI_SWIZZLE_W;
+      newInst.Src[1].Register.SwizzleY = TGSI_SWIZZLE_W;
+      newInst.Src[1].Register.SwizzleZ = TGSI_SWIZZLE_W;
+      newInst.Src[1].Register.SwizzleW = TGSI_SWIZZLE_W;
+      newInst.Src[2].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Src[2].Register.Index = tmp0;
+      newInst.Src[2].Register.SwizzleX = TGSI_SWIZZLE_W;
+      newInst.Src[2].Register.SwizzleY = TGSI_SWIZZLE_W;
+      newInst.Src[2].Register.SwizzleZ = TGSI_SWIZZLE_W;
+      newInst.Src[2].Register.SwizzleW = TGSI_SWIZZLE_W;
       ctx->emit_instruction(ctx, &newInst);
 
    }
@@ -439,26 +439,26 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
       newInst = tgsi_default_full_instruction();
       newInst.Instruction.Opcode = TGSI_OPCODE_MOV;
       newInst.Instruction.NumDstRegs = 1;
-      newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_OUTPUT;
-      newInst.FullDstRegisters[0].DstRegister.Index = aactx->colorOutput;
-      newInst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_XYZ;
+      newInst.Dst[0].Register.File = TGSI_FILE_OUTPUT;
+      newInst.Dst[0].Register.Index = aactx->colorOutput;
+      newInst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_XYZ;
       newInst.Instruction.NumSrcRegs = 1;
-      newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullSrcRegisters[0].SrcRegister.Index = aactx->colorTemp;
+      newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Src[0].Register.Index = aactx->colorTemp;
       ctx->emit_instruction(ctx, &newInst);
 
       /* MUL result.color.w, colorTemp, tmp0.w; */
       newInst = tgsi_default_full_instruction();
       newInst.Instruction.Opcode = TGSI_OPCODE_MUL;
       newInst.Instruction.NumDstRegs = 1;
-      newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_OUTPUT;
-      newInst.FullDstRegisters[0].DstRegister.Index = aactx->colorOutput;
-      newInst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_W;
+      newInst.Dst[0].Register.File = TGSI_FILE_OUTPUT;
+      newInst.Dst[0].Register.Index = aactx->colorOutput;
+      newInst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_W;
       newInst.Instruction.NumSrcRegs = 2;
-      newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullSrcRegisters[0].SrcRegister.Index = aactx->colorTemp;
-      newInst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullSrcRegisters[1].SrcRegister.Index = aactx->tmp0;
+      newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Src[0].Register.Index = aactx->colorTemp;
+      newInst.Src[1].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Src[1].Register.Index = aactx->tmp0;
       ctx->emit_instruction(ctx, &newInst);
    }
    else {
@@ -468,11 +468,11 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
       uint i;
 
       for (i = 0; i < inst->Instruction.NumDstRegs; i++) {
-         struct tgsi_full_dst_register *dst = &inst->FullDstRegisters[i];
-         if (dst->DstRegister.File == TGSI_FILE_OUTPUT &&
-             dst->DstRegister.Index == aactx->colorOutput) {
-            dst->DstRegister.File = TGSI_FILE_TEMPORARY;
-            dst->DstRegister.Index = aactx->colorTemp;
+         struct tgsi_full_dst_register *dst = &inst->Dst[i];
+         if (dst->Register.File == TGSI_FILE_OUTPUT &&
+             dst->Register.Index == aactx->colorOutput) {
+            dst->Register.File = TGSI_FILE_TEMPORARY;
+            dst->Register.Index = aactx->colorTemp;
          }
       }
    }
@@ -687,14 +687,14 @@ aapoint_first_point(struct draw_stage *stage, struct prim_header *header)
    bind_aapoint_fragment_shader(aapoint);
 
    /* update vertex attrib info */
-   aapoint->tex_slot = draw->vs.num_vs_outputs;
+   aapoint->tex_slot = draw_current_shader_outputs(draw);
    assert(aapoint->tex_slot > 0); /* output[0] is vertex pos */
 
-   aapoint->pos_slot = draw->vs.position_output;
+   aapoint->pos_slot = draw_current_shader_position_output(draw);
 
-   draw->extra_vp_outputs.semantic_name = TGSI_SEMANTIC_GENERIC;
-   draw->extra_vp_outputs.semantic_index = aapoint->fs->generic_attrib;
-   draw->extra_vp_outputs.slot = aapoint->tex_slot;
+   draw->extra_shader_outputs.semantic_name = TGSI_SEMANTIC_GENERIC;
+   draw->extra_shader_outputs.semantic_index = aapoint->fs->generic_attrib;
+   draw->extra_shader_outputs.slot = aapoint->tex_slot;
 
    /* find psize slot in post-transform vertex */
    aapoint->psize_slot = -1;
@@ -731,7 +731,7 @@ aapoint_flush(struct draw_stage *stage, unsigned flags)
    aapoint->driver_bind_fs_state(pipe, aapoint->fs->driver_fs);
    draw->suspend_flushing = FALSE;
 
-   draw->extra_vp_outputs.slot = 0;
+   draw->extra_shader_outputs.slot = 0;
 }
 
 
index 0670268a196f2c6d933dfa32fb5654bafbc06ca2..205cda5eabed89e8976ad0faeed4799ac959b069 100644 (file)
@@ -114,8 +114,8 @@ static void interp( const struct clipper *clip,
                    const struct vertex_header *out, 
                    const struct vertex_header *in )
 {
-   const unsigned nr_attrs = clip->stage.draw->vs.num_vs_outputs;
-   const unsigned pos_attr = clip->stage.draw->vs.position_output;
+   const unsigned nr_attrs = draw_current_shader_outputs(clip->stage.draw);
+   const unsigned pos_attr = draw_current_shader_position_output(clip->stage.draw);
    unsigned j;
 
    /* Vertex header.
index 0a70483858cdff525e4b071ed7bdffb7d9982461..11b39db5990b2541ca71fe0b7e41450322cb2127 100644 (file)
@@ -55,7 +55,7 @@ static INLINE struct cull_stage *cull_stage( struct draw_stage *stage )
 static void cull_tri( struct draw_stage *stage,
                      struct prim_header *header )
 {
-   const unsigned pos = stage->draw->vs.position_output;
+   const unsigned pos = draw_current_shader_position_output(stage->draw);
 
    /* Window coords: */
    const float *v0 = header->v[0]->data[pos];
index 40798a5d6e7b394b25fe9eb2595067c83e040b77..e829492423e3b0e9275a0f13c498ebf9acc4858c 100644 (file)
@@ -63,7 +63,7 @@ static INLINE struct offset_stage *offset_stage( struct draw_stage *stage )
 static void do_offset_tri( struct draw_stage *stage,
                           struct prim_header *header )
 {
-   const unsigned pos = stage->draw->vs.position_output;
+   const unsigned pos = draw_current_shader_position_output(stage->draw);
    struct offset_stage *offset = offset_stage(stage);   
    float inv_det = 1.0f / header->det;
 
index 283502cdf3e3bd31afd3114df5b0a854fe6b13ec..0cc2b7186416dce314a29d1a3f984360612b0298 100644 (file)
@@ -38,6 +38,7 @@
 #include "pipe/p_defines.h"
 #include "pipe/p_shader_tokens.h"
 
+#include "util/u_format.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
 
@@ -133,20 +134,20 @@ pstip_transform_decl(struct tgsi_transform_context *ctx,
 
    if (decl->Declaration.File == TGSI_FILE_SAMPLER) {
       uint i;
-      for (i = decl->DeclarationRange.First;
-           i <= decl->DeclarationRange.Last; i++) {
+      for (i = decl->Range.First;
+           i <= decl->Range.Last; i++) {
          pctx->samplersUsed |= 1 << i;
       }
    }
    else if (decl->Declaration.File == TGSI_FILE_INPUT) {
-      pctx->maxInput = MAX2(pctx->maxInput, (int) decl->DeclarationRange.Last);
-      if (decl->Semantic.SemanticName == TGSI_SEMANTIC_POSITION)
-         pctx->wincoordInput = (int) decl->DeclarationRange.First;
+      pctx->maxInput = MAX2(pctx->maxInput, (int) decl->Range.Last);
+      if (decl->Semantic.Name == TGSI_SEMANTIC_POSITION)
+         pctx->wincoordInput = (int) decl->Range.First;
    }
    else if (decl->Declaration.File == TGSI_FILE_TEMPORARY) {
       uint i;
-      for (i = decl->DeclarationRange.First;
-           i <= decl->DeclarationRange.Last; i++) {
+      for (i = decl->Range.First;
+           i <= decl->Range.Last; i++) {
          pctx->tempsUsed |= (1 << i);
       }
    }
@@ -226,25 +227,25 @@ pstip_transform_inst(struct tgsi_transform_context *ctx,
          decl.Declaration.File = TGSI_FILE_INPUT;
          decl.Declaration.Interpolate = TGSI_INTERPOLATE_LINEAR; /* XXX? */
          decl.Declaration.Semantic = 1;
-         decl.Semantic.SemanticName = TGSI_SEMANTIC_POSITION;
-         decl.Semantic.SemanticIndex = 0;
-         decl.DeclarationRange.First = 
-            decl.DeclarationRange.Last = wincoordInput;
+         decl.Semantic.Name = TGSI_SEMANTIC_POSITION;
+         decl.Semantic.Index = 0;
+         decl.Range.First = 
+            decl.Range.Last = wincoordInput;
          ctx->emit_declaration(ctx, &decl);
       }
 
       /* declare new sampler */
       decl = tgsi_default_full_declaration();
       decl.Declaration.File = TGSI_FILE_SAMPLER;
-      decl.DeclarationRange.First = 
-      decl.DeclarationRange.Last = pctx->freeSampler;
+      decl.Range.First = 
+      decl.Range.Last = pctx->freeSampler;
       ctx->emit_declaration(ctx, &decl);
 
       /* declare new temp regs */
       decl = tgsi_default_full_declaration();
       decl.Declaration.File = TGSI_FILE_TEMPORARY;
-      decl.DeclarationRange.First = 
-      decl.DeclarationRange.Last = pctx->texTemp;
+      decl.Range.First = 
+      decl.Range.Last = pctx->texTemp;
       ctx->emit_declaration(ctx, &decl);
 
       /* emit immediate = {1/32, 1/32, 1, 1}
@@ -280,27 +281,28 @@ pstip_transform_inst(struct tgsi_transform_context *ctx,
       newInst = tgsi_default_full_instruction();
       newInst.Instruction.Opcode = TGSI_OPCODE_MUL;
       newInst.Instruction.NumDstRegs = 1;
-      newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullDstRegisters[0].DstRegister.Index = pctx->texTemp;
+      newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Dst[0].Register.Index = pctx->texTemp;
       newInst.Instruction.NumSrcRegs = 2;
-      newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_INPUT;
-      newInst.FullSrcRegisters[0].SrcRegister.Index = wincoordInput;
-      newInst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_IMMEDIATE;
-      newInst.FullSrcRegisters[1].SrcRegister.Index = pctx->numImmed;
+      newInst.Src[0].Register.File = TGSI_FILE_INPUT;
+      newInst.Src[0].Register.Index = wincoordInput;
+      newInst.Src[1].Register.File = TGSI_FILE_IMMEDIATE;
+      newInst.Src[1].Register.Index = pctx->numImmed;
       ctx->emit_instruction(ctx, &newInst);
 
       /* TEX texTemp, texTemp, sampler; */
       newInst = tgsi_default_full_instruction();
       newInst.Instruction.Opcode = TGSI_OPCODE_TEX;
       newInst.Instruction.NumDstRegs = 1;
-      newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullDstRegisters[0].DstRegister.Index = pctx->texTemp;
+      newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Dst[0].Register.Index = pctx->texTemp;
       newInst.Instruction.NumSrcRegs = 2;
-      newInst.InstructionExtTexture.Texture = TGSI_TEXTURE_2D;
-      newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullSrcRegisters[0].SrcRegister.Index = pctx->texTemp;
-      newInst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_SAMPLER;
-      newInst.FullSrcRegisters[1].SrcRegister.Index = pctx->freeSampler;
+      newInst.Instruction.Texture = TRUE;
+      newInst.Texture.Texture = TGSI_TEXTURE_2D;
+      newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Src[0].Register.Index = pctx->texTemp;
+      newInst.Src[1].Register.File = TGSI_FILE_SAMPLER;
+      newInst.Src[1].Register.Index = pctx->freeSampler;
       ctx->emit_instruction(ctx, &newInst);
 
       /* KIL -texTemp;   # if -texTemp < 0, KILL fragment */
@@ -308,9 +310,9 @@ pstip_transform_inst(struct tgsi_transform_context *ctx,
       newInst.Instruction.Opcode = TGSI_OPCODE_KIL;
       newInst.Instruction.NumDstRegs = 0;
       newInst.Instruction.NumSrcRegs = 1;
-      newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
-      newInst.FullSrcRegisters[0].SrcRegister.Index = pctx->texTemp;
-      newInst.FullSrcRegisters[0].SrcRegister.Negate = 1;
+      newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
+      newInst.Src[0].Register.Index = pctx->texTemp;
+      newInst.Src[0].Register.Negate = 1;
       ctx->emit_instruction(ctx, &newInst);
    }
 
@@ -427,10 +429,9 @@ pstip_create_texture(struct pstip_stage *pstip)
    texTemp.target = PIPE_TEXTURE_2D;
    texTemp.format = PIPE_FORMAT_A8_UNORM; /* XXX verify supported by driver! */
    texTemp.last_level = 0;
-   texTemp.width[0] = 32;
-   texTemp.height[0] = 32;
-   texTemp.depth[0] = 1;
-   pf_get_block(texTemp.format, &texTemp.block);
+   texTemp.width0 = 32;
+   texTemp.height0 = 32;
+   texTemp.depth0 = 1;
 
    pstip->texture = screen->texture_create(screen, &texTemp);
    if (pstip->texture == NULL)
@@ -754,8 +755,8 @@ draw_install_pstipple_stage(struct draw_context *draw,
    pstip->driver_bind_fs_state = pipe->bind_fs_state;
    pstip->driver_delete_fs_state = pipe->delete_fs_state;
 
-   pstip->driver_bind_sampler_states = pipe->bind_sampler_states;
-   pstip->driver_set_sampler_textures = pipe->set_sampler_textures;
+   pstip->driver_bind_sampler_states = pipe->bind_fragment_sampler_states;
+   pstip->driver_set_sampler_textures = pipe->set_fragment_sampler_textures;
    pstip->driver_set_polygon_stipple = pipe->set_polygon_stipple;
 
    /* override the driver's functions */
@@ -763,8 +764,8 @@ draw_install_pstipple_stage(struct draw_context *draw,
    pipe->bind_fs_state = pstip_bind_fs_state;
    pipe->delete_fs_state = pstip_delete_fs_state;
 
-   pipe->bind_sampler_states = pstip_bind_sampler_states;
-   pipe->set_sampler_textures = pstip_set_sampler_textures;
+   pipe->bind_fragment_sampler_states = pstip_bind_sampler_states;
+   pipe->set_fragment_sampler_textures = pstip_set_sampler_textures;
    pipe->set_polygon_stipple = pstip_set_polygon_stipple;
 
    return TRUE;
index 6e921bac27858f84ef01a055c7a2f2767bf32f56..70fbab9ea7673dca3cbdf1a1162dd4fb0a6caaff 100644 (file)
@@ -73,7 +73,8 @@ screen_interp( struct draw_context *draw,
                const struct vertex_header *v1 )
 {
    uint attr;
-   for (attr = 0; attr < draw->vs.num_vs_outputs; attr++) {
+   int num_outputs = draw_current_shader_outputs(draw);
+   for (attr = 0; attr < num_outputs; attr++) {
       const float *val0 = v0->data[attr];
       const float *val1 = v1->data[attr];
       float *newv = dst->data[attr];
@@ -121,7 +122,7 @@ stipple_line(struct draw_stage *stage, struct prim_header *header)
    struct stipple_stage *stipple = stipple_stage(stage);
    struct vertex_header *v0 = header->v[0];
    struct vertex_header *v1 = header->v[1];
-   const unsigned pos = stage->draw->vs.position_output;
+   const unsigned pos = draw_current_shader_position_output(stage->draw);
    const float *pos0 = v0->data[pos];
    const float *pos1 = v1->data[pos];
    float start = 0;
index f32cbef983d71aa70a2c9d9dcab0682cfe8d1bd5..3073c8708251e0ee521c516b5b18c6301ab16e19 100644 (file)
@@ -59,7 +59,7 @@ static void wideline_line( struct draw_stage *stage,
                            struct prim_header *header )
 {
    /*const struct wideline_stage *wide = wideline_stage(stage);*/
-   const unsigned pos = stage->draw->vs.position_output;
+   const unsigned pos = draw_current_shader_position_output(stage->draw);
    const float half_width = 0.5f * stage->draw->rasterizer->line_width;
 
    struct prim_header tri;
index 7d76a7dbf39e32cfc7d385e59826453a23e21f42..8dc50c0ab431b7fc1f6d4a04db5b06bcc12a96b9 100644 (file)
@@ -112,7 +112,7 @@ static void set_texcoords(const struct widepoint_stage *wide,
 
    if (wide->point_coord_fs_input >= 0) {
       /* put gl_PointCoord into the extra vertex slot */
-      uint slot = wide->stage.draw->extra_vp_outputs.slot;
+      uint slot = wide->stage.draw->extra_shader_outputs.slot;
       v->data[slot][0] = tc[0];
       v->data[slot][1] = tc[1];
       v->data[slot][2] = 0.0F;
@@ -130,7 +130,7 @@ static void widepoint_point( struct draw_stage *stage,
                              struct prim_header *header )
 {
    const struct widepoint_stage *wide = widepoint_stage(stage);
-   const unsigned pos = stage->draw->vs.position_output;
+   const unsigned pos = draw_current_shader_position_output(stage->draw);
    const boolean sprite = (boolean) stage->draw->rasterizer->point_sprite;
    float half_size;
    float left_adj, right_adj, bot_adj, top_adj;
@@ -257,13 +257,13 @@ static void widepoint_first_point( struct draw_stage *stage,
       wide->point_coord_fs_input = find_pntc_input_attrib(draw);
 
       /* setup extra vp output (point coord implemented as a texcoord) */
-      draw->extra_vp_outputs.semantic_name = TGSI_SEMANTIC_GENERIC;
-      draw->extra_vp_outputs.semantic_index = 0;
-      draw->extra_vp_outputs.slot = draw->vs.num_vs_outputs;
+      draw->extra_shader_outputs.semantic_name = TGSI_SEMANTIC_GENERIC;
+      draw->extra_shader_outputs.semantic_index = 0;
+      draw->extra_shader_outputs.slot = draw_current_shader_outputs(draw);
    }
    else {
       wide->point_coord_fs_input = -1;
-      draw->extra_vp_outputs.slot = 0;
+      draw->extra_shader_outputs.slot = 0;
    }
 
    wide->psize_slot = -1;
@@ -287,7 +287,7 @@ static void widepoint_flush( struct draw_stage *stage, unsigned flags )
 {
    stage->point = widepoint_first_point;
    stage->next->flush( stage->next, flags );
-   stage->draw->extra_vp_outputs.slot = 0;
+   stage->draw->extra_shader_outputs.slot = 0;
 }
 
 
index 41fcb16a0a5a1df71c3de27bbafaec358fd5b61c..e49041556bd5d1c386e5f78448b19e5f306aad30 100644 (file)
@@ -142,8 +142,6 @@ struct draw_context
 
       /* user-space vertex data, buffers */
       struct {
-         const unsigned *edgeflag;
-
          /** vertex element/index buffer (ex: glDrawElements) */
          const void *elts;
          /** bytes per index (0, 1, 2 or 4) */
@@ -154,8 +152,9 @@ struct draw_context
          /** vertex arrays */
          const void *vbuffer[PIPE_MAX_ATTRIBS];
          
-         /** constant buffer (for vertex shader) */
-         const void *constants;
+         /** constant buffer (for vertex/geometry shader) */
+         const void *vs_constants;
+         const void *gs_constants;
       } user;
 
       boolean test_fse;         /* enable FSE even though its not correct (eg for softpipe) */
@@ -184,6 +183,7 @@ struct draw_context
       struct draw_vertex_shader *vertex_shader;
       uint num_vs_outputs;  /**< convenience, from vertex_shader */
       uint position_output;
+      uint edgeflag_output;
 
       /** TGSI program interpreter runtime state */
       struct tgsi_exec_machine *machine;
@@ -212,6 +212,18 @@ struct draw_context
       struct translate_cache *emit_cache;
    } vs;
 
+   struct {
+      struct draw_geometry_shader *geometry_shader;
+      uint num_gs_outputs;  /**< convenience, from geometry_shader */
+      uint position_output;
+
+      /** TGSI program interpreter runtime state */
+      struct tgsi_exec_machine *machine;
+
+      uint num_samplers;
+      struct tgsi_sampler **samplers;
+   } gs;
+
    /* Clip derived state:
     */
    float plane[12][4];
@@ -223,7 +235,7 @@ struct draw_context
       uint semantic_name;
       uint semantic_index;
       int slot;
-   } extra_vp_outputs;
+   } extra_shader_outputs;
 
    unsigned reduced_prim;
 
@@ -246,6 +258,19 @@ void draw_vs_set_constants( struct draw_context *,
 
 
 
+/*******************************************************************************
+ * Geometry shading code:
+ */
+boolean draw_gs_init( struct draw_context *draw );
+void draw_gs_set_constants( struct draw_context *,
+                            const float (*constants)[4],
+                            unsigned size );
+
+/*******************************************************************************
+ * Common shading code:
+ */
+int draw_current_shader_outputs(struct draw_context *draw);
+int draw_current_shader_position_output(struct draw_context *draw);
 
 /*******************************************************************************
  * Vertex processing (was passthrough) code:
index dbb5ac71821ae266729a4bf22d8461d5e2740cb9..2801dbafe4735b44246d406b310492b0bb190110 100644 (file)
@@ -192,7 +192,8 @@ draw_print_arrays(struct draw_context *draw, uint prim, int start, uint count)
                 prim, start, count);
 
    for (i = 0; i < count; i++) {
-      uint ii, j;
+      uint ii = 0;
+      uint j;
 
       if (draw->pt.user.elts) {
          /* indexed arrays */
@@ -313,12 +314,3 @@ draw_arrays(struct draw_context *draw, unsigned prim,
    /* drawing done here: */
    draw_pt_arrays(draw, prim, start, count);
 }
-
-boolean draw_pt_get_edgeflag( struct draw_context *draw,
-                              unsigned idx )
-{
-   if (draw->pt.user.edgeflag)
-      return (draw->pt.user.edgeflag[idx/32] & (1 << (idx%32))) != 0;
-   else
-      return 1;
-}
index 7a17a9fb6b2818013966b6b13c7a78be0849a6a8..20edf7a227ef32f4b8673954ec51b75f9447be3c 100644 (file)
@@ -149,11 +149,6 @@ struct draw_pt_middle_end *draw_pt_middle_fse( struct draw_context *draw );
 struct draw_pt_middle_end *draw_pt_fetch_pipeline_or_emit(struct draw_context *draw);
 
 
-/* More helpers:
- */
-boolean draw_pt_get_edgeflag( struct draw_context *draw,
-                              unsigned idx );
-
 
 /*******************************************************************************
  * HW vertex emit:
@@ -217,7 +212,8 @@ boolean draw_pt_post_vs_run( struct pt_post_vs *pvs,
 void draw_pt_post_vs_prepare( struct pt_post_vs *pvs,
                              boolean bypass_clipping,
                              boolean bypass_viewport,
-                             boolean opengl );
+                             boolean opengl,
+                             boolean need_edgeflags );
 
 struct pt_post_vs *draw_pt_post_vs_create( struct draw_context *draw );
 
index 65c3a34c3474a664fbac65042117800174eda9db..305bfef4352b002c60aa06879878d697e20b33b8 100644 (file)
@@ -42,11 +42,11 @@ struct pt_fetch {
    struct translate *translate;
 
    unsigned vertex_size;
-   boolean need_edgeflags;
 
    struct translate_cache *cache;
 };
 
+
 /* Perform the fetch from API vertex elements & vertex buffers, to a
  * contiguous set of float[4] attributes as required for the
  * vertex_shader->run_linear() method.
@@ -120,7 +120,12 @@ void draw_pt_fetch_prepare( struct pt_fetch *fetch,
       fetch->translate = translate_cache_find(fetch->cache, &key);
 
       {
-         static struct vertex_header vh = { 0, 1, 0, UNDEFINED_VERTEX_ID, { .0f, .0f, .0f, .0f } };
+         static struct vertex_header vh = { 0,
+                                            1,
+                                            0,
+                                            UNDEFINED_VERTEX_ID,
+                                            { .0f, .0f, .0f, .0f } };
+
         fetch->translate->set_buffer(fetch->translate,
                                      draw->pt.nr_vertex_buffers,
                                      &vh,
@@ -128,9 +133,6 @@ void draw_pt_fetch_prepare( struct pt_fetch *fetch,
       }
    }
 
-   fetch->need_edgeflags = ((draw->rasterizer->fill_cw != PIPE_POLYGON_MODE_FILL ||
-                             draw->rasterizer->fill_ccw != PIPE_POLYGON_MODE_FILL) &&
-                            draw->pt.user.edgeflag);
 }
 
 
@@ -158,17 +160,6 @@ void draw_pt_fetch_run( struct pt_fetch *fetch,
                        count,
                        verts );
 
-   /* Edgeflags are hard to fit into a translate program, populate
-    * them separately if required.  In the setup above they are
-    * defaulted to one, so only need this if there is reason to change
-    * that default:
-    */
-   if (fetch->need_edgeflags) {
-      for (i = 0; i < count; i++) {
-         struct vertex_header *vh = (struct vertex_header *)(verts + i * fetch->vertex_size);
-         vh->edgeflag = draw_pt_get_edgeflag( draw, elts[i] );
-      }
-   }
 }
 
 
@@ -193,18 +184,6 @@ void draw_pt_fetch_run_linear( struct pt_fetch *fetch,
                    start,
                    count,
                    verts );
-
-   /* Edgeflags are hard to fit into a translate program, populate
-    * them separately if required.  In the setup above they are
-    * defaulted to one, so only need this if there is reason to change
-    * that default:
-    */
-   if (fetch->need_edgeflags) {
-      for (i = 0; i < count; i++) {
-         struct vertex_header *vh = (struct vertex_header *)(verts + i * fetch->vertex_size);
-         vh->edgeflag = draw_pt_get_edgeflag( draw, start + i );
-      }
-   }
 }
 
 
index df6c265b7ec9026a95cd6383b1d70adb242efcbb..1a9df4cac5d5269723996da3535f7b9c1d455d59 100644 (file)
@@ -32,6 +32,7 @@
 #include "draw/draw_vertex.h"
 #include "draw/draw_pt.h"
 #include "draw/draw_vs.h"
+#include "draw/draw_gs.h"
 #include "translate/translate.h"
 
 
@@ -85,9 +86,9 @@ static void fetch_pipeline_prepare( struct draw_pt_middle_end *middle,
    draw_pt_post_vs_prepare( fpme->post_vs,
                            (boolean)draw->bypass_clipping,
                            (boolean)(draw->identity_viewport ||
-                                      draw->rasterizer->bypass_vs_clip_and_viewport),
-                           (boolean)draw->rasterizer->gl_rasterization_rules );
-                           
+                           draw->rasterizer->bypass_vs_clip_and_viewport),
+                           (boolean)draw->rasterizer->gl_rasterization_rules,
+                           (draw->vs.edgeflag_output ? true : false) );    
 
    if (!(opt & PT_PIPELINE)) {
       draw_pt_emit_prepare( fpme->emit, 
@@ -119,7 +120,8 @@ static void fetch_pipeline_run( struct draw_pt_middle_end *middle,
 {
    struct fetch_pipeline_middle_end *fpme = (struct fetch_pipeline_middle_end *)middle;
    struct draw_context *draw = fpme->draw;
-   struct draw_vertex_shader *shader = draw->vs.vertex_shader;
+   struct draw_vertex_shader *vshader = draw->vs.vertex_shader;
+   struct draw_geometry_shader *gshader = draw->gs.geometry_shader;
    unsigned opt = fpme->opt;
    unsigned alloc_count = align( fetch_count, 4 );
 
@@ -147,13 +149,21 @@ static void fetch_pipeline_run( struct draw_pt_middle_end *middle,
     */
    if (opt & PT_SHADE)
    {
-      shader->run_linear(shader, 
-                        (const float (*)[4])pipeline_verts->data,
-                        (      float (*)[4])pipeline_verts->data,
-                        (const float (*)[4])draw->pt.user.constants,
-                        fetch_count,
-                        fpme->vertex_size,
-                        fpme->vertex_size);
+      vshader->run_linear(vshader,
+                          (const float (*)[4])pipeline_verts->data,
+                          (      float (*)[4])pipeline_verts->data,
+                          (const float (*)[4])draw->pt.user.vs_constants,
+                          fetch_count,
+                          fpme->vertex_size,
+                          fpme->vertex_size);
+      if (gshader)
+         draw_geometry_shader_run(gshader,
+                                  (const float (*)[4])pipeline_verts->data,
+                                  (      float (*)[4])pipeline_verts->data,
+                                  (const float (*)[4])draw->pt.user.gs_constants,
+                                  fetch_count,
+                                  fpme->vertex_size,
+                                  fpme->vertex_size);
    }
 
    if (draw_pt_post_vs_run( fpme->post_vs,
@@ -196,6 +206,7 @@ static void fetch_pipeline_linear_run( struct draw_pt_middle_end *middle,
    struct fetch_pipeline_middle_end *fpme = (struct fetch_pipeline_middle_end *)middle;
    struct draw_context *draw = fpme->draw;
    struct draw_vertex_shader *shader = draw->vs.vertex_shader;
+   struct draw_geometry_shader *geometry_shader = draw->gs.geometry_shader;
    unsigned opt = fpme->opt;
    unsigned alloc_count = align( count, 4 );
 
@@ -226,10 +237,19 @@ static void fetch_pipeline_linear_run( struct draw_pt_middle_end *middle,
       shader->run_linear(shader,
                         (const float (*)[4])pipeline_verts->data,
                         (      float (*)[4])pipeline_verts->data,
-                        (const float (*)[4])draw->pt.user.constants,
+                        (const float (*)[4])draw->pt.user.vs_constants,
                         count,
                         fpme->vertex_size,
                         fpme->vertex_size);
+
+      if (geometry_shader)
+         draw_geometry_shader_run(geometry_shader,
+                                  (const float (*)[4])pipeline_verts->data,
+                                  (      float (*)[4])pipeline_verts->data,
+                                  (const float (*)[4])draw->pt.user.gs_constants,
+                                  count,
+                                  fpme->vertex_size,
+                                  fpme->vertex_size);
    }
 
    if (draw_pt_post_vs_run( fpme->post_vs,
@@ -270,6 +290,7 @@ static boolean fetch_pipeline_linear_run_elts( struct draw_pt_middle_end *middle
    struct fetch_pipeline_middle_end *fpme = (struct fetch_pipeline_middle_end *)middle;
    struct draw_context *draw = fpme->draw;
    struct draw_vertex_shader *shader = draw->vs.vertex_shader;
+   struct draw_geometry_shader *geometry_shader = draw->gs.geometry_shader;
    unsigned opt = fpme->opt;
    unsigned alloc_count = align( count, 4 );
 
@@ -296,10 +317,19 @@ static boolean fetch_pipeline_linear_run_elts( struct draw_pt_middle_end *middle
       shader->run_linear(shader,
                         (const float (*)[4])pipeline_verts->data,
                         (      float (*)[4])pipeline_verts->data,
-                        (const float (*)[4])draw->pt.user.constants,
+                        (const float (*)[4])draw->pt.user.vs_constants,
                         count,
                         fpme->vertex_size,
                         fpme->vertex_size);
+
+      if (geometry_shader)
+         draw_geometry_shader_run(geometry_shader,
+                                  (const float (*)[4])pipeline_verts->data,
+                                  (      float (*)[4])pipeline_verts->data,
+                                  (const float (*)[4])draw->pt.user.gs_constants,
+                                  count,
+                                  fpme->vertex_size,
+                                  fpme->vertex_size);
    }
 
    if (draw_pt_post_vs_run( fpme->post_vs,
index 6c1cb48e8b82202da1638d2a7a9cdf9cbd40c247..55151823a14e4071bd539ccd208506ddc6feb6ff 100644 (file)
@@ -100,7 +100,7 @@ static boolean post_vs_cliptest_viewport_gl( struct pt_post_vs *pvs,
    struct vertex_header *out = vertices;
    const float *scale = pvs->draw->viewport.scale;
    const float *trans = pvs->draw->viewport.translate;
-   const unsigned pos = pvs->draw->vs.position_output;
+   const unsigned pos = draw_current_shader_position_output(pvs->draw);
    unsigned clipped = 0;
    unsigned j;
 
@@ -147,6 +147,39 @@ static boolean post_vs_cliptest_viewport_gl( struct pt_post_vs *pvs,
 
 
 
+/* As above plus edgeflags
+ */
+static boolean 
+post_vs_cliptest_viewport_gl_edgeflag(struct pt_post_vs *pvs,
+                                      struct vertex_header *vertices,
+                                      unsigned count,
+                                      unsigned stride )
+{
+   unsigned j;
+   boolean needpipe;
+
+   needpipe = post_vs_cliptest_viewport_gl( pvs, vertices, count, stride);
+
+   /* If present, copy edgeflag VS output into vertex header.
+    * Otherwise, leave header as is.
+    */
+   if (pvs->draw->vs.edgeflag_output) {
+      struct vertex_header *out = vertices;
+      int ef = pvs->draw->vs.edgeflag_output;
+
+      for (j = 0; j < count; j++) {
+         const float *edgeflag = out->data[ef];
+         out->edgeflag = !(edgeflag[0] != 1.0f);
+         needpipe |= !out->edgeflag;
+         out = (struct vertex_header *)( (char *)out + stride );
+      }
+   }
+   return needpipe;
+}
+
+
+
+
 /* If bypass_clipping is set, skip cliptest and rhw divide.
  */
 static boolean post_vs_viewport( struct pt_post_vs *pvs,
@@ -157,7 +190,7 @@ static boolean post_vs_viewport( struct pt_post_vs *pvs,
    struct vertex_header *out = vertices;
    const float *scale = pvs->draw->viewport.scale;
    const float *trans = pvs->draw->viewport.translate;
-   const unsigned pos = pvs->draw->vs.position_output;
+   const unsigned pos = draw_current_shader_position_output(pvs->draw);
    unsigned j;
 
    if (0) debug_printf("%s\n", __FUNCTION__);
@@ -201,17 +234,29 @@ boolean draw_pt_post_vs_run( struct pt_post_vs *pvs,
 void draw_pt_post_vs_prepare( struct pt_post_vs *pvs,
                              boolean bypass_clipping,
                              boolean bypass_viewport,
-                             boolean opengl )
+                             boolean opengl,
+                             boolean need_edgeflags )
 {
-   if (bypass_clipping) {
-      if (bypass_viewport)
-        pvs->run = post_vs_none;
-      else
-        pvs->run = post_vs_viewport;
+   if (!need_edgeflags) {
+      if (bypass_clipping) {
+         if (bypass_viewport)
+            pvs->run = post_vs_none;
+         else
+            pvs->run = post_vs_viewport;
+      }
+      else {
+         /* if (opengl) */
+         pvs->run = post_vs_cliptest_viewport_gl;
+      }
    }
    else {
-      /* if (opengl) */
-      pvs->run = post_vs_cliptest_viewport_gl;
+      /* If we need to copy edgeflags to the vertex header, it should
+       * mean we're running the primitive pipeline.  Hence the bypass
+       * flags should be false.
+       */
+      assert(!bypass_clipping);
+      assert(!bypass_viewport);
+      pvs->run = post_vs_cliptest_viewport_gl_edgeflag;
    }
 }
 
index b61fa291436c4a79abf9c954ec809df0f71dc03a..17c3b8cec269accbbcc8db9ea8fada7731fb2dcd 100644 (file)
@@ -50,16 +50,32 @@ void draw_pt_split_prim(unsigned prim, unsigned *first, unsigned *incr)
       *first = 2;
       *incr = 1;
       break;
+   case PIPE_PRIM_LINES_ADJACENCY:
+      *first = 4;
+      *incr = 2;
+      break;
+   case PIPE_PRIM_LINE_STRIP_ADJACENCY:
+      *first = 4;
+      *incr = 1;
+      break;
    case PIPE_PRIM_TRIANGLES:
       *first = 3;
       *incr = 3;
       break;
+   case PIPE_PRIM_TRIANGLES_ADJACENCY:
+      *first = 6;
+      *incr = 3;
+      break;
    case PIPE_PRIM_TRIANGLE_STRIP:
    case PIPE_PRIM_TRIANGLE_FAN:
    case PIPE_PRIM_POLYGON:
       *first = 3;
       *incr = 1;
       break;
+   case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY:
+      *first = 6;
+      *incr = 1;
+      break;
    case PIPE_PRIM_QUADS:
       *first = 4;
       *incr = 4;
index 010c7a18a7c93e0c0b35546728ca3487f6285a72..f0aec5febabdb0b518cd626c5f28661c08a713d7 100644 (file)
@@ -36,6 +36,10 @@ static void FUNC(struct draw_pt_front_end *frontend,
    case PIPE_PRIM_TRIANGLE_STRIP:
    case PIPE_PRIM_QUADS:
    case PIPE_PRIM_QUAD_STRIP:
+   case PIPE_PRIM_LINES_ADJACENCY:
+   case PIPE_PRIM_LINE_STRIP_ADJACENCY:
+   case PIPE_PRIM_TRIANGLES_ADJACENCY:
+   case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY:
       for (j = 0; j < count;) {
          unsigned remaining = count - j;
          unsigned nr = trim( MIN2(varray->driver_fetch_max, remaining), first, incr );
index 1a0527be63a8380ea9e5962fd7a0d9cf9c71e302..757c48745456d59db25a07084cb1a691d36f07df 100644 (file)
@@ -346,7 +346,8 @@ vcache_check_run( struct draw_pt_front_end *frontend,
                        vcache->fetch_max,
                        draw_count);
       
-   if (max_index == 0xffffffff ||
+   if (max_index >= DRAW_PIPE_MAX_VERTICES ||
+       fetch_count >= UNDEFINED_VERTEX_ID ||
        fetch_count > draw_count) {
       if (0) debug_printf("fail\n");
       goto fail;
@@ -394,6 +395,7 @@ vcache_check_run( struct draw_pt_front_end *frontend,
 
          default:
             assert(0);
+            FREE(storage);
             return;
          }
       }
@@ -422,6 +424,7 @@ vcache_check_run( struct draw_pt_front_end *frontend,
 
          default:
             assert(0);
+            FREE(storage);
             return;
          }
       }
index 790e89ed820af7e7ab8d3c036b8f242a2c31931c..3553689532687ffaa326a5c93863d91f1e7f7c35 100644 (file)
@@ -101,6 +101,9 @@ draw_create_vertex_shader(struct draw_context *draw,
          if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_POSITION &&
              vs->info.output_semantic_index[i] == 0)
             vs->position_output = i;
+         else if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_EDGEFLAG &&
+             vs->info.output_semantic_index[i] == 0)
+            vs->edgeflag_output = i;
       }
    }
 
@@ -120,6 +123,7 @@ draw_bind_vertex_shader(struct draw_context *draw,
       draw->vs.vertex_shader = dvs;
       draw->vs.num_vs_outputs = dvs->info.num_outputs;
       draw->vs.position_output = dvs->position_output;
+      draw->vs.edgeflag_output = dvs->edgeflag_output;
       dvs->prepare( dvs, draw );
    }
    else {
index 89ae158751a931edc5b3c49ed50ebf0dcb3d0b38..e3b807ebd0e1df50ffdf6fa3c4aec523fb9e0b68 100644 (file)
@@ -107,6 +107,7 @@ struct draw_vertex_shader {
 
    struct tgsi_shader_info info;
    unsigned position_output;
+   unsigned edgeflag_output;
 
    /* Extracted from shader:
     */
index 645d7cccbae6d5c2aa5e15e02be3d52b1aeedb7d..1aaae4ab7a4eed74924f4953d83557cb1ad82086 100644 (file)
@@ -361,8 +361,8 @@ static struct x86_reg aos_get_shader_reg_ptr( struct aos_compilation *cp,
 static struct x86_reg get_dst_ptr( struct aos_compilation *cp, 
                                    const struct tgsi_full_dst_register *dst )
 {
-   unsigned file = dst->DstRegister.File;
-   unsigned idx = dst->DstRegister.Index;
+   unsigned file = dst->Register.File;
+   unsigned idx = dst->Register.Index;
    unsigned i;
    
 
@@ -529,27 +529,18 @@ static struct x86_reg fetch_src( struct aos_compilation *cp,
                                  const struct tgsi_full_src_register *src ) 
 {
    struct x86_reg arg0 = aos_get_shader_reg(cp, 
-                                            src->SrcRegister.File, 
-                                            src->SrcRegister.Index);
+                                            src->Register.File, 
+                                            src->Register.Index);
    unsigned i;
    ubyte swz = 0;
    unsigned negs = 0;
    unsigned abs = 0;
 
    for (i = 0; i < 4; i++) {
-      unsigned swizzle = tgsi_util_get_full_src_register_extswizzle( src, i );
+      unsigned swizzle = tgsi_util_get_full_src_register_swizzle( src, i );
       unsigned neg = tgsi_util_get_full_src_register_sign_mode( src, i );
 
-      switch (swizzle) {
-      case TGSI_EXTSWIZZLE_ZERO:
-      case TGSI_EXTSWIZZLE_ONE:
-         AOS_ERROR(cp, "not supporting full swizzles yet in tgsi_aos_sse2");
-         break;
-
-      default:
-         swz |= (swizzle & 0x3) << (i * 2);
-         break;
-      }
+      swz |= (swizzle & 0x3) << (i * 2);
 
       switch (neg) {
       case TGSI_UTIL_SIGN_TOGGLE:
@@ -629,26 +620,13 @@ static void x87_fld_src( struct aos_compilation *cp,
                          unsigned channel ) 
 {
    struct x86_reg arg0 = aos_get_shader_reg_ptr(cp, 
-                                                src->SrcRegister.File, 
-                                                src->SrcRegister.Index);
+                                                src->Register.File, 
+                                                src->Register.Index);
 
-   unsigned swizzle = tgsi_util_get_full_src_register_extswizzle( src, channel );
+   unsigned swizzle = tgsi_util_get_full_src_register_swizzle( src, channel );
    unsigned neg = tgsi_util_get_full_src_register_sign_mode( src, channel );
 
-   switch (swizzle) {
-   case TGSI_EXTSWIZZLE_ZERO:
-      x87_fldz( cp->func );
-      break;
-
-   case TGSI_EXTSWIZZLE_ONE:
-      x87_fld1( cp->func );
-      break;
-
-   default:
-      x87_fld( cp->func, x86_make_disp(arg0, (swizzle & 3) * sizeof(float)) );
-      break;
-   }
-   
+   x87_fld( cp->func, x86_make_disp(arg0, (swizzle & 3) * sizeof(float)) );
 
    switch (neg) {
    case TGSI_UTIL_SIGN_TOGGLE:
@@ -691,15 +669,15 @@ static void store_dest( struct aos_compilation *cp,
 {
    struct x86_reg dst;
 
-   switch (reg->DstRegister.WriteMask) {
+   switch (reg->Register.WriteMask) {
    case 0:
       return;
    
    case TGSI_WRITEMASK_XYZW:
       aos_adopt_xmm_reg(cp, 
                         get_xmm_writable(cp, result), 
-                        reg->DstRegister.File,
-                        reg->DstRegister.Index,
+                        reg->Register.File,
+                        reg->Register.Index,
                         TRUE);
       return;
    default: 
@@ -707,10 +685,10 @@ static void store_dest( struct aos_compilation *cp,
    }
 
    dst = aos_get_shader_reg_xmm(cp, 
-                                reg->DstRegister.File,
-                                reg->DstRegister.Index);
+                                reg->Register.File,
+                                reg->Register.Index);
 
-   switch (reg->DstRegister.WriteMask) {
+   switch (reg->Register.WriteMask) {
    case TGSI_WRITEMASK_X:
       sse_movss(cp->func, dst, get_xmm(cp, result));
       break;
@@ -732,14 +710,14 @@ static void store_dest( struct aos_compilation *cp,
       break;
 
    default:
-      mask_write(cp, dst, result, reg->DstRegister.WriteMask);
+      mask_write(cp, dst, result, reg->Register.WriteMask);
       break;
    }
 
    aos_adopt_xmm_reg(cp, 
                      dst, 
-                     reg->DstRegister.File,
-                     reg->DstRegister.Index,
+                     reg->Register.File,
+                     reg->Register.Index,
                      TRUE);
 
 }
@@ -759,7 +737,7 @@ static void store_scalar_dest( struct aos_compilation *cp,
                                const struct tgsi_full_dst_register *reg,
                                struct x86_reg result )
 {
-   unsigned writemask = reg->DstRegister.WriteMask;
+   unsigned writemask = reg->Register.WriteMask;
    struct x86_reg dst;
 
    if (writemask != TGSI_WRITEMASK_X &&
@@ -776,12 +754,12 @@ static void store_scalar_dest( struct aos_compilation *cp,
 
    result = get_xmm(cp, result);
    dst = aos_get_shader_reg_xmm(cp, 
-                                reg->DstRegister.File,
-                                reg->DstRegister.Index);
+                                reg->Register.File,
+                                reg->Register.Index);
 
 
 
-   switch (reg->DstRegister.WriteMask) {
+   switch (reg->Register.WriteMask) {
    case TGSI_WRITEMASK_X:
       sse_movss(cp->func, dst, result);
       break;
@@ -804,8 +782,8 @@ static void store_scalar_dest( struct aos_compilation *cp,
 
    aos_adopt_xmm_reg(cp, 
                      dst, 
-                     reg->DstRegister.File,
-                     reg->DstRegister.Index,
+                     reg->Register.File,
+                     reg->Register.Index,
                      TRUE);
 }
    
@@ -841,7 +819,7 @@ static void x87_fstp_dest4( struct aos_compilation *cp,
                             const struct tgsi_full_dst_register *dst )
 {
    struct x86_reg ptr = get_dst_ptr(cp, dst); 
-   unsigned writemask = dst->DstRegister.WriteMask;
+   unsigned writemask = dst->Register.WriteMask;
 
    x87_fst_or_nop(cp->func, writemask, 0, ptr);
    x87_fst_or_nop(cp->func, writemask, 1, ptr);
@@ -978,7 +956,7 @@ static void emit_print( struct aos_compilation *cp,
 
 static boolean emit_ABS( struct aos_compilation *cp, const struct tgsi_full_instruction *op ) 
 {
-   struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
+   struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
    struct x86_reg neg = aos_get_internal(cp, IMM_NEGS);
    struct x86_reg tmp = aos_get_xmm_reg(cp);
 
@@ -986,27 +964,27 @@ static boolean emit_ABS( struct aos_compilation *cp, const struct tgsi_full_inst
    sse_mulps(cp->func, tmp, neg);
    sse_maxps(cp->func, tmp, arg0);
    
-   store_dest(cp, &op->FullDstRegisters[0], tmp);
+   store_dest(cp, &op->Dst[0], tmp);
    return TRUE;
 }
 
 static boolean emit_ADD( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
 {
-   struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
-   struct x86_reg arg1 = fetch_src(cp, &op->FullSrcRegisters[1]);
+   struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
+   struct x86_reg arg1 = fetch_src(cp, &op->Src[1]);
    struct x86_reg dst = get_xmm_writable(cp, arg0);
 
    sse_addps(cp->func, dst, arg1);
 
-   store_dest(cp, &op->FullDstRegisters[0], dst);
+   store_dest(cp, &op->Dst[0], dst);
    return TRUE;
 }
 
 static boolean emit_COS( struct aos_compilation *cp, const struct tgsi_full_instruction *op ) 
 {
-   x87_fld_src(cp, &op->FullSrcRegisters[0], 0);
+   x87_fld_src(cp, &op->Src[0], 0);
    x87_fcos(cp->func);
-   x87_fstp_dest4(cp, &op->FullDstRegisters[0]);
+   x87_fstp_dest4(cp, &op->Dst[0]);
    return TRUE;
 }
 
@@ -1015,8 +993,8 @@ static boolean emit_COS( struct aos_compilation *cp, const struct tgsi_full_inst
  */
 static boolean emit_DP3( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
 {
-   struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
-   struct x86_reg arg1 = fetch_src(cp, &op->FullSrcRegisters[1]);
+   struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
+   struct x86_reg arg1 = fetch_src(cp, &op->Src[1]);
    struct x86_reg tmp = aos_get_xmm_reg(cp); 
    struct x86_reg dst = get_xmm_writable(cp, arg0);
 
@@ -1029,14 +1007,14 @@ static boolean emit_DP3( struct aos_compilation *cp, const struct tgsi_full_inst
    sse_addss(cp->func, dst, tmp);
    
    aos_release_xmm_reg(cp, tmp.idx);
-   store_scalar_dest(cp, &op->FullDstRegisters[0], dst);
+   store_scalar_dest(cp, &op->Dst[0], dst);
    return TRUE;
 }
 
 static boolean emit_DP4( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
 {
-   struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
-   struct x86_reg arg1 = fetch_src(cp, &op->FullSrcRegisters[1]);
+   struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
+   struct x86_reg arg1 = fetch_src(cp, &op->Src[1]);
    struct x86_reg tmp = aos_get_xmm_reg(cp);      
    struct x86_reg dst = get_xmm_writable(cp, arg0);
 
@@ -1050,14 +1028,14 @@ static boolean emit_DP4( struct aos_compilation *cp, const struct tgsi_full_inst
    sse_addss(cp->func, dst, tmp);
 
    aos_release_xmm_reg(cp, tmp.idx);
-   store_scalar_dest(cp, &op->FullDstRegisters[0], dst);
+   store_scalar_dest(cp, &op->Dst[0], dst);
    return TRUE;
 }
 
 static boolean emit_DPH( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
 {
-   struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
-   struct x86_reg arg1 = fetch_src(cp, &op->FullSrcRegisters[1]);
+   struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
+   struct x86_reg arg1 = fetch_src(cp, &op->Src[1]);
    struct x86_reg tmp = aos_get_xmm_reg(cp);
    struct x86_reg dst = get_xmm_writable(cp, arg0);
 
@@ -1073,14 +1051,14 @@ static boolean emit_DPH( struct aos_compilation *cp, const struct tgsi_full_inst
    sse_addss(cp->func, dst, tmp);
 
    aos_release_xmm_reg(cp, tmp.idx);
-   store_scalar_dest(cp, &op->FullDstRegisters[0], dst);
+   store_scalar_dest(cp, &op->Dst[0], dst);
    return TRUE;
 }
 
 static boolean emit_DST( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
 {
-    struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
-    struct x86_reg arg1 = fetch_src(cp, &op->FullSrcRegisters[1]);
+    struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
+    struct x86_reg arg1 = fetch_src(cp, &op->Src[1]);
     struct x86_reg dst = aos_get_xmm_reg(cp);
     struct x86_reg tmp = aos_get_xmm_reg(cp);
     struct x86_reg ones = aos_get_internal(cp, IMM_ONES);
@@ -1095,25 +1073,25 @@ static boolean emit_DST( struct aos_compilation *cp, const struct tgsi_full_inst
     sse_mulps(cp->func, dst, tmp);
 
     aos_release_xmm_reg(cp, tmp.idx);
-    store_dest(cp, &op->FullDstRegisters[0], dst);
+    store_dest(cp, &op->Dst[0], dst);
     return TRUE;
 }
 
 static boolean emit_LG2( struct aos_compilation *cp, const struct tgsi_full_instruction *op ) 
 {
    x87_fld1(cp->func);         /* 1 */
-   x87_fld_src(cp, &op->FullSrcRegisters[0], 0);       /* a0 1 */
+   x87_fld_src(cp, &op->Src[0], 0);    /* a0 1 */
    x87_fyl2x(cp->func);        /* log2(a0) */
-   x87_fstp_dest4(cp, &op->FullDstRegisters[0]);
+   x87_fstp_dest4(cp, &op->Dst[0]);
    return TRUE;
 }
 
 #if 0
 static boolean emit_EX2( struct aos_compilation *cp, const struct tgsi_full_instruction *op ) 
 {
-   x87_fld_src(cp, &op->FullSrcRegisters[0], 0);
+   x87_fld_src(cp, &op->Src[0], 0);
    x87_emit_ex2(cp);
-   x87_fstp_dest4(cp, &op->FullDstRegisters[0]);
+   x87_fstp_dest4(cp, &op->Dst[0]);
    return TRUE;
 }
 #endif
@@ -1121,8 +1099,8 @@ static boolean emit_EX2( struct aos_compilation *cp, const struct tgsi_full_inst
 
 static boolean emit_FLR( struct aos_compilation *cp, const struct tgsi_full_instruction *op ) 
 {
-   struct x86_reg dst = get_dst_ptr(cp, &op->FullDstRegisters[0]); 
-   unsigned writemask = op->FullDstRegisters[0].DstRegister.WriteMask;
+   struct x86_reg dst = get_dst_ptr(cp, &op->Dst[0]); 
+   unsigned writemask = op->Dst[0].Register.WriteMask;
    int i;
 
    set_fpu_round_neg_inf( cp );
@@ -1131,7 +1109,7 @@ static boolean emit_FLR( struct aos_compilation *cp, const struct tgsi_full_inst
     */
    for (i = 3; i >= 0; i--) {
       if (writemask & (1<<i)) {
-         x87_fld_src(cp, &op->FullSrcRegisters[0], i);   
+         x87_fld_src(cp, &op->Src[0], i);   
       }
    }
 
@@ -1148,8 +1126,8 @@ static boolean emit_FLR( struct aos_compilation *cp, const struct tgsi_full_inst
 
 static boolean emit_RND( struct aos_compilation *cp, const struct tgsi_full_instruction *op ) 
 {
-   struct x86_reg dst = get_dst_ptr(cp, &op->FullDstRegisters[0]); 
-   unsigned writemask = op->FullDstRegisters[0].DstRegister.WriteMask;
+   struct x86_reg dst = get_dst_ptr(cp, &op->Dst[0]); 
+   unsigned writemask = op->Dst[0].Register.WriteMask;
    int i;
 
    set_fpu_round_nearest( cp );
@@ -1158,7 +1136,7 @@ static boolean emit_RND( struct aos_compilation *cp, const struct tgsi_full_inst
     */
    for (i = 3; i >= 0; i--) {
       if (writemask & (1<<i)) {
-         x87_fld_src(cp, &op->FullSrcRegisters[0], i);   
+         x87_fld_src(cp, &op->Src[0], i);   
       }
    }
 
@@ -1175,10 +1153,10 @@ static boolean emit_RND( struct aos_compilation *cp, const struct tgsi_full_inst
 
 static boolean emit_FRC( struct aos_compilation *cp, const struct tgsi_full_instruction *op ) 
 {
-   struct x86_reg dst = get_dst_ptr(cp, &op->FullDstRegisters[0]); 
+   struct x86_reg dst = get_dst_ptr(cp, &op->Dst[0]); 
    struct x86_reg st0 = x86_make_reg(file_x87, 0);
    struct x86_reg st1 = x86_make_reg(file_x87, 1);
-   unsigned writemask = op->FullDstRegisters[0].DstRegister.WriteMask;
+   unsigned writemask = op->Dst[0].Register.WriteMask;
    int i;
 
    set_fpu_round_neg_inf( cp );
@@ -1188,7 +1166,7 @@ static boolean emit_FRC( struct aos_compilation *cp, const struct tgsi_full_inst
     */
    for (i = 3; i >= 0; i--) {
       if (writemask & (1<<i)) {
-         x87_fld_src(cp, &op->FullSrcRegisters[0], i);   
+         x87_fld_src(cp, &op->Src[0], i);   
       }
    }
 
@@ -1212,7 +1190,7 @@ static boolean emit_FRC( struct aos_compilation *cp, const struct tgsi_full_inst
 static boolean emit_LIT( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
 {
    struct x86_reg ecx = x86_make_reg( file_REG32, reg_CX );
-   unsigned writemask = op->FullDstRegisters[0].DstRegister.WriteMask;
+   unsigned writemask = op->Dst[0].Register.WriteMask;
    unsigned lit_count = cp->lit_count++;
    struct x86_reg result, arg0;
    unsigned i;
@@ -1231,10 +1209,10 @@ static boolean emit_LIT( struct aos_compilation *cp, const struct tgsi_full_inst
    if (writemask != TGSI_WRITEMASK_XYZW) 
       result = x86_make_disp(cp->machine_EDX, Offset(struct aos_machine, tmp[0]));
    else 
-      result = get_dst_ptr(cp, &op->FullDstRegisters[0]);    
+      result = get_dst_ptr(cp, &op->Dst[0]);    
 
    
-   arg0 = fetch_src( cp, &op->FullSrcRegisters[0] );
+   arg0 = fetch_src( cp, &op->Src[0] );
    if (arg0.file == file_XMM) {
       struct x86_reg tmp = x86_make_disp(cp->machine_EDX, 
                                          Offset(struct aos_machine, tmp[1]));
@@ -1281,7 +1259,7 @@ static boolean emit_LIT( struct aos_compilation *cp, const struct tgsi_full_inst
 
    if (writemask != TGSI_WRITEMASK_XYZW) {
       store_dest( cp, 
-                  &op->FullDstRegisters[0],
+                  &op->Dst[0],
                   get_xmm_writable( cp, result ) );
    }
 
@@ -1291,8 +1269,8 @@ static boolean emit_LIT( struct aos_compilation *cp, const struct tgsi_full_inst
 #if 0   
 static boolean emit_inline_LIT( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
 {
-   struct x86_reg dst = get_dst_ptr(cp, &op->FullDstRegisters[0]); 
-   unsigned writemask = op->FullDstRegisters[0].DstRegister.WriteMask;
+   struct x86_reg dst = get_dst_ptr(cp, &op->Dst[0]); 
+   unsigned writemask = op->Dst[0].Register.WriteMask;
 
    if (writemask & TGSI_WRITEMASK_YZ) {
       struct x86_reg st1 = x86_make_reg(file_x87, 1);
@@ -1308,13 +1286,13 @@ static boolean emit_inline_LIT( struct aos_compilation *cp, const struct tgsi_fu
        */
       x87_fldz(cp->func);                           /* 1 0  */
 #endif
-      x87_fld_src(cp, &op->FullSrcRegisters[0], 1); /* a1 1 0  */
+      x87_fld_src(cp, &op->Src[0], 1); /* a1 1 0  */
       x87_fcomi(cp->func, st2);                            /* a1 1 0  */
       x87_fcmovb(cp->func, st1);                    /* a1' 1 0  */
       x87_fstp(cp->func, st1);                      /* a1' 0  */
       x87_fstp(cp->func, st1);                      /* a1'  */
 
-      x87_fld_src(cp, &op->FullSrcRegisters[0], 3); /* a3 a1'  */
+      x87_fld_src(cp, &op->Src[0], 3); /* a3 a1'  */
       x87_fxch(cp->func, st1);                      /* a1' a3  */
       
 
@@ -1327,7 +1305,7 @@ static boolean emit_inline_LIT( struct aos_compilation *cp, const struct tgsi_fu
       /* a0' = max2(a0, 0):
        */
       x87_fldz(cp->func);                           /* 0 r2 */
-      x87_fld_src(cp, &op->FullSrcRegisters[0], 0); /* a0 0 r2 */
+      x87_fld_src(cp, &op->Src[0], 0); /* a0 0 r2 */
       x87_fcomi(cp->func, st1);        
       x87_fcmovb(cp->func, st1);                    /* a0' 0 r2 */
 
@@ -1355,58 +1333,58 @@ static boolean emit_inline_LIT( struct aos_compilation *cp, const struct tgsi_fu
 
 static boolean emit_MAX( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
 {
-   struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
-   struct x86_reg arg1 = fetch_src(cp, &op->FullSrcRegisters[1]);
+   struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
+   struct x86_reg arg1 = fetch_src(cp, &op->Src[1]);
    struct x86_reg dst = get_xmm_writable(cp, arg0);
 
    sse_maxps(cp->func, dst, arg1);
 
-   store_dest(cp, &op->FullDstRegisters[0], dst);
+   store_dest(cp, &op->Dst[0], dst);
    return TRUE;
 }
 
 
 static boolean emit_MIN( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
 {
-   struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
-   struct x86_reg arg1 = fetch_src(cp, &op->FullSrcRegisters[1]);
+   struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
+   struct x86_reg arg1 = fetch_src(cp, &op->Src[1]);
    struct x86_reg dst = get_xmm_writable(cp, arg0);
 
    sse_minps(cp->func, dst, arg1);
 
-   store_dest(cp, &op->FullDstRegisters[0], dst);
+   store_dest(cp, &op->Dst[0], dst);
    return TRUE;
 }
 
 static boolean emit_MOV( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
 {
-   struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
+   struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
    struct x86_reg dst = get_xmm_writable(cp, arg0);
 
    /* potentially nothing to do */
 
-   store_dest(cp, &op->FullDstRegisters[0], dst);
+   store_dest(cp, &op->Dst[0], dst);
    return TRUE;
 }
 
 static boolean emit_MUL( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
 {
-   struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
-   struct x86_reg arg1 = fetch_src(cp, &op->FullSrcRegisters[1]);
+   struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
+   struct x86_reg arg1 = fetch_src(cp, &op->Src[1]);
    struct x86_reg dst = get_xmm_writable(cp, arg0);
 
    sse_mulps(cp->func, dst, arg1);
 
-   store_dest(cp, &op->FullDstRegisters[0], dst);
+   store_dest(cp, &op->Dst[0], dst);
    return TRUE;
 }
 
 
 static boolean emit_MAD( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
 {
-   struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
-   struct x86_reg arg1 = fetch_src(cp, &op->FullSrcRegisters[1]);
-   struct x86_reg arg2 = fetch_src(cp, &op->FullSrcRegisters[2]);
+   struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
+   struct x86_reg arg1 = fetch_src(cp, &op->Src[1]);
+   struct x86_reg arg2 = fetch_src(cp, &op->Src[2]);
 
    /* If we can't clobber old contents of arg0, get a temporary & copy
     * it there, then clobber it...
@@ -1415,7 +1393,7 @@ static boolean emit_MAD( struct aos_compilation *cp, const struct tgsi_full_inst
 
    sse_mulps(cp->func, arg0, arg1);
    sse_addps(cp->func, arg0, arg2);
-   store_dest(cp, &op->FullDstRegisters[0], arg0);
+   store_dest(cp, &op->Dst[0], arg0);
    return TRUE;
 }
 
@@ -1447,13 +1425,13 @@ static float PIPE_CDECL _exp2(float x)
 static boolean emit_POW( struct aos_compilation *cp, const struct tgsi_full_instruction *op ) 
 {
 #if 0
-   x87_fld_src(cp, &op->FullSrcRegisters[1], 0);  /* a1.x */
-   x87_fld_src(cp, &op->FullSrcRegisters[0], 0);       /* a0.x a1.x */
+   x87_fld_src(cp, &op->Src[1], 0);  /* a1.x */
+   x87_fld_src(cp, &op->Src[0], 0);    /* a0.x a1.x */
    x87_fyl2x(cp->func);                                        /* a1*log2(a0) */
 
    x87_emit_ex2( cp );         /* 2^(a1*log2(a0)) */
 
-   x87_fstp_dest4(cp, &op->FullDstRegisters[0]);
+   x87_fstp_dest4(cp, &op->Dst[0]);
 #else
    uint i;
 
@@ -1472,9 +1450,9 @@ static boolean emit_POW( struct aos_compilation *cp, const struct tgsi_full_inst
 
    x86_lea( cp->func, cp->stack_ESP, x86_make_disp(cp->stack_ESP, -8) );
 
-   x87_fld_src( cp, &op->FullSrcRegisters[1], 0 );
+   x87_fld_src( cp, &op->Src[1], 0 );
    x87_fstp( cp->func, x86_make_disp( cp->stack_ESP, 4 ) );
-   x87_fld_src( cp, &op->FullSrcRegisters[0], 0 );
+   x87_fld_src( cp, &op->Src[0], 0 );
    x87_fstp( cp->func, x86_make_disp( cp->stack_ESP, 0 ) );
 
    /* tmp_EAX has been pushed & will be restored below */
@@ -1489,7 +1467,7 @@ static boolean emit_POW( struct aos_compilation *cp, const struct tgsi_full_inst
     */
    cp->func->x87_stack++;
 
-   x87_fstp_dest4( cp, &op->FullDstRegisters[0] );
+   x87_fstp_dest4( cp, &op->Dst[0] );
 #endif
    return TRUE;
 }
@@ -1515,7 +1493,7 @@ static boolean emit_EXPBASE2( struct aos_compilation *cp, const struct tgsi_full
 
    x86_lea( cp->func, cp->stack_ESP, x86_make_disp(cp->stack_ESP, -4) );
 
-   x87_fld_src( cp, &op->FullSrcRegisters[0], 0 );
+   x87_fld_src( cp, &op->Src[0], 0 );
    x87_fstp( cp->func, x86_make_disp( cp->stack_ESP, 0 ) );
 
    /* tmp_EAX has been pushed & will be restored below */
@@ -1530,7 +1508,7 @@ static boolean emit_EXPBASE2( struct aos_compilation *cp, const struct tgsi_full
     */
    cp->func->x87_stack++;
 
-   x87_fstp_dest4( cp, &op->FullDstRegisters[0] );
+   x87_fstp_dest4( cp, &op->Dst[0] );
 
    return TRUE;
 }
@@ -1539,7 +1517,7 @@ static boolean emit_EXPBASE2( struct aos_compilation *cp, const struct tgsi_full
 
 static boolean emit_RCP( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
 {
-   struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
+   struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
    struct x86_reg dst = aos_get_xmm_reg(cp);
 
    if (cp->have_sse2) {
@@ -1553,7 +1531,7 @@ static boolean emit_RCP( struct aos_compilation *cp, const struct tgsi_full_inst
       sse_divss(cp->func, dst, arg0);
    }
 
-   store_scalar_dest(cp, &op->FullDstRegisters[0], dst);
+   store_scalar_dest(cp, &op->Dst[0], dst);
    return TRUE;
 }
 
@@ -1573,14 +1551,14 @@ static boolean emit_RCP( struct aos_compilation *cp, const struct tgsi_full_inst
 static boolean emit_RSQ( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
 {
    if (0) {
-      struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
+      struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
       struct x86_reg r = aos_get_xmm_reg(cp);
       sse_rsqrtss(cp->func, r, arg0);
-      store_scalar_dest(cp, &op->FullDstRegisters[0], r);
+      store_scalar_dest(cp, &op->Dst[0], r);
       return TRUE;
    }
    else {
-      struct x86_reg arg0           = fetch_src(cp, &op->FullSrcRegisters[0]);
+      struct x86_reg arg0           = fetch_src(cp, &op->Src[0]);
       struct x86_reg r              = aos_get_xmm_reg(cp);
 
       struct x86_reg neg_half       = get_reg_ptr( cp, AOS_FILE_INTERNAL, IMM_RSQ );
@@ -1600,7 +1578,7 @@ static boolean emit_RSQ( struct aos_compilation *cp, const struct tgsi_full_inst
       sse_addss(   cp->func, tmp, one_point_five ); /* 1.5 - .5 * a * r * r */
       sse_mulss(   cp->func, r,  tmp );             /* r * (1.5 - .5 * a * r * r) */
 
-      store_scalar_dest(cp, &op->FullDstRegisters[0], r);
+      store_scalar_dest(cp, &op->Dst[0], r);
 
       aos_release_xmm_reg(cp, tmp.idx);
 
@@ -1611,23 +1589,23 @@ static boolean emit_RSQ( struct aos_compilation *cp, const struct tgsi_full_inst
 
 static boolean emit_SGE( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
 {
-   struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
-   struct x86_reg arg1 = fetch_src(cp, &op->FullSrcRegisters[1]);
+   struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
+   struct x86_reg arg1 = fetch_src(cp, &op->Src[1]);
    struct x86_reg ones = aos_get_internal(cp, IMM_ONES);
    struct x86_reg dst = get_xmm_writable(cp, arg0);
 
    sse_cmpps(cp->func, dst, arg1, cc_NotLessThan);
    sse_andps(cp->func, dst, ones);
 
-   store_dest(cp, &op->FullDstRegisters[0], dst);
+   store_dest(cp, &op->Dst[0], dst);
    return TRUE;
 }
 
 static boolean emit_SIN( struct aos_compilation *cp, const struct tgsi_full_instruction *op ) 
 {
-   x87_fld_src(cp, &op->FullSrcRegisters[0], 0);
+   x87_fld_src(cp, &op->Src[0], 0);
    x87_fsin(cp->func);
-   x87_fstp_dest4(cp, &op->FullDstRegisters[0]);
+   x87_fstp_dest4(cp, &op->Dst[0]);
    return TRUE;
 }
 
@@ -1635,46 +1613,46 @@ static boolean emit_SIN( struct aos_compilation *cp, const struct tgsi_full_inst
 
 static boolean emit_SLT( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
 {
-   struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
-   struct x86_reg arg1 = fetch_src(cp, &op->FullSrcRegisters[1]);
+   struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
+   struct x86_reg arg1 = fetch_src(cp, &op->Src[1]);
    struct x86_reg ones = aos_get_internal(cp, IMM_ONES);
    struct x86_reg dst = get_xmm_writable(cp, arg0);
    
    sse_cmpps(cp->func, dst, arg1, cc_LessThan);
    sse_andps(cp->func, dst, ones);
 
-   store_dest(cp, &op->FullDstRegisters[0], dst);
+   store_dest(cp, &op->Dst[0], dst);
    return TRUE;
 }
 
 static boolean emit_SUB( struct aos_compilation *cp, const struct tgsi_full_instruction *op ) 
 {
-   struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
-   struct x86_reg arg1 = fetch_src(cp, &op->FullSrcRegisters[1]);
+   struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
+   struct x86_reg arg1 = fetch_src(cp, &op->Src[1]);
    struct x86_reg dst = get_xmm_writable(cp, arg0);
 
    sse_subps(cp->func, dst, arg1);
 
-   store_dest(cp, &op->FullDstRegisters[0], dst);
+   store_dest(cp, &op->Dst[0], dst);
    return TRUE;
 }
 
 static boolean emit_TRUNC( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
 {
-   struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
+   struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
    struct x86_reg tmp0 = aos_get_xmm_reg(cp);
 
    sse2_cvttps2dq(cp->func, tmp0, arg0);
    sse2_cvtdq2ps(cp->func, tmp0, tmp0);
 
-   store_dest(cp, &op->FullDstRegisters[0], tmp0);
+   store_dest(cp, &op->Dst[0], tmp0);
    return TRUE;
 }
 
 static boolean emit_XPD( struct aos_compilation *cp, const struct tgsi_full_instruction *op ) 
 {
-   struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
-   struct x86_reg arg1 = fetch_src(cp, &op->FullSrcRegisters[1]);
+   struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
+   struct x86_reg arg1 = fetch_src(cp, &op->Src[1]);
    struct x86_reg tmp0 = aos_get_xmm_reg(cp);
    struct x86_reg tmp1 = aos_get_xmm_reg(cp);
 
@@ -1692,7 +1670,7 @@ static boolean emit_XPD( struct aos_compilation *cp, const struct tgsi_full_inst
 
 
    aos_release_xmm_reg(cp, tmp0.idx);
-   store_dest(cp, &op->FullDstRegisters[0], tmp1);
+   store_dest(cp, &op->Dst[0], tmp1);
    return TRUE;
 }
 
@@ -1919,10 +1897,10 @@ static void find_last_write_outputs( struct aos_compilation *cp )
          continue;
 
       for (i = 0; i < TGSI_FULL_MAX_DST_REGISTERS; i++) {
-         if (parse.FullToken.FullInstruction.FullDstRegisters[i].DstRegister.File ==
+         if (parse.FullToken.FullInstruction.Dst[i].Register.File ==
              TGSI_FILE_OUTPUT) 
          {
-            unsigned idx = parse.FullToken.FullInstruction.FullDstRegisters[i].DstRegister.Index;
+            unsigned idx = parse.FullToken.FullInstruction.Dst[i].Register.Index;
             cp->output_last_write[idx] = this_instruction;
          }
       }
index 7ee567d4789823fb1a0a645e8aa87cb997e85d0e..d16692584e5236fc2874c99c37954c534693da21 100644 (file)
@@ -147,11 +147,12 @@ static void PIPE_CDECL vsvg_run_elts( struct draw_vs_varient *varient,
    vsvg->base.vs->run_linear( vsvg->base.vs, 
                               temp_buffer,
                               temp_buffer,
-                              (const float (*)[4])vsvg->base.vs->draw->pt.user.constants,
+                              (const float (*)[4])vsvg->base.vs->draw->pt.user.vs_constants,
                               count,
                               temp_vertex_stride, 
                               temp_vertex_stride);
 
+   /* FIXME: geometry shading? */
 
    if (vsvg->base.key.clip) {
       /* not really handling clipping, just do the rhw so we can
@@ -207,7 +208,7 @@ static void PIPE_CDECL vsvg_run_linear( struct draw_vs_varient *varient,
    vsvg->base.vs->run_linear( vsvg->base.vs, 
                               temp_buffer,
                               temp_buffer,
-                              (const float (*)[4])vsvg->base.vs->draw->pt.user.constants,
+                              (const float (*)[4])vsvg->base.vs->draw->pt.user.vs_constants,
                               count,
                               temp_vertex_stride, 
                               temp_vertex_stride);
diff --git a/src/gallium/auxiliary/gallivm/Makefile b/src/gallium/auxiliary/gallivm/Makefile
deleted file mode 100644 (file)
index 5a96d94..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-# -*-makefile-*-
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = gallivm
-
-
-GALLIVM_SOURCES = \
-        gallivm.cpp  \
-        gallivm_cpu.cpp \
-        instructions.cpp  \
-        loweringpass.cpp \
-        tgsitollvm.cpp \
-        storage.cpp \
-        storagesoa.cpp \
-        instructionssoa.cpp
-
-INC_SOURCES = gallivm_builtins.cpp gallivmsoabuiltins.cpp
-
-CPP_SOURCES = \
-       $(GALLIVM_SOURCES)
-
-C_SOURCES =
-ASM_SOURCES =
-
-OBJECTS = $(C_SOURCES:.c=.o) \
-          $(CPP_SOURCES:.cpp=.o) \
-         $(ASM_SOURCES:.S=.o)
-
-### Include directories
-INCLUDES = \
-       -I. \
-       -I$(TOP)/src/gallium/drivers \
-       -I$(TOP)/src/gallium/auxiliary \
-       -I$(TOP)/src/gallium/include \
-       -I$(TOP)/src/mesa \
-       -I$(TOP)/include
-
-
-##### RULES #####
-
-.c.o:
-       $(CC) -c $(INCLUDES) $(LLVM_CFLAGS) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-.cpp.o:
-       $(CXX) -c $(INCLUDES) $(LLVM_CXXFLAGS) $(CXXFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-.S.o:
-       $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES)  $< -o $@
-
-##### TARGETS #####
-
-default:: depend symlinks $(LIBNAME)
-
-
-$(LIBNAME): $(OBJECTS) Makefile
-       $(TOP)/bin/mklib -o $@ -static $(OBJECTS)
-
-
-depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(INC_SOURCES)
-       rm -f depend
-       touch depend
-       $(MKDEP) $(MKDEP_OPTIONS) $(DRIVER_DEFINES) $(INCLUDES) $(C_SOURCES) $(CPP_SOURCES) \
-               $(ASM_SOURCES) $(INC_SOURCES) 2> /dev/null
-
-
-gallivm_builtins.cpp: llvm_builtins.c
-       clang --emit-llvm < $< |llvm-as|opt -std-compile-opts > temp1.bin
-       (echo "static const unsigned char llvm_builtins_data[] = {"; od -txC temp1.bin | sed -e "s/^[0-9]*//" -e s"/ \([0-9a-f][0-9a-f]\)/0x\1,/g" -e"\$$d" | sed -e"\$$s/,$$/,0x00};/") >$@
-       rm temp1.bin
-
-gallivmsoabuiltins.cpp: soabuiltins.c
-       clang --emit-llvm < $< |llvm-as|opt -std-compile-opts > temp2.bin
-       (echo "static const unsigned char soabuiltins_data[] = {"; od -txC temp2.bin | sed -e "s/^[0-9]*//" -e s"/ \([0-9a-f][0-9a-f]\)/0x\1,/g" -e"\$$d" | sed -e"\$$s/,$$/,0x00};/") >$@
-       rm temp2.bin
-
-# Emacs tags
-tags:
-       etags `find . -name \*.[ch]` `find ../include`
-
-
-# Remove .o and backup files
-clean:
-       -rm -f *.o */*.o *~ *.so *~ server/*.o
-       -rm -f depend depend.bak
-       -rm -f gallivm_builtins.cpp
-       -rm -f gallivmsoabuiltins.cpp
-
-symlinks:
-
-
-include depend
diff --git a/src/gallium/auxiliary/gallivm/SConscript b/src/gallium/auxiliary/gallivm/SConscript
deleted file mode 100644 (file)
index c0aa51b..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-Import('*')
-
-gallivm = env.ConvenienceLibrary(
-       target = 'gallivm',
-       source = [
-        'gallivm.cpp',
-        'gallivm_cpu.cpp',
-        'instructions.cpp',
-        'loweringpass.cpp',
-        'tgsitollvm.cpp',
-        'storage.cpp',
-        'storagesoa.cpp',
-        'instructionssoa.cpp',
-       ])
-
-auxiliaries.insert(0, gallivm)
index bf84401e11213425c77fe40724a4120b9cee3799..8f7d3b71004b1793f9d06d3fc07b3d43aab88844 100644 (file)
@@ -94,8 +94,8 @@ translate_declaration(struct gallivm_ir *prog,
       unsigned first, last, mask;
       uint interp_method;
 
-      first = decl->DeclarationRange.First;
-      last = decl->DeclarationRange.Last;
+      first = decl->Range.First;
+      last = decl->Range.Last;
       mask = decl->Declaration.UsageMask;
 
       /* Do not touch WPOS.xy */
@@ -149,7 +149,7 @@ translate_declarationir(struct gallivm_ir *,
                       struct tgsi_full_declaration *)
 {
    if (decl->Declaration.File == TGSI_FILE_ADDRESS) {
-      int idx = decl->DeclarationRange.First;
+      int idx = decl->Range.First;
       storage->addAddress(idx);
    }
 }
@@ -234,26 +234,26 @@ translate_instruction(llvm::Module *module,
    inputs[3] = 0;
 
    for (int i = 0; i < inst->Instruction.NumSrcRegs; ++i) {
-      struct tgsi_full_src_register *src = &inst->FullSrcRegisters[i];
+      struct tgsi_full_src_register *src = &inst->Src[i];
       llvm::Value *val = 0;
       llvm::Value *indIdx = 0;
 
-      if (src->SrcRegister.Indirect) {
-         indIdx = storage->addrElement(src->SrcRegisterInd.Index);
+      if (src->Register.Indirect) {
+         indIdx = storage->addrElement(src->Indirect.Index);
          indIdx = storage->extractIndex(indIdx);
       }
-      if (src->SrcRegister.File == TGSI_FILE_CONSTANT) {
-         val = storage->constElement(src->SrcRegister.Index, indIdx);
-      } else if (src->SrcRegister.File == TGSI_FILE_INPUT) {
-         val = storage->inputElement(src->SrcRegister.Index, indIdx);
-      } else if (src->SrcRegister.File == TGSI_FILE_TEMPORARY) {
-         val = storage->tempElement(src->SrcRegister.Index);
-      } else if (src->SrcRegister.File == TGSI_FILE_OUTPUT) {
-         val = storage->outputElement(src->SrcRegister.Index, indIdx);
-      } else if (src->SrcRegister.File == TGSI_FILE_IMMEDIATE) {
-         val = storage->immediateElement(src->SrcRegister.Index);
+      if (src->Register.File == TGSI_FILE_CONSTANT) {
+         val = storage->constElement(src->Register.Index, indIdx);
+      } else if (src->Register.File == TGSI_FILE_INPUT) {
+         val = storage->inputElement(src->Register.Index, indIdx);
+      } else if (src->Register.File == TGSI_FILE_TEMPORARY) {
+         val = storage->tempElement(src->Register.Index);
+      } else if (src->Register.File == TGSI_FILE_OUTPUT) {
+         val = storage->outputElement(src->Register.Index, indIdx);
+      } else if (src->Register.File == TGSI_FILE_IMMEDIATE) {
+         val = storage->immediateElement(src->Register.Index);
       } else {
-         fprintf(stderr, "ERROR: not supported llvm source %d\n", src->SrcRegister.File);
+         fprintf(stderr, "ERROR: not supported llvm source %d\n", src->Register.File);
          return;
       }
 
@@ -552,7 +552,7 @@ translate_instruction(llvm::Module *module,
       break;
    case TGSI_OPCODE_SHL:
       break;
-   case TGSI_OPCODE_SHR:
+   case TGSI_OPCODE_ISHR:
       break;
    case TGSI_OPCODE_AND:
       break;
@@ -656,14 +656,14 @@ translate_instruction(llvm::Module *module,
 
    /* store results  */
    for (int i = 0; i < inst->Instruction.NumDstRegs; ++i) {
-      struct tgsi_full_dst_register *dst = &inst->FullDstRegisters[i];
-
-      if (dst->DstRegister.File == TGSI_FILE_OUTPUT) {
-         storage->setOutputElement(dst->DstRegister.Index, out, dst->DstRegister.WriteMask);
-      } else if (dst->DstRegister.File == TGSI_FILE_TEMPORARY) {
-         storage->setTempElement(dst->DstRegister.Index, out, dst->DstRegister.WriteMask);
-      } else if (dst->DstRegister.File == TGSI_FILE_ADDRESS) {
-         storage->setAddrElement(dst->DstRegister.Index, out, dst->DstRegister.WriteMask);
+      struct tgsi_full_dst_register *dst = &inst->Dst[i];
+
+      if (dst->Register.File == TGSI_FILE_OUTPUT) {
+         storage->setOutputElement(dst->Register.Index, out, dst->Register.WriteMask);
+      } else if (dst->Register.File == TGSI_FILE_TEMPORARY) {
+         storage->setTempElement(dst->Register.Index, out, dst->Register.WriteMask);
+      } else if (dst->Register.File == TGSI_FILE_ADDRESS) {
+         storage->setAddrElement(dst->Register.Index, out, dst->Register.WriteMask);
       } else {
          fprintf(stderr, "ERROR: unsupported LLVM destination!");
          assert(!"wrong destination");
@@ -683,16 +683,16 @@ translate_instructionir(llvm::Module *module,
    std::vector< std::vector<llvm::Value*> > inputs(inst->Instruction.NumSrcRegs);
 
    for (int i = 0; i < inst->Instruction.NumSrcRegs; ++i) {
-      struct tgsi_full_src_register *src = &inst->FullSrcRegisters[i];
+      struct tgsi_full_src_register *src = &inst->Src[i];
       std::vector<llvm::Value*> val;
       llvm::Value *indIdx = 0;
       int swizzle = swizzleInt(src);
 
-      if (src->SrcRegister.Indirect) {
-         indIdx = storage->addrElement(src->SrcRegisterInd.Index);
+      if (src->Register.Indirect) {
+         indIdx = storage->addrElement(src->Indirect.Index);
       }
-      val = storage->load((enum tgsi_file_type)src->SrcRegister.File,
-                          src->SrcRegister.Index, swizzle, instr->getIRBuilder(), indIdx);
+      val = storage->load((enum tgsi_file_type)src->Register.File,
+                          src->Register.Index, swizzle, instr->getIRBuilder(), indIdx);
 
       inputs[i] = val;
    }
@@ -919,7 +919,7 @@ translate_instructionir(llvm::Module *module,
       break;
    case TGSI_OPCODE_SHL:
       break;
-   case TGSI_OPCODE_SHR:
+   case TGSI_OPCODE_ISHR:
       break;
    case TGSI_OPCODE_AND:
       break;
@@ -993,9 +993,9 @@ translate_instructionir(llvm::Module *module,
 
    /* store results  */
    for (int i = 0; i < inst->Instruction.NumDstRegs; ++i) {
-      struct tgsi_full_dst_register *dst = &inst->FullDstRegisters[i];
-      storage->store((enum tgsi_file_type)dst->DstRegister.File,
-                     dst->DstRegister.Index, out, dst->DstRegister.WriteMask,
+      struct tgsi_full_dst_register *dst = &inst->Dst[i];
+      storage->store((enum tgsi_file_type)dst->Register.File,
+                     dst->Register.Index, out, dst->Register.WriteMask,
                     instr->getIRBuilder() );
    }
 }
diff --git a/src/gallium/auxiliary/indices/Makefile b/src/gallium/auxiliary/indices/Makefile
deleted file mode 100644 (file)
index f2ebc3f..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = indices
-
-C_SOURCES = \
-       u_indices_gen.c \
-       u_unfilled_gen.c 
-
-include ../../Makefile.template
-
-u_indices_gen.c: u_indices_gen.py
-       python $< > $@
-
-u_unfilled_gen.c: u_unfilled_gen.py
-       python $< > $@
diff --git a/src/gallium/auxiliary/indices/SConscript b/src/gallium/auxiliary/indices/SConscript
deleted file mode 100644 (file)
index 712e215..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-Import('*')
-
-from sys import executable as python_cmd
-
-env.CodeGenerate(
-       target = 'u_indices_gen.c', 
-       script = 'u_indices_gen.py', 
-       source = [],
-       command = python_cmd + ' $SCRIPT > $TARGET'
-)
-
-env.CodeGenerate(
-       target = 'u_unfilled_gen.c', 
-       script = 'u_unfilled_gen.py', 
-       source = [],
-       command = python_cmd + ' $SCRIPT > $TARGET'
-)
-
-indices = env.ConvenienceLibrary(
-       target = 'indices',
-       source = [
-#               'u_indices.c',
-#               'u_unfilled_indices.c',
-               'u_indices_gen.c',
-               'u_unfilled_gen.c',
-       ])
-
-auxiliaries.insert(0, indices)
diff --git a/src/gallium/auxiliary/pipebuffer/Makefile b/src/gallium/auxiliary/pipebuffer/Makefile
deleted file mode 100644 (file)
index 1c00ba8..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = pipebuffer
-
-C_SOURCES = \
-       pb_buffer_fenced.c \
-       pb_buffer_malloc.c \
-       pb_bufmgr_alt.c \
-       pb_bufmgr_cache.c \
-       pb_bufmgr_debug.c \
-       pb_bufmgr_fenced.c \
-       pb_bufmgr_mm.c \
-       pb_bufmgr_ondemand.c \
-       pb_bufmgr_pool.c \
-       pb_bufmgr_slab.c \
-       pb_validate.c
-
-include ../../Makefile.template
diff --git a/src/gallium/auxiliary/pipebuffer/SConscript b/src/gallium/auxiliary/pipebuffer/SConscript
deleted file mode 100644 (file)
index 8e9f06a..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-Import('*')
-
-pipebuffer = env.ConvenienceLibrary(
-       target = 'pipebuffer',
-       source = [
-               'pb_buffer_fenced.c',
-               'pb_buffer_malloc.c',
-               'pb_bufmgr_alt.c',
-               'pb_bufmgr_cache.c',
-               'pb_bufmgr_debug.c',
-               'pb_bufmgr_fenced.c',
-               'pb_bufmgr_mm.c',
-               'pb_bufmgr_ondemand.c',
-               'pb_bufmgr_pool.c',
-               'pb_bufmgr_slab.c',
-               'pb_validate.c',
-       ])
-
-auxiliaries.insert(0, pipebuffer)
index 2590546cb4ad722744d55b798cf1933bbb47e270..eb7e84be84863c1a3336ccde8dacd92bde9cd294 100644 (file)
@@ -46,7 +46,7 @@
 
 #include "pipe/p_compiler.h"
 #include "util/u_debug.h"
-#include "pipe/p_error.h"
+#include "pipe/p_defines.h"
 #include "pipe/p_state.h"
 
 
@@ -237,8 +237,9 @@ pb_reference(struct pb_buffer **dst,
 {
    struct pb_buffer *old = *dst;
 
-   if (pipe_reference((struct pipe_reference**)dst, &src->base.reference))
+   if (pipe_reference(&(*dst)->base.reference, &src->base.reference))
       pb_destroy( old );
+   *dst = src;
 }
 
 
index d31476228c2f8b5cc4f7b95c1e3694a95b8a71a9..ba6f7b15f9ec5ec48dfcde867d67b48a688f37ea 100644 (file)
@@ -1,6 +1,6 @@
 /**************************************************************************
  *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2007-2009 VMware, Inc.
  * All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -18,7 +18,7 @@
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -42,7 +42,7 @@
 #endif
 
 #include "pipe/p_compiler.h"
-#include "pipe/p_error.h"
+#include "pipe/p_defines.h"
 #include "util/u_debug.h"
 #include "pipe/p_thread.h"
 #include "util/u_memory.h"
@@ -80,11 +80,27 @@ struct fenced_buffer_list
  */
 struct fenced_buffer
 {
+   /*
+    * Immutable members.
+    */
+
    struct pb_buffer base;
-   
    struct pb_buffer *buffer;
+   struct fenced_buffer_list *list;
+
+   /**
+    * Protected by fenced_buffer_list::mutex
+    */
+   struct list_head head;
 
-   /* FIXME: protect access with mutex */
+   /**
+    * Following members are mutable and protected by this mutex.
+    * 
+    * You may lock this mutex alone, or lock it with fenced_buffer_list::mutex
+    * held, but in order to prevent deadlocks you must never lock 
+    * fenced_buffer_list::mutex with this mutex held.
+    */
+   pipe_mutex mutex;
 
    /**
     * A bitmask of PIPE_BUFFER_USAGE_CPU/GPU_READ/WRITE describing the current
@@ -96,9 +112,6 @@ struct fenced_buffer
    struct pb_validate *vl;
    unsigned validation_flags;
    struct pipe_fence_handle *fence;
-
-   struct list_head head;
-   struct fenced_buffer_list *list;
 };
 
 
@@ -110,15 +123,24 @@ fenced_buffer(struct pb_buffer *buf)
 }
 
 
+/**
+ * Add the buffer to the fenced list.
+ * 
+ * fenced_buffer_list::mutex and fenced_buffer::mutex must be held, in this
+ * order, before calling this function.
+ * 
+ * Reference count should be incremented before calling this function.
+ */
 static INLINE void
-_fenced_buffer_add(struct fenced_buffer *fenced_buf)
+fenced_buffer_add_locked(struct fenced_buffer_list *fenced_list, 
+                         struct fenced_buffer *fenced_buf)
 {
-   struct fenced_buffer_list *fenced_list = fenced_buf->list;
-
    assert(pipe_is_referenced(&fenced_buf->base.base.reference));
    assert(fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE);
    assert(fenced_buf->fence);
 
+   /* TODO: Move the reference count increment here */
+   
 #ifdef DEBUG
    LIST_DEL(&fenced_buf->head);
    assert(fenced_list->numUnfenced);
@@ -130,32 +152,16 @@ _fenced_buffer_add(struct fenced_buffer *fenced_buf)
 
 
 /**
- * Actually destroy the buffer.
+ * Remove the buffer from the fenced list.
+ * 
+ * fenced_buffer_list::mutex and fenced_buffer::mutex must be held, in this 
+ * order before calling this function.
+ * 
+ * Reference count should be decremented after calling this function.
  */
 static INLINE void
-_fenced_buffer_destroy(struct fenced_buffer *fenced_buf)
-{
-   struct fenced_buffer_list *fenced_list = fenced_buf->list;
-   
-   assert(!pipe_is_referenced(&fenced_buf->base.base.reference));
-   assert(!fenced_buf->fence);
-#ifdef DEBUG
-   assert(fenced_buf->head.prev);
-   assert(fenced_buf->head.next);
-   LIST_DEL(&fenced_buf->head);
-   assert(fenced_list->numUnfenced);
-   --fenced_list->numUnfenced;
-#else
-   (void)fenced_list;
-#endif
-   pb_reference(&fenced_buf->buffer, NULL);
-   FREE(fenced_buf);
-}
-
-
-static INLINE void
-_fenced_buffer_remove(struct fenced_buffer_list *fenced_list,
-                      struct fenced_buffer *fenced_buf)
+fenced_buffer_remove_locked(struct fenced_buffer_list *fenced_list,
+                            struct fenced_buffer *fenced_buf)
 {
    struct pb_fence_ops *ops = fenced_list->ops;
 
@@ -177,37 +183,56 @@ _fenced_buffer_remove(struct fenced_buffer_list *fenced_list,
    ++fenced_list->numUnfenced;
 #endif
    
-   /**
-    * FIXME!!!
-    */
-
-   if(!pipe_is_referenced(&fenced_buf->base.base.reference))
-      _fenced_buffer_destroy(fenced_buf);
+   /* TODO: Move the reference count decrement and destruction here */
 }
 
 
+/**
+ * Wait for the fence to expire, and remove it from the fenced list.
+ * 
+ * fenced_buffer::mutex must be held. fenced_buffer_list::mutex must not be 
+ * held -- it will be acquired internally.
+ */
 static INLINE enum pipe_error
-_fenced_buffer_finish(struct fenced_buffer *fenced_buf)
+fenced_buffer_finish_locked(struct fenced_buffer_list *fenced_list,
+                              struct fenced_buffer *fenced_buf)
 {
-   struct fenced_buffer_list *fenced_list = fenced_buf->list;
    struct pb_fence_ops *ops = fenced_list->ops;
+   enum pipe_error ret = PIPE_ERROR;
 
 #if 0
    debug_warning("waiting for GPU");
 #endif
 
+   assert(pipe_is_referenced(&fenced_buf->base.base.reference));
    assert(fenced_buf->fence);
+
+   /*
+    * Acquire the global lock. Must release buffer mutex first to preserve
+    * lock order.
+    */
+   pipe_mutex_unlock(fenced_buf->mutex);
+   pipe_mutex_lock(fenced_list->mutex);
+   pipe_mutex_lock(fenced_buf->mutex);
+
    if(fenced_buf->fence) {
-      if(ops->fence_finish(ops, fenced_buf->fence, 0) != 0) {
-        return PIPE_ERROR;
+      if(ops->fence_finish(ops, fenced_buf->fence, 0) == 0) {
+         /* Remove from the fenced list */
+         /* TODO: remove consequents */
+         fenced_buffer_remove_locked(fenced_list, fenced_buf);
+
+         p_atomic_dec(&fenced_buf->base.base.reference.count);
+         assert(pipe_is_referenced(&fenced_buf->base.base.reference));
+
+         fenced_buf->flags &= ~PIPE_BUFFER_USAGE_GPU_READ_WRITE;
+
+         ret = PIPE_OK;
       }
-      /* Remove from the fenced list */
-      /* TODO: remove consequents */
-      _fenced_buffer_remove(fenced_list, fenced_buf);
    }
 
-   fenced_buf->flags &= ~PIPE_BUFFER_USAGE_GPU_READ_WRITE;
-   return PIPE_OK;
+   pipe_mutex_unlock(fenced_list->mutex);
+
+   return ret;
 }
 
 
@@ -215,12 +240,13 @@ _fenced_buffer_finish(struct fenced_buffer *fenced_buf)
  * Free as many fenced buffers from the list head as possible. 
  */
 static void
-_fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list, 
-                               int wait)
+fenced_buffer_list_check_free_locked(struct fenced_buffer_list *fenced_list, 
+                                     int wait)
 {
    struct pb_fence_ops *ops = fenced_list->ops;
    struct list_head *curr, *next;
    struct fenced_buffer *fenced_buf;
+   struct pb_buffer *pb_buf;
    struct pipe_fence_handle *prev_fence = NULL;
 
    curr = fenced_list->delayed.next;
@@ -228,21 +254,29 @@ _fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list,
    while(curr != &fenced_list->delayed) {
       fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head);
 
+      pipe_mutex_lock(fenced_buf->mutex);
+
       if(fenced_buf->fence != prev_fence) {
         int signaled;
         if (wait)
            signaled = ops->fence_finish(ops, fenced_buf->fence, 0);
         else
            signaled = ops->fence_signalled(ops, fenced_buf->fence, 0);
-        if (signaled != 0)
+        if (signaled != 0) {
+            pipe_mutex_unlock(fenced_buf->mutex);
            break;
+         }
         prev_fence = fenced_buf->fence;
       }
       else {
         assert(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0);
       }
 
-      _fenced_buffer_remove(fenced_list, fenced_buf);
+      fenced_buffer_remove_locked(fenced_list, fenced_buf);
+      pipe_mutex_unlock(fenced_buf->mutex);
+
+      pb_buf = &fenced_buf->base;
+      pb_reference(&pb_buf, NULL);
 
       curr = next; 
       next = curr->next;
@@ -256,30 +290,25 @@ fenced_buffer_destroy(struct pb_buffer *buf)
    struct fenced_buffer *fenced_buf = fenced_buffer(buf);   
    struct fenced_buffer_list *fenced_list = fenced_buf->list;
 
-   pipe_mutex_lock(fenced_list->mutex);
    assert(!pipe_is_referenced(&fenced_buf->base.base.reference));
-   if (fenced_buf->fence) {
-      struct pb_fence_ops *ops = fenced_list->ops;
-      if(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0) {
-        struct list_head *curr, *prev;
-        curr = &fenced_buf->head;
-        prev = curr->prev;
-        do {
-           fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head);
-           assert(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0);
-           _fenced_buffer_remove(fenced_list, fenced_buf);
-           curr = prev;
-           prev = curr->prev;
-        } while (curr != &fenced_list->delayed);
-      }          
-      else {
-        /* delay destruction */
-      }
-   }
-   else {
-      _fenced_buffer_destroy(fenced_buf);
-   }
+   assert(!fenced_buf->fence);
+
+#ifdef DEBUG
+   pipe_mutex_lock(fenced_list->mutex);
+   assert(fenced_buf->head.prev);
+   assert(fenced_buf->head.next);
+   LIST_DEL(&fenced_buf->head);
+   assert(fenced_list->numUnfenced);
+   --fenced_list->numUnfenced;
    pipe_mutex_unlock(fenced_list->mutex);
+#else
+   (void)fenced_list;
+#endif
+
+   pb_reference(&fenced_buf->buffer, NULL);
+
+   pipe_mutex_destroy(fenced_buf->mutex);
+   FREE(fenced_buf);
 }
 
 
@@ -290,24 +319,23 @@ fenced_buffer_map(struct pb_buffer *buf,
    struct fenced_buffer *fenced_buf = fenced_buffer(buf);
    struct fenced_buffer_list *fenced_list = fenced_buf->list;
    struct pb_fence_ops *ops = fenced_list->ops;
-   void *map;
+   void *map = NULL;
+
+   pipe_mutex_lock(fenced_buf->mutex);
 
    assert(!(flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE));
    
    /* Serialize writes */
    if((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_WRITE) ||
       ((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ) && (flags & PIPE_BUFFER_USAGE_CPU_WRITE))) {
-      if(flags & PIPE_BUFFER_USAGE_DONTBLOCK) {
+      if((flags & PIPE_BUFFER_USAGE_DONTBLOCK) &&
+          ops->fence_signalled(ops, fenced_buf->fence, 0) == 0) {
          /* Don't wait for the GPU to finish writing */
-         if(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0)
-            _fenced_buffer_remove(fenced_list, fenced_buf);
-         else
-            return NULL;
-      }
-      else {
-         /* Wait for the GPU to finish writing */
-         _fenced_buffer_finish(fenced_buf);
+         goto done;
       }
+
+      /* Wait for the GPU to finish writing */
+      fenced_buffer_finish_locked(fenced_list, fenced_buf);
    }
 
 #if 0
@@ -324,6 +352,9 @@ fenced_buffer_map(struct pb_buffer *buf,
       fenced_buf->flags |= flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE;
    }
 
+done:
+   pipe_mutex_unlock(fenced_buf->mutex);
+   
    return map;
 }
 
@@ -332,6 +363,9 @@ static void
 fenced_buffer_unmap(struct pb_buffer *buf)
 {
    struct fenced_buffer *fenced_buf = fenced_buffer(buf);
+   
+   pipe_mutex_lock(fenced_buf->mutex);
+   
    assert(fenced_buf->mapcount);
    if(fenced_buf->mapcount) {
       pb_unmap(fenced_buf->buffer);
@@ -339,6 +373,8 @@ fenced_buffer_unmap(struct pb_buffer *buf)
       if(!fenced_buf->mapcount)
         fenced_buf->flags &= ~PIPE_BUFFER_USAGE_CPU_READ_WRITE;
    }
+   
+   pipe_mutex_unlock(fenced_buf->mutex);
 }
 
 
@@ -350,11 +386,14 @@ fenced_buffer_validate(struct pb_buffer *buf,
    struct fenced_buffer *fenced_buf = fenced_buffer(buf);
    enum pipe_error ret;
    
+   pipe_mutex_lock(fenced_buf->mutex);
+
    if(!vl) {
       /* invalidate */
       fenced_buf->vl = NULL;
       fenced_buf->validation_flags = 0;
-      return PIPE_OK;
+      ret = PIPE_OK;
+      goto done;
    }
    
    assert(flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE);
@@ -362,14 +401,17 @@ fenced_buffer_validate(struct pb_buffer *buf,
    flags &= PIPE_BUFFER_USAGE_GPU_READ_WRITE;
 
    /* Buffer cannot be validated in two different lists */ 
-   if(fenced_buf->vl && fenced_buf->vl != vl)
-      return PIPE_ERROR_RETRY;
+   if(fenced_buf->vl && fenced_buf->vl != vl) {
+      ret = PIPE_ERROR_RETRY;
+      goto done;
+   }
    
 #if 0
    /* Do not validate if buffer is still mapped */
    if(fenced_buf->flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE) {
       /* TODO: wait for the thread that mapped the buffer to unmap it */
-      return PIPE_ERROR_RETRY;
+      ret = PIPE_ERROR_RETRY;
+      goto done;
    }
    /* Final sanity checking */
    assert(!(fenced_buf->flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE));
@@ -379,17 +421,21 @@ fenced_buffer_validate(struct pb_buffer *buf,
    if(fenced_buf->vl == vl &&
       (fenced_buf->validation_flags & flags) == flags) {
       /* Nothing to do -- buffer already validated */
-      return PIPE_OK;
+      ret = PIPE_OK;
+      goto done;
    }
    
    ret = pb_validate(fenced_buf->buffer, vl, flags);
    if (ret != PIPE_OK)
-      return ret;
+      goto done;
    
    fenced_buf->vl = vl;
    fenced_buf->validation_flags |= flags;
    
-   return PIPE_OK;
+done:
+   pipe_mutex_unlock(fenced_buf->mutex);
+
+   return ret;
 }
 
 
@@ -404,29 +450,36 @@ fenced_buffer_fence(struct pb_buffer *buf,
    fenced_buf = fenced_buffer(buf);
    fenced_list = fenced_buf->list;
    ops = fenced_list->ops;
-   
-   if(fence == fenced_buf->fence) {
-      /* Nothing to do */
-      return;
-   }
 
-   assert(fenced_buf->vl);
-   assert(fenced_buf->validation_flags);
-   
    pipe_mutex_lock(fenced_list->mutex);
-   if (fenced_buf->fence)
-      _fenced_buffer_remove(fenced_list, fenced_buf);
-   if (fence) {
-      ops->fence_reference(ops, &fenced_buf->fence, fence);
-      fenced_buf->flags |= fenced_buf->validation_flags;
-      _fenced_buffer_add(fenced_buf);
-   }
-   pipe_mutex_unlock(fenced_list->mutex);
+   pipe_mutex_lock(fenced_buf->mutex);
+
+   assert(pipe_is_referenced(&fenced_buf->base.base.reference));
+
+   if(fence != fenced_buf->fence) {
+      assert(fenced_buf->vl);
+      assert(fenced_buf->validation_flags);
+      
+      if (fenced_buf->fence) {
+         fenced_buffer_remove_locked(fenced_list, fenced_buf);
+         p_atomic_dec(&fenced_buf->base.base.reference.count);
+         assert(pipe_is_referenced(&fenced_buf->base.base.reference));
+      }
+      if (fence) {
+         ops->fence_reference(ops, &fenced_buf->fence, fence);
+         fenced_buf->flags |= fenced_buf->validation_flags;
+         p_atomic_inc(&fenced_buf->base.base.reference.count);
+         fenced_buffer_add_locked(fenced_list, fenced_buf);
+      }
+
+      pb_fence(fenced_buf->buffer, fence);
    
-   pb_fence(fenced_buf->buffer, fence);
+      fenced_buf->vl = NULL;
+      fenced_buf->validation_flags = 0;
+   }
 
-   fenced_buf->vl = NULL;
-   fenced_buf->validation_flags = 0;
+   pipe_mutex_unlock(fenced_buf->mutex);
+   pipe_mutex_unlock(fenced_list->mutex);
 }
 
 
@@ -436,6 +489,7 @@ fenced_buffer_get_base_buffer(struct pb_buffer *buf,
                               pb_size *offset)
 {
    struct fenced_buffer *fenced_buf = fenced_buffer(buf);
+   /* NOTE: accesses immutable members only -- mutex not necessary */
    pb_get_base_buffer(fenced_buf->buffer, base_buf, offset);
 }
 
@@ -475,6 +529,8 @@ fenced_buffer_create(struct fenced_buffer_list *fenced_list,
    buf->buffer = buffer;
    buf->list = fenced_list;
    
+   pipe_mutex_init(buf->mutex);
+
 #ifdef DEBUG
    pipe_mutex_lock(fenced_list->mutex);
    LIST_ADDTAIL(&buf->head, &fenced_list->unfenced);
@@ -516,7 +572,7 @@ fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list,
                               int wait)
 {
    pipe_mutex_lock(fenced_list->mutex);
-   _fenced_buffer_list_check_free(fenced_list, wait);
+   fenced_buffer_list_check_free_locked(fenced_list, wait);
    pipe_mutex_unlock(fenced_list->mutex);
 }
 
@@ -538,11 +594,13 @@ fenced_buffer_list_dump(struct fenced_buffer_list *fenced_list)
    next = curr->next;
    while(curr != &fenced_list->unfenced) {
       fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head);
+      pipe_mutex_lock(fenced_buf->mutex);
       assert(!fenced_buf->fence);
       debug_printf("%10p %7u %7u\n",
-                   fenced_buf,
+                   (void *) fenced_buf,
                    fenced_buf->base.base.size,
                    p_atomic_read(&fenced_buf->base.base.reference.count));
+      pipe_mutex_unlock(fenced_buf->mutex);
       curr = next; 
       next = curr->next;
    }
@@ -552,13 +610,15 @@ fenced_buffer_list_dump(struct fenced_buffer_list *fenced_list)
    while(curr != &fenced_list->delayed) {
       int signaled;
       fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head);
+      pipe_mutex_lock(fenced_buf->mutex);
       signaled = ops->fence_signalled(ops, fenced_buf->fence, 0);
       debug_printf("%10p %7u %7u %10p %s\n",
-                   fenced_buf,
+                   (void *) fenced_buf,
                    fenced_buf->base.base.size,
                    p_atomic_read(&fenced_buf->base.base.reference.count),
-                   fenced_buf->fence,
+                   (void *) fenced_buf->fence,
                    signaled == 0 ? "y" : "n");
+      pipe_mutex_unlock(fenced_buf->mutex);
       curr = next; 
       next = curr->next;
    }
@@ -579,8 +639,8 @@ fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list)
 #if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS)
       sched_yield();
 #endif
-      _fenced_buffer_list_check_free(fenced_list, 1);
       pipe_mutex_lock(fenced_list->mutex);
+      fenced_buffer_list_check_free_locked(fenced_list, 1);
    }
 
 #ifdef DEBUG
@@ -588,6 +648,7 @@ fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list)
 #endif
       
    pipe_mutex_unlock(fenced_list->mutex);
+   pipe_mutex_destroy(fenced_list->mutex);
    
    fenced_list->ops->destroy(fenced_list->ops);
    
index 39ab8e722c15cf194acbea95a975da2c5fa2e451..8c8d7130781d81bcf34b2ab15c96e7a5fc62d46e 100644 (file)
@@ -51,7 +51,7 @@
 
 
 #include "pipe/p_compiler.h"
-#include "pipe/p_error.h"
+#include "pipe/p_defines.h"
 
 
 #ifdef __cplusplus
index 57d1ede45a44d90a98692286abb3ccdcefa7d63e..7b34c8e35782aac1a69e8da68952973c827e1f5f 100644 (file)
@@ -294,7 +294,7 @@ pb_cache_manager_create_buffer(struct pb_manager *_mgr,
       LIST_DEL(&buf->head);
       pipe_mutex_unlock(mgr->mutex);
       /* Increase refcount */
-      pb_reference((struct pb_buffer**)&buf, &buf->base);
+      pipe_reference(NULL, &buf->base.base.reference);
       return &buf->base;
    }
    
index e7352e90db95c0866ad7be4d01fb79d139462dfd..d21910d0bf06c6d900c97ec76bb2303a6beafa17 100644 (file)
@@ -37,7 +37,6 @@
  */
 
 #include "pipe/p_compiler.h"
-#include "pipe/p_error.h"
 #include "util/u_debug.h"
 #include "pipe/p_thread.h"
 #include "pipe/p_defines.h"
index 150fd5061812e804387c2aba7589750e5d958414..ce40c0cf0e693fad1106b4594380aade082fa8ab 100644 (file)
@@ -34,7 +34,7 @@
 
 
 #include "pipe/p_compiler.h"
-#include "pipe/p_error.h"
+#include "pipe/p_defines.h"
 #include "util/u_memory.h"
 #include "util/u_debug.h"
 
index dfb84df1cef42add56a02eaef50e03635c6bd4d3..3c93f30f2012282a7c8ed0b8023aafbd83097502 100644 (file)
@@ -37,7 +37,7 @@
 
 
 #include "pipe/p_compiler.h"
-#include "pipe/p_error.h"
+#include "pipe/p_defines.h"
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/src/gallium/auxiliary/rbug/Makefile b/src/gallium/auxiliary/rbug/Makefile
deleted file mode 100644 (file)
index cd12e84..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-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
index 33d76371de4b24db74492b8ec8905f0d7237f230..d984067893c75157f4ebf71f8e51bf593cdd8413 100644 (file)
@@ -16,6 +16,10 @@ for information about applications look in:
 
 progs/rbug/README
 
+for a GUI see:
+
+  http://cgit.freedesktop.org/mesa/rbug-gui
+
 
 --
 Jakob Bornecrantz <jakob@vmware.com>
diff --git a/src/gallium/auxiliary/rbug/SConscript b/src/gallium/auxiliary/rbug/SConscript
deleted file mode 100644 (file)
index 4a9afb4..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-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)
index 52acb700af9575cfc361695e53f6ba060ac0825c..ae4e27f9f6b99dd6b3122aa4d1e781f610ae2e21 100644 (file)
@@ -87,6 +87,7 @@ rbug_get_message(struct rbug_connection *c, uint32_t *serial)
    if (!data) {
       return NULL;
    }
+   data->opcode = 0;
 
    do {
       uint8_t *ptr = ((uint8_t*)data) + read;
index da61c2365b06a6b10b7dba124535418b45d34efb..03126d6b12376b190bfa4ef9ca43ae99b51cbaec 100644 (file)
@@ -46,7 +46,7 @@ typedef enum
        RBUG_BLOCK_BEFORE = 1,
        RBUG_BLOCK_AFTER = 2,
        RBUG_BLOCK_RULE = 4,
-       RBUG_BLOCK_MASK = 7,
+       RBUG_BLOCK_MASK = 7
 } rbug_block_t;
 
 struct rbug_proto_context_list
index d273be0166d005ad5a1b40541a15c384bf2d68cc..4f3eb75dc4dd3ab81bb94af7252621e1718a60c6 100644 (file)
@@ -65,7 +65,7 @@ enum rbug_opcode
        RBUG_OP_SHADER_DISABLE = 770,
        RBUG_OP_SHADER_REPLACE = 771,
        RBUG_OP_SHADER_LIST_REPLY = -768,
-       RBUG_OP_SHADER_INFO_REPLY = -769,
+       RBUG_OP_SHADER_INFO_REPLY = -769
 };
 
 /**
diff --git a/src/gallium/auxiliary/rtasm/Makefile b/src/gallium/auxiliary/rtasm/Makefile
deleted file mode 100644 (file)
index ab8ea46..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = rtasm
-
-C_SOURCES = \
-       rtasm_cpu.c \
-       rtasm_execmem.c \
-       rtasm_x86sse.c \
-       rtasm_ppc.c \
-       rtasm_ppc_spe.c
-
-include ../../Makefile.template
diff --git a/src/gallium/auxiliary/rtasm/SConscript b/src/gallium/auxiliary/rtasm/SConscript
deleted file mode 100644 (file)
index eb48368..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-Import('*')
-
-rtasm = env.ConvenienceLibrary(
-       target = 'rtasm',
-       source = [
-               'rtasm_cpu.c',
-               'rtasm_execmem.c',
-               'rtasm_x86sse.c',
-               'rtasm_ppc.c',
-               'rtasm_ppc_spe.c',
-       ])
-
-auxiliaries.insert(0, rtasm)
index 01811d50114e2c8868285d67b820aaeb29b02c9e..ffed768f979112b009de167e52eac4619084438d 100644 (file)
 #define MAP_ANONYMOUS MAP_ANON
 #endif
 
+#if defined(PIPE_OS_WINDOWS)
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
+#endif
+#include <windows.h>
+#endif
 
 #if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS)
 
@@ -118,7 +124,29 @@ rtasm_exec_free(void *addr)
 }
 
 
-#else /* PIPE_OS_LINUX || PIPE_OS_BSD || PIPE_OS_SOLARIS */
+#elif defined(PIPE_OS_WINDOWS)
+
+
+/*
+ * Avoid Data Execution Prevention.
+ */
+
+void *
+rtasm_exec_malloc(size_t size)
+{
+   return VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
+}
+
+
+void
+rtasm_exec_free(void *addr)
+{
+   VirtualFree(addr, 0, MEM_RELEASE);
+}
+
+
+#else
+
 
 /*
  * Just use regular memory.
@@ -138,4 +166,4 @@ rtasm_exec_free(void *addr)
 }
 
 
-#endif /* PIPE_OS_LINUX || PIPE_OS_BSD || PIPE_OS_SOLARIS */
+#endif
diff --git a/src/gallium/auxiliary/sct/Makefile b/src/gallium/auxiliary/sct/Makefile
deleted file mode 100644 (file)
index a7d111b..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = sct
-
-C_SOURCES = \
-       sct.c
-
-include ../../Makefile.template
diff --git a/src/gallium/auxiliary/sct/SConscript b/src/gallium/auxiliary/sct/SConscript
deleted file mode 100644 (file)
index 76927d9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-Import('*')
-
-sct = env.ConvenienceLibrary(
-       target = 'sct',
-       source = [
-               'sct.c'
-       ])
-
-auxiliaries.insert(0, sct)
diff --git a/src/gallium/auxiliary/sct/sct.c b/src/gallium/auxiliary/sct/sct.c
deleted file mode 100644 (file)
index 722d2b7..0000000
+++ /dev/null
@@ -1,453 +0,0 @@
-/**************************************************************************
- * 
- * 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 "util/u_memory.h"
-#include "pipe/p_state.h"
-#include "sct.h"
-
-
-struct texture_list
-{
-   struct pipe_texture *texture;
-   struct texture_list *next;
-};
-
-
-
-#define MAX_SURFACES  ((PIPE_MAX_COLOR_BUFS) + 1)
-
-struct sct_context
-{
-   const struct pipe_context *context;
-
-   /** surfaces the context is drawing into */
-   struct pipe_surface *surfaces[MAX_SURFACES];
-
-   /** currently bound textures */
-   struct pipe_texture *textures[PIPE_MAX_SAMPLERS];
-
-   /** previously bound textures, used but not flushed */
-   struct texture_list *textures_used;
-
-   boolean needs_flush;
-
-   struct sct_context *next;
-};
-
-
-
-struct sct_surface
-{
-   const struct pipe_surface *surface;
-
-   /** list of contexts drawing to this surface */
-   struct sct_context_list *contexts;
-
-   struct sct_surface *next;
-};
-
-
-
-/**
- * Find the surface_info for the given pipe_surface
- */
-static struct sct_surface *
-find_surface_info(struct surface_context_tracker *sct,
-                  const struct pipe_surface *surface)
-{
-   struct sct_surface *si;
-   for (si = sct->surfaces; si; si = si->next)
-      if (si->surface == surface)
-         return si;
-   return NULL;
-}
-
-
-/**
- * As above, but create new surface_info if surface is new.
- */
-static struct sct_surface *
-find_create_surface_info(struct surface_context_tracker *sct,
-                         const struct pipe_surface *surface)
-{
-   struct sct_surface *si = find_surface_info(sct, surface);
-   if (si)
-      return si;
-
-   /* alloc new */
-   si = CALLOC_STRUCT(sct_surface);
-   if (si) {
-      si->surface = surface;
-
-      /* insert at head */
-      si->next = sct->surfaces;
-      sct->surfaces = si;
-   }
-
-   return si;
-}
-
-
-/**
- * Find a context_info for the given context.
- */
-static struct sct_context *
-find_context_info(struct surface_context_tracker *sct,
-                  const struct pipe_context *context)
-{
-   struct sct_context *ci;
-   for (ci = sct->contexts; ci; ci = ci->next)
-      if (ci->context == context)
-         return ci;
-   return NULL;
-}
-
-
-/**
- * As above, but create new context_info if context is new.
- */
-static struct sct_context *
-find_create_context_info(struct surface_context_tracker *sct,
-                         const struct pipe_context *context)
-{
-   struct sct_context *ci = find_context_info(sct, context);
-   if (ci)
-      return ci;
-
-   /* alloc new */
-   ci = CALLOC_STRUCT(sct_context);
-   if (ci) {
-      ci->context = context;
-
-      /* insert at head */
-      ci->next = sct->contexts;
-      sct->contexts = ci;
-   }
-
-   return ci;
-}
-
-
-/**
- * Is the context already bound to the surface?
- */
-static boolean
-find_surface_context(const struct sct_surface *si,
-                     const struct pipe_context *context)
-{
-   const struct sct_context_list *cl;
-   for (cl = si->contexts; cl; cl = cl->next) {
-      if (cl->context == context) {
-         return TRUE;
-      }
-   }
-   return FALSE;
-}
-
-
-/**
- * Add a context to the list of contexts associated with a surface.
- */
-static void
-add_context_to_surface(struct sct_surface *si,
-                       const struct pipe_context *context)
-{
-   struct sct_context_list *cl = CALLOC_STRUCT(sct_context_list);
-   if (cl) {
-      cl->context = context;
-      /* insert at head of list of contexts */
-      cl->next = si->contexts;
-      si->contexts = cl;
-   }
-}
-
-
-/**
- * Remove a context from the list of contexts associated with a surface.
- */
-static void
-remove_context_from_surface(struct sct_surface *si,
-                            const struct pipe_context *context)
-{
-   struct sct_context_list *prev = NULL, *curr, *next;
-
-   for (curr = si->contexts; curr; curr = next) {
-      if (curr->context == context) {
-         /* remove */
-         if (prev)
-            prev->next = curr->next;
-         else
-            si->contexts = curr->next;
-         next = curr->next;
-         FREE(curr);
-      }
-      else {
-         prev = curr;
-         next = curr->next;
-      }
-   }
-}
-
-
-/**
- * Unbind context from surface.
- */
-static void
-unbind_context_surface(struct surface_context_tracker *sct,
-                       struct pipe_context *context,
-                       struct pipe_surface *surface)
-{
-   struct sct_surface *si = find_surface_info(sct, surface);
-   if (si) {
-      remove_context_from_surface(si, context);
-   }
-}
-
-
-/**
- * Bind context to a set of surfaces (color + Z).
- * Like MakeCurrent().
- */
-void
-sct_bind_surfaces(struct surface_context_tracker *sct,
-                  struct pipe_context *context,
-                  uint num_surf,
-                  struct pipe_surface **surfaces)
-{
-   struct sct_context *ci = find_create_context_info(sct, context);
-   uint i;
-
-   if (!ci) {
-      return; /* out of memory */
-   }
-
-   /* unbind currently bound surfaces */
-   for (i = 0; i < MAX_SURFACES; i++) {
-      if (ci->surfaces[i]) {
-         unbind_context_surface(sct, context, ci->surfaces[i]);
-      }
-   }
-
-   /* bind new surfaces */
-   for (i = 0; i < num_surf; i++) {
-      struct sct_surface *si = find_create_surface_info(sct, surfaces[i]);
-      if (!find_surface_context(si, context)) {
-         add_context_to_surface(si, context);
-      }
-   }
-}
-
-
-/**
- * Return list of contexts bound to a surface.
- */
-const struct sct_context_list *
-sct_get_surface_contexts(struct surface_context_tracker *sct,
-                         const struct pipe_surface *surface)
-{
-   const struct sct_surface *si = find_surface_info(sct, surface);
-   return si->contexts;
-}
-
-
-
-static boolean
-find_texture(const struct sct_context *ci,
-             const struct pipe_texture *texture)
-{
-   const struct texture_list *tl;
-
-   for (tl = ci->textures_used; tl; tl = tl->next) {
-      if (tl->texture == texture) {
-         return TRUE;
-      }
-   }
-   return FALSE;
-}
-
-
-/**
- * Add the given texture to the context's list of used textures.
- */
-static void
-add_texture_used(struct sct_context *ci,
-                 struct pipe_texture *texture)
-{
-   if (!find_texture(ci, texture)) {
-      /* add to list */
-      struct texture_list *tl = CALLOC_STRUCT(texture_list);
-      if (tl) {
-         pipe_texture_reference(&tl->texture, texture);
-         /* insert at head */
-         tl->next = ci->textures_used;
-         ci->textures_used = tl;
-      }
-   }
-}
-
-
-/**
- * Bind a texture to a rendering context.
- */
-void
-sct_bind_texture(struct surface_context_tracker *sct,
-                 struct pipe_context *context,
-                 uint unit,
-                 struct pipe_texture *tex)
-{
-   struct sct_context *ci = find_context_info(sct, context);
-
-   if (ci->textures[unit] != tex) {
-      /* put texture on the 'used' list */
-      add_texture_used(ci, tex);
-      /* bind new */
-      pipe_texture_reference(&ci->textures[unit], tex);
-   }
-}
-
-
-/**
- * Check if the given texture has been used by the rendering context
- * since the last call to sct_flush_textures().
- */
-boolean
-sct_is_texture_used(struct surface_context_tracker *sct,
-                    const struct pipe_context *context,
-                    const struct pipe_texture *texture)
-{
-   const struct sct_context *ci = find_context_info(sct, context);
-   return find_texture(ci, texture);
-}
-
-
-/**
- * To be called when the image contents of a texture are changed, such
- * as for gl[Copy]TexSubImage().
- * XXX this may not be needed
- */
-void
-sct_update_texture(struct pipe_texture *tex)
-{
-
-}
-
-
-/**
- * When a scene is flushed/rendered we can release the list of
- * used textures.
- */
-void
-sct_flush_textures(struct surface_context_tracker *sct,
-                   struct pipe_context *context)
-{
-   struct sct_context *ci = find_context_info(sct, context);
-   struct texture_list *tl, *next;
-   uint i;
-
-   for (tl = ci->textures_used; tl; tl = next) {
-      next = tl->next;
-      pipe_texture_reference(&tl->texture, NULL);
-      FREE(tl);
-   }
-   ci->textures_used = NULL;
-
-   /* put the currently bound textures on the 'used' list */
-   for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
-      add_texture_used(ci, ci->textures[i]);
-   }
-}
-
-
-
-void
-sct_destroy_context(struct surface_context_tracker *sct,
-                    struct pipe_context *context)
-{
-   /* XXX should we require an unbinding first? */
-   {
-      struct sct_surface *si;
-      for (si = sct->surfaces; si; si = si->next) {
-         remove_context_from_surface(si, context);
-      }
-   }
-
-   /* remove context from context_info list */
-   {
-      struct sct_context *ci, *next, *prev = NULL;
-      for (ci = sct->contexts; ci; ci = next) {
-         next = ci->next;
-         if (ci->context == context) {
-            if (prev)
-               prev->next = ci->next;
-            else
-               sct->contexts = ci->next;
-            FREE(ci);
-         }
-         else {
-            prev = ci;
-         }
-      }
-   }
-
-}
-
-
-void
-sct_destroy_surface(struct surface_context_tracker *sct,
-                    struct pipe_surface *surface)
-{
-   if (1) {
-      /* debug/sanity: no context should be bound to surface */
-      struct sct_context *ci;
-      uint i;
-      for (ci = sct->contexts; ci; ci = ci->next) {
-         for (i = 0; i < MAX_SURFACES; i++) {
-            assert(ci->surfaces[i] != surface);
-         }
-      }
-   }
-
-   /* remove surface from sct_surface list */
-   {
-      struct sct_surface *si, *next, *prev = NULL;
-      for (si = sct->surfaces; si; si = next) {
-         next = si->next;
-         if (si->surface == surface) {
-            /* unlink */
-            if (prev)
-               prev->next = si->next;
-            else
-               sct->surfaces = si->next;
-            FREE(si);
-         }
-         else {
-            prev = si;
-         }
-      }
-   }
-}
diff --git a/src/gallium/auxiliary/sct/sct.h b/src/gallium/auxiliary/sct/sct.h
deleted file mode 100644 (file)
index cf7c4d3..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/**************************************************************************
- * 
- * 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.
- * 
- **************************************************************************/
-
-/**
- * Surface/Context Tracking
- *
- * For some drivers, we need to monitor the binding between contexts and
- * surfaces/textures.
- * This code may evolve quite a bit...
- */
-
-
-#ifndef SCT_H
-#define SCT_H
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-struct pipe_context;
-struct pipe_surface;
-
-struct sct_context;
-struct sct_surface;
-
-
-/**
- * Per-device info, basically
- */
-struct surface_context_tracker
-{
-   struct sct_context *contexts;
-   struct sct_surface *surfaces;
-};
-
-
-
-/**
- * Simple linked list of contexts
- */
-struct sct_context_list
-{
-   const struct pipe_context *context;
-   struct sct_context_list *next;
-};
-
-
-
-extern void
-sct_bind_surfaces(struct surface_context_tracker *sct,
-                  struct pipe_context *context,
-                  uint num_surf,
-                  struct pipe_surface **surfaces);
-
-
-extern void
-sct_bind_texture(struct surface_context_tracker *sct,
-                 struct pipe_context *context,
-                 uint unit,
-                 struct pipe_texture *texture);
-
-
-extern void
-sct_update_texture(struct pipe_texture *tex);
-
-
-extern boolean
-sct_is_texture_used(struct surface_context_tracker *sct,
-                    const struct pipe_context *context,
-                    const struct pipe_texture *texture);
-
-extern void
-sct_flush_textures(struct surface_context_tracker *sct,
-                   struct pipe_context *context);
-
-
-extern const struct sct_context_list *
-sct_get_surface_contexts(struct surface_context_tracker *sct,
-                         const struct pipe_surface *surf);
-
-
-extern void
-sct_destroy_context(struct surface_context_tracker *sct,
-                    struct pipe_context *context);
-
-
-extern void
-sct_destroy_surface(struct surface_context_tracker *sct,
-                    struct pipe_surface *surface);
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* SCT_H */
diff --git a/src/gallium/auxiliary/sct/usage.c b/src/gallium/auxiliary/sct/usage.c
deleted file mode 100644 (file)
index 6227f19..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/* surface / context tracking */
-
-
-/*
-
-context A:
-  render to texture T
-
-context B:
-  texture from T
-
------------------------
-
-flush surface:
-  which contexts are bound to the surface?
-
------------------------
-
-glTexSubImage():
-  which contexts need to be flushed?
-
- */
-
-
-/*
-
-in MakeCurrent():
-
-  call sct_bind_surfaces(context, list of surfaces) to update the
-  dependencies between context and surfaces
-
-
-in SurfaceFlush(), or whatever it is in D3D:
-
-  call sct_get_surface_contexts(surface) to get a list of contexts
-  which are currently bound to the surface.
-
-
-
-in BindTexture():
-
-  call sct_bind_texture(context, texture) to indicate that the texture
-  is used in the scene.
-
-
-in glTexSubImage() or RenderToTexture():
-
-  call sct_is_texture_used(context, texture) to determine if the texture
-  has been used in the scene, but the scene's not flushed.  If TRUE is
-  returned it means the scene has to be rendered/flushed before the contents
-  of the texture can be changed.
-
-
-in psb_scene_flush/terminate():
-
-  call sct_flush_textures(context) to tell the SCT that the textures which
-  were used in the scene can be released.
-
-
-
-*/
diff --git a/src/gallium/auxiliary/tgsi/Makefile b/src/gallium/auxiliary/tgsi/Makefile
deleted file mode 100644 (file)
index 5f0a580..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = tgsi
-
-C_SOURCES = \
-       tgsi_sanity.c \
-       tgsi_build.c \
-       tgsi_dump.c \
-       tgsi_exec.c \
-       tgsi_info.c \
-       tgsi_iterate.c \
-       tgsi_parse.c \
-       tgsi_ppc.c \
-       tgsi_scan.c \
-       tgsi_sse2.c \
-       tgsi_text.c \
-       tgsi_transform.c \
-       tgsi_ureg.c \
-       tgsi_util.c
-
-include ../../Makefile.template
diff --git a/src/gallium/auxiliary/tgsi/SConscript b/src/gallium/auxiliary/tgsi/SConscript
deleted file mode 100644 (file)
index b6bc292..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-Import('*')
-
-tgsi = env.ConvenienceLibrary(
-       target = 'tgsi',
-       source = [
-               'tgsi_build.c',
-               'tgsi_dump.c',
-               'tgsi_dump_c.c',
-               'tgsi_exec.c',
-               'tgsi_info.c',
-               'tgsi_iterate.c',
-               'tgsi_parse.c',
-               'tgsi_sanity.c',
-               'tgsi_scan.c',
-               'tgsi_ppc.c',
-               'tgsi_sse2.c',
-               'tgsi_text.c',
-               'tgsi_transform.c',
-               'tgsi_ureg.c',
-               'tgsi_util.c',
-       ])
-
-auxiliaries.insert(0, tgsi)
index eb492076b7d2dcaf935d5bdc30406fac0327d762..080fd4c7310dc53647aaf6d837ba40706ee97527 100644 (file)
@@ -1129,3 +1129,35 @@ TGSI Instruction Specification
 
   target            Label of target instruction.
 
+
+3  Other tokens
+===============
+
+
+3.1  Declaration Semantic
+-------------------------
+
+
+  Follows Declaration token if Semantic bit is set.
+
+  Since its purpose is to link a shader with other stages of the pipeline,
+  it is valid to follow only those Declaration tokens that declare a register
+  either in INPUT or OUTPUT file.
+
+  SemanticName field contains the semantic name of the register being declared.
+  There is no default value.
+
+  SemanticIndex is an optional subscript that can be used to distinguish
+  different register declarations with the same semantic name. The default value
+  is 0.
+
+  The meanings of the individual semantic names are explained in the following
+  sections.
+
+
+3.1.1  FACE
+
+  Valid only in a fragment shader INPUT declaration.
+
+  FACE.x is negative when the primitive is back facing. FACE.x is positive
+  when the primitive is front facing.
index e0cfc54420e61d5716899684503ff65073189f41..de9cbc863051f7d2495fe3f61cb9cd95865bfa33 100644 (file)
 #include "tgsi_build.h"
 #include "tgsi_parse.h"
 
-/*
- * version
- */
-
-struct tgsi_version
-tgsi_build_version( void )
-{
-   struct tgsi_version  version;
-
-   version.MajorVersion = 1;
-   version.MinorVersion = 1;
-   version.Padding = 0;
-
-   return version;
-}
 
 /*
  * header
@@ -122,7 +107,6 @@ tgsi_default_declaration( void )
    declaration.Centroid = 0;
    declaration.Invariant = 0;
    declaration.Padding = 0;
-   declaration.Extended = 0;
 
    return declaration;
 }
@@ -173,7 +157,7 @@ tgsi_default_full_declaration( void )
    struct tgsi_full_declaration  full_declaration;
 
    full_declaration.Declaration  = tgsi_default_declaration();
-   full_declaration.DeclarationRange = tgsi_default_declaration_range();
+   full_declaration.Range = tgsi_default_declaration_range();
    full_declaration.Semantic = tgsi_default_declaration_semantic();
 
    return full_declaration;
@@ -210,8 +194,8 @@ tgsi_build_full_declaration(
    size++;
 
    *dr = tgsi_build_declaration_range(
-      full_decl->DeclarationRange.First,
-      full_decl->DeclarationRange.Last,
+      full_decl->Range.First,
+      full_decl->Range.Last,
       declaration,
       header );
 
@@ -224,8 +208,8 @@ tgsi_build_full_declaration(
       size++;
 
       *ds = tgsi_build_declaration_semantic(
-         full_decl->Semantic.SemanticName,
-         full_decl->Semantic.SemanticIndex,
+         full_decl->Semantic.Name,
+         full_decl->Semantic.Index,
          declaration,
          header );
    }
@@ -270,8 +254,8 @@ tgsi_default_declaration_semantic( void )
 {
    struct tgsi_declaration_semantic ds;
 
-   ds.SemanticName = TGSI_SEMANTIC_POSITION;
-   ds.SemanticIndex = 0;
+   ds.Name = TGSI_SEMANTIC_POSITION;
+   ds.Index = 0;
    ds.Padding = 0;
 
    return ds;
@@ -290,8 +274,8 @@ tgsi_build_declaration_semantic(
    assert( semantic_index <= 0xFFFF );
 
    ds = tgsi_default_declaration_semantic();
-   ds.SemanticName = semantic_name;
-   ds.SemanticIndex = semantic_index;
+   ds.Name = semantic_name;
+   ds.Index = semantic_index;
 
    declaration_grow( declaration, header );
 
@@ -311,7 +295,6 @@ tgsi_default_immediate( void )
    immediate.NrTokens = 1;
    immediate.DataType = TGSI_IMM_FLOAT32;
    immediate.Padding = 0;
-   immediate.Extended = 0;
 
    return immediate;
 }
@@ -416,24 +399,26 @@ tgsi_default_instruction( void )
    struct tgsi_instruction instruction;
 
    instruction.Type = TGSI_TOKEN_TYPE_INSTRUCTION;
-   instruction.NrTokens = 1;
+   instruction.NrTokens = 0;
    instruction.Opcode = TGSI_OPCODE_MOV;
    instruction.Saturate = TGSI_SAT_NONE;
+   instruction.Predicate = 0;
    instruction.NumDstRegs = 1;
    instruction.NumSrcRegs = 1;
+   instruction.Label = 0;
+   instruction.Texture = 0;
    instruction.Padding  = 0;
-   instruction.Extended = 0;
 
    return instruction;
 }
 
 struct tgsi_instruction
-tgsi_build_instruction(
-   unsigned opcode,
-   unsigned saturate,
-   unsigned num_dst_regs,
-   unsigned num_src_regs,
-   struct tgsi_header *header )
+tgsi_build_instruction(unsigned opcode,
+                       unsigned saturate,
+                       unsigned predicate,
+                       unsigned num_dst_regs,
+                       unsigned num_src_regs,
+                       struct tgsi_header *header)
 {
    struct tgsi_instruction instruction;
 
@@ -445,6 +430,7 @@ tgsi_build_instruction(
    instruction = tgsi_default_instruction();
    instruction.Opcode = opcode;
    instruction.Saturate = saturate;
+   instruction.Predicate = predicate;
    instruction.NumDstRegs = num_dst_regs;
    instruction.NumSrcRegs = num_src_regs;
 
@@ -472,18 +458,16 @@ tgsi_default_full_instruction( void )
    unsigned i;
 
    full_instruction.Instruction = tgsi_default_instruction();
-   full_instruction.InstructionExtNv = tgsi_default_instruction_ext_nv();
-   full_instruction.InstructionExtLabel = tgsi_default_instruction_ext_label();
-   full_instruction.InstructionExtTexture = tgsi_default_instruction_ext_texture();
+   full_instruction.Predicate = tgsi_default_instruction_predicate();
+   full_instruction.Label = tgsi_default_instruction_label();
+   full_instruction.Texture = tgsi_default_instruction_texture();
    for( i = 0;  i < TGSI_FULL_MAX_DST_REGISTERS; i++ ) {
-      full_instruction.FullDstRegisters[i] = tgsi_default_full_dst_register();
+      full_instruction.Dst[i] = tgsi_default_full_dst_register();
    }
    for( i = 0;  i < TGSI_FULL_MAX_SRC_REGISTERS; i++ ) {
-      full_instruction.FullSrcRegisters[i] = tgsi_default_full_src_register();
+      full_instruction.Src[i] = tgsi_default_full_src_register();
    }
 
-   full_instruction.Flags = 0x0;
-
    return full_instruction;
 }
 
@@ -504,82 +488,70 @@ tgsi_build_full_instruction(
    instruction = (struct tgsi_instruction *) &tokens[size];
    size++;
 
-   *instruction = tgsi_build_instruction(
-      full_inst->Instruction.Opcode,
-      full_inst->Instruction.Saturate,
-      full_inst->Instruction.NumDstRegs,
-      full_inst->Instruction.NumSrcRegs,
-      header );
+   *instruction = tgsi_build_instruction(full_inst->Instruction.Opcode,
+                                         full_inst->Instruction.Saturate,
+                                         full_inst->Instruction.Predicate,
+                                         full_inst->Instruction.NumDstRegs,
+                                         full_inst->Instruction.NumSrcRegs,
+                                         header);
    prev_token = (struct tgsi_token  *) instruction;
 
-   if( tgsi_compare_instruction_ext_nv(
-         full_inst->InstructionExtNv,
-         tgsi_default_instruction_ext_nv() ) ) {
-      struct tgsi_instruction_ext_nv *instruction_ext_nv;
+   if (full_inst->Instruction.Predicate) {
+      struct tgsi_instruction_predicate *instruction_predicate;
 
-      if( maxsize <= size )
+      if (maxsize <= size) {
          return 0;
-      instruction_ext_nv =
-         (struct  tgsi_instruction_ext_nv *) &tokens[size];
+      }
+      instruction_predicate = (struct tgsi_instruction_predicate *)&tokens[size];
       size++;
 
-      *instruction_ext_nv  = tgsi_build_instruction_ext_nv(
-         full_inst->InstructionExtNv.Precision,
-         full_inst->InstructionExtNv.CondDstIndex,
-         full_inst->InstructionExtNv.CondFlowIndex,
-         full_inst->InstructionExtNv.CondMask,
-         full_inst->InstructionExtNv.CondSwizzleX,
-         full_inst->InstructionExtNv.CondSwizzleY,
-         full_inst->InstructionExtNv.CondSwizzleZ,
-         full_inst->InstructionExtNv.CondSwizzleW,
-         full_inst->InstructionExtNv.CondDstUpdate,
-         full_inst->InstructionExtNv.CondFlowEnable,
-         prev_token,
-         instruction,
-         header );
-      prev_token = (struct tgsi_token  *) instruction_ext_nv;
+      *instruction_predicate =
+         tgsi_build_instruction_predicate(full_inst->Predicate.Index,
+                                          full_inst->Predicate.Negate,
+                                          full_inst->Predicate.SwizzleX,
+                                          full_inst->Predicate.SwizzleY,
+                                          full_inst->Predicate.SwizzleZ,
+                                          full_inst->Predicate.SwizzleW,
+                                          instruction,
+                                          header);
    }
 
-   if( tgsi_compare_instruction_ext_label(
-         full_inst->InstructionExtLabel,
-         tgsi_default_instruction_ext_label() ) ) {
-      struct tgsi_instruction_ext_label *instruction_ext_label;
+   if (full_inst->Instruction.Label) {
+      struct tgsi_instruction_label *instruction_label;
 
       if( maxsize <= size )
          return 0;
-      instruction_ext_label =
-         (struct  tgsi_instruction_ext_label *) &tokens[size];
+      instruction_label =
+         (struct  tgsi_instruction_label *) &tokens[size];
       size++;
 
-      *instruction_ext_label = tgsi_build_instruction_ext_label(
-         full_inst->InstructionExtLabel.Label,
+      *instruction_label = tgsi_build_instruction_label(
+         full_inst->Label.Label,
          prev_token,
          instruction,
          header );
-      prev_token = (struct tgsi_token  *) instruction_ext_label;
+      prev_token = (struct tgsi_token  *) instruction_label;
    }
 
-   if( tgsi_compare_instruction_ext_texture(
-         full_inst->InstructionExtTexture,
-         tgsi_default_instruction_ext_texture() ) ) {
-      struct tgsi_instruction_ext_texture *instruction_ext_texture;
+   if (full_inst->Instruction.Texture) {
+      struct tgsi_instruction_texture *instruction_texture;
 
       if( maxsize <= size )
          return 0;
-      instruction_ext_texture =
-         (struct  tgsi_instruction_ext_texture *) &tokens[size];
+      instruction_texture =
+         (struct  tgsi_instruction_texture *) &tokens[size];
       size++;
 
-      *instruction_ext_texture = tgsi_build_instruction_ext_texture(
-         full_inst->InstructionExtTexture.Texture,
+      *instruction_texture = tgsi_build_instruction_texture(
+         full_inst->Texture.Texture,
          prev_token,
          instruction,
          header   );
-      prev_token = (struct tgsi_token  *) instruction_ext_texture;
+      prev_token = (struct tgsi_token  *) instruction_texture;
    }
 
    for( i = 0;  i <   full_inst->Instruction.NumDstRegs; i++ ) {
-      const struct tgsi_full_dst_register *reg = &full_inst->FullDstRegisters[i];
+      const struct tgsi_full_dst_register *reg = &full_inst->Dst[i];
       struct tgsi_dst_register *dst_register;
       struct tgsi_token *prev_token;
 
@@ -589,58 +561,15 @@ tgsi_build_full_instruction(
       size++;
 
       *dst_register = tgsi_build_dst_register(
-         reg->DstRegister.File,
-         reg->DstRegister.WriteMask,
-         reg->DstRegister.Indirect,
-         reg->DstRegister.Index,
+         reg->Register.File,
+         reg->Register.WriteMask,
+         reg->Register.Indirect,
+         reg->Register.Index,
          instruction,
          header );
       prev_token = (struct tgsi_token  *) dst_register;
 
-      if( tgsi_compare_dst_register_ext_concode(
-            reg->DstRegisterExtConcode,
-            tgsi_default_dst_register_ext_concode() ) ) {
-         struct tgsi_dst_register_ext_concode *dst_register_ext_concode;
-
-         if( maxsize <= size )
-            return 0;
-         dst_register_ext_concode =
-            (struct  tgsi_dst_register_ext_concode *) &tokens[size];
-         size++;
-
-         *dst_register_ext_concode =   tgsi_build_dst_register_ext_concode(
-            reg->DstRegisterExtConcode.CondMask,
-            reg->DstRegisterExtConcode.CondSwizzleX,
-            reg->DstRegisterExtConcode.CondSwizzleY,
-            reg->DstRegisterExtConcode.CondSwizzleZ,
-            reg->DstRegisterExtConcode.CondSwizzleW,
-            reg->DstRegisterExtConcode.CondSrcIndex,
-            prev_token,
-            instruction,
-            header );
-         prev_token = (struct tgsi_token  *) dst_register_ext_concode;
-      }
-
-      if( tgsi_compare_dst_register_ext_modulate(
-            reg->DstRegisterExtModulate,
-            tgsi_default_dst_register_ext_modulate() ) ) {
-         struct tgsi_dst_register_ext_modulate *dst_register_ext_modulate;
-
-         if( maxsize <= size )
-            return 0;
-         dst_register_ext_modulate =
-            (struct  tgsi_dst_register_ext_modulate *) &tokens[size];
-         size++;
-
-         *dst_register_ext_modulate = tgsi_build_dst_register_ext_modulate(
-            reg->DstRegisterExtModulate.Modulate,
-            prev_token,
-            instruction,
-            header );
-         prev_token = (struct tgsi_token  *) dst_register_ext_modulate;
-      }
-
-      if( reg->DstRegister.Indirect ) {
+      if( reg->Register.Indirect ) {
          struct tgsi_src_register *ind;
 
          if( maxsize <= size )
@@ -649,22 +578,23 @@ tgsi_build_full_instruction(
          size++;
 
          *ind = tgsi_build_src_register(
-            reg->DstRegisterInd.File,
-            reg->DstRegisterInd.SwizzleX,
-            reg->DstRegisterInd.SwizzleY,
-            reg->DstRegisterInd.SwizzleZ,
-            reg->DstRegisterInd.SwizzleW,
-            reg->DstRegisterInd.Negate,
-            reg->DstRegisterInd.Indirect,
-            reg->DstRegisterInd.Dimension,
-            reg->DstRegisterInd.Index,
+            reg->Indirect.File,
+            reg->Indirect.SwizzleX,
+            reg->Indirect.SwizzleY,
+            reg->Indirect.SwizzleZ,
+            reg->Indirect.SwizzleW,
+            reg->Indirect.Negate,
+            reg->Indirect.Absolute,
+            reg->Indirect.Indirect,
+            reg->Indirect.Dimension,
+            reg->Indirect.Index,
             instruction,
             header );
       }
    }
 
    for( i = 0;  i < full_inst->Instruction.NumSrcRegs; i++ ) {
-      const struct tgsi_full_src_register *reg = &full_inst->FullSrcRegisters[i];
+      const struct tgsi_full_src_register *reg = &full_inst->Src[i];
       struct tgsi_src_register *src_register;
       struct tgsi_token *prev_token;
 
@@ -674,77 +604,21 @@ tgsi_build_full_instruction(
       size++;
 
       *src_register = tgsi_build_src_register(
-         reg->SrcRegister.File,
-         reg->SrcRegister.SwizzleX,
-         reg->SrcRegister.SwizzleY,
-         reg->SrcRegister.SwizzleZ,
-         reg->SrcRegister.SwizzleW,
-         reg->SrcRegister.Negate,
-         reg->SrcRegister.Indirect,
-         reg->SrcRegister.Dimension,
-         reg->SrcRegister.Index,
+         reg->Register.File,
+         reg->Register.SwizzleX,
+         reg->Register.SwizzleY,
+         reg->Register.SwizzleZ,
+         reg->Register.SwizzleW,
+         reg->Register.Negate,
+         reg->Register.Absolute,
+         reg->Register.Indirect,
+         reg->Register.Dimension,
+         reg->Register.Index,
          instruction,
          header );
       prev_token = (struct tgsi_token  *) src_register;
 
-      if( tgsi_compare_src_register_ext_swz(
-            reg->SrcRegisterExtSwz,
-            tgsi_default_src_register_ext_swz() ) ) {
-         struct tgsi_src_register_ext_swz *src_register_ext_swz;
-
-         /* Use of the extended swizzle requires the simple swizzle to be identity.
-          */
-         assert( reg->SrcRegister.SwizzleX == TGSI_SWIZZLE_X );
-         assert( reg->SrcRegister.SwizzleY == TGSI_SWIZZLE_Y );
-         assert( reg->SrcRegister.SwizzleZ == TGSI_SWIZZLE_Z );
-         assert( reg->SrcRegister.SwizzleW == TGSI_SWIZZLE_W );
-         assert( reg->SrcRegister.Negate == FALSE );
-
-         if( maxsize <= size )
-            return 0;
-         src_register_ext_swz =
-            (struct  tgsi_src_register_ext_swz *) &tokens[size];
-         size++;
-
-         *src_register_ext_swz = tgsi_build_src_register_ext_swz(
-            reg->SrcRegisterExtSwz.ExtSwizzleX,
-            reg->SrcRegisterExtSwz.ExtSwizzleY,
-            reg->SrcRegisterExtSwz.ExtSwizzleZ,
-            reg->SrcRegisterExtSwz.ExtSwizzleW,
-            reg->SrcRegisterExtSwz.NegateX,
-            reg->SrcRegisterExtSwz.NegateY,
-            reg->SrcRegisterExtSwz.NegateZ,
-            reg->SrcRegisterExtSwz.NegateW,
-            prev_token,
-            instruction,
-            header );
-         prev_token = (struct tgsi_token  *) src_register_ext_swz;
-      }
-
-      if( tgsi_compare_src_register_ext_mod(
-            reg->SrcRegisterExtMod,
-            tgsi_default_src_register_ext_mod() ) ) {
-         struct tgsi_src_register_ext_mod *src_register_ext_mod;
-
-         if( maxsize <= size )
-            return 0;
-         src_register_ext_mod =
-            (struct  tgsi_src_register_ext_mod *) &tokens[size];
-         size++;
-
-         *src_register_ext_mod = tgsi_build_src_register_ext_mod(
-            reg->SrcRegisterExtMod.Complement,
-            reg->SrcRegisterExtMod.Bias,
-            reg->SrcRegisterExtMod.Scale2X,
-            reg->SrcRegisterExtMod.Absolute,
-            reg->SrcRegisterExtMod.Negate,
-            prev_token,
-            instruction,
-            header );
-         prev_token = (struct tgsi_token  *) src_register_ext_mod;
-      }
-
-      if( reg->SrcRegister.Indirect ) {
+      if( reg->Register.Indirect ) {
          struct  tgsi_src_register *ind;
 
          if( maxsize <= size )
@@ -753,23 +627,24 @@ tgsi_build_full_instruction(
          size++;
 
          *ind = tgsi_build_src_register(
-            reg->SrcRegisterInd.File,
-            reg->SrcRegisterInd.SwizzleX,
-            reg->SrcRegisterInd.SwizzleY,
-            reg->SrcRegisterInd.SwizzleZ,
-            reg->SrcRegisterInd.SwizzleW,
-            reg->SrcRegisterInd.Negate,
-            reg->SrcRegisterInd.Indirect,
-            reg->SrcRegisterInd.Dimension,
-            reg->SrcRegisterInd.Index,
+            reg->Indirect.File,
+            reg->Indirect.SwizzleX,
+            reg->Indirect.SwizzleY,
+            reg->Indirect.SwizzleZ,
+            reg->Indirect.SwizzleW,
+            reg->Indirect.Negate,
+            reg->Indirect.Absolute,
+            reg->Indirect.Indirect,
+            reg->Indirect.Dimension,
+            reg->Indirect.Index,
             instruction,
             header );
       }
 
-      if( reg->SrcRegister.Dimension ) {
+      if( reg->Register.Dimension ) {
          struct  tgsi_dimension *dim;
 
-         assert( !reg->SrcRegisterDim.Dimension );
+         assert( !reg->Dimension.Dimension );
 
          if( maxsize <= size )
             return 0;
@@ -777,12 +652,12 @@ tgsi_build_full_instruction(
          size++;
 
          *dim = tgsi_build_dimension(
-            reg->SrcRegisterDim.Indirect,
-            reg->SrcRegisterDim.Index,
+            reg->Dimension.Indirect,
+            reg->Dimension.Index,
             instruction,
             header );
 
-         if( reg->SrcRegisterDim.Indirect ) {
+         if( reg->Dimension.Indirect ) {
             struct tgsi_src_register *ind;
 
             if( maxsize <= size )
@@ -791,15 +666,16 @@ tgsi_build_full_instruction(
             size++;
 
             *ind = tgsi_build_src_register(
-               reg->SrcRegisterDimInd.File,
-               reg->SrcRegisterDimInd.SwizzleX,
-               reg->SrcRegisterDimInd.SwizzleY,
-               reg->SrcRegisterDimInd.SwizzleZ,
-               reg->SrcRegisterDimInd.SwizzleW,
-               reg->SrcRegisterDimInd.Negate,
-               reg->SrcRegisterDimInd.Indirect,
-               reg->SrcRegisterDimInd.Dimension,
-               reg->SrcRegisterDimInd.Index,
+               reg->DimIndirect.File,
+               reg->DimIndirect.SwizzleX,
+               reg->DimIndirect.SwizzleY,
+               reg->DimIndirect.SwizzleZ,
+               reg->DimIndirect.SwizzleW,
+               reg->DimIndirect.Negate,
+               reg->DimIndirect.Absolute,
+               reg->DimIndirect.Indirect,
+               reg->DimIndirect.Dimension,
+               reg->DimIndirect.Index,
                instruction,
                header );
          }
@@ -809,163 +685,103 @@ tgsi_build_full_instruction(
    return size;
 }
 
-struct tgsi_instruction_ext_nv
-tgsi_default_instruction_ext_nv( void )
+struct tgsi_instruction_predicate
+tgsi_default_instruction_predicate(void)
 {
-   struct tgsi_instruction_ext_nv instruction_ext_nv;
-
-   instruction_ext_nv.Type = TGSI_INSTRUCTION_EXT_TYPE_NV;
-   instruction_ext_nv.Precision = TGSI_PRECISION_DEFAULT;
-   instruction_ext_nv.CondDstIndex = 0;
-   instruction_ext_nv.CondFlowIndex = 0;
-   instruction_ext_nv.CondMask = TGSI_CC_TR;
-   instruction_ext_nv.CondSwizzleX = TGSI_SWIZZLE_X;
-   instruction_ext_nv.CondSwizzleY = TGSI_SWIZZLE_Y;
-   instruction_ext_nv.CondSwizzleZ = TGSI_SWIZZLE_Z;
-   instruction_ext_nv.CondSwizzleW = TGSI_SWIZZLE_W;
-   instruction_ext_nv.CondDstUpdate = 0;
-   instruction_ext_nv.CondFlowEnable = 0;
-   instruction_ext_nv.Padding = 0;
-   instruction_ext_nv.Extended = 0;
-
-   return instruction_ext_nv;
-}
+   struct tgsi_instruction_predicate instruction_predicate;
 
+   instruction_predicate.SwizzleX = TGSI_SWIZZLE_X;
+   instruction_predicate.SwizzleY = TGSI_SWIZZLE_Y;
+   instruction_predicate.SwizzleZ = TGSI_SWIZZLE_Z;
+   instruction_predicate.SwizzleW = TGSI_SWIZZLE_W;
+   instruction_predicate.Negate = 0;
+   instruction_predicate.Index = 0;
+   instruction_predicate.Padding = 0;
 
-/** test for inequality of 32-bit values pointed to by a and b */
-static INLINE boolean
-compare32(const void *a, const void *b)
-{
-   return *((uint32_t *) a) != *((uint32_t *) b);
+   return instruction_predicate;
 }
 
-
-unsigned
-tgsi_compare_instruction_ext_nv(
-   struct tgsi_instruction_ext_nv a,
-   struct tgsi_instruction_ext_nv b )
+struct tgsi_instruction_predicate
+tgsi_build_instruction_predicate(int index,
+                                 unsigned negate,
+                                 unsigned swizzleX,
+                                 unsigned swizzleY,
+                                 unsigned swizzleZ,
+                                 unsigned swizzleW,
+                                 struct tgsi_instruction *instruction,
+                                 struct tgsi_header *header)
 {
-   a.Padding = b.Padding = 0;
-   a.Extended = b.Extended = 0;
-   return compare32(&a, &b);
-}
+   struct tgsi_instruction_predicate instruction_predicate;
 
-struct tgsi_instruction_ext_nv
-tgsi_build_instruction_ext_nv(
-   unsigned precision,
-   unsigned cond_dst_index,
-   unsigned cond_flow_index,
-   unsigned cond_mask,
-   unsigned cond_swizzle_x,
-   unsigned cond_swizzle_y,
-   unsigned cond_swizzle_z,
-   unsigned cond_swizzle_w,
-   unsigned cond_dst_update,
-   unsigned cond_flow_enable,
-   struct tgsi_token *prev_token,
-   struct tgsi_instruction *instruction,
-   struct tgsi_header *header )
-{
-   struct tgsi_instruction_ext_nv instruction_ext_nv;
-
-   instruction_ext_nv = tgsi_default_instruction_ext_nv();
-   instruction_ext_nv.Precision = precision;
-   instruction_ext_nv.CondDstIndex = cond_dst_index;
-   instruction_ext_nv.CondFlowIndex = cond_flow_index;
-   instruction_ext_nv.CondMask = cond_mask;
-   instruction_ext_nv.CondSwizzleX = cond_swizzle_x;
-   instruction_ext_nv.CondSwizzleY = cond_swizzle_y;
-   instruction_ext_nv.CondSwizzleZ = cond_swizzle_z;
-   instruction_ext_nv.CondSwizzleW = cond_swizzle_w;
-   instruction_ext_nv.CondDstUpdate = cond_dst_update;
-   instruction_ext_nv.CondFlowEnable = cond_flow_enable;
-
-   prev_token->Extended = 1;
-   instruction_grow( instruction, header );
+   instruction_predicate = tgsi_default_instruction_predicate();
+   instruction_predicate.SwizzleX = swizzleX;
+   instruction_predicate.SwizzleY = swizzleY;
+   instruction_predicate.SwizzleZ = swizzleZ;
+   instruction_predicate.SwizzleW = swizzleW;
+   instruction_predicate.Negate = negate;
+   instruction_predicate.Index = index;
+
+   instruction_grow(instruction, header);
 
-   return instruction_ext_nv;
+   return instruction_predicate;
 }
 
-struct tgsi_instruction_ext_label
-tgsi_default_instruction_ext_label( void )
+struct tgsi_instruction_label
+tgsi_default_instruction_label( void )
 {
-   struct tgsi_instruction_ext_label instruction_ext_label;
+   struct tgsi_instruction_label instruction_label;
 
-   instruction_ext_label.Type = TGSI_INSTRUCTION_EXT_TYPE_LABEL;
-   instruction_ext_label.Label = 0;
-   instruction_ext_label.Padding = 0;
-   instruction_ext_label.Extended = 0;
-
-   return instruction_ext_label;
-}
+   instruction_label.Label = 0;
+   instruction_label.Padding = 0;
 
-unsigned
-tgsi_compare_instruction_ext_label(
-   struct tgsi_instruction_ext_label a,
-   struct tgsi_instruction_ext_label b )
-{
-   a.Padding = b.Padding = 0;
-   a.Extended = b.Extended = 0;
-   return compare32(&a, &b);
+   return instruction_label;
 }
 
-struct tgsi_instruction_ext_label
-tgsi_build_instruction_ext_label(
+struct tgsi_instruction_label
+tgsi_build_instruction_label(
    unsigned label,
    struct tgsi_token  *prev_token,
    struct tgsi_instruction *instruction,
    struct tgsi_header *header )
 {
-   struct tgsi_instruction_ext_label instruction_ext_label;
+   struct tgsi_instruction_label instruction_label;
 
-   instruction_ext_label = tgsi_default_instruction_ext_label();
-   instruction_ext_label.Label = label;
+   instruction_label = tgsi_default_instruction_label();
+   instruction_label.Label = label;
+   instruction->Label = 1;
 
-   prev_token->Extended = 1;
    instruction_grow( instruction, header );
 
-   return instruction_ext_label;
+   return instruction_label;
 }
 
-struct tgsi_instruction_ext_texture
-tgsi_default_instruction_ext_texture( void )
+struct tgsi_instruction_texture
+tgsi_default_instruction_texture( void )
 {
-   struct tgsi_instruction_ext_texture instruction_ext_texture;
+   struct tgsi_instruction_texture instruction_texture;
 
-   instruction_ext_texture.Type = TGSI_INSTRUCTION_EXT_TYPE_TEXTURE;
-   instruction_ext_texture.Texture = TGSI_TEXTURE_UNKNOWN;
-   instruction_ext_texture.Padding = 0;
-   instruction_ext_texture.Extended = 0;
+   instruction_texture.Texture = TGSI_TEXTURE_UNKNOWN;
+   instruction_texture.Padding = 0;
 
-   return instruction_ext_texture;
-}
-
-unsigned
-tgsi_compare_instruction_ext_texture(
-   struct tgsi_instruction_ext_texture a,
-   struct tgsi_instruction_ext_texture b )
-{
-   a.Padding = b.Padding = 0;
-   a.Extended = b.Extended = 0;
-   return compare32(&a, &b);
+   return instruction_texture;
 }
 
-struct tgsi_instruction_ext_texture
-tgsi_build_instruction_ext_texture(
+struct tgsi_instruction_texture
+tgsi_build_instruction_texture(
    unsigned texture,
    struct tgsi_token *prev_token,
    struct tgsi_instruction *instruction,
    struct tgsi_header *header )
 {
-   struct tgsi_instruction_ext_texture instruction_ext_texture;
+   struct tgsi_instruction_texture instruction_texture;
 
-   instruction_ext_texture = tgsi_default_instruction_ext_texture();
-   instruction_ext_texture.Texture = texture;
+   instruction_texture = tgsi_default_instruction_texture();
+   instruction_texture.Texture = texture;
+   instruction->Texture = 1;
 
-   prev_token->Extended = 1;
    instruction_grow( instruction, header );
 
-   return instruction_ext_texture;
+   return instruction_texture;
 }
 
 struct tgsi_src_register
@@ -979,10 +795,10 @@ tgsi_default_src_register( void )
    src_register.SwizzleZ = TGSI_SWIZZLE_Z;
    src_register.SwizzleW = TGSI_SWIZZLE_W;
    src_register.Negate = 0;
+   src_register.Absolute = 0;
    src_register.Indirect = 0;
    src_register.Dimension = 0;
    src_register.Index = 0;
-   src_register.Extended = 0;
 
    return src_register;
 }
@@ -995,6 +811,7 @@ tgsi_build_src_register(
    unsigned swizzle_z,
    unsigned swizzle_w,
    unsigned negate,
+   unsigned absolute,
    unsigned indirect,
    unsigned dimension,
    int index,
@@ -1018,6 +835,7 @@ tgsi_build_src_register(
    src_register.SwizzleZ = swizzle_z;
    src_register.SwizzleW = swizzle_w;
    src_register.Negate = negate;
+   src_register.Absolute = absolute;
    src_register.Indirect = indirect;
    src_register.Dimension = dimension;
    src_register.Index = index;
@@ -1032,145 +850,14 @@ tgsi_default_full_src_register( void )
 {
    struct tgsi_full_src_register full_src_register;
 
-   full_src_register.SrcRegister = tgsi_default_src_register();
-   full_src_register.SrcRegisterExtSwz = tgsi_default_src_register_ext_swz();
-   full_src_register.SrcRegisterExtMod = tgsi_default_src_register_ext_mod();
-   full_src_register.SrcRegisterInd = tgsi_default_src_register();
-   full_src_register.SrcRegisterDim = tgsi_default_dimension();
-   full_src_register.SrcRegisterDimInd = tgsi_default_src_register();
+   full_src_register.Register = tgsi_default_src_register();
+   full_src_register.Indirect = tgsi_default_src_register();
+   full_src_register.Dimension = tgsi_default_dimension();
+   full_src_register.DimIndirect = tgsi_default_src_register();
 
    return full_src_register;
 }
 
-struct tgsi_src_register_ext_swz
-tgsi_default_src_register_ext_swz( void )
-{
-   struct tgsi_src_register_ext_swz src_register_ext_swz;
-
-   src_register_ext_swz.Type = TGSI_SRC_REGISTER_EXT_TYPE_SWZ;
-   src_register_ext_swz.ExtSwizzleX = TGSI_EXTSWIZZLE_X;
-   src_register_ext_swz.ExtSwizzleY = TGSI_EXTSWIZZLE_Y;
-   src_register_ext_swz.ExtSwizzleZ = TGSI_EXTSWIZZLE_Z;
-   src_register_ext_swz.ExtSwizzleW = TGSI_EXTSWIZZLE_W;
-   src_register_ext_swz.NegateX = 0;
-   src_register_ext_swz.NegateY = 0;
-   src_register_ext_swz.NegateZ = 0;
-   src_register_ext_swz.NegateW = 0;
-   src_register_ext_swz.Padding = 0;
-   src_register_ext_swz.Extended = 0;
-
-   return src_register_ext_swz;
-}
-
-unsigned
-tgsi_compare_src_register_ext_swz(
-   struct tgsi_src_register_ext_swz a,
-   struct tgsi_src_register_ext_swz b )
-{
-   a.Padding = b.Padding = 0;
-   a.Extended = b.Extended = 0;
-   return compare32(&a, &b);
-}
-
-struct tgsi_src_register_ext_swz
-tgsi_build_src_register_ext_swz(
-   unsigned ext_swizzle_x,
-   unsigned ext_swizzle_y,
-   unsigned ext_swizzle_z,
-   unsigned ext_swizzle_w,
-   unsigned negate_x,
-   unsigned negate_y,
-   unsigned negate_z,
-   unsigned negate_w,
-   struct tgsi_token *prev_token,
-   struct tgsi_instruction *instruction,
-   struct tgsi_header *header )
-{
-   struct tgsi_src_register_ext_swz src_register_ext_swz;
-
-   assert( ext_swizzle_x <= TGSI_EXTSWIZZLE_ONE );
-   assert( ext_swizzle_y <= TGSI_EXTSWIZZLE_ONE );
-   assert( ext_swizzle_z <= TGSI_EXTSWIZZLE_ONE );
-   assert( ext_swizzle_w <= TGSI_EXTSWIZZLE_ONE );
-   assert( negate_x <= 1 );
-   assert( negate_y <= 1 );
-   assert( negate_z <= 1 );
-   assert( negate_w <= 1 );
-
-   src_register_ext_swz = tgsi_default_src_register_ext_swz();
-   src_register_ext_swz.ExtSwizzleX = ext_swizzle_x;
-   src_register_ext_swz.ExtSwizzleY = ext_swizzle_y;
-   src_register_ext_swz.ExtSwizzleZ = ext_swizzle_z;
-   src_register_ext_swz.ExtSwizzleW = ext_swizzle_w;
-   src_register_ext_swz.NegateX = negate_x;
-   src_register_ext_swz.NegateY = negate_y;
-   src_register_ext_swz.NegateZ = negate_z;
-   src_register_ext_swz.NegateW = negate_w;
-
-   prev_token->Extended = 1;
-   instruction_grow( instruction, header );
-
-   return src_register_ext_swz;
-}
-
-struct tgsi_src_register_ext_mod
-tgsi_default_src_register_ext_mod( void )
-{
-   struct tgsi_src_register_ext_mod src_register_ext_mod;
-
-   src_register_ext_mod.Type = TGSI_SRC_REGISTER_EXT_TYPE_MOD;
-   src_register_ext_mod.Complement = 0;
-   src_register_ext_mod.Bias = 0;
-   src_register_ext_mod.Scale2X = 0;
-   src_register_ext_mod.Absolute = 0;
-   src_register_ext_mod.Negate = 0;
-   src_register_ext_mod.Padding = 0;
-   src_register_ext_mod.Extended = 0;
-
-   return src_register_ext_mod;
-}
-
-unsigned
-tgsi_compare_src_register_ext_mod(
-   struct tgsi_src_register_ext_mod a,
-   struct tgsi_src_register_ext_mod b )
-{
-   a.Padding = b.Padding = 0;
-   a.Extended = b.Extended = 0;
-   return compare32(&a, &b);
-}
-
-struct tgsi_src_register_ext_mod
-tgsi_build_src_register_ext_mod(
-   unsigned complement,
-   unsigned bias,
-   unsigned scale_2x,
-   unsigned absolute,
-   unsigned negate,
-   struct tgsi_token *prev_token,
-   struct tgsi_instruction *instruction,
-   struct tgsi_header *header )
-{
-   struct tgsi_src_register_ext_mod src_register_ext_mod;
-
-   assert( complement <= 1 );
-   assert( bias <= 1 );
-   assert( scale_2x <= 1 );
-   assert( absolute <= 1 );
-   assert( negate <= 1 );
-
-   src_register_ext_mod = tgsi_default_src_register_ext_mod();
-   src_register_ext_mod.Complement = complement;
-   src_register_ext_mod.Bias = bias;
-   src_register_ext_mod.Scale2X = scale_2x;
-   src_register_ext_mod.Absolute = absolute;
-   src_register_ext_mod.Negate = negate;
-
-   prev_token->Extended = 1;
-   instruction_grow( instruction, header );
-
-   return src_register_ext_mod;
-}
 
 struct tgsi_dimension
 tgsi_default_dimension( void )
@@ -1181,7 +868,6 @@ tgsi_default_dimension( void )
    dimension.Dimension = 0;
    dimension.Padding = 0;
    dimension.Index = 0;
-   dimension.Extended = 0;
 
    return dimension;
 }
@@ -1215,7 +901,6 @@ tgsi_default_dst_register( void )
    dst_register.Dimension = 0;
    dst_register.Index = 0;
    dst_register.Padding = 0;
-   dst_register.Extended = 0;
 
    return dst_register;
 }
@@ -1251,118 +936,113 @@ tgsi_default_full_dst_register( void )
 {
    struct tgsi_full_dst_register full_dst_register;
 
-   full_dst_register.DstRegister = tgsi_default_dst_register();
-   full_dst_register.DstRegisterInd = tgsi_default_src_register();
-   full_dst_register.DstRegisterExtConcode =
-      tgsi_default_dst_register_ext_concode();
-   full_dst_register.DstRegisterExtModulate =
-      tgsi_default_dst_register_ext_modulate();
+   full_dst_register.Register = tgsi_default_dst_register();
+   full_dst_register.Indirect = tgsi_default_src_register();
 
    return full_dst_register;
 }
 
-struct tgsi_dst_register_ext_concode
-tgsi_default_dst_register_ext_concode( void )
+struct tgsi_property
+tgsi_default_property( void )
 {
-   struct tgsi_dst_register_ext_concode dst_register_ext_concode;
-
-   dst_register_ext_concode.Type = TGSI_DST_REGISTER_EXT_TYPE_CONDCODE;
-   dst_register_ext_concode.CondMask = TGSI_CC_TR;
-   dst_register_ext_concode.CondSwizzleX = TGSI_SWIZZLE_X;
-   dst_register_ext_concode.CondSwizzleY = TGSI_SWIZZLE_Y;
-   dst_register_ext_concode.CondSwizzleZ = TGSI_SWIZZLE_Z;
-   dst_register_ext_concode.CondSwizzleW = TGSI_SWIZZLE_W;
-   dst_register_ext_concode.CondSrcIndex = 0;
-   dst_register_ext_concode.Padding = 0;
-   dst_register_ext_concode.Extended = 0;
-
-   return dst_register_ext_concode;
+   struct tgsi_property property;
+
+   property.Type = TGSI_TOKEN_TYPE_PROPERTY;
+   property.NrTokens = 1;
+   property.PropertyName = TGSI_PROPERTY_GS_INPUT_PRIM;
+   property.Padding = 0;
+
+   return property;
 }
 
-unsigned
-tgsi_compare_dst_register_ext_concode(
-   struct tgsi_dst_register_ext_concode a,
-   struct tgsi_dst_register_ext_concode b )
+struct tgsi_property
+tgsi_build_property(unsigned property_name,
+                    struct tgsi_header *header)
 {
-   a.Padding = b.Padding = 0;
-   a.Extended = b.Extended = 0;
-   return compare32(&a, &b);
+   struct tgsi_property property;
+
+   property = tgsi_default_property();
+   property.PropertyName = property_name;
+
+   header_bodysize_grow( header );
+
+   return property;
 }
 
-struct tgsi_dst_register_ext_concode
-tgsi_build_dst_register_ext_concode(
-   unsigned cc,
-   unsigned swizzle_x,
-   unsigned swizzle_y,
-   unsigned swizzle_z,
-   unsigned swizzle_w,
-   int index,
-   struct tgsi_token *prev_token,
-   struct tgsi_instruction *instruction,
-   struct tgsi_header *header )
+
+struct tgsi_full_property
+tgsi_default_full_property( void )
 {
-   struct tgsi_dst_register_ext_concode dst_register_ext_concode;
+   struct tgsi_full_property  full_property;
 
-   assert( cc <= TGSI_CC_FL );
-   assert( swizzle_x <= TGSI_SWIZZLE_W );
-   assert( swizzle_y <= TGSI_SWIZZLE_W );
-   assert( swizzle_z <= TGSI_SWIZZLE_W );
-   assert( swizzle_w <= TGSI_SWIZZLE_W );
-   assert( index >= -32768 && index <= 32767 );
+   full_property.Property  = tgsi_default_property();
+   memset(full_property.u, 0,
+          sizeof(struct tgsi_property_data) * 8);
 
-   dst_register_ext_concode = tgsi_default_dst_register_ext_concode();
-   dst_register_ext_concode.CondMask = cc;
-   dst_register_ext_concode.CondSwizzleX = swizzle_x;
-   dst_register_ext_concode.CondSwizzleY = swizzle_y;
-   dst_register_ext_concode.CondSwizzleZ = swizzle_z;
-   dst_register_ext_concode.CondSwizzleW = swizzle_w;
-   dst_register_ext_concode.CondSrcIndex = index;
+   return full_property;
+}
 
-   prev_token->Extended = 1;
-   instruction_grow( instruction, header );
+static void
+property_grow(
+   struct tgsi_property *property,
+   struct tgsi_header *header )
+{
+   assert( property->NrTokens < 0xFF );
 
-   return dst_register_ext_concode;
+   property->NrTokens++;
+
+   header_bodysize_grow( header );
 }
 
-struct tgsi_dst_register_ext_modulate
-tgsi_default_dst_register_ext_modulate( void )
+struct tgsi_property_data
+tgsi_build_property_data(
+   unsigned value,
+   struct tgsi_property *property,
+   struct tgsi_header *header )
 {
-   struct tgsi_dst_register_ext_modulate dst_register_ext_modulate;
+   struct tgsi_property_data property_data;
+
+   property_data.Data = value;
 
-   dst_register_ext_modulate.Type = TGSI_DST_REGISTER_EXT_TYPE_MODULATE;
-   dst_register_ext_modulate.Modulate = TGSI_MODULATE_1X;
-   dst_register_ext_modulate.Padding = 0;
-   dst_register_ext_modulate.Extended = 0;
+   property_grow( property, header );
 
-   return dst_register_ext_modulate;
+   return property_data;
 }
 
 unsigned
-tgsi_compare_dst_register_ext_modulate(
-   struct tgsi_dst_register_ext_modulate a,
-   struct tgsi_dst_register_ext_modulate b )
+tgsi_build_full_property(
+   const struct tgsi_full_property *full_prop,
+   struct tgsi_token *tokens,
+   struct tgsi_header *header,
+   unsigned maxsize )
 {
-   a.Padding = b.Padding = 0;
-   a.Extended = b.Extended = 0;
-   return compare32(&a, &b);
-}
+   unsigned size = 0, i;
+   struct tgsi_property *property;
 
-struct tgsi_dst_register_ext_modulate
-tgsi_build_dst_register_ext_modulate(
-   unsigned modulate,
-   struct tgsi_token *prev_token,
-   struct tgsi_instruction *instruction,
-   struct tgsi_header *header )
-{
-   struct tgsi_dst_register_ext_modulate dst_register_ext_modulate;
+   if( maxsize <= size )
+      return 0;
+   property = (struct tgsi_property *) &tokens[size];
+   size++;
 
-   assert( modulate <= TGSI_MODULATE_EIGHTH );
+   *property = tgsi_build_property(
+      full_prop->Property.PropertyName,
+      header );
 
-   dst_register_ext_modulate = tgsi_default_dst_register_ext_modulate();
-   dst_register_ext_modulate.Modulate = modulate;
+   assert( full_prop->Property.NrTokens <= 8 + 1 );
 
-   prev_token->Extended = 1;
-   instruction_grow( instruction, header );
+   for( i = 0; i < full_prop->Property.NrTokens - 1; i++ ) {
+      struct tgsi_property_data *data;
+
+      if( maxsize <= size )
+         return  0;
+      data = (struct tgsi_property_data *) &tokens[size];
+      size++;
 
-   return dst_register_ext_modulate;
+      *data = tgsi_build_property_data(
+         full_prop->u[i].Data,
+         property,
+         header );
+   }
+
+   return size;
 }
index 17d977b05971dd3ae80e8110051aa6c7094bb53f..9de2757fe40b9ecc579784a37d3af0f6d2c43c73 100644 (file)
@@ -36,12 +36,6 @@ struct tgsi_token;
 extern "C" {
 #endif
 
-/*
- * version
- */
-
-struct tgsi_version
-tgsi_build_version( void );
 
 /*
  * header
@@ -132,6 +126,34 @@ tgsi_build_full_immediate(
    struct tgsi_header *header,
    unsigned maxsize );
 
+/*
+ * properties
+ */
+
+struct tgsi_property
+tgsi_default_property( void );
+
+struct tgsi_property
+tgsi_build_property(
+   unsigned property_name,
+   struct tgsi_header *header );
+
+struct tgsi_full_property
+tgsi_default_full_property( void );
+
+struct tgsi_property_data
+tgsi_build_property_data(
+   unsigned value,
+   struct tgsi_property *property,
+   struct tgsi_header *header );
+
+unsigned
+tgsi_build_full_property(
+   const struct tgsi_full_property *full_prop,
+   struct tgsi_token *tokens,
+   struct tgsi_header *header,
+   unsigned maxsize );
+
 /*
  * instruction
  */
@@ -143,6 +165,7 @@ struct tgsi_instruction
 tgsi_build_instruction(
    unsigned opcode,
    unsigned saturate,
+   unsigned predicate,
    unsigned num_dst_regs,
    unsigned num_src_regs,
    struct tgsi_header *header );
@@ -157,55 +180,34 @@ tgsi_build_full_instruction(
    struct tgsi_header *header,
    unsigned maxsize );
 
-struct tgsi_instruction_ext_nv
-tgsi_default_instruction_ext_nv( void );
-
-unsigned
-tgsi_compare_instruction_ext_nv(
-   struct tgsi_instruction_ext_nv a,
-   struct tgsi_instruction_ext_nv b );
-
-struct tgsi_instruction_ext_nv
-tgsi_build_instruction_ext_nv(
-   unsigned precision,
-   unsigned cond_dst_index,
-   unsigned cond_flow_index,
-   unsigned cond_mask,
-   unsigned cond_swizzle_x,
-   unsigned cond_swizzle_y,
-   unsigned cond_swizzle_z,
-   unsigned cond_swizzle_w,
-   unsigned cond_dst_update,
-   unsigned cond_flow_enable,
-   struct tgsi_token *prev_token,
-   struct tgsi_instruction *instruction,
-   struct tgsi_header *header );
+struct tgsi_instruction_predicate
+tgsi_default_instruction_predicate(void);
 
-struct tgsi_instruction_ext_label
-tgsi_default_instruction_ext_label( void );
+struct tgsi_instruction_predicate
+tgsi_build_instruction_predicate(int index,
+                                 unsigned negate,
+                                 unsigned swizzleX,
+                                 unsigned swizzleY,
+                                 unsigned swizzleZ,
+                                 unsigned swizzleW,
+                                 struct tgsi_instruction *instruction,
+                                 struct tgsi_header *header);
 
-unsigned
-tgsi_compare_instruction_ext_label(
-   struct tgsi_instruction_ext_label a,
-   struct tgsi_instruction_ext_label b );
+struct tgsi_instruction_label
+tgsi_default_instruction_label( void );
 
-struct tgsi_instruction_ext_label
-tgsi_build_instruction_ext_label(
+struct tgsi_instruction_label
+tgsi_build_instruction_label(
    unsigned label,
    struct tgsi_token *prev_token,
    struct tgsi_instruction *instruction,
    struct tgsi_header *header );
 
-struct tgsi_instruction_ext_texture
-tgsi_default_instruction_ext_texture( void );
-
-unsigned
-tgsi_compare_instruction_ext_texture(
-   struct tgsi_instruction_ext_texture a,
-   struct tgsi_instruction_ext_texture b );
+struct tgsi_instruction_texture
+tgsi_default_instruction_texture( void );
 
-struct tgsi_instruction_ext_texture
-tgsi_build_instruction_ext_texture(
+struct tgsi_instruction_texture
+tgsi_build_instruction_texture(
    unsigned texture,
    struct tgsi_token *prev_token,
    struct tgsi_instruction *instruction,
@@ -222,6 +224,7 @@ tgsi_build_src_register(
    unsigned swizzle_z,
    unsigned swizzle_w,
    unsigned negate,
+   unsigned absolute,
    unsigned indirect,
    unsigned dimension,
    int index,
@@ -231,46 +234,6 @@ tgsi_build_src_register(
 struct tgsi_full_src_register
 tgsi_default_full_src_register( void );
 
-struct tgsi_src_register_ext_swz
-tgsi_default_src_register_ext_swz( void );
-
-unsigned
-tgsi_compare_src_register_ext_swz(
-   struct tgsi_src_register_ext_swz a,
-   struct tgsi_src_register_ext_swz b );
-
-struct tgsi_src_register_ext_swz
-tgsi_build_src_register_ext_swz(
-   unsigned ext_swizzle_x,
-   unsigned ext_swizzle_y,
-   unsigned ext_swizzle_z,
-   unsigned ext_swizzle_w,
-   unsigned negate_x,
-   unsigned negate_y,
-   unsigned negate_z,
-   unsigned negate_w,
-   struct tgsi_token *prev_token,
-   struct tgsi_instruction *instruction,
-   struct tgsi_header *header );
-
-struct tgsi_src_register_ext_mod
-tgsi_default_src_register_ext_mod( void );
-
-unsigned
-tgsi_compare_src_register_ext_mod(
-   struct tgsi_src_register_ext_mod a,
-   struct tgsi_src_register_ext_mod b );
-
-struct tgsi_src_register_ext_mod
-tgsi_build_src_register_ext_mod(
-   unsigned complement,
-   unsigned bias,
-   unsigned scale_2x,
-   unsigned absolute,
-   unsigned negate,
-   struct tgsi_token *prev_token,
-   struct tgsi_instruction *instruction,
-   struct tgsi_header *header );
 
 struct tgsi_dimension
 tgsi_default_dimension( void );
@@ -297,40 +260,6 @@ tgsi_build_dst_register(
 struct tgsi_full_dst_register
 tgsi_default_full_dst_register( void );
 
-struct tgsi_dst_register_ext_concode
-tgsi_default_dst_register_ext_concode( void );
-
-unsigned
-tgsi_compare_dst_register_ext_concode(
-   struct tgsi_dst_register_ext_concode a,
-   struct tgsi_dst_register_ext_concode b );
-
-struct tgsi_dst_register_ext_concode
-tgsi_build_dst_register_ext_concode(
-   unsigned cc,
-   unsigned swizzle_x,
-   unsigned swizzle_y,
-   unsigned swizzle_z,
-   unsigned swizzle_w,
-   int index,
-   struct tgsi_token *prev_token,
-   struct tgsi_instruction *instruction,
-   struct tgsi_header *header );
-
-struct tgsi_dst_register_ext_modulate
-tgsi_default_dst_register_ext_modulate( void );
-
-unsigned
-tgsi_compare_dst_register_ext_modulate(
-   struct tgsi_dst_register_ext_modulate a,
-   struct tgsi_dst_register_ext_modulate b );
-
-struct tgsi_dst_register_ext_modulate
-tgsi_build_dst_register_ext_modulate(
-   unsigned modulate,
-   struct tgsi_token *prev_token,
-   struct tgsi_instruction *instruction,
-   struct tgsi_header *header );
 
 #if defined __cplusplus
 }
index 111d95b6665b7c4731d57b69211cdc8e4e2edba8..e2e5394f86f14f875b69765a182cf78c067aade9 100644 (file)
@@ -100,7 +100,9 @@ static const char *file_names[TGSI_FILE_COUNT] =
    "SAMP",
    "ADDR",
    "IMM",
-   "LOOP"
+   "LOOP",
+   "PRED",
+   "SV"
 };
 
 static const char *interpolate_names[] =
@@ -119,12 +121,16 @@ static const char *semantic_names[] =
    "PSIZE",
    "GENERIC",
    "NORMAL",
-   "FACE"
+   "FACE",
+   "EDGEFLAG",
+   "PRIM_ID"
 };
 
 static const char *immediate_type_names[] =
 {
-   "FLT32"
+   "FLT32",
+   "UINT32",
+   "INT32"
 };
 
 static const char *swizzle_names[] =
@@ -148,35 +154,42 @@ static const char *texture_names[] =
    "SHADOWRECT"
 };
 
-static const char *extswizzle_names[] =
+static const char *property_names[] =
 {
-   "x",
-   "y",
-   "z",
-   "w",
-   "0",
-   "1"
+   "GS_INPUT_PRIMITIVE",
+   "GS_OUTPUT_PRIMITIVE",
+   "GS_MAX_OUTPUT_VERTICES"
 };
 
-static const char *modulate_names[TGSI_MODULATE_COUNT] =
+static const char *primitive_names[] =
 {
-   "",
-   "_2X",
-   "_4X",
-   "_8X",
-   "_D2",
-   "_D4",
-   "_D8"
+   "POINTS",
+   "LINES",
+   "LINE_LOOP",
+   "LINE_STRIP",
+   "TRIANGLES",
+   "TRIANGLE_STRIP",
+   "TRIANGLE_FAN",
+   "QUADS",
+   "QUAD_STRIP",
+   "POLYGON"
 };
 
+
 static void
-_dump_register(
+_dump_register_decl(
    struct dump_ctx *ctx,
    uint file,
    int first,
    int last )
 {
    ENM( file, file_names );
+
+   /* all geometry shader inputs are two dimensional */
+   if (file == TGSI_FILE_INPUT &&
+       ctx->iter.processor.Processor == TGSI_PROCESSOR_GEOMETRY)
+      TXT("[]");
+
    CHR( '[' );
    SID( first );
    if (first != last) {
@@ -186,6 +199,52 @@ _dump_register(
    CHR( ']' );
 }
 
+static void
+_dump_register_dst(
+   struct dump_ctx *ctx,
+   uint file,
+   int index)
+{
+   ENM( file, file_names );
+
+   CHR( '[' );
+   SID( index );
+   CHR( ']' );
+}
+
+
+static void
+_dump_register_src(
+   struct dump_ctx *ctx,
+   const struct tgsi_full_src_register *src )
+{
+   if (src->Register.Indirect) {
+      ENM( src->Register.File, file_names );
+      CHR( '[' );
+      ENM( src->Indirect.File, file_names );
+      CHR( '[' );
+      SID( src->Indirect.Index );
+      TXT( "]." );
+      ENM( src->Indirect.SwizzleX, swizzle_names );
+      if (src->Register.Index != 0) {
+         if (src->Register.Index > 0)
+            CHR( '+' );
+         SID( src->Register.Index );
+      }
+      CHR( ']' );
+   } else {
+      ENM( src->Register.File, file_names );
+      CHR( '[' );
+      SID( src->Register.Index );
+      CHR( ']' );
+   }
+   if (src->Register.Dimension) {
+      CHR( '[' );
+      SID( src->Dimension.Index );
+      CHR( ']' );
+   }
+}
+
 static void
 _dump_register_ind(
    struct dump_ctx *ctx,
@@ -240,22 +299,22 @@ iter_declaration(
 
    TXT( "DCL " );
 
-   _dump_register(
+   _dump_register_decl(
       ctx,
       decl->Declaration.File,
-      decl->DeclarationRange.First,
-      decl->DeclarationRange.Last );
+      decl->Range.First,
+      decl->Range.Last );
    _dump_writemask(
       ctx,
       decl->Declaration.UsageMask );
 
    if (decl->Declaration.Semantic) {
       TXT( ", " );
-      ENM( decl->Semantic.SemanticName, semantic_names );
-      if (decl->Semantic.SemanticIndex != 0 ||
-          decl->Semantic.SemanticName == TGSI_SEMANTIC_GENERIC) {
+      ENM( decl->Semantic.Name, semantic_names );
+      if (decl->Semantic.Index != 0 ||
+          decl->Semantic.Name == TGSI_SEMANTIC_GENERIC) {
          CHR( '[' );
-         UID( decl->Semantic.SemanticIndex );
+         UID( decl->Semantic.Index );
          CHR( ']' );
       }
    }
@@ -291,6 +350,50 @@ tgsi_dump_declaration(
    iter_declaration( &ctx.iter, (struct tgsi_full_declaration *)decl );
 }
 
+static boolean
+iter_property(
+   struct tgsi_iterate_context *iter,
+   struct tgsi_full_property *prop )
+{
+   int i;
+   struct dump_ctx *ctx = (struct dump_ctx *)iter;
+
+   assert(Elements(property_names) == TGSI_PROPERTY_COUNT);
+
+   TXT( "PROPERTY " );
+   ENM(prop->Property.PropertyName, property_names);
+
+   if (prop->Property.NrTokens > 1)
+      TXT(" ");
+
+   for (i = 0; i < prop->Property.NrTokens - 1; ++i) {
+      switch (prop->Property.PropertyName) {
+      case TGSI_PROPERTY_GS_INPUT_PRIM:
+      case TGSI_PROPERTY_GS_OUTPUT_PRIM:
+         ENM(prop->u[i].Data, primitive_names);
+         break;
+      default:
+         SID( prop->u[i].Data );
+         break;
+      }
+      if (i < prop->Property.NrTokens - 2)
+         TXT( ", " );
+   }
+   EOL();
+
+   return TRUE;
+}
+
+void tgsi_dump_property(
+   const struct tgsi_full_property *prop )
+{
+   struct dump_ctx ctx;
+
+   ctx.printf = dump_ctx_printf;
+
+   iter_property( &ctx.iter, (struct tgsi_full_property *)prop );
+}
+
 static boolean
 iter_immediate(
    struct tgsi_iterate_context *iter,
@@ -311,6 +414,12 @@ iter_immediate(
       case TGSI_IMM_FLOAT32:
          FLT( imm->u[i].Float );
          break;
+      case TGSI_IMM_UINT32:
+         UID(imm->u[i].Uint);
+         break;
+      case TGSI_IMM_INT32:
+         SID(imm->u[i].Int);
+         break;
       default:
          assert( 0 );
       }
@@ -371,117 +480,66 @@ iter_instruction(
    }
 
    for (i = 0; i < inst->Instruction.NumDstRegs; i++) {
-      const struct tgsi_full_dst_register *dst = &inst->FullDstRegisters[i];
+      const struct tgsi_full_dst_register *dst = &inst->Dst[i];
 
       if (!first_reg)
          CHR( ',' );
       CHR( ' ' );
 
-      if (dst->DstRegister.Indirect) {
+      if (dst->Register.Indirect) {
          _dump_register_ind(
             ctx,
-            dst->DstRegister.File,
-            dst->DstRegister.Index,
-            dst->DstRegisterInd.File,
-            dst->DstRegisterInd.Index,
-            dst->DstRegisterInd.SwizzleX );
+            dst->Register.File,
+            dst->Register.Index,
+            dst->Indirect.File,
+            dst->Indirect.Index,
+            dst->Indirect.SwizzleX );
       }
       else {
-         _dump_register(
+         _dump_register_dst(
             ctx,
-            dst->DstRegister.File,
-            dst->DstRegister.Index,
-            dst->DstRegister.Index );
+            dst->Register.File,
+            dst->Register.Index );
       }
-      ENM( dst->DstRegisterExtModulate.Modulate, modulate_names );
-      _dump_writemask( ctx, dst->DstRegister.WriteMask );
+      _dump_writemask( ctx, dst->Register.WriteMask );
 
       first_reg = FALSE;
    }
 
    for (i = 0; i < inst->Instruction.NumSrcRegs; i++) {
-      const struct tgsi_full_src_register *src = &inst->FullSrcRegisters[i];
+      const struct tgsi_full_src_register *src = &inst->Src[i];
 
       if (!first_reg)
          CHR( ',' );
       CHR( ' ' );
 
-      if (src->SrcRegisterExtMod.Negate)
-         TXT( "-(" );
-      if (src->SrcRegisterExtMod.Absolute)
-         CHR( '|' );
-      if (src->SrcRegisterExtMod.Scale2X)
-         TXT( "2*(" );
-      if (src->SrcRegisterExtMod.Bias)
-         CHR( '(' );
-      if (src->SrcRegisterExtMod.Complement)
-         TXT( "1-(" );
-      if (src->SrcRegister.Negate)
+      if (src->Register.Negate)
          CHR( '-' );
+      if (src->Register.Absolute)
+         CHR( '|' );
 
-      if (src->SrcRegister.Indirect) {
-         _dump_register_ind(
-            ctx,
-            src->SrcRegister.File,
-            src->SrcRegister.Index,
-            src->SrcRegisterInd.File,
-            src->SrcRegisterInd.Index,
-            src->SrcRegisterInd.SwizzleX );
-      }
-      else {
-         _dump_register(
-            ctx,
-            src->SrcRegister.File,
-            src->SrcRegister.Index,
-            src->SrcRegister.Index );
-      }
+      _dump_register_src(ctx, src);
 
-      if (src->SrcRegister.SwizzleX != TGSI_SWIZZLE_X ||
-          src->SrcRegister.SwizzleY != TGSI_SWIZZLE_Y ||
-          src->SrcRegister.SwizzleZ != TGSI_SWIZZLE_Z ||
-          src->SrcRegister.SwizzleW != TGSI_SWIZZLE_W) {
-         CHR( '.' );
-         ENM( src->SrcRegister.SwizzleX, swizzle_names );
-         ENM( src->SrcRegister.SwizzleY, swizzle_names );
-         ENM( src->SrcRegister.SwizzleZ, swizzle_names );
-         ENM( src->SrcRegister.SwizzleW, swizzle_names );
-      }
-      if (src->SrcRegisterExtSwz.ExtSwizzleX != TGSI_EXTSWIZZLE_X ||
-          src->SrcRegisterExtSwz.ExtSwizzleY != TGSI_EXTSWIZZLE_Y ||
-          src->SrcRegisterExtSwz.ExtSwizzleZ != TGSI_EXTSWIZZLE_Z ||
-          src->SrcRegisterExtSwz.ExtSwizzleW != TGSI_EXTSWIZZLE_W) {
+      if (src->Register.SwizzleX != TGSI_SWIZZLE_X ||
+          src->Register.SwizzleY != TGSI_SWIZZLE_Y ||
+          src->Register.SwizzleZ != TGSI_SWIZZLE_Z ||
+          src->Register.SwizzleW != TGSI_SWIZZLE_W) {
          CHR( '.' );
-         if (src->SrcRegisterExtSwz.NegateX)
-            TXT("-");
-         ENM( src->SrcRegisterExtSwz.ExtSwizzleX, extswizzle_names );
-         if (src->SrcRegisterExtSwz.NegateY)
-            TXT("-");
-         ENM( src->SrcRegisterExtSwz.ExtSwizzleY, extswizzle_names );
-         if (src->SrcRegisterExtSwz.NegateZ)
-            TXT("-");
-         ENM( src->SrcRegisterExtSwz.ExtSwizzleZ, extswizzle_names );
-         if (src->SrcRegisterExtSwz.NegateW)
-            TXT("-");
-         ENM( src->SrcRegisterExtSwz.ExtSwizzleW, extswizzle_names );
+         ENM( src->Register.SwizzleX, swizzle_names );
+         ENM( src->Register.SwizzleY, swizzle_names );
+         ENM( src->Register.SwizzleZ, swizzle_names );
+         ENM( src->Register.SwizzleW, swizzle_names );
       }
 
-      if (src->SrcRegisterExtMod.Complement)
-         CHR( ')' );
-      if (src->SrcRegisterExtMod.Bias)
-         TXT( ")-.5" );
-      if (src->SrcRegisterExtMod.Scale2X)
-         CHR( ')' );
-      if (src->SrcRegisterExtMod.Absolute)
+      if (src->Register.Absolute)
          CHR( '|' );
-      if (src->SrcRegisterExtMod.Negate)
-         CHR( ')' );
 
       first_reg = FALSE;
    }
 
-   if (inst->InstructionExtTexture.Texture != TGSI_TEXTURE_UNKNOWN) {
+   if (inst->Instruction.Texture) {
       TXT( ", " );
-      ENM( inst->InstructionExtTexture.Texture, texture_names );
+      ENM( inst->Texture.Texture, texture_names );
    }
 
    switch (inst->Instruction.Opcode) {
@@ -491,7 +549,7 @@ iter_instruction(
    case TGSI_OPCODE_ENDLOOP:
    case TGSI_OPCODE_CAL:
       TXT( " :" );
-      UID( inst->InstructionExtLabel.Label );
+      UID( inst->Label.Label );
       break;
    }
 
@@ -529,9 +587,6 @@ prolog(
 {
    struct dump_ctx *ctx = (struct dump_ctx *) iter;
    ENM( iter->processor.Processor, processor_type_names );
-   UID( iter->version.MajorVersion );
-   CHR( '.' );
-   UID( iter->version.MinorVersion );
    EOL();
    return TRUE;
 }
@@ -547,6 +602,7 @@ tgsi_dump(
    ctx.iter.iterate_instruction = iter_instruction;
    ctx.iter.iterate_declaration = iter_declaration;
    ctx.iter.iterate_immediate = iter_immediate;
+   ctx.iter.iterate_property = iter_property;
    ctx.iter.epilog = NULL;
 
    ctx.instno = 0;
@@ -601,6 +657,7 @@ tgsi_dump_str(
    ctx.base.iter.iterate_instruction = iter_instruction;
    ctx.base.iter.iterate_declaration = iter_declaration;
    ctx.base.iter.iterate_immediate = iter_immediate;
+   ctx.base.iter.iterate_property = iter_property;
    ctx.base.iter.epilog = NULL;
 
    ctx.base.instno = 0;
index ad1e647ec9000b0b2956627e4393d3c38c082a5c..4cd27317b36792b5d60e53c8efca3ee5dc51b054 100644 (file)
@@ -49,6 +49,7 @@ tgsi_dump(
 struct tgsi_full_immediate;
 struct tgsi_full_instruction;
 struct tgsi_full_declaration;
+struct tgsi_full_property;
 
 void
 tgsi_dump_immediate(
@@ -63,6 +64,10 @@ void
 tgsi_dump_declaration(
    const struct tgsi_full_declaration *decl );
 
+void
+tgsi_dump_property(
+   const struct tgsi_full_property *prop );
+
 #if defined __cplusplus
 }
 #endif
index 4a9c02b1413c73c01076a55eb239262b42d6254b..47fd1dd590eb71b95f77756fdff480b60660ce21 100644 (file)
@@ -79,7 +79,8 @@ static const char *TGSI_FILES[TGSI_FILE_COUNT] =
    "FILE_SAMPLER",
    "FILE_ADDRESS",
    "FILE_IMMEDIATE",
-   "FILE_LOOP"
+   "FILE_LOOP",
+   "FILE_PREDICATE"
 };
 
 static const char *TGSI_INTERPOLATES[] =
@@ -112,34 +113,6 @@ static const char *TGSI_SATS[] =
    "SAT_MINUS_PLUS_ONE"
 };
 
-static const char *TGSI_INSTRUCTION_EXTS[] =
-{
-   "INSTRUCTION_EXT_TYPE_NV",
-   "INSTRUCTION_EXT_TYPE_LABEL",
-   "INSTRUCTION_EXT_TYPE_TEXTURE"
-};
-
-static const char *TGSI_PRECISIONS[] =
-{
-   "PRECISION_DEFAULT",
-   "PRECISION_FLOAT32",
-   "PRECISION_FLOAT16",
-   "PRECISION_FIXED12"
-};
-
-static const char *TGSI_CCS[] =
-{
-   "CC_GT",
-   "CC_EQ",
-   "CC_LT",
-   "CC_UN",
-   "CC_GE",
-   "CC_LE",
-   "CC_NE",
-   "CC_TR",
-   "CC_FL"
-};
-
 static const char *TGSI_SWIZZLES[] =
 {
    "SWIZZLE_X",
@@ -161,22 +134,6 @@ static const char *TGSI_TEXTURES[] =
    "TEXTURE_SHADOWRECT"
 };
 
-static const char *TGSI_SRC_REGISTER_EXTS[] =
-{
-   "SRC_REGISTER_EXT_TYPE_SWZ",
-   "SRC_REGISTER_EXT_TYPE_MOD"
-};
-
-static const char *TGSI_EXTSWIZZLES[] =
-{
-   "EXTSWIZZLE_X",
-   "EXTSWIZZLE_Y",
-   "EXTSWIZZLE_Z",
-   "EXTSWIZZLE_W",
-   "EXTSWIZZLE_ZERO",
-   "EXTSWIZZLE_ONE"
-};
-
 static const char *TGSI_WRITEMASKS[] =
 {
    "0",
@@ -197,23 +154,6 @@ static const char *TGSI_WRITEMASKS[] =
    "WRITEMASK_XYZW"
 };
 
-static const char *TGSI_DST_REGISTER_EXTS[] =
-{
-   "DST_REGISTER_EXT_TYPE_CONDCODE",
-   "DST_REGISTER_EXT_TYPE_MODULATE"
-};
-
-static const char *TGSI_MODULATES[] =
-{
-   "MODULATE_1X",
-   "MODULATE_2X",
-   "MODULATE_4X",
-   "MODULATE_8X",
-   "MODULATE_HALF",
-   "MODULATE_QUARTER",
-   "MODULATE_EIGHTH"
-};
-
 static void
 dump_declaration_verbose(
    struct tgsi_full_declaration  *decl,
@@ -246,6 +186,14 @@ dump_declaration_verbose(
       TXT( "\nSemantic   : " );
       UID( decl->Declaration.Semantic );
    }
+   if (deflt || fd->Declaration.Centroid != decl->Declaration.Centroid) {
+      TXT("\nCentroid   : ");
+      UID(decl->Declaration.Centroid);
+   }
+   if (deflt || fd->Declaration.Invariant != decl->Declaration.Invariant) {
+      TXT("\nInvariant  : ");
+      UID(decl->Declaration.Invariant);
+   }
    if( ignored ) {
       TXT( "\nPadding    : " );
       UIX( decl->Declaration.Padding );
@@ -253,16 +201,16 @@ dump_declaration_verbose(
 
    EOL();
    TXT( "\nFirst: " );
-   UID( decl->DeclarationRange.First );
+   UID( decl->Range.First );
    TXT( "\nLast : " );
-   UID( decl->DeclarationRange.Last );
+   UID( decl->Range.Last );
 
    if( decl->Declaration.Semantic ) {
       EOL();
-      TXT( "\nSemanticName : " );
-      ENM( decl->Semantic.SemanticName, TGSI_SEMANTICS );
-      TXT( "\nSemanticIndex: " );
-      UID( decl->Semantic.SemanticIndex );
+      TXT( "\nName : " );
+      ENM( decl->Semantic.Name, TGSI_SEMANTICS );
+      TXT( "\nIndex: " );
+      UID( decl->Semantic.Index );
       if( ignored ) {
          TXT( "\nPadding      : " );
          UIX( decl->Semantic.Padding );
@@ -322,318 +270,122 @@ dump_instruction_verbose(
       TXT( "\nNumSrcRegs : " );
       UID( inst->Instruction.NumSrcRegs );
    }
+   if (deflt || fi->Instruction.Predicate != inst->Instruction.Predicate) {
+      TXT("\nPredicate  : ");
+      UID(inst->Instruction.Predicate);
+   }
+   if (deflt || fi->Instruction.Label != inst->Instruction.Label) {
+      TXT("\nLabel      : ");
+      UID(inst->Instruction.Label);
+   }
+   if (deflt || fi->Instruction.Texture != inst->Instruction.Texture) {
+      TXT("\nTexture    : ");
+      UID(inst->Instruction.Texture);
+   }
    if( ignored ) {
       TXT( "\nPadding    : " );
       UIX( inst->Instruction.Padding );
    }
 
-   if( deflt || tgsi_compare_instruction_ext_nv( inst->InstructionExtNv, fi->InstructionExtNv ) ) {
-      EOL();
-      TXT( "\nType          : " );
-      ENM( inst->InstructionExtNv.Type, TGSI_INSTRUCTION_EXTS );
-      if( deflt || fi->InstructionExtNv.Precision != inst->InstructionExtNv.Precision ) {
-         TXT( "\nPrecision     : " );
-         ENM( inst->InstructionExtNv.Precision, TGSI_PRECISIONS );
-      }
-      if( deflt || fi->InstructionExtNv.CondDstIndex != inst->InstructionExtNv.CondDstIndex ) {
-         TXT( "\nCondDstIndex  : " );
-         UID( inst->InstructionExtNv.CondDstIndex );
-      }
-      if( deflt || fi->InstructionExtNv.CondFlowIndex != inst->InstructionExtNv.CondFlowIndex ) {
-         TXT( "\nCondFlowIndex : " );
-         UID( inst->InstructionExtNv.CondFlowIndex );
-      }
-      if( deflt || fi->InstructionExtNv.CondMask != inst->InstructionExtNv.CondMask ) {
-         TXT( "\nCondMask      : " );
-         ENM( inst->InstructionExtNv.CondMask, TGSI_CCS );
-      }
-      if( deflt || fi->InstructionExtNv.CondSwizzleX != inst->InstructionExtNv.CondSwizzleX ) {
-         TXT( "\nCondSwizzleX  : " );
-         ENM( inst->InstructionExtNv.CondSwizzleX, TGSI_SWIZZLES );
-      }
-      if( deflt || fi->InstructionExtNv.CondSwizzleY != inst->InstructionExtNv.CondSwizzleY ) {
-         TXT( "\nCondSwizzleY  : " );
-         ENM( inst->InstructionExtNv.CondSwizzleY, TGSI_SWIZZLES );
-      }
-      if( deflt || fi->InstructionExtNv.CondSwizzleZ != inst->InstructionExtNv.CondSwizzleZ ) {
-         TXT( "\nCondSwizzleZ  : " );
-         ENM( inst->InstructionExtNv.CondSwizzleZ, TGSI_SWIZZLES );
-      }
-      if( deflt || fi->InstructionExtNv.CondSwizzleW != inst->InstructionExtNv.CondSwizzleW ) {
-         TXT( "\nCondSwizzleW  : " );
-         ENM( inst->InstructionExtNv.CondSwizzleW, TGSI_SWIZZLES );
-      }
-      if( deflt || fi->InstructionExtNv.CondDstUpdate != inst->InstructionExtNv.CondDstUpdate ) {
-         TXT( "\nCondDstUpdate : " );
-         UID( inst->InstructionExtNv.CondDstUpdate );
-      }
-      if( deflt || fi->InstructionExtNv.CondFlowEnable != inst->InstructionExtNv.CondFlowEnable ) {
-         TXT( "\nCondFlowEnable: " );
-         UID( inst->InstructionExtNv.CondFlowEnable );
-      }
-      if( ignored ) {
-         TXT( "\nPadding       : " );
-         UIX( inst->InstructionExtNv.Padding );
-         if( deflt || fi->InstructionExtNv.Extended != inst->InstructionExtNv.Extended ) {
-            TXT( "\nExtended      : " );
-            UID( inst->InstructionExtNv.Extended );
-         }
-      }
-   }
-
-   if( deflt || tgsi_compare_instruction_ext_label( inst->InstructionExtLabel, fi->InstructionExtLabel ) ) {
+   if (deflt || inst->Instruction.Label) {
       EOL();
-      TXT( "\nType    : " );
-      ENM( inst->InstructionExtLabel.Type, TGSI_INSTRUCTION_EXTS );
-      if( deflt || fi->InstructionExtLabel.Label != inst->InstructionExtLabel.Label ) {
+      if (deflt || fi->Label.Label != inst->Label.Label) {
          TXT( "\nLabel   : " );
-         UID( inst->InstructionExtLabel.Label );
+         UID(inst->Label.Label);
       }
       if( ignored ) {
          TXT( "\nPadding : " );
-         UIX( inst->InstructionExtLabel.Padding );
-         if( deflt || fi->InstructionExtLabel.Extended != inst->InstructionExtLabel.Extended ) {
-            TXT( "\nExtended: " );
-            UID( inst->InstructionExtLabel.Extended );
-         }
+         UIX(inst->Label.Padding);
       }
    }
 
-   if( deflt || tgsi_compare_instruction_ext_texture( inst->InstructionExtTexture, fi->InstructionExtTexture ) ) {
+   if (deflt || inst->Instruction.Texture) {
       EOL();
-      TXT( "\nType    : " );
-      ENM( inst->InstructionExtTexture.Type, TGSI_INSTRUCTION_EXTS );
-      if( deflt || fi->InstructionExtTexture.Texture != inst->InstructionExtTexture.Texture ) {
+      if (deflt || fi->Texture.Texture != inst->Texture.Texture) {
          TXT( "\nTexture : " );
-         ENM( inst->InstructionExtTexture.Texture, TGSI_TEXTURES );
+         ENM(inst->Texture.Texture, TGSI_TEXTURES);
       }
       if( ignored ) {
          TXT( "\nPadding : " );
-         UIX( inst->InstructionExtTexture.Padding );
-         if( deflt || fi->InstructionExtTexture.Extended != inst->InstructionExtTexture.Extended ) {
-            TXT( "\nExtended: " );
-            UID( inst->InstructionExtTexture.Extended );
-         }
+         UIX(inst->Texture.Padding);
       }
    }
 
    for( i = 0; i < inst->Instruction.NumDstRegs; i++ ) {
-      struct tgsi_full_dst_register *dst = &inst->FullDstRegisters[i];
-      struct tgsi_full_dst_register *fd = &fi->FullDstRegisters[i];
+      struct tgsi_full_dst_register *dst = &inst->Dst[i];
+      struct tgsi_full_dst_register *fd = &fi->Dst[i];
 
       EOL();
       TXT( "\nFile     : " );
-      ENM( dst->DstRegister.File, TGSI_FILES );
-      if( deflt || fd->DstRegister.WriteMask != dst->DstRegister.WriteMask ) {
+      ENM( dst->Register.File, TGSI_FILES );
+      if( deflt || fd->Register.WriteMask != dst->Register.WriteMask ) {
          TXT( "\nWriteMask: " );
-         ENM( dst->DstRegister.WriteMask, TGSI_WRITEMASKS );
+         ENM( dst->Register.WriteMask, TGSI_WRITEMASKS );
       }
       if( ignored ) {
-         if( deflt || fd->DstRegister.Indirect != dst->DstRegister.Indirect ) {
+         if( deflt || fd->Register.Indirect != dst->Register.Indirect ) {
             TXT( "\nIndirect : " );
-            UID( dst->DstRegister.Indirect );
+            UID( dst->Register.Indirect );
          }
-         if( deflt || fd->DstRegister.Dimension != dst->DstRegister.Dimension ) {
+         if( deflt || fd->Register.Dimension != dst->Register.Dimension ) {
             TXT( "\nDimension: " );
-            UID( dst->DstRegister.Dimension );
+            UID( dst->Register.Dimension );
          }
       }
-      if( deflt || fd->DstRegister.Index != dst->DstRegister.Index ) {
+      if( deflt || fd->Register.Index != dst->Register.Index ) {
          TXT( "\nIndex    : " );
-         SID( dst->DstRegister.Index );
+         SID( dst->Register.Index );
       }
       if( ignored ) {
          TXT( "\nPadding  : " );
-         UIX( dst->DstRegister.Padding );
-         if( deflt || fd->DstRegister.Extended != dst->DstRegister.Extended ) {
-            TXT( "\nExtended : " );
-            UID( dst->DstRegister.Extended );
-         }
-      }
-
-      if( deflt || tgsi_compare_dst_register_ext_concode( dst->DstRegisterExtConcode, fd->DstRegisterExtConcode ) ) {
-         EOL();
-         TXT( "\nType        : " );
-         ENM( dst->DstRegisterExtConcode.Type, TGSI_DST_REGISTER_EXTS );
-         if( deflt || fd->DstRegisterExtConcode.CondMask != dst->DstRegisterExtConcode.CondMask ) {
-            TXT( "\nCondMask    : " );
-            ENM( dst->DstRegisterExtConcode.CondMask, TGSI_CCS );
-         }
-         if( deflt || fd->DstRegisterExtConcode.CondSwizzleX != dst->DstRegisterExtConcode.CondSwizzleX ) {
-            TXT( "\nCondSwizzleX: " );
-            ENM( dst->DstRegisterExtConcode.CondSwizzleX, TGSI_SWIZZLES );
-         }
-         if( deflt || fd->DstRegisterExtConcode.CondSwizzleY != dst->DstRegisterExtConcode.CondSwizzleY ) {
-            TXT( "\nCondSwizzleY: " );
-            ENM( dst->DstRegisterExtConcode.CondSwizzleY, TGSI_SWIZZLES );
-         }
-         if( deflt || fd->DstRegisterExtConcode.CondSwizzleZ != dst->DstRegisterExtConcode.CondSwizzleZ ) {
-            TXT( "\nCondSwizzleZ: " );
-            ENM( dst->DstRegisterExtConcode.CondSwizzleZ, TGSI_SWIZZLES );
-         }
-         if( deflt || fd->DstRegisterExtConcode.CondSwizzleW != dst->DstRegisterExtConcode.CondSwizzleW ) {
-            TXT( "\nCondSwizzleW: " );
-            ENM( dst->DstRegisterExtConcode.CondSwizzleW, TGSI_SWIZZLES );
-         }
-         if( deflt || fd->DstRegisterExtConcode.CondSrcIndex != dst->DstRegisterExtConcode.CondSrcIndex ) {
-            TXT( "\nCondSrcIndex: " );
-            UID( dst->DstRegisterExtConcode.CondSrcIndex );
-         }
-         if( ignored ) {
-            TXT( "\nPadding     : " );
-            UIX( dst->DstRegisterExtConcode.Padding );
-            if( deflt || fd->DstRegisterExtConcode.Extended != dst->DstRegisterExtConcode.Extended ) {
-               TXT( "\nExtended    : " );
-               UID( dst->DstRegisterExtConcode.Extended );
-            }
-         }
-      }
-
-      if( deflt || tgsi_compare_dst_register_ext_modulate( dst->DstRegisterExtModulate, fd->DstRegisterExtModulate ) ) {
-         EOL();
-         TXT( "\nType    : " );
-         ENM( dst->DstRegisterExtModulate.Type, TGSI_DST_REGISTER_EXTS );
-         if( deflt || fd->DstRegisterExtModulate.Modulate != dst->DstRegisterExtModulate.Modulate ) {
-            TXT( "\nModulate: " );
-            ENM( dst->DstRegisterExtModulate.Modulate, TGSI_MODULATES );
-         }
-         if( ignored ) {
-            TXT( "\nPadding : " );
-            UIX( dst->DstRegisterExtModulate.Padding );
-            if( deflt || fd->DstRegisterExtModulate.Extended != dst->DstRegisterExtModulate.Extended ) {
-               TXT( "\nExtended: " );
-               UID( dst->DstRegisterExtModulate.Extended );
-            }
-         }
+         UIX( dst->Register.Padding );
       }
    }
 
    for( i = 0; i < inst->Instruction.NumSrcRegs; i++ ) {
-      struct tgsi_full_src_register *src = &inst->FullSrcRegisters[i];
-      struct tgsi_full_src_register *fs = &fi->FullSrcRegisters[i];
+      struct tgsi_full_src_register *src = &inst->Src[i];
+      struct tgsi_full_src_register *fs = &fi->Src[i];
 
       EOL();
       TXT( "\nFile     : ");
-      ENM( src->SrcRegister.File, TGSI_FILES );
-      if( deflt || fs->SrcRegister.SwizzleX != src->SrcRegister.SwizzleX ) {
+      ENM( src->Register.File, TGSI_FILES );
+      if( deflt || fs->Register.SwizzleX != src->Register.SwizzleX ) {
          TXT( "\nSwizzleX : " );
-         ENM( src->SrcRegister.SwizzleX, TGSI_SWIZZLES );
+         ENM( src->Register.SwizzleX, TGSI_SWIZZLES );
       }
-      if( deflt || fs->SrcRegister.SwizzleY != src->SrcRegister.SwizzleY ) {
+      if( deflt || fs->Register.SwizzleY != src->Register.SwizzleY ) {
          TXT( "\nSwizzleY : " );
-         ENM( src->SrcRegister.SwizzleY, TGSI_SWIZZLES );
+         ENM( src->Register.SwizzleY, TGSI_SWIZZLES );
       }
-      if( deflt || fs->SrcRegister.SwizzleZ != src->SrcRegister.SwizzleZ ) {
+      if( deflt || fs->Register.SwizzleZ != src->Register.SwizzleZ ) {
          TXT( "\nSwizzleZ : " );
-         ENM( src->SrcRegister.SwizzleZ, TGSI_SWIZZLES );
+         ENM( src->Register.SwizzleZ, TGSI_SWIZZLES );
       }
-      if( deflt || fs->SrcRegister.SwizzleW != src->SrcRegister.SwizzleW ) {
+      if( deflt || fs->Register.SwizzleW != src->Register.SwizzleW ) {
          TXT( "\nSwizzleW : " );
-         ENM( src->SrcRegister.SwizzleW, TGSI_SWIZZLES );
+         ENM( src->Register.SwizzleW, TGSI_SWIZZLES );
       }
-      if( deflt || fs->SrcRegister.Negate != src->SrcRegister.Negate ) {
+      if (deflt || fs->Register.Absolute != src->Register.Absolute) {
+         TXT("\nAbsolute : ");
+         UID(src->Register.Absolute);
+      }
+      if( deflt || fs->Register.Negate != src->Register.Negate ) {
          TXT( "\nNegate   : " );
-         UID( src->SrcRegister.Negate );
+         UID( src->Register.Negate );
       }
       if( ignored ) {
-         if( deflt || fs->SrcRegister.Indirect != src->SrcRegister.Indirect ) {
+         if( deflt || fs->Register.Indirect != src->Register.Indirect ) {
             TXT( "\nIndirect : " );
-            UID( src->SrcRegister.Indirect );
+            UID( src->Register.Indirect );
          }
-         if( deflt || fs->SrcRegister.Dimension != src->SrcRegister.Dimension ) {
+         if( deflt || fs->Register.Dimension != src->Register.Dimension ) {
             TXT( "\nDimension: " );
-            UID( src->SrcRegister.Dimension );
+            UID( src->Register.Dimension );
          }
       }
-      if( deflt || fs->SrcRegister.Index != src->SrcRegister.Index ) {
+      if( deflt || fs->Register.Index != src->Register.Index ) {
          TXT( "\nIndex    : " );
-         SID( src->SrcRegister.Index );
-      }
-      if( ignored ) {
-         if( deflt || fs->SrcRegister.Extended != src->SrcRegister.Extended ) {
-            TXT( "\nExtended : " );
-            UID( src->SrcRegister.Extended );
-         }
-      }
-
-      if( deflt || tgsi_compare_src_register_ext_swz( src->SrcRegisterExtSwz, fs->SrcRegisterExtSwz ) ) {
-         EOL();
-         TXT( "\nType       : " );
-         ENM( src->SrcRegisterExtSwz.Type, TGSI_SRC_REGISTER_EXTS );
-         if( deflt || fs->SrcRegisterExtSwz.ExtSwizzleX != src->SrcRegisterExtSwz.ExtSwizzleX ) {
-            TXT( "\nExtSwizzleX: " );
-            ENM( src->SrcRegisterExtSwz.ExtSwizzleX, TGSI_EXTSWIZZLES );
-         }
-         if( deflt || fs->SrcRegisterExtSwz.ExtSwizzleY != src->SrcRegisterExtSwz.ExtSwizzleY ) {
-            TXT( "\nExtSwizzleY: " );
-            ENM( src->SrcRegisterExtSwz.ExtSwizzleY, TGSI_EXTSWIZZLES );
-         }
-         if( deflt || fs->SrcRegisterExtSwz.ExtSwizzleZ != src->SrcRegisterExtSwz.ExtSwizzleZ ) {
-            TXT( "\nExtSwizzleZ: " );
-            ENM( src->SrcRegisterExtSwz.ExtSwizzleZ, TGSI_EXTSWIZZLES );
-         }
-         if( deflt || fs->SrcRegisterExtSwz.ExtSwizzleW != src->SrcRegisterExtSwz.ExtSwizzleW ) {
-            TXT( "\nExtSwizzleW: " );
-            ENM( src->SrcRegisterExtSwz.ExtSwizzleW, TGSI_EXTSWIZZLES );
-         }
-         if( deflt || fs->SrcRegisterExtSwz.NegateX != src->SrcRegisterExtSwz.NegateX ) {
-            TXT( "\nNegateX   : " );
-            UID( src->SrcRegisterExtSwz.NegateX );
-         }
-         if( deflt || fs->SrcRegisterExtSwz.NegateY != src->SrcRegisterExtSwz.NegateY ) {
-            TXT( "\nNegateY   : " );
-            UID( src->SrcRegisterExtSwz.NegateY );
-         }
-         if( deflt || fs->SrcRegisterExtSwz.NegateZ != src->SrcRegisterExtSwz.NegateZ ) {
-            TXT( "\nNegateZ   : " );
-            UID( src->SrcRegisterExtSwz.NegateZ );
-         }
-         if( deflt || fs->SrcRegisterExtSwz.NegateW != src->SrcRegisterExtSwz.NegateW ) {
-            TXT( "\nNegateW   : " );
-            UID( src->SrcRegisterExtSwz.NegateW );
-         }
-         if( ignored ) {
-            TXT( "\nPadding   : " );
-            UIX( src->SrcRegisterExtSwz.Padding );
-            if( deflt || fs->SrcRegisterExtSwz.Extended != src->SrcRegisterExtSwz.Extended ) {
-               TXT( "\nExtended   : " );
-               UID( src->SrcRegisterExtSwz.Extended );
-            }
-         }
-      }
-
-      if( deflt || tgsi_compare_src_register_ext_mod( src->SrcRegisterExtMod, fs->SrcRegisterExtMod ) ) {
-         EOL();
-         TXT( "\nType     : " );
-         ENM( src->SrcRegisterExtMod.Type, TGSI_SRC_REGISTER_EXTS );
-         if( deflt || fs->SrcRegisterExtMod.Complement != src->SrcRegisterExtMod.Complement ) {
-            TXT( "\nComplement: " );
-            UID( src->SrcRegisterExtMod.Complement );
-         }
-         if( deflt || fs->SrcRegisterExtMod.Bias != src->SrcRegisterExtMod.Bias ) {
-            TXT( "\nBias     : " );
-            UID( src->SrcRegisterExtMod.Bias );
-         }
-         if( deflt || fs->SrcRegisterExtMod.Scale2X != src->SrcRegisterExtMod.Scale2X ) {
-            TXT( "\nScale2X   : " );
-            UID( src->SrcRegisterExtMod.Scale2X );
-         }
-         if( deflt || fs->SrcRegisterExtMod.Absolute != src->SrcRegisterExtMod.Absolute ) {
-            TXT( "\nAbsolute  : " );
-            UID( src->SrcRegisterExtMod.Absolute );
-         }
-         if( deflt || fs->SrcRegisterExtMod.Negate != src->SrcRegisterExtMod.Negate ) {
-            TXT( "\nNegate   : " );
-            UID( src->SrcRegisterExtMod.Negate );
-         }
-         if( ignored ) {
-            TXT( "\nPadding   : " );
-            UIX( src->SrcRegisterExtMod.Padding );
-            if( deflt || fs->SrcRegisterExtMod.Extended != src->SrcRegisterExtMod.Extended ) {
-               TXT( "\nExtended  : " );
-               UID( src->SrcRegisterExtMod.Extended );
-            }
-         }
+         SID( src->Register.Index );
       }
    }
 }
@@ -653,12 +405,6 @@ tgsi_dump_c(
 
    TXT( "tgsi-dump begin -----------------" );
 
-   TXT( "\nMajorVersion: " );
-   UID( parse.FullVersion.Version.MajorVersion );
-   TXT( "\nMinorVersion: " );
-   UID( parse.FullVersion.Version.MinorVersion );
-   EOL();
-
    TXT( "\nHeaderSize: " );
    UID( parse.FullHeader.Header.HeaderSize );
    TXT( "\nBodySize  : " );
@@ -678,10 +424,6 @@ tgsi_dump_c(
       if( ignored ) {
          TXT( "\nSize       : " );
          UID( parse.FullToken.Token.NrTokens );
-         if( deflt || parse.FullToken.Token.Extended ) {
-            TXT( "\nExtended   : " );
-            UID( parse.FullToken.Token.Extended );
-         }
       }
 
       switch( parse.FullToken.Token.Type ) {
index c79c56debd6064b3943c6955974172f30643a065..2bcb33392a8cec174029c44b9b5474e7b739e54d 100644 (file)
@@ -2,6 +2,7 @@
  * 
  * Copyright 2007-2008 Tungsten Graphics, Inc., Cedar Park, Texas.
  * All Rights Reserved.
+ * Copyright 2009-2010 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
 #include "util/u_memory.h"
 #include "util/u_math.h"
 
-#define FAST_MATH 1
 
-/** for tgsi_full_instruction::Flags */
-#define SOA_DEPENDENCY_FLAG 0x1
+#define FAST_MATH 1
 
 #define TILE_TOP_LEFT     0
 #define TILE_TOP_RIGHT    1
 #define TILE_BOTTOM_LEFT  2
 #define TILE_BOTTOM_RIGHT 3
 
+static void
+micro_abs(union tgsi_exec_channel *dst,
+          const union tgsi_exec_channel *src)
+{
+   dst->f[0] = fabsf(src->f[0]);
+   dst->f[1] = fabsf(src->f[1]);
+   dst->f[2] = fabsf(src->f[2]);
+   dst->f[3] = fabsf(src->f[3]);
+}
+
+static void
+micro_arl(union tgsi_exec_channel *dst,
+          const union tgsi_exec_channel *src)
+{
+   dst->i[0] = (int)floorf(src->f[0]);
+   dst->i[1] = (int)floorf(src->f[1]);
+   dst->i[2] = (int)floorf(src->f[2]);
+   dst->i[3] = (int)floorf(src->f[3]);
+}
+
+static void
+micro_arr(union tgsi_exec_channel *dst,
+          const union tgsi_exec_channel *src)
+{
+   dst->i[0] = (int)floorf(src->f[0] + 0.5f);
+   dst->i[1] = (int)floorf(src->f[1] + 0.5f);
+   dst->i[2] = (int)floorf(src->f[2] + 0.5f);
+   dst->i[3] = (int)floorf(src->f[3] + 0.5f);
+}
+
+static void
+micro_ceil(union tgsi_exec_channel *dst,
+           const union tgsi_exec_channel *src)
+{
+   dst->f[0] = ceilf(src->f[0]);
+   dst->f[1] = ceilf(src->f[1]);
+   dst->f[2] = ceilf(src->f[2]);
+   dst->f[3] = ceilf(src->f[3]);
+}
+
+static void
+micro_cos(union tgsi_exec_channel *dst,
+          const union tgsi_exec_channel *src)
+{
+   dst->f[0] = cosf(src->f[0]);
+   dst->f[1] = cosf(src->f[1]);
+   dst->f[2] = cosf(src->f[2]);
+   dst->f[3] = cosf(src->f[3]);
+}
+
+static void
+micro_ddx(union tgsi_exec_channel *dst,
+          const union tgsi_exec_channel *src)
+{
+   dst->f[0] =
+   dst->f[1] =
+   dst->f[2] =
+   dst->f[3] = src->f[TILE_BOTTOM_RIGHT] - src->f[TILE_BOTTOM_LEFT];
+}
+
+static void
+micro_ddy(union tgsi_exec_channel *dst,
+          const union tgsi_exec_channel *src)
+{
+   dst->f[0] =
+   dst->f[1] =
+   dst->f[2] =
+   dst->f[3] = src->f[TILE_BOTTOM_LEFT] - src->f[TILE_TOP_LEFT];
+}
+
+static void
+micro_exp2(union tgsi_exec_channel *dst,
+           const union tgsi_exec_channel *src)
+{
+#if FAST_MATH
+   dst->f[0] = util_fast_exp2(src->f[0]);
+   dst->f[1] = util_fast_exp2(src->f[1]);
+   dst->f[2] = util_fast_exp2(src->f[2]);
+   dst->f[3] = util_fast_exp2(src->f[3]);
+#else
+#if DEBUG
+   /* Inf is okay for this instruction, so clamp it to silence assertions. */
+   uint i;
+   union tgsi_exec_channel clamped;
+
+   for (i = 0; i < 4; i++) {
+      if (src->f[i] > 127.99999f) {
+         clamped.f[i] = 127.99999f;
+      } else if (src->f[i] < -126.99999f) {
+         clamped.f[i] = -126.99999f;
+      } else {
+         clamped.f[i] = src->f[i];
+      }
+   }
+   src = &clamped;
+#endif /* DEBUG */
+
+   dst->f[0] = powf(2.0f, src->f[0]);
+   dst->f[1] = powf(2.0f, src->f[1]);
+   dst->f[2] = powf(2.0f, src->f[2]);
+   dst->f[3] = powf(2.0f, src->f[3]);
+#endif /* FAST_MATH */
+}
+
+static void
+micro_flr(union tgsi_exec_channel *dst,
+          const union tgsi_exec_channel *src)
+{
+   dst->f[0] = floorf(src->f[0]);
+   dst->f[1] = floorf(src->f[1]);
+   dst->f[2] = floorf(src->f[2]);
+   dst->f[3] = floorf(src->f[3]);
+}
+
+static void
+micro_frc(union tgsi_exec_channel *dst,
+          const union tgsi_exec_channel *src)
+{
+   dst->f[0] = src->f[0] - floorf(src->f[0]);
+   dst->f[1] = src->f[1] - floorf(src->f[1]);
+   dst->f[2] = src->f[2] - floorf(src->f[2]);
+   dst->f[3] = src->f[3] - floorf(src->f[3]);
+}
+
+static void
+micro_iabs(union tgsi_exec_channel *dst,
+           const union tgsi_exec_channel *src)
+{
+   dst->i[0] = src->i[0] >= 0 ? src->i[0] : -src->i[0];
+   dst->i[1] = src->i[1] >= 0 ? src->i[1] : -src->i[1];
+   dst->i[2] = src->i[2] >= 0 ? src->i[2] : -src->i[2];
+   dst->i[3] = src->i[3] >= 0 ? src->i[3] : -src->i[3];
+}
+
+static void
+micro_ineg(union tgsi_exec_channel *dst,
+           const union tgsi_exec_channel *src)
+{
+   dst->i[0] = -src->i[0];
+   dst->i[1] = -src->i[1];
+   dst->i[2] = -src->i[2];
+   dst->i[3] = -src->i[3];
+}
+
+static void
+micro_lg2(union tgsi_exec_channel *dst,
+          const union tgsi_exec_channel *src)
+{
+#if FAST_MATH
+   dst->f[0] = util_fast_log2(src->f[0]);
+   dst->f[1] = util_fast_log2(src->f[1]);
+   dst->f[2] = util_fast_log2(src->f[2]);
+   dst->f[3] = util_fast_log2(src->f[3]);
+#else
+   dst->f[0] = logf(src->f[0]) * 1.442695f;
+   dst->f[1] = logf(src->f[1]) * 1.442695f;
+   dst->f[2] = logf(src->f[2]) * 1.442695f;
+   dst->f[3] = logf(src->f[3]) * 1.442695f;
+#endif
+}
+
+static void
+micro_lrp(union tgsi_exec_channel *dst,
+          const union tgsi_exec_channel *src)
+{
+   dst->f[0] = src[0].f[0] * (src[1].f[0] - src[2].f[0]) + src[2].f[0];
+   dst->f[1] = src[0].f[1] * (src[1].f[1] - src[2].f[1]) + src[2].f[1];
+   dst->f[2] = src[0].f[2] * (src[1].f[2] - src[2].f[2]) + src[2].f[2];
+   dst->f[3] = src[0].f[3] * (src[1].f[3] - src[2].f[3]) + src[2].f[3];
+}
+
+static void
+micro_mad(union tgsi_exec_channel *dst,
+          const union tgsi_exec_channel *src)
+{
+   dst->f[0] = src[0].f[0] * src[1].f[0] + src[2].f[0];
+   dst->f[1] = src[0].f[1] * src[1].f[1] + src[2].f[1];
+   dst->f[2] = src[0].f[2] * src[1].f[2] + src[2].f[2];
+   dst->f[3] = src[0].f[3] * src[1].f[3] + src[2].f[3];
+}
+
+static void
+micro_mov(union tgsi_exec_channel *dst,
+          const union tgsi_exec_channel *src)
+{
+   dst->u[0] = src->u[0];
+   dst->u[1] = src->u[1];
+   dst->u[2] = src->u[2];
+   dst->u[3] = src->u[3];
+}
+
+static void
+micro_rcp(union tgsi_exec_channel *dst,
+          const union tgsi_exec_channel *src)
+{
+   dst->f[0] = 1.0f / src->f[0];
+   dst->f[1] = 1.0f / src->f[1];
+   dst->f[2] = 1.0f / src->f[2];
+   dst->f[3] = 1.0f / src->f[3];
+}
+
+static void
+micro_rnd(union tgsi_exec_channel *dst,
+          const union tgsi_exec_channel *src)
+{
+   dst->f[0] = floorf(src->f[0] + 0.5f);
+   dst->f[1] = floorf(src->f[1] + 0.5f);
+   dst->f[2] = floorf(src->f[2] + 0.5f);
+   dst->f[3] = floorf(src->f[3] + 0.5f);
+}
+
+static void
+micro_rsq(union tgsi_exec_channel *dst,
+          const union tgsi_exec_channel *src)
+{
+   dst->f[0] = 1.0f / sqrtf(fabsf(src->f[0]));
+   dst->f[1] = 1.0f / sqrtf(fabsf(src->f[1]));
+   dst->f[2] = 1.0f / sqrtf(fabsf(src->f[2]));
+   dst->f[3] = 1.0f / sqrtf(fabsf(src->f[3]));
+}
+
+static void
+micro_seq(union tgsi_exec_channel *dst,
+          const union tgsi_exec_channel *src)
+{
+   dst->f[0] = src[0].f[0] == src[1].f[0] ? 1.0f : 0.0f;
+   dst->f[1] = src[0].f[1] == src[1].f[1] ? 1.0f : 0.0f;
+   dst->f[2] = src[0].f[2] == src[1].f[2] ? 1.0f : 0.0f;
+   dst->f[3] = src[0].f[3] == src[1].f[3] ? 1.0f : 0.0f;
+}
+
+static void
+micro_sge(union tgsi_exec_channel *dst,
+          const union tgsi_exec_channel *src)
+{
+   dst->f[0] = src[0].f[0] >= src[1].f[0] ? 1.0f : 0.0f;
+   dst->f[1] = src[0].f[1] >= src[1].f[1] ? 1.0f : 0.0f;
+   dst->f[2] = src[0].f[2] >= src[1].f[2] ? 1.0f : 0.0f;
+   dst->f[3] = src[0].f[3] >= src[1].f[3] ? 1.0f : 0.0f;
+}
+
+static void
+micro_sgn(union tgsi_exec_channel *dst,
+          const union tgsi_exec_channel *src)
+{
+   dst->f[0] = src->f[0] < 0.0f ? -1.0f : src->f[0] > 0.0f ? 1.0f : 0.0f;
+   dst->f[1] = src->f[1] < 0.0f ? -1.0f : src->f[1] > 0.0f ? 1.0f : 0.0f;
+   dst->f[2] = src->f[2] < 0.0f ? -1.0f : src->f[2] > 0.0f ? 1.0f : 0.0f;
+   dst->f[3] = src->f[3] < 0.0f ? -1.0f : src->f[3] > 0.0f ? 1.0f : 0.0f;
+}
+
+static void
+micro_sgt(union tgsi_exec_channel *dst,
+          const union tgsi_exec_channel *src)
+{
+   dst->f[0] = src[0].f[0] > src[1].f[0] ? 1.0f : 0.0f;
+   dst->f[1] = src[0].f[1] > src[1].f[1] ? 1.0f : 0.0f;
+   dst->f[2] = src[0].f[2] > src[1].f[2] ? 1.0f : 0.0f;
+   dst->f[3] = src[0].f[3] > src[1].f[3] ? 1.0f : 0.0f;
+}
+
+static void
+micro_sin(union tgsi_exec_channel *dst,
+          const union tgsi_exec_channel *src)
+{
+   dst->f[0] = sinf(src->f[0]);
+   dst->f[1] = sinf(src->f[1]);
+   dst->f[2] = sinf(src->f[2]);
+   dst->f[3] = sinf(src->f[3]);
+}
+
+static void
+micro_sle(union tgsi_exec_channel *dst,
+          const union tgsi_exec_channel *src)
+{
+   dst->f[0] = src[0].f[0] <= src[1].f[0] ? 1.0f : 0.0f;
+   dst->f[1] = src[0].f[1] <= src[1].f[1] ? 1.0f : 0.0f;
+   dst->f[2] = src[0].f[2] <= src[1].f[2] ? 1.0f : 0.0f;
+   dst->f[3] = src[0].f[3] <= src[1].f[3] ? 1.0f : 0.0f;
+}
+
+static void
+micro_slt(union tgsi_exec_channel *dst,
+          const union tgsi_exec_channel *src)
+{
+   dst->f[0] = src[0].f[0] < src[1].f[0] ? 1.0f : 0.0f;
+   dst->f[1] = src[0].f[1] < src[1].f[1] ? 1.0f : 0.0f;
+   dst->f[2] = src[0].f[2] < src[1].f[2] ? 1.0f : 0.0f;
+   dst->f[3] = src[0].f[3] < src[1].f[3] ? 1.0f : 0.0f;
+}
+
+static void
+micro_sne(union tgsi_exec_channel *dst,
+          const union tgsi_exec_channel *src)
+{
+   dst->f[0] = src[0].f[0] != src[1].f[0] ? 1.0f : 0.0f;
+   dst->f[1] = src[0].f[1] != src[1].f[1] ? 1.0f : 0.0f;
+   dst->f[2] = src[0].f[2] != src[1].f[2] ? 1.0f : 0.0f;
+   dst->f[3] = src[0].f[3] != src[1].f[3] ? 1.0f : 0.0f;
+}
+
+static void
+micro_trunc(union tgsi_exec_channel *dst,
+            const union tgsi_exec_channel *src)
+{
+   dst->f[0] = (float)(int)src->f[0];
+   dst->f[1] = (float)(int)src->f[1];
+   dst->f[2] = (float)(int)src->f[2];
+   dst->f[3] = (float)(int)src->f[3];
+}
+
+
 #define CHAN_X  0
 #define CHAN_Y  1
 #define CHAN_Z  2
 #define CHAN_W  3
 
+enum tgsi_exec_datatype {
+   TGSI_EXEC_DATA_FLOAT,
+   TGSI_EXEC_DATA_INT,
+   TGSI_EXEC_DATA_UINT
+};
+
 /*
  * Shorthand locations of various utility registers (_I = Index, _C = Channel)
  */
 #define TEMP_HALF_I        TGSI_EXEC_TEMP_HALF_I
 #define TEMP_HALF_C        TGSI_EXEC_TEMP_HALF_C
 #define TEMP_R0            TGSI_EXEC_TEMP_R0
+#define TEMP_P0            TGSI_EXEC_TEMP_P0
 
 #define IS_CHANNEL_ENABLED(INST, CHAN)\
-   ((INST).FullDstRegisters[0].DstRegister.WriteMask & (1 << (CHAN)))
+   ((INST).Dst[0].Register.WriteMask & (1 << (CHAN)))
 
 #define IS_CHANNEL_ENABLED2(INST, CHAN)\
-   ((INST).FullDstRegisters[1].DstRegister.WriteMask & (1 << (CHAN)))
+   ((INST).Dst[1].Register.WriteMask & (1 << (CHAN)))
 
 #define FOR_EACH_ENABLED_CHANNEL(INST, CHAN)\
    for (CHAN = 0; CHAN < NUM_CHANNELS; CHAN++)\
 
 /** The execution mask depends on the conditional mask and the loop mask */
 #define UPDATE_EXEC_MASK(MACH) \
-      MACH->ExecMask = MACH->CondMask & MACH->LoopMask & MACH->ContMask & MACH->FuncMask
+      MACH->ExecMask = MACH->CondMask & MACH->LoopMask & MACH->ContMask & MACH->Switch.mask & MACH->FuncMask
 
 
 static const union tgsi_exec_channel ZeroVec =
    { { 0.0, 0.0, 0.0, 0.0 } };
 
 
-#ifdef DEBUG
-static void
-check_inf_or_nan(const union tgsi_exec_channel *chan)
-{
-   assert(!util_is_inf_or_nan(chan->f[0]));
-   assert(!util_is_inf_or_nan(chan->f[1]));
-   assert(!util_is_inf_or_nan(chan->f[2]));
-   assert(!util_is_inf_or_nan(chan->f[3]));
-}
-#endif
+#define CHECK_INF_OR_NAN(chan) do {\
+      assert(!util_is_inf_or_nan((chan)->f[0]));\
+      assert(!util_is_inf_or_nan((chan)->f[1]));\
+      assert(!util_is_inf_or_nan((chan)->f[2]));\
+      assert(!util_is_inf_or_nan((chan)->f[3]));\
+   } while (0)
 
 
 #ifdef DEBUG
@@ -190,7 +504,7 @@ tgsi_check_soa_dependencies(const struct tgsi_full_instruction *inst)
 {
    uint i, chan;
 
-   uint writemask = inst->FullDstRegisters[0].DstRegister.WriteMask;
+   uint writemask = inst->Dst[0].Register.WriteMask;
    if (writemask == TGSI_WRITEMASK_X ||
        writemask == TGSI_WRITEMASK_Y ||
        writemask == TGSI_WRITEMASK_Z ||
@@ -202,17 +516,16 @@ tgsi_check_soa_dependencies(const struct tgsi_full_instruction *inst)
 
    /* loop over src regs */
    for (i = 0; i < inst->Instruction.NumSrcRegs; i++) {
-      if ((inst->FullSrcRegisters[i].SrcRegister.File ==
-           inst->FullDstRegisters[0].DstRegister.File) &&
-          (inst->FullSrcRegisters[i].SrcRegister.Index ==
-           inst->FullDstRegisters[0].DstRegister.Index)) {
+      if ((inst->Src[i].Register.File ==
+           inst->Dst[0].Register.File) &&
+          (inst->Src[i].Register.Index ==
+           inst->Dst[0].Register.Index)) {
          /* loop over dest channels */
          uint channelsWritten = 0x0;
          FOR_EACH_ENABLED_CHANNEL(*inst, chan) {
             /* check if we're reading a channel that's been written */
-            uint swizzle = tgsi_util_get_full_src_register_extswizzle(&inst->FullSrcRegisters[i], chan);
-            if (swizzle <= TGSI_SWIZZLE_W &&
-                (channelsWritten & (1 << swizzle))) {
+            uint swizzle = tgsi_util_get_full_src_register_swizzle(&inst->Src[i], chan);
+            if (channelsWritten & (1 << swizzle)) {
                return TRUE;
             }
 
@@ -295,6 +608,14 @@ tgsi_exec_machine_bind_shader(
                                    * sizeof(struct tgsi_full_declaration));
             maxDeclarations += 10;
          }
+         if (parse.FullToken.FullDeclaration.Declaration.File == TGSI_FILE_OUTPUT) {
+            unsigned reg;
+            for (reg = parse.FullToken.FullDeclaration.Range.First;
+                 reg <= parse.FullToken.FullDeclaration.Range.Last;
+                 ++reg) {
+               ++mach->NumOutputs;
+            }
+         }
          memcpy(declarations + numDeclarations,
                 &parse.FullToken.FullDeclaration,
                 sizeof(declarations[0]));
@@ -332,20 +653,6 @@ tgsi_exec_machine_bind_shader(
             maxInstructions += 10;
          }
 
-         if (tgsi_check_soa_dependencies(&parse.FullToken.FullInstruction)) {
-            uint opcode = parse.FullToken.FullInstruction.Instruction.Opcode;
-            parse.FullToken.FullInstruction.Flags = SOA_DEPENDENCY_FLAG;
-            /* XXX we only handle SOA dependencies properly for MOV/SWZ
-             * at this time!
-             */
-            if (opcode != TGSI_OPCODE_MOV && opcode != TGSI_OPCODE_SWZ) {
-               debug_printf("Warning: SOA dependency in instruction"
-                            " is not handled:\n");
-               tgsi_dump_instruction(&parse.FullToken.FullInstruction,
-                                     numInstructions);
-            }
-         }
-
          memcpy(instructions + numInstructions,
                 &parse.FullToken.FullInstruction,
                 sizeof(instructions[0]));
@@ -353,6 +660,9 @@ tgsi_exec_machine_bind_shader(
          numInstructions++;
          break;
 
+      case TGSI_TOKEN_TYPE_PROPERTY:
+         break;
+
       default:
          assert( 0 );
       }
@@ -386,6 +696,8 @@ tgsi_exec_machine_create( void )
    memset(mach, 0, sizeof(*mach));
 
    mach->Addrs = &mach->Temps[TGSI_EXEC_TEMP_ADDR];
+   mach->MaxGeometryShaderOutputs = TGSI_MAX_TOTAL_VERTICES;
+   mach->Predicates = &mach->Temps[TGSI_EXEC_TEMP_P0];
 
    /* Setup constants. */
    for( i = 0; i < 4; i++ ) {
@@ -426,18 +738,6 @@ tgsi_exec_machine_destroy(struct tgsi_exec_machine *mach)
    align_free(mach);
 }
 
-
-static void
-micro_abs(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src )
-{
-   dst->f[0] = fabsf( src->f[0] );
-   dst->f[1] = fabsf( src->f[1] );
-   dst->f[2] = fabsf( src->f[2] );
-   dst->f[3] = fabsf( src->f[3] );
-}
-
 static void
 micro_add(
    union tgsi_exec_channel *dst,
@@ -450,76 +750,6 @@ micro_add(
    dst->f[3] = src0->f[3] + src1->f[3];
 }
 
-#if 0
-static void
-micro_iadd(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src0,
-   const union tgsi_exec_channel *src1 )
-{
-   dst->i[0] = src0->i[0] + src1->i[0];
-   dst->i[1] = src0->i[1] + src1->i[1];
-   dst->i[2] = src0->i[2] + src1->i[2];
-   dst->i[3] = src0->i[3] + src1->i[3];
-}
-#endif
-
-static void
-micro_and(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src0,
-   const union tgsi_exec_channel *src1 )
-{
-   dst->u[0] = src0->u[0] & src1->u[0];
-   dst->u[1] = src0->u[1] & src1->u[1];
-   dst->u[2] = src0->u[2] & src1->u[2];
-   dst->u[3] = src0->u[3] & src1->u[3];
-}
-
-static void
-micro_ceil(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src )
-{
-   dst->f[0] = ceilf( src->f[0] );
-   dst->f[1] = ceilf( src->f[1] );
-   dst->f[2] = ceilf( src->f[2] );
-   dst->f[3] = ceilf( src->f[3] );
-}
-
-static void
-micro_cos(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src )
-{
-   dst->f[0] = cosf( src->f[0] );
-   dst->f[1] = cosf( src->f[1] );
-   dst->f[2] = cosf( src->f[2] );
-   dst->f[3] = cosf( src->f[3] );
-}
-
-static void
-micro_ddx(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src )
-{
-   dst->f[0] =
-   dst->f[1] =
-   dst->f[2] =
-   dst->f[3] = src->f[TILE_BOTTOM_RIGHT] - src->f[TILE_BOTTOM_LEFT];
-}
-
-static void
-micro_ddy(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src )
-{
-   dst->f[0] =
-   dst->f[1] =
-   dst->f[2] =
-   dst->f[3] = src->f[TILE_TOP_LEFT] - src->f[TILE_BOTTOM_LEFT];
-}
-
 static void
 micro_div(
    union tgsi_exec_channel *dst,
@@ -540,81 +770,6 @@ micro_div(
    }
 }
 
-#if 0
-static void
-micro_udiv(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src0,
-   const union tgsi_exec_channel *src1 )
-{
-   dst->u[0] = src0->u[0] / src1->u[0];
-   dst->u[1] = src0->u[1] / src1->u[1];
-   dst->u[2] = src0->u[2] / src1->u[2];
-   dst->u[3] = src0->u[3] / src1->u[3];
-}
-#endif
-
-static void
-micro_eq(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src0,
-   const union tgsi_exec_channel *src1,
-   const union tgsi_exec_channel *src2,
-   const union tgsi_exec_channel *src3 )
-{
-   dst->f[0] = src0->f[0] == src1->f[0] ? src2->f[0] : src3->f[0];
-   dst->f[1] = src0->f[1] == src1->f[1] ? src2->f[1] : src3->f[1];
-   dst->f[2] = src0->f[2] == src1->f[2] ? src2->f[2] : src3->f[2];
-   dst->f[3] = src0->f[3] == src1->f[3] ? src2->f[3] : src3->f[3];
-}
-
-#if 0
-static void
-micro_ieq(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src0,
-   const union tgsi_exec_channel *src1,
-   const union tgsi_exec_channel *src2,
-   const union tgsi_exec_channel *src3 )
-{
-   dst->i[0] = src0->i[0] == src1->i[0] ? src2->i[0] : src3->i[0];
-   dst->i[1] = src0->i[1] == src1->i[1] ? src2->i[1] : src3->i[1];
-   dst->i[2] = src0->i[2] == src1->i[2] ? src2->i[2] : src3->i[2];
-   dst->i[3] = src0->i[3] == src1->i[3] ? src2->i[3] : src3->i[3];
-}
-#endif
-
-static void
-micro_exp2(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src)
-{
-#if FAST_MATH
-   dst->f[0] = util_fast_exp2( src->f[0] );
-   dst->f[1] = util_fast_exp2( src->f[1] );
-   dst->f[2] = util_fast_exp2( src->f[2] );
-   dst->f[3] = util_fast_exp2( src->f[3] );
-#else
-   dst->f[0] = powf( 2.0f, src->f[0] );
-   dst->f[1] = powf( 2.0f, src->f[1] );
-   dst->f[2] = powf( 2.0f, src->f[2] );
-   dst->f[3] = powf( 2.0f, src->f[3] );
-#endif
-}
-
-#if 0
-static void
-micro_f2ut(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src )
-{
-   dst->u[0] = (uint) src->f[0];
-   dst->u[1] = (uint) src->f[1];
-   dst->u[2] = (uint) src->f[2];
-   dst->u[3] = (uint) src->f[3];
-}
-#endif
-
 static void
 micro_float_clamp(union tgsi_exec_channel *dst,
                   const union tgsi_exec_channel *src)
@@ -642,72 +797,7 @@ micro_float_clamp(union tgsi_exec_channel *dst,
 }
 
 static void
-micro_flr(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src )
-{
-   dst->f[0] = floorf( src->f[0] );
-   dst->f[1] = floorf( src->f[1] );
-   dst->f[2] = floorf( src->f[2] );
-   dst->f[3] = floorf( src->f[3] );
-}
-
-static void
-micro_frc(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src )
-{
-   dst->f[0] = src->f[0] - floorf( src->f[0] );
-   dst->f[1] = src->f[1] - floorf( src->f[1] );
-   dst->f[2] = src->f[2] - floorf( src->f[2] );
-   dst->f[3] = src->f[3] - floorf( src->f[3] );
-}
-
-static void
-micro_i2f(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src )
-{
-   dst->f[0] = (float) src->i[0];
-   dst->f[1] = (float) src->i[1];
-   dst->f[2] = (float) src->i[2];
-   dst->f[3] = (float) src->i[3];
-}
-
-static void
-micro_lg2(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src )
-{
-#if FAST_MATH
-   dst->f[0] = util_fast_log2( src->f[0] );
-   dst->f[1] = util_fast_log2( src->f[1] );
-   dst->f[2] = util_fast_log2( src->f[2] );
-   dst->f[3] = util_fast_log2( src->f[3] );
-#else
-   dst->f[0] = logf( src->f[0] ) * 1.442695f;
-   dst->f[1] = logf( src->f[1] ) * 1.442695f;
-   dst->f[2] = logf( src->f[2] ) * 1.442695f;
-   dst->f[3] = logf( src->f[3] ) * 1.442695f;
-#endif
-}
-
-static void
-micro_le(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src0,
-   const union tgsi_exec_channel *src1,
-   const union tgsi_exec_channel *src2,
-   const union tgsi_exec_channel *src3 )
-{
-   dst->f[0] = src0->f[0] <= src1->f[0] ? src2->f[0] : src3->f[0];
-   dst->f[1] = src0->f[1] <= src1->f[1] ? src2->f[1] : src3->f[1];
-   dst->f[2] = src0->f[2] <= src1->f[2] ? src2->f[2] : src3->f[2];
-   dst->f[3] = src0->f[3] <= src1->f[3] ? src2->f[3] : src3->f[3];
-}
-
-static void
-micro_lt(
+micro_lt(
    union tgsi_exec_channel *dst,
    const union tgsi_exec_channel *src0,
    const union tgsi_exec_channel *src1,
@@ -720,38 +810,6 @@ micro_lt(
    dst->f[3] = src0->f[3] < src1->f[3] ? src2->f[3] : src3->f[3];
 }
 
-#if 0
-static void
-micro_ilt(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src0,
-   const union tgsi_exec_channel *src1,
-   const union tgsi_exec_channel *src2,
-   const union tgsi_exec_channel *src3 )
-{
-   dst->i[0] = src0->i[0] < src1->i[0] ? src2->i[0] : src3->i[0];
-   dst->i[1] = src0->i[1] < src1->i[1] ? src2->i[1] : src3->i[1];
-   dst->i[2] = src0->i[2] < src1->i[2] ? src2->i[2] : src3->i[2];
-   dst->i[3] = src0->i[3] < src1->i[3] ? src2->i[3] : src3->i[3];
-}
-#endif
-
-#if 0
-static void
-micro_ult(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src0,
-   const union tgsi_exec_channel *src1,
-   const union tgsi_exec_channel *src2,
-   const union tgsi_exec_channel *src3 )
-{
-   dst->u[0] = src0->u[0] < src1->u[0] ? src2->u[0] : src3->u[0];
-   dst->u[1] = src0->u[1] < src1->u[1] ? src2->u[1] : src3->u[1];
-   dst->u[2] = src0->u[2] < src1->u[2] ? src2->u[2] : src3->u[2];
-   dst->u[3] = src0->u[3] < src1->u[3] ? src2->u[3] : src3->u[3];
-}
-#endif
-
 static void
 micro_max(
    union tgsi_exec_channel *dst,
@@ -764,34 +822,6 @@ micro_max(
    dst->f[3] = src0->f[3] > src1->f[3] ? src0->f[3] : src1->f[3];
 }
 
-#if 0
-static void
-micro_imax(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src0,
-   const union tgsi_exec_channel *src1 )
-{
-   dst->i[0] = src0->i[0] > src1->i[0] ? src0->i[0] : src1->i[0];
-   dst->i[1] = src0->i[1] > src1->i[1] ? src0->i[1] : src1->i[1];
-   dst->i[2] = src0->i[2] > src1->i[2] ? src0->i[2] : src1->i[2];
-   dst->i[3] = src0->i[3] > src1->i[3] ? src0->i[3] : src1->i[3];
-}
-#endif
-
-#if 0
-static void
-micro_umax(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src0,
-   const union tgsi_exec_channel *src1 )
-{
-   dst->u[0] = src0->u[0] > src1->u[0] ? src0->u[0] : src1->u[0];
-   dst->u[1] = src0->u[1] > src1->u[1] ? src0->u[1] : src1->u[1];
-   dst->u[2] = src0->u[2] > src1->u[2] ? src0->u[2] : src1->u[2];
-   dst->u[3] = src0->u[3] > src1->u[3] ? src0->u[3] : src1->u[3];
-}
-#endif
-
 static void
 micro_min(
    union tgsi_exec_channel *dst,
@@ -804,48 +834,6 @@ micro_min(
    dst->f[3] = src0->f[3] < src1->f[3] ? src0->f[3] : src1->f[3];
 }
 
-#if 0
-static void
-micro_imin(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src0,
-   const union tgsi_exec_channel *src1 )
-{
-   dst->i[0] = src0->i[0] < src1->i[0] ? src0->i[0] : src1->i[0];
-   dst->i[1] = src0->i[1] < src1->i[1] ? src0->i[1] : src1->i[1];
-   dst->i[2] = src0->i[2] < src1->i[2] ? src0->i[2] : src1->i[2];
-   dst->i[3] = src0->i[3] < src1->i[3] ? src0->i[3] : src1->i[3];
-}
-#endif
-
-#if 0
-static void
-micro_umin(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src0,
-   const union tgsi_exec_channel *src1 )
-{
-   dst->u[0] = src0->u[0] < src1->u[0] ? src0->u[0] : src1->u[0];
-   dst->u[1] = src0->u[1] < src1->u[1] ? src0->u[1] : src1->u[1];
-   dst->u[2] = src0->u[2] < src1->u[2] ? src0->u[2] : src1->u[2];
-   dst->u[3] = src0->u[3] < src1->u[3] ? src0->u[3] : src1->u[3];
-}
-#endif
-
-#if 0
-static void
-micro_umod(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src0,
-   const union tgsi_exec_channel *src1 )
-{
-   dst->u[0] = src0->u[0] % src1->u[0];
-   dst->u[1] = src0->u[1] % src1->u[1];
-   dst->u[2] = src0->u[2] % src1->u[2];
-   dst->u[3] = src0->u[3] % src1->u[3];
-}
-#endif
-
 static void
 micro_mul(
    union tgsi_exec_channel *dst,
@@ -858,20 +846,6 @@ micro_mul(
    dst->f[3] = src0->f[3] * src1->f[3];
 }
 
-#if 0
-static void
-micro_imul(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src0,
-   const union tgsi_exec_channel *src1 )
-{
-   dst->i[0] = src0->i[0] * src1->i[0];
-   dst->i[1] = src0->i[1] * src1->i[1];
-   dst->i[2] = src0->i[2] * src1->i[2];
-   dst->i[3] = src0->i[3] * src1->i[3];
-}
-#endif
-
 #if 0
 static void
 micro_imul64(
@@ -937,42 +911,6 @@ micro_neg(
    dst->f[3] = -src->f[3];
 }
 
-#if 0
-static void
-micro_ineg(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src )
-{
-   dst->i[0] = -src->i[0];
-   dst->i[1] = -src->i[1];
-   dst->i[2] = -src->i[2];
-   dst->i[3] = -src->i[3];
-}
-#endif
-
-static void
-micro_not(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src )
-{
-   dst->u[0] = ~src->u[0];
-   dst->u[1] = ~src->u[1];
-   dst->u[2] = ~src->u[2];
-   dst->u[3] = ~src->u[3];
-}
-
-static void
-micro_or(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src0,
-   const union tgsi_exec_channel *src1 )
-{
-   dst->u[0] = src0->u[0] | src1->u[0];
-   dst->u[1] = src0->u[1] | src1->u[1];
-   dst->u[2] = src0->u[2] | src1->u[2];
-   dst->u[3] = src0->u[3] | src1->u[3];
-}
-
 static void
 micro_pow(
    union tgsi_exec_channel *dst,
@@ -992,88 +930,6 @@ micro_pow(
 #endif
 }
 
-static void
-micro_rnd(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src )
-{
-   dst->f[0] = floorf( src->f[0] + 0.5f );
-   dst->f[1] = floorf( src->f[1] + 0.5f );
-   dst->f[2] = floorf( src->f[2] + 0.5f );
-   dst->f[3] = floorf( src->f[3] + 0.5f );
-}
-
-static void
-micro_sgn(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src )
-{
-   dst->f[0] = src->f[0] < 0.0f ? -1.0f : src->f[0] > 0.0f ? 1.0f : 0.0f;
-   dst->f[1] = src->f[1] < 0.0f ? -1.0f : src->f[1] > 0.0f ? 1.0f : 0.0f;
-   dst->f[2] = src->f[2] < 0.0f ? -1.0f : src->f[2] > 0.0f ? 1.0f : 0.0f;
-   dst->f[3] = src->f[3] < 0.0f ? -1.0f : src->f[3] > 0.0f ? 1.0f : 0.0f;
-}
-
-static void
-micro_shl(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src0,
-   const union tgsi_exec_channel *src1 )
-{
-   dst->i[0] = src0->i[0] << src1->i[0];
-   dst->i[1] = src0->i[1] << src1->i[1];
-   dst->i[2] = src0->i[2] << src1->i[2];
-   dst->i[3] = src0->i[3] << src1->i[3];
-}
-
-static void
-micro_ishr(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src0,
-   const union tgsi_exec_channel *src1 )
-{
-   dst->i[0] = src0->i[0] >> src1->i[0];
-   dst->i[1] = src0->i[1] >> src1->i[1];
-   dst->i[2] = src0->i[2] >> src1->i[2];
-   dst->i[3] = src0->i[3] >> src1->i[3];
-}
-
-static void
-micro_trunc(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src0 )
-{
-   dst->f[0] = (float) (int) src0->f[0];
-   dst->f[1] = (float) (int) src0->f[1];
-   dst->f[2] = (float) (int) src0->f[2];
-   dst->f[3] = (float) (int) src0->f[3];
-}
-
-#if 0
-static void
-micro_ushr(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src0,
-   const union tgsi_exec_channel *src1 )
-{
-   dst->u[0] = src0->u[0] >> src1->u[0];
-   dst->u[1] = src0->u[1] >> src1->u[1];
-   dst->u[2] = src0->u[2] >> src1->u[2];
-   dst->u[3] = src0->u[3] >> src1->u[3];
-}
-#endif
-
-static void
-micro_sin(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src )
-{
-   dst->f[0] = sinf( src->f[0] );
-   dst->f[1] = sinf( src->f[1] );
-   dst->f[2] = sinf( src->f[2] );
-   dst->f[3] = sinf( src->f[3] );
-}
-
 static void
 micro_sqrt( union tgsi_exec_channel *dst,
             const union tgsi_exec_channel *src )
@@ -1096,31 +952,6 @@ micro_sub(
    dst->f[3] = src0->f[3] - src1->f[3];
 }
 
-#if 0
-static void
-micro_u2f(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src )
-{
-   dst->f[0] = (float) src->u[0];
-   dst->f[1] = (float) src->u[1];
-   dst->f[2] = (float) src->u[2];
-   dst->f[3] = (float) src->u[3];
-}
-#endif
-
-static void
-micro_xor(
-   union tgsi_exec_channel *dst,
-   const union tgsi_exec_channel *src0,
-   const union tgsi_exec_channel *src1 )
-{
-   dst->u[0] = src0->u[0] ^ src1->u[0];
-   dst->u[1] = src0->u[1] ^ src1->u[1];
-   dst->u[2] = src0->u[2] ^ src1->u[2];
-   dst->u[3] = src0->u[3] ^ src1->u[3];
-}
-
 static void
 fetch_src_file_channel(
    const struct tgsi_exec_machine *mach,
@@ -1130,10 +961,10 @@ fetch_src_file_channel(
    union tgsi_exec_channel *chan )
 {
    switch( swizzle ) {
-   case TGSI_EXTSWIZZLE_X:
-   case TGSI_EXTSWIZZLE_Y:
-   case TGSI_EXTSWIZZLE_Z:
-   case TGSI_EXTSWIZZLE_W:
+   case TGSI_SWIZZLE_X:
+   case TGSI_SWIZZLE_Y:
+   case TGSI_SWIZZLE_Z:
+   case TGSI_SWIZZLE_W:
       switch( file ) {
       case TGSI_FILE_CONSTANT:
          assert(mach->Consts);
@@ -1156,6 +987,7 @@ fetch_src_file_channel(
          break;
 
       case TGSI_FILE_INPUT:
+      case TGSI_FILE_SYSTEM_VALUE:
          chan->u[0] = mach->Inputs[index->i[0]].xyzw[swizzle].u[0];
          chan->u[1] = mach->Inputs[index->i[1]].xyzw[swizzle].u[1];
          chan->u[2] = mach->Inputs[index->i[2]].xyzw[swizzle].u[2];
@@ -1188,6 +1020,17 @@ fetch_src_file_channel(
          chan->u[3] = mach->Addrs[index->i[3]].xyzw[swizzle].u[3];
          break;
 
+      case TGSI_FILE_PREDICATE:
+         assert(index->i[0] < TGSI_EXEC_NUM_PREDS);
+         assert(index->i[1] < TGSI_EXEC_NUM_PREDS);
+         assert(index->i[2] < TGSI_EXEC_NUM_PREDS);
+         assert(index->i[3] < TGSI_EXEC_NUM_PREDS);
+         chan->u[0] = mach->Predicates[0].xyzw[swizzle].u[0];
+         chan->u[1] = mach->Predicates[0].xyzw[swizzle].u[1];
+         chan->u[2] = mach->Predicates[0].xyzw[swizzle].u[2];
+         chan->u[3] = mach->Predicates[0].xyzw[swizzle].u[3];
+         break;
+
       case TGSI_FILE_OUTPUT:
          /* vertex/fragment output vars can be read too */
          chan->u[0] = mach->Outputs[index->i[0]].xyzw[swizzle].u[0];
@@ -1201,25 +1044,17 @@ fetch_src_file_channel(
       }
       break;
 
-   case TGSI_EXTSWIZZLE_ZERO:
-      *chan = mach->Temps[TEMP_0_I].xyzw[TEMP_0_C];
-      break;
-
-   case TGSI_EXTSWIZZLE_ONE:
-      *chan = mach->Temps[TEMP_1_I].xyzw[TEMP_1_C];
-      break;
-
    default:
       assert( 0 );
    }
 }
 
 static void
-fetch_source(
-   const struct tgsi_exec_machine *mach,
-   union tgsi_exec_channel *chan,
-   const struct tgsi_full_src_register *reg,
-   const uint chan_index )
+fetch_source(const struct tgsi_exec_machine *mach,
+             union tgsi_exec_channel *chan,
+             const struct tgsi_full_src_register *reg,
+             const uint chan_index,
+             enum tgsi_exec_datatype src_datatype)
 {
    union tgsi_exec_channel index;
    uint swizzle;
@@ -1228,13 +1063,13 @@ fetch_source(
     *
     *    file[1],
     *    where:
-    *       file = SrcRegister.File
-    *       [1] = SrcRegister.Index
+    *       file = Register.File
+    *       [1] = Register.Index
     */
    index.i[0] =
    index.i[1] =
    index.i[2] =
-   index.i[3] = reg->SrcRegister.Index;
+   index.i[3] = reg->Register.Index;
 
    /* There is an extra source register that indirectly subscripts
     * a register file. The direct index now becomes an offset
@@ -1242,11 +1077,11 @@ fetch_source(
     *
     *    file[ind[2].x+1],
     *    where:
-    *       ind = SrcRegisterInd.File
-    *       [2] = SrcRegisterInd.Index
-    *       .x = SrcRegisterInd.SwizzleX
+    *       ind = Indirect.File
+    *       [2] = Indirect.Index
+    *       .x = Indirect.SwizzleX
     */
-   if (reg->SrcRegister.Indirect) {
+   if (reg->Register.Indirect) {
       union tgsi_exec_channel index2;
       union tgsi_exec_channel indir_index;
       const uint execmask = mach->ExecMask;
@@ -1256,22 +1091,22 @@ fetch_source(
       index2.i[0] =
       index2.i[1] =
       index2.i[2] =
-      index2.i[3] = reg->SrcRegisterInd.Index;
+      index2.i[3] = reg->Indirect.Index;
 
       /* get current value of address register[swizzle] */
-      swizzle = tgsi_util_get_src_register_swizzle( &reg->SrcRegisterInd, CHAN_X );
+      swizzle = tgsi_util_get_src_register_swizzle( &reg->Indirect, CHAN_X );
       fetch_src_file_channel(
          mach,
-         reg->SrcRegisterInd.File,
+         reg->Indirect.File,
          swizzle,
          &index2,
          &indir_index );
 
       /* add value of address register to the offset */
-      index.i[0] += (int) indir_index.f[0];
-      index.i[1] += (int) indir_index.f[1];
-      index.i[2] += (int) indir_index.f[2];
-      index.i[3] += (int) indir_index.f[3];
+      index.i[0] += indir_index.i[0];
+      index.i[1] += indir_index.i[1];
+      index.i[2] += indir_index.i[2];
+      index.i[3] += indir_index.i[3];
 
       /* for disabled execution channels, zero-out the index to
        * avoid using a potential garbage value.
@@ -1288,15 +1123,16 @@ fetch_source(
     *
     *    file[1][3] == file[1*sizeof(file[1])+3],
     *    where:
-    *       [3] = SrcRegisterDim.Index
+    *       [3] = Dimension.Index
     */
-   if (reg->SrcRegister.Dimension) {
+   if (reg->Register.Dimension) {
       /* The size of the first-order array depends on the register file type.
        * We need to multiply the index to the first array to get an effective,
        * "flat" index that points to the beginning of the second-order array.
        */
-      switch (reg->SrcRegister.File) {
+      switch (reg->Register.File) {
       case TGSI_FILE_INPUT:
+      case TGSI_FILE_SYSTEM_VALUE:
          index.i[0] *= TGSI_EXEC_MAX_INPUT_ATTRIBS;
          index.i[1] *= TGSI_EXEC_MAX_INPUT_ATTRIBS;
          index.i[2] *= TGSI_EXEC_MAX_INPUT_ATTRIBS;
@@ -1312,10 +1148,10 @@ fetch_source(
          assert( 0 );
       }
 
-      index.i[0] += reg->SrcRegisterDim.Index;
-      index.i[1] += reg->SrcRegisterDim.Index;
-      index.i[2] += reg->SrcRegisterDim.Index;
-      index.i[3] += reg->SrcRegisterDim.Index;
+      index.i[0] += reg->Dimension.Index;
+      index.i[1] += reg->Dimension.Index;
+      index.i[2] += reg->Dimension.Index;
+      index.i[3] += reg->Dimension.Index;
 
       /* Again, the second subscript index can be addressed indirectly
        * identically to the first one.
@@ -1324,11 +1160,11 @@ fetch_source(
        *
        *    file[1][ind[4].y+3],
        *    where:
-       *       ind = SrcRegisterDimInd.File
-       *       [4] = SrcRegisterDimInd.Index
-       *       .y = SrcRegisterDimInd.SwizzleX
+       *       ind = DimIndirect.File
+       *       [4] = DimIndirect.Index
+       *       .y = DimIndirect.SwizzleX
        */
-      if (reg->SrcRegisterDim.Indirect) {
+      if (reg->Dimension.Indirect) {
          union tgsi_exec_channel index2;
          union tgsi_exec_channel indir_index;
          const uint execmask = mach->ExecMask;
@@ -1337,20 +1173,20 @@ fetch_source(
          index2.i[0] =
          index2.i[1] =
          index2.i[2] =
-         index2.i[3] = reg->SrcRegisterDimInd.Index;
+         index2.i[3] = reg->DimIndirect.Index;
 
-         swizzle = tgsi_util_get_src_register_swizzle( &reg->SrcRegisterDimInd, CHAN_X );
+         swizzle = tgsi_util_get_src_register_swizzle( &reg->DimIndirect, CHAN_X );
          fetch_src_file_channel(
             mach,
-            reg->SrcRegisterDimInd.File,
+            reg->DimIndirect.File,
             swizzle,
             &index2,
             &indir_index );
 
-         index.i[0] += (int) indir_index.f[0];
-         index.i[1] += (int) indir_index.f[1];
-         index.i[2] += (int) indir_index.f[2];
-         index.i[3] += (int) indir_index.f[3];
+         index.i[0] += indir_index.i[0];
+         index.i[1] += indir_index.i[1];
+         index.i[2] += indir_index.i[2];
+         index.i[3] += indir_index.i[3];
 
          /* for disabled execution channels, zero-out the index to
           * avoid using a potential garbage value.
@@ -1362,49 +1198,43 @@ fetch_source(
       }
 
       /* If by any chance there was a need for a 3D array of register
-       * files, we would have to check whether SrcRegisterDim is followed
+       * files, we would have to check whether Dimension is followed
        * by a dimension register and continue the saga.
        */
    }
 
-   swizzle = tgsi_util_get_full_src_register_extswizzle( reg, chan_index );
+   swizzle = tgsi_util_get_full_src_register_swizzle( reg, chan_index );
    fetch_src_file_channel(
       mach,
-      reg->SrcRegister.File,
+      reg->Register.File,
       swizzle,
       &index,
       chan );
 
-   switch (tgsi_util_get_full_src_register_sign_mode( reg, chan_index )) {
-   case TGSI_UTIL_SIGN_CLEAR:
-      micro_abs( chan, chan );
-      break;
-
-   case TGSI_UTIL_SIGN_SET:
-      micro_abs( chan, chan );
-      micro_neg( chan, chan );
-      break;
-
-   case TGSI_UTIL_SIGN_TOGGLE:
-      micro_neg( chan, chan );
-      break;
-
-   case TGSI_UTIL_SIGN_KEEP:
-      break;
+   if (reg->Register.Absolute) {
+      if (src_datatype == TGSI_EXEC_DATA_FLOAT) {
+         micro_abs(chan, chan);
+      } else {
+         micro_iabs(chan, chan);
+      }
    }
 
-   if (reg->SrcRegisterExtMod.Complement) {
-      micro_sub( chan, &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], chan );
+   if (reg->Register.Negate) {
+      if (src_datatype == TGSI_EXEC_DATA_FLOAT) {
+         micro_neg(chan, chan);
+      } else {
+         micro_ineg(chan, chan);
+      }
    }
 }
 
 static void
-store_dest(
-   struct tgsi_exec_machine *mach,
-   const union tgsi_exec_channel *chan,
-   const struct tgsi_full_dst_register *reg,
-   const struct tgsi_full_instruction *inst,
-   uint chan_index )
+store_dest(struct tgsi_exec_machine *mach,
+           const union tgsi_exec_channel *chan,
+           const struct tgsi_full_dst_register *reg,
+           const struct tgsi_full_instruction *inst,
+           uint chan_index,
+           enum tgsi_exec_datatype dst_datatype)
 {
    uint i;
    union tgsi_exec_channel null;
@@ -1413,9 +1243,9 @@ store_dest(
    int offset = 0;  /* indirection offset */
    int index;
 
-#ifdef DEBUG
-   check_inf_or_nan(chan);
-#endif
+   if (dst_datatype == TGSI_EXEC_DATA_FLOAT) {
+      CHECK_INF_OR_NAN(chan);
+   }
 
    /* There is an extra source register that indirectly subscripts
     * a register file. The direct index now becomes an offset
@@ -1423,11 +1253,11 @@ store_dest(
     *
     *    file[ind[2].x+1],
     *    where:
-    *       ind = DstRegisterInd.File
-    *       [2] = DstRegisterInd.Index
-    *       .x = DstRegisterInd.SwizzleX
+    *       ind = Indirect.File
+    *       [2] = Indirect.Index
+    *       .x = Indirect.SwizzleX
     */
-   if (reg->DstRegister.Indirect) {
+   if (reg->Register.Indirect) {
       union tgsi_exec_channel index;
       union tgsi_exec_channel indir_index;
       uint swizzle;
@@ -1436,155 +1266,110 @@ store_dest(
       index.i[0] =
       index.i[1] =
       index.i[2] =
-      index.i[3] = reg->DstRegisterInd.Index;
+      index.i[3] = reg->Indirect.Index;
 
       /* get current value of address register[swizzle] */
-      swizzle = tgsi_util_get_src_register_swizzle( &reg->DstRegisterInd, CHAN_X );
+      swizzle = tgsi_util_get_src_register_swizzle( &reg->Indirect, CHAN_X );
 
       /* fetch values from the address/indirection register */
       fetch_src_file_channel(
          mach,
-         reg->DstRegisterInd.File,
+         reg->Indirect.File,
          swizzle,
          &index,
          &indir_index );
 
       /* save indirection offset */
-      offset = (int) indir_index.f[0];
+      offset = indir_index.i[0];
    }
 
-   switch (reg->DstRegister.File) {
+   switch (reg->Register.File) {
    case TGSI_FILE_NULL:
       dst = &null;
       break;
 
    case TGSI_FILE_OUTPUT:
       index = mach->Temps[TEMP_OUTPUT_I].xyzw[TEMP_OUTPUT_C].u[0]
-         + reg->DstRegister.Index;
+         + reg->Register.Index;
       dst = &mach->Outputs[offset + index].xyzw[chan_index];
+#if 0
+      if (TGSI_PROCESSOR_GEOMETRY == mach->Processor) {
+         fprintf(stderr, "STORING OUT[%d] mask(%d), = (", offset + index, execmask);
+         for (i = 0; i < QUAD_SIZE; i++)
+            if (execmask & (1 << i))
+               fprintf(stderr, "%f, ", chan->f[i]);
+         fprintf(stderr, ")\n");
+      }
+#endif
       break;
 
    case TGSI_FILE_TEMPORARY:
-      index = reg->DstRegister.Index;
+      index = reg->Register.Index;
       assert( index < TGSI_EXEC_NUM_TEMPS );
       dst = &mach->Temps[offset + index].xyzw[chan_index];
       break;
 
    case TGSI_FILE_ADDRESS:
-      index = reg->DstRegister.Index;
+      index = reg->Register.Index;
       dst = &mach->Addrs[index].xyzw[chan_index];
       break;
 
+   case TGSI_FILE_LOOP:
+      assert(reg->Register.Index == 0);
+      assert(mach->LoopCounterStackTop > 0);
+      assert(chan_index == CHAN_X);
+      dst = &mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[chan_index];
+      break;
+
+   case TGSI_FILE_PREDICATE:
+      index = reg->Register.Index;
+      assert(index < TGSI_EXEC_NUM_PREDS);
+      dst = &mach->Predicates[index].xyzw[chan_index];
+      break;
+
    default:
       assert( 0 );
       return;
    }
 
-   if (inst->InstructionExtNv.CondFlowEnable) {
-      union tgsi_exec_channel *cc = &mach->Temps[TEMP_CC_I].xyzw[TEMP_CC_C];
+   if (inst->Instruction.Predicate) {
       uint swizzle;
-      uint shift;
-      uint mask;
-      uint test;
-
-      /* Only CC0 supported.
-       */
-      assert( inst->InstructionExtNv.CondFlowIndex < 1 );
+      union tgsi_exec_channel *pred;
 
       switch (chan_index) {
       case CHAN_X:
-         swizzle = inst->InstructionExtNv.CondSwizzleX;
+         swizzle = inst->Predicate.SwizzleX;
          break;
       case CHAN_Y:
-         swizzle = inst->InstructionExtNv.CondSwizzleY;
+         swizzle = inst->Predicate.SwizzleY;
          break;
       case CHAN_Z:
-         swizzle = inst->InstructionExtNv.CondSwizzleZ;
+         swizzle = inst->Predicate.SwizzleZ;
          break;
       case CHAN_W:
-         swizzle = inst->InstructionExtNv.CondSwizzleW;
-         break;
-      default:
-         assert( 0 );
-         return;
-      }
-
-      switch (swizzle) {
-      case TGSI_SWIZZLE_X:
-         shift = TGSI_EXEC_CC_X_SHIFT;
-         mask = TGSI_EXEC_CC_X_MASK;
-         break;
-      case TGSI_SWIZZLE_Y:
-         shift = TGSI_EXEC_CC_Y_SHIFT;
-         mask = TGSI_EXEC_CC_Y_MASK;
-         break;
-      case TGSI_SWIZZLE_Z:
-         shift = TGSI_EXEC_CC_Z_SHIFT;
-         mask = TGSI_EXEC_CC_Z_MASK;
-         break;
-      case TGSI_SWIZZLE_W:
-         shift = TGSI_EXEC_CC_W_SHIFT;
-         mask = TGSI_EXEC_CC_W_MASK;
+         swizzle = inst->Predicate.SwizzleW;
          break;
       default:
-         assert( 0 );
+         assert(0);
          return;
       }
 
-      switch (inst->InstructionExtNv.CondMask) {
-      case TGSI_CC_GT:
-         test = ~(TGSI_EXEC_CC_GT << shift) & mask;
-         for (i = 0; i < QUAD_SIZE; i++)
-            if (cc->u[i] & test)
-               execmask &= ~(1 << i);
-         break;
+      assert(inst->Predicate.Index == 0);
 
-      case TGSI_CC_EQ:
-         test = ~(TGSI_EXEC_CC_EQ << shift) & mask;
-         for (i = 0; i < QUAD_SIZE; i++)
-            if (cc->u[i] & test)
-               execmask &= ~(1 << i);
-         break;
+      pred = &mach->Predicates[inst->Predicate.Index].xyzw[swizzle];
 
-      case TGSI_CC_LT:
-         test = ~(TGSI_EXEC_CC_LT << shift) & mask;
-         for (i = 0; i < QUAD_SIZE; i++)
-            if (cc->u[i] & test)
+      if (inst->Predicate.Negate) {
+         for (i = 0; i < QUAD_SIZE; i++) {
+            if (pred->u[i]) {
                execmask &= ~(1 << i);
-         break;
-
-      case TGSI_CC_GE:
-         test = ~((TGSI_EXEC_CC_GT | TGSI_EXEC_CC_EQ) << shift) & mask;
-         for (i = 0; i < QUAD_SIZE; i++)
-            if (cc->u[i] & test)
-               execmask &= ~(1 << i);
-         break;
-
-      case TGSI_CC_LE:
-         test = ~((TGSI_EXEC_CC_LT | TGSI_EXEC_CC_EQ) << shift) & mask;
-         for (i = 0; i < QUAD_SIZE; i++)
-            if (cc->u[i] & test)
-               execmask &= ~(1 << i);
-         break;
-
-      case TGSI_CC_NE:
-         test = ~((TGSI_EXEC_CC_GT | TGSI_EXEC_CC_LT | TGSI_EXEC_CC_UN) << shift) & mask;
-         for (i = 0; i < QUAD_SIZE; i++)
-            if (cc->u[i] & test)
+            }
+         }
+      } else {
+         for (i = 0; i < QUAD_SIZE; i++) {
+            if (!pred->u[i]) {
                execmask &= ~(1 << i);
-         break;
-
-      case TGSI_CC_TR:
-         break;
-
-      case TGSI_CC_FL:
-         for (i = 0; i < QUAD_SIZE; i++)
-            execmask &= ~(1 << i);
-         break;
-
-      default:
-         assert( 0 );
-         return;
+            }
+         }
       }
    }
 
@@ -1622,58 +1407,13 @@ store_dest(
    default:
       assert( 0 );
    }
-
-   if (inst->InstructionExtNv.CondDstUpdate) {
-      union tgsi_exec_channel *cc = &mach->Temps[TEMP_CC_I].xyzw[TEMP_CC_C];
-      uint shift;
-      uint mask;
-
-      /* Only CC0 supported.
-       */
-      assert( inst->InstructionExtNv.CondDstIndex < 1 );
-
-      switch (chan_index) {
-      case CHAN_X:
-         shift = TGSI_EXEC_CC_X_SHIFT;
-         mask = ~TGSI_EXEC_CC_X_MASK;
-         break;
-      case CHAN_Y:
-         shift = TGSI_EXEC_CC_Y_SHIFT;
-         mask = ~TGSI_EXEC_CC_Y_MASK;
-         break;
-      case CHAN_Z:
-         shift = TGSI_EXEC_CC_Z_SHIFT;
-         mask = ~TGSI_EXEC_CC_Z_MASK;
-         break;
-      case CHAN_W:
-         shift = TGSI_EXEC_CC_W_SHIFT;
-         mask = ~TGSI_EXEC_CC_W_MASK;
-         break;
-      default:
-         assert( 0 );
-         return;
-      }
-
-      for (i = 0; i < QUAD_SIZE; i++)
-         if (execmask & (1 << i)) {
-            cc->u[i] &= mask;
-            if (dst->f[i] < 0.0f)
-               cc->u[i] |= TGSI_EXEC_CC_LT << shift;
-            else if (dst->f[i] > 0.0f)
-               cc->u[i] |= TGSI_EXEC_CC_GT << shift;
-            else if (dst->f[i] == 0.0f)
-               cc->u[i] |= TGSI_EXEC_CC_EQ << shift;
-            else
-               cc->u[i] |= TGSI_EXEC_CC_UN << shift;
-         }
-   }
 }
 
 #define FETCH(VAL,INDEX,CHAN)\
-    fetch_source (mach, VAL, &inst->FullSrcRegisters[INDEX], CHAN)
+    fetch_source(mach, VAL, &inst->Src[INDEX], CHAN, TGSI_EXEC_DATA_FLOAT)
 
 #define STORE(VAL,INDEX,CHAN)\
-    store_dest (mach, VAL, &inst->FullDstRegisters[INDEX], inst, CHAN )
+   store_dest(mach, VAL, &inst->Dst[INDEX], inst, CHAN, TGSI_EXEC_DATA_FLOAT)
 
 
 /**
@@ -1689,10 +1429,8 @@ exec_kil(struct tgsi_exec_machine *mach,
    uint kilmask = 0; /* bit 0 = pixel 0, bit 1 = pixel 1, etc */
    union tgsi_exec_channel r[1];
 
-   /* This mask stores component bits that were already tested. Note that
-    * we test if the value is less than zero, so 1.0 and 0.0 need not to be
-    * tested. */
-   uniquemask = (1 << TGSI_EXTSWIZZLE_ZERO) | (1 << TGSI_EXTSWIZZLE_ONE);
+   /* This mask stores component bits that were already tested. */
+   uniquemask = 0;
 
    for (chan_index = 0; chan_index < 4; chan_index++)
    {
@@ -1700,8 +1438,8 @@ exec_kil(struct tgsi_exec_machine *mach,
       uint i;
 
       /* unswizzle channel */
-      swizzle = tgsi_util_get_full_src_register_extswizzle (
-                        &inst->FullSrcRegisters[0],
+      swizzle = tgsi_util_get_full_src_register_swizzle (
+                        &inst->Src[0],
                         chan_index);
 
       /* check if the component has not been already tested */
@@ -1728,35 +1466,40 @@ exec_kilp(struct tgsi_exec_machine *mach,
 {
    uint kilmask; /* bit 0 = pixel 0, bit 1 = pixel 1, etc */
 
-   if (inst->InstructionExtNv.CondFlowEnable) {
-      uint swizzle[4];
-      uint chan_index;
-
-      kilmask = 0x0;
-
-      swizzle[0] = inst->InstructionExtNv.CondSwizzleX;
-      swizzle[1] = inst->InstructionExtNv.CondSwizzleY;
-      swizzle[2] = inst->InstructionExtNv.CondSwizzleZ;
-      swizzle[3] = inst->InstructionExtNv.CondSwizzleW;
-
-      for (chan_index = 0; chan_index < 4; chan_index++)
-      {
-         uint i;
+   /* "unconditional" kil */
+   kilmask = mach->ExecMask;
+   mach->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0] |= kilmask;
+}
 
-         for (i = 0; i < 4; i++) {
-            /* TODO: evaluate the condition code */
-            if (0)
-               kilmask |= 1 << i;
-         }
-      }
-   }
-   else {
-      /* "unconditional" kil */
-      kilmask = mach->ExecMask;
+static void
+emit_vertex(struct tgsi_exec_machine *mach)
+{
+   /* FIXME: check for exec mask correctly
+   unsigned i;
+   for (i = 0; i < QUAD_SIZE; ++i) {
+         if ((mach->ExecMask & (1 << i)))
+   */
+   if (mach->ExecMask) {
+      mach->Temps[TEMP_OUTPUT_I].xyzw[TEMP_OUTPUT_C].u[0] += mach->NumOutputs;
+      mach->Primitives[mach->Temps[TEMP_PRIMITIVE_I].xyzw[TEMP_PRIMITIVE_C].u[0]]++;
    }
-   mach->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0] |= kilmask;
 }
 
+static void
+emit_primitive(struct tgsi_exec_machine *mach)
+{
+   unsigned *prim_count = &mach->Temps[TEMP_PRIMITIVE_I].xyzw[TEMP_PRIMITIVE_C].u[0];
+   /* FIXME: check for exec mask correctly
+   unsigned i;
+   for (i = 0; i < QUAD_SIZE; ++i) {
+         if ((mach->ExecMask & (1 << i)))
+   */
+   if (mach->ExecMask) {
+      ++(*prim_count);
+      debug_assert((*prim_count * mach->NumOutputs) < mach->MaxGeometryShaderOutputs);
+      mach->Primitives[*prim_count] = 0;
+   }
+}
 
 /*
  * Fetch a four texture samples using STR texture coordinates.
@@ -1766,7 +1509,8 @@ fetch_texel( struct tgsi_sampler *sampler,
              const union tgsi_exec_channel *s,
              const union tgsi_exec_channel *t,
              const union tgsi_exec_channel *p,
-             float lodbias,  /* XXX should be float[4] */
+             const union tgsi_exec_channel *c0,
+             enum tgsi_sampler_control control,
              union tgsi_exec_channel *r,
              union tgsi_exec_channel *g,
              union tgsi_exec_channel *b,
@@ -1775,7 +1519,7 @@ fetch_texel( struct tgsi_sampler *sampler,
    uint j;
    float rgba[NUM_CHANNELS][QUAD_SIZE];
 
-   sampler->get_samples(sampler, s->f, t->f, p->f, lodbias, rgba);
+   sampler->get_samples(sampler, s->f, t->f, p->f, c0->f, control, rgba);
 
    for (j = 0; j < 4; j++) {
       r->f[j] = rgba[0][j];
@@ -1786,102 +1530,156 @@ fetch_texel( struct tgsi_sampler *sampler,
 }
 
 
+#define TEX_MODIFIER_NONE           0
+#define TEX_MODIFIER_PROJECTED      1
+#define TEX_MODIFIER_LOD_BIAS       2
+#define TEX_MODIFIER_EXPLICIT_LOD   3
+
+
 static void
 exec_tex(struct tgsi_exec_machine *mach,
          const struct tgsi_full_instruction *inst,
-         boolean biasLod,
-         boolean projected)
+         uint modifier)
 {
-   const uint unit = inst->FullSrcRegisters[1].SrcRegister.Index;
+   const uint unit = inst->Src[1].Register.Index;
    union tgsi_exec_channel r[4];
+   const union tgsi_exec_channel *lod = &ZeroVec;
+   enum tgsi_sampler_control control;
    uint chan_index;
-   float lodBias;
 
-   /*   debug_printf("Sampler %u unit %u\n", sampler, unit); */
+   if (modifier != TEX_MODIFIER_NONE) {
+      FETCH(&r[3], 0, CHAN_W);
+      if (modifier != TEX_MODIFIER_PROJECTED) {
+         lod = &r[3];
+      }
+   }
+
+   if (modifier == TEX_MODIFIER_EXPLICIT_LOD) {
+      control = tgsi_sampler_lod_explicit;
+   } else {
+      control = tgsi_sampler_lod_bias;
+   }
 
-   switch (inst->InstructionExtTexture.Texture) {
+   switch (inst->Texture.Texture) {
    case TGSI_TEXTURE_1D:
    case TGSI_TEXTURE_SHADOW1D:
-
       FETCH(&r[0], 0, CHAN_X);
 
-      if (projected) {
-         FETCH(&r[1], 0, CHAN_W);
-         micro_div( &r[0], &r[0], &r[1] );
-      }
-
-      if (biasLod) {
-         FETCH(&r[1], 0, CHAN_W);
-         lodBias = r[2].f[0];
+      if (modifier == TEX_MODIFIER_PROJECTED) {
+         micro_div(&r[0], &r[0], &r[3]);
       }
-      else
-         lodBias = 0.0;
 
       fetch_texel(mach->Samplers[unit],
-                  &r[0], &ZeroVec, &ZeroVec, lodBias,  /* S, T, P, BIAS */
-                  &r[0], &r[1], &r[2], &r[3]); /* R, G, B, A */
+                  &r[0], &ZeroVec, &ZeroVec, lod,  /* S, T, P, LOD */
+                  control,
+                  &r[0], &r[1], &r[2], &r[3]);     /* R, G, B, A */
       break;
 
    case TGSI_TEXTURE_2D:
    case TGSI_TEXTURE_RECT:
    case TGSI_TEXTURE_SHADOW2D:
    case TGSI_TEXTURE_SHADOWRECT:
-
       FETCH(&r[0], 0, CHAN_X);
       FETCH(&r[1], 0, CHAN_Y);
       FETCH(&r[2], 0, CHAN_Z);
 
-      if (projected) {
-         FETCH(&r[3], 0, CHAN_W);
-         micro_div( &r[0], &r[0], &r[3] );
-         micro_div( &r[1], &r[1], &r[3] );
-         micro_div( &r[2], &r[2], &r[3] );
-      }
-
-      if (biasLod) {
-         FETCH(&r[3], 0, CHAN_W);
-         lodBias = r[3].f[0];
+      if (modifier == TEX_MODIFIER_PROJECTED) {
+         micro_div(&r[0], &r[0], &r[3]);
+         micro_div(&r[1], &r[1], &r[3]);
+         micro_div(&r[2], &r[2], &r[3]);
       }
-      else
-         lodBias = 0.0;
 
       fetch_texel(mach->Samplers[unit],
-                  &r[0], &r[1], &r[2], lodBias,  /* inputs */
+                  &r[0], &r[1], &r[2], lod,     /* S, T, P, LOD */
+                  control,
                   &r[0], &r[1], &r[2], &r[3]);  /* outputs */
       break;
 
    case TGSI_TEXTURE_3D:
    case TGSI_TEXTURE_CUBE:
-
       FETCH(&r[0], 0, CHAN_X);
       FETCH(&r[1], 0, CHAN_Y);
       FETCH(&r[2], 0, CHAN_Z);
 
-      if (projected) {
-         FETCH(&r[3], 0, CHAN_W);
-         micro_div( &r[0], &r[0], &r[3] );
-         micro_div( &r[1], &r[1], &r[3] );
-         micro_div( &r[2], &r[2], &r[3] );
+      if (modifier == TEX_MODIFIER_PROJECTED) {
+         micro_div(&r[0], &r[0], &r[3]);
+         micro_div(&r[1], &r[1], &r[3]);
+         micro_div(&r[2], &r[2], &r[3]);
       }
 
-      if (biasLod) {
-         FETCH(&r[3], 0, CHAN_W);
-         lodBias = r[3].f[0];
-      }
-      else
-         lodBias = 0.0;
+      fetch_texel(mach->Samplers[unit],
+                  &r[0], &r[1], &r[2], lod,
+                  control,
+                  &r[0], &r[1], &r[2], &r[3]);
+      break;
+
+   default:
+      assert(0);
+   }
+
+   FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
+      STORE(&r[chan_index], 0, chan_index);
+   }
+}
+
+static void
+exec_txd(struct tgsi_exec_machine *mach,
+         const struct tgsi_full_instruction *inst)
+{
+   const uint unit = inst->Src[3].Register.Index;
+   union tgsi_exec_channel r[4];
+   uint chan_index;
+
+   /*
+    * XXX: This is fake TXD -- the derivatives are not taken into account, yet.
+    */
+
+   switch (inst->Texture.Texture) {
+   case TGSI_TEXTURE_1D:
+   case TGSI_TEXTURE_SHADOW1D:
+
+      FETCH(&r[0], 0, CHAN_X);
+
+      fetch_texel(mach->Samplers[unit],
+                  &r[0], &ZeroVec, &ZeroVec, &ZeroVec,   /* S, T, P, BIAS */
+                  tgsi_sampler_lod_bias,
+                  &r[0], &r[1], &r[2], &r[3]);           /* R, G, B, A */
+      break;
+
+   case TGSI_TEXTURE_2D:
+   case TGSI_TEXTURE_RECT:
+   case TGSI_TEXTURE_SHADOW2D:
+   case TGSI_TEXTURE_SHADOWRECT:
+
+      FETCH(&r[0], 0, CHAN_X);
+      FETCH(&r[1], 0, CHAN_Y);
+      FETCH(&r[2], 0, CHAN_Z);
+
+      fetch_texel(mach->Samplers[unit],
+                  &r[0], &r[1], &r[2], &ZeroVec,   /* inputs */
+                  tgsi_sampler_lod_bias,
+                  &r[0], &r[1], &r[2], &r[3]);     /* outputs */
+      break;
+
+   case TGSI_TEXTURE_3D:
+   case TGSI_TEXTURE_CUBE:
+
+      FETCH(&r[0], 0, CHAN_X);
+      FETCH(&r[1], 0, CHAN_Y);
+      FETCH(&r[2], 0, CHAN_Z);
 
       fetch_texel(mach->Samplers[unit],
-                  &r[0], &r[1], &r[2], lodBias,
+                  &r[0], &r[1], &r[2], &ZeroVec,
+                  tgsi_sampler_lod_bias,
                   &r[0], &r[1], &r[2], &r[3]);
       break;
 
    default:
-      assert (0);
+      assert(0);
    }
 
-   FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-      STORE( &r[chan_index], 0, chan_index );
+   FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
+      STORE(&r[chan_index], 0, chan_index);
    }
 }
 
@@ -1954,53 +1752,59 @@ typedef void (* eval_coef_func)(
    unsigned chan );
 
 static void
-exec_declaration(
-   struct tgsi_exec_machine *mach,
-   const struct tgsi_full_declaration *decl )
+exec_declaration(struct tgsi_exec_machine *mach,
+                 const struct tgsi_full_declaration *decl)
 {
-   if( mach->Processor == TGSI_PROCESSOR_FRAGMENT ) {
-      if( decl->Declaration.File == TGSI_FILE_INPUT ) {
-         unsigned first, last, mask;
-         eval_coef_func eval;
+   if (mach->Processor == TGSI_PROCESSOR_FRAGMENT) {
+      if (decl->Declaration.File == TGSI_FILE_INPUT ||
+          decl->Declaration.File == TGSI_FILE_SYSTEM_VALUE) {
+         uint first, last, mask;
 
-         first = decl->DeclarationRange.First;
-         last = decl->DeclarationRange.Last;
+         first = decl->Range.First;
+         last = decl->Range.Last;
          mask = decl->Declaration.UsageMask;
 
-         switch( decl->Declaration.Interpolate ) {
-         case TGSI_INTERPOLATE_CONSTANT:
-            eval = eval_constant_coef;
-            break;
-
-         case TGSI_INTERPOLATE_LINEAR:
-            eval = eval_linear_coef;
-            break;
+         if (decl->Semantic.Name == TGSI_SEMANTIC_POSITION) {
+            assert(decl->Semantic.Index == 0);
+            assert(first == last);
+            assert(mask == TGSI_WRITEMASK_XYZW);
 
-         case TGSI_INTERPOLATE_PERSPECTIVE:
-            eval = eval_perspective_coef;
-            break;
-
-         default:
-            eval = NULL;
-            assert( 0 );
-         }
+            mach->Inputs[first] = mach->QuadPos;
+         } else if (decl->Semantic.Name == TGSI_SEMANTIC_FACE) {
+            uint i;
 
-         if( mask == TGSI_WRITEMASK_XYZW ) {
-            unsigned i, j;
+            assert(decl->Semantic.Index == 0);
+            assert(first == last);
 
-            for( i = first; i <= last; i++ ) {
-               for( j = 0; j < NUM_CHANNELS; j++ ) {
-                  eval( mach, i, j );
-               }
+            for (i = 0; i < QUAD_SIZE; i++) {
+               mach->Inputs[first].xyzw[0].f[i] = mach->Face;
+            }
+         } else {
+            eval_coef_func eval;
+            uint i, j;
+
+            switch (decl->Declaration.Interpolate) {
+            case TGSI_INTERPOLATE_CONSTANT:
+               eval = eval_constant_coef;
+               break;
+
+            case TGSI_INTERPOLATE_LINEAR:
+               eval = eval_linear_coef;
+               break;
+
+            case TGSI_INTERPOLATE_PERSPECTIVE:
+               eval = eval_perspective_coef;
+               break;
+
+            default:
+               assert(0);
+               return;
             }
-         }
-         else {
-            unsigned i, j;
 
-            for( j = 0; j < NUM_CHANNELS; j++ ) {
-               if( mask & (1 << j) ) {
-                  for( i = first; i <= last; i++ ) {
-                     eval( mach, i, j );
+            for (j = 0; j < NUM_CHANNELS; j++) {
+               if (mask & (1 << j)) {
+                  for (i = first; i <= last; i++) {
+                     eval(mach, i, j);
                   }
                }
             }
@@ -2009,108 +1813,656 @@ exec_declaration(
    }
 }
 
+typedef void (* micro_op)(union tgsi_exec_channel *dst,
+                          const union tgsi_exec_channel *src);
+
 static void
-exec_instruction(
-   struct tgsi_exec_machine *mach,
-   const struct tgsi_full_instruction *inst,
-   int *pc )
+exec_scalar_unary(struct tgsi_exec_machine *mach,
+                  const struct tgsi_full_instruction *inst,
+                  micro_op op,
+                  enum tgsi_exec_datatype dst_datatype,
+                  enum tgsi_exec_datatype src_datatype)
 {
-   uint chan_index;
-   union tgsi_exec_channel r[10];
-
-   (*pc)++;
+   unsigned int chan;
+   union tgsi_exec_channel src;
+   union tgsi_exec_channel dst;
 
-   switch (inst->Instruction.Opcode) {
-   case TGSI_OPCODE_ARL:
-   case TGSI_OPCODE_FLR:
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         FETCH( &r[0], 0, chan_index );
-         micro_flr( &r[0], &r[0] );
-         STORE( &r[0], 0, chan_index );
+   fetch_source(mach, &src, &inst->Src[0], CHAN_X, src_datatype);
+   op(&dst, &src);
+   for (chan = 0; chan < NUM_CHANNELS; chan++) {
+      if (inst->Dst[0].Register.WriteMask & (1 << chan)) {
+         store_dest(mach, &dst, &inst->Dst[0], inst, chan, dst_datatype);
       }
-      break;
+   }
+}
 
-   case TGSI_OPCODE_MOV:
-   case TGSI_OPCODE_SWZ:
-      if (inst->Flags & SOA_DEPENDENCY_FLAG) {
-         /* Do all fetches into temp regs, then do all stores to avoid
-          * intermediate/accidental clobbering.  This could be done all the
-          * time for MOV but for other instructions we'll need more temps...
-          */
-         FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-            FETCH( &r[chan_index], 0, chan_index );
-         }
-         FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-            STORE( &r[chan_index], 0, chan_index );
-         }
+static void
+exec_vector_unary(struct tgsi_exec_machine *mach,
+                  const struct tgsi_full_instruction *inst,
+                  micro_op op,
+                  enum tgsi_exec_datatype dst_datatype,
+                  enum tgsi_exec_datatype src_datatype)
+{
+   unsigned int chan;
+   struct tgsi_exec_vector dst;
+
+   for (chan = 0; chan < NUM_CHANNELS; chan++) {
+      if (inst->Dst[0].Register.WriteMask & (1 << chan)) {
+         union tgsi_exec_channel src;
+
+         fetch_source(mach, &src, &inst->Src[0], chan, src_datatype);
+         op(&dst.xyzw[chan], &src);
       }
-      else {
-         FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-            FETCH( &r[0], 0, chan_index );
-            STORE( &r[0], 0, chan_index );
-         }
+   }
+   for (chan = 0; chan < NUM_CHANNELS; chan++) {
+      if (inst->Dst[0].Register.WriteMask & (1 << chan)) {
+         store_dest(mach, &dst.xyzw[chan], &inst->Dst[0], inst, chan, dst_datatype);
       }
-      break;
+   }
+}
 
-   case TGSI_OPCODE_LIT:
-      if (IS_CHANNEL_ENABLED( *inst, CHAN_X )) {
-         STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_X );
+static void
+exec_vector_binary(struct tgsi_exec_machine *mach,
+                   const struct tgsi_full_instruction *inst,
+                   micro_op op,
+                   enum tgsi_exec_datatype dst_datatype,
+                   enum tgsi_exec_datatype src_datatype)
+{
+   unsigned int chan;
+   struct tgsi_exec_vector dst;
+
+   for (chan = 0; chan < NUM_CHANNELS; chan++) {
+      if (inst->Dst[0].Register.WriteMask & (1 << chan)) {
+         union tgsi_exec_channel src[2];
+
+         fetch_source(mach, &src[0], &inst->Src[0], chan, src_datatype);
+         fetch_source(mach, &src[1], &inst->Src[1], chan, src_datatype);
+         op(&dst.xyzw[chan], src);
+      }
+   }
+   for (chan = 0; chan < NUM_CHANNELS; chan++) {
+      if (inst->Dst[0].Register.WriteMask & (1 << chan)) {
+         store_dest(mach, &dst.xyzw[chan], &inst->Dst[0], inst, chan, dst_datatype);
       }
+   }
+}
 
-      if (IS_CHANNEL_ENABLED( *inst, CHAN_Y ) || IS_CHANNEL_ENABLED( *inst, CHAN_Z )) {
-         FETCH( &r[0], 0, CHAN_X );
-         if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) {
-            micro_max( &r[0], &r[0], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] );
-            STORE( &r[0], 0, CHAN_Y );
-         }
+static void
+exec_vector_trinary(struct tgsi_exec_machine *mach,
+                    const struct tgsi_full_instruction *inst,
+                    micro_op op,
+                    enum tgsi_exec_datatype dst_datatype,
+                    enum tgsi_exec_datatype src_datatype)
+{
+   unsigned int chan;
+   struct tgsi_exec_vector dst;
 
-         if (IS_CHANNEL_ENABLED( *inst, CHAN_Z )) {
-            FETCH( &r[1], 0, CHAN_Y );
-            micro_max( &r[1], &r[1], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] );
+   for (chan = 0; chan < NUM_CHANNELS; chan++) {
+      if (inst->Dst[0].Register.WriteMask & (1 << chan)) {
+         union tgsi_exec_channel src[3];
 
-            FETCH( &r[2], 0, CHAN_W );
-            micro_min( &r[2], &r[2], &mach->Temps[TEMP_128_I].xyzw[TEMP_128_C] );
-            micro_max( &r[2], &r[2], &mach->Temps[TEMP_M128_I].xyzw[TEMP_M128_C] );
-            micro_pow( &r[1], &r[1], &r[2] );
-            micro_lt( &r[0], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], &r[0], &r[1], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] );
-            STORE( &r[0], 0, CHAN_Z );
-         }
+         fetch_source(mach, &src[0], &inst->Src[0], chan, src_datatype);
+         fetch_source(mach, &src[1], &inst->Src[1], chan, src_datatype);
+         fetch_source(mach, &src[2], &inst->Src[2], chan, src_datatype);
+         op(&dst.xyzw[chan], src);
       }
+   }
+   for (chan = 0; chan < NUM_CHANNELS; chan++) {
+      if (inst->Dst[0].Register.WriteMask & (1 << chan)) {
+         store_dest(mach, &dst.xyzw[chan], &inst->Dst[0], inst, chan, dst_datatype);
+      }
+   }
+}
 
-      if (IS_CHANNEL_ENABLED( *inst, CHAN_W )) {
-         STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W );
+static void
+exec_dp3(struct tgsi_exec_machine *mach,
+         const struct tgsi_full_instruction *inst)
+{
+   unsigned int chan;
+   union tgsi_exec_channel arg[3];
+
+   fetch_source(mach, &arg[0], &inst->Src[0], CHAN_X, TGSI_EXEC_DATA_FLOAT);
+   fetch_source(mach, &arg[1], &inst->Src[1], CHAN_X, TGSI_EXEC_DATA_FLOAT);
+   micro_mul(&arg[2], &arg[0], &arg[1]);
+
+   for (chan = CHAN_Y; chan <= CHAN_Z; chan++) {
+      fetch_source(mach, &arg[0], &inst->Src[0], chan, TGSI_EXEC_DATA_FLOAT);
+      fetch_source(mach, &arg[1], &inst->Src[1], chan, TGSI_EXEC_DATA_FLOAT);
+      micro_mad(&arg[2], arg);
+   }
+
+   for (chan = 0; chan < NUM_CHANNELS; chan++) {
+      if (inst->Dst[0].Register.WriteMask & (1 << chan)) {
+         store_dest(mach, &arg[2], &inst->Dst[0], inst, chan, TGSI_EXEC_DATA_FLOAT);
       }
-      break;
+   }
+}
 
-   case TGSI_OPCODE_RCP:
-   /* TGSI_OPCODE_RECIP */
-      FETCH( &r[0], 0, CHAN_X );
-      micro_div( &r[0], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], &r[0] );
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         STORE( &r[0], 0, chan_index );
+static void
+exec_dp4(struct tgsi_exec_machine *mach,
+         const struct tgsi_full_instruction *inst)
+{
+   unsigned int chan;
+   union tgsi_exec_channel arg[3];
+
+   fetch_source(mach, &arg[0], &inst->Src[0], CHAN_X, TGSI_EXEC_DATA_FLOAT);
+   fetch_source(mach, &arg[1], &inst->Src[1], CHAN_X, TGSI_EXEC_DATA_FLOAT);
+   micro_mul(&arg[2], &arg[0], &arg[1]);
+
+   for (chan = CHAN_Y; chan <= CHAN_W; chan++) {
+      fetch_source(mach, &arg[0], &inst->Src[0], chan, TGSI_EXEC_DATA_FLOAT);
+      fetch_source(mach, &arg[1], &inst->Src[1], chan, TGSI_EXEC_DATA_FLOAT);
+      micro_mad(&arg[2], arg);
+   }
+
+   for (chan = 0; chan < NUM_CHANNELS; chan++) {
+      if (inst->Dst[0].Register.WriteMask & (1 << chan)) {
+         store_dest(mach, &arg[2], &inst->Dst[0], inst, chan, TGSI_EXEC_DATA_FLOAT);
       }
-      break;
+   }
+}
 
-   case TGSI_OPCODE_RSQ:
-   /* TGSI_OPCODE_RECIPSQRT */
-      FETCH( &r[0], 0, CHAN_X );
-      micro_abs( &r[0], &r[0] );
-      micro_sqrt( &r[0], &r[0] );
-      micro_div( &r[0], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], &r[0] );
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         STORE( &r[0], 0, chan_index );
+static void
+exec_dp2a(struct tgsi_exec_machine *mach,
+          const struct tgsi_full_instruction *inst)
+{
+   unsigned int chan;
+   union tgsi_exec_channel arg[3];
+
+   fetch_source(mach, &arg[0], &inst->Src[0], CHAN_X, TGSI_EXEC_DATA_FLOAT);
+   fetch_source(mach, &arg[1], &inst->Src[1], CHAN_X, TGSI_EXEC_DATA_FLOAT);
+   micro_mul(&arg[2], &arg[0], &arg[1]);
+
+   fetch_source(mach, &arg[0], &inst->Src[0], CHAN_Y, TGSI_EXEC_DATA_FLOAT);
+   fetch_source(mach, &arg[1], &inst->Src[1], CHAN_Y, TGSI_EXEC_DATA_FLOAT);
+   micro_mad(&arg[0], arg);
+
+   fetch_source(mach, &arg[1], &inst->Src[2], CHAN_X, TGSI_EXEC_DATA_FLOAT);
+   micro_add(&arg[0], &arg[0], &arg[1]);
+
+   for (chan = 0; chan < NUM_CHANNELS; chan++) {
+      if (inst->Dst[0].Register.WriteMask & (1 << chan)) {
+         store_dest(mach, &arg[0], &inst->Dst[0], inst, chan, TGSI_EXEC_DATA_FLOAT);
       }
-      break;
+   }
+}
 
-   case TGSI_OPCODE_EXP:
-      FETCH( &r[0], 0, CHAN_X );
-      micro_flr( &r[1], &r[0] );  /* r1 = floor(r0) */
-      if (IS_CHANNEL_ENABLED( *inst, CHAN_X )) {
-         micro_exp2( &r[2], &r[1] );       /* r2 = 2 ^ r1 */
-         STORE( &r[2], 0, CHAN_X );        /* store r2 */
+static void
+exec_dph(struct tgsi_exec_machine *mach,
+         const struct tgsi_full_instruction *inst)
+{
+   unsigned int chan;
+   union tgsi_exec_channel arg[3];
+
+   fetch_source(mach, &arg[0], &inst->Src[0], CHAN_X, TGSI_EXEC_DATA_FLOAT);
+   fetch_source(mach, &arg[1], &inst->Src[1], CHAN_X, TGSI_EXEC_DATA_FLOAT);
+   micro_mul(&arg[2], &arg[0], &arg[1]);
+
+   fetch_source(mach, &arg[0], &inst->Src[0], CHAN_Y, TGSI_EXEC_DATA_FLOAT);
+   fetch_source(mach, &arg[1], &inst->Src[1], CHAN_Y, TGSI_EXEC_DATA_FLOAT);
+   micro_mad(&arg[2], arg);
+
+   fetch_source(mach, &arg[0], &inst->Src[0], CHAN_Z, TGSI_EXEC_DATA_FLOAT);
+   fetch_source(mach, &arg[1], &inst->Src[1], CHAN_Z, TGSI_EXEC_DATA_FLOAT);
+   micro_mad(&arg[0], arg);
+
+   fetch_source(mach, &arg[1], &inst->Src[1], CHAN_W, TGSI_EXEC_DATA_FLOAT);
+   micro_add(&arg[0], &arg[0], &arg[1]);
+
+   for (chan = 0; chan < NUM_CHANNELS; chan++) {
+      if (inst->Dst[0].Register.WriteMask & (1 << chan)) {
+         store_dest(mach, &arg[0], &inst->Dst[0], inst, chan, TGSI_EXEC_DATA_FLOAT);
       }
-      if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) {
-         micro_sub( &r[2], &r[0], &r[1] ); /* r2 = r0 - r1 */
+   }
+}
+
+static void
+exec_dp2(struct tgsi_exec_machine *mach,
+         const struct tgsi_full_instruction *inst)
+{
+   unsigned int chan;
+   union tgsi_exec_channel arg[3];
+
+   fetch_source(mach, &arg[0], &inst->Src[0], CHAN_X, TGSI_EXEC_DATA_FLOAT);
+   fetch_source(mach, &arg[1], &inst->Src[1], CHAN_X, TGSI_EXEC_DATA_FLOAT);
+   micro_mul(&arg[2], &arg[0], &arg[1]);
+
+   fetch_source(mach, &arg[0], &inst->Src[0], CHAN_Y, TGSI_EXEC_DATA_FLOAT);
+   fetch_source(mach, &arg[1], &inst->Src[1], CHAN_Y, TGSI_EXEC_DATA_FLOAT);
+   micro_mad(&arg[2], arg);
+
+   for (chan = 0; chan < NUM_CHANNELS; chan++) {
+      if (inst->Dst[0].Register.WriteMask & (1 << chan)) {
+         store_dest(mach, &arg[2], &inst->Dst[0], inst, chan, TGSI_EXEC_DATA_FLOAT);
+      }
+   }
+}
+
+static void
+exec_break(struct tgsi_exec_machine *mach)
+{
+   if (mach->BreakType == TGSI_EXEC_BREAK_INSIDE_LOOP) {
+      /* turn off loop channels for each enabled exec channel */
+      mach->LoopMask &= ~mach->ExecMask;
+      /* Todo: if mach->LoopMask == 0, jump to end of loop */
+      UPDATE_EXEC_MASK(mach);
+   } else {
+      assert(mach->BreakType == TGSI_EXEC_BREAK_INSIDE_SWITCH);
+
+      mach->Switch.mask = 0x0;
+
+      UPDATE_EXEC_MASK(mach);
+   }
+}
+
+static void
+exec_switch(struct tgsi_exec_machine *mach,
+            const struct tgsi_full_instruction *inst)
+{
+   assert(mach->SwitchStackTop < TGSI_EXEC_MAX_SWITCH_NESTING);
+   assert(mach->BreakStackTop < TGSI_EXEC_MAX_BREAK_STACK);
+
+   mach->SwitchStack[mach->SwitchStackTop++] = mach->Switch;
+   fetch_source(mach, &mach->Switch.selector, &inst->Src[0], CHAN_X, TGSI_EXEC_DATA_UINT);
+   mach->Switch.mask = 0x0;
+   mach->Switch.defaultMask = 0x0;
+
+   mach->BreakStack[mach->BreakStackTop++] = mach->BreakType;
+   mach->BreakType = TGSI_EXEC_BREAK_INSIDE_SWITCH;
+
+   UPDATE_EXEC_MASK(mach);
+}
+
+static void
+exec_case(struct tgsi_exec_machine *mach,
+          const struct tgsi_full_instruction *inst)
+{
+   uint prevMask = mach->SwitchStack[mach->SwitchStackTop - 1].mask;
+   union tgsi_exec_channel src;
+   uint mask = 0;
+
+   fetch_source(mach, &src, &inst->Src[0], CHAN_X, TGSI_EXEC_DATA_UINT);
+
+   if (mach->Switch.selector.u[0] == src.u[0]) {
+      mask |= 0x1;
+   }
+   if (mach->Switch.selector.u[1] == src.u[1]) {
+      mask |= 0x2;
+   }
+   if (mach->Switch.selector.u[2] == src.u[2]) {
+      mask |= 0x4;
+   }
+   if (mach->Switch.selector.u[3] == src.u[3]) {
+      mask |= 0x8;
+   }
+
+   mach->Switch.defaultMask |= mask;
+
+   mach->Switch.mask |= mask & prevMask;
+
+   UPDATE_EXEC_MASK(mach);
+}
+
+static void
+exec_default(struct tgsi_exec_machine *mach)
+{
+   uint prevMask = mach->SwitchStack[mach->SwitchStackTop - 1].mask;
+
+   mach->Switch.mask |= ~mach->Switch.defaultMask & prevMask;
+
+   UPDATE_EXEC_MASK(mach);
+}
+
+static void
+exec_endswitch(struct tgsi_exec_machine *mach)
+{
+   mach->Switch = mach->SwitchStack[--mach->SwitchStackTop];
+   mach->BreakType = mach->BreakStack[--mach->BreakStackTop];
+
+   UPDATE_EXEC_MASK(mach);
+}
+
+static void
+micro_i2f(union tgsi_exec_channel *dst,
+          const union tgsi_exec_channel *src)
+{
+   dst->f[0] = (float)src->i[0];
+   dst->f[1] = (float)src->i[1];
+   dst->f[2] = (float)src->i[2];
+   dst->f[3] = (float)src->i[3];
+}
+
+static void
+micro_not(union tgsi_exec_channel *dst,
+          const union tgsi_exec_channel *src)
+{
+   dst->u[0] = ~src->u[0];
+   dst->u[1] = ~src->u[1];
+   dst->u[2] = ~src->u[2];
+   dst->u[3] = ~src->u[3];
+}
+
+static void
+micro_shl(union tgsi_exec_channel *dst,
+          const union tgsi_exec_channel *src)
+{
+   dst->u[0] = src[0].u[0] << src[1].u[0];
+   dst->u[1] = src[0].u[1] << src[1].u[1];
+   dst->u[2] = src[0].u[2] << src[1].u[2];
+   dst->u[3] = src[0].u[3] << src[1].u[3];
+}
+
+static void
+micro_and(union tgsi_exec_channel *dst,
+          const union tgsi_exec_channel *src)
+{
+   dst->u[0] = src[0].u[0] & src[1].u[0];
+   dst->u[1] = src[0].u[1] & src[1].u[1];
+   dst->u[2] = src[0].u[2] & src[1].u[2];
+   dst->u[3] = src[0].u[3] & src[1].u[3];
+}
+
+static void
+micro_or(union tgsi_exec_channel *dst,
+         const union tgsi_exec_channel *src)
+{
+   dst->u[0] = src[0].u[0] | src[1].u[0];
+   dst->u[1] = src[0].u[1] | src[1].u[1];
+   dst->u[2] = src[0].u[2] | src[1].u[2];
+   dst->u[3] = src[0].u[3] | src[1].u[3];
+}
+
+static void
+micro_xor(union tgsi_exec_channel *dst,
+          const union tgsi_exec_channel *src)
+{
+   dst->u[0] = src[0].u[0] ^ src[1].u[0];
+   dst->u[1] = src[0].u[1] ^ src[1].u[1];
+   dst->u[2] = src[0].u[2] ^ src[1].u[2];
+   dst->u[3] = src[0].u[3] ^ src[1].u[3];
+}
+
+static void
+micro_f2i(union tgsi_exec_channel *dst,
+          const union tgsi_exec_channel *src)
+{
+   dst->i[0] = (int)src->f[0];
+   dst->i[1] = (int)src->f[1];
+   dst->i[2] = (int)src->f[2];
+   dst->i[3] = (int)src->f[3];
+}
+
+static void
+micro_idiv(union tgsi_exec_channel *dst,
+           const union tgsi_exec_channel *src)
+{
+   dst->i[0] = src[0].i[0] / src[1].i[0];
+   dst->i[1] = src[0].i[1] / src[1].i[1];
+   dst->i[2] = src[0].i[2] / src[1].i[2];
+   dst->i[3] = src[0].i[3] / src[1].i[3];
+}
+
+static void
+micro_imax(union tgsi_exec_channel *dst,
+           const union tgsi_exec_channel *src)
+{
+   dst->i[0] = src[0].i[0] > src[1].i[0] ? src[0].i[0] : src[1].i[0];
+   dst->i[1] = src[0].i[1] > src[1].i[1] ? src[0].i[1] : src[1].i[1];
+   dst->i[2] = src[0].i[2] > src[1].i[2] ? src[0].i[2] : src[1].i[2];
+   dst->i[3] = src[0].i[3] > src[1].i[3] ? src[0].i[3] : src[1].i[3];
+}
+
+static void
+micro_imin(union tgsi_exec_channel *dst,
+           const union tgsi_exec_channel *src)
+{
+   dst->i[0] = src[0].i[0] < src[1].i[0] ? src[0].i[0] : src[1].i[0];
+   dst->i[1] = src[0].i[1] < src[1].i[1] ? src[0].i[1] : src[1].i[1];
+   dst->i[2] = src[0].i[2] < src[1].i[2] ? src[0].i[2] : src[1].i[2];
+   dst->i[3] = src[0].i[3] < src[1].i[3] ? src[0].i[3] : src[1].i[3];
+}
+
+static void
+micro_isge(union tgsi_exec_channel *dst,
+           const union tgsi_exec_channel *src)
+{
+   dst->i[0] = src[0].i[0] >= src[1].i[0] ? -1 : 0;
+   dst->i[1] = src[0].i[1] >= src[1].i[1] ? -1 : 0;
+   dst->i[2] = src[0].i[2] >= src[1].i[2] ? -1 : 0;
+   dst->i[3] = src[0].i[3] >= src[1].i[3] ? -1 : 0;
+}
+
+static void
+micro_ishr(union tgsi_exec_channel *dst,
+           const union tgsi_exec_channel *src)
+{
+   dst->i[0] = src[0].i[0] >> src[1].i[0];
+   dst->i[1] = src[0].i[1] >> src[1].i[1];
+   dst->i[2] = src[0].i[2] >> src[1].i[2];
+   dst->i[3] = src[0].i[3] >> src[1].i[3];
+}
+
+static void
+micro_islt(union tgsi_exec_channel *dst,
+           const union tgsi_exec_channel *src)
+{
+   dst->i[0] = src[0].i[0] < src[1].i[0] ? -1 : 0;
+   dst->i[1] = src[0].i[1] < src[1].i[1] ? -1 : 0;
+   dst->i[2] = src[0].i[2] < src[1].i[2] ? -1 : 0;
+   dst->i[3] = src[0].i[3] < src[1].i[3] ? -1 : 0;
+}
+
+static void
+micro_f2u(union tgsi_exec_channel *dst,
+          const union tgsi_exec_channel *src)
+{
+   dst->u[0] = (uint)src->f[0];
+   dst->u[1] = (uint)src->f[1];
+   dst->u[2] = (uint)src->f[2];
+   dst->u[3] = (uint)src->f[3];
+}
+
+static void
+micro_u2f(union tgsi_exec_channel *dst,
+          const union tgsi_exec_channel *src)
+{
+   dst->f[0] = (float)src->u[0];
+   dst->f[1] = (float)src->u[1];
+   dst->f[2] = (float)src->u[2];
+   dst->f[3] = (float)src->u[3];
+}
+
+static void
+micro_uadd(union tgsi_exec_channel *dst,
+           const union tgsi_exec_channel *src)
+{
+   dst->u[0] = src[0].u[0] + src[1].u[0];
+   dst->u[1] = src[0].u[1] + src[1].u[1];
+   dst->u[2] = src[0].u[2] + src[1].u[2];
+   dst->u[3] = src[0].u[3] + src[1].u[3];
+}
+
+static void
+micro_udiv(union tgsi_exec_channel *dst,
+           const union tgsi_exec_channel *src)
+{
+   dst->u[0] = src[0].u[0] / src[1].u[0];
+   dst->u[1] = src[0].u[1] / src[1].u[1];
+   dst->u[2] = src[0].u[2] / src[1].u[2];
+   dst->u[3] = src[0].u[3] / src[1].u[3];
+}
+
+static void
+micro_umad(union tgsi_exec_channel *dst,
+           const union tgsi_exec_channel *src)
+{
+   dst->u[0] = src[0].u[0] * src[1].u[0] + src[2].u[0];
+   dst->u[1] = src[0].u[1] * src[1].u[1] + src[2].u[1];
+   dst->u[2] = src[0].u[2] * src[1].u[2] + src[2].u[2];
+   dst->u[3] = src[0].u[3] * src[1].u[3] + src[2].u[3];
+}
+
+static void
+micro_umax(union tgsi_exec_channel *dst,
+           const union tgsi_exec_channel *src)
+{
+   dst->u[0] = src[0].u[0] > src[1].u[0] ? src[0].u[0] : src[1].u[0];
+   dst->u[1] = src[0].u[1] > src[1].u[1] ? src[0].u[1] : src[1].u[1];
+   dst->u[2] = src[0].u[2] > src[1].u[2] ? src[0].u[2] : src[1].u[2];
+   dst->u[3] = src[0].u[3] > src[1].u[3] ? src[0].u[3] : src[1].u[3];
+}
+
+static void
+micro_umin(union tgsi_exec_channel *dst,
+           const union tgsi_exec_channel *src)
+{
+   dst->u[0] = src[0].u[0] < src[1].u[0] ? src[0].u[0] : src[1].u[0];
+   dst->u[1] = src[0].u[1] < src[1].u[1] ? src[0].u[1] : src[1].u[1];
+   dst->u[2] = src[0].u[2] < src[1].u[2] ? src[0].u[2] : src[1].u[2];
+   dst->u[3] = src[0].u[3] < src[1].u[3] ? src[0].u[3] : src[1].u[3];
+}
+
+static void
+micro_umod(union tgsi_exec_channel *dst,
+           const union tgsi_exec_channel *src)
+{
+   dst->u[0] = src[0].u[0] % src[1].u[0];
+   dst->u[1] = src[0].u[1] % src[1].u[1];
+   dst->u[2] = src[0].u[2] % src[1].u[2];
+   dst->u[3] = src[0].u[3] % src[1].u[3];
+}
+
+static void
+micro_umul(union tgsi_exec_channel *dst,
+           const union tgsi_exec_channel *src)
+{
+   dst->u[0] = src[0].u[0] * src[1].u[0];
+   dst->u[1] = src[0].u[1] * src[1].u[1];
+   dst->u[2] = src[0].u[2] * src[1].u[2];
+   dst->u[3] = src[0].u[3] * src[1].u[3];
+}
+
+static void
+micro_useq(union tgsi_exec_channel *dst,
+           const union tgsi_exec_channel *src)
+{
+   dst->u[0] = src[0].u[0] == src[1].u[0] ? ~0 : 0;
+   dst->u[1] = src[0].u[1] == src[1].u[1] ? ~0 : 0;
+   dst->u[2] = src[0].u[2] == src[1].u[2] ? ~0 : 0;
+   dst->u[3] = src[0].u[3] == src[1].u[3] ? ~0 : 0;
+}
+
+static void
+micro_usge(union tgsi_exec_channel *dst,
+           const union tgsi_exec_channel *src)
+{
+   dst->u[0] = src[0].u[0] >= src[1].u[0] ? ~0 : 0;
+   dst->u[1] = src[0].u[1] >= src[1].u[1] ? ~0 : 0;
+   dst->u[2] = src[0].u[2] >= src[1].u[2] ? ~0 : 0;
+   dst->u[3] = src[0].u[3] >= src[1].u[3] ? ~0 : 0;
+}
+
+static void
+micro_ushr(union tgsi_exec_channel *dst,
+           const union tgsi_exec_channel *src)
+{
+   dst->u[0] = src[0].u[0] >> src[1].u[0];
+   dst->u[1] = src[0].u[1] >> src[1].u[1];
+   dst->u[2] = src[0].u[2] >> src[1].u[2];
+   dst->u[3] = src[0].u[3] >> src[1].u[3];
+}
+
+static void
+micro_uslt(union tgsi_exec_channel *dst,
+           const union tgsi_exec_channel *src)
+{
+   dst->u[0] = src[0].u[0] < src[1].u[0] ? ~0 : 0;
+   dst->u[1] = src[0].u[1] < src[1].u[1] ? ~0 : 0;
+   dst->u[2] = src[0].u[2] < src[1].u[2] ? ~0 : 0;
+   dst->u[3] = src[0].u[3] < src[1].u[3] ? ~0 : 0;
+}
+
+static void
+micro_usne(union tgsi_exec_channel *dst,
+           const union tgsi_exec_channel *src)
+{
+   dst->u[0] = src[0].u[0] != src[1].u[0] ? ~0 : 0;
+   dst->u[1] = src[0].u[1] != src[1].u[1] ? ~0 : 0;
+   dst->u[2] = src[0].u[2] != src[1].u[2] ? ~0 : 0;
+   dst->u[3] = src[0].u[3] != src[1].u[3] ? ~0 : 0;
+}
+
+static void
+exec_instruction(
+   struct tgsi_exec_machine *mach,
+   const struct tgsi_full_instruction *inst,
+   int *pc )
+{
+   uint chan_index;
+   union tgsi_exec_channel r[10];
+   union tgsi_exec_channel d[8];
+
+   (*pc)++;
+
+   switch (inst->Instruction.Opcode) {
+   case TGSI_OPCODE_ARL:
+      exec_vector_unary(mach, inst, micro_arl, TGSI_EXEC_DATA_INT, TGSI_EXEC_DATA_FLOAT);
+      break;
+
+   case TGSI_OPCODE_MOV:
+      exec_vector_unary(mach, inst, micro_mov, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_FLOAT);
+      break;
+
+   case TGSI_OPCODE_LIT:
+      if (IS_CHANNEL_ENABLED( *inst, CHAN_Y ) || IS_CHANNEL_ENABLED( *inst, CHAN_Z )) {
+         FETCH( &r[0], 0, CHAN_X );
+         if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) {
+            micro_max(&d[CHAN_Y], &r[0], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C]);
+         }
+
+         if (IS_CHANNEL_ENABLED( *inst, CHAN_Z )) {
+            FETCH( &r[1], 0, CHAN_Y );
+            micro_max( &r[1], &r[1], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] );
+
+            FETCH( &r[2], 0, CHAN_W );
+            micro_min( &r[2], &r[2], &mach->Temps[TEMP_128_I].xyzw[TEMP_128_C] );
+            micro_max( &r[2], &r[2], &mach->Temps[TEMP_M128_I].xyzw[TEMP_M128_C] );
+            micro_pow( &r[1], &r[1], &r[2] );
+            micro_lt(&d[CHAN_Z], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], &r[0], &r[1], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C]);
+         }
+
+         if (IS_CHANNEL_ENABLED(*inst, CHAN_Y)) {
+            STORE(&d[CHAN_Y], 0, CHAN_Y);
+         }
+         if (IS_CHANNEL_ENABLED(*inst, CHAN_Z)) {
+            STORE(&d[CHAN_Z], 0, CHAN_Z);
+         }
+      }
+      if (IS_CHANNEL_ENABLED( *inst, CHAN_X )) {
+         STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_X );
+      }
+      if (IS_CHANNEL_ENABLED( *inst, CHAN_W )) {
+         STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W );
+      }
+      break;
+
+   case TGSI_OPCODE_RCP:
+      exec_scalar_unary(mach, inst, micro_rcp, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
+      break;
+
+   case TGSI_OPCODE_RSQ:
+      exec_scalar_unary(mach, inst, micro_rsq, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
+      break;
+
+   case TGSI_OPCODE_EXP:
+      FETCH( &r[0], 0, CHAN_X );
+      micro_flr( &r[1], &r[0] );  /* r1 = floor(r0) */
+      if (IS_CHANNEL_ENABLED( *inst, CHAN_X )) {
+         micro_exp2( &r[2], &r[1] );       /* r2 = 2 ^ r1 */
+         STORE( &r[2], 0, CHAN_X );        /* store r2 */
+      }
+      if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) {
+         micro_sub( &r[2], &r[0], &r[1] ); /* r2 = r0 - r1 */
          STORE( &r[2], 0, CHAN_Y );        /* store r2 */
       }
       if (IS_CHANNEL_ENABLED( *inst, CHAN_Z )) {
@@ -2144,14 +2496,13 @@ exec_instruction(
       break;
 
    case TGSI_OPCODE_MUL:
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index )
-      {
+      FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
          FETCH(&r[0], 0, chan_index);
          FETCH(&r[1], 1, chan_index);
-
-         micro_mul( &r[0], &r[0], &r[1] );
-
-         STORE(&r[0], 0, chan_index);
+         micro_mul(&d[chan_index], &r[0], &r[1]);
+      }
+      FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
+         STORE(&d[chan_index], 0, chan_index);
       }
       break;
 
@@ -2159,82 +2510,45 @@ exec_instruction(
       FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
          FETCH( &r[0], 0, chan_index );
          FETCH( &r[1], 1, chan_index );
-         micro_add( &r[0], &r[0], &r[1] );
-         STORE( &r[0], 0, chan_index );
+         micro_add(&d[chan_index], &r[0], &r[1]);
+      }
+      FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
+         STORE(&d[chan_index], 0, chan_index);
       }
       break;
 
    case TGSI_OPCODE_DP3:
-   /* TGSI_OPCODE_DOT3 */
-      FETCH( &r[0], 0, CHAN_X );
-      FETCH( &r[1], 1, CHAN_X );
-      micro_mul( &r[0], &r[0], &r[1] );
-
-      FETCH( &r[1], 0, CHAN_Y );
-      FETCH( &r[2], 1, CHAN_Y );
-      micro_mul( &r[1], &r[1], &r[2] );
-      micro_add( &r[0], &r[0], &r[1] );
-
-      FETCH( &r[1], 0, CHAN_Z );
-      FETCH( &r[2], 1, CHAN_Z );
-      micro_mul( &r[1], &r[1], &r[2] );
-      micro_add( &r[0], &r[0], &r[1] );
-
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         STORE( &r[0], 0, chan_index );
-      }
+      exec_dp3(mach, inst);
       break;
 
-    case TGSI_OPCODE_DP4:
-    /* TGSI_OPCODE_DOT4 */
-       FETCH(&r[0], 0, CHAN_X);
-       FETCH(&r[1], 1, CHAN_X);
-
-       micro_mul( &r[0], &r[0], &r[1] );
-
-       FETCH(&r[1], 0, CHAN_Y);
-       FETCH(&r[2], 1, CHAN_Y);
-
-       micro_mul( &r[1], &r[1], &r[2] );
-       micro_add( &r[0], &r[0], &r[1] );
-
-       FETCH(&r[1], 0, CHAN_Z);
-       FETCH(&r[2], 1, CHAN_Z);
-
-       micro_mul( &r[1], &r[1], &r[2] );
-       micro_add( &r[0], &r[0], &r[1] );
-
-       FETCH(&r[1], 0, CHAN_W);
-       FETCH(&r[2], 1, CHAN_W);
-
-       micro_mul( &r[1], &r[1], &r[2] );
-       micro_add( &r[0], &r[0], &r[1] );
-
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         STORE( &r[0], 0, chan_index );
-      }
+   case TGSI_OPCODE_DP4:
+      exec_dp4(mach, inst);
       break;
 
    case TGSI_OPCODE_DST:
-      if (IS_CHANNEL_ENABLED( *inst, CHAN_X )) {
-         STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_X );
-      }
-
       if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) {
          FETCH( &r[0], 0, CHAN_Y );
          FETCH( &r[1], 1, CHAN_Y);
-         micro_mul( &r[0], &r[0], &r[1] );
-         STORE( &r[0], 0, CHAN_Y );
+         micro_mul(&d[CHAN_Y], &r[0], &r[1]);
       }
-
       if (IS_CHANNEL_ENABLED( *inst, CHAN_Z )) {
-         FETCH( &r[0], 0, CHAN_Z );
-         STORE( &r[0], 0, CHAN_Z );
+         FETCH(&d[CHAN_Z], 0, CHAN_Z);
       }
-
       if (IS_CHANNEL_ENABLED( *inst, CHAN_W )) {
-         FETCH( &r[0], 1, CHAN_W );
-         STORE( &r[0], 0, CHAN_W );
+         FETCH(&d[CHAN_W], 1, CHAN_W);
+      }
+
+      if (IS_CHANNEL_ENABLED(*inst, CHAN_X)) {
+         STORE(&mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_X);
+      }
+      if (IS_CHANNEL_ENABLED(*inst, CHAN_Y)) {
+         STORE(&d[CHAN_Y], 0, CHAN_Y);
+      }
+      if (IS_CHANNEL_ENABLED(*inst, CHAN_Z)) {
+         STORE(&d[CHAN_Z], 0, CHAN_Z);
+      }
+      if (IS_CHANNEL_ENABLED(*inst, CHAN_W)) {
+         STORE(&d[CHAN_W], 0, CHAN_W);
       }
       break;
 
@@ -2244,9 +2558,10 @@ exec_instruction(
          FETCH(&r[1], 1, chan_index);
 
          /* XXX use micro_min()?? */
-         micro_lt( &r[0], &r[0], &r[1], &r[0], &r[1] );
-
-         STORE(&r[0], 0, chan_index);
+         micro_lt(&d[chan_index], &r[0], &r[1], &r[0], &r[1]);
+      }
+      FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
+         STORE(&d[chan_index], 0, chan_index);
       }
       break;
 
@@ -2256,67 +2571,38 @@ exec_instruction(
          FETCH(&r[1], 1, chan_index);
 
          /* XXX use micro_max()?? */
-         micro_lt( &r[0], &r[0], &r[1], &r[1], &r[0] );
-
-         STORE(&r[0], 0, chan_index );
+         micro_lt(&d[chan_index], &r[0], &r[1], &r[1], &r[0] );
+      }
+      FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
+         STORE(&d[chan_index], 0, chan_index);
       }
       break;
 
    case TGSI_OPCODE_SLT:
-   /* TGSI_OPCODE_SETLT */
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         FETCH( &r[0], 0, chan_index );
-         FETCH( &r[1], 1, chan_index );
-         micro_lt( &r[0], &r[0], &r[1], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] );
-         STORE( &r[0], 0, chan_index );
-      }
+      exec_vector_binary(mach, inst, micro_slt, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
       break;
 
    case TGSI_OPCODE_SGE:
-   /* TGSI_OPCODE_SETGE */
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         FETCH( &r[0], 0, chan_index );
-         FETCH( &r[1], 1, chan_index );
-         micro_le( &r[0], &r[1], &r[0], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] );
-         STORE( &r[0], 0, chan_index );
-      }
+      exec_vector_binary(mach, inst, micro_sge, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
       break;
 
    case TGSI_OPCODE_MAD:
-   /* TGSI_OPCODE_MADD */
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         FETCH( &r[0], 0, chan_index );
-         FETCH( &r[1], 1, chan_index );
-         micro_mul( &r[0], &r[0], &r[1] );
-         FETCH( &r[1], 2, chan_index );
-         micro_add( &r[0], &r[0], &r[1] );
-         STORE( &r[0], 0, chan_index );
-      }
+      exec_vector_trinary(mach, inst, micro_mad, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
       break;
 
    case TGSI_OPCODE_SUB:
       FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
          FETCH(&r[0], 0, chan_index);
          FETCH(&r[1], 1, chan_index);
-
-         micro_sub( &r[0], &r[0], &r[1] );
-
-         STORE(&r[0], 0, chan_index);
+         micro_sub(&d[chan_index], &r[0], &r[1]);
+      }
+      FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
+         STORE(&d[chan_index], 0, chan_index);
       }
       break;
 
    case TGSI_OPCODE_LRP:
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         FETCH(&r[0], 0, chan_index);
-         FETCH(&r[1], 1, chan_index);
-         FETCH(&r[2], 2, chan_index);
-
-         micro_sub( &r[1], &r[1], &r[2] );
-         micro_mul( &r[0], &r[0], &r[1] );
-         micro_add( &r[0], &r[0], &r[2] );
-
-         STORE(&r[0], 0, chan_index);
-      }
+      exec_vector_trinary(mach, inst, micro_lrp, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
       break;
 
    case TGSI_OPCODE_CND:
@@ -2324,35 +2610,19 @@ exec_instruction(
          FETCH(&r[0], 0, chan_index);
          FETCH(&r[1], 1, chan_index);
          FETCH(&r[2], 2, chan_index);
-         micro_lt(&r[0], &mach->Temps[TEMP_HALF_I].xyzw[TEMP_HALF_C], &r[2], &r[0], &r[1]);
-         STORE(&r[0], 0, chan_index);
+         micro_lt(&d[chan_index], &mach->Temps[TEMP_HALF_I].xyzw[TEMP_HALF_C], &r[2], &r[0], &r[1]);
+      }
+      FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
+         STORE(&d[chan_index], 0, chan_index);
       }
       break;
 
    case TGSI_OPCODE_DP2A:
-      FETCH( &r[0], 0, CHAN_X );
-      FETCH( &r[1], 1, CHAN_X );
-      micro_mul( &r[0], &r[0], &r[1] );
-
-      FETCH( &r[1], 0, CHAN_Y );
-      FETCH( &r[2], 1, CHAN_Y );
-      micro_mul( &r[1], &r[1], &r[2] );
-      micro_add( &r[0], &r[0], &r[1] );
-
-      FETCH( &r[2], 2, CHAN_X );
-      micro_add( &r[0], &r[0], &r[2] );
-
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         STORE( &r[0], 0, chan_index );
-      }
+      exec_dp2a(mach, inst);
       break;
 
    case TGSI_OPCODE_FRC:
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         FETCH( &r[0], 0, chan_index );
-         micro_frc( &r[0], &r[0] );
-         STORE( &r[0], 0, chan_index );
-      }
+      exec_vector_unary(mach, inst, micro_frc, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
       break;
 
    case TGSI_OPCODE_CLAMP:
@@ -2361,40 +2631,27 @@ exec_instruction(
          FETCH(&r[1], 1, chan_index);
          micro_max(&r[0], &r[0], &r[1]);
          FETCH(&r[1], 2, chan_index);
-         micro_min(&r[0], &r[0], &r[1]);
-         STORE(&r[0], 0, chan_index);
+         micro_min(&d[chan_index], &r[0], &r[1]);
+      }
+      FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
+         STORE(&d[chan_index], 0, chan_index);
       }
       break;
 
+   case TGSI_OPCODE_FLR:
+      exec_vector_unary(mach, inst, micro_flr, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
+      break;
+
    case TGSI_OPCODE_ROUND:
-   case TGSI_OPCODE_ARR:
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         FETCH( &r[0], 0, chan_index );
-         micro_rnd( &r[0], &r[0] );
-         STORE( &r[0], 0, chan_index );
-      }
+      exec_vector_unary(mach, inst, micro_rnd, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
       break;
 
    case TGSI_OPCODE_EX2:
-      FETCH(&r[0], 0, CHAN_X);
-
-#if FAST_MATH
-      micro_exp2( &r[0], &r[0] );
-#else
-      micro_pow( &r[0], &mach->Temps[TEMP_2_I].xyzw[TEMP_2_C], &r[0] );
-#endif
-
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         STORE( &r[0], 0, chan_index );
-      }
+      exec_scalar_unary(mach, inst, micro_exp2, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
       break;
 
    case TGSI_OPCODE_LG2:
-      FETCH( &r[0], 0, CHAN_X );
-      micro_lg2( &r[0], &r[0] );
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         STORE( &r[0], 0, chan_index );
-      }
+      exec_scalar_unary(mach, inst, micro_lg2, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
       break;
 
    case TGSI_OPCODE_POW:
@@ -2418,11 +2675,7 @@ exec_instruction(
       FETCH(&r[4], 1, CHAN_Y);
 
       micro_mul( &r[5], &r[3], &r[4] );
-      micro_sub( &r[2], &r[2], &r[5] );
-
-      if (IS_CHANNEL_ENABLED( *inst, CHAN_X )) {
-         STORE( &r[2], 0, CHAN_X );
-      }
+      micro_sub(&d[CHAN_X], &r[2], &r[5]);
 
       FETCH(&r[2], 1, CHAN_X);
 
@@ -2431,34 +2684,29 @@ exec_instruction(
       FETCH(&r[5], 0, CHAN_X);
 
       micro_mul( &r[1], &r[1], &r[5] );
-      micro_sub( &r[3], &r[3], &r[1] );
-
-      if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) {
-         STORE( &r[3], 0, CHAN_Y );
-      }
+      micro_sub(&d[CHAN_Y], &r[3], &r[1]);
 
       micro_mul( &r[5], &r[5], &r[4] );
       micro_mul( &r[0], &r[0], &r[2] );
-      micro_sub( &r[5], &r[5], &r[0] );
+      micro_sub(&d[CHAN_Z], &r[5], &r[0]);
 
-      if (IS_CHANNEL_ENABLED( *inst, CHAN_Z )) {
-         STORE( &r[5], 0, CHAN_Z );
+      if (IS_CHANNEL_ENABLED(*inst, CHAN_X)) {
+         STORE(&d[CHAN_X], 0, CHAN_X);
+      }
+      if (IS_CHANNEL_ENABLED(*inst, CHAN_Y)) {
+         STORE(&d[CHAN_Y], 0, CHAN_Y);
+      }
+      if (IS_CHANNEL_ENABLED(*inst, CHAN_Z)) {
+         STORE(&d[CHAN_Z], 0, CHAN_Z);
       }
-
       if (IS_CHANNEL_ENABLED( *inst, CHAN_W )) {
          STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W );
       }
       break;
 
-    case TGSI_OPCODE_ABS:
-       FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-          FETCH(&r[0], 0, chan_index);
-
-          micro_abs( &r[0], &r[0] );
-
-          STORE(&r[0], 0, chan_index);
-       }
-       break;
+   case TGSI_OPCODE_ABS:
+      exec_vector_unary(mach, inst, micro_abs, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
+      break;
 
    case TGSI_OPCODE_RCC:
       FETCH(&r[0], 0, CHAN_X);
@@ -2469,57 +2717,20 @@ exec_instruction(
       }
       break;
 
-   case TGSI_OPCODE_DPH:
-      FETCH(&r[0], 0, CHAN_X);
-      FETCH(&r[1], 1, CHAN_X);
-
-      micro_mul( &r[0], &r[0], &r[1] );
-
-      FETCH(&r[1], 0, CHAN_Y);
-      FETCH(&r[2], 1, CHAN_Y);
-
-      micro_mul( &r[1], &r[1], &r[2] );
-      micro_add( &r[0], &r[0], &r[1] );
-
-      FETCH(&r[1], 0, CHAN_Z);
-      FETCH(&r[2], 1, CHAN_Z);
-
-      micro_mul( &r[1], &r[1], &r[2] );
-      micro_add( &r[0], &r[0], &r[1] );
-
-      FETCH(&r[1], 1, CHAN_W);
-
-      micro_add( &r[0], &r[0], &r[1] );
-
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         STORE( &r[0], 0, chan_index );
-      }
-      break;
-
-   case TGSI_OPCODE_COS:
-      FETCH(&r[0], 0, CHAN_X);
-
-      micro_cos( &r[0], &r[0] );
+   case TGSI_OPCODE_DPH:
+      exec_dph(mach, inst);
+      break;
 
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         STORE( &r[0], 0, chan_index );
-      }
+   case TGSI_OPCODE_COS:
+      exec_scalar_unary(mach, inst, micro_cos, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
       break;
 
    case TGSI_OPCODE_DDX:
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         FETCH( &r[0], 0, chan_index );
-         micro_ddx( &r[0], &r[0] );
-         STORE( &r[0], 0, chan_index );
-      }
+      exec_vector_unary(mach, inst, micro_ddx, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
       break;
 
    case TGSI_OPCODE_DDY:
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         FETCH( &r[0], 0, chan_index );
-         micro_ddy( &r[0], &r[0] );
-         STORE( &r[0], 0, chan_index );
-      }
+      exec_vector_unary(mach, inst, micro_ddy, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
       break;
 
    case TGSI_OPCODE_KILP:
@@ -2596,14 +2807,7 @@ exec_instruction(
       break;
 
    case TGSI_OPCODE_SEQ:
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         FETCH( &r[0], 0, chan_index );
-         FETCH( &r[1], 1, chan_index );
-         micro_eq( &r[0], &r[0], &r[1],
-                   &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C],
-                   &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] );
-         STORE( &r[0], 0, chan_index );
-      }
+      exec_vector_binary(mach, inst, micro_seq, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
       break;
 
    case TGSI_OPCODE_SFL:
@@ -2613,38 +2817,19 @@ exec_instruction(
       break;
 
    case TGSI_OPCODE_SGT:
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         FETCH( &r[0], 0, chan_index );
-         FETCH( &r[1], 1, chan_index );
-         micro_le( &r[0], &r[0], &r[1], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C] );
-         STORE( &r[0], 0, chan_index );
-      }
+      exec_vector_binary(mach, inst, micro_sgt, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
       break;
 
    case TGSI_OPCODE_SIN:
-      FETCH( &r[0], 0, CHAN_X );
-      micro_sin( &r[0], &r[0] );
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         STORE( &r[0], 0, chan_index );
-      }
+      exec_scalar_unary(mach, inst, micro_sin, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
       break;
 
    case TGSI_OPCODE_SLE:
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         FETCH( &r[0], 0, chan_index );
-         FETCH( &r[1], 1, chan_index );
-         micro_le( &r[0], &r[0], &r[1], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] );
-         STORE( &r[0], 0, chan_index );
-      }
+      exec_vector_binary(mach, inst, micro_sle, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
       break;
 
    case TGSI_OPCODE_SNE:
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         FETCH( &r[0], 0, chan_index );
-         FETCH( &r[1], 1, chan_index );
-         micro_eq( &r[0], &r[0], &r[1], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C] );
-         STORE( &r[0], 0, chan_index );
-      }
+      exec_vector_binary(mach, inst, micro_sne, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
       break;
 
    case TGSI_OPCODE_STR:
@@ -2657,14 +2842,14 @@ exec_instruction(
       /* simple texture lookup */
       /* src[0] = texcoord */
       /* src[1] = sampler unit */
-      exec_tex(mach, inst, FALSE, FALSE);
+      exec_tex(mach, inst, TEX_MODIFIER_NONE);
       break;
 
    case TGSI_OPCODE_TXB:
       /* Texture lookup with lod bias */
       /* src[0] = texcoord (src[0].w = LOD bias) */
       /* src[1] = sampler unit */
-      exec_tex(mach, inst, TRUE, FALSE);
+      exec_tex(mach, inst, TEX_MODIFIER_LOD_BIAS);
       break;
 
    case TGSI_OPCODE_TXD:
@@ -2673,21 +2858,21 @@ exec_instruction(
       /* src[1] = d[strq]/dx */
       /* src[2] = d[strq]/dy */
       /* src[3] = sampler unit */
-      assert (0);
+      exec_txd(mach, inst);
       break;
 
    case TGSI_OPCODE_TXL:
       /* Texture lookup with explit LOD */
       /* src[0] = texcoord (src[0].w = LOD) */
       /* src[1] = sampler unit */
-      exec_tex(mach, inst, TRUE, FALSE);
+      exec_tex(mach, inst, TEX_MODIFIER_EXPLICIT_LOD);
       break;
 
    case TGSI_OPCODE_TXP:
       /* Texture lookup with projection */
       /* src[0] = texcoord (src[0].w = projection) */
       /* src[1] = sampler unit */
-      exec_tex(mach, inst, FALSE, TRUE);
+      exec_tex(mach, inst, TEX_MODIFIER_PROJECTED);
       break;
 
    case TGSI_OPCODE_UP2H:
@@ -2717,13 +2902,8 @@ exec_instruction(
          micro_mul(&r[3], &r[3], &r[1]);
          micro_add(&r[2], &r[2], &r[3]);
          FETCH(&r[3], 0, CHAN_X);
-         micro_add(&r[2], &r[2], &r[3]);
-         if (IS_CHANNEL_ENABLED(*inst, CHAN_X)) {
-            STORE(&r[2], 0, CHAN_X);
-         }
-         if (IS_CHANNEL_ENABLED(*inst, CHAN_Z)) {
-            STORE(&r[2], 0, CHAN_Z);
-         }
+         micro_add(&d[CHAN_X], &r[2], &r[3]);
+         
       }
       if (IS_CHANNEL_ENABLED(*inst, CHAN_Y) ||
           IS_CHANNEL_ENABLED(*inst, CHAN_W)) {
@@ -2733,13 +2913,20 @@ exec_instruction(
          micro_mul(&r[3], &r[3], &r[1]);
          micro_add(&r[2], &r[2], &r[3]);
          FETCH(&r[3], 0, CHAN_Y);
-         micro_add(&r[2], &r[2], &r[3]);
-         if (IS_CHANNEL_ENABLED(*inst, CHAN_Y)) {
-            STORE(&r[2], 0, CHAN_Y);
-         }
-         if (IS_CHANNEL_ENABLED(*inst, CHAN_W)) {
-            STORE(&r[2], 0, CHAN_W);
-         }
+         micro_add(&d[CHAN_Y], &r[2], &r[3]);
+         
+      }
+      if (IS_CHANNEL_ENABLED(*inst, CHAN_X)) {
+         STORE(&d[CHAN_X], 0, CHAN_X);
+      }
+      if (IS_CHANNEL_ENABLED(*inst, CHAN_Y)) {
+         STORE(&d[CHAN_Y], 0, CHAN_Y);
+      }
+      if (IS_CHANNEL_ENABLED(*inst, CHAN_Z)) {
+         STORE(&d[CHAN_X], 0, CHAN_Z);
+      }
+      if (IS_CHANNEL_ENABLED(*inst, CHAN_W)) {
+         STORE(&d[CHAN_Y], 0, CHAN_W);
       }
       break;
 
@@ -2747,6 +2934,10 @@ exec_instruction(
       assert (0);
       break;
 
+   case TGSI_OPCODE_ARR:
+      exec_vector_unary(mach, inst, micro_arr, TGSI_EXEC_DATA_INT, TGSI_EXEC_DATA_FLOAT);
+      break;
+
    case TGSI_OPCODE_BRA:
       assert (0);
       break;
@@ -2766,6 +2957,8 @@ exec_instruction(
          mach->CallStack[mach->CallStackTop].CondStackTop = mach->CondStackTop;
          mach->CallStack[mach->CallStackTop].LoopStackTop = mach->LoopStackTop;
          mach->CallStack[mach->CallStackTop].ContStackTop = mach->ContStackTop;
+         mach->CallStack[mach->CallStackTop].SwitchStackTop = mach->SwitchStackTop;
+         mach->CallStack[mach->CallStackTop].BreakStackTop = mach->BreakStackTop;
          /* note that PC was already incremented above */
          mach->CallStack[mach->CallStackTop].ReturnAddr = *pc;
 
@@ -2773,16 +2966,21 @@ exec_instruction(
 
          /* Second, push the Cond, Loop, Cont, Func stacks */
          assert(mach->CondStackTop < TGSI_EXEC_MAX_COND_NESTING);
-         mach->CondStack[mach->CondStackTop++] = mach->CondMask;
          assert(mach->LoopStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
-         mach->LoopStack[mach->LoopStackTop++] = mach->LoopMask;
          assert(mach->ContStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
-         mach->ContStack[mach->ContStackTop++] = mach->ContMask;
+         assert(mach->SwitchStackTop < TGSI_EXEC_MAX_SWITCH_NESTING);
+         assert(mach->BreakStackTop < TGSI_EXEC_MAX_BREAK_STACK);
          assert(mach->FuncStackTop < TGSI_EXEC_MAX_CALL_NESTING);
+
+         mach->CondStack[mach->CondStackTop++] = mach->CondMask;
+         mach->LoopStack[mach->LoopStackTop++] = mach->LoopMask;
+         mach->ContStack[mach->ContStackTop++] = mach->ContMask;
+         mach->SwitchStack[mach->SwitchStackTop++] = mach->Switch;
+         mach->BreakStack[mach->BreakStackTop++] = mach->BreakType;
          mach->FuncStack[mach->FuncStackTop++] = mach->FuncMask;
 
          /* Finally, jump to the subroutine */
-         *pc = inst->InstructionExtLabel.Label;
+         *pc = inst->Label.Label;
       }
       break;
 
@@ -2811,6 +3009,12 @@ exec_instruction(
          mach->ContStackTop = mach->CallStack[mach->CallStackTop].ContStackTop;
          mach->ContMask = mach->ContStack[mach->ContStackTop];
 
+         mach->SwitchStackTop = mach->CallStack[mach->CallStackTop].SwitchStackTop;
+         mach->Switch = mach->SwitchStack[mach->SwitchStackTop];
+
+         mach->BreakStackTop = mach->CallStack[mach->CallStackTop].BreakStackTop;
+         mach->BreakType = mach->BreakStack[mach->BreakStackTop];
+
          assert(mach->FuncStackTop > 0);
          mach->FuncMask = mach->FuncStack[--mach->FuncStackTop];
 
@@ -2821,12 +3025,7 @@ exec_instruction(
       break;
 
    case TGSI_OPCODE_SSG:
-   /* TGSI_OPCODE_SGN */
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         FETCH( &r[0], 0, chan_index );
-         micro_sgn( &r[0], &r[0] );
-         STORE( &r[0], 0, chan_index );
-      }
+      exec_vector_unary(mach, inst, micro_sgn, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
       break;
 
    case TGSI_OPCODE_CMP:
@@ -2834,10 +3033,10 @@ exec_instruction(
          FETCH(&r[0], 0, chan_index);
          FETCH(&r[1], 1, chan_index);
          FETCH(&r[2], 2, chan_index);
-
-         micro_lt( &r[0], &r[0], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], &r[1], &r[2] );
-
-         STORE(&r[0], 0, chan_index);
+         micro_lt(&d[chan_index], &r[0], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], &r[1], &r[2]);
+      }
+      FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
+         STORE(&d[chan_index], 0, chan_index);
       }
       break;
 
@@ -2933,18 +3132,7 @@ exec_instruction(
       break;
 
    case TGSI_OPCODE_DP2:
-      FETCH( &r[0], 0, CHAN_X );
-      FETCH( &r[1], 1, CHAN_X );
-      micro_mul( &r[0], &r[0], &r[1] );
-
-      FETCH( &r[1], 0, CHAN_Y );
-      FETCH( &r[2], 1, CHAN_Y );
-      micro_mul( &r[1], &r[1], &r[2] );
-      micro_add( &r[0], &r[0], &r[1] );
-
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         STORE( &r[0], 0, chan_index );
-      }
+      exec_dp2(mach, inst);
       break;
 
    case TGSI_OPCODE_IF:
@@ -3010,71 +3198,31 @@ exec_instruction(
       break;
 
    case TGSI_OPCODE_CEIL:
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         FETCH( &r[0], 0, chan_index );
-         micro_ceil( &r[0], &r[0] );
-         STORE( &r[0], 0, chan_index );
-      }
+      exec_vector_unary(mach, inst, micro_ceil, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
       break;
 
    case TGSI_OPCODE_I2F:
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         FETCH( &r[0], 0, chan_index );
-         micro_i2f( &r[0], &r[0] );
-         STORE( &r[0], 0, chan_index );
-      }
+      exec_vector_unary(mach, inst, micro_i2f, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_INT);
       break;
 
    case TGSI_OPCODE_NOT:
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         FETCH( &r[0], 0, chan_index );
-         micro_not( &r[0], &r[0] );
-         STORE( &r[0], 0, chan_index );
-      }
+      exec_vector_unary(mach, inst, micro_not, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
       break;
 
    case TGSI_OPCODE_TRUNC:
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         FETCH( &r[0], 0, chan_index );
-         micro_trunc( &r[0], &r[0] );
-         STORE( &r[0], 0, chan_index );
-      }
+      exec_vector_unary(mach, inst, micro_trunc, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
       break;
 
    case TGSI_OPCODE_SHL:
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         FETCH( &r[0], 0, chan_index );
-         FETCH( &r[1], 1, chan_index );
-         micro_shl( &r[0], &r[0], &r[1] );
-         STORE( &r[0], 0, chan_index );
-      }
-      break;
-
-   case TGSI_OPCODE_SHR:
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         FETCH( &r[0], 0, chan_index );
-         FETCH( &r[1], 1, chan_index );
-         micro_ishr( &r[0], &r[0], &r[1] );
-         STORE( &r[0], 0, chan_index );
-      }
+      exec_vector_binary(mach, inst, micro_shl, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
       break;
 
    case TGSI_OPCODE_AND:
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         FETCH( &r[0], 0, chan_index );
-         FETCH( &r[1], 1, chan_index );
-         micro_and( &r[0], &r[0], &r[1] );
-         STORE( &r[0], 0, chan_index );
-      }
+      exec_vector_binary(mach, inst, micro_and, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
       break;
 
    case TGSI_OPCODE_OR:
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         FETCH( &r[0], 0, chan_index );
-         FETCH( &r[1], 1, chan_index );
-         micro_or( &r[0], &r[0], &r[1] );
-         STORE( &r[0], 0, chan_index );
-      }
+      exec_vector_binary(mach, inst, micro_or, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
       break;
 
    case TGSI_OPCODE_MOD:
@@ -3082,12 +3230,7 @@ exec_instruction(
       break;
 
    case TGSI_OPCODE_XOR:
-      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-         FETCH( &r[0], 0, chan_index );
-         FETCH( &r[1], 1, chan_index );
-         micro_xor( &r[0], &r[0], &r[1] );
-         STORE( &r[0], 0, chan_index );
-      }
+      exec_vector_binary(mach, inst, micro_xor, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
       break;
 
    case TGSI_OPCODE_SAD:
@@ -3103,13 +3246,11 @@ exec_instruction(
       break;
 
    case TGSI_OPCODE_EMIT:
-      mach->Temps[TEMP_OUTPUT_I].xyzw[TEMP_OUTPUT_C].u[0] += 16;
-      mach->Primitives[mach->Temps[TEMP_PRIMITIVE_I].xyzw[TEMP_PRIMITIVE_C].u[0]]++;
+      emit_vertex(mach);
       break;
 
    case TGSI_OPCODE_ENDPRIM:
-      mach->Temps[TEMP_PRIMITIVE_I].xyzw[TEMP_PRIMITIVE_C].u[0]++;
-      mach->Primitives[mach->Temps[TEMP_PRIMITIVE_I].xyzw[TEMP_PRIMITIVE_C].u[0]] = 0;
+      emit_primitive(mach);
       break;
 
    case TGSI_OPCODE_BGNFOR:
@@ -3117,43 +3258,62 @@ exec_instruction(
       for (chan_index = 0; chan_index < 3; chan_index++) {
          FETCH( &mach->LoopCounterStack[mach->LoopCounterStackTop].xyzw[chan_index], 0, chan_index );
       }
-      STORE( &mach->LoopCounterStack[mach->LoopCounterStackTop].xyzw[CHAN_Y], 0, CHAN_X );
       ++mach->LoopCounterStackTop;
+      STORE(&mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_X], 0, CHAN_X);
+      /* update LoopMask */
+      if (mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_Y].f[0] <= 0.0f) {
+         mach->LoopMask &= ~0x1;
+      }
+      if (mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_Y].f[1] <= 0.0f) {
+         mach->LoopMask &= ~0x2;
+      }
+      if (mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_Y].f[2] <= 0.0f) {
+         mach->LoopMask &= ~0x4;
+      }
+      if (mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_Y].f[3] <= 0.0f) {
+         mach->LoopMask &= ~0x8;
+      }
+      /* TODO: if mach->LoopMask == 0, jump to end of loop */
+      UPDATE_EXEC_MASK(mach);
       /* fall-through (for now) */
    case TGSI_OPCODE_BGNLOOP:
       /* push LoopMask and ContMasks */
       assert(mach->LoopStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
-      mach->LoopStack[mach->LoopStackTop++] = mach->LoopMask;
       assert(mach->ContStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
-      mach->ContStack[mach->ContStackTop++] = mach->ContMask;
       assert(mach->LoopLabelStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
+      assert(mach->BreakStackTop < TGSI_EXEC_MAX_BREAK_STACK);
+
+      mach->LoopStack[mach->LoopStackTop++] = mach->LoopMask;
+      mach->ContStack[mach->ContStackTop++] = mach->ContMask;
       mach->LoopLabelStack[mach->LoopLabelStackTop++] = *pc - 1;
+      mach->BreakStack[mach->BreakStackTop++] = mach->BreakType;
+      mach->BreakType = TGSI_EXEC_BREAK_INSIDE_LOOP;
       break;
 
    case TGSI_OPCODE_ENDFOR:
       assert(mach->LoopCounterStackTop > 0);
-      micro_sub( &mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_X], 
-                 &mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_X],
-                 &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C] );
+      micro_sub(&mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_Y], 
+                &mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_Y],
+                &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C]);
       /* update LoopMask */
-      if( mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_X].f[0] <= 0) {
+      if (mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_Y].f[0] <= 0.0f) {
          mach->LoopMask &= ~0x1;
       }
-      if( mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_X].f[1] <= 0 ) {
+      if (mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_Y].f[1] <= 0.0f) {
          mach->LoopMask &= ~0x2;
       }
-      if( mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_X].f[2] <= 0 ) {
+      if (mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_Y].f[2] <= 0.0f) {
          mach->LoopMask &= ~0x4;
       }
-      if( mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_X].f[3] <= 0 ) {
+      if (mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_Y].f[3] <= 0.0f) {
          mach->LoopMask &= ~0x8;
       }
-      micro_add( &mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_Y], 
-                 &mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_Y], 
-                 &mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_Z]);
+      micro_add(&mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_X], 
+                &mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_X], 
+                &mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_Z]);
       assert(mach->LoopLabelStackTop > 0);
       inst = mach->Instructions + mach->LoopLabelStack[mach->LoopLabelStackTop - 1];
-      STORE( &mach->LoopCounterStack[mach->LoopCounterStackTop].xyzw[CHAN_Y], 0, CHAN_X );
+      STORE(&mach->LoopCounterStack[mach->LoopCounterStackTop].xyzw[CHAN_X], 0, CHAN_X);
       /* Restore ContMask, but don't pop */
       assert(mach->ContStackTop > 0);
       mach->ContMask = mach->ContStack[mach->ContStackTop - 1];
@@ -3174,6 +3334,8 @@ exec_instruction(
          --mach->LoopLabelStackTop;
          assert(mach->LoopCounterStackTop > 0);
          --mach->LoopCounterStackTop;
+
+         mach->BreakType = mach->BreakStack[--mach->BreakStackTop];
       }
       UPDATE_EXEC_MASK(mach);
       break;
@@ -3197,15 +3359,14 @@ exec_instruction(
          mach->ContMask = mach->ContStack[--mach->ContStackTop];
          assert(mach->LoopLabelStackTop > 0);
          --mach->LoopLabelStackTop;
+
+         mach->BreakType = mach->BreakStack[--mach->BreakStackTop];
       }
       UPDATE_EXEC_MASK(mach);
       break;
 
    case TGSI_OPCODE_BRK:
-      /* turn off loop channels for each enabled exec channel */
-      mach->LoopMask &= ~mach->ExecMask;
-      /* Todo: if mach->LoopMask == 0, jump to end of loop */
-      UPDATE_EXEC_MASK(mach);
+      exec_break(mach);
       break;
 
    case TGSI_OPCODE_CONT:
@@ -3220,26 +3381,160 @@ exec_instruction(
       break;
 
    case TGSI_OPCODE_ENDSUB:
-      /* no-op */
+      /*
+       * XXX: This really should be a no-op. We should never reach this opcode.
+       */
+
+      assert(mach->CallStackTop > 0);
+      mach->CallStackTop--;
+
+      mach->CondStackTop = mach->CallStack[mach->CallStackTop].CondStackTop;
+      mach->CondMask = mach->CondStack[mach->CondStackTop];
+
+      mach->LoopStackTop = mach->CallStack[mach->CallStackTop].LoopStackTop;
+      mach->LoopMask = mach->LoopStack[mach->LoopStackTop];
+
+      mach->ContStackTop = mach->CallStack[mach->CallStackTop].ContStackTop;
+      mach->ContMask = mach->ContStack[mach->ContStackTop];
+
+      mach->SwitchStackTop = mach->CallStack[mach->CallStackTop].SwitchStackTop;
+      mach->Switch = mach->SwitchStack[mach->SwitchStackTop];
+
+      mach->BreakStackTop = mach->CallStack[mach->CallStackTop].BreakStackTop;
+      mach->BreakType = mach->BreakStack[mach->BreakStackTop];
+
+      assert(mach->FuncStackTop > 0);
+      mach->FuncMask = mach->FuncStack[--mach->FuncStackTop];
+
+      *pc = mach->CallStack[mach->CallStackTop].ReturnAddr;
+
+      UPDATE_EXEC_MASK(mach);
       break;
 
-   case TGSI_OPCODE_NOISE1:
-      assert( 0 );
+   case TGSI_OPCODE_NOP:
       break;
 
-   case TGSI_OPCODE_NOISE2:
-      assert( 0 );
+   case TGSI_OPCODE_BREAKC:
+      FETCH(&r[0], 0, CHAN_X);
+      /* update CondMask */
+      if (r[0].u[0] && (mach->ExecMask & 0x1)) {
+         mach->LoopMask &= ~0x1;
+      }
+      if (r[0].u[1] && (mach->ExecMask & 0x2)) {
+         mach->LoopMask &= ~0x2;
+      }
+      if (r[0].u[2] && (mach->ExecMask & 0x4)) {
+         mach->LoopMask &= ~0x4;
+      }
+      if (r[0].u[3] && (mach->ExecMask & 0x8)) {
+         mach->LoopMask &= ~0x8;
+      }
+      /* Todo: if mach->LoopMask == 0, jump to end of loop */
+      UPDATE_EXEC_MASK(mach);
       break;
 
-   case TGSI_OPCODE_NOISE3:
-      assert( 0 );
+   case TGSI_OPCODE_F2I:
+      exec_vector_unary(mach, inst, micro_f2i, TGSI_EXEC_DATA_INT, TGSI_EXEC_DATA_FLOAT);
       break;
 
-   case TGSI_OPCODE_NOISE4:
-      assert( 0 );
+   case TGSI_OPCODE_IDIV:
+      exec_vector_binary(mach, inst, micro_idiv, TGSI_EXEC_DATA_INT, TGSI_EXEC_DATA_INT);
       break;
 
-   case TGSI_OPCODE_NOP:
+   case TGSI_OPCODE_IMAX:
+      exec_vector_binary(mach, inst, micro_imax, TGSI_EXEC_DATA_INT, TGSI_EXEC_DATA_INT);
+      break;
+
+   case TGSI_OPCODE_IMIN:
+      exec_vector_binary(mach, inst, micro_imin, TGSI_EXEC_DATA_INT, TGSI_EXEC_DATA_INT);
+      break;
+
+   case TGSI_OPCODE_INEG:
+      exec_vector_unary(mach, inst, micro_ineg, TGSI_EXEC_DATA_INT, TGSI_EXEC_DATA_INT);
+      break;
+
+   case TGSI_OPCODE_ISGE:
+      exec_vector_binary(mach, inst, micro_isge, TGSI_EXEC_DATA_INT, TGSI_EXEC_DATA_INT);
+      break;
+
+   case TGSI_OPCODE_ISHR:
+      exec_vector_binary(mach, inst, micro_ishr, TGSI_EXEC_DATA_INT, TGSI_EXEC_DATA_INT);
+      break;
+
+   case TGSI_OPCODE_ISLT:
+      exec_vector_binary(mach, inst, micro_islt, TGSI_EXEC_DATA_INT, TGSI_EXEC_DATA_INT);
+      break;
+
+   case TGSI_OPCODE_F2U:
+      exec_vector_unary(mach, inst, micro_f2u, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_FLOAT);
+      break;
+
+   case TGSI_OPCODE_U2F:
+      exec_vector_unary(mach, inst, micro_u2f, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_UINT);
+      break;
+
+   case TGSI_OPCODE_UADD:
+      exec_vector_binary(mach, inst, micro_uadd, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
+      break;
+
+   case TGSI_OPCODE_UDIV:
+      exec_vector_binary(mach, inst, micro_udiv, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
+      break;
+
+   case TGSI_OPCODE_UMAD:
+      exec_vector_trinary(mach, inst, micro_umad, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
+      break;
+
+   case TGSI_OPCODE_UMAX:
+      exec_vector_binary(mach, inst, micro_umax, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
+      break;
+
+   case TGSI_OPCODE_UMIN:
+      exec_vector_binary(mach, inst, micro_umin, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
+      break;
+
+   case TGSI_OPCODE_UMOD:
+      exec_vector_binary(mach, inst, micro_umod, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
+      break;
+
+   case TGSI_OPCODE_UMUL:
+      exec_vector_binary(mach, inst, micro_umul, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
+      break;
+
+   case TGSI_OPCODE_USEQ:
+      exec_vector_binary(mach, inst, micro_useq, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
+      break;
+
+   case TGSI_OPCODE_USGE:
+      exec_vector_binary(mach, inst, micro_usge, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
+      break;
+
+   case TGSI_OPCODE_USHR:
+      exec_vector_binary(mach, inst, micro_ushr, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
+      break;
+
+   case TGSI_OPCODE_USLT:
+      exec_vector_binary(mach, inst, micro_uslt, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
+      break;
+
+   case TGSI_OPCODE_USNE:
+      exec_vector_binary(mach, inst, micro_usne, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
+      break;
+
+   case TGSI_OPCODE_SWITCH:
+      exec_switch(mach, inst);
+      break;
+
+   case TGSI_OPCODE_CASE:
+      exec_case(mach, inst);
+      break;
+
+   case TGSI_OPCODE_DEFAULT:
+      exec_default(mach);
+      break;
+
+   case TGSI_OPCODE_ENDSWITCH:
+      exec_endswitch(mach);
       break;
 
    default:
@@ -3248,6 +3543,9 @@ exec_instruction(
 }
 
 
+#define DEBUG_EXECUTION 0
+
+
 /**
  * Run TGSI interpreter.
  * \return bitmask of "alive" quad components
@@ -3264,9 +3562,13 @@ tgsi_exec_machine_run( struct tgsi_exec_machine *mach )
    mach->FuncMask = 0xf;
    mach->ExecMask = 0xf;
 
+   mach->Switch.mask = 0xf;
+
    assert(mach->CondStackTop == 0);
    assert(mach->LoopStackTop == 0);
    assert(mach->ContStackTop == 0);
+   assert(mach->SwitchStackTop == 0);
+   assert(mach->BreakStackTop == 0);
    assert(mach->CallStackTop == 0);
 
    mach->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0] = 0;
@@ -3290,10 +3592,67 @@ tgsi_exec_machine_run( struct tgsi_exec_machine *mach )
       exec_declaration( mach, mach->Declarations+i );
    }
 
-   /* execute instructions, until pc is set to -1 */
-   while (pc != -1) {
-      assert(pc < (int) mach->NumInstructions);
-      exec_instruction( mach, mach->Instructions + pc, &pc );
+   {
+#if DEBUG_EXECUTION
+      struct tgsi_exec_vector temps[TGSI_EXEC_NUM_TEMPS + TGSI_EXEC_NUM_TEMP_EXTRAS];
+      struct tgsi_exec_vector outputs[PIPE_MAX_ATTRIBS];
+      uint inst = 1;
+
+      memcpy(temps, mach->Temps, sizeof(temps));
+      memcpy(outputs, mach->Outputs, sizeof(outputs));
+#endif
+
+      /* execute instructions, until pc is set to -1 */
+      while (pc != -1) {
+
+#if DEBUG_EXECUTION
+         uint i;
+
+         tgsi_dump_instruction(&mach->Instructions[pc], inst++);
+#endif
+
+         assert(pc < (int) mach->NumInstructions);
+         exec_instruction(mach, mach->Instructions + pc, &pc);
+
+#if DEBUG_EXECUTION
+         for (i = 0; i < TGSI_EXEC_NUM_TEMPS + TGSI_EXEC_NUM_TEMP_EXTRAS; i++) {
+            if (memcmp(&temps[i], &mach->Temps[i], sizeof(temps[i]))) {
+               uint j;
+
+               memcpy(&temps[i], &mach->Temps[i], sizeof(temps[i]));
+               debug_printf("TEMP[%2u] = ", i);
+               for (j = 0; j < 4; j++) {
+                  if (j > 0) {
+                     debug_printf("           ");
+                  }
+                  debug_printf("(%6f %u, %6f %u, %6f %u, %6f %u)\n",
+                               temps[i].xyzw[0].f[j], temps[i].xyzw[0].u[j],
+                               temps[i].xyzw[1].f[j], temps[i].xyzw[1].u[j],
+                               temps[i].xyzw[2].f[j], temps[i].xyzw[2].u[j],
+                               temps[i].xyzw[3].f[j], temps[i].xyzw[3].u[j]);
+               }
+            }
+         }
+         for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
+            if (memcmp(&outputs[i], &mach->Outputs[i], sizeof(outputs[i]))) {
+               uint j;
+
+               memcpy(&outputs[i], &mach->Outputs[i], sizeof(outputs[i]));
+               debug_printf("OUT[%2u] =  ", i);
+               for (j = 0; j < 4; j++) {
+                  if (j > 0) {
+                     debug_printf("           ");
+                  }
+                  debug_printf("(%6f %u, %6f %u, %6f %u, %6f %u)\n",
+                               outputs[i].xyzw[0].f[j], outputs[i].xyzw[0].u[j],
+                               outputs[i].xyzw[1].f[j], outputs[i].xyzw[1].u[j],
+                               outputs[i].xyzw[2].f[j], outputs[i].xyzw[2].u[j],
+                               outputs[i].xyzw[3].f[j], outputs[i].xyzw[3].u[j]);
+               }
+            }
+         }
+#endif
+      }
    }
 
 #if 0
@@ -3307,5 +3666,12 @@ tgsi_exec_machine_run( struct tgsi_exec_machine *mach )
    }
 #endif
 
+   assert(mach->CondStackTop == 0);
+   assert(mach->LoopStackTop == 0);
+   assert(mach->ContStackTop == 0);
+   assert(mach->SwitchStackTop == 0);
+   assert(mach->BreakStackTop == 0);
+   assert(mach->CallStackTop == 0);
+
    return ~mach->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0];
 }
index c72f76809d4873c4b88daf53123251aeb7cd43f1..59e3b445cc3cbd9cf9dc5cce1b789ee79121f423 100644 (file)
@@ -2,6 +2,7 @@
  * 
  * Copyright 2007-2008 Tungsten Graphics, Inc., Cedar Park, Texas.
  * All Rights Reserved.
+ * Copyright 2009-2010 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
 extern "C" {
 #endif
 
+
 #define MAX_LABELS (4 * 1024)  /**< basically, max instructions */
 
 #define NUM_CHANNELS 4  /* R,G,B,A */
 #define QUAD_SIZE    4  /* 4 pixel/quad */
 
+
 /**
   * Registers may be treated as float, signed int or unsigned int.
   */
@@ -69,6 +72,11 @@ struct tgsi_interp_coef
    float dady[NUM_CHANNELS];
 };
 
+enum tgsi_sampler_control {
+   tgsi_sampler_lod_bias,
+   tgsi_sampler_lod_explicit
+};
+
 /**
  * Information for sampling textures, which must be implemented
  * by code outside the TGSI executor.
@@ -80,7 +88,8 @@ struct tgsi_sampler
                        const float s[QUAD_SIZE],
                        const float t[QUAD_SIZE],
                        const float p[QUAD_SIZE],
-                       float lodbias,
+                       const float c0[QUAD_SIZE],
+                       enum tgsi_sampler_control control,
                        float rgba[NUM_CHANNELS][QUAD_SIZE]);
 };
 
@@ -168,13 +177,19 @@ struct tgsi_exec_labels
 
 #define TGSI_EXEC_TEMP_ADDR         (TGSI_EXEC_NUM_TEMPS + 8)
 #define TGSI_EXEC_NUM_ADDRS         1
-#define TGSI_EXEC_NUM_TEMP_EXTRAS   9
 
+/* predicate register */
+#define TGSI_EXEC_TEMP_P0           (TGSI_EXEC_NUM_TEMPS + 9)
+#define TGSI_EXEC_NUM_PREDS         1
+
+#define TGSI_EXEC_NUM_TEMP_EXTRAS   10
 
 
-#define TGSI_EXEC_MAX_COND_NESTING  20
-#define TGSI_EXEC_MAX_LOOP_NESTING  20
-#define TGSI_EXEC_MAX_CALL_NESTING  20
+
+#define TGSI_EXEC_MAX_COND_NESTING  32
+#define TGSI_EXEC_MAX_LOOP_NESTING  32
+#define TGSI_EXEC_MAX_SWITCH_NESTING 32
+#define TGSI_EXEC_MAX_CALL_NESTING  32
 
 /* The maximum number of input attributes per vertex. For 2D
  * input register files, this is the stride between two 1D
@@ -186,6 +201,14 @@ struct tgsi_exec_labels
  */
 #define TGSI_EXEC_MAX_CONST_BUFFER  4096
 
+/* The maximum number of vertices per primitive */
+#define TGSI_MAX_PRIM_VERTICES 6
+
+/* The maximum number of primitives to be generated */
+#define TGSI_MAX_PRIMITIVES 64
+
+/* The maximum total number of vertices */
+#define TGSI_MAX_TOTAL_VERTICES (TGSI_MAX_PRIM_VERTICES * TGSI_MAX_PRIMITIVES * PIPE_MAX_ATTRIBS)
 
 /** function call/activation record */
 struct tgsi_call_record
@@ -193,10 +216,29 @@ struct tgsi_call_record
    uint CondStackTop;
    uint LoopStackTop;
    uint ContStackTop;
+   int SwitchStackTop;
+   int BreakStackTop;
    uint ReturnAddr;
 };
 
 
+/* Switch-case block state. */
+struct tgsi_switch_record {
+   uint mask;                          /**< execution mask */
+   union tgsi_exec_channel selector;   /**< a value case statements are compared to */
+   uint defaultMask;                   /**< non-execute mask for default case */
+};
+
+
+enum tgsi_break_type {
+   TGSI_EXEC_BREAK_INSIDE_LOOP,
+   TGSI_EXEC_BREAK_INSIDE_SWITCH
+};
+
+
+#define TGSI_EXEC_MAX_BREAK_STACK (TGSI_EXEC_MAX_LOOP_NESTING + TGSI_EXEC_MAX_SWITCH_NESTING)
+
+
 /**
  * Run-time virtual machine state for executing TGSI shader.
  */
@@ -209,10 +251,11 @@ struct tgsi_exec_machine
 
    float                         Imms[TGSI_EXEC_NUM_IMMEDIATES][4];
 
-   struct tgsi_exec_vector       Inputs[PIPE_MAX_ATTRIBS];
-   struct tgsi_exec_vector       Outputs[PIPE_MAX_ATTRIBS];
+   struct tgsi_exec_vector       Inputs[TGSI_MAX_PRIM_VERTICES * PIPE_MAX_ATTRIBS];
+   struct tgsi_exec_vector       Outputs[TGSI_MAX_TOTAL_VERTICES];
 
    struct tgsi_exec_vector       *Addrs;
+   struct tgsi_exec_vector       *Predicates;
 
    struct tgsi_sampler           **Samplers;
 
@@ -223,10 +266,13 @@ struct tgsi_exec_machine
 
    /* GEOMETRY processor only. */
    unsigned                      *Primitives;
+   unsigned                       NumOutputs;
+   unsigned                       MaxGeometryShaderOutputs;
 
    /* FRAGMENT processor only. */
    const struct tgsi_interp_coef *InterpCoefs;
    struct tgsi_exec_vector       QuadPos;
+   float                         Face;    /**< +1 if front facing, -1 if back facing */
 
    /* Conditional execution masks */
    uint CondMask;  /**< For IF/ELSE/ENDIF */
@@ -235,6 +281,12 @@ struct tgsi_exec_machine
    uint FuncMask;  /**< For function calls */
    uint ExecMask;  /**< = CondMask & LoopMask */
 
+   /* Current switch-case state. */
+   struct tgsi_switch_record Switch;
+
+   /* Current break type. */
+   enum tgsi_break_type BreakType;
+
    /** Condition mask stack (for nested conditionals) */
    uint CondStack[TGSI_EXEC_MAX_COND_NESTING];
    int CondStackTop;
@@ -247,7 +299,7 @@ struct tgsi_exec_machine
    uint LoopLabelStack[TGSI_EXEC_MAX_LOOP_NESTING];
    int LoopLabelStackTop;
 
-   /** Loop counter stack (x = count, y = current, z = step) */
+   /** Loop counter stack (x = index, y = counter, z = step) */
    struct tgsi_exec_vector LoopCounterStack[TGSI_EXEC_MAX_LOOP_NESTING];
    int LoopCounterStackTop;
    
@@ -255,6 +307,13 @@ struct tgsi_exec_machine
    uint ContStack[TGSI_EXEC_MAX_LOOP_NESTING];
    int ContStackTop;
 
+   /** Switch case stack */
+   struct tgsi_switch_record SwitchStack[TGSI_EXEC_MAX_SWITCH_NESTING];
+   int SwitchStackTop;
+
+   enum tgsi_break_type BreakStack[TGSI_EXEC_MAX_BREAK_STACK];
+   int BreakStackTop;
+
    /** Function execution mask stack (for executing subroutine code) */
    uint FuncStack[TGSI_EXEC_MAX_CALL_NESTING];
    int FuncStackTop;
index 17af4cb7ad2ecc22d4b43c264da355d05107ed18..de0e09cdbae18fc3ca40db9c6ad7dff8fbec4d70 100644 (file)
@@ -119,7 +119,7 @@ static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] =
    { 1, 1, 0, 0, 0, 0, "NOT", TGSI_OPCODE_NOT },
    { 1, 1, 0, 0, 0, 0, "TRUNC", TGSI_OPCODE_TRUNC },
    { 1, 2, 0, 0, 0, 0, "SHL", TGSI_OPCODE_SHL },
-   { 1, 2, 0, 0, 0, 0, "SHR", TGSI_OPCODE_SHR },
+   { 0, 0, 0, 0, 0, 0, "", 88 },      /* removed */
    { 1, 2, 0, 0, 0, 0, "AND", TGSI_OPCODE_AND },
    { 1, 2, 0, 0, 0, 0, "OR", TGSI_OPCODE_OR },
    { 1, 2, 0, 0, 0, 0, "MOD", TGSI_OPCODE_MOD },
@@ -134,10 +134,10 @@ static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] =
    { 0, 0, 0, 0, 0, 1, "BGNSUB", TGSI_OPCODE_BGNSUB },
    { 0, 0, 0, 1, 1, 0, "ENDLOOP", TGSI_OPCODE_ENDLOOP },
    { 0, 0, 0, 0, 1, 0, "ENDSUB", TGSI_OPCODE_ENDSUB },
-   { 1, 1, 0, 0, 0, 0, "NOISE1", TGSI_OPCODE_NOISE1 },
-   { 1, 1, 0, 0, 0, 0, "NOISE2", TGSI_OPCODE_NOISE2 },
-   { 1, 1, 0, 0, 0, 0, "NOISE3", TGSI_OPCODE_NOISE3 },
-   { 1, 1, 0, 0, 0, 0, "NOISE4", TGSI_OPCODE_NOISE4 },
+   { 0, 0, 0, 0, 0, 0, "", 103 },     /* removed */
+   { 0, 0, 0, 0, 0, 0, "", 104 },     /* removed */
+   { 0, 0, 0, 0, 0, 0, "", 105 },     /* removed */
+   { 0, 0, 0, 0, 0, 0, "", 106 },     /* removed */
    { 0, 0, 0, 0, 0, 0, "NOP", TGSI_OPCODE_NOP },
    { 0, 0, 0, 0, 0, 0, "", 108 },     /* removed */
    { 0, 0, 0, 0, 0, 0, "", 109 },     /* removed */
@@ -149,7 +149,33 @@ static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] =
    { 0, 1, 0, 0, 0, 0, "BREAKC", TGSI_OPCODE_BREAKC },
    { 0, 1, 0, 0, 0, 0, "KIL", TGSI_OPCODE_KIL },
    { 0, 0, 0, 0, 0, 0, "END", TGSI_OPCODE_END },
-   { 1, 1, 0, 0, 0, 0, "SWZ", TGSI_OPCODE_SWZ }
+   { 0, 0, 0, 0, 0, 0, "", 118 },     /* removed */
+   { 1, 1, 0, 0, 0, 0, "F2I", TGSI_OPCODE_F2I },
+   { 1, 2, 0, 0, 0, 0, "IDIV", TGSI_OPCODE_IDIV },
+   { 1, 2, 0, 0, 0, 0, "IMAX", TGSI_OPCODE_IMAX },
+   { 1, 2, 0, 0, 0, 0, "IMIN", TGSI_OPCODE_IMIN },
+   { 1, 1, 0, 0, 0, 0, "INEG", TGSI_OPCODE_INEG },
+   { 1, 2, 0, 0, 0, 0, "ISGE", TGSI_OPCODE_ISGE },
+   { 1, 2, 0, 0, 0, 0, "ISHR", TGSI_OPCODE_ISHR },
+   { 1, 2, 0, 0, 0, 0, "ISLT", TGSI_OPCODE_ISLT },
+   { 1, 1, 0, 0, 0, 0, "F2U", TGSI_OPCODE_F2U },
+   { 1, 1, 0, 0, 0, 0, "U2F", TGSI_OPCODE_U2F },
+   { 1, 2, 0, 0, 0, 0, "UADD", TGSI_OPCODE_UADD },
+   { 1, 2, 0, 0, 0, 0, "UDIV", TGSI_OPCODE_UDIV },
+   { 1, 3, 0, 0, 0, 0, "UMAD", TGSI_OPCODE_UMAD },
+   { 1, 2, 0, 0, 0, 0, "UMAX", TGSI_OPCODE_UMAX },
+   { 1, 2, 0, 0, 0, 0, "UMIN", TGSI_OPCODE_UMIN },
+   { 1, 2, 0, 0, 0, 0, "UMOD", TGSI_OPCODE_UMOD },
+   { 1, 2, 0, 0, 0, 0, "UMUL", TGSI_OPCODE_UMUL },
+   { 1, 2, 0, 0, 0, 0, "USEQ", TGSI_OPCODE_USEQ },
+   { 1, 2, 0, 0, 0, 0, "USGE", TGSI_OPCODE_USGE },
+   { 1, 2, 0, 0, 0, 0, "USHR", TGSI_OPCODE_USHR },
+   { 1, 2, 0, 0, 0, 0, "USLT", TGSI_OPCODE_USLT },
+   { 1, 2, 0, 0, 0, 0, "USNE", TGSI_OPCODE_USNE },
+   { 0, 1, 0, 0, 0, 0, "SWITCH", TGSI_OPCODE_SWITCH },
+   { 0, 1, 0, 0, 0, 0, "CASE", TGSI_OPCODE_CASE },
+   { 0, 0, 0, 0, 0, 0, "DEFAULT", TGSI_OPCODE_DEFAULT },
+   { 0, 0, 0, 0, 0, 0, "ENDSWITCH", TGSI_OPCODE_ENDSWITCH }
 };
 
 const struct tgsi_opcode_info *
index d88c2558d81dcfd6541a7d255a8b0515719129dd..0ba5fe48419bdcd0df467824ac4c996506e11535 100644 (file)
@@ -39,7 +39,6 @@ tgsi_iterate_shader(
       return FALSE;
 
    ctx->processor = parse.FullHeader.Processor;
-   ctx->version = parse.FullVersion.Version;
 
    if (ctx->prolog)
       if (!ctx->prolog( ctx ))
@@ -67,6 +66,12 @@ tgsi_iterate_shader(
                goto fail;
          break;
 
+      case TGSI_TOKEN_TYPE_PROPERTY:
+         if (ctx->iterate_property)
+            if (!ctx->iterate_property( ctx,  &parse.FullToken.FullProperty ))
+               goto fail;
+         break;
+
       default:
          assert( 0 );
       }
index ec7b85bf63d667f8833ef2be559c748705223298..8d67f22c4295d16a660f55e692e0cb856a9147e2 100644 (file)
@@ -56,12 +56,16 @@ struct tgsi_iterate_context
       struct tgsi_iterate_context *ctx,
       struct tgsi_full_immediate *imm );
 
+   boolean
+   (* iterate_property)(
+      struct tgsi_iterate_context *ctx,
+      struct tgsi_full_property *prop );
+
    boolean
    (* epilog)(
       struct tgsi_iterate_context *ctx );
 
    struct tgsi_processor processor;
-   struct tgsi_version version;
 };
 
 boolean
index e7bcf4bf7543c154b7ee2c8232fbe2c52d02c5f1..e4af15c156fe8235883253d0956e64cb9b3f49b4 100644 (file)
@@ -124,7 +124,6 @@ OP11(I2F)
 OP11(NOT)
 OP11(TRUNC)
 OP12(SHL)
-OP12(SHR)
 OP12(AND)
 OP12(OR)
 OP12(MOD)
@@ -139,10 +138,6 @@ OP00_LBL(BGNLOOP)
 OP00(BGNSUB)
 OP00_LBL(ENDLOOP)
 OP00(ENDSUB)
-OP11(NOISE1)
-OP11(NOISE2)
-OP11(NOISE3)
-OP11(NOISE4)
 OP00(NOP)
 OP11(NRM4)
 OP01(CALLNZ)
@@ -150,7 +145,28 @@ OP01(IFC)
 OP01(BREAKC)
 OP01(KIL)
 OP00(END)
-OP11(SWZ)
+OP11(F2I)
+OP12(IDIV)
+OP12(IMAX)
+OP12(IMIN)
+OP11(INEG)
+OP12(ISGE)
+OP12(ISHR)
+OP12(ISLT)
+OP11(F2U)
+OP11(U2F)
+OP12(UADD)
+OP12(UDIV)
+OP13(UMAD)
+OP12(UMAX)
+OP12(UMIN)
+OP12(UMOD)
+OP12(UMUL)
+OP12(USEQ)
+OP12(USGE)
+OP12(USHR)
+OP12(USLT)
+OP12(USNE)
 
 
 #undef OP00
index 4870f82b6bd111d23bcd7bdecff7d5f33d70f587..8c7062d850cf77d4466c3c12a7754af89de9f6b3 100644 (file)
 #include "util/u_debug.h"
 #include "pipe/p_shader_tokens.h"
 #include "tgsi_parse.h"
-#include "tgsi_build.h"
 #include "util/u_memory.h"
 
-void
-tgsi_full_token_init(
-   union tgsi_full_token *full_token )
-{
-   full_token->Token.Type = TGSI_TOKEN_TYPE_DECLARATION;
-}
-
-void
-tgsi_full_token_free(
-   union tgsi_full_token *full_token )
-{
-}
-
 unsigned
 tgsi_parse_init(
    struct tgsi_parse_context *ctx,
    const struct tgsi_token *tokens )
 {
-   ctx->FullVersion.Version = *(struct tgsi_version *) &tokens[0];
-   if( ctx->FullVersion.Version.MajorVersion > 1 ) {
-      return TGSI_PARSE_ERROR;
-   }
-
-   ctx->FullHeader.Header = *(struct tgsi_header *) &tokens[1];
+   ctx->FullHeader.Header = *(struct tgsi_header *) &tokens[0];
    if( ctx->FullHeader.Header.HeaderSize >= 2 ) {
-      ctx->FullHeader.Processor = *(struct tgsi_processor *) &tokens[2];
+      ctx->FullHeader.Processor = *(struct tgsi_processor *) &tokens[1];
    }
    else {
-      ctx->FullHeader.Processor = tgsi_default_processor();
+      return TGSI_PARSE_ERROR;
    }
 
    ctx->Tokens = tokens;
-   ctx->Position = 1 + ctx->FullHeader.Header.HeaderSize;
-
-   tgsi_full_token_init( &ctx->FullToken );
+   ctx->Position = ctx->FullHeader.Header.HeaderSize;
 
    return TGSI_PARSE_OK;
 }
@@ -74,7 +53,6 @@ void
 tgsi_parse_free(
    struct tgsi_parse_context *ctx )
 {
-   tgsi_full_token_free( &ctx->FullToken );
 }
 
 boolean
@@ -82,7 +60,7 @@ tgsi_parse_end_of_tokens(
    struct tgsi_parse_context *ctx )
 {
    return ctx->Position >=
-      1 + ctx->FullHeader.Header.HeaderSize + ctx->FullHeader.Header.BodySize;
+      ctx->FullHeader.Header.HeaderSize + ctx->FullHeader.Header.BodySize;
 }
 
 
@@ -119,9 +97,6 @@ tgsi_parse_token(
    struct tgsi_token token;
    unsigned i;
 
-   tgsi_full_token_free( &ctx->FullToken );
-   tgsi_full_token_init( &ctx->FullToken );
-
    next_token( ctx, &token );
 
    switch( token.Type ) {
@@ -129,10 +104,10 @@ tgsi_parse_token(
    {
       struct tgsi_full_declaration *decl = &ctx->FullToken.FullDeclaration;
 
-      *decl = tgsi_default_full_declaration();
+      memset(decl, 0, sizeof *decl);
       copy_token(&decl->Declaration, &token);
 
-      next_token( ctx, &decl->DeclarationRange );
+      next_token( ctx, &decl->Range );
 
       if( decl->Declaration.Semantic ) {
          next_token( ctx, &decl->Semantic );
@@ -144,18 +119,29 @@ tgsi_parse_token(
    case TGSI_TOKEN_TYPE_IMMEDIATE:
    {
       struct tgsi_full_immediate *imm = &ctx->FullToken.FullImmediate;
+      uint imm_count;
 
-      *imm = tgsi_default_full_immediate();
+      memset(imm, 0, sizeof *imm);
       copy_token(&imm->Immediate, &token);
-      assert( !imm->Immediate.Extended );
+
+      imm_count = imm->Immediate.NrTokens - 1;
 
       switch (imm->Immediate.DataType) {
       case TGSI_IMM_FLOAT32:
-         {
-            uint imm_count = imm->Immediate.NrTokens - 1;
-            for (i = 0; i < imm_count; i++) {
-               next_token(ctx, &imm->u[i]);
-            }
+         for (i = 0; i < imm_count; i++) {
+            next_token(ctx, &imm->u[i].Float);
+         }
+         break;
+
+      case TGSI_IMM_UINT32:
+         for (i = 0; i < imm_count; i++) {
+            next_token(ctx, &imm->u[i].Uint);
+         }
+         break;
+
+      case TGSI_IMM_INT32:
+         for (i = 0; i < imm_count; i++) {
+            next_token(ctx, &imm->u[i].Int);
          }
          break;
 
@@ -169,147 +155,76 @@ tgsi_parse_token(
    case TGSI_TOKEN_TYPE_INSTRUCTION:
    {
       struct tgsi_full_instruction *inst = &ctx->FullToken.FullInstruction;
-      unsigned extended;
 
-      *inst = tgsi_default_full_instruction();
+      memset(inst, 0, sizeof *inst);
       copy_token(&inst->Instruction, &token);
-      extended = inst->Instruction.Extended;
-
-      while( extended ) {
-         struct tgsi_src_register_ext token;
-
-         next_token( ctx, &token );
-
-         switch( token.Type ) {
-         case TGSI_INSTRUCTION_EXT_TYPE_NV:
-            copy_token(&inst->InstructionExtNv, &token);
-            break;
 
-         case TGSI_INSTRUCTION_EXT_TYPE_LABEL:
-            copy_token(&inst->InstructionExtLabel, &token);
-            break;
-
-         case TGSI_INSTRUCTION_EXT_TYPE_TEXTURE:
-            copy_token(&inst->InstructionExtTexture, &token);
-            break;
+      if (inst->Instruction.Predicate) {
+         next_token(ctx, &inst->Predicate);
+      }
 
-         default:
-            assert( 0 );
-         }
+      if (inst->Instruction.Label) {
+         next_token( ctx, &inst->Label);
+      }
 
-         extended = token.Extended;
+      if (inst->Instruction.Texture) {
+         next_token( ctx, &inst->Texture);
       }
 
       assert( inst->Instruction.NumDstRegs <= TGSI_FULL_MAX_DST_REGISTERS );
 
       for(  i = 0; i < inst->Instruction.NumDstRegs; i++ ) {
-         unsigned extended;
 
-         next_token( ctx, &inst->FullDstRegisters[i].DstRegister );
+         next_token( ctx, &inst->Dst[i].Register );
 
          /*
           * No support for indirect or multi-dimensional addressing.
           */
-         assert( !inst->FullDstRegisters[i].DstRegister.Dimension );
-
-         extended = inst->FullDstRegisters[i].DstRegister.Extended;
-
-         while( extended ) {
-            struct tgsi_src_register_ext token;
-
-            next_token( ctx, &token );
-
-            switch( token.Type ) {
-            case TGSI_DST_REGISTER_EXT_TYPE_CONDCODE:
-               copy_token(&inst->FullDstRegisters[i].DstRegisterExtConcode,
-                          &token);
-               break;
-
-            case TGSI_DST_REGISTER_EXT_TYPE_MODULATE:
-               copy_token(&inst->FullDstRegisters[i].DstRegisterExtModulate,
-                          &token);
-               break;
-
-            default:
-               assert( 0 );
-            }
-
-            extended = token.Extended;
-         }
+         assert( !inst->Dst[i].Register.Dimension );
 
-         if( inst->FullDstRegisters[i].DstRegister.Indirect ) {
-            next_token( ctx, &inst->FullDstRegisters[i].DstRegisterInd );
+         if( inst->Dst[i].Register.Indirect ) {
+            next_token( ctx, &inst->Dst[i].Indirect );
 
             /*
              * No support for indirect or multi-dimensional addressing.
              */
-            assert( !inst->FullDstRegisters[i].DstRegisterInd.Indirect );
-            assert( !inst->FullDstRegisters[i].DstRegisterInd.Dimension );
-            assert( !inst->FullDstRegisters[i].DstRegisterInd.Extended );
+            assert( !inst->Dst[i].Indirect.Dimension );
+            assert( !inst->Dst[i].Indirect.Indirect );
          }
       }
 
       assert( inst->Instruction.NumSrcRegs <= TGSI_FULL_MAX_SRC_REGISTERS );
 
       for( i = 0; i < inst->Instruction.NumSrcRegs; i++ ) {
-         unsigned extended;
-
-         next_token( ctx, &inst->FullSrcRegisters[i].SrcRegister );
-
-         extended = inst->FullSrcRegisters[i].SrcRegister.Extended;
-
-         while( extended ) {
-            struct tgsi_src_register_ext token;
-
-            next_token( ctx, &token );
 
-            switch( token.Type ) {
-            case TGSI_SRC_REGISTER_EXT_TYPE_SWZ:
-               copy_token(&inst->FullSrcRegisters[i].SrcRegisterExtSwz,
-                          &token);
-               break;
+         next_token( ctx, &inst->Src[i].Register );
 
-            case TGSI_SRC_REGISTER_EXT_TYPE_MOD:
-               copy_token(&inst->FullSrcRegisters[i].SrcRegisterExtMod,
-                          &token);
-               break;
-
-            default:
-               assert( 0 );
-            }
-
-            extended = token.Extended;
-         }
-
-         if( inst->FullSrcRegisters[i].SrcRegister.Indirect ) {
-            next_token( ctx, &inst->FullSrcRegisters[i].SrcRegisterInd );
+         if( inst->Src[i].Register.Indirect ) {
+            next_token( ctx, &inst->Src[i].Indirect );
 
             /*
              * No support for indirect or multi-dimensional addressing.
              */
-            assert( !inst->FullSrcRegisters[i].SrcRegisterInd.Indirect );
-            assert( !inst->FullSrcRegisters[i].SrcRegisterInd.Dimension );
-            assert( !inst->FullSrcRegisters[i].SrcRegisterInd.Extended );
+            assert( !inst->Src[i].Indirect.Indirect );
+            assert( !inst->Src[i].Indirect.Dimension );
          }
 
-         if( inst->FullSrcRegisters[i].SrcRegister.Dimension ) {
-            next_token( ctx, &inst->FullSrcRegisters[i].SrcRegisterDim );
+         if( inst->Src[i].Register.Dimension ) {
+            next_token( ctx, &inst->Src[i].Dimension );
 
             /*
              * No support for multi-dimensional addressing.
              */
-            assert( !inst->FullSrcRegisters[i].SrcRegisterDim.Dimension );
-            assert( !inst->FullSrcRegisters[i].SrcRegisterDim.Extended );
+            assert( !inst->Src[i].Dimension.Dimension );
 
-            if( inst->FullSrcRegisters[i].SrcRegisterDim.Indirect ) {
-               next_token( ctx, &inst->FullSrcRegisters[i].SrcRegisterDimInd );
+            if( inst->Src[i].Dimension.Indirect ) {
+               next_token( ctx, &inst->Src[i].DimIndirect );
 
                /*
                * No support for indirect or multi-dimensional addressing.
                */
-               assert( !inst->FullSrcRegisters[i].SrcRegisterInd.Indirect );
-               assert( !inst->FullSrcRegisters[i].SrcRegisterInd.Dimension );
-               assert( !inst->FullSrcRegisters[i].SrcRegisterInd.Extended );
+               assert( !inst->Src[i].Indirect.Indirect );
+               assert( !inst->Src[i].Indirect.Dimension );
             }
          }
       }
@@ -317,6 +232,22 @@ tgsi_parse_token(
       break;
    }
 
+   case TGSI_TOKEN_TYPE_PROPERTY:
+   {
+      struct tgsi_full_property *prop = &ctx->FullToken.FullProperty;
+      uint prop_count;
+
+      memset(prop, 0, sizeof *prop);
+      copy_token(&prop->Property, &token);
+
+      prop_count = prop->Property.NrTokens - 1;
+      for (i = 0; i < prop_count; i++) {
+         next_token(ctx, &prop->u[i]);
+      }
+
+      break;
+   }
+
    default:
       assert( 0 );
    }
@@ -329,8 +260,7 @@ tgsi_num_tokens(const struct tgsi_token *tokens)
    struct tgsi_parse_context ctx;
    if (tgsi_parse_init(&ctx, tokens) == TGSI_PARSE_OK) {
       unsigned len = (ctx.FullHeader.Header.HeaderSize +
-                      ctx.FullHeader.Header.BodySize +
-                      1);
+                      ctx.FullHeader.Header.BodySize);
       return len;
    }
    return 0;
index a26ee5ba8627e80fc11359e79e255a1b4f6ab048..439a57269b7ef4e85565b08113d88b08cdb455b9 100644 (file)
 extern "C" {
 #endif
 
-struct tgsi_full_version
-{
-   struct tgsi_version  Version;
-};
-
 struct tgsi_full_header
 {
    struct tgsi_header      Header;
@@ -47,26 +42,22 @@ struct tgsi_full_header
 
 struct tgsi_full_dst_register
 {
-   struct tgsi_dst_register               DstRegister;
-   struct tgsi_src_register               DstRegisterInd;
-   struct tgsi_dst_register_ext_concode   DstRegisterExtConcode;
-   struct tgsi_dst_register_ext_modulate  DstRegisterExtModulate;
+   struct tgsi_dst_register               Register;
+   struct tgsi_src_register               Indirect;
 };
 
 struct tgsi_full_src_register
 {
-   struct tgsi_src_register         SrcRegister;
-   struct tgsi_src_register_ext_swz SrcRegisterExtSwz;
-   struct tgsi_src_register_ext_mod SrcRegisterExtMod;
-   struct tgsi_src_register         SrcRegisterInd;
-   struct tgsi_dimension            SrcRegisterDim;
-   struct tgsi_src_register         SrcRegisterDimInd;
+   struct tgsi_src_register         Register;
+   struct tgsi_src_register         Indirect;
+   struct tgsi_dimension            Dimension;
+   struct tgsi_src_register         DimIndirect;
 };
 
 struct tgsi_full_declaration
 {
    struct tgsi_declaration Declaration;
-   struct tgsi_declaration_range DeclarationRange;
+   struct tgsi_declaration_range Range;
    struct tgsi_declaration_semantic Semantic;
 };
 
@@ -76,18 +67,23 @@ struct tgsi_full_immediate
    union tgsi_immediate_data u[4];
 };
 
+struct tgsi_full_property
+{
+   struct tgsi_property   Property;
+   struct tgsi_property_data u[8];
+};
+
 #define TGSI_FULL_MAX_DST_REGISTERS 2
 #define TGSI_FULL_MAX_SRC_REGISTERS 4 /* TXD has 4 */
 
 struct tgsi_full_instruction
 {
    struct tgsi_instruction             Instruction;
-   struct tgsi_instruction_ext_nv      InstructionExtNv;
-   struct tgsi_instruction_ext_label   InstructionExtLabel;
-   struct tgsi_instruction_ext_texture InstructionExtTexture;
-   struct tgsi_full_dst_register       FullDstRegisters[TGSI_FULL_MAX_DST_REGISTERS];
-   struct tgsi_full_src_register       FullSrcRegisters[TGSI_FULL_MAX_SRC_REGISTERS];
-   uint Flags;  /**< user-defined usage */
+   struct tgsi_instruction_predicate   Predicate;
+   struct tgsi_instruction_label       Label;
+   struct tgsi_instruction_texture     Texture;
+   struct tgsi_full_dst_register       Dst[TGSI_FULL_MAX_DST_REGISTERS];
+   struct tgsi_full_src_register       Src[TGSI_FULL_MAX_SRC_REGISTERS];
 };
 
 union tgsi_full_token
@@ -96,21 +92,13 @@ union tgsi_full_token
    struct tgsi_full_declaration  FullDeclaration;
    struct tgsi_full_immediate    FullImmediate;
    struct tgsi_full_instruction  FullInstruction;
+   struct tgsi_full_property     FullProperty;
 };
 
-void
-tgsi_full_token_init(
-   union tgsi_full_token *full_token );
-
-void
-tgsi_full_token_free(
-   union tgsi_full_token *full_token );
-
 struct tgsi_parse_context
 {
    const struct tgsi_token    *Tokens;
    unsigned                   Position;
-   struct tgsi_full_version   FullVersion;
    struct tgsi_full_header    FullHeader;
    union tgsi_full_token      FullToken;
 };
index 4b1c7d4e01bca0e271b25ab8b5c909f97cc3315c..138d2d095bb037577148113ccc8a43ee958c5a10 100644 (file)
@@ -60,7 +60,7 @@ const float ppc_builtin_constants[] ALIGN16_ATTRIB = {
    for (CHAN = 0; CHAN < NUM_CHANNELS; CHAN++)
 
 #define IS_DST0_CHANNEL_ENABLED( INST, CHAN )\
-   ((INST).FullDstRegisters[0].DstRegister.WriteMask & (1 << (CHAN)))
+   ((INST).Dst[0].Register.WriteMask & (1 << (CHAN)))
 
 #define IF_IS_DST0_CHANNEL_ENABLED( INST, CHAN )\
    if (IS_DST0_CHANNEL_ENABLED( INST, CHAN ))
@@ -156,8 +156,8 @@ init_gen_context(struct gen_context *gen, struct ppc_function *func)
 static boolean
 is_ppc_vec_temporary(const struct tgsi_full_src_register *reg)
 {
-   return (reg->SrcRegister.File == TGSI_FILE_TEMPORARY &&
-           reg->SrcRegister.Index < MAX_PPC_TEMPS);
+   return (reg->Register.File == TGSI_FILE_TEMPORARY &&
+           reg->Register.Index < MAX_PPC_TEMPS);
 }
 
 
@@ -167,8 +167,8 @@ is_ppc_vec_temporary(const struct tgsi_full_src_register *reg)
 static boolean
 is_ppc_vec_temporary_dst(const struct tgsi_full_dst_register *reg)
 {
-   return (reg->DstRegister.File == TGSI_FILE_TEMPORARY &&
-           reg->DstRegister.Index < MAX_PPC_TEMPS);
+   return (reg->Register.File == TGSI_FILE_TEMPORARY &&
+           reg->Register.Index < MAX_PPC_TEMPS);
 }
 
 
@@ -283,18 +283,19 @@ emit_fetch(struct gen_context *gen,
            const struct tgsi_full_src_register *reg,
            const unsigned chan_index)
 {
-   uint swizzle = tgsi_util_get_full_src_register_extswizzle(reg, chan_index);
+   uint swizzle = tgsi_util_get_full_src_register_swizzle(reg, chan_index);
    int dst_vec = -1;
 
    switch (swizzle) {
-   case TGSI_EXTSWIZZLE_X:
-   case TGSI_EXTSWIZZLE_Y:
-   case TGSI_EXTSWIZZLE_Z:
-   case TGSI_EXTSWIZZLE_W:
-      switch (reg->SrcRegister.File) {
+   case TGSI_SWIZZLE_X:
+   case TGSI_SWIZZLE_Y:
+   case TGSI_SWIZZLE_Z:
+   case TGSI_SWIZZLE_W:
+      switch (reg->Register.File) {
       case TGSI_FILE_INPUT:
+      case TGSI_FILE_SYSTEM_VALUE:
          {
-            int offset = (reg->SrcRegister.Index * 4 + swizzle) * 16;
+            int offset = (reg->Register.Index * 4 + swizzle) * 16;
             int offset_reg = emit_li_offset(gen, offset);
             dst_vec = ppc_allocate_vec_register(gen->f);
             ppc_lvx(gen->f, dst_vec, gen->inputs_reg, offset_reg);
@@ -303,11 +304,11 @@ emit_fetch(struct gen_context *gen,
       case TGSI_FILE_TEMPORARY:
          if (is_ppc_vec_temporary(reg)) {
             /* use PPC vec register */
-            dst_vec = gen->temps_map[reg->SrcRegister.Index][swizzle];
+            dst_vec = gen->temps_map[reg->Register.Index][swizzle];
          }
          else {
             /* use memory-based temp register "file" */
-            int offset = (reg->SrcRegister.Index * 4 + swizzle) * 16;
+            int offset = (reg->Register.Index * 4 + swizzle) * 16;
             int offset_reg = emit_li_offset(gen, offset);
             dst_vec = ppc_allocate_vec_register(gen->f);
             ppc_lvx(gen->f, dst_vec, gen->temps_reg, offset_reg);
@@ -315,7 +316,7 @@ emit_fetch(struct gen_context *gen,
          break;
       case TGSI_FILE_IMMEDIATE:
          {
-            int offset = (reg->SrcRegister.Index * 4 + swizzle) * 4;
+            int offset = (reg->Register.Index * 4 + swizzle) * 4;
             int offset_reg = emit_li_offset(gen, offset);
             dst_vec = ppc_allocate_vec_register(gen->f);
             /* Load 4-byte word into vector register.
@@ -331,7 +332,7 @@ emit_fetch(struct gen_context *gen,
          break;
       case TGSI_FILE_CONSTANT:
          {
-            int offset = (reg->SrcRegister.Index * 4 + swizzle) * 4;
+            int offset = (reg->Register.Index * 4 + swizzle) * 4;
             int offset_reg = emit_li_offset(gen, offset);
             dst_vec = ppc_allocate_vec_register(gen->f);
             /* Load 4-byte word into vector register.
@@ -349,16 +350,6 @@ emit_fetch(struct gen_context *gen,
          assert( 0 );
       }
       break;
-   case TGSI_EXTSWIZZLE_ZERO:
-      ppc_vzero(gen->f, dst_vec);
-      break;
-   case TGSI_EXTSWIZZLE_ONE:
-      {
-         int one_vec = gen_one_vec(gen);
-         dst_vec = ppc_allocate_vec_register(gen->f);
-         ppc_vmove(gen->f, dst_vec, one_vec);
-      }
-      break;
    default:
       assert( 0 );
    }
@@ -414,12 +405,12 @@ equal_src_locs(const struct tgsi_full_src_register *a, uint chan_a,
 {
    int swz_a, swz_b;
    int sign_a, sign_b;
-   if (a->SrcRegister.File != b->SrcRegister.File)
+   if (a->Register.File != b->Register.File)
       return FALSE;
-   if (a->SrcRegister.Index != b->SrcRegister.Index)
+   if (a->Register.Index != b->Register.Index)
       return FALSE;
-   swz_a = tgsi_util_get_full_src_register_extswizzle(a, chan_a);
-   swz_b = tgsi_util_get_full_src_register_extswizzle(b, chan_b);
+   swz_a = tgsi_util_get_full_src_register_swizzle(a, chan_a);
+   swz_b = tgsi_util_get_full_src_register_swizzle(b, chan_b);
    if (swz_a != swz_b)
       return FALSE;
    sign_a = tgsi_util_get_full_src_register_sign_mode(a, chan_a);
@@ -441,7 +432,7 @@ get_src_vec(struct gen_context *gen,
             struct tgsi_full_instruction *inst, int src_reg, uint chan)
 {
    const const struct tgsi_full_src_register *src = 
-      &inst->FullSrcRegisters[src_reg];
+      &inst->Src[src_reg];
    int vec;
    uint i;
 
@@ -492,10 +483,10 @@ get_dst_vec(struct gen_context *gen,
             const struct tgsi_full_instruction *inst,
             unsigned chan_index)
 {
-   const struct tgsi_full_dst_register *reg = &inst->FullDstRegisters[0];
+   const struct tgsi_full_dst_register *reg = &inst->Dst[0];
 
    if (is_ppc_vec_temporary_dst(reg)) {
-      int vec = gen->temps_map[reg->DstRegister.Index][chan_index];
+      int vec = gen->temps_map[reg->Register.Index][chan_index];
       return vec;
    }
    else {
@@ -515,12 +506,12 @@ emit_store(struct gen_context *gen,
            unsigned chan_index,
            boolean free_vec)
 {
-   const struct tgsi_full_dst_register *reg = &inst->FullDstRegisters[0];
+   const struct tgsi_full_dst_register *reg = &inst->Dst[0];
 
-   switch (reg->DstRegister.File) {
+   switch (reg->Register.File) {
    case TGSI_FILE_OUTPUT:
       {
-         int offset = (reg->DstRegister.Index * 4 + chan_index) * 16;
+         int offset = (reg->Register.Index * 4 + chan_index) * 16;
          int offset_reg = emit_li_offset(gen, offset);
          ppc_stvx(gen->f, src_vec, gen->outputs_reg, offset_reg);
       }
@@ -528,14 +519,14 @@ emit_store(struct gen_context *gen,
    case TGSI_FILE_TEMPORARY:
       if (is_ppc_vec_temporary_dst(reg)) {
          if (!free_vec) {
-            int dst_vec = gen->temps_map[reg->DstRegister.Index][chan_index];
+            int dst_vec = gen->temps_map[reg->Register.Index][chan_index];
             if (dst_vec != src_vec)
                ppc_vmove(gen->f, dst_vec, src_vec);
          }
          free_vec = FALSE;
       }
       else {
-         int offset = (reg->DstRegister.Index * 4 + chan_index) * 16;
+         int offset = (reg->Register.Index * 4 + chan_index) * 16;
          int offset_reg = emit_li_offset(gen, offset);
          ppc_stvx(gen->f, src_vec, gen->temps_reg, offset_reg);
       }
@@ -545,7 +536,7 @@ emit_store(struct gen_context *gen,
       emit_addrs(
          func,
          xmm,
-         reg->DstRegister.Index,
+         reg->Register.Index,
          chan_index );
       break;
 #endif
@@ -635,7 +626,6 @@ emit_unaryop(struct gen_context *gen, struct tgsi_full_instruction *inst)
          ppc_vlogefp(gen->f, v1, v0);      /* v1 = log2(v0) */
          break;
       case TGSI_OPCODE_MOV:
-      case TGSI_OPCODE_SWZ:
          if (v0 != v1)
             ppc_vmove(gen->f, v1, v0);
          break;
@@ -1119,7 +1109,6 @@ emit_instruction(struct gen_context *gen,
 
    switch (inst->Instruction.Opcode) {
    case TGSI_OPCODE_MOV:
-   case TGSI_OPCODE_SWZ:
    case TGSI_OPCODE_ABS:
    case TGSI_OPCODE_FLR:
    case TGSI_OPCODE_FRC:
@@ -1185,13 +1174,14 @@ emit_declaration(
    struct ppc_function *func,
    struct tgsi_full_declaration *decl )
 {
-   if( decl->Declaration.File == TGSI_FILE_INPUT ) {
+   if( decl->Declaration.File == TGSI_FILE_INPUT ||
+       decl->Declaration.File == TGSI_FILE_SYSTEM_VALUE ) {
 #if 0
       unsigned first, last, mask;
       unsigned i, j;
 
-      first = decl->DeclarationRange.First;
-      last = decl->DeclarationRange.Last;
+      first = decl->Range.First;
+      last = decl->Range.Last;
       mask = decl->Declaration.UsageMask;
 
       for( i = first; i <= last; i++ ) {
@@ -1351,6 +1341,9 @@ tgsi_emit_ppc(const struct tgsi_token *tokens,
          }
          break;
 
+      case TGSI_TOKEN_TYPE_PROPERTY:
+         break;
+
       default:
         ok = 0;
          assert( 0 );
index 53e13b30e63c4442d7f9903e1133a4c589050079..7f1c8e5dd68aea1575f4a35ea1706e6b3342990c 100644 (file)
  **************************************************************************/
 
 #include "util/u_debug.h"
+#include "util/u_memory.h"
+#include "util/u_prim.h"
+#include "cso_cache/cso_hash.h"
 #include "tgsi_sanity.h"
 #include "tgsi_info.h"
 #include "tgsi_iterate.h"
 
-typedef uint reg_flag;
-
-#define BITS_IN_REG_FLAG (sizeof( reg_flag ) * 8)
-
-#define MAX_REGISTERS 256
-#define MAX_REG_FLAGS ((MAX_REGISTERS + BITS_IN_REG_FLAG - 1) / BITS_IN_REG_FLAG)
+typedef struct {
+   uint file : 28;
+   /* max 2 dimensions */
+   uint dimensions : 4;
+   uint indices[2];
+} scan_register;
 
 struct sanity_check_ctx
 {
    struct tgsi_iterate_context iter;
+   struct cso_hash *regs_decl;
+   struct cso_hash *regs_used;
+   struct cso_hash *regs_ind_used;
 
-   reg_flag regs_decl[TGSI_FILE_COUNT][MAX_REG_FLAGS];
-   reg_flag regs_used[TGSI_FILE_COUNT][MAX_REG_FLAGS];
-   boolean regs_ind_used[TGSI_FILE_COUNT];
    uint num_imms;
    uint num_instructions;
    uint index_of_END;
 
    uint errors;
    uint warnings;
+   uint implied_array_size;
 };
 
+static INLINE unsigned
+scan_register_key(const scan_register *reg)
+{
+   unsigned key = reg->file;
+   key |= (reg->indices[0] << 4);
+   key |= (reg->indices[1] << 18);
+
+   return key;
+}
+
+static void
+fill_scan_register1d(scan_register *reg,
+                     uint file, uint index)
+{
+   reg->file = file;
+   reg->dimensions = 1;
+   reg->indices[0] = index;
+   reg->indices[1] = 0;
+}
+
+static void
+fill_scan_register2d(scan_register *reg,
+                     uint file, uint index1, uint index2)
+{
+   reg->file = file;
+   reg->dimensions = 2;
+   reg->indices[0] = index1;
+   reg->indices[1] = index2;
+}
+
+static void
+scan_register_dst(scan_register *reg,
+                  struct tgsi_full_dst_register *dst)
+{
+   fill_scan_register1d(reg,
+                        dst->Register.File,
+                        dst->Register.Index);
+}
+
+static void
+scan_register_src(scan_register *reg,
+                  struct tgsi_full_src_register *src)
+{
+   if (src->Register.Dimension) {
+      /*FIXME: right now we don't support indirect
+       * multidimensional addressing */
+      debug_assert(!src->Dimension.Indirect);
+      fill_scan_register2d(reg,
+                           src->Register.File,
+                           src->Register.Index,
+                           src->Dimension.Index);
+   } else {
+      fill_scan_register1d(reg,
+                           src->Register.File,
+                           src->Register.Index);
+   }
+}
+
+static scan_register *
+create_scan_register_src(struct tgsi_full_src_register *src)
+{
+   scan_register *reg = MALLOC(sizeof(scan_register));
+   scan_register_src(reg, src);
+
+   return reg;
+}
+
+static scan_register *
+create_scan_register_dst(struct tgsi_full_dst_register *dst)
+{
+   scan_register *reg = MALLOC(sizeof(scan_register));
+   scan_register_dst(reg, dst);
+
+   return reg;
+}
+
 static void
 report_error(
    struct sanity_check_ctx *ctx,
@@ -99,12 +179,12 @@ check_file_name(
 static boolean
 is_register_declared(
    struct sanity_check_ctx *ctx,
-   uint file,
-   int index )
+   const scan_register *reg)
 {
-   assert( index >= 0 && index < MAX_REGISTERS );
-
-   return (ctx->regs_decl[file][index / BITS_IN_REG_FLAG] & (1 << (index % BITS_IN_REG_FLAG))) ? TRUE : FALSE;
+   void *data = cso_hash_find_data_from_template(
+      ctx->regs_decl, scan_register_key(reg),
+      (void*)reg, sizeof(scan_register));
+   return  data ? TRUE : FALSE;
 }
 
 static boolean
@@ -112,23 +192,37 @@ is_any_register_declared(
    struct sanity_check_ctx *ctx,
    uint file )
 {
-   uint i;
+   struct cso_hash_iter iter =
+      cso_hash_first_node(ctx->regs_decl);
 
-   for (i = 0; i < MAX_REG_FLAGS; i++)
-      if (ctx->regs_decl[file][i])
+   while (!cso_hash_iter_is_null(iter)) {
+      scan_register *reg = (scan_register *)cso_hash_iter_data(iter);
+      if (reg->file == file)
          return TRUE;
+      iter = cso_hash_iter_next(iter);
+   }
+
    return FALSE;
 }
 
 static boolean
 is_register_used(
    struct sanity_check_ctx *ctx,
-   uint file,
-   int index )
+   scan_register *reg)
 {
-   assert( index < MAX_REGISTERS );
+   void *data = cso_hash_find_data_from_template(
+      ctx->regs_used, scan_register_key(reg),
+      reg, sizeof(scan_register));
+   return  data ? TRUE : FALSE;
+}
 
-   return (ctx->regs_used[file][index / BITS_IN_REG_FLAG] & (1 << (index % BITS_IN_REG_FLAG))) ? TRUE : FALSE;
+
+static boolean
+is_ind_register_used(
+   struct sanity_check_ctx *ctx,
+   scan_register *reg)
+{
+   return cso_hash_contains(ctx->regs_ind_used, reg->file);
 }
 
 static const char *file_names[TGSI_FILE_COUNT] =
@@ -141,37 +235,49 @@ static const char *file_names[TGSI_FILE_COUNT] =
    "SAMP",
    "ADDR",
    "IMM",
-   "LOOP"
+   "LOOP",
+   "PRED"
 };
 
 static boolean
 check_register_usage(
    struct sanity_check_ctx *ctx,
-   uint file,
-   int index,
+   scan_register *reg,
    const char *name,
    boolean indirect_access )
 {
-   if (!check_file_name( ctx, file ))
+   if (!check_file_name( ctx, reg->file )) {
+      FREE(reg);
       return FALSE;
+   }
 
    if (indirect_access) {
       /* Note that 'index' is an offset relative to the value of the
-       * address register.  No range checking done here.
-       */
-      if (!is_any_register_declared( ctx, file ))
-         report_error( ctx, "%s: Undeclared %s register", file_names[file], name );
-      ctx->regs_ind_used[file] = TRUE;
+       * address register.  No range checking done here.*/
+      reg->indices[0] = 0;
+      reg->indices[1] = 0;
+      if (!is_any_register_declared( ctx, reg->file ))
+         report_error( ctx, "%s: Undeclared %s register", file_names[reg->file], name );
+      if (!is_ind_register_used(ctx, reg))
+         cso_hash_insert(ctx->regs_ind_used, reg->file, reg);
+      else
+         FREE(reg);
    }
    else {
-      if (index < 0 || index >= MAX_REGISTERS) {
-         report_error( ctx, "%s[%d]: Invalid %s index", file_names[file], index, name );
-         return FALSE;
+      if (!is_register_declared( ctx, reg )) {
+         if (reg->dimensions == 2) {
+            report_error( ctx, "%s[%d][%d]: Undeclared %s register", file_names[reg->file],
+                          reg->indices[0], reg->indices[1], name );
+         }
+         else {
+            report_error( ctx, "%s[%d]: Undeclared %s register", file_names[reg->file],
+                          reg->indices[0], name );
+         }
       }
-
-      if (!is_register_declared( ctx, file, index ))
-         report_error( ctx, "%s[%d]: Undeclared %s register", file_names[file], index, name );
-      ctx->regs_used[file][index / BITS_IN_REG_FLAG] |= (1 << (index % BITS_IN_REG_FLAG));
+      if (!is_register_used( ctx, reg ))
+         cso_hash_insert(ctx->regs_used, scan_register_key(reg), reg);
+      else
+         FREE(reg);
    }
    return TRUE;
 }
@@ -209,43 +315,43 @@ iter_instruction(
     * Mark the registers as used.
     */
    for (i = 0; i < inst->Instruction.NumDstRegs; i++) {
+      scan_register *reg = create_scan_register_dst(&inst->Dst[i]);
       check_register_usage(
          ctx,
-         inst->FullDstRegisters[i].DstRegister.File,
-         inst->FullDstRegisters[i].DstRegister.Index,
+         reg,
          "destination",
          FALSE );
    }
    for (i = 0; i < inst->Instruction.NumSrcRegs; i++) {
+      scan_register *reg = create_scan_register_src(&inst->Src[i]);
       check_register_usage(
          ctx,
-         inst->FullSrcRegisters[i].SrcRegister.File,
-         inst->FullSrcRegisters[i].SrcRegister.Index,
+         reg,
          "source",
-         (boolean)inst->FullSrcRegisters[i].SrcRegister.Indirect );
-      if (inst->FullSrcRegisters[i].SrcRegister.Indirect) {
-         uint file;
-         int index;
-
-         file = inst->FullSrcRegisters[i].SrcRegisterInd.File;
-         index = inst->FullSrcRegisters[i].SrcRegisterInd.Index;
+         (boolean)inst->Src[i].Register.Indirect );
+      if (inst->Src[i].Register.Indirect) {
+         scan_register *ind_reg = MALLOC(sizeof(scan_register));
+
+         fill_scan_register1d(ind_reg,
+                              inst->Src[i].Indirect.File,
+                              inst->Src[i].Indirect.Index);
+         if (!(reg->file == TGSI_FILE_ADDRESS || reg->file == TGSI_FILE_LOOP) ||
+             reg->indices[0] != 0) {
+            report_warning(ctx, "Indirect register neither ADDR[0] nor LOOP[0]");
+         }
          check_register_usage(
             ctx,
-            file,
-            index,
+            reg,
             "indirect",
             FALSE );
-         if (!(file == TGSI_FILE_ADDRESS || file == TGSI_FILE_LOOP) || index != 0) {
-            report_warning(ctx, "Indirect register neither ADDR[0] nor LOOP[0]");
-         }
       }
    }
 
    switch (inst->Instruction.Opcode) {
    case TGSI_OPCODE_BGNFOR:
    case TGSI_OPCODE_ENDFOR:
-      if (inst->FullDstRegisters[0].DstRegister.File != TGSI_FILE_LOOP ||
-          inst->FullDstRegisters[0].DstRegister.Index != 0) {
+      if (inst->Dst[0].Register.File != TGSI_FILE_LOOP ||
+          inst->Dst[0].Register.Index != 0) {
          report_error(ctx, "Destination register must be LOOP[0]");
       }
       break;
@@ -253,8 +359,8 @@ iter_instruction(
 
    switch (inst->Instruction.Opcode) {
    case TGSI_OPCODE_BGNFOR:
-      if (inst->FullSrcRegisters[0].SrcRegister.File != TGSI_FILE_CONSTANT &&
-          inst->FullSrcRegisters[0].SrcRegister.File != TGSI_FILE_IMMEDIATE) {
+      if (inst->Src[0].Register.File != TGSI_FILE_CONSTANT &&
+          inst->Src[0].Register.File != TGSI_FILE_IMMEDIATE) {
          report_error(ctx, "Source register file must be either CONST or IMM");
       }
       break;
@@ -265,6 +371,19 @@ iter_instruction(
    return TRUE;
 }
 
+static void
+check_and_declare(struct sanity_check_ctx *ctx,
+                  scan_register *reg)
+{
+   if (is_register_declared( ctx, reg))
+      report_error( ctx, "%s[%u]: The same register declared more than once",
+                    file_names[reg->file], reg->indices[0] );
+   cso_hash_insert(ctx->regs_decl,
+                   scan_register_key(reg),
+                   reg);
+}
+
+
 static boolean
 iter_declaration(
    struct tgsi_iterate_context *iter,
@@ -285,10 +404,22 @@ iter_declaration(
    file = decl->Declaration.File;
    if (!check_file_name( ctx, file ))
       return TRUE;
-   for (i = decl->DeclarationRange.First; i <= decl->DeclarationRange.Last; i++) {
-      if (is_register_declared( ctx, file, i ))
-         report_error( ctx, "%s[%u]: The same register declared more than once", file_names[file], i );
-      ctx->regs_decl[file][i / BITS_IN_REG_FLAG] |= (1 << (i % BITS_IN_REG_FLAG));
+   for (i = decl->Range.First; i <= decl->Range.Last; i++) {
+      /* declared TGSI_FILE_INPUT's for geometry processor
+       * have an implied second dimension */
+      if (file == TGSI_FILE_INPUT &&
+          ctx->iter.processor.Processor == TGSI_PROCESSOR_GEOMETRY) {
+         uint vert;
+         for (vert = 0; vert < ctx->implied_array_size; ++vert) {
+            scan_register *reg = MALLOC(sizeof(scan_register));
+            fill_scan_register2d(reg, file, vert, i);
+            check_and_declare(ctx, reg);
+         }
+      } else {
+         scan_register *reg = MALLOC(sizeof(scan_register));
+         fill_scan_register1d(reg, file, i);
+         check_and_declare(ctx, reg);
+      }
    }
 
    return TRUE;
@@ -300,8 +431,7 @@ iter_immediate(
    struct tgsi_full_immediate *imm )
 {
    struct sanity_check_ctx *ctx = (struct sanity_check_ctx *) iter;
-
-   assert( ctx->num_imms < MAX_REGISTERS );
+   scan_register *reg;
 
    /* No immediates allowed after the first instruction.
     */
@@ -310,12 +440,16 @@ iter_immediate(
 
    /* Mark the register as declared.
     */
-   ctx->regs_decl[TGSI_FILE_IMMEDIATE][ctx->num_imms / BITS_IN_REG_FLAG] |= (1 << (ctx->num_imms % BITS_IN_REG_FLAG));
+   reg = MALLOC(sizeof(scan_register));
+   fill_scan_register1d(reg, TGSI_FILE_IMMEDIATE, ctx->num_imms);
+   cso_hash_insert(ctx->regs_decl, scan_register_key(reg), reg);
    ctx->num_imms++;
 
    /* Check data type validity.
     */
-   if (imm->Immediate.DataType != TGSI_IMM_FLOAT32) {
+   if (imm->Immediate.DataType != TGSI_IMM_FLOAT32 &&
+       imm->Immediate.DataType != TGSI_IMM_UINT32 &&
+       imm->Immediate.DataType != TGSI_IMM_INT32) {
       report_error( ctx, "(%u): Invalid immediate data type", imm->Immediate.DataType );
       return TRUE;
    }
@@ -323,12 +457,26 @@ iter_immediate(
    return TRUE;
 }
 
+
+static boolean
+iter_property(
+   struct tgsi_iterate_context *iter,
+   struct tgsi_full_property *prop )
+{
+   struct sanity_check_ctx *ctx = (struct sanity_check_ctx *) iter;
+
+   if (iter->processor.Processor == TGSI_PROCESSOR_GEOMETRY &&
+       prop->Property.PropertyName == TGSI_PROPERTY_GS_INPUT_PRIM) {
+      ctx->implied_array_size = u_vertices_per_prim(prop->u[0].Data);
+   }
+   return TRUE;
+}
+
 static boolean
 epilog(
    struct tgsi_iterate_context *iter )
 {
    struct sanity_check_ctx *ctx = (struct sanity_check_ctx *) iter;
-   uint file;
 
    /* There must be an END instruction somewhere.
     */
@@ -338,13 +486,17 @@ epilog(
 
    /* Check if all declared registers were used.
     */
-   for (file = TGSI_FILE_NULL; file < TGSI_FILE_COUNT; file++) {
-      uint i;
-
-      for (i = 0; i < MAX_REGISTERS; i++) {
-         if (is_register_declared( ctx, file, i ) && !is_register_used( ctx, file, i ) && !ctx->regs_ind_used[file]) {
-            report_warning( ctx, "%s[%u]: Register never used", file_names[file], i );
+   {
+      struct cso_hash_iter iter =
+         cso_hash_first_node(ctx->regs_decl);
+
+      while (!cso_hash_iter_is_null(iter)) {
+         scan_register *reg = (scan_register *)cso_hash_iter_data(iter);
+         if (!is_register_used(ctx, reg) && !is_ind_register_used(ctx, reg)) {
+            report_warning( ctx, "%s[%u]: Register never used",
+                            file_names[reg->file], reg->indices[0] );
          }
+         iter = cso_hash_iter_next(iter);
       }
    }
 
@@ -356,6 +508,19 @@ epilog(
    return TRUE;
 }
 
+static void
+regs_hash_destroy(struct cso_hash *hash)
+{
+   struct cso_hash_iter iter = cso_hash_first_node(hash);
+   while (!cso_hash_iter_is_null(iter)) {
+      scan_register *reg = (scan_register *)cso_hash_iter_data(iter);
+      iter = cso_hash_erase(hash, iter);
+      assert(reg->file < TGSI_FILE_COUNT);
+      FREE(reg);
+   }
+   cso_hash_delete(hash);
+}
+
 boolean
 tgsi_sanity_check(
    const struct tgsi_token *tokens )
@@ -366,20 +531,26 @@ tgsi_sanity_check(
    ctx.iter.iterate_instruction = iter_instruction;
    ctx.iter.iterate_declaration = iter_declaration;
    ctx.iter.iterate_immediate = iter_immediate;
+   ctx.iter.iterate_property = iter_property;
    ctx.iter.epilog = epilog;
 
-   memset( ctx.regs_decl, 0, sizeof( ctx.regs_decl ) );
-   memset( ctx.regs_used, 0, sizeof( ctx.regs_used ) );
-   memset( ctx.regs_ind_used, 0, sizeof( ctx.regs_ind_used ) );
+   ctx.regs_decl = cso_hash_create();
+   ctx.regs_used = cso_hash_create();
+   ctx.regs_ind_used = cso_hash_create();
+
    ctx.num_imms = 0;
    ctx.num_instructions = 0;
    ctx.index_of_END = ~0;
 
    ctx.errors = 0;
    ctx.warnings = 0;
+   ctx.implied_array_size = 0;
 
    if (!tgsi_iterate_shader( tokens, &ctx.iter ))
       return FALSE;
 
+   regs_hash_destroy(ctx.regs_decl);
+   regs_hash_destroy(ctx.regs_used);
+   regs_hash_destroy(ctx.regs_ind_used);
    return ctx.errors == 0;
 }
index 0db4481a3d024313fabdd7cc5e1f79ff4e8decc4..a6cc773003ace80c6b7d904f89ef7cb3381c5e76 100644 (file)
@@ -35,7 +35,6 @@
 
 
 #include "util/u_math.h"
-#include "tgsi/tgsi_build.h"
 #include "tgsi/tgsi_parse.h"
 #include "tgsi/tgsi_scan.h"
 
@@ -97,14 +96,15 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
                uint i;
                for (i = 0; i < fullinst->Instruction.NumSrcRegs; i++) {
                   const struct tgsi_full_src_register *src =
-                     &fullinst->FullSrcRegisters[i];
-                  if (src->SrcRegister.File == TGSI_FILE_INPUT) {
-                     const int ind = src->SrcRegister.Index;
+                     &fullinst->Src[i];
+                  if (src->Register.File == TGSI_FILE_INPUT ||
+                      src->Register.File == TGSI_FILE_SYSTEM_VALUE) {
+                     const int ind = src->Register.Index;
                      if (info->input_semantic_name[ind] == TGSI_SEMANTIC_FOG) {
-                        if (src->SrcRegister.SwizzleX == TGSI_SWIZZLE_X) {
+                        if (src->Register.SwizzleX == TGSI_SWIZZLE_X) {
                            info->uses_fogcoord = TRUE;
                         }
-                        else if (src->SrcRegister.SwizzleX == TGSI_SWIZZLE_Y) {
+                        else if (src->Register.SwizzleX == TGSI_SWIZZLE_Y) {
                            info->uses_frontfacing = TRUE;
                         }
                      }
@@ -120,8 +120,8 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
                = &parse.FullToken.FullDeclaration;
             const uint file = fulldecl->Declaration.File;
             uint reg;
-            for (reg = fulldecl->DeclarationRange.First;
-                 reg <= fulldecl->DeclarationRange.Last;
+            for (reg = fulldecl->Range.First;
+                 reg <= fulldecl->Range.Last;
                  reg++) {
 
                /* only first 32 regs will appear in this bitfield */
@@ -129,25 +129,29 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
                info->file_count[file]++;
                info->file_max[file] = MAX2(info->file_max[file], (int)reg);
 
-               if (file == TGSI_FILE_INPUT) {
-                  info->input_semantic_name[reg] = (ubyte)fulldecl->Semantic.SemanticName;
-                  info->input_semantic_index[reg] = (ubyte)fulldecl->Semantic.SemanticIndex;
+               if (file == TGSI_FILE_INPUT || file == TGSI_FILE_SYSTEM_VALUE) {
+                  info->input_semantic_name[reg] = (ubyte)fulldecl->Semantic.Name;
+                  info->input_semantic_index[reg] = (ubyte)fulldecl->Semantic.Index;
                   info->input_interpolate[reg] = (ubyte)fulldecl->Declaration.Interpolate;
                   info->num_inputs++;
                }
                else if (file == TGSI_FILE_OUTPUT) {
-                  info->output_semantic_name[reg] = (ubyte)fulldecl->Semantic.SemanticName;
-                  info->output_semantic_index[reg] = (ubyte)fulldecl->Semantic.SemanticIndex;
+                  info->output_semantic_name[reg] = (ubyte)fulldecl->Semantic.Name;
+                  info->output_semantic_index[reg] = (ubyte)fulldecl->Semantic.Index;
                   info->num_outputs++;
-               }
 
-               /* special case */
-               if (procType == TGSI_PROCESSOR_FRAGMENT &&
-                   file == TGSI_FILE_OUTPUT &&
-                   fulldecl->Semantic.SemanticName == TGSI_SEMANTIC_POSITION) {
-                  info->writes_z = TRUE;
+                  /* extra info for special outputs */
+                  if (procType == TGSI_PROCESSOR_FRAGMENT &&
+                      fulldecl->Semantic.Name == TGSI_SEMANTIC_POSITION) {
+                     info->writes_z = TRUE;
+                  }
+                  if (procType == TGSI_PROCESSOR_VERTEX &&
+                      fulldecl->Semantic.Name == TGSI_SEMANTIC_EDGEFLAG) {
+                     info->writes_edgeflag = TRUE;
+                  }
                }
-            }
+
+             }
          }
          break;
 
@@ -161,6 +165,19 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
             info->file_max[file] = MAX2(info->file_max[file], (int)reg);
          }
          break;
+      case TGSI_TOKEN_TYPE_PROPERTY:
+      {
+         const struct tgsi_full_property *fullprop
+            = &parse.FullToken.FullProperty;
+
+         info->properties[info->num_properties].name =
+            fullprop->Property.PropertyName;
+         memcpy(info->properties[info->num_properties].data,
+                fullprop->u, 8 * sizeof(unsigned));;
+
+         ++info->num_properties;
+      }
+      break;
 
       default:
          assert( 0 );
@@ -206,34 +223,26 @@ tgsi_is_passthrough_shader(const struct tgsi_token *tokens)
             struct tgsi_full_instruction *fullinst =
                &parse.FullToken.FullInstruction;
             const struct tgsi_full_src_register *src =
-               &fullinst->FullSrcRegisters[0];
+               &fullinst->Src[0];
             const struct tgsi_full_dst_register *dst =
-               &fullinst->FullDstRegisters[0];
+               &fullinst->Dst[0];
 
             /* Do a whole bunch of checks for a simple move */
             if (fullinst->Instruction.Opcode != TGSI_OPCODE_MOV ||
-                src->SrcRegister.File != TGSI_FILE_INPUT ||
-                dst->DstRegister.File != TGSI_FILE_OUTPUT ||
-                src->SrcRegister.Index != dst->DstRegister.Index ||
-
-                src->SrcRegister.Negate ||
-                src->SrcRegisterExtMod.Negate ||
-                src->SrcRegisterExtMod.Absolute ||
-                src->SrcRegisterExtMod.Scale2X ||
-                src->SrcRegisterExtMod.Bias ||
-                src->SrcRegisterExtMod.Complement ||
-
-                src->SrcRegister.SwizzleX != TGSI_SWIZZLE_X ||
-                src->SrcRegister.SwizzleY != TGSI_SWIZZLE_Y ||
-                src->SrcRegister.SwizzleZ != TGSI_SWIZZLE_Z ||
-                src->SrcRegister.SwizzleW != TGSI_SWIZZLE_W ||
-
-                src->SrcRegisterExtSwz.ExtSwizzleX != TGSI_EXTSWIZZLE_X ||
-                src->SrcRegisterExtSwz.ExtSwizzleY != TGSI_EXTSWIZZLE_Y ||
-                src->SrcRegisterExtSwz.ExtSwizzleZ != TGSI_EXTSWIZZLE_Z ||
-                src->SrcRegisterExtSwz.ExtSwizzleW != TGSI_EXTSWIZZLE_W ||
-
-                dst->DstRegister.WriteMask != TGSI_WRITEMASK_XYZW)
+                (src->Register.File != TGSI_FILE_INPUT &&
+                 src->Register.File != TGSI_FILE_SYSTEM_VALUE) ||
+                dst->Register.File != TGSI_FILE_OUTPUT ||
+                src->Register.Index != dst->Register.Index ||
+
+                src->Register.Negate ||
+                src->Register.Absolute ||
+
+                src->Register.SwizzleX != TGSI_SWIZZLE_X ||
+                src->Register.SwizzleY != TGSI_SWIZZLE_Y ||
+                src->Register.SwizzleZ != TGSI_SWIZZLE_Z ||
+                src->Register.SwizzleW != TGSI_SWIZZLE_W ||
+
+                dst->Register.WriteMask != TGSI_WRITEMASK_XYZW)
             {
                tgsi_parse_free(&parse);
                return FALSE;
@@ -245,6 +254,8 @@ tgsi_is_passthrough_shader(const struct tgsi_token *tokens)
          /* fall-through */
       case TGSI_TOKEN_TYPE_IMMEDIATE:
          /* fall-through */
+      case TGSI_TOKEN_TYPE_PROPERTY:
+         /* fall-through */
       default:
          ; /* no-op */
       }
index 8a7ee0c7e4f1f1e2e69f159586f45d0a8cd28018..dae5376c24aae63dbebcab6f9d6d2e36adc75ca7 100644 (file)
@@ -33,7 +33,6 @@
 #include "pipe/p_state.h"
 #include "pipe/p_shader_tokens.h"
 
-
 /**
  * Shader summary info
  */
@@ -58,11 +57,17 @@ struct tgsi_shader_info
    uint opcode_count[TGSI_OPCODE_LAST];  /**< opcode histogram */
 
    boolean writes_z;  /**< does fragment shader write Z value? */
+   boolean writes_edgeflag; /**< vertex shader outputs edgeflag */
    boolean uses_kill;  /**< KIL or KILP instruction used? */
    boolean uses_fogcoord; /**< fragment shader uses fog coord? */
    boolean uses_frontfacing; /**< fragment shader uses front/back-face flag? */
-};
 
+   struct {
+      unsigned name;
+      unsigned data[8];
+   } properties[TGSI_PROPERTY_COUNT];
+   uint num_properties;
+};
 
 extern void
 tgsi_scan_shader(const struct tgsi_token *tokens,
index 5f6b83b2362acbf503300c8fb2558361bd05e147..2e13a7aaf9d15667edca5ed095cd466b0f7c0cf0 100644 (file)
@@ -2,6 +2,7 @@
  * 
  * Copyright 2007-2008 Tungsten Graphics, Inc., Cedar Park, Texas.
  * All Rights Reserved.
+ * Copyright 2009-2010 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
@@ -58,7 +59,7 @@
    for (CHAN = 0; CHAN < NUM_CHANNELS; CHAN++)
 
 #define IS_DST0_CHANNEL_ENABLED( INST, CHAN )\
-   ((INST).FullDstRegisters[0].DstRegister.WriteMask & (1 << (CHAN)))
+   ((INST).Dst[0].Register.WriteMask & (1 << (CHAN)))
 
 #define IF_IS_DST0_CHANNEL_ENABLED( INST, CHAN )\
    if (IS_DST0_CHANNEL_ENABLED( INST, CHAN ))
@@ -1260,38 +1261,39 @@ emit_fetch(
    const struct tgsi_full_src_register *reg,
    const unsigned chan_index )
 {
-   unsigned swizzle = tgsi_util_get_full_src_register_extswizzle( reg, chan_index );
+   unsigned swizzle = tgsi_util_get_full_src_register_swizzle( reg, chan_index );
 
    switch (swizzle) {
-   case TGSI_EXTSWIZZLE_X:
-   case TGSI_EXTSWIZZLE_Y:
-   case TGSI_EXTSWIZZLE_Z:
-   case TGSI_EXTSWIZZLE_W:
-      switch (reg->SrcRegister.File) {
+   case TGSI_SWIZZLE_X:
+   case TGSI_SWIZZLE_Y:
+   case TGSI_SWIZZLE_Z:
+   case TGSI_SWIZZLE_W:
+      switch (reg->Register.File) {
       case TGSI_FILE_CONSTANT:
          emit_const(
             func,
             xmm,
-            reg->SrcRegister.Index,
+            reg->Register.Index,
             swizzle,
-            reg->SrcRegister.Indirect,
-            reg->SrcRegisterInd.File,
-            reg->SrcRegisterInd.Index );
+            reg->Register.Indirect,
+            reg->Indirect.File,
+            reg->Indirect.Index );
          break;
 
       case TGSI_FILE_IMMEDIATE:
          emit_immediate(
             func,
             xmm,
-            reg->SrcRegister.Index,
+            reg->Register.Index,
             swizzle );
          break;
 
       case TGSI_FILE_INPUT:
+      case TGSI_FILE_SYSTEM_VALUE:
          emit_inputf(
             func,
             xmm,
-            reg->SrcRegister.Index,
+            reg->Register.Index,
             swizzle );
          break;
 
@@ -1299,7 +1301,7 @@ emit_fetch(
          emit_tempf(
             func,
             xmm,
-            reg->SrcRegister.Index,
+            reg->Register.Index,
             swizzle );
          break;
 
@@ -1308,22 +1310,6 @@ emit_fetch(
       }
       break;
 
-   case TGSI_EXTSWIZZLE_ZERO:
-      emit_tempf(
-         func,
-         xmm,
-         TGSI_EXEC_TEMP_00000000_I,
-         TGSI_EXEC_TEMP_00000000_C );
-      break;
-
-   case TGSI_EXTSWIZZLE_ONE:
-      emit_tempf(
-         func,
-         xmm,
-         TEMP_ONE_I,
-         TEMP_ONE_C );
-      break;
-
    default:
       assert( 0 );
    }
@@ -1347,7 +1333,7 @@ emit_fetch(
 }
 
 #define FETCH( FUNC, INST, XMM, INDEX, CHAN )\
-   emit_fetch( FUNC, XMM, &(INST).FullSrcRegisters[INDEX], CHAN )
+   emit_fetch( FUNC, XMM, &(INST).Src[INDEX], CHAN )
 
 /**
  * Register store.
@@ -1387,12 +1373,12 @@ emit_store(
    }
 
 
-   switch( reg->DstRegister.File ) {
+   switch( reg->Register.File ) {
    case TGSI_FILE_OUTPUT:
       emit_output(
          func,
          xmm,
-         reg->DstRegister.Index,
+         reg->Register.Index,
          chan_index );
       break;
 
@@ -1400,7 +1386,7 @@ emit_store(
       emit_temps(
          func,
          xmm,
-         reg->DstRegister.Index,
+         reg->Register.Index,
          chan_index );
       break;
 
@@ -1408,7 +1394,7 @@ emit_store(
       emit_addrs(
          func,
          xmm,
-         reg->DstRegister.Index,
+         reg->Register.Index,
          chan_index );
       break;
 
@@ -1418,7 +1404,7 @@ emit_store(
 }
 
 #define STORE( FUNC, INST, XMM, INDEX, CHAN )\
-   emit_store( FUNC, XMM, &(INST).FullDstRegisters[INDEX], &(INST), CHAN )
+   emit_store( FUNC, XMM, &(INST).Dst[INDEX], &(INST), CHAN )
 
 
 static void PIPE_CDECL
@@ -1433,13 +1419,13 @@ fetch_texel( struct tgsi_sampler **sampler,
                 sampler, *sampler,
                 store );
 
-   debug_printf("lodbias %f\n", store[12]);
-
    for (j = 0; j < 4; j++)
-      debug_printf("sample %d texcoord %f %f\n", 
+      debug_printf("sample %d texcoord %f %f %f lodbias %f\n",
                    j, 
                    store[0+j],
-                   store[4+j]);
+                   store[4+j],
+                   store[8 + j],
+                   store[12 + j]);
 #endif
 
    {
@@ -1448,7 +1434,8 @@ fetch_texel( struct tgsi_sampler **sampler,
                               &store[0],  /* s */
                               &store[4],  /* t */
                               &store[8],  /* r */
-                              store[12],  /* lodbias */
+                              &store[12], /* lodbias */
+                              tgsi_sampler_lod_bias,
                               rgba);      /* results */
 
       memcpy( store, rgba, 16 * sizeof(float));
@@ -1475,12 +1462,13 @@ emit_tex( struct x86_function *func,
           boolean lodbias,
           boolean projected)
 {
-   const uint unit = inst->FullSrcRegisters[1].SrcRegister.Index;
+   const uint unit = inst->Src[1].Register.Index;
    struct x86_reg args[2];
    unsigned count;
    unsigned i;
 
-   switch (inst->InstructionExtTexture.Texture) {
+   assert(inst->Instruction.Texture);
+   switch (inst->Texture.Texture) {
    case TGSI_TEXTURE_1D:
       count = 1;
       break;
@@ -1582,13 +1570,13 @@ emit_kil(
    /* This mask stores component bits that were already tested. Note that
     * we test if the value is less than zero, so 1.0 and 0.0 need not to be
     * tested. */
-   uniquemask = (1 << TGSI_EXTSWIZZLE_ZERO) | (1 << TGSI_EXTSWIZZLE_ONE);
+   uniquemask = 0;
 
    FOR_EACH_CHANNEL( chan_index ) {
       unsigned swizzle;
 
       /* unswizzle channel */
-      swizzle = tgsi_util_get_full_src_register_extswizzle(
+      swizzle = tgsi_util_get_full_src_register_swizzle(
          reg,
          chan_index );
 
@@ -1735,15 +1723,15 @@ indirect_temp_reference(const struct tgsi_full_instruction *inst)
 {
    uint i;
    for (i = 0; i < inst->Instruction.NumSrcRegs; i++) {
-      const struct tgsi_full_src_register *reg = &inst->FullSrcRegisters[i];
-      if (reg->SrcRegister.File == TGSI_FILE_TEMPORARY &&
-          reg->SrcRegister.Indirect)
+      const struct tgsi_full_src_register *reg = &inst->Src[i];
+      if (reg->Register.File == TGSI_FILE_TEMPORARY &&
+          reg->Register.Indirect)
          return TRUE;
    }
    for (i = 0; i < inst->Instruction.NumDstRegs; i++) {
-      const struct tgsi_full_dst_register *reg = &inst->FullDstRegisters[i];
-      if (reg->DstRegister.File == TGSI_FILE_TEMPORARY &&
-          reg->DstRegister.Indirect)
+      const struct tgsi_full_dst_register *reg = &inst->Dst[i];
+      if (reg->Register.File == TGSI_FILE_TEMPORARY &&
+          reg->Register.Indirect)
          return TRUE;
    }
    return FALSE;
@@ -1772,7 +1760,6 @@ emit_instruction(
       break;
 
    case TGSI_OPCODE_MOV:
-   case TGSI_OPCODE_SWZ:
       FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
          FETCH( func, *inst, 4 + chan_index, 0, chan_index );
       }
@@ -2260,7 +2247,7 @@ emit_instruction(
 
    case TGSI_OPCODE_KIL:
       /* conditional kill */
-      emit_kil( func, &inst->FullSrcRegisters[0] );
+      emit_kil( func, &inst->Src[0] );
       break;
 
    case TGSI_OPCODE_PK2H:
@@ -2521,7 +2508,7 @@ emit_instruction(
       break;
 
    case TGSI_OPCODE_TXL:
-      emit_tex( func, inst, TRUE, FALSE );
+      return 0;
       break;
 
    case TGSI_OPCODE_TXP:
@@ -2593,7 +2580,7 @@ emit_instruction(
       return 0;
       break;
 
-   case TGSI_OPCODE_SHR:
+   case TGSI_OPCODE_ISHR:
       return 0;
       break;
 
@@ -2649,12 +2636,13 @@ emit_declaration(
    struct x86_function *func,
    struct tgsi_full_declaration *decl )
 {
-   if( decl->Declaration.File == TGSI_FILE_INPUT ) {
+   if( decl->Declaration.File == TGSI_FILE_INPUT ||
+       decl->Declaration.File == TGSI_FILE_SYSTEM_VALUE ) {
       unsigned first, last, mask;
       unsigned i, j;
 
-      first = decl->DeclarationRange.First;
-      last = decl->DeclarationRange.Last;
+      first = decl->Range.First;
+      last = decl->Range.Last;
       mask = decl->Declaration.UsageMask;
 
       for( i = first; i <= last; i++ ) {
@@ -2938,8 +2926,7 @@ tgsi_emit_sse2(
              * the result in the cases where the code is too opaque to
              * fix.
              */
-            if (opcode != TGSI_OPCODE_MOV &&
-                opcode != TGSI_OPCODE_SWZ) {
+            if (opcode != TGSI_OPCODE_MOV) {
                debug_printf("Warning: src/dst aliasing in instruction"
                             " is not handled:\n");
                tgsi_dump_instruction(&parse.FullToken.FullInstruction, 1);
@@ -2969,6 +2956,9 @@ tgsi_emit_sse2(
             num_immediates++;
          }
          break;
+      case TGSI_TOKEN_TYPE_PROPERTY:
+         /* we just ignore them for now */
+         break;
 
       default:
         ok = 0;
index d438450b1e4cf0f63f8630e1aa3471ffd1576a41..9fcffeda36871b3ca1fc68550b5c3a435a51de24 100644 (file)
@@ -27,6 +27,9 @@
 
 #include "util/u_debug.h"
 #include "util/u_memory.h"
+#include "util/u_prim.h"
+#include "pipe/p_defines.h"
+#include "pipe/p_inlines.h"
 #include "tgsi_text.h"
 #include "tgsi_build.h"
 #include "tgsi_info.h"
@@ -59,6 +62,23 @@ static boolean uprcase( char c )
    return c;
 }
 
+/*
+ * Ignore case of str1 and assume str1 is already uppercase.
+ * Return TRUE iff str1 and str2 are equal.
+ */
+static int
+streq_nocase_uprcase(const char *str1,
+                     const char *str2)
+{
+   while (*str1 && *str2) {
+      if (*str1 != uprcase(*str2))
+         return FALSE;
+      str1++;
+      str2++;
+   }
+   return TRUE;
+}
+
 static boolean str_match_no_case( const char **pcur, const char *str )
 {
    const char *cur = *pcur;
@@ -110,6 +130,20 @@ static boolean parse_uint( const char **pcur, uint *val )
    return FALSE;
 }
 
+static boolean parse_identifier( const char **pcur, char *ret )
+{
+   const char *cur = *pcur;
+   int i = 0;
+   if (is_alpha_underscore( cur )) {
+      ret[i++] = *cur++;
+      while (is_alpha_underscore( cur ))
+         ret[i++] = *cur++;
+      *pcur = cur;
+      return TRUE;
+   }
+   return FALSE;
+}
+
 /* Parse floating point.
  */
 static boolean parse_float( const char **pcur, float *val )
@@ -163,38 +197,49 @@ struct translate_ctx
    struct tgsi_token *tokens_cur;
    struct tgsi_token *tokens_end;
    struct tgsi_header *header;
+   unsigned processor : 4;
+   int implied_array_size : 5;
 };
 
 static void report_error( struct translate_ctx *ctx, const char *msg )
 {
-   debug_printf( "\nError: %s", msg );
+   int line = 1;
+   int column = 1;
+   const char *itr = ctx->text;
+
+   while (itr != ctx->cur) {
+      if (*itr == '\n') {
+         column = 1;
+         ++line;
+      }
+      ++column;
+      ++itr;
+   }
+
+   debug_printf( "\nTGSI asm error: %s [%d : %d] \n", msg, line, column );
 }
 
 /* Parse shader header.
  * Return TRUE for one of the following headers.
- *    FRAG1.1
- *    GEOM1.1
- *    VERT1.1
+ *    FRAG
+ *    GEOM
+ *    VERT
  */
 static boolean parse_header( struct translate_ctx *ctx )
 {
    uint processor;
 
-   if (str_match_no_case( &ctx->cur, "FRAG1.1" ))
+   if (str_match_no_case( &ctx->cur, "FRAG" ))
       processor = TGSI_PROCESSOR_FRAGMENT;
-   else if (str_match_no_case( &ctx->cur, "VERT1.1" ))
+   else if (str_match_no_case( &ctx->cur, "VERT" ))
       processor = TGSI_PROCESSOR_VERTEX;
-   else if (str_match_no_case( &ctx->cur, "GEOM1.1" ))
+   else if (str_match_no_case( &ctx->cur, "GEOM" ))
       processor = TGSI_PROCESSOR_GEOMETRY;
    else {
       report_error( ctx, "Unknown header" );
       return FALSE;
    }
 
-   if (ctx->tokens_cur >= ctx->tokens_end)
-      return FALSE;
-   *(struct tgsi_version *) ctx->tokens_cur++ = tgsi_build_version();
-
    if (ctx->tokens_cur >= ctx->tokens_end)
       return FALSE;
    ctx->header = (struct tgsi_header *) ctx->tokens_cur++;
@@ -203,6 +248,7 @@ static boolean parse_header( struct translate_ctx *ctx )
    if (ctx->tokens_cur >= ctx->tokens_end)
       return FALSE;
    *(struct tgsi_processor *) ctx->tokens_cur++ = tgsi_build_processor( processor, ctx->header );
+   ctx->processor = processor;
 
    return TRUE;
 }
@@ -232,7 +278,9 @@ static const char *file_names[TGSI_FILE_COUNT] =
    "SAMP",
    "ADDR",
    "IMM",
-   "LOOP"
+   "LOOP",
+   "PRED",
+   "SV"
 };
 
 static boolean
@@ -297,92 +345,36 @@ parse_opt_writemask(
    return TRUE;
 }
 
-/* <register_file_bracket> ::= <file> `['
- */
 static boolean
-parse_register_file_bracket(
-   struct translate_ctx *ctx,
-   uint *file )
-{
-   if (!parse_file( &ctx->cur, file )) {
-      report_error( ctx, "Unknown register file" );
-      return FALSE;
-   }
-   eat_opt_white( &ctx->cur );
-   if (*ctx->cur != '[') {
-      report_error( ctx, "Expected `['" );
-      return FALSE;
-   }
-   ctx->cur++;
-   return TRUE;
-}
+parse_register_dst( struct translate_ctx *ctx,
+                    uint *file,
+                    int *index );
 
-/* <register_file_bracket_index> ::= <register_file_bracket> <uint>
- */
-static boolean
-parse_register_file_bracket_index(
-   struct translate_ctx *ctx,
-   uint *file,
-   int *index )
-{
-   uint uindex;
+struct parsed_src_bracket {
+   int index;
 
-   if (!parse_register_file_bracket( ctx, file ))
-      return FALSE;
-   eat_opt_white( &ctx->cur );
-   if (!parse_uint( &ctx->cur, &uindex )) {
-      report_error( ctx, "Expected literal unsigned integer" );
-      return FALSE;
-   }
-   *index = (int) uindex;
-   return TRUE;
-}
+   uint ind_file;
+   int ind_index;
+   uint ind_comp;
+};
 
-/* Parse destination register operand.
- *    <register_dst> ::= <register_file_bracket_index> `]'
- */
-static boolean
-parse_register_dst(
-   struct translate_ctx *ctx,
-   uint *file,
-   int *index )
-{
-   if (!parse_register_file_bracket_index( ctx, file, index ))
-      return FALSE;
-   eat_opt_white( &ctx->cur );
-   if (*ctx->cur != ']') {
-      report_error( ctx, "Expected `]'" );
-      return FALSE;
-   }
-   ctx->cur++;
-   return TRUE;
-}
 
-/* Parse source register operand.
- *    <register_src> ::= <register_file_bracket_index> `]' |
- *                       <register_file_bracket> <register_dst> [`.' (`x' | `y' | `z' | `w')] `]' |
- *                       <register_file_bracket> <register_dst> [`.' (`x' | `y' | `z' | `w')] `+' <uint> `]' |
- *                       <register_file_bracket> <register_dst> [`.' (`x' | `y' | `z' | `w')] `-' <uint> `]'
- */
 static boolean
-parse_register_src(
+parse_register_src_bracket(
    struct translate_ctx *ctx,
-   uint *file,
-   int *index,
-   uint *ind_file,
-   int *ind_index,
-   uint *ind_comp)
+   struct parsed_src_bracket *brackets)
 {
    const char *cur;
    uint uindex;
 
-   *ind_comp = TGSI_SWIZZLE_X;
-   if (!parse_register_file_bracket( ctx, file ))
-      return FALSE;
+   memset(brackets, 0, sizeof(struct parsed_src_bracket));
+
    eat_opt_white( &ctx->cur );
+
    cur = ctx->cur;
-   if (parse_file( &cur, ind_file )) {
-      if (!parse_register_dst( ctx, ind_file, ind_index ))
+   if (parse_file( &cur, &brackets->ind_file )) {
+      if (!parse_register_dst( ctx, &brackets->ind_file,
+                               &brackets->ind_index ))
          return FALSE;
       eat_opt_white( &ctx->cur );
 
@@ -392,16 +384,16 @@ parse_register_src(
 
          switch (uprcase(*ctx->cur)) {
          case 'X':
-            *ind_comp = TGSI_SWIZZLE_X;
+            brackets->ind_comp = TGSI_SWIZZLE_X;
             break;
          case 'Y':
-            *ind_comp = TGSI_SWIZZLE_Y;
+            brackets->ind_comp = TGSI_SWIZZLE_Y;
             break;
          case 'Z':
-            *ind_comp = TGSI_SWIZZLE_Z;
+            brackets->ind_comp = TGSI_SWIZZLE_Z;
             break;
          case 'W':
-            *ind_comp = TGSI_SWIZZLE_W;
+            brackets->ind_comp = TGSI_SWIZZLE_W;
             break;
          default:
             report_error(ctx, "Expected indirect register swizzle component `x', `y', `z' or `w'");
@@ -422,12 +414,12 @@ parse_register_src(
             return FALSE;
          }
          if (negate)
-            *index = -(int) uindex;
+            brackets->index = -(int) uindex;
          else
-            *index = (int) uindex;
+            brackets->index = (int) uindex;
       }
       else {
-         *index = 0;
+         brackets->index = 0;
       }
    }
    else {
@@ -435,9 +427,9 @@ parse_register_src(
          report_error( ctx, "Expected literal unsigned integer" );
          return FALSE;
       }
-      *index = (int) uindex;
-      *ind_file = TGSI_FILE_NULL;
-      *ind_index = 0;
+      brackets->index = (int) uindex;
+      brackets->ind_file = TGSI_FILE_NULL;
+      brackets->ind_index = 0;
    }
    eat_opt_white( &ctx->cur );
    if (*ctx->cur != ']') {
@@ -448,20 +440,123 @@ parse_register_src(
    return TRUE;
 }
 
-/* Parse register declaration.
- *    <register_dcl> ::= <register_file_bracket_index> `]' |
- *                       <register_file_bracket_index> `..' <index> `]'
+static boolean
+parse_opt_register_src_bracket(
+   struct translate_ctx *ctx,
+   struct parsed_src_bracket *brackets,
+   int *parsed_brackets)
+{
+   const char *cur = ctx->cur;
+
+   *parsed_brackets = 0;
+
+   eat_opt_white( &cur );
+   if (cur[0] == '[') {
+      ++cur;
+      ctx->cur = cur;
+
+      if (!parse_register_src_bracket(ctx, brackets))
+         return FALSE;
+
+      *parsed_brackets = 1;
+   }
+
+   return TRUE;
+}
+
+/* <register_file_bracket> ::= <file> `['
  */
 static boolean
-parse_register_dcl(
+parse_register_file_bracket(
+   struct translate_ctx *ctx,
+   uint *file )
+{
+   if (!parse_file( &ctx->cur, file )) {
+      report_error( ctx, "Unknown register file" );
+      return FALSE;
+   }
+   eat_opt_white( &ctx->cur );
+   if (*ctx->cur != '[') {
+      report_error( ctx, "Expected `['" );
+      return FALSE;
+   }
+   ctx->cur++;
+   return TRUE;
+}
+
+/* <register_file_bracket_index> ::= <register_file_bracket> <uint>
+ */
+static boolean
+parse_register_file_bracket_index(
+   struct translate_ctx *ctx,
+   uint *file,
+   int *index )
+{
+   uint uindex;
+
+   if (!parse_register_file_bracket( ctx, file ))
+      return FALSE;
+   eat_opt_white( &ctx->cur );
+   if (!parse_uint( &ctx->cur, &uindex )) {
+      report_error( ctx, "Expected literal unsigned integer" );
+      return FALSE;
+   }
+   *index = (int) uindex;
+   return TRUE;
+}
+
+/* Parse source register operand.
+ *    <register_src> ::= <register_file_bracket_index> `]' |
+ *                       <register_file_bracket> <register_dst> [`.' (`x' | `y' | `z' | `w')] `]' |
+ *                       <register_file_bracket> <register_dst> [`.' (`x' | `y' | `z' | `w')] `+' <uint> `]' |
+ *                       <register_file_bracket> <register_dst> [`.' (`x' | `y' | `z' | `w')] `-' <uint> `]'
+ */
+static boolean
+parse_register_src(
    struct translate_ctx *ctx,
    uint *file,
-   int *first,
-   int *last )
+   struct parsed_src_bracket *brackets)
 {
-   if (!parse_register_file_bracket_index( ctx, file, first ))
+
+   brackets->ind_comp = TGSI_SWIZZLE_X;
+   if (!parse_register_file_bracket( ctx, file ))
       return FALSE;
+   if (!parse_register_src_bracket( ctx, brackets ))
+       return FALSE;
+
+   return TRUE;
+}
+
+struct parsed_dcl_bracket {
+   uint first;
+   uint last;
+};
+
+static boolean
+parse_register_dcl_bracket(
+   struct translate_ctx *ctx,
+   struct parsed_dcl_bracket *bracket)
+{
+   uint uindex;
+   memset(bracket, 0, sizeof(struct parsed_dcl_bracket));
+
    eat_opt_white( &ctx->cur );
+
+   if (!parse_uint( &ctx->cur, &uindex )) {
+      /* it can be an empty bracket [] which means its range
+       * is from 0 to some implied size */
+      if (ctx->cur[0] == ']' && ctx->implied_array_size != 0) {
+         bracket->first = 0;
+         bracket->last = ctx->implied_array_size - 1;
+         goto cleanup;
+      }
+      report_error( ctx, "Expected literal unsigned integer" );
+      return FALSE;
+   }
+   bracket->first = (int) uindex;
+
+   eat_opt_white( &ctx->cur );
+
    if (ctx->cur[0] == '.' && ctx->cur[1] == '.') {
       uint uindex;
 
@@ -471,12 +566,14 @@ parse_register_dcl(
          report_error( ctx, "Expected literal integer" );
          return FALSE;
       }
-      *last = (int) uindex;
+      bracket->last = (int) uindex;
       eat_opt_white( &ctx->cur );
    }
    else {
-      *last = *first;
+      bracket->last = bracket->first;
    }
+
+cleanup:
    if (*ctx->cur != ']') {
       report_error( ctx, "Expected `]' or `..'" );
       return FALSE;
@@ -485,16 +582,70 @@ parse_register_dcl(
    return TRUE;
 }
 
-static const char *modulate_names[TGSI_MODULATE_COUNT] =
+/* Parse register declaration.
+ *    <register_dcl> ::= <register_file_bracket_index> `]' |
+ *                       <register_file_bracket_index> `..' <index> `]'
+ */
+static boolean
+parse_register_dcl(
+   struct translate_ctx *ctx,
+   uint *file,
+   struct parsed_dcl_bracket *brackets,
+   int *num_brackets)
 {
-   "_1X",
-   "_2X",
-   "_4X",
-   "_8X",
-   "_D2",
-   "_D4",
-   "_D8"
-};
+   const char *cur;
+
+   *num_brackets = 0;
+
+   if (!parse_register_file_bracket( ctx, file ))
+      return FALSE;
+   if (!parse_register_dcl_bracket( ctx, &brackets[0] ))
+      return FALSE;
+
+   *num_brackets = 1;
+
+   cur = ctx->cur;
+   eat_opt_white( &cur );
+
+   if (cur[0] == '[') {
+      ++cur;
+      ctx->cur = cur;
+      if (!parse_register_dcl_bracket( ctx, &brackets[1] ))
+         return FALSE;
+      /* for geometry shader we don't really care about
+       * the first brackets it's always the size of the
+       * input primitive. so we want to declare just
+       * the index relevant to the semantics which is in
+       * the second bracket */
+      if (ctx->processor == TGSI_PROCESSOR_GEOMETRY) {
+         brackets[0] = brackets[1];
+      }
+      *num_brackets = 2;
+   }
+
+   return TRUE;
+}
+
+
+/* Parse destination register operand.
+ *    <register_dst> ::= <register_file_bracket_index> `]'
+ */
+static boolean
+parse_register_dst(
+   struct translate_ctx *ctx,
+   uint *file,
+   int *index )
+{
+   if (!parse_register_file_bracket_index( ctx, file, index ))
+      return FALSE;
+   eat_opt_white( &ctx->cur );
+   if (*ctx->cur != ']') {
+      report_error( ctx, "Expected `]'" );
+      return FALSE;
+   }
+   ctx->cur++;
+   return TRUE;
+}
 
 static boolean
 parse_dst_operand(
@@ -511,26 +662,13 @@ parse_dst_operand(
 
    cur = ctx->cur;
    eat_opt_white( &cur );
-   if (*cur == '_') {
-      uint i;
-
-      for (i = 0; i < TGSI_MODULATE_COUNT; i++) {
-         if (str_match_no_case( &cur, modulate_names[i] )) {
-            if (!is_digit_alpha_underscore( cur )) {
-               dst->DstRegisterExtModulate.Modulate = i;
-               ctx->cur = cur;
-               break;
-            }
-         }
-      }
-   }
 
    if (!parse_opt_writemask( ctx, &writemask ))
       return FALSE;
 
-   dst->DstRegister.File = file;
-   dst->DstRegister.Index = index;
-   dst->DstRegister.WriteMask = writemask;
+   dst->Register.File = file;
+   dst->Register.Index = index;
+   dst->Register.WriteMask = writemask;
    return TRUE;
 }
 
@@ -538,13 +676,11 @@ static boolean
 parse_optional_swizzle(
    struct translate_ctx *ctx,
    uint swizzle[4],
-   boolean *parsed_swizzle,
-   boolean *parsed_extswizzle )
+   boolean *parsed_swizzle )
 {
    const char *cur = ctx->cur;
 
    *parsed_swizzle = FALSE;
-   *parsed_extswizzle = FALSE;
 
    eat_opt_white( &cur );
    if (*cur == '.') {
@@ -562,15 +698,8 @@ parse_optional_swizzle(
          else if (uprcase( *cur ) == 'W')
             swizzle[i] = TGSI_SWIZZLE_W;
          else {
-            if (*cur == '0')
-               swizzle[i] = TGSI_EXTSWIZZLE_ZERO;
-            else if (*cur == '1')
-               swizzle[i] = TGSI_EXTSWIZZLE_ONE;
-            else {
-               report_error( ctx, "Expected register swizzle component `x', `y', `z', `w', `0' or `1'" );
-               return FALSE;
-            }
-            *parsed_extswizzle = TRUE;
+           report_error( ctx, "Expected register swizzle component `x', `y', `z', `w', `0' or `1'" );
+           return FALSE;
          }
          cur++;
       }
@@ -585,171 +714,59 @@ parse_src_operand(
    struct translate_ctx *ctx,
    struct tgsi_full_src_register *src )
 {
-   const char *cur;
-   float value;
    uint file;
-   int index;
-   uint ind_file;
-   int ind_index;
-   uint ind_comp;
    uint swizzle[4];
-   boolean parsed_ext_negate_paren = FALSE;
    boolean parsed_swizzle;
-   boolean parsed_extswizzle;
+   struct parsed_src_bracket bracket[2];
+   int parsed_opt_brackets;
 
    if (*ctx->cur == '-') {
-      cur = ctx->cur;
-      cur++;
-      eat_opt_white( &cur );
-      if (*cur == '(') {
-         cur++;
-         src->SrcRegisterExtMod.Negate = 1;
-         eat_opt_white( &cur );
-         ctx->cur = cur;
-         parsed_ext_negate_paren = TRUE;
-      }
-      else if (*cur == '|') {
-         cur++;
-         src->SrcRegisterExtMod.Negate = 1;
-         src->SrcRegisterExtMod.Absolute = 1;
-         eat_opt_white(&cur);
-         ctx->cur = cur;
-      }
-   }
-   else if (*ctx->cur == '|') {
       ctx->cur++;
       eat_opt_white( &ctx->cur );
-      src->SrcRegisterExtMod.Absolute = 1;
+      src->Register.Negate = 1;
    }
 
-   if (*ctx->cur == '-') {
+   if (*ctx->cur == '|') {
       ctx->cur++;
       eat_opt_white( &ctx->cur );
-      src->SrcRegister.Negate = 1;
+      src->Register.Absolute = 1;
    }
 
-   cur = ctx->cur;
-   if (parse_float( &cur, &value )) {
-      if (value == 2.0f) {
-         eat_opt_white( &cur );
-         if (*cur != '*') {
-            report_error( ctx, "Expected `*'" );
-            return FALSE;
-         }
-         cur++;
-         if (*cur != '(') {
-            report_error( ctx, "Expected `('" );
-            return FALSE;
-         }
-         cur++;
-         src->SrcRegisterExtMod.Scale2X = 1;
-         eat_opt_white( &cur );
-         ctx->cur = cur;
-      }
-   }
-
-   if (*ctx->cur == '(') {
-      ctx->cur++;
-      eat_opt_white( &ctx->cur );
-      src->SrcRegisterExtMod.Bias = 1;
-   }
+   if (!parse_register_src(ctx, &file, &bracket[0]))
+      return FALSE;
+   if (!parse_opt_register_src_bracket(ctx, &bracket[1], &parsed_opt_brackets))
+      return FALSE;
 
-   cur = ctx->cur;
-   if (parse_float( &cur, &value )) {
-      if (value == 1.0f) {
-         eat_opt_white( &cur );
-         if (*cur != '-') {
-            report_error( ctx, "Expected `-'" );
-            return FALSE;
-         }
-         cur++;
-         if (*cur != '(') {
-            report_error( ctx, "Expected `('" );
-            return FALSE;
-         }
-         cur++;
-         src->SrcRegisterExtMod.Complement = 1;
-         eat_opt_white( &cur );
-         ctx->cur = cur;
-      }
+   src->Register.File = file;
+   src->Register.Index = bracket[0].index;
+   if (bracket[0].ind_file != TGSI_FILE_NULL) {
+      src->Register.Indirect = 1;
+      src->Indirect.File = bracket[0].ind_file;
+      src->Indirect.Index = bracket[0].ind_index;
+      src->Indirect.SwizzleX = bracket[0].ind_comp;
+      src->Indirect.SwizzleY = bracket[0].ind_comp;
+      src->Indirect.SwizzleZ = bracket[0].ind_comp;
+      src->Indirect.SwizzleW = bracket[0].ind_comp;
    }
-
-   if (!parse_register_src(ctx, &file, &index, &ind_file, &ind_index, &ind_comp))
-      return FALSE;
-   src->SrcRegister.File = file;
-   src->SrcRegister.Index = index;
-   if (ind_file != TGSI_FILE_NULL) {
-      src->SrcRegister.Indirect = 1;
-      src->SrcRegisterInd.File = ind_file;
-      src->SrcRegisterInd.Index = ind_index;
-      src->SrcRegisterInd.SwizzleX = ind_comp;
-      src->SrcRegisterInd.SwizzleY = ind_comp;
-      src->SrcRegisterInd.SwizzleZ = ind_comp;
-      src->SrcRegisterInd.SwizzleW = ind_comp;
+   if (parsed_opt_brackets) {
+      src->Register.Dimension = 1;
+      src->Dimension.Indirect = 0;
+      src->Dimension.Dimension = 0;
+      src->Dimension.Index = bracket[1].index;
    }
 
    /* Parse optional swizzle.
     */
-   if (parse_optional_swizzle( ctx, swizzle, &parsed_swizzle, &parsed_extswizzle )) {
-      if (parsed_extswizzle) {
-         assert( parsed_swizzle );
-
-         src->SrcRegisterExtSwz.ExtSwizzleX = swizzle[0];
-         src->SrcRegisterExtSwz.ExtSwizzleY = swizzle[1];
-         src->SrcRegisterExtSwz.ExtSwizzleZ = swizzle[2];
-         src->SrcRegisterExtSwz.ExtSwizzleW = swizzle[3];
-      }
-      else if (parsed_swizzle) {
-         src->SrcRegister.SwizzleX = swizzle[0];
-         src->SrcRegister.SwizzleY = swizzle[1];
-         src->SrcRegister.SwizzleZ = swizzle[2];
-         src->SrcRegister.SwizzleW = swizzle[3];
-      }
-   }
-
-   if (src->SrcRegisterExtMod.Complement) {
-      eat_opt_white( &ctx->cur );
-      if (*ctx->cur != ')') {
-         report_error( ctx, "Expected `)'" );
-         return FALSE;
-      }
-      ctx->cur++;
-   }
-
-   if (src->SrcRegisterExtMod.Bias) {
-      eat_opt_white( &ctx->cur );
-      if (*ctx->cur != ')') {
-         report_error( ctx, "Expected `)'" );
-         return FALSE;
-      }
-      ctx->cur++;
-      eat_opt_white( &ctx->cur );
-      if (*ctx->cur != '-') {
-         report_error( ctx, "Expected `-'" );
-         return FALSE;
-      }
-      ctx->cur++;
-      eat_opt_white( &ctx->cur );
-      if (!parse_float( &ctx->cur, &value )) {
-         report_error( ctx, "Expected literal floating point" );
-         return FALSE;
-      }
-      if (value != 0.5f) {
-         report_error( ctx, "Expected 0.5" );
-         return FALSE;
+   if (parse_optional_swizzle( ctx, swizzle, &parsed_swizzle )) {
+      if (parsed_swizzle) {
+         src->Register.SwizzleX = swizzle[0];
+         src->Register.SwizzleY = swizzle[1];
+         src->Register.SwizzleZ = swizzle[2];
+         src->Register.SwizzleW = swizzle[3];
       }
    }
 
-   if (src->SrcRegisterExtMod.Scale2X) {
-      eat_opt_white( &ctx->cur );
-      if (*ctx->cur != ')') {
-         report_error( ctx, "Expected `)'" );
-         return FALSE;
-      }
-      ctx->cur++;
-   }
-
-   if (src->SrcRegisterExtMod.Absolute) {
+   if (src->Register.Absolute) {
       eat_opt_white( &ctx->cur );
       if (*ctx->cur != '|') {
          report_error( ctx, "Expected `|'" );
@@ -758,14 +775,6 @@ parse_src_operand(
       ctx->cur++;
    }
 
-   if (parsed_ext_negate_paren) {
-      eat_opt_white( &ctx->cur );
-      if (*ctx->cur != ')') {
-         report_error( ctx, "Expected `)'" );
-         return FALSE;
-      }
-      ctx->cur++;
-   }
 
    return TRUE;
 }
@@ -857,11 +866,11 @@ parse_instruction(
       }
 
       if (i < info->num_dst) {
-         if (!parse_dst_operand( ctx, &inst.FullDstRegisters[i] ))
+         if (!parse_dst_operand( ctx, &inst.Dst[i] ))
             return FALSE;
       }
       else if (i < info->num_dst + info->num_src) {
-         if (!parse_src_operand( ctx, &inst.FullSrcRegisters[i - info->num_dst] ))
+         if (!parse_src_operand( ctx, &inst.Src[i - info->num_dst] ))
             return FALSE;
       }
       else {
@@ -870,7 +879,8 @@ parse_instruction(
          for (j = 0; j < TGSI_TEXTURE_COUNT; j++) {
             if (str_match_no_case( &ctx->cur, texture_names[j] )) {
                if (!is_digit_alpha_underscore( ctx->cur )) {
-                  inst.InstructionExtTexture.Texture = j;
+                  inst.Instruction.Texture = 1;
+                  inst.Texture.Texture = j;
                   break;
                }
             }
@@ -896,7 +906,8 @@ parse_instruction(
          report_error( ctx, "Expected a label" );
          return FALSE;
       }
-      inst.InstructionExtLabel.Label = target;
+      inst.Instruction.Label = 1;
+      inst.Label.Label = target;
    }
 
    advance = tgsi_build_full_instruction(
@@ -920,7 +931,9 @@ static const char *semantic_names[TGSI_SEMANTIC_COUNT] =
    "PSIZE",
    "GENERIC",
    "NORMAL",
-   "FACE"
+   "FACE",
+   "EDGEFLAG",
+   "PRIM_ID"
 };
 
 static const char *interpolate_names[TGSI_INTERPOLATE_COUNT] =
@@ -934,8 +947,8 @@ static boolean parse_declaration( struct translate_ctx *ctx )
 {
    struct tgsi_full_declaration decl;
    uint file;
-   int first;
-   int last;
+   struct parsed_dcl_bracket brackets[2];
+   int num_brackets;
    uint writemask;
    const char *cur;
    uint advance;
@@ -947,7 +960,7 @@ static boolean parse_declaration( struct translate_ctx *ctx )
       report_error( ctx, "Syntax error" );
       return FALSE;
    }
-   if (!parse_register_dcl( ctx, &file, &first, &last ))
+   if (!parse_register_dcl( ctx, &file, brackets, &num_brackets))
       return FALSE;
    if (!parse_opt_writemask( ctx, &writemask ))
       return FALSE;
@@ -955,8 +968,8 @@ static boolean parse_declaration( struct translate_ctx *ctx )
    decl = tgsi_default_full_declaration();
    decl.Declaration.File = file;
    decl.Declaration.UsageMask = writemask;
-   decl.DeclarationRange.First = first;
-   decl.DeclarationRange.Last = last;
+   decl.Range.First = brackets[0].first;
+   decl.Range.Last = brackets[0].last;
 
    cur = ctx->cur;
    eat_opt_white( &cur );
@@ -987,13 +1000,13 @@ static boolean parse_declaration( struct translate_ctx *ctx )
                }
                cur2++;
 
-               decl.Semantic.SemanticIndex = index;
+               decl.Semantic.Index = index;
 
                cur = cur2;
             }
 
             decl.Declaration.Semantic = 1;
-            decl.Semantic.SemanticName = i;
+            decl.Semantic.Name = i;
 
             ctx->cur = cur;
             break;
@@ -1099,6 +1112,110 @@ static boolean parse_immediate( struct translate_ctx *ctx )
    return TRUE;
 }
 
+static const char *property_names[] =
+{
+   "GS_INPUT_PRIMITIVE",
+   "GS_OUTPUT_PRIMITIVE",
+   "GS_MAX_OUTPUT_VERTICES"
+};
+
+static const char *primitive_names[] =
+{
+   "POINTS",
+   "LINES",
+   "LINE_LOOP",
+   "LINE_STRIP",
+   "TRIANGLES",
+   "TRIANGLE_STRIP",
+   "TRIANGLE_FAN",
+   "QUADS",
+   "QUAD_STRIP",
+   "POLYGON"
+};
+
+static boolean
+parse_primitive( const char **pcur, uint *primitive )
+{
+   uint i;
+
+   for (i = 0; i < PIPE_PRIM_MAX; i++) {
+      const char *cur = *pcur;
+
+      if (str_match_no_case( &cur, primitive_names[i])) {
+         *primitive = i;
+         *pcur = cur;
+         return TRUE;
+      }
+   }
+   return FALSE;
+}
+
+
+static boolean parse_property( struct translate_ctx *ctx )
+{
+   struct tgsi_full_property prop;
+   uint property_name;
+   uint values[8];
+   uint advance;
+   char id[64];
+
+   if (!eat_white( &ctx->cur )) {
+      report_error( ctx, "Syntax error" );
+      return FALSE;
+   }
+   if (!parse_identifier( &ctx->cur, id )) {
+      report_error( ctx, "Syntax error" );
+      return FALSE;
+   }
+   for (property_name = 0; property_name < TGSI_PROPERTY_COUNT;
+        ++property_name) {
+      if (streq_nocase_uprcase(property_names[property_name], id)) {
+         break;
+      }
+   }
+   if (property_name >= TGSI_PROPERTY_COUNT) {
+      debug_printf( "\nError: Unknown property : '%s'", id );
+      return FALSE;
+   }
+
+   eat_opt_white( &ctx->cur );
+   switch(property_name) {
+   case TGSI_PROPERTY_GS_INPUT_PRIM:
+   case TGSI_PROPERTY_GS_OUTPUT_PRIM:
+      if (!parse_primitive(&ctx->cur, &values[0] )) {
+         report_error( ctx, "Unknown primitive name as property!" );
+         return FALSE;
+      }
+      if (property_name == TGSI_PROPERTY_GS_INPUT_PRIM &&
+          ctx->processor == TGSI_PROCESSOR_GEOMETRY) {
+         ctx->implied_array_size = u_vertices_per_prim(values[0]);
+      }
+      break;
+   default:
+      if (!parse_uint(&ctx->cur, &values[0] )) {
+         report_error( ctx, "Expected unsigned integer as property!" );
+         return FALSE;
+      }
+   }
+
+   prop = tgsi_default_full_property();
+   prop.Property.PropertyName = property_name;
+   prop.Property.NrTokens += 1;
+   prop.u[0].Data = values[0];
+
+   advance = tgsi_build_full_property(
+      &prop,
+      ctx->tokens_cur,
+      ctx->header,
+      (uint) (ctx->tokens_end - ctx->tokens_cur) );
+   if (advance == 0)
+      return FALSE;
+   ctx->tokens_cur += advance;
+
+   return TRUE;
+}
+
+
 static boolean translate( struct translate_ctx *ctx )
 {
    eat_opt_white( &ctx->cur );
@@ -1107,7 +1224,6 @@ static boolean translate( struct translate_ctx *ctx )
 
    while (*ctx->cur != '\0') {
       uint label_val = 0;
-
       if (!eat_white( &ctx->cur )) {
          report_error( ctx, "Syntax error" );
          return FALSE;
@@ -1115,7 +1231,6 @@ static boolean translate( struct translate_ctx *ctx )
 
       if (*ctx->cur == '\0')
          break;
-
       if (parse_label( ctx, &label_val )) {
          if (!parse_instruction( ctx, TRUE ))
             return FALSE;
@@ -1128,6 +1243,10 @@ static boolean translate( struct translate_ctx *ctx )
          if (!parse_immediate( ctx ))
             return FALSE;
       }
+      else if (str_match_no_case( &ctx->cur, "PROPERTY" )) {
+         if (!parse_property( ctx ))
+            return FALSE;
+      }
       else if (!parse_instruction( ctx, FALSE )) {
          return FALSE;
       }
index bc9c18fd4a725df628b7b64f57a60c405cca832b..ae875f29abfb23334a42fa5c55d42d6461909455 100644 (file)
@@ -79,6 +79,19 @@ emit_immediate(struct tgsi_transform_context *ctx,
 }
 
 
+static void
+emit_property(struct tgsi_transform_context *ctx,
+              const struct tgsi_full_property *prop)
+{
+   uint ti = ctx->ti;
+
+   ti += tgsi_build_full_property(prop,
+                                  ctx->tokens_out + ti,
+                                  ctx->header,
+                                  ctx->max_tokens_out - ti);
+   ctx->ti = ti;
+}
+
 
 /**
  * Apply user-defined transformations to the input shader to produce
@@ -110,6 +123,7 @@ tgsi_transform_shader(const struct tgsi_token *tokens_in,
    ctx->emit_instruction = emit_instruction;
    ctx->emit_declaration = emit_declaration;
    ctx->emit_immediate = emit_immediate;
+   ctx->emit_property = emit_property;
    ctx->tokens_out = tokens_out;
    ctx->max_tokens_out = max_tokens_out;
 
@@ -130,15 +144,13 @@ tgsi_transform_shader(const struct tgsi_token *tokens_in,
    /**
     **  Setup output shader
     **/
-   *(struct tgsi_version *) &tokens_out[0] = tgsi_build_version();
-
-   ctx->header = (struct tgsi_header *) (tokens_out + 1);
+   ctx->header = (struct tgsi_header *)tokens_out;
    *ctx->header = tgsi_build_header();
 
-   processor = (struct tgsi_processor *) (tokens_out + 2);
+   processor = (struct tgsi_processor *) (tokens_out + 1);
    *processor = tgsi_build_processor( procType, ctx->header );
 
-   ctx->ti = 3;
+   ctx->ti = 2;
 
 
    /**
@@ -184,6 +196,17 @@ tgsi_transform_shader(const struct tgsi_token *tokens_in,
                ctx->emit_immediate(ctx, fullimm);
          }
          break;
+      case TGSI_TOKEN_TYPE_PROPERTY:
+         {
+            struct tgsi_full_property *fullprop
+               = &parse.FullToken.FullProperty;
+
+            if (ctx->transform_property)
+               ctx->transform_property(ctx, fullprop);
+            else
+               ctx->emit_property(ctx, fullprop);
+         }
+         break;
 
       default:
          assert( 0 );
@@ -215,7 +238,7 @@ tgsi_transform_foo( struct tgsi_token *tokens_out,
                     uint max_tokens_out )
 {
    const char *text = 
-      "FRAG1.1\n"
+      "FRAG\n"
       "DCL IN[0], COLOR, CONSTANT\n"
       "DCL OUT[0], COLOR\n"
       "  0: MOV OUT[0], IN[0]\n"
index a121adbaef4056fa296fc0f7591dadb72479a176..818478e277a91e8ed55105453578987550965e7f 100644 (file)
@@ -53,6 +53,8 @@ struct tgsi_transform_context
 
    void (*transform_immediate)(struct tgsi_transform_context *ctx,
                                struct tgsi_full_immediate *imm);
+   void (*transform_property)(struct tgsi_transform_context *ctx,
+                              struct tgsi_full_property *prop);
 
    /**
     * Called at end of input program to allow caller to append extra
@@ -73,6 +75,8 @@ struct tgsi_transform_context
                             const struct tgsi_full_declaration *decl);
    void (*emit_immediate)(struct tgsi_transform_context *ctx,
                           const struct tgsi_full_immediate *imm);
+   void (*emit_property)(struct tgsi_transform_context *ctx,
+                         const struct tgsi_full_property *prop);
 
    struct tgsi_header *header;
    uint max_tokens_out;
index 654426a903d70d9bc2d16f254d311f84c5bae41f..e64e2b731dfa5d494cfd0fc183efdb5db736b337 100644 (file)
@@ -29,6 +29,7 @@
 #include "pipe/p_context.h"
 #include "pipe/p_state.h"
 #include "tgsi/tgsi_ureg.h"
+#include "tgsi/tgsi_build.h"
 #include "tgsi/tgsi_info.h"
 #include "tgsi/tgsi_dump.h"
 #include "tgsi/tgsi_sanity.h"
@@ -36,7 +37,6 @@
 #include "util/u_math.h"
 
 union tgsi_any_token {
-   struct tgsi_version version;
    struct tgsi_header header;
    struct tgsi_processor processor;
    struct tgsi_token token;
@@ -46,18 +46,12 @@ union tgsi_any_token {
    struct tgsi_immediate imm;
    union  tgsi_immediate_data imm_data;
    struct tgsi_instruction insn;
-   struct tgsi_instruction_ext_nv insn_ext_nv;
-   struct tgsi_instruction_ext_label insn_ext_label;
-   struct tgsi_instruction_ext_texture insn_ext_texture;
-   struct tgsi_instruction_ext_predicate insn_ext_predicate;
+   struct tgsi_instruction_predicate insn_predicate;
+   struct tgsi_instruction_label insn_label;
+   struct tgsi_instruction_texture insn_texture;
    struct tgsi_src_register src;
-   struct tgsi_src_register_ext_swz src_ext_swz;
-   struct tgsi_src_register_ext_mod src_ext_mod;
    struct tgsi_dimension dim;
    struct tgsi_dst_register dst;
-   struct tgsi_dst_register_ext_concode dst_ext_code;
-   struct tgsi_dst_register_ext_modulate dst_ext_mod;
-   struct tgsi_dst_register_ext_predicate dst_ext_pred;
    unsigned value;
 };
 
@@ -75,6 +69,8 @@ struct ureg_tokens {
 #define UREG_MAX_IMMEDIATE 32
 #define UREG_MAX_TEMP 256
 #define UREG_MAX_ADDR 2
+#define UREG_MAX_LOOP 1
+#define UREG_MAX_PRED 1
 
 #define DOMAIN_DECL 0
 #define DOMAIN_INSN 1
@@ -93,6 +89,11 @@ struct ureg_program
 
    unsigned vs_inputs[UREG_MAX_INPUT/32];
 
+   struct {
+      unsigned index;
+   } gs_input[UREG_MAX_INPUT];
+   unsigned nr_gs_inputs;
+
    struct {
       unsigned semantic_name;
       unsigned semantic_index;
@@ -100,8 +101,13 @@ struct ureg_program
    unsigned nr_outputs;
 
    struct {
-      float v[4];
+      union {
+         float f[4];
+         unsigned u[4];
+         int i[4];
+      } value;
       unsigned nr;
+      unsigned type;
    } immediate[UREG_MAX_IMMEDIATE];
    unsigned nr_immediates;
 
@@ -118,6 +124,8 @@ struct ureg_program
    unsigned nr_constant_ranges;
 
    unsigned nr_addrs;
+   unsigned nr_preds;
+   unsigned nr_loops;
    unsigned nr_instructions;
 
    struct ureg_tokens domain[2];
@@ -141,8 +149,9 @@ static void tokens_expand( struct ureg_tokens *tokens,
 {
    unsigned old_size = tokens->size * sizeof(unsigned);
 
-   if (tokens->tokens == error_tokens)
-      goto fail;
+   if (tokens->tokens == error_tokens) {
+      return;
+   }
 
    while (tokens->count + count > tokens->size) {
       tokens->size = (1 << ++tokens->order);
@@ -151,13 +160,9 @@ static void tokens_expand( struct ureg_tokens *tokens,
    tokens->tokens = REALLOC(tokens->tokens, 
                             old_size,
                             tokens->size * sizeof(unsigned));
-   if (tokens->tokens == NULL) 
-      goto fail;
-
-   return;
-          
-fail:
-   tokens_error(tokens);
+   if (tokens->tokens == NULL) {
+      tokens_error(tokens);
+   }
 }
 
 static void set_bad( struct ureg_program *ureg )
@@ -207,9 +212,13 @@ ureg_dst_register( unsigned file,
    dst.IndirectIndex = 0;
    dst.IndirectSwizzle = 0;
    dst.Saturate  = 0;
+   dst.Predicate = 0;
+   dst.PredNegate = 0;
+   dst.PredSwizzleX = TGSI_SWIZZLE_X;
+   dst.PredSwizzleY = TGSI_SWIZZLE_Y;
+   dst.PredSwizzleZ = TGSI_SWIZZLE_Z;
+   dst.PredSwizzleW = TGSI_SWIZZLE_W;
    dst.Index     = index;
-   dst.Pad1      = 0;
-   dst.Pad2      = 0;
 
    return dst;
 }
@@ -279,6 +288,22 @@ ureg_DECL_vs_input( struct ureg_program *ureg,
 }
 
 
+struct ureg_src
+ureg_DECL_gs_input(struct ureg_program *ureg,
+                   unsigned index)
+{
+   if (ureg->nr_gs_inputs < UREG_MAX_INPUT) {
+      ureg->gs_input[ureg->nr_gs_inputs].index = index;
+      ureg->nr_gs_inputs++;
+   } else {
+      set_bad(ureg);
+   }
+
+   /* XXX: Add suport for true 2D input registers. */
+   return ureg_src_register(TGSI_FILE_INPUT, index);
+}
+
+
 struct ureg_dst 
 ureg_DECL_output( struct ureg_program *ureg,
                   unsigned name,
@@ -350,6 +375,7 @@ struct ureg_src ureg_DECL_constant(struct ureg_program *ureg,
       i = ureg->nr_constant_ranges++;
       ureg->constant_range[i].first = index;
       ureg->constant_range[i].last = index;
+      goto out;
    }
 
    /* Collapse all ranges down to one:
@@ -417,6 +443,32 @@ struct ureg_dst ureg_DECL_address( struct ureg_program *ureg )
    return ureg_dst_register( TGSI_FILE_ADDRESS, 0 );
 }
 
+/* Allocate a new loop register.
+ */
+struct ureg_dst
+ureg_DECL_loop(struct ureg_program *ureg)
+{
+   if (ureg->nr_loops < UREG_MAX_LOOP) {
+      return ureg_dst_register(TGSI_FILE_LOOP, ureg->nr_loops++);
+   }
+
+   assert(0);
+   return ureg_dst_register(TGSI_FILE_LOOP, 0);
+}
+
+/* Allocate a new predicate register.
+ */
+struct ureg_dst
+ureg_DECL_predicate(struct ureg_program *ureg)
+{
+   if (ureg->nr_preds < UREG_MAX_PRED) {
+      return ureg_dst_register(TGSI_FILE_PREDICATE, ureg->nr_preds++);
+   }
+
+   assert(0);
+   return ureg_dst_register(TGSI_FILE_PREDICATE, 0);
+}
+
 /* Allocate a new sampler.
  */
 struct ureg_src ureg_DECL_sampler( struct ureg_program *ureg,
@@ -439,22 +491,22 @@ struct ureg_src ureg_DECL_sampler( struct ureg_program *ureg,
 }
 
 
-
-
-static int match_or_expand_immediate( const float *v,
-                                      unsigned nr,
-                                      float *v2,
-                                      unsigned *nr2,
-                                      unsigned *swizzle )
+static int
+match_or_expand_immediate( const unsigned *v,
+                           unsigned nr,
+                           unsigned *v2,
+                           unsigned *pnr2,
+                           unsigned *swizzle )
 {
+   unsigned nr2 = *pnr2;
    unsigned i, j;
-   
+
    *swizzle = 0;
 
    for (i = 0; i < nr; i++) {
       boolean found = FALSE;
 
-      for (j = 0; j < *nr2 && !found; j++) {
+      for (j = 0; j < nr2 && !found; j++) {
          if (v[i] == v2[j]) {
             *swizzle |= j << (i * 2);
             found = TRUE;
@@ -462,24 +514,28 @@ static int match_or_expand_immediate( const float *v,
       }
 
       if (!found) {
-         if (*nr2 >= 4) 
+         if (nr2 >= 4) {
             return FALSE;
+         }
 
-         v2[*nr2] = v[i];
-         *swizzle |= *nr2 << (i * 2);
-         (*nr2)++;
+         v2[nr2] = v[i];
+         *swizzle |= nr2 << (i * 2);
+         nr2++;
       }
    }
 
+   /* Actually expand immediate only when fully succeeded.
+    */
+   *pnr2 = nr2;
    return TRUE;
 }
 
 
-
-
-struct ureg_src ureg_DECL_immediate( struct ureg_program *ureg, 
-                                     const float *v,
-                                     unsigned nr )
+static struct ureg_src
+decl_immediate( struct ureg_program *ureg,
+                const unsigned *v,
+                unsigned nr,
+                unsigned type )
 {
    unsigned i, j;
    unsigned swizzle;
@@ -489,38 +545,82 @@ struct ureg_src ureg_DECL_immediate( struct ureg_program *ureg,
     */
 
    for (i = 0; i < ureg->nr_immediates; i++) {
-      if (match_or_expand_immediate( v, 
-                                     nr,
-                                     ureg->immediate[i].v,
-                                     &ureg->immediate[i].nr, 
-                                     &swizzle ))
+      if (ureg->immediate[i].type != type) {
+         continue;
+      }
+      if (match_or_expand_immediate(v,
+                                    nr,
+                                    ureg->immediate[i].value.u,
+                                    &ureg->immediate[i].nr,
+                                    &swizzle)) {
          goto out;
+      }
    }
 
    if (ureg->nr_immediates < UREG_MAX_IMMEDIATE) {
       i = ureg->nr_immediates++;
-      if (match_or_expand_immediate( v,
-                                     nr,
-                                     ureg->immediate[i].v,
-                                     &ureg->immediate[i].nr, 
-                                     &swizzle ))
+      ureg->immediate[i].type = type;
+      if (match_or_expand_immediate(v,
+                                    nr,
+                                    ureg->immediate[i].value.u,
+                                    &ureg->immediate[i].nr,
+                                    &swizzle)) {
          goto out;
+      }
    }
 
-   set_bad( ureg );
+   set_bad(ureg);
 
 out:
    /* Make sure that all referenced elements are from this immediate.
     * Has the effect of making size-one immediates into scalars.
     */
-   for (j = nr; j < 4; j++)
+   for (j = nr; j < 4; j++) {
       swizzle |= (swizzle & 0x3) << (j * 2);
+   }
+
+   return ureg_swizzle(ureg_src_register(TGSI_FILE_IMMEDIATE, i),
+                       (swizzle >> 0) & 0x3,
+                       (swizzle >> 2) & 0x3,
+                       (swizzle >> 4) & 0x3,
+                       (swizzle >> 6) & 0x3);
+}
+
+
+struct ureg_src
+ureg_DECL_immediate( struct ureg_program *ureg,
+                     const float *v,
+                     unsigned nr )
+{
+   union {
+      float f[4];
+      unsigned u[4];
+   } fu;
+   unsigned int i;
+
+   for (i = 0; i < nr; i++) {
+      fu.f[i] = v[i];
+   }
+
+   return decl_immediate(ureg, fu.u, nr, TGSI_IMM_FLOAT32);
+}
 
-   return ureg_swizzle( ureg_src_register( TGSI_FILE_IMMEDIATE, i ),
-                        (swizzle >> 0) & 0x3,
-                        (swizzle >> 2) & 0x3,
-                        (swizzle >> 4) & 0x3,
-                        (swizzle >> 6) & 0x3);
+
+struct ureg_src
+ureg_DECL_immediate_uint( struct ureg_program *ureg,
+                          const unsigned *v,
+                          unsigned nr )
+{
+   return decl_immediate(ureg, v, nr, TGSI_IMM_UINT32);
+}
+
+
+struct ureg_src
+ureg_DECL_immediate_int( struct ureg_program *ureg,
+                         const int *v,
+                         unsigned nr )
+{
+   return decl_immediate(ureg, (const unsigned *)v, nr, TGSI_IMM_INT32);
 }
 
 
@@ -528,9 +628,7 @@ void
 ureg_emit_src( struct ureg_program *ureg,
                struct ureg_src src )
 {
-   unsigned size = (1 + 
-                    (src.Absolute ? 1 : 0) +
-                    (src.Indirect ? 1 : 0));
+   unsigned size = 1 + (src.Indirect ? 1 : 0);
 
    union tgsi_any_token *out = get_tokens( ureg, DOMAIN_INSN, size );
    unsigned n = 0;
@@ -547,17 +645,8 @@ ureg_emit_src( struct ureg_program *ureg,
    out[n].src.SwizzleW = src.SwizzleW;
    out[n].src.Index = src.Index;
    out[n].src.Negate = src.Negate;
+   out[0].src.Absolute = src.Absolute;
    n++;
-   
-   if (src.Absolute) {
-      out[0].src.Extended = 1;
-      out[0].src.Negate = 0;
-      out[n].value = 0;
-      out[n].src_ext_mod.Type = TGSI_SRC_REGISTER_EXT_TYPE_MOD;
-      out[n].src_ext_mod.Absolute = 1;
-      out[n].src_ext_mod.Negate = src.Negate;
-      n++;
-   }
 
    if (src.Indirect) {
       out[0].src.Indirect = 1;
@@ -628,37 +717,54 @@ static void validate( unsigned opcode,
 #endif
 }
 
-unsigned
+struct ureg_emit_insn_result
 ureg_emit_insn(struct ureg_program *ureg,
                unsigned opcode,
                boolean saturate,
+               boolean predicate,
+               boolean pred_negate,
+               unsigned pred_swizzle_x,
+               unsigned pred_swizzle_y,
+               unsigned pred_swizzle_z,
+               unsigned pred_swizzle_w,
                unsigned num_dst,
                unsigned num_src )
 {
    union tgsi_any_token *out;
+   uint count = predicate ? 2 : 1;
+   struct ureg_emit_insn_result result;
 
    validate( opcode, num_dst, num_src );
    
-   out = get_tokens( ureg, DOMAIN_INSN, 1 );
-   out[0].value = 0;
-   out[0].insn.Type = TGSI_TOKEN_TYPE_INSTRUCTION;
-   out[0].insn.NrTokens = 0;
+   out = get_tokens( ureg, DOMAIN_INSN, count );
+   out[0].insn = tgsi_default_instruction();
    out[0].insn.Opcode = opcode;
    out[0].insn.Saturate = saturate;
    out[0].insn.NumDstRegs = num_dst;
    out[0].insn.NumSrcRegs = num_src;
-   out[0].insn.Padding = 0;
-   out[0].insn.Extended = 0;
-   
+
+   result.insn_token = ureg->domain[DOMAIN_INSN].count - count;
+   result.extended_token = result.insn_token;
+
+   if (predicate) {
+      out[0].insn.Predicate = 1;
+      out[1].insn_predicate = tgsi_default_instruction_predicate();
+      out[1].insn_predicate.Negate = pred_negate;
+      out[1].insn_predicate.SwizzleX = pred_swizzle_x;
+      out[1].insn_predicate.SwizzleY = pred_swizzle_y;
+      out[1].insn_predicate.SwizzleZ = pred_swizzle_z;
+      out[1].insn_predicate.SwizzleW = pred_swizzle_w;
+   }
+
    ureg->nr_instructions++;
-   
-   return ureg->domain[DOMAIN_INSN].count - 1;
+
+   return result;
 }
 
 
 void
 ureg_emit_label(struct ureg_program *ureg,
-                unsigned insn_token,
+                unsigned extended_token,
                 unsigned *label_token )
 {
    union tgsi_any_token *out, *insn;
@@ -667,13 +773,11 @@ ureg_emit_label(struct ureg_program *ureg,
       return;
 
    out = get_tokens( ureg, DOMAIN_INSN, 1 );
-   insn = retrieve_token( ureg, DOMAIN_INSN, insn_token );
+   out[0].value = 0;
 
-   insn->insn.Extended = 1;
+   insn = retrieve_token( ureg, DOMAIN_INSN, extended_token );
+   insn->insn.Label = 1;
 
-   out[0].value = 0;
-   out[0].insn_ext_label.Type = TGSI_INSTRUCTION_EXT_TYPE_LABEL;
-   
    *label_token = ureg->domain[DOMAIN_INSN].count - 1;
 }
 
@@ -696,26 +800,24 @@ ureg_fixup_label(struct ureg_program *ureg,
 {
    union tgsi_any_token *out = retrieve_token( ureg, DOMAIN_INSN, label_token );
 
-   assert(out->insn_ext_label.Type == TGSI_INSTRUCTION_EXT_TYPE_LABEL);
-   out->insn_ext_label.Label = instruction_number;
+   out->insn_label.Label = instruction_number;
 }
 
 
 void
 ureg_emit_texture(struct ureg_program *ureg,
-                  unsigned insn_token,
+                  unsigned extended_token,
                   unsigned target )
 {
    union tgsi_any_token *out, *insn;
 
    out = get_tokens( ureg, DOMAIN_INSN, 1 );
-   insn = retrieve_token( ureg, DOMAIN_INSN, insn_token );
+   insn = retrieve_token( ureg, DOMAIN_INSN, extended_token );
 
-   insn->insn.Extended = 1;
+   insn->insn.Texture = 1;
 
    out[0].value = 0;
-   out[0].insn_ext_texture.Type = TGSI_INSTRUCTION_EXT_TYPE_TEXTURE;
-   out[0].insn_ext_texture.Texture = target;
+   out[0].insn_texture.Texture = target;
 }
 
 
@@ -738,12 +840,34 @@ ureg_insn(struct ureg_program *ureg,
           const struct ureg_src *src,
           unsigned nr_src )
 {
-   unsigned insn, i;
+   struct ureg_emit_insn_result insn;
+   unsigned i;
    boolean saturate;
+   boolean predicate;
+   boolean negate = FALSE;
+   unsigned swizzle[4] = { 0 };
 
    saturate = nr_dst ? dst[0].Saturate : FALSE;
+   predicate = nr_dst ? dst[0].Predicate : FALSE;
+   if (predicate) {
+      negate = dst[0].PredNegate;
+      swizzle[0] = dst[0].PredSwizzleX;
+      swizzle[1] = dst[0].PredSwizzleY;
+      swizzle[2] = dst[0].PredSwizzleZ;
+      swizzle[3] = dst[0].PredSwizzleW;
+   }
 
-   insn = ureg_emit_insn( ureg, opcode, saturate, nr_dst, nr_src );
+   insn = ureg_emit_insn(ureg,
+                         opcode,
+                         saturate,
+                         predicate,
+                         negate,
+                         swizzle[0],
+                         swizzle[1],
+                         swizzle[2],
+                         swizzle[3],
+                         nr_dst,
+                         nr_src);
 
    for (i = 0; i < nr_dst; i++)
       ureg_emit_dst( ureg, dst[i] );
@@ -751,7 +875,7 @@ ureg_insn(struct ureg_program *ureg,
    for (i = 0; i < nr_src; i++)
       ureg_emit_src( ureg, src[i] );
 
-   ureg_fixup_insn_size( ureg, insn );
+   ureg_fixup_insn_size( ureg, insn.insn_token );
 }
 
 void
@@ -763,14 +887,36 @@ ureg_tex_insn(struct ureg_program *ureg,
               const struct ureg_src *src,
               unsigned nr_src )
 {
-   unsigned insn, i;
+   struct ureg_emit_insn_result insn;
+   unsigned i;
    boolean saturate;
+   boolean predicate;
+   boolean negate = FALSE;
+   unsigned swizzle[4] = { 0 };
 
    saturate = nr_dst ? dst[0].Saturate : FALSE;
+   predicate = nr_dst ? dst[0].Predicate : FALSE;
+   if (predicate) {
+      negate = dst[0].PredNegate;
+      swizzle[0] = dst[0].PredSwizzleX;
+      swizzle[1] = dst[0].PredSwizzleY;
+      swizzle[2] = dst[0].PredSwizzleZ;
+      swizzle[3] = dst[0].PredSwizzleW;
+   }
 
-   insn = ureg_emit_insn( ureg, opcode, saturate, nr_dst, nr_src );
+   insn = ureg_emit_insn(ureg,
+                         opcode,
+                         saturate,
+                         predicate,
+                         negate,
+                         swizzle[0],
+                         swizzle[1],
+                         swizzle[2],
+                         swizzle[3],
+                         nr_dst,
+                         nr_src);
 
-   ureg_emit_texture( ureg, insn, target );                             \
+   ureg_emit_texture( ureg, insn.extended_token, target );
 
    for (i = 0; i < nr_dst; i++)
       ureg_emit_dst( ureg, dst[i] );
@@ -778,7 +924,7 @@ ureg_tex_insn(struct ureg_program *ureg,
    for (i = 0; i < nr_src; i++)
       ureg_emit_src( ureg, src[i] );
 
-   ureg_fixup_insn_size( ureg, insn );
+   ureg_fixup_insn_size( ureg, insn.insn_token );
 }
 
 
@@ -789,16 +935,27 @@ ureg_label_insn(struct ureg_program *ureg,
                 unsigned nr_src,
                 unsigned *label_token )
 {
-   unsigned insn, i;
+   struct ureg_emit_insn_result insn;
+   unsigned i;
 
-   insn = ureg_emit_insn( ureg, opcode, FALSE, 0, nr_src );
+   insn = ureg_emit_insn(ureg,
+                         opcode,
+                         FALSE,
+                         FALSE,
+                         FALSE,
+                         TGSI_SWIZZLE_X,
+                         TGSI_SWIZZLE_Y,
+                         TGSI_SWIZZLE_Z,
+                         TGSI_SWIZZLE_W,
+                         0,
+                         nr_src);
 
-   ureg_emit_label( ureg, insn, label_token );                  \
+   ureg_emit_label( ureg, insn.extended_token, label_token );
 
    for (i = 0; i < nr_src; i++)
       ureg_emit_src( ureg, src[i] );
 
-   ureg_fixup_insn_size( ureg, insn );
+   ureg_fixup_insn_size( ureg, insn.insn_token );
 }
 
 
@@ -825,8 +982,8 @@ static void emit_decl( struct ureg_program *ureg,
       out[1].decl_range.Last = index;
 
    out[2].value = 0;
-   out[2].decl_semantic.SemanticName = semantic_name;
-   out[2].decl_semantic.SemanticIndex = semantic_index;
+   out[2].decl_semantic.Name = semantic_name;
+   out[2].decl_semantic.Index = semantic_index;
 
 }
 
@@ -851,22 +1008,23 @@ static void emit_decl_range( struct ureg_program *ureg,
    out[1].decl_range.Last = first + count - 1;
 }
 
-static void emit_immediate( struct ureg_program *ureg,
-                            const float *v )
+static void
+emit_immediate( struct ureg_program *ureg,
+                const unsigned *v,
+                unsigned type )
 {
    union tgsi_any_token *out = get_tokens( ureg, DOMAIN_DECL, 5 );
 
    out[0].value = 0;
    out[0].imm.Type = TGSI_TOKEN_TYPE_IMMEDIATE;
    out[0].imm.NrTokens = 5;
-   out[0].imm.DataType = TGSI_IMM_FLOAT32;
+   out[0].imm.DataType = type;
    out[0].imm.Padding = 0;
-   out[0].imm.Extended = 0;
 
-   out[1].imm_data.Float = v[0];
-   out[2].imm_data.Float = v[1];
-   out[3].imm_data.Float = v[2];
-   out[4].imm_data.Float = v[3];
+   out[1].imm_data.Uint = v[0];
+   out[2].imm_data.Uint = v[1];
+   out[3].imm_data.Uint = v[2];
+   out[4].imm_data.Uint = v[3];
 }
 
 
@@ -882,8 +1040,7 @@ static void emit_decls( struct ureg_program *ureg )
             emit_decl_range( ureg, TGSI_FILE_INPUT, i, 1 );
          }
       }
-   }
-   else {
+   } else if (ureg->processor == TGSI_PROCESSOR_FRAGMENT) {
       for (i = 0; i < ureg->nr_fs_inputs; i++) {
          emit_decl( ureg, 
                     TGSI_FILE_INPUT, 
@@ -892,6 +1049,13 @@ static void emit_decls( struct ureg_program *ureg )
                     ureg->fs_input[i].semantic_index,
                     ureg->fs_input[i].interp );
       }
+   } else {
+      for (i = 0; i < ureg->nr_gs_inputs; i++) {
+         emit_decl_range(ureg, 
+                         TGSI_FILE_INPUT, 
+                         ureg->gs_input[i].index,
+                         1);
+      }
    }
 
    for (i = 0; i < ureg->nr_outputs; i++) {
@@ -930,9 +1094,24 @@ static void emit_decls( struct ureg_program *ureg )
                        0, ureg->nr_addrs );
    }
 
+   if (ureg->nr_loops) {
+      emit_decl_range(ureg,
+                      TGSI_FILE_LOOP,
+                      0,
+                      ureg->nr_loops);
+   }
+
+   if (ureg->nr_preds) {
+      emit_decl_range(ureg,
+                      TGSI_FILE_PREDICATE,
+                      0,
+                      ureg->nr_preds);
+   }
+
    for (i = 0; i < ureg->nr_immediates; i++) {
       emit_immediate( ureg,
-                      ureg->immediate[i].v );
+                      ureg->immediate[i].value.u,
+                      ureg->immediate[i].type );
    }
 }
 
@@ -955,26 +1134,22 @@ static void copy_instructions( struct ureg_program *ureg )
 static void
 fixup_header_size(struct ureg_program *ureg)
 {
-   union tgsi_any_token *out = retrieve_token( ureg, DOMAIN_DECL, 1 );
+   union tgsi_any_token *out = retrieve_token( ureg, DOMAIN_DECL, 0 );
 
-   out->header.BodySize = ureg->domain[DOMAIN_DECL].count - 3;
+   out->header.BodySize = ureg->domain[DOMAIN_DECL].count - 2;
 }
 
 
 static void
 emit_header( struct ureg_program *ureg )
 {
-   union tgsi_any_token *out = get_tokens( ureg, DOMAIN_DECL, 3 );
-
-   out[0].version.MajorVersion = 1;
-   out[0].version.MinorVersion = 1;
-   out[0].version.Padding = 0;
+   union tgsi_any_token *out = get_tokens( ureg, DOMAIN_DECL, 2 );
 
-   out[1].header.HeaderSize = 2;
-   out[1].header.BodySize = 0;
+   out[0].header.HeaderSize = 2;
+   out[0].header.BodySize = 0;
 
-   out[2].processor.Processor = ureg->processor;
-   out[2].processor.Padding = 0;
+   out[1].processor.Processor = ureg->processor;
+   out[1].processor.Padding = 0;
 }
 
 
index f04f443b9e706e12eff90ee9221c3df9401d974d..6f11273320aa156391d3cdaf75c2c37cbc2c8d54 100644 (file)
@@ -67,9 +67,13 @@ struct ureg_dst
    unsigned WriteMask   : 4;  /* TGSI_WRITEMASK_ */
    unsigned Indirect    : 1;  /* BOOL */
    unsigned Saturate    : 1;  /* BOOL */
+   unsigned Predicate   : 1;
+   unsigned PredNegate  : 1;  /* BOOL */
+   unsigned PredSwizzleX: 2;  /* TGSI_SWIZZLE_ */
+   unsigned PredSwizzleY: 2;  /* TGSI_SWIZZLE_ */
+   unsigned PredSwizzleZ: 2;  /* TGSI_SWIZZLE_ */
+   unsigned PredSwizzleW: 2;  /* TGSI_SWIZZLE_ */
    int      Index       : 16; /* SINT */
-   unsigned Pad1        : 5;
-   unsigned Pad2        : 1;  /* BOOL */
    int      IndirectIndex   : 16; /* SINT */
    int      IndirectSwizzle : 2;  /* TGSI_SWIZZLE_ */
 };
@@ -129,6 +133,10 @@ struct ureg_src
 ureg_DECL_vs_input( struct ureg_program *,
                     unsigned index );
 
+struct ureg_src
+ureg_DECL_gs_input(struct ureg_program *,
+                   unsigned index);
+
 struct ureg_dst
 ureg_DECL_output( struct ureg_program *,
                   unsigned semantic_name,
@@ -139,6 +147,16 @@ ureg_DECL_immediate( struct ureg_program *,
                      const float *v,
                      unsigned nr );
 
+struct ureg_src
+ureg_DECL_immediate_uint( struct ureg_program *,
+                          const unsigned *v,
+                          unsigned nr );
+
+struct ureg_src
+ureg_DECL_immediate_int( struct ureg_program *,
+                         const int *v,
+                         unsigned nr );
+
 struct ureg_src
 ureg_DECL_constant( struct ureg_program *,
                     unsigned index );
@@ -153,6 +171,12 @@ ureg_release_temporary( struct ureg_program *ureg,
 struct ureg_dst
 ureg_DECL_address( struct ureg_program * );
 
+struct ureg_dst
+ureg_DECL_loop( struct ureg_program * );
+
+struct ureg_dst
+ureg_DECL_predicate(struct ureg_program *);
+
 /* Supply an index to the sampler declaration as this is the hook to
  * the external pipe_sampler state.  Users of this function probably
  * don't want just any sampler, but a specific one which they've set
@@ -207,6 +231,90 @@ ureg_imm1f( struct ureg_program *ureg,
    return ureg_DECL_immediate( ureg, v, 1 );
 }
 
+static INLINE struct ureg_src
+ureg_imm4u( struct ureg_program *ureg,
+            unsigned a, unsigned b,
+            unsigned c, unsigned d)
+{
+   unsigned v[4];
+   v[0] = a;
+   v[1] = b;
+   v[2] = c;
+   v[3] = d;
+   return ureg_DECL_immediate_uint( ureg, v, 4 );
+}
+
+static INLINE struct ureg_src
+ureg_imm3u( struct ureg_program *ureg,
+            unsigned a, unsigned b,
+            unsigned c)
+{
+   unsigned v[3];
+   v[0] = a;
+   v[1] = b;
+   v[2] = c;
+   return ureg_DECL_immediate_uint( ureg, v, 3 );
+}
+
+static INLINE struct ureg_src
+ureg_imm2u( struct ureg_program *ureg,
+            unsigned a, unsigned b)
+{
+   unsigned v[2];
+   v[0] = a;
+   v[1] = b;
+   return ureg_DECL_immediate_uint( ureg, v, 2 );
+}
+
+static INLINE struct ureg_src
+ureg_imm1u( struct ureg_program *ureg,
+            unsigned a)
+{
+   return ureg_DECL_immediate_uint( ureg, &a, 1 );
+}
+
+static INLINE struct ureg_src
+ureg_imm4i( struct ureg_program *ureg,
+            int a, int b,
+            int c, int d)
+{
+   int v[4];
+   v[0] = a;
+   v[1] = b;
+   v[2] = c;
+   v[3] = d;
+   return ureg_DECL_immediate_int( ureg, v, 4 );
+}
+
+static INLINE struct ureg_src
+ureg_imm3i( struct ureg_program *ureg,
+            int a, int b,
+            int c)
+{
+   int v[3];
+   v[0] = a;
+   v[1] = b;
+   v[2] = c;
+   return ureg_DECL_immediate_int( ureg, v, 3 );
+}
+
+static INLINE struct ureg_src
+ureg_imm2i( struct ureg_program *ureg,
+            int a, int b)
+{
+   int v[2];
+   v[0] = a;
+   v[1] = b;
+   return ureg_DECL_immediate_int( ureg, v, 2 );
+}
+
+static INLINE struct ureg_src
+ureg_imm1i( struct ureg_program *ureg,
+            int a)
+{
+   return ureg_DECL_immediate_int( ureg, &a, 1 );
+}
+
 /***********************************************************************
  * Functions for patching up labels
  */
@@ -266,10 +374,21 @@ ureg_label_insn(struct ureg_program *ureg,
  * Internal instruction helpers, don't call these directly:
  */
 
-unsigned
+struct ureg_emit_insn_result {
+   unsigned insn_token;       /*< Used to fixup insn size. */
+   unsigned extended_token;   /*< Used to set the Extended bit, usually the same as insn_token. */
+};
+
+struct ureg_emit_insn_result
 ureg_emit_insn(struct ureg_program *ureg,
                unsigned opcode,
                boolean saturate,
+               boolean predicate,
+               boolean pred_negate,
+               unsigned pred_swizzle_x,
+               unsigned pred_swizzle_y,
+               unsigned pred_swizzle_z,
+               unsigned pred_swizzle_w,
                unsigned num_dst,
                unsigned num_src );
 
@@ -300,7 +419,17 @@ ureg_fixup_insn_size(struct ureg_program *ureg,
 static INLINE void ureg_##op( struct ureg_program *ureg )       \
 {                                                               \
    unsigned opcode = TGSI_OPCODE_##op;                          \
-   unsigned insn = ureg_emit_insn( ureg, opcode, FALSE, 0, 0 ); \
+   unsigned insn = ureg_emit_insn(ureg,                         \
+                                  opcode,                       \
+                                  FALSE,                        \
+                                  FALSE,                        \
+                                  FALSE,                        \
+                                  TGSI_SWIZZLE_X,               \
+                                  TGSI_SWIZZLE_Y,               \
+                                  TGSI_SWIZZLE_Z,               \
+                                  TGSI_SWIZZLE_W,               \
+                                  0,                            \
+                                  0).insn_token;                \
    ureg_fixup_insn_size( ureg, insn );                          \
 }
 
@@ -309,7 +438,17 @@ static INLINE void ureg_##op( struct ureg_program *ureg,        \
                               struct ureg_src src )             \
 {                                                               \
    unsigned opcode = TGSI_OPCODE_##op;                          \
-   unsigned insn = ureg_emit_insn( ureg, opcode, FALSE, 0, 1 ); \
+   unsigned insn = ureg_emit_insn(ureg,                         \
+                                  opcode,                       \
+                                  FALSE,                        \
+                                  FALSE,                        \
+                                  FALSE,                        \
+                                  TGSI_SWIZZLE_X,               \
+                                  TGSI_SWIZZLE_Y,               \
+                                  TGSI_SWIZZLE_Z,               \
+                                  TGSI_SWIZZLE_W,               \
+                                  0,                            \
+                                  1).insn_token;                \
    ureg_emit_src( ureg, src );                                  \
    ureg_fixup_insn_size( ureg, insn );                          \
 }
@@ -319,9 +458,20 @@ static INLINE void ureg_##op( struct ureg_program *ureg,        \
                               unsigned *label_token )           \
 {                                                               \
    unsigned opcode = TGSI_OPCODE_##op;                          \
-   unsigned insn = ureg_emit_insn( ureg, opcode, FALSE, 0, 0 ); \
-   ureg_emit_label( ureg, insn, label_token );                  \
-   ureg_fixup_insn_size( ureg, insn );                          \
+   struct ureg_emit_insn_result insn;                           \
+   insn = ureg_emit_insn(ureg,                                  \
+                         opcode,                                \
+                         FALSE,                                 \
+                         FALSE,                                 \
+                         FALSE,                                 \
+                         TGSI_SWIZZLE_X,                        \
+                         TGSI_SWIZZLE_Y,                        \
+                         TGSI_SWIZZLE_Z,                        \
+                         TGSI_SWIZZLE_W,                        \
+                         0,                                     \
+                         0);                                    \
+   ureg_emit_label( ureg, insn.extended_token, label_token );   \
+   ureg_fixup_insn_size( ureg, insn.insn_token );               \
 }
 
 #define OP01_LBL( op )                                          \
@@ -330,10 +480,21 @@ static INLINE void ureg_##op( struct ureg_program *ureg,        \
                               unsigned *label_token )          \
 {                                                               \
    unsigned opcode = TGSI_OPCODE_##op;                          \
-   unsigned insn = ureg_emit_insn( ureg, opcode, FALSE, 0, 1 ); \
-   ureg_emit_label( ureg, insn, label_token );                  \
+   struct ureg_emit_insn_result insn;                           \
+   insn = ureg_emit_insn(ureg,                                  \
+                         opcode,                                \
+                         FALSE,                                 \
+                         FALSE,                                 \
+                         FALSE,                                 \
+                         TGSI_SWIZZLE_X,                        \
+                         TGSI_SWIZZLE_Y,                        \
+                         TGSI_SWIZZLE_Z,                        \
+                         TGSI_SWIZZLE_W,                        \
+                         0,                                     \
+                         1);                                    \
+   ureg_emit_label( ureg, insn.extended_token, label_token );   \
    ureg_emit_src( ureg, src );                                  \
-   ureg_fixup_insn_size( ureg, insn );                          \
+   ureg_fixup_insn_size( ureg, insn.insn_token );               \
 }
 
 #define OP10( op )                                                      \
@@ -341,7 +502,17 @@ static INLINE void ureg_##op( struct ureg_program *ureg,                \
                               struct ureg_dst dst )                     \
 {                                                                       \
    unsigned opcode = TGSI_OPCODE_##op;                                  \
-   unsigned insn = ureg_emit_insn( ureg, opcode, dst.Saturate, 1, 0 );  \
+   unsigned insn = ureg_emit_insn(ureg,                                 \
+                                  opcode,                               \
+                                  dst.Saturate,                         \
+                                  dst.Predicate,                        \
+                                  dst.PredNegate,                       \
+                                  dst.PredSwizzleX,                     \
+                                  dst.PredSwizzleY,                     \
+                                  dst.PredSwizzleZ,                     \
+                                  dst.PredSwizzleW,                     \
+                                  1,                                    \
+                                  0).insn_token;                        \
    ureg_emit_dst( ureg, dst );                                          \
    ureg_fixup_insn_size( ureg, insn );                                  \
 }
@@ -353,7 +524,17 @@ static INLINE void ureg_##op( struct ureg_program *ureg,                \
                               struct ureg_src src )                     \
 {                                                                       \
    unsigned opcode = TGSI_OPCODE_##op;                                  \
-   unsigned insn = ureg_emit_insn( ureg, opcode, dst.Saturate, 1, 1 );  \
+   unsigned insn = ureg_emit_insn(ureg,                                 \
+                                  opcode,                               \
+                                  dst.Saturate,                         \
+                                  dst.Predicate,                        \
+                                  dst.PredNegate,                       \
+                                  dst.PredSwizzleX,                     \
+                                  dst.PredSwizzleY,                     \
+                                  dst.PredSwizzleZ,                     \
+                                  dst.PredSwizzleW,                     \
+                                  1,                                    \
+                                  1).insn_token;                        \
    ureg_emit_dst( ureg, dst );                                          \
    ureg_emit_src( ureg, src );                                          \
    ureg_fixup_insn_size( ureg, insn );                                  \
@@ -366,7 +547,17 @@ static INLINE void ureg_##op( struct ureg_program *ureg,                \
                               struct ureg_src src1 )                    \
 {                                                                       \
    unsigned opcode = TGSI_OPCODE_##op;                                  \
-   unsigned insn = ureg_emit_insn( ureg, opcode, dst.Saturate, 1, 2 );  \
+   unsigned insn = ureg_emit_insn(ureg,                                 \
+                                  opcode,                               \
+                                  dst.Saturate,                         \
+                                  dst.Predicate,                        \
+                                  dst.PredNegate,                       \
+                                  dst.PredSwizzleX,                     \
+                                  dst.PredSwizzleY,                     \
+                                  dst.PredSwizzleZ,                     \
+                                  dst.PredSwizzleW,                     \
+                                  1,                                    \
+                                  2).insn_token;                        \
    ureg_emit_dst( ureg, dst );                                          \
    ureg_emit_src( ureg, src0 );                                         \
    ureg_emit_src( ureg, src1 );                                         \
@@ -381,12 +572,23 @@ static INLINE void ureg_##op( struct ureg_program *ureg,                \
                               struct ureg_src src1 )                    \
 {                                                                       \
    unsigned opcode = TGSI_OPCODE_##op;                                  \
-   unsigned insn = ureg_emit_insn( ureg, opcode, dst.Saturate, 1, 2 );  \
-   ureg_emit_texture( ureg, insn, target );                             \
+   struct ureg_emit_insn_result insn;                                   \
+   insn = ureg_emit_insn(ureg,                                          \
+                         opcode,                                        \
+                         dst.Saturate,                                  \
+                         dst.Predicate,                                 \
+                         dst.PredNegate,                                \
+                         dst.PredSwizzleX,                              \
+                         dst.PredSwizzleY,                              \
+                         dst.PredSwizzleZ,                              \
+                         dst.PredSwizzleW,                              \
+                         1,                                             \
+                         2);                                            \
+   ureg_emit_texture( ureg, insn.extended_token, target );              \
    ureg_emit_dst( ureg, dst );                                          \
    ureg_emit_src( ureg, src0 );                                         \
    ureg_emit_src( ureg, src1 );                                         \
-   ureg_fixup_insn_size( ureg, insn );                                  \
+   ureg_fixup_insn_size( ureg, insn.insn_token );                       \
 }
 
 #define OP13( op )                                                      \
@@ -397,7 +599,17 @@ static INLINE void ureg_##op( struct ureg_program *ureg,                \
                               struct ureg_src src2 )                    \
 {                                                                       \
    unsigned opcode = TGSI_OPCODE_##op;                                  \
-   unsigned insn = ureg_emit_insn( ureg, opcode, dst.Saturate, 1, 3 );  \
+   unsigned insn = ureg_emit_insn(ureg,                                 \
+                                  opcode,                               \
+                                  dst.Saturate,                         \
+                                  dst.Predicate,                        \
+                                  dst.PredNegate,                       \
+                                  dst.PredSwizzleX,                     \
+                                  dst.PredSwizzleY,                     \
+                                  dst.PredSwizzleZ,                     \
+                                  dst.PredSwizzleW,                     \
+                                  1,                                    \
+                                  3).insn_token;                        \
    ureg_emit_dst( ureg, dst );                                          \
    ureg_emit_src( ureg, src0 );                                         \
    ureg_emit_src( ureg, src1 );                                         \
@@ -415,14 +627,25 @@ static INLINE void ureg_##op( struct ureg_program *ureg,                \
                               struct ureg_src src3 )                    \
 {                                                                       \
    unsigned opcode = TGSI_OPCODE_##op;                                  \
-   unsigned insn = ureg_emit_insn( ureg, opcode, dst.Saturate, 1, 4 );  \
-   ureg_emit_texture( ureg, insn, target );                             \
+   struct ureg_emit_insn_result insn;                                   \
+   insn = ureg_emit_insn(ureg,                                          \
+                         opcode,                                        \
+                         dst.Saturate,                                  \
+                         dst.Predicate,                                 \
+                         dst.PredNegate,                                \
+                         dst.PredSwizzleX,                              \
+                         dst.PredSwizzleY,                              \
+                         dst.PredSwizzleZ,                              \
+                         dst.PredSwizzleW,                              \
+                         1,                                             \
+                         4);                                            \
+   ureg_emit_texture( ureg, insn.extended_token, target );              \
    ureg_emit_dst( ureg, dst );                                          \
    ureg_emit_src( ureg, src0 );                                         \
    ureg_emit_src( ureg, src1 );                                         \
    ureg_emit_src( ureg, src2 );                                         \
    ureg_emit_src( ureg, src3 );                                         \
-   ureg_fixup_insn_size( ureg, insn );                                  \
+   ureg_fixup_insn_size( ureg, insn.insn_token );                       \
 }
 
 
@@ -497,6 +720,24 @@ ureg_saturate( struct ureg_dst reg )
    return reg;
 }
 
+static INLINE struct ureg_dst
+ureg_predicate(struct ureg_dst reg,
+               boolean negate,
+               unsigned swizzle_x,
+               unsigned swizzle_y,
+               unsigned swizzle_z,
+               unsigned swizzle_w)
+{
+   assert(reg.File != TGSI_FILE_NULL);
+   reg.Predicate = 1;
+   reg.PredNegate = negate;
+   reg.PredSwizzleX = swizzle_x;
+   reg.PredSwizzleY = swizzle_y;
+   reg.PredSwizzleZ = swizzle_z;
+   reg.PredSwizzleW = swizzle_w;
+   return reg;
+}
+
 static INLINE struct ureg_dst 
 ureg_dst_indirect( struct ureg_dst reg, struct ureg_src addr )
 {
@@ -530,9 +771,13 @@ ureg_dst( struct ureg_src src )
    dst.IndirectIndex = src.IndirectIndex;
    dst.IndirectSwizzle = src.IndirectSwizzle;
    dst.Saturate  = 0;
+   dst.Predicate = 0;
+   dst.PredNegate = 0;
+   dst.PredSwizzleX = TGSI_SWIZZLE_X;
+   dst.PredSwizzleY = TGSI_SWIZZLE_Y;
+   dst.PredSwizzleZ = TGSI_SWIZZLE_Z;
+   dst.PredSwizzleW = TGSI_SWIZZLE_W;
    dst.Index     = src.Index;
-   dst.Pad1      = 0;
-   dst.Pad2      = 0;
 
    return dst;
 }
@@ -571,9 +816,13 @@ ureg_dst_undef( void )
    dst.IndirectIndex = 0;
    dst.IndirectSwizzle = 0;
    dst.Saturate  = 0;
+   dst.Predicate = 0;
+   dst.PredNegate = 0;
+   dst.PredSwizzleX = TGSI_SWIZZLE_X;
+   dst.PredSwizzleY = TGSI_SWIZZLE_Y;
+   dst.PredSwizzleZ = TGSI_SWIZZLE_Z;
+   dst.PredSwizzleW = TGSI_SWIZZLE_W;
    dst.Index     = 0;
-   dst.Pad1      = 0;
-   dst.Pad2      = 0;
 
    return dst;
 }
index 71f8a6ca401262e6e92149c685e2b32bd3f27976..f4ca9e21ed95cc7686cd34e2f00465ea00525991 100644 (file)
@@ -69,59 +69,15 @@ tgsi_util_get_src_register_swizzle(
    return 0;
 }
 
-unsigned
-tgsi_util_get_src_register_extswizzle(
-   const struct tgsi_src_register_ext_swz *reg,
-   unsigned component )
-{
-   switch( component ) {
-   case 0:
-      return reg->ExtSwizzleX;
-   case 1:
-      return reg->ExtSwizzleY;
-   case 2:
-      return reg->ExtSwizzleZ;
-   case 3:
-      return reg->ExtSwizzleW;
-   default:
-      assert( 0 );
-   }
-   return 0;
-}
 
 unsigned
-tgsi_util_get_full_src_register_extswizzle(
+tgsi_util_get_full_src_register_swizzle(
    const struct tgsi_full_src_register  *reg,
    unsigned component )
 {
-   unsigned swizzle;
-
-   /*
-    * First, calculate  the   extended swizzle for a given channel. This will give
-    * us either a channel index into the simple swizzle or  a constant 1 or   0.
-    */
-   swizzle = tgsi_util_get_src_register_extswizzle(
-      &reg->SrcRegisterExtSwz,
+   return tgsi_util_get_src_register_swizzle(
+      &reg->Register,
       component );
-
-   assert (TGSI_SWIZZLE_X == TGSI_EXTSWIZZLE_X);
-   assert (TGSI_SWIZZLE_Y == TGSI_EXTSWIZZLE_Y);
-   assert (TGSI_SWIZZLE_Z == TGSI_EXTSWIZZLE_Z);
-   assert (TGSI_SWIZZLE_W == TGSI_EXTSWIZZLE_W);
-   assert (TGSI_EXTSWIZZLE_ZERO > TGSI_SWIZZLE_W);
-   assert (TGSI_EXTSWIZZLE_ONE > TGSI_SWIZZLE_W);
-
-   /*
-    * Second, calculate the simple  swizzle  for   the   unswizzled channel index.
-    * Leave the constants intact, they are   not   affected by the   simple swizzle.
-    */
-   if( swizzle <= TGSI_SWIZZLE_W ) {
-      swizzle = tgsi_util_get_src_register_swizzle(
-         &reg->SrcRegister,
-         swizzle );
-   }
-
-   return swizzle;
 }
 
 void
@@ -148,74 +104,6 @@ tgsi_util_set_src_register_swizzle(
    }
 }
 
-void
-tgsi_util_set_src_register_extswizzle(
-   struct tgsi_src_register_ext_swz *reg,
-   unsigned swizzle,
-   unsigned component )
-{
-   switch( component ) {
-   case 0:
-      reg->ExtSwizzleX = swizzle;
-      break;
-   case 1:
-      reg->ExtSwizzleY = swizzle;
-      break;
-   case 2:
-      reg->ExtSwizzleZ = swizzle;
-      break;
-   case 3:
-      reg->ExtSwizzleW = swizzle;
-      break;
-   default:
-      assert( 0 );
-   }
-}
-
-unsigned
-tgsi_util_get_src_register_extnegate(
-   const  struct tgsi_src_register_ext_swz *reg,
-   unsigned component )
-{
-   switch( component ) {
-   case 0:
-      return reg->NegateX;
-   case 1:
-      return reg->NegateY;
-   case 2:
-      return reg->NegateZ;
-   case 3:
-      return reg->NegateW;
-   default:
-      assert( 0 );
-   }
-   return 0;
-}
-
-void
-tgsi_util_set_src_register_extnegate(
-   struct tgsi_src_register_ext_swz *reg,
-   unsigned negate,
-   unsigned component )
-{
-   switch( component ) {
-   case 0:
-      reg->NegateX = negate;
-      break;
-   case 1:
-      reg->NegateY = negate;
-      break;
-   case 2:
-      reg->NegateZ = negate;
-      break;
-   case 3:
-      reg->NegateW = negate;
-      break;
-   default:
-      assert( 0 );
-   }
-}
-
 unsigned
 tgsi_util_get_full_src_register_sign_mode(
    const struct  tgsi_full_src_register *reg,
@@ -223,10 +111,10 @@ tgsi_util_get_full_src_register_sign_mode(
 {
    unsigned sign_mode;
 
-   if( reg->SrcRegisterExtMod.Absolute ) {
+   if( reg->Register.Absolute ) {
       /* Consider only the post-abs negation. */
 
-      if( reg->SrcRegisterExtMod.Negate ) {
+      if( reg->Register.Negate ) {
          sign_mode = TGSI_UTIL_SIGN_SET;
       }
       else {
@@ -234,19 +122,7 @@ tgsi_util_get_full_src_register_sign_mode(
       }
    }
    else {
-      /* Accumulate the three negations. */
-
-      unsigned negate;
-
-      negate = reg->SrcRegister.Negate;
-      if( tgsi_util_get_src_register_extnegate( &reg->SrcRegisterExtSwz, component ) ) {
-         negate = !negate;
-      }
-      if( reg->SrcRegisterExtMod.Negate ) {
-         negate = !negate;
-      }
-
-      if( negate ) {
+      if( reg->Register.Negate ) {
          sign_mode = TGSI_UTIL_SIGN_TOGGLE;
       }
       else {
@@ -262,35 +138,26 @@ tgsi_util_set_full_src_register_sign_mode(
    struct tgsi_full_src_register *reg,
    unsigned sign_mode )
 {
-   reg->SrcRegisterExtSwz.NegateX = 0;
-   reg->SrcRegisterExtSwz.NegateY = 0;
-   reg->SrcRegisterExtSwz.NegateZ = 0;
-   reg->SrcRegisterExtSwz.NegateW = 0;
-
    switch (sign_mode)
    {
    case TGSI_UTIL_SIGN_CLEAR:
-      reg->SrcRegister.Negate = 0;
-      reg->SrcRegisterExtMod.Absolute = 1;
-      reg->SrcRegisterExtMod.Negate = 0;
+      reg->Register.Negate = 0;
+      reg->Register.Absolute = 1;
       break;
 
    case TGSI_UTIL_SIGN_SET:
-      reg->SrcRegister.Negate = 0;
-      reg->SrcRegisterExtMod.Absolute = 1;
-      reg->SrcRegisterExtMod.Negate = 1;
+      reg->Register.Absolute = 1;
+      reg->Register.Negate = 1;
       break;
 
    case TGSI_UTIL_SIGN_TOGGLE:
-      reg->SrcRegister.Negate = 1;
-      reg->SrcRegisterExtMod.Absolute = 0;
-      reg->SrcRegisterExtMod.Negate = 0;
+      reg->Register.Negate = 1;
+      reg->Register.Absolute = 0;
       break;
 
    case TGSI_UTIL_SIGN_KEEP:
-      reg->SrcRegister.Negate = 0;
-      reg->SrcRegisterExtMod.Absolute = 0;
-      reg->SrcRegisterExtMod.Negate = 0;
+      reg->Register.Negate = 0;
+      reg->Register.Absolute = 0;
       break;
 
    default:
index 21eb656327ecebfc75d4ee1ee428980ac2c9d1a8..19ee2e7cf2a024ae854e13e3ed8084635b95f3b7 100644 (file)
@@ -33,7 +33,6 @@ extern "C" {
 #endif
 
 struct tgsi_src_register;
-struct tgsi_src_register_ext_swz;
 struct tgsi_full_src_register;
 
 void *
@@ -45,13 +44,9 @@ tgsi_util_get_src_register_swizzle(
    const struct tgsi_src_register *reg,
    unsigned component );
 
-unsigned
-tgsi_util_get_src_register_extswizzle(
-   const struct tgsi_src_register_ext_swz *reg,
-   unsigned component);
 
 unsigned
-tgsi_util_get_full_src_register_extswizzle(
+tgsi_util_get_full_src_register_swizzle(
    const struct tgsi_full_src_register *reg,
    unsigned component );
 
@@ -61,23 +56,6 @@ tgsi_util_set_src_register_swizzle(
    unsigned swizzle,
    unsigned component );
 
-void
-tgsi_util_set_src_register_extswizzle(
-   struct tgsi_src_register_ext_swz *reg,
-   unsigned swizzle,
-   unsigned component );
-
-unsigned
-tgsi_util_get_src_register_extnegate(
-   const struct tgsi_src_register_ext_swz *reg,
-   unsigned component );
-
-void
-tgsi_util_set_src_register_extnegate(
-   struct tgsi_src_register_ext_swz *reg,
-   unsigned negate,
-   unsigned component );
-
 #define TGSI_UTIL_SIGN_CLEAR    0   /* Force positive */
 #define TGSI_UTIL_SIGN_SET      1   /* Force negative */
 #define TGSI_UTIL_SIGN_TOGGLE   2   /* Negate */
diff --git a/src/gallium/auxiliary/translate/Makefile b/src/gallium/auxiliary/translate/Makefile
deleted file mode 100644 (file)
index 3c82f8a..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = translate
-
-C_SOURCES = \
-       translate_generic.c \
-       translate_sse.c \
-       translate.c \
-        translate_cache.c
-
-include ../../Makefile.template
diff --git a/src/gallium/auxiliary/translate/SConscript b/src/gallium/auxiliary/translate/SConscript
deleted file mode 100644 (file)
index 9553a67..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-Import('*')
-
-translate = env.ConvenienceLibrary(
-       target = 'translate',
-       source = [
-               'translate_generic.c',
-               'translate_sse.c',
-               'translate.c',
-               'translate_cache.c',
-       ])
-
-auxiliaries.insert(0, translate)
diff --git a/src/gallium/auxiliary/util/Makefile b/src/gallium/auxiliary/util/Makefile
deleted file mode 100644 (file)
index 1d8bb55..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = util
-
-C_SOURCES = \
-       u_debug.c \
-       u_debug_dump.c \
-       u_debug_symbol.c \
-       u_debug_stack.c \
-       u_blit.c \
-       u_cache.c \
-       u_cpu_detect.c \
-       u_draw_quad.c \
-       u_format.c \
-       u_format_access.c \
-       u_format_table.c \
-       u_gen_mipmap.c \
-       u_handle_table.c \
-       u_hash_table.c \
-       u_hash.c \
-       u_keymap.c \
-       u_linear.c \
-       u_network.c \
-       u_math.c \
-       u_mm.c \
-       u_rect.c \
-       u_simple_shaders.c \
-       u_snprintf.c \
-       u_stream_stdc.c \
-       u_stream_wd.c \
-       u_surface.c \
-       u_tile.c \
-       u_time.c \
-       u_timed_winsys.c \
-       u_upload_mgr.c \
-       u_simple_screen.c
-
-include ../../Makefile.template
-
-u_format_table.c: u_format_table.py u_format_parse.py u_format.csv
-       python u_format_table.py u_format.csv > $@
-
-u_format_access.c: u_format_access.py u_format_parse.py u_format.csv
-       python u_format_access.py u_format.csv > $@
diff --git a/src/gallium/auxiliary/util/SConscript b/src/gallium/auxiliary/util/SConscript
deleted file mode 100644 (file)
index 2187935..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-Import('*')
-
-env.Clone()
-
-env.Append(CPPPATH = ['.'])
-
-env.CodeGenerate(
-       target = 'u_format_table.c',
-       script = 'u_format_table.py',
-       source = ['u_format.csv'],
-       command = 'python $SCRIPT $SOURCE > $TARGET'
-)
-
-env.CodeGenerate(
-       target = 'u_format_access.c',
-       script = 'u_format_access.py',
-       source = ['u_format.csv'],
-       command = 'python $SCRIPT $SOURCE > $TARGET'
-)
-
-util = env.ConvenienceLibrary(
-       target = 'util',
-       source = [
-               'u_bitmask.c',
-               'u_blit.c',
-               'u_cache.c',
-               'u_cpu_detect.c',
-               'u_debug.c',
-               'u_debug_dump.c',
-               'u_debug_memory.c',
-               'u_debug_profile.c',
-               'u_debug_stack.c',
-               'u_debug_symbol.c',
-               'u_draw_quad.c',
-               'u_format.c',
-               'u_format_access.c',
-               'u_format_table.c',
-               'u_gen_mipmap.c',
-               'u_handle_table.c',
-               'u_hash.c',
-               'u_hash_table.c',
-               'u_keymap.c',
-               'u_network.c',
-               'u_math.c',
-               'u_mm.c',
-               'u_rect.c',
-               'u_simple_shaders.c',
-               'u_snprintf.c',
-               'u_stream_stdc.c',
-               'u_stream_wd.c',
-               'u_surface.c',
-               'u_tile.c',
-               'u_time.c',
-               'u_timed_winsys.c',
-               'u_upload_mgr.c',
-               'u_simple_screen.c',
-       ])
-
-auxiliaries.insert(0, util)
index 77587c07ec0d508344e422517664f349f03d4bd1..23c93a3ebcb987c86a11e490b542ef9634253e86 100644 (file)
@@ -97,12 +97,12 @@ util_bitmask_resize(struct util_bitmask *bm,
    if(!minimum_size)
       return FALSE;
       
-   if(bm->size > minimum_size)
+   if(bm->size >= minimum_size)
       return TRUE;
 
    assert(bm->size % UTIL_BITMASK_BITS_PER_WORD == 0);
    new_size = bm->size;
-   while(!(new_size > minimum_size)) {
+   while(new_size < minimum_size) {
       new_size *= 2;
       /* Check integer overflow */
       if(new_size < bm->size)
@@ -136,7 +136,7 @@ util_bitmask_filled_set(struct util_bitmask *bm,
                         unsigned index)
 {
    assert(bm->filled <= bm->size);
-   assert(index <= bm->size);
+   assert(index < bm->size);
    
    if(index == bm->filled) {
       ++bm->filled;
@@ -149,7 +149,7 @@ util_bitmask_filled_unset(struct util_bitmask *bm,
                           unsigned index)
 {
    assert(bm->filled <= bm->size);
-   assert(index <= bm->size);
+   assert(index < bm->size);
    
    if(index < bm->filled)
       bm->filled = index;
@@ -182,7 +182,7 @@ util_bitmask_add(struct util_bitmask *bm)
       mask = 1;
    }
 found:
-   
+
    /* grow the bitmask if necessary */
    if(!util_bitmask_resize(bm, bm->filled))
       return UTIL_BITMASK_INVALID_INDEX;
@@ -198,9 +198,9 @@ unsigned
 util_bitmask_set(struct util_bitmask *bm, 
                  unsigned index)
 {
-   unsigned word = index / UTIL_BITMASK_BITS_PER_WORD;
-   unsigned bit  = index % UTIL_BITMASK_BITS_PER_WORD;
-   util_bitmask_word mask = 1 << bit;
+   unsigned word;
+   unsigned bit;
+   util_bitmask_word mask;
    
    assert(bm);
    
@@ -208,6 +208,10 @@ util_bitmask_set(struct util_bitmask *bm,
    if(!util_bitmask_resize(bm, index))
       return UTIL_BITMASK_INVALID_INDEX;
 
+   word = index / UTIL_BITMASK_BITS_PER_WORD;
+   bit  = index % UTIL_BITMASK_BITS_PER_WORD;
+   mask = 1 << bit;
+
    bm->words[word] |= mask;
 
    util_bitmask_filled_set(bm, index);
@@ -220,15 +224,19 @@ void
 util_bitmask_clear(struct util_bitmask *bm, 
                    unsigned index)
 {
-   unsigned word = index / UTIL_BITMASK_BITS_PER_WORD;
-   unsigned bit  = index % UTIL_BITMASK_BITS_PER_WORD;
-   util_bitmask_word mask = 1 << bit;
+   unsigned word;
+   unsigned bit;
+   util_bitmask_word mask;
    
    assert(bm);
    
    if(index >= bm->size)
       return;
 
+   word = index / UTIL_BITMASK_BITS_PER_WORD;
+   bit  = index % UTIL_BITMASK_BITS_PER_WORD;
+   mask = 1 << bit;
+
    bm->words[word] &= ~mask;
    
    util_bitmask_filled_unset(bm, index);
@@ -250,7 +258,7 @@ util_bitmask_get(struct util_bitmask *bm,
       return TRUE;
    }
 
-   if(index > bm->size)
+   if(index >= bm->size)
       return FALSE;
 
    if(bm->words[word] & mask) {
index fb00c3abe8bfebd6462f1bd6af86909219031d8e..3f74e2aa8b803a45a9637255287fdbc260045e5f 100644 (file)
 
 #include "util/u_blit.h"
 #include "util/u_draw_quad.h"
+#include "util/u_format.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
 #include "util/u_simple_shaders.h"
 #include "util/u_surface.h"
+#include "util/u_rect.h"
 
 #include "cso_cache/cso_context.h"
 
@@ -125,7 +127,8 @@ util_create_blit(struct pipe_context *pipe, struct cso_context *cso)
    }
 
    /* fragment shader */
-   ctx->fs[TGSI_WRITEMASK_XYZW] = util_make_fragment_tex_shader(pipe);
+   ctx->fs[TGSI_WRITEMASK_XYZW] =
+      util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_2D);
    ctx->vbuf = NULL;
 
    /* init vertex data that doesn't change */
@@ -301,7 +304,8 @@ util_blit_pixels_writemask(struct blit_state *ctx,
     * no overlapping.
     * Filter mode should not matter since there's no stretching.
     */
-   if (dst->format == src->format &&
+   if (pipe->surface_copy &&
+       dst->format == src->format &&
        srcX0 < srcX1 &&
        dstX0 < dstX1 &&
        srcY0 < srcY1 &&
@@ -352,10 +356,9 @@ util_blit_pixels_writemask(struct blit_state *ctx,
       texTemp.target = PIPE_TEXTURE_2D;
       texTemp.format = src->format;
       texTemp.last_level = 0;
-      texTemp.width[0] = srcW;
-      texTemp.height[0] = srcH;
-      texTemp.depth[0] = 1;
-      pf_get_block(src->format, &texTemp.block);
+      texTemp.width0 = srcW;
+      texTemp.height0 = srcH;
+      texTemp.depth0 = 1;
 
       tex = screen->texture_create(screen, &texTemp);
       if (!tex)
@@ -365,10 +368,17 @@ util_blit_pixels_writemask(struct blit_state *ctx,
                                         PIPE_BUFFER_USAGE_GPU_WRITE);
 
       /* load temp texture */
-      pipe->surface_copy(pipe,
-                         texSurf, 0, 0,   /* dest */
-                         src, srcLeft, srcTop, /* src */
-                         srcW, srcH);     /* size */
+      if (pipe->surface_copy) {
+         pipe->surface_copy(pipe,
+                            texSurf, 0, 0,   /* dest */
+                            src, srcLeft, srcTop, /* src */
+                            srcW, srcH);     /* size */
+      } else {
+         util_surface_copy(pipe, FALSE,
+                           texSurf, 0, 0,   /* dest */
+                           src, srcLeft, srcTop, /* src */
+                           srcW, srcH);     /* size */
+      }
 
       /* free the surface, update the texture if necessary.
        */
@@ -380,10 +390,10 @@ util_blit_pixels_writemask(struct blit_state *ctx,
    }
    else {
       pipe_texture_reference(&tex, src->texture);
-      s0 = srcX0 / (float)tex->width[0];
-      s1 = srcX1 / (float)tex->width[0];
-      t0 = srcY0 / (float)tex->height[0];
-      t1 = srcY1 / (float)tex->height[0];
+      s0 = srcX0 / (float)tex->width0;
+      s1 = srcX1 / (float)tex->width0;
+      t0 = srcY0 / (float)tex->height0;
+      t1 = srcY1 / (float)tex->height0;
    }
 
 
@@ -412,7 +422,9 @@ util_blit_pixels_writemask(struct blit_state *ctx,
    cso_set_sampler_textures(ctx->cso, 1, &tex);
 
    if (ctx->fs[writemask] == NULL)
-      ctx->fs[writemask] = util_make_fragment_tex_shader_writemask(pipe, writemask);
+      ctx->fs[writemask] =
+         util_make_fragment_tex_shader_writemask(pipe, TGSI_TEXTURE_2D,
+                                                 writemask);
 
    /* shaders */
    cso_set_fragment_shader_handle(ctx->cso, ctx->fs[writemask]);
@@ -509,13 +521,13 @@ util_blit_pixels_tex(struct blit_state *ctx,
    assert(filter == PIPE_TEX_MIPFILTER_NEAREST ||
           filter == PIPE_TEX_MIPFILTER_LINEAR);
 
-   assert(tex->width[0] != 0);
-   assert(tex->height[0] != 0);
+   assert(tex->width0 != 0);
+   assert(tex->height0 != 0);
 
-   s0 = srcX0 / (float)tex->width[0];
-   s1 = srcX1 / (float)tex->width[0];
-   t0 = srcY0 / (float)tex->height[0];
-   t1 = srcY1 / (float)tex->height[0];
+   s0 = srcX0 / (float)tex->width0;
+   s1 = srcX1 / (float)tex->width0;
+   t0 = srcY0 / (float)tex->height0;
+   t1 = srcY1 / (float)tex->height0;
 
    assert(ctx->pipe->screen->is_format_supported(ctx->pipe->screen, dst->format,
                                                  PIPE_TEXTURE_2D,
diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c
new file mode 100644 (file)
index 0000000..cef3b69
--- /dev/null
@@ -0,0 +1,726 @@
+/**************************************************************************
+ *
+ * Copyright 2009 Marek Olšák <maraeo@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 the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * @file
+ * Blitter utility to facilitate acceleration of the clear, surface_copy,
+ * and surface_fill functions.
+ *
+ * @author Marek Olšák
+ */
+
+#include "pipe/p_context.h"
+#include "pipe/p_defines.h"
+#include "pipe/p_inlines.h"
+#include "pipe/p_shader_tokens.h"
+#include "pipe/p_state.h"
+
+#include "util/u_format.h"
+#include "util/u_memory.h"
+#include "util/u_math.h"
+#include "util/u_blitter.h"
+#include "util/u_draw_quad.h"
+#include "util/u_pack_color.h"
+#include "util/u_rect.h"
+#include "util/u_simple_shaders.h"
+#include "util/u_texture.h"
+
+#define INVALID_PTR ((void*)~0)
+
+struct blitter_context_priv
+{
+   struct blitter_context blitter;
+
+   struct pipe_context *pipe; /**< pipe context */
+   struct pipe_buffer *vbuf;  /**< quad */
+
+   float vertices[4][2][4];   /**< {pos, color} or {pos, texcoord} */
+
+   /* Templates for various state objects. */
+   struct pipe_depth_stencil_alpha_state template_dsa;
+   struct pipe_sampler_state template_sampler_state;
+
+   /* Constant state objects. */
+   /* Vertex shaders. */
+   void *vs_col; /**< Vertex shader which passes {pos, color} to the output */
+   void *vs_tex; /**<Vertex shader which passes {pos, texcoord} to the output.*/
+
+   /* Fragment shaders. */
+   /* FS which outputs a color to multiple color buffers. */
+   void *fs_col[PIPE_MAX_COLOR_BUFS];
+
+   /* FS which outputs a color from a texture,
+      where the index is PIPE_TEXTURE_* to be sampled. */
+   void *fs_texfetch_col[PIPE_MAX_TEXTURE_TYPES];
+
+   /* FS which outputs a depth from a texture,
+      where the index is PIPE_TEXTURE_* to be sampled. */
+   void *fs_texfetch_depth[PIPE_MAX_TEXTURE_TYPES];
+
+   /* Blend state. */
+   void *blend_write_color;   /**< blend state with writemask of RGBA */
+   void *blend_keep_color;    /**< blend state with writemask of 0 */
+
+   /* Depth stencil alpha state. */
+   void *dsa_write_depth_stencil[0xff]; /**< indices are stencil clear values */
+   void *dsa_write_depth_keep_stencil;
+   void *dsa_keep_depth_stencil;
+
+   /* Sampler state for clamping to a miplevel. */
+   void *sampler_state[PIPE_MAX_TEXTURE_LEVELS];
+
+   /* Rasterizer state. */
+   void *rs_state;
+};
+
+struct blitter_context *util_blitter_create(struct pipe_context *pipe)
+{
+   struct blitter_context_priv *ctx;
+   struct pipe_blend_state blend;
+   struct pipe_depth_stencil_alpha_state *dsa;
+   struct pipe_rasterizer_state rs_state;
+   struct pipe_sampler_state *sampler_state;
+   unsigned i;
+
+   ctx = CALLOC_STRUCT(blitter_context_priv);
+   if (!ctx)
+      return NULL;
+
+   ctx->pipe = pipe;
+
+   /* init state objects for them to be considered invalid */
+   ctx->blitter.saved_blend_state = INVALID_PTR;
+   ctx->blitter.saved_dsa_state = INVALID_PTR;
+   ctx->blitter.saved_rs_state = INVALID_PTR;
+   ctx->blitter.saved_fs = INVALID_PTR;
+   ctx->blitter.saved_vs = INVALID_PTR;
+   ctx->blitter.saved_fb_state.nr_cbufs = ~0;
+   ctx->blitter.saved_num_textures = ~0;
+   ctx->blitter.saved_num_sampler_states = ~0;
+
+   /* blend state objects */
+   memset(&blend, 0, sizeof(blend));
+   ctx->blend_keep_color = pipe->create_blend_state(pipe, &blend);
+
+   blend.colormask = PIPE_MASK_RGBA;
+   ctx->blend_write_color = pipe->create_blend_state(pipe, &blend);
+
+   /* depth stencil alpha state objects */
+   dsa = &ctx->template_dsa;
+   ctx->dsa_keep_depth_stencil =
+      pipe->create_depth_stencil_alpha_state(pipe, dsa);
+
+   dsa->depth.enabled = 1;
+   dsa->depth.writemask = 1;
+   dsa->depth.func = PIPE_FUNC_ALWAYS;
+   ctx->dsa_write_depth_keep_stencil =
+      pipe->create_depth_stencil_alpha_state(pipe, dsa);
+
+   dsa->stencil[0].enabled = 1;
+   dsa->stencil[0].func = PIPE_FUNC_ALWAYS;
+   dsa->stencil[0].fail_op = PIPE_STENCIL_OP_REPLACE;
+   dsa->stencil[0].zpass_op = PIPE_STENCIL_OP_REPLACE;
+   dsa->stencil[0].zfail_op = PIPE_STENCIL_OP_REPLACE;
+   dsa->stencil[0].valuemask = 0xff;
+   dsa->stencil[0].writemask = 0xff;
+   /* The DSA state objects which write depth and stencil are created
+    * on-demand. */
+
+   /* sampler state */
+   sampler_state = &ctx->template_sampler_state;
+   sampler_state->wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
+   sampler_state->wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
+   sampler_state->wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
+   /* The sampler state objects which sample from a specified mipmap level
+    * are created on-demand. */
+
+   /* rasterizer state */
+   memset(&rs_state, 0, sizeof(rs_state));
+   rs_state.front_winding = PIPE_WINDING_CW;
+   rs_state.cull_mode = PIPE_WINDING_NONE;
+   rs_state.bypass_vs_clip_and_viewport = 1;
+   rs_state.gl_rasterization_rules = 1;
+   ctx->rs_state = pipe->create_rasterizer_state(pipe, &rs_state);
+
+   /* fragment shaders are created on-demand */
+
+   /* vertex shaders */
+   {
+      const uint semantic_names[] = { TGSI_SEMANTIC_POSITION,
+                                      TGSI_SEMANTIC_COLOR };
+      const uint semantic_indices[] = { 0, 0 };
+      ctx->vs_col =
+         util_make_vertex_passthrough_shader(pipe, 2, semantic_names,
+                                             semantic_indices);
+   }
+   {
+      const uint semantic_names[] = { TGSI_SEMANTIC_POSITION,
+                                      TGSI_SEMANTIC_GENERIC };
+      const uint semantic_indices[] = { 0, 0 };
+      ctx->vs_tex =
+         util_make_vertex_passthrough_shader(pipe, 2, semantic_names,
+                                             semantic_indices);
+   }
+
+   /* set invariant vertex coordinates */
+   for (i = 0; i < 4; i++)
+      ctx->vertices[i][0][3] = 1; /*v.w*/
+
+   /* create the vertex buffer */
+   ctx->vbuf = pipe_buffer_create(ctx->pipe->screen,
+                                  32,
+                                  PIPE_BUFFER_USAGE_VERTEX,
+                                  sizeof(ctx->vertices));
+
+   return &ctx->blitter;
+}
+
+void util_blitter_destroy(struct blitter_context *blitter)
+{
+   struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
+   struct pipe_context *pipe = ctx->pipe;
+   int i;
+
+   pipe->delete_blend_state(pipe, ctx->blend_write_color);
+   pipe->delete_blend_state(pipe, ctx->blend_keep_color);
+   pipe->delete_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil);
+   pipe->delete_depth_stencil_alpha_state(pipe,
+                                          ctx->dsa_write_depth_keep_stencil);
+
+   for (i = 0; i < 0xff; i++)
+      if (ctx->dsa_write_depth_stencil[i])
+         pipe->delete_depth_stencil_alpha_state(pipe,
+            ctx->dsa_write_depth_stencil[i]);
+
+   pipe->delete_rasterizer_state(pipe, ctx->rs_state);
+   pipe->delete_vs_state(pipe, ctx->vs_col);
+   pipe->delete_vs_state(pipe, ctx->vs_tex);
+
+   for (i = 0; i < PIPE_MAX_TEXTURE_TYPES; i++) {
+      if (ctx->fs_texfetch_col[i])
+         pipe->delete_fs_state(pipe, ctx->fs_texfetch_col[i]);
+      if (ctx->fs_texfetch_depth[i])
+         pipe->delete_fs_state(pipe, ctx->fs_texfetch_depth[i]);
+   }
+
+   for (i = 0; i < PIPE_MAX_COLOR_BUFS && ctx->fs_col[i]; i++)
+      if (ctx->fs_col[i])
+         pipe->delete_fs_state(pipe, ctx->fs_col[i]);
+
+   for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++)
+      if (ctx->sampler_state[i])
+         pipe->delete_sampler_state(pipe, ctx->sampler_state[i]);
+
+   pipe_buffer_reference(&ctx->vbuf, NULL);
+   FREE(ctx);
+}
+
+static void blitter_check_saved_CSOs(struct blitter_context_priv *ctx)
+{
+   /* make sure these CSOs have been saved */
+   assert(ctx->blitter.saved_blend_state != INVALID_PTR &&
+          ctx->blitter.saved_dsa_state != INVALID_PTR &&
+          ctx->blitter.saved_rs_state != INVALID_PTR &&
+          ctx->blitter.saved_fs != INVALID_PTR &&
+          ctx->blitter.saved_vs != INVALID_PTR);
+}
+
+static void blitter_restore_CSOs(struct blitter_context_priv *ctx)
+{
+   struct pipe_context *pipe = ctx->pipe;
+
+   /* restore the state objects which are always required to be saved */
+   pipe->bind_blend_state(pipe, ctx->blitter.saved_blend_state);
+   pipe->bind_depth_stencil_alpha_state(pipe, ctx->blitter.saved_dsa_state);
+   pipe->bind_rasterizer_state(pipe, ctx->blitter.saved_rs_state);
+   pipe->bind_fs_state(pipe, ctx->blitter.saved_fs);
+   pipe->bind_vs_state(pipe, ctx->blitter.saved_vs);
+
+   ctx->blitter.saved_blend_state = INVALID_PTR;
+   ctx->blitter.saved_dsa_state = INVALID_PTR;
+   ctx->blitter.saved_rs_state = INVALID_PTR;
+   ctx->blitter.saved_fs = INVALID_PTR;
+   ctx->blitter.saved_vs = INVALID_PTR;
+
+   /* restore the state objects which are required to be saved before copy/fill
+    */
+   if (ctx->blitter.saved_fb_state.nr_cbufs != ~0) {
+      pipe->set_framebuffer_state(pipe, &ctx->blitter.saved_fb_state);
+      ctx->blitter.saved_fb_state.nr_cbufs = ~0;
+   }
+
+   if (ctx->blitter.saved_num_sampler_states != ~0) {
+      pipe->bind_fragment_sampler_states(pipe,
+                                         ctx->blitter.saved_num_sampler_states,
+                                         ctx->blitter.saved_sampler_states);
+      ctx->blitter.saved_num_sampler_states = ~0;
+   }
+
+   if (ctx->blitter.saved_num_textures != ~0) {
+      pipe->set_fragment_sampler_textures(pipe,
+                                          ctx->blitter.saved_num_textures,
+                                          ctx->blitter.saved_textures);
+      ctx->blitter.saved_num_textures = ~0;
+   }
+}
+
+static void blitter_set_rectangle(struct blitter_context_priv *ctx,
+                                  unsigned x1, unsigned y1,
+                                  unsigned x2, unsigned y2,
+                                  float depth)
+{
+   int i;
+
+   /* set vertex positions */
+   ctx->vertices[0][0][0] = x1; /*v0.x*/
+   ctx->vertices[0][0][1] = y1; /*v0.y*/
+
+   ctx->vertices[1][0][0] = x2; /*v1.x*/
+   ctx->vertices[1][0][1] = y1; /*v1.y*/
+
+   ctx->vertices[2][0][0] = x2; /*v2.x*/
+   ctx->vertices[2][0][1] = y2; /*v2.y*/
+
+   ctx->vertices[3][0][0] = x1; /*v3.x*/
+   ctx->vertices[3][0][1] = y2; /*v3.y*/
+
+   for (i = 0; i < 4; i++)
+      ctx->vertices[i][0][2] = depth; /*z*/
+}
+
+static void blitter_set_clear_color(struct blitter_context_priv *ctx,
+                                    const float *rgba)
+{
+   int i;
+
+   for (i = 0; i < 4; i++) {
+      ctx->vertices[i][1][0] = rgba[0];
+      ctx->vertices[i][1][1] = rgba[1];
+      ctx->vertices[i][1][2] = rgba[2];
+      ctx->vertices[i][1][3] = rgba[3];
+   }
+}
+
+static void blitter_set_texcoords_2d(struct blitter_context_priv *ctx,
+                                     struct pipe_surface *surf,
+                                     unsigned x1, unsigned y1,
+                                     unsigned x2, unsigned y2)
+{
+   int i;
+   float s1 = x1 / (float)surf->width;
+   float t1 = y1 / (float)surf->height;
+   float s2 = x2 / (float)surf->width;
+   float t2 = y2 / (float)surf->height;
+
+   ctx->vertices[0][1][0] = s1; /*t0.s*/
+   ctx->vertices[0][1][1] = t1; /*t0.t*/
+
+   ctx->vertices[1][1][0] = s2; /*t1.s*/
+   ctx->vertices[1][1][1] = t1; /*t1.t*/
+
+   ctx->vertices[2][1][0] = s2; /*t2.s*/
+   ctx->vertices[2][1][1] = t2; /*t2.t*/
+
+   ctx->vertices[3][1][0] = s1; /*t3.s*/
+   ctx->vertices[3][1][1] = t2; /*t3.t*/
+
+   for (i = 0; i < 4; i++) {
+      ctx->vertices[i][1][2] = 0; /*r*/
+      ctx->vertices[i][1][3] = 1; /*q*/
+   }
+}
+
+static void blitter_set_texcoords_3d(struct blitter_context_priv *ctx,
+                                     struct pipe_surface *surf,
+                                     unsigned x1, unsigned y1,
+                                     unsigned x2, unsigned y2)
+{
+   int i;
+   float depth = u_minify(surf->texture->depth0, surf->level);
+   float r = surf->zslice / depth;
+
+   blitter_set_texcoords_2d(ctx, surf, x1, y1, x2, y2);
+
+   for (i = 0; i < 4; i++)
+      ctx->vertices[i][1][2] = r; /*r*/
+}
+
+static void blitter_set_texcoords_cube(struct blitter_context_priv *ctx,
+                                       struct pipe_surface *surf,
+                                       unsigned x1, unsigned y1,
+                                       unsigned x2, unsigned y2)
+{
+   int i;
+   float s1 = x1 / (float)surf->width;
+   float t1 = y1 / (float)surf->height;
+   float s2 = x2 / (float)surf->width;
+   float t2 = y2 / (float)surf->height;
+   const float st[4][2] = {
+      {s1, t1}, {s2, t1}, {s2, t2}, {s1, t2}
+   };
+
+   util_map_texcoords2d_onto_cubemap(surf->face,
+                                     /* pointer, stride in floats */
+                                     &st[0][0], 2,
+                                     &ctx->vertices[0][1][0], 8);
+
+   for (i = 0; i < 4; i++)
+      ctx->vertices[i][1][3] = 1; /*q*/
+}
+
+static void blitter_draw_quad(struct blitter_context_priv *ctx)
+{
+   struct pipe_context *pipe = ctx->pipe;
+
+   /* write vertices and draw them */
+   pipe_buffer_write(pipe->screen, ctx->vbuf,
+                     0, sizeof(ctx->vertices), ctx->vertices);
+
+   util_draw_vertex_buffer(pipe, ctx->vbuf, 0, PIPE_PRIM_TRIANGLE_FAN,
+                           4,  /* verts */
+                           2); /* attribs/vert */
+}
+
+static INLINE
+void *blitter_get_state_write_depth_stencil(
+               struct blitter_context_priv *ctx,
+               unsigned stencil)
+{
+   struct pipe_context *pipe = ctx->pipe;
+
+   stencil &= 0xff;
+
+   /* Create the DSA state on-demand. */
+   if (!ctx->dsa_write_depth_stencil[stencil]) {
+      ctx->template_dsa.stencil[0].ref_value = stencil;
+
+      ctx->dsa_write_depth_stencil[stencil] =
+         pipe->create_depth_stencil_alpha_state(pipe, &ctx->template_dsa);
+   }
+
+   return ctx->dsa_write_depth_stencil[stencil];
+}
+
+static INLINE
+void **blitter_get_sampler_state(struct blitter_context_priv *ctx,
+                                 int miplevel)
+{
+   struct pipe_context *pipe = ctx->pipe;
+   struct pipe_sampler_state *sampler_state = &ctx->template_sampler_state;
+
+   assert(miplevel < PIPE_MAX_TEXTURE_LEVELS);
+
+   /* Create the sampler state on-demand. */
+   if (!ctx->sampler_state[miplevel]) {
+      sampler_state->lod_bias = miplevel;
+      sampler_state->min_lod = miplevel;
+      sampler_state->max_lod = miplevel;
+
+      ctx->sampler_state[miplevel] = pipe->create_sampler_state(pipe,
+                                                                sampler_state);
+   }
+
+   /* Return void** so that it can be passed to bind_fragment_sampler_states
+    * directly. */
+   return &ctx->sampler_state[miplevel];
+}
+
+static INLINE
+void *blitter_get_fs_col(struct blitter_context_priv *ctx, unsigned num_cbufs)
+{
+   struct pipe_context *pipe = ctx->pipe;
+   unsigned index = num_cbufs ? num_cbufs - 1 : 0;
+
+   assert(num_cbufs <= PIPE_MAX_COLOR_BUFS);
+
+   if (!ctx->fs_col[index])
+      ctx->fs_col[index] =
+         util_make_fragment_clonecolor_shader(pipe, num_cbufs);
+
+   return ctx->fs_col[index];
+}
+
+static INLINE
+void *blitter_get_fs_texfetch_col(struct blitter_context_priv *ctx,
+                                  unsigned tex_target)
+{
+   struct pipe_context *pipe = ctx->pipe;
+
+   assert(tex_target < PIPE_MAX_TEXTURE_TYPES);
+
+   /* Create the fragment shader on-demand. */
+   if (!ctx->fs_texfetch_col[tex_target]) {
+      switch (tex_target) {
+         case PIPE_TEXTURE_1D:
+            ctx->fs_texfetch_col[PIPE_TEXTURE_1D] =
+               util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_1D);
+            break;
+         case PIPE_TEXTURE_2D:
+            ctx->fs_texfetch_col[PIPE_TEXTURE_2D] =
+               util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_2D);
+            break;
+         case PIPE_TEXTURE_3D:
+            ctx->fs_texfetch_col[PIPE_TEXTURE_3D] =
+               util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_3D);
+            break;
+         case PIPE_TEXTURE_CUBE:
+            ctx->fs_texfetch_col[PIPE_TEXTURE_CUBE] =
+               util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_CUBE);
+            break;
+         default:;
+      }
+   }
+
+   return ctx->fs_texfetch_col[tex_target];
+}
+
+static INLINE
+void *blitter_get_fs_texfetch_depth(struct blitter_context_priv *ctx,
+                                    unsigned tex_target)
+{
+   struct pipe_context *pipe = ctx->pipe;
+
+   assert(tex_target < PIPE_MAX_TEXTURE_TYPES);
+
+   /* Create the fragment shader on-demand. */
+   if (!ctx->fs_texfetch_depth[tex_target]) {
+      switch (tex_target) {
+         case PIPE_TEXTURE_1D:
+            ctx->fs_texfetch_depth[PIPE_TEXTURE_1D] =
+               util_make_fragment_tex_shader_writedepth(pipe, TGSI_TEXTURE_1D);
+            break;
+         case PIPE_TEXTURE_2D:
+            ctx->fs_texfetch_depth[PIPE_TEXTURE_2D] =
+               util_make_fragment_tex_shader_writedepth(pipe, TGSI_TEXTURE_2D);
+            break;
+         case PIPE_TEXTURE_3D:
+            ctx->fs_texfetch_depth[PIPE_TEXTURE_3D] =
+               util_make_fragment_tex_shader_writedepth(pipe, TGSI_TEXTURE_3D);
+            break;
+         case PIPE_TEXTURE_CUBE:
+            ctx->fs_texfetch_depth[PIPE_TEXTURE_CUBE] =
+               util_make_fragment_tex_shader_writedepth(pipe,TGSI_TEXTURE_CUBE);
+            break;
+         default:;
+      }
+   }
+
+   return ctx->fs_texfetch_depth[tex_target];
+}
+
+void util_blitter_clear(struct blitter_context *blitter,
+                        unsigned width, unsigned height,
+                        unsigned num_cbufs,
+                        unsigned clear_buffers,
+                        const float *rgba,
+                        double depth, unsigned stencil)
+{
+   struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
+   struct pipe_context *pipe = ctx->pipe;
+
+   assert(num_cbufs <= PIPE_MAX_COLOR_BUFS);
+
+   blitter_check_saved_CSOs(ctx);
+
+   /* bind CSOs */
+   if (clear_buffers & PIPE_CLEAR_COLOR)
+      pipe->bind_blend_state(pipe, ctx->blend_write_color);
+   else
+      pipe->bind_blend_state(pipe, ctx->blend_keep_color);
+
+   if (clear_buffers & PIPE_CLEAR_DEPTHSTENCIL)
+      pipe->bind_depth_stencil_alpha_state(pipe,
+         blitter_get_state_write_depth_stencil(ctx, stencil));
+   else
+      pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil);
+
+   pipe->bind_rasterizer_state(pipe, ctx->rs_state);
+   pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, num_cbufs));
+   pipe->bind_vs_state(pipe, ctx->vs_col);
+
+   blitter_set_clear_color(ctx, rgba);
+   blitter_set_rectangle(ctx, 0, 0, width, height, depth);
+   blitter_draw_quad(ctx);
+   blitter_restore_CSOs(ctx);
+}
+
+void util_blitter_copy(struct blitter_context *blitter,
+                       struct pipe_surface *dst,
+                       unsigned dstx, unsigned dsty,
+                       struct pipe_surface *src,
+                       unsigned srcx, unsigned srcy,
+                       unsigned width, unsigned height,
+                       boolean ignore_stencil)
+{
+   struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
+   struct pipe_context *pipe = ctx->pipe;
+   struct pipe_screen *screen = pipe->screen;
+   struct pipe_framebuffer_state fb_state;
+   boolean is_stencil, is_depth;
+   unsigned dst_tex_usage;
+
+   /* give up if textures are not set */
+   assert(dst->texture && src->texture);
+   if (!dst->texture || !src->texture)
+      return;
+
+   is_depth = util_format_get_component_bits(src->format, UTIL_FORMAT_COLORSPACE_ZS, 0) != 0;
+   is_stencil = util_format_get_component_bits(src->format, UTIL_FORMAT_COLORSPACE_ZS, 1) != 0;
+   dst_tex_usage = is_depth || is_stencil ? PIPE_TEXTURE_USAGE_DEPTH_STENCIL :
+                                            PIPE_TEXTURE_USAGE_RENDER_TARGET;
+
+   /* check if we can sample from and render to the surfaces */
+   /* (assuming copying a stencil buffer is not possible) */
+   if ((!ignore_stencil && is_stencil) ||
+       !screen->is_format_supported(screen, dst->format, dst->texture->target,
+                                    dst_tex_usage, 0) ||
+       !screen->is_format_supported(screen, src->format, src->texture->target,
+                                    PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
+      util_surface_copy(pipe, FALSE, dst, dstx, dsty, src, srcx, srcy,
+                        width, height);
+      return;
+   }
+
+   /* check whether the states are properly saved */
+   blitter_check_saved_CSOs(ctx);
+   assert(blitter->saved_fb_state.nr_cbufs != ~0);
+   assert(blitter->saved_num_textures != ~0);
+   assert(blitter->saved_num_sampler_states != ~0);
+   assert(src->texture->target < PIPE_MAX_TEXTURE_TYPES);
+
+   /* bind CSOs */
+   fb_state.width = dst->width;
+   fb_state.height = dst->height;
+
+   if (is_depth) {
+      pipe->bind_blend_state(pipe, ctx->blend_keep_color);
+      pipe->bind_depth_stencil_alpha_state(pipe,
+                                           ctx->dsa_write_depth_keep_stencil);
+      pipe->bind_fs_state(pipe,
+         blitter_get_fs_texfetch_depth(ctx, src->texture->target));
+
+      fb_state.nr_cbufs = 0;
+      fb_state.zsbuf = dst;
+   } else {
+      pipe->bind_blend_state(pipe, ctx->blend_write_color);
+      pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil);
+      pipe->bind_fs_state(pipe,
+         blitter_get_fs_texfetch_col(ctx, src->texture->target));
+
+      fb_state.nr_cbufs = 1;
+      fb_state.cbufs[0] = dst;
+      fb_state.zsbuf = 0;
+   }
+
+   pipe->bind_rasterizer_state(pipe, ctx->rs_state);
+   pipe->bind_vs_state(pipe, ctx->vs_tex);
+   pipe->bind_fragment_sampler_states(pipe, 1,
+      blitter_get_sampler_state(ctx, src->level));
+   pipe->set_fragment_sampler_textures(pipe, 1, &src->texture);
+   pipe->set_framebuffer_state(pipe, &fb_state);
+
+   /* set texture coordinates */
+   switch (src->texture->target) {
+      case PIPE_TEXTURE_1D:
+      case PIPE_TEXTURE_2D:
+         blitter_set_texcoords_2d(ctx, src, srcx, srcy,
+                                  srcx+width, srcy+height);
+         break;
+      case PIPE_TEXTURE_3D:
+         blitter_set_texcoords_3d(ctx, src, srcx, srcy,
+                                  srcx+width, srcy+height);
+         break;
+      case PIPE_TEXTURE_CUBE:
+         blitter_set_texcoords_cube(ctx, src, srcx, srcy,
+                                    srcx+width, srcy+height);
+         break;
+      default:
+         assert(0);
+   }
+
+   blitter_set_rectangle(ctx, dstx, dsty, dstx+width, dsty+height, 0);
+   blitter_draw_quad(ctx);
+   blitter_restore_CSOs(ctx);
+}
+
+void util_blitter_fill(struct blitter_context *blitter,
+                       struct pipe_surface *dst,
+                       unsigned dstx, unsigned dsty,
+                       unsigned width, unsigned height,
+                       unsigned value)
+{
+   struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
+   struct pipe_context *pipe = ctx->pipe;
+   struct pipe_screen *screen = pipe->screen;
+   struct pipe_framebuffer_state fb_state;
+   float rgba[4];
+   ubyte ub_rgba[4] = {0};
+   union util_color color;
+   int i;
+
+   assert(dst->texture);
+   if (!dst->texture)
+      return;
+
+   /* check if we can render to the surface */
+   if (util_format_is_depth_or_stencil(dst->format) || /* unlikely, but you never know */
+       !screen->is_format_supported(screen, dst->format, dst->texture->target,
+                                    PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) {
+      util_surface_fill(pipe, dst, dstx, dsty, width, height, value);
+      return;
+   }
+
+   /* unpack the color */
+   color.ui = value;
+   util_unpack_color_ub(dst->format, &color,
+                        ub_rgba, ub_rgba+1, ub_rgba+2, ub_rgba+3);
+   for (i = 0; i < 4; i++)
+      rgba[i] = ubyte_to_float(ub_rgba[i]);
+
+   /* check the saved state */
+   blitter_check_saved_CSOs(ctx);
+   assert(blitter->saved_fb_state.nr_cbufs != ~0);
+
+   /* bind CSOs */
+   pipe->bind_blend_state(pipe, ctx->blend_write_color);
+   pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil);
+   pipe->bind_rasterizer_state(pipe, ctx->rs_state);
+   pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, 1));
+   pipe->bind_vs_state(pipe, ctx->vs_col);
+
+   /* set a framebuffer state */
+   fb_state.width = dst->width;
+   fb_state.height = dst->height;
+   fb_state.nr_cbufs = 1;
+   fb_state.cbufs[0] = dst;
+   fb_state.zsbuf = 0;
+   pipe->set_framebuffer_state(pipe, &fb_state);
+
+   blitter_set_clear_color(ctx, rgba);
+   blitter_set_rectangle(ctx, 0, 0, width, height, 0);
+   blitter_draw_quad(ctx);
+   blitter_restore_CSOs(ctx);
+}
diff --git a/src/gallium/auxiliary/util/u_blitter.h b/src/gallium/auxiliary/util/u_blitter.h
new file mode 100644 (file)
index 0000000..3da5a6c
--- /dev/null
@@ -0,0 +1,230 @@
+/**************************************************************************
+ *
+ * Copyright 2009 Marek Olšák <maraeo@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 the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 U_BLITTER_H
+#define U_BLITTER_H
+
+#include "util/u_memory.h"
+
+#include "pipe/p_state.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct pipe_context;
+
+struct blitter_context
+{
+   /* Private members, really. */
+   void *saved_blend_state;   /**< blend state */
+   void *saved_dsa_state;     /**< depth stencil alpha state */
+   void *saved_rs_state;      /**< rasterizer state */
+   void *saved_fs, *saved_vs; /**< fragment shader, vertex shader */
+
+   struct pipe_framebuffer_state saved_fb_state;  /**< framebuffer state */
+
+   int saved_num_sampler_states;
+   void *saved_sampler_states[32];
+
+   int saved_num_textures;
+   struct pipe_texture *saved_textures[32]; /* is 32 enough? */
+};
+
+/**
+ * Create a blitter context.
+ */
+struct blitter_context *util_blitter_create(struct pipe_context *pipe);
+
+/**
+ * Destroy a blitter context.
+ */
+void util_blitter_destroy(struct blitter_context *blitter);
+
+/*
+ * These CSOs must be saved before any of the following functions is called:
+ * - blend state
+ * - depth stencil alpha state
+ * - rasterizer state
+ * - vertex shader
+ * - fragment shader
+ */
+
+/**
+ * Clear a specified set of currently bound buffers to specified values.
+ */
+void util_blitter_clear(struct blitter_context *blitter,
+                        unsigned width, unsigned height,
+                        unsigned num_cbufs,
+                        unsigned clear_buffers,
+                        const float *rgba,
+                        double depth, unsigned stencil);
+
+/**
+ * Copy a block of pixels from one surface to another.
+ *
+ * You can copy from any color format to any other color format provided
+ * the former can be sampled and the latter can be rendered to. Otherwise,
+ * a software fallback path is taken and both surfaces must be of the same
+ * format.
+ *
+ * The same holds for depth-stencil formats with the exception that stencil
+ * cannot be copied unless you set ignore_stencil to FALSE. In that case,
+ * a software fallback path is taken and both surfaces must be of the same
+ * format.
+ *
+ * Use pipe_screen->is_format_supported to know your options.
+ *
+ * These states must be saved in the blitter in addition to the state objects
+ * already required to be saved:
+ * - framebuffer state
+ * - fragment sampler states
+ * - fragment sampler textures
+ */
+void util_blitter_copy(struct blitter_context *blitter,
+                       struct pipe_surface *dst,
+                       unsigned dstx, unsigned dsty,
+                       struct pipe_surface *src,
+                       unsigned srcx, unsigned srcy,
+                       unsigned width, unsigned height,
+                       boolean ignore_stencil);
+
+/**
+ * Fill a region of a surface with a constant value.
+ *
+ * If the surface cannot be rendered to or it's a depth-stencil format,
+ * a software fallback path is taken.
+ *
+ * These states must be saved in the blitter in addition to the state objects
+ * already required to be saved:
+ * - framebuffer state
+ */
+void util_blitter_fill(struct blitter_context *blitter,
+                       struct pipe_surface *dst,
+                       unsigned dstx, unsigned dsty,
+                       unsigned width, unsigned height,
+                       unsigned value);
+
+/**
+ * Copy all pixels from one surface to another.
+ *
+ * The rules are the same as in util_blitter_copy with the addition that
+ * surfaces must have the same size.
+ */
+static INLINE
+void util_blitter_copy_surface(struct blitter_context *blitter,
+                               struct pipe_surface *dst,
+                               struct pipe_surface *src,
+                               boolean ignore_stencil)
+{
+   assert(dst->width == src->width && dst->height == src->height);
+
+   util_blitter_copy(blitter, dst, 0, 0, src, 0, 0, src->width, src->height,
+                     ignore_stencil);
+}
+
+
+/* The functions below should be used to save currently bound constant state
+ * objects inside a driver. The objects are automatically restored at the end
+ * of the util_blitter_{clear, fill, copy, copy_surface} functions and then
+ * forgotten.
+ *
+ * CSOs not listed here are not affected by util_blitter. */
+
+static INLINE
+void util_blitter_save_blend(struct blitter_context *blitter,
+                             void *state)
+{
+   blitter->saved_blend_state = state;
+}
+
+static INLINE
+void util_blitter_save_depth_stencil_alpha(struct blitter_context *blitter,
+                                           void *state)
+{
+   blitter->saved_dsa_state = state;
+}
+
+static INLINE
+void util_blitter_save_rasterizer(struct blitter_context *blitter,
+                                  void *state)
+{
+   blitter->saved_rs_state = state;
+}
+
+static INLINE
+void util_blitter_save_fragment_shader(struct blitter_context *blitter,
+                                       void *fs)
+{
+   blitter->saved_fs = fs;
+}
+
+static INLINE
+void util_blitter_save_vertex_shader(struct blitter_context *blitter,
+                                     void *vs)
+{
+   blitter->saved_vs = vs;
+}
+
+static INLINE
+void util_blitter_save_framebuffer(struct blitter_context *blitter,
+                                   struct pipe_framebuffer_state *state)
+{
+   blitter->saved_fb_state = *state;
+}
+
+static INLINE
+void util_blitter_save_fragment_sampler_states(
+                  struct blitter_context *blitter,
+                  int num_sampler_states,
+                  void **sampler_states)
+{
+   assert(num_sampler_states <= Elements(blitter->saved_sampler_states));
+
+   blitter->saved_num_sampler_states = num_sampler_states;
+   memcpy(blitter->saved_sampler_states, sampler_states,
+          num_sampler_states * sizeof(void *));
+}
+
+static INLINE
+void util_blitter_save_fragment_sampler_textures(
+                  struct blitter_context *blitter,
+                  int num_textures,
+                  struct pipe_texture **textures)
+{
+   assert(num_textures <= Elements(blitter->saved_textures));
+
+   blitter->saved_num_textures = num_textures;
+   memcpy(blitter->saved_textures, textures,
+          num_textures * sizeof(struct pipe_texture *));
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
index 7c16b32cf9f280464d680fc05c73c7000323b539..2c32db61756035aae298daf777c062acd2f31982 100644 (file)
@@ -32,6 +32,7 @@
 #include "pipe/p_context.h"
 #include "pipe/p_state.h"
 #include "util/u_pack_color.h"
+#include "util/u_rect.h"
 
 
 /**
@@ -45,16 +46,25 @@ util_clear(struct pipe_context *pipe,
 {
    if (buffers & PIPE_CLEAR_COLOR) {
       struct pipe_surface *ps = framebuffer->cbufs[0];
-      unsigned color;
+      union util_color uc;
 
-      util_pack_color(rgba, ps->format, &color);
-      pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, color);
+      util_pack_color(rgba, ps->format, &uc);
+      if (pipe->surface_fill) {
+         pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, uc.ui);
+      } else {
+         util_surface_fill(pipe, ps, 0, 0, ps->width, ps->height, uc.ui);
+      }
    }
 
    if (buffers & PIPE_CLEAR_DEPTHSTENCIL) {
       struct pipe_surface *ps = framebuffer->zsbuf;
 
-      pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height,
-                         util_pack_z_stencil(ps->format, depth, stencil));
+      if (pipe->surface_fill) {
+         pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height,
+                            util_pack_z_stencil(ps->format, depth, stencil));
+      } else {
+         util_surface_fill(pipe, ps, 0, 0, ps->width, ps->height,
+                           util_pack_z_stencil(ps->format, depth, stencil));
+      }
    }
 }
index ded361ce704bff59b93f6c8a3fe865d7c9c92d42..a08241971ca1a95e56f186da9e057dffb8696df2 100644 (file)
 
 #if defined(PIPE_OS_WINDOWS)
 #include <windows.h>
+#if defined(MSVC)
+#include <intrin.h>
+#endif
 #endif
 
 
 struct util_cpu_caps util_cpu_caps;
 
 static int has_cpuid(void);
-static int cpuid(uint32_t ax, uint32_t *p);
 
 #if defined(PIPE_ARCH_X86)
 
 /* The sigill handlers */
-#if defined(PIPE_OS_LINUX) //&& defined(_POSIX_SOURCE) && defined(X86_FXSR_MAGIC)
+#if defined(PIPE_OS_LINUX) /*&& defined(_POSIX_SOURCE) && defined(X86_FXSR_MAGIC)*/
 static void
 sigill_handler_sse(int signal, struct sigcontext sc)
 {
@@ -131,7 +133,7 @@ win32_sig_handler_sse(EXCEPTION_POINTERS* ep)
 
 
 #if defined(PIPE_ARCH_PPC) && !defined(PIPE_OS_DARWIN)
-static sigjmp_buf __lv_powerpc_jmpbuf;
+static jmp_buf  __lv_powerpc_jmpbuf;
 static volatile sig_atomic_t __lv_powerpc_canjump = 0;
 
 static void
@@ -143,9 +145,11 @@ sigill_handler(int sig)
    }
 
    __lv_powerpc_canjump = 0;
-   siglongjmp(__lv_powerpc_jmpbuf, 1);
+   longjmp(__lv_powerpc_jmpbuf, 1);
 }
+#endif
 
+#if defined(PIPE_ARCH_PPC)
 static void
 check_os_altivec_support(void)
 {
@@ -166,7 +170,7 @@ check_os_altivec_support(void)
    /* no Darwin, do it the brute-force way */
    /* this is borrowed from the libmpeg2 library */
    signal(SIGILL, sigill_handler);
-   if (sigsetjmp(__lv_powerpc_jmpbuf, 1)) {
+   if (setjmp(__lv_powerpc_jmpbuf)) {
       signal(SIGILL, SIG_DFL);
    } else {
       __lv_powerpc_canjump = 1;
@@ -180,9 +184,9 @@ check_os_altivec_support(void)
       signal(SIGILL, SIG_DFL);
       util_cpu_caps.has_altivec = 1;
    }
-#endif
+#endif /* PIPE_OS_DARWIN */
 }
-#endif
+#endif /* PIPE_ARCH_PPC */
 
 /* If we're running on a processor that can do SSE, let's see if we
  * are allowed to or not.  This will catch 2.4.0 or later kernels that
@@ -190,6 +194,7 @@ check_os_altivec_support(void)
  * and RedHat patched 2.2 kernels that have broken exception handling
  * support for user space apps that do SSE.
  */
+#if defined(PIPE_ARCH_X86) || defined (PIPE_ARCH_X86_64)
 static void
 check_os_katmai_support(void)
 {
@@ -235,7 +240,7 @@ check_os_katmai_support(void)
       __asm __volatile ("xorps %xmm0, %xmm0");
 #elif defined(PIPE_CC_MSVC)
       __asm {
-          xorps xmm0, xmm0        // executing SSE instruction
+          xorps xmm0, xmm0        /* executing SSE instruction */
       }
 #else
 #error Unsupported compiler
@@ -278,7 +283,7 @@ check_os_katmai_support(void)
     * and therefore to be safe I'm going to leave this test in here.
     */
    if (util_cpu_caps.has_sse) {
-      //      test_os_katmai_exception_support();
+      /* test_os_katmai_exception_support(); */
    }
 
    /* Restore the original signal handlers.
@@ -334,12 +339,11 @@ static int has_cpuid(void)
 
 /**
  * @sa cpuid.h included in gcc-4.3 onwards.
+ * @sa http://msdn.microsoft.com/en-us/library/hskdteyh.aspx
  */
-static INLINE int
+static INLINE void
 cpuid(uint32_t ax, uint32_t *p)
 {
-   int ret = -1;
-
 #if defined(PIPE_CC_GCC) && defined(PIPE_ARCH_X86)
    __asm __volatile (
      "xchgl %%ebx, %1\n\t"
@@ -351,7 +355,6 @@ cpuid(uint32_t ax, uint32_t *p)
        "=d" (p[3])
      : "0" (ax)
    );
-   ret = 0;
 #elif defined(PIPE_CC_GCC) && defined(PIPE_ARCH_X86_64)
    __asm __volatile (
      "cpuid\n\t"
@@ -361,15 +364,16 @@ cpuid(uint32_t ax, uint32_t *p)
        "=d" (p[3])
      : "0" (ax)
    );
-   ret = 0;
 #elif defined(PIPE_CC_MSVC)
-   __cpuid(ax, p);
-
-   ret = 0;
+   __cpuid(p, ax);
+#else
+   p[0] = 0;
+   p[1] = 0;
+   p[2] = 0;
+   p[3] = 0;
 #endif
-
-   return ret;
 }
+#endif /* X86 or X86_64 */
 
 void
 util_cpu_detect(void)
@@ -390,19 +394,26 @@ util_cpu_detect(void)
    util_cpu_caps.arch = UTIL_CPU_ARCH_SPARC;
 #elif defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
    util_cpu_caps.arch = UTIL_CPU_ARCH_X86;
+   util_cpu_caps.little_endian = 1;
 #elif defined(PIPE_ARCH_PPC)
    util_cpu_caps.arch = UTIL_CPU_ARCH_POWERPC;
+   util_cpu_caps.little_endian = 0;
 #else
    util_cpu_caps.arch = UTIL_CPU_ARCH_UNKNOWN;
 #endif
 
    /* Count the number of CPUs in system */
-#if !defined(PIPE_OS_WINDOWS) && !defined(PIPE_OS_UNKNOWN) && defined(_SC_NPROCESSORS_ONLN)
+#if defined(PIPE_OS_WINDOWS)
+   {
+      SYSTEM_INFO system_info;
+      GetSystemInfo(&system_info);
+      util_cpu_caps.nr_cpus = system_info.dwNumberOfProcessors;
+   }
+#elif defined(PIPE_OS_UNIX) && defined(_SC_NPROCESSORS_ONLN)
    util_cpu_caps.nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
    if (util_cpu_caps.nr_cpus == -1)
       util_cpu_caps.nr_cpus = 1;
-
-#elif defined(PIPE_OS_NETBSD) || defined(PIPE_OS_FREEBSD) || defined(PIPE_OS_OPENBSD)
+#elif defined(PIPE_OS_BSD)
    {
       int mib[2], ncpu;
       int len;
@@ -469,7 +480,6 @@ util_cpu_detect(void)
          util_cpu_caps.cacheline = regs2[2] & 0xFF;
       }
 
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_FREEBSD) || defined(PIPE_OS_NETBSD) || defined(PIPE_OS_CYGWIN) || defined(PIPE_OS_OPENBSD)
       if (util_cpu_caps.has_sse)
          check_os_katmai_support();
 
@@ -477,13 +487,8 @@ util_cpu_detect(void)
          util_cpu_caps.has_sse2 = 0;
          util_cpu_caps.has_sse3 = 0;
          util_cpu_caps.has_ssse3 = 0;
+         util_cpu_caps.has_sse4_1 = 0;
       }
-#else
-      util_cpu_caps.has_sse = 0;
-      util_cpu_caps.has_sse2 = 0;
-      util_cpu_caps.has_sse3 = 0;
-      util_cpu_caps.has_ssse3 = 0;
-#endif
    }
 #endif /* PIPE_ARCH_X86 || PIPE_ARCH_X86_64 */
 
index 7ea0121c07f27d89f1b023440b8bfde83dddb0eb..4b3dc39c3428d610956cd631ef851fdc975b5fa8 100644 (file)
@@ -54,6 +54,8 @@ struct util_cpu_caps {
    int x86_cpu_type;
    unsigned cacheline;
 
+   unsigned little_endian:1;
+
    unsigned has_tsc:1;
    unsigned has_mmx:1;
    unsigned has_mmx2:1;
index 96d400c839b166669b3702657e5d01116dd56792..9b4e6ca2a73693e86d600964d89fd481f34e2c8f 100644 (file)
 #include "pipe/p_format.h" 
 #include "pipe/p_state.h" 
 #include "pipe/p_inlines.h" 
+#include "util/u_format.h"
 #include "util/u_memory.h" 
 #include "util/u_string.h" 
 #include "util/u_stream.h" 
 #include "util/u_math.h" 
 #include "util/u_tile.h" 
+#include "util/u_prim.h" 
 
 
 #ifdef PIPE_SUBSYSTEM_WINDOWS_DISPLAY
@@ -452,7 +454,8 @@ debug_dump_flags(const struct debug_named_value *names,
            util_strncat(output, "|", sizeof(output));
         else
            first = 0;
-        util_strncat(output, names->name, sizeof(output));
+        util_strncat(output, names->name, sizeof(output) - 1);
+        output[sizeof(output) - 1] = '\0';
         value &= ~names->value;
       }
       ++names;
@@ -465,7 +468,8 @@ debug_dump_flags(const struct debug_named_value *names,
         first = 0;
       
       util_snprintf(rest, sizeof(rest), "0x%08lx", value);
-      util_strncat(output, rest, sizeof(output));
+      util_strncat(output, rest, sizeof(output) - 1);
+      output[sizeof(output) - 1] = '\0';
    }
    
    if(first)
@@ -600,6 +604,32 @@ const char *pf_name( enum pipe_format format )
 }
 
 
+
+static const struct debug_named_value pipe_prim_names[] = {
+#ifdef DEBUG
+   DEBUG_NAMED_VALUE(PIPE_PRIM_POINTS),
+   DEBUG_NAMED_VALUE(PIPE_PRIM_LINES),
+   DEBUG_NAMED_VALUE(PIPE_PRIM_LINE_LOOP),
+   DEBUG_NAMED_VALUE(PIPE_PRIM_LINE_STRIP),
+   DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLES),
+   DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLE_STRIP),
+   DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLE_FAN),
+   DEBUG_NAMED_VALUE(PIPE_PRIM_QUADS),
+   DEBUG_NAMED_VALUE(PIPE_PRIM_QUAD_STRIP),
+   DEBUG_NAMED_VALUE(PIPE_PRIM_POLYGON),
+#endif
+   DEBUG_NAMED_VALUE_END
+};
+
+
+const char *u_prim_name( unsigned prim )
+{
+   return debug_dump_enum(pipe_prim_names, prim);
+}
+
+
+
+
 #ifdef DEBUG
 void debug_dump_image(const char *prefix,
                       unsigned format, unsigned cpp,
@@ -669,10 +699,10 @@ void debug_dump_surface(const char *prefix,
       goto error;
    
    debug_dump_image(prefix, 
-                    transfer->format,
-                    transfer->block.size
-                    transfer->nblocksx,
-                    transfer->nblocksy,
+                    texture->format,
+                    util_format_get_blocksize(texture->format)
+                    util_format_get_nblocksx(texture->format, transfer->width),
+                    util_format_get_nblocksy(texture->format, transfer->height),
                     transfer->stride,
                     data);
    
index b8c56fd600c552e2cf7f5f343b4c484dbb801d6e..facc30a5534ca8f744a9fd7180caa2d7f1f8d1e9 100644 (file)
@@ -188,7 +188,7 @@ void _debug_assert_fail(const char *expr,
 #ifdef DEBUG
 #define debug_assert(expr) ((expr) ? (void)0 : _debug_assert_fail(#expr, __FILE__, __LINE__, __FUNCTION__))
 #else
-#define debug_assert(expr) ((void)0)
+#define debug_assert(expr) do { } while (0 && (expr))
 #endif
 
 
@@ -351,17 +351,6 @@ void
 debug_memory_end(unsigned long beginning);
 
 
-#if defined(PROFILE) && defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
-
-void
-debug_profile_start(void);
-
-void 
-debug_profile_stop(void);
-
-#endif
-
-
 #ifdef DEBUG
 struct pipe_surface;
 struct pipe_transfer;
index 6bdecde048e8ddfcf22ab688277fe0c6cb3df30f..61624d05c0ac359c57228480706c60013318ea65 100644 (file)
@@ -187,3 +187,81 @@ debug_dump_func_short_names[] = {
 };
 
 DEFINE_DEBUG_DUMP_CONTINUOUS(func)
+
+
+static const char *
+debug_dump_tex_target_names[] = {
+   "PIPE_TEXTURE_1D",
+   "PIPE_TEXTURE_2D",
+   "PIPE_TEXTURE_3D",
+   "PIPE_TEXTURE_CUBE"
+};
+
+static const char *
+debug_dump_tex_target_short_names[] = {
+   "1d",
+   "2d",
+   "3d",
+   "cube"
+};
+
+DEFINE_DEBUG_DUMP_CONTINUOUS(tex_target)
+
+
+static const char *
+debug_dump_tex_wrap_names[] = {
+   "PIPE_TEX_WRAP_REPEAT",
+   "PIPE_TEX_WRAP_CLAMP",
+   "PIPE_TEX_WRAP_CLAMP_TO_EDGE",
+   "PIPE_TEX_WRAP_CLAMP_TO_BORDER",
+   "PIPE_TEX_WRAP_MIRROR_REPEAT",
+   "PIPE_TEX_WRAP_MIRROR_CLAMP",
+   "PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE",
+   "PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER"
+};
+
+static const char *
+debug_dump_tex_wrap_short_names[] = {
+   "repeat",
+   "clamp",
+   "clamp_to_edge",
+   "clamp_to_border",
+   "mirror_repeat",
+   "mirror_clamp",
+   "mirror_clamp_to_edge",
+   "mirror_clamp_to_border"
+};
+
+DEFINE_DEBUG_DUMP_CONTINUOUS(tex_wrap)
+
+
+static const char *
+debug_dump_tex_mipfilter_names[] = {
+   "PIPE_TEX_MIPFILTER_NEAREST",
+   "PIPE_TEX_MIPFILTER_LINEAR",
+   "PIPE_TEX_MIPFILTER_NONE"
+};
+
+static const char *
+debug_dump_tex_mipfilter_short_names[] = {
+   "nearest",
+   "linear",
+   "none"
+};
+
+DEFINE_DEBUG_DUMP_CONTINUOUS(tex_mipfilter)
+
+
+static const char *
+debug_dump_tex_filter_names[] = {
+   "PIPE_TEX_FILTER_NEAREST",
+   "PIPE_TEX_FILTER_LINEAR"
+};
+
+static const char *
+debug_dump_tex_filter_short_names[] = {
+   "nearest",
+   "linear"
+};
+
+DEFINE_DEBUG_DUMP_CONTINUOUS(tex_filter)
index 102935559c1868fe0316131293ff435c547008e1..19b130ad18336e1b704883b9e20b3c7d2a8c7ca5 100644 (file)
@@ -54,6 +54,18 @@ debug_dump_blend_func(unsigned value, boolean shortened);
 const char *
 debug_dump_func(unsigned value, boolean shortened);
 
+const char *
+debug_dump_tex_target(unsigned value, boolean shortened);
+
+const char *
+debug_dump_tex_wrap(unsigned value, boolean shortened);
+
+const char *
+debug_dump_tex_mipfilter(unsigned value, boolean shortened);
+
+const char *
+debug_dump_tex_filter(unsigned value, boolean shortened);
+
 
 /* FIXME: Move the other debug_dump_xxx functions out of u_debug.h into here. */
 
index 7623cb93981b5beaf1d18403a2b82189b30a6ee5..d6484f4ad5184d78dc1fb4ff35f7dd450e3c551a 100644 (file)
@@ -297,9 +297,9 @@ debug_memory_end(unsigned long start_no)
 
       if((start_no <= hdr->no && hdr->no < last_no) ||
         (last_no < start_no && (hdr->no < last_no || start_no <= hdr->no))) {
-        debug_printf("%s:%u:%s: %u bytes at %p not freed\n",
+        debug_printf("%s:%u:%s: %lu bytes at %p not freed\n",
                      hdr->file, hdr->line, hdr->function,
-                     hdr->size, ptr);
+                     (unsigned long) hdr->size, ptr);
 #if DEBUG_MEMORY_STACK
         debug_backtrace_dump(hdr->backtrace, DEBUG_MEMORY_STACK);
 #endif
@@ -315,8 +315,8 @@ debug_memory_end(unsigned long start_no)
    }
 
    if(total_size) {
-      debug_printf("Total of %u KB of system memory apparently leaked\n",
-                  (total_size + 1023)/1024);
+      debug_printf("Total of %lu KB of system memory apparently leaked\n",
+                  (unsigned long) (total_size + 1023)/1024);
    }
    else {
       debug_printf("No memory leaks detected.\n");
diff --git a/src/gallium/auxiliary/util/u_debug_profile.c b/src/gallium/auxiliary/util/u_debug_profile.c
deleted file mode 100644 (file)
index d765b50..0000000
+++ /dev/null
@@ -1,320 +0,0 @@
-/**************************************************************************
- * 
- * 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.
- * 
- **************************************************************************/
-
-/**
- * @file
- * Poor-man profiling.
- * 
- * @author José Fonseca <jrfonseca@tungstengraphics.com>
- * 
- * @sa http://blogs.msdn.com/joshpoley/archive/2008/03/12/poor-man-s-profiler.aspx
- * @sa http://www.johnpanzer.com/aci_cuj/index.html
- */
-
-#include "pipe/p_config.h" 
-
-#if defined(PROFILE) && defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
-
-#include <windows.h>
-#include <winddi.h>
-
-#include "util/u_debug.h" 
-#include "util/u_string.h" 
-
-
-#define PROFILE_TABLE_SIZE (1024*1024)
-#define FILE_NAME_SIZE 256
-
-struct debug_profile_entry
-{
-   uintptr_t caller;
-   uintptr_t callee;
-   uint64_t samples;
-};
-
-static unsigned long enabled = 0;
-
-static WCHAR wFileName[FILE_NAME_SIZE] = L"\\??\\c:\\00000000.prof";
-static ULONG_PTR iFile = 0;
-
-static struct debug_profile_entry *table = NULL;
-static unsigned long free_table_entries = 0;
-static unsigned long max_table_entries = 0;
-
-uint64_t start_stamp = 0;
-uint64_t end_stamp = 0;
-
-
-static void
-debug_profile_entry(uintptr_t caller, uintptr_t callee, uint64_t samples)
-{
-   unsigned hash = ( caller + callee ) & PROFILE_TABLE_SIZE - 1;
-   
-   while(1) {
-      if(table[hash].caller == 0 && table[hash].callee == 0) {
-         table[hash].caller = caller;
-         table[hash].callee = callee;
-         table[hash].samples = samples;
-         --free_table_entries;
-         break;
-      }
-      else if(table[hash].caller == caller && table[hash].callee == callee) {
-         table[hash].samples += samples;
-         break;
-      }
-      else {
-         ++hash;
-      }
-   }
-}
-
-
-static uintptr_t caller_stack[1024];
-static unsigned last_caller = 0;
-
-
-static int64_t delta(void) {
-   int64_t result = end_stamp - start_stamp;
-   if(result > UINT64_C(0xffffffff))
-      result = 0;
-   return result;
-}
-
-
-static void __cdecl 
-debug_profile_enter(uintptr_t callee)
-{
-   uintptr_t caller = last_caller ? caller_stack[last_caller - 1] : 0;
-                
-   if (caller)
-      debug_profile_entry(caller, 0, delta());
-   debug_profile_entry(caller, callee, 1);
-   caller_stack[last_caller++] = callee;
-}
-
-
-static void __cdecl
-debug_profile_exit(uintptr_t callee)
-{
-   debug_profile_entry(callee, 0, delta());
-   if(last_caller)
-      --last_caller;
-}
-   
-   
-/**
- * Called at the start of every method or function.
- * 
- * @sa http://msdn.microsoft.com/en-us/library/c63a9b7h.aspx
- */
-void __declspec(naked) __cdecl 
-_penter(void) {
-   _asm {
-      push eax
-      mov eax, [enabled]
-      test eax, eax
-      jz skip
-
-      push edx
-      
-      rdtsc
-      mov dword ptr [end_stamp], eax
-      mov dword ptr [end_stamp+4], edx
-
-      xor eax, eax
-      mov [enabled], eax
-
-      mov eax, [esp+8]
-
-      push ebx
-      push ecx
-      push ebp
-      push edi
-      push esi
-
-      push eax
-      call debug_profile_enter
-      add esp, 4
-
-      pop esi
-      pop edi
-      pop ebp
-      pop ecx
-      pop ebx
-
-      mov eax, 1
-      mov [enabled], eax 
-
-      rdtsc
-      mov dword ptr [start_stamp], eax
-      mov dword ptr [start_stamp+4], edx
-      
-      pop edx
-skip:
-      pop eax
-      ret
-   }
-}
-
-
-/**
- * Called at the end of Calls the end of every method or function.
- * 
- * @sa http://msdn.microsoft.com/en-us/library/xc11y76y.aspx
- */
-void __declspec(naked) __cdecl 
-_pexit(void) {
-   _asm {
-      push eax
-      mov eax, [enabled]
-      test eax, eax
-      jz skip
-
-      push edx
-      
-      rdtsc
-      mov dword ptr [end_stamp], eax
-      mov dword ptr [end_stamp+4], edx
-
-      xor eax, eax
-      mov [enabled], eax
-
-      mov eax, [esp+8]
-
-      push ebx
-      push ecx
-      push ebp
-      push edi
-      push esi
-
-      push eax
-      call debug_profile_exit
-      add esp, 4
-
-      pop esi
-      pop edi
-      pop ebp
-      pop ecx
-      pop ebx
-
-      mov eax, 1
-      mov [enabled], eax 
-
-      rdtsc
-      mov dword ptr [start_stamp], eax
-      mov dword ptr [start_stamp+4], edx
-      
-      pop edx
-skip:
-      pop eax
-      ret
-   }
-}
-
-
-/**
- * Reference function for calibration. 
- */
-void __declspec(naked) 
-__debug_profile_reference(void) {
-   _asm {
-      call _penter
-      call _pexit
-      ret
-   }
-}
-
-
-void
-debug_profile_start(void)
-{
-   WCHAR *p;
-
-   /* increment starting from the less significant digit */
-   p = &wFileName[14];
-   while(1) {
-      if(*p == '9') {
-         *p-- = '0';
-      }
-      else {
-         *p += 1;
-         break;
-      }
-   }
-
-   table = EngMapFile(wFileName, 
-                      PROFILE_TABLE_SIZE*sizeof(struct debug_profile_entry), 
-                      &iFile);
-   if(table) {
-      unsigned i;
-      
-      free_table_entries = max_table_entries = PROFILE_TABLE_SIZE;
-      memset(table, 0, PROFILE_TABLE_SIZE*sizeof(struct debug_profile_entry));
-      
-      table[0].caller = (uintptr_t)&__debug_profile_reference;
-      table[0].callee = 0;
-      table[0].samples = 0;
-      --free_table_entries;
-
-      _asm {
-         push edx
-         push eax
-      
-         rdtsc
-         mov dword ptr [start_stamp], eax
-         mov dword ptr [start_stamp+4], edx
-         
-         pop edx
-         pop eax
-      }
-
-      last_caller = 0;
-      
-      enabled = 1;
-
-      for(i = 0; i < 8; ++i) {
-         _asm {
-            call __debug_profile_reference
-         }
-      }
-   }
-}
-
-
-void 
-debug_profile_stop(void)
-{
-   enabled = 0;
-
-   if(iFile)
-      EngUnmapFile(iFile);
-   iFile = 0;
-   table = NULL;
-   free_table_entries = max_table_entries = 0;
-}
-
-#endif /* PROFILE */
diff --git a/src/gallium/auxiliary/util/u_dl.c b/src/gallium/auxiliary/util/u_dl.c
new file mode 100644 (file)
index 0000000..b42b429
--- /dev/null
@@ -0,0 +1,79 @@
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc.
+ * Copyright 1999-2008  Brian Paul
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or 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.
+ *
+ **************************************************************************/
+
+
+#include "pipe/p_config.h"
+
+#if defined(PIPE_OS_UNIX)
+#include <dlfcn.h>
+#endif
+#if defined(PIPE_OS_WINDOWS)
+#include <windows.h>
+#endif
+
+#include "u_dl.h"
+
+
+struct util_dl_library *
+util_dl_open(const char *filename)
+{
+#if defined(PIPE_OS_UNIX)
+   return (struct util_dl_library *)dlopen(filename, RTLD_LAZY | RTLD_GLOBAL);
+#elif defined(PIPE_OS_WINDOWS)
+   return (struct util_dl_library *)LoadLibraryA(filename);
+#else
+   return NULL;
+#endif
+}
+
+
+util_dl_proc
+util_dl_get_proc_address(struct util_dl_library *library,
+                         const char *procname)
+{
+#if defined(PIPE_OS_UNIX)
+   return (util_dl_proc)dlsym((void *)library, procname);
+#elif defined(PIPE_OS_WINDOWS)
+   return (util_dl_proc)GetProcAddress((HMODULE)library, procname);
+#else
+   return (util_dl_proc)NULL;
+#endif
+}
+
+
+void
+util_dl_close(struct util_dl_library *library)
+{
+#if defined(PIPE_OS_UNIX)
+   dlclose((void *)library);
+#elif defined(PIPE_OS_WINDOWS)
+   FreeLibrary((HMODULE)library);
+#else
+   (void)library;
+#endif
+}
diff --git a/src/gallium/auxiliary/util/u_dl.h b/src/gallium/auxiliary/util/u_dl.h
new file mode 100644 (file)
index 0000000..85296c5
--- /dev/null
@@ -0,0 +1,73 @@
+/**************************************************************************
+ *
+ * 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 SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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.
+ *
+ **************************************************************************/
+
+
+#ifndef U_DL_H_
+#define U_DL_H_
+
+
+#include "pipe/p_config.h"
+
+
+#if defined(PIPE_OS_WINDOWS)
+#  define UTIL_DL_EXT ".dll"
+#elif defined(PIPE_OS_APPLE)
+#  define UTIL_DL_EXT ".dylib"
+#else
+#  define UTIL_DL_EXT ".so"
+#endif
+
+
+struct util_dl_library;
+
+
+typedef void (*util_dl_proc)(void);
+
+
+/**
+ * Open a library dynamically.
+ */
+struct util_dl_library *
+util_dl_open(const char *filename);
+
+
+/**
+ * Lookup a function in a library.
+ */
+util_dl_proc
+util_dl_get_proc_address(struct util_dl_library *library,
+                         const char *procname);
+
+
+/**
+ * Close a library.
+ */
+void
+util_dl_close(struct util_dl_library *library);
+
+
+#endif /* U_DL_H_ */
index 98ea13b60b50e2ada5c30c1498073252da130c3e..e0724a1a8be909a09f8742d2e40c58e386f9adb3 100644 (file)
 const struct util_format_description *
 util_format_description(enum pipe_format format)
 {
-   const struct util_format_description *desc = util_format_description_table;
+   const struct util_format_description *desc;
 
-   while(TRUE) {
-      if(desc->format == format)
-         return desc;
+   if (format >= PIPE_FORMAT_COUNT) {
+      return NULL;
+   }
 
-      if(desc->format == PIPE_FORMAT_NONE)
-         return NULL;
+   desc = &util_format_description_table[format];
+   assert(desc->format == format);
 
-      ++desc;
-   };
+   return desc;
 }
index f1bf94f17ddc6f15487d3b5139898979c8f7544f..9f16b42944e4237e244ab8cdfd3707e4264486ec 100644 (file)
@@ -11,6 +11,8 @@ PIPE_FORMAT_A8_UNORM              , arith , 1, 1, un8 ,     ,     ,     , 000x,
 PIPE_FORMAT_I8_UNORM              , arith , 1, 1, un8 ,     ,     ,     , xxxx, rgb
 PIPE_FORMAT_A8L8_UNORM            , arith , 1, 1, un8 , un8 ,     ,     , xxxy, rgb
 PIPE_FORMAT_L16_UNORM             , arith , 1, 1, un16,     ,     ,     , xxx1, rgb
+PIPE_FORMAT_YCBCR                 , yuv   , 2, 1, x32 ,     ,     ,     , xyz1, yuv
+PIPE_FORMAT_YCBCR_REV             , yuv   , 2, 1, x32 ,     ,     ,     , xyz1, yuv
 PIPE_FORMAT_Z16_UNORM             , array , 1, 1, un16,     ,     ,     , x___, zs 
 PIPE_FORMAT_Z32_UNORM             , array , 1, 1, un32,     ,     ,     , x___, zs 
 PIPE_FORMAT_Z32_FLOAT             , array , 1, 1, f32 ,     ,     ,     , x___, zs 
@@ -74,9 +76,9 @@ PIPE_FORMAT_R8G8_SNORM            , array , 1, 1, sn8 , sn8 ,     ,     , xy01,
 PIPE_FORMAT_R8G8B8_SNORM          , array , 1, 1, sn8 , sn8 , sn8 ,     , xyz1, rgb
 PIPE_FORMAT_R8G8B8A8_SNORM        , array , 1, 1, sn8 , sn8 , sn8 , sn8 , xyzw, rgb
 PIPE_FORMAT_R8G8B8X8_SNORM        , array , 1, 1, sn8 , sn8 , sn8 , sn8 , xyz1, rgb
-PIPE_FORMAT_B6G5R5_SNORM          , arith , 1, 1, sn5 , sn5 , sn6 ,     , zyx1, rgb
-PIPE_FORMAT_A8B8G8R8_SNORM        , arith , 1, 1, sn8 , sn8 , sn8 , sn8 , zyxw, rgb
-PIPE_FORMAT_X8B8G8R8_SNORM        , arith , 1, 1, sn8 , sn8 , sn8 , sn8 , zyx1, rgb
+PIPE_FORMAT_B6G5R5_SNORM          , arith , 1, 1, sn5 , sn5 , sn6 ,     , xyz1, rgb
+PIPE_FORMAT_A8B8G8R8_SNORM        , array , 1, 1, sn8 , sn8 , sn8 , sn8 , wzyx, rgb
+PIPE_FORMAT_X8B8G8R8_SNORM        , array , 1, 1, sn8 , sn8 , sn8 , sn8 , wzy1, rgb
 PIPE_FORMAT_R8_SSCALED            , array , 1, 1, s8  ,     ,     ,     , x001, rgb
 PIPE_FORMAT_R8G8_SSCALED          , array , 1, 1, s8  , s8  ,     ,     , xy01, rgb
 PIPE_FORMAT_R8G8B8_SSCALED        , array , 1, 1, s8  , s8  , s8  ,     , xyz1, rgb
@@ -88,12 +90,20 @@ PIPE_FORMAT_R32G32B32_FIXED       , array , 1, 1, h32 , h32 , h32 ,     , xyz1,
 PIPE_FORMAT_R32G32B32A32_FIXED    , array , 1, 1, h32 , h32 , h32 , h32 , xyzw, rgb
 PIPE_FORMAT_L8_SRGB               , arith , 1, 1, u8  ,     ,     ,     , xxx1, srgb 
 PIPE_FORMAT_A8L8_SRGB             , arith , 1, 1, u8  , u8  ,     ,     , xxxy, srgb 
-PIPE_FORMAT_R8G8B8_SRGB           , arith , 1, 1, u8  , u8  , u8  ,     , xyz1, srgb 
-PIPE_FORMAT_R8G8B8A8_SRGB         , arith , 1, 1, u8  , u8  , u8  , u8  , xyzw, srgb 
-PIPE_FORMAT_R8G8B8X8_SRGB         , arith , 1, 1, u8  , u8  , u8  , u8  , xyz1, srgb 
-PIPE_FORMAT_A8R8G8B8_SRGB         , arith , 1, 1, u8  , u8  , u8  , u8  , wxyz, srgb 
-PIPE_FORMAT_X8R8G8B8_SRGB         , arith , 1, 1, u8  , u8  , u8  , u8  , 1xyz, srgb 
-PIPE_FORMAT_B8G8R8A8_SRGB         , arith , 1, 1, u8  , u8  , u8  , u8  , zyxw, srgb 
-PIPE_FORMAT_B8G8R8X8_SRGB         , arith , 1, 1, u8  , u8  , u8  , u8  , zyx1, srgb 
-PIPE_FORMAT_X8UB8UG8SR8S_NORM     , arith , 1, 1, sn8 , sn8 , un8 , x8  , 1zyx, rgb
+PIPE_FORMAT_R8G8B8_SRGB           , array , 1, 1, u8  , u8  , u8  ,     , xyz1, srgb 
+PIPE_FORMAT_R8G8B8A8_SRGB         , array , 1, 1, u8  , u8  , u8  , u8  , xyzw, srgb 
+PIPE_FORMAT_R8G8B8X8_SRGB         , array , 1, 1, u8  , u8  , u8  , u8  , xyz1, srgb 
+PIPE_FORMAT_A8R8G8B8_SRGB         , array , 1, 1, u8  , u8  , u8  , u8  , yzwx, srgb 
+PIPE_FORMAT_X8R8G8B8_SRGB         , array , 1, 1, u8  , u8  , u8  , u8  , yzw1, srgb 
+PIPE_FORMAT_B8G8R8A8_SRGB         , array , 1, 1, u8  , u8  , u8  , u8  , zyxw, srgb 
+PIPE_FORMAT_B8G8R8X8_SRGB         , array , 1, 1, u8  , u8  , u8  , u8  , zyx1, srgb 
+PIPE_FORMAT_X8UB8UG8SR8S_NORM     , array , 1, 1, sn8 , sn8 , un8 , x8  , wzy1, rgb
 PIPE_FORMAT_B6UG5SR5S_NORM        , arith , 1, 1, sn5 , sn5 , un6 ,     , xyz1, rgb
+PIPE_FORMAT_DXT1_RGB              , dxt   , 4, 4, x64 ,     ,     ,     , xyz1, rgb
+PIPE_FORMAT_DXT1_RGBA             , dxt   , 4, 4, x64 ,     ,     ,     , xyzw, rgb
+PIPE_FORMAT_DXT3_RGBA             , dxt   , 4, 4, x128,     ,     ,     , xyzw, rgb
+PIPE_FORMAT_DXT5_RGBA             , dxt   , 4, 4, x128,     ,     ,     , xyzw, rgb
+PIPE_FORMAT_DXT1_SRGB             , dxt   , 4, 4, x64 ,     ,     ,     , xyz1, srgb
+PIPE_FORMAT_DXT1_SRGBA            , dxt   , 4, 4, x64 ,     ,     ,     , xyzw, srgb
+PIPE_FORMAT_DXT3_SRGBA            , dxt   , 4, 4, x128,     ,     ,     , xyzw, srgb
+PIPE_FORMAT_DXT5_SRGBA            , dxt   , 4, 4, x128,     ,     ,     , xyzw, srgb
index 7b5b7fcda5bea8018339af61aed20e7399db1b0b..a558923b2eda6e1e5837379dcaf134753400f8c6 100644 (file)
 
 #include "pipe/p_format.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 
+
+/**
+ * Describe how to best pack/unpack pixels into/from the prescribed format.
+ *
+ * These are used for automatic code generation of pixel packing and unpacking
+ * routines (in compile time, e.g., u_format_access.py, or in runtime, like
+ * llvmpipe does).
+ *
+ * Thumb rule is: if you're not code generating pixel packing/unpacking then
+ * these are irrelevant for you.
+ *
+ * Note that this can be deduced from other values in util_format_description
+ * structure. This is by design, to make code generation of pixel
+ * packing/unpacking/sampling routines simple and efficient.
+ *
+ * XXX: This should be renamed to something like util_format_pack.
+ */
 enum util_format_layout {
+   /**
+    * Single scalar component.
+    */
    UTIL_FORMAT_LAYOUT_SCALAR = 0,
+
+   /**
+    * One or more components of mixed integer formats, arithmetically encoded
+    * in a word up to 32bits.
+    */
    UTIL_FORMAT_LAYOUT_ARITH = 1,
+
+   /**
+    * One or more components, no mixed formats, each with equal power of two
+    * number of bytes.
+    */
    UTIL_FORMAT_LAYOUT_ARRAY = 2,
+
+   /**
+    * XXX: Not used yet. These might go away and be replaced by a single entry,
+    * for formats where multiple pixels have to be
+    * read in order to determine a single pixel value (i.e., block.width > 1
+    * || block.height > 1)
+    */
    UTIL_FORMAT_LAYOUT_YUV = 3,
    UTIL_FORMAT_LAYOUT_DXT = 4
 };
@@ -50,7 +90,7 @@ struct util_format_block
    /** Block height in pixels */
    unsigned height;
 
-   /** Block size in bytes */
+   /** Block size in bits */
    unsigned bits;
 };
 
@@ -79,7 +119,7 @@ enum util_format_colorspace {
    UTIL_FORMAT_COLORSPACE_RGB = 0,
    UTIL_FORMAT_COLORSPACE_SRGB = 1,
    UTIL_FORMAT_COLORSPACE_YUV = 2,
-   UTIL_FORMAT_COLORSPACE_ZS = 3,
+   UTIL_FORMAT_COLORSPACE_ZS = 3
 };
 
 
@@ -111,6 +151,250 @@ const struct util_format_description *
 util_format_description(enum pipe_format format);
 
 
+/*
+ * Format query functions.
+ */
+
+static INLINE boolean 
+util_format_is_compressed(enum pipe_format format)
+{
+   const struct util_format_description *desc = util_format_description(format);
+
+   assert(format);
+   if (!format) {
+      return FALSE;
+   }
+
+   return desc->layout == UTIL_FORMAT_LAYOUT_DXT ? TRUE : FALSE;
+}
+
+static INLINE boolean 
+util_format_is_depth_or_stencil(enum pipe_format format)
+{
+   const struct util_format_description *desc = util_format_description(format);
+
+   assert(format);
+   if (!format) {
+      return FALSE;
+   }
+
+   return desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS ? TRUE : FALSE;
+}
+
+static INLINE boolean 
+util_format_is_depth_and_stencil(enum pipe_format format)
+{
+   const struct util_format_description *desc = util_format_description(format);
+
+   assert(format);
+   if (!format) {
+      return FALSE;
+   }
+
+   if (desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS) {
+      return FALSE;
+   }
+
+   return (desc->swizzle[0] != UTIL_FORMAT_SWIZZLE_NONE &&
+           desc->swizzle[1] != UTIL_FORMAT_SWIZZLE_NONE) ? TRUE : FALSE;
+}
+
+
+/**
+ * Return total bits needed for the pixel format per block.
+ */
+static INLINE uint
+util_format_get_blocksizebits(enum pipe_format format)
+{
+   const struct util_format_description *desc = util_format_description(format);
+
+   assert(format);
+   if (!format) {
+      return 0;
+   }
+
+   return desc->block.bits;
+}
+
+/**
+ * Return bytes per block (not pixel) for the given format.
+ */
+static INLINE uint
+util_format_get_blocksize(enum pipe_format format)
+{
+   uint bits = util_format_get_blocksizebits(format);
+
+   assert(bits % 8 == 0);
+
+   return bits / 8;
+}
+
+static INLINE uint
+util_format_get_blockwidth(enum pipe_format format)
+{
+   const struct util_format_description *desc = util_format_description(format);
+
+   assert(format);
+   if (!format) {
+      return 1;
+   }
+
+   switch (desc->layout) {
+   case UTIL_FORMAT_LAYOUT_YUV:
+      return 2;
+   case UTIL_FORMAT_LAYOUT_DXT:
+      return 4;
+   default:
+      return 1;
+   }
+}
+
+static INLINE uint
+util_format_get_blockheight(enum pipe_format format)
+{
+   const struct util_format_description *desc = util_format_description(format);
+
+   assert(format);
+   if (!format) {
+      return 1;
+   }
+
+   switch (desc->layout) {
+   case UTIL_FORMAT_LAYOUT_DXT:
+      return 4;
+   default:
+      return 1;
+   }
+}
+
+static INLINE unsigned
+util_format_get_nblocksx(enum pipe_format format,
+                         unsigned x)
+{
+   unsigned blockwidth = util_format_get_blockwidth(format);
+   return (x + blockwidth - 1) / blockwidth;
+}
+
+static INLINE unsigned
+util_format_get_nblocksy(enum pipe_format format,
+                         unsigned y)
+{
+   unsigned blockheight = util_format_get_blockheight(format);
+   return (y + blockheight - 1) / blockheight;
+}
+
+static INLINE unsigned
+util_format_get_nblocks(enum pipe_format format,
+                        unsigned width,
+                        unsigned height)
+{
+   return util_format_get_nblocksx(format, width) * util_format_get_nblocksy(format, height);
+}
+
+static INLINE size_t
+util_format_get_stride(enum pipe_format format,
+                       unsigned width)
+{
+   return util_format_get_nblocksx(format, width) * util_format_get_blocksize(format);
+}
+
+static INLINE size_t
+util_format_get_2d_size(enum pipe_format format,
+                        size_t stride,
+                        unsigned height)
+{
+   return util_format_get_nblocksy(format, height) * stride;
+}
+
+static INLINE uint
+util_format_get_component_bits(enum pipe_format format,
+                               enum util_format_colorspace colorspace,
+                               uint component)
+{
+   const struct util_format_description *desc = util_format_description(format);
+   enum util_format_colorspace desc_colorspace;
+
+   assert(format);
+   if (!format) {
+      return 0;
+   }
+
+   assert(component < 4);
+
+   /* Treat RGB and SRGB as equivalent. */
+   if (colorspace == UTIL_FORMAT_COLORSPACE_SRGB) {
+      colorspace = UTIL_FORMAT_COLORSPACE_RGB;
+   }
+   if (desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) {
+      desc_colorspace = UTIL_FORMAT_COLORSPACE_RGB;
+   } else {
+      desc_colorspace = desc->colorspace;
+   }
+
+   if (desc_colorspace != colorspace) {
+      return 0;
+   }
+
+   switch (desc->swizzle[component]) {
+   case UTIL_FORMAT_SWIZZLE_X:
+      return desc->channel[0].size;
+   case UTIL_FORMAT_SWIZZLE_Y:
+      return desc->channel[1].size;
+   case UTIL_FORMAT_SWIZZLE_Z:
+      return desc->channel[2].size;
+   case UTIL_FORMAT_SWIZZLE_W:
+      return desc->channel[3].size;
+   default:
+      return 0;
+   }
+}
+
+static INLINE boolean
+util_format_has_alpha(enum pipe_format format)
+{
+   const struct util_format_description *desc = util_format_description(format);
+
+   assert(format);
+   if (!format) {
+      return FALSE;
+   }
+
+   switch (desc->layout) {
+   case UTIL_FORMAT_LAYOUT_SCALAR:
+   case UTIL_FORMAT_LAYOUT_ARITH:
+   case UTIL_FORMAT_LAYOUT_ARRAY:
+      /* FIXME: pf_get_component_bits( PIPE_FORMAT_A8L8_UNORM, PIPE_FORMAT_COMP_A ) should not return 0 right? */
+      if (format == PIPE_FORMAT_A8_UNORM ||
+          format == PIPE_FORMAT_A8L8_UNORM ||
+          format == PIPE_FORMAT_A8L8_SRGB) {
+         return TRUE;
+      }
+      return util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 3) != 0;
+   case UTIL_FORMAT_LAYOUT_YUV:
+      return FALSE;
+   case UTIL_FORMAT_LAYOUT_DXT:
+      switch (format) {
+      case PIPE_FORMAT_DXT1_RGBA:
+      case PIPE_FORMAT_DXT3_RGBA:
+      case PIPE_FORMAT_DXT5_RGBA:
+      case PIPE_FORMAT_DXT1_SRGBA:
+      case PIPE_FORMAT_DXT3_SRGBA:
+      case PIPE_FORMAT_DXT5_SRGBA:
+         return TRUE;
+      default:
+         return FALSE;
+      }
+   default:
+      assert(0);
+      return FALSE;
+   }
+}
+
+
+/*
+ * Format access functions.
+ */
+
 void
 util_format_read_4f(enum pipe_format format,
                     float *dst, unsigned dst_stride, 
@@ -135,4 +419,8 @@ util_format_write_4ub(enum pipe_format format,
                       void *dst, unsigned dst_stride, 
                       unsigned x, unsigned y, unsigned w, unsigned h);
 
+#ifdef __cplusplus
+} // extern "C" {
+#endif
+
 #endif /* ! U_FORMAT_H */
index eeb1a9657fd05ce5fdcce2a8f162dee9f290e31b..0b05ddb9312c700911b3073177fb6b1412bbbdd8 100644 (file)
@@ -325,14 +325,14 @@ def generate_format_read(format, dst_type, dst_native_type, dst_suffix):
             elif swizzle == SWIZZLE_0:
                 value = '0'
             elif swizzle == SWIZZLE_1:
-                value = '1'
+                value = get_one(dst_type)
             else:
                 assert False
         elif format.colorspace == 'zs':
             if i < 3:
                 value = 'z'
             else:
-                value = '1'
+                value = get_one(dst_type)
         else:
             assert False
         print '         *dst_pixel++ = %s; /* %s */' % (value, 'rgba'[i])
index 8834568e8ee607022381eef0bd5a85c6388d3e77..571cab55dc8ffa30361a8b355e2d5b04fa461553 100755 (executable)
@@ -44,11 +44,10 @@ def colorspace_map(colorspace):
 
 
 colorspace_channels_map = {
-    'rgb': 'rgba',
-    'rgba': 'rgba',
-    'zs': 'zs',
-    'yuv': ['y1', 'y2', 'u', 'v'],
-    'dxt': []
+    'rgb': ['r', 'g', 'b', 'a'],
+    'srgb': ['sr', 'sg', 'sb', 'a'],
+    'zs': ['z', 's'],
+    'yuv': ['y', 'u', 'v'],
 }
 
 
@@ -90,11 +89,20 @@ def write_format_table(formats):
     print 'const struct util_format_description'
     print 'util_format_description_table[] = '
     print "{"
+    print "   {"
+    print "      PIPE_FORMAT_NONE,"
+    print "      \"PIPE_FORMAT_NONE\","
+    print "      {0, 0, 0},"
+    print "      0,"
+    print "      {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}},"
+    print "      {0, 0, 0, 0},"
+    print "      0"
+    print "   },"
     for format in formats:
         print "   {"
         print "      %s," % (format.name,)
         print "      \"%s\"," % (format.name,)
-        print "      {%u, %u, %u}, /* block */" % (format.block_width, format.block_height, format.block_size())
+        print "      {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size())
         print "      %s," % (layout_map(format.layout),)
         print "      {"
         for i in range(4):
@@ -103,7 +111,7 @@ def write_format_table(formats):
                 sep = ","
             else:
                 sep = ""
-            print "         {%s, %s, %u}%s /* %s */" % (kind_map[type.kind], bool_map(type.norm), type.size, sep, "xyzw"[i])
+            print "         {%s, %s, %u}%s\t/* %s */" % (kind_map[type.kind], bool_map(type.norm), type.size, sep, "xyzw"[i])
         print "      },"
         print "      {"
         for i in range(4):
@@ -113,22 +121,13 @@ def write_format_table(formats):
             else:
                 sep = ""
             try:
-                comment = layout_channels_map[format.layout][i]
-            except:
+                comment = colorspace_channels_map[format.colorspace][i]
+            except (KeyError, IndexError):
                 comment = 'ignored'
-            print "         %s%s /* %s */" % (swizzle_map[swizzle], sep, comment)
+            print "         %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment)
         print "      },"
         print "      %s," % (colorspace_map(format.colorspace),)
         print "   },"
-    print "   {"
-    print "      PIPE_FORMAT_NONE,"
-    print "      \"PIPE_FORMAT_NONE\","
-    print "      {0, 0, 0},"
-    print "      0,"
-    print "      {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}},"
-    print "      {0, 0, 0, 0},"
-    print "      0"
-    print "   },"
     print "};"
 
 
index aa823aa218bde6f95f6f0bc683cec9fae5955c1e..76023794dcdaecdacb0cea2a509c17bf0b037105 100644 (file)
 #include "pipe/p_shader_tokens.h"
 #include "pipe/p_state.h"
 
+#include "util/u_format.h"
 #include "util/u_memory.h"
 #include "util/u_draw_quad.h"
 #include "util/u_gen_mipmap.h"
 #include "util/u_simple_shaders.h"
+#include "util/u_math.h"
+#include "util/u_texture.h"
 
 #include "cso_cache/cso_context.h"
 
@@ -60,7 +63,7 @@ struct gen_mipmap_state
    struct pipe_sampler_state sampler;
 
    void *vs;
-   void *fs;
+   void *fs2d, *fsCube;
 
    struct pipe_buffer *vbuf;  /**< quad vertices */
    unsigned vbuf_slot;
@@ -995,7 +998,7 @@ reduce_2d(enum pipe_format pformat,
 {
    enum dtype datatype;
    uint comps;
-   const int bpt = pf_get_size(pformat);
+   const int bpt = util_format_get_blocksize(pformat);
    const ubyte *srcA, *srcB;
    ubyte *dst;
    int row;
@@ -1034,7 +1037,7 @@ reduce_3d(enum pipe_format pformat,
           int dstWidth, int dstHeight, int dstDepth,
           int dstRowStride, ubyte *dstPtr)
 {
-   const int bpt = pf_get_size(pformat);
+   const int bpt = util_format_get_blocksize(pformat);
    const int border = 0;
    int img, row;
    int bytesPerSrcImage, bytesPerDstImage;
@@ -1125,12 +1128,12 @@ make_1d_mipmap(struct gen_mipmap_state *ctx,
       
       srcTrans = screen->get_tex_transfer(screen, pt, face, srcLevel, zslice,
                                           PIPE_TRANSFER_READ, 0, 0,
-                                          pt->width[srcLevel],
-                                          pt->height[srcLevel]);
+                                          u_minify(pt->width0, srcLevel),
+                                          u_minify(pt->height0, srcLevel));
       dstTrans = screen->get_tex_transfer(screen, pt, face, dstLevel, zslice,
                                           PIPE_TRANSFER_WRITE, 0, 0,
-                                          pt->width[dstLevel],
-                                          pt->height[dstLevel]);
+                                          u_minify(pt->width0, dstLevel),
+                                          u_minify(pt->height0, dstLevel));
 
       srcMap = (ubyte *) screen->transfer_map(screen, srcTrans);
       dstMap = (ubyte *) screen->transfer_map(screen, dstTrans);
@@ -1158,8 +1161,8 @@ make_2d_mipmap(struct gen_mipmap_state *ctx,
    const uint zslice = 0;
    uint dstLevel;
    
-   assert(pt->block.width == 1);
-   assert(pt->block.height == 1);
+   assert(util_format_get_blockwidth(pt->format) == 1);
+   assert(util_format_get_blockheight(pt->format) == 1);
 
    for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) {
       const uint srcLevel = dstLevel - 1;
@@ -1168,12 +1171,12 @@ make_2d_mipmap(struct gen_mipmap_state *ctx,
       
       srcTrans = screen->get_tex_transfer(screen, pt, face, srcLevel, zslice,
                                           PIPE_TRANSFER_READ, 0, 0,
-                                          pt->width[srcLevel],
-                                          pt->height[srcLevel]);
+                                          u_minify(pt->width0, srcLevel),
+                                          u_minify(pt->height0, srcLevel));
       dstTrans = screen->get_tex_transfer(screen, pt, face, dstLevel, zslice,
                                           PIPE_TRANSFER_WRITE, 0, 0,
-                                          pt->width[dstLevel],
-                                          pt->height[dstLevel]);
+                                          u_minify(pt->width0, dstLevel),
+                                          u_minify(pt->height0, dstLevel));
 
       srcMap = (ubyte *) screen->transfer_map(screen, srcTrans);
       dstMap = (ubyte *) screen->transfer_map(screen, dstTrans);
@@ -1203,8 +1206,8 @@ make_3d_mipmap(struct gen_mipmap_state *ctx,
    struct pipe_screen *screen = pipe->screen;
    uint dstLevel, zslice = 0;
 
-   assert(pt->block.width == 1);
-   assert(pt->block.height == 1);
+   assert(util_format_get_blockwidth(pt->format) == 1);
+   assert(util_format_get_blockheight(pt->format) == 1);
 
    for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) {
       const uint srcLevel = dstLevel - 1;
@@ -1213,12 +1216,12 @@ make_3d_mipmap(struct gen_mipmap_state *ctx,
       
       srcTrans = screen->get_tex_transfer(screen, pt, face, srcLevel, zslice,
                                           PIPE_TRANSFER_READ, 0, 0,
-                                          pt->width[srcLevel],
-                                          pt->height[srcLevel]);
+                                          u_minify(pt->width0, srcLevel),
+                                          u_minify(pt->height0, srcLevel));
       dstTrans = screen->get_tex_transfer(screen, pt, face, dstLevel, zslice,
                                           PIPE_TRANSFER_WRITE, 0, 0,
-                                          pt->width[dstLevel],
-                                          pt->height[dstLevel]);
+                                          u_minify(pt->width0, dstLevel),
+                                          u_minify(pt->height0, dstLevel));
 
       srcMap = (ubyte *) screen->transfer_map(screen, srcTrans);
       dstMap = (ubyte *) screen->transfer_map(screen, dstTrans);
@@ -1316,7 +1319,8 @@ util_create_gen_mipmap(struct pipe_context *pipe,
    }
 
    /* fragment shader */
-   ctx->fs = util_make_fragment_tex_shader(pipe);
+   ctx->fs2d = util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_2D);
+   ctx->fsCube = util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_CUBE);
 
    /* vertex data that doesn't change */
    for (i = 0; i < 4; i++) {
@@ -1382,59 +1386,9 @@ set_vertex_data(struct gen_mipmap_state *ctx,
       static const float st[4][2] = {
          {0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 1.0f}
       };
-      float rx, ry, rz;
-      uint i;
-
-      /* loop over quad verts */
-      for (i = 0; i < 4; i++) {
-         /* Compute sc = +/-scale and tc = +/-scale.
-          * Not +/-1 to avoid cube face selection ambiguity near the edges,
-          * though that can still sometimes happen with this scale factor...
-          */
-         const float scale = 0.9999f;
-         const float sc = (2.0f * st[i][0] - 1.0f) * scale;
-         const float tc = (2.0f * st[i][1] - 1.0f) * scale;
-
-         switch (face) {
-         case PIPE_TEX_FACE_POS_X:
-            rx = 1.0f;
-            ry = -tc;
-            rz = -sc;
-            break;
-         case PIPE_TEX_FACE_NEG_X:
-            rx = -1.0f;
-            ry = -tc;
-            rz = sc;
-            break;
-         case PIPE_TEX_FACE_POS_Y:
-            rx = sc;
-            ry = 1.0f;
-            rz = tc;
-            break;
-         case PIPE_TEX_FACE_NEG_Y:
-            rx = sc;
-            ry = -1.0f;
-            rz = -tc;
-            break;
-         case PIPE_TEX_FACE_POS_Z:
-            rx = sc;
-            ry = -tc;
-            rz = 1.0f;
-            break;
-         case PIPE_TEX_FACE_NEG_Z:
-            rx = -sc;
-            ry = -tc;
-            rz = -1.0f;
-            break;
-         default:
-            rx = ry = rz = 0.0f;
-            assert(0);
-         }
 
-         ctx->vertices[i][1][0] = rx; /*s*/
-         ctx->vertices[i][1][1] = ry; /*t*/
-         ctx->vertices[i][1][2] = rz; /*r*/
-      }
+      util_map_texcoords2d_onto_cubemap(face, &st[0][0], 2,
+                                        &ctx->vertices[0][1][0], 8);
    }
    else {
       /* 1D/2D */
@@ -1474,7 +1428,8 @@ util_destroy_gen_mipmap(struct gen_mipmap_state *ctx)
    struct pipe_context *pipe = ctx->pipe;
 
    pipe->delete_vs_state(pipe, ctx->vs);
-   pipe->delete_fs_state(pipe, ctx->fs);
+   pipe->delete_fs_state(pipe, ctx->fs2d);
+   pipe->delete_fs_state(pipe, ctx->fsCube);
 
    pipe_buffer_reference(&ctx->vbuf, NULL);
 
@@ -1512,6 +1467,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
    struct pipe_context *pipe = ctx->pipe;
    struct pipe_screen *screen = pipe->screen;
    struct pipe_framebuffer_state fb;
+   void *fs = (pt->target == PIPE_TEXTURE_CUBE) ? ctx->fsCube : ctx->fs2d;
    uint dstLevel;
    uint zslice = 0;
    uint offset;
@@ -1549,7 +1505,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
    cso_set_depth_stencil_alpha(ctx->cso, &ctx->depthstencil);
    cso_set_rasterizer(ctx->cso, &ctx->rasterizer);
 
-   cso_set_fragment_shader_handle(ctx->cso, ctx->fs);
+   cso_set_fragment_shader_handle(ctx->cso, fs);
    cso_set_vertex_shader_handle(ctx->cso, ctx->vs);
 
    /* init framebuffer state */
@@ -1575,8 +1531,8 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
        * Setup framebuffer / dest surface
        */
       fb.cbufs[0] = surf;
-      fb.width = pt->width[dstLevel];
-      fb.height = pt->height[dstLevel];
+      fb.width = u_minify(pt->width0, dstLevel);
+      fb.height = u_minify(pt->height0, dstLevel);
       cso_set_framebuffer(ctx->cso, &fb);
 
       /*
@@ -1597,8 +1553,8 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
       offset = set_vertex_data(ctx,
                                pt->target,
                                face,
-                               (float) pt->width[dstLevel],
-                               (float) pt->height[dstLevel]);
+                               (float) u_minify(pt->width0, dstLevel),
+                               (float) u_minify(pt->height0, dstLevel));
 
       util_draw_vertex_buffer(ctx->pipe, 
                               ctx->vbuf,
index 8c2a8f454cc64a5cf67b66df230fe4b828d4e582..5604e3ac3746dfc10a861f58937125c1eddb8ee3 100644 (file)
@@ -47,7 +47,7 @@
 #include "util/u_hash_table.h"
 
 
-struct hash_table
+struct util_hash_table
 {
    struct cso_hash *cso;   
    
@@ -61,27 +61,27 @@ struct hash_table
 };
 
 
-struct hash_table_item
+struct util_hash_table_item
 {
    void *key;
    void *value;
 };
 
 
-static INLINE struct hash_table_item *
-hash_table_item(struct cso_hash_iter iter)
+static INLINE struct util_hash_table_item *
+util_hash_table_item(struct cso_hash_iter iter)
 {
-   return (struct hash_table_item *)cso_hash_iter_data(iter);
+   return (struct util_hash_table_item *)cso_hash_iter_data(iter);
 }
 
 
-struct hash_table *
-hash_table_create(unsigned (*hash)(void *key),
-                  int (*compare)(void *key1, void *key2))
+struct util_hash_table *
+util_hash_table_create(unsigned (*hash)(void *key),
+                       int (*compare)(void *key1, void *key2))
 {
-   struct hash_table *ht;
+   struct util_hash_table *ht;
    
-   ht = MALLOC_STRUCT(hash_table);
+   ht = MALLOC_STRUCT(util_hash_table);
    if(!ht)
       return NULL;
    
@@ -99,16 +99,16 @@ hash_table_create(unsigned (*hash)(void *key),
 
 
 static INLINE struct cso_hash_iter
-hash_table_find_iter(struct hash_table *ht,
-                     void *key, 
-                     unsigned key_hash)
+util_hash_table_find_iter(struct util_hash_table *ht,
+                          void *key,
+                          unsigned key_hash)
 {
    struct cso_hash_iter iter;
-   struct hash_table_item *item;
+   struct util_hash_table_item *item;
    
    iter = cso_hash_find(ht->cso, key_hash);
    while (!cso_hash_iter_is_null(iter)) {
-      item = (struct hash_table_item *)cso_hash_iter_data(iter);
+      item = (struct util_hash_table_item *)cso_hash_iter_data(iter);
       if (!ht->compare(item->key, key))
          break;
       iter = cso_hash_iter_next(iter);
@@ -118,17 +118,17 @@ hash_table_find_iter(struct hash_table *ht,
 }
 
 
-static INLINE struct hash_table_item *
-hash_table_find_item(struct hash_table *ht,
-                     void *key, 
-                     unsigned key_hash)
+static INLINE struct util_hash_table_item *
+util_hash_table_find_item(struct util_hash_table *ht,
+                          void *key,
+                          unsigned key_hash)
 {
    struct cso_hash_iter iter;
-   struct hash_table_item *item;
+   struct util_hash_table_item *item;
    
    iter = cso_hash_find(ht->cso, key_hash);
    while (!cso_hash_iter_is_null(iter)) {
-      item = (struct hash_table_item *)cso_hash_iter_data(iter);
+      item = (struct util_hash_table_item *)cso_hash_iter_data(iter);
       if (!ht->compare(item->key, key))
          return item;
       iter = cso_hash_iter_next(iter);
@@ -139,12 +139,12 @@ hash_table_find_item(struct hash_table *ht,
 
 
 enum pipe_error
-hash_table_set(struct hash_table *ht,
-               void *key,
-               void *value)
+util_hash_table_set(struct util_hash_table *ht,
+                    void *key,
+                    void *value)
 {
    unsigned key_hash;
-   struct hash_table_item *item;
+   struct util_hash_table_item *item;
    struct cso_hash_iter iter;
 
    assert(ht);
@@ -153,14 +153,14 @@ hash_table_set(struct hash_table *ht,
 
    key_hash = ht->hash(key);
 
-   item = hash_table_find_item(ht, key, key_hash);
+   item = util_hash_table_find_item(ht, key, key_hash);
    if(item) {
       /* TODO: key/value destruction? */
       item->value = value;
       return PIPE_OK;
    }
    
-   item = MALLOC_STRUCT(hash_table_item);
+   item = MALLOC_STRUCT(util_hash_table_item);
    if(!item)
       return PIPE_ERROR_OUT_OF_MEMORY;
    
@@ -178,11 +178,11 @@ hash_table_set(struct hash_table *ht,
 
 
 void *
-hash_table_get(struct hash_table *ht, 
-               void *key)
+util_hash_table_get(struct util_hash_table *ht,
+                    void *key)
 {
    unsigned key_hash;
-   struct hash_table_item *item;
+   struct util_hash_table_item *item;
 
    assert(ht);
    if (!ht)
@@ -190,7 +190,7 @@ hash_table_get(struct hash_table *ht,
 
    key_hash = ht->hash(key);
 
-   item = hash_table_find_item(ht, key, key_hash);
+   item = util_hash_table_find_item(ht, key, key_hash);
    if(!item)
       return NULL;
    
@@ -199,12 +199,12 @@ hash_table_get(struct hash_table *ht,
 
 
 void
-hash_table_remove(struct hash_table *ht, 
-                  void *key)
+util_hash_table_remove(struct util_hash_table *ht,
+                       void *key)
 {
    unsigned key_hash;
    struct cso_hash_iter iter;
-   struct hash_table_item *item;
+   struct util_hash_table_item *item;
 
    assert(ht);
    if (!ht)
@@ -212,11 +212,11 @@ hash_table_remove(struct hash_table *ht,
 
    key_hash = ht->hash(key);
 
-   iter = hash_table_find_iter(ht, key, key_hash);
+   iter = util_hash_table_find_iter(ht, key, key_hash);
    if(cso_hash_iter_is_null(iter))
       return;
    
-   item = hash_table_item(iter);
+   item = util_hash_table_item(iter);
    assert(item);
    FREE(item);
    
@@ -225,10 +225,10 @@ hash_table_remove(struct hash_table *ht,
 
 
 void 
-hash_table_clear(struct hash_table *ht)
+util_hash_table_clear(struct util_hash_table *ht)
 {
    struct cso_hash_iter iter;
-   struct hash_table_item *item;
+   struct util_hash_table_item *item;
 
    assert(ht);
    if (!ht)
@@ -236,7 +236,7 @@ hash_table_clear(struct hash_table *ht)
 
    iter = cso_hash_first_node(ht->cso);
    while (!cso_hash_iter_is_null(iter)) {
-      item = (struct hash_table_item *)cso_hash_take(ht->cso, cso_hash_iter_key(iter));
+      item = (struct util_hash_table_item *)cso_hash_take(ht->cso, cso_hash_iter_key(iter));
       FREE(item);
       iter = cso_hash_first_node(ht->cso);
    }
@@ -244,12 +244,13 @@ hash_table_clear(struct hash_table *ht)
 
 
 enum pipe_error
-hash_table_foreach(struct hash_table *ht,
-                   enum pipe_error (*callback)(void *key, void *value, void *data),
-                   void *data)
+util_hash_table_foreach(struct util_hash_table *ht,
+                     enum pipe_error (*callback)
+                        (void *key, void *value, void *data),
+                     void *data)
 {
    struct cso_hash_iter iter;
-   struct hash_table_item *item;
+   struct util_hash_table_item *item;
    enum pipe_error result;
 
    assert(ht);
@@ -258,7 +259,7 @@ hash_table_foreach(struct hash_table *ht,
 
    iter = cso_hash_first_node(ht->cso);
    while (!cso_hash_iter_is_null(iter)) {
-      item = (struct hash_table_item *)cso_hash_iter_data(iter);
+      item = (struct util_hash_table_item *)cso_hash_iter_data(iter);
       result = callback(item->key, item->value, data);
       if(result != PIPE_OK)
         return result;
@@ -270,10 +271,10 @@ hash_table_foreach(struct hash_table *ht,
 
 
 void
-hash_table_destroy(struct hash_table *ht)
+util_hash_table_destroy(struct util_hash_table *ht)
 {
    struct cso_hash_iter iter;
-   struct hash_table_item *item;
+   struct util_hash_table_item *item;
 
    assert(ht);
    if (!ht)
@@ -281,7 +282,7 @@ hash_table_destroy(struct hash_table *ht)
 
    iter = cso_hash_first_node(ht->cso);
    while (!cso_hash_iter_is_null(iter)) {
-      item = (struct hash_table_item *)cso_hash_iter_data(iter);
+      item = (struct util_hash_table_item *)cso_hash_iter_data(iter);
       FREE(item);
       iter = cso_hash_iter_next(iter);
    }
index feee881582e1b891d456fcdc0be82d5bf917dbb0..51ec10a8041938bef807fb43527568e149c26b81 100644 (file)
@@ -35,7 +35,7 @@
 #define U_HASH_TABLE_H_
 
 
-#include "pipe/p_error.h"
+#include "pipe/p_defines.h"
 
 
 #ifdef __cplusplus
@@ -46,7 +46,7 @@ extern "C" {
 /**
  * Generic purpose hash table.
  */
-struct hash_table;
+struct util_hash_table;
 
 
 /**
@@ -55,37 +55,38 @@ struct hash_table;
  * @param hash hash function
  * @param compare should return 0 for two equal keys.
  */
-struct hash_table *
-hash_table_create(unsigned (*hash)(void *key),
-                  int (*compare)(void *key1, void *key2));
+struct util_hash_table *
+util_hash_table_create(unsigned (*hash)(void *key),
+                       int (*compare)(void *key1, void *key2));
 
 
 enum pipe_error
-hash_table_set(struct hash_table *ht,
-               void *key,
-               void *value);
+util_hash_table_set(struct util_hash_table *ht,
+                    void *key,
+                    void *value);
 
 void *
-hash_table_get(struct hash_table *ht, 
-               void *key);
+util_hash_table_get(struct util_hash_table *ht,
+                    void *key);
 
 
 void
-hash_table_remove(struct hash_table *ht, 
-                  void *key);
+util_hash_table_remove(struct util_hash_table *ht,
+                       void *key);
 
 
 void
-hash_table_clear(struct hash_table *ht);
+util_hash_table_clear(struct util_hash_table *ht);
 
 
 enum pipe_error
-hash_table_foreach(struct hash_table *ht,
-                   enum pipe_error (*callback)(void *key, void *value, void *data),
-                   void *data);
+util_hash_table_foreach(struct util_hash_table *ht,
+                        enum pipe_error (*callback)
+                        (void *key, void *value, void *data),
+                        void *data);
 
 void
-hash_table_destroy(struct hash_table *ht);
+util_hash_table_destroy(struct util_hash_table *ht);
 
 
 #ifdef __cplusplus
index 508a2ee063416ba4c650cc820373238e9c1615df..c4b9eb3d9b7f9ff21b445aed7a131d64c8b3f171 100644 (file)
@@ -28,7 +28,7 @@
 /**
  * Key lookup/associative container.
  *
- * Like Jose's u_hash_table, based on CSO cache code for now.
+ * Like Jose's util_hash_table, based on CSO cache code for now.
  *
  * Author: Brian Paul
  */
@@ -36,7 +36,7 @@
 
 #include "pipe/p_compiler.h"
 #include "util/u_debug.h"
-#include "pipe/p_error.h"
+#include "pipe/p_defines.h"
 
 #include "cso_cache/cso_hash.h"
 
index a1dce3f5cf495c4ffada6496e1f72dd3f4805f9f..f1aef2167713f592ff458edf3e45727415c881e2 100644 (file)
@@ -82,7 +82,7 @@ void pipe_linear_from_tile(struct pipe_tile_info *t, const void *src_ptr,
 
 void
 pipe_linear_fill_info(struct pipe_tile_info *t,
-                     const struct pipe_format_block *block,
+                     const struct u_linear_format_block *block,
                      unsigned tile_width, unsigned tile_height,
                      unsigned tiles_x, unsigned tiles_y)
 {
index b74308ffa3d17679aa14f4be68c8dd7f68b12a0c..42c40b2aa75570b29cccb37fba5ae910df0e2cb8 100644 (file)
 
 #include "pipe/p_format.h"
 
+struct u_linear_format_block
+{
+   /** Block size in bytes */
+   unsigned size;
+   
+   /** Block width in pixels */
+   unsigned width;
+   
+   /** Block height in pixels */
+   unsigned height;
+};
+
+
 struct pipe_tile_info
 {
    unsigned size;
@@ -49,10 +62,10 @@ struct pipe_tile_info
    unsigned rows;
 
    /* Describe the tile in pixels */
-   struct pipe_format_block tile;
+   struct u_linear_format_block tile;
 
    /* Describe each block within the tile */
-   struct pipe_format_block block;
+   struct u_linear_format_block block;
 };
 
 void pipe_linear_to_tile(size_t src_stride, const void *src_ptr,
@@ -71,7 +84,7 @@ void pipe_linear_from_tile(struct pipe_tile_info *t, const void *src_ptr,
  * @tiles_y number of tiles in y axis
  */
 void pipe_linear_fill_info(struct pipe_tile_info *t,
-                          const struct pipe_format_block *block,
+                          const struct u_linear_format_block *block,
                           unsigned tile_width, unsigned tile_height,
                           unsigned tiles_x, unsigned tiles_y);
 
index 75b075f160d922c14c0277a57dd9c5b7b60ec680..b2969a210a7878f0daed5df6d715981139e2dc3d 100644 (file)
@@ -490,6 +490,47 @@ util_next_power_of_two(unsigned x)
 }
 
 
+/**
+ * Return number of bits set in n.
+ */
+static INLINE unsigned
+util_bitcount(unsigned n)
+{
+#if defined(PIPE_CC_GCC)
+   return __builtin_popcount(n);
+#else
+   /* K&R classic bitcount.
+    *
+    * For each iteration, clear the LSB from the bitfield.
+    * Requires only one iteration per set bit, instead of
+    * one iteration per bit less than highest set bit.
+    */
+   unsigned bits = 0;
+   for (bits; n; bits++) {
+      n &= n - 1;
+   }
+   return bits;
+#endif
+}
+
+
+/**
+ * Reverse byte order of a 32 bit word.
+ */
+static INLINE uint32_t
+util_bswap32(uint32_t n)
+{
+#if defined(PIPE_CC_GCC) && (PIPE_CC_GCC_VERSION >= 403)
+   return __builtin_bswap32(n);
+#else
+   return (n >> 24) |
+          ((n >> 8) & 0x0000ff00) |
+          ((n << 8) & 0x00ff0000) |
+          (n << 24);
+#endif
+}
+
+
 /**
  * Clamp X to [MIN, MAX].
  * This is a macro to allow float, int, uint, etc. types.
@@ -499,6 +540,9 @@ util_next_power_of_two(unsigned x)
 #define MIN2( A, B )   ( (A)<(B) ? (A) : (B) )
 #define MAX2( A, B )   ( (A)>(B) ? (A) : (B) )
 
+#define MIN3( A, B, C ) MIN2( MIN2( A, B ), C )
+#define MAX3( A, B, C ) MAX2( MAX2( A, B ), C )
+
 
 static INLINE int
 align(int value, int alignment)
@@ -507,9 +551,9 @@ align(int value, int alignment)
 }
 
 static INLINE unsigned
-minify(unsigned value)
+u_minify(unsigned value, unsigned levels)
 {
-    return MAX2(1, value >> 1);
+    return MAX2(1, value >> levels);
 }
 
 #ifndef COPY_4V
@@ -539,6 +583,18 @@ do {                                     \
 #endif
 
 
+static INLINE uint32_t util_unsigned_fixed(float value, unsigned frac_bits)
+{
+   return value < 0 ? 0 : (uint32_t)(value * (1<<frac_bits));
+}
+
+static INLINE int32_t util_signed_fixed(float value, unsigned frac_bits)
+{
+   return (int32_t)(value * (1<<frac_bits));
+}
+
+
+
 #ifdef __cplusplus
 }
 #endif
index 4b75d4ba1d0155f9129663ab3b557a1cdb2458d2..82f83702d1e4f01213ff7926e7c6824a2ff32dd5 100644 (file)
@@ -39,13 +39,20 @@ u_mmDumpMemInfo(const struct mem_block *heap)
    }
    else {
       const struct mem_block *p;
+      int total_used = 0, total_free = 0;
 
       for (p = heap->next; p != heap; p = p->next) {
         debug_printf("  Offset:%08x, Size:%08x, %c%c\n", p->ofs, p->size,
                       p->free ? 'F':'.',
                       p->reserved ? 'R':'.');
+         if (p->free)
+            total_free += p->size;
+         else
+            total_used += p->size;
       }
 
+      debug_printf("'\nMemory stats: total = %d, used = %d, free = %d\n",
+                   total_used + total_free, total_used, total_free);
       debug_printf("\nFree list:\n");
 
       for (p = heap->next_free; p != heap; p = p->next_free) {
index 6269c72e121335bf03f36d89aae9247cfbb99be7..87ee0e476852485fc04263b18f6302146a9e3d49 100644 (file)
@@ -6,7 +6,7 @@
 #if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
 #  include <winsock2.h>
 #  include <windows.h>
-#elif defined(PIPE_OS_LINUX) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_BSD)
+#elif defined(PIPE_OS_LINUX) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_APPLE)
 #  include <sys/socket.h>
 #  include <netinet/in.h>
 #  include <unistd.h>
@@ -54,7 +54,7 @@ u_socket_close(int s)
    if (s < 0)
       return;
 
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_BSD)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_APPLE)
    shutdown(s, SHUT_RDWR);
    close(s);
 #elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
@@ -117,7 +117,7 @@ u_socket_connect(const char *hostname, uint16_t port)
    if (!host)
       return -1;
 
-   memcpy((char *)&sa.sin_addr,host->h_addr,host->h_length);
+   memcpy((char *)&sa.sin_addr,host->h_addr_list[0],host->h_length);
    sa.sin_family= host->h_addrtype;
    sa.sin_port = htons(port);
 
@@ -169,7 +169,7 @@ u_socket_listen_on_port(uint16_t portnum)
 void
 u_socket_block(int s, boolean block)
 {
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_BSD)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_APPLE)
    int old = fcntl(s, F_GETFL, 0);
    if (old == -1)
       return;
index 0aa898b967677e48845c76c86470b81603abc306..187dcab86e7d16ee663f6ae9b7305e093f5934a6 100644 (file)
@@ -6,7 +6,7 @@
 
 #if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
 #  define PIPE_HAVE_SOCKETS
-#elif defined(PIPE_OS_LINUX) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_BSD)
+#elif defined(PIPE_OS_LINUX) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_APPLE)
 #  define PIPE_HAVE_SOCKETS
 #endif
 
index eda883b3b92ebb9ecd25570f2a2a7f5b80795f1f..43eb0153ee7936d3c58273b9cbe516d39e6b3086 100644 (file)
 
 #include "pipe/p_compiler.h"
 #include "pipe/p_format.h"
+#include "util/u_format.h"
 #include "util/u_math.h"
 
 
+
+union util_color {
+   ubyte ub;
+   ushort us;
+   uint ui;
+   float f[4];
+};
+
 /**
  * Pack ubyte R,G,B,A into dest pixel.
  */
 static INLINE void
 util_pack_color_ub(ubyte r, ubyte g, ubyte b, ubyte a,
-                   enum pipe_format format, void *dest)
+                   enum pipe_format format, union util_color *uc)
 {
    switch (format) {
    case PIPE_FORMAT_R8G8B8A8_UNORM:
       {
-         uint *d = (uint *) dest;
-         *d = (r << 24) | (g << 16) | (b << 8) | a;
+         uc->ui = (r << 24) | (g << 16) | (b << 8) | a;
       }
       return;
    case PIPE_FORMAT_R8G8B8X8_UNORM:
       {
-         uint *d = (uint *) dest;
-         *d = (r << 24) | (g << 16) | (b << 8) | 0xff;
+         uc->ui = (r << 24) | (g << 16) | (b << 8) | 0xff;
       }
       return;
    case PIPE_FORMAT_A8R8G8B8_UNORM:
       {
-         uint *d = (uint *) dest;
-         *d = (a << 24) | (r << 16) | (g << 8) | b;
+         uc->ui = (a << 24) | (r << 16) | (g << 8) | b;
       }
       return;
    case PIPE_FORMAT_X8R8G8B8_UNORM:
       {
-         uint *d = (uint *) dest;
-         *d = (0xff << 24) | (r << 16) | (g << 8) | b;
+         uc->ui = (0xff << 24) | (r << 16) | (g << 8) | b;
       }
       return;
    case PIPE_FORMAT_B8G8R8A8_UNORM:
       {
-         uint *d = (uint *) dest;
-         *d = (b << 24) | (g << 16) | (r << 8) | a;
+         uc->ui = (b << 24) | (g << 16) | (r << 8) | a;
       }
       return;
    case PIPE_FORMAT_B8G8R8X8_UNORM:
       {
-         uint *d = (uint *) dest;
-         *d = (b << 24) | (g << 16) | (r << 8) | 0xff;
+         uc->ui = (b << 24) | (g << 16) | (r << 8) | 0xff;
       }
       return;
    case PIPE_FORMAT_R5G6B5_UNORM:
       {
-         ushort *d = (ushort *) dest;
-         *d = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3);
+         uc->us = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3);
       }
       return;
    case PIPE_FORMAT_A1R5G5B5_UNORM:
       {
-         ushort *d = (ushort *) dest;
-         *d = ((a & 0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3);
+         uc->us = ((a & 0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3);
       }
       return;
    case PIPE_FORMAT_A4R4G4B4_UNORM:
       {
-         ushort *d = (ushort *) dest;
-         *d = ((a & 0xf0) << 8) | ((r & 0xf0) << 4) | ((g & 0xf0) << 0) | (b >> 4);
+         uc->us = ((a & 0xf0) << 8) | ((r & 0xf0) << 4) | ((g & 0xf0) << 0) | (b >> 4);
       }
       return;
    case PIPE_FORMAT_A8_UNORM:
       {
-         ubyte *d = (ubyte *) dest;
-         *d = a;
+         uc->ub = a;
       }
       return;
    case PIPE_FORMAT_L8_UNORM:
    case PIPE_FORMAT_I8_UNORM:
       {
-         ubyte *d = (ubyte *) dest;
-         *d = r;
+         uc->ub = a;
       }
       return;
    case PIPE_FORMAT_R32G32B32A32_FLOAT:
       {
-         float *d = (float *) dest;
-         d[0] = (float)r / 255.0f;
-         d[1] = (float)g / 255.0f;
-         d[2] = (float)b / 255.0f;
-         d[3] = (float)a / 255.0f;
+         uc->f[0] = (float)r / 255.0f;
+         uc->f[1] = (float)g / 255.0f;
+         uc->f[2] = (float)b / 255.0f;
+         uc->f[3] = (float)a / 255.0f;
       }
       return;
    case PIPE_FORMAT_R32G32B32_FLOAT:
       {
-         float *d = (float *) dest;
-         d[0] = (float)r / 255.0f;
-         d[1] = (float)g / 255.0f;
-         d[2] = (float)b / 255.0f;
+         uc->f[0] = (float)r / 255.0f;
+         uc->f[1] = (float)g / 255.0f;
+         uc->f[2] = (float)b / 255.0f;
       }
       return;
 
-   /* XXX lots more cases to add */
+   /* Handle other cases with a generic function.
+    */
    default:
-      debug_print_format("gallium: unhandled format in util_pack_color_ub()", format);
-      assert(0);
+      {
+         ubyte src[4];
+
+         src[0] = r;
+         src[1] = g;
+         src[2] = b;
+         src[3] = a;
+         util_format_write_4ub(format, src, 0, uc, 0, 0, 0, 1, 1);
+      }
    }
 }
  
@@ -145,13 +149,13 @@ util_pack_color_ub(ubyte r, ubyte g, ubyte b, ubyte a,
  * Unpack RGBA from a packed pixel, returning values as ubytes in [0,255].
  */
 static INLINE void
-util_unpack_color_ub(enum pipe_format format, const void *src,
+util_unpack_color_ub(enum pipe_format format, union util_color *uc,
                      ubyte *r, ubyte *g, ubyte *b, ubyte *a)
 {
    switch (format) {
    case PIPE_FORMAT_R8G8B8A8_UNORM:
       {
-         uint p = ((const uint *) src)[0];
+         uint p = uc->ui;
          *r = (ubyte) ((p >> 24) & 0xff);
          *g = (ubyte) ((p >> 16) & 0xff);
          *b = (ubyte) ((p >>  8) & 0xff);
@@ -160,7 +164,7 @@ util_unpack_color_ub(enum pipe_format format, const void *src,
       return;
    case PIPE_FORMAT_R8G8B8X8_UNORM:
       {
-         uint p = ((const uint *) src)[0];
+         uint p = uc->ui;
          *r = (ubyte) ((p >> 24) & 0xff);
          *g = (ubyte) ((p >> 16) & 0xff);
          *b = (ubyte) ((p >>  8) & 0xff);
@@ -169,7 +173,7 @@ util_unpack_color_ub(enum pipe_format format, const void *src,
       return;
    case PIPE_FORMAT_A8R8G8B8_UNORM:
       {
-         uint p = ((const uint *) src)[0];
+         uint p = uc->ui;
          *r = (ubyte) ((p >> 16) & 0xff);
          *g = (ubyte) ((p >>  8) & 0xff);
          *b = (ubyte) ((p >>  0) & 0xff);
@@ -178,7 +182,7 @@ util_unpack_color_ub(enum pipe_format format, const void *src,
       return;
    case PIPE_FORMAT_X8R8G8B8_UNORM:
       {
-         uint p = ((const uint *) src)[0];
+         uint p = uc->ui;
          *r = (ubyte) ((p >> 16) & 0xff);
          *g = (ubyte) ((p >>  8) & 0xff);
          *b = (ubyte) ((p >>  0) & 0xff);
@@ -187,7 +191,7 @@ util_unpack_color_ub(enum pipe_format format, const void *src,
       return;
    case PIPE_FORMAT_B8G8R8A8_UNORM:
       {
-         uint p = ((const uint *) src)[0];
+         uint p = uc->ui;
          *r = (ubyte) ((p >>  8) & 0xff);
          *g = (ubyte) ((p >> 16) & 0xff);
          *b = (ubyte) ((p >> 24) & 0xff);
@@ -196,7 +200,7 @@ util_unpack_color_ub(enum pipe_format format, const void *src,
       return;
    case PIPE_FORMAT_B8G8R8X8_UNORM:
       {
-         uint p = ((const uint *) src)[0];
+         uint p = uc->ui;
          *r = (ubyte) ((p >>  8) & 0xff);
          *g = (ubyte) ((p >> 16) & 0xff);
          *b = (ubyte) ((p >> 24) & 0xff);
@@ -205,7 +209,7 @@ util_unpack_color_ub(enum pipe_format format, const void *src,
       return;
    case PIPE_FORMAT_R5G6B5_UNORM:
       {
-         ushort p = ((const ushort *) src)[0];
+         ushort p = uc->us;
          *r = (ubyte) (((p >> 8) & 0xf8) | ((p >> 13) & 0x7));
          *g = (ubyte) (((p >> 3) & 0xfc) | ((p >>  9) & 0x3));
          *b = (ubyte) (((p << 3) & 0xf8) | ((p >>  2) & 0x7));
@@ -214,7 +218,7 @@ util_unpack_color_ub(enum pipe_format format, const void *src,
       return;
    case PIPE_FORMAT_A1R5G5B5_UNORM:
       {
-         ushort p = ((const ushort *) src)[0];
+         ushort p = uc->us;
          *r = (ubyte) (((p >>  7) & 0xf8) | ((p >> 12) & 0x7));
          *g = (ubyte) (((p >>  2) & 0xf8) | ((p >>  7) & 0x7));
          *b = (ubyte) (((p <<  3) & 0xf8) | ((p >>  2) & 0x7));
@@ -223,7 +227,7 @@ util_unpack_color_ub(enum pipe_format format, const void *src,
       return;
    case PIPE_FORMAT_A4R4G4B4_UNORM:
       {
-         ushort p = ((const ushort *) src)[0];
+         ushort p = uc->us;
          *r = (ubyte) (((p >> 4) & 0xf0) | ((p >>  8) & 0xf));
          *g = (ubyte) (((p >> 0) & 0xf0) | ((p >>  4) & 0xf));
          *b = (ubyte) (((p << 4) & 0xf0) | ((p >>  0) & 0xf));
@@ -232,27 +236,27 @@ util_unpack_color_ub(enum pipe_format format, const void *src,
       return;
    case PIPE_FORMAT_A8_UNORM:
       {
-         ubyte p = ((const ubyte *) src)[0];
+         ubyte p = uc->ub;
          *r = *g = *b = (ubyte) 0xff;
          *a = p;
       }
       return;
    case PIPE_FORMAT_L8_UNORM:
       {
-         ubyte p = ((const ubyte *) src)[0];
+         ubyte p = uc->ub;
          *r = *g = *b = p;
          *a = (ubyte) 0xff;
       }
       return;
    case PIPE_FORMAT_I8_UNORM:
       {
-         ubyte p = ((const ubyte *) src)[0];
+         ubyte p = uc->ub;
          *r = *g = *b = *a = p;
       }
       return;
    case PIPE_FORMAT_R32G32B32A32_FLOAT:
       {
-         const float *p = (const float *) src;
+         const float *p = &uc->f[0];
          *r = float_to_ubyte(p[0]);
          *g = float_to_ubyte(p[1]);
          *b = float_to_ubyte(p[2]);
@@ -261,7 +265,7 @@ util_unpack_color_ub(enum pipe_format format, const void *src,
       return;
    case PIPE_FORMAT_R32G32B32_FLOAT:
       {
-         const float *p = (const float *) src;
+         const float *p = &uc->f[0];
          *r = float_to_ubyte(p[0]);
          *g = float_to_ubyte(p[1]);
          *b = float_to_ubyte(p[2]);
@@ -271,7 +275,7 @@ util_unpack_color_ub(enum pipe_format format, const void *src,
 
    case PIPE_FORMAT_R32G32_FLOAT:
       {
-         const float *p = (const float *) src;
+         const float *p = &uc->f[0];
          *r = float_to_ubyte(p[0]);
          *g = float_to_ubyte(p[1]);
          *b = *a = (ubyte) 0xff;
@@ -280,31 +284,40 @@ util_unpack_color_ub(enum pipe_format format, const void *src,
 
    case PIPE_FORMAT_R32_FLOAT:
       {
-         const float *p = (const float *) src;
+         const float *p = &uc->f[0];
          *r = float_to_ubyte(p[0]);
          *g = *b = *a = (ubyte) 0xff;
       }
       return;
 
-   /* XXX lots more cases to add */
+   /* Handle other cases with a generic function.
+    */
    default:
-      debug_print_format("gallium: unhandled format in util_unpack_color_ub()",
-                         format);
-      assert(0);
+      {
+         ubyte dst[4];
+
+         util_format_read_4ub(format, dst, 0, uc, 0, 0, 0, 1, 1);
+         *r = dst[0];
+         *g = dst[1];
+         *b = dst[2];
+         *a = dst[3];
+      }
    }
 }
 
 
 /**
  * Note rgba outside [0,1] will be clamped for int pixel formats.
  */
 static INLINE void
-util_pack_color(const float rgba[4], enum pipe_format format, void *dest)
+util_pack_color(const float rgba[4], enum pipe_format format, union util_color *uc)
 {
-   ubyte r, g, b, a;
+   ubyte r = 0;
+   ubyte g = 0;
+   ubyte b = 0;
+   ubyte a = 0;
 
-   if (pf_size_x(format) <= 8) {
+   if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0) <= 8) {
       /* format uses 8-bit components or less */
       r = float_to_ubyte(rgba[0]);
       g = float_to_ubyte(rgba[1]);
@@ -315,92 +328,80 @@ util_pack_color(const float rgba[4], enum pipe_format format, void *dest)
    switch (format) {
    case PIPE_FORMAT_R8G8B8A8_UNORM:
       {
-         uint *d = (uint *) dest;
-         *d = (r << 24) | (g << 16) | (b << 8) | a;
+         uc->ui = (r << 24) | (g << 16) | (b << 8) | a;
       }
       return;
    case PIPE_FORMAT_R8G8B8X8_UNORM:
       {
-         uint *d = (uint *) dest;
-         *d = (r << 24) | (g << 16) | (b << 8) | 0xff;
+         uc->ui = (r << 24) | (g << 16) | (b << 8) | 0xff;
       }
       return;
    case PIPE_FORMAT_A8R8G8B8_UNORM:
       {
-         uint *d = (uint *) dest;
-         *d = (a << 24) | (r << 16) | (g << 8) | b;
+         uc->ui = (a << 24) | (r << 16) | (g << 8) | b;
       }
       return;
    case PIPE_FORMAT_X8R8G8B8_UNORM:
       {
-         uint *d = (uint *) dest;
-         *d = (0xff << 24) | (r << 16) | (g << 8) | b;
+         uc->ui = (0xff << 24) | (r << 16) | (g << 8) | b;
       }
       return;
    case PIPE_FORMAT_B8G8R8A8_UNORM:
       {
-         uint *d = (uint *) dest;
-         *d = (b << 24) | (g << 16) | (r << 8) | a;
+         uc->ui = (b << 24) | (g << 16) | (r << 8) | a;
       }
       return;
    case PIPE_FORMAT_B8G8R8X8_UNORM:
       {
-         uint *d = (uint *) dest;
-         *d = (b << 24) | (g << 16) | (r << 8) | 0xff;
+         uc->ui = (b << 24) | (g << 16) | (r << 8) | 0xff;
       }
       return;
    case PIPE_FORMAT_R5G6B5_UNORM:
       {
-         ushort *d = (ushort *) dest;
-         *d = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3);
+         uc->us = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3);
       }
       return;
    case PIPE_FORMAT_A1R5G5B5_UNORM:
       {
-         ushort *d = (ushort *) dest;
-         *d = ((a & 0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3);
+         uc->us = ((a & 0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3);
       }
       return;
    case PIPE_FORMAT_A4R4G4B4_UNORM:
       {
-         ushort *d = (ushort *) dest;
-         *d = ((a & 0xf0) << 8) | ((r & 0xf0) << 4) | ((g & 0xf0) << 0) | (b >> 4);
+         uc->ub = ((a & 0xf0) << 8) | ((r & 0xf0) << 4) | ((g & 0xf0) << 0) | (b >> 4);
       }
       return;
    case PIPE_FORMAT_A8_UNORM:
       {
-         ubyte *d = (ubyte *) dest;
-         *d = a;
+         uc->ub = a;
       }
       return;
    case PIPE_FORMAT_L8_UNORM:
    case PIPE_FORMAT_I8_UNORM:
       {
-         ubyte *d = (ubyte *) dest;
-         *d = r;
+         uc->ub = r;
       }
       return;
    case PIPE_FORMAT_R32G32B32A32_FLOAT:
       {
-         float *d = (float *) dest;
-         d[0] = rgba[0];
-         d[1] = rgba[1];
-         d[2] = rgba[2];
-         d[3] = rgba[3];
+         uc->f[0] = rgba[0];
+         uc->f[1] = rgba[1];
+         uc->f[2] = rgba[2];
+         uc->f[3] = rgba[3];
       }
       return;
    case PIPE_FORMAT_R32G32B32_FLOAT:
       {
-         float *d = (float *) dest;
-         d[0] = rgba[0];
-         d[1] = rgba[1];
-         d[2] = rgba[2];
+         uc->f[0] = rgba[0];
+         uc->f[1] = rgba[1];
+         uc->f[2] = rgba[2];
       }
       return;
-   /* XXX lots more cases to add */
+
+   /* Handle other cases with a generic function.
+    */
    default:
-      debug_print_format("gallium: unhandled format in util_pack_color()", format);
-      assert(0);
+      util_format_write_4f(format, rgba, 0, uc, 0, 0, 0, 1, 1);
    }
 }
  
index a9b533eea700458bf512607aa8b5fd9f29c4ce7f..10a874f3416d1c8957bb1e18b68c99752ed8b760 100644 (file)
@@ -135,4 +135,39 @@ static INLINE unsigned u_reduced_prim( unsigned pipe_prim )
    }
 }
 
+static INLINE unsigned
+u_vertices_per_prim(int primitive)
+{
+   switch(primitive) {
+   case PIPE_PRIM_POINTS:
+      return 1;
+   case PIPE_PRIM_LINES:
+   case PIPE_PRIM_LINE_LOOP:
+   case PIPE_PRIM_LINE_STRIP:
+      return 2;
+   case PIPE_PRIM_TRIANGLES:
+   case PIPE_PRIM_TRIANGLE_STRIP:
+   case PIPE_PRIM_TRIANGLE_FAN:
+      return 3;
+   case PIPE_PRIM_LINES_ADJACENCY:
+   case PIPE_PRIM_LINE_STRIP_ADJACENCY:
+      return 4;
+   case PIPE_PRIM_TRIANGLES_ADJACENCY:
+   case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY:
+      return 6;
+
+   /* following primitives should never be used
+    * with geometry shaders abd their size is
+    * undefined */
+   case PIPE_PRIM_POLYGON:
+   case PIPE_PRIM_QUADS:
+   case PIPE_PRIM_QUAD_STRIP:
+   default:
+      debug_printf("Unrecognized geometry shader primitive");
+      return 3;
+   }
+}
+
+const char *u_prim_name( unsigned pipe_prim );
+
 #endif
index 9866b6fc8a0e626eb3ff1cfc17777ea94b2962f0..8479161c74494b18c37170e431fe6f345517ae89 100644 (file)
 #include "pipe/p_format.h"
 #include "pipe/p_context.h"
 #include "pipe/p_screen.h"
+#include "util/u_format.h"
 #include "util/u_rect.h"
 
 
 /**
  * Copy 2D rect from one place to another.
  * Position and sizes are in pixels.
- * src_pitch may be negative to do vertical flip of pixels from source.
+ * src_stride may be negative to do vertical flip of pixels from source.
  */
 void
 util_copy_rect(ubyte * dst,
-               const struct pipe_format_block *block,
+               enum pipe_format format,
                unsigned dst_stride,
                unsigned dst_x,
                unsigned dst_y,
@@ -53,31 +54,30 @@ util_copy_rect(ubyte * dst,
                const ubyte * src,
                int src_stride,
                unsigned src_x, 
-               int src_y)
+               unsigned src_y)
 {
    unsigned i;
    int src_stride_pos = src_stride < 0 ? -src_stride : src_stride;
-
-   assert(block->size > 0);
-   assert(block->width > 0);
-   assert(block->height > 0);
-   assert(src_x >= 0);
-   assert(src_y >= 0);
-   assert(dst_x >= 0);
-   assert(dst_y >= 0);
-
-   dst_x /= block->width;
-   dst_y /= block->height;
-   width = (width + block->width - 1)/block->width;
-   height = (height + block->height - 1)/block->height;
-   src_x /= block->width;
-   src_y /= block->height;
+   int blocksize = util_format_get_blocksize(format);
+   int blockwidth = util_format_get_blockwidth(format);
+   int blockheight = util_format_get_blockheight(format);
+
+   assert(blocksize > 0);
+   assert(blockwidth > 0);
+   assert(blockheight > 0);
+
+   dst_x /= blockwidth;
+   dst_y /= blockheight;
+   width = (width + blockwidth - 1)/blockwidth;
+   height = (height + blockheight - 1)/blockheight;
+   src_x /= blockwidth;
+   src_y /= blockheight;
    
-   dst += dst_x * block->size;
-   src += src_x * block->size;
+   dst += dst_x * blocksize;
+   src += src_x * blocksize;
    dst += dst_y * dst_stride;
    src += src_y * src_stride_pos;
-   width *= block->size;
+   width *= blocksize;
 
    if (width == dst_stride && width == src_stride)
       memcpy(dst, src, height * width);
@@ -92,7 +92,7 @@ util_copy_rect(ubyte * dst,
 
 void
 util_fill_rect(ubyte * dst,
-               const struct pipe_format_block *block,
+               enum pipe_format format,
                unsigned dst_stride,
                unsigned dst_x,
                unsigned dst_y,
@@ -102,23 +102,24 @@ util_fill_rect(ubyte * dst,
 {
    unsigned i, j;
    unsigned width_size;
-
-   assert(block->size > 0);
-   assert(block->width > 0);
-   assert(block->height > 0);
-   assert(dst_x >= 0);
-   assert(dst_y >= 0);
-
-   dst_x /= block->width;
-   dst_y /= block->height;
-   width = (width + block->width - 1)/block->width;
-   height = (height + block->height - 1)/block->height;
+   int blocksize = util_format_get_blocksize(format);
+   int blockwidth = util_format_get_blockwidth(format);
+   int blockheight = util_format_get_blockheight(format);
+
+   assert(blocksize > 0);
+   assert(blockwidth > 0);
+   assert(blockheight > 0);
+
+   dst_x /= blockwidth;
+   dst_y /= blockheight;
+   width = (width + blockwidth - 1)/blockwidth;
+   height = (height + blockheight - 1)/blockheight;
    
-   dst += dst_x * block->size;
+   dst += dst_x * blocksize;
    dst += dst_y * dst_stride;
-   width_size = width * block->size;
+   width_size = width * blocksize;
    
-   switch (block->size) {
+   switch (blocksize) {
    case 1:
       if(dst_stride == width_size)
         memset(dst, (ubyte) value, height * width_size);
@@ -172,10 +173,15 @@ util_surface_copy(struct pipe_context *pipe,
    struct pipe_transfer *src_trans, *dst_trans;
    void *dst_map;
    const void *src_map;
+   enum pipe_format src_format, dst_format;
 
    assert(src->texture && dst->texture);
    if (!src->texture || !dst->texture)
       return;
+
+   src_format = src->texture->format;
+   dst_format = dst->texture->format;
+
    src_trans = screen->get_tex_transfer(screen,
                                         src->texture,
                                         src->face,
@@ -192,9 +198,9 @@ util_surface_copy(struct pipe_context *pipe,
                                         PIPE_TRANSFER_WRITE,
                                         dst_x, dst_y, w, h);
 
-   assert(dst_trans->block.size == src_trans->block.size);
-   assert(dst_trans->block.width == src_trans->block.width);
-   assert(dst_trans->block.height == src_trans->block.height);
+   assert(util_format_get_blocksize(dst_format) == util_format_get_blocksize(src_format));
+   assert(util_format_get_blockwidth(dst_format) == util_format_get_blockwidth(src_format));
+   assert(util_format_get_blockheight(dst_format) == util_format_get_blockheight(src_format));
 
    src_map = pipe->screen->transfer_map(screen, src_trans);
    dst_map = pipe->screen->transfer_map(screen, dst_trans);
@@ -205,7 +211,7 @@ util_surface_copy(struct pipe_context *pipe,
    if (src_map && dst_map) {
       /* If do_flip, invert src_y position and pass negative src stride */
       util_copy_rect(dst_map,
-                     &dst_trans->block,
+                     dst_format,
                      dst_trans->stride,
                      0, 0,
                      w, h,
@@ -259,11 +265,11 @@ util_surface_fill(struct pipe_context *pipe,
    if (dst_map) {
       assert(dst_trans->stride > 0);
 
-      switch (dst_trans->block.size) {
+      switch (util_format_get_blocksize(dst_trans->texture->format)) {
       case 1:
       case 2:
       case 4:
-         util_fill_rect(dst_map, &dst_trans->block, dst_trans->stride,
+         util_fill_rect(dst_map, dst_trans->texture->format, dst_trans->stride,
                         0, 0, width, height, value);
          break;
       case 8:
index daa50834d367bc39d57a0db346e8b0ecb82ffb8c..b44d821904b06d83a66daa42032d2079c3413a84 100644 (file)
@@ -42,13 +42,13 @@ struct pipe_surface;
 
 
 extern void
-util_copy_rect(ubyte * dst, const struct pipe_format_block *block,
+util_copy_rect(ubyte * dst, enum pipe_format format,
                unsigned dst_stride, unsigned dst_x, unsigned dst_y,
                unsigned width, unsigned height, const ubyte * src,
-               int src_stride, unsigned src_x, int src_y);
+               int src_stride, unsigned src_x, unsigned src_y);
 
 extern void
-util_fill_rect(ubyte * dst, const struct pipe_format_block *block,
+util_fill_rect(ubyte * dst, enum pipe_format format,
                unsigned dst_stride, unsigned dst_x, unsigned dst_y,
                unsigned width, unsigned height, uint32_t value);
 
index 1c8b157d91fcd1ac9d21b00fa69b3d9c01fd4e53..b751e29ab62dd5c25b88461a9fa95d40ad7f1dcf 100644 (file)
@@ -2,6 +2,7 @@
  *
  * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
  * All Rights Reserved.
+ * Copyright 2009 Marek Olšák <maraeo@gmail.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the
@@ -30,6 +31,7 @@
  * Simple vertex/fragment shader generators.
  *  
  * @author Brian Paul
+           Marek Olšák
  */
 
 
 
 /**
  * Make simple vertex pass-through shader.
+ * \param num_attribs  number of attributes to pass through
+ * \param semantic_names  array of semantic names for each attribute
+ * \param semantic_indexes  array of semantic indexes for each attribute
  */
 void *
 util_make_vertex_passthrough_shader(struct pipe_context *pipe,
                                     uint num_attribs,
                                     const uint *semantic_names,
                                     const uint *semantic_indexes)
-                                    
 {
    struct ureg_program *ureg;
    uint i;
@@ -76,8 +80,6 @@ util_make_vertex_passthrough_shader(struct pipe_context *pipe,
 }
 
 
-
-
 /**
  * Make simple fragment texture shader:
  *  IMM {0,0,0,1}                         // (if writemask != 0xf)
@@ -87,6 +89,7 @@ util_make_vertex_passthrough_shader(struct pipe_context *pipe,
  */
 void *
 util_make_fragment_tex_shader_writemask(struct pipe_context *pipe,
+                                        unsigned tex_target,
                                         unsigned writemask )
 {
    struct ureg_program *ureg;
@@ -116,30 +119,94 @@ util_make_fragment_tex_shader_writemask(struct pipe_context *pipe,
 
    ureg_TEX( ureg, 
              ureg_writemask(out, writemask),
-             TGSI_TEXTURE_2D, tex, sampler );
+             tex_target, tex, sampler );
    ureg_END( ureg );
 
    return ureg_create_shader_and_destroy( ureg, pipe );
 }
 
+
+/**
+ * Make a simple fragment shader that sets the output color to a color
+ * taken from a texture.
+ * \param tex_target  one of PIPE_TEXTURE_x
+ */
 void *
-util_make_fragment_tex_shader(struct pipe_context *pipe )
+util_make_fragment_tex_shader(struct pipe_context *pipe, unsigned tex_target )
 {
    return util_make_fragment_tex_shader_writemask( pipe,
+                                                   tex_target,
                                                    TGSI_WRITEMASK_XYZW );
 }
 
 
+/**
+ * Make a simple fragment texture shader which reads an X component from
+ * a texture and writes it as depth.
+ */
+void *
+util_make_fragment_tex_shader_writedepth(struct pipe_context *pipe,
+                                         unsigned tex_target)
+{
+   struct ureg_program *ureg;
+   struct ureg_src sampler;
+   struct ureg_src tex;
+   struct ureg_dst out, depth;
+   struct ureg_src imm;
+
+   ureg = ureg_create( TGSI_PROCESSOR_FRAGMENT );
+   if (ureg == NULL)
+      return NULL;
+
+   sampler = ureg_DECL_sampler( ureg, 0 );
+
+   tex = ureg_DECL_fs_input( ureg,
+                             TGSI_SEMANTIC_GENERIC, 0,
+                             TGSI_INTERPOLATE_PERSPECTIVE );
+
+   out = ureg_DECL_output( ureg,
+                           TGSI_SEMANTIC_COLOR,
+                           0 );
+
+   depth = ureg_DECL_output( ureg,
+                             TGSI_SEMANTIC_POSITION,
+                             0 );
+
+   imm = ureg_imm4f( ureg, 0, 0, 0, 1 );
+
+   ureg_MOV( ureg, out, imm );
+
+   ureg_TEX( ureg,
+             ureg_writemask(depth, TGSI_WRITEMASK_Z),
+             tex_target, tex, sampler );
+   ureg_END( ureg );
+
+   return ureg_create_shader_and_destroy( ureg, pipe );
+}
+
 
 /**
  * Make simple fragment color pass-through shader.
  */
 void *
 util_make_fragment_passthrough_shader(struct pipe_context *pipe)
+{
+   return util_make_fragment_clonecolor_shader(pipe, 1);
+}
+
+
+/**
+ * Make a fragment shader that copies the input color to N output colors.
+ */
+void *
+util_make_fragment_clonecolor_shader(struct pipe_context *pipe, int num_cbufs)
 {
    struct ureg_program *ureg;
    struct ureg_src src;
-   struct ureg_dst dst;
+   struct ureg_dst dst[PIPE_MAX_COLOR_BUFS];
+   int i;
+
+   assert(num_cbufs <= PIPE_MAX_COLOR_BUFS);
 
    ureg = ureg_create( TGSI_PROCESSOR_FRAGMENT );
    if (ureg == NULL)
@@ -148,12 +215,13 @@ util_make_fragment_passthrough_shader(struct pipe_context *pipe)
    src = ureg_DECL_fs_input( ureg, TGSI_SEMANTIC_COLOR, 0, 
                              TGSI_INTERPOLATE_PERSPECTIVE );
 
-   dst = ureg_DECL_output( ureg, TGSI_SEMANTIC_COLOR, 0 );
+   for (i = 0; i < num_cbufs; i++)
+      dst[i] = ureg_DECL_output( ureg, TGSI_SEMANTIC_COLOR, i );
+
+   for (i = 0; i < num_cbufs; i++)
+      ureg_MOV( ureg, dst[i], src );
 
-   ureg_MOV( ureg, dst, src );
    ureg_END( ureg );
 
    return ureg_create_shader_and_destroy( ureg, pipe );
 }
-
-
index d2e80d6eb4d1dcaf9c63ec09bd36288fc8d3200e..6e760942e25242d48fa9587d9e52626071a43378 100644 (file)
@@ -51,16 +51,25 @@ util_make_vertex_passthrough_shader(struct pipe_context *pipe,
 
 extern void *
 util_make_fragment_tex_shader_writemask(struct pipe_context *pipe, 
-                                        unsigned writemask );
+                                        unsigned tex_target,
+                                        unsigned writemask);
 
 extern void *
-util_make_fragment_tex_shader(struct pipe_context *pipe);
+util_make_fragment_tex_shader(struct pipe_context *pipe, unsigned tex_target);
+
+
+extern void *
+util_make_fragment_tex_shader_writedepth(struct pipe_context *pipe,
+                                         unsigned tex_target);
 
 
 extern void *
 util_make_fragment_passthrough_shader(struct pipe_context *pipe);
 
 
+extern void *
+util_make_fragment_clonecolor_shader(struct pipe_context *pipe, int num_cbufs);
+
 #ifdef __cplusplus
 }
 #endif
index 5cd05b29047d99aa780c6f2fdf2ad57e57209771..4d976d6dca42e7496024d7980113a28082a1548a 100644 (file)
@@ -32,7 +32,7 @@
 
 #include "pipe/p_config.h"
 
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_SUBSYSTEM_WINDOWS_USER) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_HAIKU)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_SUBSYSTEM_WINDOWS_USER) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_APPLE)
 
 #include <stdio.h>
 
index cfdf7ab8f8a9fb6ea3213d460bac93fa87ee04bd..f66376ad7509ff04eda038d0db9e865a0feea22b 100644 (file)
@@ -37,6 +37,7 @@
 #include "pipe/p_defines.h"
 
 #include "util/u_memory.h"
+#include "util/u_format.h"
 #include "util/u_surface.h"
 
 
@@ -80,10 +81,9 @@ util_create_rgba_surface(struct pipe_screen *screen,
    templ.target = target;
    templ.format = format;
    templ.last_level = 0;
-   templ.width[0] = width;
-   templ.height[0] = height;
-   templ.depth[0] = 1;
-   pf_get_block(format, &templ.block);
+   templ.width0 = width;
+   templ.height0 = height;
+   templ.depth0 = 1;
    templ.tex_usage = usage;
 
    *textureOut = screen->texture_create(screen, &templ);
diff --git a/src/gallium/auxiliary/util/u_texture.c b/src/gallium/auxiliary/util/u_texture.c
new file mode 100644 (file)
index 0000000..cd477ab
--- /dev/null
@@ -0,0 +1,102 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ * Copyright 2008 VMware, Inc.  All rights reserved.
+ * Copyright 2009 Marek Olšák <maraeo@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 the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * @file
+ * Texture mapping utility functions.
+ *
+ * @author Brian Paul
+ *         Marek Olšák
+ */
+
+#include "pipe/p_defines.h"
+
+#include "util/u_texture.h"
+
+void util_map_texcoords2d_onto_cubemap(unsigned face,
+                                       const float *in_st, unsigned in_stride,
+                                       float *out_str, unsigned out_stride)
+{
+   int i;
+   float rx, ry, rz;
+
+   /* loop over quad verts */
+   for (i = 0; i < 4; i++) {
+      /* Compute sc = +/-scale and tc = +/-scale.
+       * Not +/-1 to avoid cube face selection ambiguity near the edges,
+       * though that can still sometimes happen with this scale factor...
+       */
+      const float scale = 0.9999f;
+      const float sc = (2 * in_st[0] - 1) * scale;
+      const float tc = (2 * in_st[1] - 1) * scale;
+
+      switch (face) {
+         case PIPE_TEX_FACE_POS_X:
+            rx = 1;
+            ry = -tc;
+            rz = -sc;
+            break;
+         case PIPE_TEX_FACE_NEG_X:
+            rx = -1;
+            ry = -tc;
+            rz = sc;
+            break;
+         case PIPE_TEX_FACE_POS_Y:
+            rx = sc;
+            ry = 1;
+            rz = tc;
+            break;
+         case PIPE_TEX_FACE_NEG_Y:
+            rx = sc;
+            ry = -1;
+            rz = -tc;
+            break;
+         case PIPE_TEX_FACE_POS_Z:
+            rx = sc;
+            ry = -tc;
+            rz = 1;
+            break;
+         case PIPE_TEX_FACE_NEG_Z:
+            rx = -sc;
+            ry = -tc;
+            rz = -1;
+            break;
+         default:
+            rx = ry = rz = 0;
+            assert(0);
+      }
+
+      out_str[0] = rx; /*s*/
+      out_str[1] = ry; /*t*/
+      out_str[2] = rz; /*r*/
+
+      in_st += in_stride;
+      out_str += out_stride;
+   }
+}
diff --git a/src/gallium/auxiliary/util/u_texture.h b/src/gallium/auxiliary/util/u_texture.h
new file mode 100644 (file)
index 0000000..93b2f1e
--- /dev/null
@@ -0,0 +1,54 @@
+/**************************************************************************
+ *
+ * Copyright 2009 Marek Olšák <maraeo@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 the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 U_TEXTURE_H
+#define U_TEXTURE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Convert 2D texture coordinates of 4 vertices into cubemap coordinates
+ * in the given face.
+ * Coordinates must be in the range [0,1].
+ *
+ * \param face          Cubemap face.
+ * \param in_st         4 pairs of 2D texture coordinates to convert.
+ * \param in_stride     Stride of in_st in floats.
+ * \param out_str       STR cubemap texture coordinates to compute.
+ * \param out_stride    Stride of out_str in floats.
+ */
+void util_map_texcoords2d_onto_cubemap(unsigned face,
+                                       const float *in_st, unsigned in_stride,
+                                       float *out_str, unsigned out_stride);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
index 8a22f584bee766962c09a1d01fd642670d3a8337..1ba82bb21f0fb4c2875701af190259693bc0249d 100644 (file)
@@ -34,6 +34,7 @@
 #include "pipe/p_defines.h"
 #include "pipe/p_inlines.h"
 
+#include "util/u_format.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
 #include "util/u_rect.h"
@@ -52,7 +53,7 @@ pipe_get_tile_raw(struct pipe_transfer *pt,
    const void *src;
 
    if (dst_stride == 0)
-      dst_stride = pf_get_nblocksx(&pt->block, w) * pt->block.size;
+      dst_stride = util_format_get_stride(pt->texture->format, w);
 
    if (pipe_clip_tile(x, y, &w, &h, pt))
       return;
@@ -62,7 +63,7 @@ pipe_get_tile_raw(struct pipe_transfer *pt,
    if(!src)
       return;
 
-   util_copy_rect(dst, &pt->block, dst_stride, 0, 0, w, h, src, pt->stride, x, y);
+   util_copy_rect(dst, pt->texture->format, dst_stride, 0, 0, w, h, src, pt->stride, x, y);
 
    screen->transfer_unmap(screen, pt);
 }
@@ -78,9 +79,10 @@ pipe_put_tile_raw(struct pipe_transfer *pt,
 {
    struct pipe_screen *screen = pt->texture->screen;
    void *dst;
+   enum pipe_format format = pt->texture->format;
 
    if (src_stride == 0)
-      src_stride = pf_get_nblocksx(&pt->block, w) * pt->block.size;
+      src_stride = util_format_get_stride(format, w);
 
    if (pipe_clip_tile(x, y, &w, &h, pt))
       return;
@@ -90,7 +92,7 @@ pipe_put_tile_raw(struct pipe_transfer *pt,
    if(!dst)
       return;
 
-   util_copy_rect(dst, &pt->block, pt->stride, x, y, w, h, src, src_stride, 0, 0);
+   util_copy_rect(dst, format, pt->stride, x, y, w, h, src, src_stride, 0, 0);
 
    screen->transfer_unmap(screen, pt);
 }
@@ -246,6 +248,53 @@ b8g8r8a8_put_tile_rgba(unsigned *dst,
 }
 
 
+/*** PIPE_FORMAT_R8G8B8A8_UNORM ***/
+
+static void
+r8g8b8a8_get_tile_rgba(const unsigned *src,
+                       unsigned w, unsigned h,
+                       float *p,
+                       unsigned dst_stride)
+{
+   unsigned i, j;
+
+   for (i = 0; i < h; i++) {
+      float *pRow = p;
+      for (j = 0; j < w; j++, pRow += 4) {
+         const unsigned pixel = *src++;
+         pRow[0] = ubyte_to_float((pixel >> 24) & 0xff);
+         pRow[1] = ubyte_to_float((pixel >> 16) & 0xff);
+         pRow[2] = ubyte_to_float((pixel >>  8) & 0xff);
+         pRow[3] = ubyte_to_float((pixel >>  0) & 0xff);
+      }
+      p += dst_stride;
+   }
+}
+
+
+static void
+r8g8b8a8_put_tile_rgba(unsigned *dst,
+                       unsigned w, unsigned h,
+                       const float *p,
+                       unsigned src_stride)
+{
+   unsigned i, j;
+
+   for (i = 0; i < h; i++) {
+      const float *pRow = p;
+      for (j = 0; j < w; j++, pRow += 4) {
+         unsigned r, g, b, a;
+         r = float_to_ubyte(pRow[0]);
+         g = float_to_ubyte(pRow[1]);
+         b = float_to_ubyte(pRow[2]);
+         a = float_to_ubyte(pRow[3]);
+         *dst++ = (r << 24) | (g << 16) | (b << 8) | a;
+      }
+      p += src_stride;
+   }
+}
+
+
 /*** PIPE_FORMAT_A1R5G5B5_UNORM ***/
 
 static void
@@ -1106,27 +1155,6 @@ ycbcr_get_tile_rgba(const ushort *src,
 }
 
 
-static void
-fake_get_tile_rgba(const ushort *src,
-                   unsigned w, unsigned h,
-                   float *p,
-                   unsigned dst_stride)
-{
-   unsigned i, j;
-
-   for (i = 0; i < h; i++) {
-      float *pRow = p;
-      for (j = 0; j < w; j++, pRow += 4) {
-         pRow[0] =
-         pRow[1] =
-         pRow[2] =
-         pRow[3] = (i ^ j) & 1 ? 1.0f : 0.0f;
-      }
-      p += dst_stride;
-   }
-}
-
-
 void
 pipe_tile_raw_to_rgba(enum pipe_format format,
                       void *src,
@@ -1143,6 +1171,9 @@ pipe_tile_raw_to_rgba(enum pipe_format format,
    case PIPE_FORMAT_B8G8R8A8_UNORM:
       b8g8r8a8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride);
       break;
+   case PIPE_FORMAT_R8G8B8A8_UNORM:
+      r8g8b8a8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride);
+      break;
    case PIPE_FORMAT_A1R5G5B5_UNORM:
       a1r5g5b5_get_tile_rgba((ushort *) src, w, h, dst, dst_stride);
       break;
@@ -1206,8 +1237,10 @@ pipe_tile_raw_to_rgba(enum pipe_format format,
       ycbcr_get_tile_rgba((ushort *) src, w, h, dst, dst_stride, TRUE);
       break;
    default:
-      debug_printf("%s: unsupported format %s\n", __FUNCTION__, pf_name(format));
-      fake_get_tile_rgba(src, w, h, dst, dst_stride);
+      util_format_read_4f(format,
+                          dst, dst_stride * sizeof(float),
+                          src, util_format_get_stride(format, w),
+                          0, 0, w, h);
    }
 }
 
@@ -1219,21 +1252,22 @@ pipe_get_tile_rgba(struct pipe_transfer *pt,
 {
    unsigned dst_stride = w * 4;
    void *packed;
+   enum pipe_format format = pt->texture->format;
 
    if (pipe_clip_tile(x, y, &w, &h, pt))
       return;
 
-   packed = MALLOC(pf_get_nblocks(&pt->block, w, h) * pt->block.size);
+   packed = MALLOC(util_format_get_nblocks(format, w, h) * util_format_get_blocksize(format));
 
    if (!packed)
       return;
 
-   if(pt->format == PIPE_FORMAT_YCBCR || pt->format == PIPE_FORMAT_YCBCR_REV)
+   if(format == PIPE_FORMAT_YCBCR || format == PIPE_FORMAT_YCBCR_REV)
       assert((x & 1) == 0);
 
    pipe_get_tile_raw(pt, x, y, w, h, packed, 0);
 
-   pipe_tile_raw_to_rgba(pt->format, packed, w, h, p, dst_stride);
+   pipe_tile_raw_to_rgba(format, packed, w, h, p, dst_stride);
 
    FREE(packed);
 }
@@ -1246,16 +1280,17 @@ pipe_put_tile_rgba(struct pipe_transfer *pt,
 {
    unsigned src_stride = w * 4;
    void *packed;
+   enum pipe_format format = pt->texture->format;
 
    if (pipe_clip_tile(x, y, &w, &h, pt))
       return;
 
-   packed = MALLOC(pf_get_nblocks(&pt->block, w, h) * pt->block.size);
+   packed = MALLOC(util_format_get_nblocks(format, w, h) * util_format_get_blocksize(format));
 
    if (!packed)
       return;
 
-   switch (pt->format) {
+   switch (format) {
    case PIPE_FORMAT_A8R8G8B8_UNORM:
       a8r8g8b8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);
       break;
@@ -1265,6 +1300,9 @@ pipe_put_tile_rgba(struct pipe_transfer *pt,
    case PIPE_FORMAT_B8G8R8A8_UNORM:
       b8g8r8a8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);
       break;
+   case PIPE_FORMAT_R8G8B8A8_UNORM:
+      r8g8b8a8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);
+      break;
    case PIPE_FORMAT_A1R5G5B5_UNORM:
       a1r5g5b5_put_tile_rgba((ushort *) packed, w, h, p, src_stride);
       break;
@@ -1274,9 +1312,6 @@ pipe_put_tile_rgba(struct pipe_transfer *pt,
    case PIPE_FORMAT_R8G8B8_UNORM:
       r8g8b8_put_tile_rgba((ubyte *) packed, w, h, p, src_stride);
       break;
-   case PIPE_FORMAT_R8G8B8A8_UNORM:
-      assert(0);
-      break;
    case PIPE_FORMAT_A4R4G4B4_UNORM:
       a4r4g4b4_put_tile_rgba((ushort *) packed, w, h, p, src_stride);
       break;
@@ -1322,7 +1357,7 @@ pipe_put_tile_rgba(struct pipe_transfer *pt,
       /*z24s8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/
       break;
    default:
-      debug_printf("%s: unsupported format %s\n", __FUNCTION__, pf_name(pt->format));
+      debug_printf("%s: unsupported format %s\n", __FUNCTION__, pf_name(format));
    }
 
    pipe_put_tile_raw(pt, x, y, w, h, packed, 0);
@@ -1344,6 +1379,7 @@ pipe_get_tile_z(struct pipe_transfer *pt,
    ubyte *map;
    uint *pDest = z;
    uint i, j;
+   enum pipe_format format = pt->texture->format;
 
    if (pipe_clip_tile(x, y, &w, &h, pt))
       return;
@@ -1354,7 +1390,7 @@ pipe_get_tile_z(struct pipe_transfer *pt,
       return;
    }
 
-   switch (pt->format) {
+   switch (format) {
    case PIPE_FORMAT_Z32_UNORM:
       {
          const uint *ptrc
@@ -1428,6 +1464,7 @@ pipe_put_tile_z(struct pipe_transfer *pt,
    const uint *ptrc = zSrc;
    ubyte *map;
    uint i, j;
+   enum pipe_format format = pt->texture->format;
 
    if (pipe_clip_tile(x, y, &w, &h, pt))
       return;
@@ -1438,7 +1475,7 @@ pipe_put_tile_z(struct pipe_transfer *pt,
       return;
    }
 
-   switch (pt->format) {
+   switch (format) {
    case PIPE_FORMAT_Z32_UNORM:
       {
          uint *pDest = (uint *) (map + y * pt->stride + x*4);
index eb635c9f149cd4a355b78497fc85aa9a8912eb1d..975ee89c4551df262de09cc2b3ad613c4816edeb 100644 (file)
@@ -29,7 +29,7 @@
  * coalescing small buffers into larger ones.
  */
 
-#include "pipe/p_error.h"
+#include "pipe/p_defines.h"
 #include "pipe/p_inlines.h"
 #include "pipe/p_screen.h"
 #include "util/u_memory.h"
index 745b5834af648b571c0da27fda50707283b84584..e158bed9d04291910e373463525f55b26413734f 100644 (file)
@@ -32,6 +32,8 @@
 #ifndef U_UPLOAD_MGR_H
 #define U_UPLOAD_MGR_H
 
+#include "pipe/p_defines.h"
+
 struct pipe_screen;
 struct pipe_buffer;
 struct u_upload_mgr;
diff --git a/src/gallium/auxiliary/vl/Makefile b/src/gallium/auxiliary/vl/Makefile
deleted file mode 100644 (file)
index 4314c1e..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = vl
-
-C_SOURCES = \
-       vl_bitstream_parser.c \
-       vl_mpeg12_mc_renderer.c \
-       vl_compositor.c \
-        vl_csc.c \
-       vl_shader_build.c
-
-include ../../Makefile.template
diff --git a/src/gallium/auxiliary/vl/SConscript b/src/gallium/auxiliary/vl/SConscript
deleted file mode 100644 (file)
index aed69f5..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-Import('*')
-
-vl = env.ConvenienceLibrary(
-       target = 'vl',
-       source = [
-               'vl_bitstream_parser.c',
-               'vl_mpeg12_mc_renderer.c',
-               'vl_compositor.c',
-                'vl_csc.c',
-               'vl_shader_build.c',
-       ])
-
-auxiliaries.insert(0, vl)
index b36dbeb20885bfe5038639f6152633fef3850137..fc2a1c59a6b13bb28a1b777d90d898d26b567598 100644 (file)
@@ -95,12 +95,11 @@ create_vert_shader(struct vl_compositor *c)
    assert(c);
 
    tokens = (struct tgsi_token*)MALLOC(max_tokens * sizeof(struct tgsi_token));
-   *(struct tgsi_version*)&tokens[0] = tgsi_build_version();
-   header = (struct tgsi_header*)&tokens[1];
+   header = (struct tgsi_header*)&tokens[0];
    *header = tgsi_build_header();
-   *(struct tgsi_processor*)&tokens[2] = tgsi_build_processor(TGSI_PROCESSOR_VERTEX, header);
+   *(struct tgsi_processor*)&tokens[1] = tgsi_build_processor(TGSI_PROCESSOR_VERTEX, header);
 
-   ti = 3;
+   ti = 2;
 
    /*
     * decl i0             ; Vertex pos
@@ -172,12 +171,11 @@ create_frag_shader(struct vl_compositor *c)
    assert(c);
 
    tokens = (struct tgsi_token*)MALLOC(max_tokens * sizeof(struct tgsi_token));
-   *(struct tgsi_version*)&tokens[0] = tgsi_build_version();
-   header = (struct tgsi_header*)&tokens[1];
+   header = (struct tgsi_header*)&tokens[0];
    *header = tgsi_build_header();
-   *(struct tgsi_processor*)&tokens[2] = tgsi_build_processor(TGSI_PROCESSOR_FRAGMENT, header);
+   *(struct tgsi_processor*)&tokens[1] = tgsi_build_processor(TGSI_PROCESSOR_FRAGMENT, header);
 
-   ti = 3;
+   ti = 2;
 
    /* decl i0             ; Texcoords for s0 */
    decl = vl_decl_interpolated_input(TGSI_SEMANTIC_GENERIC, 1, 0, 0, TGSI_INTERPOLATE_LINEAR);
@@ -213,7 +211,7 @@ create_frag_shader(struct vl_compositor *c)
     */
    for (i = 0; i < 4; ++i) {
       inst = vl_inst3(TGSI_OPCODE_DP4, TGSI_FILE_OUTPUT, 0, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_CONSTANT, i);
-      inst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_X << i;
+      inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_X << i;
       ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
    }
 
@@ -455,8 +453,8 @@ void vl_compositor_render(struct vl_compositor          *compositor,
    assert(dst_area);
    assert(picture_type == PIPE_MPEG12_PICTURE_TYPE_FRAME);
 
-   compositor->fb_state.width = dst_surface->width[0];
-   compositor->fb_state.height = dst_surface->height[0];
+   compositor->fb_state.width = dst_surface->width0;
+   compositor->fb_state.height = dst_surface->height0;
    compositor->fb_state.cbufs[0] = compositor->pipe->screen->get_tex_surface
    (
       compositor->pipe->screen,
@@ -473,10 +471,14 @@ void vl_compositor_render(struct vl_compositor          *compositor,
    compositor->viewport.translate[2] = 0;
    compositor->viewport.translate[3] = 0;
 
+   compositor->scissor.maxx = compositor->fb_state.width;
+   compositor->scissor.maxy = compositor->fb_state.height;
+
    compositor->pipe->set_framebuffer_state(compositor->pipe, &compositor->fb_state);
    compositor->pipe->set_viewport_state(compositor->pipe, &compositor->viewport);
-   compositor->pipe->bind_sampler_states(compositor->pipe, 1, &compositor->sampler);
-   compositor->pipe->set_sampler_textures(compositor->pipe, 1, &src_surface);
+   compositor->pipe->set_scissor_state(compositor->pipe, &compositor->scissor);
+   compositor->pipe->bind_fragment_sampler_states(compositor->pipe, 1, &compositor->sampler);
+   compositor->pipe->set_fragment_sampler_textures(compositor->pipe, 1, &src_surface);
    compositor->pipe->bind_vs_state(compositor->pipe, compositor->vertex_shader);
    compositor->pipe->bind_fs_state(compositor->pipe, compositor->fragment_shader);
    compositor->pipe->set_vertex_buffers(compositor->pipe, 2, compositor->vertex_bufs);
@@ -500,12 +502,12 @@ void vl_compositor_render(struct vl_compositor          *compositor,
    vs_consts->dst_trans.z = 0;
    vs_consts->dst_trans.w = 0;
 
-   vs_consts->src_scale.x = src_area->w / (float)src_surface->width[0];
-   vs_consts->src_scale.y = src_area->h / (float)src_surface->height[0];
+   vs_consts->src_scale.x = src_area->w / (float)src_surface->width0;
+   vs_consts->src_scale.y = src_area->h / (float)src_surface->height0;
    vs_consts->src_scale.z = 1;
    vs_consts->src_scale.w = 1;
-   vs_consts->src_trans.x = src_area->x / (float)src_surface->width[0];
-   vs_consts->src_trans.y = src_area->y / (float)src_surface->height[0];
+   vs_consts->src_trans.x = src_area->x / (float)src_surface->width0;
+   vs_consts->src_trans.y = src_area->y / (float)src_surface->height0;
    vs_consts->src_trans.z = 0;
    vs_consts->src_trans.w = 0;
 
index 17e2afd353932af83d23758b52ecc09afa547a85..f441901a7510c33b33159a87923b038f1401f772 100644 (file)
@@ -44,6 +44,7 @@ struct vl_compositor
    void *vertex_shader;
    void *fragment_shader;
    struct pipe_viewport_state viewport;
+   struct pipe_scissor_state scissor;
    struct pipe_vertex_buffer vertex_bufs[2];
    struct pipe_vertex_element vertex_elems[2];
    struct pipe_constant_buffer vs_const_buf, fs_const_buf;
index 6b3614821cc5134785b7ed38d2a192f5f05c1abd..caf581aca60084b1b4aa4f920878ca445aac06b7 100644 (file)
@@ -29,6 +29,7 @@
 #include <assert.h>
 #include <pipe/p_context.h>
 #include <pipe/p_inlines.h>
+#include <util/u_format.h>
 #include <util/u_math.h>
 #include <util/u_memory.h>
 #include <tgsi/tgsi_parse.h>
@@ -115,12 +116,11 @@ create_intra_vert_shader(struct vl_mpeg12_mc_renderer *r)
    assert(r);
 
    tokens = (struct tgsi_token *) malloc(max_tokens * sizeof(struct tgsi_token));
-   *(struct tgsi_version *) &tokens[0] = tgsi_build_version();
-   header = (struct tgsi_header *) &tokens[1];
+   header = (struct tgsi_header *) &tokens[0];
    *header = tgsi_build_header();
-   *(struct tgsi_processor *) &tokens[2] = tgsi_build_processor(TGSI_PROCESSOR_VERTEX, header);
+   *(struct tgsi_processor *) &tokens[1] = tgsi_build_processor(TGSI_PROCESSOR_VERTEX, header);
 
-   ti = 3;
+   ti = 2;
 
    /*
     * decl i0              ; Vertex pos
@@ -185,12 +185,11 @@ create_intra_frag_shader(struct vl_mpeg12_mc_renderer *r)
    assert(r);
 
    tokens = (struct tgsi_token *) malloc(max_tokens * sizeof(struct tgsi_token));
-   *(struct tgsi_version *) &tokens[0] = tgsi_build_version();
-   header = (struct tgsi_header *) &tokens[1];
+   header = (struct tgsi_header *) &tokens[0];
    *header = tgsi_build_header();
-   *(struct tgsi_processor *) &tokens[2] = tgsi_build_processor(TGSI_PROCESSOR_FRAGMENT, header);
+   *(struct tgsi_processor *) &tokens[1] = tgsi_build_processor(TGSI_PROCESSOR_FRAGMENT, header);
 
-   ti = 3;
+   ti = 2;
 
    /*
     * decl i0                      ; Luma texcoords
@@ -237,10 +236,10 @@ create_intra_frag_shader(struct vl_mpeg12_mc_renderer *r)
       ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
 
       inst = vl_inst2(TGSI_OPCODE_MOV, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_TEMPORARY, 1);
-      inst.FullSrcRegisters[0].SrcRegister.SwizzleX = TGSI_SWIZZLE_X;
-      inst.FullSrcRegisters[0].SrcRegister.SwizzleY = TGSI_SWIZZLE_X;
-      inst.FullSrcRegisters[0].SrcRegister.SwizzleZ = TGSI_SWIZZLE_X;
-      inst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_X << i;
+      inst.Src[0].Register.SwizzleX = TGSI_SWIZZLE_X;
+      inst.Src[0].Register.SwizzleY = TGSI_SWIZZLE_X;
+      inst.Src[0].Register.SwizzleZ = TGSI_SWIZZLE_X;
+      inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_X << i;
       ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
    }
 
@@ -278,12 +277,11 @@ create_frame_pred_vert_shader(struct vl_mpeg12_mc_renderer *r)
    assert(r);
 
    tokens = (struct tgsi_token *) malloc(max_tokens * sizeof(struct tgsi_token));
-   *(struct tgsi_version *) &tokens[0] = tgsi_build_version();
-   header = (struct tgsi_header *) &tokens[1];
+   header = (struct tgsi_header *) &tokens[0];
    *header = tgsi_build_header();
-   *(struct tgsi_processor *) &tokens[2] = tgsi_build_processor(TGSI_PROCESSOR_VERTEX, header);
+   *(struct tgsi_processor *) &tokens[1] = tgsi_build_processor(TGSI_PROCESSOR_VERTEX, header);
 
-   ti = 3;
+   ti = 2;
 
    /*
     * decl i0              ; Vertex pos
@@ -336,11 +334,13 @@ create_frame_pred_vert_shader(struct vl_mpeg12_mc_renderer *r)
    free(tokens);
 }
 
+#if 0
 static void
 create_field_pred_vert_shader(struct vl_mpeg12_mc_renderer *r)
 {
    assert(false);
 }
+#endif
 
 static void
 create_frame_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
@@ -361,12 +361,11 @@ create_frame_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
    assert(r);
 
    tokens = (struct tgsi_token *) malloc(max_tokens * sizeof(struct tgsi_token));
-   *(struct tgsi_version *) &tokens[0] = tgsi_build_version();
-   header = (struct tgsi_header *) &tokens[1];
+   header = (struct tgsi_header *) &tokens[0];
    *header = tgsi_build_header();
-   *(struct tgsi_processor *) &tokens[2] = tgsi_build_processor(TGSI_PROCESSOR_FRAGMENT, header);
+   *(struct tgsi_processor *) &tokens[1] = tgsi_build_processor(TGSI_PROCESSOR_FRAGMENT, header);
 
-   ti = 3;
+   ti = 2;
 
    /*
     * decl i0                      ; Luma texcoords
@@ -415,10 +414,10 @@ create_frame_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
       ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
 
       inst = vl_inst2(TGSI_OPCODE_MOV, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_TEMPORARY, 1);
-      inst.FullSrcRegisters[0].SrcRegister.SwizzleX = TGSI_SWIZZLE_X;
-      inst.FullSrcRegisters[0].SrcRegister.SwizzleY = TGSI_SWIZZLE_X;
-      inst.FullSrcRegisters[0].SrcRegister.SwizzleZ = TGSI_SWIZZLE_X;
-      inst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_X << i;
+      inst.Src[0].Register.SwizzleX = TGSI_SWIZZLE_X;
+      inst.Src[0].Register.SwizzleY = TGSI_SWIZZLE_X;
+      inst.Src[0].Register.SwizzleZ = TGSI_SWIZZLE_X;
+      inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_X << i;
       ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
    }
 
@@ -445,11 +444,13 @@ create_frame_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
    free(tokens);
 }
 
+#if 0
 static void
 create_field_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
 {
    assert(false);
 }
+#endif
 
 static void
 create_frame_bi_pred_vert_shader(struct vl_mpeg12_mc_renderer *r)
@@ -470,12 +471,11 @@ create_frame_bi_pred_vert_shader(struct vl_mpeg12_mc_renderer *r)
    assert(r);
 
    tokens = (struct tgsi_token *) malloc(max_tokens * sizeof(struct tgsi_token));
-   *(struct tgsi_version *) &tokens[0] = tgsi_build_version();
-   header = (struct tgsi_header *) &tokens[1];
+   header = (struct tgsi_header *) &tokens[0];
    *header = tgsi_build_header();
-   *(struct tgsi_processor *) &tokens[2] = tgsi_build_processor(TGSI_PROCESSOR_VERTEX, header);
+   *(struct tgsi_processor *) &tokens[1] = tgsi_build_processor(TGSI_PROCESSOR_VERTEX, header);
 
-   ti = 3;
+   ti = 2;
 
    /*
     * decl i0              ; Vertex pos
@@ -536,11 +536,13 @@ create_frame_bi_pred_vert_shader(struct vl_mpeg12_mc_renderer *r)
    free(tokens);
 }
 
+#if 0
 static void
 create_field_bi_pred_vert_shader(struct vl_mpeg12_mc_renderer *r)
 {
    assert(false);
 }
+#endif
 
 static void
 create_frame_bi_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
@@ -561,12 +563,11 @@ create_frame_bi_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
    assert(r);
 
    tokens = (struct tgsi_token *) malloc(max_tokens * sizeof(struct tgsi_token));
-   *(struct tgsi_version *) &tokens[0] = tgsi_build_version();
-   header = (struct tgsi_header *) &tokens[1];
+   header = (struct tgsi_header *) &tokens[0];
    *header = tgsi_build_header();
-   *(struct tgsi_processor *) &tokens[2] = tgsi_build_processor(TGSI_PROCESSOR_FRAGMENT, header);
+   *(struct tgsi_processor *) &tokens[1] = tgsi_build_processor(TGSI_PROCESSOR_FRAGMENT, header);
 
-   ti = 3;
+   ti = 2;
 
    /*
     * decl i0                      ; Luma texcoords
@@ -620,10 +621,10 @@ create_frame_bi_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
       ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
 
       inst = vl_inst2(TGSI_OPCODE_MOV, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_TEMPORARY, 1);
-      inst.FullSrcRegisters[0].SrcRegister.SwizzleX = TGSI_SWIZZLE_X;
-      inst.FullSrcRegisters[0].SrcRegister.SwizzleY = TGSI_SWIZZLE_X;
-      inst.FullSrcRegisters[0].SrcRegister.SwizzleZ = TGSI_SWIZZLE_X;
-      inst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_X << i;
+      inst.Src[0].Register.SwizzleX = TGSI_SWIZZLE_X;
+      inst.Src[0].Register.SwizzleY = TGSI_SWIZZLE_X;
+      inst.Src[0].Register.SwizzleZ = TGSI_SWIZZLE_X;
+      inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_X << i;
       ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
    }
 
@@ -642,10 +643,10 @@ create_frame_bi_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
 
    /* lerp t1, c1.x, t1, t2        ; Blend past and future texels */
    inst = vl_inst4(TGSI_OPCODE_LRP, TGSI_FILE_TEMPORARY, 1, TGSI_FILE_CONSTANT, 1, TGSI_FILE_TEMPORARY, 1, TGSI_FILE_TEMPORARY, 2);
-   inst.FullSrcRegisters[0].SrcRegister.SwizzleX = TGSI_SWIZZLE_X;
-   inst.FullSrcRegisters[0].SrcRegister.SwizzleY = TGSI_SWIZZLE_X;
-   inst.FullSrcRegisters[0].SrcRegister.SwizzleZ = TGSI_SWIZZLE_X;
-   inst.FullSrcRegisters[0].SrcRegister.SwizzleW = TGSI_SWIZZLE_X;
+   inst.Src[0].Register.SwizzleX = TGSI_SWIZZLE_X;
+   inst.Src[0].Register.SwizzleY = TGSI_SWIZZLE_X;
+   inst.Src[0].Register.SwizzleZ = TGSI_SWIZZLE_X;
+   inst.Src[0].Register.SwizzleW = TGSI_SWIZZLE_X;
    ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
 
    /* add o0, t0, t1               ; Add past/future ref and differential to form final output */
@@ -663,11 +664,13 @@ create_frame_bi_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
    free(tokens);
 }
 
+#if 0
 static void
 create_field_bi_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
 {
    assert(false);
 }
+#endif
 
 static void
 xfer_buffers_map(struct vl_mpeg12_mc_renderer *r)
@@ -681,7 +684,7 @@ xfer_buffers_map(struct vl_mpeg12_mc_renderer *r)
       (
          r->pipe->screen, r->textures.all[i],
          0, 0, 0, PIPE_TRANSFER_WRITE, 0, 0,
-         r->textures.all[i]->width[0], r->textures.all[i]->height[0]
+         r->textures.all[i]->width0, r->textures.all[i]->height0
       );
 
       r->texels[i] = r->pipe->screen->transfer_map(r->pipe->screen, r->tex_transfer[i]);
@@ -721,6 +724,11 @@ init_pipe_state(struct vl_mpeg12_mc_renderer *r)
    r->viewport.translate[2] = 0;
    r->viewport.translate[3] = 0;
 
+   r->scissor.maxx = r->pot_buffers ?
+      util_next_power_of_two(r->picture_width) : r->picture_width;
+   r->scissor.maxy = r->pot_buffers ?
+      util_next_power_of_two(r->picture_height) : r->picture_height;
+
    r->fb_state.width = r->pot_buffers ?
       util_next_power_of_two(r->picture_width) : r->picture_width;
    r->fb_state.height = r->pot_buffers ?
@@ -830,26 +838,25 @@ init_buffers(struct vl_mpeg12_mc_renderer *r)
    /* TODO: Accomodate HW that can't do this and also for cases when this isn't precise enough */
    template.format = PIPE_FORMAT_R16_SNORM;
    template.last_level = 0;
-   template.width[0] = r->pot_buffers ?
+   template.width0 = r->pot_buffers ?
       util_next_power_of_two(r->picture_width) : r->picture_width;
-   template.height[0] = r->pot_buffers ?
+   template.height0 = r->pot_buffers ?
       util_next_power_of_two(r->picture_height) : r->picture_height;
-   template.depth[0] = 1;
-   pf_get_block(template.format, &template.block);
+   template.depth0 = 1;
    template.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER | PIPE_TEXTURE_USAGE_DYNAMIC;
 
    r->textures.individual.y = r->pipe->screen->texture_create(r->pipe->screen, &template);
 
    if (r->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420) {
-      template.width[0] = r->pot_buffers ?
+      template.width0 = r->pot_buffers ?
          util_next_power_of_two(r->picture_width / 2) :
          r->picture_width / 2;
-      template.height[0] = r->pot_buffers ?
+      template.height0 = r->pot_buffers ?
          util_next_power_of_two(r->picture_height / 2) :
          r->picture_height / 2;
    }
    else if (r->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_422)
-      template.height[0] = r->pot_buffers ?
+      template.height0 = r->pot_buffers ?
          util_next_power_of_two(r->picture_height / 2) :
          r->picture_height / 2;
 
@@ -1082,6 +1089,9 @@ gen_macroblock_verts(struct vl_mpeg12_mc_renderer *r,
    assert(ycbcr_vb);
    assert(pos < r->macroblocks_per_batch);
 
+   mo_vec[1].x = 0;
+   mo_vec[1].y = 0;
+
    switch (mb->mb_type) {
       case PIPE_MPEG12_MACROBLOCK_TYPE_BI:
       {
@@ -1270,6 +1280,7 @@ flush(struct vl_mpeg12_mc_renderer *r)
 
    r->pipe->set_framebuffer_state(r->pipe, &r->fb_state);
    r->pipe->set_viewport_state(r->pipe, &r->viewport);
+   r->pipe->set_scissor_state(r->pipe, &r->scissor);
 
    vs_consts = pipe_buffer_map
    (
@@ -1277,8 +1288,8 @@ flush(struct vl_mpeg12_mc_renderer *r)
       PIPE_BUFFER_USAGE_CPU_WRITE | PIPE_BUFFER_USAGE_DISCARD
    );
 
-   vs_consts->denorm.x = r->surface->width[0];
-   vs_consts->denorm.y = r->surface->height[0];
+   vs_consts->denorm.x = r->surface->width0;
+   vs_consts->denorm.y = r->surface->height0;
 
    pipe_buffer_unmap(r->pipe->screen, r->vs_const_buf.buffer);
 
@@ -1290,8 +1301,8 @@ flush(struct vl_mpeg12_mc_renderer *r)
    if (num_macroblocks[MACROBLOCK_TYPE_INTRA] > 0) {
       r->pipe->set_vertex_buffers(r->pipe, 1, r->vertex_bufs.all);
       r->pipe->set_vertex_elements(r->pipe, 4, r->vertex_elems);
-      r->pipe->set_sampler_textures(r->pipe, 3, r->textures.all);
-      r->pipe->bind_sampler_states(r->pipe, 3, r->samplers.all);
+      r->pipe->set_fragment_sampler_textures(r->pipe, 3, r->textures.all);
+      r->pipe->bind_fragment_sampler_states(r->pipe, 3, r->samplers.all);
       r->pipe->bind_vs_state(r->pipe, r->i_vs);
       r->pipe->bind_fs_state(r->pipe, r->i_fs);
 
@@ -1304,8 +1315,8 @@ flush(struct vl_mpeg12_mc_renderer *r)
       r->pipe->set_vertex_buffers(r->pipe, 2, r->vertex_bufs.all);
       r->pipe->set_vertex_elements(r->pipe, 6, r->vertex_elems);
       r->textures.individual.ref[0] = r->past;
-      r->pipe->set_sampler_textures(r->pipe, 4, r->textures.all);
-      r->pipe->bind_sampler_states(r->pipe, 4, r->samplers.all);
+      r->pipe->set_fragment_sampler_textures(r->pipe, 4, r->textures.all);
+      r->pipe->bind_fragment_sampler_states(r->pipe, 4, r->samplers.all);
       r->pipe->bind_vs_state(r->pipe, r->p_vs[0]);
       r->pipe->bind_fs_state(r->pipe, r->p_fs[0]);
 
@@ -1318,8 +1329,8 @@ flush(struct vl_mpeg12_mc_renderer *r)
       r->pipe->set_vertex_buffers(r->pipe, 2, r->vertex_bufs.all);
       r->pipe->set_vertex_elements(r->pipe, 6, r->vertex_elems);
       r->textures.individual.ref[0] = r->past;
-      r->pipe->set_sampler_textures(r->pipe, 4, r->textures.all);
-      r->pipe->bind_sampler_states(r->pipe, 4, r->samplers.all);
+      r->pipe->set_fragment_sampler_textures(r->pipe, 4, r->textures.all);
+      r->pipe->bind_fragment_sampler_states(r->pipe, 4, r->samplers.all);
       r->pipe->bind_vs_state(r->pipe, r->p_vs[1]);
       r->pipe->bind_fs_state(r->pipe, r->p_fs[1]);
 
@@ -1332,8 +1343,8 @@ flush(struct vl_mpeg12_mc_renderer *r)
       r->pipe->set_vertex_buffers(r->pipe, 2, r->vertex_bufs.all);
       r->pipe->set_vertex_elements(r->pipe, 6, r->vertex_elems);
       r->textures.individual.ref[0] = r->future;
-      r->pipe->set_sampler_textures(r->pipe, 4, r->textures.all);
-      r->pipe->bind_sampler_states(r->pipe, 4, r->samplers.all);
+      r->pipe->set_fragment_sampler_textures(r->pipe, 4, r->textures.all);
+      r->pipe->bind_fragment_sampler_states(r->pipe, 4, r->samplers.all);
       r->pipe->bind_vs_state(r->pipe, r->p_vs[0]);
       r->pipe->bind_fs_state(r->pipe, r->p_fs[0]);
 
@@ -1346,8 +1357,8 @@ flush(struct vl_mpeg12_mc_renderer *r)
       r->pipe->set_vertex_buffers(r->pipe, 2, r->vertex_bufs.all);
       r->pipe->set_vertex_elements(r->pipe, 6, r->vertex_elems);
       r->textures.individual.ref[0] = r->future;
-      r->pipe->set_sampler_textures(r->pipe, 4, r->textures.all);
-      r->pipe->bind_sampler_states(r->pipe, 4, r->samplers.all);
+      r->pipe->set_fragment_sampler_textures(r->pipe, 4, r->textures.all);
+      r->pipe->bind_fragment_sampler_states(r->pipe, 4, r->samplers.all);
       r->pipe->bind_vs_state(r->pipe, r->p_vs[1]);
       r->pipe->bind_fs_state(r->pipe, r->p_fs[1]);
 
@@ -1361,8 +1372,8 @@ flush(struct vl_mpeg12_mc_renderer *r)
       r->pipe->set_vertex_elements(r->pipe, 8, r->vertex_elems);
       r->textures.individual.ref[0] = r->past;
       r->textures.individual.ref[1] = r->future;
-      r->pipe->set_sampler_textures(r->pipe, 5, r->textures.all);
-      r->pipe->bind_sampler_states(r->pipe, 5, r->samplers.all);
+      r->pipe->set_fragment_sampler_textures(r->pipe, 5, r->textures.all);
+      r->pipe->bind_fragment_sampler_states(r->pipe, 5, r->samplers.all);
       r->pipe->bind_vs_state(r->pipe, r->b_vs[0]);
       r->pipe->bind_fs_state(r->pipe, r->b_fs[0]);
 
@@ -1376,8 +1387,8 @@ flush(struct vl_mpeg12_mc_renderer *r)
       r->pipe->set_vertex_elements(r->pipe, 8, r->vertex_elems);
       r->textures.individual.ref[0] = r->past;
       r->textures.individual.ref[1] = r->future;
-      r->pipe->set_sampler_textures(r->pipe, 5, r->textures.all);
-      r->pipe->bind_sampler_states(r->pipe, 5, r->samplers.all);
+      r->pipe->set_fragment_sampler_textures(r->pipe, 5, r->textures.all);
+      r->pipe->bind_fragment_sampler_states(r->pipe, 5, r->samplers.all);
       r->pipe->bind_vs_state(r->pipe, r->b_vs[1]);
       r->pipe->bind_fs_state(r->pipe, r->b_fs[1]);
 
@@ -1444,7 +1455,7 @@ grab_blocks(struct vl_mpeg12_mc_renderer *r, unsigned mbx, unsigned mby,
    assert(r);
    assert(blocks);
 
-   tex_pitch = r->tex_transfer[0]->stride / r->tex_transfer[0]->block.size;
+   tex_pitch = r->tex_transfer[0]->stride / util_format_get_blocksize(r->tex_transfer[0]->texture->format);
    texels = r->texels[0] + mbpy * tex_pitch + mbpx;
 
    for (y = 0; y < 2; ++y) {
@@ -1483,7 +1494,7 @@ grab_blocks(struct vl_mpeg12_mc_renderer *r, unsigned mbx, unsigned mby,
    mbpy /= 2;
 
    for (tb = 0; tb < 2; ++tb) {
-      tex_pitch = r->tex_transfer[tb + 1]->stride / r->tex_transfer[tb + 1]->block.size;
+      tex_pitch = r->tex_transfer[tb + 1]->stride / util_format_get_blocksize(r->tex_transfer[tb + 1]->texture->format);
       texels = r->texels[tb + 1] + mbpy * tex_pitch + mbpx;
 
       if ((cbp >> (1 - tb)) & 1) {
@@ -1627,8 +1638,8 @@ vl_mpeg12_mc_renderer_render_macroblocks(struct vl_mpeg12_mc_renderer
       renderer->past = past;
       renderer->future = future;
       renderer->fence = fence;
-      renderer->surface_tex_inv_size.x = 1.0f / surface->width[0];
-      renderer->surface_tex_inv_size.y = 1.0f / surface->height[0];
+      renderer->surface_tex_inv_size.x = 1.0f / surface->width0;
+      renderer->surface_tex_inv_size.y = 1.0f / surface->height0;
    }
 
    while (num_macroblocks) {
index 5d2c1273ee37b12370e8677b6d1ef128e297964f..64184337a069042aa5141f7e91e62b44854c5f9e 100644 (file)
@@ -62,6 +62,7 @@ struct vl_mpeg12_mc_renderer
    unsigned macroblocks_per_batch;
 
    struct pipe_viewport_state viewport;
+   struct pipe_scissor_state scissor;
    struct pipe_constant_buffer vs_const_buf;
    struct pipe_constant_buffer fs_const_buf;
    struct pipe_framebuffer_state fb_state;
index faa20a903cdd27a60845631e1fa029f0488f1b57..d011ef97bd63815b1ef67026a0ef61cc39f90726 100644 (file)
@@ -36,10 +36,10 @@ struct tgsi_full_declaration vl_decl_input(unsigned int name, unsigned int index
 
    decl.Declaration.File = TGSI_FILE_INPUT;
    decl.Declaration.Semantic = 1;
-   decl.Semantic.SemanticName = name;
-   decl.Semantic.SemanticIndex = index;
-   decl.DeclarationRange.First = first;
-   decl.DeclarationRange.Last = last;
+   decl.Semantic.Name = name;
+   decl.Semantic.Index = index;
+   decl.Range.First = first;
+   decl.Range.Last = last;
 
    return decl;
 }
@@ -64,11 +64,11 @@ struct tgsi_full_declaration vl_decl_interpolated_input
 
    decl.Declaration.File = TGSI_FILE_INPUT;
    decl.Declaration.Semantic = 1;
-   decl.Semantic.SemanticName = name;
-   decl.Semantic.SemanticIndex = index;
+   decl.Semantic.Name = name;
+   decl.Semantic.Index = index;
    decl.Declaration.Interpolate = interpolation;;
-   decl.DeclarationRange.First = first;
-   decl.DeclarationRange.Last = last;
+   decl.Range.First = first;
+   decl.Range.Last = last;
 
    return decl;
 }
@@ -79,10 +79,10 @@ struct tgsi_full_declaration vl_decl_constants(unsigned int name, unsigned int i
 
    decl.Declaration.File = TGSI_FILE_CONSTANT;
    decl.Declaration.Semantic = 1;
-   decl.Semantic.SemanticName = name;
-   decl.Semantic.SemanticIndex = index;
-   decl.DeclarationRange.First = first;
-   decl.DeclarationRange.Last = last;
+   decl.Semantic.Name = name;
+   decl.Semantic.Index = index;
+   decl.Range.First = first;
+   decl.Range.Last = last;
 
    return decl;
 }
@@ -93,10 +93,10 @@ struct tgsi_full_declaration vl_decl_output(unsigned int name, unsigned int inde
 
    decl.Declaration.File = TGSI_FILE_OUTPUT;
    decl.Declaration.Semantic = 1;
-   decl.Semantic.SemanticName = name;
-   decl.Semantic.SemanticIndex = index;
-   decl.DeclarationRange.First = first;
-   decl.DeclarationRange.Last = last;
+   decl.Semantic.Name = name;
+   decl.Semantic.Index = index;
+   decl.Range.First = first;
+   decl.Range.Last = last;
 
    return decl;
 }
@@ -107,8 +107,8 @@ struct tgsi_full_declaration vl_decl_temps(unsigned int first, unsigned int last
 
    decl = tgsi_default_full_declaration();
    decl.Declaration.File = TGSI_FILE_TEMPORARY;
-   decl.DeclarationRange.First = first;
-   decl.DeclarationRange.Last = last;
+   decl.Range.First = first;
+   decl.Range.Last = last;
 
    return decl;
 }
@@ -119,8 +119,8 @@ struct tgsi_full_declaration vl_decl_samplers(unsigned int first, unsigned int l
 
    decl = tgsi_default_full_declaration();
    decl.Declaration.File = TGSI_FILE_SAMPLER;
-   decl.DeclarationRange.First = first;
-   decl.DeclarationRange.Last = last;
+   decl.Range.First = first;
+   decl.Range.Last = last;
 
    return decl;
 }
@@ -138,11 +138,11 @@ struct tgsi_full_instruction vl_inst2
 
    inst.Instruction.Opcode = opcode;
    inst.Instruction.NumDstRegs = 1;
-   inst.FullDstRegisters[0].DstRegister.File = dst_file;
-   inst.FullDstRegisters[0].DstRegister.Index = dst_index;
+   inst.Dst[0].Register.File = dst_file;
+   inst.Dst[0].Register.Index = dst_index;
    inst.Instruction.NumSrcRegs = 1;
-   inst.FullSrcRegisters[0].SrcRegister.File = src_file;
-   inst.FullSrcRegisters[0].SrcRegister.Index = src_index;
+   inst.Src[0].Register.File = src_file;
+   inst.Src[0].Register.Index = src_index;
 
    return inst;
 }
@@ -162,13 +162,13 @@ struct tgsi_full_instruction vl_inst3
 
    inst.Instruction.Opcode = opcode;
    inst.Instruction.NumDstRegs = 1;
-   inst.FullDstRegisters[0].DstRegister.File = dst_file;
-   inst.FullDstRegisters[0].DstRegister.Index = dst_index;
+   inst.Dst[0].Register.File = dst_file;
+   inst.Dst[0].Register.Index = dst_index;
    inst.Instruction.NumSrcRegs = 2;
-   inst.FullSrcRegisters[0].SrcRegister.File = src1_file;
-   inst.FullSrcRegisters[0].SrcRegister.Index = src1_index;
-   inst.FullSrcRegisters[1].SrcRegister.File = src2_file;
-   inst.FullSrcRegisters[1].SrcRegister.Index = src2_index;
+   inst.Src[0].Register.File = src1_file;
+   inst.Src[0].Register.Index = src1_index;
+   inst.Src[1].Register.File = src2_file;
+   inst.Src[1].Register.Index = src2_index;
 
    return inst;
 }
@@ -188,14 +188,15 @@ struct tgsi_full_instruction vl_tex
 
    inst.Instruction.Opcode = TGSI_OPCODE_TEX;
    inst.Instruction.NumDstRegs = 1;
-   inst.FullDstRegisters[0].DstRegister.File = dst_file;
-   inst.FullDstRegisters[0].DstRegister.Index = dst_index;
+   inst.Dst[0].Register.File = dst_file;
+   inst.Dst[0].Register.Index = dst_index;
    inst.Instruction.NumSrcRegs = 2;
-   inst.InstructionExtTexture.Texture = tex;
-   inst.FullSrcRegisters[0].SrcRegister.File = src1_file;
-   inst.FullSrcRegisters[0].SrcRegister.Index = src1_index;
-   inst.FullSrcRegisters[1].SrcRegister.File = src2_file;
-   inst.FullSrcRegisters[1].SrcRegister.Index = src2_index;
+   inst.Instruction.Texture = 1;
+   inst.Texture.Texture = tex;
+   inst.Src[0].Register.File = src1_file;
+   inst.Src[0].Register.Index = src1_index;
+   inst.Src[1].Register.File = src2_file;
+   inst.Src[1].Register.Index = src2_index;
 
    return inst;
 }
@@ -217,15 +218,15 @@ struct tgsi_full_instruction vl_inst4
 
    inst.Instruction.Opcode = opcode;
    inst.Instruction.NumDstRegs = 1;
-   inst.FullDstRegisters[0].DstRegister.File = dst_file;
-   inst.FullDstRegisters[0].DstRegister.Index = dst_index;
+   inst.Dst[0].Register.File = dst_file;
+   inst.Dst[0].Register.Index = dst_index;
    inst.Instruction.NumSrcRegs = 3;
-   inst.FullSrcRegisters[0].SrcRegister.File = src1_file;
-   inst.FullSrcRegisters[0].SrcRegister.Index = src1_index;
-   inst.FullSrcRegisters[1].SrcRegister.File = src2_file;
-   inst.FullSrcRegisters[1].SrcRegister.Index = src2_index;
-   inst.FullSrcRegisters[2].SrcRegister.File = src3_file;
-   inst.FullSrcRegisters[2].SrcRegister.Index = src3_index;
+   inst.Src[0].Register.File = src1_file;
+   inst.Src[0].Register.Index = src1_index;
+   inst.Src[1].Register.File = src2_file;
+   inst.Src[1].Register.Index = src2_index;
+   inst.Src[2].Register.File = src3_file;
+   inst.Src[2].Register.Index = src3_index;
 
    return inst;
 }
diff --git a/src/gallium/docs/Makefile b/src/gallium/docs/Makefile
new file mode 100644 (file)
index 0000000..d4a5be4
--- /dev/null
@@ -0,0 +1,89 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS    =
+SPHINXBUILD   = sphinx-build
+PAPER         =
+BUILDDIR      = build
+
+# Internal variables.
+PAPEROPT_a4     = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
+
+.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest
+
+help:
+       @echo "Please use \`make <target>' where <target> is one of"
+       @echo "  html      to make standalone HTML files"
+       @echo "  dirhtml   to make HTML files named index.html in directories"
+       @echo "  pickle    to make pickle files"
+       @echo "  json      to make JSON files"
+       @echo "  htmlhelp  to make HTML files and a HTML help project"
+       @echo "  qthelp    to make HTML files and a qthelp project"
+       @echo "  latex     to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+       @echo "  changes   to make an overview of all changed/added/deprecated items"
+       @echo "  linkcheck to check all external links for integrity"
+       @echo "  doctest   to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+       -rm -rf $(BUILDDIR)/*
+
+html:
+       $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+       @echo
+       @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+       $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+       @echo
+       @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+pickle:
+       $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+       @echo
+       @echo "Build finished; now you can process the pickle files."
+
+json:
+       $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+       @echo
+       @echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+       $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+       @echo
+       @echo "Build finished; now you can run HTML Help Workshop with the" \
+             ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+       $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+       @echo
+       @echo "Build finished; now you can run "qcollectiongenerator" with the" \
+             ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+       @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Gallium.qhcp"
+       @echo "To view the help file:"
+       @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Gallium.qhc"
+
+latex:
+       $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+       @echo
+       @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+       @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
+             "run these through (pdf)latex."
+
+changes:
+       $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+       @echo
+       @echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+       $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+       @echo
+       @echo "Link check complete; look for any errors in the above output " \
+             "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+       $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+       @echo "Testing of doctests in the sources finished, look at the " \
+             "results in $(BUILDDIR)/doctest/output.txt."
diff --git a/src/gallium/docs/make.bat b/src/gallium/docs/make.bat
new file mode 100644 (file)
index 0000000..6f97e07
--- /dev/null
@@ -0,0 +1,113 @@
+@ECHO OFF
+
+REM Command file for Sphinx documentation
+
+set SPHINXBUILD=sphinx-build
+set BUILDDIR=build
+set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% source
+if NOT "%PAPER%" == "" (
+       set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
+)
+
+if "%1" == "" goto help
+
+if "%1" == "help" (
+       :help
+       echo.Please use `make ^<target^>` where ^<target^> is one of
+       echo.  html      to make standalone HTML files
+       echo.  dirhtml   to make HTML files named index.html in directories
+       echo.  pickle    to make pickle files
+       echo.  json      to make JSON files
+       echo.  htmlhelp  to make HTML files and a HTML help project
+       echo.  qthelp    to make HTML files and a qthelp project
+       echo.  latex     to make LaTeX files, you can set PAPER=a4 or PAPER=letter
+       echo.  changes   to make an overview over all changed/added/deprecated items
+       echo.  linkcheck to check all external links for integrity
+       echo.  doctest   to run all doctests embedded in the documentation if enabled
+       goto end
+)
+
+if "%1" == "clean" (
+       for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
+       del /q /s %BUILDDIR%\*
+       goto end
+)
+
+if "%1" == "html" (
+       %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
+       echo.
+       echo.Build finished. The HTML pages are in %BUILDDIR%/html.
+       goto end
+)
+
+if "%1" == "dirhtml" (
+       %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
+       echo.
+       echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
+       goto end
+)
+
+if "%1" == "pickle" (
+       %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
+       echo.
+       echo.Build finished; now you can process the pickle files.
+       goto end
+)
+
+if "%1" == "json" (
+       %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
+       echo.
+       echo.Build finished; now you can process the JSON files.
+       goto end
+)
+
+if "%1" == "htmlhelp" (
+       %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
+       echo.
+       echo.Build finished; now you can run HTML Help Workshop with the ^
+.hhp project file in %BUILDDIR%/htmlhelp.
+       goto end
+)
+
+if "%1" == "qthelp" (
+       %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
+       echo.
+       echo.Build finished; now you can run "qcollectiongenerator" with the ^
+.qhcp project file in %BUILDDIR%/qthelp, like this:
+       echo.^> qcollectiongenerator %BUILDDIR%\qthelp\Gallium.qhcp
+       echo.To view the help file:
+       echo.^> assistant -collectionFile %BUILDDIR%\qthelp\Gallium.ghc
+       goto end
+)
+
+if "%1" == "latex" (
+       %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
+       echo.
+       echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
+       goto end
+)
+
+if "%1" == "changes" (
+       %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
+       echo.
+       echo.The overview file is in %BUILDDIR%/changes.
+       goto end
+)
+
+if "%1" == "linkcheck" (
+       %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
+       echo.
+       echo.Link check complete; look for any errors in the above output ^
+or in %BUILDDIR%/linkcheck/output.txt.
+       goto end
+)
+
+if "%1" == "doctest" (
+       %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
+       echo.
+       echo.Testing of doctests in the sources finished, look at the ^
+results in %BUILDDIR%/doctest/output.txt.
+       goto end
+)
+
+:end
diff --git a/src/gallium/docs/source/conf.py b/src/gallium/docs/source/conf.py
new file mode 100644 (file)
index 0000000..9b0c86b
--- /dev/null
@@ -0,0 +1,197 @@
+# -*- coding: utf-8 -*-
+#
+# Gallium documentation build configuration file, created by
+# sphinx-quickstart on Sun Dec 20 14:09:05 2009.
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys, os
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#sys.path.append(os.path.abspath('.'))
+
+# -- General configuration -----------------------------------------------------
+
+# Add any Sphinx extension module names here, as strings. They can be extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = ['sphinx.ext.pngmath']
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'Gallium'
+copyright = u'2009, VMWare, X.org, Nouveau'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '0.3'
+# The full version, including alpha/beta/rc tags.
+release = '0.3'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of documents that shouldn't be included in the build.
+#unused_docs = []
+
+# List of directories, relative to source directory, that shouldn't be searched
+# for source files.
+exclude_trees = []
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# The language for highlighting source code.
+highlight_language = 'c'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+
+# -- Options for HTML output ---------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages.  Major themes that come with
+# Sphinx are currently 'default' and 'sphinxdoc'.
+html_theme = 'default'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further.  For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents.  If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar.  Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_use_modindex = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it.  The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = ''
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'Galliumdoc'
+
+
+# -- Options for LaTeX output --------------------------------------------------
+
+# The paper size ('letter' or 'a4').
+#latex_paper_size = 'letter'
+
+# The font size ('10pt', '11pt' or '12pt').
+#latex_font_size = '10pt'
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, documentclass [howto/manual]).
+latex_documents = [
+  ('index', 'Gallium.tex', u'Gallium Documentation',
+   u'VMWare, X.org, Nouveau', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# Additional stuff for the LaTeX preamble.
+#latex_preamble = ''
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_use_modindex = True
diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst
new file mode 100644 (file)
index 0000000..21f5f91
--- /dev/null
@@ -0,0 +1,128 @@
+Context
+=======
+
+The context object represents the purest, most directly accessible, abilities
+of the device's 3D rendering pipeline.
+
+Methods
+-------
+
+CSO State
+^^^^^^^^^
+
+All CSO state is created, bound, and destroyed, with triplets of methods that
+all follow a specific naming scheme. For example, ``create_blend_state``,
+``bind_blend_state``, and ``destroy_blend_state``.
+
+CSO objects handled by the context object:
+
+* :ref:`Blend`: ``*_blend_state``
+* :ref:`Sampler`: These are special; they can be bound to either vertex or
+  fragment samplers, and they are bound in groups.
+  ``bind_fragment_sampler_states``, ``bind_vertex_sampler_states``
+* :ref:`Rasterizer`: ``*_rasterizer_state``
+* :ref:`Depth, Stencil, & Alpha`: ``*_depth_stencil_alpha_state``
+* :ref:`Shader`: These have two sets of methods. ``*_fs_state`` is for
+  fragment shaders, and ``*_vs_state`` is for vertex shaders.
+
+
+Resource Binding State
+^^^^^^^^^^^^^^^^^^^^^^
+
+This state describes how resources in various flavours (textures,
+buffers, surfaces) are bound to the driver.
+
+
+* ``set_constant_buffer``
+* ``set_framebuffer_state``
+* ``set_fragment_sampler_textures``
+* ``set_vertex_sampler_textures``
+* ``set_vertex_buffers``
+
+
+Non-CSO State
+^^^^^^^^^^^^^
+
+These pieces of state are too small, variable, and/or trivial to have CSO
+objects. They all follow simple, one-method binding calls, e.g.
+``set_edgeflags``.
+
+* ``set_edgeflags``
+* ``set_blend_color``
+* ``set_clip_state``
+* ``set_polygon_stipple``
+* ``set_scissor_state``
+* ``set_viewport_state``
+* ``set_vertex_elements``
+
+
+Clearing
+^^^^^^^^
+
+``clear`` initializes some or all of the surfaces currently bound to
+the framebuffer to particular RGBA, depth, or stencil values.
+
+Clear is one of the most difficult concepts to nail down to a single
+interface and it seems likely that we will want to add additional
+clear paths, for instance clearing surfaces not bound to the
+framebuffer, or read-modify-write clears such as depth-only or
+stencil-only clears of packed depth-stencil buffers.  
+
+
+Drawing
+^^^^^^^
+
+``draw_arrays``
+
+``draw_elements``
+
+``draw_range_elements``
+
+
+Queries
+^^^^^^^
+
+Queries gather some statistic from the 3D pipeline over one or more
+draws.  Queries may be nested, though no state tracker currently
+exercises this.  
+
+Queries can be created with ``create_query`` and deleted with
+``destroy_query``. To enable a query, use ``begin_query``, and when finished,
+use ``end_query`` to stop the query. Finally, ``get_query_result`` is used
+to retrieve the results.
+
+Flushing
+^^^^^^^^
+
+``flush``
+
+
+Resource Busy Queries
+^^^^^^^^^^^^^^^^^^^^^
+
+``is_texture_referenced``
+
+``is_buffer_referenced``
+
+
+
+Blitting
+^^^^^^^^
+
+These methods emulate classic blitter controls. They are not guaranteed to be
+available; if they are set to NULL, then they are not present.
+
+These methods operate directly on ``pipe_surface`` objects, and stand
+apart from any 3D state in the context.  Blitting functionality may be
+moved to a separate abstraction at some point in the future.
+
+``surface_fill`` performs a fill operation on a section of a surface.
+
+``surface_copy`` blits a region of a surface to a region of another surface,
+provided that both surfaces are the same format. The source and destination
+may be the same surface, and overlapping blits are permitted.
+
+The interfaces to these calls are likely to change to make it easier
+for a driver to batch multiple blits with the same source and
+destination.
+
diff --git a/src/gallium/docs/source/cso.rst b/src/gallium/docs/source/cso.rst
new file mode 100644 (file)
index 0000000..dab1ee5
--- /dev/null
@@ -0,0 +1,14 @@
+CSO
+===
+
+CSO, Constant State Objects, are a core part of Gallium's API.
+
+CSO work on the principle of reusable state; they are created by filling
+out a state object with the desired properties, then passing that object
+to a context. The context returns an opaque context-specific handle which
+can be bound at any time for the desired effect.
+
+.. toctree::
+   :glob:
+
+   cso/*
diff --git a/src/gallium/docs/source/cso/blend.rst b/src/gallium/docs/source/cso/blend.rst
new file mode 100644 (file)
index 0000000..fd9e4a1
--- /dev/null
@@ -0,0 +1,14 @@
+.. _blend:
+
+Blend
+=====
+
+This state controls blending of the final fragments into the target rendering
+buffers.
+
+XXX it is unresolved what behavior should result if blend_enable is off.
+
+Members
+-------
+
+XXX undocumented members
diff --git a/src/gallium/docs/source/cso/dsa.rst b/src/gallium/docs/source/cso/dsa.rst
new file mode 100644 (file)
index 0000000..12abaa9
--- /dev/null
@@ -0,0 +1,58 @@
+.. _depth,stencil,&alpha:
+
+Depth, Stencil, & Alpha
+=======================
+
+These three states control the depth, stencil, and alpha tests, used to
+discard fragments that have passed through the fragment shader.
+
+Traditionally, these three tests have been clumped together in hardware, so
+they are all stored in one structure.
+
+During actual execution, the order of operations done on fragments is always:
+
+* Stencil
+* Depth
+* Alpha
+
+Depth Members
+-------------
+
+enabled
+    Whether the depth test is enabled.
+writemask
+    Whether the depth buffer receives depth writes.
+func
+    The depth test function. One of PIPE_FUNC.
+
+Stencil Members
+---------------
+
+XXX document valuemask, writemask
+
+enabled
+    Whether the stencil test is enabled. For the second stencil, whether the
+    two-sided stencil is enabled.
+func
+    The stencil test function. One of PIPE_FUNC.
+ref_value
+    Stencil test reference value; used for certain functions.
+fail_op
+    The operation to carry out if the stencil test fails. One of
+    PIPE_STENCIL_OP.
+zfail_op
+    The operation to carry out if the stencil test passes but the depth test
+    fails. One of PIPE_STENCIL_OP.
+zpass_op
+    The operation to carry out if the stencil test and depth test both pass.
+    One of PIPE_STENCIL_OP.
+
+Alpha Members
+-------------
+
+enabled
+    Whether the alpha test is enabled.
+func
+    The alpha test function. One of PIPE_FUNC.
+ref_value
+    Alpha test reference value; used for certain functions.
diff --git a/src/gallium/docs/source/cso/rasterizer.rst b/src/gallium/docs/source/cso/rasterizer.rst
new file mode 100644 (file)
index 0000000..4d8e170
--- /dev/null
@@ -0,0 +1,152 @@
+.. _rasterizer:
+
+Rasterizer
+==========
+
+The rasterizer state controls the rendering of points, lines and triangles.
+Attributes include polygon culling state, line width, line stipple,
+multisample state, scissoring and flat/smooth shading.
+
+
+Members
+-------
+
+flatshade
+    If set, the provoking vertex of each polygon is used to determine the
+    color of the entire polygon.  If not set, fragment colors will be
+    interpolated between the vertex colors.
+    Note that this is separate from the fragment shader input attributes
+    CONSTANT, LINEAR and PERSPECTIVE.  We need the flatshade state at
+    clipping time to determine how to set the color of new vertices.
+    Also note that the draw module can implement flat shading by copying
+    the provoking vertex color to all the other vertices in the primitive.
+
+flatshade_first
+    Whether the first vertex should be the provoking vertex, for most
+    primitives. If not set, the last vertex is the provoking vertex.
+
+light_twoside
+    If set, there are per-vertex back-facing colors.  The draw module
+    uses this state along with the front/back information to set the
+    final vertex colors prior to rasterization.
+
+front_winding
+    Indicates the window order of front-facing polygons, either
+    PIPE_WINDING_CW or PIPE_WINDING_CCW
+cull_mode
+    Indicates which polygons to cull, either PIPE_WINDING_NONE (cull no
+    polygons), PIPE_WINDING_CW (cull clockwise-winding polygons),
+    PIPE_WINDING_CCW (cull counter clockwise-winding polygons), or
+    PIPE_WINDING_BOTH (cull all polygons).
+
+fill_cw
+    Indicates how to fill clockwise polygons, either PIPE_POLYGON_MODE_FILL,
+    PIPE_POLYGON_MODE_LINE or PIPE_POLYGON_MODE_POINT.
+fill_ccw
+    Indicates how to fill counter clockwise polygons, either
+    PIPE_POLYGON_MODE_FILL, PIPE_POLYGON_MODE_LINE or PIPE_POLYGON_MODE_POINT.
+
+poly_stipple_enable
+    Whether polygon stippling is enabled.
+poly_smooth
+    Controls OpenGL-style polygon smoothing/antialiasing
+offset_cw
+    If set, clockwise polygons will have polygon offset factors applied
+offset_ccw
+    If set, counter clockwise polygons will have polygon offset factors applied
+offset_units
+    Specifies the polygon offset bias
+offset_scale
+    Specifies the polygon offset scale
+
+line_width
+    The width of lines.
+line_smooth
+    Whether lines should be smoothed. Line smoothing is simply anti-aliasing.
+line_stipple_enable
+    Whether line stippling is enabled.
+line_stipple_pattern
+    16-bit bitfield of on/off flags, used to pattern the line stipple.
+line_stipple_factor
+    When drawinga stippled line, each bit in the stipple pattern is
+    repeated N times, where N = line_stipple_factor + 1.
+line_last_pixel
+    Controls whether the last pixel in a line is drawn or not.  OpenGL
+    omits the last pixel to avoid double-drawing pixels at the ends of lines
+    when drawing connected lines.
+
+point_smooth
+    Whether points should be smoothed. Point smoothing turns rectangular
+    points into circles or ovals.
+point_size_per_vertex
+    Whether vertices have a point size element.
+point_size
+    The size of points, if not specified per-vertex.
+point_size_min
+    The minimum size of points.
+point_size_max
+    The maximum size of points.
+point_sprite
+    Whether points are drawn as sprites (textured quads)
+sprite_coord_mode
+    Specifies how the value for each shader output should be computed when
+    drawing sprites.  If PIPE_SPRITE_COORD_NONE, don't change the vertex
+    shader output.  Otherwise, the four vertices of the resulting quad will
+    be assigned texture coordinates.  For PIPE_SPRITE_COORD_LOWER_LEFT, the
+    lower left vertex will have coordinate (0,0,0,1).
+    For PIPE_SPRITE_COORD_UPPER_LEFT, the upper-left vertex will have
+    coordinate (0,0,0,1).
+    This state is needed by the 'draw' module because that's where each
+    point vertex is converted into four quad vertices.  There's no other
+    place to emit the new vertex texture coordinates which are required for
+    sprite rendering.
+    Note that when geometry shaders are available, this state could be
+    removed.  A special geometry shader defined by the state tracker could
+    converts the incoming points into quads with the proper texture coords.
+
+scissor
+    Whether the scissor test is enabled.
+
+multisample
+    Whether :ref:`MSAA` is enabled.
+
+bypass_vs_clip_and_viewport
+    Whether the entire TCL pipeline should be bypassed. This implies that
+    vertices are pre-transformed for the viewport, and will not be run
+    through the vertex shader. Note that implementations may still clip away
+    vertices that are not in the viewport.
+
+gl_rasterization_rules
+    Whether the rasterizer should use (0.5, 0.5) pixel centers. When not set,
+    the rasterizer will use (0, 0) for pixel centers.
+
+
+Notes
+-----
+
+flatshade
+^^^^^^^^^
+
+The actual interpolated shading algorithm is obviously
+implementation-dependent, but will usually be Gourard for most hardware.
+
+bypass_vs_clip_and_viewport
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+When set, this implies that vertices are pre-transformed for the viewport, and
+will not be run through the vertex shader. Note that implementations may still
+clip away vertices that are not visible.
+
+flatshade_first
+^^^^^^^^^^^^^^^
+
+There are several important exceptions to the specification of this rule.
+
+* ``PIPE_PRIMITIVE_POLYGON``: The provoking vertex is always the first
+  vertex. If the caller wishes to change the provoking vertex, they merely
+  need to rotate the vertices themselves.
+* ``PIPE_PRIMITIVE_QUAD``, ``PIPE_PRIMITIVE_QUAD_STRIP``: This option has no
+  effect; the provoking vertex is always the last vertex.
+* ``PIPE_PRIMITIVE_TRIANGLE_FAN``: When set, the provoking vertex is the
+  second vertex, not the first. This permits each segment of the fan to have
+  a different color.
diff --git a/src/gallium/docs/source/cso/sampler.rst b/src/gallium/docs/source/cso/sampler.rst
new file mode 100644 (file)
index 0000000..e3f1757
--- /dev/null
@@ -0,0 +1,46 @@
+.. _sampler:
+
+Sampler
+=======
+
+Texture units have many options for selecting texels from loaded textures;
+this state controls an individual texture unit's texel-sampling settings.
+
+Texture coordinates are always treated as four-dimensional, and referred to
+with the traditional (S, T, R, Q) notation.
+
+Members
+-------
+
+XXX undocumented compare_mode, compare_func
+
+wrap_s
+    How to wrap the S coordinate. One of PIPE_TEX_WRAP.
+wrap_t
+    How to wrap the T coordinate. One of PIPE_TEX_WRAP.
+wrap_r
+    How to wrap the R coordinate. One of PIPE_TEX_WRAP.
+min_img_filter
+    The filter to use when minifying texels. One of PIPE_TEX_FILTER.
+min_mip_filter
+    The filter to use when minifying mipmapped textures. One of
+    PIPE_TEX_FILTER.
+mag_img_filter
+    The filter to use when magnifying texels. One of PIPE_TEX_FILTER.
+normalized_coords
+    Whether the texture coordinates are normalized. If normalized, they will
+    always be in [0, 1]. If not, they will be in the range of each dimension
+    of the loaded texture.
+prefilter
+    XXX From the Doxy, "weird sampling state exposed by some APIs." Refine.
+lod_bias
+    The bias to apply to the level of detail.
+min_lod
+    Minimum level of detail, used to clamp LoD after bias.
+max_lod
+    Maximum level of detail, used to clamp LoD after bias.
+border_color
+    RGBA color used for out-of-bounds coordinates.
+max_anisotropy
+    Maximum filtering to apply anisotropically to textures. Setting this to
+    1.0 effectively disables anisotropic filtering.
diff --git a/src/gallium/docs/source/cso/shader.rst b/src/gallium/docs/source/cso/shader.rst
new file mode 100644 (file)
index 0000000..0ee42c8
--- /dev/null
@@ -0,0 +1,12 @@
+.. _shader:
+
+Shader
+======
+
+One of the two types of shaders supported by Gallium.
+
+Members
+-------
+
+tokens
+    A list of tgsi_tokens.
diff --git a/src/gallium/docs/source/distro.rst b/src/gallium/docs/source/distro.rst
new file mode 100644 (file)
index 0000000..33e846e
--- /dev/null
@@ -0,0 +1,141 @@
+Distribution
+============
+
+Along with the interface definitions, the following drivers, state trackers,
+and auxiliary modules are shipped in the standard Gallium distribution.
+
+Drivers
+-------
+
+Cell
+^^^^
+
+Failover
+^^^^^^^^
+
+Deprecated.
+
+Intel i915
+^^^^^^^^^^
+
+Intel i965
+^^^^^^^^^^
+
+Highly experimental.
+
+Identity
+^^^^^^^^
+
+Wrapper driver.
+
+LLVM Softpipe
+^^^^^^^^^^^^^
+
+nVidia nv04
+^^^^^^^^^^^
+
+Deprecated.
+
+nVidia nv10
+^^^^^^^^^^^
+
+Deprecated.
+
+nVidia nv20
+^^^^^^^^^^^
+
+Deprecated.
+
+nVidia nv30
+^^^^^^^^^^^
+
+nVidia nv40
+^^^^^^^^^^^
+
+nVidia nv50
+^^^^^^^^^^^
+
+VMWare SVGA
+^^^^^^^^^^^
+
+ATI r300
+^^^^^^^^
+
+AMD/ATI r600
+^^^^^^^^^^^^
+
+Highly experimental.
+
+Softpipe
+^^^^^^^^
+
+Reference software rasterizer.
+
+Trace
+^^^^^
+
+Wrapper driver.
+
+State Trackers
+--------------
+
+Direct Rendering Infrastructure
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+EGL
+^^^
+
+GLX
+^^^
+
+MesaGL
+^^^^^^
+
+Python
+^^^^^^
+
+OpenVG
+^^^^^^
+
+WGL
+^^^
+
+Xorg XFree86 DDX
+^^^^^^^^^^^^^^^^
+
+Auxiliary
+---------
+
+CSO Cache
+^^^^^^^^^
+
+Draw
+^^^^
+
+Gallivm
+^^^^^^^
+
+Indices
+^^^^^^^
+
+Pipe Buffer Manager
+^^^^^^^^^^^^^^^^^^^
+
+Remote Debugger
+^^^^^^^^^^^^^^^
+
+Runtime Assembly Emission
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Surface Context Tracker
+^^^^^^^^^^^^^^^^^^^^^^^
+
+TGSI
+^^^^
+
+Translate
+^^^^^^^^^
+
+Util
+^^^^
+
diff --git a/src/gallium/docs/source/glossary.rst b/src/gallium/docs/source/glossary.rst
new file mode 100644 (file)
index 0000000..6a9110c
--- /dev/null
@@ -0,0 +1,10 @@
+Glossary
+========
+
+.. glossary::
+   :sorted:
+
+   MSAA
+      Multi-Sampled Anti-Aliasing. A basic anti-aliasing technique that takes
+      multiple samples of the depth buffer, and uses this information to
+      smooth the edges of polygons.
diff --git a/src/gallium/docs/source/index.rst b/src/gallium/docs/source/index.rst
new file mode 100644 (file)
index 0000000..54bc883
--- /dev/null
@@ -0,0 +1,28 @@
+.. Gallium documentation master file, created by
+   sphinx-quickstart on Sun Dec 20 14:09:05 2009.
+   You can adapt this file completely to your liking, but it should at least
+   contain the root `toctree` directive.
+
+Welcome to Gallium's documentation!
+===================================
+
+Contents:
+
+.. toctree::
+   :maxdepth: 2
+
+   intro
+   tgsi
+   screen
+   context
+   cso
+   distro
+   glossary
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
+
diff --git a/src/gallium/docs/source/intro.rst b/src/gallium/docs/source/intro.rst
new file mode 100644 (file)
index 0000000..1ea1038
--- /dev/null
@@ -0,0 +1,9 @@
+Introduction
+============
+
+What is Gallium?
+----------------
+
+Gallium is essentially an API for writing graphics drivers in a largely
+device-agnostic fashion. It provides several objects which encapsulate the
+core services of graphics hardware in a straightforward manner.
diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst
new file mode 100644 (file)
index 0000000..9631e69
--- /dev/null
@@ -0,0 +1,39 @@
+Screen
+======
+
+A screen is an object representing the context-independent part of a device.
+
+Methods
+-------
+
+XXX moar; got bored
+
+get_name
+^^^^^^^^
+
+Returns an identifying name for the screen.
+
+get_vendor
+^^^^^^^^^^
+
+Returns the screen vendor.
+
+get_param
+^^^^^^^^^
+
+Get an integer/boolean screen parameter.
+
+get_paramf
+^^^^^^^^^^
+
+Get a floating-point screen parameter.
+
+is_format_supported
+^^^^^^^^^^^^^^^^^^^
+
+See if a format can be used in a specific manner.
+
+texture_create
+^^^^^^^^^^^^^^
+
+Given a template of texture setup, create a BO-backed texture.
diff --git a/src/gallium/docs/source/tgsi.rst b/src/gallium/docs/source/tgsi.rst
new file mode 100644 (file)
index 0000000..ebee490
--- /dev/null
@@ -0,0 +1,1270 @@
+TGSI
+====
+
+TGSI, Tungsten Graphics Shader Infrastructure, is an intermediate language
+for describing shaders. Since Gallium is inherently shaderful, shaders are
+an important part of the API. TGSI is the only intermediate representation
+used by all drivers.
+
+Instruction Set
+---------------
+
+From GL_NV_vertex_program
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+
+ARL - Address Register Load
+
+.. math::
+
+  dst.x = \lfloor src.x\rfloor
+
+  dst.y = \lfloor src.y\rfloor
+
+  dst.z = \lfloor src.z\rfloor
+
+  dst.w = \lfloor src.w\rfloor
+
+
+MOV - Move
+
+.. math::
+
+  dst.x = src.x
+
+  dst.y = src.y
+
+  dst.z = src.z
+
+  dst.w = src.w
+
+
+LIT - Light Coefficients
+
+.. math::
+
+  dst.x = 1
+
+  dst.y = max(src.x, 0)
+
+  dst.z = (src.x > 0) ? max(src.y, 0)^{clamp(src.w, -128, 128))} : 0
+
+  dst.w = 1
+
+
+RCP - Reciprocal
+
+.. math::
+
+  dst.x = \frac{1}{src.x}
+
+  dst.y = \frac{1}{src.x}
+
+  dst.z = \frac{1}{src.x}
+
+  dst.w = \frac{1}{src.x}
+
+
+RSQ - Reciprocal Square Root
+
+.. math::
+
+  dst.x = \frac{1}{\sqrt{|src.x|}}
+
+  dst.y = \frac{1}{\sqrt{|src.x|}}
+
+  dst.z = \frac{1}{\sqrt{|src.x|}}
+
+  dst.w = \frac{1}{\sqrt{|src.x|}}
+
+
+EXP - Approximate Exponential Base 2
+
+.. math::
+
+  dst.x = 2^{\lfloor src.x\rfloor}
+
+  dst.y = src.x - \lfloor src.x\rfloor
+
+  dst.z = 2^{src.x}
+
+  dst.w = 1
+
+
+LOG - Approximate Logarithm Base 2
+
+.. math::
+
+  dst.x = \lfloor\log_2{|src.x|}\rfloor
+
+  dst.y = \frac{|src.x|}{2^{\lfloor\log_2{|src.x|}\rfloor}}
+
+  dst.z = \log_2{|src.x|}
+
+  dst.w = 1
+
+
+MUL - Multiply
+
+.. math::
+
+  dst.x = src0.x \times src1.x
+
+  dst.y = src0.y \times src1.y
+
+  dst.z = src0.z \times src1.z
+
+  dst.w = src0.w \times src1.w
+
+
+ADD - Add
+
+.. math::
+
+  dst.x = src0.x + src1.x
+
+  dst.y = src0.y + src1.y
+
+  dst.z = src0.z + src1.z
+
+  dst.w = src0.w + src1.w
+
+
+DP3 - 3-component Dot Product
+
+.. math::
+
+  dst.x = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
+
+  dst.y = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
+
+  dst.z = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
+
+  dst.w = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
+
+
+DP4 - 4-component Dot Product
+
+.. math::
+
+  dst.x = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src0.w \times src1.w
+
+  dst.y = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src0.w \times src1.w
+
+  dst.z = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src0.w \times src1.w
+
+  dst.w = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src0.w \times src1.w
+
+
+DST - Distance Vector
+
+.. math::
+
+  dst.x = 1
+
+  dst.y = src0.y \times src1.y
+
+  dst.z = src0.z
+
+  dst.w = src1.w
+
+
+MIN - Minimum
+
+.. math::
+
+  dst.x = min(src0.x, src1.x)
+
+  dst.y = min(src0.y, src1.y)
+
+  dst.z = min(src0.z, src1.z)
+
+  dst.w = min(src0.w, src1.w)
+
+
+MAX - Maximum
+
+.. math::
+
+  dst.x = max(src0.x, src1.x)
+
+  dst.y = max(src0.y, src1.y)
+
+  dst.z = max(src0.z, src1.z)
+
+  dst.w = max(src0.w, src1.w)
+
+
+SLT - Set On Less Than
+
+.. math::
+
+  dst.x = (src0.x < src1.x) ? 1 : 0
+
+  dst.y = (src0.y < src1.y) ? 1 : 0
+
+  dst.z = (src0.z < src1.z) ? 1 : 0
+
+  dst.w = (src0.w < src1.w) ? 1 : 0
+
+
+SGE - Set On Greater Equal Than
+
+.. math::
+
+  dst.x = (src0.x >= src1.x) ? 1 : 0
+
+  dst.y = (src0.y >= src1.y) ? 1 : 0
+
+  dst.z = (src0.z >= src1.z) ? 1 : 0
+
+  dst.w = (src0.w >= src1.w) ? 1 : 0
+
+
+MAD - Multiply And Add
+
+.. math::
+
+  dst.x = src0.x \times src1.x + src2.x
+
+  dst.y = src0.y \times src1.y + src2.y
+
+  dst.z = src0.z \times src1.z + src2.z
+
+  dst.w = src0.w \times src1.w + src2.w
+
+
+SUB - Subtract
+
+.. math::
+
+  dst.x = src0.x - src1.x
+
+  dst.y = src0.y - src1.y
+
+  dst.z = src0.z - src1.z
+
+  dst.w = src0.w - src1.w
+
+
+LRP - Linear Interpolate
+
+.. math::
+
+  dst.x = src0.x \times src1.x + (1 - src0.x) \times src2.x
+
+  dst.y = src0.y \times src1.y + (1 - src0.y) \times src2.y
+
+  dst.z = src0.z \times src1.z + (1 - src0.z) \times src2.z
+
+  dst.w = src0.w \times src1.w + (1 - src0.w) \times src2.w
+
+
+CND - Condition
+
+.. math::
+
+  dst.x = (src2.x > 0.5) ? src0.x : src1.x
+
+  dst.y = (src2.y > 0.5) ? src0.y : src1.y
+
+  dst.z = (src2.z > 0.5) ? src0.z : src1.z
+
+  dst.w = (src2.w > 0.5) ? src0.w : src1.w
+
+
+DP2A - 2-component Dot Product And Add
+
+.. math::
+
+  dst.x = src0.x \times src1.x + src0.y \times src1.y + src2.x
+
+  dst.y = src0.x \times src1.x + src0.y \times src1.y + src2.x
+
+  dst.z = src0.x \times src1.x + src0.y \times src1.y + src2.x
+
+  dst.w = src0.x \times src1.x + src0.y \times src1.y + src2.x
+
+
+FRAC - Fraction
+
+.. math::
+
+  dst.x = src.x - \lfloor src.x\rfloor
+
+  dst.y = src.y - \lfloor src.y\rfloor
+
+  dst.z = src.z - \lfloor src.z\rfloor
+
+  dst.w = src.w - \lfloor src.w\rfloor
+
+
+CLAMP - Clamp
+
+.. math::
+
+  dst.x = clamp(src0.x, src1.x, src2.x)
+
+  dst.y = clamp(src0.y, src1.y, src2.y)
+
+  dst.z = clamp(src0.z, src1.z, src2.z)
+
+  dst.w = clamp(src0.w, src1.w, src2.w)
+
+
+FLR - Floor
+
+This is identical to ARL.
+
+.. math::
+
+  dst.x = \lfloor src.x\rfloor
+
+  dst.y = \lfloor src.y\rfloor
+
+  dst.z = \lfloor src.z\rfloor
+
+  dst.w = \lfloor src.w\rfloor
+
+
+ROUND - Round
+
+.. math::
+
+  dst.x = round(src.x)
+
+  dst.y = round(src.y)
+
+  dst.z = round(src.z)
+
+  dst.w = round(src.w)
+
+
+EX2 - Exponential Base 2
+
+.. math::
+
+  dst.x = 2^{src.x}
+
+  dst.y = 2^{src.x}
+
+  dst.z = 2^{src.x}
+
+  dst.w = 2^{src.x}
+
+
+LG2 - Logarithm Base 2
+
+.. math::
+
+  dst.x = \log_2{src.x}
+
+  dst.y = \log_2{src.x}
+
+  dst.z = \log_2{src.x}
+
+  dst.w = \log_2{src.x}
+
+
+POW - Power
+
+.. math::
+
+  dst.x = src0.x^{src1.x}
+
+  dst.y = src0.x^{src1.x}
+
+  dst.z = src0.x^{src1.x}
+
+  dst.w = src0.x^{src1.x}
+
+XPD - Cross Product
+
+.. math::
+
+  dst.x = src0.y \times src1.z - src1.y \times src0.z
+
+  dst.y = src0.z \times src1.x - src1.z \times src0.x
+
+  dst.z = src0.x \times src1.y - src1.x \times src0.y
+
+  dst.w = 1
+
+
+ABS - Absolute
+
+.. math::
+
+  dst.x = |src.x|
+
+  dst.y = |src.y|
+
+  dst.z = |src.z|
+
+  dst.w = |src.w|
+
+
+RCC - Reciprocal Clamped
+
+XXX cleanup on aisle three
+
+.. math::
+
+  dst.x = (1 / src.x) > 0 ? clamp(1 / src.x, 5.42101e-020, 1.884467e+019) : clamp(1 / src.x, -1.884467e+019, -5.42101e-020)
+
+  dst.y = (1 / src.x) > 0 ? clamp(1 / src.x, 5.42101e-020, 1.884467e+019) : clamp(1 / src.x, -1.884467e+019, -5.42101e-020)
+
+  dst.z = (1 / src.x) > 0 ? clamp(1 / src.x, 5.42101e-020, 1.884467e+019) : clamp(1 / src.x, -1.884467e+019, -5.42101e-020)
+
+  dst.w = (1 / src.x) > 0 ? clamp(1 / src.x, 5.42101e-020, 1.884467e+019) : clamp(1 / src.x, -1.884467e+019, -5.42101e-020)
+
+
+DPH - Homogeneous Dot Product
+
+.. math::
+
+  dst.x = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src1.w
+
+  dst.y = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src1.w
+
+  dst.z = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src1.w
+
+  dst.w = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src1.w
+
+
+COS - Cosine
+
+.. math::
+
+  dst.x = \cos{src.x}
+
+  dst.y = \cos{src.x}
+
+  dst.z = \cos{src.x}
+
+  dst.w = \cos{src.x}
+
+
+DDX - Derivative Relative To X
+
+.. math::
+
+  dst.x = partialx(src.x)
+
+  dst.y = partialx(src.y)
+
+  dst.z = partialx(src.z)
+
+  dst.w = partialx(src.w)
+
+
+DDY - Derivative Relative To Y
+
+.. math::
+
+  dst.x = partialy(src.x)
+
+  dst.y = partialy(src.y)
+
+  dst.z = partialy(src.z)
+
+  dst.w = partialy(src.w)
+
+
+KILP - Predicated Discard
+
+  discard
+
+
+PK2H - Pack Two 16-bit Floats
+
+  TBD
+
+
+PK2US - Pack Two Unsigned 16-bit Scalars
+
+  TBD
+
+
+PK4B - Pack Four Signed 8-bit Scalars
+
+  TBD
+
+
+PK4UB - Pack Four Unsigned 8-bit Scalars
+
+  TBD
+
+
+RFL - Reflection Vector
+
+.. math::
+
+  dst.x = 2 \times (src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z) / (src0.x \times src0.x + src0.y \times src0.y + src0.z \times src0.z) \times src0.x - src1.x
+
+  dst.y = 2 \times (src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z) / (src0.x \times src0.x + src0.y \times src0.y + src0.z \times src0.z) \times src0.y - src1.y
+
+  dst.z = 2 \times (src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z) / (src0.x \times src0.x + src0.y \times src0.y + src0.z \times src0.z) \times src0.z - src1.z
+
+  dst.w = 1
+
+Considered for removal.
+
+
+SEQ - Set On Equal
+
+.. math::
+
+  dst.x = (src0.x == src1.x) ? 1 : 0
+  dst.y = (src0.y == src1.y) ? 1 : 0
+  dst.z = (src0.z == src1.z) ? 1 : 0
+  dst.w = (src0.w == src1.w) ? 1 : 0
+
+
+SFL - Set On False
+
+.. math::
+
+  dst.x = 0
+  dst.y = 0
+  dst.z = 0
+  dst.w = 0
+
+Considered for removal.
+
+SGT - Set On Greater Than
+
+.. math::
+
+  dst.x = (src0.x > src1.x) ? 1 : 0
+  dst.y = (src0.y > src1.y) ? 1 : 0
+  dst.z = (src0.z > src1.z) ? 1 : 0
+  dst.w = (src0.w > src1.w) ? 1 : 0
+
+
+SIN - Sine
+
+.. math::
+
+  dst.x = \sin{src.x}
+
+  dst.y = \sin{src.x}
+
+  dst.z = \sin{src.x}
+
+  dst.w = \sin{src.x}
+
+
+SLE - Set On Less Equal Than
+
+.. math::
+
+  dst.x = (src0.x <= src1.x) ? 1 : 0
+  dst.y = (src0.y <= src1.y) ? 1 : 0
+  dst.z = (src0.z <= src1.z) ? 1 : 0
+  dst.w = (src0.w <= src1.w) ? 1 : 0
+
+
+SNE - Set On Not Equal
+
+.. math::
+
+  dst.x = (src0.x != src1.x) ? 1 : 0
+  dst.y = (src0.y != src1.y) ? 1 : 0
+  dst.z = (src0.z != src1.z) ? 1 : 0
+  dst.w = (src0.w != src1.w) ? 1 : 0
+
+
+STR - Set On True
+
+.. math::
+
+  dst.x = 1
+  dst.y = 1
+  dst.z = 1
+  dst.w = 1
+
+
+TEX - Texture Lookup
+
+  TBD
+
+
+TXD - Texture Lookup with Derivatives
+
+  TBD
+
+
+TXP - Projective Texture Lookup
+
+  TBD
+
+
+UP2H - Unpack Two 16-Bit Floats
+
+  TBD
+
+  Considered for removal.
+
+UP2US - Unpack Two Unsigned 16-Bit Scalars
+
+  TBD
+
+  Considered for removal.
+
+UP4B - Unpack Four Signed 8-Bit Values
+
+  TBD
+
+  Considered for removal.
+
+UP4UB - Unpack Four Unsigned 8-Bit Scalars
+
+  TBD
+
+  Considered for removal.
+
+X2D - 2D Coordinate Transformation
+
+.. math::
+
+  dst.x = src0.x + src1.x \times src2.x + src1.y \times src2.y
+  dst.y = src0.y + src1.x \times src2.z + src1.y \times src2.w
+  dst.z = src0.x + src1.x \times src2.x + src1.y \times src2.y
+  dst.w = src0.y + src1.x \times src2.z + src1.y \times src2.w
+
+Considered for removal.
+
+
+From GL_NV_vertex_program2
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+
+ARA - Address Register Add
+
+  TBD
+
+  Considered for removal.
+
+ARR - Address Register Load With Round
+
+.. math::
+
+  dst.x = round(src.x)
+
+  dst.y = round(src.y)
+
+  dst.z = round(src.z)
+
+  dst.w = round(src.w)
+
+
+BRA - Branch
+
+  pc = target
+
+  Considered for removal.
+
+CAL - Subroutine Call
+
+  push(pc)
+  pc = target
+
+
+RET - Subroutine Call Return
+
+  pc = pop()
+
+  Potential restrictions:  
+  * Only occurs at end of function.
+
+SSG - Set Sign
+
+.. math::
+
+  dst.x = (src.x > 0) ? 1 : (src.x < 0) ? -1 : 0
+
+  dst.y = (src.y > 0) ? 1 : (src.y < 0) ? -1 : 0
+
+  dst.z = (src.z > 0) ? 1 : (src.z < 0) ? -1 : 0
+
+  dst.w = (src.w > 0) ? 1 : (src.w < 0) ? -1 : 0
+
+
+CMP - Compare
+
+.. math::
+
+  dst.x = (src0.x < 0) ? src1.x : src2.x
+
+  dst.y = (src0.y < 0) ? src1.y : src2.y
+
+  dst.z = (src0.z < 0) ? src1.z : src2.z
+
+  dst.w = (src0.w < 0) ? src1.w : src2.w
+
+
+KIL - Conditional Discard
+
+.. math::
+
+  if (src.x < 0 || src.y < 0 || src.z < 0 || src.w < 0)
+    discard
+  endif
+
+
+SCS - Sine Cosine
+
+.. math::
+
+  dst.x = \cos{src.x}
+
+  dst.y = \sin{src.x}
+
+  dst.z = 0
+
+  dst.y = 1
+
+
+TXB - Texture Lookup With Bias
+
+  TBD
+
+
+NRM - 3-component Vector Normalise
+
+.. math::
+
+  dst.x = src.x / (src.x \times src.x + src.y \times src.y + src.z \times src.z)
+
+  dst.y = src.y / (src.x \times src.x + src.y \times src.y + src.z \times src.z)
+
+  dst.z = src.z / (src.x \times src.x + src.y \times src.y + src.z \times src.z)
+
+  dst.w = 1
+
+
+DIV - Divide
+
+.. math::
+
+  dst.x = \frac{src0.x}{src1.x}
+
+  dst.y = \frac{src0.y}{src1.y}
+
+  dst.z = \frac{src0.z}{src1.z}
+
+  dst.w = \frac{src0.w}{src1.w}
+
+
+DP2 - 2-component Dot Product
+
+.. math::
+
+  dst.x = src0.x \times src1.x + src0.y \times src1.y
+
+  dst.y = src0.x \times src1.x + src0.y \times src1.y
+
+  dst.z = src0.x \times src1.x + src0.y \times src1.y
+
+  dst.w = src0.x \times src1.x + src0.y \times src1.y
+
+
+TXL - Texture Lookup With LOD
+
+  TBD
+
+
+BRK - Break
+
+  TBD
+
+
+IF - If
+
+  TBD
+
+
+BGNFOR - Begin a For-Loop
+
+  dst.x = floor(src.x)
+  dst.y = floor(src.y)
+  dst.z = floor(src.z)
+
+  if (dst.y <= 0)
+    pc = [matching ENDFOR] + 1
+  endif
+
+  Note: The destination must be a loop register.
+        The source must be a constant register.
+
+  Considered for cleanup / removal.
+
+
+REP - Repeat
+
+  TBD
+
+
+ELSE - Else
+
+  TBD
+
+
+ENDIF - End If
+
+  TBD
+
+
+ENDFOR - End a For-Loop
+
+  dst.x = dst.x + dst.z
+  dst.y = dst.y - 1.0
+
+  if (dst.y > 0)
+    pc = [matching BGNFOR instruction] + 1
+  endif
+
+  Note: The destination must be a loop register.
+
+  Considered for cleanup / removal.
+
+ENDREP - End Repeat
+
+  TBD
+
+
+PUSHA - Push Address Register On Stack
+
+  push(src.x)
+  push(src.y)
+  push(src.z)
+  push(src.w)
+
+  Considered for cleanup / removal.
+
+POPA - Pop Address Register From Stack
+
+  dst.w = pop()
+  dst.z = pop()
+  dst.y = pop()
+  dst.x = pop()
+
+  Considered for cleanup / removal.
+
+
+From GL_NV_gpu_program4
+^^^^^^^^^^^^^^^^^^^^^^^^
+
+Support for these opcodes indicated by a special pipe capability bit (TBD).
+
+CEIL - Ceiling
+
+.. math::
+
+  dst.x = \lceil src.x\rceil
+
+  dst.y = \lceil src.y\rceil
+
+  dst.z = \lceil src.z\rceil
+
+  dst.w = \lceil src.w\rceil
+
+
+I2F - Integer To Float
+
+.. math::
+
+  dst.x = (float) src.x
+
+  dst.y = (float) src.y
+
+  dst.z = (float) src.z
+
+  dst.w = (float) src.w
+
+
+NOT - Bitwise Not
+
+.. math::
+
+  dst.x = ~src.x
+
+  dst.y = ~src.y
+
+  dst.z = ~src.z
+
+  dst.w = ~src.w
+
+
+TRUNC - Truncate
+
+.. math::
+
+  dst.x = trunc(src.x)
+
+  dst.y = trunc(src.y)
+
+  dst.z = trunc(src.z)
+
+  dst.w = trunc(src.w)
+
+
+SHL - Shift Left
+
+.. math::
+
+  dst.x = src0.x << src1.x
+
+  dst.y = src0.y << src1.x
+
+  dst.z = src0.z << src1.x
+
+  dst.w = src0.w << src1.x
+
+
+SHR - Shift Right
+
+.. math::
+
+  dst.x = src0.x >> src1.x
+
+  dst.y = src0.y >> src1.x
+
+  dst.z = src0.z >> src1.x
+
+  dst.w = src0.w >> src1.x
+
+
+AND - Bitwise And
+
+.. math::
+
+  dst.x = src0.x & src1.x
+
+  dst.y = src0.y & src1.y
+
+  dst.z = src0.z & src1.z
+
+  dst.w = src0.w & src1.w
+
+
+OR - Bitwise Or
+
+.. math::
+
+  dst.x = src0.x | src1.x
+
+  dst.y = src0.y | src1.y
+
+  dst.z = src0.z | src1.z
+
+  dst.w = src0.w | src1.w
+
+
+MOD - Modulus
+
+.. math::
+
+  dst.x = src0.x \bmod src1.x
+
+  dst.y = src0.y \bmod src1.y
+
+  dst.z = src0.z \bmod src1.z
+
+  dst.w = src0.w \bmod src1.w
+
+
+XOR - Bitwise Xor
+
+.. math::
+
+  dst.x = src0.x ^ src1.x
+
+  dst.y = src0.y ^ src1.y
+
+  dst.z = src0.z ^ src1.z
+
+  dst.w = src0.w ^ src1.w
+
+
+SAD - Sum Of Absolute Differences
+
+.. math::
+
+  dst.x = |src0.x - src1.x| + src2.x
+
+  dst.y = |src0.y - src1.y| + src2.y
+
+  dst.z = |src0.z - src1.z| + src2.z
+
+  dst.w = |src0.w - src1.w| + src2.w
+
+
+TXF - Texel Fetch
+
+  TBD
+
+
+TXQ - Texture Size Query
+
+  TBD
+
+
+CONT - Continue
+
+  TBD
+
+
+From GL_NV_geometry_program4
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+
+EMIT - Emit
+
+  TBD
+
+
+ENDPRIM - End Primitive
+
+  TBD
+
+
+From GLSL
+^^^^^^^^^^
+
+
+BGNLOOP - Begin a Loop
+
+  TBD
+
+
+BGNSUB - Begin Subroutine
+
+  TBD
+
+
+ENDLOOP - End a Loop
+
+  TBD
+
+
+ENDSUB - End Subroutine
+
+  TBD
+
+
+NOP - No Operation
+
+  Do nothing.
+
+
+NRM4 - 4-component Vector Normalise
+
+.. math::
+
+  dst.x = \frac{src.x}{src.x \times src.x + src.y \times src.y + src.z \times src.z + src.w \times src.w}
+
+  dst.y = \frac{src.y}{src.x \times src.x + src.y \times src.y + src.z \times src.z + src.w \times src.w}
+
+  dst.z = \frac{src.z}{src.x \times src.x + src.y \times src.y + src.z \times src.z + src.w \times src.w}
+
+  dst.w = \frac{src.w}{src.x \times src.x + src.y \times src.y + src.z \times src.z + src.w \times src.w}
+
+
+ps_2_x
+^^^^^^^^^^^^
+
+
+CALLNZ - Subroutine Call If Not Zero
+
+  TBD
+
+
+IFC - If
+
+  TBD
+
+
+BREAKC - Break Conditional
+
+  TBD
+
+
+Explanation of symbols used
+------------------------------
+
+
+Functions
+^^^^^^^^^^^^^^
+
+
+  :math:`|x|`       Absolute value of `x`.
+
+  :math:`\lceil x \rceil` Ceiling of `x`.
+
+  clamp(x,y,z)      Clamp x between y and z.
+                    (x < y) ? y : (x > z) ? z : x
+
+  :math:`\lfloor x\rfloor` Floor of `x`.
+
+  :math:`\log_2{x}` Logarithm of `x`, base 2.
+
+  max(x,y)          Maximum of x and y.
+                    (x > y) ? x : y
+
+  min(x,y)          Minimum of x and y.
+                    (x < y) ? x : y
+
+  partialx(x)       Derivative of x relative to fragment's X.
+
+  partialy(x)       Derivative of x relative to fragment's Y.
+
+  pop()             Pop from stack.
+
+  :math:`x^y`       `x` to the power `y`.
+
+  push(x)           Push x on stack.
+
+  round(x)          Round x.
+
+  trunc(x)          Truncate x, i.e. drop the fraction bits.
+
+
+Keywords
+^^^^^^^^^^^^^
+
+
+  discard           Discard fragment.
+
+  dst               First destination register.
+
+  dst0              First destination register.
+
+  pc                Program counter.
+
+  src               First source register.
+
+  src0              First source register.
+
+  src1              Second source register.
+
+  src2              Third source register.
+
+  target            Label of target instruction.
+
+
+Other tokens
+---------------
+
+
+Declaration Semantic
+^^^^^^^^^^^^^^^^^^^^^^^^
+
+
+  Follows Declaration token if Semantic bit is set.
+
+  Since its purpose is to link a shader with other stages of the pipeline,
+  it is valid to follow only those Declaration tokens that declare a register
+  either in INPUT or OUTPUT file.
+
+  SemanticName field contains the semantic name of the register being declared.
+  There is no default value.
+
+  SemanticIndex is an optional subscript that can be used to distinguish
+  different register declarations with the same semantic name. The default value
+  is 0.
+
+  The meanings of the individual semantic names are explained in the following
+  sections.
+
+TGSI_SEMANTIC_POSITION
+""""""""""""""""""""""
+
+Position, sometimes known as HPOS or WPOS for historical reasons, is the
+location of the vertex in space, in ``(x, y, z, w)`` format. ``x``, ``y``, and ``z``
+are the Cartesian coordinates, and ``w`` is the homogenous coordinate and used
+for the perspective divide, if enabled.
+
+As a vertex shader output, position should be scaled to the viewport. When
+used in fragment shaders, position will ---
+
+XXX --- wait a minute. Should position be in [0,1] for x and y?
+
+XXX additionally, is there a way to configure the perspective divide? it's
+accelerated on most chipsets AFAIK...
+
+Position, if not specified, usually defaults to ``(0, 0, 0, 1)``, and can
+be partially specified as ``(x, y, 0, 1)`` or ``(x, y, z, 1)``.
+
+XXX usually? can we solidify that?
+
+TGSI_SEMANTIC_COLOR
+"""""""""""""""""""
+
+Colors are used to, well, color the primitives. Colors are always in
+``(r, g, b, a)`` format.
+
+If alpha is not specified, it defaults to 1.
+
+TGSI_SEMANTIC_BCOLOR
+""""""""""""""""""""
+
+Back-facing colors are only used for back-facing polygons, and are only valid
+in vertex shader outputs. After rasterization, all polygons are front-facing
+and COLOR and BCOLOR end up occupying the same slots in the fragment, so
+all BCOLORs effectively become regular COLORs in the fragment shader.
+
+TGSI_SEMANTIC_FOG
+"""""""""""""""""
+
+The fog coordinate historically has been used to replace the depth coordinate
+for generation of fog in dedicated fog blocks. Gallium, however, does not use
+dedicated fog acceleration, placing it entirely in the fragment shader
+instead.
+
+The fog coordinate should be written in ``(f, 0, 0, 1)`` format. Only the first
+component matters when writing from the vertex shader; the driver will ensure
+that the coordinate is in this format when used as a fragment shader input.
+
+TGSI_SEMANTIC_PSIZE
+"""""""""""""""""""
+
+PSIZE, or point size, is used to specify point sizes per-vertex. It should
+be in ``(p, n, x, f)`` format, where ``p`` is the point size, ``n`` is the minimum
+size, ``x`` is the maximum size, and ``f`` is the fade threshold.
+
+XXX this is arb_vp. is this what we actually do? should double-check...
+
+When using this semantic, be sure to set the appropriate state in the
+:ref:`rasterizer` first.
+
+TGSI_SEMANTIC_GENERIC
+"""""""""""""""""""""
+
+Generic semantics are nearly always used for texture coordinate attributes,
+in ``(s, t, r, q)`` format. ``t`` and ``r`` may be unused for certain kinds
+of lookups, and ``q`` is the level-of-detail bias for biased sampling.
+
+These attributes are called "generic" because they may be used for anything
+else, including parameters, texture generation information, or anything that
+can be stored inside a four-component vector.
+
+TGSI_SEMANTIC_NORMAL
+""""""""""""""""""""
+
+Vertex normal; could be used to implement per-pixel lighting for legacy APIs
+that allow mixing fixed-function and programmable stages.
+
+TGSI_SEMANTIC_FACE
+""""""""""""""""""
+
+FACE is the facing bit, to store the facing information for the fragment
+shader. ``(f, 0, 0, 1)`` is the format. The first component will be positive
+when the fragment is front-facing, and negative when the component is
+back-facing.
+
+TGSI_SEMANTIC_EDGEFLAG
+""""""""""""""""""""""
+
+XXX no clue
index 79ad687ea94d03381e4dc1e529d344c38477ea36..3a3f968a492f8530854c4502d9258c7d55a4160a 100644 (file)
@@ -59,9 +59,9 @@ cell_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba,
 
    if (buffers & PIPE_CLEAR_COLOR) {
       uint surfIndex = 0;
-      uint clearValue;
+      union util_color uc;
 
-      util_pack_color(rgba, cell->framebuffer.cbufs[0]->format, &clearValue);
+      util_pack_color(rgba, cell->framebuffer.cbufs[0]->format, &uc);
 
       /* Build a CLEAR command and place it in the current batch buffer */
       STATIC_ASSERT(sizeof(struct cell_command_clear_surface) % 16 == 0);
@@ -70,7 +70,7 @@ cell_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba,
          cell_batch_alloc16(cell, sizeof(*clr));
       clr->opcode[0] = CELL_CMD_CLEAR_SURFACE;
       clr->surface = surfIndex;
-      clr->value = clearValue;
+      clr->value = uc.ui;
    }
 
    if (buffers & PIPE_CLEAR_DEPTHSTENCIL) {
index 644496db40cd8bc6a94682e051e4cf7a9e850f67..3fa8b975d3932b0f9a9e227dfac1ad7936ab1439 100644 (file)
@@ -59,7 +59,7 @@ cell_map_constant_buffers(struct cell_context *sp)
       }
    }
 
-   draw_set_mapped_constant_buffer(sp->draw,
+   draw_set_mapped_constant_buffer(sp->draw, PIPE_SHADER_VERTEX,
                                    sp->mapped_constants[PIPE_SHADER_VERTEX],
                                    sp->constants[PIPE_SHADER_VERTEX].buffer->size);
 }
@@ -85,7 +85,7 @@ cell_unmap_constant_buffers(struct cell_context *sp)
  *
  * XXX should the element buffer be specified/bound with a separate function?
  */
-static boolean
+static void
 cell_draw_range_elements(struct pipe_context *pipe,
                          struct pipe_buffer *indexBuffer,
                          unsigned indexSize,
@@ -145,47 +145,35 @@ cell_draw_range_elements(struct pipe_context *pipe,
 
    /* Note: leave drawing surfaces mapped */
    cell_unmap_constant_buffers(sp);
-
-   return TRUE;
 }
 
 
-static boolean
+static void
 cell_draw_elements(struct pipe_context *pipe,
                    struct pipe_buffer *indexBuffer,
                    unsigned indexSize,
                    unsigned mode, unsigned start, unsigned count)
 {
-   return cell_draw_range_elements( pipe, indexBuffer,
-                                    indexSize,
-                                    0, 0xffffffff,
-                                    mode, start, count );
+   cell_draw_range_elements( pipe, indexBuffer,
+                             indexSize,
+                             0, 0xffffffff,
+                             mode, start, count );
 }
 
 
-static boolean
+static void
 cell_draw_arrays(struct pipe_context *pipe, unsigned mode,
                      unsigned start, unsigned count)
 {
-   return cell_draw_elements(pipe, NULL, 0, mode, start, count);
-}
-
-
-static void
-cell_set_edgeflags(struct pipe_context *pipe, const unsigned *edgeflags)
-{
-   struct cell_context *cell = cell_context(pipe);
-   draw_set_edgeflags(cell->draw, edgeflags);
+   cell_draw_elements(pipe, NULL, 0, mode, start, count);
 }
 
 
-
 void
 cell_init_draw_functions(struct cell_context *cell)
 {
    cell->pipe.draw_arrays = cell_draw_arrays;
    cell->pipe.draw_elements = cell_draw_elements;
    cell->pipe.draw_range_elements = cell_draw_range_elements;
-   cell->pipe.set_edgeflags = cell_set_edgeflags;
 }
 
index 312621fd5340fa41d7a41113bc62c5842e751068..1d8a11a4ac97175a2627cd66dff1f38691e75857 100644 (file)
@@ -231,14 +231,14 @@ static boolean
 is_register_src(struct codegen *gen, int channel,
                 const struct tgsi_full_src_register *src)
 {
-   int swizzle = tgsi_util_get_full_src_register_extswizzle(src, channel);
+   int swizzle = tgsi_util_get_full_src_register_swizzle(src, channel);
    int sign_op = tgsi_util_get_full_src_register_sign_mode(src, channel);
 
    if (swizzle > TGSI_SWIZZLE_W || sign_op != TGSI_UTIL_SIGN_KEEP) {
       return FALSE;
    }
-   if (src->SrcRegister.File == TGSI_FILE_TEMPORARY ||
-       src->SrcRegister.File == TGSI_FILE_IMMEDIATE) {
+   if (src->Register.File == TGSI_FILE_TEMPORARY ||
+       src->Register.File == TGSI_FILE_IMMEDIATE) {
       return TRUE;
    }
    return FALSE;
@@ -249,7 +249,7 @@ static boolean
 is_memory_dst(struct codegen *gen, int channel,
               const struct tgsi_full_dst_register *dst)
 {
-   if (dst->DstRegister.File == TGSI_FILE_OUTPUT) {
+   if (dst->Register.File == TGSI_FILE_OUTPUT) {
       return TRUE;
    }
    else {
@@ -271,32 +271,23 @@ get_src_reg(struct codegen *gen,
             const struct tgsi_full_src_register *src)
 {
    int reg = -1;
-   int swizzle = tgsi_util_get_full_src_register_extswizzle(src, channel);
+   int swizzle = tgsi_util_get_full_src_register_swizzle(src, channel);
    boolean reg_is_itemp = FALSE;
    uint sign_op;
 
    assert(swizzle >= TGSI_SWIZZLE_X);
-   assert(swizzle <= TGSI_EXTSWIZZLE_ONE);
+   assert(swizzle <= TGSI_SWIZZLE_W);
 
-   if (swizzle == TGSI_EXTSWIZZLE_ONE) {
-      /* Load const one float and early out */
-      reg = get_const_one_reg(gen);
-   }
-   else if (swizzle == TGSI_EXTSWIZZLE_ZERO) {
-      /* Load const zero float and early out */
-      reg = get_itemp(gen);
-      spe_xor(gen->f, reg, reg, reg);
-   }
-   else {
-      int index = src->SrcRegister.Index;
+   {
+      int index = src->Register.Index;
 
       assert(swizzle < 4);
 
-      if (src->SrcRegister.Indirect) {
+      if (src->Register.Indirect) {
          /* XXX unfinished */
       }
 
-      switch (src->SrcRegister.File) {
+      switch (src->Register.File) {
       case TGSI_FILE_TEMPORARY:
          reg = gen->temp_regs[index][swizzle];
          break;
@@ -383,12 +374,12 @@ get_dst_reg(struct codegen *gen,
 {
    int reg = -1;
 
-   switch (dest->DstRegister.File) {
+   switch (dest->Register.File) {
    case TGSI_FILE_TEMPORARY:
       if (gen->if_nesting > 0 || gen->loop_nesting > 0)
          reg = get_itemp(gen);
       else
-         reg = gen->temp_regs[dest->DstRegister.Index][channel];
+         reg = gen->temp_regs[dest->Register.Index][channel];
       break;
    case TGSI_FILE_OUTPUT:
       reg = get_itemp(gen);
@@ -428,10 +419,10 @@ store_dest_reg(struct codegen *gen,
    }
 #endif
 
-   switch (dest->DstRegister.File) {
+   switch (dest->Register.File) {
    case TGSI_FILE_TEMPORARY:
       if (gen->if_nesting > 0 || gen->loop_nesting > 0) {
-         int d_reg = gen->temp_regs[dest->DstRegister.Index][channel];
+         int d_reg = gen->temp_regs[dest->Register.Index][channel];
          int exec_reg = get_exec_mask_reg(gen);
          /* Mix d with new value according to exec mask:
           * d[i] = mask_reg[i] ? value_reg : d_reg
@@ -446,7 +437,7 @@ store_dest_reg(struct codegen *gen,
    case TGSI_FILE_OUTPUT:
       {
          /* offset is measured in quadwords, not bytes */
-         int offset = dest->DstRegister.Index * 4 + channel;
+         int offset = dest->Register.Index * 4 + channel;
          if (gen->if_nesting > 0 || gen->loop_nesting > 0) {
             int exec_reg = get_exec_mask_reg(gen);
             int curval_reg = get_itemp(gen);
@@ -553,7 +544,7 @@ emit_epilogue(struct codegen *gen)
 
 #define FOR_EACH_ENABLED_CHANNEL(inst, ch) \
    for (ch = 0; ch < 4; ch++) \
-      if (inst->FullDstRegisters[0].DstRegister.WriteMask & (1 << ch))
+      if (inst->Dst[0].Register.WriteMask & (1 << ch))
 
 
 static boolean
@@ -561,7 +552,7 @@ emit_ARL(struct codegen *gen, const struct tgsi_full_instruction *inst)
 {
    int ch = 0, src_reg, addr_reg;
 
-   src_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
+   src_reg = get_src_reg(gen, ch, &inst->Src[0]);
    addr_reg = get_address_reg(gen);
 
    /* convert float to int */
@@ -579,19 +570,19 @@ emit_MOV(struct codegen *gen, const struct tgsi_full_instruction *inst)
    int ch, src_reg[4], dst_reg[4];
 
    FOR_EACH_ENABLED_CHANNEL(inst, ch) {
-      src_reg[ch] = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
-      dst_reg[ch] = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+      src_reg[ch] = get_src_reg(gen, ch, &inst->Src[0]);
+      dst_reg[ch] = get_dst_reg(gen, ch, &inst->Dst[0]);
    }
 
    FOR_EACH_ENABLED_CHANNEL(inst, ch) {
-      if (is_register_src(gen, ch, &inst->FullSrcRegisters[0]) &&
-          is_memory_dst(gen, ch, &inst->FullDstRegisters[0])) {
+      if (is_register_src(gen, ch, &inst->Src[0]) &&
+          is_memory_dst(gen, ch, &inst->Dst[0])) {
          /* special-case: register to memory store */
-         store_dest_reg(gen, src_reg[ch], ch, &inst->FullDstRegisters[0]);
+         store_dest_reg(gen, src_reg[ch], ch, &inst->Dst[0]);
       }
       else {
          spe_move(gen->f, dst_reg[ch], src_reg[ch]);
-         store_dest_reg(gen, dst_reg[ch], ch, &inst->FullDstRegisters[0]);
+         store_dest_reg(gen, dst_reg[ch], ch, &inst->Dst[0]);
       }
    }
 
@@ -610,9 +601,9 @@ emit_binop(struct codegen *gen, const struct tgsi_full_instruction *inst)
 
    /* Loop over Red/Green/Blue/Alpha channels, fetch src operands */
    FOR_EACH_ENABLED_CHANNEL(inst, ch) {
-      s1_reg[ch] = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
-      s2_reg[ch] = get_src_reg(gen, ch, &inst->FullSrcRegisters[1]);
-      d_reg[ch] = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+      s1_reg[ch] = get_src_reg(gen, ch, &inst->Src[0]);
+      s2_reg[ch] = get_src_reg(gen, ch, &inst->Src[1]);
+      d_reg[ch] = get_dst_reg(gen, ch, &inst->Dst[0]);
    }
 
    /* Loop over Red/Green/Blue/Alpha channels, do the op, store results */
@@ -635,7 +626,7 @@ emit_binop(struct codegen *gen, const struct tgsi_full_instruction *inst)
 
    /* Store the result (a no-op for TGSI_FILE_TEMPORARY dests) */
    FOR_EACH_ENABLED_CHANNEL(inst, ch) {
-      store_dest_reg(gen, d_reg[ch], ch, &inst->FullDstRegisters[0]);
+      store_dest_reg(gen, d_reg[ch], ch, &inst->Dst[0]);
    }
 
    /* Free any intermediate temps we allocated */
@@ -654,16 +645,16 @@ emit_MAD(struct codegen *gen, const struct tgsi_full_instruction *inst)
    int ch, s1_reg[4], s2_reg[4], s3_reg[4], d_reg[4];
 
    FOR_EACH_ENABLED_CHANNEL(inst, ch) {
-      s1_reg[ch] = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
-      s2_reg[ch] = get_src_reg(gen, ch, &inst->FullSrcRegisters[1]);
-      s3_reg[ch] = get_src_reg(gen, ch, &inst->FullSrcRegisters[2]);
-      d_reg[ch] = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+      s1_reg[ch] = get_src_reg(gen, ch, &inst->Src[0]);
+      s2_reg[ch] = get_src_reg(gen, ch, &inst->Src[1]);
+      s3_reg[ch] = get_src_reg(gen, ch, &inst->Src[2]);
+      d_reg[ch] = get_dst_reg(gen, ch, &inst->Dst[0]);
    }
    FOR_EACH_ENABLED_CHANNEL(inst, ch) {
       spe_fma(gen->f, d_reg[ch], s1_reg[ch], s2_reg[ch], s3_reg[ch]);
    }
    FOR_EACH_ENABLED_CHANNEL(inst, ch) {
-      store_dest_reg(gen, d_reg[ch], ch, &inst->FullDstRegisters[0]);
+      store_dest_reg(gen, d_reg[ch], ch, &inst->Dst[0]);
    }
    free_itemps(gen);
    return TRUE;
@@ -674,16 +665,16 @@ emit_MAD(struct codegen *gen, const struct tgsi_full_instruction *inst)
  * Emit linear interpolate.  See emit_ADD for comments.
  */
 static boolean
-emit_LERP(struct codegen *gen, const struct tgsi_full_instruction *inst)
+emit_LRP(struct codegen *gen, const struct tgsi_full_instruction *inst)
 {
    int ch, s1_reg[4], s2_reg[4], s3_reg[4], d_reg[4], tmp_reg[4];
 
    /* setup/get src/dst/temp regs */
    FOR_EACH_ENABLED_CHANNEL(inst, ch) {
-      s1_reg[ch] = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
-      s2_reg[ch] = get_src_reg(gen, ch, &inst->FullSrcRegisters[1]);
-      s3_reg[ch] = get_src_reg(gen, ch, &inst->FullSrcRegisters[2]);
-      d_reg[ch] = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+      s1_reg[ch] = get_src_reg(gen, ch, &inst->Src[0]);
+      s2_reg[ch] = get_src_reg(gen, ch, &inst->Src[1]);
+      s3_reg[ch] = get_src_reg(gen, ch, &inst->Src[2]);
+      d_reg[ch] = get_dst_reg(gen, ch, &inst->Dst[0]);
       tmp_reg[ch] = get_itemp(gen);
    }
 
@@ -696,7 +687,7 @@ emit_LERP(struct codegen *gen, const struct tgsi_full_instruction *inst)
       spe_fma(gen->f, d_reg[ch], tmp_reg[ch], s1_reg[ch], s3_reg[ch]);
    }
    FOR_EACH_ENABLED_CHANNEL(inst, ch) {
-      store_dest_reg(gen, d_reg[ch], ch, &inst->FullDstRegisters[0]);
+      store_dest_reg(gen, d_reg[ch], ch, &inst->Dst[0]);
    }
    free_itemps(gen);
    return TRUE;
@@ -713,8 +704,8 @@ emit_RCP_RSQ(struct codegen *gen, const struct tgsi_full_instruction *inst)
    int ch, s1_reg[4], d_reg[4], tmp_reg[4];
 
    FOR_EACH_ENABLED_CHANNEL(inst, ch) {
-      s1_reg[ch] = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
-      d_reg[ch] = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+      s1_reg[ch] = get_src_reg(gen, ch, &inst->Src[0]);
+      d_reg[ch] = get_dst_reg(gen, ch, &inst->Dst[0]);
       tmp_reg[ch] = get_itemp(gen);
    }
 
@@ -735,7 +726,7 @@ emit_RCP_RSQ(struct codegen *gen, const struct tgsi_full_instruction *inst)
    }
 
    FOR_EACH_ENABLED_CHANNEL(inst, ch) {
-      store_dest_reg(gen, d_reg[ch], ch, &inst->FullDstRegisters[0]);
+      store_dest_reg(gen, d_reg[ch], ch, &inst->Dst[0]);
    }
 
    free_itemps(gen);
@@ -756,8 +747,8 @@ emit_ABS(struct codegen *gen, const struct tgsi_full_instruction *inst)
    spe_load_uint(gen->f, bit31mask_reg, (1 << 31));
 
    FOR_EACH_ENABLED_CHANNEL(inst, ch) {
-      s1_reg[ch] = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
-      d_reg[ch] = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+      s1_reg[ch] = get_src_reg(gen, ch, &inst->Src[0]);
+      d_reg[ch] = get_dst_reg(gen, ch, &inst->Dst[0]);
    }
 
    /* d = sign bit cleared in s1 */
@@ -766,7 +757,7 @@ emit_ABS(struct codegen *gen, const struct tgsi_full_instruction *inst)
    }
 
    FOR_EACH_ENABLED_CHANNEL(inst, ch) {
-      store_dest_reg(gen, d_reg[ch], ch, &inst->FullDstRegisters[0]);
+      store_dest_reg(gen, d_reg[ch], ch, &inst->Dst[0]);
    }
 
    free_itemps(gen);
@@ -784,12 +775,12 @@ emit_DP3(struct codegen *gen, const struct tgsi_full_instruction *inst)
    int s2x_reg, s2y_reg, s2z_reg;
    int t0_reg = get_itemp(gen), t1_reg = get_itemp(gen);
 
-   s1x_reg = get_src_reg(gen, CHAN_X, &inst->FullSrcRegisters[0]);
-   s2x_reg = get_src_reg(gen, CHAN_X, &inst->FullSrcRegisters[1]);
-   s1y_reg = get_src_reg(gen, CHAN_Y, &inst->FullSrcRegisters[0]);
-   s2y_reg = get_src_reg(gen, CHAN_Y, &inst->FullSrcRegisters[1]);
-   s1z_reg = get_src_reg(gen, CHAN_Z, &inst->FullSrcRegisters[0]);
-   s2z_reg = get_src_reg(gen, CHAN_Z, &inst->FullSrcRegisters[1]);
+   s1x_reg = get_src_reg(gen, CHAN_X, &inst->Src[0]);
+   s2x_reg = get_src_reg(gen, CHAN_X, &inst->Src[1]);
+   s1y_reg = get_src_reg(gen, CHAN_Y, &inst->Src[0]);
+   s2y_reg = get_src_reg(gen, CHAN_Y, &inst->Src[1]);
+   s1z_reg = get_src_reg(gen, CHAN_Z, &inst->Src[0]);
+   s2z_reg = get_src_reg(gen, CHAN_Z, &inst->Src[1]);
 
    /* t0 = x0 * x1 */
    spe_fm(gen->f, t0_reg, s1x_reg, s2x_reg);
@@ -804,9 +795,9 @@ emit_DP3(struct codegen *gen, const struct tgsi_full_instruction *inst)
    spe_fa(gen->f, t0_reg, t0_reg, t1_reg);
 
    FOR_EACH_ENABLED_CHANNEL(inst, ch) {
-      int d_reg = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+      int d_reg = get_dst_reg(gen, ch, &inst->Dst[0]);
       spe_move(gen->f, d_reg, t0_reg);
-      store_dest_reg(gen, d_reg, ch, &inst->FullDstRegisters[0]);
+      store_dest_reg(gen, d_reg, ch, &inst->Dst[0]);
    }
 
    free_itemps(gen);
@@ -824,14 +815,14 @@ emit_DP4(struct codegen *gen, const struct tgsi_full_instruction *inst)
    int s1x_reg, s1y_reg, s1z_reg, s1w_reg;
    int t0_reg = get_itemp(gen), t1_reg = get_itemp(gen);
 
-   s0x_reg = get_src_reg(gen, CHAN_X, &inst->FullSrcRegisters[0]);
-   s1x_reg = get_src_reg(gen, CHAN_X, &inst->FullSrcRegisters[1]);
-   s0y_reg = get_src_reg(gen, CHAN_Y, &inst->FullSrcRegisters[0]);
-   s1y_reg = get_src_reg(gen, CHAN_Y, &inst->FullSrcRegisters[1]);
-   s0z_reg = get_src_reg(gen, CHAN_Z, &inst->FullSrcRegisters[0]);
-   s1z_reg = get_src_reg(gen, CHAN_Z, &inst->FullSrcRegisters[1]);
-   s0w_reg = get_src_reg(gen, CHAN_W, &inst->FullSrcRegisters[0]);
-   s1w_reg = get_src_reg(gen, CHAN_W, &inst->FullSrcRegisters[1]);
+   s0x_reg = get_src_reg(gen, CHAN_X, &inst->Src[0]);
+   s1x_reg = get_src_reg(gen, CHAN_X, &inst->Src[1]);
+   s0y_reg = get_src_reg(gen, CHAN_Y, &inst->Src[0]);
+   s1y_reg = get_src_reg(gen, CHAN_Y, &inst->Src[1]);
+   s0z_reg = get_src_reg(gen, CHAN_Z, &inst->Src[0]);
+   s1z_reg = get_src_reg(gen, CHAN_Z, &inst->Src[1]);
+   s0w_reg = get_src_reg(gen, CHAN_W, &inst->Src[0]);
+   s1w_reg = get_src_reg(gen, CHAN_W, &inst->Src[1]);
 
    /* t0 = x0 * x1 */
    spe_fm(gen->f, t0_reg, s0x_reg, s1x_reg);
@@ -849,9 +840,9 @@ emit_DP4(struct codegen *gen, const struct tgsi_full_instruction *inst)
    spe_fa(gen->f, t0_reg, t0_reg, t1_reg);
 
    FOR_EACH_ENABLED_CHANNEL(inst, ch) {
-      int d_reg = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+      int d_reg = get_dst_reg(gen, ch, &inst->Dst[0]);
       spe_move(gen->f, d_reg, t0_reg);
-      store_dest_reg(gen, d_reg, ch, &inst->FullDstRegisters[0]);
+      store_dest_reg(gen, d_reg, ch, &inst->Dst[0]);
    }
 
    free_itemps(gen);
@@ -866,31 +857,31 @@ emit_DPH(struct codegen *gen, const struct tgsi_full_instruction *inst)
 {
    /* XXX rewrite this function to look more like DP3/DP4 */
    int ch;
-   int s1_reg = get_src_reg(gen, CHAN_X, &inst->FullSrcRegisters[0]);
-   int s2_reg = get_src_reg(gen, CHAN_X, &inst->FullSrcRegisters[1]);
+   int s1_reg = get_src_reg(gen, CHAN_X, &inst->Src[0]);
+   int s2_reg = get_src_reg(gen, CHAN_X, &inst->Src[1]);
    int tmp_reg = get_itemp(gen);
 
    /* t = x0 * x1 */
    spe_fm(gen->f, tmp_reg, s1_reg, s2_reg);
 
-   s1_reg = get_src_reg(gen, CHAN_Y, &inst->FullSrcRegisters[0]);
-   s2_reg = get_src_reg(gen, CHAN_Y, &inst->FullSrcRegisters[1]);
+   s1_reg = get_src_reg(gen, CHAN_Y, &inst->Src[0]);
+   s2_reg = get_src_reg(gen, CHAN_Y, &inst->Src[1]);
    /* t = y0 * y1 + t */
    spe_fma(gen->f, tmp_reg, s1_reg, s2_reg, tmp_reg);
 
-   s1_reg = get_src_reg(gen, CHAN_Z, &inst->FullSrcRegisters[0]);
-   s2_reg = get_src_reg(gen, CHAN_Z, &inst->FullSrcRegisters[1]);
+   s1_reg = get_src_reg(gen, CHAN_Z, &inst->Src[0]);
+   s2_reg = get_src_reg(gen, CHAN_Z, &inst->Src[1]);
    /* t = z0 * z1 + t */
    spe_fma(gen->f, tmp_reg, s1_reg, s2_reg, tmp_reg);
 
-   s2_reg = get_src_reg(gen, CHAN_W, &inst->FullSrcRegisters[1]);
+   s2_reg = get_src_reg(gen, CHAN_W, &inst->Src[1]);
    /* t = w1 + t */
    spe_fa(gen->f, tmp_reg, s2_reg, tmp_reg);
 
    FOR_EACH_ENABLED_CHANNEL(inst, ch) {
-      int d_reg = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+      int d_reg = get_dst_reg(gen, ch, &inst->Dst[0]);
       spe_move(gen->f, d_reg, tmp_reg);
-      store_dest_reg(gen, tmp_reg, ch, &inst->FullDstRegisters[0]);
+      store_dest_reg(gen, tmp_reg, ch, &inst->Dst[0]);
    }
 
    free_itemps(gen);
@@ -907,9 +898,9 @@ emit_NRM3(struct codegen *gen, const struct tgsi_full_instruction *inst)
    int src_reg[3];
    int t0_reg = get_itemp(gen), t1_reg = get_itemp(gen);
 
-   src_reg[0] = get_src_reg(gen, CHAN_X, &inst->FullSrcRegisters[0]);
-   src_reg[1] = get_src_reg(gen, CHAN_Y, &inst->FullSrcRegisters[0]);
-   src_reg[2] = get_src_reg(gen, CHAN_Z, &inst->FullSrcRegisters[0]);
+   src_reg[0] = get_src_reg(gen, CHAN_X, &inst->Src[0]);
+   src_reg[1] = get_src_reg(gen, CHAN_Y, &inst->Src[0]);
+   src_reg[2] = get_src_reg(gen, CHAN_Z, &inst->Src[0]);
 
    /* t0 = x * x */
    spe_fm(gen->f, t0_reg, src_reg[0], src_reg[0]);
@@ -928,10 +919,10 @@ emit_NRM3(struct codegen *gen, const struct tgsi_full_instruction *inst)
    spe_fi(gen->f, t1_reg, t0_reg, t1_reg);
 
    FOR_EACH_ENABLED_CHANNEL(inst, ch) {
-      int d_reg = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+      int d_reg = get_dst_reg(gen, ch, &inst->Dst[0]);
       /* dst = src[ch] * t1 */
       spe_fm(gen->f, d_reg, src_reg[ch], t1_reg);
-      store_dest_reg(gen, d_reg, ch, &inst->FullDstRegisters[0]);
+      store_dest_reg(gen, d_reg, ch, &inst->Dst[0]);
    }
 
    free_itemps(gen);
@@ -945,48 +936,48 @@ emit_NRM3(struct codegen *gen, const struct tgsi_full_instruction *inst)
 static boolean
 emit_XPD(struct codegen *gen, const struct tgsi_full_instruction *inst)
 {
-   int s1_reg = get_src_reg(gen, CHAN_Z, &inst->FullSrcRegisters[0]);
-   int s2_reg = get_src_reg(gen, CHAN_Y, &inst->FullSrcRegisters[1]);
+   int s1_reg = get_src_reg(gen, CHAN_Z, &inst->Src[0]);
+   int s2_reg = get_src_reg(gen, CHAN_Y, &inst->Src[1]);
    int tmp_reg = get_itemp(gen);
 
    /* t = z0 * y1 */
    spe_fm(gen->f, tmp_reg, s1_reg, s2_reg);
 
-   s1_reg = get_src_reg(gen, CHAN_Y, &inst->FullSrcRegisters[0]);
-   s2_reg = get_src_reg(gen, CHAN_Z, &inst->FullSrcRegisters[1]);
+   s1_reg = get_src_reg(gen, CHAN_Y, &inst->Src[0]);
+   s2_reg = get_src_reg(gen, CHAN_Z, &inst->Src[1]);
    /* t = y0 * z1 - t */
    spe_fms(gen->f, tmp_reg, s1_reg, s2_reg, tmp_reg);
 
-   if (inst->FullDstRegisters[0].DstRegister.WriteMask & (1 << CHAN_X)) {
-      store_dest_reg(gen, tmp_reg, CHAN_X, &inst->FullDstRegisters[0]);
+   if (inst->Dst[0].Register.WriteMask & (1 << CHAN_X)) {
+      store_dest_reg(gen, tmp_reg, CHAN_X, &inst->Dst[0]);
    }
 
-   s1_reg = get_src_reg(gen, CHAN_X, &inst->FullSrcRegisters[0]);
-   s2_reg = get_src_reg(gen, CHAN_Z, &inst->FullSrcRegisters[1]);
+   s1_reg = get_src_reg(gen, CHAN_X, &inst->Src[0]);
+   s2_reg = get_src_reg(gen, CHAN_Z, &inst->Src[1]);
    /* t = x0 * z1 */
    spe_fm(gen->f, tmp_reg, s1_reg, s2_reg);
 
-   s1_reg = get_src_reg(gen, CHAN_Z, &inst->FullSrcRegisters[0]);
-   s2_reg = get_src_reg(gen, CHAN_X, &inst->FullSrcRegisters[1]);
+   s1_reg = get_src_reg(gen, CHAN_Z, &inst->Src[0]);
+   s2_reg = get_src_reg(gen, CHAN_X, &inst->Src[1]);
    /* t = z0 * x1 - t */
    spe_fms(gen->f, tmp_reg, s1_reg, s2_reg, tmp_reg);
 
-   if (inst->FullDstRegisters[0].DstRegister.WriteMask & (1 << CHAN_Y)) {
-      store_dest_reg(gen, tmp_reg, CHAN_Y, &inst->FullDstRegisters[0]);
+   if (inst->Dst[0].Register.WriteMask & (1 << CHAN_Y)) {
+      store_dest_reg(gen, tmp_reg, CHAN_Y, &inst->Dst[0]);
    }
 
-   s1_reg = get_src_reg(gen, CHAN_Y, &inst->FullSrcRegisters[0]);
-   s2_reg = get_src_reg(gen, CHAN_X, &inst->FullSrcRegisters[1]);
+   s1_reg = get_src_reg(gen, CHAN_Y, &inst->Src[0]);
+   s2_reg = get_src_reg(gen, CHAN_X, &inst->Src[1]);
    /* t = y0 * x1 */
    spe_fm(gen->f, tmp_reg, s1_reg, s2_reg);
 
-   s1_reg = get_src_reg(gen, CHAN_X, &inst->FullSrcRegisters[0]);
-   s2_reg = get_src_reg(gen, CHAN_Y, &inst->FullSrcRegisters[1]);
+   s1_reg = get_src_reg(gen, CHAN_X, &inst->Src[0]);
+   s2_reg = get_src_reg(gen, CHAN_Y, &inst->Src[1]);
    /* t = x0 * y1 - t */
    spe_fms(gen->f, tmp_reg, s1_reg, s2_reg, tmp_reg);
 
-   if (inst->FullDstRegisters[0].DstRegister.WriteMask & (1 << CHAN_Z)) {
-      store_dest_reg(gen, tmp_reg, CHAN_Z, &inst->FullDstRegisters[0]);
+   if (inst->Dst[0].Register.WriteMask & (1 << CHAN_Z)) {
+      store_dest_reg(gen, tmp_reg, CHAN_Z, &inst->Dst[0]);
    }
 
    free_itemps(gen);
@@ -1004,14 +995,14 @@ static boolean
 emit_inequality(struct codegen *gen, const struct tgsi_full_instruction *inst)
 {
    int ch, s1_reg[4], s2_reg[4], d_reg[4], one_reg;
-   bool complement = FALSE;
+   boolean complement = FALSE;
 
    one_reg = get_const_one_reg(gen);
 
    FOR_EACH_ENABLED_CHANNEL(inst, ch) {
-      s1_reg[ch] = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
-      s2_reg[ch] = get_src_reg(gen, ch, &inst->FullSrcRegisters[1]);
-      d_reg[ch] = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+      s1_reg[ch] = get_src_reg(gen, ch, &inst->Src[0]);
+      s2_reg[ch] = get_src_reg(gen, ch, &inst->Src[1]);
+      d_reg[ch] = get_dst_reg(gen, ch, &inst->Dst[0]);
    }
 
    FOR_EACH_ENABLED_CHANNEL(inst, ch) {
@@ -1052,7 +1043,7 @@ emit_inequality(struct codegen *gen, const struct tgsi_full_instruction *inst)
    }
 
    FOR_EACH_ENABLED_CHANNEL(inst, ch) {
-      store_dest_reg(gen, d_reg[ch], ch, &inst->FullDstRegisters[0]);
+      store_dest_reg(gen, d_reg[ch], ch, &inst->Dst[0]);
    }
 
    free_itemps(gen);
@@ -1069,10 +1060,10 @@ emit_CMP(struct codegen *gen, const struct tgsi_full_instruction *inst)
    int ch;
 
    FOR_EACH_ENABLED_CHANNEL(inst, ch) {
-      int s1_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
-      int s2_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[1]);
-      int s3_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[2]);
-      int d_reg = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+      int s1_reg = get_src_reg(gen, ch, &inst->Src[0]);
+      int s2_reg = get_src_reg(gen, ch, &inst->Src[1]);
+      int s3_reg = get_src_reg(gen, ch, &inst->Src[2]);
+      int d_reg = get_dst_reg(gen, ch, &inst->Dst[0]);
       int zero_reg = get_itemp(gen);
    
       spe_zero(gen->f, zero_reg);
@@ -1081,7 +1072,7 @@ emit_CMP(struct codegen *gen, const struct tgsi_full_instruction *inst)
       spe_fcgt(gen->f, d_reg, zero_reg, s1_reg);
       spe_selb(gen->f, d_reg, s3_reg, s2_reg, d_reg);
 
-      store_dest_reg(gen, d_reg, ch, &inst->FullDstRegisters[0]);
+      store_dest_reg(gen, d_reg, ch, &inst->Dst[0]);
       free_itemps(gen);
    }
 
@@ -1099,8 +1090,8 @@ emit_TRUNC(struct codegen *gen, const struct tgsi_full_instruction *inst)
    int ch, s1_reg[4], d_reg[4];
 
    FOR_EACH_ENABLED_CHANNEL(inst, ch) {
-      s1_reg[ch] = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
-      d_reg[ch] = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+      s1_reg[ch] = get_src_reg(gen, ch, &inst->Src[0]);
+      d_reg[ch] = get_dst_reg(gen, ch, &inst->Dst[0]);
    }
 
    /* Convert float to int */
@@ -1114,7 +1105,7 @@ emit_TRUNC(struct codegen *gen, const struct tgsi_full_instruction *inst)
    }
 
    FOR_EACH_ENABLED_CHANNEL(inst, ch) {
-      store_dest_reg(gen, d_reg[ch], ch, &inst->FullDstRegisters[0]);
+      store_dest_reg(gen, d_reg[ch], ch, &inst->Dst[0]);
    }
 
    free_itemps(gen);
@@ -1138,8 +1129,8 @@ emit_FLR(struct codegen *gen, const struct tgsi_full_instruction *inst)
    one_reg = get_const_one_reg(gen);
    
    FOR_EACH_ENABLED_CHANNEL(inst, ch) {
-      s1_reg[ch] = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
-      d_reg[ch] = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+      s1_reg[ch] = get_src_reg(gen, ch, &inst->Src[0]);
+      d_reg[ch] = get_dst_reg(gen, ch, &inst->Dst[0]);
       tmp_reg[ch] = get_itemp(gen);
    }
 
@@ -1165,7 +1156,7 @@ emit_FLR(struct codegen *gen, const struct tgsi_full_instruction *inst)
    }
 
    FOR_EACH_ENABLED_CHANNEL(inst, ch) {
-      store_dest_reg(gen, d_reg[ch], ch, &inst->FullDstRegisters[0]);
+      store_dest_reg(gen, d_reg[ch], ch, &inst->Dst[0]);
    }
 
    free_itemps(gen);
@@ -1186,8 +1177,8 @@ emit_FRC(struct codegen *gen, const struct tgsi_full_instruction *inst)
    one_reg = get_const_one_reg(gen);
 
    FOR_EACH_ENABLED_CHANNEL(inst, ch) {
-      s1_reg[ch] = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
-      d_reg[ch] = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+      s1_reg[ch] = get_src_reg(gen, ch, &inst->Src[0]);
+      d_reg[ch] = get_dst_reg(gen, ch, &inst->Dst[0]);
       tmp_reg[ch] = get_itemp(gen);
    }
 
@@ -1219,7 +1210,7 @@ emit_FRC(struct codegen *gen, const struct tgsi_full_instruction *inst)
 
    /* store result */
    FOR_EACH_ENABLED_CHANNEL(inst, ch) {
-      store_dest_reg(gen, d_reg[ch], ch, &inst->FullDstRegisters[0]);
+      store_dest_reg(gen, d_reg[ch], ch, &inst->Dst[0]);
    }
 
    free_itemps(gen);
@@ -1281,7 +1272,7 @@ emit_function_call(struct codegen *gen,
 
    if (scalar) {
       for (a = 0; a < num_args; a++) {
-         s_regs[a] = get_src_reg(gen, CHAN_X, &inst->FullSrcRegisters[a]);
+         s_regs[a] = get_src_reg(gen, CHAN_X, &inst->Src[a]);
       }
       /* we'll call the function, put the return value in this register,
        * then replicate it across all write-enabled components in d_reg.
@@ -1296,11 +1287,11 @@ emit_function_call(struct codegen *gen,
 
       if (!scalar) {
          for (a = 0; a < num_args; a++) {
-            s_regs[a] = get_src_reg(gen, ch, &inst->FullSrcRegisters[a]);
+            s_regs[a] = get_src_reg(gen, ch, &inst->Src[a]);
          }
       }
 
-      d_reg = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+      d_reg = get_dst_reg(gen, ch, &inst->Dst[0]);
 
       if (!scalar || !func_called) {
          /* for a scalar function, we'll really only call the function once */
@@ -1345,7 +1336,7 @@ emit_function_call(struct codegen *gen,
          spe_move(gen->f, d_reg, retval_reg);
       }
 
-      store_dest_reg(gen, d_reg, ch, &inst->FullDstRegisters[0]);
+      store_dest_reg(gen, d_reg, ch, &inst->Dst[0]);
       free_itemps(gen);
    }
 
@@ -1360,8 +1351,8 @@ emit_function_call(struct codegen *gen,
 static boolean
 emit_TEX(struct codegen *gen, const struct tgsi_full_instruction *inst)
 {
-   const uint target = inst->InstructionExtTexture.Texture;
-   const uint unit = inst->FullSrcRegisters[1].SrcRegister.Index;
+   const uint target = inst->Texture.Texture;
+   const uint unit = inst->Src[1].Register.Index;
    uint addr;
    int ch;
    int coord_regs[4], d_regs[4];
@@ -1382,14 +1373,14 @@ emit_TEX(struct codegen *gen, const struct tgsi_full_instruction *inst)
       return FALSE;
    }
 
-   assert(inst->FullSrcRegisters[1].SrcRegister.File == TGSI_FILE_SAMPLER);
+   assert(inst->Src[1].Register.File == TGSI_FILE_SAMPLER);
 
    spe_comment(gen->f, -4, "CALL tex:");
 
    /* get src/dst reg info */
    for (ch = 0; ch < 4; ch++) {
-      coord_regs[ch] = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
-      d_regs[ch] = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+      coord_regs[ch] = get_src_reg(gen, ch, &inst->Src[0]);
+      d_regs[ch] = get_dst_reg(gen, ch, &inst->Dst[0]);
    }
 
    {
@@ -1434,7 +1425,7 @@ emit_TEX(struct codegen *gen, const struct tgsi_full_instruction *inst)
    }
 
    FOR_EACH_ENABLED_CHANNEL(inst, ch) {
-      store_dest_reg(gen, d_regs[ch], ch, &inst->FullDstRegisters[0]);
+      store_dest_reg(gen, d_regs[ch], ch, &inst->Dst[0]);
       free_itemps(gen);
    }
 
@@ -1461,7 +1452,7 @@ emit_KIL(struct codegen *gen, const struct tgsi_full_instruction *inst)
 
    /* get src regs */
    FOR_EACH_ENABLED_CHANNEL(inst, ch) {
-      s_regs[ch] = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
+      s_regs[ch] = get_src_reg(gen, ch, &inst->Src[0]);
    }
 
    /* test if any src regs are < 0 */
@@ -1509,9 +1500,9 @@ emit_MIN_MAX(struct codegen *gen, const struct tgsi_full_instruction *inst)
    int ch, s0_reg[4], s1_reg[4], d_reg[4], tmp_reg[4];
 
    FOR_EACH_ENABLED_CHANNEL(inst, ch) {
-      s0_reg[ch] = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
-      s1_reg[ch] = get_src_reg(gen, ch, &inst->FullSrcRegisters[1]);
-      d_reg[ch] = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+      s0_reg[ch] = get_src_reg(gen, ch, &inst->Src[0]);
+      s1_reg[ch] = get_src_reg(gen, ch, &inst->Src[1]);
+      d_reg[ch] = get_dst_reg(gen, ch, &inst->Dst[0]);
       tmp_reg[ch] = get_itemp(gen);         
    }
 
@@ -1527,7 +1518,7 @@ emit_MIN_MAX(struct codegen *gen, const struct tgsi_full_instruction *inst)
    }
 
    FOR_EACH_ENABLED_CHANNEL(inst, ch) {
-      store_dest_reg(gen, d_reg[ch], ch, &inst->FullDstRegisters[0]);
+      store_dest_reg(gen, d_reg[ch], ch, &inst->Dst[0]);
    }
 
    free_itemps(gen);
@@ -1584,7 +1575,7 @@ emit_IF(struct codegen *gen, const struct tgsi_full_instruction *inst)
 
    /* update conditional execution mask with the predicate register */
    int tmp_reg = get_itemp(gen);
-   int s1_reg = get_src_reg(gen, channel, &inst->FullSrcRegisters[0]);
+   int s1_reg = get_src_reg(gen, channel, &inst->Src[0]);
 
    /* tmp = (s1_reg == 0) */
    spe_ceqi(gen->f, tmp_reg, s1_reg, 0);
@@ -1708,8 +1699,8 @@ emit_DDX_DDY(struct codegen *gen, const struct tgsi_full_instruction *inst,
    int ch;
 
    FOR_EACH_ENABLED_CHANNEL(inst, ch) {
-      int s_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
-      int d_reg = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+      int s_reg = get_src_reg(gen, ch, &inst->Src[0]);
+      int d_reg = get_dst_reg(gen, ch, &inst->Dst[0]);
 
       int t1_reg = get_itemp(gen);
       int t2_reg = get_itemp(gen);
@@ -1758,7 +1749,6 @@ emit_instruction(struct codegen *gen,
    case TGSI_OPCODE_ARL:
       return emit_ARL(gen, inst);
    case TGSI_OPCODE_MOV:
-   case TGSI_OPCODE_SWZ:
       return emit_MOV(gen, inst);
    case TGSI_OPCODE_ADD:
    case TGSI_OPCODE_SUB:
@@ -1766,7 +1756,7 @@ emit_instruction(struct codegen *gen,
       return emit_binop(gen, inst);
    case TGSI_OPCODE_MAD:
       return emit_MAD(gen, inst);
-   case TGSI_OPCODE_LERP:
+   case TGSI_OPCODE_LRP:
       return emit_LRP(gen, inst);
    case TGSI_OPCODE_DP3:
       return emit_DP3(gen, inst);
@@ -1919,8 +1909,8 @@ emit_declaration(struct cell_context *cell,
 
    switch (decl->Declaration.File) {
    case TGSI_FILE_TEMPORARY:
-      for (i = decl->DeclarationRange.First;
-           i <= decl->DeclarationRange.Last;
+      for (i = decl->Range.First;
+           i <= decl->Range.Last;
            i++) {
          assert(i < MAX_TEMPS);
          for (ch = 0; ch < 4; ch++) {
index ccd0fef6e84ef479702a91ad2b2cf43d849e35f8..c18a5d0635e9264713f0cc9268995546f1264cd9 100644 (file)
@@ -383,10 +383,10 @@ cell_init_state_functions(struct cell_context *cell)
    cell->pipe.delete_blend_state = cell_delete_blend_state;
 
    cell->pipe.create_sampler_state = cell_create_sampler_state;
-   cell->pipe.bind_sampler_states = cell_bind_sampler_states;
+   cell->pipe.bind_fragment_sampler_states = cell_bind_sampler_states;
    cell->pipe.delete_sampler_state = cell_delete_sampler_state;
 
-   cell->pipe.set_sampler_textures = cell_set_sampler_textures;
+   cell->pipe.set_fragment_sampler_textures = cell_set_sampler_textures;
 
    cell->pipe.create_depth_stencil_alpha_state = cell_create_depth_stencil_alpha_state;
    cell->pipe.bind_depth_stencil_alpha_state   = cell_bind_depth_stencil_alpha_state;
index efc4f78364b440dcf4e35f91a5a3f8d0b310aa1b..b723e794e71cf25cdbd73966b4030a21f6177f64 100644 (file)
@@ -66,7 +66,7 @@ calculate_vertex_layout( struct cell_context *cell )
    vinfo->num_attribs = 0;
 
    /* we always want to emit vertex pos */
-   src = draw_find_vs_output(cell->draw, TGSI_SEMANTIC_POSITION, 0);
+   src = draw_find_shader_output(cell->draw, TGSI_SEMANTIC_POSITION, 0);
    assert(src >= 0);
    draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_POS, src);
 
@@ -82,14 +82,14 @@ calculate_vertex_layout( struct cell_context *cell )
          break;
 
       case TGSI_SEMANTIC_COLOR:
-         src = draw_find_vs_output(cell->draw, TGSI_SEMANTIC_COLOR, 
+         src = draw_find_shader_output(cell->draw, TGSI_SEMANTIC_COLOR, 
                                    fs->info.input_semantic_index[i]);
          assert(src >= 0);
          draw_emit_vertex_attr(vinfo, EMIT_4F, colorInterp, src);
          break;
 
       case TGSI_SEMANTIC_FOG:
-         src = draw_find_vs_output(cell->draw, TGSI_SEMANTIC_FOG, 0);
+         src = draw_find_shader_output(cell->draw, TGSI_SEMANTIC_FOG, 0);
 #if 1
          if (src < 0) /* XXX temp hack, try demos/fogcoord.c with this */
             src = 0;
@@ -100,7 +100,7 @@ calculate_vertex_layout( struct cell_context *cell )
 
       case TGSI_SEMANTIC_GENERIC:
          /* this includes texcoords and varying vars */
-         src = draw_find_vs_output(cell->draw, TGSI_SEMANTIC_GENERIC,
+         src = draw_find_shader_output(cell->draw, TGSI_SEMANTIC_GENERIC,
                               fs->info.input_semantic_index[i]);
          assert(src >= 0);
          draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src);
index 9479c0898fd76c2f6a3b3a205b6d1ecde3d0f764..5b87286d4c5ea7428d23b5c3311dbdc63feddba7 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "pipe/p_inlines.h"
 #include "util/u_memory.h"
+#include "util/u_math.h"
 #include "cell_context.h"
 #include "cell_gen_fragment.h"
 #include "cell_state.h"
@@ -299,9 +300,9 @@ cell_emit_state(struct cell_context *cell)
                for (level = 0; level < CELL_MAX_TEXTURE_LEVELS; level++) {
                   texture->start[level] = (ct->mapped +
                                            ct->level_offset[level]);
-                  texture->width[level] = ct->base.width[level];
-                  texture->height[level] = ct->base.height[level];
-                  texture->depth[level] = ct->base.depth[level];
+                  texture->width[level] = u_minify(ct->base.width0, level);
+                  texture->height[level] = u_minify(ct->base.height0, level);
+                  texture->depth[level] = u_minify(ct->base.depth0, level);
                }
                texture->target = ct->base.target;
             }
@@ -330,7 +331,7 @@ cell_emit_state(struct cell_context *cell)
       const struct draw_context *const draw = cell->draw;
       struct cell_shader_info info;
 
-      info.num_outputs = draw_num_vs_outputs(draw);
+      info.num_outputs = draw_num_shader_outputs(draw);
       info.declarations = (uintptr_t) draw->vs.machine.Declarations;
       info.num_declarations = draw->vs.machine.NumDeclarations;
       info.instructions = (uintptr_t) draw->vs.machine.Instructions;
index ae4c61efb3bee91e072a545578a6de91ae13c442..998944f77a399717a86e06d5b50f1b794f3432ce 100644 (file)
@@ -35,6 +35,8 @@
 #include "pipe/p_defines.h"
 #include "pipe/p_inlines.h"
 #include "pipe/internal/p_winsys_screen.h"
+
+#include "util/u_format.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
 
@@ -49,9 +51,9 @@ cell_texture_layout(struct cell_texture *ct)
 {
    struct pipe_texture *pt = &ct->base;
    unsigned level;
-   unsigned width = pt->width[0];
-   unsigned height = pt->height[0];
-   unsigned depth = pt->depth[0];
+   unsigned width = pt->width0;
+   unsigned height = pt->height0;
+   unsigned depth = pt->depth0;
 
    ct->buffer_size = 0;
 
@@ -65,17 +67,11 @@ cell_texture_layout(struct cell_texture *ct)
       w_tile = align(width, TILE_SIZE);
       h_tile = align(height, TILE_SIZE);
 
-      pt->width[level] = width;
-      pt->height[level] = height;
-      pt->depth[level] = depth;
-      pt->nblocksx[level] = pf_get_nblocksx(&pt->block, w_tile);  
-      pt->nblocksy[level] = pf_get_nblocksy(&pt->block, h_tile);  
-
-      ct->stride[level] = pt->nblocksx[level] * pt->block.size;
+      ct->stride[level] = util_format_get_stride(pt->format, w_tile);
 
       ct->level_offset[level] = ct->buffer_size;
 
-      size = pt->nblocksx[level] * pt->nblocksy[level] * pt->block.size;
+      size = ct->stride[level] * util_format_get_nblocksy(pt->format, h_tile);
       if (pt->target == PIPE_TEXTURE_CUBE)
          size *= 6;
       else
@@ -83,9 +79,9 @@ cell_texture_layout(struct cell_texture *ct)
 
       ct->buffer_size += size;
 
-      width = minify(width);
-      height = minify(height);
-      depth = minify(depth);
+      width = u_minify(width, 1);
+      height = u_minify(height, 1);
+      depth = u_minify(depth, 1);
    }
 }
 
@@ -276,8 +272,8 @@ cell_get_tex_surface(struct pipe_screen *screen,
       pipe_reference_init(&ps->reference, 1);
       pipe_texture_reference(&ps->texture, pt);
       ps->format = pt->format;
-      ps->width = pt->width[level];
-      ps->height = pt->height[level];
+      ps->width = u_minify(pt->width0, level);
+      ps->height = u_minify(pt->height0, level);
       ps->offset = ct->level_offset[level];
       /* XXX may need to override usage flags (see sp_texture.c) */
       ps->usage = usage;
@@ -286,10 +282,12 @@ cell_get_tex_surface(struct pipe_screen *screen,
       ps->zslice = zslice;
 
       if (pt->target == PIPE_TEXTURE_CUBE) {
-         ps->offset += face * pt->nblocksy[level] * ct->stride[level];
+         unsigned h_tile = align(ps->height, TILE_SIZE);
+         ps->offset += face * util_format_get_nblocksy(ps->format, h_tile) * ct->stride[level];
       }
       else if (pt->target == PIPE_TEXTURE_3D) {
-         ps->offset += zslice * pt->nblocksy[level] * ct->stride[level];
+         unsigned h_tile = align(ps->height, TILE_SIZE);
+         ps->offset += zslice * util_format_get_nblocksy(ps->format, h_tile) * ct->stride[level];
       }
       else {
          assert(face == 0);
@@ -330,14 +328,10 @@ cell_get_tex_transfer(struct pipe_screen *screen,
    if (ctrans) {
       struct pipe_transfer *pt = &ctrans->base;
       pipe_texture_reference(&pt->texture, texture);
-      pt->format = texture->format;
-      pt->block = texture->block;
       pt->x = x;
       pt->y = y;
       pt->width = w;
       pt->height = h;
-      pt->nblocksx = texture->nblocksx[level];
-      pt->nblocksy = texture->nblocksy[level];
       pt->stride = ct->stride[level];
       pt->usage = usage;
       pt->face = face;
@@ -347,10 +341,12 @@ cell_get_tex_transfer(struct pipe_screen *screen,
       ctrans->offset = ct->level_offset[level];
 
       if (texture->target == PIPE_TEXTURE_CUBE) {
-         ctrans->offset += face * pt->nblocksy * pt->stride;
+         unsigned h_tile = align(u_minify(texture->height0, level), TILE_SIZE);
+         ctrans->offset += face * util_format_get_nblocksy(texture->format, h_tile) * pt->stride;
       }
       else if (texture->target == PIPE_TEXTURE_3D) {
-         ctrans->offset += zslice * pt->nblocksy * pt->stride;
+         unsigned h_tile = align(u_minify(texture->height0, level), TILE_SIZE);
+         ctrans->offset += zslice * util_format_get_nblocksy(texture->format, h_tile) * pt->stride;
       }
       else {
          assert(face == 0);
@@ -386,8 +382,8 @@ cell_transfer_map(struct pipe_screen *screen, struct pipe_transfer *transfer)
    struct pipe_texture *pt = transfer->texture;
    struct cell_texture *ct = cell_texture(pt);
    const uint level = ctrans->base.level;
-   const uint texWidth = pt->width[level];
-   const uint texHeight = pt->height[level];
+   const uint texWidth = u_minify(pt->width0, level);
+   const uint texHeight = u_minify(pt->height0, level);
    const uint stride = ct->stride[level];
    unsigned size;
 
@@ -403,7 +399,8 @@ cell_transfer_map(struct pipe_screen *screen, struct pipe_transfer *transfer)
     * Create a buffer of ordinary memory for the linear texture.
     * This is the memory that the user will read/write.
     */
-   size = pt->nblocksx[level] * pt->nblocksy[level] * pt->block.size;
+   size = util_format_get_stride(pt->format, align(texWidth, TILE_SIZE)) *
+          util_format_get_nblocksy(pt->format, align(texHeight, TILE_SIZE));
 
    ctrans->map = align_malloc(size, 16);
    if (!ctrans->map)
@@ -411,7 +408,7 @@ cell_transfer_map(struct pipe_screen *screen, struct pipe_transfer *transfer)
 
    if (transfer->usage & PIPE_TRANSFER_READ) {
       /* need to untwiddle the texture to make a linear version */
-      const uint bpp = pf_get_size(ct->base.format);
+      const uint bpp = util_format_get_blocksize(ct->base.format);
       if (bpp == 4) {
          const uint *src = (uint *) (ct->mapped + ctrans->offset);
          uint *dst = ctrans->map;
@@ -440,8 +437,8 @@ cell_transfer_unmap(struct pipe_screen *screen,
    struct pipe_texture *pt = transfer->texture;
    struct cell_texture *ct = cell_texture(pt);
    const uint level = ctrans->base.level;
-   const uint texWidth = pt->width[level];
-   const uint texHeight = pt->height[level];
+   const uint texWidth = u_minify(pt->width0, level);
+   const uint texHeight = u_minify(pt->height0, level);
    const uint stride = ct->stride[level];
 
    if (!ct->mapped) {
@@ -454,7 +451,7 @@ cell_transfer_unmap(struct pipe_screen *screen,
       /* The user wrote new texture data into the mapped buffer.
        * We need to convert the new linear data into the twiddled/tiled format.
        */
-      const uint bpp = pf_get_size(ct->base.format);
+      const uint bpp = util_format_get_blocksize(ct->base.format);
       if (bpp == 4) {
          const uint *src = ctrans->map;
          uint *dst = (uint *) (ct->mapped + ctrans->offset);
index 5c0179d95462015ce358303016003bdfb0f84ac3..12b855a3db2dd21a0f41059eab543976b3658df8 100644 (file)
@@ -405,8 +405,6 @@ cmd_state_sampler(const struct cell_command_sampler *sampler)
    case PIPE_TEX_FILTER_LINEAR:
       spu.min_sample_texture_2d[unit] = sample_texture_2d_bilinear;
       break;
-   case PIPE_TEX_FILTER_ANISO:
-      /* fall-through, for now */
    case PIPE_TEX_FILTER_NEAREST:
       spu.min_sample_texture_2d[unit] = sample_texture_2d_nearest;
       break;
@@ -418,8 +416,6 @@ cmd_state_sampler(const struct cell_command_sampler *sampler)
    case PIPE_TEX_FILTER_LINEAR:
       spu.mag_sample_texture_2d[unit] = sample_texture_2d_bilinear;
       break;
-   case PIPE_TEX_FILTER_ANISO:
-      /* fall-through, for now */
    case PIPE_TEX_FILTER_NEAREST:
       spu.mag_sample_texture_2d[unit] = sample_texture_2d_nearest;
       break;
index 0eaae2e451bc12258b213931fb5302cfa3988250..d86d8e09a5159d1aac40e285460cb553405e4af9 100644 (file)
    for (CHAN = 0; CHAN < 4; CHAN++)
 
 #define IS_CHANNEL_ENABLED(INST, CHAN)\
-   ((INST).FullDstRegisters[0].DstRegister.WriteMask & (1 << (CHAN)))
+   ((INST).Dst[0].Register.WriteMask & (1 << (CHAN)))
 
 #define IS_CHANNEL_ENABLED2(INST, CHAN)\
-   ((INST).FullDstRegisters[1].DstRegister.WriteMask & (1 << (CHAN)))
+   ((INST).Dst[1].Register.WriteMask & (1 << (CHAN)))
 
 #define FOR_EACH_ENABLED_CHANNEL(INST, CHAN)\
    FOR_EACH_CHANNEL( CHAN )\
@@ -346,10 +346,10 @@ fetch_src_file_channel(
    union spu_exec_channel *chan )
 {
    switch( swizzle ) {
-   case TGSI_EXTSWIZZLE_X:
-   case TGSI_EXTSWIZZLE_Y:
-   case TGSI_EXTSWIZZLE_Z:
-   case TGSI_EXTSWIZZLE_W:
+   case TGSI_SWIZZLE_X:
+   case TGSI_SWIZZLE_Y:
+   case TGSI_SWIZZLE_Z:
+   case TGSI_SWIZZLE_W:
       switch( file ) {
       case TGSI_FILE_CONSTANT: {
          unsigned i;
@@ -413,14 +413,6 @@ fetch_src_file_channel(
       }
       break;
 
-   case TGSI_EXTSWIZZLE_ZERO:
-      *chan = mach->Temps[TEMP_0_I].xyzw[TEMP_0_C];
-      break;
-
-   case TGSI_EXTSWIZZLE_ONE:
-      *chan = mach->Temps[TEMP_1_I].xyzw[TEMP_1_C];
-      break;
-
    default:
       ASSERT( 0 );
    }
@@ -439,22 +431,22 @@ fetch_source(
    index.i[0] =
    index.i[1] =
    index.i[2] =
-   index.i[3] = reg->SrcRegister.Index;
+   index.i[3] = reg->Register.Index;
 
-   if (reg->SrcRegister.Indirect) {
+   if (reg->Register.Indirect) {
       union spu_exec_channel index2;
       union spu_exec_channel indir_index;
 
       index2.i[0] =
       index2.i[1] =
       index2.i[2] =
-      index2.i[3] = reg->SrcRegisterInd.Index;
+      index2.i[3] = reg->Indirect.Index;
 
-      swizzle = tgsi_util_get_src_register_swizzle(&reg->SrcRegisterInd,
+      swizzle = tgsi_util_get_src_register_swizzle(&reg->Indirect,
                                                    CHAN_X);
       fetch_src_file_channel(
          mach,
-         reg->SrcRegisterInd.File,
+         reg->Indirect.File,
          swizzle,
          &index2,
          &indir_index );
@@ -462,8 +454,8 @@ fetch_source(
       index.q = si_a(index.q, indir_index.q);
    }
 
-   if( reg->SrcRegister.Dimension ) {
-      switch( reg->SrcRegister.File ) {
+   if( reg->Register.Dimension ) {
+      switch( reg->Register.File ) {
       case TGSI_FILE_INPUT:
          index.q = si_mpyi(index.q, 17);
          break;
@@ -474,24 +466,24 @@ fetch_source(
          ASSERT( 0 );
       }
 
-      index.i[0] += reg->SrcRegisterDim.Index;
-      index.i[1] += reg->SrcRegisterDim.Index;
-      index.i[2] += reg->SrcRegisterDim.Index;
-      index.i[3] += reg->SrcRegisterDim.Index;
+      index.i[0] += reg->Dimension.Index;
+      index.i[1] += reg->Dimension.Index;
+      index.i[2] += reg->Dimension.Index;
+      index.i[3] += reg->Dimension.Index;
 
-      if (reg->SrcRegisterDim.Indirect) {
+      if (reg->Dimension.Indirect) {
          union spu_exec_channel index2;
          union spu_exec_channel indir_index;
 
          index2.i[0] =
          index2.i[1] =
          index2.i[2] =
-         index2.i[3] = reg->SrcRegisterDimInd.Index;
+         index2.i[3] = reg->DimIndirect.Index;
 
-         swizzle = tgsi_util_get_src_register_swizzle( &reg->SrcRegisterDimInd, CHAN_X );
+         swizzle = tgsi_util_get_src_register_swizzle( &reg->DimIndirect, CHAN_X );
          fetch_src_file_channel(
             mach,
-            reg->SrcRegisterDimInd.File,
+            reg->DimIndirect.File,
             swizzle,
             &index2,
             &indir_index );
@@ -500,10 +492,10 @@ fetch_source(
       }
    }
 
-   swizzle = tgsi_util_get_full_src_register_extswizzle( reg, chan_index );
+   swizzle = tgsi_util_get_full_src_register_swizzle( reg, chan_index );
    fetch_src_file_channel(
       mach,
-      reg->SrcRegister.File,
+      reg->Register.File,
       swizzle,
       &index,
       chan );
@@ -525,7 +517,7 @@ fetch_source(
       break;
    }
 
-   if (reg->SrcRegisterExtMod.Complement) {
+   if (reg->RegisterExtMod.Complement) {
       chan->q = si_fs(mach->Temps[TEMP_1_I].xyzw[TEMP_1_C].q, chan->q);
    }
 }
@@ -540,21 +532,21 @@ store_dest(
 {
    union spu_exec_channel *dst;
 
-   switch( reg->DstRegister.File ) {
+   switch( reg->Register.File ) {
    case TGSI_FILE_NULL:
       return;
 
    case TGSI_FILE_OUTPUT:
       dst = &mach->Outputs[mach->Temps[TEMP_OUTPUT_I].xyzw[TEMP_OUTPUT_C].u[0]
-                           + reg->DstRegister.Index].xyzw[chan_index];
+                           + reg->Register.Index].xyzw[chan_index];
       break;
 
    case TGSI_FILE_TEMPORARY:
-      dst = &mach->Temps[reg->DstRegister.Index].xyzw[chan_index];
+      dst = &mach->Temps[reg->Register.Index].xyzw[chan_index];
       break;
 
    case TGSI_FILE_ADDRESS:
-      dst = &mach->Addrs[reg->DstRegister.Index].xyzw[chan_index];
+      dst = &mach->Addrs[reg->Register.Index].xyzw[chan_index];
       break;
 
    default:
@@ -591,10 +583,10 @@ store_dest(
 }
 
 #define FETCH(VAL,INDEX,CHAN)\
-    fetch_source (mach, VAL, &inst->FullSrcRegisters[INDEX], CHAN)
+    fetch_source (mach, VAL, &inst->Src[INDEX], CHAN)
 
 #define STORE(VAL,INDEX,CHAN)\
-    store_dest (mach, VAL, &inst->FullDstRegisters[INDEX], inst, CHAN )
+    store_dest (mach, VAL, &inst->Dst[INDEX], inst, CHAN )
 
 
 /**
@@ -610,10 +602,8 @@ exec_kil(struct spu_exec_machine *mach,
    uint kilmask = 0; /* bit 0 = pixel 0, bit 1 = pixel 1, etc */
    union spu_exec_channel r[1];
 
-   /* This mask stores component bits that were already tested. Note that
-    * we test if the value is less than zero, so 1.0 and 0.0 need not to be
-    * tested. */
-   uniquemask = (1 << TGSI_EXTSWIZZLE_ZERO) | (1 << TGSI_EXTSWIZZLE_ONE);
+   /* This mask stores component bits that were already tested. */
+   uniquemask = 0;
 
    for (chan_index = 0; chan_index < 4; chan_index++)
    {
@@ -621,8 +611,8 @@ exec_kil(struct spu_exec_machine *mach,
       uint i;
 
       /* unswizzle channel */
-      swizzle = tgsi_util_get_full_src_register_extswizzle (
-                        &inst->FullSrcRegisters[0],
+      swizzle = tgsi_util_get_full_src_register_swizzle (
+                        &inst->Src[0],
                         chan_index);
 
       /* check if the component has not been already tested */
@@ -687,7 +677,7 @@ exec_tex(struct spu_exec_machine *mach,
          const struct tgsi_full_instruction *inst,
          boolean biasLod, boolean projected)
 {
-   const uint unit = inst->FullSrcRegisters[1].SrcRegister.Index;
+   const uint unit = inst->Src[1].Register.Index;
    union spu_exec_channel r[8];
    uint chan_index;
    float lodBias;
@@ -843,8 +833,8 @@ exec_declaration(struct spu_exec_machine *mach,
          unsigned first, last, mask;
          interpolation_func interp;
 
-         first = decl->DeclarationRange.First;
-         last = decl->DeclarationRange.Last;
+         first = decl->Range.First;
+         last = decl->Range.Last;
          mask = decl->Declaration.UsageMask;
 
          switch( decl->Declaration.Interpolate ) {
@@ -909,7 +899,6 @@ exec_instruction(
       break;
 
    case TGSI_OPCODE_MOV:
-   case TGSI_OPCODE_SWZ:
       FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
          FETCH( &r[0], 0, chan_index );
          STORE( &r[0], 0, chan_index );
@@ -1692,7 +1681,7 @@ exec_instruction(
       }
       break;
 
-   case TGSI_OPCODE_SHR:
+   case TGSI_OPCODE_ISHR:
       FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
          FETCH( &r[0], 0, chan_index );
          FETCH( &r[1], 1, chan_index );
@@ -1807,22 +1796,6 @@ exec_instruction(
       /* no-op */
       break;
 
-   case TGSI_OPCODE_NOISE1:
-      ASSERT( 0 );
-      break;
-
-   case TGSI_OPCODE_NOISE2:
-      ASSERT( 0 );
-      break;
-
-   case TGSI_OPCODE_NOISE3:
-      ASSERT( 0 );
-      break;
-
-   case TGSI_OPCODE_NOISE4:
-      ASSERT( 0 );
-      break;
-
    case TGSI_OPCODE_NOP:
       break;
 
index af25dd3718a1e04cfcfc9f042b2622b6665b3522..24057e29e36317dcb42ee1a56beaf10cd082fee4 100644 (file)
@@ -26,104 +26,17 @@ tgsi_util_get_src_register_swizzle(
    return 0;
 }
 
-unsigned
-tgsi_util_get_src_register_extswizzle(
-   const struct tgsi_src_register_ext_swz *reg,
-   unsigned component )
-{
-   switch( component ) {
-   case 0:
-      return reg->ExtSwizzleX;
-   case 1:
-      return reg->ExtSwizzleY;
-   case 2:
-      return reg->ExtSwizzleZ;
-   case 3:
-      return reg->ExtSwizzleW;
-   default:
-      ASSERT( 0 );
-   }
-   return 0;
-}
 
 unsigned
-tgsi_util_get_full_src_register_extswizzle(
+tgsi_util_get_full_src_register_swizzle(
    const struct tgsi_full_src_register  *reg,
    unsigned component )
 {
-   unsigned swizzle;
-
-   /*
-    * First, calculate  the   extended swizzle for a given channel. This will give
-    * us either a channel index into the simple swizzle or  a constant 1 or   0.
-    */
-   swizzle = tgsi_util_get_src_register_extswizzle(
-      &reg->SrcRegisterExtSwz,
+   return tgsi_util_get_src_register_swizzle(
+      reg->Register,
       component );
-
-   ASSERT (TGSI_SWIZZLE_X == TGSI_EXTSWIZZLE_X);
-   ASSERT (TGSI_SWIZZLE_Y == TGSI_EXTSWIZZLE_Y);
-   ASSERT (TGSI_SWIZZLE_Z == TGSI_EXTSWIZZLE_Z);
-   ASSERT (TGSI_SWIZZLE_W == TGSI_EXTSWIZZLE_W);
-   ASSERT (TGSI_EXTSWIZZLE_ZERO > TGSI_SWIZZLE_W);
-   ASSERT (TGSI_EXTSWIZZLE_ONE > TGSI_SWIZZLE_W);
-
-   /*
-    * Second, calculate the simple  swizzle  for   the   unswizzled channel index.
-    * Leave the constants intact, they are   not   affected by the   simple swizzle.
-    */
-   if( swizzle <= TGSI_SWIZZLE_W ) {
-      swizzle = tgsi_util_get_src_register_swizzle(
-         &reg->SrcRegister,
-         component );
-   }
-
-   return swizzle;
 }
 
-unsigned
-tgsi_util_get_src_register_extnegate(
-   const  struct tgsi_src_register_ext_swz *reg,
-   unsigned component )
-{
-   switch( component ) {
-   case 0:
-      return reg->NegateX;
-   case 1:
-      return reg->NegateY;
-   case 2:
-      return reg->NegateZ;
-   case 3:
-      return reg->NegateW;
-   default:
-      ASSERT( 0 );
-   }
-   return 0;
-}
-
-void
-tgsi_util_set_src_register_extnegate(
-   struct tgsi_src_register_ext_swz *reg,
-   unsigned negate,
-   unsigned component )
-{
-   switch( component ) {
-   case 0:
-      reg->NegateX = negate;
-      break;
-   case 1:
-      reg->NegateY = negate;
-      break;
-   case 2:
-      reg->NegateZ = negate;
-      break;
-   case 3:
-      reg->NegateW = negate;
-      break;
-   default:
-      ASSERT( 0 );
-   }
-}
 
 unsigned
 tgsi_util_get_full_src_register_sign_mode(
@@ -132,10 +45,10 @@ tgsi_util_get_full_src_register_sign_mode(
 {
    unsigned sign_mode;
 
-   if( reg->SrcRegisterExtMod.Absolute ) {
+   if( reg->RegisterExtMod.Absolute ) {
       /* Consider only the post-abs negation. */
 
-      if( reg->SrcRegisterExtMod.Negate ) {
+      if( reg->RegisterExtMod.Negate ) {
          sign_mode = TGSI_UTIL_SIGN_SET;
       }
       else {
@@ -147,11 +60,8 @@ tgsi_util_get_full_src_register_sign_mode(
 
       unsigned negate;
 
-      negate = reg->SrcRegister.Negate;
-      if( tgsi_util_get_src_register_extnegate( &reg->SrcRegisterExtSwz, component ) ) {
-         negate = !negate;
-      }
-      if( reg->SrcRegisterExtMod.Negate ) {
+      negate = reg->Register.Negate;
+      if( reg->RegisterExtMod.Negate ) {
          negate = !negate;
       }
 
index 37184eac7b17522b6862d6c6bf5680fab3c15b9f..46e4338d98ae05a8d211e0654de8df245d09870f 100644 (file)
@@ -44,11 +44,19 @@ static void failover_destroy( struct pipe_context *pipe )
 }
 
 
+void failover_fail_over( struct failover_context *failover )
+{
+   failover->dirty = TRUE;
+   failover->mode = FO_SW;
+}
+
 
-static boolean failover_draw_elements( struct pipe_context *pipe,
-                                      struct pipe_buffer *indexBuffer,
-                                      unsigned indexSize,
-                                      unsigned prim, unsigned start, unsigned count)
+static void failover_draw_elements( struct pipe_context *pipe,
+                                    struct pipe_buffer *indexBuffer,
+                                    unsigned indexSize,
+                                    unsigned prim, 
+                                    unsigned start, 
+                                    unsigned count)
 {
    struct failover_context *failover = failover_context( pipe );
 
@@ -62,24 +70,22 @@ static boolean failover_draw_elements( struct pipe_context *pipe,
    /* Try hardware:
     */
    if (failover->mode == FO_HW) {
-      if (!failover->hw->draw_elements( failover->hw, 
-                                       indexBuffer, 
-                                       indexSize, 
-                                       prim, 
-                                       start, 
-                                       count )) {
-
-        failover->hw->flush( failover->hw, ~0, NULL );
-        failover->mode = FO_SW;
-      }
+      failover->hw->draw_elements( failover->hw, 
+                                   indexBuffer, 
+                                   indexSize, 
+                                   prim, 
+                                   start, 
+                                   count );
    }
 
    /* Possibly try software:
     */
    if (failover->mode == FO_SW) {
 
-      if (failover->dirty) 
+      if (failover->dirty) {
+         failover->hw->flush( failover->hw, ~0, NULL );
         failover_state_emit( failover );
+      }
 
       failover->sw->draw_elements( failover->sw, 
                                   indexBuffer, 
@@ -94,15 +100,13 @@ static boolean failover_draw_elements( struct pipe_context *pipe,
        */
       failover->sw->flush( failover->sw, ~0, NULL );
    }
-
-   return TRUE;
 }
 
 
-static boolean failover_draw_arrays( struct pipe_context *pipe,
+static void failover_draw_arrays( struct pipe_context *pipe,
                                     unsigned prim, unsigned start, unsigned count)
 {
-   return failover_draw_elements(pipe, NULL, 0, prim, start, count);
+   failover_draw_elements(pipe, NULL, 0, prim, start, count);
 }
 
 static unsigned int
index 9ba86ba86649462b3bd050f4d9194451b07bb13a..149393712a3c90aff853f6fd6ee55a77e82971a2 100644 (file)
@@ -72,6 +72,7 @@ struct failover_context {
     */
    const struct fo_state     *blend;
    const struct fo_state     *sampler[PIPE_MAX_SAMPLERS];
+   const struct fo_state     *vertex_samplers[PIPE_MAX_VERTEX_SAMPLERS];
    const struct fo_state     *depth_stencil;
    const struct fo_state     *rasterizer;
    const struct fo_state     *fragment_shader;
@@ -83,6 +84,7 @@ struct failover_context {
    struct pipe_poly_stipple poly_stipple;
    struct pipe_scissor_state scissor;
    struct pipe_texture *texture[PIPE_MAX_SAMPLERS];
+   struct pipe_texture *vertex_textures[PIPE_MAX_VERTEX_SAMPLERS];
    struct pipe_viewport_state viewport;
    struct pipe_vertex_buffer vertex_buffers[PIPE_MAX_ATTRIBS];
    struct pipe_vertex_element vertex_elements[PIPE_MAX_ATTRIBS];
@@ -92,11 +94,15 @@ struct failover_context {
 
    void *sw_sampler_state[PIPE_MAX_SAMPLERS];
    void *hw_sampler_state[PIPE_MAX_SAMPLERS];
+   void *sw_vertex_sampler_state[PIPE_MAX_VERTEX_SAMPLERS];
+   void *hw_vertex_sampler_state[PIPE_MAX_VERTEX_SAMPLERS];
 
    unsigned dirty;
 
    unsigned num_samplers;
+   unsigned num_vertex_samplers;
    unsigned num_textures;
+   unsigned num_vertex_textures;
 
    unsigned mode;
    struct pipe_context *hw;
index c8eb92629943cbdc509c0355228a048682f25c47..3f5f5560323260612e3d0c99ec052b83716b8fa0 100644 (file)
@@ -322,8 +322,9 @@ failover_create_sampler_state(struct pipe_context *pipe,
 }
 
 static void
-failover_bind_sampler_states(struct pipe_context *pipe,
-                             unsigned num, void **sampler)
+failover_bind_fragment_sampler_states(struct pipe_context *pipe,
+                                      unsigned num,
+                                      void **sampler)
 {
    struct failover_context *failover = failover_context(pipe);
    struct fo_state *state = (struct fo_state*)sampler;
@@ -339,10 +340,40 @@ failover_bind_sampler_states(struct pipe_context *pipe,
    }
    failover->dirty |= FO_NEW_SAMPLER;
    failover->num_samplers = num;
-   failover->sw->bind_sampler_states(failover->sw, num,
-                                     failover->sw_sampler_state);
-   failover->hw->bind_sampler_states(failover->hw, num,
-                                     failover->hw_sampler_state);
+   failover->sw->bind_fragment_sampler_states(failover->sw, num,
+                                              failover->sw_sampler_state);
+   failover->hw->bind_fragment_sampler_states(failover->hw, num,
+                                              failover->hw_sampler_state);
+}
+
+static void
+failover_bind_vertex_sampler_states(struct pipe_context *pipe,
+                                    unsigned num_samplers,
+                                    void **samplers)
+{
+   struct failover_context *failover = failover_context(pipe);
+   struct fo_state *state = (struct fo_state*)samplers;
+   uint i;
+
+   assert(num_samplers <= PIPE_MAX_VERTEX_SAMPLERS);
+
+   /* Check for no-op */
+   if (num_samplers == failover->num_vertex_samplers &&
+       !memcmp(failover->vertex_samplers, samplers, num_samplers * sizeof(void *))) {
+      return;
+   }
+   for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
+      failover->sw_vertex_sampler_state[i] = i < num_samplers ? state[i].sw_state : NULL;
+      failover->hw_vertex_sampler_state[i] = i < num_samplers ? state[i].hw_state : NULL;
+   }
+   failover->dirty |= FO_NEW_SAMPLER;
+   failover->num_vertex_samplers = num_samplers;
+   failover->sw->bind_vertex_sampler_states(failover->sw,
+                                            num_samplers,
+                                            failover->sw_vertex_sampler_state);
+   failover->hw->bind_vertex_sampler_states(failover->hw,
+                                            num_samplers,
+                                            failover->hw_vertex_sampler_state);
 }
 
 static void
@@ -360,9 +391,9 @@ failover_delete_sampler_state(struct pipe_context *pipe, void *sampler)
 
 
 static void
-failover_set_sampler_textures(struct pipe_context *pipe,
-                              unsigned num,
-                              struct pipe_texture **texture)
+failover_set_fragment_sampler_textures(struct pipe_context *pipe,
+                                       unsigned num,
+                                       struct pipe_texture **texture)
 {
    struct failover_context *failover = failover_context(pipe);
    uint i;
@@ -381,8 +412,38 @@ failover_set_sampler_textures(struct pipe_context *pipe,
                              NULL);
    failover->dirty |= FO_NEW_TEXTURE;
    failover->num_textures = num;
-   failover->sw->set_sampler_textures( failover->sw, num, texture );
-   failover->hw->set_sampler_textures( failover->hw, num, texture );
+   failover->sw->set_fragment_sampler_textures( failover->sw, num, texture );
+   failover->hw->set_fragment_sampler_textures( failover->hw, num, texture );
+}
+
+
+static void
+failover_set_vertex_sampler_textures(struct pipe_context *pipe,
+                                     unsigned num_textures,
+                                     struct pipe_texture **textures)
+{
+   struct failover_context *failover = failover_context(pipe);
+   uint i;
+
+   assert(num_textures <= PIPE_MAX_VERTEX_SAMPLERS);
+
+   /* Check for no-op */
+   if (num_textures == failover->num_vertex_textures &&
+       !memcmp(failover->vertex_textures, textures, num_textures * sizeof(struct pipe_texture *))) {
+      return;
+   }
+   for (i = 0; i < num_textures; i++) {
+      pipe_texture_reference((struct pipe_texture **)&failover->vertex_textures[i],
+                             textures[i]);
+   }
+   for (i = num_textures; i < failover->num_vertex_textures; i++) {
+      pipe_texture_reference((struct pipe_texture **)&failover->vertex_textures[i],
+                             NULL);
+   }
+   failover->dirty |= FO_NEW_TEXTURE;
+   failover->num_vertex_textures = num_textures;
+   failover->sw->set_vertex_sampler_textures(failover->sw, num_textures, textures);
+   failover->hw->set_vertex_sampler_textures(failover->hw, num_textures, textures);
 }
 
 
@@ -453,7 +514,8 @@ failover_init_state_functions( struct failover_context *failover )
    failover->pipe.bind_blend_state   = failover_bind_blend_state;
    failover->pipe.delete_blend_state = failover_delete_blend_state;
    failover->pipe.create_sampler_state = failover_create_sampler_state;
-   failover->pipe.bind_sampler_states  = failover_bind_sampler_states;
+   failover->pipe.bind_fragment_sampler_states  = failover_bind_fragment_sampler_states;
+   failover->pipe.bind_vertex_sampler_states  = failover_bind_vertex_sampler_states;
    failover->pipe.delete_sampler_state = failover_delete_sampler_state;
    failover->pipe.create_depth_stencil_alpha_state = failover_create_depth_stencil_state;
    failover->pipe.bind_depth_stencil_alpha_state   = failover_bind_depth_stencil_state;
@@ -473,7 +535,8 @@ failover_init_state_functions( struct failover_context *failover )
    failover->pipe.set_framebuffer_state = failover_set_framebuffer_state;
    failover->pipe.set_polygon_stipple = failover_set_polygon_stipple;
    failover->pipe.set_scissor_state = failover_set_scissor_state;
-   failover->pipe.set_sampler_textures = failover_set_sampler_textures;
+   failover->pipe.set_fragment_sampler_textures = failover_set_fragment_sampler_textures;
+   failover->pipe.set_vertex_sampler_textures = failover_set_vertex_sampler_textures;
    failover->pipe.set_viewport_state = failover_set_viewport_state;
    failover->pipe.set_vertex_buffers = failover_set_vertex_buffers;
    failover->pipe.set_vertex_elements = failover_set_vertex_elements;
index bd4fce9d2090a52b2667f46985d0205b59ac6af0..a3341e33f807102fda034fc8f1290e9e8d2fd8a4 100644 (file)
@@ -92,13 +92,19 @@ failover_state_emit( struct failover_context *failover )
       failover->sw->set_viewport_state( failover->sw, &failover->viewport );
 
    if (failover->dirty & FO_NEW_SAMPLER) {
-      failover->sw->bind_sampler_states( failover->sw, failover->num_samplers,
-                                         failover->sw_sampler_state );
+      failover->sw->bind_fragment_sampler_states( failover->sw, failover->num_samplers,
+                                                  failover->sw_sampler_state );
+      failover->sw->bind_vertex_sampler_states(failover->sw,
+                                               failover->num_vertex_samplers,
+                                               failover->sw_vertex_sampler_state);
    }
 
    if (failover->dirty & FO_NEW_TEXTURE) {
-      failover->sw->set_sampler_textures( failover->sw, failover->num_textures, 
-                                          failover->texture );
+      failover->sw->set_fragment_sampler_textures( failover->sw, failover->num_textures, 
+                                                   failover->texture );
+      failover->sw->set_vertex_sampler_textures(failover->sw,
+                                                failover->num_vertex_textures, 
+                                                failover->vertex_textures);
    }
 
    if (failover->dirty & FO_NEW_VERTEX_BUFFER) {
index a8ce997a1f65ada9b8218bce59271ace5629794d..533122b69dabfe24332cb6eec05b60bd36b28f0f 100644 (file)
 
 
 struct pipe_context;
+struct failover_context;
 
 
 struct pipe_context *failover_create( struct pipe_context *hw,
                                      struct pipe_context *sw );
 
 
+void failover_fail_over( struct failover_context *failover );
+
 #endif /* FO_WINSYS_H */
index effeba12972dd90fc4b5c3427c1287788916965c..669964770d41fc6bf7857d917741cba958b41c0b 100644 (file)
@@ -111,6 +111,7 @@ i915_buffer_unmap(struct pipe_screen *screen,
 {
    struct i915_buffer *buf = i915_buffer(buffer);
    assert(!buf->ibuf);
+   (void) buf;
 }
 
 static void
index e745f3342d1b345d5b0636efcd71d83603d276c6..89feeade7566ec84fd39a03ea7e31a82d828dcfb 100644 (file)
@@ -45,7 +45,7 @@
  */
 
 
-static boolean
+static void
 i915_draw_range_elements(struct pipe_context *pipe,
                          struct pipe_buffer *indexBuffer,
                          unsigned indexSize,
@@ -84,7 +84,7 @@ i915_draw_range_elements(struct pipe_context *pipe,
    }
 
 
-   draw_set_mapped_constant_buffer(draw,
+   draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX,
                                    i915->current.constants[PIPE_SHADER_VERTEX],
                                    (i915->current.num_user_constants[PIPE_SHADER_VERTEX] * 
                                       4 * sizeof(float)));
@@ -106,27 +106,25 @@ i915_draw_range_elements(struct pipe_context *pipe,
       pipe_buffer_unmap(pipe->screen, indexBuffer);
       draw_set_mapped_element_buffer_range(draw, 0, start, start + count - 1, NULL);
    }
-
-   return TRUE;
 }
 
-static boolean
+static void
 i915_draw_elements(struct pipe_context *pipe,
                    struct pipe_buffer *indexBuffer,
                    unsigned indexSize,
                    unsigned prim, unsigned start, unsigned count)
 {
-   return i915_draw_range_elements(pipe, indexBuffer,
-                                   indexSize,
-                                   0, 0xffffffff,
-                                   prim, start, count);
+   i915_draw_range_elements(pipe, indexBuffer,
+                            indexSize,
+                            0, 0xffffffff,
+                            prim, start, count);
 }
 
-static boolean
+static void
 i915_draw_arrays(struct pipe_context *pipe,
                  unsigned prim, unsigned start, unsigned count)
 {
-   return i915_draw_elements(pipe, NULL, 0, prim, start, count);
+   i915_draw_elements(pipe, NULL, 0, prim, start, count);
 }
 
 
@@ -155,15 +153,11 @@ static unsigned int
 i915_is_buffer_referenced(struct pipe_context *pipe,
                           struct pipe_buffer *buf)
 {
-   /**
-    * FIXME: Return the corrent result. We can't alays return referenced
-    *        since it causes a double flush within the vbo module.
+   /*
+    * Since we never expose hardware buffers to the state tracker
+    * they can never be referenced, so this isn't a lie
     */
-#if 0
-   return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-#else
    return 0;
-#endif
 }
 
 
index ce92d1af9a7cb75966249b8888169cc63440933d..c6e6d6fd3137446b124b5006c1977368237efe3f 100644 (file)
@@ -851,6 +851,7 @@ static boolean i915_debug_packet( struct debug_stream *stream )
       default:
         return debug(stream, "", 0);
       }
+      break;
    default:
       assert(0);
       return 0;
@@ -880,7 +881,7 @@ i915_dump_batchbuffer( struct intel_batchbuffer *batch )
       return;
    }
    
-   debug_printf( "\n\nBATCH: (%d)\n", bytes / 4);
+   debug_printf( "\n\nBATCH: (%d)\n", (int)bytes / 4);
 
    while (!done &&
          stream.offset < bytes)
index 89504ced2767e2cdec13f5e68259a4b8457244e8..25c53210be8eb2552440c4e1c74575459b2e2c62 100644 (file)
@@ -127,7 +127,7 @@ i915_program_error(struct i915_fp_compile *p, const char *msg, ...)
    va_start( args, msg );  
    util_vsnprintf( buffer, sizeof(buffer), msg, args );
    va_end( args );
-   debug_printf(buffer);
+   debug_printf("%s", buffer);
    debug_printf("\n");
 
    p->error = 1;
@@ -143,12 +143,12 @@ static uint
 src_vector(struct i915_fp_compile *p,
            const struct tgsi_full_src_register *source)
 {
-   uint index = source->SrcRegister.Index;
+   uint index = source->Register.Index;
    uint src = 0, sem_name, sem_ind;
 
-   switch (source->SrcRegister.File) {
+   switch (source->Register.File) {
    case TGSI_FILE_TEMPORARY:
-      if (source->SrcRegister.Index >= I915_MAX_TEMPORARY) {
+      if (source->Register.Index >= I915_MAX_TEMPORARY) {
          i915_program_error(p, "Exceeded max temporary reg");
          return 0;
       }
@@ -214,45 +214,26 @@ src_vector(struct i915_fp_compile *p,
       return 0;
    }
 
-   if (source->SrcRegister.Extended) {
-      src = swizzle(src,
-                    source->SrcRegisterExtSwz.ExtSwizzleX,
-                    source->SrcRegisterExtSwz.ExtSwizzleY,
-                    source->SrcRegisterExtSwz.ExtSwizzleZ,
-                    source->SrcRegisterExtSwz.ExtSwizzleW);
-   }
-   else {
-      src = swizzle(src,
-                    source->SrcRegister.SwizzleX,
-                    source->SrcRegister.SwizzleY,
-                    source->SrcRegister.SwizzleZ,
-                    source->SrcRegister.SwizzleW);
-   }
+   src = swizzle(src,
+                source->Register.SwizzleX,
+                source->Register.SwizzleY,
+                source->Register.SwizzleZ,
+                source->Register.SwizzleW);
 
 
    /* There's both negate-all-components and per-component negation.
     * Try to handle both here.
     */
    {
-      int nx = source->SrcRegisterExtSwz.NegateX;
-      int ny = source->SrcRegisterExtSwz.NegateY;
-      int nz = source->SrcRegisterExtSwz.NegateZ;
-      int nw = source->SrcRegisterExtSwz.NegateW;
-      if (source->SrcRegister.Negate) {
-         nx = !nx;
-         ny = !ny;
-         nz = !nz;
-         nw = !nw;
-      }
-      src = negate(src, nx, ny, nz, nw);
+      int n = source->Register.Negate;
+      src = negate(src, n, n, n, n);
    }
 
-   /* no abs() or post-abs negation */
+   /* no abs() */
 #if 0
    /* XXX assertions disabled to allow arbfplight.c to run */
    /* XXX enable these assertions, or fix things */
-   assert(!source->SrcRegisterExtMod.Absolute);
-   assert(!source->SrcRegisterExtMod.Negate);
+   assert(!source->Register.Absolute);
 #endif
    return src;
 }
@@ -265,10 +246,10 @@ static uint
 get_result_vector(struct i915_fp_compile *p,
                   const struct tgsi_full_dst_register *dest)
 {
-   switch (dest->DstRegister.File) {
+   switch (dest->Register.File) {
    case TGSI_FILE_OUTPUT:
       {
-         uint sem_name = p->shader->info.output_semantic_name[dest->DstRegister.Index];
+         uint sem_name = p->shader->info.output_semantic_name[dest->Register.Index];
          switch (sem_name) {
          case TGSI_SEMANTIC_POSITION:
             return UREG(REG_TYPE_OD, 0);
@@ -280,7 +261,7 @@ get_result_vector(struct i915_fp_compile *p,
          }
       }
    case TGSI_FILE_TEMPORARY:
-      return UREG(REG_TYPE_R, dest->DstRegister.Index);
+      return UREG(REG_TYPE_R, dest->Register.Index);
    default:
       i915_program_error(p, "Bad inst->DstReg.File");
       return 0;
@@ -295,7 +276,7 @@ static uint
 get_result_flags(const struct tgsi_full_instruction *inst)
 {
    const uint writeMask
-      = inst->FullDstRegisters[0].DstRegister.WriteMask;
+      = inst->Dst[0].Register.WriteMask;
    uint flags = 0x0;
 
    if (inst->Instruction.Saturate == TGSI_SAT_ZERO_ONE)
@@ -357,14 +338,14 @@ emit_tex(struct i915_fp_compile *p,
          const struct tgsi_full_instruction *inst,
          uint opcode)
 {
-   uint texture = inst->InstructionExtTexture.Texture;
-   uint unit = inst->FullSrcRegisters[1].SrcRegister.Index;
+   uint texture = inst->Texture.Texture;
+   uint unit = inst->Src[1].Register.Index;
    uint tex = translate_tex_src_target( p, texture );
    uint sampler = i915_emit_decl(p, REG_TYPE_S, unit, tex);
-   uint coord = src_vector( p, &inst->FullSrcRegisters[0]);
+   uint coord = src_vector( p, &inst->Src[0]);
 
    i915_emit_texld( p,
-                    get_result_vector( p, &inst->FullDstRegisters[0] ),
+                    get_result_vector( p, &inst->Dst[0] ),
                     get_result_flags( inst ),
                     sampler,
                     coord,
@@ -386,13 +367,13 @@ emit_simple_arith(struct i915_fp_compile *p,
 
    assert(numArgs <= 3);
 
-   arg1 = (numArgs < 1) ? 0 : src_vector( p, &inst->FullSrcRegisters[0] );
-   arg2 = (numArgs < 2) ? 0 : src_vector( p, &inst->FullSrcRegisters[1] );
-   arg3 = (numArgs < 3) ? 0 : src_vector( p, &inst->FullSrcRegisters[2] );
+   arg1 = (numArgs < 1) ? 0 : src_vector( p, &inst->Src[0] );
+   arg2 = (numArgs < 2) ? 0 : src_vector( p, &inst->Src[1] );
+   arg3 = (numArgs < 3) ? 0 : src_vector( p, &inst->Src[2] );
 
    i915_emit_arith( p,
                     opcode,
-                    get_result_vector( p, &inst->FullDstRegisters[0]),
+                    get_result_vector( p, &inst->Dst[0]),
                     get_result_flags( inst ), 0,
                     arg1,
                     arg2,
@@ -412,8 +393,8 @@ emit_simple_arith_swap2(struct i915_fp_compile *p,
 
    /* transpose first two registers */
    inst2 = *inst;
-   inst2.FullSrcRegisters[0] = inst->FullSrcRegisters[1];
-   inst2.FullSrcRegisters[1] = inst->FullSrcRegisters[0];
+   inst2.Src[0] = inst->Src[1];
+   inst2.Src[1] = inst->Src[0];
 
    emit_simple_arith(p, &inst2, opcode, numArgs);
 }
@@ -442,10 +423,10 @@ i915_translate_instruction(struct i915_fp_compile *p,
 
    switch (inst->Instruction.Opcode) {
    case TGSI_OPCODE_ABS:
-      src0 = src_vector(p, &inst->FullSrcRegisters[0]);
+      src0 = src_vector(p, &inst->Src[0]);
       i915_emit_arith(p,
                       A0_MAX,
-                      get_result_vector(p, &inst->FullDstRegisters[0]),
+                      get_result_vector(p, &inst->Dst[0]),
                       get_result_flags(inst), 0,
                       src0, negate(src0, 1, 1, 1, 1), 0);
       break;
@@ -455,17 +436,17 @@ i915_translate_instruction(struct i915_fp_compile *p,
       break;
 
    case TGSI_OPCODE_CMP:
-      src0 = src_vector(p, &inst->FullSrcRegisters[0]);
-      src1 = src_vector(p, &inst->FullSrcRegisters[1]);
-      src2 = src_vector(p, &inst->FullSrcRegisters[2]);
+      src0 = src_vector(p, &inst->Src[0]);
+      src1 = src_vector(p, &inst->Src[1]);
+      src2 = src_vector(p, &inst->Src[2]);
       i915_emit_arith(p, A0_CMP, 
-                      get_result_vector(p, &inst->FullDstRegisters[0]),
+                      get_result_vector(p, &inst->Dst[0]),
                       get_result_flags(inst), 
                       0, src0, src2, src1);   /* NOTE: order of src2, src1 */
       break;
 
    case TGSI_OPCODE_COS:
-      src0 = src_vector(p, &inst->FullSrcRegisters[0]);
+      src0 = src_vector(p, &inst->Src[0]);
       tmp = i915_get_utemp(p);
 
       i915_emit_arith(p,
@@ -508,7 +489,7 @@ i915_translate_instruction(struct i915_fp_compile *p,
 
       i915_emit_arith(p,
                       A0_DP4,
-                      get_result_vector(p, &inst->FullDstRegisters[0]),
+                      get_result_vector(p, &inst->Dst[0]),
                       get_result_flags(inst), 0,
                       swizzle(tmp, ONE, Z, Y, X),
                       i915_emit_const4fv(p, cos_constants), 0);
@@ -523,19 +504,19 @@ i915_translate_instruction(struct i915_fp_compile *p,
       break;
 
    case TGSI_OPCODE_DPH:
-      src0 = src_vector(p, &inst->FullSrcRegisters[0]);
-      src1 = src_vector(p, &inst->FullSrcRegisters[1]);
+      src0 = src_vector(p, &inst->Src[0]);
+      src1 = src_vector(p, &inst->Src[1]);
 
       i915_emit_arith(p,
                       A0_DP4,
-                      get_result_vector(p, &inst->FullDstRegisters[0]),
+                      get_result_vector(p, &inst->Dst[0]),
                       get_result_flags(inst), 0,
                       swizzle(src0, X, Y, Z, ONE), src1, 0);
       break;
 
    case TGSI_OPCODE_DST:
-      src0 = src_vector(p, &inst->FullSrcRegisters[0]);
-      src1 = src_vector(p, &inst->FullSrcRegisters[1]);
+      src0 = src_vector(p, &inst->Src[0]);
+      src1 = src_vector(p, &inst->Src[1]);
 
       /* result[0] = 1    * 1;
        * result[1] = a[1] * b[1];
@@ -544,7 +525,7 @@ i915_translate_instruction(struct i915_fp_compile *p,
        */
       i915_emit_arith(p,
                       A0_MUL,
-                      get_result_vector(p, &inst->FullDstRegisters[0]),
+                      get_result_vector(p, &inst->Dst[0]),
                       get_result_flags(inst), 0,
                       swizzle(src0, ONE, Y, Z, ONE),
                       swizzle(src1, ONE, Y, ONE, W), 0);
@@ -555,11 +536,11 @@ i915_translate_instruction(struct i915_fp_compile *p,
       break;
 
    case TGSI_OPCODE_EX2:
-      src0 = src_vector(p, &inst->FullSrcRegisters[0]);
+      src0 = src_vector(p, &inst->Src[0]);
 
       i915_emit_arith(p,
                       A0_EXP,
-                      get_result_vector(p, &inst->FullDstRegisters[0]),
+                      get_result_vector(p, &inst->Dst[0]),
                       get_result_flags(inst), 0,
                       swizzle(src0, X, X, X, X), 0, 0);
       break;
@@ -574,7 +555,7 @@ i915_translate_instruction(struct i915_fp_compile *p,
 
    case TGSI_OPCODE_KIL:
       /* kill if src[0].x < 0 || src[0].y < 0 ... */
-      src0 = src_vector(p, &inst->FullSrcRegisters[0]);
+      src0 = src_vector(p, &inst->Src[0]);
       tmp = i915_get_utemp(p);
 
       i915_emit_texld(p,
@@ -590,17 +571,17 @@ i915_translate_instruction(struct i915_fp_compile *p,
       break;
 
    case TGSI_OPCODE_LG2:
-      src0 = src_vector(p, &inst->FullSrcRegisters[0]);
+      src0 = src_vector(p, &inst->Src[0]);
 
       i915_emit_arith(p,
                       A0_LOG,
-                      get_result_vector(p, &inst->FullDstRegisters[0]),
+                      get_result_vector(p, &inst->Dst[0]),
                       get_result_flags(inst), 0,
                       swizzle(src0, X, X, X, X), 0, 0);
       break;
 
    case TGSI_OPCODE_LIT:
-      src0 = src_vector(p, &inst->FullSrcRegisters[0]);
+      src0 = src_vector(p, &inst->Src[0]);
       tmp = i915_get_utemp(p);
 
       /* tmp = max( a.xyzw, a.00zw )
@@ -624,7 +605,7 @@ i915_translate_instruction(struct i915_fp_compile *p,
                       swizzle(tmp, Y, Y, Y, Y), 0, 0);
 
       i915_emit_arith(p, A0_CMP,
-                      get_result_vector(p, &inst->FullDstRegisters[0]),
+                      get_result_vector(p, &inst->Dst[0]),
                       get_result_flags(inst), 0,
                       negate(swizzle(tmp, ONE, ONE, X, ONE), 0, 0, 1, 0),
                       swizzle(tmp, ONE, X, ZERO, ONE),
@@ -633,9 +614,9 @@ i915_translate_instruction(struct i915_fp_compile *p,
       break;
 
    case TGSI_OPCODE_LRP:
-      src0 = src_vector(p, &inst->FullSrcRegisters[0]);
-      src1 = src_vector(p, &inst->FullSrcRegisters[1]);
-      src2 = src_vector(p, &inst->FullSrcRegisters[2]);
+      src0 = src_vector(p, &inst->Src[0]);
+      src1 = src_vector(p, &inst->Src[1]);
+      src2 = src_vector(p, &inst->Src[2]);
       flags = get_result_flags(inst);
       tmp = i915_get_utemp(p);
 
@@ -650,7 +631,7 @@ i915_translate_instruction(struct i915_fp_compile *p,
                       flags & A0_DEST_CHANNEL_ALL, 0, src1, src0, src2);
 
       i915_emit_arith(p, A0_MAD,
-                      get_result_vector(p, &inst->FullDstRegisters[0]),
+                      get_result_vector(p, &inst->Dst[0]),
                       flags, 0, negate(src2, 1, 1, 1, 1), src0, tmp);
       break;
 
@@ -663,8 +644,8 @@ i915_translate_instruction(struct i915_fp_compile *p,
       break;
 
    case TGSI_OPCODE_MIN:
-      src0 = src_vector(p, &inst->FullSrcRegisters[0]);
-      src1 = src_vector(p, &inst->FullSrcRegisters[1]);
+      src0 = src_vector(p, &inst->Src[0]);
+      src1 = src_vector(p, &inst->Src[1]);
       tmp = i915_get_utemp(p);
       flags = get_result_flags(inst);
 
@@ -676,12 +657,11 @@ i915_translate_instruction(struct i915_fp_compile *p,
 
       i915_emit_arith(p,
                       A0_MOV,
-                      get_result_vector(p, &inst->FullDstRegisters[0]),
+                      get_result_vector(p, &inst->Dst[0]),
                       flags, 0, negate(tmp, 1, 1, 1, 1), 0, 0);
       break;
 
    case TGSI_OPCODE_MOV:
-   case TGSI_OPCODE_SWZ:
       emit_simple_arith(p, inst, A0_MOV, 1);
       break;
 
@@ -690,8 +670,8 @@ i915_translate_instruction(struct i915_fp_compile *p,
       break;
 
    case TGSI_OPCODE_POW:
-      src0 = src_vector(p, &inst->FullSrcRegisters[0]);
-      src1 = src_vector(p, &inst->FullSrcRegisters[1]);
+      src0 = src_vector(p, &inst->Src[0]);
+      src1 = src_vector(p, &inst->Src[1]);
       tmp = i915_get_utemp(p);
       flags = get_result_flags(inst);
 
@@ -706,7 +686,7 @@ i915_translate_instruction(struct i915_fp_compile *p,
 
       i915_emit_arith(p,
                       A0_EXP,
-                      get_result_vector(p, &inst->FullDstRegisters[0]),
+                      get_result_vector(p, &inst->Dst[0]),
                       flags, 0, swizzle(tmp, X, X, X, X), 0, 0);
       break;
       
@@ -715,27 +695,27 @@ i915_translate_instruction(struct i915_fp_compile *p,
       break;
       
    case TGSI_OPCODE_RCP:
-      src0 = src_vector(p, &inst->FullSrcRegisters[0]);
+      src0 = src_vector(p, &inst->Src[0]);
 
       i915_emit_arith(p,
                       A0_RCP,
-                      get_result_vector(p, &inst->FullDstRegisters[0]),
+                      get_result_vector(p, &inst->Dst[0]),
                          get_result_flags(inst), 0,
                       swizzle(src0, X, X, X, X), 0, 0);
       break;
 
    case TGSI_OPCODE_RSQ:
-      src0 = src_vector(p, &inst->FullSrcRegisters[0]);
+      src0 = src_vector(p, &inst->Src[0]);
 
       i915_emit_arith(p,
                       A0_RSQ,
-                      get_result_vector(p, &inst->FullDstRegisters[0]),
+                      get_result_vector(p, &inst->Dst[0]),
                       get_result_flags(inst), 0,
                       swizzle(src0, X, X, X, X), 0, 0);
       break;
 
    case TGSI_OPCODE_SCS:
-      src0 = src_vector(p, &inst->FullSrcRegisters[0]);
+      src0 = src_vector(p, &inst->Src[0]);
       tmp = i915_get_utemp(p);
 
       /* 
@@ -758,7 +738,7 @@ i915_translate_instruction(struct i915_fp_compile *p,
                       swizzle(tmp, X, Y, X, Y),
                       swizzle(tmp, X, X, ONE, ONE), 0);
 
-      writemask = inst->FullDstRegisters[0].DstRegister.WriteMask;
+      writemask = inst->Dst[0].Register.WriteMask;
 
       if (writemask & TGSI_WRITEMASK_Y) {
          uint tmp1;
@@ -776,7 +756,7 @@ i915_translate_instruction(struct i915_fp_compile *p,
 
          i915_emit_arith(p,
                          A0_DP4,
-                         get_result_vector(p, &inst->FullDstRegisters[0]),
+                         get_result_vector(p, &inst->Dst[0]),
                          A0_DEST_CHANNEL_Y, 0,
                          swizzle(tmp1, W, Z, Y, X),
                          i915_emit_const4fv(p, sin_constants), 0);
@@ -791,7 +771,7 @@ i915_translate_instruction(struct i915_fp_compile *p,
 
          i915_emit_arith(p,
                          A0_DP4,
-                         get_result_vector(p, &inst->FullDstRegisters[0]),
+                         get_result_vector(p, &inst->Dst[0]),
                          A0_DEST_CHANNEL_X, 0,
                          swizzle(tmp, ONE, Z, Y, X),
                          i915_emit_const4fv(p, cos_constants), 0);
@@ -808,7 +788,7 @@ i915_translate_instruction(struct i915_fp_compile *p,
       break;
 
    case TGSI_OPCODE_SIN:
-      src0 = src_vector(p, &inst->FullSrcRegisters[0]);
+      src0 = src_vector(p, &inst->Src[0]);
       tmp = i915_get_utemp(p);
 
       i915_emit_arith(p,
@@ -851,7 +831,7 @@ i915_translate_instruction(struct i915_fp_compile *p,
 
       i915_emit_arith(p,
                       A0_DP4,
-                      get_result_vector(p, &inst->FullDstRegisters[0]),
+                      get_result_vector(p, &inst->Dst[0]),
                       get_result_flags(inst), 0,
                       swizzle(tmp, W, Z, Y, X),
                       i915_emit_const4fv(p, sin_constants), 0);
@@ -867,12 +847,12 @@ i915_translate_instruction(struct i915_fp_compile *p,
       break;
 
    case TGSI_OPCODE_SUB:
-      src0 = src_vector(p, &inst->FullSrcRegisters[0]);
-      src1 = src_vector(p, &inst->FullSrcRegisters[1]);
+      src0 = src_vector(p, &inst->Src[0]);
+      src1 = src_vector(p, &inst->Src[1]);
 
       i915_emit_arith(p,
                       A0_ADD,
-                      get_result_vector(p, &inst->FullDstRegisters[0]),
+                      get_result_vector(p, &inst->Dst[0]),
                       get_result_flags(inst), 0,
                       src0, negate(src1, 1, 1, 1, 1), 0);
       break;
@@ -896,8 +876,8 @@ i915_translate_instruction(struct i915_fp_compile *p,
        *      result.z = src0.x * src1.y - src0.y * src1.x;
        *      result.w = undef;
        */
-      src0 = src_vector(p, &inst->FullSrcRegisters[0]);
-      src1 = src_vector(p, &inst->FullSrcRegisters[1]);
+      src0 = src_vector(p, &inst->Src[0]);
+      src1 = src_vector(p, &inst->Src[1]);
       tmp = i915_get_utemp(p);
 
       i915_emit_arith(p,
@@ -908,7 +888,7 @@ i915_translate_instruction(struct i915_fp_compile *p,
 
       i915_emit_arith(p,
                       A0_MAD,
-                      get_result_vector(p, &inst->FullDstRegisters[0]),
+                      get_result_vector(p, &inst->Dst[0]),
                       get_result_flags(inst), 0,
                       swizzle(src0, Y, Z, X, ONE),
                       swizzle(src1, Z, X, Y, ONE),
@@ -948,8 +928,8 @@ i915_translate_instructions(struct i915_fp_compile *p,
          if (parse.FullToken.FullDeclaration.Declaration.File
                   == TGSI_FILE_CONSTANT) {
             uint i;
-            for (i = parse.FullToken.FullDeclaration.DeclarationRange.First;
-                 i <= parse.FullToken.FullDeclaration.DeclarationRange.Last;
+            for (i = parse.FullToken.FullDeclaration.Range.First;
+                 i <= parse.FullToken.FullDeclaration.Range.Last;
                  i++) {
                assert(ifs->constant_flags[i] == 0x0);
                ifs->constant_flags[i] = I915_CONSTFLAG_USER;
@@ -959,8 +939,8 @@ i915_translate_instructions(struct i915_fp_compile *p,
          else if (parse.FullToken.FullDeclaration.Declaration.File
                   == TGSI_FILE_TEMPORARY) {
             uint i;
-            for (i = parse.FullToken.FullDeclaration.DeclarationRange.First;
-                 i <= parse.FullToken.FullDeclaration.DeclarationRange.Last;
+            for (i = parse.FullToken.FullDeclaration.Range.First;
+                 i <= parse.FullToken.FullDeclaration.Range.Last;
                  i++) {
                assert(i < I915_MAX_TEMPORARY);
                /* XXX just use shader->info->file_mask[TGSI_FILE_TEMPORARY] */
index c66558c320eb0f87a7e989a7fe527b9772a4f7b8..d4ee8f5339bd8d1d1d274dfcdfbc3035066be871 100644 (file)
@@ -271,6 +271,7 @@ i915_create_screen(struct intel_winsys *iws, uint pci_id)
    default:
       debug_printf("%s: unknown pci id 0x%x, cannot create screen\n", 
                    __FUNCTION__, pci_id);
+      FREE(is);
       return NULL;
    }
 
index 7d48e6e84d58a00c795d9699db05e43ce3d31fdc..5f5b6f8e1855684bf278fdf50fe01991e0df0516 100644 (file)
@@ -58,8 +58,10 @@ translate_wrap_mode(unsigned wrap)
       return TEXCOORDMODE_CLAMP_EDGE;
    case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
       return TEXCOORDMODE_CLAMP_BORDER;
-//   case PIPE_TEX_WRAP_MIRRORED_REPEAT:
-//      return TEXCOORDMODE_MIRROR;
+   /*         
+   case PIPE_TEX_WRAP_MIRRORED_REPEAT:
+      return TEXCOORDMODE_MIRROR;
+    */
    default:
       return TEXCOORDMODE_WRAP;
    }
@@ -72,8 +74,6 @@ static unsigned translate_img_filter( unsigned filter )
       return FILTER_NEAREST;
    case PIPE_TEX_FILTER_LINEAR:
       return FILTER_LINEAR;
-   case PIPE_TEX_FILTER_ANISO:
-      return FILTER_ANISOTROPIC;
    default:
       assert(0);
       return FILTER_NEAREST;
@@ -219,6 +219,9 @@ i915_create_sampler_state(struct pipe_context *pipe,
    minFilt = translate_img_filter( sampler->min_img_filter );
    magFilt = translate_img_filter( sampler->mag_img_filter );
    
+   if (sampler->max_anisotropy > 1.0)
+      minFilt = magFilt = FILTER_ANISOTROPIC;
+
    if (sampler->max_anisotropy > 2.0) {
       cso->state[0] |= SS2_MAX_ANISO_4;
    }
@@ -750,22 +753,15 @@ static void i915_set_vertex_elements(struct pipe_context *pipe,
 }
 
 
-static void i915_set_edgeflags(struct pipe_context *pipe,
-                               const unsigned *bitfield)
-{
-   /* TODO do something here */
-}
-
 void
 i915_init_state_functions( struct i915_context *i915 )
 {
-   i915->base.set_edgeflags = i915_set_edgeflags;
    i915->base.create_blend_state = i915_create_blend_state;
    i915->base.bind_blend_state = i915_bind_blend_state;
    i915->base.delete_blend_state = i915_delete_blend_state;
 
    i915->base.create_sampler_state = i915_create_sampler_state;
-   i915->base.bind_sampler_states = i915_bind_sampler_states;
+   i915->base.bind_fragment_sampler_states = i915_bind_sampler_states;
    i915->base.delete_sampler_state = i915_delete_sampler_state;
 
    i915->base.create_depth_stencil_alpha_state = i915_create_depth_stencil_state;
@@ -789,7 +785,7 @@ i915_init_state_functions( struct i915_context *i915 )
 
    i915->base.set_polygon_stipple = i915_set_polygon_stipple;
    i915->base.set_scissor_state = i915_set_scissor_state;
-   i915->base.set_sampler_textures = i915_set_sampler_textures;
+   i915->base.set_fragment_sampler_textures = i915_set_sampler_textures;
    i915->base.set_viewport_state = i915_set_viewport_state;
    i915->base.set_vertex_buffers = i915_set_vertex_buffers;
    i915->base.set_vertex_elements = i915_set_vertex_elements;
index 178d4e8781d7b261add57e9a39240efc033df5a1..03dd5091a611ba63de9eed9779ffabfff85e6e86 100644 (file)
@@ -84,7 +84,7 @@ static void calculate_vertex_layout( struct i915_context *i915 )
 
    
    /* pos */
-   src = draw_find_vs_output(i915->draw, TGSI_SEMANTIC_POSITION, 0);
+   src = draw_find_shader_output(i915->draw, TGSI_SEMANTIC_POSITION, 0);
    if (needW) {
       draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_LINEAR, src);
       vinfo.hwfmt[0] |= S4_VFMT_XYZW;
@@ -101,21 +101,21 @@ static void calculate_vertex_layout( struct i915_context *i915 )
 
    /* primary color */
    if (colors[0]) {
-      src = draw_find_vs_output(i915->draw, TGSI_SEMANTIC_COLOR, 0);
+      src = draw_find_shader_output(i915->draw, TGSI_SEMANTIC_COLOR, 0);
       draw_emit_vertex_attr(&vinfo, EMIT_4UB, colorInterp, src);
       vinfo.hwfmt[0] |= S4_VFMT_COLOR;
    }
 
    /* secondary color */
    if (colors[1]) {
-      src = draw_find_vs_output(i915->draw, TGSI_SEMANTIC_COLOR, 1);
+      src = draw_find_shader_output(i915->draw, TGSI_SEMANTIC_COLOR, 1);
       draw_emit_vertex_attr(&vinfo, EMIT_4UB, colorInterp, src);
       vinfo.hwfmt[0] |= S4_VFMT_SPEC_FOG;
    }
 
    /* fog coord, not fog blend factor */
    if (fog) {
-      src = draw_find_vs_output(i915->draw, TGSI_SEMANTIC_FOG, 0);
+      src = draw_find_shader_output(i915->draw, TGSI_SEMANTIC_FOG, 0);
       draw_emit_vertex_attr(&vinfo, EMIT_1F, INTERP_PERSPECTIVE, src);
       vinfo.hwfmt[0] |= S4_VFMT_FOG_PARAM;
    }
@@ -125,7 +125,7 @@ static void calculate_vertex_layout( struct i915_context *i915 )
       uint hwtc;
       if (texCoords[i]) {
          hwtc = TEXCOORDFMT_4D;
-         src = draw_find_vs_output(i915->draw, TGSI_SEMANTIC_GENERIC, i);
+         src = draw_find_shader_output(i915->draw, TGSI_SEMANTIC_GENERIC, i);
          draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_PERSPECTIVE, src);
       }
       else {
index c5e9084d12e7072f4902164ff24001e73cad1649..cbac4175c8f78fb5652718cc3a630771aa9b3eb3 100644 (file)
@@ -231,7 +231,7 @@ i915_update_texture(struct i915_context *i915,
 {
    const struct pipe_texture *pt = &tex->base;
    uint format, pitch;
-   const uint width = pt->width[0], height = pt->height[0], depth = pt->depth[0];
+   const uint width = pt->width0, height = pt->height0, depth = pt->depth0;
    const uint num_levels = pt->last_level;
    unsigned max_lod = num_levels * 4;
    unsigned tiled = MS3_USE_FENCE_REGS;
index ab8331f3e64a276d372b0a9254a501bcc54531f2..c693eb30e87e3a1e9dcde7b1a4b06a1aa815204a 100644 (file)
@@ -32,6 +32,7 @@
 #include "pipe/p_inlines.h"
 #include "pipe/p_inlines.h"
 #include "pipe/internal/p_winsys_screen.h"
+#include "util/u_format.h"
 #include "util/u_tile.h"
 #include "util/u_rect.h"
 
@@ -48,17 +49,19 @@ i915_surface_copy(struct pipe_context *pipe,
 {
    struct i915_texture *dst_tex = (struct i915_texture *)dst->texture;
    struct i915_texture *src_tex = (struct i915_texture *)src->texture;
+   struct pipe_texture *dpt = &dst_tex->base;
+   struct pipe_texture *spt = &src_tex->base;
 
    assert( dst != src );
-   assert( dst_tex->base.block.size == src_tex->base.block.size );
-   assert( dst_tex->base.block.width == src_tex->base.block.height );
-   assert( dst_tex->base.block.height == src_tex->base.block.height );
-   assert( dst_tex->base.block.width == 1 );
-   assert( dst_tex->base.block.height == 1 );
+   assert( util_format_get_blocksize(dpt->format) == util_format_get_blocksize(spt->format) );
+   assert( util_format_get_blockwidth(dpt->format) == util_format_get_blockwidth(spt->format) );
+   assert( util_format_get_blockheight(dpt->format) == util_format_get_blockheight(spt->format) );
+   assert( util_format_get_blockwidth(dpt->format) == 1 );
+   assert( util_format_get_blockheight(dpt->format) == 1 );
 
    i915_copy_blit( i915_context(pipe),
                    FALSE,
-                   dst_tex->base.block.size,
+                   util_format_get_blocksize(dpt->format),
                    (unsigned short) src_tex->stride, src_tex->buffer, src->offset,
                    (unsigned short) dst_tex->stride, dst_tex->buffer, dst->offset,
                    (short) srcx, (short) srcy, (short) dstx, (short) dsty, (short) width, (short) height );
@@ -72,12 +75,13 @@ i915_surface_fill(struct pipe_context *pipe,
                  unsigned width, unsigned height, unsigned value)
 {
    struct i915_texture *tex = (struct i915_texture *)dst->texture;
+   struct pipe_texture *pt = &tex->base;
 
-   assert(tex->base.block.width == 1);
-   assert(tex->base.block.height == 1);
+   assert(util_format_get_blockwidth(pt->format) == 1);
+   assert(util_format_get_blockheight(pt->format) == 1);
 
    i915_fill_blit( i915_context(pipe),
-                   tex->base.block.size,
+                   util_format_get_blocksize(pt->format),
                    (unsigned short) tex->stride,
                    tex->buffer, dst->offset,
                    (short) dstx, (short) dsty,
index 286c9ace8e5736a2ab161eca5dbb2a7be936b913..50a9e19094b8906ca1fe96f2d2f208368f1e1f9b 100644 (file)
@@ -35,6 +35,7 @@
 #include "pipe/p_defines.h"
 #include "pipe/p_inlines.h"
 #include "pipe/internal/p_winsys_screen.h"
+#include "util/u_format.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
 
@@ -74,6 +75,9 @@ static const int step_offsets[6][2] = {
    {-1, 1}
 };
 
+/* XXX really need twice the size if x is already pot?
+   Otherwise just use util_next_power_of_two?
+*/
 static unsigned
 power_of_two(unsigned x)
 {
@@ -83,13 +87,6 @@ power_of_two(unsigned x)
    return value;
 }
 
-static unsigned
-round_up(unsigned n, unsigned multiple)
-{
-   return (n + multiple - 1) & ~(multiple - 1);
-}
-
-
 /*
  * More advanced helper funcs
  */
@@ -101,17 +98,8 @@ i915_miptree_set_level_info(struct i915_texture *tex,
                              unsigned nr_images,
                              unsigned w, unsigned h, unsigned d)
 {
-   struct pipe_texture *pt = &tex->base;
-
    assert(level < PIPE_MAX_TEXTURE_LEVELS);
 
-   pt->width[level] = w;
-   pt->height[level] = h;
-   pt->depth[level] = d;
-   
-   pt->nblocksx[level] = pf_get_nblocksx(&pt->block, w);
-   pt->nblocksy[level] = pf_get_nblocksy(&pt->block, h);
-
    tex->nr_images[level] = nr_images;
 
    /*
@@ -142,7 +130,7 @@ i915_miptree_set_image_offset(struct i915_texture *tex,
 
    assert(img < tex->nr_images[level]);
 
-   tex->image_offset[level][img] = y * tex->stride + x * tex->base.block.size;
+   tex->image_offset[level][img] = y * tex->stride + x * util_format_get_blocksize(tex->base.format);
 
    /*
    printf("%s level %d img %d pos %d,%d image_offset %x\n",
@@ -164,28 +152,28 @@ i915_scanout_layout(struct i915_texture *tex)
 {
    struct pipe_texture *pt = &tex->base;
 
-   if (pt->last_level > 0 || pt->block.size != 4)
+   if (pt->last_level > 0 || util_format_get_blocksize(pt->format) != 4)
       return FALSE;
 
    i915_miptree_set_level_info(tex, 0, 1,
-                               tex->base.width[0],
-                               tex->base.height[0],
+                               pt->width0,
+                               pt->height0,
                                1);
    i915_miptree_set_image_offset(tex, 0, 0, 0, 0);
 
-   if (tex->base.width[0] >= 240) {
-      tex->stride = power_of_two(tex->base.nblocksx[0] * pt->block.size);
-      tex->total_nblocksy = round_up(tex->base.nblocksy[0], 8);
+   if (pt->width0 >= 240) {
+      tex->stride = power_of_two(util_format_get_stride(pt->format, pt->width0));
+      tex->total_nblocksy = align(util_format_get_nblocksy(pt->format, pt->height0), 8);
       tex->hw_tiled = INTEL_TILE_X;
-   } else if (tex->base.width[0] == 64 && tex->base.height[0] == 64) {
-      tex->stride = power_of_two(tex->base.nblocksx[0] * pt->block.size);
-      tex->total_nblocksy = round_up(tex->base.nblocksy[0], 8);
+   } else if (pt->width0 == 64 && pt->height0 == 64) {
+      tex->stride = power_of_two(util_format_get_stride(pt->format, pt->width0));
+      tex->total_nblocksy = align(util_format_get_nblocksy(pt->format, pt->height0), 8);
    } else {
       return FALSE;
    }
 
    debug_printf("%s size: %d,%d,%d offset %d,%d (0x%x)\n", __FUNCTION__,
-      tex->base.width[0], tex->base.height[0], pt->block.size,
+      pt->width0, pt->height0, util_format_get_blocksize(pt->format),
       tex->stride, tex->total_nblocksy, tex->stride * tex->total_nblocksy);
 
    return TRUE;
@@ -199,25 +187,25 @@ i915_display_target_layout(struct i915_texture *tex)
 {
    struct pipe_texture *pt = &tex->base;
 
-   if (pt->last_level > 0 || pt->block.size != 4)
+   if (pt->last_level > 0 || util_format_get_blocksize(pt->format) != 4)
       return FALSE;
 
    /* fallback to normal textures for small textures */
-   if (tex->base.width[0] < 240)
+   if (pt->width0 < 240)
       return FALSE;
 
    i915_miptree_set_level_info(tex, 0, 1,
-                               tex->base.width[0],
-                               tex->base.height[0],
+                               pt->width0,
+                               pt->height0,
                                1);
    i915_miptree_set_image_offset(tex, 0, 0, 0, 0);
 
-   tex->stride = power_of_two(tex->base.nblocksx[0] * pt->block.size);
-   tex->total_nblocksy = round_up(tex->base.nblocksy[0], 8);
+   tex->stride = power_of_two(util_format_get_stride(pt->format, pt->width0));
+   tex->total_nblocksy = align(util_format_get_nblocksy(pt->format, pt->height0), 8);
    tex->hw_tiled = INTEL_TILE_X;
 
    debug_printf("%s size: %d,%d,%d offset %d,%d (0x%x)\n", __FUNCTION__,
-      tex->base.width[0], tex->base.height[0], pt->block.size,
+      pt->width0, pt->height0, util_format_get_blocksize(pt->format),
       tex->stride, tex->total_nblocksy, tex->stride * tex->total_nblocksy);
 
    return TRUE;
@@ -228,36 +216,34 @@ i915_miptree_layout_2d(struct i915_texture *tex)
 {
    struct pipe_texture *pt = &tex->base;
    unsigned level;
-   unsigned width = pt->width[0];
-   unsigned height = pt->height[0];
-   unsigned nblocksx = pt->nblocksx[0];
-   unsigned nblocksy = pt->nblocksy[0];
+   unsigned width = pt->width0;
+   unsigned height = pt->height0;
+   unsigned nblocksy = util_format_get_nblocksy(pt->format, pt->width0);
 
    /* used for scanouts that need special layouts */
-   if (tex->base.tex_usage & PIPE_TEXTURE_USAGE_PRIMARY)
+   if (pt->tex_usage & PIPE_TEXTURE_USAGE_PRIMARY)
       if (i915_scanout_layout(tex))
          return;
 
    /* for shared buffers we use some very like scanout */
-   if (tex->base.tex_usage & PIPE_TEXTURE_USAGE_DISPLAY_TARGET)
+   if (pt->tex_usage & PIPE_TEXTURE_USAGE_DISPLAY_TARGET)
       if (i915_display_target_layout(tex))
          return;
 
-   tex->stride = round_up(pt->nblocksx[0] * pt->block.size, 4);
+   tex->stride = align(util_format_get_stride(pt->format, pt->width0), 4);
    tex->total_nblocksy = 0;
 
    for (level = 0; level <= pt->last_level; level++) {
       i915_miptree_set_level_info(tex, level, 1, width, height, 1);
       i915_miptree_set_image_offset(tex, level, 0, 0, tex->total_nblocksy);
 
-      nblocksy = round_up(MAX2(2, nblocksy), 2);
+      nblocksy = align(MAX2(2, nblocksy), 2);
 
       tex->total_nblocksy += nblocksy;
 
-      width = minify(width);
-      height = minify(height);
-      nblocksx = pf_get_nblocksx(&pt->block, width);
-      nblocksy = pf_get_nblocksy(&pt->block, height);
+      width = u_minify(width, 1);
+      height = u_minify(height, 1);
+      nblocksy = util_format_get_nblocksy(pt->format, height);
    }
 }
 
@@ -267,16 +253,15 @@ i915_miptree_layout_3d(struct i915_texture *tex)
    struct pipe_texture *pt = &tex->base;
    unsigned level;
 
-   unsigned width = pt->width[0];
-   unsigned height = pt->height[0];
-   unsigned depth = pt->depth[0];
-   unsigned nblocksx = pt->nblocksx[0];
-   unsigned nblocksy = pt->nblocksy[0];
+   unsigned width = pt->width0;
+   unsigned height = pt->height0;
+   unsigned depth = pt->depth0;
+   unsigned nblocksy = util_format_get_nblocksy(pt->format, pt->height0);
    unsigned stack_nblocksy = 0;
 
    /* Calculate the size of a single slice. 
     */
-   tex->stride = round_up(pt->nblocksx[0] * pt->block.size, 4);
+   tex->stride = align(util_format_get_stride(pt->format, pt->width0), 4);
 
    /* XXX: hardware expects/requires 9 levels at minimum.
     */
@@ -285,44 +270,41 @@ i915_miptree_layout_3d(struct i915_texture *tex)
 
       stack_nblocksy += MAX2(2, nblocksy);
 
-      width = minify(width);
-      height = minify(height);
-      depth = minify(depth);
-      nblocksx = pf_get_nblocksx(&pt->block, width);
-      nblocksy = pf_get_nblocksy(&pt->block, height);
+      width = u_minify(width, 1);
+      height = u_minify(height, 1);
+      nblocksy = util_format_get_nblocksy(pt->format, height);
    }
 
    /* Fixup depth image_offsets: 
     */
-   depth = pt->depth[0];
    for (level = 0; level <= pt->last_level; level++) {
       unsigned i;
       for (i = 0; i < depth; i++) 
          i915_miptree_set_image_offset(tex, level, i, 0, i * stack_nblocksy);
 
-      depth = minify(depth);
+      depth = u_minify(depth, 1);
    }
 
    /* Multiply slice size by texture depth for total size.  It's
     * remarkable how wasteful of memory the i915 texture layouts
     * are.  They are largely fixed in the i945.
     */
-   tex->total_nblocksy = stack_nblocksy * pt->depth[0];
+   tex->total_nblocksy = stack_nblocksy * pt->depth0;
 }
 
 static void
 i915_miptree_layout_cube(struct i915_texture *tex)
 {
    struct pipe_texture *pt = &tex->base;
-   unsigned width = pt->width[0], height = pt->height[0];
-   const unsigned nblocks = pt->nblocksx[0];
+   unsigned width = pt->width0, height = pt->height0;
+   const unsigned nblocks = util_format_get_nblocksx(pt->format, pt->width0);
    unsigned level;
    unsigned face;
 
    assert(width == height); /* cubemap images are square */
 
    /* double pitch for cube layouts */
-   tex->stride = round_up(nblocks * pt->block.size * 2, 4);
+   tex->stride = align(nblocks * util_format_get_blocksize(pt->format) * 2, 4);
    tex->total_nblocksy = nblocks * 4;
 
    for (level = 0; level <= pt->last_level; level++) {
@@ -383,10 +365,10 @@ i945_miptree_layout_2d(struct i915_texture *tex)
    unsigned level;
    unsigned x = 0;
    unsigned y = 0;
-   unsigned width = pt->width[0];
-   unsigned height = pt->height[0];
-   unsigned nblocksx = pt->nblocksx[0];
-   unsigned nblocksy = pt->nblocksy[0];
+   unsigned width = pt->width0;
+   unsigned height = pt->height0;
+   unsigned nblocksx = util_format_get_nblocksx(pt->format, pt->width0);
+   unsigned nblocksy = util_format_get_nblocksy(pt->format, pt->height0);
 
    /* used for scanouts that need special layouts */
    if (tex->base.tex_usage & PIPE_TEXTURE_USAGE_PRIMARY)
@@ -398,7 +380,7 @@ i945_miptree_layout_2d(struct i915_texture *tex)
       if (i915_display_target_layout(tex))
          return;
 
-   tex->stride = round_up(pt->nblocksx[0] * pt->block.size, 4);
+   tex->stride = align(util_format_get_stride(pt->format, pt->width0), 4);
 
    /* May need to adjust pitch to accomodate the placement of
     * the 2nd mipmap level.  This occurs when the alignment
@@ -407,11 +389,11 @@ i945_miptree_layout_2d(struct i915_texture *tex)
     */
    if (pt->last_level > 0) {
       unsigned mip1_nblocksx 
-         = align(pf_get_nblocksx(&pt->block, minify(width)), align_x)
-         + pf_get_nblocksx(&pt->block, minify(minify(width)));
+         = align(util_format_get_nblocksx(pt->format, u_minify(width, 1)), align_x)
+         + util_format_get_nblocksx(pt->format, u_minify(width, 2));
 
       if (mip1_nblocksx > nblocksx)
-         tex->stride = mip1_nblocksx * pt->block.size;
+         tex->stride = mip1_nblocksx * util_format_get_blocksize(pt->format);
    }
 
    /* Pitch must be a whole number of dwords
@@ -439,10 +421,10 @@ i945_miptree_layout_2d(struct i915_texture *tex)
          y += nblocksy;
       }
 
-      width  = minify(width);
-      height = minify(height);
-      nblocksx = pf_get_nblocksx(&pt->block, width);
-      nblocksy = pf_get_nblocksy(&pt->block, height);
+      width  = u_minify(width, 1);
+      height = u_minify(height, 1);
+      nblocksx = util_format_get_nblocksx(pt->format, width);
+      nblocksy = util_format_get_nblocksy(pt->format, height);
    }
 }
 
@@ -450,20 +432,19 @@ static void
 i945_miptree_layout_3d(struct i915_texture *tex)
 {
    struct pipe_texture *pt = &tex->base;
-   unsigned width = pt->width[0];
-   unsigned height = pt->height[0];
-   unsigned depth = pt->depth[0];
-   unsigned nblocksx = pt->nblocksx[0];
-   unsigned nblocksy = pt->nblocksy[0];
+   unsigned width = pt->width0;
+   unsigned height = pt->height0;
+   unsigned depth = pt->depth0;
+   unsigned nblocksy = util_format_get_nblocksy(pt->format, pt->width0);
    unsigned pack_x_pitch, pack_x_nr;
    unsigned pack_y_pitch;
    unsigned level;
 
-   tex->stride = round_up(pt->nblocksx[0] * pt->block.size, 4);
+   tex->stride = align(util_format_get_stride(pt->format, pt->width0), 4);
    tex->total_nblocksy = 0;
 
-   pack_y_pitch = MAX2(pt->nblocksy[0], 2);
-   pack_x_pitch = tex->stride / pt->block.size;
+   pack_y_pitch = MAX2(nblocksy, 2);
+   pack_x_pitch = tex->stride / util_format_get_blocksize(pt->format);
    pack_x_nr = 1;
 
    for (level = 0; level <= pt->last_level; level++) {
@@ -488,18 +469,17 @@ i945_miptree_layout_3d(struct i915_texture *tex)
       if (pack_x_pitch > 4) {
          pack_x_pitch >>= 1;
          pack_x_nr <<= 1;
-         assert(pack_x_pitch * pack_x_nr * pt->block.size <= tex->stride);
+         assert(pack_x_pitch * pack_x_nr * util_format_get_blocksize(pt->format) <= tex->stride);
       }
 
       if (pack_y_pitch > 2) {
          pack_y_pitch >>= 1;
       }
 
-      width = minify(width);
-      height = minify(height);
-      depth = minify(depth);
-      nblocksx = pf_get_nblocksx(&pt->block, width);
-      nblocksy = pf_get_nblocksy(&pt->block, height);
+      width = u_minify(width, 1);
+      height = u_minify(height, 1);
+      depth = u_minify(depth, 1);
+      nblocksy = util_format_get_nblocksy(pt->format, height);
    }
 }
 
@@ -509,13 +489,13 @@ i945_miptree_layout_cube(struct i915_texture *tex)
    struct pipe_texture *pt = &tex->base;
    unsigned level;
 
-   const unsigned nblocks = pt->nblocksx[0];
+   const unsigned nblocks = util_format_get_nblocksx(pt->format, pt->width0);
    unsigned face;
-   unsigned width = pt->width[0];
-   unsigned height = pt->height[0];
+   unsigned width = pt->width0;
+   unsigned height = pt->height0;
 
    /*
-   printf("%s %i, %i\n", __FUNCTION__, pt->width[0], pt->height[0]);
+   printf("%s %i, %i\n", __FUNCTION__, pt->width0, pt->height0);
    */
 
    assert(width == height); /* cubemap images are square */
@@ -529,9 +509,9 @@ i945_miptree_layout_cube(struct i915_texture *tex)
     * or the final row of 4x4, 2x2 and 1x1 faces below this.
     */
    if (nblocks > 32)
-      tex->stride = round_up(nblocks * pt->block.size * 2, 4);
+      tex->stride = align(nblocks * util_format_get_blocksize(pt->format) * 2, 4);
    else
-      tex->stride = 14 * 8 * pt->block.size;
+      tex->stride = 14 * 8 * util_format_get_blocksize(pt->format);
 
    tex->total_nblocksy = nblocks * 4;
 
@@ -651,9 +631,6 @@ i915_texture_create(struct pipe_screen *screen,
    pipe_reference_init(&tex->base.reference, 1);
    tex->base.screen = screen;
 
-   tex->base.nblocksx[0] = pf_get_nblocksx(&tex->base.block, tex->base.width[0]);
-   tex->base.nblocksy[0] = pf_get_nblocksy(&tex->base.block, tex->base.height[0]);
-   
    if (is->is_i945) {
       if (!i945_miptree_layout(tex))
          goto fail;
@@ -667,7 +644,7 @@ i915_texture_create(struct pipe_screen *screen,
 
 
    /* for scanouts and cursors, cursors arn't scanouts */
-   if (templat->tex_usage & PIPE_TEXTURE_USAGE_PRIMARY && templat->width[0] != 64)
+   if (templat->tex_usage & PIPE_TEXTURE_USAGE_PRIMARY && templat->width0 != 64)
       buf_usage = INTEL_NEW_SCANOUT;
    else
       buf_usage = INTEL_NEW_TEXTURE;
@@ -710,7 +687,7 @@ i915_texture_blanket(struct pipe_screen * screen,
    /* Only supports one type */
    if (base->target != PIPE_TEXTURE_2D ||
        base->last_level != 0 ||
-       base->depth[0] != 1) {
+       base->depth0 != 1) {
       return NULL;
    }
 
@@ -724,7 +701,7 @@ i915_texture_blanket(struct pipe_screen * screen,
 
    tex->stride = stride[0];
 
-   i915_miptree_set_level_info(tex, 0, 1, base->width[0], base->height[0], 1);
+   i915_miptree_set_level_info(tex, 0, 1, base->width0, base->height0, 1);
    i915_miptree_set_image_offset(tex, 0, 0, 0, 0);
 
    pipe_buffer_reference(&tex->buffer, buffer);
@@ -788,8 +765,8 @@ i915_get_tex_surface(struct pipe_screen *screen,
       pipe_reference_init(&ps->reference, 1);
       pipe_texture_reference(&ps->texture, pt);
       ps->format = pt->format;
-      ps->width = pt->width[level];
-      ps->height = pt->height[level];
+      ps->width = u_minify(pt->width0, level);
+      ps->height = u_minify(pt->height0, level);
       ps->offset = offset;
       ps->usage = flags;
    }
@@ -835,14 +812,10 @@ i915_get_tex_transfer(struct pipe_screen *screen,
    trans = CALLOC_STRUCT(i915_transfer);
    if (trans) {
       pipe_texture_reference(&trans->base.texture, texture);
-      trans->base.format = trans->base.format;
       trans->base.x = x;
       trans->base.y = y;
       trans->base.width = w;
       trans->base.height = h;
-      trans->base.block = texture->block;
-      trans->base.nblocksx = texture->nblocksx[level];
-      trans->base.nblocksy = texture->nblocksy[level];
       trans->base.stride = tex->stride;
       trans->offset = offset;
       trans->base.usage = usage;
@@ -858,6 +831,7 @@ i915_transfer_map(struct pipe_screen *screen,
    struct intel_winsys *iws = i915_screen(tex->base.screen)->iws;
    char *map;
    boolean write = FALSE;
+   enum pipe_format format = tex->base.format;
 
    if (transfer->usage & PIPE_TRANSFER_WRITE)
       write = TRUE;
@@ -867,8 +841,8 @@ i915_transfer_map(struct pipe_screen *screen,
       return NULL;
 
    return map + i915_transfer(transfer)->offset +
-      transfer->y / transfer->block.height * transfer->stride +
-      transfer->x / transfer->block.width * transfer->block.size;
+      transfer->y / util_format_get_blockheight(format) * transfer->stride +
+      transfer->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
 }
 
 static void
@@ -919,7 +893,7 @@ i915_texture_blanket_intel(struct pipe_screen *screen,
    /* Only supports one type */
    if (base->target != PIPE_TEXTURE_2D ||
        base->last_level != 0 ||
-       base->depth[0] != 1) {
+       base->depth0 != 1) {
       return NULL;
    }
 
@@ -933,7 +907,7 @@ i915_texture_blanket_intel(struct pipe_screen *screen,
 
    tex->stride = stride;
 
-   i915_miptree_set_level_info(tex, 0, 1, base->width[0], base->height[0], 1);
+   i915_miptree_set_level_info(tex, 0, 1, base->width0, base->height0, 1);
    i915_miptree_set_image_offset(tex, 0, 0, 0, 0);
 
    tex->buffer = buffer;
index 2c8dc63f3f961dab159ee43d7bb8971c2e1a3133..c6bf6e6f7f1a90834010d15b14aaf14b3dd3e6e9 100644 (file)
@@ -42,21 +42,21 @@ enum intel_buffer_usage
    INTEL_USAGE_2D_TARGET = 0x04,
    INTEL_USAGE_2D_SOURCE = 0x08,
    /* use on vertex */
-   INTEL_USAGE_VERTEX    = 0x10,
+   INTEL_USAGE_VERTEX    = 0x10
 };
 
 enum intel_buffer_type
 {
    INTEL_NEW_TEXTURE,
    INTEL_NEW_SCANOUT, /**< a texture used for scanning out from */
-   INTEL_NEW_VERTEX,
+   INTEL_NEW_VERTEX
 };
 
 enum intel_buffer_tile
 {
    INTEL_TILE_NONE,
    INTEL_TILE_X,
-   INTEL_TILE_Y,
+   INTEL_TILE_Y
 };
 
 struct intel_batchbuffer {
diff --git a/src/gallium/drivers/i965/Makefile b/src/gallium/drivers/i965/Makefile
new file mode 100644 (file)
index 0000000..95fd3cd
--- /dev/null
@@ -0,0 +1,74 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+LIBNAME = i965
+
+C_SOURCES = \
+       brw_cc.c \
+       brw_clip.c \
+       brw_clip_line.c \
+       brw_clip_point.c \
+       brw_clip_state.c \
+       brw_clip_tri.c \
+       brw_clip_unfilled.c \
+       brw_clip_util.c \
+       brw_context.c \
+       brw_curbe.c \
+       brw_disasm.c \
+       brw_draw.c \
+       brw_draw_upload.c \
+       brw_eu.c \
+       brw_eu_debug.c \
+       brw_eu_emit.c \
+       brw_eu_util.c \
+       brw_gs.c \
+       brw_gs_emit.c \
+       brw_gs_state.c \
+       brw_misc_state.c \
+       brw_pipe_blend.c \
+       brw_pipe_depth.c \
+       brw_pipe_fb.c \
+       brw_pipe_query.c \
+       brw_pipe_shader.c \
+       brw_pipe_flush.c \
+       brw_pipe_misc.c \
+       brw_pipe_sampler.c \
+       brw_pipe_vertex.c \
+       brw_pipe_clear.c \
+       brw_pipe_rast.c \
+       brw_sf.c \
+       brw_sf_emit.c \
+       brw_sf_state.c \
+       brw_state_batch.c \
+       brw_state_debug.c \
+       brw_state_cache.c \
+       brw_state_upload.c \
+       brw_structs_dump.c \
+       brw_swtnl.c \
+       brw_urb.c \
+       brw_util.c \
+       brw_vs.c \
+       brw_vs_emit.c \
+       brw_vs_state.c \
+       brw_vs_surface_state.c \
+       brw_wm.c \
+       brw_wm_debug.c \
+       brw_wm_emit.c \
+       brw_wm_fp.c \
+       brw_wm_iz.c \
+       brw_wm_pass0.c \
+       brw_wm_pass1.c \
+       brw_wm_pass2.c \
+       brw_wm_sampler_state.c \
+       brw_wm_state.c \
+       brw_wm_surface_state.c \
+       brw_screen.c \
+       brw_screen_buffers.c \
+       brw_screen_tex_layout.c \
+       brw_screen_texture.c \
+       brw_screen_surface.c \
+       brw_batchbuffer.c \
+       brw_winsys_debug.c \
+       intel_decode.c
+
+include ../../Makefile.template
diff --git a/src/gallium/drivers/i965/SConscript b/src/gallium/drivers/i965/SConscript
new file mode 100644 (file)
index 0000000..9c2faaf
--- /dev/null
@@ -0,0 +1,77 @@
+Import('*')
+
+env = env.Clone()
+
+i965 = env.ConvenienceLibrary(
+       target = 'i965',
+       source = [
+               'brw_batchbuffer.c',
+               'brw_cc.c',
+               'brw_clip.c',
+               'brw_clip_line.c',
+               'brw_clip_point.c',
+               'brw_clip_state.c',
+               'brw_clip_tri.c',
+               'brw_clip_unfilled.c',
+               'brw_clip_util.c',
+               'brw_context.c',
+               'brw_curbe.c',
+               'brw_disasm.c',
+               'brw_draw.c',
+               'brw_draw_upload.c',
+               'brw_eu.c',
+               'brw_eu_debug.c',
+               'brw_eu_emit.c',
+               'brw_eu_util.c',
+               'brw_gs.c',
+               'brw_gs_emit.c',
+               'brw_gs_state.c',
+               'brw_misc_state.c',
+               'brw_pipe_blend.c',
+               'brw_pipe_clear.c',
+               'brw_pipe_depth.c',
+               'brw_pipe_fb.c',
+               'brw_pipe_flush.c',
+               'brw_pipe_misc.c',
+               'brw_pipe_query.c',
+               'brw_pipe_rast.c',
+               'brw_pipe_sampler.c',
+               'brw_pipe_shader.c',
+               'brw_pipe_vertex.c',
+               'brw_screen_buffers.c',
+               'brw_screen.c',
+               'brw_screen_surface.c',
+               'brw_screen_tex_layout.c',
+               'brw_screen_texture.c',
+               'brw_structs_dump.c',
+               'brw_sf.c',
+               'brw_sf_emit.c',
+               'brw_sf_state.c',
+               'brw_state_batch.c',
+               'brw_state_cache.c',
+#              'brw_state_debug.c',
+               'brw_state_upload.c',
+               'brw_swtnl.c',
+               'brw_urb.c',
+               'brw_util.c',
+               'brw_vs.c',
+               'brw_vs_emit.c',
+               'brw_vs_state.c',
+               'brw_vs_surface_state.c',
+               'brw_wm.c',
+#              'brw_wm_constant_buffer.c',
+               'brw_wm_debug.c',
+               'brw_wm_emit.c',
+               'brw_wm_fp.c',
+#              'brw_wm_glsl.c',
+               'brw_wm_iz.c',
+               'brw_wm_pass0.c',
+               'brw_wm_pass1.c',
+               'brw_wm_pass2.c',
+               'brw_wm_sampler_state.c',
+               'brw_wm_state.c',
+               'brw_wm_surface_state.c',
+               'intel_decode.c',
+       ])
+
+Export('i965')
diff --git a/src/gallium/drivers/i965/brw_batchbuffer.c b/src/gallium/drivers/i965/brw_batchbuffer.c
new file mode 100644 (file)
index 0000000..22607dc
--- /dev/null
@@ -0,0 +1,202 @@
+/**************************************************************************
+ * 
+ * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 
+ **************************************************************************/
+
+#include "util/u_memory.h"
+
+#include "brw_batchbuffer.h"
+#include "brw_reg.h"
+#include "brw_winsys.h"
+#include "brw_debug.h"
+#include "brw_structs.h"
+
+#define ALWAYS_EMIT_MI_FLUSH 1
+
+enum pipe_error
+brw_batchbuffer_reset(struct brw_batchbuffer *batch)
+{
+   enum pipe_error ret;
+
+   ret = batch->sws->bo_alloc( batch->sws,
+                               BRW_BUFFER_TYPE_BATCH,
+                               BRW_BATCH_SIZE, 4096,
+                               &batch->buf );
+   if (ret)
+      return ret;
+
+   batch->size = BRW_BATCH_SIZE;
+
+   /* With map_range semantics, the winsys can decide whether to
+    * inject a malloc'ed bounce buffer instead of mapping directly.
+    */
+   batch->map = batch->sws->bo_map(batch->buf,
+                                   BRW_DATA_BATCH_BUFFER,
+                                   0, batch->size,
+                                   GL_TRUE,
+                                   GL_TRUE,
+                                   GL_TRUE);
+
+   batch->ptr = batch->map;
+   return PIPE_OK;
+}
+
+struct brw_batchbuffer *
+brw_batchbuffer_alloc(struct brw_winsys_screen *sws,
+                      struct brw_chipset chipset)
+{
+   struct brw_batchbuffer *batch = CALLOC_STRUCT(brw_batchbuffer);
+
+   batch->sws = sws;
+   batch->chipset = chipset;
+   brw_batchbuffer_reset(batch);
+
+   return batch;
+}
+
+void
+brw_batchbuffer_free(struct brw_batchbuffer *batch)
+{
+   if (batch->map) {
+      batch->sws->bo_unmap(batch->buf);
+      batch->map = NULL;
+   }
+
+   bo_reference(&batch->buf, NULL);
+   FREE(batch);
+}
+
+
+void
+_brw_batchbuffer_flush(struct brw_batchbuffer *batch, 
+                      const char *file,
+                      int line)
+{
+   GLuint used = batch->ptr - batch->map;
+
+   if (used == 0)
+      return;
+
+   /* Post-swap throttling done by the state tracker.
+    */
+
+   if (BRW_DEBUG & DEBUG_BATCH)
+      debug_printf("%s:%d: Batchbuffer flush with %db used\n", 
+                  file, line, used);
+
+   if (ALWAYS_EMIT_MI_FLUSH) {
+      *(GLuint *) (batch->ptr) = MI_FLUSH | BRW_FLUSH_STATE_CACHE;
+      batch->ptr += 4;
+      used = batch->ptr - batch->map;
+   }
+
+   /* Round batchbuffer usage to 2 DWORDs. 
+    */
+   if ((used & 4) == 0) {
+      *(GLuint *) (batch->ptr) = 0; /* noop */
+      batch->ptr += 4;
+      used = batch->ptr - batch->map;
+   }
+
+   /* Mark the end of the buffer. 
+    */
+   *(GLuint *) (batch->ptr) = MI_BATCH_BUFFER_END;
+   batch->ptr += 4;
+   used = batch->ptr - batch->map;
+
+   batch->sws->bo_flush_range(batch->buf, 0, used);
+   batch->sws->bo_unmap(batch->buf);
+   batch->map = NULL;
+   batch->ptr = NULL;
+      
+   batch->sws->bo_exec(batch->buf, used );
+
+   if (BRW_DEBUG & DEBUG_SYNC) {
+      /* Abuse map/unmap to achieve wait-for-fence.
+       *
+       * XXX: hide this inside the winsys and export a fence
+       * interface.
+       */
+      debug_printf("waiting for idle\n");
+      batch->sws->bo_wait_idle(batch->buf);
+   }
+
+   /* Reset the buffer:
+    */
+   brw_batchbuffer_reset(batch);
+}
+
+
+/* The OUT_RELOC() macro ends up here, generating a relocation within
+ * the batch buffer.
+ */
+enum pipe_error
+brw_batchbuffer_emit_reloc(struct brw_batchbuffer *batch,
+                          struct brw_winsys_buffer *buffer,
+                          uint32_t usage,
+                          uint32_t delta)
+{
+   int ret;
+
+   if (batch->ptr - batch->map > batch->buf->size) {
+      debug_printf("bad relocation ptr %p map %p offset %d size %d\n",
+                  batch->ptr, batch->map, batch->ptr - batch->map, batch->buf->size);
+
+      return PIPE_ERROR_OUT_OF_MEMORY;
+   }
+
+   ret = batch->sws->bo_emit_reloc(batch->buf,
+                                  usage,
+                                  delta, 
+                                  batch->ptr - batch->map,
+                                  buffer);
+   if (ret != 0)
+      return ret;
+
+   /* bo_emit_reloc was resposible for writing a zero into the
+    * batchbuffer if necessary.  Just need to update our pointer.
+    */
+   batch->ptr += 4;
+
+   return 0;
+}
+
+enum pipe_error
+brw_batchbuffer_data(struct brw_batchbuffer *batch,
+                       const void *data, GLuint bytes,
+                      enum cliprect_mode cliprect_mode)
+{
+   enum pipe_error ret;
+
+   assert((bytes & 3) == 0);
+
+   ret = brw_batchbuffer_require_space(batch, bytes);
+   if (ret)
+      return ret;
+
+   memcpy(batch->ptr, data, bytes);
+   batch->ptr += bytes;
+   return 0;
+}
diff --git a/src/gallium/drivers/i965/brw_batchbuffer.h b/src/gallium/drivers/i965/brw_batchbuffer.h
new file mode 100644 (file)
index 0000000..7473f5b
--- /dev/null
@@ -0,0 +1,148 @@
+#ifndef BRW_BATCHBUFFER_H
+#define BRW_BATCHBUFFER_H
+
+#include "util/u_debug.h"
+
+#include "brw_types.h"
+#include "brw_winsys.h"
+#include "brw_reg.h"
+
+#define BATCH_SZ 16384
+#define BATCH_RESERVED 16
+
+/* All ignored:
+ */
+enum cliprect_mode {
+   IGNORE_CLIPRECTS,
+   LOOP_CLIPRECTS,
+   NO_LOOP_CLIPRECTS,
+   REFERENCES_CLIPRECTS
+};
+
+
+
+
+struct brw_batchbuffer {
+
+   struct brw_winsys_screen *sws;
+   struct brw_winsys_buffer *buf;
+   struct brw_chipset chipset;
+
+   /**
+    * Values exported to speed up the writing the batchbuffer,
+    * instead of having to go trough a accesor function for
+    * each dword written.
+    */
+   /*{@*/
+   uint8_t *map;
+   uint8_t *ptr;
+   size_t size;
+   struct {
+      uint8_t *end_ptr;
+   } emit;
+
+
+   size_t relocs;
+   size_t max_relocs;
+   /*@}*/
+};
+
+struct brw_batchbuffer *brw_batchbuffer_alloc( struct brw_winsys_screen *sws,
+                                               struct brw_chipset chipset );
+
+void brw_batchbuffer_free(struct brw_batchbuffer *batch);
+
+void _brw_batchbuffer_flush(struct brw_batchbuffer *batch,
+                             const char *file, int line);
+
+
+enum pipe_error
+brw_batchbuffer_reset(struct brw_batchbuffer *batch);
+
+
+/* Unlike bmBufferData, this currently requires the buffer be mapped.
+ * Consider it a convenience function wrapping multple
+ * intel_buffer_dword() calls.
+ */
+int brw_batchbuffer_data(struct brw_batchbuffer *batch,
+                            const void *data, GLuint bytes,
+                           enum cliprect_mode cliprect_mode);
+
+
+int brw_batchbuffer_emit_reloc(struct brw_batchbuffer *batch,
+                              struct brw_winsys_buffer *buffer,
+                              enum brw_buffer_usage usage,
+                              uint32_t offset);
+
+/* Inline functions - might actually be better off with these
+ * non-inlined.  Certainly better off switching all command packets to
+ * be passed as structs rather than dwords, but that's a little bit of
+ * work...
+ */
+static INLINE GLint
+brw_batchbuffer_space(struct brw_batchbuffer *batch)
+{
+   return (batch->size - BATCH_RESERVED) - (batch->ptr - batch->map);
+}
+
+
+static INLINE void
+brw_batchbuffer_emit_dword(struct brw_batchbuffer *batch, GLuint dword)
+{
+   assert(batch->map);
+   assert(brw_batchbuffer_space(batch) >= 4);
+   *(GLuint *) (batch->ptr) = dword;
+   batch->ptr += 4;
+}
+
+static INLINE enum pipe_error
+brw_batchbuffer_require_space(struct brw_batchbuffer *batch,
+                                GLuint sz)
+{
+   assert(sz < batch->size - 8);
+   if (brw_batchbuffer_space(batch) < sz) {
+      assert(0);
+      return PIPE_ERROR_OUT_OF_MEMORY;
+   }
+#ifdef DEBUG
+   batch->emit.end_ptr = batch->ptr + sz;
+#endif
+   return 0;
+}
+
+/* Here are the crusty old macros, to be removed:
+ */
+#define BEGIN_BATCH(n, cliprect_mode) do {                             \
+      brw_batchbuffer_require_space(brw->batch, (n)*4);                        \
+   } while (0)
+
+#define OUT_BATCH(d) brw_batchbuffer_emit_dword(brw->batch, d)
+
+#define OUT_RELOC(buf, usage, delta) do {                              \
+      assert((unsigned) (delta) < buf->size);                          \
+      brw_batchbuffer_emit_reloc(brw->batch, buf,                      \
+                                usage, delta);                         \
+   } while (0)
+
+#ifdef DEBUG
+#define ADVANCE_BATCH() do {                                           \
+      unsigned int _n = brw->batch->ptr - brw->batch->emit.end_ptr;    \
+      if (_n != 0) {                                                   \
+        debug_printf("%s: %d too many bytes emitted to batch\n",       \
+                     __FUNCTION__, _n);                                \
+        abort();                                                       \
+      }                                                                        \
+      brw->batch->emit.end_ptr = NULL;                                 \
+   } while(0)
+#else
+#define ADVANCE_BATCH()
+#endif
+
+static INLINE void
+brw_batchbuffer_emit_mi_flush(struct brw_batchbuffer *batch)
+{
+   brw_batchbuffer_require_space(batch, 4);
+   brw_batchbuffer_emit_dword(batch, MI_FLUSH);
+}
+
+#endif
diff --git a/src/gallium/drivers/i965/brw_cc.c b/src/gallium/drivers/i965/brw_cc.c
new file mode 100644 (file)
index 0000000..3e070f5
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ Copyright (C) Intel Corp.  2006.  All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ **********************************************************************/
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  */
+
+
+#include "brw_context.h"
+#include "brw_state.h"
+#include "brw_defines.h"
+
+
+static enum pipe_error prepare_cc_vp( struct brw_context *brw )
+{
+   return brw_cache_data( &brw->cache, 
+                         BRW_CC_VP,
+                         &brw->curr.ccv,
+                         NULL, 0,
+                         &brw->cc.reloc[CC_RELOC_VP].bo );
+}
+
+const struct brw_tracked_state brw_cc_vp = {
+   .dirty = {
+      .mesa = PIPE_NEW_VIEWPORT,
+      .brw = BRW_NEW_CONTEXT,
+      .cache = 0
+   },
+   .prepare = prepare_cc_vp
+};
+
+
+/* A long-winded way to OR two unsigned integers together:
+ */
+static INLINE struct brw_cc3
+combine_cc3( struct brw_cc3 a, struct brw_cc3 b )
+{
+   union { struct brw_cc3 cc3; unsigned i; } ca, cb;
+   ca.cc3 = a;
+   cb.cc3 = b;
+   ca.i |= cb.i;
+   return ca.cc3;
+}
+
+
+static int prepare_cc_unit( struct brw_context *brw )
+{
+   brw->cc.cc.cc0 = brw->curr.zstencil->cc0;
+   brw->cc.cc.cc1 = brw->curr.zstencil->cc1;
+   brw->cc.cc.cc2 = brw->curr.zstencil->cc2;
+   brw->cc.cc.cc3 = combine_cc3( brw->curr.zstencil->cc3, brw->curr.blend->cc3 );
+   
+   brw->cc.cc.cc5 = brw->curr.blend->cc5;
+   brw->cc.cc.cc6 = brw->curr.blend->cc6;
+   brw->cc.cc.cc7 = brw->curr.zstencil->cc7;
+
+   return brw_cache_data_sz(&brw->cache, BRW_CC_UNIT,
+                           &brw->cc.cc, sizeof(brw->cc.cc),
+                           brw->cc.reloc, 1,
+                           &brw->cc.state_bo);
+}
+
+const struct brw_tracked_state brw_cc_unit = {
+   .dirty = {
+      .mesa = PIPE_NEW_DEPTH_STENCIL_ALPHA | PIPE_NEW_BLEND,
+      .brw = 0,
+      .cache = CACHE_NEW_CC_VP
+   },
+   .prepare = prepare_cc_unit,
+};
+
+
+void brw_hw_cc_init( struct brw_context *brw )
+{
+   make_reloc(&brw->cc.reloc[0],
+              BRW_USAGE_STATE,
+              0,
+              offsetof(struct brw_cc_unit_state, cc4),
+              NULL);
+}
+
+
+void brw_hw_cc_cleanup( struct brw_context *brw )
+{
+   bo_reference(&brw->cc.state_bo, NULL);
+   bo_reference(&brw->cc.reloc[0].bo, NULL);
+}
diff --git a/src/gallium/drivers/i965/brw_clip.c b/src/gallium/drivers/i965/brw_clip.c
new file mode 100644 (file)
index 0000000..d67a1a6
--- /dev/null
@@ -0,0 +1,224 @@
+/*
+ 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 "pipe/p_state.h"
+
+#include "util/u_math.h"
+
+#include "brw_screen.h"
+#include "brw_batchbuffer.h"
+#include "brw_defines.h"
+#include "brw_context.h"
+#include "brw_eu.h"
+#include "brw_util.h"
+#include "brw_state.h"
+#include "brw_pipe_rast.h"
+#include "brw_clip.h"
+
+
+#define FRONT_UNFILLED_BIT  0x1
+#define BACK_UNFILLED_BIT   0x2
+
+
+static enum pipe_error
+compile_clip_prog( struct brw_context *brw,
+                   struct brw_clip_prog_key *key,
+                   struct brw_winsys_buffer **bo_out )
+{
+   enum pipe_error ret;
+   struct brw_clip_compile c;
+   const GLuint *program;
+   GLuint program_size;
+   GLuint delta;
+
+   memset(&c, 0, sizeof(c));
+   
+   /* Begin the compilation:
+    */
+   brw_init_compile(brw, &c.func);
+
+   c.func.single_program_flow = 1;
+
+   c.chipset = brw->chipset;
+   c.key = *key;
+   c.need_ff_sync = c.chipset.is_igdng;
+
+   /* Need to locate the two positions present in vertex + header.
+    * These are currently hardcoded:
+    */
+   c.header_position_offset = ATTR_SIZE;
+
+   if (c.chipset.is_igdng)
+       delta = 3 * REG_SIZE;
+   else
+       delta = REG_SIZE;
+
+   c.offset_hpos = delta + c.key.output_hpos * ATTR_SIZE;
+
+   if (c.key.output_color0 != BRW_OUTPUT_NOT_PRESENT)
+      c.offset_color0 = delta + c.key.output_color0 * ATTR_SIZE;
+
+   if (c.key.output_color1 != BRW_OUTPUT_NOT_PRESENT)
+      c.offset_color1 = delta + c.key.output_color1 * ATTR_SIZE;
+
+   if (c.key.output_bfc0 != BRW_OUTPUT_NOT_PRESENT)
+      c.offset_bfc0 = delta + c.key.output_bfc0 * ATTR_SIZE;
+
+   if (c.key.output_bfc1 != BRW_OUTPUT_NOT_PRESENT)
+      c.offset_bfc1 = delta + c.key.output_bfc1 * ATTR_SIZE;
+
+   if (c.key.output_edgeflag != BRW_OUTPUT_NOT_PRESENT)
+      c.offset_edgeflag = delta + c.key.output_edgeflag * ATTR_SIZE;
+   
+   if (BRW_IS_IGDNG(brw))
+       c.nr_regs = (c.key.nr_attrs + 1) / 2 + 3;  /* are vertices packed, or reg-aligned? */
+   else
+       c.nr_regs = (c.key.nr_attrs + 1) / 2 + 1;  /* are vertices packed, or reg-aligned? */
+
+   c.nr_bytes = c.nr_regs * REG_SIZE;
+
+   c.prog_data.clip_mode = c.key.clip_mode; /* XXX */
+
+   /* For some reason the thread is spawned with only 4 channels
+    * unmasked.  
+    */
+   brw_set_mask_control(&c.func, BRW_MASK_DISABLE);
+
+
+   /* Would ideally have the option of producing a program which could
+    * do all three:
+    */
+   switch (key->primitive) {
+   case PIPE_PRIM_TRIANGLES: 
+      if (key->do_unfilled)
+        brw_emit_unfilled_clip( &c );
+      else
+        brw_emit_tri_clip( &c );
+      break;
+   case PIPE_PRIM_LINES:
+      brw_emit_line_clip( &c );
+      break;
+   case PIPE_PRIM_POINTS:
+      brw_emit_point_clip( &c );
+      break;
+   default:
+      assert(0);
+      return PIPE_ERROR_BAD_INPUT;
+   }
+
+        
+
+   /* get the program
+    */
+   ret = brw_get_program(&c.func, &program, &program_size);
+   if (ret)
+      return ret;
+
+   /* Upload
+    */
+   ret = brw_upload_cache( &brw->cache,
+                           BRW_CLIP_PROG,
+                           &c.key, sizeof(c.key),
+                           NULL, 0,
+                           program, program_size,
+                           &c.prog_data,
+                           &brw->clip.prog_data,
+                           bo_out );
+   if (ret)
+      return ret;
+
+   return PIPE_OK;
+}
+
+/* Calculate interpolants for triangle and line rasterization.
+ */
+static enum pipe_error
+upload_clip_prog(struct brw_context *brw)
+{
+   const struct brw_vertex_shader *vs = brw->curr.vertex_shader;
+   struct brw_clip_prog_key key;
+   enum pipe_error ret;
+
+   /* Populate the key, starting from the almost-complete version from
+    * the rast state. 
+    */
+
+   /* PIPE_NEW_RAST */
+   key = brw->curr.rast->clip_key;
+   
+   /* BRW_NEW_REDUCED_PRIMITIVE */
+   key.primitive = brw->reduced_primitive;
+
+   /* XXX: if edgeflag is moved to a proper TGSI vs output, can remove
+    * dependency on CACHE_NEW_VS_PROG
+    */
+   /* CACHE_NEW_VS_PROG */
+   key.nr_attrs        = brw->vs.prog_data->nr_outputs;
+
+   /* PIPE_NEW_VS */
+   key.output_hpos     = vs->output_hpos;
+   key.output_color0   = vs->output_color0;
+   key.output_color1   = vs->output_color1;
+   key.output_bfc0     = vs->output_bfc0;
+   key.output_bfc1     = vs->output_bfc1;
+   key.output_edgeflag = vs->output_edgeflag;
+
+   /* PIPE_NEW_CLIP */
+   key.nr_userclip = brw->curr.ucp.nr;
+
+   /* Already cached?
+    */
+   if (brw_search_cache(&brw->cache, BRW_CLIP_PROG,
+                        &key, sizeof(key),
+                        NULL, 0,
+                        &brw->clip.prog_data,
+                        &brw->clip.prog_bo))
+      return PIPE_OK;
+
+   /* Compile new program:
+    */
+   ret = compile_clip_prog( brw, &key, &brw->clip.prog_bo );
+   if (ret)
+      return ret;
+
+   return PIPE_OK;
+}
+
+
+const struct brw_tracked_state brw_clip_prog = {
+   .dirty = {
+      .mesa  = (PIPE_NEW_RAST | 
+               PIPE_NEW_CLIP),
+      .brw   = (BRW_NEW_REDUCED_PRIMITIVE),
+      .cache = CACHE_NEW_VS_PROG
+   },
+   .prepare = upload_clip_prog
+};
diff --git a/src/gallium/drivers/i965/brw_clip.h b/src/gallium/drivers/i965/brw_clip.h
new file mode 100644 (file)
index 0000000..80e3a11
--- /dev/null
@@ -0,0 +1,199 @@
+/*
+ Copyright (C) Intel Corp.  2006.  All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ **********************************************************************/
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  */
+
+#ifndef BRW_CLIP_H
+#define BRW_CLIP_H
+
+#include "pipe/p_state.h"
+#include "brw_reg.h"
+#include "brw_eu.h"
+
+#define MAX_VERTS (3+6+6)      
+
+/* Note that if unfilled primitives are being emitted, we have to fix
+ * up polygon offset and flatshading at this point:
+ */
+struct brw_clip_prog_key {
+   GLuint nr_attrs:6;
+   GLuint primitive:4;
+   GLuint nr_userclip:3;
+   GLuint do_flat_shading:1;
+   GLuint do_unfilled:1;
+   GLuint fill_cw:2;           /* includes cull information */
+   GLuint fill_ccw:2;          /* includes cull information */
+   GLuint offset_cw:1;
+   GLuint offset_ccw:1;
+   GLuint copy_bfc_cw:1;
+   GLuint copy_bfc_ccw:1;
+   GLuint clip_mode:3;
+   GLuint output_hpos:6;        /* not always zero? */
+
+   GLuint output_color0:6;
+   GLuint output_color1:6;
+   GLuint output_bfc0:6;
+   GLuint output_bfc1:6;
+   GLuint output_edgeflag:6;
+   GLuint pad1:2;
+   
+   GLfloat offset_factor;
+   GLfloat offset_units;
+};
+
+struct brw_clip_prog_data {
+   GLuint curb_read_length;    /* user planes? */
+   GLuint clip_mode;
+   GLuint urb_read_length;
+   GLuint total_grf;
+};
+
+#define CLIP_LINE   0
+#define CLIP_POINT  1
+#define CLIP_FILL   2
+#define CLIP_CULL   3
+
+
+#define PRIM_MASK  (0x1f)
+
+struct brw_clip_compile {
+   struct brw_compile func;
+   struct brw_clip_prog_key key;
+   struct brw_clip_prog_data prog_data;
+   
+   struct {
+      struct brw_reg R0;
+      struct brw_reg vertex[MAX_VERTS];
+
+      struct brw_reg t;
+      struct brw_reg t0, t1;
+      struct brw_reg dp0, dp1;
+
+      struct brw_reg dpPrev;
+      struct brw_reg dp;
+      struct brw_reg loopcount;
+      struct brw_reg nr_verts;
+      struct brw_reg planemask;
+
+      struct brw_reg inlist;
+      struct brw_reg outlist;
+      struct brw_reg freelist;
+
+      struct brw_reg dir;
+      struct brw_reg tmp0, tmp1;
+      struct brw_reg offset;
+      
+      struct brw_reg fixed_planes;
+      struct brw_reg plane_equation;
+       
+      struct brw_reg ff_sync;
+   } reg;
+
+   /* 3 different ways of expressing vertex size, including
+    * key.nr_attrs.
+    */
+   GLuint nr_regs;
+   GLuint nr_bytes;
+
+   GLuint first_tmp;
+   GLuint last_tmp;
+
+   GLboolean need_direction;
+   struct brw_chipset chipset;
+
+   GLuint last_mrf;
+
+   GLuint header_position_offset;
+   GLboolean need_ff_sync;
+
+   GLuint nr_color_attrs;
+   GLuint offset_color0;
+   GLuint offset_color1;
+   GLuint offset_bfc0;
+   GLuint offset_bfc1;
+
+   GLuint offset_hpos;
+   GLuint offset_edgeflag;
+};
+
+#define ATTR_SIZE  (4*4)
+
+/* Points are only culled, so no need for a clip routine, however it
+ * works out easier to have a dummy one.
+ */
+void brw_emit_unfilled_clip( struct brw_clip_compile *c );
+void brw_emit_tri_clip( struct brw_clip_compile *c );
+void brw_emit_line_clip( struct brw_clip_compile *c );
+void brw_emit_point_clip( struct brw_clip_compile *c );
+
+/* brw_clip_tri.c, for use by the unfilled clip routine:
+ */
+void brw_clip_tri_init_vertices( struct brw_clip_compile *c );
+void brw_clip_tri_flat_shade( struct brw_clip_compile *c );
+void brw_clip_tri( struct brw_clip_compile *c );
+void brw_clip_tri_emit_polygon( struct brw_clip_compile *c );
+void brw_clip_tri_alloc_regs( struct brw_clip_compile *c, 
+                             GLuint nr_verts );
+
+
+/* Utils:
+ */
+
+void brw_clip_interp_vertex( struct brw_clip_compile *c,
+                            struct brw_indirect dest_ptr,
+                            struct brw_indirect v0_ptr, /* from */
+                            struct brw_indirect v1_ptr, /* to */
+                            struct brw_reg t0,
+                            GLboolean force_edgeflag );
+
+void brw_clip_init_planes( struct brw_clip_compile *c );
+
+void brw_clip_emit_vue(struct brw_clip_compile *c, 
+                      struct brw_indirect vert,
+                      GLboolean allocate,
+                      GLboolean eot,
+                      GLuint header);
+
+void brw_clip_kill_thread(struct brw_clip_compile *c);
+
+struct brw_reg brw_clip_plane_stride( struct brw_clip_compile *c );
+struct brw_reg brw_clip_plane0_address( struct brw_clip_compile *c );
+
+void brw_clip_copy_colors( struct brw_clip_compile *c,
+                          GLuint to, GLuint from );
+
+void brw_clip_init_clipmask( struct brw_clip_compile *c );
+
+struct brw_reg get_tmp( struct brw_clip_compile *c );
+
+void brw_clip_project_position(struct brw_clip_compile *c,
+             struct brw_reg pos );
+void brw_clip_ff_sync(struct brw_clip_compile *c);
+void brw_clip_init_ff_sync(struct brw_clip_compile *c);
+#endif
diff --git a/src/gallium/drivers/i965/brw_clip_line.c b/src/gallium/drivers/i965/brw_clip_line.c
new file mode 100644 (file)
index 0000000..54282d9
--- /dev/null
@@ -0,0 +1,271 @@
+/*
+ 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 "util/u_debug.h"
+
+#include "brw_defines.h"
+#include "brw_eu.h"
+#include "brw_util.h"
+#include "brw_clip.h"
+
+
+
+
+static void brw_clip_line_alloc_regs( struct brw_clip_compile *c )
+{
+   GLuint i = 0,j;
+
+   /* Register usage is static, precompute here:
+    */
+   c->reg.R0 = retype(brw_vec8_grf(i, 0), BRW_REGISTER_TYPE_UD); i++;
+
+   if (c->key.nr_userclip) {
+      c->reg.fixed_planes = brw_vec4_grf(i, 0);
+      i += (6 + c->key.nr_userclip + 1) / 2;
+
+      c->prog_data.curb_read_length = (6 + c->key.nr_userclip + 1) / 2;
+   }
+   else
+      c->prog_data.curb_read_length = 0;
+
+
+   /* Payload vertices plus space for more generated vertices:
+    */
+   for (j = 0; j < 4; j++) {
+      c->reg.vertex[j] = brw_vec4_grf(i, 0);
+      i += c->nr_regs;
+   }
+
+   c->reg.t           = brw_vec1_grf(i, 0);
+   c->reg.t0          = brw_vec1_grf(i, 1);
+   c->reg.t1          = brw_vec1_grf(i, 2);
+   c->reg.planemask   = retype(brw_vec1_grf(i, 3), BRW_REGISTER_TYPE_UD);
+   c->reg.plane_equation = brw_vec4_grf(i, 4);
+   i++;
+
+   c->reg.dp0         = brw_vec1_grf(i, 0); /* fixme - dp4 will clobber r.1,2,3 */
+   c->reg.dp1         = brw_vec1_grf(i, 4);
+   i++;
+
+   if (!c->key.nr_userclip) {
+      c->reg.fixed_planes = brw_vec8_grf(i, 0); 
+      i++;
+   }
+
+   if (c->need_ff_sync) {
+      c->reg.ff_sync = retype(brw_vec1_grf(i, 0), BRW_REGISTER_TYPE_UD);
+      i++;
+   }
+
+   c->first_tmp = i;
+   c->last_tmp = i;
+
+   c->prog_data.urb_read_length = c->nr_regs; /* ? */
+   c->prog_data.total_grf = i;
+}
+
+
+
+/* Line clipping, more or less following the following algorithm:
+ *
+ *  for (p=0;p<MAX_PLANES;p++) {
+ *     if (clipmask & (1 << p)) {
+ *        GLfloat dp0 = DOTPROD( vtx0, plane[p] );
+ *        GLfloat dp1 = DOTPROD( vtx1, plane[p] );
+ *
+ *        if (IS_NEGATIVE(dp1)) {
+ *           GLfloat t = dp1 / (dp1 - dp0);
+ *           if (t > t1) t1 = t;
+ *        } else {
+ *           GLfloat t = dp0 / (dp0 - dp1);
+ *           if (t > t0) t0 = t;
+ *        }
+ *  
+ *        if (t0 + t1 >= 1.0)
+ *           return;
+ *     }
+ *  }
+ *
+ *  interp( ctx, newvtx0, vtx0, vtx1, t0 );
+ *  interp( ctx, newvtx1, vtx1, vtx0, t1 );
+ *
+ */
+static void clip_and_emit_line( struct brw_clip_compile *c )
+{
+   struct brw_compile *p = &c->func;
+   struct brw_indirect vtx0     = brw_indirect(0, 0);
+   struct brw_indirect vtx1      = brw_indirect(1, 0);
+   struct brw_indirect newvtx0   = brw_indirect(2, 0);
+   struct brw_indirect newvtx1   = brw_indirect(3, 0);
+   struct brw_indirect plane_ptr = brw_indirect(4, 0);
+   struct brw_instruction *plane_loop;
+   struct brw_instruction *plane_active;
+   struct brw_instruction *is_negative;
+   struct brw_instruction *is_neg2 = NULL;
+   struct brw_instruction *not_culled;
+   struct brw_reg v1_null_ud = retype(vec1(brw_null_reg()), BRW_REGISTER_TYPE_UD);
+
+   brw_MOV(p, get_addr_reg(vtx0),      brw_address(c->reg.vertex[0]));
+   brw_MOV(p, get_addr_reg(vtx1),      brw_address(c->reg.vertex[1]));
+   brw_MOV(p, get_addr_reg(newvtx0),   brw_address(c->reg.vertex[2]));
+   brw_MOV(p, get_addr_reg(newvtx1),   brw_address(c->reg.vertex[3]));
+   brw_MOV(p, get_addr_reg(plane_ptr), brw_clip_plane0_address(c));
+
+   /* Note: init t0, t1 together: 
+    */
+   brw_MOV(p, vec2(c->reg.t0), brw_imm_f(0));
+
+   brw_clip_init_planes(c);
+   brw_clip_init_clipmask(c);
+
+   /* -ve rhw workaround */
+   if (c->chipset.is_965) {
+      brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
+      brw_AND(p, brw_null_reg(), get_element_ud(c->reg.R0, 2),
+              brw_imm_ud(1<<20));
+      brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud(0x3f));
+   }
+
+   brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+
+   plane_loop = brw_DO(p, BRW_EXECUTE_1);
+   {
+      /* if (planemask & 1)
+       */
+      brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
+      brw_AND(p, v1_null_ud, c->reg.planemask, brw_imm_ud(1));
+      
+      plane_active = brw_IF(p, BRW_EXECUTE_1);
+      {
+        if (c->key.nr_userclip)
+           brw_MOV(p, c->reg.plane_equation, deref_4f(plane_ptr, 0));
+        else
+           brw_MOV(p, c->reg.plane_equation, deref_4b(plane_ptr, 0));
+
+        /* dp = DP4(vtx->position, plane) 
+         */
+        brw_DP4(p, vec4(c->reg.dp0), deref_4f(vtx0, c->offset_hpos), c->reg.plane_equation);
+
+        /* if (IS_NEGATIVE(dp1)) 
+         */
+        brw_set_conditionalmod(p, BRW_CONDITIONAL_L);
+        brw_DP4(p, vec4(c->reg.dp1), deref_4f(vtx1, c->offset_hpos), c->reg.plane_equation);
+        is_negative = brw_IF(p, BRW_EXECUTE_1);
+        {
+             /*
+              * Both can be negative on GM965/G965 due to RHW workaround
+              * if so, this object should be rejected.
+              */
+             if (c->chipset.is_965) {
+                 brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_LE, c->reg.dp0, brw_imm_f(0.0));
+                 is_neg2 = brw_IF(p, BRW_EXECUTE_1);
+                 {
+                     brw_clip_kill_thread(c);
+                 }
+                 brw_ENDIF(p, is_neg2);
+             }
+
+             brw_ADD(p, c->reg.t, c->reg.dp1, negate(c->reg.dp0));
+             brw_math_invert(p, c->reg.t, c->reg.t);
+             brw_MUL(p, c->reg.t, c->reg.t, c->reg.dp1);
+
+             brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_G, c->reg.t, c->reg.t1 );
+             brw_MOV(p, c->reg.t1, c->reg.t);
+             brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+        } 
+        is_negative = brw_ELSE(p, is_negative);
+        {
+             /* Coming back in.  We know that both cannot be negative
+              * because the line would have been culled in that case.
+              */
+
+             /* If both are positive, do nothing */
+             /* Only on GM965/G965 */
+             if (c->chipset.is_965) {
+                 brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_L, c->reg.dp0, brw_imm_f(0.0));
+                 is_neg2 = brw_IF(p, BRW_EXECUTE_1);
+             }
+
+             {
+                 brw_ADD(p, c->reg.t, c->reg.dp0, negate(c->reg.dp1));
+                 brw_math_invert(p, c->reg.t, c->reg.t);
+                 brw_MUL(p, c->reg.t, c->reg.t, c->reg.dp0);
+
+                 brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_G, c->reg.t, c->reg.t0 );
+                 brw_MOV(p, c->reg.t0, c->reg.t);
+                 brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+             }
+
+             if (c->chipset.is_965) {
+                 brw_ENDIF(p, is_neg2);
+             }
+         }
+        brw_ENDIF(p, is_negative);      
+      }
+      brw_ENDIF(p, plane_active);
+      
+      /* plane_ptr++;
+       */
+      brw_ADD(p, get_addr_reg(plane_ptr), get_addr_reg(plane_ptr), brw_clip_plane_stride(c));
+
+      /* while (planemask>>=1) != 0
+       */
+      brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
+      brw_SHR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud(1));
+   }
+   brw_WHILE(p, plane_loop);
+
+   brw_ADD(p, c->reg.t, c->reg.t0, c->reg.t1);
+   brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_L, c->reg.t, brw_imm_f(1.0));
+   not_culled = brw_IF(p, BRW_EXECUTE_1);
+   {
+      brw_clip_interp_vertex(c, newvtx0, vtx0, vtx1, c->reg.t0, FALSE);
+      brw_clip_interp_vertex(c, newvtx1, vtx1, vtx0, c->reg.t1, FALSE);
+
+      brw_clip_emit_vue(c, newvtx0, 1, 0, (_3DPRIM_LINESTRIP << 2) | R02_PRIM_START);
+      brw_clip_emit_vue(c, newvtx1, 0, 1, (_3DPRIM_LINESTRIP << 2) | R02_PRIM_END); 
+   }
+   brw_ENDIF(p, not_culled);
+   brw_clip_kill_thread(c);
+}
+
+
+
+void brw_emit_line_clip( struct brw_clip_compile *c )
+{
+   brw_clip_line_alloc_regs(c);
+   brw_clip_init_ff_sync(c);
+
+   if (c->key.do_flat_shading)
+      brw_clip_copy_colors(c, 0, 1);
+                
+   clip_and_emit_line(c);
+}
diff --git a/src/gallium/drivers/i965/brw_clip_point.c b/src/gallium/drivers/i965/brw_clip_point.c
new file mode 100644 (file)
index 0000000..e0a5330
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ Copyright (C) Intel Corp.  2006.  All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ **********************************************************************/
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  */
+
+#include "brw_defines.h"
+#include "brw_eu.h"
+#include "brw_util.h"
+#include "brw_clip.h"
+
+
+/* Point clipping, nothing to do?
+ */
+void brw_emit_point_clip( struct brw_clip_compile *c )
+{
+   /* Send an empty message to kill the thread:
+    */
+   brw_clip_tri_alloc_regs(c, 0);
+   brw_clip_init_ff_sync(c);
+
+   brw_clip_kill_thread(c);
+}
diff --git a/src/gallium/drivers/i965/brw_clip_state.c b/src/gallium/drivers/i965/brw_clip_state.c
new file mode 100644 (file)
index 0000000..5c3ccfd
--- /dev/null
@@ -0,0 +1,209 @@
+/*
+ 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 "util/u_math.h"
+
+#include "brw_context.h"
+#include "brw_clip.h"
+#include "brw_state.h"
+#include "brw_defines.h"
+#include "brw_debug.h"
+
+struct brw_clip_unit_key {
+   unsigned int total_grf;
+   unsigned int urb_entry_read_length;
+   unsigned int curb_entry_read_length;
+   unsigned int clip_mode;
+
+   unsigned int curbe_offset;
+
+   unsigned int nr_urb_entries, urb_size;
+
+   GLboolean depth_clamp;
+};
+
+static void
+clip_unit_populate_key(struct brw_context *brw, struct brw_clip_unit_key *key)
+{
+   memset(key, 0, sizeof(*key));
+
+   /* CACHE_NEW_CLIP_PROG */
+   key->total_grf = brw->clip.prog_data->total_grf;
+   key->urb_entry_read_length = brw->clip.prog_data->urb_read_length;
+   key->curb_entry_read_length = brw->clip.prog_data->curb_read_length;
+   key->clip_mode = brw->clip.prog_data->clip_mode;
+
+   /* BRW_NEW_CURBE_OFFSETS */
+   key->curbe_offset = brw->curbe.clip_start;
+
+   /* BRW_NEW_URB_FENCE */
+   key->nr_urb_entries = brw->urb.nr_clip_entries;
+   key->urb_size = brw->urb.vsize;
+
+   /*  */
+   key->depth_clamp = 0; /* XXX: add this to gallium: ctx->Transform.DepthClamp; */
+}
+
+static enum pipe_error
+clip_unit_create_from_key(struct brw_context *brw,
+                          struct brw_clip_unit_key *key,
+                          struct brw_winsys_reloc *reloc,
+                          struct brw_winsys_buffer **bo_out)
+{
+   struct brw_clip_unit_state clip;
+   enum pipe_error ret;
+
+   memset(&clip, 0, sizeof(clip));
+
+   clip.thread0.grf_reg_count = align(key->total_grf, 16) / 16 - 1;
+   /* reloc */
+   clip.thread0.kernel_start_pointer = 0;
+
+   clip.thread1.floating_point_mode = BRW_FLOATING_POINT_NON_IEEE_754;
+   clip.thread1.single_program_flow = 1;
+
+   clip.thread3.urb_entry_read_length = key->urb_entry_read_length;
+   clip.thread3.const_urb_entry_read_length = key->curb_entry_read_length;
+   clip.thread3.const_urb_entry_read_offset = key->curbe_offset * 2;
+   clip.thread3.dispatch_grf_start_reg = 1;
+   clip.thread3.urb_entry_read_offset = 0;
+
+   clip.thread4.nr_urb_entries = key->nr_urb_entries;
+   clip.thread4.urb_entry_allocation_size = key->urb_size - 1;
+   /* If we have enough clip URB entries to run two threads, do so.
+    */
+   if (key->nr_urb_entries >= 10) {
+      /* Half of the URB entries go to each thread, and it has to be an
+       * even number.
+       */
+      assert(key->nr_urb_entries % 2 == 0);
+      
+      /* Although up to 16 concurrent Clip threads are allowed on IGDNG, 
+       * only 2 threads can output VUEs at a time.
+       */
+      if (BRW_IS_IGDNG(brw))
+         clip.thread4.max_threads = 16 - 1;        
+      else
+         clip.thread4.max_threads = 2 - 1;
+   } else {
+      assert(key->nr_urb_entries >= 5);
+      clip.thread4.max_threads = 1 - 1;
+   }
+
+   if (BRW_DEBUG & DEBUG_SINGLE_THREAD)
+      clip.thread4.max_threads = 0;
+
+   if (BRW_DEBUG & DEBUG_STATS)
+      clip.thread4.stats_enable = 1;
+
+   clip.clip5.userclip_enable_flags = 0x7f;
+   clip.clip5.userclip_must_clip = 1;
+   clip.clip5.guard_band_enable = 0;
+   if (!key->depth_clamp)
+      clip.clip5.viewport_z_clip_enable = 1;
+   clip.clip5.viewport_xy_clip_enable = 1;
+   clip.clip5.vertex_position_space = BRW_CLIP_NDCSPACE;
+   clip.clip5.api_mode = BRW_CLIP_API_OGL;
+   clip.clip5.clip_mode = key->clip_mode;
+
+   if (BRW_IS_G4X(brw))
+      clip.clip5.negative_w_clip_test = 1;
+
+   clip.clip6.clipper_viewport_state_ptr = 0;
+   clip.viewport_xmin = -1;
+   clip.viewport_xmax = 1;
+   clip.viewport_ymin = -1;
+   clip.viewport_ymax = 1;
+
+   ret = brw_upload_cache(&brw->cache, BRW_CLIP_UNIT,
+                          key, sizeof(*key),
+                          reloc, 1,
+                          &clip, sizeof(clip),
+                          NULL, NULL,
+                          bo_out);
+   if (ret)
+      return ret;
+
+   return PIPE_OK;
+}
+
+static int upload_clip_unit( struct brw_context *brw )
+{
+   struct brw_clip_unit_key key;
+   struct brw_winsys_reloc reloc[1];
+   unsigned grf_reg_count;
+   enum pipe_error ret;
+
+   clip_unit_populate_key(brw, &key);
+
+   grf_reg_count = align(key.total_grf, 16) / 16 - 1;
+
+   /* clip program relocation
+    *
+    * XXX: these reloc structs are long lived and only need to be
+    * updated when the bound BO changes.  Hopefully the stuff mixed in
+    * in the delta's is non-orthogonal.
+    */
+   assert(brw->clip.prog_bo);
+   make_reloc(&reloc[0],
+              BRW_USAGE_STATE,
+              grf_reg_count << 1,
+              offsetof(struct brw_clip_unit_state, thread0),
+              brw->clip.prog_bo);
+
+
+   if (brw_search_cache(&brw->cache, BRW_CLIP_UNIT,
+                        &key, sizeof(key),
+                        reloc, 1,
+                        NULL,
+                        &brw->clip.state_bo))
+      return PIPE_OK;
+      
+   /* Create new:
+    */
+   ret = clip_unit_create_from_key(brw, &key, 
+                                   reloc,
+                                   &brw->clip.state_bo);
+   if (ret)
+      return ret;
+   
+   return PIPE_OK;
+}
+
+const struct brw_tracked_state brw_clip_unit = {
+   .dirty = {
+      .mesa  = 0,
+      .brw   = (BRW_NEW_CURBE_OFFSETS |
+               BRW_NEW_URB_FENCE),
+      .cache = CACHE_NEW_CLIP_PROG
+   },
+   .prepare = upload_clip_unit,
+};
diff --git a/src/gallium/drivers/i965/brw_clip_tri.c b/src/gallium/drivers/i965/brw_clip_tri.c
new file mode 100644 (file)
index 0000000..4cde729
--- /dev/null
@@ -0,0 +1,595 @@
+/*
+ Copyright (C) Intel Corp.  2006.  All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ **********************************************************************/
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  */
+
+#include "brw_defines.h"
+#include "brw_eu.h"
+#include "brw_util.h"
+#include "brw_clip.h"
+
+static void release_tmps( struct brw_clip_compile *c )
+{
+   c->last_tmp = c->first_tmp;
+}
+
+
+void brw_clip_tri_alloc_regs( struct brw_clip_compile *c, 
+                             GLuint nr_verts )
+{
+   GLuint i = 0,j;
+
+   /* Register usage is static, precompute here:
+    */
+   c->reg.R0 = retype(brw_vec8_grf(i, 0), BRW_REGISTER_TYPE_UD); i++;
+
+   if (c->key.nr_userclip) {
+      c->reg.fixed_planes = brw_vec4_grf(i, 0);
+      i += (6 + c->key.nr_userclip + 1) / 2;
+
+      c->prog_data.curb_read_length = (6 + c->key.nr_userclip + 1) / 2;
+   }
+   else
+      c->prog_data.curb_read_length = 0;
+
+
+   /* Payload vertices plus space for more generated vertices:
+    */
+   for (j = 0; j < nr_verts; j++) {
+      c->reg.vertex[j] = brw_vec4_grf(i, 0);
+      i += c->nr_regs;
+   }
+
+   if (c->key.nr_attrs & 1) {
+      for (j = 0; j < 3; j++) {
+        GLuint delta = c->key.nr_attrs*16 + 32;
+
+         if (c->chipset.is_igdng)
+             delta = c->key.nr_attrs * 16 + 32 * 3;
+
+        brw_MOV(&c->func, byte_offset(c->reg.vertex[j], delta), brw_imm_f(0));
+      }
+   }
+
+   c->reg.t          = brw_vec1_grf(i, 0);
+   c->reg.loopcount  = retype(brw_vec1_grf(i, 1), BRW_REGISTER_TYPE_D);
+   c->reg.nr_verts   = retype(brw_vec1_grf(i, 2), BRW_REGISTER_TYPE_UD);
+   c->reg.planemask  = retype(brw_vec1_grf(i, 3), BRW_REGISTER_TYPE_UD);
+   c->reg.plane_equation = brw_vec4_grf(i, 4);
+   i++;
+
+   c->reg.dpPrev     = brw_vec1_grf(i, 0); /* fixme - dp4 will clobber r.1,2,3 */
+   c->reg.dp         = brw_vec1_grf(i, 4);
+   i++;
+
+   c->reg.inlist     = brw_uw16_reg(BRW_GENERAL_REGISTER_FILE, i, 0);
+   i++;
+
+   c->reg.outlist    = brw_uw16_reg(BRW_GENERAL_REGISTER_FILE, i, 0);
+   i++;
+
+   c->reg.freelist   = brw_uw16_reg(BRW_GENERAL_REGISTER_FILE, i, 0);
+   i++;
+
+   if (!c->key.nr_userclip) {
+      c->reg.fixed_planes = brw_vec8_grf(i, 0); 
+      i++;
+   }
+
+   if (c->key.do_unfilled) {
+      c->reg.dir     = brw_vec4_grf(i, 0);
+      c->reg.offset  = brw_vec4_grf(i, 4);
+      i++;
+      c->reg.tmp0    = brw_vec4_grf(i, 0);
+      c->reg.tmp1    = brw_vec4_grf(i, 4);
+      i++;
+   }
+
+   if (c->need_ff_sync) {
+      c->reg.ff_sync = retype(brw_vec1_grf(i, 0), BRW_REGISTER_TYPE_UD);
+      i++;
+   }
+
+   c->first_tmp = i;
+   c->last_tmp = i;
+
+   c->prog_data.urb_read_length = c->nr_regs; /* ? */
+   c->prog_data.total_grf = i;
+}
+
+
+
+void brw_clip_tri_init_vertices( struct brw_clip_compile *c )
+{
+   struct brw_compile *p = &c->func;
+   struct brw_reg tmp0 = c->reg.loopcount; /* handy temporary */
+   struct brw_instruction *is_rev;
+
+   /* Initial list of indices for incoming vertexes:
+    */
+   brw_AND(p, tmp0, get_element_ud(c->reg.R0, 2), brw_imm_ud(PRIM_MASK)); 
+   brw_CMP(p, 
+          vec1(brw_null_reg()), 
+          BRW_CONDITIONAL_EQ, 
+          tmp0,
+          brw_imm_ud(_3DPRIM_TRISTRIP_REVERSE));
+
+   /* XXX: Is there an easier way to do this?  Need to reverse every
+    * second tristrip element:  Can ignore sometimes?
+    */
+   is_rev = brw_IF(p, BRW_EXECUTE_1);
+   {   
+      brw_MOV(p, get_element(c->reg.inlist, 0),  brw_address(c->reg.vertex[1]) );
+      brw_MOV(p, get_element(c->reg.inlist, 1),  brw_address(c->reg.vertex[0]) );
+      if (c->need_direction)
+        brw_MOV(p, c->reg.dir, brw_imm_f(-1));
+   }
+   is_rev = brw_ELSE(p, is_rev);
+   {
+      brw_MOV(p, get_element(c->reg.inlist, 0),  brw_address(c->reg.vertex[0]) );
+      brw_MOV(p, get_element(c->reg.inlist, 1),  brw_address(c->reg.vertex[1]) );
+      if (c->need_direction)
+        brw_MOV(p, c->reg.dir, brw_imm_f(1));
+   }
+   brw_ENDIF(p, is_rev);
+
+   brw_MOV(p, get_element(c->reg.inlist, 2),  brw_address(c->reg.vertex[2]) );
+   brw_MOV(p, brw_vec8_grf(c->reg.outlist.nr, 0), brw_imm_f(0));
+   brw_MOV(p, c->reg.nr_verts, brw_imm_ud(3));
+}
+
+
+
+void brw_clip_tri_flat_shade( struct brw_clip_compile *c )
+{
+   struct brw_compile *p = &c->func;
+   struct brw_instruction *is_poly;
+   struct brw_reg tmp0 = c->reg.loopcount; /* handy temporary */
+
+   brw_AND(p, tmp0, get_element_ud(c->reg.R0, 2), brw_imm_ud(PRIM_MASK)); 
+   brw_CMP(p, 
+          vec1(brw_null_reg()), 
+          BRW_CONDITIONAL_EQ, 
+          tmp0,
+          brw_imm_ud(_3DPRIM_POLYGON));
+
+   is_poly = brw_IF(p, BRW_EXECUTE_1);
+   {   
+      brw_clip_copy_colors(c, 1, 0);
+      brw_clip_copy_colors(c, 2, 0);
+   }
+   is_poly = brw_ELSE(p, is_poly);
+   {
+      brw_clip_copy_colors(c, 0, 2);
+      brw_clip_copy_colors(c, 1, 2);
+   }
+   brw_ENDIF(p, is_poly);
+}
+
+
+
+/* Use mesa's clipping algorithms, translated to GEN4 assembly.
+ */
+void brw_clip_tri( struct brw_clip_compile *c )
+{
+   struct brw_compile *p = &c->func;
+   struct brw_indirect vtx = brw_indirect(0, 0);
+   struct brw_indirect vtxPrev = brw_indirect(1, 0);
+   struct brw_indirect vtxOut = brw_indirect(2, 0);
+   struct brw_indirect plane_ptr = brw_indirect(3, 0);
+   struct brw_indirect inlist_ptr = brw_indirect(4, 0);
+   struct brw_indirect outlist_ptr = brw_indirect(5, 0);
+   struct brw_indirect freelist_ptr = brw_indirect(6, 0);
+   struct brw_instruction *plane_loop;
+   struct brw_instruction *plane_active;
+   struct brw_instruction *vertex_loop;
+   struct brw_instruction *next_test;
+   struct brw_instruction *prev_test;
+   
+   brw_MOV(p, get_addr_reg(vtxPrev),     brw_address(c->reg.vertex[2]) );
+   brw_MOV(p, get_addr_reg(plane_ptr),   brw_clip_plane0_address(c));
+   brw_MOV(p, get_addr_reg(inlist_ptr),  brw_address(c->reg.inlist));
+   brw_MOV(p, get_addr_reg(outlist_ptr), brw_address(c->reg.outlist));
+
+   brw_MOV(p, get_addr_reg(freelist_ptr), brw_address(c->reg.vertex[3]) );
+
+   plane_loop = brw_DO(p, BRW_EXECUTE_1);
+   {
+      /* if (planemask & 1)
+       */
+      brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
+      brw_AND(p, vec1(brw_null_reg()), c->reg.planemask, brw_imm_ud(1));
+      
+      plane_active = brw_IF(p, BRW_EXECUTE_1);
+      {
+        /* vtxOut = freelist_ptr++ 
+         */
+        brw_MOV(p, get_addr_reg(vtxOut),       get_addr_reg(freelist_ptr) );
+        brw_ADD(p, get_addr_reg(freelist_ptr), get_addr_reg(freelist_ptr), brw_imm_uw(c->nr_regs * REG_SIZE));
+
+        if (c->key.nr_userclip)
+           brw_MOV(p, c->reg.plane_equation, deref_4f(plane_ptr, 0));
+        else
+           brw_MOV(p, c->reg.plane_equation, deref_4b(plane_ptr, 0));
+           
+        brw_MOV(p, c->reg.loopcount, c->reg.nr_verts);
+        brw_MOV(p, c->reg.nr_verts, brw_imm_ud(0));
+
+        vertex_loop = brw_DO(p, BRW_EXECUTE_1);
+        {
+           /* vtx = *input_ptr;
+            */
+           brw_MOV(p, get_addr_reg(vtx), deref_1uw(inlist_ptr, 0));
+
+           /* IS_NEGATIVE(prev) */
+           brw_set_conditionalmod(p, BRW_CONDITIONAL_L);
+           brw_DP4(p, vec4(c->reg.dpPrev), deref_4f(vtxPrev, c->offset_hpos), c->reg.plane_equation);
+           prev_test = brw_IF(p, BRW_EXECUTE_1);
+           {
+              /* IS_POSITIVE(next)
+               */
+              brw_set_conditionalmod(p, BRW_CONDITIONAL_GE);
+              brw_DP4(p, vec4(c->reg.dp), deref_4f(vtx, c->offset_hpos), c->reg.plane_equation);
+              next_test = brw_IF(p, BRW_EXECUTE_1);
+              {
+
+                 /* Coming back in.
+                  */
+                 brw_ADD(p, c->reg.t, c->reg.dpPrev, negate(c->reg.dp));
+                 brw_math_invert(p, c->reg.t, c->reg.t);
+                 brw_MUL(p, c->reg.t, c->reg.t, c->reg.dpPrev);
+
+                 /* If (vtxOut == 0) vtxOut = vtxPrev
+                  */
+                 brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_EQ, get_addr_reg(vtxOut), brw_imm_uw(0) );
+                 brw_MOV(p, get_addr_reg(vtxOut), get_addr_reg(vtxPrev) );
+                 brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+
+                 brw_clip_interp_vertex(c, vtxOut, vtxPrev, vtx, c->reg.t, GL_FALSE);
+
+                 /* *outlist_ptr++ = vtxOut;
+                  * nr_verts++; 
+                  * vtxOut = 0;
+                  */
+                 brw_MOV(p, deref_1uw(outlist_ptr, 0), get_addr_reg(vtxOut));
+                 brw_ADD(p, get_addr_reg(outlist_ptr), get_addr_reg(outlist_ptr), brw_imm_uw(sizeof(short)));
+                 brw_ADD(p, c->reg.nr_verts, c->reg.nr_verts, brw_imm_ud(1));
+                 brw_MOV(p, get_addr_reg(vtxOut), brw_imm_uw(0) );
+              }
+              brw_ENDIF(p, next_test);
+              
+           }
+           prev_test = brw_ELSE(p, prev_test);
+           {
+              /* *outlist_ptr++ = vtxPrev;
+               * nr_verts++;
+               */
+              brw_MOV(p, deref_1uw(outlist_ptr, 0), get_addr_reg(vtxPrev));
+              brw_ADD(p, get_addr_reg(outlist_ptr), get_addr_reg(outlist_ptr), brw_imm_uw(sizeof(short)));
+              brw_ADD(p, c->reg.nr_verts, c->reg.nr_verts, brw_imm_ud(1));
+
+              /* IS_NEGATIVE(next)
+               */
+              brw_set_conditionalmod(p, BRW_CONDITIONAL_L);
+              brw_DP4(p, vec4(c->reg.dp), deref_4f(vtx, c->offset_hpos), c->reg.plane_equation);
+              next_test = brw_IF(p, BRW_EXECUTE_1);
+              {
+                 /* Going out of bounds.  Avoid division by zero as we
+                  * know dp != dpPrev from DIFFERENT_SIGNS, above.
+                  */
+                 brw_ADD(p, c->reg.t, c->reg.dp, negate(c->reg.dpPrev));
+                 brw_math_invert(p, c->reg.t, c->reg.t);
+                 brw_MUL(p, c->reg.t, c->reg.t, c->reg.dp);
+
+                 /* If (vtxOut == 0) vtxOut = vtx
+                  */
+                 brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_EQ, get_addr_reg(vtxOut), brw_imm_uw(0) );
+                 brw_MOV(p, get_addr_reg(vtxOut), get_addr_reg(vtx) );
+                 brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+
+                 brw_clip_interp_vertex(c, vtxOut, vtx, vtxPrev, c->reg.t, GL_TRUE);             
+
+                 /* *outlist_ptr++ = vtxOut;
+                  * nr_verts++; 
+                  * vtxOut = 0;
+                  */
+                 brw_MOV(p, deref_1uw(outlist_ptr, 0), get_addr_reg(vtxOut));
+                 brw_ADD(p, get_addr_reg(outlist_ptr), get_addr_reg(outlist_ptr), brw_imm_uw(sizeof(short)));
+                 brw_ADD(p, c->reg.nr_verts, c->reg.nr_verts, brw_imm_ud(1));
+                 brw_MOV(p, get_addr_reg(vtxOut), brw_imm_uw(0) );
+              }               
+              brw_ENDIF(p, next_test);
+           }
+           brw_ENDIF(p, prev_test);
+           
+           /* vtxPrev = vtx;
+            * inlist_ptr++;
+            */
+           brw_MOV(p, get_addr_reg(vtxPrev), get_addr_reg(vtx));
+           brw_ADD(p, get_addr_reg(inlist_ptr), get_addr_reg(inlist_ptr), brw_imm_uw(sizeof(short)));
+
+           /* while (--loopcount != 0)
+            */
+           brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
+           brw_ADD(p, c->reg.loopcount, c->reg.loopcount, brw_imm_d(-1));
+        } 
+        brw_WHILE(p, vertex_loop);
+
+        /* vtxPrev = *(outlist_ptr-1)  OR: outlist[nr_verts-1]
+         * inlist = outlist
+         * inlist_ptr = &inlist[0]
+         * outlist_ptr = &outlist[0]
+         */
+        brw_ADD(p, get_addr_reg(outlist_ptr), get_addr_reg(outlist_ptr), brw_imm_w(-2));
+        brw_MOV(p, get_addr_reg(vtxPrev), deref_1uw(outlist_ptr, 0));
+        brw_MOV(p, brw_vec8_grf(c->reg.inlist.nr, 0), brw_vec8_grf(c->reg.outlist.nr, 0));
+        brw_MOV(p, get_addr_reg(inlist_ptr), brw_address(c->reg.inlist));
+        brw_MOV(p, get_addr_reg(outlist_ptr), brw_address(c->reg.outlist));
+      }
+      brw_ENDIF(p, plane_active);
+      
+      /* plane_ptr++;
+       */
+      brw_ADD(p, get_addr_reg(plane_ptr), get_addr_reg(plane_ptr), brw_clip_plane_stride(c));
+
+      /* nr_verts >= 3 
+       */
+      brw_CMP(p,
+             vec1(brw_null_reg()),
+             BRW_CONDITIONAL_GE,
+             c->reg.nr_verts,
+             brw_imm_ud(3));
+   
+      /* && (planemask>>=1) != 0
+       */
+      brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
+      brw_SHR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud(1));
+   }
+   brw_WHILE(p, plane_loop);
+}
+
+
+
+void brw_clip_tri_emit_polygon(struct brw_clip_compile *c)
+{
+   struct brw_compile *p = &c->func;
+   struct brw_instruction *loop, *if_insn;
+
+   /* for (loopcount = nr_verts-2; loopcount > 0; loopcount--)
+    */
+   brw_set_conditionalmod(p, BRW_CONDITIONAL_G);
+   brw_ADD(p,
+          c->reg.loopcount,
+          c->reg.nr_verts,
+          brw_imm_d(-2));
+
+   if_insn = brw_IF(p, BRW_EXECUTE_1);
+   {
+      struct brw_indirect v0 = brw_indirect(0, 0);
+      struct brw_indirect vptr = brw_indirect(1, 0);
+
+      brw_MOV(p, get_addr_reg(vptr), brw_address(c->reg.inlist));
+      brw_MOV(p, get_addr_reg(v0), deref_1uw(vptr, 0));
+
+      brw_clip_emit_vue(c, v0, 1, 0, ((_3DPRIM_TRIFAN << 2) | R02_PRIM_START));
+      
+      brw_ADD(p, get_addr_reg(vptr), get_addr_reg(vptr), brw_imm_uw(2));
+      brw_MOV(p, get_addr_reg(v0), deref_1uw(vptr, 0));
+
+      loop = brw_DO(p, BRW_EXECUTE_1);
+      {
+        brw_clip_emit_vue(c, v0, 1, 0, (_3DPRIM_TRIFAN << 2));
+  
+        brw_ADD(p, get_addr_reg(vptr), get_addr_reg(vptr), brw_imm_uw(2));
+        brw_MOV(p, get_addr_reg(v0), deref_1uw(vptr, 0));
+
+        brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
+        brw_ADD(p, c->reg.loopcount, c->reg.loopcount, brw_imm_d(-1));
+      }
+      brw_WHILE(p, loop);
+
+      brw_clip_emit_vue(c, v0, 0, 1, ((_3DPRIM_TRIFAN << 2) | R02_PRIM_END));
+   }
+   brw_ENDIF(p, if_insn);
+}
+
+static void do_clip_tri( struct brw_clip_compile *c )
+{
+   brw_clip_init_planes(c);
+
+   brw_clip_tri(c);
+}
+
+
+static void maybe_do_clip_tri( struct brw_clip_compile *c )
+{
+   struct brw_compile *p = &c->func;
+   struct brw_instruction *do_clip;
+
+   brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_NZ, c->reg.planemask, brw_imm_ud(0));
+   do_clip = brw_IF(p, BRW_EXECUTE_1);
+   {
+      do_clip_tri(c);
+   }
+   brw_ENDIF(p, do_clip);
+}
+
+static void brw_clip_test( struct brw_clip_compile *c )
+{
+    struct brw_reg t = retype(get_tmp(c), BRW_REGISTER_TYPE_UD);
+    struct brw_reg t1 = retype(get_tmp(c), BRW_REGISTER_TYPE_UD);
+    struct brw_reg t2 = retype(get_tmp(c), BRW_REGISTER_TYPE_UD);
+    struct brw_reg t3 = retype(get_tmp(c), BRW_REGISTER_TYPE_UD);
+
+    struct brw_reg v0 = get_tmp(c);
+    struct brw_reg v1 = get_tmp(c);
+    struct brw_reg v2 = get_tmp(c);
+
+    struct brw_indirect vt0 = brw_indirect(0, 0);
+    struct brw_indirect vt1 = brw_indirect(1, 0);
+    struct brw_indirect vt2 = brw_indirect(2, 0);
+
+    struct brw_compile *p = &c->func;
+    struct brw_instruction *is_outside;
+    struct brw_reg tmp0 = c->reg.loopcount; /* handy temporary */
+
+    brw_MOV(p, get_addr_reg(vt0), brw_address(c->reg.vertex[0]));
+    brw_MOV(p, get_addr_reg(vt1), brw_address(c->reg.vertex[1]));
+    brw_MOV(p, get_addr_reg(vt2), brw_address(c->reg.vertex[2]));
+    brw_MOV(p, v0, deref_4f(vt0, c->offset_hpos));
+    brw_MOV(p, v1, deref_4f(vt1, c->offset_hpos));
+    brw_MOV(p, v2, deref_4f(vt2, c->offset_hpos));
+    brw_AND(p, c->reg.planemask, c->reg.planemask, brw_imm_ud(~0x3f));
+
+    /* test nearz, xmin, ymin plane */
+    /* clip.xyz < -clip.w */
+    brw_CMP(p, t1, BRW_CONDITIONAL_L, v0, negate(get_element(v0, 3))); 
+    brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+    brw_CMP(p, t2, BRW_CONDITIONAL_L, v1, negate(get_element(v1, 3))); 
+    brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+    brw_CMP(p, t3, BRW_CONDITIONAL_L, v2, negate(get_element(v2, 3))); 
+    brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+
+    /* All vertices are outside of a plane, rejected */
+    brw_AND(p, t, t1, t2);
+    brw_AND(p, t, t, t3);
+    brw_OR(p, tmp0, get_element(t, 0), get_element(t, 1));
+    brw_OR(p, tmp0, tmp0, get_element(t, 2));
+    brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
+    brw_AND(p, brw_null_reg(), tmp0, brw_imm_ud(0x1));
+    is_outside = brw_IF(p, BRW_EXECUTE_1);
+    {
+        brw_clip_kill_thread(c);
+    }
+    brw_ENDIF(p, is_outside);
+    brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+
+    /* some vertices are inside a plane, some are outside,need to clip */
+    brw_XOR(p, t, t1, t2);
+    brw_XOR(p, t1, t2, t3);
+    brw_OR(p, t, t, t1);
+    brw_AND(p, t, t, brw_imm_ud(0x1));
+    brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_NZ,
+            get_element(t, 0), brw_imm_ud(0));
+    brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud((1<<5)));
+    brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+    brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_NZ,
+            get_element(t, 1), brw_imm_ud(0));
+    brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud((1<<3)));
+    brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+    brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_NZ,
+            get_element(t, 2), brw_imm_ud(0));
+    brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud((1<<1)));
+    brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+
+    /* test farz, xmax, ymax plane */
+    /* clip.xyz > clip.w */
+    brw_CMP(p, t1, BRW_CONDITIONAL_G, v0, get_element(v0, 3)); 
+    brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+    brw_CMP(p, t2, BRW_CONDITIONAL_G, v1, get_element(v1, 3)); 
+    brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+    brw_CMP(p, t3, BRW_CONDITIONAL_G, v2, get_element(v2, 3)); 
+    brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+
+    /* All vertices are outside of a plane, rejected */
+    brw_AND(p, t, t1, t2);
+    brw_AND(p, t, t, t3);
+    brw_OR(p, tmp0, get_element(t, 0), get_element(t, 1));
+    brw_OR(p, tmp0, tmp0, get_element(t, 2));
+    brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
+    brw_AND(p, brw_null_reg(), tmp0, brw_imm_ud(0x1));
+    is_outside = brw_IF(p, BRW_EXECUTE_1);
+    {
+        brw_clip_kill_thread(c);
+    }
+    brw_ENDIF(p, is_outside);
+    brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+
+    /* some vertices are inside a plane, some are outside,need to clip */
+    brw_XOR(p, t, t1, t2);
+    brw_XOR(p, t1, t2, t3);
+    brw_OR(p, t, t, t1);
+    brw_AND(p, t, t, brw_imm_ud(0x1));
+    brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_NZ,
+            get_element(t, 0), brw_imm_ud(0));
+    brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud((1<<4)));
+    brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+    brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_NZ,
+            get_element(t, 1), brw_imm_ud(0));
+    brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud((1<<2)));
+    brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+    brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_NZ,
+            get_element(t, 2), brw_imm_ud(0));
+    brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud((1<<0)));
+    brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+
+    release_tmps(c);
+}
+
+
+void brw_emit_tri_clip( struct brw_clip_compile *c )
+{
+   struct brw_instruction *neg_rhw;
+   struct brw_compile *p = &c->func;
+   brw_clip_tri_alloc_regs(c, 3 + c->key.nr_userclip + 6);
+   brw_clip_tri_init_vertices(c);
+   brw_clip_init_clipmask(c);
+   brw_clip_init_ff_sync(c);
+
+   /* if -ve rhw workaround bit is set, 
+      do cliptest */
+   if (c->chipset.is_965) {
+      brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
+      brw_AND(p, brw_null_reg(), get_element_ud(c->reg.R0, 2), 
+              brw_imm_ud(1<<20));
+      neg_rhw = brw_IF(p, BRW_EXECUTE_1); 
+      {
+         brw_clip_test(c);
+      }
+      brw_ENDIF(p, neg_rhw);
+   }
+   /* Can't push into do_clip_tri because with polygon (or quad)
+    * flatshading, need to apply the flatshade here because we don't
+    * respect the PV when converting to trifan for emit:
+    */
+   if (c->key.do_flat_shading) 
+      brw_clip_tri_flat_shade(c); 
+      
+   if ((c->key.clip_mode == BRW_CLIPMODE_NORMAL) ||
+       (c->key.clip_mode == BRW_CLIPMODE_KERNEL_CLIP))
+      do_clip_tri(c);
+   else 
+      maybe_do_clip_tri(c);
+
+   brw_clip_tri_emit_polygon(c);
+
+   /* Send an empty message to kill the thread:
+    */
+   brw_clip_kill_thread(c);
+}
diff --git a/src/gallium/drivers/i965/brw_clip_unfilled.c b/src/gallium/drivers/i965/brw_clip_unfilled.c
new file mode 100644 (file)
index 0000000..aec835b
--- /dev/null
@@ -0,0 +1,497 @@
+/*
+ Copyright (C) Intel Corp.  2006.  All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ **********************************************************************/
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  */
+
+#include "brw_defines.h"
+#include "brw_eu.h"
+#include "brw_util.h"
+#include "brw_clip.h"
+
+
+
+/* This is performed against the original triangles, so no indirection
+ * required:
+BZZZT!
+ */
+static void compute_tri_direction( struct brw_clip_compile *c )
+{
+   struct brw_compile *p = &c->func;
+   struct brw_reg e = c->reg.tmp0;
+   struct brw_reg f = c->reg.tmp1;
+   struct brw_reg v0 = byte_offset(c->reg.vertex[0], c->offset_hpos); 
+   struct brw_reg v1 = byte_offset(c->reg.vertex[1], c->offset_hpos); 
+   struct brw_reg v2 = byte_offset(c->reg.vertex[2], c->offset_hpos); 
+
+
+   struct brw_reg v0n = get_tmp(c);
+   struct brw_reg v1n = get_tmp(c);
+   struct brw_reg v2n = get_tmp(c);
+
+   /* Convert to NDC.
+    * NOTE: We can't modify the original vertex coordinates,
+    * as it may impact further operations.
+    * So, we have to keep normalized coordinates in temp registers.
+    *
+    * TBD-KC
+    * Try to optimize unnecessary MOV's.
+    */
+   brw_MOV(p, v0n, v0);
+   brw_MOV(p, v1n, v1);
+   brw_MOV(p, v2n, v2);
+
+   brw_clip_project_position(c, v0n);
+   brw_clip_project_position(c, v1n);
+   brw_clip_project_position(c, v2n);
+
+   /* Calculate the vectors of two edges of the triangle:
+    */
+   brw_ADD(p, e, v0n, negate(v2n)); 
+   brw_ADD(p, f, v1n, negate(v2n)); 
+
+   /* Take their crossproduct:
+    */
+   brw_set_access_mode(p, BRW_ALIGN_16);
+   brw_MUL(p, vec4(brw_null_reg()), brw_swizzle(e, 1,2,0,3),  brw_swizzle(f,2,0,1,3));
+   brw_MAC(p, vec4(e),  negate(brw_swizzle(e, 2,0,1,3)), brw_swizzle(f,1,2,0,3));
+   brw_set_access_mode(p, BRW_ALIGN_1);
+
+   brw_MUL(p, c->reg.dir, c->reg.dir, vec4(e));
+}
+
+
+static void cull_direction( struct brw_clip_compile *c )
+{
+   struct brw_compile *p = &c->func;
+   struct brw_instruction *ccw;
+   GLuint conditional;
+
+   assert (!(c->key.fill_ccw == CLIP_CULL &&
+            c->key.fill_cw == CLIP_CULL));
+
+   if (c->key.fill_ccw == CLIP_CULL)
+      conditional = BRW_CONDITIONAL_GE;
+   else
+      conditional = BRW_CONDITIONAL_L;
+
+   brw_CMP(p,
+          vec1(brw_null_reg()),
+          conditional,
+          get_element(c->reg.dir, 2),
+          brw_imm_f(0));
+   
+   ccw = brw_IF(p, BRW_EXECUTE_1);
+   {
+      brw_clip_kill_thread(c);
+   }
+   brw_ENDIF(p, ccw);
+}
+
+
+
+static void copy_bfc( struct brw_clip_compile *c )
+{
+   struct brw_compile *p = &c->func;
+   struct brw_instruction *ccw;
+   GLuint conditional;
+
+   /* Do we have any colors to copy? 
+    */
+   if ((c->offset_color0 == 0 || c->offset_bfc0 == 0) &&
+       (c->offset_color1 == 0 || c->offset_bfc1 == 0))
+      return;
+
+   /* In some wierd degnerate cases we can end up testing the
+    * direction twice, once for culling and once for bfc copying.  Oh
+    * well, that's what you get for setting wierd GL state.
+    */
+   if (c->key.copy_bfc_ccw)
+      conditional = BRW_CONDITIONAL_GE;
+   else
+      conditional = BRW_CONDITIONAL_L;
+
+   brw_CMP(p,
+          vec1(brw_null_reg()),
+          conditional,
+          get_element(c->reg.dir, 2),
+          brw_imm_f(0));
+   
+   ccw = brw_IF(p, BRW_EXECUTE_1);
+   {
+      GLuint i;
+
+      for (i = 0; i < 3; i++) {
+        if (c->offset_color0 && c->offset_bfc0)
+           brw_MOV(p, 
+                   byte_offset(c->reg.vertex[i], c->offset_color0),
+                   byte_offset(c->reg.vertex[i], c->offset_bfc0));
+
+        if (c->offset_color1 && c->offset_bfc1)
+           brw_MOV(p, 
+                   byte_offset(c->reg.vertex[i], c->offset_color0),
+                   byte_offset(c->reg.vertex[i], c->offset_bfc0));
+      }
+   }
+   brw_ENDIF(p, ccw);
+}
+
+
+
+
+/*
+  GLfloat iz   = 1.0 / dir.z;
+  GLfloat ac   = dir.x * iz;
+  GLfloat bc   = dir.y * iz;
+  offset = ctx->Polygon.OffsetUnits * DEPTH_SCALE;
+  offset += MAX2( abs(ac), abs(bc) ) * ctx->Polygon.OffsetFactor;
+  offset *= MRD;
+*/
+static void compute_offset( struct brw_clip_compile *c )
+{
+   struct brw_compile *p = &c->func;
+   struct brw_reg off = c->reg.offset;
+   struct brw_reg dir = c->reg.dir;
+   
+   brw_math_invert(p, get_element(off, 2), get_element(dir, 2));
+   brw_MUL(p, vec2(off), dir, get_element(off, 2));
+
+   brw_CMP(p, 
+          vec1(brw_null_reg()), 
+          BRW_CONDITIONAL_GE,
+          brw_abs(get_element(off, 0)), 
+          brw_abs(get_element(off, 1)));
+
+   brw_SEL(p, vec1(off), brw_abs(get_element(off, 0)), brw_abs(get_element(off, 1)));
+   brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+
+   brw_MUL(p, vec1(off), off, brw_imm_f(c->key.offset_factor));
+   brw_ADD(p, vec1(off), off, brw_imm_f(c->key.offset_units));
+}
+
+
+static void merge_edgeflags( struct brw_clip_compile *c )
+{
+   struct brw_compile *p = &c->func;
+   struct brw_instruction *is_poly;
+   struct brw_reg tmp0 = get_element_ud(c->reg.tmp0, 0);
+
+   brw_AND(p, tmp0, get_element_ud(c->reg.R0, 2), brw_imm_ud(PRIM_MASK)); 
+   brw_CMP(p, 
+          vec1(brw_null_reg()), 
+          BRW_CONDITIONAL_EQ, 
+          tmp0,
+          brw_imm_ud(_3DPRIM_POLYGON));
+
+   /* Get away with using reg.vertex because we know that this is not
+    * a _3DPRIM_TRISTRIP_REVERSE:
+    */
+   is_poly = brw_IF(p, BRW_EXECUTE_1);
+   {   
+      brw_set_conditionalmod(p, BRW_CONDITIONAL_EQ);
+      brw_AND(p, vec1(brw_null_reg()), get_element_ud(c->reg.R0, 2), brw_imm_ud(1<<8));
+      brw_MOV(p, byte_offset(c->reg.vertex[0], c->offset_edgeflag), brw_imm_f(0));
+      brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+
+      brw_set_conditionalmod(p, BRW_CONDITIONAL_EQ);
+      brw_AND(p, vec1(brw_null_reg()), get_element_ud(c->reg.R0, 2), brw_imm_ud(1<<9));
+      brw_MOV(p, byte_offset(c->reg.vertex[2], c->offset_edgeflag), brw_imm_f(0));
+      brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+   }
+   brw_ENDIF(p, is_poly);
+}
+
+
+
+static void apply_one_offset( struct brw_clip_compile *c,
+                         struct brw_indirect vert )
+{
+   struct brw_compile *p = &c->func;
+   struct brw_reg z = deref_1f(vert, c->header_position_offset +
+                              2 * type_sz(BRW_REGISTER_TYPE_F));
+
+   brw_ADD(p, z, z, vec1(c->reg.offset));
+}
+
+
+
+/***********************************************************************
+ * Output clipped polygon as an unfilled primitive:
+ */
+static void emit_lines(struct brw_clip_compile *c,
+                      GLboolean do_offset)
+{
+   struct brw_compile *p = &c->func;
+   struct brw_instruction *loop;
+   struct brw_instruction *draw_edge;
+   struct brw_indirect v0 = brw_indirect(0, 0);
+   struct brw_indirect v1 = brw_indirect(1, 0);
+   struct brw_indirect v0ptr = brw_indirect(2, 0);
+   struct brw_indirect v1ptr = brw_indirect(3, 0);
+
+   /* Need a seperate loop for offset:
+    */
+   if (do_offset) {
+      brw_MOV(p, c->reg.loopcount, c->reg.nr_verts);
+      brw_MOV(p, get_addr_reg(v0ptr), brw_address(c->reg.inlist));
+
+      loop = brw_DO(p, BRW_EXECUTE_1);
+      {
+        brw_MOV(p, get_addr_reg(v0), deref_1uw(v0ptr, 0));
+        brw_ADD(p, get_addr_reg(v0ptr), get_addr_reg(v0ptr), brw_imm_uw(2));
+           
+        apply_one_offset(c, v0);
+           
+        brw_set_conditionalmod(p, BRW_CONDITIONAL_G);
+        brw_ADD(p, c->reg.loopcount, c->reg.loopcount, brw_imm_d(-1));
+      }
+      brw_WHILE(p, loop);
+   }
+
+   /* v1ptr = &inlist[nr_verts]
+    * *v1ptr = v0
+    */
+   brw_MOV(p, c->reg.loopcount, c->reg.nr_verts);
+   brw_MOV(p, get_addr_reg(v0ptr), brw_address(c->reg.inlist));
+   brw_ADD(p, get_addr_reg(v1ptr), get_addr_reg(v0ptr), retype(c->reg.nr_verts, BRW_REGISTER_TYPE_UW));
+   brw_ADD(p, get_addr_reg(v1ptr), get_addr_reg(v1ptr), retype(c->reg.nr_verts, BRW_REGISTER_TYPE_UW));
+   brw_MOV(p, deref_1uw(v1ptr, 0), deref_1uw(v0ptr, 0));
+
+   loop = brw_DO(p, BRW_EXECUTE_1);
+   {
+      brw_MOV(p, get_addr_reg(v0), deref_1uw(v0ptr, 0));
+      brw_MOV(p, get_addr_reg(v1), deref_1uw(v0ptr, 2));
+      brw_ADD(p, get_addr_reg(v0ptr), get_addr_reg(v0ptr), brw_imm_uw(2));
+
+      /* draw edge if edgeflag != 0 */
+      brw_CMP(p, 
+             vec1(brw_null_reg()), BRW_CONDITIONAL_NZ, 
+             deref_1f(v0, c->offset_edgeflag),
+             brw_imm_f(0));
+      draw_edge = brw_IF(p, BRW_EXECUTE_1);
+      {
+        brw_clip_emit_vue(c, v0, 1, 0, (_3DPRIM_LINESTRIP << 2) | R02_PRIM_START);
+        brw_clip_emit_vue(c, v1, 1, 0, (_3DPRIM_LINESTRIP << 2) | R02_PRIM_END);
+      }
+      brw_ENDIF(p, draw_edge);
+
+      brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
+      brw_ADD(p, c->reg.loopcount, c->reg.loopcount, brw_imm_d(-1));
+   }
+   brw_WHILE(p, loop);
+}
+
+
+
+static void emit_points(struct brw_clip_compile *c,
+                       GLboolean do_offset )
+{
+   struct brw_compile *p = &c->func;
+   struct brw_instruction *loop;
+   struct brw_instruction *draw_point;
+
+   struct brw_indirect v0 = brw_indirect(0, 0);
+   struct brw_indirect v0ptr = brw_indirect(2, 0);
+
+   brw_MOV(p, c->reg.loopcount, c->reg.nr_verts);
+   brw_MOV(p, get_addr_reg(v0ptr), brw_address(c->reg.inlist));
+
+   loop = brw_DO(p, BRW_EXECUTE_1);
+   {
+      brw_MOV(p, get_addr_reg(v0), deref_1uw(v0ptr, 0));
+      brw_ADD(p, get_addr_reg(v0ptr), get_addr_reg(v0ptr), brw_imm_uw(2));
+
+      /* draw if edgeflag != 0 
+       */
+      brw_CMP(p, 
+             vec1(brw_null_reg()), BRW_CONDITIONAL_NZ, 
+             deref_1f(v0, c->offset_edgeflag),
+             brw_imm_f(0));
+      draw_point = brw_IF(p, BRW_EXECUTE_1);
+      {
+        if (do_offset)
+           apply_one_offset(c, v0);
+
+        brw_clip_emit_vue(c, v0, 1, 0, (_3DPRIM_POINTLIST << 2) | R02_PRIM_START | R02_PRIM_END);
+      }
+      brw_ENDIF(p, draw_point);
+
+      brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
+      brw_ADD(p, c->reg.loopcount, c->reg.loopcount, brw_imm_d(-1));
+   }
+   brw_WHILE(p, loop);
+}
+
+
+
+
+
+
+
+static void emit_primitives( struct brw_clip_compile *c,
+                            GLuint mode, 
+                            GLboolean do_offset )
+{
+   switch (mode) {
+   case CLIP_FILL:
+      brw_clip_tri_emit_polygon(c);
+      break;
+
+   case CLIP_LINE:
+      emit_lines(c, do_offset);
+      break;
+
+   case CLIP_POINT:
+      emit_points(c, do_offset);
+      break;
+
+   case CLIP_CULL:
+      assert(0);
+      break;
+   }
+} 
+
+
+
+static void emit_unfilled_primitives( struct brw_clip_compile *c )
+{
+   struct brw_compile *p = &c->func;
+   struct brw_instruction *ccw;
+
+   /* Direction culling has already been done.
+    */
+   if (c->key.fill_ccw != c->key.fill_cw &&
+       c->key.fill_ccw != CLIP_CULL &&
+       c->key.fill_cw != CLIP_CULL)
+   {
+      brw_CMP(p,
+             vec1(brw_null_reg()),
+             BRW_CONDITIONAL_GE,
+             get_element(c->reg.dir, 2),
+             brw_imm_f(0));
+   
+      ccw = brw_IF(p, BRW_EXECUTE_1);
+      {
+        emit_primitives(c, c->key.fill_ccw, c->key.offset_ccw);
+      }
+      ccw = brw_ELSE(p, ccw);
+      {
+        emit_primitives(c, c->key.fill_cw, c->key.offset_cw);
+      }
+      brw_ENDIF(p, ccw);
+   }
+   else if (c->key.fill_cw != CLIP_CULL) {
+      emit_primitives(c, c->key.fill_cw, c->key.offset_cw);
+   }
+   else if (c->key.fill_ccw != CLIP_CULL) { 
+      emit_primitives(c, c->key.fill_ccw, c->key.offset_ccw);
+   }
+}
+
+
+
+
+static void check_nr_verts( struct brw_clip_compile *c )
+{
+   struct brw_compile *p = &c->func;
+   struct brw_instruction *if_insn;
+
+   brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_L, c->reg.nr_verts, brw_imm_d(3));      
+   if_insn = brw_IF(p, BRW_EXECUTE_1);
+   {
+      brw_clip_kill_thread(c);
+   }
+   brw_ENDIF(p, if_insn);
+}
+
+
+void brw_emit_unfilled_clip( struct brw_clip_compile *c )
+{
+   struct brw_compile *p = &c->func;
+   struct brw_instruction *do_clip;
+   
+
+   c->need_direction = ((c->key.offset_ccw || c->key.offset_cw) ||
+                       (c->key.fill_ccw != c->key.fill_cw) ||
+                       c->key.fill_ccw == CLIP_CULL ||
+                       c->key.fill_cw == CLIP_CULL ||
+                       c->key.copy_bfc_cw ||
+                       c->key.copy_bfc_ccw);
+
+   brw_clip_tri_alloc_regs(c, 3 + c->key.nr_userclip + 6);
+   brw_clip_tri_init_vertices(c);
+   brw_clip_init_ff_sync(c);
+
+   assert(c->offset_edgeflag);
+
+   if (c->key.fill_ccw == CLIP_CULL &&
+       c->key.fill_cw == CLIP_CULL) {
+      brw_clip_kill_thread(c);
+      return;
+   }
+
+   merge_edgeflags(c);
+
+   /* Need to use the inlist indirection here: 
+    */
+   if (c->need_direction) 
+      compute_tri_direction(c);
+   
+   if (c->key.fill_ccw == CLIP_CULL ||
+       c->key.fill_cw == CLIP_CULL)
+      cull_direction(c);
+
+   if (c->key.offset_ccw ||
+       c->key.offset_cw)
+      compute_offset(c);
+
+   if (c->key.copy_bfc_ccw ||
+       c->key.copy_bfc_cw)
+      copy_bfc(c);
+
+   /* Need to do this whether we clip or not:
+    */
+   if (c->key.do_flat_shading)
+      brw_clip_tri_flat_shade(c);
+   
+   brw_clip_init_clipmask(c);
+   brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_NZ, c->reg.planemask, brw_imm_ud(0));
+   do_clip = brw_IF(p, BRW_EXECUTE_1);
+   {
+      brw_clip_init_planes(c);
+      brw_clip_tri(c);
+      check_nr_verts(c);
+   }
+   brw_ENDIF(p, do_clip);
+   
+   emit_unfilled_primitives(c);
+   brw_clip_kill_thread(c);
+}
+
+
+
diff --git a/src/gallium/drivers/i965/brw_clip_util.c b/src/gallium/drivers/i965/brw_clip_util.c
new file mode 100644 (file)
index 0000000..97a5710
--- /dev/null
@@ -0,0 +1,388 @@
+/*
+ Copyright (C) Intel Corp.  2006.  All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ **********************************************************************/
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  */
+
+
+#include "brw_defines.h"
+#include "brw_eu.h"
+#include "brw_util.h"
+#include "brw_clip.h"
+
+
+
+
+struct brw_reg get_tmp( struct brw_clip_compile *c )
+{
+   struct brw_reg tmp = brw_vec4_grf(c->last_tmp, 0);
+
+   if (++c->last_tmp > c->prog_data.total_grf)
+      c->prog_data.total_grf = c->last_tmp;
+
+   return tmp;
+}
+
+static void release_tmp( struct brw_clip_compile *c, struct brw_reg tmp )
+{
+   if (tmp.nr == c->last_tmp-1)
+      c->last_tmp--;
+}
+
+
+static struct brw_reg make_plane_ud(GLuint x, GLuint y, GLuint z, GLuint w)
+{
+   return brw_imm_ud((w<<24) | (z<<16) | (y<<8) | x);
+}
+
+
+void brw_clip_init_planes( struct brw_clip_compile *c )
+{
+   struct brw_compile *p = &c->func;
+
+   if (!c->key.nr_userclip) {
+      brw_MOV(p, get_element_ud(c->reg.fixed_planes, 0), make_plane_ud( 0,    0, 0xff, 1));
+      brw_MOV(p, get_element_ud(c->reg.fixed_planes, 1), make_plane_ud( 0,    0,    1, 1));
+      brw_MOV(p, get_element_ud(c->reg.fixed_planes, 2), make_plane_ud( 0, 0xff,    0, 1));
+      brw_MOV(p, get_element_ud(c->reg.fixed_planes, 3), make_plane_ud( 0,    1,    0, 1));
+      brw_MOV(p, get_element_ud(c->reg.fixed_planes, 4), make_plane_ud(0xff,  0,    0, 1));
+      brw_MOV(p, get_element_ud(c->reg.fixed_planes, 5), make_plane_ud( 1,    0,    0, 1));
+   }
+}
+
+
+
+#define W 3
+
+/* Project 'pos' to screen space (or back again), overwrite with results:
+ */
+void brw_clip_project_position(struct brw_clip_compile *c, struct brw_reg pos )
+{
+   struct brw_compile *p = &c->func;
+
+   /* calc rhw 
+    */
+   brw_math_invert(p, get_element(pos, W), get_element(pos, W));
+
+   /* value.xyz *= value.rhw
+    */
+   brw_set_access_mode(p, BRW_ALIGN_16);
+   brw_MUL(p, brw_writemask(pos, BRW_WRITEMASK_XYZ), pos, brw_swizzle1(pos, W));
+   brw_set_access_mode(p, BRW_ALIGN_1);
+}
+
+
+static void brw_clip_project_vertex( struct brw_clip_compile *c, 
+                                    struct brw_indirect vert_addr )
+{
+   struct brw_compile *p = &c->func;
+   struct brw_reg tmp = get_tmp(c);
+
+   /* Fixup position.  Extract from the original vertex and re-project
+    * to screen space:
+    */
+   brw_MOV(p, tmp, deref_4f(vert_addr, c->offset_hpos));
+   brw_clip_project_position(c, tmp);
+   brw_MOV(p, deref_4f(vert_addr, c->header_position_offset), tmp);
+        
+   release_tmp(c, tmp);
+}
+
+
+
+
+/* Interpolate between two vertices and put the result into a0.0.  
+ * Increment a0.0 accordingly.
+ */
+void brw_clip_interp_vertex( struct brw_clip_compile *c,
+                            struct brw_indirect dest_ptr,
+                            struct brw_indirect v0_ptr, /* from */
+                            struct brw_indirect v1_ptr, /* to */
+                            struct brw_reg t0,
+                            GLboolean force_edgeflag)
+{
+   struct brw_compile *p = &c->func;
+   struct brw_reg tmp = get_tmp(c);
+   GLuint i;
+
+   /* Just copy the vertex header:
+    */
+   /*
+    * After CLIP stage, only first 256 bits of the VUE are read
+    * back on IGDNG, so needn't change it
+    */
+   brw_copy_indirect_to_indirect(p, dest_ptr, v0_ptr, 1);
+      
+   /* Iterate over each attribute (could be done in pairs?)
+    */
+   for (i = 0; i < c->key.nr_attrs; i++) {
+      GLuint delta = i*16 + 32;
+
+      if (c->chipset.is_igdng)
+          delta = i * 16 + 32 * 3;
+
+      if (delta == c->offset_edgeflag) {
+        if (force_edgeflag) 
+           brw_MOV(p, deref_4f(dest_ptr, delta), brw_imm_f(1));
+        else
+           brw_MOV(p, deref_4f(dest_ptr, delta), deref_4f(v0_ptr, delta));
+      }
+      else {
+        /* Interpolate: 
+         *
+         *        New = attr0 + t*attr1 - t*attr0
+         */
+        brw_MUL(p, 
+                vec4(brw_null_reg()),
+                deref_4f(v1_ptr, delta),
+                t0);
+
+        brw_MAC(p, 
+                tmp,         
+                negate(deref_4f(v0_ptr, delta)),
+                t0); 
+             
+        brw_ADD(p,
+                deref_4f(dest_ptr, delta), 
+                deref_4f(v0_ptr, delta),
+                tmp);
+      }
+   }
+
+   if (i & 1) {
+      GLuint delta = i*16 + 32;
+
+      if (c->chipset.is_igdng)
+          delta = i * 16 + 32 * 3;
+
+      brw_MOV(p, deref_4f(dest_ptr, delta), brw_imm_f(0));
+   }
+
+   release_tmp(c, tmp);
+
+   /* Recreate the projected (NDC) coordinate in the new vertex
+    * header:
+    */
+   brw_clip_project_vertex(c, dest_ptr );
+}
+
+
+
+
+#define MAX_MRF 16
+
+void brw_clip_emit_vue(struct brw_clip_compile *c, 
+                      struct brw_indirect vert,
+                      GLboolean allocate,
+                      GLboolean eot,
+                      GLuint header)
+{
+   struct brw_compile *p = &c->func;
+   GLuint start = c->last_mrf;
+
+   brw_clip_ff_sync(c);
+
+   assert(!(allocate && eot));
+   
+   /* Cycle through mrf regs - probably futile as we have to wait for
+    * the allocation response anyway.  Also, the order this function
+    * is invoked doesn't correspond to the order the instructions will
+    * be executed, so it won't have any effect in many cases.
+    */
+#if 0
+   if (start + c->nr_regs + 1 >= MAX_MRF)
+      start = 0;
+
+   c->last_mrf = start + c->nr_regs + 1;
+#endif
+       
+   /* Copy the vertex from vertn into m1..mN+1:
+    */
+   brw_copy_from_indirect(p, brw_message_reg(start+1), vert, c->nr_regs);
+
+   /* Overwrite PrimType and PrimStart in the message header, for
+    * each vertex in turn:
+    */
+   brw_MOV(p, get_element_ud(c->reg.R0, 2), brw_imm_ud(header));
+
+
+   /* Send each vertex as a seperate write to the urb.  This
+    * is different to the concept in brw_sf_emit.c, where
+    * subsequent writes are used to build up a single urb
+    * entry.  Each of these writes instantiates a seperate
+    * urb entry - (I think... what about 'allocate'?)
+    */
+   brw_urb_WRITE(p, 
+                allocate ? c->reg.R0 : retype(brw_null_reg(), BRW_REGISTER_TYPE_UD),
+                start,
+                c->reg.R0,
+                allocate,
+                1,             /* used */
+                c->nr_regs + 1, /* msg length */
+                allocate ? 1 : 0, /* response_length */ 
+                eot,           /* eot */
+                1,             /* writes_complete */
+                0,             /* urb offset */
+                BRW_URB_SWIZZLE_NONE);
+}
+
+
+
+void brw_clip_kill_thread(struct brw_clip_compile *c)
+{
+   struct brw_compile *p = &c->func;
+
+   brw_clip_ff_sync(c);
+   /* Send an empty message to kill the thread and release any
+    * allocated urb entry:
+    */
+   brw_urb_WRITE(p, 
+                retype(brw_null_reg(), BRW_REGISTER_TYPE_UD),
+                0,
+                c->reg.R0,
+                0,             /* allocate */
+                0,             /* used */
+                1,             /* msg len */
+                0,             /* response len */
+                1,             /* eot */
+                1,             /* writes complete */
+                0,
+                BRW_URB_SWIZZLE_NONE);
+}
+
+
+
+
+struct brw_reg brw_clip_plane0_address( struct brw_clip_compile *c )
+{
+   return brw_address(c->reg.fixed_planes);
+}
+
+
+struct brw_reg brw_clip_plane_stride( struct brw_clip_compile *c )
+{
+   if (c->key.nr_userclip) {
+      return brw_imm_uw(16);
+   }
+   else {
+      return brw_imm_uw(4);
+   }
+}
+
+
+/* If flatshading, distribute color from provoking vertex prior to
+ * clipping.
+ */
+void brw_clip_copy_colors( struct brw_clip_compile *c,
+                          GLuint to, GLuint from )
+{
+   struct brw_compile *p = &c->func;
+
+   if (c->offset_color0)
+      brw_MOV(p, 
+             byte_offset(c->reg.vertex[to], c->offset_color0),
+             byte_offset(c->reg.vertex[from], c->offset_color0));
+
+   if (c->offset_color1)
+      brw_MOV(p, 
+             byte_offset(c->reg.vertex[to], c->offset_color1),
+             byte_offset(c->reg.vertex[from], c->offset_color1));
+
+   if (c->offset_bfc0)
+      brw_MOV(p, 
+             byte_offset(c->reg.vertex[to], c->offset_bfc0),
+             byte_offset(c->reg.vertex[from], c->offset_bfc0));
+
+   if (c->offset_bfc1)
+      brw_MOV(p, 
+             byte_offset(c->reg.vertex[to], c->offset_bfc1),
+             byte_offset(c->reg.vertex[from], c->offset_bfc1));
+}
+
+
+
+void brw_clip_init_clipmask( struct brw_clip_compile *c )
+{
+   struct brw_compile *p = &c->func;
+   struct brw_reg incoming = get_element_ud(c->reg.R0, 2);
+   
+   /* Shift so that lowest outcode bit is rightmost: 
+    */
+   brw_SHR(p, c->reg.planemask, incoming, brw_imm_ud(26));
+
+   if (c->key.nr_userclip) {
+      struct brw_reg tmp = retype(vec1(get_tmp(c)), BRW_REGISTER_TYPE_UD);
+
+      /* Rearrange userclip outcodes so that they come directly after
+       * the fixed plane bits.
+       */
+      brw_AND(p, tmp, incoming, brw_imm_ud(0x3f<<14));
+      brw_SHR(p, tmp, tmp, brw_imm_ud(8));
+      brw_OR(p, c->reg.planemask, c->reg.planemask, tmp);
+      
+      release_tmp(c, tmp);
+   }
+}
+
+void brw_clip_ff_sync(struct brw_clip_compile *c)
+{
+    if (c->need_ff_sync) {
+        struct brw_compile *p = &c->func;
+        struct brw_instruction *need_ff_sync;
+
+        brw_set_conditionalmod(p, BRW_CONDITIONAL_Z);
+        brw_AND(p, brw_null_reg(), c->reg.ff_sync, brw_imm_ud(0x1));
+        need_ff_sync = brw_IF(p, BRW_EXECUTE_1);
+        {
+            brw_OR(p, c->reg.ff_sync, c->reg.ff_sync, brw_imm_ud(0x1));
+            brw_ff_sync(p, 
+                    c->reg.R0,
+                    0,
+                    c->reg.R0,
+                    1, 
+                    1,         /* used */
+                    1,         /* msg length */
+                    1,         /* response length */
+                    0,         /* eot */
+                    1,         /* write compelete */
+                    0,         /* urb offset */
+                    BRW_URB_SWIZZLE_NONE);
+        }
+        brw_ENDIF(p, need_ff_sync);
+        brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+    }
+}
+
+void brw_clip_init_ff_sync(struct brw_clip_compile *c)
+{
+    if (c->need_ff_sync) {
+       struct brw_compile *p = &c->func;
+        
+        brw_MOV(p, c->reg.ff_sync, brw_imm_ud(0));
+    }
+}
diff --git a/src/gallium/drivers/i965/brw_context.c b/src/gallium/drivers/i965/brw_context.c
new file mode 100644 (file)
index 0000000..e675518
--- /dev/null
@@ -0,0 +1,154 @@
+/*
+ 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 "pipe/p_context.h"
+#include "util/u_simple_list.h"
+
+#include "brw_context.h"
+#include "brw_defines.h"
+#include "brw_draw.h"
+#include "brw_state.h"
+#include "brw_batchbuffer.h"
+#include "brw_winsys.h"
+#include "brw_screen.h"
+
+
+static void brw_destroy_context( struct pipe_context *pipe )
+{
+   struct brw_context *brw = brw_context(pipe);
+   int i;
+
+   brw_context_flush( brw );
+   brw_batchbuffer_free( brw->batch );
+   brw_destroy_state(brw);
+
+   brw_draw_cleanup( brw );
+
+   brw_pipe_blend_cleanup( brw );
+   brw_pipe_depth_stencil_cleanup( brw );
+   brw_pipe_framebuffer_cleanup( brw );
+   brw_pipe_flush_cleanup( brw );
+   brw_pipe_misc_cleanup( brw );
+   brw_pipe_query_cleanup( brw );
+   brw_pipe_rast_cleanup( brw );
+   brw_pipe_sampler_cleanup( brw );
+   brw_pipe_shader_cleanup( brw );
+   brw_pipe_vertex_cleanup( brw );
+   brw_pipe_clear_cleanup( brw );
+
+   brw_hw_cc_cleanup( brw );
+
+
+   FREE(brw->wm.compile_data);
+
+   for (i = 0; i < brw->curr.fb.nr_cbufs; i++)
+      pipe_surface_reference(&brw->curr.fb.cbufs[i], NULL);
+   brw->curr.fb.nr_cbufs = 0;
+   pipe_surface_reference(&brw->curr.fb.zsbuf, NULL);
+
+   bo_reference(&brw->curbe.curbe_bo, NULL);
+   bo_reference(&brw->vs.prog_bo, NULL);
+   bo_reference(&brw->vs.state_bo, NULL);
+   bo_reference(&brw->vs.bind_bo, NULL);
+   bo_reference(&brw->gs.prog_bo, NULL);
+   bo_reference(&brw->gs.state_bo, NULL);
+   bo_reference(&brw->clip.prog_bo, NULL);
+   bo_reference(&brw->clip.state_bo, NULL);
+   bo_reference(&brw->clip.vp_bo, NULL);
+   bo_reference(&brw->sf.prog_bo, NULL);
+   bo_reference(&brw->sf.state_bo, NULL);
+   bo_reference(&brw->sf.vp_bo, NULL);
+
+   for (i = 0; i < Elements(brw->wm.sdc_bo); i++)
+      bo_reference(&brw->wm.sdc_bo[i], NULL);
+
+   bo_reference(&brw->wm.bind_bo, NULL);
+
+   for (i = 0; i < Elements(brw->wm.surf_bo); i++)
+      bo_reference(&brw->wm.surf_bo[i], NULL);
+
+   bo_reference(&brw->wm.sampler_bo, NULL);
+   bo_reference(&brw->wm.prog_bo, NULL);
+   bo_reference(&brw->wm.state_bo, NULL);
+}
+
+
+struct pipe_context *brw_create_context(struct pipe_screen *screen)
+{
+   struct brw_context *brw = (struct brw_context *) CALLOC_STRUCT(brw_context);
+
+   if (!brw) {
+      debug_printf("%s: failed to alloc context\n", __FUNCTION__);
+      return NULL;
+   }
+
+   brw->base.screen = screen;
+   brw->base.destroy = brw_destroy_context;
+   brw->sws = brw_screen(screen)->sws;
+   brw->chipset = brw_screen(screen)->chipset;
+
+   brw_pipe_blend_init( brw );
+   brw_pipe_depth_stencil_init( brw );
+   brw_pipe_framebuffer_init( brw );
+   brw_pipe_flush_init( brw );
+   brw_pipe_misc_init( brw );
+   brw_pipe_query_init( brw );
+   brw_pipe_rast_init( brw );
+   brw_pipe_sampler_init( brw );
+   brw_pipe_shader_init( brw );
+   brw_pipe_vertex_init( brw );
+   brw_pipe_clear_init( brw );
+
+   brw_hw_cc_init( brw );
+
+   brw_init_state( brw );
+   brw_draw_init( brw );
+
+   brw->state.dirty.mesa = ~0;
+   brw->state.dirty.brw = ~0;
+
+   brw->flags.always_emit_state = 0;
+
+   make_empty_list(&brw->query.active_head);
+
+   brw->batch = brw_batchbuffer_alloc( brw->sws, brw->chipset );
+   if (brw->batch == NULL)
+      goto fail;
+
+   return &brw->base;
+
+fail:
+   if (brw->batch)
+      brw_batchbuffer_free( brw->batch );
+   return NULL;
+}
+
diff --git a/src/gallium/drivers/i965/brw_context.h b/src/gallium/drivers/i965/brw_context.h
new file mode 100644 (file)
index 0000000..8c006bb
--- /dev/null
@@ -0,0 +1,858 @@
+/*
+ Copyright (C) Intel Corp.  2006.  All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ **********************************************************************/
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  */
+
+
+#ifndef BRWCONTEXT_INC
+#define BRWCONTEXT_INC
+
+#include "brw_structs.h"
+#include "brw_winsys.h"
+#include "brw_reg.h"
+#include "pipe/p_state.h"
+#include "pipe/p_context.h"
+#include "tgsi/tgsi_scan.h"
+
+
+/* Glossary:
+ *
+ * URB - uniform resource buffer.  A mid-sized buffer which is
+ * partitioned between the fixed function units and used for passing
+ * values (vertices, primitives, constants) between them.
+ *
+ * CURBE - constant URB entry.  An urb region (entry) used to hold
+ * constant values which the fixed function units can be instructed to
+ * preload into the GRF when spawning a thread.
+ *
+ * VUE - vertex URB entry.  An urb entry holding a vertex and usually
+ * a vertex header.  The header contains control information and
+ * things like primitive type, Begin/end flags and clip codes.  
+ *
+ * PUE - primitive URB entry.  An urb entry produced by the setup (SF)
+ * unit holding rasterization and interpolation parameters.
+ *
+ * GRF - general register file.  One of several register files
+ * addressable by programmed threads.  The inputs (r0, payload, curbe,
+ * urb) of the thread are preloaded to this area before the thread is
+ * spawned.  The registers are individually 8 dwords wide and suitable
+ * for general usage.  Registers holding thread input values are not
+ * special and may be overwritten.
+ *
+ * MRF - message register file.  Threads communicate (and terminate)
+ * by sending messages.  Message parameters are placed in contiguous
+ * MRF registers.  All program output is via these messages.  URB
+ * entries are populated by sending a message to the shared URB
+ * function containing the new data, together with a control word,
+ * often an unmodified copy of R0.
+ *
+ * R0 - GRF register 0.  Typically holds control information used when
+ * sending messages to other threads.
+ *
+ * EU or GEN4 EU: The name of the programmable subsystem of the
+ * i965 hardware.  Threads are executed by the EU, the registers
+ * described above are part of the EU architecture.
+ *
+ * Fixed function units:
+ *
+ * CS - Command streamer.  Notional first unit, little software
+ * interaction.  Holds the URB entries used for constant data, ie the
+ * CURBEs.
+ *
+ * VF/VS - Vertex Fetch / Vertex Shader.  The fixed function part of
+ * this unit is responsible for pulling vertices out of vertex buffers
+ * in vram and injecting them into the processing pipe as VUEs.  If
+ * enabled, it first passes them to a VS thread which is a good place
+ * for the driver to implement any active vertex shader.
+ *
+ * GS - Geometry Shader.  This corresponds to a new DX10 concept.  If
+ * enabled, incoming strips etc are passed to GS threads in individual
+ * line/triangle/point units.  The GS thread may perform arbitary
+ * computation and emit whatever primtives with whatever vertices it
+ * chooses.  This makes GS an excellent place to implement GL's
+ * unfilled polygon modes, though of course it is capable of much
+ * more.  Additionally, GS is used to translate away primitives not
+ * handled by latter units, including Quads and Lineloops.
+ *
+ * CS - Clipper.  Mesa's clipping algorithms are imported to run on
+ * this unit.  The fixed function part performs cliptesting against
+ * the 6 fixed clipplanes and makes decisions on whether or not the
+ * incoming primitive needs to be passed to a thread for clipping.
+ * User clip planes are handled via cooperation with the VS thread.
+ *
+ * SF - Strips Fans or Setup: Triangles are prepared for
+ * rasterization.  Interpolation coefficients are calculated.
+ * Flatshading and two-side lighting usually performed here.
+ *
+ * WM - Windower.  Interpolation of vertex attributes performed here.
+ * Fragment shader implemented here.  SIMD aspects of EU taken full
+ * advantage of, as pixels are processed in blocks of 16.
+ *
+ * CC - Color Calculator.  No EU threads associated with this unit.
+ * Handles blending and (presumably) depth and stencil testing.
+ */
+
+#define BRW_MAX_CURBE                    (32*16)
+
+
+/* Need a value to say a particular vertex shader output isn't
+ * present.  Limits us to 63 outputs currently.
+ */
+#define BRW_OUTPUT_NOT_PRESENT           ((1<<6)-1)
+
+
+struct brw_context;
+
+struct brw_depth_stencil_state {
+   /* Precalculated hardware state:
+    */
+   struct brw_cc0 cc0;
+   struct brw_cc1 cc1;
+   struct brw_cc2 cc2;
+   struct brw_cc3 cc3;
+   struct brw_cc7 cc7;
+
+   unsigned iz_lookup;
+};
+
+
+struct brw_blend_state {
+   /* Precalculated hardware state:
+    */
+   struct brw_cc2 cc2;
+   struct brw_cc3 cc3;
+   struct brw_cc5 cc5;
+   struct brw_cc6 cc6;
+
+   struct brw_surf_ss0 ss0;
+};
+
+
+struct brw_rasterizer_state;
+
+struct brw_immediate_data {
+   unsigned nr;
+   float (*data)[4];
+};
+
+struct brw_vertex_shader {
+   const struct tgsi_token *tokens;
+   struct brw_winsys_buffer *const_buffer;    /** Program constant buffer/surface */
+
+   struct tgsi_shader_info info;
+   struct brw_immediate_data immediates;
+
+   GLuint has_flow_control:1;
+   GLuint use_const_buffer:1;
+
+   /* Offsets of special vertex shader outputs required for clipping.
+    */
+   GLuint output_hpos:6;        /* not always zero? */
+   GLuint output_color0:6;
+   GLuint output_color1:6;
+   GLuint output_bfc0:6;
+   GLuint output_bfc1:6;
+   GLuint output_edgeflag:6;
+
+   unsigned id;
+};
+
+struct brw_fs_signature {
+   GLuint nr_inputs;
+   struct {
+      GLuint interp:3;          /* TGSI_INTERPOLATE_x */
+      GLuint semantic:5;        /* TGSI_SEMANTIC_x */
+      GLuint semantic_index:24;
+   } input[PIPE_MAX_SHADER_INPUTS];
+};
+
+#define brw_fs_signature_size(s) (offsetof(struct brw_fs_signature, input) + \
+                                  ((s)->nr_inputs * sizeof (s)->input[0])) 
+
+
+struct brw_fragment_shader {
+   const struct tgsi_token *tokens;
+   struct tgsi_shader_info info;
+
+   struct brw_fs_signature signature;
+   struct brw_immediate_data immediates;
+
+   unsigned iz_lookup;
+   /*unsigned wm_lookup;*/
+   
+   unsigned  uses_depth:1;
+   unsigned  has_flow_control:1;
+
+   unsigned id;
+   struct brw_winsys_buffer *const_buffer;    /** Program constant buffer/surface */
+   GLboolean use_const_buffer;
+};
+
+
+struct brw_sampler {
+   struct brw_ss0 ss0;
+   struct brw_ss1 ss1;
+   float border_color[4];
+   struct brw_ss3 ss3;
+};
+
+
+
+#define PIPE_NEW_DEPTH_STENCIL_ALPHA    0x1
+#define PIPE_NEW_RAST                   0x2
+#define PIPE_NEW_BLEND                  0x4
+#define PIPE_NEW_VIEWPORT               0x8
+#define PIPE_NEW_SAMPLERS               0x10
+#define PIPE_NEW_VERTEX_BUFFER          0x20
+#define PIPE_NEW_VERTEX_ELEMENT         0x40
+#define PIPE_NEW_FRAGMENT_SHADER        0x80
+#define PIPE_NEW_VERTEX_SHADER          0x100
+#define PIPE_NEW_FRAGMENT_CONSTANTS     0x200
+#define PIPE_NEW_VERTEX_CONSTANTS       0x400
+#define PIPE_NEW_CLIP                   0x800
+#define PIPE_NEW_INDEX_BUFFER           0x1000
+#define PIPE_NEW_INDEX_RANGE            0x2000
+#define PIPE_NEW_BLEND_COLOR            0x4000
+#define PIPE_NEW_POLYGON_STIPPLE        0x8000
+#define PIPE_NEW_FRAMEBUFFER_DIMENSIONS 0x10000
+#define PIPE_NEW_DEPTH_BUFFER           0x20000
+#define PIPE_NEW_COLOR_BUFFERS          0x40000
+#define PIPE_NEW_QUERY                  0x80000
+#define PIPE_NEW_SCISSOR                0x100000
+#define PIPE_NEW_BOUND_TEXTURES         0x200000
+#define PIPE_NEW_NR_CBUFS               0x400000
+#define PIPE_NEW_FRAGMENT_SIGNATURE     0x800000
+
+
+
+#define BRW_NEW_URB_FENCE               0x1
+#define BRW_NEW_FRAGMENT_PROGRAM        0x2
+#define BRW_NEW_VERTEX_PROGRAM          0x4
+#define BRW_NEW_INPUT_DIMENSIONS        0x8
+#define BRW_NEW_CURBE_OFFSETS           0x10
+#define BRW_NEW_REDUCED_PRIMITIVE       0x20
+#define BRW_NEW_PRIMITIVE               0x40
+#define BRW_NEW_CONTEXT                 0x80
+#define BRW_NEW_WM_INPUT_DIMENSIONS     0x100
+#define BRW_NEW_PSP                     0x800
+#define BRW_NEW_WM_SURFACES            0x1000
+#define BRW_NEW_xxx                     0x2000 /* was FENCE */
+#define BRW_NEW_INDICES                        0x4000
+
+/**
+ * Used for any batch entry with a relocated pointer that will be used
+ * by any 3D rendering.  Need to re-emit these fresh in each
+ * batchbuffer as the referenced buffers may be relocated in the
+ * meantime.
+ */
+#define BRW_NEW_BATCH                  0x10000
+#define BRW_NEW_NR_WM_SURFACES         0x40000
+#define BRW_NEW_NR_VS_SURFACES         0x80000
+#define BRW_NEW_INDEX_BUFFER           0x100000
+
+struct brw_state_flags {
+   /** State update flags signalled by mesa internals */
+   GLuint mesa;
+   /**
+    * State update flags signalled as the result of brw_tracked_state updates
+    */
+   GLuint brw;
+   /** State update flags signalled by brw_state_cache.c searches */
+   GLuint cache;
+};
+
+
+
+/* Data about a particular attempt to compile a program.  Note that
+ * there can be many of these, each in a different GL state
+ * corresponding to a different brw_wm_prog_key struct, with different
+ * compiled programs:
+ */
+struct brw_wm_prog_data {
+   GLuint curb_read_length;
+   GLuint urb_read_length;
+
+   GLuint first_curbe_grf;
+   GLuint total_grf;
+   GLuint total_scratch;
+
+   GLuint nr_params;       /**< number of float params/constants */
+   GLboolean error;
+
+   /* Pointer to tracked values (only valid once
+    * _mesa_load_state_parameters has been called at runtime).
+    */
+   const GLfloat *param[BRW_MAX_CURBE];
+};
+
+struct brw_sf_prog_data {
+   GLuint urb_read_length;
+   GLuint total_grf;
+
+   /* Each vertex may have upto 12 attributes, 4 components each,
+    * except WPOS which requires only 2.  (11*4 + 2) == 44 ==> 11
+    * rows.
+    *
+    * Actually we use 4 for each, so call it 12 rows.
+    */
+   GLuint urb_entry_size;
+};
+
+
+struct brw_clip_prog_data;
+
+struct brw_gs_prog_data {
+   GLuint urb_read_length;
+   GLuint total_grf;
+};
+
+struct brw_vs_prog_data {
+   GLuint curb_read_length;
+   GLuint urb_read_length;
+   GLuint total_grf;
+
+   GLuint nr_outputs;
+   GLuint nr_inputs;
+
+   GLuint nr_params;       /**< number of TGSI_FILE_CONSTANT's */
+
+   GLboolean writes_psiz;
+
+   /* Used for calculating urb partitions:
+    */
+   GLuint urb_entry_size;
+};
+
+
+/* Size == 0 if output either not written, or always [0,0,0,1]
+ */
+struct brw_vs_ouput_sizes {
+   GLubyte output_size[PIPE_MAX_SHADER_OUTPUTS];
+};
+
+
+/** Number of texture sampler units */
+#define BRW_MAX_TEX_UNIT 16
+
+/** Max number of render targets in a shader */
+#define BRW_MAX_DRAW_BUFFERS 4
+
+/**
+ * Size of our surface binding table for the WM.
+ * This contains pointers to the drawing surfaces and current texture
+ * objects and shader constant buffers (+2).
+ */
+#define BRW_WM_MAX_SURF (BRW_MAX_DRAW_BUFFERS + BRW_MAX_TEX_UNIT + 1)
+
+/**
+ * Helpers to convert drawing buffers, textures and constant buffers
+ * to surface binding table indexes, for WM.
+ */
+#define BTI_COLOR_BUF(d)          (d)
+#define BTI_FRAGMENT_CONSTANTS    (BRW_MAX_DRAW_BUFFERS) 
+#define BTI_TEXTURE(t)            (BRW_MAX_DRAW_BUFFERS + 1 + (t))
+
+/**
+ * Size of surface binding table for the VS.
+ * Only one constant buffer for now.
+ */
+#define BRW_VS_MAX_SURF 1
+
+/**
+ * Only a VS constant buffer
+ */
+#define SURF_INDEX_VERT_CONST_BUFFER 0
+
+
+/* Bit of a hack to align these with the winsys buffer_data_type enum.
+ */
+enum brw_cache_id {
+   BRW_CC_VP         = BRW_DATA_GS_CC_VP,
+   BRW_CC_UNIT       = BRW_DATA_GS_CC_UNIT,
+   BRW_WM_PROG       = BRW_DATA_GS_WM_PROG,
+   BRW_SAMPLER_DEFAULT_COLOR    = BRW_DATA_GS_SAMPLER_DEFAULT_COLOR,
+   BRW_SAMPLER       = BRW_DATA_GS_SAMPLER,
+   BRW_WM_UNIT       = BRW_DATA_GS_WM_UNIT,
+   BRW_SF_PROG       = BRW_DATA_GS_SF_PROG,
+   BRW_SF_VP         = BRW_DATA_GS_SF_VP,
+   BRW_SF_UNIT       = BRW_DATA_GS_SF_UNIT,
+   BRW_VS_UNIT       = BRW_DATA_GS_VS_UNIT,
+   BRW_VS_PROG       = BRW_DATA_GS_VS_PROG,
+   BRW_GS_UNIT       = BRW_DATA_GS_GS_UNIT,
+   BRW_GS_PROG       = BRW_DATA_GS_GS_PROG,
+   BRW_CLIP_VP       = BRW_DATA_GS_CLIP_VP,
+   BRW_CLIP_UNIT     = BRW_DATA_GS_CLIP_UNIT,
+   BRW_CLIP_PROG     = BRW_DATA_GS_CLIP_PROG,
+   BRW_SS_SURFACE    = BRW_DATA_SS_SURFACE,
+   BRW_SS_SURF_BIND  = BRW_DATA_SS_SURF_BIND,
+
+   BRW_MAX_CACHE
+};
+
+struct brw_cache_item {
+   /**
+    * Effectively part of the key, cache_id identifies what kind of state
+    * buffer is involved, and also which brw->state.dirty.cache flag should
+    * be set when this cache item is chosen.
+    */
+   enum brw_cache_id cache_id;
+   /** 32-bit hash of the key data */
+   GLuint hash;
+   GLuint key_size;            /* for variable-sized keys */
+   const void *key;
+   struct brw_winsys_reloc *relocs;
+   GLuint nr_relocs;
+
+   struct brw_winsys_buffer *bo;
+   GLuint data_size;
+
+   struct brw_cache_item *next;
+};   
+
+
+
+struct brw_cache {
+   struct brw_context *brw;
+   struct brw_winsys_screen *sws;
+
+   struct brw_cache_item **items;
+   GLuint size, n_items;
+
+   enum brw_buffer_type buffer_type;
+
+   GLuint key_size[BRW_MAX_CACHE];             /* for fixed-size keys */
+   GLuint aux_size[BRW_MAX_CACHE];
+   char *name[BRW_MAX_CACHE];
+   
+
+   /* Record of the last BOs chosen for each cache_id.  Used to set
+    * brw->state.dirty.cache when a new cache item is chosen.
+    */
+   struct brw_winsys_buffer *last_bo[BRW_MAX_CACHE];
+};
+
+
+struct brw_tracked_state {
+   struct brw_state_flags dirty;
+   int (*prepare)( struct brw_context *brw );
+   int (*emit)( struct brw_context *brw );
+};
+
+/* Flags for brw->state.cache.
+ */
+#define CACHE_NEW_CC_VP                  (1<<BRW_CC_VP)
+#define CACHE_NEW_CC_UNIT                (1<<BRW_CC_UNIT)
+#define CACHE_NEW_WM_PROG                (1<<BRW_WM_PROG)
+#define CACHE_NEW_SAMPLER_DEFAULT_COLOR  (1<<BRW_SAMPLER_DEFAULT_COLOR)
+#define CACHE_NEW_SAMPLER                (1<<BRW_SAMPLER)
+#define CACHE_NEW_WM_UNIT                (1<<BRW_WM_UNIT)
+#define CACHE_NEW_SF_PROG                (1<<BRW_SF_PROG)
+#define CACHE_NEW_SF_VP                  (1<<BRW_SF_VP)
+#define CACHE_NEW_SF_UNIT                (1<<BRW_SF_UNIT)
+#define CACHE_NEW_VS_UNIT                (1<<BRW_VS_UNIT)
+#define CACHE_NEW_VS_PROG                (1<<BRW_VS_PROG)
+#define CACHE_NEW_GS_UNIT                (1<<BRW_GS_UNIT)
+#define CACHE_NEW_GS_PROG                (1<<BRW_GS_PROG)
+#define CACHE_NEW_CLIP_VP                (1<<BRW_CLIP_VP)
+#define CACHE_NEW_CLIP_UNIT              (1<<BRW_CLIP_UNIT)
+#define CACHE_NEW_CLIP_PROG              (1<<BRW_CLIP_PROG)
+#define CACHE_NEW_SURFACE                (1<<BRW_SS_SURFACE)
+#define CACHE_NEW_SURF_BIND              (1<<BRW_SS_SURF_BIND)
+
+struct brw_cached_batch_item {
+   struct header *header;
+   GLuint sz;
+   struct brw_cached_batch_item *next;
+};
+   
+
+
+/* Protect against a future where VERT_ATTRIB_MAX > 32.  Wouldn't life
+ * be easier if C allowed arrays of packed elements?
+ */
+#define VS_INPUT_BITMASK_DWORDS  ((PIPE_MAX_SHADER_INPUTS+31)/32)
+
+
+
+
+struct brw_vertex_info {
+   GLuint sizes[VS_INPUT_BITMASK_DWORDS * 2]; /* sizes:2[VERT_ATTRIB_MAX] */
+};
+
+
+struct brw_query_object {
+   /** Doubly linked list of active query objects in the context. */
+   struct brw_query_object *prev, *next;
+
+   /** Last query BO associated with this query. */
+   struct brw_winsys_buffer *bo;
+   /** First index in bo with query data for this object. */
+   int first_index;
+   /** Last index in bo with query data for this object. */
+   int last_index;
+
+   /* Total count of pixels from previous BOs */
+   uint64_t result;
+};
+
+#define CC_RELOC_VP 0
+
+
+/**
+ * brw_context is derived from pipe_context
+ */
+struct brw_context 
+{
+   struct pipe_context base;
+   struct brw_chipset chipset;
+
+   struct brw_winsys_screen *sws;
+
+   struct brw_batchbuffer *batch;
+
+   GLuint primitive;
+   GLuint reduced_primitive;
+
+   /* Active state from the state tracker: 
+    */
+   struct {
+      struct brw_vertex_shader *vertex_shader;
+      struct brw_fragment_shader *fragment_shader;
+      const struct brw_blend_state *blend;
+      const struct brw_rasterizer_state *rast;
+      const struct brw_depth_stencil_state *zstencil;
+
+      const struct brw_sampler *sampler[PIPE_MAX_SAMPLERS];
+      unsigned num_samplers;
+
+      struct pipe_texture *texture[PIPE_MAX_SAMPLERS];
+      struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
+      struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS];
+      unsigned num_vertex_elements;
+      unsigned num_textures;
+      unsigned num_vertex_buffers;
+
+      struct pipe_scissor_state scissor;
+      struct pipe_viewport_state viewport;
+      struct pipe_framebuffer_state fb;
+      struct pipe_clip_state ucp;
+      struct pipe_buffer *vertex_constants;
+      struct pipe_buffer *fragment_constants;
+
+      struct brw_blend_constant_color bcc;
+      struct brw_polygon_stipple bps;
+      struct brw_cc_viewport ccv;
+
+      /**
+       * Index buffer for this draw_prims call.
+       *
+       * Updates are signaled by PIPE_NEW_INDEX_BUFFER.
+       */
+      struct pipe_buffer *index_buffer;
+      unsigned index_size;
+
+      /* Updates are signalled by PIPE_NEW_INDEX_RANGE:
+       */
+      unsigned min_index;
+      unsigned max_index;
+
+   } curr;
+
+   struct {
+      struct brw_state_flags dirty;
+
+      /**
+       * List of buffers accumulated in brw_validate_state to receive
+       * dri_bo_check_aperture treatment before exec, so we can know if we
+       * should flush the batch and try again before emitting primitives.
+       *
+       * This can be a fixed number as we only have a limited number of
+       * objects referenced from the batchbuffer in a primitive emit,
+       * consisting of the vertex buffers, pipelined state pointers,
+       * the CURBE, the depth buffer, and a query BO.
+       */
+      struct brw_winsys_buffer *validated_bos[PIPE_MAX_SHADER_INPUTS + 16];
+      int validated_bo_count;
+   } state;
+
+   struct brw_cache cache;  /** non-surface items */
+   struct brw_cache surface_cache;  /* surface items */
+   struct brw_cached_batch_item *cached_batch_items;
+
+   struct {
+      struct u_upload_mgr *upload_vertex;
+      struct u_upload_mgr *upload_index;
+      
+      /* Information on uploaded vertex buffers:
+       */
+      struct {
+        unsigned stride;       /* in bytes between successive vertices */
+        unsigned offset;       /* in bytes, of first vertex in bo */
+        unsigned vertex_count; /* count of valid vertices which may be accessed */
+        struct brw_winsys_buffer *bo;
+      } vb[PIPE_MAX_ATTRIBS];
+
+      unsigned nr_vb;          /* currently the same as curr.num_vertex_buffers */
+   } vb;
+
+   struct {
+      /* Updates to these fields are signaled by BRW_NEW_INDEX_BUFFER. */
+      struct brw_winsys_buffer *bo;
+      unsigned int offset;
+      unsigned int size;
+      /* Offset to index buffer index to use in CMD_3D_PRIM so that we can
+       * avoid re-uploading the IB packet over and over if we're actually
+       * referencing the same index buffer.
+       */
+      unsigned int start_vertex_offset;
+   } ib;
+
+
+   /* BRW_NEW_URB_ALLOCATIONS:
+    */
+   struct {
+      GLuint vsize;            /* vertex size plus header in urb registers */
+      GLuint csize;            /* constant buffer size in urb registers */
+      GLuint sfsize;           /* setup data size in urb registers */
+
+      GLboolean constrained;
+
+      GLuint nr_vs_entries;
+      GLuint nr_gs_entries;
+      GLuint nr_clip_entries;
+      GLuint nr_sf_entries;
+      GLuint nr_cs_entries;
+
+      GLuint vs_start;
+      GLuint gs_start;
+      GLuint clip_start;
+      GLuint sf_start;
+      GLuint cs_start;
+   } urb;
+
+   
+   /* BRW_NEW_CURBE_OFFSETS: 
+    */
+   struct {
+      GLuint wm_start;  /**< pos of first wm const in CURBE buffer */
+      GLuint wm_size;   /**< number of float[4] consts, multiple of 16 */
+      GLuint clip_start;
+      GLuint clip_size;
+      GLuint vs_start;
+      GLuint vs_size;
+      GLuint total_size;
+
+      struct brw_winsys_buffer *curbe_bo;
+      /** Offset within curbe_bo of space for current curbe entry */
+      GLuint curbe_offset;
+      /** Offset within curbe_bo of space for next curbe entry */
+      GLuint curbe_next_offset;
+
+      GLfloat *last_buf;
+      GLuint last_bufsz;
+      /**
+       *  Whether we should create a new bo instead of reusing the old one
+       * (if we just dispatch the batch pointing at the old one.
+       */
+      GLboolean need_new_bo;
+   } curbe;
+
+   struct {
+      struct brw_vs_prog_data *prog_data;
+
+      struct brw_winsys_buffer *prog_bo;
+      struct brw_winsys_buffer *state_bo;
+
+      /** Binding table of pointers to surf_bo entries */
+      struct brw_winsys_buffer *bind_bo;
+      struct brw_winsys_buffer *surf_bo[BRW_VS_MAX_SURF];
+      GLuint nr_surfaces;      
+   } vs;
+
+   struct {
+      struct brw_gs_prog_data *prog_data;
+
+      GLboolean prog_active;
+      struct brw_winsys_buffer *prog_bo;
+      struct brw_winsys_buffer *state_bo;
+   } gs;
+
+   struct {
+      struct brw_clip_prog_data *prog_data;
+
+      struct brw_winsys_buffer *prog_bo;
+      struct brw_winsys_buffer *state_bo;
+      struct brw_winsys_buffer *vp_bo;
+   } clip;
+
+
+   struct {
+      struct brw_sf_prog_data *prog_data;
+
+      struct brw_winsys_buffer *prog_bo;
+      struct brw_winsys_buffer *state_bo;
+      struct brw_winsys_buffer *vp_bo;
+   } sf;
+
+   struct {
+      struct brw_wm_prog_data *prog_data;
+      struct brw_wm_compile *compile_data;
+
+      /** Input sizes, calculated from active vertex program.
+       * One bit per fragment program input attribute.
+       */
+      /*GLbitfield input_size_masks[4];*/
+
+      /** Array of surface default colors (texture border color) */
+      struct brw_winsys_buffer *sdc_bo[BRW_MAX_TEX_UNIT];
+
+      GLuint render_surf;
+      GLuint nr_surfaces;      
+
+      GLuint max_threads;
+      struct brw_winsys_buffer *scratch_bo;
+
+      GLuint sampler_count;
+      struct brw_winsys_buffer *sampler_bo;
+
+      /** Binding table of pointers to surf_bo entries */
+      struct brw_winsys_buffer *bind_bo;
+      struct brw_winsys_buffer *surf_bo[BRW_WM_MAX_SURF];
+
+      struct brw_winsys_buffer *prog_bo;
+      struct brw_winsys_buffer *state_bo;
+   } wm;
+
+
+   struct {
+      struct brw_winsys_buffer *state_bo;
+
+      struct brw_cc_unit_state cc;
+      struct brw_winsys_reloc reloc[1];
+   } cc;
+
+   struct {
+      struct brw_query_object active_head;
+      struct brw_winsys_buffer *bo;
+      int index;
+      GLboolean active;
+      int stats_wm;
+   } query;
+
+   struct {
+      unsigned always_emit_state:1;
+      unsigned always_flush_batch:1;
+      unsigned force_swtnl:1;
+      unsigned no_swtnl:1;
+   } flags;
+
+   /* Used to give every program string a unique id
+    */
+   GLuint program_id;
+};
+
+
+
+/*======================================================================
+ * brw_queryobj.c
+ */
+void brw_init_query(struct brw_context *brw);
+enum pipe_error brw_prepare_query_begin(struct brw_context *brw);
+void brw_emit_query_begin(struct brw_context *brw);
+void brw_emit_query_end(struct brw_context *brw);
+
+/*======================================================================
+ * brw_state_dump.c
+ */
+void brw_debug_batch(struct brw_context *intel);
+
+
+/*======================================================================
+ * brw_pipe_*.c
+ */
+void brw_pipe_blend_init( struct brw_context *brw );
+void brw_pipe_depth_stencil_init( struct brw_context *brw );
+void brw_pipe_framebuffer_init( struct brw_context *brw );
+void brw_pipe_flush_init( struct brw_context *brw );
+void brw_pipe_misc_init( struct brw_context *brw );
+void brw_pipe_query_init( struct brw_context *brw );
+void brw_pipe_rast_init( struct brw_context *brw );
+void brw_pipe_sampler_init( struct brw_context *brw );
+void brw_pipe_shader_init( struct brw_context *brw );
+void brw_pipe_vertex_init( struct brw_context *brw );
+void brw_pipe_clear_init( struct brw_context *brw );
+
+
+void brw_pipe_blend_cleanup( struct brw_context *brw );
+void brw_pipe_depth_stencil_cleanup( struct brw_context *brw );
+void brw_pipe_framebuffer_cleanup( struct brw_context *brw );
+void brw_pipe_flush_cleanup( struct brw_context *brw );
+void brw_pipe_misc_cleanup( struct brw_context *brw );
+void brw_pipe_query_cleanup( struct brw_context *brw );
+void brw_pipe_rast_cleanup( struct brw_context *brw );
+void brw_pipe_sampler_cleanup( struct brw_context *brw );
+void brw_pipe_shader_cleanup( struct brw_context *brw );
+void brw_pipe_vertex_cleanup( struct brw_context *brw );
+void brw_pipe_clear_cleanup( struct brw_context *brw );
+
+void brw_hw_cc_init( struct brw_context *brw );
+void brw_hw_cc_cleanup( struct brw_context *brw );
+
+
+
+void brw_context_flush( struct brw_context *brw );
+
+
+/* brw_urb.c
+ */
+int brw_upload_urb_fence(struct brw_context *brw);
+
+/* brw_curbe.c
+ */
+int brw_upload_cs_urb_state(struct brw_context *brw);
+
+
+/*======================================================================
+ * Inline conversion functions.  These are better-typed than the
+ * macros used previously:
+ */
+static INLINE struct brw_context *
+brw_context( struct pipe_context *ctx )
+{
+   return (struct brw_context *)ctx;
+}
+
+
+#define BRW_IS_965(brw)    ((brw)->chipset.is_965)
+#define BRW_IS_IGDNG(brw)  ((brw)->chipset.is_igdng)
+#define BRW_IS_G4X(brw)    ((brw)->chipset.is_g4x)
+
+
+#endif
+
diff --git a/src/gallium/drivers/i965/brw_curbe.c b/src/gallium/drivers/i965/brw_curbe.c
new file mode 100644 (file)
index 0000000..3f03157
--- /dev/null
@@ -0,0 +1,390 @@
+/*
+ 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 "util/u_memory.h"
+#include "util/u_math.h"
+
+#include "brw_batchbuffer.h"
+#include "brw_context.h"
+#include "brw_defines.h"
+#include "brw_state.h"
+#include "brw_util.h"
+#include "brw_debug.h"
+#include "brw_screen.h"
+
+
+/**
+ * Partition the CURBE between the various users of constant values:
+ * Note that vertex and fragment shaders can now fetch constants out
+ * of constant buffers.  We no longer allocatea block of the GRF for
+ * constants.  That greatly reduces the demand for space in the CURBE.
+ * Some of the comments within are dated...
+ */
+static int calculate_curbe_offsets( struct brw_context *brw )
+{
+   /* CACHE_NEW_WM_PROG */
+   const GLuint nr_fp_regs = brw->wm.prog_data->curb_read_length;
+   
+   /* BRW_NEW_VERTEX_PROGRAM */
+   const GLuint nr_vp_regs = brw->vs.prog_data->curb_read_length;
+   GLuint nr_clip_regs = 0;
+   GLuint total_regs;
+
+   /* PIPE_NEW_CLIP */
+   if (brw->curr.ucp.nr) {
+      GLuint nr_planes = 6 + brw->curr.ucp.nr;
+      nr_clip_regs = (nr_planes * 4 + 15) / 16;
+   }
+
+
+   total_regs = nr_fp_regs + nr_vp_regs + nr_clip_regs;
+
+   /* When this is > 32, want to use a true constant buffer to hold
+    * the extra constants.
+    */
+   assert(total_regs <= 32);
+
+   /* Lazy resize:
+    */
+   if (nr_fp_regs > brw->curbe.wm_size ||
+       nr_vp_regs > brw->curbe.vs_size ||
+       nr_clip_regs != brw->curbe.clip_size ||
+       (total_regs < brw->curbe.total_size / 4 &&
+       brw->curbe.total_size > 16)) {
+
+      GLuint reg = 0;
+
+      /* Calculate a new layout: 
+       */
+      reg = 0;
+      brw->curbe.wm_start = reg;
+      brw->curbe.wm_size = nr_fp_regs; reg += nr_fp_regs;
+      brw->curbe.clip_start = reg;
+      brw->curbe.clip_size = nr_clip_regs; reg += nr_clip_regs;
+      brw->curbe.vs_start = reg;
+      brw->curbe.vs_size = nr_vp_regs; reg += nr_vp_regs;
+      brw->curbe.total_size = reg;
+
+      if (BRW_DEBUG & DEBUG_CURBE)
+        debug_printf("curbe wm %d+%d clip %d+%d vs %d+%d\n",
+                     brw->curbe.wm_start,
+                     brw->curbe.wm_size,
+                     brw->curbe.clip_start,
+                     brw->curbe.clip_size,
+                     brw->curbe.vs_start,
+                     brw->curbe.vs_size );
+
+      brw->state.dirty.brw |= BRW_NEW_CURBE_OFFSETS;
+   }
+
+   return 0;
+}
+
+
+const struct brw_tracked_state brw_curbe_offsets = {
+   .dirty = {
+      .mesa = PIPE_NEW_CLIP,
+      .brw  = BRW_NEW_VERTEX_PROGRAM,
+      .cache = CACHE_NEW_WM_PROG
+   },
+   .prepare = calculate_curbe_offsets
+};
+
+
+
+
+/* Define the number of curbes within CS's urb allocation.  Multiple
+ * urb entries -> multiple curbes.  These will be used by
+ * fixed-function hardware in a double-buffering scheme to avoid a
+ * pipeline stall each time the contents of the curbe is changed.
+ */
+int brw_upload_cs_urb_state(struct brw_context *brw)
+{
+   struct brw_cs_urb_state cs_urb;
+   memset(&cs_urb, 0, sizeof(cs_urb));
+
+   /* It appears that this is the state packet for the CS unit, ie. the
+    * urb entries detailed here are housed in the CS range from the
+    * URB_FENCE command.
+    */
+   cs_urb.header.opcode = CMD_CS_URB_STATE;
+   cs_urb.header.length = sizeof(cs_urb)/4 - 2;
+
+   /* BRW_NEW_URB_FENCE */
+   cs_urb.bits0.nr_urb_entries = brw->urb.nr_cs_entries;
+   cs_urb.bits0.urb_entry_size = brw->urb.csize - 1;
+
+   assert(brw->urb.nr_cs_entries);
+   BRW_CACHED_BATCH_STRUCT(brw, &cs_urb);
+   return 0;
+}
+
+static GLfloat fixed_plane[6][4] = {
+   { 0,    0,   -1, 1 },
+   { 0,    0,    1, 1 },
+   { 0,   -1,    0, 1 },
+   { 0,    1,    0, 1 },
+   {-1,    0,    0, 1 },
+   { 1,    0,    0, 1 }
+};
+
+/* Upload a new set of constants.  Too much variability to go into the
+ * cache mechanism, but maybe would benefit from a comparison against
+ * the current uploaded set of constants.
+ */
+static enum pipe_error prepare_curbe_buffer(struct brw_context *brw)
+{
+   struct pipe_screen *screen = brw->base.screen;
+   const GLuint sz = brw->curbe.total_size;
+   const GLuint bufsz = sz * 16 * sizeof(GLfloat);
+   enum pipe_error ret;
+   GLfloat *buf;
+   GLuint i;
+
+   if (sz == 0) {
+      if (brw->curbe.last_buf) {
+        free(brw->curbe.last_buf);
+        brw->curbe.last_buf = NULL;
+        brw->curbe.last_bufsz  = 0;
+      }
+      return 0;
+   }
+
+   buf = (GLfloat *) CALLOC(bufsz, 1);
+
+   /* fragment shader constants */
+   if (brw->curbe.wm_size) {
+      const struct brw_fragment_shader *fs = brw->curr.fragment_shader;
+      GLuint offset = brw->curbe.wm_start * 16;
+      GLuint nr_immediate, nr_const;
+
+      nr_immediate = fs->immediates.nr;
+      if (nr_immediate) {
+         memcpy(&buf[offset], 
+                fs->immediates.data,
+                nr_immediate * 4 * sizeof(float));
+
+         offset += nr_immediate * 4;
+      }
+
+      nr_const = fs->info.file_max[TGSI_FILE_CONSTANT] + 1;
+/*      nr_const = brw->wm.prog_data->nr_params; */
+      if (nr_const) {
+         const GLfloat *value = screen->buffer_map( screen,
+                                                    brw->curr.fragment_constants,
+                                                    PIPE_BUFFER_USAGE_CPU_READ);
+
+         memcpy(&buf[offset], value,
+                nr_const * 4 * sizeof(float));
+         
+         screen->buffer_unmap( screen, 
+                               brw->curr.fragment_constants );
+      }
+   }
+
+
+   /* The clipplanes are actually delivered to both CLIP and VS units.
+    * VS uses them to calculate the outcode bitmasks.
+    */
+   if (brw->curbe.clip_size) {
+      GLuint offset = brw->curbe.clip_start * 16;
+      GLuint j;
+
+      /* If any planes are going this way, send them all this way:
+       */
+      for (i = 0; i < 6; i++) {
+        buf[offset + i * 4 + 0] = fixed_plane[i][0];
+        buf[offset + i * 4 + 1] = fixed_plane[i][1];
+        buf[offset + i * 4 + 2] = fixed_plane[i][2];
+        buf[offset + i * 4 + 3] = fixed_plane[i][3];
+      }
+
+      /* Clip planes:
+       */
+      assert(brw->curr.ucp.nr <= 6);
+      for (j = 0; j < brw->curr.ucp.nr; j++) {
+        buf[offset + i * 4 + 0] = brw->curr.ucp.ucp[j][0];
+        buf[offset + i * 4 + 1] = brw->curr.ucp.ucp[j][1];
+        buf[offset + i * 4 + 2] = brw->curr.ucp.ucp[j][2];
+        buf[offset + i * 4 + 3] = brw->curr.ucp.ucp[j][3];
+        i++;
+      }
+   }
+
+   /* vertex shader constants */
+   if (brw->curbe.vs_size) {
+      GLuint offset = brw->curbe.vs_start * 16;
+      const struct brw_vertex_shader *vs = brw->curr.vertex_shader;
+      GLuint nr_immediate, nr_const;
+
+      nr_immediate = vs->immediates.nr;
+      if (nr_immediate) {
+         memcpy(&buf[offset], 
+                vs->immediates.data,
+                nr_immediate * 4 * sizeof(float));
+
+         offset += nr_immediate * 4;
+      }
+
+      nr_const = vs->info.file_max[TGSI_FILE_CONSTANT] + 1;
+      if (nr_const) {
+         /* XXX: note that constant buffers are currently *already* in
+          * buffer objects.  If we want to keep on putting them into the
+          * curbe, makes sense to treat constbuf's specially with malloc.
+          */
+         const GLfloat *value = screen->buffer_map( screen,
+                                                    brw->curr.vertex_constants,
+                                                    PIPE_BUFFER_USAGE_CPU_READ);
+         
+         /* XXX: what if user's constant buffer is too small?
+          */
+         memcpy(&buf[offset], value, nr_const * 4 * sizeof(float));
+         
+         screen->buffer_unmap( screen, brw->curr.vertex_constants );
+      }
+   }
+
+   if (BRW_DEBUG & DEBUG_CURBE) {
+      for (i = 0; i < sz*16; i+=4) 
+        debug_printf("curbe %d.%d: %f %f %f %f\n", i/8, i&4,
+                     buf[i+0], buf[i+1], buf[i+2], buf[i+3]);
+
+      debug_printf("last_buf %p buf %p sz %d/%d cmp %d\n",
+                  (void *)brw->curbe.last_buf, (void *)buf,
+                  bufsz, brw->curbe.last_bufsz,
+                  brw->curbe.last_buf ? memcmp(buf, brw->curbe.last_buf, bufsz) : -1);
+   }
+
+   if (brw->curbe.curbe_bo != NULL &&
+       brw->curbe.last_buf &&
+       bufsz == brw->curbe.last_bufsz &&
+       memcmp(buf, brw->curbe.last_buf, bufsz) == 0) {
+      /* constants have not changed */
+      FREE(buf);
+   } 
+   else {
+      /* constants have changed */
+      FREE(brw->curbe.last_buf);
+
+      brw->curbe.last_buf = buf;
+      brw->curbe.last_bufsz = bufsz;
+
+      if (brw->curbe.curbe_bo != NULL &&
+         (brw->curbe.need_new_bo ||
+          brw->curbe.curbe_next_offset + bufsz > brw->curbe.curbe_bo->size))
+      {
+        bo_reference(&brw->curbe.curbe_bo, NULL);
+      }
+
+      if (brw->curbe.curbe_bo == NULL) {
+        /* Allocate a single page for CURBE entries for this
+         * batchbuffer.  They're generally around 64b.  We will
+         * discard the curbe buffer after the batch is flushed to
+         * avoid synchronous updates.
+         */
+        ret = brw->sws->bo_alloc(brw->sws, 
+                                  BRW_BUFFER_TYPE_CURBE,
+                                  4096, 1 << 6,
+                                  &brw->curbe.curbe_bo);
+         if (ret)
+            return ret;
+
+        brw->curbe.curbe_next_offset = 0;
+      }
+
+      brw->curbe.curbe_offset = brw->curbe.curbe_next_offset;
+      brw->curbe.curbe_next_offset += bufsz;
+      brw->curbe.curbe_next_offset = align(brw->curbe.curbe_next_offset, 64);
+
+      /* Copy data to the buffer:
+       */
+      brw->sws->bo_subdata(brw->curbe.curbe_bo,
+                           BRW_DATA_CONSTANT_BUFFER,
+                          brw->curbe.curbe_offset,
+                          bufsz,
+                          buf,
+                           NULL, 0);
+   }
+
+   brw_add_validated_bo(brw, brw->curbe.curbe_bo);
+
+   /* Because this provokes an action (ie copy the constants into the
+    * URB), it shouldn't be shortcircuited if identical to the
+    * previous time - because eg. the urb destination may have
+    * changed, or the urb contents different to last time.
+    *
+    * Note that the data referred to is actually copied internally,
+    * not just used in place according to passed pointer.
+    *
+    * It appears that the CS unit takes care of using each available
+    * URB entry (Const URB Entry == CURBE) in turn, and issuing
+    * flushes as necessary when doublebuffering of CURBEs isn't
+    * possible.
+    */
+
+   return 0;
+}
+
+static enum pipe_error emit_curbe_buffer(struct brw_context *brw)
+{
+   GLuint sz = brw->curbe.total_size;
+
+   BEGIN_BATCH(2, IGNORE_CLIPRECTS);
+   if (sz == 0) {
+      OUT_BATCH((CMD_CONST_BUFFER << 16) | (2 - 2));
+      OUT_BATCH(0);
+   } else {
+      OUT_BATCH((CMD_CONST_BUFFER << 16) | (1 << 8) | (2 - 2));
+      OUT_RELOC(brw->curbe.curbe_bo,
+               BRW_USAGE_STATE,
+               (sz - 1) + brw->curbe.curbe_offset);
+   }
+   ADVANCE_BATCH();
+   return 0;
+}
+
+const struct brw_tracked_state brw_curbe_buffer = {
+   .dirty = {
+      .mesa = (PIPE_NEW_FRAGMENT_CONSTANTS |
+              PIPE_NEW_VERTEX_CONSTANTS |
+              PIPE_NEW_CLIP),
+      .brw  = (BRW_NEW_FRAGMENT_PROGRAM |
+              BRW_NEW_VERTEX_PROGRAM |
+              BRW_NEW_URB_FENCE | /* Implicit - hardware requires this, not used above */
+              BRW_NEW_PSP | /* Implicit - hardware requires this, not used above */
+              BRW_NEW_CURBE_OFFSETS |
+              BRW_NEW_BATCH),
+      .cache = (CACHE_NEW_WM_PROG) 
+   },
+   .prepare = prepare_curbe_buffer,
+   .emit = emit_curbe_buffer,
+};
+
diff --git a/src/gallium/drivers/i965/brw_debug.h b/src/gallium/drivers/i965/brw_debug.h
new file mode 100644 (file)
index 0000000..ae8e925
--- /dev/null
@@ -0,0 +1,43 @@
+#ifndef BRW_DEBUG_H
+#define BRW_DEBUG_H
+
+/* ================================================================
+ * Debugging:
+ */
+
+#define DEBUG_TEXTURE          0x1
+#define DEBUG_STATE            0x2
+#define DEBUG_IOCTL            0x4
+#define DEBUG_BLIT             0x8
+#define DEBUG_CURBE             0x10
+#define DEBUG_FALLBACKS                0x20
+#define DEBUG_VERBOSE          0x40
+#define DEBUG_BATCH             0x80
+#define DEBUG_PIXEL             0x100
+#define DEBUG_WINSYS            0x200
+#define DEBUG_MIN_URB           0x400
+#define DEBUG_DISASSEM           0x800
+#define DEBUG_unused3           0x1000
+#define DEBUG_SYNC             0x2000
+#define DEBUG_PRIMS            0x4000
+#define DEBUG_VERTS            0x8000
+#define DEBUG_unused4           0x10000
+#define DEBUG_DMA               0x20000
+#define DEBUG_SANITY            0x40000
+#define DEBUG_SLEEP             0x80000
+#define DEBUG_STATS             0x100000
+#define DEBUG_unused5           0x200000
+#define DEBUG_SINGLE_THREAD     0x400000
+#define DEBUG_WM                0x800000
+#define DEBUG_URB               0x1000000
+#define DEBUG_VS                0x2000000
+
+#ifdef DEBUG
+extern int BRW_DEBUG;
+#else
+#define BRW_DEBUG 0
+#endif
+
+
+
+#endif
diff --git a/src/gallium/drivers/i965/brw_defines.h b/src/gallium/drivers/i965/brw_defines.h
new file mode 100644 (file)
index 0000000..e201ce4
--- /dev/null
@@ -0,0 +1,847 @@
+/*
+ Copyright (C) Intel Corp.  2006.  All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ **********************************************************************/
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  */
+
+#ifndef BRW_DEFINES_H
+#define BRW_DEFINES_H
+
+/* 3D state:
+ */
+#define _3DOP_3DSTATE_PIPELINED       0x0
+#define _3DOP_3DSTATE_NONPIPELINED    0x1
+#define _3DOP_3DCONTROL               0x2
+#define _3DOP_3DPRIMITIVE             0x3
+
+#define _3DSTATE_PIPELINED_POINTERS       0x00
+#define _3DSTATE_BINDING_TABLE_POINTERS   0x01
+#define _3DSTATE_VERTEX_BUFFERS           0x08
+#define _3DSTATE_VERTEX_ELEMENTS          0x09
+#define _3DSTATE_INDEX_BUFFER             0x0A
+#define _3DSTATE_VF_STATISTICS            0x0B
+#define _3DSTATE_DRAWING_RECTANGLE            0x00
+#define _3DSTATE_CONSTANT_COLOR               0x01
+#define _3DSTATE_SAMPLER_PALETTE_LOAD         0x02
+#define _3DSTATE_CHROMA_KEY                   0x04
+#define _3DSTATE_DEPTH_BUFFER                 0x05
+#define _3DSTATE_POLY_STIPPLE_OFFSET          0x06
+#define _3DSTATE_POLY_STIPPLE_PATTERN         0x07
+#define _3DSTATE_LINE_STIPPLE                 0x08
+#define _3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP    0x09
+#define _3DCONTROL    0x00
+
+#define PIPE_CONTROL_NOWRITE          0x00
+#define PIPE_CONTROL_WRITEIMMEDIATE   0x01
+#define PIPE_CONTROL_WRITEDEPTH       0x02
+#define PIPE_CONTROL_WRITETIMESTAMP   0x03
+
+#define PIPE_CONTROL_GTTWRITE_PROCESS_LOCAL 0x00
+#define PIPE_CONTROL_GTTWRITE_GLOBAL        0x01
+
+#define _3DPRIM_POINTLIST         0x01
+#define _3DPRIM_LINELIST          0x02
+#define _3DPRIM_LINESTRIP         0x03
+#define _3DPRIM_TRILIST           0x04
+#define _3DPRIM_TRISTRIP          0x05
+#define _3DPRIM_TRIFAN            0x06
+#define _3DPRIM_QUADLIST          0x07
+#define _3DPRIM_QUADSTRIP         0x08
+#define _3DPRIM_LINELIST_ADJ      0x09
+#define _3DPRIM_LINESTRIP_ADJ     0x0A
+#define _3DPRIM_TRILIST_ADJ       0x0B
+#define _3DPRIM_TRISTRIP_ADJ      0x0C
+#define _3DPRIM_TRISTRIP_REVERSE  0x0D
+#define _3DPRIM_POLYGON           0x0E
+#define _3DPRIM_RECTLIST          0x0F
+#define _3DPRIM_LINELOOP          0x10
+#define _3DPRIM_POINTLIST_BF      0x11
+#define _3DPRIM_LINESTRIP_CONT    0x12
+#define _3DPRIM_LINESTRIP_BF      0x13
+#define _3DPRIM_LINESTRIP_CONT_BF 0x14
+#define _3DPRIM_TRIFAN_NOSTIPPLE  0x15
+
+#define _3DPRIM_VERTEXBUFFER_ACCESS_SEQUENTIAL 0
+#define _3DPRIM_VERTEXBUFFER_ACCESS_RANDOM     1
+
+#define BRW_ANISORATIO_2     0 
+#define BRW_ANISORATIO_4     1 
+#define BRW_ANISORATIO_6     2 
+#define BRW_ANISORATIO_8     3 
+#define BRW_ANISORATIO_10    4 
+#define BRW_ANISORATIO_12    5 
+#define BRW_ANISORATIO_14    6 
+#define BRW_ANISORATIO_16    7
+
+#define BRW_BLENDFACTOR_ONE                 0x1
+#define BRW_BLENDFACTOR_SRC_COLOR           0x2
+#define BRW_BLENDFACTOR_SRC_ALPHA           0x3
+#define BRW_BLENDFACTOR_DST_ALPHA           0x4
+#define BRW_BLENDFACTOR_DST_COLOR           0x5
+#define BRW_BLENDFACTOR_SRC_ALPHA_SATURATE  0x6
+#define BRW_BLENDFACTOR_CONST_COLOR         0x7
+#define BRW_BLENDFACTOR_CONST_ALPHA         0x8
+#define BRW_BLENDFACTOR_SRC1_COLOR          0x9
+#define BRW_BLENDFACTOR_SRC1_ALPHA          0x0A
+#define BRW_BLENDFACTOR_ZERO                0x11
+#define BRW_BLENDFACTOR_INV_SRC_COLOR       0x12
+#define BRW_BLENDFACTOR_INV_SRC_ALPHA       0x13
+#define BRW_BLENDFACTOR_INV_DST_ALPHA       0x14
+#define BRW_BLENDFACTOR_INV_DST_COLOR       0x15
+#define BRW_BLENDFACTOR_INV_CONST_COLOR     0x17
+#define BRW_BLENDFACTOR_INV_CONST_ALPHA     0x18
+#define BRW_BLENDFACTOR_INV_SRC1_COLOR      0x19
+#define BRW_BLENDFACTOR_INV_SRC1_ALPHA      0x1A
+
+#define BRW_BLENDFUNCTION_ADD               0
+#define BRW_BLENDFUNCTION_SUBTRACT          1
+#define BRW_BLENDFUNCTION_REVERSE_SUBTRACT  2
+#define BRW_BLENDFUNCTION_MIN               3
+#define BRW_BLENDFUNCTION_MAX               4
+
+#define BRW_ALPHATEST_FORMAT_UNORM8         0
+#define BRW_ALPHATEST_FORMAT_FLOAT32        1
+
+#define BRW_CHROMAKEY_KILL_ON_ANY_MATCH  0
+#define BRW_CHROMAKEY_REPLACE_BLACK      1
+
+#define BRW_CLIP_API_OGL     0
+#define BRW_CLIP_API_DX      1
+
+#define BRW_CLIPMODE_NORMAL              0
+#define BRW_CLIPMODE_CLIP_ALL            1
+#define BRW_CLIPMODE_CLIP_NON_REJECTED   2
+#define BRW_CLIPMODE_REJECT_ALL          3
+#define BRW_CLIPMODE_ACCEPT_ALL          4
+#define BRW_CLIPMODE_KERNEL_CLIP         5
+
+#define BRW_CLIP_NDCSPACE     0
+#define BRW_CLIP_SCREENSPACE  1
+
+#define BRW_COMPAREFUNCTION_ALWAYS       0
+#define BRW_COMPAREFUNCTION_NEVER        1
+#define BRW_COMPAREFUNCTION_LESS         2
+#define BRW_COMPAREFUNCTION_EQUAL        3
+#define BRW_COMPAREFUNCTION_LEQUAL       4
+#define BRW_COMPAREFUNCTION_GREATER      5
+#define BRW_COMPAREFUNCTION_NOTEQUAL     6
+#define BRW_COMPAREFUNCTION_GEQUAL       7
+
+#define BRW_COVERAGE_PIXELS_HALF     0
+#define BRW_COVERAGE_PIXELS_1        1
+#define BRW_COVERAGE_PIXELS_2        2
+#define BRW_COVERAGE_PIXELS_4        3
+
+#define BRW_CULLMODE_BOTH        0
+#define BRW_CULLMODE_NONE        1
+#define BRW_CULLMODE_FRONT       2
+#define BRW_CULLMODE_BACK        3
+
+#define BRW_DEFAULTCOLOR_R8G8B8A8_UNORM      0
+#define BRW_DEFAULTCOLOR_R32G32B32A32_FLOAT  1
+
+#define BRW_DEPTHFORMAT_D32_FLOAT_S8X24_UINT     0
+#define BRW_DEPTHFORMAT_D32_FLOAT                1
+#define BRW_DEPTHFORMAT_D24_UNORM_S8_UINT        2
+#define BRW_DEPTHFORMAT_D16_UNORM                5
+
+#define BRW_FLOATING_POINT_IEEE_754        0
+#define BRW_FLOATING_POINT_NON_IEEE_754    1
+
+#define BRW_FRONTWINDING_CW      0
+#define BRW_FRONTWINDING_CCW     1
+
+#define BRW_SPRITE_POINT_ENABLE  16
+
+#define BRW_INDEX_BYTE     0
+#define BRW_INDEX_WORD     1
+#define BRW_INDEX_DWORD    2
+
+#define BRW_LOGICOPFUNCTION_CLEAR            0
+#define BRW_LOGICOPFUNCTION_NOR              1
+#define BRW_LOGICOPFUNCTION_AND_INVERTED     2
+#define BRW_LOGICOPFUNCTION_COPY_INVERTED    3
+#define BRW_LOGICOPFUNCTION_AND_REVERSE      4
+#define BRW_LOGICOPFUNCTION_INVERT           5
+#define BRW_LOGICOPFUNCTION_XOR              6
+#define BRW_LOGICOPFUNCTION_NAND             7
+#define BRW_LOGICOPFUNCTION_AND              8
+#define BRW_LOGICOPFUNCTION_EQUIV            9
+#define BRW_LOGICOPFUNCTION_NOOP             10
+#define BRW_LOGICOPFUNCTION_OR_INVERTED      11
+#define BRW_LOGICOPFUNCTION_COPY             12
+#define BRW_LOGICOPFUNCTION_OR_REVERSE       13
+#define BRW_LOGICOPFUNCTION_OR               14
+#define BRW_LOGICOPFUNCTION_SET              15  
+
+#define BRW_MAPFILTER_NEAREST        0x0 
+#define BRW_MAPFILTER_LINEAR         0x1 
+#define BRW_MAPFILTER_ANISOTROPIC    0x2
+
+#define BRW_MIPFILTER_NONE        0   
+#define BRW_MIPFILTER_NEAREST     1   
+#define BRW_MIPFILTER_LINEAR      3
+
+#define BRW_POLYGON_FRONT_FACING     0
+#define BRW_POLYGON_BACK_FACING      1
+
+#define BRW_PREFILTER_ALWAYS     0x0 
+#define BRW_PREFILTER_NEVER      0x1
+#define BRW_PREFILTER_LESS       0x2
+#define BRW_PREFILTER_EQUAL      0x3
+#define BRW_PREFILTER_LEQUAL     0x4
+#define BRW_PREFILTER_GREATER    0x5
+#define BRW_PREFILTER_NOTEQUAL   0x6
+#define BRW_PREFILTER_GEQUAL     0x7
+
+#define BRW_PROVOKING_VERTEX_0    0
+#define BRW_PROVOKING_VERTEX_1    1 
+#define BRW_PROVOKING_VERTEX_2    2
+
+#define BRW_RASTRULE_UPPER_LEFT  0    
+#define BRW_RASTRULE_UPPER_RIGHT 1
+/* These are listed as "Reserved, but not seen as useful"
+ * in Intel documentation (page 212, "Point Rasterization Rule",
+ * section 7.4 "SF Pipeline State Summary", of document
+ * "Intel® 965 Express Chipset Family and Intel® G35 Express
+ * Chipset Graphics Controller Programmer's Reference Manual,
+ * Volume 2: 3D/Media", Revision 1.0b as of January 2008,
+ * available at 
+ *     http://intellinuxgraphics.org/documentation.html
+ * at the time of this writing).
+ *
+ * These appear to be supported on at least some
+ * i965-family devices, and the BRW_RASTRULE_LOWER_RIGHT
+ * is useful when using OpenGL to render to a FBO
+ * (which has the pixel coordinate Y orientation inverted
+ * with respect to the normal OpenGL pixel coordinate system).
+ */
+#define BRW_RASTRULE_LOWER_LEFT  2
+#define BRW_RASTRULE_LOWER_RIGHT 3
+
+#define BRW_RENDERTARGET_CLAMPRANGE_UNORM    0
+#define BRW_RENDERTARGET_CLAMPRANGE_SNORM    1
+#define BRW_RENDERTARGET_CLAMPRANGE_FORMAT   2
+
+#define BRW_STENCILOP_KEEP               0
+#define BRW_STENCILOP_ZERO               1
+#define BRW_STENCILOP_REPLACE            2
+#define BRW_STENCILOP_INCRSAT            3
+#define BRW_STENCILOP_DECRSAT            4
+#define BRW_STENCILOP_INCR               5
+#define BRW_STENCILOP_DECR               6
+#define BRW_STENCILOP_INVERT             7
+
+#define BRW_SURFACE_MIPMAPLAYOUT_BELOW   0
+#define BRW_SURFACE_MIPMAPLAYOUT_RIGHT   1
+
+#define BRW_SURFACEFORMAT_R32G32B32A32_FLOAT             0x000 
+#define BRW_SURFACEFORMAT_R32G32B32A32_SINT              0x001 
+#define BRW_SURFACEFORMAT_R32G32B32A32_UINT              0x002 
+#define BRW_SURFACEFORMAT_R32G32B32A32_UNORM             0x003 
+#define BRW_SURFACEFORMAT_R32G32B32A32_SNORM             0x004 
+#define BRW_SURFACEFORMAT_R64G64_FLOAT                   0x005 
+#define BRW_SURFACEFORMAT_R32G32B32X32_FLOAT             0x006 
+#define BRW_SURFACEFORMAT_R32G32B32A32_SSCALED           0x007
+#define BRW_SURFACEFORMAT_R32G32B32A32_USCALED           0x008
+#define BRW_SURFACEFORMAT_R32G32B32_FLOAT                0x040 
+#define BRW_SURFACEFORMAT_R32G32B32_SINT                 0x041 
+#define BRW_SURFACEFORMAT_R32G32B32_UINT                 0x042 
+#define BRW_SURFACEFORMAT_R32G32B32_UNORM                0x043 
+#define BRW_SURFACEFORMAT_R32G32B32_SNORM                0x044 
+#define BRW_SURFACEFORMAT_R32G32B32_SSCALED              0x045 
+#define BRW_SURFACEFORMAT_R32G32B32_USCALED              0x046 
+#define BRW_SURFACEFORMAT_R16G16B16A16_UNORM             0x080 
+#define BRW_SURFACEFORMAT_R16G16B16A16_SNORM             0x081 
+#define BRW_SURFACEFORMAT_R16G16B16A16_SINT              0x082 
+#define BRW_SURFACEFORMAT_R16G16B16A16_UINT              0x083 
+#define BRW_SURFACEFORMAT_R16G16B16A16_FLOAT             0x084 
+#define BRW_SURFACEFORMAT_R32G32_FLOAT                   0x085 
+#define BRW_SURFACEFORMAT_R32G32_SINT                    0x086 
+#define BRW_SURFACEFORMAT_R32G32_UINT                    0x087 
+#define BRW_SURFACEFORMAT_R32_FLOAT_X8X24_TYPELESS       0x088 
+#define BRW_SURFACEFORMAT_X32_TYPELESS_G8X24_UINT        0x089 
+#define BRW_SURFACEFORMAT_L32A32_FLOAT                   0x08A 
+#define BRW_SURFACEFORMAT_R32G32_UNORM                   0x08B 
+#define BRW_SURFACEFORMAT_R32G32_SNORM                   0x08C 
+#define BRW_SURFACEFORMAT_R64_FLOAT                      0x08D 
+#define BRW_SURFACEFORMAT_R16G16B16X16_UNORM             0x08E 
+#define BRW_SURFACEFORMAT_R16G16B16X16_FLOAT             0x08F 
+#define BRW_SURFACEFORMAT_A32X32_FLOAT                   0x090 
+#define BRW_SURFACEFORMAT_L32X32_FLOAT                   0x091 
+#define BRW_SURFACEFORMAT_I32X32_FLOAT                   0x092 
+#define BRW_SURFACEFORMAT_R16G16B16A16_SSCALED           0x093
+#define BRW_SURFACEFORMAT_R16G16B16A16_USCALED           0x094
+#define BRW_SURFACEFORMAT_R32G32_SSCALED                 0x095
+#define BRW_SURFACEFORMAT_R32G32_USCALED                 0x096
+#define BRW_SURFACEFORMAT_B8G8R8A8_UNORM                 0x0C0 
+#define BRW_SURFACEFORMAT_B8G8R8A8_UNORM_SRGB            0x0C1 
+#define BRW_SURFACEFORMAT_R10G10B10A2_UNORM              0x0C2 
+#define BRW_SURFACEFORMAT_R10G10B10A2_UNORM_SRGB         0x0C3 
+#define BRW_SURFACEFORMAT_R10G10B10A2_UINT               0x0C4 
+#define BRW_SURFACEFORMAT_R10G10B10_SNORM_A2_UNORM       0x0C5 
+#define BRW_SURFACEFORMAT_R8G8B8A8_UNORM                 0x0C7 
+#define BRW_SURFACEFORMAT_R8G8B8A8_UNORM_SRGB            0x0C8 
+#define BRW_SURFACEFORMAT_R8G8B8A8_SNORM                 0x0C9 
+#define BRW_SURFACEFORMAT_R8G8B8A8_SINT                  0x0CA 
+#define BRW_SURFACEFORMAT_R8G8B8A8_UINT                  0x0CB 
+#define BRW_SURFACEFORMAT_R16G16_UNORM                   0x0CC 
+#define BRW_SURFACEFORMAT_R16G16_SNORM                   0x0CD 
+#define BRW_SURFACEFORMAT_R16G16_SINT                    0x0CE 
+#define BRW_SURFACEFORMAT_R16G16_UINT                    0x0CF 
+#define BRW_SURFACEFORMAT_R16G16_FLOAT                   0x0D0 
+#define BRW_SURFACEFORMAT_B10G10R10A2_UNORM              0x0D1 
+#define BRW_SURFACEFORMAT_B10G10R10A2_UNORM_SRGB         0x0D2 
+#define BRW_SURFACEFORMAT_R11G11B10_FLOAT                0x0D3 
+#define BRW_SURFACEFORMAT_R32_SINT                       0x0D6 
+#define BRW_SURFACEFORMAT_R32_UINT                       0x0D7 
+#define BRW_SURFACEFORMAT_R32_FLOAT                      0x0D8 
+#define BRW_SURFACEFORMAT_R24_UNORM_X8_TYPELESS          0x0D9 
+#define BRW_SURFACEFORMAT_X24_TYPELESS_G8_UINT           0x0DA 
+#define BRW_SURFACEFORMAT_L16A16_UNORM                   0x0DF 
+#define BRW_SURFACEFORMAT_I24X8_UNORM                    0x0E0 
+#define BRW_SURFACEFORMAT_L24X8_UNORM                    0x0E1 
+#define BRW_SURFACEFORMAT_A24X8_UNORM                    0x0E2 
+#define BRW_SURFACEFORMAT_I32_FLOAT                      0x0E3 
+#define BRW_SURFACEFORMAT_L32_FLOAT                      0x0E4 
+#define BRW_SURFACEFORMAT_A32_FLOAT                      0x0E5 
+#define BRW_SURFACEFORMAT_B8G8R8X8_UNORM                 0x0E9 
+#define BRW_SURFACEFORMAT_B8G8R8X8_UNORM_SRGB            0x0EA 
+#define BRW_SURFACEFORMAT_R8G8B8X8_UNORM                 0x0EB 
+#define BRW_SURFACEFORMAT_R8G8B8X8_UNORM_SRGB            0x0EC 
+#define BRW_SURFACEFORMAT_R9G9B9E5_SHAREDEXP             0x0ED 
+#define BRW_SURFACEFORMAT_B10G10R10X2_UNORM              0x0EE 
+#define BRW_SURFACEFORMAT_L16A16_FLOAT                   0x0F0 
+#define BRW_SURFACEFORMAT_R32_UNORM                      0x0F1 
+#define BRW_SURFACEFORMAT_R32_SNORM                      0x0F2 
+#define BRW_SURFACEFORMAT_R10G10B10X2_USCALED            0x0F3
+#define BRW_SURFACEFORMAT_R8G8B8A8_SSCALED               0x0F4
+#define BRW_SURFACEFORMAT_R8G8B8A8_USCALED               0x0F5
+#define BRW_SURFACEFORMAT_R16G16_SSCALED                 0x0F6
+#define BRW_SURFACEFORMAT_R16G16_USCALED                 0x0F7
+#define BRW_SURFACEFORMAT_R32_SSCALED                    0x0F8
+#define BRW_SURFACEFORMAT_R32_USCALED                    0x0F9
+#define BRW_SURFACEFORMAT_B5G6R5_UNORM                   0x100 
+#define BRW_SURFACEFORMAT_B5G6R5_UNORM_SRGB              0x101 
+#define BRW_SURFACEFORMAT_B5G5R5A1_UNORM                 0x102 
+#define BRW_SURFACEFORMAT_B5G5R5A1_UNORM_SRGB            0x103 
+#define BRW_SURFACEFORMAT_B4G4R4A4_UNORM                 0x104 
+#define BRW_SURFACEFORMAT_B4G4R4A4_UNORM_SRGB            0x105 
+#define BRW_SURFACEFORMAT_R8G8_UNORM                     0x106 
+#define BRW_SURFACEFORMAT_R8G8_SNORM                     0x107 
+#define BRW_SURFACEFORMAT_R8G8_SINT                      0x108 
+#define BRW_SURFACEFORMAT_R8G8_UINT                      0x109 
+#define BRW_SURFACEFORMAT_R16_UNORM                      0x10A 
+#define BRW_SURFACEFORMAT_R16_SNORM                      0x10B 
+#define BRW_SURFACEFORMAT_R16_SINT                       0x10C 
+#define BRW_SURFACEFORMAT_R16_UINT                       0x10D 
+#define BRW_SURFACEFORMAT_R16_FLOAT                      0x10E 
+#define BRW_SURFACEFORMAT_I16_UNORM                      0x111 
+#define BRW_SURFACEFORMAT_L16_UNORM                      0x112 
+#define BRW_SURFACEFORMAT_A16_UNORM                      0x113 
+#define BRW_SURFACEFORMAT_L8A8_UNORM                     0x114 
+#define BRW_SURFACEFORMAT_I16_FLOAT                      0x115
+#define BRW_SURFACEFORMAT_L16_FLOAT                      0x116
+#define BRW_SURFACEFORMAT_A16_FLOAT                      0x117
+#define BRW_SURFACEFORMAT_L8A8_UNORM_SRGB                0x118
+#define BRW_SURFACEFORMAT_R5G5_SNORM_B6_UNORM            0x119
+#define BRW_SURFACEFORMAT_B5G5R5X1_UNORM                 0x11A
+#define BRW_SURFACEFORMAT_B5G5R5X1_UNORM_SRGB            0x11B
+#define BRW_SURFACEFORMAT_R8G8_SSCALED                   0x11C
+#define BRW_SURFACEFORMAT_R8G8_USCALED                   0x11D
+#define BRW_SURFACEFORMAT_R16_SSCALED                    0x11E
+#define BRW_SURFACEFORMAT_R16_USCALED                    0x11F
+#define BRW_SURFACEFORMAT_R8_UNORM                       0x140 
+#define BRW_SURFACEFORMAT_R8_SNORM                       0x141 
+#define BRW_SURFACEFORMAT_R8_SINT                        0x142 
+#define BRW_SURFACEFORMAT_R8_UINT                        0x143 
+#define BRW_SURFACEFORMAT_A8_UNORM                       0x144 
+#define BRW_SURFACEFORMAT_I8_UNORM                       0x145 
+#define BRW_SURFACEFORMAT_L8_UNORM                       0x146 
+#define BRW_SURFACEFORMAT_P4A4_UNORM                     0x147 
+#define BRW_SURFACEFORMAT_A4P4_UNORM                     0x148
+#define BRW_SURFACEFORMAT_R8_SSCALED                     0x149
+#define BRW_SURFACEFORMAT_R8_USCALED                     0x14A
+#define BRW_SURFACEFORMAT_L8_UNORM_SRGB                  0x14C
+#define BRW_SURFACEFORMAT_R1_UINT                        0x181 
+#define BRW_SURFACEFORMAT_YCRCB_NORMAL                   0x182 
+#define BRW_SURFACEFORMAT_YCRCB_SWAPUVY                  0x183 
+#define BRW_SURFACEFORMAT_BC1_UNORM                      0x186 
+#define BRW_SURFACEFORMAT_BC2_UNORM                      0x187 
+#define BRW_SURFACEFORMAT_BC3_UNORM                      0x188 
+#define BRW_SURFACEFORMAT_BC4_UNORM                      0x189 
+#define BRW_SURFACEFORMAT_BC5_UNORM                      0x18A 
+#define BRW_SURFACEFORMAT_BC1_UNORM_SRGB                 0x18B 
+#define BRW_SURFACEFORMAT_BC2_UNORM_SRGB                 0x18C 
+#define BRW_SURFACEFORMAT_BC3_UNORM_SRGB                 0x18D 
+#define BRW_SURFACEFORMAT_MONO8                          0x18E 
+#define BRW_SURFACEFORMAT_YCRCB_SWAPUV                   0x18F 
+#define BRW_SURFACEFORMAT_YCRCB_SWAPY                    0x190 
+#define BRW_SURFACEFORMAT_DXT1_RGB                       0x191 
+#define BRW_SURFACEFORMAT_FXT1                           0x192 
+#define BRW_SURFACEFORMAT_R8G8B8_UNORM                   0x193 
+#define BRW_SURFACEFORMAT_R8G8B8_SNORM                   0x194 
+#define BRW_SURFACEFORMAT_R8G8B8_SSCALED                 0x195 
+#define BRW_SURFACEFORMAT_R8G8B8_USCALED                 0x196 
+#define BRW_SURFACEFORMAT_R64G64B64A64_FLOAT             0x197 
+#define BRW_SURFACEFORMAT_R64G64B64_FLOAT                0x198 
+#define BRW_SURFACEFORMAT_BC4_SNORM                      0x199 
+#define BRW_SURFACEFORMAT_BC5_SNORM                      0x19A 
+#define BRW_SURFACEFORMAT_R16G16B16_UNORM                0x19C 
+#define BRW_SURFACEFORMAT_R16G16B16_SNORM                0x19D 
+#define BRW_SURFACEFORMAT_R16G16B16_SSCALED              0x19E 
+#define BRW_SURFACEFORMAT_R16G16B16_USCALED              0x19F
+#define BRW_SURFACEFORMAT_INVALID                        0xFFF
+
+#define BRW_SURFACERETURNFORMAT_FLOAT32  0
+#define BRW_SURFACERETURNFORMAT_S1       1
+
+#define BRW_SURFACE_1D      0
+#define BRW_SURFACE_2D      1
+#define BRW_SURFACE_3D      2
+#define BRW_SURFACE_CUBE    3
+#define BRW_SURFACE_BUFFER  4
+#define BRW_SURFACE_NULL    7
+
+#define BRW_TEXCOORDMODE_WRAP            0
+#define BRW_TEXCOORDMODE_MIRROR          1
+#define BRW_TEXCOORDMODE_CLAMP           2
+#define BRW_TEXCOORDMODE_CUBE            3
+#define BRW_TEXCOORDMODE_CLAMP_BORDER    4
+#define BRW_TEXCOORDMODE_MIRROR_ONCE     5
+
+#define BRW_THREAD_PRIORITY_NORMAL   0
+#define BRW_THREAD_PRIORITY_HIGH     1
+
+#define BRW_TILEWALK_XMAJOR                 0
+#define BRW_TILEWALK_YMAJOR                 1
+
+#define BRW_VERTEX_SUBPIXEL_PRECISION_8BITS  0
+#define BRW_VERTEX_SUBPIXEL_PRECISION_4BITS  1
+
+/* Execution Unit (EU) defines
+ */
+
+#define BRW_ALIGN_1   0
+#define BRW_ALIGN_16  1
+
+#define BRW_ADDRESS_DIRECT                        0
+#define BRW_ADDRESS_REGISTER_INDIRECT_REGISTER    1
+
+#define BRW_CHANNEL_X     0
+#define BRW_CHANNEL_Y     1
+#define BRW_CHANNEL_Z     2
+#define BRW_CHANNEL_W     3
+
+#define BRW_COMPRESSION_NONE          0
+#define BRW_COMPRESSION_2NDHALF       1
+#define BRW_COMPRESSION_COMPRESSED    2
+
+#define BRW_CONDITIONAL_NONE  0
+#define BRW_CONDITIONAL_Z     1
+#define BRW_CONDITIONAL_NZ    2
+#define BRW_CONDITIONAL_EQ    1        /* Z */
+#define BRW_CONDITIONAL_NEQ   2        /* NZ */
+#define BRW_CONDITIONAL_G     3
+#define BRW_CONDITIONAL_GE    4
+#define BRW_CONDITIONAL_L     5
+#define BRW_CONDITIONAL_LE    6
+#define BRW_CONDITIONAL_R     7
+#define BRW_CONDITIONAL_O     8
+#define BRW_CONDITIONAL_U     9
+
+#define BRW_DEBUG_NONE        0
+#define BRW_DEBUG_BREAKPOINT  1
+
+#define BRW_DEPENDENCY_NORMAL         0
+#define BRW_DEPENDENCY_NOTCLEARED     1
+#define BRW_DEPENDENCY_NOTCHECKED     2
+#define BRW_DEPENDENCY_DISABLE        3
+
+#define BRW_EXECUTE_1     0
+#define BRW_EXECUTE_2     1
+#define BRW_EXECUTE_4     2
+#define BRW_EXECUTE_8     3
+#define BRW_EXECUTE_16    4
+#define BRW_EXECUTE_32    5
+
+#define BRW_HORIZONTAL_STRIDE_0   0
+#define BRW_HORIZONTAL_STRIDE_1   1
+#define BRW_HORIZONTAL_STRIDE_2   2
+#define BRW_HORIZONTAL_STRIDE_4   3
+
+#define BRW_INSTRUCTION_NORMAL    0
+#define BRW_INSTRUCTION_SATURATE  1
+
+#define BRW_MASK_ENABLE   0
+#define BRW_MASK_DISABLE  1
+
+#define BRW_OPCODE_MOV        1
+#define BRW_OPCODE_SEL        2
+#define BRW_OPCODE_NOT        4
+#define BRW_OPCODE_AND        5
+#define BRW_OPCODE_OR         6
+#define BRW_OPCODE_XOR        7
+#define BRW_OPCODE_SHR        8
+#define BRW_OPCODE_SHL        9
+#define BRW_OPCODE_RSR        10
+#define BRW_OPCODE_RSL        11
+#define BRW_OPCODE_ASR        12
+#define BRW_OPCODE_CMP        16
+#define BRW_OPCODE_CMPN       17
+#define BRW_OPCODE_JMPI       32
+#define BRW_OPCODE_IF         34
+#define BRW_OPCODE_IFF        35
+#define BRW_OPCODE_ELSE       36
+#define BRW_OPCODE_ENDIF      37
+#define BRW_OPCODE_DO         38
+#define BRW_OPCODE_WHILE      39
+#define BRW_OPCODE_BREAK      40
+#define BRW_OPCODE_CONTINUE   41
+#define BRW_OPCODE_HALT       42
+#define BRW_OPCODE_MSAVE      44
+#define BRW_OPCODE_MRESTORE   45
+#define BRW_OPCODE_PUSH       46
+#define BRW_OPCODE_POP        47
+#define BRW_OPCODE_WAIT       48
+#define BRW_OPCODE_SEND       49
+#define BRW_OPCODE_ADD        64
+#define BRW_OPCODE_MUL        65
+#define BRW_OPCODE_AVG        66
+#define BRW_OPCODE_FRC        67
+#define BRW_OPCODE_RNDU       68
+#define BRW_OPCODE_RNDD       69
+#define BRW_OPCODE_RNDE       70
+#define BRW_OPCODE_RNDZ       71
+#define BRW_OPCODE_MAC        72
+#define BRW_OPCODE_MACH       73
+#define BRW_OPCODE_LZD        74
+#define BRW_OPCODE_SAD2       80
+#define BRW_OPCODE_SADA2      81
+#define BRW_OPCODE_DP4        84
+#define BRW_OPCODE_DPH        85
+#define BRW_OPCODE_DP3        86
+#define BRW_OPCODE_DP2        87
+#define BRW_OPCODE_DPA2       88
+#define BRW_OPCODE_LINE       89
+#define BRW_OPCODE_NOP        126
+
+#define BRW_PREDICATE_NONE             0
+#define BRW_PREDICATE_NORMAL           1
+#define BRW_PREDICATE_ALIGN1_ANYV             2
+#define BRW_PREDICATE_ALIGN1_ALLV             3
+#define BRW_PREDICATE_ALIGN1_ANY2H            4
+#define BRW_PREDICATE_ALIGN1_ALL2H            5
+#define BRW_PREDICATE_ALIGN1_ANY4H            6
+#define BRW_PREDICATE_ALIGN1_ALL4H            7
+#define BRW_PREDICATE_ALIGN1_ANY8H            8
+#define BRW_PREDICATE_ALIGN1_ALL8H            9
+#define BRW_PREDICATE_ALIGN1_ANY16H           10
+#define BRW_PREDICATE_ALIGN1_ALL16H           11
+#define BRW_PREDICATE_ALIGN16_REPLICATE_X     2
+#define BRW_PREDICATE_ALIGN16_REPLICATE_Y     3
+#define BRW_PREDICATE_ALIGN16_REPLICATE_Z     4
+#define BRW_PREDICATE_ALIGN16_REPLICATE_W     5
+#define BRW_PREDICATE_ALIGN16_ANY4H           6
+#define BRW_PREDICATE_ALIGN16_ALL4H           7
+
+#define BRW_ARCHITECTURE_REGISTER_FILE    0
+#define BRW_GENERAL_REGISTER_FILE         1
+#define BRW_MESSAGE_REGISTER_FILE         2
+#define BRW_IMMEDIATE_VALUE               3
+
+#define BRW_REGISTER_TYPE_UD  0
+#define BRW_REGISTER_TYPE_D   1
+#define BRW_REGISTER_TYPE_UW  2
+#define BRW_REGISTER_TYPE_W   3
+#define BRW_REGISTER_TYPE_UB  4
+#define BRW_REGISTER_TYPE_B   5
+#define BRW_REGISTER_TYPE_VF  5        /* packed float vector, immediates only? */
+#define BRW_REGISTER_TYPE_HF  6
+#define BRW_REGISTER_TYPE_V   6        /* packed int vector, immediates only, uword dest only */
+#define BRW_REGISTER_TYPE_F   7
+
+#define BRW_ARF_NULL                  0x00
+#define BRW_ARF_ADDRESS               0x10
+#define BRW_ARF_ACCUMULATOR           0x20   
+#define BRW_ARF_FLAG                  0x30
+#define BRW_ARF_MASK                  0x40
+#define BRW_ARF_MASK_STACK            0x50
+#define BRW_ARF_MASK_STACK_DEPTH      0x60
+#define BRW_ARF_STATE                 0x70
+#define BRW_ARF_CONTROL               0x80
+#define BRW_ARF_NOTIFICATION_COUNT    0x90
+#define BRW_ARF_IP                    0xA0
+
+#define BRW_AMASK   0
+#define BRW_IMASK   1
+#define BRW_LMASK   2
+#define BRW_CMASK   3
+
+
+
+#define BRW_THREAD_NORMAL     0
+#define BRW_THREAD_ATOMIC     1
+#define BRW_THREAD_SWITCH     2
+
+#define BRW_VERTICAL_STRIDE_0                 0
+#define BRW_VERTICAL_STRIDE_1                 1
+#define BRW_VERTICAL_STRIDE_2                 2
+#define BRW_VERTICAL_STRIDE_4                 3
+#define BRW_VERTICAL_STRIDE_8                 4
+#define BRW_VERTICAL_STRIDE_16                5
+#define BRW_VERTICAL_STRIDE_32                6
+#define BRW_VERTICAL_STRIDE_64                7
+#define BRW_VERTICAL_STRIDE_128               8
+#define BRW_VERTICAL_STRIDE_256               9
+#define BRW_VERTICAL_STRIDE_ONE_DIMENSIONAL   0xF
+
+#define BRW_WIDTH_1       0
+#define BRW_WIDTH_2       1
+#define BRW_WIDTH_4       2
+#define BRW_WIDTH_8       3
+#define BRW_WIDTH_16      4
+
+#define BRW_STATELESS_BUFFER_BOUNDARY_1K      0
+#define BRW_STATELESS_BUFFER_BOUNDARY_2K      1
+#define BRW_STATELESS_BUFFER_BOUNDARY_4K      2
+#define BRW_STATELESS_BUFFER_BOUNDARY_8K      3
+#define BRW_STATELESS_BUFFER_BOUNDARY_16K     4
+#define BRW_STATELESS_BUFFER_BOUNDARY_32K     5
+#define BRW_STATELESS_BUFFER_BOUNDARY_64K     6
+#define BRW_STATELESS_BUFFER_BOUNDARY_128K    7
+#define BRW_STATELESS_BUFFER_BOUNDARY_256K    8
+#define BRW_STATELESS_BUFFER_BOUNDARY_512K    9
+#define BRW_STATELESS_BUFFER_BOUNDARY_1M      10
+#define BRW_STATELESS_BUFFER_BOUNDARY_2M      11
+
+#define BRW_POLYGON_FACING_FRONT      0
+#define BRW_POLYGON_FACING_BACK       1
+
+#define BRW_MESSAGE_TARGET_NULL               0
+#define BRW_MESSAGE_TARGET_MATH               1
+#define BRW_MESSAGE_TARGET_SAMPLER            2
+#define BRW_MESSAGE_TARGET_GATEWAY            3
+#define BRW_MESSAGE_TARGET_DATAPORT_READ      4
+#define BRW_MESSAGE_TARGET_DATAPORT_WRITE     5
+#define BRW_MESSAGE_TARGET_URB                6
+#define BRW_MESSAGE_TARGET_THREAD_SPAWNER     7
+
+#define BRW_SAMPLER_RETURN_FORMAT_FLOAT32     0
+#define BRW_SAMPLER_RETURN_FORMAT_UINT32      2
+#define BRW_SAMPLER_RETURN_FORMAT_SINT32      3
+
+#define BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE              0
+#define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE             0
+#define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_BIAS        0
+#define BRW_SAMPLER_MESSAGE_SIMD8_KILLPIX             1
+#define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_LOD        1
+#define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_LOD         1
+#define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_GRADIENTS  2
+#define BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_GRADIENTS    2
+#define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_COMPARE    0
+#define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_COMPARE     2
+#define BRW_SAMPLER_MESSAGE_SIMD4X2_RESINFO           2
+#define BRW_SAMPLER_MESSAGE_SIMD8_RESINFO             2
+#define BRW_SAMPLER_MESSAGE_SIMD16_RESINFO            2
+#define BRW_SAMPLER_MESSAGE_SIMD4X2_LD                3
+#define BRW_SAMPLER_MESSAGE_SIMD8_LD                  3
+#define BRW_SAMPLER_MESSAGE_SIMD16_LD                 3
+
+#define BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_IGDNG            0
+#define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_IGDNG          0
+#define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_IGDNG           0
+#define BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_BIAS_IGDNG       1
+#define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_BIAS_IGDNG     1
+#define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_BIAS_IGDNG      1
+#define BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_LOD_IGDNG        2
+#define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_LOD_IGDNG      2
+#define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_LOD_IGDNG       2
+#define BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_COMPARE_IGDNG    3
+#define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_COMPARE_IGDNG  3
+#define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_COMPARE_IGDNG   3
+
+/* for IGDNG only */
+#define BRW_SAMPLER_SIMD_MODE_SIMD4X2                   0
+#define BRW_SAMPLER_SIMD_MODE_SIMD8                     1
+#define BRW_SAMPLER_SIMD_MODE_SIMD16                    2
+#define BRW_SAMPLER_SIMD_MODE_SIMD32_64                 3
+
+#define BRW_DATAPORT_OWORD_BLOCK_1_OWORDLOW   0
+#define BRW_DATAPORT_OWORD_BLOCK_1_OWORDHIGH  1
+#define BRW_DATAPORT_OWORD_BLOCK_2_OWORDS     2
+#define BRW_DATAPORT_OWORD_BLOCK_4_OWORDS     3
+#define BRW_DATAPORT_OWORD_BLOCK_8_OWORDS     4
+
+#define BRW_DATAPORT_OWORD_DUAL_BLOCK_1OWORD     0
+#define BRW_DATAPORT_OWORD_DUAL_BLOCK_4OWORDS    2
+
+#define BRW_DATAPORT_DWORD_SCATTERED_BLOCK_8DWORDS   2
+#define BRW_DATAPORT_DWORD_SCATTERED_BLOCK_16DWORDS  3
+
+#define BRW_DATAPORT_READ_MESSAGE_OWORD_BLOCK_READ          0
+#define BRW_DATAPORT_READ_MESSAGE_OWORD_DUAL_BLOCK_READ     1
+#define BRW_DATAPORT_READ_MESSAGE_DWORD_BLOCK_READ          2
+#define BRW_DATAPORT_READ_MESSAGE_DWORD_SCATTERED_READ      3
+
+#define BRW_DATAPORT_READ_TARGET_DATA_CACHE      0
+#define BRW_DATAPORT_READ_TARGET_RENDER_CACHE    1
+#define BRW_DATAPORT_READ_TARGET_SAMPLER_CACHE   2
+
+#define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE                0
+#define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE_REPLICATED     1
+#define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_DUAL_SOURCE_SUBSPAN01         2
+#define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_DUAL_SOURCE_SUBSPAN23         3
+#define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_SINGLE_SOURCE_SUBSPAN01       4
+
+#define BRW_DATAPORT_WRITE_MESSAGE_OWORD_BLOCK_WRITE                0
+#define BRW_DATAPORT_WRITE_MESSAGE_OWORD_DUAL_BLOCK_WRITE           1
+#define BRW_DATAPORT_WRITE_MESSAGE_DWORD_BLOCK_WRITE                2
+#define BRW_DATAPORT_WRITE_MESSAGE_DWORD_SCATTERED_WRITE            3
+#define BRW_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE              4
+#define BRW_DATAPORT_WRITE_MESSAGE_STREAMED_VERTEX_BUFFER_WRITE     5
+#define BRW_DATAPORT_WRITE_MESSAGE_FLUSH_RENDER_CACHE               7
+
+#define BRW_MATH_FUNCTION_INV                              1
+#define BRW_MATH_FUNCTION_LOG                              2
+#define BRW_MATH_FUNCTION_EXP                              3
+#define BRW_MATH_FUNCTION_SQRT                             4
+#define BRW_MATH_FUNCTION_RSQ                              5
+#define BRW_MATH_FUNCTION_SIN                              6 /* was 7 */
+#define BRW_MATH_FUNCTION_COS                              7 /* was 8 */
+#define BRW_MATH_FUNCTION_SINCOS                           8 /* was 6 */
+#define BRW_MATH_FUNCTION_TAN                              9
+#define BRW_MATH_FUNCTION_POW                              10
+#define BRW_MATH_FUNCTION_INT_DIV_QUOTIENT_AND_REMAINDER   11
+#define BRW_MATH_FUNCTION_INT_DIV_QUOTIENT                 12
+#define BRW_MATH_FUNCTION_INT_DIV_REMAINDER                13
+
+#define BRW_MATH_INTEGER_UNSIGNED     0
+#define BRW_MATH_INTEGER_SIGNED       1
+
+#define BRW_MATH_PRECISION_FULL        0
+#define BRW_MATH_PRECISION_PARTIAL     1
+
+#define BRW_MATH_SATURATE_NONE         0
+#define BRW_MATH_SATURATE_SATURATE     1
+
+#define BRW_MATH_DATA_VECTOR  0
+#define BRW_MATH_DATA_SCALAR  1
+
+#define BRW_URB_OPCODE_WRITE  0
+
+#define BRW_URB_SWIZZLE_NONE          0
+#define BRW_URB_SWIZZLE_INTERLEAVE    1
+#define BRW_URB_SWIZZLE_TRANSPOSE     2
+
+#define BRW_SCRATCH_SPACE_SIZE_1K     0
+#define BRW_SCRATCH_SPACE_SIZE_2K     1
+#define BRW_SCRATCH_SPACE_SIZE_4K     2
+#define BRW_SCRATCH_SPACE_SIZE_8K     3
+#define BRW_SCRATCH_SPACE_SIZE_16K    4
+#define BRW_SCRATCH_SPACE_SIZE_32K    5
+#define BRW_SCRATCH_SPACE_SIZE_64K    6
+#define BRW_SCRATCH_SPACE_SIZE_128K   7
+#define BRW_SCRATCH_SPACE_SIZE_256K   8
+#define BRW_SCRATCH_SPACE_SIZE_512K   9
+#define BRW_SCRATCH_SPACE_SIZE_1M     10
+#define BRW_SCRATCH_SPACE_SIZE_2M     11
+
+
+
+
+#define CMD_URB_FENCE                 0x6000
+#define CMD_CS_URB_STATE              0x6001
+#define CMD_CONST_BUFFER              0x6002
+
+#define CMD_STATE_BASE_ADDRESS        0x6101
+#define CMD_STATE_INSN_POINTER        0x6102
+#define CMD_PIPELINE_SELECT_965       0x6104
+#define CMD_PIPELINE_SELECT_GM45      0x6904
+
+#define CMD_PIPELINED_STATE_POINTERS  0x7800
+#define CMD_BINDING_TABLE_PTRS        0x7801
+
+#define CMD_VERTEX_BUFFER             0x7808
+# define BRW_VB0_INDEX_SHIFT           27
+# define BRW_VB0_ACCESS_VERTEXDATA     (0 << 26)
+# define BRW_VB0_ACCESS_INSTANCEDATA   (1 << 26)
+# define BRW_VB0_PITCH_SHIFT           0
+
+#define CMD_VERTEX_ELEMENT            0x7809
+# define BRW_VE0_INDEX_SHIFT           27
+# define BRW_VE0_FORMAT_SHIFT          16
+# define BRW_VE0_VALID                 (1 << 26)
+# define BRW_VE0_SRC_OFFSET_SHIFT      0
+# define BRW_VE1_COMPONENT_NOSTORE     0
+# define BRW_VE1_COMPONENT_STORE_SRC   1
+# define BRW_VE1_COMPONENT_STORE_0     2
+# define BRW_VE1_COMPONENT_STORE_1_FLT 3
+# define BRW_VE1_COMPONENT_STORE_1_INT 4
+# define BRW_VE1_COMPONENT_STORE_VID   5
+# define BRW_VE1_COMPONENT_STORE_IID   6
+# define BRW_VE1_COMPONENT_STORE_PID   7
+# define BRW_VE1_COMPONENT_0_SHIFT     28
+# define BRW_VE1_COMPONENT_1_SHIFT     24
+# define BRW_VE1_COMPONENT_2_SHIFT     20
+# define BRW_VE1_COMPONENT_3_SHIFT     16
+# define BRW_VE1_DST_OFFSET_SHIFT      0
+
+#define CMD_INDEX_BUFFER              0x780a
+#define CMD_VF_STATISTICS_965         0x780b
+#define CMD_VF_STATISTICS_GM45        0x680b
+
+#define CMD_DRAW_RECT                 0x7900
+#define CMD_BLEND_CONSTANT_COLOR      0x7901
+#define CMD_CHROMA_KEY                0x7904
+#define CMD_DEPTH_BUFFER              0x7905
+#define CMD_POLY_STIPPLE_OFFSET       0x7906
+#define CMD_POLY_STIPPLE_PATTERN      0x7907
+#define CMD_LINE_STIPPLE_PATTERN      0x7908
+#define CMD_GLOBAL_DEPTH_OFFSET_CLAMP 0x7909
+#define CMD_AA_LINE_PARAMETERS        0x790a
+
+#define CMD_PIPE_CONTROL              0x7a00
+
+#define CMD_3D_PRIM                   0x7b00
+
+#define CMD_MI_FLUSH                  0x0200
+
+
+/* Various values from the R0 vertex header:
+ */
+#define R02_PRIM_END    0x1
+#define R02_PRIM_START  0x2
+
+#define URB_SIZES(brw)                  (BRW_IS_IGDNG(brw) ? 1024 : \
+                                         (BRW_IS_G4X(brw) ? 384 : 256))  /* 512 bit units */
+
+
+
+#endif
diff --git a/src/gallium/drivers/i965/brw_disasm.c b/src/gallium/drivers/i965/brw_disasm.c
new file mode 100644 (file)
index 0000000..65db272
--- /dev/null
@@ -0,0 +1,922 @@
+/*
+ * Copyright © 2008 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <getopt.h>
+#include <unistd.h>
+#include <stdarg.h>
+
+#include "brw_disasm.h"
+#include "brw_structs.h"
+#include "brw_reg.h"
+#include "brw_defines.h"
+
+struct {
+    char    *name;
+    int            nsrc;
+    int            ndst;
+} opcode[128] = {
+    [BRW_OPCODE_MOV] = { .name = "mov", .nsrc = 1, .ndst = 1 },
+    [BRW_OPCODE_FRC] = { .name = "frc", .nsrc = 1, .ndst = 1 },
+    [BRW_OPCODE_RNDU] = { .name = "rndu", .nsrc = 1, .ndst = 1 },
+    [BRW_OPCODE_RNDD] = { .name = "rndd", .nsrc = 1, .ndst = 1 },
+    [BRW_OPCODE_RNDE] = { .name = "rnde", .nsrc = 1, .ndst = 1 },
+    [BRW_OPCODE_RNDZ] = { .name = "rndz", .nsrc = 1, .ndst = 1 },
+    [BRW_OPCODE_NOT] = { .name = "not", .nsrc = 1, .ndst = 1 },
+    [BRW_OPCODE_LZD] = { .name = "lzd", .nsrc = 1, .ndst = 1 },
+
+    [BRW_OPCODE_MUL] = { .name = "mul", .nsrc = 2, .ndst = 1 },
+    [BRW_OPCODE_MAC] = { .name = "mac", .nsrc = 2, .ndst = 1 },
+    [BRW_OPCODE_MACH] = { .name = "mach", .nsrc = 2, .ndst = 1 },
+    [BRW_OPCODE_LINE] = { .name = "line", .nsrc = 2, .ndst = 1 },
+    [BRW_OPCODE_SAD2] = { .name = "sad2", .nsrc = 2, .ndst = 1 },
+    [BRW_OPCODE_SADA2] = { .name = "sada2", .nsrc = 2, .ndst = 1 },
+    [BRW_OPCODE_DP4] = { .name = "dp4", .nsrc = 2, .ndst = 1 },
+    [BRW_OPCODE_DPH] = { .name = "dph", .nsrc = 2, .ndst = 1 },
+    [BRW_OPCODE_DP3] = { .name = "dp3", .nsrc = 2, .ndst = 1 },
+    [BRW_OPCODE_DP2] = { .name = "dp2", .nsrc = 2, .ndst = 1 },
+
+    [BRW_OPCODE_AVG] = { .name = "avg", .nsrc = 2, .ndst = 1 },
+    [BRW_OPCODE_ADD] = { .name = "add", .nsrc = 2, .ndst = 1 },
+    [BRW_OPCODE_SEL] = { .name = "sel", .nsrc = 2, .ndst = 1 },
+    [BRW_OPCODE_AND] = { .name = "and", .nsrc = 2, .ndst = 1 },
+    [BRW_OPCODE_OR] = { .name = "or", .nsrc = 2, .ndst = 1 },
+    [BRW_OPCODE_XOR] = { .name = "xor", .nsrc = 2, .ndst = 1 },
+    [BRW_OPCODE_SHR] = { .name = "shr", .nsrc = 2, .ndst = 1 },
+    [BRW_OPCODE_SHL] = { .name = "shl", .nsrc = 2, .ndst = 1 },
+    [BRW_OPCODE_ASR] = { .name = "asr", .nsrc = 2, .ndst = 1 },
+    [BRW_OPCODE_CMP] = { .name = "cmp", .nsrc = 2, .ndst = 1 },
+    [BRW_OPCODE_CMPN] = { .name = "cmpn", .nsrc = 2, .ndst = 1 },
+
+    [BRW_OPCODE_SEND] = { .name = "send", .nsrc = 1, .ndst = 1 },
+    [BRW_OPCODE_NOP] = { .name = "nop", .nsrc = 0, .ndst = 0 },
+    [BRW_OPCODE_JMPI] = { .name = "jmpi", .nsrc = 1, .ndst = 0 },
+    [BRW_OPCODE_IF] = { .name = "if", .nsrc = 2, .ndst = 0 },
+    [BRW_OPCODE_IFF] = { .name = "iff", .nsrc = 1, .ndst = 01 },
+    [BRW_OPCODE_WHILE] = { .name = "while", .nsrc = 1, .ndst = 0 },
+    [BRW_OPCODE_ELSE] = { .name = "else", .nsrc = 2, .ndst = 0 },
+    [BRW_OPCODE_BREAK] = { .name = "break", .nsrc = 1, .ndst = 0 },
+    [BRW_OPCODE_CONTINUE] = { .name = "cont", .nsrc = 1, .ndst = 0 },
+    [BRW_OPCODE_HALT] = { .name = "halt", .nsrc = 1, .ndst = 0 },
+    [BRW_OPCODE_MSAVE] = { .name = "msave", .nsrc = 1, .ndst = 1 },
+    [BRW_OPCODE_PUSH] = { .name = "push", .nsrc = 1, .ndst = 1 },
+    [BRW_OPCODE_MRESTORE] = { .name = "mrest", .nsrc = 1, .ndst = 1 },
+    [BRW_OPCODE_POP] = { .name = "pop", .nsrc = 2, .ndst = 0 },
+    [BRW_OPCODE_WAIT] = { .name = "wait", .nsrc = 1, .ndst = 0 },
+    [BRW_OPCODE_DO] = { .name = "do", .nsrc = 0, .ndst = 0 },
+    [BRW_OPCODE_ENDIF] = { .name = "endif", .nsrc = 2, .ndst = 0 },
+};
+
+char *conditional_modifier[16] = {
+    [BRW_CONDITIONAL_NONE] = "",
+    [BRW_CONDITIONAL_Z] = ".e",
+    [BRW_CONDITIONAL_NZ] = ".ne",
+    [BRW_CONDITIONAL_G] = ".g",
+    [BRW_CONDITIONAL_GE] = ".ge",
+    [BRW_CONDITIONAL_L] = ".l",
+    [BRW_CONDITIONAL_LE] = ".le",
+    [BRW_CONDITIONAL_R] = ".r",
+    [BRW_CONDITIONAL_O] = ".o",
+    [BRW_CONDITIONAL_U] = ".u",
+};
+
+char *negate[2] = {
+    [0] = "",
+    [1] = "-",
+};
+
+char *_abs[2] = {
+    [0] = "",
+    [1] = "(abs)",
+};
+
+char *vert_stride[16] = {
+    [0] = "0",
+    [1] = "1",
+    [2] = "2",
+    [3] = "4",
+    [4] = "8",
+    [5] = "16",
+    [6] = "32",
+    [15] = "VxH",
+};
+
+char *width[8] = {
+    [0] = "1",
+    [1] = "2",
+    [2] = "4",
+    [3] = "8",
+    [4] = "16",
+};
+
+char *horiz_stride[4] = {
+    [0] = "0",
+    [1] = "1",
+    [2] = "2",
+    [3] = "4"
+};
+
+char *chan_sel[4] = {
+    [0] = "x",
+    [1] = "y",
+    [2] = "z",
+    [3] = "w",
+};
+
+char *dest_condmod[16] = {
+   [0] = NULL
+};
+
+char *debug_ctrl[2] = {
+    [0] = "",
+    [1] = ".breakpoint"
+};
+
+char *saturate[2] = {
+    [0] = "",
+    [1] = ".sat"
+};
+
+char *exec_size[8] = {
+    [0] = "1",
+    [1] = "2",
+    [2] = "4",
+    [3] = "8",
+    [4] = "16",
+    [5] = "32"
+};
+
+char *pred_inv[2] = {
+    [0] = "+",
+    [1] = "-"
+};
+
+char *pred_ctrl_align16[16] = {
+    [1] = "",
+    [2] = ".x",
+    [3] = ".y",
+    [4] = ".z",
+    [5] = ".w",
+    [6] = ".any4h",
+    [7] = ".all4h",
+};
+
+char *pred_ctrl_align1[16] = {
+    [1] = "",
+    [2] = ".anyv",
+    [3] = ".allv",
+    [4] = ".any2h",
+    [5] = ".all2h",
+    [6] = ".any4h",
+    [7] = ".all4h",
+    [8] = ".any8h",
+    [9] = ".all8h",
+    [10] = ".any16h",
+    [11] = ".all16h",
+};
+
+char *thread_ctrl[4] = {
+    [0] = "",
+    [2] = "switch"
+};
+
+char *compr_ctrl[4] = {
+    [0] = "",
+    [1] = "sechalf",
+    [2] = "compr",
+};
+
+char *dep_ctrl[4] = {
+    [0] = "",
+    [1] = "NoDDClr",
+    [2] = "NoDDChk",
+    [3] = "NoDDClr,NoDDChk",
+};
+
+char *mask_ctrl[4] = {
+    [0] = "",
+    [1] = "nomask",
+};
+
+char *access_mode[2] = {
+    [0] = "align1",
+    [1] = "align16",
+};
+
+char *reg_encoding[8] = {
+    [0] = "UD",
+    [1] = "D",
+    [2] = "UW",
+    [3] = "W",
+    [4] = "UB",
+    [5] = "B",
+    [7] = "F"
+};
+
+char *imm_encoding[8] = {
+    [0] = "UD",
+    [1] = "D",
+    [2] = "UW",
+    [3] = "W",
+    [5] = "VF",
+    [5] = "V",
+    [7] = "F"
+};
+
+char *reg_file[4] = {
+    [0] = "A",
+    [1] = "g",
+    [2] = "m",
+    [3] = "imm",
+};
+
+char *writemask[16] = {
+    [0x0] = ".",
+    [0x1] = ".x",
+    [0x2] = ".y",
+    [0x3] = ".xy",
+    [0x4] = ".z",
+    [0x5] = ".xz",
+    [0x6] = ".yz",
+    [0x7] = ".xyz",
+    [0x8] = ".w",
+    [0x9] = ".xw",
+    [0xa] = ".yw",
+    [0xb] = ".xyw",
+    [0xc] = ".zw",
+    [0xd] = ".xzw",
+    [0xe] = ".yzw",
+    [0xf] = "",
+};
+
+char *end_of_thread[2] = {
+    [0] = "",
+    [1] = "EOT"
+};
+
+char *target_function[16] = {
+    [BRW_MESSAGE_TARGET_NULL] = "null",
+    [BRW_MESSAGE_TARGET_MATH] = "math",
+    [BRW_MESSAGE_TARGET_SAMPLER] = "sampler",
+    [BRW_MESSAGE_TARGET_GATEWAY] = "gateway",
+    [BRW_MESSAGE_TARGET_DATAPORT_READ] = "read",
+    [BRW_MESSAGE_TARGET_DATAPORT_WRITE] = "write",
+    [BRW_MESSAGE_TARGET_URB] = "urb",
+    [BRW_MESSAGE_TARGET_THREAD_SPAWNER] = "thread_spawner"
+};
+
+char *math_function[16] = {
+    [BRW_MATH_FUNCTION_INV] = "inv",
+    [BRW_MATH_FUNCTION_LOG] = "log",
+    [BRW_MATH_FUNCTION_EXP] = "exp",
+    [BRW_MATH_FUNCTION_SQRT] = "sqrt",
+    [BRW_MATH_FUNCTION_RSQ] = "rsq",
+    [BRW_MATH_FUNCTION_SIN] = "sin",
+    [BRW_MATH_FUNCTION_COS] = "cos",
+    [BRW_MATH_FUNCTION_SINCOS] = "sincos",
+    [BRW_MATH_FUNCTION_TAN] = "tan",
+    [BRW_MATH_FUNCTION_POW] = "pow",
+    [BRW_MATH_FUNCTION_INT_DIV_QUOTIENT_AND_REMAINDER] = "intdivmod",
+    [BRW_MATH_FUNCTION_INT_DIV_QUOTIENT] = "intmod",
+    [BRW_MATH_FUNCTION_INT_DIV_REMAINDER] = "intdiv",
+};
+
+char *math_saturate[2] = {
+    [0] = "",
+    [1] = "sat"
+};
+
+char *math_signed[2] = {
+    [0] = "",
+    [1] = "signed"
+};
+
+char *math_scalar[2] = {
+    [0] = "",
+    [1] = "scalar"
+};
+
+char *math_precision[2] = {
+    [0] = "",
+    [1] = "partial_precision"
+};
+
+char *urb_swizzle[4] = {
+    [BRW_URB_SWIZZLE_NONE] = "",
+    [BRW_URB_SWIZZLE_INTERLEAVE] = "interleave",
+    [BRW_URB_SWIZZLE_TRANSPOSE] = "transpose",
+};
+
+char *urb_allocate[2] = {
+    [0] = "",
+    [1] = "allocate"
+};
+
+char *urb_used[2] = {
+    [0] = "",
+    [1] = "used"
+};
+
+char *urb_complete[2] = {
+    [0] = "",
+    [1] = "complete"
+};
+
+char *sampler_target_format[4] = {
+    [0] = "F",
+    [2] = "UD",
+    [3] = "D"
+};
+
+
+static int column;
+
+static int string (FILE *file, char *string)
+{
+    fputs (string, file);
+    column += strlen (string);
+    return 0;
+}
+
+static int format (FILE *f, char *format, ...)
+{
+    char    buf[1024];
+    va_list    args;
+    va_start (args, format);
+
+    vsnprintf (buf, sizeof (buf) - 1, format, args);
+    string (f, buf);
+    return 0;
+}
+
+static int newline (FILE *f)
+{
+    putc ('\n', f);
+    column = 0;
+    return 0;
+}
+
+static int pad (FILE *f, int c)
+{
+    do
+       string (f, " ");
+    while (column < c);
+    return 0;
+}
+
+static int control (FILE *file, char *name, char *ctrl[], GLuint id, int *space)
+{
+    if (!ctrl[id]) {
+       fprintf (file, "*** invalid %s value %d ",
+                name, id);
+       return 1;
+    }
+    if (ctrl[id][0])
+    {
+       if (space && *space)
+           string (file, " ");
+       string (file, ctrl[id]);
+       if (space)
+           *space = 1;
+    }
+    return 0;
+}
+
+static int print_opcode (FILE *file, int id)
+{
+    if (!opcode[id].name) {
+       format (file, "*** invalid opcode value %d ", id);
+       return 1;
+    }
+    string (file, opcode[id].name);
+    return 0;
+}
+
+static int reg (FILE *file, GLuint _reg_file, GLuint _reg_nr)
+{
+    int        err = 0;
+    if (_reg_file == BRW_ARCHITECTURE_REGISTER_FILE) {
+       switch (_reg_nr & 0xf0) {
+       case BRW_ARF_NULL:
+           string (file, "null");
+           return -1;
+       case BRW_ARF_ADDRESS:
+           format (file, "a%d", _reg_nr & 0x0f);
+           break;
+       case BRW_ARF_ACCUMULATOR:
+           format (file, "acc%d", _reg_nr & 0x0f);
+           break;
+       case BRW_ARF_MASK:
+           format (file, "mask%d", _reg_nr & 0x0f);
+           break;
+       case BRW_ARF_MASK_STACK:
+           format (file, "msd%d", _reg_nr & 0x0f);
+           break;
+       case BRW_ARF_STATE:
+           format (file, "sr%d", _reg_nr & 0x0f);
+           break;
+       case BRW_ARF_CONTROL:
+           format (file, "cr%d", _reg_nr & 0x0f);
+           break;
+       case BRW_ARF_NOTIFICATION_COUNT:
+           format (file, "n%d", _reg_nr & 0x0f);
+           break;
+       case BRW_ARF_IP:
+           string (file, "ip");
+           return -1;
+           break;
+       default:
+           format (file, "ARF%d", _reg_nr);
+           break;
+       }
+    } else {
+       err  |= control (file, "src reg file", reg_file, _reg_file, NULL);
+       format (file, "%d", _reg_nr);
+    }
+    return err;
+}
+
+static int dest (FILE *file, const struct brw_instruction *inst)
+{
+    int        err = 0;
+
+    if (inst->header.access_mode == BRW_ALIGN_1)
+    {
+       if (inst->bits1.da1.dest_address_mode == BRW_ADDRESS_DIRECT)
+       {
+           err |= reg (file, inst->bits1.da1.dest_reg_file, inst->bits1.da1.dest_reg_nr);
+           if (err == -1)
+               return 0;
+           if (inst->bits1.da1.dest_subreg_nr)
+               format (file, ".%d", inst->bits1.da1.dest_subreg_nr);
+           format (file, "<%d>", inst->bits1.da1.dest_horiz_stride);
+           err |= control (file, "dest reg encoding", reg_encoding, inst->bits1.da1.dest_reg_type, NULL);
+       }
+       else
+       {
+           string (file, "g[a0");
+           if (inst->bits1.ia1.dest_subreg_nr)
+               format (file, ".%d", inst->bits1.ia1.dest_subreg_nr);
+           if (inst->bits1.ia1.dest_indirect_offset)
+               format (file, " %d", inst->bits1.ia1.dest_indirect_offset);
+           string (file, "]");
+           format (file, "<%d>", inst->bits1.ia1.dest_horiz_stride);
+           err |= control (file, "dest reg encoding", reg_encoding, inst->bits1.ia1.dest_reg_type, NULL);
+       }
+    }
+    else
+    {
+       if (inst->bits1.da16.dest_address_mode == BRW_ADDRESS_DIRECT)
+       {
+           err |= reg (file, inst->bits1.da16.dest_reg_file, inst->bits1.da16.dest_reg_nr);
+           if (err == -1)
+               return 0;
+           if (inst->bits1.da16.dest_subreg_nr)
+               format (file, ".%d", inst->bits1.da16.dest_subreg_nr);
+           string (file, "<1>");
+           err |= control (file, "writemask", writemask, inst->bits1.da16.dest_writemask, NULL);
+           err |= control (file, "dest reg encoding", reg_encoding, inst->bits1.da16.dest_reg_type, NULL);
+       }
+       else
+       {
+           err = 1;
+           string (file, "Indirect align16 address mode not supported");
+       }
+    }
+
+    return 0;
+}
+
+static int src_align1_region (FILE *file,
+                             GLuint _vert_stride, GLuint _width, GLuint _horiz_stride)
+{
+    int err = 0;
+    string (file, "<");
+    err |= control (file, "vert stride", vert_stride, _vert_stride, NULL);
+    string (file, ",");
+    err |= control (file, "width", width, _width, NULL);
+    string (file, ",");
+    err |= control (file, "horiz_stride", horiz_stride, _horiz_stride, NULL);
+    string (file, ">");
+    return err;
+}
+
+static int src_da1 (FILE *file, GLuint type, GLuint _reg_file,
+                   GLuint _vert_stride, GLuint _width, GLuint _horiz_stride,
+                   GLuint reg_num, GLuint sub_reg_num, GLuint __abs, GLuint _negate)
+{
+    int err = 0;
+    err |= control (file, "negate", negate, _negate, NULL);
+    err |= control (file, "abs", _abs, __abs, NULL);
+
+    err |= reg (file, _reg_file, reg_num);
+    if (err == -1)
+       return 0;
+    if (sub_reg_num)
+       format (file, ".%d", sub_reg_num);
+    src_align1_region (file, _vert_stride, _width, _horiz_stride);
+    err |= control (file, "src reg encoding", reg_encoding, type, NULL);
+    return err;
+}
+
+static int src_ia1 (FILE *file,
+                   GLuint type,
+                   GLuint _reg_file,
+                   GLint _addr_imm,
+                   GLuint _addr_subreg_nr,
+                   GLuint _negate,
+                   GLuint __abs,
+                   GLuint _addr_mode,
+                   GLuint _horiz_stride,
+                   GLuint _width,
+                   GLuint _vert_stride)
+{
+    int err = 0;
+    err |= control (file, "negate", negate, _negate, NULL);
+    err |= control (file, "abs", _abs, __abs, NULL);
+
+    string (file, "g[a0");
+    if (_addr_subreg_nr)
+       format (file, ".%d", _addr_subreg_nr);
+    if (_addr_imm)
+       format (file, " %d", _addr_imm);
+    string (file, "]");
+    src_align1_region (file, _vert_stride, _width, _horiz_stride);
+    err |= control (file, "src reg encoding", reg_encoding, type, NULL);
+    return err;
+}
+
+static int src_da16 (FILE *file,
+                    GLuint _reg_type,
+                    GLuint _reg_file,
+                    GLuint _vert_stride,
+                    GLuint _reg_nr,
+                    GLuint _subreg_nr,
+                    GLuint __abs,
+                    GLuint _negate,
+                    GLuint swz_x,
+                    GLuint swz_y,
+                    GLuint swz_z,
+                    GLuint swz_w)
+{
+    int err = 0;
+    err |= control (file, "negate", negate, _negate, NULL);
+    err |= control (file, "abs", _abs, __abs, NULL);
+
+    err |= reg (file, _reg_file, _reg_nr);
+    if (err == -1)
+       return 0;
+    if (_subreg_nr)
+       format (file, ".%d", _subreg_nr);
+    string (file, "<");
+    err |= control (file, "vert stride", vert_stride, _vert_stride, NULL);
+    string (file, ",1,1>");
+    err |= control (file, "src da16 reg type", reg_encoding, _reg_type, NULL);
+    /*
+     * Three kinds of swizzle display:
+     *  identity - nothing printed
+     *  1->all  - print the single channel
+     *  1->1     - print the mapping
+     */
+    if (swz_x == BRW_CHANNEL_X &&
+       swz_y == BRW_CHANNEL_Y &&
+       swz_z == BRW_CHANNEL_Z &&
+       swz_w == BRW_CHANNEL_W)
+    {
+       ;
+    }
+    else if (swz_x == swz_y && swz_x == swz_z && swz_x == swz_w)
+    {
+       string (file, ".");
+       err |= control (file, "channel select", chan_sel, swz_x, NULL);
+    }
+    else
+    {
+       string (file, ".");
+       err |= control (file, "channel select", chan_sel, swz_x, NULL);
+       err |= control (file, "channel select", chan_sel, swz_y, NULL);
+       err |= control (file, "channel select", chan_sel, swz_z, NULL);
+       err |= control (file, "channel select", chan_sel, swz_w, NULL);
+    }
+    return err;
+}
+
+
+static int imm (FILE *file, GLuint type, const struct brw_instruction *inst) {
+    switch (type) {
+    case BRW_REGISTER_TYPE_UD:
+       format (file, "0x%08xUD", inst->bits3.ud);
+       break;
+    case BRW_REGISTER_TYPE_D:
+       format (file, "%dD", inst->bits3.d);
+       break;
+    case BRW_REGISTER_TYPE_UW:
+       format (file, "0x%04xUW", (uint16_t) inst->bits3.ud);
+       break;
+    case BRW_REGISTER_TYPE_W:
+       format (file, "%dW", (int16_t) inst->bits3.d);
+       break;
+    case BRW_REGISTER_TYPE_UB:
+       format (file, "0x%02xUB", (int8_t) inst->bits3.ud);
+       break;
+    case BRW_REGISTER_TYPE_VF:
+       format (file, "Vector Float");
+       break;
+    case BRW_REGISTER_TYPE_V:
+       format (file, "0x%08xV", inst->bits3.ud);
+       break;
+    case BRW_REGISTER_TYPE_F:
+       format (file, "%-gF", inst->bits3.f);
+    }
+    return 0;
+}
+
+static int src0 (FILE *file, const struct brw_instruction *inst)
+{
+    if (inst->bits1.da1.src0_reg_file == BRW_IMMEDIATE_VALUE)
+       return imm (file, inst->bits1.da1.src0_reg_type,
+                   inst);
+    else if (inst->header.access_mode == BRW_ALIGN_1)
+    {
+       if (inst->bits2.da1.src0_address_mode == BRW_ADDRESS_DIRECT)
+       {
+           return src_da1 (file,
+                           inst->bits1.da1.src0_reg_type,
+                           inst->bits1.da1.src0_reg_file,
+                           inst->bits2.da1.src0_vert_stride,
+                           inst->bits2.da1.src0_width,
+                           inst->bits2.da1.src0_horiz_stride,
+                           inst->bits2.da1.src0_reg_nr,
+                           inst->bits2.da1.src0_subreg_nr,
+                           inst->bits2.da1.src0_abs,
+                           inst->bits2.da1.src0_negate);
+       }
+       else
+       {
+           return src_ia1 (file,
+                           inst->bits1.ia1.src0_reg_type,
+                           inst->bits1.ia1.src0_reg_file,
+                           inst->bits2.ia1.src0_indirect_offset,
+                           inst->bits2.ia1.src0_subreg_nr,
+                           inst->bits2.ia1.src0_negate,
+                           inst->bits2.ia1.src0_abs,
+                           inst->bits2.ia1.src0_address_mode,
+                           inst->bits2.ia1.src0_horiz_stride,
+                           inst->bits2.ia1.src0_width,
+                           inst->bits2.ia1.src0_vert_stride);
+       }
+    }
+    else
+    {
+       if (inst->bits2.da16.src0_address_mode == BRW_ADDRESS_DIRECT)
+       {
+           return src_da16 (file,
+                            inst->bits1.da16.src0_reg_type,
+                            inst->bits1.da16.src0_reg_file,
+                            inst->bits2.da16.src0_vert_stride,
+                            inst->bits2.da16.src0_reg_nr,
+                            inst->bits2.da16.src0_subreg_nr,
+                            inst->bits2.da16.src0_abs,
+                            inst->bits2.da16.src0_negate,
+                            inst->bits2.da16.src0_swz_x,
+                            inst->bits2.da16.src0_swz_y,
+                            inst->bits2.da16.src0_swz_z,
+                            inst->bits2.da16.src0_swz_w);
+       }
+       else
+       {
+           string (file, "Indirect align16 address mode not supported");
+           return 1;
+       }
+    }
+}
+
+static int src1 (FILE *file, const struct brw_instruction *inst)
+{
+    if (inst->bits1.da1.src1_reg_file == BRW_IMMEDIATE_VALUE)
+       return imm (file, inst->bits1.da1.src1_reg_type,
+                   inst);
+    else if (inst->header.access_mode == BRW_ALIGN_1)
+    {
+       if (inst->bits3.da1.src1_address_mode == BRW_ADDRESS_DIRECT)
+       {
+           return src_da1 (file,
+                           inst->bits1.da1.src1_reg_type,
+                           inst->bits1.da1.src1_reg_file,
+                           inst->bits3.da1.src1_vert_stride,
+                           inst->bits3.da1.src1_width,
+                           inst->bits3.da1.src1_horiz_stride,
+                           inst->bits3.da1.src1_reg_nr,
+                           inst->bits3.da1.src1_subreg_nr,
+                           inst->bits3.da1.src1_abs,
+                           inst->bits3.da1.src1_negate);
+       }
+       else
+       {
+           return src_ia1 (file,
+                           inst->bits1.ia1.src1_reg_type,
+                           inst->bits1.ia1.src1_reg_file,
+                           inst->bits3.ia1.src1_indirect_offset,
+                           inst->bits3.ia1.src1_subreg_nr,
+                           inst->bits3.ia1.src1_negate,
+                           inst->bits3.ia1.src1_abs,
+                           inst->bits3.ia1.src1_address_mode,
+                           inst->bits3.ia1.src1_horiz_stride,
+                           inst->bits3.ia1.src1_width,
+                           inst->bits3.ia1.src1_vert_stride);
+       }
+    }
+    else
+    {
+       if (inst->bits3.da16.src1_address_mode == BRW_ADDRESS_DIRECT)
+       {
+           return src_da16 (file,
+                            inst->bits1.da16.src1_reg_type,
+                            inst->bits1.da16.src1_reg_file,
+                            inst->bits3.da16.src1_vert_stride,
+                            inst->bits3.da16.src1_reg_nr,
+                            inst->bits3.da16.src1_subreg_nr,
+                            inst->bits3.da16.src1_abs,
+                            inst->bits3.da16.src1_negate,
+                            inst->bits3.da16.src1_swz_x,
+                            inst->bits3.da16.src1_swz_y,
+                            inst->bits3.da16.src1_swz_z,
+                            inst->bits3.da16.src1_swz_w);
+       }
+       else
+       {
+           string (file, "Indirect align16 address mode not supported");
+           return 1;
+       }
+    }
+}
+
+int brw_disasm_insn (FILE *file, const struct brw_instruction *inst)
+{
+    int        err = 0;
+    int space = 0;
+
+    if (inst->header.predicate_control) {
+       string (file, "(");
+       err |= control (file, "predicate inverse", pred_inv, inst->header.predicate_inverse, NULL);
+       string (file, "f0");
+       if (inst->bits2.da1.flag_reg_nr)
+           format (file, ".%d", inst->bits2.da1.flag_reg_nr);
+       if (inst->header.access_mode == BRW_ALIGN_1)
+           err |= control (file, "predicate control align1", pred_ctrl_align1,
+                           inst->header.predicate_control, NULL);
+       else
+           err |= control (file, "predicate control align16", pred_ctrl_align16,
+                           inst->header.predicate_control, NULL);
+       string (file, ") ");
+    }
+
+    err |= print_opcode (file, inst->header.opcode);
+    err |= control (file, "saturate", saturate, inst->header.saturate, NULL);
+    err |= control (file, "debug control", debug_ctrl, inst->header.debug_control, NULL);
+
+    if (inst->header.opcode != BRW_OPCODE_SEND)
+       err |= control (file, "conditional modifier", conditional_modifier,
+                       inst->header.destreg__conditionalmod, NULL);
+
+    if (inst->header.opcode != BRW_OPCODE_NOP) {
+       string (file, "(");
+       err |= control (file, "execution size", exec_size, inst->header.execution_size, NULL);
+       string (file, ")");
+    }
+
+    if (inst->header.opcode == BRW_OPCODE_SEND)
+       format (file, " %d", inst->header.destreg__conditionalmod);
+
+    if (opcode[inst->header.opcode].ndst > 0) {
+       pad (file, 16);
+       err |= dest (file, inst);
+    }
+    if (opcode[inst->header.opcode].nsrc > 0) {
+       pad (file, 32);
+       err |= src0 (file, inst);
+    }
+    if (opcode[inst->header.opcode].nsrc > 1) {
+       pad (file, 48);
+       err |= src1 (file, inst);
+    }
+
+    if (inst->header.opcode == BRW_OPCODE_SEND) {
+       newline (file);
+       pad (file, 16);
+       space = 0;
+       err |= control (file, "target function", target_function,
+                       inst->bits3.generic.msg_target, &space);
+       switch (inst->bits3.generic.msg_target) {
+       case BRW_MESSAGE_TARGET_MATH:
+           err |= control (file, "math function", math_function,
+                           inst->bits3.math.function, &space);
+           err |= control (file, "math saturate", math_saturate,
+                           inst->bits3.math.saturate, &space);
+           err |= control (file, "math signed", math_signed,
+                           inst->bits3.math.int_type, &space);
+           err |= control (file, "math scalar", math_scalar,
+                           inst->bits3.math.data_type, &space);
+           err |= control (file, "math precision", math_precision,
+                           inst->bits3.math.precision, &space);
+           break;
+       case BRW_MESSAGE_TARGET_SAMPLER:
+           format (file, " (%d, %d, ",
+                   inst->bits3.sampler.binding_table_index,
+                   inst->bits3.sampler.sampler);
+           err |= control (file, "sampler target format", sampler_target_format,
+                           inst->bits3.sampler.return_format, NULL);
+           string (file, ")");
+           break;
+       case BRW_MESSAGE_TARGET_DATAPORT_WRITE:
+           format (file, " (%d, %d, %d, %d)",
+                   inst->bits3.dp_write.binding_table_index,
+                   (inst->bits3.dp_write.pixel_scoreboard_clear << 3) |
+                   inst->bits3.dp_write.msg_control,
+                   inst->bits3.dp_write.msg_type,
+                   inst->bits3.dp_write.send_commit_msg);
+           break;
+       case BRW_MESSAGE_TARGET_URB:
+           format (file, " %d", inst->bits3.urb.offset);
+           space = 1;
+           err |= control (file, "urb swizzle", urb_swizzle,
+                           inst->bits3.urb.swizzle_control, &space);
+           err |= control (file, "urb allocate", urb_allocate,
+                           inst->bits3.urb.allocate, &space);
+           err |= control (file, "urb used", urb_used,
+                           inst->bits3.urb.used, &space);
+           err |= control (file, "urb complete", urb_complete,
+                           inst->bits3.urb.complete, &space);
+           break;
+       case BRW_MESSAGE_TARGET_THREAD_SPAWNER:
+           break;
+       default:
+           format (file, "unsupported target %d", inst->bits3.generic.msg_target);
+           break;
+       }
+       if (space)
+           string (file, " ");
+       format (file, "mlen %d",
+               inst->bits3.generic.msg_length);
+       format (file, " rlen %d",
+               inst->bits3.generic.response_length);
+    }
+    pad (file, 64);
+    if (inst->header.opcode != BRW_OPCODE_NOP) {
+       string (file, "{");
+       space = 1;
+       err |= control(file, "access mode", access_mode, inst->header.access_mode, &space);
+       err |= control (file, "mask control", mask_ctrl, inst->header.mask_control, &space);
+       err |= control (file, "dependency control", dep_ctrl, inst->header.dependency_control, &space);
+       err |= control (file, "compression control", compr_ctrl, inst->header.compression_control, &space);
+       err |= control (file, "thread control", thread_ctrl, inst->header.thread_control, &space);
+       if (inst->header.opcode == BRW_OPCODE_SEND)
+           err |= control (file, "end of thread", end_of_thread,
+                           inst->bits3.generic.end_of_thread, &space);
+       if (space)
+           string (file, " ");
+       string (file, "}");
+    }
+    string (file, ";");
+    newline (file);
+    return err;
+}
+
+
+int brw_disasm (FILE *file, 
+                const struct brw_instruction *inst,
+                unsigned count)
+{
+   int i, err;
+
+   for (i = 0; i < count; i++) {
+      err = brw_disasm_insn(stderr, &inst[i]);
+      if (err)
+         return err;
+   }
+
+   fprintf(file, "\n");
+   return 0;
+}
+
diff --git a/src/gallium/drivers/i965/brw_disasm.h b/src/gallium/drivers/i965/brw_disasm.h
new file mode 100644 (file)
index 0000000..ba5b109
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright © 2008 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#ifndef BRW_DISASM_H
+#define BRW_DISASM_H
+
+#include <stdio.h>
+
+struct brw_instruction;
+
+int brw_disasm_insn (FILE *file, const struct brw_instruction *inst);
+int brw_disasm (FILE *file, 
+                const struct brw_instruction *inst,
+                unsigned count);
+
+#endif
+
diff --git a/src/gallium/drivers/i965/brw_draw.c b/src/gallium/drivers/i965/brw_draw.c
new file mode 100644 (file)
index 0000000..ea8d39a
--- /dev/null
@@ -0,0 +1,289 @@
+/**************************************************************************
+ * 
+ * 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 "util/u_prim.h"
+#include "util/u_upload_mgr.h"
+
+#include "brw_draw.h"
+#include "brw_defines.h"
+#include "brw_context.h"
+#include "brw_state.h"
+#include "brw_debug.h"
+#include "brw_screen.h"
+
+#include "brw_batchbuffer.h"
+
+
+static uint32_t prim_to_hw_prim[PIPE_PRIM_POLYGON+1] = {
+   _3DPRIM_POINTLIST,
+   _3DPRIM_LINELIST,
+   _3DPRIM_LINELOOP,
+   _3DPRIM_LINESTRIP,
+   _3DPRIM_TRILIST,
+   _3DPRIM_TRISTRIP,
+   _3DPRIM_TRIFAN,
+   _3DPRIM_QUADLIST,
+   _3DPRIM_QUADSTRIP,
+   _3DPRIM_POLYGON
+};
+
+
+
+/* When the primitive changes, set a state bit and re-validate.  Not
+ * the nicest and would rather deal with this by having all the
+ * programs be immune to the active primitive (ie. cope with all
+ * possibilities).  That may not be realistic however.
+ */
+static int brw_set_prim(struct brw_context *brw, unsigned prim )
+{
+
+   if (BRW_DEBUG & DEBUG_PRIMS)
+      debug_printf("PRIM: %s\n", u_prim_name(prim));
+   
+   if (prim != brw->primitive) {
+      unsigned reduced_prim;
+
+      brw->primitive = prim;
+      brw->state.dirty.brw |= BRW_NEW_PRIMITIVE;
+
+      reduced_prim = u_reduced_prim(prim);
+      if (reduced_prim != brw->reduced_primitive) {
+        brw->reduced_primitive = reduced_prim;
+        brw->state.dirty.brw |= BRW_NEW_REDUCED_PRIMITIVE;
+      }
+   }
+
+   return prim_to_hw_prim[prim];
+}
+
+
+
+static int brw_emit_prim(struct brw_context *brw,
+                        unsigned start,
+                        unsigned count,
+                        boolean indexed,
+                        uint32_t hw_prim)
+{
+   struct brw_3d_primitive prim_packet;
+   int ret;
+
+   if (BRW_DEBUG & DEBUG_PRIMS)
+      debug_printf("%s start %d count %d indexed %d hw_prim %d\n",
+                   __FUNCTION__, start, count, indexed, hw_prim); 
+
+   prim_packet.header.opcode = CMD_3D_PRIM;
+   prim_packet.header.length = sizeof(prim_packet)/4 - 2;
+   prim_packet.header.pad = 0;
+   prim_packet.header.topology = hw_prim;
+   prim_packet.header.indexed = indexed;
+
+   prim_packet.verts_per_instance = count;
+   prim_packet.start_vert_location = start;
+   if (indexed)
+      prim_packet.start_vert_location += brw->ib.start_vertex_offset;
+   prim_packet.instance_count = 1;
+   prim_packet.start_instance_location = 0;
+   prim_packet.base_vert_location = 0; /* prim->basevertex; XXX: add this to gallium */
+
+
+   /* If we're set to always flush, do it before and after the primitive emit.
+    * We want to catch both missed flushes that hurt instruction/state cache
+    * and missed flushes of the render cache as it heads to other parts of
+    * the besides the draw code.
+    */
+   if (0) {
+      BEGIN_BATCH(1, IGNORE_CLIPRECTS);
+      OUT_BATCH((CMD_MI_FLUSH << 16) | BRW_FLUSH_STATE_CACHE);
+      ADVANCE_BATCH();
+   }
+   if (prim_packet.verts_per_instance) {
+      ret = brw_batchbuffer_data( brw->batch, &prim_packet,
+                                 sizeof(prim_packet), LOOP_CLIPRECTS);
+      if (ret)
+        return ret;
+   }
+   if (0) {
+      BEGIN_BATCH(1, IGNORE_CLIPRECTS);
+      OUT_BATCH((CMD_MI_FLUSH << 16) | BRW_FLUSH_STATE_CACHE);
+      ADVANCE_BATCH();
+   }
+
+   return 0;
+}
+
+
+/* May fail if out of video memory for texture or vbo upload, or on
+ * fallback conditions.
+ */
+static int
+try_draw_range_elements(struct brw_context *brw,
+                       struct pipe_buffer *index_buffer,
+                       unsigned hw_prim, 
+                       unsigned start, unsigned count)
+{
+   int ret;
+
+   ret = brw_validate_state(brw);
+   if (ret)
+      return ret;
+
+   /* Check that we can fit our state in with our existing batchbuffer, or
+    * flush otherwise.
+    */
+   ret = brw->sws->check_aperture_space(brw->sws,
+                                       brw->state.validated_bos,
+                                       brw->state.validated_bo_count);
+   if (ret)
+      return ret;
+
+   ret = brw_upload_state(brw);
+   if (ret)
+      return ret;
+   
+   ret = brw_emit_prim(brw, start, count, index_buffer != NULL, hw_prim);
+   if (ret)
+      return ret;
+
+   if (brw->flags.always_flush_batch)
+      brw_context_flush( brw );
+
+   return 0;
+}
+
+
+static void
+brw_draw_range_elements(struct pipe_context *pipe,
+                       struct pipe_buffer *index_buffer,
+                       unsigned index_size,
+                       unsigned min_index,
+                       unsigned max_index,
+                       unsigned mode, unsigned start, unsigned count)
+{
+   struct brw_context *brw = brw_context(pipe);
+   int ret;
+   uint32_t hw_prim;
+
+   hw_prim = brw_set_prim(brw, mode);
+
+   if (BRW_DEBUG & DEBUG_PRIMS)
+      debug_printf("PRIM: %s start %d count %d index_buffer %p\n",
+                   u_prim_name(mode), start, count, (void *)index_buffer);
+
+   /* Potentially trigger upload of new index buffer.
+    *
+    * XXX: do we need to go through state validation to achieve this?
+    * Could just call upload code directly.
+    */
+   if (brw->curr.index_buffer != index_buffer ||
+       brw->curr.index_size != index_size) {
+      pipe_buffer_reference( &brw->curr.index_buffer, index_buffer );
+      brw->curr.index_size = index_size;
+      brw->state.dirty.mesa |= PIPE_NEW_INDEX_BUFFER;
+   }
+
+   /* XXX: do we really care?
+    */
+   if (brw->curr.min_index != min_index ||
+       brw->curr.max_index != max_index) 
+   { 
+      brw->curr.min_index = min_index;
+      brw->curr.max_index = max_index;
+      brw->state.dirty.mesa |= PIPE_NEW_INDEX_RANGE;
+   }
+
+
+   /* Make a first attempt at drawing:
+    */
+   ret = try_draw_range_elements(brw, index_buffer, hw_prim, start, count );
+
+   /* Otherwise, flush and retry:
+    */
+   if (ret != 0) {
+      brw_context_flush( brw );
+      ret = try_draw_range_elements(brw, index_buffer, hw_prim, start, count );
+      assert(ret == 0);
+   }
+}
+
+static void
+brw_draw_elements(struct pipe_context *pipe,
+                 struct pipe_buffer *index_buffer,
+                 unsigned index_size,
+                 unsigned mode, 
+                 unsigned start, unsigned count)
+{
+   brw_draw_range_elements( pipe, index_buffer,
+                            index_size,
+                            0, 0xffffffff,
+                            mode, 
+                            start, count );
+}
+
+static void
+brw_draw_arrays(struct pipe_context *pipe, unsigned mode,
+                     unsigned start, unsigned count)
+{
+   brw_draw_elements(pipe, NULL, 0, mode, start, count);
+}
+
+
+
+boolean brw_draw_init( struct brw_context *brw )
+{
+   /* Register our drawing function: 
+    */
+   brw->base.draw_arrays = brw_draw_arrays;
+   brw->base.draw_elements = brw_draw_elements;
+   brw->base.draw_range_elements = brw_draw_range_elements;
+
+   /* Create helpers for uploading data in user buffers:
+    */
+   brw->vb.upload_vertex = u_upload_create( brw->base.screen,
+                                           128 * 1024,
+                                           64,
+                                           PIPE_BUFFER_USAGE_VERTEX );
+   if (brw->vb.upload_vertex == NULL)
+      return FALSE;
+
+   brw->vb.upload_index = u_upload_create( brw->base.screen,
+                                          32 * 1024,
+                                          64,
+                                          PIPE_BUFFER_USAGE_INDEX );
+   if (brw->vb.upload_index == NULL)
+      return FALSE;
+
+   return TRUE;
+}
+
+void brw_draw_cleanup( struct brw_context *brw )
+{
+   u_upload_destroy( brw->vb.upload_vertex );
+   u_upload_destroy( brw->vb.upload_index );
+
+   bo_reference(&brw->ib.bo, NULL);
+}
diff --git a/src/gallium/drivers/i965/brw_draw.h b/src/gallium/drivers/i965/brw_draw.h
new file mode 100644 (file)
index 0000000..8dc5dbc
--- /dev/null
@@ -0,0 +1,39 @@
+ /**************************************************************************
+ * 
+ * Copyright 2005 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 
+ **************************************************************************/
+
+#ifndef BRW_DRAW_H
+#define BRW_DRAW_H
+
+#include "brw_types.h"
+
+struct brw_context;
+
+boolean brw_draw_init( struct brw_context *brw );
+void brw_draw_cleanup( struct brw_context *brw );
+
+
+#endif
diff --git a/src/gallium/drivers/i965/brw_draw_upload.c b/src/gallium/drivers/i965/brw_draw_upload.c
new file mode 100644 (file)
index 0000000..a27da5f
--- /dev/null
@@ -0,0 +1,542 @@
+/**************************************************************************
+ * 
+ * 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_context.h"
+
+#include "util/u_upload_mgr.h"
+#include "util/u_math.h"
+
+#include "brw_draw.h"
+#include "brw_defines.h"
+#include "brw_context.h"
+#include "brw_state.h"
+#include "brw_screen.h"
+#include "brw_batchbuffer.h"
+#include "brw_debug.h"
+
+
+
+
+static unsigned brw_translate_surface_format( unsigned id )
+{
+   switch (id) {
+   case PIPE_FORMAT_R64_FLOAT:
+      return BRW_SURFACEFORMAT_R64_FLOAT;
+   case PIPE_FORMAT_R64G64_FLOAT:
+      return BRW_SURFACEFORMAT_R64G64_FLOAT;
+   case PIPE_FORMAT_R64G64B64_FLOAT:
+      return BRW_SURFACEFORMAT_R64G64B64_FLOAT;
+   case PIPE_FORMAT_R64G64B64A64_FLOAT:
+      return BRW_SURFACEFORMAT_R64G64B64A64_FLOAT;
+
+   case PIPE_FORMAT_R32_FLOAT:
+      return BRW_SURFACEFORMAT_R32_FLOAT;
+   case PIPE_FORMAT_R32G32_FLOAT:
+      return BRW_SURFACEFORMAT_R32G32_FLOAT;
+   case PIPE_FORMAT_R32G32B32_FLOAT:
+      return BRW_SURFACEFORMAT_R32G32B32_FLOAT;
+   case PIPE_FORMAT_R32G32B32A32_FLOAT:
+      return BRW_SURFACEFORMAT_R32G32B32A32_FLOAT;
+
+   case PIPE_FORMAT_R32_UNORM:
+      return BRW_SURFACEFORMAT_R32_UNORM;
+   case PIPE_FORMAT_R32G32_UNORM:
+      return BRW_SURFACEFORMAT_R32G32_UNORM;
+   case PIPE_FORMAT_R32G32B32_UNORM:
+      return BRW_SURFACEFORMAT_R32G32B32_UNORM;
+   case PIPE_FORMAT_R32G32B32A32_UNORM:
+      return BRW_SURFACEFORMAT_R32G32B32A32_UNORM;
+
+   case PIPE_FORMAT_R32_USCALED:
+      return BRW_SURFACEFORMAT_R32_USCALED;
+   case PIPE_FORMAT_R32G32_USCALED:
+      return BRW_SURFACEFORMAT_R32G32_USCALED;
+   case PIPE_FORMAT_R32G32B32_USCALED:
+      return BRW_SURFACEFORMAT_R32G32B32_USCALED;
+   case PIPE_FORMAT_R32G32B32A32_USCALED:
+      return BRW_SURFACEFORMAT_R32G32B32A32_USCALED;
+
+   case PIPE_FORMAT_R32_SNORM:
+      return BRW_SURFACEFORMAT_R32_SNORM;
+   case PIPE_FORMAT_R32G32_SNORM:
+      return BRW_SURFACEFORMAT_R32G32_SNORM;
+   case PIPE_FORMAT_R32G32B32_SNORM:
+      return BRW_SURFACEFORMAT_R32G32B32_SNORM;
+   case PIPE_FORMAT_R32G32B32A32_SNORM:
+      return BRW_SURFACEFORMAT_R32G32B32A32_SNORM;
+
+   case PIPE_FORMAT_R32_SSCALED:
+      return BRW_SURFACEFORMAT_R32_SSCALED;
+   case PIPE_FORMAT_R32G32_SSCALED:
+      return BRW_SURFACEFORMAT_R32G32_SSCALED;
+   case PIPE_FORMAT_R32G32B32_SSCALED:
+      return BRW_SURFACEFORMAT_R32G32B32_SSCALED;
+   case PIPE_FORMAT_R32G32B32A32_SSCALED:
+      return BRW_SURFACEFORMAT_R32G32B32A32_SSCALED;
+
+   case PIPE_FORMAT_R16_UNORM:
+      return BRW_SURFACEFORMAT_R16_UNORM;
+   case PIPE_FORMAT_R16G16_UNORM:
+      return BRW_SURFACEFORMAT_R16G16_UNORM;
+   case PIPE_FORMAT_R16G16B16_UNORM:
+      return BRW_SURFACEFORMAT_R16G16B16_UNORM;
+   case PIPE_FORMAT_R16G16B16A16_UNORM:
+      return BRW_SURFACEFORMAT_R16G16B16A16_UNORM;
+
+   case PIPE_FORMAT_R16_USCALED:
+      return BRW_SURFACEFORMAT_R16_USCALED;
+   case PIPE_FORMAT_R16G16_USCALED:
+      return BRW_SURFACEFORMAT_R16G16_USCALED;
+   case PIPE_FORMAT_R16G16B16_USCALED:
+      return BRW_SURFACEFORMAT_R16G16B16_USCALED;
+   case PIPE_FORMAT_R16G16B16A16_USCALED:
+      return BRW_SURFACEFORMAT_R16G16B16A16_USCALED;
+
+   case PIPE_FORMAT_R16_SNORM:
+      return BRW_SURFACEFORMAT_R16_SNORM;
+   case PIPE_FORMAT_R16G16_SNORM:
+      return BRW_SURFACEFORMAT_R16G16_SNORM;
+   case PIPE_FORMAT_R16G16B16_SNORM:
+      return BRW_SURFACEFORMAT_R16G16B16_SNORM;
+   case PIPE_FORMAT_R16G16B16A16_SNORM:
+      return BRW_SURFACEFORMAT_R16G16B16A16_SNORM;
+
+   case PIPE_FORMAT_R16_SSCALED:
+      return BRW_SURFACEFORMAT_R16_SSCALED;
+   case PIPE_FORMAT_R16G16_SSCALED:
+      return BRW_SURFACEFORMAT_R16G16_SSCALED;
+   case PIPE_FORMAT_R16G16B16_SSCALED:
+      return BRW_SURFACEFORMAT_R16G16B16_SSCALED;
+   case PIPE_FORMAT_R16G16B16A16_SSCALED:
+      return BRW_SURFACEFORMAT_R16G16B16A16_SSCALED;
+
+   case PIPE_FORMAT_R8_UNORM:
+      return BRW_SURFACEFORMAT_R8_UNORM;
+   case PIPE_FORMAT_R8G8_UNORM:
+      return BRW_SURFACEFORMAT_R8G8_UNORM;
+   case PIPE_FORMAT_R8G8B8_UNORM:
+      return BRW_SURFACEFORMAT_R8G8B8_UNORM;
+   case PIPE_FORMAT_R8G8B8A8_UNORM:
+      return BRW_SURFACEFORMAT_R8G8B8A8_UNORM;
+
+   case PIPE_FORMAT_R8_USCALED:
+      return BRW_SURFACEFORMAT_R8_USCALED;
+   case PIPE_FORMAT_R8G8_USCALED:
+      return BRW_SURFACEFORMAT_R8G8_USCALED;
+   case PIPE_FORMAT_R8G8B8_USCALED:
+      return BRW_SURFACEFORMAT_R8G8B8_USCALED;
+   case PIPE_FORMAT_R8G8B8A8_USCALED:
+      return BRW_SURFACEFORMAT_R8G8B8A8_USCALED;
+
+   case PIPE_FORMAT_R8_SNORM:
+      return BRW_SURFACEFORMAT_R8_SNORM;
+   case PIPE_FORMAT_R8G8_SNORM:
+      return BRW_SURFACEFORMAT_R8G8_SNORM;
+   case PIPE_FORMAT_R8G8B8_SNORM:
+      return BRW_SURFACEFORMAT_R8G8B8_SNORM;
+   case PIPE_FORMAT_R8G8B8A8_SNORM:
+      return BRW_SURFACEFORMAT_R8G8B8A8_SNORM;
+
+   case PIPE_FORMAT_R8_SSCALED:
+      return BRW_SURFACEFORMAT_R8_SSCALED;
+   case PIPE_FORMAT_R8G8_SSCALED:
+      return BRW_SURFACEFORMAT_R8G8_SSCALED;
+   case PIPE_FORMAT_R8G8B8_SSCALED:
+      return BRW_SURFACEFORMAT_R8G8B8_SSCALED;
+   case PIPE_FORMAT_R8G8B8A8_SSCALED:
+      return BRW_SURFACEFORMAT_R8G8B8A8_SSCALED;
+
+   default:
+      assert(0);
+      return 0;
+   }
+}
+
+static unsigned get_index_type(int type)
+{
+   switch (type) {
+   case 1: return BRW_INDEX_BYTE;
+   case 2: return BRW_INDEX_WORD;
+   case 4: return BRW_INDEX_DWORD;
+   default: assert(0); return 0;
+   }
+}
+
+
+static int brw_prepare_vertices(struct brw_context *brw)
+{
+   unsigned int min_index = brw->curr.min_index;
+   unsigned int max_index = brw->curr.max_index;
+   GLuint i;
+   int ret;
+
+   if (BRW_DEBUG & DEBUG_VERTS)
+      debug_printf("%s %d..%d\n", __FUNCTION__, min_index, max_index);
+
+
+   for (i = 0; i < brw->curr.num_vertex_buffers; i++) {
+      struct pipe_vertex_buffer *vb = &brw->curr.vertex_buffer[i];
+      struct brw_winsys_buffer *bo;
+      struct pipe_buffer *upload_buf = NULL;
+      unsigned offset;
+      
+      if (BRW_DEBUG & DEBUG_VERTS)
+        debug_printf("%s vb[%d] user:%d offset:0x%x sz:0x%x stride:0x%x\n",
+                     __FUNCTION__, i,
+                     brw_buffer_is_user_buffer(vb->buffer),
+                     vb->buffer_offset,
+                     vb->buffer->size,
+                     vb->stride);
+
+      if (brw_buffer_is_user_buffer(vb->buffer)) {
+
+        /* XXX: simplify this.  Stop the state trackers from generating
+         * zero-stride buffers & have them use additional constants (or
+         * add support for >1 constant buffer) instead.
+         */
+        unsigned size = (vb->stride == 0 ? 
+                         vb->buffer->size - vb->buffer_offset :
+                         MAX2(vb->buffer->size - vb->buffer_offset,
+                              vb->stride * (max_index + 1 - min_index)));
+
+        ret = u_upload_buffer( brw->vb.upload_vertex, 
+                               vb->buffer_offset + min_index * vb->stride,
+                               size,
+                               vb->buffer,
+                               &offset,
+                               &upload_buf );
+        if (ret)
+           return ret;
+
+        bo = brw_buffer(upload_buf)->bo;
+        
+        assert(offset + size <= bo->size);
+      }
+      else
+      {
+        offset = vb->buffer_offset;
+        bo = brw_buffer(vb->buffer)->bo;
+      }
+
+      assert(offset < bo->size);
+      
+      /* Set up post-upload info about this vertex buffer:
+       */
+      brw->vb.vb[i].offset = offset;
+      brw->vb.vb[i].stride = vb->stride;
+      brw->vb.vb[i].vertex_count = (vb->stride == 0 ?
+                                   1 :
+                                   (bo->size - offset) / vb->stride);
+
+      bo_reference( &brw->vb.vb[i].bo,  bo );
+
+      /* Don't need to retain this reference.  We have a reference on
+       * the underlying winsys buffer:
+       */
+      pipe_buffer_reference( &upload_buf, NULL );
+   }
+
+   brw->vb.nr_vb = i;
+   brw_prepare_query_begin(brw);
+
+   for (i = 0; i < brw->vb.nr_vb; i++) {
+      brw_add_validated_bo(brw, brw->vb.vb[i].bo);
+   }
+
+   return 0;
+}
+
+static int brw_emit_vertex_buffers( struct brw_context *brw )
+{
+   int i;
+
+   /* If the VS doesn't read any inputs (calculating vertex position from
+    * a state variable for some reason, for example), just bail.
+    *
+    * The stale VB state stays in place, but they don't do anything unless
+    * a VE loads from them.
+    */
+   if (brw->vb.nr_vb == 0) {
+      if (BRW_DEBUG & DEBUG_VERTS)
+        debug_printf("%s: no active vertex buffers\n", __FUNCTION__);
+
+      return 0;
+   }
+
+   /* Emit VB state packets.
+    */
+   BEGIN_BATCH(1 + brw->vb.nr_vb * 4, IGNORE_CLIPRECTS);
+   OUT_BATCH((CMD_VERTEX_BUFFER << 16) |
+            ((1 + brw->vb.nr_vb * 4) - 2));
+
+   for (i = 0; i < brw->vb.nr_vb; i++) {
+      OUT_BATCH((i << BRW_VB0_INDEX_SHIFT) |
+               BRW_VB0_ACCESS_VERTEXDATA |
+               (brw->vb.vb[i].stride << BRW_VB0_PITCH_SHIFT));
+      OUT_RELOC(brw->vb.vb[i].bo,
+               BRW_USAGE_VERTEX,
+               brw->vb.vb[i].offset);
+      if (BRW_IS_IGDNG(brw)) {
+        OUT_RELOC(brw->vb.vb[i].bo,
+                  BRW_USAGE_VERTEX,
+                  brw->vb.vb[i].bo->size - 1);
+      } else
+        OUT_BATCH(brw->vb.vb[i].stride ? brw->vb.vb[i].vertex_count : 0);
+      OUT_BATCH(0); /* Instance data step rate */
+   }
+   ADVANCE_BATCH();
+   return 0;
+}
+
+
+
+
+static int brw_emit_vertex_elements(struct brw_context *brw)
+{
+   GLuint nr = brw->curr.num_vertex_elements;
+   GLuint i;
+
+   brw_emit_query_begin(brw);
+
+   /* If the VS doesn't read any inputs (calculating vertex position from
+    * a state variable for some reason, for example), emit a single pad
+    * VERTEX_ELEMENT struct and bail.
+    *
+    * The stale VB state stays in place, but they don't do anything unless
+    * a VE loads from them.
+    */
+   if (nr == 0) {
+      BEGIN_BATCH(3, IGNORE_CLIPRECTS);
+      OUT_BATCH((CMD_VERTEX_ELEMENT << 16) | 1);
+      OUT_BATCH((0 << BRW_VE0_INDEX_SHIFT) |
+               BRW_VE0_VALID |
+               (BRW_SURFACEFORMAT_R32G32B32A32_FLOAT << BRW_VE0_FORMAT_SHIFT) |
+               (0 << BRW_VE0_SRC_OFFSET_SHIFT));
+      OUT_BATCH((BRW_VE1_COMPONENT_STORE_0 << BRW_VE1_COMPONENT_0_SHIFT) |
+               (BRW_VE1_COMPONENT_STORE_0 << BRW_VE1_COMPONENT_1_SHIFT) |
+               (BRW_VE1_COMPONENT_STORE_0 << BRW_VE1_COMPONENT_2_SHIFT) |
+               (BRW_VE1_COMPONENT_STORE_1_FLT << BRW_VE1_COMPONENT_3_SHIFT));
+      ADVANCE_BATCH();
+      return 0;
+   }
+
+   /* Now emit vertex element (VEP) state packets.
+    *
+    */
+   BEGIN_BATCH(1 + nr * 2, IGNORE_CLIPRECTS);
+   OUT_BATCH((CMD_VERTEX_ELEMENT << 16) | ((1 + nr * 2) - 2));
+   for (i = 0; i < nr; i++) {
+      const struct pipe_vertex_element *input = &brw->curr.vertex_element[i];
+      uint32_t format = brw_translate_surface_format( input->src_format );
+      uint32_t comp0 = BRW_VE1_COMPONENT_STORE_SRC;
+      uint32_t comp1 = BRW_VE1_COMPONENT_STORE_SRC;
+      uint32_t comp2 = BRW_VE1_COMPONENT_STORE_SRC;
+      uint32_t comp3 = BRW_VE1_COMPONENT_STORE_SRC;
+
+      switch (input->nr_components) {
+      case 0: comp0 = BRW_VE1_COMPONENT_STORE_0;
+      case 1: comp1 = BRW_VE1_COMPONENT_STORE_0;
+      case 2: comp2 = BRW_VE1_COMPONENT_STORE_0;
+      case 3: comp3 = BRW_VE1_COMPONENT_STORE_1_FLT;
+        break;
+      }
+
+      OUT_BATCH((input->vertex_buffer_index << BRW_VE0_INDEX_SHIFT) |
+               BRW_VE0_VALID |
+               (format << BRW_VE0_FORMAT_SHIFT) |
+               (input->src_offset << BRW_VE0_SRC_OFFSET_SHIFT));
+
+      if (BRW_IS_IGDNG(brw))
+          OUT_BATCH((comp0 << BRW_VE1_COMPONENT_0_SHIFT) |
+                    (comp1 << BRW_VE1_COMPONENT_1_SHIFT) |
+                    (comp2 << BRW_VE1_COMPONENT_2_SHIFT) |
+                    (comp3 << BRW_VE1_COMPONENT_3_SHIFT));
+      else
+          OUT_BATCH((comp0 << BRW_VE1_COMPONENT_0_SHIFT) |
+                    (comp1 << BRW_VE1_COMPONENT_1_SHIFT) |
+                    (comp2 << BRW_VE1_COMPONENT_2_SHIFT) |
+                    (comp3 << BRW_VE1_COMPONENT_3_SHIFT) |
+                    ((i * 4) << BRW_VE1_DST_OFFSET_SHIFT));
+   }
+   ADVANCE_BATCH();
+   return 0;
+}
+
+
+static int brw_emit_vertices( struct brw_context *brw )
+{
+   int ret;
+
+   ret = brw_emit_vertex_buffers( brw );
+   if (ret)
+      return ret;
+
+   ret = brw_emit_vertex_elements( brw );
+   if (ret)
+      return ret;
+   
+   return 0;
+}
+
+
+const struct brw_tracked_state brw_vertices = {
+   .dirty = {
+      .mesa = (PIPE_NEW_INDEX_RANGE |
+               PIPE_NEW_VERTEX_BUFFER),
+      .brw = BRW_NEW_BATCH,
+      .cache = 0,
+   },
+   .prepare = brw_prepare_vertices,
+   .emit = brw_emit_vertices,
+};
+
+
+static int brw_prepare_indices(struct brw_context *brw)
+{
+   struct pipe_buffer *index_buffer = brw->curr.index_buffer;
+   struct pipe_buffer *upload_buf = NULL;
+   struct brw_winsys_buffer *bo = NULL;
+   GLuint offset;
+   GLuint index_size;
+   GLuint ib_size;
+   int ret;
+
+   if (index_buffer == NULL)
+      return 0;
+
+   if (BRW_DEBUG & DEBUG_VERTS)
+      debug_printf("%s: index_size:%d index_buffer->size:%d\n",
+                  __FUNCTION__,
+                  brw->curr.index_size,
+                  brw->curr.index_buffer->size);
+
+   ib_size = index_buffer->size;
+   index_size = brw->curr.index_size;
+
+   /* Turn userbuffer into a proper hardware buffer?
+    */
+   if (brw_buffer_is_user_buffer(index_buffer)) {
+
+      ret = u_upload_buffer( brw->vb.upload_index,
+                            0,
+                            ib_size,
+                            index_buffer,
+                            &offset,
+                            &upload_buf );
+      if (ret)
+        return ret;
+
+      bo = brw_buffer(upload_buf)->bo;
+
+      /* XXX: annotate the userbuffer with the upload information so
+       * that successive calls don't get re-uploaded.
+       */
+   }
+   else {
+      bo = brw_buffer(index_buffer)->bo;
+      ib_size = bo->size;
+      offset = 0;
+   }
+
+   /* Use CMD_3D_PRIM's start_vertex_offset to avoid re-uploading the
+    * index buffer state when we're just moving the start index of our
+    * drawing.
+    *
+    * In gallium this will happen in the case where successive draw
+    * calls are made with (distinct?) userbuffers, but the upload_mgr
+    * places the data into a single winsys buffer.
+    * 
+    * This statechange doesn't raise any state flags and is always
+    * just merged into the final draw packet:
+    */
+   if (1) {
+      assert((offset & (index_size - 1)) == 0);
+      brw->ib.start_vertex_offset = offset / index_size;
+   }
+
+   /* These statechanges trigger a new CMD_INDEX_BUFFER packet:
+    */
+   if (brw->ib.bo != bo ||
+       brw->ib.size != ib_size)
+   {
+      bo_reference(&brw->ib.bo, bo);
+      brw->ib.size = ib_size;
+      brw->state.dirty.brw |= BRW_NEW_INDEX_BUFFER;
+   }
+
+   pipe_buffer_reference( &upload_buf, NULL );
+   brw_add_validated_bo(brw, brw->ib.bo);
+   return 0;
+}
+
+const struct brw_tracked_state brw_indices = {
+   .dirty = {
+      .mesa = PIPE_NEW_INDEX_BUFFER,
+      .brw = 0,
+      .cache = 0,
+   },
+   .prepare = brw_prepare_indices,
+};
+
+static int brw_emit_index_buffer(struct brw_context *brw)
+{
+   /* Emit the indexbuffer packet:
+    */
+   if (brw->ib.bo)
+   {
+      struct brw_indexbuffer ib;
+
+      memset(&ib, 0, sizeof(ib));
+
+      ib.header.bits.opcode = CMD_INDEX_BUFFER;
+      ib.header.bits.length = sizeof(ib)/4 - 2;
+      ib.header.bits.index_format = get_index_type(brw->ib.size);
+      ib.header.bits.cut_index_enable = 0;
+
+      BEGIN_BATCH(4, IGNORE_CLIPRECTS);
+      OUT_BATCH( ib.header.dword );
+      OUT_RELOC(brw->ib.bo,
+               BRW_USAGE_VERTEX,
+               brw->ib.offset);
+      OUT_RELOC(brw->ib.bo,
+               BRW_USAGE_VERTEX,
+               brw->ib.offset + brw->ib.size - 1);
+      OUT_BATCH( 0 );
+      ADVANCE_BATCH();
+   }
+
+   return 0;
+}
+
+const struct brw_tracked_state brw_index_buffer = {
+   .dirty = {
+      .mesa = 0,
+      .brw = BRW_NEW_BATCH | BRW_NEW_INDEX_BUFFER,
+      .cache = 0,
+   },
+   .emit = brw_emit_index_buffer,
+};
diff --git a/src/gallium/drivers/i965/brw_eu.c b/src/gallium/drivers/i965/brw_eu.c
new file mode 100644 (file)
index 0000000..a8fcb5f
--- /dev/null
@@ -0,0 +1,262 @@
+/*
+ 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 "util/u_memory.h"
+
+#include "brw_context.h"
+#include "brw_defines.h"
+#include "brw_eu.h"
+
+
+
+/* How does predicate control work when execution_size != 8?  Do I
+ * need to test/set for 0xffff when execution_size is 16?
+ */
+void brw_set_predicate_control_flag_value( struct brw_compile *p, GLuint value )
+{
+   p->current->header.predicate_control = BRW_PREDICATE_NONE;
+
+   if (value != 0xff) {
+      if (value != p->flag_value) {
+        brw_push_insn_state(p);
+        brw_MOV(p, brw_flag_reg(), brw_imm_uw(value));
+        p->flag_value = value;
+        brw_pop_insn_state(p);
+      }
+
+      p->current->header.predicate_control = BRW_PREDICATE_NORMAL;
+   }   
+}
+
+void brw_set_predicate_control( struct brw_compile *p, GLuint pc )
+{
+   p->current->header.predicate_control = pc;
+}
+
+void brw_set_conditionalmod( struct brw_compile *p, GLuint conditional )
+{
+   p->current->header.destreg__conditionalmod = conditional;
+}
+
+void brw_set_access_mode( struct brw_compile *p, GLuint access_mode )
+{
+   p->current->header.access_mode = access_mode;
+}
+
+void brw_set_compression_control( struct brw_compile *p, GLboolean compression_control )
+{
+   p->current->header.compression_control = compression_control;
+}
+
+void brw_set_mask_control( struct brw_compile *p, GLuint value )
+{
+   p->current->header.mask_control = value;
+}
+
+void brw_set_saturate( struct brw_compile *p, GLuint value )
+{
+   p->current->header.saturate = value;
+}
+
+void brw_push_insn_state( struct brw_compile *p )
+{
+   assert(p->current != &p->stack[BRW_EU_MAX_INSN_STACK-1]);
+   memcpy(p->current+1, p->current, sizeof(struct brw_instruction));
+   p->current++;   
+}
+
+void brw_pop_insn_state( struct brw_compile *p )
+{
+   assert(p->current != p->stack);
+   p->current--;
+}
+
+
+/***********************************************************************
+ */
+void brw_init_compile( struct brw_context *brw, struct brw_compile *p )
+{
+   p->brw = brw;
+   p->nr_insn = 0;
+   p->current = p->stack;
+   memset(p->current, 0, sizeof(p->current[0]));
+
+   /* Some defaults?
+    */
+   brw_set_mask_control(p, BRW_MASK_ENABLE); /* what does this do? */
+   brw_set_saturate(p, 0);
+   brw_set_compression_control(p, BRW_COMPRESSION_NONE);
+   brw_set_predicate_control_flag_value(p, 0xff); 
+}
+
+
+enum pipe_error brw_get_program( struct brw_compile *p,
+                                 const GLuint **data,
+                                 GLuint *sz )
+{
+   GLuint i;
+
+   for (i = 0; i < 8; i++)
+      brw_NOP(p);
+
+   /* Is the generated program malformed for some reason?
+    */
+   if (p->error)
+      return PIPE_ERROR_BAD_INPUT;
+
+   *sz = p->nr_insn * sizeof(struct brw_instruction);
+   *data = (const GLuint *)p->store;
+   return PIPE_OK;
+}
+
+
+
+/**
+ * Subroutine calls require special attention.
+ * Mesa instructions may be expanded into multiple hardware instructions
+ * so the prog_instruction::BranchTarget field can't be used as an index
+ * into the hardware instructions.
+ *
+ * The BranchTarget field isn't needed, however.  Mesa's GLSL compiler
+ * emits CAL and BGNSUB instructions with labels that can be used to map
+ * subroutine calls to actual subroutine code blocks.
+ *
+ * The structures and function here implement patching of CAL instructions
+ * so they jump to the right subroutine code...
+ */
+
+
+/**
+ * For each OPCODE_BGNSUB we create one of these.
+ */
+struct brw_eu_label
+{
+   GLuint label;     /**< the label number */
+   GLuint position;  /**< the position of the brw instruction for this label */
+   struct brw_eu_label *next;  /**< next in linked list */
+};
+
+
+/**
+ * For each OPCODE_CAL we create one of these.
+ */
+struct brw_eu_call
+{
+   GLuint call_inst_pos;  /**< location of the CAL instruction */
+   GLuint label;
+   struct brw_eu_call *next;  /**< next in linked list */
+};
+
+
+/**
+ * Called for each OPCODE_BGNSUB.
+ */
+void
+brw_save_label(struct brw_compile *c, unsigned l, GLuint position)
+{
+   struct brw_eu_label *label = CALLOC_STRUCT(brw_eu_label);
+   label->label = l;
+   label->position = position;
+   label->next = c->first_label;
+   c->first_label = label;
+}
+
+
+/**
+ * Called for each OPCODE_CAL.
+ */
+void
+brw_save_call(struct brw_compile *c, GLuint label, GLuint call_pos)
+{
+   struct brw_eu_call *call = CALLOC_STRUCT(brw_eu_call);
+   call->call_inst_pos = call_pos;
+   call->label = label;
+   call->next = c->first_call;
+   c->first_call = call;
+}
+
+
+/**
+ * Lookup a label, return label's position/offset.
+ */
+static GLuint
+brw_lookup_label(struct brw_compile *c, unsigned l)
+{
+   const struct brw_eu_label *label;
+   for (label = c->first_label; label; label = label->next) {
+      if (l == label->label) {
+         return label->position;
+      }
+   }
+   abort();  /* should never happen */
+   return ~0;
+}
+
+
+/**
+ * When we're done generating code, this function is called to resolve
+ * subroutine calls.
+ */
+void
+brw_resolve_cals(struct brw_compile *c)
+{
+    const struct brw_eu_call *call;
+
+    for (call = c->first_call; call; call = call->next) {
+        const GLuint sub_loc = brw_lookup_label(c, call->label);
+       struct brw_instruction *brw_call_inst = &c->store[call->call_inst_pos];
+       struct brw_instruction *brw_sub_inst = &c->store[sub_loc];
+       GLint offset = brw_sub_inst - brw_call_inst;
+
+       /* patch brw_inst1 to point to brw_inst2 */
+       brw_set_src1(brw_call_inst, brw_imm_d(offset * 16));
+    }
+
+    /* free linked list of calls */
+    {
+        struct brw_eu_call *call, *next;
+        for (call = c->first_call; call; call = next) {
+           next = call->next;
+           FREE(call);
+       }
+       c->first_call = NULL;
+    }
+
+    /* free linked list of labels */
+    {
+        struct brw_eu_label *label, *next;
+       for (label = c->first_label; label; label = next) {
+           next = label->next;
+           FREE(label);
+       }
+       c->first_label = NULL;
+    }
+}
diff --git a/src/gallium/drivers/i965/brw_eu.h b/src/gallium/drivers/i965/brw_eu.h
new file mode 100644 (file)
index 0000000..af509b2
--- /dev/null
@@ -0,0 +1,992 @@
+/*
+ Copyright (C) Intel Corp.  2006.  All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ **********************************************************************/
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  */
+   
+
+#ifndef BRW_EU_H
+#define BRW_EU_H
+
+#include "util/u_debug.h"
+#include "pipe/p_defines.h"
+
+#include "brw_structs.h"
+#include "brw_defines.h"
+
+#define BRW_SWIZZLE4(a,b,c,d) (((a)<<0) | ((b)<<2) | ((c)<<4) | ((d)<<6))
+#define BRW_GET_SWZ(swz, idx) (((swz) >> ((idx)*2)) & 0x3)
+
+#define BRW_SWIZZLE_NOOP      BRW_SWIZZLE4(0,1,2,3)
+#define BRW_SWIZZLE_XYZW      BRW_SWIZZLE4(0,1,2,3)
+#define BRW_SWIZZLE_XXXX      BRW_SWIZZLE4(0,0,0,0)
+#define BRW_SWIZZLE_XYXY      BRW_SWIZZLE4(0,1,0,1)
+
+#define BRW_WRITEMASK_NONE     0x00
+#define BRW_WRITEMASK_X        0x01
+#define BRW_WRITEMASK_Y        0x02
+#define BRW_WRITEMASK_XY       0x03
+#define BRW_WRITEMASK_Z        0x04
+#define BRW_WRITEMASK_XZ       0x05
+#define BRW_WRITEMASK_YZ       0x06
+#define BRW_WRITEMASK_XYZ      0x07
+#define BRW_WRITEMASK_W        0x08
+#define BRW_WRITEMASK_XW       0x09
+#define BRW_WRITEMASK_YW       0x0A
+#define BRW_WRITEMASK_XYW      0x0B
+#define BRW_WRITEMASK_ZW       0x0C
+#define BRW_WRITEMASK_XZW      0x0D
+#define BRW_WRITEMASK_YZW      0x0E
+#define BRW_WRITEMASK_XYZW     0x0F
+
+
+#define REG_SIZE (8*4)
+
+
+/* These aren't hardware structs, just something useful for us to pass around:
+ *
+ * Align1 operation has a lot of control over input ranges.  Used in
+ * WM programs to implement shaders decomposed into "channel serial"
+ * or "structure of array" form:
+ */
+struct brw_reg
+{
+   GLuint type:4;
+   GLuint file:2;
+   GLuint nr:8;
+   GLuint subnr:5;             /* :1 in align16 */
+   GLuint negate:1;            /* source only */
+   GLuint abs:1;               /* source only */
+   GLuint vstride:4;           /* source only */
+   GLuint width:3;             /* src only, align1 only */
+   GLuint hstride:2;                   /* align1 only */
+   GLuint address_mode:1;      /* relative addressing, hopefully! */
+   GLuint pad0:1;
+
+   union {      
+      struct {
+        GLuint swizzle:8;              /* src only, align16 only */
+        GLuint writemask:4;            /* dest only, align16 only */
+        GLint  indirect_offset:10;     /* relative addressing offset */
+        GLuint pad1:10;                /* two dwords total */
+      } bits;
+
+      GLfloat f;
+      GLint   d;
+      GLuint ud;
+   } dw1;      
+};
+
+
+struct brw_indirect {
+   GLuint addr_subnr:4;
+   GLint addr_offset:10;
+   GLuint pad:18;
+};
+
+
+struct brw_eu_label;
+struct brw_eu_call;
+
+
+
+#define BRW_EU_MAX_INSN_STACK 5
+#define BRW_EU_MAX_INSN 10000
+
+struct brw_compile {
+   struct brw_instruction store[BRW_EU_MAX_INSN];
+   GLuint nr_insn;
+
+   /* Allow clients to push/pop instruction state:
+    */
+   struct brw_instruction stack[BRW_EU_MAX_INSN_STACK];
+   struct brw_instruction *current;
+
+   GLuint flag_value;
+   GLboolean single_program_flow;
+   struct brw_context *brw;
+
+   struct brw_eu_label *first_label;  /**< linked list of labels */
+   struct brw_eu_call *first_call;    /**< linked list of CALs */
+
+   boolean error;
+};
+
+
+void
+brw_save_label(struct brw_compile *c, unsigned label, GLuint position);
+
+void
+brw_save_call(struct brw_compile *c, unsigned label, GLuint call_pos);
+
+void
+brw_resolve_cals(struct brw_compile *c);
+
+
+
+static INLINE int type_sz( GLuint type )
+{
+   switch( type ) {
+   case BRW_REGISTER_TYPE_UD:
+   case BRW_REGISTER_TYPE_D:
+   case BRW_REGISTER_TYPE_F:
+      return 4;
+   case BRW_REGISTER_TYPE_HF:
+   case BRW_REGISTER_TYPE_UW:
+   case BRW_REGISTER_TYPE_W:
+      return 2;
+   case BRW_REGISTER_TYPE_UB:
+   case BRW_REGISTER_TYPE_B:
+      return 1;
+   default:
+      return 0;
+   }
+}
+
+/**
+ * Construct a brw_reg.
+ * \param file  one of the BRW_x_REGISTER_FILE values
+ * \param nr  register number/index
+ * \param subnr  register sub number
+ * \param type  one of BRW_REGISTER_TYPE_x
+ * \param vstride  one of BRW_VERTICAL_STRIDE_x
+ * \param width  one of BRW_WIDTH_x
+ * \param hstride  one of BRW_HORIZONTAL_STRIDE_x
+ * \param swizzle  one of BRW_SWIZZLE_x
+ * \param writemask  BRW_WRITEMASK_X/Y/Z/W bitfield
+ */
+static INLINE struct brw_reg brw_reg( GLuint file,
+                                      GLuint nr,
+                                      GLuint subnr,
+                                      GLuint type,
+                                      GLuint vstride,
+                                      GLuint width,
+                                      GLuint hstride,
+                                      GLuint swizzle,
+                                      GLuint writemask )
+{
+   struct brw_reg reg;
+   if (type == BRW_GENERAL_REGISTER_FILE)
+      assert(nr < BRW_MAX_GRF);
+   else if (type == BRW_MESSAGE_REGISTER_FILE)
+      assert(nr < BRW_MAX_MRF);
+   else if (type == BRW_ARCHITECTURE_REGISTER_FILE)
+      assert(nr <= BRW_ARF_IP);
+
+   reg.type = type;
+   reg.file = file;
+   reg.nr = nr;
+   reg.subnr = subnr * type_sz(type);
+   reg.negate = 0;
+   reg.abs = 0;
+   reg.vstride = vstride;
+   reg.width = width;
+   reg.hstride = hstride;
+   reg.address_mode = BRW_ADDRESS_DIRECT;
+   reg.pad0 = 0;
+
+   /* Could do better: If the reg is r5.3<0;1,0>, we probably want to
+    * set swizzle and writemask to W, as the lower bits of subnr will
+    * be lost when converted to align16.  This is probably too much to
+    * keep track of as you'd want it adjusted by suboffset(), etc.
+    * Perhaps fix up when converting to align16?
+    */
+   reg.dw1.bits.swizzle = swizzle;
+   reg.dw1.bits.writemask = writemask;
+   reg.dw1.bits.indirect_offset = 0;
+   reg.dw1.bits.pad1 = 0;
+   return reg;
+}
+
+/** Construct float[16] register */
+static INLINE struct brw_reg brw_vec16_reg( GLuint file,
+                                             GLuint nr,
+                                             GLuint subnr )
+{
+   return brw_reg(file,
+                 nr,
+                 subnr,
+                 BRW_REGISTER_TYPE_F,
+                 BRW_VERTICAL_STRIDE_16,
+                 BRW_WIDTH_16,
+                 BRW_HORIZONTAL_STRIDE_1,
+                 BRW_SWIZZLE_XYZW,
+                 BRW_WRITEMASK_XYZW);
+}
+
+/** Construct float[8] register */
+static INLINE struct brw_reg brw_vec8_reg( GLuint file,
+                                            GLuint nr,
+                                            GLuint subnr )
+{
+   return brw_reg(file,
+                 nr,
+                 subnr,
+                 BRW_REGISTER_TYPE_F,
+                 BRW_VERTICAL_STRIDE_8,
+                 BRW_WIDTH_8,
+                 BRW_HORIZONTAL_STRIDE_1,
+                 BRW_SWIZZLE_XYZW,
+                 BRW_WRITEMASK_XYZW);
+}
+
+/** Construct float[4] register */
+static INLINE struct brw_reg brw_vec4_reg( GLuint file,
+                                             GLuint nr,
+                                             GLuint subnr )
+{
+   return brw_reg(file,
+                 nr,
+                 subnr,
+                 BRW_REGISTER_TYPE_F,
+                 BRW_VERTICAL_STRIDE_4,
+                 BRW_WIDTH_4,
+                 BRW_HORIZONTAL_STRIDE_1,
+                 BRW_SWIZZLE_XYZW,
+                 BRW_WRITEMASK_XYZW);
+}
+
+/** Construct float[2] register */
+static INLINE struct brw_reg brw_vec2_reg( GLuint file,
+                                             GLuint nr,
+                                             GLuint subnr )
+{
+   return brw_reg(file,
+                 nr,
+                 subnr,
+                 BRW_REGISTER_TYPE_F,
+                 BRW_VERTICAL_STRIDE_2,
+                 BRW_WIDTH_2,
+                 BRW_HORIZONTAL_STRIDE_1,
+                 BRW_SWIZZLE_XYXY,
+                 BRW_WRITEMASK_XY);
+}
+
+/** Construct float[1] register */
+static INLINE struct brw_reg brw_vec1_reg( GLuint file,
+                                            GLuint nr,
+                                            GLuint subnr )
+{
+   return brw_reg(file,
+                 nr,
+                 subnr,
+                 BRW_REGISTER_TYPE_F,
+                 BRW_VERTICAL_STRIDE_0,
+                 BRW_WIDTH_1,
+                 BRW_HORIZONTAL_STRIDE_0,
+                 BRW_SWIZZLE_XXXX,
+                 BRW_WRITEMASK_X);
+}
+
+
+static INLINE struct brw_reg retype( struct brw_reg reg,
+                                      GLuint type )
+{
+   reg.type = type;
+   return reg;
+}
+
+static INLINE struct brw_reg suboffset( struct brw_reg reg,
+                                         GLuint delta )
+{   
+   reg.subnr += delta * type_sz(reg.type);
+   return reg;
+}
+
+
+static INLINE struct brw_reg offset( struct brw_reg reg,
+                                      GLuint delta )
+{
+   reg.nr += delta;
+   return reg;
+}
+
+
+static INLINE struct brw_reg byte_offset( struct brw_reg reg,
+                                           GLuint bytes )
+{
+   GLuint newoffset = reg.nr * REG_SIZE + reg.subnr + bytes;
+   reg.nr = newoffset / REG_SIZE;
+   reg.subnr = newoffset % REG_SIZE;
+   return reg;
+}
+   
+
+/** Construct unsigned word[16] register */
+static INLINE struct brw_reg brw_uw16_reg( GLuint file,
+                                            GLuint nr,
+                                            GLuint subnr )
+{
+   return suboffset(retype(brw_vec16_reg(file, nr, 0), BRW_REGISTER_TYPE_UW), subnr);
+}
+
+/** Construct unsigned word[8] register */
+static INLINE struct brw_reg brw_uw8_reg( GLuint file,
+                                           GLuint nr,
+                                           GLuint subnr )
+{
+   return suboffset(retype(brw_vec8_reg(file, nr, 0), BRW_REGISTER_TYPE_UW), subnr);
+}
+
+/** Construct unsigned word[1] register */
+static INLINE struct brw_reg brw_uw1_reg( GLuint file,
+                                           GLuint nr,
+                                           GLuint subnr )
+{
+   return suboffset(retype(brw_vec1_reg(file, nr, 0), BRW_REGISTER_TYPE_UW), subnr);
+}
+
+static INLINE struct brw_reg brw_imm_reg( GLuint type )
+{
+   return brw_reg( BRW_IMMEDIATE_VALUE,
+                  0,
+                  0,
+                  type,
+                  BRW_VERTICAL_STRIDE_0,
+                  BRW_WIDTH_1,
+                  BRW_HORIZONTAL_STRIDE_0,
+                  0,
+                  0);      
+}
+
+/** Construct float immediate register */
+static INLINE struct brw_reg brw_imm_f( GLfloat f )
+{
+   struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_F);
+   imm.dw1.f = f;
+   return imm;
+}
+
+/** Construct integer immediate register */
+static INLINE struct brw_reg brw_imm_d( GLint d )
+{
+   struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_D);
+   imm.dw1.d = d;
+   return imm;
+}
+
+/** Construct uint immediate register */
+static INLINE struct brw_reg brw_imm_ud( GLuint ud )
+{
+   struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_UD);
+   imm.dw1.ud = ud;
+   return imm;
+}
+
+/** Construct ushort immediate register */
+static INLINE struct brw_reg brw_imm_uw( GLushort uw )
+{
+   struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_UW);
+   imm.dw1.ud = uw | (uw << 16);
+   return imm;
+}
+
+/** Construct short immediate register */
+static INLINE struct brw_reg brw_imm_w( GLshort w )
+{
+   struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_W);
+   imm.dw1.d = w | (w << 16);
+   return imm;
+}
+
+/* brw_imm_b and brw_imm_ub aren't supported by hardware - the type
+ * numbers alias with _V and _VF below:
+ */
+
+/** Construct vector of eight signed half-byte values */
+static INLINE struct brw_reg brw_imm_v( GLuint v )
+{
+   struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_V);
+   imm.vstride = BRW_VERTICAL_STRIDE_0;
+   imm.width = BRW_WIDTH_8;
+   imm.hstride = BRW_HORIZONTAL_STRIDE_1;
+   imm.dw1.ud = v;
+   return imm;
+}
+
+/** Construct vector of four 8-bit float values */
+static INLINE struct brw_reg brw_imm_vf( GLuint v )
+{
+   struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_VF);
+   imm.vstride = BRW_VERTICAL_STRIDE_0;
+   imm.width = BRW_WIDTH_4;
+   imm.hstride = BRW_HORIZONTAL_STRIDE_1;
+   imm.dw1.ud = v;
+   return imm;
+}
+
+#define VF_ZERO 0x0
+#define VF_ONE  0x30
+#define VF_NEG  (1<<7)
+
+static INLINE struct brw_reg brw_imm_vf4( GLuint v0, 
+                                           GLuint v1, 
+                                           GLuint v2,
+                                           GLuint v3)
+{
+   struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_VF);
+   imm.vstride = BRW_VERTICAL_STRIDE_0;
+   imm.width = BRW_WIDTH_4;
+   imm.hstride = BRW_HORIZONTAL_STRIDE_1;
+   imm.dw1.ud = ((v0 << 0) |
+                (v1 << 8) |
+                (v2 << 16) |
+                (v3 << 24));
+   return imm;
+}
+
+
+static INLINE struct brw_reg brw_address( struct brw_reg reg )
+{
+   return brw_imm_uw(reg.nr * REG_SIZE + reg.subnr);
+}
+
+/** Construct float[1] general-purpose register */
+static INLINE struct brw_reg brw_vec1_grf( GLuint nr, GLuint subnr )
+{
+   return brw_vec1_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr);
+}
+
+/** Construct float[2] general-purpose register */
+static INLINE struct brw_reg brw_vec2_grf( GLuint nr, GLuint subnr )
+{
+   return brw_vec2_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr);
+}
+
+/** Construct float[4] general-purpose register */
+static INLINE struct brw_reg brw_vec4_grf( GLuint nr, GLuint subnr )
+{
+   return brw_vec4_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr);
+}
+
+/** Construct float[8] general-purpose register */
+static INLINE struct brw_reg brw_vec8_grf( GLuint nr, GLuint subnr )
+{
+   return brw_vec8_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr);
+}
+
+
+static INLINE struct brw_reg brw_uw8_grf( GLuint nr, GLuint subnr )
+{
+   return brw_uw8_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr);
+}
+
+static INLINE struct brw_reg brw_uw16_grf( GLuint nr, GLuint subnr )
+{
+   return brw_uw16_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr);
+}
+
+
+/** Construct null register (usually used for setting condition codes) */
+static INLINE struct brw_reg brw_null_reg( void )
+{
+   return brw_vec8_reg(BRW_ARCHITECTURE_REGISTER_FILE, 
+                      BRW_ARF_NULL, 
+                      0);
+}
+
+static INLINE struct brw_reg brw_address_reg( GLuint subnr )
+{
+   return brw_uw1_reg(BRW_ARCHITECTURE_REGISTER_FILE, 
+                     BRW_ARF_ADDRESS, 
+                     subnr);
+}
+
+/* If/else instructions break in align16 mode if writemask & swizzle
+ * aren't xyzw.  This goes against the convention for other scalar
+ * regs:
+ */
+static INLINE struct brw_reg brw_ip_reg( void )
+{
+   return brw_reg(BRW_ARCHITECTURE_REGISTER_FILE, 
+                 BRW_ARF_IP, 
+                 0,
+                 BRW_REGISTER_TYPE_UD,
+                 BRW_VERTICAL_STRIDE_4, /* ? */
+                 BRW_WIDTH_1,
+                 BRW_HORIZONTAL_STRIDE_0,
+                 BRW_SWIZZLE_XYZW, /* NOTE! */
+                 BRW_WRITEMASK_XYZW); /* NOTE! */
+}
+
+static INLINE struct brw_reg brw_acc_reg( void )
+{
+   return brw_vec8_reg(BRW_ARCHITECTURE_REGISTER_FILE, 
+                      BRW_ARF_ACCUMULATOR, 
+                      0);
+}
+
+
+static INLINE struct brw_reg brw_flag_reg( void )
+{
+   return brw_uw1_reg(BRW_ARCHITECTURE_REGISTER_FILE,
+                     BRW_ARF_FLAG,
+                     0);
+}
+
+
+static INLINE struct brw_reg brw_mask_reg( GLuint subnr )
+{
+   return brw_uw1_reg(BRW_ARCHITECTURE_REGISTER_FILE,
+                     BRW_ARF_MASK,
+                     subnr);
+}
+
+static INLINE struct brw_reg brw_message_reg( GLuint nr )
+{
+   assert(nr < BRW_MAX_MRF);
+   return brw_vec8_reg(BRW_MESSAGE_REGISTER_FILE,
+                      nr,
+                      0);
+}
+
+
+
+
+/* This is almost always called with a numeric constant argument, so
+ * make things easy to evaluate at compile time:
+ */
+static INLINE GLuint cvt( GLuint val )
+{
+   switch (val) {
+   case 0: return 0;
+   case 1: return 1;
+   case 2: return 2;
+   case 4: return 3;
+   case 8: return 4;
+   case 16: return 5;
+   case 32: return 6;
+   }
+   return 0;
+}
+
+static INLINE struct brw_reg stride( struct brw_reg reg,
+                                      GLuint vstride,
+                                      GLuint width,
+                                      GLuint hstride )
+{
+   reg.vstride = cvt(vstride);
+   reg.width = cvt(width) - 1;
+   reg.hstride = cvt(hstride);
+   return reg;
+}
+
+
+static INLINE struct brw_reg vec16( struct brw_reg reg )
+{
+   return stride(reg, 16,16,1);
+}
+
+static INLINE struct brw_reg vec8( struct brw_reg reg )
+{
+   return stride(reg, 8,8,1);
+}
+
+static INLINE struct brw_reg vec4( struct brw_reg reg )
+{
+   return stride(reg, 4,4,1);
+}
+
+static INLINE struct brw_reg vec2( struct brw_reg reg )
+{
+   return stride(reg, 2,2,1);
+}
+
+static INLINE struct brw_reg vec1( struct brw_reg reg )
+{
+   return stride(reg, 0,1,0);
+}
+
+
+static INLINE struct brw_reg get_element( struct brw_reg reg, GLuint elt )
+{
+   return vec1(suboffset(reg, elt));
+}
+
+static INLINE struct brw_reg get_element_ud( struct brw_reg reg, GLuint elt )
+{
+   return vec1(suboffset(retype(reg, BRW_REGISTER_TYPE_UD), elt));
+}
+
+
+static INLINE struct brw_reg brw_swizzle( struct brw_reg reg,
+                                           GLuint x,
+                                           GLuint y, 
+                                           GLuint z,
+                                           GLuint w)
+{
+   reg.dw1.bits.swizzle = BRW_SWIZZLE4(BRW_GET_SWZ(reg.dw1.bits.swizzle, x),
+                                      BRW_GET_SWZ(reg.dw1.bits.swizzle, y),
+                                      BRW_GET_SWZ(reg.dw1.bits.swizzle, z),
+                                      BRW_GET_SWZ(reg.dw1.bits.swizzle, w));
+   return reg;
+}
+
+
+static INLINE struct brw_reg brw_swizzle1( struct brw_reg reg,
+                                            GLuint x )
+{
+   return brw_swizzle(reg, x, x, x, x);
+}
+
+static INLINE struct brw_reg brw_writemask( struct brw_reg reg,
+                                             GLuint mask )
+{
+   reg.dw1.bits.writemask &= mask;
+   return reg;
+}
+
+static INLINE struct brw_reg brw_set_writemask( struct brw_reg reg,
+                                                 GLuint mask )
+{
+   reg.dw1.bits.writemask = mask;
+   return reg;
+}
+
+static INLINE struct brw_reg negate( struct brw_reg reg )
+{
+   reg.negate ^= 1;
+   return reg;
+}
+
+static INLINE struct brw_reg brw_abs( struct brw_reg reg )
+{
+   reg.abs = 1;
+   return reg;
+}
+
+/***********************************************************************
+ */
+static INLINE struct brw_reg brw_vec4_indirect( GLuint subnr,
+                                                 GLint offset )
+{
+   struct brw_reg reg =  brw_vec4_grf(0, 0);
+   reg.subnr = subnr;
+   reg.address_mode = BRW_ADDRESS_REGISTER_INDIRECT_REGISTER;
+   reg.dw1.bits.indirect_offset = offset;
+   return reg;
+}
+
+static INLINE struct brw_reg brw_vec1_indirect( GLuint subnr,
+                                                 GLint offset )
+{
+   struct brw_reg reg =  brw_vec1_grf(0, 0);
+   reg.subnr = subnr;
+   reg.address_mode = BRW_ADDRESS_REGISTER_INDIRECT_REGISTER;
+   reg.dw1.bits.indirect_offset = offset;
+   return reg;
+}
+
+static INLINE struct brw_reg deref_4f(struct brw_indirect ptr, GLint offset)
+{
+   return brw_vec4_indirect(ptr.addr_subnr, ptr.addr_offset + offset);
+}
+
+static INLINE struct brw_reg deref_1f(struct brw_indirect ptr, GLint offset)
+{
+   return brw_vec1_indirect(ptr.addr_subnr, ptr.addr_offset + offset);
+}
+
+static INLINE struct brw_reg deref_4b(struct brw_indirect ptr, GLint offset)
+{
+   return retype(deref_4f(ptr, offset), BRW_REGISTER_TYPE_B);
+}
+
+static INLINE struct brw_reg deref_1uw(struct brw_indirect ptr, GLint offset)
+{
+   return retype(deref_1f(ptr, offset), BRW_REGISTER_TYPE_UW);
+}
+
+static INLINE struct brw_reg deref_1d(struct brw_indirect ptr, GLint offset)
+{
+   return retype(deref_1f(ptr, offset), BRW_REGISTER_TYPE_D);
+}
+
+static INLINE struct brw_reg deref_1ud(struct brw_indirect ptr, GLint offset)
+{
+   return retype(deref_1f(ptr, offset), BRW_REGISTER_TYPE_UD);
+}
+
+static INLINE struct brw_reg get_addr_reg(struct brw_indirect ptr)
+{
+   return brw_address_reg(ptr.addr_subnr);
+}
+
+static INLINE struct brw_indirect brw_indirect_offset( struct brw_indirect ptr, GLint offset )
+{
+   ptr.addr_offset += offset;
+   return ptr;
+}
+
+static INLINE struct brw_indirect brw_indirect( GLuint addr_subnr, GLint offset )
+{
+   struct brw_indirect ptr;
+   ptr.addr_subnr = addr_subnr;
+   ptr.addr_offset = offset;
+   ptr.pad = 0;
+   return ptr;
+}
+
+/** Do two brw_regs refer to the same register? */
+static INLINE GLboolean
+brw_same_reg(struct brw_reg r1, struct brw_reg r2)
+{
+   return r1.file == r2.file && r1.nr == r2.nr;
+}
+
+static INLINE struct brw_instruction *current_insn( struct brw_compile *p)
+{
+   return &p->store[p->nr_insn];
+}
+
+void brw_pop_insn_state( struct brw_compile *p );
+void brw_push_insn_state( struct brw_compile *p );
+void brw_set_mask_control( struct brw_compile *p, GLuint value );
+void brw_set_saturate( struct brw_compile *p, GLuint value );
+void brw_set_access_mode( struct brw_compile *p, GLuint access_mode );
+void brw_set_compression_control( struct brw_compile *p, GLboolean control );
+void brw_set_predicate_control_flag_value( struct brw_compile *p, GLuint value );
+void brw_set_predicate_control( struct brw_compile *p, GLuint pc );
+void brw_set_conditionalmod( struct brw_compile *p, GLuint conditional );
+
+void brw_init_compile( struct brw_context *, struct brw_compile *p );
+
+enum pipe_error brw_get_program( struct brw_compile *p, 
+                                 const GLuint **program,
+                                 GLuint *sz );
+
+
+/* Helpers for regular instructions:
+ */
+#define ALU1(OP)                                       \
+struct brw_instruction *brw_##OP(struct brw_compile *p,        \
+             struct brw_reg dest,                      \
+             struct brw_reg src0);
+
+#define ALU2(OP)                                       \
+struct brw_instruction *brw_##OP(struct brw_compile *p,        \
+             struct brw_reg dest,                      \
+             struct brw_reg src0,                      \
+             struct brw_reg src1);
+
+ALU1(MOV)
+ALU2(SEL)
+ALU1(NOT)
+ALU2(AND)
+ALU2(OR)
+ALU2(XOR)
+ALU2(SHR)
+ALU2(SHL)
+ALU2(RSR)
+ALU2(RSL)
+ALU2(ASR)
+ALU2(JMPI)
+ALU2(ADD)
+ALU2(MUL)
+ALU1(FRC)
+ALU1(RNDD)
+ALU1(RNDZ)
+ALU2(MAC)
+ALU2(MACH)
+ALU1(LZD)
+ALU2(DP4)
+ALU2(DPH)
+ALU2(DP3)
+ALU2(DP2)
+ALU2(LINE)
+
+#undef ALU1
+#undef ALU2
+
+
+
+/* Helpers for SEND instruction:
+ */
+void brw_urb_WRITE(struct brw_compile *p,
+                  struct brw_reg dest,
+                  GLuint msg_reg_nr,
+                  struct brw_reg src0,
+                  GLboolean allocate,
+                  GLboolean used,
+                  GLuint msg_length,
+                  GLuint response_length,
+                  GLboolean eot,
+                  GLboolean writes_complete,
+                  GLuint offset,
+                  GLuint swizzle);
+
+void brw_ff_sync(struct brw_compile *p,
+                  struct brw_reg dest,
+                  GLuint msg_reg_nr,
+                  struct brw_reg src0,
+                  GLboolean allocate,
+                  GLboolean used,
+                  GLuint msg_length,
+                  GLuint response_length,
+                  GLboolean eot,
+                  GLboolean writes_complete,
+                  GLuint offset,
+                  GLuint swizzle);
+
+void brw_fb_WRITE(struct brw_compile *p,
+                  struct brw_reg dest,
+                  GLuint msg_reg_nr,
+                  struct brw_reg src0,
+                  GLuint binding_table_index,
+                  GLuint msg_length,
+                  GLuint response_length,
+                  GLboolean eot);
+
+void brw_SAMPLE(struct brw_compile *p,
+               struct brw_reg dest,
+               GLuint msg_reg_nr,
+               struct brw_reg src0,
+               GLuint binding_table_index,
+               GLuint sampler,
+               GLuint writemask,
+               GLuint msg_type,
+               GLuint response_length,
+               GLuint msg_length,
+               GLboolean eot,
+               GLuint header_present,
+               GLuint simd_mode);
+
+void brw_math_16( struct brw_compile *p,
+                 struct brw_reg dest,
+                 GLuint function,
+                 GLuint saturate,
+                 GLuint msg_reg_nr,
+                 struct brw_reg src,
+                 GLuint precision );
+
+void brw_math( struct brw_compile *p,
+              struct brw_reg dest,
+              GLuint function,
+              GLuint saturate,
+              GLuint msg_reg_nr,
+              struct brw_reg src,
+              GLuint data_type,
+              GLuint precision );
+
+void brw_dp_READ_16( struct brw_compile *p,
+                    struct brw_reg dest,
+                    GLuint scratch_offset );
+
+void brw_dp_READ_4( struct brw_compile *p,
+                    struct brw_reg dest,
+                    GLboolean relAddr,
+                    GLuint location,
+                    GLuint bind_table_index );
+
+void brw_dp_READ_4_vs( struct brw_compile *p,
+                       struct brw_reg dest,
+                       GLuint oword,
+                       GLboolean relAddr,
+                       struct brw_reg addrReg,
+                       GLuint location,
+                       GLuint bind_table_index );
+
+void brw_dp_WRITE_16( struct brw_compile *p,
+                     struct brw_reg src,
+                     GLuint scratch_offset );
+
+/* If/else/endif.  Works by manipulating the execution flags on each
+ * channel.
+ */
+struct brw_instruction *brw_IF(struct brw_compile *p, 
+                              GLuint execute_size);
+
+struct brw_instruction *brw_ELSE(struct brw_compile *p, 
+                                struct brw_instruction *if_insn);
+
+void brw_ENDIF(struct brw_compile *p, 
+              struct brw_instruction *if_or_else_insn);
+
+
+/* DO/WHILE loops:
+ */
+struct brw_instruction *brw_DO(struct brw_compile *p,
+                              GLuint execute_size);
+
+struct brw_instruction *brw_WHILE(struct brw_compile *p, 
+              struct brw_instruction *patch_insn);
+
+struct brw_instruction *brw_BREAK(struct brw_compile *p);
+struct brw_instruction *brw_CONT(struct brw_compile *p);
+/* Forward jumps:
+ */
+void brw_land_fwd_jump(struct brw_compile *p, 
+                      struct brw_instruction *jmp_insn);
+
+
+
+void brw_NOP(struct brw_compile *p);
+
+/* Special case: there is never a destination, execution size will be
+ * taken from src0:
+ */
+void brw_CMP(struct brw_compile *p,
+            struct brw_reg dest,
+            GLuint conditional,
+            struct brw_reg src0,
+            struct brw_reg src1);
+
+void brw_print_reg( struct brw_reg reg );
+
+
+/*********************************************************************** 
+ * brw_eu_util.c:
+ */
+
+void brw_copy_indirect_to_indirect(struct brw_compile *p,
+                                  struct brw_indirect dst_ptr,
+                                  struct brw_indirect src_ptr,
+                                  GLuint count);
+
+void brw_copy_from_indirect(struct brw_compile *p,
+                           struct brw_reg dst,
+                           struct brw_indirect ptr,
+                           GLuint count);
+
+void brw_copy4(struct brw_compile *p,
+              struct brw_reg dst,
+              struct brw_reg src,
+              GLuint count);
+
+void brw_copy8(struct brw_compile *p,
+              struct brw_reg dst,
+              struct brw_reg src,
+              GLuint count);
+
+void brw_math_invert( struct brw_compile *p, 
+                     struct brw_reg dst,
+                     struct brw_reg src);
+
+void brw_set_src1( struct brw_instruction *insn,
+                          struct brw_reg reg );
+#endif
diff --git a/src/gallium/drivers/i965/brw_eu_debug.c b/src/gallium/drivers/i965/brw_eu_debug.c
new file mode 100644 (file)
index 0000000..5989f5a
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ 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 "util/u_debug.h"
+
+#include "brw_eu.h"
+
+void brw_print_reg( struct brw_reg hwreg )
+{
+   static const char *file[] = {
+      "arf",
+      "grf",
+      "msg",
+      "imm"
+   };
+
+   static const char *type[] = {
+      "ud",
+      "d",
+      "uw",
+      "w",
+      "ub",
+      "vf",
+      "hf",
+      "f"
+   };
+
+   debug_printf("%s%s", 
+               hwreg.abs ? "abs/" : "",
+               hwreg.negate ? "-" : "");
+     
+   if (hwreg.file == BRW_GENERAL_REGISTER_FILE &&
+       hwreg.nr % 2 == 0 &&
+       hwreg.subnr == 0 &&
+       hwreg.vstride == BRW_VERTICAL_STRIDE_8 &&
+       hwreg.width == BRW_WIDTH_8 &&
+       hwreg.hstride == BRW_HORIZONTAL_STRIDE_1 &&
+       hwreg.type == BRW_REGISTER_TYPE_F) {
+      /* vector register */
+      debug_printf("vec%d", hwreg.nr);
+   }
+   else if (hwreg.file == BRW_GENERAL_REGISTER_FILE &&
+           hwreg.vstride == BRW_VERTICAL_STRIDE_0 &&
+           hwreg.width == BRW_WIDTH_1 &&
+           hwreg.hstride == BRW_HORIZONTAL_STRIDE_0 &&
+           hwreg.type == BRW_REGISTER_TYPE_F) {      
+      /* "scalar" register */
+      debug_printf("scl%d.%d", hwreg.nr, hwreg.subnr / 4);
+   }
+   else if (hwreg.file == BRW_IMMEDIATE_VALUE) {
+      debug_printf("imm %f", hwreg.dw1.f);
+   }
+   else {
+      debug_printf("%s%d.%d<%d;%d,%d>:%s", 
+                  file[hwreg.file],
+                  hwreg.nr,
+                  hwreg.subnr / type_sz(hwreg.type),
+                  hwreg.vstride ? (1<<(hwreg.vstride-1)) : 0,
+                  1<<hwreg.width,
+                  hwreg.hstride ? (1<<(hwreg.hstride-1)) : 0,          
+                  type[hwreg.type]);
+   }
+}
+
+
+
diff --git a/src/gallium/drivers/i965/brw_eu_emit.c b/src/gallium/drivers/i965/brw_eu_emit.c
new file mode 100644 (file)
index 0000000..00d8eac
--- /dev/null
@@ -0,0 +1,1433 @@
+/*
+ Copyright (C) Intel Corp.  2006.  All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ **********************************************************************/
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  */
+     
+
+#include "brw_context.h"
+#include "brw_defines.h"
+#include "brw_eu.h"
+#include "brw_debug.h"
+#include "brw_disasm.h"
+
+
+
+
+/***********************************************************************
+ * Internal helper for constructing instructions
+ */
+
+static void guess_execution_size( struct brw_instruction *insn,
+                                 struct brw_reg reg )
+{
+   if (reg.width == BRW_WIDTH_8 && 
+       insn->header.compression_control == BRW_COMPRESSION_COMPRESSED) 
+      insn->header.execution_size = BRW_EXECUTE_16;
+   else
+      insn->header.execution_size = reg.width; /* note - definitions are compatible */
+}
+
+
+static void brw_set_dest( struct brw_instruction *insn,
+                         struct brw_reg dest )
+{
+   if (dest.type != BRW_ARCHITECTURE_REGISTER_FILE)
+      assert(dest.nr < 128);
+
+   insn->bits1.da1.dest_reg_file = dest.file;
+   insn->bits1.da1.dest_reg_type = dest.type;
+   insn->bits1.da1.dest_address_mode = dest.address_mode;
+
+   if (dest.address_mode == BRW_ADDRESS_DIRECT) {   
+      insn->bits1.da1.dest_reg_nr = dest.nr;
+
+      if (insn->header.access_mode == BRW_ALIGN_1) {
+        insn->bits1.da1.dest_subreg_nr = dest.subnr;
+        if (dest.hstride == BRW_HORIZONTAL_STRIDE_0)
+           dest.hstride = BRW_HORIZONTAL_STRIDE_1;
+        insn->bits1.da1.dest_horiz_stride = dest.hstride;
+      }
+      else {
+        insn->bits1.da16.dest_subreg_nr = dest.subnr / 16;
+        insn->bits1.da16.dest_writemask = dest.dw1.bits.writemask;
+      }
+   }
+   else {
+      insn->bits1.ia1.dest_subreg_nr = dest.subnr;
+
+      /* These are different sizes in align1 vs align16:
+       */
+      if (insn->header.access_mode == BRW_ALIGN_1) {
+        insn->bits1.ia1.dest_indirect_offset = dest.dw1.bits.indirect_offset;
+        if (dest.hstride == BRW_HORIZONTAL_STRIDE_0)
+           dest.hstride = BRW_HORIZONTAL_STRIDE_1;
+        insn->bits1.ia1.dest_horiz_stride = dest.hstride;
+      }
+      else {
+        insn->bits1.ia16.dest_indirect_offset = dest.dw1.bits.indirect_offset;
+      }
+   }
+
+   /* NEW: Set the execution size based on dest.width and
+    * insn->compression_control:
+    */
+   guess_execution_size(insn, dest);
+}
+
+static void brw_set_src0( struct brw_instruction *insn,
+                          struct brw_reg reg )
+{
+   assert(reg.file != BRW_MESSAGE_REGISTER_FILE);
+
+   if (reg.type != BRW_ARCHITECTURE_REGISTER_FILE)
+      assert(reg.nr < 128);
+
+   insn->bits1.da1.src0_reg_file = reg.file;
+   insn->bits1.da1.src0_reg_type = reg.type;
+   insn->bits2.da1.src0_abs = reg.abs;
+   insn->bits2.da1.src0_negate = reg.negate;
+   insn->bits2.da1.src0_address_mode = reg.address_mode;
+
+   if (reg.file == BRW_IMMEDIATE_VALUE) {
+      insn->bits3.ud = reg.dw1.ud;
+   
+      /* Required to set some fields in src1 as well:
+       */
+      insn->bits1.da1.src1_reg_file = 0; /* arf */
+      insn->bits1.da1.src1_reg_type = reg.type;
+   }
+   else 
+   {
+      if (reg.address_mode == BRW_ADDRESS_DIRECT) {
+        if (insn->header.access_mode == BRW_ALIGN_1) {
+           insn->bits2.da1.src0_subreg_nr = reg.subnr;
+           insn->bits2.da1.src0_reg_nr = reg.nr;
+        }
+        else {
+           insn->bits2.da16.src0_subreg_nr = reg.subnr / 16;
+           insn->bits2.da16.src0_reg_nr = reg.nr;
+        }
+      }
+      else {
+        insn->bits2.ia1.src0_subreg_nr = reg.subnr;
+
+        if (insn->header.access_mode == BRW_ALIGN_1) {
+           insn->bits2.ia1.src0_indirect_offset = reg.dw1.bits.indirect_offset; 
+        }
+        else {
+           insn->bits2.ia16.src0_subreg_nr = reg.dw1.bits.indirect_offset;
+        }
+      }
+
+      if (insn->header.access_mode == BRW_ALIGN_1) {
+        if (reg.width == BRW_WIDTH_1 && 
+            insn->header.execution_size == BRW_EXECUTE_1) {
+           insn->bits2.da1.src0_horiz_stride = BRW_HORIZONTAL_STRIDE_0;
+           insn->bits2.da1.src0_width = BRW_WIDTH_1;
+           insn->bits2.da1.src0_vert_stride = BRW_VERTICAL_STRIDE_0;
+        }
+        else {
+           insn->bits2.da1.src0_horiz_stride = reg.hstride;
+           insn->bits2.da1.src0_width = reg.width;
+           insn->bits2.da1.src0_vert_stride = reg.vstride;
+        }
+      }
+      else {
+        insn->bits2.da16.src0_swz_x = BRW_GET_SWZ(reg.dw1.bits.swizzle, BRW_CHANNEL_X);
+        insn->bits2.da16.src0_swz_y = BRW_GET_SWZ(reg.dw1.bits.swizzle, BRW_CHANNEL_Y);
+        insn->bits2.da16.src0_swz_z = BRW_GET_SWZ(reg.dw1.bits.swizzle, BRW_CHANNEL_Z);
+        insn->bits2.da16.src0_swz_w = BRW_GET_SWZ(reg.dw1.bits.swizzle, BRW_CHANNEL_W);
+
+        /* This is an oddity of the fact we're using the same
+         * descriptions for registers in align_16 as align_1:
+         */
+        if (reg.vstride == BRW_VERTICAL_STRIDE_8)
+           insn->bits2.da16.src0_vert_stride = BRW_VERTICAL_STRIDE_4;
+        else
+           insn->bits2.da16.src0_vert_stride = reg.vstride;
+      }
+   }
+}
+
+
+void brw_set_src1( struct brw_instruction *insn,
+                   struct brw_reg reg )
+{
+   assert(reg.file != BRW_MESSAGE_REGISTER_FILE);
+
+   assert(reg.nr < 128);
+
+   insn->bits1.da1.src1_reg_file = reg.file;
+   insn->bits1.da1.src1_reg_type = reg.type;
+   insn->bits3.da1.src1_abs = reg.abs;
+   insn->bits3.da1.src1_negate = reg.negate;
+
+   /* Only src1 can be immediate in two-argument instructions.
+    */
+   assert(insn->bits1.da1.src0_reg_file != BRW_IMMEDIATE_VALUE);
+
+   if (reg.file == BRW_IMMEDIATE_VALUE) {
+      insn->bits3.ud = reg.dw1.ud;
+   }
+   else {
+      /* This is a hardware restriction, which may or may not be lifted
+       * in the future:
+       */
+      assert (reg.address_mode == BRW_ADDRESS_DIRECT);
+      /*assert (reg.file == BRW_GENERAL_REGISTER_FILE); */
+
+      if (insn->header.access_mode == BRW_ALIGN_1) {
+        insn->bits3.da1.src1_subreg_nr = reg.subnr;
+        insn->bits3.da1.src1_reg_nr = reg.nr;
+      }
+      else {
+        insn->bits3.da16.src1_subreg_nr = reg.subnr / 16;
+        insn->bits3.da16.src1_reg_nr = reg.nr;
+      }
+
+      if (insn->header.access_mode == BRW_ALIGN_1) {
+        if (reg.width == BRW_WIDTH_1 && 
+            insn->header.execution_size == BRW_EXECUTE_1) {
+           insn->bits3.da1.src1_horiz_stride = BRW_HORIZONTAL_STRIDE_0;
+           insn->bits3.da1.src1_width = BRW_WIDTH_1;
+           insn->bits3.da1.src1_vert_stride = BRW_VERTICAL_STRIDE_0;
+        }
+        else {
+           insn->bits3.da1.src1_horiz_stride = reg.hstride;
+           insn->bits3.da1.src1_width = reg.width;
+           insn->bits3.da1.src1_vert_stride = reg.vstride;
+        }
+      }
+      else {
+        insn->bits3.da16.src1_swz_x = BRW_GET_SWZ(reg.dw1.bits.swizzle, BRW_CHANNEL_X);
+        insn->bits3.da16.src1_swz_y = BRW_GET_SWZ(reg.dw1.bits.swizzle, BRW_CHANNEL_Y);
+        insn->bits3.da16.src1_swz_z = BRW_GET_SWZ(reg.dw1.bits.swizzle, BRW_CHANNEL_Z);
+        insn->bits3.da16.src1_swz_w = BRW_GET_SWZ(reg.dw1.bits.swizzle, BRW_CHANNEL_W);
+
+        /* This is an oddity of the fact we're using the same
+         * descriptions for registers in align_16 as align_1:
+         */
+        if (reg.vstride == BRW_VERTICAL_STRIDE_8)
+           insn->bits3.da16.src1_vert_stride = BRW_VERTICAL_STRIDE_4;
+        else
+           insn->bits3.da16.src1_vert_stride = reg.vstride;
+      }
+   }
+}
+
+
+
+static void brw_set_math_message( struct brw_context *brw,
+                                 struct brw_instruction *insn,
+                                 GLuint msg_length,
+                                 GLuint response_length,
+                                 GLuint function,
+                                 GLuint integer_type,
+                                 GLboolean low_precision,
+                                 GLboolean saturate,
+                                 GLuint dataType )
+{
+   brw_set_src1(insn, brw_imm_d(0));
+
+   if (BRW_IS_IGDNG(brw)) {
+       insn->bits3.math_igdng.function = function;
+       insn->bits3.math_igdng.int_type = integer_type;
+       insn->bits3.math_igdng.precision = low_precision;
+       insn->bits3.math_igdng.saturate = saturate;
+       insn->bits3.math_igdng.data_type = dataType;
+       insn->bits3.math_igdng.snapshot = 0;
+       insn->bits3.math_igdng.header_present = 0;
+       insn->bits3.math_igdng.response_length = response_length;
+       insn->bits3.math_igdng.msg_length = msg_length;
+       insn->bits3.math_igdng.end_of_thread = 0;
+       insn->bits2.send_igdng.sfid = BRW_MESSAGE_TARGET_MATH;
+       insn->bits2.send_igdng.end_of_thread = 0;
+   } else {
+       insn->bits3.math.function = function;
+       insn->bits3.math.int_type = integer_type;
+       insn->bits3.math.precision = low_precision;
+       insn->bits3.math.saturate = saturate;
+       insn->bits3.math.data_type = dataType;
+       insn->bits3.math.response_length = response_length;
+       insn->bits3.math.msg_length = msg_length;
+       insn->bits3.math.msg_target = BRW_MESSAGE_TARGET_MATH;
+       insn->bits3.math.end_of_thread = 0;
+   }
+}
+
+
+static void brw_set_ff_sync_message( struct brw_context *brw,
+                                struct brw_instruction *insn,
+                                GLboolean allocate,
+                                GLboolean used,
+                                GLuint msg_length,
+                                GLuint response_length,
+                                GLboolean end_of_thread,
+                                GLboolean complete,
+                                GLuint offset,
+                                GLuint swizzle_control )
+{
+       brw_set_src1(insn, brw_imm_d(0));
+
+       insn->bits3.urb_igdng.opcode = 1;
+       insn->bits3.urb_igdng.offset = offset;
+       insn->bits3.urb_igdng.swizzle_control = swizzle_control;
+       insn->bits3.urb_igdng.allocate = allocate;
+       insn->bits3.urb_igdng.used = used;
+       insn->bits3.urb_igdng.complete = complete;
+       insn->bits3.urb_igdng.header_present = 1;
+       insn->bits3.urb_igdng.response_length = response_length;
+       insn->bits3.urb_igdng.msg_length = msg_length;
+       insn->bits3.urb_igdng.end_of_thread = end_of_thread;
+       insn->bits2.send_igdng.sfid = BRW_MESSAGE_TARGET_URB;
+       insn->bits2.send_igdng.end_of_thread = end_of_thread;
+}
+
+static void brw_set_urb_message( struct brw_context *brw,
+                                struct brw_instruction *insn,
+                                GLboolean allocate,
+                                GLboolean used,
+                                GLuint msg_length,
+                                GLuint response_length,
+                                GLboolean end_of_thread,
+                                GLboolean complete,
+                                GLuint offset,
+                                GLuint swizzle_control )
+{
+    brw_set_src1(insn, brw_imm_d(0));
+
+    if (BRW_IS_IGDNG(brw)) {
+        insn->bits3.urb_igdng.opcode = 0;      /* ? */
+        insn->bits3.urb_igdng.offset = offset;
+        insn->bits3.urb_igdng.swizzle_control = swizzle_control;
+        insn->bits3.urb_igdng.allocate = allocate;
+        insn->bits3.urb_igdng.used = used;     /* ? */
+        insn->bits3.urb_igdng.complete = complete;
+        insn->bits3.urb_igdng.header_present = 1;
+        insn->bits3.urb_igdng.response_length = response_length;
+        insn->bits3.urb_igdng.msg_length = msg_length;
+        insn->bits3.urb_igdng.end_of_thread = end_of_thread;
+        insn->bits2.send_igdng.sfid = BRW_MESSAGE_TARGET_URB;
+        insn->bits2.send_igdng.end_of_thread = end_of_thread;
+    } else {
+        insn->bits3.urb.opcode = 0;    /* ? */
+        insn->bits3.urb.offset = offset;
+        insn->bits3.urb.swizzle_control = swizzle_control;
+        insn->bits3.urb.allocate = allocate;
+        insn->bits3.urb.used = used;   /* ? */
+        insn->bits3.urb.complete = complete;
+        insn->bits3.urb.response_length = response_length;
+        insn->bits3.urb.msg_length = msg_length;
+        insn->bits3.urb.msg_target = BRW_MESSAGE_TARGET_URB;
+        insn->bits3.urb.end_of_thread = end_of_thread;
+    }
+}
+
+static void brw_set_dp_write_message( struct brw_context *brw,
+                                     struct brw_instruction *insn,
+                                     GLuint binding_table_index,
+                                     GLuint msg_control,
+                                     GLuint msg_type,
+                                     GLuint msg_length,
+                                     GLuint pixel_scoreboard_clear,
+                                     GLuint response_length,
+                                     GLuint end_of_thread )
+{
+   brw_set_src1(insn, brw_imm_d(0));
+
+   if (BRW_IS_IGDNG(brw)) {
+       insn->bits3.dp_write_igdng.binding_table_index = binding_table_index;
+       insn->bits3.dp_write_igdng.msg_control = msg_control;
+       insn->bits3.dp_write_igdng.pixel_scoreboard_clear = pixel_scoreboard_clear;
+       insn->bits3.dp_write_igdng.msg_type = msg_type;
+       insn->bits3.dp_write_igdng.send_commit_msg = 0;
+       insn->bits3.dp_write_igdng.header_present = 1;
+       insn->bits3.dp_write_igdng.response_length = response_length;
+       insn->bits3.dp_write_igdng.msg_length = msg_length;
+       insn->bits3.dp_write_igdng.end_of_thread = end_of_thread;
+       insn->bits2.send_igdng.sfid = BRW_MESSAGE_TARGET_DATAPORT_WRITE;
+       insn->bits2.send_igdng.end_of_thread = end_of_thread;
+   } else {
+       insn->bits3.dp_write.binding_table_index = binding_table_index;
+       insn->bits3.dp_write.msg_control = msg_control;
+       insn->bits3.dp_write.pixel_scoreboard_clear = pixel_scoreboard_clear;
+       insn->bits3.dp_write.msg_type = msg_type;
+       insn->bits3.dp_write.send_commit_msg = 0;
+       insn->bits3.dp_write.response_length = response_length;
+       insn->bits3.dp_write.msg_length = msg_length;
+       insn->bits3.dp_write.msg_target = BRW_MESSAGE_TARGET_DATAPORT_WRITE;
+       insn->bits3.dp_write.end_of_thread = end_of_thread;
+   }
+}
+
+static void brw_set_dp_read_message( struct brw_context *brw,
+                                     struct brw_instruction *insn,
+                                     GLuint binding_table_index,
+                                     GLuint msg_control,
+                                     GLuint msg_type,
+                                     GLuint target_cache,
+                                     GLuint msg_length,
+                                     GLuint response_length,
+                                     GLuint end_of_thread )
+{
+   brw_set_src1(insn, brw_imm_d(0));
+
+   if (BRW_IS_IGDNG(brw)) {
+       insn->bits3.dp_read_igdng.binding_table_index = binding_table_index;
+       insn->bits3.dp_read_igdng.msg_control = msg_control;
+       insn->bits3.dp_read_igdng.msg_type = msg_type;
+       insn->bits3.dp_read_igdng.target_cache = target_cache;
+       insn->bits3.dp_read_igdng.header_present = 1;
+       insn->bits3.dp_read_igdng.response_length = response_length;
+       insn->bits3.dp_read_igdng.msg_length = msg_length;
+       insn->bits3.dp_read_igdng.pad1 = 0;
+       insn->bits3.dp_read_igdng.end_of_thread = end_of_thread;
+       insn->bits2.send_igdng.sfid = BRW_MESSAGE_TARGET_DATAPORT_READ;
+       insn->bits2.send_igdng.end_of_thread = end_of_thread;
+   } else {
+       insn->bits3.dp_read.binding_table_index = binding_table_index; /*0:7*/
+       insn->bits3.dp_read.msg_control = msg_control;  /*8:11*/
+       insn->bits3.dp_read.msg_type = msg_type;  /*12:13*/
+       insn->bits3.dp_read.target_cache = target_cache;  /*14:15*/
+       insn->bits3.dp_read.response_length = response_length;  /*16:19*/
+       insn->bits3.dp_read.msg_length = msg_length;  /*20:23*/
+       insn->bits3.dp_read.msg_target = BRW_MESSAGE_TARGET_DATAPORT_READ; /*24:27*/
+       insn->bits3.dp_read.pad1 = 0;  /*28:30*/
+       insn->bits3.dp_read.end_of_thread = end_of_thread;  /*31*/
+   }
+}
+
+static void brw_set_sampler_message(struct brw_context *brw,
+                                    struct brw_instruction *insn,
+                                    GLuint binding_table_index,
+                                    GLuint sampler,
+                                    GLuint msg_type,
+                                    GLuint response_length,
+                                    GLuint msg_length,
+                                    GLboolean eot,
+                                    GLuint header_present,
+                                    GLuint simd_mode)
+{
+   assert(eot == 0);
+   brw_set_src1(insn, brw_imm_d(0));
+
+   if (BRW_IS_IGDNG(brw)) {
+      insn->bits3.sampler_igdng.binding_table_index = binding_table_index;
+      insn->bits3.sampler_igdng.sampler = sampler;
+      insn->bits3.sampler_igdng.msg_type = msg_type;
+      insn->bits3.sampler_igdng.simd_mode = simd_mode;
+      insn->bits3.sampler_igdng.header_present = header_present;
+      insn->bits3.sampler_igdng.response_length = response_length;
+      insn->bits3.sampler_igdng.msg_length = msg_length;
+      insn->bits3.sampler_igdng.end_of_thread = eot;
+      insn->bits2.send_igdng.sfid = BRW_MESSAGE_TARGET_SAMPLER;
+      insn->bits2.send_igdng.end_of_thread = eot;
+   } else if (BRW_IS_G4X(brw)) {
+      insn->bits3.sampler_g4x.binding_table_index = binding_table_index;
+      insn->bits3.sampler_g4x.sampler = sampler;
+      insn->bits3.sampler_g4x.msg_type = msg_type;
+      insn->bits3.sampler_g4x.response_length = response_length;
+      insn->bits3.sampler_g4x.msg_length = msg_length;
+      insn->bits3.sampler_g4x.end_of_thread = eot;
+      insn->bits3.sampler_g4x.msg_target = BRW_MESSAGE_TARGET_SAMPLER;
+   } else {
+      insn->bits3.sampler.binding_table_index = binding_table_index;
+      insn->bits3.sampler.sampler = sampler;
+      insn->bits3.sampler.msg_type = msg_type;
+      insn->bits3.sampler.return_format = BRW_SAMPLER_RETURN_FORMAT_FLOAT32;
+      insn->bits3.sampler.response_length = response_length;
+      insn->bits3.sampler.msg_length = msg_length;
+      insn->bits3.sampler.end_of_thread = eot;
+      insn->bits3.sampler.msg_target = BRW_MESSAGE_TARGET_SAMPLER;
+   }
+}
+
+
+
+static struct brw_instruction *next_insn( struct brw_compile *p, 
+                                         GLuint opcode )
+{
+   struct brw_instruction *insn;
+
+   if (0 && (BRW_DEBUG & DEBUG_DISASSEM))
+   {
+      if (p->nr_insn) 
+         brw_disasm_insn(stderr, &p->store[p->nr_insn-1]);
+   }
+
+   assert(p->nr_insn + 1 < BRW_EU_MAX_INSN);
+
+   insn = &p->store[p->nr_insn++];
+   memcpy(insn, p->current, sizeof(*insn));
+
+   /* Reset this one-shot flag: 
+    */
+
+   if (p->current->header.destreg__conditionalmod) {
+      p->current->header.destreg__conditionalmod = 0;
+      p->current->header.predicate_control = BRW_PREDICATE_NORMAL;
+   }
+
+   insn->header.opcode = opcode;
+   return insn;
+}
+
+
+static struct brw_instruction *brw_alu1( struct brw_compile *p,
+                                        GLuint opcode,
+                                        struct brw_reg dest,
+                                        struct brw_reg src )
+{
+   struct brw_instruction *insn = next_insn(p, opcode);
+   brw_set_dest(insn, dest);
+   brw_set_src0(insn, src);   
+   return insn;
+}
+
+static struct brw_instruction *brw_alu2(struct brw_compile *p,
+                                       GLuint opcode,
+                                       struct brw_reg dest,
+                                       struct brw_reg src0,
+                                       struct brw_reg src1 )
+{
+   struct brw_instruction *insn = next_insn(p, opcode);   
+   brw_set_dest(insn, dest);
+   brw_set_src0(insn, src0);
+   brw_set_src1(insn, src1);
+   return insn;
+}
+
+
+/***********************************************************************
+ * Convenience routines.
+ */
+#define ALU1(OP)                                       \
+struct brw_instruction *brw_##OP(struct brw_compile *p,        \
+             struct brw_reg dest,                      \
+             struct brw_reg src0)                      \
+{                                                      \
+   return brw_alu1(p, BRW_OPCODE_##OP, dest, src0);            \
+}
+
+#define ALU2(OP)                                       \
+struct brw_instruction *brw_##OP(struct brw_compile *p,        \
+             struct brw_reg dest,                      \
+             struct brw_reg src0,                      \
+             struct brw_reg src1)                      \
+{                                                      \
+   return brw_alu2(p, BRW_OPCODE_##OP, dest, src0, src1);      \
+}
+
+
+ALU1(MOV)
+ALU2(SEL)
+ALU1(NOT)
+ALU2(AND)
+ALU2(OR)
+ALU2(XOR)
+ALU2(SHR)
+ALU2(SHL)
+ALU2(RSR)
+ALU2(RSL)
+ALU2(ASR)
+ALU2(ADD)
+ALU2(MUL)
+ALU1(FRC)
+ALU1(RNDD)
+ALU1(RNDZ)
+ALU2(MAC)
+ALU2(MACH)
+ALU1(LZD)
+ALU2(DP4)
+ALU2(DPH)
+ALU2(DP3)
+ALU2(DP2)
+ALU2(LINE)
+
+
+
+
+void brw_NOP(struct brw_compile *p)
+{
+   struct brw_instruction *insn = next_insn(p, BRW_OPCODE_NOP);   
+   brw_set_dest(insn, retype(brw_vec4_grf(0,0), BRW_REGISTER_TYPE_UD));
+   brw_set_src0(insn, retype(brw_vec4_grf(0,0), BRW_REGISTER_TYPE_UD));
+   brw_set_src1(insn, brw_imm_ud(0x0));
+}
+
+
+
+
+
+/***********************************************************************
+ * Comparisons, if/else/endif
+ */
+
+struct brw_instruction *brw_JMPI(struct brw_compile *p, 
+                                 struct brw_reg dest,
+                                 struct brw_reg src0,
+                                 struct brw_reg src1)
+{
+   struct brw_instruction *insn = brw_alu2(p, BRW_OPCODE_JMPI, dest, src0, src1);
+
+   insn->header.execution_size = 1;
+   insn->header.compression_control = BRW_COMPRESSION_NONE;
+   insn->header.mask_control = BRW_MASK_DISABLE;
+
+   p->current->header.predicate_control = BRW_PREDICATE_NONE;
+
+   return insn;
+}
+
+/* EU takes the value from the flag register and pushes it onto some
+ * sort of a stack (presumably merging with any flag value already on
+ * the stack).  Within an if block, the flags at the top of the stack
+ * control execution on each channel of the unit, eg. on each of the
+ * 16 pixel values in our wm programs.
+ *
+ * When the matching 'else' instruction is reached (presumably by
+ * countdown of the instruction count patched in by our ELSE/ENDIF
+ * functions), the relevent flags are inverted.
+ *
+ * When the matching 'endif' instruction is reached, the flags are
+ * popped off.  If the stack is now empty, normal execution resumes.
+ *
+ * No attempt is made to deal with stack overflow (14 elements?).
+ */
+struct brw_instruction *brw_IF(struct brw_compile *p, GLuint execute_size)
+{
+   struct brw_instruction *insn;
+
+   if (p->single_program_flow) {
+      assert(execute_size == BRW_EXECUTE_1);
+
+      insn = next_insn(p, BRW_OPCODE_ADD);
+      insn->header.predicate_inverse = 1;
+   } else {
+      insn = next_insn(p, BRW_OPCODE_IF);
+   }
+
+   /* Override the defaults for this instruction:
+    */
+   brw_set_dest(insn, brw_ip_reg());
+   brw_set_src0(insn, brw_ip_reg());
+   brw_set_src1(insn, brw_imm_d(0x0));
+
+   insn->header.execution_size = execute_size;
+   insn->header.compression_control = BRW_COMPRESSION_NONE;
+   insn->header.predicate_control = BRW_PREDICATE_NORMAL;
+   insn->header.mask_control = BRW_MASK_ENABLE;
+   if (!p->single_program_flow)
+       insn->header.thread_control = BRW_THREAD_SWITCH;
+
+   p->current->header.predicate_control = BRW_PREDICATE_NONE;
+
+   return insn;
+}
+
+
+struct brw_instruction *brw_ELSE(struct brw_compile *p, 
+                                struct brw_instruction *if_insn)
+{
+   struct brw_instruction *insn;
+   GLuint br = 1;
+
+   if (BRW_IS_IGDNG(p->brw))
+      br = 2;
+
+   if (p->single_program_flow) {
+      insn = next_insn(p, BRW_OPCODE_ADD);
+   } else {
+      insn = next_insn(p, BRW_OPCODE_ELSE);
+   }
+
+   brw_set_dest(insn, brw_ip_reg());
+   brw_set_src0(insn, brw_ip_reg());
+   brw_set_src1(insn, brw_imm_d(0x0));
+
+   insn->header.compression_control = BRW_COMPRESSION_NONE;
+   insn->header.execution_size = if_insn->header.execution_size;
+   insn->header.mask_control = BRW_MASK_ENABLE;
+   if (!p->single_program_flow)
+       insn->header.thread_control = BRW_THREAD_SWITCH;
+
+   /* Patch the if instruction to point at this instruction.
+    */
+   if (p->single_program_flow) {
+      assert(if_insn->header.opcode == BRW_OPCODE_ADD);
+
+      if_insn->bits3.ud = (insn - if_insn + 1) * 16;
+   } else {
+      assert(if_insn->header.opcode == BRW_OPCODE_IF);
+
+      if_insn->bits3.if_else.jump_count = br * (insn - if_insn);
+      if_insn->bits3.if_else.pop_count = 0;
+      if_insn->bits3.if_else.pad0 = 0;
+   }
+
+   return insn;
+}
+
+void brw_ENDIF(struct brw_compile *p, 
+              struct brw_instruction *patch_insn)
+{
+   GLuint br = 1;
+
+   if (BRW_IS_IGDNG(p->brw))
+      br = 2; 
+   if (p->single_program_flow) {
+      /* In single program flow mode, there's no need to execute an ENDIF,
+       * since we don't need to do any stack operations, and if we're executing
+       * currently, we want to just continue executing.
+       */
+      struct brw_instruction *next = &p->store[p->nr_insn];
+
+      assert(patch_insn->header.opcode == BRW_OPCODE_ADD);
+
+      patch_insn->bits3.ud = (next - patch_insn) * 16;
+   } else {
+      struct brw_instruction *insn = next_insn(p, BRW_OPCODE_ENDIF);
+
+      brw_set_dest(insn, retype(brw_vec4_grf(0,0), BRW_REGISTER_TYPE_UD));
+      brw_set_src0(insn, retype(brw_vec4_grf(0,0), BRW_REGISTER_TYPE_UD));
+      brw_set_src1(insn, brw_imm_d(0x0));
+
+      insn->header.compression_control = BRW_COMPRESSION_NONE;
+      insn->header.execution_size = patch_insn->header.execution_size;
+      insn->header.mask_control = BRW_MASK_ENABLE;
+      insn->header.thread_control = BRW_THREAD_SWITCH;
+
+      assert(patch_insn->bits3.if_else.jump_count == 0);
+
+      /* Patch the if or else instructions to point at this or the next
+       * instruction respectively.
+       */
+      if (patch_insn->header.opcode == BRW_OPCODE_IF) {
+        /* Automagically turn it into an IFF:
+         */
+        patch_insn->header.opcode = BRW_OPCODE_IFF;
+        patch_insn->bits3.if_else.jump_count = br * (insn - patch_insn + 1);
+        patch_insn->bits3.if_else.pop_count = 0;
+        patch_insn->bits3.if_else.pad0 = 0;
+      } else if (patch_insn->header.opcode == BRW_OPCODE_ELSE) {
+        patch_insn->bits3.if_else.jump_count = br * (insn - patch_insn + 1);
+        patch_insn->bits3.if_else.pop_count = 1;
+        patch_insn->bits3.if_else.pad0 = 0;
+      } else {
+        assert(0);
+      }
+
+      /* Also pop item off the stack in the endif instruction:
+       */
+      insn->bits3.if_else.jump_count = 0;
+      insn->bits3.if_else.pop_count = 1;
+      insn->bits3.if_else.pad0 = 0;
+   }
+}
+
+struct brw_instruction *brw_BREAK(struct brw_compile *p)
+{
+   struct brw_instruction *insn;
+   insn = next_insn(p, BRW_OPCODE_BREAK);
+   brw_set_dest(insn, brw_ip_reg());
+   brw_set_src0(insn, brw_ip_reg());
+   brw_set_src1(insn, brw_imm_d(0x0));
+   insn->header.compression_control = BRW_COMPRESSION_NONE;
+   insn->header.execution_size = BRW_EXECUTE_8;
+   /* insn->header.mask_control = BRW_MASK_DISABLE; */
+   insn->bits3.if_else.pad0 = 0;
+   return insn;
+}
+
+struct brw_instruction *brw_CONT(struct brw_compile *p)
+{
+   struct brw_instruction *insn;
+   insn = next_insn(p, BRW_OPCODE_CONTINUE);
+   brw_set_dest(insn, brw_ip_reg());
+   brw_set_src0(insn, brw_ip_reg());
+   brw_set_src1(insn, brw_imm_d(0x0));
+   insn->header.compression_control = BRW_COMPRESSION_NONE;
+   insn->header.execution_size = BRW_EXECUTE_8;
+   /* insn->header.mask_control = BRW_MASK_DISABLE; */
+   insn->bits3.if_else.pad0 = 0;
+   return insn;
+}
+
+/* DO/WHILE loop:
+ */
+struct brw_instruction *brw_DO(struct brw_compile *p, GLuint execute_size)
+{
+   if (p->single_program_flow) {
+      return &p->store[p->nr_insn];
+   } else {
+      struct brw_instruction *insn = next_insn(p, BRW_OPCODE_DO);
+
+      /* Override the defaults for this instruction:
+       */
+      brw_set_dest(insn, brw_null_reg());
+      brw_set_src0(insn, brw_null_reg());
+      brw_set_src1(insn, brw_null_reg());
+
+      insn->header.compression_control = BRW_COMPRESSION_NONE;
+      insn->header.execution_size = execute_size;
+      insn->header.predicate_control = BRW_PREDICATE_NONE;
+      /* insn->header.mask_control = BRW_MASK_ENABLE; */
+      /* insn->header.mask_control = BRW_MASK_DISABLE; */
+
+      return insn;
+   }
+}
+
+
+
+struct brw_instruction *brw_WHILE(struct brw_compile *p, 
+                                  struct brw_instruction *do_insn)
+{
+   struct brw_instruction *insn;
+   GLuint br = 1;
+
+   if (BRW_IS_IGDNG(p->brw))
+      br = 2;
+
+   if (p->single_program_flow)
+      insn = next_insn(p, BRW_OPCODE_ADD);
+   else
+      insn = next_insn(p, BRW_OPCODE_WHILE);
+
+   brw_set_dest(insn, brw_ip_reg());
+   brw_set_src0(insn, brw_ip_reg());
+   brw_set_src1(insn, brw_imm_d(0x0));
+
+   insn->header.compression_control = BRW_COMPRESSION_NONE;
+
+   if (p->single_program_flow) {
+      insn->header.execution_size = BRW_EXECUTE_1;
+
+      insn->bits3.d = (do_insn - insn) * 16;
+   } else {
+      insn->header.execution_size = do_insn->header.execution_size;
+
+      assert(do_insn->header.opcode == BRW_OPCODE_DO);
+      insn->bits3.if_else.jump_count = br * (do_insn - insn + 1);
+      insn->bits3.if_else.pop_count = 0;
+      insn->bits3.if_else.pad0 = 0;
+   }
+
+/*    insn->header.mask_control = BRW_MASK_ENABLE; */
+
+   /* insn->header.mask_control = BRW_MASK_DISABLE; */
+   p->current->header.predicate_control = BRW_PREDICATE_NONE;   
+   return insn;
+}
+
+
+/* FORWARD JUMPS:
+ */
+void brw_land_fwd_jump(struct brw_compile *p, 
+                      struct brw_instruction *jmp_insn)
+{
+   struct brw_instruction *landing = &p->store[p->nr_insn];
+   GLuint jmpi = 1;
+
+   if (BRW_IS_IGDNG(p->brw))
+       jmpi = 2;
+
+   assert(jmp_insn->header.opcode == BRW_OPCODE_JMPI);
+   assert(jmp_insn->bits1.da1.src1_reg_file == BRW_IMMEDIATE_VALUE);
+
+   jmp_insn->bits3.ud = jmpi * ((landing - jmp_insn) - 1);
+}
+
+
+
+/* To integrate with the above, it makes sense that the comparison
+ * instruction should populate the flag register.  It might be simpler
+ * just to use the flag reg for most WM tasks?
+ */
+void brw_CMP(struct brw_compile *p,
+            struct brw_reg dest,
+            GLuint conditional,
+            struct brw_reg src0,
+            struct brw_reg src1)
+{
+   struct brw_instruction *insn = next_insn(p, BRW_OPCODE_CMP);
+
+   insn->header.destreg__conditionalmod = conditional;
+   brw_set_dest(insn, dest);
+   brw_set_src0(insn, src0);
+   brw_set_src1(insn, src1);
+
+/*    guess_execution_size(insn, src0); */
+
+
+   /* Make it so that future instructions will use the computed flag
+    * value until brw_set_predicate_control_flag_value() is called
+    * again.  
+    */
+   if (dest.file == BRW_ARCHITECTURE_REGISTER_FILE &&
+       dest.nr == 0) {
+      p->current->header.predicate_control = BRW_PREDICATE_NORMAL;
+      p->flag_value = 0xff;
+   }
+}
+
+
+
+/***********************************************************************
+ * Helpers for the various SEND message types:
+ */
+
+/** Extended math function, float[8].
+ */
+void brw_math( struct brw_compile *p,
+              struct brw_reg dest,
+              GLuint function,
+              GLuint saturate,
+              GLuint msg_reg_nr,
+              struct brw_reg src,
+              GLuint data_type,
+              GLuint precision )
+{
+   struct brw_instruction *insn = next_insn(p, BRW_OPCODE_SEND);
+   GLuint msg_length = (function == BRW_MATH_FUNCTION_POW) ? 2 : 1; 
+   GLuint response_length = (function == BRW_MATH_FUNCTION_SINCOS) ? 2 : 1; 
+
+   /* Example code doesn't set predicate_control for send
+    * instructions.
+    */
+   insn->header.predicate_control = 0; 
+   insn->header.destreg__conditionalmod = msg_reg_nr;
+
+   brw_set_dest(insn, dest);
+   brw_set_src0(insn, src);
+   brw_set_math_message(p->brw,
+                       insn, 
+                       msg_length, response_length, 
+                       function,
+                       BRW_MATH_INTEGER_UNSIGNED,
+                       precision,
+                       saturate,
+                       data_type);
+}
+
+/**
+ * Extended math function, float[16].
+ * Use 2 send instructions.
+ */
+void brw_math_16( struct brw_compile *p,
+                 struct brw_reg dest,
+                 GLuint function,
+                 GLuint saturate,
+                 GLuint msg_reg_nr,
+                 struct brw_reg src,
+                 GLuint precision )
+{
+   struct brw_instruction *insn;
+   GLuint msg_length = (function == BRW_MATH_FUNCTION_POW) ? 2 : 1; 
+   GLuint response_length = (function == BRW_MATH_FUNCTION_SINCOS) ? 2 : 1; 
+
+   /* First instruction:
+    */
+   brw_push_insn_state(p);
+   brw_set_predicate_control_flag_value(p, 0xff);
+   brw_set_compression_control(p, BRW_COMPRESSION_NONE);
+
+   insn = next_insn(p, BRW_OPCODE_SEND);
+   insn->header.destreg__conditionalmod = msg_reg_nr;
+
+   brw_set_dest(insn, dest);
+   brw_set_src0(insn, src);
+   brw_set_math_message(p->brw,
+                       insn, 
+                       msg_length, response_length, 
+                       function,
+                       BRW_MATH_INTEGER_UNSIGNED,
+                       precision,
+                       saturate,
+                       BRW_MATH_DATA_VECTOR);
+
+   /* Second instruction:
+    */
+   insn = next_insn(p, BRW_OPCODE_SEND);
+   insn->header.compression_control = BRW_COMPRESSION_2NDHALF;
+   insn->header.destreg__conditionalmod = msg_reg_nr+1;
+
+   brw_set_dest(insn, offset(dest,1));
+   brw_set_src0(insn, src);
+   brw_set_math_message(p->brw, 
+                       insn, 
+                       msg_length, response_length, 
+                       function,
+                       BRW_MATH_INTEGER_UNSIGNED,
+                       precision,
+                       saturate,
+                       BRW_MATH_DATA_VECTOR);
+
+   brw_pop_insn_state(p);
+}
+
+
+/**
+ * Write block of 16 dwords/floats to the data port Render Cache scratch buffer.
+ * Scratch offset should be a multiple of 64.
+ * Used for register spilling.
+ */
+void brw_dp_WRITE_16( struct brw_compile *p,
+                     struct brw_reg src,
+                     GLuint scratch_offset )
+{
+   GLuint msg_reg_nr = 1;
+   {
+      brw_push_insn_state(p);
+      brw_set_mask_control(p, BRW_MASK_DISABLE);
+      brw_set_compression_control(p, BRW_COMPRESSION_NONE);
+
+      /* set message header global offset field (reg 0, element 2) */
+      brw_MOV(p,
+             retype(brw_vec1_grf(0, 2), BRW_REGISTER_TYPE_D),
+             brw_imm_d(scratch_offset));
+
+      brw_pop_insn_state(p);
+   }
+
+   {
+      GLuint msg_length = 3;
+      struct brw_reg dest = retype(brw_null_reg(), BRW_REGISTER_TYPE_UW);
+      struct brw_instruction *insn = next_insn(p, BRW_OPCODE_SEND);
+   
+      insn->header.predicate_control = 0; /* XXX */
+      insn->header.compression_control = BRW_COMPRESSION_NONE; 
+      insn->header.destreg__conditionalmod = msg_reg_nr;
+  
+      brw_set_dest(insn, dest);
+      brw_set_src0(insn, src);
+
+      brw_set_dp_write_message(p->brw,
+                              insn,
+                              255, /* binding table index (255=stateless) */
+                              BRW_DATAPORT_OWORD_BLOCK_4_OWORDS, /* msg_control */
+                              BRW_DATAPORT_WRITE_MESSAGE_OWORD_BLOCK_WRITE, /* msg_type */
+                              msg_length,
+                              0, /* pixel scoreboard */
+                              0, /* response_length */
+                              0); /* eot */
+   }
+}
+
+
+/**
+ * Read block of 16 dwords/floats from the data port Render Cache scratch buffer.
+ * Scratch offset should be a multiple of 64.
+ * Used for register spilling.
+ */
+void brw_dp_READ_16( struct brw_compile *p,
+                     struct brw_reg dest,
+                     GLuint scratch_offset )
+{
+   GLuint msg_reg_nr = 1;
+   {
+      brw_push_insn_state(p);
+      brw_set_compression_control(p, BRW_COMPRESSION_NONE);
+      brw_set_mask_control(p, BRW_MASK_DISABLE);
+
+      /* set message header global offset field (reg 0, element 2) */
+      brw_MOV(p,
+             retype(brw_vec1_grf(0, 2), BRW_REGISTER_TYPE_D),
+             brw_imm_d(scratch_offset));
+
+      brw_pop_insn_state(p);
+   }
+
+   {
+      struct brw_instruction *insn = next_insn(p, BRW_OPCODE_SEND);
+   
+      insn->header.predicate_control = 0; /* XXX */
+      insn->header.compression_control = BRW_COMPRESSION_NONE; 
+      insn->header.destreg__conditionalmod = msg_reg_nr;
+  
+      brw_set_dest(insn, dest);        /* UW? */
+      brw_set_src0(insn, retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UW));
+
+      brw_set_dp_read_message(p->brw,
+                             insn,
+                             255, /* binding table index (255=stateless) */
+                             3,  /* msg_control (3 means 4 Owords) */
+                             BRW_DATAPORT_READ_MESSAGE_OWORD_BLOCK_READ, /* msg_type */
+                             1, /* target cache (render/scratch) */
+                             1, /* msg_length */
+                             2, /* response_length */
+                             0); /* eot */
+   }
+}
+
+
+/**
+ * Read a float[4] vector from the data port Data Cache (const buffer).
+ * Location (in buffer) should be a multiple of 16.
+ * Used for fetching shader constants.
+ * If relAddr is true, we'll do an indirect fetch using the address register.
+ */
+void brw_dp_READ_4( struct brw_compile *p,
+                    struct brw_reg dest,
+                    GLboolean relAddr,
+                    GLuint location,
+                    GLuint bind_table_index )
+{
+   /* XXX: relAddr not implemented */
+   GLuint msg_reg_nr = 1;
+   {
+      struct brw_reg b;
+      brw_push_insn_state(p);
+      brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+      brw_set_compression_control(p, BRW_COMPRESSION_NONE);
+      brw_set_mask_control(p, BRW_MASK_DISABLE);
+
+   /* Setup MRF[1] with location/offset into const buffer */
+      b = brw_message_reg(msg_reg_nr);
+      b = retype(b, BRW_REGISTER_TYPE_UD);
+      /* XXX I think we're setting all the dwords of MRF[1] to 'location'.
+       * when the docs say only dword[2] should be set.  Hmmm.  But it works.
+       */
+      brw_MOV(p, b, brw_imm_ud(location));
+      brw_pop_insn_state(p);
+   }
+
+   {
+      struct brw_instruction *insn = next_insn(p, BRW_OPCODE_SEND);
+   
+      insn->header.predicate_control = BRW_PREDICATE_NONE;
+      insn->header.compression_control = BRW_COMPRESSION_NONE; 
+      insn->header.destreg__conditionalmod = msg_reg_nr;
+      insn->header.mask_control = BRW_MASK_DISABLE;
+  
+      /* cast dest to a uword[8] vector */
+      dest = retype(vec8(dest), BRW_REGISTER_TYPE_UW);
+
+      brw_set_dest(insn, dest);
+      brw_set_src0(insn, brw_null_reg());
+
+      brw_set_dp_read_message(p->brw,
+                             insn,
+                             bind_table_index,
+                             0,  /* msg_control (0 means 1 Oword) */
+                             BRW_DATAPORT_READ_MESSAGE_OWORD_BLOCK_READ, /* msg_type */
+                             0, /* source cache = data cache */
+                             1, /* msg_length */
+                             1, /* response_length (1 Oword) */
+                             0); /* eot */
+   }
+}
+
+
+/**
+ * Read float[4] constant(s) from VS constant buffer.
+ * For relative addressing, two float[4] constants will be read into 'dest'.
+ * Otherwise, one float[4] constant will be read into the lower half of 'dest'.
+ */
+void brw_dp_READ_4_vs(struct brw_compile *p,
+                      struct brw_reg dest,
+                      GLuint oword,
+                      GLboolean relAddr,
+                      struct brw_reg addrReg,
+                      GLuint location,
+                      GLuint bind_table_index)
+{
+   GLuint msg_reg_nr = 1;
+
+   assert(oword < 2);
+   /*
+   printf("vs const read msg, location %u, msg_reg_nr %d\n",
+          location, msg_reg_nr);
+   */
+
+   /* Setup MRF[1] with location/offset into const buffer */
+   {
+      struct brw_reg b;
+
+      brw_push_insn_state(p);
+      brw_set_compression_control(p, BRW_COMPRESSION_NONE);
+      brw_set_mask_control(p, BRW_MASK_DISABLE);
+      brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+      /*brw_set_access_mode(p, BRW_ALIGN_16);*/
+
+      /* XXX I think we're setting all the dwords of MRF[1] to 'location'.
+       * when the docs say only dword[2] should be set.  Hmmm.  But it works.
+       */
+      b = brw_message_reg(msg_reg_nr);
+      b = retype(b, BRW_REGISTER_TYPE_UD);
+      /*b = get_element_ud(b, 2);*/
+      if (relAddr) {
+         brw_ADD(p, b, addrReg, brw_imm_ud(location));
+      }
+      else {
+         brw_MOV(p, b, brw_imm_ud(location));
+      }
+
+      brw_pop_insn_state(p);
+   }
+
+   {
+      struct brw_instruction *insn = next_insn(p, BRW_OPCODE_SEND);
+   
+      insn->header.predicate_control = BRW_PREDICATE_NONE;
+      insn->header.compression_control = BRW_COMPRESSION_NONE; 
+      insn->header.destreg__conditionalmod = msg_reg_nr;
+      insn->header.mask_control = BRW_MASK_DISABLE;
+      /*insn->header.access_mode = BRW_ALIGN_16;*/
+  
+      brw_set_dest(insn, dest);
+      brw_set_src0(insn, brw_null_reg());
+
+      brw_set_dp_read_message(p->brw,
+                             insn,
+                             bind_table_index,
+                             oword,  /* 0 = lower Oword, 1 = upper Oword */
+                             BRW_DATAPORT_READ_MESSAGE_OWORD_BLOCK_READ, /* msg_type */
+                             0, /* source cache = data cache */
+                             1, /* msg_length */
+                             1, /* response_length (1 Oword) */
+                             0); /* eot */
+   }
+}
+
+
+
+void brw_fb_WRITE(struct brw_compile *p,
+                  struct brw_reg dest,
+                  GLuint msg_reg_nr,
+                  struct brw_reg src0,
+                  GLuint binding_table_index,
+                  GLuint msg_length,
+                  GLuint response_length,
+                  GLboolean eot)
+{
+   struct brw_instruction *insn = next_insn(p, BRW_OPCODE_SEND);
+   
+   insn->header.predicate_control = 0; /* XXX */
+   insn->header.compression_control = BRW_COMPRESSION_NONE; 
+   insn->header.destreg__conditionalmod = msg_reg_nr;
+  
+   brw_set_dest(insn, dest);
+   brw_set_src0(insn, src0);
+   brw_set_dp_write_message(p->brw,
+                           insn,
+                           binding_table_index,
+                           BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE, /* msg_control */
+                           BRW_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE, /* msg_type */
+                           msg_length,
+                           1,  /* pixel scoreboard */
+                           response_length, 
+                           eot);
+}
+
+
+/**
+ * Texture sample instruction.
+ * Note: the msg_type plus msg_length values determine exactly what kind
+ * of sampling operation is performed.  See volume 4, page 161 of docs.
+ */
+void brw_SAMPLE(struct brw_compile *p,
+               struct brw_reg dest,
+               GLuint msg_reg_nr,
+               struct brw_reg src0,
+               GLuint binding_table_index,
+               GLuint sampler,
+               GLuint writemask,
+               GLuint msg_type,
+               GLuint response_length,
+               GLuint msg_length,
+               GLboolean eot,
+               GLuint header_present,
+               GLuint simd_mode)
+{
+   GLboolean need_stall = 0;
+   
+   if (writemask == 0) {
+      /*debug_printf("%s: zero writemask??\n", __FUNCTION__); */
+      return;
+   }
+   
+   /* Hardware doesn't do destination dependency checking on send
+    * instructions properly.  Add a workaround which generates the
+    * dependency by other means.  In practice it seems like this bug
+    * only crops up for texture samples, and only where registers are
+    * written by the send and then written again later without being
+    * read in between.  Luckily for us, we already track that
+    * information and use it to modify the writemask for the
+    * instruction, so that is a guide for whether a workaround is
+    * needed.
+    */
+   if (writemask != BRW_WRITEMASK_XYZW) {
+      GLuint dst_offset = 0;
+      GLuint i, newmask = 0, len = 0;
+
+      for (i = 0; i < 4; i++) {
+        if (writemask & (1<<i))
+           break;
+        dst_offset += 2;
+      }
+      for (; i < 4; i++) {
+        if (!(writemask & (1<<i)))
+           break;
+        newmask |= 1<<i;
+        len++;
+      }
+
+      if (newmask != writemask) {
+        need_stall = 1;
+         /* debug_printf("need stall %x %x\n", newmask , writemask); */
+      }
+      else {
+        struct brw_reg m1 = brw_message_reg(msg_reg_nr);
+        
+        newmask = ~newmask & BRW_WRITEMASK_XYZW;
+
+        brw_push_insn_state(p);
+
+        brw_set_compression_control(p, BRW_COMPRESSION_NONE);
+        brw_set_mask_control(p, BRW_MASK_DISABLE);
+
+        brw_MOV(p, m1, brw_vec8_grf(0,0));      
+        brw_MOV(p, get_element_ud(m1, 2), brw_imm_ud(newmask << 12)); 
+
+        brw_pop_insn_state(p);
+
+        src0 = retype(brw_null_reg(), BRW_REGISTER_TYPE_UW); 
+        dest = offset(dest, dst_offset);
+        response_length = len * 2;
+      }
+   }
+
+   {
+      struct brw_instruction *insn = next_insn(p, BRW_OPCODE_SEND);
+   
+      insn->header.predicate_control = 0; /* XXX */
+      insn->header.compression_control = BRW_COMPRESSION_NONE;
+      insn->header.destreg__conditionalmod = msg_reg_nr;
+
+      brw_set_dest(insn, dest);
+      brw_set_src0(insn, src0);
+      brw_set_sampler_message(p->brw, insn,
+                             binding_table_index,
+                             sampler,
+                             msg_type,
+                             response_length, 
+                             msg_length,
+                             eot,
+                             header_present,
+                             simd_mode);
+   }
+
+   if (need_stall) {
+      struct brw_reg reg = vec8(offset(dest, response_length-1));
+
+      /*  mov (8) r9.0<1>:f    r9.0<8;8,1>:f    { Align1 }
+       */
+      brw_push_insn_state(p);
+      brw_set_compression_control(p, BRW_COMPRESSION_NONE);
+      brw_MOV(p, reg, reg);          
+      brw_pop_insn_state(p);
+   }
+
+}
+
+/* All these variables are pretty confusing - we might be better off
+ * using bitmasks and macros for this, in the old style.  Or perhaps
+ * just having the caller instantiate the fields in dword3 itself.
+ */
+void brw_urb_WRITE(struct brw_compile *p,
+                  struct brw_reg dest,
+                  GLuint msg_reg_nr,
+                  struct brw_reg src0,
+                  GLboolean allocate,
+                  GLboolean used,
+                  GLuint msg_length,
+                  GLuint response_length,
+                  GLboolean eot,
+                  GLboolean writes_complete,
+                  GLuint offset,
+                  GLuint swizzle)
+{
+   struct brw_instruction *insn = next_insn(p, BRW_OPCODE_SEND);
+
+   assert(msg_length < BRW_MAX_MRF);
+
+   brw_set_dest(insn, dest);
+   brw_set_src0(insn, src0);
+   brw_set_src1(insn, brw_imm_d(0));
+
+   insn->header.destreg__conditionalmod = msg_reg_nr;
+
+   brw_set_urb_message(p->brw,
+                      insn,
+                      allocate,
+                      used,
+                      msg_length,
+                      response_length, 
+                      eot, 
+                      writes_complete, 
+                      offset,
+                      swizzle);
+}
+
+void brw_ff_sync(struct brw_compile *p,
+                  struct brw_reg dest,
+                  GLuint msg_reg_nr,
+                  struct brw_reg src0,
+                  GLboolean allocate,
+                  GLboolean used,
+                  GLuint msg_length,
+                  GLuint response_length,
+                  GLboolean eot,
+                  GLboolean writes_complete,
+                  GLuint offset,
+                  GLuint swizzle)
+{
+   struct brw_instruction *insn = next_insn(p, BRW_OPCODE_SEND);
+
+   assert(msg_length < 16);
+
+   brw_set_dest(insn, dest);
+   brw_set_src0(insn, src0);
+   brw_set_src1(insn, brw_imm_d(0));
+
+   insn->header.destreg__conditionalmod = msg_reg_nr;
+
+   brw_set_ff_sync_message(p->brw,
+                      insn,
+                      allocate,
+                      used,
+                      msg_length,
+                      response_length, 
+                      eot, 
+                      writes_complete, 
+                      offset,
+                      swizzle);
+}
diff --git a/src/gallium/drivers/i965/brw_eu_util.c b/src/gallium/drivers/i965/brw_eu_util.c
new file mode 100644 (file)
index 0000000..5405cf1
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ Copyright (C) Intel Corp.  2006.  All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ **********************************************************************/
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  */
+      
+
+#include "brw_context.h"
+#include "brw_defines.h"
+#include "brw_eu.h"
+
+
+void brw_math_invert( struct brw_compile *p, 
+                            struct brw_reg dst,
+                            struct brw_reg src)
+{
+   brw_math( p, 
+            dst,
+            BRW_MATH_FUNCTION_INV, 
+            BRW_MATH_SATURATE_NONE,
+            0,
+            src,
+            BRW_MATH_PRECISION_FULL, 
+            BRW_MATH_DATA_VECTOR );
+}
+
+
+
+void brw_copy4(struct brw_compile *p,
+              struct brw_reg dst,
+              struct brw_reg src,
+              GLuint count)
+{
+   GLuint i;
+
+   dst = vec4(dst);
+   src = vec4(src);
+
+   for (i = 0; i < count; i++)
+   {
+      GLuint delta = i*32;
+      brw_MOV(p, byte_offset(dst, delta),    byte_offset(src, delta));
+      brw_MOV(p, byte_offset(dst, delta+16), byte_offset(src, delta+16));
+   }
+}
+
+
+void brw_copy8(struct brw_compile *p,
+              struct brw_reg dst,
+              struct brw_reg src,
+              GLuint count)
+{
+   GLuint i;
+
+   dst = vec8(dst);
+   src = vec8(src);
+
+   for (i = 0; i < count; i++)
+   {
+      GLuint delta = i*32;
+      brw_MOV(p, byte_offset(dst, delta),    byte_offset(src, delta));
+   }
+}
+
+
+void brw_copy_indirect_to_indirect(struct brw_compile *p,
+                                  struct brw_indirect dst_ptr,
+                                  struct brw_indirect src_ptr,
+                                  GLuint count)
+{
+   GLuint i;
+
+   for (i = 0; i < count; i++)
+   {
+      GLuint delta = i*32;
+      brw_MOV(p, deref_4f(dst_ptr, delta),    deref_4f(src_ptr, delta));
+      brw_MOV(p, deref_4f(dst_ptr, delta+16), deref_4f(src_ptr, delta+16));
+   }
+}
+
+
+void brw_copy_from_indirect(struct brw_compile *p,
+                           struct brw_reg dst,
+                           struct brw_indirect ptr,
+                           GLuint count)
+{
+   GLuint i;
+
+   dst = vec4(dst);
+
+   for (i = 0; i < count; i++)
+   {
+      GLuint delta = i*32;
+      brw_MOV(p, byte_offset(dst, delta),    deref_4f(ptr, delta));
+      brw_MOV(p, byte_offset(dst, delta+16), deref_4f(ptr, delta+16));
+   }
+}
+
+
+
+
diff --git a/src/gallium/drivers/i965/brw_gs.c b/src/gallium/drivers/i965/brw_gs.c
new file mode 100644 (file)
index 0000000..921b201
--- /dev/null
@@ -0,0 +1,216 @@
+/*
+ Copyright (C) Intel Corp.  2006.  All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ **********************************************************************/
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  */
+      
+#include "brw_batchbuffer.h"
+
+#include "brw_defines.h"
+#include "brw_context.h"
+#include "brw_eu.h"
+#include "brw_util.h"
+#include "brw_state.h"
+#include "brw_gs.h"
+
+
+
+static enum pipe_error compile_gs_prog( struct brw_context *brw,
+                                        struct brw_gs_prog_key *key,
+                                        struct brw_winsys_buffer **bo_out )
+{
+   struct brw_gs_compile c;
+   enum pipe_error ret;
+   const GLuint *program;
+   GLuint program_size;
+
+   memset(&c, 0, sizeof(c));
+   
+   c.key = *key;
+   c.need_ff_sync = BRW_IS_IGDNG(brw);
+   /* Need to locate the two positions present in vertex + header.
+    * These are currently hardcoded:
+    */
+   c.nr_attrs = c.key.nr_attrs;
+
+   if (BRW_IS_IGDNG(brw))
+      c.nr_regs = (c.nr_attrs + 1) / 2 + 3;  /* are vertices packed, or reg-aligned? */
+   else
+      c.nr_regs = (c.nr_attrs + 1) / 2 + 1;  /* are vertices packed, or reg-aligned? */
+
+   c.nr_bytes = c.nr_regs * REG_SIZE;
+
+   
+   /* Begin the compilation:
+    */
+   brw_init_compile(brw, &c.func);
+
+   c.func.single_program_flow = 1;
+
+   /* For some reason the thread is spawned with only 4 channels
+    * unmasked.  
+    */
+   brw_set_mask_control(&c.func, BRW_MASK_DISABLE);
+
+
+   /* Note that primitives which don't require a GS program have
+    * already been weeded out by this stage:
+    */
+   switch (key->primitive) {
+   case PIPE_PRIM_QUADS:
+      brw_gs_quads( &c ); 
+      break;
+   case PIPE_PRIM_QUAD_STRIP:
+      brw_gs_quad_strip( &c );
+      break;
+   case PIPE_PRIM_LINE_LOOP:
+      brw_gs_lines( &c );
+      break;
+   case PIPE_PRIM_LINES:
+      if (key->hint_gs_always)
+        brw_gs_lines( &c );
+      else {
+        return PIPE_OK;
+      }
+      break;
+   case PIPE_PRIM_TRIANGLES:
+      if (key->hint_gs_always)
+        brw_gs_tris( &c );
+      else {
+        return PIPE_OK;
+      }
+      break;
+   case PIPE_PRIM_POINTS:
+      if (key->hint_gs_always)
+        brw_gs_points( &c );
+      else {
+        return PIPE_OK;
+      }
+      break;
+   default:
+      assert(0);
+      return PIPE_ERROR_BAD_INPUT;
+   }
+
+   /* get the program
+    */
+   ret = brw_get_program(&c.func, &program, &program_size);
+   if (ret)
+      return ret;
+
+   /* Upload
+    */
+   ret = brw_upload_cache( &brw->cache, BRW_GS_PROG,
+                           &c.key, sizeof(c.key),
+                           NULL, 0,
+                           program, program_size,
+                           &c.prog_data,
+                           &brw->gs.prog_data,
+                           bo_out );
+   if (ret)
+      return ret;
+
+   return PIPE_OK;
+}
+
+static const unsigned gs_prim[PIPE_PRIM_MAX] = {  
+   PIPE_PRIM_POINTS,
+   PIPE_PRIM_LINES,
+   PIPE_PRIM_LINE_LOOP,
+   PIPE_PRIM_LINES,
+   PIPE_PRIM_TRIANGLES,
+   PIPE_PRIM_TRIANGLES,
+   PIPE_PRIM_TRIANGLES,
+   PIPE_PRIM_QUADS,
+   PIPE_PRIM_QUAD_STRIP,
+   PIPE_PRIM_TRIANGLES
+};
+
+static void populate_key( struct brw_context *brw,
+                         struct brw_gs_prog_key *key )
+{
+   const struct brw_fs_signature *sig = &brw->curr.fragment_shader->signature;
+
+   memset(key, 0, sizeof(*key));
+
+   /* PIPE_NEW_FRAGMENT_SIGNATURE */
+   key->nr_attrs = sig->nr_inputs + 1;
+
+   /* BRW_NEW_PRIMITIVE */
+   key->primitive = gs_prim[brw->primitive];
+
+   key->hint_gs_always = 0;    /* debug code? */
+
+   key->need_gs_prog = (key->hint_gs_always ||
+                       brw->primitive == PIPE_PRIM_QUADS ||
+                       brw->primitive == PIPE_PRIM_QUAD_STRIP ||
+                       brw->primitive == PIPE_PRIM_LINE_LOOP);
+}
+
+/* Calculate interpolants for triangle and line rasterization.
+ */
+static int prepare_gs_prog(struct brw_context *brw)
+{
+   struct brw_gs_prog_key key;
+   enum pipe_error ret;
+
+   /* Populate the key:
+    */
+   populate_key(brw, &key);
+
+   if (brw->gs.prog_active != key.need_gs_prog) {
+      brw->state.dirty.cache |= CACHE_NEW_GS_PROG;
+      brw->gs.prog_active = key.need_gs_prog;
+   }
+
+   if (!brw->gs.prog_active)
+      return PIPE_OK;
+
+   if (brw_search_cache(&brw->cache, BRW_GS_PROG,
+                        &key, sizeof(key),
+                        NULL, 0,
+                        &brw->gs.prog_data,
+                        &brw->gs.prog_bo))
+      return PIPE_OK;
+
+   ret = compile_gs_prog( brw, &key, &brw->gs.prog_bo );
+   if (ret)
+      return ret;
+
+   return PIPE_OK;
+}
+
+
+const struct brw_tracked_state brw_gs_prog = {
+   .dirty = {
+      .mesa  = PIPE_NEW_FRAGMENT_SIGNATURE,
+      .brw   = BRW_NEW_PRIMITIVE,
+      .cache = 0,
+   },
+   .prepare = prepare_gs_prog
+};
diff --git a/src/gallium/drivers/i965/brw_gs.h b/src/gallium/drivers/i965/brw_gs.h
new file mode 100644 (file)
index 0000000..6e616dc
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ Copyright (C) Intel Corp.  2006.  All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ **********************************************************************/
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  */
+
+#ifndef BRW_GS_H
+#define BRW_GS_H
+
+
+#include "brw_context.h"
+#include "brw_eu.h"
+
+#define MAX_GS_VERTS (4)            
+
+struct brw_gs_prog_key {
+   GLuint nr_attrs:8;
+   GLuint primitive:4;
+   GLuint hint_gs_always:1;
+   GLuint need_gs_prog:1;
+   GLuint pad:18;
+};
+
+struct brw_gs_compile {
+   struct brw_compile func;
+   struct brw_gs_prog_key key;
+   struct brw_gs_prog_data prog_data;
+   
+   struct {
+      struct brw_reg R0;
+      struct brw_reg vertex[MAX_GS_VERTS];
+   } reg;
+
+   /* 3 different ways of expressing vertex size:
+    */
+   GLuint nr_attrs;
+   GLuint nr_regs;
+   GLuint nr_bytes;
+   GLboolean need_ff_sync;
+};
+
+#define ATTR_SIZE  (4*4)
+
+void brw_gs_quads( struct brw_gs_compile *c );
+void brw_gs_quad_strip( struct brw_gs_compile *c );
+void brw_gs_tris( struct brw_gs_compile *c );
+void brw_gs_lines( struct brw_gs_compile *c );
+void brw_gs_points( struct brw_gs_compile *c );
+
+#endif
diff --git a/src/gallium/drivers/i965/brw_gs_emit.c b/src/gallium/drivers/i965/brw_gs_emit.c
new file mode 100644 (file)
index 0000000..fd8e2ac
--- /dev/null
@@ -0,0 +1,181 @@
+/*
+ Copyright (C) Intel Corp.  2006.  All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ **********************************************************************/
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  */
+
+#include "brw_batchbuffer.h"
+
+#include "brw_defines.h"
+#include "brw_context.h"
+#include "brw_eu.h"
+#include "brw_util.h"
+#include "brw_gs.h"
+
+static void brw_gs_alloc_regs( struct brw_gs_compile *c,
+                              GLuint nr_verts )
+{
+   GLuint i = 0,j;
+
+   /* Register usage is static, precompute here:
+    */
+   c->reg.R0 = retype(brw_vec8_grf(i, 0), BRW_REGISTER_TYPE_UD); i++;
+
+   /* Payload vertices plus space for more generated vertices:
+    */
+   for (j = 0; j < nr_verts; j++) {
+      c->reg.vertex[j] = brw_vec4_grf(i, 0);
+      i += c->nr_regs;
+   }
+
+   c->prog_data.urb_read_length = c->nr_regs; 
+   c->prog_data.total_grf = i;
+}
+
+
+static void brw_gs_emit_vue(struct brw_gs_compile *c, 
+                           struct brw_reg vert,
+                           GLboolean last,
+                           GLuint header)
+{
+   struct brw_compile *p = &c->func;
+   GLboolean allocate = !last;
+
+   /* Overwrite PrimType and PrimStart in the message header, for
+    * each vertex in turn:
+    */
+   brw_MOV(p, get_element_ud(c->reg.R0, 2), brw_imm_ud(header));
+
+   /* Copy the vertex from vertn into m1..mN+1:
+    */
+   brw_copy8(p, brw_message_reg(1), vert, c->nr_regs);
+
+   /* Send each vertex as a seperate write to the urb.  This is
+    * different to the concept in brw_sf_emit.c, where subsequent
+    * writes are used to build up a single urb entry.  Each of these
+    * writes instantiates a seperate urb entry, and a new one must be
+    * allocated each time.
+    */
+   brw_urb_WRITE(p, 
+                allocate ? c->reg.R0 : retype(brw_null_reg(), BRW_REGISTER_TYPE_UD),
+                0,
+                c->reg.R0,
+                allocate,
+                1,             /* used */
+                c->nr_regs + 1, /* msg length */
+                allocate ? 1 : 0, /* response length */
+                allocate ? 0 : 1, /* eot */
+                1,             /* writes_complete */
+                0,             /* urb offset */
+                BRW_URB_SWIZZLE_NONE);
+}
+
+static void brw_gs_ff_sync(struct brw_gs_compile *c, int num_prim)
+{
+       struct brw_compile *p = &c->func;
+       brw_MOV(p, get_element_ud(c->reg.R0, 1), brw_imm_ud(num_prim));
+       brw_ff_sync(p, 
+                               c->reg.R0,
+                               0,
+                               c->reg.R0,
+                               1,      
+                               1,              /* used */
+                               1,      /* msg length */
+                               1,              /* response length */
+                               0,              /* eot */
+                               1,              /* write compelete */
+                               0,              /* urb offset */
+                               BRW_URB_SWIZZLE_NONE);
+}
+
+
+void brw_gs_quads( struct brw_gs_compile *c )
+{
+   brw_gs_alloc_regs(c, 4);
+   
+   /* Use polygons for correct edgeflag behaviour. Note that vertex 3
+    * is the PV for quads, but vertex 0 for polygons:
+    */
+   if (c->need_ff_sync)
+          brw_gs_ff_sync(c, 1);    
+   brw_gs_emit_vue(c, c->reg.vertex[3], 0, ((_3DPRIM_POLYGON << 2) | R02_PRIM_START));
+   brw_gs_emit_vue(c, c->reg.vertex[0], 0, (_3DPRIM_POLYGON << 2));
+   brw_gs_emit_vue(c, c->reg.vertex[1], 0, (_3DPRIM_POLYGON << 2)); 
+   brw_gs_emit_vue(c, c->reg.vertex[2], 1, ((_3DPRIM_POLYGON << 2) | R02_PRIM_END));
+}
+
+void brw_gs_quad_strip( struct brw_gs_compile *c )
+{
+   brw_gs_alloc_regs(c, 4);
+   
+   if (c->need_ff_sync)
+          brw_gs_ff_sync(c, 1);      
+   brw_gs_emit_vue(c, c->reg.vertex[2], 0, ((_3DPRIM_POLYGON << 2) | R02_PRIM_START));
+   brw_gs_emit_vue(c, c->reg.vertex[3], 0, (_3DPRIM_POLYGON << 2));
+   brw_gs_emit_vue(c, c->reg.vertex[0], 0, (_3DPRIM_POLYGON << 2)); 
+   brw_gs_emit_vue(c, c->reg.vertex[1], 1, ((_3DPRIM_POLYGON << 2) | R02_PRIM_END));
+}
+
+void brw_gs_tris( struct brw_gs_compile *c )
+{
+   brw_gs_alloc_regs(c, 3);
+
+   if (c->need_ff_sync)
+          brw_gs_ff_sync(c, 1);      
+   brw_gs_emit_vue(c, c->reg.vertex[0], 0, ((_3DPRIM_TRILIST << 2) | R02_PRIM_START));
+   brw_gs_emit_vue(c, c->reg.vertex[1], 0, (_3DPRIM_TRILIST << 2));
+   brw_gs_emit_vue(c, c->reg.vertex[2], 1, ((_3DPRIM_TRILIST << 2) | R02_PRIM_END));
+}
+
+void brw_gs_lines( struct brw_gs_compile *c )
+{
+   brw_gs_alloc_regs(c, 2);
+
+   if (c->need_ff_sync)
+          brw_gs_ff_sync(c, 1);      
+   brw_gs_emit_vue(c, c->reg.vertex[0], 0, ((_3DPRIM_LINESTRIP << 2) | R02_PRIM_START));
+   brw_gs_emit_vue(c, c->reg.vertex[1], 1, ((_3DPRIM_LINESTRIP << 2) | R02_PRIM_END));
+}
+
+void brw_gs_points( struct brw_gs_compile *c )
+{
+   brw_gs_alloc_regs(c, 1);
+
+   if (c->need_ff_sync)
+          brw_gs_ff_sync(c, 1);      
+   brw_gs_emit_vue(c, c->reg.vertex[0], 1, ((_3DPRIM_POINTLIST << 2) | R02_PRIM_START | R02_PRIM_END));
+}
+
+
+
+
+
+
+
+
diff --git a/src/gallium/drivers/i965/brw_gs_state.c b/src/gallium/drivers/i965/brw_gs_state.c
new file mode 100644 (file)
index 0000000..b64ec28
--- /dev/null
@@ -0,0 +1,169 @@
+/*
+ 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 "util/u_math.h"
+
+#include "brw_context.h"
+#include "brw_state.h"
+#include "brw_defines.h"
+#include "brw_debug.h"
+
+struct brw_gs_unit_key {
+   unsigned int total_grf;
+   unsigned int urb_entry_read_length;
+
+   unsigned int curbe_offset;
+
+   unsigned int nr_urb_entries, urb_size;
+   GLboolean prog_active;
+};
+
+static void
+gs_unit_populate_key(struct brw_context *brw, struct brw_gs_unit_key *key)
+{
+   memset(key, 0, sizeof(*key));
+
+   /* CACHE_NEW_GS_PROG */
+   key->prog_active = brw->gs.prog_active;
+   if (key->prog_active) {
+      key->total_grf = brw->gs.prog_data->total_grf;
+      key->urb_entry_read_length = brw->gs.prog_data->urb_read_length;
+   } else {
+      key->total_grf = 1;
+      key->urb_entry_read_length = 1;
+   }
+
+   /* BRW_NEW_CURBE_OFFSETS */
+   key->curbe_offset = brw->curbe.clip_start;
+
+   /* BRW_NEW_URB_FENCE */
+   key->nr_urb_entries = brw->urb.nr_gs_entries;
+   key->urb_size = brw->urb.vsize;
+}
+
+static enum pipe_error
+gs_unit_create_from_key(struct brw_context *brw, 
+                        struct brw_gs_unit_key *key,
+                        struct brw_winsys_reloc *reloc,
+                        unsigned nr_reloc,
+                        struct brw_winsys_buffer **bo_out)
+{
+   struct brw_gs_unit_state gs;
+   enum pipe_error ret;
+
+
+   memset(&gs, 0, sizeof(gs));
+
+   /* reloc */
+   gs.thread0.grf_reg_count = align(key->total_grf, 16) / 16 - 1;
+   gs.thread0.kernel_start_pointer = 0;
+
+   gs.thread1.floating_point_mode = BRW_FLOATING_POINT_NON_IEEE_754;
+   gs.thread1.single_program_flow = 1;
+
+   gs.thread3.dispatch_grf_start_reg = 1;
+   gs.thread3.const_urb_entry_read_offset = 0;
+   gs.thread3.const_urb_entry_read_length = 0;
+   gs.thread3.urb_entry_read_offset = 0;
+   gs.thread3.urb_entry_read_length = key->urb_entry_read_length;
+
+   gs.thread4.nr_urb_entries = key->nr_urb_entries;
+   gs.thread4.urb_entry_allocation_size = key->urb_size - 1;
+
+   if (key->nr_urb_entries >= 8)
+      gs.thread4.max_threads = 1;
+   else
+      gs.thread4.max_threads = 0;
+
+   if (BRW_IS_IGDNG(brw))
+      gs.thread4.rendering_enable = 1;
+
+   if (BRW_DEBUG & DEBUG_STATS)
+      gs.thread4.stats_enable = 1;
+
+   ret = brw_upload_cache(&brw->cache, BRW_GS_UNIT,
+                          key, sizeof(*key),
+                          reloc, nr_reloc,
+                          &gs, sizeof(gs),
+                          NULL, NULL,
+                          bo_out);
+   if (ret)
+      return ret;
+
+   return PIPE_OK;
+}
+
+static enum pipe_error prepare_gs_unit(struct brw_context *brw)
+{
+   struct brw_gs_unit_key key;
+   enum pipe_error ret;
+   struct brw_winsys_reloc reloc[1];
+   unsigned nr_reloc = 0;
+   unsigned grf_reg_count;
+
+   gs_unit_populate_key(brw, &key);
+
+   grf_reg_count = (align(key.total_grf, 16) / 16 - 1);
+
+   /* GS program relocation */
+   if (key.prog_active) {
+      make_reloc(&reloc[nr_reloc++],
+                 BRW_USAGE_STATE,
+                 grf_reg_count << 1,
+                 offsetof(struct brw_gs_unit_state, thread0),
+                 brw->gs.prog_bo);
+   }
+
+   if (brw_search_cache(&brw->cache, BRW_GS_UNIT,
+                        &key, sizeof(key),
+                        reloc, nr_reloc,
+                        NULL,
+                        &brw->gs.state_bo))
+      return PIPE_OK;
+
+   ret = gs_unit_create_from_key(brw, &key,
+                                 reloc, nr_reloc,
+                                 &brw->gs.state_bo);
+   if (ret)
+      return ret;
+
+   return PIPE_OK;
+}
+
+const struct brw_tracked_state brw_gs_unit = {
+   .dirty = {
+      .mesa  = 0,
+      .brw   = (BRW_NEW_CURBE_OFFSETS |
+               BRW_NEW_URB_FENCE),
+      .cache = CACHE_NEW_GS_PROG
+   },
+   .prepare = prepare_gs_unit,
+};
diff --git a/src/gallium/drivers/i965/brw_misc_state.c b/src/gallium/drivers/i965/brw_misc_state.c
new file mode 100644 (file)
index 0000000..e4b2422
--- /dev/null
@@ -0,0 +1,513 @@
+/*
+ Copyright (C) Intel Corp.  2006.  All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ **********************************************************************/
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  */
+
+
+#include "brw_debug.h"
+#include "brw_batchbuffer.h"
+#include "brw_context.h"
+#include "brw_state.h"
+#include "brw_defines.h"
+#include "brw_screen.h"
+#include "brw_pipe_rast.h"
+
+
+
+
+
+/***********************************************************************
+ * Blend color
+ */
+
+static int upload_blend_constant_color(struct brw_context *brw)
+{
+   BRW_CACHED_BATCH_STRUCT(brw, &brw->curr.bcc);
+   return 0;
+}
+
+
+const struct brw_tracked_state brw_blend_constant_color = {
+   .dirty = {
+      .mesa = PIPE_NEW_BLEND_COLOR,
+      .brw = 0,
+      .cache = 0
+   },
+   .emit = upload_blend_constant_color
+};
+
+/***********************************************************************
+ * Drawing rectangle - framebuffer dimensions
+ */
+static int upload_drawing_rect(struct brw_context *brw)
+{
+   BEGIN_BATCH(4, NO_LOOP_CLIPRECTS);
+   OUT_BATCH(_3DSTATE_DRAWRECT_INFO_I965);
+   OUT_BATCH(0);
+   OUT_BATCH(((brw->curr.fb.width - 1) & 0xffff) |
+           ((brw->curr.fb.height - 1) << 16));
+   OUT_BATCH(0);
+   ADVANCE_BATCH();
+   return 0;
+}
+
+const struct brw_tracked_state brw_drawing_rect = {
+   .dirty = {
+      .mesa = PIPE_NEW_FRAMEBUFFER_DIMENSIONS,
+      .brw = 0,
+      .cache = 0
+   },
+   .emit = upload_drawing_rect
+};
+
+
+/***********************************************************************
+ * Binding table pointers
+ */
+
+static int prepare_binding_table_pointers(struct brw_context *brw)
+{
+   brw_add_validated_bo(brw, brw->vs.bind_bo);
+   brw_add_validated_bo(brw, brw->wm.bind_bo);
+   return 0;
+}
+
+/**
+ * Upload the binding table pointers, which point each stage's array of surface
+ * state pointers.
+ *
+ * The binding table pointers are relative to the surface state base address,
+ * which is 0.
+ */
+static int upload_binding_table_pointers(struct brw_context *brw)
+{
+   BEGIN_BATCH(6, IGNORE_CLIPRECTS);
+   OUT_BATCH(CMD_BINDING_TABLE_PTRS << 16 | (6 - 2));
+   if (brw->vs.bind_bo != NULL)
+      OUT_RELOC(brw->vs.bind_bo, 
+               BRW_USAGE_SAMPLER,
+               0); /* vs */
+   else
+      OUT_BATCH(0);
+   OUT_BATCH(0); /* gs */
+   OUT_BATCH(0); /* clip */
+   OUT_BATCH(0); /* sf */
+   OUT_RELOC(brw->wm.bind_bo,
+            BRW_USAGE_SAMPLER,
+            0); /* wm/ps */
+   ADVANCE_BATCH();
+   return 0;
+}
+
+const struct brw_tracked_state brw_binding_table_pointers = {
+   .dirty = {
+      .mesa = 0,
+      .brw = BRW_NEW_BATCH,
+      .cache = CACHE_NEW_SURF_BIND,
+   },
+   .prepare = prepare_binding_table_pointers,
+   .emit = upload_binding_table_pointers,
+};
+
+
+/**********************************************************************
+ * Upload pointers to the per-stage state.
+ *
+ * The state pointers in this packet are all relative to the general state
+ * base address set by CMD_STATE_BASE_ADDRESS, which is 0.
+ */
+static int upload_pipelined_state_pointers(struct brw_context *brw )
+{
+   BEGIN_BATCH(7, IGNORE_CLIPRECTS);
+   OUT_BATCH(CMD_PIPELINED_STATE_POINTERS << 16 | (7 - 2));
+   OUT_RELOC(brw->vs.state_bo, 
+            BRW_USAGE_STATE,
+            0);
+   if (brw->gs.prog_active)
+      OUT_RELOC(brw->gs.state_bo, 
+               BRW_USAGE_STATE,
+               1);
+   else
+      OUT_BATCH(0);
+   OUT_RELOC(brw->clip.state_bo, 
+            BRW_USAGE_STATE,
+            1);
+   OUT_RELOC(brw->sf.state_bo,
+            BRW_USAGE_STATE,
+            0);
+   OUT_RELOC(brw->wm.state_bo,
+            BRW_USAGE_STATE,
+            0);
+   OUT_RELOC(brw->cc.state_bo,
+            BRW_USAGE_STATE,
+            0);
+   ADVANCE_BATCH();
+
+   brw->state.dirty.brw |= BRW_NEW_PSP;
+   return 0;
+}
+
+
+static int prepare_psp_urb_cbs(struct brw_context *brw)
+{
+   brw_add_validated_bo(brw, brw->vs.state_bo);
+   brw_add_validated_bo(brw, brw->gs.state_bo);
+   brw_add_validated_bo(brw, brw->clip.state_bo);
+   brw_add_validated_bo(brw, brw->sf.state_bo);
+   brw_add_validated_bo(brw, brw->wm.state_bo);
+   brw_add_validated_bo(brw, brw->cc.state_bo);
+   return 0;
+}
+
+static int upload_psp_urb_cbs(struct brw_context *brw )
+{
+   int ret;
+   
+   ret = upload_pipelined_state_pointers(brw);
+   if (ret)
+      return ret;
+
+   ret = brw_upload_urb_fence(brw);
+   if (ret)
+      return ret;
+
+   ret = brw_upload_cs_urb_state(brw);
+   if (ret)
+      return ret;
+
+   return 0;
+}
+
+const struct brw_tracked_state brw_psp_urb_cbs = {
+   .dirty = {
+      .mesa = 0,
+      .brw = BRW_NEW_URB_FENCE | BRW_NEW_BATCH,
+      .cache = (CACHE_NEW_VS_UNIT | 
+               CACHE_NEW_GS_UNIT | 
+               CACHE_NEW_GS_PROG | 
+               CACHE_NEW_CLIP_UNIT | 
+               CACHE_NEW_SF_UNIT | 
+               CACHE_NEW_WM_UNIT | 
+               CACHE_NEW_CC_UNIT)
+   },
+   .prepare = prepare_psp_urb_cbs,
+   .emit = upload_psp_urb_cbs,
+};
+
+
+/***********************************************************************
+ * Depth buffer 
+ */
+
+static int prepare_depthbuffer(struct brw_context *brw)
+{
+   struct pipe_surface *zsbuf = brw->curr.fb.zsbuf;
+
+   if (zsbuf)
+      brw_add_validated_bo(brw, brw_surface(zsbuf)->bo);
+
+   return 0;
+}
+
+static int emit_depthbuffer(struct brw_context *brw)
+{
+   struct pipe_surface *surface = brw->curr.fb.zsbuf;
+   unsigned int len = (BRW_IS_G4X(brw) || BRW_IS_IGDNG(brw)) ? 6 : 5;
+
+   if (surface == NULL) {
+      BEGIN_BATCH(len, IGNORE_CLIPRECTS);
+      OUT_BATCH(CMD_DEPTH_BUFFER << 16 | (len - 2));
+      OUT_BATCH((BRW_DEPTHFORMAT_D32_FLOAT << 18) |
+               (BRW_SURFACE_NULL << 29));
+      OUT_BATCH(0);
+      OUT_BATCH(0);
+      OUT_BATCH(0);
+
+      if (BRW_IS_G4X(brw) || BRW_IS_IGDNG(brw))
+         OUT_BATCH(0);
+
+      ADVANCE_BATCH();
+   } else {
+      struct brw_winsys_buffer *bo;
+      unsigned int format;
+      unsigned int pitch;
+      unsigned int cpp;
+
+      switch (surface->format) {
+      case PIPE_FORMAT_Z16_UNORM:
+        format = BRW_DEPTHFORMAT_D16_UNORM;
+        cpp = 2;
+        break;
+      case PIPE_FORMAT_X8Z24_UNORM:
+      case PIPE_FORMAT_S8Z24_UNORM:
+        format = BRW_DEPTHFORMAT_D24_UNORM_S8_UINT;
+        cpp = 4;
+        break;
+      case PIPE_FORMAT_Z32_FLOAT:
+        format = BRW_DEPTHFORMAT_D32_FLOAT;
+        cpp = 4;
+        break;
+      default:
+        assert(0);
+        return PIPE_ERROR_BAD_INPUT;
+      }
+
+      bo = brw_surface(surface)->bo;
+      pitch = brw_surface(surface)->pitch;
+
+      BEGIN_BATCH(len, IGNORE_CLIPRECTS);
+      OUT_BATCH(CMD_DEPTH_BUFFER << 16 | (len - 2));
+      OUT_BATCH(((pitch * cpp) - 1) |
+               (format << 18) |
+               (BRW_TILEWALK_YMAJOR << 26) |
+               ((surface->layout != PIPE_SURFACE_LAYOUT_LINEAR) << 27) |
+               (BRW_SURFACE_2D << 29));
+      OUT_RELOC(bo,
+               BRW_USAGE_DEPTH_BUFFER,
+               surface->offset);
+      OUT_BATCH((BRW_SURFACE_MIPMAPLAYOUT_BELOW << 1) |
+               ((pitch - 1) << 6) |
+               ((surface->height - 1) << 19));
+      OUT_BATCH(0);
+
+      if (BRW_IS_G4X(brw) || BRW_IS_IGDNG(brw))
+         OUT_BATCH(0);
+
+      ADVANCE_BATCH();
+   }
+
+   return 0;
+}
+
+const struct brw_tracked_state brw_depthbuffer = {
+   .dirty = {
+      .mesa = PIPE_NEW_DEPTH_BUFFER,
+      .brw = BRW_NEW_BATCH,
+      .cache = 0,
+   },
+   .prepare = prepare_depthbuffer,
+   .emit = emit_depthbuffer,
+};
+
+
+
+/***********************************************************************
+ * Polygon stipple packet
+ */
+
+static int upload_polygon_stipple(struct brw_context *brw)
+{
+   BRW_CACHED_BATCH_STRUCT(brw, &brw->curr.bps);
+   return 0;
+}
+
+const struct brw_tracked_state brw_polygon_stipple = {
+   .dirty = {
+      .mesa = PIPE_NEW_POLYGON_STIPPLE,
+      .brw = 0,
+      .cache = 0
+   },
+   .emit = upload_polygon_stipple
+};
+
+
+/***********************************************************************
+ * Line stipple packet
+ */
+
+static int upload_line_stipple(struct brw_context *brw)
+{
+   const struct brw_line_stipple *bls = &brw->curr.rast->bls;
+   if (bls->header.opcode) {
+      BRW_CACHED_BATCH_STRUCT(brw, bls);
+   }
+   return 0;
+}
+
+const struct brw_tracked_state brw_line_stipple = {
+   .dirty = {
+      .mesa = PIPE_NEW_RAST,
+      .brw = 0,
+      .cache = 0
+   },
+   .emit = upload_line_stipple
+};
+
+
+/***********************************************************************
+ * Misc invarient state packets
+ */
+
+static int upload_invarient_state( struct brw_context *brw )
+{
+   {
+      /* 0x61040000  Pipeline Select */
+      /*     PipelineSelect            : 0 */
+      struct brw_pipeline_select ps;
+
+      memset(&ps, 0, sizeof(ps));
+      if (BRW_IS_G4X(brw) || BRW_IS_IGDNG(brw))
+        ps.header.opcode = CMD_PIPELINE_SELECT_GM45;
+      else
+        ps.header.opcode = CMD_PIPELINE_SELECT_965;
+      ps.header.pipeline_select = 0;
+      BRW_BATCH_STRUCT(brw, &ps);
+   }
+
+   {
+      struct brw_global_depth_offset_clamp gdo;
+      memset(&gdo, 0, sizeof(gdo));
+
+      /* Disable depth offset clamping. 
+       */
+      gdo.header.opcode = CMD_GLOBAL_DEPTH_OFFSET_CLAMP;
+      gdo.header.length = sizeof(gdo)/4 - 2;
+      gdo.depth_offset_clamp = 0.0;
+
+      BRW_BATCH_STRUCT(brw, &gdo);
+   }
+
+
+   /* 0x61020000  State Instruction Pointer */
+   {
+      struct brw_system_instruction_pointer sip;
+      memset(&sip, 0, sizeof(sip));
+
+      sip.header.opcode = CMD_STATE_INSN_POINTER;
+      sip.header.length = 0;
+      sip.bits0.pad = 0;
+      sip.bits0.system_instruction_pointer = 0;
+      BRW_BATCH_STRUCT(brw, &sip);
+   }
+
+   /* VF Statistics */
+   {
+      struct brw_vf_statistics vfs;
+      memset(&vfs, 0, sizeof(vfs));
+
+      if (BRW_IS_G4X(brw) || BRW_IS_IGDNG(brw)) 
+        vfs.opcode = CMD_VF_STATISTICS_GM45;
+      else 
+        vfs.opcode = CMD_VF_STATISTICS_965;
+
+      if (BRW_DEBUG & DEBUG_STATS)
+        vfs.statistics_enable = 1; 
+
+      BRW_BATCH_STRUCT(brw, &vfs);
+   }
+   
+   if (!BRW_IS_965(brw))
+   {
+      struct brw_aa_line_parameters balp;
+
+      /* use legacy aa line coverage computation */
+      memset(&balp, 0, sizeof(balp));
+      balp.header.opcode = CMD_AA_LINE_PARAMETERS;
+      balp.header.length = sizeof(balp) / 4 - 2;
+   
+      BRW_BATCH_STRUCT(brw, &balp);
+   }
+
+   {
+      struct brw_polygon_stipple_offset bpso;
+      
+      /* This is invarient state in gallium:
+       */
+      memset(&bpso, 0, sizeof(bpso));
+      bpso.header.opcode = CMD_POLY_STIPPLE_OFFSET;
+      bpso.header.length = sizeof(bpso)/4-2;
+      bpso.bits0.y_offset = 0;
+      bpso.bits0.x_offset = 0;
+
+      BRW_BATCH_STRUCT(brw, &bpso);
+   }
+   
+   return 0;
+}
+
+const struct brw_tracked_state brw_invarient_state = {
+   .dirty = {
+      .mesa = 0,
+      .brw = BRW_NEW_CONTEXT,
+      .cache = 0
+   },
+   .emit = upload_invarient_state
+};
+
+
+/***********************************************************************
+ * State base address 
+ */
+
+/**
+ * Define the base addresses which some state is referenced from.
+ *
+ * This allows us to avoid having to emit relocations in many places for
+ * cached state, and instead emit pointers inside of large, mostly-static
+ * state pools.  This comes at the expense of memory, and more expensive cache
+ * misses.
+ */
+static int upload_state_base_address( struct brw_context *brw )
+{
+   /* Output the structure (brw_state_base_address) directly to the
+    * batchbuffer, so we can emit relocations inline.
+    */
+   if (BRW_IS_IGDNG(brw)) {
+       BEGIN_BATCH(8, IGNORE_CLIPRECTS);
+       OUT_BATCH(CMD_STATE_BASE_ADDRESS << 16 | (8 - 2));
+       OUT_BATCH(1); /* General state base address */
+       OUT_BATCH(1); /* Surface state base address */
+       OUT_BATCH(1); /* Indirect object base address */
+       OUT_BATCH(1); /* Instruction base address */
+       OUT_BATCH(1); /* General state upper bound */
+       OUT_BATCH(1); /* Indirect object upper bound */
+       OUT_BATCH(1); /* Instruction access upper bound */
+       ADVANCE_BATCH();
+   } else {
+       BEGIN_BATCH(6, IGNORE_CLIPRECTS);
+       OUT_BATCH(CMD_STATE_BASE_ADDRESS << 16 | (6 - 2));
+       OUT_BATCH(1); /* General state base address */
+       OUT_BATCH(1); /* Surface state base address */
+       OUT_BATCH(1); /* Indirect object base address */
+       OUT_BATCH(1); /* General state upper bound */
+       OUT_BATCH(1); /* Indirect object upper bound */
+       ADVANCE_BATCH();
+   }
+   return 0;
+}
+
+const struct brw_tracked_state brw_state_base_address = {
+   .dirty = {
+      .mesa = 0,
+      .brw = BRW_NEW_CONTEXT,
+      .cache = 0,
+   },
+   .emit = upload_state_base_address
+};
diff --git a/src/gallium/drivers/i965/brw_pipe_blend.c b/src/gallium/drivers/i965/brw_pipe_blend.c
new file mode 100644 (file)
index 0000000..b759a91
--- /dev/null
@@ -0,0 +1,208 @@
+
+#include "util/u_memory.h"
+#include "pipe/p_context.h"
+#include "pipe/p_state.h"
+
+#include "brw_context.h"
+#include "brw_defines.h"
+#include "brw_debug.h"
+
+static int translate_logicop(unsigned logicop)
+{
+   switch (logicop) {
+   case PIPE_LOGICOP_CLEAR:
+      return BRW_LOGICOPFUNCTION_CLEAR;
+   case PIPE_LOGICOP_AND:
+      return BRW_LOGICOPFUNCTION_AND;
+   case PIPE_LOGICOP_AND_REVERSE:
+      return BRW_LOGICOPFUNCTION_AND_REVERSE;
+   case PIPE_LOGICOP_COPY:
+      return BRW_LOGICOPFUNCTION_COPY;
+   case PIPE_LOGICOP_COPY_INVERTED:
+      return BRW_LOGICOPFUNCTION_COPY_INVERTED;
+   case PIPE_LOGICOP_AND_INVERTED:
+      return BRW_LOGICOPFUNCTION_AND_INVERTED;
+   case PIPE_LOGICOP_NOOP:
+      return BRW_LOGICOPFUNCTION_NOOP;
+   case PIPE_LOGICOP_XOR:
+      return BRW_LOGICOPFUNCTION_XOR;
+   case PIPE_LOGICOP_OR:
+      return BRW_LOGICOPFUNCTION_OR;
+   case PIPE_LOGICOP_OR_INVERTED:
+      return BRW_LOGICOPFUNCTION_OR_INVERTED;
+   case PIPE_LOGICOP_NOR:
+      return BRW_LOGICOPFUNCTION_NOR;
+   case PIPE_LOGICOP_EQUIV:
+      return BRW_LOGICOPFUNCTION_EQUIV;
+   case PIPE_LOGICOP_INVERT:
+      return BRW_LOGICOPFUNCTION_INVERT;
+   case PIPE_LOGICOP_OR_REVERSE:
+      return BRW_LOGICOPFUNCTION_OR_REVERSE;
+   case PIPE_LOGICOP_NAND:
+      return BRW_LOGICOPFUNCTION_NAND;
+   case PIPE_LOGICOP_SET:
+      return BRW_LOGICOPFUNCTION_SET;
+   default:
+      assert(0);
+      return BRW_LOGICOPFUNCTION_SET;
+   }
+}
+
+
+static unsigned translate_blend_equation( unsigned mode )
+{
+   switch (mode) {
+   case PIPE_BLEND_ADD: 
+      return BRW_BLENDFUNCTION_ADD; 
+   case PIPE_BLEND_MIN: 
+      return BRW_BLENDFUNCTION_MIN; 
+   case PIPE_BLEND_MAX: 
+      return BRW_BLENDFUNCTION_MAX; 
+   case PIPE_BLEND_SUBTRACT: 
+      return BRW_BLENDFUNCTION_SUBTRACT; 
+   case PIPE_BLEND_REVERSE_SUBTRACT: 
+      return BRW_BLENDFUNCTION_REVERSE_SUBTRACT; 
+   default: 
+      assert(0);
+      return BRW_BLENDFUNCTION_ADD;
+   }
+}
+
+static unsigned translate_blend_factor( unsigned factor )
+{
+   switch(factor) {
+   case PIPE_BLENDFACTOR_ZERO: 
+      return BRW_BLENDFACTOR_ZERO; 
+   case PIPE_BLENDFACTOR_SRC_ALPHA: 
+      return BRW_BLENDFACTOR_SRC_ALPHA; 
+   case PIPE_BLENDFACTOR_ONE: 
+      return BRW_BLENDFACTOR_ONE; 
+   case PIPE_BLENDFACTOR_SRC_COLOR: 
+      return BRW_BLENDFACTOR_SRC_COLOR; 
+   case PIPE_BLENDFACTOR_INV_SRC_COLOR: 
+      return BRW_BLENDFACTOR_INV_SRC_COLOR; 
+   case PIPE_BLENDFACTOR_DST_COLOR: 
+      return BRW_BLENDFACTOR_DST_COLOR; 
+   case PIPE_BLENDFACTOR_INV_DST_COLOR: 
+      return BRW_BLENDFACTOR_INV_DST_COLOR; 
+   case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
+      return BRW_BLENDFACTOR_INV_SRC_ALPHA; 
+   case PIPE_BLENDFACTOR_DST_ALPHA: 
+      return BRW_BLENDFACTOR_DST_ALPHA; 
+   case PIPE_BLENDFACTOR_INV_DST_ALPHA:
+      return BRW_BLENDFACTOR_INV_DST_ALPHA; 
+   case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE: 
+      return BRW_BLENDFACTOR_SRC_ALPHA_SATURATE;
+   case PIPE_BLENDFACTOR_CONST_COLOR:
+      return BRW_BLENDFACTOR_CONST_COLOR; 
+   case PIPE_BLENDFACTOR_INV_CONST_COLOR:
+      return BRW_BLENDFACTOR_INV_CONST_COLOR;
+   case PIPE_BLENDFACTOR_CONST_ALPHA:
+      return BRW_BLENDFACTOR_CONST_ALPHA; 
+   case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
+      return BRW_BLENDFACTOR_INV_CONST_ALPHA;
+   default:
+      assert(0);
+      return BRW_BLENDFACTOR_ZERO;
+   }   
+}
+
+static void *brw_create_blend_state( struct pipe_context *pipe,
+                                    const struct pipe_blend_state *templ )
+{
+   struct brw_blend_state *blend = CALLOC_STRUCT(brw_blend_state);
+   if (blend == NULL)
+      return NULL;
+
+   if (templ->logicop_enable) {
+      blend->cc2.logicop_enable = 1;
+      blend->cc5.logicop_func = translate_logicop(templ->logicop_func);
+   } 
+   else if (templ->blend_enable) {
+      blend->cc6.dest_blend_factor = translate_blend_factor(templ->rgb_dst_factor);
+      blend->cc6.src_blend_factor = translate_blend_factor(templ->rgb_src_factor);
+      blend->cc6.blend_function = translate_blend_equation(templ->rgb_func);
+
+      blend->cc5.ia_dest_blend_factor = translate_blend_factor(templ->alpha_dst_factor);
+      blend->cc5.ia_src_blend_factor = translate_blend_factor(templ->alpha_src_factor);
+      blend->cc5.ia_blend_function = translate_blend_equation(templ->alpha_func);
+
+      blend->cc3.blend_enable = 1;
+      blend->cc3.ia_blend_enable = 
+        (blend->cc6.dest_blend_factor != blend->cc5.ia_dest_blend_factor ||
+         blend->cc6.src_blend_factor != blend->cc5.ia_src_blend_factor ||
+         blend->cc6.blend_function != blend->cc5.ia_blend_function);
+
+      /* Per-surface blend enables, currently just follow global
+       * state:
+       */
+      blend->ss0.color_blend = 1;
+   }
+
+   blend->cc5.dither_enable = templ->dither;
+
+   if (BRW_DEBUG & DEBUG_STATS)
+      blend->cc5.statistics_enable = 1;
+
+   /* Per-surface color mask -- just follow global state:
+    */
+   blend->ss0.writedisable_red   = (templ->colormask & PIPE_MASK_R) ? 0 : 1;
+   blend->ss0.writedisable_green = (templ->colormask & PIPE_MASK_G) ? 0 : 1;
+   blend->ss0.writedisable_blue  = (templ->colormask & PIPE_MASK_B) ? 0 : 1;
+   blend->ss0.writedisable_alpha = (templ->colormask & PIPE_MASK_A) ? 0 : 1;
+
+   return (void *)blend;
+}
+
+static void brw_bind_blend_state(struct pipe_context *pipe,
+                                void *cso)
+{
+   struct brw_context *brw = brw_context(pipe);
+   brw->curr.blend = (const struct brw_blend_state *)cso;
+   brw->state.dirty.mesa |= PIPE_NEW_BLEND;
+}
+
+static void brw_delete_blend_state(struct pipe_context *pipe,
+                                 void *cso)
+{
+   struct brw_context *brw = brw_context(pipe);
+   assert((const void *)cso != (const void *)brw->curr.blend);
+   FREE(cso);
+}
+
+
+static void brw_set_blend_color(struct pipe_context *pipe,
+                               const struct pipe_blend_color *blend_color)
+{
+   struct brw_context *brw = brw_context(pipe);
+   struct brw_blend_constant_color *bcc = &brw->curr.bcc;
+
+   bcc->blend_constant_color[0] = blend_color->color[0];
+   bcc->blend_constant_color[1] = blend_color->color[1];
+   bcc->blend_constant_color[2] = blend_color->color[2];
+   bcc->blend_constant_color[3] = blend_color->color[3];
+
+   brw->state.dirty.mesa |= PIPE_NEW_BLEND_COLOR;
+}
+
+
+void brw_pipe_blend_init( struct brw_context *brw )
+{
+   brw->base.set_blend_color = brw_set_blend_color;
+   brw->base.create_blend_state = brw_create_blend_state;
+   brw->base.bind_blend_state = brw_bind_blend_state;
+   brw->base.delete_blend_state = brw_delete_blend_state;
+
+   {
+      struct brw_blend_constant_color *bcc = &brw->curr.bcc;
+
+      memset(bcc, 0, sizeof(*bcc));      
+      bcc->header.opcode = CMD_BLEND_CONSTANT_COLOR;
+      bcc->header.length = sizeof(*bcc)/4-2;
+   }
+
+}
+
+void brw_pipe_blend_cleanup( struct brw_context *brw )
+{
+}
diff --git a/src/gallium/drivers/i965/brw_pipe_clear.c b/src/gallium/drivers/i965/brw_pipe_clear.c
new file mode 100644 (file)
index 0000000..452e1e8
--- /dev/null
@@ -0,0 +1,218 @@
+/**************************************************************************
+ * 
+ * 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 "util/u_pack_color.h"
+
+#include "pipe/p_state.h"
+
+#include "brw_batchbuffer.h"
+#include "brw_screen.h"
+#include "brw_context.h"
+
+#define MASK16 0xffff
+#define MASK24 0xffffff
+
+
+/**
+ * Use blitting to clear the renderbuffers named by 'flags'.
+ * Note: we can't use the ctx->DrawBuffer->_ColorDrawBufferIndexes field
+ * since that might include software renderbuffers or renderbuffers
+ * which we're clearing with triangles.
+ * \param mask  bitmask of BUFFER_BIT_* values indicating buffers to clear
+ */
+static enum pipe_error
+try_clear( struct brw_context *brw,
+           struct brw_surface *surface,
+           unsigned value )
+{
+   uint32_t BR13, CMD;
+   int x1 = 0;
+   int y1 = 0;
+   int x2 = surface->base.width;
+   int y2 = surface->base.height;
+   int pitch = surface->pitch;
+   int cpp = surface->cpp;
+
+   if (x2 == 0 || y2 == 0)
+      return 0;
+
+   debug_printf("%s dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n",
+                __FUNCTION__,
+                (void *)surface->bo, pitch * cpp,
+                surface->base.offset,
+                x1, y1, x2 - x1, y2 - y1);
+
+   BR13 = 0xf0 << 16;
+   CMD = XY_COLOR_BLT_CMD | XY_BLT_WRITE_RGB | XY_BLT_WRITE_ALPHA;
+
+   /* Setup the blit command */
+   if (cpp == 4) {
+      BR13 |= BR13_8888;
+      CMD |= XY_BLT_WRITE_ALPHA | XY_BLT_WRITE_RGB;
+   }
+   else {
+      assert(cpp == 2);
+      BR13 |= BR13_565;
+   }
+
+   /* XXX: nasty hack for clearing depth buffers
+    */
+   if (surface->tiling == BRW_TILING_Y) {
+      x2 = pitch;
+   }
+
+   if (surface->tiling == BRW_TILING_X) {
+      CMD |= XY_DST_TILED;
+      pitch /= 4;
+   }
+
+   BR13 |= (pitch * cpp);
+
+   BEGIN_BATCH(6, 0);
+   OUT_BATCH(CMD);
+   OUT_BATCH(BR13);
+   OUT_BATCH((y1 << 16) | x1);
+   OUT_BATCH((y2 << 16) | x2);
+   OUT_RELOC(surface->bo,
+             BRW_USAGE_BLIT_DEST,
+             surface->base.offset);
+   OUT_BATCH(value);
+   ADVANCE_BATCH();
+
+   return 0;
+}
+
+
+
+
+static void color_clear(struct brw_context *brw, 
+                        struct brw_surface *bsurface,
+                        const float *rgba )
+{
+   enum pipe_error ret;
+   union util_color value;
+
+   util_pack_color( rgba, bsurface->base.format, &value );
+
+   if (bsurface->cpp == 2)
+      value.ui |= value.ui << 16;
+
+   ret = try_clear( brw, bsurface, value.ui );
+
+   if (ret != 0) {
+      brw_context_flush( brw );
+      ret = try_clear( brw, bsurface, value.ui );
+      assert( ret == 0 );
+   }
+}
+
+static void zstencil_clear(struct brw_context *brw, 
+                           struct brw_surface *bsurface,
+                           double depth,
+                           unsigned stencil )
+{
+   enum pipe_error ret;
+   unsigned value;
+
+   switch (bsurface->base.format) {
+   case PIPE_FORMAT_X8Z24_UNORM:
+   case PIPE_FORMAT_S8Z24_UNORM:
+      value = ((unsigned)(depth * MASK24) & MASK24);
+      break;
+   case PIPE_FORMAT_Z16_UNORM:
+      value = ((unsigned)(depth * MASK16) & MASK16);
+      break;
+   default:
+      assert(0);
+      return;
+   }
+
+   switch (bsurface->base.format) {
+   case PIPE_FORMAT_X8Z24_UNORM:
+   case PIPE_FORMAT_S8Z24_UNORM:
+      value = value | (stencil << 24);
+      break;
+
+   case PIPE_FORMAT_Z16_UNORM:
+      value = value | (value << 16);
+      break;
+
+   default:
+      break;
+   }
+
+   ret = try_clear( brw, bsurface, value );
+
+   if (ret != 0) {
+      brw_context_flush( brw );
+      ret = try_clear( brw, bsurface, value );
+      assert( ret == 0 );
+   }
+}
+
+
+
+/**
+ * Clear the given surface to the specified value.
+ * No masking, no scissor (clear entire buffer).
+ */
+static void brw_clear(struct pipe_context *pipe, 
+                      unsigned buffers,
+                      const float *rgba,
+                      double depth,
+                      unsigned stencil)
+{
+   struct brw_context *brw = brw_context( pipe );
+   int i;
+
+   if (buffers & PIPE_CLEAR_COLOR) {
+      for (i = 0; i < brw->curr.fb.nr_cbufs; i++) {
+         color_clear( brw, 
+                      brw_surface(brw->curr.fb.cbufs[i]),
+                      rgba );
+      }
+   }
+
+   if (buffers & PIPE_CLEAR_DEPTHSTENCIL) {
+      if (brw->curr.fb.zsbuf) {
+         zstencil_clear( brw,
+                         brw_surface(brw->curr.fb.zsbuf),
+                         depth, stencil );
+      }
+   }
+}
+
+
+void brw_pipe_clear_init( struct brw_context *brw )
+{
+   brw->base.clear = brw_clear;
+}
+
+
+void brw_pipe_clear_cleanup( struct brw_context *brw )
+{
+}
diff --git a/src/gallium/drivers/i965/brw_pipe_depth.c b/src/gallium/drivers/i965/brw_pipe_depth.c
new file mode 100644 (file)
index 0000000..e010d76
--- /dev/null
@@ -0,0 +1,172 @@
+
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
+#include "brw_context.h"
+#include "brw_defines.h"
+
+/* XXX: Fixme - include this to get IZ_ defines
+ */
+#include "brw_wm.h"
+
+static unsigned brw_translate_compare_func(unsigned func)
+{
+   switch (func) {
+   case PIPE_FUNC_NEVER:
+      return BRW_COMPAREFUNCTION_NEVER;
+   case PIPE_FUNC_LESS:
+      return BRW_COMPAREFUNCTION_LESS;
+   case PIPE_FUNC_LEQUAL:
+      return BRW_COMPAREFUNCTION_LEQUAL;
+   case PIPE_FUNC_GREATER:
+      return BRW_COMPAREFUNCTION_GREATER;
+   case PIPE_FUNC_GEQUAL:
+      return BRW_COMPAREFUNCTION_GEQUAL;
+   case PIPE_FUNC_NOTEQUAL:
+      return BRW_COMPAREFUNCTION_NOTEQUAL;
+   case PIPE_FUNC_EQUAL:
+      return BRW_COMPAREFUNCTION_EQUAL;
+   case PIPE_FUNC_ALWAYS:
+      return BRW_COMPAREFUNCTION_ALWAYS;
+   default:
+      assert(0);
+      return BRW_COMPAREFUNCTION_ALWAYS;
+   }
+}
+
+static unsigned translate_stencil_op(unsigned op)
+{
+   switch (op) {
+   case PIPE_STENCIL_OP_KEEP:
+      return BRW_STENCILOP_KEEP;
+   case PIPE_STENCIL_OP_ZERO:
+      return BRW_STENCILOP_ZERO;
+   case PIPE_STENCIL_OP_REPLACE:
+      return BRW_STENCILOP_REPLACE;
+   case PIPE_STENCIL_OP_INCR:
+      return BRW_STENCILOP_INCRSAT;
+   case PIPE_STENCIL_OP_DECR:
+      return BRW_STENCILOP_DECRSAT;
+   case PIPE_STENCIL_OP_INCR_WRAP:
+      return BRW_STENCILOP_INCR;
+   case PIPE_STENCIL_OP_DECR_WRAP:
+      return BRW_STENCILOP_DECR;
+   case PIPE_STENCIL_OP_INVERT:
+      return BRW_STENCILOP_INVERT;
+   default:
+      assert(0);
+      return BRW_STENCILOP_ZERO;
+   }
+}
+
+static void create_bcc_state( struct brw_depth_stencil_state *zstencil,
+                             const struct pipe_depth_stencil_alpha_state *templ )
+{
+   if (templ->stencil[0].enabled) {
+      zstencil->cc0.stencil_enable = 1;
+      zstencil->cc0.stencil_func =
+        brw_translate_compare_func(templ->stencil[0].func);
+      zstencil->cc0.stencil_fail_op =
+        translate_stencil_op(templ->stencil[0].fail_op);
+      zstencil->cc0.stencil_pass_depth_fail_op =
+        translate_stencil_op(templ->stencil[0].zfail_op);
+      zstencil->cc0.stencil_pass_depth_pass_op =
+        translate_stencil_op(templ->stencil[0].zpass_op);
+      zstencil->cc1.stencil_ref = templ->stencil[0].ref_value;
+      zstencil->cc1.stencil_write_mask = templ->stencil[0].writemask;
+      zstencil->cc1.stencil_test_mask = templ->stencil[0].valuemask;
+
+      if (templ->stencil[1].enabled) {
+        zstencil->cc0.bf_stencil_enable = 1;
+        zstencil->cc0.bf_stencil_func =
+           brw_translate_compare_func(templ->stencil[1].func);
+        zstencil->cc0.bf_stencil_fail_op =
+           translate_stencil_op(templ->stencil[1].fail_op);
+        zstencil->cc0.bf_stencil_pass_depth_fail_op =
+           translate_stencil_op(templ->stencil[1].zfail_op);
+        zstencil->cc0.bf_stencil_pass_depth_pass_op =
+           translate_stencil_op(templ->stencil[1].zpass_op);
+        zstencil->cc1.bf_stencil_ref = templ->stencil[1].ref_value;
+        zstencil->cc2.bf_stencil_write_mask = templ->stencil[1].writemask;
+        zstencil->cc2.bf_stencil_test_mask = templ->stencil[1].valuemask;
+      }
+
+      zstencil->cc0.stencil_write_enable = (zstencil->cc1.stencil_write_mask ||
+                                           zstencil->cc2.bf_stencil_write_mask);
+   }
+
+
+   if (templ->alpha.enabled) {
+      zstencil->cc3.alpha_test = 1;
+      zstencil->cc3.alpha_test_func = brw_translate_compare_func(templ->alpha.func);
+      zstencil->cc3.alpha_test_format = BRW_ALPHATEST_FORMAT_UNORM8;
+      zstencil->cc7.alpha_ref.ub[0] = float_to_ubyte(templ->alpha.ref_value);
+   }
+
+   if (templ->depth.enabled) {
+      zstencil->cc2.depth_test = 1;
+      zstencil->cc2.depth_test_function = brw_translate_compare_func(templ->depth.func);
+      zstencil->cc2.depth_write_enable = templ->depth.writemask;
+   }
+}
+
+static void create_wm_iz_state( struct brw_depth_stencil_state *zstencil )
+{
+   if (zstencil->cc3.alpha_test)
+      zstencil->iz_lookup |= IZ_PS_KILL_ALPHATEST_BIT;
+
+   if (zstencil->cc2.depth_test)
+      zstencil->iz_lookup |= IZ_DEPTH_TEST_ENABLE_BIT;
+
+   if (zstencil->cc2.depth_write_enable)
+      zstencil->iz_lookup |= IZ_DEPTH_WRITE_ENABLE_BIT;
+
+   if (zstencil->cc0.stencil_enable)
+      zstencil->iz_lookup |= IZ_STENCIL_TEST_ENABLE_BIT;
+
+   if (zstencil->cc0.stencil_write_enable)
+      zstencil->iz_lookup |= IZ_STENCIL_WRITE_ENABLE_BIT;
+
+}
+
+
+static void *
+brw_create_depth_stencil_state( struct pipe_context *pipe,
+                               const struct pipe_depth_stencil_alpha_state *templ )
+{
+   struct brw_depth_stencil_state *zstencil = CALLOC_STRUCT(brw_depth_stencil_state);
+
+   create_bcc_state( zstencil, templ );
+   create_wm_iz_state( zstencil );
+
+   return (void *)zstencil;
+}
+
+
+static void brw_bind_depth_stencil_state(struct pipe_context *pipe,
+                                        void *cso)
+{
+   struct brw_context *brw = brw_context(pipe);
+   brw->curr.zstencil = (const struct brw_depth_stencil_state *)cso;
+   brw->state.dirty.mesa |= PIPE_NEW_DEPTH_STENCIL_ALPHA;
+}
+
+static void brw_delete_depth_stencil_state(struct pipe_context *pipe,
+                                          void *cso)
+{
+   struct brw_context *brw = brw_context(pipe);
+   assert((const void *)cso != (const void *)brw->curr.zstencil);
+   FREE(cso);
+}
+
+
+void brw_pipe_depth_stencil_init( struct brw_context *brw )
+{
+   brw->base.create_depth_stencil_alpha_state = brw_create_depth_stencil_state;
+   brw->base.bind_depth_stencil_alpha_state = brw_bind_depth_stencil_state;
+   brw->base.delete_depth_stencil_alpha_state = brw_delete_depth_stencil_state;
+}
+
+void brw_pipe_depth_stencil_cleanup( struct brw_context *brw )
+{
+}
diff --git a/src/gallium/drivers/i965/brw_pipe_fb.c b/src/gallium/drivers/i965/brw_pipe_fb.c
new file mode 100644 (file)
index 0000000..5d4e502
--- /dev/null
@@ -0,0 +1,84 @@
+#include "util/u_math.h"
+#include "pipe/p_context.h"
+#include "pipe/p_state.h"
+
+#include "brw_context.h"
+#include "brw_debug.h"
+
+/**
+ * called from intelDrawBuffer()
+ */
+static void brw_set_framebuffer_state( struct pipe_context *pipe, 
+                                      const struct pipe_framebuffer_state *fb )
+{
+   struct brw_context *brw = brw_context(pipe);
+   unsigned i;
+
+   /* Dimensions:
+    */
+   if (brw->curr.fb.width != fb->width ||
+       brw->curr.fb.height != fb->height) {
+      brw->curr.fb.width = fb->width;
+      brw->curr.fb.height = fb->height;
+      brw->state.dirty.mesa |= PIPE_NEW_FRAMEBUFFER_DIMENSIONS;
+   }
+   
+   /* Z/Stencil
+    */
+   if (brw->curr.fb.zsbuf != fb->zsbuf) {
+      pipe_surface_reference(&brw->curr.fb.zsbuf, fb->zsbuf);
+      brw->state.dirty.mesa |= PIPE_NEW_DEPTH_BUFFER;
+   }
+
+   /* Color buffers:
+    */
+   for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
+      if (brw->curr.fb.cbufs[i] != fb->cbufs[i]) {
+        brw->state.dirty.mesa |= PIPE_NEW_COLOR_BUFFERS;
+        pipe_surface_reference(&brw->curr.fb.cbufs[i], fb->cbufs[i]);
+      }
+   }
+   
+   if (brw->curr.fb.nr_cbufs != fb->nr_cbufs) {
+      brw->curr.fb.nr_cbufs = MIN2(BRW_MAX_DRAW_BUFFERS, fb->nr_cbufs);
+      brw->state.dirty.mesa |= PIPE_NEW_NR_CBUFS;
+   }
+}
+
+
+static void brw_set_viewport_state( struct pipe_context *pipe,
+                                   const struct pipe_viewport_state *viewport )
+{
+   struct brw_context *brw = brw_context(pipe);
+
+   brw->curr.viewport = *viewport;
+   brw->curr.ccv.min_depth = viewport->scale[2] * -1.0 + viewport->translate[2];
+   brw->curr.ccv.max_depth = viewport->scale[2] *  1.0 + viewport->translate[2];
+
+   if (0)
+      debug_printf("%s depth range %f .. %f\n",
+                   __FUNCTION__,
+                   brw->curr.ccv.min_depth,
+                   brw->curr.ccv.max_depth);
+
+   brw->state.dirty.mesa |= PIPE_NEW_VIEWPORT;
+}
+
+
+void brw_pipe_framebuffer_init( struct brw_context *brw )
+{
+   brw->base.set_framebuffer_state = brw_set_framebuffer_state;
+   brw->base.set_viewport_state = brw_set_viewport_state;
+}
+
+void brw_pipe_framebuffer_cleanup( struct brw_context *brw )
+{
+   struct pipe_framebuffer_state *fb = &brw->curr.fb;
+   int i;
+
+   for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
+      pipe_surface_reference(&fb->cbufs[i], NULL);
+   }
+
+   pipe_surface_reference(&fb->zsbuf, NULL);
+}
diff --git a/src/gallium/drivers/i965/brw_pipe_flush.c b/src/gallium/drivers/i965/brw_pipe_flush.c
new file mode 100644 (file)
index 0000000..fdc4814
--- /dev/null
@@ -0,0 +1,83 @@
+
+#include "util/u_upload_mgr.h"
+
+#include "brw_context.h"
+#include "brw_screen.h"
+#include "brw_batchbuffer.h"
+
+
+
+/* All batchbuffer flushes must go through this function.
+ */
+void brw_context_flush( struct brw_context *brw )
+{
+   /*
+    * 
+    */
+   brw_emit_query_end(brw);
+
+   /* Move to the end of the current upload buffer so that we'll force choosing
+    * a new buffer next time.
+    */
+   u_upload_flush( brw->vb.upload_vertex );
+   u_upload_flush( brw->vb.upload_index );
+
+   _brw_batchbuffer_flush( brw->batch, __FILE__, __LINE__ );
+
+   /* Mark all context state as needing to be re-emitted.
+    * This is probably not as severe as on 915, since almost all of our state
+    * is just in referenced buffers.
+    */
+   brw->state.dirty.brw |= BRW_NEW_CONTEXT;
+   brw->state.dirty.mesa |= ~0;
+   brw->state.dirty.brw |= ~0;
+   brw->state.dirty.cache |= ~0;
+
+   brw->curbe.need_new_bo = GL_TRUE;
+}
+
+static void
+brw_flush( struct pipe_context *pipe,
+           unsigned flags, 
+           struct pipe_fence_handle **fence )
+{
+   brw_context_flush( brw_context( pipe ) );
+   if (fence)
+      *fence = NULL;
+}
+
+static unsigned brw_is_buffer_referenced(struct pipe_context *pipe,
+                                  struct pipe_buffer *buffer)
+{
+   struct brw_context *brw = brw_context(pipe);
+   struct brw_screen *bscreen = brw_screen(brw->base.screen);
+
+   return brw_is_buffer_referenced_by_bo( bscreen,
+                                          buffer,
+                                          brw->batch->buf );
+}
+
+static unsigned brw_is_texture_referenced(struct pipe_context *pipe,
+                                   struct pipe_texture *texture,
+                                   unsigned face,
+                                   unsigned level)
+{
+   struct brw_context *brw = brw_context(pipe);
+   struct brw_screen *bscreen = brw_screen(brw->base.screen);
+
+   return brw_is_texture_referenced_by_bo( bscreen,
+                                           texture, face, level,
+                                           brw->batch->buf );
+}
+
+void brw_pipe_flush_init( struct brw_context *brw )
+{
+   brw->base.flush = brw_flush;
+   brw->base.is_buffer_referenced = brw_is_buffer_referenced;
+   brw->base.is_texture_referenced = brw_is_texture_referenced;
+}
+
+
+void brw_pipe_flush_cleanup( struct brw_context *brw )
+{
+}
diff --git a/src/gallium/drivers/i965/brw_pipe_misc.c b/src/gallium/drivers/i965/brw_pipe_misc.c
new file mode 100644 (file)
index 0000000..3035907
--- /dev/null
@@ -0,0 +1,54 @@
+
+#include "brw_context.h"
+#include "brw_structs.h"
+#include "brw_defines.h"
+
+static void brw_set_polygon_stipple( struct pipe_context *pipe,
+                                    const struct pipe_poly_stipple *stip )
+{
+   struct brw_context *brw = brw_context(pipe);
+   struct brw_polygon_stipple *bps = &brw->curr.bps;
+   GLuint i;
+
+   memset(bps, 0, sizeof *bps);
+   bps->header.opcode = CMD_POLY_STIPPLE_PATTERN;
+   bps->header.length = sizeof *bps/4-2;
+
+   for (i = 0; i < 32; i++)
+      bps->stipple[i] = stip->stipple[i]; /* don't invert */
+
+   brw->state.dirty.mesa |= PIPE_NEW_POLYGON_STIPPLE;
+}
+
+
+static void brw_set_scissor_state( struct pipe_context *pipe,
+                                   const struct pipe_scissor_state *scissor )
+{
+   struct brw_context *brw = brw_context(pipe);
+
+   brw->curr.scissor =  *scissor;
+   brw->state.dirty.mesa |= PIPE_NEW_SCISSOR;
+}
+
+
+static void brw_set_clip_state( struct pipe_context *pipe,
+                                const struct pipe_clip_state *clip )
+{
+   struct brw_context *brw = brw_context(pipe);
+
+   brw->curr.ucp = *clip;
+   brw->state.dirty.mesa |= PIPE_NEW_CLIP;
+}
+
+
+void brw_pipe_misc_init( struct brw_context *brw )
+{
+   brw->base.set_polygon_stipple = brw_set_polygon_stipple;
+   brw->base.set_scissor_state = brw_set_scissor_state;
+   brw->base.set_clip_state = brw_set_clip_state;
+}
+
+
+void brw_pipe_misc_cleanup( struct brw_context *brw )
+{
+}
diff --git a/src/gallium/drivers/i965/brw_pipe_query.c b/src/gallium/drivers/i965/brw_pipe_query.c
new file mode 100644 (file)
index 0000000..2eb8626
--- /dev/null
@@ -0,0 +1,263 @@
+/*
+ * Copyright © 2008 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ *    Eric Anholt <eric@anholt.net>
+ *
+ */
+
+/** @file support for ARB_query_object
+ *
+ * ARB_query_object is implemented by using the PIPE_CONTROL command to stall
+ * execution on the completion of previous depth tests, and write the
+ * current PS_DEPTH_COUNT to a buffer object.
+ *
+ * We use before and after counts when drawing during a query so that
+ * we don't pick up other clients' query data in ours.  To reduce overhead,
+ * a single BO is used to record the query data for all active queries at
+ * once.  This also gives us a simple bound on how much batchbuffer space is
+ * required for handling queries, so that we can be sure that we won't
+ * have to emit a batchbuffer without getting the ending PS_DEPTH_COUNT.
+ */
+#include "util/u_simple_list.h"
+
+#include "brw_context.h"
+#include "brw_state.h"
+#include "brw_batchbuffer.h"
+#include "brw_reg.h"
+
+/** Waits on the query object's BO and totals the results for this query */
+static boolean
+brw_query_get_result(struct pipe_context *pipe,
+                    struct pipe_query *q,
+                    boolean wait,
+                    uint64_t *result)
+{
+   struct brw_context *brw = brw_context(pipe);
+   struct brw_query_object *query = (struct brw_query_object *)q;
+
+   /* Map and count the pixels from the current query BO */
+   if (query->bo) {
+      int i;
+      uint64_t *map;
+      
+      if (brw->sws->bo_is_busy(query->bo) && !wait)
+        return FALSE;
+      
+      map = bo_map_read(brw->sws, query->bo);
+      if (map == NULL)
+        return FALSE;
+      
+      for (i = query->first_index; i <= query->last_index; i++) {
+        query->result += map[i * 2 + 1] - map[i * 2];
+      }
+
+      brw->sws->bo_unmap(query->bo);
+      bo_reference(&query->bo, NULL);
+   }
+
+   *result = query->result;
+   return TRUE;
+}
+
+static struct pipe_query *
+brw_query_create(struct pipe_context *pipe, unsigned type )
+{
+   struct brw_query_object *query;
+
+   switch (type) {
+   case PIPE_QUERY_OCCLUSION_COUNTER:
+      query = CALLOC_STRUCT( brw_query_object );
+      if (query == NULL)
+        return NULL;
+      return (struct pipe_query *)query;
+      
+   default:
+      return NULL;
+   }
+}
+
+static void
+brw_query_destroy(struct pipe_context *pipe, struct pipe_query *q)
+{
+   struct brw_query_object *query = (struct brw_query_object *)q;
+
+   bo_reference(&query->bo, NULL);
+   FREE(query);
+}
+
+static void
+brw_query_begin(struct pipe_context *pipe, struct pipe_query *q)
+{
+   struct brw_context *brw = brw_context(pipe);
+   struct brw_query_object *query = (struct brw_query_object *)q;
+
+   /* Reset our driver's tracking of query state. */
+   bo_reference(&query->bo, NULL);
+   query->result = 0;
+   query->first_index = -1;
+   query->last_index = -1;
+
+   insert_at_head(&brw->query.active_head, query);
+   brw->query.stats_wm++;
+   brw->state.dirty.mesa |= PIPE_NEW_QUERY;
+}
+
+static void
+brw_query_end(struct pipe_context *pipe, struct pipe_query *q)
+{
+   struct brw_context *brw = brw_context(pipe);
+   struct brw_query_object *query = (struct brw_query_object *)q;
+
+   /* Flush the batchbuffer in case it has writes to our query BO.
+    * Have later queries write to a new query BO so that further rendering
+    * doesn't delay the collection of our results.
+    */
+   if (query->bo) {
+      brw_emit_query_end(brw);
+      brw_context_flush( brw );
+
+      bo_reference(&brw->query.bo, NULL);
+   }
+
+   remove_from_list(query);
+   brw->query.stats_wm--;
+   brw->state.dirty.mesa |= PIPE_NEW_QUERY;
+}
+
+/***********************************************************************
+ * Internal functions and callbacks to implement queries 
+ */
+
+/** Called to set up the query BO and account for its aperture space */
+enum pipe_error
+brw_prepare_query_begin(struct brw_context *brw)
+{
+   enum pipe_error ret;
+
+   /* Skip if we're not doing any queries. */
+   if (is_empty_list(&brw->query.active_head))
+      return PIPE_OK;
+
+   /* Get a new query BO if we're going to need it. */
+   if (brw->query.bo == NULL ||
+       brw->query.index * 2 + 1 >= 4096 / sizeof(uint64_t)) {
+
+      ret = brw->sws->bo_alloc(brw->sws, BRW_BUFFER_TYPE_QUERY, 4096, 1,
+                               &brw->query.bo);
+      if (ret)
+         return ret;
+
+      brw->query.index = 0;
+   }
+
+   brw_add_validated_bo(brw, brw->query.bo);
+
+   return PIPE_OK;
+}
+
+/** Called just before primitive drawing to get a beginning PS_DEPTH_COUNT. */
+void
+brw_emit_query_begin(struct brw_context *brw)
+{
+   struct brw_query_object *query;
+
+   /* Skip if we're not doing any queries, or we've emitted the start. */
+   if (brw->query.active || is_empty_list(&brw->query.active_head))
+      return;
+
+   BEGIN_BATCH(4, IGNORE_CLIPRECTS);
+   OUT_BATCH(_3DSTATE_PIPE_CONTROL |
+            PIPE_CONTROL_DEPTH_STALL |
+            PIPE_CONTROL_WRITE_DEPTH_COUNT);
+   /* This object could be mapped cacheable, but we don't have an exposed
+    * mechanism to support that.  Since it's going uncached, tell GEM that
+    * we're writing to it.  The usual clflush should be all that's required
+    * to pick up the results.
+    */
+   OUT_RELOC(brw->query.bo,
+            BRW_USAGE_QUERY_RESULT,
+            PIPE_CONTROL_GLOBAL_GTT_WRITE |
+            ((brw->query.index * 2) * sizeof(uint64_t)));
+   OUT_BATCH(0);
+   OUT_BATCH(0);
+   ADVANCE_BATCH();
+
+   foreach(query, &brw->query.active_head) {
+      if (query->bo != brw->query.bo) {
+        uint64_t tmp;
+        
+        /* Propogate the results from this buffer to all of the
+         * active queries, as the bo is going away.
+         */
+        if (query->bo != NULL)
+           brw_query_get_result( &brw->base, 
+                                 (struct pipe_query *)query,
+                                 FALSE,
+                                 &tmp );
+
+        bo_reference( &query->bo, brw->query.bo );
+        query->first_index = brw->query.index;
+      }
+      query->last_index = brw->query.index;
+   }
+   brw->query.active = GL_TRUE;
+}
+
+/** Called at batchbuffer flush to get an ending PS_DEPTH_COUNT */
+void
+brw_emit_query_end(struct brw_context *brw)
+{
+   if (!brw->query.active)
+      return;
+
+   BEGIN_BATCH(4, IGNORE_CLIPRECTS);
+   OUT_BATCH(_3DSTATE_PIPE_CONTROL |
+            PIPE_CONTROL_DEPTH_STALL |
+            PIPE_CONTROL_WRITE_DEPTH_COUNT);
+   OUT_RELOC(brw->query.bo,
+            BRW_USAGE_QUERY_RESULT,
+            PIPE_CONTROL_GLOBAL_GTT_WRITE |
+            ((brw->query.index * 2 + 1) * sizeof(uint64_t)));
+   OUT_BATCH(0);
+   OUT_BATCH(0);
+   ADVANCE_BATCH();
+
+   brw->query.active = GL_FALSE;
+   brw->query.index++;
+}
+
+void brw_pipe_query_init( struct brw_context *brw )
+{
+   brw->base.create_query = brw_query_create;
+   brw->base.destroy_query = brw_query_destroy;
+   brw->base.begin_query = brw_query_begin;
+   brw->base.end_query = brw_query_end;
+   brw->base.get_query_result = brw_query_get_result;
+}
+
+
+void brw_pipe_query_cleanup( struct brw_context *brw )
+{
+   /* Unreference brw->query.bo ??
+    */
+}
diff --git a/src/gallium/drivers/i965/brw_pipe_rast.c b/src/gallium/drivers/i965/brw_pipe_rast.c
new file mode 100644 (file)
index 0000000..2117e91
--- /dev/null
@@ -0,0 +1,161 @@
+
+#include "util/u_memory.h"
+#include "pipe/p_defines.h"
+#include "brw_context.h"
+#include "brw_defines.h"
+#include "brw_pipe_rast.h"
+#include "brw_wm.h"
+
+
+static unsigned translate_fill( unsigned fill )
+{
+   switch (fill) {
+   case PIPE_POLYGON_MODE_FILL:
+      return CLIP_FILL;
+   case PIPE_POLYGON_MODE_LINE:
+      return CLIP_LINE;
+   case PIPE_POLYGON_MODE_POINT:
+      return CLIP_POINT;
+   default:
+      assert(0);
+      return CLIP_FILL;
+   }
+}
+
+
+/* Calculates the key for triangle-mode clipping.  Non-triangle
+ * clipping keys use much less information and are computed on the
+ * fly.
+ */
+static void
+calculate_clip_key_rast( const struct brw_context *brw,
+                        const struct pipe_rasterizer_state *templ,
+                        const struct brw_rasterizer_state *rast,
+                        struct brw_clip_prog_key *key)
+{
+   memset(key, 0, sizeof *key);
+
+   if (brw->chipset.is_igdng)
+       key->clip_mode = BRW_CLIPMODE_KERNEL_CLIP;
+   else
+       key->clip_mode = BRW_CLIPMODE_NORMAL;
+
+   key->do_flat_shading = templ->flatshade;
+
+   if (templ->cull_mode == PIPE_WINDING_BOTH) {
+      key->clip_mode = BRW_CLIPMODE_REJECT_ALL;
+      return;
+   }
+
+   key->fill_ccw = CLIP_CULL;
+   key->fill_cw = CLIP_CULL;
+
+   if (!(templ->cull_mode & PIPE_WINDING_CCW)) {
+      key->fill_ccw = translate_fill(templ->fill_ccw);
+   }
+
+   if (!(templ->cull_mode & PIPE_WINDING_CW)) {
+      key->fill_cw = translate_fill(templ->fill_cw);
+   }
+
+   if (key->fill_cw == CLIP_LINE ||
+       key->fill_ccw == CLIP_LINE ||
+       key->fill_cw == CLIP_POINT ||
+       key->fill_ccw == CLIP_POINT) {
+      key->do_unfilled = 1;
+      key->clip_mode = BRW_CLIPMODE_CLIP_NON_REJECTED;
+   }
+
+   key->offset_ccw = templ->offset_ccw;
+   key->offset_cw = templ->offset_cw;
+
+   if (templ->light_twoside && key->fill_cw != CLIP_CULL) 
+      key->copy_bfc_cw = 1;
+   
+   if (templ->light_twoside && key->fill_ccw != CLIP_CULL) 
+      key->copy_bfc_ccw = 1;
+}
+
+
+static void
+calculate_line_stipple_rast( const struct pipe_rasterizer_state *templ,
+                            struct brw_line_stipple *bls )
+{
+   GLfloat tmp = 1.0f / (templ->line_stipple_factor + 1);
+   GLint tmpi = tmp * (1<<13);
+
+   bls->header.opcode = CMD_LINE_STIPPLE_PATTERN;
+   bls->header.length = sizeof(*bls)/4 - 2;
+   bls->bits0.pattern = templ->line_stipple_pattern;
+   bls->bits1.repeat_count = templ->line_stipple_factor + 1;
+   bls->bits1.inverse_repeat_count = tmpi;
+}
+
+static void *brw_create_rasterizer_state( struct pipe_context *pipe,
+                                         const struct pipe_rasterizer_state *templ )
+{
+   struct brw_context *brw = brw_context(pipe);
+   struct brw_rasterizer_state *rast;
+
+   rast = CALLOC_STRUCT(brw_rasterizer_state);
+   if (rast == NULL)
+      return NULL;
+
+   rast->templ = *templ;
+
+   calculate_clip_key_rast( brw, templ, rast, &rast->clip_key );
+   
+   if (templ->line_stipple_enable)
+      calculate_line_stipple_rast( templ, &rast->bls );
+
+   /* Caclculate lookup value for WM IZ table.
+    */
+   if (templ->line_smooth) {
+      if (templ->fill_cw == PIPE_POLYGON_MODE_LINE &&
+         templ->fill_ccw == PIPE_POLYGON_MODE_LINE) {
+        rast->unfilled_aa_line = AA_ALWAYS;
+      }
+      else if (templ->fill_cw == PIPE_POLYGON_MODE_LINE ||
+              templ->fill_ccw == PIPE_POLYGON_MODE_LINE) {
+        rast->unfilled_aa_line = AA_SOMETIMES;
+      }
+      else {
+        rast->unfilled_aa_line = AA_NEVER;
+      }
+   }
+   else {
+      rast->unfilled_aa_line = AA_NEVER;
+   }
+
+   return (void *)rast;
+}
+
+
+static void brw_bind_rasterizer_state(struct pipe_context *pipe,
+                                void *cso)
+{
+   struct brw_context *brw = brw_context(pipe);
+   brw->curr.rast = (const struct brw_rasterizer_state *)cso;
+   brw->state.dirty.mesa |= PIPE_NEW_RAST;
+}
+
+static void brw_delete_rasterizer_state(struct pipe_context *pipe,
+                                 void *cso)
+{
+   struct brw_context *brw = brw_context(pipe);
+   assert((const void *)cso != (const void *)brw->curr.rast);
+   FREE(cso);
+}
+
+
+
+void brw_pipe_rast_init( struct brw_context *brw )
+{
+   brw->base.create_rasterizer_state = brw_create_rasterizer_state;
+   brw->base.bind_rasterizer_state = brw_bind_rasterizer_state;
+   brw->base.delete_rasterizer_state = brw_delete_rasterizer_state;
+}
+
+void brw_pipe_rast_cleanup( struct brw_context *brw )
+{
+}
diff --git a/src/gallium/drivers/i965/brw_pipe_rast.h b/src/gallium/drivers/i965/brw_pipe_rast.h
new file mode 100644 (file)
index 0000000..9354f01
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef BRW_PIPE_RAST_H
+#define BRW_PIPE_RAST_H
+
+#include "brw_clip.h"
+
+struct brw_rasterizer_state {
+   struct pipe_rasterizer_state templ; /* for draw module */
+
+   /* Precalculated hardware state:
+    */
+   struct brw_clip_prog_key clip_key;
+   struct brw_line_stipple bls;
+   unsigned unfilled_aa_line;
+};
+
+#endif
diff --git a/src/gallium/drivers/i965/brw_pipe_sampler.c b/src/gallium/drivers/i965/brw_pipe_sampler.c
new file mode 100644 (file)
index 0000000..8171279
--- /dev/null
@@ -0,0 +1,231 @@
+
+#include "util/u_memory.h"
+#include "util/u_math.h"
+
+#include "pipe/p_context.h"
+#include "pipe/p_state.h"
+
+#include "brw_context.h"
+#include "brw_defines.h"
+#include "brw_debug.h"
+
+
+
+/* The brw (and related graphics cores) do not support GL_CLAMP.  The
+ * Intel drivers for "other operating systems" implement GL_CLAMP as
+ * GL_CLAMP_TO_EDGE, so the same is done here.
+ */
+static GLuint translate_wrap_mode( unsigned wrap )
+{
+   switch( wrap ) {
+   case PIPE_TEX_WRAP_REPEAT: 
+      return BRW_TEXCOORDMODE_WRAP;
+
+   case PIPE_TEX_WRAP_CLAMP:
+   case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
+      return BRW_TEXCOORDMODE_CLAMP;
+      
+   case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
+      return BRW_TEXCOORDMODE_CLAMP_BORDER;
+
+   case PIPE_TEX_WRAP_MIRROR_REPEAT: 
+      return BRW_TEXCOORDMODE_MIRROR;
+
+   case PIPE_TEX_WRAP_MIRROR_CLAMP: 
+   case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE: 
+   case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER: 
+      return BRW_TEXCOORDMODE_MIRROR_ONCE;
+
+   default: 
+      return BRW_TEXCOORDMODE_WRAP;
+   }
+}
+
+static GLuint translate_img_filter( unsigned filter )
+{
+   switch (filter) {
+   case PIPE_TEX_FILTER_NEAREST:
+      return BRW_MAPFILTER_NEAREST;
+   case PIPE_TEX_FILTER_LINEAR:
+      return BRW_MAPFILTER_LINEAR;
+   default:
+      assert(0);
+      return BRW_MAPFILTER_NEAREST;
+   }
+}
+
+static GLuint translate_mip_filter( unsigned filter )
+{
+   switch (filter) {
+   case PIPE_TEX_MIPFILTER_NONE: 
+      return BRW_MIPFILTER_NONE;
+   case PIPE_TEX_MIPFILTER_NEAREST:
+      return BRW_MIPFILTER_NEAREST;
+   case PIPE_TEX_MIPFILTER_LINEAR:
+      return BRW_MIPFILTER_LINEAR;
+   default:
+      assert(0);
+      return BRW_MIPFILTER_NONE;
+   }
+}
+
+/* XXX: not sure why there are special translations for the shadow tex
+ * compare functions.  In particular ALWAYS is translated to NEVER.
+ * Is this a hardware issue?  Does i965 really suffer from this?
+ */
+static GLuint translate_shadow_compare_func( unsigned func )
+{
+   switch (func) {
+   case PIPE_FUNC_NEVER: 
+       return BRW_COMPAREFUNCTION_ALWAYS;
+   case PIPE_FUNC_LESS: 
+       return BRW_COMPAREFUNCTION_LEQUAL;
+   case PIPE_FUNC_LEQUAL: 
+       return BRW_COMPAREFUNCTION_LESS;
+   case PIPE_FUNC_GREATER: 
+       return BRW_COMPAREFUNCTION_GEQUAL;
+   case PIPE_FUNC_GEQUAL: 
+      return BRW_COMPAREFUNCTION_GREATER;
+   case PIPE_FUNC_NOTEQUAL: 
+      return BRW_COMPAREFUNCTION_EQUAL;
+   case PIPE_FUNC_EQUAL: 
+      return BRW_COMPAREFUNCTION_NOTEQUAL;
+   case PIPE_FUNC_ALWAYS: 
+       return BRW_COMPAREFUNCTION_NEVER;
+   default:
+      assert(0);
+      return BRW_COMPAREFUNCTION_NEVER;
+   }
+}
+
+
+
+
+static void *
+brw_create_sampler_state( struct pipe_context *pipe,
+                          const struct pipe_sampler_state *template )
+{
+   struct brw_sampler *sampler = CALLOC_STRUCT(brw_sampler);
+
+   sampler->ss0.min_filter = translate_img_filter( template->min_img_filter );
+   sampler->ss0.mag_filter = translate_img_filter( template->mag_img_filter );
+   sampler->ss0.mip_filter = translate_mip_filter( template->min_mip_filter );
+
+
+   /* XXX: anisotropy logic slightly changed: 
+    */
+   if (template->max_anisotropy > 1.0) {
+      sampler->ss0.min_filter = BRW_MAPFILTER_ANISOTROPIC; 
+      sampler->ss0.mag_filter = BRW_MAPFILTER_ANISOTROPIC;
+
+      if (template->max_anisotropy > 2.0) {
+        sampler->ss3.max_aniso = MIN2((template->max_anisotropy - 2) / 2,
+                                      BRW_ANISORATIO_16);
+      }
+   }
+
+   sampler->ss1.r_wrap_mode = translate_wrap_mode(template->wrap_r);
+   sampler->ss1.s_wrap_mode = translate_wrap_mode(template->wrap_s);
+   sampler->ss1.t_wrap_mode = translate_wrap_mode(template->wrap_t);
+
+   /* Set LOD bias: 
+    */
+   sampler->ss0.lod_bias = 
+      util_signed_fixed(CLAMP(template->lod_bias, -16, 15), 6);
+
+
+   sampler->ss0.lod_preclamp = 1; /* OpenGL mode */
+   sampler->ss0.default_color_mode = 0; /* OpenGL/DX10 mode */
+
+   /* Set shadow function: 
+    */
+   if (template->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) {
+
+      /* Shadowing is "enabled" by emitting a particular sampler
+       * message (sample_c).  So need to recompile WM program when
+       * shadow comparison is enabled on each/any texture unit.
+       */
+      sampler->ss0.shadow_function =
+        translate_shadow_compare_func(template->compare_func);
+   }
+
+   /* Set BaseMipLevel, MaxLOD, MinLOD: 
+    */
+   sampler->ss0.base_level = 
+      util_unsigned_fixed(0, 1);
+
+   sampler->ss1.max_lod = 
+      util_unsigned_fixed(CLAMP(template->max_lod, 0, 13), 6);
+
+   sampler->ss1.min_lod = 
+      util_unsigned_fixed(CLAMP(template->min_lod, 0, 13), 6);
+
+   return (void *)sampler;
+}
+
+static void brw_bind_sampler_state(struct pipe_context *pipe,
+                                   unsigned num, void **sampler)
+{
+   struct brw_context *brw = brw_context(pipe);
+   int i;
+
+   for (i = 0; i < num; i++)
+      brw->curr.sampler[i] = sampler[i];
+
+   for (i = num; i < brw->curr.num_samplers; i++)
+      brw->curr.sampler[i] = NULL;
+
+   brw->curr.num_samplers = num;
+   brw->state.dirty.mesa |= PIPE_NEW_SAMPLERS;
+}
+
+static void brw_delete_sampler_state(struct pipe_context *pipe,
+                                 void *cso)
+{
+   FREE(cso);
+}
+
+static void brw_set_sampler_textures(struct pipe_context *pipe,
+                                    unsigned num,
+                                    struct pipe_texture **texture)
+{
+   struct brw_context *brw = brw_context(pipe);
+   int i;
+
+   for (i = 0; i < num; i++)
+      pipe_texture_reference(&brw->curr.texture[i], texture[i]);
+
+   for (i = num; i < brw->curr.num_textures; i++)
+      pipe_texture_reference(&brw->curr.texture[i], NULL);
+
+   brw->curr.num_textures = num;
+   brw->state.dirty.mesa |= PIPE_NEW_BOUND_TEXTURES;
+}
+
+static void brw_set_vertex_sampler_textures(struct pipe_context *pipe,
+                                            unsigned num,
+                                            struct pipe_texture **texture)
+{
+}
+
+static void brw_bind_vertex_sampler_state(struct pipe_context *pipe,
+                                          unsigned num, void **sampler)
+{
+}
+
+
+void brw_pipe_sampler_init( struct brw_context *brw )
+{
+   brw->base.create_sampler_state = brw_create_sampler_state;
+   brw->base.delete_sampler_state = brw_delete_sampler_state;
+
+   brw->base.set_fragment_sampler_textures = brw_set_sampler_textures;
+   brw->base.bind_fragment_sampler_states = brw_bind_sampler_state;
+
+   brw->base.set_vertex_sampler_textures = brw_set_vertex_sampler_textures;
+   brw->base.bind_vertex_sampler_states = brw_bind_vertex_sampler_state;
+
+}
+void brw_pipe_sampler_cleanup( struct brw_context *brw )
+{
+}
diff --git a/src/gallium/drivers/i965/brw_pipe_shader.c b/src/gallium/drivers/i965/brw_pipe_shader.c
new file mode 100644 (file)
index 0000000..bb32d90
--- /dev/null
@@ -0,0 +1,303 @@
+/*
+ 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 "util/u_memory.h"
+  
+#include "tgsi/tgsi_parse.h"
+#include "tgsi/tgsi_scan.h"
+
+#include "brw_context.h"
+#include "brw_util.h"
+#include "brw_wm.h"
+
+
+/**
+ * Determine if the given shader uses complex features such as flow
+ * conditionals, loops, subroutines.
+ */
+static GLboolean has_flow_control(const struct tgsi_shader_info *info)
+{
+    return (info->opcode_count[TGSI_OPCODE_ARL] > 0 ||
+           info->opcode_count[TGSI_OPCODE_IF] > 0 ||
+           info->opcode_count[TGSI_OPCODE_ENDIF] > 0 || /* redundant - IF */
+           info->opcode_count[TGSI_OPCODE_CAL] > 0 ||
+           info->opcode_count[TGSI_OPCODE_BRK] > 0 ||   /* redundant - BGNLOOP */
+           info->opcode_count[TGSI_OPCODE_RET] > 0 ||   /* redundant - CAL */
+           info->opcode_count[TGSI_OPCODE_BGNLOOP] > 0);
+}
+
+
+static void scan_immediates(const struct tgsi_token *tokens,
+                            const struct tgsi_shader_info *info,
+                            struct brw_immediate_data *imm)
+{
+   struct tgsi_parse_context parse;
+   boolean done = FALSE;
+
+   imm->nr = 0;
+   imm->data = MALLOC(info->immediate_count * 4 * sizeof(float));
+
+   tgsi_parse_init( &parse, tokens );
+   while (!tgsi_parse_end_of_tokens( &parse ) && !done) {
+      tgsi_parse_token( &parse );
+
+      switch (parse.FullToken.Token.Type) {
+      case TGSI_TOKEN_TYPE_DECLARATION:
+         break;
+
+      case TGSI_TOKEN_TYPE_IMMEDIATE: {
+        static const float id[4] = {0,0,0,1};
+        const float *value = &parse.FullToken.FullImmediate.u[0].Float;
+        unsigned size = parse.FullToken.FullImmediate.Immediate.NrTokens - 1;
+         unsigned i;
+
+        for (i = 0; i < size; i++)
+           imm->data[imm->nr][i] = value[i];
+
+        for (; i < 4; i++)
+           imm->data[imm->nr][i] = id[i];
+         
+         imm->nr++;
+        break;
+      }
+
+      case TGSI_TOKEN_TYPE_INSTRUCTION:
+        done = 1;
+        break;
+      }
+   }
+}
+
+
+static void brw_bind_fs_state( struct pipe_context *pipe, void *prog )
+{
+   struct brw_fragment_shader *fs = (struct brw_fragment_shader *)prog;
+   struct brw_context *brw = brw_context(pipe);
+   
+   if (brw->curr.fragment_shader == fs)
+      return;
+
+   if (brw->curr.fragment_shader == NULL ||
+       fs == NULL ||
+       memcmp(&brw->curr.fragment_shader->signature, &fs->signature,
+              brw_fs_signature_size(&fs->signature)) != 0) {
+      brw->state.dirty.mesa |= PIPE_NEW_FRAGMENT_SIGNATURE;
+   }
+
+   brw->curr.fragment_shader = fs;
+   brw->state.dirty.mesa |= PIPE_NEW_FRAGMENT_SHADER;
+}
+
+static void brw_bind_vs_state( struct pipe_context *pipe, void *prog )
+{
+   struct brw_context *brw = brw_context(pipe);
+
+   brw->curr.vertex_shader = (struct brw_vertex_shader *)prog;
+   brw->state.dirty.mesa |= PIPE_NEW_VERTEX_SHADER;
+}
+
+
+
+static void *brw_create_fs_state( struct pipe_context *pipe,
+                                 const struct pipe_shader_state *shader )
+{
+   struct brw_context *brw = brw_context(pipe);
+   struct brw_fragment_shader *fs;
+   int i;
+
+   fs = CALLOC_STRUCT(brw_fragment_shader);
+   if (fs == NULL)
+      return NULL;
+
+   /* Duplicate tokens, scan shader
+    */
+   fs->id = brw->program_id++;
+   fs->has_flow_control = has_flow_control(&fs->info);
+
+   fs->tokens = tgsi_dup_tokens(shader->tokens);
+   if (fs->tokens == NULL)
+      goto fail;
+
+   tgsi_scan_shader(fs->tokens, &fs->info);
+   scan_immediates(fs->tokens, &fs->info, &fs->immediates);
+
+   fs->signature.nr_inputs = fs->info.num_inputs;
+   for (i = 0; i < fs->info.num_inputs; i++) {
+      fs->signature.input[i].interp = fs->info.input_interpolate[i];
+      fs->signature.input[i].semantic = fs->info.input_semantic_name[i];
+      fs->signature.input[i].semantic_index = fs->info.input_semantic_index[i];
+   }
+
+   for (i = 0; i < fs->info.num_inputs; i++)
+      if (fs->info.input_semantic_name[i] == TGSI_SEMANTIC_POSITION)
+        fs->uses_depth = 1;
+
+   if (fs->info.uses_kill)
+      fs->iz_lookup |= IZ_PS_KILL_ALPHATEST_BIT;
+
+   if (fs->info.writes_z)
+      fs->iz_lookup |= IZ_PS_COMPUTES_DEPTH_BIT;
+
+   return (void *)fs;
+
+fail:
+   FREE(fs);
+   return NULL;
+}
+
+
+static void *brw_create_vs_state( struct pipe_context *pipe,
+                                 const struct pipe_shader_state *shader )
+{
+   struct brw_context *brw = brw_context(pipe);
+   struct brw_vertex_shader *vs;
+   unsigned i;
+
+   vs = CALLOC_STRUCT(brw_vertex_shader);
+   if (vs == NULL)
+      return NULL;
+
+   /* Duplicate tokens, scan shader
+    */
+   vs->tokens = tgsi_dup_tokens(shader->tokens);
+   if (vs->tokens == NULL)
+      goto fail;
+
+   tgsi_scan_shader(vs->tokens, &vs->info);
+   scan_immediates(vs->tokens, &vs->info, &vs->immediates);
+
+   vs->id = brw->program_id++;
+   vs->has_flow_control = has_flow_control(&vs->info);
+
+   vs->output_hpos = BRW_OUTPUT_NOT_PRESENT;
+   vs->output_color0 = BRW_OUTPUT_NOT_PRESENT;
+   vs->output_color1 = BRW_OUTPUT_NOT_PRESENT;
+   vs->output_bfc0 = BRW_OUTPUT_NOT_PRESENT;
+   vs->output_bfc1 = BRW_OUTPUT_NOT_PRESENT;
+   vs->output_edgeflag = BRW_OUTPUT_NOT_PRESENT;
+
+   for (i = 0; i < vs->info.num_outputs; i++) {
+      int index = vs->info.output_semantic_index[i];
+      switch (vs->info.output_semantic_name[i]) {
+      case TGSI_SEMANTIC_POSITION:
+         vs->output_hpos = i;
+         break;
+      case TGSI_SEMANTIC_COLOR:
+         if (index == 0)
+            vs->output_color0 = i;
+         else
+            vs->output_color1 = i;
+         break;
+      case TGSI_SEMANTIC_BCOLOR:
+         if (index == 0)
+            vs->output_bfc0 = i;
+         else
+            vs->output_bfc1 = i;
+         break;
+      case TGSI_SEMANTIC_EDGEFLAG:
+         vs->output_edgeflag = i;
+         break;
+      }
+   }
+
+   
+   /* Done:
+    */
+   return (void *)vs;
+
+fail:
+   FREE(vs);
+   return NULL;
+}
+
+
+static void brw_delete_fs_state( struct pipe_context *pipe, void *prog )
+{
+   struct brw_fragment_shader *fs = (struct brw_fragment_shader *)prog;
+
+   bo_reference(&fs->const_buffer, NULL);
+   FREE( (void *)fs->tokens );
+   FREE( fs );
+}
+
+
+static void brw_delete_vs_state( struct pipe_context *pipe, void *prog )
+{
+   struct brw_fragment_shader *vs = (struct brw_fragment_shader *)prog;
+
+   /* Delete draw shader
+    */
+   FREE( (void *)vs->tokens );
+   FREE( vs );
+}
+
+
+static void brw_set_constant_buffer(struct pipe_context *pipe,
+                                     uint shader, uint index,
+                                     const struct pipe_constant_buffer *buf)
+{
+   struct brw_context *brw = brw_context(pipe);
+
+   assert(index == 0);
+
+   if (shader == PIPE_SHADER_FRAGMENT) {
+      pipe_buffer_reference( &brw->curr.fragment_constants,
+                             buf->buffer );
+
+      brw->state.dirty.mesa |= PIPE_NEW_FRAGMENT_CONSTANTS;
+   }
+   else {
+      pipe_buffer_reference( &brw->curr.vertex_constants,
+                             buf->buffer );
+
+      brw->state.dirty.mesa |= PIPE_NEW_VERTEX_CONSTANTS;
+   }
+}
+
+
+void brw_pipe_shader_init( struct brw_context *brw )
+{
+   brw->base.set_constant_buffer = brw_set_constant_buffer;
+
+   brw->base.create_vs_state = brw_create_vs_state;
+   brw->base.bind_vs_state = brw_bind_vs_state;
+   brw->base.delete_vs_state = brw_delete_vs_state;
+
+   brw->base.create_fs_state = brw_create_fs_state;
+   brw->base.bind_fs_state = brw_bind_fs_state;
+   brw->base.delete_fs_state = brw_delete_fs_state;
+}
+
+void brw_pipe_shader_cleanup( struct brw_context *brw )
+{
+   pipe_buffer_reference( &brw->curr.fragment_constants, NULL );
+   pipe_buffer_reference( &brw->curr.vertex_constants, NULL );
+}
diff --git a/src/gallium/drivers/i965/brw_pipe_vertex.c b/src/gallium/drivers/i965/brw_pipe_vertex.c
new file mode 100644 (file)
index 0000000..e3c48e3
--- /dev/null
@@ -0,0 +1,71 @@
+#include "brw_context.h"
+
+
+static void brw_set_vertex_elements( struct pipe_context *pipe,
+                                    unsigned count,
+                                    const struct pipe_vertex_element *elements )
+{
+   struct brw_context *brw = brw_context(pipe);
+
+   memcpy(brw->curr.vertex_element, elements, count * sizeof(elements[0]));
+   brw->curr.num_vertex_elements = count;
+
+   brw->state.dirty.mesa |= PIPE_NEW_VERTEX_ELEMENT;
+}
+
+
+static void brw_set_vertex_buffers(struct pipe_context *pipe,
+                                  unsigned count,
+                                  const struct pipe_vertex_buffer *buffers)
+{
+   struct brw_context *brw = brw_context(pipe);
+   unsigned i;
+
+   /* Check for no change */
+   if (count == brw->curr.num_vertex_buffers &&
+       memcmp(brw->curr.vertex_buffer,
+              buffers,
+              count * sizeof buffers[0]) == 0)
+      return;
+
+   /* Adjust refcounts */
+   for (i = 0; i < count; i++) 
+      pipe_buffer_reference(&brw->curr.vertex_buffer[i].buffer, 
+                            buffers[i].buffer);
+
+   for ( ; i < brw->curr.num_vertex_buffers; i++)
+      pipe_buffer_reference(&brw->curr.vertex_buffer[i].buffer,
+                            NULL);
+
+   /* Copy remaining data */
+   memcpy(brw->curr.vertex_buffer, buffers, count * sizeof buffers[0]);
+   brw->curr.num_vertex_buffers = count;
+
+   brw->state.dirty.mesa |= PIPE_NEW_VERTEX_BUFFER;
+}
+
+
+void 
+brw_pipe_vertex_init( struct brw_context *brw )
+{
+   brw->base.set_vertex_buffers = brw_set_vertex_buffers;
+   brw->base.set_vertex_elements = brw_set_vertex_elements;
+}
+
+
+void 
+brw_pipe_vertex_cleanup( struct brw_context *brw )
+{
+
+   /* Release bound pipe vertex_buffers
+    */
+
+   /* Release some other stuff
+    */
+#if 0
+   for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
+      bo_reference(&brw->vb.inputs[i].bo, NULL);
+      brw->vb.inputs[i].bo = NULL;
+   }
+#endif
+}
diff --git a/src/gallium/drivers/i965/brw_reg.h b/src/gallium/drivers/i965/brw_reg.h
new file mode 100644 (file)
index 0000000..a63403b
--- /dev/null
@@ -0,0 +1,115 @@
+/**************************************************************************
+ * 
+ * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 
+ **************************************************************************/
+
+#ifndef BRW_REG_H
+#define BRW_REG_H
+
+#define CMD_MI                         (0x0 << 29)
+#define CMD_2D                         (0x2 << 29)
+#define CMD_3D                         (0x3 << 29)
+
+#define MI_NOOP                                (CMD_MI | 0)
+#define MI_BATCH_BUFFER_END            (CMD_MI | 0xA << 23)
+#define MI_FLUSH                       (CMD_MI | (4 << 23))
+
+#define _3DSTATE_DRAWRECT_INFO_I965    (CMD_3D | (3 << 27) | (1 << 24) | 0x2)
+
+/** @{
+ *
+ * PIPE_CONTROL operation, a combination MI_FLUSH and register write with
+ * additional flushing control.
+ */
+#define _3DSTATE_PIPE_CONTROL          (CMD_3D | (3 << 27) | (2 << 24) | 2)
+#define PIPE_CONTROL_NO_WRITE          (0 << 14)
+#define PIPE_CONTROL_WRITE_IMMEDIATE   (1 << 14)
+#define PIPE_CONTROL_WRITE_DEPTH_COUNT (2 << 14)
+#define PIPE_CONTROL_WRITE_TIMESTAMP   (3 << 14)
+#define PIPE_CONTROL_DEPTH_STALL       (1 << 13)
+#define PIPE_CONTROL_WRITE_FLUSH       (1 << 12)
+#define PIPE_CONTROL_INSTRUCTION_FLUSH (1 << 11)
+#define PIPE_CONTROL_INTERRUPT_ENABLE  (1 << 8)
+#define PIPE_CONTROL_PPGTT_WRITE       (0 << 2)
+#define PIPE_CONTROL_GLOBAL_GTT_WRITE  (1 << 2)
+
+/** @} */
+
+#define XY_SETUP_BLT_CMD               (CMD_2D | (0x01 << 22) | 6)
+#define XY_COLOR_BLT_CMD               (CMD_2D | (0x50 << 22) | 4)
+#define XY_SRC_COPY_BLT_CMD             (CMD_2D | (0x53 << 22) | 6)
+
+/* BR00 */
+#define XY_BLT_WRITE_ALPHA     (1 << 21)
+#define XY_BLT_WRITE_RGB       (1 << 20)
+#define XY_SRC_TILED           (1 << 15)
+#define XY_DST_TILED           (1 << 11)
+
+/* BR13 */
+#define BR13_565               (0x1 << 24)
+#define BR13_8888              (0x3 << 24)
+
+#define FENCE_LINEAR 0
+#define FENCE_XMAJOR 1
+#define FENCE_YMAJOR 2
+
+
+
+/* PCI IDs
+ */
+#define PCI_CHIP_I965_G                        0x29A2
+#define PCI_CHIP_I965_Q                        0x2992
+#define PCI_CHIP_I965_G_1              0x2982
+#define PCI_CHIP_I946_GZ               0x2972
+#define PCI_CHIP_I965_GM                0x2A02
+#define PCI_CHIP_I965_GME               0x2A12
+
+#define PCI_CHIP_GM45_GM                0x2A42
+
+#define PCI_CHIP_IGD_E_G                0x2E02
+#define PCI_CHIP_Q45_G                  0x2E12
+#define PCI_CHIP_G45_G                  0x2E22
+#define PCI_CHIP_G41_G                  0x2E32
+#define PCI_CHIP_B43_G                  0x2E42
+
+#define PCI_CHIP_ILD_G                  0x0042
+#define PCI_CHIP_ILM_G                  0x0046
+
+struct brw_chipset {
+   unsigned pci_id:16;
+   unsigned is_965:1;
+   unsigned is_igdng:1;
+   unsigned is_g4x:1;
+   unsigned pad:13;
+};
+
+
+/* XXX: hacks
+ */
+#define VERT_RESULT_HPOS 0     /* not always true */
+#define VERT_RESULT_PSIZ 10000 /* disabled */
+
+
+#endif
diff --git a/src/gallium/drivers/i965/brw_screen.c b/src/gallium/drivers/i965/brw_screen.c
new file mode 100644 (file)
index 0000000..0ecacac
--- /dev/null
@@ -0,0 +1,403 @@
+/**************************************************************************
+ * 
+ * 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_inlines.h"
+#include "util/u_memory.h"
+#include "util/u_string.h"
+
+#include "brw_reg.h"
+#include "brw_context.h"
+#include "brw_screen.h"
+#include "brw_winsys.h"
+#include "brw_debug.h"
+
+#ifdef DEBUG
+static const struct debug_named_value debug_names[] = {
+   { "tex",   DEBUG_TEXTURE},
+   { "state", DEBUG_STATE},
+   { "ioctl", DEBUG_IOCTL},
+   { "blit",  DEBUG_BLIT},
+   { "curbe", DEBUG_CURBE},
+   { "fall",  DEBUG_FALLBACKS},
+   { "verb",  DEBUG_VERBOSE},
+   { "bat",   DEBUG_BATCH},
+   { "pix",   DEBUG_PIXEL},
+   { "wins",  DEBUG_WINSYS},
+   { "min",   DEBUG_MIN_URB},
+   { "dis",   DEBUG_DISASSEM},
+   { "sync",  DEBUG_SYNC},
+   { "prim",  DEBUG_PRIMS },
+   { "vert",  DEBUG_VERTS },
+   { "dma",   DEBUG_DMA },
+   { "san",   DEBUG_SANITY },
+   { "sleep", DEBUG_SLEEP },
+   { "stats", DEBUG_STATS },
+   { "sing",  DEBUG_SINGLE_THREAD },
+   { "thre",  DEBUG_SINGLE_THREAD },
+   { "wm",    DEBUG_WM },
+   { "urb",   DEBUG_URB },
+   { "vs",    DEBUG_VS },
+   { NULL,    0 }
+};
+
+static const struct debug_named_value dump_names[] = {
+   { "asm",   DUMP_ASM},
+   { "state", DUMP_STATE},
+   { "batch", DUMP_BATCH},
+   { NULL, 0 }
+};
+
+int BRW_DEBUG = 0;
+int BRW_DUMP = 0;
+
+#endif
+
+
+/*
+ * Probe functions
+ */
+
+
+static const char *
+brw_get_vendor(struct pipe_screen *screen)
+{
+   return "VMware, Inc.";
+}
+
+static const char *
+brw_get_name(struct pipe_screen *screen)
+{
+   static char buffer[128];
+   const char *chipset;
+
+   switch (brw_screen(screen)->chipset.pci_id) {
+   case PCI_CHIP_I965_G:
+      chipset = "I965_G";
+      break;
+   case PCI_CHIP_I965_Q:
+      chipset = "I965_Q";
+      break;
+   case PCI_CHIP_I965_G_1:
+      chipset = "I965_G_1";
+      break;
+   case PCI_CHIP_I946_GZ:
+      chipset = "I946_GZ";
+      break;
+   case PCI_CHIP_I965_GM:
+      chipset = "I965_GM";
+      break;
+   case PCI_CHIP_I965_GME:
+      chipset = "I965_GME";
+      break;
+   case PCI_CHIP_GM45_GM:
+      chipset = "GM45_GM";
+      break;
+   case PCI_CHIP_IGD_E_G:
+      chipset = "IGD_E_G";
+      break;
+   case PCI_CHIP_Q45_G:
+      chipset = "Q45_G";
+      break;
+   case PCI_CHIP_G45_G:
+      chipset = "G45_G";
+      break;
+   case PCI_CHIP_G41_G:
+      chipset = "G41_G";
+      break;
+   case PCI_CHIP_B43_G:
+      chipset = "B43_G";
+      break;
+   case PCI_CHIP_ILD_G:
+      chipset = "ILD_G";
+      break;
+   case PCI_CHIP_ILM_G:
+      chipset = "ILM_G";
+      break;
+   }
+
+   util_snprintf(buffer, sizeof(buffer), "i965 (chipset: %s)", chipset);
+   return buffer;
+}
+
+static int
+brw_get_param(struct pipe_screen *screen, int param)
+{
+   switch (param) {
+   case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
+      return 8;
+   case PIPE_CAP_NPOT_TEXTURES:
+      return 1;
+   case PIPE_CAP_TWO_SIDED_STENCIL:
+      return 1;
+   case PIPE_CAP_GLSL:
+      return 0;
+   case PIPE_CAP_ANISOTROPIC_FILTER:
+      return 0;
+   case PIPE_CAP_POINT_SPRITE:
+      return 0;
+   case PIPE_CAP_MAX_RENDER_TARGETS:
+      return 1;
+   case PIPE_CAP_OCCLUSION_QUERY:
+      return 0;
+   case PIPE_CAP_TEXTURE_SHADOW_MAP:
+      return 1;
+   case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
+      return 11; /* max 1024x1024 */
+   case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
+      return 8;  /* max 128x128x128 */
+   case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
+      return 11; /* max 1024x1024 */
+   default:
+      return 0;
+   }
+}
+
+static float
+brw_get_paramf(struct pipe_screen *screen, int param)
+{
+   switch (param) {
+   case PIPE_CAP_MAX_LINE_WIDTH:
+      /* fall-through */
+   case PIPE_CAP_MAX_LINE_WIDTH_AA:
+      return 7.5;
+
+   case PIPE_CAP_MAX_POINT_WIDTH:
+      /* fall-through */
+   case PIPE_CAP_MAX_POINT_WIDTH_AA:
+      return 255.0;
+
+   case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
+      return 4.0;
+
+   case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
+      return 16.0;
+
+   default:
+      return 0;
+   }
+}
+
+static boolean
+brw_is_format_supported(struct pipe_screen *screen,
+                         enum pipe_format format, 
+                         enum pipe_texture_target target,
+                         unsigned tex_usage, 
+                         unsigned geom_flags)
+{
+   static const enum pipe_format tex_supported[] = {
+      PIPE_FORMAT_L8_UNORM,
+      PIPE_FORMAT_I8_UNORM,
+      PIPE_FORMAT_A8_UNORM,
+      PIPE_FORMAT_L16_UNORM,
+      /*PIPE_FORMAT_I16_UNORM,*/
+      /*PIPE_FORMAT_A16_UNORM,*/
+      PIPE_FORMAT_A8L8_UNORM,
+      PIPE_FORMAT_R5G6B5_UNORM,
+      PIPE_FORMAT_A1R5G5B5_UNORM,
+      PIPE_FORMAT_A4R4G4B4_UNORM,
+      PIPE_FORMAT_X8R8G8B8_UNORM,
+      PIPE_FORMAT_A8R8G8B8_UNORM,
+      /* video */
+      PIPE_FORMAT_YCBCR,
+      PIPE_FORMAT_YCBCR_REV,
+      /* compressed */
+      /*PIPE_FORMAT_FXT1_RGBA,*/
+      PIPE_FORMAT_DXT1_RGB,
+      PIPE_FORMAT_DXT1_RGBA,
+      PIPE_FORMAT_DXT3_RGBA,
+      PIPE_FORMAT_DXT5_RGBA,
+      /* sRGB */
+      PIPE_FORMAT_R8G8B8A8_SRGB,
+      PIPE_FORMAT_A8L8_SRGB,
+      PIPE_FORMAT_L8_SRGB,
+      PIPE_FORMAT_DXT1_SRGB,
+      /* depth */
+      PIPE_FORMAT_Z32_FLOAT,
+      PIPE_FORMAT_X8Z24_UNORM,
+      PIPE_FORMAT_S8Z24_UNORM,
+      PIPE_FORMAT_Z16_UNORM,
+      /* signed */
+      PIPE_FORMAT_R8G8_SNORM,
+      PIPE_FORMAT_R8G8B8A8_SNORM,
+      PIPE_FORMAT_NONE  /* list terminator */
+   };
+   static const enum pipe_format render_supported[] = {
+      PIPE_FORMAT_X8R8G8B8_UNORM,
+      PIPE_FORMAT_A8R8G8B8_UNORM,
+      PIPE_FORMAT_R5G6B5_UNORM,
+      PIPE_FORMAT_NONE  /* list terminator */
+   };
+   static const enum pipe_format depth_supported[] = {
+      PIPE_FORMAT_Z32_FLOAT,
+      PIPE_FORMAT_X8Z24_UNORM,
+      PIPE_FORMAT_S8Z24_UNORM,
+      PIPE_FORMAT_Z16_UNORM,
+      PIPE_FORMAT_NONE  /* list terminator */
+   };
+   const enum pipe_format *list;
+   uint i;
+
+   if (tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL)
+      list = depth_supported;
+   else if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET)
+      list = render_supported;
+   else
+      list = tex_supported;
+
+   for (i = 0; list[i] != PIPE_FORMAT_NONE; i++) {
+      if (list[i] == format)
+         return TRUE;
+   }
+
+   return FALSE;
+}
+
+
+/*
+ * Fence functions
+ */
+
+
+static void
+brw_fence_reference(struct pipe_screen *screen,
+                     struct pipe_fence_handle **ptr,
+                     struct pipe_fence_handle *fence)
+{
+}
+
+static int
+brw_fence_signalled(struct pipe_screen *screen,
+                     struct pipe_fence_handle *fence,
+                     unsigned flags)
+{
+   return 0;                    /* XXX shouldn't this be a boolean? */
+}
+
+static int
+brw_fence_finish(struct pipe_screen *screen,
+                 struct pipe_fence_handle *fence,
+                 unsigned flags)
+{
+   return 0;
+}
+
+
+/*
+ * Generic functions
+ */
+
+
+static void
+brw_destroy_screen(struct pipe_screen *screen)
+{
+   struct brw_screen *bscreen = brw_screen(screen);
+
+   if (bscreen->sws)
+      bscreen->sws->destroy(bscreen->sws);
+
+   FREE(bscreen);
+}
+
+/**
+ * Create a new brw_screen object
+ */
+struct pipe_screen *
+brw_create_screen(struct brw_winsys_screen *sws, uint pci_id)
+{
+   struct brw_screen *bscreen;
+   struct brw_chipset chipset;
+
+#ifdef DEBUG
+   BRW_DEBUG = debug_get_flags_option("BRW_DEBUG", debug_names, 0);
+   BRW_DEBUG |= debug_get_flags_option("INTEL_DEBUG", debug_names, 0);
+   BRW_DEBUG |= DEBUG_STATS | DEBUG_MIN_URB | DEBUG_WM;
+
+   BRW_DUMP = debug_get_flags_option("BRW_DUMP", dump_names, 0);
+#endif
+
+   memset(&chipset, 0, sizeof chipset);
+
+   chipset.pci_id = pci_id;
+
+   switch (pci_id) {
+   case PCI_CHIP_I965_G:
+   case PCI_CHIP_I965_Q:
+   case PCI_CHIP_I965_G_1:
+   case PCI_CHIP_I946_GZ:
+   case PCI_CHIP_I965_GM:
+   case PCI_CHIP_I965_GME:
+      chipset.is_965 = TRUE;
+      break;
+
+   case PCI_CHIP_GM45_GM:
+   case PCI_CHIP_IGD_E_G:
+   case PCI_CHIP_Q45_G:
+   case PCI_CHIP_G45_G:
+   case PCI_CHIP_G41_G:
+   case PCI_CHIP_B43_G:
+      chipset.is_g4x = TRUE;
+      break;
+
+   case PCI_CHIP_ILD_G:
+   case PCI_CHIP_ILM_G:
+      chipset.is_igdng = TRUE;
+      break;
+
+   default:
+      debug_printf("%s: unknown pci id 0x%x, cannot create screen\n", 
+                   __FUNCTION__, pci_id);
+      return NULL;
+   }
+
+
+   bscreen = CALLOC_STRUCT(brw_screen);
+   if (!bscreen)
+      return NULL;
+
+   bscreen->chipset = chipset;
+   bscreen->sws = sws;
+   bscreen->base.winsys = NULL;
+   bscreen->base.destroy = brw_destroy_screen;
+   bscreen->base.get_name = brw_get_name;
+   bscreen->base.get_vendor = brw_get_vendor;
+   bscreen->base.get_param = brw_get_param;
+   bscreen->base.get_paramf = brw_get_paramf;
+   bscreen->base.is_format_supported = brw_is_format_supported;
+   bscreen->base.fence_reference = brw_fence_reference;
+   bscreen->base.fence_signalled = brw_fence_signalled;
+   bscreen->base.fence_finish = brw_fence_finish;
+
+   brw_screen_tex_init(bscreen);
+   brw_screen_tex_surface_init(bscreen);
+   brw_screen_buffer_init(bscreen);
+
+   bscreen->no_tiling = debug_get_option("BRW_NO_TILING", FALSE) != NULL;
+   
+   
+   return &bscreen->base;
+}
diff --git a/src/gallium/drivers/i965/brw_screen.h b/src/gallium/drivers/i965/brw_screen.h
new file mode 100644 (file)
index 0000000..7226d92
--- /dev/null
@@ -0,0 +1,199 @@
+/**************************************************************************
+ * 
+ * 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 BRW_SCREEN_H
+#define BRW_SCREEN_H
+
+#include "pipe/p_state.h"
+#include "pipe/p_screen.h"
+
+#include "brw_reg.h"
+#include "brw_structs.h"
+
+struct brw_winsys_screen;
+
+
+/**
+ * Subclass of pipe_screen
+ */
+struct brw_screen
+{
+   struct pipe_screen base;
+   struct brw_chipset chipset;
+   struct brw_winsys_screen *sws;
+   boolean no_tiling;
+};
+
+/**
+ * Subclass of pipe_transfer
+ */
+struct brw_transfer
+{
+   struct pipe_transfer base;
+
+   unsigned offset;
+};
+
+struct brw_buffer
+{
+   struct pipe_buffer base;
+
+   /* One of either bo or user_buffer will be non-null, depending on
+    * whether this is a hardware or user buffer.
+    */
+   struct brw_winsys_buffer *bo;
+   void *user_buffer;
+
+   /* Mapped pointer??
+    */
+   void *ptr;
+};
+
+
+union brw_surface_id {
+   struct {
+      unsigned face:3;
+      unsigned zslice:13;
+      unsigned level:16;
+   } bits;
+   unsigned value;
+};
+
+
+struct brw_surface
+{
+   struct pipe_surface base;
+   
+   union brw_surface_id id;
+   unsigned cpp;
+   unsigned pitch;
+   unsigned draw_offset;
+   unsigned tiling;
+
+   struct brw_surface_state ss;
+   struct brw_winsys_buffer *bo;
+   struct brw_surface *next, *prev;
+};
+
+
+
+struct brw_texture
+{
+   struct pipe_texture base;
+   struct brw_winsys_buffer *bo;
+   struct brw_surface_state ss;
+
+   unsigned *image_offset[PIPE_MAX_TEXTURE_LEVELS];
+   unsigned nr_images[PIPE_MAX_TEXTURE_LEVELS];
+   unsigned level_offset[PIPE_MAX_TEXTURE_LEVELS];
+
+   boolean compressed;
+   unsigned brw_target;
+   unsigned pitch;
+   unsigned tiling;
+   unsigned cpp;
+   unsigned total_height;
+
+   struct brw_surface views[2];
+};
+
+
+
+/*
+ * Cast wrappers
+ */
+static INLINE struct brw_screen *
+brw_screen(struct pipe_screen *pscreen)
+{
+   return (struct brw_screen *) pscreen;
+}
+
+static INLINE struct brw_transfer *
+brw_transfer(struct pipe_transfer *transfer)
+{
+   return (struct brw_transfer *)transfer;
+}
+
+static INLINE struct brw_surface *
+brw_surface(struct pipe_surface *surface)
+{
+   return (struct brw_surface *)surface;
+}
+
+static INLINE struct brw_buffer *
+brw_buffer(struct pipe_buffer *buffer)
+{
+   return (struct brw_buffer *)buffer;
+}
+
+static INLINE struct brw_texture *
+brw_texture(struct pipe_texture *texture)
+{
+   return (struct brw_texture *)texture;
+}
+
+
+/* Pipe buffer helpers
+ */
+static INLINE boolean
+brw_buffer_is_user_buffer( const struct pipe_buffer *buf )
+{
+   return ((const struct brw_buffer *)buf)->user_buffer != NULL;
+}
+
+unsigned
+brw_surface_pitch( const struct pipe_surface *surface );
+
+/***********************************************************************
+ * Internal functions 
+ */
+GLboolean brw_texture_layout(struct brw_screen *brw_screen,
+                            struct brw_texture *tex );
+
+void brw_update_texture( struct brw_screen *brw_screen,
+                        struct brw_texture *tex );
+
+
+void brw_screen_tex_init( struct brw_screen *brw_screen );
+void brw_screen_tex_surface_init( struct brw_screen *brw_screen );
+
+void brw_screen_buffer_init(struct brw_screen *brw_screen);
+
+
+boolean brw_is_texture_referenced_by_bo( struct brw_screen *brw_screen,
+                                         struct pipe_texture *texture,
+                                         unsigned face, 
+                                         unsigned level,
+                                         struct brw_winsys_buffer *bo );
+
+boolean brw_is_buffer_referenced_by_bo( struct brw_screen *brw_screen,
+                                        struct pipe_buffer *buffer,
+                                        struct brw_winsys_buffer *bo );
+
+
+
+#endif /* BRW_SCREEN_H */
diff --git a/src/gallium/drivers/i965/brw_screen_buffers.c b/src/gallium/drivers/i965/brw_screen_buffers.c
new file mode 100644 (file)
index 0000000..d8141a3
--- /dev/null
@@ -0,0 +1,202 @@
+
+#include "util/u_memory.h"
+#include "util/u_math.h"
+
+#include "pipe/p_state.h"
+#include "pipe/p_defines.h"
+#include "pipe/p_inlines.h"
+
+#include "brw_screen.h"
+#include "brw_winsys.h"
+
+
+
+static void *
+brw_buffer_map_range( struct pipe_screen *screen,
+                      struct pipe_buffer *buffer,
+                      unsigned offset,
+                      unsigned length,
+                      unsigned usage )
+{
+   struct brw_screen *bscreen = brw_screen(screen); 
+   struct brw_winsys_screen *sws = bscreen->sws;
+   struct brw_buffer *buf = brw_buffer( buffer );
+
+   if (buf->user_buffer)
+      return buf->user_buffer;
+
+   return sws->bo_map( buf->bo, 
+                       BRW_DATA_OTHER,
+                       offset,
+                       length,
+                       (usage & PIPE_BUFFER_USAGE_CPU_WRITE) ? TRUE : FALSE,
+                       (usage & PIPE_BUFFER_USAGE_DISCARD) ? TRUE : FALSE,
+                       (usage & PIPE_BUFFER_USAGE_FLUSH_EXPLICIT) ? TRUE : FALSE);
+}
+
+static void *
+brw_buffer_map( struct pipe_screen *screen,
+                struct pipe_buffer *buffer,
+                unsigned usage )
+{
+   struct brw_screen *bscreen = brw_screen(screen); 
+   struct brw_winsys_screen *sws = bscreen->sws;
+   struct brw_buffer *buf = brw_buffer( buffer );
+
+   if (buf->user_buffer)
+      return buf->user_buffer;
+
+   return sws->bo_map( buf->bo, 
+                       BRW_DATA_OTHER,
+                       0,
+                       buf->base.size,
+                       (usage & PIPE_BUFFER_USAGE_CPU_WRITE) ? TRUE : FALSE,
+                       FALSE,
+                       FALSE);
+}
+
+
+static void 
+brw_buffer_flush_mapped_range( struct pipe_screen *screen,
+                               struct pipe_buffer *buffer,
+                               unsigned offset,
+                               unsigned length )
+{
+   struct brw_screen *bscreen = brw_screen(screen); 
+   struct brw_winsys_screen *sws = bscreen->sws;
+   struct brw_buffer *buf = brw_buffer( buffer );
+
+   if (buf->user_buffer)
+      return;
+
+   sws->bo_flush_range( buf->bo, 
+                        offset,
+                        length );
+}
+
+
+static void 
+brw_buffer_unmap( struct pipe_screen *screen,
+                   struct pipe_buffer *buffer )
+{
+   struct brw_screen *bscreen = brw_screen(screen); 
+   struct brw_winsys_screen *sws = bscreen->sws;
+   struct brw_buffer *buf = brw_buffer( buffer );
+   
+   if (buf->bo)
+      sws->bo_unmap(buf->bo);
+}
+
+static void
+brw_buffer_destroy( struct pipe_buffer *buffer )
+{
+   struct brw_buffer *buf = brw_buffer( buffer );
+
+   assert(!p_atomic_read(&buffer->reference.count));
+
+   bo_reference(&buf->bo, NULL);
+   FREE(buf);
+}
+
+
+static struct pipe_buffer *
+brw_buffer_create(struct pipe_screen *screen,
+                   unsigned alignment,
+                   unsigned usage,
+                   unsigned size)
+{
+   struct brw_screen *bscreen = brw_screen(screen);
+   struct brw_winsys_screen *sws = bscreen->sws;
+   struct brw_buffer *buf;
+   unsigned buffer_type;
+   enum pipe_error ret;
+   
+   buf = CALLOC_STRUCT(brw_buffer);
+   if (!buf)
+      return NULL;
+      
+   pipe_reference_init(&buf->base.reference, 1);
+   buf->base.screen = screen;
+   buf->base.alignment = alignment;
+   buf->base.usage = usage;
+   buf->base.size = size;
+
+   switch (usage & (PIPE_BUFFER_USAGE_VERTEX |
+                    PIPE_BUFFER_USAGE_INDEX |
+                    PIPE_BUFFER_USAGE_PIXEL |
+                    PIPE_BUFFER_USAGE_CONSTANT))
+   {
+   case PIPE_BUFFER_USAGE_VERTEX:
+   case PIPE_BUFFER_USAGE_INDEX:
+   case (PIPE_BUFFER_USAGE_VERTEX|PIPE_BUFFER_USAGE_INDEX):
+      buffer_type = BRW_BUFFER_TYPE_VERTEX;
+      break;
+      
+   case PIPE_BUFFER_USAGE_PIXEL:
+      buffer_type = BRW_BUFFER_TYPE_PIXEL;
+      break;
+
+   case PIPE_BUFFER_USAGE_CONSTANT:
+      buffer_type = BRW_BUFFER_TYPE_SHADER_CONSTANTS;
+      break;
+
+   default:
+      buffer_type = BRW_BUFFER_TYPE_GENERIC;
+      break;
+   }
+   
+   ret = sws->bo_alloc( sws, buffer_type,
+                        size, alignment,
+                        &buf->bo );
+   if (ret != PIPE_OK)
+      return NULL;
+      
+   return &buf->base; 
+}
+
+
+static struct pipe_buffer *
+brw_user_buffer_create(struct pipe_screen *screen,
+                       void *ptr,
+                       unsigned bytes)
+{
+   struct brw_buffer *buf;
+   
+   buf = CALLOC_STRUCT(brw_buffer);
+   if (!buf)
+      return NULL;
+      
+   buf->user_buffer = ptr;
+   
+   pipe_reference_init(&buf->base.reference, 1);
+   buf->base.screen = screen;
+   buf->base.alignment = 1;
+   buf->base.usage = 0;
+   buf->base.size = bytes;
+   
+   return &buf->base; 
+}
+
+
+boolean brw_is_buffer_referenced_by_bo( struct brw_screen *brw_screen,
+                                     struct pipe_buffer *buffer,
+                                     struct brw_winsys_buffer *bo )
+{
+   struct brw_buffer *buf = brw_buffer(buffer);
+   if (buf->bo == NULL)
+      return FALSE;
+
+   return brw_screen->sws->bo_references( bo, buf->bo );
+}
+
+   
+void brw_screen_buffer_init(struct brw_screen *brw_screen)
+{
+   brw_screen->base.buffer_create = brw_buffer_create;
+   brw_screen->base.user_buffer_create = brw_user_buffer_create;
+   brw_screen->base.buffer_map = brw_buffer_map;
+   brw_screen->base.buffer_map_range = brw_buffer_map_range;
+   brw_screen->base.buffer_flush_mapped_range = brw_buffer_flush_mapped_range;
+   brw_screen->base.buffer_unmap = brw_buffer_unmap;
+   brw_screen->base.buffer_destroy = brw_buffer_destroy;
+}
diff --git a/src/gallium/drivers/i965/brw_screen_surface.c b/src/gallium/drivers/i965/brw_screen_surface.c
new file mode 100644 (file)
index 0000000..e2b9954
--- /dev/null
@@ -0,0 +1,262 @@
+/*
+ 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 "util/u_memory.h"
+#include "util/u_simple_list.h"
+#include "util/u_math.h"
+
+#include "pipe/p_screen.h"
+#include "brw_screen.h"
+#include "brw_defines.h"
+#include "brw_winsys.h"
+
+enum {
+   BRW_VIEW_LINEAR,
+   BRW_VIEW_IN_PLACE
+};
+
+
+static boolean need_linear_view( struct brw_screen *brw_screen,
+                                struct brw_texture *brw_texture,
+                                union brw_surface_id id,
+                                unsigned usage )
+{
+#if 0
+   /* XXX: what about IDGNG?
+    */
+   if (!BRW_IS_G4X(brw->brw_screen->pci_id))
+   {
+      struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[i];
+      struct intel_renderbuffer *irb = intel_renderbuffer(rb);
+
+      /* The original gen4 hardware couldn't set up WM surfaces pointing
+       * at an offset within a tile, which can happen when rendering to
+       * anything but the base level of a texture or the +X face/0 depth.
+       * This was fixed with the 4 Series hardware.
+       *
+       * For these original chips, you would have to make the depth and
+       * color destination surfaces include information on the texture
+       * type, LOD, face, and various limits to use them as a destination.
+       *
+       * This is easy in Gallium as surfaces are all backed by
+       * textures, but there's also a nasty requirement that the depth
+       * and the color surfaces all be of the same LOD, which is
+       * harder to get around as we can't look at a surface in
+       * isolation and decide if it's legal.
+       *
+       * Instead, end up being pessimistic and say that for i965,
+       * ... ??
+       */
+      if (brw_tex->tiling != I915_TILING_NONE &&
+         (brw_tex_image_offset(brw_tex, face, level, zslize) & 4095)) {
+        if (BRW_DEBUG & DEBUG_VIEW)
+           debug_printf("%s: need surface view for non-aligned tex image\n",
+                        __FUNCTION__);
+        return GL_TRUE;
+      }
+   }
+#endif
+
+   /* Tiled 3d textures don't have subsets that look like 2d surfaces:
+    */
+   
+   /* Everything else should be fine to render to in-place:
+    */
+   return GL_FALSE;
+}
+
+/* Look at all texture views and figure out if any of them need to be
+ * back-copied into the texture for sampling
+ */
+void brw_update_texture( struct brw_screen *brw_screen,
+                        struct brw_texture *tex )
+{
+   /* currently nothing to do */
+}
+
+
+/* Create a new surface with linear layout to serve as a render-target
+ * where it would be illegal (perhaps due to tiling constraints) to do
+ * this in-place.
+ * 
+ * Currently not implmented, not sure if it's needed.
+ */
+static struct brw_surface *create_linear_view( struct brw_screen *brw_screen,
+                                              struct brw_texture *tex,
+                                              union brw_surface_id id,
+                                              unsigned usage )
+{
+   return NULL;
+}
+
+
+/* Create a pipe_surface that just points directly into the existing
+ * texture's storage.
+ */
+static struct brw_surface *create_in_place_view( struct brw_screen *brw_screen,
+                                                 struct brw_texture *tex,
+                                                 union brw_surface_id id,
+                                                 unsigned usage )
+{
+   struct brw_surface *surface;
+
+   surface = CALLOC_STRUCT(brw_surface);
+   if (surface == NULL)
+      return NULL;
+
+   pipe_reference_init(&surface->base.reference, 1);
+
+   /* XXX: ignoring render-to-slice-of-3d-texture
+    */
+   assert(id.bits.zslice == 0);
+
+   surface->base.format = tex->base.format;
+   surface->base.width = u_minify(tex->base.width0, id.bits.level);
+   surface->base.height = u_minify(tex->base.height0, id.bits.level);
+   surface->base.offset = tex->image_offset[id.bits.level][id.bits.face];
+   surface->base.usage = usage;
+   surface->base.zslice = id.bits.zslice;
+   surface->base.face = id.bits.face;
+   surface->base.level = id.bits.level;
+   surface->id = id;
+   surface->cpp = tex->cpp;
+   surface->pitch = tex->pitch;
+   surface->tiling = tex->tiling;
+
+   bo_reference( &surface->bo, tex->bo );
+   pipe_texture_reference( &surface->base.texture, &tex->base );
+
+   surface->ss.ss0.surface_format = tex->ss.ss0.surface_format;
+   surface->ss.ss0.surface_type = BRW_SURFACE_2D;
+
+   if (tex->tiling == BRW_TILING_NONE) {
+      surface->ss.ss1.base_addr = surface->base.offset;
+   } else {
+      uint32_t tile_offset = surface->base.offset % 4096;
+
+      surface->ss.ss1.base_addr = surface->base.offset - tile_offset;
+
+      if (brw_screen->chipset.is_g4x) {
+        if (tex->tiling == BRW_TILING_X) {
+           /* Note that the low bits of these fields are missing, so
+            * there's the possibility of getting in trouble.
+            */
+           surface->ss.ss5.x_offset = (tile_offset % 512) / tex->cpp / 4;
+           surface->ss.ss5.y_offset = tile_offset / 512 / 2;
+        } else {
+           surface->ss.ss5.x_offset = (tile_offset % 128) / tex->cpp / 4;
+           surface->ss.ss5.y_offset = tile_offset / 128 / 2;
+        }
+      }
+      else {
+        assert(tile_offset == 0);
+      }
+   }
+
+#if 0
+   if (region_bo != NULL)
+      surface->ss.ss1.base_addr += region_bo->offset; /* reloc */
+#endif
+
+   surface->ss.ss2.width = surface->base.width - 1;
+   surface->ss.ss2.height = surface->base.height - 1;
+   surface->ss.ss3.tiled_surface = tex->ss.ss3.tiled_surface;
+   surface->ss.ss3.tile_walk = tex->ss.ss3.tile_walk;
+   surface->ss.ss3.pitch = tex->ss.ss3.pitch;
+
+   return surface;
+}
+
+/* Get a surface which is view into a texture 
+ */
+static struct pipe_surface *brw_get_tex_surface(struct pipe_screen *screen,
+                                               struct pipe_texture *pt,
+                                               unsigned face, unsigned level,
+                                               unsigned zslice,
+                                               unsigned usage )
+{
+   struct brw_texture *tex = brw_texture(pt);
+   struct brw_screen *bscreen = brw_screen(screen);
+   struct brw_surface *surface;
+   union brw_surface_id id;
+   int type;
+
+   id.bits.face = face;
+   id.bits.level = level;
+   id.bits.zslice = zslice;
+
+   if (need_linear_view(bscreen, tex, id, usage)) 
+      type = BRW_VIEW_LINEAR;
+   else
+      type = BRW_VIEW_IN_PLACE;
+
+   
+   foreach (surface, &tex->views[type]) {
+      if (id.value == surface->id.value)
+        return &surface->base;
+   }
+
+   switch (type) {
+   case BRW_VIEW_LINEAR:
+      surface = create_linear_view( bscreen, tex, id, usage );
+      break;
+   case BRW_VIEW_IN_PLACE:
+      surface = create_in_place_view( bscreen, tex, id, usage );
+      break;
+   default:
+      return NULL;
+   }
+
+   insert_at_head( &tex->views[type], surface );
+   return &surface->base;
+}
+
+
+static void brw_tex_surface_destroy( struct pipe_surface *surf )
+{
+   struct brw_surface *surface = brw_surface(surf);
+
+   /* Unreference texture, shared buffer:
+    */
+   remove_from_list(surface);
+   bo_reference(&surface->bo, NULL);
+   pipe_texture_reference( &surface->base.texture, NULL );
+
+
+   FREE(surface);
+}
+
+
+void brw_screen_tex_surface_init( struct brw_screen *brw_screen )
+{
+   brw_screen->base.get_tex_surface = brw_get_tex_surface;
+   brw_screen->base.tex_surface_destroy = brw_tex_surface_destroy;
+}
diff --git a/src/gallium/drivers/i965/brw_screen_tex_layout.c b/src/gallium/drivers/i965/brw_screen_tex_layout.c
new file mode 100644 (file)
index 0000000..894f4be
--- /dev/null
@@ -0,0 +1,414 @@
+/*
+ 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.
+ **********************************************************************/
+
+#include "pipe/p_format.h"
+
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
+#include "brw_screen.h"
+#include "brw_debug.h"
+#include "brw_winsys.h"
+
+/* Code to layout images in a mipmap tree for i965.
+ */
+
+static int 
+brw_tex_pitch_align (struct brw_texture *tex,
+                    int pitch)
+{
+   if (!tex->compressed) {
+      int pitch_align;
+
+      switch (tex->tiling) {
+      case BRW_TILING_X:
+        pitch_align = 512;
+        break;
+      case BRW_TILING_Y:
+        pitch_align = 128;
+        break;
+      default:
+        /* XXX: Untiled pitch alignment of 64 bytes for now to allow
+         * render-to-texture to work in all cases. This should
+         * probably be replaced at some point by some scheme to only
+         * do this when really necessary, for example standalone
+         * render target views.
+         */
+        pitch_align = 64;
+        break;
+      }
+
+      pitch = align(pitch * tex->cpp, pitch_align);
+      pitch /= tex->cpp;
+   }
+
+   return pitch;
+}
+
+
+static void 
+brw_tex_alignment_unit(enum pipe_format pf, 
+                      GLuint *w, GLuint *h)
+{
+    switch (pf) {
+    case PIPE_FORMAT_DXT1_RGB:
+    case PIPE_FORMAT_DXT1_RGBA:
+    case PIPE_FORMAT_DXT3_RGBA:
+    case PIPE_FORMAT_DXT5_RGBA:
+    case PIPE_FORMAT_DXT1_SRGB:
+    case PIPE_FORMAT_DXT1_SRGBA:
+    case PIPE_FORMAT_DXT3_SRGBA:
+    case PIPE_FORMAT_DXT5_SRGBA:
+        *w = 4;
+        *h = 4;
+        break;
+
+    default:
+        *w = 4;
+        *h = 2;
+        break;
+    }
+}
+
+
+static void 
+brw_tex_set_level_info(struct brw_texture *tex,
+                      GLuint level,
+                      GLuint nr_images,
+                      GLuint x, GLuint y,
+                      GLuint w, GLuint h, GLuint d)
+{
+
+   if (BRW_DEBUG & DEBUG_TEXTURE)
+      debug_printf("%s level %d size: %d,%d,%d offset %d,%d (0x%x)\n", __FUNCTION__,
+                  level, w, h, d, x, y, tex->level_offset[level]);
+
+   assert(tex->image_offset[level] == NULL);
+   assert(nr_images >= 1);
+
+   tex->level_offset[level] = (x + y * tex->pitch) * tex->cpp;
+   tex->nr_images[level] = nr_images;
+
+   tex->image_offset[level] = MALLOC(nr_images * sizeof(GLuint));
+   tex->image_offset[level][0] = 0;
+}
+
+
+static void
+brw_tex_set_image_offset(struct brw_texture *tex,
+                        GLuint level, GLuint img,
+                        GLuint x, GLuint y, 
+                        GLuint offset)
+{
+   assert((x == 0 && y == 0) || img != 0 || level != 0);
+   assert(img < tex->nr_images[level]);
+
+   if (BRW_DEBUG & DEBUG_TEXTURE)
+      debug_printf("%s level %d img %d pos %d,%d image_offset %x\n",
+                  __FUNCTION__, level, img, x, y, 
+                  tex->image_offset[level][img]);
+
+   tex->image_offset[level][img] = (x + y * tex->pitch) * tex->cpp + offset;
+}
+
+
+
+static void brw_layout_2d( struct brw_texture *tex )
+{
+   GLuint align_h = 2, align_w = 4;
+   GLuint level;
+   GLuint x = 0;
+   GLuint y = 0;
+   GLuint width = tex->base.width0;
+   GLuint height = tex->base.height0;
+
+   tex->pitch = tex->base.width0;
+   brw_tex_alignment_unit(tex->base.format, &align_w, &align_h);
+
+   if (tex->compressed) {
+       tex->pitch = align(tex->base.width0, align_w);
+   }
+
+   /* May need to adjust pitch to accomodate the placement of
+    * the 2nd mipmap.  This occurs when the alignment
+    * constraints of mipmap placement push the right edge of the
+    * 2nd mipmap out past the width of its parent.
+    */
+   if (tex->base.last_level > 0) {
+       GLuint mip1_width;
+
+       if (tex->compressed) {
+          mip1_width = (align(u_minify(tex->base.width0, 1), align_w) + 
+                        align(u_minify(tex->base.width0, 2), align_w));
+       } else {
+          mip1_width = (align(u_minify(tex->base.width0, 1), align_w) + 
+                        u_minify(tex->base.width0, 2));
+       }
+
+       if (mip1_width > tex->pitch) {
+           tex->pitch = mip1_width;
+       }
+   }
+
+   /* Pitch must be a whole number of dwords, even though we
+    * express it in texels.
+    */
+   tex->pitch = brw_tex_pitch_align (tex, tex->pitch);
+   tex->total_height = 0;
+
+   for ( level = 0 ; level <= tex->base.last_level ; level++ ) {
+      GLuint img_height;
+
+      brw_tex_set_level_info(tex, level, 1, x, y, width, height, 1);
+
+      if (tex->compressed)
+        img_height = MAX2(1, height/4);
+      else
+        img_height = align(height, align_h);
+
+
+      /* Because the images are packed better, the final offset
+       * might not be the maximal one:
+       */
+      tex->total_height = MAX2(tex->total_height, y + img_height);
+
+      /* Layout_below: step right after second mipmap.
+       */
+      if (level == 1) {
+        x += align(width, align_w);
+      }
+      else {
+        y += img_height;
+      }
+
+      width  = u_minify(width, 1);
+      height = u_minify(height, 1);
+   }
+}
+
+
+static boolean 
+brw_layout_cubemap_idgng( struct brw_texture *tex )
+{
+   GLuint align_h = 2, align_w = 4;
+   GLuint level;
+   GLuint x = 0;
+   GLuint y = 0;
+   GLuint width = tex->base.width0;
+   GLuint height = tex->base.height0;
+   GLuint qpitch = 0;
+   GLuint y_pitch = 0;
+
+   tex->pitch = tex->base.width0;
+   brw_tex_alignment_unit(tex->base.format, &align_w, &align_h);
+   y_pitch = align(height, align_h);
+
+   if (tex->compressed) {
+      tex->pitch = align(tex->base.width0, align_w);
+   }
+
+   if (tex->base.last_level != 0) {
+      GLuint mip1_width;
+
+      if (tex->compressed) {
+        mip1_width = (align(u_minify(tex->base.width0, 1), align_w) +
+                      align(u_minify(tex->base.width0, 2), align_w));
+      } else {
+        mip1_width = (align(u_minify(tex->base.width0, 1), align_w) +
+                      u_minify(tex->base.width0, 2));
+      }
+
+      if (mip1_width > tex->pitch) {
+        tex->pitch = mip1_width;
+      }
+   }
+
+   tex->pitch = brw_tex_pitch_align(tex, tex->pitch);
+
+   if (tex->compressed) {
+      qpitch = ((y_pitch + 
+                align(u_minify(y_pitch, 1), align_h) +
+                11 * align_h) / 4) * tex->pitch * tex->cpp;
+
+      tex->total_height = ((y_pitch + 
+                           align(u_minify(y_pitch, 1), align_h) + 
+                           11 * align_h) / 4) * 6;
+   } else {
+      qpitch = (y_pitch + 
+               align(u_minify(y_pitch, 1), align_h) + 
+               11 * align_h) * tex->pitch * tex->cpp;
+
+      tex->total_height = (y_pitch +
+                          align(u_minify(y_pitch, 1), align_h) +
+                          11 * align_h) * 6;
+   }
+
+   for (level = 0; level <= tex->base.last_level; level++) {
+      GLuint img_height;
+      GLuint nr_images = 6;
+      GLuint q = 0;
+
+      brw_tex_set_level_info(tex, level, nr_images, x, y, width, height, 1);
+
+      for (q = 0; q < nr_images; q++)
+        brw_tex_set_image_offset(tex, level, q, x, y, q * qpitch);
+
+      if (tex->compressed)
+        img_height = MAX2(1, height/4);
+      else
+        img_height = align(height, align_h);
+
+      if (level == 1) {
+        x += align(width, align_w);
+      }
+      else {
+        y += img_height;
+      }
+
+      width  = u_minify(width, 1);
+      height = u_minify(height, 1);
+   }
+
+   return TRUE;
+}
+
+
+static boolean
+brw_layout_3d_cube( struct brw_texture *tex )
+{
+   GLuint width  = tex->base.width0;
+   GLuint height = tex->base.height0;
+   GLuint depth = tex->base.depth0;
+   GLuint pack_x_pitch, pack_x_nr;
+   GLuint pack_y_pitch;
+   GLuint level;
+   GLuint align_h = 2;
+   GLuint align_w = 4;
+
+   tex->total_height = 0;
+   brw_tex_alignment_unit(tex->base.format, &align_w, &align_h);
+
+   if (tex->compressed) {
+      tex->pitch = align(width, align_w);
+      pack_y_pitch = (height + 3) / 4;
+   } else {
+      tex->pitch = brw_tex_pitch_align(tex, tex->base.width0);
+      pack_y_pitch = align(tex->base.height0, align_h);
+   }
+
+   pack_x_pitch = width;
+   pack_x_nr = 1;
+
+   for (level = 0 ; level <= tex->base.last_level ; level++) {
+      GLuint nr_images = tex->base.target == PIPE_TEXTURE_3D ? depth : 6;
+      GLint x = 0;
+      GLint y = 0;
+      GLint q, j;
+
+      brw_tex_set_level_info(tex, level, nr_images,
+                                  0, tex->total_height,
+                                  width, height, depth);
+
+      for (q = 0; q < nr_images;) {
+        for (j = 0; j < pack_x_nr && q < nr_images; j++, q++) {
+           brw_tex_set_image_offset(tex, level, q, x, y, 0);
+           x += pack_x_pitch;
+        }
+
+        x = 0;
+        y += pack_y_pitch;
+      }
+
+
+      tex->total_height += y;
+      width  = u_minify(width, 1);
+      height = u_minify(height, 1);
+      depth  = u_minify(depth, 1);
+
+      if (tex->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 <= tex->pitch);
+        }
+
+        if (pack_y_pitch > 2) {
+           pack_y_pitch >>= 1;
+           pack_y_pitch = align(pack_y_pitch, align_h);
+        }
+      }
+   }
+
+   /* The 965's sampler lays cachelines out according to how accesses
+    * in the texture surfaces run, so they may be "vertical" through
+    * memory.  As a result, the docs say in Surface Padding Requirements:
+    * Sampling Engine Surfaces that two extra rows of padding are required.
+    */
+   if (tex->base.target == PIPE_TEXTURE_CUBE)
+      tex->total_height += 2;
+
+   return TRUE;
+}
+
+
+
+GLboolean brw_texture_layout(struct brw_screen *brw_screen,
+                            struct brw_texture *tex )
+{
+   switch (tex->base.target) {
+   case PIPE_TEXTURE_CUBE:
+      if (brw_screen->chipset.is_igdng)
+        brw_layout_cubemap_idgng( tex );
+      else
+        brw_layout_3d_cube( tex );
+      break;
+           
+   case PIPE_TEXTURE_3D:
+      brw_layout_3d_cube( tex );
+      break;
+
+   default:
+      brw_layout_2d( tex );
+      break;
+   }
+
+   if (BRW_DEBUG & DEBUG_TEXTURE)
+      debug_printf("%s: %dx%dx%d - sz 0x%x\n", __FUNCTION__,
+                  tex->pitch,
+                  tex->total_height,
+                  tex->cpp,
+                  tex->pitch * tex->total_height * tex->cpp );
+
+   return GL_TRUE;
+}
diff --git a/src/gallium/drivers/i965/brw_screen_texture.c b/src/gallium/drivers/i965/brw_screen_texture.c
new file mode 100644 (file)
index 0000000..feb9d5f
--- /dev/null
@@ -0,0 +1,573 @@
+/*
+ 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 "util/u_memory.h"
+#include "util/u_simple_list.h"
+#include "util/u_format.h"
+
+#include "brw_screen.h"
+#include "brw_defines.h"
+#include "brw_structs.h"
+#include "brw_winsys.h"
+
+
+
+static GLuint translate_tex_target( unsigned target )
+{
+   switch (target) {
+   case PIPE_TEXTURE_1D: 
+      return BRW_SURFACE_1D;
+
+   case PIPE_TEXTURE_2D: 
+      return BRW_SURFACE_2D;
+
+   case PIPE_TEXTURE_3D: 
+      return BRW_SURFACE_3D;
+
+   case PIPE_TEXTURE_CUBE:
+      return BRW_SURFACE_CUBE;
+
+   default: 
+      assert(0); 
+      return BRW_SURFACE_1D;
+   }
+}
+
+
+static GLuint translate_tex_format( enum pipe_format pf )
+{
+   switch( pf ) {
+   case PIPE_FORMAT_L8_UNORM:
+      return BRW_SURFACEFORMAT_L8_UNORM;
+
+   case PIPE_FORMAT_I8_UNORM:
+      return BRW_SURFACEFORMAT_I8_UNORM;
+
+   case PIPE_FORMAT_A8_UNORM:
+      return BRW_SURFACEFORMAT_A8_UNORM; 
+
+   case PIPE_FORMAT_L16_UNORM:
+      return BRW_SURFACEFORMAT_L16_UNORM;
+
+      /* XXX: Add these to gallium
+   case PIPE_FORMAT_I16_UNORM:
+      return BRW_SURFACEFORMAT_I16_UNORM;
+
+   case PIPE_FORMAT_A16_UNORM:
+      return BRW_SURFACEFORMAT_A16_UNORM; 
+      */
+
+   case PIPE_FORMAT_A8L8_UNORM:
+      return BRW_SURFACEFORMAT_L8A8_UNORM;
+
+   case PIPE_FORMAT_R5G6B5_UNORM:
+      return BRW_SURFACEFORMAT_B5G6R5_UNORM;
+
+   case PIPE_FORMAT_A1R5G5B5_UNORM:
+      return BRW_SURFACEFORMAT_B5G5R5A1_UNORM;
+
+   case PIPE_FORMAT_A4R4G4B4_UNORM:
+      return BRW_SURFACEFORMAT_B4G4R4A4_UNORM;
+
+   case PIPE_FORMAT_X8R8G8B8_UNORM:
+      return BRW_SURFACEFORMAT_R8G8B8X8_UNORM;
+
+   case PIPE_FORMAT_A8R8G8B8_UNORM:
+      return BRW_SURFACEFORMAT_B8G8R8A8_UNORM;
+
+   /*
+    * Video formats
+    */
+
+   case PIPE_FORMAT_YCBCR_REV:
+      return BRW_SURFACEFORMAT_YCRCB_NORMAL;
+
+   case PIPE_FORMAT_YCBCR:
+      return BRW_SURFACEFORMAT_YCRCB_SWAPUVY;
+
+   /*
+    * Compressed formats.
+    */
+      /* XXX: Add FXT to gallium?
+   case PIPE_FORMAT_FXT1_RGBA:
+      return BRW_SURFACEFORMAT_FXT1;
+      */
+
+   case PIPE_FORMAT_DXT1_RGB:
+       return BRW_SURFACEFORMAT_DXT1_RGB;
+
+   case PIPE_FORMAT_DXT1_RGBA:
+       return BRW_SURFACEFORMAT_BC1_UNORM;
+       
+   case PIPE_FORMAT_DXT3_RGBA:
+       return BRW_SURFACEFORMAT_BC2_UNORM;
+       
+   case PIPE_FORMAT_DXT5_RGBA:
+       return BRW_SURFACEFORMAT_BC3_UNORM;
+
+   /*
+    * sRGB formats
+    */
+
+   case PIPE_FORMAT_R8G8B8A8_SRGB:
+      return BRW_SURFACEFORMAT_B8G8R8A8_UNORM_SRGB;
+
+   case PIPE_FORMAT_A8L8_SRGB:
+      return BRW_SURFACEFORMAT_L8A8_UNORM_SRGB;
+
+   case PIPE_FORMAT_L8_SRGB:
+      return BRW_SURFACEFORMAT_L8_UNORM_SRGB;
+
+   case PIPE_FORMAT_DXT1_SRGB:
+      return BRW_SURFACEFORMAT_BC1_UNORM_SRGB;
+
+   /*
+    * Depth formats
+    */
+
+   case PIPE_FORMAT_Z16_UNORM:
+         return BRW_SURFACEFORMAT_I16_UNORM;
+
+   case PIPE_FORMAT_S8Z24_UNORM:
+   case PIPE_FORMAT_X8Z24_UNORM:
+         return BRW_SURFACEFORMAT_I24X8_UNORM;
+
+   case PIPE_FORMAT_Z32_FLOAT:
+         return BRW_SURFACEFORMAT_I32_FLOAT;
+
+      /* XXX: presumably for bump mapping.  Add this to mesa state
+       * tracker?
+       *
+       * XXX: Add flipped versions of these formats to Gallium.
+       */
+   case PIPE_FORMAT_R8G8_SNORM:
+      return BRW_SURFACEFORMAT_R8G8_SNORM;
+
+   case PIPE_FORMAT_R8G8B8A8_SNORM:
+      return BRW_SURFACEFORMAT_R8G8B8A8_SNORM;
+
+   default:
+      return BRW_SURFACEFORMAT_INVALID;
+   }
+}
+
+
+
+
+
+static struct pipe_texture *brw_texture_create( struct pipe_screen *screen,
+                                               const struct pipe_texture *templ )
+
+{  
+   struct brw_screen *bscreen = brw_screen(screen);
+   struct brw_texture *tex;
+   enum brw_buffer_type buffer_type;
+   enum pipe_error ret;
+   
+   tex = CALLOC_STRUCT(brw_texture);
+   if (tex == NULL)
+      return NULL;
+
+   memcpy(&tex->base, templ, sizeof *templ);
+   pipe_reference_init(&tex->base.reference, 1);
+   tex->base.screen = screen;
+
+   /* XXX: compressed textures need special treatment here
+    */
+   tex->cpp = util_format_get_blocksize(tex->base.format);
+   tex->compressed = util_format_is_compressed(tex->base.format);
+
+   make_empty_list(&tex->views[0]);
+   make_empty_list(&tex->views[1]);
+
+   /* XXX: No tiling with compressed textures??
+    */
+   if (tex->compressed == 0 &&
+       !bscreen->no_tiling) 
+   {
+      if (bscreen->chipset.is_965 &&
+         util_format_is_depth_or_stencil(templ->format))
+        tex->tiling = BRW_TILING_Y;
+      else
+        tex->tiling = BRW_TILING_X;
+   } 
+   else {
+      tex->tiling = BRW_TILING_NONE;
+   }
+
+
+
+
+   if (!brw_texture_layout( bscreen, tex ))
+      goto fail;
+
+   
+   if (templ->tex_usage & (PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
+                           PIPE_TEXTURE_USAGE_PRIMARY)) {
+      buffer_type = BRW_BUFFER_TYPE_SCANOUT;
+   }
+   else {
+      buffer_type = BRW_BUFFER_TYPE_TEXTURE;
+   }
+
+   ret = bscreen->sws->bo_alloc( bscreen->sws,
+                                 buffer_type,
+                                 tex->pitch * tex->total_height * tex->cpp,
+                                 64,
+                                 &tex->bo );
+   if (ret)
+      goto fail;
+
+   tex->ss.ss0.mipmap_layout_mode = BRW_SURFACE_MIPMAPLAYOUT_BELOW;
+   tex->ss.ss0.surface_type = translate_tex_target(tex->base.target);
+   tex->ss.ss0.surface_format = translate_tex_format(tex->base.format);
+   assert(tex->ss.ss0.surface_format != BRW_SURFACEFORMAT_INVALID);
+
+   /* This is ok for all textures with channel width 8bit or less:
+    */
+/*    tex->ss.ss0.data_return_format = BRW_SURFACERETURNFORMAT_S1; */
+
+
+   /* XXX: what happens when tex->bo->offset changes???
+    */
+   tex->ss.ss1.base_addr = 0; /* reloc */
+   tex->ss.ss2.mip_count = tex->base.last_level;
+   tex->ss.ss2.width = tex->base.width0 - 1;
+   tex->ss.ss2.height = tex->base.height0 - 1;
+
+   switch (tex->tiling) {
+   case BRW_TILING_NONE:
+      tex->ss.ss3.tiled_surface = 0;
+      tex->ss.ss3.tile_walk = 0;
+      break;
+   case BRW_TILING_X:
+      tex->ss.ss3.tiled_surface = 1;
+      tex->ss.ss3.tile_walk = BRW_TILEWALK_XMAJOR;
+      break;
+   case BRW_TILING_Y:
+      tex->ss.ss3.tiled_surface = 1;
+      tex->ss.ss3.tile_walk = BRW_TILEWALK_YMAJOR;
+      break;
+   }
+
+   tex->ss.ss3.pitch = (tex->pitch * tex->cpp) - 1;
+   tex->ss.ss3.depth = tex->base.depth0 - 1;
+
+   tex->ss.ss4.min_lod = 0;
+   if (tex->base.target == PIPE_TEXTURE_CUBE) {
+      tex->ss.ss0.cube_pos_x = 1;
+      tex->ss.ss0.cube_pos_y = 1;
+      tex->ss.ss0.cube_pos_z = 1;
+      tex->ss.ss0.cube_neg_x = 1;
+      tex->ss.ss0.cube_neg_y = 1;
+      tex->ss.ss0.cube_neg_z = 1;
+   }
+
+   return &tex->base;
+
+fail:
+   bo_reference(&tex->bo, NULL);
+   FREE(tex);
+   return NULL;
+}
+
+static struct pipe_texture *brw_texture_blanket(struct pipe_screen *screen,
+                                               const struct pipe_texture *templ,
+                                               const unsigned *stride,
+                                               struct pipe_buffer *buffer)
+{
+   return NULL;
+}
+
+static void brw_texture_destroy(struct pipe_texture *pt)
+{
+   struct brw_texture *tex = brw_texture(pt);
+   bo_reference(&tex->bo, NULL);
+   FREE(pt);
+}
+
+
+static boolean brw_is_format_supported( struct pipe_screen *screen,
+                                       enum pipe_format format,
+                                       enum pipe_texture_target target,
+                                       unsigned tex_usage, 
+                                       unsigned geom_flags )
+{
+   return translate_tex_format(format) != BRW_SURFACEFORMAT_INVALID;
+}
+
+
+boolean brw_is_texture_referenced_by_bo( struct brw_screen *brw_screen,
+                                      struct pipe_texture *texture,
+                                      unsigned face, 
+                                      unsigned level,
+                                      struct brw_winsys_buffer *bo )
+{
+   struct brw_texture *tex = brw_texture(texture);
+   struct brw_surface *surf;
+   int i;
+
+   /* XXX: this is subject to false positives if the underlying
+    * texture BO is referenced, we can't tell whether the sub-region
+    * we care about participates in that.
+    */
+   if (brw_screen->sws->bo_references( bo, tex->bo ))
+      return TRUE;
+
+   /* Find any view on this texture for this face/level and see if it
+    * is referenced:
+    */
+   for (i = 0; i < 2; i++) {
+      foreach (surf, &tex->views[i]) {
+         if (surf->bo == tex->bo)
+            continue;
+
+         if (surf->id.bits.face != face ||
+             surf->id.bits.level != level)
+            continue;
+         
+         if (brw_screen->sws->bo_references( bo, surf->bo))
+            return TRUE;
+      }
+   }
+
+   return FALSE;
+}
+
+
+/*
+ * Transfer functions
+ */
+
+static struct pipe_transfer*
+brw_get_tex_transfer(struct pipe_screen *screen,
+                     struct pipe_texture *texture,
+                     unsigned face, unsigned level, unsigned zslice,
+                     enum pipe_transfer_usage usage, unsigned x, unsigned y,
+                     unsigned w, unsigned h)
+{
+   struct brw_texture *tex = brw_texture(texture);
+   struct brw_transfer *trans;
+   unsigned offset;  /* in bytes */
+
+   if (texture->target == PIPE_TEXTURE_CUBE) {
+      offset = tex->image_offset[level][face];
+   } else if (texture->target == PIPE_TEXTURE_3D) {
+      offset = tex->image_offset[level][zslice];
+   } else {
+      offset = tex->image_offset[level][0];
+      assert(face == 0);
+      assert(zslice == 0);
+   }
+
+   trans = CALLOC_STRUCT(brw_transfer);
+   if (trans) {
+      pipe_texture_reference(&trans->base.texture, texture);
+      trans->base.x = x;
+      trans->base.y = y;
+      trans->base.width = w;
+      trans->base.height = h;
+      trans->base.stride = tex->pitch * tex->cpp;
+      trans->offset = offset;
+      trans->base.usage = usage;
+   }
+   return &trans->base;
+}
+
+static void *
+brw_transfer_map(struct pipe_screen *screen,
+                 struct pipe_transfer *transfer)
+{
+   struct brw_texture *tex = brw_texture(transfer->texture);
+   struct brw_winsys_screen *sws = brw_screen(screen)->sws;
+   char *map;
+   unsigned usage = transfer->usage;
+
+   map = sws->bo_map(tex->bo, 
+                     BRW_DATA_OTHER,
+                     0,
+                     tex->bo->size,
+                     (usage & PIPE_TRANSFER_WRITE) ? TRUE : FALSE,
+                     (usage & 0) ? TRUE : FALSE,
+                     (usage & 0) ? TRUE : FALSE);
+
+   if (!map)
+      return NULL;
+
+   /* XXX: blocksize and compressed textures
+    */
+   return map + brw_transfer(transfer)->offset +
+      transfer->y /* / transfer->block.height */ * transfer->stride +
+      transfer->x /* / transfer->block.width */ * brw_texture(transfer->texture)->cpp;
+}
+
+static void
+brw_transfer_unmap(struct pipe_screen *screen,
+                   struct pipe_transfer *transfer)
+{
+   struct brw_texture *tex = brw_texture(transfer->texture);
+   struct brw_winsys_screen *sws = brw_screen(screen)->sws;
+
+   sws->bo_unmap(tex->bo);
+}
+
+static void
+brw_tex_transfer_destroy(struct pipe_transfer *trans)
+{
+   pipe_texture_reference(&trans->texture, NULL);
+   FREE(trans);
+}
+
+
+/*
+ * Functions exported to the winsys
+ */
+
+boolean brw_texture_get_winsys_buffer(struct pipe_texture *texture,
+                                      struct brw_winsys_buffer **buffer,
+                                      unsigned *stride)
+{
+   struct brw_texture *tex = brw_texture(texture);
+
+   *buffer = tex->bo;
+   if (stride)
+      *stride = tex->pitch * tex->cpp;
+
+   return TRUE;
+}
+
+struct pipe_texture * 
+brw_texture_blanket_winsys_buffer(struct pipe_screen *screen,
+                                  const struct pipe_texture *templ,
+                                  unsigned pitch,
+                                 unsigned tiling,
+                                  struct brw_winsys_buffer *buffer)
+{
+   struct brw_screen *bscreen = brw_screen(screen);
+   struct brw_texture *tex;
+
+   if (templ->target != PIPE_TEXTURE_2D ||
+       templ->last_level != 0 ||
+       templ->depth0 != 1)
+      return NULL;
+
+   if (util_format_is_compressed(templ->format))
+      return NULL;
+
+   tex = CALLOC_STRUCT(brw_texture);
+   if (!tex)
+      return NULL;
+
+   memcpy(&tex->base, templ, sizeof *templ);
+   pipe_reference_init(&tex->base.reference, 1);
+   tex->base.screen = screen;
+
+   /* XXX: cpp vs. blocksize
+    */
+   tex->cpp = util_format_get_blocksize(tex->base.format);
+   tex->tiling = tiling;
+
+   make_empty_list(&tex->views[0]);
+   make_empty_list(&tex->views[1]);
+
+   if (!brw_texture_layout(bscreen, tex))
+      goto fail;
+
+   /* XXX Maybe some more checks? */
+   if ((pitch / tex->cpp) < tex->pitch)
+      goto fail;
+
+   tex->pitch = pitch / tex->cpp;
+
+   tex->bo = buffer;
+
+   /* fix this warning */
+#if 0
+   if (tex->size > buffer->size)
+      goto fail;
+#endif
+
+   tex->ss.ss0.mipmap_layout_mode = BRW_SURFACE_MIPMAPLAYOUT_BELOW;
+   tex->ss.ss0.surface_type = translate_tex_target(tex->base.target);
+   tex->ss.ss0.surface_format = translate_tex_format(tex->base.format);
+   assert(tex->ss.ss0.surface_format != BRW_SURFACEFORMAT_INVALID);
+
+   /* This is ok for all textures with channel width 8bit or less:
+    */
+/*    tex->ss.ss0.data_return_format = BRW_SURFACERETURNFORMAT_S1; */
+
+
+   /* XXX: what happens when tex->bo->offset changes???
+    */
+   tex->ss.ss1.base_addr = 0; /* reloc */
+   tex->ss.ss2.mip_count = tex->base.last_level;
+   tex->ss.ss2.width = tex->base.width0 - 1;
+   tex->ss.ss2.height = tex->base.height0 - 1;
+
+   switch (tex->tiling) {
+   case BRW_TILING_NONE:
+      tex->ss.ss3.tiled_surface = 0;
+      tex->ss.ss3.tile_walk = 0;
+      break;
+   case BRW_TILING_X:
+      tex->ss.ss3.tiled_surface = 1;
+      tex->ss.ss3.tile_walk = BRW_TILEWALK_XMAJOR;
+      break;
+   case BRW_TILING_Y:
+      tex->ss.ss3.tiled_surface = 1;
+      tex->ss.ss3.tile_walk = BRW_TILEWALK_YMAJOR;
+      break;
+   }
+
+   tex->ss.ss3.pitch = (tex->pitch * tex->cpp) - 1;
+   tex->ss.ss3.depth = tex->base.depth0 - 1;
+
+   tex->ss.ss4.min_lod = 0;
+
+   return &tex->base;
+
+fail:
+   FREE(tex);
+   return NULL;
+}
+
+void brw_screen_tex_init( struct brw_screen *brw_screen )
+{
+   brw_screen->base.is_format_supported = brw_is_format_supported;
+   brw_screen->base.texture_create = brw_texture_create;
+   brw_screen->base.texture_destroy = brw_texture_destroy;
+   brw_screen->base.texture_blanket = brw_texture_blanket;
+   brw_screen->base.get_tex_transfer = brw_get_tex_transfer;
+   brw_screen->base.transfer_map = brw_transfer_map;
+   brw_screen->base.transfer_unmap = brw_transfer_unmap;
+   brw_screen->base.tex_transfer_destroy = brw_tex_transfer_destroy;
+}
diff --git a/src/gallium/drivers/i965/brw_sf.c b/src/gallium/drivers/i965/brw_sf.c
new file mode 100644 (file)
index 0000000..e1986a9
--- /dev/null
@@ -0,0 +1,216 @@
+/*
+ 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 "pipe/p_state.h"
+
+#include "brw_batchbuffer.h"
+#include "brw_defines.h"
+#include "brw_context.h"
+#include "brw_pipe_rast.h"
+#include "brw_eu.h"
+#include "brw_util.h"
+#include "brw_sf.h"
+#include "brw_state.h"
+
+static enum pipe_error compile_sf_prog( struct brw_context *brw,
+                                        struct brw_sf_prog_key *key,
+                                        struct brw_winsys_buffer **bo_out )
+{
+   enum pipe_error ret;
+   struct brw_sf_compile c;
+   const GLuint *program;
+   GLuint program_size;
+
+   memset(&c, 0, sizeof(c));
+
+   /* Begin the compilation:
+    */
+   brw_init_compile(brw, &c.func);
+
+   c.key = *key;
+   c.nr_attrs = c.key.nr_attrs;
+   c.nr_attr_regs = (c.nr_attrs+1)/2;
+   c.nr_setup_attrs = c.key.nr_attrs;
+   c.nr_setup_regs = (c.nr_setup_attrs+1)/2;
+
+   c.prog_data.urb_read_length = c.nr_attr_regs;
+   c.prog_data.urb_entry_size = c.nr_setup_regs * 2;
+
+   /* Special case when there are no attributes to setup.
+    *
+    * XXX: should be able to set nr_setup_attrs to nr_attrs-1 -- but
+    * breaks vp-tris.c
+    */
+   if (c.nr_attrs - 1 == 0) {
+      c.nr_verts = 0;
+      brw_emit_null_setup( &c );
+   }
+   else {
+      /* Which primitive?  Or all three? 
+       */
+      switch (key->primitive) {
+      case SF_TRIANGLES:
+         c.nr_verts = 3;
+         brw_emit_tri_setup( &c, GL_TRUE );
+         break;
+      case SF_LINES:
+         c.nr_verts = 2;
+         brw_emit_line_setup( &c, GL_TRUE );
+         break;
+      case SF_POINTS:
+         c.nr_verts = 1;
+         if (key->do_point_sprite)
+            brw_emit_point_sprite_setup( &c, GL_TRUE );
+         else
+            brw_emit_point_setup( &c, GL_TRUE );
+         break;
+      case SF_UNFILLED_TRIS:
+         c.nr_verts = 3;
+         brw_emit_anyprim_setup( &c );
+         break;
+      default:
+         assert(0);
+         return PIPE_ERROR_BAD_INPUT;
+      }
+   }
+
+   /* get the program
+    */
+   ret = brw_get_program(&c.func, &program, &program_size);
+   if (ret)
+      return ret;
+
+   /* Upload
+    */
+   ret = brw_upload_cache( &brw->cache, BRW_SF_PROG,
+                           &c.key, sizeof(c.key),
+                           NULL, 0,
+                           program, program_size,
+                           &c.prog_data,
+                           &brw->sf.prog_data,
+                           bo_out);
+   if (ret)
+      return ret;
+
+   return PIPE_OK;
+}
+
+/* Calculate interpolants for triangle and line rasterization.
+ */
+static enum pipe_error upload_sf_prog(struct brw_context *brw)
+{
+   const struct brw_fs_signature *sig = &brw->curr.fragment_shader->signature;
+   struct brw_sf_prog_key key;
+   enum pipe_error ret;
+   unsigned i;
+
+   memset(&key, 0, sizeof(key));
+
+   /* Populate the key, noting state dependencies:
+    */
+
+   /* XXX: Add one to account for the position input.
+    */
+   /* PIPE_NEW_FRAGMENT_SIGNATURE */
+   key.nr_attrs = sig->nr_inputs + 1;
+
+
+   /* XXX: why is position required to be linear?  why do we care
+    * about it at all?
+    */
+   key.linear_attrs = 1;        /* position -- but why? */
+
+   for (i = 0; i < sig->nr_inputs; i++) {
+      switch (sig->input[i].interp) {
+      case TGSI_INTERPOLATE_CONSTANT:
+         break;
+      case TGSI_INTERPOLATE_LINEAR:
+         key.linear_attrs |= 1 << (i+1);
+         break;
+      case TGSI_INTERPOLATE_PERSPECTIVE:
+         key.persp_attrs |= 1 << (i+1);
+         break;
+      }
+   }
+
+   /* BRW_NEW_REDUCED_PRIMITIVE */
+   switch (brw->reduced_primitive) {
+   case PIPE_PRIM_TRIANGLES: 
+      /* PIPE_NEW_RAST
+       */
+      if (brw->curr.rast->templ.fill_cw != PIPE_POLYGON_MODE_FILL ||
+         brw->curr.rast->templ.fill_ccw != PIPE_POLYGON_MODE_FILL)
+        key.primitive = SF_UNFILLED_TRIS;
+      else
+        key.primitive = SF_TRIANGLES;
+      break;
+   case PIPE_PRIM_LINES: 
+      key.primitive = SF_LINES; 
+      break;
+   case PIPE_PRIM_POINTS: 
+      key.primitive = SF_POINTS; 
+      break;
+   }
+
+   key.do_point_sprite = brw->curr.rast->templ.point_sprite;
+   key.sprite_origin_lower_left = 0; /* XXX: ctx->Point.SpriteOrigin - fix rast state */
+   key.do_flat_shading = brw->curr.rast->templ.flatshade;
+   key.do_twoside_color = brw->curr.rast->templ.light_twoside;
+
+   if (key.do_twoside_color) {
+      key.frontface_ccw = (brw->curr.rast->templ.front_winding == 
+                          PIPE_WINDING_CCW);
+   }
+
+   if (brw_search_cache(&brw->cache, BRW_SF_PROG,
+                        &key, sizeof(key),
+                        NULL, 0,
+                        &brw->sf.prog_data,
+                        &brw->sf.prog_bo))
+      return PIPE_OK;
+
+   ret = compile_sf_prog( brw, &key, &brw->sf.prog_bo );
+   if (ret)
+      return ret;
+
+   return PIPE_OK;
+}
+
+
+const struct brw_tracked_state brw_sf_prog = {
+   .dirty = {
+      .mesa  = (PIPE_NEW_RAST | PIPE_NEW_FRAGMENT_SIGNATURE),
+      .brw   = (BRW_NEW_REDUCED_PRIMITIVE),
+      .cache = 0
+   },
+   .prepare = upload_sf_prog
+};
+
diff --git a/src/gallium/drivers/i965/brw_sf.h b/src/gallium/drivers/i965/brw_sf.h
new file mode 100644 (file)
index 0000000..a895c7d
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ Copyright (C) Intel Corp.  2006.  All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ **********************************************************************/
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  */
+   
+
+#ifndef BRW_SF_H
+#define BRW_SF_H
+
+
+#include "brw_context.h"
+#include "brw_eu.h"
+
+
+#define SF_POINTS    0
+#define SF_LINES     1
+#define SF_TRIANGLES 2
+#define SF_UNFILLED_TRIS   3
+
+struct brw_sf_prog_key {
+
+   /* Bitmask of linear and perspective interpolated inputs, 0..nr
+    */
+   GLuint persp_attrs:32;
+   GLuint linear_attrs:32;
+   GLuint point_coord_replace_attrs:32;
+
+   GLuint nr_attrs:8;
+   GLuint primitive:2;
+   GLuint do_twoside_color:1;
+   GLuint do_flat_shading:1;
+   GLuint frontface_ccw:1;
+   GLuint do_point_sprite:1;
+   GLuint sprite_origin_lower_left:1;
+   GLuint pad:17;
+
+   GLuint attr_col0:8;
+   GLuint attr_col1:8;
+   GLuint attr_bfc0:8;
+   GLuint attr_bfc1:8;
+};
+
+struct brw_sf_point_tex {
+   GLboolean CoordReplace;     
+};
+
+struct brw_sf_compile {
+   struct brw_compile func;
+   struct brw_sf_prog_key key;
+   struct brw_sf_prog_data prog_data;
+   
+   struct brw_reg pv;
+   struct brw_reg det;
+   struct brw_reg dx0;
+   struct brw_reg dx2;
+   struct brw_reg dy0;
+   struct brw_reg dy2;
+
+   /* z and 1/w passed in seperately:
+    */
+   struct brw_reg z[3];
+   struct brw_reg inv_w[3];
+   
+   /* The vertices:
+    */
+   struct brw_reg vert[3];
+
+    /* Temporaries, allocated after last vertex reg.
+    */
+   struct brw_reg inv_det;
+   struct brw_reg a1_sub_a0;
+   struct brw_reg a2_sub_a0;
+   struct brw_reg tmp;
+
+   struct brw_reg m1Cx;
+   struct brw_reg m2Cy;
+   struct brw_reg m3C0;
+
+   GLuint nr_verts;
+   GLuint nr_attrs;
+   GLuint nr_attr_regs;
+   GLuint nr_setup_attrs;
+   GLuint nr_setup_regs;
+
+   GLuint point_coord_replace_mask;
+};
+
+void brw_emit_null_setup( struct brw_sf_compile *c );
+void brw_emit_tri_setup( struct brw_sf_compile *c, GLboolean allocate );
+void brw_emit_line_setup( struct brw_sf_compile *c, GLboolean allocate );
+void brw_emit_point_setup( struct brw_sf_compile *c, GLboolean allocate );
+void brw_emit_point_sprite_setup( struct brw_sf_compile *c, GLboolean allocate );
+void brw_emit_anyprim_setup( struct brw_sf_compile *c );
+
+#endif
diff --git a/src/gallium/drivers/i965/brw_sf_emit.c b/src/gallium/drivers/i965/brw_sf_emit.c
new file mode 100644 (file)
index 0000000..3b85725
--- /dev/null
@@ -0,0 +1,765 @@
+/*
+ Copyright (C) Intel Corp.  2006.  All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ **********************************************************************/
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  */
+   
+
+#include "brw_batchbuffer.h"
+
+#include "brw_defines.h"
+#include "brw_context.h"
+#include "brw_eu.h"
+#include "brw_util.h"
+#include "brw_sf.h"
+
+
+static struct brw_reg get_vert_attr(struct brw_sf_compile *c,
+                                   struct brw_reg vert,
+                                   GLuint attr)
+{
+   GLuint off = attr / 2;
+   GLuint sub = attr % 2;
+
+   return brw_vec4_grf(vert.nr + off, sub * 4);
+}
+
+
+/*********************************************************************** 
+ * Twoside lighting
+ */
+static void copy_bfc( struct brw_sf_compile *c,
+                     struct brw_reg vert )
+{
+   struct brw_compile *p = &c->func;
+
+   if (c->key.attr_col0 && c->key.attr_bfc0)
+      brw_MOV(p, 
+             get_vert_attr(c, vert, c->key.attr_col0), 
+             get_vert_attr(c, vert, c->key.attr_bfc0));
+
+   if (c->key.attr_col1 && c->key.attr_bfc1)
+      brw_MOV(p, 
+             get_vert_attr(c, vert, c->key.attr_col1), 
+             get_vert_attr(c, vert, c->key.attr_bfc1));
+}
+
+
+static void do_twoside_color( struct brw_sf_compile *c )
+{
+   struct brw_compile *p = &c->func;
+   struct brw_instruction *if_insn;
+   GLuint backface_conditional = c->key.frontface_ccw ? BRW_CONDITIONAL_G : BRW_CONDITIONAL_L;
+
+   /* Already done in clip program:
+    */
+   if (c->key.primitive == SF_UNFILLED_TRIS)
+      return;
+
+   /* XXX: What happens if BFC isn't present?  This could only happen
+    * for user-supplied vertex programs, as t_vp_build.c always does
+    * the right thing.
+    */
+   if (!(c->key.attr_col0 && c->key.attr_bfc0) &&
+       !(c->key.attr_col1 && c->key.attr_bfc1))
+      return;
+   
+   /* Need to use BRW_EXECUTE_4 and also do an 4-wide compare in order
+    * to get all channels active inside the IF.  In the clipping code
+    * we run with NoMask, so it's not an option and we can use
+    * BRW_EXECUTE_1 for all comparisions.
+    */
+   brw_push_insn_state(p);
+   brw_CMP(p, vec4(brw_null_reg()), backface_conditional, c->det, brw_imm_f(0));
+   if_insn = brw_IF(p, BRW_EXECUTE_4); 
+   {
+      switch (c->nr_verts) {
+      case 3: copy_bfc(c, c->vert[2]);
+      case 2: copy_bfc(c, c->vert[1]);
+      case 1: copy_bfc(c, c->vert[0]);
+      }
+   }
+   brw_ENDIF(p, if_insn);
+   brw_pop_insn_state(p);
+}
+
+
+
+/***********************************************************************
+ * Flat shading
+ */
+
+#define VERT_RESULT_COLOR_BITS ((1<<VERT_RESULT_COL0) | \
+                                 (1<<VERT_RESULT_COL1))
+
+static void copy_colors( struct brw_sf_compile *c,
+                    struct brw_reg dst,
+                    struct brw_reg src)
+{
+   struct brw_compile *p = &c->func;
+
+   if (c->key.attr_col0)
+      brw_MOV(p, 
+             get_vert_attr(c, dst, c->key.attr_col0), 
+             get_vert_attr(c, src, c->key.attr_col0));
+
+   if (c->key.attr_col1)
+      brw_MOV(p, 
+             get_vert_attr(c, dst, c->key.attr_col1), 
+             get_vert_attr(c, src, c->key.attr_col1));
+
+}
+
+
+
+/* Need to use a computed jump to copy flatshaded attributes as the
+ * vertices are ordered according to y-coordinate before reaching this
+ * point, so the PV could be anywhere.
+ */
+static void do_flatshade_triangle( struct brw_sf_compile *c )
+{
+   struct brw_compile *p = &c->func;
+   struct brw_reg ip = brw_ip_reg();
+   GLuint jmpi = 1;
+   GLuint nr = 0;
+
+   if (c->key.attr_col0)
+      nr++;
+
+   if (c->key.attr_col1)
+      nr++;
+
+   if (nr == 0)
+      return;
+
+   /* Already done in clip program:
+    */
+   if (c->key.primitive == SF_UNFILLED_TRIS)
+      return;
+
+   if (BRW_IS_IGDNG(p->brw))
+       jmpi = 2;
+
+   brw_push_insn_state(p);
+   
+   brw_MUL(p, c->pv, c->pv, brw_imm_d(jmpi*(nr*2+1)));
+   brw_JMPI(p, ip, ip, c->pv);
+
+   copy_colors(c, c->vert[1], c->vert[0]);
+   copy_colors(c, c->vert[2], c->vert[0]);
+   brw_JMPI(p, ip, ip, brw_imm_d(jmpi*(nr*4+1)));
+
+   copy_colors(c, c->vert[0], c->vert[1]);
+   copy_colors(c, c->vert[2], c->vert[1]);
+   brw_JMPI(p, ip, ip, brw_imm_d(jmpi*nr*2));
+
+   copy_colors(c, c->vert[0], c->vert[2]);
+   copy_colors(c, c->vert[1], c->vert[2]);
+
+   brw_pop_insn_state(p);
+}
+       
+
+static void do_flatshade_line( struct brw_sf_compile *c )
+{
+   struct brw_compile *p = &c->func;
+   struct brw_reg ip = brw_ip_reg();
+   GLuint jmpi = 1;
+   GLuint nr = 0;
+
+   if (c->key.attr_col0)
+      nr++;
+
+   if (c->key.attr_col1)
+      nr++;
+
+   if (nr == 0)
+      return;
+
+   /* Already done in clip program: 
+    */
+   if (c->key.primitive == SF_UNFILLED_TRIS)
+      return;
+
+   if (BRW_IS_IGDNG(p->brw))
+       jmpi = 2;
+
+   brw_push_insn_state(p);
+   
+   brw_MUL(p, c->pv, c->pv, brw_imm_d(jmpi*(nr+1)));
+   brw_JMPI(p, ip, ip, c->pv);
+   copy_colors(c, c->vert[1], c->vert[0]);
+
+   brw_JMPI(p, ip, ip, brw_imm_ud(jmpi*nr));
+   copy_colors(c, c->vert[0], c->vert[1]);
+
+   brw_pop_insn_state(p);
+}
+
+       
+
+/***********************************************************************
+ * Triangle setup.
+ */
+
+
+static void alloc_regs( struct brw_sf_compile *c )
+{
+   GLuint reg, i;
+
+   /* Values computed by fixed function unit:
+    */
+   c->pv  = retype(brw_vec1_grf(1, 1), BRW_REGISTER_TYPE_D);
+   c->det = brw_vec1_grf(1, 2);
+   c->dx0 = brw_vec1_grf(1, 3);
+   c->dx2 = brw_vec1_grf(1, 4);
+   c->dy0 = brw_vec1_grf(1, 5);
+   c->dy2 = brw_vec1_grf(1, 6);
+
+   /* z and 1/w passed in seperately:
+    */
+   c->z[0]     = brw_vec1_grf(2, 0);
+   c->inv_w[0] = brw_vec1_grf(2, 1);
+   c->z[1]     = brw_vec1_grf(2, 2);
+   c->inv_w[1] = brw_vec1_grf(2, 3);
+   c->z[2]     = brw_vec1_grf(2, 4);
+   c->inv_w[2] = brw_vec1_grf(2, 5);
+   
+   /* The vertices:
+    */
+   reg = 3;
+   for (i = 0; i < c->nr_verts; i++) {
+      c->vert[i] = brw_vec8_grf(reg, 0);
+      reg += c->nr_attr_regs;
+   }
+
+   /* Temporaries, allocated after last vertex reg.
+    */
+   c->inv_det = brw_vec1_grf(reg, 0);  reg++;
+   c->a1_sub_a0 = brw_vec8_grf(reg, 0);  reg++;
+   c->a2_sub_a0 = brw_vec8_grf(reg, 0);  reg++;
+   c->tmp = brw_vec8_grf(reg, 0);  reg++;
+
+   /* Note grf allocation:
+    */
+   c->prog_data.total_grf = reg;
+   
+
+   /* Outputs of this program - interpolation coefficients for
+    * rasterization:
+    */
+   c->m1Cx = brw_vec8_reg(BRW_MESSAGE_REGISTER_FILE, 1, 0);
+   c->m2Cy = brw_vec8_reg(BRW_MESSAGE_REGISTER_FILE, 2, 0);
+   c->m3C0 = brw_vec8_reg(BRW_MESSAGE_REGISTER_FILE, 3, 0);
+}
+
+
+static void copy_z_inv_w( struct brw_sf_compile *c )
+{
+   struct brw_compile *p = &c->func;
+   GLuint i;
+
+   brw_push_insn_state(p);
+       
+   /* Copy both scalars with a single MOV:
+    */
+   for (i = 0; i < c->nr_verts; i++)
+      brw_MOV(p, vec2(suboffset(c->vert[i], 2)), vec2(c->z[i]));
+        
+   brw_pop_insn_state(p);
+}
+
+
+static void invert_det( struct brw_sf_compile *c)
+{
+   /* Looks like we invert all 8 elements just to get 1/det in
+    * position 2 !?!
+    */
+   brw_math(&c->func, 
+           c->inv_det, 
+           BRW_MATH_FUNCTION_INV,
+           BRW_MATH_SATURATE_NONE,
+           0, 
+           c->det,
+           BRW_MATH_DATA_SCALAR,
+           BRW_MATH_PRECISION_FULL);
+
+}
+
+
+/* Two attributes packed into a wide register.  Figure out if either
+ * or both of them need linear/perspective interpolation.  Constant
+ * regs are left as-is.
+ */
+static GLboolean calculate_masks( struct brw_sf_compile *c,
+                                 GLuint reg,
+                                 GLushort *pc,
+                                 GLushort *pc_persp,
+                                 GLushort *pc_linear)
+{
+   GLboolean is_last_attr = (reg == c->nr_setup_regs - 1);
+   GLuint persp_mask = c->key.persp_attrs;
+   GLuint linear_mask = (c->key.persp_attrs | c->key.linear_attrs);
+
+   *pc_persp = 0;
+   *pc_linear = 0;
+   *pc = 0xf;
+      
+   if (persp_mask & (1 << (reg*2))) 
+      *pc_persp = 0xf;
+
+   if (linear_mask & (1 << (reg*2))) 
+      *pc_linear = 0xf;
+
+   /* Maybe only processs one attribute on the final round:
+    */
+   if (reg*2+1 < c->nr_setup_attrs) {
+      *pc |= 0xf0;
+
+      if (persp_mask & (1 << (reg*2+1))) 
+        *pc_persp |= 0xf0;
+
+      if (linear_mask & (1 << (reg*2+1))) 
+        *pc_linear |= 0xf0;
+   }
+
+   return is_last_attr;
+}
+
+
+void brw_emit_null_setup( struct brw_sf_compile *c )
+{
+   struct brw_compile *p = &c->func;
+
+   /* m0 is implicitly copied from r0 in the send instruction:
+    */  
+   brw_urb_WRITE(p, 
+                 brw_null_reg(),
+                 0,
+                 brw_vec8_grf(0, 0), /* r0, will be copied to m0 */
+                 0,    /* allocate */
+                 1,    /* used */
+                 1,    /* msg len */
+                 0,    /* response len */
+                 1,    /* eot */
+                 1,    /* writes complete */
+                 0,    /* offset */
+                 BRW_URB_SWIZZLE_TRANSPOSE); 
+}
+
+void brw_emit_tri_setup( struct brw_sf_compile *c, GLboolean allocate)
+{
+   struct brw_compile *p = &c->func;
+   GLuint i;
+
+   c->nr_verts = 3;
+
+   if (allocate)
+      alloc_regs(c);
+
+   invert_det(c);
+   copy_z_inv_w(c);
+
+   if (c->key.do_twoside_color) 
+      do_twoside_color(c);
+
+   if (c->key.do_flat_shading)
+      do_flatshade_triangle(c);
+      
+   
+   for (i = 0; i < c->nr_setup_regs; i++)
+   {
+      /* Pair of incoming attributes:
+       */
+      struct brw_reg a0 = offset(c->vert[0], i);
+      struct brw_reg a1 = offset(c->vert[1], i);
+      struct brw_reg a2 = offset(c->vert[2], i);
+      GLushort pc, pc_persp, pc_linear;
+      GLboolean last = calculate_masks(c, i, &pc, &pc_persp, &pc_linear);
+
+      if (pc_persp)
+      {
+        brw_set_predicate_control_flag_value(p, pc_persp);
+        brw_MUL(p, a0, a0, c->inv_w[0]);
+        brw_MUL(p, a1, a1, c->inv_w[1]);
+        brw_MUL(p, a2, a2, c->inv_w[2]);
+      }
+      
+      
+      /* Calculate coefficients for interpolated values:
+       */      
+      if (pc_linear)
+      {
+        brw_set_predicate_control_flag_value(p, pc_linear);
+
+        brw_ADD(p, c->a1_sub_a0, a1, negate(a0));
+        brw_ADD(p, c->a2_sub_a0, a2, negate(a0));
+
+        /* calculate dA/dx
+         */
+        brw_MUL(p, brw_null_reg(), c->a1_sub_a0, c->dy2);
+        brw_MAC(p, c->tmp, c->a2_sub_a0, negate(c->dy0));
+        brw_MUL(p, c->m1Cx, c->tmp, c->inv_det);
+               
+        /* calculate dA/dy
+         */
+        brw_MUL(p, brw_null_reg(), c->a2_sub_a0, c->dx0);
+        brw_MAC(p, c->tmp, c->a1_sub_a0, negate(c->dx2));
+        brw_MUL(p, c->m2Cy, c->tmp, c->inv_det);
+      }
+
+      {
+        brw_set_predicate_control_flag_value(p, pc); 
+        /* start point for interpolation
+         */
+        brw_MOV(p, c->m3C0, a0);
+      
+        /* Copy m0..m3 to URB.  m0 is implicitly copied from r0 in
+         * the send instruction:
+         */     
+        brw_urb_WRITE(p, 
+                      brw_null_reg(),
+                      0,
+                      brw_vec8_grf(0, 0), /* r0, will be copied to m0 */
+                      0,       /* allocate */
+                      1,       /* used */
+                      4,       /* msg len */
+                      0,       /* response len */
+                      last,    /* eot */
+                      last,    /* writes complete */
+                      i*4,     /* offset */
+                      BRW_URB_SWIZZLE_TRANSPOSE); /* XXX: Swizzle control "SF to windower" */
+      }
+   }
+}
+
+
+
+void brw_emit_line_setup( struct brw_sf_compile *c, GLboolean allocate)
+{
+   struct brw_compile *p = &c->func;
+   GLuint i;
+
+
+   c->nr_verts = 2;
+
+   if (allocate)
+      alloc_regs(c);
+
+   invert_det(c);
+   copy_z_inv_w(c);
+
+   if (c->key.do_flat_shading)
+      do_flatshade_line(c);
+
+   for (i = 0; i < c->nr_setup_regs; i++)
+   {
+      /* Pair of incoming attributes:
+       */
+      struct brw_reg a0 = offset(c->vert[0], i);
+      struct brw_reg a1 = offset(c->vert[1], i);
+      GLushort pc, pc_persp, pc_linear;
+      GLboolean last = calculate_masks(c, i, &pc, &pc_persp, &pc_linear);
+
+      if (pc_persp)
+      {
+        brw_set_predicate_control_flag_value(p, pc_persp);
+        brw_MUL(p, a0, a0, c->inv_w[0]);
+        brw_MUL(p, a1, a1, c->inv_w[1]);
+      }
+
+      /* Calculate coefficients for position, color:
+       */
+      if (pc_linear) {
+        brw_set_predicate_control_flag_value(p, pc_linear); 
+
+        brw_ADD(p, c->a1_sub_a0, a1, negate(a0));
+
+        brw_MUL(p, c->tmp, c->a1_sub_a0, c->dx0); 
+        brw_MUL(p, c->m1Cx, c->tmp, c->inv_det);
+               
+        brw_MUL(p, c->tmp, c->a1_sub_a0, c->dy0);
+        brw_MUL(p, c->m2Cy, c->tmp, c->inv_det);
+      }
+
+      {
+        brw_set_predicate_control_flag_value(p, pc); 
+
+        /* start point for interpolation
+         */
+        brw_MOV(p, c->m3C0, a0);
+
+        /* Copy m0..m3 to URB. 
+         */
+        brw_urb_WRITE(p, 
+                      brw_null_reg(),
+                      0,
+                      brw_vec8_grf(0, 0),
+                      0,       /* allocate */
+                      1,       /* used */
+                      4,       /* msg len */
+                      0,       /* response len */
+                      last,    /* eot */
+                      last,    /* writes complete */
+                      i*4,     /* urb destination offset */
+                      BRW_URB_SWIZZLE_TRANSPOSE); 
+      }
+   } 
+}
+
+void brw_emit_point_sprite_setup( struct brw_sf_compile *c, GLboolean allocate)
+{
+   struct brw_compile *p = &c->func;
+   GLuint i;
+
+   c->nr_verts = 1;
+
+   if (allocate)
+      alloc_regs(c);
+
+   copy_z_inv_w(c);
+
+   for (i = 0; i < c->nr_setup_regs; i++)
+   {
+      /* XXX: only seems to check point_coord_replace_attrs for every
+       * second attribute?!?
+       */
+      boolean coord_replace = !!(c->key.point_coord_replace_attrs & (1<<(2*i)));
+      struct brw_reg a0 = offset(c->vert[0], i);
+      GLushort pc, pc_persp, pc_linear;
+      GLboolean last = calculate_masks(c, i, &pc, &pc_persp, &pc_linear);
+            
+      if (pc_persp)
+      {                                
+        if (coord_replace) {
+           brw_set_predicate_control_flag_value(p, pc_persp);
+           brw_MUL(p, a0, a0, c->inv_w[0]);
+        }
+      }
+
+      if (coord_replace) {
+        /* Caculate 1.0/PointWidth */
+        brw_math(&c->func,
+                 c->tmp,
+                 BRW_MATH_FUNCTION_INV,
+                 BRW_MATH_SATURATE_NONE,
+                 0,
+                 c->dx0,
+                 BRW_MATH_DATA_SCALAR,
+                 BRW_MATH_PRECISION_FULL);
+
+        if (c->key.sprite_origin_lower_left) {
+           brw_MUL(p, c->m1Cx, c->tmp, c->inv_w[0]);
+           brw_MOV(p, vec1(suboffset(c->m1Cx, 1)), brw_imm_f(0.0));
+           brw_MUL(p, c->m2Cy, c->tmp, negate(c->inv_w[0]));
+           brw_MOV(p, vec1(suboffset(c->m2Cy, 0)), brw_imm_f(0.0));
+        } 
+        else {
+           brw_MUL(p, c->m1Cx, c->tmp, c->inv_w[0]);
+           brw_MOV(p, vec1(suboffset(c->m1Cx, 1)), brw_imm_f(0.0));
+           brw_MUL(p, c->m2Cy, c->tmp, c->inv_w[0]);
+           brw_MOV(p, vec1(suboffset(c->m2Cy, 0)), brw_imm_f(0.0));
+        }
+      } 
+      else {
+        brw_MOV(p, c->m1Cx, brw_imm_ud(0));
+        brw_MOV(p, c->m2Cy, brw_imm_ud(0));
+      }
+
+      {
+        brw_set_predicate_control_flag_value(p, pc); 
+        if (coord_replace) {
+           if (c->key.sprite_origin_lower_left) {
+              brw_MUL(p, c->m3C0, c->inv_w[0], brw_imm_f(1.0));
+              brw_MOV(p, vec1(suboffset(c->m3C0, 0)), brw_imm_f(0.0));
+           }
+           else {
+              brw_MOV(p, c->m3C0, brw_imm_f(0.0));
+           }
+        } 
+        else {
+           brw_MOV(p, c->m3C0, a0); /* constant value */
+        }
+
+        /* Copy m0..m3 to URB. 
+         */
+        brw_urb_WRITE(p, 
+                      brw_null_reg(),
+                      0,
+                      brw_vec8_grf(0, 0),
+                      0,       /* allocate */
+                      1,       /* used */
+                      4,       /* msg len */
+                      0,       /* response len */
+                      last,    /* eot */
+                      last,    /* writes complete */
+                      i*4,     /* urb destination offset */
+                      BRW_URB_SWIZZLE_TRANSPOSE);
+      }
+   }
+}
+
+/* Points setup - several simplifications as all attributes are
+ * constant across the face of the point (point sprites excluded!)
+ */
+void brw_emit_point_setup( struct brw_sf_compile *c, GLboolean allocate)
+{
+   struct brw_compile *p = &c->func;
+   GLuint i;
+
+   c->nr_verts = 1;
+   
+   if (allocate)
+      alloc_regs(c);
+
+   copy_z_inv_w(c);
+
+   brw_MOV(p, c->m1Cx, brw_imm_ud(0)); /* zero - move out of loop */
+   brw_MOV(p, c->m2Cy, brw_imm_ud(0)); /* zero - move out of loop */
+
+   for (i = 0; i < c->nr_setup_regs; i++)
+   {
+      struct brw_reg a0 = offset(c->vert[0], i);
+      GLushort pc, pc_persp, pc_linear;
+      GLboolean last = calculate_masks(c, i, &pc, &pc_persp, &pc_linear);
+            
+      if (pc_persp)
+      {                                
+        /* This seems odd as the values are all constant, but the
+         * fragment shader will be expecting it:
+         */
+        brw_set_predicate_control_flag_value(p, pc_persp);
+        brw_MUL(p, a0, a0, c->inv_w[0]);
+      }
+
+
+      /* The delta values are always zero, just send the starting
+       * coordinate.  Again, this is to fit in with the interpolation
+       * code in the fragment shader.
+       */
+      {
+        brw_set_predicate_control_flag_value(p, pc); 
+
+        brw_MOV(p, c->m3C0, a0); /* constant value */
+
+        /* Copy m0..m3 to URB. 
+         */
+        brw_urb_WRITE(p, 
+                      brw_null_reg(),
+                      0,
+                      brw_vec8_grf(0, 0),
+                      0,       /* allocate */
+                      1,       /* used */
+                      4,       /* msg len */
+                      0,       /* response len */
+                      last,    /* eot */
+                      last,    /* writes complete */
+                      i*4,     /* urb destination offset */
+                      BRW_URB_SWIZZLE_TRANSPOSE);
+      }
+   }
+}
+
+void brw_emit_anyprim_setup( struct brw_sf_compile *c )
+{
+   struct brw_compile *p = &c->func;
+   struct brw_reg ip = brw_ip_reg();
+   struct brw_reg payload_prim = brw_uw1_reg(BRW_GENERAL_REGISTER_FILE, 1, 0);
+   struct brw_reg payload_attr = get_element_ud(brw_vec1_reg(BRW_GENERAL_REGISTER_FILE, 1, 0), 0); 
+   struct brw_reg primmask;
+   struct brw_instruction *jmp;
+   struct brw_reg v1_null_ud = vec1(retype(brw_null_reg(), BRW_REGISTER_TYPE_UD));
+   
+   GLuint saveflag;
+
+   c->nr_verts = 3;
+   alloc_regs(c);
+
+   primmask = retype(get_element(c->tmp, 0), BRW_REGISTER_TYPE_UD);
+
+   brw_MOV(p, primmask, brw_imm_ud(1));
+   brw_SHL(p, primmask, primmask, payload_prim);
+
+   brw_set_conditionalmod(p, BRW_CONDITIONAL_Z);
+   brw_AND(p, v1_null_ud, primmask, brw_imm_ud((1<<_3DPRIM_TRILIST) |
+                                              (1<<_3DPRIM_TRISTRIP) |
+                                              (1<<_3DPRIM_TRIFAN) |
+                                              (1<<_3DPRIM_TRISTRIP_REVERSE) |
+                                              (1<<_3DPRIM_POLYGON) |
+                                              (1<<_3DPRIM_RECTLIST) |
+                                              (1<<_3DPRIM_TRIFAN_NOSTIPPLE)));
+   jmp = brw_JMPI(p, ip, ip, brw_imm_d(0));
+   {
+      saveflag = p->flag_value;
+      brw_push_insn_state(p); 
+      brw_emit_tri_setup( c, GL_FALSE );
+      brw_pop_insn_state(p);
+      p->flag_value = saveflag;
+      /* note - thread killed in subroutine, so must
+       * restore the flag which is changed when building
+       * the subroutine. fix #13240
+       */
+   }
+   brw_land_fwd_jump(p, jmp);
+
+   brw_set_conditionalmod(p, BRW_CONDITIONAL_Z);
+   brw_AND(p, v1_null_ud, primmask, brw_imm_ud((1<<_3DPRIM_LINELIST) |
+                                              (1<<_3DPRIM_LINESTRIP) |
+                                              (1<<_3DPRIM_LINELOOP) |
+                                              (1<<_3DPRIM_LINESTRIP_CONT) |
+                                              (1<<_3DPRIM_LINESTRIP_BF) |
+                                              (1<<_3DPRIM_LINESTRIP_CONT_BF)));
+   jmp = brw_JMPI(p, ip, ip, brw_imm_d(0));
+   {
+      saveflag = p->flag_value;
+      brw_push_insn_state(p); 
+      brw_emit_line_setup( c, GL_FALSE );
+      brw_pop_insn_state(p);
+      p->flag_value = saveflag;
+      /* note - thread killed in subroutine */
+   }
+   brw_land_fwd_jump(p, jmp); 
+
+   brw_set_conditionalmod(p, BRW_CONDITIONAL_Z);
+   brw_AND(p, v1_null_ud, payload_attr, brw_imm_ud(1<<BRW_SPRITE_POINT_ENABLE));
+   jmp = brw_JMPI(p, ip, ip, brw_imm_d(0));
+   {
+      saveflag = p->flag_value;
+      brw_push_insn_state(p); 
+      brw_emit_point_sprite_setup( c, GL_FALSE );
+      brw_pop_insn_state(p);
+      p->flag_value = saveflag;
+   }
+   brw_land_fwd_jump(p, jmp); 
+
+   brw_emit_point_setup( c, GL_FALSE );
+}
+
+
+
+
diff --git a/src/gallium/drivers/i965/brw_sf_state.c b/src/gallium/drivers/i965/brw_sf_state.c
new file mode 100644 (file)
index 0000000..25dc2b5
--- /dev/null
@@ -0,0 +1,333 @@
+/*
+ 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 "util/u_math.h"
+
+#include "pipe/p_state.h"
+
+#include "brw_context.h"
+#include "brw_state.h"
+#include "brw_defines.h"
+#include "brw_debug.h"
+#include "brw_pipe_rast.h"
+
+static enum pipe_error upload_sf_vp(struct brw_context *brw)
+{
+   const struct pipe_viewport_state *vp = &brw->curr.viewport;
+   const struct pipe_scissor_state *scissor = &brw->curr.scissor;
+   struct brw_sf_viewport sfv;
+   enum pipe_error ret;
+
+   memset(&sfv, 0, sizeof(sfv));
+
+   /* PIPE_NEW_VIEWPORT, PIPE_NEW_SCISSOR */
+
+   sfv.viewport.m00 = vp->scale[0];
+   sfv.viewport.m11 = vp->scale[1];
+   sfv.viewport.m22 = vp->scale[2];
+   sfv.viewport.m30 = vp->translate[0];
+   sfv.viewport.m31 = vp->translate[1];
+   sfv.viewport.m32 = vp->translate[2];
+
+   sfv.scissor.xmin = scissor->minx;
+   sfv.scissor.xmax = scissor->maxx - 1; /* ? */
+   sfv.scissor.ymin = scissor->miny;
+   sfv.scissor.ymax = scissor->maxy - 1; /* ? */
+
+   ret = brw_cache_data( &brw->cache, BRW_SF_VP, &sfv, NULL, 0,
+                         &brw->sf.vp_bo );
+   if (ret)
+      return ret;
+
+   return PIPE_OK;
+}
+
+const struct brw_tracked_state brw_sf_vp = {
+   .dirty = {
+      .mesa  = (PIPE_NEW_VIEWPORT | 
+               PIPE_NEW_SCISSOR),
+      .brw   = 0,
+      .cache = 0
+   },
+   .prepare = upload_sf_vp
+};
+
+struct brw_sf_unit_key {
+   unsigned int total_grf;
+   unsigned int urb_entry_read_length;
+   unsigned int nr_urb_entries, urb_size, sfsize;
+   
+   unsigned scissor:1;
+   unsigned line_smooth:1;
+   unsigned point_sprite:1;
+   unsigned point_attenuated:1;
+   unsigned front_face:2;
+   unsigned cull_mode:2;
+   unsigned flatshade_first:1;
+   unsigned gl_rasterization_rules:1;
+   unsigned line_last_pixel_enable:1;
+   float line_width;
+   float point_size;
+};
+
+static void
+sf_unit_populate_key(struct brw_context *brw, struct brw_sf_unit_key *key)
+{
+   const struct pipe_rasterizer_state *rast = &brw->curr.rast->templ;
+   memset(key, 0, sizeof(*key));
+
+   /* CACHE_NEW_SF_PROG */
+   key->total_grf = brw->sf.prog_data->total_grf;
+   key->urb_entry_read_length = brw->sf.prog_data->urb_read_length;
+
+   /* BRW_NEW_URB_FENCE */
+   key->nr_urb_entries = brw->urb.nr_sf_entries;
+   key->urb_size = brw->urb.vsize;
+   key->sfsize = brw->urb.sfsize;
+
+   /* PIPE_NEW_RAST */
+   key->scissor = rast->scissor;
+   key->front_face = rast->front_winding;
+   key->cull_mode = rast->cull_mode;
+   key->line_smooth = rast->line_smooth;
+   key->line_width = rast->line_width;
+   key->flatshade_first = rast->flatshade_first;
+   key->line_last_pixel_enable = rast->line_last_pixel;
+   key->gl_rasterization_rules = rast->gl_rasterization_rules;
+
+   key->point_sprite = rast->point_sprite;
+   key->point_attenuated = rast->point_size_per_vertex;
+
+   key->point_size = CLAMP(rast->point_size, 
+                          rast->point_size_min, 
+                          rast->point_size_max);
+}
+
+static enum pipe_error
+sf_unit_create_from_key(struct brw_context *brw,
+                        struct brw_sf_unit_key *key,
+                        struct brw_winsys_reloc *reloc,
+                        struct brw_winsys_buffer **bo_out)
+{
+   struct brw_sf_unit_state sf;
+   enum pipe_error ret;
+   int chipset_max_threads;
+   memset(&sf, 0, sizeof(sf));
+
+   sf.thread0.grf_reg_count = align(key->total_grf, 16) / 16 - 1;
+   /* reloc */
+   sf.thread0.kernel_start_pointer = 0;
+
+   sf.thread1.floating_point_mode = BRW_FLOATING_POINT_NON_IEEE_754;
+
+   sf.thread3.dispatch_grf_start_reg = 3;
+
+   if (BRW_IS_IGDNG(brw))
+       sf.thread3.urb_entry_read_offset = 3;
+   else
+       sf.thread3.urb_entry_read_offset = 1;
+
+   sf.thread3.urb_entry_read_length = key->urb_entry_read_length;
+
+   sf.thread4.nr_urb_entries = key->nr_urb_entries;
+   sf.thread4.urb_entry_allocation_size = key->sfsize - 1;
+
+   /* Each SF thread produces 1 PUE, and there can be up to 24(Pre-IGDNG) or 
+    * 48(IGDNG) threads 
+    */
+   if (BRW_IS_IGDNG(brw))
+      chipset_max_threads = 48;
+   else
+      chipset_max_threads = 24;
+
+   sf.thread4.max_threads = MIN2(chipset_max_threads, key->nr_urb_entries) - 1;
+
+   if (BRW_DEBUG & DEBUG_SINGLE_THREAD)
+      sf.thread4.max_threads = 0;
+
+   if (BRW_DEBUG & DEBUG_STATS)
+      sf.thread4.stats_enable = 1;
+
+   /* CACHE_NEW_SF_VP */
+   /* reloc */
+   sf.sf5.sf_viewport_state_offset = 0;
+
+   sf.sf5.viewport_transform = 1;
+
+   if (key->scissor)
+      sf.sf6.scissor = 1;
+
+   if (key->front_face == PIPE_WINDING_CCW)
+      sf.sf5.front_winding = BRW_FRONTWINDING_CCW;
+   else
+      sf.sf5.front_winding = BRW_FRONTWINDING_CW;
+
+   switch (key->cull_mode) {
+   case PIPE_WINDING_CCW:
+   case PIPE_WINDING_CW:
+      sf.sf6.cull_mode = (key->front_face == key->cull_mode ?
+                         BRW_CULLMODE_FRONT :
+                         BRW_CULLMODE_BACK);
+      break;
+   case PIPE_WINDING_BOTH:
+      sf.sf6.cull_mode = BRW_CULLMODE_BOTH;
+      break;
+   case PIPE_WINDING_NONE:
+      sf.sf6.cull_mode = BRW_CULLMODE_NONE;
+      break;
+   default:
+      assert(0);
+      sf.sf6.cull_mode = BRW_CULLMODE_NONE;
+      break;
+   }
+
+   /* _NEW_LINE */
+   /* XXX use ctx->Const.Min/MaxLineWidth here */
+   sf.sf6.line_width = CLAMP(key->line_width, 1.0, 5.0) * (1<<1);
+
+   sf.sf6.line_endcap_aa_region_width = 1;
+   if (key->line_smooth)
+      sf.sf6.aa_enable = 1;
+   else if (sf.sf6.line_width <= 0x2)
+       sf.sf6.line_width = 0;
+
+   /* XXX: gl_rasterization_rules?  something else?
+    */
+   sf.sf6.point_rast_rule = BRW_RASTRULE_UPPER_RIGHT;
+   sf.sf6.point_rast_rule = BRW_RASTRULE_LOWER_RIGHT;
+   sf.sf6.point_rast_rule = 1;
+
+   /* XXX clamp max depends on AA vs. non-AA */
+
+   /* _NEW_POINT */
+   sf.sf7.sprite_point = key->point_sprite;
+   sf.sf7.point_size = CLAMP(rint(key->point_size), 1, 255) * (1<<3);
+   sf.sf7.use_point_size_state = !key->point_attenuated;
+   sf.sf7.aa_line_distance_mode = 0;
+
+   /* might be BRW_NEW_PRIMITIVE if we have to adjust pv for polygons:
+    */
+   if (!key->flatshade_first) {
+      sf.sf7.trifan_pv = 2;
+      sf.sf7.linestrip_pv = 1;
+      sf.sf7.tristrip_pv = 2;
+   } else {
+      sf.sf7.trifan_pv = 1;
+      sf.sf7.linestrip_pv = 0;
+      sf.sf7.tristrip_pv = 0;
+   }
+
+   sf.sf7.line_last_pixel_enable = key->line_last_pixel_enable;
+
+   /* Set bias for OpenGL rasterization rules:
+    */
+   if (key->gl_rasterization_rules) {
+      sf.sf6.dest_org_vbias = 0x8;
+      sf.sf6.dest_org_hbias = 0x8;
+   }
+   else {
+      sf.sf6.dest_org_vbias = 0x0;
+      sf.sf6.dest_org_hbias = 0x0;
+   }
+
+   ret = brw_upload_cache(&brw->cache, BRW_SF_UNIT,
+                          key, sizeof(*key),
+                          reloc, 2,
+                          &sf, sizeof(sf),
+                          NULL, NULL,
+                          bo_out);
+   if (ret)
+      return ret;
+
+   
+   return PIPE_OK;
+}
+
+static enum pipe_error upload_sf_unit( struct brw_context *brw )
+{
+   struct brw_sf_unit_key key;
+   struct brw_winsys_reloc reloc[2];
+   unsigned total_grf;
+   unsigned viewport_transform;
+   unsigned front_winding;
+   enum pipe_error ret;
+
+   sf_unit_populate_key(brw, &key);
+   
+   /* XXX: cut this crap and pre calculate the key:
+    */
+   total_grf = (align(key.total_grf, 16) / 16 - 1);
+   viewport_transform = 1;
+   front_winding = (key.front_face == PIPE_WINDING_CCW ?
+                    BRW_FRONTWINDING_CCW :
+                    BRW_FRONTWINDING_CW);
+
+   /* Emit SF program relocation */
+   make_reloc(&reloc[0],
+              BRW_USAGE_STATE,
+              total_grf << 1,
+              offsetof(struct brw_sf_unit_state, thread0),
+              brw->sf.prog_bo);
+
+   /* Emit SF viewport relocation */
+   make_reloc(&reloc[1],
+              BRW_USAGE_STATE,
+              front_winding | (viewport_transform << 1),
+              offsetof(struct brw_sf_unit_state, sf5),
+              brw->sf.vp_bo);
+
+
+   if (brw_search_cache(&brw->cache, BRW_SF_UNIT,
+                        &key, sizeof(key),
+                        reloc, 2,
+                        NULL,
+                        &brw->sf.state_bo))
+      return PIPE_OK;
+
+
+   ret = sf_unit_create_from_key(brw, &key,
+                                 reloc,
+                                 &brw->sf.state_bo);
+   if (ret)
+      return ret;
+
+   return PIPE_OK;
+}
+
+const struct brw_tracked_state brw_sf_unit = {
+   .dirty = {
+      .mesa  = (PIPE_NEW_RAST),
+      .brw   = BRW_NEW_URB_FENCE,
+      .cache = (CACHE_NEW_SF_VP |
+               CACHE_NEW_SF_PROG)
+   },
+   .prepare = upload_sf_unit,
+};
diff --git a/src/gallium/drivers/i965/brw_state.h b/src/gallium/drivers/i965/brw_state.h
new file mode 100644 (file)
index 0000000..d2bbd01
--- /dev/null
@@ -0,0 +1,174 @@
+/*
+ Copyright (C) Intel Corp.  2006.  All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ **********************************************************************/
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  */
+    
+
+#ifndef BRW_STATE_H
+#define BRW_STATE_H
+
+#include "pipe/p_defines.h"
+#include "util/u_memory.h"
+
+#include "brw_context.h"
+
+static INLINE void
+brw_add_validated_bo(struct brw_context *brw, struct brw_winsys_buffer *bo)
+{
+   assert(brw->state.validated_bo_count < Elements(brw->state.validated_bos));
+
+   if (bo != NULL) {
+      bo_reference( &brw->state.validated_bos[brw->state.validated_bo_count++],
+                    bo );
+   }
+}
+
+const struct brw_tracked_state brw_blend_constant_color;
+const struct brw_tracked_state brw_cc_unit;
+const struct brw_tracked_state brw_cc_vp;
+const struct brw_tracked_state brw_clip_prog;
+const struct brw_tracked_state brw_clip_unit;
+const struct brw_tracked_state brw_curbe_buffer;
+const struct brw_tracked_state brw_curbe_offsets;
+const struct brw_tracked_state brw_invarient_state;
+const struct brw_tracked_state brw_gs_prog;
+const struct brw_tracked_state brw_gs_unit;
+const struct brw_tracked_state brw_line_stipple;
+const struct brw_tracked_state brw_aa_line_parameters;
+const struct brw_tracked_state brw_pipelined_state_pointers;
+const struct brw_tracked_state brw_binding_table_pointers;
+const struct brw_tracked_state brw_depthbuffer;
+const struct brw_tracked_state brw_polygon_stipple;
+const struct brw_tracked_state brw_program_parameters;
+const struct brw_tracked_state brw_recalculate_urb_fence;
+const struct brw_tracked_state brw_sf_prog;
+const struct brw_tracked_state brw_sf_unit;
+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;
+
+const struct brw_tracked_state brw_psp_urb_cbs;
+
+const struct brw_tracked_state brw_pipe_control;
+
+const struct brw_tracked_state brw_drawing_rect;
+const struct brw_tracked_state brw_indices;
+const struct brw_tracked_state brw_vertices;
+const struct brw_tracked_state brw_index_buffer;
+
+
+/***********************************************************************
+ * brw_state.c
+ */
+int brw_validate_state(struct brw_context *brw);
+int brw_upload_state(struct brw_context *brw);
+void brw_init_state(struct brw_context *brw);
+void brw_destroy_state(struct brw_context *brw);
+
+/***********************************************************************
+ * brw_state_cache.c
+ */
+enum pipe_error brw_cache_data(struct brw_cache *cache,
+                               enum brw_cache_id cache_id,
+                               const void *data,
+                               struct brw_winsys_reloc *relocs,
+                               GLuint nr_relocs,
+                               struct brw_winsys_buffer **bo_out );
+
+enum pipe_error brw_cache_data_sz(struct brw_cache *cache,
+                                  enum brw_cache_id cache_id,
+                                  const void *data,
+                                  GLuint data_size,
+                                  struct brw_winsys_reloc *relocs,
+                                  GLuint nr_relocs,
+                                  struct brw_winsys_buffer **bo_out);
+
+enum pipe_error brw_upload_cache( struct brw_cache *cache,
+                                  enum brw_cache_id cache_id,
+                                  const void *key,
+                                  GLuint key_sz,
+                                  struct brw_winsys_reloc *relocs,
+                                  GLuint nr_relocs,
+                                  const void *data,
+                                  GLuint data_sz,
+                                  const void *aux,
+                                  void *aux_return ,
+                                  struct brw_winsys_buffer **bo_out);
+
+boolean brw_search_cache( struct brw_cache *cache,
+                          enum brw_cache_id cache_id,
+                          const void *key,
+                          GLuint key_size,
+                          struct brw_winsys_reloc *relocs,
+                          GLuint nr_relocs,
+                          void *aux_return,
+                          struct brw_winsys_buffer **bo_out);
+
+void brw_state_cache_check_size( struct brw_context *brw );
+
+void brw_init_caches( struct brw_context *brw );
+void brw_destroy_caches( struct brw_context *brw );
+void brw_state_cache_bo_delete(struct brw_cache *cache, struct brw_winsys_buffer *bo);
+
+/***********************************************************************
+ * brw_state_batch.c
+ */
+#define BRW_BATCH_STRUCT(brw, s) brw_batchbuffer_data( brw->batch, (s), sizeof(*(s)), IGNORE_CLIPRECTS)
+#define BRW_CACHED_BATCH_STRUCT(brw, s) brw_cached_batch_struct( brw, (s), sizeof(*(s)) )
+
+GLboolean brw_cached_batch_struct( struct brw_context *brw,
+                                  const void *data,
+                                  GLuint sz );
+void brw_destroy_batch_cache( struct brw_context *brw );
+void brw_clear_batch_cache( struct brw_context *brw );
+
+/***********************************************************************
+ * brw_wm_surface_state.c 
+ */
+
+/***********************************************************************
+ * brw_state_debug.c
+ */
+void brw_update_dirty_counts( unsigned mesa,
+                             unsigned brw,
+                             unsigned cache );
+
+
+
+#endif
diff --git a/src/gallium/drivers/i965/brw_state_batch.c b/src/gallium/drivers/i965/brw_state_batch.c
new file mode 100644 (file)
index 0000000..7d212e5
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ Copyright (C) Intel Corp.  2006.  All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ **********************************************************************/
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  */
+     
+
+
+#include "brw_state.h"
+#include "brw_batchbuffer.h"
+
+
+
+/* A facility similar to the data caching code above, which aims to
+ * prevent identical commands being issued repeatedly.
+ */
+GLboolean brw_cached_batch_struct( struct brw_context *brw,
+                                  const void *data,
+                                  GLuint sz )
+{
+   struct brw_cached_batch_item *item = brw->cached_batch_items;
+   struct header *newheader = (struct header *)data;
+
+   if (brw->flags.always_emit_state) {
+      brw_batchbuffer_data(brw->batch, data, sz, IGNORE_CLIPRECTS);
+      return GL_TRUE;
+   }
+
+   while (item) {
+      if (item->header->opcode == newheader->opcode) {
+        if (item->sz == sz && memcmp(item->header, newheader, sz) == 0)
+           return GL_FALSE;
+        if (item->sz != sz) {
+           FREE(item->header);
+           item->header = MALLOC(sz);
+           item->sz = sz;
+        }
+        goto emit;
+      }
+      item = item->next;
+   }
+
+   assert(!item);
+   item = CALLOC_STRUCT(brw_cached_batch_item);
+   item->header = MALLOC(sz);
+   item->sz = sz;
+   item->next = brw->cached_batch_items;
+   brw->cached_batch_items = item;
+
+ emit:
+   memcpy(item->header, newheader, sz);
+   brw_batchbuffer_data(brw->batch, data, sz, IGNORE_CLIPRECTS);
+   return GL_TRUE;
+}
+
+void brw_clear_batch_cache( struct brw_context *brw )
+{
+   struct brw_cached_batch_item *item = brw->cached_batch_items;
+
+   while (item) {
+      struct brw_cached_batch_item *next = item->next;
+      free((void *)item->header);
+      free(item);
+      item = next;
+   }
+
+   brw->cached_batch_items = NULL;
+}
+
+void brw_destroy_batch_cache( struct brw_context *brw )
+{
+   brw_clear_batch_cache(brw);
+}
diff --git a/src/gallium/drivers/i965/brw_state_cache.c b/src/gallium/drivers/i965/brw_state_cache.c
new file mode 100644 (file)
index 0000000..16b643c
--- /dev/null
@@ -0,0 +1,617 @@
+/*
+ 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>
+  */
+
+/** @file brw_state_cache.c
+ *
+ * This file implements a simple static state cache for 965.  The consumers
+ * can query the hash table of state using a cache_id, opaque key data,
+ * and list of buffers that will be used in relocations, and receive the
+ * corresponding state buffer object of state (plus associated auxiliary
+ * data) in return.
+ *
+ * The inner workings are a simple hash table based on a CRC of the key data.
+ * The cache_id and relocation target buffers associated with the state
+ * buffer are included as auxiliary key data, but are not part of the hash
+ * value (this should be fixed, but will likely be fixed instead by making
+ * consumers use structured keys).
+ *
+ * Replacement is not implemented.  Instead, when the cache gets too big, at
+ * a safe point (unlock) we throw out all of the cache data and let it
+ * regenerate for the next rendering operation.
+ *
+ * The reloc structs need to be included as key data, otherwise the
+ * non-unique values stuffed in the offset in key data through
+ * brw_cache_data() may result in successful probe for state buffers
+ * even when the buffer being referenced doesn't match.  The result would be
+ * that the same state cache entry is used twice for different buffers,
+ * only one of the two buffers referenced gets put into the offset, and the
+ * incorrect program is run for the other instance.
+ */
+#include "util/u_memory.h"
+
+#include "brw_debug.h"
+#include "brw_state.h"
+#include "brw_batchbuffer.h"
+
+/* XXX: Fixme - have to include these to get the sizes of the prog_key
+ * structs:
+ */
+#include "brw_wm.h"
+#include "brw_vs.h"
+#include "brw_clip.h"
+#include "brw_sf.h"
+#include "brw_gs.h"
+
+
+static GLuint
+hash_key(const void *key, GLuint key_size,
+         struct brw_winsys_reloc *relocs, GLuint nr_relocs)
+{
+   GLuint *ikey = (GLuint *)key;
+   GLuint hash = 0, i;
+
+   assert(key_size % 4 == 0);
+
+   /* I'm sure this can be improved on:
+    */
+   for (i = 0; i < key_size/4; i++) {
+      hash ^= ikey[i];
+      hash = (hash << 5) | (hash >> 27);
+   }
+
+   /* Include the BO pointers as key data as well */
+   ikey = (GLuint *)relocs;
+   key_size = nr_relocs * sizeof(struct brw_winsys_reloc);
+   for (i = 0; i < key_size/4; i++) {
+      hash ^= ikey[i];
+      hash = (hash << 5) | (hash >> 27);
+   }
+
+   return hash;
+}
+
+
+/**
+ * Marks a new buffer as being chosen for the given cache id.
+ */
+static void
+update_cache_last(struct brw_cache *cache, enum brw_cache_id cache_id,
+                 struct brw_winsys_buffer *bo)
+{
+   if (bo == cache->last_bo[cache_id])
+      return; /* no change */
+
+   bo_reference( &cache->last_bo[cache_id],  bo );
+
+   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,
+            struct brw_winsys_reloc *relocs, GLuint nr_relocs)
+{
+   struct brw_cache_item *c;
+
+#if 0
+   int bucketcount = 0;
+
+   for (c = cache->items[hash % cache->size]; c; c = c->next)
+      bucketcount++;
+
+   debug_printf("bucket %d/%d = %d/%d items\n", hash % cache->size,
+          cache->size, bucketcount, cache->n_items);
+#endif
+
+   for (c = cache->items[hash % cache->size]; c; c = c->next) {
+      if (c->cache_id == cache_id &&
+         c->hash == hash &&
+         c->key_size == key_size &&
+         memcmp(c->key, key, key_size) == 0 &&
+         c->nr_relocs == nr_relocs &&
+         memcmp(c->relocs, relocs, nr_relocs * sizeof *relocs) == 0)
+        return c;
+   }
+
+   return NULL;
+}
+
+
+static void
+rehash(struct brw_cache *cache)
+{
+   struct brw_cache_item **items;
+   struct brw_cache_item *c, *next;
+   GLuint size, i;
+
+   size = cache->size * 3;
+   items = (struct brw_cache_item**) CALLOC(size, sizeof(*items));
+
+   for (i = 0; i < cache->size; i++)
+      for (c = cache->items[i]; c; c = next) {
+        next = c->next;
+        c->next = items[c->hash % size];
+        items[c->hash % size] = c;
+      }
+
+   FREE(cache->items);
+   cache->items = items;
+   cache->size = size;
+}
+
+
+/**
+ * Returns the buffer object matching cache_id and key, or NULL.
+ */
+boolean
+brw_search_cache(struct brw_cache *cache,
+                 enum brw_cache_id cache_id,
+                 const void *key,
+                 GLuint key_size,
+                 struct brw_winsys_reloc *relocs, 
+                GLuint nr_relocs,
+                 void *aux_return,
+                 struct brw_winsys_buffer **bo_out)
+{
+   struct brw_cache_item *item;
+   GLuint hash = hash_key(key, key_size, relocs, nr_relocs);
+
+   item = search_cache(cache, cache_id, hash, key, key_size,
+                      relocs, nr_relocs);
+
+   if (item) {
+      if (aux_return)
+         *(void **)aux_return = (void *)((char *)item->key + item->key_size);
+      
+      update_cache_last(cache, cache_id, item->bo);
+      bo_reference(bo_out, item->bo);
+      return TRUE;
+   }
+   
+   return FALSE;      
+}
+
+
+enum pipe_error
+brw_upload_cache( struct brw_cache *cache,
+                 enum brw_cache_id cache_id,
+                 const void *key,
+                 GLuint key_size,
+                 struct brw_winsys_reloc *relocs,
+                 GLuint nr_relocs,
+                 const void *data,
+                 GLuint data_size,
+                 const void *aux,
+                 void *aux_return,
+                  struct brw_winsys_buffer **bo_out)
+{
+   struct brw_cache_item *item = CALLOC_STRUCT(brw_cache_item);
+   GLuint hash = hash_key(key, key_size, relocs, nr_relocs);
+   GLuint relocs_size = nr_relocs * sizeof relocs[0];
+   GLuint aux_size = cache->aux_size[cache_id];
+   enum pipe_error ret;
+   void *tmp;
+   int i;
+
+   /* Create the buffer object to contain the data.  For now, use a
+    * single buffer type to describe all cached state atoms.  Later,
+    * may want to take advantage of hardware distinctions between
+    * these various entities.
+    */
+   ret = cache->sws->bo_alloc(cache->sws,
+                              cache->buffer_type,
+                              data_size, 1 << 6, 
+                              bo_out);
+   if (ret)
+      return ret;
+
+
+   /* Set up the memory containing the key, aux_data, and relocs */
+   tmp = MALLOC(key_size + aux_size + relocs_size);
+
+   memcpy(tmp, key, key_size);
+   memcpy((char *)tmp + key_size, aux, cache->aux_size[cache_id]);
+   memcpy((char *)tmp + key_size + aux_size, relocs, relocs_size);
+   for (i = 0; i < nr_relocs; i++) {
+      p_atomic_inc(&relocs[i].bo->reference.count);
+   }
+
+   item->cache_id = cache_id;
+   item->key = tmp;
+   item->hash = hash;
+   item->key_size = key_size;
+   item->relocs = (struct brw_winsys_reloc *)((char *)tmp + key_size + aux_size);
+   item->nr_relocs = nr_relocs;
+   bo_reference( &item->bo, *bo_out );
+   item->data_size = data_size;
+
+   if (cache->n_items > cache->size * 1.5)
+      rehash(cache);
+
+   hash %= cache->size;
+   item->next = cache->items[hash];
+   cache->items[hash] = item;
+   cache->n_items++;
+
+   if (aux_return) {
+      assert(cache->aux_size[cache_id]);
+      *(void **)aux_return = (void *)((char *)item->key + item->key_size);
+   }
+
+   if (BRW_DEBUG & DEBUG_STATE)
+      debug_printf("upload %s: %d bytes to cache id %d\n",
+                  cache->name[cache_id],
+                  data_size, cache_id);
+
+   /* Copy data to the buffer */
+   ret = cache->sws->bo_subdata(item->bo, 
+                                cache_id,
+                                0, data_size, data,
+                                relocs, nr_relocs);
+   if (ret)
+      return ret;
+
+   update_cache_last(cache, cache_id, item->bo);
+
+   return PIPE_OK;
+}
+
+
+/**
+ * This doesn't really work with aux data.  Use search/upload instead
+ */
+enum pipe_error
+brw_cache_data_sz(struct brw_cache *cache,
+                 enum brw_cache_id cache_id,
+                 const void *data,
+                 GLuint data_size,
+                 struct brw_winsys_reloc *relocs,
+                 GLuint nr_relocs,
+                  struct brw_winsys_buffer **bo_out)
+{
+   struct brw_cache_item *item;
+   GLuint hash = hash_key(data, data_size, relocs, nr_relocs);
+
+   item = search_cache(cache, cache_id, hash, data, data_size,
+                      relocs, nr_relocs);
+   if (item) {
+      update_cache_last(cache, cache_id, item->bo);
+
+      bo_reference(bo_out, item->bo);
+      return PIPE_OK;
+   }
+
+   return brw_upload_cache(cache, cache_id,
+                           data, data_size,
+                           relocs, nr_relocs,
+                           data, data_size,
+                           NULL, NULL,
+                           bo_out);
+}
+
+
+/**
+ * Wrapper around brw_cache_data_sz using the cache_id's canonical key size.
+ *
+ * If nr_relocs is nonzero, brw_search_cache()/brw_upload_cache() would be
+ * better to use, as the potentially changing offsets in the data-used-as-key
+ * will result in excessive cache misses.
+ * 
+ * XXX: above is no longer true -- can we remove some code?
+ */
+enum pipe_error
+brw_cache_data(struct brw_cache *cache,
+              enum brw_cache_id cache_id,
+              const void *data,
+              struct brw_winsys_reloc *relocs,
+              GLuint nr_relocs,
+               struct brw_winsys_buffer **bo_out)
+{
+   return brw_cache_data_sz(cache, cache_id, data, cache->key_size[cache_id],
+                           relocs, nr_relocs, bo_out);
+}
+
+
+static void
+brw_init_cache_id(struct brw_cache *cache,
+                  const char *name,
+                  enum brw_cache_id id,
+                  GLuint key_size,
+                  GLuint aux_size)
+{
+   cache->name[id] = strdup(name);
+   cache->key_size[id] = key_size;
+   cache->aux_size[id] = aux_size;
+}
+
+
+static void
+brw_init_general_state_cache(struct brw_context *brw)
+{
+   struct brw_cache *cache = &brw->cache;
+
+   cache->brw = brw;
+   cache->sws = brw->sws;
+
+   cache->buffer_type = BRW_BUFFER_TYPE_GENERAL_STATE;
+
+   cache->size = 7;
+   cache->n_items = 0;
+   cache->items = (struct brw_cache_item **)
+      CALLOC(cache->size, sizeof(struct brw_cache_item));
+
+   brw_init_cache_id(cache,
+                    "CC_VP",
+                    BRW_CC_VP,
+                    sizeof(struct brw_cc_viewport),
+                    0);
+
+   brw_init_cache_id(cache,
+                    "CC_UNIT",
+                    BRW_CC_UNIT,
+                    sizeof(struct brw_cc_unit_state),
+                    0);
+
+   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(cache,
+                    "SAMPLER_DEFAULT_COLOR",
+                    BRW_SAMPLER_DEFAULT_COLOR,
+                    sizeof(struct brw_sampler_default_color),
+                    0);
+
+   brw_init_cache_id(cache,
+                    "SAMPLER",
+                    BRW_SAMPLER,
+                    0,         /* variable key/data size */
+                    0);
+
+   brw_init_cache_id(cache,
+                    "WM_UNIT",
+                    BRW_WM_UNIT,
+                    sizeof(struct brw_wm_unit_state),
+                    0);
+
+   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(cache,
+                    "SF_VP",
+                    BRW_SF_VP,
+                    sizeof(struct brw_sf_viewport),
+                    0);
+
+   brw_init_cache_id(cache,
+                    "SF_UNIT",
+                    BRW_SF_UNIT,
+                    sizeof(struct brw_sf_unit_state),
+                    0);
+
+   brw_init_cache_id(cache,
+                    "VS_UNIT",
+                    BRW_VS_UNIT,
+                    sizeof(struct brw_vs_unit_state),
+                    0);
+
+   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(cache,
+                    "CLIP_UNIT",
+                    BRW_CLIP_UNIT,
+                    sizeof(struct brw_clip_unit_state),
+                    0);
+
+   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(cache,
+                    "GS_UNIT",
+                    BRW_GS_UNIT,
+                    sizeof(struct brw_gs_unit_state),
+                    0);
+
+   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_state_cache(struct brw_context *brw)
+{
+   struct brw_cache *cache = &brw->surface_cache;
+
+   cache->brw = brw;
+   cache->sws = brw->sws;
+
+   cache->buffer_type = BRW_BUFFER_TYPE_SURFACE_STATE;
+
+   cache->size = 7;
+   cache->n_items = 0;
+   cache->items = (struct brw_cache_item **)
+      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(cache,
+                    "SS_SURF_BIND",
+                    BRW_SS_SURF_BIND,
+                    0,
+                    0);
+}
+
+
+void
+brw_init_caches(struct brw_context *brw)
+{
+   brw_init_general_state_cache(brw);
+   brw_init_surface_state_cache(brw);
+}
+
+
+static void
+brw_clear_cache(struct brw_context *brw, struct brw_cache *cache)
+{
+   struct brw_cache_item *c, *next;
+   GLuint i;
+
+   if (BRW_DEBUG & DEBUG_STATE)
+      debug_printf("%s\n", __FUNCTION__);
+
+   for (i = 0; i < cache->size; i++) {
+      for (c = cache->items[i]; c; c = next) {
+        int j;
+
+        next = c->next;
+
+        for (j = 0; j < c->nr_relocs; j++)
+           bo_reference(&c->relocs[j].bo, NULL);
+
+        bo_reference(&c->bo, NULL);
+        FREE((void *)c->key);
+        FREE(c);
+      }
+      cache->items[i] = NULL;
+   }
+
+   cache->n_items = 0;
+
+   if (brw->curbe.last_buf) {
+      FREE(brw->curbe.last_buf);
+      brw->curbe.last_buf = NULL;
+   }
+
+   brw->state.dirty.mesa |= ~0;
+   brw->state.dirty.brw |= ~0;
+   brw->state.dirty.cache |= ~0;
+}
+
+/* Clear all entries from the cache that point to the given bo.
+ *
+ * This lets us release memory for reuse earlier for known-dead buffers,
+ * at the cost of walking the entire hash table.
+ */
+void
+brw_state_cache_bo_delete(struct brw_cache *cache, struct brw_winsys_buffer *bo)
+{
+   struct brw_cache_item **prev;
+   GLuint i;
+
+   if (BRW_DEBUG & DEBUG_STATE)
+      debug_printf("%s\n", __FUNCTION__);
+
+   for (i = 0; i < cache->size; i++) {
+      for (prev = &cache->items[i]; *prev;) {
+        struct brw_cache_item *c = *prev;
+
+        if (cache->sws->bo_references(c->bo, bo)) {
+           int j;
+
+           *prev = c->next;
+
+           for (j = 0; j < c->nr_relocs; j++)
+              bo_reference(&c->relocs[j].bo, NULL);
+
+           bo_reference(&c->bo, NULL);
+
+           FREE((void *)c->key);
+           FREE(c);
+           cache->n_items--;
+        } else {
+           prev = &c->next;
+        }
+      }
+   }
+}
+
+void
+brw_state_cache_check_size(struct brw_context *brw)
+{
+   if (BRW_DEBUG & DEBUG_STATE)
+      debug_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->cache);
+
+   if (brw->surface_cache.n_items > 1000)
+      brw_clear_cache(brw, &brw->surface_cache);
+}
+
+
+static void
+brw_destroy_cache(struct brw_context *brw, struct brw_cache *cache)
+{
+   GLuint i;
+
+   if (BRW_DEBUG & DEBUG_STATE)
+      debug_printf("%s\n", __FUNCTION__);
+
+   brw_clear_cache(brw, cache);
+   for (i = 0; i < BRW_MAX_CACHE; i++) {
+      bo_reference(&cache->last_bo[i], NULL);
+      FREE(cache->name[i]);
+   }
+   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);
+}
diff --git a/src/gallium/drivers/i965/brw_state_debug.c b/src/gallium/drivers/i965/brw_state_debug.c
new file mode 100644 (file)
index 0000000..049c278
--- /dev/null
@@ -0,0 +1,153 @@
+/*
+ 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.
+ **********************************************************************/
+      
+
+
+#include "brw_context.h"
+#include "brw_state.h"
+
+
+struct dirty_bit_map {
+   uint32_t bit;
+   char *name;
+   uint32_t count;
+};
+
+#define DEFINE_BIT(name) {name, #name, 0}
+
+static struct dirty_bit_map mesa_bits[] = {
+   DEFINE_BIT(PIPE_NEW_DEPTH_STENCIL_ALPHA),
+   DEFINE_BIT(PIPE_NEW_RAST),
+   DEFINE_BIT(PIPE_NEW_BLEND),
+   DEFINE_BIT(PIPE_NEW_VIEWPORT),
+   DEFINE_BIT(PIPE_NEW_SAMPLERS),
+   DEFINE_BIT(PIPE_NEW_VERTEX_BUFFER),
+   DEFINE_BIT(PIPE_NEW_VERTEX_ELEMENT),
+   DEFINE_BIT(PIPE_NEW_FRAGMENT_SHADER),
+   DEFINE_BIT(PIPE_NEW_VERTEX_SHADER),
+   DEFINE_BIT(PIPE_NEW_FRAGMENT_CONSTANTS),
+   DEFINE_BIT(PIPE_NEW_VERTEX_CONSTANTS),
+   DEFINE_BIT(PIPE_NEW_CLIP),
+   DEFINE_BIT(PIPE_NEW_INDEX_BUFFER),
+   DEFINE_BIT(PIPE_NEW_INDEX_RANGE),
+   DEFINE_BIT(PIPE_NEW_BLEND_COLOR),
+   DEFINE_BIT(PIPE_NEW_POLYGON_STIPPLE),
+   DEFINE_BIT(PIPE_NEW_FRAMEBUFFER_DIMENSIONS),
+   DEFINE_BIT(PIPE_NEW_DEPTH_BUFFER),
+   DEFINE_BIT(PIPE_NEW_COLOR_BUFFERS),
+   DEFINE_BIT(PIPE_NEW_QUERY),
+   DEFINE_BIT(PIPE_NEW_SCISSOR),
+   DEFINE_BIT(PIPE_NEW_BOUND_TEXTURES),
+   DEFINE_BIT(PIPE_NEW_NR_CBUFS),
+   {0, 0, 0}
+};
+
+static struct dirty_bit_map brw_bits[] = {
+   DEFINE_BIT(BRW_NEW_URB_FENCE),
+   DEFINE_BIT(BRW_NEW_FRAGMENT_PROGRAM),
+   DEFINE_BIT(BRW_NEW_VERTEX_PROGRAM),
+   DEFINE_BIT(BRW_NEW_INPUT_DIMENSIONS),
+   DEFINE_BIT(BRW_NEW_CURBE_OFFSETS),
+   DEFINE_BIT(BRW_NEW_REDUCED_PRIMITIVE),
+   DEFINE_BIT(BRW_NEW_PRIMITIVE),
+   DEFINE_BIT(BRW_NEW_CONTEXT),
+   DEFINE_BIT(BRW_NEW_WM_INPUT_DIMENSIONS),
+   DEFINE_BIT(BRW_NEW_PSP),
+   DEFINE_BIT(BRW_NEW_WM_SURFACES),
+   DEFINE_BIT(BRW_NEW_xxx),
+   DEFINE_BIT(BRW_NEW_INDICES),
+   {0, 0, 0}
+};
+
+static struct dirty_bit_map cache_bits[] = {
+   DEFINE_BIT(CACHE_NEW_CC_VP),
+   DEFINE_BIT(CACHE_NEW_CC_UNIT),
+   DEFINE_BIT(CACHE_NEW_WM_PROG),
+   DEFINE_BIT(CACHE_NEW_SAMPLER_DEFAULT_COLOR),
+   DEFINE_BIT(CACHE_NEW_SAMPLER),
+   DEFINE_BIT(CACHE_NEW_WM_UNIT),
+   DEFINE_BIT(CACHE_NEW_SF_PROG),
+   DEFINE_BIT(CACHE_NEW_SF_VP),
+   DEFINE_BIT(CACHE_NEW_SF_UNIT),
+   DEFINE_BIT(CACHE_NEW_VS_UNIT),
+   DEFINE_BIT(CACHE_NEW_VS_PROG),
+   DEFINE_BIT(CACHE_NEW_GS_UNIT),
+   DEFINE_BIT(CACHE_NEW_GS_PROG),
+   DEFINE_BIT(CACHE_NEW_CLIP_VP),
+   DEFINE_BIT(CACHE_NEW_CLIP_UNIT),
+   DEFINE_BIT(CACHE_NEW_CLIP_PROG),
+   DEFINE_BIT(CACHE_NEW_SURFACE),
+   DEFINE_BIT(CACHE_NEW_SURF_BIND),
+   {0, 0, 0}
+};
+
+
+static void
+brw_update_dirty_count(struct dirty_bit_map *bit_map, int32_t bits)
+{
+   int i;
+
+   for (i = 0; i < 32; i++) {
+      if (bit_map[i].bit == 0)
+        return;
+
+      if (bit_map[i].bit & bits)
+        bit_map[i].count++;
+   }
+}
+
+static void
+brw_print_dirty_count(struct dirty_bit_map *bit_map, int32_t bits)
+{
+   int i;
+
+   for (i = 0; i < 32; i++) {
+      if (bit_map[i].bit == 0)
+        return;
+
+      debug_printf("0x%08x: %12d (%s)\n",
+             bit_map[i].bit, bit_map[i].count, bit_map[i].name);
+   }
+}
+
+void
+brw_update_dirty_counts( unsigned mesa,
+                        unsigned brw,
+                        unsigned cache )
+{
+   static int dirty_count = 0;
+
+   brw_update_dirty_count(mesa_bits, mesa);
+   brw_update_dirty_count(brw_bits, brw);
+   brw_update_dirty_count(cache_bits, cache);
+      if (dirty_count++ % 1000 == 0) {
+        brw_print_dirty_count(mesa_bits, mesa);
+        brw_print_dirty_count(brw_bits, brw);
+        brw_print_dirty_count(cache_bits, cache);
+        debug_printf("\n");
+      }
+}
diff --git a/src/gallium/drivers/i965/brw_state_upload.c b/src/gallium/drivers/i965/brw_state_upload.c
new file mode 100644 (file)
index 0000000..f8b91ef
--- /dev/null
@@ -0,0 +1,270 @@
+/*
+ Copyright (C) Intel Corp.  2006.  All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ **********************************************************************/
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  */
+       
+
+
+#include "brw_context.h"
+#include "brw_state.h"
+#include "brw_batchbuffer.h"
+#include "brw_debug.h"
+
+const struct brw_tracked_state *atoms[] =
+{
+/*   &brw_wm_input_sizes, */
+   &brw_vs_prog,
+   &brw_gs_prog, 
+   &brw_clip_prog, 
+   &brw_sf_prog,
+   &brw_wm_prog,
+
+   /* Once all the programs are done, we know how large urb entry
+    * sizes need to be and can decide if we need to change the urb
+    * layout.
+    */
+   &brw_curbe_offsets,
+   &brw_recalculate_urb_fence,
+
+   &brw_cc_vp,
+   &brw_cc_unit,
+
+   &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,
+   &brw_sf_vp,
+   &brw_sf_unit,
+   &brw_vs_unit,               /* always required, enabled or not */
+   &brw_clip_unit,
+   &brw_gs_unit,  
+
+   /* Command packets:
+    */
+   &brw_invarient_state,
+   &brw_state_base_address,
+
+   &brw_binding_table_pointers,
+   &brw_blend_constant_color,
+
+   &brw_depthbuffer,
+   &brw_polygon_stipple,
+   &brw_line_stipple,
+
+   &brw_psp_urb_cbs,
+
+   &brw_drawing_rect,
+   &brw_indices,
+   &brw_index_buffer,
+   &brw_vertices,
+
+   &brw_curbe_buffer
+};
+
+
+void brw_init_state( struct brw_context *brw )
+{
+   brw_init_caches(brw);
+}
+
+
+void brw_destroy_state( struct brw_context *brw )
+{
+   brw_destroy_caches(brw);
+   brw_destroy_batch_cache(brw);
+}
+
+/***********************************************************************
+ */
+
+static GLboolean check_state( const struct brw_state_flags *a,
+                             const struct brw_state_flags *b )
+{
+   return ((a->mesa & b->mesa) ||
+          (a->brw & b->brw) ||
+          (a->cache & b->cache));
+}
+
+static void accumulate_state( struct brw_state_flags *a,
+                             const struct brw_state_flags *b )
+{
+   a->mesa |= b->mesa;
+   a->brw |= b->brw;
+   a->cache |= b->cache;
+}
+
+
+static void xor_states( struct brw_state_flags *result,
+                            const struct brw_state_flags *a,
+                             const struct brw_state_flags *b )
+{
+   result->mesa = a->mesa ^ b->mesa;
+   result->brw = a->brw ^ b->brw;
+   result->cache = a->cache ^ b->cache;
+}
+
+static void
+brw_clear_validated_bos(struct brw_context *brw)
+{
+   int i;
+
+   /* Clear the last round of validated bos */
+   for (i = 0; i < brw->state.validated_bo_count; i++) {
+      bo_reference(&brw->state.validated_bos[i], NULL);
+   }
+   brw->state.validated_bo_count = 0;
+}
+
+
+/***********************************************************************
+ * Emit all state:
+ */
+enum pipe_error brw_validate_state( struct brw_context *brw )
+{
+   struct brw_state_flags *state = &brw->state.dirty;
+   GLuint i;
+   int ret;
+
+   brw_clear_validated_bos(brw);
+   brw_add_validated_bo(brw, brw->batch->buf);
+
+   if (brw->flags.always_emit_state) {
+      state->mesa |= ~0;
+      state->brw |= ~0;
+      state->cache |= ~0;
+   }
+
+   if (state->mesa == 0 &&
+       state->cache == 0 &&
+       state->brw == 0)
+      return 0;
+
+   if (brw->state.dirty.brw & BRW_NEW_CONTEXT)
+      brw_clear_batch_cache(brw);
+
+   /* do prepare stage for all atoms */
+   for (i = 0; i < Elements(atoms); i++) {
+      const struct brw_tracked_state *atom = atoms[i];
+
+      if (check_state(state, &atom->dirty)) {
+         if (atom->prepare) {
+            ret = atom->prepare(brw);
+           if (ret)
+              return ret;
+        }
+      }
+   }
+
+   /* Make sure that the textures which are referenced by the current
+    * brw fragment program are actually present/valid.
+    * If this fails, we can experience GPU lock-ups.
+    */
+   {
+      const struct brw_fragment_shader *fp = brw->curr.fragment_shader;
+      if (fp) {
+         assert(fp->info.file_max[TGSI_FILE_SAMPLER] < (int)brw->curr.num_samplers);
+        /*assert(fp->info.texture_max <= brw->curr.num_textures);*/
+      }
+   }
+
+   return 0;
+}
+
+
+enum pipe_error brw_upload_state(struct brw_context *brw)
+{
+   struct brw_state_flags *state = &brw->state.dirty;
+   int ret;
+   int i;
+
+   brw_clear_validated_bos(brw);
+
+   if (BRW_DEBUG) {
+      /* Debug version which enforces various sanity checks on the
+       * state flags which are generated and checked to help ensure
+       * state atoms are ordered correctly in the list.
+       */
+      struct brw_state_flags examined, prev;      
+      memset(&examined, 0, sizeof(examined));
+      prev = *state;
+
+      for (i = 0; i < Elements(atoms); i++) {
+        const struct brw_tracked_state *atom = atoms[i];
+        struct brw_state_flags generated;
+
+        assert(atom->dirty.mesa ||
+               atom->dirty.brw ||
+               atom->dirty.cache);
+
+        if (check_state(state, &atom->dirty)) {
+           if (atom->emit) {
+              ret = atom->emit( brw );
+              if (ret)
+                 return ret;
+           }
+        }
+
+        accumulate_state(&examined, &atom->dirty);
+
+        /* generated = (prev ^ state)
+         * if (examined & generated)
+         *     fail;
+         */
+        xor_states(&generated, &prev, state);
+        assert(!check_state(&examined, &generated));
+        prev = *state;
+      }
+   }
+   else {
+      for (i = 0; i < Elements(atoms); i++) {   
+        const struct brw_tracked_state *atom = atoms[i];
+
+        if (check_state(state, &atom->dirty)) {
+           if (atom->emit) {
+              ret = atom->emit( brw );
+              if (ret)
+                 return ret;
+           }
+        }
+      }
+   }
+
+   if (BRW_DEBUG & DEBUG_STATE) {
+      brw_update_dirty_counts( state->mesa, 
+                              state->brw,
+                              state->cache );
+   }
+   
+   /* Clear dirty flags:
+    */
+   memset(state, 0, sizeof(*state));
+   return 0;
+}
diff --git a/src/gallium/drivers/i965/brw_structs.h b/src/gallium/drivers/i965/brw_structs.h
new file mode 100644 (file)
index 0000000..bf10bc0
--- /dev/null
@@ -0,0 +1,1576 @@
+/*
+ Copyright (C) Intel Corp.  2006.  All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ **********************************************************************/
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  */
+        
+
+#ifndef BRW_STRUCTS_H
+#define BRW_STRUCTS_H
+
+#include "brw_types.h"
+
+/** Number of general purpose registers (VS, WM, etc) */
+#define BRW_MAX_GRF 128
+
+/** Number of message register file registers */
+#define BRW_MAX_MRF 16
+
+
+/* Command packets:
+ */
+struct header 
+{
+   GLuint length:16; 
+   GLuint opcode:16; 
+};
+
+
+union header_union
+{
+   struct header bits;
+   GLuint dword;
+};
+
+struct brw_3d_control
+{   
+   struct 
+   {
+      GLuint length:8;
+      GLuint notify_enable:1;
+      GLuint pad:3;
+      GLuint wc_flush_enable:1; 
+      GLuint depth_stall_enable:1; 
+      GLuint operation:2; 
+      GLuint opcode:16; 
+   } header;
+   
+   struct
+   {
+      GLuint pad:2;
+      GLuint dest_addr_type:1; 
+      GLuint dest_addr:29; 
+   } dest;
+   
+   GLuint dword2;   
+   GLuint dword3;   
+};
+
+
+struct brw_3d_primitive
+{
+   struct
+   {
+      GLuint length:8; 
+      GLuint pad:2;
+      GLuint topology:5; 
+      GLuint indexed:1; 
+      GLuint opcode:16; 
+   } header;
+
+   GLuint verts_per_instance;  
+   GLuint start_vert_location;  
+   GLuint instance_count;  
+   GLuint start_instance_location;  
+   GLuint base_vert_location;  
+};
+
+/* These seem to be passed around as function args, so it works out
+ * better to keep them as #defines:
+ */
+#define BRW_FLUSH_READ_CACHE           0x1
+#define BRW_FLUSH_STATE_CACHE          0x2
+#define BRW_INHIBIT_FLUSH_RENDER_CACHE 0x4
+#define BRW_FLUSH_SNAPSHOT_COUNTERS    0x8
+
+struct brw_mi_flush
+{
+   GLuint flags:4;
+   GLuint pad:12;
+   GLuint opcode:16;
+};
+
+struct brw_vf_statistics
+{
+   GLuint statistics_enable:1;
+   GLuint pad:15;
+   GLuint opcode:16;
+};
+
+
+
+struct brw_binding_table_pointers
+{
+   struct header header;
+   GLuint vs; 
+   GLuint gs; 
+   GLuint clp; 
+   GLuint sf; 
+   GLuint wm; 
+};
+
+
+struct brw_blend_constant_color
+{
+   struct header header;
+   GLfloat blend_constant_color[4];  
+};
+
+
+struct brw_depthbuffer
+{
+   union header_union header;
+   
+   union {
+      struct {
+        GLuint pitch:18; 
+        GLuint format:3; 
+        GLuint pad:2;
+        GLuint software_tiled_rendering_mode:2;
+        GLuint depth_offset_disable:1; 
+        GLuint tile_walk:1; 
+        GLuint tiled_surface:1; 
+        GLuint pad2:1;
+        GLuint surface_type:3; 
+      } bits;
+      GLuint dword;
+   } dword1;
+   
+   GLuint dword2_base_addr; 
+   union {
+      struct {
+        GLuint pad:1;
+        GLuint mipmap_layout:1; 
+        GLuint lod:4; 
+        GLuint width:13; 
+        GLuint height:13; 
+      } bits;
+      GLuint dword;
+   } dword3;
+
+   union {
+      struct {
+        GLuint pad:10;
+        GLuint min_array_element:11; 
+        GLuint depth:11; 
+      } bits;
+      GLuint dword;
+   } dword4;
+};
+
+struct brw_depthbuffer_g4x
+{
+   union header_union header;
+   
+   union {
+      struct {
+        GLuint pitch:18; 
+        GLuint format:3; 
+        GLuint pad:2;
+        GLuint software_tiled_rendering_mode:2;
+        GLuint depth_offset_disable:1; 
+        GLuint tile_walk:1; 
+        GLuint tiled_surface:1; 
+        GLuint pad2:1;
+        GLuint surface_type:3; 
+      } bits;
+      GLuint dword;
+   } dword1;
+   
+   GLuint dword2_base_addr; 
+   union {
+      struct {
+        GLuint pad:1;
+        GLuint mipmap_layout:1; 
+        GLuint lod:4; 
+        GLuint width:13; 
+        GLuint height:13; 
+      } bits;
+      GLuint dword;
+   } dword3;
+
+   union {
+      struct {
+        GLuint pad:10;
+        GLuint min_array_element:11; 
+        GLuint depth:11; 
+      } bits;
+      GLuint dword;
+   } dword4;
+
+   union {
+      struct {
+         GLuint xoffset:16;
+         GLuint yoffset:16;
+      } bits;
+      GLuint dword;
+   } dword5;   /* NEW in Integrated Graphics Device */
+};
+
+struct brw_drawrect
+{
+   struct header header;
+   GLuint xmin:16; 
+   GLuint ymin:16; 
+   GLuint xmax:16; 
+   GLuint ymax:16; 
+   GLuint xorg:16;  
+   GLuint yorg:16;  
+};
+
+
+
+
+struct brw_global_depth_offset_clamp
+{
+   struct header header;
+   GLfloat depth_offset_clamp;  
+};
+
+struct brw_indexbuffer
+{   
+   union {
+      struct
+      {
+        GLuint length:8; 
+        GLuint index_format:2; 
+        GLuint cut_index_enable:1; 
+        GLuint pad:5; 
+        GLuint opcode:16; 
+      } bits;
+      GLuint dword;
+
+   } header;
+
+   GLuint buffer_start; 
+   GLuint buffer_end; 
+};
+
+/* NEW in Integrated Graphics Device */
+struct brw_aa_line_parameters
+{
+   struct header header;
+
+   struct {
+      GLuint aa_coverage_scope:8;
+      GLuint pad0:8;
+      GLuint aa_coverage_bias:8;
+      GLuint pad1:8;
+   } bits0;
+
+   struct {
+      GLuint aa_coverage_endcap_slope:8;
+      GLuint pad0:8;
+      GLuint aa_coverage_endcap_bias:8;
+      GLuint pad1:8;
+   } bits1;
+};
+
+struct brw_line_stipple
+{   
+   struct header header;
+  
+   struct
+   {
+      GLuint pattern:16; 
+      GLuint pad:16;
+   } bits0;
+   
+   struct
+   {
+      GLuint repeat_count:9; 
+      GLuint pad:7;
+      GLuint inverse_repeat_count:16; 
+   } bits1;
+};
+
+
+struct brw_pipelined_state_pointers
+{
+   struct header header;
+   
+   struct {
+      GLuint pad:5;
+      GLuint offset:27; /* Offset from GENERAL_STATE_BASE */
+   } vs;
+   
+   struct
+   {
+      GLuint enable:1;
+      GLuint pad:4;
+      GLuint offset:27; /* Offset from GENERAL_STATE_BASE */
+   } gs;
+   
+   struct
+   {
+      GLuint enable:1;
+      GLuint pad:4;
+      GLuint offset:27; /* Offset from GENERAL_STATE_BASE */
+   } clp;
+   
+   struct
+   {
+      GLuint pad:5;
+      GLuint offset:27; /* Offset from GENERAL_STATE_BASE */
+   } sf;
+
+   struct
+   {
+      GLuint pad:5;
+      GLuint offset:27; /* Offset from GENERAL_STATE_BASE */
+   } wm;
+   
+   struct
+   {
+      GLuint pad:5;
+      GLuint offset:27; /* Offset from GENERAL_STATE_BASE. KW: check me! */
+   } cc;
+};
+
+
+struct brw_polygon_stipple_offset
+{
+   struct header header;
+
+   struct {
+      GLuint y_offset:5; 
+      GLuint pad:3;
+      GLuint x_offset:5; 
+      GLuint pad0:19;
+   } bits0;
+};
+
+
+
+struct brw_polygon_stipple
+{
+   struct header header;
+   GLuint stipple[32];
+};
+
+
+
+struct brw_pipeline_select
+{
+   struct
+   {
+      GLuint pipeline_select:1;   
+      GLuint pad:15;
+      GLuint opcode:16;   
+   } header;
+};
+
+
+struct brw_pipe_control
+{
+   struct
+   {
+      GLuint length:8;
+      GLuint notify_enable:1;
+      GLuint texture_cache_flush_enable:1;
+      GLuint indirect_state_pointers_disable:1;
+      GLuint instruction_state_cache_flush_enable:1;
+      GLuint write_cache_flush_enable:1;
+      GLuint depth_stall_enable:1;
+      GLuint post_sync_operation:2;
+
+      GLuint opcode:16;
+   } header;
+
+   struct
+   {
+      GLuint pad:2;
+      GLuint dest_addr_type:1;
+      GLuint dest_addr:29;
+   } bits1;
+
+   GLuint data0;
+   GLuint data1;
+};
+
+
+struct brw_urb_fence
+{
+   struct
+   {
+      GLuint length:8;   
+      GLuint vs_realloc:1;   
+      GLuint gs_realloc:1;   
+      GLuint clp_realloc:1;   
+      GLuint sf_realloc:1;   
+      GLuint vfe_realloc:1;   
+      GLuint cs_realloc:1;   
+      GLuint pad:2;
+      GLuint opcode:16;   
+   } header;
+
+   struct
+   {
+      GLuint vs_fence:10;  
+      GLuint gs_fence:10;  
+      GLuint clp_fence:10;  
+      GLuint pad:2;
+   } bits0;
+
+   struct
+   {
+      GLuint sf_fence:10;  
+      GLuint vf_fence:10;  
+      GLuint cs_fence:11;  
+      GLuint pad:1;
+   } bits1;
+};
+
+struct brw_cs_urb_state
+{
+   struct header header;
+
+   struct
+   {
+      GLuint nr_urb_entries:3;   
+      GLuint pad:1;
+      GLuint urb_entry_size:5;   
+      GLuint pad0:23;
+   } bits0;
+};
+
+struct brw_constant_buffer
+{
+   struct
+   {
+      GLuint length:8;   
+      GLuint valid:1;   
+      GLuint pad:7;
+      GLuint opcode:16;   
+   } header;
+
+   struct
+   {
+      GLuint buffer_length:6;   
+      GLuint buffer_address:26;  
+   } bits0;
+};
+
+struct brw_state_base_address
+{
+   struct header header;
+
+   struct
+   {
+      GLuint modify_enable:1;
+      GLuint pad:4;
+      GLuint general_state_address:27;  
+   } bits0;
+
+   struct
+   {
+      GLuint modify_enable:1;
+      GLuint pad:4;
+      GLuint surface_state_address:27;  
+   } bits1;
+
+   struct
+   {
+      GLuint modify_enable:1;
+      GLuint pad:4;
+      GLuint indirect_object_state_address:27;  
+   } bits2;
+
+   struct
+   {
+      GLuint modify_enable:1;
+      GLuint pad:11;
+      GLuint general_state_upper_bound:20;  
+   } bits3;
+
+   struct
+   {
+      GLuint modify_enable:1;
+      GLuint pad:11;
+      GLuint indirect_object_state_upper_bound:20;  
+   } bits4;
+};
+
+struct brw_state_prefetch
+{
+   struct header header;
+
+   struct
+   {
+      GLuint prefetch_count:3;   
+      GLuint pad:3;
+      GLuint prefetch_pointer:26;  
+   } bits0;
+};
+
+struct brw_system_instruction_pointer
+{
+   struct header header;
+
+   struct
+   {
+      GLuint pad:4;
+      GLuint system_instruction_pointer:28;  
+   } bits0;
+};
+
+
+
+
+/* State structs for the various fixed function units:
+ */
+
+
+struct thread0
+{
+   GLuint pad0:1;
+   GLuint grf_reg_count:3; 
+   GLuint pad1:2;
+   GLuint kernel_start_pointer:26; /* Offset from GENERAL_STATE_BASE */
+};
+
+struct thread1
+{
+   GLuint ext_halt_exception_enable:1; 
+   GLuint sw_exception_enable:1; 
+   GLuint mask_stack_exception_enable:1; 
+   GLuint timeout_exception_enable:1; 
+   GLuint illegal_op_exception_enable:1; 
+   GLuint pad0:3;
+   GLuint depth_coef_urb_read_offset:6;        /* WM only */
+   GLuint pad1:2;
+   GLuint floating_point_mode:1; 
+   GLuint thread_priority:1; 
+   GLuint binding_table_entry_count:8; 
+   GLuint pad3:5;
+   GLuint single_program_flow:1; 
+};
+
+struct thread2
+{
+   GLuint per_thread_scratch_space:4; 
+   GLuint pad0:6;
+   GLuint scratch_space_base_pointer:22; 
+};
+
+   
+struct thread3
+{
+   GLuint dispatch_grf_start_reg:4; 
+   GLuint urb_entry_read_offset:6; 
+   GLuint pad0:1;
+   GLuint urb_entry_read_length:6; 
+   GLuint pad1:1;
+   GLuint const_urb_entry_read_offset:6; 
+   GLuint pad2:1;
+   GLuint const_urb_entry_read_length:6; 
+   GLuint pad3:1;
+};
+
+
+
+struct brw_clip_unit_state
+{
+   struct thread0 thread0;
+   struct
+   {
+      GLuint pad0:7;
+      GLuint sw_exception_enable:1;
+      GLuint pad1:3;
+      GLuint mask_stack_exception_enable:1;
+      GLuint pad2:1;
+      GLuint illegal_op_exception_enable:1;
+      GLuint pad3:2;
+      GLuint floating_point_mode:1;
+      GLuint thread_priority:1;
+      GLuint binding_table_entry_count:8;
+      GLuint pad4:5;
+      GLuint single_program_flow:1;
+   } thread1;
+
+   struct thread2 thread2;
+   struct thread3 thread3;
+
+   struct
+   {
+      GLuint pad0:9;
+      GLuint gs_output_stats:1; /* not always */
+      GLuint stats_enable:1; 
+      GLuint nr_urb_entries:7; 
+      GLuint pad1:1;
+      GLuint urb_entry_allocation_size:5; 
+      GLuint pad2:1;
+      GLuint max_threads:5;    /* may be less */
+      GLuint pad3:2;
+   } thread4;   
+      
+   struct
+   {
+      GLuint pad0:13;
+      GLuint clip_mode:3; 
+      GLuint userclip_enable_flags:8; 
+      GLuint userclip_must_clip:1; 
+      GLuint negative_w_clip_test:1;
+      GLuint guard_band_enable:1; 
+      GLuint viewport_z_clip_enable:1; 
+      GLuint viewport_xy_clip_enable:1; 
+      GLuint vertex_position_space:1; 
+      GLuint api_mode:1; 
+      GLuint pad2:1;
+   } clip5;
+   
+   struct
+   {
+      GLuint pad0:5;
+      GLuint clipper_viewport_state_ptr:27; 
+   } clip6;
+
+   
+   GLfloat viewport_xmin;  
+   GLfloat viewport_xmax;  
+   GLfloat viewport_ymin;  
+   GLfloat viewport_ymax;  
+};
+
+
+
+struct brw_cc_unit_state
+{
+   struct brw_cc0
+   {
+      GLuint pad0:3;
+      GLuint bf_stencil_pass_depth_pass_op:3; 
+      GLuint bf_stencil_pass_depth_fail_op:3; 
+      GLuint bf_stencil_fail_op:3; 
+      GLuint bf_stencil_func:3; 
+      GLuint bf_stencil_enable:1; 
+      GLuint pad1:2;
+      GLuint stencil_write_enable:1; 
+      GLuint stencil_pass_depth_pass_op:3; 
+      GLuint stencil_pass_depth_fail_op:3; 
+      GLuint stencil_fail_op:3; 
+      GLuint stencil_func:3; 
+      GLuint stencil_enable:1; 
+   } cc0;
+
+   
+   struct brw_cc1
+   {
+      GLuint bf_stencil_ref:8; 
+      GLuint stencil_write_mask:8; 
+      GLuint stencil_test_mask:8; 
+      GLuint stencil_ref:8; 
+   } cc1;
+
+   
+   struct brw_cc2
+   {
+      GLuint logicop_enable:1; 
+      GLuint pad0:10;
+      GLuint depth_write_enable:1; 
+      GLuint depth_test_function:3; 
+      GLuint depth_test:1; 
+      GLuint bf_stencil_write_mask:8; 
+      GLuint bf_stencil_test_mask:8; 
+   } cc2;
+
+   
+   struct brw_cc3
+   {
+      GLuint pad0:8;
+      GLuint alpha_test_func:3; 
+      GLuint alpha_test:1; 
+      GLuint blend_enable:1; 
+      GLuint ia_blend_enable:1; 
+      GLuint pad1:1;
+      GLuint alpha_test_format:1;
+      GLuint pad2:16;
+   } cc3;
+   
+   struct brw_cc4
+   {
+      GLuint pad0:5; 
+      GLuint cc_viewport_state_offset:27; /* Offset from GENERAL_STATE_BASE */
+   } cc4;
+   
+   struct brw_cc5
+   {
+      GLuint pad0:2;
+      GLuint ia_dest_blend_factor:5; 
+      GLuint ia_src_blend_factor:5; 
+      GLuint ia_blend_function:3; 
+      GLuint statistics_enable:1; 
+      GLuint logicop_func:4; 
+      GLuint pad1:11;
+      GLuint dither_enable:1; 
+   } cc5;
+
+   struct brw_cc6
+   {
+      GLuint clamp_post_alpha_blend:1; 
+      GLuint clamp_pre_alpha_blend:1; 
+      GLuint clamp_range:2; 
+      GLuint pad0:11;
+      GLuint y_dither_offset:2; 
+      GLuint x_dither_offset:2; 
+      GLuint dest_blend_factor:5; 
+      GLuint src_blend_factor:5; 
+      GLuint blend_function:3; 
+   } cc6;
+
+   struct brw_cc7 {
+      union {
+        GLfloat f;  
+        GLubyte ub[4];
+      } alpha_ref;
+   } cc7;
+};
+
+
+
+struct brw_sf_unit_state
+{
+   struct thread0 thread0;
+   struct thread1 thread1;
+   struct thread2 thread2;
+   struct thread3 thread3;
+
+   struct
+   {
+      GLuint pad0:10;
+      GLuint stats_enable:1; 
+      GLuint nr_urb_entries:7; 
+      GLuint pad1:1;
+      GLuint urb_entry_allocation_size:5; 
+      GLuint pad2:1;
+      GLuint max_threads:6; 
+      GLuint pad3:1;
+   } thread4;   
+
+   struct
+   {
+      GLuint front_winding:1; 
+      GLuint viewport_transform:1; 
+      GLuint pad0:3;
+      GLuint sf_viewport_state_offset:27; /* Offset from GENERAL_STATE_BASE */
+   } sf5;
+   
+   struct
+   {
+      GLuint pad0:9;
+      GLuint dest_org_vbias:4; 
+      GLuint dest_org_hbias:4; 
+      GLuint scissor:1; 
+      GLuint disable_2x2_trifilter:1; 
+      GLuint disable_zero_pix_trifilter:1; 
+      GLuint point_rast_rule:2; 
+      GLuint line_endcap_aa_region_width:2; 
+      GLuint line_width:4; 
+      GLuint fast_scissor_disable:1; 
+      GLuint cull_mode:2; 
+      GLuint aa_enable:1; 
+   } sf6;
+
+   struct
+   {
+      GLuint point_size:11; 
+      GLuint use_point_size_state:1; 
+      GLuint subpixel_precision:1; 
+      GLuint sprite_point:1; 
+      GLuint pad0:10;
+      GLuint aa_line_distance_mode:1;
+      GLuint trifan_pv:2; 
+      GLuint linestrip_pv:2; 
+      GLuint tristrip_pv:2; 
+      GLuint line_last_pixel_enable:1; 
+   } sf7;
+
+};
+
+
+struct brw_gs_unit_state
+{
+   struct thread0 thread0;
+   struct thread1 thread1;
+   struct thread2 thread2;
+   struct thread3 thread3;
+
+   struct
+   {
+      GLuint pad0:8;
+      GLuint rendering_enable:1; /* for IGDNG */
+      GLuint pad4:1;
+      GLuint stats_enable:1; 
+      GLuint nr_urb_entries:7; 
+      GLuint pad1:1;
+      GLuint urb_entry_allocation_size:5; 
+      GLuint pad2:1;
+      GLuint max_threads:5; 
+      GLuint pad3:2;
+   } thread4;   
+      
+   struct
+   {
+      GLuint sampler_count:3; 
+      GLuint pad0:2;
+      GLuint sampler_state_pointer:27; 
+   } gs5;
+
+   
+   struct
+   {
+      GLuint max_vp_index:4; 
+      GLuint pad0:12;
+      GLuint svbi_post_inc_value:10;
+      GLuint pad1:1;
+      GLuint svbi_post_inc_enable:1;
+      GLuint svbi_payload:1;
+      GLuint discard_adjaceny:1;
+      GLuint reorder_enable:1; 
+      GLuint pad2:1;
+   } gs6;
+};
+
+
+struct brw_vs_unit_state
+{
+   struct thread0 thread0;
+   struct thread1 thread1;
+   struct thread2 thread2;
+   struct thread3 thread3;
+   
+   struct
+   {
+      GLuint pad0:10;
+      GLuint stats_enable:1; 
+      GLuint nr_urb_entries:7; 
+      GLuint pad1:1;
+      GLuint urb_entry_allocation_size:5; 
+      GLuint pad2:1;
+      GLuint max_threads:6; 
+      GLuint pad3:1;
+   } thread4;   
+
+   struct
+   {
+      GLuint sampler_count:3; 
+      GLuint pad0:2;
+      GLuint sampler_state_pointer:27; 
+   } vs5;
+
+   struct
+   {
+      GLuint vs_enable:1; 
+      GLuint vert_cache_disable:1; 
+      GLuint pad0:30;
+   } vs6;
+};
+
+
+struct brw_wm_unit_state
+{
+   struct thread0 thread0;
+   struct thread1 thread1;
+   struct thread2 thread2;
+   struct thread3 thread3;
+   
+   struct {
+      GLuint stats_enable:1; 
+      GLuint depth_buffer_clear:1;
+      GLuint sampler_count:3; 
+      GLuint sampler_state_pointer:27; 
+   } wm4;
+   
+   struct
+   {
+      GLuint enable_8_pix:1; 
+      GLuint enable_16_pix:1; 
+      GLuint enable_32_pix:1; 
+      GLuint enable_con_32_pix:1;
+      GLuint enable_con_64_pix:1;
+      GLuint pad0:5;
+      GLuint legacy_global_depth_bias:1; 
+      GLuint line_stipple:1; 
+      GLuint depth_offset:1; 
+      GLuint polygon_stipple:1; 
+      GLuint line_aa_region_width:2; 
+      GLuint line_endcap_aa_region_width:2; 
+      GLuint early_depth_test:1; 
+      GLuint thread_dispatch_enable:1; 
+      GLuint program_uses_depth:1; 
+      GLuint program_computes_depth:1; 
+      GLuint program_uses_killpixel:1; 
+      GLuint legacy_line_rast: 1; 
+      GLuint transposed_urb_read_enable:1; 
+      GLuint max_threads:7; 
+   } wm5;
+   
+   GLfloat global_depth_offset_constant;  
+   GLfloat global_depth_offset_scale;   
+   
+   /* for IGDNG only */
+   struct {
+      GLuint pad0:1;
+      GLuint grf_reg_count_1:3; 
+      GLuint pad1:2;
+      GLuint kernel_start_pointer_1:26;
+   } wm8;       
+
+   struct {
+      GLuint pad0:1;
+      GLuint grf_reg_count_2:3; 
+      GLuint pad1:2;
+      GLuint kernel_start_pointer_2:26;
+   } wm9;       
+
+   struct {
+      GLuint pad0:1;
+      GLuint grf_reg_count_3:3; 
+      GLuint pad1:2;
+      GLuint kernel_start_pointer_3:26;
+   } wm10;       
+};
+
+struct brw_sampler_default_color {
+   GLfloat color[4];
+};
+
+struct brw_sampler_state
+{
+   
+   struct brw_ss0
+   {
+      GLuint shadow_function:3; 
+      GLuint lod_bias:11; 
+      GLuint min_filter:3; 
+      GLuint mag_filter:3; 
+      GLuint mip_filter:2; 
+      GLuint base_level:5; 
+      GLuint pad:1;
+      GLuint lod_preclamp:1; 
+      GLuint default_color_mode:1; 
+      GLuint pad0:1;
+      GLuint disable:1; 
+   } ss0;
+
+   struct brw_ss1
+   {
+      GLuint r_wrap_mode:3; 
+      GLuint t_wrap_mode:3; 
+      GLuint s_wrap_mode:3; 
+      GLuint pad:3;
+      GLuint max_lod:10; 
+      GLuint min_lod:10; 
+   } ss1;
+
+   
+   struct brw_ss2
+   {
+      GLuint pad:5;
+      GLuint default_color_pointer:27; 
+   } ss2;
+   
+   struct brw_ss3
+   {
+      GLuint pad:19;
+      GLuint max_aniso:3; 
+      GLuint chroma_key_mode:1; 
+      GLuint chroma_key_index:2; 
+      GLuint chroma_key_enable:1; 
+      GLuint monochrome_filter_width:3; 
+      GLuint monochrome_filter_height:3; 
+   } ss3;
+};
+
+
+struct brw_clipper_viewport
+{
+   GLfloat xmin;  
+   GLfloat xmax;  
+   GLfloat ymin;  
+   GLfloat ymax;  
+};
+
+struct brw_cc_viewport
+{
+   GLfloat min_depth;  
+   GLfloat max_depth;  
+};
+
+struct brw_sf_viewport
+{
+   struct {
+      GLfloat m00;  
+      GLfloat m11;  
+      GLfloat m22;  
+      GLfloat m30;  
+      GLfloat m31;  
+      GLfloat m32;  
+   } viewport;
+
+   /* scissor coordinates are inclusive */
+   struct {
+      GLshort xmin;
+      GLshort ymin;
+      GLshort xmax;
+      GLshort ymax;
+   } scissor;
+};
+
+/* Documented in the subsystem/shared-functions/sampler chapter...
+ */
+struct brw_surface_state
+{
+   struct brw_surf_ss0 {
+      GLuint cube_pos_z:1; 
+      GLuint cube_neg_z:1; 
+      GLuint cube_pos_y:1; 
+      GLuint cube_neg_y:1; 
+      GLuint cube_pos_x:1; 
+      GLuint cube_neg_x:1; 
+      GLuint pad:4;
+      GLuint mipmap_layout_mode:1; 
+      GLuint vert_line_stride_ofs:1; 
+      GLuint vert_line_stride:1; 
+      GLuint color_blend:1; 
+      GLuint writedisable_blue:1; 
+      GLuint writedisable_green:1; 
+      GLuint writedisable_red:1; 
+      GLuint writedisable_alpha:1; 
+      GLuint surface_format:9;     /**< BRW_SURFACEFORMAT_x */
+      GLuint data_return_format:1; 
+      GLuint pad0:1;
+      GLuint surface_type:3;       /**< BRW_SURFACE_1D/2D/3D/CUBE */
+   } ss0;
+   
+   struct brw_surf_ss1 {
+      GLuint base_addr;  
+   } ss1;
+   
+   struct brw_surf_ss2 {
+      GLuint pad:2;
+      GLuint mip_count:4; 
+      GLuint width:13; 
+      GLuint height:13; 
+   } ss2;
+
+   struct brw_surf_ss3 {
+      GLuint tile_walk:1; 
+      GLuint tiled_surface:1; 
+      GLuint pad:1; 
+      GLuint pitch:18; 
+      GLuint depth:11; 
+   } ss3;
+   
+   struct brw_surf_ss4 {
+      GLuint multisample_position_palette_index:3;
+      GLuint pad1:1;
+      GLuint num_multisamples:3;
+      GLuint pad0:1;
+      GLuint render_target_view_extent:9;
+      GLuint min_array_elt:11;
+      GLuint min_lod:4; 
+   } ss4;
+
+   struct brw_surf_ss5 {
+      GLuint pad1:16;
+      GLuint llc_mapping:1;
+      GLuint mlc_mapping:1;
+      GLuint gfdt:1;
+      GLuint gfdt_src:1;
+      GLuint y_offset:4;
+      GLuint pad0:1;
+      GLuint x_offset:7;
+   } ss5;   /* New in G4X */
+
+};
+
+
+
+struct brw_vertex_buffer_state
+{
+   struct {
+      GLuint pitch:11; 
+      GLuint pad:15;
+      GLuint access_type:1; 
+      GLuint vb_index:5; 
+   } vb0;
+   
+   GLuint start_addr; 
+   GLuint max_index;   
+#if 1
+   GLuint instance_data_step_rate; /* not included for sequential/random vertices? */
+#endif
+};
+
+#define BRW_VBP_MAX 17
+
+struct brw_vb_array_state {
+   struct header header;
+   struct brw_vertex_buffer_state vb[BRW_VBP_MAX];
+};
+
+
+struct brw_vertex_element_state
+{
+   struct
+   {
+      GLuint src_offset:11; 
+      GLuint pad:5;
+      GLuint src_format:9; 
+      GLuint pad0:1;
+      GLuint valid:1; 
+      GLuint vertex_buffer_index:5; 
+   } ve0;
+   
+   struct
+   {
+      GLuint dst_offset:8; 
+      GLuint pad:8;
+      GLuint vfcomponent3:4; 
+      GLuint vfcomponent2:4; 
+      GLuint vfcomponent1:4; 
+      GLuint vfcomponent0:4; 
+   } ve1;
+};
+
+#define BRW_VEP_MAX 18
+
+struct brw_vertex_element_packet {
+   struct header header;
+   struct brw_vertex_element_state ve[BRW_VEP_MAX]; /* note: less than _TNL_ATTRIB_MAX */
+};
+
+
+struct brw_urb_immediate {
+   GLuint opcode:4;
+   GLuint offset:6;
+   GLuint swizzle_control:2; 
+   GLuint pad:1;
+   GLuint allocate:1;
+   GLuint used:1;
+   GLuint complete:1;
+   GLuint response_length:4;
+   GLuint msg_length:4;
+   GLuint msg_target:4;
+   GLuint pad1:3;
+   GLuint end_of_thread:1;
+};
+
+/* Instruction format for the execution units:
+ */
+struct brw_instruction
+{
+   struct 
+   {
+      GLuint opcode:7;
+      GLuint pad:1;
+      GLuint access_mode:1;
+      GLuint mask_control:1;
+      GLuint dependency_control:2;
+      GLuint compression_control:2;
+      GLuint thread_control:2;
+      GLuint predicate_control:4;
+      GLuint predicate_inverse:1;
+      GLuint execution_size:3;
+      GLuint destreg__conditionalmod:4; /* destreg - send, conditionalmod - others */
+      GLuint pad0:2;
+      GLuint debug_control:1;
+      GLuint saturate:1;
+   } header;
+
+   union {
+      struct
+      {
+        GLuint dest_reg_file:2;
+        GLuint dest_reg_type:3;
+        GLuint src0_reg_file:2;
+        GLuint src0_reg_type:3;
+        GLuint src1_reg_file:2;
+        GLuint src1_reg_type:3;
+        GLuint pad:1;
+        GLuint dest_subreg_nr:5;
+        GLuint dest_reg_nr:8;
+        GLuint dest_horiz_stride:2;
+        GLuint dest_address_mode:1;
+      } da1;
+
+      struct
+      {
+        GLuint dest_reg_file:2;
+        GLuint dest_reg_type:3;
+        GLuint src0_reg_file:2;
+        GLuint src0_reg_type:3;
+        GLuint src1_reg_file:2;        /* 0x00000c00 */
+        GLuint src1_reg_type:3;        /* 0x00007000 */
+        GLuint pad:1;
+        GLint dest_indirect_offset:10; /* offset against the deref'd address reg */
+        GLuint dest_subreg_nr:3; /* subnr for the address reg a0.x */
+        GLuint dest_horiz_stride:2;
+        GLuint dest_address_mode:1;
+      } ia1;
+
+      struct
+      {
+        GLuint dest_reg_file:2;
+        GLuint dest_reg_type:3;
+        GLuint src0_reg_file:2;
+        GLuint src0_reg_type:3;
+        GLuint src1_reg_file:2;
+        GLuint src1_reg_type:3;
+        GLuint pad:1;
+        GLuint dest_writemask:4;
+        GLuint dest_subreg_nr:1;
+        GLuint dest_reg_nr:8;
+        GLuint pad1:2;
+        GLuint dest_address_mode:1;
+      } da16;
+
+      struct
+      {
+        GLuint dest_reg_file:2;
+        GLuint dest_reg_type:3;
+        GLuint src0_reg_file:2;
+        GLuint src0_reg_type:3;
+        GLuint pad0:6;
+        GLuint dest_writemask:4;
+        GLint dest_indirect_offset:6;
+        GLuint dest_subreg_nr:3;
+        GLuint pad1:2;
+        GLuint dest_address_mode:1;
+      } ia16;
+   } bits1;
+
+
+   union {
+      struct
+      {
+        GLuint src0_subreg_nr:5;
+        GLuint src0_reg_nr:8;
+        GLuint src0_abs:1;
+        GLuint src0_negate:1;
+        GLuint src0_address_mode:1;
+        GLuint src0_horiz_stride:2;
+        GLuint src0_width:3;
+        GLuint src0_vert_stride:4;
+        GLuint flag_reg_nr:1;
+        GLuint pad:6;
+      } da1;
+
+      struct
+      {
+        GLint src0_indirect_offset:10;
+        GLuint src0_subreg_nr:3;
+        GLuint src0_abs:1;
+        GLuint src0_negate:1;
+        GLuint src0_address_mode:1;
+        GLuint src0_horiz_stride:2;
+        GLuint src0_width:3;
+        GLuint src0_vert_stride:4;
+        GLuint flag_reg_nr:1;
+        GLuint pad:6;  
+      } ia1;
+
+      struct
+      {
+        GLuint src0_swz_x:2;
+        GLuint src0_swz_y:2;
+        GLuint src0_subreg_nr:1;
+        GLuint src0_reg_nr:8;
+        GLuint src0_abs:1;
+        GLuint src0_negate:1;
+        GLuint src0_address_mode:1;
+        GLuint src0_swz_z:2;
+        GLuint src0_swz_w:2;
+        GLuint pad0:1;
+        GLuint src0_vert_stride:4;
+        GLuint flag_reg_nr:1;
+        GLuint pad1:6;
+      } da16;
+
+      struct
+      {
+        GLuint src0_swz_x:2;
+        GLuint src0_swz_y:2;
+        GLint src0_indirect_offset:6;
+        GLuint src0_subreg_nr:3;
+        GLuint src0_abs:1;
+        GLuint src0_negate:1;
+        GLuint src0_address_mode:1;
+        GLuint src0_swz_z:2;
+        GLuint src0_swz_w:2;
+        GLuint pad0:1;
+        GLuint src0_vert_stride:4;
+        GLuint flag_reg_nr:1;
+        GLuint pad1:6;
+      } ia16;
+
+       struct 
+       {
+           GLuint pad:26;
+           GLuint end_of_thread:1;
+           GLuint pad1:1;
+           GLuint sfid:4;
+       } send_igdng;  /* for IGDNG only */
+
+   } bits2;
+
+   union
+   {
+      struct
+      {
+        GLuint src1_subreg_nr:5;
+        GLuint src1_reg_nr:8;
+        GLuint src1_abs:1;
+        GLuint src1_negate:1;
+        GLuint src1_address_mode:1;
+        GLuint src1_horiz_stride:2;
+        GLuint src1_width:3;
+        GLuint src1_vert_stride:4;
+        GLuint pad0:7;
+      } da1;
+
+      struct
+      {
+        GLuint src1_swz_x:2;
+        GLuint src1_swz_y:2;
+        GLuint src1_subreg_nr:1;
+        GLuint src1_reg_nr:8;
+        GLuint src1_abs:1;
+        GLuint src1_negate:1;
+        GLuint src1_address_mode:1;
+        GLuint src1_swz_z:2;
+        GLuint src1_swz_w:2;
+        GLuint pad1:1;
+        GLuint src1_vert_stride:4;
+        GLuint pad2:7;
+      } da16;
+
+      struct
+      {
+        GLint  src1_indirect_offset:10;
+        GLuint src1_subreg_nr:3;
+        GLuint src1_abs:1;
+        GLuint src1_negate:1;
+        GLuint src1_address_mode:1;
+        GLuint src1_horiz_stride:2;
+        GLuint src1_width:3;
+        GLuint src1_vert_stride:4;
+        GLuint flag_reg_nr:1;
+        GLuint pad1:6; 
+      } ia1;
+
+      struct
+      {
+        GLuint src1_swz_x:2;
+        GLuint src1_swz_y:2;
+        GLint  src1_indirect_offset:6;
+        GLuint src1_subreg_nr:3;
+        GLuint src1_abs:1;
+        GLuint src1_negate:1;
+        GLuint pad0:1;
+        GLuint src1_swz_z:2;
+        GLuint src1_swz_w:2;
+        GLuint pad1:1;
+        GLuint src1_vert_stride:4;
+        GLuint flag_reg_nr:1;
+        GLuint pad2:6;
+      } ia16;
+
+
+      struct
+      {
+        GLint  jump_count:16;  /* note: signed */
+        GLuint  pop_count:4;
+        GLuint  pad0:12;
+      } if_else;
+
+      struct {
+        GLuint function:4;
+        GLuint int_type:1;
+        GLuint precision:1;
+        GLuint saturate:1;
+        GLuint data_type:1;
+        GLuint pad0:8;
+        GLuint response_length:4;
+        GLuint msg_length:4;
+        GLuint msg_target:4;
+        GLuint pad1:3;
+        GLuint end_of_thread:1;
+      } math;
+
+      struct {
+        GLuint function:4;
+        GLuint int_type:1;
+        GLuint precision:1;
+        GLuint saturate:1;
+        GLuint data_type:1;
+        GLuint snapshot:1;
+        GLuint pad0:10;
+        GLuint header_present:1;
+        GLuint response_length:5;
+        GLuint msg_length:4;
+        GLuint pad1:2;
+        GLuint end_of_thread:1;
+      } math_igdng;
+
+      struct {
+        GLuint binding_table_index:8;
+        GLuint sampler:4;
+        GLuint return_format:2; 
+        GLuint msg_type:2;   
+        GLuint response_length:4;
+        GLuint msg_length:4;
+        GLuint msg_target:4;
+        GLuint pad1:3;
+        GLuint end_of_thread:1;
+      } sampler;
+
+      struct {
+         GLuint binding_table_index:8;
+         GLuint sampler:4;
+         GLuint msg_type:4;
+         GLuint response_length:4;
+         GLuint msg_length:4;
+         GLuint msg_target:4;
+         GLuint pad1:3;
+         GLuint end_of_thread:1;
+      } sampler_g4x;
+
+      struct {
+        GLuint binding_table_index:8;
+        GLuint sampler:4;
+        GLuint msg_type:4;
+        GLuint simd_mode:2;
+        GLuint pad0:1;
+        GLuint header_present:1;
+        GLuint response_length:5;
+        GLuint msg_length:4;
+        GLuint pad1:2;
+        GLuint end_of_thread:1;
+      } sampler_igdng;
+
+      struct brw_urb_immediate urb;
+
+      struct {
+        GLuint opcode:4;
+        GLuint offset:6;
+        GLuint swizzle_control:2; 
+        GLuint pad:1;
+        GLuint allocate:1;
+        GLuint used:1;
+        GLuint complete:1;
+        GLuint pad0:3;
+        GLuint header_present:1;
+        GLuint response_length:5;
+        GLuint msg_length:4;
+        GLuint pad1:2;
+        GLuint end_of_thread:1;
+      } urb_igdng;
+
+      struct {
+        GLuint binding_table_index:8;
+        GLuint msg_control:4;  
+        GLuint msg_type:2;  
+        GLuint target_cache:2;    
+        GLuint response_length:4;
+        GLuint msg_length:4;
+        GLuint msg_target:4;
+        GLuint pad1:3;
+        GLuint end_of_thread:1;
+      } dp_read;
+
+      struct {
+        GLuint binding_table_index:8;
+        GLuint msg_control:3;  
+        GLuint msg_type:3;  
+        GLuint target_cache:2;    
+        GLuint pad0:3;
+        GLuint header_present:1;
+        GLuint response_length:5;
+        GLuint msg_length:4;
+        GLuint pad1:2;
+        GLuint end_of_thread:1;
+      } dp_read_igdng;
+
+      struct {
+        GLuint binding_table_index:8;
+        GLuint msg_control:3;
+        GLuint pixel_scoreboard_clear:1;
+        GLuint msg_type:3;    
+        GLuint send_commit_msg:1;
+        GLuint response_length:4;
+        GLuint msg_length:4;
+        GLuint msg_target:4;
+        GLuint pad1:3;
+        GLuint end_of_thread:1;
+      } dp_write;
+
+      struct {
+        GLuint binding_table_index:8;
+        GLuint msg_control:3;
+        GLuint pixel_scoreboard_clear:1;
+        GLuint msg_type:3;    
+        GLuint send_commit_msg:1;
+        GLuint pad0:3;
+        GLuint header_present:1;
+        GLuint response_length:5;
+        GLuint msg_length:4;
+        GLuint pad1:2;
+        GLuint end_of_thread:1;
+      } dp_write_igdng;
+
+      struct {
+        GLuint pad:16;
+        GLuint response_length:4;
+        GLuint msg_length:4;
+        GLuint msg_target:4;
+        GLuint pad1:3;
+        GLuint end_of_thread:1;
+      } generic;
+
+      struct {
+        GLuint pad:19;
+        GLuint header_present:1;
+        GLuint response_length:5;
+        GLuint msg_length:4;
+        GLuint pad1:2;
+        GLuint end_of_thread:1;
+      } generic_igdng;
+
+      GLint d;
+      GLuint ud;
+      float f;
+   } bits3;
+};
+
+
+#endif
diff --git a/src/gallium/drivers/i965/brw_structs_dump.c b/src/gallium/drivers/i965/brw_structs_dump.c
new file mode 100644 (file)
index 0000000..cd40fc6
--- /dev/null
@@ -0,0 +1,1247 @@
+/**************************************************************************
+ *
+ * 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 SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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.
+ *
+ **************************************************************************/
+
+/**
+ * @file
+ * Dump i965 data structures.
+ *
+ * Generated automatically from brw_structs.h by brw_structs_dump.py.
+ */
+
+#include "util/u_debug.h"
+
+#include "brw_types.h"
+#include "brw_structs.h"
+#include "brw_structs_dump.h"
+
+void
+brw_dump_3d_control(const struct brw_3d_control *ptr)
+{
+   debug_printf("\t\t.header.length = 0x%x\n", (*ptr).header.length);
+   debug_printf("\t\t.header.notify_enable = 0x%x\n", (*ptr).header.notify_enable);
+   debug_printf("\t\t.header.wc_flush_enable = 0x%x\n", (*ptr).header.wc_flush_enable);
+   debug_printf("\t\t.header.depth_stall_enable = 0x%x\n", (*ptr).header.depth_stall_enable);
+   debug_printf("\t\t.header.operation = 0x%x\n", (*ptr).header.operation);
+   debug_printf("\t\t.header.opcode = 0x%x\n", (*ptr).header.opcode);
+   debug_printf("\t\t.dest.dest_addr_type = 0x%x\n", (*ptr).dest.dest_addr_type);
+   debug_printf("\t\t.dest.dest_addr = 0x%x\n", (*ptr).dest.dest_addr);
+   debug_printf("\t\t.dword2 = 0x%x\n", (*ptr).dword2);
+   debug_printf("\t\t.dword3 = 0x%x\n", (*ptr).dword3);
+}
+
+void
+brw_dump_3d_primitive(const struct brw_3d_primitive *ptr)
+{
+   debug_printf("\t\t.header.length = 0x%x\n", (*ptr).header.length);
+   debug_printf("\t\t.header.topology = 0x%x\n", (*ptr).header.topology);
+   debug_printf("\t\t.header.indexed = 0x%x\n", (*ptr).header.indexed);
+   debug_printf("\t\t.header.opcode = 0x%x\n", (*ptr).header.opcode);
+   debug_printf("\t\t.verts_per_instance = 0x%x\n", (*ptr).verts_per_instance);
+   debug_printf("\t\t.start_vert_location = 0x%x\n", (*ptr).start_vert_location);
+   debug_printf("\t\t.instance_count = 0x%x\n", (*ptr).instance_count);
+   debug_printf("\t\t.start_instance_location = 0x%x\n", (*ptr).start_instance_location);
+   debug_printf("\t\t.base_vert_location = 0x%x\n", (*ptr).base_vert_location);
+}
+
+void
+brw_dump_aa_line_parameters(const struct brw_aa_line_parameters *ptr)
+{
+   debug_printf("\t\t.header.length = 0x%x\n", (*ptr).header.length);
+   debug_printf("\t\t.header.opcode = 0x%x\n", (*ptr).header.opcode);
+   debug_printf("\t\t.bits0.aa_coverage_scope = 0x%x\n", (*ptr).bits0.aa_coverage_scope);
+   debug_printf("\t\t.bits0.aa_coverage_bias = 0x%x\n", (*ptr).bits0.aa_coverage_bias);
+   debug_printf("\t\t.bits1.aa_coverage_endcap_slope = 0x%x\n", (*ptr).bits1.aa_coverage_endcap_slope);
+   debug_printf("\t\t.bits1.aa_coverage_endcap_bias = 0x%x\n", (*ptr).bits1.aa_coverage_endcap_bias);
+}
+
+void
+brw_dump_binding_table_pointers(const struct brw_binding_table_pointers *ptr)
+{
+   debug_printf("\t\t.header.length = 0x%x\n", (*ptr).header.length);
+   debug_printf("\t\t.header.opcode = 0x%x\n", (*ptr).header.opcode);
+   debug_printf("\t\t.vs = 0x%x\n", (*ptr).vs);
+   debug_printf("\t\t.gs = 0x%x\n", (*ptr).gs);
+   debug_printf("\t\t.clp = 0x%x\n", (*ptr).clp);
+   debug_printf("\t\t.sf = 0x%x\n", (*ptr).sf);
+   debug_printf("\t\t.wm = 0x%x\n", (*ptr).wm);
+}
+
+void
+brw_dump_blend_constant_color(const struct brw_blend_constant_color *ptr)
+{
+   debug_printf("\t\t.header.length = 0x%x\n", (*ptr).header.length);
+   debug_printf("\t\t.header.opcode = 0x%x\n", (*ptr).header.opcode);
+   debug_printf("\t\t.blend_constant_color[0] = %f\n", (*ptr).blend_constant_color[0]);
+   debug_printf("\t\t.blend_constant_color[1] = %f\n", (*ptr).blend_constant_color[1]);
+   debug_printf("\t\t.blend_constant_color[2] = %f\n", (*ptr).blend_constant_color[2]);
+   debug_printf("\t\t.blend_constant_color[3] = %f\n", (*ptr).blend_constant_color[3]);
+}
+
+void
+brw_dump_cc0(const struct brw_cc0 *ptr)
+{
+   debug_printf("\t\t.bf_stencil_pass_depth_pass_op = 0x%x\n", (*ptr).bf_stencil_pass_depth_pass_op);
+   debug_printf("\t\t.bf_stencil_pass_depth_fail_op = 0x%x\n", (*ptr).bf_stencil_pass_depth_fail_op);
+   debug_printf("\t\t.bf_stencil_fail_op = 0x%x\n", (*ptr).bf_stencil_fail_op);
+   debug_printf("\t\t.bf_stencil_func = 0x%x\n", (*ptr).bf_stencil_func);
+   debug_printf("\t\t.bf_stencil_enable = 0x%x\n", (*ptr).bf_stencil_enable);
+   debug_printf("\t\t.stencil_write_enable = 0x%x\n", (*ptr).stencil_write_enable);
+   debug_printf("\t\t.stencil_pass_depth_pass_op = 0x%x\n", (*ptr).stencil_pass_depth_pass_op);
+   debug_printf("\t\t.stencil_pass_depth_fail_op = 0x%x\n", (*ptr).stencil_pass_depth_fail_op);
+   debug_printf("\t\t.stencil_fail_op = 0x%x\n", (*ptr).stencil_fail_op);
+   debug_printf("\t\t.stencil_func = 0x%x\n", (*ptr).stencil_func);
+   debug_printf("\t\t.stencil_enable = 0x%x\n", (*ptr).stencil_enable);
+}
+
+void
+brw_dump_cc1(const struct brw_cc1 *ptr)
+{
+   debug_printf("\t\t.bf_stencil_ref = 0x%x\n", (*ptr).bf_stencil_ref);
+   debug_printf("\t\t.stencil_write_mask = 0x%x\n", (*ptr).stencil_write_mask);
+   debug_printf("\t\t.stencil_test_mask = 0x%x\n", (*ptr).stencil_test_mask);
+   debug_printf("\t\t.stencil_ref = 0x%x\n", (*ptr).stencil_ref);
+}
+
+void
+brw_dump_cc2(const struct brw_cc2 *ptr)
+{
+   debug_printf("\t\t.logicop_enable = 0x%x\n", (*ptr).logicop_enable);
+   debug_printf("\t\t.depth_write_enable = 0x%x\n", (*ptr).depth_write_enable);
+   debug_printf("\t\t.depth_test_function = 0x%x\n", (*ptr).depth_test_function);
+   debug_printf("\t\t.depth_test = 0x%x\n", (*ptr).depth_test);
+   debug_printf("\t\t.bf_stencil_write_mask = 0x%x\n", (*ptr).bf_stencil_write_mask);
+   debug_printf("\t\t.bf_stencil_test_mask = 0x%x\n", (*ptr).bf_stencil_test_mask);
+}
+
+void
+brw_dump_cc3(const struct brw_cc3 *ptr)
+{
+   debug_printf("\t\t.alpha_test_func = 0x%x\n", (*ptr).alpha_test_func);
+   debug_printf("\t\t.alpha_test = 0x%x\n", (*ptr).alpha_test);
+   debug_printf("\t\t.blend_enable = 0x%x\n", (*ptr).blend_enable);
+   debug_printf("\t\t.ia_blend_enable = 0x%x\n", (*ptr).ia_blend_enable);
+   debug_printf("\t\t.alpha_test_format = 0x%x\n", (*ptr).alpha_test_format);
+}
+
+void
+brw_dump_cc4(const struct brw_cc4 *ptr)
+{
+   debug_printf("\t\t.cc_viewport_state_offset = 0x%x\n", (*ptr).cc_viewport_state_offset);
+}
+
+void
+brw_dump_cc5(const struct brw_cc5 *ptr)
+{
+   debug_printf("\t\t.ia_dest_blend_factor = 0x%x\n", (*ptr).ia_dest_blend_factor);
+   debug_printf("\t\t.ia_src_blend_factor = 0x%x\n", (*ptr).ia_src_blend_factor);
+   debug_printf("\t\t.ia_blend_function = 0x%x\n", (*ptr).ia_blend_function);
+   debug_printf("\t\t.statistics_enable = 0x%x\n", (*ptr).statistics_enable);
+   debug_printf("\t\t.logicop_func = 0x%x\n", (*ptr).logicop_func);
+   debug_printf("\t\t.dither_enable = 0x%x\n", (*ptr).dither_enable);
+}
+
+void
+brw_dump_cc6(const struct brw_cc6 *ptr)
+{
+   debug_printf("\t\t.clamp_post_alpha_blend = 0x%x\n", (*ptr).clamp_post_alpha_blend);
+   debug_printf("\t\t.clamp_pre_alpha_blend = 0x%x\n", (*ptr).clamp_pre_alpha_blend);
+   debug_printf("\t\t.clamp_range = 0x%x\n", (*ptr).clamp_range);
+   debug_printf("\t\t.y_dither_offset = 0x%x\n", (*ptr).y_dither_offset);
+   debug_printf("\t\t.x_dither_offset = 0x%x\n", (*ptr).x_dither_offset);
+   debug_printf("\t\t.dest_blend_factor = 0x%x\n", (*ptr).dest_blend_factor);
+   debug_printf("\t\t.src_blend_factor = 0x%x\n", (*ptr).src_blend_factor);
+   debug_printf("\t\t.blend_function = 0x%x\n", (*ptr).blend_function);
+}
+
+void
+brw_dump_cc7(const struct brw_cc7 *ptr)
+{
+   debug_printf("\t\t.alpha_ref.f = %f\n", (*ptr).alpha_ref.f);
+   debug_printf("\t\t.alpha_ref.ub[0] = 0x%x\n", (*ptr).alpha_ref.ub[0]);
+   debug_printf("\t\t.alpha_ref.ub[1] = 0x%x\n", (*ptr).alpha_ref.ub[1]);
+   debug_printf("\t\t.alpha_ref.ub[2] = 0x%x\n", (*ptr).alpha_ref.ub[2]);
+   debug_printf("\t\t.alpha_ref.ub[3] = 0x%x\n", (*ptr).alpha_ref.ub[3]);
+}
+
+void
+brw_dump_cc_unit_state(const struct brw_cc_unit_state *ptr)
+{
+   debug_printf("\t\t.cc0.bf_stencil_pass_depth_pass_op = 0x%x\n", (*ptr).cc0.bf_stencil_pass_depth_pass_op);
+   debug_printf("\t\t.cc0.bf_stencil_pass_depth_fail_op = 0x%x\n", (*ptr).cc0.bf_stencil_pass_depth_fail_op);
+   debug_printf("\t\t.cc0.bf_stencil_fail_op = 0x%x\n", (*ptr).cc0.bf_stencil_fail_op);
+   debug_printf("\t\t.cc0.bf_stencil_func = 0x%x\n", (*ptr).cc0.bf_stencil_func);
+   debug_printf("\t\t.cc0.bf_stencil_enable = 0x%x\n", (*ptr).cc0.bf_stencil_enable);
+   debug_printf("\t\t.cc0.stencil_write_enable = 0x%x\n", (*ptr).cc0.stencil_write_enable);
+   debug_printf("\t\t.cc0.stencil_pass_depth_pass_op = 0x%x\n", (*ptr).cc0.stencil_pass_depth_pass_op);
+   debug_printf("\t\t.cc0.stencil_pass_depth_fail_op = 0x%x\n", (*ptr).cc0.stencil_pass_depth_fail_op);
+   debug_printf("\t\t.cc0.stencil_fail_op = 0x%x\n", (*ptr).cc0.stencil_fail_op);
+   debug_printf("\t\t.cc0.stencil_func = 0x%x\n", (*ptr).cc0.stencil_func);
+   debug_printf("\t\t.cc0.stencil_enable = 0x%x\n", (*ptr).cc0.stencil_enable);
+   debug_printf("\t\t.cc1.bf_stencil_ref = 0x%x\n", (*ptr).cc1.bf_stencil_ref);
+   debug_printf("\t\t.cc1.stencil_write_mask = 0x%x\n", (*ptr).cc1.stencil_write_mask);
+   debug_printf("\t\t.cc1.stencil_test_mask = 0x%x\n", (*ptr).cc1.stencil_test_mask);
+   debug_printf("\t\t.cc1.stencil_ref = 0x%x\n", (*ptr).cc1.stencil_ref);
+   debug_printf("\t\t.cc2.logicop_enable = 0x%x\n", (*ptr).cc2.logicop_enable);
+   debug_printf("\t\t.cc2.depth_write_enable = 0x%x\n", (*ptr).cc2.depth_write_enable);
+   debug_printf("\t\t.cc2.depth_test_function = 0x%x\n", (*ptr).cc2.depth_test_function);
+   debug_printf("\t\t.cc2.depth_test = 0x%x\n", (*ptr).cc2.depth_test);
+   debug_printf("\t\t.cc2.bf_stencil_write_mask = 0x%x\n", (*ptr).cc2.bf_stencil_write_mask);
+   debug_printf("\t\t.cc2.bf_stencil_test_mask = 0x%x\n", (*ptr).cc2.bf_stencil_test_mask);
+   debug_printf("\t\t.cc3.alpha_test_func = 0x%x\n", (*ptr).cc3.alpha_test_func);
+   debug_printf("\t\t.cc3.alpha_test = 0x%x\n", (*ptr).cc3.alpha_test);
+   debug_printf("\t\t.cc3.blend_enable = 0x%x\n", (*ptr).cc3.blend_enable);
+   debug_printf("\t\t.cc3.ia_blend_enable = 0x%x\n", (*ptr).cc3.ia_blend_enable);
+   debug_printf("\t\t.cc3.alpha_test_format = 0x%x\n", (*ptr).cc3.alpha_test_format);
+   debug_printf("\t\t.cc4.cc_viewport_state_offset = 0x%x\n", (*ptr).cc4.cc_viewport_state_offset);
+   debug_printf("\t\t.cc5.ia_dest_blend_factor = 0x%x\n", (*ptr).cc5.ia_dest_blend_factor);
+   debug_printf("\t\t.cc5.ia_src_blend_factor = 0x%x\n", (*ptr).cc5.ia_src_blend_factor);
+   debug_printf("\t\t.cc5.ia_blend_function = 0x%x\n", (*ptr).cc5.ia_blend_function);
+   debug_printf("\t\t.cc5.statistics_enable = 0x%x\n", (*ptr).cc5.statistics_enable);
+   debug_printf("\t\t.cc5.logicop_func = 0x%x\n", (*ptr).cc5.logicop_func);
+   debug_printf("\t\t.cc5.dither_enable = 0x%x\n", (*ptr).cc5.dither_enable);
+   debug_printf("\t\t.cc6.clamp_post_alpha_blend = 0x%x\n", (*ptr).cc6.clamp_post_alpha_blend);
+   debug_printf("\t\t.cc6.clamp_pre_alpha_blend = 0x%x\n", (*ptr).cc6.clamp_pre_alpha_blend);
+   debug_printf("\t\t.cc6.clamp_range = 0x%x\n", (*ptr).cc6.clamp_range);
+   debug_printf("\t\t.cc6.y_dither_offset = 0x%x\n", (*ptr).cc6.y_dither_offset);
+   debug_printf("\t\t.cc6.x_dither_offset = 0x%x\n", (*ptr).cc6.x_dither_offset);
+   debug_printf("\t\t.cc6.dest_blend_factor = 0x%x\n", (*ptr).cc6.dest_blend_factor);
+   debug_printf("\t\t.cc6.src_blend_factor = 0x%x\n", (*ptr).cc6.src_blend_factor);
+   debug_printf("\t\t.cc6.blend_function = 0x%x\n", (*ptr).cc6.blend_function);
+   debug_printf("\t\t.cc7.alpha_ref.f = %f\n", (*ptr).cc7.alpha_ref.f);
+   debug_printf("\t\t.cc7.alpha_ref.ub[0] = 0x%x\n", (*ptr).cc7.alpha_ref.ub[0]);
+   debug_printf("\t\t.cc7.alpha_ref.ub[1] = 0x%x\n", (*ptr).cc7.alpha_ref.ub[1]);
+   debug_printf("\t\t.cc7.alpha_ref.ub[2] = 0x%x\n", (*ptr).cc7.alpha_ref.ub[2]);
+   debug_printf("\t\t.cc7.alpha_ref.ub[3] = 0x%x\n", (*ptr).cc7.alpha_ref.ub[3]);
+}
+
+void
+brw_dump_cc_viewport(const struct brw_cc_viewport *ptr)
+{
+   debug_printf("\t\t.min_depth = %f\n", (*ptr).min_depth);
+   debug_printf("\t\t.max_depth = %f\n", (*ptr).max_depth);
+}
+
+void
+brw_dump_clip_unit_state(const struct brw_clip_unit_state *ptr)
+{
+   debug_printf("\t\t.thread0.grf_reg_count = 0x%x\n", (*ptr).thread0.grf_reg_count);
+   debug_printf("\t\t.thread0.kernel_start_pointer = 0x%x\n", (*ptr).thread0.kernel_start_pointer);
+   debug_printf("\t\t.thread1.sw_exception_enable = 0x%x\n", (*ptr).thread1.sw_exception_enable);
+   debug_printf("\t\t.thread1.mask_stack_exception_enable = 0x%x\n", (*ptr).thread1.mask_stack_exception_enable);
+   debug_printf("\t\t.thread1.illegal_op_exception_enable = 0x%x\n", (*ptr).thread1.illegal_op_exception_enable);
+   debug_printf("\t\t.thread1.floating_point_mode = 0x%x\n", (*ptr).thread1.floating_point_mode);
+   debug_printf("\t\t.thread1.thread_priority = 0x%x\n", (*ptr).thread1.thread_priority);
+   debug_printf("\t\t.thread1.binding_table_entry_count = 0x%x\n", (*ptr).thread1.binding_table_entry_count);
+   debug_printf("\t\t.thread1.single_program_flow = 0x%x\n", (*ptr).thread1.single_program_flow);
+   debug_printf("\t\t.thread2.per_thread_scratch_space = 0x%x\n", (*ptr).thread2.per_thread_scratch_space);
+   debug_printf("\t\t.thread2.scratch_space_base_pointer = 0x%x\n", (*ptr).thread2.scratch_space_base_pointer);
+   debug_printf("\t\t.thread3.dispatch_grf_start_reg = 0x%x\n", (*ptr).thread3.dispatch_grf_start_reg);
+   debug_printf("\t\t.thread3.urb_entry_read_offset = 0x%x\n", (*ptr).thread3.urb_entry_read_offset);
+   debug_printf("\t\t.thread3.urb_entry_read_length = 0x%x\n", (*ptr).thread3.urb_entry_read_length);
+   debug_printf("\t\t.thread3.const_urb_entry_read_offset = 0x%x\n", (*ptr).thread3.const_urb_entry_read_offset);
+   debug_printf("\t\t.thread3.const_urb_entry_read_length = 0x%x\n", (*ptr).thread3.const_urb_entry_read_length);
+   debug_printf("\t\t.thread4.gs_output_stats = 0x%x\n", (*ptr).thread4.gs_output_stats);
+   debug_printf("\t\t.thread4.stats_enable = 0x%x\n", (*ptr).thread4.stats_enable);
+   debug_printf("\t\t.thread4.nr_urb_entries = 0x%x\n", (*ptr).thread4.nr_urb_entries);
+   debug_printf("\t\t.thread4.urb_entry_allocation_size = 0x%x\n", (*ptr).thread4.urb_entry_allocation_size);
+   debug_printf("\t\t.thread4.max_threads = 0x%x\n", (*ptr).thread4.max_threads);
+   debug_printf("\t\t.clip5.clip_mode = 0x%x\n", (*ptr).clip5.clip_mode);
+   debug_printf("\t\t.clip5.userclip_enable_flags = 0x%x\n", (*ptr).clip5.userclip_enable_flags);
+   debug_printf("\t\t.clip5.userclip_must_clip = 0x%x\n", (*ptr).clip5.userclip_must_clip);
+   debug_printf("\t\t.clip5.negative_w_clip_test = 0x%x\n", (*ptr).clip5.negative_w_clip_test);
+   debug_printf("\t\t.clip5.guard_band_enable = 0x%x\n", (*ptr).clip5.guard_band_enable);
+   debug_printf("\t\t.clip5.viewport_z_clip_enable = 0x%x\n", (*ptr).clip5.viewport_z_clip_enable);
+   debug_printf("\t\t.clip5.viewport_xy_clip_enable = 0x%x\n", (*ptr).clip5.viewport_xy_clip_enable);
+   debug_printf("\t\t.clip5.vertex_position_space = 0x%x\n", (*ptr).clip5.vertex_position_space);
+   debug_printf("\t\t.clip5.api_mode = 0x%x\n", (*ptr).clip5.api_mode);
+   debug_printf("\t\t.clip6.clipper_viewport_state_ptr = 0x%x\n", (*ptr).clip6.clipper_viewport_state_ptr);
+   debug_printf("\t\t.viewport_xmin = %f\n", (*ptr).viewport_xmin);
+   debug_printf("\t\t.viewport_xmax = %f\n", (*ptr).viewport_xmax);
+   debug_printf("\t\t.viewport_ymin = %f\n", (*ptr).viewport_ymin);
+   debug_printf("\t\t.viewport_ymax = %f\n", (*ptr).viewport_ymax);
+}
+
+void
+brw_dump_clipper_viewport(const struct brw_clipper_viewport *ptr)
+{
+   debug_printf("\t\t.xmin = %f\n", (*ptr).xmin);
+   debug_printf("\t\t.xmax = %f\n", (*ptr).xmax);
+   debug_printf("\t\t.ymin = %f\n", (*ptr).ymin);
+   debug_printf("\t\t.ymax = %f\n", (*ptr).ymax);
+}
+
+void
+brw_dump_constant_buffer(const struct brw_constant_buffer *ptr)
+{
+   debug_printf("\t\t.header.length = 0x%x\n", (*ptr).header.length);
+   debug_printf("\t\t.header.valid = 0x%x\n", (*ptr).header.valid);
+   debug_printf("\t\t.header.opcode = 0x%x\n", (*ptr).header.opcode);
+   debug_printf("\t\t.bits0.buffer_length = 0x%x\n", (*ptr).bits0.buffer_length);
+   debug_printf("\t\t.bits0.buffer_address = 0x%x\n", (*ptr).bits0.buffer_address);
+}
+
+void
+brw_dump_cs_urb_state(const struct brw_cs_urb_state *ptr)
+{
+   debug_printf("\t\t.header.length = 0x%x\n", (*ptr).header.length);
+   debug_printf("\t\t.header.opcode = 0x%x\n", (*ptr).header.opcode);
+   debug_printf("\t\t.bits0.nr_urb_entries = 0x%x\n", (*ptr).bits0.nr_urb_entries);
+   debug_printf("\t\t.bits0.urb_entry_size = 0x%x\n", (*ptr).bits0.urb_entry_size);
+}
+
+void
+brw_dump_depthbuffer(const struct brw_depthbuffer *ptr)
+{
+   debug_printf("\t\t.header.bits.length = 0x%x\n", (*ptr).header.bits.length);
+   debug_printf("\t\t.header.bits.opcode = 0x%x\n", (*ptr).header.bits.opcode);
+   debug_printf("\t\t.dword1.bits.pitch = 0x%x\n", (*ptr).dword1.bits.pitch);
+   debug_printf("\t\t.dword1.bits.format = 0x%x\n", (*ptr).dword1.bits.format);
+   debug_printf("\t\t.dword1.bits.software_tiled_rendering_mode = 0x%x\n", (*ptr).dword1.bits.software_tiled_rendering_mode);
+   debug_printf("\t\t.dword1.bits.depth_offset_disable = 0x%x\n", (*ptr).dword1.bits.depth_offset_disable);
+   debug_printf("\t\t.dword1.bits.tile_walk = 0x%x\n", (*ptr).dword1.bits.tile_walk);
+   debug_printf("\t\t.dword1.bits.tiled_surface = 0x%x\n", (*ptr).dword1.bits.tiled_surface);
+   debug_printf("\t\t.dword1.bits.surface_type = 0x%x\n", (*ptr).dword1.bits.surface_type);
+   debug_printf("\t\t.dword2_base_addr = 0x%x\n", (*ptr).dword2_base_addr);
+   debug_printf("\t\t.dword3.bits.mipmap_layout = 0x%x\n", (*ptr).dword3.bits.mipmap_layout);
+   debug_printf("\t\t.dword3.bits.lod = 0x%x\n", (*ptr).dword3.bits.lod);
+   debug_printf("\t\t.dword3.bits.width = 0x%x\n", (*ptr).dword3.bits.width);
+   debug_printf("\t\t.dword3.bits.height = 0x%x\n", (*ptr).dword3.bits.height);
+   debug_printf("\t\t.dword4.bits.min_array_element = 0x%x\n", (*ptr).dword4.bits.min_array_element);
+   debug_printf("\t\t.dword4.bits.depth = 0x%x\n", (*ptr).dword4.bits.depth);
+}
+
+void
+brw_dump_depthbuffer_g4x(const struct brw_depthbuffer_g4x *ptr)
+{
+   debug_printf("\t\t.header.bits.length = 0x%x\n", (*ptr).header.bits.length);
+   debug_printf("\t\t.header.bits.opcode = 0x%x\n", (*ptr).header.bits.opcode);
+   debug_printf("\t\t.dword1.bits.pitch = 0x%x\n", (*ptr).dword1.bits.pitch);
+   debug_printf("\t\t.dword1.bits.format = 0x%x\n", (*ptr).dword1.bits.format);
+   debug_printf("\t\t.dword1.bits.software_tiled_rendering_mode = 0x%x\n", (*ptr).dword1.bits.software_tiled_rendering_mode);
+   debug_printf("\t\t.dword1.bits.depth_offset_disable = 0x%x\n", (*ptr).dword1.bits.depth_offset_disable);
+   debug_printf("\t\t.dword1.bits.tile_walk = 0x%x\n", (*ptr).dword1.bits.tile_walk);
+   debug_printf("\t\t.dword1.bits.tiled_surface = 0x%x\n", (*ptr).dword1.bits.tiled_surface);
+   debug_printf("\t\t.dword1.bits.surface_type = 0x%x\n", (*ptr).dword1.bits.surface_type);
+   debug_printf("\t\t.dword2_base_addr = 0x%x\n", (*ptr).dword2_base_addr);
+   debug_printf("\t\t.dword3.bits.mipmap_layout = 0x%x\n", (*ptr).dword3.bits.mipmap_layout);
+   debug_printf("\t\t.dword3.bits.lod = 0x%x\n", (*ptr).dword3.bits.lod);
+   debug_printf("\t\t.dword3.bits.width = 0x%x\n", (*ptr).dword3.bits.width);
+   debug_printf("\t\t.dword3.bits.height = 0x%x\n", (*ptr).dword3.bits.height);
+   debug_printf("\t\t.dword4.bits.min_array_element = 0x%x\n", (*ptr).dword4.bits.min_array_element);
+   debug_printf("\t\t.dword4.bits.depth = 0x%x\n", (*ptr).dword4.bits.depth);
+   debug_printf("\t\t.dword5.bits.xoffset = 0x%x\n", (*ptr).dword5.bits.xoffset);
+   debug_printf("\t\t.dword5.bits.yoffset = 0x%x\n", (*ptr).dword5.bits.yoffset);
+}
+
+void
+brw_dump_drawrect(const struct brw_drawrect *ptr)
+{
+   debug_printf("\t\t.header.length = 0x%x\n", (*ptr).header.length);
+   debug_printf("\t\t.header.opcode = 0x%x\n", (*ptr).header.opcode);
+   debug_printf("\t\t.xmin = 0x%x\n", (*ptr).xmin);
+   debug_printf("\t\t.ymin = 0x%x\n", (*ptr).ymin);
+   debug_printf("\t\t.xmax = 0x%x\n", (*ptr).xmax);
+   debug_printf("\t\t.ymax = 0x%x\n", (*ptr).ymax);
+   debug_printf("\t\t.xorg = 0x%x\n", (*ptr).xorg);
+   debug_printf("\t\t.yorg = 0x%x\n", (*ptr).yorg);
+}
+
+void
+brw_dump_global_depth_offset_clamp(const struct brw_global_depth_offset_clamp *ptr)
+{
+   debug_printf("\t\t.header.length = 0x%x\n", (*ptr).header.length);
+   debug_printf("\t\t.header.opcode = 0x%x\n", (*ptr).header.opcode);
+   debug_printf("\t\t.depth_offset_clamp = %f\n", (*ptr).depth_offset_clamp);
+}
+
+void
+brw_dump_gs_unit_state(const struct brw_gs_unit_state *ptr)
+{
+   debug_printf("\t\t.thread0.grf_reg_count = 0x%x\n", (*ptr).thread0.grf_reg_count);
+   debug_printf("\t\t.thread0.kernel_start_pointer = 0x%x\n", (*ptr).thread0.kernel_start_pointer);
+   debug_printf("\t\t.thread1.ext_halt_exception_enable = 0x%x\n", (*ptr).thread1.ext_halt_exception_enable);
+   debug_printf("\t\t.thread1.sw_exception_enable = 0x%x\n", (*ptr).thread1.sw_exception_enable);
+   debug_printf("\t\t.thread1.mask_stack_exception_enable = 0x%x\n", (*ptr).thread1.mask_stack_exception_enable);
+   debug_printf("\t\t.thread1.timeout_exception_enable = 0x%x\n", (*ptr).thread1.timeout_exception_enable);
+   debug_printf("\t\t.thread1.illegal_op_exception_enable = 0x%x\n", (*ptr).thread1.illegal_op_exception_enable);
+   debug_printf("\t\t.thread1.depth_coef_urb_read_offset = 0x%x\n", (*ptr).thread1.depth_coef_urb_read_offset);
+   debug_printf("\t\t.thread1.floating_point_mode = 0x%x\n", (*ptr).thread1.floating_point_mode);
+   debug_printf("\t\t.thread1.thread_priority = 0x%x\n", (*ptr).thread1.thread_priority);
+   debug_printf("\t\t.thread1.binding_table_entry_count = 0x%x\n", (*ptr).thread1.binding_table_entry_count);
+   debug_printf("\t\t.thread1.single_program_flow = 0x%x\n", (*ptr).thread1.single_program_flow);
+   debug_printf("\t\t.thread2.per_thread_scratch_space = 0x%x\n", (*ptr).thread2.per_thread_scratch_space);
+   debug_printf("\t\t.thread2.scratch_space_base_pointer = 0x%x\n", (*ptr).thread2.scratch_space_base_pointer);
+   debug_printf("\t\t.thread3.dispatch_grf_start_reg = 0x%x\n", (*ptr).thread3.dispatch_grf_start_reg);
+   debug_printf("\t\t.thread3.urb_entry_read_offset = 0x%x\n", (*ptr).thread3.urb_entry_read_offset);
+   debug_printf("\t\t.thread3.urb_entry_read_length = 0x%x\n", (*ptr).thread3.urb_entry_read_length);
+   debug_printf("\t\t.thread3.const_urb_entry_read_offset = 0x%x\n", (*ptr).thread3.const_urb_entry_read_offset);
+   debug_printf("\t\t.thread3.const_urb_entry_read_length = 0x%x\n", (*ptr).thread3.const_urb_entry_read_length);
+   debug_printf("\t\t.thread4.rendering_enable = 0x%x\n", (*ptr).thread4.rendering_enable);
+   debug_printf("\t\t.thread4.stats_enable = 0x%x\n", (*ptr).thread4.stats_enable);
+   debug_printf("\t\t.thread4.nr_urb_entries = 0x%x\n", (*ptr).thread4.nr_urb_entries);
+   debug_printf("\t\t.thread4.urb_entry_allocation_size = 0x%x\n", (*ptr).thread4.urb_entry_allocation_size);
+   debug_printf("\t\t.thread4.max_threads = 0x%x\n", (*ptr).thread4.max_threads);
+   debug_printf("\t\t.gs5.sampler_count = 0x%x\n", (*ptr).gs5.sampler_count);
+   debug_printf("\t\t.gs5.sampler_state_pointer = 0x%x\n", (*ptr).gs5.sampler_state_pointer);
+   debug_printf("\t\t.gs6.max_vp_index = 0x%x\n", (*ptr).gs6.max_vp_index);
+   debug_printf("\t\t.gs6.svbi_post_inc_value = 0x%x\n", (*ptr).gs6.svbi_post_inc_value);
+   debug_printf("\t\t.gs6.svbi_post_inc_enable = 0x%x\n", (*ptr).gs6.svbi_post_inc_enable);
+   debug_printf("\t\t.gs6.svbi_payload = 0x%x\n", (*ptr).gs6.svbi_payload);
+   debug_printf("\t\t.gs6.discard_adjaceny = 0x%x\n", (*ptr).gs6.discard_adjaceny);
+   debug_printf("\t\t.gs6.reorder_enable = 0x%x\n", (*ptr).gs6.reorder_enable);
+}
+
+void
+brw_dump_indexbuffer(const struct brw_indexbuffer *ptr)
+{
+   debug_printf("\t\t.header.bits.length = 0x%x\n", (*ptr).header.bits.length);
+   debug_printf("\t\t.header.bits.index_format = 0x%x\n", (*ptr).header.bits.index_format);
+   debug_printf("\t\t.header.bits.cut_index_enable = 0x%x\n", (*ptr).header.bits.cut_index_enable);
+   debug_printf("\t\t.header.bits.opcode = 0x%x\n", (*ptr).header.bits.opcode);
+   debug_printf("\t\t.buffer_start = 0x%x\n", (*ptr).buffer_start);
+   debug_printf("\t\t.buffer_end = 0x%x\n", (*ptr).buffer_end);
+}
+
+void
+brw_dump_line_stipple(const struct brw_line_stipple *ptr)
+{
+   debug_printf("\t\t.header.length = 0x%x\n", (*ptr).header.length);
+   debug_printf("\t\t.header.opcode = 0x%x\n", (*ptr).header.opcode);
+   debug_printf("\t\t.bits0.pattern = 0x%x\n", (*ptr).bits0.pattern);
+   debug_printf("\t\t.bits1.repeat_count = 0x%x\n", (*ptr).bits1.repeat_count);
+   debug_printf("\t\t.bits1.inverse_repeat_count = 0x%x\n", (*ptr).bits1.inverse_repeat_count);
+}
+
+void
+brw_dump_mi_flush(const struct brw_mi_flush *ptr)
+{
+   debug_printf("\t\t.flags = 0x%x\n", (*ptr).flags);
+   debug_printf("\t\t.opcode = 0x%x\n", (*ptr).opcode);
+}
+
+void
+brw_dump_pipe_control(const struct brw_pipe_control *ptr)
+{
+   debug_printf("\t\t.header.length = 0x%x\n", (*ptr).header.length);
+   debug_printf("\t\t.header.notify_enable = 0x%x\n", (*ptr).header.notify_enable);
+   debug_printf("\t\t.header.texture_cache_flush_enable = 0x%x\n", (*ptr).header.texture_cache_flush_enable);
+   debug_printf("\t\t.header.indirect_state_pointers_disable = 0x%x\n", (*ptr).header.indirect_state_pointers_disable);
+   debug_printf("\t\t.header.instruction_state_cache_flush_enable = 0x%x\n", (*ptr).header.instruction_state_cache_flush_enable);
+   debug_printf("\t\t.header.write_cache_flush_enable = 0x%x\n", (*ptr).header.write_cache_flush_enable);
+   debug_printf("\t\t.header.depth_stall_enable = 0x%x\n", (*ptr).header.depth_stall_enable);
+   debug_printf("\t\t.header.post_sync_operation = 0x%x\n", (*ptr).header.post_sync_operation);
+   debug_printf("\t\t.header.opcode = 0x%x\n", (*ptr).header.opcode);
+   debug_printf("\t\t.bits1.dest_addr_type = 0x%x\n", (*ptr).bits1.dest_addr_type);
+   debug_printf("\t\t.bits1.dest_addr = 0x%x\n", (*ptr).bits1.dest_addr);
+   debug_printf("\t\t.data0 = 0x%x\n", (*ptr).data0);
+   debug_printf("\t\t.data1 = 0x%x\n", (*ptr).data1);
+}
+
+void
+brw_dump_pipeline_select(const struct brw_pipeline_select *ptr)
+{
+   debug_printf("\t\t.header.pipeline_select = 0x%x\n", (*ptr).header.pipeline_select);
+   debug_printf("\t\t.header.opcode = 0x%x\n", (*ptr).header.opcode);
+}
+
+void
+brw_dump_pipelined_state_pointers(const struct brw_pipelined_state_pointers *ptr)
+{
+   debug_printf("\t\t.header.length = 0x%x\n", (*ptr).header.length);
+   debug_printf("\t\t.header.opcode = 0x%x\n", (*ptr).header.opcode);
+   debug_printf("\t\t.vs.offset = 0x%x\n", (*ptr).vs.offset);
+   debug_printf("\t\t.gs.enable = 0x%x\n", (*ptr).gs.enable);
+   debug_printf("\t\t.gs.offset = 0x%x\n", (*ptr).gs.offset);
+   debug_printf("\t\t.clp.enable = 0x%x\n", (*ptr).clp.enable);
+   debug_printf("\t\t.clp.offset = 0x%x\n", (*ptr).clp.offset);
+   debug_printf("\t\t.sf.offset = 0x%x\n", (*ptr).sf.offset);
+   debug_printf("\t\t.wm.offset = 0x%x\n", (*ptr).wm.offset);
+   debug_printf("\t\t.cc.offset = 0x%x\n", (*ptr).cc.offset);
+}
+
+void
+brw_dump_polygon_stipple(const struct brw_polygon_stipple *ptr)
+{
+   debug_printf("\t\t.header.length = 0x%x\n", (*ptr).header.length);
+   debug_printf("\t\t.header.opcode = 0x%x\n", (*ptr).header.opcode);
+   debug_printf("\t\t.stipple[0] = 0x%x\n", (*ptr).stipple[0]);
+   debug_printf("\t\t.stipple[1] = 0x%x\n", (*ptr).stipple[1]);
+   debug_printf("\t\t.stipple[2] = 0x%x\n", (*ptr).stipple[2]);
+   debug_printf("\t\t.stipple[3] = 0x%x\n", (*ptr).stipple[3]);
+   debug_printf("\t\t.stipple[4] = 0x%x\n", (*ptr).stipple[4]);
+   debug_printf("\t\t.stipple[5] = 0x%x\n", (*ptr).stipple[5]);
+   debug_printf("\t\t.stipple[6] = 0x%x\n", (*ptr).stipple[6]);
+   debug_printf("\t\t.stipple[7] = 0x%x\n", (*ptr).stipple[7]);
+   debug_printf("\t\t.stipple[8] = 0x%x\n", (*ptr).stipple[8]);
+   debug_printf("\t\t.stipple[9] = 0x%x\n", (*ptr).stipple[9]);
+   debug_printf("\t\t.stipple[10] = 0x%x\n", (*ptr).stipple[10]);
+   debug_printf("\t\t.stipple[11] = 0x%x\n", (*ptr).stipple[11]);
+   debug_printf("\t\t.stipple[12] = 0x%x\n", (*ptr).stipple[12]);
+   debug_printf("\t\t.stipple[13] = 0x%x\n", (*ptr).stipple[13]);
+   debug_printf("\t\t.stipple[14] = 0x%x\n", (*ptr).stipple[14]);
+   debug_printf("\t\t.stipple[15] = 0x%x\n", (*ptr).stipple[15]);
+   debug_printf("\t\t.stipple[16] = 0x%x\n", (*ptr).stipple[16]);
+   debug_printf("\t\t.stipple[17] = 0x%x\n", (*ptr).stipple[17]);
+   debug_printf("\t\t.stipple[18] = 0x%x\n", (*ptr).stipple[18]);
+   debug_printf("\t\t.stipple[19] = 0x%x\n", (*ptr).stipple[19]);
+   debug_printf("\t\t.stipple[20] = 0x%x\n", (*ptr).stipple[20]);
+   debug_printf("\t\t.stipple[21] = 0x%x\n", (*ptr).stipple[21]);
+   debug_printf("\t\t.stipple[22] = 0x%x\n", (*ptr).stipple[22]);
+   debug_printf("\t\t.stipple[23] = 0x%x\n", (*ptr).stipple[23]);
+   debug_printf("\t\t.stipple[24] = 0x%x\n", (*ptr).stipple[24]);
+   debug_printf("\t\t.stipple[25] = 0x%x\n", (*ptr).stipple[25]);
+   debug_printf("\t\t.stipple[26] = 0x%x\n", (*ptr).stipple[26]);
+   debug_printf("\t\t.stipple[27] = 0x%x\n", (*ptr).stipple[27]);
+   debug_printf("\t\t.stipple[28] = 0x%x\n", (*ptr).stipple[28]);
+   debug_printf("\t\t.stipple[29] = 0x%x\n", (*ptr).stipple[29]);
+   debug_printf("\t\t.stipple[30] = 0x%x\n", (*ptr).stipple[30]);
+   debug_printf("\t\t.stipple[31] = 0x%x\n", (*ptr).stipple[31]);
+}
+
+void
+brw_dump_polygon_stipple_offset(const struct brw_polygon_stipple_offset *ptr)
+{
+   debug_printf("\t\t.header.length = 0x%x\n", (*ptr).header.length);
+   debug_printf("\t\t.header.opcode = 0x%x\n", (*ptr).header.opcode);
+   debug_printf("\t\t.bits0.y_offset = 0x%x\n", (*ptr).bits0.y_offset);
+   debug_printf("\t\t.bits0.x_offset = 0x%x\n", (*ptr).bits0.x_offset);
+}
+
+void
+brw_dump_sampler_default_color(const struct brw_sampler_default_color *ptr)
+{
+   debug_printf("\t\t.color[0] = %f\n", (*ptr).color[0]);
+   debug_printf("\t\t.color[1] = %f\n", (*ptr).color[1]);
+   debug_printf("\t\t.color[2] = %f\n", (*ptr).color[2]);
+   debug_printf("\t\t.color[3] = %f\n", (*ptr).color[3]);
+}
+
+void
+brw_dump_sampler_state(const struct brw_sampler_state *ptr)
+{
+   debug_printf("\t\t.ss0.shadow_function = 0x%x\n", (*ptr).ss0.shadow_function);
+   debug_printf("\t\t.ss0.lod_bias = 0x%x\n", (*ptr).ss0.lod_bias);
+   debug_printf("\t\t.ss0.min_filter = 0x%x\n", (*ptr).ss0.min_filter);
+   debug_printf("\t\t.ss0.mag_filter = 0x%x\n", (*ptr).ss0.mag_filter);
+   debug_printf("\t\t.ss0.mip_filter = 0x%x\n", (*ptr).ss0.mip_filter);
+   debug_printf("\t\t.ss0.base_level = 0x%x\n", (*ptr).ss0.base_level);
+   debug_printf("\t\t.ss0.lod_preclamp = 0x%x\n", (*ptr).ss0.lod_preclamp);
+   debug_printf("\t\t.ss0.default_color_mode = 0x%x\n", (*ptr).ss0.default_color_mode);
+   debug_printf("\t\t.ss0.disable = 0x%x\n", (*ptr).ss0.disable);
+   debug_printf("\t\t.ss1.r_wrap_mode = 0x%x\n", (*ptr).ss1.r_wrap_mode);
+   debug_printf("\t\t.ss1.t_wrap_mode = 0x%x\n", (*ptr).ss1.t_wrap_mode);
+   debug_printf("\t\t.ss1.s_wrap_mode = 0x%x\n", (*ptr).ss1.s_wrap_mode);
+   debug_printf("\t\t.ss1.max_lod = 0x%x\n", (*ptr).ss1.max_lod);
+   debug_printf("\t\t.ss1.min_lod = 0x%x\n", (*ptr).ss1.min_lod);
+   debug_printf("\t\t.ss2.default_color_pointer = 0x%x\n", (*ptr).ss2.default_color_pointer);
+   debug_printf("\t\t.ss3.max_aniso = 0x%x\n", (*ptr).ss3.max_aniso);
+   debug_printf("\t\t.ss3.chroma_key_mode = 0x%x\n", (*ptr).ss3.chroma_key_mode);
+   debug_printf("\t\t.ss3.chroma_key_index = 0x%x\n", (*ptr).ss3.chroma_key_index);
+   debug_printf("\t\t.ss3.chroma_key_enable = 0x%x\n", (*ptr).ss3.chroma_key_enable);
+   debug_printf("\t\t.ss3.monochrome_filter_width = 0x%x\n", (*ptr).ss3.monochrome_filter_width);
+   debug_printf("\t\t.ss3.monochrome_filter_height = 0x%x\n", (*ptr).ss3.monochrome_filter_height);
+}
+
+void
+brw_dump_sf_unit_state(const struct brw_sf_unit_state *ptr)
+{
+   debug_printf("\t\t.thread0.grf_reg_count = 0x%x\n", (*ptr).thread0.grf_reg_count);
+   debug_printf("\t\t.thread0.kernel_start_pointer = 0x%x\n", (*ptr).thread0.kernel_start_pointer);
+   debug_printf("\t\t.thread1.ext_halt_exception_enable = 0x%x\n", (*ptr).thread1.ext_halt_exception_enable);
+   debug_printf("\t\t.thread1.sw_exception_enable = 0x%x\n", (*ptr).thread1.sw_exception_enable);
+   debug_printf("\t\t.thread1.mask_stack_exception_enable = 0x%x\n", (*ptr).thread1.mask_stack_exception_enable);
+   debug_printf("\t\t.thread1.timeout_exception_enable = 0x%x\n", (*ptr).thread1.timeout_exception_enable);
+   debug_printf("\t\t.thread1.illegal_op_exception_enable = 0x%x\n", (*ptr).thread1.illegal_op_exception_enable);
+   debug_printf("\t\t.thread1.depth_coef_urb_read_offset = 0x%x\n", (*ptr).thread1.depth_coef_urb_read_offset);
+   debug_printf("\t\t.thread1.floating_point_mode = 0x%x\n", (*ptr).thread1.floating_point_mode);
+   debug_printf("\t\t.thread1.thread_priority = 0x%x\n", (*ptr).thread1.thread_priority);
+   debug_printf("\t\t.thread1.binding_table_entry_count = 0x%x\n", (*ptr).thread1.binding_table_entry_count);
+   debug_printf("\t\t.thread1.single_program_flow = 0x%x\n", (*ptr).thread1.single_program_flow);
+   debug_printf("\t\t.thread2.per_thread_scratch_space = 0x%x\n", (*ptr).thread2.per_thread_scratch_space);
+   debug_printf("\t\t.thread2.scratch_space_base_pointer = 0x%x\n", (*ptr).thread2.scratch_space_base_pointer);
+   debug_printf("\t\t.thread3.dispatch_grf_start_reg = 0x%x\n", (*ptr).thread3.dispatch_grf_start_reg);
+   debug_printf("\t\t.thread3.urb_entry_read_offset = 0x%x\n", (*ptr).thread3.urb_entry_read_offset);
+   debug_printf("\t\t.thread3.urb_entry_read_length = 0x%x\n", (*ptr).thread3.urb_entry_read_length);
+   debug_printf("\t\t.thread3.const_urb_entry_read_offset = 0x%x\n", (*ptr).thread3.const_urb_entry_read_offset);
+   debug_printf("\t\t.thread3.const_urb_entry_read_length = 0x%x\n", (*ptr).thread3.const_urb_entry_read_length);
+   debug_printf("\t\t.thread4.stats_enable = 0x%x\n", (*ptr).thread4.stats_enable);
+   debug_printf("\t\t.thread4.nr_urb_entries = 0x%x\n", (*ptr).thread4.nr_urb_entries);
+   debug_printf("\t\t.thread4.urb_entry_allocation_size = 0x%x\n", (*ptr).thread4.urb_entry_allocation_size);
+   debug_printf("\t\t.thread4.max_threads = 0x%x\n", (*ptr).thread4.max_threads);
+   debug_printf("\t\t.sf5.front_winding = 0x%x\n", (*ptr).sf5.front_winding);
+   debug_printf("\t\t.sf5.viewport_transform = 0x%x\n", (*ptr).sf5.viewport_transform);
+   debug_printf("\t\t.sf5.sf_viewport_state_offset = 0x%x\n", (*ptr).sf5.sf_viewport_state_offset);
+   debug_printf("\t\t.sf6.dest_org_vbias = 0x%x\n", (*ptr).sf6.dest_org_vbias);
+   debug_printf("\t\t.sf6.dest_org_hbias = 0x%x\n", (*ptr).sf6.dest_org_hbias);
+   debug_printf("\t\t.sf6.scissor = 0x%x\n", (*ptr).sf6.scissor);
+   debug_printf("\t\t.sf6.disable_2x2_trifilter = 0x%x\n", (*ptr).sf6.disable_2x2_trifilter);
+   debug_printf("\t\t.sf6.disable_zero_pix_trifilter = 0x%x\n", (*ptr).sf6.disable_zero_pix_trifilter);
+   debug_printf("\t\t.sf6.point_rast_rule = 0x%x\n", (*ptr).sf6.point_rast_rule);
+   debug_printf("\t\t.sf6.line_endcap_aa_region_width = 0x%x\n", (*ptr).sf6.line_endcap_aa_region_width);
+   debug_printf("\t\t.sf6.line_width = 0x%x\n", (*ptr).sf6.line_width);
+   debug_printf("\t\t.sf6.fast_scissor_disable = 0x%x\n", (*ptr).sf6.fast_scissor_disable);
+   debug_printf("\t\t.sf6.cull_mode = 0x%x\n", (*ptr).sf6.cull_mode);
+   debug_printf("\t\t.sf6.aa_enable = 0x%x\n", (*ptr).sf6.aa_enable);
+   debug_printf("\t\t.sf7.point_size = 0x%x\n", (*ptr).sf7.point_size);
+   debug_printf("\t\t.sf7.use_point_size_state = 0x%x\n", (*ptr).sf7.use_point_size_state);
+   debug_printf("\t\t.sf7.subpixel_precision = 0x%x\n", (*ptr).sf7.subpixel_precision);
+   debug_printf("\t\t.sf7.sprite_point = 0x%x\n", (*ptr).sf7.sprite_point);
+   debug_printf("\t\t.sf7.aa_line_distance_mode = 0x%x\n", (*ptr).sf7.aa_line_distance_mode);
+   debug_printf("\t\t.sf7.trifan_pv = 0x%x\n", (*ptr).sf7.trifan_pv);
+   debug_printf("\t\t.sf7.linestrip_pv = 0x%x\n", (*ptr).sf7.linestrip_pv);
+   debug_printf("\t\t.sf7.tristrip_pv = 0x%x\n", (*ptr).sf7.tristrip_pv);
+   debug_printf("\t\t.sf7.line_last_pixel_enable = 0x%x\n", (*ptr).sf7.line_last_pixel_enable);
+}
+
+void
+brw_dump_sf_viewport(const struct brw_sf_viewport *ptr)
+{
+   debug_printf("\t\t.viewport.m00 = %f\n", (*ptr).viewport.m00);
+   debug_printf("\t\t.viewport.m11 = %f\n", (*ptr).viewport.m11);
+   debug_printf("\t\t.viewport.m22 = %f\n", (*ptr).viewport.m22);
+   debug_printf("\t\t.viewport.m30 = %f\n", (*ptr).viewport.m30);
+   debug_printf("\t\t.viewport.m31 = %f\n", (*ptr).viewport.m31);
+   debug_printf("\t\t.viewport.m32 = %f\n", (*ptr).viewport.m32);
+   debug_printf("\t\t.scissor.xmin = 0x%x\n", (*ptr).scissor.xmin);
+   debug_printf("\t\t.scissor.ymin = 0x%x\n", (*ptr).scissor.ymin);
+   debug_printf("\t\t.scissor.xmax = 0x%x\n", (*ptr).scissor.xmax);
+   debug_printf("\t\t.scissor.ymax = 0x%x\n", (*ptr).scissor.ymax);
+}
+
+void
+brw_dump_ss0(const struct brw_ss0 *ptr)
+{
+   debug_printf("\t\t.shadow_function = 0x%x\n", (*ptr).shadow_function);
+   debug_printf("\t\t.lod_bias = 0x%x\n", (*ptr).lod_bias);
+   debug_printf("\t\t.min_filter = 0x%x\n", (*ptr).min_filter);
+   debug_printf("\t\t.mag_filter = 0x%x\n", (*ptr).mag_filter);
+   debug_printf("\t\t.mip_filter = 0x%x\n", (*ptr).mip_filter);
+   debug_printf("\t\t.base_level = 0x%x\n", (*ptr).base_level);
+   debug_printf("\t\t.lod_preclamp = 0x%x\n", (*ptr).lod_preclamp);
+   debug_printf("\t\t.default_color_mode = 0x%x\n", (*ptr).default_color_mode);
+   debug_printf("\t\t.disable = 0x%x\n", (*ptr).disable);
+}
+
+void
+brw_dump_ss1(const struct brw_ss1 *ptr)
+{
+   debug_printf("\t\t.r_wrap_mode = 0x%x\n", (*ptr).r_wrap_mode);
+   debug_printf("\t\t.t_wrap_mode = 0x%x\n", (*ptr).t_wrap_mode);
+   debug_printf("\t\t.s_wrap_mode = 0x%x\n", (*ptr).s_wrap_mode);
+   debug_printf("\t\t.max_lod = 0x%x\n", (*ptr).max_lod);
+   debug_printf("\t\t.min_lod = 0x%x\n", (*ptr).min_lod);
+}
+
+void
+brw_dump_ss2(const struct brw_ss2 *ptr)
+{
+   debug_printf("\t\t.default_color_pointer = 0x%x\n", (*ptr).default_color_pointer);
+}
+
+void
+brw_dump_ss3(const struct brw_ss3 *ptr)
+{
+   debug_printf("\t\t.max_aniso = 0x%x\n", (*ptr).max_aniso);
+   debug_printf("\t\t.chroma_key_mode = 0x%x\n", (*ptr).chroma_key_mode);
+   debug_printf("\t\t.chroma_key_index = 0x%x\n", (*ptr).chroma_key_index);
+   debug_printf("\t\t.chroma_key_enable = 0x%x\n", (*ptr).chroma_key_enable);
+   debug_printf("\t\t.monochrome_filter_width = 0x%x\n", (*ptr).monochrome_filter_width);
+   debug_printf("\t\t.monochrome_filter_height = 0x%x\n", (*ptr).monochrome_filter_height);
+}
+
+void
+brw_dump_state_base_address(const struct brw_state_base_address *ptr)
+{
+   debug_printf("\t\t.header.length = 0x%x\n", (*ptr).header.length);
+   debug_printf("\t\t.header.opcode = 0x%x\n", (*ptr).header.opcode);
+   debug_printf("\t\t.bits0.modify_enable = 0x%x\n", (*ptr).bits0.modify_enable);
+   debug_printf("\t\t.bits0.general_state_address = 0x%x\n", (*ptr).bits0.general_state_address);
+   debug_printf("\t\t.bits1.modify_enable = 0x%x\n", (*ptr).bits1.modify_enable);
+   debug_printf("\t\t.bits1.surface_state_address = 0x%x\n", (*ptr).bits1.surface_state_address);
+   debug_printf("\t\t.bits2.modify_enable = 0x%x\n", (*ptr).bits2.modify_enable);
+   debug_printf("\t\t.bits2.indirect_object_state_address = 0x%x\n", (*ptr).bits2.indirect_object_state_address);
+   debug_printf("\t\t.bits3.modify_enable = 0x%x\n", (*ptr).bits3.modify_enable);
+   debug_printf("\t\t.bits3.general_state_upper_bound = 0x%x\n", (*ptr).bits3.general_state_upper_bound);
+   debug_printf("\t\t.bits4.modify_enable = 0x%x\n", (*ptr).bits4.modify_enable);
+   debug_printf("\t\t.bits4.indirect_object_state_upper_bound = 0x%x\n", (*ptr).bits4.indirect_object_state_upper_bound);
+}
+
+void
+brw_dump_state_prefetch(const struct brw_state_prefetch *ptr)
+{
+   debug_printf("\t\t.header.length = 0x%x\n", (*ptr).header.length);
+   debug_printf("\t\t.header.opcode = 0x%x\n", (*ptr).header.opcode);
+   debug_printf("\t\t.bits0.prefetch_count = 0x%x\n", (*ptr).bits0.prefetch_count);
+   debug_printf("\t\t.bits0.prefetch_pointer = 0x%x\n", (*ptr).bits0.prefetch_pointer);
+}
+
+void
+brw_dump_surf_ss0(const struct brw_surf_ss0 *ptr)
+{
+   debug_printf("\t\t.cube_pos_z = 0x%x\n", (*ptr).cube_pos_z);
+   debug_printf("\t\t.cube_neg_z = 0x%x\n", (*ptr).cube_neg_z);
+   debug_printf("\t\t.cube_pos_y = 0x%x\n", (*ptr).cube_pos_y);
+   debug_printf("\t\t.cube_neg_y = 0x%x\n", (*ptr).cube_neg_y);
+   debug_printf("\t\t.cube_pos_x = 0x%x\n", (*ptr).cube_pos_x);
+   debug_printf("\t\t.cube_neg_x = 0x%x\n", (*ptr).cube_neg_x);
+   debug_printf("\t\t.mipmap_layout_mode = 0x%x\n", (*ptr).mipmap_layout_mode);
+   debug_printf("\t\t.vert_line_stride_ofs = 0x%x\n", (*ptr).vert_line_stride_ofs);
+   debug_printf("\t\t.vert_line_stride = 0x%x\n", (*ptr).vert_line_stride);
+   debug_printf("\t\t.color_blend = 0x%x\n", (*ptr).color_blend);
+   debug_printf("\t\t.writedisable_blue = 0x%x\n", (*ptr).writedisable_blue);
+   debug_printf("\t\t.writedisable_green = 0x%x\n", (*ptr).writedisable_green);
+   debug_printf("\t\t.writedisable_red = 0x%x\n", (*ptr).writedisable_red);
+   debug_printf("\t\t.writedisable_alpha = 0x%x\n", (*ptr).writedisable_alpha);
+   debug_printf("\t\t.surface_format = 0x%x\n", (*ptr).surface_format);
+   debug_printf("\t\t.data_return_format = 0x%x\n", (*ptr).data_return_format);
+   debug_printf("\t\t.surface_type = 0x%x\n", (*ptr).surface_type);
+}
+
+void
+brw_dump_surf_ss1(const struct brw_surf_ss1 *ptr)
+{
+   debug_printf("\t\t.base_addr = 0x%x\n", (*ptr).base_addr);
+}
+
+void
+brw_dump_surf_ss2(const struct brw_surf_ss2 *ptr)
+{
+   debug_printf("\t\t.mip_count = 0x%x\n", (*ptr).mip_count);
+   debug_printf("\t\t.width = 0x%x\n", (*ptr).width);
+   debug_printf("\t\t.height = 0x%x\n", (*ptr).height);
+}
+
+void
+brw_dump_surf_ss3(const struct brw_surf_ss3 *ptr)
+{
+   debug_printf("\t\t.tile_walk = 0x%x\n", (*ptr).tile_walk);
+   debug_printf("\t\t.tiled_surface = 0x%x\n", (*ptr).tiled_surface);
+   debug_printf("\t\t.pitch = 0x%x\n", (*ptr).pitch);
+   debug_printf("\t\t.depth = 0x%x\n", (*ptr).depth);
+}
+
+void
+brw_dump_surf_ss4(const struct brw_surf_ss4 *ptr)
+{
+   debug_printf("\t\t.multisample_position_palette_index = 0x%x\n", (*ptr).multisample_position_palette_index);
+   debug_printf("\t\t.num_multisamples = 0x%x\n", (*ptr).num_multisamples);
+   debug_printf("\t\t.render_target_view_extent = 0x%x\n", (*ptr).render_target_view_extent);
+   debug_printf("\t\t.min_array_elt = 0x%x\n", (*ptr).min_array_elt);
+   debug_printf("\t\t.min_lod = 0x%x\n", (*ptr).min_lod);
+}
+
+void
+brw_dump_surf_ss5(const struct brw_surf_ss5 *ptr)
+{
+   debug_printf("\t\t.llc_mapping = 0x%x\n", (*ptr).llc_mapping);
+   debug_printf("\t\t.mlc_mapping = 0x%x\n", (*ptr).mlc_mapping);
+   debug_printf("\t\t.gfdt = 0x%x\n", (*ptr).gfdt);
+   debug_printf("\t\t.gfdt_src = 0x%x\n", (*ptr).gfdt_src);
+   debug_printf("\t\t.y_offset = 0x%x\n", (*ptr).y_offset);
+   debug_printf("\t\t.x_offset = 0x%x\n", (*ptr).x_offset);
+}
+
+void
+brw_dump_surface_state(const struct brw_surface_state *ptr)
+{
+   debug_printf("\t\t.ss0.cube_pos_z = 0x%x\n", (*ptr).ss0.cube_pos_z);
+   debug_printf("\t\t.ss0.cube_neg_z = 0x%x\n", (*ptr).ss0.cube_neg_z);
+   debug_printf("\t\t.ss0.cube_pos_y = 0x%x\n", (*ptr).ss0.cube_pos_y);
+   debug_printf("\t\t.ss0.cube_neg_y = 0x%x\n", (*ptr).ss0.cube_neg_y);
+   debug_printf("\t\t.ss0.cube_pos_x = 0x%x\n", (*ptr).ss0.cube_pos_x);
+   debug_printf("\t\t.ss0.cube_neg_x = 0x%x\n", (*ptr).ss0.cube_neg_x);
+   debug_printf("\t\t.ss0.mipmap_layout_mode = 0x%x\n", (*ptr).ss0.mipmap_layout_mode);
+   debug_printf("\t\t.ss0.vert_line_stride_ofs = 0x%x\n", (*ptr).ss0.vert_line_stride_ofs);
+   debug_printf("\t\t.ss0.vert_line_stride = 0x%x\n", (*ptr).ss0.vert_line_stride);
+   debug_printf("\t\t.ss0.color_blend = 0x%x\n", (*ptr).ss0.color_blend);
+   debug_printf("\t\t.ss0.writedisable_blue = 0x%x\n", (*ptr).ss0.writedisable_blue);
+   debug_printf("\t\t.ss0.writedisable_green = 0x%x\n", (*ptr).ss0.writedisable_green);
+   debug_printf("\t\t.ss0.writedisable_red = 0x%x\n", (*ptr).ss0.writedisable_red);
+   debug_printf("\t\t.ss0.writedisable_alpha = 0x%x\n", (*ptr).ss0.writedisable_alpha);
+   debug_printf("\t\t.ss0.surface_format = 0x%x\n", (*ptr).ss0.surface_format);
+   debug_printf("\t\t.ss0.data_return_format = 0x%x\n", (*ptr).ss0.data_return_format);
+   debug_printf("\t\t.ss0.surface_type = 0x%x\n", (*ptr).ss0.surface_type);
+   debug_printf("\t\t.ss1.base_addr = 0x%x\n", (*ptr).ss1.base_addr);
+   debug_printf("\t\t.ss2.mip_count = 0x%x\n", (*ptr).ss2.mip_count);
+   debug_printf("\t\t.ss2.width = 0x%x\n", (*ptr).ss2.width);
+   debug_printf("\t\t.ss2.height = 0x%x\n", (*ptr).ss2.height);
+   debug_printf("\t\t.ss3.tile_walk = 0x%x\n", (*ptr).ss3.tile_walk);
+   debug_printf("\t\t.ss3.tiled_surface = 0x%x\n", (*ptr).ss3.tiled_surface);
+   debug_printf("\t\t.ss3.pitch = 0x%x\n", (*ptr).ss3.pitch);
+   debug_printf("\t\t.ss3.depth = 0x%x\n", (*ptr).ss3.depth);
+   debug_printf("\t\t.ss4.multisample_position_palette_index = 0x%x\n", (*ptr).ss4.multisample_position_palette_index);
+   debug_printf("\t\t.ss4.num_multisamples = 0x%x\n", (*ptr).ss4.num_multisamples);
+   debug_printf("\t\t.ss4.render_target_view_extent = 0x%x\n", (*ptr).ss4.render_target_view_extent);
+   debug_printf("\t\t.ss4.min_array_elt = 0x%x\n", (*ptr).ss4.min_array_elt);
+   debug_printf("\t\t.ss4.min_lod = 0x%x\n", (*ptr).ss4.min_lod);
+   debug_printf("\t\t.ss5.llc_mapping = 0x%x\n", (*ptr).ss5.llc_mapping);
+   debug_printf("\t\t.ss5.mlc_mapping = 0x%x\n", (*ptr).ss5.mlc_mapping);
+   debug_printf("\t\t.ss5.gfdt = 0x%x\n", (*ptr).ss5.gfdt);
+   debug_printf("\t\t.ss5.gfdt_src = 0x%x\n", (*ptr).ss5.gfdt_src);
+   debug_printf("\t\t.ss5.y_offset = 0x%x\n", (*ptr).ss5.y_offset);
+   debug_printf("\t\t.ss5.x_offset = 0x%x\n", (*ptr).ss5.x_offset);
+}
+
+void
+brw_dump_system_instruction_pointer(const struct brw_system_instruction_pointer *ptr)
+{
+   debug_printf("\t\t.header.length = 0x%x\n", (*ptr).header.length);
+   debug_printf("\t\t.header.opcode = 0x%x\n", (*ptr).header.opcode);
+   debug_printf("\t\t.bits0.system_instruction_pointer = 0x%x\n", (*ptr).bits0.system_instruction_pointer);
+}
+
+void
+brw_dump_urb_fence(const struct brw_urb_fence *ptr)
+{
+   debug_printf("\t\t.header.length = 0x%x\n", (*ptr).header.length);
+   debug_printf("\t\t.header.vs_realloc = 0x%x\n", (*ptr).header.vs_realloc);
+   debug_printf("\t\t.header.gs_realloc = 0x%x\n", (*ptr).header.gs_realloc);
+   debug_printf("\t\t.header.clp_realloc = 0x%x\n", (*ptr).header.clp_realloc);
+   debug_printf("\t\t.header.sf_realloc = 0x%x\n", (*ptr).header.sf_realloc);
+   debug_printf("\t\t.header.vfe_realloc = 0x%x\n", (*ptr).header.vfe_realloc);
+   debug_printf("\t\t.header.cs_realloc = 0x%x\n", (*ptr).header.cs_realloc);
+   debug_printf("\t\t.header.opcode = 0x%x\n", (*ptr).header.opcode);
+   debug_printf("\t\t.bits0.vs_fence = 0x%x\n", (*ptr).bits0.vs_fence);
+   debug_printf("\t\t.bits0.gs_fence = 0x%x\n", (*ptr).bits0.gs_fence);
+   debug_printf("\t\t.bits0.clp_fence = 0x%x\n", (*ptr).bits0.clp_fence);
+   debug_printf("\t\t.bits1.sf_fence = 0x%x\n", (*ptr).bits1.sf_fence);
+   debug_printf("\t\t.bits1.vf_fence = 0x%x\n", (*ptr).bits1.vf_fence);
+   debug_printf("\t\t.bits1.cs_fence = 0x%x\n", (*ptr).bits1.cs_fence);
+}
+
+void
+brw_dump_urb_immediate(const struct brw_urb_immediate *ptr)
+{
+   debug_printf("\t\t.opcode = 0x%x\n", (*ptr).opcode);
+   debug_printf("\t\t.offset = 0x%x\n", (*ptr).offset);
+   debug_printf("\t\t.swizzle_control = 0x%x\n", (*ptr).swizzle_control);
+   debug_printf("\t\t.allocate = 0x%x\n", (*ptr).allocate);
+   debug_printf("\t\t.used = 0x%x\n", (*ptr).used);
+   debug_printf("\t\t.complete = 0x%x\n", (*ptr).complete);
+   debug_printf("\t\t.response_length = 0x%x\n", (*ptr).response_length);
+   debug_printf("\t\t.msg_length = 0x%x\n", (*ptr).msg_length);
+   debug_printf("\t\t.msg_target = 0x%x\n", (*ptr).msg_target);
+   debug_printf("\t\t.end_of_thread = 0x%x\n", (*ptr).end_of_thread);
+}
+
+void
+brw_dump_vb_array_state(const struct brw_vb_array_state *ptr)
+{
+   debug_printf("\t\t.header.length = 0x%x\n", (*ptr).header.length);
+   debug_printf("\t\t.header.opcode = 0x%x\n", (*ptr).header.opcode);
+   debug_printf("\t\t.vb[0].vb0.pitch = 0x%x\n", (*ptr).vb[0].vb0.pitch);
+   debug_printf("\t\t.vb[0].vb0.access_type = 0x%x\n", (*ptr).vb[0].vb0.access_type);
+   debug_printf("\t\t.vb[0].vb0.vb_index = 0x%x\n", (*ptr).vb[0].vb0.vb_index);
+   debug_printf("\t\t.vb[0].start_addr = 0x%x\n", (*ptr).vb[0].start_addr);
+   debug_printf("\t\t.vb[0].max_index = 0x%x\n", (*ptr).vb[0].max_index);
+   debug_printf("\t\t.vb[0].instance_data_step_rate = 0x%x\n", (*ptr).vb[0].instance_data_step_rate);
+   debug_printf("\t\t.vb[1].vb0.pitch = 0x%x\n", (*ptr).vb[1].vb0.pitch);
+   debug_printf("\t\t.vb[1].vb0.access_type = 0x%x\n", (*ptr).vb[1].vb0.access_type);
+   debug_printf("\t\t.vb[1].vb0.vb_index = 0x%x\n", (*ptr).vb[1].vb0.vb_index);
+   debug_printf("\t\t.vb[1].start_addr = 0x%x\n", (*ptr).vb[1].start_addr);
+   debug_printf("\t\t.vb[1].max_index = 0x%x\n", (*ptr).vb[1].max_index);
+   debug_printf("\t\t.vb[1].instance_data_step_rate = 0x%x\n", (*ptr).vb[1].instance_data_step_rate);
+   debug_printf("\t\t.vb[2].vb0.pitch = 0x%x\n", (*ptr).vb[2].vb0.pitch);
+   debug_printf("\t\t.vb[2].vb0.access_type = 0x%x\n", (*ptr).vb[2].vb0.access_type);
+   debug_printf("\t\t.vb[2].vb0.vb_index = 0x%x\n", (*ptr).vb[2].vb0.vb_index);
+   debug_printf("\t\t.vb[2].start_addr = 0x%x\n", (*ptr).vb[2].start_addr);
+   debug_printf("\t\t.vb[2].max_index = 0x%x\n", (*ptr).vb[2].max_index);
+   debug_printf("\t\t.vb[2].instance_data_step_rate = 0x%x\n", (*ptr).vb[2].instance_data_step_rate);
+   debug_printf("\t\t.vb[3].vb0.pitch = 0x%x\n", (*ptr).vb[3].vb0.pitch);
+   debug_printf("\t\t.vb[3].vb0.access_type = 0x%x\n", (*ptr).vb[3].vb0.access_type);
+   debug_printf("\t\t.vb[3].vb0.vb_index = 0x%x\n", (*ptr).vb[3].vb0.vb_index);
+   debug_printf("\t\t.vb[3].start_addr = 0x%x\n", (*ptr).vb[3].start_addr);
+   debug_printf("\t\t.vb[3].max_index = 0x%x\n", (*ptr).vb[3].max_index);
+   debug_printf("\t\t.vb[3].instance_data_step_rate = 0x%x\n", (*ptr).vb[3].instance_data_step_rate);
+   debug_printf("\t\t.vb[4].vb0.pitch = 0x%x\n", (*ptr).vb[4].vb0.pitch);
+   debug_printf("\t\t.vb[4].vb0.access_type = 0x%x\n", (*ptr).vb[4].vb0.access_type);
+   debug_printf("\t\t.vb[4].vb0.vb_index = 0x%x\n", (*ptr).vb[4].vb0.vb_index);
+   debug_printf("\t\t.vb[4].start_addr = 0x%x\n", (*ptr).vb[4].start_addr);
+   debug_printf("\t\t.vb[4].max_index = 0x%x\n", (*ptr).vb[4].max_index);
+   debug_printf("\t\t.vb[4].instance_data_step_rate = 0x%x\n", (*ptr).vb[4].instance_data_step_rate);
+   debug_printf("\t\t.vb[5].vb0.pitch = 0x%x\n", (*ptr).vb[5].vb0.pitch);
+   debug_printf("\t\t.vb[5].vb0.access_type = 0x%x\n", (*ptr).vb[5].vb0.access_type);
+   debug_printf("\t\t.vb[5].vb0.vb_index = 0x%x\n", (*ptr).vb[5].vb0.vb_index);
+   debug_printf("\t\t.vb[5].start_addr = 0x%x\n", (*ptr).vb[5].start_addr);
+   debug_printf("\t\t.vb[5].max_index = 0x%x\n", (*ptr).vb[5].max_index);
+   debug_printf("\t\t.vb[5].instance_data_step_rate = 0x%x\n", (*ptr).vb[5].instance_data_step_rate);
+   debug_printf("\t\t.vb[6].vb0.pitch = 0x%x\n", (*ptr).vb[6].vb0.pitch);
+   debug_printf("\t\t.vb[6].vb0.access_type = 0x%x\n", (*ptr).vb[6].vb0.access_type);
+   debug_printf("\t\t.vb[6].vb0.vb_index = 0x%x\n", (*ptr).vb[6].vb0.vb_index);
+   debug_printf("\t\t.vb[6].start_addr = 0x%x\n", (*ptr).vb[6].start_addr);
+   debug_printf("\t\t.vb[6].max_index = 0x%x\n", (*ptr).vb[6].max_index);
+   debug_printf("\t\t.vb[6].instance_data_step_rate = 0x%x\n", (*ptr).vb[6].instance_data_step_rate);
+   debug_printf("\t\t.vb[7].vb0.pitch = 0x%x\n", (*ptr).vb[7].vb0.pitch);
+   debug_printf("\t\t.vb[7].vb0.access_type = 0x%x\n", (*ptr).vb[7].vb0.access_type);
+   debug_printf("\t\t.vb[7].vb0.vb_index = 0x%x\n", (*ptr).vb[7].vb0.vb_index);
+   debug_printf("\t\t.vb[7].start_addr = 0x%x\n", (*ptr).vb[7].start_addr);
+   debug_printf("\t\t.vb[7].max_index = 0x%x\n", (*ptr).vb[7].max_index);
+   debug_printf("\t\t.vb[7].instance_data_step_rate = 0x%x\n", (*ptr).vb[7].instance_data_step_rate);
+   debug_printf("\t\t.vb[8].vb0.pitch = 0x%x\n", (*ptr).vb[8].vb0.pitch);
+   debug_printf("\t\t.vb[8].vb0.access_type = 0x%x\n", (*ptr).vb[8].vb0.access_type);
+   debug_printf("\t\t.vb[8].vb0.vb_index = 0x%x\n", (*ptr).vb[8].vb0.vb_index);
+   debug_printf("\t\t.vb[8].start_addr = 0x%x\n", (*ptr).vb[8].start_addr);
+   debug_printf("\t\t.vb[8].max_index = 0x%x\n", (*ptr).vb[8].max_index);
+   debug_printf("\t\t.vb[8].instance_data_step_rate = 0x%x\n", (*ptr).vb[8].instance_data_step_rate);
+   debug_printf("\t\t.vb[9].vb0.pitch = 0x%x\n", (*ptr).vb[9].vb0.pitch);
+   debug_printf("\t\t.vb[9].vb0.access_type = 0x%x\n", (*ptr).vb[9].vb0.access_type);
+   debug_printf("\t\t.vb[9].vb0.vb_index = 0x%x\n", (*ptr).vb[9].vb0.vb_index);
+   debug_printf("\t\t.vb[9].start_addr = 0x%x\n", (*ptr).vb[9].start_addr);
+   debug_printf("\t\t.vb[9].max_index = 0x%x\n", (*ptr).vb[9].max_index);
+   debug_printf("\t\t.vb[9].instance_data_step_rate = 0x%x\n", (*ptr).vb[9].instance_data_step_rate);
+   debug_printf("\t\t.vb[10].vb0.pitch = 0x%x\n", (*ptr).vb[10].vb0.pitch);
+   debug_printf("\t\t.vb[10].vb0.access_type = 0x%x\n", (*ptr).vb[10].vb0.access_type);
+   debug_printf("\t\t.vb[10].vb0.vb_index = 0x%x\n", (*ptr).vb[10].vb0.vb_index);
+   debug_printf("\t\t.vb[10].start_addr = 0x%x\n", (*ptr).vb[10].start_addr);
+   debug_printf("\t\t.vb[10].max_index = 0x%x\n", (*ptr).vb[10].max_index);
+   debug_printf("\t\t.vb[10].instance_data_step_rate = 0x%x\n", (*ptr).vb[10].instance_data_step_rate);
+   debug_printf("\t\t.vb[11].vb0.pitch = 0x%x\n", (*ptr).vb[11].vb0.pitch);
+   debug_printf("\t\t.vb[11].vb0.access_type = 0x%x\n", (*ptr).vb[11].vb0.access_type);
+   debug_printf("\t\t.vb[11].vb0.vb_index = 0x%x\n", (*ptr).vb[11].vb0.vb_index);
+   debug_printf("\t\t.vb[11].start_addr = 0x%x\n", (*ptr).vb[11].start_addr);
+   debug_printf("\t\t.vb[11].max_index = 0x%x\n", (*ptr).vb[11].max_index);
+   debug_printf("\t\t.vb[11].instance_data_step_rate = 0x%x\n", (*ptr).vb[11].instance_data_step_rate);
+   debug_printf("\t\t.vb[12].vb0.pitch = 0x%x\n", (*ptr).vb[12].vb0.pitch);
+   debug_printf("\t\t.vb[12].vb0.access_type = 0x%x\n", (*ptr).vb[12].vb0.access_type);
+   debug_printf("\t\t.vb[12].vb0.vb_index = 0x%x\n", (*ptr).vb[12].vb0.vb_index);
+   debug_printf("\t\t.vb[12].start_addr = 0x%x\n", (*ptr).vb[12].start_addr);
+   debug_printf("\t\t.vb[12].max_index = 0x%x\n", (*ptr).vb[12].max_index);
+   debug_printf("\t\t.vb[12].instance_data_step_rate = 0x%x\n", (*ptr).vb[12].instance_data_step_rate);
+   debug_printf("\t\t.vb[13].vb0.pitch = 0x%x\n", (*ptr).vb[13].vb0.pitch);
+   debug_printf("\t\t.vb[13].vb0.access_type = 0x%x\n", (*ptr).vb[13].vb0.access_type);
+   debug_printf("\t\t.vb[13].vb0.vb_index = 0x%x\n", (*ptr).vb[13].vb0.vb_index);
+   debug_printf("\t\t.vb[13].start_addr = 0x%x\n", (*ptr).vb[13].start_addr);
+   debug_printf("\t\t.vb[13].max_index = 0x%x\n", (*ptr).vb[13].max_index);
+   debug_printf("\t\t.vb[13].instance_data_step_rate = 0x%x\n", (*ptr).vb[13].instance_data_step_rate);
+   debug_printf("\t\t.vb[14].vb0.pitch = 0x%x\n", (*ptr).vb[14].vb0.pitch);
+   debug_printf("\t\t.vb[14].vb0.access_type = 0x%x\n", (*ptr).vb[14].vb0.access_type);
+   debug_printf("\t\t.vb[14].vb0.vb_index = 0x%x\n", (*ptr).vb[14].vb0.vb_index);
+   debug_printf("\t\t.vb[14].start_addr = 0x%x\n", (*ptr).vb[14].start_addr);
+   debug_printf("\t\t.vb[14].max_index = 0x%x\n", (*ptr).vb[14].max_index);
+   debug_printf("\t\t.vb[14].instance_data_step_rate = 0x%x\n", (*ptr).vb[14].instance_data_step_rate);
+   debug_printf("\t\t.vb[15].vb0.pitch = 0x%x\n", (*ptr).vb[15].vb0.pitch);
+   debug_printf("\t\t.vb[15].vb0.access_type = 0x%x\n", (*ptr).vb[15].vb0.access_type);
+   debug_printf("\t\t.vb[15].vb0.vb_index = 0x%x\n", (*ptr).vb[15].vb0.vb_index);
+   debug_printf("\t\t.vb[15].start_addr = 0x%x\n", (*ptr).vb[15].start_addr);
+   debug_printf("\t\t.vb[15].max_index = 0x%x\n", (*ptr).vb[15].max_index);
+   debug_printf("\t\t.vb[15].instance_data_step_rate = 0x%x\n", (*ptr).vb[15].instance_data_step_rate);
+   debug_printf("\t\t.vb[16].vb0.pitch = 0x%x\n", (*ptr).vb[16].vb0.pitch);
+   debug_printf("\t\t.vb[16].vb0.access_type = 0x%x\n", (*ptr).vb[16].vb0.access_type);
+   debug_printf("\t\t.vb[16].vb0.vb_index = 0x%x\n", (*ptr).vb[16].vb0.vb_index);
+   debug_printf("\t\t.vb[16].start_addr = 0x%x\n", (*ptr).vb[16].start_addr);
+   debug_printf("\t\t.vb[16].max_index = 0x%x\n", (*ptr).vb[16].max_index);
+   debug_printf("\t\t.vb[16].instance_data_step_rate = 0x%x\n", (*ptr).vb[16].instance_data_step_rate);
+}
+
+void
+brw_dump_vertex_buffer_state(const struct brw_vertex_buffer_state *ptr)
+{
+   debug_printf("\t\t.vb0.pitch = 0x%x\n", (*ptr).vb0.pitch);
+   debug_printf("\t\t.vb0.access_type = 0x%x\n", (*ptr).vb0.access_type);
+   debug_printf("\t\t.vb0.vb_index = 0x%x\n", (*ptr).vb0.vb_index);
+   debug_printf("\t\t.start_addr = 0x%x\n", (*ptr).start_addr);
+   debug_printf("\t\t.max_index = 0x%x\n", (*ptr).max_index);
+   debug_printf("\t\t.instance_data_step_rate = 0x%x\n", (*ptr).instance_data_step_rate);
+}
+
+void
+brw_dump_vertex_element_packet(const struct brw_vertex_element_packet *ptr)
+{
+   debug_printf("\t\t.header.length = 0x%x\n", (*ptr).header.length);
+   debug_printf("\t\t.header.opcode = 0x%x\n", (*ptr).header.opcode);
+   debug_printf("\t\t.ve[0].ve0.src_offset = 0x%x\n", (*ptr).ve[0].ve0.src_offset);
+   debug_printf("\t\t.ve[0].ve0.src_format = 0x%x\n", (*ptr).ve[0].ve0.src_format);
+   debug_printf("\t\t.ve[0].ve0.valid = 0x%x\n", (*ptr).ve[0].ve0.valid);
+   debug_printf("\t\t.ve[0].ve0.vertex_buffer_index = 0x%x\n", (*ptr).ve[0].ve0.vertex_buffer_index);
+   debug_printf("\t\t.ve[0].ve1.dst_offset = 0x%x\n", (*ptr).ve[0].ve1.dst_offset);
+   debug_printf("\t\t.ve[0].ve1.vfcomponent3 = 0x%x\n", (*ptr).ve[0].ve1.vfcomponent3);
+   debug_printf("\t\t.ve[0].ve1.vfcomponent2 = 0x%x\n", (*ptr).ve[0].ve1.vfcomponent2);
+   debug_printf("\t\t.ve[0].ve1.vfcomponent1 = 0x%x\n", (*ptr).ve[0].ve1.vfcomponent1);
+   debug_printf("\t\t.ve[0].ve1.vfcomponent0 = 0x%x\n", (*ptr).ve[0].ve1.vfcomponent0);
+   debug_printf("\t\t.ve[1].ve0.src_offset = 0x%x\n", (*ptr).ve[1].ve0.src_offset);
+   debug_printf("\t\t.ve[1].ve0.src_format = 0x%x\n", (*ptr).ve[1].ve0.src_format);
+   debug_printf("\t\t.ve[1].ve0.valid = 0x%x\n", (*ptr).ve[1].ve0.valid);
+   debug_printf("\t\t.ve[1].ve0.vertex_buffer_index = 0x%x\n", (*ptr).ve[1].ve0.vertex_buffer_index);
+   debug_printf("\t\t.ve[1].ve1.dst_offset = 0x%x\n", (*ptr).ve[1].ve1.dst_offset);
+   debug_printf("\t\t.ve[1].ve1.vfcomponent3 = 0x%x\n", (*ptr).ve[1].ve1.vfcomponent3);
+   debug_printf("\t\t.ve[1].ve1.vfcomponent2 = 0x%x\n", (*ptr).ve[1].ve1.vfcomponent2);
+   debug_printf("\t\t.ve[1].ve1.vfcomponent1 = 0x%x\n", (*ptr).ve[1].ve1.vfcomponent1);
+   debug_printf("\t\t.ve[1].ve1.vfcomponent0 = 0x%x\n", (*ptr).ve[1].ve1.vfcomponent0);
+   debug_printf("\t\t.ve[2].ve0.src_offset = 0x%x\n", (*ptr).ve[2].ve0.src_offset);
+   debug_printf("\t\t.ve[2].ve0.src_format = 0x%x\n", (*ptr).ve[2].ve0.src_format);
+   debug_printf("\t\t.ve[2].ve0.valid = 0x%x\n", (*ptr).ve[2].ve0.valid);
+   debug_printf("\t\t.ve[2].ve0.vertex_buffer_index = 0x%x\n", (*ptr).ve[2].ve0.vertex_buffer_index);
+   debug_printf("\t\t.ve[2].ve1.dst_offset = 0x%x\n", (*ptr).ve[2].ve1.dst_offset);
+   debug_printf("\t\t.ve[2].ve1.vfcomponent3 = 0x%x\n", (*ptr).ve[2].ve1.vfcomponent3);
+   debug_printf("\t\t.ve[2].ve1.vfcomponent2 = 0x%x\n", (*ptr).ve[2].ve1.vfcomponent2);
+   debug_printf("\t\t.ve[2].ve1.vfcomponent1 = 0x%x\n", (*ptr).ve[2].ve1.vfcomponent1);
+   debug_printf("\t\t.ve[2].ve1.vfcomponent0 = 0x%x\n", (*ptr).ve[2].ve1.vfcomponent0);
+   debug_printf("\t\t.ve[3].ve0.src_offset = 0x%x\n", (*ptr).ve[3].ve0.src_offset);
+   debug_printf("\t\t.ve[3].ve0.src_format = 0x%x\n", (*ptr).ve[3].ve0.src_format);
+   debug_printf("\t\t.ve[3].ve0.valid = 0x%x\n", (*ptr).ve[3].ve0.valid);
+   debug_printf("\t\t.ve[3].ve0.vertex_buffer_index = 0x%x\n", (*ptr).ve[3].ve0.vertex_buffer_index);
+   debug_printf("\t\t.ve[3].ve1.dst_offset = 0x%x\n", (*ptr).ve[3].ve1.dst_offset);
+   debug_printf("\t\t.ve[3].ve1.vfcomponent3 = 0x%x\n", (*ptr).ve[3].ve1.vfcomponent3);
+   debug_printf("\t\t.ve[3].ve1.vfcomponent2 = 0x%x\n", (*ptr).ve[3].ve1.vfcomponent2);
+   debug_printf("\t\t.ve[3].ve1.vfcomponent1 = 0x%x\n", (*ptr).ve[3].ve1.vfcomponent1);
+   debug_printf("\t\t.ve[3].ve1.vfcomponent0 = 0x%x\n", (*ptr).ve[3].ve1.vfcomponent0);
+   debug_printf("\t\t.ve[4].ve0.src_offset = 0x%x\n", (*ptr).ve[4].ve0.src_offset);
+   debug_printf("\t\t.ve[4].ve0.src_format = 0x%x\n", (*ptr).ve[4].ve0.src_format);
+   debug_printf("\t\t.ve[4].ve0.valid = 0x%x\n", (*ptr).ve[4].ve0.valid);
+   debug_printf("\t\t.ve[4].ve0.vertex_buffer_index = 0x%x\n", (*ptr).ve[4].ve0.vertex_buffer_index);
+   debug_printf("\t\t.ve[4].ve1.dst_offset = 0x%x\n", (*ptr).ve[4].ve1.dst_offset);
+   debug_printf("\t\t.ve[4].ve1.vfcomponent3 = 0x%x\n", (*ptr).ve[4].ve1.vfcomponent3);
+   debug_printf("\t\t.ve[4].ve1.vfcomponent2 = 0x%x\n", (*ptr).ve[4].ve1.vfcomponent2);
+   debug_printf("\t\t.ve[4].ve1.vfcomponent1 = 0x%x\n", (*ptr).ve[4].ve1.vfcomponent1);
+   debug_printf("\t\t.ve[4].ve1.vfcomponent0 = 0x%x\n", (*ptr).ve[4].ve1.vfcomponent0);
+   debug_printf("\t\t.ve[5].ve0.src_offset = 0x%x\n", (*ptr).ve[5].ve0.src_offset);
+   debug_printf("\t\t.ve[5].ve0.src_format = 0x%x\n", (*ptr).ve[5].ve0.src_format);
+   debug_printf("\t\t.ve[5].ve0.valid = 0x%x\n", (*ptr).ve[5].ve0.valid);
+   debug_printf("\t\t.ve[5].ve0.vertex_buffer_index = 0x%x\n", (*ptr).ve[5].ve0.vertex_buffer_index);
+   debug_printf("\t\t.ve[5].ve1.dst_offset = 0x%x\n", (*ptr).ve[5].ve1.dst_offset);
+   debug_printf("\t\t.ve[5].ve1.vfcomponent3 = 0x%x\n", (*ptr).ve[5].ve1.vfcomponent3);
+   debug_printf("\t\t.ve[5].ve1.vfcomponent2 = 0x%x\n", (*ptr).ve[5].ve1.vfcomponent2);
+   debug_printf("\t\t.ve[5].ve1.vfcomponent1 = 0x%x\n", (*ptr).ve[5].ve1.vfcomponent1);
+   debug_printf("\t\t.ve[5].ve1.vfcomponent0 = 0x%x\n", (*ptr).ve[5].ve1.vfcomponent0);
+   debug_printf("\t\t.ve[6].ve0.src_offset = 0x%x\n", (*ptr).ve[6].ve0.src_offset);
+   debug_printf("\t\t.ve[6].ve0.src_format = 0x%x\n", (*ptr).ve[6].ve0.src_format);
+   debug_printf("\t\t.ve[6].ve0.valid = 0x%x\n", (*ptr).ve[6].ve0.valid);
+   debug_printf("\t\t.ve[6].ve0.vertex_buffer_index = 0x%x\n", (*ptr).ve[6].ve0.vertex_buffer_index);
+   debug_printf("\t\t.ve[6].ve1.dst_offset = 0x%x\n", (*ptr).ve[6].ve1.dst_offset);
+   debug_printf("\t\t.ve[6].ve1.vfcomponent3 = 0x%x\n", (*ptr).ve[6].ve1.vfcomponent3);
+   debug_printf("\t\t.ve[6].ve1.vfcomponent2 = 0x%x\n", (*ptr).ve[6].ve1.vfcomponent2);
+   debug_printf("\t\t.ve[6].ve1.vfcomponent1 = 0x%x\n", (*ptr).ve[6].ve1.vfcomponent1);
+   debug_printf("\t\t.ve[6].ve1.vfcomponent0 = 0x%x\n", (*ptr).ve[6].ve1.vfcomponent0);
+   debug_printf("\t\t.ve[7].ve0.src_offset = 0x%x\n", (*ptr).ve[7].ve0.src_offset);
+   debug_printf("\t\t.ve[7].ve0.src_format = 0x%x\n", (*ptr).ve[7].ve0.src_format);
+   debug_printf("\t\t.ve[7].ve0.valid = 0x%x\n", (*ptr).ve[7].ve0.valid);
+   debug_printf("\t\t.ve[7].ve0.vertex_buffer_index = 0x%x\n", (*ptr).ve[7].ve0.vertex_buffer_index);
+   debug_printf("\t\t.ve[7].ve1.dst_offset = 0x%x\n", (*ptr).ve[7].ve1.dst_offset);
+   debug_printf("\t\t.ve[7].ve1.vfcomponent3 = 0x%x\n", (*ptr).ve[7].ve1.vfcomponent3);
+   debug_printf("\t\t.ve[7].ve1.vfcomponent2 = 0x%x\n", (*ptr).ve[7].ve1.vfcomponent2);
+   debug_printf("\t\t.ve[7].ve1.vfcomponent1 = 0x%x\n", (*ptr).ve[7].ve1.vfcomponent1);
+   debug_printf("\t\t.ve[7].ve1.vfcomponent0 = 0x%x\n", (*ptr).ve[7].ve1.vfcomponent0);
+   debug_printf("\t\t.ve[8].ve0.src_offset = 0x%x\n", (*ptr).ve[8].ve0.src_offset);
+   debug_printf("\t\t.ve[8].ve0.src_format = 0x%x\n", (*ptr).ve[8].ve0.src_format);
+   debug_printf("\t\t.ve[8].ve0.valid = 0x%x\n", (*ptr).ve[8].ve0.valid);
+   debug_printf("\t\t.ve[8].ve0.vertex_buffer_index = 0x%x\n", (*ptr).ve[8].ve0.vertex_buffer_index);
+   debug_printf("\t\t.ve[8].ve1.dst_offset = 0x%x\n", (*ptr).ve[8].ve1.dst_offset);
+   debug_printf("\t\t.ve[8].ve1.vfcomponent3 = 0x%x\n", (*ptr).ve[8].ve1.vfcomponent3);
+   debug_printf("\t\t.ve[8].ve1.vfcomponent2 = 0x%x\n", (*ptr).ve[8].ve1.vfcomponent2);
+   debug_printf("\t\t.ve[8].ve1.vfcomponent1 = 0x%x\n", (*ptr).ve[8].ve1.vfcomponent1);
+   debug_printf("\t\t.ve[8].ve1.vfcomponent0 = 0x%x\n", (*ptr).ve[8].ve1.vfcomponent0);
+   debug_printf("\t\t.ve[9].ve0.src_offset = 0x%x\n", (*ptr).ve[9].ve0.src_offset);
+   debug_printf("\t\t.ve[9].ve0.src_format = 0x%x\n", (*ptr).ve[9].ve0.src_format);
+   debug_printf("\t\t.ve[9].ve0.valid = 0x%x\n", (*ptr).ve[9].ve0.valid);
+   debug_printf("\t\t.ve[9].ve0.vertex_buffer_index = 0x%x\n", (*ptr).ve[9].ve0.vertex_buffer_index);
+   debug_printf("\t\t.ve[9].ve1.dst_offset = 0x%x\n", (*ptr).ve[9].ve1.dst_offset);
+   debug_printf("\t\t.ve[9].ve1.vfcomponent3 = 0x%x\n", (*ptr).ve[9].ve1.vfcomponent3);
+   debug_printf("\t\t.ve[9].ve1.vfcomponent2 = 0x%x\n", (*ptr).ve[9].ve1.vfcomponent2);
+   debug_printf("\t\t.ve[9].ve1.vfcomponent1 = 0x%x\n", (*ptr).ve[9].ve1.vfcomponent1);
+   debug_printf("\t\t.ve[9].ve1.vfcomponent0 = 0x%x\n", (*ptr).ve[9].ve1.vfcomponent0);
+   debug_printf("\t\t.ve[10].ve0.src_offset = 0x%x\n", (*ptr).ve[10].ve0.src_offset);
+   debug_printf("\t\t.ve[10].ve0.src_format = 0x%x\n", (*ptr).ve[10].ve0.src_format);
+   debug_printf("\t\t.ve[10].ve0.valid = 0x%x\n", (*ptr).ve[10].ve0.valid);
+   debug_printf("\t\t.ve[10].ve0.vertex_buffer_index = 0x%x\n", (*ptr).ve[10].ve0.vertex_buffer_index);
+   debug_printf("\t\t.ve[10].ve1.dst_offset = 0x%x\n", (*ptr).ve[10].ve1.dst_offset);
+   debug_printf("\t\t.ve[10].ve1.vfcomponent3 = 0x%x\n", (*ptr).ve[10].ve1.vfcomponent3);
+   debug_printf("\t\t.ve[10].ve1.vfcomponent2 = 0x%x\n", (*ptr).ve[10].ve1.vfcomponent2);
+   debug_printf("\t\t.ve[10].ve1.vfcomponent1 = 0x%x\n", (*ptr).ve[10].ve1.vfcomponent1);
+   debug_printf("\t\t.ve[10].ve1.vfcomponent0 = 0x%x\n", (*ptr).ve[10].ve1.vfcomponent0);
+   debug_printf("\t\t.ve[11].ve0.src_offset = 0x%x\n", (*ptr).ve[11].ve0.src_offset);
+   debug_printf("\t\t.ve[11].ve0.src_format = 0x%x\n", (*ptr).ve[11].ve0.src_format);
+   debug_printf("\t\t.ve[11].ve0.valid = 0x%x\n", (*ptr).ve[11].ve0.valid);
+   debug_printf("\t\t.ve[11].ve0.vertex_buffer_index = 0x%x\n", (*ptr).ve[11].ve0.vertex_buffer_index);
+   debug_printf("\t\t.ve[11].ve1.dst_offset = 0x%x\n", (*ptr).ve[11].ve1.dst_offset);
+   debug_printf("\t\t.ve[11].ve1.vfcomponent3 = 0x%x\n", (*ptr).ve[11].ve1.vfcomponent3);
+   debug_printf("\t\t.ve[11].ve1.vfcomponent2 = 0x%x\n", (*ptr).ve[11].ve1.vfcomponent2);
+   debug_printf("\t\t.ve[11].ve1.vfcomponent1 = 0x%x\n", (*ptr).ve[11].ve1.vfcomponent1);
+   debug_printf("\t\t.ve[11].ve1.vfcomponent0 = 0x%x\n", (*ptr).ve[11].ve1.vfcomponent0);
+   debug_printf("\t\t.ve[12].ve0.src_offset = 0x%x\n", (*ptr).ve[12].ve0.src_offset);
+   debug_printf("\t\t.ve[12].ve0.src_format = 0x%x\n", (*ptr).ve[12].ve0.src_format);
+   debug_printf("\t\t.ve[12].ve0.valid = 0x%x\n", (*ptr).ve[12].ve0.valid);
+   debug_printf("\t\t.ve[12].ve0.vertex_buffer_index = 0x%x\n", (*ptr).ve[12].ve0.vertex_buffer_index);
+   debug_printf("\t\t.ve[12].ve1.dst_offset = 0x%x\n", (*ptr).ve[12].ve1.dst_offset);
+   debug_printf("\t\t.ve[12].ve1.vfcomponent3 = 0x%x\n", (*ptr).ve[12].ve1.vfcomponent3);
+   debug_printf("\t\t.ve[12].ve1.vfcomponent2 = 0x%x\n", (*ptr).ve[12].ve1.vfcomponent2);
+   debug_printf("\t\t.ve[12].ve1.vfcomponent1 = 0x%x\n", (*ptr).ve[12].ve1.vfcomponent1);
+   debug_printf("\t\t.ve[12].ve1.vfcomponent0 = 0x%x\n", (*ptr).ve[12].ve1.vfcomponent0);
+   debug_printf("\t\t.ve[13].ve0.src_offset = 0x%x\n", (*ptr).ve[13].ve0.src_offset);
+   debug_printf("\t\t.ve[13].ve0.src_format = 0x%x\n", (*ptr).ve[13].ve0.src_format);
+   debug_printf("\t\t.ve[13].ve0.valid = 0x%x\n", (*ptr).ve[13].ve0.valid);
+   debug_printf("\t\t.ve[13].ve0.vertex_buffer_index = 0x%x\n", (*ptr).ve[13].ve0.vertex_buffer_index);
+   debug_printf("\t\t.ve[13].ve1.dst_offset = 0x%x\n", (*ptr).ve[13].ve1.dst_offset);
+   debug_printf("\t\t.ve[13].ve1.vfcomponent3 = 0x%x\n", (*ptr).ve[13].ve1.vfcomponent3);
+   debug_printf("\t\t.ve[13].ve1.vfcomponent2 = 0x%x\n", (*ptr).ve[13].ve1.vfcomponent2);
+   debug_printf("\t\t.ve[13].ve1.vfcomponent1 = 0x%x\n", (*ptr).ve[13].ve1.vfcomponent1);
+   debug_printf("\t\t.ve[13].ve1.vfcomponent0 = 0x%x\n", (*ptr).ve[13].ve1.vfcomponent0);
+   debug_printf("\t\t.ve[14].ve0.src_offset = 0x%x\n", (*ptr).ve[14].ve0.src_offset);
+   debug_printf("\t\t.ve[14].ve0.src_format = 0x%x\n", (*ptr).ve[14].ve0.src_format);
+   debug_printf("\t\t.ve[14].ve0.valid = 0x%x\n", (*ptr).ve[14].ve0.valid);
+   debug_printf("\t\t.ve[14].ve0.vertex_buffer_index = 0x%x\n", (*ptr).ve[14].ve0.vertex_buffer_index);
+   debug_printf("\t\t.ve[14].ve1.dst_offset = 0x%x\n", (*ptr).ve[14].ve1.dst_offset);
+   debug_printf("\t\t.ve[14].ve1.vfcomponent3 = 0x%x\n", (*ptr).ve[14].ve1.vfcomponent3);
+   debug_printf("\t\t.ve[14].ve1.vfcomponent2 = 0x%x\n", (*ptr).ve[14].ve1.vfcomponent2);
+   debug_printf("\t\t.ve[14].ve1.vfcomponent1 = 0x%x\n", (*ptr).ve[14].ve1.vfcomponent1);
+   debug_printf("\t\t.ve[14].ve1.vfcomponent0 = 0x%x\n", (*ptr).ve[14].ve1.vfcomponent0);
+   debug_printf("\t\t.ve[15].ve0.src_offset = 0x%x\n", (*ptr).ve[15].ve0.src_offset);
+   debug_printf("\t\t.ve[15].ve0.src_format = 0x%x\n", (*ptr).ve[15].ve0.src_format);
+   debug_printf("\t\t.ve[15].ve0.valid = 0x%x\n", (*ptr).ve[15].ve0.valid);
+   debug_printf("\t\t.ve[15].ve0.vertex_buffer_index = 0x%x\n", (*ptr).ve[15].ve0.vertex_buffer_index);
+   debug_printf("\t\t.ve[15].ve1.dst_offset = 0x%x\n", (*ptr).ve[15].ve1.dst_offset);
+   debug_printf("\t\t.ve[15].ve1.vfcomponent3 = 0x%x\n", (*ptr).ve[15].ve1.vfcomponent3);
+   debug_printf("\t\t.ve[15].ve1.vfcomponent2 = 0x%x\n", (*ptr).ve[15].ve1.vfcomponent2);
+   debug_printf("\t\t.ve[15].ve1.vfcomponent1 = 0x%x\n", (*ptr).ve[15].ve1.vfcomponent1);
+   debug_printf("\t\t.ve[15].ve1.vfcomponent0 = 0x%x\n", (*ptr).ve[15].ve1.vfcomponent0);
+   debug_printf("\t\t.ve[16].ve0.src_offset = 0x%x\n", (*ptr).ve[16].ve0.src_offset);
+   debug_printf("\t\t.ve[16].ve0.src_format = 0x%x\n", (*ptr).ve[16].ve0.src_format);
+   debug_printf("\t\t.ve[16].ve0.valid = 0x%x\n", (*ptr).ve[16].ve0.valid);
+   debug_printf("\t\t.ve[16].ve0.vertex_buffer_index = 0x%x\n", (*ptr).ve[16].ve0.vertex_buffer_index);
+   debug_printf("\t\t.ve[16].ve1.dst_offset = 0x%x\n", (*ptr).ve[16].ve1.dst_offset);
+   debug_printf("\t\t.ve[16].ve1.vfcomponent3 = 0x%x\n", (*ptr).ve[16].ve1.vfcomponent3);
+   debug_printf("\t\t.ve[16].ve1.vfcomponent2 = 0x%x\n", (*ptr).ve[16].ve1.vfcomponent2);
+   debug_printf("\t\t.ve[16].ve1.vfcomponent1 = 0x%x\n", (*ptr).ve[16].ve1.vfcomponent1);
+   debug_printf("\t\t.ve[16].ve1.vfcomponent0 = 0x%x\n", (*ptr).ve[16].ve1.vfcomponent0);
+   debug_printf("\t\t.ve[17].ve0.src_offset = 0x%x\n", (*ptr).ve[17].ve0.src_offset);
+   debug_printf("\t\t.ve[17].ve0.src_format = 0x%x\n", (*ptr).ve[17].ve0.src_format);
+   debug_printf("\t\t.ve[17].ve0.valid = 0x%x\n", (*ptr).ve[17].ve0.valid);
+   debug_printf("\t\t.ve[17].ve0.vertex_buffer_index = 0x%x\n", (*ptr).ve[17].ve0.vertex_buffer_index);
+   debug_printf("\t\t.ve[17].ve1.dst_offset = 0x%x\n", (*ptr).ve[17].ve1.dst_offset);
+   debug_printf("\t\t.ve[17].ve1.vfcomponent3 = 0x%x\n", (*ptr).ve[17].ve1.vfcomponent3);
+   debug_printf("\t\t.ve[17].ve1.vfcomponent2 = 0x%x\n", (*ptr).ve[17].ve1.vfcomponent2);
+   debug_printf("\t\t.ve[17].ve1.vfcomponent1 = 0x%x\n", (*ptr).ve[17].ve1.vfcomponent1);
+   debug_printf("\t\t.ve[17].ve1.vfcomponent0 = 0x%x\n", (*ptr).ve[17].ve1.vfcomponent0);
+}
+
+void
+brw_dump_vertex_element_state(const struct brw_vertex_element_state *ptr)
+{
+   debug_printf("\t\t.ve0.src_offset = 0x%x\n", (*ptr).ve0.src_offset);
+   debug_printf("\t\t.ve0.src_format = 0x%x\n", (*ptr).ve0.src_format);
+   debug_printf("\t\t.ve0.valid = 0x%x\n", (*ptr).ve0.valid);
+   debug_printf("\t\t.ve0.vertex_buffer_index = 0x%x\n", (*ptr).ve0.vertex_buffer_index);
+   debug_printf("\t\t.ve1.dst_offset = 0x%x\n", (*ptr).ve1.dst_offset);
+   debug_printf("\t\t.ve1.vfcomponent3 = 0x%x\n", (*ptr).ve1.vfcomponent3);
+   debug_printf("\t\t.ve1.vfcomponent2 = 0x%x\n", (*ptr).ve1.vfcomponent2);
+   debug_printf("\t\t.ve1.vfcomponent1 = 0x%x\n", (*ptr).ve1.vfcomponent1);
+   debug_printf("\t\t.ve1.vfcomponent0 = 0x%x\n", (*ptr).ve1.vfcomponent0);
+}
+
+void
+brw_dump_vf_statistics(const struct brw_vf_statistics *ptr)
+{
+   debug_printf("\t\t.statistics_enable = 0x%x\n", (*ptr).statistics_enable);
+   debug_printf("\t\t.opcode = 0x%x\n", (*ptr).opcode);
+}
+
+void
+brw_dump_vs_unit_state(const struct brw_vs_unit_state *ptr)
+{
+   debug_printf("\t\t.thread0.grf_reg_count = 0x%x\n", (*ptr).thread0.grf_reg_count);
+   debug_printf("\t\t.thread0.kernel_start_pointer = 0x%x\n", (*ptr).thread0.kernel_start_pointer);
+   debug_printf("\t\t.thread1.ext_halt_exception_enable = 0x%x\n", (*ptr).thread1.ext_halt_exception_enable);
+   debug_printf("\t\t.thread1.sw_exception_enable = 0x%x\n", (*ptr).thread1.sw_exception_enable);
+   debug_printf("\t\t.thread1.mask_stack_exception_enable = 0x%x\n", (*ptr).thread1.mask_stack_exception_enable);
+   debug_printf("\t\t.thread1.timeout_exception_enable = 0x%x\n", (*ptr).thread1.timeout_exception_enable);
+   debug_printf("\t\t.thread1.illegal_op_exception_enable = 0x%x\n", (*ptr).thread1.illegal_op_exception_enable);
+   debug_printf("\t\t.thread1.depth_coef_urb_read_offset = 0x%x\n", (*ptr).thread1.depth_coef_urb_read_offset);
+   debug_printf("\t\t.thread1.floating_point_mode = 0x%x\n", (*ptr).thread1.floating_point_mode);
+   debug_printf("\t\t.thread1.thread_priority = 0x%x\n", (*ptr).thread1.thread_priority);
+   debug_printf("\t\t.thread1.binding_table_entry_count = 0x%x\n", (*ptr).thread1.binding_table_entry_count);
+   debug_printf("\t\t.thread1.single_program_flow = 0x%x\n", (*ptr).thread1.single_program_flow);
+   debug_printf("\t\t.thread2.per_thread_scratch_space = 0x%x\n", (*ptr).thread2.per_thread_scratch_space);
+   debug_printf("\t\t.thread2.scratch_space_base_pointer = 0x%x\n", (*ptr).thread2.scratch_space_base_pointer);
+   debug_printf("\t\t.thread3.dispatch_grf_start_reg = 0x%x\n", (*ptr).thread3.dispatch_grf_start_reg);
+   debug_printf("\t\t.thread3.urb_entry_read_offset = 0x%x\n", (*ptr).thread3.urb_entry_read_offset);
+   debug_printf("\t\t.thread3.urb_entry_read_length = 0x%x\n", (*ptr).thread3.urb_entry_read_length);
+   debug_printf("\t\t.thread3.const_urb_entry_read_offset = 0x%x\n", (*ptr).thread3.const_urb_entry_read_offset);
+   debug_printf("\t\t.thread3.const_urb_entry_read_length = 0x%x\n", (*ptr).thread3.const_urb_entry_read_length);
+   debug_printf("\t\t.thread4.stats_enable = 0x%x\n", (*ptr).thread4.stats_enable);
+   debug_printf("\t\t.thread4.nr_urb_entries = 0x%x\n", (*ptr).thread4.nr_urb_entries);
+   debug_printf("\t\t.thread4.urb_entry_allocation_size = 0x%x\n", (*ptr).thread4.urb_entry_allocation_size);
+   debug_printf("\t\t.thread4.max_threads = 0x%x\n", (*ptr).thread4.max_threads);
+   debug_printf("\t\t.vs5.sampler_count = 0x%x\n", (*ptr).vs5.sampler_count);
+   debug_printf("\t\t.vs5.sampler_state_pointer = 0x%x\n", (*ptr).vs5.sampler_state_pointer);
+   debug_printf("\t\t.vs6.vs_enable = 0x%x\n", (*ptr).vs6.vs_enable);
+   debug_printf("\t\t.vs6.vert_cache_disable = 0x%x\n", (*ptr).vs6.vert_cache_disable);
+}
+
+void
+brw_dump_wm_unit_state(const struct brw_wm_unit_state *ptr)
+{
+   debug_printf("\t\t.thread0.grf_reg_count = 0x%x\n", (*ptr).thread0.grf_reg_count);
+   debug_printf("\t\t.thread0.kernel_start_pointer = 0x%x\n", (*ptr).thread0.kernel_start_pointer);
+   debug_printf("\t\t.thread1.ext_halt_exception_enable = 0x%x\n", (*ptr).thread1.ext_halt_exception_enable);
+   debug_printf("\t\t.thread1.sw_exception_enable = 0x%x\n", (*ptr).thread1.sw_exception_enable);
+   debug_printf("\t\t.thread1.mask_stack_exception_enable = 0x%x\n", (*ptr).thread1.mask_stack_exception_enable);
+   debug_printf("\t\t.thread1.timeout_exception_enable = 0x%x\n", (*ptr).thread1.timeout_exception_enable);
+   debug_printf("\t\t.thread1.illegal_op_exception_enable = 0x%x\n", (*ptr).thread1.illegal_op_exception_enable);
+   debug_printf("\t\t.thread1.depth_coef_urb_read_offset = 0x%x\n", (*ptr).thread1.depth_coef_urb_read_offset);
+   debug_printf("\t\t.thread1.floating_point_mode = 0x%x\n", (*ptr).thread1.floating_point_mode);
+   debug_printf("\t\t.thread1.thread_priority = 0x%x\n", (*ptr).thread1.thread_priority);
+   debug_printf("\t\t.thread1.binding_table_entry_count = 0x%x\n", (*ptr).thread1.binding_table_entry_count);
+   debug_printf("\t\t.thread1.single_program_flow = 0x%x\n", (*ptr).thread1.single_program_flow);
+   debug_printf("\t\t.thread2.per_thread_scratch_space = 0x%x\n", (*ptr).thread2.per_thread_scratch_space);
+   debug_printf("\t\t.thread2.scratch_space_base_pointer = 0x%x\n", (*ptr).thread2.scratch_space_base_pointer);
+   debug_printf("\t\t.thread3.dispatch_grf_start_reg = 0x%x\n", (*ptr).thread3.dispatch_grf_start_reg);
+   debug_printf("\t\t.thread3.urb_entry_read_offset = 0x%x\n", (*ptr).thread3.urb_entry_read_offset);
+   debug_printf("\t\t.thread3.urb_entry_read_length = 0x%x\n", (*ptr).thread3.urb_entry_read_length);
+   debug_printf("\t\t.thread3.const_urb_entry_read_offset = 0x%x\n", (*ptr).thread3.const_urb_entry_read_offset);
+   debug_printf("\t\t.thread3.const_urb_entry_read_length = 0x%x\n", (*ptr).thread3.const_urb_entry_read_length);
+   debug_printf("\t\t.wm4.stats_enable = 0x%x\n", (*ptr).wm4.stats_enable);
+   debug_printf("\t\t.wm4.depth_buffer_clear = 0x%x\n", (*ptr).wm4.depth_buffer_clear);
+   debug_printf("\t\t.wm4.sampler_count = 0x%x\n", (*ptr).wm4.sampler_count);
+   debug_printf("\t\t.wm4.sampler_state_pointer = 0x%x\n", (*ptr).wm4.sampler_state_pointer);
+   debug_printf("\t\t.wm5.enable_8_pix = 0x%x\n", (*ptr).wm5.enable_8_pix);
+   debug_printf("\t\t.wm5.enable_16_pix = 0x%x\n", (*ptr).wm5.enable_16_pix);
+   debug_printf("\t\t.wm5.enable_32_pix = 0x%x\n", (*ptr).wm5.enable_32_pix);
+   debug_printf("\t\t.wm5.enable_con_32_pix = 0x%x\n", (*ptr).wm5.enable_con_32_pix);
+   debug_printf("\t\t.wm5.enable_con_64_pix = 0x%x\n", (*ptr).wm5.enable_con_64_pix);
+   debug_printf("\t\t.wm5.legacy_global_depth_bias = 0x%x\n", (*ptr).wm5.legacy_global_depth_bias);
+   debug_printf("\t\t.wm5.line_stipple = 0x%x\n", (*ptr).wm5.line_stipple);
+   debug_printf("\t\t.wm5.depth_offset = 0x%x\n", (*ptr).wm5.depth_offset);
+   debug_printf("\t\t.wm5.polygon_stipple = 0x%x\n", (*ptr).wm5.polygon_stipple);
+   debug_printf("\t\t.wm5.line_aa_region_width = 0x%x\n", (*ptr).wm5.line_aa_region_width);
+   debug_printf("\t\t.wm5.line_endcap_aa_region_width = 0x%x\n", (*ptr).wm5.line_endcap_aa_region_width);
+   debug_printf("\t\t.wm5.early_depth_test = 0x%x\n", (*ptr).wm5.early_depth_test);
+   debug_printf("\t\t.wm5.thread_dispatch_enable = 0x%x\n", (*ptr).wm5.thread_dispatch_enable);
+   debug_printf("\t\t.wm5.program_uses_depth = 0x%x\n", (*ptr).wm5.program_uses_depth);
+   debug_printf("\t\t.wm5.program_computes_depth = 0x%x\n", (*ptr).wm5.program_computes_depth);
+   debug_printf("\t\t.wm5.program_uses_killpixel = 0x%x\n", (*ptr).wm5.program_uses_killpixel);
+   debug_printf("\t\t.wm5.legacy_line_rast = 0x%x\n", (*ptr).wm5.legacy_line_rast);
+   debug_printf("\t\t.wm5.transposed_urb_read_enable = 0x%x\n", (*ptr).wm5.transposed_urb_read_enable);
+   debug_printf("\t\t.wm5.max_threads = 0x%x\n", (*ptr).wm5.max_threads);
+   debug_printf("\t\t.global_depth_offset_constant = %f\n", (*ptr).global_depth_offset_constant);
+   debug_printf("\t\t.global_depth_offset_scale = %f\n", (*ptr).global_depth_offset_scale);
+   debug_printf("\t\t.wm8.grf_reg_count_1 = 0x%x\n", (*ptr).wm8.grf_reg_count_1);
+   debug_printf("\t\t.wm8.kernel_start_pointer_1 = 0x%x\n", (*ptr).wm8.kernel_start_pointer_1);
+   debug_printf("\t\t.wm9.grf_reg_count_2 = 0x%x\n", (*ptr).wm9.grf_reg_count_2);
+   debug_printf("\t\t.wm9.kernel_start_pointer_2 = 0x%x\n", (*ptr).wm9.kernel_start_pointer_2);
+   debug_printf("\t\t.wm10.grf_reg_count_3 = 0x%x\n", (*ptr).wm10.grf_reg_count_3);
+   debug_printf("\t\t.wm10.kernel_start_pointer_3 = 0x%x\n", (*ptr).wm10.kernel_start_pointer_3);
+}
+
diff --git a/src/gallium/drivers/i965/brw_structs_dump.h b/src/gallium/drivers/i965/brw_structs_dump.h
new file mode 100644 (file)
index 0000000..7c02dbf
--- /dev/null
@@ -0,0 +1,276 @@
+/**************************************************************************
+ *
+ * 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 SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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.
+ *
+ **************************************************************************/
+
+/**
+ * @file
+ * Dump i965 data structures.
+ *
+ * Generated automatically from brw_structs.h by brw_structs_dump.py.
+ */
+
+#ifndef BRW_STRUCTS_DUMP_H
+#define BRW_STRUCTS_DUMP_H
+
+struct brw_3d_control;
+struct brw_3d_primitive;
+struct brw_aa_line_parameters;
+struct brw_binding_table_pointers;
+struct brw_blend_constant_color;
+struct brw_cc0;
+struct brw_cc1;
+struct brw_cc2;
+struct brw_cc3;
+struct brw_cc4;
+struct brw_cc5;
+struct brw_cc6;
+struct brw_cc7;
+struct brw_cc_unit_state;
+struct brw_cc_viewport;
+struct brw_clip_unit_state;
+struct brw_clipper_viewport;
+struct brw_constant_buffer;
+struct brw_cs_urb_state;
+struct brw_depthbuffer;
+struct brw_depthbuffer_g4x;
+struct brw_drawrect;
+struct brw_global_depth_offset_clamp;
+struct brw_gs_unit_state;
+struct brw_indexbuffer;
+struct brw_line_stipple;
+struct brw_mi_flush;
+struct brw_pipe_control;
+struct brw_pipeline_select;
+struct brw_pipelined_state_pointers;
+struct brw_polygon_stipple;
+struct brw_polygon_stipple_offset;
+struct brw_sampler_default_color;
+struct brw_sampler_state;
+struct brw_sf_unit_state;
+struct brw_sf_viewport;
+struct brw_ss0;
+struct brw_ss1;
+struct brw_ss2;
+struct brw_ss3;
+struct brw_state_base_address;
+struct brw_state_prefetch;
+struct brw_surf_ss0;
+struct brw_surf_ss1;
+struct brw_surf_ss2;
+struct brw_surf_ss3;
+struct brw_surf_ss4;
+struct brw_surf_ss5;
+struct brw_surface_state;
+struct brw_system_instruction_pointer;
+struct brw_urb_fence;
+struct brw_urb_immediate;
+struct brw_vb_array_state;
+struct brw_vertex_buffer_state;
+struct brw_vertex_element_packet;
+struct brw_vertex_element_state;
+struct brw_vf_statistics;
+struct brw_vs_unit_state;
+struct brw_wm_unit_state;
+
+void
+brw_dump_3d_control(const struct brw_3d_control *ptr);
+
+void
+brw_dump_3d_primitive(const struct brw_3d_primitive *ptr);
+
+void
+brw_dump_aa_line_parameters(const struct brw_aa_line_parameters *ptr);
+
+void
+brw_dump_binding_table_pointers(const struct brw_binding_table_pointers *ptr);
+
+void
+brw_dump_blend_constant_color(const struct brw_blend_constant_color *ptr);
+
+void
+brw_dump_cc0(const struct brw_cc0 *ptr);
+
+void
+brw_dump_cc1(const struct brw_cc1 *ptr);
+
+void
+brw_dump_cc2(const struct brw_cc2 *ptr);
+
+void
+brw_dump_cc3(const struct brw_cc3 *ptr);
+
+void
+brw_dump_cc4(const struct brw_cc4 *ptr);
+
+void
+brw_dump_cc5(const struct brw_cc5 *ptr);
+
+void
+brw_dump_cc6(const struct brw_cc6 *ptr);
+
+void
+brw_dump_cc7(const struct brw_cc7 *ptr);
+
+void
+brw_dump_cc_unit_state(const struct brw_cc_unit_state *ptr);
+
+void
+brw_dump_cc_viewport(const struct brw_cc_viewport *ptr);
+
+void
+brw_dump_clip_unit_state(const struct brw_clip_unit_state *ptr);
+
+void
+brw_dump_clipper_viewport(const struct brw_clipper_viewport *ptr);
+
+void
+brw_dump_constant_buffer(const struct brw_constant_buffer *ptr);
+
+void
+brw_dump_cs_urb_state(const struct brw_cs_urb_state *ptr);
+
+void
+brw_dump_depthbuffer(const struct brw_depthbuffer *ptr);
+
+void
+brw_dump_depthbuffer_g4x(const struct brw_depthbuffer_g4x *ptr);
+
+void
+brw_dump_drawrect(const struct brw_drawrect *ptr);
+
+void
+brw_dump_global_depth_offset_clamp(const struct brw_global_depth_offset_clamp *ptr);
+
+void
+brw_dump_gs_unit_state(const struct brw_gs_unit_state *ptr);
+
+void
+brw_dump_indexbuffer(const struct brw_indexbuffer *ptr);
+
+void
+brw_dump_line_stipple(const struct brw_line_stipple *ptr);
+
+void
+brw_dump_mi_flush(const struct brw_mi_flush *ptr);
+
+void
+brw_dump_pipe_control(const struct brw_pipe_control *ptr);
+
+void
+brw_dump_pipeline_select(const struct brw_pipeline_select *ptr);
+
+void
+brw_dump_pipelined_state_pointers(const struct brw_pipelined_state_pointers *ptr);
+
+void
+brw_dump_polygon_stipple(const struct brw_polygon_stipple *ptr);
+
+void
+brw_dump_polygon_stipple_offset(const struct brw_polygon_stipple_offset *ptr);
+
+void
+brw_dump_sampler_default_color(const struct brw_sampler_default_color *ptr);
+
+void
+brw_dump_sampler_state(const struct brw_sampler_state *ptr);
+
+void
+brw_dump_sf_unit_state(const struct brw_sf_unit_state *ptr);
+
+void
+brw_dump_sf_viewport(const struct brw_sf_viewport *ptr);
+
+void
+brw_dump_ss0(const struct brw_ss0 *ptr);
+
+void
+brw_dump_ss1(const struct brw_ss1 *ptr);
+
+void
+brw_dump_ss2(const struct brw_ss2 *ptr);
+
+void
+brw_dump_ss3(const struct brw_ss3 *ptr);
+
+void
+brw_dump_state_base_address(const struct brw_state_base_address *ptr);
+
+void
+brw_dump_state_prefetch(const struct brw_state_prefetch *ptr);
+
+void
+brw_dump_surf_ss0(const struct brw_surf_ss0 *ptr);
+
+void
+brw_dump_surf_ss1(const struct brw_surf_ss1 *ptr);
+
+void
+brw_dump_surf_ss2(const struct brw_surf_ss2 *ptr);
+
+void
+brw_dump_surf_ss3(const struct brw_surf_ss3 *ptr);
+
+void
+brw_dump_surf_ss4(const struct brw_surf_ss4 *ptr);
+
+void
+brw_dump_surf_ss5(const struct brw_surf_ss5 *ptr);
+
+void
+brw_dump_surface_state(const struct brw_surface_state *ptr);
+
+void
+brw_dump_system_instruction_pointer(const struct brw_system_instruction_pointer *ptr);
+
+void
+brw_dump_urb_fence(const struct brw_urb_fence *ptr);
+
+void
+brw_dump_urb_immediate(const struct brw_urb_immediate *ptr);
+
+void
+brw_dump_vb_array_state(const struct brw_vb_array_state *ptr);
+
+void
+brw_dump_vertex_buffer_state(const struct brw_vertex_buffer_state *ptr);
+
+void
+brw_dump_vertex_element_packet(const struct brw_vertex_element_packet *ptr);
+
+void
+brw_dump_vertex_element_state(const struct brw_vertex_element_state *ptr);
+
+void
+brw_dump_vf_statistics(const struct brw_vf_statistics *ptr);
+
+void
+brw_dump_vs_unit_state(const struct brw_vs_unit_state *ptr);
+
+void
+brw_dump_wm_unit_state(const struct brw_wm_unit_state *ptr);
+
+
+#endif /* BRW_STRUCTS_DUMP_H */
diff --git a/src/gallium/drivers/i965/brw_structs_dump.py b/src/gallium/drivers/i965/brw_structs_dump.py
new file mode 100755 (executable)
index 0000000..6dba49a
--- /dev/null
@@ -0,0 +1,291 @@
+#!/usr/bin/env python
+'''
+Generates dumpers for the i965 state strucutures using pygccxml.
+
+Run as 
+
+  PYTHONPATH=/path/to/pygccxml-1.0.0 python brw_structs_dump.py
+
+Jose Fonseca <jfonseca@vmware.com>
+'''
+
+copyright = '''
+/**************************************************************************
+ *
+ * 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 SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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.
+ *
+ **************************************************************************/
+ '''
+
+import os
+import sys
+import re
+
+from pygccxml import parser
+from pygccxml import declarations
+
+from pygccxml.declarations import algorithm
+from pygccxml.declarations import decl_visitor
+from pygccxml.declarations import type_traits
+from pygccxml.declarations import type_visitor
+
+
+enums = True
+
+
+def vars_filter(variable):
+    name = variable.name
+    return not re.match('^pad\d*', name) and name != 'dword' 
+
+
+class decl_dumper_t(decl_visitor.decl_visitor_t):
+
+    def __init__(self, stream, instance = '', decl = None):
+        decl_visitor.decl_visitor_t.__init__(self)
+        self.stream = stream
+        self._instance = instance
+        self.decl = decl
+
+    def clone(self):
+        return decl_dumper_t(self.stream, self._instance, self.decl)
+
+    def visit_class(self):
+        class_ = self.decl
+        assert self.decl.class_type in ('struct', 'union')
+
+        for variable in class_.variables(recursive = False):
+            if vars_filter(variable):
+                dump_type(self.stream, self._instance + '.' + variable.name, variable.type)
+
+    def visit_enumeration(self):
+        if enums:
+            self.stream.write('   switch(%s) {\n' % ("(*ptr)" + self._instance,))
+            for name, value in self.decl.values:
+                self.stream.write('   case %s:\n' % (name,))
+                self.stream.write('      debug_printf("\\t\\t%s = %s\\n");\n' % (self._instance, name))
+                self.stream.write('      break;\n')
+            self.stream.write('   default:\n')
+            self.stream.write('      debug_printf("\\t\\t%s = %%i\\n", %s);\n' % (self._instance, "(*ptr)" + self._instance))
+            self.stream.write('      break;\n')
+            self.stream.write('   }\n')
+        else:
+            self.stream.write('   debug_printf("\\t\\t%s = %%i\\n", %s);\n' % (self._instance, "(*ptr)" + self._instance))
+
+
+def dump_decl(stream, instance, decl):
+    dumper = decl_dumper_t(stream, instance, decl)
+    algorithm.apply_visitor(dumper, decl)
+
+
+class type_dumper_t(type_visitor.type_visitor_t):
+
+    def __init__(self, stream, instance, type_):
+        type_visitor.type_visitor_t.__init__(self)
+        self.stream = stream
+        self.instance = instance
+        self.type = type_
+
+    def clone(self):
+        return type_dumper_t(self.instance, self.type)
+
+    def visit_bool(self):
+        self.print_instance('%i')
+        
+    def visit_char(self):
+        #self.print_instance('%i')
+        self.print_instance('0x%x')
+        
+    def visit_unsigned_char(self):
+        #self.print_instance('%u')
+        self.print_instance('0x%x')
+
+    def visit_signed_char(self):
+        #self.print_instance('%i')
+        self.print_instance('0x%x')
+    
+    def visit_wchar(self):
+        self.print_instance('0x%x')
+        
+    def visit_short_int(self):
+        #self.print_instance('%i')
+        self.print_instance('0x%x')
+        
+    def visit_short_unsigned_int(self):
+        #self.print_instance('%u')
+        self.print_instance('0x%x')
+        
+    def visit_int(self):
+        #self.print_instance('%i')
+        self.print_instance('0x%x')
+        
+    def visit_unsigned_int(self):
+        #self.print_instance('%u')
+        self.print_instance('0x%x')
+        
+    def visit_long_int(self):
+        #self.print_instance('%li')
+        self.print_instance('0x%lx')
+        
+    def visit_long_unsigned_int(self):
+        #self.print_instance('%lu')
+        self.print_instance('%0xlx')
+        
+    def visit_long_long_int(self):
+        #self.print_instance('%lli')
+        self.print_instance('%0xllx')
+        
+    def visit_long_long_unsigned_int(self):
+        #self.print_instance('%llu')
+        self.print_instance('0x%llx')
+        
+    def visit_float(self):
+        self.print_instance('%f')
+        
+    def visit_double(self):
+        self.print_instance('%f')
+        
+    def visit_array(self):
+        for i in range(type_traits.array_size(self.type)):
+            dump_type(self.stream, self.instance + '[%i]' % i, type_traits.base_type(self.type))
+
+    def visit_pointer(self):
+        self.print_instance('%p')
+
+    def visit_declarated(self):
+        #stream.write('decl = %r\n' % self.type.decl_string)
+        decl = type_traits.remove_declarated(self.type)
+        dump_decl(self.stream, self.instance, decl)
+
+    def print_instance(self, format):
+        self.stream.write('   debug_printf("\\t\\t%s = %s\\n", %s);\n' % (self.instance, format, "(*ptr)" + self.instance))
+
+
+
+def dump_type(stream, instance, type_):
+    type_ = type_traits.remove_alias(type_)
+    visitor = type_dumper_t(stream, instance, type_)
+    algorithm.apply_visitor(visitor, type_)
+
+
+def dump_struct_interface(stream, class_, suffix = ';'):
+    name = class_.name
+    assert name.startswith('brw_');
+    name = name[:4] + 'dump_' + name[4:]
+    stream.write('void\n')
+    stream.write('%s(const struct %s *ptr)%s\n' % (name, class_.name, suffix))
+
+
+def dump_struct_implementation(stream, decls, class_):
+    dump_struct_interface(stream, class_, suffix = '')
+    stream.write('{\n')
+    dump_decl(stream, '', class_)
+    stream.write('}\n')
+    stream.write('\n')
+
+
+def dump_header(stream):
+    stream.write(copyright.strip() + '\n')
+    stream.write('\n')
+    stream.write('/**\n')
+    stream.write(' * @file\n')
+    stream.write(' * Dump i965 data structures.\n')
+    stream.write(' *\n')
+    stream.write(' * Generated automatically from brw_structs.h by brw_structs_dump.py.\n')
+    stream.write(' */\n')
+    stream.write('\n')
+
+
+def dump_interfaces(decls, global_ns, names):
+    stream = open('brw_structs_dump.h', 'wt')
+    
+    dump_header(stream)
+    
+    stream.write('#ifndef BRW_STRUCTS_DUMP_H\n')
+    stream.write('#define BRW_STRUCTS_DUMP_H\n')
+    stream.write('\n')
+    
+    for name in names:
+        stream.write('struct %s;\n' % (name,))
+    stream.write('\n')
+
+    for name in names:
+        (class_,) = global_ns.classes(name = name)
+        dump_struct_interface(stream, class_)
+        stream.write('\n')
+    stream.write('\n')
+
+    stream.write('#endif /* BRW_STRUCTS_DUMP_H */\n')
+
+
+def dump_implementations(decls, global_ns, names):
+    stream = open('brw_structs_dump.c', 'wt')
+    
+    dump_header(stream)
+
+    stream.write('#include "util/u_debug.h"\n')
+    stream.write('\n')
+    stream.write('#include "brw_types.h"\n')
+    stream.write('#include "brw_structs.h"\n')
+    stream.write('#include "brw_structs_dump.h"\n')
+    stream.write('\n')
+
+    for name in names:
+        (class_,) = global_ns.classes(name = name)
+        dump_struct_implementation(stream, decls, class_)
+
+
+def decl_filter(decl):
+    '''Filter the declarations we're interested in'''
+    name = decl.name
+    return name.startswith('brw_') and name not in ('brw_instruction',) 
+
+
+def main():
+
+    config = parser.config_t(
+        include_paths = [
+            '../../include',
+        ],
+        compiler = 'gcc',
+    )
+
+    headers = [
+        'brw_types.h', 
+        'brw_structs.h', 
+    ]
+
+    decls = parser.parse(headers, config, parser.COMPILATION_MODE.ALL_AT_ONCE)
+    global_ns = declarations.get_global_namespace(decls)
+
+    names = []
+    for class_ in global_ns.classes(decl_filter):
+        names.append(class_.name)
+    names.sort()
+
+    dump_interfaces(decls, global_ns, names)
+    dump_implementations(decls, global_ns, names)
+
+
+if __name__ == '__main__':
+    main()
diff --git a/src/gallium/drivers/i965/brw_swtnl.c b/src/gallium/drivers/i965/brw_swtnl.c
new file mode 100644 (file)
index 0000000..464013e
--- /dev/null
@@ -0,0 +1,95 @@
+
+#include "brw_context.h"
+#include "brw_pipe_rast.h"
+
+
+static GLboolean need_swtnl( struct brw_context *brw )
+{
+   const struct pipe_rasterizer_state *rast = &brw->curr.rast->templ;
+
+   /* If we don't require strict OpenGL conformance, never 
+    * use fallbacks.  If we're forcing fallbacks, always
+    * use fallfacks.
+    */
+   if (brw->flags.no_swtnl)
+      return FALSE;
+
+   if (brw->flags.force_swtnl)
+      return TRUE;
+
+   /* Exceeding hw limits on number of VS inputs?
+    */
+   if (brw->curr.num_vertex_elements == 0 ||
+       brw->curr.num_vertex_elements >= BRW_VEP_MAX) {
+      return TRUE;
+   }
+
+   /* Position array with zero stride?
+    *
+    * XXX: position isn't always at zero...
+    * XXX: eliminate zero-stride arrays
+    */
+   {
+      int ve0_vb = brw->curr.vertex_element[0].vertex_buffer_index;
+      
+      if (brw->curr.vertex_buffer[ve0_vb].stride == 0)
+        return TRUE;
+   }
+
+   /* XXX: short-circuit
+    */
+   return FALSE;
+
+   if (brw->reduced_primitive == PIPE_PRIM_TRIANGLES) {
+      if (rast->poly_smooth)
+        return TRUE;
+
+   }
+   
+   if (brw->reduced_primitive == PIPE_PRIM_LINES ||
+       (brw->reduced_primitive == PIPE_PRIM_TRIANGLES &&
+       (rast->fill_cw == PIPE_POLYGON_MODE_LINE ||
+        rast->fill_ccw == PIPE_POLYGON_MODE_LINE)))
+   {
+      /* BRW hardware will do AA lines, but they are non-conformant it
+       * seems.  TBD whether we keep this fallback:
+       */
+      if (rast->line_smooth)
+        return TRUE;
+
+      /* XXX: was a fallback in mesa (gs doesn't get enough
+       * information to know when to reset stipple counter), but there
+       * must be a way around it.
+       */
+      if (rast->line_stipple_enable &&
+         (brw->reduced_primitive == PIPE_PRIM_TRIANGLES ||
+          brw->primitive == PIPE_PRIM_LINE_LOOP || 
+          brw->primitive == PIPE_PRIM_LINE_STRIP))
+        return TRUE;
+   }
+
+   
+   if (brw->reduced_primitive == PIPE_PRIM_POINTS ||
+       (brw->reduced_primitive == PIPE_PRIM_TRIANGLES &&
+       (rast->fill_cw == PIPE_POLYGON_MODE_POINT ||
+        rast->fill_ccw == PIPE_POLYGON_MODE_POINT)))
+   {
+      if (rast->point_smooth)
+        return TRUE;
+   }
+
+   /* BRW hardware doesn't handle CLAMP texturing correctly;
+    * brw_wm_sampler_state:translate_wrap_mode() treats CLAMP
+    * as CLAMP_TO_EDGE instead.  If we're using CLAMP, and
+    * we want strict conformance, force the fallback.
+    *
+    * XXX: need a workaround for this.
+    */
+      
+   /* Nothing stopping us from the fast path now */
+   return FALSE;
+}
+
+
+
+
diff --git a/src/gallium/drivers/i965/brw_types.h b/src/gallium/drivers/i965/brw_types.h
new file mode 100644 (file)
index 0000000..89e08a5
--- /dev/null
@@ -0,0 +1,21 @@
+#ifndef BRW_TYPES_H
+#define BRW_TYPES_H
+
+#include "pipe/p_compiler.h"
+
+typedef uint32_t GLuint;
+typedef uint8_t GLubyte;
+typedef uint16_t GLushort;
+typedef int32_t GLint;
+typedef int8_t GLbyte;
+typedef int16_t GLshort;
+typedef float GLfloat;
+
+/* no GLenum, translate all away */
+
+typedef uint8_t GLboolean;
+
+#define GL_FALSE FALSE
+#define GL_TRUE TRUE
+
+#endif
diff --git a/src/gallium/drivers/i965/brw_urb.c b/src/gallium/drivers/i965/brw_urb.c
new file mode 100644 (file)
index 0000000..907ec56
--- /dev/null
@@ -0,0 +1,263 @@
+/*
+ Copyright (C) Intel Corp.  2006.  All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ **********************************************************************/
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  */
+        
+
+
+#include "brw_batchbuffer.h"
+#include "brw_context.h"
+#include "brw_state.h"
+#include "brw_defines.h"
+#include "brw_debug.h"
+
+#define VS 0
+#define GS 1
+#define CLP 2
+#define SF 3
+#define CS 4
+
+/** @file brw_urb.c
+ *
+ * Manages the division of the URB space between the various fixed-function
+ * units.
+ *
+ * See the Thread Initiation Management section of the GEN4 B-Spec, and
+ * the individual *_STATE structures for restrictions on numbers of
+ * entries and threads.
+ */
+
+/*
+ * Generally, a unit requires a min_nr_entries based on how many entries
+ * it produces before the downstream unit gets unblocked and can use and
+ * dereference some of its handles.
+ *
+ * The SF unit preallocates a PUE at the start of thread dispatch, and only
+ * uses that one.  So it requires one entry per thread.
+ *
+ * For CLIP, the SF unit will hold the previous primitive while the
+ * next is getting assembled, meaning that linestrips require 3 CLIP VUEs
+ * (vertices) to ensure continued processing, trifans require 4, and tristrips
+ * require 5.  There can be 1 or 2 threads, and each has the same requirement.
+ *
+ * GS has the same requirement as CLIP, but it never handles tristrips,
+ * so we can lower the minimum to 4 for the POLYGONs (trifans) it produces.
+ * We only run it single-threaded.
+ *
+ * For VS, the number of entries may be 8, 12, 16, or 32 (or 64 on G4X).
+ * Each thread processes 2 preallocated VUEs (vertices) at a time, and they
+ * get streamed down as soon as threads processing earlier vertices get
+ * theirs accepted.
+ *
+ * Each unit will take the number of URB entries we give it (based on the
+ * entry size calculated in brw_vs_emit.c for VUEs, brw_sf_emit.c for PUEs,
+ * and brw_curbe.c for the CURBEs) and decide its maximum number of
+ * threads it can support based on that. in brw_*_state.c.
+ *
+ * XXX: Are the min_entry_size numbers useful?
+ * XXX: Verify min_nr_entries, esp for VS.
+ * XXX: Verify SF min_entry_size.
+ */
+static const struct urb_limits {
+   GLuint min_nr_entries;
+   GLuint preferred_nr_entries;
+   GLuint min_entry_size;
+   GLuint max_entry_size;
+} limits[CS+1] = {
+   { 16, 32, 1, 5 },                   /* vs */
+   { 4, 8,  1, 5 },                    /* gs */
+   { 5, 10,  1, 5 },                   /* clp */
+   { 1, 8,  1, 12 },                   /* sf */
+   { 1, 4,  1, 32 }                    /* cs */
+};
+
+
+static GLboolean check_urb_layout( struct brw_context *brw )
+{
+   brw->urb.vs_start = 0;
+   brw->urb.gs_start = brw->urb.nr_vs_entries * brw->urb.vsize;
+   brw->urb.clip_start = brw->urb.gs_start + brw->urb.nr_gs_entries * brw->urb.vsize;
+   brw->urb.sf_start = brw->urb.clip_start + brw->urb.nr_clip_entries * brw->urb.vsize;
+   brw->urb.cs_start = brw->urb.sf_start + brw->urb.nr_sf_entries * brw->urb.sfsize;
+
+   return brw->urb.cs_start + brw->urb.nr_cs_entries * brw->urb.csize <= URB_SIZES(brw);
+}
+
+/* Most minimal update, forces re-emit of URB fence packet after GS
+ * unit turned on/off.
+ */
+static int recalculate_urb_fence( struct brw_context *brw )
+{
+   GLuint csize = brw->curbe.total_size;
+   GLuint vsize = brw->vs.prog_data->urb_entry_size;
+   GLuint sfsize = brw->sf.prog_data->urb_entry_size;
+
+   if (csize < limits[CS].min_entry_size)
+      csize = limits[CS].min_entry_size;
+
+   if (vsize < limits[VS].min_entry_size)
+      vsize = limits[VS].min_entry_size;
+
+   if (sfsize < limits[SF].min_entry_size)
+      sfsize = limits[SF].min_entry_size;
+
+   if (brw->urb.vsize < vsize ||
+       brw->urb.sfsize < sfsize ||
+       brw->urb.csize < csize ||
+       (brw->urb.constrained && (brw->urb.vsize > vsize ||
+                                brw->urb.sfsize > sfsize ||
+                                brw->urb.csize > csize))) {
+      
+
+      brw->urb.csize = csize;
+      brw->urb.sfsize = sfsize;
+      brw->urb.vsize = vsize;
+
+      brw->urb.nr_vs_entries = limits[VS].preferred_nr_entries;        
+      brw->urb.nr_gs_entries = limits[GS].preferred_nr_entries;        
+      brw->urb.nr_clip_entries = limits[CLP].preferred_nr_entries;
+      brw->urb.nr_sf_entries = limits[SF].preferred_nr_entries;        
+      brw->urb.nr_cs_entries = limits[CS].preferred_nr_entries;        
+
+      brw->urb.constrained = 0;
+
+      if (BRW_IS_IGDNG(brw)) {
+         brw->urb.nr_vs_entries = 128;
+         brw->urb.nr_sf_entries = 48;
+         if (check_urb_layout(brw)) {
+            goto done;
+         } else {
+            brw->urb.constrained = 1;
+            brw->urb.nr_vs_entries = limits[VS].preferred_nr_entries;
+            brw->urb.nr_sf_entries = limits[SF].preferred_nr_entries;
+         }
+      } else if (BRW_IS_G4X(brw)) {
+        brw->urb.nr_vs_entries = 64;
+        if (check_urb_layout(brw)) {
+           goto done;
+        } else {
+           brw->urb.constrained = 1;
+           brw->urb.nr_vs_entries = limits[VS].preferred_nr_entries;
+        }
+      }
+
+      if (BRW_DEBUG & DEBUG_MIN_URB) {
+        brw->urb.nr_vs_entries = limits[VS].min_nr_entries;    
+        brw->urb.nr_gs_entries = limits[GS].min_nr_entries;    
+        brw->urb.nr_clip_entries = limits[CLP].min_nr_entries;
+        brw->urb.nr_sf_entries = limits[SF].min_nr_entries;    
+        brw->urb.nr_cs_entries = limits[CS].min_nr_entries;    
+        brw->urb.constrained = 1;
+      }
+
+      if (!check_urb_layout(brw)) {
+        brw->urb.nr_vs_entries = limits[VS].min_nr_entries;    
+        brw->urb.nr_gs_entries = limits[GS].min_nr_entries;    
+        brw->urb.nr_clip_entries = limits[CLP].min_nr_entries;
+        brw->urb.nr_sf_entries = limits[SF].min_nr_entries;    
+        brw->urb.nr_cs_entries = limits[CS].min_nr_entries;    
+
+        /* Mark us as operating with constrained nr_entries, so that next
+         * time we recalculate we'll resize the fences in the hope of
+         * escaping constrained mode and getting back to normal performance.
+         */
+        brw->urb.constrained = 1;
+        
+        if (!check_urb_layout(brw)) {
+           /* This is impossible, given the maximal sizes of urb
+            * entries and the values for minimum nr of entries
+            * provided above.
+            */
+           debug_printf("couldn't calculate URB layout!\n");
+           exit(1);
+        }
+        
+        if (BRW_DEBUG & (DEBUG_URB|DEBUG_FALLBACKS))
+           debug_printf("URB CONSTRAINED\n");
+      }
+
+done:
+      if (BRW_DEBUG & DEBUG_URB)
+        debug_printf("URB fence: %d ..VS.. %d ..GS.. %d ..CLP.. %d ..SF.. %d ..CS.. %d\n",
+                     brw->urb.vs_start,
+                     brw->urb.gs_start,
+                     brw->urb.clip_start,
+                     brw->urb.sf_start,
+                     brw->urb.cs_start, 
+                     URB_SIZES(brw));
+      
+      brw->state.dirty.brw |= BRW_NEW_URB_FENCE;
+   }
+
+   return 0;
+}
+
+
+const struct brw_tracked_state brw_recalculate_urb_fence = {
+   .dirty = {
+      .mesa = 0,
+      .brw = BRW_NEW_CURBE_OFFSETS,
+      .cache = (CACHE_NEW_VS_PROG |
+               CACHE_NEW_SF_PROG)
+   },
+   .prepare = recalculate_urb_fence
+};
+
+
+
+
+
+int brw_upload_urb_fence(struct brw_context *brw)
+{
+   struct brw_urb_fence uf;
+   memset(&uf, 0, sizeof(uf));
+
+   uf.header.opcode = CMD_URB_FENCE;
+   uf.header.length = sizeof(uf)/4-2;
+   uf.header.vs_realloc = 1;
+   uf.header.gs_realloc = 1;
+   uf.header.clp_realloc = 1;
+   uf.header.sf_realloc = 1;
+   uf.header.vfe_realloc = 1;
+   uf.header.cs_realloc = 1;
+
+   /* The ordering below is correct, not the layout in the
+    * instruction.
+    *
+    * There are 256/384 urb reg pairs in total.
+    */
+   uf.bits0.vs_fence  = brw->urb.gs_start;
+   uf.bits0.gs_fence  = brw->urb.clip_start; 
+   uf.bits0.clp_fence = brw->urb.sf_start; 
+   uf.bits1.sf_fence  = brw->urb.cs_start; 
+   uf.bits1.cs_fence  = URB_SIZES(brw);
+
+   BRW_BATCH_STRUCT(brw, &uf);
+   return 0;
+}
diff --git a/src/gallium/drivers/i965/brw_util.c b/src/gallium/drivers/i965/brw_util.c
new file mode 100644 (file)
index 0000000..458058d
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ Copyright (C) Intel Corp.  2006.  All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ **********************************************************************/
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  */
+         
+
+#include "brw_util.h"
+#include "brw_defines.h"
+
+
+
+
diff --git a/src/gallium/drivers/i965/brw_util.h b/src/gallium/drivers/i965/brw_util.h
new file mode 100644 (file)
index 0000000..b5f9a36
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ Copyright (C) Intel Corp.  2006.  All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ **********************************************************************/
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  */
+          
+
+#ifndef BRW_UTIL_H
+#define BRW_UTIL_H
+
+#include "brw_types.h"
+
+extern GLuint brw_count_bits( GLuint val );
+extern GLuint brw_translate_blend_factor( unsigned factor );
+extern GLuint brw_translate_blend_equation( unsigned mode );
+
+
+
+#endif
diff --git a/src/gallium/drivers/i965/brw_vs.c b/src/gallium/drivers/i965/brw_vs.c
new file mode 100644 (file)
index 0000000..e3ea5a3
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+ 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 "tgsi/tgsi_dump.h"           
+
+#include "brw_context.h"
+#include "brw_vs.h"
+#include "brw_util.h"
+#include "brw_state.h"
+#include "brw_pipe_rast.h"
+
+
+
+static enum pipe_error do_vs_prog( struct brw_context *brw, 
+                                   struct brw_vertex_shader *vp,
+                                   struct brw_vs_prog_key *key,
+                                   struct brw_winsys_buffer **bo_out)
+{
+   enum pipe_error ret;
+   GLuint program_size;
+   const GLuint *program;
+   struct brw_vs_compile c;
+
+   memset(&c, 0, sizeof(c));
+   memcpy(&c.key, key, sizeof(*key));
+
+   brw_init_compile(brw, &c.func);
+   c.vp = vp;
+
+   c.prog_data.nr_outputs = vp->info.num_outputs;
+   c.prog_data.nr_inputs = vp->info.num_inputs;
+
+   if (1)
+      tgsi_dump(c.vp->tokens, 0);
+
+   /* Emit GEN4 code.
+    */
+   brw_vs_emit(&c);
+
+   /* get the program
+    */
+   ret = brw_get_program(&c.func, &program, &program_size);
+   if (ret)
+      return ret;
+
+   ret = brw_upload_cache( &brw->cache, BRW_VS_PROG,
+                           &c.key, brw_vs_prog_key_size(&c.key),
+                           NULL, 0,
+                           program, program_size,
+                           &c.prog_data,
+                           &brw->vs.prog_data,
+                           bo_out);
+   if (ret)
+      return ret;
+
+   return PIPE_OK;
+}
+
+
+static enum pipe_error brw_upload_vs_prog(struct brw_context *brw)
+{
+   struct brw_vs_prog_key key;
+   struct brw_vertex_shader *vp = brw->curr.vertex_shader;
+   struct brw_fs_signature *sig = &brw->curr.fragment_shader->signature;
+   enum pipe_error ret;
+
+   memset(&key, 0, sizeof(key));
+
+   key.program_string_id = vp->id;
+   key.nr_userclip = brw->curr.ucp.nr;
+
+   memcpy(&key.fs_signature, sig, brw_fs_signature_size(sig));
+
+
+   /* Make an early check for the key.
+    */
+   if (brw_search_cache(&brw->cache, BRW_VS_PROG,
+                        &key, brw_vs_prog_key_size(&key),
+                        NULL, 0,
+                        &brw->vs.prog_data,
+                        &brw->vs.prog_bo))
+      return PIPE_OK;
+
+   ret = do_vs_prog(brw, vp, &key, &brw->vs.prog_bo);
+   if (ret)
+      return ret;
+
+   return PIPE_OK;
+}
+
+
+/* See brw_vs.c:
+ */
+const struct brw_tracked_state brw_vs_prog = {
+   .dirty = {
+      .mesa  = (PIPE_NEW_CLIP | 
+                PIPE_NEW_RAST |
+                PIPE_NEW_FRAGMENT_SIGNATURE),
+      .brw   = BRW_NEW_VERTEX_PROGRAM,
+      .cache = 0
+   },
+   .prepare = brw_upload_vs_prog
+};
diff --git a/src/gallium/drivers/i965/brw_vs.h b/src/gallium/drivers/i965/brw_vs.h
new file mode 100644 (file)
index 0000000..944d88c
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ Copyright (C) Intel Corp.  2006.  All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ **********************************************************************/
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  */
+            
+
+#ifndef BRW_VS_H
+#define BRW_VS_H
+
+
+#include "brw_context.h"
+#include "brw_eu.h"
+
+
+struct brw_vs_prog_key {
+   GLuint program_string_id;
+   GLuint nr_userclip:4;
+   GLuint pad:26;
+   struct brw_fs_signature fs_signature;
+};
+
+#define brw_vs_prog_key_size(s) (offsetof(struct brw_vs_prog_key, fs_signature) + \
+                                 brw_fs_signature_size(&(s)->fs_signature))
+
+
+#define MAX_IF_DEPTH 32
+#define MAX_LOOP_DEPTH 32
+
+struct brw_vs_compile {
+   struct brw_compile func;
+   struct brw_vs_prog_key key;
+   struct brw_vs_prog_data prog_data;
+   struct brw_chipset chipset;
+
+   struct brw_vertex_shader *vp;
+
+   GLuint nr_inputs;
+   GLuint nr_outputs;
+   GLuint nr_immediates;
+   GLfloat immediate[128][4];
+
+   GLuint overflow_grf_start;
+   GLuint overflow_count;
+
+   GLuint first_tmp;
+   GLuint last_tmp;
+
+   struct brw_reg r0;
+   struct brw_reg r1;
+   struct brw_reg regs[TGSI_FILE_COUNT][128];
+   struct brw_reg tmp;
+   struct brw_reg stack;
+
+   struct {    
+       GLboolean used_in_src;
+       struct brw_reg reg;
+   } output_regs[128];
+
+   struct brw_reg userplane[6];
+
+   /** we may need up to 3 constants per instruction (if use_const_buffer) */
+   struct {
+      GLint index;
+      struct brw_reg reg;
+   } current_const[3];
+
+   struct brw_instruction *if_inst[MAX_IF_DEPTH];
+   struct brw_instruction *loop_inst[MAX_LOOP_DEPTH];
+   GLuint insn;
+   GLuint if_depth;
+   GLuint loop_depth;
+   GLuint end_offset;
+
+   struct brw_indirect stack_index;
+};
+
+
+void brw_vs_emit( struct brw_vs_compile *c );
+
+#endif
diff --git a/src/gallium/drivers/i965/brw_vs_emit.c b/src/gallium/drivers/i965/brw_vs_emit.c
new file mode 100644 (file)
index 0000000..8a16205
--- /dev/null
@@ -0,0 +1,1654 @@
+/*
+ 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 "pipe/p_shader_tokens.h"
+            
+#include "util/u_memory.h"
+#include "util/u_math.h"
+
+#include "tgsi/tgsi_parse.h"
+#include "tgsi/tgsi_dump.h"
+#include "tgsi/tgsi_info.h"
+
+#include "brw_context.h"
+#include "brw_vs.h"
+#include "brw_debug.h"
+#include "brw_disasm.h"
+
+/* Choose one of the 4 vec4's which can be packed into each 16-wide reg.
+ */
+static INLINE struct brw_reg brw_vec4_grf_repeat( GLuint reg, GLuint slot )
+{
+   int nr = reg + slot/2;
+   int subnr = (slot%2) * 4;
+
+   return stride(brw_vec4_grf(nr, subnr), 0, 4, 1);
+}
+
+
+static struct brw_reg get_tmp( struct brw_vs_compile *c )
+{
+   struct brw_reg tmp = brw_vec8_grf(c->last_tmp, 0);
+
+   if (++c->last_tmp > c->prog_data.total_grf)
+      c->prog_data.total_grf = c->last_tmp;
+
+   return tmp;
+}
+
+static void release_tmp( struct brw_vs_compile *c, struct brw_reg tmp )
+{
+   if (tmp.nr == c->last_tmp-1)
+      c->last_tmp--;
+}
+                              
+static void release_tmps( struct brw_vs_compile *c )
+{
+   c->last_tmp = c->first_tmp;
+}
+
+
+static boolean is_position_output( struct brw_vs_compile *c,
+                                   unsigned vs_output )
+{
+   const struct brw_vertex_shader *vs = c->vp;
+   unsigned semantic = vs->info.output_semantic_name[vs_output];
+   unsigned index = vs->info.output_semantic_index[vs_output];
+      
+   return (semantic == TGSI_SEMANTIC_POSITION &&
+           index == 0);
+}
+
+
+static boolean find_output_slot( struct brw_vs_compile *c,
+                                  unsigned vs_output,
+                                  unsigned *fs_input_slot )
+{
+   const struct brw_vertex_shader *vs = c->vp;
+   unsigned semantic = vs->info.output_semantic_name[vs_output];
+   unsigned index = vs->info.output_semantic_index[vs_output];
+   unsigned i;
+
+   for (i = 0; i < c->key.fs_signature.nr_inputs; i++) {
+      if (c->key.fs_signature.input[i].semantic == semantic &&
+          c->key.fs_signature.input[i].semantic_index == index) {
+         *fs_input_slot = i;
+         return TRUE;
+      }
+   }
+
+   return FALSE;
+}
+
+
+/**
+ * Preallocate GRF register before code emit.
+ * Do things as simply as possible.  Allocate and populate all regs
+ * ahead of time.
+ */
+static void brw_vs_alloc_regs( struct brw_vs_compile *c )
+{
+   GLuint i, reg = 0, subreg = 0, mrf;
+   int attributes_in_vue;
+
+   /* 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->info.file_max[TGSI_FILE_CONSTANT] + 1 +
+       c->vp->info.file_max[TGSI_FILE_IMMEDIATE] + 1 +
+       c->vp->info.file_max[TGSI_FILE_TEMPORARY] + 1 + 21 > BRW_MAX_GRF)
+      c->vp->use_const_buffer = GL_TRUE;
+   else {
+      /* XXX: immediates can go elsewhere if necessary:
+       */
+      assert(c->vp->info.file_max[TGSI_FILE_IMMEDIATE] + 1 +
+            c->vp->info.file_max[TGSI_FILE_TEMPORARY] + 1 + 21 <= BRW_MAX_GRF);
+
+      c->vp->use_const_buffer = GL_FALSE;
+   }
+
+   /*printf("use_const_buffer = %d\n", c->vp->use_const_buffer);*/
+
+   /* r0 -- reserved as usual
+    */
+   c->r0 = brw_vec8_grf(reg, 0);
+   reg++;
+
+   /* User clip planes from curbe: 
+    */
+   if (c->key.nr_userclip) {
+      /* Skip over fixed planes:  Or never read them into vs unit?
+       */
+      subreg += 6;
+
+      for (i = 0; i < c->key.nr_userclip; i++, subreg++) {
+        c->userplane[i] = 
+            stride( brw_vec4_grf(reg+subreg/2, (subreg%2) * 4), 0, 4, 1);
+      }     
+
+      /* Deal with curbe alignment:
+       */
+      subreg = align(subreg, 2);
+      /*reg += ((6 + c->key.nr_userclip + 3) / 4) * 2;*/
+   }
+
+
+   /* Immediates: always in the curbe.
+    *
+    * XXX: Can try to encode some immediates as brw immediates
+    * XXX: Make sure ureg sets minimal immediate size and respect it
+    * here.
+    */
+   for (i = 0; i < c->vp->info.immediate_count; i++, subreg++) {
+      c->regs[TGSI_FILE_IMMEDIATE][i] = 
+         stride( brw_vec4_grf(reg+subreg/2, (subreg%2) * 4), 0, 4, 1);
+   }
+   c->prog_data.nr_params = c->vp->info.immediate_count * 4;
+
+
+   /* Vertex constant buffer.
+    *
+    * Constants from the buffer can be either cached in the curbe or
+    * loaded as needed from the actual constant buffer.
+    */
+   if (!c->vp->use_const_buffer) {
+      GLuint nr_params = c->vp->info.file_max[TGSI_FILE_CONSTANT] + 1;
+
+      for (i = 0; i < nr_params; i++, subreg++) {
+         c->regs[TGSI_FILE_CONSTANT][i] =
+            stride( brw_vec4_grf(reg+subreg/2, (subreg%2) * 4), 0, 4, 1);
+      }
+
+      c->prog_data.nr_params += nr_params * 4;
+   }
+
+   /* All regs allocated
+    */
+   reg += (subreg + 1) / 2;
+   c->prog_data.curb_read_length = reg - 1;
+
+
+   /* Allocate input regs:  
+    */
+   c->nr_inputs = c->vp->info.num_inputs;
+   for (i = 0; i < c->nr_inputs; i++) {
+      c->regs[TGSI_FILE_INPUT][i] = brw_vec8_grf(reg, 0);
+      reg++;
+   }
+
+   /* If there are no inputs, we'll still be reading one attribute's worth
+    * because it's required -- see urb_read_length setting.
+    */
+   if (c->nr_inputs == 0)
+      reg++;
+
+
+
+   /* Allocate outputs.  The non-position outputs go straight into message regs.
+    */
+   c->nr_outputs = c->prog_data.nr_outputs;
+
+   if (c->chipset.is_igdng)
+      mrf = 8;
+   else
+      mrf = 4;
+
+   
+   if (c->key.fs_signature.nr_inputs > BRW_MAX_MRF) {
+      c->overflow_grf_start = reg;
+      c->overflow_count = c->key.fs_signature.nr_inputs - BRW_MAX_MRF;
+      reg += c->overflow_count;
+   }
+
+   /* XXX: need to access vertex output semantics here:
+    */
+   for (i = 0; i < c->nr_outputs; i++) {
+      unsigned slot;
+
+      /* XXX: Put output position in slot zero always.  Clipper, etc,
+       * need access to this reg.
+       */
+      if (is_position_output(c, i)) {
+        c->regs[TGSI_FILE_OUTPUT][i] = brw_vec8_grf(reg, 0); /* copy to mrf 0 */
+        reg++;
+      }
+      else if (find_output_slot(c, i, &slot)) {
+         
+         if (0 /* is_psize_output(c, i) */ ) {
+            /* c->psize_out.grf = reg; */
+            /* c->psize_out.mrf = i; */
+         }
+         
+         /* The first (16-4) outputs can go straight into the message regs.
+          */
+         if (slot + mrf < BRW_MAX_MRF) {
+            c->regs[TGSI_FILE_OUTPUT][i] = brw_message_reg(slot + mrf);
+         }
+         else {
+            int grf = c->overflow_grf_start + slot - BRW_MAX_MRF;
+            c->regs[TGSI_FILE_OUTPUT][i] = brw_vec8_grf(grf, 0);
+         }
+      }
+      else {
+         c->regs[TGSI_FILE_OUTPUT][i] = brw_null_reg();
+      }
+   }     
+
+   /* Allocate program temporaries:
+    */
+   
+   for (i = 0; i < c->vp->info.file_max[TGSI_FILE_TEMPORARY]+1; i++) {
+      c->regs[TGSI_FILE_TEMPORARY][i] = brw_vec8_grf(reg, 0);
+      reg++;
+   }
+
+   /* Address reg(s).  Don't try to use the internal address reg until
+    * deref time.
+    */
+   for (i = 0; i < c->vp->info.file_max[TGSI_FILE_ADDRESS]+1; i++) {
+      c->regs[TGSI_FILE_ADDRESS][i] =  brw_reg(BRW_GENERAL_REGISTER_FILE,
+                                            reg,
+                                            0,
+                                            BRW_REGISTER_TYPE_D,
+                                            BRW_VERTICAL_STRIDE_8,
+                                            BRW_WIDTH_8,
+                                            BRW_HORIZONTAL_STRIDE_1,
+                                            BRW_SWIZZLE_XXXX,
+                                            BRW_WRITEMASK_X);
+      reg++;
+   }
+
+   if (c->vp->use_const_buffer) {
+      for (i = 0; i < 3; i++) {
+         c->current_const[i].index = -1;
+         c->current_const[i].reg = brw_vec8_grf(reg, 0);
+         reg++;
+      }
+   }
+
+#if 0
+   for (i = 0; i < 128; i++) {
+      if (c->output_regs[i].used_in_src) {
+         c->output_regs[i].reg = brw_vec8_grf(reg, 0);
+         reg++;
+      }
+   }
+#endif
+
+   if (c->vp->has_flow_control) {
+      c->stack =  brw_uw16_reg(BRW_GENERAL_REGISTER_FILE, reg, 0);
+      reg += 2;
+   }
+
+   /* Some opcodes need an internal temporary:
+    */
+   c->first_tmp = reg;
+   c->last_tmp = reg;          /* for allocation purposes */
+
+   /* Each input reg holds data from two vertices.  The
+    * urb_read_length is the number of registers read from *each*
+    * vertex urb, so is half the amount:
+    */
+   c->prog_data.urb_read_length = (c->nr_inputs + 1) / 2;
+
+   /* Setting this field to 0 leads to undefined behavior according to the
+    * the VS_STATE docs.  Our VUEs will always have at least one attribute
+    * sitting in them, even if it's padding.
+    */
+   if (c->prog_data.urb_read_length == 0)
+      c->prog_data.urb_read_length = 1;
+
+   /* The VS VUEs are shared by VF (outputting our inputs) and VS, so size
+    * them to fit the biggest thing they need to.
+    */
+   attributes_in_vue = MAX2(c->nr_outputs, c->nr_inputs);
+
+   if (c->chipset.is_igdng)
+      c->prog_data.urb_entry_size = (attributes_in_vue + 6 + 3) / 4;
+   else
+      c->prog_data.urb_entry_size = (attributes_in_vue + 2 + 3) / 4;
+
+   c->prog_data.total_grf = reg;
+
+   if (BRW_DEBUG & DEBUG_VS) {
+      debug_printf("%s NumAddrRegs %d\n", __FUNCTION__, 
+                  c->vp->info.file_max[TGSI_FILE_ADDRESS]+1);
+      debug_printf("%s NumTemps %d\n", __FUNCTION__,
+                  c->vp->info.file_max[TGSI_FILE_TEMPORARY]+1);
+      debug_printf("%s reg = %d\n", __FUNCTION__, reg);
+   }
+}
+
+
+/**
+ * If an instruction uses a temp reg both as a src and the dest, we
+ * sometimes need to allocate an intermediate temporary.
+ */
+static void unalias1( struct brw_vs_compile *c,
+                     struct brw_reg dst,
+                     struct brw_reg arg0,
+                     void (*func)( struct brw_vs_compile *,
+                                   struct brw_reg,
+                                   struct brw_reg ))
+{
+   if (dst.file == arg0.file && dst.nr == arg0.nr) {
+      struct brw_compile *p = &c->func;
+      struct brw_reg tmp = brw_writemask(get_tmp(c), dst.dw1.bits.writemask);
+      func(c, tmp, arg0);
+      brw_MOV(p, dst, tmp);
+      release_tmp(c, tmp);
+   }
+   else {
+      func(c, dst, arg0);
+   }
+}
+
+/**
+ * \sa unalias2
+ * Checkes if 2-operand instruction needs an intermediate temporary.
+ */
+static void unalias2( struct brw_vs_compile *c,
+                     struct brw_reg dst,
+                     struct brw_reg arg0,
+                     struct brw_reg arg1,
+                     void (*func)( struct brw_vs_compile *,
+                                   struct brw_reg,
+                                   struct brw_reg,
+                                   struct brw_reg ))
+{
+   if ((dst.file == arg0.file && dst.nr == arg0.nr) ||
+       (dst.file == arg1.file && dst.nr == arg1.nr)) {
+      struct brw_compile *p = &c->func;
+      struct brw_reg tmp = brw_writemask(get_tmp(c), dst.dw1.bits.writemask);
+      func(c, tmp, arg0, arg1);
+      brw_MOV(p, dst, tmp);
+      release_tmp(c, tmp);
+   }
+   else {
+      func(c, dst, arg0, arg1);
+   }
+}
+
+/**
+ * \sa unalias2
+ * Checkes if 3-operand instruction needs an intermediate temporary.
+ */
+static void unalias3( struct brw_vs_compile *c,
+                     struct brw_reg dst,
+                     struct brw_reg arg0,
+                     struct brw_reg arg1,
+                     struct brw_reg arg2,
+                     void (*func)( struct brw_vs_compile *,
+                                   struct brw_reg,
+                                   struct brw_reg,
+                                   struct brw_reg,
+                                   struct brw_reg ))
+{
+   if ((dst.file == arg0.file && dst.nr == arg0.nr) ||
+       (dst.file == arg1.file && dst.nr == arg1.nr) ||
+       (dst.file == arg2.file && dst.nr == arg2.nr)) {
+      struct brw_compile *p = &c->func;
+      struct brw_reg tmp = brw_writemask(get_tmp(c), dst.dw1.bits.writemask);
+      func(c, tmp, arg0, arg1, arg2);
+      brw_MOV(p, dst, tmp);
+      release_tmp(c, tmp);
+   }
+   else {
+      func(c, dst, arg0, arg1, arg2);
+   }
+}
+
+static void emit_sop( struct brw_compile *p,
+                      struct brw_reg dst,
+                      struct brw_reg arg0,
+                      struct brw_reg arg1, 
+                     GLuint cond)
+{
+   brw_MOV(p, dst, brw_imm_f(0.0f));
+   brw_CMP(p, brw_null_reg(), cond, arg0, arg1);
+   brw_MOV(p, dst, brw_imm_f(1.0f));
+   brw_set_predicate_control_flag_value(p, 0xff);
+}
+
+static void emit_seq( struct brw_compile *p,
+                      struct brw_reg dst,
+                      struct brw_reg arg0,
+                      struct brw_reg arg1 )
+{
+   emit_sop(p, dst, arg0, arg1, BRW_CONDITIONAL_EQ);
+}
+
+static void emit_sne( struct brw_compile *p,
+                      struct brw_reg dst,
+                      struct brw_reg arg0,
+                      struct brw_reg arg1 )
+{
+   emit_sop(p, dst, arg0, arg1, BRW_CONDITIONAL_NEQ);
+}
+static void emit_slt( struct brw_compile *p, 
+                     struct brw_reg dst,
+                     struct brw_reg arg0,
+                     struct brw_reg arg1 )
+{
+   emit_sop(p, dst, arg0, arg1, BRW_CONDITIONAL_L);
+}
+
+static void emit_sle( struct brw_compile *p, 
+                     struct brw_reg dst,
+                     struct brw_reg arg0,
+                     struct brw_reg arg1 )
+{
+   emit_sop(p, dst, arg0, arg1, BRW_CONDITIONAL_LE);
+}
+
+static void emit_sgt( struct brw_compile *p, 
+                     struct brw_reg dst,
+                     struct brw_reg arg0,
+                     struct brw_reg arg1 )
+{
+   emit_sop(p, dst, arg0, arg1, BRW_CONDITIONAL_G);
+}
+
+static void emit_sge( struct brw_compile *p, 
+                     struct brw_reg dst,
+                     struct brw_reg arg0,
+                     struct brw_reg arg1 )
+{
+  emit_sop(p, dst, arg0, arg1, BRW_CONDITIONAL_GE);
+}
+
+static void emit_max( struct brw_compile *p, 
+                     struct brw_reg dst,
+                     struct brw_reg arg0,
+                     struct brw_reg arg1 )
+{
+   brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_L, arg0, arg1);
+   brw_SEL(p, dst, arg1, arg0);
+   brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+}
+
+static void emit_min( struct brw_compile *p, 
+                     struct brw_reg dst,
+                     struct brw_reg arg0,
+                     struct brw_reg arg1 )
+{
+   brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_L, arg0, arg1);
+   brw_SEL(p, dst, arg0, arg1);
+   brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+}
+
+
+static void emit_math1( struct brw_vs_compile *c,
+                       GLuint function,
+                       struct brw_reg dst,
+                       struct brw_reg arg0,
+                       GLuint precision)
+{
+   /* There are various odd behaviours with SEND on the simulator.  In
+    * addition there are documented issues with the fact that the GEN4
+    * processor doesn't do dependency control properly on SEND
+    * results.  So, on balance, this kludge to get around failures
+    * with writemasked math results looks like it might be necessary
+    * whether that turns out to be a simulator bug or not:
+    */
+   struct brw_compile *p = &c->func;
+   struct brw_reg tmp = dst;
+   GLboolean need_tmp = (dst.dw1.bits.writemask != 0xf ||
+                        dst.file != BRW_GENERAL_REGISTER_FILE);
+
+   if (need_tmp) 
+      tmp = get_tmp(c);
+
+   brw_math(p, 
+           tmp,
+           function,
+           BRW_MATH_SATURATE_NONE,
+           2,
+           arg0,
+           BRW_MATH_DATA_SCALAR,
+           precision);
+
+   if (need_tmp) {
+      brw_MOV(p, dst, tmp);
+      release_tmp(c, tmp);
+   }
+}
+
+
+static void emit_math2( struct brw_vs_compile *c, 
+                       GLuint function,
+                       struct brw_reg dst,
+                       struct brw_reg arg0,
+                       struct brw_reg arg1,
+                       GLuint precision)
+{
+   struct brw_compile *p = &c->func;
+   struct brw_reg tmp = dst;
+   GLboolean need_tmp = (dst.dw1.bits.writemask != 0xf ||
+                        dst.file != BRW_GENERAL_REGISTER_FILE);
+
+   if (need_tmp) 
+      tmp = get_tmp(c);
+
+   brw_MOV(p, brw_message_reg(3), arg1);
+   
+   brw_math(p, 
+           tmp,
+           function,
+           BRW_MATH_SATURATE_NONE,
+           2,
+           arg0,
+           BRW_MATH_DATA_SCALAR,
+           precision);
+
+   if (need_tmp) {
+      brw_MOV(p, dst, tmp);
+      release_tmp(c, tmp);
+   }
+}
+
+
+static void emit_exp_noalias( struct brw_vs_compile *c,
+                             struct brw_reg dst,
+                             struct brw_reg arg0 )
+{
+   struct brw_compile *p = &c->func;
+   
+
+   if (dst.dw1.bits.writemask & BRW_WRITEMASK_X) {
+      struct brw_reg tmp = get_tmp(c);
+      struct brw_reg tmp_d = retype(tmp, BRW_REGISTER_TYPE_D);
+
+      /* tmp_d = floor(arg0.x) */
+      brw_RNDD(p, tmp_d, brw_swizzle1(arg0, 0));
+
+      /* result[0] = 2.0 ^ tmp */
+
+      /* Adjust exponent for floating point: 
+       * exp += 127 
+       */
+      brw_ADD(p, brw_writemask(tmp_d, BRW_WRITEMASK_X), tmp_d, brw_imm_d(127));
+
+      /* Install exponent and sign.  
+       * Excess drops off the edge: 
+       */
+      brw_SHL(p, brw_writemask(retype(dst, BRW_REGISTER_TYPE_D), BRW_WRITEMASK_X), 
+             tmp_d, brw_imm_d(23));
+
+      release_tmp(c, tmp);
+   }
+
+   if (dst.dw1.bits.writemask & BRW_WRITEMASK_Y) {
+      /* result[1] = arg0.x - floor(arg0.x) */
+      brw_FRC(p, brw_writemask(dst, BRW_WRITEMASK_Y), brw_swizzle1(arg0, 0));
+   }
+   
+   if (dst.dw1.bits.writemask & BRW_WRITEMASK_Z) {
+      /* As with the LOG instruction, we might be better off just
+       * doing a taylor expansion here, seeing as we have to do all
+       * the prep work.
+       *
+       * If mathbox partial precision is too low, consider also:
+       * result[3] = result[0] * EXP(result[1])
+       */
+      emit_math1(c, 
+                BRW_MATH_FUNCTION_EXP, 
+                brw_writemask(dst, BRW_WRITEMASK_Z),
+                brw_swizzle1(arg0, 0), 
+                BRW_MATH_PRECISION_FULL);
+   }  
+
+   if (dst.dw1.bits.writemask & BRW_WRITEMASK_W) {
+      /* result[3] = 1.0; */
+      brw_MOV(p, brw_writemask(dst, BRW_WRITEMASK_W), brw_imm_f(1));
+   }
+}
+
+
+static void emit_log_noalias( struct brw_vs_compile *c,
+                             struct brw_reg dst,
+                             struct brw_reg arg0 )
+{
+   struct brw_compile *p = &c->func;
+   struct brw_reg tmp = dst;
+   struct brw_reg tmp_ud = retype(tmp, BRW_REGISTER_TYPE_UD);
+   struct brw_reg arg0_ud = retype(arg0, BRW_REGISTER_TYPE_UD);
+   GLboolean need_tmp = (dst.dw1.bits.writemask != 0xf ||
+                        dst.file != BRW_GENERAL_REGISTER_FILE);
+
+   if (need_tmp) {
+      tmp = get_tmp(c);
+      tmp_ud = retype(tmp, BRW_REGISTER_TYPE_UD);
+   }
+   
+   /* Perform mant = frexpf(fabsf(x), &exp), adjust exp and mnt
+    * according to spec:
+    *
+    * These almost look likey they could be joined up, but not really
+    * practical:
+    *
+    * result[0].f = (x.i & ((1<<31)-1) >> 23) - 127
+    * result[1].i = (x.i & ((1<<23)-1)        + (127<<23)
+    */
+   if (dst.dw1.bits.writemask & BRW_WRITEMASK_XZ) {
+      brw_AND(p, 
+             brw_writemask(tmp_ud, BRW_WRITEMASK_X),
+             brw_swizzle1(arg0_ud, 0),
+             brw_imm_ud((1U<<31)-1));
+
+      brw_SHR(p, 
+             brw_writemask(tmp_ud, BRW_WRITEMASK_X), 
+             tmp_ud,
+             brw_imm_ud(23));
+
+      brw_ADD(p, 
+             brw_writemask(tmp, BRW_WRITEMASK_X), 
+             retype(tmp_ud, BRW_REGISTER_TYPE_D),      /* does it matter? */
+             brw_imm_d(-127));
+   }
+
+   if (dst.dw1.bits.writemask & BRW_WRITEMASK_YZ) {
+      brw_AND(p, 
+             brw_writemask(tmp_ud, BRW_WRITEMASK_Y),
+             brw_swizzle1(arg0_ud, 0),
+             brw_imm_ud((1<<23)-1));
+
+      brw_OR(p, 
+            brw_writemask(tmp_ud, BRW_WRITEMASK_Y), 
+            tmp_ud,
+            brw_imm_ud(127<<23));
+   }
+   
+   if (dst.dw1.bits.writemask & BRW_WRITEMASK_Z) {
+      /* result[2] = result[0] + LOG2(result[1]); */
+
+      /* Why bother?  The above is just a hint how to do this with a
+       * taylor series.  Maybe we *should* use a taylor series as by
+       * the time all the above has been done it's almost certainly
+       * quicker than calling the mathbox, even with low precision.
+       * 
+       * Options are:
+       *    - result[0] + mathbox.LOG2(result[1])
+       *    - mathbox.LOG2(arg0.x)
+       *    - result[0] + inline_taylor_approx(result[1])
+       */
+      emit_math1(c, 
+                BRW_MATH_FUNCTION_LOG, 
+                brw_writemask(tmp, BRW_WRITEMASK_Z), 
+                brw_swizzle1(tmp, 1), 
+                BRW_MATH_PRECISION_FULL);
+      
+      brw_ADD(p, 
+             brw_writemask(tmp, BRW_WRITEMASK_Z), 
+             brw_swizzle1(tmp, 2), 
+             brw_swizzle1(tmp, 0));
+   }  
+
+   if (dst.dw1.bits.writemask & BRW_WRITEMASK_W) {
+      /* result[3] = 1.0; */
+      brw_MOV(p, brw_writemask(tmp, BRW_WRITEMASK_W), brw_imm_f(1));
+   }
+
+   if (need_tmp) {
+      brw_MOV(p, dst, tmp);
+      release_tmp(c, tmp);
+   }
+}
+
+
+/* Need to unalias - consider swizzles:   r0 = DST r0.xxxx r1
+ */
+static void emit_dst_noalias( struct brw_vs_compile *c, 
+                             struct brw_reg dst,
+                             struct brw_reg arg0,
+                             struct brw_reg arg1)
+{
+   struct brw_compile *p = &c->func;
+
+   /* There must be a better way to do this: 
+    */
+   if (dst.dw1.bits.writemask & BRW_WRITEMASK_X)
+      brw_MOV(p, brw_writemask(dst, BRW_WRITEMASK_X), brw_imm_f(1.0));
+   if (dst.dw1.bits.writemask & BRW_WRITEMASK_Y)
+      brw_MUL(p, brw_writemask(dst, BRW_WRITEMASK_Y), arg0, arg1);
+   if (dst.dw1.bits.writemask & BRW_WRITEMASK_Z)
+      brw_MOV(p, brw_writemask(dst, BRW_WRITEMASK_Z), arg0);
+   if (dst.dw1.bits.writemask & BRW_WRITEMASK_W)
+      brw_MOV(p, brw_writemask(dst, BRW_WRITEMASK_W), arg1);
+}
+
+
+static void emit_xpd( struct brw_compile *p,
+                     struct brw_reg dst,
+                     struct brw_reg t,
+                     struct brw_reg u)
+{
+   brw_MUL(p, brw_null_reg(), brw_swizzle(t, 1,2,0,3),  brw_swizzle(u,2,0,1,3));
+   brw_MAC(p, dst,     negate(brw_swizzle(t, 2,0,1,3)), brw_swizzle(u,1,2,0,3));
+}
+
+
+static void emit_lit_noalias( struct brw_vs_compile *c, 
+                             struct brw_reg dst,
+                             struct brw_reg arg0 )
+{
+   struct brw_compile *p = &c->func;
+   struct brw_instruction *if_insn;
+   struct brw_reg tmp = dst;
+   GLboolean need_tmp = (dst.file != BRW_GENERAL_REGISTER_FILE);
+
+   if (need_tmp) 
+      tmp = get_tmp(c);
+   
+   brw_MOV(p, brw_writemask(dst, BRW_WRITEMASK_YZ), brw_imm_f(0)); 
+   brw_MOV(p, brw_writemask(dst, BRW_WRITEMASK_XW), brw_imm_f(1)); 
+
+   /* Need to use BRW_EXECUTE_8 and also do an 8-wide compare in order
+    * to get all channels active inside the IF.  In the clipping code
+    * we run with NoMask, so it's not an option and we can use
+    * BRW_EXECUTE_1 for all comparisions.
+    */
+   brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_G, brw_swizzle1(arg0,0), brw_imm_f(0));
+   if_insn = brw_IF(p, BRW_EXECUTE_8);
+   {
+      brw_MOV(p, brw_writemask(dst, BRW_WRITEMASK_Y), brw_swizzle1(arg0,0));
+
+      brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_G, brw_swizzle1(arg0,1), brw_imm_f(0));
+      brw_MOV(p, brw_writemask(tmp, BRW_WRITEMASK_Z),  brw_swizzle1(arg0,1));
+      brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+
+      emit_math2(c, 
+                BRW_MATH_FUNCTION_POW, 
+                brw_writemask(dst, BRW_WRITEMASK_Z),
+                brw_swizzle1(tmp, 2),
+                brw_swizzle1(arg0, 3),
+                BRW_MATH_PRECISION_PARTIAL);      
+   }
+
+   brw_ENDIF(p, if_insn);
+
+   release_tmp(c, tmp);
+}
+
+static void emit_lrp_noalias(struct brw_vs_compile *c,
+                            struct brw_reg dst,
+                            struct brw_reg arg0,
+                            struct brw_reg arg1,
+                            struct brw_reg arg2)
+{
+   struct brw_compile *p = &c->func;
+
+   brw_ADD(p, dst, negate(arg0), brw_imm_f(1.0));
+   brw_MUL(p, brw_null_reg(), dst, arg2);
+   brw_MAC(p, dst, arg0, arg1);
+}
+
+/** 3 or 4-component vector normalization */
+static void emit_nrm( struct brw_vs_compile *c, 
+                      struct brw_reg dst,
+                      struct brw_reg arg0,
+                      int num_comps)
+{
+   struct brw_compile *p = &c->func;
+   struct brw_reg tmp = get_tmp(c);
+
+   /* tmp = dot(arg0, arg0) */
+   if (num_comps == 3)
+      brw_DP3(p, tmp, arg0, arg0);
+   else
+      brw_DP4(p, tmp, arg0, arg0);
+
+   /* tmp = 1 / sqrt(tmp) */
+   emit_math1(c, BRW_MATH_FUNCTION_RSQ, tmp, tmp, BRW_MATH_PRECISION_FULL);
+
+   /* dst = arg0 * tmp */
+   brw_MUL(p, dst, arg0, tmp);
+
+   release_tmp(c, tmp);
+}
+
+
+static struct brw_reg
+get_constant(struct brw_vs_compile *c,
+            GLuint argIndex,
+            GLuint index,
+            GLboolean relAddr)
+{
+   struct brw_compile *p = &c->func;
+   struct brw_reg const_reg;
+   struct brw_reg const2_reg;
+
+   assert(argIndex < 3);
+
+   if (c->current_const[argIndex].index != index || relAddr) {
+      struct brw_reg addrReg = c->regs[TGSI_FILE_ADDRESS][0];
+
+      c->current_const[argIndex].index = index;
+
+#if 0
+      printf("  fetch const[%d] for arg %d into reg %d\n",
+             src.Index, argIndex, c->current_const[argIndex].reg.nr);
+#endif
+      /* need to fetch the constant now */
+      brw_dp_READ_4_vs(p,
+                       c->current_const[argIndex].reg,/* writeback dest */
+                       0,                             /* oword */
+                       relAddr,                       /* relative indexing? */
+                       addrReg,                       /* address register */
+                       16 * index,               /* byte offset */
+                       SURF_INDEX_VERT_CONST_BUFFER   /* binding table index */
+                       );
+
+      if (relAddr) {
+         /* second read */
+         const2_reg = get_tmp(c);
+
+         /* use upper half of address reg for second read */
+         addrReg = stride(addrReg, 0, 4, 0);
+         addrReg.subnr = 16;
+
+         brw_dp_READ_4_vs(p,
+                          const2_reg,              /* writeback dest */
+                          1,                       /* oword */
+                          relAddr,                 /* relative indexing? */
+                          addrReg,                 /* address register */
+                          16 * index,         /* byte offset */
+                          SURF_INDEX_VERT_CONST_BUFFER
+                          );
+      }
+   }
+
+   const_reg = c->current_const[argIndex].reg;
+
+   if (relAddr) {
+      /* merge the two Owords into the constant register */
+      /* const_reg[7..4] = const2_reg[7..4] */
+      brw_MOV(p,
+              suboffset(stride(const_reg, 0, 4, 1), 4),
+              suboffset(stride(const2_reg, 0, 4, 1), 4));
+      release_tmp(c, const2_reg);
+   }
+   else {
+      /* replicate lower four floats into upper half (to get XYZWXYZW) */
+      const_reg = stride(const_reg, 0, 4, 0);
+      const_reg.subnr = 0;
+   }
+
+   return const_reg;
+}
+
+
+
+/* TODO: relative addressing!
+ */
+static struct brw_reg get_reg( struct brw_vs_compile *c,
+                              enum tgsi_file_type file,
+                              GLuint index )
+{
+   switch (file) {
+   case TGSI_FILE_TEMPORARY:
+   case TGSI_FILE_INPUT:
+   case TGSI_FILE_OUTPUT:
+   case TGSI_FILE_CONSTANT:
+      assert(c->regs[file][index].nr != 0);
+      return c->regs[file][index];
+
+   case TGSI_FILE_ADDRESS:
+      assert(index == 0);
+      return c->regs[file][index];
+
+   case TGSI_FILE_NULL:                        /* undef values */
+      return brw_null_reg();
+
+   default:
+      assert(0);
+      return brw_null_reg();
+   }
+}
+
+
+/**
+ * Indirect addressing:  get reg[[arg] + offset].
+ */
+static struct brw_reg deref( struct brw_vs_compile *c,
+                            struct brw_reg arg,
+                            GLint offset)
+{
+   struct brw_compile *p = &c->func;
+   struct brw_reg tmp = vec4(get_tmp(c));
+   struct brw_reg addr_reg = c->regs[TGSI_FILE_ADDRESS][0];
+   struct brw_reg vp_address = retype(vec1(addr_reg), BRW_REGISTER_TYPE_UW);
+   GLuint byte_offset = arg.nr * 32 + arg.subnr + offset * 16;
+   struct brw_reg indirect = brw_vec4_indirect(0,0);
+
+   {
+      brw_push_insn_state(p);
+      brw_set_access_mode(p, BRW_ALIGN_1);
+
+      /* This is pretty clunky - load the address register twice and
+       * fetch each 4-dword value in turn.  There must be a way to do
+       * this in a single pass, but I couldn't get it to work.
+       */
+      brw_ADD(p, brw_address_reg(0), vp_address, brw_imm_d(byte_offset));
+      brw_MOV(p, tmp, indirect);
+
+      brw_ADD(p, brw_address_reg(0), suboffset(vp_address, 8), brw_imm_d(byte_offset));
+      brw_MOV(p, suboffset(tmp, 4), indirect);
+
+      brw_pop_insn_state(p);
+   }
+   
+   /* NOTE: tmp not released */
+   return vec8(tmp);
+}
+
+
+/**
+ * Get brw reg corresponding to the instruction's [argIndex] src reg.
+ * TODO: relative addressing!
+ */
+static struct brw_reg
+get_src_reg( struct brw_vs_compile *c,
+            GLuint argIndex,
+            GLuint file,
+            GLint index,
+            GLboolean relAddr )
+{
+
+   switch (file) {
+   case TGSI_FILE_TEMPORARY:
+   case TGSI_FILE_INPUT:
+   case TGSI_FILE_OUTPUT:
+      if (relAddr) {
+         return deref(c, c->regs[file][0], index);
+      }
+      else {
+         assert(c->regs[file][index].nr != 0);
+         return c->regs[file][index];
+      }
+
+   case TGSI_FILE_IMMEDIATE:
+      return c->regs[file][index];
+
+   case TGSI_FILE_CONSTANT:
+      if (c->vp->use_const_buffer) {
+         return get_constant(c, argIndex, index, relAddr);
+      }
+      else if (relAddr) {
+         return deref(c, c->regs[TGSI_FILE_CONSTANT][0], index);
+      }
+      else {
+         assert(c->regs[TGSI_FILE_CONSTANT][index].nr != 0);
+         return c->regs[TGSI_FILE_CONSTANT][index];
+      }
+   case TGSI_FILE_ADDRESS:
+      assert(index == 0);
+      return c->regs[file][index];
+
+   case TGSI_FILE_NULL:
+      /* this is a normal case since we loop over all three src args */
+      return brw_null_reg();
+
+   default:
+      assert(0);
+      return brw_null_reg();
+   }
+}
+
+
+static void emit_arl( struct brw_vs_compile *c,
+                     struct brw_reg dst,
+                     struct brw_reg arg0 )
+{
+   struct brw_compile *p = &c->func;
+   struct brw_reg tmp = dst;
+   GLboolean need_tmp = (dst.file != BRW_GENERAL_REGISTER_FILE);
+   
+   if (need_tmp) 
+      tmp = get_tmp(c);
+
+   brw_RNDD(p, tmp, arg0);               /* tmp = round(arg0) */
+   brw_MUL(p, dst, tmp, brw_imm_d(16));  /* dst = tmp * 16 */
+
+   if (need_tmp)
+      release_tmp(c, tmp);
+}
+
+
+/**
+ * Return the brw reg for the given instruction's src argument.
+ */
+static struct brw_reg get_arg( struct brw_vs_compile *c,
+                               const struct tgsi_full_src_register *src,
+                               GLuint argIndex )
+{
+   struct brw_reg reg;
+
+   if (src->Register.File == TGSI_FILE_NULL)
+      return brw_null_reg();
+
+   reg = get_src_reg(c, argIndex,
+                    src->Register.File,
+                    src->Register.Index,
+                    src->Register.Indirect);
+
+   /* Convert 3-bit swizzle to 2-bit.  
+    */
+   reg.dw1.bits.swizzle = BRW_SWIZZLE4(src->Register.SwizzleX,
+                                      src->Register.SwizzleY,
+                                      src->Register.SwizzleZ,
+                                      src->Register.SwizzleW);
+
+   reg.negate = src->Register.Negate ? 1 : 0;   
+
+   /* XXX: abs, absneg
+    */
+
+   return reg;
+}
+
+
+/**
+ * Get brw register for the given program dest register.
+ */
+static struct brw_reg get_dst( struct brw_vs_compile *c,
+                              unsigned file,
+                              unsigned index,
+                              unsigned writemask )
+{
+   struct brw_reg reg;
+
+   switch (file) {
+   case TGSI_FILE_TEMPORARY:
+   case TGSI_FILE_OUTPUT:
+      assert(c->regs[file][index].nr != 0);
+      reg = c->regs[file][index];
+      break;
+   case TGSI_FILE_ADDRESS:
+      assert(index == 0);
+      reg = c->regs[file][index];
+      break;
+   case TGSI_FILE_NULL:
+      /* we may hit this for OPCODE_END, OPCODE_KIL, etc */
+      reg = brw_null_reg();
+      break;
+   default:
+      assert(0);
+      reg = brw_null_reg();
+   }
+
+   reg.dw1.bits.writemask = writemask;
+
+   return reg;
+}
+
+
+
+
+/**
+ * Post-vertex-program processing.  Send the results to the URB.
+ */
+static void emit_vertex_write( struct brw_vs_compile *c)
+{
+   struct brw_compile *p = &c->func;
+   struct brw_reg m0 = brw_message_reg(0);
+   struct brw_reg pos = c->regs[TGSI_FILE_OUTPUT][VERT_RESULT_HPOS];
+   struct brw_reg ndc;
+   int eot;
+   int i;
+   GLuint len_vertext_header = 2;
+
+   /* Build ndc coords */
+   ndc = get_tmp(c);
+   /* ndc = 1.0 / pos.w */
+   emit_math1(c, BRW_MATH_FUNCTION_INV, ndc, brw_swizzle1(pos, 3), BRW_MATH_PRECISION_FULL);
+   /* ndc.xyz = pos * ndc */
+   brw_MUL(p, brw_writemask(ndc, BRW_WRITEMASK_XYZ), pos, ndc);
+
+   /* Update the header for point size, user clipping flags, and -ve rhw
+    * workaround.
+    */
+   if (c->prog_data.writes_psiz ||
+       c->key.nr_userclip || 
+       c->chipset.is_965)
+   {
+      struct brw_reg header1 = retype(get_tmp(c), BRW_REGISTER_TYPE_UD);
+      GLuint i;
+
+      brw_MOV(p, header1, brw_imm_ud(0));
+
+      brw_set_access_mode(p, BRW_ALIGN_16);    
+
+      if (c->prog_data.writes_psiz) {
+        struct brw_reg psiz = c->regs[TGSI_FILE_OUTPUT][VERT_RESULT_PSIZ];
+        brw_MUL(p, brw_writemask(header1, BRW_WRITEMASK_W), brw_swizzle1(psiz, 0), brw_imm_f(1<<11));
+        brw_AND(p, brw_writemask(header1, BRW_WRITEMASK_W), header1, brw_imm_ud(0x7ff<<8));
+      }
+
+      for (i = 0; i < c->key.nr_userclip; i++) {
+        brw_set_conditionalmod(p, BRW_CONDITIONAL_L);
+        brw_DP4(p, brw_null_reg(), pos, c->userplane[i]);
+        brw_OR(p, brw_writemask(header1, BRW_WRITEMASK_W), header1, brw_imm_ud(1<<i));
+        brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+      }
+
+      /* i965 clipping workaround: 
+       * 1) Test for -ve rhw
+       * 2) If set, 
+       *      set ndc = (0,0,0,0)
+       *      set ucp[6] = 1
+       *
+       * Later, clipping will detect ucp[6] and ensure the primitive is
+       * clipped against all fixed planes.
+       */
+      if (c->chipset.is_965) {
+        brw_CMP(p,
+                vec8(brw_null_reg()),
+                BRW_CONDITIONAL_L,
+                brw_swizzle1(ndc, 3),
+                brw_imm_f(0));
+   
+        brw_OR(p, brw_writemask(header1, BRW_WRITEMASK_W), header1, brw_imm_ud(1<<6));
+        brw_MOV(p, ndc, brw_imm_f(0));
+        brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+      }
+
+      brw_set_access_mode(p, BRW_ALIGN_1);     /* why? */
+      brw_MOV(p, retype(brw_message_reg(1), BRW_REGISTER_TYPE_UD), header1);
+      brw_set_access_mode(p, BRW_ALIGN_16);
+
+      release_tmp(c, header1);
+   }
+   else {
+      brw_MOV(p, retype(brw_message_reg(1), BRW_REGISTER_TYPE_UD), brw_imm_ud(0));
+   }
+
+   /* Emit the (interleaved) headers for the two vertices - an 8-reg
+    * of zeros followed by two sets of NDC coordinates:
+    */
+   brw_set_access_mode(p, BRW_ALIGN_1);
+   brw_MOV(p, offset(m0, 2), ndc);
+
+   if (c->chipset.is_igdng) {
+       /* There are 20 DWs (D0-D19) in VUE vertex header on IGDNG */
+       brw_MOV(p, offset(m0, 3), pos); /* a portion of vertex header */
+       /* m4, m5 contain the distances from vertex to the user clip planeXXX. 
+        * Seems it is useless for us.
+        * m6 is used for aligning, so that the remainder of vertex element is 
+        * reg-aligned.
+        */
+       brw_MOV(p, offset(m0, 7), pos); /* the remainder of vertex element */
+       len_vertext_header = 6;
+   } else {
+       brw_MOV(p, offset(m0, 3), pos);
+       len_vertext_header = 2;
+   }
+
+   eot = (c->overflow_count == 0);
+
+   brw_urb_WRITE(p, 
+                brw_null_reg(), /* dest */
+                0,             /* starting mrf reg nr */
+                c->r0,         /* src */
+                0,             /* allocate */
+                1,             /* used */
+                MIN2(c->nr_outputs + 1 + len_vertext_header, (BRW_MAX_MRF-1)), /* msg len */
+                0,             /* response len */
+                eot,           /* eot */
+                eot,           /* writes complete */
+                0,             /* urb destination offset */
+                BRW_URB_SWIZZLE_INTERLEAVE);
+
+   /* Not all of the vertex outputs/results fit into the MRF.
+    * Move the overflowed attributes from the GRF to the MRF and
+    * issue another brw_urb_WRITE().
+    */
+   for (i = 0; i < c->overflow_count; i += BRW_MAX_MRF) {
+      unsigned nr = MIN2(c->overflow_count - i, BRW_MAX_MRF);
+      GLuint j;
+
+      eot = (i + nr >= c->overflow_count);
+
+      /* XXX I'm not 100% sure about which MRF regs to use here.  Starting
+       * at mrf[4] atm...
+       */
+      for (j = 0; j < nr; j++) {
+        brw_MOV(p, brw_message_reg(4+j), 
+                 brw_vec8_grf(c->overflow_grf_start + i + j, 0));
+      }
+
+      brw_urb_WRITE(p,
+                    brw_null_reg(), /* dest */
+                    4,              /* starting mrf reg nr */
+                    c->r0,          /* src */
+                    0,              /* allocate */
+                    1,              /* used */
+                    nr+1,          /* msg len */
+                    0,              /* response len */
+                    eot,            /* eot */
+                    eot,            /* writes complete */
+                    i-1,            /* urb destination offset */
+                    BRW_URB_SWIZZLE_INTERLEAVE);
+   }
+}
+
+
+/**
+ * Called after code generation to resolve subroutine calls and the
+ * END instruction.
+ * \param end_inst  points to brw code for END instruction
+ * \param last_inst  points to last instruction emitted before vertex write
+ */
+static void 
+post_vs_emit( struct brw_vs_compile *c,
+              struct brw_instruction *end_inst,
+              struct brw_instruction *last_inst )
+{
+   GLint offset;
+
+   brw_resolve_cals(&c->func);
+
+   /* patch up the END code to jump past subroutines, etc */
+   offset = last_inst - end_inst;
+   if (offset > 1) {
+      brw_set_src1(end_inst, brw_imm_d(offset * 16));
+   } else {
+      end_inst->header.opcode = BRW_OPCODE_NOP;
+   }
+}
+
+static uint32_t
+get_predicate(const struct tgsi_full_instruction *inst)
+{
+   /* XXX: disabling for now
+    */
+#if 0
+   if (inst->dst.CondMask == COND_TR)
+      return BRW_PREDICATE_NONE;
+
+   /* All of GLSL only produces predicates for COND_NE and one channel per
+    * vector.  Fail badly if someone starts doing something else, as it might
+    * mean infinite looping or something.
+    *
+    * We'd like to support all the condition codes, but our hardware doesn't
+    * quite match the Mesa IR, which is modeled after the NV extensions.  For
+    * those, the instruction may update the condition codes or not, then any
+    * later instruction may use one of those condition codes.  For gen4, the
+    * instruction may update the flags register based on one of the condition
+    * codes output by the instruction, and then further instructions may
+    * predicate on that.  We can probably support this, but it won't
+    * necessarily be easy.
+    */
+/*   assert(inst->dst.CondMask == COND_NE); */
+
+   switch (inst->dst.CondSwizzle) {
+   case SWIZZLE_XXXX:
+      return BRW_PREDICATE_ALIGN16_REPLICATE_X;
+   case SWIZZLE_YYYY:
+      return BRW_PREDICATE_ALIGN16_REPLICATE_Y;
+   case SWIZZLE_ZZZZ:
+      return BRW_PREDICATE_ALIGN16_REPLICATE_Z;
+   case SWIZZLE_WWWW:
+      return BRW_PREDICATE_ALIGN16_REPLICATE_W;
+   default:
+      debug_printf("Unexpected predicate: 0x%08x\n",
+                   inst->dst.CondMask);
+      return BRW_PREDICATE_NORMAL;
+   }
+#else
+   return BRW_PREDICATE_NORMAL;
+#endif
+}
+
+static void emit_insn(struct brw_vs_compile *c,
+                     const struct tgsi_full_instruction *inst)
+{
+   unsigned opcode = inst->Instruction.Opcode;
+   unsigned label = inst->Label.Label;
+   struct brw_compile *p = &c->func;
+   struct brw_reg args[3], dst;
+   GLuint i;
+
+#if 0
+   printf("%d: ", insn);
+   _mesa_print_instruction(inst);
+#endif
+
+   /* Get argument regs.
+    */
+   for (i = 0; i < 3; i++) {
+      args[i] = get_arg(c, &inst->Src[i], i);
+   }
+
+   /* Get dest regs.  Note that it is possible for a reg to be both
+    * dst and arg, given the static allocation of registers.  So
+    * care needs to be taken emitting multi-operation instructions.
+    */ 
+   dst = get_dst(c, 
+                inst->Dst[0].Register.File,
+                inst->Dst[0].Register.Index,
+                inst->Dst[0].Register.WriteMask);
+
+   /* XXX: saturate
+    */
+   if (inst->Instruction.Saturate != TGSI_SAT_NONE) {
+      debug_printf("Unsupported saturate in vertex shader");
+   }
+
+   switch (opcode) {
+   case TGSI_OPCODE_ABS:
+      brw_MOV(p, dst, brw_abs(args[0]));
+      break;
+   case TGSI_OPCODE_ADD:
+      brw_ADD(p, dst, args[0], args[1]);
+      break;
+   case TGSI_OPCODE_COS:
+      emit_math1(c, BRW_MATH_FUNCTION_COS, dst, args[0], BRW_MATH_PRECISION_FULL);
+      break;
+   case TGSI_OPCODE_DP3:
+      brw_DP3(p, dst, args[0], args[1]);
+      break;
+   case TGSI_OPCODE_DP4:
+      brw_DP4(p, dst, args[0], args[1]);
+      break;
+   case TGSI_OPCODE_DPH:
+      brw_DPH(p, dst, args[0], args[1]);
+      break;
+   case TGSI_OPCODE_NRM:
+      emit_nrm(c, dst, args[0], 3);
+      break;
+   case TGSI_OPCODE_NRM4:
+      emit_nrm(c, dst, args[0], 4);
+      break;
+   case TGSI_OPCODE_DST:
+      unalias2(c, dst, args[0], args[1], emit_dst_noalias); 
+      break;
+   case TGSI_OPCODE_EXP:
+      unalias1(c, dst, args[0], emit_exp_noalias);
+      break;
+   case TGSI_OPCODE_EX2:
+      emit_math1(c, BRW_MATH_FUNCTION_EXP, dst, args[0], BRW_MATH_PRECISION_FULL);
+      break;
+   case TGSI_OPCODE_ARL:
+      emit_arl(c, dst, args[0]);
+      break;
+   case TGSI_OPCODE_FLR:
+      brw_RNDD(p, dst, args[0]);
+      break;
+   case TGSI_OPCODE_FRC:
+      brw_FRC(p, dst, args[0]);
+      break;
+   case TGSI_OPCODE_LOG:
+      unalias1(c, dst, args[0], emit_log_noalias);
+      break;
+   case TGSI_OPCODE_LG2:
+      emit_math1(c, BRW_MATH_FUNCTION_LOG, dst, args[0], BRW_MATH_PRECISION_FULL);
+      break;
+   case TGSI_OPCODE_LIT:
+      unalias1(c, dst, args[0], emit_lit_noalias);
+      break;
+   case TGSI_OPCODE_LRP:
+      unalias3(c, dst, args[0], args[1], args[2], emit_lrp_noalias);
+      break;
+   case TGSI_OPCODE_MAD:
+      brw_MOV(p, brw_acc_reg(), args[2]);
+      brw_MAC(p, dst, args[0], args[1]);
+      break;
+   case TGSI_OPCODE_MAX:
+      emit_max(p, dst, args[0], args[1]);
+      break;
+   case TGSI_OPCODE_MIN:
+      emit_min(p, dst, args[0], args[1]);
+      break;
+   case TGSI_OPCODE_MOV:
+      brw_MOV(p, dst, args[0]);
+      break;
+   case TGSI_OPCODE_MUL:
+      brw_MUL(p, dst, args[0], args[1]);
+      break;
+   case TGSI_OPCODE_POW:
+      emit_math2(c, BRW_MATH_FUNCTION_POW, dst, args[0], args[1], BRW_MATH_PRECISION_FULL); 
+      break;
+   case TGSI_OPCODE_RCP:
+      emit_math1(c, BRW_MATH_FUNCTION_INV, dst, args[0], BRW_MATH_PRECISION_FULL);
+      break;
+   case TGSI_OPCODE_RSQ:
+      emit_math1(c, BRW_MATH_FUNCTION_RSQ, dst, 
+                 brw_swizzle(args[0], 0,0,0,0), BRW_MATH_PRECISION_FULL);
+      break;
+   case TGSI_OPCODE_SEQ:
+      emit_seq(p, dst, args[0], args[1]);
+      break;
+   case TGSI_OPCODE_SIN:
+      emit_math1(c, BRW_MATH_FUNCTION_SIN, dst, args[0], BRW_MATH_PRECISION_FULL);
+      break;
+   case TGSI_OPCODE_SNE:
+      emit_sne(p, dst, args[0], args[1]);
+      break;
+   case TGSI_OPCODE_SGE:
+      emit_sge(p, dst, args[0], args[1]);
+      break;
+   case TGSI_OPCODE_SGT:
+      emit_sgt(p, dst, args[0], args[1]);
+      break;
+   case TGSI_OPCODE_SLT:
+      emit_slt(p, dst, args[0], args[1]);
+      break;
+   case TGSI_OPCODE_SLE:
+      emit_sle(p, dst, args[0], args[1]);
+      break;
+   case TGSI_OPCODE_SUB:
+      brw_ADD(p, dst, args[0], negate(args[1]));
+      break;
+   case TGSI_OPCODE_TRUNC:
+      /* round toward zero */
+      brw_RNDZ(p, dst, args[0]);
+      break;
+   case TGSI_OPCODE_XPD:
+      emit_xpd(p, dst, args[0], args[1]);
+      break;
+   case TGSI_OPCODE_IF:
+      assert(c->if_depth < MAX_IF_DEPTH);
+      c->if_inst[c->if_depth] = brw_IF(p, BRW_EXECUTE_8);
+      /* Note that brw_IF smashes the predicate_control field. */
+      c->if_inst[c->if_depth]->header.predicate_control = get_predicate(inst);
+      c->if_depth++;
+      break;
+   case TGSI_OPCODE_ELSE:
+      c->if_inst[c->if_depth-1] = brw_ELSE(p, c->if_inst[c->if_depth-1]);
+      break;
+   case TGSI_OPCODE_ENDIF:
+      assert(c->if_depth > 0);
+      brw_ENDIF(p, c->if_inst[--c->if_depth]);
+      break;                   
+   case TGSI_OPCODE_BGNLOOP:
+      c->loop_inst[c->loop_depth++] = brw_DO(p, BRW_EXECUTE_8);
+      break;
+   case TGSI_OPCODE_BRK:
+      brw_set_predicate_control(p, get_predicate(inst));
+      brw_BREAK(p);
+      brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+      break;
+   case TGSI_OPCODE_CONT:
+      brw_set_predicate_control(p, get_predicate(inst));
+      brw_CONT(p);
+      brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+      break;
+   case TGSI_OPCODE_ENDLOOP: 
+   {
+      struct brw_instruction *inst0, *inst1;
+      GLuint br = 1;
+
+      c->loop_depth--;
+
+      if (c->chipset.is_igdng)
+        br = 2;
+
+      inst0 = inst1 = brw_WHILE(p, c->loop_inst[c->loop_depth]);
+      /* patch all the BREAK/CONT instructions from last BEGINLOOP */
+      while (inst0 > c->loop_inst[c->loop_depth]) {
+        inst0--;
+        if (inst0->header.opcode == TGSI_OPCODE_BRK) {
+           inst0->bits3.if_else.jump_count = br * (inst1 - inst0 + 1);
+           inst0->bits3.if_else.pop_count = 0;
+        }
+        else if (inst0->header.opcode == TGSI_OPCODE_CONT) {
+           inst0->bits3.if_else.jump_count = br * (inst1 - inst0);
+           inst0->bits3.if_else.pop_count = 0;
+        }
+      }
+   }
+   break;
+   case TGSI_OPCODE_BRA:
+      brw_set_predicate_control(p, get_predicate(inst));
+      brw_ADD(p, brw_ip_reg(), brw_ip_reg(), brw_imm_d(1*16));
+      brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+      break;
+   case TGSI_OPCODE_CAL:
+      brw_set_access_mode(p, BRW_ALIGN_1);
+      brw_ADD(p, deref_1d(c->stack_index, 0), brw_ip_reg(), brw_imm_d(3*16));
+      brw_set_access_mode(p, BRW_ALIGN_16);
+      brw_ADD(p, get_addr_reg(c->stack_index),
+             get_addr_reg(c->stack_index), brw_imm_d(4));
+      brw_save_call(p, label, p->nr_insn);
+      brw_ADD(p, brw_ip_reg(), brw_ip_reg(), brw_imm_d(1*16));
+      break;
+   case TGSI_OPCODE_RET:
+      brw_ADD(p, get_addr_reg(c->stack_index),
+             get_addr_reg(c->stack_index), brw_imm_d(-4));
+      brw_set_access_mode(p, BRW_ALIGN_1);
+      brw_MOV(p, brw_ip_reg(), deref_1d(c->stack_index, 0));
+      brw_set_access_mode(p, BRW_ALIGN_16);
+      break;
+   case TGSI_OPCODE_END:       
+      c->end_offset = p->nr_insn;
+      /* this instruction will get patched later to jump past subroutine
+       * code, etc.
+       */
+      brw_ADD(p, brw_ip_reg(), brw_ip_reg(), brw_imm_d(1*16));
+      break;
+   case TGSI_OPCODE_BGNSUB:
+      brw_save_label(p, p->nr_insn, p->nr_insn);
+      break;
+   case TGSI_OPCODE_ENDSUB:
+      /* no-op */
+      break;
+   default:
+      debug_printf("Unsupported opcode %i (%s) in vertex shader",
+                  opcode, 
+                  tgsi_get_opcode_name(opcode));
+   }
+
+   /* Set the predication update on the last instruction of the native
+    * instruction sequence.
+    *
+    * This would be problematic if it was set on a math instruction,
+    * but that shouldn't be the case with the current GLSL compiler.
+    */
+#if 0
+   /* XXX: disabled
+    */
+   if (inst->CondUpdate) {
+      struct brw_instruction *hw_insn = &p->store[p->nr_insn - 1];
+
+      assert(hw_insn->header.destreg__conditionalmod == 0);
+      hw_insn->header.destreg__conditionalmod = BRW_CONDITIONAL_NZ;
+   }
+#endif
+
+   release_tmps(c);
+}
+
+
+/* Emit the vertex program instructions here.
+ */
+void brw_vs_emit(struct brw_vs_compile *c)
+{
+   struct brw_compile *p = &c->func;
+   const struct tgsi_token *tokens = c->vp->tokens;
+   struct brw_instruction *end_inst, *last_inst;
+   struct tgsi_parse_context parse;
+   struct tgsi_full_instruction *inst;
+
+   if (BRW_DEBUG & DEBUG_VS)
+      tgsi_dump(c->vp->tokens, 0); 
+
+   c->stack_index = brw_indirect(0, 0);
+
+   brw_set_compression_control(p, BRW_COMPRESSION_NONE);
+   brw_set_access_mode(p, BRW_ALIGN_16);
+   
+
+   /* Static register allocation
+    */
+   brw_vs_alloc_regs(c);
+
+   if (c->vp->has_flow_control) {
+      brw_MOV(p, get_addr_reg(c->stack_index), brw_address(c->stack));
+   }
+
+   /* Instructions
+    */
+   tgsi_parse_init( &parse, tokens );
+   while( !tgsi_parse_end_of_tokens( &parse ) ) {
+      tgsi_parse_token( &parse );
+
+      switch( parse.FullToken.Token.Type ) {
+      case TGSI_TOKEN_TYPE_DECLARATION:
+      case TGSI_TOKEN_TYPE_IMMEDIATE:
+        break;
+
+      case TGSI_TOKEN_TYPE_INSTRUCTION:
+         inst = &parse.FullToken.FullInstruction;
+        emit_insn( c, inst );
+         break;
+
+      default:
+         assert( 0 );
+      }
+   }
+   tgsi_parse_free( &parse );
+
+   end_inst = &p->store[c->end_offset];
+   last_inst = &p->store[p->nr_insn];
+
+   /* The END instruction will be patched to jump to this code */
+   emit_vertex_write(c);
+
+   post_vs_emit(c, end_inst, last_inst);
+
+   if (BRW_DEBUG & DEBUG_VS) {
+      debug_printf("vs-native:\n");
+      brw_disasm(stderr, p->store, p->nr_insn);
+   }
+}
diff --git a/src/gallium/drivers/i965/brw_vs_state.c b/src/gallium/drivers/i965/brw_vs_state.c
new file mode 100644 (file)
index 0000000..dadbb62
--- /dev/null
@@ -0,0 +1,201 @@
+/*
+ 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 "util/u_math.h"
+
+
+#include "brw_debug.h"
+#include "brw_context.h"
+#include "brw_state.h"
+#include "brw_defines.h"
+
+struct brw_vs_unit_key {
+   unsigned int total_grf;
+   unsigned int urb_entry_read_length;
+   unsigned int curb_entry_read_length;
+
+   unsigned int curbe_offset;
+
+   unsigned int nr_urb_entries, urb_size;
+
+   unsigned int nr_surfaces;
+};
+
+static void
+vs_unit_populate_key(struct brw_context *brw, struct brw_vs_unit_key *key)
+{
+   memset(key, 0, sizeof(*key));
+
+   /* CACHE_NEW_VS_PROG */
+   key->total_grf = brw->vs.prog_data->total_grf;
+   key->urb_entry_read_length = brw->vs.prog_data->urb_read_length;
+   key->curb_entry_read_length = brw->vs.prog_data->curb_read_length;
+
+   /* BRW_NEW_URB_FENCE */
+   key->nr_urb_entries = brw->urb.nr_vs_entries;
+   key->urb_size = brw->urb.vsize;
+
+   /* BRW_NEW_NR_VS_SURFACES */
+   key->nr_surfaces = brw->vs.nr_surfaces;
+
+   /* PIPE_NEW_CLIP */
+   if (brw->curr.ucp.nr) {
+      /* Note that we read in the userclip planes as well, hence
+       * clip_start:
+       */
+      key->curbe_offset = brw->curbe.clip_start;
+   }
+   else {
+      key->curbe_offset = brw->curbe.vs_start;
+   }
+}
+
+static enum pipe_error
+vs_unit_create_from_key(struct brw_context *brw, 
+                        struct brw_vs_unit_key *key,
+                        struct brw_winsys_reloc *reloc,
+                        struct brw_winsys_buffer **bo_out)
+{
+   enum pipe_error ret;
+   struct brw_vs_unit_state vs;
+   int chipset_max_threads;
+
+   memset(&vs, 0, sizeof(vs));
+
+   vs.thread0.kernel_start_pointer = 0; /* reloc */
+   vs.thread0.grf_reg_count = align(key->total_grf, 16) / 16 - 1;
+   vs.thread1.floating_point_mode = BRW_FLOATING_POINT_NON_IEEE_754;
+   /* Choosing multiple program flow means that we may get 2-vertex threads,
+    * which will have the channel mask for dwords 4-7 enabled in the thread,
+    * and those dwords will be written to the second URB handle when we
+    * brw_urb_WRITE() results.
+    */
+   vs.thread1.single_program_flow = 0;
+
+   if (BRW_IS_IGDNG(brw))
+      vs.thread1.binding_table_entry_count = 0; /* hardware requirement */
+   else
+      vs.thread1.binding_table_entry_count = key->nr_surfaces;
+
+   vs.thread3.urb_entry_read_length = key->urb_entry_read_length;
+   vs.thread3.const_urb_entry_read_length = key->curb_entry_read_length;
+   vs.thread3.dispatch_grf_start_reg = 1;
+   vs.thread3.urb_entry_read_offset = 0;
+   vs.thread3.const_urb_entry_read_offset = key->curbe_offset * 2;
+
+   if (BRW_IS_IGDNG(brw))
+       vs.thread4.nr_urb_entries = key->nr_urb_entries >> 2;
+   else
+       vs.thread4.nr_urb_entries = key->nr_urb_entries;
+
+   vs.thread4.urb_entry_allocation_size = key->urb_size - 1;
+
+   if (BRW_IS_IGDNG(brw))
+      chipset_max_threads = 72;
+   else if (BRW_IS_G4X(brw))
+      chipset_max_threads = 32;
+   else
+      chipset_max_threads = 16;
+
+   vs.thread4.max_threads = CLAMP(key->nr_urb_entries / 2,
+                                 1, chipset_max_threads) - 1;
+
+   if (BRW_DEBUG & DEBUG_SINGLE_THREAD)
+      vs.thread4.max_threads = 0;
+
+   /* No samplers for ARB_vp programs:
+    */
+   /* It has to be set to 0 for IGDNG
+    */
+   vs.vs5.sampler_count = 0;
+
+   if (BRW_DEBUG & DEBUG_STATS)
+      vs.thread4.stats_enable = 1;
+
+   /* Vertex program always enabled:
+    */
+   vs.vs6.vs_enable = 1;
+
+   ret = brw_upload_cache(&brw->cache, BRW_VS_UNIT,
+                          key, sizeof(*key),
+                          reloc, 1,
+                          &vs, sizeof(vs),
+                          NULL, NULL,
+                          bo_out);
+   if (ret)
+      return ret;
+
+   return PIPE_OK;
+}
+
+static int prepare_vs_unit(struct brw_context *brw)
+{
+   struct brw_vs_unit_key key;
+   enum pipe_error ret;
+   struct brw_winsys_reloc reloc[1];
+   unsigned grf_reg_count;
+
+   vs_unit_populate_key(brw, &key);
+
+   grf_reg_count = (align(key.total_grf, 16) / 16 - 1);
+
+   /* Emit VS program relocation */
+   make_reloc(&reloc[0],
+              BRW_USAGE_STATE,
+              grf_reg_count << 1,
+              offsetof(struct brw_vs_unit_state, thread0),
+              brw->vs.prog_bo);
+
+
+   if (brw_search_cache(&brw->cache, BRW_VS_UNIT,
+                        &key, sizeof(key),
+                        reloc, 1,
+                        NULL,
+                        &brw->vs.state_bo))
+      return PIPE_OK;
+
+   ret = vs_unit_create_from_key(brw, &key, reloc, &brw->vs.state_bo);
+   if (ret)
+      return ret;
+
+   return PIPE_OK;
+}
+
+const struct brw_tracked_state brw_vs_unit = {
+   .dirty = {
+      .mesa  = (PIPE_NEW_CLIP),
+      .brw   = (BRW_NEW_CURBE_OFFSETS |
+                BRW_NEW_NR_VS_SURFACES |
+               BRW_NEW_URB_FENCE),
+      .cache = CACHE_NEW_VS_PROG
+   },
+   .prepare = prepare_vs_unit,
+};
diff --git a/src/gallium/drivers/i965/brw_vs_surface_state.c b/src/gallium/drivers/i965/brw_vs_surface_state.c
new file mode 100644 (file)
index 0000000..177a517
--- /dev/null
@@ -0,0 +1,232 @@
+/*
+ Copyright (C) Intel Corp.  2006.  All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ **********************************************************************/
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  */
+
+#include "brw_context.h"
+#include "brw_state.h"
+#include "brw_defines.h"
+#include "brw_winsys.h"
+
+/* XXX: disabled true constant buffer functionality
+ */
+
+
+/* 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.
+ */
+#if 0
+static struct brw_winsys_buffer *
+brw_vs_update_constant_buffer(struct brw_context *brw)
+{
+   /* XXX: true constant buffers
+    */
+   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 = brw->sws->bo_alloc(brw->sws, 
+                                    BRW_BUFFER_TYPE_SHADER_CONSTANTS,
+                                    size, 64);
+
+   /* _NEW_PROGRAM_CONSTANTS */
+   brw->sws->bo_subdata(const_buffer, 0, size, params->ParameterValues,
+                        NULL, 0);
+
+   return const_buffer;
+}
+#endif
+
+/**
+ * Update the surface state for a VS constant buffer.
+ *
+ * Sets brw->vs.surf_bo[surf] and brw->vp->const_buffer.
+ */
+#if 0
+static void
+brw_update_vs_constant_surface( struct brw_context *brw,
+                                GLuint surf)
+{
+   struct brw_surface_key key;
+   struct pipe_buffer *cb = brw->curr.vs_constants;
+   enum pipe_error ret;
+
+   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.
+    */
+   ret = brw_vs_update_constant_buffer(brw, &vp->const_buffer);
+   if (ret)
+      return ret;
+
+   /* If there's no constant buffer, then no surface BO is needed to point at
+    * it.
+    */
+   if (vp->const_buffer == NULL) {
+      bo_reference(brw->vs.surf_bo[surf], NULL);
+      return PIPE_OK;
+   }
+
+   memset(&key, 0, sizeof(key));
+
+   key.format = PIPE_FORMAT_R32G32B32A32_FLOAT;
+   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);
+   */
+
+   if (brw_search_cache(&brw->surface_cache,
+                        BRW_SS_SURFACE,
+                        &key, sizeof(key),
+                        &key.bo, key.bo ? 1 : 0,
+                        NULL,
+                        &brw->vs.surf_bo[surf]))
+      return PIPE_OK;
+
+   ret = brw_create_constant_surface(brw, &key
+                                     &brw->vs.surf_bo[surf]);
+   if (ret)
+      return ret;
+   
+   return PIPE_OK;
+}
+#endif
+
+
+/**
+ * Constructs the binding table for the VS surface state.
+ */
+static enum pipe_error
+brw_vs_get_binding_table(struct brw_context *brw,
+                         struct brw_winsys_buffer **bo_out)
+{
+#if 0
+   static GLuint data[BRW_VS_MAX_SURF]; /* always zero */
+   struct brw_winsys_reloc reloc[BRW_VS_MAX_SURF];
+   int i;
+
+   /* Emit binding table relocations to surface state */
+   for (i = 0; i < BRW_VS_MAX_SURF; i++) {
+      make_reloc(&reloc[i],
+                 BRW_USAGE_STATE,
+                 0,
+                 i * 4,
+                 brw->vs.surf_bo[i]);
+   }
+   
+   ret = brw_cache_data( &brw->surface_cache, 
+                         BRW_SS_SURF_BIND,
+                         NULL, 0,
+                         reloc, nr_reloc,
+                         data, sizeof data,
+                         NULL, NULL,
+                         bo_out);
+   if (ret)
+      return ret;
+
+   FREE(data);
+   return PIPE_OK;
+#else
+   return PIPE_OK;
+#endif
+}
+
+/**
+ * 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 enum pipe_error prepare_vs_surfaces(struct brw_context *brw )
+{
+   enum pipe_error ret;
+
+#if 0
+   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;
+   }
+#endif
+
+   /* 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) {
+      ret = brw_vs_get_binding_table(brw, &brw->vs.bind_bo);
+      if (ret)
+         return ret;
+   }
+
+   return PIPE_OK;
+}
+
+const struct brw_tracked_state brw_vs_surfaces = {
+   .dirty = {
+      .mesa = (PIPE_NEW_VERTEX_CONSTANTS |
+              PIPE_NEW_VERTEX_SHADER),
+      .brw = 0,
+      .cache = 0
+   },
+   .prepare = prepare_vs_surfaces,
+};
+
+
+
diff --git a/src/gallium/drivers/i965/brw_winsys.h b/src/gallium/drivers/i965/brw_winsys.h
new file mode 100644 (file)
index 0000000..a242e31
--- /dev/null
@@ -0,0 +1,309 @@
+/**************************************************************************
+ *
+ * Copyright © 2009 Jakob Bornecrantz
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **************************************************************************/
+
+#ifndef BRW_WINSYS_H
+#define BRW_WINSYS_H
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_defines.h"
+#include "pipe/p_refcnt.h"
+
+struct brw_winsys;
+struct pipe_fence_handle;
+
+/* Not sure why the winsys needs this:
+ */
+#define BRW_BATCH_SIZE (32*1024)
+
+struct brw_winsys_screen;
+
+/* Need a tiny bit of information inside the abstract buffer struct:
+ */
+struct brw_winsys_buffer {
+   struct pipe_reference reference;
+   struct brw_winsys_screen *sws;
+   unsigned size;
+};
+
+
+/* Should be possible to validate usages above against buffer creation
+ * types, below:
+ */
+enum brw_buffer_type
+{
+   BRW_BUFFER_TYPE_TEXTURE,
+   BRW_BUFFER_TYPE_SCANOUT,          /**< a texture used for scanning out from */
+   BRW_BUFFER_TYPE_VERTEX,
+   BRW_BUFFER_TYPE_CURBE,
+   BRW_BUFFER_TYPE_QUERY,
+   BRW_BUFFER_TYPE_SHADER_CONSTANTS,
+   BRW_BUFFER_TYPE_SHADER_SCRATCH,
+   BRW_BUFFER_TYPE_BATCH,
+   BRW_BUFFER_TYPE_GENERAL_STATE,
+   BRW_BUFFER_TYPE_SURFACE_STATE,
+   BRW_BUFFER_TYPE_PIXEL,            /* image uploads, pbo's, etc */
+   BRW_BUFFER_TYPE_GENERIC,          /* unknown */
+   BRW_BUFFER_TYPE_MAX               /* Count of possible values */
+};
+
+
+/* Describe the usage of a particular buffer in a relocation.  The DRM
+ * winsys will translate these back to GEM read/write domain flags.
+ */
+enum brw_buffer_usage {
+   BRW_USAGE_STATE,         /* INSTRUCTION, 0 */
+   BRW_USAGE_QUERY_RESULT,  /* INSTRUCTION, INSTRUCTION */
+   BRW_USAGE_RENDER_TARGET, /* RENDER,      0 */
+   BRW_USAGE_DEPTH_BUFFER,  /* RENDER,      RENDER */
+   BRW_USAGE_BLIT_SOURCE,   /* RENDER,      0 */
+   BRW_USAGE_BLIT_DEST,     /* RENDER,      RENDER */
+   BRW_USAGE_SAMPLER,       /* SAMPLER,     0 */
+   BRW_USAGE_VERTEX,        /* VERTEX,      0 */
+   BRW_USAGE_SCRATCH,       /* 0,           0 */
+   BRW_USAGE_MAX
+};
+
+enum brw_buffer_data_type {
+   BRW_DATA_GS_CC_VP,
+   BRW_DATA_GS_CC_UNIT,
+   BRW_DATA_GS_WM_PROG,
+   BRW_DATA_GS_SAMPLER_DEFAULT_COLOR,
+   BRW_DATA_GS_SAMPLER,
+   BRW_DATA_GS_WM_UNIT,
+   BRW_DATA_GS_SF_PROG,
+   BRW_DATA_GS_SF_VP,
+   BRW_DATA_GS_SF_UNIT,
+   BRW_DATA_GS_VS_UNIT,
+   BRW_DATA_GS_VS_PROG,
+   BRW_DATA_GS_GS_UNIT,
+   BRW_DATA_GS_GS_PROG,
+   BRW_DATA_GS_CLIP_VP,
+   BRW_DATA_GS_CLIP_UNIT,
+   BRW_DATA_GS_CLIP_PROG,
+   BRW_DATA_SS_SURFACE,
+   BRW_DATA_SS_SURF_BIND,
+   BRW_DATA_CONSTANT_BUFFER,
+   BRW_DATA_BATCH_BUFFER,
+   BRW_DATA_OTHER,
+   BRW_DATA_MAX
+};
+
+
+/* Matches the i915_drm definitions:
+ */
+#define BRW_TILING_NONE  0
+#define BRW_TILING_X     1
+#define BRW_TILING_Y     2
+
+
+/* Relocations to be applied with subdata in a call to sws->bo_subdata, below.
+ *
+ * Effectively this encodes:
+ *
+ *    (unsigned *)(subdata + offset) = bo->offset + delta
+ */
+struct brw_winsys_reloc {
+   enum brw_buffer_usage usage; /* debug only */
+   unsigned delta;
+   unsigned offset;
+   struct brw_winsys_buffer *bo;
+};
+
+static INLINE void make_reloc(struct brw_winsys_reloc *reloc,
+                              enum brw_buffer_usage usage,
+                              unsigned delta,
+                              unsigned offset,
+                              struct brw_winsys_buffer *bo)
+{
+   reloc->usage = usage;
+   reloc->delta = delta;
+   reloc->offset = offset;
+   reloc->bo = bo;              /* Note - note taking a reference yet */
+}
+
+
+
+struct brw_winsys_screen {
+
+
+   /**
+    * Buffer functions.
+    */
+
+   /*@{*/
+   /**
+    * Create a buffer.
+    */
+   enum pipe_error (*bo_alloc)(struct brw_winsys_screen *sws,
+                               enum brw_buffer_type type,
+                               unsigned size,
+                               unsigned alignment,
+                               struct brw_winsys_buffer **bo_out);
+
+   /* Destroy a buffer when our refcount goes to zero:
+    */
+   void (*bo_destroy)(struct brw_winsys_buffer *buffer);
+
+   /* delta -- added to b2->offset, and written into buffer
+    * offset -- location above value is written to within buffer
+    */
+   enum pipe_error (*bo_emit_reloc)(struct brw_winsys_buffer *buffer,
+                                    enum brw_buffer_usage usage,
+                                    unsigned delta,
+                                    unsigned offset,
+                                    struct brw_winsys_buffer *b2);
+
+   enum pipe_error (*bo_exec)(struct brw_winsys_buffer *buffer,
+                              unsigned bytes_used);
+
+   enum pipe_error (*bo_subdata)(struct brw_winsys_buffer *buffer,
+                                 enum brw_buffer_data_type data_type,
+                                 size_t offset,
+                                 size_t size,
+                                 const void *data,
+                                 const struct brw_winsys_reloc *reloc,
+                                 unsigned nr_reloc );
+
+   boolean (*bo_is_busy)(struct brw_winsys_buffer *buffer);
+   boolean (*bo_references)(struct brw_winsys_buffer *a,
+                            struct brw_winsys_buffer *b);
+
+   /* XXX: couldn't this be handled by returning true/false on
+    * bo_emit_reloc?
+    */
+   enum pipe_error (*check_aperture_space)(struct brw_winsys_screen *iws,
+                                           struct brw_winsys_buffer **buffers,
+                                           unsigned count);
+
+   /**
+    * Map a buffer.
+    */
+   void *(*bo_map)(struct brw_winsys_buffer *buffer,
+                   enum brw_buffer_data_type data_type,
+                   unsigned offset,
+                   unsigned length,
+                   boolean write,
+                   boolean discard,
+                   boolean flush_explicit);
+
+   void (*bo_flush_range)(struct brw_winsys_buffer *buffer,
+                          unsigned offset,
+                          unsigned length);
+
+   /**
+    * Unmap a buffer.
+    */
+   void (*bo_unmap)(struct brw_winsys_buffer *buffer);
+   /*@}*/
+
+   
+   /* Wait for buffer to go idle.  Similar to map+unmap, but doesn't
+    * mark buffer contents as dirty.
+    */
+   void (*bo_wait_idle)(struct brw_winsys_buffer *buffer);
+   
+   /**
+    * Destroy the winsys.
+    */
+   void (*destroy)(struct brw_winsys_screen *iws);
+};
+
+static INLINE void *
+bo_map_read(struct brw_winsys_screen *sws, struct brw_winsys_buffer *buf)
+{
+   return sws->bo_map( buf,
+                       BRW_DATA_OTHER,
+                       0, buf->size,
+                       FALSE, FALSE, FALSE );
+}
+
+static INLINE void
+bo_reference(struct brw_winsys_buffer **ptr, struct brw_winsys_buffer *buf)
+{
+   struct brw_winsys_buffer *old_buf = *ptr;
+
+   if (pipe_reference(&(*ptr)->reference, &buf->reference))
+      old_buf->sws->bo_destroy(old_buf);
+
+   *ptr = buf;
+}
+
+
+/**
+ * Create brw pipe_screen.
+ */
+struct pipe_screen *brw_create_screen(struct brw_winsys_screen *iws, unsigned pci_id);
+
+/**
+ * Create a brw pipe_context.
+ */
+struct pipe_context *brw_create_context(struct pipe_screen *screen);
+
+/**
+ * Get the brw_winsys buffer backing the texture.
+ *
+ * TODO UGLY
+ */
+struct pipe_texture;
+boolean brw_texture_get_winsys_buffer(struct pipe_texture *texture,
+                                      struct brw_winsys_buffer **buffer,
+                                      unsigned *stride);
+
+/**
+ * Wrap a brw_winsys buffer with a texture blanket.
+ *
+ * TODO UGLY
+ */
+struct pipe_texture * 
+brw_texture_blanket_winsys_buffer(struct pipe_screen *screen,
+                                  const struct pipe_texture *template,
+                                  unsigned pitch,
+                                 unsigned tiling,
+                                  struct brw_winsys_buffer *buffer);
+
+
+/*************************************************************************
+ * Cooperative dumping between winsys and driver.  TODO: make this
+ * driver-only by wrapping calls to winsys->bo_subdata().
+ */
+
+#ifdef DEBUG
+extern int BRW_DUMP;
+#else
+#define BRW_DUMP 0
+#endif 
+
+#define DUMP_ASM               0x1
+#define DUMP_STATE             0x2
+#define DUMP_BATCH             0x4
+
+void brw_dump_data( unsigned pci_id,
+                   enum brw_buffer_data_type data_type,
+                   unsigned offset,
+                   const void *data,
+                   size_t size );
+
+
+#endif
diff --git a/src/gallium/drivers/i965/brw_winsys_debug.c b/src/gallium/drivers/i965/brw_winsys_debug.c
new file mode 100644 (file)
index 0000000..f8f6a53
--- /dev/null
@@ -0,0 +1,87 @@
+#include "brw_winsys.h"
+#include "brw_disasm.h"
+#include "brw_structs_dump.h"
+#include "brw_structs.h"
+#include "intel_decode.h"
+
+
+void brw_dump_data( unsigned pci_id,
+                   enum brw_buffer_data_type data_type,
+                   unsigned offset,
+                   const void *data,
+                   size_t size )
+{
+   if (BRW_DUMP & DUMP_ASM) {
+      switch (data_type) {
+      case BRW_DATA_GS_WM_PROG:
+      case BRW_DATA_GS_SF_PROG:
+      case BRW_DATA_GS_VS_PROG:
+      case BRW_DATA_GS_GS_PROG:
+      case BRW_DATA_GS_CLIP_PROG:
+         brw_disasm( stderr, data, size / sizeof(struct brw_instruction) );
+         break;
+      default:
+         break;
+      }
+   }
+
+   if (BRW_DUMP & DUMP_STATE) {
+      switch (data_type) {
+      case BRW_DATA_GS_CC_VP:
+         brw_dump_cc_viewport( data );
+         break;
+      case BRW_DATA_GS_CC_UNIT:
+         brw_dump_cc_unit_state( data );
+         break;
+      case BRW_DATA_GS_SAMPLER_DEFAULT_COLOR:
+         brw_dump_sampler_default_color( data );
+         break;
+      case BRW_DATA_GS_SAMPLER:
+         brw_dump_sampler_state( data );
+         break;
+      case BRW_DATA_GS_WM_UNIT:
+         brw_dump_wm_unit_state( data );
+         break;
+      case BRW_DATA_GS_SF_VP:
+         brw_dump_sf_viewport( data );
+         break;
+      case BRW_DATA_GS_SF_UNIT:
+         brw_dump_sf_unit_state( data );
+         break;
+      case BRW_DATA_GS_VS_UNIT:
+         brw_dump_vs_unit_state( data );
+         break;
+      case BRW_DATA_GS_GS_UNIT:
+         brw_dump_gs_unit_state( data );
+         break;
+      case BRW_DATA_GS_CLIP_VP:
+         brw_dump_clipper_viewport( data );
+         break;
+      case BRW_DATA_GS_CLIP_UNIT:
+         brw_dump_clip_unit_state( data );
+         break;
+      case BRW_DATA_SS_SURFACE:
+         brw_dump_surface_state( data );
+         break;
+      case BRW_DATA_SS_SURF_BIND:
+         break;
+      case BRW_DATA_OTHER:
+         break;
+      case BRW_DATA_CONSTANT_BUFFER:
+         break;
+      default:
+         break;
+      }
+   }
+
+   if (BRW_DUMP & DUMP_BATCH) {
+      switch (data_type) {
+      case BRW_DATA_BATCH_BUFFER:
+         intel_decode(data, size / 4, offset, pci_id);
+         break;
+      default:
+         break;
+      }
+   }
+}
+
diff --git a/src/gallium/drivers/i965/brw_wm.c b/src/gallium/drivers/i965/brw_wm.c
new file mode 100644 (file)
index 0000000..fdf820a
--- /dev/null
@@ -0,0 +1,319 @@
+/*
+ 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 "tgsi/tgsi_info.h"
+
+#include "brw_context.h"
+#include "brw_screen.h"
+#include "brw_util.h"
+#include "brw_wm.h"
+#include "brw_state.h"
+#include "brw_debug.h"
+#include "brw_pipe_rast.h"
+
+
+/** Return number of src args for given instruction */
+GLuint brw_wm_nr_args( GLuint opcode )
+{
+   switch (opcode) {
+   case WM_FRONTFACING:
+   case WM_PIXELXY:
+      return 0;
+   case WM_CINTERP:
+   case WM_WPOSXY:
+   case WM_DELTAXY:
+      return 1;
+   case WM_LINTERP:
+   case WM_PIXELW:
+      return 2;
+   case WM_FB_WRITE:
+   case WM_PINTERP:
+      return 3;
+   case TGSI_OPCODE_TEX:
+   case TGSI_OPCODE_TXP:
+   case TGSI_OPCODE_TXB:
+   case TGSI_OPCODE_TXD:
+      /* sampler arg is held as a field in the instruction, not in an
+       * actual register:
+       */
+      return tgsi_get_opcode_info(opcode)->num_src - 1;
+
+   default:
+      assert(opcode < MAX_OPCODE);
+      return tgsi_get_opcode_info(opcode)->num_src;
+   }
+}
+
+
+GLuint brw_wm_is_scalar_result( GLuint opcode )
+{
+   switch (opcode) {
+   case TGSI_OPCODE_COS:
+   case TGSI_OPCODE_EX2:
+   case TGSI_OPCODE_LG2:
+   case TGSI_OPCODE_POW:
+   case TGSI_OPCODE_RCP:
+   case TGSI_OPCODE_RSQ:
+   case TGSI_OPCODE_SIN:
+   case TGSI_OPCODE_DP3:
+   case TGSI_OPCODE_DP4:
+   case TGSI_OPCODE_DPH:
+   case TGSI_OPCODE_DST:
+      return 1;
+      
+   default:
+      return 0;
+   }
+}
+
+
+/**
+ * Do GPU code generation for shaders without flow control.  Shaders
+ * without flow control instructions can more readily be analysed for
+ * SSA-style optimizations.
+ */
+static void
+brw_wm_linear_shader_emit(struct brw_context *brw, struct brw_wm_compile *c)
+{
+   /* Augment fragment program.  Add instructions for pre- and
+    * post-fragment-program tasks such as interpolation and fogging.
+    */
+   brw_wm_pass_fp(c);
+
+   /* Translate to intermediate representation.  Build register usage
+    * chains.
+    */
+   brw_wm_pass0(c);
+
+   /* Dead code removal.
+    */
+   brw_wm_pass1(c);
+
+   /* Register allocation.
+    * Divide by two because we operate on 16 pixels at a time and require
+    * two GRF entries for each logical shader register.
+    */
+   c->grf_limit = BRW_WM_MAX_GRF / 2;
+
+   brw_wm_pass2(c);
+
+   /* how many general-purpose registers are used */
+   c->prog_data.total_grf = c->max_wm_grf;
+
+   /* Scratch space is used for register spilling */
+   if (c->last_scratch) {
+      c->prog_data.total_scratch = c->last_scratch + 0x40;
+   }
+   else {
+      c->prog_data.total_scratch = 0;
+   }
+
+   /* Emit GEN4 code.
+    */
+   brw_wm_emit(c);
+}
+
+
+/**
+ * All Mesa program -> GPU code generation goes through this function.
+ * Depending on the instructions used (i.e. flow control instructions)
+ * we'll use one of two code generators.
+ */
+static enum pipe_error do_wm_prog( struct brw_context *brw,
+                                   struct brw_fragment_shader *fp, 
+                                   struct brw_wm_prog_key *key,
+                                   struct brw_winsys_buffer **bo_out)
+{
+   enum pipe_error ret;
+   struct brw_wm_compile *c;
+   const GLuint *program;
+   GLuint program_size;
+
+   if (brw->wm.compile_data == NULL) {
+      brw->wm.compile_data = MALLOC(sizeof(*brw->wm.compile_data));
+      if (!brw->wm.compile_data) 
+         return PIPE_ERROR_OUT_OF_MEMORY;
+   }
+
+   c = brw->wm.compile_data;
+   memset(c, 0, sizeof *c);
+
+   c->key = *key;
+   c->fp = fp;
+   c->env_param = NULL; /*brw->intel.ctx.FragmentProgram.Parameters;*/
+
+   brw_init_compile(brw, &c->func);
+
+   /*
+    * Shader which use GLSL features such as flow control are handled
+    * differently from "simple" shaders.
+    */
+   if (fp->has_flow_control) {
+      c->dispatch_width = 8;
+      /* XXX: GLSL support
+       */
+      exit(1);
+      /* brw_wm_branching_shader_emit(brw, c); */
+   }
+   else {
+      c->dispatch_width = 16;
+      brw_wm_linear_shader_emit(brw, c);
+   }
+
+   if (BRW_DEBUG & DEBUG_WM)
+      debug_printf("\n");
+
+   /* get the program
+    */
+   ret = brw_get_program(&c->func, &program, &program_size);
+   if (ret)
+      return ret;
+
+   ret = brw_upload_cache( &brw->cache, BRW_WM_PROG,
+                           &c->key, sizeof(c->key),
+                           NULL, 0,
+                           program, program_size,
+                           &c->prog_data,
+                           &brw->wm.prog_data,
+                           bo_out );
+   if (ret)
+      return ret;
+
+   return PIPE_OK;
+}
+
+
+
+static void brw_wm_populate_key( struct brw_context *brw,
+                                struct brw_wm_prog_key *key )
+{
+   unsigned lookup, line_aa;
+   unsigned i;
+
+   memset(key, 0, sizeof(*key));
+
+   /* PIPE_NEW_FRAGMENT_SHADER
+    * PIPE_NEW_DEPTH_STENCIL_ALPHA
+    */
+   lookup = (brw->curr.zstencil->iz_lookup |
+            brw->curr.fragment_shader->iz_lookup);
+
+
+   /* PIPE_NEW_RAST
+    * BRW_NEW_REDUCED_PRIMITIVE 
+    */
+   switch (brw->reduced_primitive) {
+   case PIPE_PRIM_POINTS:
+      line_aa = AA_NEVER;
+      break;
+   case PIPE_PRIM_LINES:
+      line_aa = (brw->curr.rast->templ.line_smooth ? 
+                 AA_ALWAYS : AA_NEVER);
+      break;
+   default:
+      line_aa = brw->curr.rast->unfilled_aa_line;
+      break;
+   }
+        
+   brw_wm_lookup_iz(line_aa,
+                   lookup,
+                   brw->curr.fragment_shader->uses_depth,
+                   key);
+
+   /* PIPE_NEW_RAST */
+   key->flat_shade = brw->curr.rast->templ.flatshade;
+
+
+   /* PIPE_NEW_BOUND_TEXTURES */
+   for (i = 0; i < brw->curr.num_textures; i++) {
+      const struct brw_texture *tex = brw_texture(brw->curr.texture[i]);
+        
+      if (tex->base.format == PIPE_FORMAT_YCBCR)
+        key->yuvtex_mask |= 1 << i;
+
+      if (tex->base.format == PIPE_FORMAT_YCBCR_REV)
+        key->yuvtex_swap_mask |= 1 << i;
+
+      /* XXX: shadow texture
+       */
+      /* key->shadowtex_mask |= 1<<i; */
+   }
+
+   /* CACHE_NEW_VS_PROG */
+   key->vp_nr_outputs = brw->vs.prog_data->nr_outputs;
+
+   key->nr_cbufs = brw->curr.fb.nr_cbufs;
+
+   key->nr_inputs = brw->curr.fragment_shader->info.num_inputs;
+
+   /* The unique fragment program ID */
+   key->program_string_id = brw->curr.fragment_shader->id;
+}
+
+
+static enum pipe_error brw_prepare_wm_prog(struct brw_context *brw)
+{
+   struct brw_wm_prog_key key;
+   struct brw_fragment_shader *fs = brw->curr.fragment_shader;
+   enum pipe_error ret;
+     
+   brw_wm_populate_key(brw, &key);
+
+   /* Make an early check for the key.
+    */
+   if (brw_search_cache(&brw->cache, BRW_WM_PROG,
+                        &key, sizeof(key),
+                        NULL, 0,
+                        &brw->wm.prog_data,
+                        &brw->wm.prog_bo))
+      return PIPE_OK;
+
+   ret = do_wm_prog(brw, fs, &key, &brw->wm.prog_bo);
+   if (ret)
+      return ret;
+
+   return PIPE_OK;
+}
+
+
+const struct brw_tracked_state brw_wm_prog = {
+   .dirty = {
+      .mesa  = (PIPE_NEW_FRAGMENT_SHADER |
+               PIPE_NEW_DEPTH_STENCIL_ALPHA |
+               PIPE_NEW_RAST |
+               PIPE_NEW_NR_CBUFS |
+               PIPE_NEW_BOUND_TEXTURES),
+      .brw   = (BRW_NEW_WM_INPUT_DIMENSIONS |
+               BRW_NEW_REDUCED_PRIMITIVE),
+      .cache = CACHE_NEW_VS_PROG,
+   },
+   .prepare = brw_prepare_wm_prog
+};
+
diff --git a/src/gallium/drivers/i965/brw_wm.h b/src/gallium/drivers/i965/brw_wm.h
new file mode 100644 (file)
index 0000000..f1ca9f6
--- /dev/null
@@ -0,0 +1,344 @@
+/*
+ Copyright (C) Intel Corp.  2006.  All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ **********************************************************************/
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  */
+              
+
+#ifndef BRW_WM_H
+#define BRW_WM_H
+
+#include "brw_context.h"
+#include "brw_eu.h"
+
+#define SATURATE (1<<5)
+
+/* A big lookup table is used to figure out which and how many
+ * additional regs will inserted before the main payload in the WM
+ * program execution.  These mainly relate to depth and stencil
+ * processing and the early-depth-test optimization.
+ */
+#define IZ_PS_KILL_ALPHATEST_BIT    0x1
+#define IZ_PS_COMPUTES_DEPTH_BIT    0x2
+#define IZ_DEPTH_WRITE_ENABLE_BIT   0x4
+#define IZ_DEPTH_TEST_ENABLE_BIT    0x8
+#define IZ_STENCIL_WRITE_ENABLE_BIT 0x10
+#define IZ_STENCIL_TEST_ENABLE_BIT  0x20
+#define IZ_BIT_MAX                  0x40
+
+#define AA_NEVER     0
+#define AA_SOMETIMES 1
+#define AA_ALWAYS    2
+
+struct brw_wm_prog_key {
+   GLuint source_depth_reg:3;
+   GLuint aa_dest_stencil_reg:3;
+   GLuint dest_depth_reg:3;
+   GLuint nr_depth_regs:3;
+   GLuint computes_depth:1;
+   GLuint source_depth_to_render_target:1;
+   GLuint flat_shade:1;
+   GLuint runtime_check_aads_emit:1;
+
+   GLuint shadowtex_mask:16;
+   GLuint yuvtex_mask:16;
+   GLuint yuvtex_swap_mask:16; /* UV swaped */
+
+   GLuint vp_nr_outputs:6;
+   GLuint nr_inputs:6;
+   GLuint nr_cbufs:3;
+   GLuint has_flow_control:1;
+
+   GLuint program_string_id;
+};
+
+
+/* A bit of a glossary:
+ *
+ * brw_wm_value: A computed value or program input.  Values are
+ * constant, they are created once and are never modified.  When a
+ * fragment program register is written or overwritten, new values are
+ * created fresh, preserving the rule that values are constant.
+ *
+ * brw_wm_ref: A reference to a value.  Wherever a value used is by an
+ * instruction or as a program output, that is tracked with an
+ * instance of this struct.  All references to a value occur after it
+ * is created.  After the last reference, a value is dead and can be
+ * discarded.
+ *
+ * brw_wm_grf: Represents a physical hardware register.  May be either
+ * empty or hold a value.  Register allocation is the process of
+ * assigning values to grf registers.  This occurs in pass2 and the
+ * brw_wm_grf struct is not used before that.
+ *
+ * Fragment program registers: These are time-varying constructs that
+ * are hard to reason about and which we translate away in pass0.  A
+ * single fragment program register element (eg. temp[0].x) will be
+ * translated to one or more brw_wm_value structs, one for each time
+ * that temp[0].x is written to during the program. 
+ */
+
+
+
+/* Used in pass2 to track register allocation.
+ */
+struct brw_wm_grf {
+   struct brw_wm_value *value;
+   GLuint nextuse;
+};
+
+struct brw_wm_value {
+   struct brw_reg hw_reg;      /* emitted to this reg, may not always be there */
+   struct brw_wm_ref *lastuse;
+   struct brw_wm_grf *resident; 
+   GLuint contributes_to_output:1;
+   GLuint spill_slot:16;       /* if non-zero, spill immediately after calculation */
+};
+
+struct brw_wm_ref {
+   struct brw_reg hw_reg;      /* nr filled in in pass2, everything else, pass0 */
+   struct brw_wm_value *value;
+   struct brw_wm_ref *prevuse;
+   GLuint unspill_reg:7;       /* unspill to reg */
+   GLuint emitted:1;
+   GLuint insn:24;
+};
+
+struct brw_wm_instruction {
+   struct brw_wm_value *dst[4];
+   struct brw_wm_ref *src[3][4];
+   GLuint opcode:8;
+   GLuint saturate:1;
+   GLuint writemask:4;
+   GLuint sampler:4;
+   GLuint tex_unit:4;   /* texture/sampler unit for texture instructions */
+   GLuint target:4;     /* TGSI_TEXTURE_x for texture instructions,
+                         * target binding table index for FB_WRITE
+                         */
+   GLuint eot:1;       /* End of thread indicator for FB_WRITE*/
+};
+
+
+#define BRW_WM_MAX_INSN  2048
+#define BRW_WM_MAX_GRF   128           /* hardware limit */
+#define BRW_WM_MAX_VREG  (BRW_WM_MAX_INSN * 4)
+#define BRW_WM_MAX_REF   (BRW_WM_MAX_INSN * 12)
+#define BRW_WM_MAX_PARAM 256
+#define BRW_WM_MAX_CONST 256
+#define BRW_WM_MAX_KILLS MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS
+#define BRW_WM_MAX_SUBROUTINE 16
+
+
+/* New opcodes to track internal operations required for WM unit.
+ * These are added early so that the registers used can be tracked,
+ * freed and reused like those of other instructions.
+ */
+#define MAX_OPCODE        TGSI_OPCODE_LAST
+#define WM_PIXELXY        (MAX_OPCODE)
+#define WM_DELTAXY        (MAX_OPCODE + 1)
+#define WM_PIXELW         (MAX_OPCODE + 2)
+#define WM_LINTERP        (MAX_OPCODE + 3)
+#define WM_PINTERP        (MAX_OPCODE + 4)
+#define WM_CINTERP        (MAX_OPCODE + 5)
+#define WM_WPOSXY         (MAX_OPCODE + 6)
+#define WM_FB_WRITE       (MAX_OPCODE + 7)
+#define WM_FRONTFACING    (MAX_OPCODE + 8)
+#define MAX_WM_OPCODE     (MAX_OPCODE + 9)
+
+#define BRW_FILE_PAYLOAD   (TGSI_FILE_COUNT)
+#define PAYLOAD_DEPTH      (PIPE_MAX_SHADER_INPUTS) /* ?? */
+
+#define X    0
+#define Y    1
+#define Z    2
+#define W    3
+
+
+struct brw_fp_src {
+   unsigned file:4;
+   unsigned index:16;
+   unsigned swizzle:8;
+   unsigned indirect:1;
+   unsigned negate:1;
+   unsigned abs:1;
+};
+
+struct brw_fp_dst {
+   unsigned file:4;
+   unsigned index:16;
+   unsigned writemask:4;
+   unsigned indirect:1;
+   unsigned saturate:1;
+};
+
+struct brw_fp_instruction {
+   struct brw_fp_dst dst;
+   struct brw_fp_src src[3];
+   unsigned opcode:8;
+   unsigned target:8; /* XXX: special usage for FB_WRITE */
+   unsigned tex_unit:4;
+   unsigned sampler:4;
+   unsigned pad:8;
+};
+
+
+struct brw_wm_compile {
+   struct brw_compile func;
+   struct brw_wm_prog_key key;
+   struct brw_wm_prog_data prog_data;
+
+   struct brw_fragment_shader *fp;
+
+   GLfloat (*env_param)[4];
+
+   enum {
+      START,
+      PASS2_DONE
+   } state;
+
+   /* Initial pass - translate fp instructions to fp instructions,
+    * simplifying and adding instructions for interpolation and
+    * framebuffer writes.
+    */
+   struct {
+      GLfloat v[4];
+      unsigned nr;
+   } immediate[BRW_WM_MAX_CONST+3];
+   GLuint nr_immediates;
+   
+   struct brw_fp_instruction fp_instructions[BRW_WM_MAX_INSN];
+   GLuint nr_fp_insns;
+   GLuint fp_temp;
+   GLuint fp_interp_emitted;
+   GLuint fp_fragcolor_emitted;
+   GLuint fp_first_internal_temp;
+
+   struct brw_fp_src fp_pixel_xy;
+   struct brw_fp_src fp_delta_xy;
+   struct brw_fp_src fp_pixel_w;
+
+
+   /* Subsequent passes using SSA representation:
+    */
+   struct brw_wm_value vreg[BRW_WM_MAX_VREG];
+   GLuint nr_vreg;
+
+   struct brw_wm_value creg[BRW_WM_MAX_PARAM];
+   GLuint nr_creg;
+
+   struct {
+      struct brw_wm_value depth[4]; /* includes r0/r1 */
+      struct brw_wm_value input_interp[PIPE_MAX_SHADER_INPUTS];
+   } payload;
+
+
+   const struct brw_wm_ref *pass0_fp_reg[BRW_FILE_PAYLOAD+1][256][4];
+
+   struct brw_wm_ref undef_ref;
+   struct brw_wm_value undef_value;
+
+   struct brw_wm_ref refs[BRW_WM_MAX_REF];
+   GLuint nr_refs;
+
+   struct brw_wm_instruction instruction[BRW_WM_MAX_INSN];
+   GLuint nr_insns;
+
+   struct brw_wm_grf pass2_grf[BRW_WM_MAX_GRF/2];
+
+   GLuint grf_limit;
+   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[BRW_FILE_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 tmp_regs[BRW_WM_MAX_GRF];
+   GLuint tmp_index;
+   GLuint tmp_max;
+   GLuint subroutines[BRW_WM_MAX_SUBROUTINE];
+   GLuint dispatch_width;
+
+   /** we may need up to 3 constants per instruction (if use_const_buffer) */
+   struct {
+      GLint index;
+      struct brw_reg reg;
+   } current_const[3];
+
+   GLuint error;
+};
+
+
+GLuint brw_wm_nr_args( GLuint opcode );
+GLuint brw_wm_is_scalar_result( GLuint opcode );
+
+int brw_wm_pass_fp( struct brw_wm_compile *c );
+void brw_wm_pass0( struct brw_wm_compile *c );
+void brw_wm_pass1( struct brw_wm_compile *c );
+void brw_wm_pass2( struct brw_wm_compile *c );
+void brw_wm_emit( struct brw_wm_compile *c );
+
+void brw_wm_print_value( struct brw_wm_compile *c,
+                        struct brw_wm_value *value );
+
+void brw_wm_print_ref( struct brw_wm_compile *c,
+                      struct brw_wm_ref *ref );
+
+void brw_wm_print_insn( struct brw_wm_compile *c,
+                       struct brw_wm_instruction *inst );
+
+void brw_wm_print_program( struct brw_wm_compile *c,
+                          const char *stage );
+
+void brw_wm_print_fp_program( struct brw_wm_compile *c,
+                              const char *stage );
+
+void brw_wm_lookup_iz( GLuint line_aa,
+                      GLuint lookup,
+                      GLboolean ps_uses_depth,
+                      struct brw_wm_prog_key *key );
+
+void brw_wm_branching_shader_emit(struct brw_context *brw, struct brw_wm_compile *c);
+
+void emit_ddxy(struct brw_compile *p,
+              const struct brw_reg *dst,
+              GLuint mask,
+              GLboolean is_ddx,
+              const struct brw_reg *arg0);
+
+#endif
diff --git a/src/gallium/drivers/i965/brw_wm_constant_buffer.c b/src/gallium/drivers/i965/brw_wm_constant_buffer.c
new file mode 100644 (file)
index 0000000..6434c6a
--- /dev/null
@@ -0,0 +1,165 @@
+/* XXX: Constant buffers disabled
+ */
+
+
+/**
+ * Create the constant buffer surface.  Vertex/fragment shader constants will be
+ * read from this buffer with Data Port Read instructions/messages.
+ */
+enum pipe_error
+brw_create_constant_surface( struct brw_context *brw,
+                             struct brw_surface_key *key,
+                             struct brw_winsys_buffer **bo_out )
+{
+   const GLint w = key->width - 1;
+   struct brw_winsys_buffer *bo;
+   struct brw_winsys_reloc reloc[1];
+   enum pipe_error ret;
+
+      /* Emit relocation to surface contents */
+   make_reloc(&reloc[0],
+              BRW_USAGE_SAMPLER,
+              0,
+              offsetof(struct brw_surface_state, ss1),
+              key->bo);
+
+   
+   memset(&surf, 0, sizeof(surf));
+
+   surf.ss0.mipmap_layout_mode = BRW_SURFACE_MIPMAPLAYOUT_BELOW;
+   surf.ss0.surface_type = BRW_SURFACE_BUFFER;
+   surf.ss0.surface_format = BRW_SURFACEFORMAT_R32G32B32A32_FLOAT;
+
+   surf.ss1.base_addr = 0; /* reloc */
+
+   surf.ss2.width = w & 0x7f;            /* bits 6:0 of size or width */
+   surf.ss2.height = (w >> 7) & 0x1fff;  /* bits 19:7 of size or width */
+   surf.ss3.depth = (w >> 20) & 0x7f;    /* bits 26:20 of size or width */
+   surf.ss3.pitch = (key->pitch * key->cpp) - 1; /* ignored?? */
+   brw_set_surface_tiling(&surf, key->tiling); /* tiling now allowed */
+   ret = brw_upload_cache(&brw->surface_cache, BRW_SS_SURFACE,
+                          key, sizeof(*key),
+                          reloc, Elements(reloc),
+                          &surf, sizeof(surf),
+                          NULL, NULL,
+                          &bo_out);
+   if (ret)
+      return ret;
+
+   return PIPE_OK;
+}
+
+
+
+/**
+ * Update the surface state for a WM constant buffer.
+ * The constant buffer will be (re)allocated here if needed.
+ */
+static enum pipe_error
+brw_update_wm_constant_surface( struct brw_context *brw,
+                                GLuint surf)
+{
+   struct brw_surface_key key;
+   struct brw_fragment_shader *fp = brw->curr.fragment_shader;
+   struct pipe_buffer *cbuf = brw->curr.fragment_constants;
+   int pitch = cbuf->size / (4 * sizeof(float));
+   enum pipe_error ret;
+
+   /* 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.
+    */
+   ret = brw_wm_update_constant_buffer(brw, &fp->const_buffer);
+   if (ret)
+      return ret;
+
+   /* If there's no constant buffer, then no surface BO is needed to point at
+    * it.
+    */
+   if (cbuf == NULL) {
+      bo_reference(&brw->wm.surf_bo[surf], NULL);
+      return PIPE_OK;
+   }
+
+   memset(&key, 0, sizeof(key));
+
+   key.ss0.mipmap_layout_mode = BRW_SURFACE_MIPMAPLAYOUT_BELOW;
+   key.ss0.surface_type = BRW_SURFACE_BUFFER;
+   key.ss0.surface_format = BRW_SURFACEFORMAT_R32G32B32A32_FLOAT;
+
+   key.bo = brw_buffer(cbuf)->bo;
+
+   key.ss2.width = (pitch-1) & 0x7f;            /* bits 6:0 of size or width */
+   key.ss2.height = ((pitch-1) >> 7) & 0x1fff;  /* bits 19:7 of size or width */
+   key.ss3.depth = ((pitch-1) >> 20) & 0x7f;    /* bits 26:20 of size or width */
+   key.ss3.pitch = (pitch * 4 * sizeof(float)) - 1; /* ignored?? */
+   brw_set_surface_tiling(&surf, key->tiling); /* tiling now allowed */
+
+
+   /*
+   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);
+   */
+
+   if (brw_search_cache(&brw->surface_cache,
+                        BRW_SS_SURFACE,
+                        &key, sizeof(key),
+                        &key.bo, 1,
+                        NULL,
+                        &brw->wm.surf_bo[surf]))
+      return PIPE_OK;
+
+   ret = brw_create_constant_surface(brw, &key, &brw->wm.surf_bo[surf]);
+   if (ret)
+      return ret;
+
+   brw->state.dirty.brw |= BRW_NEW_WM_SURFACES;
+   return PIPE_OK;
+}
+
+/**
+ * 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 enum pipe_error prepare_wm_constant_surface(struct brw_context *brw )
+{
+   struct brw_fragment_program *fp =
+      (struct brw_fragment_program *) brw->fragment_program;
+   GLuint surf = SURF_INDEX_FRAG_CONST_BUFFER;
+
+   ret = brw_wm_update_constant_buffer(brw,
+                                       &fp->const_buffer);
+   if (ret)
+      return ret;
+
+   /* 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) {
+        bo_reference(&brw->wm.surf_bo[surf], NULL);
+        brw->state.dirty.brw |= BRW_NEW_WM_SURFACES;
+      }
+      return PIPE_OK;
+   }
+
+   ret = brw_update_wm_constant_surface(ctx, surf);
+   if (ret)
+      return ret;
+
+   return PIPE_OK
+}
+
+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,
+};
diff --git a/src/gallium/drivers/i965/brw_wm_debug.c b/src/gallium/drivers/i965/brw_wm_debug.c
new file mode 100644 (file)
index 0000000..3d11fa0
--- /dev/null
@@ -0,0 +1,256 @@
+/*
+ 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 "tgsi/tgsi_info.h"
+
+#include "brw_context.h"
+#include "brw_wm.h"
+
+static void print_writemask( unsigned writemask )
+{
+   if (writemask != BRW_WRITEMASK_XYZW)
+      debug_printf(".%s%s%s%s", 
+                  (writemask & BRW_WRITEMASK_X) ? "x" : "",
+                  (writemask & BRW_WRITEMASK_Y) ? "y" : "",
+                  (writemask & BRW_WRITEMASK_Z) ? "z" : "",
+                  (writemask & BRW_WRITEMASK_W) ? "w" : "");
+}
+
+static void print_swizzle( unsigned swizzle )
+{
+   char *swz = "xyzw";
+   if (swizzle != BRW_SWIZZLE_XYZW)
+      debug_printf(".%c%c%c%c", 
+                  swz[BRW_GET_SWZ(swizzle, X)],
+                  swz[BRW_GET_SWZ(swizzle, Y)],
+                  swz[BRW_GET_SWZ(swizzle, Z)],
+                  swz[BRW_GET_SWZ(swizzle, W)]);
+}
+
+static void print_opcode( unsigned opcode )
+{
+   switch (opcode) {
+   case WM_PIXELXY:
+      debug_printf("PIXELXY");
+      break;
+   case WM_DELTAXY:
+      debug_printf("DELTAXY");
+      break;
+   case WM_PIXELW:
+      debug_printf("PIXELW");
+      break;
+   case WM_WPOSXY:
+      debug_printf("WPOSXY");
+      break;
+   case WM_PINTERP:
+      debug_printf("PINTERP");
+      break;
+   case WM_LINTERP:
+      debug_printf("LINTERP");
+      break;
+   case WM_CINTERP:
+      debug_printf("CINTERP");
+      break;
+   case WM_FB_WRITE:
+      debug_printf("FB_WRITE");
+      break;
+   case WM_FRONTFACING:
+      debug_printf("FRONTFACING");
+      break;
+   default:
+      debug_printf("%s", tgsi_get_opcode_info(opcode)->mnemonic);
+      break;
+   }
+}
+
+void brw_wm_print_value( struct brw_wm_compile *c,
+                      struct brw_wm_value *value )
+{
+   assert(value);
+   if (c->state >= PASS2_DONE) 
+      brw_print_reg(value->hw_reg);
+   else if( value == &c->undef_value )
+      debug_printf("undef");
+   else if( value - c->vreg >= 0 &&
+           value - c->vreg < BRW_WM_MAX_VREG)
+      debug_printf("r%d", value - c->vreg);
+   else if (value - c->creg >= 0 &&
+           value - c->creg < BRW_WM_MAX_PARAM)
+      debug_printf("c%d", value - c->creg);
+   else if (value - c->payload.input_interp >= 0 &&
+           value - c->payload.input_interp < PIPE_MAX_SHADER_INPUTS)
+      debug_printf("i%d", value - c->payload.input_interp);
+   else if (value - c->payload.depth >= 0 &&
+           value - c->payload.depth < PIPE_MAX_SHADER_INPUTS)
+      debug_printf("d%d", value - c->payload.depth);
+   else 
+      debug_printf("?");
+}
+
+void brw_wm_print_ref( struct brw_wm_compile *c,
+                      struct brw_wm_ref *ref )
+{
+   struct brw_reg hw_reg = ref->hw_reg;
+
+   if (ref->unspill_reg)
+      debug_printf("UNSPILL(%x)/", ref->value->spill_slot);
+
+   if (c->state >= PASS2_DONE)
+      brw_print_reg(ref->hw_reg);
+   else {
+      debug_printf("%s", hw_reg.negate ? "-" : "");
+      debug_printf("%s", hw_reg.abs ? "abs/" : "");
+      brw_wm_print_value(c, ref->value);
+      if ((hw_reg.nr&1) || hw_reg.subnr) {
+        debug_printf("->%d.%d", (hw_reg.nr&1), hw_reg.subnr);
+      }
+   }
+}
+
+void brw_wm_print_insn( struct brw_wm_compile *c,
+                       struct brw_wm_instruction *inst )
+{
+   GLuint i, arg;
+   GLuint nr_args = brw_wm_nr_args(inst->opcode);
+
+   debug_printf("[");
+   for (i = 0; i < 4; i++) {
+      if (inst->dst[i]) {
+        brw_wm_print_value(c, inst->dst[i]);
+        if (inst->dst[i]->spill_slot)
+           debug_printf("/SPILL(%x)",inst->dst[i]->spill_slot);
+      }
+      else
+        debug_printf("#");
+      if (i < 3)      
+        debug_printf(",");
+   }
+   debug_printf("]");
+   print_writemask(inst->writemask);
+   
+   debug_printf(" = ");
+   print_opcode(inst->opcode);
+  
+   if (inst->saturate)
+      debug_printf("_SAT");
+
+   for (arg = 0; arg < nr_args; arg++) {
+
+      debug_printf(" [");
+
+      for (i = 0; i < 4; i++) {
+        if (inst->src[arg][i]) {
+           brw_wm_print_ref(c, inst->src[arg][i]);
+        }
+        else
+           debug_printf("%%");
+
+        if (i < 3) 
+           debug_printf(",");
+        else
+           debug_printf("]");
+      }
+   }
+   debug_printf("\n");
+}
+
+void brw_wm_print_program( struct brw_wm_compile *c,
+                          const char *stage )
+{
+   GLuint insn;
+
+   debug_printf("%s:\n", stage);
+   for (insn = 0; insn < c->nr_insns; insn++)
+      brw_wm_print_insn(c, &c->instruction[insn]);
+   debug_printf("\n");
+}
+
+static const char *file_strings[TGSI_FILE_COUNT+1] = {
+   "NULL",
+   "CONST",
+   "IN",
+   "OUT",
+   "TEMP",
+   "SAMPLER",
+   "ADDR",
+   "IMM",
+   "LOOP",
+   "PAYLOAD"
+};
+
+static void brw_wm_print_fp_insn( struct brw_wm_compile *c,
+                                  struct brw_fp_instruction *inst )
+{
+   GLuint i;
+   GLuint nr_args = brw_wm_nr_args(inst->opcode);
+
+   print_opcode(inst->opcode);
+   if (inst->dst.saturate)
+      debug_printf("_SAT");
+   debug_printf(" ");
+
+   if (inst->dst.indirect)
+      debug_printf("[");
+
+   debug_printf("%s[%d]",
+                file_strings[inst->dst.file],
+                inst->dst.index );
+   print_writemask(inst->dst.writemask);
+
+   if (inst->dst.indirect)
+      debug_printf("]");
+
+   debug_printf(nr_args ? ", " : "\n");
+   
+   for (i = 0; i < nr_args; i++) {
+      debug_printf("%s%s%s[%d]%s",
+                   inst->src[i].negate ? "-" : "",
+                   inst->src[i].abs ? "ABS(" : "",
+                   file_strings[inst->src[i].file],
+                   inst->src[i].index,
+                   inst->src[i].abs ? ")" : "");
+      print_swizzle(inst->src[i].swizzle);
+      debug_printf("%s", i == nr_args - 1 ? "\n" : ", ");
+   }
+}
+
+
+void brw_wm_print_fp_program( struct brw_wm_compile *c,
+                              const char *stage )
+{
+   GLuint insn;
+
+   debug_printf("%s:\n", stage);
+   for (insn = 0; insn < c->nr_fp_insns; insn++)
+      brw_wm_print_fp_insn(c, &c->fp_instructions[insn]);
+   debug_printf("\n");
+}
+
diff --git a/src/gallium/drivers/i965/brw_wm_emit.c b/src/gallium/drivers/i965/brw_wm_emit.c
new file mode 100644 (file)
index 0000000..8f983a6
--- /dev/null
@@ -0,0 +1,1521 @@
+/*
+ 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 "util/u_math.h"
+#include "tgsi/tgsi_info.h"
+
+#include "brw_context.h"
+#include "brw_wm.h"
+#include "brw_debug.h"
+#include "brw_disasm.h"
+
+/* Not quite sure how correct this is - need to understand horiz
+ * vs. vertical strides a little better.
+ */
+static INLINE struct brw_reg sechalf( struct brw_reg reg )
+{
+   if (reg.vstride)
+      reg.nr++;
+   return reg;
+}
+
+/* Payload R0:
+ *
+ * R0.0 -- pixel mask, one bit for each of 4 pixels in 4 quads,
+ *         corresponding to each of the 16 execution channels.
+ * R0.1..8 -- ?
+ * R1.0 -- triangle vertex 0.X
+ * R1.1 -- triangle vertex 0.Y
+ * R1.2 -- quad 0 x,y coords (2 packed uwords)
+ * R1.3 -- quad 1 x,y coords (2 packed uwords)
+ * R1.4 -- quad 2 x,y coords (2 packed uwords)
+ * R1.5 -- quad 3 x,y coords (2 packed uwords)
+ * R1.6 -- ?
+ * R1.7 -- ?
+ * R1.8 -- ?
+ */
+
+
+static void emit_pixel_xy(struct brw_compile *p,
+                         const struct brw_reg *dst,
+                         GLuint mask)
+{
+   struct brw_reg r1 = brw_vec1_grf(1, 0);
+   struct brw_reg r1_uw = retype(r1, BRW_REGISTER_TYPE_UW);
+
+   brw_set_compression_control(p, BRW_COMPRESSION_NONE);
+
+   /* Calculate pixel centers by adding 1 or 0 to each of the
+    * micro-tile coordinates passed in r1.
+    */
+   if (mask & BRW_WRITEMASK_X) {
+      brw_ADD(p,
+             vec16(retype(dst[0], BRW_REGISTER_TYPE_UW)),
+             stride(suboffset(r1_uw, 4), 2, 4, 0),
+             brw_imm_v(0x10101010));
+   }
+
+   if (mask & BRW_WRITEMASK_Y) {
+      brw_ADD(p,
+             vec16(retype(dst[1], BRW_REGISTER_TYPE_UW)),
+             stride(suboffset(r1_uw,5), 2, 4, 0),
+             brw_imm_v(0x11001100));
+   }
+
+   brw_set_compression_control(p, BRW_COMPRESSION_COMPRESSED);
+}
+
+
+
+static void emit_delta_xy(struct brw_compile *p,
+                         const struct brw_reg *dst,
+                         GLuint mask,
+                         const struct brw_reg *arg0)
+{
+   struct brw_reg r1 = brw_vec1_grf(1, 0);
+
+   /* Calc delta X,Y by subtracting origin in r1 from the pixel
+    * centers.
+    */
+   if (mask & BRW_WRITEMASK_X) {
+      brw_ADD(p,
+             dst[0],
+             retype(arg0[0], BRW_REGISTER_TYPE_UW),
+             negate(r1));
+   }
+
+   if (mask & BRW_WRITEMASK_Y) {
+      brw_ADD(p,
+             dst[1],
+             retype(arg0[1], BRW_REGISTER_TYPE_UW),
+             negate(suboffset(r1,1)));
+
+   }
+}
+
+static void emit_wpos_xy(struct brw_wm_compile *c,
+                        const struct brw_reg *dst,
+                        GLuint mask,
+                        const struct brw_reg *arg0)
+{
+   struct brw_compile *p = &c->func;
+
+   if (mask & BRW_WRITEMASK_X) {
+      /* X' = X */
+      brw_MOV(p,
+             dst[0],
+             retype(arg0[0], BRW_REGISTER_TYPE_W));
+   }
+
+   /* XXX: is this needed any more, or is this a NOOP?
+    */
+   if (mask & BRW_WRITEMASK_Y) {
+#if 0
+      /* Y' = height - 1 - Y */
+      brw_ADD(p,
+             dst[1],
+             negate(retype(arg0[1], BRW_REGISTER_TYPE_W)),
+             brw_imm_d(c->key.drawable_height - 1));
+#else
+      brw_MOV(p,
+             dst[0],
+             retype(arg0[0], BRW_REGISTER_TYPE_W));
+#endif
+   }
+}
+
+
+static void emit_pixel_w( struct brw_compile *p,
+                         const struct brw_reg *dst,
+                         GLuint mask,
+                         const struct brw_reg *arg0,
+                         const struct brw_reg *deltas)
+{
+   /* Don't need this if all you are doing is interpolating color, for
+    * instance.
+    */
+   if (mask & BRW_WRITEMASK_W) {      
+      struct brw_reg interp3 = brw_vec1_grf(arg0[0].nr+1, 4);
+
+      /* Calc 1/w - just linterp wpos[3] optimized by putting the
+       * result straight into a message reg.
+       */
+      brw_LINE(p, brw_null_reg(), interp3, deltas[0]);
+      brw_MAC(p, brw_message_reg(2), suboffset(interp3, 1), deltas[1]);
+
+      /* Calc w */
+      brw_math_16( p, dst[3],
+                  BRW_MATH_FUNCTION_INV,
+                  BRW_MATH_SATURATE_NONE,
+                  2, brw_null_reg(),
+                  BRW_MATH_PRECISION_FULL);
+   }
+}
+
+
+
+static void emit_linterp( struct brw_compile *p, 
+                        const struct brw_reg *dst,
+                        GLuint mask,
+                        const struct brw_reg *arg0,
+                        const struct brw_reg *deltas )
+{
+   struct brw_reg interp[4];
+   GLuint nr = arg0[0].nr;
+   GLuint i;
+
+   interp[0] = brw_vec1_grf(nr, 0);
+   interp[1] = brw_vec1_grf(nr, 4);
+   interp[2] = brw_vec1_grf(nr+1, 0);
+   interp[3] = brw_vec1_grf(nr+1, 4);
+
+   for (i = 0; i < 4; i++) {
+      if (mask & (1<<i)) {
+        brw_LINE(p, brw_null_reg(), interp[i], deltas[0]);
+        brw_MAC(p, dst[i], suboffset(interp[i],1), deltas[1]);
+      }
+   }
+}
+
+
+static void emit_pinterp( struct brw_compile *p, 
+                         const struct brw_reg *dst,
+                         GLuint mask,
+                         const struct brw_reg *arg0,
+                         const struct brw_reg *deltas,
+                         const struct brw_reg *w)
+{
+   struct brw_reg interp[4];
+   GLuint nr = arg0[0].nr;
+   GLuint i;
+
+   interp[0] = brw_vec1_grf(nr, 0);
+   interp[1] = brw_vec1_grf(nr, 4);
+   interp[2] = brw_vec1_grf(nr+1, 0);
+   interp[3] = brw_vec1_grf(nr+1, 4);
+
+   for (i = 0; i < 4; i++) {
+      if (mask & (1<<i)) {
+        brw_LINE(p, brw_null_reg(), interp[i], deltas[0]);
+        brw_MAC(p, dst[i], suboffset(interp[i],1), deltas[1]);
+      }
+   }
+   for (i = 0; i < 4; i++) {
+      if (mask & (1<<i)) {
+        brw_MUL(p, dst[i], dst[i], w[3]);
+      }
+   }
+}
+
+
+static void emit_cinterp( struct brw_compile *p, 
+                        const struct brw_reg *dst,
+                        GLuint mask,
+                        const struct brw_reg *arg0 )
+{
+   struct brw_reg interp[4];
+   GLuint nr = arg0[0].nr;
+   GLuint i;
+
+   interp[0] = brw_vec1_grf(nr, 0);
+   interp[1] = brw_vec1_grf(nr, 4);
+   interp[2] = brw_vec1_grf(nr+1, 0);
+   interp[3] = brw_vec1_grf(nr+1, 4);
+
+   for (i = 0; i < 4; i++) {
+      if (mask & (1<<i)) {
+         brw_MOV(p, dst[i], suboffset(interp[i],3));   /* TODO: optimize away like other moves */
+      }
+   }
+}
+
+/* Sets the destination channels to 1.0 or 0.0 according to glFrontFacing. */
+static void emit_frontfacing( struct brw_compile *p,
+                             const struct brw_reg *dst,
+                             GLuint mask )
+{
+   struct brw_reg r1_6ud = retype(brw_vec1_grf(1, 6), BRW_REGISTER_TYPE_UD);
+   GLuint i;
+
+   if (!(mask & BRW_WRITEMASK_XYZW))
+      return;
+
+   for (i = 0; i < 4; i++) {
+      if (mask & (1<<i)) {
+        brw_MOV(p, dst[i], brw_imm_f(0.0));
+      }
+   }
+
+   /* bit 31 is "primitive is back face", so checking < (1 << 31) gives
+    * us front face
+    */
+   brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_L, r1_6ud, brw_imm_ud(1 << 31));
+   for (i = 0; i < 4; i++) {
+      if (mask & (1<<i)) {
+        brw_MOV(p, dst[i], brw_imm_f(1.0));
+      }
+   }
+   brw_set_predicate_control_flag_value(p, 0xff);
+}
+
+/* For OPCODE_DDX and OPCODE_DDY, per channel of output we've got input
+ * looking like:
+ *
+ * arg0: q0.tl q0.tr q0.bl q0.br q1.tl q1.tr q1.bl q1.br
+ *
+ * and we're trying to produce:
+ *
+ *           DDX                     DDY
+ * dst: (q0.tr - q0.tl)     (q0.tl - q0.bl)
+ *      (q0.tr - q0.tl)     (q0.tr - q0.br)
+ *      (q0.br - q0.bl)     (q0.tl - q0.bl)
+ *      (q0.br - q0.bl)     (q0.tr - q0.br)
+ *      (q1.tr - q1.tl)     (q1.tl - q1.bl)
+ *      (q1.tr - q1.tl)     (q1.tr - q1.br)
+ *      (q1.br - q1.bl)     (q1.tl - q1.bl)
+ *      (q1.br - q1.bl)     (q1.tr - q1.br)
+ *
+ * and add two more quads if in 16-pixel dispatch mode.
+ *
+ * For DDX, it ends up being easy: width = 2, horiz=0 gets us the same result
+ * for each pair, and vertstride = 2 jumps us 2 elements after processing a
+ * pair. But for DDY, it's harder, as we want to produce the pairs swizzled
+ * between each other.  We could probably do it like ddx and swizzle the right
+ * order later, but bail for now and just produce
+ * ((q0.tl - q0.bl)x4 (q1.tl - q1.bl)x4)
+ */
+void emit_ddxy(struct brw_compile *p,
+              const struct brw_reg *dst,
+              GLuint mask,
+              GLboolean is_ddx,
+              const struct brw_reg *arg0)
+{
+   int i;
+   struct brw_reg src0, src1;
+
+   if (mask & SATURATE)
+      brw_set_saturate(p, 1);
+   for (i = 0; i < 4; i++ ) {
+      if (mask & (1<<i)) {
+        if (is_ddx) {
+           src0 = brw_reg(arg0[i].file, arg0[i].nr, 1,
+                          BRW_REGISTER_TYPE_F,
+                          BRW_VERTICAL_STRIDE_2,
+                          BRW_WIDTH_2,
+                          BRW_HORIZONTAL_STRIDE_0,
+                          BRW_SWIZZLE_XYZW, BRW_WRITEMASK_XYZW);
+           src1 = brw_reg(arg0[i].file, arg0[i].nr, 0,
+                          BRW_REGISTER_TYPE_F,
+                          BRW_VERTICAL_STRIDE_2,
+                          BRW_WIDTH_2,
+                          BRW_HORIZONTAL_STRIDE_0,
+                          BRW_SWIZZLE_XYZW, BRW_WRITEMASK_XYZW);
+        } else {
+           src0 = brw_reg(arg0[i].file, arg0[i].nr, 0,
+                          BRW_REGISTER_TYPE_F,
+                          BRW_VERTICAL_STRIDE_4,
+                          BRW_WIDTH_4,
+                          BRW_HORIZONTAL_STRIDE_0,
+                          BRW_SWIZZLE_XYZW, BRW_WRITEMASK_XYZW);
+           src1 = brw_reg(arg0[i].file, arg0[i].nr, 2,
+                          BRW_REGISTER_TYPE_F,
+                          BRW_VERTICAL_STRIDE_4,
+                          BRW_WIDTH_4,
+                          BRW_HORIZONTAL_STRIDE_0,
+                          BRW_SWIZZLE_XYZW, BRW_WRITEMASK_XYZW);
+        }
+        brw_ADD(p, dst[i], src0, negate(src1));
+      }
+   }
+   if (mask & SATURATE)
+      brw_set_saturate(p, 0);
+}
+
+static void emit_alu1( struct brw_compile *p, 
+                      struct brw_instruction *(*func)(struct brw_compile *, 
+                                                      struct brw_reg, 
+                                                      struct brw_reg),
+                      const struct brw_reg *dst,
+                      GLuint mask,
+                      const struct brw_reg *arg0 )
+{
+   GLuint i;
+
+   if (mask & SATURATE)
+      brw_set_saturate(p, 1);
+
+   for (i = 0; i < 4; i++) {
+      if (mask & (1<<i)) {
+        func(p, dst[i], arg0[i]);
+      }
+   }
+
+   if (mask & SATURATE)
+      brw_set_saturate(p, 0);
+}
+
+
+static void emit_alu2( struct brw_compile *p, 
+                      struct brw_instruction *(*func)(struct brw_compile *, 
+                                                      struct brw_reg, 
+                                                      struct brw_reg, 
+                                                      struct brw_reg),
+                      const struct brw_reg *dst,
+                      GLuint mask,
+                      const struct brw_reg *arg0,
+                      const struct brw_reg *arg1 )
+{
+   GLuint i;
+
+   if (mask & SATURATE)
+      brw_set_saturate(p, 1);
+
+   for (i = 0; i < 4; i++) {
+      if (mask & (1<<i)) {
+        func(p, dst[i], arg0[i], arg1[i]);
+      }
+   }
+
+   if (mask & SATURATE)
+      brw_set_saturate(p, 0);
+}
+
+
+static void emit_mad( struct brw_compile *p, 
+                     const struct brw_reg *dst,
+                     GLuint mask,
+                     const struct brw_reg *arg0,
+                     const struct brw_reg *arg1,
+                     const struct brw_reg *arg2 )
+{
+   GLuint i;
+
+   for (i = 0; i < 4; i++) {
+      if (mask & (1<<i)) {
+        brw_MUL(p, dst[i], arg0[i], arg1[i]);
+
+        brw_set_saturate(p, (mask & SATURATE) ? 1 : 0);
+        brw_ADD(p, dst[i], dst[i], arg2[i]);
+        brw_set_saturate(p, 0);
+      }
+   }
+}
+
+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,
+                     GLuint mask,
+                     const struct brw_reg *arg0,
+                     const struct brw_reg *arg1,
+                     const struct brw_reg *arg2 )
+{
+   GLuint i;
+
+   /* Uses dst as a temporary:
+    */
+   for (i = 0; i < 4; i++) {
+      if (mask & (1<<i)) {     
+        /* Can I use the LINE instruction for this? 
+         */
+        brw_ADD(p, dst[i], negate(arg0[i]), brw_imm_f(1.0));
+        brw_MUL(p, brw_null_reg(), dst[i], arg2[i]);
+
+        brw_set_saturate(p, (mask & SATURATE) ? 1 : 0);
+        brw_MAC(p, dst[i], arg0[i], arg1[i]);
+        brw_set_saturate(p, 0);
+      }
+   }
+}
+
+static void emit_sop( struct brw_compile *p, 
+                     const struct brw_reg *dst,
+                     GLuint mask,
+                     GLuint cond,
+                     const struct brw_reg *arg0,
+                     const struct brw_reg *arg1 )
+{
+   GLuint i;
+
+   for (i = 0; i < 4; i++) {
+      if (mask & (1<<i)) {     
+        brw_MOV(p, dst[i], brw_imm_f(0));
+        brw_CMP(p, brw_null_reg(), cond, arg0[i], arg1[i]);
+        brw_MOV(p, dst[i], brw_imm_f(1.0));
+        brw_set_predicate_control_flag_value(p, 0xff);
+      }
+   }
+}
+
+static void emit_slt( struct brw_compile *p, 
+                     const struct brw_reg *dst,
+                     GLuint mask,
+                     const struct brw_reg *arg0,
+                     const struct brw_reg *arg1 )
+{
+   emit_sop(p, dst, mask, BRW_CONDITIONAL_L, arg0, arg1);
+}
+
+static void emit_sle( struct brw_compile *p, 
+                     const struct brw_reg *dst,
+                     GLuint mask,
+                     const struct brw_reg *arg0,
+                     const struct brw_reg *arg1 )
+{
+   emit_sop(p, dst, mask, BRW_CONDITIONAL_LE, arg0, arg1);
+}
+
+static void emit_sgt( struct brw_compile *p, 
+                     const struct brw_reg *dst,
+                     GLuint mask,
+                     const struct brw_reg *arg0,
+                     const struct brw_reg *arg1 )
+{
+   emit_sop(p, dst, mask, BRW_CONDITIONAL_G, arg0, arg1);
+}
+
+static void emit_sge( struct brw_compile *p, 
+                     const struct brw_reg *dst,
+                     GLuint mask,
+                     const struct brw_reg *arg0,
+                     const struct brw_reg *arg1 )
+{
+   emit_sop(p, dst, mask, BRW_CONDITIONAL_GE, arg0, arg1);
+}
+
+static void emit_seq( struct brw_compile *p, 
+                     const struct brw_reg *dst,
+                     GLuint mask,
+                     const struct brw_reg *arg0,
+                     const struct brw_reg *arg1 )
+{
+   emit_sop(p, dst, mask, BRW_CONDITIONAL_EQ, arg0, arg1);
+}
+
+static void emit_sne( struct brw_compile *p, 
+                     const struct brw_reg *dst,
+                     GLuint mask,
+                     const struct brw_reg *arg0,
+                     const struct brw_reg *arg1 )
+{
+   emit_sop(p, dst, mask, BRW_CONDITIONAL_NEQ, arg0, arg1);
+}
+
+static void emit_cmp( struct brw_compile *p, 
+                     const struct brw_reg *dst,
+                     GLuint mask,
+                     const struct brw_reg *arg0,
+                     const struct brw_reg *arg1,
+                     const struct brw_reg *arg2 )
+{
+   GLuint i;
+
+   for (i = 0; i < 4; i++) {
+      if (mask & (1<<i)) {     
+        brw_set_saturate(p, (mask & SATURATE) ? 1 : 0);
+        brw_MOV(p, dst[i], arg2[i]);
+        brw_set_saturate(p, 0);
+
+        brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_L, arg0[i], brw_imm_f(0));
+
+        brw_set_saturate(p, (mask & SATURATE) ? 1 : 0);
+        brw_MOV(p, dst[i], arg1[i]);
+        brw_set_saturate(p, 0);
+        brw_set_predicate_control_flag_value(p, 0xff);
+      }
+   }
+}
+
+static void emit_max( struct brw_compile *p, 
+                     const struct brw_reg *dst,
+                     GLuint mask,
+                     const struct brw_reg *arg0,
+                     const struct brw_reg *arg1 )
+{
+   GLuint i;
+
+   for (i = 0; i < 4; i++) {
+      if (mask & (1<<i)) {     
+        brw_set_saturate(p, (mask & SATURATE) ? 1 : 0);
+        brw_MOV(p, dst[i], arg0[i]);
+        brw_set_saturate(p, 0);
+
+        brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_L, arg0[i], arg1[i]);
+
+        brw_set_saturate(p, (mask & SATURATE) ? 1 : 0);
+        brw_MOV(p, dst[i], arg1[i]);
+        brw_set_saturate(p, 0);
+        brw_set_predicate_control_flag_value(p, 0xff);
+      }
+   }
+}
+
+static void emit_min( struct brw_compile *p, 
+                     const struct brw_reg *dst,
+                     GLuint mask,
+                     const struct brw_reg *arg0,
+                     const struct brw_reg *arg1 )
+{
+   GLuint i;
+
+   for (i = 0; i < 4; i++) {
+      if (mask & (1<<i)) {     
+        brw_set_saturate(p, (mask & SATURATE) ? 1 : 0);
+        brw_MOV(p, dst[i], arg1[i]);
+        brw_set_saturate(p, 0);
+
+        brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_L, arg0[i], arg1[i]);
+
+        brw_set_saturate(p, (mask & SATURATE) ? 1 : 0);
+        brw_MOV(p, dst[i], arg0[i]);
+        brw_set_saturate(p, 0);
+        brw_set_predicate_control_flag_value(p, 0xff);
+      }
+   }
+}
+
+
+static void emit_dp3( struct brw_compile *p, 
+                     const struct brw_reg *dst,
+                     GLuint mask,
+                     const struct brw_reg *arg0,
+                     const struct brw_reg *arg1 )
+{
+   int dst_chan = ffs(mask & BRW_WRITEMASK_XYZW) - 1;
+
+   if (!(mask & BRW_WRITEMASK_XYZW))
+      return; /* Do not emit dead code */
+
+   assert(util_is_power_of_two(mask & BRW_WRITEMASK_XYZW));
+
+   brw_MUL(p, brw_null_reg(), arg0[0], arg1[0]);
+   brw_MAC(p, brw_null_reg(), arg0[1], arg1[1]);
+
+   brw_set_saturate(p, (mask & SATURATE) ? 1 : 0);
+   brw_MAC(p, dst[dst_chan], arg0[2], arg1[2]);
+   brw_set_saturate(p, 0);
+}
+
+
+static void emit_dp4( struct brw_compile *p, 
+                     const struct brw_reg *dst,
+                     GLuint mask,
+                     const struct brw_reg *arg0,
+                     const struct brw_reg *arg1 )
+{
+   int dst_chan = ffs(mask & BRW_WRITEMASK_XYZW) - 1;
+
+   if (!(mask & BRW_WRITEMASK_XYZW))
+      return; /* Do not emit dead code */
+
+   assert(util_is_power_of_two(mask & BRW_WRITEMASK_XYZW));
+
+   brw_MUL(p, brw_null_reg(), arg0[0], arg1[0]);
+   brw_MAC(p, brw_null_reg(), arg0[1], arg1[1]);
+   brw_MAC(p, brw_null_reg(), arg0[2], arg1[2]);
+
+   brw_set_saturate(p, (mask & SATURATE) ? 1 : 0);
+   brw_MAC(p, dst[dst_chan], arg0[3], arg1[3]);
+   brw_set_saturate(p, 0);
+}
+
+
+static void emit_dph( struct brw_compile *p, 
+                     const struct brw_reg *dst,
+                     GLuint mask,
+                     const struct brw_reg *arg0,
+                     const struct brw_reg *arg1 )
+{
+   const int dst_chan = ffs(mask & BRW_WRITEMASK_XYZW) - 1;
+
+   if (!(mask & BRW_WRITEMASK_XYZW))
+      return; /* Do not emit dead code */
+
+   assert(util_is_power_of_two(mask & BRW_WRITEMASK_XYZW));
+
+   brw_MUL(p, brw_null_reg(), arg0[0], arg1[0]);
+   brw_MAC(p, brw_null_reg(), arg0[1], arg1[1]);
+   brw_MAC(p, dst[dst_chan], arg0[2], arg1[2]);
+
+   brw_set_saturate(p, (mask & SATURATE) ? 1 : 0);
+   brw_ADD(p, dst[dst_chan], dst[dst_chan], arg1[3]);
+   brw_set_saturate(p, 0);
+}
+
+
+static void emit_xpd( struct brw_compile *p, 
+                     const struct brw_reg *dst,
+                     GLuint mask,
+                     const struct brw_reg *arg0,
+                     const struct brw_reg *arg1 )
+{
+   GLuint i;
+
+   assert((mask & BRW_WRITEMASK_W) != BRW_WRITEMASK_W);
+   
+   for (i = 0 ; i < 3; i++) {
+      if (mask & (1<<i)) {
+        GLuint i2 = (i+2)%3;
+        GLuint i1 = (i+1)%3;
+
+        brw_MUL(p, brw_null_reg(), negate(arg0[i2]), arg1[i1]);
+
+        brw_set_saturate(p, (mask & SATURATE) ? 1 : 0);
+        brw_MAC(p, dst[i], arg0[i1], arg1[i2]);
+        brw_set_saturate(p, 0);
+      }
+   }
+}
+
+
+static void emit_math1( struct brw_compile *p, 
+                       GLuint function,
+                       const struct brw_reg *dst,
+                       GLuint mask,
+                       const struct brw_reg *arg0 )
+{
+   int dst_chan = ffs(mask & BRW_WRITEMASK_XYZW) - 1;
+
+   if (!(mask & BRW_WRITEMASK_XYZW))
+      return; /* Do not emit dead code */
+
+   assert(util_is_power_of_two(mask & BRW_WRITEMASK_XYZW));
+
+   brw_MOV(p, brw_message_reg(2), arg0[0]);
+
+   /* Send two messages to perform all 16 operations:
+    */
+   brw_math_16(p, 
+              dst[dst_chan],
+              function,
+              (mask & SATURATE) ? BRW_MATH_SATURATE_SATURATE : BRW_MATH_SATURATE_NONE,
+              2,
+              brw_null_reg(),
+              BRW_MATH_PRECISION_FULL);
+}
+
+
+static void emit_math2( struct brw_compile *p, 
+                       GLuint function,
+                       const struct brw_reg *dst,
+                       GLuint mask,
+                       const struct brw_reg *arg0,
+                       const struct brw_reg *arg1)
+{
+   int dst_chan = ffs(mask & BRW_WRITEMASK_XYZW) - 1;
+
+   if (!(mask & BRW_WRITEMASK_XYZW))
+      return; /* Do not emit dead code */
+
+   assert(util_is_power_of_two(mask & BRW_WRITEMASK_XYZW));
+
+   brw_push_insn_state(p);
+
+   brw_set_compression_control(p, BRW_COMPRESSION_NONE);
+   brw_MOV(p, brw_message_reg(2), arg0[0]);
+   brw_set_compression_control(p, BRW_COMPRESSION_2NDHALF);
+   brw_MOV(p, brw_message_reg(4), sechalf(arg0[0]));
+
+   brw_set_compression_control(p, BRW_COMPRESSION_NONE);
+   brw_MOV(p, brw_message_reg(3), arg1[0]);
+   brw_set_compression_control(p, BRW_COMPRESSION_2NDHALF);
+   brw_MOV(p, brw_message_reg(5), sechalf(arg1[0]));
+
+   
+   /* Send two messages to perform all 16 operations:
+    */
+   brw_set_compression_control(p, BRW_COMPRESSION_NONE);
+   brw_math(p, 
+           dst[dst_chan],
+           function,
+           (mask & SATURATE) ? BRW_MATH_SATURATE_SATURATE : BRW_MATH_SATURATE_NONE,
+           2,
+           brw_null_reg(),
+           BRW_MATH_DATA_VECTOR,
+           BRW_MATH_PRECISION_FULL);
+
+   brw_set_compression_control(p, BRW_COMPRESSION_2NDHALF);
+   brw_math(p, 
+           offset(dst[dst_chan],1),
+           function,
+           (mask & SATURATE) ? BRW_MATH_SATURATE_SATURATE : BRW_MATH_SATURATE_NONE,
+           4,
+           brw_null_reg(),
+           BRW_MATH_DATA_VECTOR,
+           BRW_MATH_PRECISION_FULL);
+   
+   brw_pop_insn_state(p);
+}
+                    
+
+
+static void emit_tex( struct brw_wm_compile *c,
+                     const struct brw_wm_instruction *inst,
+                     struct brw_reg *dst,
+                     GLuint dst_flags,
+                     struct brw_reg *coord,
+                     GLuint sampler)
+{
+   struct brw_compile *p = &c->func;
+   GLuint msgLength, responseLength;
+   GLuint i, nr;
+   GLuint emit;
+   GLuint msg_type;
+   GLboolean shadow = FALSE;
+
+   /* How many input regs are there?
+    */
+   switch (inst->target) {
+   case TGSI_TEXTURE_1D:
+      emit = BRW_WRITEMASK_X;
+      nr = 1;
+      break;
+   case TGSI_TEXTURE_SHADOW1D:
+      emit = BRW_WRITEMASK_XW;
+      nr = 4;
+      shadow = TRUE;
+      break;
+   case TGSI_TEXTURE_2D:
+      emit = BRW_WRITEMASK_XY;
+      nr = 2;
+      break;
+   case TGSI_TEXTURE_SHADOW2D:
+   case TGSI_TEXTURE_SHADOWRECT:
+      emit = BRW_WRITEMASK_XYW;
+      nr = 4;
+      shadow = TRUE;
+      break;
+   case TGSI_TEXTURE_3D:
+   case TGSI_TEXTURE_CUBE:
+      emit = BRW_WRITEMASK_XYZ;
+      nr = 3;
+      break;
+   default:
+      /* unexpected target */
+      abort();
+   }
+
+   msgLength = 1;
+
+   for (i = 0; i < nr; i++) {
+      static const GLuint swz[4] = {0,1,2,2};
+      if (emit & (1<<i)) 
+        brw_MOV(p, brw_message_reg(msgLength+1), coord[swz[i]]);
+      else
+        brw_MOV(p, brw_message_reg(msgLength+1), brw_imm_f(0));
+      msgLength += 2;
+   }
+
+   responseLength = 8;         /* always */
+
+   if (BRW_IS_IGDNG(p->brw)) {
+       if (shadow)
+           msg_type = BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_COMPARE_IGDNG;
+       else
+           msg_type = BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_IGDNG;
+   } else {
+       if (shadow)
+           msg_type = BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_COMPARE;
+       else
+           msg_type = BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE;
+   }
+
+   brw_SAMPLE(p, 
+             retype(vec16(dst[0]), BRW_REGISTER_TYPE_UW),
+             1,
+             retype(c->payload.depth[0].hw_reg, BRW_REGISTER_TYPE_UW),
+              BTI_TEXTURE(inst->tex_unit),
+             sampler,          /* sampler index */
+             inst->writemask,
+             msg_type, 
+             responseLength,
+             msgLength,
+             0,        
+             1,
+             BRW_SAMPLER_SIMD_MODE_SIMD16);    
+}
+
+
+static void emit_txb( struct brw_wm_compile *c,
+                     const struct brw_wm_instruction *inst,
+                     struct brw_reg *dst,
+                     GLuint dst_flags,
+                     struct brw_reg *coord,
+                     GLuint sampler )
+{
+   struct brw_compile *p = &c->func;
+   GLuint msgLength;
+   GLuint msg_type;
+   /* Shadow ignored for txb.
+    */
+   switch (inst->target) {
+   case TGSI_TEXTURE_1D:
+   case TGSI_TEXTURE_SHADOW1D:
+      brw_MOV(p, brw_message_reg(2), coord[0]);
+      brw_MOV(p, brw_message_reg(4), brw_imm_f(0));
+      brw_MOV(p, brw_message_reg(6), brw_imm_f(0));
+      break;
+   case TGSI_TEXTURE_2D:
+   case TGSI_TEXTURE_RECT:
+   case TGSI_TEXTURE_SHADOW2D:
+   case TGSI_TEXTURE_SHADOWRECT:
+      brw_MOV(p, brw_message_reg(2), coord[0]);
+      brw_MOV(p, brw_message_reg(4), coord[1]);
+      brw_MOV(p, brw_message_reg(6), brw_imm_f(0));
+      break;
+   case TGSI_TEXTURE_3D:
+   case TGSI_TEXTURE_CUBE:
+      brw_MOV(p, brw_message_reg(2), coord[0]);
+      brw_MOV(p, brw_message_reg(4), coord[1]);
+      brw_MOV(p, brw_message_reg(6), coord[2]);
+      break;
+   default:
+      /* unexpected target */
+      abort();
+   }
+
+   brw_MOV(p, brw_message_reg(8), coord[3]);
+   msgLength = 9;
+
+   if (BRW_IS_IGDNG(p->brw))
+       msg_type = BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_BIAS_IGDNG;
+   else
+       msg_type = BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_BIAS;
+
+   brw_SAMPLE(p, 
+             retype(vec16(dst[0]), BRW_REGISTER_TYPE_UW),
+             1,
+             retype(c->payload.depth[0].hw_reg, BRW_REGISTER_TYPE_UW),
+              BTI_TEXTURE(inst->tex_unit),
+             sampler,          /* sampler index */
+             inst->writemask,
+             msg_type,
+             8,                /* responseLength */
+             msgLength,
+             0,        
+             1,
+             BRW_SAMPLER_SIMD_MODE_SIMD16);    
+}
+
+
+static void emit_lit( struct brw_compile *p, 
+                     const struct brw_reg *dst,
+                     GLuint mask,
+                     const struct brw_reg *arg0 )
+{
+   assert((mask & BRW_WRITEMASK_XW) == 0);
+
+   if (mask & BRW_WRITEMASK_Y) {
+      brw_set_saturate(p, (mask & SATURATE) ? 1 : 0);
+      brw_MOV(p, dst[1], arg0[0]);
+      brw_set_saturate(p, 0);
+   }
+
+   if (mask & BRW_WRITEMASK_Z) {
+      emit_math2(p, BRW_MATH_FUNCTION_POW,
+                &dst[2],
+                BRW_WRITEMASK_X | (mask & SATURATE),
+                &arg0[1],
+                &arg0[3]);
+   }
+
+   /* Ordinarily you'd use an iff statement to skip or shortcircuit
+    * some of the POW calculations above, but 16-wide iff statements
+    * seem to lock c1 hardware, so this is a nasty workaround:
+    */
+   brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_LE, arg0[0], brw_imm_f(0));
+   {
+      if (mask & BRW_WRITEMASK_Y) 
+        brw_MOV(p, dst[1], brw_imm_f(0));
+
+      if (mask & BRW_WRITEMASK_Z) 
+        brw_MOV(p, dst[2], brw_imm_f(0)); 
+   }
+   brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+}
+
+
+/* Kill pixel - set execution mask to zero for those pixels which
+ * fail.
+ */
+static void emit_kil( struct brw_wm_compile *c,
+                     struct brw_reg *arg0)
+{
+   struct brw_compile *p = &c->func;
+   struct brw_reg r0uw = retype(brw_vec1_grf(0, 0), BRW_REGISTER_TYPE_UW);
+   GLuint i;
+   
+   /* XXX - usually won't need 4 compares!
+    */
+   for (i = 0; i < 4; i++) {
+      brw_push_insn_state(p);
+      brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_GE, arg0[i], brw_imm_f(0));   
+      brw_set_predicate_control_flag_value(p, 0xff);
+      brw_set_compression_control(p, BRW_COMPRESSION_NONE);
+      brw_AND(p, r0uw, brw_flag_reg(), r0uw);
+      brw_pop_insn_state(p);
+   }
+}
+
+/* KILLP kills the pixels that are currently executing, not based on a test
+ * of the arguments.
+ */
+static void emit_killp( struct brw_wm_compile *c )
+{
+   struct brw_compile *p = &c->func;
+   struct brw_reg r0uw = retype(brw_vec1_grf(0, 0), BRW_REGISTER_TYPE_UW);
+
+   brw_push_insn_state(p);
+   brw_set_mask_control(p, BRW_MASK_DISABLE);
+   brw_NOT(p, c->emit_mask_reg, brw_mask_reg(1)); /* IMASK */
+   brw_AND(p, r0uw, c->emit_mask_reg, r0uw);
+   brw_pop_insn_state(p);
+}
+
+static void fire_fb_write( struct brw_wm_compile *c,
+                          GLuint base_reg,
+                          GLuint nr,
+                          GLuint target,
+                          GLuint eot )
+{
+   struct brw_compile *p = &c->func;
+   
+   /* Pass through control information:
+    */
+/*  mov (8) m1.0<1>:ud   r1.0<8;8,1>:ud   { Align1 NoMask } */
+   {
+      brw_push_insn_state(p);
+      brw_set_mask_control(p, BRW_MASK_DISABLE); /* ? */
+      brw_set_compression_control(p, BRW_COMPRESSION_NONE);
+      brw_MOV(p, 
+              brw_message_reg(base_reg + 1),
+              brw_vec8_grf(1, 0));
+      brw_pop_insn_state(p);
+   }
+
+   /* Send framebuffer write message: */
+/*  send (16) null.0<1>:uw m0               r0.0<8;8,1>:uw   0x85a04000:ud    { Align1 EOT } */
+   brw_fb_WRITE(p,
+               retype(vec16(brw_null_reg()), BRW_REGISTER_TYPE_UW),
+               base_reg,
+               retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UW),
+               target,         
+               nr,
+               0, 
+               eot);
+}
+
+
+static void emit_aa( struct brw_wm_compile *c,
+                    struct brw_reg *arg1,
+                    GLuint reg )
+{
+   struct brw_compile *p = &c->func;
+   GLuint comp = c->key.aa_dest_stencil_reg / 2;
+   GLuint off = c->key.aa_dest_stencil_reg % 2;
+   struct brw_reg aa = offset(arg1[comp], off);
+
+   brw_push_insn_state(p);
+   brw_set_compression_control(p, BRW_COMPRESSION_NONE); /* ?? */
+   brw_MOV(p, brw_message_reg(reg), aa);
+   brw_pop_insn_state(p);
+}
+
+
+/* Post-fragment-program processing.  Send the results to the
+ * framebuffer.
+ * \param arg0  the fragment color
+ * \param arg1  the pass-through depth value
+ * \param arg2  the shader-computed depth value
+ */
+static void emit_fb_write( struct brw_wm_compile *c,
+                          struct brw_reg *arg0,
+                          struct brw_reg *arg1,
+                          struct brw_reg *arg2,
+                          GLuint target,
+                          GLuint eot)
+{
+   struct brw_compile *p = &c->func;
+   GLuint nr = 2;
+   GLuint channel;
+
+   /* Reserve a space for AA - may not be needed:
+    */
+   if (c->key.aa_dest_stencil_reg)
+      nr += 1;
+
+   /* I don't really understand how this achieves the color interleave
+    * (ie RGBARGBA) in the result:  [Do the saturation here]
+    */
+   {
+      brw_push_insn_state(p);
+      
+      for (channel = 0; channel < 4; channel++) {
+        /*  mov (8) m2.0<1>:ud   r28.0<8;8,1>:ud  { Align1 } */
+        /*  mov (8) m6.0<1>:ud   r29.0<8;8,1>:ud  { Align1 SecHalf } */
+
+        brw_set_compression_control(p, BRW_COMPRESSION_NONE);
+        brw_MOV(p,
+                brw_message_reg(nr + channel),
+                arg0[channel]);
+       
+        brw_set_compression_control(p, BRW_COMPRESSION_2NDHALF);
+        brw_MOV(p,
+                brw_message_reg(nr + channel + 4),
+                sechalf(arg0[channel]));
+      }
+
+      /* skip over the regs populated above:
+       */
+      nr += 8;
+   
+      brw_pop_insn_state(p);
+   }
+
+   if (c->key.source_depth_to_render_target)
+   {
+      if (c->key.computes_depth) 
+        brw_MOV(p, brw_message_reg(nr), arg2[2]);
+      else 
+        brw_MOV(p, brw_message_reg(nr), arg1[1]); /* ? */
+
+      nr += 2;
+   }
+
+   if (c->key.dest_depth_reg)
+   {
+      GLuint comp = c->key.dest_depth_reg / 2;
+      GLuint off = c->key.dest_depth_reg % 2;
+
+      if (off != 0) {
+         brw_push_insn_state(p);
+         brw_set_compression_control(p, BRW_COMPRESSION_NONE);
+
+         brw_MOV(p, brw_message_reg(nr), offset(arg1[comp],1));
+         /* 2nd half? */
+         brw_MOV(p, brw_message_reg(nr+1), arg1[comp+1]);
+         brw_pop_insn_state(p);
+      }
+      else {
+         brw_MOV(p, brw_message_reg(nr), arg1[comp]);
+      }
+      nr += 2;
+   }
+
+   if (!c->key.runtime_check_aads_emit) {
+      if (c->key.aa_dest_stencil_reg)
+        emit_aa(c, arg1, 2);
+
+      fire_fb_write(c, 0, nr, target, eot);
+   }
+   else {
+      struct brw_reg v1_null_ud = vec1(retype(brw_null_reg(), BRW_REGISTER_TYPE_UD));
+      struct brw_reg ip = brw_ip_reg();
+      struct brw_instruction *jmp;
+      
+      brw_set_compression_control(p, BRW_COMPRESSION_NONE);
+      brw_set_conditionalmod(p, BRW_CONDITIONAL_Z);
+      brw_AND(p, 
+             v1_null_ud, 
+             get_element_ud(brw_vec8_grf(1,0), 6), 
+             brw_imm_ud(1<<26)); 
+
+      jmp = brw_JMPI(p, ip, ip, brw_imm_d(0));
+      {
+        emit_aa(c, arg1, 2);
+        fire_fb_write(c, 0, nr, target, eot);
+        /* note - thread killed in subroutine */
+      }
+      brw_land_fwd_jump(p, jmp);
+
+      /* ELSE: Shuffle up one register to fill in the hole left for AA:
+       */
+      fire_fb_write(c, 1, nr-1, target, eot);
+   }
+}
+
+
+/**
+ * Move a GPR to scratch memory. 
+ */
+static void emit_spill( struct brw_wm_compile *c,
+                       struct brw_reg reg,
+                       GLuint slot )
+{
+   struct brw_compile *p = &c->func;
+
+   /*
+     mov (16) m2.0<1>:ud   r2.0<8;8,1>:ud   { Align1 Compr }
+   */
+   brw_MOV(p, brw_message_reg(2), reg);
+
+   /*
+     mov (1) r0.2<1>:d    0x00000080:d     { Align1 NoMask }
+     send (16) null.0<1>:uw m1               r0.0<8;8,1>:uw   0x053003ff:ud    { Align1 }
+   */
+   brw_dp_WRITE_16(p, 
+                  retype(vec16(brw_vec8_grf(0, 0)), BRW_REGISTER_TYPE_UW),
+                  slot);
+}
+
+
+/**
+ * Load a GPR from scratch memory. 
+ */
+static void emit_unspill( struct brw_wm_compile *c,
+                         struct brw_reg reg,
+                         GLuint slot )
+{
+   struct brw_compile *p = &c->func;
+
+   /* Slot 0 is the undef value.
+    */
+   if (slot == 0) {
+      brw_MOV(p, reg, brw_imm_f(0));
+      return;
+   }
+
+   /*
+     mov (1) r0.2<1>:d    0x000000c0:d     { Align1 NoMask }
+     send (16) r110.0<1>:uw m1               r0.0<8;8,1>:uw   0x041243ff:ud    { Align1 }
+   */
+
+   brw_dp_READ_16(p,
+                 retype(vec16(reg), BRW_REGISTER_TYPE_UW),
+                 slot);
+}
+
+
+/**
+ * Retrieve up to 4 GEN4 register pairs for the given wm reg:
+ * Args with unspill_reg != 0 will be loaded from scratch memory.
+ */
+static void get_argument_regs( struct brw_wm_compile *c,
+                              struct brw_wm_ref *arg[],
+                              struct brw_reg *regs )
+{
+   GLuint i;
+
+   for (i = 0; i < 4; i++) {
+      if (arg[i]) {
+        if (arg[i]->unspill_reg)
+           emit_unspill(c,
+                        brw_vec8_grf(arg[i]->unspill_reg, 0),
+                        arg[i]->value->spill_slot);
+
+        regs[i] = arg[i]->hw_reg;
+      }
+      else {
+        regs[i] = brw_null_reg();
+      }
+   }
+}
+
+
+/**
+ * For values that have a spill_slot!=0, write those regs to scratch memory.
+ */
+static void spill_values( struct brw_wm_compile *c,
+                         struct brw_wm_value *values,
+                         GLuint nr )
+{
+   GLuint i;
+
+   for (i = 0; i < nr; i++)
+      if (values[i].spill_slot) 
+        emit_spill(c, values[i].hw_reg, values[i].spill_slot);
+}
+
+
+/* Emit the fragment program instructions here.
+ */
+void brw_wm_emit( struct brw_wm_compile *c )
+{
+   struct brw_compile *p = &c->func;
+   GLuint insn;
+
+   brw_set_compression_control(p, BRW_COMPRESSION_COMPRESSED);
+
+   /* Check if any of the payload regs need to be spilled:
+    */
+   spill_values(c, c->payload.depth, 4);
+   spill_values(c, c->creg, c->nr_creg);
+   spill_values(c, c->payload.input_interp, PIPE_MAX_SHADER_INPUTS);
+   
+
+   for (insn = 0; insn < c->nr_insns; insn++) {
+
+      struct brw_wm_instruction *inst = &c->instruction[insn];
+      struct brw_reg args[3][4], dst[4];
+      GLuint i, dst_flags;
+      
+      /* Get argument regs:
+       */
+      for (i = 0; i < 3; i++) 
+        get_argument_regs(c, inst->src[i], args[i]);
+
+      /* Get dest regs:
+       */
+      for (i = 0; i < 4; i++)
+        if (inst->dst[i])
+           dst[i] = inst->dst[i]->hw_reg;
+        else
+           dst[i] = brw_null_reg();
+      
+      /* Flags
+       */
+      dst_flags = inst->writemask;
+      if (inst->saturate) 
+        dst_flags |= SATURATE;
+
+      switch (inst->opcode) {
+        /* Generated instructions for calculating triangle interpolants:
+         */
+      case WM_PIXELXY:
+        emit_pixel_xy(p, dst, dst_flags);
+        break;
+
+      case WM_DELTAXY:
+        emit_delta_xy(p, dst, dst_flags, args[0]);
+        break;
+
+      case WM_WPOSXY:
+        emit_wpos_xy(c, dst, dst_flags, args[0]);
+        break;
+
+      case WM_PIXELW:
+        emit_pixel_w(p, dst, dst_flags, args[0], args[1]);
+        break;
+
+      case WM_LINTERP:
+        emit_linterp(p, dst, dst_flags, args[0], args[1]);
+        break;
+
+      case WM_PINTERP:
+        emit_pinterp(p, dst, dst_flags, args[0], args[1], args[2]);
+        break;
+
+      case WM_CINTERP:
+        emit_cinterp(p, dst, dst_flags, args[0]);
+        break;
+
+      case WM_FB_WRITE:
+        emit_fb_write(c, args[0], args[1], args[2], inst->target, inst->eot);
+        break;
+
+      case WM_FRONTFACING:
+        emit_frontfacing(p, dst, dst_flags);
+        break;
+
+        /* Straightforward arithmetic:
+         */
+      case TGSI_OPCODE_ADD:
+        emit_alu2(p, brw_ADD, dst, dst_flags, args[0], args[1]);
+        break;
+
+      case TGSI_OPCODE_FRC:
+        emit_alu1(p, brw_FRC, dst, dst_flags, args[0]);
+        break;
+
+      case TGSI_OPCODE_FLR:
+        emit_alu1(p, brw_RNDD, dst, dst_flags, args[0]);
+        break;
+
+      case TGSI_OPCODE_DDX:
+        emit_ddxy(p, dst, dst_flags, GL_TRUE, args[0]);
+        break;
+
+      case TGSI_OPCODE_DDY:
+        emit_ddxy(p, dst, dst_flags, GL_FALSE, args[0]);
+        break;
+
+      case TGSI_OPCODE_DP3:
+        emit_dp3(p, dst, dst_flags, args[0], args[1]);
+        break;
+
+      case TGSI_OPCODE_DP4:
+        emit_dp4(p, dst, dst_flags, args[0], args[1]);
+        break;
+
+      case TGSI_OPCODE_DPH:
+        emit_dph(p, dst, dst_flags, args[0], args[1]);
+        break;
+
+      case TGSI_OPCODE_TRUNC:
+        emit_trunc(p, dst, dst_flags, args[0]);
+        break;
+
+      case TGSI_OPCODE_LRP:
+        emit_lrp(p, dst, dst_flags, args[0], args[1], args[2]);
+        break;
+
+      case TGSI_OPCODE_MAD:    
+        emit_mad(p, dst, dst_flags, args[0], args[1], args[2]);
+        break;
+
+      case TGSI_OPCODE_MOV:
+        emit_alu1(p, brw_MOV, dst, dst_flags, args[0]);
+        break;
+
+      case TGSI_OPCODE_MUL:
+        emit_alu2(p, brw_MUL, dst, dst_flags, args[0], args[1]);
+        break;
+
+      case TGSI_OPCODE_XPD:
+        emit_xpd(p, dst, dst_flags, args[0], args[1]);
+        break;
+
+        /* Higher math functions:
+         */
+      case TGSI_OPCODE_RCP:
+        emit_math1(p, BRW_MATH_FUNCTION_INV, dst, dst_flags, args[0]);
+        break;
+
+      case TGSI_OPCODE_RSQ:
+        emit_math1(p, BRW_MATH_FUNCTION_RSQ, dst, dst_flags, args[0]);
+        break;
+
+      case TGSI_OPCODE_SIN:
+        emit_math1(p, BRW_MATH_FUNCTION_SIN, dst, dst_flags, args[0]);
+        break;
+
+      case TGSI_OPCODE_COS:
+        emit_math1(p, BRW_MATH_FUNCTION_COS, dst, dst_flags, args[0]);
+        break;
+
+      case TGSI_OPCODE_EX2:
+        emit_math1(p, BRW_MATH_FUNCTION_EXP, dst, dst_flags, args[0]);
+        break;
+
+      case TGSI_OPCODE_LG2:
+        emit_math1(p, BRW_MATH_FUNCTION_LOG, dst, dst_flags, args[0]);
+        break;
+
+      case TGSI_OPCODE_SCS:
+        /* There is an scs math function, but it would need some
+         * fixup for 16-element execution.
+         */
+        if (dst_flags & BRW_WRITEMASK_X)
+           emit_math1(p, BRW_MATH_FUNCTION_COS, dst, (dst_flags&SATURATE)|BRW_WRITEMASK_X, args[0]);
+        if (dst_flags & BRW_WRITEMASK_Y)
+           emit_math1(p, BRW_MATH_FUNCTION_SIN, dst+1, (dst_flags&SATURATE)|BRW_WRITEMASK_X, args[0]);
+        break;
+
+      case TGSI_OPCODE_POW:
+        emit_math2(p, BRW_MATH_FUNCTION_POW, dst, dst_flags, args[0], args[1]);
+        break;
+
+        /* Comparisons:
+         */
+      case TGSI_OPCODE_CMP:
+        emit_cmp(p, dst, dst_flags, args[0], args[1], args[2]);
+        break;
+
+      case TGSI_OPCODE_MAX:
+        emit_max(p, dst, dst_flags, args[0], args[1]);
+        break;
+
+      case TGSI_OPCODE_MIN:
+        emit_min(p, dst, dst_flags, args[0], args[1]);
+        break;
+
+      case TGSI_OPCODE_SLT:
+        emit_slt(p, dst, dst_flags, args[0], args[1]);
+        break;
+
+      case TGSI_OPCODE_SLE:
+        emit_sle(p, dst, dst_flags, args[0], args[1]);
+       break;
+      case TGSI_OPCODE_SGT:
+        emit_sgt(p, dst, dst_flags, args[0], args[1]);
+       break;
+      case TGSI_OPCODE_SGE:
+        emit_sge(p, dst, dst_flags, args[0], args[1]);
+        break;
+      case TGSI_OPCODE_SEQ:
+        emit_seq(p, dst, dst_flags, args[0], args[1]);
+       break;
+      case TGSI_OPCODE_SNE:
+        emit_sne(p, dst, dst_flags, args[0], args[1]);
+       break;
+
+      case TGSI_OPCODE_LIT:
+        emit_lit(p, dst, dst_flags, args[0]);
+        break;
+
+        /* Texturing operations:
+         */
+      case TGSI_OPCODE_TEX:
+        emit_tex(c, inst, dst, dst_flags, args[0], inst->sampler);
+        break;
+
+      case TGSI_OPCODE_TXB:
+        emit_txb(c, inst, dst, dst_flags, args[0], inst->sampler);
+        break;
+
+      case TGSI_OPCODE_KIL:
+        emit_kil(c, args[0]);
+        break;
+
+      case TGSI_OPCODE_KILP:
+        emit_killp(c);
+        break;
+
+      default:
+        debug_printf("Unsupported opcode %i (%s) in fragment shader\n",
+                     inst->opcode, 
+                     tgsi_get_opcode_info(inst->opcode)->mnemonic);
+      }
+      
+      for (i = 0; i < 4; i++)
+       if (inst->dst[i] && inst->dst[i]->spill_slot) 
+          emit_spill(c, 
+                     inst->dst[i]->hw_reg, 
+                     inst->dst[i]->spill_slot);
+   }
+
+   if (BRW_DEBUG & DEBUG_WM) {
+      debug_printf("wm-native:\n");
+      brw_disasm(stderr, p->store, p->nr_insn);
+   }
+}
diff --git a/src/gallium/drivers/i965/brw_wm_fp.c b/src/gallium/drivers/i965/brw_wm_fp.c
new file mode 100644 (file)
index 0000000..9c5b527
--- /dev/null
@@ -0,0 +1,1224 @@
+/*
+ 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 "pipe/p_shader_tokens.h"
+
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
+#include "tgsi/tgsi_parse.h"
+#include "tgsi/tgsi_dump.h"
+#include "tgsi/tgsi_info.h"
+#include "tgsi/tgsi_util.h"
+
+#include "brw_wm.h"
+#include "brw_util.h"
+#include "brw_debug.h"
+
+
+/***********************************************************************
+ * Source regs
+ */
+
+static struct brw_fp_src src_reg(GLuint file, GLuint idx)
+{
+   struct brw_fp_src reg;
+   reg.file = file;
+   reg.index = idx;
+   reg.swizzle = BRW_SWIZZLE_XYZW;
+   reg.indirect = 0;
+   reg.negate = 0;
+   reg.abs = 0;
+   return reg;
+}
+
+static struct brw_fp_src src_reg_from_dst(struct brw_fp_dst dst)
+{
+   return src_reg(dst.file, dst.index);
+}
+
+static struct brw_fp_src src_undef( void )
+{
+   return src_reg(TGSI_FILE_NULL, 0);
+}
+
+static GLboolean src_is_undef(struct brw_fp_src src)
+{
+   return src.file == TGSI_FILE_NULL;
+}
+
+static struct brw_fp_src src_swizzle( struct brw_fp_src reg, int x, int y, int z, int w )
+{
+   unsigned swz = reg.swizzle;
+
+   reg.swizzle = ( BRW_GET_SWZ(swz, x) << 0 |
+                  BRW_GET_SWZ(swz, y) << 2 |
+                  BRW_GET_SWZ(swz, z) << 4 |
+                  BRW_GET_SWZ(swz, w) << 6 );
+
+   return reg;
+}
+
+static struct brw_fp_src src_scalar( struct brw_fp_src reg, int x )
+{
+   return src_swizzle(reg, x, x, x, x);
+}
+
+static struct brw_fp_src src_abs( struct brw_fp_src src )
+{
+   src.negate = 0;
+   src.abs = 1;
+   return src;
+}
+
+static struct brw_fp_src src_negate( struct brw_fp_src src )
+{
+   src.negate = 1;
+   src.abs = 0;
+   return src;
+}
+
+
+static int match_or_expand_immediate( const float *v,
+                                      unsigned nr,
+                                      float *v2,
+                                      unsigned *nr2,
+                                      unsigned *swizzle )
+{
+   unsigned i, j;
+   
+   *swizzle = 0;
+
+   for (i = 0; i < nr; i++) {
+      boolean found = FALSE;
+
+      for (j = 0; j < *nr2 && !found; j++) {
+         if (v[i] == v2[j]) {
+            *swizzle |= j << (i * 2);
+            found = TRUE;
+         }
+      }
+
+      if (!found) {
+         if (*nr2 >= 4) 
+            return FALSE;
+
+         v2[*nr2] = v[i];
+         *swizzle |= *nr2 << (i * 2);
+         (*nr2)++;
+      }
+   }
+
+   return TRUE;
+}
+
+
+
+/* Internally generated immediates: overkill...
+ */
+static struct brw_fp_src src_imm( struct brw_wm_compile *c, 
+                                 const GLfloat *v, 
+                                 unsigned nr)
+{
+   unsigned i, j;
+   unsigned swizzle;
+
+   /* Could do a first pass where we examine all existing immediates
+    * without expanding.
+    */
+
+   for (i = 0; i < c->nr_immediates; i++) {
+      if (match_or_expand_immediate( v, 
+                                     nr,
+                                     c->immediate[i].v,
+                                     &c->immediate[i].nr, 
+                                     &swizzle ))
+         goto out;
+   }
+
+   if (c->nr_immediates < Elements(c->immediate)) {
+      i = c->nr_immediates++;
+      if (match_or_expand_immediate( v,
+                                     nr,
+                                     c->immediate[i].v,
+                                     &c->immediate[i].nr, 
+                                     &swizzle ))
+         goto out;
+   }
+
+   c->error = 1;
+   return src_undef();
+
+out:
+   /* Make sure that all referenced elements are from this immediate.
+    * Has the effect of making size-one immediates into scalars.
+    */
+   for (j = nr; j < 4; j++)
+      swizzle |= (swizzle & 0x3) << (j * 2);
+
+   return src_swizzle( src_reg( TGSI_FILE_IMMEDIATE, i ),
+                      BRW_GET_SWZ(swizzle, X),
+                      BRW_GET_SWZ(swizzle, Y),
+                      BRW_GET_SWZ(swizzle, Z),
+                      BRW_GET_SWZ(swizzle, W) );
+}
+
+
+
+static struct brw_fp_src src_imm1f( struct brw_wm_compile *c,
+                                   GLfloat f )
+{
+   return src_imm(c, &f, 1);
+}
+
+static struct brw_fp_src src_imm4f( struct brw_wm_compile *c,
+                                   GLfloat x,
+                                   GLfloat y,
+                                   GLfloat z,
+                                   GLfloat w)
+{
+   GLfloat f[4] = {x,y,z,w};
+   return src_imm(c, f, 4);
+}
+
+
+
+/***********************************************************************
+ * Dest regs
+ */
+
+static struct brw_fp_dst dst_reg(GLuint file, GLuint idx)
+{
+   struct brw_fp_dst reg;
+   reg.file = file;
+   reg.index = idx;
+   reg.writemask = BRW_WRITEMASK_XYZW;
+   reg.indirect = 0;
+   reg.saturate = 0;
+   return reg;
+}
+
+static struct brw_fp_dst dst_mask( struct brw_fp_dst reg, int mask )
+{
+   reg.writemask &= mask;
+   return reg;
+}
+
+static struct brw_fp_dst dst_undef( void )
+{
+   return dst_reg(TGSI_FILE_NULL, 0);
+}
+
+static boolean dst_is_undef( struct brw_fp_dst dst )
+{
+   return dst.file == TGSI_FILE_NULL;
+}
+
+static struct brw_fp_dst dst_saturate( struct brw_fp_dst reg, boolean flag )
+{
+   reg.saturate = flag;
+   return reg;
+}
+
+static struct brw_fp_dst get_temp( struct brw_wm_compile *c )
+{
+   int bit = ffs( ~c->fp_temp );
+
+   if (!bit) {
+      debug_printf("%s: out of temporaries\n", __FILE__);
+   }
+
+   c->fp_temp |= 1<<(bit-1);
+   return dst_reg(TGSI_FILE_TEMPORARY, c->fp_first_internal_temp+(bit-1));
+}
+
+
+static void release_temp( struct brw_wm_compile *c, struct brw_fp_dst temp )
+{
+   c->fp_temp &= ~(1 << (temp.index - c->fp_first_internal_temp));
+}
+
+
+/***********************************************************************
+ * Instructions 
+ */
+
+static struct brw_fp_instruction *get_fp_inst(struct brw_wm_compile *c)
+{
+   return &c->fp_instructions[c->nr_fp_insns++];
+}
+
+static struct brw_fp_instruction * emit_tex_op(struct brw_wm_compile *c,
+                                            GLuint op,
+                                            struct brw_fp_dst dest,
+                                            GLuint tex_unit,
+                                            GLuint target,
+                                            GLuint sampler,
+                                            struct brw_fp_src src0,
+                                            struct brw_fp_src src1,
+                                            struct brw_fp_src src2 )
+{
+   struct brw_fp_instruction *inst = get_fp_inst(c);
+
+   if (tex_unit || target)
+      assert(op == TGSI_OPCODE_TXP ||
+             op == TGSI_OPCODE_TXB ||
+             op == TGSI_OPCODE_TEX ||
+             op == WM_FB_WRITE);
+
+   inst->opcode = op;
+   inst->dst = dest;
+   inst->tex_unit = tex_unit;
+   inst->target = target;
+   inst->sampler = sampler;
+   inst->src[0] = src0;
+   inst->src[1] = src1;
+   inst->src[2] = src2;
+
+   return inst;
+}
+   
+
+static INLINE void emit_op3(struct brw_wm_compile *c,
+                           GLuint op,
+                           struct brw_fp_dst dest,
+                           struct brw_fp_src src0,
+                           struct brw_fp_src src1,
+                           struct brw_fp_src src2 )
+{
+   emit_tex_op(c, op, dest, 0, 0, 0, src0, src1, src2);
+}
+
+
+static INLINE void emit_op2(struct brw_wm_compile *c,
+                           GLuint op,
+                           struct brw_fp_dst dest,
+                           struct brw_fp_src src0,
+                           struct brw_fp_src src1)
+{
+   emit_tex_op(c, op, dest, 0, 0, 0, src0, src1, src_undef());
+}
+
+static INLINE void emit_op1(struct brw_wm_compile *c,
+                           GLuint op,
+                           struct brw_fp_dst dest,
+                           struct brw_fp_src src0)
+{
+   emit_tex_op(c, op, dest, 0, 0, 0, src0, src_undef(), src_undef());
+}
+
+static INLINE void emit_op0(struct brw_wm_compile *c,
+                          GLuint op,
+                          struct brw_fp_dst dest)
+{
+   emit_tex_op(c, op, dest, 0, 0, 0, src_undef(), src_undef(), src_undef());
+}
+
+
+
+/* Many opcodes produce the same value across all the result channels.
+ * We'd rather not have to support that splatting in the opcode implementations,
+ * and brw_wm_pass*.c wants to optimize them out by shuffling references around
+ * anyway.  We can easily get both by emitting the opcode to one channel, and
+ * then MOVing it to the others, which brw_wm_pass*.c already understands.
+ */
+static void emit_scalar_insn(struct brw_wm_compile *c,
+                            unsigned opcode,
+                            struct brw_fp_dst dst,
+                            struct brw_fp_src src0,
+                            struct brw_fp_src src1,
+                            struct brw_fp_src src2 )
+{
+   unsigned first_chan = ffs(dst.writemask) - 1;
+   unsigned first_mask = 1 << first_chan;
+
+   if (dst.writemask == 0)
+      return;
+
+   emit_op3( c, opcode,
+            dst_mask(dst, first_mask),
+            src0, src1, src2 );
+
+   if (dst.writemask != first_mask) {
+      emit_op1(c, TGSI_OPCODE_MOV,
+              dst_mask(dst, ~first_mask),
+              src_scalar(src_reg_from_dst(dst), first_chan));
+   }
+}
+
+
+/***********************************************************************
+ * Special instructions for interpolation and other tasks
+ */
+
+static struct brw_fp_src get_pixel_xy( struct brw_wm_compile *c )
+{
+   if (src_is_undef(c->fp_pixel_xy)) {
+      struct brw_fp_dst pixel_xy = get_temp(c);
+      struct brw_fp_src payload_r0_depth = src_reg(BRW_FILE_PAYLOAD, PAYLOAD_DEPTH);
+      
+      
+      /* Emit the out calculations, and hold onto the results.  Use
+       * two instructions as a temporary is required.
+       */   
+      /* pixel_xy.xy = PIXELXY payload[0];
+       */
+      emit_op1(c,
+              WM_PIXELXY,
+              dst_mask(pixel_xy, BRW_WRITEMASK_XY),
+              payload_r0_depth);
+
+      c->fp_pixel_xy = src_reg_from_dst(pixel_xy);
+   }
+
+   return c->fp_pixel_xy;
+}
+
+static struct brw_fp_src get_delta_xy( struct brw_wm_compile *c )
+{
+   if (src_is_undef(c->fp_delta_xy)) {
+      struct brw_fp_dst delta_xy = get_temp(c);
+      struct brw_fp_src pixel_xy = get_pixel_xy(c);
+      struct brw_fp_src payload_r0_depth = src_reg(BRW_FILE_PAYLOAD, PAYLOAD_DEPTH);
+      
+      /* deltas.xy = DELTAXY pixel_xy, payload[0]
+       */
+      emit_op3(c,
+             WM_DELTAXY,
+             dst_mask(delta_xy, BRW_WRITEMASK_XY),
+             pixel_xy, 
+             payload_r0_depth,
+             src_undef());
+      
+      c->fp_delta_xy = src_reg_from_dst(delta_xy);
+   }
+
+   return c->fp_delta_xy;
+}
+
+static struct brw_fp_src get_pixel_w( struct brw_wm_compile *c )
+{
+   if (src_is_undef(c->fp_pixel_w)) {
+      struct brw_fp_dst pixel_w = get_temp(c);
+      struct brw_fp_src deltas = get_delta_xy(c);
+
+      /* XXX: assuming position is always first -- valid? 
+       */
+      struct brw_fp_src interp_wpos = src_reg(BRW_FILE_PAYLOAD, 0);
+
+      /* deltas.xyw = DELTAS2 deltas.xy, payload.interp_wpos.x
+       */
+      emit_op3(c,
+              WM_PIXELW,
+              dst_mask(pixel_w, BRW_WRITEMASK_W),
+              interp_wpos,
+              deltas, 
+              src_undef());
+      
+
+      c->fp_pixel_w = src_reg_from_dst(pixel_w);
+   }
+
+   return c->fp_pixel_w;
+}
+
+
+/***********************************************************************
+ * Emit INTERP instructions ahead of first use of each attrib.
+ */
+
+static void emit_interp( struct brw_wm_compile *c,
+                        GLuint idx,
+                        GLuint semantic,
+                        GLuint interp_mode )
+{
+   struct brw_fp_dst dst = dst_reg(TGSI_FILE_INPUT, idx);
+   struct brw_fp_src interp = src_reg(BRW_FILE_PAYLOAD, idx);
+   struct brw_fp_src deltas = get_delta_xy(c);
+
+   /* Need to use PINTERP on attributes which have been
+    * multiplied by 1/W in the SF program, and LINTERP on those
+    * which have not:
+    */
+   switch (semantic) {
+   case TGSI_SEMANTIC_POSITION:
+      /* Have to treat wpos.xy specially:
+       */
+      emit_op1(c,
+             WM_WPOSXY,
+             dst_mask(dst, BRW_WRITEMASK_XY),
+             get_pixel_xy(c));
+      
+      /* TGSI_FILE_INPUT.attr.xyzw = INTERP payload.interp[attr].x, deltas.xyw
+       */
+      emit_op2(c,
+              WM_LINTERP,
+              dst_mask(dst, BRW_WRITEMASK_ZW),
+              interp,
+              deltas);
+      break;
+
+   case TGSI_SEMANTIC_COLOR:
+      if (c->key.flat_shade) {
+        emit_op1(c,
+                WM_CINTERP,
+                dst,
+                interp);
+      }
+      else if (interp_mode == TGSI_INTERPOLATE_LINEAR) {
+        emit_op2(c,
+                 WM_LINTERP,
+                 dst,
+                 interp,
+                 deltas);
+      }
+      else {
+        emit_op3(c,
+                 WM_PINTERP,
+                 dst,
+                 interp,
+                 deltas,
+                 get_pixel_w(c));
+      }
+
+      break;
+
+   case TGSI_SEMANTIC_FOG:
+      /* Interpolate the fog coordinate */
+      emit_op3(c,
+             WM_PINTERP,
+             dst_mask(dst, BRW_WRITEMASK_X),
+             interp,
+             deltas,
+             get_pixel_w(c));
+
+      emit_op1(c,
+              TGSI_OPCODE_MOV,
+              dst_mask(dst, BRW_WRITEMASK_YZ),
+              src_imm1f(c, 0.0));
+
+      emit_op1(c,
+              TGSI_OPCODE_MOV,
+              dst_mask(dst, BRW_WRITEMASK_W),
+              src_imm1f(c, 1.0));
+      break;
+
+   case TGSI_SEMANTIC_FACE:
+      /* XXX review/test this case */
+      emit_op0(c,
+              WM_FRONTFACING,
+              dst_mask(dst, BRW_WRITEMASK_X));
+      
+      emit_op1(c,
+             TGSI_OPCODE_MOV,
+             dst_mask(dst, BRW_WRITEMASK_YZ),
+              src_imm1f(c, 0.0));
+
+      emit_op1(c,
+             TGSI_OPCODE_MOV,
+             dst_mask(dst, BRW_WRITEMASK_W),
+              src_imm1f(c, 1.0));
+      break;
+
+   case TGSI_SEMANTIC_PSIZE:
+      /* XXX review/test this case */
+      emit_op3(c,
+              WM_PINTERP,
+              dst_mask(dst, BRW_WRITEMASK_XY),
+              interp,
+              deltas,
+              get_pixel_w(c));
+
+      emit_op1(c,
+             TGSI_OPCODE_MOV,
+             dst_mask(dst, BRW_WRITEMASK_Z),
+             src_imm1f(c, 0.0f));
+
+      emit_op1(c,
+             TGSI_OPCODE_MOV,
+             dst_mask(dst, BRW_WRITEMASK_W),
+             src_imm1f(c, 1.0f));
+      break;
+
+   default: 
+      switch (interp_mode) {
+      case TGSI_INTERPOLATE_CONSTANT:
+        emit_op1(c,
+                 WM_CINTERP,
+                 dst,
+                 interp);
+        break;
+
+      case TGSI_INTERPOLATE_LINEAR:
+        emit_op2(c,
+                 WM_LINTERP,
+                 dst,
+                 interp,
+                 deltas);
+        break;
+
+      case TGSI_INTERPOLATE_PERSPECTIVE:
+        emit_op3(c,
+                 WM_PINTERP,
+                 dst,
+                 interp,
+                 deltas,
+                 get_pixel_w(c));
+        break;
+      }
+      break;
+   }
+}
+
+
+/***********************************************************************
+ * Expand various instructions here to simpler forms.  
+ */
+static void precalc_dst( struct brw_wm_compile *c,
+                        struct brw_fp_dst dst,
+                        struct brw_fp_src src0,
+                        struct brw_fp_src src1 )
+{
+   if (dst.writemask & BRW_WRITEMASK_Y) {      
+      /* dst.y = mul src0.y, src1.y
+       */
+      emit_op2(c,
+              TGSI_OPCODE_MUL,
+              dst_mask(dst, BRW_WRITEMASK_Y),
+              src0,
+              src1);
+   }
+
+   if (dst.writemask & BRW_WRITEMASK_XZ) {
+      /* dst.z = mov src0.zzzz
+       */
+      emit_op1(c,
+             TGSI_OPCODE_MOV,
+             dst_mask(dst, BRW_WRITEMASK_Z),
+             src_scalar(src0, Z));
+
+      /* dst.x = imm1f(1.0)
+       */
+      emit_op1(c,
+             TGSI_OPCODE_MOV,
+             dst_saturate(dst_mask(dst, BRW_WRITEMASK_X), 0),
+             src_imm1f(c, 1.0));
+   }
+   if (dst.writemask & BRW_WRITEMASK_W) {
+      /* dst.w = mov src1.w
+       */
+      emit_op1(c,
+              TGSI_OPCODE_MOV,
+              dst_mask(dst, BRW_WRITEMASK_W),
+              src1);
+   }
+}
+
+
+static void precalc_lit( struct brw_wm_compile *c,
+                        struct brw_fp_dst dst,
+                        struct brw_fp_src src0 )
+{
+   if (dst.writemask & BRW_WRITEMASK_XW) {
+      /* dst.xw = imm(1.0f)
+       */
+      emit_op1(c,
+              TGSI_OPCODE_MOV,
+              dst_saturate(dst_mask(dst, BRW_WRITEMASK_XW), 0),
+              src_imm1f(c, 1.0f));
+   }
+
+   if (dst.writemask & BRW_WRITEMASK_YZ) {
+      emit_op1(c,
+              TGSI_OPCODE_LIT,
+              dst_mask(dst, BRW_WRITEMASK_YZ),
+              src0);
+   }
+}
+
+
+/**
+ * Some TEX instructions require extra code, cube map coordinate
+ * normalization, or coordinate scaling for RECT textures, etc.
+ * This function emits those extra instructions and the TEX
+ * instruction itself.
+ */
+static void precalc_tex( struct brw_wm_compile *c,
+                        struct brw_fp_dst dst,
+                        unsigned target,
+                        unsigned unit,
+                        struct brw_fp_src src0,
+                        struct brw_fp_src sampler )
+{
+   struct brw_fp_src coord = src_undef();
+   struct brw_fp_dst tmp = dst_undef();
+
+   assert(unit < BRW_MAX_TEX_UNIT);
+
+   /* Cubemap: find longest component of coord vector and normalize
+    * it.
+    */
+   if (target == TGSI_TEXTURE_CUBE) {
+      struct brw_fp_src tmpsrc;
+
+      tmp = get_temp(c);
+      tmpsrc = src_reg_from_dst(tmp);
+
+      /* tmp = abs(src0) */
+      emit_op1(c, 
+              TGSI_OPCODE_MOV,
+              tmp,
+              src_abs(src0));
+
+      /* tmp.X = MAX(tmp.X, tmp.Y) */
+      emit_op2(c, TGSI_OPCODE_MAX,
+              dst_mask(tmp, BRW_WRITEMASK_X),
+              src_scalar(tmpsrc, X),
+              src_scalar(tmpsrc, Y));
+
+      /* tmp.X = MAX(tmp.X, tmp.Z) */
+      emit_op2(c, TGSI_OPCODE_MAX,
+              dst_mask(tmp, BRW_WRITEMASK_X),
+              tmpsrc,
+              src_scalar(tmpsrc, Z));
+
+      /* tmp.X = 1 / tmp.X */
+      emit_op1(c, TGSI_OPCODE_RCP,
+             dst_mask(tmp, BRW_WRITEMASK_X),
+             tmpsrc);
+
+      /* tmp = src0 * tmp.xxxx */
+      emit_op2(c, TGSI_OPCODE_MUL,
+              tmp,
+              src0,
+              src_scalar(tmpsrc, X));
+
+      coord = tmpsrc;
+   }
+   else if (target == TGSI_TEXTURE_RECT ||
+           target == TGSI_TEXTURE_SHADOWRECT) {
+      /* XXX: need a mechanism for internally generated constants.
+       */
+      coord = src0;
+   }
+   else {
+      coord = src0;
+   }
+
+   /* Need to emit YUV texture conversions by hand.  Probably need to
+    * do this here - the alternative is in brw_wm_emit.c, but the
+    * conversion requires allocating a temporary variable which we
+    * don't have the facility to do that late in the compilation.
+    */
+   if (c->key.yuvtex_mask & (1 << unit)) {
+      /* convert ycbcr to RGBA */
+      GLboolean  swap_uv = c->key.yuvtex_swap_mask & (1<<unit);
+      struct brw_fp_dst tmp = get_temp(c);
+      struct brw_fp_src tmpsrc = src_reg_from_dst(tmp);
+      struct brw_fp_src C0 = src_imm4f( c,  -.5, -.0625, -.5, 1.164 );
+      struct brw_fp_src C1 = src_imm4f( c, 1.596, -0.813, 2.018, -.391 );
+     
+      /* tmp     = TEX ...
+       */
+      emit_tex_op(c, 
+                  TGSI_OPCODE_TEX,
+                  dst_saturate(tmp, dst.saturate),
+                  unit,
+                  target,
+                  sampler.index,
+                  coord,
+                  src_undef(),
+                  src_undef());
+
+      /* tmp.xyz =  ADD TMP, C0
+       */
+      emit_op2(c, TGSI_OPCODE_ADD,
+              dst_mask(tmp, BRW_WRITEMASK_XYZ),
+              tmpsrc,
+              C0);
+
+      /* YUV.y   = MUL YUV.y, C0.w
+       */
+      emit_op2(c, TGSI_OPCODE_MUL,
+              dst_mask(tmp, BRW_WRITEMASK_Y),
+              tmpsrc,
+              src_scalar(C0, W));
+
+      /* 
+       * if (UV swaped)
+       *     RGB.xyz = MAD YUV.zzx, C1, YUV.y
+       * else
+       *     RGB.xyz = MAD YUV.xxz, C1, YUV.y
+       */
+
+      emit_op3(c, TGSI_OPCODE_MAD,
+              dst_mask(dst, BRW_WRITEMASK_XYZ),
+              ( swap_uv ? 
+                src_swizzle(tmpsrc, Z,Z,X,X) : 
+                src_swizzle(tmpsrc, X,X,Z,Z)),
+              C1,
+              src_scalar(tmpsrc, Y));
+
+      /*  RGB.y   = MAD YUV.z, C1.w, RGB.y
+       */
+      emit_op3(c,
+              TGSI_OPCODE_MAD,
+              dst_mask(dst, BRW_WRITEMASK_Y),
+              src_scalar(tmpsrc, Z),
+              src_scalar(C1, W),
+              src_scalar(src_reg_from_dst(dst), Y));
+
+      release_temp(c, tmp);
+   }
+   else {
+      /* ordinary RGBA tex instruction */
+      emit_tex_op(c, 
+                  TGSI_OPCODE_TEX,
+                  dst,
+                  unit,
+                  target,
+                  sampler.index,
+                  coord,
+                  src_undef(),
+                  src_undef());
+   }
+
+   /* XXX: add GL_EXT_texture_swizzle support to gallium -- by
+    * generating shader varients in mesa state tracker.
+    */
+
+   /* Release this temp if we ended up allocating it:
+    */
+   if (!dst_is_undef(tmp))
+      release_temp(c, tmp);
+}
+
+
+/**
+ * Check if the given TXP instruction really needs the divide-by-W step.
+ */
+static GLboolean projtex( struct brw_wm_compile *c,
+                         unsigned target, 
+                         struct brw_fp_src src )
+{
+   /* Only try to detect the simplest cases.  Could detect (later)
+    * cases where we are trying to emit code like RCP {1.0}, MUL x,
+    * {1.0}, and so on.
+    *
+    * More complex cases than this typically only arise from
+    * user-provided fragment programs anyway:
+    */
+   if (target == TGSI_TEXTURE_CUBE)
+      return GL_FALSE;  /* ut2004 gun rendering !?! */
+   
+   if (src.file == TGSI_FILE_INPUT && 
+       BRW_GET_SWZ(src.swizzle, W) == W &&
+       c->fp->info.input_interpolate[src.index] != TGSI_INTERPOLATE_PERSPECTIVE)
+      return GL_FALSE;
+
+   return GL_TRUE;
+}
+
+
+/**
+ * Emit code for TXP.
+ */
+static void precalc_txp( struct brw_wm_compile *c,
+                        struct brw_fp_dst dst,
+                        unsigned target,
+                        unsigned unit,
+                        struct brw_fp_src src0,
+                         struct brw_fp_src sampler )
+{
+   if (projtex(c, target, src0)) {
+      struct brw_fp_dst tmp = get_temp(c);
+
+      /* tmp0.w = RCP inst.arg[0][3]
+       */
+      emit_op1(c,
+             TGSI_OPCODE_RCP,
+             dst_mask(tmp, BRW_WRITEMASK_W),
+             src_scalar(src0, W));
+
+      /* tmp0.xyz =  MUL inst.arg[0], tmp0.wwww
+       */
+      emit_op2(c,
+              TGSI_OPCODE_MUL,
+              dst_mask(tmp, BRW_WRITEMASK_XYZ),
+              src0,
+              src_scalar(src_reg_from_dst(tmp), W));
+
+      /* dst = TEX tmp0
+       */
+      precalc_tex(c, 
+                 dst,
+                 target,
+                 unit,
+                 src_reg_from_dst(tmp),
+                  sampler );
+
+      release_temp(c, tmp);
+   }
+   else
+   {
+      /* dst = TEX src0
+       */
+      precalc_tex(c, dst, target, unit, src0, sampler);
+   }
+}
+
+
+/* XXX: note this returns a src_reg.
+ */
+static struct brw_fp_src
+find_output_by_semantic( struct brw_wm_compile *c,
+                        unsigned semantic,
+                        unsigned index )
+{
+   const struct tgsi_shader_info *info = &c->fp->info;
+   unsigned i;
+
+   for (i = 0; i < info->num_outputs; i++)
+      if (info->output_semantic_name[i] == semantic &&
+         info->output_semantic_index[i] == index)
+        return src_reg( TGSI_FILE_OUTPUT, i );
+
+   /* If not found, return some arbitrary immediate value:
+    *
+    * XXX: this is a good idea but immediates are up generating extra
+    * curbe entries atm, as they would have in the original driver.
+    */
+   return src_reg( TGSI_FILE_OUTPUT, 0 ); /* src_imm1f(c, 1.0); */
+}
+
+
+static void emit_fb_write( struct brw_wm_compile *c )
+{
+   struct brw_fp_src payload_r0_depth = src_reg(BRW_FILE_PAYLOAD, PAYLOAD_DEPTH);
+   struct brw_fp_src outdepth = find_output_by_semantic(c, TGSI_SEMANTIC_POSITION, 0);
+   GLuint i;
+
+
+   outdepth = src_scalar(outdepth, Z);
+
+   for (i = 0 ; i < c->key.nr_cbufs; i++) {
+      struct brw_fp_src outcolor;
+      
+      outcolor = find_output_by_semantic(c, TGSI_SEMANTIC_COLOR, i);
+
+      /* Use emit_tex_op so that we can specify the inst->target
+       * field, which is abused to contain the FB write target and the
+       * EOT marker
+       */
+      emit_tex_op(c, WM_FB_WRITE,
+                 dst_undef(),
+                 (i == c->key.nr_cbufs - 1), /* EOT */
+                 i,
+                  0,            /* no sampler */
+                 outcolor,
+                 payload_r0_depth,
+                 outdepth);
+   }
+}
+
+
+static struct brw_fp_dst translate_dst( struct brw_wm_compile *c,
+                                       const struct tgsi_full_dst_register *dst,
+                                       unsigned saturate )
+{
+   struct brw_fp_dst out;
+
+   out.file = dst->Register.File;
+   out.index = dst->Register.Index;
+   out.writemask = dst->Register.WriteMask;
+   out.indirect = dst->Register.Indirect;
+   out.saturate = (saturate == TGSI_SAT_ZERO_ONE);
+   
+   if (out.indirect) {
+      assert(dst->Indirect.File == TGSI_FILE_ADDRESS);
+      assert(dst->Indirect.Index == 0);
+   }
+   
+   return out;
+}
+
+
+static struct brw_fp_src translate_src( struct brw_wm_compile *c,
+                                       const struct tgsi_full_src_register *src )
+{
+   struct brw_fp_src out;
+
+   out.file = src->Register.File;
+   out.index = src->Register.Index;
+   out.indirect = src->Register.Indirect;
+
+   out.swizzle = ((src->Register.SwizzleX << 0) |
+                 (src->Register.SwizzleY << 2) |
+                 (src->Register.SwizzleZ << 4) |
+                 (src->Register.SwizzleW << 6));
+   
+   switch (tgsi_util_get_full_src_register_sign_mode( src, 0 )) {
+   case TGSI_UTIL_SIGN_CLEAR:
+      out.abs = 1;
+      out.negate = 0;
+      break;
+
+   case TGSI_UTIL_SIGN_SET:
+      out.abs = 1;
+      out.negate = 1;
+      break;
+
+   case TGSI_UTIL_SIGN_TOGGLE:
+      out.abs = 0;
+      out.negate = 1;
+      break;
+
+   case TGSI_UTIL_SIGN_KEEP:
+   default:
+      out.abs = 0;
+      out.negate = 0;
+      break;
+   }
+
+   if (out.indirect) {
+      assert(src->Indirect.File == TGSI_FILE_ADDRESS);
+      assert(src->Indirect.Index == 0);
+   }
+   
+   return out;
+}
+
+
+
+static void emit_insn( struct brw_wm_compile *c,
+                      const struct tgsi_full_instruction *inst )
+{
+   unsigned opcode = inst->Instruction.Opcode;
+   struct brw_fp_dst dst;
+   struct brw_fp_src src[3];
+   int i;
+
+   dst = translate_dst( c, &inst->Dst[0],
+                       inst->Instruction.Saturate );
+
+   for (i = 0; i < inst->Instruction.NumSrcRegs; i++)
+      src[i] = translate_src( c, &inst->Src[i] );
+   
+   switch (opcode) {
+   case TGSI_OPCODE_ABS:
+      emit_op1(c, TGSI_OPCODE_MOV,
+              dst, 
+              src_abs(src[0]));
+      break;
+
+   case TGSI_OPCODE_SUB: 
+      emit_op2(c, TGSI_OPCODE_ADD,
+              dst,
+              src[0],
+              src_negate(src[1]));
+      break;
+
+   case TGSI_OPCODE_SCS: 
+      emit_op1(c, TGSI_OPCODE_SCS,
+              dst_mask(dst, BRW_WRITEMASK_XY),
+              src[0]);
+      break;
+        
+   case TGSI_OPCODE_DST:
+      precalc_dst(c, dst, src[0], src[1]);
+      break;
+
+   case TGSI_OPCODE_LIT:
+      precalc_lit(c, dst, src[0]);
+      break;
+
+   case TGSI_OPCODE_TEX:
+      precalc_tex(c, dst,
+                 inst->Texture.Texture,
+                 src[1].index, /* use sampler unit for tex idx */
+                 src[0],       /* coord */
+                  src[1]);      /* sampler */
+      break;
+
+   case TGSI_OPCODE_TXP:
+      precalc_txp(c, dst,
+                 inst->Texture.Texture,
+                 src[1].index, /* use sampler unit for tex idx */
+                 src[0],       /* coord */
+                  src[1]);      /* sampler */
+      break;
+
+   case TGSI_OPCODE_TXB:
+      /* XXX: TXB not done
+       */
+      precalc_tex(c, dst,
+                 inst->Texture.Texture,
+                 src[1].index, /* use sampler unit for tex idx*/
+                 src[0],
+                  src[1]);
+      break;
+
+   case TGSI_OPCODE_XPD: 
+      emit_op2(c, TGSI_OPCODE_XPD,
+              dst_mask(dst, BRW_WRITEMASK_XYZ),
+              src[0], 
+              src[1]);
+      break;
+
+   case TGSI_OPCODE_KIL: 
+      emit_op1(c, TGSI_OPCODE_KIL,
+              dst_mask(dst_undef(), 0),
+              src[0]);
+      break;
+
+   case TGSI_OPCODE_END:
+      emit_fb_write(c);
+      break;
+   default:
+      if (!c->key.has_flow_control &&
+         brw_wm_is_scalar_result(opcode))
+        emit_scalar_insn(c, opcode, dst, src[0], src[1], src[2]);
+      else
+        emit_op3(c, opcode, dst, src[0], src[1], src[2]);
+      break;
+   }
+}
+
+/**
+ * Initial pass for fragment program code generation.
+ * This function is used by both the GLSL and non-GLSL paths.
+ */
+int brw_wm_pass_fp( struct brw_wm_compile *c )
+{
+   struct brw_fragment_shader *fs = c->fp;
+   struct tgsi_parse_context parse;
+   struct tgsi_full_instruction *inst;
+   struct tgsi_full_declaration *decl;
+   const float *imm;
+   GLuint size;
+   GLuint i;
+
+   if (BRW_DEBUG & DEBUG_WM) {
+      debug_printf("pre-fp:\n");
+      tgsi_dump(fs->tokens, 0); 
+   }
+
+   c->fp_pixel_xy = src_undef();
+   c->fp_delta_xy = src_undef();
+   c->fp_pixel_w = src_undef();
+   c->nr_fp_insns = 0;
+   c->nr_immediates = 0;
+
+
+   /* Loop over all instructions doing assorted simplifications and
+    * transformations.
+    */
+   tgsi_parse_init( &parse, fs->tokens );
+   while( !tgsi_parse_end_of_tokens( &parse ) ) {
+      tgsi_parse_token( &parse );
+
+      switch( parse.FullToken.Token.Type ) {
+      case TGSI_TOKEN_TYPE_DECLARATION:
+        /* Turn intput declarations into special WM_* instructions.
+         *
+         * XXX: For non-branching shaders, consider deferring variable
+         * initialization as late as possible to minimize register
+         * usage.  This is how the original BRW driver worked.
+         *
+         * In a branching shader, must preamble instructions at decl
+         * time, as instruction order in the shader does not
+         * correspond to the order instructions are executed in the
+         * wild.
+         *
+         * This is where special instructions such as WM_CINTERP,
+         * WM_LINTERP, WM_PINTERP and WM_WPOSXY are emitted to
+         * compute shader inputs from the payload registers and pixel
+         * position.
+         */
+         decl = &parse.FullToken.FullDeclaration;
+         if( decl->Declaration.File == TGSI_FILE_INPUT ) {
+            unsigned first, last, mask;
+            unsigned attrib;
+
+            first = decl->Range.First;
+            last = decl->Range.Last;
+            mask = decl->Declaration.UsageMask;
+
+            for (attrib = first; attrib <= last; attrib++) {
+              emit_interp(c, 
+                          attrib, 
+                          decl->Semantic.Name,
+                          decl->Declaration.Interpolate );
+            }
+         }
+        
+         break;
+
+      case TGSI_TOKEN_TYPE_IMMEDIATE:
+        /* Unlike VS programs we can probably manage fine encoding
+         * immediate values directly into the emitted EU
+         * instructions, as we probably only need to reference one
+         * float value per instruction.  Just save the data for now
+         * and use directly later.
+         */
+        i = c->nr_immediates++;
+        imm = &parse.FullToken.FullImmediate.u[i].Float;
+        size = parse.FullToken.FullImmediate.Immediate.NrTokens - 1;
+
+        if (c->nr_immediates >= BRW_WM_MAX_CONST)
+           return PIPE_ERROR_OUT_OF_MEMORY;
+
+        for (i = 0; i < size; i++)
+           c->immediate[c->nr_immediates].v[i] = imm[i];
+
+        for (; i < 4; i++)
+           c->immediate[c->nr_immediates].v[i] = 0.0;
+
+        c->immediate[c->nr_immediates].nr = size;
+        c->nr_immediates++;
+        break;
+
+      case TGSI_TOKEN_TYPE_INSTRUCTION:
+         inst = &parse.FullToken.FullInstruction;
+        emit_insn(c, inst);
+        break;
+      }
+   }
+
+   if (BRW_DEBUG & DEBUG_WM) {
+      brw_wm_print_fp_program( c, "pass_fp" );
+      debug_printf("\n");
+   }
+
+   return c->error;
+}
+
diff --git a/src/gallium/drivers/i965/brw_wm_glsl.c b/src/gallium/drivers/i965/brw_wm_glsl.c
new file mode 100644 (file)
index 0000000..3b3afc3
--- /dev/null
@@ -0,0 +1,2032 @@
+#include "util/u_math.h"
+
+
+#include "brw_context.h"
+#include "brw_eu.h"
+#include "brw_wm.h"
+
+
+static struct brw_reg get_dst_reg(struct brw_wm_compile *c,
+                                  const struct brw_fp_instruction *inst,
+                                  GLuint component);
+
+
+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 */
+      debug_printf("%s: ran out of registers for fragment program", __FUNCTION__);
+      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.
+ */
+static void set_reg(struct brw_wm_compile *c, int file, int index, 
+       int component, struct brw_reg reg)
+{
+    c->wm_regs[file][index][component].reg = reg;
+    c->wm_regs[file][index][component].inited = GL_TRUE;
+}
+
+static struct brw_reg alloc_tmp(struct brw_wm_compile *c)
+{
+    struct brw_reg reg;
+
+    /* 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;
+
+}
+
+/**
+ * Save current temp register info.
+ * There must be a matching call to release_tmps().
+ */
+static int mark_tmps(struct brw_wm_compile *c)
+{
+    return c->tmp_index;
+}
+
+static struct brw_reg lookup_tmp( struct brw_wm_compile *c, int index )
+{
+    return brw_vec8_grf( c->tmp_regs[ index ], 0 );
+}
+
+static void release_tmps(struct brw_wm_compile *c, int mark)
+{
+    c->tmp_index = mark;
+}
+
+/**
+ * Convert Mesa src register to brw register.
+ *
+ * Since we're running in SOA mode each Mesa register corresponds to four
+ * hardware registers.  We allocate the hardware registers as needed here.
+ *
+ * \param file  register file, one of PROGRAM_x
+ * \param index  register number
+ * \param component  src component (X=0, Y=1, Z=2, W=3)
+ * \param nr  not used?!?
+ * \param neg  negate value?
+ * \param abs  take absolute value?
+ */
+static struct brw_reg 
+get_reg(struct brw_wm_compile *c, int file, int index, int component,
+        int nr, GLuint neg, GLuint abs)
+{
+    struct brw_reg reg;
+    switch (file) {
+       case TGSI_FILE_NULL:
+           return brw_null_reg();      
+
+       case TGSI_FILE_CONSTANT:
+       case TGSI_FILE_TEMPORARY:
+       case TGSI_FILE_INPUT:
+       case TGSI_FILE_OUTPUT:
+       case BRW_FILE_PAYLOAD:
+           break;
+
+       default:
+          debug_printf("%s: Unexpected file type\n", __FUNCTION__);
+          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;
+    }
+    else {
+       /* no, allocate new register */
+       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! */
+       }
+
+       reg = brw_vec8_grf(grf, 0);
+       /*printf("Alloc new grf %d for %d.%d\n", reg.nr, index, component);*/
+
+       set_reg(c, file, index, component, reg);
+    }
+
+    if (neg & (1 << component)) {
+       reg = negate(reg);
+    }
+    if (abs)
+       reg = brw_abs(reg);
+    return reg;
+}
+
+
+
+
+/**
+ * Find first/last instruction that references each temporary register.
+ */
+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
+   {
+      GLuint Start, End;  /**< Start, end instructions of loop */
+   };
+   struct loop_info loopStack[MAX_LOOP_NESTING];
+   GLuint loopStackDepth = 0;
+   GLuint i;
+
+   for (i = 0; i < MAX_PROGRAM_TEMPS; i++){
+      intBegin[i] = intEnd[i] = -1;
+   }
+
+   /* Scan instructions looking for temporary registers */
+   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;
+         loopStackDepth++;
+      }
+      else if (inst->Opcode == OPCODE_ENDLOOP) {
+         loopStackDepth--;
+      }
+      else if (inst->Opcode == OPCODE_CAL) {
+         return GL_FALSE;
+      }
+      else {
+         const GLuint numSrc = 3;
+         GLuint j;
+         for (j = 0; j < numSrc; j++) {
+            if (inst->SrcReg[j].File == PROGRAM_TEMPORARY) {
+               const GLuint index = inst->SrcReg[j].Index;
+               if (inst->SrcReg[j].RelAddr)
+                  return GL_FALSE;
+               update_interval(intBegin, intEnd, index, i);
+               if (loopStackDepth > 0) {
+                  /* extend temp register's interval to end of loop */
+                  GLuint loopEnd = loopStack[loopStackDepth - 1].End;
+                  update_interval(intBegin, intEnd, index, loopEnd);
+               }
+            }
+         }
+         if (inst->DstReg.File == PROGRAM_TEMPORARY) {
+            const GLuint index = inst->DstReg.Index;
+            if (inst->DstReg.RelAddr)
+               return GL_FALSE;
+            update_interval(intBegin, intEnd, index, i);
+            if (loopStackDepth > 0) {
+               /* extend temp register's interval to end of loop */
+               GLuint loopEnd = loopStack[loopStackDepth - 1].End;
+               update_interval(intBegin, intEnd, index, loopEnd);
+            }
+         }
+      }
+   }
+
+   return GL_TRUE;
+}
+
+
+/**
+ * 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[BRW_WM_MAX_TEMPS];
+   GLint intEnd[BRW_WM_MAX_TEMPS];
+   int index;
+
+   /*printf("Reclaim temps:\n");*/
+
+   _mesa_find_temp_intervals(c->fp_instructions, c->nr_fp_insns,
+                             intBegin, intEnd);
+
+   for (index = 0; index < BRW_WM_MAX_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[TGSI_FILE_TEMPORARY][index][component].inited) {
+               int r = c->wm_regs[TGSI_FILE_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[TGSI_FILE_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)
+ * and shader inputs.
+ */
+static void prealloc_reg(struct brw_wm_compile *c)
+{
+    int i, j;
+    struct brw_reg reg;
+    int urb_read_length = 0;
+    GLuint inputs = FRAG_BIT_WPOS | c->fp_interp_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) 
+            reg = brw_vec8_grf(i * 2, 0);
+        else
+            reg = brw_vec8_grf(0, 0);
+       set_reg(c, TGSI_FILE_PAYLOAD, PAYLOAD_DEPTH, i, reg);
+    }
+    reg_index += 2 * c->key.nr_depth_regs;
+
+    /* constants */
+    {
+        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? */
+        /* 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
+            * it with a dataport read message.
+            */
+
+           /* number of float constants in CURBE */
+           c->prog_data.nr_params = 0;
+        }
+        else {
+           const struct gl_program_parameter_list *plist = 
+              c->fp->program.Base.Parameters;
+           int index = 0;
+
+           /* number of float constants in CURBE */
+           c->prog_data.nr_params = 4 * nr_params;
+
+           /* loop over program constants (float[4]) */
+           for (i = 0; i < nr_params; i++) {
+              /* loop over XYZW channels */
+              for (j = 0; j < 4; j++, index++) {
+                 reg = brw_vec1_grf(reg_index + index / 8, index % 8);
+                 /* Save pointer to parameter/constant value.
+                  * Constants will be copied in prepare_constant_buffer()
+                  */
+                 c->prog_data.param[index] = &plist->ParameterValues[i][j];
+                 set_reg(c, TGSI_FILE_STATE_VAR, i, j, reg);
+              }
+           }
+           /* number of constant regs used (each reg is float[8]) */
+           c->nr_creg = 2 * ((4 * nr_params + 15) / 16);
+           reg_index += c->nr_creg;
+        }
+    }
+
+    /* fragment shader inputs */
+    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, TGSI_FILE_PAYLOAD, fp_input, j, reg);
+       }
+       if (c->key.nr_vp_outputs > i) {
+         reg_index += 2;
+       }
+    }
+
+    c->prog_data.first_curbe_grf = c->key.nr_depth_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, 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);
+
+    for (i = 0; i < c->nr_fp_insns; i++) {
+       const struct brw_fp_instruction *inst = &c->fp_instructions[i];
+       struct brw_reg dst[4];
+
+       switch (inst->Opcode) {
+       case OPCODE_TEX:
+       case OPCODE_TXB:
+           /* Allocate the channels of texture results contiguously,
+            * since they are written out that way by the sampler unit.
+            */
+           for (j = 0; j < 4; j++) {
+               dst[j] = get_dst_reg(c, inst, j);
+               if (j != 0)
+                   assert(dst[j].nr == dst[j - 1].nr + 1);
+           }
+           break;
+       default:
+           break;
+       }
+    }
+
+    /* An instruction may reference up to three constants.
+     * They'll be found in these registers.
+     * XXX alloc these on demand!
+     */
+    if (c->fp->use_const_buffer) {
+       for (i = 0; i < 3; i++) {
+          c->current_const[i].index = -1;
+          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", reg_index);
+#endif
+}
+
+
+/**
+ * Check if any of the instruction's src registers are constants, uniforms,
+ * or statevars.  If so, fetch any constants that we don't already have in
+ * the three GRF slots.
+ */
+static void fetch_constants(struct brw_wm_compile *c,
+                            const struct brw_fp_instruction *inst)
+{
+   struct brw_compile *p = &c->func;
+   GLuint i;
+
+   /* loop over instruction src regs */
+   for (i = 0; i < 3; i++) {
+      const struct prog_src_register *src = &inst->SrcReg[i];
+      if (src->File == TGSI_FILE_IMMEDIATE ||
+          src->File == TGSI_FILE_CONSTANT) {
+        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);
+#endif
+
+        /* need to fetch the constant now */
+        brw_dp_READ_4(p,
+                      c->current_const[i].reg,  /* writeback dest */
+                      src->RelAddr,             /* relative indexing? */
+                      16 * src->Index,          /* byte offset */
+                      SURF_INDEX_FRAG_CONST_BUFFER/* binding table index */
+                      );
+      }
+   }
+}
+
+
+/**
+ * Convert Mesa dst register to brw register.
+ */
+static struct brw_reg get_dst_reg(struct brw_wm_compile *c, 
+                                  const struct brw_fp_instruction *inst,
+                                  GLuint component)
+{
+    const int nr = 1;
+    return get_reg(c, inst->DstReg.File, inst->DstReg.Index, component, nr,
+           0, 0);
+}
+
+
+static struct brw_reg
+get_src_reg_const(struct brw_wm_compile *c,
+                  const struct brw_fp_instruction *inst,
+                  GLuint srcRegIndex, GLuint component)
+{
+   /* We should have already fetched the constant from the constant
+    * buffer in fetch_constants().  Now we just have to return a
+    * register description that extracts the needed component and
+    * smears it across all eight vector components.
+    */
+   const struct prog_src_register *src = &inst->SrcReg[srcRegIndex];
+   struct brw_reg const_reg;
+
+   assert(component < 4);
+   assert(srcRegIndex < 3);
+   assert(c->current_const[srcRegIndex].index != -1);
+   const_reg = c->current_const[srcRegIndex].reg;
+
+   /* extract desired float from the const_reg, and smear */
+   const_reg = stride(const_reg, 0, 1, 0);
+   const_reg.subnr = component * 4;
+
+   if (src->Negate)
+      const_reg = negate(const_reg);
+   if (src->Abs)
+      const_reg = brw_abs(const_reg);
+
+#if 0
+   printf("  form const[%d].%d for arg %d, reg %d\n",
+          c->current_const[srcRegIndex].index,
+          component,
+          srcRegIndex,
+          const_reg.nr);
+#endif
+
+   return const_reg;
+}
+
+
+/**
+ * Convert Mesa src register to brw register.
+ */
+static struct brw_reg get_src_reg(struct brw_wm_compile *c, 
+                                  const struct brw_fp_instruction *inst,
+                                  GLuint srcRegIndex, GLuint channel)
+{
+    const struct prog_src_register *src = &inst->SrcReg[srcRegIndex];
+    const GLuint nr = 1;
+    const GLuint component = BRW_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 == TGSI_FILE_STATE_VAR ||
+         src->File == TGSI_FILE_CONSTANT ||
+         src->File == TGSI_FILE_UNIFORM)) {
+       return get_src_reg_const(c, inst, srcRegIndex, component);
+    }
+    else {
+       /* other type of source register */
+       return get_reg(c, src->File, src->Index, component, nr, 
+                      src->Negate, src->Abs);
+    }
+}
+
+
+/**
+ * Same as \sa get_src_reg() but if the register is a immediate, emit
+ * a brw_reg encoding the immediate.
+ * Note that a brw instruction only allows one src operand to be a immediate.
+ * For instructions with more than one operand, only the second can be a
+ * immediate.  This means that we treat some immediates as constants
+ * (which why TGSI_FILE_IMMEDIATE is checked in fetch_constants()).
+ * 
+ */
+static struct brw_reg get_src_reg_imm(struct brw_wm_compile *c, 
+                                      const struct brw_fp_instruction *inst,
+                                      GLuint srcRegIndex, GLuint channel)
+{
+    const struct prog_src_register *src = &inst->SrcReg[srcRegIndex];
+    if (src->File == TGSI_FILE_IMMEDIATE) {
+       /* an immediate */
+       const int component = BRW_GET_SWZ(src->Swizzle, channel);
+       const GLfloat *param =
+          c->fp->program.Base.Parameters->ParameterValues[src->Index];
+       GLfloat value = param[component];
+       if (src->Negate)
+          value = -value;
+       if (src->Abs)
+          value = FABSF(value);
+#if 0
+       printf("  form immed value %f for chan %d\n", value, channel);
+#endif
+       return brw_imm_f(value);
+    }
+    else {
+       return get_src_reg(c, inst, srcRegIndex, channel);
+    }
+}
+
+
+/**
+ * Subroutines are minimal support for resusable instruction sequences.
+ * They are implemented as simply as possible to minimise overhead: there
+ * is no explicit support for communication between the caller and callee
+ * other than saving the return address in a temporary register, nor is
+ * there any automatic local storage.  This implies that great care is
+ * required before attempting reentrancy or any kind of nested
+ * subroutine invocations.
+ */
+static void invoke_subroutine( struct brw_wm_compile *c,
+                              enum _subroutine subroutine,
+                              void (*emit)( struct brw_wm_compile * ) )
+{
+    struct brw_compile *p = &c->func;
+
+    assert( subroutine < BRW_WM_MAX_SUBROUTINE );
+    
+    if( c->subroutines[ subroutine ] ) {
+       /* subroutine previously emitted: reuse existing instructions */
+
+       int mark = mark_tmps( c );
+       struct brw_reg return_address = retype( alloc_tmp( c ),
+                                               BRW_REGISTER_TYPE_UD );
+       int here = p->nr_insn;
+       
+       brw_push_insn_state(p);
+       brw_set_mask_control(p, BRW_MASK_DISABLE);
+       brw_ADD( p, return_address, brw_ip_reg(), brw_imm_ud( 2 << 4 ) );
+
+       brw_ADD( p, brw_ip_reg(), brw_ip_reg(),
+                brw_imm_d( ( c->subroutines[ subroutine ] -
+                             here - 1 ) << 4 ) );
+       brw_pop_insn_state(p);
+
+       release_tmps( c, mark );
+    } else {
+       /* previously unused subroutine: emit, and mark for later reuse */
+       
+       int mark = mark_tmps( c );
+       struct brw_reg return_address = retype( alloc_tmp( c ),
+                                               BRW_REGISTER_TYPE_UD );
+       struct brw_instruction *calc;
+       int base = p->nr_insn;
+       
+       brw_push_insn_state(p);
+       brw_set_mask_control(p, BRW_MASK_DISABLE);
+       calc = brw_ADD( p, return_address, brw_ip_reg(), brw_imm_ud( 0 ) );
+       brw_pop_insn_state(p);
+       
+       c->subroutines[ subroutine ] = p->nr_insn;
+
+       emit( c );
+       
+       brw_push_insn_state(p);
+       brw_set_mask_control(p, BRW_MASK_DISABLE);
+       brw_MOV( p, brw_ip_reg(), return_address );
+       brw_pop_insn_state(p);
+
+       brw_set_src1( calc, brw_imm_ud( ( p->nr_insn - base ) << 4 ) );
+       
+       release_tmps( c, mark );
+    }
+}
+
+static void emit_trunc( struct brw_wm_compile *c,
+                        const struct brw_fp_instruction *inst)
+{
+    int i;
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+    brw_set_saturate(p, inst->SaturateMode != SATURATE_OFF);
+    for (i = 0; i < 4; i++) {
+       if (mask & (1<<i)) {
+           struct brw_reg src, dst;
+           dst = get_dst_reg(c, inst, i);
+           src = get_src_reg(c, inst, 0, i);
+           brw_RNDZ(p, dst, src);
+       }
+    }
+    brw_set_saturate(p, 0);
+}
+
+static void emit_mov( struct brw_wm_compile *c,
+                      const struct brw_fp_instruction *inst)
+{
+    int i;
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+    brw_set_saturate(p, inst->SaturateMode != SATURATE_OFF);
+    for (i = 0; i < 4; i++) {
+       if (mask & (1<<i)) {
+           struct brw_reg src, dst;
+           dst = get_dst_reg(c, inst, i);
+            /* XXX some moves from immediate value don't work reliably!!! */
+            /*src = get_src_reg_imm(c, inst, 0, i);*/
+            src = get_src_reg(c, inst, 0, i);
+           brw_MOV(p, dst, src);
+       }
+    }
+    brw_set_saturate(p, 0);
+}
+
+static void emit_pixel_xy(struct brw_wm_compile *c,
+                          const struct brw_fp_instruction *inst)
+{
+    struct brw_reg r1 = brw_vec1_grf(1, 0);
+    struct brw_reg r1_uw = retype(r1, BRW_REGISTER_TYPE_UW);
+
+    struct brw_reg dst0, dst1;
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+
+    dst0 = get_dst_reg(c, inst, 0);
+    dst1 = get_dst_reg(c, inst, 1);
+    /* Calculate pixel centers by adding 1 or 0 to each of the
+     * micro-tile coordinates passed in r1.
+     */
+    if (mask & WRITEMASK_X) {
+       brw_ADD(p,
+               vec8(retype(dst0, BRW_REGISTER_TYPE_UW)),
+               stride(suboffset(r1_uw, 4), 2, 4, 0),
+               brw_imm_v(0x10101010));
+    }
+
+    if (mask & WRITEMASK_Y) {
+       brw_ADD(p,
+               vec8(retype(dst1, BRW_REGISTER_TYPE_UW)),
+               stride(suboffset(r1_uw, 5), 2, 4, 0),
+               brw_imm_v(0x11001100));
+    }
+}
+
+static void emit_delta_xy(struct brw_wm_compile *c,
+                          const struct brw_fp_instruction *inst)
+{
+    struct brw_reg r1 = brw_vec1_grf(1, 0);
+    struct brw_reg dst0, dst1, src0, src1;
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+
+    dst0 = get_dst_reg(c, inst, 0);
+    dst1 = get_dst_reg(c, inst, 1);
+    src0 = get_src_reg(c, inst, 0, 0);
+    src1 = get_src_reg(c, inst, 0, 1);
+    /* Calc delta X,Y by subtracting origin in r1 from the pixel
+     * centers.
+     */
+    if (mask & WRITEMASK_X) {
+       brw_ADD(p,
+               dst0,
+               retype(src0, BRW_REGISTER_TYPE_UW),
+               negate(r1));
+    }
+
+    if (mask & WRITEMASK_Y) {
+       brw_ADD(p,
+               dst1,
+               retype(src1, BRW_REGISTER_TYPE_UW),
+               negate(suboffset(r1,1)));
+
+    }
+}
+
+static void fire_fb_write( struct brw_wm_compile *c,
+                           GLuint base_reg,
+                           GLuint nr,
+                           GLuint target,
+                           GLuint eot)
+{
+    struct brw_compile *p = &c->func;
+    /* Pass through control information:
+     */
+    /*  mov (8) m1.0<1>:ud   r1.0<8;8,1>:ud   { Align1 NoMask } */
+    {
+       brw_push_insn_state(p);
+       brw_set_mask_control(p, BRW_MASK_DISABLE); /* ? */
+       brw_MOV(p,
+               brw_message_reg(base_reg + 1),
+               brw_vec8_grf(1, 0));
+       brw_pop_insn_state(p);
+    }
+    /* Send framebuffer write message: */
+    brw_fb_WRITE(p,
+           retype(vec8(brw_null_reg()), BRW_REGISTER_TYPE_UW),
+           base_reg,
+           retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UW),
+           target,              
+           nr,
+           0,
+           eot);
+}
+
+static void emit_fb_write(struct brw_wm_compile *c,
+                          const struct brw_fp_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    int nr = 2;
+    int channel;
+    GLuint target, eot;
+    struct brw_reg src0;
+
+    /* Reserve a space for AA - may not be needed:
+     */
+    if (c->key.aa_dest_stencil_reg)
+       nr += 1;
+
+    brw_push_insn_state(p);
+    for (channel = 0; channel < 4; channel++) {
+        src0 = get_src_reg(c,  inst, 0, channel);
+        /*  mov (8) m2.0<1>:ud   r28.0<8;8,1>:ud  { Align1 } */
+        /*  mov (8) m6.0<1>:ud   r29.0<8;8,1>:ud  { Align1 SecHalf } */
+        brw_MOV(p, brw_message_reg(nr + channel), src0);
+    }
+    /* skip over the regs populated above: */
+    nr += 8;
+    brw_pop_insn_state(p);
+
+    if (c->key.source_depth_to_render_target) {
+       if (c->key.computes_depth) {
+          src0 = get_src_reg(c, inst, 2, 2);
+          brw_MOV(p, brw_message_reg(nr), src0);
+       }
+       else {
+          src0 = get_src_reg(c, inst, 1, 1);
+          brw_MOV(p, brw_message_reg(nr), src0);
+       }
+
+       nr += 2;
+    }
+
+    if (c->key.dest_depth_reg) {
+        const GLuint comp = c->key.dest_depth_reg / 2;
+        const GLuint off = c->key.dest_depth_reg % 2;
+
+        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_0, 1));
+            /* 2nd half? */
+            brw_MOV(p, brw_message_reg(nr+1), arg1_1);
+            brw_pop_insn_state(p);
+        }
+        else
+        {
+            struct brw_reg src =  get_src_reg(c, inst, 1, 1);
+            brw_MOV(p, brw_message_reg(nr), src);
+        }
+        nr += 2;
+   }
+
+    target = inst->Aux >> 1;
+    eot = inst->Aux & 1;
+    fire_fb_write(c, 0, nr, target, eot);
+}
+
+static void emit_pixel_w( struct brw_wm_compile *c,
+                          const struct brw_fp_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+    if (mask & WRITEMASK_W) {
+       struct brw_reg dst, src0, delta0, delta1;
+       struct brw_reg interp3;
+
+       dst = get_dst_reg(c, inst, 3);
+       src0 = get_src_reg(c, inst, 0, 0);
+       delta0 = get_src_reg(c, inst, 1, 0);
+       delta1 = get_src_reg(c, inst, 1, 1);
+
+       interp3 = brw_vec1_grf(src0.nr+1, 4);
+       /* Calc 1/w - just linterp wpos[3] optimized by putting the
+        * result straight into a message reg.
+        */
+       brw_LINE(p, brw_null_reg(), interp3, delta0);
+       brw_MAC(p, brw_message_reg(2), suboffset(interp3, 1), delta1);
+
+       /* Calc w */
+       brw_math_16( p, dst,
+               BRW_MATH_FUNCTION_INV,
+               BRW_MATH_SATURATE_NONE,
+               2, brw_null_reg(),
+               BRW_MATH_PRECISION_FULL);
+    }
+}
+
+static void emit_linterp(struct brw_wm_compile *c,
+                         const struct brw_fp_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+    struct brw_reg interp[4];
+    struct brw_reg dst, delta0, delta1;
+    struct brw_reg src0;
+    GLuint nr, i;
+
+    src0 = get_src_reg(c, inst, 0, 0);
+    delta0 = get_src_reg(c, inst, 1, 0);
+    delta1 = get_src_reg(c, inst, 1, 1);
+    nr = src0.nr;
+
+    interp[0] = brw_vec1_grf(nr, 0);
+    interp[1] = brw_vec1_grf(nr, 4);
+    interp[2] = brw_vec1_grf(nr+1, 0);
+    interp[3] = brw_vec1_grf(nr+1, 4);
+
+    for(i = 0; i < 4; i++ ) {
+       if (mask & (1<<i)) {
+           dst = get_dst_reg(c, inst, i);
+           brw_LINE(p, brw_null_reg(), interp[i], delta0);
+           brw_MAC(p, dst, suboffset(interp[i],1), delta1);
+       }
+    }
+}
+
+static void emit_cinterp(struct brw_wm_compile *c,
+                         const struct brw_fp_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+
+    struct brw_reg interp[4];
+    struct brw_reg dst, src0;
+    GLuint nr, i;
+
+    src0 = get_src_reg(c, inst, 0, 0);
+    nr = src0.nr;
+
+    interp[0] = brw_vec1_grf(nr, 0);
+    interp[1] = brw_vec1_grf(nr, 4);
+    interp[2] = brw_vec1_grf(nr+1, 0);
+    interp[3] = brw_vec1_grf(nr+1, 4);
+
+    for(i = 0; i < 4; i++ ) {
+       if (mask & (1<<i)) {
+           dst = get_dst_reg(c, inst, i);
+           brw_MOV(p, dst, suboffset(interp[i],3));
+       }
+    }
+}
+
+static void emit_pinterp(struct brw_wm_compile *c,
+                         const struct brw_fp_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+
+    struct brw_reg interp[4];
+    struct brw_reg dst, delta0, delta1;
+    struct brw_reg src0, w;
+    GLuint nr, i;
+
+    src0 = get_src_reg(c, inst, 0, 0);
+    delta0 = get_src_reg(c, inst, 1, 0);
+    delta1 = get_src_reg(c, inst, 1, 1);
+    w = get_src_reg(c, inst, 2, 3);
+    nr = src0.nr;
+
+    interp[0] = brw_vec1_grf(nr, 0);
+    interp[1] = brw_vec1_grf(nr, 4);
+    interp[2] = brw_vec1_grf(nr+1, 0);
+    interp[3] = brw_vec1_grf(nr+1, 4);
+
+    for(i = 0; i < 4; i++ ) {
+       if (mask & (1<<i)) {
+           dst = get_dst_reg(c, inst, i);
+           brw_LINE(p, brw_null_reg(), interp[i], delta0);
+           brw_MAC(p, dst, suboffset(interp[i],1), 
+                   delta1);
+           brw_MUL(p, dst, dst, w);
+       }
+    }
+}
+
+/* Sets the destination channels to 1.0 or 0.0 according to glFrontFacing. */
+static void emit_frontfacing(struct brw_wm_compile *c,
+                            const struct brw_fp_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    struct brw_reg r1_6ud = retype(brw_vec1_grf(1, 6), BRW_REGISTER_TYPE_UD);
+    struct brw_reg dst;
+    GLuint mask = inst->DstReg.WriteMask;
+    int i;
+
+    for (i = 0; i < 4; i++) {
+       if (mask & (1<<i)) {
+           dst = get_dst_reg(c, inst, i);
+           brw_MOV(p, dst, brw_imm_f(0.0));
+       }
+    }
+
+    /* bit 31 is "primitive is back face", so checking < (1 << 31) gives
+     * us front face
+     */
+    brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_L, r1_6ud, brw_imm_ud(1 << 31));
+    for (i = 0; i < 4; i++) {
+       if (mask & (1<<i)) {
+           dst = get_dst_reg(c, inst, i);
+           brw_MOV(p, dst, brw_imm_f(1.0));
+       }
+    }
+    brw_set_predicate_control_flag_value(p, 0xff);
+}
+
+static void emit_xpd(struct brw_wm_compile *c,
+                     const struct brw_fp_instruction *inst)
+{
+    int i;
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+    for (i = 0; i < 4; i++) {
+       GLuint i2 = (i+2)%3;
+       GLuint i1 = (i+1)%3;
+       if (mask & (1<<i)) {
+           struct brw_reg src0, src1, dst;
+           dst = get_dst_reg(c, inst, i);
+           src0 = negate(get_src_reg(c, inst, 0, i2));
+           src1 = get_src_reg_imm(c, inst, 1, i1);
+           brw_MUL(p, brw_null_reg(), src0, src1);
+           src0 = get_src_reg(c, inst, 0, i1);
+           src1 = get_src_reg_imm(c, inst, 1, i2);
+           brw_set_saturate(p, inst->SaturateMode != SATURATE_OFF);
+           brw_MAC(p, dst, src0, src1);
+           brw_set_saturate(p, 0);
+       }
+    }
+    brw_set_saturate(p, 0);
+}
+
+static void emit_dp3(struct brw_wm_compile *c,
+                     const struct brw_fp_instruction *inst)
+{
+    struct brw_reg src0[3], src1[3], dst;
+    int i;
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+    int dst_chan = ffs(mask & WRITEMASK_XYZW) - 1;
+
+    if (!(mask & WRITEMASK_XYZW))
+       return;
+
+    assert(is_power_of_two(mask & WRITEMASK_XYZW));
+
+    for (i = 0; i < 3; i++) {
+       src0[i] = get_src_reg(c, inst, 0, i);
+       src1[i] = get_src_reg_imm(c, inst, 1, i);
+    }
+
+    dst = get_dst_reg(c, inst, dst_chan);
+    brw_MUL(p, brw_null_reg(), src0[0], src1[0]);
+    brw_MAC(p, brw_null_reg(), src0[1], src1[1]);
+    brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
+    brw_MAC(p, dst, src0[2], src1[2]);
+    brw_set_saturate(p, 0);
+}
+
+static void emit_dp4(struct brw_wm_compile *c,
+                     const struct brw_fp_instruction *inst)
+{
+    struct brw_reg src0[4], src1[4], dst;
+    int i;
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+    int dst_chan = ffs(mask & WRITEMASK_XYZW) - 1;
+
+    if (!(mask & WRITEMASK_XYZW))
+       return;
+
+    assert(is_power_of_two(mask & WRITEMASK_XYZW));
+
+    for (i = 0; i < 4; i++) {
+       src0[i] = get_src_reg(c, inst, 0, i);
+       src1[i] = get_src_reg_imm(c, inst, 1, i);
+    }
+    dst = get_dst_reg(c, inst, dst_chan);
+    brw_MUL(p, brw_null_reg(), src0[0], src1[0]);
+    brw_MAC(p, brw_null_reg(), src0[1], src1[1]);
+    brw_MAC(p, brw_null_reg(), src0[2], src1[2]);
+    brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
+    brw_MAC(p, dst, src0[3], src1[3]);
+    brw_set_saturate(p, 0);
+}
+
+static void emit_dph(struct brw_wm_compile *c,
+                     const struct brw_fp_instruction *inst)
+{
+    struct brw_reg src0[4], src1[4], dst;
+    int i;
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+    int dst_chan = ffs(mask & WRITEMASK_XYZW) - 1;
+
+    if (!(mask & WRITEMASK_XYZW))
+       return;
+
+    assert(is_power_of_two(mask & WRITEMASK_XYZW));
+
+    for (i = 0; i < 4; i++) {
+       src0[i] = get_src_reg(c, inst, 0, i);
+       src1[i] = get_src_reg_imm(c, inst, 1, i);
+    }
+    dst = get_dst_reg(c, inst, dst_chan);
+    brw_MUL(p, brw_null_reg(), src0[0], src1[0]);
+    brw_MAC(p, brw_null_reg(), src0[1], src1[1]);
+    brw_MAC(p, dst, src0[2], src1[2]);
+    brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
+    brw_ADD(p, dst, dst, src1[3]);
+    brw_set_saturate(p, 0);
+}
+
+/**
+ * Emit a scalar instruction, like RCP, RSQ, LOG, EXP.
+ * Note that the result of the function is smeared across the dest
+ * register's X, Y, Z and W channels (subject to writemasking of course).
+ */
+static void emit_math1(struct brw_wm_compile *c,
+                       const struct brw_fp_instruction *inst, GLuint func)
+{
+    struct brw_compile *p = &c->func;
+    struct brw_reg src0, dst;
+    GLuint mask = inst->DstReg.WriteMask;
+    int dst_chan = ffs(mask & WRITEMASK_XYZW) - 1;
+
+    if (!(mask & WRITEMASK_XYZW))
+       return;
+
+    assert(is_power_of_two(mask & WRITEMASK_XYZW));
+
+    /* Get first component of source register */
+    dst = get_dst_reg(c, inst, dst_chan);
+    src0 = get_src_reg(c, inst, 0, 0);
+
+    brw_MOV(p, brw_message_reg(2), src0);
+    brw_math(p,
+             dst,
+             func,
+             (inst->SaturateMode != SATURATE_OFF) ? BRW_MATH_SATURATE_SATURATE : BRW_MATH_SATURATE_NONE,
+             2,
+             brw_null_reg(),
+             BRW_MATH_DATA_VECTOR,
+             BRW_MATH_PRECISION_FULL);
+}
+
+static void emit_rcp(struct brw_wm_compile *c,
+                     const struct brw_fp_instruction *inst)
+{
+    emit_math1(c, inst, BRW_MATH_FUNCTION_INV);
+}
+
+static void emit_rsq(struct brw_wm_compile *c,
+                     const struct brw_fp_instruction *inst)
+{
+    emit_math1(c, inst, BRW_MATH_FUNCTION_RSQ);
+}
+
+static void emit_sin(struct brw_wm_compile *c,
+                     const struct brw_fp_instruction *inst)
+{
+    emit_math1(c, inst, BRW_MATH_FUNCTION_SIN);
+}
+
+static void emit_cos(struct brw_wm_compile *c,
+                     const struct brw_fp_instruction *inst)
+{
+    emit_math1(c, inst, BRW_MATH_FUNCTION_COS);
+}
+
+static void emit_ex2(struct brw_wm_compile *c,
+                     const struct brw_fp_instruction *inst)
+{
+    emit_math1(c, inst, BRW_MATH_FUNCTION_EXP);
+}
+
+static void emit_lg2(struct brw_wm_compile *c,
+                     const struct brw_fp_instruction *inst)
+{
+    emit_math1(c, inst, BRW_MATH_FUNCTION_LOG);
+}
+
+static void emit_add(struct brw_wm_compile *c,
+                     const struct brw_fp_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    struct brw_reg src0, src1, dst;
+    GLuint mask = inst->DstReg.WriteMask;
+    int i;
+    brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
+    for (i = 0 ; i < 4; i++) {
+       if (mask & (1<<i)) {
+           dst = get_dst_reg(c, inst, i);
+           src0 = get_src_reg(c, inst, 0, i);
+           src1 = get_src_reg_imm(c, inst, 1, i);
+           brw_ADD(p, dst, src0, src1);
+       }
+    }
+    brw_set_saturate(p, 0);
+}
+
+static void emit_arl(struct brw_wm_compile *c,
+                     const struct brw_fp_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    struct brw_reg src0, addr_reg;
+    brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
+    addr_reg = brw_uw8_reg(BRW_ARCHITECTURE_REGISTER_FILE, 
+                           BRW_ARF_ADDRESS, 0);
+    src0 = get_src_reg(c, inst, 0, 0); /* channel 0 */
+    brw_MOV(p, addr_reg, src0);
+    brw_set_saturate(p, 0);
+}
+
+
+static void emit_mul(struct brw_wm_compile *c,
+                     const struct brw_fp_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    struct brw_reg src0, src1, dst;
+    GLuint mask = inst->DstReg.WriteMask;
+    int i;
+    brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
+    for (i = 0 ; i < 4; i++) {
+       if (mask & (1<<i)) {
+           dst = get_dst_reg(c, inst, i);
+           src0 = get_src_reg(c, inst, 0, i);
+           src1 = get_src_reg_imm(c, inst, 1, i);
+           brw_MUL(p, dst, src0, src1);
+       }
+    }
+    brw_set_saturate(p, 0);
+}
+
+static void emit_frc(struct brw_wm_compile *c,
+                     const struct brw_fp_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    struct brw_reg src0, dst;
+    GLuint mask = inst->DstReg.WriteMask;
+    int i;
+    brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
+    for (i = 0 ; i < 4; i++) {
+       if (mask & (1<<i)) {
+           dst = get_dst_reg(c, inst, i);
+           src0 = get_src_reg_imm(c, inst, 0, i);
+           brw_FRC(p, dst, src0);
+       }
+    }
+    if (inst->SaturateMode != SATURATE_OFF)
+       brw_set_saturate(p, 0);
+}
+
+static void emit_flr(struct brw_wm_compile *c,
+                     const struct brw_fp_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    struct brw_reg src0, dst;
+    GLuint mask = inst->DstReg.WriteMask;
+    int i;
+    brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
+    for (i = 0 ; i < 4; i++) {
+       if (mask & (1<<i)) {
+           dst = get_dst_reg(c, inst, i);
+           src0 = get_src_reg_imm(c, inst, 0, i);
+           brw_RNDD(p, dst, src0);
+       }
+    }
+    brw_set_saturate(p, 0);
+}
+
+
+static void emit_min_max(struct brw_wm_compile *c,
+                         const struct brw_fp_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    const GLuint mask = inst->DstReg.WriteMask;
+    const int mark = mark_tmps(c);
+    int i;
+    brw_push_insn_state(p);
+    for (i = 0; i < 4; i++) {
+       if (mask & (1<<i)) {
+            struct brw_reg real_dst = get_dst_reg(c, inst, i);
+           struct brw_reg src0 = get_src_reg(c, inst, 0, i);
+           struct brw_reg src1 = get_src_reg(c, inst, 1, i);
+            struct brw_reg dst;
+            /* if dst==src0 or dst==src1 we need to use a temp reg */
+            GLboolean use_temp = brw_same_reg(dst, src0) ||
+                                 brw_same_reg(dst, src1);
+            if (use_temp)
+               dst = alloc_tmp(c);
+            else
+               dst = real_dst;
+
+            /*
+            printf("  Min/max: dst %d  src0 %d  src1 %d\n",
+                   dst.nr, src0.nr, src1.nr);
+            */
+           brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
+           brw_MOV(p, dst, src0);
+           brw_set_saturate(p, 0);
+
+            if (inst->Opcode == OPCODE_MIN)
+               brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_L, src1, src0);
+            else
+               brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_G, src1, src0);
+
+           brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
+           brw_set_predicate_control(p, BRW_PREDICATE_NORMAL);
+           brw_MOV(p, dst, src1);
+           brw_set_saturate(p, 0);
+           brw_set_predicate_control_flag_value(p, 0xff);
+            if (use_temp)
+               brw_MOV(p, real_dst, dst);
+       }
+    }
+    brw_pop_insn_state(p);
+    release_tmps(c, mark);
+}
+
+static void emit_pow(struct brw_wm_compile *c,
+                     const struct brw_fp_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    struct brw_reg dst, src0, src1;
+    GLuint mask = inst->DstReg.WriteMask;
+    int dst_chan = ffs(mask & WRITEMASK_XYZW) - 1;
+
+    if (!(mask & WRITEMASK_XYZW))
+       return;
+
+    assert(is_power_of_two(mask & WRITEMASK_XYZW));
+
+    dst = get_dst_reg(c, inst, dst_chan);
+    src0 = get_src_reg_imm(c, inst, 0, 0);
+    src1 = get_src_reg_imm(c, inst, 1, 0);
+
+    brw_MOV(p, brw_message_reg(2), src0);
+    brw_MOV(p, brw_message_reg(3), src1);
+
+    brw_math(p,
+           dst,
+           BRW_MATH_FUNCTION_POW,
+           (inst->SaturateMode != SATURATE_OFF) ? BRW_MATH_SATURATE_SATURATE : BRW_MATH_SATURATE_NONE,
+           2,
+           brw_null_reg(),
+           BRW_MATH_DATA_VECTOR,
+           BRW_MATH_PRECISION_FULL);
+}
+
+static void emit_lrp(struct brw_wm_compile *c,
+                     const struct brw_fp_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+    struct brw_reg dst, tmp1, tmp2, src0, src1, src2;
+    int i;
+    int mark = mark_tmps(c);
+    for (i = 0; i < 4; i++) {
+       if (mask & (1<<i)) {
+           dst = get_dst_reg(c, inst, i);
+           src0 = get_src_reg(c, inst, 0, i);
+
+           src1 = get_src_reg_imm(c, inst, 1, i);
+
+           if (src1.nr == dst.nr) {
+               tmp1 = alloc_tmp(c);
+               brw_MOV(p, tmp1, src1);
+           } else
+               tmp1 = src1;
+
+           src2 = get_src_reg(c, inst, 2, i);
+           if (src2.nr == dst.nr) {
+               tmp2 = alloc_tmp(c);
+               brw_MOV(p, tmp2, src2);
+           } else
+               tmp2 = src2;
+
+           brw_ADD(p, dst, negate(src0), brw_imm_f(1.0));
+           brw_MUL(p, brw_null_reg(), dst, tmp2);
+           brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
+           brw_MAC(p, dst, src0, tmp1);
+           brw_set_saturate(p, 0);
+       }
+       release_tmps(c, mark);
+    }
+}
+
+/**
+ * For GLSL shaders, this KIL will be unconditional.
+ * It may be contained inside an IF/ENDIF structure of course.
+ */
+static void emit_kil(struct brw_wm_compile *c)
+{
+    struct brw_compile *p = &c->func;
+    struct brw_reg depth = retype(brw_vec1_grf(0, 0), BRW_REGISTER_TYPE_UW);
+    brw_push_insn_state(p);
+    brw_set_mask_control(p, BRW_MASK_DISABLE);
+    brw_NOT(p, c->emit_mask_reg, brw_mask_reg(1)); //IMASK
+    brw_AND(p, depth, c->emit_mask_reg, depth);
+    brw_pop_insn_state(p);
+}
+
+static void emit_mad(struct brw_wm_compile *c,
+                     const struct brw_fp_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+    struct brw_reg dst, src0, src1, src2;
+    int i;
+
+    for (i = 0; i < 4; i++) {
+       if (mask & (1<<i)) {
+           dst = get_dst_reg(c, inst, i);
+           src0 = get_src_reg(c, inst, 0, i);
+           src1 = get_src_reg_imm(c, inst, 1, i);
+           src2 = get_src_reg_imm(c, inst, 2, i);
+           brw_MUL(p, dst, src0, src1);
+
+           brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
+           brw_ADD(p, dst, dst, src2);
+           brw_set_saturate(p, 0);
+       }
+    }
+}
+
+static void emit_sop(struct brw_wm_compile *c,
+                     const struct brw_fp_instruction *inst, GLuint cond)
+{
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+    struct brw_reg dst, src0, src1;
+    int i;
+
+    for (i = 0; i < 4; i++) {
+       if (mask & (1<<i)) {
+           dst = get_dst_reg(c, inst, i);
+           src0 = get_src_reg(c, inst, 0, i);
+           src1 = get_src_reg_imm(c, inst, 1, i);
+           brw_push_insn_state(p);
+           brw_CMP(p, brw_null_reg(), cond, src0, src1);
+           brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+           brw_MOV(p, dst, brw_imm_f(0.0));
+           brw_set_predicate_control(p, BRW_PREDICATE_NORMAL);
+           brw_MOV(p, dst, brw_imm_f(1.0));
+           brw_pop_insn_state(p);
+       }
+    }
+}
+
+static void emit_slt(struct brw_wm_compile *c,
+                     const struct brw_fp_instruction *inst)
+{
+    emit_sop(c, inst, BRW_CONDITIONAL_L);
+}
+
+static void emit_sle(struct brw_wm_compile *c,
+                     const struct brw_fp_instruction *inst)
+{
+    emit_sop(c, inst, BRW_CONDITIONAL_LE);
+}
+
+static void emit_sgt(struct brw_wm_compile *c,
+                     const struct brw_fp_instruction *inst)
+{
+    emit_sop(c, inst, BRW_CONDITIONAL_G);
+}
+
+static void emit_sge(struct brw_wm_compile *c,
+                     const struct brw_fp_instruction *inst)
+{
+    emit_sop(c, inst, BRW_CONDITIONAL_GE);
+}
+
+static void emit_seq(struct brw_wm_compile *c,
+                     const struct brw_fp_instruction *inst)
+{
+    emit_sop(c, inst, BRW_CONDITIONAL_EQ);
+}
+
+static void emit_sne(struct brw_wm_compile *c,
+                     const struct brw_fp_instruction *inst)
+{
+    emit_sop(c, inst, BRW_CONDITIONAL_NEQ);
+}
+
+static INLINE struct brw_reg high_words( struct brw_reg reg )
+{
+    return stride( suboffset( retype( reg, BRW_REGISTER_TYPE_W ), 1 ),
+                  0, 8, 2 );
+}
+
+static INLINE struct brw_reg low_words( struct brw_reg reg )
+{
+    return stride( retype( reg, BRW_REGISTER_TYPE_W ), 0, 8, 2 );
+}
+
+static INLINE struct brw_reg even_bytes( struct brw_reg reg )
+{
+    return stride( retype( reg, BRW_REGISTER_TYPE_B ), 0, 16, 2 );
+}
+
+static INLINE struct brw_reg odd_bytes( struct brw_reg reg )
+{
+    return stride( suboffset( retype( reg, BRW_REGISTER_TYPE_B ), 1 ),
+                  0, 16, 2 );
+}
+
+
+    
+static void emit_wpos_xy(struct brw_wm_compile *c,
+                         const struct brw_fp_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+    struct brw_reg src0[2], dst[2];
+
+    dst[0] = get_dst_reg(c, inst, 0);
+    dst[1] = get_dst_reg(c, inst, 1);
+
+    src0[0] = get_src_reg(c, inst, 0, 0);
+    src0[1] = get_src_reg(c, inst, 0, 1);
+
+    /* Calculate the pixel offset from window bottom left into destination
+     * X and Y channels.
+     */
+    if (mask & WRITEMASK_X) {
+       /* X' = X */
+       brw_MOV(p,
+               dst[0],
+               retype(src0[0], BRW_REGISTER_TYPE_W));
+    }
+
+    if (mask & WRITEMASK_Y) {
+       /* Y' = height - 1 - Y */
+       brw_ADD(p,
+               dst[1],
+               negate(retype(src0[1], BRW_REGISTER_TYPE_W)),
+               brw_imm_d(c->key.drawable_height - 1));
+    }
+}
+
+/* TODO
+   BIAS on SIMD8 not working yet...
+ */    
+static void emit_txb(struct brw_wm_compile *c,
+                     const struct brw_fp_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    struct brw_reg dst[4], src[4], payload_reg;
+    /* Note: tex_unit was already looked up through SamplerTextures[] */
+    const GLuint unit = inst->tex_unit;
+    GLuint i;
+    GLuint msg_type;
+
+    assert(unit < BRW_MAX_TEX_UNIT);
+
+    payload_reg = get_reg(c, TGSI_FILE_PAYLOAD, PAYLOAD_DEPTH, 0, 1, 0, 0);
+
+    for (i = 0; i < 4; i++) 
+       dst[i] = get_dst_reg(c, inst, i);
+    for (i = 0; i < 4; i++)
+       src[i] = get_src_reg(c, inst, 0, i);
+
+    switch (inst->tex_target) {
+       case TEXTURE_1D_INDEX:
+           brw_MOV(p, brw_message_reg(2), src[0]);         /* s coord */
+           brw_MOV(p, brw_message_reg(3), brw_imm_f(0));   /* t coord */
+           brw_MOV(p, brw_message_reg(4), brw_imm_f(0));   /* r coord */
+           break;
+       case TEXTURE_2D_INDEX:
+       case TEXTURE_RECT_INDEX:
+           brw_MOV(p, brw_message_reg(2), src[0]);
+           brw_MOV(p, brw_message_reg(3), src[1]);
+           brw_MOV(p, brw_message_reg(4), brw_imm_f(0));
+           break;
+       case TEXTURE_3D_INDEX:
+       case TEXTURE_CUBE_INDEX:
+           brw_MOV(p, brw_message_reg(2), src[0]);
+           brw_MOV(p, brw_message_reg(3), src[1]);
+           brw_MOV(p, brw_message_reg(4), src[2]);
+           break;
+       default:
+            /* invalid target */
+            abort();
+    }
+    brw_MOV(p, brw_message_reg(5), src[3]);          /* bias */
+    brw_MOV(p, brw_message_reg(6), brw_imm_f(0));    /* ref (unused?) */
+
+    if (BRW_IS_IGDNG(p->brw)) {
+        msg_type = BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_BIAS_IGDNG;
+    } else {
+        /* Does it work well on SIMD8? */
+        msg_type = BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_BIAS;
+    }
+
+    brw_SAMPLE(p,
+               retype(vec8(dst[0]), BRW_REGISTER_TYPE_UW),  /* dest */
+               1,                                           /* msg_reg_nr */
+               retype(payload_reg, BRW_REGISTER_TYPE_UW),   /* src0 */
+               SURF_INDEX_TEXTURE(unit),
+               unit,                                        /* sampler */
+               inst->DstReg.WriteMask,                      /* writemask */
+               msg_type,                                    /* msg_type */
+               4,                                           /* response_length */
+               4,                                           /* msg_length */
+               0,                                           /* eot */
+               1,
+               BRW_SAMPLER_SIMD_MODE_SIMD8);   
+}
+
+
+static void emit_tex(struct brw_wm_compile *c,
+                     const struct brw_fp_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    struct brw_reg dst[4], src[4], payload_reg;
+    /* Note: tex_unit was already looked up through SamplerTextures[] */
+    const GLuint unit = inst->tex_unit;
+    GLuint msg_len;
+    GLuint i, nr;
+    GLuint emit;
+    GLboolean shadow = (c->key.shadowtex_mask & (1<<unit)) ? 1 : 0;
+    GLuint msg_type;
+
+    assert(unit < BRW_MAX_TEX_UNIT);
+
+    payload_reg = get_reg(c, TGSI_FILE_PAYLOAD, PAYLOAD_DEPTH, 0, 1, 0, 0);
+
+    for (i = 0; i < 4; i++) 
+       dst[i] = get_dst_reg(c, inst, i);
+    for (i = 0; i < 4; i++)
+       src[i] = get_src_reg(c, inst, 0, i);
+
+    switch (inst->tex_target) {
+       case TEXTURE_1D_INDEX:
+           emit = WRITEMASK_X;
+           nr = 1;
+           break;
+       case TEXTURE_2D_INDEX:
+       case TEXTURE_RECT_INDEX:
+           emit = WRITEMASK_XY;
+           nr = 2;
+           break;
+       case TEXTURE_3D_INDEX:
+       case TEXTURE_CUBE_INDEX:
+           emit = WRITEMASK_XYZ;
+           nr = 3;
+           break;
+       default:
+           /* invalid target */
+           abort();
+    }
+    msg_len = 1;
+
+    /* move/load S, T, R coords */
+    for (i = 0; i < nr; i++) {
+       static const GLuint swz[4] = {0,1,2,2};
+       if (emit & (1<<i))
+           brw_MOV(p, brw_message_reg(msg_len+1), src[swz[i]]);
+       else
+           brw_MOV(p, brw_message_reg(msg_len+1), brw_imm_f(0));
+       msg_len += 1;
+    }
+
+    if (shadow) {
+       brw_MOV(p, brw_message_reg(5), brw_imm_f(0));  /* lod / bias */
+       brw_MOV(p, brw_message_reg(6), src[2]);        /* ref value / R coord */
+    }
+
+    if (BRW_IS_IGDNG(p->brw)) {
+        if (shadow)
+            msg_type = BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_COMPARE_IGDNG;
+        else
+            msg_type = BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_IGDNG;
+    } else {
+        /* Does it work for shadow on SIMD8 ? */
+        msg_type = BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE;
+    }
+    
+    brw_SAMPLE(p,
+               retype(vec8(dst[0]), BRW_REGISTER_TYPE_UW), /* dest */
+               1,                                          /* msg_reg_nr */
+               retype(payload_reg, BRW_REGISTER_TYPE_UW),  /* src0 */
+               SURF_INDEX_TEXTURE(unit),
+               unit,                                       /* sampler */
+               inst->DstReg.WriteMask,                     /* writemask */
+               msg_type,                                   /* msg_type */
+               4,                                          /* response_length */
+               shadow ? 6 : 4,                             /* msg_length */
+               0,                                          /* eot */
+               1,
+               BRW_SAMPLER_SIMD_MODE_SIMD8);   
+
+    if (shadow)
+       brw_MOV(p, dst[3], brw_imm_f(1.0));
+}
+
+
+/**
+ * Resolve subroutine calls after code emit is done.
+ */
+static void post_wm_emit( struct brw_wm_compile *c )
+{
+    brw_resolve_cals(&c->func);
+}
+
+static void
+get_argument_regs(struct brw_wm_compile *c,
+                 const struct brw_fp_instruction *inst,
+                 int index,
+                 struct brw_reg *regs,
+                 int mask)
+{
+    int i;
+
+    for (i = 0; i < 4; i++) {
+       if (mask & (1 << i))
+           regs[i] = get_src_reg(c, inst, index, i);
+    }
+}
+
+static void brw_wm_emit_branching_shader(struct brw_context *brw, struct brw_wm_compile *c)
+{
+#define MAX_IF_DEPTH 32
+#define MAX_LOOP_DEPTH 32
+    struct brw_instruction *if_inst[MAX_IF_DEPTH], *loop_inst[MAX_LOOP_DEPTH];
+    GLuint i, if_depth = 0, loop_depth = 0;
+    struct brw_compile *p = &c->func;
+    struct brw_indirect stack_index = brw_indirect(0, 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));
+
+    for (i = 0; i < c->nr_fp_insns; i++) {
+        const struct brw_fp_instruction *inst = &c->fp_instructions[i];
+       int dst_flags;
+       struct brw_reg args[3][4], dst[4];
+       int j;
+
+        c->cur_inst = i;
+
+#if 0
+        debug_printf("Inst %d: ", i);
+        _mesa_print_instruction(inst);
+#endif
+
+        /* fetch any constants that this instruction needs */
+        if (c->fp->use_const_buffer)
+           fetch_constants(c, inst);
+
+       if (inst->CondUpdate)
+           brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
+       else
+           brw_set_conditionalmod(p, BRW_CONDITIONAL_NONE);
+
+       dst_flags = inst->DstReg.WriteMask;
+       if (inst->SaturateMode == SATURATE_ZERO_ONE)
+           dst_flags |= SATURATE;
+
+       switch (inst->Opcode) {
+           case WM_PIXELXY:
+               emit_pixel_xy(c, inst);
+               break;
+           case WM_DELTAXY: 
+               emit_delta_xy(c, inst);
+               break;
+           case WM_PIXELW:
+               emit_pixel_w(c, inst);
+               break;  
+           case WM_LINTERP:
+               emit_linterp(c, inst);
+               break;
+           case WM_PINTERP:
+               emit_pinterp(c, inst);
+               break;
+           case WM_CINTERP:
+               emit_cinterp(c, inst);
+               break;
+           case WM_WPOSXY:
+               emit_wpos_xy(c, inst);
+               break;
+           case WM_FB_WRITE:
+               emit_fb_write(c, inst);
+               break;
+           case WM_FRONTFACING:
+               emit_frontfacing(c, inst);
+               break;
+           case OPCODE_ADD:
+               emit_add(c, inst);
+               break;
+           case OPCODE_ARL:
+               emit_arl(c, inst);
+               break;
+           case OPCODE_FRC:
+               emit_frc(c, inst);
+               break;
+           case OPCODE_FLR:
+               emit_flr(c, inst);
+               break;
+           case OPCODE_LRP:
+               emit_lrp(c, inst);
+               break;
+           case OPCODE_TRUNC:
+               emit_trunc(c, inst);
+               break;
+           case OPCODE_MOV:
+               emit_mov(c, inst);
+               break;
+           case OPCODE_DP3:
+               emit_dp3(c, inst);
+               break;
+           case OPCODE_DP4:
+               emit_dp4(c, inst);
+               break;
+           case OPCODE_XPD:
+               emit_xpd(c, inst);
+               break;
+           case OPCODE_DPH:
+               emit_dph(c, inst);
+               break;
+           case OPCODE_RCP:
+               emit_rcp(c, inst);
+               break;
+           case OPCODE_RSQ:
+               emit_rsq(c, inst);
+               break;
+           case OPCODE_SIN:
+               emit_sin(c, inst);
+               break;
+           case OPCODE_COS:
+               emit_cos(c, inst);
+               break;
+           case OPCODE_EX2:
+               emit_ex2(c, inst);
+               break;
+           case OPCODE_LG2:
+               emit_lg2(c, inst);
+               break;
+           case OPCODE_MIN:    
+           case OPCODE_MAX:    
+               emit_min_max(c, inst);
+               break;
+           case OPCODE_DDX:
+           case OPCODE_DDY:
+               for (j = 0; j < 4; j++) {
+                   if (inst->DstReg.WriteMask & (1 << j))
+                       dst[j] = get_dst_reg(c, inst, j);
+                   else
+                       dst[j] = brw_null_reg();
+               }
+               get_argument_regs(c, inst, 0, args[0], WRITEMASK_XYZW);
+               emit_ddxy(p, dst, dst_flags, (inst->Opcode == OPCODE_DDX),
+                         args[0]);
+                break;
+           case OPCODE_SLT:
+               emit_slt(c, inst);
+               break;
+           case OPCODE_SLE:
+               emit_sle(c, inst);
+               break;
+           case OPCODE_SGT:
+               emit_sgt(c, inst);
+               break;
+           case OPCODE_SGE:
+               emit_sge(c, inst);
+               break;
+           case OPCODE_SEQ:
+               emit_seq(c, inst);
+               break;
+           case OPCODE_SNE:
+               emit_sne(c, inst);
+               break;
+           case OPCODE_MUL:
+               emit_mul(c, inst);
+               break;
+           case OPCODE_POW:
+               emit_pow(c, inst);
+               break;
+           case OPCODE_MAD:
+               emit_mad(c, inst);
+               break;
+           case OPCODE_TEX:
+               emit_tex(c, inst);
+               break;
+           case OPCODE_TXB:
+               emit_txb(c, inst);
+               break;
+           case OPCODE_KIL_NV:
+               emit_kil(c);
+               break;
+           case OPCODE_IF:
+               assert(if_depth < MAX_IF_DEPTH);
+               if_inst[if_depth++] = brw_IF(p, BRW_EXECUTE_8);
+               break;
+           case OPCODE_ELSE:
+               if_inst[if_depth-1]  = brw_ELSE(p, if_inst[if_depth-1]);
+               break;
+           case OPCODE_ENDIF:
+               assert(if_depth > 0);
+               brw_ENDIF(p, if_inst[--if_depth]);
+               break;
+           case OPCODE_BGNSUB:
+               brw_save_label(p, inst->Comment, p->nr_insn);
+               break;
+           case OPCODE_ENDSUB:
+               /* no-op */
+               break;
+           case OPCODE_CAL: 
+               brw_push_insn_state(p);
+               brw_set_mask_control(p, BRW_MASK_DISABLE);
+                brw_set_access_mode(p, BRW_ALIGN_1);
+                brw_ADD(p, deref_1ud(stack_index, 0), brw_ip_reg(), brw_imm_d(3*16));
+                brw_set_access_mode(p, BRW_ALIGN_16);
+                brw_ADD(p, get_addr_reg(stack_index),
+                         get_addr_reg(stack_index), brw_imm_d(4));
+               brw_save_call(&c->func, inst->label, p->nr_insn);
+                brw_ADD(p, brw_ip_reg(), brw_ip_reg(), brw_imm_d(1*16));
+                brw_pop_insn_state(p);
+               break;
+
+           case OPCODE_RET:
+               brw_push_insn_state(p);
+               brw_set_mask_control(p, BRW_MASK_DISABLE);
+                brw_ADD(p, get_addr_reg(stack_index),
+                        get_addr_reg(stack_index), brw_imm_d(-4));
+                brw_set_access_mode(p, BRW_ALIGN_1);
+                brw_MOV(p, brw_ip_reg(), deref_1ud(stack_index, 0));
+                brw_set_access_mode(p, BRW_ALIGN_16);
+               brw_pop_insn_state(p);
+
+               break;
+           case OPCODE_BGNLOOP:
+                /* XXX may need to invalidate the current_constant regs */
+               loop_inst[loop_depth++] = brw_DO(p, BRW_EXECUTE_8);
+               break;
+           case OPCODE_BRK:
+               brw_BREAK(p);
+               brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+               break;
+           case OPCODE_CONT:
+               brw_CONT(p);
+               brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+               break;
+           case OPCODE_ENDLOOP: 
+               {
+                  struct brw_instruction *inst0, *inst1;
+                  GLuint br = 1;
+
+                  if (BRW_IS_IGDNG(brw))
+                     br = 2;
+                  loop_depth--;
+                  inst0 = inst1 = brw_WHILE(p, loop_inst[loop_depth]);
+                  /* patch all the BREAK/CONT instructions from last BGNLOOP */
+                  while (inst0 > loop_inst[loop_depth]) {
+                     inst0--;
+                     if (inst0->header.opcode == BRW_OPCODE_BREAK) {
+                       inst0->bits3.if_else.jump_count = br * (inst1 - inst0 + 1);
+                       inst0->bits3.if_else.pop_count = 0;
+                     }
+                     else if (inst0->header.opcode == BRW_OPCODE_CONTINUE) {
+                        inst0->bits3.if_else.jump_count = br * (inst1 - inst0);
+                        inst0->bits3.if_else.pop_count = 0;
+                     }
+                  }
+               }
+               break;
+           default:
+               debug_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 (BRW_DEBUG & DEBUG_WM) {
+      debug_printf("wm-native:\n");
+      brw_disasm(stderr, p->store, p->nr_insn);
+    }
+}
+
+/**
+ * Do GPU code generation for shaders that use GLSL features such as
+ * flow control.  Other shaders will be compiled with the 
+ */
+void brw_wm_branching_shader_emit(struct brw_context *brw, struct brw_wm_compile *c)
+{
+    if (BRW_DEBUG & DEBUG_WM) {
+       debug_printf("%s:\n", __FUNCTION__);
+    }
+
+    /* initial instruction translation/simplification */
+    brw_wm_pass_fp(c);
+
+    /* actual code generation */
+    brw_wm_emit_branching_shader(brw, c);
+
+    if (BRW_DEBUG & DEBUG_WM) {
+        brw_wm_print_program(c, "brw_wm_branching_shader_emit done");
+    }
+
+    c->prog_data.total_grf = num_grf_used(c);
+    c->prog_data.total_scratch = 0;
+}
diff --git a/src/gallium/drivers/i965/brw_wm_iz.c b/src/gallium/drivers/i965/brw_wm_iz.c
new file mode 100644 (file)
index 0000000..6f1e9fc
--- /dev/null
@@ -0,0 +1,156 @@
+/*
+ Copyright (C) Intel Corp.  2006.  All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ **********************************************************************/
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  */
+                
+
+#include "brw_wm.h"
+
+
+#undef P                       /* prompted depth */
+#undef C                       /* computed */
+#undef N                       /* non-promoted? */
+
+#define P 0
+#define C 1
+#define N 2
+
+const struct {
+   GLuint mode:2;
+   GLuint sd_present:1;
+   GLuint sd_to_rt:1;
+   GLuint dd_present:1;
+   GLuint ds_present:1;
+} wm_iz_table[IZ_BIT_MAX] =
+{
+ { P, 0, 0, 0, 0 }, 
+ { P, 0, 0, 0, 0 }, 
+ { P, 0, 0, 0, 0 }, 
+ { P, 0, 0, 0, 0 }, 
+ { P, 0, 0, 0, 0 }, 
+ { N, 1, 1, 0, 0 }, 
+ { N, 0, 1, 0, 0 }, 
+ { N, 0, 1, 0, 0 }, 
+ { P, 0, 0, 0, 0 }, 
+ { P, 0, 0, 0, 0 }, 
+ { C, 0, 1, 1, 0 }, 
+ { C, 0, 1, 1, 0 }, 
+ { P, 0, 0, 0, 0 }, 
+ { N, 1, 1, 0, 0 }, 
+ { C, 0, 1, 1, 0 }, 
+ { C, 0, 1, 1, 0 }, 
+ { P, 0, 0, 0, 0 }, 
+ { P, 0, 0, 0, 0 }, 
+ { P, 0, 0, 0, 0 }, 
+ { P, 0, 0, 0, 0 }, 
+ { P, 0, 0, 0, 0 }, 
+ { N, 1, 1, 0, 0 }, 
+ { N, 0, 1, 0, 0 }, 
+ { N, 0, 1, 0, 0 }, 
+ { P, 0, 0, 0, 0 }, 
+ { P, 0, 0, 0, 0 }, 
+ { C, 0, 1, 1, 0 }, 
+ { C, 0, 1, 1, 0 }, 
+ { P, 0, 0, 0, 0 }, 
+ { N, 1, 1, 0, 0 }, 
+ { C, 0, 1, 1, 0 }, 
+ { C, 0, 1, 1, 0 }, 
+ { P, 0, 0, 0, 0 }, 
+ { P, 0, 0, 0, 0 }, 
+ { P, 0, 0, 0, 0 }, 
+ { P, 0, 0, 0, 0 }, 
+ { P, 0, 0, 0, 0 }, 
+ { N, 1, 1, 0, 1 }, 
+ { N, 0, 1, 0, 1 }, 
+ { N, 0, 1, 0, 1 }, 
+ { P, 0, 0, 0, 0 }, 
+ { P, 0, 0, 0, 0 }, 
+ { C, 0, 1, 1, 1 }, 
+ { C, 0, 1, 1, 1 }, 
+ { P, 0, 0, 0, 0 }, 
+ { N, 1, 1, 0, 1 }, 
+ { C, 0, 1, 1, 1 }, 
+ { C, 0, 1, 1, 1 }, 
+ { P, 0, 0, 0, 0 }, 
+ { C, 0, 0, 0, 1 }, 
+ { P, 0, 0, 0, 0 }, 
+ { C, 0, 1, 0, 1 }, 
+ { P, 0, 0, 0, 0 }, 
+ { C, 1, 1, 0, 1 }, 
+ { C, 0, 1, 0, 1 }, 
+ { C, 0, 1, 0, 1 }, 
+ { P, 0, 0, 0, 0 }, 
+ { C, 1, 1, 1, 1 }, 
+ { C, 0, 1, 1, 1 }, 
+ { C, 0, 1, 1, 1 }, 
+ { P, 0, 0, 0, 0 }, 
+ { C, 1, 1, 1, 1 }, 
+ { C, 0, 1, 1, 1 }, 
+ { 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,
+                      GLboolean ps_uses_depth,
+                      struct brw_wm_prog_key *key )
+{
+   GLuint reg = 2;
+
+   assert (lookup < IZ_BIT_MAX);
+      
+   if (lookup & IZ_PS_COMPUTES_DEPTH_BIT)
+      key->computes_depth = 1;
+
+   if (wm_iz_table[lookup].sd_present || ps_uses_depth) {
+      key->source_depth_reg = reg;
+      reg += 2;
+   }
+
+   if (wm_iz_table[lookup].sd_to_rt)
+      key->source_depth_to_render_target = 1;
+
+   if (wm_iz_table[lookup].ds_present || line_aa != AA_NEVER) {
+      key->aa_dest_stencil_reg = reg;
+      key->runtime_check_aads_emit = (!wm_iz_table[lookup].ds_present &&
+                                     line_aa == AA_SOMETIMES);
+      reg++;
+   }
+
+   if (wm_iz_table[lookup].dd_present) {
+      key->dest_depth_reg = reg;
+      reg+=2;
+   }
+
+   key->nr_depth_regs = (reg+1)/2;
+}
+
diff --git a/src/gallium/drivers/i965/brw_wm_pass0.c b/src/gallium/drivers/i965/brw_wm_pass0.c
new file mode 100644 (file)
index 0000000..0bacad2
--- /dev/null
@@ -0,0 +1,366 @@
+/*
+ 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 "util/u_memory.h"
+#include "util/u_math.h"
+
+#include "brw_debug.h"
+#include "brw_wm.h"
+
+
+
+/***********************************************************************
+ */
+
+static struct brw_wm_ref *get_ref( struct brw_wm_compile *c )
+{
+   assert(c->nr_refs < BRW_WM_MAX_REF);
+   return &c->refs[c->nr_refs++];
+}
+
+static struct brw_wm_value *get_value( struct brw_wm_compile *c)
+{
+   assert(c->nr_refs < BRW_WM_MAX_VREG);
+   return &c->vreg[c->nr_vreg++];
+}
+
+/** return pointer to a newly allocated instruction */
+static struct brw_wm_instruction *get_instruction( struct brw_wm_compile *c )
+{
+   assert(c->nr_insns < BRW_WM_MAX_INSN);
+   return &c->instruction[c->nr_insns++];
+}
+
+/***********************************************************************
+ */
+
+/** Init the "undef" register */
+static void pass0_init_undef( struct brw_wm_compile *c)
+{
+   struct brw_wm_ref *ref = &c->undef_ref;
+   ref->value = &c->undef_value;
+   ref->hw_reg = brw_vec8_grf(0, 0);
+   ref->insn = 0;
+   ref->prevuse = NULL;
+}
+
+/** Set a FP register to a value */
+static void pass0_set_fpreg_value( struct brw_wm_compile *c,
+                                  GLuint file,
+                                  GLuint idx,
+                                  GLuint component,
+                                  struct brw_wm_value *value )
+{
+   struct brw_wm_ref *ref = get_ref(c);
+   ref->value = value;
+   ref->hw_reg = brw_vec8_grf(0, 0);
+   ref->insn = 0;
+   ref->prevuse = NULL;
+   c->pass0_fp_reg[file][idx][component] = ref;
+}
+
+/** Set a FP register to a ref */
+static void pass0_set_fpreg_ref( struct brw_wm_compile *c,
+                                GLuint file,
+                                GLuint idx,
+                                GLuint component,
+                                const struct brw_wm_ref *src_ref )
+{
+   c->pass0_fp_reg[file][idx][component] = src_ref;
+}
+
+static const struct brw_wm_ref *get_param_ref( struct brw_wm_compile *c, 
+                                              unsigned idx,
+                                               unsigned component)
+{
+   GLuint i = idx * 4 + component;
+   
+   if (i >= BRW_WM_MAX_PARAM) {
+      debug_printf("%s: out of params\n", __FUNCTION__);
+      c->prog_data.error = 1;
+      return NULL;
+   }
+   else {
+      struct brw_wm_ref *ref = get_ref(c);
+
+      c->nr_creg = MAX2(c->nr_creg, (i+16)/16);
+
+      /* Push the offsets into hw_reg.  These will be added to the
+       * real register numbers once one is allocated in pass2.
+       */
+      ref->hw_reg = brw_vec1_grf((i&8)?1:0, i%8);
+      ref->value = &c->creg[i/16];
+      ref->insn = 0;
+      ref->prevuse = NULL;
+
+      return ref;
+   }
+}
+
+
+
+
+/* Lookup our internal registers
+ */
+static const struct brw_wm_ref *pass0_get_reg( struct brw_wm_compile *c,
+                                              GLuint file,
+                                              GLuint idx,
+                                              GLuint component )
+{
+   const struct brw_wm_ref *ref = c->pass0_fp_reg[file][idx][component];
+
+   if (!ref) {
+      switch (file) {
+      case TGSI_FILE_INPUT:
+      case TGSI_FILE_TEMPORARY:
+      case TGSI_FILE_OUTPUT:
+      case BRW_FILE_PAYLOAD:
+        /* should already be done?? */
+        break;
+
+      case TGSI_FILE_CONSTANT:
+        ref = get_param_ref(c, 
+                             c->fp->info.immediate_count + idx,
+                             component);
+        break;
+
+      case TGSI_FILE_IMMEDIATE:
+        ref = get_param_ref(c, 
+                             idx,
+                             component);
+        break;
+
+      default:
+        assert(0);
+        break;
+      }
+
+      c->pass0_fp_reg[file][idx][component] = ref;
+   }
+
+   if (!ref)
+      ref = &c->undef_ref;
+
+   return ref;
+}
+
+
+
+/***********************************************************************
+ * Straight translation to internal instruction format
+ */
+
+static void pass0_set_dst( struct brw_wm_compile *c,
+                          struct brw_wm_instruction *out,
+                          const struct brw_fp_instruction *inst,
+                          GLuint writemask )
+{
+   const struct brw_fp_dst dst = inst->dst;
+   GLuint i;
+
+   for (i = 0; i < 4; i++) {
+      if (writemask & (1<<i)) {
+        out->dst[i] = get_value(c);
+        pass0_set_fpreg_value(c, dst.file, dst.index, i, out->dst[i]);
+      }
+   }
+
+   out->writemask = writemask;
+}
+
+
+static const struct brw_wm_ref *get_fp_src_reg_ref( struct brw_wm_compile *c,
+                                                   struct brw_fp_src src,
+                                                   GLuint i )
+{
+   return pass0_get_reg(c, src.file, src.index, BRW_GET_SWZ(src.swizzle,i));
+}
+
+
+static struct brw_wm_ref *get_new_ref( struct brw_wm_compile *c,
+                                      struct brw_fp_src src,
+                                      GLuint i,
+                                      struct brw_wm_instruction *insn)
+{
+   const struct brw_wm_ref *ref = get_fp_src_reg_ref(c, src, i);
+   struct brw_wm_ref *newref = get_ref(c);
+
+   newref->value = ref->value;
+   newref->hw_reg = ref->hw_reg;
+
+   if (insn) {
+      newref->insn = insn - c->instruction;
+      newref->prevuse = newref->value->lastuse;
+      newref->value->lastuse = newref;
+   }
+
+   if (src.negate)
+      newref->hw_reg.negate ^= 1;
+
+   if (src.abs) {
+      newref->hw_reg.negate = 0;
+      newref->hw_reg.abs = 1;
+   }
+
+   return newref;
+}
+
+
+static void
+translate_insn(struct brw_wm_compile *c,
+               const struct brw_fp_instruction *inst)
+{
+   struct brw_wm_instruction *out = get_instruction(c);
+   GLuint writemask = inst->dst.writemask;
+   GLuint nr_args = brw_wm_nr_args(inst->opcode);
+   GLuint i, j;
+
+   /* Copy some data out of the instruction
+    */
+   out->opcode = inst->opcode;
+   out->saturate = inst->dst.saturate;
+   out->tex_unit = inst->tex_unit;
+   out->target = inst->target;
+
+   /* Nasty hack:
+    */
+   out->eot = (inst->opcode == WM_FB_WRITE &&
+               inst->tex_unit != 0);
+
+
+   /* Args:
+    */
+   for (i = 0; i < nr_args; i++) {
+      for (j = 0; j < 4; j++) {
+        out->src[i][j] = get_new_ref(c, inst->src[i], j, out);
+      }
+   }
+
+   /* Dst:
+    */
+   pass0_set_dst(c, out, inst, writemask);
+}
+
+
+
+/***********************************************************************
+ * Optimize moves and swizzles away:
+ */ 
+static void pass0_precalc_mov( struct brw_wm_compile *c,
+                              const struct brw_fp_instruction *inst )
+{
+   const struct brw_fp_dst dst = inst->dst;
+   GLuint writemask = dst.writemask;
+   struct brw_wm_ref *refs[4];
+   GLuint i;
+
+   /* Get the effect of a MOV by manipulating our register table:
+    * First get all refs, then assign refs.  This ensures that "in-place"
+    * swizzles such as:
+    *   MOV t, t.xxyx
+    * are handled correctly.  Previously, these two steps were done in
+    * one loop and the above case was incorrectly handled.
+    */
+   for (i = 0; i < 4; i++) {
+      refs[i] = get_new_ref(c, inst->src[0], i, NULL);
+   }
+   for (i = 0; i < 4; i++) {
+      if (writemask & (1 << i)) {          
+         pass0_set_fpreg_ref( c, dst.file, dst.index, i, refs[i]);
+      }
+   }
+}
+
+
+/* Initialize payload "registers".
+ */
+static void pass0_init_payload( struct brw_wm_compile *c )
+{
+   GLuint i;
+
+   for (i = 0; i < 4; i++) {
+      GLuint j = i >= c->key.nr_depth_regs ? 0 : i;
+      pass0_set_fpreg_value( c, BRW_FILE_PAYLOAD, PAYLOAD_DEPTH, i, 
+                            &c->payload.depth[j] );
+   }
+
+   for (i = 0; i < c->key.nr_inputs; i++)
+      pass0_set_fpreg_value( c, BRW_FILE_PAYLOAD, i, 0, 
+                            &c->payload.input_interp[i] );      
+}
+
+
+/***********************************************************************
+ * PASS 0
+ *
+ * Work forwards to give each calculated value a unique number.  Where
+ * an instruction produces duplicate values (eg DP3), all are given
+ * the same number.
+ *
+ * Translate away swizzling and eliminate non-saturating moves.
+ *
+ * Translate instructions from our fp_instruction structs to our
+ * internal brw_wm_instruction representation.
+ */
+void brw_wm_pass0( struct brw_wm_compile *c )
+{
+   GLuint insn;
+
+   c->nr_vreg = 0;
+   c->nr_insns = 0;
+
+   pass0_init_undef(c);
+   pass0_init_payload(c);
+
+   for (insn = 0; insn < c->nr_fp_insns; insn++) {
+      const struct brw_fp_instruction *inst = &c->fp_instructions[insn];
+
+      /* Optimize away moves, otherwise emit translated instruction:
+       */      
+      switch (inst->opcode) {
+      case TGSI_OPCODE_MOV: 
+        if (!inst->dst.saturate) {
+           pass0_precalc_mov(c, inst);
+        }
+        else {
+           translate_insn(c, inst);
+        }
+        break;
+      default:
+        translate_insn(c, inst);
+        break;
+      }
+   }
+   if (BRW_DEBUG & DEBUG_WM) {
+      brw_wm_print_program(c, "pass0");
+   }
+}
diff --git a/src/gallium/drivers/i965/brw_wm_pass1.c b/src/gallium/drivers/i965/brw_wm_pass1.c
new file mode 100644 (file)
index 0000000..005747f
--- /dev/null
@@ -0,0 +1,292 @@
+/*
+ Copyright (C) Intel Corp.  2006.  All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ **********************************************************************/
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  */
+                  
+
+#include "brw_wm.h"
+#include "brw_debug.h"
+
+
+static GLuint get_tracked_mask(struct brw_wm_compile *c,
+                              struct brw_wm_instruction *inst)
+{
+   GLuint i;
+   for (i = 0; i < 4; i++) {
+      if (inst->writemask & (1<<i)) {
+        if (!inst->dst[i]->contributes_to_output) {
+           inst->writemask &= ~(1<<i);
+           inst->dst[i] = 0;
+        }
+      }
+   }
+
+   return inst->writemask;
+}
+
+/* Remove a reference from a value's usage chain.
+ */
+static void unlink_ref(struct brw_wm_ref *ref)
+{
+   struct brw_wm_value *value = ref->value;
+
+   if (ref == value->lastuse) {
+      value->lastuse = ref->prevuse;
+   }
+   else {
+      struct brw_wm_ref *i = value->lastuse;
+      while (i->prevuse != ref) i = i->prevuse;
+      i->prevuse = ref->prevuse;
+   }
+}
+
+static void track_arg(struct brw_wm_compile *c,
+                     struct brw_wm_instruction *inst,
+                     GLuint arg,
+                     GLuint readmask)
+{
+   GLuint i;
+
+   for (i = 0; i < 4; i++) {
+      struct brw_wm_ref *ref = inst->src[arg][i];
+      if (ref) {
+        if (readmask & (1<<i)) {
+           ref->value->contributes_to_output = 1;
+         }
+        else {
+           unlink_ref(ref);
+           inst->src[arg][i] = NULL;
+        }
+      }
+   }
+}
+
+static GLuint get_texcoord_mask( GLuint tex_idx )
+{
+   switch (tex_idx) {
+   case TGSI_TEXTURE_1D:
+      return BRW_WRITEMASK_X;
+   case TGSI_TEXTURE_2D:
+   case TGSI_TEXTURE_RECT:
+      return BRW_WRITEMASK_XY;
+   case TGSI_TEXTURE_3D:
+      return BRW_WRITEMASK_XYZ;
+   case TGSI_TEXTURE_CUBE:
+      return BRW_WRITEMASK_XYZ;
+
+   case TGSI_TEXTURE_SHADOW1D:
+      return BRW_WRITEMASK_XZ;
+   case TGSI_TEXTURE_SHADOW2D:
+   case TGSI_TEXTURE_SHADOWRECT:
+      return BRW_WRITEMASK_XYZ;
+   default: 
+      assert(0);
+      return 0;
+   }
+}
+
+
+/* Step two: Basically this is dead code elimination.  
+ *
+ * Iterate backwards over instructions, noting which values
+ * contribute to the final result.  Adjust writemasks to only
+ * calculate these values.
+ */
+void brw_wm_pass1( struct brw_wm_compile *c )
+{
+   GLint insn;
+
+   for (insn = c->nr_insns-1; insn >= 0; insn--) {
+      struct brw_wm_instruction *inst = &c->instruction[insn];
+      GLuint writemask;
+      GLuint read0, read1, read2;
+
+      if (inst->opcode == TGSI_OPCODE_KIL) {
+        track_arg(c, inst, 0, BRW_WRITEMASK_XYZW); /* All args contribute to final */
+        continue;
+      }
+
+      if (inst->opcode == WM_FB_WRITE) {
+        track_arg(c, inst, 0, BRW_WRITEMASK_XYZW); 
+        track_arg(c, inst, 1, BRW_WRITEMASK_XYZW); 
+        if (c->key.source_depth_to_render_target &&
+            c->key.computes_depth)
+           track_arg(c, inst, 2, BRW_WRITEMASK_Z); 
+        else
+           track_arg(c, inst, 2, 0); 
+        continue;
+      }
+
+      /* Lookup all the registers which were written by this
+       * instruction and get a mask of those that contribute to the output:
+       */
+      writemask = get_tracked_mask(c, inst);
+      if (!writemask) {
+        GLuint arg;
+        for (arg = 0; arg < 3; arg++)
+           track_arg(c, inst, arg, 0);
+        continue;
+      }
+
+      read0 = 0;
+      read1 = 0;
+      read2 = 0;
+
+      /* Mark all inputs which contribute to the marked outputs:
+       */
+      switch (inst->opcode) {
+      case TGSI_OPCODE_ABS:
+      case TGSI_OPCODE_FLR:
+      case TGSI_OPCODE_FRC:
+      case TGSI_OPCODE_MOV:
+      case TGSI_OPCODE_TRUNC:
+        read0 = writemask;
+        break;
+
+      case TGSI_OPCODE_SUB:
+      case TGSI_OPCODE_SLT:
+      case TGSI_OPCODE_SLE:
+      case TGSI_OPCODE_SGE:
+      case TGSI_OPCODE_SGT:
+      case TGSI_OPCODE_SEQ:
+      case TGSI_OPCODE_SNE:
+      case TGSI_OPCODE_ADD:
+      case TGSI_OPCODE_MAX:
+      case TGSI_OPCODE_MIN:
+      case TGSI_OPCODE_MUL:
+        read0 = writemask;
+        read1 = writemask;
+        break;
+
+      case TGSI_OPCODE_DDX:
+      case TGSI_OPCODE_DDY:
+        read0 = writemask;
+        break;
+
+      case TGSI_OPCODE_MAD:    
+      case TGSI_OPCODE_CMP:
+      case TGSI_OPCODE_LRP:
+        read0 = writemask;
+        read1 = writemask;     
+        read2 = writemask;     
+        break;
+
+      case TGSI_OPCODE_XPD: 
+        if (writemask & BRW_WRITEMASK_X) read0 |= BRW_WRITEMASK_YZ;     
+        if (writemask & BRW_WRITEMASK_Y) read0 |= BRW_WRITEMASK_XZ;     
+        if (writemask & BRW_WRITEMASK_Z) read0 |= BRW_WRITEMASK_XY;
+        read1 = read0;
+        break;
+
+      case TGSI_OPCODE_COS:
+      case TGSI_OPCODE_EX2:
+      case TGSI_OPCODE_LG2:
+      case TGSI_OPCODE_RCP:
+      case TGSI_OPCODE_RSQ:
+      case TGSI_OPCODE_SIN:
+      case TGSI_OPCODE_SCS:
+      case WM_CINTERP:
+      case WM_PIXELXY:
+        read0 = BRW_WRITEMASK_X;
+        break;
+
+      case TGSI_OPCODE_POW:
+        read0 = BRW_WRITEMASK_X;
+        read1 = BRW_WRITEMASK_X;
+        break;
+
+      case TGSI_OPCODE_TEX:
+      case TGSI_OPCODE_TXP:
+        read0 = get_texcoord_mask(inst->target);
+        break;
+
+      case TGSI_OPCODE_TXB:
+        read0 = get_texcoord_mask(inst->target) | BRW_WRITEMASK_W;
+        break;
+
+      case WM_WPOSXY:
+        read0 = writemask & BRW_WRITEMASK_XY;
+        break;
+
+      case WM_DELTAXY:
+        read0 = writemask & BRW_WRITEMASK_XY;
+        read1 = BRW_WRITEMASK_X;
+        break;
+
+      case WM_PIXELW:
+        read0 = BRW_WRITEMASK_X;
+        read1 = BRW_WRITEMASK_XY;
+        break;
+
+      case WM_LINTERP:
+        read0 = BRW_WRITEMASK_X;
+        read1 = BRW_WRITEMASK_XY;
+        break;
+
+      case WM_PINTERP:
+        read0 = BRW_WRITEMASK_X; /* interpolant */
+        read1 = BRW_WRITEMASK_XY; /* deltas */
+        read2 = BRW_WRITEMASK_W; /* pixel w */
+        break;
+
+      case TGSI_OPCODE_DP3:    
+        read0 = BRW_WRITEMASK_XYZ;
+        read1 = BRW_WRITEMASK_XYZ;
+        break;
+
+      case TGSI_OPCODE_DPH:
+        read0 = BRW_WRITEMASK_XYZ;
+        read1 = BRW_WRITEMASK_XYZW;
+        break;
+
+      case TGSI_OPCODE_DP4:
+        read0 = BRW_WRITEMASK_XYZW;
+        read1 = BRW_WRITEMASK_XYZW;
+        break;
+
+      case TGSI_OPCODE_LIT: 
+        read0 = BRW_WRITEMASK_XYW;
+        break;
+
+      case TGSI_OPCODE_DST:
+      case WM_FRONTFACING:
+      case TGSI_OPCODE_KILP:
+      default:
+        break;
+      }
+
+      track_arg(c, inst, 0, read0);
+      track_arg(c, inst, 1, read1);
+      track_arg(c, inst, 2, read2);
+   }
+
+   if (BRW_DEBUG & DEBUG_WM) {
+      brw_wm_print_program(c, "pass1");
+   }
+}
diff --git a/src/gallium/drivers/i965/brw_wm_pass2.c b/src/gallium/drivers/i965/brw_wm_pass2.c
new file mode 100644 (file)
index 0000000..19248b4
--- /dev/null
@@ -0,0 +1,334 @@
+/*
+ Copyright (C) Intel Corp.  2006.  All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ **********************************************************************/
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  */
+                   
+
+#include "brw_debug.h"
+#include "brw_wm.h"
+
+
+/* Use these to force spilling so that that functionality can be
+ * tested with known-good examples rather than having to construct new
+ * tests.
+ */
+#define TEST_PAYLOAD_SPILLS 0
+#define TEST_DST_SPILLS 0
+
+static void spill_value(struct brw_wm_compile *c,
+                       struct brw_wm_value *value);
+
+static void prealloc_reg(struct brw_wm_compile *c,
+                        struct brw_wm_value *value,
+                        GLuint reg)
+{
+   if (value->lastuse) {
+      /* Set nextuse to zero, it will be corrected by
+       * update_register_usage().
+       */
+      c->pass2_grf[reg].value = value;
+      c->pass2_grf[reg].nextuse = 0;
+
+      value->resident = &c->pass2_grf[reg];
+      value->hw_reg = brw_vec8_grf(reg*2, 0);
+
+      if (TEST_PAYLOAD_SPILLS)
+        spill_value(c, value);
+   }
+}
+
+
+/* Initialize all the register values.  Do the initial setup
+ * calculations for interpolants.
+ */
+static void init_registers( struct brw_wm_compile *c )
+{
+   GLuint reg = 0;
+   GLuint j;
+
+   for (j = 0; j < c->grf_limit; j++) 
+      c->pass2_grf[j].nextuse = BRW_WM_MAX_INSN;
+
+   /* Pre-allocate incoming payload regs:
+    */
+   for (j = 0; j < c->key.nr_depth_regs; j++) 
+      prealloc_reg(c, &c->payload.depth[j], reg++);
+
+   for (j = 0; j < c->nr_creg; j++) 
+      prealloc_reg(c, &c->creg[j], reg++);
+
+   reg++;                       /* XXX: skip over position output */
+
+   /* XXX: currently just hope the VS outputs line up with FS inputs:
+    */
+   for (j = 0; j < c->key.nr_inputs; j++)
+      prealloc_reg(c, &c->payload.input_interp[j], reg++);
+
+   c->prog_data.first_curbe_grf = c->key.nr_depth_regs * 2;
+   c->prog_data.urb_read_length = (c->key.nr_inputs + 1) * 2;
+   c->prog_data.curb_read_length = c->nr_creg * 2;
+
+   /* Note this allocation:
+    */
+   c->max_wm_grf = reg * 2;
+}
+
+
+/* Update the nextuse value for each register in our file.
+ */
+static void update_register_usage(struct brw_wm_compile *c,
+                                 GLuint thisinsn)
+{
+   GLuint i;
+
+   for (i = 1; i < c->grf_limit; i++) {
+      struct brw_wm_grf *grf = &c->pass2_grf[i];
+
+      /* Only search those which can change:
+       */
+      if (grf->nextuse < thisinsn) {
+        const struct brw_wm_ref *ref = grf->value->lastuse;
+
+        /* Has last use of value been passed?
+         */
+        if (ref->insn < thisinsn) {
+           grf->value->resident = 0;
+           grf->value = 0;
+           grf->nextuse = BRW_WM_MAX_INSN;
+        }
+        else {
+           /* Else loop through chain to update:
+            */
+           while (ref->prevuse && ref->prevuse->insn >= thisinsn)
+              ref = ref->prevuse;
+
+           grf->nextuse = ref->insn;
+        }
+      }
+   }
+}
+
+
+static void spill_value(struct brw_wm_compile *c,
+                       struct brw_wm_value *value)
+{      
+   /* Allocate a spill slot.  Note that allocations start from 0x40 -
+    * the first slot is reserved to mean "undef" in brw_wm_emit.c
+    */
+   if (!value->spill_slot) {
+      c->last_scratch += 0x40; 
+      value->spill_slot = c->last_scratch;
+   }
+
+   /* The spill will be done in brw_wm_emit.c immediately after the
+    * value is calculated, so we can just take this reg without any
+    * further work.
+    */
+   value->resident->value = NULL;
+   value->resident->nextuse = BRW_WM_MAX_INSN;
+   value->resident = NULL;
+}
+
+
+
+/* Search for contiguous region with the most distant nearest
+ * member.  Free regs count as very distant.
+ *
+ * TODO: implement spill-to-reg so that we can rearrange discontigous
+ * free regs and then spill the oldest non-free regs in sequence.
+ * This would mean inserting instructions in this pass.
+ */
+static GLuint search_contiguous_regs(struct brw_wm_compile *c,
+                                    GLuint nr,
+                                    GLuint thisinsn)
+{
+   struct brw_wm_grf *grf = c->pass2_grf;
+   GLuint furthest = 0;
+   GLuint reg = 0;
+   GLuint i, j;
+
+   /* Start search at 1: r0 is special and can't be used or spilled.
+    */
+   for (i = 1; i < c->grf_limit && furthest < BRW_WM_MAX_INSN; i++) {
+      GLuint group_nextuse = BRW_WM_MAX_INSN;
+
+      for (j = 0; j < nr; j++) {
+        if (grf[i+j].nextuse < group_nextuse)
+           group_nextuse = grf[i+j].nextuse;
+      }
+
+      if (group_nextuse > furthest) {
+        furthest = group_nextuse;
+        reg = i;
+      }
+   }
+
+   assert(furthest != thisinsn);
+
+   /* Any non-empty regs will need to be spilled:
+    */
+   for (j = 0; j < nr; j++) 
+      if (grf[reg+j].value)
+        spill_value(c, grf[reg+j].value);
+
+   return reg;
+}
+
+
+static void alloc_contiguous_dest(struct brw_wm_compile *c, 
+                                 struct brw_wm_value *dst[],
+                                 GLuint nr,
+                                 GLuint thisinsn)
+{
+   GLuint reg = search_contiguous_regs(c, nr, thisinsn);
+   GLuint i;
+
+   for (i = 0; i < nr; i++) {
+      if (!dst[i]) {
+        /* Need to grab a dummy value in TEX case.  Don't introduce
+         * it into the tracking scheme.
+         */
+        dst[i] = &c->vreg[c->nr_vreg++];
+      }
+      else {
+        assert(!dst[i]->resident);
+        assert(c->pass2_grf[reg+i].nextuse != thisinsn);
+
+        c->pass2_grf[reg+i].value = dst[i];
+        c->pass2_grf[reg+i].nextuse = thisinsn;
+
+        dst[i]->resident = &c->pass2_grf[reg+i];
+      }
+
+      dst[i]->hw_reg = brw_vec8_grf((reg+i)*2, 0);
+   }
+
+   if ((reg+nr)*2 > c->max_wm_grf)
+      c->max_wm_grf = (reg+nr) * 2;
+}
+
+
+static void load_args(struct brw_wm_compile *c, 
+                     struct brw_wm_instruction *inst)
+{
+   GLuint thisinsn = inst - c->instruction;
+   GLuint i,j;
+
+   for (i = 0; i < 3; i++) {
+      for (j = 0; j < 4; j++) {
+        struct brw_wm_ref *ref = inst->src[i][j];
+
+        if (ref) {
+           if (!ref->value->resident) {
+              /* Need to bring the value in from scratch space.  The code for
+               * this will be done in brw_wm_emit.c, here we just do the
+               * register allocation and mark the ref as requiring a fill.
+               */
+              GLuint reg = search_contiguous_regs(c, 1, thisinsn);
+
+              c->pass2_grf[reg].value = ref->value;
+              c->pass2_grf[reg].nextuse = thisinsn;
+
+              ref->value->resident = &c->pass2_grf[reg];
+
+              /* Note that a fill is required:
+               */
+              ref->unspill_reg = reg*2;
+           }
+
+           /* Adjust the hw_reg to point at the value's current location:
+            */
+           assert(ref->value == ref->value->resident->value);
+           ref->hw_reg.nr += (ref->value->resident - c->pass2_grf) * 2;
+        }
+      }
+   }
+}
+
+
+
+/* Step 3: Work forwards once again.  Perform register allocations,
+ * taking into account instructions like TEX which require contiguous
+ * result registers.  Where necessary spill registers to scratch space
+ * and reload later.
+ */
+void brw_wm_pass2( struct brw_wm_compile *c )
+{
+   GLuint insn;
+   GLuint i;
+
+   init_registers(c);
+
+   for (insn = 0; insn < c->nr_insns; insn++) {
+      struct brw_wm_instruction *inst = &c->instruction[insn];
+
+      /* Update registers' nextuse values:
+       */
+      update_register_usage(c, insn);
+
+      /* May need to unspill some args.
+       */
+      load_args(c, inst);
+
+      /* Allocate registers to hold results:
+       */
+      switch (inst->opcode) {
+      case TGSI_OPCODE_TEX:
+      case TGSI_OPCODE_TXB:
+      case TGSI_OPCODE_TXP:
+        alloc_contiguous_dest(c, inst->dst, 4, insn);
+        break;
+
+      default:
+        for (i = 0; i < 4; i++) {
+           if (inst->writemask & (1<<i)) {
+              assert(inst->dst[i]);
+              alloc_contiguous_dest(c, &inst->dst[i], 1, insn);
+           }
+        }
+        break;
+      }
+
+      if (TEST_DST_SPILLS && inst->opcode != WM_PIXELXY) {
+        for (i = 0; i < 4; i++)        
+           if (inst->dst[i])
+              spill_value(c, inst->dst[i]);
+      }
+   }
+
+   if (BRW_DEBUG & DEBUG_WM) {
+      brw_wm_print_program(c, "pass2");
+   }
+
+   c->state = PASS2_DONE;
+
+   if (BRW_DEBUG & DEBUG_WM) {
+       brw_wm_print_program(c, "pass2/done");
+   }
+}
diff --git a/src/gallium/drivers/i965/brw_wm_sampler_state.c b/src/gallium/drivers/i965/brw_wm_sampler_state.c
new file mode 100644 (file)
index 0000000..a8bc31c
--- /dev/null
@@ -0,0 +1,229 @@
+/*
+ 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 "util/u_math.h"
+#include "util/u_format.h"
+
+#include "brw_context.h"
+#include "brw_state.h"
+#include "brw_defines.h"
+#include "brw_screen.h"
+
+
+/* Samplers aren't strictly wm state from the hardware's perspective,
+ * but that is the only situation in which we use them in this driver.
+ */
+
+
+
+static enum pipe_error
+upload_default_color( struct brw_context *brw,
+                     const GLfloat *color,
+                      struct brw_winsys_buffer **bo_out )
+{
+   struct brw_sampler_default_color sdc;
+   enum pipe_error ret;
+
+   COPY_4V(sdc.color, color); 
+   
+   ret = brw_cache_data( &brw->cache, BRW_SAMPLER_DEFAULT_COLOR, &sdc,
+                         NULL, 0, bo_out );
+   if (ret)
+      return ret;
+
+   return PIPE_OK;
+}
+
+
+struct wm_sampler_key {
+   int sampler_count;
+   struct brw_sampler_state sampler[BRW_MAX_TEX_UNIT];
+};
+
+
+/** Sets up the cache key for sampler state for all texture units */
+static void
+brw_wm_sampler_populate_key(struct brw_context *brw,
+                           struct wm_sampler_key *key)
+{
+   int i;
+
+   memset(key, 0, sizeof(*key));
+
+   key->sampler_count = MIN2(brw->curr.num_textures,
+                           brw->curr.num_samplers);
+
+   for (i = 0; i < key->sampler_count; i++) {
+      const struct brw_texture *tex = brw_texture(brw->curr.texture[i]);
+      const struct brw_sampler *sampler = brw->curr.sampler[i];
+      struct brw_sampler_state *entry = &key->sampler[i];
+
+      entry->ss0 = sampler->ss0;
+      entry->ss1 = sampler->ss1;
+      entry->ss2.default_color_pointer = 0; /* reloc */
+      entry->ss3 = sampler->ss3;
+
+      /* Cube-maps on 965 and later must use the same wrap mode for all 3
+       * coordinate dimensions.  Futher, only CUBE and CLAMP are valid.
+       */
+      if (tex->base.target == PIPE_TEXTURE_CUBE) {
+        if (FALSE &&
+            (sampler->ss0.min_filter != BRW_MAPFILTER_NEAREST || 
+             sampler->ss0.mag_filter != BRW_MAPFILTER_NEAREST)) {
+           entry->ss1.r_wrap_mode = BRW_TEXCOORDMODE_CUBE;
+           entry->ss1.s_wrap_mode = BRW_TEXCOORDMODE_CUBE;
+           entry->ss1.t_wrap_mode = BRW_TEXCOORDMODE_CUBE;
+        } else {
+           entry->ss1.r_wrap_mode = BRW_TEXCOORDMODE_CLAMP;
+           entry->ss1.s_wrap_mode = BRW_TEXCOORDMODE_CLAMP;
+           entry->ss1.t_wrap_mode = BRW_TEXCOORDMODE_CLAMP;
+        }
+      } else if (tex->base.target == PIPE_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.
+         */
+        entry->ss1.t_wrap_mode = BRW_TEXCOORDMODE_WRAP;
+      }
+   }
+}
+
+
+static enum pipe_error
+brw_wm_sampler_update_default_colors(struct brw_context *brw)
+{
+   enum pipe_error ret;
+   int nr = MIN2(brw->curr.num_textures,
+                brw->curr.num_samplers);
+   int i;
+
+   for (i = 0; i < nr; i++) {
+      const struct brw_texture *tex = brw_texture(brw->curr.texture[i]);
+      const struct brw_sampler *sampler = brw->curr.sampler[i];
+      const float *bc;
+
+      if (util_format_is_depth_or_stencil(tex->base.format)) {
+        float bordercolor[4] = {
+           sampler->border_color[0],
+           sampler->border_color[0],
+           sampler->border_color[0],
+           sampler->border_color[0]
+        };
+         
+         bc = bordercolor;
+      }
+      else {
+         bc = sampler->border_color;
+      }
+
+      /* GL specs that border color for depth textures is taken from the
+       * R channel, while the hardware uses A.  Spam R into all the
+       * channels for safety.
+       */
+      ret = upload_default_color(brw, 
+                                 bc,
+                                 &brw->wm.sdc_bo[i]);
+      if (ret) 
+         return ret;
+   }
+
+   return PIPE_OK;
+}
+
+
+
+/* All samplers must be uploaded in a single contiguous array.  
+ */
+static int upload_wm_samplers( struct brw_context *brw )
+{
+   struct wm_sampler_key key;
+   struct brw_winsys_reloc reloc[BRW_MAX_TEX_UNIT];
+   enum pipe_error ret;
+   int i;
+
+   brw_wm_sampler_update_default_colors(brw);
+   brw_wm_sampler_populate_key(brw, &key);
+
+   if (brw->wm.sampler_count != key.sampler_count) {
+      brw->wm.sampler_count = key.sampler_count;
+      brw->state.dirty.cache |= CACHE_NEW_SAMPLER;
+   }
+
+   if (brw->wm.sampler_count == 0) {
+      bo_reference(&brw->wm.sampler_bo, NULL);
+      return PIPE_OK;
+   }
+
+   /* Emit SDC relocations */
+   for (i = 0; i < key.sampler_count; i++) {
+      make_reloc( &reloc[i],
+                  BRW_USAGE_SAMPLER,
+                  0,
+                  i * sizeof(struct brw_sampler_state) +
+                  offsetof(struct brw_sampler_state, ss2),
+                  brw->wm.sdc_bo[i]);
+   }
+
+
+   if (brw_search_cache(&brw->cache, BRW_SAMPLER,
+                        &key, sizeof(key),
+                        reloc, key.sampler_count,
+                        NULL,
+                        &brw->wm.sampler_bo))
+      return PIPE_OK;
+
+   /* If we didnt find it in the cache, compute the state and put it in the
+    * cache.
+    */
+   ret = brw_upload_cache(&brw->cache, BRW_SAMPLER,
+                          &key, sizeof(key),
+                          reloc, key.sampler_count,
+                          &key.sampler, sizeof(key.sampler),
+                          NULL, NULL,
+                          &brw->wm.sampler_bo);
+   if (ret)
+      return ret;
+
+
+   return 0;
+}
+
+const struct brw_tracked_state brw_wm_samplers = {
+   .dirty = {
+      .mesa = PIPE_NEW_BOUND_TEXTURES | PIPE_NEW_SAMPLERS,
+      .brw = 0,
+      .cache = 0
+   },
+   .prepare = upload_wm_samplers,
+};
+
+
diff --git a/src/gallium/drivers/i965/brw_wm_state.c b/src/gallium/drivers/i965/brw_wm_state.c
new file mode 100644 (file)
index 0000000..ee970ac
--- /dev/null
@@ -0,0 +1,339 @@
+/*
+ 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 "util/u_math.h"
+
+#include "brw_context.h"
+#include "brw_state.h"
+#include "brw_defines.h"
+#include "brw_wm.h"
+#include "brw_debug.h"
+#include "brw_pipe_rast.h"
+
+/***********************************************************************
+ * WM unit - fragment programs and rasterization
+ */
+
+struct brw_wm_unit_key {
+   unsigned int total_grf, total_scratch;
+   unsigned int urb_entry_read_length;
+   unsigned int curb_entry_read_length;
+   unsigned int dispatch_grf_start_reg;
+
+   unsigned int curbe_offset;
+   unsigned int urb_size;
+
+   unsigned int max_threads;
+
+   unsigned int nr_surfaces, sampler_count;
+   GLboolean uses_depth, computes_depth, uses_kill, has_flow_control;
+   GLboolean polygon_stipple, stats_wm, line_stipple, offset_enable;
+   GLfloat offset_units, offset_factor;
+};
+
+static void
+wm_unit_populate_key(struct brw_context *brw, struct brw_wm_unit_key *key)
+{
+   const struct brw_fragment_shader *fp = brw->curr.fragment_shader;
+
+   memset(key, 0, sizeof(*key));
+
+   if (BRW_DEBUG & DEBUG_SINGLE_THREAD)
+      key->max_threads = 1;
+   else {
+      /* WM maximum threads is number of EUs times number of threads per EU. */
+      if (BRW_IS_IGDNG(brw))
+         key->max_threads = 12 * 6;
+      else if (BRW_IS_G4X(brw))
+        key->max_threads = 10 * 5;
+      else
+        key->max_threads = 8 * 4;
+   }
+
+   /* CACHE_NEW_WM_PROG */
+   key->total_grf = brw->wm.prog_data->total_grf;
+   key->urb_entry_read_length = brw->wm.prog_data->urb_read_length;
+   key->curb_entry_read_length = brw->wm.prog_data->curb_read_length;
+   key->dispatch_grf_start_reg = brw->wm.prog_data->first_curbe_grf;
+   key->total_scratch = align(brw->wm.prog_data->total_scratch, 1024);
+
+   /* BRW_NEW_URB_FENCE */
+   key->urb_size = brw->urb.vsize;
+
+   /* BRW_NEW_CURBE_OFFSETS */
+   key->curbe_offset = brw->curbe.wm_start;
+
+   /* BRW_NEW_NR_SURFACEs */
+   key->nr_surfaces = brw->wm.nr_surfaces;
+
+   /* CACHE_NEW_SAMPLER */
+   key->sampler_count = brw->wm.sampler_count;
+
+   /* PIPE_NEW_RAST */
+   key->polygon_stipple = brw->curr.rast->templ.poly_stipple_enable;
+
+   /* PIPE_NEW_FRAGMENT_PROGRAM */
+   key->uses_depth = fp->uses_depth;
+   key->computes_depth = fp->info.writes_z;
+
+   /* PIPE_NEW_DEPTH_BUFFER
+    *
+    * Override for NULL depthbuffer case, required by the Pixel Shader Computed
+    * Depth field.
+    */
+   if (brw->curr.fb.zsbuf == NULL)
+      key->computes_depth = 0;
+
+   /* PIPE_NEW_DEPTH_STENCIL_ALPHA */
+   key->uses_kill = (fp->info.uses_kill || 
+                    brw->curr.zstencil->cc3.alpha_test);
+
+   key->has_flow_control = fp->has_flow_control;
+
+   /* temporary sanity check assertion */
+   assert(fp->has_flow_control == 0);
+
+   /* PIPE_NEW_QUERY */
+   key->stats_wm = (brw->query.stats_wm != 0);
+
+   /* PIPE_NEW_RAST */
+   key->line_stipple = brw->curr.rast->templ.line_stipple_enable;
+
+
+   key->offset_enable = (brw->curr.rast->templ.offset_cw ||
+                        brw->curr.rast->templ.offset_ccw);
+
+   key->offset_units = brw->curr.rast->templ.offset_units;
+   key->offset_factor = brw->curr.rast->templ.offset_scale;
+}
+
+/**
+ * Setup wm hardware state.  See page 225 of Volume 2
+ */
+static enum pipe_error
+wm_unit_create_from_key(struct brw_context *brw, struct brw_wm_unit_key *key,
+                       struct brw_winsys_reloc *reloc,
+                        unsigned nr_reloc,
+                        struct brw_winsys_buffer **bo_out)
+{
+   struct brw_wm_unit_state wm;
+   enum pipe_error ret;
+
+   memset(&wm, 0, sizeof(wm));
+
+   wm.thread0.grf_reg_count = align(key->total_grf, 16) / 16 - 1;
+   wm.thread0.kernel_start_pointer = 0; /* reloc */
+   wm.thread1.depth_coef_urb_read_offset = 1;
+   wm.thread1.floating_point_mode = BRW_FLOATING_POINT_NON_IEEE_754;
+
+   if (BRW_IS_IGDNG(brw))
+      wm.thread1.binding_table_entry_count = 0; /* hardware requirement */
+   else
+      wm.thread1.binding_table_entry_count = key->nr_surfaces;
+
+   if (key->total_scratch != 0) {
+      wm.thread2.scratch_space_base_pointer = 0; /* reloc */
+      wm.thread2.per_thread_scratch_space = key->total_scratch / 1024 - 1;
+   } else {
+      wm.thread2.scratch_space_base_pointer = 0;
+      wm.thread2.per_thread_scratch_space = 0;
+   }
+
+   wm.thread3.dispatch_grf_start_reg = key->dispatch_grf_start_reg;
+   wm.thread3.urb_entry_read_length = key->urb_entry_read_length;
+   wm.thread3.urb_entry_read_offset = 0;
+   wm.thread3.const_urb_entry_read_length = key->curb_entry_read_length;
+   wm.thread3.const_urb_entry_read_offset = key->curbe_offset * 2;
+
+   if (BRW_IS_IGDNG(brw)) 
+      wm.wm4.sampler_count = 0; /* hardware requirement */
+   else
+      wm.wm4.sampler_count = (key->sampler_count + 1) / 4;
+
+   /* reloc */
+   wm.wm4.sampler_state_pointer = 0;
+
+   wm.wm5.program_uses_depth = key->uses_depth;
+   wm.wm5.program_computes_depth = key->computes_depth;
+   wm.wm5.program_uses_killpixel = key->uses_kill;
+
+   if (key->has_flow_control)
+      wm.wm5.enable_8_pix = 1;
+   else
+      wm.wm5.enable_16_pix = 1;
+
+   wm.wm5.max_threads = key->max_threads - 1;
+   wm.wm5.thread_dispatch_enable = 1;  /* AKA: color_write */
+   wm.wm5.legacy_line_rast = 0;
+   wm.wm5.legacy_global_depth_bias = 0;
+   wm.wm5.early_depth_test = 1;                /* never need to disable */
+   wm.wm5.line_aa_region_width = 0;
+   wm.wm5.line_endcap_aa_region_width = 1;
+
+   wm.wm5.polygon_stipple = key->polygon_stipple;
+
+   if (key->offset_enable) {
+      wm.wm5.depth_offset = 1;
+      /* Something wierd going on with legacy_global_depth_bias,
+       * offset_constant, scaling and MRD.  This value passes glean
+       * but gives some odd results elsewere (eg. the
+       * quad-offset-units test).
+       */
+      wm.global_depth_offset_constant = key->offset_units * 2;
+
+      /* This is the only value that passes glean:
+       */
+      wm.global_depth_offset_scale = key->offset_factor;
+   }
+
+   wm.wm5.line_stipple = key->line_stipple;
+
+   if ((BRW_DEBUG & DEBUG_STATS) || key->stats_wm)
+      wm.wm4.stats_enable = 1;
+
+   ret = brw_upload_cache(&brw->cache, BRW_WM_UNIT,
+                          key, sizeof(*key),
+                          reloc, nr_reloc,
+                          &wm, sizeof(wm),
+                          NULL, NULL,
+                          bo_out);
+   if (ret)
+      return ret;
+
+   return PIPE_OK;
+}
+
+
+static enum pipe_error upload_wm_unit( struct brw_context *brw )
+{
+   struct brw_wm_unit_key key;
+   struct brw_winsys_reloc reloc[3];
+   unsigned nr_reloc = 0;
+   enum pipe_error ret;
+   unsigned grf_reg_count;
+   unsigned per_thread_scratch_space;
+   unsigned stats_enable;
+   unsigned sampler_count;
+
+   wm_unit_populate_key(brw, &key);
+
+
+   /* Allocate the necessary scratch space if we haven't already.  Don't
+    * bother reducing the allocation later, since we use scratch so
+    * rarely.
+    */
+   assert(key.total_scratch <= 12 * 1024);
+   if (key.total_scratch) {
+      GLuint total = key.total_scratch * key.max_threads;
+
+      /* Do we need a new buffer:
+       */
+      if (brw->wm.scratch_bo && total > brw->wm.scratch_bo->size) 
+        bo_reference(&brw->wm.scratch_bo, NULL);
+
+      if (brw->wm.scratch_bo == NULL) {
+        ret = brw->sws->bo_alloc(brw->sws,
+                                  BRW_BUFFER_TYPE_SHADER_SCRATCH,
+                                  total,
+                                  4096,
+                                  &brw->wm.scratch_bo);
+         if (ret)
+            return ret;
+      }
+   }
+
+
+   /* XXX: temporary:
+    */
+   grf_reg_count = (align(key.total_grf, 16) / 16 - 1);
+   per_thread_scratch_space = key.total_scratch / 1024 - 1;
+   stats_enable = (BRW_DEBUG & DEBUG_STATS) || key.stats_wm;
+   sampler_count = BRW_IS_IGDNG(brw) ? 0 :(key.sampler_count + 1) / 4;
+
+   /* Emit WM program relocation */
+   make_reloc(&reloc[nr_reloc++],
+              BRW_USAGE_STATE,
+              grf_reg_count << 1,
+              offsetof(struct brw_wm_unit_state, thread0),
+              brw->wm.prog_bo);
+
+   /* Emit scratch space relocation */
+   if (key.total_scratch != 0) {
+      make_reloc(&reloc[nr_reloc++],
+                 BRW_USAGE_SCRATCH,
+                 per_thread_scratch_space,
+                 offsetof(struct brw_wm_unit_state, thread2),
+                 brw->wm.scratch_bo);
+   }
+
+   /* Emit sampler state relocation */
+   if (key.sampler_count != 0) {
+      make_reloc(&reloc[nr_reloc++],
+                 BRW_USAGE_STATE,
+                 stats_enable | (sampler_count << 2),
+                 offsetof(struct brw_wm_unit_state, wm4),
+                 brw->wm.sampler_bo);
+   }
+
+
+   if (brw_search_cache(&brw->cache, BRW_WM_UNIT,
+                        &key, sizeof(key),
+                        reloc, nr_reloc,
+                        NULL,
+                        &brw->wm.state_bo))
+      return PIPE_OK;
+
+   ret = wm_unit_create_from_key(brw, &key, 
+                                 reloc, nr_reloc,
+                                 &brw->wm.state_bo);
+   if (ret)
+      return ret;
+
+   return PIPE_OK;
+}
+
+const struct brw_tracked_state brw_wm_unit = {
+   .dirty = {
+      .mesa = (PIPE_NEW_FRAGMENT_SHADER |
+              PIPE_NEW_DEPTH_BUFFER |
+              PIPE_NEW_RAST | 
+              PIPE_NEW_DEPTH_STENCIL_ALPHA |
+              PIPE_NEW_QUERY),
+
+      .brw = (BRW_NEW_CURBE_OFFSETS |
+             BRW_NEW_NR_WM_SURFACES),
+
+      .cache = (CACHE_NEW_WM_PROG |
+               CACHE_NEW_SAMPLER)
+   },
+   .prepare = upload_wm_unit,
+};
+
diff --git a/src/gallium/drivers/i965/brw_wm_surface_state.c b/src/gallium/drivers/i965/brw_wm_surface_state.c
new file mode 100644 (file)
index 0000000..f92b819
--- /dev/null
@@ -0,0 +1,294 @@
+/*
+ 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 "pipe/p_format.h"
+
+#include "brw_batchbuffer.h"
+#include "brw_context.h"
+#include "brw_state.h"
+#include "brw_defines.h"
+#include "brw_screen.h"
+
+
+
+
+static enum pipe_error
+brw_update_texture_surface( struct brw_context *brw,
+                           struct brw_texture *tex,
+                            struct brw_winsys_buffer **bo_out)
+{
+   struct brw_winsys_reloc reloc[1];
+   enum pipe_error ret;
+
+   /* Emit relocation to surface contents */
+   make_reloc(&reloc[0],
+              BRW_USAGE_SAMPLER,
+              0,
+              offsetof(struct brw_surface_state, ss1),
+              tex->bo);
+
+   if (brw_search_cache(&brw->surface_cache,
+                        BRW_SS_SURFACE,
+                        &tex->ss, sizeof tex->ss,
+                        reloc, Elements(reloc),
+                        NULL,
+                        bo_out))
+      return PIPE_OK;
+
+   ret = brw_upload_cache(&brw->surface_cache, BRW_SS_SURFACE,
+                          &tex->ss, sizeof tex->ss,
+                          reloc, Elements(reloc),
+                          &tex->ss, sizeof tex->ss,
+                          NULL, NULL,
+                          bo_out);
+   if (ret)
+      return ret;
+
+   return PIPE_OK;
+}
+
+
+
+
+
+
+
+
+/**
+ * Sets up a surface state structure to point at the given region.
+ * While it is only used for the front/back buffer currently, it should be
+ * usable for further buffers when doing ARB_draw_buffer support.
+ */
+static enum pipe_error
+brw_update_render_surface(struct brw_context *brw,
+                          struct brw_surface *surface,
+                          struct brw_winsys_buffer **bo_out)
+{
+   struct brw_surf_ss0 blend_ss0 = brw->curr.blend->ss0;
+   struct brw_surface_state ss;
+   struct brw_winsys_reloc reloc[1];
+   enum pipe_error ret;
+
+   /* XXX: we will only be rendering to this surface:
+    */
+   make_reloc(&reloc[0],
+              BRW_USAGE_RENDER_TARGET,
+              0,
+              offsetof(struct brw_surface_state, ss1),
+              surface->bo);
+
+   /* Surfaces are potentially shared between contexts, so can't
+    * scribble the in-place ss0 value in the surface.
+    */
+   memcpy(&ss, &surface->ss, sizeof ss);
+
+   ss.ss0.color_blend        = blend_ss0.color_blend;
+   ss.ss0.writedisable_blue  = blend_ss0.writedisable_blue;
+   ss.ss0.writedisable_green = blend_ss0.writedisable_green;
+   ss.ss0.writedisable_red   = blend_ss0.writedisable_red;
+   ss.ss0.writedisable_alpha = blend_ss0.writedisable_alpha;
+
+   if (brw_search_cache(&brw->surface_cache,
+                        BRW_SS_SURFACE,
+                        &ss, sizeof(ss),
+                        reloc, Elements(reloc),
+                        NULL,
+                        bo_out))
+      return PIPE_OK;
+       
+   ret = brw_upload_cache(&brw->surface_cache,
+                          BRW_SS_SURFACE,
+                          &ss, sizeof ss,
+                          reloc, Elements(reloc),
+                          &ss, sizeof ss,
+                          NULL, NULL,
+                          bo_out);
+   if (ret)
+      return ret;
+
+   return PIPE_OK;
+}
+
+
+/**
+ * Constructs the binding table for the WM surface state, which maps unit
+ * numbers to surface state objects.
+ */
+static enum pipe_error
+brw_wm_get_binding_table(struct brw_context *brw,
+                         struct brw_winsys_buffer **bo_out )
+{
+   enum pipe_error ret;
+   struct brw_winsys_reloc reloc[BRW_WM_MAX_SURF];
+   uint32_t data[BRW_WM_MAX_SURF];
+   GLuint nr_relocs = 0;
+   GLuint data_size = brw->wm.nr_surfaces * sizeof data[0];
+   int i;
+
+   assert(brw->wm.nr_surfaces <= BRW_WM_MAX_SURF);
+   assert(brw->wm.nr_surfaces > 0);
+
+   /* Emit binding table relocations to surface state 
+    */
+   for (i = 0; i < brw->wm.nr_surfaces; i++) {
+      if (brw->wm.surf_bo[i]) {
+         make_reloc(&reloc[nr_relocs++],
+                    BRW_USAGE_STATE,
+                    0,
+                    i * sizeof(GLuint),
+                    brw->wm.surf_bo[i]);
+      }
+   }
+
+   /* Note there is no key for this search beyond the values in the
+    * relocation array:
+    */
+   if (brw_search_cache(&brw->surface_cache, BRW_SS_SURF_BIND,
+                        NULL, 0,
+                        reloc, nr_relocs,
+                        NULL,
+                        bo_out))
+      return PIPE_OK;
+
+   /* Upload zero data, will all be overwitten with relocation
+    * offsets:
+    */
+   for (i = 0; i < brw->wm.nr_surfaces; i++)
+      data[i] = 0;
+
+   ret = brw_upload_cache( &brw->surface_cache, BRW_SS_SURF_BIND,
+                           NULL, 0,
+                           reloc, nr_relocs,
+                           data, data_size,
+                           NULL, NULL,
+                           bo_out);
+   if (ret)
+      return ret;
+
+   return PIPE_OK;
+}
+
+static enum pipe_error prepare_wm_surfaces(struct brw_context *brw )
+{
+   enum pipe_error ret;
+   int nr_surfaces = 0;
+   GLuint i;
+
+   /* PIPE_NEW_COLOR_BUFFERS | PIPE_NEW_BLEND
+    *
+    * Update surfaces for drawing buffers.  Mixes in colormask and
+    * blend state.
+    *
+    * XXX: no color buffer case
+    */
+   for (i = 0; i < brw->curr.fb.nr_cbufs; i++) {
+      ret = brw_update_render_surface(brw, 
+                                      brw_surface(brw->curr.fb.cbufs[i]), 
+                                      &brw->wm.surf_bo[BTI_COLOR_BUF(i)]);
+      if (ret)
+         return ret;
+      
+      nr_surfaces = BTI_COLOR_BUF(i) + 1;
+   }
+
+
+
+   /* PIPE_NEW_FRAGMENT_CONSTANTS
+    */
+#if 0
+   if (brw->curr.fragment_constants) {
+      ret = brw_update_fragment_constant_surface(
+         brw, 
+         brw->curr.fragment_constants, 
+         &brw->wm.surf_bo[BTI_FRAGMENT_CONSTANTS]);
+
+      if (ret)
+         return ret;
+
+      nr_surfaces = BTI_FRAGMENT_CONSTANTS + 1;
+   }
+   else {
+      bo_reference(&brw->wm.surf_bo[SURF_FRAG_CONSTANTS], NULL);      
+   }
+#endif
+
+
+   /* PIPE_NEW_TEXTURE 
+    */
+   for (i = 0; i < brw->curr.num_textures; i++) {
+      ret = brw_update_texture_surface(brw, 
+                                       brw_texture(brw->curr.texture[i]),
+                                       &brw->wm.surf_bo[BTI_TEXTURE(i)]);
+      if (ret)
+         return ret;
+
+      nr_surfaces = BTI_TEXTURE(i) + 1;
+   }
+
+   /* Clear any inactive entries:
+    */
+   for (i = brw->curr.fb.nr_cbufs; i < BRW_MAX_DRAW_BUFFERS; i++) 
+      bo_reference(&brw->wm.surf_bo[BTI_COLOR_BUF(i)], NULL);
+
+   if (!brw->curr.fragment_constants)
+      bo_reference(&brw->wm.surf_bo[BTI_FRAGMENT_CONSTANTS], NULL);      
+
+   /* XXX: no pipe_max_textures define?? */
+   for (i = brw->curr.num_textures; i < PIPE_MAX_SAMPLERS; i++)
+      bo_reference(&brw->wm.surf_bo[BTI_TEXTURE(i)], NULL);
+
+   if (brw->wm.nr_surfaces != nr_surfaces) {
+      brw->wm.nr_surfaces = nr_surfaces;
+      brw->state.dirty.brw |= BRW_NEW_NR_WM_SURFACES;
+   }
+
+   ret = brw_wm_get_binding_table(brw, &brw->wm.bind_bo);
+   if (ret)
+      return ret;
+
+   return PIPE_OK;
+}
+
+const struct brw_tracked_state brw_wm_surfaces = {
+   .dirty = {
+      .mesa = (PIPE_NEW_COLOR_BUFFERS |
+               PIPE_NEW_BOUND_TEXTURES |
+               PIPE_NEW_FRAGMENT_CONSTANTS |
+              PIPE_NEW_BLEND),
+      .brw = (BRW_NEW_CONTEXT |
+             BRW_NEW_WM_SURFACES),
+      .cache = 0
+   },
+   .prepare = prepare_wm_surfaces,
+};
+
+
+
diff --git a/src/gallium/drivers/i965/intel_decode.c b/src/gallium/drivers/i965/intel_decode.c
new file mode 100644 (file)
index 0000000..3166958
--- /dev/null
@@ -0,0 +1,1790 @@
+/* -*- c-basic-offset: 4 -*- */
+/*
+ * Copyright © 2007 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ *    Eric Anholt <eric@anholt.net>
+ *
+ */
+
+/** @file intel_decode.c
+ * This file contains code to print out batchbuffer contents in a
+ * human-readable format.
+ *
+ * The current version only supports i915 packets, and only pretty-prints a
+ * subset of them.  The intention is for it to make just a best attempt to
+ * decode, but never crash in the process.
+ */
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include "intel_decode.h"
+
+/*#include "intel_chipset.h"*/
+#define IS_965(x) 1             /* XXX */
+#define IS_9XX(x) 1             /* XXX */
+
+#define BUFFER_FAIL(_count, _len, _name) do {                  \
+    fprintf(out, "Buffer size too small in %s (%d < %d)\n",    \
+           (_name), (_count), (_len));                         \
+    (*failures)++;                                             \
+    return count;                                              \
+} while (0)
+
+static FILE *out;
+static uint32_t saved_s2 = 0, saved_s4 = 0;
+static char saved_s2_set = 0, saved_s4_set = 0;
+
+static float
+int_as_float(uint32_t intval)
+{
+    union intfloat {
+       uint32_t i;
+       float f;
+    } uval;
+
+    uval.i = intval;
+    return uval.f;
+}
+
+static void
+instr_out(const uint32_t *data, uint32_t hw_offset, unsigned int index,
+         char *fmt, ...)
+{
+    va_list va;
+
+    fprintf(out, "0x%08x: 0x%08x:%s ", hw_offset + index * 4, data[index],
+           index == 0 ? "" : "  ");
+    va_start(va, fmt);
+    vfprintf(out, fmt, va);
+    va_end(va);
+}
+
+
+static int
+decode_mi(const uint32_t *data, int count, uint32_t hw_offset, int *failures)
+{
+    unsigned int opcode;
+
+    struct {
+       uint32_t opcode;
+       int len_mask;
+       int min_len;
+       int max_len;
+       char *name;
+    } opcodes_mi[] = {
+       { 0x08, 0, 1, 1, "MI_ARB_ON_OFF" },
+       { 0x0a, 0, 1, 1, "MI_BATCH_BUFFER_END" },
+       { 0x31, 0x3f, 2, 2, "MI_BATCH_BUFFER_START" },
+       { 0x14, 0x3f, 3, 3, "MI_DISPLAY_BUFFER_INFO" },
+       { 0x04, 0, 1, 1, "MI_FLUSH" },
+       { 0x22, 0, 3, 3, "MI_LOAD_REGISTER_IMM" },
+       { 0x13, 0x3f, 2, 2, "MI_LOAD_SCAN_LINES_EXCL" },
+       { 0x12, 0x3f, 2, 2, "MI_LOAD_SCAN_LINES_INCL" },
+       { 0x00, 0, 1, 1, "MI_NOOP" },
+       { 0x11, 0x3f, 2, 2, "MI_OVERLAY_FLIP" },
+       { 0x07, 0, 1, 1, "MI_REPORT_HEAD" },
+       { 0x18, 0x3f, 2, 2, "MI_SET_CONTEXT" },
+       { 0x20, 0x3f, 3, 4, "MI_STORE_DATA_IMM" },
+       { 0x21, 0x3f, 3, 4, "MI_STORE_DATA_INDEX" },
+       { 0x24, 0x3f, 3, 3, "MI_STORE_REGISTER_MEM" },
+       { 0x02, 0, 1, 1, "MI_USER_INTERRUPT" },
+       { 0x03, 0, 1, 1, "MI_WAIT_FOR_EVENT" },
+    };
+
+
+    for (opcode = 0; opcode < sizeof(opcodes_mi) / sizeof(opcodes_mi[0]);
+        opcode++) {
+       if ((data[0] & 0x1f800000) >> 23 == opcodes_mi[opcode].opcode) {
+           unsigned int len = 1, i;
+
+           instr_out(data, hw_offset, 0, "%s\n", opcodes_mi[opcode].name);
+           if (opcodes_mi[opcode].max_len > 1) {
+               len = (data[0] & opcodes_mi[opcode].len_mask) + 2;
+               if (len < opcodes_mi[opcode].min_len ||
+                   len > opcodes_mi[opcode].max_len)
+               {
+                   fprintf(out, "Bad length (%d) in %s, [%d, %d]\n",
+                           len, opcodes_mi[opcode].name,
+                           opcodes_mi[opcode].min_len,
+                           opcodes_mi[opcode].max_len);
+               }
+           }
+
+           for (i = 1; i < len; i++) {
+               if (i >= count)
+                   BUFFER_FAIL(count, len, opcodes_mi[opcode].name);
+               instr_out(data, hw_offset, i, "dword %d\n", i);
+           }
+
+           return len;
+       }
+    }
+
+    instr_out(data, hw_offset, 0, "MI UNKNOWN\n");
+    (*failures)++;
+    return 1;
+}
+
+static int
+decode_2d(const uint32_t *data, int count, uint32_t hw_offset, int *failures)
+{
+    unsigned int opcode, len;
+    char *format = NULL;
+
+    struct {
+       uint32_t opcode;
+       int min_len;
+       int max_len;
+       char *name;
+    } opcodes_2d[] = {
+       { 0x40, 5, 5, "COLOR_BLT" },
+       { 0x43, 6, 6, "SRC_COPY_BLT" },
+       { 0x01, 8, 8, "XY_SETUP_BLT" },
+       { 0x11, 9, 9, "XY_SETUP_MONO_PATTERN_SL_BLT" },
+       { 0x03, 3, 3, "XY_SETUP_CLIP_BLT" },
+       { 0x24, 2, 2, "XY_PIXEL_BLT" },
+       { 0x25, 3, 3, "XY_SCANLINES_BLT" },
+       { 0x26, 4, 4, "Y_TEXT_BLT" },
+       { 0x31, 5, 134, "XY_TEXT_IMMEDIATE_BLT" },
+       { 0x50, 6, 6, "XY_COLOR_BLT" },
+       { 0x51, 6, 6, "XY_PAT_BLT" },
+       { 0x76, 8, 8, "XY_PAT_CHROMA_BLT" },
+       { 0x72, 7, 135, "XY_PAT_BLT_IMMEDIATE" },
+       { 0x77, 9, 137, "XY_PAT_CHROMA_BLT_IMMEDIATE" },
+       { 0x52, 9, 9, "XY_MONO_PAT_BLT" },
+       { 0x59, 7, 7, "XY_MONO_PAT_FIXED_BLT" },
+       { 0x53, 8, 8, "XY_SRC_COPY_BLT" },
+       { 0x54, 8, 8, "XY_MONO_SRC_COPY_BLT" },
+       { 0x71, 9, 137, "XY_MONO_SRC_COPY_IMMEDIATE_BLT" },
+       { 0x55, 9, 9, "XY_FULL_BLT" },
+       { 0x55, 9, 137, "XY_FULL_IMMEDIATE_PATTERN_BLT" },
+       { 0x56, 9, 9, "XY_FULL_MONO_SRC_BLT" },
+       { 0x75, 10, 138, "XY_FULL_MONO_SRC_IMMEDIATE_PATTERN_BLT" },
+       { 0x57, 12, 12, "XY_FULL_MONO_PATTERN_BLT" },
+       { 0x58, 12, 12, "XY_FULL_MONO_PATTERN_MONO_SRC_BLT" },
+    };
+
+    switch ((data[0] & 0x1fc00000) >> 22) {
+    case 0x50:
+       instr_out(data, hw_offset, 0,
+                 "XY_COLOR_BLT (rgb %sabled, alpha %sabled, dst tile %d)\n",
+                 (data[0] & (1 << 20)) ? "en" : "dis",
+                 (data[0] & (1 << 21)) ? "en" : "dis",
+                 (data[0] >> 11) & 1);
+
+       len = (data[0] & 0x000000ff) + 2;
+       if (len != 6)
+           fprintf(out, "Bad count in XY_COLOR_BLT\n");
+       if (count < 6)
+           BUFFER_FAIL(count, len, "XY_COLOR_BLT");
+
+       switch ((data[1] >> 24) & 0x3) {
+       case 0:
+           format="8";
+           break;
+       case 1:
+           format="565";
+           break;
+       case 2:
+           format="1555";
+           break;
+       case 3:
+           format="8888";
+           break;
+       }
+
+       instr_out(data, hw_offset, 1, "format %s, pitch %d, "
+                 "clipping %sabled\n", format,
+                 (short)(data[1] & 0xffff),
+                 data[1] & (1 << 30) ? "en" : "dis");
+       instr_out(data, hw_offset, 2, "(%d,%d)\n",
+                 data[2] & 0xffff, data[2] >> 16);
+       instr_out(data, hw_offset, 3, "(%d,%d)\n",
+                 data[3] & 0xffff, data[3] >> 16);
+       instr_out(data, hw_offset, 4, "offset 0x%08x\n", data[4]);
+       instr_out(data, hw_offset, 5, "color\n");
+       return len;
+    case 0x53:
+       instr_out(data, hw_offset, 0,
+                 "XY_SRC_COPY_BLT (rgb %sabled, alpha %sabled, "
+                 "src tile %d, dst tile %d)\n",
+                 (data[0] & (1 << 20)) ? "en" : "dis",
+                 (data[0] & (1 << 21)) ? "en" : "dis",
+                 (data[0] >> 15) & 1,
+                 (data[0] >> 11) & 1);
+
+       len = (data[0] & 0x000000ff) + 2;
+       if (len != 8)
+           fprintf(out, "Bad count in XY_SRC_COPY_BLT\n");
+       if (count < 8)
+           BUFFER_FAIL(count, len, "XY_SRC_COPY_BLT");
+
+       switch ((data[1] >> 24) & 0x3) {
+       case 0:
+           format="8";
+           break;
+       case 1:
+           format="565";
+           break;
+       case 2:
+           format="1555";
+           break;
+       case 3:
+           format="8888";
+           break;
+       }
+
+       instr_out(data, hw_offset, 1, "format %s, dst pitch %d, "
+                 "clipping %sabled\n", format,
+                 (short)(data[1] & 0xffff),
+                 data[1] & (1 << 30) ? "en" : "dis");
+       instr_out(data, hw_offset, 2, "dst (%d,%d)\n",
+                 data[2] & 0xffff, data[2] >> 16);
+       instr_out(data, hw_offset, 3, "dst (%d,%d)\n",
+                 data[3] & 0xffff, data[3] >> 16);
+       instr_out(data, hw_offset, 4, "dst offset 0x%08x\n", data[4]);
+       instr_out(data, hw_offset, 5, "src (%d,%d)\n",
+                 data[5] & 0xffff, data[5] >> 16);
+       instr_out(data, hw_offset, 6, "src pitch %d\n",
+                 (short)(data[6] & 0xffff));
+       instr_out(data, hw_offset, 7, "src offset 0x%08x\n", data[7]);
+       return len;
+    }
+
+    for (opcode = 0; opcode < sizeof(opcodes_2d) / sizeof(opcodes_2d[0]);
+        opcode++) {
+       if ((data[0] & 0x1fc00000) >> 22 == opcodes_2d[opcode].opcode) {
+           unsigned int i;
+
+           len = 1;
+           instr_out(data, hw_offset, 0, "%s\n", opcodes_2d[opcode].name);
+           if (opcodes_2d[opcode].max_len > 1) {
+               len = (data[0] & 0x000000ff) + 2;
+               if (len < opcodes_2d[opcode].min_len ||
+                   len > opcodes_2d[opcode].max_len)
+               {
+                   fprintf(out, "Bad count in %s\n", opcodes_2d[opcode].name);
+               }
+           }
+
+           for (i = 1; i < len; i++) {
+               if (i >= count)
+                   BUFFER_FAIL(count, len, opcodes_2d[opcode].name);
+               instr_out(data, hw_offset, i, "dword %d\n", i);
+           }
+
+           return len;
+       }
+    }
+
+    instr_out(data, hw_offset, 0, "2D UNKNOWN\n");
+    (*failures)++;
+    return 1;
+}
+
+static int
+decode_3d_1c(const uint32_t *data, int count, uint32_t hw_offset, int *failures)
+{
+    switch ((data[0] & 0x00f80000) >> 19) {
+    case 0x11:
+       instr_out(data, hw_offset, 0, "3DSTATE_DEPTH_SUBRECTANGLE_DISALBE\n");
+       return 1;
+    case 0x10:
+       instr_out(data, hw_offset, 0, "3DSTATE_SCISSOR_ENABLE\n");
+       return 1;
+    case 0x01:
+       instr_out(data, hw_offset, 0, "3DSTATE_MAP_COORD_SET_I830\n");
+       return 1;
+    case 0x0a:
+       instr_out(data, hw_offset, 0, "3DSTATE_MAP_CUBE_I830\n");
+       return 1;
+    case 0x05:
+       instr_out(data, hw_offset, 0, "3DSTATE_MAP_TEX_STREAM_I830\n");
+       return 1;
+    }
+
+    instr_out(data, hw_offset, 0, "3D UNKNOWN\n");
+    (*failures)++;
+    return 1;
+}
+
+/** Sets the string dstname to describe the destination of the PS instruction */
+static void
+i915_get_instruction_dst(const uint32_t *data, int i, char *dstname, int do_mask)
+{
+    uint32_t a0 = data[i];
+    int dst_nr = (a0 >> 14) & 0xf;
+    char dstmask[8];
+    char *sat;
+
+    if (do_mask) {
+       if (((a0 >> 10) & 0xf) == 0xf) {
+           dstmask[0] = 0;
+       } else {
+           int dstmask_index = 0;
+
+           dstmask[dstmask_index++] = '.';
+           if (a0 & (1 << 10))
+               dstmask[dstmask_index++] = 'x';
+           if (a0 & (1 << 11))
+               dstmask[dstmask_index++] = 'y';
+           if (a0 & (1 << 12))
+               dstmask[dstmask_index++] = 'z';
+           if (a0 & (1 << 13))
+               dstmask[dstmask_index++] = 'w';
+           dstmask[dstmask_index++] = 0;
+       }
+
+       if (a0 & (1 << 22))
+           sat = ".sat";
+       else
+           sat = "";
+    } else {
+       dstmask[0] = 0;
+       sat = "";
+    }
+
+    switch ((a0 >> 19) & 0x7) {
+    case 0:
+       if (dst_nr > 15)
+           fprintf(out, "bad destination reg R%d\n", dst_nr);
+       sprintf(dstname, "R%d%s%s", dst_nr, dstmask, sat);
+       break;
+    case 4:
+       if (dst_nr > 0)
+           fprintf(out, "bad destination reg oC%d\n", dst_nr);
+       sprintf(dstname, "oC%s%s", dstmask, sat);
+       break;
+    case 5:
+       if (dst_nr > 0)
+           fprintf(out, "bad destination reg oD%d\n", dst_nr);
+       sprintf(dstname, "oD%s%s",  dstmask, sat);
+       break;
+    case 6:
+       if (dst_nr > 2)
+           fprintf(out, "bad destination reg U%d\n", dst_nr);
+       sprintf(dstname, "U%d%s%s", dst_nr, dstmask, sat);
+       break;
+    default:
+       sprintf(dstname, "RESERVED");
+       break;
+    }
+}
+
+static char *
+i915_get_channel_swizzle(uint32_t select)
+{
+    switch (select & 0x7) {
+    case 0:
+       return (select & 8) ? "-x" : "x";
+    case 1:
+       return (select & 8) ? "-y" : "y";
+    case 2:
+       return (select & 8) ? "-z" : "z";
+    case 3:
+       return (select & 8) ? "-w" : "w";
+    case 4:
+       return (select & 8) ? "-0" : "0";
+    case 5:
+       return (select & 8) ? "-1" : "1";
+    default:
+       return (select & 8) ? "-bad" : "bad";
+    }
+}
+
+static void
+i915_get_instruction_src_name(uint32_t src_type, uint32_t src_nr, char *name)
+{
+    switch (src_type) {
+    case 0:
+       sprintf(name, "R%d", src_nr);
+       if (src_nr > 15)
+           fprintf(out, "bad src reg %s\n", name);
+       break;
+    case 1:
+       if (src_nr < 8)
+           sprintf(name, "T%d", src_nr);
+       else if (src_nr == 8)
+           sprintf(name, "DIFFUSE");
+       else if (src_nr == 9)
+           sprintf(name, "SPECULAR");
+       else if (src_nr == 10)
+           sprintf(name, "FOG");
+       else {
+           fprintf(out, "bad src reg T%d\n", src_nr);
+           sprintf(name, "RESERVED");
+       }
+       break;
+    case 2:
+       sprintf(name, "C%d", src_nr);
+       if (src_nr > 31)
+           fprintf(out, "bad src reg %s\n", name);
+       break;
+    case 4:
+       sprintf(name, "oC");
+       if (src_nr > 0)
+           fprintf(out, "bad src reg oC%d\n", src_nr);
+       break;
+    case 5:
+       sprintf(name, "oD");
+       if (src_nr > 0)
+           fprintf(out, "bad src reg oD%d\n", src_nr);
+       break;
+    case 6:
+       sprintf(name, "U%d", src_nr);
+       if (src_nr > 2)
+           fprintf(out, "bad src reg %s\n", name);
+       break;
+    default:
+       fprintf(out, "bad src reg type %d\n", src_type);
+       sprintf(name, "RESERVED");
+       break;
+    }
+}
+
+static void
+i915_get_instruction_src0(const uint32_t *data, int i, char *srcname)
+{
+    uint32_t a0 = data[i];
+    uint32_t a1 = data[i + 1];
+    int src_nr = (a0 >> 2) & 0x1f;
+    char *swizzle_x = i915_get_channel_swizzle((a1 >> 28) & 0xf);
+    char *swizzle_y = i915_get_channel_swizzle((a1 >> 24) & 0xf);
+    char *swizzle_z = i915_get_channel_swizzle((a1 >> 20) & 0xf);
+    char *swizzle_w = i915_get_channel_swizzle((a1 >> 16) & 0xf);
+    char swizzle[100];
+
+    i915_get_instruction_src_name((a0 >> 7) & 0x7, src_nr, srcname);
+    sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z, swizzle_w);
+    if (strcmp(swizzle, ".xyzw") != 0)
+       strcat(srcname, swizzle);
+}
+
+static void
+i915_get_instruction_src1(const uint32_t *data, int i, char *srcname)
+{
+    uint32_t a1 = data[i + 1];
+    uint32_t a2 = data[i + 2];
+    int src_nr = (a1 >> 8) & 0x1f;
+    char *swizzle_x = i915_get_channel_swizzle((a1 >> 4) & 0xf);
+    char *swizzle_y = i915_get_channel_swizzle((a1 >> 0) & 0xf);
+    char *swizzle_z = i915_get_channel_swizzle((a2 >> 28) & 0xf);
+    char *swizzle_w = i915_get_channel_swizzle((a2 >> 24) & 0xf);
+    char swizzle[100];
+
+    i915_get_instruction_src_name((a1 >> 13) & 0x7, src_nr, srcname);
+    sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z, swizzle_w);
+    if (strcmp(swizzle, ".xyzw") != 0)
+       strcat(srcname, swizzle);
+}
+
+static void
+i915_get_instruction_src2(const uint32_t *data, int i, char *srcname)
+{
+    uint32_t a2 = data[i + 2];
+    int src_nr = (a2 >> 16) & 0x1f;
+    char *swizzle_x = i915_get_channel_swizzle((a2 >> 12) & 0xf);
+    char *swizzle_y = i915_get_channel_swizzle((a2 >> 8) & 0xf);
+    char *swizzle_z = i915_get_channel_swizzle((a2 >> 4) & 0xf);
+    char *swizzle_w = i915_get_channel_swizzle((a2 >> 0) & 0xf);
+    char swizzle[100];
+
+    i915_get_instruction_src_name((a2 >> 21) & 0x7, src_nr, srcname);
+    sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z, swizzle_w);
+    if (strcmp(swizzle, ".xyzw") != 0)
+       strcat(srcname, swizzle);
+}
+
+static void
+i915_get_instruction_addr(uint32_t src_type, uint32_t src_nr, char *name)
+{
+    switch (src_type) {
+    case 0:
+       sprintf(name, "R%d", src_nr);
+       if (src_nr > 15)
+           fprintf(out, "bad src reg %s\n", name);
+       break;
+    case 1:
+       if (src_nr < 8)
+           sprintf(name, "T%d", src_nr);
+       else if (src_nr == 8)
+           sprintf(name, "DIFFUSE");
+       else if (src_nr == 9)
+           sprintf(name, "SPECULAR");
+       else if (src_nr == 10)
+           sprintf(name, "FOG");
+       else {
+           fprintf(out, "bad src reg T%d\n", src_nr);
+           sprintf(name, "RESERVED");
+       }
+       break;
+    case 4:
+       sprintf(name, "oC");
+       if (src_nr > 0)
+           fprintf(out, "bad src reg oC%d\n", src_nr);
+       break;
+    case 5:
+       sprintf(name, "oD");
+       if (src_nr > 0)
+           fprintf(out, "bad src reg oD%d\n", src_nr);
+       break;
+    default:
+       fprintf(out, "bad src reg type %d\n", src_type);
+       sprintf(name, "RESERVED");
+       break;
+    }
+}
+
+static void
+i915_decode_alu1(const uint32_t *data, uint32_t hw_offset,
+                int i, char *instr_prefix, char *op_name)
+{
+    char dst[100], src0[100];
+
+    i915_get_instruction_dst(data, i, dst, 1);
+    i915_get_instruction_src0(data, i, src0);
+
+    instr_out(data, hw_offset, i++, "%s: %s %s, %s\n", instr_prefix,
+             op_name, dst, src0);
+    instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
+    instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
+}
+
+static void
+i915_decode_alu2(const uint32_t *data, uint32_t hw_offset,
+                int i, char *instr_prefix, char *op_name)
+{
+    char dst[100], src0[100], src1[100];
+
+    i915_get_instruction_dst(data, i, dst, 1);
+    i915_get_instruction_src0(data, i, src0);
+    i915_get_instruction_src1(data, i, src1);
+
+    instr_out(data, hw_offset, i++, "%s: %s %s, %s, %s\n", instr_prefix,
+             op_name, dst, src0, src1);
+    instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
+    instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
+}
+
+static void
+i915_decode_alu3(const uint32_t *data, uint32_t hw_offset,
+                int i, char *instr_prefix, char *op_name)
+{
+    char dst[100], src0[100], src1[100], src2[100];
+
+    i915_get_instruction_dst(data, i, dst, 1);
+    i915_get_instruction_src0(data, i, src0);
+    i915_get_instruction_src1(data, i, src1);
+    i915_get_instruction_src2(data, i, src2);
+
+    instr_out(data, hw_offset, i++, "%s: %s %s, %s, %s, %s\n", instr_prefix,
+             op_name, dst, src0, src1, src2);
+    instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
+    instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
+}
+
+static void
+i915_decode_tex(const uint32_t *data, uint32_t hw_offset, int i, char *instr_prefix,
+               char *tex_name)
+{
+    uint32_t t0 = data[i];
+    uint32_t t1 = data[i + 1];
+    char dst_name[100];
+    char addr_name[100];
+    int sampler_nr;
+
+    i915_get_instruction_dst(data, i, dst_name, 0);
+    i915_get_instruction_addr((t1 >> 24) & 0x7,
+                             (t1 >> 17) & 0xf,
+                             addr_name);
+    sampler_nr = t0 & 0xf;
+
+    instr_out(data, hw_offset, i++, "%s: %s %s, S%d, %s\n", instr_prefix,
+             tex_name, dst_name, sampler_nr, addr_name);
+    instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
+    instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
+}
+
+static void
+i915_decode_dcl(const uint32_t *data, uint32_t hw_offset, int i, char *instr_prefix)
+{
+    uint32_t d0 = data[i];
+    char *sampletype;
+    int dcl_nr = (d0 >> 14) & 0xf;
+    char *dcl_x = d0 & (1 << 10) ? "x" : "";
+    char *dcl_y = d0 & (1 << 11) ? "y" : "";
+    char *dcl_z = d0 & (1 << 12) ? "z" : "";
+    char *dcl_w = d0 & (1 << 13) ? "w" : "";
+    char dcl_mask[10];
+
+    switch ((d0 >> 19) & 0x3) {
+    case 1:
+       sprintf(dcl_mask, ".%s%s%s%s", dcl_x, dcl_y, dcl_z, dcl_w);
+       if (strcmp(dcl_mask, ".") == 0)
+           fprintf(out, "bad (empty) dcl mask\n");
+
+       if (dcl_nr > 10)
+           fprintf(out, "bad T%d dcl register number\n", dcl_nr);
+       if (dcl_nr < 8) {
+           if (strcmp(dcl_mask, ".x") != 0 &&
+               strcmp(dcl_mask, ".xy") != 0 &&
+               strcmp(dcl_mask, ".xz") != 0 &&
+               strcmp(dcl_mask, ".w") != 0 &&
+               strcmp(dcl_mask, ".xyzw") != 0) {
+               fprintf(out, "bad T%d.%s dcl mask\n", dcl_nr, dcl_mask);
+           }
+           instr_out(data, hw_offset, i++, "%s: DCL T%d%s\n", instr_prefix,
+                     dcl_nr, dcl_mask);
+       } else {
+           if (strcmp(dcl_mask, ".xz") == 0)
+               fprintf(out, "errataed bad dcl mask %s\n", dcl_mask);
+           else if (strcmp(dcl_mask, ".xw") == 0)
+               fprintf(out, "errataed bad dcl mask %s\n", dcl_mask);
+           else if (strcmp(dcl_mask, ".xzw") == 0)
+               fprintf(out, "errataed bad dcl mask %s\n", dcl_mask);
+
+           if (dcl_nr == 8) {
+               instr_out(data, hw_offset, i++, "%s: DCL DIFFUSE%s\n", instr_prefix,
+                         dcl_mask);
+           } else if (dcl_nr == 9) {
+               instr_out(data, hw_offset, i++, "%s: DCL SPECULAR%s\n", instr_prefix,
+                         dcl_mask);
+           } else if (dcl_nr == 10) {
+               instr_out(data, hw_offset, i++, "%s: DCL FOG%s\n", instr_prefix,
+                         dcl_mask);
+           }
+       }
+       instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
+       instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
+       break;
+    case 3:
+       switch ((d0 >> 22) & 0x3) {
+       case 0:
+           sampletype = "2D";
+           break;
+       case 1:
+           sampletype = "CUBE";
+           break;
+       case 2:
+           sampletype = "3D";
+           break;
+       default:
+           sampletype = "RESERVED";
+           break;
+       }
+       if (dcl_nr > 15)
+           fprintf(out, "bad S%d dcl register number\n", dcl_nr);
+       instr_out(data, hw_offset, i++, "%s: DCL S%d %s\n", instr_prefix,
+                 dcl_nr, sampletype);
+       instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
+       instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
+       break;
+    default:
+       instr_out(data, hw_offset, i++, "%s: DCL RESERVED%d\n", instr_prefix, dcl_nr);
+       instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
+       instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
+    }
+}
+
+static void
+i915_decode_instruction(const uint32_t *data, uint32_t hw_offset,
+                       int i, char *instr_prefix)
+{
+    switch ((data[i] >> 24) & 0x1f) {
+    case 0x0:
+       instr_out(data, hw_offset, i++, "%s: NOP\n", instr_prefix);
+       instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
+       instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
+       break;
+    case 0x01:
+       i915_decode_alu2(data, hw_offset, i, instr_prefix, "ADD");
+       break;
+    case 0x02:
+       i915_decode_alu1(data, hw_offset, i, instr_prefix, "MOV");
+       break;
+    case 0x03:
+       i915_decode_alu2(data, hw_offset, i, instr_prefix, "MUL");
+       break;
+    case 0x04:
+       i915_decode_alu3(data, hw_offset, i, instr_prefix, "MAD");
+       break;
+    case 0x05:
+       i915_decode_alu3(data, hw_offset, i, instr_prefix, "DP2ADD");
+       break;
+    case 0x06:
+       i915_decode_alu2(data, hw_offset, i, instr_prefix, "DP3");
+       break;
+    case 0x07:
+       i915_decode_alu2(data, hw_offset, i, instr_prefix, "DP4");
+       break;
+    case 0x08:
+       i915_decode_alu1(data, hw_offset, i, instr_prefix, "FRC");
+       break;
+    case 0x09:
+       i915_decode_alu1(data, hw_offset, i, instr_prefix, "RCP");
+       break;
+    case 0x0a:
+       i915_decode_alu1(data, hw_offset, i, instr_prefix, "RSQ");
+       break;
+    case 0x0b:
+       i915_decode_alu1(data, hw_offset, i, instr_prefix, "EXP");
+       break;
+    case 0x0c:
+       i915_decode_alu1(data, hw_offset, i, instr_prefix, "LOG");
+       break;
+    case 0x0d:
+       i915_decode_alu2(data, hw_offset, i, instr_prefix, "CMP");
+       break;
+    case 0x0e:
+       i915_decode_alu2(data, hw_offset, i, instr_prefix, "MIN");
+       break;
+    case 0x0f:
+       i915_decode_alu2(data, hw_offset, i, instr_prefix, "MAX");
+       break;
+    case 0x10:
+       i915_decode_alu1(data, hw_offset, i, instr_prefix, "FLR");
+       break;
+    case 0x11:
+       i915_decode_alu1(data, hw_offset, i, instr_prefix, "MOD");
+       break;
+    case 0x12:
+       i915_decode_alu1(data, hw_offset, i, instr_prefix, "TRC");
+       break;
+    case 0x13:
+       i915_decode_alu2(data, hw_offset, i, instr_prefix, "SGE");
+       break;
+    case 0x14:
+       i915_decode_alu2(data, hw_offset, i, instr_prefix, "SLT");
+       break;
+    case 0x15:
+       i915_decode_tex(data, hw_offset, i, instr_prefix, "TEXLD");
+       break;
+    case 0x16:
+       i915_decode_tex(data, hw_offset, i, instr_prefix, "TEXLDP");
+       break;
+    case 0x17:
+       i915_decode_tex(data, hw_offset, i, instr_prefix, "TEXLDB");
+       break;
+    case 0x19:
+       i915_decode_dcl(data, hw_offset, i, instr_prefix);
+       break;
+    default:
+       instr_out(data, hw_offset, i++, "%s: unknown\n", instr_prefix);
+       instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
+       instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
+       break;
+    }
+}
+
+static int
+decode_3d_1d(const uint32_t *data, int count, uint32_t hw_offset, int *failures, int i830)
+{
+    unsigned int len, i, c, opcode, word, map, sampler, instr;
+    char *format;
+
+    struct {
+       uint32_t opcode;
+       int i830_only;
+       int min_len;
+       int max_len;
+       char *name;
+    } opcodes_3d_1d[] = {
+       { 0x8e, 0, 3, 3, "3DSTATE_BUFFER_INFO" },
+       { 0x86, 0, 4, 4, "3DSTATE_CHROMA_KEY" },
+       { 0x9c, 0, 1, 1, "3DSTATE_CLEAR_PARAMETERS" },
+       { 0x88, 0, 2, 2, "3DSTATE_CONSTANT_BLEND_COLOR" },
+       { 0x99, 0, 2, 2, "3DSTATE_DEFAULT_DIFFUSE" },
+       { 0x9a, 0, 2, 2, "3DSTATE_DEFAULT_SPECULAR" },
+       { 0x98, 0, 2, 2, "3DSTATE_DEFAULT_Z" },
+       { 0x97, 0, 2, 2, "3DSTATE_DEPTH_OFFSET_SCALE" },
+       { 0x85, 0, 2, 2, "3DSTATE_DEST_BUFFER_VARIABLES" },
+       { 0x80, 0, 5, 5, "3DSTATE_DRAWING_RECTANGLE" },
+       { 0x8e, 0, 3, 3, "3DSTATE_BUFFER_INFO" },
+       { 0x9d, 0, 65, 65, "3DSTATE_FILTER_COEFFICIENTS_4X4" },
+       { 0x9e, 0, 4, 4, "3DSTATE_MONO_FILTER" },
+       { 0x89, 0, 4, 4, "3DSTATE_FOG_MODE" },
+       { 0x8f, 0, 2, 16, "3DSTATE_MAP_PALLETE_LOAD_32" },
+       { 0x81, 0, 3, 3, "3DSTATE_SCISSOR_RECTANGLE" },
+       { 0x83, 0, 2, 2, "3DSTATE_SPAN_STIPPLE" },
+       { 0x8c, 1, 2, 2, "3DSTATE_MAP_COORD_TRANSFORM_I830" },
+       { 0x8b, 1, 2, 2, "3DSTATE_MAP_VERTEX_TRANSFORM_I830" },
+       { 0x8d, 1, 3, 3, "3DSTATE_W_STATE_I830" },
+       { 0x01, 1, 2, 2, "3DSTATE_COLOR_FACTOR_I830" },
+       { 0x02, 1, 2, 2, "3DSTATE_MAP_COORD_SETBIND_I830" },
+    };
+
+    switch ((data[0] & 0x00ff0000) >> 16) {
+    case 0x07:
+       /* This instruction is unusual.  A 0 length means just 1 DWORD instead of
+        * 2.  The 0 length is specified in one place to be unsupported, but
+        * stated to be required in another, and 0 length LOAD_INDIRECTs appear
+        * to cause no harm at least.
+        */
+       instr_out(data, hw_offset, 0, "3DSTATE_LOAD_INDIRECT\n");
+       len = (data[0] & 0x000000ff) + 1;
+       i = 1;
+       if (data[0] & (0x01 << 8)) {
+           if (i + 2 >= count)
+               BUFFER_FAIL(count, len, "3DSTATE_LOAD_INDIRECT");
+           instr_out(data, hw_offset, i++, "SIS.0\n");
+           instr_out(data, hw_offset, i++, "SIS.1\n");
+       }
+       if (data[0] & (0x02 << 8)) {
+           if (i + 1 >= count)
+               BUFFER_FAIL(count, len, "3DSTATE_LOAD_INDIRECT");
+           instr_out(data, hw_offset, i++, "DIS.0\n");
+       }
+       if (data[0] & (0x04 << 8)) {
+           if (i + 2 >= count)
+               BUFFER_FAIL(count, len, "3DSTATE_LOAD_INDIRECT");
+           instr_out(data, hw_offset, i++, "SSB.0\n");
+           instr_out(data, hw_offset, i++, "SSB.1\n");
+       }
+       if (data[0] & (0x08 << 8)) {
+           if (i + 2 >= count)
+               BUFFER_FAIL(count, len, "3DSTATE_LOAD_INDIRECT");
+           instr_out(data, hw_offset, i++, "MSB.0\n");
+           instr_out(data, hw_offset, i++, "MSB.1\n");
+       }
+       if (data[0] & (0x10 << 8)) {
+           if (i + 2 >= count)
+               BUFFER_FAIL(count, len, "3DSTATE_LOAD_INDIRECT");
+           instr_out(data, hw_offset, i++, "PSP.0\n");
+           instr_out(data, hw_offset, i++, "PSP.1\n");
+       }
+       if (data[0] & (0x20 << 8)) {
+           if (i + 2 >= count)
+               BUFFER_FAIL(count, len, "3DSTATE_LOAD_INDIRECT");
+           instr_out(data, hw_offset, i++, "PSC.0\n");
+           instr_out(data, hw_offset, i++, "PSC.1\n");
+       }
+       if (len != i) {
+           fprintf(out, "Bad count in 3DSTATE_LOAD_INDIRECT\n");
+           (*failures)++;
+           return len;
+       }
+       return len;
+    case 0x04:
+       instr_out(data, hw_offset, 0, "3DSTATE_LOAD_STATE_IMMEDIATE_1\n");
+       len = (data[0] & 0x0000000f) + 2;
+       i = 1;
+       for (word = 0; word <= 7; word++) {
+           if (data[0] & (1 << (4 + word))) {
+               if (i >= count)
+                   BUFFER_FAIL(count, len, "3DSTATE_LOAD_STATE_IMMEDIATE_1");
+
+               /* save vertex state for decode */
+               if (word == 2) {
+                   saved_s2_set = 1;
+                   saved_s2 = data[i];
+               }
+               if (word == 4) {
+                   saved_s4_set = 1;
+                   saved_s4 = data[i];
+               }
+
+               instr_out(data, hw_offset, i++, "S%d\n", word);
+           }
+       }
+       if (len != i) {
+           fprintf(out, "Bad count in 3DSTATE_LOAD_INDIRECT\n");
+           (*failures)++;
+       }
+       return len;
+    case 0x00:
+       instr_out(data, hw_offset, 0, "3DSTATE_MAP_STATE\n");
+       len = (data[0] & 0x0000003f) + 2;
+       instr_out(data, hw_offset, 1, "mask\n");
+
+       i = 2;
+       for (map = 0; map <= 15; map++) {
+           if (data[1] & (1 << map)) {
+               if (i + 3 >= count)
+                   BUFFER_FAIL(count, len, "3DSTATE_MAP_STATE");
+               instr_out(data, hw_offset, i++, "map %d MS2\n", map);
+               instr_out(data, hw_offset, i++, "map %d MS3\n", map);
+               instr_out(data, hw_offset, i++, "map %d MS4\n", map);
+           }
+       }
+       if (len != i) {
+           fprintf(out, "Bad count in 3DSTATE_MAP_STATE\n");
+           (*failures)++;
+           return len;
+       }
+       return len;
+    case 0x06:
+       instr_out(data, hw_offset, 0, "3DSTATE_PIXEL_SHADER_CONSTANTS\n");
+       len = (data[0] & 0x000000ff) + 2;
+
+       i = 2;
+       for (c = 0; c <= 31; c++) {
+           if (data[1] & (1 << c)) {
+               if (i + 4 >= count)
+                   BUFFER_FAIL(count, len, "3DSTATE_PIXEL_SHADER_CONSTANTS");
+               instr_out(data, hw_offset, i, "C%d.X = %f\n",
+                         c, int_as_float(data[i]));
+               i++;
+               instr_out(data, hw_offset, i, "C%d.Y = %f\n",
+                         c, int_as_float(data[i]));
+               i++;
+               instr_out(data, hw_offset, i, "C%d.Z = %f\n",
+                         c, int_as_float(data[i]));
+               i++;
+               instr_out(data, hw_offset, i, "C%d.W = %f\n",
+                         c, int_as_float(data[i]));
+               i++;
+           }
+       }
+       if (len != i) {
+           fprintf(out, "Bad count in 3DSTATE_PIXEL_SHADER_CONSTANTS\n");
+           (*failures)++;
+       }
+       return len;
+    case 0x05:
+       instr_out(data, hw_offset, 0, "3DSTATE_PIXEL_SHADER_PROGRAM\n");
+       len = (data[0] & 0x000000ff) + 2;
+       if ((len - 1) % 3 != 0 || len > 370) {
+           fprintf(out, "Bad count in 3DSTATE_PIXEL_SHADER_PROGRAM\n");
+           (*failures)++;
+       }
+       i = 1;
+       for (instr = 0; instr < (len - 1) / 3; instr++) {
+           char instr_prefix[10];
+
+           if (i + 3 >= count)
+               BUFFER_FAIL(count, len, "3DSTATE_PIXEL_SHADER_PROGRAM");
+           sprintf(instr_prefix, "PS%03d", instr);
+           i915_decode_instruction(data, hw_offset, i, instr_prefix);
+           i += 3;
+       }
+       return len;
+    case 0x01:
+       if (i830)
+           break;
+       instr_out(data, hw_offset, 0, "3DSTATE_SAMPLER_STATE\n");
+       instr_out(data, hw_offset, 1, "mask\n");
+       len = (data[0] & 0x0000003f) + 2;
+       i = 2;
+       for (sampler = 0; sampler <= 15; sampler++) {
+           if (data[1] & (1 << sampler)) {
+               if (i + 3 >= count)
+                   BUFFER_FAIL(count, len, "3DSTATE_SAMPLER_STATE");
+               instr_out(data, hw_offset, i++, "sampler %d SS2\n",
+                         sampler);
+               instr_out(data, hw_offset, i++, "sampler %d SS3\n",
+                         sampler);
+               instr_out(data, hw_offset, i++, "sampler %d SS4\n",
+                         sampler);
+           }
+       }
+       if (len != i) {
+           fprintf(out, "Bad count in 3DSTATE_SAMPLER_STATE\n");
+           (*failures)++;
+       }
+       return len;
+    case 0x85:
+       len = (data[0] & 0x0000000f) + 2;
+
+       if (len != 2)
+           fprintf(out, "Bad count in 3DSTATE_DEST_BUFFER_VARIABLES\n");
+       if (count < 2)
+           BUFFER_FAIL(count, len, "3DSTATE_DEST_BUFFER_VARIABLES");
+
+       instr_out(data, hw_offset, 0,
+                 "3DSTATE_DEST_BUFFER_VARIABLES\n");
+
+       switch ((data[1] >> 8) & 0xf) {
+       case 0x0: format = "g8"; break;
+       case 0x1: format = "x1r5g5b5"; break;
+       case 0x2: format = "r5g6b5"; break;
+       case 0x3: format = "a8r8g8b8"; break;
+       case 0x4: format = "ycrcb_swapy"; break;
+       case 0x5: format = "ycrcb_normal"; break;
+       case 0x6: format = "ycrcb_swapuv"; break;
+       case 0x7: format = "ycrcb_swapuvy"; break;
+       case 0x8: format = "a4r4g4b4"; break;
+       case 0x9: format = "a1r5g5b5"; break;
+       case 0xa: format = "a2r10g10b10"; break;
+       default: format = "BAD"; break;
+       }
+       instr_out(data, hw_offset, 1, "%s format, early Z %sabled\n",
+                 format,
+                 (data[1] & (1 << 31)) ? "en" : "dis");
+       return len;
+    }
+
+    for (opcode = 0; opcode < sizeof(opcodes_3d_1d) / sizeof(opcodes_3d_1d[0]);
+        opcode++)
+    {
+       if (opcodes_3d_1d[opcode].i830_only && !i830)
+           continue;
+
+       if (((data[0] & 0x00ff0000) >> 16) == opcodes_3d_1d[opcode].opcode) {
+           len = 1;
+
+           instr_out(data, hw_offset, 0, "%s\n", opcodes_3d_1d[opcode].name);
+           if (opcodes_3d_1d[opcode].max_len > 1) {
+               len = (data[0] & 0x0000ffff) + 2;
+               if (len < opcodes_3d_1d[opcode].min_len ||
+                   len > opcodes_3d_1d[opcode].max_len)
+               {
+                   fprintf(out, "Bad count in %s\n",
+                           opcodes_3d_1d[opcode].name);
+                   (*failures)++;
+               }
+           }
+
+           for (i = 1; i < len; i++) {
+               if (i >= count)
+                   BUFFER_FAIL(count, len,  opcodes_3d_1d[opcode].name);
+               instr_out(data, hw_offset, i, "dword %d\n", i);
+           }
+
+           return len;
+       }
+    }
+
+    instr_out(data, hw_offset, 0, "3D UNKNOWN\n");
+    (*failures)++;
+    return 1;
+}
+
+static int
+decode_3d_primitive(const uint32_t *data, int count, uint32_t hw_offset,
+                   int *failures)
+{
+    char immediate = (data[0] & (1 << 23)) == 0;
+    unsigned int len, i;
+    char *primtype;
+
+    switch ((data[0] >> 18) & 0xf) {
+    case 0x0: primtype = "TRILIST"; break;
+    case 0x1: primtype = "TRISTRIP"; break;
+    case 0x2: primtype = "TRISTRIP_REVERSE"; break;
+    case 0x3: primtype = "TRIFAN"; break;
+    case 0x4: primtype = "POLYGON"; break;
+    case 0x5: primtype = "LINELIST"; break;
+    case 0x6: primtype = "LINESTRIP"; break;
+    case 0x7: primtype = "RECTLIST"; break;
+    case 0x8: primtype = "POINTLIST"; break;
+    case 0x9: primtype = "DIB"; break;
+    case 0xa: primtype = "CLEAR_RECT"; break;
+    default: primtype = "unknown"; break;
+    }
+
+    /* XXX: 3DPRIM_DIB not supported */
+    if (immediate) {
+       len = (data[0] & 0x0003ffff) + 2;
+       instr_out(data, hw_offset, 0, "3DPRIMITIVE inline %s\n", primtype);
+       if (count < len)
+           BUFFER_FAIL(count, len,  "3DPRIMITIVE inline");
+       if (!saved_s2_set || !saved_s4_set) {
+           fprintf(out, "unknown vertex format\n");
+           for (i = 1; i < len; i++) {
+               instr_out(data, hw_offset, i,
+                         "           vertex data (%f float)\n",
+                         int_as_float(data[i]));
+           }
+       } else {
+           unsigned int vertex = 0;
+           for (i = 1; i < len;) {
+               unsigned int tc;
+
+#define VERTEX_OUT(fmt, ...) do {                                      \
+    if (i < len)                                                       \
+       instr_out(data, hw_offset, i, " V%d."fmt"\n", vertex, __VA_ARGS__); \
+    else                                                               \
+       fprintf(out, " missing data in V%d\n", vertex);                 \
+    i++;                                                               \
+} while (0)
+
+               VERTEX_OUT("X = %f", int_as_float(data[i]));
+               VERTEX_OUT("Y = %f", int_as_float(data[i]));
+               switch (saved_s4 >> 6 & 0x7) {
+               case 0x1:
+                   VERTEX_OUT("Z = %f", int_as_float(data[i]));
+                   break;
+               case 0x2:
+                   VERTEX_OUT("Z = %f", int_as_float(data[i]));
+                   VERTEX_OUT("W = %f", int_as_float(data[i]));
+                   break;
+               case 0x3:
+                   break;
+               case 0x4:
+                   VERTEX_OUT("W = %f", int_as_float(data[i]));
+                   break;
+               default:
+                   fprintf(out, "bad S4 position mask\n");
+               }
+
+               if (saved_s4 & (1 << 10)) {
+                   VERTEX_OUT("color = (A=0x%02x, R=0x%02x, G=0x%02x, "
+                              "B=0x%02x)",
+                              data[i] >> 24,
+                              (data[i] >> 16) & 0xff,
+                              (data[i] >> 8) & 0xff,
+                              data[i] & 0xff);
+               }
+               if (saved_s4 & (1 << 11)) {
+                   VERTEX_OUT("spec = (A=0x%02x, R=0x%02x, G=0x%02x, "
+                              "B=0x%02x)",
+                              data[i] >> 24,
+                              (data[i] >> 16) & 0xff,
+                              (data[i] >> 8) & 0xff,
+                              data[i] & 0xff);
+               }
+               if (saved_s4 & (1 << 12))
+                   VERTEX_OUT("width = 0x%08x)", data[i]);
+
+               for (tc = 0; tc <= 7; tc++) {
+                   switch ((saved_s2 >> (tc * 4)) & 0xf) {
+                   case 0x0:
+                       VERTEX_OUT("T%d.X = %f", tc, int_as_float(data[i]));
+                       VERTEX_OUT("T%d.Y = %f", tc, int_as_float(data[i]));
+                       break;
+                   case 0x1:
+                       VERTEX_OUT("T%d.X = %f", tc, int_as_float(data[i]));
+                       VERTEX_OUT("T%d.Y = %f", tc, int_as_float(data[i]));
+                       VERTEX_OUT("T%d.Z = %f", tc, int_as_float(data[i]));
+                       break;
+                   case 0x2:
+                       VERTEX_OUT("T%d.X = %f", tc, int_as_float(data[i]));
+                       VERTEX_OUT("T%d.Y = %f", tc, int_as_float(data[i]));
+                       VERTEX_OUT("T%d.Z = %f", tc, int_as_float(data[i]));
+                       VERTEX_OUT("T%d.W = %f", tc, int_as_float(data[i]));
+                       break;
+                   case 0x3:
+                       VERTEX_OUT("T%d.X = %f", tc, int_as_float(data[i]));
+                       break;
+                   case 0x4:
+                       VERTEX_OUT("T%d.XY = 0x%08x half-float", tc, data[i]);
+                       break;
+                   case 0x5:
+                       VERTEX_OUT("T%d.XY = 0x%08x half-float", tc, data[i]);
+                       VERTEX_OUT("T%d.ZW = 0x%08x half-float", tc, data[i]);
+                       break;
+                   case 0xf:
+                       break;
+                   default:
+                       fprintf(out, "bad S2.T%d format\n", tc);
+                   }
+               }
+               vertex++;
+           }
+       }
+    } else {
+       /* indirect vertices */
+       len = data[0] & 0x0000ffff; /* index count */
+       if (data[0] & (1 << 17)) {
+           /* random vertex access */
+           if (count < (len + 1) / 2 + 1) {
+               BUFFER_FAIL(count, (len + 1) / 2 + 1,
+                           "3DPRIMITIVE random indirect");
+           }
+           instr_out(data, hw_offset, 0,
+                     "3DPRIMITIVE random indirect %s (%d)\n", primtype, len);
+           if (len == 0) {
+               /* vertex indices continue until 0xffff is found */
+               for (i = 1; i < count; i++) {
+                   if ((data[i] & 0xffff) == 0xffff) {
+                       instr_out(data, hw_offset, i,
+                                 "            indices: (terminator)\n");
+                       return i;
+                   } else if ((data[i] >> 16) == 0xffff) {
+                       instr_out(data, hw_offset, i,
+                                 "            indices: 0x%04x, "
+                                 "(terminator)\n",
+                                 data[i] & 0xffff);
+                       return i;
+                   } else {
+                       instr_out(data, hw_offset, i,
+                                 "            indices: 0x%04x, 0x%04x\n",
+                                 data[i] & 0xffff, data[i] >> 16);
+                   }
+               }
+               fprintf(out,
+                       "3DPRIMITIVE: no terminator found in index buffer\n");
+               (*failures)++;
+               return count;
+           } else {
+               /* fixed size vertex index buffer */
+               for (i = 0; i < len; i += 2) {
+                   if (i * 2 == len - 1) {
+                       instr_out(data, hw_offset, i,
+                                 "            indices: 0x%04x\n",
+                                 data[i] & 0xffff);
+                   } else {
+                       instr_out(data, hw_offset, i,
+                                 "            indices: 0x%04x, 0x%04x\n",
+                                 data[i] & 0xffff, data[i] >> 16);
+                   }
+               }
+           }
+           return (len + 1) / 2 + 1;
+       } else {
+           /* sequential vertex access */
+           if (count < 2)
+               BUFFER_FAIL(count, 2, "3DPRIMITIVE seq indirect");
+           instr_out(data, hw_offset, 0,
+                     "3DPRIMITIVE sequential indirect %s, %d starting from "
+                     "%d\n", primtype, len, data[1] & 0xffff);
+           instr_out(data, hw_offset, 1, "           start\n");
+           return 2;
+       }
+    }
+
+    return len;
+}
+
+static int
+decode_3d(const uint32_t *data, int count, uint32_t hw_offset, int *failures)
+{
+    unsigned int opcode;
+
+    struct {
+       uint32_t opcode;
+       int min_len;
+       int max_len;
+       char *name;
+    } opcodes_3d[] = {
+       { 0x06, 1, 1, "3DSTATE_ANTI_ALIASING" },
+       { 0x08, 1, 1, "3DSTATE_BACKFACE_STENCIL_OPS" },
+       { 0x09, 1, 1, "3DSTATE_BACKFACE_STENCIL_MASKS" },
+       { 0x16, 1, 1, "3DSTATE_COORD_SET_BINDINGS" },
+       { 0x15, 1, 1, "3DSTATE_FOG_COLOR" },
+       { 0x0b, 1, 1, "3DSTATE_INDEPENDENT_ALPHA_BLEND" },
+       { 0x0d, 1, 1, "3DSTATE_MODES_4" },
+       { 0x0c, 1, 1, "3DSTATE_MODES_5" },
+       { 0x07, 1, 1, "3DSTATE_RASTERIZATION_RULES" },
+    };
+
+    switch ((data[0] & 0x1f000000) >> 24) {
+    case 0x1f:
+       return decode_3d_primitive(data, count, hw_offset, failures);
+    case 0x1d:
+       return decode_3d_1d(data, count, hw_offset, failures, 0);
+    case 0x1c:
+       return decode_3d_1c(data, count, hw_offset, failures);
+    }
+
+    for (opcode = 0; opcode < sizeof(opcodes_3d) / sizeof(opcodes_3d[0]);
+        opcode++) {
+       if ((data[0] & 0x1f000000) >> 24 == opcodes_3d[opcode].opcode) {
+           unsigned int len = 1, i;
+
+           instr_out(data, hw_offset, 0, "%s\n", opcodes_3d[opcode].name);
+           if (opcodes_3d[opcode].max_len > 1) {
+               len = (data[0] & 0xff) + 2;
+               if (len < opcodes_3d[opcode].min_len ||
+                   len > opcodes_3d[opcode].max_len)
+               {
+                   fprintf(out, "Bad count in %s\n", opcodes_3d[opcode].name);
+               }
+           }
+
+           for (i = 1; i < len; i++) {
+               if (i >= count)
+                   BUFFER_FAIL(count, len, opcodes_3d[opcode].name);
+               instr_out(data, hw_offset, i, "dword %d\n", i);
+           }
+           return len;
+       }
+    }
+
+    instr_out(data, hw_offset, 0, "3D UNKNOWN\n");
+    (*failures)++;
+    return 1;
+}
+
+static const char *
+get_965_surfacetype(unsigned int surfacetype)
+{
+    switch (surfacetype) {
+    case 0: return "1D";
+    case 1: return "2D";
+    case 2: return "3D";
+    case 3: return "CUBE";
+    case 4: return "BUFFER";
+    case 7: return "NULL";
+    default: return "unknown";
+    }
+}
+
+static const char *
+get_965_depthformat(unsigned int depthformat)
+{
+    switch (depthformat) {
+    case 0: return "s8_z24float";
+    case 1: return "z32float";
+    case 2: return "z24s8";
+    case 5: return "z16";
+    default: return "unknown";
+    }
+}
+
+static const char *
+get_965_element_component(uint32_t data, int component)
+{
+    uint32_t component_control = (data >> (16 + (3 - component) * 4)) & 0x7;
+
+    switch (component_control) {
+    case 0:
+       return "nostore";
+    case 1:
+       switch (component) {
+       case 0: return "X";
+       case 1: return "Y";
+       case 2: return "Z";
+       case 3: return "W";
+       default: return "fail";
+       }
+    case 2:
+       return "0.0";
+    case 3:
+       return "1.0";
+    case 4:
+       return "0x1";
+    case 5:
+       return "VID";
+    default:
+       return "fail";
+    }
+}
+
+static const char *
+get_965_prim_type(uint32_t data)
+{
+    uint32_t primtype = (data >> 10) & 0x1f;
+
+    switch (primtype) {
+    case 0x01: return "point list";
+    case 0x02: return "line list";
+    case 0x03: return "line strip";
+    case 0x04: return "tri list";
+    case 0x05: return "tri strip";
+    case 0x06: return "tri fan";
+    case 0x07: return "quad list";
+    case 0x08: return "quad strip";
+    case 0x09: return "line list adj";
+    case 0x0a: return "line strip adj";
+    case 0x0b: return "tri list adj";
+    case 0x0c: return "tri strip adj";
+    case 0x0d: return "tri strip reverse";
+    case 0x0e: return "polygon";
+    case 0x0f: return "rect list";
+    case 0x10: return "line loop";
+    case 0x11: return "point list bf";
+    case 0x12: return "line strip cont";
+    case 0x13: return "line strip bf";
+    case 0x14: return "line strip cont bf";
+    case 0x15: return "tri fan no stipple";
+    default: return "fail";
+    }
+}
+
+static int
+decode_3d_965(const uint32_t *data, int count, uint32_t hw_offset, int *failures)
+{
+    unsigned int opcode, len;
+    int i;
+
+    struct {
+       uint32_t opcode;
+       int min_len;
+       int max_len;
+       char *name;
+    } opcodes_3d[] = {
+       { 0x6000, 3, 3, "URB_FENCE" },
+       { 0x6001, 2, 2, "CS_URB_STATE" },
+       { 0x6002, 2, 2, "CONSTANT_BUFFER" },
+       { 0x6101, 6, 6, "STATE_BASE_ADDRESS" },
+       { 0x6102, 2, 2 , "STATE_SIP" },
+       { 0x6104, 1, 1, "3DSTATE_PIPELINE_SELECT" },
+       { 0x680b, 1, 1, "3DSTATE_VF_STATISTICS" },
+       { 0x6904, 1, 1, "3DSTATE_PIPELINE_SELECT" },
+       { 0x7800, 7, 7, "3DSTATE_PIPELINED_POINTERS" },
+       { 0x7801, 6, 6, "3DSTATE_BINDING_TABLE_POINTERS" },
+       { 0x780b, 1, 1, "3DSTATE_VF_STATISTICS" },
+       { 0x7808, 5, 257, "3DSTATE_VERTEX_BUFFERS" },
+       { 0x7809, 3, 256, "3DSTATE_VERTEX_ELEMENTS" },
+       { 0x780a, 3, 3, "3DSTATE_INDEX_BUFFER" },
+       { 0x7900, 4, 4, "3DSTATE_DRAWING_RECTANGLE" },
+       { 0x7901, 5, 5, "3DSTATE_CONSTANT_COLOR" },
+       { 0x7905, 5, 7, "3DSTATE_DEPTH_BUFFER" },
+       { 0x7906, 2, 2, "3DSTATE_POLY_STIPPLE_OFFSET" },
+       { 0x7907, 33, 33, "3DSTATE_POLY_STIPPLE_PATTERN" },
+       { 0x7908, 3, 3, "3DSTATE_LINE_STIPPLE" },
+       { 0x7909, 2, 2, "3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP" },
+       { 0x790a, 3, 3, "3DSTATE_AA_LINE_PARAMETERS" },
+       { 0x7b00, 6, 6, "3DPRIMITIVE" },
+    };
+
+    len = (data[0] & 0x0000ffff) + 2;
+
+    switch ((data[0] & 0xffff0000) >> 16) {
+    case 0x6101:
+       if (len != 6)
+           fprintf(out, "Bad count in STATE_BASE_ADDRESS\n");
+       if (count < 6)
+           BUFFER_FAIL(count, len, "STATE_BASE_ADDRESS");
+
+       instr_out(data, hw_offset, 0,
+                 "STATE_BASE_ADDRESS\n");
+
+       if (data[1] & 1) {
+           instr_out(data, hw_offset, 1, "General state at 0x%08x\n",
+                     data[1] & ~1);
+       } else
+           instr_out(data, hw_offset, 1, "General state not updated\n");
+
+       if (data[2] & 1) {
+           instr_out(data, hw_offset, 2, "Surface state at 0x%08x\n",
+                     data[2] & ~1);
+       } else
+           instr_out(data, hw_offset, 2, "Surface state not updated\n");
+
+       if (data[3] & 1) {
+           instr_out(data, hw_offset, 3, "Indirect state at 0x%08x\n",
+                     data[3] & ~1);
+       } else
+           instr_out(data, hw_offset, 3, "Indirect state not updated\n");
+
+       if (data[4] & 1) {
+           instr_out(data, hw_offset, 4, "General state upper bound 0x%08x\n",
+                     data[4] & ~1);
+       } else
+           instr_out(data, hw_offset, 4, "General state not updated\n");
+
+       if (data[5] & 1) {
+           instr_out(data, hw_offset, 5, "Indirect state upper bound 0x%08x\n",
+                     data[5] & ~1);
+       } else
+           instr_out(data, hw_offset, 5, "Indirect state not updated\n");
+
+       return len;
+    case 0x7800:
+       if (len != 7)
+           fprintf(out, "Bad count in 3DSTATE_PIPELINED_POINTERS\n");
+       if (count < 7)
+           BUFFER_FAIL(count, len, "3DSTATE_PIPELINED_POINTERS");
+
+       instr_out(data, hw_offset, 0,
+                 "3DSTATE_PIPELINED_POINTERS\n");
+       instr_out(data, hw_offset, 1, "VS state\n");
+       instr_out(data, hw_offset, 2, "GS state\n");
+       instr_out(data, hw_offset, 3, "Clip state\n");
+       instr_out(data, hw_offset, 4, "SF state\n");
+       instr_out(data, hw_offset, 5, "WM state\n");
+       instr_out(data, hw_offset, 6, "CC state\n");
+       return len;
+    case 0x7801:
+       if (len != 6)
+           fprintf(out, "Bad count in 3DSTATE_BINDING_TABLE_POINTERS\n");
+       if (count < 6)
+           BUFFER_FAIL(count, len, "3DSTATE_BINDING_TABLE_POINTERS");
+
+       instr_out(data, hw_offset, 0,
+                 "3DSTATE_BINDING_TABLE_POINTERS\n");
+       instr_out(data, hw_offset, 1, "VS binding table\n");
+       instr_out(data, hw_offset, 2, "GS binding table\n");
+       instr_out(data, hw_offset, 3, "Clip binding table\n");
+       instr_out(data, hw_offset, 4, "SF binding table\n");
+       instr_out(data, hw_offset, 5, "WM binding table\n");
+
+       return len;
+
+    case 0x7808:
+       len = (data[0] & 0xff) + 2;
+       if ((len - 1) % 4 != 0)
+           fprintf(out, "Bad count in 3DSTATE_VERTEX_BUFFERS\n");
+       if (count < len)
+           BUFFER_FAIL(count, len, "3DSTATE_VERTEX_BUFFERS");
+       instr_out(data, hw_offset, 0, "3DSTATE_VERTEX_BUFFERS\n");
+
+       for (i = 1; i < len;) {
+           instr_out(data, hw_offset, i, "buffer %d: %s, pitch %db\n",
+                     data[i] >> 27,
+                     data[i] & (1 << 26) ? "random" : "sequential",
+                     data[i] & 0x07ff);
+           i++;
+           instr_out(data, hw_offset, i++, "buffer address\n");
+           instr_out(data, hw_offset, i++, "max index\n");
+           instr_out(data, hw_offset, i++, "mbz\n");
+       }
+       return len;
+
+    case 0x7809:
+       len = (data[0] & 0xff) + 2;
+       if ((len + 1) % 2 != 0)
+           fprintf(out, "Bad count in 3DSTATE_VERTEX_ELEMENTS\n");
+       if (count < len)
+           BUFFER_FAIL(count, len, "3DSTATE_VERTEX_ELEMENTS");
+       instr_out(data, hw_offset, 0, "3DSTATE_VERTEX_ELEMENTS\n");
+
+       for (i = 1; i < len;) {
+           instr_out(data, hw_offset, i, "buffer %d: %svalid, type 0x%04x, "
+                     "src offset 0x%04x bytes\n",
+                     data[i] >> 27,
+                     data[i] & (1 << 26) ? "" : "in",
+                     (data[i] >> 16) & 0x1ff,
+                     data[i] & 0x07ff);
+           i++;
+           instr_out(data, hw_offset, i, "(%s, %s, %s, %s), "
+                     "dst offset 0x%02x bytes\n",
+                     get_965_element_component(data[i], 0),
+                     get_965_element_component(data[i], 1),
+                     get_965_element_component(data[i], 2),
+                     get_965_element_component(data[i], 3),
+                     (data[i] & 0xff) * 4);
+           i++;
+       }
+       return len;
+
+    case 0x780a:
+       len = (data[0] & 0xff) + 2;
+       if (len != 3)
+           fprintf(out, "Bad count in 3DSTATE_INDEX_BUFFER\n");
+       if (count < len)
+           BUFFER_FAIL(count, len, "3DSTATE_INDEX_BUFFER");
+       instr_out(data, hw_offset, 0, "3DSTATE_INDEX_BUFFER\n");
+       instr_out(data, hw_offset, 1, "beginning buffer address\n");
+       instr_out(data, hw_offset, 2, "ending buffer address\n");
+       return len;
+
+    case 0x7900:
+       if (len != 4)
+           fprintf(out, "Bad count in 3DSTATE_DRAWING_RECTANGLE\n");
+       if (count < 4)
+           BUFFER_FAIL(count, len, "3DSTATE_DRAWING_RECTANGLE");
+
+       instr_out(data, hw_offset, 0,
+                 "3DSTATE_DRAWING_RECTANGLE\n");
+       instr_out(data, hw_offset, 1, "top left: %d,%d\n",
+                 data[1] & 0xffff,
+                 (data[1] >> 16) & 0xffff);
+       instr_out(data, hw_offset, 2, "bottom right: %d,%d\n",
+                 data[2] & 0xffff,
+                 (data[2] >> 16) & 0xffff);
+       instr_out(data, hw_offset, 3, "origin: %d,%d\n",
+                 (int)data[3] & 0xffff,
+                 ((int)data[3] >> 16) & 0xffff);
+
+       return len;
+
+    case 0x7905:
+       if (len != 5 && len != 6)
+           fprintf(out, "Bad count in 3DSTATE_DEPTH_BUFFER\n");
+       if (count < len)
+           BUFFER_FAIL(count, len, "3DSTATE_DEPTH_BUFFER");
+
+       instr_out(data, hw_offset, 0,
+                 "3DSTATE_DEPTH_BUFFER\n");
+       instr_out(data, hw_offset, 1, "%s, %s, pitch = %d bytes, %stiled\n",
+                 get_965_surfacetype(data[1] >> 29),
+                 get_965_depthformat((data[1] >> 18) & 0x7),
+                 (data[1] & 0x0001ffff) + 1,
+                 data[1] & (1 << 27) ? "" : "not ");
+       instr_out(data, hw_offset, 2, "depth offset\n");
+       instr_out(data, hw_offset, 3, "%dx%d\n",
+                 ((data[3] & 0x0007ffc0) >> 6) + 1,
+                 ((data[3] & 0xfff80000) >> 19) + 1);
+       instr_out(data, hw_offset, 4, "volume depth\n");
+       if (len == 6)
+           instr_out(data, hw_offset, 5, "\n");
+
+       return len;
+
+    case 0x7b00:
+       len = (data[0] & 0xff) + 2;
+       if (len != 6)
+           fprintf(out, "Bad count in 3DPRIMITIVE\n");
+       if (count < len)
+           BUFFER_FAIL(count, len, "3DPRIMITIVE");
+
+       instr_out(data, hw_offset, 0,
+                 "3DPRIMITIVE: %s %s\n",
+                 get_965_prim_type(data[0]),
+                 (data[0] & (1 << 15)) ? "random" : "sequential");
+       instr_out(data, hw_offset, 1, "vertex count\n");
+       instr_out(data, hw_offset, 2, "start vertex\n");
+       instr_out(data, hw_offset, 3, "instance count\n");
+       instr_out(data, hw_offset, 4, "start instance\n");
+       instr_out(data, hw_offset, 5, "index bias\n");
+       return len;
+    }
+
+    for (opcode = 0; opcode < sizeof(opcodes_3d) / sizeof(opcodes_3d[0]);
+        opcode++) {
+       if ((data[0] & 0xffff0000) >> 16 == opcodes_3d[opcode].opcode) {
+           unsigned int i;
+           len = 1;
+
+           instr_out(data, hw_offset, 0, "%s\n", opcodes_3d[opcode].name);
+           if (opcodes_3d[opcode].max_len > 1) {
+               len = (data[0] & 0xff) + 2;
+               if (len < opcodes_3d[opcode].min_len ||
+                   len > opcodes_3d[opcode].max_len)
+               {
+                   fprintf(out, "Bad count in %s\n", opcodes_3d[opcode].name);
+               }
+           }
+
+           for (i = 1; i < len; i++) {
+               if (i >= count)
+                   BUFFER_FAIL(count, len, opcodes_3d[opcode].name);
+               instr_out(data, hw_offset, i, "dword %d\n", i);
+           }
+           return len;
+       }
+    }
+
+    instr_out(data, hw_offset, 0, "3D UNKNOWN\n");
+    (*failures)++;
+    return 1;
+}
+
+static int
+decode_3d_i830(const uint32_t *data, int count, uint32_t hw_offset, int *failures)
+{
+    unsigned int opcode;
+
+    struct {
+       uint32_t opcode;
+       int min_len;
+       int max_len;
+       char *name;
+    } opcodes_3d[] = {
+       { 0x02, 1, 1, "3DSTATE_MODES_3" },
+       { 0x03, 1, 1, "3DSTATE_ENABLES_1"},
+       { 0x04, 1, 1, "3DSTATE_ENABLES_2"},
+       { 0x05, 1, 1, "3DSTATE_VFT0"},
+       { 0x06, 1, 1, "3DSTATE_AA"},
+       { 0x07, 1, 1, "3DSTATE_RASTERIZATION_RULES" },
+       { 0x08, 1, 1, "3DSTATE_MODES_1" },
+       { 0x09, 1, 1, "3DSTATE_STENCIL_TEST" },
+       { 0x0a, 1, 1, "3DSTATE_VFT1"},
+       { 0x0b, 1, 1, "3DSTATE_INDPT_ALPHA_BLEND" },
+       { 0x0c, 1, 1, "3DSTATE_MODES_5" },
+       { 0x0d, 1, 1, "3DSTATE_MAP_BLEND_OP" },
+       { 0x0e, 1, 1, "3DSTATE_MAP_BLEND_ARG" },
+       { 0x0f, 1, 1, "3DSTATE_MODES_2" },
+       { 0x15, 1, 1, "3DSTATE_FOG_COLOR" },
+       { 0x16, 1, 1, "3DSTATE_MODES_4" },
+    };
+
+    switch ((data[0] & 0x1f000000) >> 24) {
+    case 0x1f:
+       return decode_3d_primitive(data, count, hw_offset, failures);
+    case 0x1d:
+       return decode_3d_1d(data, count, hw_offset, failures, 1);
+    case 0x1c:
+       return decode_3d_1c(data, count, hw_offset, failures);
+    }
+
+    for (opcode = 0; opcode < sizeof(opcodes_3d) / sizeof(opcodes_3d[0]);
+        opcode++) {
+       if ((data[0] & 0x1f000000) >> 24 == opcodes_3d[opcode].opcode) {
+           unsigned int len = 1, i;
+
+           instr_out(data, hw_offset, 0, "%s\n", opcodes_3d[opcode].name);
+           if (opcodes_3d[opcode].max_len > 1) {
+               len = (data[0] & 0xff) + 2;
+               if (len < opcodes_3d[opcode].min_len ||
+                   len > opcodes_3d[opcode].max_len)
+               {
+                   fprintf(out, "Bad count in %s\n", opcodes_3d[opcode].name);
+               }
+           }
+
+           for (i = 1; i < len; i++) {
+               if (i >= count)
+                   BUFFER_FAIL(count, len, opcodes_3d[opcode].name);
+               instr_out(data, hw_offset, i, "dword %d\n", i);
+           }
+           return len;
+       }
+    }
+
+    instr_out(data, hw_offset, 0, "3D UNKNOWN\n");
+    (*failures)++;
+    return 1;
+}
+
+/**
+ * Decodes an i830-i915 batch buffer, writing the output to stdout.
+ *
+ * \param data batch buffer contents
+ * \param count number of DWORDs to decode in the batch buffer
+ * \param hw_offset hardware address for the buffer
+ */
+int
+intel_decode(const uint32_t *data, int count, uint32_t hw_offset, uint32_t devid)
+{
+    int index = 0;
+    int failures = 0;
+
+    out = stderr;
+
+    while (index < count) {
+       switch ((data[index] & 0xe0000000) >> 29) {
+       case 0x0:
+           index += decode_mi(data + index, count - index,
+                              hw_offset + index * 4, &failures);
+           break;
+       case 0x2:
+           index += decode_2d(data + index, count - index,
+                              hw_offset + index * 4, &failures);
+           break;
+       case 0x3:
+           if (IS_965(devid)) {
+               index += decode_3d_965(data + index, count - index,
+                                      hw_offset + index * 4, &failures);
+           } else if (IS_9XX(devid)) {
+               index += decode_3d(data + index, count - index,
+                                  hw_offset + index * 4, &failures);
+           } else {
+               index += decode_3d_i830(data + index, count - index,
+                                       hw_offset + index * 4, &failures);
+           }
+           break;
+       default:
+           instr_out(data, hw_offset, index, "UNKNOWN\n");
+           failures++;
+           index++;
+           break;
+       }
+       fflush(out);
+    }
+
+    return failures;
+}
+
+void intel_decode_context_reset(void)
+{
+    saved_s2_set = 0;
+    saved_s4_set = 1;
+}
+
diff --git a/src/gallium/drivers/i965/intel_decode.h b/src/gallium/drivers/i965/intel_decode.h
new file mode 100644 (file)
index 0000000..7683097
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright © 2007 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ *    Eric Anholt <eric@anholt.net>
+ *
+ */
+
+int intel_decode(const uint32_t *data, int count, uint32_t hw_offset, uint32_t devid);
+void intel_decode_context_reset(void);
diff --git a/src/gallium/drivers/i965/intel_structs.h b/src/gallium/drivers/i965/intel_structs.h
new file mode 100644 (file)
index 0000000..522e3bd
--- /dev/null
@@ -0,0 +1,132 @@
+#ifndef INTEL_STRUCTS_H
+#define INTEL_STRUCTS_H
+
+struct br0 {
+   GLuint length:8;
+   GLuint pad0:3;
+   GLuint dst_tiled:1;
+   GLuint pad1:8;
+   GLuint write_rgb:1;
+   GLuint write_alpha:1;
+   GLuint opcode:7;
+   GLuint client:3;
+};
+
+   
+struct br13 {
+   GLint dest_pitch:16;
+   GLuint rop:8;
+   GLuint color_depth:2;
+   GLuint pad1:3;
+   GLuint mono_source_transparency:1;
+   GLuint clipping_enable:1;
+   GLuint pad0:1;
+};
+
+
+
+/* This is an attempt to move some of the 2D interaction in this
+ * driver to using structs for packets rather than a bunch of #defines
+ * and dwords.
+ */
+struct xy_color_blit {
+   struct br0 br0;
+   struct br13 br13;
+
+   struct {
+      GLuint dest_x1:16;
+      GLuint dest_y1:16;
+   } dw2;
+
+   struct {
+      GLuint dest_x2:16;
+      GLuint dest_y2:16;
+   } dw3;
+   
+   GLuint dest_base_addr;
+   GLuint color;
+};
+
+struct xy_src_copy_blit {
+   struct br0 br0;
+   struct br13 br13;
+
+   struct {
+      GLuint dest_x1:16;
+      GLuint dest_y1:16;
+   } dw2;
+
+   struct {
+      GLuint dest_x2:16;
+      GLuint dest_y2:16;
+   } dw3;
+   
+   GLuint dest_base_addr;
+
+   struct {
+      GLuint src_x1:16;
+      GLuint src_y1:16;
+   } dw5;
+
+   struct {
+      GLint src_pitch:16;
+      GLuint pad:16;
+   } dw6;
+   
+   GLuint src_base_addr;
+};
+
+struct xy_setup_blit {
+   struct br0 br0;
+   struct br13 br13;
+
+   struct {
+      GLuint clip_x1:16;
+      GLuint clip_y1:16;
+   } dw2;
+
+   struct {
+      GLuint clip_x2:16;
+      GLuint clip_y2:16;
+   } dw3;
+      
+   GLuint dest_base_addr;
+   GLuint background_color;
+   GLuint foreground_color;
+   GLuint pattern_base_addr;
+};
+
+
+struct xy_text_immediate_blit {
+   struct {
+      GLuint length:8;
+      GLuint pad2:3;
+      GLuint dst_tiled:1;
+      GLuint pad1:4;
+      GLuint byte_packed:1;
+      GLuint pad0:5;
+      GLuint opcode:7;
+      GLuint client:3;
+   } dw0;
+
+   struct {
+      GLuint dest_x1:16;
+      GLuint dest_y1:16;
+   } dw1;
+
+   struct {
+      GLuint dest_x2:16;
+      GLuint dest_y2:16;
+   } dw2;   
+
+   /* Src bitmap data follows as inline dwords.
+    */
+};
+
+
+#define CLIENT_2D 0x2
+#define OPCODE_XY_SETUP_BLT 0x1
+#define OPCODE_XY_COLOR_BLT 0x50
+#define OPCODE_XY_TEXT_IMMEDIATE_BLT 0x31
+
+#endif
index 4e700089e331010ae0d717858a08a73e360f9387..9f5b4e63236ba785c3de9f7143f833d861704864 100644 (file)
@@ -46,17 +46,6 @@ identity_destroy(struct pipe_context *_pipe)
 }
 
 static void
-identity_set_edgeflags(struct pipe_context *_pipe,
-                       const unsigned *bitfield)
-{
-   struct identity_context *id_pipe = identity_context(_pipe);
-   struct pipe_context *pipe = id_pipe->pipe;
-
-   pipe->set_edgeflags(pipe,
-                       bitfield);
-}
-
-static boolean
 identity_draw_arrays(struct pipe_context *_pipe,
                      unsigned prim,
                      unsigned start,
@@ -65,13 +54,13 @@ identity_draw_arrays(struct pipe_context *_pipe,
    struct identity_context *id_pipe = identity_context(_pipe);
    struct pipe_context *pipe = id_pipe->pipe;
 
-   return pipe->draw_arrays(pipe,
-                            prim,
-                            start,
-                            count);
+   pipe->draw_arrays(pipe,
+                     prim,
+                     start,
+                     count);
 }
 
-static boolean
+static void
 identity_draw_elements(struct pipe_context *_pipe,
                        struct pipe_buffer *_indexBuffer,
                        unsigned indexSize,
@@ -84,15 +73,15 @@ identity_draw_elements(struct pipe_context *_pipe,
    struct pipe_context *pipe = id_pipe->pipe;
    struct pipe_buffer *indexBuffer = id_buffer->buffer;
 
-   return pipe->draw_elements(pipe,
-                              indexBuffer,
-                              indexSize,
-                              prim,
-                              start,
-                              count);
+   pipe->draw_elements(pipe,
+                       indexBuffer,
+                       indexSize,
+                       prim,
+                       start,
+                       count);
 }
 
-static boolean
+static void
 identity_draw_range_elements(struct pipe_context *_pipe,
                              struct pipe_buffer *_indexBuffer,
                              unsigned indexSize,
@@ -107,14 +96,14 @@ identity_draw_range_elements(struct pipe_context *_pipe,
    struct pipe_context *pipe = id_pipe->pipe;
    struct pipe_buffer *indexBuffer = id_buffer->buffer;
 
-   return pipe->draw_range_elements(pipe,
-                                    indexBuffer,
-                                    indexSize,
-                                    minIndex,
-                                    maxIndex,
-                                    mode,
-                                    start,
-                                    count);
+   pipe->draw_range_elements(pipe,
+                             indexBuffer,
+                             indexSize,
+                             minIndex,
+                             maxIndex,
+                             mode,
+                             start,
+                             count);
 }
 
 static struct pipe_query *
@@ -221,16 +210,29 @@ identity_create_sampler_state(struct pipe_context *_pipe,
 }
 
 static void
-identity_bind_sampler_states(struct pipe_context *_pipe,
-                             unsigned num,
-                             void **samplers)
+identity_bind_fragment_sampler_states(struct pipe_context *_pipe,
+                                      unsigned num_samplers,
+                                      void **samplers)
+{
+   struct identity_context *id_pipe = identity_context(_pipe);
+   struct pipe_context *pipe = id_pipe->pipe;
+
+   pipe->bind_fragment_sampler_states(pipe,
+                                      num_samplers,
+                                      samplers);
+}
+
+static void
+identity_bind_vertex_sampler_states(struct pipe_context *_pipe,
+                                    unsigned num_samplers,
+                                    void **samplers)
 {
    struct identity_context *id_pipe = identity_context(_pipe);
    struct pipe_context *pipe = id_pipe->pipe;
 
-   pipe->bind_sampler_states(pipe,
-                             num,
-                             samplers);
+   pipe->bind_vertex_sampler_states(pipe,
+                                    num_samplers,
+                                    samplers);
 }
 
 static void
@@ -480,9 +482,9 @@ identity_set_viewport_state(struct pipe_context *_pipe,
 }
 
 static void
-identity_set_sampler_textures(struct pipe_context *_pipe,
-                              unsigned num_textures,
-                              struct pipe_texture **_textures)
+identity_set_fragment_sampler_textures(struct pipe_context *_pipe,
+                                       unsigned num_textures,
+                                       struct pipe_texture **_textures)
 {
    struct identity_context *id_pipe = identity_context(_pipe);
    struct pipe_context *pipe = id_pipe->pipe;
@@ -499,9 +501,34 @@ identity_set_sampler_textures(struct pipe_context *_pipe,
       textures = unwrapped_textures;
    }
 
-   pipe->set_sampler_textures(pipe,
-                              num_textures,
-                              textures);
+   pipe->set_fragment_sampler_textures(pipe,
+                                       num_textures,
+                                       textures);
+}
+
+static void
+identity_set_vertex_sampler_textures(struct pipe_context *_pipe,
+                                     unsigned num_textures,
+                                     struct pipe_texture **_textures)
+{
+   struct identity_context *id_pipe = identity_context(_pipe);
+   struct pipe_context *pipe = id_pipe->pipe;
+   struct pipe_texture *unwrapped_textures[PIPE_MAX_VERTEX_SAMPLERS];
+   struct pipe_texture **textures = NULL;
+   unsigned i;
+
+   if (_textures) {
+      for (i = 0; i < num_textures; i++)
+         unwrapped_textures[i] = identity_texture_unwrap(_textures[i]);
+      for (; i < PIPE_MAX_VERTEX_SAMPLERS; i++)
+         unwrapped_textures[i] = NULL;
+
+      textures = unwrapped_textures;
+   }
+
+   pipe->set_vertex_sampler_textures(pipe,
+                                     num_textures,
+                                     textures);
 }
 
 static void
@@ -669,7 +696,6 @@ identity_context_create(struct pipe_screen *_screen, struct pipe_context *pipe)
    id_pipe->base.draw = NULL;
 
    id_pipe->base.destroy = identity_destroy;
-   id_pipe->base.set_edgeflags = identity_set_edgeflags;
    id_pipe->base.draw_arrays = identity_draw_arrays;
    id_pipe->base.draw_elements = identity_draw_elements;
    id_pipe->base.draw_range_elements = identity_draw_range_elements;
@@ -682,7 +708,8 @@ identity_context_create(struct pipe_screen *_screen, struct pipe_context *pipe)
    id_pipe->base.bind_blend_state = identity_bind_blend_state;
    id_pipe->base.delete_blend_state = identity_delete_blend_state;
    id_pipe->base.create_sampler_state = identity_create_sampler_state;
-   id_pipe->base.bind_sampler_states = identity_bind_sampler_states;
+   id_pipe->base.bind_fragment_sampler_states = identity_bind_fragment_sampler_states;
+   id_pipe->base.bind_vertex_sampler_states = identity_bind_vertex_sampler_states;
    id_pipe->base.delete_sampler_state = identity_delete_sampler_state;
    id_pipe->base.create_rasterizer_state = identity_create_rasterizer_state;
    id_pipe->base.bind_rasterizer_state = identity_bind_rasterizer_state;
@@ -703,7 +730,8 @@ identity_context_create(struct pipe_screen *_screen, struct pipe_context *pipe)
    id_pipe->base.set_polygon_stipple = identity_set_polygon_stipple;
    id_pipe->base.set_scissor_state = identity_set_scissor_state;
    id_pipe->base.set_viewport_state = identity_set_viewport_state;
-   id_pipe->base.set_sampler_textures = identity_set_sampler_textures;
+   id_pipe->base.set_fragment_sampler_textures = identity_set_fragment_sampler_textures;
+   id_pipe->base.set_vertex_sampler_textures = identity_set_vertex_sampler_textures;
    id_pipe->base.set_vertex_buffers = identity_set_vertex_buffers;
    id_pipe->base.set_vertex_elements = identity_set_vertex_elements;
    id_pipe->base.surface_copy = identity_surface_copy;
index e893e59940816913b900de77329c730e59a803a8..bc9bc7121d58caf5ac2b23267d64c9c5e9b05f3b 100644 (file)
@@ -180,3 +180,42 @@ identity_transfer_destroy(struct identity_transfer *id_transfer)
    screen->tex_transfer_destroy(id_transfer->transfer);
    FREE(id_transfer);
 }
+
+struct pipe_video_surface *
+identity_video_surface_create(struct identity_screen *id_screen,
+                              struct pipe_video_surface *video_surface)
+{
+   struct identity_video_surface *id_video_surface;
+
+   if (!video_surface) {
+      goto error;
+   }
+
+   assert(video_surface->screen == id_screen->screen);
+
+   id_video_surface = CALLOC_STRUCT(identity_video_surface);
+   if (!id_video_surface) {
+      goto error;
+   }
+
+   memcpy(&id_video_surface->base,
+          video_surface,
+          sizeof(struct pipe_video_surface));
+
+   pipe_reference_init(&id_video_surface->base.reference, 1);
+   id_video_surface->base.screen = &id_screen->base;
+   id_video_surface->video_surface = video_surface;
+
+   return &id_video_surface->base;
+
+error:
+   pipe_video_surface_reference(&video_surface, NULL);
+   return NULL;
+}
+
+void
+identity_video_surface_destroy(struct identity_video_surface *id_video_surface)
+{
+   pipe_video_surface_reference(&id_video_surface->video_surface, NULL);
+   FREE(id_video_surface);
+}
index ce58faa3c7c813c1287ad04a9f5004f1d3f63bba..77cc7190798c75810cecfa076b8987ec6c95c7b4 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "pipe/p_compiler.h"
 #include "pipe/p_state.h"
+#include "pipe/p_video_state.h"
 
 #include "id_screen.h"
 
@@ -67,6 +68,14 @@ struct identity_transfer
 };
 
 
+struct identity_video_surface
+{
+   struct pipe_video_surface base;
+
+   struct pipe_video_surface *video_surface;
+};
+
+
 static INLINE struct identity_buffer *
 identity_buffer(struct pipe_buffer *_buffer)
 {
@@ -103,6 +112,15 @@ identity_transfer(struct pipe_transfer *_transfer)
    return (struct identity_transfer *)_transfer;
 }
 
+static INLINE struct identity_video_surface *
+identity_video_surface(struct pipe_video_surface *_video_surface)
+{
+   if (!_video_surface) {
+      return NULL;
+   }
+   (void)identity_screen(_video_surface->screen);
+   return (struct identity_video_surface *)_video_surface;
+}
 
 static INLINE struct pipe_buffer *
 identity_buffer_unwrap(struct pipe_buffer *_buffer)
@@ -165,5 +183,12 @@ identity_transfer_create(struct identity_texture *id_texture,
 void
 identity_transfer_destroy(struct identity_transfer *id_transfer);
 
+struct pipe_video_surface *
+identity_video_surface_create(struct identity_screen *id_screen,
+                              struct pipe_video_surface *video_surface);
+
+void
+identity_video_surface_destroy(struct identity_video_surface *id_video_surface);
+
 
 #endif /* ID_OBJECTS_H */
index cac14cfd60466db6b6827841017e236563e6ce42..3d2862eaa01e506ce5fe292bcb49feb93b767dc1 100644 (file)
@@ -37,4 +37,4 @@ identity_screen_create(struct pipe_screen *screen);
 struct pipe_context *
 identity_context_create(struct pipe_screen *screen, struct pipe_context *pipe);
 
-#endif /* PT_PUBLIC_H */
+#endif /* ID_PUBLIC_H */
index 26439637d08ffffeb98acb4d9a7c59bab458b592..53eae3ef5440c821bb78e1d9471befadaaa75b1d 100644 (file)
@@ -379,6 +379,33 @@ identity_screen_buffer_destroy(struct pipe_buffer *_buffer)
    identity_buffer_destroy(identity_buffer(_buffer));
 }
 
+static struct pipe_video_surface *
+identity_screen_video_surface_create(struct pipe_screen *_screen,
+                                     enum pipe_video_chroma_format chroma_format,
+                                     unsigned width,
+                                     unsigned height)
+{
+   struct identity_screen *id_screen = identity_screen(_screen);
+   struct pipe_screen *screen = id_screen->screen;
+   struct pipe_video_surface *result;
+
+   result = screen->video_surface_create(screen,
+                                         chroma_format,
+                                         width,
+                                         height);
+
+   if (result) {
+      return identity_video_surface_create(id_screen, result);
+   }
+   return NULL;
+}
+
+static void
+identity_screen_video_surface_destroy(struct pipe_video_surface *_vsfc)
+{
+   identity_video_surface_destroy(identity_video_surface(_vsfc));
+}
+
 static void
 identity_screen_flush_frontbuffer(struct pipe_screen *_screen,
                                   struct pipe_surface *_surface,
@@ -472,6 +499,12 @@ identity_screen_create(struct pipe_screen *screen)
    if (screen->buffer_unmap)
       id_screen->base.buffer_unmap = identity_screen_buffer_unmap;
    id_screen->base.buffer_destroy = identity_screen_buffer_destroy;
+   if (screen->video_surface_create) {
+      id_screen->base.video_surface_create = identity_screen_video_surface_create;
+   }
+   if (screen->video_surface_destroy) {
+      id_screen->base.video_surface_destroy = identity_screen_video_surface_destroy;
+   }
    id_screen->base.flush_frontbuffer = identity_screen_flush_frontbuffer;
    id_screen->base.fence_reference = identity_screen_fence_reference;
    id_screen->base.fence_signalled = identity_screen_fence_signalled;
index 6ec97046e15a4c57930dd789d310c513f5ba8c07..264999a7ceaa301ba335f713864d2da1cfd1670f 100644 (file)
@@ -19,10 +19,13 @@ C_SOURCES = \
        lp_bld_depth.c \
        lp_bld_flow.c \
        lp_bld_format_aos.c \
+       lp_bld_format_query.c \
        lp_bld_format_soa.c \
        lp_bld_interp.c \
        lp_bld_intr.c \
        lp_bld_logic.c \
+       lp_bld_pack.c \
+       lp_bld_sample.c \
        lp_bld_sample_soa.c \
        lp_bld_swizzle.c \
        lp_bld_struct.c \
@@ -58,6 +61,9 @@ C_SOURCES = \
        lp_texture.c \
        lp_tile_soa.c
 
+CPP_SOURCES = \
+       lp_bld_misc.cpp
+
 include ../../Makefile.template
 
 lp_tile_soa.c: lp_tile_soa.py ../../auxiliary/util/u_format_parse.py ../../auxiliary/util/u_format_access.py ../../auxiliary/util/u_format.csv
index 89d08834a3c408a4c78276024a6b1b5f6f1608ef..0c3f00fd58f89b69b57821c803a37d00f3b7c3aa 100644 (file)
@@ -51,21 +51,22 @@ Requirements
 
  - Linux
  
- - udis86, http://udis86.sourceforge.net/ . Use my repository, which decodes
-   opcodes not yet supported by upstream.
+ - A x86 or amd64 processor.  64bit mode is preferred.
  
-     git clone git://people.freedesktop.org/~jrfonseca/udis86
-     cd udis86
-     ./configure --with-pic
-     make
-     sudo make install
+   Support for sse2 is strongly encouraged.  Support for ssse3, and sse4.1 will
+   yield the most efficient code.  The less features the CPU has the more
+   likely is that you ran into underperforming, buggy, or incomplete code.  
+   
+   See /proc/cpuinfo to know what your CPU supports.
+ - LLVM 2.5 or greater. LLVM 2.6 is preferred.
  
- LLVM 2.5. On Debian based distributions do:
  On Debian based distributions do:
  
      aptitude install llvm-dev
 
-   There is a typo in one of the llvm-dev 2.5 headers, that causes compilation
-   errors in the debug build:
+   There is a typo in one of the llvm 2.5 headers, that may cause compilation
+   errors. To fix it apply the change:
 
      --- /usr/include/llvm-c/Core.h.orig       2009-08-10 15:38:54.000000000 +0100
      +++ /usr/include/llvm-c/Core.h    2009-08-10 15:38:25.000000000 +0100
@@ -79,12 +80,17 @@ Requirements
           #endif
           return reinterpret_cast<T**>(Vals);
  
- - A x86 or amd64 processor with support for sse2, sse3, and sse4.1 SIMD
-   instructions. This is necessary because we emit several SSE intrinsics for
-   convenience. See /proc/cpuinfo to know what your CPU supports.
- - scons
+ - scons (optional)
 
+ - udis86, http://udis86.sourceforge.net/ (optional):
+     git clone git://udis86.git.sourceforge.net/gitroot/udis86/udis86
+     cd udis86
+     ./autogen.sh
+     ./configure --with-pic
+     make
+     sudo make install
 
 Building
 ========
index ae4303bd24ff6f9f4ba0ba9b1d773475e8d71707..5af77c4a12d68c5eaaef4e8085f18bae238fad01 100644 (file)
@@ -9,6 +9,8 @@ if not env.has_key('LLVM_VERSION'):
 
 env.Tool('udis86')
 
+env.Append(CPPPATH = ['.'])
+
 env.CodeGenerate(
        target = 'lp_tile_soa.c',
        script = 'lp_tile_soa.py',
@@ -30,10 +32,14 @@ llvmpipe = env.ConvenienceLibrary(
                'lp_bld_depth.c',
                'lp_bld_flow.c',
                'lp_bld_format_aos.c',
+        'lp_bld_format_query.c',
                'lp_bld_format_soa.c',
                'lp_bld_interp.c',
                'lp_bld_intr.c',
                'lp_bld_logic.c',
+               'lp_bld_misc.cpp',
+        'lp_bld_pack.c',
+        'lp_bld_sample.c',
                'lp_bld_sample_soa.c',
                'lp_bld_struct.c',
                'lp_bld_swizzle.c',
@@ -75,21 +81,19 @@ llvmpipe = env.ConvenienceLibrary(
 
 env = env.Clone()
 
-env.Prepend(LIBS = [llvmpipe] + auxiliaries)
+env.Prepend(LIBS = [llvmpipe] + gallium)
 
-env.Program(
-    target = 'lp_test_format',
-    source = ['lp_test_format.c'],
-)
+tests = [
+    'format',
+    'blend',
+    'conv',
+]
 
-env.Program(
-    target = 'lp_test_blend',
-    source = ['lp_test_blend.c', 'lp_test_main.c'],
-)
-
-env.Program(
-    target = 'lp_test_conv',
-    source = ['lp_test_conv.c', 'lp_test_main.c'],
-)
+for test in tests:
+    target = env.Program(
+        target = 'lp_test_' + test,
+        source = ['lp_test_' + test + '.c', 'lp_test_main.c'],
+    )
+    env.InstallProgram(target)
 
 Export('llvmpipe')
index f8260938f5a337048a6fa1cc4afc94180813895b..2df86dd32e50e63476af819728907994ea7988a9 100644 (file)
@@ -47,6 +47,7 @@
 
 #include "util/u_memory.h"
 #include "util/u_debug.h"
+#include "util/u_math.h"
 #include "util/u_string.h"
 #include "util/u_cpu_detect.h"
 
@@ -54,6 +55,7 @@
 #include "lp_bld_const.h"
 #include "lp_bld_intr.h"
 #include "lp_bld_logic.h"
+#include "lp_bld_pack.h"
 #include "lp_bld_debug.h"
 #include "lp_bld_arit.h"
 
@@ -279,45 +281,6 @@ lp_build_sub(struct lp_build_context *bld,
 }
 
 
-/**
- * Build shuffle vectors that match PUNPCKLxx and PUNPCKHxx instructions.
- */
-static LLVMValueRef 
-lp_build_unpack_shuffle(unsigned n, unsigned lo_hi)
-{
-   LLVMValueRef elems[LP_MAX_VECTOR_LENGTH];
-   unsigned i, j;
-
-   assert(n <= LP_MAX_VECTOR_LENGTH);
-   assert(lo_hi < 2);
-
-   for(i = 0, j = lo_hi*n/2; i < n; i += 2, ++j) {
-      elems[i + 0] = LLVMConstInt(LLVMInt32Type(), 0 + j, 0);
-      elems[i + 1] = LLVMConstInt(LLVMInt32Type(), n + j, 0);
-   }
-
-   return LLVMConstVector(elems, n);
-}
-
-
-/**
- * Build constant int vector of width 'n' and value 'c'.
- */
-static LLVMValueRef 
-lp_build_const_vec(LLVMTypeRef type, unsigned n, long long c)
-{
-   LLVMValueRef elems[LP_MAX_VECTOR_LENGTH];
-   unsigned i;
-
-   assert(n <= LP_MAX_VECTOR_LENGTH);
-
-   for(i = 0; i < n; ++i)
-      elems[i] = LLVMConstInt(type, c, 0);
-
-   return LLVMConstVector(elems, n);
-}
-
-
 /**
  * Normalized 8bit multiplication.
  *
@@ -361,33 +324,30 @@ lp_build_const_vec(LLVMTypeRef type, unsigned n, long long c)
  */
 static LLVMValueRef
 lp_build_mul_u8n(LLVMBuilderRef builder,
+                 struct lp_type i16_type,
                  LLVMValueRef a, LLVMValueRef b)
 {
-   static LLVMValueRef c01 = NULL;
-   static LLVMValueRef c08 = NULL;
-   static LLVMValueRef c80 = NULL;
+   LLVMValueRef c8;
    LLVMValueRef ab;
 
-   if(!c01) c01 = lp_build_const_vec(LLVMInt16Type(), 8, 0x01);
-   if(!c08) c08 = lp_build_const_vec(LLVMInt16Type(), 8, 0x08);
-   if(!c80) c80 = lp_build_const_vec(LLVMInt16Type(), 8, 0x80);
+   c8 = lp_build_int_const_scalar(i16_type, 8);
    
 #if 0
    
    /* a*b/255 ~= (a*(b + 1)) >> 256 */
-   b = LLVMBuildAdd(builder, b, c01, "");
+   b = LLVMBuildAdd(builder, b, lp_build_int_const_scalar(i16_type, 1), "");
    ab = LLVMBuildMul(builder, a, b, "");
 
 #else
    
-   /* t/255 ~= (t + (t >> 8) + 0x80) >> 8 */
+   /* ab/255 ~= (ab + (ab >> 8) + 0x80) >> 8 */
    ab = LLVMBuildMul(builder, a, b, "");
-   ab = LLVMBuildAdd(builder, ab, LLVMBuildLShr(builder, ab, c08, ""), "");
-   ab = LLVMBuildAdd(builder, ab, c80, "");
+   ab = LLVMBuildAdd(builder, ab, LLVMBuildLShr(builder, ab, c8, ""), "");
+   ab = LLVMBuildAdd(builder, ab, lp_build_int_const_scalar(i16_type, 0x80), "");
 
 #endif
    
-   ab = LLVMBuildLShr(builder, ab, c08, "");
+   ab = LLVMBuildLShr(builder, ab, c8, "");
 
    return ab;
 }
@@ -402,6 +362,8 @@ lp_build_mul(struct lp_build_context *bld,
              LLVMValueRef b)
 {
    const struct lp_type type = bld->type;
+   LLVMValueRef shift;
+   LLVMValueRef res;
 
    if(a == bld->zero)
       return bld->zero;
@@ -415,39 +377,18 @@ lp_build_mul(struct lp_build_context *bld,
       return bld->undef;
 
    if(!type.floating && !type.fixed && type.norm) {
-      if(util_cpu_caps.has_sse2 && type.width == 8 && type.length == 16) {
-         LLVMTypeRef i16x8 = LLVMVectorType(LLVMInt16Type(), 8);
-         LLVMTypeRef i8x16 = LLVMVectorType(LLVMInt8Type(), 16);
-         static LLVMValueRef ml = NULL;
-         static LLVMValueRef mh = NULL;
-         LLVMValueRef al, ah, bl, bh;
-         LLVMValueRef abl, abh;
-         LLVMValueRef ab;
-         
-         if(!ml) ml = lp_build_unpack_shuffle(16, 0);
-         if(!mh) mh = lp_build_unpack_shuffle(16, 1);
-
-         /*  PUNPCKLBW, PUNPCKHBW */
-         al = LLVMBuildShuffleVector(bld->builder, a, bld->zero, ml, "");
-         bl = LLVMBuildShuffleVector(bld->builder, b, bld->zero, ml, "");
-         ah = LLVMBuildShuffleVector(bld->builder, a, bld->zero, mh, "");
-         bh = LLVMBuildShuffleVector(bld->builder, b, bld->zero, mh, "");
+      if(type.width == 8) {
+         struct lp_type i16_type = lp_wider_type(type);
+         LLVMValueRef al, ah, bl, bh, abl, abh, ab;
 
-         /* NOP */
-         al = LLVMBuildBitCast(bld->builder, al, i16x8, "");
-         bl = LLVMBuildBitCast(bld->builder, bl, i16x8, "");
-         ah = LLVMBuildBitCast(bld->builder, ah, i16x8, "");
-         bh = LLVMBuildBitCast(bld->builder, bh, i16x8, "");
+         lp_build_unpack2(bld->builder, type, i16_type, a, &al, &ah);
+         lp_build_unpack2(bld->builder, type, i16_type, b, &bl, &bh);
 
          /* PMULLW, PSRLW, PADDW */
-         abl = lp_build_mul_u8n(bld->builder, al, bl);
-         abh = lp_build_mul_u8n(bld->builder, ah, bh);
+         abl = lp_build_mul_u8n(bld->builder, i16_type, al, bl);
+         abh = lp_build_mul_u8n(bld->builder, i16_type, ah, bh);
 
-         /* PACKUSWB */
-         ab = lp_build_intrinsic_binary(bld->builder, "llvm.x86.sse2.packuswb.128" , i16x8, abl, abh);
-
-         /* NOP */
-         ab = LLVMBuildBitCast(bld->builder, ab, i8x16, "");
+         ab = lp_build_pack2(bld->builder, i16_type, type, abl, abh);
          
          return ab;
       }
@@ -456,10 +397,84 @@ lp_build_mul(struct lp_build_context *bld,
       assert(0);
    }
 
-   if(LLVMIsConstant(a) && LLVMIsConstant(b))
-      return LLVMConstMul(a, b);
+   if(type.fixed)
+      shift = lp_build_int_const_scalar(type, type.width/2);
+   else
+      shift = NULL;
+
+   if(LLVMIsConstant(a) && LLVMIsConstant(b)) {
+      res =  LLVMConstMul(a, b);
+      if(shift) {
+         if(type.sign)
+            res = LLVMConstAShr(res, shift);
+         else
+            res = LLVMConstLShr(res, shift);
+      }
+   }
+   else {
+      res = LLVMBuildMul(bld->builder, a, b, "");
+      if(shift) {
+         if(type.sign)
+            res = LLVMBuildAShr(bld->builder, res, shift, "");
+         else
+            res = LLVMBuildLShr(bld->builder, res, shift, "");
+      }
+   }
+
+   return res;
+}
+
+
+/**
+ * Small vector x scale multiplication optimization.
+ */
+LLVMValueRef
+lp_build_mul_imm(struct lp_build_context *bld,
+                 LLVMValueRef a,
+                 int b)
+{
+   LLVMValueRef factor;
+
+   if(b == 0)
+      return bld->zero;
 
-   return LLVMBuildMul(bld->builder, a, b, "");
+   if(b == 1)
+      return a;
+
+   if(b == -1)
+      return LLVMBuildNeg(bld->builder, a, "");
+
+   if(b == 2 && bld->type.floating)
+      return lp_build_add(bld, a, a);
+
+   if(util_is_pot(b)) {
+      unsigned shift = ffs(b) - 1;
+
+      if(bld->type.floating) {
+#if 0
+         /*
+          * Power of two multiplication by directly manipulating the mantissa.
+          *
+          * XXX: This might not be always faster, it will introduce a small error
+          * for multiplication by zero, and it will produce wrong results
+          * for Inf and NaN.
+          */
+         unsigned mantissa = lp_mantissa(bld->type);
+         factor = lp_build_int_const_scalar(bld->type, (unsigned long long)shift << mantissa);
+         a = LLVMBuildBitCast(bld->builder, a, lp_build_int_vec_type(bld->type), "");
+         a = LLVMBuildAdd(bld->builder, a, factor, "");
+         a = LLVMBuildBitCast(bld->builder, a, lp_build_vec_type(bld->type), "");
+         return a;
+#endif
+      }
+      else {
+         factor = lp_build_const_scalar(bld->type, shift);
+         return LLVMBuildShl(bld->builder, a, factor, "");
+      }
+   }
+
+   factor = lp_build_const_scalar(bld->type, (double)b);
+   return lp_build_mul(bld, a, factor);
 }
 
 
@@ -494,13 +509,36 @@ lp_build_div(struct lp_build_context *bld,
 }
 
 
+/**
+ * Linear interpolation.
+ *
+ * This also works for integer values with a few caveats.
+ *
+ * @sa http://www.stereopsis.com/doubleblend.html
+ */
 LLVMValueRef
 lp_build_lerp(struct lp_build_context *bld,
               LLVMValueRef x,
               LLVMValueRef v0,
               LLVMValueRef v1)
 {
-   return lp_build_add(bld, v0, lp_build_mul(bld, x, lp_build_sub(bld, v1, v0)));
+   LLVMValueRef delta;
+   LLVMValueRef res;
+
+   delta = lp_build_sub(bld, v1, v0);
+
+   res = lp_build_mul(bld, x, delta);
+
+   res = lp_build_add(bld, v0, res);
+
+   if(bld->type.fixed)
+      /* XXX: This step is necessary for lerping 8bit colors stored on 16bits,
+       * but it will be wrong for other uses. Basically we need a more
+       * powerful lp_type, capable of further distinguishing the values
+       * interpretation from the value storage. */
+      res = LLVMBuildAnd(bld->builder, res, lp_build_int_const_scalar(bld->type, (1 << bld->type.width/2) - 1), "");
+
+   return res;
 }
 
 
@@ -1046,7 +1084,7 @@ lp_build_log(struct lp_build_context *bld,
              LLVMValueRef x)
 {
    /* log(2) */
-   LLVMValueRef log2 = lp_build_const_scalar(bld->type, 1.4426950408889634);
+   LLVMValueRef log2 = lp_build_const_scalar(bld->type, 0.69314718055994529);
 
    return lp_build_mul(bld, log2, lp_build_exp2(bld, x));
 }
@@ -1058,7 +1096,7 @@ lp_build_log(struct lp_build_context *bld,
 
 /**
  * Generate polynomial.
- * Ex:  x^2 * coeffs[0] + x * coeffs[1] + coeffs[2].
+ * Ex:  coeffs[0] + x * coeffs[1] + x^2 * coeffs[2].
  */
 static LLVMValueRef
 lp_build_polynomial(struct lp_build_context *bld,
@@ -1248,13 +1286,13 @@ lp_build_log2_approx(struct lp_build_context *bld,
       /* mant = (float) mantissa(x) */
       mant = LLVMBuildAnd(bld->builder, i, mantmask, "");
       mant = LLVMBuildOr(bld->builder, mant, one, "");
-      mant = LLVMBuildSIToFP(bld->builder, mant, vec_type, "");
+      mant = LLVMBuildBitCast(bld->builder, mant, vec_type, "");
 
       logmant = lp_build_polynomial(bld, mant, lp_build_log2_polynomial,
                                     Elements(lp_build_log2_polynomial));
 
       /* This effectively increases the polynomial degree by one, but ensures that log2(1) == 0*/
-      logmant = LLVMBuildMul(bld->builder, logmant, LLVMBuildMul(bld->builder, mant, bld->one, ""), "");
+      logmant = LLVMBuildMul(bld->builder, logmant, LLVMBuildSub(bld->builder, mant, bld->one, ""), "");
 
       res = LLVMBuildAdd(bld->builder, logmant, logexp, "");
    }
index 095a8e1cabea425e051ba45aa8b58ee364c10888..62be4b9aee18abfe85734106325d0d92f6628a15 100644 (file)
@@ -40,7 +40,7 @@
 #include <llvm-c/Core.h>  
 
 
-struct lp_type type;
+struct lp_type;
 struct lp_build_context;
 
 
@@ -66,6 +66,11 @@ lp_build_mul(struct lp_build_context *bld,
              LLVMValueRef a,
              LLVMValueRef b);
 
+LLVMValueRef
+lp_build_mul_imm(struct lp_build_context *bld,
+                 LLVMValueRef a,
+                 int b);
+
 LLVMValueRef
 lp_build_div(struct lp_build_context *bld,
              LLVMValueRef a,
index d14f468ba93b2f27e92b5e85a957f3f1fbe2b126..ced7b9c11d739e1821357c13d5778b823e0e760c 100644 (file)
@@ -142,7 +142,7 @@ lp_build_blend_factor_unswizzled(struct lp_build_blend_aos_context *bld,
 
 enum lp_build_blend_swizzle {
    LP_BUILD_BLEND_SWIZZLE_RGBA = 0,
-   LP_BUILD_BLEND_SWIZZLE_AAAA = 1,
+   LP_BUILD_BLEND_SWIZZLE_AAAA = 1
 };
 
 
index ffb302f73663987ee2423e7fab6e7a104af2a9bf..cb8e1c7b006da3ce9e887b10b391dc1f7504ddba 100644 (file)
@@ -42,7 +42,7 @@
 #include <pipe/p_compiler.h>
 
 
-struct lp_type type;
+struct lp_type;
 
 
 unsigned
index 1df938529c4f27ae81996c782ffe439406fbab51..9fa8837202207cfd46828d4a5931e5db48c167c2 100644 (file)
@@ -69,6 +69,7 @@
 #include "lp_bld_const.h"
 #include "lp_bld_intr.h"
 #include "lp_bld_arit.h"
+#include "lp_bld_pack.h"
 #include "lp_bld_conv.h"
 
 
@@ -202,241 +203,6 @@ lp_build_unsigned_norm_to_float(LLVMBuilderRef builder,
 }
 
 
-/**
- * Build shuffle vectors that match PUNPCKLxx and PUNPCKHxx instructions.
- */
-static LLVMValueRef
-lp_build_const_unpack_shuffle(unsigned n, unsigned lo_hi)
-{
-   LLVMValueRef elems[LP_MAX_VECTOR_LENGTH];
-   unsigned i, j;
-
-   assert(n <= LP_MAX_VECTOR_LENGTH);
-   assert(lo_hi < 2);
-
-   /* TODO: cache results in a static table */
-
-   for(i = 0, j = lo_hi*n/2; i < n; i += 2, ++j) {
-      elems[i + 0] = LLVMConstInt(LLVMInt32Type(), 0 + j, 0);
-      elems[i + 1] = LLVMConstInt(LLVMInt32Type(), n + j, 0);
-   }
-
-   return LLVMConstVector(elems, n);
-}
-
-
-/**
- * Build shuffle vectors that match PACKxx instructions.
- */
-static LLVMValueRef
-lp_build_const_pack_shuffle(unsigned n)
-{
-   LLVMValueRef elems[LP_MAX_VECTOR_LENGTH];
-   unsigned i;
-
-   assert(n <= LP_MAX_VECTOR_LENGTH);
-
-   /* TODO: cache results in a static table */
-
-   for(i = 0; i < n; ++i)
-      elems[i] = LLVMConstInt(LLVMInt32Type(), 2*i, 0);
-
-   return LLVMConstVector(elems, n);
-}
-
-
-/**
- * Expand the bit width.
- *
- * This will only change the number of bits the values are represented, not the
- * values themselves.
- */
-static void
-lp_build_expand(LLVMBuilderRef builder,
-               struct lp_type src_type,
-               struct lp_type dst_type,
-               LLVMValueRef src,
-               LLVMValueRef *dst, unsigned num_dsts)
-{
-   unsigned num_tmps;
-   unsigned i;
-
-   /* Register width must remain constant */
-   assert(src_type.width * src_type.length == dst_type.width * dst_type.length);
-
-   /* We must not loose or gain channels. Only precision */
-   assert(src_type.length == dst_type.length * num_dsts);
-
-   num_tmps = 1;
-   dst[0] = src;
-
-   while(src_type.width < dst_type.width) {
-      struct lp_type new_type = src_type;
-      LLVMTypeRef new_vec_type;
-
-      new_type.width *= 2;
-      new_type.length /= 2;
-      new_vec_type = lp_build_vec_type(new_type);
-
-      for(i = num_tmps; i--; ) {
-         LLVMValueRef zero;
-         LLVMValueRef shuffle_lo;
-         LLVMValueRef shuffle_hi;
-         LLVMValueRef lo;
-         LLVMValueRef hi;
-
-         zero = lp_build_zero(src_type);
-         shuffle_lo = lp_build_const_unpack_shuffle(src_type.length, 0);
-         shuffle_hi = lp_build_const_unpack_shuffle(src_type.length, 1);
-
-         /*  PUNPCKLBW, PUNPCKHBW */
-         lo = LLVMBuildShuffleVector(builder, dst[i], zero, shuffle_lo, "");
-         hi = LLVMBuildShuffleVector(builder, dst[i], zero, shuffle_hi, "");
-
-         dst[2*i + 0] = LLVMBuildBitCast(builder, lo, new_vec_type, "");
-         dst[2*i + 1] = LLVMBuildBitCast(builder, hi, new_vec_type, "");
-      }
-
-      src_type = new_type;
-
-      num_tmps *= 2;
-   }
-
-   assert(num_tmps == num_dsts);
-}
-
-
-/**
- * Non-interleaved pack.
- *
- * This will move values as
- *
- *   lo =   __ l0 __ l1 __ l2 __..  __ ln
- *   hi =   __ h0 __ h1 __ h2 __..  __ hn
- *   res =  l0 l1 l2 .. ln h0 h1 h2 .. hn
- *
- * TODO: handle saturation consistently.
- */
-static LLVMValueRef
-lp_build_pack2(LLVMBuilderRef builder,
-               struct lp_type src_type,
-               struct lp_type dst_type,
-               boolean clamped,
-               LLVMValueRef lo,
-               LLVMValueRef hi)
-{
-   LLVMTypeRef src_vec_type = lp_build_vec_type(src_type);
-   LLVMTypeRef dst_vec_type = lp_build_vec_type(dst_type);
-   LLVMValueRef shuffle;
-   LLVMValueRef res;
-
-   /* Register width must remain constant */
-   assert(src_type.width * src_type.length == dst_type.width * dst_type.length);
-
-   /* We must not loose or gain channels. Only precision */
-   assert(src_type.length * 2 == dst_type.length);
-
-   assert(!src_type.floating);
-   assert(!dst_type.floating);
-
-   if(util_cpu_caps.has_sse2 && src_type.width * src_type.length == 128) {
-      /* All X86 non-interleaved pack instructions all take signed inputs and
-       * saturate them, so saturate beforehand. */
-      if(!src_type.sign && !clamped) {
-         struct lp_build_context bld;
-         unsigned dst_bits = dst_type.sign ? dst_type.width - 1 : dst_type.width;
-         LLVMValueRef dst_max = lp_build_int_const_scalar(src_type, ((unsigned long long)1 << dst_bits) - 1);
-         lp_build_context_init(&bld, builder, src_type);
-         lo = lp_build_min(&bld, lo, dst_max);
-         hi = lp_build_min(&bld, hi, dst_max);
-      }
-
-      switch(src_type.width) {
-      case 32:
-         if(dst_type.sign || !util_cpu_caps.has_sse4_1)
-            res = lp_build_intrinsic_binary(builder, "llvm.x86.sse2.packssdw.128", src_vec_type, lo, hi);
-         else
-            /* PACKUSDW is the only instrinsic with a consistent signature */
-            return lp_build_intrinsic_binary(builder, "llvm.x86.sse41.packusdw", dst_vec_type, lo, hi);
-         break;
-
-      case 16:
-         if(dst_type.sign)
-            res = lp_build_intrinsic_binary(builder, "llvm.x86.sse2.packsswb.128", src_vec_type, lo, hi);
-         else
-            res = lp_build_intrinsic_binary(builder, "llvm.x86.sse2.packuswb.128", src_vec_type, lo, hi);
-         break;
-
-      default:
-         assert(0);
-         return LLVMGetUndef(dst_vec_type);
-         break;
-      }
-
-      res = LLVMBuildBitCast(builder, res, dst_vec_type, "");
-      return res;
-   }
-
-   lo = LLVMBuildBitCast(builder, lo, dst_vec_type, "");
-   hi = LLVMBuildBitCast(builder, hi, dst_vec_type, "");
-
-   shuffle = lp_build_const_pack_shuffle(dst_type.length);
-
-   res = LLVMBuildShuffleVector(builder, lo, hi, shuffle, "");
-
-   return res;
-}
-
-
-/**
- * Truncate the bit width.
- *
- * TODO: Handle saturation consistently.
- */
-static LLVMValueRef
-lp_build_pack(LLVMBuilderRef builder,
-              struct lp_type src_type,
-              struct lp_type dst_type,
-              boolean clamped,
-              const LLVMValueRef *src, unsigned num_srcs)
-{
-   LLVMValueRef tmp[LP_MAX_VECTOR_LENGTH];
-   unsigned i;
-
-   /* Register width must remain constant */
-   assert(src_type.width * src_type.length == dst_type.width * dst_type.length);
-
-   /* We must not loose or gain channels. Only precision */
-   assert(src_type.length * num_srcs == dst_type.length);
-
-   for(i = 0; i < num_srcs; ++i)
-      tmp[i] = src[i];
-
-   while(src_type.width > dst_type.width) {
-      struct lp_type new_type = src_type;
-
-      new_type.width /= 2;
-      new_type.length *= 2;
-
-      /* Take in consideration the sign changes only in the last step */
-      if(new_type.width == dst_type.width)
-         new_type.sign = dst_type.sign;
-
-      num_srcs /= 2;
-
-      for(i = 0; i < num_srcs; ++i)
-         tmp[i] = lp_build_pack2(builder, src_type, new_type, clamped,
-                                 tmp[2*i + 0], tmp[2*i + 1]);
-
-      src_type = new_type;
-   }
-
-   assert(num_srcs == 1);
-
-   return tmp[0];
-}
-
-
 /**
  * Generic type conversion.
  *
@@ -576,7 +342,7 @@ lp_build_conv(LLVMBuilderRef builder,
 
    if(tmp_type.width < dst_type.width) {
       assert(num_tmps == 1);
-      lp_build_expand(builder, tmp_type, dst_type, tmp[0], tmp, num_dsts);
+      lp_build_unpack(builder, tmp_type, dst_type, tmp[0], tmp, num_dsts);
       tmp_type.width = dst_type.width;
       tmp_type.length = dst_type.length;
       num_tmps = num_dsts;
@@ -696,7 +462,7 @@ lp_build_conv_mask(LLVMBuilderRef builder,
    }
    else if(src_type.width < dst_type.width) {
       assert(num_srcs == 1);
-      lp_build_expand(builder, src_type, dst_type, src[0], dst, num_dsts);
+      lp_build_unpack(builder, src_type, dst_type, src[0], dst, num_dsts);
    }
    else {
       assert(num_srcs == num_dsts);
index ca378804d2a249904cea0c6c995dab684d767dad..948e68fae4fc3f7bf6998f82484d95bffd06011b 100644 (file)
@@ -40,7 +40,7 @@
 #include <llvm-c/Core.h>  
 
 
-struct lp_type type;
+struct lp_type;
 
 
 LLVMValueRef
index 59d8f492e60af0af4585c1fcaa5ac95f8154e5f6..39dfc51e50331b6cabeaa2f076a2fc069f610b9f 100644 (file)
@@ -77,10 +77,10 @@ lp_disassemble(const void* func)
    while (ud_disassemble(&ud_obj)) {
 
 #ifdef PIPE_ARCH_X86
-      debug_printf("%08lx: ", (unsigned long)ud_insn_off(&ud_obj));
+      debug_printf("0x%08lx:\t", (unsigned long)ud_insn_off(&ud_obj));
 #endif
 #ifdef PIPE_ARCH_X86_64
-      debug_printf("%016llx: ", (unsigned long long)ud_insn_off(&ud_obj));
+      debug_printf("0x%016llx:\t", (unsigned long long)ud_insn_off(&ud_obj));
 #endif
 
 #if 0
@@ -115,9 +115,16 @@ lp_disassemble(const void* func)
          }
       }
 
-      if (ud_insn_off(&ud_obj) >= max_jmp_pc && ud_obj.mnemonic == UD_Iret)
+      if ((ud_insn_off(&ud_obj) >= max_jmp_pc && ud_obj.mnemonic == UD_Iret) ||
+           ud_obj.mnemonic == UD_Iinvalid)
          break;
    }
+
+#if 0
+   /* Print GDB command, useful to verify udis86 output */
+   debug_printf("disassemble %p %p\n", func, (void*)(uintptr_t)ud_obj.pc);
+#endif
+
    debug_printf("\n");
 #else
    (void)func;
index 98ec1cb1b9dca428118830ae8e8f70173a4d9648..d438c0e63d7d43695775d89ed9ca137c8cf4d9db 100644 (file)
@@ -90,7 +90,7 @@ lp_depth_type(const struct util_format_description *format_desc,
 
    if(format_desc->channel[swizzle].type == UTIL_FORMAT_TYPE_FLOAT) {
       type.floating = TRUE;
-      assert(swizzle = 0);
+      assert(swizzle == 0);
       assert(format_desc->channel[swizzle].size == format_desc->block.bits);
    }
    else if(format_desc->channel[swizzle].type == UTIL_FORMAT_TYPE_UNSIGNED) {
index c087fc986eddffd3647209ae56cb098cf0abb784..970bee379f554e20906a28241272d14c6a4b633d 100644 (file)
@@ -42,62 +42,34 @@ struct util_format_description;
 struct lp_type;
 
 
-/**
- * Unpack a pixel into its RGBA components.
- *
- * @param packed integer.
- *
- * @return RGBA in a 4 floats vector.
- */
-LLVMValueRef
-lp_build_unpack_rgba_aos(LLVMBuilderRef builder,
-                         enum pipe_format format,
-                         LLVMValueRef packed);
+boolean
+lp_format_is_rgba8(const struct util_format_description *desc);
 
 
-/**
- * Pack a pixel.
- *
- * @param rgba 4 float vector with the unpacked components.
- */
-LLVMValueRef
-lp_build_pack_rgba_aos(LLVMBuilderRef builder,
-                       enum pipe_format format,
-                       LLVMValueRef rgba);
+void
+lp_build_format_swizzle_soa(const struct util_format_description *format_desc,
+                            struct lp_type type,
+                            const LLVMValueRef *unswizzled,
+                            LLVMValueRef *swizzled);
 
 
-/**
- * Load a pixel into its RGBA components.
- *
- * @param ptr value with the pointer to the packed pixel. Pointer type is
- * irrelevant.
- *
- * @return RGBA in a 4 floats vector.
- */
 LLVMValueRef
-lp_build_load_rgba_aos(LLVMBuilderRef builder,
-                       enum pipe_format format,
-                       LLVMValueRef ptr);
+lp_build_unpack_rgba_aos(LLVMBuilderRef builder,
+                         const struct util_format_description *desc,
+                         LLVMValueRef packed);
 
 
-/**
- * Store a pixel.
- *
- * @param rgba 4 float vector with the unpacked components.
- */
-void 
-lp_build_store_rgba_aos(LLVMBuilderRef builder,
-                        enum pipe_format format,
-                        LLVMValueRef ptr,
-                        LLVMValueRef rgba);
+LLVMValueRef
+lp_build_unpack_rgba8_aos(LLVMBuilderRef builder,
+                          const struct util_format_description *desc,
+                          struct lp_type type,
+                          LLVMValueRef packed);
+
 
 LLVMValueRef
-lp_build_gather(LLVMBuilderRef builder,
-                unsigned length,
-                unsigned src_width,
-                unsigned dst_width,
-                LLVMValueRef base_ptr,
-                LLVMValueRef offsets);
+lp_build_pack_rgba_aos(LLVMBuilderRef builder,
+                       const struct util_format_description *desc,
+                       LLVMValueRef rgba);
 
 
 void
@@ -108,12 +80,4 @@ lp_build_unpack_rgba_soa(LLVMBuilderRef builder,
                          LLVMValueRef *rgba);
 
 
-void
-lp_build_load_rgba_soa(LLVMBuilderRef builder,
-                       const struct util_format_description *format_desc,
-                       struct lp_type type,
-                       LLVMValueRef base_ptr,
-                       LLVMValueRef offsets,
-                       LLVMValueRef *rgba);
-
 #endif /* !LP_BLD_FORMAT_H */
index b9b5d84bed5330c57e78bd67d97b302de3e45577..10e82f120bb7ef8f5042714a6b8e2474254e49f9 100644 (file)
  *
  **************************************************************************/
 
+/**
+ * @file
+ * AoS pixel format manipulation.
+ *
+ * @author Jose Fonseca <jfonseca@vmware.com>
+ */
+
 
+#include "util/u_cpu_detect.h"
 #include "util/u_format.h"
 
+#include "lp_bld_type.h"
+#include "lp_bld_const.h"
+#include "lp_bld_logic.h"
+#include "lp_bld_swizzle.h"
 #include "lp_bld_format.h"
 
 
+/**
+ * Unpack a single pixel into its RGBA components.
+ *
+ * @param packed integer.
+ *
+ * @return RGBA in a 4 floats vector.
+ *
+ * XXX: This is mostly for reference and testing -- operating a single pixel at
+ * a time is rarely if ever needed.
+ */
 LLVMValueRef
 lp_build_unpack_rgba_aos(LLVMBuilderRef builder,
-                         enum pipe_format format,
+                         const struct util_format_description *desc,
                          LLVMValueRef packed)
 {
-   const struct util_format_description *desc;
    LLVMTypeRef type;
    LLVMValueRef shifted, casted, scaled, masked;
    LLVMValueRef shifts[4];
@@ -49,8 +70,6 @@ lp_build_unpack_rgba_aos(LLVMBuilderRef builder,
    unsigned shift;
    unsigned i;
 
-   desc = util_format_description(format);
-
    /* FIXME: Support more formats */
    assert(desc->layout == UTIL_FORMAT_LAYOUT_ARITH);
    assert(desc->block.width == 1);
@@ -111,7 +130,7 @@ lp_build_unpack_rgba_aos(LLVMBuilderRef builder,
 
    shifted = LLVMBuildLShr(builder, packed, LLVMConstVector(shifts, 4), "");
    masked = LLVMBuildAnd(builder, shifted, LLVMConstVector(masks, 4), "");
-   // UIToFP can't be expressed in SSE2
+   /* UIToFP can't be expressed in SSE2 */
    casted = LLVMBuildSIToFP(builder, masked, LLVMVectorType(LLVMFloatType(), 4), "");
 
    if (normalized)
@@ -151,12 +170,130 @@ lp_build_unpack_rgba_aos(LLVMBuilderRef builder,
 }
 
 
+/**
+ * Take a vector with packed pixels and unpack into a rgba8 vector.
+ *
+ * Formats with bit depth smaller than 32bits are accepted, but they must be
+ * padded to 32bits.
+ */
+LLVMValueRef
+lp_build_unpack_rgba8_aos(LLVMBuilderRef builder,
+                          const struct util_format_description *desc,
+                          struct lp_type type,
+                          LLVMValueRef packed)
+{
+   struct lp_build_context bld;
+   bool rgba8;
+   LLVMValueRef res;
+   unsigned i;
+
+   lp_build_context_init(&bld, builder, type);
+
+   /* FIXME: Support more formats */
+   assert(desc->layout == UTIL_FORMAT_LAYOUT_ARITH);
+   assert(desc->block.width == 1);
+   assert(desc->block.height == 1);
+   assert(desc->block.bits <= 32);
+
+   assert(!type.floating);
+   assert(!type.fixed);
+   assert(type.norm);
+   assert(type.width == 8);
+   assert(type.length % 4 == 0);
+
+   rgba8 = TRUE;
+   for(i = 0; i < 4; ++i) {
+      assert(desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED ||
+             desc->channel[i].type == UTIL_FORMAT_TYPE_VOID);
+      if(desc->channel[0].size != 8)
+         rgba8 = FALSE;
+   }
+
+   if(rgba8) {
+      /*
+       * The pixel is already in a rgba8 format variant. All it is necessary
+       * is to swizzle the channels.
+       */
+
+      unsigned char swizzles[4];
+      boolean zeros[4]; /* bitwise AND mask */
+      boolean ones[4]; /* bitwise OR mask */
+      boolean swizzles_needed = FALSE;
+      boolean zeros_needed = FALSE;
+      boolean ones_needed = FALSE;
+
+      for(i = 0; i < 4; ++i) {
+         enum util_format_swizzle swizzle = desc->swizzle[i];
+
+         /* Initialize with the no-op case */
+         swizzles[i] = util_cpu_caps.little_endian ? 3 - i : i;
+         zeros[i] = TRUE;
+         ones[i] = FALSE;
+
+         switch (swizzle) {
+         case UTIL_FORMAT_SWIZZLE_X:
+         case UTIL_FORMAT_SWIZZLE_Y:
+         case UTIL_FORMAT_SWIZZLE_Z:
+         case UTIL_FORMAT_SWIZZLE_W:
+            if(swizzle != swizzles[i]) {
+               swizzles[i] = swizzle;
+               swizzles_needed = TRUE;
+            }
+            break;
+         case UTIL_FORMAT_SWIZZLE_0:
+            zeros[i] = FALSE;
+            zeros_needed = TRUE;
+            break;
+         case UTIL_FORMAT_SWIZZLE_1:
+            ones[i] = TRUE;
+            ones_needed = TRUE;
+            break;
+         case UTIL_FORMAT_SWIZZLE_NONE:
+            assert(0);
+            break;
+         }
+      }
+
+      res = packed;
+
+      if(swizzles_needed)
+         res = lp_build_swizzle1_aos(&bld, res, swizzles);
+
+      if(zeros_needed) {
+         /* Mask out zero channels */
+         LLVMValueRef mask = lp_build_const_mask_aos(type, zeros);
+         res = LLVMBuildAnd(builder, res, mask, "");
+      }
+
+      if(ones_needed) {
+         /* Or one channels */
+         LLVMValueRef mask = lp_build_const_mask_aos(type, ones);
+         res = LLVMBuildOr(builder, res, mask, "");
+      }
+   }
+   else {
+      /* FIXME */
+      assert(0);
+      res = lp_build_undef(type);
+   }
+
+   return res;
+}
+
+
+/**
+ * Pack a single pixel.
+ *
+ * @param rgba 4 float vector with the unpacked components.
+ *
+ * XXX: This is mostly for reference and testing -- operating a single pixel at
+ * a time is rarely if ever needed.
+ */
 LLVMValueRef
 lp_build_pack_rgba_aos(LLVMBuilderRef builder,
-                       enum pipe_format format,
+                       const struct util_format_description *desc,
                        LLVMValueRef rgba)
 {
-   const struct util_format_description *desc;
    LLVMTypeRef type;
    LLVMValueRef packed = NULL;
    LLVMValueRef swizzles[4];
@@ -167,8 +304,6 @@ lp_build_pack_rgba_aos(LLVMBuilderRef builder,
    unsigned shift;
    unsigned i, j;
 
-   desc = util_format_description(format);
-
    assert(desc->layout == UTIL_FORMAT_LAYOUT_ARITH);
    assert(desc->block.width == 1);
    assert(desc->block.height == 1);
@@ -247,57 +382,3 @@ lp_build_pack_rgba_aos(LLVMBuilderRef builder,
 
    return packed;
 }
-
-
-LLVMValueRef
-lp_build_load_rgba_aos(LLVMBuilderRef builder,
-                       enum pipe_format format,
-                       LLVMValueRef ptr)
-{
-   const struct util_format_description *desc;
-   LLVMTypeRef type;
-   LLVMValueRef packed;
-
-   desc = util_format_description(format);
-
-   /* FIXME: Support more formats */
-   assert(desc->layout == UTIL_FORMAT_LAYOUT_ARITH);
-   assert(desc->block.width == 1);
-   assert(desc->block.height == 1);
-   assert(desc->block.bits <= 32);
-
-   type = LLVMIntType(desc->block.bits);
-
-   ptr = LLVMBuildBitCast(builder, ptr, LLVMPointerType(type, 0), "");
-
-   packed = LLVMBuildLoad(builder, ptr, "");
-
-   return lp_build_unpack_rgba_aos(builder, format, packed);
-}
-
-
-void
-lp_build_store_rgba_aos(LLVMBuilderRef builder,
-                        enum pipe_format format,
-                        LLVMValueRef ptr,
-                        LLVMValueRef rgba)
-{
-   const struct util_format_description *desc;
-   LLVMTypeRef type;
-   LLVMValueRef packed;
-
-   desc = util_format_description(format);
-
-   assert(desc->layout == UTIL_FORMAT_LAYOUT_ARITH);
-   assert(desc->block.width == 1);
-   assert(desc->block.height == 1);
-
-   type = LLVMIntType(desc->block.bits);
-
-   packed = lp_build_pack_rgba_aos(builder, format, rgba);
-
-   ptr = LLVMBuildBitCast(builder, ptr, LLVMPointerType(type, 0), "");
-
-   LLVMBuildStore(builder, packed, ptr);
-}
-
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_format_query.c b/src/gallium/drivers/llvmpipe/lp_bld_format_query.c
new file mode 100644 (file)
index 0000000..f3832d0
--- /dev/null
@@ -0,0 +1,72 @@
+/**************************************************************************
+ *
+ * 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 VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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
+ * Utility functions to make assertions about formats.
+ *
+ * This module centralizes most of logic used when determining what algorithm
+ * is most suitable (i.e., most efficient yet correct) for a given format.
+ *
+ * It might be possible to move some of these functions to u_format module,
+ * but since tiny differences in the format my render it more/less
+ * appropriate to a given algorithm it is impossible to make any long term
+ * guarantee about the semantics of these functions.
+ *
+ * @author Jose Fonseca <jfonseca@vmware.com>
+ */
+
+
+#include "util/u_format.h"
+
+#include "lp_bld_format.h"
+
+
+/**
+ * Whether this format is a 4 rgba8 variant
+ */
+boolean
+lp_format_is_rgba8(const struct util_format_description *desc)
+{
+   unsigned chan;
+
+   if(desc->block.width != 1 ||
+      desc->block.height != 1 ||
+      desc->block.bits != 32)
+      return FALSE;
+
+   for(chan = 0; chan < 4; ++chan) {
+      if(desc->channel[chan].type != UTIL_FORMAT_TYPE_UNSIGNED &&
+         desc->channel[chan].type != UTIL_FORMAT_TYPE_SIGNED &&
+         desc->channel[chan].type != UTIL_FORMAT_TYPE_VOID)
+         return FALSE;
+      if(desc->channel[chan].size != 8)
+         return FALSE;
+   }
+
+   return TRUE;
+}
index 66bebdcdec854b402fa519baece71e3709d5311f..64151d169da9b904781ef72c083e85ffddcc434e 100644 (file)
 #include "lp_bld_format.h"
 
 
-/**
- * Gather elements from scatter positions in memory into a single vector.
- *
- * @param src_width src element width
- * @param dst_width result element width (source will be expanded to fit)
- * @param length length of the offsets,
- * @param base_ptr base pointer, should be a i8 pointer type.
- * @param offsets vector with offsets
- */
-LLVMValueRef
-lp_build_gather(LLVMBuilderRef builder,
-                unsigned length,
-                unsigned src_width,
-                unsigned dst_width,
-                LLVMValueRef base_ptr,
-                LLVMValueRef offsets)
-{
-   LLVMTypeRef src_type = LLVMIntType(src_width);
-   LLVMTypeRef src_ptr_type = LLVMPointerType(src_type, 0);
-   LLVMTypeRef dst_elem_type = LLVMIntType(dst_width);
-   LLVMTypeRef dst_vec_type = LLVMVectorType(dst_elem_type, length);
-   LLVMValueRef res;
-   unsigned i;
-
-   res = LLVMGetUndef(dst_vec_type);
-   for(i = 0; i < length; ++i) {
-      LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0);
-      LLVMValueRef elem_offset;
-      LLVMValueRef elem_ptr;
-      LLVMValueRef elem;
-
-      elem_offset = LLVMBuildExtractElement(builder, offsets, index, "");
-      elem_ptr = LLVMBuildGEP(builder, base_ptr, &elem_offset, 1, "");
-      elem_ptr = LLVMBuildBitCast(builder, elem_ptr, src_ptr_type, "");
-      elem = LLVMBuildLoad(builder, elem_ptr, "");
-
-      assert(src_width <= dst_width);
-      if(src_width > dst_width)
-         elem = LLVMBuildTrunc(builder, elem, dst_elem_type, "");
-      if(src_width < dst_width)
-         elem = LLVMBuildZExt(builder, elem, dst_elem_type, "");
-
-      res = LLVMBuildInsertElement(builder, res, elem, index, "");
-   }
-
-   return res;
-}
-
-
 static LLVMValueRef
-lp_build_format_swizzle(struct lp_type type,
-                        const LLVMValueRef *inputs,
-                        enum util_format_swizzle swizzle)
+lp_build_format_swizzle_chan_soa(struct lp_type type,
+                                 const LLVMValueRef *unswizzled,
+                                 enum util_format_swizzle swizzle)
 {
    switch (swizzle) {
    case UTIL_FORMAT_SWIZZLE_X:
    case UTIL_FORMAT_SWIZZLE_Y:
    case UTIL_FORMAT_SWIZZLE_Z:
    case UTIL_FORMAT_SWIZZLE_W:
-      return inputs[swizzle];
+      return unswizzled[swizzle];
    case UTIL_FORMAT_SWIZZLE_0:
       return lp_build_zero(type);
    case UTIL_FORMAT_SWIZZLE_1:
@@ -107,6 +58,28 @@ lp_build_format_swizzle(struct lp_type type,
 }
 
 
+void
+lp_build_format_swizzle_soa(const struct util_format_description *format_desc,
+                            struct lp_type type,
+                            const LLVMValueRef *unswizzled,
+                            LLVMValueRef *swizzled)
+{
+   if(format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) {
+      enum util_format_swizzle swizzle = format_desc->swizzle[0];
+      LLVMValueRef depth = lp_build_format_swizzle_chan_soa(type, unswizzled, swizzle);
+      swizzled[2] = swizzled[1] = swizzled[0] = depth;
+      swizzled[3] = lp_build_one(type);
+   }
+   else {
+      unsigned chan;
+      for (chan = 0; chan < 4; ++chan) {
+         enum util_format_swizzle swizzle = format_desc->swizzle[chan];
+         swizzled[chan] = lp_build_format_swizzle_chan_soa(type, unswizzled, swizzle);
+      }
+   }
+}
+
+
 void
 lp_build_unpack_rgba_soa(LLVMBuilderRef builder,
                          const struct util_format_description *format_desc,
@@ -172,38 +145,5 @@ lp_build_unpack_rgba_soa(LLVMBuilderRef builder,
       start = stop;
    }
 
-   if(format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) {
-      enum util_format_swizzle swizzle = format_desc->swizzle[0];
-      LLVMValueRef depth = lp_build_format_swizzle(type, inputs, swizzle);
-      rgba[2] = rgba[1] = rgba[0] = depth;
-      rgba[3] = lp_build_one(type);
-   }
-   else {
-      for (chan = 0; chan < 4; ++chan) {
-         enum util_format_swizzle swizzle = format_desc->swizzle[chan];
-         rgba[chan] = lp_build_format_swizzle(type, inputs, swizzle);
-      }
-   }
-}
-
-
-void
-lp_build_load_rgba_soa(LLVMBuilderRef builder,
-                       const struct util_format_description *format_desc,
-                       struct lp_type type,
-                       LLVMValueRef base_ptr,
-                       LLVMValueRef offsets,
-                       LLVMValueRef *rgba)
-{
-   LLVMValueRef packed;
-
-   assert(format_desc->block.width == 1);
-   assert(format_desc->block.height == 1);
-   assert(format_desc->block.bits <= type.width);
-
-   packed = lp_build_gather(builder,
-                            type.length, format_desc->block.bits, type.width,
-                            base_ptr, offsets);
-
-   lp_build_unpack_rgba_soa(builder, format_desc, type, packed, rgba);
+   lp_build_format_swizzle_soa(format_desc, type, inputs, rgba);
 }
index affeeca6ff995721a35e7de67c823bb945a00571..daedf40d558b6e95465d79e26d1b6ca9d4e42faa 100644 (file)
@@ -142,32 +142,6 @@ coeffs_init(struct lp_build_interp_soa_context *bld,
 }
 
 
-/**
- * Small vector x scale multiplication optimization.
- *
- * TODO: Should be elsewhere.
- */
-static LLVMValueRef
-coeff_multiply(struct lp_build_interp_soa_context *bld,
-               LLVMValueRef coeff,
-               int step)
-{
-   LLVMValueRef factor;
-
-   switch(step) {
-   case 0:
-      return bld->base.zero;
-   case 1:
-      return coeff;
-   case 2:
-      return lp_build_add(&bld->base, coeff, coeff);
-   default:
-      factor = lp_build_const_scalar(bld->base.type, (double)step);
-      return lp_build_mul(&bld->base, coeff, factor);
-   }
-}
-
-
 /**
  * Emit LLVM code to compute the fragment shader input attribute values.
  * For example, for a color input, we'll compute red, green, blue and alpha
@@ -378,8 +352,8 @@ lp_build_interp_soa_init(struct lp_build_interp_soa_context *bld,
             unsigned first, last, mask;
             unsigned attrib;
 
-            first = decl->DeclarationRange.First;
-            last = decl->DeclarationRange.Last;
+            first = decl->Range.First;
+            last = decl->Range.Last;
             mask = decl->Declaration.UsageMask;
 
             for( attrib = first; attrib <= last; ++attrib ) {
index d68763665613e0bd2df6540474add8451a2264ab..40d64eb2c1917c2089865224b7105e2f2b2c56f3 100644 (file)
@@ -42,7 +42,7 @@
 #include "pipe/p_defines.h" /* For PIPE_FUNC_xxx */
 
 
-struct lp_type type;
+struct lp_type;
 struct lp_build_context;
 
 
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_misc.cpp b/src/gallium/drivers/llvmpipe/lp_bld_misc.cpp
new file mode 100644 (file)
index 0000000..d3f78c0
--- /dev/null
@@ -0,0 +1,61 @@
+/**************************************************************************
+ *
+ * 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 VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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_config.h"
+
+#include "lp_bld_misc.h"
+
+
+#ifndef LLVM_NATIVE_ARCH
+
+namespace llvm {
+   extern void LinkInJIT();
+}
+
+
+void
+LLVMLinkInJIT(void)
+{
+   llvm::LinkInJIT();
+}
+
+
+extern "C" int X86TargetMachineModule;
+
+
+int
+LLVMInitializeNativeTarget(void)
+{
+#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
+   X86TargetMachineModule = 1;
+#endif
+   return 0;
+}
+
+
+#endif
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_misc.h b/src/gallium/drivers/llvmpipe/lp_bld_misc.h
new file mode 100644 (file)
index 0000000..0e787e0
--- /dev/null
@@ -0,0 +1,56 @@
+/**************************************************************************
+ *
+ * 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 VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 LP_BLD_MISC_H
+#define LP_BLD_MISC_H
+
+
+#include "llvm/Config/config.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#ifndef LLVM_NATIVE_ARCH
+
+void
+LLVMLinkInJIT(void);
+
+int
+LLVMInitializeNativeTarget(void);
+
+#endif /* !LLVM_NATIVE_ARCH */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* !LP_BLD_MISC_H */
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_pack.c b/src/gallium/drivers/llvmpipe/lp_bld_pack.c
new file mode 100644 (file)
index 0000000..bc360ad
--- /dev/null
@@ -0,0 +1,418 @@
+/**************************************************************************
+ *
+ * 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 VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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
+ * Helper functions for packing/unpacking.
+ *
+ * Pack/unpacking is necessary for conversion between types of different
+ * bit width.
+ *
+ * They are also commonly used when an computation needs higher
+ * precision for the intermediate values. For example, if one needs the
+ * function:
+ *
+ *   c = compute(a, b);
+ *
+ * to use more precision for intermediate results then one should implement it
+ * as:
+ *
+ *   LLVMValueRef
+ *   compute(LLVMBuilderRef builder struct lp_type type, LLVMValueRef a, LLVMValueRef b)
+ *   {
+ *      struct lp_type wide_type = lp_wider_type(type);
+ *      LLVMValueRef al, ah, bl, bh, cl, ch, c;
+ *
+ *      lp_build_unpack2(builder, type, wide_type, a, &al, &ah);
+ *      lp_build_unpack2(builder, type, wide_type, b, &bl, &bh);
+ *
+ *      cl = compute_half(al, bl);
+ *      ch = compute_half(ah, bh);
+ *
+ *      c = lp_build_pack2(bld->builder, wide_type, type, cl, ch);
+ *
+ *      return c;
+ *   }
+ *
+ * where compute_half() would do the computation for half the elements with
+ * twice the precision.
+ *
+ * @author Jose Fonseca <jfonseca@vmware.com>
+ */
+
+
+#include "util/u_debug.h"
+#include "util/u_math.h"
+#include "util/u_cpu_detect.h"
+
+#include "lp_bld_type.h"
+#include "lp_bld_const.h"
+#include "lp_bld_intr.h"
+#include "lp_bld_arit.h"
+#include "lp_bld_pack.h"
+
+
+/**
+ * Build shuffle vectors that match PUNPCKLxx and PUNPCKHxx instructions.
+ */
+static LLVMValueRef
+lp_build_const_unpack_shuffle(unsigned n, unsigned lo_hi)
+{
+   LLVMValueRef elems[LP_MAX_VECTOR_LENGTH];
+   unsigned i, j;
+
+   assert(n <= LP_MAX_VECTOR_LENGTH);
+   assert(lo_hi < 2);
+
+   /* TODO: cache results in a static table */
+
+   for(i = 0, j = lo_hi*n/2; i < n; i += 2, ++j) {
+      elems[i + 0] = LLVMConstInt(LLVMInt32Type(), 0 + j, 0);
+      elems[i + 1] = LLVMConstInt(LLVMInt32Type(), n + j, 0);
+   }
+
+   return LLVMConstVector(elems, n);
+}
+
+
+/**
+ * Build shuffle vectors that match PACKxx instructions.
+ */
+static LLVMValueRef
+lp_build_const_pack_shuffle(unsigned n)
+{
+   LLVMValueRef elems[LP_MAX_VECTOR_LENGTH];
+   unsigned i;
+
+   assert(n <= LP_MAX_VECTOR_LENGTH);
+
+   /* TODO: cache results in a static table */
+
+   for(i = 0; i < n; ++i)
+      elems[i] = LLVMConstInt(LLVMInt32Type(), 2*i, 0);
+
+   return LLVMConstVector(elems, n);
+}
+
+
+/**
+ * Interleave vector elements.
+ *
+ * Matches the PUNPCKLxx and PUNPCKHxx SSE instructions.
+ */
+LLVMValueRef
+lp_build_interleave2(LLVMBuilderRef builder,
+                     struct lp_type type,
+                     LLVMValueRef a,
+                     LLVMValueRef b,
+                     unsigned lo_hi)
+{
+   LLVMValueRef shuffle;
+
+   shuffle = lp_build_const_unpack_shuffle(type.length, lo_hi);
+
+   return LLVMBuildShuffleVector(builder, a, b, shuffle, "");
+}
+
+
+/**
+ * Double the bit width.
+ *
+ * This will only change the number of bits the values are represented, not the
+ * values themselves.
+ */
+void
+lp_build_unpack2(LLVMBuilderRef builder,
+                 struct lp_type src_type,
+                 struct lp_type dst_type,
+                 LLVMValueRef src,
+                 LLVMValueRef *dst_lo,
+                 LLVMValueRef *dst_hi)
+{
+   LLVMValueRef msb;
+   LLVMTypeRef dst_vec_type;
+
+   assert(!src_type.floating);
+   assert(!dst_type.floating);
+   assert(dst_type.width == src_type.width * 2);
+   assert(dst_type.length * 2 == src_type.length);
+
+   if(dst_type.sign && src_type.sign) {
+      /* Replicate the sign bit in the most significant bits */
+      msb = LLVMBuildAShr(builder, src, lp_build_int_const_scalar(src_type, src_type.width - 1), "");
+   }
+   else
+      /* Most significant bits always zero */
+      msb = lp_build_zero(src_type);
+
+   /* Interleave bits */
+   if(util_cpu_caps.little_endian) {
+      *dst_lo = lp_build_interleave2(builder, src_type, src, msb, 0);
+      *dst_hi = lp_build_interleave2(builder, src_type, src, msb, 1);
+   }
+   else {
+      *dst_lo = lp_build_interleave2(builder, src_type, msb, src, 0);
+      *dst_hi = lp_build_interleave2(builder, src_type, msb, src, 1);
+   }
+
+   /* Cast the result into the new type (twice as wide) */
+
+   dst_vec_type = lp_build_vec_type(dst_type);
+
+   *dst_lo = LLVMBuildBitCast(builder, *dst_lo, dst_vec_type, "");
+   *dst_hi = LLVMBuildBitCast(builder, *dst_hi, dst_vec_type, "");
+}
+
+
+/**
+ * Expand the bit width.
+ *
+ * This will only change the number of bits the values are represented, not the
+ * values themselves.
+ */
+void
+lp_build_unpack(LLVMBuilderRef builder,
+                struct lp_type src_type,
+                struct lp_type dst_type,
+                LLVMValueRef src,
+                LLVMValueRef *dst, unsigned num_dsts)
+{
+   unsigned num_tmps;
+   unsigned i;
+
+   /* Register width must remain constant */
+   assert(src_type.width * src_type.length == dst_type.width * dst_type.length);
+
+   /* We must not loose or gain channels. Only precision */
+   assert(src_type.length == dst_type.length * num_dsts);
+
+   num_tmps = 1;
+   dst[0] = src;
+
+   while(src_type.width < dst_type.width) {
+      struct lp_type tmp_type = src_type;
+
+      tmp_type.width *= 2;
+      tmp_type.length /= 2;
+
+      for(i = num_tmps; i--; ) {
+         lp_build_unpack2(builder, src_type, tmp_type, dst[i], &dst[2*i + 0], &dst[2*i + 1]);
+      }
+
+      src_type = tmp_type;
+
+      num_tmps *= 2;
+   }
+
+   assert(num_tmps == num_dsts);
+}
+
+
+/**
+ * Non-interleaved pack.
+ *
+ * This will move values as
+ *
+ *   lo =   __ l0 __ l1 __ l2 __..  __ ln
+ *   hi =   __ h0 __ h1 __ h2 __..  __ hn
+ *   res =  l0 l1 l2 .. ln h0 h1 h2 .. hn
+ *
+ * This will only change the number of bits the values are represented, not the
+ * values themselves.
+ *
+ * It is assumed the values are already clamped into the destination type range.
+ * Values outside that range will produce undefined results. Use
+ * lp_build_packs2 instead.
+ */
+LLVMValueRef
+lp_build_pack2(LLVMBuilderRef builder,
+               struct lp_type src_type,
+               struct lp_type dst_type,
+               LLVMValueRef lo,
+               LLVMValueRef hi)
+{
+   LLVMTypeRef src_vec_type = lp_build_vec_type(src_type);
+   LLVMTypeRef dst_vec_type = lp_build_vec_type(dst_type);
+   LLVMValueRef shuffle;
+   LLVMValueRef res;
+
+   dst_vec_type = lp_build_vec_type(dst_type);
+
+   assert(!src_type.floating);
+   assert(!dst_type.floating);
+   assert(src_type.width == dst_type.width * 2);
+   assert(src_type.length * 2 == dst_type.length);
+
+   if(util_cpu_caps.has_sse2 && src_type.width * src_type.length == 128) {
+      switch(src_type.width) {
+      case 32:
+         if(dst_type.sign) {
+            res = lp_build_intrinsic_binary(builder, "llvm.x86.sse2.packssdw.128", src_vec_type, lo, hi);
+         }
+         else {
+            if (util_cpu_caps.has_sse4_1) {
+               /* PACKUSDW is the only instrinsic with a consistent signature */
+               return lp_build_intrinsic_binary(builder, "llvm.x86.sse41.packusdw", dst_vec_type, lo, hi);
+            }
+            else {
+               assert(0);
+               return LLVMGetUndef(dst_vec_type);
+            }
+         }
+         break;
+
+      case 16:
+         if(dst_type.sign)
+            res = lp_build_intrinsic_binary(builder, "llvm.x86.sse2.packsswb.128", src_vec_type, lo, hi);
+         else
+            res = lp_build_intrinsic_binary(builder, "llvm.x86.sse2.packuswb.128", src_vec_type, lo, hi);
+         break;
+
+      default:
+         assert(0);
+         return LLVMGetUndef(dst_vec_type);
+         break;
+      }
+
+      res = LLVMBuildBitCast(builder, res, dst_vec_type, "");
+      return res;
+   }
+
+   lo = LLVMBuildBitCast(builder, lo, dst_vec_type, "");
+   hi = LLVMBuildBitCast(builder, hi, dst_vec_type, "");
+
+   shuffle = lp_build_const_pack_shuffle(dst_type.length);
+
+   res = LLVMBuildShuffleVector(builder, lo, hi, shuffle, "");
+
+   return res;
+}
+
+
+
+/**
+ * Non-interleaved pack and saturate.
+ *
+ * Same as lp_build_pack2 but will saturate values so that they fit into the
+ * destination type.
+ */
+LLVMValueRef
+lp_build_packs2(LLVMBuilderRef builder,
+                struct lp_type src_type,
+                struct lp_type dst_type,
+                LLVMValueRef lo,
+                LLVMValueRef hi)
+{
+   boolean clamp;
+
+   assert(!src_type.floating);
+   assert(!dst_type.floating);
+   assert(src_type.sign == dst_type.sign);
+   assert(src_type.width == dst_type.width * 2);
+   assert(src_type.length * 2 == dst_type.length);
+
+   clamp = TRUE;
+
+   /* All X86 SSE non-interleaved pack instructions take signed inputs and
+    * saturate them, so no need to clamp for those cases. */
+   if(util_cpu_caps.has_sse2 &&
+      src_type.width * src_type.length == 128 &&
+      src_type.sign)
+      clamp = FALSE;
+
+   if(clamp) {
+      struct lp_build_context bld;
+      unsigned dst_bits = dst_type.sign ? dst_type.width - 1 : dst_type.width;
+      LLVMValueRef dst_max = lp_build_int_const_scalar(src_type, ((unsigned long long)1 << dst_bits) - 1);
+      lp_build_context_init(&bld, builder, src_type);
+      lo = lp_build_min(&bld, lo, dst_max);
+      hi = lp_build_min(&bld, hi, dst_max);
+      /* FIXME: What about lower bound? */
+   }
+
+   return lp_build_pack2(builder, src_type, dst_type, lo, hi);
+}
+
+
+/**
+ * Truncate the bit width.
+ *
+ * TODO: Handle saturation consistently.
+ */
+LLVMValueRef
+lp_build_pack(LLVMBuilderRef builder,
+              struct lp_type src_type,
+              struct lp_type dst_type,
+              boolean clamped,
+              const LLVMValueRef *src, unsigned num_srcs)
+{
+   LLVMValueRef (*pack2)(LLVMBuilderRef builder,
+                         struct lp_type src_type,
+                         struct lp_type dst_type,
+                         LLVMValueRef lo,
+                         LLVMValueRef hi);
+   LLVMValueRef tmp[LP_MAX_VECTOR_LENGTH];
+   unsigned i;
+
+
+   /* Register width must remain constant */
+   assert(src_type.width * src_type.length == dst_type.width * dst_type.length);
+
+   /* We must not loose or gain channels. Only precision */
+   assert(src_type.length * num_srcs == dst_type.length);
+
+   if(clamped)
+      pack2 = &lp_build_pack2;
+   else
+      pack2 = &lp_build_packs2;
+
+   for(i = 0; i < num_srcs; ++i)
+      tmp[i] = src[i];
+
+   while(src_type.width > dst_type.width) {
+      struct lp_type tmp_type = src_type;
+
+      tmp_type.width /= 2;
+      tmp_type.length *= 2;
+
+      /* Take in consideration the sign changes only in the last step */
+      if(tmp_type.width == dst_type.width)
+         tmp_type.sign = dst_type.sign;
+
+      num_srcs /= 2;
+
+      for(i = 0; i < num_srcs; ++i)
+         tmp[i] = pack2(builder, src_type, tmp_type, tmp[2*i + 0], tmp[2*i + 1]);
+
+      src_type = tmp_type;
+   }
+
+   assert(num_srcs == 1);
+
+   return tmp[0];
+}
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_pack.h b/src/gallium/drivers/llvmpipe/lp_bld_pack.h
new file mode 100644 (file)
index 0000000..fb2a349
--- /dev/null
@@ -0,0 +1,95 @@
+/**************************************************************************
+ *
+ * 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 VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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
+ * Helper functions for packing/unpacking conversions.
+ *
+ * @author Jose Fonseca <jfonseca@vmware.com>
+ */
+
+
+#ifndef LP_BLD_PACK_H
+#define LP_BLD_PACK_H
+
+
+#include <llvm-c/Core.h>  
+
+
+struct lp_type;
+
+
+LLVMValueRef
+lp_build_interleave2(LLVMBuilderRef builder,
+                     struct lp_type type,
+                     LLVMValueRef a,
+                     LLVMValueRef b,
+                     unsigned lo_hi);
+
+
+void
+lp_build_unpack2(LLVMBuilderRef builder,
+                 struct lp_type src_type,
+                 struct lp_type dst_type,
+                 LLVMValueRef src,
+                 LLVMValueRef *dst_lo,
+                 LLVMValueRef *dst_hi);
+
+
+void
+lp_build_unpack(LLVMBuilderRef builder,
+                struct lp_type src_type,
+                struct lp_type dst_type,
+                LLVMValueRef src,
+                LLVMValueRef *dst, unsigned num_dsts);
+
+
+LLVMValueRef
+lp_build_packs2(LLVMBuilderRef builder,
+                struct lp_type src_type,
+                struct lp_type dst_type,
+                LLVMValueRef lo,
+                LLVMValueRef hi);
+
+
+LLVMValueRef
+lp_build_pack2(LLVMBuilderRef builder,
+               struct lp_type src_type,
+               struct lp_type dst_type,
+               LLVMValueRef lo,
+               LLVMValueRef hi);
+
+
+LLVMValueRef
+lp_build_pack(LLVMBuilderRef builder,
+              struct lp_type src_type,
+              struct lp_type dst_type,
+              boolean clamped,
+              const LLVMValueRef *src, unsigned num_srcs);
+
+
+#endif /* !LP_BLD_PACK_H */
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_sample.c b/src/gallium/drivers/llvmpipe/lp_bld_sample.c
new file mode 100644 (file)
index 0000000..9003e10
--- /dev/null
@@ -0,0 +1,190 @@
+/**************************************************************************
+ *
+ * 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 VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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
+ * Texture sampling -- common code.
+ *
+ * @author Jose Fonseca <jfonseca@vmware.com>
+ */
+
+#include "pipe/p_defines.h"
+#include "pipe/p_state.h"
+#include "util/u_format.h"
+#include "util/u_math.h"
+#include "lp_bld_debug.h"
+#include "lp_bld_const.h"
+#include "lp_bld_arit.h"
+#include "lp_bld_type.h"
+#include "lp_bld_format.h"
+#include "lp_bld_sample.h"
+
+
+void
+lp_sampler_static_state(struct lp_sampler_static_state *state,
+                        const struct pipe_texture *texture,
+                        const struct pipe_sampler_state *sampler)
+{
+   memset(state, 0, sizeof *state);
+
+   if(!texture)
+      return;
+
+   if(!sampler)
+      return;
+
+   state->format            = texture->format;
+   state->target            = texture->target;
+   state->pot_width         = util_is_pot(texture->width0);
+   state->pot_height        = util_is_pot(texture->height0);
+   state->pot_depth         = util_is_pot(texture->depth0);
+
+   state->wrap_s            = sampler->wrap_s;
+   state->wrap_t            = sampler->wrap_t;
+   state->wrap_r            = sampler->wrap_r;
+   state->min_img_filter    = sampler->min_img_filter;
+   state->min_mip_filter    = sampler->min_mip_filter;
+   state->mag_img_filter    = sampler->mag_img_filter;
+   state->compare_mode      = sampler->compare_mode;
+   if(sampler->compare_mode != PIPE_TEX_COMPARE_NONE) {
+      state->compare_func      = sampler->compare_func;
+   }
+   state->normalized_coords = sampler->normalized_coords;
+   state->prefilter         = sampler->prefilter;
+}
+
+
+/**
+ * Gather elements from scatter positions in memory into a single vector.
+ *
+ * @param src_width src element width
+ * @param dst_width result element width (source will be expanded to fit)
+ * @param length length of the offsets,
+ * @param base_ptr base pointer, should be a i8 pointer type.
+ * @param offsets vector with offsets
+ */
+LLVMValueRef
+lp_build_gather(LLVMBuilderRef builder,
+                unsigned length,
+                unsigned src_width,
+                unsigned dst_width,
+                LLVMValueRef base_ptr,
+                LLVMValueRef offsets)
+{
+   LLVMTypeRef src_type = LLVMIntType(src_width);
+   LLVMTypeRef src_ptr_type = LLVMPointerType(src_type, 0);
+   LLVMTypeRef dst_elem_type = LLVMIntType(dst_width);
+   LLVMTypeRef dst_vec_type = LLVMVectorType(dst_elem_type, length);
+   LLVMValueRef res;
+   unsigned i;
+
+   res = LLVMGetUndef(dst_vec_type);
+   for(i = 0; i < length; ++i) {
+      LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0);
+      LLVMValueRef elem_offset;
+      LLVMValueRef elem_ptr;
+      LLVMValueRef elem;
+
+      elem_offset = LLVMBuildExtractElement(builder, offsets, index, "");
+      elem_ptr = LLVMBuildGEP(builder, base_ptr, &elem_offset, 1, "");
+      elem_ptr = LLVMBuildBitCast(builder, elem_ptr, src_ptr_type, "");
+      elem = LLVMBuildLoad(builder, elem_ptr, "");
+
+      assert(src_width <= dst_width);
+      if(src_width > dst_width)
+         elem = LLVMBuildTrunc(builder, elem, dst_elem_type, "");
+      if(src_width < dst_width)
+         elem = LLVMBuildZExt(builder, elem, dst_elem_type, "");
+
+      res = LLVMBuildInsertElement(builder, res, elem, index, "");
+   }
+
+   return res;
+}
+
+
+/**
+ * Compute the offset of a pixel.
+ *
+ * x, y, y_stride are vectors
+ */
+LLVMValueRef
+lp_build_sample_offset(struct lp_build_context *bld,
+                       const struct util_format_description *format_desc,
+                       LLVMValueRef x,
+                       LLVMValueRef y,
+                       LLVMValueRef y_stride,
+                       LLVMValueRef data_ptr)
+{
+   LLVMValueRef x_stride;
+   LLVMValueRef offset;
+
+   x_stride = lp_build_const_scalar(bld->type, format_desc->block.bits/8);
+
+   if(format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) {
+      LLVMValueRef x_lo, x_hi;
+      LLVMValueRef y_lo, y_hi;
+      LLVMValueRef x_stride_lo, x_stride_hi;
+      LLVMValueRef y_stride_lo, y_stride_hi;
+      LLVMValueRef x_offset_lo, x_offset_hi;
+      LLVMValueRef y_offset_lo, y_offset_hi;
+      LLVMValueRef offset_lo, offset_hi;
+
+      x_lo = LLVMBuildAnd(bld->builder, x, bld->one, "");
+      y_lo = LLVMBuildAnd(bld->builder, y, bld->one, "");
+
+      x_hi = LLVMBuildLShr(bld->builder, x, bld->one, "");
+      y_hi = LLVMBuildLShr(bld->builder, y, bld->one, "");
+
+      x_stride_lo = x_stride;
+      y_stride_lo = lp_build_const_scalar(bld->type, 2*format_desc->block.bits/8);
+
+      x_stride_hi = lp_build_const_scalar(bld->type, 4*format_desc->block.bits/8);
+      y_stride_hi = LLVMBuildShl(bld->builder, y_stride, bld->one, "");
+
+      x_offset_lo = lp_build_mul(bld, x_lo, x_stride_lo);
+      y_offset_lo = lp_build_mul(bld, y_lo, y_stride_lo);
+      offset_lo = lp_build_add(bld, x_offset_lo, y_offset_lo);
+
+      x_offset_hi = lp_build_mul(bld, x_hi, x_stride_hi);
+      y_offset_hi = lp_build_mul(bld, y_hi, y_stride_hi);
+      offset_hi = lp_build_add(bld, x_offset_hi, y_offset_hi);
+
+      offset = lp_build_add(bld, offset_hi, offset_lo);
+   }
+   else {
+      LLVMValueRef x_offset;
+      LLVMValueRef y_offset;
+
+      x_offset = lp_build_mul(bld, x, x_stride);
+      y_offset = lp_build_mul(bld, y, y_stride);
+
+      offset = lp_build_add(bld, x_offset, y_offset);
+   }
+
+   return offset;
+}
index 403d0e48367b5e95e7865533ad50f45dc5679f50..8cb8210ca76586af9ca2e6093f8f31fa042cdf59 100644 (file)
@@ -40,7 +40,9 @@
 
 struct pipe_texture;
 struct pipe_sampler_state;
+struct util_format_description;
 struct lp_type;
+struct lp_build_context;
 
 
 /**
@@ -119,6 +121,24 @@ lp_sampler_static_state(struct lp_sampler_static_state *state,
                         const struct pipe_sampler_state *sampler);
 
 
+LLVMValueRef
+lp_build_gather(LLVMBuilderRef builder,
+                unsigned length,
+                unsigned src_width,
+                unsigned dst_width,
+                LLVMValueRef base_ptr,
+                LLVMValueRef offsets);
+
+
+LLVMValueRef
+lp_build_sample_offset(struct lp_build_context *bld,
+                       const struct util_format_description *format_desc,
+                       LLVMValueRef x,
+                       LLVMValueRef y,
+                       LLVMValueRef y_stride,
+                       LLVMValueRef data_ptr);
+
+
 void
 lp_build_sample_soa(LLVMBuilderRef builder,
                     const struct lp_sampler_static_state *static_state,
index 1a47ca32d2d631c6549db46becb0b8a77db152dd..5ee8d556a687cfc334781dbd1de78d00ff28cd8a 100644 (file)
@@ -27,7 +27,7 @@
 
 /**
  * @file
- * Texture sampling.
+ * Texture sampling -- SoA.
  *
  * @author Jose Fonseca <jfonseca@vmware.com>
  */
 #include "pipe/p_defines.h"
 #include "pipe/p_state.h"
 #include "util/u_debug.h"
+#include "util/u_debug_dump.h"
 #include "util/u_memory.h"
 #include "util/u_math.h"
 #include "util/u_format.h"
+#include "util/u_cpu_detect.h"
 #include "lp_bld_debug.h"
 #include "lp_bld_type.h"
 #include "lp_bld_const.h"
+#include "lp_bld_conv.h"
 #include "lp_bld_arit.h"
 #include "lp_bld_logic.h"
 #include "lp_bld_swizzle.h"
+#include "lp_bld_pack.h"
 #include "lp_bld_format.h"
 #include "lp_bld_sample.h"
 
 
-void
-lp_sampler_static_state(struct lp_sampler_static_state *state,
-                        const struct pipe_texture *texture,
-                        const struct pipe_sampler_state *sampler)
-{
-   memset(state, 0, sizeof *state);
-
-   if(!texture)
-      return;
-
-   if(!sampler)
-      return;
-
-   state->format            = texture->format;
-   state->target            = texture->target;
-   state->pot_width         = util_is_pot(texture->width[0]);
-   state->pot_height        = util_is_pot(texture->height[0]);
-   state->pot_depth         = util_is_pot(texture->depth[0]);
-
-   state->wrap_s            = sampler->wrap_s;
-   state->wrap_t            = sampler->wrap_t;
-   state->wrap_r            = sampler->wrap_r;
-   state->min_img_filter    = sampler->min_img_filter;
-   state->min_mip_filter    = sampler->min_mip_filter;
-   state->mag_img_filter    = sampler->mag_img_filter;
-   if(sampler->compare_mode) {
-      state->compare_mode      = sampler->compare_mode;
-      state->compare_func      = sampler->compare_func;
-   }
-   state->normalized_coords = sampler->normalized_coords;
-   state->prefilter         = sampler->prefilter;
-}
-
-
-
 /**
  * Keep all information for sampling code generation in a single place.
  */
@@ -111,66 +80,61 @@ struct lp_build_sample_context
 
 
 static void
-lp_build_sample_texel(struct lp_build_sample_context *bld,
-                      LLVMValueRef x,
-                      LLVMValueRef y,
-                      LLVMValueRef y_stride,
-                      LLVMValueRef data_ptr,
-                      LLVMValueRef *texel)
+lp_build_sample_texel_soa(struct lp_build_sample_context *bld,
+                          LLVMValueRef x,
+                          LLVMValueRef y,
+                          LLVMValueRef y_stride,
+                          LLVMValueRef data_ptr,
+                          LLVMValueRef *texel)
 {
-   struct lp_build_context *int_coord_bld = &bld->int_coord_bld;
-   LLVMValueRef x_stride;
    LLVMValueRef offset;
+   LLVMValueRef packed;
+
+   offset = lp_build_sample_offset(&bld->int_coord_bld,
+                                   bld->format_desc,
+                                   x, y, y_stride,
+                                   data_ptr);
+
+   assert(bld->format_desc->block.width == 1);
+   assert(bld->format_desc->block.height == 1);
+   assert(bld->format_desc->block.bits <= bld->texel_type.width);
+
+   packed = lp_build_gather(bld->builder,
+                            bld->texel_type.length,
+                            bld->format_desc->block.bits,
+                            bld->texel_type.width,
+                            data_ptr, offset);
+
+   lp_build_unpack_rgba_soa(bld->builder,
+                            bld->format_desc,
+                            bld->texel_type,
+                            packed, texel);
+}
 
-   x_stride = lp_build_const_scalar(bld->int_coord_type, bld->format_desc->block.bits/8);
-
-   if(bld->format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) {
-      LLVMValueRef x_lo, x_hi;
-      LLVMValueRef y_lo, y_hi;
-      LLVMValueRef x_stride_lo, x_stride_hi;
-      LLVMValueRef y_stride_lo, y_stride_hi;
-      LLVMValueRef x_offset_lo, x_offset_hi;
-      LLVMValueRef y_offset_lo, y_offset_hi;
-      LLVMValueRef offset_lo, offset_hi;
-
-      x_lo = LLVMBuildAnd(bld->builder, x, int_coord_bld->one, "");
-      y_lo = LLVMBuildAnd(bld->builder, y, int_coord_bld->one, "");
-
-      x_hi = LLVMBuildLShr(bld->builder, x, int_coord_bld->one, "");
-      y_hi = LLVMBuildLShr(bld->builder, y, int_coord_bld->one, "");
-
-      x_stride_lo = x_stride;
-      y_stride_lo = lp_build_const_scalar(bld->int_coord_type, 2*bld->format_desc->block.bits/8);
-
-      x_stride_hi = lp_build_const_scalar(bld->int_coord_type, 4*bld->format_desc->block.bits/8);
-      y_stride_hi = LLVMBuildShl(bld->builder, y_stride, int_coord_bld->one, "");
-
-      x_offset_lo = lp_build_mul(int_coord_bld, x_lo, x_stride_lo);
-      y_offset_lo = lp_build_mul(int_coord_bld, y_lo, y_stride_lo);
-      offset_lo = lp_build_add(int_coord_bld, x_offset_lo, y_offset_lo);
-
-      x_offset_hi = lp_build_mul(int_coord_bld, x_hi, x_stride_hi);
-      y_offset_hi = lp_build_mul(int_coord_bld, y_hi, y_stride_hi);
-      offset_hi = lp_build_add(int_coord_bld, x_offset_hi, y_offset_hi);
 
-      offset = lp_build_add(int_coord_bld, offset_hi, offset_lo);
-   }
-   else {
-      LLVMValueRef x_offset;
-      LLVMValueRef y_offset;
+static LLVMValueRef
+lp_build_sample_packed(struct lp_build_sample_context *bld,
+                       LLVMValueRef x,
+                       LLVMValueRef y,
+                       LLVMValueRef y_stride,
+                       LLVMValueRef data_ptr)
+{
+   LLVMValueRef offset;
 
-      x_offset = lp_build_mul(int_coord_bld, x, x_stride);
-      y_offset = lp_build_mul(int_coord_bld, y, y_stride);
+   offset = lp_build_sample_offset(&bld->int_coord_bld,
+                                   bld->format_desc,
+                                   x, y, y_stride,
+                                   data_ptr);
 
-      offset = lp_build_add(int_coord_bld, x_offset, y_offset);
-   }
+   assert(bld->format_desc->block.width == 1);
+   assert(bld->format_desc->block.height == 1);
+   assert(bld->format_desc->block.bits <= bld->texel_type.width);
 
-   lp_build_load_rgba_soa(bld->builder,
-                          bld->format_desc,
-                          bld->texel_type,
-                          data_ptr,
-                          offset,
-                          texel);
+   return lp_build_gather(bld->builder,
+                          bld->texel_type.length,
+                          bld->format_desc->block.bits,
+                          bld->texel_type.width,
+                          data_ptr, offset);
 }
 
 
@@ -208,7 +172,8 @@ lp_build_sample_wrap(struct lp_build_sample_context *bld,
    case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
    case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
       /* FIXME */
-      _debug_printf("warning: failed to translate texture wrap mode %u\n", wrap_mode);
+      _debug_printf("warning: failed to translate texture wrap mode %s\n",
+                    debug_dump_tex_wrap(wrap_mode, TRUE));
       coord = lp_build_max(int_coord_bld, coord, int_coord_bld->zero);
       coord = lp_build_min(int_coord_bld, coord, length_minus_one);
       break;
@@ -240,7 +205,7 @@ lp_build_sample_2d_nearest_soa(struct lp_build_sample_context *bld,
    x = lp_build_sample_wrap(bld, x, width,  bld->static_state->pot_width,  bld->static_state->wrap_s);
    y = lp_build_sample_wrap(bld, y, height, bld->static_state->pot_height, bld->static_state->wrap_t);
 
-   lp_build_sample_texel(bld, x, y, stride, data_ptr, texel);
+   lp_build_sample_texel_soa(bld, x, y, stride, data_ptr, texel);
 }
 
 
@@ -286,10 +251,10 @@ lp_build_sample_2d_linear_soa(struct lp_build_sample_context *bld,
    x1 = lp_build_sample_wrap(bld, x1, width,  bld->static_state->pot_width,  bld->static_state->wrap_s);
    y1 = lp_build_sample_wrap(bld, y1, height, bld->static_state->pot_height, bld->static_state->wrap_t);
 
-   lp_build_sample_texel(bld, x0, y0, stride, data_ptr, neighbors[0][0]);
-   lp_build_sample_texel(bld, x1, y0, stride, data_ptr, neighbors[0][1]);
-   lp_build_sample_texel(bld, x0, y1, stride, data_ptr, neighbors[1][0]);
-   lp_build_sample_texel(bld, x1, y1, stride, data_ptr, neighbors[1][1]);
+   lp_build_sample_texel_soa(bld, x0, y0, stride, data_ptr, neighbors[0][0]);
+   lp_build_sample_texel_soa(bld, x1, y0, stride, data_ptr, neighbors[0][1]);
+   lp_build_sample_texel_soa(bld, x0, y1, stride, data_ptr, neighbors[1][0]);
+   lp_build_sample_texel_soa(bld, x1, y1, stride, data_ptr, neighbors[1][1]);
 
    /* TODO: Don't interpolate missing channels */
    for(chan = 0; chan < 4; ++chan) {
@@ -303,6 +268,217 @@ lp_build_sample_2d_linear_soa(struct lp_build_sample_context *bld,
 }
 
 
+static void
+lp_build_rgba8_to_f32_soa(LLVMBuilderRef builder,
+                          struct lp_type dst_type,
+                          LLVMValueRef packed,
+                          LLVMValueRef *rgba)
+{
+   LLVMValueRef mask = lp_build_int_const_scalar(dst_type, 0xff);
+   unsigned chan;
+
+   /* Decode the input vector components */
+   for (chan = 0; chan < 4; ++chan) {
+      unsigned start = chan*8;
+      unsigned stop = start + 8;
+      LLVMValueRef input;
+
+      input = packed;
+
+      if(start)
+         input = LLVMBuildLShr(builder, input, lp_build_int_const_scalar(dst_type, start), "");
+
+      if(stop < 32)
+         input = LLVMBuildAnd(builder, input, mask, "");
+
+      input = lp_build_unsigned_norm_to_float(builder, 8, dst_type, input);
+
+      rgba[chan] = input;
+   }
+}
+
+
+static void
+lp_build_sample_2d_linear_aos(struct lp_build_sample_context *bld,
+                              LLVMValueRef s,
+                              LLVMValueRef t,
+                              LLVMValueRef width,
+                              LLVMValueRef height,
+                              LLVMValueRef stride,
+                              LLVMValueRef data_ptr,
+                              LLVMValueRef *texel)
+{
+   LLVMBuilderRef builder = bld->builder;
+   struct lp_build_context i32, h16, u8n;
+   LLVMTypeRef i32_vec_type, h16_vec_type, u8n_vec_type;
+   LLVMValueRef i32_c8, i32_c128, i32_c255;
+   LLVMValueRef s_ipart, s_fpart, s_fpart_lo, s_fpart_hi;
+   LLVMValueRef t_ipart, t_fpart, t_fpart_lo, t_fpart_hi;
+   LLVMValueRef x0, x1;
+   LLVMValueRef y0, y1;
+   LLVMValueRef neighbors[2][2];
+   LLVMValueRef neighbors_lo[2][2];
+   LLVMValueRef neighbors_hi[2][2];
+   LLVMValueRef packed, packed_lo, packed_hi;
+   LLVMValueRef unswizzled[4];
+
+   lp_build_context_init(&i32, builder, lp_type_int(32));
+   lp_build_context_init(&h16, builder, lp_type_ufixed(16));
+   lp_build_context_init(&u8n, builder, lp_type_unorm(8));
+
+   i32_vec_type = lp_build_vec_type(i32.type);
+   h16_vec_type = lp_build_vec_type(h16.type);
+   u8n_vec_type = lp_build_vec_type(u8n.type);
+
+   s = lp_build_mul_imm(&bld->coord_bld, s, 256);
+   t = lp_build_mul_imm(&bld->coord_bld, t, 256);
+
+   s = LLVMBuildFPToSI(builder, s, i32_vec_type, "");
+   t = LLVMBuildFPToSI(builder, t, i32_vec_type, "");
+
+   i32_c128 = lp_build_int_const_scalar(i32.type, -128);
+   s = LLVMBuildAdd(builder, s, i32_c128, "");
+   t = LLVMBuildAdd(builder, t, i32_c128, "");
+
+   i32_c8 = lp_build_int_const_scalar(i32.type, 8);
+   s_ipart = LLVMBuildAShr(builder, s, i32_c8, "");
+   t_ipart = LLVMBuildAShr(builder, t, i32_c8, "");
+
+   i32_c255 = lp_build_int_const_scalar(i32.type, 255);
+   s_fpart = LLVMBuildAnd(builder, s, i32_c255, "");
+   t_fpart = LLVMBuildAnd(builder, t, i32_c255, "");
+
+   x0 = s_ipart;
+   y0 = t_ipart;
+
+   x0 = lp_build_sample_wrap(bld, x0, width,  bld->static_state->pot_width,  bld->static_state->wrap_s);
+   y0 = lp_build_sample_wrap(bld, y0, height, bld->static_state->pot_height, bld->static_state->wrap_t);
+
+   x1 = lp_build_add(&bld->int_coord_bld, x0, bld->int_coord_bld.one);
+   y1 = lp_build_add(&bld->int_coord_bld, y0, bld->int_coord_bld.one);
+
+   x1 = lp_build_sample_wrap(bld, x1, width,  bld->static_state->pot_width,  bld->static_state->wrap_s);
+   y1 = lp_build_sample_wrap(bld, y1, height, bld->static_state->pot_height, bld->static_state->wrap_t);
+
+   /*
+    * Transform 4 x i32 in
+    *
+    *   s_fpart = {s0, s1, s2, s3}
+    *
+    * into 8 x i16
+    *
+    *   s_fpart = {00, s0, 00, s1, 00, s2, 00, s3}
+    *
+    * into two 8 x i16
+    *
+    *   s_fpart_lo = {s0, s0, s0, s0, s1, s1, s1, s1}
+    *   s_fpart_hi = {s2, s2, s2, s2, s3, s3, s3, s3}
+    *
+    * and likewise for t_fpart. There is no risk of loosing precision here
+    * since the fractional parts only use the lower 8bits.
+    */
+
+   s_fpart = LLVMBuildBitCast(builder, s_fpart, h16_vec_type, "");
+   t_fpart = LLVMBuildBitCast(builder, t_fpart, h16_vec_type, "");
+
+   {
+      LLVMTypeRef elem_type = LLVMInt32Type();
+      LLVMValueRef shuffles_lo[LP_MAX_VECTOR_LENGTH];
+      LLVMValueRef shuffles_hi[LP_MAX_VECTOR_LENGTH];
+      LLVMValueRef shuffle_lo;
+      LLVMValueRef shuffle_hi;
+      unsigned i, j;
+
+      for(j = 0; j < h16.type.length; j += 4) {
+         unsigned subindex = util_cpu_caps.little_endian ? 0 : 1;
+         LLVMValueRef index;
+
+         index = LLVMConstInt(elem_type, j/2 + subindex, 0);
+         for(i = 0; i < 4; ++i)
+            shuffles_lo[j + i] = index;
+
+         index = LLVMConstInt(elem_type, h16.type.length/2 + j/2 + subindex, 0);
+         for(i = 0; i < 4; ++i)
+            shuffles_hi[j + i] = index;
+      }
+
+      shuffle_lo = LLVMConstVector(shuffles_lo, h16.type.length);
+      shuffle_hi = LLVMConstVector(shuffles_hi, h16.type.length);
+
+      s_fpart_lo = LLVMBuildShuffleVector(builder, s_fpart, h16.undef, shuffle_lo, "");
+      t_fpart_lo = LLVMBuildShuffleVector(builder, t_fpart, h16.undef, shuffle_lo, "");
+      s_fpart_hi = LLVMBuildShuffleVector(builder, s_fpart, h16.undef, shuffle_hi, "");
+      t_fpart_hi = LLVMBuildShuffleVector(builder, t_fpart, h16.undef, shuffle_hi, "");
+   }
+
+   /*
+    * Fetch the pixels as 4 x 32bit (rgba order might differ):
+    *
+    *   rgba0 rgba1 rgba2 rgba3
+    *
+    * bit cast them into 16 x u8
+    *
+    *   r0 g0 b0 a0 r1 g1 b1 a1 r2 g2 b2 a2 r3 g3 b3 a3
+    *
+    * unpack them into two 8 x i16:
+    *
+    *   r0 g0 b0 a0 r1 g1 b1 a1
+    *   r2 g2 b2 a2 r3 g3 b3 a3
+    *
+    * The higher 8 bits of the resulting elements will be zero.
+    */
+
+   neighbors[0][0] = lp_build_sample_packed(bld, x0, y0, stride, data_ptr);
+   neighbors[0][1] = lp_build_sample_packed(bld, x1, y0, stride, data_ptr);
+   neighbors[1][0] = lp_build_sample_packed(bld, x0, y1, stride, data_ptr);
+   neighbors[1][1] = lp_build_sample_packed(bld, x1, y1, stride, data_ptr);
+
+   neighbors[0][0] = LLVMBuildBitCast(builder, neighbors[0][0], u8n_vec_type, "");
+   neighbors[0][1] = LLVMBuildBitCast(builder, neighbors[0][1], u8n_vec_type, "");
+   neighbors[1][0] = LLVMBuildBitCast(builder, neighbors[1][0], u8n_vec_type, "");
+   neighbors[1][1] = LLVMBuildBitCast(builder, neighbors[1][1], u8n_vec_type, "");
+
+   lp_build_unpack2(builder, u8n.type, h16.type, neighbors[0][0], &neighbors_lo[0][0], &neighbors_hi[0][0]);
+   lp_build_unpack2(builder, u8n.type, h16.type, neighbors[0][1], &neighbors_lo[0][1], &neighbors_hi[0][1]);
+   lp_build_unpack2(builder, u8n.type, h16.type, neighbors[1][0], &neighbors_lo[1][0], &neighbors_hi[1][0]);
+   lp_build_unpack2(builder, u8n.type, h16.type, neighbors[1][1], &neighbors_lo[1][1], &neighbors_hi[1][1]);
+
+   /*
+    * Linear interpolate with 8.8 fixed point.
+    */
+
+   packed_lo = lp_build_lerp_2d(&h16,
+                                s_fpart_lo, t_fpart_lo,
+                                neighbors_lo[0][0],
+                                neighbors_lo[0][1],
+                                neighbors_lo[1][0],
+                                neighbors_lo[1][1]);
+
+   packed_hi = lp_build_lerp_2d(&h16,
+                                s_fpart_hi, t_fpart_hi,
+                                neighbors_hi[0][0],
+                                neighbors_hi[0][1],
+                                neighbors_hi[1][0],
+                                neighbors_hi[1][1]);
+
+   packed = lp_build_pack2(builder, h16.type, u8n.type, packed_lo, packed_hi);
+
+   /*
+    * Convert to SoA and swizzle.
+    */
+
+   packed = LLVMBuildBitCast(builder, packed, i32_vec_type, "");
+
+   lp_build_rgba8_to_f32_soa(bld->builder,
+                             bld->texel_type,
+                             packed, unswizzled);
+
+   lp_build_format_swizzle_soa(bld->format_desc,
+                               bld->texel_type, unswizzled,
+                               texel);
+}
+
+
 static void
 lp_build_sample_compare(struct lp_build_sample_context *bld,
                         LLVMValueRef p,
@@ -312,7 +488,7 @@ lp_build_sample_compare(struct lp_build_sample_context *bld,
    LLVMValueRef res;
    unsigned chan;
 
-   if(!bld->static_state->compare_mode)
+   if(bld->static_state->compare_mode == PIPE_TEX_COMPARE_NONE)
       return;
 
    /* TODO: Compare before swizzling, to avoid redundant computations */
@@ -401,8 +577,10 @@ lp_build_sample_soa(LLVMBuilderRef builder,
       lp_build_sample_2d_nearest_soa(&bld, s, t, width, height, stride, data_ptr, texel);
       break;
    case PIPE_TEX_FILTER_LINEAR:
-   case PIPE_TEX_FILTER_ANISO:
-      lp_build_sample_2d_linear_soa(&bld, s, t, width, height, stride, data_ptr, texel);
+      if(lp_format_is_rgba8(bld.format_desc))
+         lp_build_sample_2d_linear_aos(&bld, s, t, width, height, stride, data_ptr, texel);
+      else
+         lp_build_sample_2d_linear_soa(&bld, s, t, width, height, stride, data_ptr, texel);
       break;
    default:
       assert(0);
index 1f6da8044886974999c391a2296eb72db4530a97..b9472127a6322e2485aea8e8fd2fc38bae17d4c6 100644 (file)
@@ -40,7 +40,7 @@
 #include <llvm-c/Core.h>  
 
 
-struct lp_type type;
+struct lp_type;
 struct lp_build_context;
 
 
index 83ac25bb200d61c1292eb1015bab2c47a2f8586c..fb1eda4423ba4db3047ae131839be2135619e5c4 100644 (file)
@@ -64,7 +64,7 @@
    for (CHAN = 0; CHAN < NUM_CHANNELS; CHAN++)
 
 #define IS_DST0_CHANNEL_ENABLED( INST, CHAN )\
-   ((INST)->FullDstRegisters[0].DstRegister.WriteMask & (1 << (CHAN)))
+   ((INST)->Dst[0].Register.WriteMask & (1 << (CHAN)))
 
 #define IF_IS_DST0_CHANNEL_ENABLED( INST, CHAN )\
    if (IS_DST0_CHANNEL_ENABLED( INST, CHAN ))
@@ -157,19 +157,19 @@ emit_fetch(
    unsigned index,
    const unsigned chan_index )
 {
-   const struct tgsi_full_src_register *reg = &inst->FullSrcRegisters[index];
-   unsigned swizzle = tgsi_util_get_full_src_register_extswizzle( reg, chan_index );
+   const struct tgsi_full_src_register *reg = &inst->Src[index];
+   unsigned swizzle = tgsi_util_get_full_src_register_swizzle( reg, chan_index );
    LLVMValueRef res;
 
    switch (swizzle) {
-   case TGSI_EXTSWIZZLE_X:
-   case TGSI_EXTSWIZZLE_Y:
-   case TGSI_EXTSWIZZLE_Z:
-   case TGSI_EXTSWIZZLE_W:
+   case TGSI_SWIZZLE_X:
+   case TGSI_SWIZZLE_Y:
+   case TGSI_SWIZZLE_Z:
+   case TGSI_SWIZZLE_W:
 
-      switch (reg->SrcRegister.File) {
+      switch (reg->Register.File) {
       case TGSI_FILE_CONSTANT: {
-         LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), reg->SrcRegister.Index*4 + swizzle, 0);
+         LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), reg->Register.Index*4 + swizzle, 0);
          LLVMValueRef scalar_ptr = LLVMBuildGEP(bld->base.builder, bld->consts_ptr, &index, 1, "");
          LLVMValueRef scalar = LLVMBuildLoad(bld->base.builder, scalar_ptr, "");
          res = lp_build_broadcast_scalar(&bld->base, scalar);
@@ -177,17 +177,17 @@ emit_fetch(
       }
 
       case TGSI_FILE_IMMEDIATE:
-         res = bld->immediates[reg->SrcRegister.Index][swizzle];
+         res = bld->immediates[reg->Register.Index][swizzle];
          assert(res);
          break;
 
       case TGSI_FILE_INPUT:
-         res = bld->inputs[reg->SrcRegister.Index][swizzle];
+         res = bld->inputs[reg->Register.Index][swizzle];
          assert(res);
          break;
 
       case TGSI_FILE_TEMPORARY:
-         res = bld->temps[reg->SrcRegister.Index][swizzle];
+         res = bld->temps[reg->Register.Index][swizzle];
          if(!res)
             return bld->base.undef;
          break;
@@ -198,14 +198,6 @@ emit_fetch(
       }
       break;
 
-   case TGSI_EXTSWIZZLE_ZERO:
-      res = bld->base.zero;
-      break;
-
-   case TGSI_EXTSWIZZLE_ONE:
-      res = bld->base.one;
-      break;
-
    default:
       assert( 0 );
       return bld->base.undef;
@@ -275,7 +267,7 @@ emit_store(
    unsigned chan_index,
    LLVMValueRef value)
 {
-   const struct tgsi_full_dst_register *reg = &inst->FullDstRegisters[index];
+   const struct tgsi_full_dst_register *reg = &inst->Dst[index];
 
    switch( inst->Instruction.Saturate ) {
    case TGSI_SAT_NONE:
@@ -295,13 +287,13 @@ emit_store(
       assert(0);
    }
 
-   switch( reg->DstRegister.File ) {
+   switch( reg->Register.File ) {
    case TGSI_FILE_OUTPUT:
-      bld->outputs[reg->DstRegister.Index][chan_index] = value;
+      bld->outputs[reg->Register.Index][chan_index] = value;
       break;
 
    case TGSI_FILE_TEMPORARY:
-      bld->temps[reg->DstRegister.Index][chan_index] = value;
+      bld->temps[reg->Register.Index][chan_index] = value;
       break;
 
    case TGSI_FILE_ADDRESS:
@@ -327,14 +319,14 @@ emit_tex( struct lp_build_tgsi_soa_context *bld,
           boolean projected,
           LLVMValueRef *texel)
 {
-   const uint unit = inst->FullSrcRegisters[1].SrcRegister.Index;
+   const uint unit = inst->Src[1].Register.Index;
    LLVMValueRef lodbias;
-   LLVMValueRef oow;
+   LLVMValueRef oow = NULL;
    LLVMValueRef coords[3];
    unsigned num_coords;
    unsigned i;
 
-   switch (inst->InstructionExtTexture.Texture) {
+   switch (inst->Texture.Texture) {
    case TGSI_TEXTURE_1D:
       num_coords = 1;
       break;
@@ -369,6 +361,9 @@ emit_tex( struct lp_build_tgsi_soa_context *bld,
       if (projected)
          coords[i] = lp_build_mul(&bld->base, coords[i], oow);
    }
+   for (i = num_coords; i < 3; i++) {
+      coords[i] = bld->base.undef;
+   }
 
    bld->sampler->emit_fetch_texel(bld->sampler,
                                   bld->base.builder,
@@ -383,7 +378,7 @@ emit_kil(
    struct lp_build_tgsi_soa_context *bld,
    const struct tgsi_full_instruction *inst )
 {
-   const struct tgsi_full_src_register *reg = &inst->FullSrcRegisters[0];
+   const struct tgsi_full_src_register *reg = &inst->Src[0];
    LLVMValueRef terms[NUM_CHANNELS];
    LLVMValueRef mask;
    unsigned chan_index;
@@ -394,12 +389,7 @@ emit_kil(
       unsigned swizzle;
 
       /* Unswizzle channel */
-      swizzle = tgsi_util_get_full_src_register_extswizzle( reg, chan_index );
-
-      /* Note that we test if the value is less than zero, so 1.0 and 0.0 need
-       * not to be tested. */
-      if(swizzle == TGSI_EXTSWIZZLE_ZERO || swizzle == TGSI_EXTSWIZZLE_ONE)
-         continue;
+      swizzle = tgsi_util_get_full_src_register_swizzle( reg, chan_index );
 
       /* Check if the component has not been already tested. */
       assert(swizzle < NUM_CHANNELS);
@@ -436,15 +426,15 @@ indirect_temp_reference(const struct tgsi_full_instruction *inst)
 {
    uint i;
    for (i = 0; i < inst->Instruction.NumSrcRegs; i++) {
-      const struct tgsi_full_src_register *reg = &inst->FullSrcRegisters[i];
-      if (reg->SrcRegister.File == TGSI_FILE_TEMPORARY &&
-          reg->SrcRegister.Indirect)
+      const struct tgsi_full_src_register *reg = &inst->Src[i];
+      if (reg->Register.File == TGSI_FILE_TEMPORARY &&
+          reg->Register.Indirect)
          return TRUE;
    }
    for (i = 0; i < inst->Instruction.NumDstRegs; i++) {
-      const struct tgsi_full_dst_register *reg = &inst->FullDstRegisters[i];
-      if (reg->DstRegister.File == TGSI_FILE_TEMPORARY &&
-          reg->DstRegister.Indirect)
+      const struct tgsi_full_dst_register *reg = &inst->Dst[i];
+      if (reg->Register.File == TGSI_FILE_TEMPORARY &&
+          reg->Register.Indirect)
          return TRUE;
    }
    return FALSE;
@@ -459,7 +449,12 @@ emit_instruction(
 {
    unsigned chan_index;
    LLVMValueRef src0, src1, src2;
-   LLVMValueRef tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
+   LLVMValueRef tmp0, tmp1, tmp2;
+   LLVMValueRef tmp3 = NULL;
+   LLVMValueRef tmp4 = NULL;
+   LLVMValueRef tmp5 = NULL;
+   LLVMValueRef tmp6 = NULL;
+   LLVMValueRef tmp7 = NULL;
    LLVMValueRef res;
    LLVMValueRef dst0[NUM_CHANNELS];
 
@@ -488,7 +483,6 @@ emit_instruction(
 #endif
 
    case TGSI_OPCODE_MOV:
-   case TGSI_OPCODE_SWZ:
       FOR_EACH_DST0_ENABLED_CHANNEL( inst, chan_index ) {
          dst0[chan_index] = emit_fetch( bld, inst, 0, chan_index );
       }
@@ -574,9 +568,9 @@ emit_instruction(
       if (IS_DST0_CHANNEL_ENABLED( inst, CHAN_X ) ||
           IS_DST0_CHANNEL_ENABLED( inst, CHAN_Y ) ||
           IS_DST0_CHANNEL_ENABLED( inst, CHAN_Z )) {
-         LLVMValueRef *p_floor_log2;
-         LLVMValueRef *p_exp;
-         LLVMValueRef *p_log2;
+         LLVMValueRef *p_floor_log2 = NULL;
+         LLVMValueRef *p_exp = NULL;
+         LLVMValueRef *p_log2 = NULL;
 
          src0 = emit_fetch( bld, inst, 0, CHAN_X );
          src0 = lp_build_abs( &bld->base, src0 );
@@ -1324,7 +1318,7 @@ emit_instruction(
       return 0;
       break;
 
-   case TGSI_OPCODE_SHR:
+   case TGSI_OPCODE_ISHR:
       /* deprecated? */
       assert(0);
       return 0;
@@ -1386,15 +1380,6 @@ emit_instruction(
       return 0;
       break;
 
-   case TGSI_OPCODE_NOISE1:
-   case TGSI_OPCODE_NOISE2:
-   case TGSI_OPCODE_NOISE3:
-   case TGSI_OPCODE_NOISE4:
-      FOR_EACH_DST0_ENABLED_CHANNEL( inst, chan_index ) {
-         dst0[chan_index] = bld->base.zero;
-      }
-      break;
-
    case TGSI_OPCODE_NOP:
       break;
 
index e8cf7256c0ebeb32e93efd228dbfe6b56f7d9270..8270cd057f61c114c2f532d09d331f212194bac5 100644 (file)
@@ -161,7 +161,7 @@ lp_build_int_vec_type(struct lp_type type)
  * Build int32[4] vector type
  */
 LLVMTypeRef
-lp_build_int32_vec4_type()
+lp_build_int32_vec4_type(void)
 {
    struct lp_type t;
    LLVMTypeRef type;
@@ -181,12 +181,31 @@ lp_build_int32_vec4_type()
 struct lp_type
 lp_int_type(struct lp_type type)
 {
-   struct lp_type int_type;
+   struct lp_type res_type;
 
-   memset(&int_type, 0, sizeof int_type);
-   int_type.width = type.width;
-   int_type.length = type.length;
-   return int_type;
+   memset(&res_type, 0, sizeof res_type);
+   res_type.width = type.width;
+   res_type.length = type.length;
+
+   return res_type;
+}
+
+
+/**
+ * Return the type with twice the bit width (hence half the number of elements).
+ */
+struct lp_type
+lp_wider_type(struct lp_type type)
+{
+   struct lp_type res_type;
+
+   memcpy(&res_type, &type, sizeof res_type);
+   res_type.width *= 2;
+   res_type.length /= 2;
+
+   assert(res_type.length);
+
+   return res_type;
 }
 
 
index 118fb339089c3375d7434204fb660cbc67959416..b7d8aed396dec41d0b984128521bf58b797453f1 100644 (file)
 #include <pipe/p_compiler.h>
 
 
+/**
+ * Native SIMD register width.
+ *
+ * 128 for all architectures we care about.
+ */
+#define LP_NATIVE_VECTOR_WIDTH 128
+
 /**
  * Several functions can only cope with vectors of length up to this value.
  * You may need to increase that value if you want to represent bigger vectors.
  */
 #define LP_MAX_VECTOR_LENGTH 16
 
-#define LP_MAX_TYPE_WIDTH 64
-
 
 /**
  * The LLVM type system can't conveniently express all the things we care about
@@ -134,6 +139,91 @@ struct lp_build_context
 };
 
 
+static INLINE struct lp_type
+lp_type_float(unsigned width)
+{
+   struct lp_type res_type;
+
+   memset(&res_type, 0, sizeof res_type);
+   res_type.floating = TRUE;
+   res_type.sign = TRUE;
+   res_type.width = width;
+   res_type.length = LP_NATIVE_VECTOR_WIDTH / width;
+
+   return res_type;
+}
+
+
+static INLINE struct lp_type
+lp_type_int(unsigned width)
+{
+   struct lp_type res_type;
+
+   memset(&res_type, 0, sizeof res_type);
+   res_type.sign = TRUE;
+   res_type.width = width;
+   res_type.length = LP_NATIVE_VECTOR_WIDTH / width;
+
+   return res_type;
+}
+
+
+static INLINE struct lp_type
+lp_type_uint(unsigned width)
+{
+   struct lp_type res_type;
+
+   memset(&res_type, 0, sizeof res_type);
+   res_type.width = width;
+   res_type.length = LP_NATIVE_VECTOR_WIDTH / width;
+
+   return res_type;
+}
+
+
+static INLINE struct lp_type
+lp_type_unorm(unsigned width)
+{
+   struct lp_type res_type;
+
+   memset(&res_type, 0, sizeof res_type);
+   res_type.norm = TRUE;
+   res_type.width = width;
+   res_type.length = LP_NATIVE_VECTOR_WIDTH / width;
+
+   return res_type;
+}
+
+
+static INLINE struct lp_type
+lp_type_fixed(unsigned width)
+{
+   struct lp_type res_type;
+
+   memset(&res_type, 0, sizeof res_type);
+   res_type.sign = TRUE;
+   res_type.fixed = TRUE;
+   res_type.width = width;
+   res_type.length = LP_NATIVE_VECTOR_WIDTH / width;
+
+   return res_type;
+}
+
+
+static INLINE struct lp_type
+lp_type_ufixed(unsigned width)
+{
+   struct lp_type res_type;
+
+   memset(&res_type, 0, sizeof res_type);
+   res_type.fixed = TRUE;
+   res_type.width = width;
+   res_type.length = LP_NATIVE_VECTOR_WIDTH / width;
+
+   return res_type;
+}
+
+
 LLVMTypeRef
 lp_build_elem_type(struct lp_type type);
 
@@ -170,6 +260,10 @@ struct lp_type
 lp_int_type(struct lp_type type);
 
 
+struct lp_type
+lp_wider_type(struct lp_type type);
+
+
 void
 lp_build_context_init(struct lp_build_context *bld,
                       LLVMBuilderRef builder,
index 696a9d5f6a841c55557e55df36d8b94fdc010449..8d965175f8c32c90c93c12f7c3ec360046babd3a 100644 (file)
@@ -31,6 +31,7 @@
  */
 
 #include "draw/draw_context.h"
+#include "draw/draw_vbuf.h"
 #include "pipe/p_defines.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
@@ -68,6 +69,10 @@ static void llvmpipe_destroy( struct pipe_context *pipe )
       pipe_texture_reference(&llvmpipe->texture[i], NULL);
    }
 
+   for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
+      pipe_texture_reference(&llvmpipe->vertex_textures[i], NULL);
+   }
+
    for (i = 0; i < Elements(llvmpipe->constants); i++) {
       if (llvmpipe->constants[i].buffer) {
          pipe_buffer_reference(&llvmpipe->constants[i].buffer, NULL);
@@ -117,7 +122,8 @@ llvmpipe_create( struct pipe_screen *screen )
    llvmpipe->pipe.delete_blend_state = llvmpipe_delete_blend_state;
 
    llvmpipe->pipe.create_sampler_state = llvmpipe_create_sampler_state;
-   llvmpipe->pipe.bind_sampler_states  = llvmpipe_bind_sampler_states;
+   llvmpipe->pipe.bind_fragment_sampler_states  = llvmpipe_bind_sampler_states;
+   llvmpipe->pipe.bind_vertex_sampler_states  = llvmpipe_bind_vertex_sampler_states;
    llvmpipe->pipe.delete_sampler_state = llvmpipe_delete_sampler_state;
 
    llvmpipe->pipe.create_depth_stencil_alpha_state = llvmpipe_create_depth_stencil_state;
@@ -142,7 +148,8 @@ llvmpipe_create( struct pipe_screen *screen )
    llvmpipe->pipe.set_framebuffer_state = llvmpipe_set_framebuffer_state;
    llvmpipe->pipe.set_polygon_stipple = llvmpipe_set_polygon_stipple;
    llvmpipe->pipe.set_scissor_state = llvmpipe_set_scissor_state;
-   llvmpipe->pipe.set_sampler_textures = llvmpipe_set_sampler_textures;
+   llvmpipe->pipe.set_fragment_sampler_textures = llvmpipe_set_sampler_textures;
+   llvmpipe->pipe.set_vertex_sampler_textures = llvmpipe_set_vertex_sampler_textures;
    llvmpipe->pipe.set_viewport_state = llvmpipe_set_viewport_state;
 
    llvmpipe->pipe.set_vertex_buffers = llvmpipe_set_vertex_buffers;
@@ -151,8 +158,6 @@ llvmpipe_create( struct pipe_screen *screen )
    llvmpipe->pipe.draw_arrays = llvmpipe_draw_arrays;
    llvmpipe->pipe.draw_elements = llvmpipe_draw_elements;
    llvmpipe->pipe.draw_range_elements = llvmpipe_draw_range_elements;
-   llvmpipe->pipe.set_edgeflags = llvmpipe_set_edgeflags;
-
 
    llvmpipe->pipe.clear = llvmpipe_clear;
    llvmpipe->pipe.flush = llvmpipe_flush;
@@ -170,8 +175,7 @@ llvmpipe_create( struct pipe_screen *screen )
    if (!llvmpipe->draw) 
       goto fail;
 
-   /* FIXME: vertex sampler state
-    */
+   /* FIXME: devise alternative to draw_texture_samplers */
 
    if (debug_get_bool_option( "LP_NO_RAST", FALSE ))
       llvmpipe->no_rast = TRUE;
index 194692045dc9504ffdbf49dd79722e72538d5bad..1ede6a6a72f9bc69bce5c690194dc3145962601d 100644 (file)
@@ -53,6 +53,7 @@ struct llvmpipe_context {
    /** Constant state objects */
    const struct pipe_blend_state *blend;
    const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS];
+   struct pipe_sampler_state *vertex_samplers[PIPE_MAX_VERTEX_SAMPLERS];
    const struct pipe_depth_stencil_alpha_state *depth_stencil;
    const struct pipe_rasterizer_state *rasterizer;
    struct lp_fragment_shader *fs;
@@ -66,12 +67,15 @@ struct llvmpipe_context {
    struct pipe_poly_stipple poly_stipple;
    struct pipe_scissor_state scissor;
    struct pipe_texture *texture[PIPE_MAX_SAMPLERS];
+   struct pipe_texture *vertex_textures[PIPE_MAX_VERTEX_SAMPLERS];
    struct pipe_viewport_state viewport;
    struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
    struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS];
 
    unsigned num_samplers;
    unsigned num_textures;
+   unsigned num_vertex_samplers;
+   unsigned num_vertex_textures;
    unsigned num_vertex_elements;
    unsigned num_vertex_buffers;
 
index 91fcbc01c6d4f7204812b8e7b2134ad9242842b5..3989cce7445e49b5266b58ecd5dbb004ae45d843 100644 (file)
 
 
 
-boolean
+void
 llvmpipe_draw_arrays(struct pipe_context *pipe, unsigned mode,
                      unsigned start, unsigned count)
 {
-   return llvmpipe_draw_elements(pipe, NULL, 0, mode, start, count);
+   llvmpipe_draw_elements(pipe, NULL, 0, mode, start, count);
 }
 
 
@@ -58,7 +58,7 @@ llvmpipe_draw_arrays(struct pipe_context *pipe, unsigned mode,
  * Basically, map the vertex buffers (and drawing surfaces), then hand off
  * the drawing to the 'draw' module.
  */
-boolean
+void
 llvmpipe_draw_range_elements(struct pipe_context *pipe,
                              struct pipe_buffer *indexBuffer,
                              unsigned indexSize,
@@ -99,7 +99,7 @@ llvmpipe_draw_range_elements(struct pipe_context *pipe,
    draw_arrays(draw, mode, start, count);
 
    /*
-    * unmap vertex/index buffers - will cause draw module to flush
+    * unmap vertex/index buffers
     */
    for (i = 0; i < lp->num_vertex_buffers; i++) {
       draw_set_mapped_vertex_buffer(draw, i, NULL);
@@ -108,26 +108,24 @@ llvmpipe_draw_range_elements(struct pipe_context *pipe,
       draw_set_mapped_element_buffer(draw, 0, NULL);
    }
 
-   return TRUE;
+   /*
+    * TODO: Flush only when a user vertex/index buffer is present
+    * (or even better, modify draw module to do this
+    * internally when this condition is seen?)
+    */
+   draw_flush(draw);
 }
 
 
-boolean
+void
 llvmpipe_draw_elements(struct pipe_context *pipe,
                        struct pipe_buffer *indexBuffer,
                        unsigned indexSize,
                        unsigned mode, unsigned start, unsigned count)
 {
-   return llvmpipe_draw_range_elements( pipe, indexBuffer,
-                                        indexSize,
-                                        0, 0xffffffff,
-                                        mode, start, count );
+   llvmpipe_draw_range_elements( pipe, indexBuffer,
+                                 indexSize,
+                                 0, 0xffffffff,
+                                 mode, start, count );
 }
 
-
-void
-llvmpipe_set_edgeflags(struct pipe_context *pipe, const unsigned *edgeflags)
-{
-   struct llvmpipe_context *lp = llvmpipe_context(pipe);
-   draw_set_edgeflags(lp->draw, edgeflags);
-}
index 14fbea6d99318d3ac95ebdb513feacf4f40cb6af..97c46087da02243fe746c18bc77a834e094340ed 100644 (file)
@@ -64,7 +64,7 @@ llvmpipe_fence_reference(struct pipe_screen *screen,
    struct lp_fence *old = (struct lp_fence *) *ptr;
    struct lp_fence *f = (struct lp_fence *) fence;
 
-   if (pipe_reference((struct pipe_reference**)ptr, &f->reference)) {
+   if (pipe_reference(&old->reference, &f->reference)) {
       lp_fence_destroy(old);
    }
 }
index fb6ec9bb37a8db32d48d62302a48a40176de42dc..4ef0783f3e2962078d51a2477ba968e72f8a779b 100644 (file)
@@ -39,6 +39,7 @@
 #include "util/u_cpu_detect.h"
 #include "lp_screen.h"
 #include "lp_bld_intr.h"
+#include "lp_bld_misc.h"
 #include "lp_jit.h"
 
 
@@ -78,25 +79,22 @@ lp_jit_init_globals(struct llvmpipe_screen *screen)
 
    /* struct lp_jit_context */
    {
-      LLVMTypeRef elem_types[5];
+      LLVMTypeRef elem_types[4];
       LLVMTypeRef context_type;
 
       elem_types[0] = LLVMPointerType(LLVMFloatType(), 0); /* constants */
-      elem_types[1] = LLVMPointerType(LLVMInt8Type(), 0);  /* samplers */
-      elem_types[2] = LLVMFloatType();                     /* alpha_ref_value */
-      elem_types[3] = LLVMPointerType(LLVMInt8Type(), 0);  /* blend_color */
-      elem_types[4] = LLVMArrayType(texture_type, PIPE_MAX_SAMPLERS); /* textures */
+      elem_types[1] = LLVMFloatType();                     /* alpha_ref_value */
+      elem_types[2] = LLVMPointerType(LLVMInt8Type(), 0);  /* blend_color */
+      elem_types[3] = LLVMArrayType(texture_type, PIPE_MAX_SAMPLERS); /* textures */
 
       context_type = LLVMStructType(elem_types, Elements(elem_types), 0);
 
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, constants,
                              screen->target, context_type, 0);
-      LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, dummy,
-                             screen->target, context_type, 1);
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, alpha_ref_value,
-                             screen->target, context_type, 2);
+                             screen->target, context_type, 1);
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, blend_color,
-                             screen->target, context_type, 3);
+                             screen->target, context_type, 2);
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, textures,
                              screen->target, context_type,
                              LP_JIT_CONTEXT_TEXTURES_INDEX);
@@ -135,13 +133,12 @@ lp_jit_screen_init(struct llvmpipe_screen *screen)
 #if 0
    /* For simulating less capable machines */
    util_cpu_caps.has_sse3 = 0;
+   util_cpu_caps.has_ssse3 = 0;
    util_cpu_caps.has_sse4_1 = 0;
 #endif
 
-#ifdef LLVM_NATIVE_ARCH
    LLVMLinkInJIT();
    LLVMInitializeNativeTarget();
-#endif
 
    screen->module = LLVMModuleCreateWithName("llvmpipe");
 
@@ -150,7 +147,7 @@ lp_jit_screen_init(struct llvmpipe_screen *screen)
    if (LLVMCreateJITCompiler(&screen->engine, screen->provider, 1, &error)) {
       _debug_printf("%s\n", error);
       LLVMDisposeMessage(error);
-      abort();
+      assert(0);
    }
 
    screen->target = LLVMGetExecutionEngineTargetData(screen->engine);
index e8fb7d990f8963da0a482a127aac43a8c3b0a88a..1a6e939aa247752ee340ebe3f7df4fb92d70af23 100644 (file)
@@ -41,7 +41,6 @@
 #include "pipe/p_state.h"
 
 
-struct tgsi_sampler;
 struct llvmpipe_screen;
 
 
@@ -78,8 +77,6 @@ struct lp_jit_context
 {
    const float *constants;
 
-   void *dummy;                 /* remove me */
-
    float alpha_ref_value;
 
    /* FIXME: store (also?) in floats */
@@ -92,16 +89,13 @@ struct lp_jit_context
 #define lp_jit_context_constants(_builder, _ptr) \
    lp_build_struct_get(_builder, _ptr, 0, "constants")
 
-#define lp_jit_context_samplers(_builder, _ptr) \
-   lp_build_struct_get(_builder, _ptr, 1, "samplers")
-
 #define lp_jit_context_alpha_ref_value(_builder, _ptr) \
-   lp_build_struct_get(_builder, _ptr, 2, "alpha_ref_value")
+   lp_build_struct_get(_builder, _ptr, 1, "alpha_ref_value")
 
 #define lp_jit_context_blend_color(_builder, _ptr) \
-   lp_build_struct_get(_builder, _ptr, 3, "blend_color")
+   lp_build_struct_get(_builder, _ptr, 2, "blend_color")
 
-#define LP_JIT_CONTEXT_TEXTURES_INDEX 4
+#define LP_JIT_CONTEXT_TEXTURES_INDEX 3
 
 #define lp_jit_context_textures(_builder, _ptr) \
    lp_build_struct_get_ptr(_builder, _ptr, LP_JIT_CONTEXT_TEXTURES_INDEX, "textures")
@@ -124,7 +118,6 @@ typedef void
                     const int32_t *step3);
 
 
-
 void
 lp_jit_screen_cleanup(struct llvmpipe_screen *screen);
 
index 6772ff332ba48cb301170c29de3ffa87fcf7a554..6535e69308908f5bc2618345d2e4c9c3fa53e4f6 100644 (file)
@@ -230,7 +230,7 @@ void lp_rast_load_color( struct lp_rasterizer *rast,
    assert(w <= TILE_SIZE);
    assert(h <= TILE_SIZE);
 
-   lp_tile_read_4ub(rast->cbuf_transfer->format,
+   lp_tile_read_4ub(rast->cbuf_transfer->texture->format,
                      rast->tasks[thread_index].tile.color,
                      rast->cbuf_map, 
                      rast->cbuf_transfer->stride,
@@ -394,7 +394,7 @@ static void lp_rast_store_color( struct lp_rasterizer *rast,
    LP_DBG(DEBUG_RAST, "%s [%u] %d,%d %dx%d\n", __FUNCTION__,
           thread_index, x, y, w, h);
 
-   lp_tile_write_4ub(rast->cbuf_transfer->format,
+   lp_tile_write_4ub(rast->cbuf_transfer->texture->format,
                      rast->tasks[thread_index].tile.color,
                      rast->cbuf_map, 
                      rast->cbuf_transfer->stride,
@@ -437,7 +437,7 @@ static void lp_rast_store_zstencil( struct lp_rasterizer *rast,
 
    LP_DBG(DEBUG_RAST, "%s %d,%d %dx%d\n", __FUNCTION__, x, y, w, h);
 
-   assert(rast->zsbuf_transfer->format == PIPE_FORMAT_Z32_UNORM);
+   assert(rast->zsbuf_transfer->texture->format == PIPE_FORMAT_Z32_UNORM);
    lp_tile_write_z32(rast->tasks[thread_index].tile.depth,
                      rast->zsbuf_map, 
                      rast->zsbuf_transfer->stride,
index 017496ea5fc5f5289798c339a46d17414a59029f..a28f6935b68fac8e3817a4c71ffc3b384860d10d 100644 (file)
@@ -27,6 +27,7 @@
 
 
 #include "util/u_memory.h"
+#include "util/u_format.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_screen.h"
 
@@ -77,7 +78,9 @@ llvmpipe_get_param(struct pipe_screen *screen, int param)
    case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
       return PIPE_MAX_SAMPLERS;
    case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS:
-      return PIPE_MAX_SAMPLERS;
+      return PIPE_MAX_VERTEX_SAMPLERS;
+   case PIPE_CAP_MAX_COMBINED_SAMPLERS:
+      return PIPE_MAX_SAMPLERS + PIPE_MAX_VERTEX_SAMPLERS;
    case PIPE_CAP_NPOT_TEXTURES:
       return 1;
    case PIPE_CAP_TWO_SIDED_STENCIL:
@@ -150,17 +153,17 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen,
 {
    struct llvmpipe_screen *screen = llvmpipe_screen(_screen);
    struct llvmpipe_winsys *winsys = screen->winsys;
+   const struct util_format_description *format_desc;
+
+   format_desc = util_format_description(format);
+   if(!format_desc)
+      return FALSE;
 
    assert(target == PIPE_TEXTURE_1D ||
           target == PIPE_TEXTURE_2D ||
           target == PIPE_TEXTURE_3D ||
           target == PIPE_TEXTURE_CUBE);
 
-   if(format == PIPE_FORMAT_Z16_UNORM)
-      return FALSE;
-   if(format == PIPE_FORMAT_S8_UNORM)
-      return FALSE;
-
    switch(format) {
    case PIPE_FORMAT_DXT1_RGB:
    case PIPE_FORMAT_DXT1_RGBA:
@@ -171,8 +174,51 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen,
       break;
    }
 
-   if(tex_usage & PIPE_TEXTURE_USAGE_DISPLAY_TARGET)
-      return winsys->is_displaytarget_format_supported(winsys, format);
+   if(tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) {
+      if(format_desc->block.width != 1 ||
+         format_desc->block.height != 1)
+         return FALSE;
+
+      if(format_desc->layout != UTIL_FORMAT_LAYOUT_SCALAR &&
+         format_desc->layout != UTIL_FORMAT_LAYOUT_ARITH &&
+         format_desc->layout != UTIL_FORMAT_LAYOUT_ARRAY)
+         return FALSE;
+
+      if(format_desc->colorspace != UTIL_FORMAT_COLORSPACE_RGB &&
+         format_desc->colorspace != UTIL_FORMAT_COLORSPACE_SRGB)
+         return FALSE;
+   }
+
+   if(tex_usage & PIPE_TEXTURE_USAGE_DISPLAY_TARGET) {
+      if(!winsys->is_displaytarget_format_supported(winsys, format))
+         return FALSE;
+   }
+
+   if(tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL) {
+      if(format_desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS)
+         return FALSE;
+
+      /* FIXME: Temporary restriction. See lp_state_fs.c. */
+      if(format_desc->block.bits != 32)
+         return FALSE;
+   }
+
+   /* FIXME: Temporary restrictions. See lp_bld_sample_soa.c */
+   if(tex_usage & PIPE_TEXTURE_USAGE_SAMPLER) {
+      if(format_desc->block.width != 1 ||
+         format_desc->block.height != 1)
+         return FALSE;
+
+      if(format_desc->layout != UTIL_FORMAT_LAYOUT_SCALAR &&
+         format_desc->layout != UTIL_FORMAT_LAYOUT_ARITH &&
+         format_desc->layout != UTIL_FORMAT_LAYOUT_ARRAY)
+         return FALSE;
+
+      if(format_desc->colorspace != UTIL_FORMAT_COLORSPACE_RGB &&
+         format_desc->colorspace != UTIL_FORMAT_COLORSPACE_SRGB &&
+         format_desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS)
+         return FALSE;
+   }
 
    return TRUE;
 }
index 1eb944a0de7901b88f1d1afd2da46a58eff5ebb6..5cdcf4ecc985f0521ddcc9836aa8bc436ee5b5be 100644 (file)
@@ -451,8 +451,8 @@ lp_setup_set_sampler_textures( struct setup_context *setup,
          struct llvmpipe_texture *lp_tex = llvmpipe_texture(tex);
          struct lp_jit_texture *jit_tex;
          jit_tex = &setup->fs.current.jit_context.textures[i];
-         jit_tex->width = tex->width[0];
-         jit_tex->height = tex->height[0];
+         jit_tex->width = tex->width0;
+         jit_tex->height = tex->height0;
          jit_tex->stride = lp_tex->stride[0];
          if(!lp_tex->dt)
             jit_tex->data = lp_tex->data;
index e15b987767c87203bb077c9e8988c665c21a1b54..fe34903cf326e93c3ebe25a26b4777fe7414d157 100644 (file)
@@ -241,9 +241,6 @@ static inline int subpixel_snap( float a )
 }
 
 
-#define MIN3(a,b,c) MIN2(MIN2(a,b),c)
-#define MAX3(a,b,c) MAX2(MAX2(a,b),c)
-
 /**
  * Do basic setup for triangle rasterization and determine which
  * framebuffer tiles are touched.  Put the triangle in the scene's
index 6017dc553a6fe0ebdc675a944cee703c1f30f9c8..25d135367414b6b4960b5ceb2e67cfa8fbae7c5f 100644 (file)
@@ -57,7 +57,6 @@
 #define LP_NEW_BLEND_COLOR   0x8000
 
 
-struct tgsi_sampler;
 struct vertex_info;
 struct pipe_context;
 struct llvmpipe_context;
@@ -127,6 +126,10 @@ void *
 llvmpipe_create_sampler_state(struct pipe_context *,
                               const struct pipe_sampler_state *);
 void llvmpipe_bind_sampler_states(struct pipe_context *, unsigned, void **);
+void
+llvmpipe_bind_vertex_sampler_states(struct pipe_context *,
+                                    unsigned num_samplers,
+                                    void **samplers);
 void llvmpipe_delete_sampler_state(struct pipe_context *, void *);
 
 void *
@@ -173,6 +176,11 @@ void llvmpipe_set_sampler_textures( struct pipe_context *,
                                     unsigned num,
                                     struct pipe_texture ** );
 
+void
+llvmpipe_set_vertex_sampler_textures(struct pipe_context *,
+                                     unsigned num_textures,
+                                     struct pipe_texture **);
+
 void llvmpipe_set_viewport_state( struct pipe_context *,
                                   const struct pipe_viewport_state * );
 
@@ -189,14 +197,14 @@ void llvmpipe_update_fs(struct llvmpipe_context *lp);
 void llvmpipe_update_derived( struct llvmpipe_context *llvmpipe );
 
 
-boolean llvmpipe_draw_arrays(struct pipe_context *pipe, unsigned mode,
+void llvmpipe_draw_arrays(struct pipe_context *pipe, unsigned mode,
                             unsigned start, unsigned count);
 
-boolean llvmpipe_draw_elements(struct pipe_context *pipe,
+void llvmpipe_draw_elements(struct pipe_context *pipe,
                               struct pipe_buffer *indexBuffer,
                               unsigned indexSize,
                               unsigned mode, unsigned start, unsigned count);
-boolean
+void
 llvmpipe_draw_range_elements(struct pipe_context *pipe,
                              struct pipe_buffer *indexBuffer,
                              unsigned indexSize,
@@ -204,10 +212,6 @@ llvmpipe_draw_range_elements(struct pipe_context *pipe,
                              unsigned max_index,
                              unsigned mode, unsigned start, unsigned count);
 
-void
-llvmpipe_set_edgeflags(struct pipe_context *pipe, const unsigned *edgeflags);
-
-
 void
 llvmpipe_map_texture_surfaces(struct llvmpipe_context *lp);
 
index 48afe5f524224e84f7d2618c53b53c97afd25b0f..a10c5918df3d0d7a65c7a03e036c6f6fa7340178 100644 (file)
@@ -34,6 +34,7 @@
 #include "util/u_memory.h"
 #include "util/u_math.h"
 #include "util/u_debug_dump.h"
+#include "draw/draw_context.h"
 #include "lp_screen.h"
 #include "lp_context.h"
 #include "lp_state.h"
@@ -51,6 +52,11 @@ void llvmpipe_bind_blend_state( struct pipe_context *pipe,
 {
    struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
 
+   if (llvmpipe->blend == blend)
+      return;
+
+   draw_flush(llvmpipe->draw);
+
    llvmpipe->blend = blend;
 
    llvmpipe->dirty |= LP_NEW_BLEND;
@@ -74,6 +80,11 @@ void llvmpipe_set_blend_color( struct pipe_context *pipe,
    if(memcmp(&llvmpipe->blend_color, blend_color, sizeof *blend_color) == 0)
       return;
 
+   if(memcmp(&llvmpipe->blend_color, blend_color, sizeof *blend_color) == 0)
+      return;
+
+   draw_flush(llvmpipe->draw);
+
    memcpy(&llvmpipe->blend_color, blend_color, sizeof *blend_color);
 
    llvmpipe->dirty |= LP_NEW_BLEND_COLOR;
@@ -98,7 +109,12 @@ llvmpipe_bind_depth_stencil_state(struct pipe_context *pipe,
 {
    struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
 
-   llvmpipe->depth_stencil = (const struct pipe_depth_stencil_alpha_state *)depth_stencil;
+   if (llvmpipe->depth_stencil == depth_stencil)
+      return;
+
+   draw_flush(llvmpipe->draw);
+
+   llvmpipe->depth_stencil = depth_stencil;
 
    llvmpipe->dirty |= LP_NEW_DEPTH_STENCIL_ALPHA;
 }
index cc7b09fd4d15cb1502c1bdcb818ff60a589fb4a5..78d046985b9dc50e0426da573483fe1277753e11 100644 (file)
@@ -50,7 +50,7 @@ compute_vertex_info(struct llvmpipe_context *llvmpipe)
 {
    const struct lp_fragment_shader *lpfs = llvmpipe->fs;
    struct vertex_info *vinfo = &llvmpipe->vertex_info;
-   const uint num = draw_num_vs_outputs(llvmpipe->draw);
+   const uint num = draw_num_shader_outputs(llvmpipe->draw);
    uint i;
 
    /* Tell setup to tell the draw module to simply emit the whole
@@ -123,9 +123,9 @@ compute_vertex_info(struct llvmpipe_context *llvmpipe)
          /* Search for each input in current vs output:
           */
          inputs[i].src_index = 
-            draw_find_vs_output(llvmpipe->draw,
-                                lpfs->info.input_semantic_name[i],
-                                lpfs->info.input_semantic_index[i]);
+            draw_find_shader_output(llvmpipe->draw,
+                                    lpfs->info.input_semantic_name[i],
+                                    lpfs->info.input_semantic_index[i]);
       }
 
       lp_setup_set_fs_inputs(llvmpipe->setup, 
@@ -170,26 +170,6 @@ compute_cliprect(struct llvmpipe_context *lp)
 }
 
 
-#if 0
-static void 
-update_culling(struct llvmpipe_context *lp)
-{
-   struct lp_setup_context *setup = lp->setup;
-
-   if (lp->reduced_api_prim == PIPE_PRIM_TRIANGLES &&
-       lp->rasterizer->fill_cw == PIPE_POLYGON_MODE_FILL &&
-       lp->rasterizer->fill_ccw == PIPE_POLYGON_MODE_FILL) {
-      /* we'll do culling */
-      setup->winding = lp->rasterizer->cull_mode;
-   }
-   else {
-      /* 'draw' will do culling */
-      setup->winding = PIPE_WINDING_NONE;
-   }
-}
-#endif
-
-
 /* Hopefully this will remain quite simple, otherwise need to pull in
  * something like the state tracker mechanism.
  */
index 3ad58415e3927c8ddf7bd900a599de433363aba2..3a669ba859ab7b9064ba20a606038852d9c9f28a 100644 (file)
@@ -149,6 +149,20 @@ generate_depth(LLVMBuilderRef builder,
    format_desc = util_format_description(key->zsbuf_format);
    assert(format_desc);
 
+   /*
+    * Depths are expected to be between 0 and 1, even if they are stored in
+    * floats. Setting these bits here will ensure that the lp_build_conv() call
+    * below won't try to unnecessarily clamp the incoming values.
+    */
+   if(src_type.floating) {
+      src_type.sign = FALSE;
+      src_type.norm = TRUE;
+   }
+   else {
+      assert(!src_type.sign);
+      assert(src_type.norm);
+   }
+
    /* Pick the depth type. */
    dst_type = lp_depth_type(format_desc, src_type.width*src_type.length);
 
@@ -156,14 +170,11 @@ generate_depth(LLVMBuilderRef builder,
    assert(dst_type.width == src_type.width);
    assert(dst_type.length == src_type.length);
 
-#if 1
-   src = lp_build_clamped_float_to_unsigned_norm(builder,
-                                                 src_type,
-                                                 dst_type.width,
-                                                 src);
-#else
    lp_build_conv(builder, src_type, dst_type, &src, 1, &src, 1);
-#endif
+
+   dst_ptr = LLVMBuildBitCast(builder,
+                              dst_ptr,
+                              LLVMPointerType(lp_build_vec_type(dst_type), 0), "");
 
    lp_build_depth_test(builder,
                        &key->depth,
@@ -505,6 +516,7 @@ generate_fragment(struct llvmpipe_context *lp,
    if (LP_DEBUG & DEBUG_JIT) {
       tgsi_dump(shader->base.tokens, 0);
       if(key->depth.enabled) {
+         debug_printf("depth.format = %s\n", pf_name(key->zsbuf_format));
          debug_printf("depth.func = %s\n", debug_dump_func(key->depth.func, TRUE));
          debug_printf("depth.writemask = %u\n", key->depth.writemask);
       }
@@ -517,13 +529,40 @@ generate_fragment(struct llvmpipe_context *lp,
       }
       else if(key->blend.blend_enable) {
          debug_printf("blend.rgb_func = %s\n",   debug_dump_blend_func  (key->blend.rgb_func, TRUE));
-         debug_printf("blend.rgb_src_factor = %s\n",   debug_dump_blend_factor(key->blend.rgb_src_factor, TRUE));
-         debug_printf("blend.rgb_dst_factor = %s\n",   debug_dump_blend_factor(key->blend.rgb_dst_factor, TRUE));
-         debug_printf("blend.alpha_func = %s\n",       debug_dump_blend_func  (key->blend.alpha_func, TRUE));
-         debug_printf("blend.alpha_src_factor = %s\n", debug_dump_blend_factor(key->blend.alpha_src_factor, TRUE));
-         debug_printf("blend.alpha_dst_factor = %s\n", debug_dump_blend_factor(key->blend.alpha_dst_factor, TRUE));
+         debug_printf("rgb_src_factor = %s\n",   debug_dump_blend_factor(key->blend.rgb_src_factor, TRUE));
+         debug_printf("rgb_dst_factor = %s\n",   debug_dump_blend_factor(key->blend.rgb_dst_factor, TRUE));
+         debug_printf("alpha_func = %s\n",       debug_dump_blend_func  (key->blend.alpha_func, TRUE));
+         debug_printf("alpha_src_factor = %s\n", debug_dump_blend_factor(key->blend.alpha_src_factor, TRUE));
+         debug_printf("alpha_dst_factor = %s\n", debug_dump_blend_factor(key->blend.alpha_dst_factor, TRUE));
       }
       debug_printf("blend.colormask = 0x%x\n", key->blend.colormask);
+      for(i = 0; i < PIPE_MAX_SAMPLERS; ++i) {
+         if(key->sampler[i].format) {
+            debug_printf("sampler[%u] = \n", i);
+            debug_printf("  .format = %s\n",
+                         pf_name(key->sampler[i].format));
+            debug_printf("  .target = %s\n",
+                         debug_dump_tex_target(key->sampler[i].target, TRUE));
+            debug_printf("  .pot = %u %u %u\n",
+                         key->sampler[i].pot_width,
+                         key->sampler[i].pot_height,
+                         key->sampler[i].pot_depth);
+            debug_printf("  .wrap = %s %s %s\n",
+                         debug_dump_tex_wrap(key->sampler[i].wrap_s, TRUE),
+                         debug_dump_tex_wrap(key->sampler[i].wrap_t, TRUE),
+                         debug_dump_tex_wrap(key->sampler[i].wrap_r, TRUE));
+            debug_printf("  .min_img_filter = %s\n",
+                         debug_dump_tex_filter(key->sampler[i].min_img_filter, TRUE));
+            debug_printf("  .min_mip_filter = %s\n",
+                         debug_dump_tex_mipfilter(key->sampler[i].min_mip_filter, TRUE));
+            debug_printf("  .mag_img_filter = %s\n",
+                         debug_dump_tex_filter(key->sampler[i].mag_img_filter, TRUE));
+            if(key->sampler[i].compare_mode != PIPE_TEX_COMPARE_NONE)
+               debug_printf("  .compare_func = %s\n", debug_dump_func(key->sampler[i].compare_func, TRUE));
+            debug_printf("  .normalized_coords = %u\n", key->sampler[i].normalized_coords);
+            debug_printf("  .prefilter = %u\n", key->sampler[i].prefilter);
+         }
+      }
    }
 
    variant = CALLOC_STRUCT(lp_fragment_shader_variant);
@@ -702,10 +741,12 @@ generate_fragment(struct llvmpipe_context *lp,
     * Translate the LLVM IR into machine code.
     */
 
+#ifdef DEBUG
    if(LLVMVerifyFunction(variant->function, LLVMPrintMessageAction)) {
       LLVMDumpValue(variant->function);
-      abort();
+      assert(0);
    }
+#endif
 
    LLVMRunFunctionPassManager(screen->pass, variant->function);
 
@@ -751,7 +792,12 @@ llvmpipe_bind_fs_state(struct pipe_context *pipe, void *fs)
 {
    struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
 
-   llvmpipe->fs = (struct lp_fragment_shader *) fs;
+   if (llvmpipe->fs == fs)
+      return;
+
+   draw_flush(llvmpipe->draw);
+
+   llvmpipe->fs = fs;
 
    llvmpipe->dirty |= LP_NEW_FS;
 }
@@ -766,6 +812,7 @@ llvmpipe_delete_fs_state(struct pipe_context *pipe, void *fs)
    struct lp_fragment_shader_variant *variant;
 
    assert(fs != llvmpipe->fs);
+   (void) llvmpipe;
 
    variant = shader->variants;
    while(variant) {
@@ -804,14 +851,14 @@ llvmpipe_set_constant_buffer(struct pipe_context *pipe,
    if(llvmpipe->constants[shader].buffer == buffer)
       return;
 
-   if(shader == PIPE_SHADER_VERTEX)
-      draw_flush(llvmpipe->draw);
+   draw_flush(llvmpipe->draw);
 
    /* note: reference counting */
    pipe_buffer_reference(&llvmpipe->constants[shader].buffer, buffer);
 
    if(shader == PIPE_SHADER_VERTEX) {
-      draw_set_mapped_constant_buffer(llvmpipe->draw, data, size);
+      draw_set_mapped_constant_buffer(llvmpipe->draw, PIPE_SHADER_VERTEX,
+                                      data, size);
    }
 
    llvmpipe->dirty |= LP_NEW_CONSTANTS;
index 282ed2e9ea3e17cb69190b70f7845a6b9ecb4d75..7d4c310aae844f7a6458ef38e4d66dbdcf8c5565 100644 (file)
@@ -42,14 +42,17 @@ llvmpipe_create_rasterizer_state(struct pipe_context *pipe,
 }
 
 void llvmpipe_bind_rasterizer_state(struct pipe_context *pipe,
-                                    void *setup)
+                                    void *rasterizer)
 {
    struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
 
+   if (llvmpipe->rasterizer == rasterizer)
+      return;
+
    /* pass-through to draw module */
-   draw_set_rasterizer_state(llvmpipe->draw, setup);
+   draw_set_rasterizer_state(llvmpipe->draw, rasterizer);
 
-   llvmpipe->rasterizer = (struct pipe_rasterizer_state *)setup;
+   llvmpipe->rasterizer = rasterizer;
 
    /* Note: we can immediately set the triangle state here and
     * not worry about binning because we handle culling during
index e19394a4c92007623ebfd67236f2c4f9aef52b16..976f81113fd1e4bea5176cb00ae2942168815c85 100644 (file)
@@ -76,6 +76,34 @@ llvmpipe_bind_sampler_states(struct pipe_context *pipe,
 }
 
 
+void
+llvmpipe_bind_vertex_sampler_states(struct pipe_context *pipe,
+                                    unsigned num_samplers,
+                                    void **samplers)
+{
+   struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
+   unsigned i;
+
+   assert(num_samplers <= PIPE_MAX_VERTEX_SAMPLERS);
+
+   /* Check for no-op */
+   if (num_samplers == llvmpipe->num_vertex_samplers &&
+       !memcmp(llvmpipe->vertex_samplers, samplers, num_samplers * sizeof(void *)))
+      return;
+
+   draw_flush(llvmpipe->draw);
+
+   for (i = 0; i < num_samplers; ++i)
+      llvmpipe->vertex_samplers[i] = samplers[i];
+   for (i = num_samplers; i < PIPE_MAX_VERTEX_SAMPLERS; ++i)
+      llvmpipe->vertex_samplers[i] = NULL;
+
+   llvmpipe->num_vertex_samplers = num_samplers;
+
+   llvmpipe->dirty |= LP_NEW_SAMPLER;
+}
+
+
 void
 llvmpipe_set_sampler_textures(struct pipe_context *pipe,
                               unsigned num, struct pipe_texture **texture)
@@ -104,6 +132,36 @@ llvmpipe_set_sampler_textures(struct pipe_context *pipe,
 }
 
 
+void
+llvmpipe_set_vertex_sampler_textures(struct pipe_context *pipe,
+                                     unsigned num_textures,
+                                     struct pipe_texture **textures)
+{
+   struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
+   uint i;
+
+   assert(num_textures <= PIPE_MAX_VERTEX_SAMPLERS);
+
+   /* Check for no-op */
+   if (num_textures == llvmpipe->num_vertex_textures &&
+       !memcmp(llvmpipe->vertex_textures, textures, num_textures * sizeof(struct pipe_texture *))) {
+      return;
+   }
+
+   draw_flush(llvmpipe->draw);
+
+   for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
+      struct pipe_texture *tex = i < num_textures ? textures[i] : NULL;
+
+      pipe_texture_reference(&llvmpipe->vertex_textures[i], tex);
+   }
+
+   llvmpipe->num_vertex_textures = num_textures;
+
+   llvmpipe->dirty |= LP_NEW_TEXTURE;
+}
+
+
 void
 llvmpipe_delete_sampler_state(struct pipe_context *pipe,
                               void *sampler)
index 957e947fe029c92e1915a08f9d68cc37a98b85be..0e9f03b90b85b12b6b120eb30bf5fcf23863e8c4 100644 (file)
@@ -37,6 +37,8 @@
 
 #include "draw/draw_context.h"
 
+#include "util/u_format.h"
+
 
 /**
  * Set the framebuffer surface info: color buffers, zbuffer, stencil buffer.
@@ -57,8 +59,9 @@ llvmpipe_set_framebuffer_state(struct pipe_context *pipe,
       if (lp->framebuffer.zsbuf) {
          int depth_bits;
          double mrd;
-         depth_bits = pf_get_component_bits(lp->framebuffer.zsbuf->format,
-                                            PIPE_FORMAT_COMP_Z);
+         depth_bits = util_format_get_component_bits(lp->framebuffer.zsbuf->format,
+                                                     UTIL_FORMAT_COLORSPACE_ZS,
+                                                     0);
          if (depth_bits > 16) {
             mrd = 0.0000001;
          }
index 15c30296144117462f3b9f9bad4d3be86f4af877..884e3878e621af5fea2eb76220b4f6c39549ab7e 100644 (file)
@@ -70,14 +70,18 @@ fail:
 
 
 void
-llvmpipe_bind_vs_state(struct pipe_context *pipe, void *vs)
+llvmpipe_bind_vs_state(struct pipe_context *pipe, void *_vs)
 {
    struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
+   const struct lp_vertex_shader *vs = (const struct lp_vertex_shader *)_vs;
 
-   llvmpipe->vs = (const struct lp_vertex_shader *)vs;
+   if (llvmpipe->vs == vs)
+      return;
 
-   draw_bind_vertex_shader(llvmpipe->draw,
-                           (llvmpipe->vs ? llvmpipe->vs->draw_data : NULL));
+   draw_bind_vertex_shader(llvmpipe->draw, 
+                           vs ? vs->draw_data : NULL);
+
+   llvmpipe->vs = vs;
 
    llvmpipe->dirty |= LP_NEW_VS;
 }
@@ -92,5 +96,6 @@ llvmpipe_delete_vs_state(struct pipe_context *pipe, void *vs)
       (struct lp_vertex_shader *)vs;
 
    draw_delete_vertex_shader(llvmpipe->draw, state->draw_data);
+   FREE( (void *)state->shader.tokens );
    FREE( state );
 }
index a88e110c6631eeaee07d6b6f148b676c6bcc9ee3..39d80726e6574538ab4695db6ca8ff9ae6a3d434 100644 (file)
@@ -56,6 +56,9 @@
 #include "lp_bld_type.h"
 
 
+#define LP_TEST_NUM_SAMPLES 32
+
+
 void
 write_tsv_header(FILE *fp);
 
@@ -68,17 +71,28 @@ boolean
 test_all(unsigned verbose, FILE *fp);
 
 
+#if defined(PIPE_CC_MSVC)
+
+unsigned __int64 __rdtsc();
+#pragma intrinsic(__rdtsc)
+#define rdtsc() __rdtsc()
+
+#elif defined(PIPE_CC_GCC) && (defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64))
+
 static INLINE uint64_t
 rdtsc(void)
 {
-#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
    uint32_t hi, lo;
    __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
    return ((uint64_t)lo) | (((uint64_t)hi) << 32);
+}
+
 #else
-   return 0;
+
+#define rdtsc() 0
+
 #endif
-}
+
 
 
 float
index 94b661dcba42ce393d04bc65824c446ce3a8105d..29fff91981aef423770c2c0ce24e4ab8f3fce4cc 100644 (file)
@@ -462,6 +462,7 @@ compute_blend_ref(const struct pipe_blend_state *blend,
 }
 
 
+ALIGN_STACK
 static boolean
 test_one(unsigned verbose,
          FILE *fp,
@@ -477,8 +478,8 @@ test_one(unsigned verbose,
    char *error = NULL;
    blend_test_ptr_t blend_test_ptr;
    boolean success;
-   const unsigned n = 32;
-   int64_t cycles[n];
+   const unsigned n = LP_TEST_NUM_SAMPLES;
+   int64_t cycles[LP_TEST_NUM_SAMPLES];
    double cycles_avg = 0.0;
    unsigned i, j;
 
@@ -530,11 +531,11 @@ test_one(unsigned verbose,
    success = TRUE;
    for(i = 0; i < n && success; ++i) {
       if(mode == AoS) {
-         uint8_t src[LP_MAX_VECTOR_LENGTH*LP_MAX_TYPE_WIDTH/8];
-         uint8_t dst[LP_MAX_VECTOR_LENGTH*LP_MAX_TYPE_WIDTH/8];
-         uint8_t con[LP_MAX_VECTOR_LENGTH*LP_MAX_TYPE_WIDTH/8];
-         uint8_t res[LP_MAX_VECTOR_LENGTH*LP_MAX_TYPE_WIDTH/8];
-         uint8_t ref[LP_MAX_VECTOR_LENGTH*LP_MAX_TYPE_WIDTH/8];
+         ALIGN16_ATTRIB uint8_t src[LP_NATIVE_VECTOR_WIDTH/8];
+         ALIGN16_ATTRIB uint8_t dst[LP_NATIVE_VECTOR_WIDTH/8];
+         ALIGN16_ATTRIB uint8_t con[LP_NATIVE_VECTOR_WIDTH/8];
+         ALIGN16_ATTRIB uint8_t res[LP_NATIVE_VECTOR_WIDTH/8];
+         ALIGN16_ATTRIB uint8_t ref[LP_NATIVE_VECTOR_WIDTH/8];
          int64_t start_counter = 0;
          int64_t end_counter = 0;
 
@@ -595,11 +596,11 @@ test_one(unsigned verbose,
 
       if(mode == SoA) {
          const unsigned stride = type.length*type.width/8;
-         uint8_t src[4*LP_MAX_VECTOR_LENGTH*LP_MAX_TYPE_WIDTH/8];
-         uint8_t dst[4*LP_MAX_VECTOR_LENGTH*LP_MAX_TYPE_WIDTH/8];
-         uint8_t con[4*LP_MAX_VECTOR_LENGTH*LP_MAX_TYPE_WIDTH/8];
-         uint8_t res[4*LP_MAX_VECTOR_LENGTH*LP_MAX_TYPE_WIDTH/8];
-         uint8_t ref[4*LP_MAX_VECTOR_LENGTH*LP_MAX_TYPE_WIDTH/8];
+         ALIGN16_ATTRIB uint8_t src[4*LP_NATIVE_VECTOR_WIDTH/8];
+         ALIGN16_ATTRIB uint8_t dst[4*LP_NATIVE_VECTOR_WIDTH/8];
+         ALIGN16_ATTRIB uint8_t con[4*LP_NATIVE_VECTOR_WIDTH/8];
+         ALIGN16_ATTRIB uint8_t res[4*LP_NATIVE_VECTOR_WIDTH/8];
+         ALIGN16_ATTRIB uint8_t ref[4*LP_NATIVE_VECTOR_WIDTH/8];
          int64_t start_counter = 0;
          int64_t end_counter = 0;
          boolean mismatch;
index 9dcf58e5dcde05002cbcc882defb99f466e65d6e..faddfb96779660ecd3ec84e5338303ece82da36b 100644 (file)
@@ -142,6 +142,7 @@ add_conv_test(LLVMModuleRef module,
 }
 
 
+ALIGN_STACK
 static boolean
 test_one(unsigned verbose,
          FILE *fp,
@@ -156,8 +157,8 @@ test_one(unsigned verbose,
    char *error = NULL;
    conv_test_ptr_t conv_test_ptr;
    boolean success;
-   const unsigned n = 32;
-   int64_t cycles[n];
+   const unsigned n = LP_TEST_NUM_SAMPLES;
+   int64_t cycles[LP_TEST_NUM_SAMPLES];
    double cycles_avg = 0.0;
    unsigned num_srcs;
    unsigned num_dsts;
@@ -229,8 +230,8 @@ test_one(unsigned verbose,
    for(i = 0; i < n && success; ++i) {
       unsigned src_stride = src_type.length*src_type.width/8;
       unsigned dst_stride = dst_type.length*dst_type.width/8;
-      uint8_t src[LP_MAX_VECTOR_LENGTH*LP_MAX_VECTOR_LENGTH];
-      uint8_t dst[LP_MAX_VECTOR_LENGTH*LP_MAX_VECTOR_LENGTH];
+      ALIGN16_ATTRIB uint8_t src[LP_MAX_VECTOR_LENGTH*LP_MAX_VECTOR_LENGTH];
+      ALIGN16_ATTRIB uint8_t dst[LP_MAX_VECTOR_LENGTH*LP_MAX_VECTOR_LENGTH];
       double fref[LP_MAX_VECTOR_LENGTH*LP_MAX_VECTOR_LENGTH];
       uint8_t ref[LP_MAX_VECTOR_LENGTH*LP_MAX_VECTOR_LENGTH];
       int64_t start_counter = 0;
@@ -329,7 +330,7 @@ test_one(unsigned verbose,
          fprintf(stderr, "conv.bc written\n");
          fprintf(stderr, "Invoke as \"llc -o - conv.bc\"\n");
          firsttime = FALSE;
-         //abort();
+         /* abort(); */
       }
    }
 
index ab80c0143f9c4dcdab77f9f12cab59dfa8088956..23ea9ebbe7d96c526482280742a7c212808e1e2d 100644 (file)
 #include <llvm-c/Target.h>
 #include <llvm-c/Transforms/Scalar.h>
 
+#include "util/u_cpu_detect.h"
 #include "util/u_format.h"
 
 #include "lp_bld_format.h"
+#include "lp_test.h"
 
 
 struct pixel_test_case
@@ -88,34 +90,62 @@ struct pixel_test_case test_cases[] =
 };
 
 
-typedef void (*load_ptr_t)(const void *, float *);
+void
+write_tsv_header(FILE *fp)
+{
+   fprintf(fp,
+           "result\t"
+           "format\n");
+
+   fflush(fp);
+}
+
+
+static void
+write_tsv_row(FILE *fp,
+              const struct util_format_description *desc,
+              boolean success)
+{
+   fprintf(fp, "%s\t", success ? "pass" : "fail");
+
+   fprintf(fp, "%s\n", desc->name);
+
+   fflush(fp);
+}
+
+
+typedef void (*load_ptr_t)(const uint32_t packed, float *);
 
 
 static LLVMValueRef
 add_load_rgba_test(LLVMModuleRef module,
-                   enum pipe_format format)
+                   const struct util_format_description *desc)
 {
    LLVMTypeRef args[2];
    LLVMValueRef func;
-   LLVMValueRef ptr;
+   LLVMValueRef packed;
    LLVMValueRef rgba_ptr;
    LLVMBasicBlockRef block;
    LLVMBuilderRef builder;
    LLVMValueRef rgba;
 
-   args[0] = LLVMPointerType(LLVMInt8Type(), 0);
+   args[0] = LLVMInt32Type();
    args[1] = LLVMPointerType(LLVMVectorType(LLVMFloatType(), 4), 0);
 
    func = LLVMAddFunction(module, "load", LLVMFunctionType(LLVMVoidType(), args, 2, 0));
    LLVMSetFunctionCallConv(func, LLVMCCallConv);
-   ptr = LLVMGetParam(func, 0);
+   packed = LLVMGetParam(func, 0);
    rgba_ptr = LLVMGetParam(func, 1);
 
    block = LLVMAppendBasicBlock(func, "entry");
    builder = LLVMCreateBuilder();
    LLVMPositionBuilderAtEnd(builder, block);
 
-   rgba = lp_build_load_rgba_aos(builder, format, ptr);
+   if(desc->block.bits < 32)
+      packed = LLVMBuildTrunc(builder, packed, LLVMIntType(desc->block.bits), "");
+
+   rgba = lp_build_unpack_rgba_aos(builder, desc, packed);
+
    LLVMBuildStore(builder, rgba, rgba_ptr);
 
    LLVMBuildRetVoid(builder);
@@ -125,27 +155,28 @@ add_load_rgba_test(LLVMModuleRef module,
 }
 
 
-typedef void (*store_ptr_t)(void *, const float *);
+typedef void (*store_ptr_t)(uint32_t *, const float *);
 
 
 static LLVMValueRef
 add_store_rgba_test(LLVMModuleRef module,
-                    enum pipe_format format)
+                    const struct util_format_description *desc)
 {
    LLVMTypeRef args[2];
    LLVMValueRef func;
-   LLVMValueRef ptr;
+   LLVMValueRef packed_ptr;
    LLVMValueRef rgba_ptr;
    LLVMBasicBlockRef block;
    LLVMBuilderRef builder;
    LLVMValueRef rgba;
+   LLVMValueRef packed;
 
-   args[0] = LLVMPointerType(LLVMInt8Type(), 0);
+   args[0] = LLVMPointerType(LLVMInt32Type(), 0);
    args[1] = LLVMPointerType(LLVMVectorType(LLVMFloatType(), 4), 0);
 
    func = LLVMAddFunction(module, "store", LLVMFunctionType(LLVMVoidType(), args, 2, 0));
    LLVMSetFunctionCallConv(func, LLVMCCallConv);
-   ptr = LLVMGetParam(func, 0);
+   packed_ptr = LLVMGetParam(func, 0);
    rgba_ptr = LLVMGetParam(func, 1);
 
    block = LLVMAppendBasicBlock(func, "entry");
@@ -154,7 +185,12 @@ add_store_rgba_test(LLVMModuleRef module,
 
    rgba = LLVMBuildLoad(builder, rgba_ptr, "");
 
-   lp_build_store_rgba_aos(builder, format, ptr, rgba);
+   packed = lp_build_pack_rgba_aos(builder, desc, rgba);
+
+   if(desc->block.bits < 32)
+      packed = LLVMBuildZExt(builder, packed, LLVMInt32Type(), "");
+
+   LLVMBuildStore(builder, packed, packed_ptr);
 
    LLVMBuildRetVoid(builder);
 
@@ -163,8 +199,9 @@ add_store_rgba_test(LLVMModuleRef module,
 }
 
 
+ALIGN_STACK
 static boolean
-test_format(const struct pixel_test_case *test)
+test_format(unsigned verbose, FILE *fp, const struct pixel_test_case *test)
 {
    LLVMModuleRef module = NULL;
    LLVMValueRef load = NULL;
@@ -186,8 +223,8 @@ test_format(const struct pixel_test_case *test)
 
    module = LLVMModuleCreateWithName("test");
 
-   load = add_load_rgba_test(module, test->format);
-   store = add_store_rgba_test(module, test->format);
+   load = add_load_rgba_test(module, desc);
+   store = add_store_rgba_test(module, desc);
 
    if(LLVMVerifyModule(module, LLVMPrintMessageAction, &error)) {
       LLVMDumpModule(module);
@@ -223,7 +260,7 @@ test_format(const struct pixel_test_case *test)
    memset(unpacked, 0, sizeof unpacked);
    packed = 0;
 
-   load_ptr(&test->packed, unpacked);
+   load_ptr(test->packed, unpacked);
    store_ptr(&packed, unpacked);
 
    success = TRUE;
@@ -249,23 +286,29 @@ test_format(const struct pixel_test_case *test)
    if(pass)
       LLVMDisposePassManager(pass);
 
+   if(fp)
+      write_tsv_row(fp, desc, success);
+
    return success;
 }
 
 
-int main(int argc, char **argv)
+boolean
+test_all(unsigned verbose, FILE *fp)
 {
    unsigned i;
-   int ret;
-
-#ifdef LLVM_NATIVE_ARCH
-   LLVMLinkInJIT();
-   LLVMInitializeNativeTarget();
-#endif
+   bool success = TRUE;
 
    for (i = 0; i < sizeof(test_cases)/sizeof(test_cases[0]); ++i)
-      if(!test_format(&test_cases[i]))
-        ret = 1;
+      if(!test_format(verbose, fp, &test_cases[i]))
+        success = FALSE;
 
-   return ret;
+   return success;
+}
+
+
+boolean
+test_some(unsigned verbose, FILE *fp, unsigned long n)
+{
+   return test_all(verbose, fp);
 }
index f07fa256f16d3d4a199d525a6e699253ff54aaad..314544aa9a6774d9cc9210ba9bafb0dcf409bd3c 100644 (file)
  */
 
 
+#include "util/u_cpu_detect.h"
+
 #include "lp_bld_const.h"
+#include "lp_bld_misc.h"
 #include "lp_test.h"
 
 
+#ifdef PIPE_CC_MSVC
+static INLINE double
+round(double x)
+{
+   if (x >= 0.0)
+      return floor(x + 0.5);
+   else
+      return ceil(x - 0.5);
+}
+#endif
+
+
 void
 dump_type(FILE *fp,
           struct lp_type type)
@@ -365,10 +380,10 @@ int main(int argc, char **argv)
          n = atoi(argv[i]);
    }
 
-#ifdef LLVM_NATIVE_ARCH
    LLVMLinkInJIT();
    LLVMInitializeNativeTarget();
-#endif
+
+   util_cpu_detect();
 
    if(fp) {
       /* Warm up the caches */
index dfc9c0e6f0435a12a212ae7d54304e97b8f8bc07..cb59a94464a2604655642e5f9692e4879e1509a4 100644 (file)
 
 #include <llvm-c/Core.h>
 
-#include "tgsi/tgsi_exec.h"
-
 
 struct lp_sampler_static_state;
 
 
-
-extern void
-lp_get_samples(struct tgsi_sampler *tgsi_sampler,
-               const float s[QUAD_SIZE],
-               const float t[QUAD_SIZE],
-               const float p[QUAD_SIZE],
-               float lodbias,
-               float rgba[NUM_CHANNELS][QUAD_SIZE]);
-
-
-/**
- * Texture sampling code generator that just calls lp_get_samples C function
- * for the actual sampling computation.
- *
- * @param context_ptr LLVM value with the pointer to the struct lp_jit_context.
- */
-struct lp_build_sampler_soa *
-lp_c_sampler_soa_create(LLVMValueRef context_ptr);
-
-
 /**
  * Pure-LLVM texture sampling code generator.
  *
index 1682e37354a345176a157e2ebd365bf8ac97c2db..2462378152ab9c3000c6a1f19814a88bd72b0ed0 100644 (file)
@@ -34,6 +34,8 @@
 #include "pipe/p_defines.h"
 #include "pipe/p_inlines.h"
 #include "pipe/internal/p_winsys_screen.h"
+
+#include "util/u_format.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
 
@@ -47,7 +49,6 @@
 /* Simple, maximally packed layout.
  */
 
-
 /* Conventional allocation path for non-display textures:
  */
 static boolean
@@ -56,31 +57,31 @@ llvmpipe_texture_layout(struct llvmpipe_screen *screen,
 {
    struct pipe_texture *pt = &lpt->base;
    unsigned level;
-   unsigned width = pt->width[0];
-   unsigned height = pt->height[0];
-   unsigned depth = pt->depth[0];
+   unsigned width = pt->width0;
+   unsigned height = pt->height0;
+   unsigned depth = pt->depth0;
 
    unsigned buffer_size = 0;
 
-   pf_get_block(lpt->base.format, &lpt->base.block);
-
    for (level = 0; level <= pt->last_level; level++) {
-      pt->width[level] = width;
-      pt->height[level] = height;
-      pt->depth[level] = depth;
-      pt->nblocksx[level] = pf_get_nblocksx(&pt->block, width);  
-      pt->nblocksy[level] = pf_get_nblocksy(&pt->block, height);  
-      lpt->stride[level] = align(pt->nblocksx[level]*pt->block.size, 16);
+      unsigned nblocksx, nblocksy;
+
+      /* Allocate storage for whole quads. This is particularly important
+       * for depth surfaces, which are currently stored in a swizzled format. */
+      nblocksx = util_format_get_nblocksx(pt->format, align(width, 2));
+      nblocksy = util_format_get_nblocksy(pt->format, align(height, 2));
+
+      lpt->stride[level] = align(nblocksx * util_format_get_blocksize(pt->format), 16);
 
       lpt->level_offset[level] = buffer_size;
 
-      buffer_size += (pt->nblocksy[level] *
+      buffer_size += (nblocksy *
                       ((pt->target == PIPE_TEXTURE_CUBE) ? 6 : depth) *
                       lpt->stride[level]);
 
-      width  = minify(width);
-      height = minify(height);
-      depth = minify(depth);
+      width  = u_minify(width, 1);
+      height = u_minify(height, 1);
+      depth = u_minify(depth, 1);
    }
 
    lpt->data = align_malloc(buffer_size, 16);
@@ -94,14 +95,10 @@ llvmpipe_displaytarget_layout(struct llvmpipe_screen *screen,
 {
    struct llvmpipe_winsys *winsys = screen->winsys;
 
-   pf_get_block(lpt->base.format, &lpt->base.block);
-   lpt->base.nblocksx[0] = pf_get_nblocksx(&lpt->base.block, lpt->base.width[0]);  
-   lpt->base.nblocksy[0] = pf_get_nblocksy(&lpt->base.block, lpt->base.height[0]);  
-
    lpt->dt = winsys->displaytarget_create(winsys,
                                           lpt->base.format,
-                                          lpt->base.width[0],
-                                          lpt->base.height[0],
+                                          lpt->base.width0,
+                                          lpt->base.height0,
                                           16,
                                           &lpt->stride[0] );
 
@@ -163,7 +160,7 @@ llvmpipe_texture_blanket(struct pipe_screen * screen,
    /* Only supports one type */
    if (base->target != PIPE_TEXTURE_2D ||
        base->last_level != 0 ||
-       base->depth[0] != 1) {
+       base->depth0 != 1) {
       return NULL;
    }
 
@@ -174,8 +171,6 @@ llvmpipe_texture_blanket(struct pipe_screen * screen,
    lpt->base = *base;
    pipe_reference_init(&lpt->base.reference, 1);
    lpt->base.screen = screen;
-   lpt->base.nblocksx[0] = pf_get_nblocksx(&lpt->base.block, lpt->base.width[0]);  
-   lpt->base.nblocksy[0] = pf_get_nblocksy(&lpt->base.block, lpt->base.height[0]);  
    lpt->stride[0] = stride[0];
 
    pipe_buffer_reference(&lpt->buffer, buffer);
@@ -220,8 +215,8 @@ llvmpipe_get_tex_surface(struct pipe_screen *screen,
       pipe_reference_init(&ps->reference, 1);
       pipe_texture_reference(&ps->texture, pt);
       ps->format = pt->format;
-      ps->width = pt->width[level];
-      ps->height = pt->height[level];
+      ps->width = u_minify(pt->width0, level);
+      ps->height = u_minify(pt->height0, level);
       ps->offset = lpt->level_offset[level];
       ps->usage = usage;
 
@@ -249,11 +244,17 @@ llvmpipe_get_tex_surface(struct pipe_screen *screen,
       ps->level = level;
       ps->zslice = zslice;
 
+      /* XXX shouldn't that rather be
+         tex_height = align(ps->height, 2);
+         to account for alignment done in llvmpipe_texture_layout ?
+      */
       if (pt->target == PIPE_TEXTURE_CUBE) {
-         ps->offset += face * pt->nblocksy[level] * lpt->stride[level];
+         unsigned tex_height = ps->height;
+         ps->offset += face * util_format_get_nblocksy(pt->format, tex_height) * lpt->stride[level];
       }
       else if (pt->target == PIPE_TEXTURE_3D) {
-         ps->offset += zslice * pt->nblocksy[level] * lpt->stride[level];
+         unsigned tex_height = ps->height;
+         ps->offset += zslice * util_format_get_nblocksy(pt->format, tex_height) * lpt->stride[level];
       }
       else {
          assert(face == 0);
@@ -294,14 +295,10 @@ llvmpipe_get_tex_transfer(struct pipe_screen *screen,
    if (lpt) {
       struct pipe_transfer *pt = &lpt->base;
       pipe_texture_reference(&pt->texture, texture);
-      pt->format = texture->format;
-      pt->block = texture->block;
       pt->x = x;
       pt->y = y;
       pt->width = w;
       pt->height = h;
-      pt->nblocksx = texture->nblocksx[level];
-      pt->nblocksy = texture->nblocksy[level];
       pt->stride = lptex->stride[level];
       pt->usage = usage;
       pt->face = face;
@@ -310,11 +307,17 @@ llvmpipe_get_tex_transfer(struct pipe_screen *screen,
 
       lpt->offset = lptex->level_offset[level];
 
+      /* XXX shouldn't that rather be
+         tex_height = align(u_minify(texture->height0, level), 2)
+         to account for alignment done in llvmpipe_texture_layout ?
+      */
       if (texture->target == PIPE_TEXTURE_CUBE) {
-         lpt->offset += face * pt->nblocksy * pt->stride;
+         unsigned tex_height = u_minify(texture->height0, level);
+         lpt->offset += face *  util_format_get_nblocksy(texture->format, tex_height) * pt->stride;
       }
       else if (texture->target == PIPE_TEXTURE_3D) {
-         lpt->offset += zslice * pt->nblocksy * pt->stride;
+         unsigned tex_height = u_minify(texture->height0, level);
+         lpt->offset += zslice * util_format_get_nblocksy(texture->format, tex_height) * pt->stride;
       }
       else {
          assert(face == 0);
@@ -346,9 +349,11 @@ llvmpipe_transfer_map( struct pipe_screen *_screen,
    struct llvmpipe_screen *screen = llvmpipe_screen(_screen);
    ubyte *map, *xfer_map;
    struct llvmpipe_texture *lpt;
+   enum pipe_format format;
 
    assert(transfer->texture);
    lpt = llvmpipe_texture(transfer->texture);
+   format = lpt->base.format;
 
    if(lpt->dt) {
       struct llvmpipe_winsys *winsys = screen->winsys;
@@ -372,8 +377,8 @@ llvmpipe_transfer_map( struct pipe_screen *_screen,
    }
    
    xfer_map = map + llvmpipe_transfer(transfer)->offset +
-      transfer->y / transfer->block.height * transfer->stride +
-      transfer->x / transfer->block.width * transfer->block.size;
+      transfer->y / util_format_get_blockheight(format) * transfer->stride +
+      transfer->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
    /*printf("map = %p  xfer map = %p\n", map, xfer_map);*/
    return xfer_map;
 }
index 660cc30c820f3874458df6d96da83692d620363c..1b7be3cce0d010d9e76f7016fc92cb342edb15b3 100644 (file)
@@ -29,7 +29,7 @@
 #define LP_TILE_SOA_H
 
 #include "pipe/p_compiler.h"
-#include "tgsi/tgsi_exec.h" // for NUM_CHANNELS
+#include "tgsi/tgsi_exec.h" /* for NUM_CHANNELS */
 
 
 #ifdef __cplusplus
index 595481c2cbc21e4fce33fb332e6ee8cf56266a66..74b472b653137793315c63eea710e3644cc10d7e 100644 (file)
@@ -35,7 +35,7 @@
 #define LP_WINSYS_H
 
 
-#include "pipe/p_compiler.h" // for boolean
+#include "pipe/p_compiler.h" /* for boolean */
 #include "pipe/p_format.h"
 
 
index dbe8a6e7bf5816620f667f97c1f478cf3fd70a01..0cb66041d50ac12d21cd9161e32523e874d8a1f8 100644 (file)
@@ -3,6 +3,7 @@ include $(TOP)/configs/current
 
 LIBNAME = nouveau
 
-C_SOURCES = nouveau_screen.c
+C_SOURCES = nouveau_screen.c \
+           nouveau_context.c
 
 include ../../Makefile.template
diff --git a/src/gallium/drivers/nouveau/nouveau_context.c b/src/gallium/drivers/nouveau/nouveau_context.c
new file mode 100644 (file)
index 0000000..2344386
--- /dev/null
@@ -0,0 +1,41 @@
+#include <pipe/p_defines.h>
+#include <pipe/p_context.h>
+
+#include "nouveau/nouveau_screen.h"
+#include "nouveau/nouveau_context.h"
+
+#include "nouveau/nouveau_bo.h"
+
+static unsigned int
+nouveau_reference_flags(struct nouveau_bo *bo)
+{
+       uint32_t bo_flags;
+       int flags = 0;
+
+       bo_flags = nouveau_bo_pending(bo);
+       if (bo_flags & NOUVEAU_BO_RD)
+               flags |= PIPE_REFERENCED_FOR_READ;
+       if (bo_flags & NOUVEAU_BO_WR)
+               flags |= PIPE_REFERENCED_FOR_WRITE;
+
+       return flags;
+}
+
+unsigned int
+nouveau_is_texture_referenced(struct pipe_context *pipe,
+                             struct pipe_texture *pt,
+                             unsigned face, unsigned level)
+{
+       struct nouveau_miptree *mt = nouveau_miptree(pt);
+
+       return nouveau_reference_flags(mt->bo);
+}
+
+unsigned int
+nouveau_is_buffer_referenced(struct pipe_context *pipe, struct pipe_buffer *pb)
+{
+       struct nouveau_bo *bo = nouveau_bo(pb);
+
+       return nouveau_reference_flags(bo);
+}
+
diff --git a/src/gallium/drivers/nouveau/nouveau_context.h b/src/gallium/drivers/nouveau/nouveau_context.h
new file mode 100644 (file)
index 0000000..6a28d40
--- /dev/null
@@ -0,0 +1,11 @@
+#ifndef __NOUVEAU_CONTEXT_H__
+#define __NOUVEAU_CONTEXT_H__
+
+unsigned int
+nouveau_is_texture_referenced(struct pipe_context *, struct pipe_texture *,
+                             unsigned face, unsigned level);
+
+unsigned int
+nouveau_is_buffer_referenced(struct pipe_context *, struct pipe_buffer *);
+
+#endif
diff --git a/src/gallium/drivers/nouveau/nouveau_push.h b/src/gallium/drivers/nouveau/nouveau_push.h
deleted file mode 100644 (file)
index 9c23508..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-#ifndef __NOUVEAU_PUSH_H__
-#define __NOUVEAU_PUSH_H__
-
-#include "nouveau/nouveau_winsys.h"
-
-#ifndef NOUVEAU_PUSH_CONTEXT
-#error undefined push context
-#endif
-
-#define OUT_RING(data) do {                                                    \
-       NOUVEAU_PUSH_CONTEXT(pc);                                              \
-       (*pc->base.channel->pushbuf->cur++) = (data);                          \
-} while(0)
-
-#define OUT_RINGp(src,size) do {                                               \
-       NOUVEAU_PUSH_CONTEXT(pc);                                              \
-       memcpy(pc->base.channel->pushbuf->cur, (src), (size) * 4);             \
-       pc->base.channel->pushbuf->cur += (size);                              \
-} while(0)
-
-#define OUT_RINGf(data) do {                                                   \
-       union { float v; uint32_t u; } c;                                      \
-       c.v = (data);                                                          \
-       OUT_RING(c.u);                                                         \
-} while(0)
-
-#define BEGIN_RING(obj,mthd,size) do {                                         \
-       NOUVEAU_PUSH_CONTEXT(pc);                                              \
-       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));             \
-       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);                                              \
-       DO_FIRE_RING(pc->base.channel, fence);                                 \
-} while(0)
-
-#define OUT_RELOC(bo,data,flags,vor,tor) do {                                  \
-       NOUVEAU_PUSH_CONTEXT(pc);                                              \
-       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 */
-#define OUT_RELOCd(bo,data,flags,vor,tor) do {                                 \
-       OUT_RELOC((bo), (data), (flags) | NOUVEAU_BO_OR, (vor), (tor));        \
-} while(0)
-
-/* FB/TT object handle */
-#define OUT_RELOCo(bo,flags) do {                                              \
-       OUT_RELOC((bo), 0, (flags) | NOUVEAU_BO_OR,                            \
-                 pc->base.channel->vram->handle,                              \
-                 pc->base.channel->gart->handle);                             \
-} while(0)
-
-/* Low 32-bits of offset */
-#define OUT_RELOCl(bo,delta,flags) do {                                        \
-       OUT_RELOC((bo), (delta), (flags) | NOUVEAU_BO_LOW, 0, 0);              \
-} while(0)
-
-/* High 32-bits of offset */
-#define OUT_RELOCh(bo,delta,flags) do {                                        \
-       OUT_RELOC((bo), (delta), (flags) | NOUVEAU_BO_HIGH, 0, 0);             \
-} while(0)
-
-/* 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);                                              \
-       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);                                             \
-       chan->pushbuf->remaining -= ((size) + 1);                              \
-} while(0)
-
-#endif
index e4cf91c005c4d5d9a9ba8ac8d936e097e7e65d10..7ebc94ed6c7f2b37d6f4d6fa230295581a88fdab 100644 (file)
@@ -31,7 +31,7 @@ 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);
@@ -127,8 +127,18 @@ nouveau_screen_bo_map(struct pipe_screen *pscreen, struct pipe_buffer *pb,
                      unsigned usage)
 {
        struct nouveau_bo *bo = nouveau_bo(pb);
+       struct nouveau_screen *nscreen = nouveau_screen(pscreen);
        int ret;
 
+       if (nscreen->pre_pipebuffer_map_callback) {
+               ret = nscreen->pre_pipebuffer_map_callback(pscreen, pb, usage);
+               if (ret) {
+                       debug_printf("pre_pipebuffer_map_callback failed %d\n",
+                               ret);
+                       return NULL;
+               }
+       }
+
        ret = nouveau_bo_map(bo, nouveau_screen_map_flags(usage));
        if (ret) {
                debug_printf("map failed: %d\n", ret);
@@ -143,11 +153,22 @@ 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);
+       struct nouveau_screen *nscreen = nouveau_screen(pscreen);
        uint32_t flags = nouveau_screen_map_flags(usage);
        int ret;
 
+       if (nscreen->pre_pipebuffer_map_callback) {
+               ret = nscreen->pre_pipebuffer_map_callback(pscreen, pb, usage);
+               if (ret) {
+                       debug_printf("pre_pipebuffer_map_callback failed %d\n",
+                               ret);
+                       return NULL;
+               }
+       }
+
        ret = nouveau_bo_map_range(bo, offset, length, flags);
        if (ret) {
+               nouveau_bo_unmap(bo);
                if (!(flags & NOUVEAU_BO_NOWAIT) || ret != -EBUSY)
                        debug_printf("map_range failed: %d\n", ret);
                return NULL;
@@ -239,5 +260,6 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev)
 void
 nouveau_screen_fini(struct nouveau_screen *screen)
 {
+       nouveau_channel_free(&screen->channel);
 }
 
index ebfc67ad1c171dda2ba601260b663a47a53b2a06..a7927d88dfc832fec9011e52e95fa7a5481b0762 100644 (file)
@@ -5,6 +5,9 @@ struct nouveau_screen {
        struct pipe_screen base;
        struct nouveau_device *device;
        struct nouveau_channel *channel;
+
+       int (*pre_pipebuffer_map_callback) (struct pipe_screen *pscreen,
+               struct pipe_buffer *pb, unsigned usage);
 };
 
 static inline struct nouveau_screen *
index b595405357f0044255261993c4887f1acdcfb8c5..e844f6abb3dcc120747295a9a704ae49cd06390e 100644 (file)
@@ -3,41 +3,95 @@
 
 #include "util/u_debug.h"
 
+#ifdef DEBUG
+#define DEBUG_NOUVEAU_STATEOBJ
+#endif /* DEBUG */
+
 struct nouveau_stateobj_reloc {
        struct nouveau_bo *bo;
 
-       unsigned offset;
-       unsigned packet;
+       struct nouveau_grobj *gr;
+       uint32_t push_offset;
+       uint32_t mthd;
 
-       unsigned data;
+       uint32_t data;
        unsigned flags;
        unsigned vor;
        unsigned tor;
 };
 
+struct nouveau_stateobj_start {
+       struct nouveau_grobj *gr;
+       uint32_t mthd;
+       uint32_t size;
+       unsigned offset;
+};
+
 struct nouveau_stateobj {
        struct pipe_reference reference;
 
-       unsigned *push;
+       struct nouveau_stateobj_start *start;
        struct nouveau_stateobj_reloc *reloc;
 
-       unsigned *cur;
-       unsigned cur_packet;
+       /* Common memory pool for data. */
+       uint32_t *pool;
+       unsigned pool_cur;
+
+#ifdef DEBUG_NOUVEAU_STATEOBJ
+       unsigned start_alloc;
+       unsigned reloc_alloc;
+       unsigned pool_alloc;
+#endif  /* DEBUG_NOUVEAU_STATEOBJ */
+
+       unsigned total; /* includes begin_ring */
+       unsigned cur; /* excludes begin_ring, offset from "cur_start" */
+       unsigned cur_start;
        unsigned cur_reloc;
 };
 
+static INLINE void
+so_dump(struct nouveau_stateobj *so)
+{
+       unsigned i, nr, total = 0;
+
+       for (i = 0; i < so->cur_start; i++) {
+               if (so->start[i].gr->subc > -1)
+                       debug_printf("+0x%04x: 0x%08x\n", total++,
+                               (so->start[i].size << 18) | (so->start[i].gr->subc << 13)
+                               | so->start[i].mthd);
+               else
+                       debug_printf("+0x%04x: 0x%08x\n", total++,
+                               (so->start[i].size << 18) | so->start[i].mthd);
+               for (nr = 0; nr < so->start[i].size; nr++, total++)
+                       debug_printf("+0x%04x: 0x%08x\n", total,
+                               so->pool[so->start[i].offset + nr]);
+       }
+}
+
 static INLINE struct nouveau_stateobj *
-so_new(unsigned push, unsigned reloc)
+so_new(unsigned start, unsigned push, unsigned reloc)
 {
        struct nouveau_stateobj *so;
 
        so = MALLOC(sizeof(struct nouveau_stateobj));
        pipe_reference_init(&so->reference, 1);
-       so->push = MALLOC(sizeof(unsigned) * push);
-       so->reloc = MALLOC(sizeof(struct nouveau_stateobj_reloc) * reloc);
+       so->total = so->cur = so->cur_start = so->cur_reloc = 0;
+
+#ifdef DEBUG_NOUVEAU_STATEOBJ
+       so->start_alloc = start;
+       so->reloc_alloc = reloc;
+       so->pool_alloc = push;
+#endif /* DEBUG_NOUVEAU_STATEOBJ */
 
-       so->cur = so->push;
-       so->cur_reloc = so->cur_packet = 0;
+       so->start = MALLOC(start * sizeof(struct nouveau_stateobj_start));
+       so->reloc = MALLOC(reloc * sizeof(struct nouveau_stateobj_reloc));
+       so->pool = MALLOC(push * sizeof(uint32_t));
+       so->pool_cur = 0;
+
+       if (!so->start || !so->reloc || !so->pool) {
+               debug_printf("malloc failed\n");
+               assert(0);
+       }
 
        return so;
 }
@@ -48,62 +102,128 @@ so_ref(struct nouveau_stateobj *ref, struct nouveau_stateobj **pso)
        struct nouveau_stateobj *so = *pso;
        int i;
 
-        if (pipe_reference((struct pipe_reference**)pso, &ref->reference)) {
-               free(so->push);
+       if (pipe_reference(&(*pso)->reference, &ref->reference)) {
+               FREE(so->start);
                for (i = 0; i < so->cur_reloc; i++)
                        nouveau_bo_ref(NULL, &so->reloc[i].bo);
-               free(so->reloc);
-               free(so);
+               FREE(so->reloc);
+               FREE(so->pool);
+               FREE(so);
        }
+       *pso = ref;
 }
 
 static INLINE void
-so_data(struct nouveau_stateobj *so, unsigned data)
+so_data(struct nouveau_stateobj *so, uint32_t data)
 {
-       (*so->cur++) = (data);
-       so->cur_packet += 4;
+#ifdef DEBUG_NOUVEAU_STATEOBJ
+       if (so->cur >= so->start[so->cur_start - 1].size) {
+               debug_printf("exceeding specified size\n");
+               assert(0);
+       }
+#endif /* DEBUG_NOUVEAU_STATEOBJ */
+
+       so->pool[so->start[so->cur_start - 1].offset + so->cur++] = data;
 }
 
 static INLINE void
-so_datap(struct nouveau_stateobj *so, unsigned *data, unsigned size)
+so_datap(struct nouveau_stateobj *so, uint32_t *data, unsigned size)
 {
-       so->cur_packet += (4 * size);
+#ifdef DEBUG_NOUVEAU_STATEOBJ
+       if ((so->cur + size) > so->start[so->cur_start - 1].size) {
+               debug_printf("exceeding specified size\n");
+               assert(0);
+       }
+#endif /* DEBUG_NOUVEAU_STATEOBJ */
+
        while (size--)
-               (*so->cur++) = (*data++);
+               so->pool[so->start[so->cur_start - 1].offset + so->cur++] =
+                       *data++;
 }
 
 static INLINE void
 so_method(struct nouveau_stateobj *so, struct nouveau_grobj *gr,
          unsigned mthd, unsigned size)
 {
-       so->cur_packet = (gr->subc << 13) | (1 << 18) | (mthd - 4);
-       so_data(so, (gr->subc << 13) | (size << 18) | mthd);
+       struct nouveau_stateobj_start *start;
+
+#ifdef DEBUG_NOUVEAU_STATEOBJ
+       if (so->start_alloc <= so->cur_start) {
+               debug_printf("exceeding num_start size\n");
+               assert(0);
+       } else
+#endif /* DEBUG_NOUVEAU_STATEOBJ */
+               start = so->start;
+
+#ifdef DEBUG_NOUVEAU_STATEOBJ
+       if (so->cur_start > 0 && start[so->cur_start - 1].size > so->cur) {
+               debug_printf("previous so_method was not filled\n");
+               assert(0);
+       }
+#endif /* DEBUG_NOUVEAU_STATEOBJ */
+
+       so->start = start;
+       start[so->cur_start].gr = gr;
+       start[so->cur_start].mthd = mthd;
+       start[so->cur_start].size = size;
+
+#ifdef DEBUG_NOUVEAU_STATEOBJ
+       if (so->pool_alloc < (size + so->pool_cur)) {
+               debug_printf("exceeding num_pool size\n");
+               assert(0);
+       }
+#endif /* DEBUG_NOUVEAU_STATEOBJ */
+
+       start[so->cur_start].offset = so->pool_cur;
+       so->pool_cur += size;
+
+       so->cur_start++;
+       /* The 1 is for *this* begin_ring. */
+       so->total += so->cur + 1;
+       so->cur = 0;
 }
 
 static INLINE void
 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;
-       nouveau_bo_ref(bo, &r->bo);
-       r->offset = so->cur - so->push;
-       r->packet = so->cur_packet;
-       r->data = data;
-       r->flags = flags;
-       r->vor = vor;
-       r->tor = tor;
+       struct nouveau_stateobj_reloc *r;
+
+#ifdef DEBUG_NOUVEAU_STATEOBJ
+       if (so->reloc_alloc <= so->cur_reloc) {
+               debug_printf("exceeding num_reloc size\n");
+               assert(0);
+       } else
+#endif /* DEBUG_NOUVEAU_STATEOBJ */
+               r = so->reloc;
+
+       so->reloc = r;
+       r[so->cur_reloc].bo = NULL;
+       nouveau_bo_ref(bo, &(r[so->cur_reloc].bo));
+       r[so->cur_reloc].gr = so->start[so->cur_start-1].gr;
+       r[so->cur_reloc].push_offset = so->total + so->cur;
+       r[so->cur_reloc].data = data;
+       r[so->cur_reloc].flags = flags;
+       r[so->cur_reloc].mthd = so->start[so->cur_start-1].mthd +
+                                                       (so->cur << 2);
+       r[so->cur_reloc].vor = vor;
+       r[so->cur_reloc].tor = tor;
+
        so_data(so, data);
+       so->cur_reloc++;
 }
 
-static INLINE void
-so_dump(struct nouveau_stateobj *so)
+/* Determine if this buffer object is referenced by this state object. */
+static INLINE boolean
+so_bo_is_reloc(struct nouveau_stateobj *so, struct nouveau_bo *bo)
 {
-       unsigned i, nr = so->cur - so->push;
+       int i;
+
+       for (i = 0; i < so->cur_reloc; i++)
+               if (so->reloc[i].bo == bo)
+                       return true;
 
-       for (i = 0; i < nr; i++)
-               debug_printf("+0x%04x: 0x%08x\n", i, so->push[i]);
+       return false;
 }
 
 static INLINE void
@@ -111,48 +231,95 @@ so_emit(struct nouveau_channel *chan, struct nouveau_stateobj *so)
 {
        struct nouveau_pushbuf *pb = chan->pushbuf;
        unsigned nr, i;
+       int ret = 0;
 
-       nr = so->cur - so->push;
-       if (pb->remaining < nr)
-               nouveau_pushbuf_flush(chan, nr);
-       pb->remaining -= nr;
+#ifdef DEBUG_NOUVEAU_STATEOBJ
+       if (so->start[so->cur_start - 1].size > so->cur) {
+               debug_printf("emit: previous so_method was not filled\n");
+               assert(0);
+       }
+#endif /* DEBUG_NOUVEAU_STATEOBJ */
+
+       /* We cannot update total in case we so_emit again. */
+       nr = so->total + so->cur;
+
+       /* This will flush if we need space.
+        * We don't actually need the marker.
+        */
+       if ((ret = nouveau_pushbuf_marker_emit(chan, nr, so->cur_reloc))) {
+               debug_printf("so_emit failed marker emit with error %d\n", ret);
+               assert(0);
+       }
+
+       /* Submit data. This will ensure proper binding of objects. */
+       for (i = 0; i < so->cur_start; i++) {
+               BEGIN_RING(chan, so->start[i].gr, so->start[i].mthd, so->start[i].size);
+               OUT_RINGp(chan, &(so->pool[so->start[i].offset]), so->start[i].size);
+       }
 
-       memcpy(pb->cur, so->push, nr * 4);
        for (i = 0; i < so->cur_reloc; i++) {
                struct nouveau_stateobj_reloc *r = &so->reloc[i];
 
-               nouveau_pushbuf_emit_reloc(chan, pb->cur + r->offset,
-                                          r->bo, r->data, 0, r->flags,
-                                          r->vor, r->tor);
+               if ((ret = nouveau_pushbuf_emit_reloc(chan, pb->cur - nr +
+                                               r->push_offset, r->bo, r->data,
+                                               0, r->flags, r->vor, r->tor))) {
+                       debug_printf("so_emit failed reloc with error %d\n", ret);
+                       assert(0);
+               }
        }
-       pb->cur += nr;
 }
 
 static INLINE void
 so_emit_reloc_markers(struct nouveau_channel *chan, struct nouveau_stateobj *so)
 {
        struct nouveau_pushbuf *pb = chan->pushbuf;
+       struct nouveau_grobj *gr = NULL;
        unsigned i;
+       int ret = 0;
 
        if (!so)
                return;
 
-       i = so->cur_reloc << 1;
-       if (pb->remaining < i)
-               nouveau_pushbuf_flush(chan, i);
-       pb->remaining -= i;
-
+       /* If we need to flush in flush notify, then we have a problem anyway. */
        for (i = 0; i < so->cur_reloc; i++) {
                struct nouveau_stateobj_reloc *r = &so->reloc[i];
 
-               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);
+#ifdef DEBUG_NOUVEAU_STATEOBJ
+               if (r->mthd & 0x40000000) {
+                       debug_printf("error: NI mthd 0x%08X\n", r->mthd);
+                       continue;
+               }
+#endif /* DEBUG_NOUVEAU_STATEOBJ */
+
+               /* The object needs to be bound and the system must know the
+                * subchannel is being used. Otherwise it will discard it.
+                */
+               if (gr != r->gr) {
+                       BEGIN_RING(chan, r->gr, 0x100, 1);
+                       OUT_RING(chan, 0);
+                       gr = r->gr;
+               }
+
+               /* Some relocs really don't like to be hammered,
+                * NOUVEAU_BO_DUMMY makes sure it only
+                * happens when needed.
+                */
+               ret = OUT_RELOC(chan, r->bo, (r->gr->subc << 13) | (1<< 18) |
+                       r->mthd, (r->flags & (NOUVEAU_BO_VRAM | NOUVEAU_BO_GART
+                               | NOUVEAU_BO_RDWR)) | NOUVEAU_BO_DUMMY, 0, 0);
+               if (ret) {
+                       debug_printf("OUT_RELOC failed %d\n", ret);
+                       assert(0);
+               }
+
+               ret = OUT_RELOC(chan, r->bo, r->data, r->flags |
+                       NOUVEAU_BO_DUMMY, r->vor, r->tor);
+               if (ret) {
+                       debug_printf("OUT_RELOC failed %d\n", ret);
+                       assert(0);
+               }
+
+               pb->remaining -= 2;
        }
 }
 
index 42c77e5e77890fb15e8403cbc6d485ea29f95255..4c3e08a43f5d8131ce78761580922c8fef1022d4 100644 (file)
@@ -23,6 +23,9 @@
 #define NOUVEAU_BUFFER_USAGE_ZETA     (1 << 17)
 #define NOUVEAU_BUFFER_USAGE_TRANSFER (1 << 18)
 
+/* use along with GPU_WRITE for 2D-only writes */
+#define NOUVEAU_BUFFER_USAGE_NO_RENDER (1 << 19)
+
 extern struct pipe_screen *
 nv04_screen_create(struct pipe_winsys *ws, struct nouveau_device *);
 
index 17166c9f51de49f07281928fa3ae33ac09d07871..edd96859cf8c1269a2e3e169e9e2929265eeec34 100644 (file)
@@ -10,10 +10,14 @@ nv04_flush(struct pipe_context *pipe, unsigned flags,
           struct pipe_fence_handle **fence)
 {
        struct nv04_context *nv04 = nv04_context(pipe);
+       struct nv04_screen *screen = nv04->screen;
+       struct nouveau_channel *chan = screen->base.channel;
 
        draw_flush(nv04->draw);
 
-       FIRE_RING(fence);
+       FIRE_RING(chan);
+       if (fence)
+               *fence = NULL;
 }
 
 static void
@@ -27,67 +31,42 @@ nv04_destroy(struct pipe_context *pipe)
        FREE(nv04);
 }
 
-static void
-nv04_set_edgeflags(struct pipe_context *pipe, const unsigned *bitfield)
-{
-}
-
 static boolean
 nv04_init_hwctx(struct nv04_context *nv04)
 {
+       struct nv04_screen *screen = nv04->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *fahrenheit = screen->fahrenheit;
+
        // requires a valid handle
-//     BEGIN_RING(fahrenheit, NV04_DX5_TEXTURED_TRIANGLE_NOTIFY, 1);
+//     BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_NOTIFY, 1);
 //     OUT_RING(0);
-       BEGIN_RING(fahrenheit, NV04_DX5_TEXTURED_TRIANGLE_NOP, 1);
-       OUT_RING(0);
+       BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_NOP, 1);
+       OUT_RING(chan, 0);
 
-       BEGIN_RING(fahrenheit, NV04_DX5_TEXTURED_TRIANGLE_CONTROL, 1);
-       OUT_RING(0x40182800);
+       BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_CONTROL, 1);
+       OUT_RING(chan, 0x40182800);
 //     OUT_RING(1<<20/*no cull*/);
-       BEGIN_RING(fahrenheit, NV04_DX5_TEXTURED_TRIANGLE_BLEND, 1);
+       BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_BLEND, 1);
 //     OUT_RING(0x24|(1<<6)|(1<<8));
-       OUT_RING(0x120001a4);
-       BEGIN_RING(fahrenheit, NV04_DX5_TEXTURED_TRIANGLE_FORMAT, 1);
-       OUT_RING(0x332213a1);
-       BEGIN_RING(fahrenheit, NV04_DX5_TEXTURED_TRIANGLE_FILTER, 1);
-       OUT_RING(0x11001010);
-       BEGIN_RING(fahrenheit, NV04_DX5_TEXTURED_TRIANGLE_COLORKEY, 1);
-       OUT_RING(0x0);
-//     BEGIN_RING(fahrenheit, NV04_DX5_TEXTURED_TRIANGLE_OFFSET, 1);
+       OUT_RING(chan, 0x120001a4);
+       BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_FORMAT, 1);
+       OUT_RING(chan, 0x332213a1);
+       BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_FILTER, 1);
+       OUT_RING(chan, 0x11001010);
+       BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_COLORKEY, 1);
+       OUT_RING(chan, 0x0);
+//     BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_OFFSET, 1);
 //     OUT_RING(SCREEN_OFFSET);
-       BEGIN_RING(fahrenheit, NV04_DX5_TEXTURED_TRIANGLE_FOGCOLOR, 1);
-       OUT_RING(0xff000000);
+       BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_FOGCOLOR, 1);
+       OUT_RING(chan, 0xff000000);
 
 
 
-       FIRE_RING (NULL);
+       FIRE_RING (chan);
        return TRUE;
 }
 
-static unsigned int
-nv04_is_texture_referenced( struct pipe_context *pipe,
-                           struct pipe_texture *texture,
-                           unsigned face, unsigned level)
-{
-   /**
-    * FIXME: Optimize.
-    */
-
-   return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
-
-static unsigned int
-nv04_is_buffer_referenced( struct pipe_context *pipe,
-                          struct pipe_buffer *buf)
-{
-   /**
-    * FIXME: Optimize.
-    */
-
-   return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
-
-
 struct pipe_context *
 nv04_create(struct pipe_screen *pscreen, unsigned pctx_id)
 {
@@ -107,14 +86,13 @@ nv04_create(struct pipe_screen *pscreen, unsigned pctx_id)
        nv04->pipe.winsys = ws;
        nv04->pipe.screen = pscreen;
        nv04->pipe.destroy = nv04_destroy;
-       nv04->pipe.set_edgeflags = nv04_set_edgeflags;
        nv04->pipe.draw_arrays = nv04_draw_arrays;
        nv04->pipe.draw_elements = nv04_draw_elements;
        nv04->pipe.clear = nv04_clear;
        nv04->pipe.flush = nv04_flush;
 
-       nv04->pipe.is_texture_referenced = nv04_is_texture_referenced;
-       nv04->pipe.is_buffer_referenced = nv04_is_buffer_referenced;
+       nv04->pipe.is_texture_referenced = nouveau_is_texture_referenced;
+       nv04->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
 
        nv04_init_surface_functions(nv04);
        nv04_init_state_functions(nv04);
index 2842b2c90db54f7ce62fc7499733bed9ec9e2ca6..fe3b527423cf44316f32a7ee2caeb7c37fe6ea65 100644 (file)
 
 #include "nouveau/nouveau_winsys.h"
 #include "nouveau/nouveau_gldefs.h"
-
-#define NOUVEAU_PUSH_CONTEXT(ctx)                                              \
-       struct nv04_screen *ctx = nv04->screen
-#include "nouveau/nouveau_push.h"
+#include "nouveau/nouveau_context.h"
 
 #include "nv04_state.h"
 
@@ -140,9 +137,9 @@ extern void nv04_emit_hw_state(struct nv04_context *nv04);
 extern void nv04_state_tex_update(struct nv04_context *nv04);
 
 /* nv04_vbo.c */
-extern boolean nv04_draw_arrays(struct pipe_context *, unsigned mode,
+extern void nv04_draw_arrays(struct pipe_context *, unsigned mode,
                                unsigned start, unsigned count);
-extern boolean nv04_draw_elements( struct pipe_context *pipe,
+extern void nv04_draw_elements( struct pipe_context *pipe,
                     struct pipe_buffer *indexBuffer,
                     unsigned indexSize,
                     unsigned prim, unsigned start, unsigned count);
index 21f990fd536deb3a4a4fe32319c9d775c2c1f649..c152b52119aae8c8f49dd353a2ff909e2b9358cf 100644 (file)
@@ -4,7 +4,7 @@
 #define _(m,tf)                                                                \
 {                                                                              \
   PIPE_FORMAT_##m,                                                             \
-  NV04_DX5_TEXTURED_TRIANGLE_FORMAT_COLOR_##tf,                                               \
+  NV04_TEXTURED_TRIANGLE_FORMAT_COLOR_##tf,                                               \
 }
 
 struct nv04_texture_format {
@@ -53,14 +53,14 @@ nv04_fragtex_build(struct nv04_context *nv04, int unit)
                return;
        }
 
-       nv04->fragtex.format = NV04_DX5_TEXTURED_TRIANGLE_FORMAT_ORIGIN_ZOH_CORNER 
-               | NV04_DX5_TEXTURED_TRIANGLE_FORMAT_ORIGIN_FOH_CORNER
+       nv04->fragtex.format = NV04_TEXTURED_TRIANGLE_FORMAT_ORIGIN_ZOH_CORNER
+               | NV04_TEXTURED_TRIANGLE_FORMAT_ORIGIN_FOH_CORNER
                | nv04_fragtex_format(pt->format)
-               | ( (pt->last_level + 1) << NV04_DX5_TEXTURED_TRIANGLE_FORMAT_MIPMAP_LEVELS_SHIFT )
-               | ( log2i(pt->width[0]) << NV04_DX5_TEXTURED_TRIANGLE_FORMAT_BASE_SIZE_U_SHIFT )
-               | ( log2i(pt->height[0]) << NV04_DX5_TEXTURED_TRIANGLE_FORMAT_BASE_SIZE_V_SHIFT )
-               | NV04_DX5_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_CLAMP_TO_EDGE
-               | NV04_DX5_TEXTURED_TRIANGLE_FORMAT_ADDRESSV_CLAMP_TO_EDGE
+               | ( (pt->last_level + 1) << NV04_TEXTURED_TRIANGLE_FORMAT_MIPMAP_LEVELS_SHIFT )
+               | ( log2i(pt->width0) << NV04_TEXTURED_TRIANGLE_FORMAT_BASE_SIZE_U_SHIFT )
+               | ( log2i(pt->height0) << NV04_TEXTURED_TRIANGLE_FORMAT_BASE_SIZE_V_SHIFT )
+               | NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_CLAMP_TO_EDGE
+               | NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSV_CLAMP_TO_EDGE
                ;
 }
 
index 93f752faec90c135e7b4e38f313b9a2bee4b3197..e0a6948aeb45eef0017ca1e0d87c1716048646c8 100644 (file)
@@ -1,6 +1,7 @@
 #include "pipe/p_state.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_inlines.h"
+#include "util/u_math.h"
 
 #include "nv04_context.h"
 #include "nv04_screen.h"
@@ -9,31 +10,22 @@ static void
 nv04_miptree_layout(struct nv04_miptree *nv04mt)
 {
        struct pipe_texture *pt = &nv04mt->base;
-       uint width = pt->width[0], height = pt->height[0];
        uint offset = 0;
        int nr_faces, l;
 
        nr_faces = 1;
 
        for (l = 0; l <= pt->last_level; l++) {
-               pt->width[l] = width;
-               pt->height[l] = height;
-
-               pt->nblocksx[l] = pf_get_nblocksx(&pt->block, width);
-               pt->nblocksy[l] = pf_get_nblocksy(&pt->block, height);
-               
-               nv04mt->level[l].pitch = pt->width[0];
+               nv04mt->level[l].pitch = pt->width0;
                nv04mt->level[l].pitch = (nv04mt->level[l].pitch + 63) & ~63;
-
-               width  = MAX2(1, width  >> 1);
-               height = MAX2(1, height >> 1);
        }
 
        for (l = 0; l <= pt->last_level; l++) {
-
                nv04mt->level[l].image_offset = 
                        CALLOC(nr_faces, sizeof(unsigned));
-               offset += nv04mt->level[l].pitch * pt->height[l];
+               /* XXX guess was obviously missing */
+               nv04mt->level[l].image_offset[0] = offset;
+               offset += nv04mt->level[l].pitch * u_minify(pt->height0, l);
        }
 
        nv04mt->total_size = offset;
@@ -63,7 +55,7 @@ nv04_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
                FREE(mt);
                return NULL;
        }
-       
+       mt->bo = nouveau_bo(mt->buffer);
        return &mt->base;
 }
 
@@ -75,7 +67,7 @@ nv04_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
 
        /* Only supports 2D, non-mipmapped textures for the moment */
        if (pt->target != PIPE_TEXTURE_2D || pt->last_level != 0 ||
-           pt->depth[0] != 1)
+           pt->depth0 != 1)
                return NULL;
 
        mt = CALLOC_STRUCT(nv04_miptree);
@@ -89,6 +81,7 @@ nv04_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
        mt->level[0].image_offset = CALLOC(1, sizeof(unsigned));
 
        pipe_buffer_reference(&mt->buffer, pb);
+       mt->bo = nouveau_bo(mt->buffer);
        return &mt->base;
 }
 
@@ -120,8 +113,8 @@ nv04_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
                return NULL;
        pipe_texture_reference(&ns->base.texture, pt);
        ns->base.format = pt->format;
-       ns->base.width = pt->width[level];
-       ns->base.height = pt->height[level];
+       ns->base.width = u_minify(pt->width0, level);
+       ns->base.height = u_minify(pt->height0, level);
        ns->base.usage = flags;
        pipe_reference_init(&ns->base.reference, 1);
        ns->base.face = face;
@@ -129,7 +122,7 @@ nv04_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
        ns->base.zslice = zslice;
        ns->pitch = nv04mt->level[level].pitch;
 
-       ns->base.offset = nv04mt->level[level].image_offset;
+       ns->base.offset = nv04mt->level[level].image_offset[0];
 
        return &ns->base;
 }
index f6458232ae58833c1287fa429b00d4368a5224ea..0b795ea24301b35d256b98d62fb4aa96eb642667 100644 (file)
@@ -93,33 +93,45 @@ nv04_vbuf_render_set_primitive( struct vbuf_render *render,
 
 static INLINE void nv04_2triangles(struct nv04_context* nv04, unsigned char* buffer, ushort v0, ushort v1, ushort v2, ushort v3, ushort v4, ushort v5)
 {
-       BEGIN_RING(fahrenheit,NV04_DX5_TEXTURED_TRIANGLE_TLVERTEX_SX(0xA),49);
-       OUT_RINGp(buffer + VERTEX_SIZE * v0,8);
-       OUT_RINGp(buffer + VERTEX_SIZE * v1,8);
-       OUT_RINGp(buffer + VERTEX_SIZE * v2,8);
-       OUT_RINGp(buffer + VERTEX_SIZE * v3,8);
-       OUT_RINGp(buffer + VERTEX_SIZE * v4,8);
-       OUT_RINGp(buffer + VERTEX_SIZE * v5,8);
-       OUT_RING(0xFEDCBA);
+       struct nv04_screen *screen = nv04->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *fahrenheit = screen->fahrenheit;
+
+       BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_TLVERTEX_SX(0xA), 49);
+       OUT_RINGp(chan, buffer + VERTEX_SIZE * v0,8);
+       OUT_RINGp(chan, buffer + VERTEX_SIZE * v1,8);
+       OUT_RINGp(chan, buffer + VERTEX_SIZE * v2,8);
+       OUT_RINGp(chan, buffer + VERTEX_SIZE * v3,8);
+       OUT_RINGp(chan, buffer + VERTEX_SIZE * v4,8);
+       OUT_RINGp(chan, buffer + VERTEX_SIZE * v5,8);
+       OUT_RING(chan, 0xFEDCBA);
 }
 
 static INLINE void nv04_1triangle(struct nv04_context* nv04, unsigned char* buffer, ushort v0, ushort v1, ushort v2)
 {
-       BEGIN_RING(fahrenheit,NV04_DX5_TEXTURED_TRIANGLE_TLVERTEX_SX(0xD),25);
-       OUT_RINGp(buffer + VERTEX_SIZE * v0,8);
-       OUT_RINGp(buffer + VERTEX_SIZE * v1,8);
-       OUT_RINGp(buffer + VERTEX_SIZE * v2,8);
-       OUT_RING(0xFED);
+       struct nv04_screen *screen = nv04->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *fahrenheit = screen->fahrenheit;
+
+       BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_TLVERTEX_SX(0xD), 25);
+       OUT_RINGp(chan, buffer + VERTEX_SIZE * v0,8);
+       OUT_RINGp(chan, buffer + VERTEX_SIZE * v1,8);
+       OUT_RINGp(chan, buffer + VERTEX_SIZE * v2,8);
+       OUT_RING(chan, 0xFED);
 }
 
 static INLINE void nv04_1quad(struct nv04_context* nv04, unsigned char* buffer, ushort v0, ushort v1, ushort v2, ushort v3)
 {
-       BEGIN_RING(fahrenheit,NV04_DX5_TEXTURED_TRIANGLE_TLVERTEX_SX(0xC),33);
-       OUT_RINGp(buffer + VERTEX_SIZE * v0,8);
-       OUT_RINGp(buffer + VERTEX_SIZE * v1,8);
-       OUT_RINGp(buffer + VERTEX_SIZE * v2,8);
-       OUT_RINGp(buffer + VERTEX_SIZE * v3,8);
-       OUT_RING(0xFECEDC);
+       struct nv04_screen *screen = nv04->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *fahrenheit = screen->fahrenheit;
+
+       BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_TLVERTEX_SX(0xC), 33);
+       OUT_RINGp(chan, buffer + VERTEX_SIZE * v0,8);
+       OUT_RINGp(chan, buffer + VERTEX_SIZE * v1,8);
+       OUT_RINGp(chan, buffer + VERTEX_SIZE * v2,8);
+       OUT_RINGp(chan, buffer + VERTEX_SIZE * v3,8);
+       OUT_RING(chan, 0xFECEDC);
 }
 
 static void nv04_vbuf_render_triangles_elts(struct nv04_vbuf_render * render, const ushort * indices, uint nr_indices)
@@ -156,7 +168,10 @@ static void nv04_vbuf_render_tri_strip_elts(struct nv04_vbuf_render* render, con
 {
        const uint32_t striptbl[]={0x321210,0x543432,0x765654,0x987876,0xBA9A98,0xDCBCBA,0xFEDEDC};
        unsigned char* buffer = render->buffer;
-       struct nv04_context* nv04 = render->nv04;
+       struct nv04_context *nv04 = render->nv04;
+       struct nv04_screen *screen = nv04->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *fahrenheit = screen->fahrenheit;
        int i,j;
 
        for(i = 0; i<nr_indices; i+=14) 
@@ -166,15 +181,15 @@ static void nv04_vbuf_render_tri_strip_elts(struct nv04_vbuf_render* render, con
                if (numvert<3)
                        break;
 
-               BEGIN_RING( fahrenheit, NV04_DX5_TEXTURED_TRIANGLE_TLVERTEX_SX(0x0), numvert*8 );
+               BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_TLVERTEX_SX(0x0), numvert*8);
                for(j = 0; j<numvert; j++)
-                       OUT_RINGp( buffer + VERTEX_SIZE * indices [i+j], 8 );
+                       OUT_RINGp(chan, buffer + VERTEX_SIZE * indices [i+j], 8 );
 
-               BEGIN_RING_NI( fahrenheit, NV04_DX5_TEXTURED_TRIANGLE_TLVERTEX_DRAWPRIMITIVE(0), (numtri+1)/2 );
+               BEGIN_RING_NI(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_DRAWPRIMITIVE(0), (numtri+1)/2 );
                for(j = 0; j<numtri/2; j++ )
-                       OUT_RING(striptbl[j]);
+                       OUT_RING(chan, striptbl[j]);
                if (numtri%2)
-                       OUT_RING(striptbl[numtri/2]&0xFFF);
+                       OUT_RING(chan, striptbl[numtri/2]&0xFFF);
        }
 }
 
@@ -182,11 +197,14 @@ static void nv04_vbuf_render_tri_fan_elts(struct nv04_vbuf_render* render, const
 {
        const uint32_t fantbl[]={0x320210,0x540430,0x760650,0x980870,0xBA0A90,0xDC0CB0,0xFE0ED0};
        unsigned char* buffer = render->buffer;
-       struct nv04_context* nv04 = render->nv04;
+       struct nv04_context *nv04 = render->nv04;
+       struct nv04_screen *screen = nv04->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *fahrenheit = screen->fahrenheit;
        int i,j;
 
-       BEGIN_RING(fahrenheit, NV04_DX5_TEXTURED_TRIANGLE_TLVERTEX_SX(0x0), 8);
-       OUT_RINGp(buffer + VERTEX_SIZE * indices[0], 8);
+       BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_TLVERTEX_SX(0x0), 8);
+       OUT_RINGp(chan, buffer + VERTEX_SIZE * indices[0], 8);
 
        for(i = 1; i<nr_indices; i+=14)
        {
@@ -195,16 +213,16 @@ static void nv04_vbuf_render_tri_fan_elts(struct nv04_vbuf_render* render, const
                if (numvert < 3)
                        break;
 
-               BEGIN_RING(fahrenheit, NV04_DX5_TEXTURED_TRIANGLE_TLVERTEX_SX(0x1), numvert*8);
+               BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_TLVERTEX_SX(0x1), numvert*8);
 
                for(j=0;j<numvert;j++)
-                       OUT_RINGp( buffer + VERTEX_SIZE * indices[ i+j ], 8 );
+                       OUT_RINGp(chan, buffer + VERTEX_SIZE * indices[ i+j ], 8 );
 
-               BEGIN_RING_NI(fahrenheit, NV04_DX5_TEXTURED_TRIANGLE_TLVERTEX_DRAWPRIMITIVE(0), (numtri+1)/2);
+               BEGIN_RING_NI(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_DRAWPRIMITIVE(0), (numtri+1)/2);
                for(j = 0; j<numtri/2; j++)
-                       OUT_RING(fantbl[j]);
+                       OUT_RING(chan, fantbl[j]);
                if (numtri%2)
-                       OUT_RING(fantbl[numtri/2]&0xFFF);
+                       OUT_RING(chan, fantbl[numtri/2]&0xFFF);
        }
 }
 
index 170ce3eb7e54846b7c6f8ac856e192b909f490ee..7c5b6e8229ae1d8f3ad4b5bf5cdf1f64acc47726 100644 (file)
@@ -119,6 +119,8 @@ nv04_screen_destroy(struct pipe_screen *pscreen)
        nouveau_grobj_free(&screen->fahrenheit);
        nv04_surface_2d_takedown(&screen->eng2d);
 
+       nouveau_screen_fini(&screen->base);
+
        FREE(pscreen);
 }
 
@@ -163,10 +165,10 @@ nv04_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
                fahrenheit_class = 0;
                sub3d_class = 0;
        } else if (dev->chipset >= 0x10) {
-               fahrenheit_class = NV10_DX5_TEXTURED_TRIANGLE;
+               fahrenheit_class = NV10_TEXTURED_TRIANGLE;
                sub3d_class = NV10_CONTEXT_SURFACES_3D;
        } else {
-               fahrenheit_class=NV04_DX5_TEXTURED_TRIANGLE;
+               fahrenheit_class=NV04_TEXTURED_TRIANGLE;
                sub3d_class = NV04_CONTEXT_SURFACES_3D;
        }
 
index d356ebd8b3688217740b49d490b644342f3253e3..e3dc4c5bf447c095663c64a22987747a88a1b749 100644 (file)
@@ -50,28 +50,28 @@ wrap_mode(unsigned wrap) {
 
        switch (wrap) {
        case PIPE_TEX_WRAP_REPEAT:
-               ret = NV04_DX5_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_REPEAT;
+               ret = NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_REPEAT;
                break;
        case PIPE_TEX_WRAP_MIRROR_REPEAT:
-               ret = NV04_DX5_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_MIRRORED_REPEAT;
+               ret = NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_MIRRORED_REPEAT;
                break;
        case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
-               ret = NV04_DX5_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_CLAMP_TO_EDGE;
+               ret = NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_CLAMP_TO_EDGE;
                break;
        case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
-               ret = NV04_DX5_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_CLAMP_TO_BORDER;
+               ret = NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_CLAMP_TO_BORDER;
                break;
        case PIPE_TEX_WRAP_CLAMP:
-               ret = NV04_DX5_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_CLAMP;
+               ret = NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_CLAMP;
                break;
        case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
        case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
        case PIPE_TEX_WRAP_MIRROR_CLAMP:
        default:
                NOUVEAU_ERR("unknown wrap mode: %d\n", wrap);
-               ret = NV04_DX5_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_CLAMP;
+               ret = NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_CLAMP;
        }
-       return ret >> NV04_DX5_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_SHIFT;
+       return ret >> NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_SHIFT;
 }
 
 static void *
@@ -84,20 +84,20 @@ nv04_sampler_state_create(struct pipe_context *pipe,
 
        ss = MALLOC(sizeof(struct nv04_sampler_state));
 
-       ss->format = ((wrap_mode(cso->wrap_s) << NV04_DX5_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_SHIFT) |
-                   (wrap_mode(cso->wrap_t) << NV04_DX5_TEXTURED_TRIANGLE_FORMAT_ADDRESSV_SHIFT));
+       ss->format = ((wrap_mode(cso->wrap_s) << NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_SHIFT) |
+                   (wrap_mode(cso->wrap_t) << NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSV_SHIFT));
 
        if (cso->max_anisotropy > 1.0) {
-               filter |= NV04_DX5_TEXTURED_TRIANGLE_FILTER_ANISOTROPIC_MINIFY_ENABLE | NV04_DX5_TEXTURED_TRIANGLE_FILTER_ANISOTROPIC_MAGNIFY_ENABLE;
+               filter |= NV04_TEXTURED_TRIANGLE_FILTER_ANISOTROPIC_MINIFY_ENABLE | NV04_TEXTURED_TRIANGLE_FILTER_ANISOTROPIC_MAGNIFY_ENABLE;
        }
 
        switch (cso->mag_img_filter) {
        case PIPE_TEX_FILTER_LINEAR:
-               filter |= NV04_DX5_TEXTURED_TRIANGLE_FILTER_MAGNIFY_LINEAR;
+               filter |= NV04_TEXTURED_TRIANGLE_FILTER_MAGNIFY_LINEAR;
                break;
        case PIPE_TEX_FILTER_NEAREST:
        default:
-               filter |= NV04_DX5_TEXTURED_TRIANGLE_FILTER_MAGNIFY_NEAREST;
+               filter |= NV04_TEXTURED_TRIANGLE_FILTER_MAGNIFY_NEAREST;
                break;
        }
 
@@ -105,14 +105,14 @@ nv04_sampler_state_create(struct pipe_context *pipe,
        case PIPE_TEX_FILTER_LINEAR:
                switch (cso->min_mip_filter) {
                case PIPE_TEX_MIPFILTER_NEAREST:
-                       filter |= NV04_DX5_TEXTURED_TRIANGLE_FILTER_MINIFY_LINEAR_MIPMAP_NEAREST;
+                       filter |= NV04_TEXTURED_TRIANGLE_FILTER_MINIFY_LINEAR_MIPMAP_NEAREST;
                        break;
                case PIPE_TEX_MIPFILTER_LINEAR:
-                       filter |= NV04_DX5_TEXTURED_TRIANGLE_FILTER_MINIFY_LINEAR_MIPMAP_LINEAR;
+                       filter |= NV04_TEXTURED_TRIANGLE_FILTER_MINIFY_LINEAR_MIPMAP_LINEAR;
                        break;
                case PIPE_TEX_MIPFILTER_NONE:
                default:
-                       filter |= NV04_DX5_TEXTURED_TRIANGLE_FILTER_MINIFY_LINEAR;
+                       filter |= NV04_TEXTURED_TRIANGLE_FILTER_MINIFY_LINEAR;
                        break;
                }
                break;
@@ -120,14 +120,14 @@ nv04_sampler_state_create(struct pipe_context *pipe,
        default:
                switch (cso->min_mip_filter) {
                case PIPE_TEX_MIPFILTER_NEAREST:
-                       filter |= NV04_DX5_TEXTURED_TRIANGLE_FILTER_MINIFY_NEAREST_MIPMAP_NEAREST;
+                       filter |= NV04_TEXTURED_TRIANGLE_FILTER_MINIFY_NEAREST_MIPMAP_NEAREST;
                break;
                case PIPE_TEX_MIPFILTER_LINEAR:
-                       filter |= NV04_DX5_TEXTURED_TRIANGLE_FILTER_MINIFY_NEAREST_MIPMAP_LINEAR;
+                       filter |= NV04_TEXTURED_TRIANGLE_FILTER_MINIFY_NEAREST_MIPMAP_LINEAR;
                        break;
                case PIPE_TEX_MIPFILTER_NONE:
                default:
-                       filter |= NV04_DX5_TEXTURED_TRIANGLE_FILTER_MINIFY_NEAREST;
+                       filter |= NV04_TEXTURED_TRIANGLE_FILTER_MINIFY_NEAREST;
                        break;
                }
                break;
@@ -181,7 +181,7 @@ nv04_rasterizer_state_create(struct pipe_context *pipe,
         */
        rs = MALLOC(sizeof(struct nv04_rasterizer_state));
 
-       rs->blend = cso->flatshade ? NV04_DX5_TEXTURED_TRIANGLE_BLEND_SHADE_MODE_FLAT : NV04_DX5_TEXTURED_TRIANGLE_BLEND_SHADE_MODE_GOURAUD;
+       rs->blend = cso->flatshade ? NV04_TEXTURED_TRIANGLE_BLEND_SHADE_MODE_FLAT : NV04_TEXTURED_TRIANGLE_BLEND_SHADE_MODE_GOURAUD;
 
        return (void *)rs;
 }
@@ -229,16 +229,16 @@ nv04_depth_stencil_alpha_state_create(struct pipe_context *pipe,
        hw = MALLOC(sizeof(struct nv04_depth_stencil_alpha_state));
 
        hw->control = float_to_ubyte(cso->alpha.ref_value);
-       hw->control |= ( nv04_compare_func(cso->alpha.func) << NV04_DX5_TEXTURED_TRIANGLE_CONTROL_ALPHA_FUNC_SHIFT );
-       hw->control |= cso->alpha.enabled ? NV04_DX5_TEXTURED_TRIANGLE_CONTROL_ALPHA_TEST_ENABLE : 0;
-       hw->control |= NV04_DX5_TEXTURED_TRIANGLE_CONTROL_ORIGIN;
-       hw->control |= cso->depth.enabled ? (1 << NV04_DX5_TEXTURED_TRIANGLE_CONTROL_Z_ENABLE_SHIFT) : 0;
-       hw->control |= ( nv04_compare_func(cso->depth.func)<< NV04_DX5_TEXTURED_TRIANGLE_CONTROL_Z_FUNC_SHIFT );
-       hw->control |= 1 << NV04_DX5_TEXTURED_TRIANGLE_CONTROL_CULL_MODE_SHIFT; // no culling, handled by the draw module
-       hw->control |= NV04_DX5_TEXTURED_TRIANGLE_CONTROL_DITHER_ENABLE;
-       hw->control |= NV04_DX5_TEXTURED_TRIANGLE_CONTROL_Z_PERSPECTIVE_ENABLE;
-       hw->control |= cso->depth.writemask ? (1 << NV04_DX5_TEXTURED_TRIANGLE_CONTROL_Z_WRITE_ENABLE_SHIFT) : 0;
-       hw->control |= 1 << NV04_DX5_TEXTURED_TRIANGLE_CONTROL_Z_FORMAT_SHIFT; // integer zbuffer format
+       hw->control |= ( nv04_compare_func(cso->alpha.func) << NV04_TEXTURED_TRIANGLE_CONTROL_ALPHA_FUNC_SHIFT );
+       hw->control |= cso->alpha.enabled ? NV04_TEXTURED_TRIANGLE_CONTROL_ALPHA_ENABLE : 0;
+       hw->control |= NV04_TEXTURED_TRIANGLE_CONTROL_ORIGIN;
+       hw->control |= cso->depth.enabled ? NV04_TEXTURED_TRIANGLE_CONTROL_Z_ENABLE : 0;
+       hw->control |= ( nv04_compare_func(cso->depth.func)<< NV04_TEXTURED_TRIANGLE_CONTROL_Z_FUNC_SHIFT );
+       hw->control |= 1 << NV04_TEXTURED_TRIANGLE_CONTROL_CULL_MODE_SHIFT; // no culling, handled by the draw module
+       hw->control |= NV04_TEXTURED_TRIANGLE_CONTROL_DITHER_ENABLE;
+       hw->control |= NV04_TEXTURED_TRIANGLE_CONTROL_Z_PERSPECTIVE_ENABLE;
+       hw->control |= cso->depth.writemask ? NV04_TEXTURED_TRIANGLE_CONTROL_Z_WRITE : 0;
+       hw->control |= 1 << NV04_TEXTURED_TRIANGLE_CONTROL_Z_FORMAT_SHIFT; // integer zbuffer format
 
        return (void *)hw;
 }
@@ -377,7 +377,7 @@ nv04_set_scissor_state(struct pipe_context *pipe,
 /*     struct nv04_context *nv04 = nv04_context(pipe);
 
        // XXX
-       BEGIN_RING(fahrenheit, NV04_DX5_TEXTURED_TRIANGLE_SCISSOR_HORIZ, 2);
+       BEGIN_RING(fahrenheit, NV04_TEXTURED_TRIANGLE_SCISSOR_HORIZ, 2);
        OUT_RING  (((s->maxx - s->minx) << 16) | s->minx);
        OUT_RING  (((s->maxy - s->miny) << 16) | s->miny);*/
 }
@@ -425,9 +425,9 @@ nv04_init_state_functions(struct nv04_context *nv04)
        nv04->pipe.delete_blend_state = nv04_blend_state_delete;
 
        nv04->pipe.create_sampler_state = nv04_sampler_state_create;
-       nv04->pipe.bind_sampler_states = nv04_sampler_state_bind;
+       nv04->pipe.bind_fragment_sampler_states = nv04_sampler_state_bind;
        nv04->pipe.delete_sampler_state = nv04_sampler_state_delete;
-       nv04->pipe.set_sampler_textures = nv04_set_sampler_texture;
+       nv04->pipe.set_fragment_sampler_textures = nv04_set_sampler_texture;
 
        nv04->pipe.create_rasterizer_state = nv04_rasterizer_state_create;
        nv04->pipe.bind_rasterizer_state = nv04_rasterizer_state_bind;
index 399f750dbe7caf4de1d33036b2704aa297fc81d7..81d1d2ebaa94a034c9dba060527403b765a29e22 100644 (file)
@@ -31,6 +31,7 @@ struct nv04_rasterizer_state {
 
 struct nv04_miptree {
        struct pipe_texture base;
+       struct nouveau_bo *bo;
 
        struct pipe_buffer *buffer;
        uint total_size;
index eb2c1c57c67dbad4b196d2618c2b8bc68df66733..b8d6dc560f053efffac6f10a390c135ee9df38d3 100644 (file)
@@ -57,13 +57,19 @@ static uint32_t nv04_blend_func(uint32_t f)
 static void nv04_emit_control(struct nv04_context* nv04)
 {
        uint32_t control = nv04->dsa->control;
+       struct nv04_screen *screen = nv04->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *fahrenheit = screen->fahrenheit;
 
-       BEGIN_RING(fahrenheit, NV04_DX5_TEXTURED_TRIANGLE_CONTROL, 1);
-       OUT_RING(control);
+       BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_CONTROL, 1);
+       OUT_RING(chan, control);
 }
 
 static void nv04_emit_blend(struct nv04_context* nv04)
 {
+       struct nv04_screen *screen = nv04->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *fahrenheit = screen->fahrenheit;
        uint32_t blend;
 
        blend=0x4; // texture MODULATE_ALPHA
@@ -75,19 +81,23 @@ static void nv04_emit_blend(struct nv04_context* nv04)
        blend|=(nv04_blend_func(nv04->blend->b_src)<<24);
        blend|=(nv04_blend_func(nv04->blend->b_dst)<<28);
 
-       BEGIN_RING(fahrenheit, NV04_DX5_TEXTURED_TRIANGLE_BLEND, 1);
-       OUT_RING(blend);
+       BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_BLEND, 1);
+       OUT_RING(chan, blend);
 }
 
 static void nv04_emit_sampler(struct nv04_context *nv04, int unit)
 {
        struct nv04_miptree *nv04mt = nv04->tex_miptree[unit];
        struct pipe_texture *pt = &nv04mt->base;
-
-       BEGIN_RING(fahrenheit, NV04_DX5_TEXTURED_TRIANGLE_OFFSET, 3);
-       OUT_RELOCl(nv04mt->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD);
-       OUT_RELOCd(nv04mt->buffer, (nv04->fragtex.format | nv04->sampler[unit]->format), NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_OR | NOUVEAU_BO_RD, 1/*VRAM*/,2/*TT*/);
-       OUT_RING(nv04->sampler[unit]->filter);
+       struct nv04_screen *screen = nv04->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *fahrenheit = screen->fahrenheit;
+       struct nouveau_bo *bo = nouveau_bo(nv04mt->buffer);
+
+       BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_OFFSET, 3);
+       OUT_RELOCl(chan, bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD);
+       OUT_RELOCd(chan, bo, (nv04->fragtex.format | nv04->sampler[unit]->format), NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_OR | NOUVEAU_BO_RD, 1/*VRAM*/,2/*TT*/);
+       OUT_RING(chan, nv04->sampler[unit]->filter);
 }
 
 static void nv04_state_emit_framebuffer(struct nv04_context* nv04)
@@ -97,6 +107,10 @@ static void nv04_state_emit_framebuffer(struct nv04_context* nv04)
        uint32_t rt_format, w, h;
        int colour_format = 0, zeta_format = 0;
        struct nv04_miptree *nv04mt = 0;
+       struct nv04_screen *screen = nv04->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *context_surfaces_3d = screen->context_surfaces_3d;
+       struct nouveau_bo *bo;
 
        w = fb->cbufs[0]->width;
        h = fb->cbufs[0]->height;
@@ -128,24 +142,29 @@ static void nv04_state_emit_framebuffer(struct nv04_context* nv04)
                assert(0);
        }
 
-       BEGIN_RING(context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_FORMAT, 1);
-       OUT_RING(rt_format);
+       BEGIN_RING(chan, context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_FORMAT, 1);
+       OUT_RING(chan, rt_format);
 
        nv04mt = (struct nv04_miptree *)rt->base.texture;
+       bo = nouveau_bo(nv04mt->buffer);
        /* FIXME pitches have to be aligned ! */
-       BEGIN_RING(context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_PITCH, 2);
-       OUT_RING(rt->pitch|(zeta->pitch<<16));
-       OUT_RELOCl(nv04mt->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+       BEGIN_RING(chan, context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_PITCH, 2);
+       OUT_RING(chan, rt->pitch|(zeta->pitch<<16));
+       OUT_RELOCl(chan, bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
        if (fb->zsbuf) {
                nv04mt = (struct nv04_miptree *)zeta->base.texture;
-               BEGIN_RING(context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_OFFSET_ZETA, 1);
-               OUT_RELOCl(nv04mt->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+               BEGIN_RING(chan, context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_OFFSET_ZETA, 1);
+               OUT_RELOCl(chan, bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
        }
 }
 
 void
 nv04_emit_hw_state(struct nv04_context *nv04)
 {
+       struct nv04_screen *screen = nv04->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *fahrenheit = screen->fahrenheit;
+       struct nouveau_grobj *context_surfaces_3d = screen->context_surfaces_3d;
        int i;
 
        if (nv04->dirty & NV04_NEW_VERTPROG) {
@@ -163,8 +182,8 @@ nv04_emit_hw_state(struct nv04_context *nv04)
        if (nv04->dirty & NV04_NEW_CONTROL) {
                nv04->dirty &= ~NV04_NEW_CONTROL;
 
-               BEGIN_RING(fahrenheit, NV04_DX5_TEXTURED_TRIANGLE_CONTROL, 1);
-               OUT_RING(nv04->dsa->control);
+               BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_CONTROL, 1);
+               OUT_RING(chan, nv04->dsa->control);
        }
 
        if (nv04->dirty & NV04_NEW_BLEND) {
@@ -205,12 +224,12 @@ nv04_emit_hw_state(struct nv04_context *nv04)
        unsigned rt_pitch = ((struct nv04_surface *)nv04->rt)->pitch;
        unsigned zeta_pitch = ((struct nv04_surface *)nv04->zeta)->pitch;
 
-       BEGIN_RING(context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_PITCH, 2);
-       OUT_RING(rt_pitch|(zeta_pitch<<16));
-       OUT_RELOCl(nv04->rt, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+       BEGIN_RING(chan, context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_PITCH, 2);
+       OUT_RING(chan, rt_pitch|(zeta_pitch<<16));
+       OUT_RELOCl(chan, nouveau_bo(nv04->rt), 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
        if (nv04->zeta) {
-               BEGIN_RING(context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_OFFSET_ZETA, 1);
-               OUT_RELOCl(nv04->zeta, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+               BEGIN_RING(chan, context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_OFFSET_ZETA, 1);
+               OUT_RELOCl(chan, nouveau_bo(nv04->zeta), 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
        }
 
        /* Texture images */
@@ -218,9 +237,10 @@ nv04_emit_hw_state(struct nv04_context *nv04)
                if (!(nv04->fp_samplers & (1 << i)))
                        continue;
                struct nv04_miptree *nv04mt = nv04->tex_miptree[i];
-               BEGIN_RING(fahrenheit, NV04_DX5_TEXTURED_TRIANGLE_OFFSET, 2);
-               OUT_RELOCl(nv04mt->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD);
-               OUT_RELOCd(nv04mt->buffer, (nv04->fragtex.format | nv04->sampler[i]->format), NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_OR | NOUVEAU_BO_RD, 1/*VRAM*/,2/*TT*/);
+               struct nouveau_bo *bo = nouveau_bo(nv04mt->buffer);
+               BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_OFFSET, 2);
+               OUT_RELOCl(chan, bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD);
+               OUT_RELOCd(chan, bo, (nv04->fragtex.format | nv04->sampler[i]->format), NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_OR | NOUVEAU_BO_RD, 1/*VRAM*/,2/*TT*/);
        }
 }
 
index b2ab50ee21f90d4327f2e409bd87790fa4fba04e..b24a9cee5aec64c963707d7d9586f068e19d3a00 100644 (file)
@@ -1,5 +1,6 @@
 #include "pipe/p_context.h"
 #include "pipe/p_format.h"
+#include "util/u_format.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
 
@@ -13,10 +14,13 @@ nv04_surface_format(enum pipe_format format)
 {
        switch (format) {
        case PIPE_FORMAT_A8_UNORM:
+       case PIPE_FORMAT_L8_UNORM:
+       case PIPE_FORMAT_I8_UNORM:
                return NV04_CONTEXT_SURFACES_2D_FORMAT_Y8;
        case PIPE_FORMAT_R16_SNORM:
        case PIPE_FORMAT_R5G6B5_UNORM:
        case PIPE_FORMAT_Z16_UNORM:
+       case PIPE_FORMAT_A8L8_UNORM:
                return NV04_CONTEXT_SURFACES_2D_FORMAT_R5G6B5;
        case PIPE_FORMAT_X8R8G8B8_UNORM:
        case PIPE_FORMAT_A8R8G8B8_UNORM:
@@ -36,8 +40,10 @@ nv04_rect_format(enum pipe_format format)
        case PIPE_FORMAT_A8_UNORM:
                return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A8R8G8B8;
        case PIPE_FORMAT_R5G6B5_UNORM:
+       case PIPE_FORMAT_A8L8_UNORM:
        case PIPE_FORMAT_Z16_UNORM:
                return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A16R5G6B5;
+       case PIPE_FORMAT_X8R8G8B8_UNORM:
        case PIPE_FORMAT_A8R8G8B8_UNORM:
        case PIPE_FORMAT_Z24S8_UNORM:
        case PIPE_FORMAT_Z24X8_UNORM:
@@ -51,6 +57,10 @@ static INLINE int
 nv04_scaled_image_format(enum pipe_format format)
 {
        switch (format) {
+       case PIPE_FORMAT_A8_UNORM:
+       case PIPE_FORMAT_L8_UNORM:
+       case PIPE_FORMAT_I8_UNORM:
+               return NV04_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_Y8;
        case PIPE_FORMAT_A1R5G5B5_UNORM:
                return NV04_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_A1R5G5B5;
        case PIPE_FORMAT_A8R8G8B8_UNORM:
@@ -59,6 +69,7 @@ nv04_scaled_image_format(enum pipe_format format)
                return NV04_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_X8R8G8B8;
        case PIPE_FORMAT_R5G6B5_UNORM:
        case PIPE_FORMAT_R16_SNORM:
+       case PIPE_FORMAT_A8L8_UNORM:
                return NV04_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_R5G6B5;
        default:
                return -1;
@@ -66,7 +77,7 @@ nv04_scaled_image_format(enum pipe_format format)
 }
 
 static INLINE unsigned
-nv04_swizzle_bits(unsigned x, unsigned y)
+nv04_swizzle_bits_square(unsigned x, unsigned y)
 {
        unsigned u = (x & 0x001) << 0 |
                     (x & 0x002) << 1 |
@@ -96,6 +107,15 @@ nv04_swizzle_bits(unsigned x, unsigned y)
        return v | u;
 }
 
+/* rectangular swizzled textures are linear concatenations of swizzled square tiles */
+static INLINE unsigned
+nv04_swizzle_bits(unsigned x, unsigned y, unsigned w, unsigned h)
+{
+       unsigned s = MIN2(w, h);
+       unsigned m = s - 1;
+       return (((x | y) & ~m) * s) | nv04_swizzle_bits_square(x & m, y & m);
+}
+
 static int
 nv04_surface_copy_swizzle(struct nv04_surface_2d *ctx,
                          struct pipe_surface *dst, int dx, int dy,
@@ -123,6 +143,9 @@ nv04_surface_copy_swizzle(struct nv04_surface_2d *ctx,
        assert(sub_w == w || util_is_pot(sub_w));
        assert(sub_h == h || util_is_pot(sub_h));
 
+       MARK_RING (chan, 8 + ((w+sub_w)/sub_w)*((h+sub_h)/sub_h)*17, 2 +
+                        ((w+sub_w)/sub_w)*((h+sub_h)/sub_h)*2);
+
        BEGIN_RING(chan, swzsurf, NV04_SWIZZLED_SURFACE_DMA_IMAGE, 1);
        OUT_RELOCo(chan, dst_bo,
                         NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
@@ -131,7 +154,7 @@ nv04_surface_copy_swizzle(struct nv04_surface_2d *ctx,
        OUT_RING  (chan, nv04_surface_format(dst->format) |
                         log2i(dst->width) << NV04_SWIZZLED_SURFACE_FORMAT_BASE_SIZE_U_SHIFT |
                         log2i(dst->height) << NV04_SWIZZLED_SURFACE_FORMAT_BASE_SIZE_V_SHIFT);
+
        BEGIN_RING(chan, sifm, NV04_SCALED_IMAGE_FROM_MEMORY_DMA_IMAGE, 1);
        OUT_RELOCo(chan, src_bo,
                         NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
@@ -144,20 +167,19 @@ nv04_surface_copy_swizzle(struct nv04_surface_2d *ctx,
          for (x = 0; x < w; x += sub_w) {
            sub_w = MIN2(sub_w, w - x);
 
-           /* Must be 64-byte aligned */
-           assert(!((dst->offset + nv04_swizzle_bits(dx+x, dy+y) * dst->texture->block.size) & 63));
+           assert(!(dst->offset & 63));
 
            BEGIN_RING(chan, swzsurf, NV04_SWIZZLED_SURFACE_OFFSET, 1);
-           OUT_RELOCl(chan, dst_bo, dst->offset + nv04_swizzle_bits(dx+x, dy+y) * dst->texture->block.size,
+           OUT_RELOCl(chan, dst_bo, dst->offset,
                              NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
 
            BEGIN_RING(chan, sifm, NV04_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION, 9);
            OUT_RING  (chan, NV04_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION_TRUNCATE);
            OUT_RING  (chan, nv04_scaled_image_format(src->format));
            OUT_RING  (chan, NV04_SCALED_IMAGE_FROM_MEMORY_OPERATION_SRCCOPY);
-           OUT_RING  (chan, 0);
+           OUT_RING  (chan, (x + dx) | ((y + dy) << NV04_SCALED_IMAGE_FROM_MEMORY_CLIP_POINT_Y_SHIFT));
            OUT_RING  (chan, sub_h << NV04_SCALED_IMAGE_FROM_MEMORY_CLIP_SIZE_H_SHIFT | sub_w);
-           OUT_RING  (chan, 0);
+           OUT_RING  (chan, (x + dx) | ((y + dy) << NV04_SCALED_IMAGE_FROM_MEMORY_OUT_POINT_Y_SHIFT));
            OUT_RING  (chan, sub_h << NV04_SCALED_IMAGE_FROM_MEMORY_OUT_SIZE_H_SHIFT | sub_w);
            OUT_RING  (chan, 1 << 20);
            OUT_RING  (chan, 1 << 20);
@@ -167,7 +189,7 @@ nv04_surface_copy_swizzle(struct nv04_surface_2d *ctx,
            OUT_RING  (chan, src_pitch |
                             NV04_SCALED_IMAGE_FROM_MEMORY_FORMAT_ORIGIN_CENTER |
                             NV04_SCALED_IMAGE_FROM_MEMORY_FORMAT_FILTER_POINT_SAMPLE);
-           OUT_RELOCl(chan, src_bo, src->offset + (sy+y) * src_pitch + (sx+x) * src->texture->block.size,
+           OUT_RELOCl(chan, src_bo, src->offset + (sy+y) * src_pitch + (sx+x) * util_format_get_blocksize(src->texture->format),
                              NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
            OUT_RING  (chan, 0);
          }
@@ -188,11 +210,11 @@ nv04_surface_copy_m2mf(struct nv04_surface_2d *ctx,
        unsigned src_pitch = ((struct nv04_surface *)src)->pitch;
        unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch;
        unsigned dst_offset = dst->offset + dy * dst_pitch +
-                             dx * dst->texture->block.size;
+                             dx * util_format_get_blocksize(dst->texture->format);
        unsigned src_offset = src->offset + sy * src_pitch +
-                             sx * src->texture->block.size;
+                             sx * util_format_get_blocksize(src->texture->format);
 
-       WAIT_RING (chan, 3 + ((h / 2047) + 1) * 9);
+       MARK_RING (chan, 3 + ((h / 2047) + 1) * 9, 2 + ((h / 2047) + 1) * 2);
        BEGIN_RING(chan, m2mf, NV04_MEMORY_TO_MEMORY_FORMAT_DMA_BUFFER_IN, 2);
        OUT_RELOCo(chan, src_bo,
                   NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
@@ -209,7 +231,7 @@ nv04_surface_copy_m2mf(struct nv04_surface_2d *ctx,
                           NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_WR);
                OUT_RING  (chan, src_pitch);
                OUT_RING  (chan, dst_pitch);
-               OUT_RING  (chan, w * src->texture->block.size);
+               OUT_RING  (chan, w * util_format_get_blocksize(src->texture->format));
                OUT_RING  (chan, count);
                OUT_RING  (chan, 0x0101);
                OUT_RING  (chan, 0);
@@ -240,7 +262,7 @@ nv04_surface_copy_blit(struct nv04_surface_2d *ctx, struct pipe_surface *dst,
        if (format < 0)
                return 1;
 
-       WAIT_RING (chan, 12);
+       MARK_RING (chan, 12, 4);
        BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_DMA_IMAGE_SOURCE, 2);
        OUT_RELOCo(chan, src_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
        OUT_RELOCo(chan, dst_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
@@ -305,7 +327,7 @@ nv04_surface_fill(struct nv04_surface_2d *ctx, struct pipe_surface *dst,
        gdirect_format = nv04_rect_format(dst->format);
        assert(gdirect_format >= 0);
 
-       WAIT_RING (chan, 16);
+       MARK_RING (chan, 16, 4);
        BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_DMA_IMAGE_SOURCE, 2);
        OUT_RELOCo(chan, dst_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
        OUT_RELOCo(chan, dst_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
@@ -477,3 +499,49 @@ nv04_surface_2d_init(struct nouveau_screen *screen)
        ctx->fill = nv04_surface_fill;
        return ctx;
 }
+
+struct nv04_surface*
+nv04_surface_wrap_for_render(struct pipe_screen *pscreen, struct nv04_surface_2d* eng2d, struct nv04_surface* ns)
+{
+       int temp_flags;
+
+       // printf("creating temp, flags is %i!\n", flags);
+
+       if(ns->base.usage & PIPE_BUFFER_USAGE_DISCARD)
+       {
+               temp_flags = ns->base.usage | PIPE_BUFFER_USAGE_GPU_READ;
+               ns->base.usage = PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER | PIPE_BUFFER_USAGE_DISCARD;
+       }
+       else
+       {
+               temp_flags = ns->base.usage | PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE;
+               ns->base.usage = PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER | PIPE_BUFFER_USAGE_GPU_READ;
+       }
+
+       struct nv40_screen* screen = (struct nv40_screen*)pscreen;
+       ns->base.usage = PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE;
+
+       struct pipe_texture templ;
+       memset(&templ, 0, sizeof(templ));
+       templ.format = ns->base.texture->format;
+       templ.target = PIPE_TEXTURE_2D;
+       templ.width0 = ns->base.width;
+       templ.height0 = ns->base.height;
+       templ.depth0 = 1;
+       templ.last_level = 0;
+
+       // TODO: this is probably wrong and we should specifically handle multisampling somehow once it is implemented
+       templ.nr_samples = ns->base.texture->nr_samples;
+
+       templ.tex_usage = ns->base.texture->tex_usage | PIPE_TEXTURE_USAGE_RENDER_TARGET;
+
+       struct pipe_texture* temp_tex = pscreen->texture_create(pscreen, &templ);
+       struct nv04_surface* temp_ns = (struct nv04_surface*)pscreen->get_tex_surface(pscreen, temp_tex, 0, 0, 0, temp_flags);
+       temp_ns->backing = ns;
+
+       if(ns->base.usage & PIPE_BUFFER_USAGE_GPU_READ)
+               eng2d->copy(eng2d, &temp_ns->backing->base, 0, 0, &ns->base, 0, 0, ns->base.width, ns->base.height);
+
+       return temp_ns;
+}
+
index 02b3f56ba8b8c89a06f19e9488334803b5a08c92..ce696a11a39e44a9fda8425a082f2a0ecdab559d 100644 (file)
@@ -4,6 +4,7 @@
 struct nv04_surface {
        struct pipe_surface base;
        unsigned pitch;
+       struct nv04_surface* backing;
 };
 
 struct nv04_surface_2d {
@@ -30,4 +31,7 @@ nv04_surface_2d_init(struct nouveau_screen *screen);
 void
 nv04_surface_2d_takedown(struct nv04_surface_2d **);
 
+struct nv04_surface*
+nv04_surface_wrap_for_render(struct pipe_screen *pscreen, struct nv04_surface_2d* eng2d, struct nv04_surface* ns);
+
 #endif
index 6618660743d48388048912c1bb45d4014f37ced6..2dd2e146a8f30f22e6f0c7184de98b1791c8fcd6 100644 (file)
@@ -1,7 +1,9 @@
 #include <pipe/p_state.h>
 #include <pipe/p_defines.h>
 #include <pipe/p_inlines.h>
+#include <util/u_format.h>
 #include <util/u_memory.h>
+#include <util/u_math.h>
 #include <nouveau/nouveau_winsys.h>
 #include "nv04_context.h"
 #include "nv04_screen.h"
 struct nv04_transfer {
        struct pipe_transfer base;
        struct pipe_surface *surface;
-       bool direct;
+       boolean direct;
 };
 
 static void
-nv04_compatible_transfer_tex(struct pipe_texture *pt, unsigned level,
+nv04_compatible_transfer_tex(struct pipe_texture *pt, unsigned width, unsigned height,
                              struct pipe_texture *template)
 {
        memset(template, 0, sizeof(struct pipe_texture));
        template->target = pt->target;
        template->format = pt->format;
-       template->width[0] = pt->width[level];
-       template->height[0] = pt->height[level];
-       template->depth[0] = 1;
-       template->block = pt->block;
-       template->nblocksx[0] = pt->nblocksx[level];
-       template->nblocksy[0] = pt->nblocksx[level];
+       template->width0 = width;
+       template->height0 = height;
+       template->depth0 = 1;
        template->last_level = 0;
        template->nr_samples = pt->nr_samples;
 
@@ -48,14 +47,10 @@ nv04_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
                return NULL;
 
        pipe_texture_reference(&tx->base.texture, pt);
-       tx->base.format = pt->format;
        tx->base.x = x;
        tx->base.y = y;
        tx->base.width = w;
        tx->base.height = h;
-       tx->base.block = pt->block;
-       tx->base.nblocksx = pt->nblocksx[level];
-       tx->base.nblocksy = pt->nblocksy[level];
        tx->base.stride = mt->level[level].pitch;
        tx->base.usage = usage;
        tx->base.face = face;
@@ -76,7 +71,7 @@ nv04_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
 
        tx->direct = false;
 
-       nv04_compatible_transfer_tex(pt, level, &tx_tex_template);
+       nv04_compatible_transfer_tex(pt, w, h, &tx_tex_template);
 
        tx_tex = pscreen->texture_create(pscreen, &tx_tex_template);
        if (!tx_tex)
@@ -85,6 +80,8 @@ nv04_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
                return NULL;
        }
 
+       tx->base.stride = ((struct nv04_miptree*)tx_tex)->level[0].pitch;
+
        tx->surface = pscreen->get_tex_surface(pscreen, tx_tex,
                                               face, level, zslice,
                                               pipe_transfer_buffer_flags(&tx->base));
@@ -110,8 +107,8 @@ nv04_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
                /* TODO: Check if SIFM can un-swizzle */
                nvscreen->eng2d->copy(nvscreen->eng2d,
                                      tx->surface, 0, 0,
-                                     src, 0, 0,
-                                     src->width, src->height);
+                                     src, x, y,
+                                     w, h);
 
                pipe_surface_reference(&src, NULL);
        }
@@ -135,9 +132,9 @@ nv04_transfer_del(struct pipe_transfer *ptx)
 
                /* TODO: Check if SIFM can deal with x,y,w,h when swizzling */
                nvscreen->eng2d->copy(nvscreen->eng2d,
-                                     dst, 0, 0,
+                                     dst, tx->base.x, tx->base.y,
                                      tx->surface, 0, 0,
-                                     dst->width, dst->height);
+                                     tx->base.width, tx->base.height);
 
                pipe_surface_reference(&dst, NULL);
        }
@@ -156,8 +153,10 @@ nv04_transfer_map(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
        void *map = pipe_buffer_map(pscreen, mt->buffer,
                                    pipe_transfer_buffer_flags(ptx));
 
-       return map + ns->base.offset +
-              ptx->y * ns->pitch + ptx->x * ptx->block.size;
+       if(!tx->direct)
+               return map + ns->base.offset;
+       else
+               return map + ns->base.offset + ptx->y * ns->pitch + ptx->x * util_format_get_blocksize(ptx->texture->format);
 }
 
 static void
index e3167814f2bcb39d5ec92280c3391f8b1fea9c40..348477181455a45260580fc8419e16021e144a2e 100644 (file)
@@ -9,7 +9,7 @@
 #include "nouveau/nouveau_channel.h"
 #include "nouveau/nouveau_pushbuf.h"
 
-boolean nv04_draw_elements( struct pipe_context *pipe,
+void nv04_draw_elements( struct pipe_context *pipe,
                     struct pipe_buffer *indexBuffer,
                     unsigned indexSize,
                     unsigned prim, unsigned start, unsigned count)
@@ -45,7 +45,7 @@ boolean nv04_draw_elements( struct pipe_context *pipe,
                draw_set_mapped_element_buffer(draw, 0, NULL);
        }
 
-       draw_set_mapped_constant_buffer(draw,
+       draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX,
                                        nv04->constbuf[PIPE_SHADER_VERTEX],
                                        nv04->constbuf_nr[PIPE_SHADER_VERTEX]);
 
@@ -65,15 +65,13 @@ boolean nv04_draw_elements( struct pipe_context *pipe,
                pipe_buffer_unmap(pscreen, indexBuffer);
                draw_set_mapped_element_buffer(draw, 0, NULL);
        }
-
-       return TRUE;
 }
 
-boolean nv04_draw_arrays( struct pipe_context *pipe,
-                                unsigned prim, unsigned start, unsigned count)
+void nv04_draw_arrays( struct pipe_context *pipe,
+                       unsigned prim, unsigned start, unsigned count)
 {
        printf("coucou in draw arrays\n");
-       return nv04_draw_elements(pipe, NULL, 0, prim, start, count);
+       nv04_draw_elements(pipe, NULL, 0, prim, start, count);
 }
 
 
index a127b134ecd5043369915ae96b9d90e707b70156..1ecb73d06e89415bef5ae7718fb74a0f47e95628 100644 (file)
@@ -10,10 +10,14 @@ nv10_flush(struct pipe_context *pipe, unsigned flags,
           struct pipe_fence_handle **fence)
 {
        struct nv10_context *nv10 = nv10_context(pipe);
+       struct nv10_screen *screen = nv10->screen;
+       struct nouveau_channel *chan = screen->base.channel;
 
        draw_flush(nv10->draw);
 
-       FIRE_RING(fence);
+       FIRE_RING(chan);
+       if (fence)
+               *fence = NULL;
 }
 
 static void
@@ -31,253 +35,226 @@ static void nv10_init_hwctx(struct nv10_context *nv10)
 {
        struct nv10_screen *screen = nv10->screen;
        struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *celsius = screen->celsius;
        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  (chan->vram->handle);
-       OUT_RING  (chan->gart->handle);
-       BEGIN_RING(celsius, NV10TCL_DMA_IN_MEMORY2, 2);
-       OUT_RING  (chan->vram->handle);
-       OUT_RING  (chan->vram->handle);
+       BEGIN_RING(chan, celsius, NV10TCL_DMA_NOTIFY, 1);
+       OUT_RING  (chan, screen->sync->handle);
+       BEGIN_RING(chan, celsius, NV10TCL_DMA_IN_MEMORY0, 2);
+       OUT_RING  (chan, chan->vram->handle);
+       OUT_RING  (chan, chan->gart->handle);
+       BEGIN_RING(chan, celsius, NV10TCL_DMA_IN_MEMORY2, 2);
+       OUT_RING  (chan, chan->vram->handle);
+       OUT_RING  (chan, chan->vram->handle);
 
-       BEGIN_RING(celsius, NV10TCL_NOP, 1);
-       OUT_RING  (0);
+       BEGIN_RING(chan, celsius, NV10TCL_NOP, 1);
+       OUT_RING  (chan, 0);
 
-       BEGIN_RING(celsius, NV10TCL_RT_HORIZ, 2);
-       OUT_RING  (0);
-       OUT_RING  (0);
+       BEGIN_RING(chan, celsius, NV10TCL_RT_HORIZ, 2);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 0);
 
-       BEGIN_RING(celsius, NV10TCL_VIEWPORT_CLIP_HORIZ(0), 1);
-       OUT_RING  ((0x7ff<<16)|0x800);
-       BEGIN_RING(celsius, NV10TCL_VIEWPORT_CLIP_VERT(0), 1);
-       OUT_RING  ((0x7ff<<16)|0x800);
+       BEGIN_RING(chan, celsius, NV10TCL_VIEWPORT_CLIP_HORIZ(0), 1);
+       OUT_RING  (chan, (0x7ff<<16)|0x800);
+       BEGIN_RING(chan, celsius, NV10TCL_VIEWPORT_CLIP_VERT(0), 1);
+       OUT_RING  (chan, (0x7ff<<16)|0x800);
 
        for (i=1;i<8;i++) {
-               BEGIN_RING(celsius, NV10TCL_VIEWPORT_CLIP_HORIZ(i), 1);
-               OUT_RING  (0);
-               BEGIN_RING(celsius, NV10TCL_VIEWPORT_CLIP_VERT(i), 1);
-               OUT_RING  (0);
+               BEGIN_RING(chan, celsius, NV10TCL_VIEWPORT_CLIP_HORIZ(i), 1);
+               OUT_RING  (chan, 0);
+               BEGIN_RING(chan, celsius, NV10TCL_VIEWPORT_CLIP_VERT(i), 1);
+               OUT_RING  (chan, 0);
        }
 
-       BEGIN_RING(celsius, 0x290, 1);
-       OUT_RING  ((0x10<<16)|1);
-       BEGIN_RING(celsius, 0x3f4, 1);
-       OUT_RING  (0);
+       BEGIN_RING(chan, celsius, 0x290, 1);
+       OUT_RING  (chan, (0x10<<16)|1);
+       BEGIN_RING(chan, celsius, 0x3f4, 1);
+       OUT_RING  (chan, 0);
 
-       BEGIN_RING(celsius, NV10TCL_NOP, 1);
-       OUT_RING  (0);
+       BEGIN_RING(chan, celsius, NV10TCL_NOP, 1);
+       OUT_RING  (chan, 0);
 
        if (nv10->screen->celsius->grclass != NV10TCL) {
                /* For nv11, nv17 */
-               BEGIN_RING(celsius, 0x120, 3);
-               OUT_RING  (0);
-               OUT_RING  (1);
-               OUT_RING  (2);
+               BEGIN_RING(chan, celsius, 0x120, 3);
+               OUT_RING  (chan, 0);
+               OUT_RING  (chan, 1);
+               OUT_RING  (chan, 2);
 
-               BEGIN_RING(celsius, NV10TCL_NOP, 1);
-               OUT_RING  (0);
+               BEGIN_RING(chan, celsius, NV10TCL_NOP, 1);
+               OUT_RING  (chan, 0);
        }
 
-       BEGIN_RING(celsius, NV10TCL_NOP, 1);
-       OUT_RING  (0);
+       BEGIN_RING(chan, celsius, NV10TCL_NOP, 1);
+       OUT_RING  (chan, 0);
 
        /* Set state */
-       BEGIN_RING(celsius, NV10TCL_FOG_ENABLE, 1);
-       OUT_RING  (0);
-       BEGIN_RING(celsius, NV10TCL_ALPHA_FUNC_ENABLE, 1);
-       OUT_RING  (0);
-       BEGIN_RING(celsius, NV10TCL_ALPHA_FUNC_FUNC, 2);
-       OUT_RING  (0x207);
-       OUT_RING  (0);
-       BEGIN_RING(celsius, NV10TCL_TX_ENABLE(0), 2);
-       OUT_RING  (0);
-       OUT_RING  (0);
-
-       BEGIN_RING(celsius, NV10TCL_RC_IN_ALPHA(0), 12);
-       OUT_RING  (0x30141010);
-       OUT_RING  (0);
-       OUT_RING  (0x20040000);
-       OUT_RING  (0);
-       OUT_RING  (0);
-       OUT_RING  (0);
-       OUT_RING  (0x00000c00);
-       OUT_RING  (0);
-       OUT_RING  (0x00000c00);
-       OUT_RING  (0x18000000);
-       OUT_RING  (0x300e0300);
-       OUT_RING  (0x0c091c80);
-
-       BEGIN_RING(celsius, NV10TCL_BLEND_FUNC_ENABLE, 1);
-       OUT_RING  (0);
-       BEGIN_RING(celsius, NV10TCL_DITHER_ENABLE, 2);
-       OUT_RING  (1);
-       OUT_RING  (0);
-       BEGIN_RING(celsius, NV10TCL_LINE_SMOOTH_ENABLE, 1);
-       OUT_RING  (0);
-       BEGIN_RING(celsius, NV10TCL_VERTEX_WEIGHT_ENABLE, 2);
-       OUT_RING  (0);
-       OUT_RING  (0);
-       BEGIN_RING(celsius, NV10TCL_BLEND_FUNC_SRC, 4);
-       OUT_RING  (1);
-       OUT_RING  (0);
-       OUT_RING  (0);
-       OUT_RING  (0x8006);
-       BEGIN_RING(celsius, NV10TCL_STENCIL_MASK, 8);
-       OUT_RING  (0xff);
-       OUT_RING  (0x207);
-       OUT_RING  (0);
-       OUT_RING  (0xff);
-       OUT_RING  (0x1e00);
-       OUT_RING  (0x1e00);
-       OUT_RING  (0x1e00);
-       OUT_RING  (0x1d01);
-       BEGIN_RING(celsius, NV10TCL_NORMALIZE_ENABLE, 1);
-       OUT_RING  (0);
-       BEGIN_RING(celsius, NV10TCL_FOG_ENABLE, 2);
-       OUT_RING  (0);
-       OUT_RING  (0);
-       BEGIN_RING(celsius, NV10TCL_LIGHT_MODEL, 1);
-       OUT_RING  (0);
-       BEGIN_RING(celsius, NV10TCL_COLOR_CONTROL, 1);
-       OUT_RING  (0);
-       BEGIN_RING(celsius, NV10TCL_ENABLED_LIGHTS, 1);
-       OUT_RING  (0);
-       BEGIN_RING(celsius, NV10TCL_POLYGON_OFFSET_POINT_ENABLE, 3);
-       OUT_RING  (0);
-       OUT_RING  (0);
-       OUT_RING  (0);
-       BEGIN_RING(celsius, NV10TCL_DEPTH_FUNC, 1);
-       OUT_RING  (0x201);
-       BEGIN_RING(celsius, NV10TCL_DEPTH_WRITE_ENABLE, 1);
-       OUT_RING  (0);
-       BEGIN_RING(celsius, NV10TCL_DEPTH_TEST_ENABLE, 1);
-       OUT_RING  (0);
-       BEGIN_RING(celsius, NV10TCL_POLYGON_OFFSET_FACTOR, 2);
-       OUT_RING  (0);
-       OUT_RING  (0);
-       BEGIN_RING(celsius, NV10TCL_POINT_SIZE, 1);
-       OUT_RING  (8);
-       BEGIN_RING(celsius, NV10TCL_POINT_PARAMETERS_ENABLE, 2);
-       OUT_RING  (0);
-       OUT_RING  (0);
-       BEGIN_RING(celsius, NV10TCL_LINE_WIDTH, 1);
-       OUT_RING  (8);
-       BEGIN_RING(celsius, NV10TCL_LINE_SMOOTH_ENABLE, 1);
-       OUT_RING  (0);
-       BEGIN_RING(celsius, NV10TCL_POLYGON_MODE_FRONT, 2);
-       OUT_RING  (0x1b02);
-       OUT_RING  (0x1b02);
-       BEGIN_RING(celsius, NV10TCL_CULL_FACE, 2);
-       OUT_RING  (0x405);
-       OUT_RING  (0x901);
-       BEGIN_RING(celsius, NV10TCL_POLYGON_SMOOTH_ENABLE, 1);
-       OUT_RING  (0);
-       BEGIN_RING(celsius, NV10TCL_CULL_FACE_ENABLE, 1);
-       OUT_RING  (0);
-       BEGIN_RING(celsius, NV10TCL_TX_GEN_S(0), 8);
+       BEGIN_RING(chan, celsius, NV10TCL_FOG_ENABLE, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, celsius, NV10TCL_ALPHA_FUNC_ENABLE, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, celsius, NV10TCL_ALPHA_FUNC_FUNC, 2);
+       OUT_RING  (chan, 0x207);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, celsius, NV10TCL_TX_ENABLE(0), 2);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 0);
+
+       BEGIN_RING(chan, celsius, NV10TCL_RC_IN_ALPHA(0), 12);
+       OUT_RING  (chan, 0x30141010);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 0x20040000);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 0x00000c00);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 0x00000c00);
+       OUT_RING  (chan, 0x18000000);
+       OUT_RING  (chan, 0x300e0300);
+       OUT_RING  (chan, 0x0c091c80);
+
+       BEGIN_RING(chan, celsius, NV10TCL_BLEND_FUNC_ENABLE, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, celsius, NV10TCL_DITHER_ENABLE, 2);
+       OUT_RING  (chan, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, celsius, NV10TCL_LINE_SMOOTH_ENABLE, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, celsius, NV10TCL_VERTEX_WEIGHT_ENABLE, 2);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, celsius, NV10TCL_BLEND_FUNC_SRC, 4);
+       OUT_RING  (chan, 1);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 0x8006);
+       BEGIN_RING(chan, celsius, NV10TCL_STENCIL_MASK, 8);
+       OUT_RING  (chan, 0xff);
+       OUT_RING  (chan, 0x207);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 0xff);
+       OUT_RING  (chan, 0x1e00);
+       OUT_RING  (chan, 0x1e00);
+       OUT_RING  (chan, 0x1e00);
+       OUT_RING  (chan, 0x1d01);
+       BEGIN_RING(chan, celsius, NV10TCL_NORMALIZE_ENABLE, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, celsius, NV10TCL_FOG_ENABLE, 2);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, celsius, NV10TCL_LIGHT_MODEL, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, celsius, NV10TCL_COLOR_CONTROL, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, celsius, NV10TCL_ENABLED_LIGHTS, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, celsius, NV10TCL_POLYGON_OFFSET_POINT_ENABLE, 3);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, celsius, NV10TCL_DEPTH_FUNC, 1);
+       OUT_RING  (chan, 0x201);
+       BEGIN_RING(chan, celsius, NV10TCL_DEPTH_WRITE_ENABLE, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, celsius, NV10TCL_DEPTH_TEST_ENABLE, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, celsius, NV10TCL_POLYGON_OFFSET_FACTOR, 2);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, celsius, NV10TCL_POINT_SIZE, 1);
+       OUT_RING  (chan, 8);
+       BEGIN_RING(chan, celsius, NV10TCL_POINT_PARAMETERS_ENABLE, 2);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, celsius, NV10TCL_LINE_WIDTH, 1);
+       OUT_RING  (chan, 8);
+       BEGIN_RING(chan, celsius, NV10TCL_LINE_SMOOTH_ENABLE, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, celsius, NV10TCL_POLYGON_MODE_FRONT, 2);
+       OUT_RING  (chan, 0x1b02);
+       OUT_RING  (chan, 0x1b02);
+       BEGIN_RING(chan, celsius, NV10TCL_CULL_FACE, 2);
+       OUT_RING  (chan, 0x405);
+       OUT_RING  (chan, 0x901);
+       BEGIN_RING(chan, celsius, NV10TCL_POLYGON_SMOOTH_ENABLE, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, celsius, NV10TCL_CULL_FACE_ENABLE, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, celsius, NV10TCL_TX_GEN_S(0), 8);
        for (i=0;i<8;i++) {
-               OUT_RING  (0);
+               OUT_RING  (chan, 0);
        }
-       BEGIN_RING(celsius, NV10TCL_FOG_EQUATION_CONSTANT, 3);
-       OUT_RING  (0x3fc00000); /* -1.50 */
-       OUT_RING  (0xbdb8aa0a); /* -0.09 */
-       OUT_RING  (0);          /*  0.00 */
+       BEGIN_RING(chan, celsius, NV10TCL_FOG_EQUATION_CONSTANT, 3);
+       OUT_RING  (chan, 0x3fc00000);   /* -1.50 */
+       OUT_RING  (chan, 0xbdb8aa0a);   /* -0.09 */
+       OUT_RING  (chan, 0);            /*  0.00 */
 
-       BEGIN_RING(celsius, NV10TCL_NOP, 1);
-       OUT_RING  (0);
+       BEGIN_RING(chan, celsius, NV10TCL_NOP, 1);
+       OUT_RING  (chan, 0);
 
-       BEGIN_RING(celsius, NV10TCL_FOG_MODE, 2);
-       OUT_RING  (0x802);
-       OUT_RING  (2);
+       BEGIN_RING(chan, celsius, NV10TCL_FOG_MODE, 2);
+       OUT_RING  (chan, 0x802);
+       OUT_RING  (chan, 2);
        /* for some reason VIEW_MATRIX_ENABLE need to be 6 instead of 4 when
         * using texturing, except when using the texture matrix
         */
-       BEGIN_RING(celsius, NV10TCL_VIEW_MATRIX_ENABLE, 1);
-       OUT_RING  (6);
-       BEGIN_RING(celsius, NV10TCL_COLOR_MASK, 1);
-       OUT_RING  (0x01010101);
+       BEGIN_RING(chan, celsius, NV10TCL_VIEW_MATRIX_ENABLE, 1);
+       OUT_RING  (chan, 6);
+       BEGIN_RING(chan, celsius, NV10TCL_COLOR_MASK, 1);
+       OUT_RING  (chan, 0x01010101);
 
        /* Set vertex component */
-       BEGIN_RING(celsius, NV10TCL_VERTEX_COL_4F_R, 4);
-       OUT_RINGf (1.0);
-       OUT_RINGf (1.0);
-       OUT_RINGf (1.0);
-       OUT_RINGf (1.0);
-       BEGIN_RING(celsius, NV10TCL_VERTEX_COL2_3F_R, 3);
-       OUT_RING  (0);
-       OUT_RING  (0);
-       OUT_RING  (0);
-       BEGIN_RING(celsius, NV10TCL_VERTEX_NOR_3F_X, 3);
-       OUT_RING  (0);
-       OUT_RING  (0);
-       OUT_RINGf (1.0);
-       BEGIN_RING(celsius, NV10TCL_VERTEX_TX0_4F_S, 4);
-       OUT_RINGf (0.0);
-       OUT_RINGf (0.0);
-       OUT_RINGf (0.0);
-       OUT_RINGf (1.0);
-       BEGIN_RING(celsius, NV10TCL_VERTEX_TX1_4F_S, 4);
-       OUT_RINGf (0.0);
-       OUT_RINGf (0.0);
-       OUT_RINGf (0.0);
-       OUT_RINGf (1.0);
-       BEGIN_RING(celsius, NV10TCL_VERTEX_FOG_1F, 1);
-       OUT_RINGf (0.0);
-       BEGIN_RING(celsius, NV10TCL_EDGEFLAG_ENABLE, 1);
-       OUT_RING  (1);
+       BEGIN_RING(chan, celsius, NV10TCL_VERTEX_COL_4F_R, 4);
+       OUT_RINGf (chan, 1.0);
+       OUT_RINGf (chan, 1.0);
+       OUT_RINGf (chan, 1.0);
+       OUT_RINGf (chan, 1.0);
+       BEGIN_RING(chan, celsius, NV10TCL_VERTEX_COL2_3F_R, 3);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, celsius, NV10TCL_VERTEX_NOR_3F_X, 3);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 0);
+       OUT_RINGf (chan, 1.0);
+       BEGIN_RING(chan, celsius, NV10TCL_VERTEX_TX0_4F_S, 4);
+       OUT_RINGf (chan, 0.0);
+       OUT_RINGf (chan, 0.0);
+       OUT_RINGf (chan, 0.0);
+       OUT_RINGf (chan, 1.0);
+       BEGIN_RING(chan, celsius, NV10TCL_VERTEX_TX1_4F_S, 4);
+       OUT_RINGf (chan, 0.0);
+       OUT_RINGf (chan, 0.0);
+       OUT_RINGf (chan, 0.0);
+       OUT_RINGf (chan, 1.0);
+       BEGIN_RING(chan, celsius, NV10TCL_VERTEX_FOG_1F, 1);
+       OUT_RINGf (chan, 0.0);
+       BEGIN_RING(chan, celsius, NV10TCL_EDGEFLAG_ENABLE, 1);
+       OUT_RING  (chan, 1);
 
        memset(projectionmatrix, 0, sizeof(projectionmatrix));
-       BEGIN_RING(celsius, NV10TCL_PROJECTION_MATRIX(0), 16);
+       BEGIN_RING(chan, celsius, NV10TCL_PROJECTION_MATRIX(0), 16);
        projectionmatrix[0*4+0] = 1.0;
        projectionmatrix[1*4+1] = 1.0;
        projectionmatrix[2*4+2] = 1.0;
        projectionmatrix[3*4+3] = 1.0;
        for (i=0;i<16;i++) {
-               OUT_RINGf  (projectionmatrix[i]);
+               OUT_RINGf  (chan, projectionmatrix[i]);
        }
 
-       BEGIN_RING(celsius, NV10TCL_DEPTH_RANGE_NEAR, 2);
-       OUT_RING  (0.0);
-       OUT_RINGf  (16777216.0);
-
-       BEGIN_RING(celsius, NV10TCL_VIEWPORT_SCALE_X, 4);
-       OUT_RINGf  (-2048.0);
-       OUT_RINGf  (-2048.0);
-       OUT_RINGf  (16777215.0 * 0.5);
-       OUT_RING  (0);
-
-       FIRE_RING (NULL);
-}
-
-static void
-nv10_set_edgeflags(struct pipe_context *pipe, const unsigned *bitfield)
-{
-}
-
-static unsigned int
-nv10_is_texture_referenced( struct pipe_context *pipe,
-                           struct pipe_texture *texture,
-                           unsigned face, unsigned level)
-{
-   /**
-    * FIXME: Optimize.
-    */
+       BEGIN_RING(chan, celsius, NV10TCL_DEPTH_RANGE_NEAR, 2);
+       OUT_RING  (chan, 0.0);
+       OUT_RINGf  (chan, 16777216.0);
 
-   return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
-
-static unsigned int
-nv10_is_buffer_referenced( struct pipe_context *pipe,
-                          struct pipe_buffer *buf)
-{
-   /**
-    * FIXME: Optimize.
-    */
+       BEGIN_RING(chan, celsius, NV10TCL_VIEWPORT_TRANSLATE_X, 4);
+       OUT_RINGf  (chan, -2048.0);
+       OUT_RINGf  (chan, -2048.0);
+       OUT_RINGf  (chan, 16777215.0 * 0.5);
+       OUT_RING  (chan, 0);
 
-   return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
+       FIRE_RING (chan);
 }
 
 struct pipe_context *
@@ -299,14 +276,13 @@ nv10_create(struct pipe_screen *pscreen, unsigned pctx_id)
        nv10->pipe.winsys = ws;
        nv10->pipe.screen = pscreen;
        nv10->pipe.destroy = nv10_destroy;
-       nv10->pipe.set_edgeflags = nv10_set_edgeflags;
        nv10->pipe.draw_arrays = nv10_draw_arrays;
        nv10->pipe.draw_elements = nv10_draw_elements;
        nv10->pipe.clear = nv10_clear;
        nv10->pipe.flush = nv10_flush;
 
-       nv10->pipe.is_texture_referenced = nv10_is_texture_referenced;
-       nv10->pipe.is_buffer_referenced = nv10_is_buffer_referenced;
+       nv10->pipe.is_texture_referenced = nouveau_is_texture_referenced;
+       nv10->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
 
        nv10_init_surface_functions(nv10);
        nv10_init_state_functions(nv10);
index f1e003c95373f752bf78a3d9f8b413eb66c9118a..ab4b825487d5fc19fc66c63dcabd149b67d819f2 100644 (file)
 
 #include "nouveau/nouveau_winsys.h"
 #include "nouveau/nouveau_gldefs.h"
-
-#define NOUVEAU_PUSH_CONTEXT(ctx)                                              \
-       struct nv10_screen *ctx = nv10->screen
-#include "nouveau/nouveau_push.h"
+#include "nouveau/nouveau_context.h"
 
 #include "nv10_state.h"
 
@@ -143,9 +140,9 @@ extern void nv10_emit_hw_state(struct nv10_context *nv10);
 extern void nv10_state_tex_update(struct nv10_context *nv10);
 
 /* nv10_vbo.c */
-extern boolean nv10_draw_arrays(struct pipe_context *, unsigned mode,
+extern void nv10_draw_arrays(struct pipe_context *, unsigned mode,
                                unsigned start, unsigned count);
-extern boolean nv10_draw_elements( struct pipe_context *pipe,
+extern void nv10_draw_elements( struct pipe_context *pipe,
                     struct pipe_buffer *indexBuffer,
                     unsigned indexSize,
                     unsigned prim, unsigned start, unsigned count);
index 27f2f8758471064b7b689be1f0241de6e3279437..c1f7ccb9ab6dfe0b0d47af3d917b11b12e819bef 100644 (file)
@@ -52,6 +52,9 @@ nv10_fragtex_build(struct nv10_context *nv10, int unit)
        struct nv10_miptree *nv10mt = nv10->tex_miptree[unit];
        struct pipe_texture *pt = &nv10mt->base;
        struct nv10_texture_format *tf;
+       struct nv10_screen *screen = nv10->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *celsius = screen->celsius;
        uint32_t txf, txs, txp;
 
        tf = nv10_fragtex_format(pt->format);
@@ -62,9 +65,9 @@ nv10_fragtex_build(struct nv10_context *nv10, int unit)
 
        txf  = tf->format << 8;
        txf |= (pt->last_level + 1) << 16;
-       txf |= log2i(pt->width[0]) << 20;
-       txf |= log2i(pt->height[0]) << 24;
-       txf |= log2i(pt->depth[0]) << 28;
+       txf |= log2i(pt->width0) << 20;
+       txf |= log2i(pt->height0) << 24;
+       txf |= log2i(pt->depth0) << 28;
        txf |= 8;
 
        switch (pt->target) {
@@ -82,15 +85,15 @@ nv10_fragtex_build(struct nv10_context *nv10, int unit)
                return;
        }
 
-       BEGIN_RING(celsius, NV10TCL_TX_OFFSET(unit), 8);
-       OUT_RELOCl(nv10mt->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD);
-       OUT_RELOCd(nv10mt->buffer,txf,NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_OR | NOUVEAU_BO_RD, 1/*VRAM*/,2/*TT*/);
-       OUT_RING  (ps->wrap);
-       OUT_RING  (0x40000000); /* enable */
-       OUT_RING  (txs);
-       OUT_RING  (ps->filt | 0x2000 /* magic */);
-       OUT_RING  ((pt->width[0] << 16) | pt->height[0]);
-       OUT_RING  (ps->bcol);
+       BEGIN_RING(chan, celsius, NV10TCL_TX_OFFSET(unit), 8);
+       OUT_RELOCl(chan, nouveau_bo(nv10mt->buffer), 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD);
+       OUT_RELOCd(chan, nouveau_bo(nv10mt->buffer),txf,NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_OR | NOUVEAU_BO_RD, 1/*VRAM*/,2/*TT*/);
+       OUT_RING  (chan, ps->wrap);
+       OUT_RING  (chan, 0x40000000); /* enable */
+       OUT_RING  (chan, txs);
+       OUT_RING  (chan, ps->filt | 0x2000 /* magic */);
+       OUT_RING  (chan, (pt->width0 << 16) | pt->height0);
+       OUT_RING  (chan, ps->bcol);
 #endif
 }
 
@@ -99,6 +102,9 @@ nv10_fragtex_bind(struct nv10_context *nv10)
 {
 #if 0
        struct nv10_fragment_program *fp = nv10->fragprog.active;
+       struct nv10_screen *screen = nv10->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *celsius = screen->celsius;
        unsigned samplers, unit;
 
        samplers = nv10->fp_samplers & ~fp->samplers;
@@ -106,8 +112,8 @@ nv10_fragtex_bind(struct nv10_context *nv10)
                unit = ffs(samplers) - 1;
                samplers &= ~(1 << unit);
 
-               BEGIN_RING(celsius, NV10TCL_TX_ENABLE(unit), 1);
-               OUT_RING  (0);
+               BEGIN_RING(chan, celsius, NV10TCL_TX_ENABLE(unit), 1);
+               OUT_RING  (chan, 0);
        }
 
        samplers = nv10->dirty_samplers & fp->samplers;
index 34e3c2ebd770e86d2456049a2e34e6f32b3f19fe..908482ad854890eaee16fa33006f395714292de6 100644 (file)
@@ -1,6 +1,8 @@
 #include "pipe/p_state.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_inlines.h"
+#include "util/u_format.h"
+#include "util/u_math.h"
 
 #include "nv10_context.h"
 #include "nv10_screen.h"
@@ -10,7 +12,7 @@ nv10_miptree_layout(struct nv10_miptree *nv10mt)
 {
        struct pipe_texture *pt = &nv10mt->base;
        boolean swizzled = FALSE;
-       uint width = pt->width[0], height = pt->height[0];
+       uint width = pt->width0;
        uint offset = 0;
        int nr_faces, l, f;
 
@@ -21,29 +23,23 @@ nv10_miptree_layout(struct nv10_miptree *nv10mt)
        }
        
        for (l = 0; l <= pt->last_level; l++) {
-               pt->width[l] = width;
-               pt->height[l] = height;
-               pt->nblocksx[l] = pf_get_nblocksx(&pt->block, width);
-               pt->nblocksy[l] = pf_get_nblocksy(&pt->block, height);
-
                if (swizzled)
-                       nv10mt->level[l].pitch = pt->nblocksx[l] * pt->block.size;
+                       nv10mt->level[l].pitch = util_format_get_stride(pt->format, width);
                else
-                       nv10mt->level[l].pitch = pt->nblocksx[0] * pt->block.size;
+                       nv10mt->level[l].pitch = util_format_get_stride(pt->format, pt->width0);
                nv10mt->level[l].pitch = (nv10mt->level[l].pitch + 63) & ~63;
 
                nv10mt->level[l].image_offset =
                        CALLOC(nr_faces, sizeof(unsigned));
 
-               width  = MAX2(1, width  >> 1);
-               height = MAX2(1, height >> 1);
+               width  = u_minify(width, 1);
 
        }
 
        for (f = 0; f < nr_faces; f++) {
                for (l = 0; l <= pt->last_level; l++) {
                        nv10mt->level[l].image_offset[f] = offset;
-                       offset += nv10mt->level[l].pitch * pt->height[l];
+                       offset += nv10mt->level[l].pitch * u_minify(pt->height0, l);
                }
        }
 
@@ -58,7 +54,7 @@ nv10_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
 
        /* Only supports 2D, non-mipmapped textures for the moment */
        if (pt->target != PIPE_TEXTURE_2D || pt->last_level != 0 ||
-           pt->depth[0] != 1)
+           pt->depth0 != 1)
                return NULL;
 
        mt = CALLOC_STRUCT(nv10_miptree);
@@ -72,6 +68,7 @@ nv10_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
        mt->level[0].image_offset = CALLOC(1, sizeof(unsigned));
 
        pipe_buffer_reference(&mt->buffer, pb);
+       mt->bo = nouveau_bo(mt->buffer);
        return &mt->base;
 }
 
@@ -95,6 +92,7 @@ nv10_miptree_create(struct pipe_screen *screen, const struct pipe_texture *pt)
                FREE(mt);
                return NULL;
        }
+       mt->bo = nouveau_bo(mt->buffer);
        
        return &mt->base;
 }
@@ -133,8 +131,8 @@ nv10_miptree_surface_get(struct pipe_screen *screen, struct pipe_texture *pt,
                return NULL;
        pipe_texture_reference(&ns->base.texture, pt);
        ns->base.format = pt->format;
-       ns->base.width = pt->width[level];
-       ns->base.height = pt->height[level];
+       ns->base.width = u_minify(pt->width0, level);
+       ns->base.height = u_minify(pt->height0, level);
        ns->base.usage = flags;
        pipe_reference_init(&ns->base.reference, 1);
        ns->base.face = face;
index 1806d5f8ccc3ac17cbe97d0bd1fb4d470bf22d6d..c5dbe43dbc8ebc5411b1994c86bc0cd7b7d29e91 100644 (file)
@@ -67,12 +67,15 @@ struct nv10_vbuf_render {
 
 void nv10_vtxbuf_bind( struct nv10_context* nv10 )
 {
+       struct nv10_screen *screen = nv10->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *celsius = screen->celsius;
        int i;
        for(i = 0; i < 8; i++) {
-               BEGIN_RING(celsius, NV10TCL_VERTEX_ARRAY_ATTRIB_OFFSET(i), 1);
-               OUT_RING(0/*nv10->vtxbuf*/);
-               BEGIN_RING(celsius, NV10TCL_VERTEX_ARRAY_ATTRIB_FORMAT(i) ,1);
-               OUT_RING(0/*XXX*/);
+               BEGIN_RING(chan, celsius, NV10TCL_VTXBUF_ADDRESS(i), 1);
+               OUT_RING(chan, 0/*nv10->vtxbuf*/);
+               BEGIN_RING(chan, celsius, NV10TCL_VTXFMT(i), 1);
+               OUT_RING(chan, 0/*XXX*/);
        }
 }
 
@@ -163,19 +166,22 @@ nv10_vbuf_render_draw( struct vbuf_render *render,
 {
        struct nv10_vbuf_render *nv10_render = nv10_vbuf_render(render);
        struct nv10_context *nv10 = nv10_render->nv10;
+       struct nv10_screen *screen = nv10->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *celsius = screen->celsius;
        int push, i;
 
        nv10_emit_hw_state(nv10);
 
-       BEGIN_RING(celsius, NV10TCL_VERTEX_ARRAY_OFFSET_POS, 1);
-       OUT_RELOCl(nv10_render->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD);
+       BEGIN_RING(chan, celsius, NV10TCL_VERTEX_ARRAY_OFFSET_POS, 1);
+       OUT_RELOCl(chan, nouveau_bo(nv10_render->buffer), 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD);
 
-       BEGIN_RING(celsius, NV10TCL_VERTEX_BUFFER_BEGIN_END, 1);
-       OUT_RING(nv10_render->hwprim);
+       BEGIN_RING(chan, celsius, NV10TCL_VERTEX_BUFFER_BEGIN_END, 1);
+       OUT_RING(chan, nv10_render->hwprim);
 
        if (nr_indices & 1) {
-               BEGIN_RING(celsius, NV10TCL_VB_ELEMENT_U32, 1);
-               OUT_RING  (indices[0]);
+               BEGIN_RING(chan, celsius, NV10TCL_VB_ELEMENT_U32, 1);
+               OUT_RING  (chan, indices[0]);
                indices++; nr_indices--;
        }
 
@@ -183,16 +189,16 @@ nv10_vbuf_render_draw( struct vbuf_render *render,
                // XXX too big/small ? check the size
                push = MIN2(nr_indices, 1200 * 2);
 
-               BEGIN_RING_NI(celsius, NV10TCL_VB_ELEMENT_U16, push >> 1);
+               BEGIN_RING_NI(chan, celsius, NV10TCL_VB_ELEMENT_U16, push >> 1);
                for (i = 0; i < push; i+=2)
-                       OUT_RING((indices[i+1] << 16) | indices[i]);
+                       OUT_RING(chan, (indices[i+1] << 16) | indices[i]);
 
                nr_indices -= push;
                indices  += push;
        }
 
-       BEGIN_RING(celsius, NV10TCL_VERTEX_BUFFER_BEGIN_END, 1);
-       OUT_RING  (0);
+       BEGIN_RING(chan, celsius, NV10TCL_VERTEX_BUFFER_BEGIN_END, 1);
+       OUT_RING  (chan, 0);
 }
 
 
index ee5901e743e54554a5d276439ccdc4a617878d47..69a6dab866a6f3c2c6e0f74f0672f2fa6cd92b7e 100644 (file)
@@ -115,6 +115,9 @@ nv10_screen_destroy(struct pipe_screen *pscreen)
 
        nouveau_notifier_free(&screen->sync);
        nouveau_grobj_free(&screen->celsius);
+       nv04_surface_2d_takedown(&screen->eng2d);
+
+       nouveau_screen_fini(&screen->base);
 
        FREE(pscreen);
 }
@@ -177,7 +180,6 @@ nv10_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
                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);
index 9b38219b996d70cbc1d607c11e35586b8fe6db1f..ffc6be3c401d68740f162bb86d15ab001d4d2299 100644 (file)
@@ -553,9 +553,9 @@ nv10_init_state_functions(struct nv10_context *nv10)
        nv10->pipe.delete_blend_state = nv10_blend_state_delete;
 
        nv10->pipe.create_sampler_state = nv10_sampler_state_create;
-       nv10->pipe.bind_sampler_states = nv10_sampler_state_bind;
+       nv10->pipe.bind_fragment_sampler_states = nv10_sampler_state_bind;
        nv10->pipe.delete_sampler_state = nv10_sampler_state_delete;
-       nv10->pipe.set_sampler_textures = nv10_set_sampler_texture;
+       nv10->pipe.set_fragment_sampler_textures = nv10_set_sampler_texture;
 
        nv10->pipe.create_rasterizer_state = nv10_rasterizer_state_create;
        nv10->pipe.bind_rasterizer_state = nv10_rasterizer_state_bind;
index 3a3fd0d4f4f01f151ceaa00d975c7813d4bf02f0..2524ac02e29d95bb39cbc4879eb894a84e18456c 100644 (file)
@@ -126,6 +126,7 @@ struct nv10_depth_stencil_alpha_state {
 
 struct nv10_miptree {
        struct pipe_texture base;
+       struct nouveau_bo *bo;
 
        struct pipe_buffer *buffer;
        uint total_size;
index d8691ef9c67ebdaed9872953914a307dba87658a..30a596ca604a8443833cb4ebc369f5d2614900c4 100644 (file)
@@ -4,25 +4,32 @@
 static void nv10_state_emit_blend(struct nv10_context* nv10)
 {
        struct nv10_blend_state *b = nv10->blend;
+       struct nv10_screen *screen = nv10->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *celsius = screen->celsius;
 
-       BEGIN_RING(celsius, NV10TCL_DITHER_ENABLE, 1);
-       OUT_RING  (b->d_enable);
+       BEGIN_RING(chan, celsius, NV10TCL_DITHER_ENABLE, 1);
+       OUT_RING  (chan, b->d_enable);
 
-       BEGIN_RING(celsius, NV10TCL_BLEND_FUNC_ENABLE, 3);
-       OUT_RING  (b->b_enable);
-       OUT_RING  (b->b_srcfunc);
-       OUT_RING  (b->b_dstfunc);
+       BEGIN_RING(chan, celsius, NV10TCL_BLEND_FUNC_ENABLE, 3);
+       OUT_RING  (chan, b->b_enable);
+       OUT_RING  (chan, b->b_srcfunc);
+       OUT_RING  (chan, b->b_dstfunc);
 
-       BEGIN_RING(celsius, NV10TCL_COLOR_MASK, 1);
-       OUT_RING  (b->c_mask);
+       BEGIN_RING(chan, celsius, NV10TCL_COLOR_MASK, 1);
+       OUT_RING  (chan, b->c_mask);
 }
 
 static void nv10_state_emit_blend_color(struct nv10_context* nv10)
 {
        struct pipe_blend_color *c = nv10->blend_color;
+       struct nv10_screen *screen = nv10->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *celsius = screen->celsius;
 
-       BEGIN_RING(celsius, NV10TCL_BLEND_COLOR, 1);
-       OUT_RING  ((float_to_ubyte(c->color[3]) << 24)|
+       BEGIN_RING(chan, celsius, NV10TCL_BLEND_COLOR, 1);
+       OUT_RING  (chan,
+                  (float_to_ubyte(c->color[3]) << 24)|
                   (float_to_ubyte(c->color[0]) << 16)|
                   (float_to_ubyte(c->color[1]) << 8) |
                   (float_to_ubyte(c->color[2]) << 0));
@@ -31,60 +38,66 @@ static void nv10_state_emit_blend_color(struct nv10_context* nv10)
 static void nv10_state_emit_rast(struct nv10_context* nv10)
 {
        struct nv10_rasterizer_state *r = nv10->rast;
+       struct nv10_screen *screen = nv10->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *celsius = screen->celsius;
 
-       BEGIN_RING(celsius, NV10TCL_SHADE_MODEL, 2);
-       OUT_RING  (r->shade_model);
-       OUT_RING  (r->line_width);
+       BEGIN_RING(chan, celsius, NV10TCL_SHADE_MODEL, 2);
+       OUT_RING  (chan, r->shade_model);
+       OUT_RING  (chan, r->line_width);
 
 
-       BEGIN_RING(celsius, NV10TCL_POINT_SIZE, 1);
-       OUT_RING  (r->point_size);
+       BEGIN_RING(chan, celsius, NV10TCL_POINT_SIZE, 1);
+       OUT_RING  (chan, r->point_size);
 
-       BEGIN_RING(celsius, NV10TCL_POLYGON_MODE_FRONT, 2);
-       OUT_RING  (r->poly_mode_front);
-       OUT_RING  (r->poly_mode_back);
+       BEGIN_RING(chan, celsius, NV10TCL_POLYGON_MODE_FRONT, 2);
+       OUT_RING  (chan, r->poly_mode_front);
+       OUT_RING  (chan, r->poly_mode_back);
 
 
-       BEGIN_RING(celsius, NV10TCL_CULL_FACE, 2);
-       OUT_RING  (r->cull_face);
-       OUT_RING  (r->front_face);
+       BEGIN_RING(chan, celsius, NV10TCL_CULL_FACE, 2);
+       OUT_RING  (chan, r->cull_face);
+       OUT_RING  (chan, r->front_face);
 
-       BEGIN_RING(celsius, NV10TCL_LINE_SMOOTH_ENABLE, 2);
-       OUT_RING  (r->line_smooth_en);
-       OUT_RING  (r->poly_smooth_en);
+       BEGIN_RING(chan, celsius, NV10TCL_LINE_SMOOTH_ENABLE, 2);
+       OUT_RING  (chan, r->line_smooth_en);
+       OUT_RING  (chan, r->poly_smooth_en);
 
-       BEGIN_RING(celsius, NV10TCL_CULL_FACE_ENABLE, 1);
-       OUT_RING  (r->cull_face_en);
+       BEGIN_RING(chan, celsius, NV10TCL_CULL_FACE_ENABLE, 1);
+       OUT_RING  (chan, r->cull_face_en);
 }
 
 static void nv10_state_emit_dsa(struct nv10_context* nv10)
 {
        struct nv10_depth_stencil_alpha_state *d = nv10->dsa;
+       struct nv10_screen *screen = nv10->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *celsius = screen->celsius;
 
-       BEGIN_RING(celsius, NV10TCL_DEPTH_FUNC, 1);
-       OUT_RING (d->depth.func);
+       BEGIN_RING(chan, celsius, NV10TCL_DEPTH_FUNC, 1);
+       OUT_RING (chan, d->depth.func);
 
-       BEGIN_RING(celsius, NV10TCL_DEPTH_WRITE_ENABLE, 1);
-       OUT_RING (d->depth.write_enable);
+       BEGIN_RING(chan, celsius, NV10TCL_DEPTH_WRITE_ENABLE, 1);
+       OUT_RING (chan, d->depth.write_enable);
 
-       BEGIN_RING(celsius, NV10TCL_DEPTH_TEST_ENABLE, 1);
-       OUT_RING (d->depth.test_enable);
+       BEGIN_RING(chan, celsius, NV10TCL_DEPTH_TEST_ENABLE, 1);
+       OUT_RING (chan, d->depth.test_enable);
 
 #if 0
-       BEGIN_RING(celsius, NV10TCL_STENCIL_ENABLE, 1);
-       OUT_RING (d->stencil.enable);
-       BEGIN_RING(celsius, NV10TCL_STENCIL_MASK, 7);
-       OUT_RINGp ((uint32_t *)&(d->stencil.wmask), 7);
+       BEGIN_RING(chan, celsius, NV10TCL_STENCIL_ENABLE, 1);
+       OUT_RING (chan, d->stencil.enable);
+       BEGIN_RING(chan, celsius, NV10TCL_STENCIL_MASK, 7);
+       OUT_RINGp (chan, (uint32_t *)&(d->stencil.wmask), 7);
 #endif
 
-       BEGIN_RING(celsius, NV10TCL_ALPHA_FUNC_ENABLE, 1);
-       OUT_RING (d->alpha.enabled);
+       BEGIN_RING(chan, celsius, NV10TCL_ALPHA_FUNC_ENABLE, 1);
+       OUT_RING (chan, d->alpha.enabled);
 
-       BEGIN_RING(celsius, NV10TCL_ALPHA_FUNC_FUNC, 1);
-       OUT_RING (d->alpha.func);
+       BEGIN_RING(chan, celsius, NV10TCL_ALPHA_FUNC_FUNC, 1);
+       OUT_RING (chan, d->alpha.func);
 
-       BEGIN_RING(celsius, NV10TCL_ALPHA_FUNC_REF, 1);
-       OUT_RING (d->alpha.ref);
+       BEGIN_RING(chan, celsius, NV10TCL_ALPHA_FUNC_REF, 1);
+       OUT_RING (chan, d->alpha.ref);
 }
 
 static void nv10_state_emit_viewport(struct nv10_context* nv10)
@@ -108,6 +121,10 @@ static void nv10_state_emit_framebuffer(struct nv10_context* nv10)
        int colour_format = 0, zeta_format = 0;
         struct nv10_miptree *nv10mt = 0;
 
+       struct nv10_screen *screen = nv10->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *celsius = screen->celsius;
+
        w = fb->cbufs[0]->width;
        h = fb->cbufs[0]->height;
        colour_format = fb->cbufs[0]->format;
@@ -129,6 +146,9 @@ static void nv10_state_emit_framebuffer(struct nv10_context* nv10)
        rt_format = NV10TCL_RT_FORMAT_TYPE_LINEAR;
 
        switch (colour_format) {
+       case PIPE_FORMAT_X8R8G8B8_UNORM:
+               rt_format |= NV10TCL_RT_FORMAT_COLOR_X8R8G8B8;
+               break;
        case PIPE_FORMAT_A8R8G8B8_UNORM:
        case 0:
                rt_format |= NV10TCL_RT_FORMAT_COLOR_A8R8G8B8;
@@ -141,11 +161,11 @@ static void nv10_state_emit_framebuffer(struct nv10_context* nv10)
        }
 
        if (zeta) {
-               BEGIN_RING(celsius, NV10TCL_RT_PITCH, 1);
-               OUT_RING  (rt->pitch | (zeta->pitch << 16));
+               BEGIN_RING(chan, celsius, NV10TCL_RT_PITCH, 1);
+               OUT_RING  (chan, rt->pitch | (zeta->pitch << 16));
        } else {
-               BEGIN_RING(celsius, NV10TCL_RT_PITCH, 1);
-               OUT_RING  (rt->pitch | (rt->pitch << 16));
+               BEGIN_RING(chan, celsius, NV10TCL_RT_PITCH, 1);
+               OUT_RING  (chan, rt->pitch | (rt->pitch << 16));
        }
 
        nv10mt = (struct nv10_miptree *)rt->base.texture;
@@ -157,13 +177,13 @@ static void nv10_state_emit_framebuffer(struct nv10_context* nv10)
                nv10->zeta = nv10mt->buffer;
        }
 
-       BEGIN_RING(celsius, NV10TCL_RT_HORIZ, 3);
-       OUT_RING  ((w << 16) | 0);
-       OUT_RING  ((h << 16) | 0);
-       OUT_RING  (rt_format);
-       BEGIN_RING(celsius, NV10TCL_VIEWPORT_CLIP_HORIZ(0), 2);
-       OUT_RING  (((w - 1) << 16) | 0 | 0x08000800);
-       OUT_RING  (((h - 1) << 16) | 0 | 0x08000800);
+       BEGIN_RING(chan, celsius, NV10TCL_RT_HORIZ, 3);
+       OUT_RING  (chan, (w << 16) | 0);
+       OUT_RING  (chan, (h << 16) | 0);
+       OUT_RING  (chan, rt_format);
+       BEGIN_RING(chan, celsius, NV10TCL_VIEWPORT_CLIP_HORIZ(0), 2);
+       OUT_RING  (chan, ((w - 1) << 16) | 0 | 0x08000800);
+       OUT_RING  (chan, ((h - 1) << 16) | 0 | 0x08000800);
 }
 
 static void nv10_vertex_layout(struct nv10_context *nv10)
@@ -198,6 +218,10 @@ static void nv10_vertex_layout(struct nv10_context *nv10)
 void
 nv10_emit_hw_state(struct nv10_context *nv10)
 {
+       struct nv10_screen *screen = nv10->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *celsius = screen->celsius;
+       struct nouveau_bo *rt_bo;
        int i;
 
        if (nv10->dirty & NV10_NEW_VERTPROG) {
@@ -266,38 +290,41 @@ nv10_emit_hw_state(struct nv10_context *nv10)
         */
 
        /* Render target */
+       rt_bo = nouveau_bo(nv10->rt[0]);
 // XXX figre out who's who for NV10TCL_DMA_* and fill accordingly
-//     BEGIN_RING(celsius, NV10TCL_DMA_COLOR0, 1);
-//     OUT_RELOCo(nv10->rt[0], NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
-       BEGIN_RING(celsius, NV10TCL_COLOR_OFFSET, 1);
-       OUT_RELOCl(nv10->rt[0], 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+//     BEGIN_RING(chan, celsius, NV10TCL_DMA_COLOR0, 1);
+//     OUT_RELOCo(chan, rt_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+       BEGIN_RING(chan, celsius, NV10TCL_COLOR_OFFSET, 1);
+       OUT_RELOCl(chan, rt_bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
 
        if (nv10->zeta) {
+               struct nouveau_bo *zeta_bo = nouveau_bo(nv10->zeta);
 // XXX
-//             BEGIN_RING(celsius, NV10TCL_DMA_ZETA, 1);
-//             OUT_RELOCo(nv10->zeta, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
-               BEGIN_RING(celsius, NV10TCL_ZETA_OFFSET, 1);
-               OUT_RELOCl(nv10->zeta, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+//             BEGIN_RING(chan, celsius, NV10TCL_DMA_ZETA, 1);
+//             OUT_RELOCo(chan, zeta_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+               BEGIN_RING(chan, celsius, NV10TCL_ZETA_OFFSET, 1);
+               OUT_RELOCl(chan, zeta_bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
                /* XXX for when we allocate LMA on nv17 */
-/*             BEGIN_RING(celsius, NV10TCL_LMA_DEPTH_BUFFER_OFFSET, 1);
-               OUT_RELOCl(nv10->zeta + lma_offset);*/
+/*             BEGIN_RING(chan, celsius, NV10TCL_LMA_DEPTH_BUFFER_OFFSET, 1);
+               OUT_RELOCl(chan, nouveau_bo(nv10->zeta + lma_offset));*/
        }
 
        /* Vertex buffer */
-       BEGIN_RING(celsius, NV10TCL_DMA_VTXBUF0, 1);
-       OUT_RELOCo(nv10->rt[0], NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
-       BEGIN_RING(celsius, NV10TCL_COLOR_OFFSET, 1);
-       OUT_RELOCl(nv10->rt[0], 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+       BEGIN_RING(chan, celsius, NV10TCL_DMA_VTXBUF0, 1);
+       OUT_RELOCo(chan, rt_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+       BEGIN_RING(chan, celsius, NV10TCL_COLOR_OFFSET, 1);
+       OUT_RELOCl(chan, rt_bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
 
        /* Texture images */
        for (i = 0; i < 2; i++) {
                if (!(nv10->fp_samplers & (1 << i)))
                        continue;
-               BEGIN_RING(celsius, NV10TCL_TX_OFFSET(i), 1);
-               OUT_RELOCl(nv10->tex[i].buffer, 0, NOUVEAU_BO_VRAM |
+               struct nouveau_bo *bo = nouveau_bo(nv10->tex[i].buffer);
+               BEGIN_RING(chan, celsius, NV10TCL_TX_OFFSET(i), 1);
+               OUT_RELOCl(chan, bo, 0, NOUVEAU_BO_VRAM |
                           NOUVEAU_BO_GART | NOUVEAU_BO_RD);
-               BEGIN_RING(celsius, NV10TCL_TX_FORMAT(i), 1);
-               OUT_RELOCd(nv10->tex[i].buffer, nv10->tex[i].format,
+               BEGIN_RING(chan, celsius, NV10TCL_TX_FORMAT(i), 1);
+               OUT_RELOCd(chan, bo, nv10->tex[i].format,
                           NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD |
                           NOUVEAU_BO_OR, NV10TCL_TX_FORMAT_DMA0,
                           NV10TCL_TX_FORMAT_DMA1);
index 8feb85e4bda22eb33837d7002fd0777cf9edd0ca..eb04af9782eed62b06782f956fda3e178fc942b0 100644 (file)
@@ -1,7 +1,9 @@
 #include <pipe/p_state.h>
 #include <pipe/p_defines.h>
 #include <pipe/p_inlines.h>
+#include <util/u_format.h>
 #include <util/u_memory.h>
+#include <util/u_math.h>
 #include <nouveau/nouveau_winsys.h>
 #include "nv10_context.h"
 #include "nv10_screen.h"
 struct nv10_transfer {
        struct pipe_transfer base;
        struct pipe_surface *surface;
-       bool direct;
+       boolean direct;
 };
 
 static void
-nv10_compatible_transfer_tex(struct pipe_texture *pt, unsigned level,
+nv10_compatible_transfer_tex(struct pipe_texture *pt, unsigned width, unsigned height,
                              struct pipe_texture *template)
 {
        memset(template, 0, sizeof(struct pipe_texture));
        template->target = pt->target;
        template->format = pt->format;
-       template->width[0] = pt->width[level];
-       template->height[0] = pt->height[level];
-       template->depth[0] = 1;
-       template->block = pt->block;
-       template->nblocksx[0] = pt->nblocksx[level];
-       template->nblocksy[0] = pt->nblocksx[level];
+       template->width0 = width;
+       template->height0 = height;
+       template->depth0 = 1;
        template->last_level = 0;
        template->nr_samples = pt->nr_samples;
 
@@ -48,14 +47,10 @@ nv10_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
                return NULL;
 
        pipe_texture_reference(&tx->base.texture, pt);
-       tx->base.format = pt->format;
        tx->base.x = x;
        tx->base.y = y;
        tx->base.width = w;
        tx->base.height = h;
-       tx->base.block = pt->block;
-       tx->base.nblocksx = pt->nblocksx[level];
-       tx->base.nblocksy = pt->nblocksy[level];
        tx->base.stride = mt->level[level].pitch;
        tx->base.usage = usage;
        tx->base.face = face;
@@ -76,7 +71,7 @@ nv10_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
 
        tx->direct = false;
 
-       nv10_compatible_transfer_tex(pt, level, &tx_tex_template);
+       nv10_compatible_transfer_tex(pt, w, h, &tx_tex_template);
 
        tx_tex = pscreen->texture_create(pscreen, &tx_tex_template);
        if (!tx_tex)
@@ -85,6 +80,8 @@ nv10_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
                return NULL;
        }
 
+       tx->base.stride = ((struct nv10_miptree*)tx_tex)->level[0].pitch;
+
        tx->surface = pscreen->get_tex_surface(pscreen, tx_tex,
                                               face, level, zslice,
                                               pipe_transfer_buffer_flags(&tx->base));
@@ -110,8 +107,8 @@ nv10_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
                /* TODO: Check if SIFM can un-swizzle */
                nvscreen->eng2d->copy(nvscreen->eng2d,
                                      tx->surface, 0, 0,
-                                     src, 0, 0,
-                                     src->width, src->height);
+                                     src, x, y,
+                                     w, h);
 
                pipe_surface_reference(&src, NULL);
        }
@@ -135,9 +132,9 @@ nv10_transfer_del(struct pipe_transfer *ptx)
 
                /* TODO: Check if SIFM can deal with x,y,w,h when swizzling */
                nvscreen->eng2d->copy(nvscreen->eng2d,
-                                     dst, 0, 0,
+                                     dst, tx->base.x, tx->base.y,
                                      tx->surface, 0, 0,
-                                     dst->width, dst->height);
+                                     tx->base.width, tx->base.height);
 
                pipe_surface_reference(&dst, NULL);
        }
@@ -156,8 +153,10 @@ nv10_transfer_map(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
        void *map = pipe_buffer_map(pscreen, mt->buffer,
                                    pipe_transfer_buffer_flags(ptx));
 
-       return map + ns->base.offset +
-              ptx->y * ns->pitch + ptx->x * ptx->block.size;
+       if(!tx->direct)
+               return map + ns->base.offset;
+       else
+               return map + ns->base.offset + ptx->y * ns->pitch + ptx->x * util_format_get_blocksize(ptx->texture->format);
 }
 
 static void
index 441a4f75f3f84ddfde01116b4ed01d44e1b16b0a..9180c72c9b09f4041859e1a7bf99679643d006bd 100644 (file)
@@ -9,7 +9,7 @@
 #include "nouveau/nouveau_channel.h"
 #include "nouveau/nouveau_pushbuf.h"
 
-boolean nv10_draw_elements( struct pipe_context *pipe,
+void nv10_draw_elements( struct pipe_context *pipe,
                     struct pipe_buffer *indexBuffer,
                     unsigned indexSize,
                     unsigned prim, unsigned start, unsigned count)
@@ -45,6 +45,7 @@ boolean nv10_draw_elements( struct pipe_context *pipe,
        }
 
        draw_set_mapped_constant_buffer(draw,
+                                        PIPE_SHADER_VERTEX,
                                        nv10->constbuf[PIPE_SHADER_VERTEX],
                                        nv10->constbuf_nr[PIPE_SHADER_VERTEX]);
 
@@ -64,14 +65,12 @@ boolean nv10_draw_elements( struct pipe_context *pipe,
                pipe_buffer_unmap(pscreen, indexBuffer);
                draw_set_mapped_element_buffer(draw, 0, NULL);
        }
-
-       return TRUE;
 }
 
-boolean nv10_draw_arrays( struct pipe_context *pipe,
-                                unsigned prim, unsigned start, unsigned count)
+void nv10_draw_arrays( struct pipe_context *pipe,
+                       unsigned prim, unsigned start, unsigned count)
 {
-       return nv10_draw_elements(pipe, NULL, 0, prim, start, count);
+       nv10_draw_elements(pipe, NULL, 0, prim, start, count);
 }
 
 
index b32d0d83ba0642fd111352c74be272447c866277..5b80af2d22a2088e2622d15313b2d3a421f885d6 100644 (file)
@@ -10,10 +10,14 @@ nv20_flush(struct pipe_context *pipe, unsigned flags,
           struct pipe_fence_handle **fence)
 {
        struct nv20_context *nv20 = nv20_context(pipe);
+       struct nv20_screen *screen = nv20->screen;
+       struct nouveau_channel *chan = screen->base.channel;
 
        draw_flush(nv20->draw);
 
-       FIRE_RING(fence);
+       FIRE_RING(chan);
+       if (fence)
+               *fence = NULL;
 }
 
 static void
@@ -31,377 +35,352 @@ static void nv20_init_hwctx(struct nv20_context *nv20)
 {
        struct nv20_screen *screen = nv20->screen;
        struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *kelvin = screen->kelvin;
        int i;
        float projectionmatrix[16];
-       const boolean is_nv25tcl = (nv20->screen->kelvin->grclass == NV25TCL);
+       const boolean is_nv25tcl = (kelvin->grclass == NV25TCL);
 
-       BEGIN_RING(kelvin, NV20TCL_DMA_NOTIFY, 1);
-       OUT_RING  (screen->sync->handle);
-       BEGIN_RING(kelvin, NV20TCL_DMA_TEXTURE0, 2);
-       OUT_RING  (chan->vram->handle);
-       OUT_RING  (chan->gart->handle); /* TEXTURE1 */
-       BEGIN_RING(kelvin, NV20TCL_DMA_COLOR, 2);
-       OUT_RING  (chan->vram->handle);
-       OUT_RING  (chan->vram->handle); /* ZETA */
+       BEGIN_RING(chan, kelvin, NV20TCL_DMA_NOTIFY, 1);
+       OUT_RING  (chan, screen->sync->handle);
+       BEGIN_RING(chan, kelvin, NV20TCL_DMA_TEXTURE0, 2);
+       OUT_RING  (chan, chan->vram->handle);
+       OUT_RING  (chan, chan->gart->handle); /* TEXTURE1 */
+       BEGIN_RING(chan, kelvin, NV20TCL_DMA_COLOR, 2);
+       OUT_RING  (chan, chan->vram->handle);
+       OUT_RING  (chan, chan->vram->handle); /* ZETA */
 
-       BEGIN_RING(kelvin, NV20TCL_DMA_QUERY, 1);
-       OUT_RING  (0); /* renouveau: beef0351, unique */
+       BEGIN_RING(chan, kelvin, NV20TCL_DMA_QUERY, 1);
+       OUT_RING  (chan, 0); /* renouveau: beef0351, unique */
 
-       BEGIN_RING(kelvin, NV20TCL_RT_HORIZ, 2);
-       OUT_RING  (0);
-       OUT_RING  (0);
+       BEGIN_RING(chan, kelvin, NV20TCL_RT_HORIZ, 2);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 0);
 
-       BEGIN_RING(kelvin, NV20TCL_VIEWPORT_CLIP_HORIZ(0), 1);
-       OUT_RING  ((0xfff << 16) | 0x0);
-       BEGIN_RING(kelvin, NV20TCL_VIEWPORT_CLIP_VERT(0), 1);
-       OUT_RING  ((0xfff << 16) | 0x0);
+       BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_CLIP_HORIZ(0), 1);
+       OUT_RING  (chan, (0xfff << 16) | 0x0);
+       BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_CLIP_VERT(0), 1);
+       OUT_RING  (chan, (0xfff << 16) | 0x0);
 
        for (i = 1; i < NV20TCL_VIEWPORT_CLIP_HORIZ__SIZE; i++) {
-               BEGIN_RING(kelvin, NV20TCL_VIEWPORT_CLIP_HORIZ(i), 1);
-               OUT_RING  (0);
-               BEGIN_RING(kelvin, NV20TCL_VIEWPORT_CLIP_VERT(i), 1);
-               OUT_RING  (0);
+               BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_CLIP_HORIZ(i), 1);
+               OUT_RING  (chan, 0);
+               BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_CLIP_VERT(i), 1);
+               OUT_RING  (chan, 0);
        }
 
-       BEGIN_RING(kelvin, NV20TCL_VIEWPORT_CLIP_MODE, 1);
-       OUT_RING  (0);
+       BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_CLIP_MODE, 1);
+       OUT_RING  (chan, 0);
 
-       BEGIN_RING(kelvin, 0x17e0, 3);
-       OUT_RINGf (0.0);
-       OUT_RINGf (0.0);
-       OUT_RINGf (1.0);
+       BEGIN_RING(chan, kelvin, 0x17e0, 3);
+       OUT_RINGf (chan, 0.0);
+       OUT_RINGf (chan, 0.0);
+       OUT_RINGf (chan, 1.0);
 
        if (is_nv25tcl) {
-               BEGIN_RING(kelvin, NV20TCL_TX_RCOMP, 1);
-               OUT_RING  (NV20TCL_TX_RCOMP_LEQUAL | 0xdb0);
+               BEGIN_RING(chan, kelvin, NV20TCL_TX_RCOMP, 1);
+               OUT_RING  (chan, NV20TCL_TX_RCOMP_LEQUAL | 0xdb0);
        } else {
-               BEGIN_RING(kelvin, 0x1e68, 1);
-               OUT_RING  (0x4b800000); /* 16777216.000000 */
-               BEGIN_RING(kelvin, NV20TCL_TX_RCOMP, 1);
-               OUT_RING  (NV20TCL_TX_RCOMP_LEQUAL);
+               BEGIN_RING(chan, kelvin, 0x1e68, 1);
+               OUT_RING  (chan, 0x4b800000); /* 16777216.000000 */
+               BEGIN_RING(chan, kelvin, NV20TCL_TX_RCOMP, 1);
+               OUT_RING  (chan, NV20TCL_TX_RCOMP_LEQUAL);
        }
 
-       BEGIN_RING(kelvin, 0x290, 1);
-       OUT_RING  ((0x10 << 16) | 1);
-       BEGIN_RING(kelvin, 0x9fc, 1);
-       OUT_RING  (0);
-       BEGIN_RING(kelvin, 0x1d80, 1);
-       OUT_RING  (1);
-       BEGIN_RING(kelvin, 0x9f8, 1);
-       OUT_RING  (4);
-       BEGIN_RING(kelvin, 0x17ec, 3);
-       OUT_RINGf (0.0);
-       OUT_RINGf (1.0);
-       OUT_RINGf (0.0);
+       BEGIN_RING(chan, kelvin, 0x290, 1);
+       OUT_RING  (chan, (0x10 << 16) | 1);
+       BEGIN_RING(chan, kelvin, 0x9fc, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, kelvin, 0x1d80, 1);
+       OUT_RING  (chan, 1);
+       BEGIN_RING(chan, kelvin, 0x9f8, 1);
+       OUT_RING  (chan, 4);
+       BEGIN_RING(chan, kelvin, 0x17ec, 3);
+       OUT_RINGf (chan, 0.0);
+       OUT_RINGf (chan, 1.0);
+       OUT_RINGf (chan, 0.0);
 
        if (is_nv25tcl) {
-               BEGIN_RING(kelvin, 0x1d88, 1);
-               OUT_RING  (3);
+               BEGIN_RING(chan, kelvin, 0x1d88, 1);
+               OUT_RING  (chan, 3);
 
-               BEGIN_RING(kelvin, NV25TCL_DMA_IN_MEMORY9, 1);
-               OUT_RING  (chan->vram->handle);
-               BEGIN_RING(kelvin, NV25TCL_DMA_IN_MEMORY8, 1);
-               OUT_RING  (chan->vram->handle);
+               BEGIN_RING(chan, kelvin, NV25TCL_DMA_IN_MEMORY9, 1);
+               OUT_RING  (chan, chan->vram->handle);
+               BEGIN_RING(chan, kelvin, NV25TCL_DMA_IN_MEMORY8, 1);
+               OUT_RING  (chan, chan->vram->handle);
        }
-       BEGIN_RING(kelvin, NV20TCL_DMA_FENCE, 1);
-       OUT_RING  (0);  /* renouveau: beef1e10 */
+       BEGIN_RING(chan, kelvin, NV20TCL_DMA_FENCE, 1);
+       OUT_RING  (chan, 0);    /* renouveau: beef1e10 */
 
-       BEGIN_RING(kelvin, 0x1e98, 1);
-       OUT_RING  (0);
+       BEGIN_RING(chan, kelvin, 0x1e98, 1);
+       OUT_RING  (chan, 0);
 #if 0
        if (is_nv25tcl) {
-               BEGIN_RING(NvSub3D, NV25TCL_DMA_IN_MEMORY4, 2);
-               OUT_RING  (NvDmaTT);    /* renouveau: beef0202 */
-               OUT_RING  (NvDmaFB);    /* renouveau: beef0201 */
+               BEGIN_RING(chan, NvSub3D, NV25TCL_DMA_IN_MEMORY4, 2);
+               OUT_RING  (chan, NvDmaTT);      /* renouveau: beef0202 */
+               OUT_RING  (chan, NvDmaFB);      /* renouveau: beef0201 */
 
-               BEGIN_RING(NvSub3D, NV20TCL_DMA_TEXTURE1, 1);
-               OUT_RING  (NvDmaTT);    /* renouveau: beef0202 */
+               BEGIN_RING(chan, NvSub3D, NV20TCL_DMA_TEXTURE1, 1);
+               OUT_RING  (chan, NvDmaTT);      /* renouveau: beef0202 */
        }
 #endif
-       BEGIN_RING(kelvin, NV20TCL_NOTIFY, 1);
-       OUT_RING  (0);
+       BEGIN_RING(chan, kelvin, NV20TCL_NOTIFY, 1);
+       OUT_RING  (chan, 0);
 
-       BEGIN_RING(kelvin, 0x120, 3);
-       OUT_RING  (0);
-       OUT_RING  (1);
-       OUT_RING  (2);
+       BEGIN_RING(chan, kelvin, 0x120, 3);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 1);
+       OUT_RING  (chan, 2);
 
 /* error: ILLEGAL_MTHD, PROTECTION_FAULT
-       BEGIN_RING(kelvin, NV20TCL_VIEWPORT_TRANSLATE_X, 4);
-       OUT_RINGf (0.0);
-       OUT_RINGf (512.0);
-       OUT_RINGf (0.0);
-       OUT_RINGf (0.0);
+       BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_TRANSLATE_X, 4);
+       OUT_RINGf (chan, 0.0);
+       OUT_RINGf (chan, 512.0);
+       OUT_RINGf (chan, 0.0);
+       OUT_RINGf (chan, 0.0);
 */
 
        if (is_nv25tcl) {
-               BEGIN_RING(kelvin, 0x022c, 2);
-               OUT_RING  (0x280);
-               OUT_RING  (0x07d28000);
+               BEGIN_RING(chan, kelvin, 0x022c, 2);
+               OUT_RING  (chan, 0x280);
+               OUT_RING  (chan, 0x07d28000);
        }
 
 /* * illegal method, protection fault
-       BEGIN_RING(NvSub3D, 0x1c2c, 1);
-       OUT_RING  (0); */
+       BEGIN_RING(chan, NvSub3D, 0x1c2c, 1);
+       OUT_RING  (chan, 0); */
 
        if (is_nv25tcl) {
-               BEGIN_RING(kelvin, 0x1da4, 1);
-               OUT_RING  (0);
+               BEGIN_RING(chan, kelvin, 0x1da4, 1);
+               OUT_RING  (chan, 0);
        }
 
 /* * crashes with illegal method, protection fault
-       BEGIN_RING(NvSub3D, 0x1c18, 1);
-       OUT_RING  (0x200); */
+       BEGIN_RING(chan, NvSub3D, 0x1c18, 1);
+       OUT_RING  (chan, 0x200); */
 
-       BEGIN_RING(kelvin, NV20TCL_RT_HORIZ, 2);
-       OUT_RING  ((0 << 16) | 0);
-       OUT_RING  ((0 << 16) | 0);
+       BEGIN_RING(chan, kelvin, NV20TCL_RT_HORIZ, 2);
+       OUT_RING  (chan, (0 << 16) | 0);
+       OUT_RING  (chan, (0 << 16) | 0);
 
        /* *** Set state *** */
 
-       BEGIN_RING(kelvin, NV20TCL_ALPHA_FUNC_ENABLE, 1);
-       OUT_RING  (0);
-       BEGIN_RING(kelvin, NV20TCL_ALPHA_FUNC_FUNC, 2);
-       OUT_RING  (NV20TCL_ALPHA_FUNC_FUNC_ALWAYS);
-       OUT_RING  (0);                  /* NV20TCL_ALPHA_FUNC_REF */
+       BEGIN_RING(chan, kelvin, NV20TCL_ALPHA_FUNC_ENABLE, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, kelvin, NV20TCL_ALPHA_FUNC_FUNC, 2);
+       OUT_RING  (chan, NV20TCL_ALPHA_FUNC_FUNC_ALWAYS);
+       OUT_RING  (chan, 0);                    /* NV20TCL_ALPHA_FUNC_REF */
 
        for (i = 0; i < NV20TCL_TX_ENABLE__SIZE; ++i) {
-               BEGIN_RING(kelvin, NV20TCL_TX_ENABLE(i), 1);
-               OUT_RING  (0);
+               BEGIN_RING(chan, kelvin, NV20TCL_TX_ENABLE(i), 1);
+               OUT_RING  (chan, 0);
        }
-       BEGIN_RING(kelvin, NV20TCL_TX_SHADER_OP, 1);
-       OUT_RING  (0);
-       BEGIN_RING(kelvin, NV20TCL_TX_SHADER_CULL_MODE, 1);
-       OUT_RING  (0);
-       BEGIN_RING(kelvin, NV20TCL_RC_IN_ALPHA(0), 4);
-       OUT_RING  (0x30d410d0);
-       OUT_RING  (0);
-       OUT_RING  (0);
-       OUT_RING  (0);
-       BEGIN_RING(kelvin, NV20TCL_RC_OUT_RGB(0), 4);
-       OUT_RING  (0x00000c00);
-       OUT_RING  (0);
-       OUT_RING  (0);
-       OUT_RING  (0);
-       BEGIN_RING(kelvin, NV20TCL_RC_ENABLE, 1);
-       OUT_RING  (0x00011101);
-       BEGIN_RING(kelvin, NV20TCL_RC_FINAL0, 2);
-       OUT_RING  (0x130e0300);
-       OUT_RING  (0x0c091c80);
-       BEGIN_RING(kelvin, NV20TCL_RC_OUT_ALPHA(0), 4);
-       OUT_RING  (0x00000c00);
-       OUT_RING  (0);
-       OUT_RING  (0);
-       OUT_RING  (0);
-       BEGIN_RING(kelvin, NV20TCL_RC_IN_RGB(0), 4);
-       OUT_RING  (0x20c400c0);
-       OUT_RING  (0);
-       OUT_RING  (0);
-       OUT_RING  (0);
-       BEGIN_RING(kelvin, NV20TCL_RC_COLOR0, 2);
-       OUT_RING  (0);
-       OUT_RING  (0);
-       BEGIN_RING(kelvin, NV20TCL_RC_CONSTANT_COLOR0(0), 4);
-       OUT_RING  (0x035125a0);
-       OUT_RING  (0);
-       OUT_RING  (0x40002000);
-       OUT_RING  (0);
-       BEGIN_RING(kelvin, NV20TCL_MULTISAMPLE_CONTROL, 1);
-       OUT_RING  (0xffff0000);
-
-       BEGIN_RING(kelvin, NV20TCL_BLEND_FUNC_ENABLE, 1);
-       OUT_RING  (0);
-       BEGIN_RING(kelvin, NV20TCL_DITHER_ENABLE, 1);
-       OUT_RING  (0);
-       BEGIN_RING(kelvin, NV20TCL_STENCIL_ENABLE, 1);
-       OUT_RING  (0);
-       BEGIN_RING(kelvin, NV20TCL_BLEND_FUNC_SRC, 4);
-       OUT_RING  (NV20TCL_BLEND_FUNC_SRC_ONE);
-       OUT_RING  (NV20TCL_BLEND_FUNC_DST_ZERO);
-       OUT_RING  (0);                  /* NV20TCL_BLEND_COLOR */
-       OUT_RING  (NV20TCL_BLEND_EQUATION_FUNC_ADD);
-       BEGIN_RING(kelvin, NV20TCL_STENCIL_MASK, 7);
-       OUT_RING  (0xff);
-       OUT_RING  (NV20TCL_STENCIL_FUNC_FUNC_ALWAYS);
-       OUT_RING  (0);                  /* NV20TCL_STENCIL_FUNC_REF */
-       OUT_RING  (0xff);               /* NV20TCL_STENCIL_FUNC_MASK */
-       OUT_RING  (NV20TCL_STENCIL_OP_FAIL_KEEP);
-       OUT_RING  (NV20TCL_STENCIL_OP_ZFAIL_KEEP);
-       OUT_RING  (NV20TCL_STENCIL_OP_ZPASS_KEEP);
-
-       BEGIN_RING(kelvin, NV20TCL_COLOR_LOGIC_OP_ENABLE, 2);
-       OUT_RING  (0);
-       OUT_RING  (NV20TCL_COLOR_LOGIC_OP_OP_COPY);
-       BEGIN_RING(kelvin, 0x17cc, 1);
-       OUT_RING  (0);
+       BEGIN_RING(chan, kelvin, NV20TCL_TX_SHADER_OP, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, kelvin, NV20TCL_TX_SHADER_CULL_MODE, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, kelvin, NV20TCL_RC_IN_ALPHA(0), 4);
+       OUT_RING  (chan, 0x30d410d0);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, kelvin, NV20TCL_RC_OUT_RGB(0), 4);
+       OUT_RING  (chan, 0x00000c00);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, kelvin, NV20TCL_RC_ENABLE, 1);
+       OUT_RING  (chan, 0x00011101);
+       BEGIN_RING(chan, kelvin, NV20TCL_RC_FINAL0, 2);
+       OUT_RING  (chan, 0x130e0300);
+       OUT_RING  (chan, 0x0c091c80);
+       BEGIN_RING(chan, kelvin, NV20TCL_RC_OUT_ALPHA(0), 4);
+       OUT_RING  (chan, 0x00000c00);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, kelvin, NV20TCL_RC_IN_RGB(0), 4);
+       OUT_RING  (chan, 0x20c400c0);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, kelvin, NV20TCL_RC_COLOR0, 2);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, kelvin, NV20TCL_RC_CONSTANT_COLOR0(0), 4);
+       OUT_RING  (chan, 0x035125a0);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 0x40002000);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, kelvin, NV20TCL_MULTISAMPLE_CONTROL, 1);
+       OUT_RING  (chan, 0xffff0000);
+
+       BEGIN_RING(chan, kelvin, NV20TCL_BLEND_FUNC_ENABLE, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, kelvin, NV20TCL_DITHER_ENABLE, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, kelvin, NV20TCL_STENCIL_ENABLE, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, kelvin, NV20TCL_BLEND_FUNC_SRC, 4);
+       OUT_RING  (chan, NV20TCL_BLEND_FUNC_SRC_ONE);
+       OUT_RING  (chan, NV20TCL_BLEND_FUNC_DST_ZERO);
+       OUT_RING  (chan, 0);                    /* NV20TCL_BLEND_COLOR */
+       OUT_RING  (chan, NV20TCL_BLEND_EQUATION_FUNC_ADD);
+       BEGIN_RING(chan, kelvin, NV20TCL_STENCIL_MASK, 7);
+       OUT_RING  (chan, 0xff);
+       OUT_RING  (chan, NV20TCL_STENCIL_FUNC_FUNC_ALWAYS);
+       OUT_RING  (chan, 0);                    /* NV20TCL_STENCIL_FUNC_REF */
+       OUT_RING  (chan, 0xff);         /* NV20TCL_STENCIL_FUNC_MASK */
+       OUT_RING  (chan, NV20TCL_STENCIL_OP_FAIL_KEEP);
+       OUT_RING  (chan, NV20TCL_STENCIL_OP_ZFAIL_KEEP);
+       OUT_RING  (chan, NV20TCL_STENCIL_OP_ZPASS_KEEP);
+
+       BEGIN_RING(chan, kelvin, NV20TCL_COLOR_LOGIC_OP_ENABLE, 2);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, NV20TCL_COLOR_LOGIC_OP_OP_COPY);
+       BEGIN_RING(chan, kelvin, 0x17cc, 1);
+       OUT_RING  (chan, 0);
        if (is_nv25tcl) {
-               BEGIN_RING(kelvin, 0x1d84, 1);
-               OUT_RING  (1);
+               BEGIN_RING(chan, kelvin, 0x1d84, 1);
+               OUT_RING  (chan, 1);
        }
-       BEGIN_RING(kelvin, NV20TCL_LIGHTING_ENABLE, 1);
-       OUT_RING  (0);
-       BEGIN_RING(kelvin, NV20TCL_LIGHT_CONTROL, 1);
-       OUT_RING  (0x00020000);
-       BEGIN_RING(kelvin, NV20TCL_SEPARATE_SPECULAR_ENABLE, 1);
-       OUT_RING  (0);
-       BEGIN_RING(kelvin, NV20TCL_LIGHT_MODEL_TWO_SIDE_ENABLE, 1);
-       OUT_RING  (0);
-       BEGIN_RING(kelvin, NV20TCL_ENABLED_LIGHTS, 1);
-       OUT_RING  (0);
-       BEGIN_RING(kelvin, NV20TCL_NORMALIZE_ENABLE, 1);
-       OUT_RING  (0);
-       BEGIN_RING(kelvin, NV20TCL_POLYGON_STIPPLE_PATTERN(0),
+       BEGIN_RING(chan, kelvin, NV20TCL_LIGHTING_ENABLE, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, kelvin, NV20TCL_LIGHT_CONTROL, 1);
+       OUT_RING  (chan, 0x00020000);
+       BEGIN_RING(chan, kelvin, NV20TCL_SEPARATE_SPECULAR_ENABLE, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, kelvin, NV20TCL_LIGHT_MODEL_TWO_SIDE_ENABLE, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, kelvin, NV20TCL_ENABLED_LIGHTS, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, kelvin, NV20TCL_NORMALIZE_ENABLE, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_STIPPLE_PATTERN(0),
                                        NV20TCL_POLYGON_STIPPLE_PATTERN__SIZE);
        for (i = 0; i < NV20TCL_POLYGON_STIPPLE_PATTERN__SIZE; ++i) {
-               OUT_RING(0xffffffff);
+               OUT_RING(chan, 0xffffffff);
        }
 
-       BEGIN_RING(kelvin, NV20TCL_POLYGON_OFFSET_POINT_ENABLE, 3);
-       OUT_RING  (0);
-       OUT_RING  (0);          /* NV20TCL.POLYGON_OFFSET_LINE_ENABLE */
-       OUT_RING  (0);          /* NV20TCL.POLYGON_OFFSET_FILL_ENABLE */
-       BEGIN_RING(kelvin, NV20TCL_DEPTH_FUNC, 1);
-       OUT_RING  (NV20TCL_DEPTH_FUNC_LESS);
-       BEGIN_RING(kelvin, NV20TCL_DEPTH_WRITE_ENABLE, 1);
-       OUT_RING  (0);
-       BEGIN_RING(kelvin, NV20TCL_DEPTH_TEST_ENABLE, 1);
-       OUT_RING  (0);
-       BEGIN_RING(kelvin, NV20TCL_POLYGON_OFFSET_FACTOR, 2);
-       OUT_RINGf (0.0);
-       OUT_RINGf (0.0);        /* NV20TCL.POLYGON_OFFSET_UNITS */
-       BEGIN_RING(kelvin, NV20TCL_DEPTH_UNK17D8, 1);
-       OUT_RING  (1);
+       BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_OFFSET_POINT_ENABLE, 3);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 0);            /* NV20TCL.POLYGON_OFFSET_LINE_ENABLE */
+       OUT_RING  (chan, 0);            /* NV20TCL.POLYGON_OFFSET_FILL_ENABLE */
+       BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_FUNC, 1);
+       OUT_RING  (chan, NV20TCL_DEPTH_FUNC_LESS);
+       BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_WRITE_ENABLE, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_TEST_ENABLE, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_OFFSET_FACTOR, 2);
+       OUT_RINGf (chan, 0.0);
+       OUT_RINGf (chan, 0.0);  /* NV20TCL.POLYGON_OFFSET_UNITS */
+       BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_UNK17D8, 1);
+       OUT_RING  (chan, 1);
        if (!is_nv25tcl) {
-               BEGIN_RING(kelvin, 0x1d84, 1);
-               OUT_RING  (3);
+               BEGIN_RING(chan, kelvin, 0x1d84, 1);
+               OUT_RING  (chan, 3);
        }
-       BEGIN_RING(kelvin, NV20TCL_POINT_SIZE, 1);
+       BEGIN_RING(chan, kelvin, NV20TCL_POINT_SIZE, 1);
        if (!is_nv25tcl) {
-               OUT_RING  (8);
+               OUT_RING  (chan, 8);
        } else {
-               OUT_RINGf (1.0);
+               OUT_RINGf (chan, 1.0);
        }
        if (!is_nv25tcl) {
-               BEGIN_RING(kelvin, NV20TCL_POINT_PARAMETERS_ENABLE, 2);
-               OUT_RING  (0);
-               OUT_RING  (0);          /* NV20TCL.POINT_SMOOTH_ENABLE */
+               BEGIN_RING(chan, kelvin, NV20TCL_POINT_PARAMETERS_ENABLE, 2);
+               OUT_RING  (chan, 0);
+               OUT_RING  (chan, 0);            /* NV20TCL.POINT_SMOOTH_ENABLE */
        } else {
-               BEGIN_RING(kelvin, NV20TCL_POINT_PARAMETERS_ENABLE, 1);
-               OUT_RING  (0);
-               BEGIN_RING(kelvin, 0x0a1c, 1);
-               OUT_RING  (0x800);
+               BEGIN_RING(chan, kelvin, NV20TCL_POINT_PARAMETERS_ENABLE, 1);
+               OUT_RING  (chan, 0);
+               BEGIN_RING(chan, kelvin, 0x0a1c, 1);
+               OUT_RING  (chan, 0x800);
        }
-       BEGIN_RING(kelvin, NV20TCL_LINE_WIDTH, 1);
-       OUT_RING  (8);
-       BEGIN_RING(kelvin, NV20TCL_LINE_SMOOTH_ENABLE, 1);
-       OUT_RING  (0);
-       BEGIN_RING(kelvin, NV20TCL_POLYGON_MODE_FRONT, 2);
-       OUT_RING  (NV20TCL_POLYGON_MODE_FRONT_FILL);
-       OUT_RING  (NV20TCL_POLYGON_MODE_BACK_FILL);
-       BEGIN_RING(kelvin, NV20TCL_CULL_FACE, 2);
-       OUT_RING  (NV20TCL_CULL_FACE_BACK);
-       OUT_RING  (NV20TCL_FRONT_FACE_CCW);
-       BEGIN_RING(kelvin, NV20TCL_POLYGON_SMOOTH_ENABLE, 1);
-       OUT_RING  (0);
-       BEGIN_RING(kelvin, NV20TCL_CULL_FACE_ENABLE, 1);
-       OUT_RING  (0);
-       BEGIN_RING(kelvin, NV20TCL_SHADE_MODEL, 1);
-       OUT_RING  (NV20TCL_SHADE_MODEL_SMOOTH);
-       BEGIN_RING(kelvin, NV20TCL_POLYGON_STIPPLE_ENABLE, 1);
-       OUT_RING  (0);
-       BEGIN_RING(kelvin, NV20TCL_TX_GEN_S(0), 4 * NV20TCL_TX_GEN_S__SIZE);
+       BEGIN_RING(chan, kelvin, NV20TCL_LINE_WIDTH, 1);
+       OUT_RING  (chan, 8);
+       BEGIN_RING(chan, kelvin, NV20TCL_LINE_SMOOTH_ENABLE, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_MODE_FRONT, 2);
+       OUT_RING  (chan, NV20TCL_POLYGON_MODE_FRONT_FILL);
+       OUT_RING  (chan, NV20TCL_POLYGON_MODE_BACK_FILL);
+       BEGIN_RING(chan, kelvin, NV20TCL_CULL_FACE, 2);
+       OUT_RING  (chan, NV20TCL_CULL_FACE_BACK);
+       OUT_RING  (chan, NV20TCL_FRONT_FACE_CCW);
+       BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_SMOOTH_ENABLE, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, kelvin, NV20TCL_CULL_FACE_ENABLE, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, kelvin, NV20TCL_SHADE_MODEL, 1);
+       OUT_RING  (chan, NV20TCL_SHADE_MODEL_SMOOTH);
+       BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_STIPPLE_ENABLE, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, kelvin, NV20TCL_TX_GEN_S(0), 4 * NV20TCL_TX_GEN_S__SIZE);
        for (i=0; i < 4 * NV20TCL_TX_GEN_S__SIZE; ++i) {
-               OUT_RING(0);
+               OUT_RING(chan, 0);
        }
-       BEGIN_RING(kelvin, NV20TCL_FOG_EQUATION_CONSTANT, 3);
-       OUT_RINGf (1.5);
-       OUT_RINGf (-0.090168);          /* NV20TCL.FOG_EQUATION_LINEAR */
-       OUT_RINGf (0.0);                /* NV20TCL.FOG_EQUATION_QUADRATIC */
-       BEGIN_RING(kelvin, NV20TCL_FOG_MODE, 2);
-       OUT_RING  (NV20TCL_FOG_MODE_EXP_2);
-       OUT_RING  (NV20TCL_FOG_COORD_DIST_COORD_FOG);
-       BEGIN_RING(kelvin, NV20TCL_FOG_ENABLE, 2);
-       OUT_RING  (0);
-       OUT_RING  (0);                  /* NV20TCL.FOG_COLOR */
-       BEGIN_RING(kelvin, NV20TCL_ENGINE, 1);
-       OUT_RING  (NV20TCL_ENGINE_FIXED);
+       BEGIN_RING(chan, kelvin, NV20TCL_FOG_EQUATION_CONSTANT, 3);
+       OUT_RINGf (chan, 1.5);
+       OUT_RINGf (chan, -0.090168);            /* NV20TCL.FOG_EQUATION_LINEAR */
+       OUT_RINGf (chan, 0.0);          /* NV20TCL.FOG_EQUATION_QUADRATIC */
+       BEGIN_RING(chan, kelvin, NV20TCL_FOG_MODE, 2);
+       OUT_RING  (chan, NV20TCL_FOG_MODE_EXP_SIGNED);
+       OUT_RING  (chan, NV20TCL_FOG_COORD_FOG);
+       BEGIN_RING(chan, kelvin, NV20TCL_FOG_ENABLE, 2);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 0);                    /* NV20TCL.FOG_COLOR */
+       BEGIN_RING(chan, kelvin, NV20TCL_ENGINE, 1);
+       OUT_RING  (chan, NV20TCL_ENGINE_FIXED);
 
        for (i = 0; i < NV20TCL_TX_MATRIX_ENABLE__SIZE; ++i) {
-               BEGIN_RING(kelvin, NV20TCL_TX_MATRIX_ENABLE(i), 1);
-               OUT_RING  (0);
+               BEGIN_RING(chan, kelvin, NV20TCL_TX_MATRIX_ENABLE(i), 1);
+               OUT_RING  (chan, 0);
        }
 
-       BEGIN_RING(kelvin, NV20TCL_VTX_ATTR_4F_X(1), 4 * 15);
-       OUT_RINGf(1.0); OUT_RINGf(0.0); OUT_RINGf(0.0); OUT_RINGf(1.0);
-       OUT_RINGf(0.0); OUT_RINGf(0.0); OUT_RINGf(1.0); OUT_RINGf(1.0);
-       OUT_RINGf(1.0); OUT_RINGf(1.0); OUT_RINGf(1.0); OUT_RINGf(1.0);
+       BEGIN_RING(chan, kelvin, NV20TCL_VTX_ATTR_4F_X(1), 4 * 15);
+       OUT_RINGf(chan, 1.0); OUT_RINGf(chan, 0.0); OUT_RINGf(chan, 0.0); OUT_RINGf(chan, 1.0);
+       OUT_RINGf(chan, 0.0); OUT_RINGf(chan, 0.0); OUT_RINGf(chan, 1.0); OUT_RINGf(chan, 1.0);
+       OUT_RINGf(chan, 1.0); OUT_RINGf(chan, 1.0); OUT_RINGf(chan, 1.0); OUT_RINGf(chan, 1.0);
        for (i = 4; i < 16; ++i) {
-               OUT_RINGf(0.0); OUT_RINGf(0.0); OUT_RINGf(0.0); OUT_RINGf(1.0);
+               OUT_RINGf(chan, 0.0);
+               OUT_RINGf(chan, 0.0);
+               OUT_RINGf(chan, 0.0);
+               OUT_RINGf(chan, 1.0);
        }
 
-       BEGIN_RING(kelvin, NV20TCL_EDGEFLAG_ENABLE, 1);
-       OUT_RING  (1);
-       BEGIN_RING(kelvin, NV20TCL_COLOR_MASK, 1);
-       OUT_RING (0x00010101);
-       BEGIN_RING(kelvin, NV20TCL_CLEAR_VALUE, 1);
-       OUT_RING (0);
+       BEGIN_RING(chan, kelvin, NV20TCL_EDGEFLAG_ENABLE, 1);
+       OUT_RING  (chan, 1);
+       BEGIN_RING(chan, kelvin, NV20TCL_COLOR_MASK, 1);
+       OUT_RING (chan, 0x00010101);
+       BEGIN_RING(chan, kelvin, NV20TCL_CLEAR_VALUE, 1);
+       OUT_RING (chan, 0);
 
        memset(projectionmatrix, 0, sizeof(projectionmatrix));
        projectionmatrix[0*4+0] = 1.0;
        projectionmatrix[1*4+1] = 1.0;
        projectionmatrix[2*4+2] = 16777215.0;
        projectionmatrix[3*4+3] = 1.0;
-       BEGIN_RING(kelvin, NV20TCL_PROJECTION_MATRIX(0), 16);
+       BEGIN_RING(chan, kelvin, NV20TCL_PROJECTION_MATRIX(0), 16);
        for (i = 0; i < 16; i++) {
-               OUT_RINGf  (projectionmatrix[i]);
+               OUT_RINGf  (chan, projectionmatrix[i]);
        }
 
-       BEGIN_RING(kelvin, NV20TCL_DEPTH_RANGE_NEAR, 2);
-       OUT_RINGf (0.0);
-       OUT_RINGf (16777216.0); /* [0, 1] scaled approx to [0, 2^24] */
-
-       BEGIN_RING(kelvin, NV20TCL_VIEWPORT_SCALE0_X, 4);
-       OUT_RINGf (0.0); /* x-offset, w/2 + 1.031250 */
-       OUT_RINGf (0.0); /* y-offset, h/2 + 0.030762 */
-       OUT_RINGf (0.0);
-       OUT_RINGf (16777215.0);
-
-       BEGIN_RING(kelvin, NV20TCL_VIEWPORT_SCALE1_X, 4);
-       OUT_RINGf (0.0); /* no effect?, w/2 */
-       OUT_RINGf (0.0); /* no effect?, h/2 */
-       OUT_RINGf (16777215.0 * 0.5);
-       OUT_RINGf (65535.0);
+       BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_RANGE_NEAR, 2);
+       OUT_RINGf (chan, 0.0);
+       OUT_RINGf (chan, 16777216.0); /* [0, 1] scaled approx to [0, 2^24] */
 
-       FIRE_RING (NULL);
-}
+       BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_TRANSLATE_X, 4);
+       OUT_RINGf (chan, 0.0); /* x-offset, w/2 + 1.031250 */
+       OUT_RINGf (chan, 0.0); /* y-offset, h/2 + 0.030762 */
+       OUT_RINGf (chan, 0.0);
+       OUT_RINGf (chan, 16777215.0);
 
-static void
-nv20_set_edgeflags(struct pipe_context *pipe, const unsigned *bitfield)
-{
-}
-
-
-static unsigned int
-nv20_is_texture_referenced( struct pipe_context *pipe,
-                           struct pipe_texture *texture,
-                           unsigned face, unsigned level)
-{
-   /**
-    * FIXME: Optimize.
-    */
-
-   return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
-
-static unsigned int
-nv20_is_buffer_referenced( struct pipe_context *pipe,
-                          struct pipe_buffer *buf)
-{
-   /**
-    * FIXME: Optimize.
-    */
+       BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_SCALE_X, 4);
+       OUT_RINGf (chan, 0.0); /* no effect?, w/2 */
+       OUT_RINGf (chan, 0.0); /* no effect?, h/2 */
+       OUT_RINGf (chan, 16777215.0 * 0.5);
+       OUT_RINGf (chan, 65535.0);
 
-   return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
+       FIRE_RING (chan);
 }
 
 struct pipe_context *
@@ -423,14 +402,13 @@ nv20_create(struct pipe_screen *pscreen, unsigned pctx_id)
        nv20->pipe.winsys = ws;
        nv20->pipe.screen = pscreen;
        nv20->pipe.destroy = nv20_destroy;
-       nv20->pipe.set_edgeflags = nv20_set_edgeflags;
        nv20->pipe.draw_arrays = nv20_draw_arrays;
        nv20->pipe.draw_elements = nv20_draw_elements;
        nv20->pipe.clear = nv20_clear;
        nv20->pipe.flush = nv20_flush;
 
-       nv20->pipe.is_texture_referenced = nv20_is_texture_referenced;
-       nv20->pipe.is_buffer_referenced = nv20_is_buffer_referenced;
+       nv20->pipe.is_texture_referenced = nouveau_is_texture_referenced;
+       nv20->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
 
        nv20_init_surface_functions(nv20);
        nv20_init_state_functions(nv20);
index fc932f1f90e13c69c782f15e2b47fb2dadeae045..c7dfadaa311128247b08c7c2a4c9361929d4407f 100644 (file)
 
 #include "nouveau/nouveau_winsys.h"
 #include "nouveau/nouveau_gldefs.h"
-
-#define NOUVEAU_PUSH_CONTEXT(ctx)                                              \
-       struct nv20_screen *ctx = nv20->screen
-#include "nouveau/nouveau_push.h"
+#include "nouveau/nouveau_context.h"
 
 #include "nv20_state.h"
 
@@ -142,9 +139,9 @@ extern void nv20_emit_hw_state(struct nv20_context *nv20);
 extern void nv20_state_tex_update(struct nv20_context *nv20);
 
 /* nv20_vbo.c */
-extern boolean nv20_draw_arrays(struct pipe_context *, unsigned mode,
+extern void nv20_draw_arrays(struct pipe_context *, unsigned mode,
                                unsigned start, unsigned count);
-extern boolean nv20_draw_elements( struct pipe_context *pipe,
+extern void nv20_draw_elements( struct pipe_context *pipe,
                     struct pipe_buffer *indexBuffer,
                     unsigned indexSize,
                     unsigned prim, unsigned start, unsigned count);
index 495a7be9127f85301a593cfec1e14c7ddeaed2aa..dedbec73f390b4194353dcd563ed02fab5fee52c 100644 (file)
@@ -52,6 +52,9 @@ nv20_fragtex_build(struct nv20_context *nv20, int unit)
        struct nv20_miptree *nv20mt = nv20->tex_miptree[unit];
        struct pipe_texture *pt = &nv20mt->base;
        struct nv20_texture_format *tf;
+       struct nv20_screen *screen = nv20->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *kelvin = screen->kelvin;
        uint32_t txf, txs, txp;
 
        tf = nv20_fragtex_format(pt->format);
@@ -62,9 +65,9 @@ nv20_fragtex_build(struct nv20_context *nv20, int unit)
 
        txf  = tf->format << 8;
        txf |= (pt->last_level + 1) << 16;
-       txf |= log2i(pt->width[0]) << 20;
-       txf |= log2i(pt->height[0]) << 24;
-       txf |= log2i(pt->depth[0]) << 28;
+       txf |= log2i(pt->width0) << 20;
+       txf |= log2i(pt->height0) << 24;
+       txf |= log2i(pt->depth0) << 28;
        txf |= 8;
 
        switch (pt->target) {
@@ -82,15 +85,15 @@ nv20_fragtex_build(struct nv20_context *nv20, int unit)
                return;
        }
 
-       BEGIN_RING(kelvin, NV10TCL_TX_OFFSET(unit), 8);
-       OUT_RELOCl(nv20mt->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD);
-       OUT_RELOCd(nv20mt->buffer,txf,NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_OR | NOUVEAU_BO_RD, 1/*VRAM*/,2/*TT*/);
-       OUT_RING  (ps->wrap);
-       OUT_RING  (0x40000000); /* enable */
-       OUT_RING  (txs);
-       OUT_RING  (ps->filt | 0x2000 /* magic */);
-       OUT_RING  ((pt->width[0] << 16) | pt->height[0]);
-       OUT_RING  (ps->bcol);
+       BEGIN_RING(chan, kelvin, NV10TCL_TX_OFFSET(unit), 8);
+       OUT_RELOCl(chan, nouveau_bo(nv20mt->buffer), 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD);
+       OUT_RELOCd(chan, nouveau_bo(nv20mt->buffer),txf,NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_OR | NOUVEAU_BO_RD, 1/*VRAM*/,2/*TT*/);
+       OUT_RING  (chan, ps->wrap);
+       OUT_RING  (chan, 0x40000000); /* enable */
+       OUT_RING  (chan, txs);
+       OUT_RING  (chan, ps->filt | 0x2000 /* magic */);
+       OUT_RING  (chan, (pt->width0 << 16) | pt->height0);
+       OUT_RING  (chan, ps->bcol);
 #endif
 }
 
@@ -99,6 +102,9 @@ nv20_fragtex_bind(struct nv20_context *nv20)
 {
 #if 0
        struct nv20_fragment_program *fp = nv20->fragprog.active;
+       struct nv20_screen *screen = nv20->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *kelvin = screen->kelvin;
        unsigned samplers, unit;
 
        samplers = nv20->fp_samplers & ~fp->samplers;
@@ -106,8 +112,8 @@ nv20_fragtex_bind(struct nv20_context *nv20)
                unit = ffs(samplers) - 1;
                samplers &= ~(1 << unit);
 
-               BEGIN_RING(kelvin, NV10TCL_TX_ENABLE(unit), 1);
-               OUT_RING  (0);
+               BEGIN_RING(chan, kelvin, NV10TCL_TX_ENABLE(unit), 1);
+               OUT_RING  (chan, 0);
        }
 
        samplers = nv20->dirty_samplers & fp->samplers;
index 185fbf53e0f8fb7419fc9bd0939c0fbe9b2433b1..8f7538e7f576af2528ee1383c6f800f5ccab8bdd 100644 (file)
@@ -1,15 +1,18 @@
 #include "pipe/p_state.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_inlines.h"
+#include "util/u_format.h"
+#include "util/u_math.h"
 
 #include "nv20_context.h"
 #include "nv20_screen.h"
+#include "../nv04/nv04_surface_2d.h"
 
 static void
 nv20_miptree_layout(struct nv20_miptree *nv20mt)
 {
        struct pipe_texture *pt = &nv20mt->base;
-       uint width = pt->width[0], height = pt->height[0];
+       uint width = pt->width0;
        uint offset = 0;
        int nr_faces, l, f;
        uint wide_pitch = pt->tex_usage & (PIPE_TEXTURE_USAGE_SAMPLER |
@@ -25,21 +28,15 @@ nv20_miptree_layout(struct nv20_miptree *nv20mt)
        }
        
        for (l = 0; l <= pt->last_level; l++) {
-               pt->width[l] = width;
-               pt->height[l] = height;
-               pt->nblocksx[l] = pf_get_nblocksx(&pt->block, width);
-               pt->nblocksy[l] = pf_get_nblocksy(&pt->block, height);
-
                if (wide_pitch && (pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR))
-                       nv20mt->level[l].pitch = align(pt->width[0] * pt->block.size, 64);
+                       nv20mt->level[l].pitch = align(util_format_get_stride(pt->format, pt->width0), 64);
                else
-                       nv20mt->level[l].pitch = pt->width[l] * pt->block.size;
+                       nv20mt->level[l].pitch = util_format_get_stride(pt->format, width);
 
                nv20mt->level[l].image_offset =
                        CALLOC(nr_faces, sizeof(unsigned));
 
-               width  = MAX2(1, width  >> 1);
-               height = MAX2(1, height >> 1);
+               width  = u_minify(width, 1);
        }
 
        for (f = 0; f < nr_faces; f++) {
@@ -47,14 +44,14 @@ nv20_miptree_layout(struct nv20_miptree *nv20mt)
                        nv20mt->level[l].image_offset[f] = offset;
 
                        if (!(pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR) &&
-                           pt->width[l + 1] > 1 && pt->height[l + 1] > 1)
-                               offset += align(nv20mt->level[l].pitch * pt->height[l], 64);
+                           u_minify(pt->width0, l + 1) > 1 && u_minify(pt->height0, l + 1) > 1)
+                               offset += align(nv20mt->level[l].pitch * u_minify(pt->height0, l), 64);
                        else
-                               offset += nv20mt->level[l].pitch * pt->height[l];
+                               offset += nv20mt->level[l].pitch * u_minify(pt->height0, l);
                }
 
                nv20mt->level[l].image_offset[f] = offset;
-               offset += nv20mt->level[l].pitch * pt->height[l];
+               offset += nv20mt->level[l].pitch * u_minify(pt->height0, l);
        }
 
        nv20mt->total_size = offset;
@@ -68,7 +65,7 @@ nv20_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
 
        /* Only supports 2D, non-mipmapped textures for the moment */
        if (pt->target != PIPE_TEXTURE_2D || pt->last_level != 0 ||
-           pt->depth[0] != 1)
+           pt->depth0 != 1)
                return NULL;
 
        mt = CALLOC_STRUCT(nv20_miptree);
@@ -82,6 +79,7 @@ nv20_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
        mt->level[0].image_offset = CALLOC(1, sizeof(unsigned));
 
        pipe_buffer_reference(&mt->buffer, pb);
+       mt->bo = nouveau_bo(mt->buffer);
        return &mt->base;
 }
 
@@ -100,8 +98,8 @@ nv20_miptree_create(struct pipe_screen *screen, const struct pipe_texture *pt)
        mt->base.screen = screen;
 
        /* Swizzled textures must be POT */
-       if (pt->width[0] & (pt->width[0] - 1) ||
-           pt->height[0] & (pt->height[0] - 1))
+       if (pt->width0 & (pt->width0 - 1) ||
+           pt->height0 & (pt->height0 - 1))
                mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
        else
        if (pt->tex_usage & (PIPE_TEXTURE_USAGE_PRIMARY |
@@ -130,6 +128,12 @@ nv20_miptree_create(struct pipe_screen *screen, const struct pipe_texture *pt)
        if (pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC)
                buf_usage |= PIPE_BUFFER_USAGE_CPU_READ_WRITE;
 
+       /* apparently we can't render to swizzled surfaces smaller than 64 bytes, so make them linear.
+        * If the user did not ask for a render target, they can still render to it, but it will cost them an extra copy.
+        * This also happens for small mipmaps of large textures. */
+       if (pt->tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET && util_format_get_stride(pt->format, pt->width0) < 64)
+               mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
+
        nv20_miptree_layout(mt);
 
        mt->buffer = screen->buffer_create(screen, 256, buf_usage, mt->total_size);
@@ -137,6 +141,7 @@ nv20_miptree_create(struct pipe_screen *screen, const struct pipe_texture *pt)
                FREE(mt);
                return NULL;
        }
+       mt->bo = nouveau_bo(mt->buffer);
        
        return &mt->base;
 }
@@ -167,8 +172,8 @@ nv20_miptree_surface_get(struct pipe_screen *screen, struct pipe_texture *pt,
                return NULL;
        pipe_texture_reference(&ns->base.texture, pt);
        ns->base.format = pt->format;
-       ns->base.width = pt->width[level];
-       ns->base.height = pt->height[level];
+       ns->base.width = u_minify(pt->width0, level);
+       ns->base.height = u_minify(pt->height0, level);
        ns->base.usage = flags;
        pipe_reference_init(&ns->base.reference, 1);
        ns->base.face = face;
@@ -185,12 +190,27 @@ nv20_miptree_surface_get(struct pipe_screen *screen, struct pipe_texture *pt,
                ns->base.offset = nv20mt->level[level].image_offset[0];
        }
 
+       /* create a linear temporary that we can render into if necessary.
+        * Note that ns->pitch is always a multiple of 64 for linear surfaces and swizzled surfaces are POT, so
+        * ns->pitch & 63 is equivalent to (ns->pitch < 64 && swizzled)*/
+       if((ns->pitch & 63) && (ns->base.usage & (PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER)) == PIPE_BUFFER_USAGE_GPU_WRITE)
+               return &nv04_surface_wrap_for_render(screen, ((struct nv20_screen*)screen)->eng2d, ns)->base;
+
        return &ns->base;
 }
 
 static void
 nv20_miptree_surface_destroy(struct pipe_surface *ps)
 {
+       struct nv04_surface* ns = (struct nv04_surface*)ps;
+       if(ns->backing)
+       {
+               struct nv20_screen* screen = (struct nv20_screen*)ps->texture->screen;
+               if(ns->backing->base.usage & PIPE_BUFFER_USAGE_GPU_WRITE)
+                       screen->eng2d->copy(screen->eng2d, &ns->backing->base, 0, 0, ps, 0, 0, ns->base.width, ns->base.height);
+               nv20_miptree_surface_destroy(&ns->backing->base);
+       }
+       
        pipe_texture_reference(&ps->texture, NULL);
        FREE(ps);
 }
index ddfcdb8057ae19535fa697e976a4e47531e8a701..2e145672da116a28a66787deb66ba73a8586bed7 100644 (file)
@@ -81,12 +81,15 @@ nv20_vbuf_render(struct vbuf_render *render)
 void nv20_vtxbuf_bind( struct nv20_context* nv20 )
 {
 #if 0
+       struct nv20_screen *screen = nv20->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *kelvin = screen->kelvin;
        int i;
        for(i = 0; i < NV20TCL_VTXBUF_ADDRESS__SIZE; i++) {
-               BEGIN_RING(kelvin, NV20TCL_VTXBUF_ADDRESS(i), 1);
-               OUT_RING(0/*nv20->vtxbuf*/);
-               BEGIN_RING(kelvin, NV20TCL_VTXFMT(i) ,1);
-               OUT_RING(0/*XXX*/);
+               BEGIN_RING(chan, kelvin, NV20TCL_VTXBUF_ADDRESS(i), 1);
+               OUT_RING(chan, 0/*nv20->vtxbuf*/);
+               BEGIN_RING(chan, kelvin, NV20TCL_VTXFMT(i) ,1);
+               OUT_RING(chan, 0/*XXX*/);
        }
 #endif
 }
@@ -202,6 +205,9 @@ nv20__vtxhwformat(unsigned stride, unsigned fields, unsigned type)
 static unsigned
 nv20__emit_format(struct nv20_context *nv20, enum attrib_emit type, int hwattr)
 {
+       struct nv20_screen *screen = nv20->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *kelvin = screen->kelvin;
        uint32_t hwfmt = 0;
        unsigned fields;
 
@@ -231,8 +237,8 @@ nv20__emit_format(struct nv20_context *nv20, enum attrib_emit type, int hwattr)
                return 0;
        }
 
-       BEGIN_RING(kelvin, NV20TCL_VTXFMT(hwattr), 1);
-       OUT_RING(hwfmt);
+       BEGIN_RING(chan, kelvin, NV20TCL_VTXFMT(hwattr), 1);
+       OUT_RING(chan, hwfmt);
        return fields;
 }
 
@@ -262,6 +268,9 @@ nv20__draw_mbuffer(struct nv20_vbuf_render *nv20_render,
                uint nr_indices)
 {
        struct nv20_context *nv20 = nv20_render->nv20;
+       struct nv20_screen *screen = nv20->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *kelvin = screen->kelvin;
        struct vertex_info *vinfo = &nv20->vertex_info;
        unsigned nr_fields;
        int max_push;
@@ -270,29 +279,29 @@ nv20__draw_mbuffer(struct nv20_vbuf_render *nv20_render,
 
        nr_fields = nv20__emit_vertex_array_format(nv20);
 
-       BEGIN_RING(kelvin, NV20TCL_VERTEX_BEGIN_END, 1);
-       OUT_RING(nv20_render->hwprim);
+       BEGIN_RING(chan, kelvin, NV20TCL_VERTEX_BEGIN_END, 1);
+       OUT_RING(chan, nv20_render->hwprim);
 
        max_push = 1200 / nr_fields;
        while (nr_indices) {
                int i;
                int push = MIN2(nr_indices, max_push);
 
-               BEGIN_RING_NI(kelvin, NV20TCL_VERTEX_DATA, push * nr_fields);
+               BEGIN_RING_NI(chan, kelvin, NV20TCL_VERTEX_DATA, push * nr_fields);
                for (i = 0; i < push; i++) {
                        /* XXX: fixme to handle other than floats? */
                        int f = nr_fields;
                        float *attrv = (float*)&data[indices[i] * vsz];
                        while (f-- > 0)
-                               OUT_RINGf(*attrv++);
+                               OUT_RINGf(chan, *attrv++);
                }
 
                nr_indices -= push;
                indices += push;
        }
 
-       BEGIN_RING(kelvin, NV20TCL_VERTEX_BEGIN_END, 1);
-       OUT_RING(NV20TCL_VERTEX_BEGIN_END_STOP);
+       BEGIN_RING(chan, kelvin, NV20TCL_VERTEX_BEGIN_END, 1);
+       OUT_RING(chan, NV20TCL_VERTEX_BEGIN_END_STOP);
 }
 
 static void
@@ -301,20 +310,23 @@ nv20__draw_pbuffer(struct nv20_vbuf_render *nv20_render,
                uint nr_indices)
 {
        struct nv20_context *nv20 = nv20_render->nv20;
+       struct nv20_screen *screen = nv20->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *kelvin = screen->kelvin;
        int push, i;
 
        NOUVEAU_ERR("nv20__draw_pbuffer: this path is broken.\n");
 
-       BEGIN_RING(kelvin, NV10TCL_VERTEX_ARRAY_OFFSET_POS, 1);
-       OUT_RELOCl(nv20_render->pbuffer, 0,
+       BEGIN_RING(chan, kelvin, NV10TCL_VERTEX_ARRAY_OFFSET_POS, 1);
+       OUT_RELOCl(chan, nouveau_bo(nv20_render->pbuffer), 0,
                        NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD);
 
-       BEGIN_RING(kelvin, NV10TCL_VERTEX_BUFFER_BEGIN_END, 1);
-       OUT_RING(nv20_render->hwprim);
+       BEGIN_RING(chan, kelvin, NV10TCL_VERTEX_BUFFER_BEGIN_END, 1);
+       OUT_RING(chan, nv20_render->hwprim);
 
        if (nr_indices & 1) {
-               BEGIN_RING(kelvin, NV10TCL_VB_ELEMENT_U32, 1);
-               OUT_RING  (indices[0]);
+               BEGIN_RING(chan, kelvin, NV10TCL_VB_ELEMENT_U32, 1);
+               OUT_RING  (chan, indices[0]);
                indices++; nr_indices--;
        }
 
@@ -322,16 +334,16 @@ nv20__draw_pbuffer(struct nv20_vbuf_render *nv20_render,
                // XXX too big/small ? check the size
                push = MIN2(nr_indices, 1200 * 2);
 
-               BEGIN_RING_NI(kelvin, NV10TCL_VB_ELEMENT_U16, push >> 1);
+               BEGIN_RING_NI(chan, kelvin, NV10TCL_VB_ELEMENT_U16, push >> 1);
                for (i = 0; i < push; i+=2)
-                       OUT_RING((indices[i+1] << 16) | indices[i]);
+                       OUT_RING(chan, (indices[i+1] << 16) | indices[i]);
 
                nr_indices -= push;
                indices  += push;
        }
 
-       BEGIN_RING(kelvin, NV10TCL_VERTEX_BUFFER_BEGIN_END, 1);
-       OUT_RING  (0);
+       BEGIN_RING(chan, kelvin, NV10TCL_VERTEX_BUFFER_BEGIN_END, 1);
+       OUT_RING  (chan, 0);
 }
 
 static void
index 4eeacd1afd56661debacfc33078fab2fa32cde13..d091335063b9ba668b73a012966b5f95764fcd84 100644 (file)
@@ -115,6 +115,9 @@ nv20_screen_destroy(struct pipe_screen *pscreen)
 
        nouveau_notifier_free(&screen->sync);
        nouveau_grobj_free(&screen->kelvin);
+       nv04_surface_2d_takedown(&screen->eng2d);
+
+       nouveau_screen_fini(&screen->base);
 
        FREE(pscreen);
 }
@@ -173,7 +176,6 @@ nv20_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
                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);
index ed4084980f20148af52ae8aec449511eff03d531..3a82e63423dcea9b595a573c25479f9af90c452b 100644 (file)
@@ -546,9 +546,9 @@ nv20_init_state_functions(struct nv20_context *nv20)
        nv20->pipe.delete_blend_state = nv20_blend_state_delete;
 
        nv20->pipe.create_sampler_state = nv20_sampler_state_create;
-       nv20->pipe.bind_sampler_states = nv20_sampler_state_bind;
+       nv20->pipe.bind_fragment_sampler_states = nv20_sampler_state_bind;
        nv20->pipe.delete_sampler_state = nv20_sampler_state_delete;
-       nv20->pipe.set_sampler_textures = nv20_set_sampler_texture;
+       nv20->pipe.set_fragment_sampler_textures = nv20_set_sampler_texture;
 
        nv20->pipe.create_rasterizer_state = nv20_rasterizer_state_create;
        nv20->pipe.bind_rasterizer_state = nv20_rasterizer_state_bind;
index 34f402fdcbf4140c74bb335109218287bf08533c..dde41065685d6186a0d1644ee30787116d1de4c8 100644 (file)
@@ -126,6 +126,7 @@ struct nv20_depth_stencil_alpha_state {
 
 struct nv20_miptree {
        struct pipe_texture base;
+       struct nouveau_bo *bo;
 
        struct pipe_buffer *buffer;
        uint total_size;
index 4042f46d0530c6ad2008dbbe13f03ddcae9a1fcb..6bbd1fdae9df47463017d31cded3f9408b7afe31 100644 (file)
@@ -5,27 +5,34 @@
 static void nv20_state_emit_blend(struct nv20_context* nv20)
 {
        struct nv20_blend_state *b = nv20->blend;
+       struct nv20_screen *screen = nv20->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *kelvin = screen->kelvin;
 
-       BEGIN_RING(kelvin, NV20TCL_DITHER_ENABLE, 1);
-       OUT_RING  (b->d_enable);
+       BEGIN_RING(chan, kelvin, NV20TCL_DITHER_ENABLE, 1);
+       OUT_RING  (chan, b->d_enable);
 
-       BEGIN_RING(kelvin, NV20TCL_BLEND_FUNC_ENABLE, 1);
-       OUT_RING  (b->b_enable);
+       BEGIN_RING(chan, kelvin, NV20TCL_BLEND_FUNC_ENABLE, 1);
+       OUT_RING  (chan, b->b_enable);
 
-       BEGIN_RING(kelvin, NV20TCL_BLEND_FUNC_SRC, 2);
-       OUT_RING  (b->b_srcfunc);
-       OUT_RING  (b->b_dstfunc);
+       BEGIN_RING(chan, kelvin, NV20TCL_BLEND_FUNC_SRC, 2);
+       OUT_RING  (chan, b->b_srcfunc);
+       OUT_RING  (chan, b->b_dstfunc);
 
-       BEGIN_RING(kelvin, NV20TCL_COLOR_MASK, 1);
-       OUT_RING  (b->c_mask);
+       BEGIN_RING(chan, kelvin, NV20TCL_COLOR_MASK, 1);
+       OUT_RING  (chan, b->c_mask);
 }
 
 static void nv20_state_emit_blend_color(struct nv20_context* nv20)
 {
        struct pipe_blend_color *c = nv20->blend_color;
+       struct nv20_screen *screen = nv20->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *kelvin = screen->kelvin;
 
-       BEGIN_RING(kelvin, NV20TCL_BLEND_COLOR, 1);
-       OUT_RING  ((float_to_ubyte(c->color[3]) << 24)|
+       BEGIN_RING(chan, kelvin, NV20TCL_BLEND_COLOR, 1);
+       OUT_RING  (chan,
+                  (float_to_ubyte(c->color[3]) << 24)|
                   (float_to_ubyte(c->color[0]) << 16)|
                   (float_to_ubyte(c->color[1]) << 8) |
                   (float_to_ubyte(c->color[2]) << 0));
@@ -34,63 +41,69 @@ static void nv20_state_emit_blend_color(struct nv20_context* nv20)
 static void nv20_state_emit_rast(struct nv20_context* nv20)
 {
        struct nv20_rasterizer_state *r = nv20->rast;
+       struct nv20_screen *screen = nv20->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *kelvin = screen->kelvin;
 
-       BEGIN_RING(kelvin, NV20TCL_SHADE_MODEL, 2);
-       OUT_RING  (r->shade_model);
-       OUT_RING  (r->line_width);
+       BEGIN_RING(chan, kelvin, NV20TCL_SHADE_MODEL, 2);
+       OUT_RING  (chan, r->shade_model);
+       OUT_RING  (chan, r->line_width);
 
 
-       BEGIN_RING(kelvin, NV20TCL_POINT_SIZE, 1);
-       OUT_RING  (r->point_size);
+       BEGIN_RING(chan, kelvin, NV20TCL_POINT_SIZE, 1);
+       OUT_RING  (chan, r->point_size);
 
-       BEGIN_RING(kelvin, NV20TCL_POLYGON_MODE_FRONT, 2);
-       OUT_RING  (r->poly_mode_front);
-       OUT_RING  (r->poly_mode_back);
+       BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_MODE_FRONT, 2);
+       OUT_RING  (chan, r->poly_mode_front);
+       OUT_RING  (chan, r->poly_mode_back);
 
 
-       BEGIN_RING(kelvin, NV20TCL_CULL_FACE, 2);
-       OUT_RING  (r->cull_face);
-       OUT_RING  (r->front_face);
+       BEGIN_RING(chan, kelvin, NV20TCL_CULL_FACE, 2);
+       OUT_RING  (chan, r->cull_face);
+       OUT_RING  (chan, r->front_face);
 
-       BEGIN_RING(kelvin, NV20TCL_LINE_SMOOTH_ENABLE, 2);
-       OUT_RING  (r->line_smooth_en);
-       OUT_RING  (r->poly_smooth_en);
+       BEGIN_RING(chan, kelvin, NV20TCL_LINE_SMOOTH_ENABLE, 2);
+       OUT_RING  (chan, r->line_smooth_en);
+       OUT_RING  (chan, r->poly_smooth_en);
 
-       BEGIN_RING(kelvin, NV20TCL_CULL_FACE_ENABLE, 1);
-       OUT_RING  (r->cull_face_en);
+       BEGIN_RING(chan, kelvin, NV20TCL_CULL_FACE_ENABLE, 1);
+       OUT_RING  (chan, r->cull_face_en);
 }
 
 static void nv20_state_emit_dsa(struct nv20_context* nv20)
 {
        struct nv20_depth_stencil_alpha_state *d = nv20->dsa;
+       struct nv20_screen *screen = nv20->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *kelvin = screen->kelvin;
 
-       BEGIN_RING(kelvin, NV20TCL_DEPTH_FUNC, 1);
-       OUT_RING (d->depth.func);
+       BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_FUNC, 1);
+       OUT_RING (chan, d->depth.func);
 
-       BEGIN_RING(kelvin, NV20TCL_DEPTH_WRITE_ENABLE, 1);
-       OUT_RING (d->depth.write_enable);
+       BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_WRITE_ENABLE, 1);
+       OUT_RING (chan, d->depth.write_enable);
 
-       BEGIN_RING(kelvin, NV20TCL_DEPTH_TEST_ENABLE, 1);
-       OUT_RING (d->depth.test_enable);
+       BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_TEST_ENABLE, 1);
+       OUT_RING (chan, d->depth.test_enable);
 
-       BEGIN_RING(kelvin, NV20TCL_DEPTH_UNK17D8, 1);
-       OUT_RING (1);
+       BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_UNK17D8, 1);
+       OUT_RING (chan, 1);
 
 #if 0
-       BEGIN_RING(kelvin, NV20TCL_STENCIL_ENABLE, 1);
-       OUT_RING (d->stencil.enable);
-       BEGIN_RING(kelvin, NV20TCL_STENCIL_MASK, 7);
-       OUT_RINGp ((uint32_t *)&(d->stencil.wmask), 7);
+       BEGIN_RING(chan, kelvin, NV20TCL_STENCIL_ENABLE, 1);
+       OUT_RING (chan, d->stencil.enable);
+       BEGIN_RING(chan, kelvin, NV20TCL_STENCIL_MASK, 7);
+       OUT_RINGp (chan, (uint32_t *)&(d->stencil.wmask), 7);
 #endif
 
-       BEGIN_RING(kelvin, NV20TCL_ALPHA_FUNC_ENABLE, 1);
-       OUT_RING (d->alpha.enabled);
+       BEGIN_RING(chan, kelvin, NV20TCL_ALPHA_FUNC_ENABLE, 1);
+       OUT_RING (chan, d->alpha.enabled);
 
-       BEGIN_RING(kelvin, NV20TCL_ALPHA_FUNC_FUNC, 1);
-       OUT_RING (d->alpha.func);
+       BEGIN_RING(chan, kelvin, NV20TCL_ALPHA_FUNC_FUNC, 1);
+       OUT_RING (chan, d->alpha.func);
 
-       BEGIN_RING(kelvin, NV20TCL_ALPHA_FUNC_REF, 1);
-       OUT_RING (d->alpha.ref);
+       BEGIN_RING(chan, kelvin, NV20TCL_ALPHA_FUNC_REF, 1);
+       OUT_RING (chan, d->alpha.ref);
 }
 
 static void nv20_state_emit_viewport(struct nv20_context* nv20)
@@ -101,9 +114,13 @@ static void nv20_state_emit_scissor(struct nv20_context* nv20)
 {
        /* NV20TCL_SCISSOR_* is probably a software method */
 /*     struct pipe_scissor_state *s = nv20->scissor;
-       BEGIN_RING(kelvin, NV20TCL_SCISSOR_HORIZ, 2);
-       OUT_RING  (((s->maxx - s->minx) << 16) | s->minx);
-       OUT_RING  (((s->maxy - s->miny) << 16) | s->miny);*/
+       struct nv20_screen *screen = nv20->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *kelvin = screen->kelvin;
+
+       BEGIN_RING(chan, kelvin, NV20TCL_SCISSOR_HORIZ, 2);
+       OUT_RING  (chan, ((s->maxx - s->minx) << 16) | s->minx);
+       OUT_RING  (chan, ((s->maxy - s->miny) << 16) | s->miny);*/
 }
 
 static void nv20_state_emit_framebuffer(struct nv20_context* nv20)
@@ -113,6 +130,9 @@ static void nv20_state_emit_framebuffer(struct nv20_context* nv20)
        uint32_t rt_format, w, h;
        int colour_format = 0, zeta_format = 0;
        struct nv20_miptree *nv20mt = 0;
+       struct nv20_screen *screen = nv20->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *kelvin = screen->kelvin;
 
        w = fb->cbufs[0]->width;
        h = fb->cbufs[0]->height;
@@ -135,6 +155,9 @@ static void nv20_state_emit_framebuffer(struct nv20_context* nv20)
        rt_format = NV20TCL_RT_FORMAT_TYPE_LINEAR | 0x20;
 
        switch (colour_format) {
+       case PIPE_FORMAT_X8R8G8B8_UNORM:
+               rt_format |= NV20TCL_RT_FORMAT_COLOR_X8R8G8B8;
+               break;
        case PIPE_FORMAT_A8R8G8B8_UNORM:
        case 0:
                rt_format |= NV20TCL_RT_FORMAT_COLOR_A8R8G8B8;
@@ -147,11 +170,11 @@ static void nv20_state_emit_framebuffer(struct nv20_context* nv20)
        }
 
        if (zeta) {
-               BEGIN_RING(kelvin, NV20TCL_RT_PITCH, 1);
-               OUT_RING  (rt->pitch | (zeta->pitch << 16));
+               BEGIN_RING(chan, kelvin, NV20TCL_RT_PITCH, 1);
+               OUT_RING  (chan, rt->pitch | (zeta->pitch << 16));
        } else {
-               BEGIN_RING(kelvin, NV20TCL_RT_PITCH, 1);
-               OUT_RING  (rt->pitch | (rt->pitch << 16));
+               BEGIN_RING(chan, kelvin, NV20TCL_RT_PITCH, 1);
+               OUT_RING  (chan, rt->pitch | (rt->pitch << 16));
        }
 
        nv20mt = (struct nv20_miptree *)rt->base.texture;
@@ -163,13 +186,13 @@ static void nv20_state_emit_framebuffer(struct nv20_context* nv20)
                nv20->zeta = nv20mt->buffer;
        }
 
-       BEGIN_RING(kelvin, NV20TCL_RT_HORIZ, 3);
-       OUT_RING  ((w << 16) | 0);
-       OUT_RING  ((h << 16) | 0); /*NV20TCL_RT_VERT */
-       OUT_RING  (rt_format); /* NV20TCL_RT_FORMAT */
-       BEGIN_RING(kelvin, NV20TCL_VIEWPORT_CLIP_HORIZ(0), 2);
-       OUT_RING  (((w - 1) << 16) | 0);
-       OUT_RING  (((h - 1) << 16) | 0);
+       BEGIN_RING(chan, kelvin, NV20TCL_RT_HORIZ, 3);
+       OUT_RING  (chan, (w << 16) | 0);
+       OUT_RING  (chan, (h << 16) | 0); /*NV20TCL_RT_VERT */
+       OUT_RING  (chan, rt_format); /* NV20TCL_RT_FORMAT */
+       BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_CLIP_HORIZ(0), 2);
+       OUT_RING  (chan, ((w - 1) << 16) | 0);
+       OUT_RING  (chan, ((h - 1) << 16) | 0);
 }
 
 static void nv20_vertex_layout(struct nv20_context *nv20)
@@ -225,7 +248,7 @@ static void nv20_vertex_layout(struct nv20_context *nv20)
        }
 
        /* always do position */ {
-               src = draw_find_vs_output(dc, TGSI_SEMANTIC_POSITION, 0);
+               src = draw_find_shader_output(dc, TGSI_SEMANTIC_POSITION, 0);
                draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_LINEAR, src);
                vinfo->hwfmt[0] |= (1 << 0);
        }
@@ -234,19 +257,19 @@ static void nv20_vertex_layout(struct nv20_context *nv20)
        for (i = 4; i < 6; i++) {
                if (!generics[i])
                        continue;
-               src = draw_find_vs_output(dc, TGSI_SEMANTIC_GENERIC, i);
+               src = draw_find_shader_output(dc, TGSI_SEMANTIC_GENERIC, i);
                draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src);
                vinfo->hwfmt[0] |= (1 << (i - 3));
        }
 
        if (colors[0]) {
-               src = draw_find_vs_output(dc, TGSI_SEMANTIC_COLOR, 0);
+               src = draw_find_shader_output(dc, TGSI_SEMANTIC_COLOR, 0);
                draw_emit_vertex_attr(vinfo, EMIT_4F, colorInterp, src);
                vinfo->hwfmt[0] |= (1 << 3);
        }
 
        if (colors[1]) {
-               src = draw_find_vs_output(dc, TGSI_SEMANTIC_COLOR, 1);
+               src = draw_find_shader_output(dc, TGSI_SEMANTIC_COLOR, 1);
                draw_emit_vertex_attr(vinfo, EMIT_4F, colorInterp, src);
                vinfo->hwfmt[0] |= (1 << 4);
        }
@@ -255,7 +278,7 @@ static void nv20_vertex_layout(struct nv20_context *nv20)
        for (i = 6; i < 10; i++) {
                if (!generics[i])
                        continue;
-               src = draw_find_vs_output(dc, TGSI_SEMANTIC_GENERIC, i);
+               src = draw_find_shader_output(dc, TGSI_SEMANTIC_GENERIC, i);
                draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src);
                vinfo->hwfmt[0] |= (1 << (i - 1));
        }
@@ -264,7 +287,7 @@ static void nv20_vertex_layout(struct nv20_context *nv20)
        for (i = 0; i < 4; i++) {
                if (!generics[i])
                        continue;
-               src = draw_find_vs_output(dc, TGSI_SEMANTIC_GENERIC, i);
+               src = draw_find_shader_output(dc, TGSI_SEMANTIC_GENERIC, i);
                draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src);
                vinfo->hwfmt[0] |= (1 << (i + 9));
        }
@@ -273,13 +296,13 @@ static void nv20_vertex_layout(struct nv20_context *nv20)
        for (i = 10; i < 12; i++) {
                if (!generics[i])
                        continue;
-               src = draw_find_vs_output(dc, TGSI_SEMANTIC_GENERIC, i);
+               src = draw_find_shader_output(dc, TGSI_SEMANTIC_GENERIC, i);
                draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src);
                vinfo->hwfmt[0] |= (1 << (i + 3));
        }
 
        if (fog) {
-               src = draw_find_vs_output(dc, TGSI_SEMANTIC_FOG, 0);
+               src = draw_find_shader_output(dc, TGSI_SEMANTIC_FOG, 0);
                draw_emit_vertex_attr(vinfo, EMIT_1F, INTERP_PERSPECTIVE, src);
                vinfo->hwfmt[0] |= (1 << 15);
        }
@@ -290,6 +313,10 @@ static void nv20_vertex_layout(struct nv20_context *nv20)
 void
 nv20_emit_hw_state(struct nv20_context *nv20)
 {
+       struct nv20_screen *screen = nv20->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *kelvin = screen->kelvin;
+       struct nouveau_bo *rt_bo;
        int i;
 
        if (nv20->dirty & NV20_NEW_VERTPROG) {
@@ -358,36 +385,39 @@ nv20_emit_hw_state(struct nv20_context *nv20)
         */
 
        /* Render target */
-       BEGIN_RING(kelvin, NV20TCL_DMA_COLOR, 1);
-       OUT_RELOCo(nv20->rt[0], NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
-       BEGIN_RING(kelvin, NV20TCL_COLOR_OFFSET, 1);
-       OUT_RELOCl(nv20->rt[0], 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+       rt_bo = nouveau_bo(nv20->rt[0]);
+       BEGIN_RING(chan, kelvin, NV20TCL_DMA_COLOR, 1);
+       OUT_RELOCo(chan, rt_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+       BEGIN_RING(chan, kelvin, NV20TCL_COLOR_OFFSET, 1);
+       OUT_RELOCl(chan, rt_bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
 
        if (nv20->zeta) {
-               BEGIN_RING(kelvin, NV20TCL_DMA_ZETA, 1);
-               OUT_RELOCo(nv20->zeta, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
-               BEGIN_RING(kelvin, NV20TCL_ZETA_OFFSET, 1);
-               OUT_RELOCl(nv20->zeta, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+               struct nouveau_bo *zeta_bo = nouveau_bo(nv20->zeta);
+               BEGIN_RING(chan, kelvin, NV20TCL_DMA_ZETA, 1);
+               OUT_RELOCo(chan, zeta_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+               BEGIN_RING(chan, kelvin, NV20TCL_ZETA_OFFSET, 1);
+               OUT_RELOCl(chan, zeta_bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
                /* XXX for when we allocate LMA on nv17 */
-/*             BEGIN_RING(kelvin, NV10TCL_LMA_DEPTH_BUFFER_OFFSET, 1);
-               OUT_RELOCl(nv20->zeta + lma_offset);*/
+/*             BEGIN_RING(chan, kelvin, NV10TCL_LMA_DEPTH_BUFFER_OFFSET, 1);
+               OUT_RELOCl(chan, nouveau_bo(nv20->zeta + lma_offset));*/
        }
 
        /* Vertex buffer */
-       BEGIN_RING(kelvin, NV20TCL_DMA_VTXBUF0, 1);
-       OUT_RELOCo(nv20->rt[0], NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
-       BEGIN_RING(kelvin, NV20TCL_COLOR_OFFSET, 1);
-       OUT_RELOCl(nv20->rt[0], 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+       BEGIN_RING(chan, kelvin, NV20TCL_DMA_VTXBUF0, 1);
+       OUT_RELOCo(chan, rt_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+       BEGIN_RING(chan, kelvin, NV20TCL_COLOR_OFFSET, 1);
+       OUT_RELOCl(chan, rt_bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
 
        /* Texture images */
        for (i = 0; i < 2; i++) {
                if (!(nv20->fp_samplers & (1 << i)))
                        continue;
-               BEGIN_RING(kelvin, NV20TCL_TX_OFFSET(i), 1);
-               OUT_RELOCl(nv20->tex[i].buffer, 0, NOUVEAU_BO_VRAM |
+               struct nouveau_bo *bo = nouveau_bo(nv20->tex[i].buffer);
+               BEGIN_RING(chan, kelvin, NV20TCL_TX_OFFSET(i), 1);
+               OUT_RELOCl(chan, bo, 0, NOUVEAU_BO_VRAM |
                           NOUVEAU_BO_GART | NOUVEAU_BO_RD);
-               BEGIN_RING(kelvin, NV20TCL_TX_FORMAT(i), 1);
-               OUT_RELOCd(nv20->tex[i].buffer, nv20->tex[i].format,
+               BEGIN_RING(chan, kelvin, NV20TCL_TX_FORMAT(i), 1);
+               OUT_RELOCd(chan, bo, nv20->tex[i].format,
                           NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD |
                           NOUVEAU_BO_OR, NV20TCL_TX_FORMAT_DMA0,
                           NV20TCL_TX_FORMAT_DMA1);
index 81b4f1a9177f47beb75e7c138abb17ca3b975a7e..699773e8e6f99146e087dc8a7add07b448c38ec2 100644 (file)
@@ -1,7 +1,9 @@
 #include <pipe/p_state.h>
 #include <pipe/p_defines.h>
 #include <pipe/p_inlines.h>
+#include <util/u_format.h>
 #include <util/u_memory.h>
+#include <util/u_math.h>
 #include <nouveau/nouveau_winsys.h>
 #include "nv20_context.h"
 #include "nv20_screen.h"
 struct nv20_transfer {
        struct pipe_transfer base;
        struct pipe_surface *surface;
-       bool direct;
+       boolean direct;
 };
 
 static void
-nv20_compatible_transfer_tex(struct pipe_texture *pt, unsigned level,
+nv20_compatible_transfer_tex(struct pipe_texture *pt, unsigned width, unsigned height,
                              struct pipe_texture *template)
 {
        memset(template, 0, sizeof(struct pipe_texture));
        template->target = pt->target;
        template->format = pt->format;
-       template->width[0] = pt->width[level];
-       template->height[0] = pt->height[level];
-       template->depth[0] = 1;
-       template->block = pt->block;
-       template->nblocksx[0] = pt->nblocksx[level];
-       template->nblocksy[0] = pt->nblocksx[level];
+       template->width0 = width;
+       template->height0 = height;
+       template->depth0 = 1;
        template->last_level = 0;
        template->nr_samples = pt->nr_samples;
 
@@ -48,14 +47,10 @@ nv20_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
                return NULL;
 
        pipe_texture_reference(&tx->base.texture, pt);
-       tx->base.format = pt->format;
        tx->base.x = x;
        tx->base.y = y;
        tx->base.width = w;
        tx->base.height = h;
-       tx->base.block = pt->block;
-       tx->base.nblocksx = pt->nblocksx[level];
-       tx->base.nblocksy = pt->nblocksy[level];
        tx->base.stride = mt->level[level].pitch;
        tx->base.usage = usage;
        tx->base.face = face;
@@ -76,7 +71,7 @@ nv20_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
 
        tx->direct = false;
 
-       nv20_compatible_transfer_tex(pt, level, &tx_tex_template);
+       nv20_compatible_transfer_tex(pt, w, h, &tx_tex_template);
 
        tx_tex = pscreen->texture_create(pscreen, &tx_tex_template);
        if (!tx_tex)
@@ -85,6 +80,8 @@ nv20_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
                return NULL;
        }
 
+       tx->base.stride = ((struct nv20_miptree*)tx_tex)->level[0].pitch;
+
        tx->surface = pscreen->get_tex_surface(pscreen, tx_tex,
                                               face, level, zslice,
                                               pipe_transfer_buffer_flags(&tx->base));
@@ -110,8 +107,8 @@ nv20_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
                /* TODO: Check if SIFM can un-swizzle */
                nvscreen->eng2d->copy(nvscreen->eng2d,
                                      tx->surface, 0, 0,
-                                     src, 0, 0,
-                                     src->width, src->height);
+                                     src, x, y,
+                                     w, h);
 
                pipe_surface_reference(&src, NULL);
        }
@@ -131,13 +128,13 @@ nv20_transfer_del(struct pipe_transfer *ptx)
 
                dst = pscreen->get_tex_surface(pscreen, ptx->texture,
                                               ptx->face, ptx->level, ptx->zslice,
-                                              PIPE_BUFFER_USAGE_GPU_WRITE);
+                                              PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER);
 
                /* TODO: Check if SIFM can deal with x,y,w,h when swizzling */
                nvscreen->eng2d->copy(nvscreen->eng2d,
-                                     dst, 0, 0,
+                                     dst, tx->base.x, tx->base.y,
                                      tx->surface, 0, 0,
-                                     dst->width, dst->height);
+                                     tx->base.width, tx->base.height);
 
                pipe_surface_reference(&dst, NULL);
        }
@@ -156,8 +153,10 @@ nv20_transfer_map(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
        void *map = pipe_buffer_map(pscreen, mt->buffer,
                                    pipe_transfer_buffer_flags(ptx));
 
-       return map + ns->base.offset +
-              ptx->y * ns->pitch + ptx->x * ptx->block.size;
+       if(!tx->direct)
+               return map + ns->base.offset;
+       else
+               return map + ns->base.offset + ptx->y * ns->pitch + ptx->x * util_format_get_blocksize(ptx->texture->format);
 }
 
 static void
index 84d7db6c5e27c3274eea2f40340e06311db8a04e..52991a0d85621a1106befb9825208be3c98fc662 100644 (file)
@@ -9,7 +9,7 @@
 #include "nouveau/nouveau_channel.h"
 #include "nouveau/nouveau_pushbuf.h"
 
-boolean nv20_draw_elements( struct pipe_context *pipe,
+void nv20_draw_elements( struct pipe_context *pipe,
                     struct pipe_buffer *indexBuffer,
                     unsigned indexSize,
                     unsigned prim, unsigned start, unsigned count)
@@ -45,7 +45,7 @@ boolean nv20_draw_elements( struct pipe_context *pipe,
                draw_set_mapped_element_buffer(draw, 0, NULL);
        }
 
-       draw_set_mapped_constant_buffer(draw,
+       draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX,
                                        nv20->constbuf[PIPE_SHADER_VERTEX],
                                        nv20->constbuf_nr[PIPE_SHADER_VERTEX]);
 
@@ -67,13 +67,12 @@ boolean nv20_draw_elements( struct pipe_context *pipe,
        }
 
        draw_flush(nv20->draw);
-       return TRUE;
 }
 
-boolean nv20_draw_arrays( struct pipe_context *pipe,
+void nv20_draw_arrays( struct pipe_context *pipe,
                                 unsigned prim, unsigned start, unsigned count)
 {
-       return nv20_draw_elements(pipe, NULL, 0, prim, start, count);
+       nv20_draw_elements(pipe, NULL, 0, prim, start, count);
 }
 
 
index 388245ecb042a430ed800588a497ec88423726e1..7886c2af7e62d75d66deb3d61824d013358c7ddf 100644 (file)
@@ -253,32 +253,32 @@ static INLINE struct nv20_sreg
 tgsi_src(struct nv20_vpc *vpc, const struct tgsi_full_src_register *fsrc) {
        struct nv20_sreg src;
 
-       switch (fsrc->SrcRegister.File) {
+       switch (fsrc->Register.File) {
        case TGSI_FILE_INPUT:
-               src = nv20_sr(NV30SR_INPUT, fsrc->SrcRegister.Index);
+               src = nv20_sr(NV30SR_INPUT, fsrc->Register.Index);
                break;
        case TGSI_FILE_CONSTANT:
-               src = constant(vpc, fsrc->SrcRegister.Index, 0, 0, 0, 0);
+               src = constant(vpc, fsrc->Register.Index, 0, 0, 0, 0);
                break;
        case TGSI_FILE_IMMEDIATE:
-               src = vpc->imm[fsrc->SrcRegister.Index];
+               src = vpc->imm[fsrc->Register.Index];
                break;
        case TGSI_FILE_TEMPORARY:
-               if (vpc->high_temp < fsrc->SrcRegister.Index)
-                       vpc->high_temp = fsrc->SrcRegister.Index;
-               src = nv20_sr(NV30SR_TEMP, fsrc->SrcRegister.Index);
+               if (vpc->high_temp < fsrc->Register.Index)
+                       vpc->high_temp = fsrc->Register.Index;
+               src = nv20_sr(NV30SR_TEMP, fsrc->Register.Index);
                break;
        default:
                NOUVEAU_ERR("bad src file\n");
                break;
        }
 
-       src.abs = fsrc->SrcRegisterExtMod.Absolute;
-       src.negate = fsrc->SrcRegister.Negate;
-       src.swz[0] = fsrc->SrcRegister.SwizzleX;
-       src.swz[1] = fsrc->SrcRegister.SwizzleY;
-       src.swz[2] = fsrc->SrcRegister.SwizzleZ;
-       src.swz[3] = fsrc->SrcRegister.SwizzleW;
+       src.abs = fsrc->Register.Absolute;
+       src.negate = fsrc->Register.Negate;
+       src.swz[0] = fsrc->Register.SwizzleX;
+       src.swz[1] = fsrc->Register.SwizzleY;
+       src.swz[2] = fsrc->Register.SwizzleZ;
+       src.swz[3] = fsrc->Register.SwizzleW;
        return src;
 }
 
@@ -286,14 +286,14 @@ static INLINE struct nv20_sreg
 tgsi_dst(struct nv20_vpc *vpc, const struct tgsi_full_dst_register *fdst) {
        struct nv20_sreg dst;
 
-       switch (fdst->DstRegister.File) {
+       switch (fdst->Register.File) {
        case TGSI_FILE_OUTPUT:
                dst = nv20_sr(NV30SR_OUTPUT,
-                             vpc->output_map[fdst->DstRegister.Index]);
+                             vpc->output_map[fdst->Register.Index]);
 
                break;
        case TGSI_FILE_TEMPORARY:
-               dst = nv20_sr(NV30SR_TEMP, fdst->DstRegister.Index);
+               dst = nv20_sr(NV30SR_TEMP, fdst->Register.Index);
                if (vpc->high_temp < dst.index)
                        vpc->high_temp = dst.index;
                break;
@@ -334,8 +334,8 @@ nv20_vertprog_parse_instruction(struct nv20_vpc *vpc,
        for (i = 0; i < finst->Instruction.NumSrcRegs; i++) {
                const struct tgsi_full_src_register *fsrc;
 
-               fsrc = &finst->FullSrcRegisters[i];
-               if (fsrc->SrcRegister.File == TGSI_FILE_TEMPORARY) {
+               fsrc = &finst->Src[i];
+               if (fsrc->Register.File == TGSI_FILE_TEMPORARY) {
                        src[i] = tgsi_src(vpc, fsrc);
                }
        }
@@ -343,11 +343,11 @@ nv20_vertprog_parse_instruction(struct nv20_vpc *vpc,
        for (i = 0; i < finst->Instruction.NumSrcRegs; i++) {
                const struct tgsi_full_src_register *fsrc;
 
-               fsrc = &finst->FullSrcRegisters[i];
-               switch (fsrc->SrcRegister.File) {
+               fsrc = &finst->Src[i];
+               switch (fsrc->Register.File) {
                case TGSI_FILE_INPUT:
-                       if (ai == -1 || ai == fsrc->SrcRegister.Index) {
-                               ai = fsrc->SrcRegister.Index;
+                       if (ai == -1 || ai == fsrc->Register.Index) {
+                               ai = fsrc->Register.Index;
                                src[i] = tgsi_src(vpc, fsrc);
                        } else {
                                src[i] = temp(vpc);
@@ -360,8 +360,8 @@ nv20_vertprog_parse_instruction(struct nv20_vpc *vpc,
                 */
                case TGSI_FILE_CONSTANT:
                case TGSI_FILE_IMMEDIATE:
-                       if (ci == -1 || ci == fsrc->SrcRegister.Index) {
-                               ci = fsrc->SrcRegister.Index;
+                       if (ci == -1 || ci == fsrc->Register.Index) {
+                               ci = fsrc->Register.Index;
                                src[i] = tgsi_src(vpc, fsrc);
                        } else {
                                src[i] = temp(vpc);
@@ -378,8 +378,8 @@ nv20_vertprog_parse_instruction(struct nv20_vpc *vpc,
                }
        }
 
-       dst  = tgsi_dst(vpc, &finst->FullDstRegisters[0]);
-       mask = tgsi_mask(finst->FullDstRegisters[0].DstRegister.WriteMask);
+       dst  = tgsi_dst(vpc, &finst->Dst[0]);
+       mask = tgsi_mask(finst->Dst[0].Register.WriteMask);
 
        switch (finst->Instruction.Opcode) {
        case TGSI_OPCODE_ABS:
@@ -490,15 +490,15 @@ nv20_vertprog_parse_decl_output(struct nv20_vpc *vpc,
 {
        int hw;
 
-       switch (fdec->Semantic.SemanticName) {
+       switch (fdec->Semantic.Name) {
        case TGSI_SEMANTIC_POSITION:
                hw = NV30_VP_INST_DEST_POS;
                break;
        case TGSI_SEMANTIC_COLOR:
-               if (fdec->Semantic.SemanticIndex == 0) {
+               if (fdec->Semantic.Index == 0) {
                        hw = NV30_VP_INST_DEST_COL0;
                } else
-               if (fdec->Semantic.SemanticIndex == 1) {
+               if (fdec->Semantic.Index == 1) {
                        hw = NV30_VP_INST_DEST_COL1;
                } else {
                        NOUVEAU_ERR("bad colour semantic index\n");
@@ -506,10 +506,10 @@ nv20_vertprog_parse_decl_output(struct nv20_vpc *vpc,
                }
                break;
        case TGSI_SEMANTIC_BCOLOR:
-               if (fdec->Semantic.SemanticIndex == 0) {
+               if (fdec->Semantic.Index == 0) {
                        hw = NV30_VP_INST_DEST_BFC0;
                } else
-               if (fdec->Semantic.SemanticIndex == 1) {
+               if (fdec->Semantic.Index == 1) {
                        hw = NV30_VP_INST_DEST_BFC1;
                } else {
                        NOUVEAU_ERR("bad bcolour semantic index\n");
@@ -523,19 +523,22 @@ nv20_vertprog_parse_decl_output(struct nv20_vpc *vpc,
                hw = NV30_VP_INST_DEST_PSZ;
                break;
        case TGSI_SEMANTIC_GENERIC:
-               if (fdec->Semantic.SemanticIndex <= 7) {
-                       hw = NV30_VP_INST_DEST_TC(fdec->Semantic.SemanticIndex);
+               if (fdec->Semantic.Index <= 7) {
+                       hw = NV30_VP_INST_DEST_TC(fdec->Semantic.Index);
                } else {
                        NOUVEAU_ERR("bad generic semantic index\n");
                        return FALSE;
                }
                break;
+       case TGSI_SEMANTIC_EDGEFLAG:
+               NOUVEAU_ERR("cannot handle edgeflag output\n");
+               return FALSE;
        default:
                NOUVEAU_ERR("bad output semantic\n");
                return FALSE;
        }
 
-       vpc->output_map[fdec->DeclarationRange.First] = hw;
+       vpc->output_map[fdec->Range.First] = hw;
        return TRUE;
 }
 
index f827bdc78b1f3ae9bee54ee45f1afa368f2cb738..54572e9ab3a893f55ca81bf4c17541e3e2892545 100644 (file)
@@ -10,50 +10,38 @@ nv30_flush(struct pipe_context *pipe, unsigned flags,
           struct pipe_fence_handle **fence)
 {
        struct nv30_context *nv30 = nv30_context(pipe);
-       
+       struct nv30_screen *screen = nv30->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *rankine = screen->rankine;
+
        if (flags & PIPE_FLUSH_TEXTURE_CACHE) {
-               BEGIN_RING(rankine, 0x1fd8, 1);
-               OUT_RING  (2);
-               BEGIN_RING(rankine, 0x1fd8, 1);
-               OUT_RING  (1);
+               BEGIN_RING(chan, rankine, 0x1fd8, 1);
+               OUT_RING  (chan, 2);
+               BEGIN_RING(chan, rankine, 0x1fd8, 1);
+               OUT_RING  (chan, 1);
        }
 
-       FIRE_RING(fence);
+       FIRE_RING(chan);
+       if (fence)
+               *fence = NULL;
 }
 
 static void
 nv30_destroy(struct pipe_context *pipe)
 {
        struct nv30_context *nv30 = nv30_context(pipe);
+       unsigned i;
+
+       for (i = 0; i < NV30_STATE_MAX; i++) {
+               if (nv30->state.hw[i])
+                       so_ref(NULL, &nv30->state.hw[i]);
+       }
 
        if (nv30->draw)
                draw_destroy(nv30->draw);
        FREE(nv30);
 }
 
-static unsigned int
-nv30_is_texture_referenced( struct pipe_context *pipe,
-                           struct pipe_texture *texture,
-                           unsigned face, unsigned level)
-{
-   /**
-    * FIXME: Optimize.
-    */
-
-   return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
-
-static unsigned int
-nv30_is_buffer_referenced( struct pipe_context *pipe,
-                          struct pipe_buffer *buf)
-{
-   /**
-    * FIXME: Optimize.
-    */
-
-   return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
-
 struct pipe_context *
 nv30_create(struct pipe_screen *pscreen, unsigned pctx_id)
 {
@@ -78,8 +66,11 @@ nv30_create(struct pipe_screen *pscreen, unsigned pctx_id)
        nv30->pipe.clear = nv30_clear;
        nv30->pipe.flush = nv30_flush;
 
-       nv30->pipe.is_texture_referenced = nv30_is_texture_referenced;
-       nv30->pipe.is_buffer_referenced = nv30_is_buffer_referenced;
+       nv30->pipe.is_texture_referenced = nouveau_is_texture_referenced;
+       nv30->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
+
+       screen->base.channel->user_private = nv30;
+       screen->base.channel->flush_notify = nv30_state_flush_notify;
 
        nv30_init_query_functions(nv30);
        nv30_init_surface_functions(nv30);
@@ -95,4 +86,3 @@ nv30_create(struct pipe_screen *pscreen, unsigned pctx_id)
 
        return &nv30->pipe;
 }
-       
index 4229c0a0e1478bc33842e4416e0283fdf751dd73..e59449287b5e504b30bdcda7337de89933d02985 100644 (file)
 
 #include "nouveau/nouveau_winsys.h"
 #include "nouveau/nouveau_gldefs.h"
-
-#define NOUVEAU_PUSH_CONTEXT(ctx)                                              \
-       struct nv30_screen *ctx = nv30->screen
-#include "nouveau/nouveau_push.h"
+#include "nouveau/nouveau_context.h"
 #include "nouveau/nouveau_stateobj.h"
 
 #include "nv30_state.h"
@@ -143,7 +140,6 @@ struct nv30_context {
        unsigned vtxbuf_nr;
        struct pipe_vertex_element vtxelt[PIPE_MAX_ATTRIBS];
        unsigned vtxelt_nr;
-       const unsigned *edgeflags;
 };
 
 static INLINE struct nv30_context *
@@ -183,6 +179,7 @@ extern void nv30_fragtex_bind(struct nv30_context *);
 /* nv30_state.c and friends */
 extern boolean nv30_state_validate(struct nv30_context *nv30);
 extern void nv30_state_emit(struct nv30_context *nv30);
+extern void nv30_state_flush_notify(struct nouveau_channel *chan);
 extern struct nv30_state_entry nv30_state_rasterizer;
 extern struct nv30_state_entry nv30_state_scissor;
 extern struct nv30_state_entry nv30_state_stipple;
@@ -197,9 +194,9 @@ extern struct nv30_state_entry nv30_state_fragtex;
 extern struct nv30_state_entry nv30_state_vbo;
 
 /* nv30_vbo.c */
-extern boolean nv30_draw_arrays(struct pipe_context *, unsigned mode,
+extern void nv30_draw_arrays(struct pipe_context *, unsigned mode,
                                unsigned start, unsigned count);
-extern boolean nv30_draw_elements(struct pipe_context *pipe,
+extern void nv30_draw_elements(struct pipe_context *pipe,
                                  struct pipe_buffer *indexBuffer,
                                  unsigned indexSize,
                                  unsigned mode, unsigned start,
index a48ba9782b329e47e32431f5fb48379ed36ef1c3..2d565cb631b66d221d8f958f65b23a17c9f42f53 100644 (file)
@@ -4,6 +4,7 @@
 #include "pipe/p_inlines.h"
 
 #include "pipe/p_shader_tokens.h"
+#include "tgsi/tgsi_dump.h"
 #include "tgsi/tgsi_parse.h"
 #include "tgsi/tgsi_util.h"
 
@@ -131,7 +132,7 @@ emit_src(struct nv30_fpc *fpc, int pos, struct nv30_sreg src)
                                sizeof(uint32_t) * 4);
                }
 
-               sr |= (NV30_FP_REG_TYPE_CONST << NV30_FP_REG_TYPE_SHIFT);       
+               sr |= (NV30_FP_REG_TYPE_CONST << NV30_FP_REG_TYPE_SHIFT);
                break;
        case NV30SR_NONE:
                sr |= (NV30_FP_REG_TYPE_INPUT << NV30_FP_REG_TYPE_SHIFT);
@@ -236,20 +237,20 @@ tgsi_src(struct nv30_fpc *fpc, const struct tgsi_full_src_register *fsrc)
 {
        struct nv30_sreg src;
 
-       switch (fsrc->SrcRegister.File) {
+       switch (fsrc->Register.File) {
        case TGSI_FILE_INPUT:
                src = nv30_sr(NV30SR_INPUT,
-                             fpc->attrib_map[fsrc->SrcRegister.Index]);
+                             fpc->attrib_map[fsrc->Register.Index]);
                break;
        case TGSI_FILE_CONSTANT:
-               src = constant(fpc, fsrc->SrcRegister.Index, NULL);
+               src = constant(fpc, fsrc->Register.Index, NULL);
                break;
        case TGSI_FILE_IMMEDIATE:
-               assert(fsrc->SrcRegister.Index < fpc->nr_imm);
-               src = fpc->imm[fsrc->SrcRegister.Index];
+               assert(fsrc->Register.Index < fpc->nr_imm);
+               src = fpc->imm[fsrc->Register.Index];
                break;
        case TGSI_FILE_TEMPORARY:
-               src = nv30_sr(NV30SR_TEMP, fsrc->SrcRegister.Index + 1);
+               src = nv30_sr(NV30SR_TEMP, fsrc->Register.Index + 1);
                if (fpc->high_temp < src.index)
                        fpc->high_temp = src.index;
                break;
@@ -257,7 +258,7 @@ tgsi_src(struct nv30_fpc *fpc, const struct tgsi_full_src_register *fsrc)
         * Luckily fragprog results are just temp regs..
         */
        case TGSI_FILE_OUTPUT:
-               if (fsrc->SrcRegister.Index == fpc->colour_id)
+               if (fsrc->Register.Index == fpc->colour_id)
                        return nv30_sr(NV30SR_OUTPUT, 0);
                else
                        return nv30_sr(NV30SR_OUTPUT, 1);
@@ -267,12 +268,12 @@ tgsi_src(struct nv30_fpc *fpc, const struct tgsi_full_src_register *fsrc)
                break;
        }
 
-       src.abs = fsrc->SrcRegisterExtMod.Absolute;
-       src.negate = fsrc->SrcRegister.Negate;
-       src.swz[0] = fsrc->SrcRegister.SwizzleX;
-       src.swz[1] = fsrc->SrcRegister.SwizzleY;
-       src.swz[2] = fsrc->SrcRegister.SwizzleZ;
-       src.swz[3] = fsrc->SrcRegister.SwizzleW;
+       src.abs = fsrc->Register.Absolute;
+       src.negate = fsrc->Register.Negate;
+       src.swz[0] = fsrc->Register.SwizzleX;
+       src.swz[1] = fsrc->Register.SwizzleY;
+       src.swz[2] = fsrc->Register.SwizzleZ;
+       src.swz[3] = fsrc->Register.SwizzleW;
        return src;
 }
 
@@ -280,22 +281,22 @@ static INLINE struct nv30_sreg
 tgsi_dst(struct nv30_fpc *fpc, const struct tgsi_full_dst_register *fdst) {
        int idx;
 
-       switch (fdst->DstRegister.File) {
+       switch (fdst->Register.File) {
        case TGSI_FILE_OUTPUT:
-               if (fdst->DstRegister.Index == fpc->colour_id)
+               if (fdst->Register.Index == fpc->colour_id)
                        return nv30_sr(NV30SR_OUTPUT, 0);
                else
                        return nv30_sr(NV30SR_OUTPUT, 1);
                break;
        case TGSI_FILE_TEMPORARY:
-               idx = fdst->DstRegister.Index + 1;
+               idx = fdst->Register.Index + 1;
                if (fpc->high_temp < idx)
                        fpc->high_temp = idx;
                return nv30_sr(NV30SR_TEMP, idx);
        case TGSI_FILE_NULL:
                return nv30_sr(NV30SR_NONE, 0);
        default:
-               NOUVEAU_ERR("bad dst file %d\n", fdst->DstRegister.File);
+               NOUVEAU_ERR("bad dst file %d\n", fdst->Register.File);
                return nv30_sr(NV30SR_NONE, 0);
        }
 }
@@ -318,38 +319,23 @@ src_native_swz(struct nv30_fpc *fpc, const struct tgsi_full_src_register *fsrc,
 {
        const struct nv30_sreg none = nv30_sr(NV30SR_NONE, 0);
        struct nv30_sreg tgsi = tgsi_src(fpc, fsrc);
-       uint mask = 0, zero_mask = 0, one_mask = 0, neg_mask = 0;
-       uint neg[4] = { fsrc->SrcRegisterExtSwz.NegateX,
-                       fsrc->SrcRegisterExtSwz.NegateY,
-                       fsrc->SrcRegisterExtSwz.NegateZ,
-                       fsrc->SrcRegisterExtSwz.NegateW };
+       uint mask = 0;
        uint c;
 
        for (c = 0; c < 4; c++) {
-               switch (tgsi_util_get_full_src_register_extswizzle(fsrc, c)) {
-               case TGSI_EXTSWIZZLE_X:
-               case TGSI_EXTSWIZZLE_Y:
-               case TGSI_EXTSWIZZLE_Z:
-               case TGSI_EXTSWIZZLE_W:
+               switch (tgsi_util_get_full_src_register_swizzle(fsrc, c)) {
+               case TGSI_SWIZZLE_X:
+               case TGSI_SWIZZLE_Y:
+               case TGSI_SWIZZLE_Z:
+               case TGSI_SWIZZLE_W:
                        mask |= (1 << c);
                        break;
-               case TGSI_EXTSWIZZLE_ZERO:
-                       zero_mask |= (1 << c);
-                       tgsi.swz[c] = SWZ_X;
-                       break;
-               case TGSI_EXTSWIZZLE_ONE:
-                       one_mask |= (1 << c);
-                       tgsi.swz[c] = SWZ_X;
-                       break;
                default:
                        assert(0);
                }
-
-               if (!tgsi.negate && neg[c])
-                       neg_mask |= (1 << c);
        }
 
-       if (mask == MASK_ALL && !neg_mask)
+       if (mask == MASK_ALL)
                return TRUE;
 
        *src = temp(fpc);
@@ -357,18 +343,6 @@ src_native_swz(struct nv30_fpc *fpc, const struct tgsi_full_src_register *fsrc,
        if (mask)
                arith(fpc, 0, MOV, *src, mask, tgsi, none, none);
 
-       if (zero_mask)
-               arith(fpc, 0, SFL, *src, zero_mask, *src, none, none);
-
-       if (one_mask)
-               arith(fpc, 0, STR, *src, one_mask, *src, none, none);
-
-       if (neg_mask) {
-               struct nv30_sreg one = temp(fpc);
-               arith(fpc, 0, STR, one, neg_mask, one, none, none);
-               arith(fpc, 0, MUL, *src, neg_mask, *src, neg(one), none);
-       }
-
        return FALSE;
 }
 
@@ -389,8 +363,8 @@ nv30_fragprog_parse_instruction(struct nv30_fpc *fpc,
        for (i = 0; i < finst->Instruction.NumSrcRegs; i++) {
                const struct tgsi_full_src_register *fsrc;
 
-               fsrc = &finst->FullSrcRegisters[i];
-               if (fsrc->SrcRegister.File == TGSI_FILE_TEMPORARY) {
+               fsrc = &finst->Src[i];
+               if (fsrc->Register.File == TGSI_FILE_TEMPORARY) {
                        src[i] = tgsi_src(fpc, fsrc);
                }
        }
@@ -398,9 +372,9 @@ nv30_fragprog_parse_instruction(struct nv30_fpc *fpc,
        for (i = 0; i < finst->Instruction.NumSrcRegs; i++) {
                const struct tgsi_full_src_register *fsrc;
 
-               fsrc = &finst->FullSrcRegisters[i];
+               fsrc = &finst->Src[i];
 
-               switch (fsrc->SrcRegister.File) {
+               switch (fsrc->Register.File) {
                case TGSI_FILE_INPUT:
                case TGSI_FILE_CONSTANT:
                case TGSI_FILE_TEMPORARY:
@@ -411,14 +385,14 @@ nv30_fragprog_parse_instruction(struct nv30_fpc *fpc,
                        break;
                }
 
-               switch (fsrc->SrcRegister.File) {
+               switch (fsrc->Register.File) {
                case TGSI_FILE_INPUT:
-                       if (ai == -1 || ai == fsrc->SrcRegister.Index) {
-                               ai = fsrc->SrcRegister.Index;
+                       if (ai == -1 || ai == fsrc->Register.Index) {
+                               ai = fsrc->Register.Index;
                                src[i] = tgsi_src(fpc, fsrc);
                        } else {
                                NOUVEAU_MSG("extra src attr %d\n",
-                                        fsrc->SrcRegister.Index);
+                                        fsrc->Register.Index);
                                src[i] = temp(fpc);
                                arith(fpc, 0, MOV, src[i], MASK_ALL,
                                      tgsi_src(fpc, fsrc), none, none);
@@ -426,8 +400,8 @@ nv30_fragprog_parse_instruction(struct nv30_fpc *fpc,
                        break;
                case TGSI_FILE_CONSTANT:
                case TGSI_FILE_IMMEDIATE:
-                       if (ci == -1 || ci == fsrc->SrcRegister.Index) {
-                               ci = fsrc->SrcRegister.Index;
+                       if (ci == -1 || ci == fsrc->Register.Index) {
+                               ci = fsrc->Register.Index;
                                src[i] = tgsi_src(fpc, fsrc);
                        } else {
                                src[i] = temp(fpc);
@@ -439,7 +413,7 @@ nv30_fragprog_parse_instruction(struct nv30_fpc *fpc,
                        /* handled above */
                        break;
                case TGSI_FILE_SAMPLER:
-                       unit = fsrc->SrcRegister.Index;
+                       unit = fsrc->Register.Index;
                        break;
                case TGSI_FILE_OUTPUT:
                        break;
@@ -449,8 +423,8 @@ nv30_fragprog_parse_instruction(struct nv30_fpc *fpc,
                }
        }
 
-       dst  = tgsi_dst(fpc, &finst->FullDstRegisters[0]);
-       mask = tgsi_mask(finst->FullDstRegisters[0].DstRegister.WriteMask);
+       dst  = tgsi_dst(fpc, &finst->Dst[0]);
+       mask = tgsi_mask(finst->Dst[0].Register.WriteMask);
        sat  = (finst->Instruction.Saturate == TGSI_SAT_ZERO_ONE);
 
        switch (finst->Instruction.Opcode) {
@@ -461,10 +435,11 @@ nv30_fragprog_parse_instruction(struct nv30_fpc *fpc,
                arith(fpc, sat, ADD, dst, mask, src[0], src[1], none);
                break;
        case TGSI_OPCODE_CMP:
-               tmp = temp(fpc);
-               arith(fpc, sat, MOV, dst, mask, src[2], none, none);
+               tmp = nv30_sr(NV30SR_NONE, 0);
                tmp.cc_update = 1;
                arith(fpc, 0, MOV, tmp, 0xf, src[0], none, none);
+               dst.cc_test = NV30_VP_INST_COND_GE;
+               arith(fpc, sat, MOV, dst, mask, src[2], none, none);
                dst.cc_test = NV30_VP_INST_COND_LT;
                arith(fpc, sat, MOV, dst, mask, src[1], none, none);
                break;
@@ -527,12 +502,6 @@ nv30_fragprog_parse_instruction(struct nv30_fpc *fpc,
        case TGSI_OPCODE_MUL:
                arith(fpc, sat, MUL, dst, mask, src[0], src[1], none);
                break;
-       case TGSI_OPCODE_NOISE1:
-       case TGSI_OPCODE_NOISE2:
-       case TGSI_OPCODE_NOISE3:
-       case TGSI_OPCODE_NOISE4:
-               arith(fpc, sat, SFL, dst, mask, none, none, none);
-               break;
        case TGSI_OPCODE_POW:
                arith(fpc, sat, POW, dst, mask, src[0], src[1], none);
                break;
@@ -549,13 +518,28 @@ nv30_fragprog_parse_instruction(struct nv30_fpc *fpc,
                arith(fpc, sat, RSQ, dst, mask, abs(swz(src[0], X, X, X, X)), none, none);
                break;
        case TGSI_OPCODE_SCS:
-               if (mask & MASK_X) {
-                       arith(fpc, sat, COS, dst, MASK_X,
-                             swz(src[0], X, X, X, X), none, none);
+               /* avoid overwriting the source */
+               if(src[0].swz[SWZ_X] != SWZ_X)
+               {
+                       if (mask & MASK_X) {
+                               arith(fpc, sat, COS, dst, MASK_X,
+                                     swz(src[0], X, X, X, X), none, none);
+                       }
+                       if (mask & MASK_Y) {
+                               arith(fpc, sat, SIN, dst, MASK_Y,
+                                     swz(src[0], X, X, X, X), none, none);
+                       }
                }
-               if (mask & MASK_Y) {
-                       arith(fpc, sat, SIN, dst, MASK_Y,
-                             swz(src[0], X, X, X, X), none, none);
+               else
+               {
+                       if (mask & MASK_Y) {
+                               arith(fpc, sat, SIN, dst, MASK_Y,
+                                     swz(src[0], X, X, X, X), none, none);
+                       }
+                       if (mask & MASK_X) {
+                               arith(fpc, sat, COS, dst, MASK_X,
+                                     swz(src[0], X, X, X, X), none, none);
+                       }
                }
                break;
        case TGSI_OPCODE_SIN:
@@ -604,15 +588,15 @@ nv30_fragprog_parse_decl_attrib(struct nv30_fpc *fpc,
 {
        int hw;
 
-       switch (fdec->Semantic.SemanticName) {
+       switch (fdec->Semantic.Name) {
        case TGSI_SEMANTIC_POSITION:
                hw = NV30_FP_OP_INPUT_SRC_POSITION;
                break;
        case TGSI_SEMANTIC_COLOR:
-               if (fdec->Semantic.SemanticIndex == 0) {
+               if (fdec->Semantic.Index == 0) {
                        hw = NV30_FP_OP_INPUT_SRC_COL0;
                } else
-               if (fdec->Semantic.SemanticIndex == 1) {
+               if (fdec->Semantic.Index == 1) {
                        hw = NV30_FP_OP_INPUT_SRC_COL1;
                } else {
                        NOUVEAU_ERR("bad colour semantic index\n");
@@ -623,9 +607,9 @@ nv30_fragprog_parse_decl_attrib(struct nv30_fpc *fpc,
                hw = NV30_FP_OP_INPUT_SRC_FOGC;
                break;
        case TGSI_SEMANTIC_GENERIC:
-               if (fdec->Semantic.SemanticIndex <= 7) {
+               if (fdec->Semantic.Index <= 7) {
                        hw = NV30_FP_OP_INPUT_SRC_TC(fdec->Semantic.
-                                                    SemanticIndex);
+                                                    Index);
                } else {
                        NOUVEAU_ERR("bad generic semantic index\n");
                        return FALSE;
@@ -636,7 +620,7 @@ nv30_fragprog_parse_decl_attrib(struct nv30_fpc *fpc,
                return FALSE;
        }
 
-       fpc->attrib_map[fdec->DeclarationRange.First] = hw;
+       fpc->attrib_map[fdec->Range.First] = hw;
        return TRUE;
 }
 
@@ -644,12 +628,12 @@ static boolean
 nv30_fragprog_parse_decl_output(struct nv30_fpc *fpc,
                                const struct tgsi_full_declaration *fdec)
 {
-       switch (fdec->Semantic.SemanticName) {
+       switch (fdec->Semantic.Name) {
        case TGSI_SEMANTIC_POSITION:
-               fpc->depth_id = fdec->DeclarationRange.First;
+               fpc->depth_id = fdec->Range.First;
                break;
        case TGSI_SEMANTIC_COLOR:
-               fpc->colour_id = fdec->DeclarationRange.First;
+               fpc->colour_id = fdec->Range.First;
                break;
        default:
                NOUVEAU_ERR("bad output semantic\n");
@@ -685,9 +669,9 @@ nv30_fragprog_prepare(struct nv30_fpc *fpc)
                                        goto out_err;
                                break;
                        /*case TGSI_FILE_TEMPORARY:
-                               if (fdec->DeclarationRange.Last > high_temp) {
+                               if (fdec->Range.Last > high_temp) {
                                        high_temp =
-                                               fdec->DeclarationRange.Last;
+                                               fdec->Range.Last;
                                }
                                break;*/
                        default:
@@ -699,7 +683,7 @@ nv30_fragprog_prepare(struct nv30_fpc *fpc)
                {
                        struct tgsi_full_immediate *imm;
                        float vals[4];
-                       
+
                        imm = &p.FullToken.FullImmediate;
                        assert(imm->Immediate.DataType == TGSI_IMM_FLOAT32);
                        assert(fpc->nr_imm < MAX_IMM);
@@ -787,7 +771,7 @@ nv30_fragprog_translate(struct nv30_context *nv30,
        fp->insn[fpc->inst_offset + 1] = 0x00000000;
        fp->insn[fpc->inst_offset + 2] = 0x00000000;
        fp->insn[fpc->inst_offset + 3] = 0x00000000;
-       
+
        fp->translated = TRUE;
        fp->on_hw = FALSE;
 out_err:
@@ -853,7 +837,7 @@ nv30_fragprog_validate(struct nv30_context *nv30)
        fp->buffer = pscreen->buffer_create(pscreen, 0x100, 0, fp->insn_len * 4);
        nv30_fragprog_upload(nv30, fp);
 
-       so = so_new(8, 1);
+       so = so_new(4, 4, 1);
        so_method(so, nv30->screen->rankine, NV34TCL_FP_ACTIVE_PROGRAM, 1);
        so_reloc (so, nouveau_bo(fp->buffer), 0, NOUVEAU_BO_VRAM |
                      NOUVEAU_BO_GART | NOUVEAU_BO_RD | NOUVEAU_BO_LOW |
@@ -871,7 +855,7 @@ nv30_fragprog_validate(struct nv30_context *nv30)
 update_constants:
        if (fp->nr_consts) {
                float *map;
-               
+
                map = pipe_buffer_map(pscreen, constbuf,
                                      PIPE_BUFFER_USAGE_CPU_READ);
                for (i = 0; i < fp->nr_consts; i++) {
@@ -902,6 +886,12 @@ void
 nv30_fragprog_destroy(struct nv30_context *nv30,
                      struct nv30_fragment_program *fp)
 {
+       if (fp->buffer)
+               pipe_buffer_reference(&fp->buffer, NULL);
+
+       if (fp->so)
+               so_ref(NULL, &fp->so);
+
        if (fp->insn_len)
                FREE(fp->insn);
 }
index 822e1d8defe7c42b0f1dcdceb6737d306cf62131..989356789114baa0dc5ca2da98ca402254854f02 100644 (file)
@@ -21,6 +21,7 @@ struct nv30_texture_format {
 
 static struct nv30_texture_format
 nv30_texture_formats[] = {
+       _(X8R8G8B8_UNORM, A8R8G8B8,   S1,   S1,   S1,  ONE, X, Y, Z, W),
        _(A8R8G8B8_UNORM, A8R8G8B8,   S1,   S1,   S1,   S1, X, Y, Z, W),
        _(A1R5G5B5_UNORM, A1R5G5B5,   S1,   S1,   S1,   S1, X, Y, Z, W),
        _(A4R4G4B4_UNORM, A4R4G4B4,   S1,   S1,   S1,   S1, X, Y, Z, W),
@@ -29,8 +30,8 @@ nv30_texture_formats[] = {
        _(A8_UNORM      , L8      , ZERO, ZERO, ZERO,   S1, X, X, X, X),
        _(I8_UNORM      , L8      ,   S1,   S1,   S1,   S1, X, X, X, X),
        _(A8L8_UNORM    , A8L8    ,   S1,   S1,   S1,   S1, X, X, X, Y),
-//     _(Z16_UNORM     , Z16     ,   S1,   S1,   S1,  ONE, X, X, X, X),
-//     _(Z24S8_UNORM   , Z24     ,   S1,   S1,   S1,  ONE, X, X, X, X),
+       _(Z16_UNORM     , R5G6B5  ,   S1,   S1,   S1,  ONE, X, X, X, X),
+       _(Z24S8_UNORM   , A8R8G8B8,   S1,   S1,   S1,  ONE, X, X, X, X),
        _(DXT1_RGB      , DXT1    ,   S1,   S1,   S1,  ONE, X, Y, Z, W),
        _(DXT1_RGBA     , DXT1    ,   S1,   S1,   S1,   S1, X, Y, Z, W),
        _(DXT3_RGBA     , DXT3    ,   S1,   S1,   S1,   S1, X, Y, Z, W),
@@ -69,13 +70,13 @@ nv30_fragtex_build(struct nv30_context *nv30, int unit)
 
        tf = nv30_fragtex_format(pt->format);
        if (!tf)
-               assert(0);
+               return NULL;
 
        txf  = tf->format;
        txf |= ((pt->last_level>0) ? NV34TCL_TX_FORMAT_MIPMAP : 0);
-       txf |= log2i(pt->width[0]) << 20;
-       txf |= log2i(pt->height[0]) << 24;
-       txf |= log2i(pt->depth[0]) << 28;
+       txf |= log2i(pt->width0) << NV34TCL_TX_FORMAT_BASE_SIZE_U_SHIFT;
+       txf |= log2i(pt->height0) << NV34TCL_TX_FORMAT_BASE_SIZE_V_SHIFT;
+       txf |= log2i(pt->depth0) << NV34TCL_TX_FORMAT_BASE_SIZE_W_SHIFT;
        txf |= NV34TCL_TX_FORMAT_NO_BORDER | 0x10000;
 
        switch (pt->target) {
@@ -105,7 +106,7 @@ nv30_fragtex_build(struct nv30_context *nv30, int unit)
 
        txs = tf->swizzle;
 
-       so = so_new(16, 2);
+       so = so_new(1, 8, 2);
        so_method(so, nv30->screen->rankine, NV34TCL_TX_OFFSET(unit), 8);
        so_reloc (so, bo, 0, tex_flags | NOUVEAU_BO_LOW, 0, 0);
        so_reloc (so, bo, txf, tex_flags | NOUVEAU_BO_OR,
@@ -114,8 +115,8 @@ nv30_fragtex_build(struct nv30_context *nv30, int unit)
        so_data  (so, NV34TCL_TX_ENABLE_ENABLE | ps->en);
        so_data  (so, txs);
        so_data  (so, ps->filt | 0x2000 /*voodoo*/);
-       so_data  (so, (pt->width[0] << NV34TCL_TX_NPOT_SIZE_W_SHIFT) |
-                      pt->height[0]);
+       so_data  (so, (pt->width0 << NV34TCL_TX_NPOT_SIZE_W_SHIFT) |
+                      pt->height0);
        so_data  (so, ps->bcol);
 
        return so;
@@ -134,7 +135,7 @@ nv30_fragtex_validate(struct nv30_context *nv30)
                unit = ffs(samplers) - 1;
                samplers &= ~(1 << unit);
 
-               so = so_new(2, 0);
+               so = so_new(1, 1, 0);
                so_method(so, nv30->screen->rankine, NV34TCL_TX_ENABLE(unit), 1);
                so_data  (so, 0);
                so_ref(so, &nv30->state.hw[NV30_STATE_FRAGTEX0 + unit]);
index 7f8054de733400588a61df830b6063db2115164a..8fbba38e78f30d9cf59f6f4e8465f4c1fdf64103 100644 (file)
@@ -1,14 +1,17 @@
 #include "pipe/p_state.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_inlines.h"
+#include "util/u_format.h"
+#include "util/u_math.h"
 
 #include "nv30_context.h"
+#include "../nv04/nv04_surface_2d.h"
 
 static void
 nv30_miptree_layout(struct nv30_miptree *nv30mt)
 {
        struct pipe_texture *pt = &nv30mt->base;
-       uint width = pt->width[0], height = pt->height[0], depth = pt->depth[0];
+       uint width = pt->width0;
        uint offset = 0;
        int nr_faces, l, f;
        uint wide_pitch = pt->tex_usage & (PIPE_TEXTURE_USAGE_SAMPLER |
@@ -21,29 +24,21 @@ nv30_miptree_layout(struct nv30_miptree *nv30mt)
                nr_faces = 6;
        } else
        if (pt->target == PIPE_TEXTURE_3D) {
-               nr_faces = pt->depth[0];
+               nr_faces = pt->depth0;
        } else {
                nr_faces = 1;
        }
 
        for (l = 0; l <= pt->last_level; l++) {
-               pt->width[l] = width;
-               pt->height[l] = height;
-               pt->depth[l] = depth;
-               pt->nblocksx[l] = pf_get_nblocksx(&pt->block, width);
-               pt->nblocksy[l] = pf_get_nblocksy(&pt->block, height);
-
                if (wide_pitch && (pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR))
-                       nv30mt->level[l].pitch = align(pt->width[0] * pt->block.size, 64);
+                       nv30mt->level[l].pitch = align(util_format_get_stride(pt->format, pt->width0), 64);
                else
-                       nv30mt->level[l].pitch = pt->width[l] * pt->block.size;
+                       nv30mt->level[l].pitch = util_format_get_stride(pt->format, width);
 
                nv30mt->level[l].image_offset =
                        CALLOC(nr_faces, sizeof(unsigned));
 
-               width  = MAX2(1, width  >> 1);
-               height = MAX2(1, height >> 1);
-               depth  = MAX2(1, depth  >> 1);
+               width  = u_minify(width, 1);
        }
 
        for (f = 0; f < nr_faces; f++) {
@@ -51,14 +46,14 @@ nv30_miptree_layout(struct nv30_miptree *nv30mt)
                        nv30mt->level[l].image_offset[f] = offset;
 
                        if (!(pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR) &&
-                           pt->width[l + 1] > 1 && pt->height[l + 1] > 1)
-                               offset += align(nv30mt->level[l].pitch * pt->height[l], 64);
+                           u_minify(pt->width0, l + 1) > 1 && u_minify(pt->height0, l + 1) > 1)
+                               offset += align(nv30mt->level[l].pitch * u_minify(pt->height0, l), 64);
                        else
-                               offset += nv30mt->level[l].pitch * pt->height[l];
+                               offset += nv30mt->level[l].pitch * u_minify(pt->height0, l);
                }
 
                nv30mt->level[l].image_offset[f] = offset;
-               offset += nv30mt->level[l].pitch * pt->height[l];
+               offset += nv30mt->level[l].pitch * u_minify(pt->height0, l);
        }
 
        nv30mt->total_size = offset;
@@ -79,8 +74,8 @@ nv30_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
        mt->base.screen = pscreen;
 
        /* Swizzled textures must be POT */
-       if (pt->width[0] & (pt->width[0] - 1) ||
-           pt->height[0] & (pt->height[0] - 1))
+       if (pt->width0 & (pt->width0 - 1) ||
+           pt->height0 & (pt->height0 - 1))
                mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
        else
        if (pt->tex_usage & (PIPE_TEXTURE_USAGE_PRIMARY |
@@ -96,6 +91,11 @@ nv30_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
                case PIPE_FORMAT_A8R8G8B8_UNORM:
                case PIPE_FORMAT_X8R8G8B8_UNORM:
                case PIPE_FORMAT_R16_SNORM:
+               case PIPE_FORMAT_R5G6B5_UNORM:
+               case PIPE_FORMAT_A8L8_UNORM:
+               case PIPE_FORMAT_A8_UNORM:
+               case PIPE_FORMAT_L8_UNORM:
+               case PIPE_FORMAT_I8_UNORM:
                {
                        if (debug_get_bool_option("NOUVEAU_NO_SWIZZLE", FALSE))
                                mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
@@ -109,6 +109,12 @@ nv30_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
        if (pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC)
                buf_usage |= PIPE_BUFFER_USAGE_CPU_READ_WRITE;
 
+       /* apparently we can't render to swizzled surfaces smaller than 64 bytes, so make them linear.
+        * If the user did not ask for a render target, they can still render to it, but it will cost them an extra copy.
+        * This also happens for small mipmaps of large textures. */
+       if (pt->tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET && util_format_get_stride(pt->format, pt->width0) < 64)
+               mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
+
        nv30_miptree_layout(mt);
 
        mt->buffer = pscreen->buffer_create(pscreen, 256, buf_usage,
@@ -117,6 +123,7 @@ nv30_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
                FREE(mt);
                return NULL;
        }
+       mt->bo = nouveau_bo(mt->buffer);
 
        return &mt->base;
 }
@@ -129,7 +136,7 @@ nv30_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
 
        /* Only supports 2D, non-mipmapped textures for the moment */
        if (pt->target != PIPE_TEXTURE_2D || pt->last_level != 0 ||
-           pt->depth[0] != 1)
+           pt->depth0 != 1)
                return NULL;
 
        mt = CALLOC_STRUCT(nv30_miptree);
@@ -142,7 +149,11 @@ nv30_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
        mt->level[0].pitch = stride[0];
        mt->level[0].image_offset = CALLOC(1, sizeof(unsigned));
 
+       /* Assume whoever created this buffer expects it to be linear for now */
+       mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
+
        pipe_buffer_reference(&mt->buffer, pb);
+       mt->bo = nouveau_bo(mt->buffer);
        return &mt->base;
 }
 
@@ -174,8 +185,8 @@ nv30_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
                return NULL;
        pipe_texture_reference(&ns->base.texture, pt);
        ns->base.format = pt->format;
-       ns->base.width = pt->width[level];
-       ns->base.height = pt->height[level];
+       ns->base.width = u_minify(pt->width0, level);
+       ns->base.height = u_minify(pt->height0, level);
        ns->base.usage = flags;
        pipe_reference_init(&ns->base.reference, 1);
        ns->base.face = face;
@@ -192,12 +203,27 @@ nv30_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
                ns->base.offset = nv30mt->level[level].image_offset[0];
        }
 
+       /* create a linear temporary that we can render into if necessary.
+        * Note that ns->pitch is always a multiple of 64 for linear surfaces and swizzled surfaces are POT, so
+        * ns->pitch & 63 is equivalent to (ns->pitch < 64 && swizzled)*/
+       if((ns->pitch & 63) && (ns->base.usage & (PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER)) == PIPE_BUFFER_USAGE_GPU_WRITE)
+               return &nv04_surface_wrap_for_render(pscreen, ((struct nv30_screen*)pscreen)->eng2d, ns)->base;
+
        return &ns->base;
 }
 
 static void
 nv30_miptree_surface_del(struct pipe_surface *ps)
 {
+       struct nv04_surface* ns = (struct nv04_surface*)ps;
+       if(ns->backing)
+       {
+               struct nv30_screen* screen = (struct nv30_screen*)ps->texture->screen;
+               if(ns->backing->base.usage & PIPE_BUFFER_USAGE_GPU_WRITE)
+                       screen->eng2d->copy(screen->eng2d, &ns->backing->base, 0, 0, ps, 0, 0, ns->base.width, ns->base.height);
+               nv30_miptree_surface_del(&ns->backing->base);
+       }
+
        pipe_texture_reference(&ps->texture, NULL);
        FREE(ps);
 }
index 1d1c8a484e1933da0d78cab6297e01bbce5377a4..e27e9ccbf60f7ae3705e3aeaa2991f110e74bc02 100644 (file)
@@ -41,6 +41,9 @@ nv30_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
 {
        struct nv30_context *nv30 = nv30_context(pipe);
        struct nv30_query *q = nv30_query(pq);
+       struct nv30_screen *screen = nv30->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *rankine = screen->rankine;
 
        assert(q->type == PIPE_QUERY_OCCLUSION_COUNTER);
 
@@ -57,10 +60,10 @@ nv30_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
                assert(0);
        nouveau_notifier_reset(nv30->screen->query, q->object->start);
 
-       BEGIN_RING(rankine, NV34TCL_QUERY_RESET, 1);
-       OUT_RING  (1);
-       BEGIN_RING(rankine, NV34TCL_QUERY_UNK17CC, 1);
-       OUT_RING  (1);
+       BEGIN_RING(chan, rankine, NV34TCL_QUERY_RESET, 1);
+       OUT_RING  (chan, 1);
+       BEGIN_RING(chan, rankine, NV34TCL_QUERY_UNK17CC, 1);
+       OUT_RING  (chan, 1);
 
        q->ready = FALSE;
 }
@@ -69,12 +72,15 @@ static void
 nv30_query_end(struct pipe_context *pipe, struct pipe_query *pq)
 {
        struct nv30_context *nv30 = nv30_context(pipe);
+       struct nv30_screen *screen = nv30->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *rankine = screen->rankine;
        struct nv30_query *q = nv30_query(pq);
 
-       BEGIN_RING(rankine, NV34TCL_QUERY_GET, 1);
-       OUT_RING  ((0x01 << NV34TCL_QUERY_GET_UNK24_SHIFT) |
+       BEGIN_RING(chan, rankine, NV34TCL_QUERY_GET, 1);
+       OUT_RING  (chan, (0x01 << NV34TCL_QUERY_GET_UNK24_SHIFT) |
                   ((q->object->start * 32) << NV34TCL_QUERY_GET_OFFSET_SHIFT));
-       FIRE_RING(NULL);
+       FIRE_RING(chan);
 }
 
 static boolean
index 41af38450b5f5498997496e4a4db9adb346980d0..9ed48178dc2b6d12bf26c8f41abcb6b64e1a4325 100644 (file)
 #define NV34TCL_CHIPSET_3X_MASK 0x00000010
 #define NV35TCL_CHIPSET_3X_MASK 0x000001e0
 
+/* FIXME: It seems I should not include directly ../../winsys/drm/nouveau/drm/nouveau_drm_api.h
+ * to get the pointer to the context front buffer, so I copied nouveau_winsys here.
+ * nv30_screen_surface_format_supported() can then use it to enforce creating fbo
+ * with same number of bits everywhere.
+ */
+struct nouveau_winsys {
+       struct pipe_winsys base;
+
+       struct pipe_screen *pscreen;
+
+       unsigned nr_pctx;
+       struct pipe_context **pctx;
+
+       struct pipe_surface *front;
+};
+
 static int
 nv30_screen_get_param(struct pipe_screen *pscreen, int param)
 {
@@ -83,6 +99,8 @@ nv30_screen_surface_format_supported(struct pipe_screen *pscreen,
                                     enum pipe_texture_target target,
                                     unsigned tex_usage, unsigned geom_flags)
 {
+       struct pipe_surface *front = ((struct nouveau_winsys *) pscreen->winsys)->front;
+
        if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) {
                switch (format) {
                case PIPE_FORMAT_A8R8G8B8_UNORM:
@@ -96,7 +114,11 @@ nv30_screen_surface_format_supported(struct pipe_screen *pscreen,
                switch (format) {
                case PIPE_FORMAT_Z24S8_UNORM:
                case PIPE_FORMAT_Z24X8_UNORM:
+                       return TRUE;
                case PIPE_FORMAT_Z16_UNORM:
+                       if (front) {
+                               return (front->format == PIPE_FORMAT_R5G6B5_UNORM);
+                       }
                        return TRUE;
                default:
                        break;
@@ -134,6 +156,12 @@ static void
 nv30_screen_destroy(struct pipe_screen *pscreen)
 {
        struct nv30_screen *screen = nv30_screen(pscreen);
+       unsigned i;
+
+       for (i = 0; i < NV30_STATE_MAX; i++) {
+               if (screen->state[i])
+                       so_ref(NULL, &screen->state[i]);
+       }
 
        nouveau_resource_free(&screen->vp_exec_heap);
        nouveau_resource_free(&screen->vp_data_heap);
@@ -141,6 +169,9 @@ nv30_screen_destroy(struct pipe_screen *pscreen)
        nouveau_notifier_free(&screen->query);
        nouveau_notifier_free(&screen->sync);
        nouveau_grobj_free(&screen->rankine);
+       nv04_surface_2d_takedown(&screen->eng2d);
+
+       nouveau_screen_fini(&screen->base);
 
        FREE(pscreen);
 }
@@ -202,7 +233,6 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
                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);
@@ -239,7 +269,7 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
        }
 
        /* Static rankine initialisation */
-       so = so_new(128, 0);
+       so = so_new(36, 60, 0);
        so_method(so, screen->rankine, NV34TCL_DMA_NOTIFY, 1);
        so_data  (so, screen->sync->handle);
        so_method(so, screen->rankine, NV34TCL_DMA_TEXTURE0, 2);
index b91e972c12336783abd0910564f87e011eaf7b31..a80dfb04880db04a30967706ca72d083e3546eb7 100644 (file)
@@ -14,7 +14,7 @@ nv30_blend_state_create(struct pipe_context *pipe,
        struct nv30_context *nv30 = nv30_context(pipe);
        struct nouveau_grobj *rankine = nv30->screen->rankine;
        struct nv30_blend_state *bso = CALLOC(1, sizeof(*bso));
-       struct nouveau_stateobj *so = so_new(16, 0);
+       struct nouveau_stateobj *so = so_new(5, 8, 0);
 
        if (cso->blend_enable) {
                so_method(so, rankine, NV34TCL_BLEND_FUNC_ENABLE, 3);
@@ -300,7 +300,7 @@ nv30_rasterizer_state_create(struct pipe_context *pipe,
 {
        struct nv30_context *nv30 = nv30_context(pipe);
        struct nv30_rasterizer_state *rsso = CALLOC(1, sizeof(*rsso));
-       struct nouveau_stateobj *so = so_new(32, 0);
+       struct nouveau_stateobj *so = so_new(9, 19, 0);
        struct nouveau_grobj *rankine = nv30->screen->rankine;
 
        /*XXX: ignored:
@@ -435,7 +435,7 @@ nv30_depth_stencil_alpha_state_create(struct pipe_context *pipe,
 {
        struct nv30_context *nv30 = nv30_context(pipe);
        struct nv30_zsa_state *zsaso = CALLOC(1, sizeof(*zsaso));
-       struct nouveau_stateobj *so = so_new(32, 0);
+       struct nouveau_stateobj *so = so_new(5, 21, 0);
        struct nouveau_grobj *rankine = nv30->screen->rankine;
 
        so_method(so, rankine, NV34TCL_DEPTH_FUNC, 3);
@@ -672,16 +672,6 @@ nv30_set_vertex_elements(struct pipe_context *pipe, unsigned count,
        /*nv30->draw_dirty |= NV30_NEW_ARRAYS;*/
 }
 
-static void
-nv30_set_edgeflags(struct pipe_context *pipe, const unsigned *bitfield)
-{
-       struct nv30_context *nv30 = nv30_context(pipe);
-
-       nv30->edgeflags = bitfield;
-       nv30->dirty |= NV30_NEW_ARRAYS;
-       /*nv30->draw_dirty |= NV30_NEW_ARRAYS;*/
-}
-
 void
 nv30_init_state_functions(struct nv30_context *nv30)
 {
@@ -690,9 +680,9 @@ nv30_init_state_functions(struct nv30_context *nv30)
        nv30->pipe.delete_blend_state = nv30_blend_state_delete;
 
        nv30->pipe.create_sampler_state = nv30_sampler_state_create;
-       nv30->pipe.bind_sampler_states = nv30_sampler_state_bind;
+       nv30->pipe.bind_fragment_sampler_states = nv30_sampler_state_bind;
        nv30->pipe.delete_sampler_state = nv30_sampler_state_delete;
-       nv30->pipe.set_sampler_textures = nv30_set_sampler_texture;
+       nv30->pipe.set_fragment_sampler_textures = nv30_set_sampler_texture;
 
        nv30->pipe.create_rasterizer_state = nv30_rasterizer_state_create;
        nv30->pipe.bind_rasterizer_state = nv30_rasterizer_state_bind;
@@ -721,7 +711,6 @@ nv30_init_state_functions(struct nv30_context *nv30)
        nv30->pipe.set_scissor_state = nv30_set_scissor_state;
        nv30->pipe.set_viewport_state = nv30_set_viewport_state;
 
-       nv30->pipe.set_edgeflags = nv30_set_edgeflags;
        nv30->pipe.set_vertex_buffers = nv30_set_vertex_buffers;
        nv30->pipe.set_vertex_elements = nv30_set_vertex_elements;
 }
index e6f23bf166715c2fbcaf4e03d994212d6d74f2b9..e42e872de757257f3c2998b8e25e09b24d87a95e 100644 (file)
@@ -72,6 +72,7 @@ struct nv30_fragment_program {
 
 struct nv30_miptree {
        struct pipe_texture base;
+       struct nouveau_bo *bo;
 
        struct pipe_buffer *buffer;
        uint total_size;
index 64cf9ae93a0a6018262be11a7b715900acc145b6..c36d58c040cd8a1e4a194483fdb5346150168051 100644 (file)
@@ -18,7 +18,7 @@ struct nv30_state_entry nv30_state_blend = {
 static boolean
 nv30_state_blend_colour_validate(struct nv30_context *nv30)
 {
-       struct nouveau_stateobj *so = so_new(2, 0);
+       struct nouveau_stateobj *so = so_new(1, 1, 0);
        struct pipe_blend_color *bcol = &nv30->blend_colour;
 
        so_method(so, nv30->screen->rankine, NV34TCL_BLEND_COLOR, 1);
index 621b8846c8ed3835c97fd809ddfbe0dcba208e26..ac52d946f021232356e8912b47041080fe19d049 100644 (file)
@@ -41,7 +41,7 @@ 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;
+       unsigned i;
        uint64_t states;
 
        if (nv30->pctx_id != screen->cur_pctx) {
@@ -63,6 +63,14 @@ nv30_state_emit(struct nv30_context *nv30)
        }
 
        state->dirty = 0;
+}
+
+void
+nv30_state_flush_notify(struct nouveau_channel *chan)
+{
+       struct nv30_context *nv30 = chan->user_private;
+       struct nv30_state *state = &nv30->state;
+       unsigned i, samplers;
 
        so_emit_reloc_markers(chan, state->hw[NV30_STATE_FB]);
        for (i = 0, samplers = state->fp_samplers; i < 16 && samplers; i++) {
index 44b6a74715a79627c4d62908a487fa26eed96517..2ed2ea55e8473875e695d53b68e44140650cbf4a 100644 (file)
@@ -8,15 +8,15 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30)
        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;
-       struct nouveau_stateobj *so = so_new(64, 10);
+       uint32_t rt_enable = 0, rt_format = 0;
+       int i, colour_format = 0, zeta_format = 0, depth_only = 0;
+       struct nouveau_stateobj *so = so_new(12, 18, 10);
        unsigned rt_flags = NOUVEAU_BO_RDWR | NOUVEAU_BO_VRAM;
        unsigned w = fb->width;
        unsigned h = fb->height;
        struct nv30_miptree *nv30mt;
+       int colour_bits = 32, zeta_bits = 32;
 
-       rt_enable = 0;
        for (i = 0; i < fb->nr_cbufs; i++) {
                if (colour_format) {
                        assert(colour_format == fb->cbufs[i]->format);
@@ -35,26 +35,47 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30)
                zeta = (struct nv04_surface *)fb->zsbuf;
        }
 
-       if (!(rt[0]->base.texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)) {
-               assert(!(fb->width & (fb->width - 1)) && !(fb->height & (fb->height - 1)));
-               for (i = 1; i < fb->nr_cbufs; i++)
-                       assert(!(rt[i]->base.texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR));
+       if (rt_enable & (NV34TCL_RT_ENABLE_COLOR0|NV34TCL_RT_ENABLE_COLOR1)) {
+               /* Render to at least a colour buffer */
+               if (!(rt[0]->base.texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)) {
+                       assert(!(fb->width & (fb->width - 1)) && !(fb->height & (fb->height - 1)));
+                       for (i = 1; i < fb->nr_cbufs; i++)
+                               assert(!(rt[i]->base.texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR));
 
-               /* FIXME: NV34TCL_RT_FORMAT_LOG2_[WIDTH/HEIGHT] */
-               rt_format = NV34TCL_RT_FORMAT_TYPE_SWIZZLED |
-               log2i(fb->width) << 16 /*NV34TCL_RT_FORMAT_LOG2_WIDTH_SHIFT*/ |
-               log2i(fb->height) << 24 /*NV34TCL_RT_FORMAT_LOG2_HEIGHT_SHIFT*/;
+                       rt_format = NV34TCL_RT_FORMAT_TYPE_SWIZZLED |
+                               (log2i(rt[0]->base.width) << NV34TCL_RT_FORMAT_LOG2_WIDTH_SHIFT) |
+                               (log2i(rt[0]->base.height) << NV34TCL_RT_FORMAT_LOG2_HEIGHT_SHIFT);
+               }
+               else
+                       rt_format = NV34TCL_RT_FORMAT_TYPE_LINEAR;
+       } else if (fb->zsbuf) {
+               depth_only = 1;
+
+               /* Render to depth buffer only */
+               if (!(zeta->base.texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)) {
+                       assert(!(fb->width & (fb->width - 1)) && !(fb->height & (fb->height - 1)));
+
+                       rt_format = NV34TCL_RT_FORMAT_TYPE_SWIZZLED |
+                               (log2i(zeta->base.width) << NV34TCL_RT_FORMAT_LOG2_WIDTH_SHIFT) |
+                               (log2i(zeta->base.height) << NV34TCL_RT_FORMAT_LOG2_HEIGHT_SHIFT);
+               }
+               else
+                       rt_format = NV34TCL_RT_FORMAT_TYPE_LINEAR;
+       } else {
+               return FALSE;
        }
-       else
-               rt_format = NV34TCL_RT_FORMAT_TYPE_LINEAR;
 
        switch (colour_format) {
+       case PIPE_FORMAT_X8R8G8B8_UNORM:
+               rt_format |= NV34TCL_RT_FORMAT_COLOR_X8R8G8B8;
+               break;
        case PIPE_FORMAT_A8R8G8B8_UNORM:
        case 0:
                rt_format |= NV34TCL_RT_FORMAT_COLOR_A8R8G8B8;
                break;
        case PIPE_FORMAT_R5G6B5_UNORM:
                rt_format |= NV34TCL_RT_FORMAT_COLOR_R5G6B5;
+               colour_bits = 16;
                break;
        default:
                assert(0);
@@ -63,6 +84,7 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30)
        switch (zeta_format) {
        case PIPE_FORMAT_Z16_UNORM:
                rt_format |= NV34TCL_RT_FORMAT_ZETA_Z16;
+               zeta_bits = 16;
                break;
        case PIPE_FORMAT_Z24S8_UNORM:
        case PIPE_FORMAT_Z24X8_UNORM:
@@ -73,21 +95,27 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30)
                assert(0);
        }
 
-       if (rt_enable & NV34TCL_RT_ENABLE_COLOR0) {
-               uint32_t pitch = rt[0]->pitch;
+       if (colour_bits > zeta_bits) {
+               return FALSE;
+       }
+
+       if (depth_only || (rt_enable & NV34TCL_RT_ENABLE_COLOR0)) {
+               struct nv04_surface *rt0 = (depth_only ? zeta : rt[0]);
+               uint32_t pitch = rt0->pitch;
+
                if (zeta) {
                        pitch |= (zeta->pitch << 16);
                } else {
                        pitch |= (pitch << 16);
                }
 
-               nv30mt = (struct nv30_miptree *)rt[0]->base.texture;
+               nv30mt = (struct nv30_miptree *) rt0->base.texture;
                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, nouveau_bo(nv30mt->buffer), rt[0]->base.offset,
+               so_reloc (so, nouveau_bo(nv30mt->buffer), rt0->base.offset,
                              rt_flags | NOUVEAU_BO_LOW, 0, 0);
        }
 
index 3ac7a8471eae26df8cc040e144c098bbca69121f..ba61a9e24a478cf2298d5afc7282a18ec03094c3 100644 (file)
@@ -12,7 +12,7 @@ nv30_state_scissor_validate(struct nv30_context *nv30)
                return FALSE;
        nv30->state.scissor_enabled = rast->scissor;
 
-       so = so_new(3, 0);
+       so = so_new(1, 2, 0);
        so_method(so, nv30->screen->rankine, NV34TCL_SCISSOR_HORIZ, 2);
        if (nv30->state.scissor_enabled) {
                so_data  (so, ((s->maxx - s->minx) << 16) | s->minx);
index d0c791ac0821648337f0b367bf45b189410211f5..ed520a4f439cc5dc33174378bd53653b0991210b 100644 (file)
@@ -14,14 +14,14 @@ nv30_state_stipple_validate(struct nv30_context *nv30)
        if (rast->poly_stipple_enable) {
                unsigned i;
 
-               so = so_new(35, 0);
+               so = so_new(2, 33, 0);
                so_method(so, rankine, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
                so_data  (so, 1);
                so_method(so, rankine, NV34TCL_POLYGON_STIPPLE_PATTERN(0), 32);
                for (i = 0; i < 32; i++)
                        so_data(so, nv30->stipple[i]);
        } else {
-               so = so_new(2, 0);
+               so = so_new(1, 1, 0);
                so_method(so, rankine, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
                so_data  (so, 0);
        }
index c3eb413dac69178a41d20a507df3ae94e3b2b29d..2d7781292bdded0700ac0099689f18feab759d55 100644 (file)
@@ -19,7 +19,7 @@ nv30_state_viewport_validate(struct nv30_context *nv30)
                return FALSE;
        nv30->state.viewport_bypass = bypass;
 
-       so = so_new(11, 0);
+       so = so_new(3, 10, 0);
        if (!bypass) {
                so_method(so, nv30->screen->rankine,
                          NV34TCL_VIEWPORT_TRANSLATE_X, 8);
index 98011decf7cac2c3f1e2a4cab30fe2be12f0f5d9..65598991c689c1a242a7c0d4eb3b8efe9ce70a0f 100644 (file)
@@ -1,7 +1,9 @@
 #include <pipe/p_state.h>
 #include <pipe/p_defines.h>
 #include <pipe/p_inlines.h>
+#include <util/u_format.h>
 #include <util/u_memory.h>
+#include <util/u_math.h>
 #include <nouveau/nouveau_winsys.h>
 #include "nv30_context.h"
 #include "nv30_screen.h"
 struct nv30_transfer {
        struct pipe_transfer base;
        struct pipe_surface *surface;
-       bool direct;
+       boolean direct;
 };
 
 static void
-nv30_compatible_transfer_tex(struct pipe_texture *pt, unsigned level,
+nv30_compatible_transfer_tex(struct pipe_texture *pt, unsigned width, unsigned height,
                              struct pipe_texture *template)
 {
        memset(template, 0, sizeof(struct pipe_texture));
        template->target = pt->target;
        template->format = pt->format;
-       template->width[0] = pt->width[level];
-       template->height[0] = pt->height[level];
-       template->depth[0] = 1;
-       template->block = pt->block;
-       template->nblocksx[0] = pt->nblocksx[level];
-       template->nblocksy[0] = pt->nblocksx[level];
+       template->width0 = width;
+       template->height0 = height;
+       template->depth0 = 1;
        template->last_level = 0;
        template->nr_samples = pt->nr_samples;
 
@@ -48,14 +47,10 @@ nv30_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
                return NULL;
 
        pipe_texture_reference(&tx->base.texture, pt);
-       tx->base.format = pt->format;
        tx->base.x = x;
        tx->base.y = y;
        tx->base.width = w;
        tx->base.height = h;
-       tx->base.block = pt->block;
-       tx->base.nblocksx = pt->nblocksx[level];
-       tx->base.nblocksy = pt->nblocksy[level];
        tx->base.stride = mt->level[level].pitch;
        tx->base.usage = usage;
        tx->base.face = face;
@@ -76,7 +71,7 @@ nv30_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
 
        tx->direct = false;
 
-       nv30_compatible_transfer_tex(pt, level, &tx_tex_template);
+       nv30_compatible_transfer_tex(pt, w, h, &tx_tex_template);
 
        tx_tex = pscreen->texture_create(pscreen, &tx_tex_template);
        if (!tx_tex)
@@ -85,6 +80,8 @@ nv30_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
                return NULL;
        }
 
+       tx->base.stride = ((struct nv30_miptree*)tx_tex)->level[0].pitch;
+
        tx->surface = pscreen->get_tex_surface(pscreen, tx_tex,
                                               0, 0, 0,
                                               pipe_transfer_buffer_flags(&tx->base));
@@ -110,8 +107,8 @@ nv30_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
                /* TODO: Check if SIFM can un-swizzle */
                nvscreen->eng2d->copy(nvscreen->eng2d,
                                      tx->surface, 0, 0,
-                                     src, 0, 0,
-                                     src->width, src->height);
+                                     src, x, y,
+                                     w, h);
 
                pipe_surface_reference(&src, NULL);
        }
@@ -131,13 +128,13 @@ nv30_transfer_del(struct pipe_transfer *ptx)
 
                dst = pscreen->get_tex_surface(pscreen, ptx->texture,
                                               ptx->face, ptx->level, ptx->zslice,
-                                              PIPE_BUFFER_USAGE_GPU_WRITE);
+                                              PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER);
 
                /* TODO: Check if SIFM can deal with x,y,w,h when swizzling */
                nvscreen->eng2d->copy(nvscreen->eng2d,
-                                     dst, 0, 0,
+                                     dst, tx->base.x, tx->base.y,
                                      tx->surface, 0, 0,
-                                     dst->width, dst->height);
+                                     tx->base.width, tx->base.height);
 
                pipe_surface_reference(&dst, NULL);
        }
@@ -156,8 +153,10 @@ nv30_transfer_map(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
        void *map = pipe_buffer_map(pscreen, mt->buffer,
                                    pipe_transfer_buffer_flags(ptx));
 
-       return map + ns->base.offset +
-              ptx->y * ns->pitch + ptx->x * ptx->block.size;
+       if(!tx->direct)
+               return map + ns->base.offset;
+       else
+               return map + ns->base.offset + ptx->y * ns->pitch + ptx->x * util_format_get_blocksize(ptx->texture->format);
 }
 
 static void
index 189656ec817aadb637c83b47fe31614400ab3d45..1c5db03ea240293c420d95740cfa3a34a8d56941 100644 (file)
@@ -163,19 +163,21 @@ nv30_vbo_static_attrib(struct nv30_context *nv30, struct nouveau_stateobj *so,
        return TRUE;
 }
 
-boolean
+void
 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->screen->base.channel;
+       struct nv30_screen *screen = nv30->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *rankine = screen->rankine;
        unsigned restart = 0;
 
        nv30_vbo_set_idxbuf(nv30, NULL, 0);
        if (FORCE_SWTNL || !nv30_state_validate(nv30)) {
                /*return nv30_draw_elements_swtnl(pipe, NULL, 0,
                                                mode, start, count);*/
-               return FALSE;
+               return;
        }
 
        while (count) {
@@ -186,17 +188,17 @@ nv30_draw_arrays(struct pipe_context *pipe,
                vc = nouveau_vbuf_split(chan->pushbuf->remaining, 6, 256,
                                        mode, start, count, &restart);
                if (!vc) {
-                       FIRE_RING(NULL);
+                       FIRE_RING(chan);
                        continue;
                }
 
-               BEGIN_RING(rankine, NV34TCL_VERTEX_BEGIN_END, 1);
-               OUT_RING  (nvgl_primitive(mode));
+               BEGIN_RING(chan, rankine, NV34TCL_VERTEX_BEGIN_END, 1);
+               OUT_RING  (chan, nvgl_primitive(mode));
 
                nr = (vc & 0xff);
                if (nr) {
-                       BEGIN_RING(rankine, NV34TCL_VB_VERTEX_BATCH, 1);
-                       OUT_RING  (((nr - 1) << 24) | start);
+                       BEGIN_RING(chan, rankine, NV34TCL_VB_VERTEX_BATCH, 1);
+                       OUT_RING  (chan, ((nr - 1) << 24) | start);
                        start += nr;
                }
 
@@ -206,15 +208,15 @@ nv30_draw_arrays(struct pipe_context *pipe,
 
                        nr -= push;
 
-                       BEGIN_RING_NI(rankine, NV34TCL_VB_VERTEX_BATCH, push);
+                       BEGIN_RING_NI(chan, rankine, NV34TCL_VB_VERTEX_BATCH, push);
                        while (push--) {
-                               OUT_RING(((0x100 - 1) << 24) | start);
+                               OUT_RING(chan, ((0x100 - 1) << 24) | start);
                                start += 0x100;
                        }
                }
 
-               BEGIN_RING(rankine, NV34TCL_VERTEX_BEGIN_END, 1);
-               OUT_RING  (0);
+               BEGIN_RING(chan, rankine, NV34TCL_VERTEX_BEGIN_END, 1);
+               OUT_RING  (chan, 0);
 
                count -= vc;
                start = restart;
@@ -228,7 +230,9 @@ static INLINE void
 nv30_draw_elements_u08(struct nv30_context *nv30, void *ib,
                       unsigned mode, unsigned start, unsigned count)
 {
-       struct nouveau_channel *chan = nv30->screen->base.channel;
+       struct nv30_screen *screen = nv30->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *rankine = screen->rankine;
 
        while (count) {
                uint8_t *elts = (uint8_t *)ib + start;
@@ -239,17 +243,17 @@ nv30_draw_elements_u08(struct nv30_context *nv30, void *ib,
                vc = nouveau_vbuf_split(chan->pushbuf->remaining, 6, 2,
                                        mode, start, count, &restart);
                if (vc == 0) {
-                       FIRE_RING(NULL);
+                       FIRE_RING(chan);
                        continue;
                }
                count -= vc;
 
-               BEGIN_RING(rankine, NV34TCL_VERTEX_BEGIN_END, 1);
-               OUT_RING  (nvgl_primitive(mode));
+               BEGIN_RING(chan, rankine, NV34TCL_VERTEX_BEGIN_END, 1);
+               OUT_RING  (chan, nvgl_primitive(mode));
 
                if (vc & 1) {
-                       BEGIN_RING(rankine, NV34TCL_VB_ELEMENT_U32, 1);
-                       OUT_RING  (elts[0]);
+                       BEGIN_RING(chan, rankine, NV34TCL_VB_ELEMENT_U32, 1);
+                       OUT_RING  (chan, elts[0]);
                        elts++; vc--;
                }
 
@@ -258,16 +262,16 @@ nv30_draw_elements_u08(struct nv30_context *nv30, void *ib,
 
                        push = MIN2(vc, 2047 * 2);
 
-                       BEGIN_RING_NI(rankine, NV34TCL_VB_ELEMENT_U16, push >> 1);
+                       BEGIN_RING_NI(chan, rankine, NV34TCL_VB_ELEMENT_U16, push >> 1);
                        for (i = 0; i < push; i+=2)
-                               OUT_RING((elts[i+1] << 16) | elts[i]);
+                               OUT_RING(chan, (elts[i+1] << 16) | elts[i]);
 
                        vc -= push;
                        elts += push;
                }
 
-               BEGIN_RING(rankine, NV34TCL_VERTEX_BEGIN_END, 1);
-               OUT_RING  (0);
+               BEGIN_RING(chan, rankine, NV34TCL_VERTEX_BEGIN_END, 1);
+               OUT_RING  (chan, 0);
 
                start = restart;
        }
@@ -277,7 +281,9 @@ static INLINE void
 nv30_draw_elements_u16(struct nv30_context *nv30, void *ib,
                       unsigned mode, unsigned start, unsigned count)
 {
-       struct nouveau_channel *chan = nv30->screen->base.channel;
+       struct nv30_screen *screen = nv30->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *rankine = screen->rankine;
 
        while (count) {
                uint16_t *elts = (uint16_t *)ib + start;
@@ -288,17 +294,17 @@ nv30_draw_elements_u16(struct nv30_context *nv30, void *ib,
                vc = nouveau_vbuf_split(chan->pushbuf->remaining, 6, 2,
                                        mode, start, count, &restart);
                if (vc == 0) {
-                       FIRE_RING(NULL);
+                       FIRE_RING(chan);
                        continue;
                }
                count -= vc;
 
-               BEGIN_RING(rankine, NV34TCL_VERTEX_BEGIN_END, 1);
-               OUT_RING  (nvgl_primitive(mode));
+               BEGIN_RING(chan, rankine, NV34TCL_VERTEX_BEGIN_END, 1);
+               OUT_RING  (chan, nvgl_primitive(mode));
 
                if (vc & 1) {
-                       BEGIN_RING(rankine, NV34TCL_VB_ELEMENT_U32, 1);
-                       OUT_RING  (elts[0]);
+                       BEGIN_RING(chan, rankine, NV34TCL_VB_ELEMENT_U32, 1);
+                       OUT_RING  (chan, elts[0]);
                        elts++; vc--;
                }
 
@@ -307,16 +313,16 @@ nv30_draw_elements_u16(struct nv30_context *nv30, void *ib,
 
                        push = MIN2(vc, 2047 * 2);
 
-                       BEGIN_RING_NI(rankine, NV34TCL_VB_ELEMENT_U16, push >> 1);
+                       BEGIN_RING_NI(chan, rankine, NV34TCL_VB_ELEMENT_U16, push >> 1);
                        for (i = 0; i < push; i+=2)
-                               OUT_RING((elts[i+1] << 16) | elts[i]);
+                               OUT_RING(chan, (elts[i+1] << 16) | elts[i]);
 
                        vc -= push;
                        elts += push;
                }
 
-               BEGIN_RING(rankine, NV34TCL_VERTEX_BEGIN_END, 1);
-               OUT_RING  (0);
+               BEGIN_RING(chan, rankine, NV34TCL_VERTEX_BEGIN_END, 1);
+               OUT_RING  (chan, 0);
 
                start = restart;
        }
@@ -326,7 +332,9 @@ static INLINE void
 nv30_draw_elements_u32(struct nv30_context *nv30, void *ib,
                       unsigned mode, unsigned start, unsigned count)
 {
-       struct nouveau_channel *chan = nv30->screen->base.channel;
+       struct nv30_screen *screen = nv30->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *rankine = screen->rankine;
 
        while (count) {
                uint32_t *elts = (uint32_t *)ib + start;
@@ -337,32 +345,32 @@ nv30_draw_elements_u32(struct nv30_context *nv30, void *ib,
                vc = nouveau_vbuf_split(chan->pushbuf->remaining, 5, 1,
                                        mode, start, count, &restart);
                if (vc == 0) {
-                       FIRE_RING(NULL);
+                       FIRE_RING(chan);
                        continue;
                }
                count -= vc;
 
-               BEGIN_RING(rankine, NV34TCL_VERTEX_BEGIN_END, 1);
-               OUT_RING  (nvgl_primitive(mode));
+               BEGIN_RING(chan, rankine, NV34TCL_VERTEX_BEGIN_END, 1);
+               OUT_RING  (chan, nvgl_primitive(mode));
 
                while (vc) {
                        push = MIN2(vc, 2047);
 
-                       BEGIN_RING_NI(rankine, NV34TCL_VB_ELEMENT_U32, push);
-                       OUT_RINGp    (elts, push);
+                       BEGIN_RING_NI(chan, rankine, NV34TCL_VB_ELEMENT_U32, push);
+                       OUT_RINGp    (chan, elts, push);
 
                        vc -= push;
                        elts += push;
                }
 
-               BEGIN_RING(rankine, NV34TCL_VERTEX_BEGIN_END, 1);
-               OUT_RING  (0);
+               BEGIN_RING(chan, rankine, NV34TCL_VERTEX_BEGIN_END, 1);
+               OUT_RING  (chan, 0);
 
                start = restart;
        }
 }
 
-static boolean
+static void
 nv30_draw_elements_inline(struct pipe_context *pipe,
                          struct pipe_buffer *ib, unsigned ib_size,
                          unsigned mode, unsigned start, unsigned count)
@@ -393,15 +401,16 @@ nv30_draw_elements_inline(struct pipe_context *pipe,
        }
 
        pipe_buffer_unmap(pscreen, ib);
-       return TRUE;
 }
 
-static boolean
+static void
 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->screen->base.channel;
+       struct nv30_screen *screen = nv30->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *rankine = screen->rankine;
        unsigned restart = 0;
 
        while (count) {
@@ -412,17 +421,17 @@ nv30_draw_elements_vbo(struct pipe_context *pipe,
                vc = nouveau_vbuf_split(chan->pushbuf->remaining, 6, 256,
                                        mode, start, count, &restart);
                if (!vc) {
-                       FIRE_RING(NULL);
+                       FIRE_RING(chan);
                        continue;
                }
                
-               BEGIN_RING(rankine, NV34TCL_VERTEX_BEGIN_END, 1);
-               OUT_RING  (nvgl_primitive(mode));
+               BEGIN_RING(chan, rankine, NV34TCL_VERTEX_BEGIN_END, 1);
+               OUT_RING  (chan, nvgl_primitive(mode));
 
                nr = (vc & 0xff);
                if (nr) {
-                       BEGIN_RING(rankine, NV34TCL_VB_INDEX_BATCH, 1);
-                       OUT_RING  (((nr - 1) << 24) | start);
+                       BEGIN_RING(chan, rankine, NV34TCL_VB_INDEX_BATCH, 1);
+                       OUT_RING  (chan, ((nr - 1) << 24) | start);
                        start += nr;
                }
 
@@ -432,24 +441,22 @@ nv30_draw_elements_vbo(struct pipe_context *pipe,
 
                        nr -= push;
 
-                       BEGIN_RING_NI(rankine, NV34TCL_VB_INDEX_BATCH, push);
+                       BEGIN_RING_NI(chan, rankine, NV34TCL_VB_INDEX_BATCH, push);
                        while (push--) {
-                               OUT_RING(((0x100 - 1) << 24) | start);
+                               OUT_RING(chan, ((0x100 - 1) << 24) | start);
                                start += 0x100;
                        }
                }
 
-               BEGIN_RING(rankine, NV34TCL_VERTEX_BEGIN_END, 1);
-               OUT_RING  (0);
+               BEGIN_RING(chan, rankine, NV34TCL_VERTEX_BEGIN_END, 1);
+               OUT_RING  (chan, 0);
 
                count -= vc;
                start = restart;
        }
-
-       return TRUE;
 }
 
-boolean
+void
 nv30_draw_elements(struct pipe_context *pipe,
                   struct pipe_buffer *indexBuffer, unsigned indexSize,
                   unsigned mode, unsigned start, unsigned count)
@@ -461,7 +468,7 @@ nv30_draw_elements(struct pipe_context *pipe,
        if (FORCE_SWTNL || !nv30_state_validate(nv30)) {
                /*return nv30_draw_elements_swtnl(pipe, NULL, 0,
                                                mode, start, count);*/
-               return FALSE;   
+               return; 
        }
 
        if (idxbuf) {
@@ -472,7 +479,6 @@ nv30_draw_elements(struct pipe_context *pipe,
        }
 
        pipe->flush(pipe, 0, NULL);
-       return TRUE;
 }
 
 static boolean
@@ -485,14 +491,9 @@ nv30_vbo_validate(struct nv30_context *nv30)
        unsigned vb_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD;
        int hw;
 
-       if (nv30->edgeflags) {
-               /*nv30->fallback_swtnl |= NV30_NEW_ARRAYS;*/
-               return FALSE;
-       }
-
-       vtxbuf = so_new(20, 18);
+       vtxbuf = so_new(3, 17, 18);
        so_method(vtxbuf, rankine, NV34TCL_VTXBUF_ADDRESS(0), nv30->vtxelt_nr);
-       vtxfmt = so_new(17, 0);
+       vtxfmt = so_new(1, 16, 0);
        so_method(vtxfmt, rankine, NV34TCL_VTXFMT(0), nv30->vtxelt_nr);
 
        for (hw = 0; hw < nv30->vtxelt_nr; hw++) {
@@ -505,7 +506,7 @@ nv30_vbo_validate(struct nv30_context *nv30)
 
                if (!vb->stride) {
                        if (!sattr)
-                               sattr = so_new(16 * 5, 0);
+                               sattr = so_new(16, 16 * 4, 0);
 
                        if (nv30_vbo_static_attrib(nv30, sattr, hw, ve, vb)) {
                                so_data(vtxbuf, 0);
index 14a5c0260d073a6c139a0ac537bbcdcc2f4beeb7..e77a5be3f23152a6cc1ee4bbf8c17c9e8b7f9350 100644 (file)
@@ -253,32 +253,32 @@ static INLINE struct nv30_sreg
 tgsi_src(struct nv30_vpc *vpc, const struct tgsi_full_src_register *fsrc) {
        struct nv30_sreg src;
 
-       switch (fsrc->SrcRegister.File) {
+       switch (fsrc->Register.File) {
        case TGSI_FILE_INPUT:
-               src = nv30_sr(NV30SR_INPUT, fsrc->SrcRegister.Index);
+               src = nv30_sr(NV30SR_INPUT, fsrc->Register.Index);
                break;
        case TGSI_FILE_CONSTANT:
-               src = constant(vpc, fsrc->SrcRegister.Index, 0, 0, 0, 0);
+               src = constant(vpc, fsrc->Register.Index, 0, 0, 0, 0);
                break;
        case TGSI_FILE_IMMEDIATE:
-               src = vpc->imm[fsrc->SrcRegister.Index];
+               src = vpc->imm[fsrc->Register.Index];
                break;
        case TGSI_FILE_TEMPORARY:
-               if (vpc->high_temp < fsrc->SrcRegister.Index)
-                       vpc->high_temp = fsrc->SrcRegister.Index;
-               src = nv30_sr(NV30SR_TEMP, fsrc->SrcRegister.Index);
+               if (vpc->high_temp < fsrc->Register.Index)
+                       vpc->high_temp = fsrc->Register.Index;
+               src = nv30_sr(NV30SR_TEMP, fsrc->Register.Index);
                break;
        default:
                NOUVEAU_ERR("bad src file\n");
                break;
        }
 
-       src.abs = fsrc->SrcRegisterExtMod.Absolute;
-       src.negate = fsrc->SrcRegister.Negate;
-       src.swz[0] = fsrc->SrcRegister.SwizzleX;
-       src.swz[1] = fsrc->SrcRegister.SwizzleY;
-       src.swz[2] = fsrc->SrcRegister.SwizzleZ;
-       src.swz[3] = fsrc->SrcRegister.SwizzleW;
+       src.abs = fsrc->Register.Absolute;
+       src.negate = fsrc->Register.Negate;
+       src.swz[0] = fsrc->Register.SwizzleX;
+       src.swz[1] = fsrc->Register.SwizzleY;
+       src.swz[2] = fsrc->Register.SwizzleZ;
+       src.swz[3] = fsrc->Register.SwizzleW;
        return src;
 }
 
@@ -286,14 +286,14 @@ static INLINE struct nv30_sreg
 tgsi_dst(struct nv30_vpc *vpc, const struct tgsi_full_dst_register *fdst) {
        struct nv30_sreg dst;
 
-       switch (fdst->DstRegister.File) {
+       switch (fdst->Register.File) {
        case TGSI_FILE_OUTPUT:
                dst = nv30_sr(NV30SR_OUTPUT,
-                             vpc->output_map[fdst->DstRegister.Index]);
+                             vpc->output_map[fdst->Register.Index]);
 
                break;
        case TGSI_FILE_TEMPORARY:
-               dst = nv30_sr(NV30SR_TEMP, fdst->DstRegister.Index);
+               dst = nv30_sr(NV30SR_TEMP, fdst->Register.Index);
                if (vpc->high_temp < dst.index)
                        vpc->high_temp = dst.index;
                break;
@@ -334,8 +334,8 @@ nv30_vertprog_parse_instruction(struct nv30_vpc *vpc,
        for (i = 0; i < finst->Instruction.NumSrcRegs; i++) {
                const struct tgsi_full_src_register *fsrc;
 
-               fsrc = &finst->FullSrcRegisters[i];
-               if (fsrc->SrcRegister.File == TGSI_FILE_TEMPORARY) {
+               fsrc = &finst->Src[i];
+               if (fsrc->Register.File == TGSI_FILE_TEMPORARY) {
                        src[i] = tgsi_src(vpc, fsrc);
                }
        }
@@ -343,11 +343,11 @@ nv30_vertprog_parse_instruction(struct nv30_vpc *vpc,
        for (i = 0; i < finst->Instruction.NumSrcRegs; i++) {
                const struct tgsi_full_src_register *fsrc;
 
-               fsrc = &finst->FullSrcRegisters[i];
-               switch (fsrc->SrcRegister.File) {
+               fsrc = &finst->Src[i];
+               switch (fsrc->Register.File) {
                case TGSI_FILE_INPUT:
-                       if (ai == -1 || ai == fsrc->SrcRegister.Index) {
-                               ai = fsrc->SrcRegister.Index;
+                       if (ai == -1 || ai == fsrc->Register.Index) {
+                               ai = fsrc->Register.Index;
                                src[i] = tgsi_src(vpc, fsrc);
                        } else {
                                src[i] = temp(vpc);
@@ -360,8 +360,8 @@ nv30_vertprog_parse_instruction(struct nv30_vpc *vpc,
                 */
                case TGSI_FILE_CONSTANT:
                case TGSI_FILE_IMMEDIATE:
-                       if (ci == -1 || ci == fsrc->SrcRegister.Index) {
-                               ci = fsrc->SrcRegister.Index;
+                       if (ci == -1 || ci == fsrc->Register.Index) {
+                               ci = fsrc->Register.Index;
                                src[i] = tgsi_src(vpc, fsrc);
                        } else {
                                src[i] = temp(vpc);
@@ -378,8 +378,8 @@ nv30_vertprog_parse_instruction(struct nv30_vpc *vpc,
                }
        }
 
-       dst  = tgsi_dst(vpc, &finst->FullDstRegisters[0]);
-       mask = tgsi_mask(finst->FullDstRegisters[0].DstRegister.WriteMask);
+       dst  = tgsi_dst(vpc, &finst->Dst[0]);
+       mask = tgsi_mask(finst->Dst[0].Register.WriteMask);
 
        switch (finst->Instruction.Opcode) {
        case TGSI_OPCODE_ABS:
@@ -490,15 +490,15 @@ nv30_vertprog_parse_decl_output(struct nv30_vpc *vpc,
 {
        int hw;
 
-       switch (fdec->Semantic.SemanticName) {
+       switch (fdec->Semantic.Name) {
        case TGSI_SEMANTIC_POSITION:
                hw = NV30_VP_INST_DEST_POS;
                break;
        case TGSI_SEMANTIC_COLOR:
-               if (fdec->Semantic.SemanticIndex == 0) {
+               if (fdec->Semantic.Index == 0) {
                        hw = NV30_VP_INST_DEST_COL0;
                } else
-               if (fdec->Semantic.SemanticIndex == 1) {
+               if (fdec->Semantic.Index == 1) {
                        hw = NV30_VP_INST_DEST_COL1;
                } else {
                        NOUVEAU_ERR("bad colour semantic index\n");
@@ -506,10 +506,10 @@ nv30_vertprog_parse_decl_output(struct nv30_vpc *vpc,
                }
                break;
        case TGSI_SEMANTIC_BCOLOR:
-               if (fdec->Semantic.SemanticIndex == 0) {
+               if (fdec->Semantic.Index == 0) {
                        hw = NV30_VP_INST_DEST_BFC0;
                } else
-               if (fdec->Semantic.SemanticIndex == 1) {
+               if (fdec->Semantic.Index == 1) {
                        hw = NV30_VP_INST_DEST_BFC1;
                } else {
                        NOUVEAU_ERR("bad bcolour semantic index\n");
@@ -523,19 +523,22 @@ nv30_vertprog_parse_decl_output(struct nv30_vpc *vpc,
                hw = NV30_VP_INST_DEST_PSZ;
                break;
        case TGSI_SEMANTIC_GENERIC:
-               if (fdec->Semantic.SemanticIndex <= 7) {
-                       hw = NV30_VP_INST_DEST_TC(fdec->Semantic.SemanticIndex);
+               if (fdec->Semantic.Index <= 7) {
+                       hw = NV30_VP_INST_DEST_TC(fdec->Semantic.Index);
                } else {
                        NOUVEAU_ERR("bad generic semantic index\n");
                        return FALSE;
                }
                break;
+       case TGSI_SEMANTIC_EDGEFLAG:
+               NOUVEAU_ERR("cannot handle edgeflag output\n");
+               return FALSE;
        default:
                NOUVEAU_ERR("bad output semantic\n");
                return FALSE;
        }
 
-       vpc->output_map[fdec->DeclarationRange.First] = hw;
+       vpc->output_map[fdec->Range.First] = hw;
        return TRUE;
 }
 
@@ -647,7 +650,9 @@ static boolean
 nv30_vertprog_validate(struct nv30_context *nv30)
 { 
        struct pipe_screen *pscreen = nv30->pipe.screen;
-       struct nouveau_grobj *rankine = nv30->screen->rankine;
+       struct nv30_screen *screen = nv30->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *rankine = screen->rankine;
        struct nv30_vertex_program *vp;
        struct pipe_buffer *constbuf;
        boolean upload_code = FALSE, upload_data = FALSE;
@@ -681,7 +686,7 @@ nv30_vertprog_validate(struct nv30_context *nv30)
                                assert(0);
                }
 
-               so = so_new(2, 0);
+               so = so_new(1, 1, 0);
                so_method(so, rankine, NV34TCL_VP_START_FROM_ID, 1);
                so_data  (so, vp->exec->start);
                so_ref(so, &vp->so);
@@ -767,9 +772,9 @@ nv30_vertprog_validate(struct nv30_context *nv30)
                                       4 * sizeof(float));
                        }
 
-                       BEGIN_RING(rankine, NV34TCL_VP_UPLOAD_CONST_ID, 5);
-                       OUT_RING  (i + vp->data->start);
-                       OUT_RINGp ((uint32_t *)vpd->value, 4);
+                       BEGIN_RING(chan, rankine, NV34TCL_VP_UPLOAD_CONST_ID, 5);
+                       OUT_RING  (chan, i + vp->data->start);
+                       OUT_RINGp (chan, (uint32_t *)vpd->value, 4);
                }
 
                if (constbuf)
@@ -785,11 +790,11 @@ nv30_vertprog_validate(struct nv30_context *nv30)
                                vp->insns[i].data[2], vp->insns[i].data[3]);
                }
 #endif
-               BEGIN_RING(rankine, NV34TCL_VP_UPLOAD_FROM_ID, 1);
-               OUT_RING  (vp->exec->start);
+               BEGIN_RING(chan, rankine, NV34TCL_VP_UPLOAD_FROM_ID, 1);
+               OUT_RING  (chan, vp->exec->start);
                for (i = 0; i < vp->nr_insns; i++) {
-                       BEGIN_RING(rankine, NV34TCL_VP_UPLOAD_INST(0), 4);
-                       OUT_RINGp (vp->insns[i].data, 4);
+                       BEGIN_RING(chan, rankine, NV34TCL_VP_UPLOAD_INST(0), 4);
+                       OUT_RINGp (chan, vp->insns[i].data, 4);
                }
        }
 
index 8eba6a43ef95338432b628380f57f15676c501cf..f79ae4db84edbe117e67204e7bead2fff8002a68 100644 (file)
@@ -10,50 +10,38 @@ nv40_flush(struct pipe_context *pipe, unsigned flags,
           struct pipe_fence_handle **fence)
 {
        struct nv40_context *nv40 = nv40_context(pipe);
-       
+       struct nv40_screen *screen = nv40->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *curie = screen->curie;
+
        if (flags & PIPE_FLUSH_TEXTURE_CACHE) {
-               BEGIN_RING(curie, 0x1fd8, 1);
-               OUT_RING  (2);
-               BEGIN_RING(curie, 0x1fd8, 1);
-               OUT_RING  (1);
+               BEGIN_RING(chan, curie, 0x1fd8, 1);
+               OUT_RING  (chan, 2);
+               BEGIN_RING(chan, curie, 0x1fd8, 1);
+               OUT_RING  (chan, 1);
        }
 
-       FIRE_RING(fence);
+       FIRE_RING(chan);
+       if (fence)
+               *fence = NULL;
 }
 
 static void
 nv40_destroy(struct pipe_context *pipe)
 {
        struct nv40_context *nv40 = nv40_context(pipe);
+       unsigned i;
+
+       for (i = 0; i < NV40_STATE_MAX; i++) {
+               if (nv40->state.hw[i])
+                       so_ref(NULL, &nv40->state.hw[i]);
+       }
 
        if (nv40->draw)
                draw_destroy(nv40->draw);
        FREE(nv40);
 }
 
-static unsigned int
-nv40_is_texture_referenced( struct pipe_context *pipe,
-                           struct pipe_texture *texture,
-                           unsigned face, unsigned level)
-{
-   /**
-    * FIXME: Optimize.
-    */
-
-   return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
-
-static unsigned int
-nv40_is_buffer_referenced( struct pipe_context *pipe,
-                          struct pipe_buffer *buf)
-{
-   /**
-    * FIXME: Optimize.
-    */
-
-   return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
-
 struct pipe_context *
 nv40_create(struct pipe_screen *pscreen, unsigned pctx_id)
 {
@@ -78,8 +66,11 @@ nv40_create(struct pipe_screen *pscreen, unsigned pctx_id)
        nv40->pipe.clear = nv40_clear;
        nv40->pipe.flush = nv40_flush;
 
-       nv40->pipe.is_texture_referenced = nv40_is_texture_referenced;
-       nv40->pipe.is_buffer_referenced = nv40_is_buffer_referenced;
+       nv40->pipe.is_texture_referenced = nouveau_is_texture_referenced;
+       nv40->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
+
+       screen->base.channel->user_private = nv40;
+       screen->base.channel->flush_notify = nv40_state_flush_notify;
 
        nv40_init_query_functions(nv40);
        nv40_init_surface_functions(nv40);
@@ -95,4 +86,3 @@ nv40_create(struct pipe_screen *pscreen, unsigned pctx_id)
 
        return &nv40->pipe;
 }
-       
index 97bc83292d4dd0edf3217bbf4af7a8e38701d3b6..e219bb537ac324d7cc1116ada476b96a1703bb65 100644 (file)
 
 #include "nouveau/nouveau_winsys.h"
 #include "nouveau/nouveau_gldefs.h"
-
-#define NOUVEAU_PUSH_CONTEXT(ctx)                                              \
-       struct nv40_screen *ctx = nv40->screen
-#include "nouveau/nouveau_push.h"
+#include "nouveau/nouveau_context.h"
 #include "nouveau/nouveau_stateobj.h"
 
 #include "nv40_state.h"
@@ -158,7 +155,6 @@ struct nv40_context {
        unsigned vtxbuf_nr;
        struct pipe_vertex_element vtxelt[PIPE_MAX_ATTRIBS];
        unsigned vtxelt_nr;
-       const unsigned *edgeflags;
 };
 
 static INLINE struct nv40_context *
@@ -183,7 +179,7 @@ extern void nv40_screen_init_miptree_functions(struct pipe_screen *pscreen);
 
 /* nv40_draw.c */
 extern struct draw_stage *nv40_draw_render_stage(struct nv40_context *nv40);
-extern boolean nv40_draw_elements_swtnl(struct pipe_context *pipe,
+extern void nv40_draw_elements_swtnl(struct pipe_context *pipe,
                                        struct pipe_buffer *idxbuf,
                                        unsigned ib_size, unsigned mode,
                                        unsigned start, unsigned count);
@@ -203,6 +199,7 @@ extern void nv40_fragtex_bind(struct nv40_context *);
 extern boolean nv40_state_validate(struct nv40_context *nv40);
 extern boolean nv40_state_validate_swtnl(struct nv40_context *nv40);
 extern void nv40_state_emit(struct nv40_context *nv40);
+extern void nv40_state_flush_notify(struct nouveau_channel *chan);
 extern struct nv40_state_entry nv40_state_rasterizer;
 extern struct nv40_state_entry nv40_state_scissor;
 extern struct nv40_state_entry nv40_state_stipple;
@@ -218,9 +215,9 @@ extern struct nv40_state_entry nv40_state_vbo;
 extern struct nv40_state_entry nv40_state_vtxfmt;
 
 /* nv40_vbo.c */
-extern boolean nv40_draw_arrays(struct pipe_context *, unsigned mode,
+extern void nv40_draw_arrays(struct pipe_context *, unsigned mode,
                                unsigned start, unsigned count);
-extern boolean nv40_draw_elements(struct pipe_context *pipe,
+extern void nv40_draw_elements(struct pipe_context *pipe,
                                  struct pipe_buffer *indexBuffer,
                                  unsigned indexSize,
                                  unsigned mode, unsigned start,
index b2f19ecb699826bccd729640a6834b7dca64cf6e..d826f8c2f5fee0380b33e5f37d3cc91da8c3d4c8 100644 (file)
@@ -31,6 +31,9 @@ nv40_render_stage(struct draw_stage *stage)
 static INLINE void
 nv40_render_vertex(struct nv40_context *nv40, const struct vertex_header *v)
 {
+       struct nv40_screen *screen = nv40->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *curie = screen->curie;
        unsigned i;
 
        for (i = 0; i < nv40->swtnl.nr_attribs; i++) {
@@ -41,30 +44,30 @@ nv40_render_vertex(struct nv40_context *nv40, const struct vertex_header *v)
                case EMIT_OMIT:
                        break;
                case EMIT_1F:
-                       BEGIN_RING(curie, NV40TCL_VTX_ATTR_1F(hw), 1);
-                       OUT_RING  (fui(v->data[idx][0]));
+                       BEGIN_RING(chan, curie, NV40TCL_VTX_ATTR_1F(hw), 1);
+                       OUT_RING  (chan, fui(v->data[idx][0]));
                        break;
                case EMIT_2F:
-                       BEGIN_RING(curie, NV40TCL_VTX_ATTR_2F_X(hw), 2);
-                       OUT_RING  (fui(v->data[idx][0]));
-                       OUT_RING  (fui(v->data[idx][1]));
+                       BEGIN_RING(chan, curie, NV40TCL_VTX_ATTR_2F_X(hw), 2);
+                       OUT_RING  (chan, fui(v->data[idx][0]));
+                       OUT_RING  (chan, fui(v->data[idx][1]));
                        break;
                case EMIT_3F:
-                       BEGIN_RING(curie, NV40TCL_VTX_ATTR_3F_X(hw), 3);
-                       OUT_RING  (fui(v->data[idx][0]));
-                       OUT_RING  (fui(v->data[idx][1]));
-                       OUT_RING  (fui(v->data[idx][2]));
+                       BEGIN_RING(chan, curie, NV40TCL_VTX_ATTR_3F_X(hw), 3);
+                       OUT_RING  (chan, fui(v->data[idx][0]));
+                       OUT_RING  (chan, fui(v->data[idx][1]));
+                       OUT_RING  (chan, fui(v->data[idx][2]));
                        break;
                case EMIT_4F:
-                       BEGIN_RING(curie, NV40TCL_VTX_ATTR_4F_X(hw), 4);
-                       OUT_RING  (fui(v->data[idx][0]));
-                       OUT_RING  (fui(v->data[idx][1]));
-                       OUT_RING  (fui(v->data[idx][2]));
-                       OUT_RING  (fui(v->data[idx][3]));
+                       BEGIN_RING(chan, curie, NV40TCL_VTX_ATTR_4F_X(hw), 4);
+                       OUT_RING  (chan, fui(v->data[idx][0]));
+                       OUT_RING  (chan, fui(v->data[idx][1]));
+                       OUT_RING  (chan, fui(v->data[idx][2]));
+                       OUT_RING  (chan, fui(v->data[idx][3]));
                        break;
                case EMIT_4UB:
-                       BEGIN_RING(curie, NV40TCL_VTX_ATTR_4UB(hw), 1);
-                       OUT_RING  (pack_ub4(float_to_ubyte(v->data[idx][0]),
+                       BEGIN_RING(chan, curie, NV40TCL_VTX_ATTR_4UB(hw), 1);
+                       OUT_RING  (chan, pack_ub4(float_to_ubyte(v->data[idx][0]),
                                            float_to_ubyte(v->data[idx][1]),
                                            float_to_ubyte(v->data[idx][2]),
                                            float_to_ubyte(v->data[idx][3])));
@@ -82,7 +85,11 @@ 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->screen->base.channel->pushbuf;
+
+       struct nv40_screen *screen = nv40->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_pushbuf *pb = chan->pushbuf;
+       struct nouveau_grobj *curie = screen->curie;
        unsigned i;
 
        /* Ensure there's room for 4xfloat32 + potentially 3 begin/end */
@@ -91,19 +98,19 @@ nv40_render_prim(struct draw_stage *stage, struct prim_header *prim,
                        NOUVEAU_ERR("AIII, missed flush\n");
                        assert(0);
                }
-               FIRE_RING(NULL);
+               FIRE_RING(chan);
                nv40_state_emit(nv40);
        }
 
        /* Switch primitive modes if necessary */
        if (rs->prim != mode) {
                if (rs->prim != NV40TCL_BEGIN_END_STOP) {
-                       BEGIN_RING(curie, NV40TCL_BEGIN_END, 1);
-                       OUT_RING  (NV40TCL_BEGIN_END_STOP);     
+                       BEGIN_RING(chan, curie, NV40TCL_BEGIN_END, 1);
+                       OUT_RING  (chan, NV40TCL_BEGIN_END_STOP);
                }
 
-               BEGIN_RING(curie, NV40TCL_BEGIN_END, 1);
-               OUT_RING  (mode);
+               BEGIN_RING(chan, curie, NV40TCL_BEGIN_END, 1);
+               OUT_RING  (chan, mode);
                rs->prim = mode;
        }
 
@@ -115,8 +122,8 @@ nv40_render_prim(struct draw_stage *stage, struct prim_header *prim,
         * off the primitive now.
         */
        if (pb->remaining < ((count * 20) + 6)) {
-               BEGIN_RING(curie, NV40TCL_BEGIN_END, 1);
-               OUT_RING  (NV40TCL_BEGIN_END_STOP);
+               BEGIN_RING(chan, curie, NV40TCL_BEGIN_END, 1);
+               OUT_RING  (chan, NV40TCL_BEGIN_END_STOP);
                rs->prim = NV40TCL_BEGIN_END_STOP;
        }
 }
@@ -144,10 +151,13 @@ nv40_render_flush(struct draw_stage *draw, unsigned flags)
 {
        struct nv40_render_stage *rs = nv40_render_stage(draw);
        struct nv40_context *nv40 = rs->nv40;
+       struct nv40_screen *screen = nv40->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *curie = screen->curie;
 
        if (rs->prim != NV40TCL_BEGIN_END_STOP) {
-               BEGIN_RING(curie, NV40TCL_BEGIN_END, 1);
-               OUT_RING  (NV40TCL_BEGIN_END_STOP);
+               BEGIN_RING(chan, curie, NV40TCL_BEGIN_END, 1);
+               OUT_RING  (chan, NV40TCL_BEGIN_END_STOP);
                rs->prim = NV40TCL_BEGIN_END_STOP;
        }
 }
@@ -226,7 +236,7 @@ nv40_draw_render_stage(struct nv40_context *nv40)
        return &render->stage;
 }
 
-boolean
+void
 nv40_draw_elements_swtnl(struct pipe_context *pipe,
                         struct pipe_buffer *idxbuf, unsigned idxbuf_size,
                         unsigned mode, unsigned start, unsigned count)
@@ -237,7 +247,7 @@ nv40_draw_elements_swtnl(struct pipe_context *pipe,
        void *map;
 
        if (!nv40_state_validate_swtnl(nv40))
-               return FALSE;
+               return;
        nv40->state.dirty &= ~(1ULL << NV40_STATE_VTXBUF);
        nv40_state_emit(nv40);
 
@@ -261,7 +271,8 @@ nv40_draw_elements_swtnl(struct pipe_context *pipe,
                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_set_mapped_constant_buffer(nv40->draw, PIPE_SHADER_VERTEX,
+                                                map, nr);
        }
 
        draw_arrays(nv40->draw, mode, start, count);
@@ -277,15 +288,13 @@ nv40_draw_elements_swtnl(struct pipe_context *pipe,
 
        draw_flush(nv40->draw);
        pipe->flush(pipe, 0, NULL);
-
-       return TRUE;
 }
 
 static INLINE void
 emit_attrib(struct nv40_context *nv40, unsigned hw, unsigned emit,
            unsigned semantic, unsigned index)
 {
-       unsigned draw_out = draw_find_vs_output(nv40->draw, semantic, index);
+       unsigned draw_out = draw_find_shader_output(nv40->draw, semantic, index);
        unsigned a = nv40->swtnl.nr_attribs++;
 
        nv40->swtnl.hw[a] = hw;
index 32d9ed1a7f810657e3d23f3b53b7d72c2250ac7e..1237066c3981df27e338487ffff7ddb63102d0c6 100644 (file)
@@ -149,7 +149,7 @@ emit_src(struct nv40_fpc *fpc, int pos, struct nv40_sreg src)
                                sizeof(uint32_t) * 4);
                }
 
-               sr |= (NV40_FP_REG_TYPE_CONST << NV40_FP_REG_TYPE_SHIFT);       
+               sr |= (NV40_FP_REG_TYPE_CONST << NV40_FP_REG_TYPE_SHIFT);
                break;
        case NV40SR_NONE:
                sr |= (NV40_FP_REG_TYPE_INPUT << NV40_FP_REG_TYPE_SHIFT);
@@ -255,50 +255,50 @@ tgsi_src(struct nv40_fpc *fpc, const struct tgsi_full_src_register *fsrc)
 {
        struct nv40_sreg src;
 
-       switch (fsrc->SrcRegister.File) {
+       switch (fsrc->Register.File) {
        case TGSI_FILE_INPUT:
                src = nv40_sr(NV40SR_INPUT,
-                             fpc->attrib_map[fsrc->SrcRegister.Index]);
+                             fpc->attrib_map[fsrc->Register.Index]);
                break;
        case TGSI_FILE_CONSTANT:
-               src = constant(fpc, fsrc->SrcRegister.Index, NULL);
+               src = constant(fpc, fsrc->Register.Index, NULL);
                break;
        case TGSI_FILE_IMMEDIATE:
-               assert(fsrc->SrcRegister.Index < fpc->nr_imm);
-               src = fpc->imm[fsrc->SrcRegister.Index];
+               assert(fsrc->Register.Index < fpc->nr_imm);
+               src = fpc->imm[fsrc->Register.Index];
                break;
        case TGSI_FILE_TEMPORARY:
-               src = fpc->r_temp[fsrc->SrcRegister.Index];
+               src = fpc->r_temp[fsrc->Register.Index];
                break;
        /* NV40 fragprog result regs are just temps, so this is simple */
        case TGSI_FILE_OUTPUT:
-               src = fpc->r_result[fsrc->SrcRegister.Index];
+               src = fpc->r_result[fsrc->Register.Index];
                break;
        default:
                NOUVEAU_ERR("bad src file\n");
                break;
        }
 
-       src.abs = fsrc->SrcRegisterExtMod.Absolute;
-       src.negate = fsrc->SrcRegister.Negate;
-       src.swz[0] = fsrc->SrcRegister.SwizzleX;
-       src.swz[1] = fsrc->SrcRegister.SwizzleY;
-       src.swz[2] = fsrc->SrcRegister.SwizzleZ;
-       src.swz[3] = fsrc->SrcRegister.SwizzleW;
+       src.abs = fsrc->Register.Absolute;
+       src.negate = fsrc->Register.Negate;
+       src.swz[0] = fsrc->Register.SwizzleX;
+       src.swz[1] = fsrc->Register.SwizzleY;
+       src.swz[2] = fsrc->Register.SwizzleZ;
+       src.swz[3] = fsrc->Register.SwizzleW;
        return src;
 }
 
 static INLINE struct nv40_sreg
 tgsi_dst(struct nv40_fpc *fpc, const struct tgsi_full_dst_register *fdst) {
-       switch (fdst->DstRegister.File) {
+       switch (fdst->Register.File) {
        case TGSI_FILE_OUTPUT:
-               return fpc->r_result[fdst->DstRegister.Index];
+               return fpc->r_result[fdst->Register.Index];
        case TGSI_FILE_TEMPORARY:
-               return fpc->r_temp[fdst->DstRegister.Index];
+               return fpc->r_temp[fdst->Register.Index];
        case TGSI_FILE_NULL:
                return nv40_sr(NV40SR_NONE, 0);
        default:
-               NOUVEAU_ERR("bad dst file %d\n", fdst->DstRegister.File);
+               NOUVEAU_ERR("bad dst file %d\n", fdst->Register.File);
                return nv40_sr(NV40SR_NONE, 0);
        }
 }
@@ -321,38 +321,23 @@ src_native_swz(struct nv40_fpc *fpc, const struct tgsi_full_src_register *fsrc,
 {
        const struct nv40_sreg none = nv40_sr(NV40SR_NONE, 0);
        struct nv40_sreg tgsi = tgsi_src(fpc, fsrc);
-       uint mask = 0, zero_mask = 0, one_mask = 0, neg_mask = 0;
-       uint neg[4] = { fsrc->SrcRegisterExtSwz.NegateX,
-                       fsrc->SrcRegisterExtSwz.NegateY,
-                       fsrc->SrcRegisterExtSwz.NegateZ,
-                       fsrc->SrcRegisterExtSwz.NegateW };
+       uint mask = 0;
        uint c;
 
        for (c = 0; c < 4; c++) {
-               switch (tgsi_util_get_full_src_register_extswizzle(fsrc, c)) {
-               case TGSI_EXTSWIZZLE_X:
-               case TGSI_EXTSWIZZLE_Y:
-               case TGSI_EXTSWIZZLE_Z:
-               case TGSI_EXTSWIZZLE_W:
+               switch (tgsi_util_get_full_src_register_swizzle(fsrc, c)) {
+               case TGSI_SWIZZLE_X:
+               case TGSI_SWIZZLE_Y:
+               case TGSI_SWIZZLE_Z:
+               case TGSI_SWIZZLE_W:
                        mask |= (1 << c);
                        break;
-               case TGSI_EXTSWIZZLE_ZERO:
-                       zero_mask |= (1 << c);
-                       tgsi.swz[c] = SWZ_X;
-                       break;
-               case TGSI_EXTSWIZZLE_ONE:
-                       one_mask |= (1 << c);
-                       tgsi.swz[c] = SWZ_X;
-                       break;
                default:
                        assert(0);
                }
-
-               if (!tgsi.negate && neg[c])
-                       neg_mask |= (1 << c);
        }
 
-       if (mask == MASK_ALL && !neg_mask)
+       if (mask == MASK_ALL)
                return TRUE;
 
        *src = temp(fpc);
@@ -360,18 +345,6 @@ src_native_swz(struct nv40_fpc *fpc, const struct tgsi_full_src_register *fsrc,
        if (mask)
                arith(fpc, 0, MOV, *src, mask, tgsi, none, none);
 
-       if (zero_mask)
-               arith(fpc, 0, SFL, *src, zero_mask, *src, none, none);
-
-       if (one_mask)
-               arith(fpc, 0, STR, *src, one_mask, *src, none, none);
-
-       if (neg_mask) {
-               struct nv40_sreg one = temp(fpc);
-               arith(fpc, 0, STR, one, neg_mask, one, none, none);
-               arith(fpc, 0, MUL, *src, neg_mask, *src, neg(one), none);
-       }
-
        return FALSE;
 }
 
@@ -391,8 +364,8 @@ nv40_fragprog_parse_instruction(struct nv40_fpc *fpc,
        for (i = 0; i < finst->Instruction.NumSrcRegs; i++) {
                const struct tgsi_full_src_register *fsrc;
 
-               fsrc = &finst->FullSrcRegisters[i];
-               if (fsrc->SrcRegister.File == TGSI_FILE_TEMPORARY) {
+               fsrc = &finst->Src[i];
+               if (fsrc->Register.File == TGSI_FILE_TEMPORARY) {
                        src[i] = tgsi_src(fpc, fsrc);
                }
        }
@@ -400,9 +373,9 @@ nv40_fragprog_parse_instruction(struct nv40_fpc *fpc,
        for (i = 0; i < finst->Instruction.NumSrcRegs; i++) {
                const struct tgsi_full_src_register *fsrc;
 
-               fsrc = &finst->FullSrcRegisters[i];
+               fsrc = &finst->Src[i];
 
-               switch (fsrc->SrcRegister.File) {
+               switch (fsrc->Register.File) {
                case TGSI_FILE_INPUT:
                case TGSI_FILE_CONSTANT:
                case TGSI_FILE_TEMPORARY:
@@ -413,10 +386,10 @@ nv40_fragprog_parse_instruction(struct nv40_fpc *fpc,
                        break;
                }
 
-               switch (fsrc->SrcRegister.File) {
+               switch (fsrc->Register.File) {
                case TGSI_FILE_INPUT:
-                       if (ai == -1 || ai == fsrc->SrcRegister.Index) {
-                               ai = fsrc->SrcRegister.Index;
+                       if (ai == -1 || ai == fsrc->Register.Index) {
+                               ai = fsrc->Register.Index;
                                src[i] = tgsi_src(fpc, fsrc);
                        } else {
                                src[i] = temp(fpc);
@@ -426,8 +399,8 @@ nv40_fragprog_parse_instruction(struct nv40_fpc *fpc,
                        break;
                case TGSI_FILE_CONSTANT:
                        if ((ci == -1 && ii == -1) ||
-                           ci == fsrc->SrcRegister.Index) {
-                               ci = fsrc->SrcRegister.Index;
+                           ci == fsrc->Register.Index) {
+                               ci = fsrc->Register.Index;
                                src[i] = tgsi_src(fpc, fsrc);
                        } else {
                                src[i] = temp(fpc);
@@ -437,8 +410,8 @@ nv40_fragprog_parse_instruction(struct nv40_fpc *fpc,
                        break;
                case TGSI_FILE_IMMEDIATE:
                        if ((ci == -1 && ii == -1) ||
-                           ii == fsrc->SrcRegister.Index) {
-                               ii = fsrc->SrcRegister.Index;
+                           ii == fsrc->Register.Index) {
+                               ii = fsrc->Register.Index;
                                src[i] = tgsi_src(fpc, fsrc);
                        } else {
                                src[i] = temp(fpc);
@@ -450,7 +423,7 @@ nv40_fragprog_parse_instruction(struct nv40_fpc *fpc,
                        /* handled above */
                        break;
                case TGSI_FILE_SAMPLER:
-                       unit = fsrc->SrcRegister.Index;
+                       unit = fsrc->Register.Index;
                        break;
                case TGSI_FILE_OUTPUT:
                        break;
@@ -460,8 +433,8 @@ nv40_fragprog_parse_instruction(struct nv40_fpc *fpc,
                }
        }
 
-       dst  = tgsi_dst(fpc, &finst->FullDstRegisters[0]);
-       mask = tgsi_mask(finst->FullDstRegisters[0].DstRegister.WriteMask);
+       dst  = tgsi_dst(fpc, &finst->Dst[0]);
+       mask = tgsi_mask(finst->Dst[0].Register.WriteMask);
        sat  = (finst->Instruction.Saturate == TGSI_SAT_ZERO_ONE);
 
        switch (finst->Instruction.Opcode) {
@@ -472,10 +445,11 @@ nv40_fragprog_parse_instruction(struct nv40_fpc *fpc,
                arith(fpc, sat, ADD, dst, mask, src[0], src[1], none);
                break;
        case TGSI_OPCODE_CMP:
-               tmp = temp(fpc);
-               arith(fpc, sat, MOV, dst, mask, src[2], none, none);
+               tmp = nv40_sr(NV40SR_NONE, 0);
                tmp.cc_update = 1;
                arith(fpc, 0, MOV, tmp, 0xf, src[0], none, none);
+               dst.cc_test = NV40_VP_INST_COND_GE;
+               arith(fpc, sat, MOV, dst, mask, src[2], none, none);
                dst.cc_test = NV40_VP_INST_COND_LT;
                arith(fpc, sat, MOV, dst, mask, src[1], none, none);
                break;
@@ -568,12 +542,6 @@ nv40_fragprog_parse_instruction(struct nv40_fpc *fpc,
        case TGSI_OPCODE_MUL:
                arith(fpc, sat, MUL, dst, mask, src[0], src[1], none);
                break;
-       case TGSI_OPCODE_NOISE1:
-       case TGSI_OPCODE_NOISE2:
-       case TGSI_OPCODE_NOISE3:
-       case TGSI_OPCODE_NOISE4:
-               arith(fpc, sat, SFL, dst, mask, none, none, none);
-               break;
        case TGSI_OPCODE_POW:
                tmp = temp(fpc);
                arith(fpc, 0, LG2, tmp, MASK_X,
@@ -606,13 +574,28 @@ nv40_fragprog_parse_instruction(struct nv40_fpc *fpc,
                      neg(swz(tmp, X, X, X, X)), none, none);
                break;
        case TGSI_OPCODE_SCS:
-               if (mask & MASK_X) {
-                       arith(fpc, sat, COS, dst, MASK_X,
-                             swz(src[0], X, X, X, X), none, none);
+               /* avoid overwriting the source */
+               if(src[0].swz[SWZ_X] != SWZ_X)
+               {
+                       if (mask & MASK_X) {
+                               arith(fpc, sat, COS, dst, MASK_X,
+                                     swz(src[0], X, X, X, X), none, none);
+                       }
+                       if (mask & MASK_Y) {
+                               arith(fpc, sat, SIN, dst, MASK_Y,
+                                     swz(src[0], X, X, X, X), none, none);
+                       }
                }
-               if (mask & MASK_Y) {
-                       arith(fpc, sat, SIN, dst, MASK_Y,
-                             swz(src[0], X, X, X, X), none, none);
+               else
+               {
+                       if (mask & MASK_Y) {
+                               arith(fpc, sat, SIN, dst, MASK_Y,
+                                     swz(src[0], X, X, X, X), none, none);
+                       }
+                       if (mask & MASK_X) {
+                               arith(fpc, sat, COS, dst, MASK_X,
+                                     swz(src[0], X, X, X, X), none, none);
+                       }
                }
                break;
        case TGSI_OPCODE_SEQ:
@@ -677,15 +660,15 @@ nv40_fragprog_parse_decl_attrib(struct nv40_fpc *fpc,
 {
        int hw;
 
-       switch (fdec->Semantic.SemanticName) {
+       switch (fdec->Semantic.Name) {
        case TGSI_SEMANTIC_POSITION:
                hw = NV40_FP_OP_INPUT_SRC_POSITION;
                break;
        case TGSI_SEMANTIC_COLOR:
-               if (fdec->Semantic.SemanticIndex == 0) {
+               if (fdec->Semantic.Index == 0) {
                        hw = NV40_FP_OP_INPUT_SRC_COL0;
                } else
-               if (fdec->Semantic.SemanticIndex == 1) {
+               if (fdec->Semantic.Index == 1) {
                        hw = NV40_FP_OP_INPUT_SRC_COL1;
                } else {
                        NOUVEAU_ERR("bad colour semantic index\n");
@@ -696,9 +679,9 @@ nv40_fragprog_parse_decl_attrib(struct nv40_fpc *fpc,
                hw = NV40_FP_OP_INPUT_SRC_FOGC;
                break;
        case TGSI_SEMANTIC_GENERIC:
-               if (fdec->Semantic.SemanticIndex <= 7) {
+               if (fdec->Semantic.Index <= 7) {
                        hw = NV40_FP_OP_INPUT_SRC_TC(fdec->Semantic.
-                                                    SemanticIndex);
+                                                    Index);
                } else {
                        NOUVEAU_ERR("bad generic semantic index\n");
                        return FALSE;
@@ -709,7 +692,7 @@ nv40_fragprog_parse_decl_attrib(struct nv40_fpc *fpc,
                return FALSE;
        }
 
-       fpc->attrib_map[fdec->DeclarationRange.First] = hw;
+       fpc->attrib_map[fdec->Range.First] = hw;
        return TRUE;
 }
 
@@ -717,15 +700,15 @@ static boolean
 nv40_fragprog_parse_decl_output(struct nv40_fpc *fpc,
                                const struct tgsi_full_declaration *fdec)
 {
-       unsigned idx = fdec->DeclarationRange.First;
+       unsigned idx = fdec->Range.First;
        unsigned hw;
 
-       switch (fdec->Semantic.SemanticName) {
+       switch (fdec->Semantic.Name) {
        case TGSI_SEMANTIC_POSITION:
                hw = 1;
                break;
        case TGSI_SEMANTIC_COLOR:
-               switch (fdec->Semantic.SemanticIndex) {
+               switch (fdec->Semantic.Index) {
                case 0: hw = 0; break;
                case 1: hw = 2; break;
                case 2: hw = 3; break;
@@ -771,9 +754,9 @@ nv40_fragprog_prepare(struct nv40_fpc *fpc)
                                        goto out_err;
                                break;
                        case TGSI_FILE_TEMPORARY:
-                               if (fdec->DeclarationRange.Last > high_temp) {
+                               if (fdec->Range.Last > high_temp) {
                                        high_temp =
-                                               fdec->DeclarationRange.Last;
+                                               fdec->Range.Last;
                                }
                                break;
                        default:
@@ -785,7 +768,7 @@ nv40_fragprog_prepare(struct nv40_fpc *fpc)
                {
                        struct tgsi_full_immediate *imm;
                        float vals[4];
-                       
+
                        imm = &p.FullToken.FullImmediate;
                        assert(imm->Immediate.DataType == TGSI_IMM_FLOAT32);
                        assert(fpc->nr_imm < MAX_IMM);
@@ -869,7 +852,7 @@ nv40_fragprog_translate(struct nv40_context *nv40,
        fp->insn[fpc->inst_offset + 1] = 0x00000000;
        fp->insn[fpc->inst_offset + 2] = 0x00000000;
        fp->insn[fpc->inst_offset + 3] = 0x00000000;
-       
+
        fp->translated = TRUE;
 out_err:
        tgsi_parse_free(&parse);
@@ -936,7 +919,7 @@ nv40_fragprog_validate(struct nv40_context *nv40)
        fp->buffer = pscreen->buffer_create(pscreen, 0x100, 0, fp->insn_len * 4);
        nv40_fragprog_upload(nv40, fp);
 
-       so = so_new(4, 1);
+       so = so_new(2, 2, 1);
        so_method(so, nv40->screen->curie, NV40TCL_FP_ADDRESS, 1);
        so_reloc (so, nouveau_bo(fp->buffer), 0, NOUVEAU_BO_VRAM |
                      NOUVEAU_BO_GART | NOUVEAU_BO_RD | NOUVEAU_BO_LOW |
@@ -950,7 +933,7 @@ nv40_fragprog_validate(struct nv40_context *nv40)
 update_constants:
        if (fp->nr_consts) {
                float *map;
-               
+
                map = pipe_buffer_map(pscreen, constbuf,
                                      PIPE_BUFFER_USAGE_CPU_READ);
                for (i = 0; i < fp->nr_consts; i++) {
@@ -981,6 +964,12 @@ void
 nv40_fragprog_destroy(struct nv40_context *nv40,
                      struct nv40_fragment_program *fp)
 {
+       if (fp->buffer)
+               pipe_buffer_reference(&fp->buffer, NULL);
+
+       if (fp->so)
+               so_ref(NULL, &fp->so);
+
        if (fp->insn_len)
                FREE(fp->insn);
 }
index f6cdf31dfee282093fdccb91186821b4cba4bca8..aad9198210fd22626cbbabc6ea7a8e32e0056285 100644 (file)
@@ -23,6 +23,7 @@ struct nv40_texture_format {
 
 static struct nv40_texture_format
 nv40_texture_formats[] = {
+       _(X8R8G8B8_UNORM, A8R8G8B8,   S1,   S1,   S1,  ONE, X, Y, Z, W, 0, 0, 0, 0),
        _(A8R8G8B8_UNORM, A8R8G8B8,   S1,   S1,   S1,   S1, X, Y, Z, W, 0, 0, 0, 0),
        _(A1R5G5B5_UNORM, A1R5G5B5,   S1,   S1,   S1,   S1, X, Y, Z, W, 0, 0, 0, 0),
        _(A4R4G4B4_UNORM, A4R4G4B4,   S1,   S1,   S1,   S1, X, Y, Z, W, 0, 0, 0, 0),
@@ -107,7 +108,7 @@ nv40_fragtex_build(struct nv40_context *nv40, int unit)
 
        txs = tf->swizzle;
 
-       so = so_new(16, 2);
+       so = so_new(2, 9, 2);
        so_method(so, nv40->screen->curie, NV40TCL_TEX_OFFSET(unit), 8);
        so_reloc (so, bo, 0, tex_flags | NOUVEAU_BO_LOW, 0, 0);
        so_reloc (so, bo, txf, tex_flags | NOUVEAU_BO_OR,
@@ -116,11 +117,11 @@ nv40_fragtex_build(struct nv40_context *nv40, int unit)
        so_data  (so, NV40TCL_TEX_ENABLE_ENABLE | ps->en);
        so_data  (so, txs);
        so_data  (so, ps->filt | tf->sign | 0x2000 /*voodoo*/);
-       so_data  (so, (pt->width[0] << NV40TCL_TEX_SIZE0_W_SHIFT) |
-                      pt->height[0]);
+       so_data  (so, (pt->width0 << NV40TCL_TEX_SIZE0_W_SHIFT) |
+                      pt->height0);
        so_data  (so, ps->bcol);
        so_method(so, nv40->screen->curie, NV40TCL_TEX_SIZE1(unit), 1);
-       so_data  (so, (pt->depth[0] << NV40TCL_TEX_SIZE1_DEPTH_SHIFT) | txp);
+       so_data  (so, (pt->depth0 << NV40TCL_TEX_SIZE1_DEPTH_SHIFT) | txp);
 
        return so;
 }
@@ -138,7 +139,7 @@ nv40_fragtex_validate(struct nv40_context *nv40)
                unit = ffs(samplers) - 1;
                samplers &= ~(1 << unit);
 
-               so = so_new(2, 0);
+               so = so_new(1, 1, 0);
                so_method(so, nv40->screen->curie, NV40TCL_TEX_ENABLE(unit), 1);
                so_data  (so, 0);
                so_ref(so, &nv40->state.hw[NV40_STATE_FRAGTEX0 + unit]);
index 5a201ccf458041c1d0fc56d56ed0d19c0716f81b..89bd155ff493ace556940c692e5f211d6d9d3c2d 100644 (file)
@@ -1,14 +1,19 @@
 #include "pipe/p_state.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_inlines.h"
+#include "util/u_format.h"
+#include "util/u_math.h"
 
 #include "nv40_context.h"
+#include "../nv04/nv04_surface_2d.h"
+
+
 
 static void
 nv40_miptree_layout(struct nv40_miptree *mt)
 {
        struct pipe_texture *pt = &mt->base;
-       uint width = pt->width[0], height = pt->height[0], depth = pt->depth[0];
+       uint width = pt->width0;
        uint offset = 0;
        int nr_faces, l, f;
        uint wide_pitch = pt->tex_usage & (PIPE_TEXTURE_USAGE_SAMPLER |
@@ -21,29 +26,21 @@ nv40_miptree_layout(struct nv40_miptree *mt)
                nr_faces = 6;
        } else
        if (pt->target == PIPE_TEXTURE_3D) {
-               nr_faces = pt->depth[0];
+               nr_faces = pt->depth0;
        } else {
                nr_faces = 1;
        }
 
        for (l = 0; l <= pt->last_level; l++) {
-               pt->width[l] = width;
-               pt->height[l] = height;
-               pt->depth[l] = depth;
-               pt->nblocksx[l] = pf_get_nblocksx(&pt->block, width);
-               pt->nblocksy[l] = pf_get_nblocksy(&pt->block, height);
-
                if (wide_pitch && (pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR))
-                       mt->level[l].pitch = align(pt->width[0] * pt->block.size, 64);
+                       mt->level[l].pitch = align(util_format_get_stride(pt->format, pt->width0), 64);
                else
-                       mt->level[l].pitch = pt->width[l] * pt->block.size;
+                       mt->level[l].pitch = util_format_get_stride(pt->format, width);
 
                mt->level[l].image_offset =
                        CALLOC(nr_faces, sizeof(unsigned));
 
-               width  = MAX2(1, width  >> 1);
-               height = MAX2(1, height >> 1);
-               depth  = MAX2(1, depth  >> 1);
+               width  = u_minify(width, 1);
        }
 
        for (f = 0; f < nr_faces; f++) {
@@ -51,14 +48,14 @@ nv40_miptree_layout(struct nv40_miptree *mt)
                        mt->level[l].image_offset[f] = offset;
 
                        if (!(pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR) &&
-                           pt->width[l + 1] > 1 && pt->height[l + 1] > 1)
-                               offset += align(mt->level[l].pitch * pt->height[l], 64);
+                           u_minify(pt->width0, l + 1) > 1 && u_minify(pt->height0, l + 1) > 1)
+                               offset += align(mt->level[l].pitch * u_minify(pt->height0, l), 64);
                        else
-                               offset += mt->level[l].pitch * pt->height[l];
+                               offset += mt->level[l].pitch * u_minify(pt->height0, l);
                }
 
                mt->level[l].image_offset[f] = offset;
-               offset += mt->level[l].pitch * pt->height[l];
+               offset += mt->level[l].pitch * u_minify(pt->height0, l);
        }
 
        mt->total_size = offset;
@@ -79,8 +76,8 @@ nv40_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
        mt->base.screen = pscreen;
 
        /* Swizzled textures must be POT */
-       if (pt->width[0] & (pt->width[0] - 1) ||
-           pt->height[0] & (pt->height[0] - 1))
+       if (pt->width0 & (pt->width0 - 1) ||
+           pt->height0 & (pt->height0 - 1))
                mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
        else
        if (pt->tex_usage & (PIPE_TEXTURE_USAGE_PRIMARY |
@@ -109,6 +106,12 @@ nv40_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
        if (pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC)
                buf_usage |= PIPE_BUFFER_USAGE_CPU_READ_WRITE;
 
+       /* apparently we can't render to swizzled surfaces smaller than 64 bytes, so make them linear.
+        * If the user did not ask for a render target, they can still render to it, but it will cost them an extra copy.
+        * This also happens for small mipmaps of large textures. */
+       if (pt->tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET && util_format_get_stride(pt->format, pt->width0) < 64)
+               mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
+
        nv40_miptree_layout(mt);
 
        mt->buffer = pscreen->buffer_create(pscreen, 256, buf_usage, mt->total_size);
@@ -116,7 +119,7 @@ nv40_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
                FREE(mt);
                return NULL;
        }
-
+       mt->bo = nouveau_bo(mt->buffer);
        return &mt->base;
 }
 
@@ -128,7 +131,7 @@ nv40_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
 
        /* Only supports 2D, non-mipmapped textures for the moment */
        if (pt->target != PIPE_TEXTURE_2D || pt->last_level != 0 ||
-           pt->depth[0] != 1)
+           pt->depth0 != 1)
                return NULL;
 
        mt = CALLOC_STRUCT(nv40_miptree);
@@ -141,7 +144,11 @@ nv40_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
        mt->level[0].pitch = stride[0];
        mt->level[0].image_offset = CALLOC(1, sizeof(unsigned));
 
+       /* Assume whoever created this buffer expects it to be linear for now */
+       mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
+
        pipe_buffer_reference(&mt->buffer, pb);
+       mt->bo = nouveau_bo(mt->buffer);
        return &mt->base;
 }
 
@@ -173,8 +180,8 @@ nv40_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
                return NULL;
        pipe_texture_reference(&ns->base.texture, pt);
        ns->base.format = pt->format;
-       ns->base.width = pt->width[level];
-       ns->base.height = pt->height[level];
+       ns->base.width = u_minify(pt->width0, level);
+       ns->base.height = u_minify(pt->height0, level);
        ns->base.usage = flags;
        pipe_reference_init(&ns->base.reference, 1);
        ns->base.face = face;
@@ -191,12 +198,27 @@ nv40_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
                ns->base.offset = mt->level[level].image_offset[0];
        }
 
+       /* create a linear temporary that we can render into if necessary.
+        * Note that ns->pitch is always a multiple of 64 for linear surfaces and swizzled surfaces are POT, so
+        * ns->pitch & 63 is equivalent to (ns->pitch < 64 && swizzled)*/
+       if((ns->pitch & 63) && (ns->base.usage & (PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER)) == PIPE_BUFFER_USAGE_GPU_WRITE)
+               return &nv04_surface_wrap_for_render(pscreen, ((struct nv40_screen*)pscreen)->eng2d, ns)->base;
+
        return &ns->base;
 }
 
 static void
 nv40_miptree_surface_del(struct pipe_surface *ps)
 {
+       struct nv04_surface* ns = (struct nv04_surface*)ps;
+       if(ns->backing)
+       {
+               struct nv40_screen* screen = (struct nv40_screen*)ps->texture->screen;
+               if(ns->backing->base.usage & PIPE_BUFFER_USAGE_GPU_WRITE)
+                       screen->eng2d->copy(screen->eng2d, &ns->backing->base, 0, 0, ps, 0, 0, ns->base.width, ns->base.height);
+               nv40_miptree_surface_del(&ns->backing->base);
+       }
+
        pipe_texture_reference(&ps->texture, NULL);
        FREE(ps);
 }
index 7874aedd428ae61e79c47107a3f9b33b865d5a22..8ed4a67dd03b2f69885e92a9d2baf138493028b5 100644 (file)
@@ -41,6 +41,9 @@ nv40_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
 {
        struct nv40_context *nv40 = nv40_context(pipe);
        struct nv40_query *q = nv40_query(pq);
+       struct nv40_screen *screen = nv40->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *curie = screen->curie;
 
        assert(q->type == PIPE_QUERY_OCCLUSION_COUNTER);
 
@@ -57,10 +60,10 @@ nv40_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
                assert(0);
        nouveau_notifier_reset(nv40->screen->query, q->object->start);
 
-       BEGIN_RING(curie, NV40TCL_QUERY_RESET, 1);
-       OUT_RING  (1);
-       BEGIN_RING(curie, NV40TCL_QUERY_UNK17CC, 1);
-       OUT_RING  (1);
+       BEGIN_RING(chan, curie, NV40TCL_QUERY_RESET, 1);
+       OUT_RING  (chan, 1);
+       BEGIN_RING(chan, curie, NV40TCL_QUERY_UNK17CC, 1);
+       OUT_RING  (chan, 1);
 
        q->ready = FALSE;
 }
@@ -70,11 +73,14 @@ nv40_query_end(struct pipe_context *pipe, struct pipe_query *pq)
 {
        struct nv40_context *nv40 = nv40_context(pipe);
        struct nv40_query *q = nv40_query(pq);
+       struct nv40_screen *screen = nv40->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *curie = screen->curie;
 
-       BEGIN_RING(curie, NV40TCL_QUERY_GET, 1);
-       OUT_RING  ((0x01 << NV40TCL_QUERY_GET_UNK24_SHIFT) |
+       BEGIN_RING(chan, curie, NV40TCL_QUERY_GET, 1);
+       OUT_RING  (chan, (0x01 << NV40TCL_QUERY_GET_UNK24_SHIFT) |
                   ((q->object->start * 32) << NV40TCL_QUERY_GET_OFFSET_SHIFT));
-       FIRE_RING(NULL);
+       FIRE_RING(chan);
 }
 
 static boolean
index bd13dfddd1c459b86f90d13a389762b9cd96e6f3..9e55e5a089c6eb46790c44b9e7902bc593fa1188 100644 (file)
@@ -140,6 +140,12 @@ static void
 nv40_screen_destroy(struct pipe_screen *pscreen)
 {
        struct nv40_screen *screen = nv40_screen(pscreen);
+       unsigned i;
+
+       for (i = 0; i < NV40_STATE_MAX; i++) {
+               if (screen->state[i])
+                       so_ref(NULL, &screen->state[i]);
+       }
 
        nouveau_resource_free(&screen->vp_exec_heap);
        nouveau_resource_free(&screen->vp_data_heap);
@@ -147,6 +153,7 @@ nv40_screen_destroy(struct pipe_screen *pscreen)
        nouveau_notifier_free(&screen->query);
        nouveau_notifier_free(&screen->sync);
        nouveau_grobj_free(&screen->curie);
+       nv04_surface_2d_takedown(&screen->eng2d);
 
        nouveau_screen_fini(&screen->base);
 
@@ -208,7 +215,6 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
                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);
@@ -245,7 +251,7 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
        }
 
        /* Static curie initialisation */
-       so = so_new(128, 0);
+       so = so_new(16, 25, 0);
        so_method(so, screen->curie, NV40TCL_DMA_NOTIFY, 1);
        so_data  (so, screen->sync->handle);
        so_method(so, screen->curie, NV40TCL_DMA_TEXTURE0, 2);
index c3ee4d234537d1dc317649dff573316899c46f94..ed0ca9e02c31d8c0b183ebd59e9e126993d164a3 100644 (file)
@@ -16,7 +16,7 @@ nv40_blend_state_create(struct pipe_context *pipe,
        struct nv40_context *nv40 = nv40_context(pipe);
        struct nouveau_grobj *curie = nv40->screen->curie;
        struct nv40_blend_state *bso = CALLOC(1, sizeof(*bso));
-       struct nouveau_stateobj *so = so_new(16, 0);
+       struct nouveau_stateobj *so = so_new(5, 8, 0);
 
        if (cso->blend_enable) {
                so_method(so, curie, NV40TCL_BLEND_ENABLE, 3);
@@ -310,7 +310,7 @@ nv40_rasterizer_state_create(struct pipe_context *pipe,
 {
        struct nv40_context *nv40 = nv40_context(pipe);
        struct nv40_rasterizer_state *rsso = CALLOC(1, sizeof(*rsso));
-       struct nouveau_stateobj *so = so_new(32, 0);
+       struct nouveau_stateobj *so = so_new(8, 18, 0);
        struct nouveau_grobj *curie = nv40->screen->curie;
 
        /*XXX: ignored:
@@ -445,7 +445,7 @@ nv40_depth_stencil_alpha_state_create(struct pipe_context *pipe,
 {
        struct nv40_context *nv40 = nv40_context(pipe);
        struct nv40_zsa_state *zsaso = CALLOC(1, sizeof(*zsaso));
-       struct nouveau_stateobj *so = so_new(32, 0);
+       struct nouveau_stateobj *so = so_new(4, 21, 0);
        struct nouveau_grobj *curie = nv40->screen->curie;
 
        so_method(so, curie, NV40TCL_DEPTH_FUNC, 3);
@@ -687,16 +687,6 @@ nv40_set_vertex_elements(struct pipe_context *pipe, unsigned count,
        nv40->draw_dirty |= NV40_NEW_ARRAYS;
 }
 
-static void
-nv40_set_edgeflags(struct pipe_context *pipe, const unsigned *bitfield)
-{
-       struct nv40_context *nv40 = nv40_context(pipe);
-
-       nv40->edgeflags = bitfield;
-       nv40->dirty |= NV40_NEW_ARRAYS;
-       nv40->draw_dirty |= NV40_NEW_ARRAYS;
-}
-
 void
 nv40_init_state_functions(struct nv40_context *nv40)
 {
@@ -705,9 +695,9 @@ nv40_init_state_functions(struct nv40_context *nv40)
        nv40->pipe.delete_blend_state = nv40_blend_state_delete;
 
        nv40->pipe.create_sampler_state = nv40_sampler_state_create;
-       nv40->pipe.bind_sampler_states = nv40_sampler_state_bind;
+       nv40->pipe.bind_fragment_sampler_states = nv40_sampler_state_bind;
        nv40->pipe.delete_sampler_state = nv40_sampler_state_delete;
-       nv40->pipe.set_sampler_textures = nv40_set_sampler_texture;
+       nv40->pipe.set_fragment_sampler_textures = nv40_set_sampler_texture;
 
        nv40->pipe.create_rasterizer_state = nv40_rasterizer_state_create;
        nv40->pipe.bind_rasterizer_state = nv40_rasterizer_state_bind;
@@ -736,7 +726,6 @@ nv40_init_state_functions(struct nv40_context *nv40)
        nv40->pipe.set_scissor_state = nv40_set_scissor_state;
        nv40->pipe.set_viewport_state = nv40_set_viewport_state;
 
-       nv40->pipe.set_edgeflags = nv40_set_edgeflags;
        nv40->pipe.set_vertex_buffers = nv40_set_vertex_buffers;
        nv40->pipe.set_vertex_elements = nv40_set_vertex_elements;
 }
index 8a9d8c8fdf608bc409f3b157f53a2edc38ba9a18..192074e7471c8fe382e8b5f1f5f037870628cd5a 100644 (file)
@@ -75,6 +75,7 @@ struct nv40_fragment_program {
 
 struct nv40_miptree {
        struct pipe_texture base;
+       struct nouveau_bo *bo;
 
        struct pipe_buffer *buffer;
        uint total_size;
index 8cd05ce66ef858f138d0c9d064b9cbf2ed8e7af3..3ff00a37f66b7067093a6b5202e08b34a6f26eee 100644 (file)
@@ -18,7 +18,7 @@ struct nv40_state_entry nv40_state_blend = {
 static boolean
 nv40_state_blend_colour_validate(struct nv40_context *nv40)
 {
-       struct nouveau_stateobj *so = so_new(2, 0);
+       struct nouveau_stateobj *so = so_new(1, 1, 0);
        struct pipe_blend_color *bcol = &nv40->blend_colour;
 
        so_method(so, nv40->screen->curie, NV40TCL_BLEND_COLOR, 1);
index 198692965dc4ad3d482c2826161af03c04457524..13fe854915b3722c092e355e342c8bee6a3631db 100644 (file)
@@ -54,10 +54,11 @@ 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;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *curie = screen->curie;
+       unsigned i;
        uint64_t states;
 
        if (nv40->pctx_id != screen->cur_pctx) {
@@ -80,13 +81,21 @@ nv40_state_emit(struct nv40_context *nv40)
 
        if (state->dirty & ((1ULL << NV40_STATE_FRAGPROG) |
                            (1ULL << NV40_STATE_FRAGTEX0))) {
-               BEGIN_RING(curie, NV40TCL_TEX_CACHE_CTL, 1);
-               OUT_RING  (2);
-               BEGIN_RING(curie, NV40TCL_TEX_CACHE_CTL, 1);
-               OUT_RING  (1);
+               BEGIN_RING(chan, curie, NV40TCL_TEX_CACHE_CTL, 1);
+               OUT_RING  (chan, 2);
+               BEGIN_RING(chan, curie, NV40TCL_TEX_CACHE_CTL, 1);
+               OUT_RING  (chan, 1);
        }
 
        state->dirty = 0;
+}
+
+void
+nv40_state_flush_notify(struct nouveau_channel *chan)
+{
+       struct nv40_context *nv40 = chan->user_private;
+       struct nv40_state *state = &nv40->state;
+       unsigned i, samplers;
 
        so_emit_reloc_markers(chan, state->hw[NV40_STATE_FB]);
        for (i = 0, samplers = state->fp_samplers; i < 16 && samplers; i++) {
@@ -160,7 +169,6 @@ nv40_state_validate_swtnl(struct nv40_context *nv40)
                draw_set_viewport_state(draw, &nv40->viewport);
 
        if (nv40->draw_dirty & NV40_NEW_ARRAYS) {
-               draw_set_edgeflags(draw, nv40->edgeflags);
                draw_set_vertex_buffers(draw, nv40->vtxbuf_nr, nv40->vtxbuf);
                draw_set_vertex_elements(draw, nv40->vtxelt_nr, nv40->vtxelt);  
        }
index c2f739157ad5f7f9409bbc3f9ccf484c3dd893dc..a58fe9ddb1954718a185e6eb8eb6436953902bed 100644 (file)
@@ -19,7 +19,7 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40)
        struct nv04_surface *rt[4], *zeta;
        uint32_t rt_enable, rt_format;
        int i, colour_format = 0, zeta_format = 0;
-       struct nouveau_stateobj *so = so_new(64, 10);
+       struct nouveau_stateobj *so = so_new(18, 24, 10);
        unsigned rt_flags = NOUVEAU_BO_RDWR | NOUVEAU_BO_VRAM;
        unsigned w = fb->width;
        unsigned h = fb->height;
@@ -57,6 +57,9 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40)
                rt_format = NV40TCL_RT_FORMAT_TYPE_LINEAR;
 
        switch (colour_format) {
+       case PIPE_FORMAT_X8R8G8B8_UNORM:
+               rt_format |= NV40TCL_RT_FORMAT_COLOR_X8R8G8B8;
+               break;
        case PIPE_FORMAT_A8R8G8B8_UNORM:
        case 0:
                rt_format |= NV40TCL_RT_FORMAT_COLOR_A8R8G8B8;
index cf58d33906a9629c134f673ac8aaf6f937ac821f..753a505e934b13881a903960d4a10abeac4a9790 100644 (file)
@@ -12,7 +12,7 @@ nv40_state_scissor_validate(struct nv40_context *nv40)
                return FALSE;
        nv40->state.scissor_enabled = rast->scissor;
 
-       so = so_new(3, 0);
+       so = so_new(1, 2, 0);
        so_method(so, nv40->screen->curie, NV40TCL_SCISSOR_HORIZ, 2);
        if (nv40->state.scissor_enabled) {
                so_data  (so, ((s->maxx - s->minx) << 16) | s->minx);
index b51024ad9b20c293d365a64145177deaa95d6d86..2b371ebfec065dcbb932e35a28cd1b6a4d085c65 100644 (file)
@@ -14,14 +14,14 @@ nv40_state_stipple_validate(struct nv40_context *nv40)
        if (rast->poly_stipple_enable) {
                unsigned i;
 
-               so = so_new(35, 0);
+               so = so_new(2, 33, 0);
                so_method(so, curie, NV40TCL_POLYGON_STIPPLE_ENABLE, 1);
                so_data  (so, 1);
                so_method(so, curie, NV40TCL_POLYGON_STIPPLE_PATTERN(0), 32);
                for (i = 0; i < 32; i++)
                        so_data(so, nv40->stipple[i]);
        } else {
-               so = so_new(2, 0);
+               so = so_new(1, 1, 0);
                so_method(so, curie, NV40TCL_POLYGON_STIPPLE_ENABLE, 1);
                so_data  (so, 0);
        }
index 665d2d5fcaca698125438fdad42eb0d68aae9763..9919ba1d0b0dcd5e766181ebf5e67c5ad269c57e 100644 (file)
@@ -19,7 +19,7 @@ nv40_state_viewport_validate(struct nv40_context *nv40)
                return FALSE;
        nv40->state.viewport_bypass = bypass;
 
-       so = so_new(11, 0);
+       so = so_new(2, 9, 0);
        if (!bypass) {
                so_method(so, nv40->screen->curie,
                          NV40TCL_VIEWPORT_TRANSLATE_X, 8);
index 92caee6f3825dda7324b3326501e37cee9d11504..791ee6823d332ab3dd9ec36846995b92fa365073 100644 (file)
@@ -1,7 +1,9 @@
 #include <pipe/p_state.h>
 #include <pipe/p_defines.h>
 #include <pipe/p_inlines.h>
+#include <util/u_format.h>
 #include <util/u_memory.h>
+#include <util/u_math.h>
 #include <nouveau/nouveau_winsys.h>
 #include "nv40_context.h"
 #include "nv40_screen.h"
 struct nv40_transfer {
        struct pipe_transfer base;
        struct pipe_surface *surface;
-       bool direct;
+       boolean direct;
 };
 
 static void
-nv40_compatible_transfer_tex(struct pipe_texture *pt, unsigned level,
+nv40_compatible_transfer_tex(struct pipe_texture *pt, unsigned width, unsigned height,
                              struct pipe_texture *template)
 {
        memset(template, 0, sizeof(struct pipe_texture));
        template->target = pt->target;
        template->format = pt->format;
-       template->width[0] = pt->width[level];
-       template->height[0] = pt->height[level];
-       template->depth[0] = 1;
-       template->block = pt->block;
-       template->nblocksx[0] = pt->nblocksx[level];
-       template->nblocksy[0] = pt->nblocksx[level];
+       template->width0 = width;
+       template->height0 = height;
+       template->depth0 = 1;
        template->last_level = 0;
        template->nr_samples = pt->nr_samples;
 
@@ -48,14 +47,10 @@ nv40_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
                return NULL;
 
        pipe_texture_reference(&tx->base.texture, pt);
-       tx->base.format = pt->format;
        tx->base.x = x;
        tx->base.y = y;
        tx->base.width = w;
        tx->base.height = h;
-       tx->base.block = pt->block;
-       tx->base.nblocksx = pt->nblocksx[level];
-       tx->base.nblocksy = pt->nblocksy[level];
        tx->base.stride = mt->level[level].pitch;
        tx->base.usage = usage;
        tx->base.face = face;
@@ -76,7 +71,7 @@ nv40_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
 
        tx->direct = false;
 
-       nv40_compatible_transfer_tex(pt, level, &tx_tex_template);
+       nv40_compatible_transfer_tex(pt, w, h, &tx_tex_template);
 
        tx_tex = pscreen->texture_create(pscreen, &tx_tex_template);
        if (!tx_tex)
@@ -85,6 +80,8 @@ nv40_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
                return NULL;
        }
 
+       tx->base.stride = ((struct nv40_miptree*)tx_tex)->level[0].pitch;
+
        tx->surface = pscreen->get_tex_surface(pscreen, tx_tex,
                                               0, 0, 0,
                                               pipe_transfer_buffer_flags(&tx->base));
@@ -110,8 +107,8 @@ nv40_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
                /* TODO: Check if SIFM can un-swizzle */
                nvscreen->eng2d->copy(nvscreen->eng2d,
                                      tx->surface, 0, 0,
-                                     src, 0, 0,
-                                     src->width, src->height);
+                                     src, x, y,
+                                     w, h);
 
                pipe_surface_reference(&src, NULL);
        }
@@ -131,13 +128,13 @@ nv40_transfer_del(struct pipe_transfer *ptx)
 
                dst = pscreen->get_tex_surface(pscreen, ptx->texture,
                                               ptx->face, ptx->level, ptx->zslice,
-                                              PIPE_BUFFER_USAGE_GPU_WRITE);
+                                              PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER);
 
                /* TODO: Check if SIFM can deal with x,y,w,h when swizzling */
                nvscreen->eng2d->copy(nvscreen->eng2d,
-                                     dst, 0, 0,
+                                     dst, tx->base.x, tx->base.y,
                                      tx->surface, 0, 0,
-                                     dst->width, dst->height);
+                                     tx->base.width, tx->base.height);
 
                pipe_surface_reference(&dst, NULL);
        }
@@ -156,8 +153,10 @@ nv40_transfer_map(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
        void *map = pipe_buffer_map(pscreen, mt->buffer,
                                    pipe_transfer_buffer_flags(ptx));
 
-       return map + ns->base.offset +
-              ptx->y * ns->pitch + ptx->x * ptx->block.size;
+       if(!tx->direct)
+               return map + ns->base.offset;
+       else
+               return map + ns->base.offset + ptx->y * ns->pitch + ptx->x * util_format_get_blocksize(ptx->texture->format);
 }
 
 static void
index b2753b8e2e052a655a7f89c28e5d3243ec5c84ed..a777898f6880dafa9586febcccb3eec360f70a53 100644 (file)
@@ -164,18 +164,21 @@ nv40_vbo_static_attrib(struct nv40_context *nv40, struct nouveau_stateobj *so,
        return TRUE;
 }
 
-boolean
+void
 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->screen->base.channel;
+       struct nv40_screen *screen = nv40->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *curie = screen->curie;
        unsigned restart;
 
        nv40_vbo_set_idxbuf(nv40, NULL, 0);
        if (FORCE_SWTNL || !nv40_state_validate(nv40)) {
-               return nv40_draw_elements_swtnl(pipe, NULL, 0,
-                                               mode, start, count);
+               nv40_draw_elements_swtnl(pipe, NULL, 0,
+                                         mode, start, count);
+                return;
        }
 
        while (count) {
@@ -186,17 +189,17 @@ nv40_draw_arrays(struct pipe_context *pipe,
                vc = nouveau_vbuf_split(chan->pushbuf->remaining, 6, 256,
                                        mode, start, count, &restart);
                if (!vc) {
-                       FIRE_RING(NULL);
+                       FIRE_RING(chan);
                        continue;
                }
 
-               BEGIN_RING(curie, NV40TCL_BEGIN_END, 1);
-               OUT_RING  (nvgl_primitive(mode));
+               BEGIN_RING(chan, curie, NV40TCL_BEGIN_END, 1);
+               OUT_RING  (chan, nvgl_primitive(mode));
 
                nr = (vc & 0xff);
                if (nr) {
-                       BEGIN_RING(curie, NV40TCL_VB_VERTEX_BATCH, 1);
-                       OUT_RING  (((nr - 1) << 24) | start);
+                       BEGIN_RING(chan, curie, NV40TCL_VB_VERTEX_BATCH, 1);
+                       OUT_RING  (chan, ((nr - 1) << 24) | start);
                        start += nr;
                }
 
@@ -206,29 +209,30 @@ nv40_draw_arrays(struct pipe_context *pipe,
 
                        nr -= push;
 
-                       BEGIN_RING_NI(curie, NV40TCL_VB_VERTEX_BATCH, push);
+                       BEGIN_RING_NI(chan, curie, NV40TCL_VB_VERTEX_BATCH, push);
                        while (push--) {
-                               OUT_RING(((0x100 - 1) << 24) | start);
+                               OUT_RING(chan, ((0x100 - 1) << 24) | start);
                                start += 0x100;
                        }
                }
 
-               BEGIN_RING(curie, NV40TCL_BEGIN_END, 1);
-               OUT_RING  (0);
+               BEGIN_RING(chan, curie, NV40TCL_BEGIN_END, 1);
+               OUT_RING  (chan, 0);
 
                count -= vc;
                start = restart;
        }
 
        pipe->flush(pipe, 0, NULL);
-       return TRUE;
 }
 
 static INLINE void
 nv40_draw_elements_u08(struct nv40_context *nv40, void *ib,
                       unsigned mode, unsigned start, unsigned count)
 {
-       struct nouveau_channel *chan = nv40->screen->base.channel;
+       struct nv40_screen *screen = nv40->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *curie = screen->curie;
 
        while (count) {
                uint8_t *elts = (uint8_t *)ib + start;
@@ -239,17 +243,17 @@ nv40_draw_elements_u08(struct nv40_context *nv40, void *ib,
                vc = nouveau_vbuf_split(chan->pushbuf->remaining, 6, 2,
                                        mode, start, count, &restart);
                if (vc == 0) {
-                       FIRE_RING(NULL);
+                       FIRE_RING(chan);
                        continue;
                }
                count -= vc;
 
-               BEGIN_RING(curie, NV40TCL_BEGIN_END, 1);
-               OUT_RING  (nvgl_primitive(mode));
+               BEGIN_RING(chan, curie, NV40TCL_BEGIN_END, 1);
+               OUT_RING  (chan, nvgl_primitive(mode));
 
                if (vc & 1) {
-                       BEGIN_RING(curie, NV40TCL_VB_ELEMENT_U32, 1);
-                       OUT_RING  (elts[0]);
+                       BEGIN_RING(chan, curie, NV40TCL_VB_ELEMENT_U32, 1);
+                       OUT_RING  (chan, elts[0]);
                        elts++; vc--;
                }
 
@@ -258,16 +262,16 @@ nv40_draw_elements_u08(struct nv40_context *nv40, void *ib,
 
                        push = MIN2(vc, 2047 * 2);
 
-                       BEGIN_RING_NI(curie, NV40TCL_VB_ELEMENT_U16, push >> 1);
+                       BEGIN_RING_NI(chan, curie, NV40TCL_VB_ELEMENT_U16, push >> 1);
                        for (i = 0; i < push; i+=2)
-                               OUT_RING((elts[i+1] << 16) | elts[i]);
+                               OUT_RING(chan, (elts[i+1] << 16) | elts[i]);
 
                        vc -= push;
                        elts += push;
                }
 
-               BEGIN_RING(curie, NV40TCL_BEGIN_END, 1);
-               OUT_RING  (0);
+               BEGIN_RING(chan, curie, NV40TCL_BEGIN_END, 1);
+               OUT_RING  (chan, 0);
 
                start = restart;
        }
@@ -277,7 +281,9 @@ static INLINE void
 nv40_draw_elements_u16(struct nv40_context *nv40, void *ib,
                       unsigned mode, unsigned start, unsigned count)
 {
-       struct nouveau_channel *chan = nv40->screen->base.channel;
+       struct nv40_screen *screen = nv40->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *curie = screen->curie;
 
        while (count) {
                uint16_t *elts = (uint16_t *)ib + start;
@@ -288,17 +294,17 @@ nv40_draw_elements_u16(struct nv40_context *nv40, void *ib,
                vc = nouveau_vbuf_split(chan->pushbuf->remaining, 6, 2,
                                        mode, start, count, &restart);
                if (vc == 0) {
-                       FIRE_RING(NULL);
+                       FIRE_RING(chan);
                        continue;
                }
                count -= vc;
 
-               BEGIN_RING(curie, NV40TCL_BEGIN_END, 1);
-               OUT_RING  (nvgl_primitive(mode));
+               BEGIN_RING(chan, curie, NV40TCL_BEGIN_END, 1);
+               OUT_RING  (chan, nvgl_primitive(mode));
 
                if (vc & 1) {
-                       BEGIN_RING(curie, NV40TCL_VB_ELEMENT_U32, 1);
-                       OUT_RING  (elts[0]);
+                       BEGIN_RING(chan, curie, NV40TCL_VB_ELEMENT_U32, 1);
+                       OUT_RING  (chan, elts[0]);
                        elts++; vc--;
                }
 
@@ -307,16 +313,16 @@ nv40_draw_elements_u16(struct nv40_context *nv40, void *ib,
 
                        push = MIN2(vc, 2047 * 2);
 
-                       BEGIN_RING_NI(curie, NV40TCL_VB_ELEMENT_U16, push >> 1);
+                       BEGIN_RING_NI(chan, curie, NV40TCL_VB_ELEMENT_U16, push >> 1);
                        for (i = 0; i < push; i+=2)
-                               OUT_RING((elts[i+1] << 16) | elts[i]);
+                               OUT_RING(chan, (elts[i+1] << 16) | elts[i]);
 
                        vc -= push;
                        elts += push;
                }
 
-               BEGIN_RING(curie, NV40TCL_BEGIN_END, 1);
-               OUT_RING  (0);
+               BEGIN_RING(chan, curie, NV40TCL_BEGIN_END, 1);
+               OUT_RING  (chan, 0);
 
                start = restart;
        }
@@ -326,7 +332,9 @@ static INLINE void
 nv40_draw_elements_u32(struct nv40_context *nv40, void *ib,
                       unsigned mode, unsigned start, unsigned count)
 {
-       struct nouveau_channel *chan = nv40->screen->base.channel;
+       struct nv40_screen *screen = nv40->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *curie = screen->curie;
 
        while (count) {
                uint32_t *elts = (uint32_t *)ib + start;
@@ -337,32 +345,32 @@ nv40_draw_elements_u32(struct nv40_context *nv40, void *ib,
                vc = nouveau_vbuf_split(chan->pushbuf->remaining, 5, 1,
                                        mode, start, count, &restart);
                if (vc == 0) {
-                       FIRE_RING(NULL);
+                       FIRE_RING(chan);
                        continue;
                }
                count -= vc;
 
-               BEGIN_RING(curie, NV40TCL_BEGIN_END, 1);
-               OUT_RING  (nvgl_primitive(mode));
+               BEGIN_RING(chan, curie, NV40TCL_BEGIN_END, 1);
+               OUT_RING  (chan, nvgl_primitive(mode));
 
                while (vc) {
                        push = MIN2(vc, 2047);
 
-                       BEGIN_RING_NI(curie, NV40TCL_VB_ELEMENT_U32, push);
-                       OUT_RINGp    (elts, push);
+                       BEGIN_RING_NI(chan, curie, NV40TCL_VB_ELEMENT_U32, push);
+                       OUT_RINGp    (chan, elts, push);
 
                        vc -= push;
                        elts += push;
                }
 
-               BEGIN_RING(curie, NV40TCL_BEGIN_END, 1);
-               OUT_RING  (0);
+               BEGIN_RING(chan, curie, NV40TCL_BEGIN_END, 1);
+               OUT_RING  (chan, 0);
 
                start = restart;
        }
 }
 
-static boolean
+static void
 nv40_draw_elements_inline(struct pipe_context *pipe,
                          struct pipe_buffer *ib, unsigned ib_size,
                          unsigned mode, unsigned start, unsigned count)
@@ -393,15 +401,16 @@ nv40_draw_elements_inline(struct pipe_context *pipe,
        }
 
        pipe_buffer_unmap(pscreen, ib);
-       return TRUE;
 }
 
-static boolean
+static void
 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->screen->base.channel;
+       struct nv40_screen *screen = nv40->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *curie = screen->curie;
        unsigned restart;
 
        while (count) {
@@ -412,17 +421,17 @@ nv40_draw_elements_vbo(struct pipe_context *pipe,
                vc = nouveau_vbuf_split(chan->pushbuf->remaining, 6, 256,
                                        mode, start, count, &restart);
                if (!vc) {
-                       FIRE_RING(NULL);
+                       FIRE_RING(chan);
                        continue;
                }
                
-               BEGIN_RING(curie, NV40TCL_BEGIN_END, 1);
-               OUT_RING  (nvgl_primitive(mode));
+               BEGIN_RING(chan, curie, NV40TCL_BEGIN_END, 1);
+               OUT_RING  (chan, nvgl_primitive(mode));
 
                nr = (vc & 0xff);
                if (nr) {
-                       BEGIN_RING(curie, NV40TCL_VB_INDEX_BATCH, 1);
-                       OUT_RING  (((nr - 1) << 24) | start);
+                       BEGIN_RING(chan, curie, NV40TCL_VB_INDEX_BATCH, 1);
+                       OUT_RING  (chan, ((nr - 1) << 24) | start);
                        start += nr;
                }
 
@@ -432,24 +441,22 @@ nv40_draw_elements_vbo(struct pipe_context *pipe,
 
                        nr -= push;
 
-                       BEGIN_RING_NI(curie, NV40TCL_VB_INDEX_BATCH, push);
+                       BEGIN_RING_NI(chan, curie, NV40TCL_VB_INDEX_BATCH, push);
                        while (push--) {
-                               OUT_RING(((0x100 - 1) << 24) | start);
+                               OUT_RING(chan, ((0x100 - 1) << 24) | start);
                                start += 0x100;
                        }
                }
 
-               BEGIN_RING(curie, NV40TCL_BEGIN_END, 1);
-               OUT_RING  (0);
+               BEGIN_RING(chan, curie, NV40TCL_BEGIN_END, 1);
+               OUT_RING  (chan, 0);
 
                count -= vc;
                start = restart;
        }
-
-       return TRUE;
 }
 
-boolean
+void
 nv40_draw_elements(struct pipe_context *pipe,
                   struct pipe_buffer *indexBuffer, unsigned indexSize,
                   unsigned mode, unsigned start, unsigned count)
@@ -459,8 +466,9 @@ nv40_draw_elements(struct pipe_context *pipe,
 
        idxbuf = nv40_vbo_set_idxbuf(nv40, indexBuffer, indexSize);
        if (FORCE_SWTNL || !nv40_state_validate(nv40)) {
-               return nv40_draw_elements_swtnl(pipe, NULL, 0,
-                                               mode, start, count);
+               nv40_draw_elements_swtnl(pipe, NULL, 0,
+                                         mode, start, count);
+                return;
        }
 
        if (idxbuf) {
@@ -471,7 +479,6 @@ nv40_draw_elements(struct pipe_context *pipe,
        }
 
        pipe->flush(pipe, 0, NULL);
-       return TRUE;
 }
 
 static boolean
@@ -484,14 +491,9 @@ nv40_vbo_validate(struct nv40_context *nv40)
        unsigned vb_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD;
        int hw;
 
-       if (nv40->edgeflags) {
-               nv40->fallback_swtnl |= NV40_NEW_ARRAYS;
-               return FALSE;
-       }
-
-       vtxbuf = so_new(20, 18);
+       vtxbuf = so_new(3, 17, 18);
        so_method(vtxbuf, curie, NV40TCL_VTXBUF_ADDRESS(0), nv40->vtxelt_nr);
-       vtxfmt = so_new(17, 0);
+       vtxfmt = so_new(1, 16, 0);
        so_method(vtxfmt, curie, NV40TCL_VTXFMT(0), nv40->vtxelt_nr);
 
        for (hw = 0; hw < nv40->vtxelt_nr; hw++) {
@@ -504,7 +506,7 @@ nv40_vbo_validate(struct nv40_context *nv40)
 
                if (!vb->stride) {
                        if (!sattr)
-                               sattr = so_new(16 * 5, 0);
+                               sattr = so_new(16, 16 * 4, 0);
 
                        if (nv40_vbo_static_attrib(nv40, sattr, hw, ve, vb)) {
                                so_data(vtxbuf, 0);
index 0382dbba8f6b1d9e36f760c3565511b962db8dee..8d80fcad38e51104bd7d85096c3ec32c47f203e8 100644 (file)
@@ -295,30 +295,30 @@ static INLINE struct nv40_sreg
 tgsi_src(struct nv40_vpc *vpc, const struct tgsi_full_src_register *fsrc) {
        struct nv40_sreg src;
 
-       switch (fsrc->SrcRegister.File) {
+       switch (fsrc->Register.File) {
        case TGSI_FILE_INPUT:
-               src = nv40_sr(NV40SR_INPUT, fsrc->SrcRegister.Index);
+               src = nv40_sr(NV40SR_INPUT, fsrc->Register.Index);
                break;
        case TGSI_FILE_CONSTANT:
-               src = constant(vpc, fsrc->SrcRegister.Index, 0, 0, 0, 0);
+               src = constant(vpc, fsrc->Register.Index, 0, 0, 0, 0);
                break;
        case TGSI_FILE_IMMEDIATE:
-               src = vpc->imm[fsrc->SrcRegister.Index];
+               src = vpc->imm[fsrc->Register.Index];
                break;
        case TGSI_FILE_TEMPORARY:
-               src = vpc->r_temp[fsrc->SrcRegister.Index];
+               src = vpc->r_temp[fsrc->Register.Index];
                break;
        default:
                NOUVEAU_ERR("bad src file\n");
                break;
        }
 
-       src.abs = fsrc->SrcRegisterExtMod.Absolute;
-       src.negate = fsrc->SrcRegister.Negate;
-       src.swz[0] = fsrc->SrcRegister.SwizzleX;
-       src.swz[1] = fsrc->SrcRegister.SwizzleY;
-       src.swz[2] = fsrc->SrcRegister.SwizzleZ;
-       src.swz[3] = fsrc->SrcRegister.SwizzleW;
+       src.abs = fsrc->Register.Absolute;
+       src.negate = fsrc->Register.Negate;
+       src.swz[0] = fsrc->Register.SwizzleX;
+       src.swz[1] = fsrc->Register.SwizzleY;
+       src.swz[2] = fsrc->Register.SwizzleZ;
+       src.swz[3] = fsrc->Register.SwizzleW;
        return src;
 }
 
@@ -326,15 +326,15 @@ static INLINE struct nv40_sreg
 tgsi_dst(struct nv40_vpc *vpc, const struct tgsi_full_dst_register *fdst) {
        struct nv40_sreg dst;
 
-       switch (fdst->DstRegister.File) {
+       switch (fdst->Register.File) {
        case TGSI_FILE_OUTPUT:
-               dst = vpc->r_result[fdst->DstRegister.Index];
+               dst = vpc->r_result[fdst->Register.Index];
                break;
        case TGSI_FILE_TEMPORARY:
-               dst = vpc->r_temp[fdst->DstRegister.Index];
+               dst = vpc->r_temp[fdst->Register.Index];
                break;
        case TGSI_FILE_ADDRESS:
-               dst = vpc->r_address[fdst->DstRegister.Index];
+               dst = vpc->r_address[fdst->Register.Index];
                break;
        default:
                NOUVEAU_ERR("bad dst file\n");
@@ -362,38 +362,23 @@ src_native_swz(struct nv40_vpc *vpc, const struct tgsi_full_src_register *fsrc,
 {
        const struct nv40_sreg none = nv40_sr(NV40SR_NONE, 0);
        struct nv40_sreg tgsi = tgsi_src(vpc, fsrc);
-       uint mask = 0, zero_mask = 0, one_mask = 0, neg_mask = 0;
-       uint neg[4] = { fsrc->SrcRegisterExtSwz.NegateX,
-                       fsrc->SrcRegisterExtSwz.NegateY,
-                       fsrc->SrcRegisterExtSwz.NegateZ,
-                       fsrc->SrcRegisterExtSwz.NegateW };
+       uint mask = 0;
        uint c;
 
        for (c = 0; c < 4; c++) {
-               switch (tgsi_util_get_full_src_register_extswizzle(fsrc, c)) {
-               case TGSI_EXTSWIZZLE_X:
-               case TGSI_EXTSWIZZLE_Y:
-               case TGSI_EXTSWIZZLE_Z:
-               case TGSI_EXTSWIZZLE_W:
+               switch (tgsi_util_get_full_src_register_swizzle(fsrc, c)) {
+               case TGSI_SWIZZLE_X:
+               case TGSI_SWIZZLE_Y:
+               case TGSI_SWIZZLE_Z:
+               case TGSI_SWIZZLE_W:
                        mask |= tgsi_mask(1 << c);
                        break;
-               case TGSI_EXTSWIZZLE_ZERO:
-                       zero_mask |= tgsi_mask(1 << c);
-                       tgsi.swz[c] = SWZ_X;
-                       break;
-               case TGSI_EXTSWIZZLE_ONE:
-                       one_mask |= tgsi_mask(1 << c);
-                       tgsi.swz[c] = SWZ_X;
-                       break;
                default:
                        assert(0);
                }
-
-               if (!tgsi.negate && neg[c])
-                       neg_mask |= tgsi_mask(1 << c);
        }
 
-       if (mask == MASK_ALL && !neg_mask)
+       if (mask == MASK_ALL)
                return TRUE;
 
        *src = temp(vpc);
@@ -401,18 +386,6 @@ src_native_swz(struct nv40_vpc *vpc, const struct tgsi_full_src_register *fsrc,
        if (mask)
                arith(vpc, 0, OP_MOV, *src, mask, tgsi, none, none);
 
-       if (zero_mask)
-               arith(vpc, 0, OP_SFL, *src, zero_mask, *src, none, none);
-
-       if (one_mask)
-               arith(vpc, 0, OP_STR, *src, one_mask, *src, none, none);
-
-       if (neg_mask) {
-               struct nv40_sreg one = temp(vpc);
-               arith(vpc, 0, OP_STR, one, neg_mask, one, none, none);
-               arith(vpc, 0, OP_MUL, *src, neg_mask, *src, neg(one), none);
-       }
-
        return FALSE;
 }
 
@@ -432,8 +405,8 @@ nv40_vertprog_parse_instruction(struct nv40_vpc *vpc,
        for (i = 0; i < finst->Instruction.NumSrcRegs; i++) {
                const struct tgsi_full_src_register *fsrc;
 
-               fsrc = &finst->FullSrcRegisters[i];
-               if (fsrc->SrcRegister.File == TGSI_FILE_TEMPORARY) {
+               fsrc = &finst->Src[i];
+               if (fsrc->Register.File == TGSI_FILE_TEMPORARY) {
                        src[i] = tgsi_src(vpc, fsrc);
                }
        }
@@ -441,9 +414,9 @@ nv40_vertprog_parse_instruction(struct nv40_vpc *vpc,
        for (i = 0; i < finst->Instruction.NumSrcRegs; i++) {
                const struct tgsi_full_src_register *fsrc;
 
-               fsrc = &finst->FullSrcRegisters[i];
+               fsrc = &finst->Src[i];
 
-               switch (fsrc->SrcRegister.File) {
+               switch (fsrc->Register.File) {
                case TGSI_FILE_INPUT:
                case TGSI_FILE_CONSTANT:
                case TGSI_FILE_TEMPORARY:
@@ -454,10 +427,10 @@ nv40_vertprog_parse_instruction(struct nv40_vpc *vpc,
                        break;
                }
 
-               switch (fsrc->SrcRegister.File) {
+               switch (fsrc->Register.File) {
                case TGSI_FILE_INPUT:
-                       if (ai == -1 || ai == fsrc->SrcRegister.Index) {
-                               ai = fsrc->SrcRegister.Index;
+                       if (ai == -1 || ai == fsrc->Register.Index) {
+                               ai = fsrc->Register.Index;
                                src[i] = tgsi_src(vpc, fsrc);
                        } else {
                                src[i] = temp(vpc);
@@ -467,8 +440,8 @@ nv40_vertprog_parse_instruction(struct nv40_vpc *vpc,
                        break;
                case TGSI_FILE_CONSTANT:
                        if ((ci == -1 && ii == -1) ||
-                           ci == fsrc->SrcRegister.Index) {
-                               ci = fsrc->SrcRegister.Index;
+                           ci == fsrc->Register.Index) {
+                               ci = fsrc->Register.Index;
                                src[i] = tgsi_src(vpc, fsrc);
                        } else {
                                src[i] = temp(vpc);
@@ -478,8 +451,8 @@ nv40_vertprog_parse_instruction(struct nv40_vpc *vpc,
                        break;
                case TGSI_FILE_IMMEDIATE:
                        if ((ci == -1 && ii == -1) ||
-                           ii == fsrc->SrcRegister.Index) {
-                               ii = fsrc->SrcRegister.Index;
+                           ii == fsrc->Register.Index) {
+                               ii = fsrc->Register.Index;
                                src[i] = tgsi_src(vpc, fsrc);
                        } else {
                                src[i] = temp(vpc);
@@ -496,8 +469,8 @@ nv40_vertprog_parse_instruction(struct nv40_vpc *vpc,
                }
        }
 
-       dst  = tgsi_dst(vpc, &finst->FullDstRegisters[0]);
-       mask = tgsi_mask(finst->FullDstRegisters[0].DstRegister.WriteMask);
+       dst  = tgsi_dst(vpc, &finst->Dst[0]);
+       mask = tgsi_mask(finst->Dst[0].Register.WriteMask);
 
        switch (finst->Instruction.Opcode) {
        case TGSI_OPCODE_ABS:
@@ -604,19 +577,19 @@ static boolean
 nv40_vertprog_parse_decl_output(struct nv40_vpc *vpc,
                                const struct tgsi_full_declaration *fdec)
 {
-       unsigned idx = fdec->DeclarationRange.First;
+       unsigned idx = fdec->Range.First;
        int hw;
 
-       switch (fdec->Semantic.SemanticName) {
+       switch (fdec->Semantic.Name) {
        case TGSI_SEMANTIC_POSITION:
                hw = NV40_VP_INST_DEST_POS;
                vpc->hpos_idx = idx;
                break;
        case TGSI_SEMANTIC_COLOR:
-               if (fdec->Semantic.SemanticIndex == 0) {
+               if (fdec->Semantic.Index == 0) {
                        hw = NV40_VP_INST_DEST_COL0;
                } else
-               if (fdec->Semantic.SemanticIndex == 1) {
+               if (fdec->Semantic.Index == 1) {
                        hw = NV40_VP_INST_DEST_COL1;
                } else {
                        NOUVEAU_ERR("bad colour semantic index\n");
@@ -624,10 +597,10 @@ nv40_vertprog_parse_decl_output(struct nv40_vpc *vpc,
                }
                break;
        case TGSI_SEMANTIC_BCOLOR:
-               if (fdec->Semantic.SemanticIndex == 0) {
+               if (fdec->Semantic.Index == 0) {
                        hw = NV40_VP_INST_DEST_BFC0;
                } else
-               if (fdec->Semantic.SemanticIndex == 1) {
+               if (fdec->Semantic.Index == 1) {
                        hw = NV40_VP_INST_DEST_BFC1;
                } else {
                        NOUVEAU_ERR("bad bcolour semantic index\n");
@@ -641,13 +614,17 @@ nv40_vertprog_parse_decl_output(struct nv40_vpc *vpc,
                hw = NV40_VP_INST_DEST_PSZ;
                break;
        case TGSI_SEMANTIC_GENERIC:
-               if (fdec->Semantic.SemanticIndex <= 7) {
-                       hw = NV40_VP_INST_DEST_TC(fdec->Semantic.SemanticIndex);
+               if (fdec->Semantic.Index <= 7) {
+                       hw = NV40_VP_INST_DEST_TC(fdec->Semantic.Index);
                } else {
                        NOUVEAU_ERR("bad generic semantic index\n");
                        return FALSE;
                }
                break;
+       case TGSI_SEMANTIC_EDGEFLAG:
+               /* not really an error just a fallback */
+               NOUVEAU_ERR("cannot handle edgeflag output\n");
+               return FALSE;
        default:
                NOUVEAU_ERR("bad output semantic\n");
                return FALSE;
@@ -679,16 +656,16 @@ nv40_vertprog_prepare(struct nv40_vpc *vpc)
                        fdec = &p.FullToken.FullDeclaration;
                        switch (fdec->Declaration.File) {
                        case TGSI_FILE_TEMPORARY:
-                               if (fdec->DeclarationRange.Last > high_temp) {
+                               if (fdec->Range.Last > high_temp) {
                                        high_temp =
-                                               fdec->DeclarationRange.Last;
+                                               fdec->Range.Last;
                                }
                                break;
 #if 0 /* this would be nice.. except gallium doesn't track it */
                        case TGSI_FILE_ADDRESS:
-                               if (fdec->DeclarationRange.Last > high_addr) {
+                               if (fdec->Range.Last > high_addr) {
                                        high_addr =
-                                               fdec->DeclarationRange.Last;
+                                               fdec->Range.Last;
                                }
                                break;
 #endif
@@ -708,11 +685,11 @@ nv40_vertprog_prepare(struct nv40_vpc *vpc)
                        const struct tgsi_full_dst_register *fdst;
 
                        finst = &p.FullToken.FullInstruction;
-                       fdst = &finst->FullDstRegisters[0];
+                       fdst = &finst->Dst[0];
 
-                       if (fdst->DstRegister.File == TGSI_FILE_ADDRESS) {
-                               if (fdst->DstRegister.Index > high_addr)
-                                       high_addr = fdst->DstRegister.Index;
+                       if (fdst->Register.File == TGSI_FILE_ADDRESS) {
+                               if (fdst->Register.Index > high_addr)
+                                       high_addr = fdst->Register.Index;
                        }
                
                }
@@ -857,7 +834,9 @@ static boolean
 nv40_vertprog_validate(struct nv40_context *nv40)
 { 
        struct pipe_screen *pscreen = nv40->pipe.screen;
-       struct nouveau_grobj *curie = nv40->screen->curie;
+       struct nv40_screen *screen = nv40->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *curie = screen->curie;
        struct nv40_vertex_program *vp;
        struct pipe_buffer *constbuf;
        boolean upload_code = FALSE, upload_data = FALSE;
@@ -907,7 +886,7 @@ check_gpu_resources:
                                assert(0);
                }
 
-               so = so_new(7, 0);
+               so = so_new(3, 4, 0);
                so_method(so, curie, NV40TCL_VP_START_FROM_ID, 1);
                so_data  (so, vp->exec->start);
                so_method(so, curie, NV40TCL_VP_ATTRIB_EN, 2);
@@ -997,9 +976,9 @@ check_gpu_resources:
                                       4 * sizeof(float));
                        }
 
-                       BEGIN_RING(curie, NV40TCL_VP_UPLOAD_CONST_ID, 5);
-                       OUT_RING  (i + vp->data->start);
-                       OUT_RINGp ((uint32_t *)vpd->value, 4);
+                       BEGIN_RING(chan, curie, NV40TCL_VP_UPLOAD_CONST_ID, 5);
+                       OUT_RING  (chan, i + vp->data->start);
+                       OUT_RINGp (chan, (uint32_t *)vpd->value, 4);
                }
 
                if (constbuf)
@@ -1016,11 +995,11 @@ check_gpu_resources:
                        NOUVEAU_MSG("VP %d: 0x%08x\n", i, vp->insns[i].data[3]);
                }
 #endif
-               BEGIN_RING(curie, NV40TCL_VP_UPLOAD_FROM_ID, 1);
-               OUT_RING  (vp->exec->start);
+               BEGIN_RING(chan, curie, NV40TCL_VP_UPLOAD_FROM_ID, 1);
+               OUT_RING  (chan, vp->exec->start);
                for (i = 0; i < vp->nr_insns; i++) {
-                       BEGIN_RING(curie, NV40TCL_VP_UPLOAD_INST(0), 4);
-                       OUT_RINGp (vp->insns[i].data, 4);
+                       BEGIN_RING(chan, curie, NV40TCL_VP_UPLOAD_INST(0), 4);
+                       OUT_RINGp (chan, vp->insns[i].data, 4);
                }
        }
 
index fca078b174a4f1d3178bee90e9869a21214ffcb3..5997456e4c9911f02374a66e811d9f982045f505 100644 (file)
@@ -33,13 +33,6 @@ nv50_flush(struct pipe_context *pipe, unsigned flags,
 {
        struct nv50_context *nv50 = nv50_context(pipe);
        struct nouveau_channel *chan = nv50->screen->base.channel;
-       struct nouveau_grobj *eng2d = nv50->screen->eng2d;
-
-       /* We need this in the ddx for reliable composite, not sure what we're
-        * actually flushing. We generate all our own flushes with flags = 0. */
-       WAIT_RING(chan, 2);
-       BEGIN_RING(chan, eng2d, 0x0110, 1);
-       OUT_RING  (chan, 0);
 
        if (flags & PIPE_FLUSH_FRAME)
                FIRE_RING(chan);
@@ -50,39 +43,44 @@ nv50_destroy(struct pipe_context *pipe)
 {
        struct nv50_context *nv50 = nv50_context(pipe);
 
+        if (nv50->state.fb)
+               so_ref(NULL, &nv50->state.fb);
+       if (nv50->state.blend)
+               so_ref(NULL, &nv50->state.blend);
+       if (nv50->state.blend_colour)
+               so_ref(NULL, &nv50->state.blend_colour);
+       if (nv50->state.zsa)
+               so_ref(NULL, &nv50->state.zsa);
+       if (nv50->state.rast)
+               so_ref(NULL, &nv50->state.rast);
+       if (nv50->state.stipple)
+               so_ref(NULL, &nv50->state.stipple);
+       if (nv50->state.scissor)
+               so_ref(NULL, &nv50->state.scissor);
+       if (nv50->state.viewport)
+               so_ref(NULL, &nv50->state.viewport);
+       if (nv50->state.tsc_upload)
+               so_ref(NULL, &nv50->state.tsc_upload);
+       if (nv50->state.tic_upload)
+               so_ref(NULL, &nv50->state.tic_upload);
+       if (nv50->state.vertprog)
+               so_ref(NULL, &nv50->state.vertprog);
+       if (nv50->state.fragprog)
+               so_ref(NULL, &nv50->state.fragprog);
+       if (nv50->state.programs)
+               so_ref(NULL, &nv50->state.programs);
+       if (nv50->state.vtxfmt)
+               so_ref(NULL, &nv50->state.vtxfmt);
+       if (nv50->state.vtxbuf)
+               so_ref(NULL, &nv50->state.vtxbuf);
+       if (nv50->state.vtxattr)
+               so_ref(NULL, &nv50->state.vtxattr);
+
        draw_destroy(nv50->draw);
        FREE(nv50);
 }
 
 
-static void
-nv50_set_edgeflags(struct pipe_context *pipe, const unsigned *bitfield)
-{
-}
-
-static unsigned int
-nv50_is_texture_referenced( struct pipe_context *pipe,
-                           struct pipe_texture *texture,
-                           unsigned face, unsigned level)
-{
-   /**
-    * FIXME: Optimize.
-    */
-
-   return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
-
-static unsigned int
-nv50_is_buffer_referenced( struct pipe_context *pipe,
-                          struct pipe_buffer *buf)
-{
-   /**
-    * FIXME: Optimize.
-    */
-
-   return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
-
 struct pipe_context *
 nv50_create(struct pipe_screen *pscreen, unsigned pctx_id)
 {
@@ -101,15 +99,14 @@ nv50_create(struct pipe_screen *pscreen, unsigned pctx_id)
 
        nv50->pipe.destroy = nv50_destroy;
 
-       nv50->pipe.set_edgeflags = nv50_set_edgeflags;
        nv50->pipe.draw_arrays = nv50_draw_arrays;
        nv50->pipe.draw_elements = nv50_draw_elements;
        nv50->pipe.clear = nv50_clear;
 
        nv50->pipe.flush = nv50_flush;
 
-       nv50->pipe.is_texture_referenced = nv50_is_texture_referenced;
-       nv50->pipe.is_buffer_referenced = nv50_is_buffer_referenced;
+       nv50->pipe.is_texture_referenced = nouveau_is_texture_referenced;
+       nv50->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
 
        screen->base.channel->user_private = nv50;
        screen->base.channel->flush_notify = nv50_state_flush_notify;
index 4608854d7111734de2136facf4b6f4c1cf3acdf1..cbd4c3ff86d6b6234514a26ec9e6d4a7466c72ed 100644 (file)
@@ -14,6 +14,7 @@
 #include "nouveau/nouveau_winsys.h"
 #include "nouveau/nouveau_gldefs.h"
 #include "nouveau/nouveau_stateobj.h"
+#include "nouveau/nouveau_context.h"
 
 #include "nv50_screen.h"
 #include "nv50_program.h"
@@ -64,10 +65,22 @@ struct nv50_rasterizer_stateobj {
 };
 
 struct nv50_sampler_stateobj {
-       bool normalized;
+       boolean normalized;
        unsigned tsc[8];
 };
 
+static INLINE unsigned
+get_tile_height(uint32_t tile_mode)
+{
+        return 1 << ((tile_mode & 0xf) + 2);
+}
+
+static INLINE unsigned
+get_tile_depth(uint32_t tile_mode)
+{
+        return 1 << (tile_mode >> 4);
+}
+
 struct nv50_miptree_level {
        int *image_offset;
        unsigned pitch;
@@ -113,13 +126,14 @@ struct nv50_state {
        unsigned viewport_bypass;
        struct nouveau_stateobj *tsc_upload;
        struct nouveau_stateobj *tic_upload;
-       unsigned miptree_nr;
+       unsigned miptree_nr[PIPE_SHADER_TYPES];
        struct nouveau_stateobj *vertprog;
        struct nouveau_stateobj *fragprog;
        struct nouveau_stateobj *programs;
        struct nouveau_stateobj *vtxfmt;
        struct nouveau_stateobj *vtxbuf;
        struct nouveau_stateobj *vtxattr;
+       unsigned vtxelt_nr;
 };
 
 struct nv50_context {
@@ -148,10 +162,12 @@ struct nv50_context {
        unsigned vtxbuf_nr;
        struct pipe_vertex_element vtxelt[PIPE_MAX_ATTRIBS];
        unsigned vtxelt_nr;
-       struct nv50_sampler_stateobj *sampler[PIPE_MAX_SAMPLERS];
-       unsigned sampler_nr;
-       struct nv50_miptree *miptree[PIPE_MAX_SAMPLERS];
-       unsigned miptree_nr;
+       struct nv50_sampler_stateobj *sampler[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
+       unsigned sampler_nr[PIPE_SHADER_TYPES];
+       struct nv50_miptree *miptree[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
+       unsigned miptree_nr[PIPE_SHADER_TYPES];
+
+       uint16_t vbo_fifo;
 };
 
 static INLINE struct nv50_context *
@@ -175,9 +191,9 @@ nv50_surface_do_copy(struct nv50_screen *screen, struct pipe_surface *dst,
 extern struct draw_stage *nv50_draw_render_stage(struct nv50_context *nv50);
 
 /* nv50_vbo.c */
-extern boolean nv50_draw_arrays(struct pipe_context *, unsigned mode,
+extern void nv50_draw_arrays(struct pipe_context *, unsigned mode,
                                unsigned start, unsigned count);
-extern boolean nv50_draw_elements(struct pipe_context *pipe,
+extern void nv50_draw_elements(struct pipe_context *pipe,
                                  struct pipe_buffer *indexBuffer,
                                  unsigned indexSize,
                                  unsigned mode, unsigned start,
@@ -192,13 +208,27 @@ extern void nv50_clear(struct pipe_context *pipe, unsigned buffers,
 extern void nv50_vertprog_validate(struct nv50_context *nv50);
 extern void nv50_fragprog_validate(struct nv50_context *nv50);
 extern void nv50_linkage_validate(struct nv50_context *nv50);
-extern void nv50_program_destroy(struct nv50_context *nv50, struct nv50_program *p);
+extern void nv50_program_destroy(struct nv50_context *nv50,
+                                struct nv50_program *p);
 
 /* nv50_state_validate.c */
 extern boolean nv50_state_validate(struct nv50_context *nv50);
 extern void nv50_state_flush_notify(struct nouveau_channel *chan);
 
+extern void nv50_so_init_sifc(struct nv50_context *nv50,
+                             struct nouveau_stateobj *so,
+                             struct nouveau_bo *bo, unsigned reloc,
+                             unsigned offset, unsigned size);
+
 /* nv50_tex.c */
 extern void nv50_tex_validate(struct nv50_context *);
 
+/* nv50_transfer.c */
+extern void
+nv50_upload_sifc(struct nv50_context *nv50,
+                struct nouveau_bo *bo, unsigned dst_offset, unsigned reloc,
+                unsigned dst_format, int dst_w, int dst_h, int dst_pitch,
+                void *src, unsigned src_format, int src_pitch,
+                int x, int y, int w, int h, int cpp);
+
 #endif
index 93479a0314a2c2279ead0ea25183d44166fad27b..3f1edf0a13970cba730556e2b3eee69f97d44239 100644 (file)
 #include "pipe/p_state.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_inlines.h"
+#include "util/u_format.h"
 
 #include "nv50_context.h"
 
+/* The restrictions in tile mode selection probably aren't necessary. */
+static INLINE uint32_t
+get_tile_mode(unsigned ny, unsigned d)
+{
+       uint32_t tile_mode = 0x00;
+
+       if (ny > 32) tile_mode = 0x04; /* height 64 tiles */
+       else
+       if (ny > 16) tile_mode = 0x03; /* height 32 tiles */
+       else
+       if (ny >  8) tile_mode = 0x02; /* height 16 tiles */
+       else
+       if (ny >  4) tile_mode = 0x01; /* height 8 tiles */
+
+       if (d == 1)
+               return tile_mode;
+       else
+       if (tile_mode > 0x02)
+               tile_mode = 0x02;
+
+       if (d > 16 && tile_mode < 0x02)
+               return tile_mode | 0x50; /* depth 32 tiles */
+       if (d >  8) return tile_mode | 0x40; /* depth 16 tiles */
+       if (d >  4) return tile_mode | 0x30; /* depth 8 tiles */
+       if (d >  2) return tile_mode | 0x20; /* depth 4 tiles */
+
+       return tile_mode | 0x10;
+}
+
+static INLINE unsigned
+get_zslice_offset(unsigned tile_mode, unsigned z, unsigned pitch, unsigned nb_h)
+{
+       unsigned tile_h = get_tile_height(tile_mode);
+       unsigned tile_d = get_tile_depth(tile_mode);
+
+       /* pitch_2d == to next slice within this volume-tile */
+       /* pitch_3d == size (in bytes) of a volume-tile */
+       unsigned pitch_2d = tile_h * 64;
+       unsigned pitch_3d = tile_d * align(nb_h, tile_h) * pitch;
+
+       return (z % tile_d) * pitch_2d + (z / tile_d) * pitch_3d;
+}
+
 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.base;
-       unsigned width = tmp->width[0], height = tmp->height[0];
-       unsigned depth = tmp->depth[0];
-       uint32_t tile_mode, tile_flags, tile_h;
+       unsigned width = tmp->width0, height = tmp->height0;
+       unsigned depth = tmp->depth0, image_alignment;
+       uint32_t tile_flags;
        int ret, i, l;
 
        *pt = *tmp;
@@ -57,68 +101,52 @@ nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *tmp)
                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];
-               break;
-       case PIPE_TEXTURE_CUBE:
-               mt->image_nr = 6;
-               break;
-       default:
-               mt->image_nr = 1;
-               break;
-       }
+       /* XXX: texture arrays */
+       mt->image_nr = (pt->target == PIPE_TEXTURE_CUBE) ? 6 : 1;
 
        for (l = 0; l <= pt->last_level; l++) {
                struct nv50_miptree_level *lvl = &mt->level[l];
-
-               pt->width[l] = width;
-               pt->height[l] = height;
-               pt->depth[l] = depth;
-               pt->nblocksx[l] = pf_get_nblocksx(&pt->block, width);
-               pt->nblocksy[l] = pf_get_nblocksy(&pt->block, height);
+               unsigned nblocksy = util_format_get_nblocksy(pt->format, height);
 
                lvl->image_offset = CALLOC(mt->image_nr, sizeof(int));
-               lvl->pitch = align(pt->width[l] * pt->block.size, 64);
-               lvl->tile_mode = tile_mode;
-
-               width = MAX2(1, width >> 1);
-               height = MAX2(1, height >> 1);
-               depth = MAX2(1, depth >> 1);
+               lvl->pitch = align(util_format_get_stride(pt->format, width), 64);
+               lvl->tile_mode = get_tile_mode(nblocksy, depth);
 
-               if (tile_mode && height <= (tile_h >> 1)) {
-                       tile_mode--;
-                       tile_h >>= 1;
-               }
+               width = u_minify(width, 1);
+               height = u_minify(height, 1);
+               depth = u_minify(depth, 1);
        }
 
+       image_alignment  = get_tile_height(mt->level[0].tile_mode) * 64;
+       image_alignment *= get_tile_depth(mt->level[0].tile_mode);
+
+       /* NOTE the distinction between arrays of mip-mapped 2D textures and
+        * mip-mapped 3D textures. We can't use image_nr == depth for 3D mip.
+        */
        for (i = 0; i < mt->image_nr; i++) {
                for (l = 0; l <= pt->last_level; l++) {
                        struct nv50_miptree_level *lvl = &mt->level[l];
                        int size;
-                       tile_h = 1 << (lvl->tile_mode + 2);
+                       unsigned tile_h = get_tile_height(lvl->tile_mode);
+                       unsigned tile_d = get_tile_depth(lvl->tile_mode);
 
-                       size  = align(pt->width[l], 8) * pt->block.size;
-                       size  = align(size, 64);
-                       size *= align(pt->height[l], tile_h);
+                       size  = lvl->pitch;
+                       size *= align(util_format_get_nblocksy(pt->format, u_minify(pt->height0, l)), tile_h);
+                       size *= align(u_minify(pt->depth0, l), tile_d);
 
                        lvl->image_offset[i] = mt->total_size;
 
                        mt->total_size += size;
                }
+               mt->total_size = align(mt->total_size, image_alignment);
        }
 
        ret = nouveau_bo_new_tile(dev, NOUVEAU_BO_VRAM, 256, mt->total_size,
                                  mt->level[0].tile_mode, tile_flags,
                                  &mt->base.bo);
        if (ret) {
+               for (l = 0; l < pt->last_level; ++l)
+                       FREE(mt->level[l].image_offset);
                FREE(mt);
                return NULL;
        }
@@ -135,7 +163,7 @@ nv50_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
 
        /* Only supports 2D, non-mipmapped textures for the moment */
        if (pt->target != PIPE_TEXTURE_2D || pt->last_level != 0 ||
-           pt->depth[0] != 1)
+           pt->depth0 != 1)
                return NULL;
 
        mt = CALLOC_STRUCT(nv50_miptree);
@@ -158,6 +186,10 @@ static void
 nv50_miptree_destroy(struct pipe_texture *pt)
 {
        struct nv50_miptree *mt = nv50_miptree(pt);
+       unsigned l;
+
+       for (l = 0; l < pt->last_level; ++l)
+               FREE(mt->level[l].image_offset);
 
        nouveau_bo_ref(NULL, &mt->base.bo);
        FREE(mt);
@@ -171,23 +203,18 @@ nv50_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
        struct nv50_miptree *mt = nv50_miptree(pt);
        struct nv50_miptree_level *lvl = &mt->level[level];
        struct pipe_surface *ps;
-       int img;
+       unsigned img = 0;
 
        if (pt->target == PIPE_TEXTURE_CUBE)
                img = face;
-       else
-       if (pt->target == PIPE_TEXTURE_3D)
-               img = zslice;
-       else
-               img = 0;
 
        ps = CALLOC_STRUCT(pipe_surface);
        if (!ps)
                return NULL;
        pipe_texture_reference(&ps->texture, pt);
        ps->format = pt->format;
-       ps->width = pt->width[level];
-       ps->height = pt->height[level];
+       ps->width = u_minify(pt->width0, level);
+       ps->height = u_minify(pt->height0, level);
        ps->usage = flags;
        pipe_reference_init(&ps->reference, 1);
        ps->face = face;
@@ -195,6 +222,12 @@ nv50_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
        ps->zslice = zslice;
        ps->offset = lvl->image_offset[img];
 
+       if (pt->target == PIPE_TEXTURE_3D) {
+               unsigned nb_h = util_format_get_nblocksy(pt->format, ps->height);
+               ps->offset += get_zslice_offset(lvl->tile_mode, zslice,
+                                               lvl->pitch, nb_h);
+       }
+
        return ps;
 }
 
index 576d075318f9b187bc8ba7a3cb5ebaafa7dcddf9..53f9f0adf310e610ab13926e590b4c62be515cc8 100644 (file)
 
 #include "nv50_context.h"
 
-#define NV50_SU_MAX_TEMP 64
+#define NV50_SU_MAX_TEMP 127
+#define NV50_SU_MAX_ADDR 4
 //#define NV50_PROGRAM_DUMP
 
+/* $a5 and $a6 always seem to be 0, and using $a7 gives you noise */
+
 /* ARL - gallium craps itself on progs/vp/arl.txt
  *
  * MSB - Like MAD, but MUL+SUB
@@ -79,26 +82,44 @@ struct nv50_reg {
                P_ATTR,
                P_RESULT,
                P_CONST,
-               P_IMMD
+               P_IMMD,
+               P_ADDR
        } type;
        int index;
 
        int hw;
-       int neg;
+       int mod;
 
        int rhw; /* result hw for FP outputs, or interpolant index */
        int acc; /* instruction where this reg is last read (first insn == 1) */
 };
 
-/* arbitrary limits */
-#define MAX_IF_DEPTH 4
-#define MAX_LOOP_DEPTH 4
+#define NV50_MOD_NEG 1
+#define NV50_MOD_ABS 2
+#define NV50_MOD_NEG_ABS (NV50_MOD_NEG | NV50_MOD_ABS)
+#define NV50_MOD_SAT 4
+#define NV50_MOD_I32 8
+
+/* NV50_MOD_I32 is used to indicate integer mode for neg/abs */
+
+/* STACK: Conditionals and loops have to use the (per warp) stack.
+ * Stack entries consist of an entry type (divergent path, join at),
+ * a mask indicating the active threads of the warp, and an address.
+ * MPs can store 12 stack entries internally, if we need more (and
+ * we probably do), we have to create a stack buffer in VRAM.
+ */
+/* impose low limits for now */
+#define NV50_MAX_COND_NESTING 4
+#define NV50_MAX_LOOP_NESTING 3
+
+#define JOIN_ON(e) e; pc->p->exec_tail->inst[1] |= 2
 
 struct nv50_pc {
        struct nv50_program *p;
 
        /* hw resources */
        struct nv50_reg *r_temp[NV50_SU_MAX_TEMP];
+       struct nv50_reg r_addr[NV50_SU_MAX_ADDR];
 
        /* tgsi resources */
        struct nv50_reg *temp;
@@ -110,8 +131,11 @@ struct nv50_pc {
        struct nv50_reg *param;
        int param_nr;
        struct nv50_reg *immd;
-       float *immd_buf;
+       uint32_t *immd_buf;
        int immd_nr;
+       struct nv50_reg **addr;
+       int addr_nr;
+       uint8_t addr_alloc; /* set bit indicates used for TGSI_FILE_ADDRESS */
 
        struct nv50_reg *temp_temp[16];
        unsigned temp_temp_nr;
@@ -120,23 +144,30 @@ struct nv50_pc {
        struct nv50_reg *r_brdc;
        struct nv50_reg *r_dst[4];
 
+       struct nv50_reg reg_instances[16];
+       unsigned reg_instance_nr;
+
        unsigned interp_mode[32];
        /* perspective interpolation registers */
        struct nv50_reg *iv_p;
        struct nv50_reg *iv_c;
 
-       struct nv50_program_exec *if_cond;
-       struct nv50_program_exec *if_insn[MAX_IF_DEPTH];
-       struct nv50_program_exec *br_join[MAX_IF_DEPTH];
-       struct nv50_program_exec *br_loop[MAX_LOOP_DEPTH]; /* for BRK branch */
+       struct nv50_program_exec *if_insn[NV50_MAX_COND_NESTING];
+       struct nv50_program_exec *if_join[NV50_MAX_COND_NESTING];
+       struct nv50_program_exec *loop_brka[NV50_MAX_LOOP_NESTING];
        int if_lvl, loop_lvl;
-       unsigned loop_pos[MAX_LOOP_DEPTH];
+       unsigned loop_pos[NV50_MAX_LOOP_NESTING];
+
+       unsigned *insn_pos; /* actual program offset of each TGSI insn */
+       boolean in_subroutine;
 
        /* current instruction and total number of insns */
        unsigned insn_cur;
        unsigned insn_nr;
 
        boolean allow32;
+
+       uint8_t edgeflag_out;
 };
 
 static INLINE void
@@ -145,7 +176,7 @@ ctor_reg(struct nv50_reg *reg, unsigned type, int index, int hw)
        reg->type = type;
        reg->index = index;
        reg->hw = hw;
-       reg->neg = 0;
+       reg->mod = 0;
        reg->rhw = -1;
        reg->acc = 0;
 }
@@ -158,6 +189,16 @@ popcnt4(uint32_t val)
        return cnt[val & 0xf];
 }
 
+static void
+terminate_mbb(struct nv50_pc *pc)
+{
+       int i;
+
+       /* remove records of temporary address register values */
+       for (i = 0; i < NV50_SU_MAX_ADDR; ++i)
+               pc->r_addr[i].rhw = -1;
+}
+
 static void
 alloc_reg(struct nv50_pc *pc, struct nv50_reg *reg)
 {
@@ -207,6 +248,21 @@ alloc_reg(struct nv50_pc *pc, struct nv50_reg *reg)
        assert(0);
 }
 
+static INLINE struct nv50_reg *
+reg_instance(struct nv50_pc *pc, struct nv50_reg *reg)
+{
+       struct nv50_reg *ri;
+
+       assert(pc->reg_instance_nr < 16);
+       ri = &pc->reg_instances[pc->reg_instance_nr++];
+       if (reg) {
+               alloc_reg(pc, reg);
+               *ri = *reg;
+               reg->mod = 0;
+       }
+       return ri;
+}
+
 /* XXX: For shaders that aren't executed linearly (e.g. shaders that
  * contain loops), we need to assign all hw regs to TGSI TEMPs early,
  * lest we risk temp_temps overwriting regs alloc'd "later".
@@ -233,22 +289,6 @@ 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)
@@ -320,25 +360,34 @@ static void
 kill_temp_temp(struct nv50_pc *pc)
 {
        int i;
-       
+
        for (i = 0; i < pc->temp_temp_nr; i++)
                free_temp(pc, pc->temp_temp[i]);
        pc->temp_temp_nr = 0;
 }
 
 static int
-ctor_immd(struct nv50_pc *pc, float x, float y, float z, float w)
+ctor_immd_4u32(struct nv50_pc *pc,
+              uint32_t x, uint32_t y, uint32_t z, uint32_t w)
 {
-       pc->immd_buf = REALLOC(pc->immd_buf, (pc->immd_nr * 4 * sizeof(float)),
-                              (pc->immd_nr + 1) * 4 * sizeof(float));
+       unsigned size = pc->immd_nr * 4 * sizeof(uint32_t);
+
+       pc->immd_buf = REALLOC(pc->immd_buf, size, size + 4 * sizeof(uint32_t));
+
        pc->immd_buf[(pc->immd_nr * 4) + 0] = x;
        pc->immd_buf[(pc->immd_nr * 4) + 1] = y;
        pc->immd_buf[(pc->immd_nr * 4) + 2] = z;
        pc->immd_buf[(pc->immd_nr * 4) + 3] = w;
-       
+
        return pc->immd_nr++;
 }
 
+static INLINE int
+ctor_immd_4f32(struct nv50_pc *pc, float x, float y, float z, float w)
+{
+       return ctor_immd_4u32(pc, fui(x), fui(y), fui(z), fui(w));
+}
+
 static struct nv50_reg *
 alloc_immd(struct nv50_pc *pc, float f)
 {
@@ -346,11 +395,11 @@ alloc_immd(struct nv50_pc *pc, float f)
        unsigned hw;
 
        for (hw = 0; hw < pc->immd_nr * 4; hw++)
-               if (pc->immd_buf[hw] == f)
+               if (pc->immd_buf[hw] == fui(f))
                        break;
 
        if (hw == pc->immd_nr * 4)
-               hw = ctor_immd(pc, f, -f, 0.5 * f, 0) * 4;
+               hw = ctor_immd_4f32(pc, f, -f, 0.5 * f, 0) * 4;
 
        ctor_reg(r, P_IMMD, -1, hw);
        return r;
@@ -396,10 +445,19 @@ is_immd(struct nv50_program_exec *e)
        return FALSE;
 }
 
+static boolean
+is_join(struct nv50_program_exec *e)
+{
+       if (is_long(e) && (e->inst[1] & 3) == 2)
+               return TRUE;
+       return FALSE;
+}
+
 static INLINE void
 set_pred(struct nv50_pc *pc, unsigned pred, unsigned idx,
         struct nv50_program_exec *e)
 {
+       assert(!is_immd(e));
        set_long(pc, e);
        e->inst[1] &= ~((0x1f << 7) | (0x3 << 12));
        e->inst[1] |= (pred << 7) | (idx << 12);
@@ -434,29 +492,119 @@ set_dst(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_program_exec *e)
        }
 
        alloc_reg(pc, dst);
+       if (dst->hw > 63)
+               set_long(pc, e);
        e->inst[0] |= (dst->hw << 2);
 }
 
 static INLINE void
 set_immd(struct nv50_pc *pc, struct nv50_reg *imm, struct nv50_program_exec *e)
 {
-       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
-        *     are required and avoid them. */
+       /* XXX: can't be predicated - bits overlap; cases where both
+        * are required should be avoided by using pc->allow32 */
        set_pred(pc, 0, 0, e);
        set_pred_wr(pc, 0, 0, e);
 
        e->inst[1] |= 0x00000002 | 0x00000001;
-       e->inst[0] |= (val & 0x3f) << 16;
-       e->inst[1] |= (val >> 6) << 2;
+       e->inst[0] |= (pc->immd_buf[imm->hw] & 0x3f) << 16;
+       e->inst[1] |= (pc->immd_buf[imm->hw] >> 6) << 2;
 }
 
+static INLINE void
+set_addr(struct nv50_program_exec *e, struct nv50_reg *a)
+{
+       assert(!(e->inst[0] & 0x0c000000));
+       assert(!(e->inst[1] & 0x00000004));
+
+       e->inst[0] |= (a->hw & 3) << 26;
+       e->inst[1] |= (a->hw >> 2) << 2;
+}
+
+static void
+emit_add_addr_imm(struct nv50_pc *pc, struct nv50_reg *dst,
+                 struct nv50_reg *src0, uint16_t src1_val)
+{
+       struct nv50_program_exec *e = exec(pc);
+
+       e->inst[0] = 0xd0000000 | (src1_val << 9);
+       e->inst[1] = 0x20000000;
+       set_long(pc, e);
+       e->inst[0] |= dst->hw << 2;
+       if (src0) /* otherwise will add to $a0, which is always 0 */
+               set_addr(e, src0);
+
+       emit(pc, e);
+}
+
+static struct nv50_reg *
+alloc_addr(struct nv50_pc *pc, struct nv50_reg *ref)
+{
+       struct nv50_reg *a_tgsi = NULL, *a = NULL;
+       int i;
+       uint8_t avail = ~pc->addr_alloc;
+
+       if (!ref) {
+               /* allocate for TGSI_FILE_ADDRESS */
+               while (avail) {
+                       i = ffs(avail) - 1;
+
+                       if (pc->r_addr[i].rhw < 0 ||
+                           pc->r_addr[i].acc != pc->insn_cur) {
+                               pc->addr_alloc |= (1 << i);
+
+                               pc->r_addr[i].rhw = -1;
+                               pc->r_addr[i].index = i;
+                               return &pc->r_addr[i];
+                       }
+                       avail &= ~(1 << i);
+               }
+               assert(0);
+               return NULL;
+       }
+
+       /* Allocate and set an address reg so we can access 'ref'.
+        *
+        * If and r_addr->index will be -1 or the hw index the value
+        * value in rhw is relative to. If rhw < 0, the reg has not
+        * been initialized or is in use for TGSI_FILE_ADDRESS.
+        */
+       while (avail) { /* only consider regs that are not TGSI */
+               i = ffs(avail) - 1;
+               avail &= ~(1 << i);
+
+               if ((!a || a->rhw >= 0) && pc->r_addr[i].rhw < 0) {
+                       /* prefer an usused reg with low hw index */
+                       a = &pc->r_addr[i];
+                       continue;
+               }
+               if (!a && pc->r_addr[i].acc != pc->insn_cur)
+                       a = &pc->r_addr[i];
+
+               if (ref->hw - pc->r_addr[i].rhw >= 128)
+                       continue;
+
+               if ((ref->acc >= 0 && pc->r_addr[i].index < 0) ||
+                   (ref->acc < 0 && pc->r_addr[i].index == ref->index)) {
+                       pc->r_addr[i].acc = pc->insn_cur;
+                       return &pc->r_addr[i];
+               }
+       }
+       assert(a);
+
+       if (ref->acc < 0)
+               a_tgsi = pc->addr[ref->index];
+
+       emit_add_addr_imm(pc, a, a_tgsi, (ref->hw & ~0x7f) * 4);
+
+       a->rhw = ref->hw & ~0x7f;
+       a->acc = pc->insn_cur;
+       a->index = a_tgsi ? ref->index : -1;
+       return a;
+}
 
 #define INTERP_LINEAR          0
-#define INTERP_FLAT                    1
+#define INTERP_FLAT            1
 #define INTERP_PERSPECTIVE     2
 #define INTERP_CENTROID                4
 
@@ -494,23 +642,34 @@ set_data(struct nv50_pc *pc, struct nv50_reg *src, unsigned m, unsigned s,
 {
        set_long(pc, e);
 
-       e->param.index = src->hw;
+       e->param.index = src->hw & 127;
        e->param.shift = s;
        e->param.mask = m << (s % 32);
 
+       if (src->hw > 127)
+               set_addr(e, alloc_addr(pc, src));
+       else
+       if (src->acc < 0) {
+               assert(src->type == P_CONST);
+               set_addr(e, pc->addr[src->index]);
+       }
+
        e->inst[1] |= (((src->type == P_IMMD) ? 0 : 1) << 22);
 }
 
+/* Never apply nv50_reg::mod in emit_mov, or carefully check the code !!! */
 static void
 emit_mov(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src)
 {
        struct nv50_program_exec *e = exec(pc);
 
-       e->inst[0] |= 0x10000000;
+       e->inst[0] = 0x10000000;
+       if (!pc->allow32)
+               set_long(pc, e);
 
        set_dst(pc, dst, e);
 
-       if (pc->allow32 && dst->type != P_RESULT && src->type == P_IMMD) {
+       if (!is_long(e) && 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
@@ -519,7 +678,7 @@ emit_mov(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src)
        if (src->type == P_IMMD || src->type == P_CONST) {
                set_long(pc, e);
                set_data(pc, src, 0x7f, 9, e);
-               e->inst[1] |= 0x20000000; /* src0 const? */
+               e->inst[1] |= 0x20000000; /* mov from c[] */
        } else {
                if (src->type == P_ATTR) {
                        set_long(pc, e);
@@ -527,14 +686,16 @@ emit_mov(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src)
                }
 
                alloc_reg(pc, src);
+               if (src->hw > 63)
+                       set_long(pc, e);
                e->inst[0] |= (src->hw << 9);
        }
 
        if (is_long(e) && !is_immd(e)) {
                e->inst[1] |= 0x04000000; /* 32-bit */
-               e->inst[1] |= 0x0000c000; /* "subsubop" 0x3 */
+               e->inst[1] |= 0x0000c000; /* 32-bit c[] load / lane mask 0:1 */
                if (!(e->inst[1] & 0x20000000))
-                       e->inst[1] |= 0x00030000; /* "subsubop" 0xf */
+                       e->inst[1] |= 0x00030000; /* lane mask 2:3 */
        } else
                e->inst[0] |= 0x00008000;
 
@@ -549,6 +710,45 @@ emit_mov_immdval(struct nv50_pc *pc, struct nv50_reg *dst, float f)
        FREE(imm);
 }
 
+/* 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 (pc->if_lvl || pc->loop_lvl ||
+           (dst->type != P_TEMP) ||
+           (src->hw < pc->result_nr * 4 &&
+            pc->p->type == PIPE_SHADER_FRAGMENT) ||
+           pc->p->info.opcode_count[TGSI_OPCODE_CAL] ||
+           pc->p->info.opcode_count[TGSI_OPCODE_BRA]) {
+
+               emit_mov(pc, dst, src);
+               free_temp(pc, src);
+               return;
+       }
+
+       if (dst->hw != -1)
+               pc->r_temp[dst->hw] = NULL;
+       pc->r_temp[src->hw] = dst;
+       dst->hw = src->hw;
+
+       FREE(src);
+}
+
+static void
+emit_nop(struct nv50_pc *pc)
+{
+       struct nv50_program_exec *e = exec(pc);
+
+       e->inst[0] = 0xf0000000;
+       set_long(pc, e);
+       e->inst[1] = 0xe0000000;
+       emit(pc, e);
+}
+
 static boolean
 check_swap_src_0_1(struct nv50_pc *pc,
                   struct nv50_reg **s0, struct nv50_reg **s1)
@@ -586,6 +786,8 @@ set_src_0_restricted(struct nv50_pc *pc, struct nv50_reg *src,
        }
 
        alloc_reg(pc, src);
+       if (src->hw > 63)
+               set_long(pc, e);
        e->inst[0] |= (src->hw << 9);
 }
 
@@ -604,6 +806,8 @@ set_src_0(struct nv50_pc *pc, struct nv50_reg *src, struct nv50_program_exec *e)
        }
 
        alloc_reg(pc, src);
+       if (src->hw > 63)
+               set_long(pc, e);
        e->inst[0] |= (src->hw << 9);
 }
 
@@ -630,7 +834,9 @@ set_src_1(struct nv50_pc *pc, struct nv50_reg *src, struct nv50_program_exec *e)
        }
 
        alloc_reg(pc, src);
-       e->inst[0] |= (src->hw << 16);
+       if (src->hw > 63)
+               set_long(pc, e);
+       e->inst[0] |= ((src->hw & 127) << 16);
 }
 
 static void
@@ -658,7 +864,34 @@ set_src_2(struct nv50_pc *pc, struct nv50_reg *src, struct nv50_program_exec *e)
        }
 
        alloc_reg(pc, src);
-       e->inst[1] |= (src->hw << 14);
+       e->inst[1] |= ((src->hw & 127) << 14);
+}
+
+static void
+emit_mov_from_pred(struct nv50_pc *pc, struct nv50_reg *dst, int pred)
+{
+       struct nv50_program_exec *e = exec(pc);
+
+       assert(dst->type == P_TEMP);
+       e->inst[1] = 0x20000000 | (pred << 12);
+       set_long(pc, e);
+       set_dst(pc, dst, e);
+
+       emit(pc, e);
+}
+
+static void
+emit_mov_to_pred(struct nv50_pc *pc, int pred, struct nv50_reg *src)
+{
+       struct nv50_program_exec *e = exec(pc);
+
+       e->inst[0] = 0x000001fc;
+       e->inst[1] = 0xa0000008;
+       set_long(pc, e);
+       set_pred_wr(pc, 1, pred, e);
+       set_src_0_restricted(pc, src, e);
+
+       emit(pc, e);
 }
 
 static void
@@ -676,12 +909,12 @@ emit_mul(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src0,
        set_dst(pc, dst, e);
        set_src_0(pc, src0, e);
        if (src1->type == P_IMMD && !is_long(e)) {
-               if (src0->neg)
+               if (src0->mod ^ src1->mod)
                        e->inst[0] |= 0x00008000;
                set_immd(pc, src1, e);
        } else {
                set_src_1(pc, src1, e);
-               if (src0->neg ^ src1->neg) {
+               if ((src0->mod ^ src1->mod) & NV50_MOD_NEG) {
                        if (is_long(e))
                                e->inst[1] |= 0x08000000;
                        else
@@ -698,13 +931,15 @@ emit_add(struct nv50_pc *pc, struct nv50_reg *dst,
 {
        struct nv50_program_exec *e = exec(pc);
 
-       e->inst[0] |= 0xb0000000;
+       e->inst[0] = 0xb0000000;
 
+       alloc_reg(pc, src1);
        check_swap_src_0_1(pc, &src0, &src1);
 
-       if (!pc->allow32 || src0->neg || src1->neg) {
+       if (!pc->allow32 || (src0->mod | src1->mod) || src1->hw > 63) {
                set_long(pc, e);
-               e->inst[1] |= (src0->neg << 26) | (src1->neg << 27);
+               e->inst[1] |= ((src0->mod & NV50_MOD_NEG) << 26) |
+                             ((src1->mod & NV50_MOD_NEG) << 27);
        }
 
        set_dst(pc, dst, e);
@@ -720,6 +955,29 @@ emit_add(struct nv50_pc *pc, struct nv50_reg *dst,
        emit(pc, e);
 }
 
+static void
+emit_arl(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src,
+        uint8_t s)
+{
+       struct nv50_program_exec *e = exec(pc);
+
+       set_long(pc, e);
+       e->inst[1] |= 0xc0000000;
+
+       e->inst[0] |= dst->hw << 2;
+       e->inst[0] |= s << 16; /* shift left */
+       set_src_0_restricted(pc, src, e);
+
+       emit(pc, e);
+}
+
+#define NV50_MAX_F32 0x880
+#define NV50_MAX_S32 0x08c
+#define NV50_MAX_U32 0x084
+#define NV50_MIN_F32 0x8a0
+#define NV50_MIN_S32 0x0ac
+#define NV50_MIN_U32 0x0a4
+
 static void
 emit_minmax(struct nv50_pc *pc, unsigned sub, struct nv50_reg *dst,
            struct nv50_reg *src0, struct nv50_reg *src1)
@@ -727,14 +985,19 @@ emit_minmax(struct nv50_pc *pc, unsigned sub, struct nv50_reg *dst,
        struct nv50_program_exec *e = exec(pc);
 
        set_long(pc, e);
-       e->inst[0] |= 0xb0000000;
-       e->inst[1] |= (sub << 29);
+       e->inst[0] |= 0x30000000 | ((sub & 0x800) << 20);
+       e->inst[1] |= (sub << 24);
 
        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 (src0->mod & NV50_MOD_ABS)
+               e->inst[1] |= 0x00100000;
+       if (src1->mod & NV50_MOD_ABS)
+               e->inst[1] |= 0x00080000;
+
        emit(pc, e);
 }
 
@@ -742,9 +1005,76 @@ static INLINE void
 emit_sub(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src0,
         struct nv50_reg *src1)
 {
-       src1->neg ^= 1;
+       src1->mod ^= NV50_MOD_NEG;
        emit_add(pc, dst, src0, src1);
-       src1->neg ^= 1;
+       src1->mod ^= NV50_MOD_NEG;
+}
+
+static void
+emit_bitop2(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src0,
+           struct nv50_reg *src1, unsigned op)
+{
+       struct nv50_program_exec *e = exec(pc);
+
+       e->inst[0] = 0xd0000000;
+       set_long(pc, e);
+
+       check_swap_src_0_1(pc, &src0, &src1);
+       set_dst(pc, dst, e);
+       set_src_0(pc, src0, e);
+
+       if (op != TGSI_OPCODE_AND && op != TGSI_OPCODE_OR &&
+           op != TGSI_OPCODE_XOR)
+               assert(!"invalid bit op");
+
+       assert(!(src0->mod | src1->mod));
+
+       if (src1->type == P_IMMD && src0->type == P_TEMP && pc->allow32) {
+               set_immd(pc, src1, e);
+               if (op == TGSI_OPCODE_OR)
+                       e->inst[0] |= 0x0100;
+               else
+               if (op == TGSI_OPCODE_XOR)
+                       e->inst[0] |= 0x8000;
+       } else {
+               set_src_1(pc, src1, e);
+               e->inst[1] |= 0x04000000; /* 32 bit */
+               if (op == TGSI_OPCODE_OR)
+                       e->inst[1] |= 0x4000;
+               else
+               if (op == TGSI_OPCODE_XOR)
+                       e->inst[1] |= 0x8000;
+       }
+
+       emit(pc, e);
+}
+
+static void
+emit_shift(struct nv50_pc *pc, struct nv50_reg *dst,
+          struct nv50_reg *src0, struct nv50_reg *src1, unsigned dir)
+{
+       struct nv50_program_exec *e = exec(pc);
+
+       e->inst[0] = 0x30000000;
+       e->inst[1] = 0xc4000000;
+
+       set_long(pc, e);
+       set_dst(pc, dst, e);
+       set_src_0(pc, src0, e);
+
+       if (src1->type == P_IMMD) {
+               e->inst[1] |= (1 << 20);
+               e->inst[0] |= (pc->immd_buf[src1->hw] & 0x7f) << 16;
+       } else
+               set_src_1(pc, src1, e);
+
+       if (dir != TGSI_OPCODE_SHL)
+               e->inst[1] |= (1 << 29);
+
+       if (dir == TGSI_OPCODE_ISHR)
+               e->inst[1] |= (1 << 27);
+
+       emit(pc, e);
 }
 
 static void
@@ -761,9 +1091,9 @@ 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)
+       if ((src0->mod ^ src1->mod) & NV50_MOD_NEG)
                e->inst[1] |= 0x04000000;
-       if (src2->neg)
+       if (src2->mod & NV50_MOD_NEG)
                e->inst[1] |= 0x08000000;
 
        emit(pc, e);
@@ -773,11 +1103,19 @@ 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)
 {
-       src2->neg ^= 1;
+       src2->mod ^= NV50_MOD_NEG;
        emit_mad(pc, dst, src0, src1, src2);
-       src2->neg ^= 1;
+       src2->mod ^= NV50_MOD_NEG;
 }
 
+#define NV50_FLOP_RCP 0
+#define NV50_FLOP_RSQ 2
+#define NV50_FLOP_LG2 3
+#define NV50_FLOP_SIN 4
+#define NV50_FLOP_COS 5
+#define NV50_FLOP_EX2 6
+
+/* rcp, rsqrt, lg2 support neg and abs */
 static void
 emit_flop(struct nv50_pc *pc, unsigned sub,
          struct nv50_reg *dst, struct nv50_reg *src)
@@ -785,17 +1123,20 @@ emit_flop(struct nv50_pc *pc, unsigned sub,
        struct nv50_program_exec *e = exec(pc);
 
        e->inst[0] |= 0x90000000;
-       if (sub) {
+       if (sub || src->mod) {
                set_long(pc, e);
                e->inst[1] |= (sub << 29);
        }
 
        set_dst(pc, dst, e);
+       set_src_0_restricted(pc, src, e);
 
-       if (sub == 0 || sub == 2)
-               set_src_0_restricted(pc, src, e);
-       else
-               set_src_0(pc, src, e);
+       assert(!src->mod || sub < 4);
+
+       if (src->mod & NV50_MOD_NEG)
+               e->inst[1] |= 0x04000000;
+       if (src->mod & NV50_MOD_ABS)
+               e->inst[1] |= 0x00100000;
 
        emit(pc, e);
 }
@@ -812,6 +1153,11 @@ emit_preex2(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src)
        set_long(pc, e);
        e->inst[1] |= (6 << 29) | 0x00004000;
 
+       if (src->mod & NV50_MOD_NEG)
+               e->inst[1] |= 0x04000000;
+       if (src->mod & NV50_MOD_ABS)
+               e->inst[1] |= 0x00100000;
+
        emit(pc, e);
 }
 
@@ -827,40 +1173,49 @@ emit_precossin(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src)
        set_long(pc, e);
        e->inst[1] |= (6 << 29);
 
+       if (src->mod & NV50_MOD_NEG)
+               e->inst[1] |= 0x04000000;
+       if (src->mod & NV50_MOD_ABS)
+               e->inst[1] |= 0x00100000;
+
        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
-
-/* 0x04 == 32 bit */
-/* 0x40 == dst is float */
-/* 0x80 == src is float */
-#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_NEG     0x20
-#define CVT_RI      0x08
+#define CVT_RN    (0x00 << 16)
+#define CVT_FLOOR (0x02 << 16)
+#define CVT_CEIL  (0x04 << 16)
+#define CVT_TRUNC (0x06 << 16)
+#define CVT_SAT   (0x08 << 16)
+#define CVT_ABS   (0x10 << 16)
+
+#define CVT_X32_X32 0x04004000
+#define CVT_X32_S32 0x04014000
+#define CVT_F32_F32 ((0xc0 << 24) | CVT_X32_X32)
+#define CVT_S32_F32 ((0x88 << 24) | CVT_X32_X32)
+#define CVT_U32_F32 ((0x80 << 24) | CVT_X32_X32)
+#define CVT_F32_S32 ((0x40 << 24) | CVT_X32_S32)
+#define CVT_F32_U32 ((0x40 << 24) | CVT_X32_X32)
+#define CVT_S32_S32 ((0x08 << 24) | CVT_X32_S32)
+#define CVT_S32_U32 ((0x08 << 24) | CVT_X32_X32)
+#define CVT_U32_S32 ((0x00 << 24) | CVT_X32_S32)
+
+#define CVT_NEG 0x20000000
+#define CVT_RI  0x08000000
 
 static void
 emit_cvt(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src,
-        int wp, unsigned cvn, unsigned fmt)
+        int wp, uint32_t cvn)
 {
        struct nv50_program_exec *e;
 
        e = exec(pc);
-       set_long(pc, e);
 
-       e->inst[0] |= 0xa0000000;
-       e->inst[1] |= 0x00004000;
-       e->inst[1] |= (cvn << 16);
-       e->inst[1] |= (fmt << 24);
+       if (src->mod & NV50_MOD_NEG) cvn |= CVT_NEG;
+       if (src->mod & NV50_MOD_ABS) cvn |= CVT_ABS;
+
+       e->inst[0] = 0xa0000000;
+       e->inst[1] = cvn;
+       set_long(pc, e);
        set_src_0(pc, src, e);
 
        if (wp >= 0)
@@ -885,10 +1240,12 @@ emit_cvt(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src,
  *  0x6 = GE
  *  0x7 = set condition code ? (used before bra.lt/le/gt/ge)
  *  0x8 = unordered bit (allows NaN)
+ *
+ *  mode = 0x04 (u32), 0x0c (s32), 0x80 (f32)
  */
 static void
 emit_set(struct nv50_pc *pc, unsigned ccode, struct nv50_reg *dst, int wp,
-        struct nv50_reg *src0, struct nv50_reg *src1)
+        struct nv50_reg *src0, struct nv50_reg *src1, uint8_t mode)
 {
        static const unsigned cc_swapped[8] = { 0, 4, 2, 6, 1, 5, 3, 7 };
 
@@ -903,16 +1260,10 @@ emit_set(struct nv50_pc *pc, unsigned ccode, struct nv50_reg *dst, int wp,
        if (dst && dst->type != P_TEMP)
                dst = alloc_temp(pc, NULL);
 
-       /* set.u32 */
        set_long(pc, e);
-       e->inst[0] |= 0xb0000000;
+       e->inst[0] |= 0x30000000 | (mode << 24);
        e->inst[1] |= 0x60000000 | (ccode << 14);
 
-       /* XXX: decuda will disasm as .u16 and use .lo/.hi regs, but
-        * that doesn't seem to match what the hw actually does
-       e->inst[1] |= 0x04000000; << breaks things, u32 by default ?
-        */
-
        if (wp >= 0)
                set_pred_wr(pc, 1, wp, e);
        if (dst)
@@ -926,35 +1277,108 @@ emit_set(struct nv50_pc *pc, unsigned ccode, struct nv50_reg *dst, int wp,
        set_src_1(pc, src1, e);
 
        emit(pc, e);
-       pc->if_cond = pc->p->exec_tail; /* record for OPCODE_IF */
 
-       /* cvt.f32.u32/s32 (?) if we didn't only write the predicate */
-       if (rdst)
-               emit_cvt(pc, rdst, dst, -1, CVTOP_ABS | CVTOP_RN, CVT_F32_S32);
+       if (rdst && mode == 0x80) /* convert to float ? */
+               emit_cvt(pc, rdst, dst, -1, CVT_ABS | CVT_F32_S32);
        if (rdst && rdst != dst)
                free_temp(pc, dst);
 }
 
-static INLINE unsigned
-map_tgsi_setop_cc(unsigned op)
+static INLINE void
+map_tgsi_setop_hw(unsigned op, uint8_t *cc, uint8_t *ty)
 {
        switch (op) {
-       case TGSI_OPCODE_SLT: return 0x1;
-       case TGSI_OPCODE_SGE: return 0x6;
-       case TGSI_OPCODE_SEQ: return 0x2;
-       case TGSI_OPCODE_SGT: return 0x4;
-       case TGSI_OPCODE_SLE: return 0x3;
-       case TGSI_OPCODE_SNE: return 0xd;
+       case TGSI_OPCODE_SLT: *cc = 0x1; *ty = 0x80; break;
+       case TGSI_OPCODE_SGE: *cc = 0x6; *ty = 0x80; break;
+       case TGSI_OPCODE_SEQ: *cc = 0x2; *ty = 0x80; break;
+       case TGSI_OPCODE_SGT: *cc = 0x4; *ty = 0x80; break;
+       case TGSI_OPCODE_SLE: *cc = 0x3; *ty = 0x80; break;
+       case TGSI_OPCODE_SNE: *cc = 0xd; *ty = 0x80; break;
+
+       case TGSI_OPCODE_ISLT: *cc = 0x1; *ty = 0x0c; break;
+       case TGSI_OPCODE_ISGE: *cc = 0x6; *ty = 0x0c; break;
+       case TGSI_OPCODE_USEQ: *cc = 0x2; *ty = 0x04; break;
+       case TGSI_OPCODE_USGE: *cc = 0x6; *ty = 0x04; break;
+       case TGSI_OPCODE_USLT: *cc = 0x1; *ty = 0x04; break;
+       case TGSI_OPCODE_USNE: *cc = 0x5; *ty = 0x04; break;
        default:
                assert(0);
-               return 0;
+               return;
        }
 }
 
+static void
+emit_add_b32(struct nv50_pc *pc, struct nv50_reg *dst,
+            struct nv50_reg *src0, struct nv50_reg *rsrc1)
+{
+       struct nv50_program_exec *e = exec(pc);
+       struct nv50_reg *src1;
+
+       e->inst[0] = 0x20000000;
+
+       alloc_reg(pc, rsrc1);
+       check_swap_src_0_1(pc, &src0, &rsrc1);
+
+       src1 = rsrc1;
+       if (src0->mod & rsrc1->mod & NV50_MOD_NEG) {
+               src1 = alloc_temp(pc, NULL);
+               emit_cvt(pc, src1, rsrc1, -1, CVT_S32_S32);
+       }
+
+       if (!pc->allow32 || src1->hw > 63 ||
+           (src1->type != P_TEMP && src1->type != P_IMMD))
+               set_long(pc, e);
+
+       set_dst(pc, dst, e);
+       set_src_0(pc, src0, e);
+
+       if (is_long(e)) {
+               e->inst[1] |= 1 << 26;
+               set_src_2(pc, src1, e);
+       } else {
+               e->inst[0] |= 0x8000;
+               if (src1->type == P_IMMD)
+                       set_immd(pc, src1, e);
+               else
+                       set_src_1(pc, src1, e);
+       }
+
+       if (src0->mod & NV50_MOD_NEG)
+               e->inst[0] |= 1 << 28;
+       else
+       if (src1->mod & NV50_MOD_NEG)
+               e->inst[0] |= 1 << 22;
+
+       emit(pc, e);
+
+       if (src1 != rsrc1)
+               free_temp(pc, src1);
+}
+
+static void
+emit_sad(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] = 0x50000000;
+       set_dst(pc, dst, e);
+       set_src_0(pc, src0, e);
+       set_src_1(pc, src1, e);
+       alloc_reg(pc, src2);
+       if (is_long(e) || (src2->type != dst->type) || (src2->hw != dst->hw))
+               set_src_2(pc, src2, e);
+
+       if (is_long(e))
+               e->inst[1] |= 0x0c << 24;
+       else
+               e->inst[0] |= 0x81 << 8;
+}
+
 static INLINE void
 emit_flr(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src)
 {
-       emit_cvt(pc, dst, src, -1, CVTOP_FLOOR, CVT_F32_F32 | CVT_RI);
+       emit_cvt(pc, dst, src, -1, CVT_FLOOR | CVT_F32_F32 | CVT_RI);
 }
 
 static void
@@ -963,24 +1387,18 @@ emit_pow(struct nv50_pc *pc, struct nv50_reg *dst,
 {
        struct nv50_reg *temp = alloc_temp(pc, NULL);
 
-       emit_flop(pc, 3, temp, v);
+       emit_flop(pc, NV50_FLOP_LG2, temp, v);
        emit_mul(pc, temp, temp, e);
        emit_preex2(pc, temp, temp);
-       emit_flop(pc, 6, dst, temp);
+       emit_flop(pc, NV50_FLOP_EX2, dst, temp);
 
        free_temp(pc, temp);
 }
 
-static INLINE void
-emit_abs(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src)
-{
-       emit_cvt(pc, dst, src, -1, CVTOP_ABS, CVT_F32_F32);
-}
-
 static INLINE void
 emit_sat(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src)
 {
-       emit_cvt(pc, dst, src, -1, CVTOP_SAT, CVT_F32_F32);
+       emit_cvt(pc, dst, src, -1, CVT_SAT | CVT_F32_F32);
 }
 
 static void
@@ -998,18 +1416,18 @@ emit_lit(struct nv50_pc *pc, struct nv50_reg **dst, unsigned mask,
 
        if (mask & (3 << 1)) {
                tmp[0] = alloc_temp(pc, NULL);
-               emit_minmax(pc, 4, tmp[0], src[0], zero);
+               emit_minmax(pc, NV50_MAX_F32, tmp[0], src[0], zero);
        }
 
        if (mask & (1 << 2)) {
                set_pred_wr(pc, 1, 0, pc->p->exec_tail);
 
                tmp[1] = temp_temp(pc);
-               emit_minmax(pc, 4, tmp[1], src[1], zero);
+               emit_minmax(pc, NV50_MAX_F32, tmp[1], src[1], zero);
 
                tmp[3] = temp_temp(pc);
-               emit_minmax(pc, 4, tmp[3], src[3], neg128);
-               emit_minmax(pc, 5, tmp[3], tmp[3], pos128);
+               emit_minmax(pc, NV50_MAX_F32, tmp[3], src[3], neg128);
+               emit_minmax(pc, NV50_MIN_F32, tmp[3], tmp[3], pos128);
 
                emit_pow(pc, dst[2], tmp[1], tmp[3]);
                emit_mov(pc, dst[2], zero);
@@ -1038,132 +1456,356 @@ emit_lit(struct nv50_pc *pc, struct nv50_reg **dst, unsigned mask,
 }
 
 static void
-emit_neg(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src)
+emit_kil(struct nv50_pc *pc, struct nv50_reg *src)
+{
+       struct nv50_program_exec *e;
+       const int r_pred = 1;
+
+       e = exec(pc);
+       e->inst[0] = 0x00000002; /* discard */
+       set_long(pc, e); /* sets cond code to ALWAYS */
+
+       if (src) {
+               set_pred(pc, 0x1 /* cc = LT */, r_pred, e);
+               /* write to predicate reg */
+               emit_cvt(pc, NULL, src, r_pred, CVT_F32_F32);
+       }
+
+       emit(pc, e);
+}
+
+static struct nv50_program_exec *
+emit_control_flow(struct nv50_pc *pc, unsigned op, int pred, unsigned cc)
 {
        struct nv50_program_exec *e = exec(pc);
 
+       e->inst[0] = (op << 28) | 2;
        set_long(pc, e);
-       e->inst[0] |= 0xa0000000; /* delta */
-       e->inst[1] |= (7 << 29); /* delta */
-       e->inst[1] |= 0x04000000; /* negate arg0? probably not */
-       e->inst[1] |= (1 << 14); /* src .f32 */
-       set_dst(pc, dst, e);
-       set_src_0(pc, src, e);
+       if (pred >= 0)
+               set_pred(pc, cc, pred, e);
 
        emit(pc, e);
+       return e;
+}
+
+static INLINE struct nv50_program_exec *
+emit_breakaddr(struct nv50_pc *pc)
+{
+       return emit_control_flow(pc, 0x4, -1, 0);
 }
 
+static INLINE void
+emit_break(struct nv50_pc *pc, int pred, unsigned cc)
+{
+       emit_control_flow(pc, 0x5, pred, cc);
+}
+
+static INLINE struct nv50_program_exec *
+emit_joinat(struct nv50_pc *pc)
+{
+       return emit_control_flow(pc, 0xa, -1, 0);
+}
+
+static INLINE struct nv50_program_exec *
+emit_branch(struct nv50_pc *pc, int pred, unsigned cc)
+{
+       return emit_control_flow(pc, 0x1, pred, cc);
+}
+
+static INLINE struct nv50_program_exec *
+emit_call(struct nv50_pc *pc, int pred, unsigned cc)
+{
+       return emit_control_flow(pc, 0x2, pred, cc);
+}
+
+static INLINE void
+emit_ret(struct nv50_pc *pc, int pred, unsigned cc)
+{
+       emit_control_flow(pc, 0x3, pred, cc);
+}
+
+#define QOP_ADD 0
+#define QOP_SUBR 1
+#define QOP_SUB 2
+#define QOP_MOV_SRC1 3
+
+/* For a quad of threads / top left, top right, bottom left, bottom right
+ * pixels, do a different operation, and take src0 from a specific thread.
+ */
 static void
-emit_kil(struct nv50_pc *pc, struct nv50_reg *src)
+emit_quadop(struct nv50_pc *pc, struct nv50_reg *dst, int wp, int lane_src0,
+           struct nv50_reg *src0, struct nv50_reg *src1, ubyte qop)
 {
-       struct nv50_program_exec *e;
-       const int r_pred = 1;
+       struct nv50_program_exec *e = exec(pc);
 
-       /* Sets predicate reg ? */
-       e = exec(pc);
-       e->inst[0] = 0xa00001fd;
-       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);
+       e->inst[0] = 0xc0000000;
+       e->inst[1] = 0x80000000;
+       set_long(pc, e);
+       e->inst[0] |= lane_src0 << 16;
+       set_src_0(pc, src0, e);
+       set_src_2(pc, src1, e);
 
-       /* This is probably KILP */
-       e = exec(pc);
-       e->inst[0] = 0x000001fe;
-       set_long(pc, e);
-       set_pred(pc, 1 /* LT? */, r_pred, e);
-       emit(pc, 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;
+       }
+
+       e->inst[0] |= (qop & 3) << 20;
+       e->inst[1] |= (qop >> 2) << 22;
+
+       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)
+load_cube_tex_coords(struct nv50_pc *pc, struct nv50_reg *t[4],
+                    struct nv50_reg **src, unsigned arg, boolean proj)
 {
-       struct nv50_reg *temp, *t[4];
-       struct nv50_program_exec *e;
+       int mod[3] = { src[0]->mod, src[1]->mod, src[2]->mod };
+
+       src[0]->mod |= NV50_MOD_ABS;
+       src[1]->mod |= NV50_MOD_ABS;
+       src[2]->mod |= NV50_MOD_ABS;
+
+       emit_minmax(pc, NV50_MAX_F32, t[2], src[0], src[1]);
+       emit_minmax(pc, NV50_MAX_F32, t[2], src[2], t[2]);
+
+       src[0]->mod = mod[0];
+       src[1]->mod = mod[1];
+       src[2]->mod = mod[2];
+
+       if (proj && 0 /* looks more correct without this */)
+               emit_mul(pc, t[2], t[2], src[3]);
+       else
+       if (arg == 4) /* there is no textureProj(samplerCubeShadow) */
+               emit_mov(pc, t[3], src[3]);
+
+       emit_flop(pc, NV50_FLOP_RCP, t[2], t[2]);
+
+       emit_mul(pc, t[0], src[0], t[2]);
+       emit_mul(pc, t[1], src[1], t[2]);
+       emit_mul(pc, t[2], src[2], t[2]);
+}
+
+static void
+load_proj_tex_coords(struct nv50_pc *pc, struct nv50_reg *t[4],
+                    struct nv50_reg **src, unsigned dim, unsigned arg)
+{
+       unsigned c, mode;
+
+       if (src[0]->type == P_TEMP && src[0]->rhw != -1) {
+               mode = pc->interp_mode[src[0]->index] | INTERP_PERSPECTIVE;
+
+               t[3]->rhw = src[3]->rhw;
+               emit_interp(pc, t[3], NULL, (mode & INTERP_CENTROID));
+               emit_flop(pc, NV50_FLOP_RCP, t[3], t[3]);
 
-       unsigned c, mode, dim;
+               for (c = 0; c < dim; ++c) {
+                       t[c]->rhw = src[c]->rhw;
+                       emit_interp(pc, t[c], t[3], mode);
+               }
+               if (arg != dim) { /* depth reference value */
+                       t[dim]->rhw = src[2]->rhw;
+                       emit_interp(pc, t[dim], t[3], mode);
+               }
+       } else {
+               /* XXX: for some reason the blob sometimes uses MAD
+                * (mad f32 $rX $rY $rZ neg $r63)
+                */
+               emit_flop(pc, NV50_FLOP_RCP, t[3], src[3]);
+               for (c = 0; c < dim; ++c)
+                       emit_mul(pc, t[c], src[c], t[3]);
+               if (arg != dim) /* depth reference value */
+                       emit_mul(pc, t[dim], src[2], t[3]);
+       }
+}
 
+static INLINE void
+get_tex_dim(unsigned type, unsigned *dim, unsigned *arg)
+{
        switch (type) {
        case TGSI_TEXTURE_1D:
-               dim = 1;
+               *arg = *dim = 1;
+               break;
+       case TGSI_TEXTURE_SHADOW1D:
+               *dim = 1;
+               *arg = 2;
                break;
        case TGSI_TEXTURE_UNKNOWN:
        case TGSI_TEXTURE_2D:
-       case TGSI_TEXTURE_SHADOW1D: /* XXX: x, z */
        case TGSI_TEXTURE_RECT:
-               dim = 2;
+               *arg = *dim = 2;
+               break;
+       case TGSI_TEXTURE_SHADOW2D:
+       case TGSI_TEXTURE_SHADOWRECT:
+               *dim = 2;
+               *arg = 3;
                break;
        case TGSI_TEXTURE_3D:
        case TGSI_TEXTURE_CUBE:
-       case TGSI_TEXTURE_SHADOW2D:
-       case TGSI_TEXTURE_SHADOWRECT: /* XXX */
-               dim = 3;
+               *dim = *arg = 3;
                break;
        default:
                assert(0);
                break;
        }
+}
 
-       /* some cards need t[0]'s hw index to be a multiple of 4 */
-       alloc_temp4(pc, t, 0);
+/* We shouldn't execute TEXLOD if any of the pixels in a quad have
+ * different LOD values, so branch off groups of equal LOD.
+ */
+static void
+emit_texlod_sequence(struct nv50_pc *pc, struct nv50_reg *tlod,
+                    struct nv50_reg *src, struct nv50_program_exec *tex)
+{
+       struct nv50_program_exec *join_at;
+       unsigned i, target = pc->p->exec_size + 9 * 2;
 
-       if (proj) {
-               if (src[0]->type == P_TEMP && src[0]->rhw != -1) {
-                       mode = pc->interp_mode[src[0]->index];
+       if (pc->p->type != PIPE_SHADER_FRAGMENT) {
+               emit(pc, tex);
+               return;
+       }
+       pc->allow32 = FALSE;
 
-                       t[3]->rhw = src[3]->rhw;
-                       emit_interp(pc, t[3], NULL, (mode & INTERP_CENTROID));
-                       emit_flop(pc, 0, t[3], t[3]);
+       /* Subtract lod of each pixel from lod of top left pixel, jump
+        * texlod insn if result is 0, then repeat for 2 other pixels.
+        */
+       join_at = emit_joinat(pc);
+       emit_quadop(pc, NULL, 0, 0, tlod, tlod, 0x55);
+       emit_branch(pc, 0, 2)->param.index = target;
 
-                       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]);
+       for (i = 1; i < 4; ++i) {
+               emit_quadop(pc, NULL, 0, i, tlod, tlod, 0x55);
+               emit_branch(pc, 0, 2)->param.index = target;
+       }
 
-                       /* 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]);
+       emit_mov(pc, tlod, src); /* target */
+       emit(pc, tex); /* texlod */
+
+       join_at->param.index = target + 2 * 2;
+       JOIN_ON(emit_nop(pc)); /* join _after_ tex */
+}
+
+static void
+emit_texbias_sequence(struct nv50_pc *pc, struct nv50_reg *t[4], unsigned arg,
+                     struct nv50_program_exec *tex)
+{
+       struct nv50_program_exec *e;
+       struct nv50_reg imm_1248, *t123[4][4], *r_bits = alloc_temp(pc, NULL);
+       int r_pred = 0;
+       unsigned n, c, i, cc[4] = { 0x0a, 0x13, 0x11, 0x10 };
+
+       pc->allow32 = FALSE;
+       ctor_reg(&imm_1248, P_IMMD, -1, ctor_immd_4u32(pc, 1, 2, 4, 8) * 4);
+
+       /* Subtract bias value of thread i from bias values of each thread,
+        * store result in r_pred, and set bit i in r_bits if result was 0.
+        */
+       assert(arg < 4);
+       for (i = 0; i < 4; ++i, ++imm_1248.hw) {
+               emit_quadop(pc, NULL, r_pred, i, t[arg], t[arg], 0x55);
+               emit_mov(pc, r_bits, &imm_1248);
+               set_pred(pc, 2, r_pred, pc->p->exec_tail);
+       }
+       emit_mov_to_pred(pc, r_pred, r_bits);
+
+       /* The lanes of a quad are now grouped by the bit in r_pred they have
+        * set. Put the input values for TEX into a new register set for each
+        * group and execute TEX only for a specific group.
+        * We cannot use the same register set for each group because we need
+        * the derivatives, which are implicitly calculated, to be correct.
+        */
+       for (i = 1; i < 4; ++i) {
+               alloc_temp4(pc, t123[i], 0);
+
+               for (c = 0; c <= arg; ++c)
+                       emit_mov(pc, t123[i][c], t[c]);
+
+               *(e = exec(pc)) = *(tex);
+               e->inst[0] &= ~0x01fc;
+               set_dst(pc, t123[i][0], e);
+               set_pred(pc, cc[i], r_pred, e);
+               emit(pc, e);
+       }
+       /* finally TEX on the original regs (where we kept the input) */
+       set_pred(pc, cc[0], r_pred, tex);
+       emit(pc, tex);
+
+       /* put the 3 * n other results into regs for lane 0 */
+       n = popcnt4(((e->inst[0] >> 25) & 0x3) | ((e->inst[1] >> 12) & 0xc));
+       for (i = 1; i < 4; ++i) {
+               for (c = 0; c < n; ++c) {
+                       emit_mov(pc, t[c], t123[i][c]);
+                       set_pred(pc, cc[i], r_pred, pc->p->exec_tail);
                }
+               free_temp4(pc, t123[i]);
        }
 
+       emit_nop(pc);
+       free_temp(pc, r_bits);
+}
+
+static void
+emit_tex(struct nv50_pc *pc, struct nv50_reg **dst, unsigned mask,
+        struct nv50_reg **src, unsigned unit, unsigned type,
+        boolean proj, int bias_lod)
+{
+       struct nv50_reg *t[4];
+       struct nv50_program_exec *e;
+       unsigned c, dim, arg;
+
+       /* t[i] must be within a single 128 bit super-reg */
+       alloc_temp4(pc, t, 0);
+
        e = exec(pc);
+       e->inst[0] = 0xf0000000;
        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;
+       /* TIC and TSC binding indices (TSC is ignored as TSC_LINKED = TRUE): */
+       e->inst[0] |= (unit << 9) /* | (unit << 17) */;
+
+       /* live flag (don't set if TEX results affect input to another TEX): */
+       /* e->inst[0] |= 0x00000004; */
+
+       get_tex_dim(type, &dim, &arg);
+
+       if (type == TGSI_TEXTURE_CUBE) {
+               e->inst[0] |= 0x08000000;
+               load_cube_tex_coords(pc, t, src, arg, proj);
+       } else
+       if (proj)
+               load_proj_tex_coords(pc, t, src, dim, arg);
+       else {
+               for (c = 0; c < dim; c++)
+                       emit_mov(pc, t[c], src[c]);
+               if (arg != dim) /* depth reference value (always src.z here) */
+                       emit_mov(pc, t[dim], src[2]);
+       }
 
        e->inst[0] |= (mask & 0x3) << 25;
        e->inst[1] |= (mask & 0xc) << 12;
 
-       emit(pc, e);
+       if (!bias_lod) {
+               e->inst[0] |= (arg - 1) << 22;
+               emit(pc, e);
+       } else
+       if (bias_lod < 0) {
+               assert(pc->p->type == PIPE_SHADER_FRAGMENT);
+               e->inst[0] |= arg << 22;
+               e->inst[1] |= 0x20000000; /* texbias */
+               emit_mov(pc, t[arg], src[3]);
+               emit_texbias_sequence(pc, t, arg, e);
+       } else {
+               e->inst[0] |= arg << 22;
+               e->inst[1] |= 0x40000000; /* texlod */
+               emit_mov(pc, t[arg], src[3]);
+               emit_texlod_sequence(pc, t[arg], src[3], e);
+       }
 
 #if 1
        c = 0;
@@ -1187,34 +1829,36 @@ emit_tex(struct nv50_pc *pc, struct nv50_reg **dst, unsigned mask,
 }
 
 static void
-emit_branch(struct nv50_pc *pc, int pred, unsigned cc,
-           struct nv50_program_exec **join)
+emit_ddx(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src)
 {
        struct nv50_program_exec *e = exec(pc);
 
-       if (join) {
-               set_long(pc, e);
-               e->inst[0] |= 0xa0000002;
-               emit(pc, e);
-               *join = e;
-               e = exec(pc);
-       }
+       assert(src->type == P_TEMP);
 
+       e->inst[0] = (src->mod & NV50_MOD_NEG) ? 0xc0240000 : 0xc0140000;
+       e->inst[1] = (src->mod & NV50_MOD_NEG) ? 0x86400000 : 0x89800000;
        set_long(pc, e);
-       e->inst[0] |= 0x10000002;
-       if (pred >= 0)
-               set_pred(pc, cc, pred, e);
+       set_dst(pc, dst, e);
+       set_src_0(pc, src, e);
+       set_src_2(pc, src, e);
+
        emit(pc, e);
 }
 
 static void
-emit_nop(struct nv50_pc *pc)
+emit_ddy(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src)
 {
        struct nv50_program_exec *e = exec(pc);
 
-       e->inst[0] = 0xf0000000;
+       assert(src->type == P_TEMP);
+
+       e->inst[0] = (src->mod & NV50_MOD_NEG) ? 0xc0250000 : 0xc0150000;
+       e->inst[1] = (src->mod & NV50_MOD_NEG) ? 0x85800000 : 0x8a400000;
        set_long(pc, e);
-       e->inst[1] = 0xe0000000;
+       set_dst(pc, dst, e);
+       set_src_0(pc, src, e);
+       set_src_2(pc, src, e);
+
        emit(pc, e);
 }
 
@@ -1231,6 +1875,17 @@ convert_to_long(struct nv50_pc *pc, struct nv50_program_exec *e)
                q = 0x0403c000;
                m = 0xffff7fff;
                break;
+       case 0x2:
+       case 0x3:
+               /* ADD, SUB, SUBR b32 */
+               m = ~(0x8000 | (127 << 16));
+               q = ((e->inst[0] & (~m)) >> 2) | (1 << 26);
+               break;
+       case 0x5:
+               /* SAD */
+               m = ~(0x81 << 8);
+               q = 0x0c << 24;
+               break;
        case 0x8:
                /* INTERP (move centroid, perspective and flat bits) */
                m = ~0x03000100;
@@ -1266,22 +1921,55 @@ convert_to_long(struct nv50_pc *pc, struct nv50_program_exec *e)
        e->inst[1] |= q;
 }
 
-static boolean
-negate_supported(const struct tgsi_full_instruction *insn, int i)
+/* Some operations support an optional negation flag. */
+static int
+get_supported_mods(const struct tgsi_full_instruction *insn, int i)
 {
        switch (insn->Instruction.Opcode) {
+       case TGSI_OPCODE_ADD:
+       case TGSI_OPCODE_COS:
+       case TGSI_OPCODE_DDX:
+       case TGSI_OPCODE_DDY:
        case TGSI_OPCODE_DP3:
        case TGSI_OPCODE_DP4:
-       case TGSI_OPCODE_MUL:
+       case TGSI_OPCODE_EX2:
        case TGSI_OPCODE_KIL:
-       case TGSI_OPCODE_ADD:
-       case TGSI_OPCODE_SUB:
+       case TGSI_OPCODE_LG2:
        case TGSI_OPCODE_MAD:
-               return TRUE;
+       case TGSI_OPCODE_MUL:
        case TGSI_OPCODE_POW:
-               return (i == 1) ? TRUE : FALSE;
+       case TGSI_OPCODE_RCP:
+       case TGSI_OPCODE_RSQ: /* ignored, RSQ = rsqrt(abs(src.x)) */
+       case TGSI_OPCODE_SCS:
+       case TGSI_OPCODE_SIN:
+       case TGSI_OPCODE_SUB:
+               return NV50_MOD_NEG;
+       case TGSI_OPCODE_MAX:
+       case TGSI_OPCODE_MIN:
+       case TGSI_OPCODE_INEG: /* tgsi src sign toggle/set would be stupid */
+               return NV50_MOD_ABS;
+       case TGSI_OPCODE_CEIL:
+       case TGSI_OPCODE_FLR:
+       case TGSI_OPCODE_TRUNC:
+               return NV50_MOD_NEG | NV50_MOD_ABS;
+       case TGSI_OPCODE_F2I:
+       case TGSI_OPCODE_F2U:
+       case TGSI_OPCODE_I2F:
+       case TGSI_OPCODE_U2F:
+               return NV50_MOD_NEG | NV50_MOD_ABS | NV50_MOD_I32;
+       case TGSI_OPCODE_UADD:
+               return NV50_MOD_NEG | NV50_MOD_I32;
+       case TGSI_OPCODE_SAD:
+       case TGSI_OPCODE_SHL:
+       case TGSI_OPCODE_IMAX:
+       case TGSI_OPCODE_IMIN:
+       case TGSI_OPCODE_ISHR:
+       case TGSI_OPCODE_UMAX:
+       case TGSI_OPCODE_UMIN:
+       case TGSI_OPCODE_USHR:
+               return NV50_MOD_I32;
        default:
-               return FALSE;
+               return 0;
        }
 }
 
@@ -1289,7 +1977,7 @@ negate_supported(const struct tgsi_full_instruction *insn, int i)
 static unsigned
 nv50_tgsi_src_mask(const struct tgsi_full_instruction *insn, int c)
 {
-       unsigned x, mask = insn->FullDstRegisters[0].DstRegister.WriteMask;
+       unsigned x, mask = insn->Dst[0].Register.WriteMask;
 
        switch (insn->Instruction.Opcode) {
        case TGSI_OPCODE_COS:
@@ -1304,30 +1992,40 @@ nv50_tgsi_src_mask(const struct tgsi_full_instruction *insn, int c)
        case TGSI_OPCODE_DST:
                return mask & (c ? 0xa : 0x6);
        case TGSI_OPCODE_EX2:
+       case TGSI_OPCODE_EXP:
        case TGSI_OPCODE_LG2:
+       case TGSI_OPCODE_LOG:
        case TGSI_OPCODE_POW:
        case TGSI_OPCODE_RCP:
        case TGSI_OPCODE_RSQ:
        case TGSI_OPCODE_SCS:
                return 0x1;
+       case TGSI_OPCODE_IF:
+               return 0x1;
        case TGSI_OPCODE_LIT:
                return 0xb;
        case TGSI_OPCODE_TEX:
+       case TGSI_OPCODE_TXB:
+       case TGSI_OPCODE_TXL:
        case TGSI_OPCODE_TXP:
        {
-               const struct tgsi_instruction_ext_texture *tex;
+               const struct tgsi_instruction_texture *tex;
 
-               assert(insn->Instruction.Extended);
-               tex = &insn->InstructionExtTexture;
+               assert(insn->Instruction.Texture);
+               tex = &insn->Texture;
 
                mask = 0x7;
-               if (insn->Instruction.Opcode == TGSI_OPCODE_TXP)
-                       mask |= 0x8;
+               if (insn->Instruction.Opcode != TGSI_OPCODE_TEX &&
+                   insn->Instruction.Opcode != TGSI_OPCODE_TXD)
+                       mask |= 0x8; /* bias, lod or proj */
 
                switch (tex->Texture) {
                case TGSI_TEXTURE_1D:
                        mask &= 0x9;
                        break;
+               case TGSI_TEXTURE_SHADOW1D:
+                       mask &= 0x5;
+                       break;
                case TGSI_TEXTURE_2D:
                        mask &= 0xb;
                        break;
@@ -1352,11 +2050,21 @@ nv50_tgsi_src_mask(const struct tgsi_full_instruction *insn, int c)
 static struct nv50_reg *
 tgsi_dst(struct nv50_pc *pc, int c, const struct tgsi_full_dst_register *dst)
 {
-       switch (dst->DstRegister.File) {
+       switch (dst->Register.File) {
        case TGSI_FILE_TEMPORARY:
-               return &pc->temp[dst->DstRegister.Index * 4 + c];
+               return &pc->temp[dst->Register.Index * 4 + c];
        case TGSI_FILE_OUTPUT:
-               return &pc->result[dst->DstRegister.Index * 4 + c];
+               return &pc->result[dst->Register.Index * 4 + c];
+       case TGSI_FILE_ADDRESS:
+       {
+               struct nv50_reg *r = pc->addr[dst->Register.Index * 4 + c];
+               if (!r) {
+                       r = alloc_addr(pc, NULL);
+                       pc->addr[dst->Register.Index * 4 + c] = r;
+               }
+               assert(r);
+               return r;
+       }
        case TGSI_FILE_NULL:
                return NULL;
        default:
@@ -1368,83 +2076,93 @@ 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,
-        boolean neg)
+        int mod)
 {
        struct nv50_reg *r = NULL;
-       struct nv50_reg *temp;
-       unsigned sgn, c;
+       struct nv50_reg *temp = NULL;
+       unsigned sgn, c, swz, cvn;
+
+       if (src->Register.File != TGSI_FILE_CONSTANT)
+               assert(!src->Register.Indirect);
 
        sgn = tgsi_util_get_full_src_register_sign_mode(src, chan);
 
-       c = tgsi_util_get_full_src_register_extswizzle(src, chan);
+       c = tgsi_util_get_full_src_register_swizzle(src, chan);
        switch (c) {
-       case TGSI_EXTSWIZZLE_X:
-       case TGSI_EXTSWIZZLE_Y:
-       case TGSI_EXTSWIZZLE_Z:
-       case TGSI_EXTSWIZZLE_W:
-               switch (src->SrcRegister.File) {
+       case TGSI_SWIZZLE_X:
+       case TGSI_SWIZZLE_Y:
+       case TGSI_SWIZZLE_Z:
+       case TGSI_SWIZZLE_W:
+               switch (src->Register.File) {
                case TGSI_FILE_INPUT:
-                       r = &pc->attr[src->SrcRegister.Index * 4 + c];
+                       r = &pc->attr[src->Register.Index * 4 + c];
                        break;
                case TGSI_FILE_TEMPORARY:
-                       r = &pc->temp[src->SrcRegister.Index * 4 + c];
+                       r = &pc->temp[src->Register.Index * 4 + c];
                        break;
                case TGSI_FILE_CONSTANT:
-                       r = &pc->param[src->SrcRegister.Index * 4 + c];
+                       if (!src->Register.Indirect) {
+                               r = &pc->param[src->Register.Index * 4 + c];
+                               break;
+                       }
+                       /* Indicate indirection by setting r->acc < 0 and
+                        * use the index field to select the address reg.
+                        */
+                       r = reg_instance(pc, NULL);
+                       swz = tgsi_util_get_src_register_swizzle(
+                                                &src->Indirect, 0);
+                       ctor_reg(r, P_CONST,
+                                src->Indirect.Index * 4 + swz,
+                                src->Register.Index * 4 + c);
+                       r->acc = -1;
                        break;
                case TGSI_FILE_IMMEDIATE:
-                       r = &pc->immd[src->SrcRegister.Index * 4 + c];
+                       r = &pc->immd[src->Register.Index * 4 + c];
                        break;
                case TGSI_FILE_SAMPLER:
+                       return NULL;
+               case TGSI_FILE_ADDRESS:
+                       r = pc->addr[src->Register.Index * 4 + c];
+                       assert(r);
                        break;
                default:
                        assert(0);
                        break;
                }
                break;
-       case TGSI_EXTSWIZZLE_ZERO:
-               r = alloc_immd(pc, 0.0);
-               return r;
-       case TGSI_EXTSWIZZLE_ONE:
-               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;
        }
 
+       cvn = (mod & NV50_MOD_I32) ? CVT_S32_S32 : CVT_F32_F32;
+
        switch (sgn) {
-       case TGSI_UTIL_SIGN_KEEP:
-               break;
        case TGSI_UTIL_SIGN_CLEAR:
-               temp = temp_temp(pc);
-               emit_abs(pc, temp, r);
-               r = temp;
-               break;
-       case TGSI_UTIL_SIGN_TOGGLE:
-               if (neg)
-                       r->neg = 1;
-               else {
-                       temp = temp_temp(pc);
-                       emit_neg(pc, temp, r);
-                       r = temp;
-               }
+               r->mod = NV50_MOD_ABS;
                break;
        case TGSI_UTIL_SIGN_SET:
-               temp = temp_temp(pc);
-               emit_abs(pc, temp, r);
-               if (neg)
-                       temp->neg = 1;
-               else
-                       emit_neg(pc, temp, temp);
-               r = temp;
+               r->mod = NV50_MOD_NEG_ABS;
+               break;
+       case TGSI_UTIL_SIGN_TOGGLE:
+               r->mod = NV50_MOD_NEG;
                break;
        default:
-               assert(0);
+               assert(!r->mod && sgn == TGSI_UTIL_SIGN_KEEP);
                break;
        }
 
+       if ((r->mod & mod) != r->mod) {
+               temp = temp_temp(pc);
+               emit_cvt(pc, temp, r, -1, cvn);
+               r->mod = 0;
+               r = temp;
+       } else
+               r->mod |= mod & NV50_MOD_I32;
+
+       assert(r);
+       if (r->acc >= 0 && r != temp)
+               return reg_instance(pc, r); /* will clear r->mod */
        return r;
 }
 
@@ -1497,9 +2215,13 @@ nv50_tgsi_dst_revdep(unsigned op, int s, int c)
                        assert(0);
                        return 0x0;
                }
+       case TGSI_OPCODE_EXP:
+       case TGSI_OPCODE_LOG:
        case TGSI_OPCODE_LIT:
        case TGSI_OPCODE_SCS:
        case TGSI_OPCODE_TEX:
+       case TGSI_OPCODE_TXB:
+       case TGSI_OPCODE_TXL:
        case TGSI_OPCODE_TXP:
                /* these take care of dangerous swizzles themselves */
                return 0x0;
@@ -1535,34 +2257,51 @@ nv50_kill_branch(struct nv50_pc *pc)
 
        if (pc->if_insn[lvl]->next != pc->p->exec_tail)
                return FALSE;
+       if (is_immd(pc->p->exec_tail))
+               return FALSE;
 
        /* if ccode == 'true', the BRA is from an ELSE and the predicate
         * reg may no longer be valid, since we currently always use $p0
         */
        if (has_pred(pc->if_insn[lvl], 0xf))
                return FALSE;
-       assert(pc->if_insn[lvl] && pc->br_join[lvl]);
+       assert(pc->if_insn[lvl] && pc->if_join[lvl]);
 
-       /* We'll use the exec allocated for JOIN_AT (as we can't easily
-        * update prev's next); if exec_tail is BRK, update the pointer.
+       /* We'll use the exec allocated for JOIN_AT (we can't easily
+        * access nv50_program_exec's prev).
         */
-       if (pc->loop_lvl && pc->br_loop[pc->loop_lvl - 1] == pc->p->exec_tail)
-               pc->br_loop[pc->loop_lvl - 1] = pc->br_join[lvl];
-
        pc->p->exec_size -= 4; /* remove JOIN_AT and BRA */
 
-       *pc->br_join[lvl] = *pc->p->exec_tail;
+       *pc->if_join[lvl] = *pc->p->exec_tail;
 
        FREE(pc->if_insn[lvl]);
        FREE(pc->p->exec_tail);
 
-       pc->p->exec_tail = pc->br_join[lvl];
+       pc->p->exec_tail = pc->if_join[lvl];
        pc->p->exec_tail->next = NULL;
        set_pred(pc, 0xd, 0, pc->p->exec_tail);
 
        return TRUE;
 }
 
+static void
+nv50_fp_move_results(struct nv50_pc *pc)
+{
+       struct nv50_reg reg;
+       unsigned i;
+
+       ctor_reg(&reg, P_TEMP, -1, -1);
+
+       for (i = 0; i < pc->result_nr * 4; ++i) {
+               if (pc->result[i].rhw < 0 || pc->result[i].hw < 0)
+                       continue;
+               if (pc->result[i].rhw != pc->result[i].hw) {
+                       reg.hw = pc->result[i].rhw;
+                       emit_mov(pc, &reg, &pc->result[i]);
+               }
+       }
+}
+
 static boolean
 nv50_program_tx_insn(struct nv50_pc *pc,
                     const struct tgsi_full_instruction *inst)
@@ -1571,33 +2310,33 @@ nv50_program_tx_insn(struct nv50_pc *pc,
        unsigned mask, sat, unit;
        int i, c;
 
-       mask = inst->FullDstRegisters[0].DstRegister.WriteMask;
+       mask = inst->Dst[0].Register.WriteMask;
        sat = inst->Instruction.Saturate == TGSI_SAT_ZERO_ONE;
 
        memset(src, 0, sizeof(src));
 
        for (c = 0; c < 4; c++) {
                if ((mask & (1 << c)) && !pc->r_dst[c])
-                       dst[c] = tgsi_dst(pc, c, &inst->FullDstRegisters[0]);
+                       dst[c] = tgsi_dst(pc, c, &inst->Dst[0]);
                else
                        dst[c] = pc->r_dst[c];
                rdst[c] = dst[c];
        }
 
        for (i = 0; i < inst->Instruction.NumSrcRegs; i++) {
-               const struct tgsi_full_src_register *fs = &inst->FullSrcRegisters[i];
+               const struct tgsi_full_src_register *fs = &inst->Src[i];
                unsigned src_mask;
-               boolean neg_supp;
+               int mod_supp;
 
                src_mask = nv50_tgsi_src_mask(inst, i);
-               neg_supp = negate_supported(inst, i);
+               mod_supp = get_supported_mods(inst, i);
 
-               if (fs->SrcRegister.File == TGSI_FILE_SAMPLER)
-                       unit = fs->SrcRegister.Index;
+               if (fs->Register.File == TGSI_FILE_SAMPLER)
+                       unit = fs->Register.Index;
 
                for (c = 0; c < 4; c++)
                        if (src_mask & (1 << c))
-                               src[i][c] = tgsi_src(pc, c, fs, neg_supp);
+                               src[i][c] = tgsi_src(pc, c, fs, mod_supp);
        }
 
        brdc = temp = pc->r_brdc;
@@ -1610,7 +2349,7 @@ nv50_program_tx_insn(struct nv50_pc *pc,
                for (c = 0; c < 4; c++) {
                        if (!(mask & (1 << c)) || dst[c]->type == P_TEMP)
                                continue;
-                       rdst[c] = dst[c];
+                       /* rdst[c] = dst[c]; */ /* done above */
                        dst[c] = temp_temp(pc);
                }
        }
@@ -1622,7 +2361,8 @@ nv50_program_tx_insn(struct nv50_pc *pc,
                for (c = 0; c < 4; c++) {
                        if (!(mask & (1 << c)))
                                continue;
-                       emit_abs(pc, dst[c], src[0][c]);
+                       emit_cvt(pc, dst[c], src[0][c], -1,
+                                CVT_ABS | CVT_F32_F32);
                }
                break;
        case TGSI_OPCODE_ADD:
@@ -1632,33 +2372,93 @@ nv50_program_tx_insn(struct nv50_pc *pc,
                        emit_add(pc, dst[c], src[0][c], src[1][c]);
                }
                break;
+       case TGSI_OPCODE_AND:
+       case TGSI_OPCODE_XOR:
+       case TGSI_OPCODE_OR:
+               for (c = 0; c < 4; c++) {
+                       if (!(mask & (1 << c)))
+                               continue;
+                       emit_bitop2(pc, dst[c], src[0][c], src[1][c],
+                                   inst->Instruction.Opcode);
+               }
+               break;
+       case TGSI_OPCODE_ARL:
+               assert(src[0][0]);
+               temp = temp_temp(pc);
+               emit_cvt(pc, temp, src[0][0], -1, CVT_FLOOR | CVT_S32_F32);
+               emit_arl(pc, dst[0], temp, 4);
+               break;
        case TGSI_OPCODE_BGNLOOP:
+               pc->loop_brka[pc->loop_lvl] = emit_breakaddr(pc);
                pc->loop_pos[pc->loop_lvl++] = pc->p->exec_size;
+               terminate_mbb(pc);
+               break;
+       case TGSI_OPCODE_BGNSUB:
+               assert(!pc->in_subroutine);
+               pc->in_subroutine = TRUE;
+               /* probably not necessary, but align to 8 byte boundary */
+               if (!is_long(pc->p->exec_tail))
+                       convert_to_long(pc, pc->p->exec_tail);
                break;
        case TGSI_OPCODE_BRK:
-               emit_branch(pc, -1, 0, NULL);
                assert(pc->loop_lvl > 0);
-               pc->br_loop[pc->loop_lvl - 1] = pc->p->exec_tail;
+               emit_break(pc, -1, 0);
+               break;
+       case TGSI_OPCODE_CAL:
+               assert(inst->Label.Label < pc->insn_nr);
+               emit_call(pc, -1, 0)->param.index = inst->Label.Label;
+               /* replaced by actual offset in nv50_program_fixup_insns */
                break;
        case TGSI_OPCODE_CEIL:
                for (c = 0; c < 4; c++) {
                        if (!(mask & (1 << c)))
                                continue;
                        emit_cvt(pc, dst[c], src[0][c], -1,
-                                CVTOP_CEIL, CVT_F32_F32 | CVT_RI);
+                                CVT_CEIL | CVT_F32_F32 | CVT_RI);
+               }
+               break;
+       case TGSI_OPCODE_CMP:
+               pc->allow32 = FALSE;
+               for (c = 0; c < 4; c++) {
+                       if (!(mask & (1 << c)))
+                               continue;
+                       emit_cvt(pc, NULL, src[0][c], 1, CVT_F32_F32);
+                       emit_mov(pc, dst[c], src[1][c]);
+                       set_pred(pc, 0x1, 1, pc->p->exec_tail); /* @SF */
+                       emit_mov(pc, dst[c], src[2][c]);
+                       set_pred(pc, 0x6, 1, pc->p->exec_tail); /* @NSF */
                }
                break;
+       case TGSI_OPCODE_CONT:
+               assert(pc->loop_lvl > 0);
+               emit_branch(pc, -1, 0)->param.index =
+                       pc->loop_pos[pc->loop_lvl - 1];
+               break;
        case TGSI_OPCODE_COS:
                if (mask & 8) {
                        emit_precossin(pc, temp, src[0][3]);
-                       emit_flop(pc, 5, dst[3], temp);
+                       emit_flop(pc, NV50_FLOP_COS, dst[3], temp);
                        if (!(mask &= 7))
                                break;
                        if (temp == dst[3])
                                temp = brdc = temp_temp(pc);
                }
                emit_precossin(pc, temp, src[0][0]);
-               emit_flop(pc, 5, brdc, temp);
+               emit_flop(pc, NV50_FLOP_COS, brdc, temp);
+               break;
+       case TGSI_OPCODE_DDX:
+               for (c = 0; c < 4; c++) {
+                       if (!(mask & (1 << c)))
+                               continue;
+                       emit_ddx(pc, dst[c], src[0][c]);
+               }
+               break;
+       case TGSI_OPCODE_DDY:
+               for (c = 0; c < 4; c++) {
+                       if (!(mask & (1 << c)))
+                               continue;
+                       emit_ddy(pc, dst[c], src[0][c]);
+               }
                break;
        case TGSI_OPCODE_DP3:
                emit_mul(pc, temp, src[0][0], src[1][0]);
@@ -1688,9 +2488,10 @@ nv50_program_tx_insn(struct nv50_pc *pc,
                        emit_mov_immdval(pc, dst[0], 1.0f);
                break;
        case TGSI_OPCODE_ELSE:
-               emit_branch(pc, -1, 0, NULL);
+               emit_branch(pc, -1, 0);
                pc->if_insn[--pc->if_lvl]->param.index = pc->p->exec_size;
                pc->if_insn[pc->if_lvl++] = pc->p->exec_tail;
+               terminate_mbb(pc);
                break;
        case TGSI_OPCODE_ENDIF:
                pc->if_insn[--pc->if_lvl]->param.index = pc->p->exec_size;
@@ -1699,24 +2500,72 @@ nv50_program_tx_insn(struct nv50_pc *pc,
                if (nv50_kill_branch(pc) == TRUE)
                        break;
 
-               if (pc->br_join[pc->if_lvl]) {
-                       pc->br_join[pc->if_lvl]->param.index = pc->p->exec_size;
-                       pc->br_join[pc->if_lvl] = NULL;
+               if (pc->if_join[pc->if_lvl]) {
+                       pc->if_join[pc->if_lvl]->param.index = pc->p->exec_size;
+                       pc->if_join[pc->if_lvl] = NULL;
                }
+               terminate_mbb(pc);
                /* emit a NOP as join point, we could set it on the next
                 * one, but would have to make sure it is long and !immd
                 */
-               emit_nop(pc);
-               pc->p->exec_tail->inst[1] |= 2;
+               JOIN_ON(emit_nop(pc));
                break;
        case TGSI_OPCODE_ENDLOOP:
-               emit_branch(pc, -1, 0, NULL);
-               pc->p->exec_tail->param.index = pc->loop_pos[--pc->loop_lvl];
-               pc->br_loop[pc->loop_lvl]->param.index = pc->p->exec_size;
+               emit_branch(pc, -1, 0)->param.index =
+                       pc->loop_pos[--pc->loop_lvl];
+               pc->loop_brka[pc->loop_lvl]->param.index = pc->p->exec_size;
+               terminate_mbb(pc);
+               break;
+       case TGSI_OPCODE_ENDSUB:
+               assert(pc->in_subroutine);
+               pc->in_subroutine = FALSE;
                break;
        case TGSI_OPCODE_EX2:
                emit_preex2(pc, temp, src[0][0]);
-               emit_flop(pc, 6, brdc, temp);
+               emit_flop(pc, NV50_FLOP_EX2, brdc, temp);
+               break;
+       case TGSI_OPCODE_EXP:
+       {
+               struct nv50_reg *t[2];
+
+               assert(!temp);
+               t[0] = temp_temp(pc);
+               t[1] = temp_temp(pc);
+
+               if (mask & 0x6)
+                       emit_mov(pc, t[0], src[0][0]);
+               if (mask & 0x3)
+                       emit_flr(pc, t[1], src[0][0]);
+
+               if (mask & (1 << 1))
+                       emit_sub(pc, dst[1], t[0], t[1]);
+               if (mask & (1 << 0)) {
+                       emit_preex2(pc, t[1], t[1]);
+                       emit_flop(pc, NV50_FLOP_EX2, dst[0], t[1]);
+               }
+               if (mask & (1 << 2)) {
+                       emit_preex2(pc, t[0], t[0]);
+                       emit_flop(pc, NV50_FLOP_EX2, dst[2], t[0]);
+               }
+               if (mask & (1 << 3))
+                       emit_mov_immdval(pc, dst[3], 1.0f);
+       }
+               break;
+       case TGSI_OPCODE_F2I:
+               for (c = 0; c < 4; c++) {
+                       if (!(mask & (1 << c)))
+                               continue;
+                       emit_cvt(pc, dst[c], src[0][c], -1,
+                                CVT_TRUNC | CVT_S32_F32);
+               }
+               break;
+       case TGSI_OPCODE_F2U:
+               for (c = 0; c < 4; c++) {
+                       if (!(mask & (1 << c)))
+                               continue;
+                       emit_cvt(pc, dst[c], src[0][c], -1,
+                                CVT_TRUNC | CVT_U32_F32);
+               }
                break;
        case TGSI_OPCODE_FLR:
                for (c = 0; c < 4; c++) {
@@ -1734,24 +2583,85 @@ nv50_program_tx_insn(struct nv50_pc *pc,
                        emit_sub(pc, dst[c], src[0][c], temp);
                }
                break;
+       case TGSI_OPCODE_I2F:
+               for (c = 0; c < 4; c++) {
+                       if (!(mask & (1 << c)))
+                               continue;
+                       emit_cvt(pc, dst[c], src[0][c], -1, CVT_F32_S32);
+               }
+               break;
        case TGSI_OPCODE_IF:
-               /* emitting a join_at may not be necessary */
-               assert(pc->if_lvl < MAX_IF_DEPTH);
-               set_pred_wr(pc, 1, 0, pc->if_cond);
-               emit_branch(pc, 0, 2, &pc->br_join[pc->if_lvl]);
-               pc->if_insn[pc->if_lvl++] = pc->p->exec_tail;
+               assert(pc->if_lvl < NV50_MAX_COND_NESTING);
+               emit_cvt(pc, NULL, src[0][0], 0, CVT_ABS | CVT_F32_F32);
+               pc->if_join[pc->if_lvl] = emit_joinat(pc);
+               pc->if_insn[pc->if_lvl++] = emit_branch(pc, 0, 2);;
+               terminate_mbb(pc);
+               break;
+       case TGSI_OPCODE_IMAX:
+               for (c = 0; c < 4; c++) {
+                       if (!(mask & (1 << c)))
+                               continue;
+                       emit_minmax(pc, 0x08c, dst[c], src[0][c], src[1][c]);
+               }
+               break;
+       case TGSI_OPCODE_IMIN:
+               for (c = 0; c < 4; c++) {
+                       if (!(mask & (1 << c)))
+                               continue;
+                       emit_minmax(pc, 0x0ac, dst[c], src[0][c], src[1][c]);
+               }
+               break;
+       case TGSI_OPCODE_INEG:
+               for (c = 0; c < 4; c++) {
+                       if (!(mask & (1 << c)))
+                               continue;
+                       emit_cvt(pc, dst[c], src[0][c], -1,
+                                CVT_S32_S32 | CVT_NEG);
+               }
                break;
        case TGSI_OPCODE_KIL:
+               assert(src[0][0] && src[0][1] && src[0][2] && src[0][3]);
                emit_kil(pc, src[0][0]);
                emit_kil(pc, src[0][1]);
                emit_kil(pc, src[0][2]);
                emit_kil(pc, src[0][3]);
                break;
+       case TGSI_OPCODE_KILP:
+               emit_kil(pc, NULL);
+               break;
        case TGSI_OPCODE_LIT:
                emit_lit(pc, &dst[0], mask, &src[0][0]);
                break;
        case TGSI_OPCODE_LG2:
-               emit_flop(pc, 3, brdc, src[0][0]);
+               emit_flop(pc, NV50_FLOP_LG2, brdc, src[0][0]);
+               break;
+       case TGSI_OPCODE_LOG:
+       {
+               struct nv50_reg *t[2];
+
+               t[0] = temp_temp(pc);
+               if (mask & (1 << 1))
+                       t[1] = temp_temp(pc);
+               else
+                       t[1] = t[0];
+
+               emit_cvt(pc, t[0], src[0][0], -1, CVT_ABS | CVT_F32_F32);
+               emit_flop(pc, NV50_FLOP_LG2, t[1], t[0]);
+               if (mask & (1 << 2))
+                       emit_mov(pc, dst[2], t[1]);
+               emit_flr(pc, t[1], t[1]);
+               if (mask & (1 << 0))
+                       emit_mov(pc, dst[0], t[1]);
+               if (mask & (1 << 1)) {
+                       t[1]->mod = NV50_MOD_NEG;
+                       emit_preex2(pc, t[1], t[1]);
+                       t[1]->mod = 0;
+                       emit_flop(pc, NV50_FLOP_EX2, t[1], t[1]);
+                       emit_mul(pc, dst[1], t[0], t[1]);
+               }
+               if (mask & (1 << 3))
+                       emit_mov_immdval(pc, dst[3], 1.0f);
+       }
                break;
        case TGSI_OPCODE_LRP:
                temp = temp_temp(pc);
@@ -1773,18 +2683,17 @@ nv50_program_tx_insn(struct nv50_pc *pc,
                for (c = 0; c < 4; c++) {
                        if (!(mask & (1 << c)))
                                continue;
-                       emit_minmax(pc, 4, dst[c], src[0][c], src[1][c]);
+                       emit_minmax(pc, 0x880, dst[c], src[0][c], src[1][c]);
                }
                break;
        case TGSI_OPCODE_MIN:
                for (c = 0; c < 4; c++) {
                        if (!(mask & (1 << c)))
                                continue;
-                       emit_minmax(pc, 5, dst[c], src[0][c], src[1][c]);
+                       emit_minmax(pc, 0x8a0, dst[c], src[0][c], src[1][c]);
                }
                break;
        case TGSI_OPCODE_MOV:
-       case TGSI_OPCODE_SWZ:
                for (c = 0; c < 4; c++) {
                        if (!(mask & (1 << c)))
                                continue;
@@ -1802,35 +2711,58 @@ nv50_program_tx_insn(struct nv50_pc *pc,
                emit_pow(pc, brdc, src[0][0], src[1][0]);
                break;
        case TGSI_OPCODE_RCP:
-               emit_flop(pc, 0, brdc, src[0][0]);
+               emit_flop(pc, NV50_FLOP_RCP, brdc, src[0][0]);
+               break;
+       case TGSI_OPCODE_RET:
+               if (pc->p->type == PIPE_SHADER_FRAGMENT && !pc->in_subroutine)
+                       nv50_fp_move_results(pc);
+               emit_ret(pc, -1, 0);
                break;
        case TGSI_OPCODE_RSQ:
-               emit_flop(pc, 2, brdc, src[0][0]);
+               src[0][0]->mod |= NV50_MOD_ABS;
+               emit_flop(pc, NV50_FLOP_RSQ, brdc, src[0][0]);
+               break;
+       case TGSI_OPCODE_SAD:
+               for (c = 0; c < 4; c++) {
+                       if (!(mask & (1 << c)))
+                               continue;
+                       emit_sad(pc, dst[c], src[0][c], src[1][c], src[2][c]);
+               }
                break;
        case TGSI_OPCODE_SCS:
                temp = temp_temp(pc);
                if (mask & 3)
                        emit_precossin(pc, temp, src[0][0]);
                if (mask & (1 << 0))
-                       emit_flop(pc, 5, dst[0], temp);
+                       emit_flop(pc, NV50_FLOP_COS, dst[0], temp);
                if (mask & (1 << 1))
-                       emit_flop(pc, 4, dst[1], temp);
+                       emit_flop(pc, NV50_FLOP_SIN, 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_SHL:
+       case TGSI_OPCODE_ISHR:
+       case TGSI_OPCODE_USHR:
+               for (c = 0; c < 4; c++) {
+                       if (!(mask & (1 << c)))
+                               continue;
+                       emit_shift(pc, dst[c], src[0][c], src[1][c],
+                                  inst->Instruction.Opcode);
+               }
+               break;
        case TGSI_OPCODE_SIN:
                if (mask & 8) {
                        emit_precossin(pc, temp, src[0][3]);
-                       emit_flop(pc, 4, dst[3], temp);
+                       emit_flop(pc, NV50_FLOP_SIN, dst[3], temp);
                        if (!(mask &= 7))
                                break;
                        if (temp == dst[3])
                                temp = brdc = temp_temp(pc);
                }
                emit_precossin(pc, temp, src[0][0]);
-               emit_flop(pc, 4, brdc, temp);
+               emit_flop(pc, NV50_FLOP_SIN, brdc, temp);
                break;
        case TGSI_OPCODE_SLT:
        case TGSI_OPCODE_SGE:
@@ -1838,12 +2770,23 @@ nv50_program_tx_insn(struct nv50_pc *pc,
        case TGSI_OPCODE_SGT:
        case TGSI_OPCODE_SLE:
        case TGSI_OPCODE_SNE:
-               i = map_tgsi_setop_cc(inst->Instruction.Opcode);
+       case TGSI_OPCODE_ISLT:
+       case TGSI_OPCODE_ISGE:
+       case TGSI_OPCODE_USEQ:
+       case TGSI_OPCODE_USGE:
+       case TGSI_OPCODE_USLT:
+       case TGSI_OPCODE_USNE:
+       {
+               uint8_t cc, ty;
+
+               map_tgsi_setop_hw(inst->Instruction.Opcode, &cc, &ty);
+
                for (c = 0; c < 4; c++) {
                        if (!(mask & (1 << c)))
                                continue;
-                       emit_set(pc, i, dst[c], -1, src[0][c], src[1][c]);
+                       emit_set(pc, cc, dst[c], -1, src[0][c], src[1][c], ty);
                }
+       }
                break;
        case TGSI_OPCODE_SUB:
                for (c = 0; c < 4; c++) {
@@ -1854,18 +2797,54 @@ nv50_program_tx_insn(struct nv50_pc *pc,
                break;
        case TGSI_OPCODE_TEX:
                emit_tex(pc, dst, mask, src[0], unit,
-                        inst->InstructionExtTexture.Texture, FALSE);
+                        inst->Texture.Texture, FALSE, 0);
+               break;
+       case TGSI_OPCODE_TXB:
+               emit_tex(pc, dst, mask, src[0], unit,
+                        inst->Texture.Texture, FALSE, -1);
+               break;
+       case TGSI_OPCODE_TXL:
+               emit_tex(pc, dst, mask, src[0], unit,
+                        inst->Texture.Texture, FALSE, 1);
                break;
        case TGSI_OPCODE_TXP:
                emit_tex(pc, dst, mask, src[0], unit,
-                        inst->InstructionExtTexture.Texture, TRUE);
+                        inst->Texture.Texture, TRUE, 0);
                break;
        case TGSI_OPCODE_TRUNC:
                for (c = 0; c < 4; c++) {
                        if (!(mask & (1 << c)))
                                continue;
                        emit_cvt(pc, dst[c], src[0][c], -1,
-                                CVTOP_TRUNC, CVT_F32_F32 | CVT_RI);
+                                CVT_TRUNC | CVT_F32_F32 | CVT_RI);
+               }
+               break;
+       case TGSI_OPCODE_U2F:
+               for (c = 0; c < 4; c++) {
+                       if (!(mask & (1 << c)))
+                               continue;
+                       emit_cvt(pc, dst[c], src[0][c], -1, CVT_F32_U32);
+               }
+               break;
+       case TGSI_OPCODE_UADD:
+               for (c = 0; c < 4; c++) {
+                       if (!(mask & (1 << c)))
+                               continue;
+                       emit_add_b32(pc, dst[c], src[0][c], src[1][c]);
+               }
+               break;
+       case TGSI_OPCODE_UMAX:
+               for (c = 0; c < 4; c++) {
+                       if (!(mask & (1 << c)))
+                               continue;
+                       emit_minmax(pc, 0x084, dst[c], src[0][c], src[1][c]);
+               }
+               break;
+       case TGSI_OPCODE_UMIN:
+               for (c = 0; c < 4; c++) {
+                       if (!(mask & (1 << c)))
+                               continue;
+                       emit_minmax(pc, 0x0a4, dst[c], src[0][c], src[1][c]);
                }
                break;
        case TGSI_OPCODE_XPD:
@@ -1886,6 +2865,17 @@ nv50_program_tx_insn(struct nv50_pc *pc,
                        emit_mov_immdval(pc, dst[3], 1.0);
                break;
        case TGSI_OPCODE_END:
+               if (pc->p->type == PIPE_SHADER_FRAGMENT)
+                       nv50_fp_move_results(pc);
+
+               /* last insn must be long so it can have the exit bit set */
+               if (!is_long(pc->p->exec_tail))
+                       convert_to_long(pc, pc->p->exec_tail);
+               else
+               if (is_immd(pc->p->exec_tail) || is_join(pc->p->exec_tail))
+                       emit_nop(pc);
+
+               pc->p->exec_tail->inst[1] |= 1; /* set exit bit */
                break;
        default:
                NOUVEAU_ERR("invalid opcode %d\n", inst->Instruction.Opcode);
@@ -1903,42 +2893,43 @@ nv50_program_tx_insn(struct nv50_pc *pc,
                for (c = 0; c < 4; c++) {
                        if (!(mask & (1 << c)))
                                continue;
-                       /* in this case we saturate later */
-                       if (dst[c]->type == P_TEMP && dst[c]->index < 0)
+                       /* In this case we saturate later, and dst[c] won't
+                        * be another temp_temp (and thus lost), since rdst
+                        * already is TEMP (see above). */
+                       if (rdst[c]->type == P_TEMP && rdst[c]->index < 0)
                                continue;
                        emit_sat(pc, rdst[c], dst[c]);
                }
        }
 
-       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]);
-               }
-       }
-
        kill_temp_temp(pc);
+       pc->reg_instance_nr = 0;
+
        return TRUE;
 }
 
 static void
 prep_inspect_insn(struct nv50_pc *pc, const struct tgsi_full_instruction *insn)
 {
-       struct nv50_reg *reg = NULL;
+       struct nv50_reg *r, *reg = NULL;
        const struct tgsi_full_src_register *src;
        const struct tgsi_dst_register *dst;
        unsigned i, c, k, mask;
 
-       dst = &insn->FullDstRegisters[0].DstRegister;
+       dst = &insn->Dst[0].Register;
        mask = dst->WriteMask;
 
         if (dst->File == TGSI_FILE_TEMPORARY)
-                reg = pc->temp;
+               reg = pc->temp;
         else
-        if (dst->File == TGSI_FILE_OUTPUT)
-                reg = pc->result;
+       if (dst->File == TGSI_FILE_OUTPUT) {
+               reg = pc->result;
+
+               if (insn->Instruction.Opcode == TGSI_OPCODE_MOV &&
+                   dst->Index == pc->edgeflag_out &&
+                   insn->Src[0].Register.File == TGSI_FILE_INPUT)
+                       pc->p->cfg.edgeflag_in = insn->Src[0].Register.Index;
+       }
 
        if (reg) {
                for (c = 0; c < 4; c++) {
@@ -1949,12 +2940,12 @@ prep_inspect_insn(struct nv50_pc *pc, const struct tgsi_full_instruction *insn)
        }
 
        for (i = 0; i < insn->Instruction.NumSrcRegs; i++) {
-               src = &insn->FullSrcRegisters[i];
+               src = &insn->Src[i];
 
-               if (src->SrcRegister.File == TGSI_FILE_TEMPORARY)
+               if (src->Register.File == TGSI_FILE_TEMPORARY)
                        reg = pc->temp;
                else
-               if (src->SrcRegister.File == TGSI_FILE_INPUT)
+               if (src->Register.File == TGSI_FILE_INPUT)
                        reg = pc->attr;
                else
                        continue;
@@ -1964,12 +2955,17 @@ prep_inspect_insn(struct nv50_pc *pc, const struct tgsi_full_instruction *insn)
                for (c = 0; c < 4; c++) {
                        if (!(mask & (1 << c)))
                                continue;
-                       k = tgsi_util_get_full_src_register_extswizzle(src, c);
+                       k = tgsi_util_get_full_src_register_swizzle(src, c);
 
-                       if (k > TGSI_EXTSWIZZLE_W)
-                               continue;
+                       r = &reg[src->Register.Index * 4 + k];
+
+                       /* If used before written, pre-allocate the reg,
+                        * lest we overwrite results from a subroutine.
+                        */
+                       if (!r->acc && r->type == P_TEMP)
+                               alloc_reg(pc, r);
 
-                       reg[src->SrcRegister.Index * 4 + k].acc = pc->insn_nr;
+                       r->acc = pc->insn_nr;
                }
        }
 }
@@ -2029,13 +3025,13 @@ static struct nv50_reg *
 tgsi_broadcast_dst(struct nv50_pc *pc,
                   const struct tgsi_full_dst_register *fd, unsigned mask)
 {
-       if (fd->DstRegister.File == TGSI_FILE_TEMPORARY) {
-               int c = ffs(~mask & fd->DstRegister.WriteMask);
+       if (fd->Register.File == TGSI_FILE_TEMPORARY) {
+               int c = ffs(~mask & fd->Register.WriteMask);
                if (c)
                        return tgsi_dst(pc, c - 1, fd);
        } else {
-               int c = ffs(fd->DstRegister.WriteMask) - 1;
-               if ((1 << c) == fd->DstRegister.WriteMask)
+               int c = ffs(fd->Register.WriteMask) - 1;
+               if ((1 << c) == fd->Register.WriteMask)
                        return tgsi_dst(pc, c, fd);
        }
 
@@ -2049,7 +3045,7 @@ static unsigned
 nv50_tgsi_scan_swizzle(const struct tgsi_full_instruction *insn,
                       unsigned rdep[4])
 {
-       const struct tgsi_full_dst_register *fd = &insn->FullDstRegisters[0];
+       const struct tgsi_full_dst_register *fd = &insn->Dst[0];
        const struct tgsi_full_src_register *fs;
        unsigned i, deqs = 0;
 
@@ -2058,11 +3054,11 @@ nv50_tgsi_scan_swizzle(const struct tgsi_full_instruction *insn,
 
        for (i = 0; i < insn->Instruction.NumSrcRegs; i++) {
                unsigned chn, mask = nv50_tgsi_src_mask(insn, i);
-               boolean neg_supp = negate_supported(insn, i);
+               int ms = get_supported_mods(insn, i);
 
-               fs = &insn->FullSrcRegisters[i];
-               if (fs->SrcRegister.File != fd->DstRegister.File ||
-                   fs->SrcRegister.Index != fd->DstRegister.Index)
+               fs = &insn->Src[i];
+               if (fs->Register.File != fd->Register.File ||
+                   fs->Register.Index != fd->Register.Index)
                        continue;
 
                for (chn = 0; chn < 4; ++chn) {
@@ -2070,17 +3066,18 @@ nv50_tgsi_scan_swizzle(const struct tgsi_full_instruction *insn,
 
                        if (!(mask & (1 << chn))) /* src is not read */
                                continue;
-                       c = tgsi_util_get_full_src_register_extswizzle(fs, chn);
+                       c = tgsi_util_get_full_src_register_swizzle(fs, chn);
                        s = tgsi_util_get_full_src_register_sign_mode(fs, chn);
 
-                       if (c > TGSI_EXTSWIZZLE_W ||
-                           !(fd->DstRegister.WriteMask & (1 << c)))
+                       if (!(fd->Register.WriteMask & (1 << c)))
                                continue;
 
-                       /* no danger if src is copied to TEMP first */
-                       if ((s != TGSI_UTIL_SIGN_KEEP) &&
-                           (s != TGSI_UTIL_SIGN_TOGGLE || !neg_supp))
-                               continue;
+                       if (s == TGSI_UTIL_SIGN_TOGGLE && !(ms & NV50_MOD_NEG))
+                                       continue;
+                       if (s == TGSI_UTIL_SIGN_CLEAR && !(ms & NV50_MOD_ABS))
+                                       continue;
+                       if ((s == TGSI_UTIL_SIGN_SET) && ((ms & 3) != 3))
+                                       continue;
 
                        rdep[c] |= nv50_tgsi_dst_revdep(
                                insn->Instruction.Opcode, i, chn);
@@ -2098,7 +3095,7 @@ nv50_tgsi_insn(struct nv50_pc *pc, const union tgsi_full_token *tok)
        const struct tgsi_full_dst_register *fd;
        unsigned i, deqs, rdep[4], m[4];
 
-       fd = &tok->FullInstruction.FullDstRegisters[0];
+       fd = &tok->FullInstruction.Dst[0];
        deqs = nv50_tgsi_scan_swizzle(&insn, rdep);
 
        if (is_scalar_op(insn.Instruction.Opcode)) {
@@ -2109,7 +3106,7 @@ nv50_tgsi_insn(struct nv50_pc *pc, const union tgsi_full_token *tok)
        }
        pc->r_brdc = NULL;
 
-       if (!deqs)
+       if (!deqs || (!rdep[0] && !rdep[1] && !rdep[2] && !rdep[3]))
                return nv50_program_tx_insn(pc, &insn);
 
        deqs = nv50_revdep_reorder(m, rdep);
@@ -2117,10 +3114,10 @@ nv50_tgsi_insn(struct nv50_pc *pc, const union tgsi_full_token *tok)
        for (i = 0; i < 4; ++i) {
                assert(pc->r_dst[m[i]] == NULL);
 
-               insn.FullDstRegisters[0].DstRegister.WriteMask =
-                       fd->DstRegister.WriteMask & (1 << m[i]);
+               insn.Dst[0].Register.WriteMask =
+                       fd->Register.WriteMask & (1 << m[i]);
 
-               if (!insn.FullDstRegisters[0].DstRegister.WriteMask)
+               if (!insn.Dst[0].Register.WriteMask)
                        continue;
 
                if (deqs & (1 << i))
@@ -2160,7 +3157,7 @@ load_interpolant(struct nv50_pc *pc, struct nv50_reg *reg)
                iv->rhw = popcnt4(pc->p->cfg.regs[1] >> 24) - 1;
 
                emit_interp(pc, iv, NULL, mode & INTERP_CENTROID);
-               emit_flop(pc, 0, iv, iv);
+               emit_flop(pc, NV50_FLOP_RCP, iv, iv);
 
                /* XXX: when loading interpolants dynamically, move these
                 * to the program head, or make sure it can't be skipped.
@@ -2170,6 +3167,23 @@ load_interpolant(struct nv50_pc *pc, struct nv50_reg *reg)
        emit_interp(pc, reg, iv, mode);
 }
 
+/* The face input is always at v[255] (varying space), with a
+ * value of 0 for back-facing, and 0xffffffff for front-facing.
+ */
+static void
+load_frontfacing(struct nv50_pc *pc, struct nv50_reg *a)
+{
+       struct nv50_reg *one = alloc_immd(pc, 1.0f);
+
+       assert(a->rhw == -1);
+       alloc_reg(pc, a); /* do this before rhw is set */
+       a->rhw = 255;
+       load_interpolant(pc, a);
+       emit_bitop2(pc, a, a, one, TGSI_OPCODE_AND);
+
+       FREE(one);
+}
+
 static boolean
 nv50_program_tx_prep(struct nv50_pc *pc)
 {
@@ -2189,10 +3203,10 @@ nv50_program_tx_prep(struct nv50_pc *pc)
                        const struct tgsi_full_immediate *imm =
                                &tp.FullToken.FullImmediate;
 
-                       ctor_immd(pc, imm->u[0].Float,
-                                     imm->u[1].Float,
-                                     imm->u[2].Float,
-                                     imm->u[3].Float);
+                       ctor_immd_4f32(pc, imm->u[0].Float,
+                                      imm->u[1].Float,
+                                      imm->u[2].Float,
+                                      imm->u[3].Float);
                }
                        break;
                case TGSI_TOKEN_TYPE_DECLARATION:
@@ -2201,8 +3215,8 @@ nv50_program_tx_prep(struct nv50_pc *pc)
                        unsigned si, last, first, mode;
 
                        d = &tp.FullToken.FullDeclaration;
-                       first = d->DeclarationRange.First;
-                       last = d->DeclarationRange.Last;
+                       first = d->Range.First;
+                       last = d->Range.Last;
 
                        switch (d->Declaration.File) {
                        case TGSI_FILE_TEMPORARY:
@@ -2212,8 +3226,8 @@ nv50_program_tx_prep(struct nv50_pc *pc)
                                    p->type == PIPE_SHADER_FRAGMENT)
                                        break;
 
-                               si = d->Semantic.SemanticIndex;
-                               switch (d->Semantic.SemanticName) {
+                               si = d->Semantic.Index;
+                               switch (d->Semantic.Name) {
                                case TGSI_SEMANTIC_BCOLOR:
                                        p->cfg.two_side[si].hw = first;
                                        if (p->cfg.io_nr > first)
@@ -2224,6 +3238,9 @@ nv50_program_tx_prep(struct nv50_pc *pc)
                                        if (p->cfg.io_nr > first)
                                                p->cfg.io_nr = first;
                                        break;
+                               case TGSI_SEMANTIC_EDGEFLAG:
+                                       pc->edgeflag_out = first;
+                                       break;
                                        /*
                                case TGSI_SEMANTIC_CLIP_DISTANCE:
                                        p->cfg.clpd = MIN2(p->cfg.clpd, first);
@@ -2259,8 +3276,8 @@ nv50_program_tx_prep(struct nv50_pc *pc)
                                        pc->interp_mode[i] = mode;
                        }
                                break;
+                       case TGSI_FILE_ADDRESS:
                        case TGSI_FILE_CONSTANT:
-                               break;
                        case TGSI_FILE_SAMPLER:
                                break;
                        default:
@@ -2291,7 +3308,7 @@ nv50_program_tx_prep(struct nv50_pc *pc)
 
                for (i = 0, rid = 0; i < pc->result_nr; ++i) {
                        p->cfg.io[i].hw = rid;
-                       p->cfg.io[i].id_vp = i;
+                       p->cfg.io[i].id = i;
 
                        for (c = 0; c < 4; ++c) {
                                int n = i * 4 + c;
@@ -2314,6 +3331,8 @@ nv50_program_tx_prep(struct nv50_pc *pc)
                int rid, aid;
                unsigned n = 0, m = pc->attr_nr - flat_nr;
 
+               pc->allow32 = TRUE;
+
                int base = (TGSI_SEMANTIC_POSITION ==
                            p->info.input_semantic_name[0]) ? 0 : 1;
 
@@ -2321,14 +3340,12 @@ nv50_program_tx_prep(struct nv50_pc *pc)
                 * the lower hardware IDs, so sort them:
                 */
                for (i = 0; i < pc->attr_nr; i++) {
-                       if (pc->interp_mode[i] == INTERP_FLAT) {
-                               p->cfg.io[m].id_vp = i + base;
-                               p->cfg.io[m++].id_fp = i;
-                       } else {
+                       if (pc->interp_mode[i] == INTERP_FLAT)
+                               p->cfg.io[m++].id = i;
+                       else {
                                if (!(pc->interp_mode[i] & INTERP_PERSPECTIVE))
                                        p->cfg.io[n].linear = TRUE;
-                               p->cfg.io[n].id_vp = i + base;
-                               p->cfg.io[n++].id_fp = i;
+                               p->cfg.io[n++].id = i;
                        }
                }
 
@@ -2340,7 +3357,13 @@ nv50_program_tx_prep(struct nv50_pc *pc)
 
                for (n = 0; n < pc->attr_nr; ++n) {
                        p->cfg.io[n].hw = rid = aid;
-                       i = p->cfg.io[n].id_fp;
+                       i = p->cfg.io[n].id;
+
+                       if (p->info.input_semantic_name[n] ==
+                           TGSI_SEMANTIC_FACE) {
+                               load_frontfacing(pc, &pc->attr[i * 4]);
+                               continue;
+                       }
 
                        for (c = 0; c < 4; ++c) {
                                if (!pc->attr[i * 4 + c].acc)
@@ -2374,8 +3397,8 @@ nv50_program_tx_prep(struct nv50_pc *pc)
                for (i = 0; i < pc->attr_nr; i++) {
                        ubyte si, sn;
 
-                       sn = p->info.input_semantic_name[p->cfg.io[i].id_fp];
-                       si = p->info.input_semantic_index[p->cfg.io[i].id_fp];
+                       sn = p->info.input_semantic_name[p->cfg.io[i].id];
+                       si = p->info.input_semantic_index[p->cfg.io[i].id];
 
                        if (sn == TGSI_SEMANTIC_COLOR) {
                                p->cfg.two_side[si] = p->cfg.io[i];
@@ -2400,6 +3423,10 @@ nv50_program_tx_prep(struct nv50_pc *pc)
                        pc->result[2].rhw = rid;
 
                p->cfg.high_result = rid;
+
+               /* separate/different colour results for MRTs ? */
+               if (pc->result_nr - (p->info.writes_z ? 1 : 0) > 1)
+                       p->cfg.regs[2] |= 1;
        }
 
        if (pc->immd_nr) {
@@ -2454,12 +3481,16 @@ ctor_nv50_pc(struct nv50_pc *pc, struct nv50_program *p)
        pc->attr_nr = p->info.file_max[TGSI_FILE_INPUT] + 1;
        pc->result_nr = p->info.file_max[TGSI_FILE_OUTPUT] + 1;
        pc->param_nr = p->info.file_max[TGSI_FILE_CONSTANT] + 1;
+       pc->addr_nr = p->info.file_max[TGSI_FILE_ADDRESS] + 1;
+       assert(pc->addr_nr <= 2);
 
        p->cfg.high_temp = 4;
 
        p->cfg.two_side[0].hw = 0x40;
        p->cfg.two_side[1].hw = 0x40;
 
+       p->cfg.edgeflag_in = pc->edgeflag_out = 0xff;
+
        switch (p->type) {
        case PIPE_SHADER_VERTEX:
                p->cfg.psiz = 0x40;
@@ -2522,31 +3553,21 @@ ctor_nv50_pc(struct nv50_pc *pc, struct nv50_program *p)
                                ctor_reg(&pc->param[rid], P_CONST, i, rid);
        }
 
-       return TRUE;
-}
-
-static void
-nv50_fp_move_results(struct nv50_pc *pc)
-{
-       struct nv50_reg reg;
-       unsigned i;
-
-       ctor_reg(&reg, P_TEMP, -1, -1);
-
-       for (i = 0; i < pc->result_nr * 4; ++i) {
-               if (pc->result[i].rhw < 0 || pc->result[i].hw < 0)
-                       continue;
-               if (pc->result[i].rhw != pc->result[i].hw) {
-                       reg.hw = pc->result[i].rhw;
-                       emit_mov(pc, &reg, &pc->result[i]);
-               }
+       if (pc->addr_nr) {
+               pc->addr = CALLOC(pc->addr_nr * 4, sizeof(struct nv50_reg *));
+               if (!pc->addr)
+                       return FALSE;
        }
+       for (i = 0; i < NV50_SU_MAX_ADDR; ++i)
+               ctor_reg(&pc->r_addr[i], P_ADDR, -256, i + 1);
+
+       return TRUE;
 }
 
 static void
 nv50_program_fixup_insns(struct nv50_pc *pc)
 {
-       struct nv50_program_exec *e, *prev = NULL, **bra_list;
+       struct nv50_program_exec *e, **bra_list;
        unsigned i, n, pos;
 
        bra_list = CALLOC(pc->p->exec_size, sizeof(struct nv50_program_exec *));
@@ -2566,27 +3587,24 @@ nv50_program_fixup_insns(struct nv50_pc *pc)
                        for (i = 0; i < n; ++i)
                                if (bra_list[i]->param.index >= pos)
                                        bra_list[i]->param.index += 1;
+                       for (i = 0; i < pc->insn_nr; ++i)
+                               if (pc->insn_pos[i] >= pos)
+                                       pc->insn_pos[i] += 1;
                        convert_to_long(pc, e);
                        ++pos;
                }
-               if (e->next)
-                       prev = e;
        }
 
-       assert(!is_immd(pc->p->exec_head));
-       assert(!is_immd(pc->p->exec_tail));
+       FREE(bra_list);
 
-       /* last instruction must be long so it can have the end bit set */
-       if (!is_long(pc->p->exec_tail)) {
-               convert_to_long(pc, pc->p->exec_tail);
-               if (prev)
-                       convert_to_long(pc, prev);
-       }
-       assert(!(pc->p->exec_tail->inst[1] & 2));
-       /* set the end-bit */
-       pc->p->exec_tail->inst[1] |= 1;
+       if (!pc->p->info.opcode_count[TGSI_OPCODE_CAL])
+               return;
 
-       FREE(bra_list);
+       /* fill in CALL offsets */
+       for (e = pc->p->exec_head; e; e = e->next) {
+               if ((e->inst[0] & 2) && (e->inst[0] >> 28) == 0x2)
+                       e->param.index = pc->insn_pos[e->param.index];
+       }
 }
 
 static boolean
@@ -2608,19 +3626,20 @@ nv50_program_tx(struct nv50_program *p)
        if (ret == FALSE)
                goto out_cleanup;
 
+       pc->insn_pos = MALLOC(pc->insn_nr * sizeof(unsigned));
+
        tgsi_parse_init(&parse, pc->p->pipe.tokens);
        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 */
+               /* previously allow32 was FALSE for first & 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_pos[pc->insn_cur] = pc->p->exec_size;
                        ++pc->insn_cur;
                        ret = nv50_tgsi_insn(pc, tok);
                        if (ret == FALSE)
@@ -2631,9 +3650,6 @@ nv50_program_tx(struct nv50_program *p)
                }
        }
 
-       if (pc->p->type == PIPE_SHADER_FRAGMENT)
-               nv50_fp_move_results(pc);
-
        nv50_program_fixup_insns(pc);
 
        p->param_nr = pc->param_nr * 4;
@@ -2657,7 +3673,7 @@ nv50_program_validate(struct nv50_context *nv50, struct nv50_program *p)
 }
 
 static void
-nv50_program_upload_data(struct nv50_context *nv50, float *map,
+nv50_program_upload_data(struct nv50_context *nv50, uint32_t *map,
                        unsigned start, unsigned count, unsigned cbuf)
 {
        struct nouveau_channel *chan = nv50->screen->base.channel;
@@ -2701,12 +3717,12 @@ nv50_program_validate_data(struct nv50_context *nv50, struct nv50_program *p)
                                         p->immd_nr, NV50_CB_PMISC);
        }
 
-       assert(p->param_nr <= 128);
+       assert(p->param_nr <= 512);
 
        if (p->param_nr) {
                unsigned cb;
-               float *map = pipe_buffer_map(pscreen, nv50->constbuf[p->type],
-                                            PIPE_BUFFER_USAGE_CPU_READ);
+               uint32_t *map = pipe_buffer_map(pscreen, nv50->constbuf[p->type],
+                                               PIPE_BUFFER_USAGE_CPU_READ);
 
                if (p->type == PIPE_SHADER_VERTEX)
                        cb = NV50_CB_PVP;
@@ -2722,11 +3738,8 @@ static void
 nv50_program_validate_code(struct nv50_context *nv50, struct nv50_program *p)
 {
        struct nouveau_channel *chan = nv50->screen->base.channel;
-       struct nouveau_grobj *tesla = nv50->screen->tesla;
        struct nv50_program_exec *e;
-       struct nouveau_stateobj *so;
-       const unsigned flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_WR;
-       unsigned start, count, *up, *ptr;
+       uint32_t *up, i;
        boolean upload = FALSE;
 
        if (!p->bo) {
@@ -2741,32 +3754,37 @@ nv50_program_validate_code(struct nv50_context *nv50, struct nv50_program *p)
        if (!upload)
                return;
 
-       for (e = p->exec_head; e; e = e->next) {
+       up = MALLOC(p->exec_size * 4);
+
+       for (i = 0, e = p->exec_head; e; e = e->next) {
                unsigned ei, ci, bs;
 
-               if (e->param.index < 0)
-                       continue;
+               if (e->param.index >= 0 && e->param.mask) {
+                       bs = (e->inst[1] >> 22) & 0x07;
+                       assert(bs < 2);
+                       ei = e->param.shift >> 5;
+                       ci = e->param.index;
+                       if (bs == 0)
+                               ci += p->data[bs]->start;
 
-               if (e->param.mask == 0) {
+                       e->inst[ei] &= ~e->param.mask;
+                       e->inst[ei] |= (ci << e->param.shift);
+               } else
+               if (e->param.index >= 0) {
+                       /* zero mask means param is a jump/branch offset */
                        assert(!(e->param.index & 1));
                        /* seem to be 8 byte steps */
                        ei = (e->param.index >> 1) + 0 /* START_ID */;
 
                        e->inst[0] &= 0xf0000fff;
                        e->inst[0] |= ei << 12;
-                       continue;
                }
 
-               bs = (e->inst[1] >> 22) & 0x07;
-               assert(bs < 2);
-               ei = e->param.shift >> 5;
-               ci = e->param.index;
-               if (bs == 0)
-                       ci += p->data[bs]->start;
-
-               e->inst[ei] &= ~e->param.mask;
-               e->inst[ei] |= (ci << e->param.shift);
+               up[i++] = e->inst[0];
+               if (is_long(e))
+                       up[i++] = e->inst[1];
        }
+       assert(i == p->exec_size);
 
        if (p->data[0])
                p->data_start[0] = p->data[0]->start;
@@ -2779,45 +3797,12 @@ nv50_program_validate_code(struct nv50_context *nv50, struct nv50_program *p)
                        NOUVEAU_ERR("0x%08x\n", e->inst[1]);
        }
 #endif
-
-       up = ptr = MALLOC(p->exec_size * 4);
-       for (e = p->exec_head; e; e = e->next) {
-               *(ptr++) = e->inst[0];
-               if (is_long(e))
-                       *(ptr++) = e->inst[1];
-       }
-
-       so = so_new(4,2);
-       so_method(so, nv50->screen->tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3);
-       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_channel *chan = nv50->screen->base.channel;
-               unsigned nr;
-
-               so_emit(chan, so);
-
-               nr = MIN2(count, 2047);
-               nr = MIN2(chan->pushbuf->remaining, nr);
-               if (chan->pushbuf->remaining < (nr + 3)) {
-                       FIRE_RING(chan);
-                       continue;
-               }
-
-               BEGIN_RING(chan, tesla, NV50TCL_CB_ADDR, 1);
-               OUT_RING  (chan, (start << 8) | NV50_CB_PUPLOAD);
-               BEGIN_RING(chan, tesla, NV50TCL_CB_DATA(0) | 0x40000000, nr);
-               OUT_RINGp (chan, up + start, nr);
-
-               start += nr;
-               count -= nr;
-       }
+       nv50_upload_sifc(nv50, p->bo, 0, NOUVEAU_BO_VRAM,
+                        NV50_2D_DST_FORMAT_R8_UNORM, 65536, 1, 262144,
+                        up, NV50_2D_SIFC_FORMAT_R8_UNORM, 0,
+                        0, 0, p->exec_size * 4, 1, 1);
 
        FREE(up);
-       so_ref(NULL, &so);
 }
 
 void
@@ -2836,7 +3821,7 @@ nv50_vertprog_validate(struct nv50_context *nv50)
        nv50_program_validate_data(nv50, p);
        nv50_program_validate_code(nv50, p);
 
-       so = so_new(13, 2);
+       so = so_new(5, 8, 2);
        so_method(so, tesla, NV50TCL_VP_ADDRESS_HIGH, 2);
        so_reloc (so, p->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD |
                      NOUVEAU_BO_HIGH, 0, 0);
@@ -2872,7 +3857,7 @@ nv50_fragprog_validate(struct nv50_context *nv50)
        nv50_program_validate_data(nv50, p);
        nv50_program_validate_code(nv50, p);
 
-       so = so_new(64, 2);
+       so = so_new(6, 7, 2);
        so_method(so, tesla, NV50TCL_FP_ADDRESS_HIGH, 2);
        so_reloc (so, p->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD |
                      NOUVEAU_BO_HIGH, 0, 0);
@@ -2882,7 +3867,7 @@ nv50_fragprog_validate(struct nv50_context *nv50)
        so_data  (so, p->cfg.high_temp);
        so_method(so, tesla, NV50TCL_FP_RESULT_COUNT, 1);
        so_data  (so, p->cfg.high_result);
-       so_method(so, tesla, NV50TCL_FP_CTRL_UNK19A8, 1);
+       so_method(so, tesla, NV50TCL_FP_CONTROL, 1);
        so_data  (so, p->cfg.regs[2]);
        so_method(so, tesla, NV50TCL_FP_CTRL_UNK196C, 1);
        so_data  (so, p->cfg.regs[3]);
@@ -2899,15 +3884,15 @@ nv50_pntc_replace(struct nv50_context *nv50, uint32_t pntc[8], unsigned base)
        struct nv50_program *vp = nv50->vertprog;
        unsigned i, c, m = base;
 
-       /* XXX: This can't work correctly in all cases yet, we either
-        * have to create TGSI_SEMANTIC_PNTC or sprite_coord_mode has
-        * to be per FP input instead of per VP output
+       /* XXX: this might not work correctly in all cases yet - we'll
+        * just assume that an FP generic input that is not written in
+        * the VP is PointCoord.
         */
        memset(pntc, 0, 8 * sizeof(uint32_t));
 
        for (i = 0; i < fp->cfg.io_nr; i++) {
                uint8_t sn, si;
-               uint8_t j = fp->cfg.io[i].id_vp, k = fp->cfg.io[i].id_fp;
+               uint8_t j, k = fp->cfg.io[i].id;
                unsigned n = popcnt4(fp->cfg.io[i].mask);
 
                if (fp->info.input_semantic_name[k] != TGSI_SEMANTIC_GENERIC) {
@@ -2915,10 +3900,16 @@ nv50_pntc_replace(struct nv50_context *nv50, uint32_t pntc[8], unsigned base)
                        continue;
                }
 
-               sn = vp->info.input_semantic_name[j];
-               si = vp->info.input_semantic_index[j];
+               for (j = 0; j < vp->info.num_outputs; ++j) {
+                       sn = vp->info.output_semantic_name[j];
+                       si = vp->info.output_semantic_index[j];
+
+                       if (sn == fp->info.input_semantic_name[k] &&
+                           si == fp->info.input_semantic_index[k])
+                               break;
+               }
 
-               if (j < fp->cfg.io_nr && sn == TGSI_SEMANTIC_GENERIC) {
+               if (j < vp->info.num_outputs) {
                        ubyte mode =
                                nv50->rasterizer->pipe.sprite_coord_mode[si];
 
@@ -3006,20 +3997,24 @@ nv50_linkage_validate(struct nv50_context *nv50)
        reg[0] += m - 4; /* adjust FFC0 id */
        reg[4] |= m << 8; /* set mid where 'normal' FP inputs start */
 
-       i = 0;
-       if (fp->info.input_semantic_name[0] == TGSI_SEMANTIC_POSITION)
-               i = 1;
-       for (; i < fp->cfg.io_nr; i++) {
-               ubyte sn = fp->info.input_semantic_name[fp->cfg.io[i].id_fp];
-               ubyte si = fp->info.input_semantic_index[fp->cfg.io[i].id_fp];
-
-               n = fp->cfg.io[i].id_vp;
-               if (n >= vp->cfg.io_nr ||
-                   vp->info.output_semantic_name[n] != sn ||
-                   vp->info.output_semantic_index[n] != si)
-                       vpo = &dummy;
-               else
-                       vpo = &vp->cfg.io[n];
+       for (i = 0; i < fp->cfg.io_nr; i++) {
+               ubyte sn = fp->info.input_semantic_name[fp->cfg.io[i].id];
+               ubyte si = fp->info.input_semantic_index[fp->cfg.io[i].id];
+
+               /* position must be mapped first */
+               assert(i == 0 || sn != TGSI_SEMANTIC_POSITION);
+
+               /* maybe even remove these from cfg.io */
+               if (sn == TGSI_SEMANTIC_POSITION || sn == TGSI_SEMANTIC_FACE)
+                       continue;
+
+               /* VP outputs and vp->cfg.io are in the same order */
+               for (n = 0; n < vp->info.num_outputs; ++n) {
+                       if (vp->info.output_semantic_name[n] == sn &&
+                           vp->info.output_semantic_index[n] == si)
+                               break;
+               }
+               vpo = (n < vp->info.num_outputs) ? &vp->cfg.io[n] : &dummy;
 
                m = nv50_sreg4_map(map, m, lin, &fp->cfg.io[i], vpo);
        }
@@ -3030,7 +4025,7 @@ nv50_linkage_validate(struct nv50_context *nv50)
        }
 
        /* now fill the stateobj */
-       so = so_new(64, 0);
+       so = so_new(6, 58, 0);
 
        n = (m + 3) / 4;
        so_method(so, tesla, NV50TCL_VP_RESULT_MAP_SIZE, 1);
@@ -3044,7 +4039,7 @@ nv50_linkage_validate(struct nv50_context *nv50)
        so_method(so, tesla, NV50TCL_FP_INTERPOLANT_CTRL, 1);
        so_data  (so, reg[4]);
 
-       so_method(so, tesla, 0x1540, 4);
+       so_method(so, tesla, NV50TCL_NOPERSPECTIVE_BITMAP(0), 4);
        so_datap (so, lin, 4);
 
        if (nv50->rasterizer->pipe.point_sprite) {
index d78dee083f1452cf6ed725c48718ae7364278078..461fec1d89c323663602f52e89e4d23358bebdd9 100644 (file)
@@ -17,8 +17,7 @@ struct nv50_program_exec {
 
 struct nv50_sreg4 {
        uint8_t hw;
-       uint8_t id_vp;
-       uint8_t id_fp;
+       uint8_t id; /* tgsi index, nv50 needs them sorted: flat ones last */
 
        uint8_t mask;
        boolean linear;
@@ -38,7 +37,7 @@ struct nv50_program {
 
        struct nouveau_bo *bo;
 
-       float *immd;
+       uint32_t *immd;
        unsigned immd_nr;
        unsigned param_nr;
 
@@ -59,6 +58,7 @@ struct nv50_program {
                /* VP only */
                uint8_t clpd, clpd_nr;
                uint8_t psiz;
+               uint8_t edgeflag_in;
        } cfg;
 };
 
index 5305c93d59ab15de76094c8a14e667d8d2b335a2..5d9e18218ae8cd976c364a5bdcf2755efc5a0f90 100644 (file)
@@ -77,9 +77,9 @@ nv50_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
        struct nouveau_grobj *tesla = nv50->screen->tesla;
        struct nv50_query *q = nv50_query(pq);
 
-       BEGIN_RING(chan, tesla, 0x1530, 1);
+       BEGIN_RING(chan, tesla, NV50TCL_SAMPLECNT_RESET, 1);
        OUT_RING  (chan, 1);
-       BEGIN_RING(chan, tesla, 0x1514, 1);
+       BEGIN_RING(chan, tesla, NV50TCL_SAMPLECNT_ENABLE, 1);
        OUT_RING  (chan, 1);
 
        q->ready = FALSE;
@@ -93,7 +93,7 @@ nv50_query_end(struct pipe_context *pipe, struct pipe_query *pq)
        struct nouveau_grobj *tesla = nv50->screen->tesla;
        struct nv50_query *q = nv50_query(pq);
 
-       WAIT_RING (chan, 5);
+       MARK_RING (chan, 5, 2); /* flush on lack of space or relocs */
        BEGIN_RING(chan, tesla, NV50TCL_QUERY_ADDRESS_HIGH, 4);
        OUT_RELOCh(chan, q->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
        OUT_RELOCl(chan, q->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
index dd7baecba7c3f42bfa0e4592e3f3ce5c4ea8781c..28e2b35deaaa664cece88ce5b162974152c408de 100644 (file)
@@ -38,6 +38,11 @@ nv50_screen_is_format_supported(struct pipe_screen *pscreen,
                case PIPE_FORMAT_X8R8G8B8_UNORM:
                case PIPE_FORMAT_A8R8G8B8_UNORM:
                case PIPE_FORMAT_R5G6B5_UNORM:
+               case PIPE_FORMAT_R16G16B16A16_SNORM:
+               case PIPE_FORMAT_R16G16B16A16_UNORM:
+               case PIPE_FORMAT_R32G32B32A32_FLOAT:
+               case PIPE_FORMAT_R16G16_SNORM:
+               case PIPE_FORMAT_R16G16_UNORM:
                        return TRUE;
                default:
                        break;
@@ -57,6 +62,8 @@ nv50_screen_is_format_supported(struct pipe_screen *pscreen,
                switch (format) {
                case PIPE_FORMAT_A8R8G8B8_UNORM:
                case PIPE_FORMAT_X8R8G8B8_UNORM:
+               case PIPE_FORMAT_A8R8G8B8_SRGB:
+               case PIPE_FORMAT_X8R8G8B8_SRGB:
                case PIPE_FORMAT_A1R5G5B5_UNORM:
                case PIPE_FORMAT_A4R4G4B4_UNORM:
                case PIPE_FORMAT_R5G6B5_UNORM:
@@ -68,6 +75,14 @@ nv50_screen_is_format_supported(struct pipe_screen *pscreen,
                case PIPE_FORMAT_DXT1_RGBA:
                case PIPE_FORMAT_DXT3_RGBA:
                case PIPE_FORMAT_DXT5_RGBA:
+               case PIPE_FORMAT_Z24S8_UNORM:
+               case PIPE_FORMAT_S8Z24_UNORM:
+               case PIPE_FORMAT_Z32_FLOAT:
+               case PIPE_FORMAT_R16G16B16A16_SNORM:
+               case PIPE_FORMAT_R16G16B16A16_UNORM:
+               case PIPE_FORMAT_R32G32B32A32_FLOAT:
+               case PIPE_FORMAT_R16G16_SNORM:
+               case PIPE_FORMAT_R16G16_UNORM:
                        return TRUE;
                default:
                        break;
@@ -83,6 +98,10 @@ nv50_screen_get_param(struct pipe_screen *pscreen, int param)
        switch (param) {
        case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
                return 32;
+       case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS:
+               return 32;
+       case PIPE_CAP_MAX_COMBINED_SAMPLERS:
+               return 64;
        case PIPE_CAP_NPOT_TEXTURES:
                return 1;
        case PIPE_CAP_TWO_SIDED_STENCIL:
@@ -108,10 +127,8 @@ nv50_screen_get_param(struct pipe_screen *pscreen, int param)
        case PIPE_CAP_TEXTURE_MIRROR_CLAMP:
        case PIPE_CAP_TEXTURE_MIRROR_REPEAT:
                return 1;
-       case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS:
-               return 0;
        case PIPE_CAP_TGSI_CONT_SUPPORTED:
-               return 0;
+               return 1;
        case PIPE_CAP_BLEND_EQUATION_SEPARATE:
                return 1;
        case NOUVEAU_CAP_HW_VTXBUF:
@@ -148,6 +165,21 @@ static void
 nv50_screen_destroy(struct pipe_screen *pscreen)
 {
        struct nv50_screen *screen = nv50_screen(pscreen);
+       unsigned i;
+
+       for (i = 0; i < 2; i++) {
+               if (screen->constbuf_parm[i])
+                       nouveau_bo_ref(NULL, &screen->constbuf_parm[i]);
+       }
+
+       if (screen->constbuf_misc[0])
+               nouveau_bo_ref(NULL, &screen->constbuf_misc[0]);
+       if (screen->tic)
+               nouveau_bo_ref(NULL, &screen->tic);
+       if (screen->tsc)
+               nouveau_bo_ref(NULL, &screen->tsc);
+       if (screen->static_init)
+               so_ref(NULL, &screen->static_init);
 
        nouveau_notifier_free(&screen->sync);
        nouveau_grobj_free(&screen->tesla);
@@ -157,6 +189,28 @@ nv50_screen_destroy(struct pipe_screen *pscreen)
        FREE(screen);
 }
 
+static int
+nv50_pre_pipebuffer_map(struct pipe_screen *pscreen, struct pipe_buffer *pb,
+       unsigned usage)
+{
+       struct nv50_screen *screen = nv50_screen(pscreen);
+       struct nv50_context *ctx = screen->cur_ctx;
+
+       if (!(pb->usage & PIPE_BUFFER_USAGE_VERTEX))
+               return 0;
+
+       /* Our vtxbuf got mapped, it can no longer be considered part of current
+        * state, remove it to avoid emitting reloc markers.
+        */
+       if (ctx && ctx->state.vtxbuf && so_bo_is_reloc(ctx->state.vtxbuf,
+                       nouveau_bo(pb))) {
+               so_ref(NULL, &ctx->state.vtxbuf);
+               ctx->dirty |= NV50_NEW_ARRAYS;
+       }
+
+       return 0;
+}
+
 struct pipe_screen *
 nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
 {
@@ -184,6 +238,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
        pscreen->get_param = nv50_screen_get_param;
        pscreen->get_paramf = nv50_screen_get_paramf;
        pscreen->is_format_supported = nv50_screen_is_format_supported;
+       screen->base.pre_pipebuffer_map_callback = nv50_pre_pipebuffer_map;
 
        nv50_screen_init_miptree_functions(pscreen);
        nv50_transfer_init_screen_functions(pscreen);
@@ -196,7 +251,6 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
                nv50_screen_destroy(pscreen);
                return NULL;
        }
-       BIND_RING(chan, screen->m2mf, 1);
 
        /* 2D object */
        ret = nouveau_grobj_alloc(chan, 0xbeef502d, NV50_2D, &screen->eng2d);
@@ -205,7 +259,6 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
                nv50_screen_destroy(pscreen);
                return NULL;
        }
-       BIND_RING(chan, screen->eng2d, 2);
 
        /* 3D object */
        switch (chipset & 0xf0) {
@@ -214,11 +267,19 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
                break;
        case 0x80:
        case 0x90:
-               /* this stupid name should be corrected. */
-               tesla_class = NV54TCL;
+               tesla_class = NV84TCL;
                break;
        case 0xa0:
-               tesla_class = NVA0TCL;
+               switch (chipset) {
+               case 0xa0:
+               case 0xaa:
+               case 0xac:
+                       tesla_class = NVA0TCL;
+                       break;
+               default:
+                       tesla_class = NVA8TCL;
+                       break;
+               }
                break;
        default:
                NOUVEAU_ERR("Not a known NV50 chipset: NV%02x\n", chipset);
@@ -226,12 +287,6 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
                return NULL;
        }
 
-       if (tesla_class == 0) {
-               NOUVEAU_ERR("Unknown G8x chipset: NV%02x\n", chipset);
-               nv50_screen_destroy(pscreen);
-               return NULL;
-       }
-
        ret = nouveau_grobj_alloc(chan, 0xbeef5097, tesla_class,
                &screen->tesla);
        if (ret) {
@@ -239,7 +294,6 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
                nv50_screen_destroy(pscreen);
                return NULL;
        }
-       BIND_RING(chan, screen->tesla, 3);
 
        /* Sync notifier */
        ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync);
@@ -250,7 +304,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
        }
 
        /* Static M2MF init */
-       so = so_new(32, 0);
+       so = so_new(1, 3, 0);
        so_method(so, screen->m2mf, NV04_MEMORY_TO_MEMORY_FORMAT_DMA_NOTIFY, 3);
        so_data  (so, screen->sync->handle);
        so_data  (so, chan->vram->handle);
@@ -259,7 +313,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
        so_ref (NULL, &so);
 
        /* Static 2D init */
-       so = so_new(64, 0);
+       so = so_new(4, 7, 0);
        so_method(so, screen->eng2d, NV50_2D_DMA_NOTIFY, 4);
        so_data  (so, screen->sync->handle);
        so_data  (so, chan->vram->handle);
@@ -267,7 +321,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
        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_method(so, screen->eng2d, NV50_2D_CLIP_ENABLE, 1);
        so_data  (so, 0);
        so_method(so, screen->eng2d, 0x0888, 1);
        so_data  (so, 1);
@@ -275,33 +329,41 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
        so_ref(NULL, &so);
 
        /* Static tesla init */
-       so = so_new(256, 20);
+       so = so_new(40, 84, 20);
 
-       so_method(so, screen->tesla, 0x1558, 1);
-       so_data  (so, 1);
+       so_method(so, screen->tesla, NV50TCL_COND_MODE, 1);
+       so_data  (so, NV50TCL_COND_MODE_ALWAYS);
        so_method(so, screen->tesla, NV50TCL_DMA_NOTIFY, 1);
        so_data  (so, screen->sync->handle);
-       so_method(so, screen->tesla, NV50TCL_DMA_UNK0(0),
-                                    NV50TCL_DMA_UNK0__SIZE);
-       for (i = 0; i < NV50TCL_DMA_UNK0__SIZE; i++)
+       so_method(so, screen->tesla, NV50TCL_DMA_ZETA, 11);
+       for (i = 0; i < 11; i++)
                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_method(so, screen->tesla, NV50TCL_DMA_COLOR(0),
+                                    NV50TCL_DMA_COLOR__SIZE);
+       for (i = 0; i < NV50TCL_DMA_COLOR__SIZE; i++)
                so_data(so, chan->vram->handle);
-       so_method(so, screen->tesla, 0x121c, 1);
+       so_method(so, screen->tesla, NV50TCL_RT_CONTROL, 1);
        so_data  (so, 1);
 
-       so_method(so, screen->tesla, 0x13bc, 1);
+       /* activate all 32 lanes (threads) in a warp */
+       so_method(so, screen->tesla, NV50TCL_WARP_HALVES, 1);
+       so_data  (so, 0x2);
+       so_method(so, screen->tesla, 0x1400, 1);
+       so_data  (so, 0xf);
+
+       /* max TIC (bits 4:8) & TSC (ignored) bindings, per program type */
+       so_method(so, screen->tesla, NV50TCL_TEX_LIMITS(0), 1);
+       so_data  (so, 0x54);
+       so_method(so, screen->tesla, NV50TCL_TEX_LIMITS(2), 1);
        so_data  (so, 0x54);
        /* origin is top left (set to 1 for bottom left) */
-       so_method(so, screen->tesla, 0x13ac, 1);
+       so_method(so, screen->tesla, NV50TCL_Y_ORIGIN_BOTTOM, 1);
        so_data  (so, 0);
        so_method(so, screen->tesla, NV50TCL_VP_REG_ALLOC_RESULT, 1);
        so_data  (so, 8);
 
        /* constant buffers for immediates and VP/FP parameters */
-       ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 128*4*4,
+       ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, (32 * 4) * 4,
                             &screen->constbuf_misc[0]);
        if (ret) {
                nv50_screen_destroy(pscreen);
@@ -309,7 +371,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
        }
 
        for (i = 0; i < 2; i++) {
-               ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 128*4*4,
+               ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, (128 * 4) * 4,
                                     &screen->constbuf_parm[i]);
                if (ret) {
                        nv50_screen_destroy(pscreen);
@@ -318,8 +380,8 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
        }
 
        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_resource_init(&screen->parm_heap[0], 0, 512) ||
+           nouveau_resource_init(&screen->parm_heap[1], 0, 512))
        {
                NOUVEAU_ERR("Error initialising constant buffers.\n");
                nv50_screen_destroy(pscreen);
@@ -331,7 +393,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
        //  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_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1);
        so_data  (so, 0x000BBNP1);
        */
 
@@ -340,7 +402,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
                  NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
        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) | 0x00000800);
+       so_data  (so, (NV50_CB_PMISC << 16) | 0x00000200);
        so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1);
        so_data  (so, 0x00000001 | (NV50_CB_PMISC << 12));
        so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1);
@@ -364,68 +426,57 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
        so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 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?
-        */
-       ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 32*8*4, &screen->tic);
+       ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, PIPE_SHADER_TYPES*32*32,
+                            &screen->tic);
        if (ret) {
                nv50_screen_destroy(pscreen);
                return NULL;
        }
 
-       so_method(so, screen->tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3);
-       so_reloc (so, screen->tic, 0, NOUVEAU_BO_VRAM |
-                 NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
-       so_reloc (so, screen->tic, 0, NOUVEAU_BO_VRAM |
-                 NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
-       so_data  (so, (NV50_CB_TIC << 16) | 0x0800);
        so_method(so, screen->tesla, NV50TCL_TIC_ADDRESS_HIGH, 3);
        so_reloc (so, screen->tic, 0, NOUVEAU_BO_VRAM |
                  NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
        so_reloc (so, screen->tic, 0, NOUVEAU_BO_VRAM |
                  NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
-       so_data  (so, 0x00000800);
+       so_data  (so, PIPE_SHADER_TYPES * 32 - 1);
 
-       ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 32*8*4, &screen->tsc);
+       ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, PIPE_SHADER_TYPES*32*32,
+                            &screen->tsc);
        if (ret) {
                nv50_screen_destroy(pscreen);
                return NULL;
        }
 
-       so_method(so, screen->tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3);
-       so_reloc (so, screen->tsc, 0, NOUVEAU_BO_VRAM |
-                 NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
-       so_reloc (so, screen->tsc, 0, NOUVEAU_BO_VRAM |
-                 NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
-       so_data  (so, (NV50_CB_TSC << 16) | 0x0800);
        so_method(so, screen->tesla, NV50TCL_TSC_ADDRESS_HIGH, 3);
        so_reloc (so, screen->tsc, 0, NOUVEAU_BO_VRAM |
                  NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
        so_reloc (so, screen->tsc, 0, NOUVEAU_BO_VRAM |
                  NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
-       so_data  (so, 0x00000800);
+       so_data  (so, 0x00000000); /* ignored if TSC_LINKED (0x1234) = 1 */
 
 
        /* Vertex array limits - max them out */
        for (i = 0; i < 16; i++) {
-               so_method(so, screen->tesla, NV50TCL_UNK1080_OFFSET_HIGH(i), 2);
+               so_method(so, screen->tesla, NV50TCL_VERTEX_ARRAY_LIMIT_HIGH(i), 2);
                so_data  (so, 0x000000ff);
                so_data  (so, 0xffffffff);
        }
 
-       so_method(so, screen->tesla, NV50TCL_DEPTH_RANGE_NEAR, 2);
+       so_method(so, screen->tesla, NV50TCL_DEPTH_RANGE_NEAR(0), 2);
        so_data  (so, fui(0.0));
        so_data  (so, fui(1.0));
 
-       so_method(so, screen->tesla, 0x1234, 1);
+       /* no dynamic combination of TIC & TSC entries => only BIND_TIC used */
+       so_method(so, screen->tesla, NV50TCL_LINKED_TSC, 1);
        so_data  (so, 1);
 
        /* activate first scissor rectangle */
-       so_method(so, screen->tesla, NV50TCL_SCISSOR_ENABLE, 1);
+       so_method(so, screen->tesla, NV50TCL_SCISSOR_ENABLE(0), 1);
        so_data  (so, 1);
 
+       so_method(so, screen->tesla, NV50TCL_EDGEFLAG_ENABLE, 1);
+       so_data  (so, 1); /* default edgeflag to TRUE */
+
        so_emit(chan, so);
        so_ref (so, &screen->static_init);
        so_ref (NULL, &so);
index 61e24a5b571746e3b5b9c2af0fb76ff4398b2a2e..a038a4e3c2adee79addfa0a57229c6022699ab23 100644 (file)
@@ -2,6 +2,7 @@
 #define __NV50_SCREEN_H__
 
 #include "nouveau/nouveau_screen.h"
+#include "nv50_context.h"
 
 struct nv50_screen {
        struct nouveau_screen base;
@@ -9,6 +10,7 @@ struct nv50_screen {
        struct nouveau_winsys *nvws;
 
        unsigned cur_pctx;
+       struct nv50_context *cur_ctx;
 
        struct nouveau_grobj *tesla;
        struct nouveau_grobj *eng2d;
index 81fa3e34c59c00f5a083c008d42957517ed0a13a..1f67df814b1742a4d9e8ad748a209ff9269870f7 100644 (file)
@@ -35,7 +35,7 @@ static void *
 nv50_blend_state_create(struct pipe_context *pipe,
                        const struct pipe_blend_state *cso)
 {
-       struct nouveau_stateobj *so = so_new(64, 0);
+       struct nouveau_stateobj *so = so_new(5, 24, 0);
        struct nouveau_grobj *tesla = nv50_context(pipe)->screen->tesla;
        struct nv50_blend_stateobj *bso = CALLOC_STRUCT(nv50_blend_stateobj);
        unsigned cmask = 0, i;
@@ -183,25 +183,20 @@ nv50_sampler_state_create(struct pipe_context *pipe,
        else
        if (cso->max_anisotropy >= 12.0)
                tsc[0] |= (6 << 20);
-       else
-       if (cso->max_anisotropy >= 10.0)
-               tsc[0] |= (5 << 20);
-       else
-       if (cso->max_anisotropy >= 8.0)
-               tsc[0] |= (4 << 20);
-       else
-       if (cso->max_anisotropy >= 6.0)
-               tsc[0] |= (3 << 20);
-       else
-       if (cso->max_anisotropy >= 4.0)
-               tsc[0] |= (2 << 20);
-       else
-       if (cso->max_anisotropy >= 2.0)
-               tsc[0] |= (1 << 20);
+       else {
+               tsc[0] |= (int)(cso->max_anisotropy * 0.5f) << 20;
+
+               if (cso->max_anisotropy >= 4.0)
+                       tsc[1] |= NV50TSC_1_1_UNKN_ANISO_35;
+               else
+               if (cso->max_anisotropy >= 2.0)
+                       tsc[1] |= NV50TSC_1_1_UNKN_ANISO_15;
+       }
 
        if (cso->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) {
-               tsc[0] |= (1 << 8);
-               tsc[0] |= (nvgl_comparison_op(cso->compare_func) & 0x7);
+               /* XXX: must be deactivated for non-shadow textures */
+               tsc[0] |= (1 << 9);
+               tsc[0] |= (nvgl_comparison_op(cso->compare_func) & 0x7) << 10;
        }
 
        limit = CLAMP(cso->lod_bias, -16.0, 15.0);
@@ -219,46 +214,71 @@ nv50_sampler_state_create(struct pipe_context *pipe,
        return (void *)sso;
 }
 
-static void
-nv50_sampler_state_bind(struct pipe_context *pipe, unsigned nr, void **sampler)
+static INLINE void
+nv50_sampler_state_bind(struct pipe_context *pipe, unsigned type,
+                       unsigned nr, void **sampler)
 {
        struct nv50_context *nv50 = nv50_context(pipe);
-       int i;
 
-       nv50->sampler_nr = nr;
-       for (i = 0; i < nv50->sampler_nr; i++)
-               nv50->sampler[i] = sampler[i];
+       memcpy(nv50->sampler[type], sampler, nr * sizeof(void *));
 
+       nv50->sampler_nr[type] = nr;
        nv50->dirty |= NV50_NEW_SAMPLER;
 }
 
+static void
+nv50_vp_sampler_state_bind(struct pipe_context *pipe, unsigned nr, void **s)
+{
+       nv50_sampler_state_bind(pipe, PIPE_SHADER_VERTEX, nr, s);
+}
+
+static void
+nv50_fp_sampler_state_bind(struct pipe_context *pipe, unsigned nr, void **s)
+{
+       nv50_sampler_state_bind(pipe, PIPE_SHADER_FRAGMENT, nr, s);
+}
+
 static void
 nv50_sampler_state_delete(struct pipe_context *pipe, void *hwcso)
 {
        FREE(hwcso);
 }
 
-static void
-nv50_set_sampler_texture(struct pipe_context *pipe, unsigned nr,
-                        struct pipe_texture **pt)
+static INLINE void
+nv50_set_sampler_texture(struct pipe_context *pipe, unsigned type,
+                        unsigned nr, struct pipe_texture **pt)
 {
        struct nv50_context *nv50 = nv50_context(pipe);
-       int i;
+       unsigned i;
 
        for (i = 0; i < nr; i++)
-               pipe_texture_reference((void *)&nv50->miptree[i], pt[i]);
-       for (i = nr; i < nv50->miptree_nr; i++)
-               pipe_texture_reference((void *)&nv50->miptree[i], NULL);
+               pipe_texture_reference((void *)&nv50->miptree[type][i], pt[i]);
+       for (i = nr; i < nv50->miptree_nr[type]; i++)
+               pipe_texture_reference((void *)&nv50->miptree[type][i], NULL);
 
-       nv50->miptree_nr = nr;
+       nv50->miptree_nr[type] = nr;
        nv50->dirty |= NV50_NEW_TEXTURE;
 }
 
+static void
+nv50_set_vp_sampler_textures(struct pipe_context *pipe,
+                            unsigned nr, struct pipe_texture **pt)
+{
+       nv50_set_sampler_texture(pipe, PIPE_SHADER_VERTEX, nr, pt);
+}
+
+static void
+nv50_set_fp_sampler_textures(struct pipe_context *pipe,
+                            unsigned nr, struct pipe_texture **pt)
+{
+       nv50_set_sampler_texture(pipe, PIPE_SHADER_FRAGMENT, nr, pt);
+}
+
 static void *
 nv50_rasterizer_state_create(struct pipe_context *pipe,
                             const struct pipe_rasterizer_state *cso)
 {
-       struct nouveau_stateobj *so = so_new(64, 0);
+       struct nouveau_stateobj *so = so_new(15, 21, 0);
        struct nouveau_grobj *tesla = nv50_context(pipe)->screen->tesla;
        struct nv50_rasterizer_stateobj *rso =
                CALLOC_STRUCT(nv50_rasterizer_stateobj);
@@ -273,7 +293,7 @@ nv50_rasterizer_state_create(struct pipe_context *pipe,
        so_method(so, tesla, NV50TCL_SHADE_MODEL, 1);
        so_data  (so, cso->flatshade ? NV50TCL_SHADE_MODEL_FLAT :
                                       NV50TCL_SHADE_MODEL_SMOOTH);
-       so_method(so, tesla, 0x1684, 1);
+       so_method(so, tesla, NV50TCL_PROVOKING_VERTEX_LAST, 1);
        so_data  (so, cso->flatshade_first ? 0 : 1);
 
        so_method(so, tesla, NV50TCL_VERTEX_TWO_SIDE_ENABLE, 1);
@@ -370,7 +390,7 @@ nv50_rasterizer_state_create(struct pipe_context *pipe,
                so_method(so, tesla, NV50TCL_POLYGON_OFFSET_FACTOR, 1);
                so_data  (so, fui(cso->offset_scale));
                so_method(so, tesla, NV50TCL_POLYGON_OFFSET_UNITS, 1);
-               so_data  (so, fui(cso->offset_units));
+               so_data  (so, fui(cso->offset_units * 2.0f));
        }
 
        rso->pipe = *cso;
@@ -403,7 +423,7 @@ nv50_depth_stencil_alpha_state_create(struct pipe_context *pipe,
 {
        struct nouveau_grobj *tesla = nv50_context(pipe)->screen->tesla;
        struct nv50_zsa_stateobj *zsa = CALLOC_STRUCT(nv50_zsa_stateobj);
-       struct nouveau_stateobj *so = so_new(64, 0);
+       struct nouveau_stateobj *so = so_new(8, 22, 0);
 
        so_method(so, tesla, NV50TCL_DEPTH_WRITE_ENABLE, 1);
        so_data  (so, cso->depth.writemask ? 1 : 0);
@@ -417,9 +437,8 @@ nv50_depth_stencil_alpha_state_create(struct pipe_context *pipe,
                so_data  (so, 0);
        }
 
-       /* XXX: keep hex values until header is updated (names reversed) */
        if (cso->stencil[0].enabled) {
-               so_method(so, tesla, 0x1380, 8);
+               so_method(so, tesla, NV50TCL_STENCIL_FRONT_ENABLE, 8);
                so_data  (so, 1);
                so_data  (so, nvgl_stencil_op(cso->stencil[0].fail_op));
                so_data  (so, nvgl_stencil_op(cso->stencil[0].zfail_op));
@@ -429,23 +448,23 @@ nv50_depth_stencil_alpha_state_create(struct pipe_context *pipe,
                so_data  (so, cso->stencil[0].writemask);
                so_data  (so, cso->stencil[0].valuemask);
        } else {
-               so_method(so, tesla, 0x1380, 1);
+               so_method(so, tesla, NV50TCL_STENCIL_FRONT_ENABLE, 1);
                so_data  (so, 0);
        }
 
        if (cso->stencil[1].enabled) {
-               so_method(so, tesla, 0x1594, 5);
+               so_method(so, tesla, NV50TCL_STENCIL_BACK_ENABLE, 5);
                so_data  (so, 1);
                so_data  (so, nvgl_stencil_op(cso->stencil[1].fail_op));
                so_data  (so, nvgl_stencil_op(cso->stencil[1].zfail_op));
                so_data  (so, nvgl_stencil_op(cso->stencil[1].zpass_op));
                so_data  (so, nvgl_comparison_op(cso->stencil[1].func));
-               so_method(so, tesla, 0x0f54, 3);
+               so_method(so, tesla, NV50TCL_STENCIL_BACK_FUNC_REF, 3);
                so_data  (so, cso->stencil[1].ref_value);
                so_data  (so, cso->stencil[1].writemask);
                so_data  (so, cso->stencil[1].valuemask);
        } else {
-               so_method(so, tesla, 0x1594, 1);
+               so_method(so, tesla, NV50TCL_STENCIL_BACK_ENABLE, 1);
                so_data  (so, 0);
        }
 
@@ -652,9 +671,11 @@ nv50_init_state_functions(struct nv50_context *nv50)
        nv50->pipe.delete_blend_state = nv50_blend_state_delete;
 
        nv50->pipe.create_sampler_state = nv50_sampler_state_create;
-       nv50->pipe.bind_sampler_states = nv50_sampler_state_bind;
        nv50->pipe.delete_sampler_state = nv50_sampler_state_delete;
-       nv50->pipe.set_sampler_textures = nv50_set_sampler_texture;
+       nv50->pipe.bind_fragment_sampler_states = nv50_fp_sampler_state_bind;
+       nv50->pipe.bind_vertex_sampler_states   = nv50_vp_sampler_state_bind;
+       nv50->pipe.set_fragment_sampler_textures = nv50_set_fp_sampler_textures;
+       nv50->pipe.set_vertex_sampler_textures   = nv50_set_vp_sampler_textures;
 
        nv50->pipe.create_rasterizer_state = nv50_rasterizer_state_create;
        nv50->pipe.bind_rasterizer_state = nv50_rasterizer_state_bind;
index fd276203710f570f3cfc40dd3cea681ad5e671ff..f83232f43cf5cc0eca3114ecd336ae8f1458821c 100644 (file)
 #include "nv50_context.h"
 #include "nouveau/nouveau_stateobj.h"
 
+#define NV50_CBUF_FORMAT_CASE(n) \
+       case PIPE_FORMAT_##n: so_data(so, NV50TCL_RT_FORMAT_##n); break
+
+#define NV50_ZETA_FORMAT_CASE(n) \
+       case PIPE_FORMAT_##n: so_data(so, NV50TCL_ZETA_FORMAT_##n); break
+
 static void
 nv50_state_validate_fb(struct nv50_context *nv50)
 {
        struct nouveau_grobj *tesla = nv50->screen->tesla;
-       struct nouveau_stateobj *so = so_new(128, 18);
+       struct nouveau_stateobj *so = so_new(32, 79, 18);
        struct pipe_framebuffer_state *fb = &nv50->framebuffer;
        unsigned i, w, h, gw = 0;
 
+       /* Set nr of active RTs and select RT for each colour output.
+        * FP result 0 always goes to RT[0], bits 4 - 6 are ignored.
+        * Ambiguous assignment results in no rendering (no DATA_ERROR).
+        */
+       so_method(so, tesla, NV50TCL_RT_CONTROL, 1);
+       so_data  (so, fb->nr_cbufs |
+                 (0 <<  4) | (1 <<  7) | (2 << 10) | (3 << 13) |
+                 (4 << 16) | (5 << 19) | (6 << 22) | (7 << 25));
+
        for (i = 0; i < fb->nr_cbufs; i++) {
                struct pipe_texture *pt = fb->cbufs[i]->texture;
                struct nouveau_bo *bo = nv50_miptree(pt)->base.bo;
@@ -54,15 +69,14 @@ nv50_state_validate_fb(struct nv50_context *nv50)
                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, NV50TCL_RT_FORMAT_A8R8G8B8_UNORM);
-                       break;
-               case PIPE_FORMAT_X8R8G8B8_UNORM:
-                       so_data(so, NV50TCL_RT_FORMAT_X8R8G8B8_UNORM);
-                       break;
-               case PIPE_FORMAT_R5G6B5_UNORM:
-                       so_data(so, NV50TCL_RT_FORMAT_R5G6B5_UNORM);
-                       break;
+               NV50_CBUF_FORMAT_CASE(A8R8G8B8_UNORM);
+               NV50_CBUF_FORMAT_CASE(X8R8G8B8_UNORM);
+               NV50_CBUF_FORMAT_CASE(R5G6B5_UNORM);
+               NV50_CBUF_FORMAT_CASE(R16G16B16A16_SNORM);
+               NV50_CBUF_FORMAT_CASE(R16G16B16A16_UNORM);
+               NV50_CBUF_FORMAT_CASE(R32G32B32A32_FLOAT);
+               NV50_CBUF_FORMAT_CASE(R16G16_SNORM);
+               NV50_CBUF_FORMAT_CASE(R16G16_UNORM);
                default:
                        NOUVEAU_ERR("AIIII unknown format %s\n",
                                    pf_name(fb->cbufs[i]->format));
@@ -73,7 +87,7 @@ nv50_state_validate_fb(struct nv50_context *nv50)
                                level[fb->cbufs[i]->level].tile_mode << 4);
                so_data(so, 0x00000000);
 
-               so_method(so, tesla, 0x1224, 1);
+               so_method(so, tesla, NV50TCL_RT_ARRAY_MODE, 1);
                so_data  (so, 1);
        }
 
@@ -96,18 +110,10 @@ nv50_state_validate_fb(struct nv50_context *nv50)
                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_Z32_FLOAT:
-                       so_data(so, NV50TCL_ZETA_FORMAT_Z32_FLOAT);
-                       break;
-               case PIPE_FORMAT_Z24S8_UNORM:
-                       so_data(so, NV50TCL_ZETA_FORMAT_Z24S8_UNORM);
-                       break;
-               case PIPE_FORMAT_X8Z24_UNORM:
-                       so_data(so, NV50TCL_ZETA_FORMAT_X8Z24_UNORM);
-                       break;
-               case PIPE_FORMAT_S8Z24_UNORM:
-                       so_data(so, NV50TCL_ZETA_FORMAT_S8Z24_UNORM);
-                       break;
+               NV50_ZETA_FORMAT_CASE(S8Z24_UNORM);
+               NV50_ZETA_FORMAT_CASE(X8Z24_UNORM);
+               NV50_ZETA_FORMAT_CASE(Z24S8_UNORM);
+               NV50_ZETA_FORMAT_CASE(Z32_FLOAT);
                default:
                        NOUVEAU_ERR("AIIII unknown format %s\n",
                                    pf_name(fb->zsbuf->format));
@@ -118,19 +124,22 @@ nv50_state_validate_fb(struct nv50_context *nv50)
                                level[fb->zsbuf->level].tile_mode << 4);
                so_data(so, 0x00000000);
 
-               so_method(so, tesla, 0x1538, 1);
+               so_method(so, tesla, NV50TCL_ZETA_ENABLE, 1);
                so_data  (so, 1);
                so_method(so, tesla, NV50TCL_ZETA_HORIZ, 3);
                so_data  (so, fb->zsbuf->width);
                so_data  (so, fb->zsbuf->height);
                so_data  (so, 0x00010001);
+       } else {
+               so_method(so, tesla, NV50TCL_ZETA_ENABLE, 1);
+               so_data  (so, 0);
        }
 
-       so_method(so, tesla, NV50TCL_VIEWPORT_HORIZ, 2);
+       so_method(so, tesla, NV50TCL_VIEWPORT_HORIZ(0), 2);
        so_data  (so, w << 16);
        so_data  (so, h << 16);
        /* set window lower left corner */
-       so_method(so, tesla, NV50TCL_WINDOW_LEFT, 2);
+       so_method(so, tesla, NV50TCL_WINDOW_OFFSET_X, 2);
        so_data  (so, 0);
        so_data  (so, 0);
        /* set screen scissor rectangle */
@@ -146,12 +155,39 @@ nv50_state_validate_fb(struct nv50_context *nv50)
        so_ref(NULL, &so);
 }
 
+static void
+nv50_validate_samplers(struct nv50_context *nv50, struct nouveau_stateobj *so,
+                      unsigned p)
+{
+       struct nouveau_grobj *eng2d = nv50->screen->eng2d;
+       unsigned i, j, dw = nv50->sampler_nr[p] * 8;
+
+       if (!dw)
+               return;
+       nv50_so_init_sifc(nv50, so, nv50->screen->tsc, NOUVEAU_BO_VRAM,
+                         p * (32 * 8 * 4), dw * 4);
+
+       so_method(so, eng2d, NV50_2D_SIFC_DATA | (2 << 29), dw);
+
+       for (i = 0; i < nv50->sampler_nr[p]; ++i) {
+               if (nv50->sampler[p][i])
+                       so_datap(so, nv50->sampler[p][i]->tsc, 8);
+               else {
+                       for (j = 0; j < 8; ++j) /* you get punished */
+                               so_data(so, 0); /* ... for leaving holes */
+               }
+       }
+}
+
 static void
 nv50_state_emit(struct nv50_context *nv50)
 {
        struct nv50_screen *screen = nv50->screen;
        struct nouveau_channel *chan = screen->base.channel;
 
+       /* I don't want to copy headers from the winsys. */
+       screen->cur_ctx = nv50;
+
        if (nv50->pctx_id != screen->cur_pctx) {
                if (nv50->state.fb)
                        nv50->state.dirty |= NV50_NEW_FRAMEBUFFER;
@@ -192,7 +228,8 @@ nv50_state_emit(struct nv50_context *nv50)
                so_emit(chan, nv50->state.vertprog);
        if (nv50->state.dirty & NV50_NEW_FRAGPROG)
                so_emit(chan, nv50->state.fragprog);
-       if (nv50->state.dirty & (NV50_NEW_FRAGPROG | NV50_NEW_VERTPROG))
+       if (nv50->state.dirty & (NV50_NEW_FRAGPROG | NV50_NEW_VERTPROG |
+                                NV50_NEW_RASTERIZER))
                so_emit(chan, nv50->state.programs);
        if (nv50->state.dirty & NV50_NEW_RASTERIZER)
                so_emit(chan, nv50->state.rast);
@@ -222,6 +259,9 @@ nv50_state_flush_notify(struct nouveau_channel *chan)
 {
        struct nv50_context *nv50 = chan->user_private;
 
+       if (nv50->state.tic_upload && !(nv50->dirty & NV50_NEW_TEXTURE))
+               so_emit(chan, nv50->state.tic_upload);
+
        so_emit_reloc_markers(chan, nv50->state.fb);
        so_emit_reloc_markers(chan, nv50->state.vertprog);
        so_emit_reloc_markers(chan, nv50->state.fragprog);
@@ -251,14 +291,15 @@ nv50_state_validate(struct nv50_context *nv50)
        if (nv50->dirty & (NV50_NEW_FRAGPROG | NV50_NEW_FRAGPROG_CB))
                nv50_fragprog_validate(nv50);
 
-       if (nv50->dirty & (NV50_NEW_FRAGPROG | NV50_NEW_VERTPROG))
+       if (nv50->dirty & (NV50_NEW_FRAGPROG | NV50_NEW_VERTPROG |
+                          NV50_NEW_RASTERIZER))
                nv50_linkage_validate(nv50);
 
        if (nv50->dirty & NV50_NEW_RASTERIZER)
                so_ref(nv50->rasterizer->so, &nv50->state.rast);
 
        if (nv50->dirty & NV50_NEW_BLEND_COLOUR) {
-               so = so_new(5, 0);
+               so = so_new(1, 4, 0);
                so_method(so, tesla, NV50TCL_BLEND_COLOR(0), 4);
                so_data  (so, fui(nv50->blend_colour.color[0]));
                so_data  (so, fui(nv50->blend_colour.color[1]));
@@ -269,10 +310,10 @@ nv50_state_validate(struct nv50_context *nv50)
        }
 
        if (nv50->dirty & NV50_NEW_STIPPLE) {
-               so = so_new(33, 0);
+               so = so_new(1, 32, 0);
                so_method(so, tesla, NV50TCL_POLYGON_STIPPLE_PATTERN(0), 32);
                for (i = 0; i < 32; i++)
-                       so_data(so, nv50->stipple.stipple[i]);
+                       so_data(so, util_bswap32(nv50->stipple.stipple[i]));
                so_ref(so, &nv50->state.stipple);
                so_ref(NULL, &so);
        }
@@ -286,8 +327,8 @@ nv50_state_validate(struct nv50_context *nv50)
                        goto scissor_uptodate;
                nv50->state.scissor_enabled = rast->scissor;
 
-               so = so_new(3, 0);
-               so_method(so, tesla, NV50TCL_SCISSOR_HORIZ, 2);
+               so = so_new(1, 2, 0);
+               so_method(so, tesla, NV50TCL_SCISSOR_HORIZ(0), 2);
                if (nv50->state.scissor_enabled) {
                        so_data(so, (s->maxx << 16) | s->minx);
                        so_data(so, (s->maxy << 16) | s->miny);
@@ -315,13 +356,13 @@ scissor_uptodate:
                        goto viewport_uptodate;
                nv50->state.viewport_bypass = bypass;
 
-               so = so_new(14, 0);
+               so = so_new(5, 9, 0);
                if (!bypass) {
-                       so_method(so, tesla, NV50TCL_VIEWPORT_TRANSLATE(0), 3);
+                       so_method(so, tesla, NV50TCL_VIEWPORT_TRANSLATE_X(0), 3);
                        so_data  (so, fui(nv50->viewport.translate[0]));
                        so_data  (so, fui(nv50->viewport.translate[1]));
                        so_data  (so, fui(nv50->viewport.translate[2]));
-                       so_method(so, tesla, NV50TCL_VIEWPORT_SCALE(0), 3);
+                       so_method(so, tesla, NV50TCL_VIEWPORT_SCALE_X(0), 3);
                        so_data  (so, fui(nv50->viewport.scale[0]));
                        so_data  (so, fui(nv50->viewport.scale[1]));
                        so_data  (so, fui(nv50->viewport.scale[2]));
@@ -354,18 +395,20 @@ scissor_uptodate:
 viewport_uptodate:
 
        if (nv50->dirty & NV50_NEW_SAMPLER) {
-               int i;
+               unsigned nr = 0;
 
-               so = so_new(nv50->sampler_nr * 9 + 2, 0);
-               so_method(so, tesla, NV50TCL_CB_ADDR, 1);
-               so_data  (so, NV50_CB_TSC);
-               for (i = 0; i < nv50->sampler_nr; i++) {
-                       if (!nv50->sampler[i])
-                               continue;
+               for (i = 0; i < PIPE_SHADER_TYPES; ++i)
+                       nr += nv50->sampler_nr[i];
+
+               so = so_new(1+ 5 * PIPE_SHADER_TYPES, 1+ 19 * PIPE_SHADER_TYPES
+                                       + nr * 8, PIPE_SHADER_TYPES * 2);
+
+               nv50_validate_samplers(nv50, so, PIPE_SHADER_VERTEX);
+               nv50_validate_samplers(nv50, so, PIPE_SHADER_FRAGMENT);
+
+               so_method(so, tesla, 0x1334, 1); /* flush TSC */
+               so_data  (so, 0);
 
-                       so_method(so, tesla, NV50TCL_CB_DATA(0) | (2<<29), 8);
-                       so_datap (so, nv50->sampler[i]->tsc, 8);
-               }
                so_ref(so, &nv50->state.tsc_upload);
                so_ref(NULL, &so);
        }
@@ -383,3 +426,36 @@ viewport_uptodate:
        return TRUE;
 }
 
+void nv50_so_init_sifc(struct nv50_context *nv50,
+                      struct nouveau_stateobj *so,
+                      struct nouveau_bo *bo, unsigned reloc,
+                      unsigned offset, unsigned size)
+{
+       struct nouveau_grobj *eng2d = nv50->screen->eng2d;
+
+       reloc |= NOUVEAU_BO_WR;
+
+       so_method(so, eng2d, NV50_2D_DST_FORMAT, 2);
+       so_data  (so, NV50_2D_DST_FORMAT_R8_UNORM);
+       so_data  (so, 1);
+       so_method(so, eng2d, NV50_2D_DST_PITCH, 5);
+       so_data  (so, 262144);
+       so_data  (so, 65536);
+       so_data  (so, 1);
+       so_reloc (so, bo, offset, reloc | NOUVEAU_BO_HIGH, 0, 0);
+       so_reloc (so, bo, offset, reloc | NOUVEAU_BO_LOW, 0, 0);
+       so_method(so, eng2d, NV50_2D_SIFC_BITMAP_ENABLE, 2);
+       so_data  (so, 0);
+       so_data  (so, NV50_2D_SIFC_FORMAT_R8_UNORM);
+       so_method(so, eng2d, NV50_2D_SIFC_WIDTH, 10);
+       so_data  (so, size);
+       so_data  (so, 1);
+       so_data  (so, 0);
+       so_data  (so, 1);
+       so_data  (so, 0);
+       so_data  (so, 1);
+       so_data  (so, 0);
+       so_data  (so, 0);
+       so_data  (so, 0);
+       so_data  (so, 0);
+}
index 6bf6f773b0c26b075282175c1d3292a1e3ddd753..6378132979ed16e4af90083ad7e6ec4d6ab755b6 100644 (file)
@@ -62,6 +62,7 @@ nv50_surface_set(struct nv50_screen *screen, struct pipe_surface *ps, int dst)
                return 1;
 
        if (!bo->tile_flags) {
+               MARK_RING (chan, 9, 2); /* flush on lack of space or relocs */
                BEGIN_RING(chan, eng2d, mthd, 2);
                OUT_RING  (chan, format);
                OUT_RING  (chan, 1);
@@ -72,6 +73,7 @@ nv50_surface_set(struct nv50_screen *screen, struct pipe_surface *ps, int dst)
                OUT_RELOCh(chan, bo, ps->offset, flags);
                OUT_RELOCl(chan, bo, ps->offset, flags);
        } else {
+               MARK_RING (chan, 11, 2); /* flush on lack of space or relocs */
                BEGIN_RING(chan, eng2d, mthd, 5);
                OUT_RING  (chan, format);
                OUT_RING  (chan, 0);
@@ -174,11 +176,11 @@ nv50_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest,
        if (ret)
                return;
 
-       BEGIN_RING(chan, eng2d, 0x0580, 3);
-       OUT_RING  (chan, 4);
+       BEGIN_RING(chan, eng2d, NV50_2D_DRAW_SHAPE, 3);
+       OUT_RING  (chan, NV50_2D_DRAW_SHAPE_RECTANGLES);
        OUT_RING  (chan, format);
        OUT_RING  (chan, value);
-       BEGIN_RING(chan, eng2d, NV50_2D_RECT_X1, 4);
+       BEGIN_RING(chan, eng2d, NV50_2D_DRAW_POINT32_X(0), 4);
        OUT_RING  (chan, destx);
        OUT_RING  (chan, desty);
        OUT_RING  (chan, width);
index 72d33150af1abbb5d0da32e09ab52ff324f51bb3..bef548b728673684caca98afe605bbd9b60763ed 100644 (file)
 
 #include "nouveau/nouveau_stateobj.h"
 
+#include "util/u_format.h"
+
+#define _MIXED(pf, t0, t1, t2, t3, cr, cg, cb, ca, f)          \
+{                                                              \
+       PIPE_FORMAT_##pf,                                       \
+       NV50TIC_0_0_MAPR_##cr | NV50TIC_0_0_TYPER_##t0 |        \
+       NV50TIC_0_0_MAPG_##cg | NV50TIC_0_0_TYPEG_##t1 |        \
+       NV50TIC_0_0_MAPB_##cb | NV50TIC_0_0_TYPEB_##t2 |        \
+       NV50TIC_0_0_MAPA_##ca | NV50TIC_0_0_TYPEA_##t3 |        \
+       NV50TIC_0_0_FMT_##f                                     \
+}
+
+#define _(pf, t, cr, cg, cb, ca, f) _MIXED(pf, t, t, t, t, cr, cg, cb, ca, f)
+
+struct nv50_texture_format {
+       enum pipe_format pf;
+       uint32_t hw;
+};
+
+#define NV50_TEX_FORMAT_LIST_SIZE \
+       (sizeof(nv50_tex_format_list) / sizeof(struct nv50_texture_format))
+
+static const struct nv50_texture_format nv50_tex_format_list[] =
+{
+       _(A8R8G8B8_UNORM, UNORM, C2, C1, C0, C3,  8_8_8_8),
+       _(A8R8G8B8_SRGB,  UNORM, C2, C1, C0, C3,  8_8_8_8),
+       _(X8R8G8B8_UNORM, UNORM, C2, C1, C0, ONE, 8_8_8_8),
+       _(X8R8G8B8_SRGB,  UNORM, C2, C1, C0, ONE, 8_8_8_8),
+       _(A1R5G5B5_UNORM, UNORM, C2, C1, C0, C3,  1_5_5_5),
+       _(A4R4G4B4_UNORM, UNORM, C2, C1, C0, C3,  4_4_4_4),
+
+       _(R5G6B5_UNORM, UNORM, C2, C1, C0, ONE, 5_6_5),
+
+       _(L8_UNORM, UNORM, C0, C0, C0, ONE, 8),
+       _(A8_UNORM, UNORM, ZERO, ZERO, ZERO, C0, 8),
+       _(I8_UNORM, UNORM, C0, C0, C0, C0, 8),
+
+       _(A8L8_UNORM, UNORM, C0, C0, C0, C1, 8_8),
+
+       _(DXT1_RGB, UNORM, C0, C1, C2, ONE, DXT1),
+       _(DXT1_RGBA, UNORM, C0, C1, C2, C3, DXT1),
+       _(DXT3_RGBA, UNORM, C0, C1, C2, C3, DXT3),
+       _(DXT5_RGBA, UNORM, C0, C1, C2, C3, DXT5),
+
+       _MIXED(Z24S8_UNORM, UINT, UNORM, UINT, UINT, C1, C1, C1, ONE, 24_8),
+       _MIXED(S8Z24_UNORM, UNORM, UINT, UINT, UINT, C0, C0, C0, ONE, 8_24),
+
+       _(R16G16B16A16_SNORM, UNORM, C0, C1, C2, C3, 16_16_16_16),
+       _(R16G16B16A16_UNORM, SNORM, C0, C1, C2, C3, 16_16_16_16),
+       _(R32G32B32A32_FLOAT, FLOAT, C0, C1, C2, C3, 32_32_32_32),
+
+       _(R16G16_SNORM, SNORM, C0, C1, ZERO, ONE, 16_16),
+       _(R16G16_UNORM, UNORM, C0, C1, ZERO, ONE, 16_16),
+
+       _MIXED(Z32_FLOAT, FLOAT, UINT, UINT, UINT, C0, C0, C0, ONE, 32_DEPTH)
+
+};
+
+#undef _
+#undef _MIXED
+
 static int
 nv50_tex_construct(struct nv50_context *nv50, struct nouveau_stateobj *so,
-                  struct nv50_miptree *mt, int unit)
+                  struct nv50_miptree *mt, int unit, unsigned p)
 {
-       switch (mt->base.base.format) {
-       case PIPE_FORMAT_A8R8G8B8_UNORM:
-               so_data(so, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM |
-                           NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
-                           NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEG_UNORM |
-                           NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEB_UNORM |
-                           NV50TIC_0_0_FMT_8_8_8_8);
-               break;
-       case PIPE_FORMAT_X8R8G8B8_UNORM:
-               so_data(so, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM |
-                           NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
-                           NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEG_UNORM |
-                           NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEB_UNORM |
-                           NV50TIC_0_0_FMT_8_8_8_8);
-               break;
-       case PIPE_FORMAT_A1R5G5B5_UNORM:
-               so_data(so, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM |
-                           NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
-                           NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEG_UNORM |
-                           NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEB_UNORM |
-                           NV50TIC_0_0_FMT_1_5_5_5);
-               break;
-       case PIPE_FORMAT_A4R4G4B4_UNORM:
-               so_data(so, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM |
-                           NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
-                           NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEG_UNORM |
-                           NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEB_UNORM |
-                           NV50TIC_0_0_FMT_4_4_4_4);
-               break;
-       case PIPE_FORMAT_R5G6B5_UNORM:
-               so_data(so, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM |
-                           NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
-                           NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEG_UNORM |
-                           NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEB_UNORM |
-                           NV50TIC_0_0_FMT_5_6_5);
-               break;
-       case PIPE_FORMAT_L8_UNORM:
-               so_data(so, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM |
-                           NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
-                           NV50TIC_0_0_MAPG_C0 | NV50TIC_0_0_TYPEG_UNORM |
-                           NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEB_UNORM |
-                           NV50TIC_0_0_FMT_8);
-               break;
-       case PIPE_FORMAT_A8_UNORM:
-               so_data(so, NV50TIC_0_0_MAPA_C0 | NV50TIC_0_0_TYPEA_UNORM |
-                           NV50TIC_0_0_MAPR_ZERO | NV50TIC_0_0_TYPER_UNORM |
-                           NV50TIC_0_0_MAPG_ZERO | NV50TIC_0_0_TYPEG_UNORM |
-                           NV50TIC_0_0_MAPB_ZERO | NV50TIC_0_0_TYPEB_UNORM |
-                           NV50TIC_0_0_FMT_8);
-               break;
-       case PIPE_FORMAT_I8_UNORM:
-               so_data(so, NV50TIC_0_0_MAPA_C0 | NV50TIC_0_0_TYPEA_UNORM |
-                           NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
-                           NV50TIC_0_0_MAPG_C0 | NV50TIC_0_0_TYPEG_UNORM |
-                           NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEB_UNORM |
-                           NV50TIC_0_0_FMT_8);
-               break;
-       case PIPE_FORMAT_A8L8_UNORM:
-               so_data(so, NV50TIC_0_0_MAPA_C1 | NV50TIC_0_0_TYPEA_UNORM |
-                           NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
-                           NV50TIC_0_0_MAPG_C0 | NV50TIC_0_0_TYPEG_UNORM |
-                           NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEB_UNORM |
-                           NV50TIC_0_0_FMT_8_8);
-               break;
-       case PIPE_FORMAT_DXT1_RGB:
-               so_data(so, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM |
-                           NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
-                           NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEG_UNORM |
-                           NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEB_UNORM |
-                           NV50TIC_0_0_FMT_DXT1);
+       unsigned i;
+       uint32_t mode;
+       const struct util_format_description *desc;
+
+       for (i = 0; i < NV50_TEX_FORMAT_LIST_SIZE; i++)
+               if (nv50_tex_format_list[i].pf == mt->base.base.format)
+                       break;
+       if (i == NV50_TEX_FORMAT_LIST_SIZE)
+                return 1;
+
+       if (nv50->sampler[p][unit]->normalized)
+               mode = 0x50001000 | (1 << 31);
+       else {
+               mode = 0x50001000 | (7 << 14);
+               assert(mt->base.base.target == PIPE_TEXTURE_2D);
+       }
+
+       mode |= ((mt->base.bo->tile_mode & 0x0f) << 22) |
+               ((mt->base.bo->tile_mode & 0xf0) << 21);
+
+       desc = util_format_description(mt->base.base.format);
+       assert(desc);
+
+       if (desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB)
+               mode |= 0x0400;
+
+       switch (mt->base.base.target) {
+       case PIPE_TEXTURE_1D:
                break;
-       case PIPE_FORMAT_DXT1_RGBA:
-               so_data(so, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM |
-                           NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
-                           NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEG_UNORM |
-                           NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEB_UNORM |
-                           NV50TIC_0_0_FMT_DXT1);
+       case PIPE_TEXTURE_2D:
+               mode |= (1 << 14);
                break;
-       case PIPE_FORMAT_DXT3_RGBA:
-               so_data(so, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM |
-                           NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
-                           NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEG_UNORM |
-                           NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEB_UNORM |
-                           NV50TIC_0_0_FMT_DXT3);
+       case PIPE_TEXTURE_3D:
+               mode |= (2 << 14);
                break;
-       case PIPE_FORMAT_DXT5_RGBA:
-               so_data(so, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM |
-                           NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
-                           NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEG_UNORM |
-                           NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEB_UNORM |
-                           NV50TIC_0_0_FMT_DXT5);
+       case PIPE_TEXTURE_CUBE:
+               mode |= (3 << 14);
                break;
        default:
-               return 1;
+               assert(!"unsupported texture target");
+               break;
        }
 
+       so_data (so, nv50_tex_format_list[i].hw);
        so_reloc(so, mt->base.bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW |
-                    NOUVEAU_BO_RD, 0, 0);
-       if (nv50->sampler[unit]->normalized)
-               so_data (so, 0xd0005000 | mt->base.bo->tile_mode << 22);
-       else
-               so_data (so, 0x5001d000 | mt->base.bo->tile_mode << 22);
+                NOUVEAU_BO_RD, 0, 0);
+       so_data (so, mode);
        so_data (so, 0x00300000);
-       so_data (so, mt->base.base.width[0]);
+       so_data (so, mt->base.base.width0 | (1 << 31));
        so_data (so, (mt->base.base.last_level << 28) |
-                    (mt->base.base.depth[0] << 16) | mt->base.base.height[0]);
+                (mt->base.base.depth0 << 16) | mt->base.base.height0);
        so_data (so, 0x03000000);
        so_data (so, mt->base.base.last_level << 4);
 
        return 0;
 }
 
-void
-nv50_tex_validate(struct nv50_context *nv50)
+#ifndef NV50TCL_BIND_TIC
+#define NV50TCL_BIND_TIC(n) (0x1448 + 8 * n)
+#endif
+
+static boolean
+nv50_validate_textures(struct nv50_context *nv50, struct nouveau_stateobj *so,
+                      unsigned p)
 {
-       struct nouveau_grobj *tesla = nv50->screen->tesla;
-       struct nouveau_stateobj *so;
-       int unit, push;
+       static const unsigned p_remap[PIPE_SHADER_TYPES] = { 0, 2 };
 
-       push  = nv50->miptree_nr * 9 + 2;
-       push += MAX2(nv50->miptree_nr, nv50->state.miptree_nr) * 2;
+       struct nouveau_grobj *eng2d = nv50->screen->eng2d;
+       struct nouveau_grobj *tesla = nv50->screen->tesla;
+       unsigned unit, j, p_hw = p_remap[p];
 
-       so = so_new(push, nv50->miptree_nr * 2);
-       so_method(so, tesla, NV50TCL_CB_ADDR, 1);
-       so_data  (so, NV50_CB_TIC);
-       for (unit = 0; unit < nv50->miptree_nr; unit++) {
-               struct nv50_miptree *mt = nv50->miptree[unit];
+       nv50_so_init_sifc(nv50, so, nv50->screen->tic, NOUVEAU_BO_VRAM,
+                         p * (32 * 8 * 4), nv50->miptree_nr[p] * 8 * 4);
 
-               if (!mt)
-                       continue;
+       for (unit = 0; unit < nv50->miptree_nr[p]; ++unit) {
+               struct nv50_miptree *mt = nv50->miptree[p][unit];
 
-               so_method(so, tesla, NV50TCL_CB_DATA(0) | 0x40000000, 8);
-               if (nv50_tex_construct(nv50, so, mt, unit)) {
-                       NOUVEAU_ERR("failed tex validate\n");
-                       so_ref(NULL, &so);
-                       return;
+               so_method(so, eng2d, NV50_2D_SIFC_DATA | (2 << 29), 8);
+               if (mt) {
+                       if (nv50_tex_construct(nv50, so, mt, unit, p))
+                               return FALSE;
+                       /* Set TEX insn $t src binding $unit in program type p
+                        * to TIC, TSC entry (32 * p + unit), mark valid (1).
+                        */
+                       so_method(so, tesla, NV50TCL_BIND_TIC(p_hw), 1);
+                       so_data  (so, ((32 * p + unit) << 9) | (unit << 1) | 1);
+               } else {
+                       for (j = 0; j < 8; ++j)
+                               so_data(so, 0);
+                       so_method(so, tesla, NV50TCL_BIND_TIC(p_hw), 1);
+                       so_data  (so, (unit << 1) | 0);
                }
+       }
 
-               so_method(so, tesla, NV50TCL_SET_SAMPLER_TEX, 1);
-               so_data  (so, (unit << NV50TCL_SET_SAMPLER_TEX_TIC_SHIFT) |
-                       (unit << NV50TCL_SET_SAMPLER_TEX_SAMPLER_SHIFT) |
-                       NV50TCL_SET_SAMPLER_TEX_VALID);
+       for (; unit < nv50->state.miptree_nr[p]; unit++) {
+               /* Make other bindings invalid. */
+               so_method(so, tesla, NV50TCL_BIND_TIC(p_hw), 1);
+               so_data  (so, (unit << 1) | 0);
        }
 
-       for (; unit < nv50->state.miptree_nr; unit++) {
-               so_method(so, tesla, NV50TCL_SET_SAMPLER_TEX, 1);
-               so_data  (so,
-                       (unit << NV50TCL_SET_SAMPLER_TEX_SAMPLER_SHIFT) | 0);
+       nv50->state.miptree_nr[p] = nv50->miptree_nr[p];
+       return TRUE;
+}
+
+void
+nv50_tex_validate(struct nv50_context *nv50)
+{
+       struct nouveau_stateobj *so;
+       struct nouveau_grobj *tesla = nv50->screen->tesla;
+       unsigned p, start, push, nrlc;
+
+       for (nrlc = 0, start = 0, push = 0, p = 0; p < PIPE_SHADER_TYPES; ++p) {
+               start += MAX2(nv50->miptree_nr[p], nv50->state.miptree_nr[p]);
+               push += MAX2(nv50->miptree_nr[p], nv50->state.miptree_nr[p]);
+               nrlc += nv50->miptree_nr[p];
        }
+       start = start * 2 + 4 * PIPE_SHADER_TYPES + 2;
+       push = push * 9 + 19 * PIPE_SHADER_TYPES + 2;
+       nrlc = nrlc * 2 + 2 * PIPE_SHADER_TYPES;
+
+       so = so_new(start, push, nrlc);
+
+       if (nv50_validate_textures(nv50, so, PIPE_SHADER_VERTEX) == FALSE ||
+           nv50_validate_textures(nv50, so, PIPE_SHADER_FRAGMENT) == FALSE) {
+               so_ref(NULL, &so);
+
+               NOUVEAU_ERR("failed tex validate\n");
+               return;
+       }
+
+       /* not sure if the following really do what I think: */
+       so_method(so, tesla, 0x1330, 1); /* flush TIC */
+       so_data  (so, 0);
+       so_method(so, tesla, 0x1338, 1); /* flush texture caches */
+       so_data  (so, 0x20);
 
        so_ref(so, &nv50->state.tic_upload);
        so_ref(NULL, &so);
-       nv50->state.miptree_nr = nv50->miptree_nr;
 }
-
index 207fb039f70eab9a4d6f1ef104a3e96e77701045..b870302019a80359d63eba90e176d5e4045f2ee2 100644 (file)
 #define NV50TIC_0_0_TYPEA_MASK                                    0x00038000
 #define NV50TIC_0_0_TYPEA_UNORM                                   0x00010000
 #define NV50TIC_0_0_TYPEA_SNORM                                   0x00008000
+#define NV50TIC_0_0_TYPEA_SINT                                    0x00018000
+#define NV50TIC_0_0_TYPEA_UINT                                    0x00020000
 #define NV50TIC_0_0_TYPEA_FLOAT                                   0x00038000
 #define NV50TIC_0_0_TYPEB_MASK                                    0x00007000
 #define NV50TIC_0_0_TYPEB_UNORM                                   0x00002000
 #define NV50TIC_0_0_TYPEB_SNORM                                   0x00001000
+#define NV50TIC_0_0_TYPEB_SINT                                    0x00003000
+#define NV50TIC_0_0_TYPEB_UINT                                    0x00004000
 #define NV50TIC_0_0_TYPEB_FLOAT                                   0x00007000
 #define NV50TIC_0_0_TYPEG_MASK                                    0x00000e00
 #define NV50TIC_0_0_TYPEG_UNORM                                   0x00000400
 #define NV50TIC_0_0_TYPEG_SNORM                                   0x00000200
+#define NV50TIC_0_0_TYPEG_SINT                                    0x00000600
+#define NV50TIC_0_0_TYPEG_UINT                                    0x00000800
 #define NV50TIC_0_0_TYPEG_FLOAT                                   0x00000e00
 #define NV50TIC_0_0_TYPER_MASK                                    0x000001c0
 #define NV50TIC_0_0_TYPER_UNORM                                   0x00000080
 #define NV50TIC_0_0_TYPER_SNORM                                   0x00000040
+#define NV50TIC_0_0_TYPER_SINT                                    0x000000c0
+#define NV50TIC_0_0_TYPER_UINT                                    0x00000100
 #define NV50TIC_0_0_TYPER_FLOAT                                   0x000001c0
 #define NV50TIC_0_0_FMT_MASK                                      0x0000003f
 #define NV50TIC_0_0_FMT_32_32_32_32                               0x00000001
@@ -57,6 +65,7 @@
 #define NV50TIC_0_0_FMT_32_32                                     0x00000004
 #define NV50TIC_0_0_FMT_8_8_8_8                                   0x00000008
 #define NV50TIC_0_0_FMT_2_10_10_10                                0x00000009
+#define NV50TIC_0_0_FMT_16_16                                     0x0000000c
 #define NV50TIC_0_0_FMT_32                                        0x0000000f
 #define NV50TIC_0_0_FMT_4_4_4_4                                   0x00000012
 /* #define NV50TIC_0_0_FMT_1_5_5_5                                0x00000013 */
 #define NV50TIC_0_0_FMT_8_8                                       0x00000018
 #define NV50TIC_0_0_FMT_16                                        0x0000001b
 #define NV50TIC_0_0_FMT_8                                         0x0000001d
+#define NV50TIC_0_0_FMT_5_9_9_9                                   0x00000020
 #define NV50TIC_0_0_FMT_10_11_11                                  0x00000021
 #define NV50TIC_0_0_FMT_DXT1                                      0x00000024
 #define NV50TIC_0_0_FMT_DXT3                                      0x00000025
 #define NV50TIC_0_0_FMT_DXT5                                      0x00000026
 #define NV50TIC_0_0_FMT_RGTC1                                     0x00000027
 #define NV50TIC_0_0_FMT_RGTC2                                     0x00000028
+#define NV50TIC_0_0_FMT_24_8                                      0x00000029
+#define NV50TIC_0_0_FMT_8_24                                      0x0000002a
+#define NV50TIC_0_0_FMT_32_DEPTH                                  0x0000002f
+#define NV50TIC_0_0_FMT_32_8                                      0x00000030
 
 #define NV50TIC_0_1_OFFSET_LOW_MASK                               0xffffffff
 #define NV50TIC_0_1_OFFSET_LOW_SHIFT                                       0
 #define NV50TSC_1_1_MIPF_NEAREST                                 0x00000080
 #define NV50TSC_1_1_MIPF_LINEAR                                  0x000000c0
 #define NV50TSC_1_1_LOD_BIAS_MASK                                0x01fff000
+#define NV50TSC_1_1_UNKN_ANISO_15                                0x10000000
+#define NV50TSC_1_1_UNKN_ANISO_35                                0x18000000
 
 #define NV50TSC_1_2_MIN_LOD_MASK                                 0x00000f00
 #define NV50TSC_1_2_MAX_LOD_MASK                                 0x00f00000
index 9c289026bbb14498adccdfa5f1ee602794c71416..a2f1db2914cf7523443fb1babee3196473463569 100644 (file)
@@ -1,6 +1,8 @@
 
 #include "pipe/p_context.h"
 #include "pipe/p_inlines.h"
+#include "util/u_format.h"
+#include "util/u_math.h"
 
 #include "nv50_context.h"
 
@@ -12,18 +14,22 @@ struct nv50_transfer {
        int level_pitch;
        int level_width;
        int level_height;
+       int level_depth;
        int level_x;
        int level_y;
+       int level_z;
+       unsigned nblocksx;
+       unsigned nblocksy;
 };
 
 static void
 nv50_transfer_rect_m2mf(struct pipe_screen *pscreen,
                        struct nouveau_bo *src_bo, unsigned src_offset,
                        int src_pitch, unsigned src_tile_mode,
-                       int sx, int sy, int sw, int sh,
+                       int sx, int sy, int sz, int sw, int sh, int sd,
                        struct nouveau_bo *dst_bo, unsigned dst_offset,
                        int dst_pitch, unsigned dst_tile_mode,
-                       int dx, int dy, int dw, int dh,
+                       int dx, int dy, int dz, int dw, int dh, int dd,
                        int cpp, int width, int height,
                        unsigned src_reloc, unsigned dst_reloc)
 {
@@ -41,7 +47,7 @@ nv50_transfer_rect_m2mf(struct pipe_screen *pscreen,
                        NV50_MEMORY_TO_MEMORY_FORMAT_LINEAR_IN, 1);
                OUT_RING  (chan, 1);
                BEGIN_RING(chan, m2mf,
-                       NV50_MEMORY_TO_MEMORY_FORMAT_PITCH_IN, 1);
+                       NV04_MEMORY_TO_MEMORY_FORMAT_PITCH_IN, 1);
                OUT_RING  (chan, src_pitch);
                src_offset += (sy * src_pitch) + (sx * cpp);
        } else {
@@ -51,8 +57,8 @@ nv50_transfer_rect_m2mf(struct pipe_screen *pscreen,
                OUT_RING  (chan, src_tile_mode << 4);
                OUT_RING  (chan, sw * cpp);
                OUT_RING  (chan, sh);
-               OUT_RING  (chan, 1);
-               OUT_RING  (chan, 0);
+               OUT_RING  (chan, sd);
+               OUT_RING  (chan, sz); /* copying only 1 zslice per call */
        }
 
        if (!dst_bo->tile_flags) {
@@ -60,7 +66,7 @@ nv50_transfer_rect_m2mf(struct pipe_screen *pscreen,
                        NV50_MEMORY_TO_MEMORY_FORMAT_LINEAR_OUT, 1);
                OUT_RING  (chan, 1);
                BEGIN_RING(chan, m2mf,
-                       NV50_MEMORY_TO_MEMORY_FORMAT_PITCH_OUT, 1);
+                       NV04_MEMORY_TO_MEMORY_FORMAT_PITCH_OUT, 1);
                OUT_RING  (chan, dst_pitch);
                dst_offset += (dy * dst_pitch) + (dx * cpp);
        } else {
@@ -70,20 +76,20 @@ nv50_transfer_rect_m2mf(struct pipe_screen *pscreen,
                OUT_RING  (chan, dst_tile_mode << 4);
                OUT_RING  (chan, dw * cpp);
                OUT_RING  (chan, dh);
-               OUT_RING  (chan, 1);
-               OUT_RING  (chan, 0);
+               OUT_RING  (chan, dd);
+               OUT_RING  (chan, dz); /* copying only 1 zslice per call */
        }
 
        while (height) {
                int line_count = height > 2047 ? 2047 : height;
 
-               WAIT_RING (chan, 15);
+               MARK_RING (chan, 15, 4); /* flush on lack of space or relocs */
                BEGIN_RING(chan, m2mf,
                        NV50_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN_HIGH, 2);
                OUT_RELOCh(chan, src_bo, src_offset, src_reloc);
                OUT_RELOCh(chan, dst_bo, dst_offset, dst_reloc);
                BEGIN_RING(chan, m2mf,
-                       NV50_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN, 2);
+                       NV04_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN, 2);
                OUT_RELOCl(chan, src_bo, src_offset, src_reloc);
                OUT_RELOCl(chan, dst_bo, dst_offset, dst_reloc);
                if (src_bo->tile_flags) {
@@ -101,7 +107,7 @@ nv50_transfer_rect_m2mf(struct pipe_screen *pscreen,
                        dst_offset += (line_count * dst_pitch);
                }
                BEGIN_RING(chan, m2mf,
-                       NV50_MEMORY_TO_MEMORY_FORMAT_LINE_LENGTH_IN, 4);
+                       NV04_MEMORY_TO_MEMORY_FORMAT_LINE_LENGTH_IN, 4);
                OUT_RING  (chan, width * cpp);
                OUT_RING  (chan, line_count);
                OUT_RING  (chan, 0x00000101);
@@ -124,52 +130,54 @@ nv50_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
        struct nv50_miptree *mt = nv50_miptree(pt);
        struct nv50_miptree_level *lvl = &mt->level[level];
        struct nv50_transfer *tx;
-       unsigned image = 0;
+       unsigned nx, ny, image = 0;
        int ret;
 
        if (pt->target == PIPE_TEXTURE_CUBE)
                image = face;
-       else
-       if (pt->target == PIPE_TEXTURE_3D)
-               image = zslice;
 
        tx = CALLOC_STRUCT(nv50_transfer);
        if (!tx)
                return NULL;
 
        pipe_texture_reference(&tx->base.texture, pt);
-       tx->base.format = pt->format;
+       tx->nblocksx = util_format_get_nblocksx(pt->format, u_minify(pt->width0, level));
+       tx->nblocksy = util_format_get_nblocksy(pt->format, u_minify(pt->height0, level));
        tx->base.width = w;
        tx->base.height = h;
-       tx->base.block = pt->block;
-       tx->base.nblocksx = pt->nblocksx[level];
-       tx->base.nblocksy = pt->nblocksy[level];
-       tx->base.stride = (w * pt->block.size);
+       tx->base.stride = tx->nblocksx * util_format_get_blocksize(pt->format);
        tx->base.usage = usage;
 
        tx->level_pitch = lvl->pitch;
-       tx->level_width = mt->base.base.width[level];
-       tx->level_height = mt->base.base.height[level];
+       tx->level_width = u_minify(mt->base.base.width0, level);
+       tx->level_height = u_minify(mt->base.base.height0, level);
+       tx->level_depth = u_minify(mt->base.base.depth0, level);
        tx->level_offset = lvl->image_offset[image];
        tx->level_tiling = lvl->tile_mode;
-       tx->level_x = x;
-       tx->level_y = y;
+       tx->level_z = zslice;
+       tx->level_x = util_format_get_nblocksx(pt->format, x);
+       tx->level_y = util_format_get_nblocksy(pt->format, y);
        ret = nouveau_bo_new(dev, NOUVEAU_BO_GART | NOUVEAU_BO_MAP, 0,
-                            w * pt->block.size * h, &tx->bo);
+                            tx->nblocksy * tx->base.stride, &tx->bo);
        if (ret) {
                FREE(tx);
                return NULL;
        }
 
        if (usage & PIPE_TRANSFER_READ) {
+               nx = util_format_get_nblocksx(pt->format, tx->base.width);
+               ny = util_format_get_nblocksy(pt->format, tx->base.height);
+
                nv50_transfer_rect_m2mf(pscreen, mt->base.bo, tx->level_offset,
                                        tx->level_pitch, tx->level_tiling,
-                                       x, y,
-                                       tx->level_width, tx->level_height,
-                                       tx->bo, 0, tx->base.stride,
-                                       tx->bo->tile_mode, 0, 0,
-                                       tx->base.width, tx->base.height,
-                                       tx->base.block.size, w, h,
+                                       x, y, zslice,
+                                       tx->nblocksx, tx->nblocksy,
+                                       tx->level_depth,
+                                       tx->bo, 0,
+                                       tx->base.stride, tx->bo->tile_mode,
+                                       0, 0, 0,
+                                       tx->nblocksx, tx->nblocksy, 1,
+                                       util_format_get_blocksize(pt->format), nx, ny,
                                        NOUVEAU_BO_VRAM | NOUVEAU_BO_GART,
                                        NOUVEAU_BO_GART);
        }
@@ -182,18 +190,24 @@ nv50_transfer_del(struct pipe_transfer *ptx)
 {
        struct nv50_transfer *tx = (struct nv50_transfer *)ptx;
        struct nv50_miptree *mt = nv50_miptree(ptx->texture);
+       struct pipe_texture *pt = ptx->texture;
+
+       unsigned nx = util_format_get_nblocksx(pt->format, tx->base.width);
+       unsigned ny = util_format_get_nblocksy(pt->format, tx->base.height);
 
        if (ptx->usage & PIPE_TRANSFER_WRITE) {
-               struct pipe_screen *pscreen = ptx->texture->screen;
-               nv50_transfer_rect_m2mf(pscreen, tx->bo, 0, tx->base.stride,
-                                       tx->bo->tile_mode, 0, 0,
-                                       tx->base.width, tx->base.height,
+               struct pipe_screen *pscreen = pt->screen;
+
+               nv50_transfer_rect_m2mf(pscreen, tx->bo, 0,
+                                       tx->base.stride, tx->bo->tile_mode,
+                                       0, 0, 0,
+                                       tx->nblocksx, tx->nblocksy, 1,
                                        mt->base.bo, tx->level_offset,
                                        tx->level_pitch, tx->level_tiling,
-                                       tx->level_x, tx->level_y,
-                                       tx->level_width, tx->level_height,
-                                       tx->base.block.size, tx->base.width,
-                                       tx->base.height,
+                                       tx->level_x, tx->level_y, tx->level_z,
+                                       tx->nblocksx, tx->nblocksy,
+                                       tx->level_depth,
+                                       util_format_get_blocksize(pt->format), nx, ny,
                                        NOUVEAU_BO_GART, NOUVEAU_BO_VRAM |
                                        NOUVEAU_BO_GART);
        }
@@ -237,3 +251,89 @@ nv50_transfer_init_screen_functions(struct pipe_screen *pscreen)
        pscreen->transfer_map = nv50_transfer_map;
        pscreen->transfer_unmap = nv50_transfer_unmap;
 }
+
+void
+nv50_upload_sifc(struct nv50_context *nv50,
+                struct nouveau_bo *bo, unsigned dst_offset, unsigned reloc,
+                unsigned dst_format, int dst_w, int dst_h, int dst_pitch,
+                void *src, unsigned src_format, int src_pitch,
+                int x, int y, int w, int h, int cpp)
+{
+       struct nouveau_channel *chan = nv50->screen->base.channel;
+       struct nouveau_grobj *eng2d = nv50->screen->eng2d;
+       struct nouveau_grobj *tesla = nv50->screen->tesla;
+       unsigned line_dwords = (w * cpp + 3) / 4;
+
+       reloc |= NOUVEAU_BO_WR;
+
+       MARK_RING (chan, 32, 2); /* flush on lack of space or relocs */
+
+       if (bo->tile_flags) {
+               BEGIN_RING(chan, eng2d, NV50_2D_DST_FORMAT, 5);
+               OUT_RING  (chan, dst_format);
+               OUT_RING  (chan, 0);
+               OUT_RING  (chan, bo->tile_mode << 4);
+               OUT_RING  (chan, 1);
+               OUT_RING  (chan, 0);
+       } else {
+               BEGIN_RING(chan, eng2d, NV50_2D_DST_FORMAT, 2);
+               OUT_RING  (chan, dst_format);
+               OUT_RING  (chan, 1);
+               BEGIN_RING(chan, eng2d, NV50_2D_DST_PITCH, 1);
+               OUT_RING  (chan, dst_pitch);
+       }
+
+       BEGIN_RING(chan, eng2d, NV50_2D_DST_WIDTH, 4);
+       OUT_RING  (chan, dst_w);
+       OUT_RING  (chan, dst_h);
+       OUT_RELOCh(chan, bo, dst_offset, reloc);
+       OUT_RELOCl(chan, bo, dst_offset, reloc);
+
+       /* NV50_2D_OPERATION_SRCCOPY assumed already set */
+
+       BEGIN_RING(chan, eng2d, NV50_2D_SIFC_BITMAP_ENABLE, 2);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, src_format);
+       BEGIN_RING(chan, eng2d, NV50_2D_SIFC_WIDTH, 10);
+       OUT_RING  (chan, w);
+       OUT_RING  (chan, h);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 1);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, 1);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, x);
+       OUT_RING  (chan, 0);
+       OUT_RING  (chan, y);
+
+       while (h--) {
+               const uint32_t *p = src;
+               unsigned count = line_dwords;
+
+               while (count) {
+                       unsigned nr = MIN2(count, 1792);
+
+                       if (chan->pushbuf->remaining <= nr) {
+                               FIRE_RING (chan);
+
+                               BEGIN_RING(chan, eng2d,
+                                          NV50_2D_DST_ADDRESS_HIGH, 2);
+                               OUT_RELOCh(chan, bo, dst_offset, reloc);
+                               OUT_RELOCl(chan, bo, dst_offset, reloc);
+                       }
+                       assert(chan->pushbuf->remaining > nr);
+
+                       BEGIN_RING(chan, eng2d,
+                                  NV50_2D_SIFC_DATA | (2 << 29), nr);
+                       OUT_RINGp (chan, p, nr);
+
+                       p += nr;
+                       count -= nr;
+               }
+
+               src += src_pitch;
+       }
+
+       BEGIN_RING(chan, tesla, NV50TCL_CODE_CB_FLUSH, 1);
+       OUT_RING  (chan, 0);
+}
index eeed148c7b904bfd4b79c06ee846dd4359d47d3b..f2e510fba6181df3cb646866b64f3e275cbc060e 100644 (file)
 #include "pipe/p_state.h"
 #include "pipe/p_inlines.h"
 
+#include "util/u_format.h"
+
 #include "nv50_context.h"
 
+static boolean
+nv50_push_elements_u08(struct nv50_context *, uint8_t *, unsigned);
+
+static boolean
+nv50_push_elements_u16(struct nv50_context *, uint16_t *, unsigned);
+
+static boolean
+nv50_push_elements_u32(struct nv50_context *, uint32_t *, unsigned);
+
+static boolean
+nv50_push_arrays(struct nv50_context *, unsigned, unsigned);
+
 static INLINE unsigned
 nv50_prim(unsigned mode)
 {
@@ -50,18 +64,25 @@ nv50_prim(unsigned mode)
 }
 
 static INLINE uint32_t
-nv50_vbo_type_to_hw(unsigned type)
+nv50_vbo_type_to_hw(enum pipe_format format)
 {
-       switch (type) {
-       case PIPE_FORMAT_TYPE_FLOAT:
+       const struct util_format_description *desc;
+
+       desc = util_format_description(format);
+       assert(desc);
+
+       switch (desc->channel[0].type) {
+       case UTIL_FORMAT_TYPE_FLOAT:
                return NV50TCL_VERTEX_ARRAY_ATTRIB_TYPE_FLOAT;
-       case PIPE_FORMAT_TYPE_UNORM:
-               return NV50TCL_VERTEX_ARRAY_ATTRIB_TYPE_UNORM;
-       case PIPE_FORMAT_TYPE_SNORM:
-               return NV50TCL_VERTEX_ARRAY_ATTRIB_TYPE_SNORM;
-       case PIPE_FORMAT_TYPE_USCALED:
+       case UTIL_FORMAT_TYPE_UNSIGNED:
+               if (desc->channel[0].normalized) {
+                       return NV50TCL_VERTEX_ARRAY_ATTRIB_TYPE_UNORM;
+               }
                return NV50TCL_VERTEX_ARRAY_ATTRIB_TYPE_USCALED;
-       case PIPE_FORMAT_TYPE_SSCALED:
+       case UTIL_FORMAT_TYPE_SIGNED:
+               if (desc->channel[0].normalized) {
+                       return NV50TCL_VERTEX_ARRAY_ATTRIB_TYPE_SNORM;
+               }
                return NV50TCL_VERTEX_ARRAY_ATTRIB_TYPE_SSCALED;
        /*
        case PIPE_FORMAT_TYPE_UINT:
@@ -78,19 +99,19 @@ nv50_vbo_size_to_hw(unsigned size, unsigned nr_c)
 {
        static const uint32_t hw_values[] = {
                0, 0, 0, 0,
-               NV50TCL_VERTEX_ARRAY_ATTRIB_SIZE_8,
-               NV50TCL_VERTEX_ARRAY_ATTRIB_SIZE_8_8,
-               NV50TCL_VERTEX_ARRAY_ATTRIB_SIZE_8_8_8,
-               NV50TCL_VERTEX_ARRAY_ATTRIB_SIZE_8_8_8_8,
-               NV50TCL_VERTEX_ARRAY_ATTRIB_SIZE_16,
-               NV50TCL_VERTEX_ARRAY_ATTRIB_SIZE_16_16,
-               NV50TCL_VERTEX_ARRAY_ATTRIB_SIZE_16_16_16,
-               NV50TCL_VERTEX_ARRAY_ATTRIB_SIZE_16_16_16_16,
+               NV50TCL_VERTEX_ARRAY_ATTRIB_FORMAT_8,
+               NV50TCL_VERTEX_ARRAY_ATTRIB_FORMAT_8_8,
+               NV50TCL_VERTEX_ARRAY_ATTRIB_FORMAT_8_8_8,
+               NV50TCL_VERTEX_ARRAY_ATTRIB_FORMAT_8_8_8_8,
+               NV50TCL_VERTEX_ARRAY_ATTRIB_FORMAT_16,
+               NV50TCL_VERTEX_ARRAY_ATTRIB_FORMAT_16_16,
+               NV50TCL_VERTEX_ARRAY_ATTRIB_FORMAT_16_16_16,
+               NV50TCL_VERTEX_ARRAY_ATTRIB_FORMAT_16_16_16_16,
                0, 0, 0, 0,
-               NV50TCL_VERTEX_ARRAY_ATTRIB_SIZE_32,
-               NV50TCL_VERTEX_ARRAY_ATTRIB_SIZE_32_32,
-               NV50TCL_VERTEX_ARRAY_ATTRIB_SIZE_32_32_32,
-               NV50TCL_VERTEX_ARRAY_ATTRIB_SIZE_32_32_32_32 };
+               NV50TCL_VERTEX_ARRAY_ATTRIB_FORMAT_32,
+               NV50TCL_VERTEX_ARRAY_ATTRIB_FORMAT_32_32,
+               NV50TCL_VERTEX_ARRAY_ATTRIB_FORMAT_32_32_32,
+               NV50TCL_VERTEX_ARRAY_ATTRIB_FORMAT_32_32_32_32 };
 
        /* we'd also have R11G11B10 and R10G10B10A2 */
 
@@ -108,9 +129,15 @@ nv50_vbo_vtxelt_to_hw(struct pipe_vertex_element *ve)
 {
        uint32_t hw_type, hw_size;
        enum pipe_format pf = ve->src_format;
-       unsigned size = pf_size_x(pf) << pf_exp2(pf);
+       const struct util_format_description *desc;
+       unsigned size;
+
+       desc = util_format_description(pf);
+       assert(desc);
 
-       hw_type = nv50_vbo_type_to_hw(pf_type(pf));
+       size = util_format_get_component_bits(pf, UTIL_FORMAT_COLORSPACE_RGB, 0);
+
+       hw_type = nv50_vbo_type_to_hw(pf);
        hw_size = nv50_vbo_size_to_hw(size, ve->nr_components);
 
        if (!hw_type || !hw_size) {
@@ -119,19 +146,20 @@ nv50_vbo_vtxelt_to_hw(struct pipe_vertex_element *ve)
                return 0x24e80000;
        }
 
-       if (pf_swizzle_x(pf) == 2) /* BGRA */
+       if (desc->swizzle[0] == UTIL_FORMAT_SWIZZLE_Z) /* BGRA */
                hw_size |= (1 << 31); /* no real swizzle bits :-( */
 
        return (hw_type | hw_size);
 }
 
-boolean
+void
 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->tesla->channel;
        struct nouveau_grobj *tesla = nv50->screen->tesla;
+       boolean ret;
 
        nv50_state_validate(nv50);
 
@@ -139,24 +167,27 @@ nv50_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start,
        OUT_RING  (chan, 0);
        BEGIN_RING(chan, tesla, 0x142c, 1);
        OUT_RING  (chan, 0);
-       BEGIN_RING(chan, tesla, 0x1440, 1);
-       OUT_RING  (chan, 0);
-       BEGIN_RING(chan, tesla, 0x1334, 1);
-       OUT_RING  (chan, 0);
 
        BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BEGIN, 1);
        OUT_RING  (chan, nv50_prim(mode));
-       BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BUFFER_FIRST, 2);
-       OUT_RING  (chan, start);
-       OUT_RING  (chan, count);
+
+       if (nv50->vbo_fifo)
+               ret = nv50_push_arrays(nv50, start, count);
+       else {
+               BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BUFFER_FIRST, 2);
+               OUT_RING  (chan, start);
+               OUT_RING  (chan, count);
+               ret = TRUE;
+       }
        BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1);
        OUT_RING  (chan, 0);
 
-       pipe->flush(pipe, 0, NULL);
-       return TRUE;
+        /* XXX: not sure what to do if ret != TRUE: flush and retry?
+         */
+        assert(ret);
 }
 
-static INLINE void
+static INLINE boolean
 nv50_draw_elements_inline_u08(struct nv50_context *nv50, uint8_t *map,
                              unsigned start, unsigned count)
 {
@@ -165,8 +196,11 @@ nv50_draw_elements_inline_u08(struct nv50_context *nv50, uint8_t *map,
 
        map += start;
 
+       if (nv50->vbo_fifo)
+               return nv50_push_elements_u08(nv50, map, count);
+
        if (count & 1) {
-               BEGIN_RING(chan, tesla, 0x15e8, 1);
+               BEGIN_RING(chan, tesla, NV50TCL_VB_ELEMENT_U32, 1);
                OUT_RING  (chan, map[0]);
                map++;
                count--;
@@ -176,16 +210,17 @@ nv50_draw_elements_inline_u08(struct nv50_context *nv50, uint8_t *map,
                unsigned nr = count > 2046 ? 2046 : count;
                int i;
 
-               BEGIN_RING(chan, tesla, 0x400015f0, nr >> 1);
+               BEGIN_RING(chan, tesla, NV50TCL_VB_ELEMENT_U16 | 0x40000000, nr >> 1);
                for (i = 0; i < nr; i += 2)
                        OUT_RING  (chan, (map[i + 1] << 16) | map[i]);
 
                count -= nr;
                map += nr;
        }
+       return TRUE;
 }
 
-static INLINE void
+static INLINE boolean
 nv50_draw_elements_inline_u16(struct nv50_context *nv50, uint16_t *map,
                              unsigned start, unsigned count)
 {
@@ -194,8 +229,11 @@ nv50_draw_elements_inline_u16(struct nv50_context *nv50, uint16_t *map,
 
        map += start;
 
+       if (nv50->vbo_fifo)
+               return nv50_push_elements_u16(nv50, map, count);
+
        if (count & 1) {
-               BEGIN_RING(chan, tesla, 0x15e8, 1);
+               BEGIN_RING(chan, tesla, NV50TCL_VB_ELEMENT_U32, 1);
                OUT_RING  (chan, map[0]);
                map++;
                count--;
@@ -205,16 +243,17 @@ nv50_draw_elements_inline_u16(struct nv50_context *nv50, uint16_t *map,
                unsigned nr = count > 2046 ? 2046 : count;
                int i;
 
-               BEGIN_RING(chan, tesla, 0x400015f0, nr >> 1);
+               BEGIN_RING(chan, tesla, NV50TCL_VB_ELEMENT_U16 | 0x40000000, nr >> 1);
                for (i = 0; i < nr; i += 2)
                        OUT_RING  (chan, (map[i + 1] << 16) | map[i]);
 
                count -= nr;
                map += nr;
        }
+       return TRUE;
 }
 
-static INLINE void
+static INLINE boolean
 nv50_draw_elements_inline_u32(struct nv50_context *nv50, uint32_t *map,
                              unsigned start, unsigned count)
 {
@@ -223,18 +262,22 @@ nv50_draw_elements_inline_u32(struct nv50_context *nv50, uint32_t *map,
 
        map += start;
 
+       if (nv50->vbo_fifo)
+               return nv50_push_elements_u32(nv50, map, count);
+
        while (count) {
                unsigned nr = count > 2047 ? 2047 : count;
 
-               BEGIN_RING(chan, tesla, 0x400015e8, nr);
+               BEGIN_RING(chan, tesla, NV50TCL_VB_ELEMENT_U32 | 0x40000000, nr);
                OUT_RINGp (chan, map, nr);
 
                count -= nr;
                map += nr;
        }
+       return TRUE;
 }
 
-boolean
+void
 nv50_draw_elements(struct pipe_context *pipe,
                   struct pipe_buffer *indexBuffer, unsigned indexSize,
                   unsigned mode, unsigned start, unsigned count)
@@ -244,6 +287,7 @@ nv50_draw_elements(struct pipe_context *pipe,
        struct nouveau_grobj *tesla = nv50->screen->tesla;
        struct pipe_screen *pscreen = pipe->screen;
        void *map;
+       boolean ret;
        
        map = pipe_buffer_map(pscreen, indexBuffer, PIPE_BUFFER_USAGE_CPU_READ);
 
@@ -258,23 +302,27 @@ nv50_draw_elements(struct pipe_context *pipe,
        OUT_RING  (chan, nv50_prim(mode));
        switch (indexSize) {
        case 1:
-               nv50_draw_elements_inline_u08(nv50, map, start, count);
+               ret = nv50_draw_elements_inline_u08(nv50, map, start, count);
                break;
        case 2:
-               nv50_draw_elements_inline_u16(nv50, map, start, count);
+               ret = nv50_draw_elements_inline_u16(nv50, map, start, count);
                break;
        case 4:
-               nv50_draw_elements_inline_u32(nv50, map, start, count);
+               ret = nv50_draw_elements_inline_u32(nv50, map, start, count);
                break;
        default:
                assert(0);
+               ret = FALSE;
+               break;
        }
        BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1);
        OUT_RING  (chan, 0);
 
        pipe_buffer_unmap(pscreen, indexBuffer);
-       pipe->flush(pipe, 0, NULL);
-       return TRUE;
+        
+        /* XXX: what to do if ret != TRUE?  Flush and retry?
+         */
+       assert(ret);
 }
 
 static INLINE boolean
@@ -290,9 +338,13 @@ nv50_vbo_static_attrib(struct nv50_context *nv50, unsigned attrib,
        float *v;
        int ret;
        enum pipe_format pf = ve->src_format;
+       const struct util_format_description *desc;
 
-       if ((pf_type(pf) != PIPE_FORMAT_TYPE_FLOAT) ||
-           (pf_size_x(pf) << pf_exp2(pf)) != 32)
+       desc = util_format_description(pf);
+       assert(desc);
+
+       if ((desc->channel[0].type != UTIL_FORMAT_TYPE_FLOAT) ||
+           util_format_get_component_bits(pf, UTIL_FORMAT_COLORSPACE_RGB, 0) != 32)
                return FALSE;
 
        ret = nouveau_bo_map(bo, NOUVEAU_BO_RD);
@@ -302,7 +354,7 @@ nv50_vbo_static_attrib(struct nv50_context *nv50, unsigned attrib,
 
        so = *pso;
        if (!so)
-               *pso = so = so_new(nv50->vtxelt_nr * 5, 0);
+               *pso = so = so_new(nv50->vtxelt_nr, nv50->vtxelt_nr * 4, 0);
 
        switch (ve->nr_components) {
        case 4:
@@ -324,6 +376,10 @@ nv50_vbo_static_attrib(struct nv50_context *nv50, unsigned attrib,
                so_data  (so, fui(v[1]));
                break;
        case 1:
+               if (attrib == nv50->vertprog->cfg.edgeflag_in) {
+                       so_method(so, tesla, NV50TCL_EDGEFLAG_ENABLE, 1);
+                       so_data  (so, v[0] ? 1 : 0);
+               }
                so_method(so, tesla, NV50TCL_VTX_ATTR_1F(attrib), 1);
                so_data  (so, fui(v[0]));
                break;
@@ -341,17 +397,27 @@ nv50_vbo_validate(struct nv50_context *nv50)
 {
        struct nouveau_grobj *tesla = nv50->screen->tesla;
        struct nouveau_stateobj *vtxbuf, *vtxfmt, *vtxattr;
-       unsigned i;
+       unsigned i, n_ve;
 
        /* don't validate if Gallium took away our buffers */
        if (nv50->vtxbuf_nr == 0)
                return;
+       nv50->vbo_fifo = 0;
+
+       for (i = 0; i < nv50->vtxbuf_nr; ++i)
+               if (nv50->vtxbuf[i].stride &&
+                   !(nv50->vtxbuf[i].buffer->usage & PIPE_BUFFER_USAGE_VERTEX))
+                       nv50->vbo_fifo = 0xffff;
+
+       if (nv50->vertprog->cfg.edgeflag_in < 16)
+               nv50->vbo_fifo = 0xffff; /* vertprog can't set edgeflag */
+
+       n_ve = MAX2(nv50->vtxelt_nr, nv50->state.vtxelt_nr);
 
        vtxattr = NULL;
-       vtxbuf = so_new(nv50->vtxelt_nr * 7, nv50->vtxelt_nr * 4);
-       vtxfmt = so_new(nv50->vtxelt_nr + 1, 0);
-       so_method(vtxfmt, tesla, NV50TCL_VERTEX_ARRAY_ATTRIB(0),
-               nv50->vtxelt_nr);
+       vtxbuf = so_new(n_ve * 2, n_ve * 5, nv50->vtxelt_nr * 4);
+       vtxfmt = so_new(1, n_ve, 0);
+       so_method(vtxfmt, tesla, NV50TCL_VERTEX_ARRAY_ATTRIB(0), n_ve);
 
        for (i = 0; i < nv50->vtxelt_nr; i++) {
                struct pipe_vertex_element *ve = &nv50->vtxelt[i];
@@ -367,10 +433,19 @@ nv50_vbo_validate(struct nv50_context *nv50)
                        so_method(vtxbuf, tesla,
                                  NV50TCL_VERTEX_ARRAY_FORMAT(i), 1);
                        so_data  (vtxbuf, 0);
+
+                       nv50->vbo_fifo &= ~(1 << i);
                        continue;
                }
                so_data(vtxfmt, hw | i);
 
+               if (nv50->vbo_fifo) {
+                       so_method(vtxbuf, tesla,
+                                 NV50TCL_VERTEX_ARRAY_FORMAT(i), 1);
+                       so_data  (vtxbuf, 0);
+                       continue;
+               }
+
                so_method(vtxbuf, tesla, NV50TCL_VERTEX_ARRAY_FORMAT(i), 3);
                so_data  (vtxbuf, 0x20000000 | vb->stride);
                so_reloc (vtxbuf, bo, vb->buffer_offset +
@@ -381,7 +456,7 @@ nv50_vbo_validate(struct nv50_context *nv50)
                          NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
 
                /* vertex array limits */
-               so_method(vtxbuf, tesla, 0x1080 + (i * 8), 2);
+               so_method(vtxbuf, tesla, NV50TCL_VERTEX_ARRAY_LIMIT_HIGH(i), 2);
                so_reloc (vtxbuf, bo, vb->buffer->size - 1,
                          NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD |
                          NOUVEAU_BO_HIGH, 0, 0);
@@ -389,6 +464,13 @@ nv50_vbo_validate(struct nv50_context *nv50)
                          NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD |
                          NOUVEAU_BO_LOW, 0, 0);
        }
+       for (; i < n_ve; ++i) {
+               so_data  (vtxfmt, 0x7e080010);
+
+               so_method(vtxbuf, tesla, NV50TCL_VERTEX_ARRAY_FORMAT(i), 1);
+               so_data  (vtxbuf, 0);
+       }
+       nv50->state.vtxelt_nr = nv50->vtxelt_nr;
 
        so_ref (vtxfmt, &nv50->state.vtxfmt);
        so_ref (vtxbuf, &nv50->state.vtxbuf);
@@ -398,3 +480,359 @@ nv50_vbo_validate(struct nv50_context *nv50)
        so_ref (NULL, &vtxattr);
 }
 
+typedef void (*pfn_push)(struct nouveau_channel *, void *);
+
+struct nv50_vbo_emitctx
+{
+       pfn_push push[16];
+       void *map[16];
+       unsigned stride[16];
+       unsigned nr_ve;
+       unsigned vtx_dwords;
+       unsigned vtx_max;
+
+       float edgeflag;
+       unsigned ve_edgeflag;
+};
+
+static INLINE void
+emit_vtx_next(struct nouveau_channel *chan, struct nv50_vbo_emitctx *emit)
+{
+       unsigned i;
+
+       for (i = 0; i < emit->nr_ve; ++i) {
+               emit->push[i](chan, emit->map[i]);
+               emit->map[i] += emit->stride[i];
+       }
+}
+
+static INLINE void
+emit_vtx(struct nouveau_channel *chan, struct nv50_vbo_emitctx *emit,
+        uint32_t vi)
+{
+       unsigned i;
+
+       for (i = 0; i < emit->nr_ve; ++i)
+               emit->push[i](chan, emit->map[i] + emit->stride[i] * vi);
+}
+
+static INLINE boolean
+nv50_map_vbufs(struct nv50_context *nv50)
+{
+       int i;
+
+       for (i = 0; i < nv50->vtxbuf_nr; ++i) {
+               struct pipe_vertex_buffer *vb = &nv50->vtxbuf[i];
+               unsigned size, delta;
+
+               if (nouveau_bo(vb->buffer)->map)
+                       continue;
+
+               size = vb->stride * (vb->max_index + 1);
+               delta = vb->buffer_offset;
+
+               if (!size)
+                       size = vb->buffer->size - vb->buffer_offset;
+
+               if (nouveau_bo_map_range(nouveau_bo(vb->buffer),
+                                        delta, size, NOUVEAU_BO_RD))
+                       break;
+       }
+
+       if (i == nv50->vtxbuf_nr)
+               return TRUE;
+       for (; i >= 0; --i)
+               nouveau_bo_unmap(nouveau_bo(nv50->vtxbuf[i].buffer));
+       return FALSE;
+}
+
+static INLINE void
+nv50_unmap_vbufs(struct nv50_context *nv50)
+{
+        unsigned i;
+
+        for (i = 0; i < nv50->vtxbuf_nr; ++i)
+                if (nouveau_bo(nv50->vtxbuf[i].buffer)->map)
+                        nouveau_bo_unmap(nouveau_bo(nv50->vtxbuf[i].buffer));
+}
+
+static void
+emit_b32_1(struct nouveau_channel *chan, void *data)
+{
+       uint32_t *v = data;
+
+       OUT_RING(chan, v[0]);
+}
+
+static void
+emit_b32_2(struct nouveau_channel *chan, void *data)
+{
+       uint32_t *v = data;
+
+       OUT_RING(chan, v[0]);
+       OUT_RING(chan, v[1]);
+}
+
+static void
+emit_b32_3(struct nouveau_channel *chan, void *data)
+{
+       uint32_t *v = data;
+
+       OUT_RING(chan, v[0]);
+       OUT_RING(chan, v[1]);
+       OUT_RING(chan, v[2]);
+}
+
+static void
+emit_b32_4(struct nouveau_channel *chan, void *data)
+{
+       uint32_t *v = data;
+
+       OUT_RING(chan, v[0]);
+       OUT_RING(chan, v[1]);
+       OUT_RING(chan, v[2]);
+       OUT_RING(chan, v[3]);
+}
+
+static void
+emit_b16_1(struct nouveau_channel *chan, void *data)
+{
+       uint16_t *v = data;
+
+       OUT_RING(chan, v[0]);
+}
+
+static void
+emit_b16_3(struct nouveau_channel *chan, void *data)
+{
+       uint16_t *v = data;
+
+       OUT_RING(chan, (v[1] << 16) | v[0]);
+       OUT_RING(chan, v[2]);
+}
+
+static void
+emit_b08_1(struct nouveau_channel *chan, void *data)
+{
+       uint8_t *v = data;
+
+       OUT_RING(chan, v[0]);
+}
+
+static void
+emit_b08_3(struct nouveau_channel *chan, void *data)
+{
+       uint8_t *v = data;
+
+       OUT_RING(chan, (v[2] << 16) | (v[1] << 8) | v[0]);
+}
+
+static boolean
+emit_prepare(struct nv50_context *nv50, struct nv50_vbo_emitctx *emit,
+            unsigned start)
+{
+       unsigned i;
+
+       if (nv50_map_vbufs(nv50) == FALSE)
+               return FALSE;
+
+       emit->ve_edgeflag = nv50->vertprog->cfg.edgeflag_in;
+
+       emit->edgeflag = 0.5f;
+       emit->nr_ve = 0;
+       emit->vtx_dwords = 0;
+
+       for (i = 0; i < nv50->vtxelt_nr; ++i) {
+               struct pipe_vertex_element *ve;
+               struct pipe_vertex_buffer *vb;
+               unsigned n, size;
+               const struct util_format_description *desc;
+
+               ve = &nv50->vtxelt[i];
+               vb = &nv50->vtxbuf[ve->vertex_buffer_index];
+               if (!(nv50->vbo_fifo & (1 << i)))
+                       continue;
+               n = emit->nr_ve++;
+
+               emit->stride[n] = vb->stride;
+               emit->map[n] = nouveau_bo(vb->buffer)->map +
+                       (start * vb->stride + ve->src_offset);
+
+               desc = util_format_description(ve->src_format);
+               assert(desc);
+
+               size = util_format_get_component_bits(
+                       ve->src_format, UTIL_FORMAT_COLORSPACE_RGB, 0);
+
+               assert(ve->nr_components > 0 && ve->nr_components <= 4);
+
+               /* It shouldn't be necessary to push the implicit 1s
+                * for case 3 and size 8 cases 1, 2, 3.
+                */
+               switch (size) {
+               default:
+                       NOUVEAU_ERR("unsupported vtxelt size: %u\n", size);
+                       return FALSE;
+               case 32:
+                       switch (ve->nr_components) {
+                       case 1: emit->push[n] = emit_b32_1; break;
+                       case 2: emit->push[n] = emit_b32_2; break;
+                       case 3: emit->push[n] = emit_b32_3; break;
+                       case 4: emit->push[n] = emit_b32_4; break;
+                       }
+                       emit->vtx_dwords += ve->nr_components;
+                       break;
+               case 16:
+                       switch (ve->nr_components) {
+                       case 1: emit->push[n] = emit_b16_1; break;
+                       case 2: emit->push[n] = emit_b32_1; break;
+                       case 3: emit->push[n] = emit_b16_3; break;
+                       case 4: emit->push[n] = emit_b32_2; break;
+                       }
+                       emit->vtx_dwords += (ve->nr_components + 1) >> 1;
+                       break;
+               case 8:
+                       switch (ve->nr_components) {
+                       case 1: emit->push[n] = emit_b08_1; break;
+                       case 2: emit->push[n] = emit_b16_1; break;
+                       case 3: emit->push[n] = emit_b08_3; break;
+                       case 4: emit->push[n] = emit_b32_1; break;
+                       }
+                       emit->vtx_dwords += 1;
+                       break;
+               }
+       }
+
+       emit->vtx_max = 512 / emit->vtx_dwords;
+       if (emit->ve_edgeflag < 16)
+               emit->vtx_max = 1;
+
+       return TRUE;
+}
+
+static INLINE void
+set_edgeflag(struct nouveau_channel *chan,
+            struct nouveau_grobj *tesla,
+            struct nv50_vbo_emitctx *emit, uint32_t index)
+{
+       unsigned i = emit->ve_edgeflag;
+
+       if (i < 16) {
+               float f = *((float *)(emit->map[i] + index * emit->stride[i]));
+
+               if (emit->edgeflag != f) {
+                       emit->edgeflag = f;
+
+                       BEGIN_RING(chan, tesla, 0x15e4, 1);
+                       OUT_RING  (chan, f ? 1 : 0);
+               }
+       }
+}
+
+static boolean
+nv50_push_arrays(struct nv50_context *nv50, unsigned start, unsigned count)
+{
+       struct nouveau_channel *chan = nv50->screen->base.channel;
+       struct nouveau_grobj *tesla = nv50->screen->tesla;
+       struct nv50_vbo_emitctx emit;
+
+       if (emit_prepare(nv50, &emit, start) == FALSE)
+               return FALSE;
+
+       while (count) {
+               unsigned i, dw, nr = MIN2(count, emit.vtx_max);
+               dw = nr * emit.vtx_dwords;
+
+               set_edgeflag(chan, tesla, &emit, 0); /* nr will be 1 */
+
+               BEGIN_RING(chan, tesla, NV50TCL_VERTEX_DATA | 0x40000000, dw);
+               for (i = 0; i < nr; ++i)
+                       emit_vtx_next(chan, &emit);
+
+               count -= nr;
+       }
+       nv50_unmap_vbufs(nv50);
+
+       return TRUE;
+}
+
+static boolean
+nv50_push_elements_u32(struct nv50_context *nv50, uint32_t *map, unsigned count)
+{
+       struct nouveau_channel *chan = nv50->screen->base.channel;
+       struct nouveau_grobj *tesla = nv50->screen->tesla;
+       struct nv50_vbo_emitctx emit;
+
+       if (emit_prepare(nv50, &emit, 0) == FALSE)
+               return FALSE;
+
+       while (count) {
+               unsigned i, dw, nr = MIN2(count, emit.vtx_max);
+               dw = nr * emit.vtx_dwords;
+
+               set_edgeflag(chan, tesla, &emit, *map);
+
+               BEGIN_RING(chan, tesla, NV50TCL_VERTEX_DATA | 0x40000000, dw);
+               for (i = 0; i < nr; ++i)
+                       emit_vtx(chan, &emit, *map++);
+
+               count -= nr;
+       }
+       nv50_unmap_vbufs(nv50);
+
+       return TRUE;
+}
+
+static boolean
+nv50_push_elements_u16(struct nv50_context *nv50, uint16_t *map, unsigned count)
+{
+       struct nouveau_channel *chan = nv50->screen->base.channel;
+       struct nouveau_grobj *tesla = nv50->screen->tesla;
+       struct nv50_vbo_emitctx emit;
+
+       if (emit_prepare(nv50, &emit, 0) == FALSE)
+               return FALSE;
+
+       while (count) {
+               unsigned i, dw, nr = MIN2(count, emit.vtx_max);
+               dw = nr * emit.vtx_dwords;
+
+               set_edgeflag(chan, tesla, &emit, *map);
+
+               BEGIN_RING(chan, tesla, NV50TCL_VERTEX_DATA | 0x40000000, dw);
+               for (i = 0; i < nr; ++i)
+                       emit_vtx(chan, &emit, *map++);
+
+               count -= nr;
+       }
+       nv50_unmap_vbufs(nv50);
+
+       return TRUE;
+}
+
+static boolean
+nv50_push_elements_u08(struct nv50_context *nv50, uint8_t *map, unsigned count)
+{
+       struct nouveau_channel *chan = nv50->screen->base.channel;
+       struct nouveau_grobj *tesla = nv50->screen->tesla;
+       struct nv50_vbo_emitctx emit;
+
+       if (emit_prepare(nv50, &emit, 0) == FALSE)
+               return FALSE;
+
+       while (count) {
+               unsigned i, dw, nr = MIN2(count, emit.vtx_max);
+               dw = nr * emit.vtx_dwords;
+
+               set_edgeflag(chan, tesla, &emit, *map);
+
+               BEGIN_RING(chan, tesla, NV50TCL_VERTEX_DATA | 0x40000000, dw);
+               for (i = 0; i < nr; ++i)
+                       emit_vtx(chan, &emit, *map++);
+
+               count -= nr;
+       }
+       nv50_unmap_vbufs(nv50);
+
+       return TRUE;
+}
index 69e4724790a1130a06045561baa78cf5384c2b77..afddcb161fa76089a8cc1e2a8a04b9218323d15a 100644 (file)
@@ -4,10 +4,8 @@ include $(TOP)/configs/current
 LIBNAME = r300
 
 C_SOURCES = \
-       r3xx_fs.c \
-       r5xx_fs.c \
+       r300_blit.c \
        r300_chipset.c \
-       r300_clear.c \
        r300_context.c \
        r300_debug.c \
        r300_emit.c \
@@ -20,12 +18,12 @@ C_SOURCES = \
        r300_state_derived.c \
        r300_state_invariant.c \
        r300_vs.c \
-       r300_surface.c \
        r300_texture.c \
        r300_tgsi_to_rc.c
 
 LIBRARY_INCLUDES = \
-       -I$(TOP)/src/mesa/drivers/dri/r300/compiler
+       -I$(TOP)/src/mesa/drivers/dri/r300/compiler \
+       -I$(TOP)/src/gallium/winsys/drm/radeon/core
 
 COMPILER_ARCHIVE = $(TOP)/src/mesa/drivers/dri/r300/compiler/libr300compiler.a
 
@@ -37,4 +35,4 @@ include ../../Makefile.template
 .PHONY : $(COMPILER_ARCHIVE)
 
 $(COMPILER_ARCHIVE):
-       cd $(TOP)/src/mesa/drivers/dri/r300/compiler; make
+       $(MAKE) -C $(TOP)/src/mesa/drivers/dri/r300/compiler
index b4c8ba2015a31dd7674799294fb778f01dfae244..183aa17f9b3361fe52e6dc9fa47aca187270f629 100644 (file)
@@ -4,15 +4,18 @@ r300compiler = SConscript('#/src/mesa/drivers/dri/r300/compiler/SConscript')
 
 env = env.Clone()
 # add the paths for r300compiler
-env.Append(CPPPATH = ['#/src/mesa/drivers/dri/r300/compiler', '#/include', '#/src/mesa'])
+env.Append(CPPPATH = [
+    '#/src/mesa/drivers/dri/r300/compiler', 
+    '#/src/gallium/winsys/drm/radeon/core',
+    '#/include', 
+    '#/src/mesa',
+])
 
 r300 = env.ConvenienceLibrary(
     target = 'r300',
     source = [
-        'r3xx_fs.c',
-        'r5xx_fs.c',
+        'r300_blit.c',
         'r300_chipset.c',
-        'r300_clear.c',
         'r300_context.c',
         'r300_debug.c',
         'r300_emit.c',
@@ -25,7 +28,6 @@ r300 = env.ConvenienceLibrary(
         'r300_state_derived.c',
         'r300_state_invariant.c',
         'r300_vs.c',
-        'r300_surface.c',
         'r300_texture.c',
         'r300_tgsi_to_rc.c',
     ] + r300compiler) + r300compiler
diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c
new file mode 100644 (file)
index 0000000..ffe066d
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2009 Marek Olšák <maraeo@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. */
+
+#include "r300_blit.h"
+#include "r300_context.h"
+
+#include "util/u_rect.h"
+
+static void r300_blitter_save_states(struct r300_context* r300)
+{
+    util_blitter_save_blend(r300->blitter, r300->blend_state);
+    util_blitter_save_depth_stencil_alpha(r300->blitter, r300->dsa_state);
+    util_blitter_save_rasterizer(r300->blitter, r300->rs_state);
+    util_blitter_save_fragment_shader(r300->blitter, r300->fs);
+    util_blitter_save_vertex_shader(r300->blitter, r300->vs);
+}
+
+/* Clear currently bound buffers. */
+void r300_clear(struct pipe_context* pipe,
+                unsigned buffers,
+                const float* rgba,
+                double depth,
+                unsigned stencil)
+{
+    /* XXX Implement fastfill.
+     *
+     * If fastfill is enabled, a few facts should be considered:
+     *
+     * 1) Zbuffer must be micro-tiled and whole microtiles must be
+     *    written.
+     *
+     * 2) ZB_DEPTHCLEARVALUE is used to clear a zbuffer and Z Mask must be
+     *    equal to 0.
+     *
+     * 3) RB3D_COLOR_CLEAR_VALUE is used to clear a colorbuffer and
+     *    RB3D_COLOR_CHANNEL_MASK must be equal to 0.
+     *
+     * 4) ZB_CB_CLEAR can be used to make the ZB units help in clearing
+     *    the colorbuffer. The color clear value is supplied through both
+     *    RB3D_COLOR_CLEAR_VALUE and ZB_DEPTHCLEARVALUE, and the colorbuffer
+     *    must be set in ZB_DEPTHOFFSET and ZB_DEPTHPITCH in addition to
+     *    RB3D_COLOROFFSET and RB3D_COLORPITCH. It's obvious that the zbuffer
+     *    will not be cleared and multiple render targets cannot be cleared
+     *    this way either.
+     *
+     * 5) For 16-bit integer buffering, compression causes a hung with one or
+     *    two samples and should not be used.
+     *
+     * 6) Fastfill must not be used if reading of compressed Z data is disabled
+     *    and writing of compressed Z data is enabled (RD/WR_COMP_ENABLE),
+     *    i.e. it cannot be used to compress the zbuffer.
+     *    (what the hell does that mean and how does it fit in clearing
+     *    the buffers?)
+     *
+     * - Marek
+     */
+
+    struct r300_context* r300 = r300_context(pipe);
+
+    r300_blitter_save_states(r300);
+
+    util_blitter_clear(r300->blitter,
+                       r300->framebuffer_state.width,
+                       r300->framebuffer_state.height,
+                       r300->framebuffer_state.nr_cbufs,
+                       buffers, rgba, depth, stencil);
+}
+
+/* Copy a block of pixels from one surface to another. */
+void r300_surface_copy(struct pipe_context* pipe,
+                       struct pipe_surface* dst,
+                       unsigned dstx, unsigned dsty,
+                       struct pipe_surface* src,
+                       unsigned srcx, unsigned srcy,
+                       unsigned width, unsigned height)
+{
+    struct r300_context* r300 = r300_context(pipe);
+
+    /* Yeah we have to save all those states to ensure this blitter operation
+     * is really transparent. The states will be restored by the blitter once
+     * copying is done. */
+    r300_blitter_save_states(r300);
+    util_blitter_save_framebuffer(r300->blitter, &r300->framebuffer_state);
+
+    util_blitter_save_fragment_sampler_states(
+        r300->blitter, r300->sampler_count, (void**)r300->sampler_states);
+
+    util_blitter_save_fragment_sampler_textures(
+        r300->blitter, r300->texture_count,
+        (struct pipe_texture**)r300->textures);
+
+    /* Do a copy */
+    util_blitter_copy(r300->blitter,
+                      dst, dstx, dsty, src, srcx, srcy, width, height, TRUE);
+}
+
+/* Fill a region of a surface with a constant value. */
+void r300_surface_fill(struct pipe_context* pipe,
+                       struct pipe_surface* dst,
+                       unsigned dstx, unsigned dsty,
+                       unsigned width, unsigned height,
+                       unsigned value)
+{
+    struct r300_context* r300 = r300_context(pipe);
+
+    r300_blitter_save_states(r300);
+    util_blitter_save_framebuffer(r300->blitter, &r300->framebuffer_state);
+
+    util_blitter_fill(r300->blitter,
+                      dst, dstx, dsty, width, height, value);
+}
diff --git a/src/gallium/drivers/r300/r300_blit.h b/src/gallium/drivers/r300/r300_blit.h
new file mode 100644 (file)
index 0000000..029e4f9
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2008 Marek Olšák <maraeo@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 R300_BLIT_H
+#define R300_BLIT_H
+
+struct pipe_context;
+struct pipe_surface;
+
+void r300_clear(struct pipe_context* pipe,
+                unsigned buffers,
+                const float* rgba,
+                double depth,
+                unsigned stencil);
+
+void r300_surface_copy(struct pipe_context* pipe,
+                       struct pipe_surface* dst,
+                       unsigned dstx, unsigned dsty,
+                       struct pipe_surface* src,
+                       unsigned srcx, unsigned srcy,
+                       unsigned width, unsigned height);
+
+void r300_surface_fill(struct pipe_context* pipe,
+                       struct pipe_surface* dst,
+                       unsigned dstx, unsigned dsty,
+                       unsigned width, unsigned height,
+                       unsigned value);
+
+#endif /* R300_BLIT_H */
index d138866d33cac217ab015b0729f88fe2a9879105..51fdb82ff343a5db76b7ff94cbdabbac462a0960 100644 (file)
@@ -21,6 +21,7 @@
  * USE OR OTHER DEALINGS IN THE SOFTWARE. */
 
 #include "r300_chipset.h"
+
 #include "util/u_debug.h"
 
 /* r300_chipset: A file all to itself for deducing the various properties of
@@ -31,7 +32,7 @@ void r300_parse_chipset(struct r300_capabilities* caps)
 {
     /* Reasonable defaults */
     caps->num_vert_fpus = 4;
-    caps->has_tcl = getenv("RADEON_NO_TCL") ? FALSE : TRUE;
+    caps->has_tcl = debug_get_bool_option("RADEON_NO_TCL", FALSE) ? FALSE : TRUE;
     caps->is_r500 = FALSE;
     caps->high_second_pipe = FALSE;
 
index 322d4a57e414f9e04284e505d0eb83a875f9323b..0633a8b8a729b4e0be91596b6942914415002f13 100644 (file)
@@ -33,9 +33,11 @@ struct r300_capabilities {
     /* Chipset family */
     int family;
     /* The number of vertex floating-point units */
-    int num_vert_fpus;
+    unsigned num_vert_fpus;
     /* The number of fragment pipes */
-    int num_frag_pipes;
+    unsigned num_frag_pipes;
+    /* The number of z pipes */
+    unsigned num_z_pipes;
     /* Whether or not TCL is physically present */
     boolean has_tcl;
     /* Whether or not this is an RV515 or newer; R500s have many differences
diff --git a/src/gallium/drivers/r300/r300_clear.c b/src/gallium/drivers/r300/r300_clear.c
deleted file mode 100644 (file)
index 8b9cb81..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2008 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. */
-
-#include "r300_clear.h"
-
-/* Clears currently bound buffers. */
-void r300_clear(struct pipe_context* pipe,
-                unsigned buffers,
-                const float* rgba,
-                double depth,
-                unsigned stencil)
-{
-    /* XXX we can and should do one clear if both color and zs are set */
-    util_clear(pipe, &r300_context(pipe)->framebuffer_state,
-            buffers, rgba, depth, stencil);
-}
diff --git a/src/gallium/drivers/r300/r300_clear.h b/src/gallium/drivers/r300/r300_clear.h
deleted file mode 100644 (file)
index cd59005..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2008 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 R300_CLEAR_H
-#define R300_CLEAR_H
-
-#include "util/u_clear.h"
-
-#include "r300_context.h"
-
-void r300_clear(struct pipe_context* pipe,
-                unsigned buffers,
-                const float* rgba,
-                double depth,
-                unsigned stencil);
-
-#endif /* R300_CLEAR_H */
index 9cc455135db9bdaa926626caf7e4223be7536e58..d5c2d63d393babb83a5c18c6c400abc21b77b90b 100644 (file)
  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  * USE OR OTHER DEALINGS IN THE SOFTWARE. */
 
-#include "r300_context.h"
-
-#include "r300_flush.h"
-#include "r300_state_invariant.h"
-
-static boolean r300_draw_range_elements(struct pipe_context* pipe,
-                                        struct pipe_buffer* indexBuffer,
-                                        unsigned indexSize,
-                                        unsigned minIndex,
-                                        unsigned maxIndex,
-                                        unsigned mode,
-                                        unsigned start,
-                                        unsigned count)
-{
-    struct r300_context* r300 = r300_context(pipe);
-    int i;
-
-    for (i = 0; i < r300->vertex_buffer_count; i++) {
-        void* buf = pipe_buffer_map(pipe->screen,
-                                    r300->vertex_buffers[i].buffer,
-                                    PIPE_BUFFER_USAGE_CPU_READ);
-        draw_set_mapped_vertex_buffer(r300->draw, i, buf);
-    }
-
-    if (indexBuffer) {
-        void* indices = pipe_buffer_map(pipe->screen, indexBuffer,
-                                        PIPE_BUFFER_USAGE_CPU_READ);
-        draw_set_mapped_element_buffer_range(r300->draw, indexSize,
-                                             minIndex, maxIndex, indices);
-    } else {
-        draw_set_mapped_element_buffer(r300->draw, 0, NULL);
-    }
-
-    draw_set_mapped_constant_buffer(r300->draw,
-            r300->shader_constants[PIPE_SHADER_VERTEX].constants,
-            r300->shader_constants[PIPE_SHADER_VERTEX].count *
-                (sizeof(float) * 4));
-
-    draw_arrays(r300->draw, mode, start, count);
+#include "draw/draw_context.h"
 
-    for (i = 0; i < r300->vertex_buffer_count; i++) {
-        pipe_buffer_unmap(pipe->screen, r300->vertex_buffers[i].buffer);
-        draw_set_mapped_vertex_buffer(r300->draw, i, NULL);
-    }
+#include "tgsi/tgsi_scan.h"
 
-    if (indexBuffer) {
-        pipe_buffer_unmap(pipe->screen, indexBuffer);
-        draw_set_mapped_element_buffer_range(r300->draw, 0, start,
-                                             start + count - 1, NULL);
-    }
+#include "util/u_hash_table.h"
+#include "util/u_memory.h"
+#include "util/u_simple_list.h"
 
-    return TRUE;
-}
+#include "r300_blit.h"
+#include "r300_context.h"
+#include "r300_flush.h"
+#include "r300_query.h"
+#include "r300_render.h"
+#include "r300_screen.h"
+#include "r300_state_derived.h"
+#include "r300_state_invariant.h"
+#include "r300_texture.h"
+#include "r300_winsys.h"
 
-static boolean r300_draw_elements(struct pipe_context* pipe,
-                                  struct pipe_buffer* indexBuffer,
-                                  unsigned indexSize, unsigned mode,
-                                  unsigned start, unsigned count)
+static enum pipe_error r300_clear_hash_table(void* key, void* value,
+                                             void* data)
 {
-    return r300_draw_range_elements(pipe, indexBuffer, indexSize, 0, ~0,
-                                    mode, start, count);
+    FREE(key);
+    FREE(value);
+    return PIPE_OK;
 }
 
-static boolean r300_draw_arrays(struct pipe_context* pipe, unsigned mode,
-                                unsigned start, unsigned count)
+static void r300_destroy_context(struct pipe_context* context)
 {
-    return r300_draw_elements(pipe, NULL, 0, mode, start, count);
-}
-
-static void r300_destroy_context(struct pipe_context* context) {
     struct r300_context* r300 = r300_context(context);
     struct r300_query* query, * temp;
 
+    util_blitter_destroy(r300->blitter);
+
+    util_hash_table_foreach(r300->shader_hash_table, r300_clear_hash_table,
+        NULL);
+    util_hash_table_destroy(r300->shader_hash_table);
+
     draw_destroy(r300->draw);
 
     /* Free the OQ BO. */
     context->screen->buffer_destroy(r300->oqbo);
 
     /* If there are any queries pending or not destroyed, remove them now. */
-    if (r300->query_list) {
-        foreach_s(query, temp, r300->query_list) {
-            remove_from_list(query);
-            FREE(query);
-        }
+    foreach_s(query, temp, &r300->query_list) {
+        remove_from_list(query);
+        FREE(query);
     }
 
     FREE(r300->blend_color_state);
     FREE(r300->rs_block);
     FREE(r300->scissor_state);
+    FREE(r300->vertex_info);
     FREE(r300->viewport_state);
     FREE(r300);
 }
 
 static unsigned int
-r300_is_texture_referenced( struct pipe_context *pipe,
-                           struct pipe_texture *texture,
-                           unsigned face, unsigned level)
+r300_is_texture_referenced(struct pipe_context *pipe,
+                           struct pipe_texture *texture,
+                           unsigned face, unsigned level)
 {
-   /**
-    * FIXME: Optimize.
-    */
+    struct pipe_buffer* buf = 0;
 
-   return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
+    r300_get_texture_buffer(texture, &buf, NULL);
+
+    return pipe->is_buffer_referenced(pipe, buf);
 }
 
 static unsigned int
-r300_is_buffer_referenced( struct pipe_context *pipe,
-                          struct pipe_buffer *buf)
+r300_is_buffer_referenced(struct pipe_context *pipe,
+                          struct pipe_buffer *buf)
+{
+    /* This only checks to see whether actual hardware buffers are
+     * referenced. Since we use managed BOs and transfers, it's actually not
+     * possible for pipe_buffers to ever reference the actual hardware, so
+     * buffers are never referenced. */
+    return 0;
+}
+
+static void r300_flush_cb(void *data)
 {
-   /**
-    * FIXME: Optimize.
-    */
+    struct r300_context* const cs_context_copy = data;
 
-   return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
+    cs_context_copy->context.flush(&cs_context_copy->context, 0, NULL);
 }
 
 struct pipe_context* r300_create_context(struct pipe_screen* screen,
-                                         struct r300_winsys* r300_winsys)
+                                         struct radeon_winsys* radeon_winsys)
 {
     struct r300_context* r300 = CALLOC_STRUCT(r300_context);
+    struct r300_screen* r300screen = r300_screen(screen);
 
     if (!r300)
         return NULL;
 
-    r300->winsys = r300_winsys;
+    r300->winsys = radeon_winsys;
 
-    r300->context.winsys = (struct pipe_winsys*)r300_winsys;
-    r300->context.screen = r300_screen(screen);
+    r300->context.winsys = (struct pipe_winsys*)radeon_winsys;
+    r300->context.screen = screen;
 
     r300_init_debug(r300);
 
     r300->context.destroy = r300_destroy_context;
 
     r300->context.clear = r300_clear;
+    r300->context.surface_copy = r300_surface_copy;
+    r300->context.surface_fill = r300_surface_fill;
 
-    r300->context.draw_arrays = r300_draw_arrays;
-    r300->context.draw_elements = r300_draw_elements;
-    r300->context.draw_range_elements = r300_draw_range_elements;
+    if (r300screen->caps->has_tcl) {
+        r300->context.draw_arrays = r300_draw_arrays;
+        r300->context.draw_elements = r300_draw_elements;
+        r300->context.draw_range_elements = r300_draw_range_elements;
+    } else {
+        r300->context.draw_arrays = r300_swtcl_draw_arrays;
+        r300->context.draw_elements = r300_draw_elements;
+        r300->context.draw_range_elements = r300_swtcl_draw_range_elements;
+
+        /* Create a Draw. This is used for SW TCL. */
+        r300->draw = draw_create();
+        /* Enable our renderer. */
+        draw_set_rasterize_stage(r300->draw, r300_draw_stage(r300));
+        /* Enable Draw's clipping. */
+        draw_set_driver_clipping(r300->draw, FALSE);
+        /* Force Draw to never do viewport transform, since we can do
+         * transform in hardware, always. */
+        draw_set_viewport_state(r300->draw, &r300_viewport_identity);
+    }
 
     r300->context.is_texture_referenced = r300_is_texture_referenced;
     r300->context.is_buffer_referenced = r300_is_buffer_referenced;
 
+    r300->shader_hash_table = util_hash_table_create(r300_shader_key_hash,
+        r300_shader_key_compare);
+
     r300->blend_color_state = CALLOC_STRUCT(r300_blend_color_state);
     r300->rs_block = CALLOC_STRUCT(r300_rs_block);
     r300->scissor_state = CALLOC_STRUCT(r300_scissor_state);
+    r300->vertex_info = CALLOC_STRUCT(r300_vertex_info);
     r300->viewport_state = CALLOC_STRUCT(r300_viewport_state);
 
-    /* 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);
-
     /* Open up the OQ BO. */
     r300->oqbo = screen->buffer_create(screen, 4096,
             PIPE_BUFFER_USAGE_VERTEX, 4096);
+    make_empty_list(&r300->query_list);
 
     r300_init_flush_functions(r300);
 
     r300_init_query_functions(r300);
 
-    r300_init_surface_functions(r300);
+    /* r300_init_surface_functions(r300); */
 
     r300_init_state_functions(r300);
 
     r300_emit_invariant_state(r300);
+
+    r300->winsys->set_flush_cb(r300->winsys, r300_flush_cb, r300);
     r300->dirty_state = R300_NEW_KITCHEN_SINK;
     r300->dirty_hw++;
 
+    r300->blitter = util_blitter_create(&r300->context);
+
     return &r300->context;
 }
index 52b1c9a6b2660555c689f8048ed8193f825fe3be..232530b7dc447b1840cadc9d1189ea4ca0e66186 100644 (file)
 #ifndef R300_CONTEXT_H
 #define R300_CONTEXT_H
 
-#include "draw/draw_context.h"
 #include "draw/draw_vertex.h"
 
-#include "pipe/p_context.h"
-
-#include "tgsi/tgsi_scan.h"
+#include "util/u_blitter.h"
 
-#include "util/u_memory.h"
-#include "util/u_simple_list.h"
-
-#include "r300_clear.h"
-#include "r300_query.h"
-#include "r300_screen.h"
-#include "r300_winsys.h"
+#include "pipe/p_context.h"
+#include "pipe/p_inlines.h"
 
 struct r300_fragment_shader;
 struct r300_vertex_shader;
@@ -44,6 +36,7 @@ struct r300_vertex_shader;
 struct r300_blend_state {
     uint32_t blend_control;       /* R300_RB3D_CBLEND: 0x4e04 */
     uint32_t alpha_blend_control; /* R300_RB3D_ABLEND: 0x4e08 */
+    uint32_t color_channel_mask;  /* R300_RB3D_COLOR_CHANNEL_MASK: 0x4e0c */
     uint32_t rop;                 /* R300_RB3D_ROPCNTL: 0x4e18 */
     uint32_t dither;              /* R300_RB3D_DITHER_CTL: 0x4e50 */
 };
@@ -62,7 +55,6 @@ struct r300_dsa_state {
     uint32_t z_buffer_control;  /* R300_ZB_CNTL: 0x4f00 */
     uint32_t z_stencil_control; /* R300_ZB_ZSTENCILCNTL: 0x4f04 */
     uint32_t stencil_ref_mask;  /* R300_ZB_STENCILREFMASK: 0x4f08 */
-    uint32_t z_buffer_top;      /* R300_ZB_ZTOP: 0x4f14 */
     uint32_t stencil_ref_bf;    /* R500_ZB_STENCILREFMASK_BF: 0x4fd4 */
 };
 
@@ -88,6 +80,7 @@ struct r300_rs_state {
     uint32_t line_stipple_config;   /* R300_GA_LINE_STIPPLE_CONFIG: 0x4328 */
     uint32_t line_stipple_value;    /* R300_GA_LINE_STIPPLE_VALUE: 0x4260 */
     uint32_t color_control;         /* R300_GA_COLOR_CONTROL: 0x4278 */
+    uint32_t polygon_mode;          /* R300_GA_POLY_MODE: 0x4288 */
 };
 
 struct r300_rs_block {
@@ -98,14 +91,28 @@ struct r300_rs_block {
 };
 
 struct r300_sampler_state {
+    struct pipe_sampler_state state;
+
     uint32_t filter0;      /* R300_TX_FILTER0: 0x4400 */
     uint32_t filter1;      /* R300_TX_FILTER1: 0x4440 */
     uint32_t border_color; /* R300_TX_BORDER_COLOR: 0x45c0 */
+
+    /* Min/max LOD must be clamped to [0, last_level], thus
+     * it's dependent on a currently bound texture */
+    unsigned min_lod, max_lod;
+};
+
+struct r300_scissor_regs {
+    uint32_t top_left;     /* R300_SC_SCISSORS_TL: 0x43e0 */
+    uint32_t bottom_right; /* R300_SC_SCISSORS_BR: 0x43e4 */
+
+    /* Whether everything is culled by scissoring. */
+    boolean empty_area;
 };
 
 struct r300_scissor_state {
-    uint32_t scissor_top_left;     /* R300_SC_SCISSORS_TL: 0x43e0 */
-    uint32_t scissor_bottom_right; /* R300_SC_SCISSORS_BR: 0x43e4 */
+    struct r300_scissor_regs framebuffer;
+    struct r300_scissor_regs scissor;
 };
 
 struct r300_texture_state {
@@ -124,13 +131,17 @@ struct r300_viewport_state {
     uint32_t vte_control; /* R300_VAP_VTE_CNTL:      0x20b0 */
 };
 
+struct r300_ztop_state {
+    uint32_t z_buffer_top;      /* R300_ZB_ZTOP: 0x4f14 */
+};
+
 #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_DSA             0x00000008
+#define R300_NEW_FRAMEBUFFERS    0x00000010
+#define R300_NEW_FRAGMENT_SHADER 0x00000020
+#define R300_NEW_FRAGMENT_SHADER_CONSTANTS    0x00000040
 #define R300_NEW_RASTERIZER      0x00000080
 #define R300_NEW_RS_BLOCK        0x00000100
 #define R300_NEW_SAMPLER         0x00000200
@@ -140,8 +151,10 @@ struct r300_viewport_state {
 #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
+#define R300_NEW_VERTEX_SHADER_CONSTANTS    0x10000000
+#define R300_NEW_VIEWPORT        0x20000000
+#define R300_NEW_QUERY           0x40000000
+#define R300_NEW_KITCHEN_SINK    0x7fffffff
 
 /* The next several objects are not pure Radeon state; they inherit from
  * various Gallium classes. */
@@ -172,6 +185,10 @@ struct r300_query {
     unsigned int count;
     /* The offset of this query into the query buffer, in bytes. */
     unsigned offset;
+    /* if we've flushed the query */
+    boolean flushed;
+    /* if begin has been emitted */
+    boolean begin_emitted;
     /* Linked list members. */
     struct r300_query* prev;
     struct r300_query* next;
@@ -184,6 +201,12 @@ struct r300_texture {
     /* Offsets into the buffer. */
     unsigned offset[PIPE_MAX_TEXTURE_LEVELS];
 
+    /* A pitch for each mip-level */
+    unsigned pitch[PIPE_MAX_TEXTURE_LEVELS];
+
+    /* Size of one zslice or face based on the texture target */
+    unsigned layer_size[PIPE_MAX_TEXTURE_LEVELS];
+
     /**
      * If non-zero, override the natural texture layout with
      * a custom stride (in bytes).
@@ -197,6 +220,11 @@ struct r300_texture {
     /* Total size of this texture, in bytes. */
     unsigned size;
 
+    /* Whether this texture has non-power-of-two dimensions.
+     * It can be either a regular texture or a rectangle one.
+     */
+    boolean is_npot;
+
     /* Pipe buffer backing this texture. */
     struct pipe_buffer* buffer;
 
@@ -204,18 +232,14 @@ struct r300_texture {
     struct r300_texture_state state;
 };
 
-struct r300_vertex_format {
+struct r300_vertex_info {
     /* Parent class */
     struct vertex_info vinfo;
+
     /* R300_VAP_PROG_STREAK_CNTL_[0-7] */
     uint32_t vap_prog_stream_cntl[8];
     /* R300_VAP_PROG_STREAK_CNTL_EXT_[0-7] */
     uint32_t vap_prog_stream_cntl_ext[8];
-    /* Map of vertex attributes into PVS memory for HW TCL,
-     * or GA memory for SW TCL. */
-    int vs_tab[16];
-    /* Map of rasterizer attributes from GB through RS to US. */
-    int fs_tab[16];
 };
 
 extern struct pipe_viewport_state r300_viewport_identity;
@@ -225,9 +249,11 @@ struct r300_context {
     struct pipe_context context;
 
     /* The interface to the windowing system, etc. */
-    struct r300_winsys* winsys;
+    struct radeon_winsys* winsys;
     /* Draw module. Used mostly for SW TCL. */
     struct draw_context* draw;
+    /* Accelerated blit support. */
+    struct blitter_context* blitter;
 
     /* Vertex buffer for rendering. */
     struct pipe_buffer* vbo;
@@ -237,7 +263,14 @@ struct r300_context {
     /* Occlusion query buffer. */
     struct pipe_buffer* oqbo;
     /* Query list. */
-    struct r300_query* query_list;
+    struct r300_query *query_current;
+    struct r300_query query_list;
+
+    /* Shader hash table. Used to store vertex formatting information, which
+     * depends on the combination of both currently loaded shaders. */
+    struct util_hash_table* shader_hash_table;
+    /* Vertex formatting information. */
+    struct r300_vertex_info* vertex_info;
 
     /* Various CSO state objects. */
     /* Blend state. */
@@ -266,15 +299,20 @@ struct r300_context {
     /* Texture states. */
     struct r300_texture* textures[8];
     int texture_count;
-    /* Vertex buffers for Gallium. */
-    struct pipe_vertex_buffer vertex_buffers[PIPE_MAX_ATTRIBS];
-    int vertex_buffer_count;
-    /* Vertex information. */
-    struct r300_vertex_format vertex_info;
     /* Vertex shader. */
     struct r300_vertex_shader* vs;
     /* Viewport state. */
     struct r300_viewport_state* viewport_state;
+    /* ZTOP state. */
+    struct r300_ztop_state ztop_state;
+
+    /* Vertex buffers for Gallium. */
+    struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
+    int vertex_buffer_count;
+    /* Vertex elements for Gallium. */
+    struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS];
+    int vertex_element_count;
+
     /* Bitmask of dirty state objects. */
     uint32_t dirty_state;
     /* Flag indicating whether or not the HW is dirty. */
@@ -312,11 +350,13 @@ void r300_init_surface_functions(struct r300_context* r300);
 #define DBG_VP      0x0000004
 #define DBG_CS      0x0000008
 #define DBG_DRAW    0x0000010
+#define DBG_TEX     0x0000020
+#define DBG_FALL    0x0000040
 /*@}*/
 
 static INLINE boolean DBG_ON(struct r300_context * ctx, unsigned flags)
 {
-    return (ctx->debug & flags) ? true : false;
+    return (ctx->debug & flags) ? TRUE : FALSE;
 }
 
 static INLINE void DBG(struct r300_context * ctx, unsigned flags, const char * fmt, ...)
index 883f0a02dc50ded7bcc5e94678a9e030ed0dae65..d142fee0502a058de93fdb94943a0cdcb3ad75c1 100644 (file)
@@ -26,7 +26,8 @@
 #include "util/u_math.h"
 
 #include "r300_reg.h"
-#include "r300_winsys.h"
+
+#include "radeon_winsys.h"
 
 /* Yes, I know macros are ugly. However, they are much prettier than the code
  * that they neatly hide away, and don't have the cost of function setup,so
@@ -34,8 +35,8 @@
 
 #define MAX_CS_SIZE 64 * 1024 / 4
 
-#define VERY_VERBOSE_CS 0
-#define VERY_VERBOSE_REGISTERS 0
+#define VERY_VERBOSE_CS 1
+#define VERY_VERBOSE_REGISTERS 1
 
 /* XXX stolen from radeon_drm.h */
 #define RADEON_GEM_DOMAIN_CPU  0x1
 
 #define CS_LOCALS(context) \
     struct r300_context* const cs_context_copy = (context); \
-    struct r300_winsys* cs_winsys = cs_context_copy->winsys; \
+    struct radeon_winsys* cs_winsys = cs_context_copy->winsys; \
     int cs_count = 0;
 
 #define CHECK_CS(size) \
-    cs_winsys->check_cs(cs_winsys, (size))
+    assert(cs_winsys->check_cs(cs_winsys, (size)))
 
 #define BEGIN_CS(size) do { \
     CHECK_CS(size); \
     cs_count -= 3; \
 } while (0)
 
+#define OUT_CS_RELOC_NO_OFFSET(bo, rd, wd, flags) do { \
+    DBG(cs_context_copy, DBG_CS, "r300: writing relocation for buffer %p, " \
+            "domains (%d, %d, %d)\n", \
+        bo, rd, wd, flags); \
+    assert(bo); \
+    cs_winsys->write_cs_reloc(cs_winsys, bo, rd, wd, flags); \
+    cs_count -= 2; \
+} while (0)
+
 #define END_CS do { \
     if (VERY_VERBOSE_CS) { \
         DBG(cs_context_copy, DBG_CS, "r300: END_CS in %s (%s:%d)\n", __FUNCTION__, \
index 85d69c07479c383348ea24e0dadf02e523d3e1e2..2a6ed54ac9bd20d297cdebf3f02468441aa17ad0 100644 (file)
@@ -37,6 +37,8 @@ static struct debug_option debug_options[] = {
     { "vp", DBG_VP, "Vertex program handling" },
     { "cs", DBG_CS, "Command submissions" },
     { "draw", DBG_DRAW, "Draw and emit" },
+    { "tex", DBG_TEX, "Textures" },
+    { "fall", DBG_FALL, "Fallbacks" },
 
     { "all", ~0, "Convenience option that enables all debug flags" },
 
@@ -47,7 +49,7 @@ static struct debug_option debug_options[] = {
 void r300_init_debug(struct r300_context * ctx)
 {
     const char * options = debug_get_option("RADEON_DEBUG", 0);
-    boolean printhint = false;
+    boolean printhint = FALSE;
     size_t length;
     struct debug_option * opt;
 
@@ -69,14 +71,14 @@ void r300_init_debug(struct r300_context * ctx)
 
             if (!opt->name) {
                 debug_printf("Unknown debug option: %s\n", options);
-                printhint = true;
+                printhint = TRUE;
             }
 
             options += length;
         }
 
         if (!ctx->debug)
-            printhint = true;
+            printhint = TRUE;
     }
 
     if (printhint || ctx->debug & DBG_HELP) {
index 77ce431cdc3fb9d984e280c8ad819fce6d54e13d..f8bfa714fefe458e02466140d5ec2ea794e61af7 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
+ * Copyright 2009 Marek Olšák <maraeo@gmail.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
 
 /* r300_emit: Functions for emitting state. */
 
-#include "r300_emit.h"
+#include "util/u_format.h"
+#include "util/u_math.h"
 
+#include "r300_context.h"
+#include "r300_cs.h"
+#include "r300_emit.h"
 #include "r300_fs.h"
+#include "r300_screen.h"
 #include "r300_state_derived.h"
+#include "r300_state_inlines.h"
+#include "r300_texture.h"
 #include "r300_vs.h"
 
 void r300_emit_blend_state(struct r300_context* r300,
                            struct r300_blend_state* blend)
 {
     CS_LOCALS(r300);
-    BEGIN_CS(7);
-    OUT_CS_REG_SEQ(R300_RB3D_CBLEND, 2);
-    OUT_CS(blend->blend_control);
-    OUT_CS(blend->alpha_blend_control);
+    BEGIN_CS(8);
+    OUT_CS_REG_SEQ(R300_RB3D_CBLEND, 3);
+    if (r300->framebuffer_state.nr_cbufs) {
+        OUT_CS(blend->blend_control);
+        OUT_CS(blend->alpha_blend_control);
+        OUT_CS(blend->color_channel_mask);
+    } else {
+        OUT_CS(0);
+        OUT_CS(0);
+        OUT_CS(0);
+        /* XXX also disable fastfill here once it's supported */
+    }
     OUT_CS_REG(R300_RB3D_ROPCNTL, blend->rop);
     OUT_CS_REG(R300_RB3D_DITHER_CTL, blend->dither);
     END_CS;
@@ -96,19 +112,30 @@ void r300_emit_dsa_state(struct r300_context* r300,
     struct r300_screen* r300screen = r300_screen(r300->context.screen);
     CS_LOCALS(r300);
 
-    BEGIN_CS(r300screen->caps->is_r500 ? 8 : 8);
+    BEGIN_CS(r300screen->caps->is_r500 ? 10 : 8);
     OUT_CS_REG(R300_FG_ALPHA_FUNC, dsa->alpha_function);
-    /* XXX figure out the r300 counterpart for this */
-    if (r300screen->caps->is_r500) {
-        /* OUT_CS_REG(R500_FG_ALPHA_VALUE, dsa->alpha_reference); */
-    }
+
+    /* not needed since we use the 8bit alpha ref */
+    /*if (r300screen->caps->is_r500) {
+        OUT_CS_REG(R500_FG_ALPHA_VALUE, dsa->alpha_reference);
+    }*/
+
     OUT_CS_REG_SEQ(R300_ZB_CNTL, 3);
-    OUT_CS(dsa->z_buffer_control);
-    OUT_CS(dsa->z_stencil_control);
+
+    if (r300->framebuffer_state.zsbuf) {
+        OUT_CS(dsa->z_buffer_control);
+        OUT_CS(dsa->z_stencil_control);
+    } else {
+        OUT_CS(0);
+        OUT_CS(0);
+    }
+
     OUT_CS(dsa->stencil_ref_mask);
-    OUT_CS_REG(R300_ZB_ZTOP, dsa->z_buffer_top);
+    OUT_CS_REG(R300_ZB_ZTOP, r300->ztop_state.z_buffer_top);
+
+    /* XXX it seems r3xx doesn't support STENCILREFMASK_BF */
     if (r300screen->caps->is_r500) {
-        /* OUT_CS_REG(R500_ZB_STENCILREFMASK_BF, dsa->stencil_ref_bf); */
+        OUT_CS_REG(R500_ZB_STENCILREFMASK_BF, dsa->stencil_ref_bf);
     }
     END_CS;
 }
@@ -118,7 +145,9 @@ static const float * get_shader_constant(
     struct rc_constant * constant,
     struct r300_constant_buffer * externals)
 {
-    static const float zero[4] = { 0.0, 0.0, 0.0, 0.0 };
+    static float vec[4] = { 0.0, 0.0, 0.0, 1.0 };
+    struct pipe_texture *tex;
+
     switch(constant->Type) {
         case RC_CONSTANT_EXTERNAL:
             return externals->constants[constant->u.External];
@@ -126,11 +155,60 @@ static const float * get_shader_constant(
         case RC_CONSTANT_IMMEDIATE:
             return constant->u.Immediate;
 
+        case RC_CONSTANT_STATE:
+            switch (constant->u.State[0]) {
+                /* Factor for converting rectangle coords to
+                 * normalized coords. Should only show up on non-r500. */
+                case RC_STATE_R300_TEXRECT_FACTOR:
+                    tex = &r300->textures[constant->u.State[1]]->tex;
+                    vec[0] = 1.0 / tex->width0;
+                    vec[1] = 1.0 / tex->height0;
+                    break;
+
+                /* Texture compare-fail value. */
+                /* XXX Since Gallium doesn't support GL_ARB_shadow_ambient,
+                 * this is always (0,0,0,0). */
+                case RC_STATE_SHADOW_AMBIENT:
+                    vec[3] = 0;
+                    break;
+
+                case RC_STATE_R300_VIEWPORT_SCALE:
+                    if (r300->rs_state->enable_vte) {
+                        vec[0] = r300->viewport_state->xscale;
+                        vec[1] = r300->viewport_state->yscale;
+                        vec[2] = r300->viewport_state->zscale;
+                    } else {
+                        vec[0] = 1;
+                        vec[1] = 1;
+                        vec[2] = 1;
+                    }
+                    break;
+
+                case RC_STATE_R300_VIEWPORT_OFFSET:
+                    if (r300->rs_state->enable_vte) {
+                        vec[0] = r300->viewport_state->xoffset;
+                        vec[1] = r300->viewport_state->yoffset;
+                        vec[2] = r300->viewport_state->zoffset;
+                    } else {
+                        /* Zeros. */
+                    }
+                    break;
+
+                default:
+                    debug_printf("r300: Implementation error: "
+                        "Unknown RC_CONSTANT type %d\n", constant->u.State[0]);
+            }
+            break;
+
         default:
-            debug_printf("r300: Implementation error: Unhandled constant type %i\n",
-                constant->Type);
-            return zero;
+            debug_printf("r300: Implementation error: "
+                "Unhandled constant type %d\n", constant->Type);
     }
+
+    /* This should either be (0, 0, 0, 1), which should be a relatively safe
+     * RGBA or STRQ value, or it could be one of the RC_CONSTANT_STATE
+     * state factors. */
+    return vec;
 }
 
 /* Convert a normal single-precision float into the 7.16 format
@@ -168,18 +246,15 @@ static uint32_t pack_float24(float f)
 }
 
 void r300_emit_fragment_program_code(struct r300_context* r300,
-                                     struct rX00_fragment_program_code* generic_code,
-                                     struct r300_constant_buffer* externals)
+                                     struct rX00_fragment_program_code* generic_code)
 {
     struct r300_fragment_program_code * code = &generic_code->code.r300;
-    struct rc_constant_list * constants = &generic_code->constants;
     int i;
     CS_LOCALS(r300);
 
     BEGIN_CS(15 +
              code->alu.length * 4 +
-             (code->tex.length ? (1 + code->tex.length) : 0) +
-             (constants->Count ? (1 + constants->Count * 4) : 0));
+             (code->tex.length ? (1 + code->tex.length) : 0));
 
     OUT_CS_REG(R300_US_CONFIG, code->config);
     OUT_CS_REG(R300_US_PIXSIZE, code->pixsize);
@@ -211,33 +286,58 @@ void r300_emit_fragment_program_code(struct r300_context* r300,
             OUT_CS(code->tex.inst[i]);
     }
 
-    if (constants->Count) {
-        OUT_CS_ONE_REG(R300_PFS_PARAM_0_X, constants->Count * 4);
-        for(i = 0; i < constants->Count; ++i) {
-            const float * data = get_shader_constant(r300, &constants->Constants[i], externals);
-            OUT_CS(pack_float24(data[0]));
-            OUT_CS(pack_float24(data[1]));
-            OUT_CS(pack_float24(data[2]));
-            OUT_CS(pack_float24(data[3]));
-        }
+    END_CS;
+}
+
+void r300_emit_fs_constant_buffer(struct r300_context* r300,
+                                  struct rc_constant_list* constants)
+{
+    int i;
+    CS_LOCALS(r300);
+
+    if (constants->Count == 0)
+        return;
+
+    BEGIN_CS(constants->Count * 4 + 1);
+    OUT_CS_REG_SEQ(R300_PFS_PARAM_0_X, constants->Count * 4);
+    for(i = 0; i < constants->Count; ++i) {
+        const float * data = get_shader_constant(r300,
+                                                 &constants->Constants[i],
+                                                 &r300->shader_constants[PIPE_SHADER_FRAGMENT]);
+        OUT_CS(pack_float24(data[0]));
+        OUT_CS(pack_float24(data[1]));
+        OUT_CS(pack_float24(data[2]));
+        OUT_CS(pack_float24(data[3]));
     }
+    END_CS;
+}
 
+static void r300_emit_fragment_depth_config(struct r300_context* r300,
+                                            struct r300_fragment_shader* fs)
+{
+    CS_LOCALS(r300);
+
+    BEGIN_CS(4);
+    if (r300_fragment_shader_writes_depth(fs)) {
+        OUT_CS_REG(R300_FG_DEPTH_SRC, R300_FG_DEPTH_SRC_SHADER);
+        OUT_CS_REG(R300_US_W_FMT, R300_W_FMT_W24 | R300_W_SRC_US);
+    } else {
+        OUT_CS_REG(R300_FG_DEPTH_SRC, R300_FG_DEPTH_SRC_SCAN);
+        OUT_CS_REG(R300_US_W_FMT, R300_W_FMT_W0 | R300_W_SRC_US);
+    }
     END_CS;
 }
 
 void r500_emit_fragment_program_code(struct r300_context* r300,
-                                     struct rX00_fragment_program_code* generic_code,
-                                     struct r300_constant_buffer* externals)
+                                     struct rX00_fragment_program_code* generic_code)
 {
     struct r500_fragment_program_code * code = &generic_code->code.r500;
-    struct rc_constant_list * constants = &generic_code->constants;
     int i;
     CS_LOCALS(r300);
 
     BEGIN_CS(13 +
-             ((code->inst_end + 1) * 6) +
-             (constants->Count ? (3 + (constants->Count * 4)) : 0));
-    OUT_CS_REG(R500_US_CONFIG, 0);
+             ((code->inst_end + 1) * 6));
+    OUT_CS_REG(R500_US_CONFIG, R500_ZERO_TIMES_ANYTHING_EQUALS_ZERO);
     OUT_CS_REG(R500_US_PIXSIZE, code->max_temp_idx);
     OUT_CS_REG(R500_US_CODE_RANGE,
                R500_US_CODE_RANGE_ADDR(0) | R500_US_CODE_RANGE_SIZE(code->inst_end));
@@ -256,18 +356,30 @@ void r500_emit_fragment_program_code(struct r300_context* r300,
         OUT_CS(code->inst[i].inst5);
     }
 
-    if (constants->Count) {
-        OUT_CS_REG(R500_GA_US_VECTOR_INDEX, R500_GA_US_VECTOR_INDEX_TYPE_CONST);
-        OUT_CS_ONE_REG(R500_GA_US_VECTOR_DATA, constants->Count * 4);
-        for (i = 0; i < constants->Count; i++) {
-            const float * data = get_shader_constant(r300, &constants->Constants[i], externals);
-            OUT_CS_32F(data[0]);
-            OUT_CS_32F(data[1]);
-            OUT_CS_32F(data[2]);
-            OUT_CS_32F(data[3]);
-        }
-    }
+    END_CS;
+}
+
+void r500_emit_fs_constant_buffer(struct r300_context* r300,
+                                  struct rc_constant_list* constants)
+{
+    int i;
+    CS_LOCALS(r300);
+
+    if (constants->Count == 0)
+        return;
 
+    BEGIN_CS(constants->Count * 4 + 3);
+    OUT_CS_REG(R500_GA_US_VECTOR_INDEX, R500_GA_US_VECTOR_INDEX_TYPE_CONST);
+    OUT_CS_ONE_REG(R500_GA_US_VECTOR_DATA, constants->Count * 4);
+    for (i = 0; i < constants->Count; i++) {
+        const float * data = get_shader_constant(r300,
+                                                 &constants->Constants[i],
+                                                 &r300->shader_constants[PIPE_SHADER_FRAGMENT]);
+        OUT_CS_32F(data[0]);
+        OUT_CS_32F(data[1]);
+        OUT_CS_32F(data[2]);
+        OUT_CS_32F(data[3]);
+    }
     END_CS;
 }
 
@@ -275,76 +387,98 @@ void r300_emit_fb_state(struct r300_context* r300,
                         struct pipe_framebuffer_state* fb)
 {
     struct r300_texture* tex;
-    unsigned pixpitch;
+    struct pipe_surface* surf;
     int i;
     CS_LOCALS(r300);
 
-    BEGIN_CS((10 * fb->nr_cbufs) + (fb->zsbuf ? 10 : 0) + 4);
+    /* Shouldn't fail unless there is a bug in the state tracker. */
+    assert(fb->nr_cbufs <= 4);
+
+    BEGIN_CS((10 * fb->nr_cbufs) + (2 * (4 - fb->nr_cbufs)) +
+             (fb->zsbuf ? 10 : 0) + 6);
+
+    /* Flush and free renderbuffer caches. */
+    OUT_CS_REG(R300_RB3D_DSTCACHE_CTLSTAT,
+        R300_RB3D_DSTCACHE_CTLSTAT_DC_FREE_FREE_3D_TAGS |
+        R300_RB3D_DSTCACHE_CTLSTAT_DC_FLUSH_FLUSH_DIRTY_3D);
+    OUT_CS_REG(R300_ZB_ZCACHE_CTLSTAT,
+        R300_ZB_ZCACHE_CTLSTAT_ZC_FLUSH_FLUSH_AND_FREE |
+        R300_ZB_ZCACHE_CTLSTAT_ZC_FREE_FREE);
+
+    /* Set the number of colorbuffers. */
+    OUT_CS_REG(R300_RB3D_CCTL, R300_RB3D_CCTL_NUM_MULTIWRITES(fb->nr_cbufs));
+
+    /* Set up colorbuffers. */
     for (i = 0; i < fb->nr_cbufs; i++) {
-        tex = (struct r300_texture*)fb->cbufs[i]->texture;
+        surf = fb->cbufs[i];
+        tex = (struct r300_texture*)surf->texture;
         assert(tex && tex->buffer && "cbuf is marked, but NULL!");
-        pixpitch = r300_texture_get_stride(tex, 0) / tex->tex.block.size;
 
         OUT_CS_REG_SEQ(R300_RB3D_COLOROFFSET0 + (4 * i), 1);
-        OUT_CS_RELOC(tex->buffer, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0);
+        OUT_CS_RELOC(tex->buffer, surf->offset, 0, RADEON_GEM_DOMAIN_VRAM, 0);
 
         OUT_CS_REG_SEQ(R300_RB3D_COLORPITCH0 + (4 * i), 1);
-        OUT_CS_RELOC(tex->buffer, pixpitch |
+        OUT_CS_RELOC(tex->buffer, tex->pitch[surf->level] |
                      r300_translate_colorformat(tex->tex.format), 0,
                      RADEON_GEM_DOMAIN_VRAM, 0);
 
         OUT_CS_REG(R300_US_OUT_FMT_0 + (4 * i),
-            r300_translate_out_fmt(fb->cbufs[i]->format));
+            r300_translate_out_fmt(surf->format));
+    }
+
+    /* Disable unused colorbuffers. */
+    for (; i < 4; i++) {
+        OUT_CS_REG(R300_US_OUT_FMT_0 + (4 * i), R300_US_OUT_FMT_UNUSED);
     }
 
+    /* Set up a zbuffer. */
     if (fb->zsbuf) {
-        tex = (struct r300_texture*)fb->zsbuf->texture;
+        surf = fb->zsbuf;
+        tex = (struct r300_texture*)surf->texture;
         assert(tex && tex->buffer && "zsbuf is marked, but NULL!");
-        pixpitch = r300_texture_get_stride(tex, 0) / tex->tex.block.size;
 
         OUT_CS_REG_SEQ(R300_ZB_DEPTHOFFSET, 1);
-        OUT_CS_RELOC(tex->buffer, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0);
+        OUT_CS_RELOC(tex->buffer, surf->offset, 0, RADEON_GEM_DOMAIN_VRAM, 0);
 
         OUT_CS_REG(R300_ZB_FORMAT, r300_translate_zsformat(tex->tex.format));
 
         OUT_CS_REG_SEQ(R300_ZB_DEPTHPITCH, 1);
-        OUT_CS_RELOC(tex->buffer, pixpitch, 0, RADEON_GEM_DOMAIN_VRAM, 0);
+        OUT_CS_RELOC(tex->buffer, tex->pitch[surf->level], 0,
+                     RADEON_GEM_DOMAIN_VRAM, 0);
     }
 
-    OUT_CS_REG(R300_RB3D_DSTCACHE_CTLSTAT,
-        R300_RB3D_DSTCACHE_CTLSTAT_DC_FREE_FREE_3D_TAGS |
-        R300_RB3D_DSTCACHE_CTLSTAT_DC_FLUSH_FLUSH_DIRTY_3D);
-    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;
 }
 
-void r300_emit_query_begin(struct r300_context* r300,
-                           struct r300_query* query)
+static void r300_emit_query_start(struct r300_context *r300)
 {
+    struct r300_capabilities *caps = r300_screen(r300->context.screen)->caps;
+    struct r300_query *query = r300->query_current;
     CS_LOCALS(r300);
 
-    /* XXX This will almost certainly not return good results
-     * for overlapping queries. */
-    BEGIN_CS(2);
+    if (!query)
+       return;
+
+    BEGIN_CS(4);
+    if (caps->family == CHIP_FAMILY_RV530) {
+        OUT_CS_REG(RV530_FG_ZBREG_DEST, RV530_FG_ZBREG_DEST_PIPE_SELECT_ALL);
+    } else {
+        OUT_CS_REG(R300_SU_REG_DEST, R300_RASTER_PIPE_SELECT_ALL);
+    }
     OUT_CS_REG(R300_ZB_ZPASS_DATA, 0);
     END_CS;
+    query->begin_emitted = TRUE;
 }
 
-void r300_emit_query_end(struct r300_context* r300,
-                         struct r300_query* query)
+
+static void r300_emit_query_finish(struct r300_context *r300,
+                                   struct r300_query *query)
 {
     struct r300_capabilities* caps = r300_screen(r300->context.screen)->caps;
     CS_LOCALS(r300);
 
-    if (!r300->winsys->add_buffer(r300->winsys, r300->oqbo,
-                0, RADEON_GEM_DOMAIN_GTT)) {
-        debug_printf("r300: There wasn't room for the OQ buffer!?"
-                " Oh noes!\n");
-    }
-
     assert(caps->num_frag_pipes);
+
     BEGIN_CS(6 * caps->num_frag_pipes + 2);
     /* I'm not so sure I like this switch, but it's hard to be elegant
      * when there's so many special cases...
@@ -381,7 +515,7 @@ void r300_emit_query_end(struct r300_context* r300,
             OUT_CS_REG_SEQ(R300_ZB_ZPASS_ADDR, 1);
             OUT_CS_RELOC(r300->oqbo, query->offset + (sizeof(uint32_t) * 0),
                     0, RADEON_GEM_DOMAIN_GTT, 0);
-           break;
+            break;
         default:
             debug_printf("r300: Implementation error: Chipset reports %d"
                     " pixel pipes!\n", caps->num_frag_pipes);
@@ -391,14 +525,62 @@ void r300_emit_query_end(struct r300_context* r300,
     /* And, finally, reset it to normal... */
     OUT_CS_REG(R300_SU_REG_DEST, 0xF);
     END_CS;
+}
+
+static void rv530_emit_query_single(struct r300_context *r300,
+                                    struct r300_query *query)
+{
+    CS_LOCALS(r300);
 
+    BEGIN_CS(8);
+    OUT_CS_REG(RV530_FG_ZBREG_DEST, RV530_FG_ZBREG_DEST_PIPE_SELECT_0);
+    OUT_CS_REG_SEQ(R300_ZB_ZPASS_ADDR, 1);
+    OUT_CS_RELOC(r300->oqbo, query->offset, 0, RADEON_GEM_DOMAIN_GTT, 0);
+    OUT_CS_REG(RV530_FG_ZBREG_DEST, RV530_FG_ZBREG_DEST_PIPE_SELECT_ALL);
+    END_CS;
+}
+
+static void rv530_emit_query_double(struct r300_context *r300,
+                                    struct r300_query *query)
+{
+    CS_LOCALS(r300);
+
+    BEGIN_CS(14);
+    OUT_CS_REG(RV530_FG_ZBREG_DEST, RV530_FG_ZBREG_DEST_PIPE_SELECT_0);
+    OUT_CS_REG_SEQ(R300_ZB_ZPASS_ADDR, 1);
+    OUT_CS_RELOC(r300->oqbo, query->offset, 0, RADEON_GEM_DOMAIN_GTT, 0);
+    OUT_CS_REG(RV530_FG_ZBREG_DEST, RV530_FG_ZBREG_DEST_PIPE_SELECT_1);
+    OUT_CS_REG_SEQ(R300_ZB_ZPASS_ADDR, 1);
+    OUT_CS_RELOC(r300->oqbo, query->offset + sizeof(uint32_t), 0, RADEON_GEM_DOMAIN_GTT, 0);
+    OUT_CS_REG(RV530_FG_ZBREG_DEST, RV530_FG_ZBREG_DEST_PIPE_SELECT_ALL);
+    END_CS;
+}
+
+void r300_emit_query_end(struct r300_context* r300)
+{
+    struct r300_capabilities *caps = r300_screen(r300->context.screen)->caps;
+    struct r300_query *query = r300->query_current;
+
+    if (!query)
+       return;
+
+    if (query->begin_emitted == FALSE)
+        return;
+
+    if (caps->family == CHIP_FAMILY_RV530) {
+        if (caps->num_z_pipes == 2)
+            rv530_emit_query_double(r300, query);
+        else
+            rv530_emit_query_single(r300, query);
+    } else 
+        r300_emit_query_finish(r300, query);
 }
 
 void r300_emit_rs_state(struct r300_context* r300, struct r300_rs_state* rs)
 {
     CS_LOCALS(r300);
 
-    BEGIN_CS(20);
+    BEGIN_CS(22);
     OUT_CS_REG(R300_VAP_CNTL_STATUS, rs->vap_control_status);
     OUT_CS_REG(R300_GA_POINT_SIZE, rs->point_size);
     OUT_CS_REG_SEQ(R300_GA_POINT_MINMAX, 2);
@@ -414,6 +596,7 @@ void r300_emit_rs_state(struct r300_context* r300, struct r300_rs_state* rs)
     OUT_CS_REG(R300_GA_LINE_STIPPLE_CONFIG, rs->line_stipple_config);
     OUT_CS_REG(R300_GA_LINE_STIPPLE_VALUE, rs->line_stipple_value);
     OUT_CS_REG(R300_GA_COLOR_CONTROL, rs->color_control);
+    OUT_CS_REG(R300_GA_POLY_MODE, rs->polygon_mode);
     END_CS;
 }
 
@@ -424,6 +607,8 @@ void r300_emit_rs_block_state(struct r300_context* r300,
     struct r300_screen* r300screen = r300_screen(r300->context.screen);
     CS_LOCALS(r300);
 
+    DBG(r300, DBG_DRAW, "r300: RS emit:\n");
+
     BEGIN_CS(21);
     if (r300screen->caps->is_r500) {
         OUT_CS_REG_SEQ(R500_RS_IP_0, 8);
@@ -432,7 +617,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]); */
+        DBG(r300, DBG_DRAW, "    : ip %d: 0x%08x\n", i, rs->ip[i]);
     }
 
     OUT_CS_REG_SEQ(R300_RS_COUNT, 2);
@@ -446,40 +631,67 @@ 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]); */
+        DBG(r300, DBG_DRAW, "    : inst %d: 0x%08x\n", i, rs->inst[i]);
     }
 
-    /* debug_printf("count: 0x%08x inst_count: 0x%08x\n", rs->count,
-     *        rs->inst_count); */
+    DBG(r300, DBG_DRAW, "    : count: 0x%08x inst_count: 0x%08x\n",
+        rs->count, rs->inst_count);
 
     END_CS;
 }
 
-void r300_emit_scissor_state(struct r300_context* r300,
-                             struct r300_scissor_state* scissor)
+static void r300_emit_scissor_regs(struct r300_context* r300,
+                                   struct r300_scissor_regs* scissor)
 {
     CS_LOCALS(r300);
 
     BEGIN_CS(3);
     OUT_CS_REG_SEQ(R300_SC_SCISSORS_TL, 2);
-    OUT_CS(scissor->scissor_top_left);
-    OUT_CS(scissor->scissor_bottom_right);
+    OUT_CS(scissor->top_left);
+    OUT_CS(scissor->bottom_right);
     END_CS;
 }
 
+void r300_emit_scissor_state(struct r300_context* r300,
+                             struct r300_scissor_state* scissor)
+{
+    if (r300->rs_state->rs.scissor) {
+        r300_emit_scissor_regs(r300, &scissor->scissor);
+    } else {
+        r300_emit_scissor_regs(r300, &scissor->framebuffer);
+    }
+}
+
 void r300_emit_texture(struct r300_context* r300,
                        struct r300_sampler_state* sampler,
                        struct r300_texture* tex,
                        unsigned offset)
 {
+    uint32_t filter0 = sampler->filter0;
+    uint32_t format0 = tex->state.format0;
+    unsigned min_level, max_level;
     CS_LOCALS(r300);
 
+    /* to emulate 1D textures through 2D ones correctly */
+    if (tex->tex.target == PIPE_TEXTURE_1D) {
+        filter0 &= ~R300_TX_WRAP_T_MASK;
+        filter0 |= R300_TX_WRAP_T(R300_TX_CLAMP_TO_EDGE);
+    }
+
+    /* determine min/max levels */
+    /* the MAX_MIP level is the largest (finest) one */
+    max_level = MIN2(sampler->max_lod, tex->tex.last_level);
+    min_level = MIN2(sampler->min_lod, max_level);
+    format0 |= R300_TX_NUM_LEVELS(max_level);
+    filter0 |= R300_TX_MAX_MIP_LEVEL(min_level);
+
     BEGIN_CS(16);
-    OUT_CS_REG(R300_TX_FILTER0_0 + (offset * 4), sampler->filter0);
+    OUT_CS_REG(R300_TX_FILTER0_0 + (offset * 4), filter0 |
+        (offset << 28));
     OUT_CS_REG(R300_TX_FILTER1_0 + (offset * 4), sampler->filter1);
     OUT_CS_REG(R300_TX_BORDER_COLOR_0 + (offset * 4), sampler->border_color);
 
-    OUT_CS_REG(R300_TX_FORMAT0_0 + (offset * 4), tex->state.format0);
+    OUT_CS_REG(R300_TX_FORMAT0_0 + (offset * 4), format0);
     OUT_CS_REG(R300_TX_FORMAT1_0 + (offset * 4), tex->state.format1);
     OUT_CS_REG(R300_TX_FORMAT2_0 + (offset * 4), tex->state.format2);
     OUT_CS_REG_SEQ(R300_TX_OFFSET_0 + (offset * 4), 1);
@@ -488,13 +700,76 @@ void r300_emit_texture(struct r300_context* r300,
     END_CS;
 }
 
-void r300_emit_vertex_buffer(struct r300_context* r300)
+static boolean r300_validate_aos(struct r300_context *r300)
+{
+    struct pipe_vertex_buffer *vbuf = r300->vertex_buffer;
+    struct pipe_vertex_element *velem = r300->vertex_element;
+    int i;
+
+    /* Check if formats and strides are aligned to the size of DWORD. */
+    for (i = 0; i < r300->vertex_element_count; i++) {
+        if (vbuf[velem[i].vertex_buffer_index].stride % 4 != 0 ||
+            util_format_get_blocksize(velem[i].src_format) % 4 != 0) {
+            return FALSE;
+        }
+    }
+    return TRUE;
+}
+
+void r300_emit_aos(struct r300_context* r300, unsigned offset)
+{
+    struct pipe_vertex_buffer *vb1, *vb2, *vbuf = r300->vertex_buffer;
+    struct pipe_vertex_element *velem = r300->vertex_element;
+    int i;
+    unsigned size1, size2, aos_count = r300->vertex_element_count;
+    unsigned packet_size = (aos_count * 3 + 1) / 2;
+    CS_LOCALS(r300);
+
+    /* XXX Move this checking to a more approriate place. */
+    if (!r300_validate_aos(r300)) {
+        /* XXX We should fallback using Draw. */
+        assert(0);
+    }
+
+    BEGIN_CS(2 + packet_size + aos_count * 2);
+    OUT_CS_PKT3(R300_PACKET3_3D_LOAD_VBPNTR, packet_size);
+    OUT_CS(aos_count);
+
+    for (i = 0; i < aos_count - 1; i += 2) {
+        vb1 = &vbuf[velem[i].vertex_buffer_index];
+        vb2 = &vbuf[velem[i+1].vertex_buffer_index];
+        size1 = util_format_get_blocksize(velem[i].src_format);
+        size2 = util_format_get_blocksize(velem[i+1].src_format);
+
+        OUT_CS(R300_VBPNTR_SIZE0(size1) | R300_VBPNTR_STRIDE0(vb1->stride) |
+               R300_VBPNTR_SIZE1(size2) | R300_VBPNTR_STRIDE1(vb2->stride));
+        OUT_CS(vb1->buffer_offset + velem[i].src_offset   + offset * vb1->stride);
+        OUT_CS(vb2->buffer_offset + velem[i+1].src_offset + offset * vb2->stride);
+    }
+
+    if (aos_count & 1) {
+        vb1 = &vbuf[velem[i].vertex_buffer_index];
+        size1 = util_format_get_blocksize(velem[i].src_format);
+
+        OUT_CS(R300_VBPNTR_SIZE0(size1) | R300_VBPNTR_STRIDE0(vb1->stride));
+        OUT_CS(vb1->buffer_offset + velem[i].src_offset + offset * vb1->stride);
+    }
+
+    for (i = 0; i < aos_count; i++) {
+        OUT_CS_RELOC_NO_OFFSET(vbuf[velem[i].vertex_buffer_index].buffer,
+                               RADEON_GEM_DOMAIN_GTT, 0, 0);
+    }
+    END_CS;
+}
+
+#if 0
+void r300_emit_draw_packet(struct r300_context* r300)
 {
     CS_LOCALS(r300);
 
     DBG(r300, DBG_DRAW, "r300: Preparing vertex buffer %p for render, "
             "vertex size %d\n", r300->vbo,
-            r300->vertex_info.vinfo.size);
+            r300->vertex_info->vinfo.size);
     /* Set the pointer to our vertex buffer. The emitted values are this:
      * PACKET3 [3D_LOAD_VBPNTR]
      * COUNT   [1]
@@ -505,54 +780,66 @@ void r300_emit_vertex_buffer(struct r300_context* r300)
     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->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;
 }
+#endif
 
 void r300_emit_vertex_format_state(struct r300_context* r300)
 {
     int i;
     CS_LOCALS(r300);
 
+    DBG(r300, DBG_DRAW, "r300: VAP/PSC emit:\n");
+
     BEGIN_CS(26);
-    OUT_CS_REG(R300_VAP_VTX_SIZE, r300->vertex_info.vinfo.size);
+    OUT_CS_REG(R300_VAP_VTX_SIZE, r300->vertex_info->vinfo.size);
 
     OUT_CS_REG_SEQ(R300_VAP_VTX_STATE_CNTL, 2);
-    OUT_CS(r300->vertex_info.vinfo.hwfmt[0]);
-    OUT_CS(r300->vertex_info.vinfo.hwfmt[1]);
+    OUT_CS(r300->vertex_info->vinfo.hwfmt[0]);
+    OUT_CS(r300->vertex_info->vinfo.hwfmt[1]);
     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]);
-     * } */
+    OUT_CS(r300->vertex_info->vinfo.hwfmt[2]);
+    OUT_CS(r300->vertex_info->vinfo.hwfmt[3]);
+    for (i = 0; i < 4; i++) {
+       DBG(r300, DBG_DRAW, "    : 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]); */
+        OUT_CS(r300->vertex_info->vap_prog_stream_cntl[i]);
+        DBG(r300, DBG_DRAW, "    : 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]); */
+        OUT_CS(r300->vertex_info->vap_prog_stream_cntl_ext[i]);
+        DBG(r300, DBG_DRAW, "    : prog_stream_cntl_ext%d: 0x%08x\n", i,
+               r300->vertex_info->vap_prog_stream_cntl_ext[i]);
     }
     END_CS;
 }
 
+
 void r300_emit_vertex_program_code(struct r300_context* r300,
-                                   struct r300_vertex_program_code* code,
-                                   struct r300_constant_buffer* constants)
+                                   struct r300_vertex_program_code* code)
 {
     int i;
     struct r300_screen* r300screen = r300_screen(r300->context.screen);
     unsigned instruction_count = code->length / 4;
+
+    int vtx_mem_size = r300screen->caps->is_r500 ? 128 : 72;
+    int input_count = MAX2(util_bitcount(code->InputsRead), 1);
+    int output_count = MAX2(util_bitcount(code->OutputsWritten), 1);
+    int temp_count = MAX2(code->num_temporaries, 1);
+    int pvs_num_slots = MIN3(vtx_mem_size / input_count,
+                             vtx_mem_size / output_count, 10);
+    int pvs_num_controllers = MIN2(vtx_mem_size / temp_count, 6);
+
     CS_LOCALS(r300);
 
     if (!r300screen->caps->has_tcl) {
@@ -561,17 +848,11 @@ void r300_emit_vertex_program_code(struct r300_context* r300,
         return;
     }
 
-    if (code->constants.Count) {
-        BEGIN_CS(14 + code->length + (code->constants.Count * 4));
-    } else {
-        BEGIN_CS(11 + code->length);
-    }
-
+    BEGIN_CS(9 + code->length);
     /* 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... */
+     * See the r5xx docs for instructions on how to use these. */
     OUT_CS_REG_SEQ(R300_VAP_PVS_CODE_CNTL_0, 3);
     OUT_CS(R300_PVS_FIRST_INST(0) |
             R300_PVS_XYZW_VALID_INST(instruction_count - 1) |
@@ -584,32 +865,51 @@ void r300_emit_vertex_program_code(struct r300_context* r300,
     for (i = 0; i < code->length; i++)
         OUT_CS(code->body.d[i]);
 
-    if (code->constants.Count) {
-        OUT_CS_REG(R300_VAP_PVS_VECTOR_INDX_REG,
-                (r300screen->caps->is_r500 ?
-                 R500_PVS_CONST_START : R300_PVS_CONST_START));
-        OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, code->constants.Count * 4);
-        for (i = 0; i < code->constants.Count; i++) {
-            const float * data = get_shader_constant(r300, &code->constants.Constants[i], constants);
-            OUT_CS_32F(data[0]);
-            OUT_CS_32F(data[1]);
-            OUT_CS_32F(data[2]);
-            OUT_CS_32F(data[3]);
-        }
-    }
-
-    OUT_CS_REG(R300_VAP_CNTL, R300_PVS_NUM_SLOTS(10) |
-            R300_PVS_NUM_CNTLRS(5) |
+    OUT_CS_REG(R300_VAP_CNTL, R300_PVS_NUM_SLOTS(pvs_num_slots) |
+            R300_PVS_NUM_CNTLRS(pvs_num_controllers) |
             R300_PVS_NUM_FPUS(r300screen->caps->num_vert_fpus) |
-            R300_PVS_VF_MAX_VTX_NUM(12));
-    OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0x0);
+            R300_PVS_VF_MAX_VTX_NUM(12) |
+            (r300screen->caps->is_r500 ? R500_TCL_STATE_OPTIMIZATION : 0));
     END_CS;
 }
 
 void r300_emit_vertex_shader(struct r300_context* r300,
                              struct r300_vertex_shader* vs)
 {
-    r300_emit_vertex_program_code(r300, &vs->code, &r300->shader_constants[PIPE_SHADER_VERTEX]);
+    r300_emit_vertex_program_code(r300, &vs->code);
+}
+
+void r300_emit_vs_constant_buffer(struct r300_context* r300,
+                                  struct rc_constant_list* constants)
+{
+    int i;
+    struct r300_screen* r300screen = r300_screen(r300->context.screen);
+    CS_LOCALS(r300);
+
+    if (!r300screen->caps->has_tcl) {
+        debug_printf("r300: Implementation error: emit_vertex_shader called,"
+        " but has_tcl is FALSE!\n");
+        return;
+    }
+
+    if (constants->Count == 0)
+        return;
+
+    BEGIN_CS(constants->Count * 4 + 3);
+    OUT_CS_REG(R300_VAP_PVS_VECTOR_INDX_REG,
+               (r300screen->caps->is_r500 ?
+               R500_PVS_CONST_START : R300_PVS_CONST_START));
+    OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, constants->Count * 4);
+    for (i = 0; i < constants->Count; i++) {
+        const float * data = get_shader_constant(r300,
+                                                 &constants->Constants[i],
+                                                 &r300->shader_constants[PIPE_SHADER_VERTEX]);
+        OUT_CS_32F(data[0]);
+        OUT_CS_32F(data[1]);
+        OUT_CS_32F(data[2]);
+        OUT_CS_32F(data[3]);
+    }
+    END_CS;
 }
 
 void r300_emit_viewport_state(struct r300_context* r300,
@@ -634,13 +934,42 @@ void r300_emit_viewport_state(struct r300_context* r300,
     END_CS;
 }
 
+void r300_emit_texture_count(struct r300_context* r300)
+{
+    uint32_t tx_enable = 0;
+    int i;
+    CS_LOCALS(r300);
+
+    /* Notice that texture_count and sampler_count are just sizes
+     * of the respective arrays. We still have to check for the individual
+     * elements. */
+    for (i = 0; i < MIN2(r300->sampler_count, r300->texture_count); i++) {
+        if (r300->textures[i]) {
+            tx_enable |= 1 << i;
+        }
+    }
+
+    BEGIN_CS(2);
+    OUT_CS_REG(R300_TX_ENABLE, tx_enable);
+    END_CS;
+
+}
+
 void r300_flush_textures(struct r300_context* r300)
 {
     CS_LOCALS(r300);
 
-    BEGIN_CS(4);
+    BEGIN_CS(2);
     OUT_CS_REG(R300_TX_INVALTAGS, 0);
-    OUT_CS_REG(R300_TX_ENABLE, (1 << r300->texture_count) - 1);
+    END_CS;
+}
+
+static void r300_flush_pvs(struct r300_context* r300)
+{
+    CS_LOCALS(r300);
+
+    BEGIN_CS(2);
+    OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0x0);
     END_CS;
 }
 
@@ -656,9 +985,17 @@ void r300_emit_dirty_state(struct r300_context* r300)
         return;
     }
 
-    r300_update_derived_state(r300);
+    /* Check size of CS. */
+    /* Make sure we have at least 8*1024 spare dwords. */
+    /* XXX It would be nice to know the number of dwords we really need to
+     * XXX emit. */
+    if (!r300->winsys->check_cs(r300->winsys, 8*1024)) {
+        r300->context.flush(&r300->context, 0, NULL);
+    }
+
+    /* Clean out BOs. */
+    r300->winsys->reset_bos(r300->winsys);
 
-    /* XXX check size */
 validate:
     /* Color buffers... */
     for (i = 0; i < r300->framebuffer_state.nr_cbufs; i++) {
@@ -683,7 +1020,8 @@ validate:
     /* ...textures... */
     for (i = 0; i < r300->texture_count; i++) {
         tex = r300->textures[i];
-        assert(tex && tex->buffer && "texture is marked, but NULL!");
+        if (!tex)
+            continue;
         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);
@@ -704,7 +1042,7 @@ validate:
             goto validate;
         }
     } else {
-        debug_printf("No VBO while emitting dirty state!\n");
+        /* debug_printf("No VBO while emitting dirty state!\n"); */
     }
     if (!r300->winsys->validate(r300->winsys)) {
         r300->context.flush(&r300->context, 0, NULL);
@@ -717,6 +1055,11 @@ validate:
         goto validate;
     }
 
+    if (r300->dirty_state & R300_NEW_QUERY) {
+        r300_emit_query_start(r300);
+        r300->dirty_state &= ~R300_NEW_QUERY;
+    }
+
     if (r300->dirty_state & R300_NEW_BLEND) {
         r300_emit_blend_state(r300, r300->blend_state);
         r300->dirty_state &= ~R300_NEW_BLEND;
@@ -738,14 +1081,26 @@ validate:
     }
 
     if (r300->dirty_state & R300_NEW_FRAGMENT_SHADER) {
+        r300_emit_fragment_depth_config(r300, r300->fs);
         if (r300screen->caps->is_r500) {
-            r500_emit_fragment_program_code(r300, &r300->fs->code, &r300->shader_constants[PIPE_SHADER_FRAGMENT]);
+            r500_emit_fragment_program_code(r300, &r300->fs->shader->code);
         } else {
-            r300_emit_fragment_program_code(r300, &r300->fs->code, &r300->shader_constants[PIPE_SHADER_FRAGMENT]);
+            r300_emit_fragment_program_code(r300, &r300->fs->shader->code);
         }
         r300->dirty_state &= ~R300_NEW_FRAGMENT_SHADER;
     }
 
+    if (r300->dirty_state & R300_NEW_FRAGMENT_SHADER_CONSTANTS) {
+        if (r300screen->caps->is_r500) {
+            r500_emit_fs_constant_buffer(r300,
+                                         &r300->fs->shader->code.constants);
+        } else {
+            r300_emit_fs_constant_buffer(r300,
+                                         &r300->fs->shader->code.constants);
+        }
+        r300->dirty_state &= ~R300_NEW_FRAGMENT_SHADER_CONSTANTS;
+    }
+
     if (r300->dirty_state & R300_NEW_FRAMEBUFFERS) {
         r300_emit_fb_state(r300, &r300->framebuffer_state);
         r300->dirty_state &= ~R300_NEW_FRAMEBUFFERS;
@@ -769,13 +1124,16 @@ validate:
     /* Samplers and textures are tracked separately but emitted together. */
     if (r300->dirty_state &
             (R300_ANY_NEW_SAMPLERS | R300_ANY_NEW_TEXTURES)) {
+        r300_emit_texture_count(r300);
+
         for (i = 0; i < MIN2(r300->sampler_count, r300->texture_count); i++) {
-            if (r300->dirty_state &
-                    ((R300_NEW_SAMPLER << i) | (R300_NEW_TEXTURE << i))) {
-                r300_emit_texture(r300,
-                        r300->sampler_states[i],
-                        r300->textures[i],
-                        i);
+           if (r300->dirty_state &
+               ((R300_NEW_SAMPLER << i) | (R300_NEW_TEXTURE << i))) {
+               if (r300->textures[i]) 
+                   r300_emit_texture(r300,
+                                     r300->sampler_states[i],
+                                     r300->textures[i],
+                                     i);
                 r300->dirty_state &=
                     ~((R300_NEW_SAMPLER << i) | (R300_NEW_TEXTURE << i));
                 dirty_tex++;
@@ -798,17 +1156,26 @@ validate:
         r300->dirty_state &= ~R300_NEW_VERTEX_FORMAT;
     }
 
+    if (r300->dirty_state & (R300_NEW_VERTEX_SHADER | R300_NEW_VERTEX_SHADER_CONSTANTS)) {
+        r300_flush_pvs(r300);
+    }
+
     if (r300->dirty_state & R300_NEW_VERTEX_SHADER) {
         r300_emit_vertex_shader(r300, r300->vs);
         r300->dirty_state &= ~R300_NEW_VERTEX_SHADER;
     }
 
+    if (r300->dirty_state & R300_NEW_VERTEX_SHADER_CONSTANTS) {
+        r300_emit_vs_constant_buffer(r300, &r300->vs->code.constants);
+        r300->dirty_state &= ~R300_NEW_VERTEX_SHADER_CONSTANTS;
+    }
+
     /* XXX
     assert(r300->dirty_state == 0);
     */
 
     /* Finally, emit the VBO. */
-    r300_emit_vertex_buffer(r300);
+    /* r300_emit_vertex_buffer(r300); */
 
     r300->dirty_hw++;
 }
index c4002b8e5d00efa5dbca087d285899e888eb9c4a..3797d3d332addfdb133ce978854145b99932d71b 100644 (file)
 #ifndef R300_EMIT_H
 #define R300_EMIT_H
 
-#include "util/u_math.h"
-
 #include "r300_context.h"
-#include "r300_cs.h"
-#include "r300_screen.h"
-#include "r300_state_inlines.h"
+#include "radeon_code.h"
 
 struct rX00_fragment_program_code;
 struct r300_vertex_program_code;
 
+void r300_emit_aos(struct r300_context* r300, unsigned offset);
+
 void r300_emit_blend_state(struct r300_context* r300,
                            struct r300_blend_state* blend);
 
@@ -46,20 +44,24 @@ void r300_emit_dsa_state(struct r300_context* r300,
                          struct r300_dsa_state* dsa);
 
 void r300_emit_fragment_program_code(struct r300_context* r300,
-                                     struct rX00_fragment_program_code* generic_code,
-                                     struct r300_constant_buffer* externals);
+                                     struct rX00_fragment_program_code* generic_code);
+
+void r300_emit_fs_constant_buffer(struct r300_context* r300,
+                                  struct rc_constant_list* constants);
 
 void r500_emit_fragment_program_code(struct r300_context* r300,
-                                     struct rX00_fragment_program_code* generic_code,
-                                     struct r300_constant_buffer* externals);
+                                     struct rX00_fragment_program_code* generic_code);
+
+void r500_emit_fs_constant_buffer(struct r300_context* r300,
+                                  struct rc_constant_list* constants);
 
 void r300_emit_fb_state(struct r300_context* r300,
                         struct pipe_framebuffer_state* fb);
 
 void r300_emit_query_begin(struct r300_context* r300,
                            struct r300_query* query);
-void r300_emit_query_end(struct r300_context* r300,
-                         struct r300_query* query);
+
+void r300_emit_query_end(struct r300_context* r300);
 
 void r300_emit_rs_state(struct r300_context* r300, struct r300_rs_state* rs);
 
@@ -79,8 +81,10 @@ void r300_emit_vertex_buffer(struct r300_context* r300);
 void r300_emit_vertex_format_state(struct r300_context* r300);
 
 void r300_emit_vertex_program_code(struct r300_context* r300,
-                                   struct r300_vertex_program_code* code,
-                                   struct r300_constant_buffer* constants);
+                                   struct r300_vertex_program_code* code);
+
+void r300_emit_vs_constant_buffer(struct r300_context* r300,
+                                  struct rc_constant_list* constants);
 
 void r300_emit_vertex_shader(struct r300_context* r300,
                              struct r300_vertex_shader* vs);
@@ -88,6 +92,8 @@ void r300_emit_vertex_shader(struct r300_context* r300,
 void r300_emit_viewport_state(struct r300_context* r300,
                               struct r300_viewport_state* viewport);
 
+void r300_emit_texture_count(struct r300_context* r300);
+
 void r300_flush_textures(struct r300_context* r300);
 
 /* Emit all dirty state. */
index 0dff1c6f4fb59d085aa3b8bda377b9c8855192ac..14a08241fc460bb68416aa322c09d2ce1cec8fcc 100644 (file)
  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  * USE OR OTHER DEALINGS IN THE SOFTWARE. */
 
+#include "draw/draw_context.h"
+#include "draw/draw_private.h"
+
+#include "util/u_simple_list.h"
+
+#include "r300_context.h"
+#include "r300_cs.h"
+#include "r300_emit.h"
 #include "r300_flush.h"
+#include "r300_state_invariant.h"
 
 static void r300_flush(struct pipe_context* pipe,
                        unsigned flags,
                        struct pipe_fence_handle** fence)
 {
-    struct r300_contextr300 = r300_context(pipe);
-    CS_LOCALS(r300);
+    struct r300_context *r300 = r300_context(pipe);
+    struct r300_query *query;
 
+    CS_LOCALS(r300);
     /* We probably need to flush Draw, but we may have been called from
-     * within Draw. This feels kludgy, but it might be the best thing. */
-    if (!r300->draw->flushing) {
+     * within Draw. This feels kludgy, but it might be the best thing.
+     *
+     * Of course, the best thing is to kill Draw with fire. :3 */
+    if (r300->draw && !r300->draw->flushing) {
         draw_flush(r300->draw);
     }
 
+    r300_emit_query_end(r300);
+
     if (r300->dirty_hw) {
         FLUSH_CS;
         r300_emit_invariant_state(r300);
         r300->dirty_state = R300_NEW_KITCHEN_SINK;
         r300->dirty_hw = 0;
     }
+    /* reset flushed query */
+    foreach(query, &r300->query_list) {
+        query->flushed = TRUE;
+    }
 }
 
+
 void r300_init_flush_functions(struct r300_context* r300)
 {
     r300->context.flush = r300_flush;
index 9a83d89daab7dbce5d651d2066c089d3c8967fc5..0e9e6106bb77703d771336c2f72f00b59a1b2db7 100644 (file)
 #ifndef R300_FLUSH_H
 #define R300_FLUSH_H
 
-#include "draw/draw_private.h"
-
-#include "pipe/p_context.h"
-
-#include "r300_context.h"
-#include "r300_cs.h"
-
 void r300_init_flush_functions(struct r300_context* r300);
 
 #endif /* R300_FLUSH_H */
index 546ad545a5330754ad560759432a06982282014f..60ea9c171d5d9eef7090986dcf8080ce4fb1d8f7 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
  *                Joakim Sindholt <opensource@zhasha.com>
+ * Copyright 2009 Marek Olšák <maraeo@gmail.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  * USE OR OTHER DEALINGS IN THE SOFTWARE. */
 
-#include "r300_fs.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
+#include "tgsi/tgsi_dump.h"
 
+#include "r300_context.h"
+#include "r300_screen.h"
+#include "r300_fs.h"
 #include "r300_tgsi_to_rc.h"
 
+#include "radeon_code.h"
 #include "radeon_compiler.h"
 
+/* Convert info about FS input semantics to r300_shader_semantics. */
+void r300_shader_read_fs_inputs(struct tgsi_shader_info* info,
+                                struct r300_shader_semantics* fs_inputs)
+{
+    int i;
+    unsigned index;
+
+    r300_shader_semantics_reset(fs_inputs);
+
+    for (i = 0; i < info->num_inputs; i++) {
+        index = info->input_semantic_index[i];
+
+        switch (info->input_semantic_name[i]) {
+            case TGSI_SEMANTIC_COLOR:
+                assert(index <= ATTR_COLOR_COUNT);
+                fs_inputs->color[index] = i;
+                break;
+
+            case TGSI_SEMANTIC_GENERIC:
+                assert(index <= ATTR_GENERIC_COUNT);
+                fs_inputs->generic[index] = i;
+                break;
+
+            case TGSI_SEMANTIC_FOG:
+                assert(index == 0);
+                fs_inputs->fog = i;
+                break;
+
+            case TGSI_SEMANTIC_POSITION:
+                assert(index == 0);
+                fs_inputs->wpos = i;
+                break;
+
+            default:
+                assert(0);
+        }
+    }
+}
+
 static void find_output_registers(struct r300_fragment_program_compiler * compiler,
                                   struct r300_fragment_shader * fs)
 {
@@ -54,61 +101,69 @@ static void allocate_hardware_inputs(
     void (*allocate)(void * data, unsigned input, unsigned hwreg),
     void * mydata)
 {
-    struct tgsi_shader_info* info = &((struct r300_fragment_shader*)c->UserData)->info;
-    int total_colors = 0;
-    int colors = 0;
-    int total_generic = 0;
-    int generic = 0;
-    int i;
-
-    for (i = 0; i < info->num_inputs; i++) {
-        switch (info->input_semantic_name[i]) {
-            case TGSI_SEMANTIC_COLOR:
-                total_colors++;
-                break;
-            case TGSI_SEMANTIC_FOG:
-            case TGSI_SEMANTIC_GENERIC:
-                total_generic++;
-                break;
+    struct r300_shader_semantics* inputs =
+        (struct r300_shader_semantics*)c->UserData;
+    int i, reg = 0;
+
+    /* Allocate input registers. */
+    for (i = 0; i < ATTR_COLOR_COUNT; i++) {
+        if (inputs->color[i] != ATTR_UNUSED) {
+            allocate(mydata, inputs->color[i], reg++);
+        }
+    }
+    for (i = 0; i < ATTR_GENERIC_COUNT; i++) {
+        if (inputs->generic[i] != ATTR_UNUSED) {
+            allocate(mydata, inputs->generic[i], reg++);
         }
     }
+    if (inputs->fog != ATTR_UNUSED) {
+        allocate(mydata, inputs->fog, reg++);
+    }
+    if (inputs->wpos != ATTR_UNUSED) {
+        allocate(mydata, inputs->wpos, reg++);
+    }
+}
 
-    for(i = 0; i < info->num_inputs; i++) {
-        switch (info->input_semantic_name[i]) {
-            case TGSI_SEMANTIC_COLOR:
-                allocate(mydata, i, colors);
-                colors++;
-                break;
-            case TGSI_SEMANTIC_FOG:
-            case TGSI_SEMANTIC_GENERIC:
-                allocate(mydata, i, total_colors + generic);
-                generic++;
-                break;
+static void get_compare_state(
+    struct r300_context* r300,
+    struct r300_fragment_program_external_state* state,
+    unsigned shadow_samplers)
+{
+    memset(state, 0, sizeof(*state));
+
+    for (int i = 0; i < r300->sampler_count; i++) {
+        struct r300_sampler_state* s = r300->sampler_states[i];
+
+        if (s && s->state.compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) {
+            /* XXX Gallium doesn't provide us with any information regarding
+             * this mode, so we are screwed. I'm setting 0 = LUMINANCE. */
+            state->unit[i].depth_texture_mode = 0;
+
+            /* Fortunately, no need to translate this. */
+            state->unit[i].texture_compare_func = s->state.compare_func;
         }
     }
 }
 
-void r300_translate_fragment_shader(struct r300_context* r300,
-                                    struct r300_fragment_shader* fs)
+static void r300_translate_fragment_shader(
+    struct r300_context* r300,
+    struct r300_fragment_shader_code* shader)
 {
+    struct r300_fragment_shader* fs = r300->fs;
     struct r300_fragment_program_compiler compiler;
     struct tgsi_to_rc ttr;
+    int wpos = fs->inputs.wpos;
 
+    /* Setup the compiler. */
     memset(&compiler, 0, sizeof(compiler));
     rc_init(&compiler.Base);
     compiler.Base.Debug = DBG_ON(r300, DBG_FP);
 
-    compiler.code = &fs->code;
+    compiler.code = &shader->code;
+    compiler.state = shader->compare_state;
     compiler.is_r500 = r300_screen(r300->context.screen)->caps->is_r500;
     compiler.AllocateHwInputs = &allocate_hardware_inputs;
-    compiler.UserData = fs;
-
-    /* TODO: Program compilation depends on texture compare modes,
-     * which are sampler state. Therefore, programs need to be recompiled
-     * depending on this state as in the classic Mesa driver.
-     *
-     * This is not yet handled correctly.
-     */
+    compiler.UserData = &fs->inputs;
 
     find_output_registers(&compiler, fs);
 
@@ -123,20 +178,76 @@ void r300_translate_fragment_shader(struct r300_context* r300,
 
     r300_tgsi_to_rc(&ttr, fs->state.tokens);
 
+    fs->shadow_samplers = compiler.Base.Program.ShadowSamplers;
+
+    /**
+     * Transform the program to support WPOS.
+     *
+     * Introduce a small fragment at the start of the program that will be
+     * the only code that directly reads the WPOS input.
+     * All other code pieces that reference that input will be rewritten
+     * to read from a newly allocated temporary. */
+    if (wpos != ATTR_UNUSED) {
+        /* Moving the input to some other reg is not really necessary. */
+        rc_transform_fragment_wpos(&compiler.Base, wpos, wpos, TRUE);
+    }
+
     /* Invoke the compiler */
     r3xx_compile_fragment_program(&compiler);
     if (compiler.Base.Error) {
-        /* Todo: Fallback to software rendering gracefully? */
-        fprintf(stderr, "r300 FP: Compiler error: %s\n", compiler.Base.ErrorMsg);
-
-        if (compiler.is_r500) {
-            memcpy(compiler.code, &r5xx_passthrough_fragment_shader, sizeof(r5xx_passthrough_fragment_shader));
-        } else {
-            memcpy(compiler.code, &r3xx_passthrough_fragment_shader, sizeof(r3xx_passthrough_fragment_shader));
-        }
+        /* XXX failover maybe? */
+        DBG(r300, DBG_FP, "r300: Error compiling fragment program: %s\n",
+            compiler.Base.ErrorMsg);
+        assert(0);
     }
 
     /* And, finally... */
     rc_destroy(&compiler.Base);
-    fs->translated = TRUE;
+}
+
+boolean r300_pick_fragment_shader(struct r300_context* r300)
+{
+    struct r300_fragment_shader* fs = r300->fs;
+    struct r300_fragment_program_external_state state;
+    struct r300_fragment_shader_code* ptr;
+
+    if (!fs->first) {
+        /* Build the fragment shader for the first time. */
+        fs->first = fs->shader = CALLOC_STRUCT(r300_fragment_shader_code);
+
+        /* BTW shadow samplers will be known after the first translation,
+         * therefore we set ~0, which means it should look at all sampler
+         * states. This choice doesn't have any impact on the correctness. */
+        get_compare_state(r300, &fs->shader->compare_state, ~0);
+        r300_translate_fragment_shader(r300, fs->shader);
+        return TRUE;
+
+    } else if (fs->shadow_samplers) {
+        get_compare_state(r300, &state, fs->shadow_samplers);
+
+        /* Check if the currently-bound shader has been compiled
+         * with the texture-compare state we need. */
+        if (memcmp(&fs->shader->compare_state, &state, sizeof(state)) != 0) {
+            /* Search for the right shader. */
+            ptr = fs->first;
+            while (ptr) {
+                if (memcmp(&ptr->compare_state, &state, sizeof(state)) == 0) {
+                    fs->shader = ptr;
+                    return TRUE;
+                }
+                ptr = ptr->next;
+            }
+
+            /* Not found, gotta compile a new one. */
+            ptr = CALLOC_STRUCT(r300_fragment_shader_code);
+            ptr->next = fs->first;
+            fs->first = fs->shader = ptr;
+
+            ptr->compare_state = state;
+            r300_translate_fragment_shader(r300, ptr);
+            return TRUE;
+        }
+    }
+
+    return FALSE;
 }
index 967e9f697e9aac47b1c7fe93750a6f1756ccb8d8..40ce874353c08bf2cb429bc4c0acc816ad26e475 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
  *                Joakim Sindholt <opensource@zhasha.com>
+ * Copyright 2009 Marek Olšák <maraeo@gmail.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
 #ifndef R300_FS_H
 #define R300_FS_H
 
-#include "tgsi/tgsi_dump.h"
+#include "pipe/p_state.h"
+#include "tgsi/tgsi_scan.h"
+#include "radeon_code.h"
+#include "r300_shader_semantics.h"
 
-#include "r300_context.h"
-#include "r3xx_fs.h"
-#include "r5xx_fs.h"
+struct r300_fragment_shader_code {
+    struct r300_fragment_program_external_state compare_state;
+    struct rX00_fragment_program_code code;
 
-#include "radeon_code.h"
+    struct r300_fragment_shader_code* next;
+};
 
 struct r300_fragment_shader {
     /* Parent class */
     struct pipe_shader_state state;
+
     struct tgsi_shader_info info;
+    struct r300_shader_semantics inputs;
 
-    /* Has this shader been translated yet? */
-    boolean translated;
+    /* Bits 0-15: TRUE if it's a shadow sampler, FALSE otherwise. */
+    unsigned shadow_samplers;
 
-    /* Compiled code */
-    struct rX00_fragment_program_code code;
+    /* Currently-bound fragment shader. */
+    struct r300_fragment_shader_code* shader;
+
+    /* List of the same shaders compiled with different texture-compare
+     * states. */
+    struct r300_fragment_shader_code* first;
 };
 
+void r300_shader_read_fs_inputs(struct tgsi_shader_info* info,
+                                struct r300_shader_semantics* fs_inputs);
+
+/* Return TRUE if the shader was switched and should be re-emitted. */
+boolean r300_pick_fragment_shader(struct r300_context* r300);
 
-void r300_translate_fragment_shader(struct r300_context* r300,
-                                    struct r300_fragment_shader* fs);
+static INLINE boolean r300_fragment_shader_writes_depth(struct r300_fragment_shader *fs)
+{
+    if (!fs)
+        return FALSE;
+    return (fs->shader->code.writes_depth) ? TRUE : FALSE;
+}
 
 #endif /* R300_FS_H */
index 2880d34877f29c456b2ea9e3e6af675e72c49f20..ca00b043c51d85dab138eb1998387d688154ce9e 100644 (file)
  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  * USE OR OTHER DEALINGS IN THE SOFTWARE. */
 
-#include "r300_query.h"
+#include "util/u_memory.h"
+#include "util/u_simple_list.h"
 
+#include "r300_context.h"
+#include "r300_screen.h"
+#include "r300_cs.h"
 #include "r300_emit.h"
+#include "r300_query.h"
+#include "r300_reg.h"
 
-static struct pipe_query* r300_create_query(struct pipe_context* pipe,
+static struct pipe_query *r300_create_query(struct pipe_context *pipe,
                                             unsigned query_type)
 {
-    struct r300_contextr300 = r300_context(pipe);
-    struct r300_screenr300screen = r300_screen(r300->context.screen);
-    unsigned query_size = r300screen->caps->num_frag_pipes * 4;
-    struct r300_query* q, * qptr;
+    struct r300_context *r300 = r300_context(pipe);
+    struct r300_screen *r300screen = r300_screen(r300->context.screen);
+    unsigned query_size;
+    struct r300_query *q, *qptr;
 
     q = CALLOC_STRUCT(r300_query);
 
@@ -39,13 +45,16 @@ static struct pipe_query* r300_create_query(struct pipe_context* pipe,
 
     q->active = FALSE;
 
-    if (!r300->query_list) {
-        r300->query_list = q;
-    } else if (!is_empty_list(r300->query_list)) {
-        qptr = last_elem(r300->query_list);
+    if (r300screen->caps->family == CHIP_FAMILY_RV530)
+       query_size = r300screen->caps->num_z_pipes * sizeof(uint32_t);
+    else
+       query_size = r300screen->caps->num_frag_pipes * sizeof(uint32_t);
+
+    if (!is_empty_list(&r300->query_list)) {
+        qptr = last_elem(&r300->query_list);
         q->offset = qptr->offset + query_size;
-        insert_at_tail(r300->query_list, q);
     }
+    insert_at_tail(&r300->query_list, q);
 
     /* XXX */
     if (q->offset >= 4096) {
@@ -71,24 +80,26 @@ static void r300_begin_query(struct pipe_context* pipe,
     struct r300_context* r300 = r300_context(pipe);
     struct r300_query* q = (struct r300_query*)query;
 
+    assert(r300->query_current == NULL);
+
     map = pipe->screen->buffer_map(pipe->screen, r300->oqbo,
             PIPE_BUFFER_USAGE_CPU_WRITE);
     map += q->offset / 4;
-    *map = ~0;
+    *map = ~0U;
     pipe->screen->buffer_unmap(pipe->screen, r300->oqbo);
 
-    r300_emit_dirty_state(r300);
-    r300_emit_query_begin(r300, q);
+    q->flushed = FALSE;
+    r300->query_current = q;
+    r300->dirty_state |= R300_NEW_QUERY;
 }
 
 static void r300_end_query(struct pipe_context* pipe,
-                           struct pipe_query* query)
+                          struct pipe_query* query)
 {
     struct r300_context* r300 = r300_context(pipe);
-    struct r300_query* q = (struct r300_query*)query;
 
-    r300_emit_dirty_state(r300);
-    r300_emit_query_end(r300, q);
+    r300_emit_query_end(r300);
+    r300->query_current = NULL;
 }
 
 static boolean r300_get_query_result(struct pipe_context* pipe,
@@ -98,28 +109,36 @@ static boolean r300_get_query_result(struct pipe_context* pipe,
 {
     struct r300_context* r300 = r300_context(pipe);
     struct r300_screen* r300screen = r300_screen(r300->context.screen);
-    struct r300_queryq = (struct r300_query*)query;
+    struct r300_query *q = (struct r300_query*)query;
     unsigned flags = PIPE_BUFFER_USAGE_CPU_READ;
     uint32_t* map;
-    uint32_t temp;
-    unsigned i;
+    uint32_t temp = 0;
+    unsigned i, num_results;
 
-    if (wait) {
+    if (q->flushed == FALSE)
         pipe->flush(pipe, 0, NULL);
-    } else {
+    if (!wait) {
         flags |= PIPE_BUFFER_USAGE_DONTBLOCK;
     }
 
     map = pipe->screen->buffer_map(pipe->screen, r300->oqbo, flags);
+    if (!map)
+        return FALSE;
     map += q->offset / 4;
-    for (i = 0; i < r300screen->caps->num_frag_pipes; i++) {
-        if (*map == ~0) {
+
+    if (r300screen->caps->family == CHIP_FAMILY_RV530)
+        num_results = r300screen->caps->num_z_pipes;
+    else
+        num_results = r300screen->caps->num_frag_pipes;
+
+    for (i = 0; i < num_results; i++) {
+        if (*map == ~0U) {
             /* Looks like our results aren't ready yet. */
             if (wait) {
                 debug_printf("r300: Despite waiting, OQ results haven't"
                         " come in yet.\n");
             }
-            temp = ~0;
+            temp = ~0U;
             break;
         }
         temp += *map;
@@ -127,7 +146,7 @@ static boolean r300_get_query_result(struct pipe_context* pipe,
     }
     pipe->screen->buffer_unmap(pipe->screen, r300->oqbo);
 
-    if (temp == ~0) {
+    if (temp == ~0U) {
         /* Our results haven't been written yet... */
         return FALSE;
     }
index 4f50e8f84401599ddd5ae9b89ffe92219089287d..48876da3123947131b6e680140205da5ee6d42b9 100644 (file)
 #ifndef R300_QUERY_H
 #define R300_QUERY_H
 
-#include "r300_context.h"
-#include "r300_cs.h"
-#include "r300_reg.h"
-
 struct r300_context;
 
 static INLINE struct r300_query* r300_query(struct pipe_query* q)
index 3abff5db6222d039b925c67f3ea514803ccb3fdd..034bfc15cf952a86eb37cdf657a8b1290d8521db 100644 (file)
@@ -348,6 +348,27 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #       define R300_WRITE_ENA_W                         8
 #       define R300_SWIZZLE1_SHIFT                      16
 
+#       define R300_VAP_SWIZZLE_X001 \
+        ((R300_SWIZZLE_SELECT_X << R300_SWIZZLE_SELECT_X_SHIFT) | \
+         (R300_SWIZZLE_SELECT_FP_ZERO << R300_SWIZZLE_SELECT_Y_SHIFT) | \
+         (R300_SWIZZLE_SELECT_FP_ZERO << R300_SWIZZLE_SELECT_Z_SHIFT) | \
+         (R300_SWIZZLE_SELECT_FP_ONE << R300_SWIZZLE_SELECT_W_SHIFT) | \
+         (0xf << R300_WRITE_ENA_SHIFT))
+
+#       define R300_VAP_SWIZZLE_XY01 \
+        ((R300_SWIZZLE_SELECT_X << R300_SWIZZLE_SELECT_X_SHIFT) | \
+         (R300_SWIZZLE_SELECT_Y << R300_SWIZZLE_SELECT_Y_SHIFT) | \
+         (R300_SWIZZLE_SELECT_FP_ZERO << R300_SWIZZLE_SELECT_Z_SHIFT) | \
+         (R300_SWIZZLE_SELECT_FP_ONE << R300_SWIZZLE_SELECT_W_SHIFT) | \
+         (0xf << R300_WRITE_ENA_SHIFT))
+
+#       define R300_VAP_SWIZZLE_XYZ1 \
+        ((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_FP_ONE << R300_SWIZZLE_SELECT_W_SHIFT) | \
+         (0xf << R300_WRITE_ENA_SHIFT))
+
 #       define R300_VAP_SWIZZLE_XYZW \
         ((R300_SWIZZLE_SELECT_X << R300_SWIZZLE_SELECT_X_SHIFT) | \
          (R300_SWIZZLE_SELECT_Y << R300_SWIZZLE_SELECT_Y_SHIFT) | \
@@ -640,20 +661,20 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #      define R300_GB_SUPER_TILE_B             (1 << 15)
 #      define R300_GB_SUBPIXEL_1_12            (0 << 16)
 #      define R300_GB_SUBPIXEL_1_16            (1 << 16)
-#      define GB_TILE_CONFIG_QUADS_PER_RAS_4   (0 << 17)
-#      define GB_TILE_CONFIG_QUADS_PER_RAS_8   (1 << 17)
-#      define GB_TILE_CONFIG_QUADS_PER_RAS_16  (2 << 17)
-#      define GB_TILE_CONFIG_QUADS_PER_RAS_32  (3 << 17)
-#      define GB_TILE_CONFIG_BB_SCAN_INTERCEPT (0 << 19)
-#      define GB_TILE_CONFIG_BB_SCAN_BOUND_BOX (1 << 19)
-#      define GB_TILE_CONFIG_ALT_SCAN_EN_LR    (0 << 20)
-#      define GB_TILE_CONFIG_ALT_SCAN_EN_LRL   (1 << 20)
-#      define GB_TILE_CONFIG_ALT_OFFSET        (0 << 21)
-#      define GB_TILE_CONFIG_SUBPRECISION      (0 << 22)
-#      define GB_TILE_CONFIG_ALT_TILING_DEF    (0 << 23)
-#      define GB_TILE_CONFIG_ALT_TILING_3_2    (1 << 23)
-#      define GB_TILE_CONFIG_Z_EXTENDED_24_1   (0 << 24)
-#      define GB_TILE_CONFIG_Z_EXTENDED_S25_1  (1 << 24)
+#      define R300_GB_TILE_CONFIG_QUADS_PER_RAS_4   (0 << 17)
+#      define R300_GB_TILE_CONFIG_QUADS_PER_RAS_8   (1 << 17)
+#      define R300_GB_TILE_CONFIG_QUADS_PER_RAS_16  (2 << 17)
+#      define R300_GB_TILE_CONFIG_QUADS_PER_RAS_32  (3 << 17)
+#      define R300_GB_TILE_CONFIG_BB_SCAN_INTERCEPT (0 << 19)
+#      define R300_GB_TILE_CONFIG_BB_SCAN_BOUND_BOX (1 << 19)
+#      define R300_GB_TILE_CONFIG_ALT_SCAN_EN_LR    (0 << 20)
+#      define R300_GB_TILE_CONFIG_ALT_SCAN_EN_LRL   (1 << 20)
+#      define R300_GB_TILE_CONFIG_ALT_OFFSET        (0 << 21)
+#      define R300_GB_TILE_CONFIG_SUBPRECISION      (0 << 22)
+#      define R300_GB_TILE_CONFIG_ALT_TILING_DEF    (0 << 23)
+#      define R300_GB_TILE_CONFIG_ALT_TILING_3_2    (1 << 23)
+#      define R300_GB_TILE_CONFIG_Z_EXTENDED_24_1   (0 << 24)
+#      define R300_GB_TILE_CONFIG_Z_EXTENDED_S25_1  (1 << 24)
 
 /* Specifies the sizes of the various FIFO`s in the sc/rs/us. This register must be the first one written */
 #define R300_GB_FIFO_SIZE      0x4024
@@ -679,9 +700,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #      define R300_OFIFO_HIGHWATER_SHIFT       22      /* two bits only */
 #      define R300_CUBE_FIFO_HIGHWATER_COL_SHIFT       24
 
-#define GB_Z_PEQ_CONFIG                          0x4028
-#      define GB_Z_PEQ_CONFIG_Z_PEQ_SIZE_4_4    (0 << 0)
-#      define GB_Z_PEQ_CONFIG_Z_PEQ_SIZE_8_8    (1 << 0)
+#define R300_GB_Z_PEQ_CONFIG                          0x4028
+#      define R300_GB_Z_PEQ_CONFIG_Z_PEQ_SIZE_4_4    (0 << 0)
+#      define R300_GB_Z_PEQ_CONFIG_Z_PEQ_SIZE_8_8    (1 << 0)
 
 /* Specifies various polygon specific selects (fog, depth, perspective). */
 #define R300_GB_SELECT                           0x401c
@@ -704,39 +725,39 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 /* Specifies the graphics pipeline configuration for antialiasing. */
 #define R300_GB_AA_CONFIG                         0x4020
-#      define GB_AA_CONFIG_AA_DISABLE           (0 << 0)
-#      define GB_AA_CONFIG_AA_ENABLE            (1 << 0)
-#      define GB_AA_CONFIG_NUM_AA_SUBSAMPLES_2  (0 << 1)
-#      define GB_AA_CONFIG_NUM_AA_SUBSAMPLES_3  (1 << 1)
-#      define GB_AA_CONFIG_NUM_AA_SUBSAMPLES_4  (2 << 1)
-#      define GB_AA_CONFIG_NUM_AA_SUBSAMPLES_6  (3 << 1)
+#      define R300_GB_AA_CONFIG_AA_DISABLE           (0 << 0)
+#      define R300_GB_AA_CONFIG_AA_ENABLE            (1 << 0)
+#      define R300_GB_AA_CONFIG_NUM_AA_SUBSAMPLES_2  (0 << 1)
+#      define R300_GB_AA_CONFIG_NUM_AA_SUBSAMPLES_3  (1 << 1)
+#      define R300_GB_AA_CONFIG_NUM_AA_SUBSAMPLES_4  (2 << 1)
+#      define R300_GB_AA_CONFIG_NUM_AA_SUBSAMPLES_6  (3 << 1)
 
 /* Selects which of 4 pipes are active. */
-#define GB_PIPE_SELECT                           0x402c
-#      define GB_PIPE_SELECT_PIPE0_ID_SHIFT  0
-#      define GB_PIPE_SELECT_PIPE1_ID_SHIFT  2
-#      define GB_PIPE_SELECT_PIPE2_ID_SHIFT  4
-#      define GB_PIPE_SELECT_PIPE3_ID_SHIFT  6
-#      define GB_PIPE_SELECT_PIPE_MASK_SHIFT 8
-#      define GB_PIPE_SELECT_MAX_PIPE        12
-#      define GB_PIPE_SELECT_BAD_PIPES       14
-#      define GB_PIPE_SELECT_CONFIG_PIPES    18
+#define R300_GB_PIPE_SELECT                           0x402c
+#      define R300_GB_PIPE_SELECT_PIPE0_ID_SHIFT  0
+#      define R300_GB_PIPE_SELECT_PIPE1_ID_SHIFT  2
+#      define R300_GB_PIPE_SELECT_PIPE2_ID_SHIFT  4
+#      define R300_GB_PIPE_SELECT_PIPE3_ID_SHIFT  6
+#      define R300_GB_PIPE_SELECT_PIPE_MASK_SHIFT 8
+#      define R300_GB_PIPE_SELECT_MAX_PIPE        12
+#      define R300_GB_PIPE_SELECT_BAD_PIPES       14
+#      define R300_GB_PIPE_SELECT_CONFIG_PIPES    18
 
 
 /* Specifies the sizes of the various FIFO`s in the sc/rs. */
-#define GB_FIFO_SIZE1                            0x4070
+#define R300_GB_FIFO_SIZE1                            0x4070
 /* High water mark for SC input fifo */
-#      define GB_FIFO_SIZE1_SC_HIGHWATER_IFIFO_SHIFT 0
-#      define GB_FIFO_SIZE1_SC_HIGHWATER_IFIFO_MASK  0x0000003f
+#      define R300_GB_FIFO_SIZE1_SC_HIGHWATER_IFIFO_SHIFT 0
+#      define R300_GB_FIFO_SIZE1_SC_HIGHWATER_IFIFO_MASK  0x0000003f
 /* High water mark for SC input fifo (B) */
-#      define GB_FIFO_SIZE1_SC_HIGHWATER_BFIFO_SHIFT 6
-#      define GB_FIFO_SIZE1_SC_HIGHWATER_BFIFO_MASK  0x00000fc0
+#      define R300_GB_FIFO_SIZE1_SC_HIGHWATER_BFIFO_SHIFT 6
+#      define R300_GB_FIFO_SIZE1_SC_HIGHWATER_BFIFO_MASK  0x00000fc0
 /* High water mark for RS colors' fifo */
-#      define GB_FIFO_SIZE1_SC_HIGHWATER_COL_SHIFT   12
-#      define GB_FIFO_SIZE1_SC_HIGHWATER_COL_MASK    0x0003f000
+#      define R300_GB_FIFO_SIZE1_SC_HIGHWATER_COL_SHIFT   12
+#      define R300_GB_FIFO_SIZE1_SC_HIGHWATER_COL_MASK    0x0003f000
 /* High water mark for RS textures' fifo */
-#      define GB_FIFO_SIZE1_SC_HIGHWATER_TEX_SHIFT   18
-#      define GB_FIFO_SIZE1_SC_HIGHWATER_TEX_MASK    0x00fc0000
+#      define R300_GB_FIFO_SIZE1_SC_HIGHWATER_TEX_SHIFT   18
+#      define R300_GB_FIFO_SIZE1_SC_HIGHWATER_TEX_MASK    0x00fc0000
 
 /* This table specifies the source location and format for up to 16 texture
  * addresses (i[0]:i[15]) and four colors (c[0]:c[3])
@@ -841,10 +862,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #       define R300_POINTSIZE_X_MASK          0xffff0000
 #       define R300_POINTSIZE_MAX             (R300_POINTSIZE_Y_MASK / 6)
 
-/* Blue fill color */
+/* Red fill color */
 #define R500_GA_FILL_R                                0x4220
 
-/* Blue fill color */
+/* Green fill color */
 #define R500_GA_FILL_G                                0x4224
 
 /* Blue fill color */
@@ -1172,6 +1193,13 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 /* SU Depth Offset value */
 #define R300_SU_DEPTH_OFFSET                0x42c4
 
+#define R300_SU_REG_DEST                   0x42c8
+#      define R300_RASTER_PIPE_SELECT_0        (1 << 0)
+#      define R300_RASTER_PIPE_SELECT_1        (1 << 1)
+#      define R300_RASTER_PIPE_SELECT_2        (1 << 2)
+#      define R300_RASTER_PIPE_SELECT_3        (1 << 3)
+#      define R300_RASTER_PIPE_SELECT_ALL      0xf
+
 
 /* BEGIN: Rasterization / Interpolators - many guesses */
 
@@ -1265,7 +1293,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #        define R500_RS_INST_TEX_ID(x)                  ((x) << 0)
 #define R500_RS_INST_TEX_CN_WRITE                      (1 << 4)
 #define R500_RS_INST_TEX_ADDR_SHIFT                    5
-#        define R500_RS_INST_TEX_ADDR(x)                ((x) << 0)
+#        define R500_RS_INST_TEX_ADDR(x)                ((x) << 5)
 #define R500_RS_INST_COL_ID_SHIFT                      12
 #        define R500_RS_INST_COL_ID(x)                  ((x) << 12)
 #define R500_RS_INST_COL_CN_NO_WRITE                   (0 << 16)
@@ -1435,6 +1463,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #      define R300_TX_MIN_FILTER_MIP_NEAREST    (1 << 13)
 #      define R300_TX_MIN_FILTER_MIP_LINEAR     (2 << 13)
 #      define R300_TX_MIN_FILTER_MIP_MASK       (3 << 13)
+#       define R300_TX_MAX_MIP_LEVEL_SHIFT       17
+#       define R300_TX_MAX_MIP_LEVEL_MASK        (0xf << 17)
 #      define R300_TX_MAX_ANISO_1_TO_1          (0 << 21)
 #      define R300_TX_MAX_ANISO_2_TO_1          (1 << 21)
 #      define R300_TX_MAX_ANISO_4_TO_1          (2 << 21)
@@ -1443,6 +1473,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #      define R300_TX_MAX_ANISO_MASK            (7 << 21)
 #       define R300_TX_WRAP_S(x)                 ((x) << 0)
 #       define R300_TX_WRAP_T(x)                 ((x) << 3)
+#       define R300_TX_MAX_MIP_LEVEL(x)          ((x) << 17)
 
 #define R300_TX_FILTER1_0                      0x4440
 #      define R300_CHROMA_KEY_MODE_DISABLE    0
@@ -1472,8 +1503,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #       define R300_TX_HEIGHTMASK_MASK           (2047 << 11)
 #      define R300_TX_DEPTHMASK_SHIFT           22
 #      define R300_TX_DEPTHMASK_MASK            (0xf << 22)
-#       define R300_TX_MAX_MIP_LEVEL_SHIFT       26
-#       define R300_TX_MAX_MIP_LEVEL_MASK        (0xf << 26)
 #       define R300_TX_SIZE_PROJECTED            (1 << 30)
 #       define R300_TX_PITCH_EN                  (1 << 31)
 #       define R300_TX_WIDTH(x)                  ((x) << 0)
@@ -1856,6 +1885,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #       define R300_RGB_ADDR0(x)                ((x) << 0)
 #       define R300_RGB_ADDR1(x)                ((x) << 6)
 #       define R300_RGB_ADDR2(x)                ((x) << 12)
+#       define R300_RGB_TARGET(x)               ((x) << 29)
 
 #define R300_US_ALU_ALPHA_ADDR_0                 0x47C0
 #       define R300_ALU_SRC0A_SHIFT             0
@@ -1873,9 +1903,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #       define R300_ALU_DSTA_REG                (1 << 23)
 #       define R300_ALU_DSTA_OUTPUT             (1 << 24)
 #              define R300_ALU_DSTA_DEPTH              (1 << 27)
-#       define R300_ALPHA_ADDR0(x)                ((x) << 0)
-#       define R300_ALPHA_ADDR1(x)                ((x) << 6)
-#       define R300_ALPHA_ADDR2(x)                ((x) << 12)
+#       define R300_ALPHA_ADDR0(x)              ((x) << 0)
+#       define R300_ALPHA_ADDR1(x)              ((x) << 6)
+#       define R300_ALPHA_ADDR2(x)              ((x) << 12)
+#       define R300_ALPHA_TARGET(x)             ((x) << 25)
 
 #define R300_US_ALU_RGB_INST_0                   0x48C0
 #       define R300_ALU_ARGC_SRC0C_XYZ          0
@@ -2095,6 +2126,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define R500_FG_ALPHA_VALUE                0x4be0
 #      define R500_FG_ALPHA_VALUE_MASK 0x0000ffff
 
+#define RV530_FG_ZBREG_DEST                 0x4be8
+#      define RV530_FG_ZBREG_DEST_PIPE_SELECT_0             (1 << 0)
+#      define RV530_FG_ZBREG_DEST_PIPE_SELECT_1             (1 << 1)
+#      define RV530_FG_ZBREG_DEST_PIPE_SELECT_ALL           (3 << 0)
 /* gap */
 
 /* Fragment program parameters in 7.16 floating point */
@@ -2110,6 +2145,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 /* Unpipelined. */
 #define R300_RB3D_CCTL                      0x4e00
+#      define R300_RB3D_CCTL_NUM_MULTIWRITES(x)       (MAX2(((x)-1), 0) << 5)
 #      define R300_RB3D_CCTL_NUM_MULTIWRITES_1_BUFFER                (0 << 5)
 #      define R300_RB3D_CCTL_NUM_MULTIWRITES_2_BUFFERS               (1 << 5)
 #      define R300_RB3D_CCTL_NUM_MULTIWRITES_3_BUFFERS               (2 << 5)
@@ -2150,6 +2186,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #       define R300_DISCARD_SRC_PIXELS_SRC_ALPHA_1     (4 << 3)
 #       define R300_DISCARD_SRC_PIXELS_SRC_COLOR_1     (5 << 3)
 #       define R300_DISCARD_SRC_PIXELS_SRC_ALPHA_COLOR_1     (6 << 3)
+#       define R500_SRC_ALPHA_0_NO_READ                (1 << 30)
+#       define R500_SRC_ALPHA_1_NO_READ                (1 << 31)
 
 /* the following are shared between CBLEND and ABLEND */
 #       define R300_FCN_MASK                         (3  << 12)
@@ -2384,6 +2422,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #      define R300_Z_WRITE_ENABLE               (1 << 2)
 #      define R300_Z_SIGNED_COMPARE             (1 << 3)
 #      define R300_STENCIL_FRONT_BACK           (1 << 4)
+#   define R500_STENCIL_ZSIGNED_MAGNITUDE (1 << 5)
+#   define R500_STENCIL_REFMASK_FRONT_BACK (1 << 6)
 
 #define R300_ZB_ZSTENCILCNTL                   0x4f04
        /* functions */
@@ -2600,7 +2640,7 @@ enum {
        VE_COND_MUX_GTE                 = 25,
        VE_SET_GREATER_THAN             = 26,
        VE_SET_EQUAL                    = 27,
-       VE_SET_NOT_EQUAL                = 28,
+       VE_SET_NOT_EQUAL                = 28
 };
 
 enum {
@@ -2634,20 +2674,20 @@ enum {
        ME_PRED_SET_CLR                 = 25,
        ME_PRED_SET_INV                 = 26,
        ME_PRED_SET_POP                 = 27,
-       ME_PRED_SET_RESTORE             = 28,
+       ME_PRED_SET_RESTORE             = 28
 };
 
 enum {
        /* R3XX */
        PVS_MACRO_OP_2CLK_MADD          = 0,
-       PVS_MACRO_OP_2CLK_M2X_ADD       = 1,
+       PVS_MACRO_OP_2CLK_M2X_ADD       = 1
 };
 
 enum {
        PVS_SRC_REG_TEMPORARY           = 0,    /* Intermediate Storage */
        PVS_SRC_REG_INPUT               = 1,    /* Input Vertex Storage */
        PVS_SRC_REG_CONSTANT            = 2,    /* Constant State Storage */
-       PVS_SRC_REG_ALT_TEMPORARY       = 3,    /* Alternate Intermediate Storage */
+       PVS_SRC_REG_ALT_TEMPORARY       = 3     /* Alternate Intermediate Storage */
 };
 
 enum {
@@ -2656,7 +2696,7 @@ enum {
        PVS_DST_REG_OUT                 = 2,    /* Output Memory. Used for all outputs */
        PVS_DST_REG_OUT_REPL_X          = 3,    /* Output Memory & Replicate X to all channels */
        PVS_DST_REG_ALT_TEMPORARY       = 4,    /* Alternate Intermediate Storage */
-       PVS_DST_REG_INPUT               = 5,    /* Output Memory & Replicate X to all channels */
+       PVS_DST_REG_INPUT               = 5     /* Output Memory & Replicate X to all channels */
 };
 
 enum {
@@ -2665,7 +2705,7 @@ enum {
        PVS_SRC_SELECT_Z                = 2,    /* Select Z Component */
        PVS_SRC_SELECT_W                = 3,    /* Select W Component */
        PVS_SRC_SELECT_FORCE_0          = 4,    /* Force Component to 0.0 */
-       PVS_SRC_SELECT_FORCE_1          = 5,    /* Force Component to 1.0 */
+       PVS_SRC_SELECT_FORCE_1          = 5     /* Force Component to 1.0 */
 };
 
 /* PVS Opcode & Destination Operand Description */
@@ -2704,7 +2744,7 @@ enum {
        PVS_DST_ADDR_SEL_MASK           = 0x3,
        PVS_DST_ADDR_SEL_SHIFT          = 29,
        PVS_DST_ADDR_MODE_0_MASK        = 0x1,
-       PVS_DST_ADDR_MODE_0_SHIFT       = 31,
+       PVS_DST_ADDR_MODE_0_SHIFT       = 31
 };
 
 /* PVS Source Operand Description */
@@ -2739,7 +2779,7 @@ enum {
        PVS_SRC_ADDR_SEL_MASK           = 0x3,
        PVS_SRC_ADDR_SEL_SHIFT          = 29,
        PVS_SRC_ADDR_MODE_1_MASK        = 0x0,
-       PVS_SRC_ADDR_MODE_1_SHIFT       = 32,
+       PVS_SRC_ADDR_MODE_1_SHIFT       = 32
 };
 
 /*\}*/
@@ -3256,6 +3296,11 @@ enum {
  */
 #define R300_PACKET3_3D_LOAD_VBPNTR         0x00002F00
 
+#   define R300_VBPNTR_SIZE0(x)    ((x) >> 2)
+#   define R300_VBPNTR_STRIDE0(x)  (((x) >> 2) << 8)
+#   define R300_VBPNTR_SIZE1(x)    (((x) >> 2) << 16)
+#   define R300_VBPNTR_STRIDE1(x)  (((x) >> 2) << 24)
+
 #define R300_PACKET3_INDX_BUFFER            0x00003300
 #    define R300_INDX_BUFFER_DST_SHIFT          0
 #    define R300_INDX_BUFFER_SKIP_SHIFT         16
@@ -3313,10 +3358,6 @@ enum {
 
 #define R200_3D_DRAW_IMMD_2      0xC0003500
 
-/* XXX Oh look, stuff not brought over from docs yet */
-
-#define R300_SU_REG_DEST                    0x42C8
-
 #endif /* _R300_REG_H */
 
 /* *INDENT-ON* */
index ca44e0f66157d123606ed8d8dfa651ee0a6d8413..a4ac9ad9a7bc74860ba02674c1eab7569ae396ad 100644 (file)
  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  * USE OR OTHER DEALINGS IN THE SOFTWARE. */
 
-#include "draw/draw_pipe.h"
+/* r300_render: Vertex and index buffer primitive emission. Contains both
+ * HW TCL fastpath rendering, and SW TCL Draw-assisted rendering. */
+
+#include "draw/draw_context.h"
 #include "draw/draw_vbuf.h"
+
+#include "pipe/p_inlines.h"
+
 #include "util/u_memory.h"
+#include "util/u_prim.h"
 
 #include "r300_cs.h"
 #include "r300_context.h"
 #include "r300_emit.h"
 #include "r300_reg.h"
+#include "r300_render.h"
 #include "r300_state_derived.h"
 
 /* r300_render: Vertex and index buffer primitive emission. */
 #define R300_MAX_VBO_SIZE  (1024 * 1024)
 
+uint32_t r300_translate_primitive(unsigned prim)
+{
+    switch (prim) {
+        case PIPE_PRIM_POINTS:
+            return R300_VAP_VF_CNTL__PRIM_POINTS;
+        case PIPE_PRIM_LINES:
+            return R300_VAP_VF_CNTL__PRIM_LINES;
+        case PIPE_PRIM_LINE_LOOP:
+            return R300_VAP_VF_CNTL__PRIM_LINE_LOOP;
+        case PIPE_PRIM_LINE_STRIP:
+            return R300_VAP_VF_CNTL__PRIM_LINE_STRIP;
+        case PIPE_PRIM_TRIANGLES:
+            return R300_VAP_VF_CNTL__PRIM_TRIANGLES;
+        case PIPE_PRIM_TRIANGLE_STRIP:
+            return R300_VAP_VF_CNTL__PRIM_TRIANGLE_STRIP;
+        case PIPE_PRIM_TRIANGLE_FAN:
+            return R300_VAP_VF_CNTL__PRIM_TRIANGLE_FAN;
+        case PIPE_PRIM_QUADS:
+            return R300_VAP_VF_CNTL__PRIM_QUADS;
+        case PIPE_PRIM_QUAD_STRIP:
+            return R300_VAP_VF_CNTL__PRIM_QUAD_STRIP;
+        case PIPE_PRIM_POLYGON:
+            return R300_VAP_VF_CNTL__PRIM_POLYGON;
+        default:
+            return 0;
+    }
+}
+
+static boolean r300_nothing_to_draw(struct r300_context *r300)
+{
+    return r300->rs_state->rs.scissor &&
+           r300->scissor_state->scissor.empty_area;
+}
+
+static uint32_t r300_provoking_vertex_fixes(struct r300_context *r300,
+                                            unsigned mode)
+{
+    uint32_t color_control = r300->rs_state->color_control;
+
+    /* By default (see r300_state.c:r300_create_rs_state) color_control is
+     * initialized to provoking the first vertex.
+     *
+     * Triangle fans must be reduced to the second vertex, not the first, in
+     * Gallium flatshade-first mode, as per the GL spec.
+     * (http://www.opengl.org/registry/specs/ARB/provoking_vertex.txt)
+     *
+     * Quads never provoke correctly in flatshade-first mode. The first
+     * vertex is never considered as provoking, so only the second, third,
+     * and fourth vertices can be selected, and both "third" and "last" modes
+     * select the fourth vertex. This is probably due to D3D lacking quads.
+     *
+     * Similarly, polygons reduce to the first, not the last, vertex, when in
+     * "last" mode, and all other modes start from the second vertex.
+     *
+     * ~ C.
+     */
+
+    if (r300->rs_state->rs.flatshade_first) {
+        switch (mode) {
+            case PIPE_PRIM_TRIANGLE_FAN:
+                color_control |= R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_SECOND;
+                break;
+            case PIPE_PRIM_QUADS:
+            case PIPE_PRIM_QUAD_STRIP:
+            case PIPE_PRIM_POLYGON:
+                color_control |= R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_LAST;
+                break;
+            default:
+                color_control |= R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_FIRST;
+                break;
+        }
+    } else {
+        color_control |= R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_LAST;
+    }
+
+    return color_control;
+}
+
+static void r300_emit_draw_arrays(struct r300_context *r300,
+                                  unsigned mode,
+                                  unsigned count)
+{
+    CS_LOCALS(r300);
+
+    BEGIN_CS(8);
+    OUT_CS_REG(R300_GA_COLOR_CONTROL,
+            r300_provoking_vertex_fixes(r300, mode));
+    OUT_CS_REG(R300_VAP_VF_MIN_VTX_INDX, 0);
+    OUT_CS_REG(R300_VAP_VF_MAX_VTX_INDX, count - 1);
+    OUT_CS_PKT3(R300_PACKET3_3D_DRAW_VBUF_2, 0);
+    OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST | (count << 16) |
+           r300_translate_primitive(mode));
+    END_CS;
+}
+
+static void r300_emit_draw_elements(struct r300_context *r300,
+                                    struct pipe_buffer* indexBuffer,
+                                    unsigned indexSize,
+                                    unsigned minIndex,
+                                    unsigned maxIndex,
+                                    unsigned mode,
+                                    unsigned start,
+                                    unsigned count)
+{
+    uint32_t count_dwords;
+    uint32_t offset_dwords = indexSize * start / sizeof(uint32_t);
+    CS_LOCALS(r300);
+
+    /* XXX most of these are stupid */
+    assert(indexSize == 4 || indexSize == 2);
+    assert((start * indexSize)  % 4 == 0);
+    assert(offset_dwords == 0);
+
+    BEGIN_CS(14);
+    OUT_CS_REG(R300_GA_COLOR_CONTROL,
+            r300_provoking_vertex_fixes(r300, mode));
+    OUT_CS_REG(R300_VAP_VF_MIN_VTX_INDX, minIndex);
+    OUT_CS_REG(R300_VAP_VF_MAX_VTX_INDX, maxIndex);
+    OUT_CS_PKT3(R300_PACKET3_3D_DRAW_INDX_2, 0);
+    if (indexSize == 4) {
+        count_dwords = count + start;
+        OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (count << 16) |
+               R300_VAP_VF_CNTL__INDEX_SIZE_32bit |
+               r300_translate_primitive(mode));
+    } else {
+        count_dwords = (count + start + 1) / 2;
+        OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (count << 16) |
+               r300_translate_primitive(mode));
+    }
+
+    /* INDX_BUFFER is a truly special packet3.
+     * Unlike most other packet3, where the offset is after the count,
+     * the order is reversed, so the relocation ends up carrying the
+     * size of the indexbuf instead of the offset.
+     *
+     * XXX Fix offset
+     */
+    OUT_CS_PKT3(R300_PACKET3_INDX_BUFFER, 2);
+    OUT_CS(R300_INDX_BUFFER_ONE_REG_WR | (R300_VAP_PORT_IDX0 >> 2) |
+           (0 << R300_INDX_BUFFER_SKIP_SHIFT));
+    OUT_CS(offset_dwords);
+    OUT_CS_RELOC(indexBuffer, count_dwords,
+        RADEON_GEM_DOMAIN_GTT, 0, 0);
+
+    END_CS;
+}
+
+
+static boolean r300_setup_vertex_buffers(struct r300_context *r300)
+{
+    struct pipe_vertex_buffer *vbuf = r300->vertex_buffer;
+    struct pipe_vertex_element *velem = r300->vertex_element;
+
+validate:
+    for (int i = 0; i < r300->vertex_element_count; i++) {
+        if (!r300->winsys->add_buffer(r300->winsys,
+                vbuf[velem[i].vertex_buffer_index].buffer,
+            RADEON_GEM_DOMAIN_GTT, 0)) {
+            r300->context.flush(&r300->context, 0, NULL);
+            goto validate;
+        }
+    }
+
+    if (!r300->winsys->validate(r300->winsys)) {
+        r300->context.flush(&r300->context, 0, NULL);
+        return r300->winsys->validate(r300->winsys);
+    }
+
+    return TRUE;
+}
+
+/* This is the fast-path drawing & emission for HW TCL. */
+void r300_draw_range_elements(struct pipe_context* pipe,
+                                 struct pipe_buffer* indexBuffer,
+                                 unsigned indexSize,
+                                 unsigned minIndex,
+                                 unsigned maxIndex,
+                                 unsigned mode,
+                                 unsigned start,
+                                 unsigned count)
+{
+    struct r300_context* r300 = r300_context(pipe);
+
+    if (!u_trim_pipe_prim(mode, &count)) {
+        return;
+    }
+
+    if (count > 65535) {
+       /* XXX: use aux/indices functions to split this into smaller
+        * primitives.
+        */
+        return;
+    }
+
+    if (r300_nothing_to_draw(r300)) {
+        return;
+    }
+
+    r300_update_derived_state(r300);
+
+    if (!r300_setup_vertex_buffers(r300)) {
+        return;
+    }
+
+    if (!r300->winsys->add_buffer(r300->winsys, indexBuffer,
+                                  RADEON_GEM_DOMAIN_GTT, 0)) {
+        return;
+    }
+
+    if (!r300->winsys->validate(r300->winsys)) {
+        return;
+    }
+
+    r300_emit_dirty_state(r300);
+
+    r300_emit_aos(r300, 0);
+
+    r300_emit_draw_elements(r300, indexBuffer, indexSize, minIndex, maxIndex,
+                            mode, start, count);
+}
+
+/* Simple helpers for context setup. Should probably be moved to util. */
+void r300_draw_elements(struct pipe_context* pipe,
+                        struct pipe_buffer* indexBuffer,
+                        unsigned indexSize, unsigned mode,
+                        unsigned start, unsigned count)
+{
+   pipe->draw_range_elements(pipe, indexBuffer, indexSize, 0, ~0,
+                             mode, start, count);
+}
+
+void r300_draw_arrays(struct pipe_context* pipe, unsigned mode,
+                         unsigned start, unsigned count)
+{
+    struct r300_context* r300 = r300_context(pipe);
+
+    if (!u_trim_pipe_prim(mode, &count)) {
+        return;
+    }
+
+    if (count > 65535) {
+        /* XXX: driver needs to handle this -- use the functions in
+         * aux/indices to split this into several smaller primitives.
+         */
+        return;
+    }
+
+    if (r300_nothing_to_draw(r300)) {
+        return;
+    }
+
+    r300_update_derived_state(r300);
+
+    if (!r300_setup_vertex_buffers(r300)) {
+        return;
+    }
+
+    r300_emit_dirty_state(r300);
+
+    r300_emit_aos(r300, start);
+
+    r300_emit_draw_arrays(r300, mode, count);
+}
+
+/****************************************************************************
+ * The rest of this file is for SW TCL rendering only. Please be polite and *
+ * keep these functions separated so that they are easier to locate. ~C.    *
+ ***************************************************************************/
+
+/* SW TCL arrays, using Draw. */
+void r300_swtcl_draw_arrays(struct pipe_context* pipe,
+                               unsigned mode,
+                               unsigned start,
+                               unsigned count)
+{
+    struct r300_context* r300 = r300_context(pipe);
+    int i;
+
+    if (!u_trim_pipe_prim(mode, &count)) {
+        return;
+    }
+
+    if (r300_nothing_to_draw(r300)) {
+        return;
+    }
+
+    for (i = 0; i < r300->vertex_buffer_count; i++) {
+        void* buf = pipe_buffer_map(pipe->screen,
+                                    r300->vertex_buffer[i].buffer,
+                                    PIPE_BUFFER_USAGE_CPU_READ);
+        draw_set_mapped_vertex_buffer(r300->draw, i, buf);
+    }
+
+    draw_set_mapped_element_buffer(r300->draw, 0, NULL);
+
+    draw_set_mapped_constant_buffer(r300->draw,
+                                   PIPE_SHADER_VERTEX,
+                                   r300->shader_constants[PIPE_SHADER_VERTEX].constants,
+                                   r300->shader_constants[PIPE_SHADER_VERTEX].count *
+                (sizeof(float) * 4));
+
+    draw_arrays(r300->draw, mode, start, count);
+
+    for (i = 0; i < r300->vertex_buffer_count; i++) {
+        pipe_buffer_unmap(pipe->screen, r300->vertex_buffer[i].buffer);
+        draw_set_mapped_vertex_buffer(r300->draw, i, NULL);
+    }
+}
+
+/* SW TCL elements, using Draw. */
+void r300_swtcl_draw_range_elements(struct pipe_context* pipe,
+                                       struct pipe_buffer* indexBuffer,
+                                       unsigned indexSize,
+                                       unsigned minIndex,
+                                       unsigned maxIndex,
+                                       unsigned mode,
+                                       unsigned start,
+                                       unsigned count)
+{
+    struct r300_context* r300 = r300_context(pipe);
+    int i;
+    void* indices;
+
+    if (!u_trim_pipe_prim(mode, &count)) {
+        return;
+    }
+
+    if (r300_nothing_to_draw(r300)) {
+        return;
+    }
+
+    for (i = 0; i < r300->vertex_buffer_count; i++) {
+        void* buf = pipe_buffer_map(pipe->screen,
+                                    r300->vertex_buffer[i].buffer,
+                                    PIPE_BUFFER_USAGE_CPU_READ);
+        draw_set_mapped_vertex_buffer(r300->draw, i, buf);
+    }
+
+    indices = pipe_buffer_map(pipe->screen, indexBuffer,
+                              PIPE_BUFFER_USAGE_CPU_READ);
+    draw_set_mapped_element_buffer_range(r300->draw, indexSize,
+                                         minIndex, maxIndex, indices);
+
+    draw_set_mapped_constant_buffer(r300->draw,
+                                   PIPE_SHADER_VERTEX,
+            r300->shader_constants[PIPE_SHADER_VERTEX].constants,
+            r300->shader_constants[PIPE_SHADER_VERTEX].count *
+                (sizeof(float) * 4));
+
+    draw_arrays(r300->draw, mode, start, count);
+
+    for (i = 0; i < r300->vertex_buffer_count; i++) {
+        pipe_buffer_unmap(pipe->screen, r300->vertex_buffer[i].buffer);
+        draw_set_mapped_vertex_buffer(r300->draw, i, NULL);
+    }
+
+    pipe_buffer_unmap(pipe->screen, indexBuffer);
+    draw_set_mapped_element_buffer_range(r300->draw, 0, start,
+                                         start + count - 1, NULL);
+}
+
+/* Object for rendering using Draw. */
 struct r300_render {
     /* Parent class */
     struct vbuf_render base;
@@ -67,7 +437,7 @@ r300_render_get_vertex_info(struct vbuf_render* render)
 
     r300_update_derived_state(r300);
 
-    return &r300->vertex_info.vinfo;
+    return &r300->vertex_info->vinfo;
 }
 
 static boolean r300_render_allocate_vertices(struct vbuf_render* render,
@@ -105,7 +475,7 @@ static void* r300_render_map_vertices(struct vbuf_render* render)
     r300render->vbo_ptr = pipe_buffer_map(screen, r300render->vbo,
                                           PIPE_BUFFER_USAGE_CPU_WRITE);
 
-    return (r300render->vbo_ptr + r300render->vbo_offset);
+    return ((uint8_t*)r300render->vbo_ptr + r300render->vbo_offset);
 }
 
 static void r300_render_unmap_vertices(struct vbuf_render* render,
@@ -127,7 +497,6 @@ static void r300_render_unmap_vertices(struct vbuf_render* render,
 static void r300_render_release_vertices(struct vbuf_render* render)
 {
     struct r300_render* r300render = r300_render(render);
-    struct r300_context* r300 = r300render->r300;
 
     r300render->vbo_offset += r300render->vbo_max_used;
     r300render->vbo_max_used = 0;
@@ -137,56 +506,13 @@ static boolean r300_render_set_primitive(struct vbuf_render* render,
                                                unsigned prim)
 {
     struct r300_render* r300render = r300_render(render);
-    r300render->prim = prim;
 
-    switch (prim) {
-        case PIPE_PRIM_POINTS:
-            r300render->hwprim = R300_VAP_VF_CNTL__PRIM_POINTS;
-            break;
-        case PIPE_PRIM_LINES:
-            r300render->hwprim = R300_VAP_VF_CNTL__PRIM_LINES;
-            break;
-        case PIPE_PRIM_LINE_LOOP:
-            r300render->hwprim = R300_VAP_VF_CNTL__PRIM_LINE_LOOP;
-            break;
-        case PIPE_PRIM_LINE_STRIP:
-            r300render->hwprim = R300_VAP_VF_CNTL__PRIM_LINE_STRIP;
-            break;
-        case PIPE_PRIM_TRIANGLES:
-            r300render->hwprim = R300_VAP_VF_CNTL__PRIM_TRIANGLES;
-            break;
-        case PIPE_PRIM_TRIANGLE_STRIP:
-            r300render->hwprim = R300_VAP_VF_CNTL__PRIM_TRIANGLE_STRIP;
-            break;
-        case PIPE_PRIM_TRIANGLE_FAN:
-            r300render->hwprim = R300_VAP_VF_CNTL__PRIM_TRIANGLE_FAN;
-            break;
-        case PIPE_PRIM_QUADS:
-            r300render->hwprim = R300_VAP_VF_CNTL__PRIM_QUADS;
-            break;
-        case PIPE_PRIM_QUAD_STRIP:
-            r300render->hwprim = R300_VAP_VF_CNTL__PRIM_QUAD_STRIP;
-            break;
-        case PIPE_PRIM_POLYGON:
-            r300render->hwprim = R300_VAP_VF_CNTL__PRIM_POLYGON;
-            break;
-        default:
-            return FALSE;
-            break;
-    }
+    r300render->prim = prim;
+    r300render->hwprim = r300_translate_primitive(prim);
 
     return TRUE;
 }
 
-static void r300_prepare_render(struct r300_render* render, unsigned count)
-{
-    struct r300_context* r300 = render->r300;
-
-    CS_LOCALS(r300);
-
-    r300_emit_dirty_state(r300);
-}
-
 static void r300_render_draw_arrays(struct vbuf_render* render,
                                           unsigned start,
                                           unsigned count)
@@ -196,7 +522,7 @@ static void r300_render_draw_arrays(struct vbuf_render* render,
 
     CS_LOCALS(r300);
 
-    r300_prepare_render(r300render, count);
+    r300_emit_dirty_state(r300);
 
     DBG(r300, DBG_DRAW, "r300: Doing vbuf render, count %d\n", count);
 
@@ -213,15 +539,11 @@ static void r300_render_draw(struct vbuf_render* render,
 {
     struct r300_render* r300render = r300_render(render);
     struct r300_context* r300 = r300render->r300;
-    struct pipe_screen* screen = r300->context.screen;
-    struct pipe_buffer* index_buffer;
-    void* index_map;
     int i;
-    uint32_t index;
 
     CS_LOCALS(r300);
 
-    r300_prepare_render(r300render, count);
+    r300_emit_dirty_state(r300);
 
     BEGIN_CS(2 + (count+1)/2);
     OUT_CS_PKT3(R300_PACKET3_3D_DRAW_INDX_2, (count+1)/2);
diff --git a/src/gallium/drivers/r300/r300_render.h b/src/gallium/drivers/r300/r300_render.h
new file mode 100644 (file)
index 0000000..27b5e6a
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2009 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 R300_RENDER_H
+#define R300_RENDER_H
+
+uint32_t r300_translate_primitive(unsigned prim);
+
+void r300_draw_range_elements(struct pipe_context* pipe,
+                              struct pipe_buffer* indexBuffer,
+                              unsigned indexSize,
+                              unsigned minIndex,
+                              unsigned maxIndex,
+                              unsigned mode,
+                              unsigned start,
+                              unsigned count);
+
+void r300_draw_elements(struct pipe_context* pipe,
+                        struct pipe_buffer* indexBuffer,
+                        unsigned indexSize, unsigned mode,
+                        unsigned start, unsigned count);
+
+void r300_draw_arrays(struct pipe_context* pipe, unsigned mode,
+                      unsigned start, unsigned count);
+
+void r300_swtcl_draw_arrays(struct pipe_context* pipe,
+                            unsigned mode,
+                            unsigned start,
+                            unsigned count);
+
+void r300_swtcl_draw_range_elements(struct pipe_context* pipe,
+                                    struct pipe_buffer* indexBuffer,
+                                    unsigned indexSize,
+                                    unsigned minIndex,
+                                    unsigned maxIndex,
+                                    unsigned mode,
+                                    unsigned start,
+                                    unsigned count);
+
+#endif /* R300_RENDER_H */
index 81d01b1320ca6ec6323f01d7b7532e7989c04b6d..287664b1d20013060dad0ef9c2c87b52cb2bb683 100644 (file)
  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  * USE OR OTHER DEALINGS IN THE SOFTWARE. */
 
+#include "pipe/p_inlines.h"
+#include "util/u_format.h"
+#include "util/u_memory.h"
+#include "util/u_simple_screen.h"
+
+#include "r300_context.h"
 #include "r300_screen.h"
+#include "r300_texture.h"
+
+#include "radeon_winsys.h"
 
 /* Return the identifier behind whom the brave coders responsible for this
  * amalgamation of code, sweat, and duct tape, routinely obscure their names.
@@ -73,14 +82,14 @@ static int r300_get_param(struct pipe_screen* pscreen, int param)
     struct r300_screen* r300screen = r300_screen(pscreen);
 
     switch (param) {
-        /* XXX cases marked "IN THEORY" are possible on the hardware,
-         * but haven't been implemented yet. */
         case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
+        case PIPE_CAP_MAX_COMBINED_SAMPLERS:
             /* XXX I'm told this goes up to 16 */
             return 8;
         case PIPE_CAP_NPOT_TEXTURES:
-            /* IN THEORY */
-            return 0;
+            /* XXX enable now to get GL2.1 API,
+             * figure out later how to emulate this */
+            return 1;
         case PIPE_CAP_TWO_SIDED_STENCIL:
             if (r300screen->caps->is_r500) {
                 return 1;
@@ -88,16 +97,26 @@ static int r300_get_param(struct pipe_screen* pscreen, int param)
                 return 0;
             }
         case PIPE_CAP_GLSL:
-            if (r300screen->caps->is_r500) {
-                return 1;
-            } else {
-                return 0;
-            }
+            /* I'll be frank. This is a lie.
+             *
+             * We don't truly support GLSL on any of this driver's chipsets.
+             * To be fair, no chipset supports the full GLSL specification
+             * to the best of our knowledge, but some of the less esoteric
+             * features are still missing here.
+             *
+             * Rather than cripple ourselves intentionally, I'm going to set
+             * this flag, and as Gallium's interface continues to change, I
+             * hope that this single monolithic GLSL enable can slowly get
+             * split down into many different pieces and the state tracker
+             * will handle fallbacks transparently, like it should.
+             *
+             * ~ C.
+             */
+            return 1;
         case PIPE_CAP_ANISOTROPIC_FILTER:
             return 1;
         case PIPE_CAP_POINT_SPRITE:
-            /* IN THEORY */
-            return 0;
+            return 1;
         case PIPE_CAP_MAX_RENDER_TARGETS:
             return 4;
         case PIPE_CAP_OCCLUSION_QUERY:
@@ -105,32 +124,13 @@ static int r300_get_param(struct pipe_screen* pscreen, int param)
         case PIPE_CAP_TEXTURE_SHADOW_MAP:
             return 1;
         case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
-            if (r300screen->caps->is_r500) {
-                /* 13 == 4096x4096 */
-                return 13;
-            } else {
-                /* 12 == 2048x2048 */
-                return 12;
-            }
         case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
-            /* So, technically, the limit is the same as above, but some math
-             * shows why this is silly. Assuming RGBA, 4cpp, we can see that
-             * 4096*4096*4096 = 64.0 GiB exactly, so it's not exactly
-             * practical. However, if at some point a game really wants this,
-             * then we can remove or raise this limit. */
-            if (r300screen->caps->is_r500) {
-                /* 9 == 256x256x256 */
-                return 9;
-            } else {
-                /* 8 == 128*128*128 */
-                return 8;
-            }
         case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
             if (r300screen->caps->is_r500) {
-                /* 13 == 4096x4096 */
+                /* 13 == 4096 */
                 return 13;
             } else {
-                /* 12 == 2048x2048 */
+                /* 12 == 2048 */
                 return 12;
             }
         case PIPE_CAP_TEXTURE_MIRROR_CLAMP:
@@ -138,13 +138,17 @@ static int r300_get_param(struct pipe_screen* pscreen, int param)
         case PIPE_CAP_TEXTURE_MIRROR_REPEAT:
             return 1;
         case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS:
-            /* XXX guessing (what a terrible guess) */
-            return 2;
+            return 0;
         case PIPE_CAP_TGSI_CONT_SUPPORTED:
-            /* XXX */
             return 0;
         case PIPE_CAP_BLEND_EQUATION_SEPARATE:
             return 1;
+        case PIPE_CAP_SM3:
+            if (r300screen->caps->is_r500) {
+                return 1;
+            } else {
+                return 0;
+            }
         default:
             debug_printf("r300: Implementation error: Bad param %d\n",
                 param);
@@ -179,19 +183,22 @@ static float r300_get_paramf(struct pipe_screen* pscreen, int param)
     }
 }
 
-static boolean check_tex_2d_format(enum pipe_format format, uint32_t usage,
-                                   boolean is_r500)
+static boolean check_tex_format(enum pipe_format format, uint32_t usage,
+                                boolean is_r500)
 {
+    uint32_t retval = 0;
+
     switch (format) {
         /* Supported formats. */
         /* Colorbuffer */
         case PIPE_FORMAT_A4R4G4B4_UNORM:
         case PIPE_FORMAT_R5G6B5_UNORM:
         case PIPE_FORMAT_A1R5G5B5_UNORM:
-            return usage &
+            retval = usage &
                 (PIPE_TEXTURE_USAGE_RENDER_TARGET |
                  PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
                  PIPE_TEXTURE_USAGE_PRIMARY);
+            break;
 
         /* Texture */
         case PIPE_FORMAT_A8R8G8B8_SRGB:
@@ -201,7 +208,10 @@ static boolean check_tex_2d_format(enum pipe_format format, uint32_t usage,
         case PIPE_FORMAT_DXT3_RGBA:
         case PIPE_FORMAT_DXT5_RGBA:
         case PIPE_FORMAT_YCBCR:
-            return usage & PIPE_TEXTURE_USAGE_SAMPLER;
+        case PIPE_FORMAT_L8_UNORM:
+        case PIPE_FORMAT_A8L8_UNORM:
+            retval = usage & PIPE_TEXTURE_USAGE_SAMPLER;
+            break;
 
         /* Colorbuffer or texture */
         case PIPE_FORMAT_A8R8G8B8_UNORM:
@@ -209,25 +219,32 @@ static boolean check_tex_2d_format(enum pipe_format format, uint32_t usage,
         case PIPE_FORMAT_R8G8B8A8_UNORM:
         case PIPE_FORMAT_R8G8B8X8_UNORM:
         case PIPE_FORMAT_I8_UNORM:
-            return usage &
+            retval = usage &
                 (PIPE_TEXTURE_USAGE_RENDER_TARGET |
                  PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
                  PIPE_TEXTURE_USAGE_PRIMARY |
                  PIPE_TEXTURE_USAGE_SAMPLER);
+            break;
 
-        /* Z buffer */
+        /* Z buffer or texture */
         case PIPE_FORMAT_Z16_UNORM:
-            return usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL;
+            retval = usage &
+                (PIPE_TEXTURE_USAGE_DEPTH_STENCIL |
+                 PIPE_TEXTURE_USAGE_SAMPLER);
+            break;
 
+        /* 24bit Z buffer can only be used as a texture on R500. */
+        case PIPE_FORMAT_Z24X8_UNORM:
         /* Z buffer with stencil or texture */
         case PIPE_FORMAT_Z24S8_UNORM:
-            return usage &
+            retval = usage &
                 (PIPE_TEXTURE_USAGE_DEPTH_STENCIL |
-                 PIPE_TEXTURE_USAGE_SAMPLER);
+                 (is_r500 ? PIPE_TEXTURE_USAGE_SAMPLER : 0));
+            break;
 
         /* Definitely unsupported formats. */
         /* Non-usable Z buffer/stencil formats. */
-        case PIPE_FORMAT_Z24X8_UNORM:
+        case PIPE_FORMAT_Z32_UNORM:
         case PIPE_FORMAT_S8Z24_UNORM:
         case PIPE_FORMAT_X8Z24_UNORM:
             debug_printf("r300: Note: Got unsupported format: %s in %s\n",
@@ -237,7 +254,6 @@ static boolean check_tex_2d_format(enum pipe_format format, uint32_t usage,
         /* XXX These don't even exist
         case PIPE_FORMAT_A32R32G32B32:
         case PIPE_FORMAT_A16R16G16B16: */
-        /* XXX Insert YUV422 packed VYUY and YVYU here */
         /* XXX What the deuce is UV88? (r3xx accel page 14)
             debug_printf("r300: Warning: Got unimplemented format: %s in %s\n",
                 pf_name(format), __FUNCTION__);
@@ -261,10 +277,15 @@ static boolean check_tex_2d_format(enum pipe_format format, uint32_t usage,
             break;
     }
 
-    return FALSE;
+    /* If usage was a mask that contained multiple bits, and not all of them
+     * are supported, this will catch that and return FALSE.
+     * e.g. usage = 2 | 4; retval = 4; (retval >= usage) == FALSE
+     *
+     * This also returns FALSE for any unknown formats.
+     */
+    return (retval >= usage);
 }
 
-/* XXX moar targets */
 static boolean r300_is_format_supported(struct pipe_screen* pscreen,
                                         enum pipe_format format,
                                         enum pipe_texture_target target,
@@ -272,15 +293,13 @@ static boolean r300_is_format_supported(struct pipe_screen* pscreen,
                                         unsigned geom_flags)
 {
     switch (target) {
+        case PIPE_TEXTURE_1D:   /* handle 1D textures as 2D ones */
         case PIPE_TEXTURE_2D:
-            return check_tex_2d_format(format, tex_usage,
-                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;
+            return check_tex_format(format, tex_usage,
+                r300_screen(pscreen)->caps->is_r500);
+
         default:
             debug_printf("r300: Fatal: This is not a format target: %d\n",
                 target);
@@ -300,36 +319,25 @@ r300_get_tex_transfer(struct pipe_screen *screen,
 {
     struct r300_texture *tex = (struct r300_texture *)texture;
     struct r300_transfer *trans;
-    unsigned offset;  /* in bytes */
+    unsigned offset;
 
-    /* XXX Add support for these things */
-    if (texture->target == PIPE_TEXTURE_CUBE) {
-        debug_printf("PIPE_TEXTURE_CUBE is not yet supported.\n");
-        /* offset = tex->image_offset[level][face]; */
-    }
-    else if (texture->target == PIPE_TEXTURE_3D) {
-        debug_printf("PIPE_TEXTURE_3D is not yet supported.\n");
-        /* offset = tex->image_offset[level][zslice]; */
-    }
-    else {
-        offset = tex->offset[level];
-        assert(face == 0);
-        assert(zslice == 0);
-    }
+    offset = r300_texture_get_offset(tex, level, zslice, face);  /* in bytes */
 
     trans = CALLOC_STRUCT(r300_transfer);
     if (trans) {
         pipe_texture_reference(&trans->transfer.texture, texture);
-        trans->transfer.format = texture->format;
         trans->transfer.x = x;
         trans->transfer.y = y;
         trans->transfer.width = w;
         trans->transfer.height = h;
-        trans->transfer.block = texture->block;
-        trans->transfer.nblocksx = texture->nblocksx[level];
-        trans->transfer.nblocksy = texture->nblocksy[level];
         trans->transfer.stride = r300_texture_get_stride(tex, level);
         trans->transfer.usage = usage;
+
+        /* XXX not sure whether it's required to set these two,
+               the driver doesn't use them */
+        trans->transfer.zslice = zslice;
+        trans->transfer.face = face;
+
         trans->offset = offset;
     }
     return &trans->transfer;
@@ -347,6 +355,7 @@ static void* r300_transfer_map(struct pipe_screen* screen,
 {
     struct r300_texture* tex = (struct r300_texture*)transfer->texture;
     char* map;
+    enum pipe_format format = tex->tex.format;
 
     map = pipe_buffer_map(screen, tex->buffer,
                           pipe_transfer_buffer_flags(transfer));
@@ -356,8 +365,8 @@ static void* r300_transfer_map(struct pipe_screen* screen,
     }
 
     return map + r300_transfer(transfer)->offset +
-        transfer->y / transfer->block.height * transfer->stride +
-        transfer->x / transfer->block.width * transfer->block.size;
+        transfer->y / util_format_get_blockheight(format) * transfer->stride +
+        transfer->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
 }
 
 static void r300_transfer_unmap(struct pipe_screen* screen,
@@ -375,7 +384,7 @@ static void r300_destroy_screen(struct pipe_screen* pscreen)
     FREE(r300screen);
 }
 
-struct pipe_screen* r300_create_screen(struct r300_winsys* r300_winsys)
+struct pipe_screen* r300_create_screen(struct radeon_winsys* radeon_winsys)
 {
     struct r300_screen* r300screen = CALLOC_STRUCT(r300_screen);
     struct r300_capabilities* caps = CALLOC_STRUCT(r300_capabilities);
@@ -383,13 +392,14 @@ struct pipe_screen* r300_create_screen(struct r300_winsys* r300_winsys)
     if (!r300screen || !caps)
         return NULL;
 
-    caps->pci_id = r300_winsys->pci_id;
-    caps->num_frag_pipes = r300_winsys->gb_pipes;
+    caps->pci_id = radeon_winsys->pci_id;
+    caps->num_frag_pipes = radeon_winsys->gb_pipes;
+    caps->num_z_pipes = radeon_winsys->z_pipes;
 
     r300_parse_chipset(caps);
 
     r300screen->caps = caps;
-    r300screen->screen.winsys = (struct pipe_winsys*)r300_winsys;
+    r300screen->screen.winsys = (struct pipe_winsys*)radeon_winsys;
     r300screen->screen.destroy = r300_destroy_screen;
     r300screen->screen.get_name = r300_get_name;
     r300screen->screen.get_vendor = r300_get_vendor;
index 2a0e41fbc3b5c86d520d4c96217544c8cb7bd04c..2217988adddb596758b2c83d1d1709d112c0dc8c 100644 (file)
 #ifndef R300_SCREEN_H
 #define R300_SCREEN_H
 
-#include "pipe/p_inlines.h"
 #include "pipe/p_screen.h"
-#include "util/u_memory.h"
-#include "util/u_simple_screen.h"
 
 #include "r300_chipset.h"
-#include "r300_texture.h"
-#include "r300_winsys.h"
+
+struct radeon_winsys;
 
 struct r300_screen {
     /* Parent class */
@@ -61,6 +58,6 @@ r300_transfer(struct pipe_transfer* transfer)
 }
 
 /* Creates a new r300 screen. */
-struct pipe_screen* r300_create_screen(struct r300_winsys* r300_winsys);
+struct pipe_screen* r300_create_screen(struct radeon_winsys* radeon_winsys);
 
 #endif /* R300_SCREEN_H */
diff --git a/src/gallium/drivers/r300/r300_shader_inlines.h b/src/gallium/drivers/r300/r300_shader_inlines.h
deleted file mode 100644 (file)
index a04f45b..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2009 Corbin Simpson <MostAwesomeDude@gmail.com>
- *                Joakim Sindholt <opensource@zhasha.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 R300_SHADER_INLINES_H
-#define R300_SHADER_INLINES_H
-
-/* TGSI constants. TGSI is like XML: If it can't solve your problems, you're
- * not using enough of it. */
-static const struct tgsi_full_src_register r300_constant_zero = {
-    .SrcRegister.Extended = TRUE,
-    .SrcRegister.File = TGSI_FILE_NULL,
-    .SrcRegisterExtSwz.ExtSwizzleX = TGSI_EXTSWIZZLE_ZERO,
-    .SrcRegisterExtSwz.ExtSwizzleY = TGSI_EXTSWIZZLE_ZERO,
-    .SrcRegisterExtSwz.ExtSwizzleZ = TGSI_EXTSWIZZLE_ZERO,
-    .SrcRegisterExtSwz.ExtSwizzleW = TGSI_EXTSWIZZLE_ZERO,
-};
-
-static const struct tgsi_full_src_register r300_constant_one = {
-    .SrcRegister.Extended = TRUE,
-    .SrcRegister.File = TGSI_FILE_NULL,
-    .SrcRegisterExtSwz.ExtSwizzleX = TGSI_EXTSWIZZLE_ONE,
-    .SrcRegisterExtSwz.ExtSwizzleY = TGSI_EXTSWIZZLE_ONE,
-    .SrcRegisterExtSwz.ExtSwizzleZ = TGSI_EXTSWIZZLE_ONE,
-    .SrcRegisterExtSwz.ExtSwizzleW = TGSI_EXTSWIZZLE_ONE,
-};
-
-#endif /* R300_SHADER_INLINES_H */
diff --git a/src/gallium/drivers/r300/r300_shader_semantics.h b/src/gallium/drivers/r300/r300_shader_semantics.h
new file mode 100644 (file)
index 0000000..6796841
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2009 Marek Olšák <maraeo@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 R300_SHADER_SEMANTICS_H
+#define R300_SHADER_SEMANTICS_H
+
+#define ATTR_UNUSED             (-1)
+#define ATTR_COLOR_COUNT        2
+#define ATTR_GENERIC_COUNT      16
+
+/* This structure contains information about what attributes are written by VS
+ * or read by FS. (but not both) It's much easier to work with than
+ * tgsi_shader_info.
+ *
+ * The variables contain indices to tgsi_shader_info semantics and those
+ * indices are nothing else than input/output register numbers. */
+struct r300_shader_semantics {
+    int pos;
+    int psize;
+    int color[ATTR_COLOR_COUNT];
+    int bcolor[ATTR_COLOR_COUNT];
+    int generic[ATTR_GENERIC_COUNT];
+    int fog;
+    int wpos;
+};
+
+static INLINE void r300_shader_semantics_reset(
+    struct r300_shader_semantics* info)
+{
+    int i;
+
+    info->pos = ATTR_UNUSED;
+    info->psize = ATTR_UNUSED;
+    info->fog = ATTR_UNUSED;
+    info->wpos = ATTR_UNUSED;
+
+    for (i = 0; i < ATTR_COLOR_COUNT; i++) {
+        info->color[i] = ATTR_UNUSED;
+        info->bcolor[i] = ATTR_UNUSED;
+    }
+
+    for (i = 0; i < ATTR_GENERIC_COUNT; i++) {
+        info->generic[i] = ATTR_UNUSED;
+    }
+}
+
+#endif
index 88cb9af6fb7bbe00404549ce69edcbf504cd246e..a145a7f18a5820bc79f1c80e84a92a455dfe7d0c 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
+ * Copyright 2009 Marek Olšák <maraeo@gmail.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  * USE OR OTHER DEALINGS IN THE SOFTWARE. */
 
-#include "util/u_debug.h"
+#include "draw/draw_context.h"
+
 #include "util/u_math.h"
+#include "util/u_memory.h"
 #include "util/u_pack_color.h"
 
 #include "tgsi/tgsi_parse.h"
@@ -31,6 +34,7 @@
 
 #include "r300_context.h"
 #include "r300_reg.h"
+#include "r300_screen.h"
 #include "r300_state_inlines.h"
 #include "r300_fs.h"
 #include "r300_vs.h"
 /* r300_state: Functions used to intialize state context by translating
  * Gallium state objects into semi-native r300 state objects. */
 
+static boolean blend_discard_if_src_alpha_0(unsigned srcRGB, unsigned srcA,
+                                            unsigned dstRGB, unsigned dstA)
+{
+    /* If the blend equation is ADD or REVERSE_SUBTRACT,
+     * SRC_ALPHA == 0, and the following state is set, the colorbuffer
+     * will not be changed.
+     * Notice that the dst factors are the src factors inverted. */
+    return (srcRGB == PIPE_BLENDFACTOR_SRC_ALPHA ||
+            srcRGB == PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE ||
+            srcRGB == PIPE_BLENDFACTOR_ZERO) &&
+           (srcA == PIPE_BLENDFACTOR_SRC_COLOR ||
+            srcA == PIPE_BLENDFACTOR_SRC_ALPHA ||
+            srcA == PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE ||
+            srcA == PIPE_BLENDFACTOR_ZERO) &&
+           (dstRGB == PIPE_BLENDFACTOR_INV_SRC_ALPHA ||
+            dstRGB == PIPE_BLENDFACTOR_ONE) &&
+           (dstA == PIPE_BLENDFACTOR_INV_SRC_COLOR ||
+            dstA == PIPE_BLENDFACTOR_INV_SRC_ALPHA ||
+            dstA == PIPE_BLENDFACTOR_ONE);
+}
+
+static boolean blend_discard_if_src_alpha_1(unsigned srcRGB, unsigned srcA,
+                                            unsigned dstRGB, unsigned dstA)
+{
+    /* If the blend equation is ADD or REVERSE_SUBTRACT,
+     * SRC_ALPHA == 1, and the following state is set, the colorbuffer
+     * will not be changed.
+     * Notice that the dst factors are the src factors inverted. */
+    return (srcRGB == PIPE_BLENDFACTOR_INV_SRC_ALPHA ||
+            srcRGB == PIPE_BLENDFACTOR_ZERO) &&
+           (srcA == PIPE_BLENDFACTOR_INV_SRC_COLOR ||
+            srcA == PIPE_BLENDFACTOR_INV_SRC_ALPHA ||
+            srcA == PIPE_BLENDFACTOR_ZERO) &&
+           (dstRGB == PIPE_BLENDFACTOR_SRC_ALPHA ||
+            dstRGB == PIPE_BLENDFACTOR_ONE) &&
+           (dstA == PIPE_BLENDFACTOR_SRC_COLOR ||
+            dstA == PIPE_BLENDFACTOR_SRC_ALPHA ||
+            dstA == PIPE_BLENDFACTOR_ONE);
+}
+
+static boolean blend_discard_if_src_color_0(unsigned srcRGB, unsigned srcA,
+                                            unsigned dstRGB, unsigned dstA)
+{
+    /* If the blend equation is ADD or REVERSE_SUBTRACT,
+     * SRC_COLOR == (0,0,0), and the following state is set, the colorbuffer
+     * will not be changed.
+     * Notice that the dst factors are the src factors inverted. */
+    return (srcRGB == PIPE_BLENDFACTOR_SRC_COLOR ||
+            srcRGB == PIPE_BLENDFACTOR_ZERO) &&
+           (srcA == PIPE_BLENDFACTOR_ZERO) &&
+           (dstRGB == PIPE_BLENDFACTOR_INV_SRC_COLOR ||
+            dstRGB == PIPE_BLENDFACTOR_ONE) &&
+           (dstA == PIPE_BLENDFACTOR_ONE);
+}
+
+static boolean blend_discard_if_src_color_1(unsigned srcRGB, unsigned srcA,
+                                            unsigned dstRGB, unsigned dstA)
+{
+    /* If the blend equation is ADD or REVERSE_SUBTRACT,
+     * SRC_COLOR == (1,1,1), and the following state is set, the colorbuffer
+     * will not be changed.
+     * Notice that the dst factors are the src factors inverted. */
+    return (srcRGB == PIPE_BLENDFACTOR_INV_SRC_COLOR ||
+            srcRGB == PIPE_BLENDFACTOR_ZERO) &&
+           (srcA == PIPE_BLENDFACTOR_ZERO) &&
+           (dstRGB == PIPE_BLENDFACTOR_SRC_COLOR ||
+            dstRGB == PIPE_BLENDFACTOR_ONE) &&
+           (dstA == PIPE_BLENDFACTOR_ONE);
+}
+
+static boolean blend_discard_if_src_alpha_color_0(unsigned srcRGB, unsigned srcA,
+                                                  unsigned dstRGB, unsigned dstA)
+{
+    /* If the blend equation is ADD or REVERSE_SUBTRACT,
+     * SRC_ALPHA_COLOR == (0,0,0,0), and the following state is set,
+     * the colorbuffer will not be changed.
+     * Notice that the dst factors are the src factors inverted. */
+    return (srcRGB == PIPE_BLENDFACTOR_SRC_COLOR ||
+            srcRGB == PIPE_BLENDFACTOR_SRC_ALPHA ||
+            srcRGB == PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE ||
+            srcRGB == PIPE_BLENDFACTOR_ZERO) &&
+           (srcA == PIPE_BLENDFACTOR_SRC_COLOR ||
+            srcA == PIPE_BLENDFACTOR_SRC_ALPHA ||
+            srcA == PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE ||
+            srcA == PIPE_BLENDFACTOR_ZERO) &&
+           (dstRGB == PIPE_BLENDFACTOR_INV_SRC_COLOR ||
+            dstRGB == PIPE_BLENDFACTOR_INV_SRC_ALPHA ||
+            dstRGB == PIPE_BLENDFACTOR_ONE) &&
+           (dstA == PIPE_BLENDFACTOR_INV_SRC_COLOR ||
+            dstA == PIPE_BLENDFACTOR_INV_SRC_ALPHA ||
+            dstA == PIPE_BLENDFACTOR_ONE);
+}
+
+static boolean blend_discard_if_src_alpha_color_1(unsigned srcRGB, unsigned srcA,
+                                                  unsigned dstRGB, unsigned dstA)
+{
+    /* If the blend equation is ADD or REVERSE_SUBTRACT,
+     * SRC_ALPHA_COLOR == (1,1,1,1), and the following state is set,
+     * the colorbuffer will not be changed.
+     * Notice that the dst factors are the src factors inverted. */
+    return (srcRGB == PIPE_BLENDFACTOR_INV_SRC_COLOR ||
+            srcRGB == PIPE_BLENDFACTOR_INV_SRC_ALPHA ||
+            srcRGB == PIPE_BLENDFACTOR_ZERO) &&
+           (srcA == PIPE_BLENDFACTOR_INV_SRC_COLOR ||
+            srcA == PIPE_BLENDFACTOR_INV_SRC_ALPHA ||
+            srcA == PIPE_BLENDFACTOR_ZERO) &&
+           (dstRGB == PIPE_BLENDFACTOR_SRC_COLOR ||
+            dstRGB == PIPE_BLENDFACTOR_SRC_ALPHA ||
+            dstRGB == PIPE_BLENDFACTOR_ONE) &&
+           (dstA == PIPE_BLENDFACTOR_SRC_COLOR ||
+            dstA == PIPE_BLENDFACTOR_SRC_ALPHA ||
+            dstA == PIPE_BLENDFACTOR_ONE);
+}
+
 /* Create a new blend state based on the CSO blend state.
  *
  * This encompasses alpha blending, logic/raster ops, and blend dithering. */
@@ -46,23 +164,123 @@ static void* r300_create_blend_state(struct pipe_context* pipe,
 {
     struct r300_blend_state* blend = CALLOC_STRUCT(r300_blend_state);
 
-    if (state->blend_enable) {
-        /* XXX for now, always do separate alpha...
-         * is it faster to do it with one reg? */
+    if (state->blend_enable)
+    {
+        unsigned eqRGB = state->rgb_func;
+        unsigned srcRGB = state->rgb_src_factor;
+        unsigned dstRGB = state->rgb_dst_factor;
+
+        unsigned eqA = state->alpha_func;
+        unsigned srcA = state->alpha_src_factor;
+        unsigned dstA = state->alpha_dst_factor;
+
+        /* despite the name, ALPHA_BLEND_ENABLE has nothing to do with alpha,
+         * this is just the crappy D3D naming */
         blend->blend_control = R300_ALPHA_BLEND_ENABLE |
-                R300_SEPARATE_ALPHA_ENABLE |
-                R300_READ_ENABLE |
-                r300_translate_blend_function(state->rgb_func) |
-                (r300_translate_blend_factor(state->rgb_src_factor) <<
-                    R300_SRC_BLEND_SHIFT) |
-                (r300_translate_blend_factor(state->rgb_dst_factor) <<
-                    R300_DST_BLEND_SHIFT);
-        blend->alpha_blend_control =
-                r300_translate_blend_function(state->alpha_func) |
-                (r300_translate_blend_factor(state->alpha_src_factor) <<
-                    R300_SRC_BLEND_SHIFT) |
-                (r300_translate_blend_factor(state->alpha_dst_factor) <<
-                    R300_DST_BLEND_SHIFT);
+            r300_translate_blend_function(eqRGB) |
+            ( r300_translate_blend_factor(srcRGB) << R300_SRC_BLEND_SHIFT) |
+            ( r300_translate_blend_factor(dstRGB) << R300_DST_BLEND_SHIFT);
+
+        /* Optimization: some operations do not require the destination color.
+         *
+         * When SRC_ALPHA_SATURATE is used, colorbuffer reads must be enabled,
+         * otherwise blending gives incorrect results. It seems to be
+         * a hardware bug. */
+        if (eqRGB == PIPE_BLEND_MIN || eqA == PIPE_BLEND_MIN ||
+            eqRGB == PIPE_BLEND_MAX || eqA == PIPE_BLEND_MAX ||
+            dstRGB != PIPE_BLENDFACTOR_ZERO ||
+            dstA != PIPE_BLENDFACTOR_ZERO ||
+            srcRGB == PIPE_BLENDFACTOR_DST_COLOR ||
+            srcRGB == PIPE_BLENDFACTOR_DST_ALPHA ||
+            srcRGB == PIPE_BLENDFACTOR_INV_DST_COLOR ||
+            srcRGB == PIPE_BLENDFACTOR_INV_DST_ALPHA ||
+            srcA == PIPE_BLENDFACTOR_DST_COLOR ||
+            srcA == PIPE_BLENDFACTOR_DST_ALPHA ||
+            srcA == PIPE_BLENDFACTOR_INV_DST_COLOR ||
+            srcA == PIPE_BLENDFACTOR_INV_DST_ALPHA ||
+            srcRGB == PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE) {
+            /* Enable reading from the colorbuffer. */
+            blend->blend_control |= R300_READ_ENABLE;
+
+            if (r300_screen(r300_context(pipe)->context.screen)->caps->is_r500) {
+                /* Optimization: Depending on incoming pixels, we can
+                 * conditionally disable the reading in hardware... */
+                if (eqRGB != PIPE_BLEND_MIN && eqA != PIPE_BLEND_MIN &&
+                    eqRGB != PIPE_BLEND_MAX && eqA != PIPE_BLEND_MAX) {
+                    /* Disable reading if SRC_ALPHA == 0. */
+                    if ((dstRGB == PIPE_BLENDFACTOR_SRC_ALPHA ||
+                         dstRGB == PIPE_BLENDFACTOR_ZERO) &&
+                        (dstA == PIPE_BLENDFACTOR_SRC_COLOR ||
+                         dstA == PIPE_BLENDFACTOR_SRC_ALPHA ||
+                         dstA == PIPE_BLENDFACTOR_ZERO)) {
+                         blend->blend_control |= R500_SRC_ALPHA_0_NO_READ;
+                    }
+
+                    /* Disable reading if SRC_ALPHA == 1. */
+                    if ((dstRGB == PIPE_BLENDFACTOR_INV_SRC_ALPHA ||
+                         dstRGB == PIPE_BLENDFACTOR_ZERO) &&
+                        (dstA == PIPE_BLENDFACTOR_INV_SRC_COLOR ||
+                         dstA == PIPE_BLENDFACTOR_INV_SRC_ALPHA ||
+                         dstA == PIPE_BLENDFACTOR_ZERO)) {
+                         blend->blend_control |= R500_SRC_ALPHA_1_NO_READ;
+                    }
+                }
+            }
+        }
+
+        /* Optimization: discard pixels which don't change the colorbuffer.
+         *
+         * The code below is non-trivial and some math is involved.
+         *
+         * Discarding pixels must be disabled when FP16 AA is enabled.
+         * This is a hardware bug. Also, this implementation wouldn't work
+         * with FP blending enabled and equation clamping disabled.
+         *
+         * Equations other than ADD are rarely used and therefore won't be
+         * optimized. */
+        if ((eqRGB == PIPE_BLEND_ADD || eqRGB == PIPE_BLEND_REVERSE_SUBTRACT) &&
+            (eqA == PIPE_BLEND_ADD || eqA == PIPE_BLEND_REVERSE_SUBTRACT)) {
+            /* ADD: X+Y
+             * REVERSE_SUBTRACT: Y-X
+             *
+             * The idea is:
+             * If X = src*srcFactor = 0 and Y = dst*dstFactor = 1,
+             * then CB will not be changed.
+             *
+             * Given the srcFactor and dstFactor variables, we can derive
+             * what src and dst should be equal to and discard appropriate
+             * pixels.
+             */
+            if (blend_discard_if_src_alpha_0(srcRGB, srcA, dstRGB, dstA)) {
+                blend->blend_control |= R300_DISCARD_SRC_PIXELS_SRC_ALPHA_0;
+            } else if (blend_discard_if_src_alpha_1(srcRGB, srcA,
+                                                    dstRGB, dstA)) {
+                blend->blend_control |= R300_DISCARD_SRC_PIXELS_SRC_ALPHA_1;
+            } else if (blend_discard_if_src_color_0(srcRGB, srcA,
+                                                    dstRGB, dstA)) {
+                blend->blend_control |= R300_DISCARD_SRC_PIXELS_SRC_COLOR_0;
+            } else if (blend_discard_if_src_color_1(srcRGB, srcA,
+                                                    dstRGB, dstA)) {
+                blend->blend_control |= R300_DISCARD_SRC_PIXELS_SRC_COLOR_1;
+            } else if (blend_discard_if_src_alpha_color_0(srcRGB, srcA,
+                                                          dstRGB, dstA)) {
+                blend->blend_control |=
+                    R300_DISCARD_SRC_PIXELS_SRC_ALPHA_COLOR_0;
+            } else if (blend_discard_if_src_alpha_color_1(srcRGB, srcA,
+                                                          dstRGB, dstA)) {
+                blend->blend_control |=
+                    R300_DISCARD_SRC_PIXELS_SRC_ALPHA_COLOR_1;
+            }
+        }
+
+        /* separate alpha */
+        if (srcA != srcRGB || dstA != dstRGB || eqA != eqRGB) {
+            blend->blend_control |= R300_SEPARATE_ALPHA_ENABLE;
+            blend->alpha_blend_control =
+                r300_translate_blend_function(eqA) |
+                (r300_translate_blend_factor(srcA) << R300_SRC_BLEND_SHIFT) |
+                (r300_translate_blend_factor(dstA) << R300_DST_BLEND_SHIFT);
+        }
     }
 
     /* PIPE_LOGICOP_* don't need to be translated, fortunately. */
@@ -71,6 +289,20 @@ static void* r300_create_blend_state(struct pipe_context* pipe,
                 (state->logicop_func) << R300_RB3D_ROPCNTL_ROP_SHIFT;
     }
 
+    /* Color Channel Mask */
+    if (state->colormask & PIPE_MASK_R) {
+        blend->color_channel_mask |= RB3D_COLOR_CHANNEL_MASK_RED_MASK0;
+    }
+    if (state->colormask & PIPE_MASK_G) {
+        blend->color_channel_mask |= RB3D_COLOR_CHANNEL_MASK_GREEN_MASK0;
+    }
+    if (state->colormask & PIPE_MASK_B) {
+        blend->color_channel_mask |= RB3D_COLOR_CHANNEL_MASK_BLUE_MASK0;
+    }
+    if (state->colormask & PIPE_MASK_A) {
+        blend->color_channel_mask |= RB3D_COLOR_CHANNEL_MASK_ALPHA_MASK0;
+    }
+
     if (state->dither) {
         blend->dither = R300_RB3D_DITHER_CTL_DITHER_MODE_LUT |
                 R300_RB3D_DITHER_CTL_ALPHA_DITHER_MODE_LUT;
@@ -96,25 +328,30 @@ static void r300_delete_blend_state(struct pipe_context* pipe,
     FREE(state);
 }
 
+/* Convert float to 10bit integer */
+static unsigned float_to_fixed10(float f)
+{
+    return CLAMP((unsigned)(f * 1023.9f), 0, 1023);
+}
+
 /* Set blend color.
  * Setup both R300 and R500 registers, figure out later which one to write. */
 static void r300_set_blend_color(struct pipe_context* pipe,
                                  const struct pipe_blend_color* color)
 {
     struct r300_context* r300 = r300_context(pipe);
-    ubyte ur, ug, ub, ua;
-
-    ur = float_to_ubyte(color->color[0]);
-    ug = float_to_ubyte(color->color[1]);
-    ub = float_to_ubyte(color->color[2]);
-    ua = float_to_ubyte(color->color[3]);
+    union util_color uc;
 
-    util_pack_color(color->color, PIPE_FORMAT_A8R8G8B8_UNORM,
-            &r300->blend_color_state->blend_color);
+    util_pack_color(color->color, PIPE_FORMAT_A8R8G8B8_UNORM, &uc);
+    r300->blend_color_state->blend_color = uc.ui;
 
-    /* XXX this is wrong */
-    r300->blend_color_state->blend_color_red_alpha = ur | (ua << 16);
-    r300->blend_color_state->blend_color_green_blue = ub | (ug << 16);
+    /* XXX if FP16 blending is enabled, we should use the FP16 format */
+    r300->blend_color_state->blend_color_red_alpha =
+        float_to_fixed10(color->color[0]) |
+        (float_to_fixed10(color->color[3]) << 16);
+    r300->blend_color_state->blend_color_green_blue =
+        float_to_fixed10(color->color[2]) |
+        (float_to_fixed10(color->color[1]) << 16);
 
     r300->dirty_state |= R300_NEW_BLEND_COLOR;
 }
@@ -133,31 +370,6 @@ static void r300_set_clip_state(struct pipe_context* pipe,
     }
 }
 
-static void
-    r300_set_constant_buffer(struct pipe_context* pipe,
-                             uint shader, uint index,
-                             const struct pipe_constant_buffer* buffer)
-{
-    struct r300_context* r300 = r300_context(pipe);
-
-    /* This entire chunk of code seems ever-so-slightly baked.
-     * It's as if I've got pipe_buffer* matryoshkas... */
-    if (buffer && buffer->buffer && buffer->buffer->size) {
-        void* map = pipe->winsys->buffer_map(pipe->winsys, buffer->buffer,
-                                             PIPE_BUFFER_USAGE_CPU_READ);
-        memcpy(r300->shader_constants[shader].constants,
-            map, buffer->buffer->size);
-        pipe->winsys->buffer_unmap(pipe->winsys, buffer->buffer);
-
-        r300->shader_constants[shader].count =
-            buffer->buffer->size / (sizeof(float) * 4);
-    } else {
-        r300->shader_constants[shader].count = 0;
-    }
-
-    r300->dirty_state |= R300_NEW_CONSTANTS;
-}
-
 /* Create a new depth, stencil, and alpha state based on the CSO dsa state.
  *
  * This contains the depth buffer, stencil buffer, alpha test, and such.
@@ -167,6 +379,8 @@ static void*
         r300_create_dsa_state(struct pipe_context* pipe,
                               const struct pipe_depth_stencil_alpha_state* state)
 {
+    struct r300_capabilities *caps =
+        r300_screen(r300_context(pipe)->context.screen)->caps;
     struct r300_dsa_state* dsa = CALLOC_STRUCT(r300_dsa_state);
 
     /* Depth test setup. */
@@ -211,9 +425,16 @@ static void*
             (r300_translate_stencil_op(state->stencil[1].zfail_op) <<
                 R300_S_BACK_ZFAIL_OP_SHIFT);
 
-            dsa->stencil_ref_bf = (state->stencil[1].ref_value) |
-                (state->stencil[1].valuemask << R300_STENCILMASK_SHIFT) |
-                (state->stencil[1].writemask << R300_STENCILWRITEMASK_SHIFT);
+            /* XXX it seems r3xx doesn't support STENCILREFMASK_BF */
+            if (caps->is_r500)
+            {
+                dsa->z_buffer_control |= R500_STENCIL_REFMASK_FRONT_BACK;
+                dsa->stencil_ref_bf = (state->stencil[1].ref_value) |
+                    (state->stencil[1].valuemask <<
+                    R300_STENCILMASK_SHIFT) |
+                    (state->stencil[1].writemask <<
+                    R300_STENCILWRITEMASK_SHIFT);
+            }
         }
     }
 
@@ -222,11 +443,13 @@ static void*
         dsa->alpha_function =
             r300_translate_alpha_function(state->alpha.func) |
             R300_FG_ALPHA_FUNC_ENABLE;
-        dsa->alpha_reference = CLAMP(state->alpha.ref_value * 1023.0f,
-                                     0, 1023);
-    } else {
-        /* XXX need to fix this to be dynamically set
-        dsa->z_buffer_top = R300_ZTOP_ENABLE; */
+
+        /* XXX figure out why emitting 10bit alpha ref causes CS to dump */
+        /* always use 8bit alpha ref */
+        dsa->alpha_function |= float_to_ubyte(state->alpha.ref_value);
+
+        if (caps->is_r500)
+            dsa->alpha_function |= R500_FG_ALPHA_FUNC_8BIT;
     }
 
     return (void*)dsa;
@@ -249,11 +472,29 @@ static void r300_delete_dsa_state(struct pipe_context* pipe,
     FREE(state);
 }
 
-static void r300_set_edgeflags(struct pipe_context* pipe,
-                               const unsigned* bitfield)
+static void r300_set_scissor_regs(const struct pipe_scissor_state* state,
+                                  struct r300_scissor_regs *scissor,
+                                  boolean is_r500)
 {
-    /* XXX you know it's bad when i915 has this blank too */
-    /* XXX and even worse, I have no idea WTF the bitfield is */
+    if (is_r500) {
+        scissor->top_left =
+            (state->minx << R300_SCISSORS_X_SHIFT) |
+            (state->miny << R300_SCISSORS_Y_SHIFT);
+        scissor->bottom_right =
+            ((state->maxx - 1) << R300_SCISSORS_X_SHIFT) |
+            ((state->maxy - 1) << R300_SCISSORS_Y_SHIFT);
+    } else {
+        /* Offset of 1440 in non-R500 chipsets. */
+        scissor->top_left =
+            ((state->minx + 1440) << R300_SCISSORS_X_SHIFT) |
+            ((state->miny + 1440) << R300_SCISSORS_Y_SHIFT);
+        scissor->bottom_right =
+            (((state->maxx - 1) + 1440) << R300_SCISSORS_X_SHIFT) |
+            (((state->maxy - 1) + 1440) << R300_SCISSORS_Y_SHIFT);
+    }
+
+    scissor->empty_area = state->minx >= state->maxx ||
+                          state->miny >= state->maxy;
 }
 
 static void
@@ -261,12 +502,27 @@ static void
                                const struct pipe_framebuffer_state* state)
 {
     struct r300_context* r300 = r300_context(pipe);
+    struct pipe_scissor_state scissor;
 
-    draw_flush(r300->draw);
+    if (r300->draw) {
+        draw_flush(r300->draw);
+    }
 
     r300->framebuffer_state = *state;
 
+    scissor.minx = scissor.miny = 0;
+    scissor.maxx = state->width;
+    scissor.maxy = state->height;
+    r300_set_scissor_regs(&scissor, &r300->scissor_state->framebuffer,
+                          r300_screen(r300->context.screen)->caps->is_r500);
+
+    /* Don't rely on the order of states being set for the first time. */
+    if (!r300->rs_state || !r300->rs_state->rs.scissor) {
+        r300->dirty_state |= R300_NEW_SCISSOR;
+    }
     r300->dirty_state |= R300_NEW_FRAMEBUFFERS;
+    r300->dirty_state |= R300_NEW_BLEND;
+    r300->dirty_state |= R300_NEW_DSA;
 }
 
 /* Create fragment shader state. */
@@ -282,6 +538,7 @@ static void* r300_create_fs_state(struct pipe_context* pipe,
     fs->state.tokens = tgsi_dup_tokens(shader->tokens);
 
     tgsi_scan_shader(shader->tokens, &fs->info);
+    r300_shader_read_fs_inputs(&fs->info, &fs->inputs);
 
     return (void*)fs;
 }
@@ -295,21 +552,31 @@ static void r300_bind_fs_state(struct pipe_context* pipe, void* shader)
     if (fs == NULL) {
         r300->fs = NULL;
         return;
-    } else if (!fs->translated) {
-        r300_translate_fragment_shader(r300, fs);
     }
 
     r300->fs = fs;
+    r300_pick_fragment_shader(r300);
 
-    r300->dirty_state |= R300_NEW_FRAGMENT_SHADER;
+    if (r300->vs && r300_vertex_shader_setup_wpos(r300)) {
+        r300->dirty_state |= R300_NEW_VERTEX_FORMAT;
+    }
+
+    r300->dirty_state |= R300_NEW_FRAGMENT_SHADER | R300_NEW_FRAGMENT_SHADER_CONSTANTS;
 }
 
 /* Delete fragment shader state. */
 static void r300_delete_fs_state(struct pipe_context* pipe, void* shader)
 {
     struct r300_fragment_shader* fs = (struct r300_fragment_shader*)shader;
-    rc_constants_destroy(&fs->code.constants);
-    FREE(fs->state.tokens);
+    struct r300_fragment_shader_code *tmp, *ptr = fs->first;
+
+    while (ptr) {
+        tmp = ptr;
+        ptr = ptr->next;
+        rc_constants_destroy(&tmp->code.constants);
+        FREE(tmp);
+    }
+    FREE((void*)fs->state.tokens);
     FREE(shader);
 }
 
@@ -347,8 +614,6 @@ static void* r300_create_rs_state(struct pipe_context* pipe,
     if (state->bypass_vs_clip_and_viewport ||
             !r300_screen(pipe->screen)->caps->has_tcl) {
         rs->vap_control_status |= R300_VAP_TCL_BYPASS;
-    } else {
-        rs->rs.bypass_vs_clip_and_viewport = TRUE;
     }
 
     rs->point_size = pack_float_16_6x(state->point_size) |
@@ -363,25 +628,52 @@ static void* r300_create_rs_state(struct pipe_context* pipe,
     rs->line_control = pack_float_16_6x(state->line_width) |
         R300_GA_LINE_CNTL_END_TYPE_COMP;
 
+    /* XXX I think there is something wrong with the polygon mode,
+     * XXX re-test when r300g is in a better shape */
+
+    /* Enable polygon mode */
+    if (state->fill_cw != PIPE_POLYGON_MODE_FILL ||
+        state->fill_ccw != PIPE_POLYGON_MODE_FILL) {
+        rs->polygon_mode = R300_GA_POLY_MODE_DUAL;
+    }
+
     /* Radeons don't think in "CW/CCW", they think in "front/back". */
     if (state->front_winding == PIPE_WINDING_CW) {
         rs->cull_mode = R300_FRONT_FACE_CW;
 
+        /* Polygon offset */
         if (state->offset_cw) {
             rs->polygon_offset_enable |= R300_FRONT_ENABLE;
         }
         if (state->offset_ccw) {
             rs->polygon_offset_enable |= R300_BACK_ENABLE;
         }
+
+        /* Polygon mode */
+        if (rs->polygon_mode) {
+            rs->polygon_mode |=
+                r300_translate_polygon_mode_front(state->fill_cw);
+            rs->polygon_mode |=
+                r300_translate_polygon_mode_back(state->fill_ccw);
+        }
     } else {
         rs->cull_mode = R300_FRONT_FACE_CCW;
 
+        /* Polygon offset */
         if (state->offset_ccw) {
             rs->polygon_offset_enable |= R300_FRONT_ENABLE;
         }
         if (state->offset_cw) {
             rs->polygon_offset_enable |= R300_BACK_ENABLE;
         }
+
+        /* Polygon mode */
+        if (rs->polygon_mode) {
+            rs->polygon_mode |=
+                r300_translate_polygon_mode_front(state->fill_ccw);
+            rs->polygon_mode |=
+                r300_translate_polygon_mode_back(state->fill_cw);
+        }
     }
     if (state->front_winding & state->cull_mode) {
         rs->cull_mode |= R300_CULL_FRONT;
@@ -412,10 +704,6 @@ static void* r300_create_rs_state(struct pipe_context* pipe,
         rs->color_control = R300_SHADE_MODEL_SMOOTH;
     }
 
-    if (!state->flatshade_first) {
-        rs->color_control |= R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_LAST;
-    }
-
     return (void*)rs;
 }
 
@@ -425,14 +713,20 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state)
     struct r300_context* r300 = r300_context(pipe);
     struct r300_rs_state* rs = (struct r300_rs_state*)state;
 
-    draw_flush(r300->draw);
-    draw_set_rasterizer_state(r300->draw, &rs->rs);
+    if (r300->draw) {
+        draw_flush(r300->draw);
+        draw_set_rasterizer_state(r300->draw, &rs->rs);
+    }
 
     r300->rs_state = rs;
+    /* XXX Clean these up when we move to atom emits */
     r300->dirty_state |= R300_NEW_RASTERIZER;
     r300->dirty_state |= R300_NEW_RS_BLOCK;
     r300->dirty_state |= R300_NEW_SCISSOR;
     r300->dirty_state |= R300_NEW_VIEWPORT;
+    if (r300->fs && r300->fs->inputs.wpos != ATTR_UNUSED) {
+        r300->dirty_state |= R300_NEW_FRAGMENT_SHADER_CONSTANTS;
+    }
 }
 
 /* Free rasterizer state. */
@@ -448,6 +742,9 @@ static void*
     struct r300_context* r300 = r300_context(pipe);
     struct r300_sampler_state* sampler = CALLOC_STRUCT(r300_sampler_state);
     int lod_bias;
+    union util_color uc;
+
+    sampler->state = *state;
 
     sampler->filter0 |=
         (r300_translate_wrap(state->wrap_s) << R300_TX_WRAP_S_SHIFT) |
@@ -456,7 +753,13 @@ static void*
 
     sampler->filter0 |= r300_translate_tex_filters(state->min_img_filter,
                                                    state->mag_img_filter,
-                                                   state->min_mip_filter);
+                                                   state->min_mip_filter,
+                                                   state->max_anisotropy > 1.0);
+
+    /* Unfortunately, r300-r500 don't support floating-point mipmap lods. */
+    /* We must pass these to the emit function to clamp them properly. */
+    sampler->min_lod = MAX2((unsigned)state->min_lod, 0);
+    sampler->max_lod = MAX2((unsigned)ceilf(state->max_lod), 0);
 
     lod_bias = CLAMP((int)(state->lod_bias * 32), -(1 << 9), (1 << 9) - 1);
 
@@ -464,8 +767,8 @@ static void*
 
     sampler->filter1 |= r300_anisotropy(state->max_anisotropy);
 
-    util_pack_color(state->border_color, PIPE_FORMAT_A8R8G8B8_UNORM,
-                    &sampler->border_color);
+    util_pack_color(state->border_color, PIPE_FORMAT_A8R8G8B8_UNORM, &uc);
+    sampler->border_color = uc.ui;
 
     /* R500-specific fixups and optimizations */
     if (r300_screen(r300->context.screen)->caps->is_r500) {
@@ -494,6 +797,20 @@ static void r300_bind_sampler_states(struct pipe_context* pipe,
     }
 
     r300->sampler_count = count;
+
+    /* Pick a fragment shader based on the texture compare state. */
+    if (r300->fs && (r300->dirty_state & R300_ANY_NEW_SAMPLERS)) {
+        if (r300_pick_fragment_shader(r300)) {
+            r300->dirty_state |= R300_NEW_FRAGMENT_SHADER |
+                                 R300_NEW_FRAGMENT_SHADER_CONSTANTS;
+        }
+    }
+}
+
+static void r300_lacks_vertex_textures(struct pipe_context* pipe,
+                                       unsigned count,
+                                       void** states)
+{
 }
 
 static void r300_delete_sampler_state(struct pipe_context* pipe, void* state)
@@ -506,18 +823,26 @@ static void r300_set_sampler_textures(struct pipe_context* pipe,
                                       struct pipe_texture** texture)
 {
     struct r300_context* r300 = r300_context(pipe);
+    boolean is_r500 = r300_screen(r300->context.screen)->caps->is_r500;
     int i;
 
     /* XXX magic num */
     if (count > 8) {
         return;
     }
-
+    
     for (i = 0; i < count; i++) {
         if (r300->textures[i] != (struct r300_texture*)texture[i]) {
             pipe_texture_reference((struct pipe_texture**)&r300->textures[i],
                 texture[i]);
             r300->dirty_state |= (R300_NEW_TEXTURE << i);
+
+            /* R300-specific - set the texrect factor in a fragment shader */
+            if (!is_r500 && r300->textures[i]->is_npot) {
+                /* XXX It would be nice to re-emit just 1 constant,
+                 * XXX not all of them */
+                r300->dirty_state |= R300_NEW_FRAGMENT_SHADER_CONSTANTS;
+            }
         }
     }
 
@@ -537,24 +862,13 @@ static void r300_set_scissor_state(struct pipe_context* pipe,
 {
     struct r300_context* r300 = r300_context(pipe);
 
-    if (r300_screen(r300->context.screen)->caps->is_r500) {
-        r300->scissor_state->scissor_top_left =
-            (state->minx << R300_SCISSORS_X_SHIFT) |
-            (state->miny << R300_SCISSORS_Y_SHIFT);
-        r300->scissor_state->scissor_bottom_right =
-            ((state->maxx - 1) << R300_SCISSORS_X_SHIFT) |
-            ((state->maxy - 1) << R300_SCISSORS_Y_SHIFT);
-    } else {
-        /* Offset of 1440 in non-R500 chipsets. */
-        r300->scissor_state->scissor_top_left =
-            ((state->minx + 1440) << R300_SCISSORS_X_SHIFT) |
-            ((state->miny + 1440) << R300_SCISSORS_Y_SHIFT);
-        r300->scissor_state->scissor_bottom_right =
-            (((state->maxx - 1) + 1440) << R300_SCISSORS_X_SHIFT) |
-            (((state->maxy - 1) + 1440) << R300_SCISSORS_Y_SHIFT);
-    }
+    r300_set_scissor_regs(state, &r300->scissor_state->scissor,
+                          r300_screen(r300->context.screen)->caps->is_r500);
 
-    r300->dirty_state |= R300_NEW_SCISSOR;
+    /* Don't rely on the order of states being set for the first time. */
+    if (!r300->rs_state || r300->rs_state->rs.scissor) {
+        r300->dirty_state |= R300_NEW_SCISSOR;
+    }
 }
 
 static void r300_set_viewport_state(struct pipe_context* pipe,
@@ -566,17 +880,14 @@ static void r300_set_viewport_state(struct pipe_context* pipe,
     r300->viewport_state->vte_control = R300_VTX_W0_FMT;
 
     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;
     }
@@ -594,6 +905,9 @@ static void r300_set_viewport_state(struct pipe_context* pipe,
     }
 
     r300->dirty_state |= R300_NEW_VIEWPORT;
+    if (r300->fs && r300->fs->inputs.wpos != ATTR_UNUSED) {
+        r300->dirty_state |= R300_NEW_FRAGMENT_SHADER_CONSTANTS;
+    }
 }
 
 static void r300_set_vertex_buffers(struct pipe_context* pipe,
@@ -602,13 +916,16 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe,
 {
     struct r300_context* r300 = r300_context(pipe);
 
-    memcpy(r300->vertex_buffers, buffers,
+    memcpy(r300->vertex_buffer, buffers,
         sizeof(struct pipe_vertex_buffer) * count);
-
     r300->vertex_buffer_count = count;
 
-    draw_flush(r300->draw);
-    draw_set_vertex_buffers(r300->draw, count, buffers);
+    if (r300->draw) {
+        draw_flush(r300->draw);
+        draw_set_vertex_buffers(r300->draw, count, buffers);
+    }
+
+    r300->dirty_state |= R300_NEW_VERTEX_FORMAT;
 }
 
 static void r300_set_vertex_elements(struct pipe_context* pipe,
@@ -617,8 +934,15 @@ static void r300_set_vertex_elements(struct pipe_context* pipe,
 {
     struct r300_context* r300 = r300_context(pipe);
 
-    draw_flush(r300->draw);
-    draw_set_vertex_elements(r300->draw, count, elements);
+    memcpy(r300->vertex_element,
+           elements,
+           sizeof(struct pipe_vertex_element) * count);
+    r300->vertex_element_count = count;
+
+    if (r300->draw) {
+        draw_flush(r300->draw);
+        draw_set_vertex_elements(r300->draw, count, elements);
+    }
 }
 
 static void* r300_create_vs_state(struct pipe_context* pipe,
@@ -634,9 +958,6 @@ static void* r300_create_vs_state(struct pipe_context* pipe,
 
         tgsi_scan_shader(shader->tokens, &vs->info);
 
-        /* Appease Draw. */
-        vs->draw = draw_create_vertex_shader(r300->draw, shader);
-
         return (void*)vs;
     } else {
         return draw_create_vertex_shader(r300->draw, shader);
@@ -647,8 +968,6 @@ static void r300_bind_vs_state(struct pipe_context* pipe, void* shader)
 {
     struct r300_context* r300 = r300_context(pipe);
 
-    draw_flush(r300->draw);
-
     if (r300_screen(pipe->screen)->caps->has_tcl) {
         struct r300_vertex_shader* vs = (struct r300_vertex_shader*)shader;
 
@@ -659,10 +978,16 @@ static void r300_bind_vs_state(struct pipe_context* pipe, void* shader)
             r300_translate_vertex_shader(r300, vs);
         }
 
-        draw_bind_vertex_shader(r300->draw, vs->draw);
         r300->vs = vs;
-        r300->dirty_state |= R300_NEW_VERTEX_SHADER;
+        if (r300->fs) {
+            r300_vertex_shader_setup_wpos(r300);
+        }
+
+        r300->dirty_state |=
+            R300_NEW_VERTEX_SHADER | R300_NEW_VERTEX_SHADER_CONSTANTS |
+            R300_NEW_VERTEX_FORMAT;
     } else {
+        draw_flush(r300->draw);
         draw_bind_vertex_shader(r300->draw,
                 (struct draw_vertex_shader*)shader);
     }
@@ -676,8 +1001,7 @@ static void r300_delete_vs_state(struct pipe_context* pipe, void* shader)
         struct r300_vertex_shader* vs = (struct r300_vertex_shader*)shader;
 
         rc_constants_destroy(&vs->code.constants);
-        draw_delete_vertex_shader(r300->draw, vs->draw);
-        FREE(vs->state.tokens);
+        FREE((void*)vs->state.tokens);
         FREE(shader);
     } else {
         draw_delete_vertex_shader(r300->draw,
@@ -685,6 +1009,31 @@ static void r300_delete_vs_state(struct pipe_context* pipe, void* shader)
     }
 }
 
+static void r300_set_constant_buffer(struct pipe_context *pipe,
+                                     uint shader, uint index,
+                                     const struct pipe_constant_buffer *buf)
+{
+    struct r300_context* r300 = r300_context(pipe);
+    void *mapped;
+
+    if (buf == NULL || buf->buffer->size == 0 ||
+        (mapped = pipe_buffer_map(pipe->screen, buf->buffer, PIPE_BUFFER_USAGE_CPU_READ)) == NULL)
+    {
+        r300->shader_constants[shader].count = 0;
+        return;
+    }
+
+    assert((buf->buffer->size % 4 * sizeof(float)) == 0);
+    memcpy(r300->shader_constants[shader].constants, mapped, buf->buffer->size);
+    r300->shader_constants[shader].count = buf->buffer->size / (4 * sizeof(float));
+    pipe_buffer_unmap(pipe->screen, buf->buffer);
+
+    if (shader == PIPE_SHADER_VERTEX)
+        r300->dirty_state |= R300_NEW_VERTEX_SHADER_CONSTANTS;
+    else if (shader == PIPE_SHADER_FRAGMENT)
+        r300->dirty_state |= R300_NEW_FRAGMENT_SHADER_CONSTANTS;
+}
+
 void r300_init_state_functions(struct r300_context* r300)
 {
     r300->context.create_blend_state = r300_create_blend_state;
@@ -701,8 +1050,6 @@ void r300_init_state_functions(struct r300_context* r300)
     r300->context.bind_depth_stencil_alpha_state = r300_bind_dsa_state;
     r300->context.delete_depth_stencil_alpha_state = r300_delete_dsa_state;
 
-    r300->context.set_edgeflags = r300_set_edgeflags;
-
     r300->context.set_framebuffer_state = r300_set_framebuffer_state;
 
     r300->context.create_fs_state = r300_create_fs_state;
@@ -716,10 +1063,11 @@ void r300_init_state_functions(struct r300_context* r300)
     r300->context.delete_rasterizer_state = r300_delete_rs_state;
 
     r300->context.create_sampler_state = r300_create_sampler_state;
-    r300->context.bind_sampler_states = r300_bind_sampler_states;
+    r300->context.bind_fragment_sampler_states = r300_bind_sampler_states;
+    r300->context.bind_vertex_sampler_states = r300_lacks_vertex_textures;
     r300->context.delete_sampler_state = r300_delete_sampler_state;
 
-    r300->context.set_sampler_textures = r300_set_sampler_textures;
+    r300->context.set_fragment_sampler_textures = r300_set_sampler_textures;
 
     r300->context.set_scissor_state = r300_set_scissor_state;
 
index 02b7ab91076ad6217b760d2ccfa22442b22ddb98..22660a52d9ac1d067125631fa765d78becbec26e 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
+ * Copyright 2009 Marek Olšák <maraeo@gmail.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  * USE OR OTHER DEALINGS IN THE SOFTWARE. */
 
-#include "r300_state_derived.h"
+#include "draw/draw_context.h"
+
+#include "util/u_math.h"
+#include "util/u_memory.h"
 
+#include "r300_context.h"
 #include "r300_fs.h"
+#include "r300_screen.h"
+#include "r300_shader_semantics.h"
+#include "r300_state_derived.h"
 #include "r300_state_inlines.h"
 #include "r300_vs.h"
 
 /* r300_state_derived: Various bits of state which are dependent upon
  * currently bound CSO data. */
 
-/* Set up the vs_tab and routes. */
-static void r300_vs_tab_routes(struct r300_context* r300,
-                               struct r300_vertex_format* vformat)
+struct r300_shader_key {
+    struct r300_vertex_shader* vs;
+    struct r300_fragment_shader* fs;
+};
+
+struct r300_shader_derived_value {
+    struct r300_vertex_format* vformat;
+    struct r300_rs_block* rs_block;
+};
+
+unsigned r300_shader_key_hash(void* key) {
+    struct r300_shader_key* shader_key = (struct r300_shader_key*)key;
+    unsigned vs = (intptr_t)shader_key->vs;
+    unsigned fs = (intptr_t)shader_key->fs;
+
+    return (vs << 16) | (fs & 0xffff);
+}
+
+int r300_shader_key_compare(void* key1, void* key2) {
+    struct r300_shader_key* shader_key1 = (struct r300_shader_key*)key1;
+    struct r300_shader_key* shader_key2 = (struct r300_shader_key*)key2;
+
+    return (shader_key1->vs == shader_key2->vs) &&
+        (shader_key1->fs == shader_key2->fs);
+}
+
+static void r300_draw_emit_attrib(struct r300_context* r300,
+                                  enum attrib_emit emit,
+                                  enum interp_mode interp,
+                                  int index)
 {
-    struct r300_screen* r300screen = r300_screen(r300->context.screen);
-    struct vertex_info* vinfo = &vformat->vinfo;
-    int* tab = vformat->vs_tab;
-    boolean pos = FALSE, psize = FALSE, fog = FALSE;
-    int i, texs = 0, cols = 0;
-    struct tgsi_shader_info* info;
+    struct tgsi_shader_info* info = &r300->vs->info;
+    int output;
 
-    if (r300screen->caps->has_tcl) {
-        /* Use vertex shader to determine required routes. */
-        info = &r300->vs->info;
+    output = draw_find_shader_output(r300->draw,
+                                     info->output_semantic_name[index],
+                                     info->output_semantic_index[index]);
+    draw_emit_vertex_attr(&r300->vertex_info->vinfo, emit, interp, output);
+}
+
+static void r300_draw_emit_all_attribs(struct r300_context* r300)
+{
+    struct r300_shader_semantics* vs_outputs = &r300->vs->outputs;
+    int i, gen_count;
+
+    /* Position. */
+    if (vs_outputs->pos != ATTR_UNUSED) {
+        r300_draw_emit_attrib(r300, EMIT_4F, INTERP_PERSPECTIVE,
+                              vs_outputs->pos);
     } else {
-        /* Use fragment shader to determine required routes. */
-        info = &r300->fs->info;
+        assert(0);
     }
 
-    assert(info->num_inputs <= 16);
-
-    if (!r300screen->caps->has_tcl || !r300->rs_state->enable_vte)
-    {
-        for (i = 0; i < info->num_inputs; i++) {
-            switch (r300->vs->code.inputs[i]) {
-                case TGSI_SEMANTIC_POSITION:
-                    pos = TRUE;
-                    tab[i] = 0;
-                    break;
-                case TGSI_SEMANTIC_COLOR:
-                    tab[i] = 2 + cols;
-                    cols++;
-                    break;
-                case TGSI_SEMANTIC_PSIZE:
-                    assert(psize == FALSE);
-                    psize = TRUE;
-                    tab[i] = 15;
-                    break;
-                case TGSI_SEMANTIC_FOG:
-                    assert(fog == FALSE);
-                    fog = TRUE;
-                    /* Fall through */
-                case TGSI_SEMANTIC_GENERIC:
-                    tab[i] = 6 + texs;
-                    texs++;
-                    break;
-                default:
-                    debug_printf("r300: Unknown vertex input %d\n",
-                        info->input_semantic_name[i]);
-                    break;
-            }
-        }
+    /* Point size. */
+    if (vs_outputs->psize != ATTR_UNUSED) {
+        r300_draw_emit_attrib(r300, EMIT_1F_PSIZE, INTERP_POS,
+                              vs_outputs->psize);
     }
-    else
-    {
-        /* Just copy vert attribs over as-is. */
-        for (i = 0; i < info->num_inputs; i++) {
-            tab[i] = i;
-        }
 
-        for (i = 0; i < info->num_outputs; i++) {
-            switch (info->output_semantic_name[i]) {
-                case TGSI_SEMANTIC_POSITION:
-                    pos = TRUE;
-                    break;
-                case TGSI_SEMANTIC_COLOR:
-                    cols++;
-                    break;
-                case TGSI_SEMANTIC_PSIZE:
-                    psize = TRUE;
-                    break;
-                case TGSI_SEMANTIC_FOG:
-                    fog = TRUE;
-                    /* Fall through */
-                case TGSI_SEMANTIC_GENERIC:
-                    texs++;
-                    break;
-                default:
-                    debug_printf("r300: Unknown vertex output %d\n",
-                        info->output_semantic_name[i]);
-                    break;
-            }
+    /* Colors. */
+    for (i = 0; i < ATTR_COLOR_COUNT; i++) {
+        if (vs_outputs->color[i] != ATTR_UNUSED) {
+            r300_draw_emit_attrib(r300, EMIT_4F, INTERP_LINEAR,
+                                  vs_outputs->color[i]);
         }
     }
 
-    /* XXX magic */
-    assert(texs <= 8);
+    /* XXX Back-face colors. */
 
-    /* Do the actual vertex_info setup.
-     *
-     * vertex_info has four uints of hardware-specific data in it.
-     * vinfo.hwfmt[0] is R300_VAP_VTX_STATE_CNTL
-     * vinfo.hwfmt[1] is R300_VAP_VSM_VTX_ASSM
-     * vinfo.hwfmt[2] is R300_VAP_OUTPUT_VTX_FMT_0
-     * vinfo.hwfmt[3] is R300_VAP_OUTPUT_VTX_FMT_1 */
-
-    vinfo->hwfmt[0] = 0x5555; /* XXX this is classic Mesa bonghits */
-
-    /* We need to add vertex position attribute only for SW TCL case,
-     * for HW TCL case it could be generated by vertex shader */
-    if (!pos && !r300screen->caps->has_tcl) {
-        debug_printf("r300: Forcing vertex position attribute emit...\n");
-        /* Make room for the position attribute
-         * at the beginning of the tab. */
-        for (i = 15; i > 0; i--) {
-            tab[i] = tab[i-1];
+    /* Texture coordinates. */
+    gen_count = 0;
+    for (i = 0; i < ATTR_GENERIC_COUNT; i++) {
+        if (vs_outputs->generic[i] != ATTR_UNUSED) {
+            r300_draw_emit_attrib(r300, EMIT_4F, INTERP_PERSPECTIVE,
+                                  vs_outputs->generic[i]);
+            gen_count++;
         }
-        tab[0] = 0;
-    }
-    draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE,
-        draw_find_vs_output(r300->draw, TGSI_SEMANTIC_POSITION, 0));
-    vinfo->hwfmt[1] |= R300_INPUT_CNTL_POS;
-    vinfo->hwfmt[2] |= R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT;
-
-    if (psize) {
-        draw_emit_vertex_attr(vinfo, EMIT_1F_PSIZE, INTERP_POS,
-            draw_find_vs_output(r300->draw, TGSI_SEMANTIC_PSIZE, 0));
-        vinfo->hwfmt[2] |= R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT;
     }
 
-    for (i = 0; i < cols; i++) {
-        draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_LINEAR,
-            draw_find_vs_output(r300->draw, TGSI_SEMANTIC_COLOR, i));
-        vinfo->hwfmt[1] |= R300_INPUT_CNTL_COLOR;
-        vinfo->hwfmt[2] |= (R300_VAP_OUTPUT_VTX_FMT_0__COLOR_0_PRESENT << i);
+    /* Fog coordinates. */
+    if (vs_outputs->fog != ATTR_UNUSED) {
+        r300_draw_emit_attrib(r300, EMIT_4F, INTERP_PERSPECTIVE,
+                              vs_outputs->fog);
+        gen_count++;
     }
 
-    /* Init i right here, increment it if fog is enabled.
-     * This gets around a double-increment problem. */
-    i = 0;
+    /* XXX magic */
+    assert(gen_count <= 8);
+}
 
-    if (fog) {
-        i++;
-        draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE,
-            draw_find_vs_output(r300->draw, TGSI_SEMANTIC_FOG, 0));
-        vinfo->hwfmt[1] |= (R300_INPUT_CNTL_TC0 << i);
-        vinfo->hwfmt[3] |= (4 << (3 * i));
+/* Update the PSC tables. */
+static void r300_vertex_psc(struct r300_context* r300)
+{
+    struct r300_vertex_info *vformat = r300->vertex_info;
+    uint16_t type, swizzle;
+    enum pipe_format format;
+    unsigned i;
+    int identity[16] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    int* stream_tab;
+
+    /* If TCL is bypassed, map vertex streams to equivalent VS output
+     * locations. */
+    if (r300->rs_state->enable_vte) {
+        stream_tab = identity;
+    } else {
+        stream_tab = r300->vs->stream_loc_notcl;
     }
 
-    for (; i < texs; i++) {
-        draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE,
-            draw_find_vs_output(r300->draw, TGSI_SEMANTIC_GENERIC, i));
-        vinfo->hwfmt[1] |= (R300_INPUT_CNTL_TC0 << i);
-        vinfo->hwfmt[3] |= (4 << (3 * i));
-    }
+    /* Vertex shaders have no semantics on their inputs,
+     * so PSC should just route stuff based on the vertex elements,
+     * and not on attrib information. */
+    DBG(r300, DBG_DRAW, "r300: vs expects %d attribs, routing %d elements"
+            " in psc\n",
+            r300->vs->info.num_inputs,
+            r300->vertex_element_count);
 
-    /* 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;
+    for (i = 0; i < r300->vertex_element_count; i++) {
+        format = r300->vertex_element[i].src_format;
+
+        type = r300_translate_vertex_data_type(format) |
+            (stream_tab[i] << R300_DST_VEC_LOC_SHIFT);
+        swizzle = r300_translate_vertex_data_swizzle(format);
+
+        if (i & 1) {
+            vformat->vap_prog_stream_cntl[i >> 1] |= type << 16;
+            vformat->vap_prog_stream_cntl_ext[i >> 1] |= swizzle << 16;
+        } else {
+            vformat->vap_prog_stream_cntl[i >> 1] |= type;
+            vformat->vap_prog_stream_cntl_ext[i >> 1] |= swizzle;
+        }
     }
 
-    draw_compute_vertex_size(vinfo);
+    assert(i <= 15);
+
+    /* Set the last vector in the PSC. */
+    if (i) {
+        i -= 1;
+    }
+    vformat->vap_prog_stream_cntl[i >> 1] |=
+        (R300_LAST_VEC << (i & 1 ? 16 : 0));
 }
 
-/* Update the PSC tables. */
-static void r300_vertex_psc(struct r300_context* r300,
-                            struct r300_vertex_format* vformat)
+/* Update the PSC tables for SW TCL, using Draw. */
+static void r300_swtcl_vertex_psc(struct r300_context* r300)
 {
-    struct r300_screen* r300screen = r300_screen(r300->context.screen);
+    struct r300_vertex_info *vformat = r300->vertex_info;
     struct vertex_info* vinfo = &vformat->vinfo;
-    int* tab = vformat->vs_tab;
-    uint32_t temp;
-    int i, attrib_count;
-
-    /* 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;
-        DBG(r300, DBG_DRAW, "r300: routing %d attribs in psc for vs\n",
-                attrib_count);
-    } else {
-        attrib_count = vinfo->num_attribs;
-        DBG(r300, DBG_DRAW, "r300: attrib count: %d\n", attrib_count);
-        for (i = 0; i < attrib_count; i++) {
-            DBG(r300, DBG_DRAW, "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]);
-        }
+    uint16_t type, swizzle;
+    enum pipe_format format;
+    unsigned i, attrib_count;
+    int* vs_output_tab = r300->vs->stream_loc_notcl;
+
+    /* For each Draw attribute, route it to the fragment shader according
+     * to the vs_output_tab. */
+    attrib_count = vinfo->num_attribs;
+    DBG(r300, DBG_DRAW, "r300: attrib count: %d\n", attrib_count);
+    for (i = 0; i < attrib_count; i++) {
+        DBG(r300, DBG_DRAW, "r300: attrib: offset %d, interp %d, size %d,"
+               " vs_output_tab %d\n", vinfo->attrib[i].src_index,
+               vinfo->attrib[i].interp_mode, vinfo->attrib[i].emit,
+               vs_output_tab[i]);
     }
 
     for (i = 0; i < attrib_count; i++) {
-        /* Make sure we have a proper destination for our attribute */
-        assert(tab[i] != -1);
+        /* Make sure we have a proper destination for our attribute. */
+        assert(vs_output_tab[i] != -1);
 
-        /* Add the attribute to the PSC table. */
-        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;
+        format = draw_translate_vinfo_format(vinfo->attrib[i].emit);
 
-        if (i & 1) {
-            vformat->vap_prog_stream_cntl[i >> 1] &= 0x0000ffff;
-            vformat->vap_prog_stream_cntl[i >> 1] |= temp << 16;
+        /* Obtain the type of data in this attribute. */
+        type = r300_translate_vertex_data_type(format) |
+            vs_output_tab[i] << R300_DST_VEC_LOC_SHIFT;
 
-            vformat->vap_prog_stream_cntl_ext[i >> 1] |=
-                (R300_VAP_SWIZZLE_XYZW << 16);
-        } else {
-            vformat->vap_prog_stream_cntl[i >> 1] &= 0xffff0000;
-            vformat->vap_prog_stream_cntl[i >> 1] |= temp <<  0;
+        /* Obtain the swizzle for this attribute. Note that the default
+         * swizzle in the hardware is not XYZW! */
+        swizzle = r300_translate_vertex_data_swizzle(format);
 
-            vformat->vap_prog_stream_cntl_ext[i >> 1] |=
-                (R300_VAP_SWIZZLE_XYZW <<  0);
+        /* Add the attribute to the PSC table. */
+        if (i & 1) {
+            vformat->vap_prog_stream_cntl[i >> 1] |= type << 16;
+            vformat->vap_prog_stream_cntl_ext[i >> 1] |= swizzle << 16;
+        } else {
+            vformat->vap_prog_stream_cntl[i >> 1] |= type;
+            vformat->vap_prog_stream_cntl_ext[i >> 1] |= swizzle;
         }
     }
 
     /* Set the last vector in the PSC. */
-    i--;
+    if (i) {
+        i -= 1;
+    }
     vformat->vap_prog_stream_cntl[i >> 1] |=
         (R300_LAST_VEC << (i & 1 ? 16 : 0));
 }
 
-/* Update the vertex format. */
-static void r300_update_vertex_format(struct r300_context* r300)
+static void r300_rs_col(struct r300_rs_block* rs, int id, int ptr,
+                        boolean swizzle_0001)
 {
-    struct r300_vertex_format vformat;
-    int i;
-
-    memset(&vformat, 0, sizeof(struct r300_vertex_format));
-    for (i = 0; i < 16; i++) {
-        vformat.vs_tab[i] = -1;
-        vformat.fs_tab[i] = -1;
+    rs->ip[id] |= R300_RS_COL_PTR(ptr);
+    if (swizzle_0001) {
+        rs->ip[id] |= R300_RS_COL_FMT(R300_RS_COL_FMT_0001);
+    } else {
+        rs->ip[id] |= R300_RS_COL_FMT(R300_RS_COL_FMT_RGBA);
     }
+    rs->inst[id] |= R300_RS_INST_COL_ID(id);
+}
 
-    r300_vs_tab_routes(r300, &vformat);
-
-    r300_vertex_psc(r300, &vformat);
+static void r300_rs_col_write(struct r300_rs_block* rs, int id, int fp_offset)
+{
+    rs->inst[id] |= R300_RS_INST_COL_CN_WRITE |
+                    R300_RS_INST_COL_ADDR(fp_offset);
+}
 
-    if (memcmp(&r300->vertex_info, &vformat,
-                sizeof(struct r300_vertex_format))) {
-        memcpy(&r300->vertex_info, &vformat,
-                sizeof(struct r300_vertex_format));
-        r300->dirty_state |= R300_NEW_VERTEX_FORMAT;
+static void r300_rs_tex(struct r300_rs_block* rs, int id, int ptr,
+                        boolean swizzle_X001)
+{
+    if (swizzle_X001) {
+        rs->ip[id] |= R300_RS_TEX_PTR(ptr*4) |
+                      R300_RS_SEL_S(R300_RS_SEL_C0) |
+                      R300_RS_SEL_T(R300_RS_SEL_K0) |
+                      R300_RS_SEL_R(R300_RS_SEL_K0) |
+                      R300_RS_SEL_Q(R300_RS_SEL_K1);
+    } else {
+        rs->ip[id] |= R300_RS_TEX_PTR(ptr*4) |
+                      R300_RS_SEL_S(R300_RS_SEL_C0) |
+                      R300_RS_SEL_T(R300_RS_SEL_C1) |
+                      R300_RS_SEL_R(R300_RS_SEL_C2) |
+                      R300_RS_SEL_Q(R300_RS_SEL_C3);
     }
+    rs->inst[id] |= R300_RS_INST_TEX_ID(id);
 }
 
-/* Set up the mappings from GB to US, for RS block. */
-static void r300_update_fs_tab(struct r300_context* r300)
+static void r300_rs_tex_write(struct r300_rs_block* rs, int id, int fp_offset)
 {
-    struct r300_vertex_format* vformat = &r300->vertex_info;
-    struct tgsi_shader_info* info = &r300->fs->info;
-    int i, cols = 0, texs = 0, cols_emitted = 0;
-    int* tab = vformat->fs_tab;
+    rs->inst[id] |= R300_RS_INST_TEX_CN_WRITE |
+                    R300_RS_INST_TEX_ADDR(fp_offset);
+}
 
-    for (i = 0; i < 16; i++) {
-        tab[i] = -1;
+static void r500_rs_col(struct r300_rs_block* rs, int id, int ptr,
+                        boolean swizzle_0001)
+{
+    rs->ip[id] |= R500_RS_COL_PTR(ptr);
+    if (swizzle_0001) {
+        rs->ip[id] |= R500_RS_COL_FMT(R300_RS_COL_FMT_0001);
+    } else {
+        rs->ip[id] |= R500_RS_COL_FMT(R300_RS_COL_FMT_RGBA);
     }
+    rs->inst[id] |= R500_RS_INST_COL_ID(id);
+}
 
-    assert(info->num_inputs <= 16);
-    for (i = 0; i < info->num_inputs; i++) {
-        switch (info->input_semantic_name[i]) {
-            case TGSI_SEMANTIC_COLOR:
-                tab[i] = INTERP_LINEAR;
-                cols++;
-                break;
-            case TGSI_SEMANTIC_POSITION:
-            case TGSI_SEMANTIC_PSIZE:
-                debug_printf("r300: Implementation error: Can't use "
-                        "pos attribs in fragshader yet!\n");
-                /* Pass through for now */
-            case TGSI_SEMANTIC_FOG:
-            case TGSI_SEMANTIC_GENERIC:
-                tab[i] = INTERP_PERSPECTIVE;
-                break;
-            default:
-                debug_printf("r300: Unknown vertex input %d\n",
-                    info->input_semantic_name[i]);
-                break;
-        }
-    }
+static void r500_rs_col_write(struct r300_rs_block* rs, int id, int fp_offset)
+{
+    rs->inst[id] |= R500_RS_INST_COL_CN_WRITE |
+                    R500_RS_INST_COL_ADDR(fp_offset);
+}
 
-    /* Now that we know where everything is... */
-    DBG(r300, DBG_DRAW, "r300: fp input count: %d\n", info->num_inputs);
-    for (i = 0; i < info->num_inputs; i++) {
-        switch (tab[i]) {
-            case INTERP_LINEAR:
-                DBG(r300, DBG_DRAW, "r300: attrib: "
-                        "stack offset %d, color,    tab %d\n",
-                        i, cols_emitted);
-                tab[i] = cols_emitted;
-                cols_emitted++;
-                break;
-            case INTERP_PERSPECTIVE:
-                DBG(r300, DBG_DRAW, "r300: attrib: "
-                        "stack offset %d, texcoord, tab %d\n",
-                        i, cols + texs);
-                tab[i] = cols + texs;
-                texs++;
-                break;
-            case -1:
-                debug_printf("r300: Implementation error: Bad fp interp!\n");
-            default:
-                break;
-        }
+static void r500_rs_tex(struct r300_rs_block* rs, int id, int ptr,
+                        boolean swizzle_X001)
+{
+    int rs_tex_comp = ptr*4;
+
+    if (swizzle_X001) {
+        rs->ip[id] |= R500_RS_SEL_S(rs_tex_comp) |
+                      R500_RS_SEL_T(R500_RS_IP_PTR_K0) |
+                      R500_RS_SEL_R(R500_RS_IP_PTR_K0) |
+                      R500_RS_SEL_Q(R500_RS_IP_PTR_K1);
+    } else {
+        rs->ip[id] |= R500_RS_SEL_S(rs_tex_comp) |
+                      R500_RS_SEL_T(rs_tex_comp + 1) |
+                      R500_RS_SEL_R(rs_tex_comp + 2) |
+                      R500_RS_SEL_Q(rs_tex_comp + 3);
     }
+    rs->inst[id] |= R500_RS_INST_TEX_ID(id);
+}
 
+static void r500_rs_tex_write(struct r300_rs_block* rs, int id, int fp_offset)
+{
+    rs->inst[id] |= R500_RS_INST_TEX_CN_WRITE |
+                    R500_RS_INST_TEX_ADDR(fp_offset);
 }
 
-/* Set up the RS block. This is the part of the chipset that actually does
- * the rasterization of vertices into fragments. This is also the part of the
- * chipset that locks up if any part of it is even slightly wrong. */
-static void r300_update_rs_block(struct r300_context* r300)
+/* Set up the RS block.
+ *
+ * This is the part of the chipset that actually does the rasterization
+ * of vertices into fragments. This is also the part of the chipset that
+ * locks up if any part of it is even slightly wrong. */
+static void r300_update_rs_block(struct r300_context* r300,
+                                 struct r300_shader_semantics* vs_outputs,
+                                 struct r300_shader_semantics* fs_inputs)
 {
     struct r300_rs_block* rs = r300->rs_block;
-    struct tgsi_shader_info* info = &r300->fs->info;
-    int* tab = r300->vertex_info.fs_tab;
-    int col_count = 0, fp_offset = 0, i, tex_count = 0;
-    int rs_tex_comp = 0;
-    memset(rs, 0, sizeof(struct r300_rs_block));
+    int i, col_count = 0, tex_count = 0, fp_offset = 0;
+    void (*rX00_rs_col)(struct r300_rs_block*, int, int, boolean);
+    void (*rX00_rs_col_write)(struct r300_rs_block*, int, int);
+    void (*rX00_rs_tex)(struct r300_rs_block*, int, int, boolean);
+    void (*rX00_rs_tex_write)(struct r300_rs_block*, int, int);
+    boolean any_bcolor_used = vs_outputs->bcolor[0] != ATTR_UNUSED ||
+                              vs_outputs->bcolor[1] != ATTR_UNUSED;
 
     if (r300_screen(r300->context.screen)->caps->is_r500) {
-        for (i = 0; i < info->num_inputs; i++) {
-            assert(tab[i] != -1);
-            switch (info->input_semantic_name[i]) {
-                case TGSI_SEMANTIC_COLOR:
-                    rs->ip[col_count] |=
-                        R500_RS_COL_PTR(col_count) |
-                        R500_RS_COL_FMT(R300_RS_COL_FMT_RGBA);
-                    col_count++;
-                    break;
-                case TGSI_SEMANTIC_GENERIC:
-                    rs->ip[tex_count] |=
-                        R500_RS_SEL_S(rs_tex_comp) |
-                        R500_RS_SEL_T(rs_tex_comp + 1) |
-                        R500_RS_SEL_R(rs_tex_comp + 2) |
-                        R500_RS_SEL_Q(rs_tex_comp + 3);
-                    tex_count++;
-                    rs_tex_comp += 4;
-                    break;
-                default:
-                    break;
-            }
-        }
+        rX00_rs_col       = r500_rs_col;
+        rX00_rs_col_write = r500_rs_col_write;
+        rX00_rs_tex       = r500_rs_tex;
+        rX00_rs_tex_write = r500_rs_tex_write;
+    } else {
+        rX00_rs_col       = r300_rs_col;
+        rX00_rs_col_write = r300_rs_col_write;
+        rX00_rs_tex       = r300_rs_tex;
+        rX00_rs_tex_write = r300_rs_tex_write;
+    }
 
-        /* Rasterize at least one color, or bad things happen. */
-        if ((col_count == 0) && (tex_count == 0)) {
-            rs->ip[0] |= R500_RS_COL_FMT(R300_RS_COL_FMT_0001);
+    /* Rasterize colors. */
+    for (i = 0; i < ATTR_COLOR_COUNT; i++) {
+        if (vs_outputs->color[i] != ATTR_UNUSED || any_bcolor_used) {
+            /* Always rasterize if it's written by the VS,
+             * otherwise it locks up. */
+            rX00_rs_col(rs, col_count, i, FALSE);
+
+            /* Write it to the FS input register if it's used by the FS. */
+            if (fs_inputs->color[i] != ATTR_UNUSED) {
+                rX00_rs_col_write(rs, col_count, fp_offset);
+                fp_offset++;
+            }
             col_count++;
+        } else {
+            /* Skip the FS input register, leave it uninitialized. */
+            /* If we try to set it to (0,0,0,1), it will lock up. */
+            if (fs_inputs->color[i] != ATTR_UNUSED) {
+                fp_offset++;
+            }
         }
+    }
 
-        for (i = 0; i < tex_count; i++) {
-            rs->inst[i] |= R500_RS_INST_TEX_ID(i) |
-                R500_RS_INST_TEX_CN_WRITE | R500_RS_INST_TEX_ADDR(fp_offset);
-            fp_offset++;
+    /* Rasterize texture coordinates. */
+    for (i = 0; i < ATTR_GENERIC_COUNT; i++) {
+        if (vs_outputs->generic[i] != ATTR_UNUSED) {
+            /* Always rasterize if it's written by the VS,
+             * otherwise it locks up. */
+            rX00_rs_tex(rs, tex_count, tex_count, FALSE);
+
+            /* Write it to the FS input register if it's used by the FS. */
+            if (fs_inputs->generic[i] != ATTR_UNUSED) {
+                rX00_rs_tex_write(rs, tex_count, fp_offset);
+                fp_offset++;
+            }
+            tex_count++;
+        } else {
+            /* Skip the FS input register, leave it uninitialized. */
+            /* If we try to set it to (0,0,0,1), it will lock up. */
+            if (fs_inputs->generic[i] != ATTR_UNUSED) {
+                fp_offset++;
+            }
         }
+    }
 
-        for (i = 0; i < col_count; i++) {
-            rs->inst[i] |= R500_RS_INST_COL_ID(i) |
-                R500_RS_INST_COL_CN_WRITE | R500_RS_INST_COL_ADDR(fp_offset);
+    /* Rasterize fog coordinates. */
+    if (vs_outputs->fog != ATTR_UNUSED) {
+        /* Always rasterize if it's written by the VS,
+         * otherwise it locks up. */
+        rX00_rs_tex(rs, tex_count, tex_count, TRUE);
+
+        /* Write it to the FS input register if it's used by the FS. */
+        if (fs_inputs->fog != ATTR_UNUSED) {
+            rX00_rs_tex_write(rs, tex_count, fp_offset);
             fp_offset++;
         }
+        tex_count++;
     } else {
-        for (i = 0; i < info->num_inputs; i++) {
-            assert(tab[i] != -1);
-            switch (info->input_semantic_name[i]) {
-                case TGSI_SEMANTIC_COLOR:
-                    rs->ip[col_count] |=
-                        R300_RS_COL_PTR(col_count) |
-                        R300_RS_COL_FMT(R300_RS_COL_FMT_RGBA);
-                    col_count++;
-                    break;
-                case TGSI_SEMANTIC_GENERIC:
-                    rs->ip[tex_count] |=
-                        R300_RS_TEX_PTR(rs_tex_comp) |
-                        R300_RS_SEL_S(R300_RS_SEL_C0) |
-                        R300_RS_SEL_T(R300_RS_SEL_C1) |
-                        R300_RS_SEL_R(R300_RS_SEL_C2) |
-                        R300_RS_SEL_Q(R300_RS_SEL_C3);
-                    tex_count++;
-                    rs_tex_comp+=4;
-                    break;
-                default:
-                    break;
-            }
+        /* Skip the FS input register, leave it uninitialized. */
+        /* If we try to set it to (0,0,0,1), it will lock up. */
+        if (fs_inputs->fog != ATTR_UNUSED) {
+            fp_offset++;
         }
+    }
 
-        if (col_count == 0) {
-            rs->ip[0] |= R300_RS_COL_FMT(R300_RS_COL_FMT_0001);
-        }
+    /* Rasterize WPOS. */
+    /* If the FS doesn't need it, it's not written by the VS. */
+    if (fs_inputs->wpos != ATTR_UNUSED) {
+        rX00_rs_tex(rs, tex_count, tex_count, FALSE);
+        rX00_rs_tex_write(rs, tex_count, fp_offset);
 
-        if (tex_count == 0) {
-            rs->ip[0] |=
-                R300_RS_SEL_S(R300_RS_SEL_K0) |
-                R300_RS_SEL_T(R300_RS_SEL_K0) |
-                R300_RS_SEL_R(R300_RS_SEL_K0) |
-                R300_RS_SEL_Q(R300_RS_SEL_K1);
-        }
+        fp_offset++;
+        tex_count++;
+    }
 
-        /* Rasterize at least one color, or bad things happen. */
-        if ((col_count == 0) && (tex_count == 0)) {
-            col_count++;
-        }
+    /* Rasterize at least one color, or bad things happen. */
+    if (col_count == 0 && tex_count == 0) {
+        rX00_rs_col(rs, 0, 0, TRUE);
+        col_count++;
+    }
 
-        for (i = 0; i < tex_count; i++) {
-            rs->inst[i] |= R300_RS_INST_TEX_ID(i) |
-                R300_RS_INST_TEX_CN_WRITE | R300_RS_INST_TEX_ADDR(fp_offset);
-            fp_offset++;
-        }
+    rs->count = (tex_count*4) | (col_count << R300_IC_COUNT_SHIFT) |
+        R300_HIRES_EN;
 
-        for (i = 0; i < col_count; i++) {
-            rs->inst[i] |= R300_RS_INST_COL_ID(i) |
-                R300_RS_INST_COL_CN_WRITE | R300_RS_INST_COL_ADDR(fp_offset);
-            fp_offset++;
-        }
+    rs->inst_count = MAX3(col_count - 1, tex_count - 1, 0);
+}
+
+/* Update the vertex format. */
+static void r300_update_derived_shader_state(struct r300_context* r300)
+{
+    struct r300_screen* r300screen = r300_screen(r300->context.screen);
+
+    /*
+    struct r300_shader_key* key;
+    struct r300_shader_derived_value* value;
+    key = CALLOC_STRUCT(r300_shader_key);
+    key->vs = r300->vs;
+    key->fs = r300->fs;
+
+    value = (struct r300_shader_derived_value*)
+        util_hash_table_get(r300->shader_hash_table, (void*)key);
+    if (value) {
+        //vformat = value->vformat;
+        rs_block = value->rs_block;
+
+        FREE(key);
+    } else {
+        rs_block = CALLOC_STRUCT(r300_rs_block);
+        value = CALLOC_STRUCT(r300_shader_derived_value);
+
+        r300_update_rs_block(r300, rs_block);
+
+        //value->vformat = vformat;
+        value->rs_block = rs_block;
+        util_hash_table_set(r300->shader_hash_table,
+            (void*)key, (void*)value);
+    } */
+
+    /* Reset structures */
+    memset(r300->rs_block, 0, sizeof(struct r300_rs_block));
+    memset(r300->vertex_info, 0, sizeof(struct r300_vertex_info));
+    memcpy(r300->vertex_info->vinfo.hwfmt, r300->vs->hwfmt, sizeof(uint)*4);
+
+    r300_update_rs_block(r300, &r300->vs->outputs, &r300->fs->inputs);
+
+    if (r300screen->caps->has_tcl) {
+        r300_vertex_psc(r300);
+    } else {
+        r300_draw_emit_all_attribs(r300);
+        draw_compute_vertex_size(&r300->vertex_info->vinfo);
+        r300_swtcl_vertex_psc(r300);
     }
 
-    rs->count = (rs_tex_comp) | (col_count << R300_IC_COUNT_SHIFT) |
-        R300_HIRES_EN;
+    r300->dirty_state |= R300_NEW_RS_BLOCK;
+}
+
+static boolean r300_dsa_writes_depth_stencil(struct r300_dsa_state* dsa)
+{
+    /* We are interested only in the cases when a new depth or stencil value
+     * can be written and changed. */
+
+    /* We might optionally check for [Z func: never] and inspect the stencil
+     * state in a similar fashion, but it's not terribly important. */
+    return (dsa->z_buffer_control & R300_Z_WRITE_ENABLE) ||
+           (dsa->stencil_ref_mask & R300_STENCILWRITEMASK_MASK) ||
+           ((dsa->z_buffer_control & R500_STENCIL_REFMASK_FRONT_BACK) &&
+            (dsa->stencil_ref_bf & R300_STENCILWRITEMASK_MASK));
+}
+
+static boolean r300_dsa_alpha_test_enabled(struct r300_dsa_state* dsa)
+{
+    /* We are interested only in the cases when alpha testing can kill
+     * a fragment. */
+    uint32_t af = dsa->alpha_function;
+
+    return (af & R300_FG_ALPHA_FUNC_ENABLE) &&
+           (af & R300_FG_ALPHA_FUNC_ALWAYS) != R300_FG_ALPHA_FUNC_ALWAYS;
+}
 
-    rs->inst_count = MAX2(MAX2(col_count - 1, tex_count - 1), 0);
+static void r300_update_ztop(struct r300_context* r300)
+{
+    r300->ztop_state.z_buffer_top = R300_ZTOP_ENABLE;
+
+    /* This is important enough that I felt it warranted a comment.
+     *
+     * According to the docs, these are the conditions where ZTOP must be
+     * disabled:
+     * 1) Alpha testing enabled
+     * 2) Texture kill instructions in fragment shader
+     * 3) Chroma key culling enabled
+     * 4) W-buffering enabled
+     *
+     * The docs claim that for the first three cases, if no ZS writes happen,
+     * then ZTOP can be used.
+     *
+     * (3) will never apply since we do not support chroma-keyed operations.
+     * (4) will need to be re-examined (and this comment updated) if/when
+     * Hyper-Z becomes supported.
+     *
+     * Additionally, the following conditions require disabled ZTOP:
+     * 5) Depth writes in fragment shader
+     * 6) Outstanding occlusion queries
+     *
+     * ~C.
+     */
+
+    /* ZS writes */
+    if (r300_dsa_writes_depth_stencil(r300->dsa_state) &&
+           (r300_dsa_alpha_test_enabled(r300->dsa_state) ||   /* (1) */
+            r300->fs->info.uses_kill)) {                      /* (2) */
+        r300->ztop_state.z_buffer_top = R300_ZTOP_DISABLE;
+    } else if (r300_fragment_shader_writes_depth(r300->fs)) { /* (5) */
+        r300->ztop_state.z_buffer_top = R300_ZTOP_DISABLE;
+    } else if (r300->query_current) {                         /* (6) */
+        r300->ztop_state.z_buffer_top = R300_ZTOP_DISABLE;
+    }
 }
 
 void r300_update_derived_state(struct r300_context* r300)
 {
     if (r300->dirty_state &
-            (R300_NEW_FRAGMENT_SHADER | R300_NEW_VERTEX_SHADER)) {
-        r300_update_vertex_format(r300);
+        (R300_NEW_FRAGMENT_SHADER | R300_NEW_VERTEX_SHADER |
+         R300_NEW_VERTEX_FORMAT)) {
+        r300_update_derived_shader_state(r300);
     }
 
-    if (r300->dirty_state & R300_NEW_VERTEX_FORMAT) {
-        r300_update_fs_tab(r300);
-        r300_update_rs_block(r300);
+    if (r300->dirty_state &
+            (R300_NEW_DSA | R300_NEW_FRAGMENT_SHADER | R300_NEW_QUERY)) {
+        r300_update_ztop(r300);
     }
 }
index 71a4a47b003662bd7aa567fdf32c4751a0765262..05ad535e2de18487f00bbfcb298948a71ab2cf6f 100644 (file)
 
 struct r300_context;
 
+unsigned r300_shader_key_hash(void* key);
+
+int r300_shader_key_compare(void* key1, void* key2);
+
 void r300_update_derived_state(struct r300_context* r300);
 
 #endif /* R300_STATE_DERIVED_H */
index 88eb66b79e768c314e903bc1aabda3f7411f86e7..35be00e1b01ae9788f692372889be0ea50258cdb 100644 (file)
 #ifndef R300_STATE_INLINES_H
 #define R300_STATE_INLINES_H
 
+#include "draw/draw_vertex.h"
+
 #include "pipe/p_format.h"
 
+#include "util/u_format.h"
+
 #include "r300_reg.h"
 
 /* Some maths. These should probably find their way to u_math, if needed. */
@@ -51,6 +55,7 @@ static INLINE uint32_t r300_translate_blend_function(int blend_func)
             return R300_COMB_FCN_MAX;
         default:
             debug_printf("r300: Unknown blend function %d\n", blend_func);
+            assert(0);
             break;
     }
     return 0;
@@ -98,6 +103,7 @@ static INLINE uint32_t r300_translate_blend_factor(int blend_fact)
         case PIPE_BLENDFACTOR_INV_SRC1_ALPHA: */
         default:
             debug_printf("r300: Unknown blend factor %d\n", blend_fact);
+            assert(0);
             break;
     }
     return 0;
@@ -127,6 +133,7 @@ static INLINE uint32_t r300_translate_depth_stencil_function(int zs_func)
         default:
             debug_printf("r300: Unknown depth/stencil function %d\n",
                 zs_func);
+            assert(0);
             break;
     }
     return 0;
@@ -153,6 +160,7 @@ static INLINE uint32_t r300_translate_stencil_op(int s_op)
             return R300_ZS_INVERT;
         default:
             debug_printf("r300: Unknown stencil op %d", s_op);
+            assert(0);
             break;
     }
     return 0;
@@ -179,11 +187,48 @@ static INLINE uint32_t r300_translate_alpha_function(int alpha_func)
             return R300_FG_ALPHA_FUNC_ALWAYS;
         default:
             debug_printf("r300: Unknown alpha function %d", alpha_func);
+            assert(0);
             break;
     }
     return 0;
 }
 
+static INLINE uint32_t
+r300_translate_polygon_mode_front(unsigned mode) {
+    switch (mode)
+    {
+        case PIPE_POLYGON_MODE_FILL:
+            return R300_GA_POLY_MODE_FRONT_PTYPE_TRI;
+        case PIPE_POLYGON_MODE_LINE:
+            return R300_GA_POLY_MODE_FRONT_PTYPE_LINE;
+        case PIPE_POLYGON_MODE_POINT:
+            return R300_GA_POLY_MODE_FRONT_PTYPE_POINT;
+
+        default:
+            debug_printf("r300: Bad polygon mode %i in %s\n", mode,
+                __FUNCTION__);
+            return R300_GA_POLY_MODE_FRONT_PTYPE_TRI;
+    }
+}
+
+static INLINE uint32_t
+r300_translate_polygon_mode_back(unsigned mode) {
+    switch (mode)
+    {
+        case PIPE_POLYGON_MODE_FILL:
+            return R300_GA_POLY_MODE_BACK_PTYPE_TRI;
+        case PIPE_POLYGON_MODE_LINE:
+            return R300_GA_POLY_MODE_BACK_PTYPE_LINE;
+        case PIPE_POLYGON_MODE_POINT:
+            return R300_GA_POLY_MODE_BACK_PTYPE_POINT;
+
+        default:
+            debug_printf("r300: Bad polygon mode %i in %s\n", mode,
+                __FUNCTION__);
+            return R300_GA_POLY_MODE_BACK_PTYPE_TRI;
+    }
+}
+
 /* Texture sampler state. */
 
 static INLINE uint32_t r300_translate_wrap(int wrap)
@@ -207,40 +252,42 @@ static INLINE uint32_t r300_translate_wrap(int wrap)
             return R300_TX_CLAMP_TO_EDGE | R300_TX_MIRRORED;
         default:
             debug_printf("r300: Unknown texture wrap %d", wrap);
+            assert(0);
             return 0;
     }
 }
 
-static INLINE uint32_t r300_translate_tex_filters(int min, int mag, int mip)
+static INLINE uint32_t r300_translate_tex_filters(int min, int mag, int mip,
+                                                  int is_anisotropic)
 {
     uint32_t retval = 0;
-    switch (min) {
+    if (is_anisotropic)
+        retval |= R300_TX_MIN_FILTER_ANISO | R300_TX_MAG_FILTER_ANISO;
+    else {
+        switch (min) {
         case PIPE_TEX_FILTER_NEAREST:
             retval |= R300_TX_MIN_FILTER_NEAREST;
             break;
         case PIPE_TEX_FILTER_LINEAR:
             retval |= R300_TX_MIN_FILTER_LINEAR;
             break;
-        case PIPE_TEX_FILTER_ANISO:
-            retval |= R300_TX_MIN_FILTER_ANISO;
-            break;
         default:
             debug_printf("r300: Unknown texture filter %d\n", min);
+            assert(0);
             break;
-    }
-    switch (mag) {
+        }
+        switch (mag) {
         case PIPE_TEX_FILTER_NEAREST:
             retval |= R300_TX_MAG_FILTER_NEAREST;
             break;
         case PIPE_TEX_FILTER_LINEAR:
             retval |= R300_TX_MAG_FILTER_LINEAR;
             break;
-        case PIPE_TEX_FILTER_ANISO:
-            retval |= R300_TX_MAG_FILTER_ANISO;
-            break;
         default:
             debug_printf("r300: Unknown texture filter %d\n", mag);
+            assert(0);
             break;
+        }
     }
     switch (mip) {
         case PIPE_TEX_MIPFILTER_NONE:
@@ -254,6 +301,7 @@ static INLINE uint32_t r300_translate_tex_filters(int min, int mag, int mip)
             break;
         default:
             debug_printf("r300: Unknown texture filter %d\n", mip);
+            assert(0);
             break;
     }
 
@@ -277,6 +325,8 @@ static INLINE uint32_t r300_anisotropy(float max_aniso)
 
 /* Buffer formats. */
 
+/* Colorbuffer formats. This is the unswizzled format of the RB3D block's
+ * output. For the swizzling of the targets, check the shader's format. */
 static INLINE uint32_t r300_translate_colorformat(enum pipe_format format)
 {
     switch (format) {
@@ -295,7 +345,6 @@ static INLINE uint32_t r300_translate_colorformat(enum pipe_format format)
         case PIPE_FORMAT_X8R8G8B8_UNORM:
         case PIPE_FORMAT_R8G8B8A8_UNORM:
         case PIPE_FORMAT_R8G8B8X8_UNORM:
-        case PIPE_FORMAT_Z24S8_UNORM:
             return R300_COLOR_FORMAT_ARGB8888;
         /* XXX Not in pipe_format
         case PIPE_FORMAT_A32R32G32B32:
@@ -312,17 +361,21 @@ static INLINE uint32_t r300_translate_colorformat(enum pipe_format format)
             debug_printf("r300: Implementation error: "
                 "Got unsupported color format %s in %s\n",
                 pf_name(format), __FUNCTION__);
+            assert(0);
             break;
     }
     return 0;
 }
 
+/* Depthbuffer and stencilbuffer. Thankfully, we only support two flavors. */
 static INLINE uint32_t r300_translate_zsformat(enum pipe_format format)
 {
     switch (format) {
         /* 16-bit depth, no stencil */
         case PIPE_FORMAT_Z16_UNORM:
             return R300_DEPTHFORMAT_16BIT_INT_Z;
+        /* 24-bit depth, ignored stencil */
+        case PIPE_FORMAT_Z24X8_UNORM:
         /* 24-bit depth, 8-bit stencil */
         case PIPE_FORMAT_Z24S8_UNORM:
             return R300_DEPTHFORMAT_24BIT_INT_Z_8BIT_STENCIL;
@@ -330,18 +383,22 @@ static INLINE uint32_t r300_translate_zsformat(enum pipe_format format)
             debug_printf("r300: Implementation error: "
                 "Got unsupported ZS format %s in %s\n",
                 pf_name(format), __FUNCTION__);
+            assert(0);
             break;
     }
     return 0;
 }
 
-/* Translate pipe_format into US_OUT_FMT.
+/* Shader output formats. This is essentially the swizzle from the shader
+ * to the RB3D block.
+ *
  * Note that formats are stored from C3 to C0. */
 static INLINE uint32_t r300_translate_out_fmt(enum pipe_format format)
 {
     switch (format) {
         case PIPE_FORMAT_A8R8G8B8_UNORM:
         case PIPE_FORMAT_X8R8G8B8_UNORM:
+        /* XXX */
         case PIPE_FORMAT_Z24S8_UNORM:
             return R300_US_OUT_FMT_C4_8 |
                 R300_C0_SEL_B | R300_C1_SEL_G |
@@ -355,6 +412,7 @@ static INLINE uint32_t r300_translate_out_fmt(enum pipe_format format)
             debug_printf("r300: Implementation error: "
                 "Got unsupported output format %s in %s\n",
                 pf_name(format), __FUNCTION__);
+            assert(0);
             return R300_US_OUT_FMT_UNUSED;
     }
     return 0;
@@ -381,32 +439,119 @@ static INLINE uint32_t r300_translate_gb_pipes(int pipe_count)
     return 0;
 }
 
-static INLINE uint32_t translate_vertex_data_type(int type) {
-    switch (type) {
-        case EMIT_1F:
-        case EMIT_1F_PSIZE:
-            return R300_DATA_TYPE_FLOAT_1;
-            break;
-        case EMIT_2F:
-            return R300_DATA_TYPE_FLOAT_2;
-            break;
-        case EMIT_3F:
-            return R300_DATA_TYPE_FLOAT_3;
-            break;
-        case EMIT_4F:
-            return R300_DATA_TYPE_FLOAT_4;
+/* Utility function to count the number of components in RGBAZS formats.
+ * XXX should go to util or p_format.h */
+static INLINE unsigned pf_component_count(enum pipe_format format) {
+    unsigned count = 0;
+
+    if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0)) {
+        count++;
+    }
+    if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 1)) {
+        count++;
+    }
+    if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 2)) {
+        count++;
+    }
+    if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 3)) {
+        count++;
+    }
+    if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 0)) {
+        count++;
+    }
+    if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 1)) {
+        count++;
+    }
+
+    return count;
+}
+
+/* Translate pipe_formats into PSC vertex types. */
+static INLINE uint16_t
+r300_translate_vertex_data_type(enum pipe_format format) {
+    uint32_t result = 0;
+    const struct util_format_description *desc;
+    unsigned components = pf_component_count(format);
+
+    desc = util_format_description(format);
+
+    if (desc->layout != UTIL_FORMAT_LAYOUT_ARITH &&
+        desc->layout != UTIL_FORMAT_LAYOUT_ARRAY) {
+        debug_printf("r300: Bad format %s in %s:%d\n", pf_name(format),
+            __FUNCTION__, __LINE__);
+        assert(0);
+    }
+
+    switch (desc->channel[0].type) {
+        /* Half-floats, floats, doubles */
+        case UTIL_FORMAT_TYPE_FLOAT:
+            switch (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0)) {
+                case 32:
+                    result = R300_DATA_TYPE_FLOAT_1 + (components - 1);
+                    break;
+                default:
+                    debug_printf("r300: Bad format %s in %s:%d\n",
+                        pf_name(format), __FUNCTION__, __LINE__);
+                    assert(0);
+            }
             break;
-        case EMIT_4UB:
-            return R300_DATA_TYPE_BYTE;
+        /* Unsigned ints */
+        case UTIL_FORMAT_TYPE_UNSIGNED:
+        /* Signed ints */
+        case UTIL_FORMAT_TYPE_SIGNED:
+            switch (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0)) {
+                case 8:
+                    result = R300_DATA_TYPE_BYTE;
+                    break;
+                case 16:
+                    if (components > 2) {
+                        result = R300_DATA_TYPE_SHORT_4;
+                    } else {
+                        result = R300_DATA_TYPE_SHORT_2;
+                    }
+                    break;
+                default:
+                    debug_printf("r300: Bad format %s in %s:%d\n",
+                        pf_name(format), __FUNCTION__, __LINE__);
+                    debug_printf("r300: util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0) == %d\n",
+                        util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0));
+                    assert(0);
+            }
             break;
         default:
-            debug_printf("r300: Implementation error: "
-                    "Bad vertex data type!\n");
+            debug_printf("r300: Bad format %s in %s:%d\n",
+                pf_name(format), __FUNCTION__, __LINE__);
             assert(0);
-            break;
     }
 
-    return 0;
+    if (desc->channel[0].type == UTIL_FORMAT_TYPE_SIGNED) {
+        result |= R300_SIGNED;
+    }
+    if (desc->channel[0].normalized) {
+        result |= R300_NORMALIZE;
+    }
+
+    return result;
+}
+
+static INLINE uint16_t
+r300_translate_vertex_data_swizzle(enum pipe_format format) {
+    const struct util_format_description *desc = util_format_description(format);
+
+    assert(format);
+
+    if (desc->layout != UTIL_FORMAT_LAYOUT_ARITH &&
+        desc->layout != UTIL_FORMAT_LAYOUT_ARRAY) {
+        debug_printf("r300: Bad format %s in %s:%d\n",
+            pf_name(format), __FUNCTION__, __LINE__);
+        return 0;
+    }
+
+    return ((desc->swizzle[0] << R300_SWIZZLE_SELECT_X_SHIFT) |
+        (desc->swizzle[1] << R300_SWIZZLE_SELECT_Y_SHIFT) |
+        (desc->swizzle[2] << R300_SWIZZLE_SELECT_Z_SHIFT) |
+        (desc->swizzle[3] << R300_SWIZZLE_SELECT_W_SHIFT) |
+        (0xf << R300_WRITE_ENA_SHIFT));
 }
 
 #endif /* R300_STATE_INLINES_H */
index 3865730d635cfef71354eb38f609f5428ffa6ed9..f25f3ca217d73e4d9f0d6f2c72fd8e6d3181f47a 100644 (file)
  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  * USE OR OTHER DEALINGS IN THE SOFTWARE. */
 
+#include "r300_context.h"
+#include "r300_cs.h"
+#include "r300_reg.h"
+#include "r300_screen.h"
 #include "r300_state_invariant.h"
 
-
 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},
@@ -40,7 +43,7 @@ void r300_emit_invariant_state(struct r300_context* r300)
     struct r300_capabilities* caps = r300_screen(r300->context.screen)->caps;
     CS_LOCALS(r300);
 
-    BEGIN_CS(24 + (caps->has_tcl ? 2: 0));
+    BEGIN_CS(16 + (caps->has_tcl ? 2: 0));
 
     /*** Graphics Backend (GB) ***/
     /* Various GB enables */
@@ -63,13 +66,8 @@ void r300_emit_invariant_state(struct r300_context* r300)
     OUT_CS_REG(R300_FG_FOG_COLOR_R, 0x0);
     OUT_CS_REG(R300_FG_FOG_COLOR_G, 0x0);
     OUT_CS_REG(R300_FG_FOG_COLOR_B, 0x0);
-    OUT_CS_REG(R300_FG_DEPTH_SRC, 0x0);
-    OUT_CS_REG(R300_US_W_FMT, 0x0);
 
     /*** VAP ***/
-    /* Max and min vertex index clamp. */
-    OUT_CS_REG(R300_VAP_VF_MIN_VTX_INDX, 0x0);
-    OUT_CS_REG(R300_VAP_VF_MAX_VTX_INDX, 0xffffff);
     /* Sign/normalize control */
     OUT_CS_REG(R300_VAP_PSC_SGN_NORM_CNTL, R300_SGN_NORM_NO_ZERO);
     /* TCL-only stuff */
@@ -81,15 +79,11 @@ void r300_emit_invariant_state(struct r300_context* r300)
     END_CS;
 
     /* XXX unsorted stuff from surface_fill */
-    BEGIN_CS(64 + (caps->has_tcl ? 5 : 0) + (caps->is_r500 ? 4 : 0));
-    /* Flush PVS. */
-    OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0x0);
+    BEGIN_CS(44 + (caps->has_tcl ? 7 : 0) + (caps->is_r500 ? 4 : 0));
 
-    OUT_CS_REG(R300_SE_VTE_CNTL, R300_VPORT_X_SCALE_ENA |
-        R300_VPORT_X_OFFSET_ENA | R300_VPORT_Y_SCALE_ENA |
-        R300_VPORT_Y_OFFSET_ENA | R300_VPORT_Z_SCALE_ENA |
-        R300_VPORT_Z_OFFSET_ENA | R300_VTX_W0_FMT);
     if (caps->has_tcl) {
+        /*Flushing PVS is required before the VAP_GB registers can be changed*/
+        OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0);
         OUT_CS_REG_SEQ(R300_VAP_GB_VERT_CLIP_ADJ, 4);
         OUT_CS_32F(1.0);
         OUT_CS_32F(1.0);
@@ -111,7 +105,6 @@ void r300_emit_invariant_state(struct r300_context* r300)
     /* XXX this big chunk should be refactored into rs_state */
     OUT_CS_REG(R300_GA_SOLID_RG, 0x00000000);
     OUT_CS_REG(R300_GA_SOLID_BA, 0x00000000);
-    OUT_CS_REG(R300_GA_POLY_MODE, 0x00000000);
     OUT_CS_REG(R300_GA_ROUND_MODE, 0x00000001);
     OUT_CS_REG(R300_GA_OFFSET, 0x00000000);
     OUT_CS_REG(R300_GA_FOG_SCALE, 0x3DBF1412);
@@ -121,22 +114,15 @@ void r300_emit_invariant_state(struct r300_context* r300)
     OUT_CS_REG(R300_SU_DEPTH_OFFSET, 0x00000000);
     OUT_CS_REG(R300_SC_HYPERZ, 0x0000001C);
     OUT_CS_REG(R300_SC_EDGERULE, 0x2DA49525);
-    OUT_CS_REG(R300_RB3D_CCTL, 0x00000000);
-    OUT_CS_REG(RB3D_COLOR_CHANNEL_MASK, 0x0000000F);
     OUT_CS_REG(R300_RB3D_AARESOLVE_CTL, 0x00000000);
     if (caps->is_r500) {
-        OUT_CS_REG(R500_RB3D_DISCARD_SRC_PIXEL_LTE_THRESHOLD, 0x00000000);
-        OUT_CS_REG(R500_RB3D_DISCARD_SRC_PIXEL_GTE_THRESHOLD, 0xFFFFFFFF);
+        OUT_CS_REG(R500_RB3D_DISCARD_SRC_PIXEL_LTE_THRESHOLD, 0x01010101);
+        OUT_CS_REG(R500_RB3D_DISCARD_SRC_PIXEL_GTE_THRESHOLD, 0xFEFEFEFE);
     }
-    OUT_CS_REG(R300_ZB_FORMAT, 0x00000002);
-    OUT_CS_REG(R300_ZB_ZCACHE_CTLSTAT, 0x00000003);
     OUT_CS_REG(R300_ZB_BW_CNTL, 0x00000000);
     OUT_CS_REG(R300_ZB_DEPTHCLEARVALUE, 0x00000000);
     OUT_CS_REG(R300_ZB_HIZ_OFFSET, 0x00000000);
     OUT_CS_REG(R300_ZB_HIZ_PITCH, 0x00000000);
-    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);
 
     /* XXX */
     OUT_CS_REG(R300_SC_CLIP_RULE, 0xaaaa);
index 5bea6779fe5b879b33d1cd09d87de2554d809d86..05cff0d6dfeb4254d10cc34acaf47b02c90c086e 100644 (file)
 #ifndef R300_STATE_INVARIANT_H
 #define R300_STATE_INVARIANT_H
 
-#include "r300_chipset.h"
-#include "r300_context.h"
-#include "r300_cs.h"
-#include "r300_reg.h"
-#include "r300_state_inlines.h"
+struct r300_context;
 
 void r300_emit_invariant_state(struct r300_context* r300);
 
diff --git a/src/gallium/drivers/r300/r300_surface.c b/src/gallium/drivers/r300/r300_surface.c
deleted file mode 100644 (file)
index cc6288c..0000000
+++ /dev/null
@@ -1,372 +0,0 @@
-/*
- * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
- *                Joakim Sindholt <opensource@zhasha.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. */
-
-#include "r300_surface.h"
-
-static void r300_surface_setup(struct r300_context* r300,
-                               struct r300_texture* dest,
-                               unsigned x, unsigned y,
-                               unsigned w, unsigned h)
-{
-    struct r300_capabilities* caps = r300_screen(r300->context.screen)->caps;
-    unsigned pixpitch = r300_texture_get_stride(dest, 0) / dest->tex.block.size;
-    CS_LOCALS(r300);
-
-    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(26);
-
-    /* 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);
-    if (caps->is_r500) {
-        OUT_CS((x << R300_SCISSORS_X_SHIFT) | (y << R300_SCISSORS_Y_SHIFT));
-        OUT_CS(((w - 1) << R300_SCISSORS_X_SHIFT) | ((h - 1) << R300_SCISSORS_Y_SHIFT));
-    } else {
-        /* Non-R500 chipsets have an offset of 1440 in their scissors. */
-        OUT_CS(((x + 1440) << R300_SCISSORS_X_SHIFT) |
-                ((y + 1440) << R300_SCISSORS_Y_SHIFT));
-        OUT_CS((((w - 1) + 1440) << R300_SCISSORS_X_SHIFT) |
-                (((h - 1) + 1440) << R300_SCISSORS_Y_SHIFT));
-    }
-
-    /* Flush colorbuffer and blend caches. */
-    OUT_CS_REG(R300_RB3D_DSTCACHE_CTLSTAT,
-        R300_RB3D_DSTCACHE_CTLSTAT_DC_FLUSH_FLUSH_DIRTY_3D |
-        R300_RB3D_DSTCACHE_CTLSTAT_DC_FINISH_SIGNAL);
-    OUT_CS_REG(R300_ZB_ZCACHE_CTLSTAT,
-        R300_ZB_ZCACHE_CTLSTAT_ZC_FLUSH_FLUSH_AND_FREE |
-        R300_ZB_ZCACHE_CTLSTAT_ZC_FREE_FREE);
-
-    /* Setup colorbuffer. */
-    OUT_CS_REG_SEQ(R300_RB3D_COLOROFFSET0, 1);
-    OUT_CS_RELOC(dest->buffer, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0);
-    OUT_CS_REG_SEQ(R300_RB3D_COLORPITCH0, 1);
-    OUT_CS_RELOC(dest->buffer, pixpitch |
-                 r300_translate_colorformat(dest->tex.format), 0,
-                 RADEON_GEM_DOMAIN_VRAM, 0);
-    OUT_CS_REG(RB3D_COLOR_CHANNEL_MASK, 0xf);
-
-    END_CS;
-}
-
-/* Provides pipe_context's "surface_fill". Commonly used for clearing
- * buffers. */
-static void r300_surface_fill(struct pipe_context* pipe,
-                              struct pipe_surface* dest,
-                              unsigned x, unsigned y,
-                              unsigned w, unsigned h,
-                              unsigned color)
-{
-    int i;
-    float r, g, b, a, depth;
-    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 = r300_texture_get_stride(tex, 0) / tex->tex.block.size;
-    boolean invalid = FALSE;
-    CS_LOCALS(r300);
-
-    a = (float)((color >> 24) & 0xff) / 255.0f;
-    r = (float)((color >> 16) & 0xff) / 255.0f;
-    g = (float)((color >>  8) & 0xff) / 255.0f;
-    b = (float)((color >>  0) & 0xff) / 255.0f;
-    debug_printf("r300: Filling surface %p at (%d,%d),"
-        " dimensions %dx%d (pixel pitch %d), color 0x%x\n",
-        dest, x, y, w, h, pixpitch, color);
-
-    /* Fallback? */
-    if (FALSE) {
-fallback:
-        debug_printf("r300: Falling back on surface clear...");
-        util_surface_fill(pipe, dest, x, y, w, h, color);
-        return;
-    }
-
-    /* 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) {
-            debug_printf("r300: Stuck in validation loop, gonna fallback.");
-            goto fallback;
-        }
-        invalid = TRUE;
-        goto validate;
-    }
-
-    r300_surface_setup(r300, tex, x, y, w, h);
-
-    /* Vertex shader setup */
-    if (caps->has_tcl) {
-        r300_emit_vertex_program_code(r300, &r300_passthrough_vertex_shader, 0);
-    } else {
-        BEGIN_CS(4);
-        OUT_CS_REG(R300_VAP_CNTL_STATUS,
-#ifdef PIPE_ARCH_BIG_ENDIAN
-                   R300_VC_32BIT_SWAP |
-#endif
-                   R300_VAP_TCL_BYPASS);
-        OUT_CS_REG(R300_VAP_CNTL, R300_PVS_NUM_SLOTS(5) |
-                R300_PVS_NUM_CNTLRS(5) |
-                R300_PVS_NUM_FPUS(caps->num_vert_fpus) |
-                R300_PVS_VF_MAX_VTX_NUM(12));
-        END_CS;
-    }
-
-    /* Fragment shader setup */
-    if (caps->is_r500) {
-        r500_emit_fragment_program_code(r300, &r5xx_passthrough_fragment_shader, 0);
-        r300_emit_rs_block_state(r300, &r5xx_rs_block_clear_state);
-    } else {
-        r300_emit_fragment_program_code(r300, &r3xx_passthrough_fragment_shader, 0);
-        r300_emit_rs_block_state(r300, &r3xx_rs_block_clear_state);
-    }
-
-    BEGIN_CS(26);
-
-    /* VAP stream control, mapping from input memory to PVS/RS memory */
-    if (caps->has_tcl) {
-        OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_0,
-            (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));
-    } else {
-        OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_0,
-            (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));
-    }
-    OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_EXT_0,
-            (R300_VAP_SWIZZLE_XYZW << R300_SWIZZLE0_SHIFT) |
-            (R300_VAP_SWIZZLE_XYZW << R300_SWIZZLE1_SHIFT));
-
-    /* VAP format controls */
-    OUT_CS_REG(R300_VAP_OUTPUT_VTX_FMT_0,
-            R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT |
-            R300_VAP_OUTPUT_VTX_FMT_0__COLOR_0_PRESENT);
-    OUT_CS_REG(R300_VAP_OUTPUT_VTX_FMT_1, 0x0);
-
-    /* Disable textures */
-    OUT_CS_REG(R300_TX_ENABLE, 0x0);
-
-    /* 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) |
-        ((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(0.5);
-    OUT_CS_32F(0.5);
-    OUT_CS_32F(1.0);
-    OUT_CS_32F(1.0);
-    /* Color */
-    OUT_CS_32F(r);
-    OUT_CS_32F(g);
-    OUT_CS_32F(b);
-    OUT_CS_32F(a);
-
-    OUT_CS_REG(R300_RB3D_DSTCACHE_CTLSTAT, 0xA);
-
-    END_CS;
-
-    r300->dirty_hw++;
-}
-
-static void r300_surface_copy(struct pipe_context* pipe,
-                              struct pipe_surface* dest,
-                              unsigned destx, unsigned desty,
-                              struct pipe_surface* src,
-                              unsigned srcx, unsigned srcy,
-                              unsigned w, unsigned h)
-{
-    struct r300_context* r300 = r300_context(pipe);
-    struct r300_capabilities* caps = r300_screen(pipe->screen)->caps;
-    struct r300_texture* srctex = (struct r300_texture*)src->texture;
-    struct r300_texture* desttex = (struct r300_texture*)dest->texture;
-    unsigned pixpitch = r300_texture_get_stride(srctex, 0) / srctex->tex.block.size;
-    boolean invalid = FALSE;
-    float fsrcx = srcx, fsrcy = srcy, fdestx = destx, fdesty = desty;
-    CS_LOCALS(r300);
-
-    debug_printf("r300: Copying surface %p at (%d,%d) to %p at (%d, %d),"
-        " dimensions %dx%d (pixel pitch %d)\n",
-        src, srcx, srcy, dest, destx, desty, w, h, pixpitch);
-
-    if ((srctex->buffer == desttex->buffer) &&
-            ((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) {
-            debug_printf("r300: Stuck in validation loop, gonna fallback.");
-            goto fallback;
-        }
-        invalid = TRUE;
-        goto validate;
-    }
-
-    r300_surface_setup(r300, desttex, destx, desty, w, h);
-
-    /* Setup the texture. */
-    r300_emit_texture(r300, &r300_sampler_copy_state, srctex, 0);
-
-    /* Flush and enable. */
-    r300_flush_textures(r300);
-
-    /* Vertex shader setup */
-    if (caps->has_tcl) {
-        r300_emit_vertex_program_code(r300, &r300_passthrough_vertex_shader, 0);
-    } else {
-        BEGIN_CS(4);
-        OUT_CS_REG(R300_VAP_CNTL_STATUS,
-#ifdef PIPE_ARCH_BIG_ENDIAN
-                   R300_VC_32BIT_SWAP |
-#endif
-                   R300_VAP_TCL_BYPASS);
-        OUT_CS_REG(R300_VAP_CNTL, R300_PVS_NUM_SLOTS(5) |
-                R300_PVS_NUM_CNTLRS(5) |
-                R300_PVS_NUM_FPUS(caps->num_vert_fpus) |
-                R300_PVS_VF_MAX_VTX_NUM(12));
-        END_CS;
-    }
-
-    /* Fragment shader setup */
-    if (caps->is_r500) {
-        r500_emit_fragment_program_code(r300, &r5xx_texture_fragment_shader, 0);
-        r300_emit_rs_block_state(r300, &r5xx_rs_block_copy_state);
-    } else {
-        r300_emit_fragment_program_code(r300, &r3xx_texture_fragment_shader, 0);
-        r300_emit_rs_block_state(r300, &r3xx_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,
-            (R300_DATA_TYPE_FLOAT_2 << R300_DATA_TYPE_0_SHIFT) |
-            ((R300_LAST_VEC | (1 << R300_DST_VEC_LOC_SHIFT) |
-                R300_DATA_TYPE_FLOAT_2) << R300_DATA_TYPE_1_SHIFT));
-    } else {
-        OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_0,
-            (R300_DATA_TYPE_FLOAT_2 << R300_DATA_TYPE_0_SHIFT) |
-            ((R300_LAST_VEC | (6 << R300_DST_VEC_LOC_SHIFT) |
-                R300_DATA_TYPE_FLOAT_2) << R300_DATA_TYPE_1_SHIFT));
-    }
-    OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_EXT_0,
-            (R300_VAP_SWIZZLE_XYZW << R300_SWIZZLE0_SHIFT) |
-            (R300_VAP_SWIZZLE_XYZW << R300_SWIZZLE1_SHIFT));
-
-    /* VAP format controls */
-    OUT_CS_REG(R300_VAP_OUTPUT_VTX_FMT_0,
-            R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT);
-    /* 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, 16);
-    OUT_CS(R300_PRIM_TYPE_QUADS | R300_PRIM_WALK_RING |
-            (4 << R300_PRIM_NUM_VERTICES_SHIFT));
-    /* (x    , y    ) */
-    OUT_CS_32F(fdestx / dest->width);
-    OUT_CS_32F(fdesty / dest->height);
-    OUT_CS_32F(fsrcx  / src->width);
-    OUT_CS_32F(fsrcy  / src->height);
-    /* (x    , y + h) */
-    OUT_CS_32F(fdestx / dest->width);
-    OUT_CS_32F((fdesty + h) / dest->height);
-    OUT_CS_32F(fsrcx  / src->width);
-    OUT_CS_32F((fsrcy  + h) / src->height);
-    /* (x + w, y + h) */
-    OUT_CS_32F((fdestx + w) / dest->width);
-    OUT_CS_32F((fdesty + h) / dest->height);
-    OUT_CS_32F((fsrcx  + w) / src->width);
-    OUT_CS_32F((fsrcy  + h) / src->height);
-    /* (x + w, y    ) */
-    OUT_CS_32F((fdestx + w) / dest->width);
-    OUT_CS_32F(fdesty / dest->height);
-    OUT_CS_32F((fsrcx  + w) / src->width);
-    OUT_CS_32F(fsrcy  / src->height);
-
-    OUT_CS_REG(R300_RB3D_DSTCACHE_CTLSTAT, 0xA);
-
-    END_CS;
-
-    r300->dirty_hw++;
-}
-
-void r300_init_surface_functions(struct r300_context* r300)
-{
-    r300->context.surface_fill = r300_surface_fill;
-    r300->context.surface_copy = r300_surface_copy;
-}
diff --git a/src/gallium/drivers/r300/r300_surface.h b/src/gallium/drivers/r300/r300_surface.h
deleted file mode 100644 (file)
index f9e98b2..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright 2008 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 R300_SURFACE_H
-#define R300_SURFACE_H
-
-#include "pipe/p_context.h"
-#include "pipe/p_screen.h"
-
-#include "util/u_rect.h"
-
-#include "r300_context.h"
-#include "r300_cs.h"
-#include "r300_emit.h"
-#include "r300_fs.h"
-#include "r300_vs.h"
-#include "r300_state_inlines.h"
-
-static struct r300_blend_state blend_clear_state = {
-    .blend_control = 0x0,
-    .alpha_blend_control = 0x0,
-    .rop = 0x0,
-    .dither = 0x0,
-};
-
-static struct r300_blend_color_state blend_color_clear_state = {
-    .blend_color = 0x0,
-    .blend_color_red_alpha = 0x0,
-    .blend_color_green_blue = 0x0,
-};
-
-static struct r300_dsa_state dsa_clear_state = {
-    .alpha_function = 0x0,
-    .alpha_reference = 0x0,
-    .z_buffer_control = 0x0,
-    .z_stencil_control = 0x0,
-    .stencil_ref_mask = R300_STENCILWRITEMASK_MASK,
-    .z_buffer_top = R300_ZTOP_ENABLE,
-    .stencil_ref_bf = 0x0,
-};
-
-static struct r300_rs_state rs_clear_state = {
-    .point_minmax = 0x36000006,
-    .line_control = 0x00030006,
-    .depth_scale_front = 0x0,
-    .depth_offset_front = 0x0,
-    .depth_scale_back = 0x0,
-    .depth_offset_back = 0x0,
-    .polygon_offset_enable = 0x0,
-    .cull_mode = 0x0,
-    .line_stipple_config = 0x3BAAAAAB,
-    .line_stipple_value = 0x0,
-    .color_control = R300_SHADE_MODEL_FLAT,
-};
-
-static struct r300_rs_block r3xx_rs_block_clear_state = {
-    .ip[0] = R500_RS_SEL_S(R300_RS_SEL_C0) |
-        R500_RS_SEL_T(R300_RS_SEL_C0) |
-        R500_RS_SEL_R(R300_RS_SEL_C0) |
-        R500_RS_SEL_Q(R300_RS_SEL_K1),
-    .inst[0] = R300_RS_INST_COL_CN_WRITE,
-    .count = R300_IT_COUNT(0) | R300_IC_COUNT(1) | R300_HIRES_EN,
-    .inst_count = 0,
-};
-
-static struct r300_rs_block r5xx_rs_block_clear_state = {
-    .ip[0] = R500_RS_SEL_S(R500_RS_IP_PTR_K0) |
-        R500_RS_SEL_T(R500_RS_IP_PTR_K0) |
-        R500_RS_SEL_R(R500_RS_IP_PTR_K0) |
-        R500_RS_SEL_Q(R500_RS_IP_PTR_K1),
-    .inst[0] = R500_RS_INST_COL_CN_WRITE,
-    .count = R300_IT_COUNT(0) | R300_IC_COUNT(1) | R300_HIRES_EN,
-    .inst_count = 0,
-};
-
-/* The following state is used for surface_copy only. */
-
-static struct r300_rs_block r3xx_rs_block_copy_state = {
-    .ip[0] = R500_RS_SEL_S(R300_RS_SEL_K0) |
-        R500_RS_SEL_T(R300_RS_SEL_K0) |
-        R500_RS_SEL_R(R300_RS_SEL_K0) |
-        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(0),
-};
-
-static struct r300_rs_block r5xx_rs_block_copy_state = {
-    .ip[0] = R500_RS_SEL_S(0) |
-        R500_RS_SEL_T(1) |
-        R500_RS_SEL_R(R500_RS_IP_PTR_K0) |
-        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(0),
-};
-
-static struct r300_sampler_state r300_sampler_copy_state = {
-    .filter0 = R300_TX_WRAP_S(R300_TX_CLAMP) |
-        R300_TX_WRAP_T(R300_TX_CLAMP) |
-        R300_TX_MAG_FILTER_NEAREST |
-        R300_TX_MIN_FILTER_NEAREST,
-};
-
-#endif /* R300_SURFACE_H */
index ce60ded7caf929db182207dc1833476653ec1b07..9a96206a4dc186f72828191488466321cfe9e205 100644 (file)
  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  * USE OR OTHER DEALINGS IN THE SOFTWARE. */
 
+#include "pipe/p_screen.h"
+
+#include "util/u_format.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
+#include "r300_context.h"
 #include "r300_texture.h"
+#include "r300_screen.h"
 
-static void r300_setup_texture_state(struct r300_texture* tex)
+static void r300_setup_texture_state(struct r300_texture* tex, boolean is_r500)
 {
     struct r300_texture_state* state = &tex->state;
     struct pipe_texture *pt = &tex->tex;
 
-    state->format0 = R300_TX_WIDTH((pt->width[0] - 1) & 0x7ff) |
-        R300_TX_HEIGHT((pt->height[0] - 1) & 0x7ff) |
-        R300_TX_DEPTH(util_logbase2(pt->depth[0]) & 0xf) |
-        R300_TX_NUM_LEVELS(pt->last_level) |
-        R300_TX_PITCH_EN;
+    state->format0 = R300_TX_WIDTH((pt->width0 - 1) & 0x7ff) |
+                     R300_TX_HEIGHT((pt->height0 - 1) & 0x7ff);
+
+    if (tex->is_npot) {
+        /* rectangles love this */
+        state->format0 |= R300_TX_PITCH_EN;
+        state->format2 = (tex->pitch[0] - 1) & 0x1fff;
+    } else {
+        /* power of two textures (3D, mipmaps, and no pitch) */
+        state->format0 |= R300_TX_DEPTH(util_logbase2(pt->depth0) & 0xf);
+    }
 
-    /* XXX */
     state->format1 = r300_translate_texformat(pt->format);
     if (pt->target == PIPE_TEXTURE_CUBE) {
-       state->format1 |= R300_TX_FORMAT_CUBIC_MAP;
+        state->format1 |= R300_TX_FORMAT_CUBIC_MAP;
     }
     if (pt->target == PIPE_TEXTURE_3D) {
-       state->format1 |= R300_TX_FORMAT_3D;
+        state->format1 |= R300_TX_FORMAT_3D;
     }
 
-    state->format2 = (r300_texture_get_stride(tex, 0) / pt->block.size) - 1;
-
-    /* Assume (somewhat foolishly) that oversized textures will
-     * not be permitted by the state tracker. */
-    if (pt->width[0] > 2048) {
-        state->format2 |= R500_TXWIDTH_BIT11;
-    }
-    if (pt->height[0] > 2048) {
-        state->format2 |= R500_TXHEIGHT_BIT11;
+    /* large textures on r500 */
+    if (is_r500)
+    {
+        if (pt->width0 > 2048) {
+            state->format2 |= R500_TXWIDTH_BIT11;
+        }
+        if (pt->height0 > 2048) {
+            state->format2 |= R500_TXHEIGHT_BIT11;
+        }
     }
+    assert(is_r500 || (pt->width0 <= 2048 && pt->height0 <= 2048));
 
     debug_printf("r300: Set texture state (%dx%d, %d levels)\n",
-                pt->width[0], pt->height[0], pt->last_level);
+                pt->width0, pt->height0, pt->last_level);
+}
+
+unsigned r300_texture_get_offset(struct r300_texture* tex, unsigned level,
+                                 unsigned zslice, unsigned face)
+{
+    unsigned offset = tex->offset[level];
+
+    switch (tex->tex.target) {
+        case PIPE_TEXTURE_3D:
+            assert(face == 0);
+            return offset + zslice * tex->layer_size[level];
+
+        case PIPE_TEXTURE_CUBE:
+            assert(zslice == 0);
+            return offset + face * tex->layer_size[level];
+
+        default:
+            assert(zslice == 0 && face == 0);
+            return offset;
+    }
 }
 
 /**
@@ -67,47 +101,49 @@ unsigned r300_texture_get_stride(struct r300_texture* tex, unsigned level)
         return tex->stride_override;
 
     if (level > tex->tex.last_level) {
-        debug_printf("%s: level (%u) > last_level (%u)\n", __FUNCTION__, level, tex->tex.last_level);
+        debug_printf("%s: level (%u) > last_level (%u)\n", __FUNCTION__,
+            level, tex->tex.last_level);
         return 0;
     }
 
-    return align(pf_get_stride(&tex->tex.block, tex->tex.width[level]), 32);
+    return align(util_format_get_stride(tex->tex.format, u_minify(tex->tex.width0, level)), 32);
 }
 
 static void r300_setup_miptree(struct r300_texture* tex)
 {
     struct pipe_texture* base = &tex->tex;
-    int stride, size;
+    int stride, size, layer_size;
     int i;
 
     for (i = 0; i <= base->last_level; i++) {
-        if (i > 0) {
-            base->width[i] = minify(base->width[i-1]);
-            base->height[i] = minify(base->height[i-1]);
-            base->depth[i] = minify(base->depth[i-1]);
-        }
+        unsigned nblocksy = util_format_get_nblocksy(base->format, u_minify(base->height0, i));
 
-        base->nblocksx[i] = pf_get_nblocksx(&base->block, base->width[i]);
-        base->nblocksy[i] = pf_get_nblocksy(&base->block, base->height[i]);
-
-        /* Radeons enjoy things in multiples of 64.
-         *
-         * XXX
-         * POT, uncompressed, unmippmapped textures can be aligned to 32,
-         * instead of 64. */
         stride = r300_texture_get_stride(tex, i);
-        size = stride * base->nblocksy[i] * base->depth[i];
+        layer_size = stride * nblocksy;
+
+        if (base->target == PIPE_TEXTURE_CUBE)
+            size = layer_size * 6;
+        else
+            size = layer_size * u_minify(base->depth0, i);
 
         tex->offset[i] = align(tex->size, 32);
         tex->size = tex->offset[i] + size;
+        tex->layer_size[i] = layer_size;
+        tex->pitch[i] = stride / util_format_get_blocksize(base->format);
 
         debug_printf("r300: Texture miptree: Level %d "
                 "(%dx%dx%d px, pitch %d bytes)\n",
-                i, base->width[i], base->height[i], base->depth[i],
-                stride);
+                i, u_minify(base->width0, i), u_minify(base->height0, i),
+                u_minify(base->depth0, i), stride);
     }
 }
 
+static void r300_setup_flags(struct r300_texture* tex)
+{
+    tex->is_npot = !util_is_power_of_two(tex->tex.width0) ||
+                   !util_is_power_of_two(tex->tex.height0);
+}
+
 /* Create a new texture. */
 static struct pipe_texture*
     r300_texture_create(struct pipe_screen* screen,
@@ -123,9 +159,9 @@ static struct pipe_texture*
     pipe_reference_init(&tex->tex.reference, 1);
     tex->tex.screen = screen;
 
+    r300_setup_flags(tex);
     r300_setup_miptree(tex);
-
-    r300_setup_texture_state(tex);
+    r300_setup_texture_state(tex, r300_screen(screen)->caps->is_r500);
 
     tex->buffer = screen->buffer_create(screen, 1024,
                                         PIPE_BUFFER_USAGE_PIXEL,
@@ -159,17 +195,20 @@ static struct pipe_surface* r300_get_tex_surface(struct pipe_screen* screen,
     struct pipe_surface* surface = CALLOC_STRUCT(pipe_surface);
     unsigned offset;
 
-    /* XXX this is certainly dependent on tex target */
-    offset = tex->offset[level];
+    offset = r300_texture_get_offset(tex, level, zslice, face);
 
     if (surface) {
         pipe_reference_init(&surface->reference, 1);
         pipe_texture_reference(&surface->texture, texture);
         surface->format = texture->format;
-        surface->width = texture->width[level];
-        surface->height = texture->height[level];
+        surface->width = u_minify(texture->width0, level);
+        surface->height = u_minify(texture->height0, level);
         surface->offset = offset;
         surface->usage = flags;
+        surface->zslice = zslice;
+        surface->texture = texture;
+        surface->face = face;
+        surface->level = level;
     }
 
     return surface;
@@ -189,10 +228,10 @@ static struct pipe_texture*
 {
     struct r300_texture* tex;
 
-    /* XXX we should start doing mips now... */
+    /* Support only 2D textures without mipmaps */
     if (base->target != PIPE_TEXTURE_2D ||
-        base->last_level != 0 ||
-        base->depth[0] != 1) {
+        base->depth0 != 1 ||
+        base->last_level != 0) {
         return NULL;
     }
 
@@ -206,15 +245,64 @@ static struct pipe_texture*
     tex->tex.screen = screen;
 
     tex->stride_override = *stride;
+    tex->pitch[0] = *stride / util_format_get_blocksize(base->format);
 
-    /* XXX */
-    r300_setup_texture_state(tex);
+    r300_setup_flags(tex);
+    r300_setup_texture_state(tex, r300_screen(screen)->caps->is_r500);
 
     pipe_buffer_reference(&tex->buffer, buffer);
 
     return (struct pipe_texture*)tex;
 }
 
+static struct pipe_video_surface *
+r300_video_surface_create(struct pipe_screen *screen,
+                          enum pipe_video_chroma_format chroma_format,
+                          unsigned width, unsigned height)
+{
+    struct r300_video_surface *r300_vsfc;
+    struct pipe_texture template;
+
+    assert(screen);
+    assert(width && height);
+
+    r300_vsfc = CALLOC_STRUCT(r300_video_surface);
+    if (!r300_vsfc)
+       return NULL;
+
+    pipe_reference_init(&r300_vsfc->base.reference, 1);
+    r300_vsfc->base.screen = screen;
+    r300_vsfc->base.chroma_format = chroma_format;
+    r300_vsfc->base.width = width;
+    r300_vsfc->base.height = height;
+
+    memset(&template, 0, sizeof(struct pipe_texture));
+    template.target = PIPE_TEXTURE_2D;
+    template.format = PIPE_FORMAT_X8R8G8B8_UNORM;
+    template.last_level = 0;
+    template.width0 = util_next_power_of_two(width);
+    template.height0 = util_next_power_of_two(height);
+    template.depth0 = 1;
+    template.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER |
+                         PIPE_TEXTURE_USAGE_RENDER_TARGET;
+
+    r300_vsfc->tex = screen->texture_create(screen, &template);
+    if (!r300_vsfc->tex)
+    {
+        FREE(r300_vsfc);
+        return NULL;
+    }
+
+    return &r300_vsfc->base;
+}
+
+static void r300_video_surface_destroy(struct pipe_video_surface *vsfc)
+{
+    struct r300_video_surface *r300_vsfc = r300_video_surface(vsfc);
+    pipe_texture_reference(&r300_vsfc->tex, NULL);
+    FREE(r300_vsfc);
+}
+
 void r300_init_screen_texture_functions(struct pipe_screen* screen)
 {
     screen->texture_create = r300_texture_create;
@@ -222,6 +310,9 @@ void r300_init_screen_texture_functions(struct pipe_screen* screen)
     screen->get_tex_surface = r300_get_tex_surface;
     screen->tex_surface_destroy = r300_tex_surface_destroy;
     screen->texture_blanket = r300_texture_blanket;
+
+    screen->video_surface_create = r300_video_surface_create;
+    screen->video_surface_destroy= r300_video_surface_destroy;
 }
 
 boolean r300_get_texture_buffer(struct pipe_texture* texture,
index bd87790bc34f76238fe5ba7b4eb934ee89a55e1a..55ceb1a5136b14d38acce5de710aca28dae968bd 100644 (file)
 #ifndef R300_TEXTURE_H
 #define R300_TEXTURE_H
 
-#include "pipe/p_screen.h"
+#include "pipe/p_video_state.h"
 
-#include "util/u_math.h"
-
-#include "r300_context.h"
 #include "r300_reg.h"
 
 struct r300_texture;
@@ -36,6 +33,9 @@ void r300_init_screen_texture_functions(struct pipe_screen* screen);
 
 unsigned r300_texture_get_stride(struct r300_texture* tex, unsigned level);
 
+unsigned r300_texture_get_offset(struct r300_texture* tex, unsigned level,
+                                 unsigned zslice, unsigned face);
+
 /* Note the signature of R300_EASY_TX_FORMAT(A, R, G, B, FORMAT)... */
 static INLINE uint32_t r300_translate_texformat(enum pipe_format format)
 {
@@ -43,6 +43,19 @@ static INLINE uint32_t r300_translate_texformat(enum pipe_format format)
         /* X8 */
         case PIPE_FORMAT_I8_UNORM:
             return R300_EASY_TX_FORMAT(X, X, X, X, X8);
+        case PIPE_FORMAT_L8_UNORM:
+            return R300_EASY_TX_FORMAT(X, X, X, ONE, X8);
+        /* X16 */
+        case PIPE_FORMAT_R16_UNORM:
+            return R300_EASY_TX_FORMAT(X, X, X, X, X16);
+        case PIPE_FORMAT_R16_SNORM:
+            return R300_EASY_TX_FORMAT(X, X, X, X, X16) |
+                R300_TX_FORMAT_SIGNED;
+        case PIPE_FORMAT_Z16_UNORM:
+            return R300_EASY_TX_FORMAT(X, X, X, X, X16);
+        /* Y8X8 */
+        case PIPE_FORMAT_A8L8_UNORM:
+            return R300_EASY_TX_FORMAT(X, X, X, Y, Y8X8);
         /* W8Z8Y8X8 */
         case PIPE_FORMAT_A8R8G8B8_UNORM:
             return R300_EASY_TX_FORMAT(X, Y, Z, W, W8Z8Y8X8);
@@ -75,12 +88,9 @@ static INLINE uint32_t r300_translate_texformat(enum pipe_format format)
                 R300_TX_FORMAT_YUV_TO_RGB;
         /* W24_FP */
         case PIPE_FORMAT_Z24S8_UNORM:
+        case PIPE_FORMAT_Z24X8_UNORM:
             return R300_EASY_TX_FORMAT(X, X, X, X, W24_FP);
-       /* Z5_Y6_X5 */
-        case PIPE_FORMAT_R16_SNORM:
-            return R300_EASY_TX_FORMAT(X, X, X, X, Z5Y6X5);
-        case PIPE_FORMAT_Z16_UNORM:
-           return R300_EASY_TX_FORMAT(X, X, X, X, X16);
+
         default:
             debug_printf("r300: Implementation error: "
                 "Got unsupported texture format %s in %s\n",
@@ -91,6 +101,18 @@ static INLINE uint32_t r300_translate_texformat(enum pipe_format format)
     return 0;
 }
 
+struct r300_video_surface
+{
+    struct pipe_video_surface   base;
+    struct pipe_texture         *tex;
+};
+
+static INLINE struct r300_video_surface *
+r300_video_surface(struct pipe_video_surface *pvs)
+{
+    return (struct r300_video_surface *)pvs;
+}
+
 #ifndef R300_WINSYS_H
 
 boolean r300_get_texture_buffer(struct pipe_texture* texture,
index 74d4fb5087680ecdc9e040ac9aea07c958c8c561..a792c2cf9890c77a14be9d05a43ed07f31632517 100644 (file)
@@ -120,7 +120,7 @@ static unsigned translate_opcode(unsigned opcode)
      /* case TGSI_OPCODE_NOT: return RC_OPCODE_NOT; */
      /* case TGSI_OPCODE_TRUNC: return RC_OPCODE_TRUNC; */
      /* case TGSI_OPCODE_SHL: return RC_OPCODE_SHL; */
-     /* case TGSI_OPCODE_SHR: return RC_OPCODE_SHR; */
+     /* case TGSI_OPCODE_ISHR: return RC_OPCODE_SHR; */
      /* case TGSI_OPCODE_AND: return RC_OPCODE_AND; */
      /* case TGSI_OPCODE_OR: return RC_OPCODE_OR; */
      /* case TGSI_OPCODE_MOD: return RC_OPCODE_MOD; */
@@ -135,10 +135,6 @@ static unsigned translate_opcode(unsigned opcode)
      /* case TGSI_OPCODE_BGNSUB: return RC_OPCODE_BGNSUB; */
      /* case TGSI_OPCODE_ENDLOOP2: return RC_OPCODE_ENDLOOP2; */
      /* case TGSI_OPCODE_ENDSUB: return RC_OPCODE_ENDSUB; */
-     /* case TGSI_OPCODE_NOISE1: return RC_OPCODE_NOISE1; */
-     /* case TGSI_OPCODE_NOISE2: return RC_OPCODE_NOISE2; */
-     /* case TGSI_OPCODE_NOISE3: return RC_OPCODE_NOISE3; */
-     /* case TGSI_OPCODE_NOISE4: return RC_OPCODE_NOISE4; */
         case TGSI_OPCODE_NOP: return RC_OPCODE_NOP;
                                         /* gap */
      /* case TGSI_OPCODE_NRM4: return RC_OPCODE_NRM4; */
@@ -146,7 +142,6 @@ static unsigned translate_opcode(unsigned opcode)
      /* case TGSI_OPCODE_IFC: return RC_OPCODE_IFC; */
      /* case TGSI_OPCODE_BREAKC: return RC_OPCODE_BREAKC; */
         case TGSI_OPCODE_KIL: return RC_OPCODE_KIL;
-        case TGSI_OPCODE_SWZ: return RC_OPCODE_SWZ;
     }
 
     fprintf(stderr, "Unknown opcode: %i\n", opcode);
@@ -195,10 +190,10 @@ static void transform_dstreg(
     struct rc_dst_register * dst,
     struct tgsi_full_dst_register * src)
 {
-    dst->File = translate_register_file(src->DstRegister.File);
-    dst->Index = translate_register_index(ttr, src->DstRegister.File, src->DstRegister.Index);
-    dst->WriteMask = src->DstRegister.WriteMask;
-    dst->RelAddr = src->DstRegister.Indirect;
+    dst->File = translate_register_file(src->Register.File);
+    dst->Index = translate_register_index(ttr, src->Register.File, src->Register.Index);
+    dst->WriteMask = src->Register.WriteMask;
+    dst->RelAddr = src->Register.Indirect;
 }
 
 static void transform_srcreg(
@@ -206,23 +201,19 @@ static void transform_srcreg(
     struct rc_src_register * dst,
     struct tgsi_full_src_register * src)
 {
-    dst->File = translate_register_file(src->SrcRegister.File);
-    dst->Index = translate_register_index(ttr, src->SrcRegister.File, src->SrcRegister.Index);
-    dst->RelAddr = src->SrcRegister.Indirect;
-    dst->Swizzle = tgsi_util_get_full_src_register_extswizzle(src, 0);
-    dst->Swizzle |= tgsi_util_get_full_src_register_extswizzle(src, 1) << 3;
-    dst->Swizzle |= tgsi_util_get_full_src_register_extswizzle(src, 2) << 6;
-    dst->Swizzle |= tgsi_util_get_full_src_register_extswizzle(src, 3) << 9;
-    dst->Abs = src->SrcRegisterExtMod.Absolute;
-    dst->Negate =
-        src->SrcRegisterExtSwz.NegateX |
-        (src->SrcRegisterExtSwz.NegateY << 1) |
-        (src->SrcRegisterExtSwz.NegateZ << 2) |
-        (src->SrcRegisterExtSwz.NegateW << 3);
-    dst->Negate ^= src->SrcRegister.Negate ? RC_MASK_XYZW : 0;
+    dst->File = translate_register_file(src->Register.File);
+    dst->Index = translate_register_index(ttr, src->Register.File, src->Register.Index);
+    dst->RelAddr = src->Register.Indirect;
+    dst->Swizzle = tgsi_util_get_full_src_register_swizzle(src, 0);
+    dst->Swizzle |= tgsi_util_get_full_src_register_swizzle(src, 1) << 3;
+    dst->Swizzle |= tgsi_util_get_full_src_register_swizzle(src, 2) << 6;
+    dst->Swizzle |= tgsi_util_get_full_src_register_swizzle(src, 3) << 9;
+    dst->Abs = src->Register.Absolute;
+    dst->Negate = src->Register.Negate ? RC_MASK_XYZW : 0;
 }
 
-static void transform_texture(struct rc_instruction * dst, struct tgsi_instruction_ext_texture src)
+static void transform_texture(struct rc_instruction * dst, struct tgsi_instruction_texture src,
+                              uint32_t *shadowSamplers)
 {
     switch(src.Texture) {
         case TGSI_TEXTURE_1D:
@@ -243,14 +234,17 @@ static void transform_texture(struct rc_instruction * dst, struct tgsi_instructi
         case TGSI_TEXTURE_SHADOW1D:
             dst->U.I.TexSrcTarget = RC_TEXTURE_1D;
             dst->U.I.TexShadow = 1;
+            *shadowSamplers |= 1 << dst->U.I.TexSrcUnit;
             break;
         case TGSI_TEXTURE_SHADOW2D:
             dst->U.I.TexSrcTarget = RC_TEXTURE_2D;
             dst->U.I.TexShadow = 1;
+            *shadowSamplers |= 1 << dst->U.I.TexSrcUnit;
             break;
         case TGSI_TEXTURE_SHADOWRECT:
             dst->U.I.TexSrcTarget = RC_TEXTURE_RECT;
             dst->U.I.TexShadow = 1;
+            *shadowSamplers |= 1 << dst->U.I.TexSrcUnit;
             break;
     }
 }
@@ -268,17 +262,19 @@ static void transform_instruction(struct tgsi_to_rc * ttr, struct tgsi_full_inst
     dst->U.I.SaturateMode = translate_saturate(src->Instruction.Saturate);
 
     if (src->Instruction.NumDstRegs)
-        transform_dstreg(ttr, &dst->U.I.DstReg, &src->FullDstRegisters[0]);
+        transform_dstreg(ttr, &dst->U.I.DstReg, &src->Dst[0]);
 
     for(i = 0; i < src->Instruction.NumSrcRegs; ++i) {
-        if (src->FullSrcRegisters[i].SrcRegister.File == TGSI_FILE_SAMPLER)
-            dst->U.I.TexSrcUnit = src->FullSrcRegisters[i].SrcRegister.Index;
+        if (src->Src[i].Register.File == TGSI_FILE_SAMPLER)
+            dst->U.I.TexSrcUnit = src->Src[i].Register.Index;
         else
-            transform_srcreg(ttr, &dst->U.I.SrcReg[i], &src->FullSrcRegisters[i]);
+            transform_srcreg(ttr, &dst->U.I.SrcReg[i], &src->Src[i]);
     }
 
     /* Texturing. */
-    transform_texture(dst, src->InstructionExtTexture);
+    if (src->Instruction.Texture)
+        transform_texture(dst, src->Texture,
+                          &ttr->compiler->Program.ShadowSamplers);
 }
 
 static void handle_immediate(struct tgsi_to_rc * ttr, struct tgsi_full_immediate * imm)
index 8460cfaf518d348c6b1fff4dac108ae0950e9910..68aef70872ecad450369aaa2a57b0225473b4d19 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright 2009 Corbin Simpson <MostAwesomeDude@gmail.com>
+ * Copyright 2009 Marek Olšák <maraeo@gmail.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
  * USE OR OTHER DEALINGS IN THE SOFTWARE. */
 
 #include "r300_vs.h"
+#include "r300_fs.h"
 
 #include "r300_context.h"
+#include "r300_screen.h"
 #include "r300_tgsi_to_rc.h"
+#include "r300_reg.h"
 
 #include "tgsi/tgsi_dump.h"
 #include "tgsi/tgsi_parse.h"
 
 #include "radeon_compiler.h"
 
+#include "util/u_math.h"
 
-static void set_vertex_inputs_outputs(struct r300_vertex_program_compiler * c)
+/* Convert info about VS output semantics into r300_shader_semantics. */
+static void r300_shader_read_vs_outputs(
+    struct tgsi_shader_info* info,
+    struct r300_shader_semantics* vs_outputs)
 {
-    struct r300_vertex_shader * vs = c->UserData;
-    struct tgsi_shader_info* info = &vs->info;
-    struct tgsi_parse_context parser;
-    struct tgsi_full_declaration * decl;
-    boolean pointsize = false;
-    int out_colors = 0;
-    int colors = 0;
-    int out_generic = 0;
-    int generic = 0;
     int i;
+    unsigned index;
 
-    /* Fill in the input mapping */
-    for (i = 0; i < info->num_inputs; i++)
-        c->code->inputs[i] = i;
+    r300_shader_semantics_reset(vs_outputs);
 
-    /* Fill in the output mapping */
     for (i = 0; i < info->num_outputs; i++) {
+        index = info->output_semantic_index[i];
+
         switch (info->output_semantic_name[i]) {
+            case TGSI_SEMANTIC_POSITION:
+                assert(index == 0);
+                vs_outputs->pos = i;
+                break;
+
             case TGSI_SEMANTIC_PSIZE:
-                pointsize = true;
+                assert(index == 0);
+                vs_outputs->psize = i;
                 break;
+
             case TGSI_SEMANTIC_COLOR:
-                out_colors++;
+                assert(index <= ATTR_COLOR_COUNT);
+                vs_outputs->color[index] = i;
                 break;
-            case TGSI_SEMANTIC_FOG:
+
+            case TGSI_SEMANTIC_BCOLOR:
+                assert(index <= ATTR_COLOR_COUNT);
+                vs_outputs->bcolor[index] = i;
+                break;
+
             case TGSI_SEMANTIC_GENERIC:
-                out_generic++;
+                assert(index <= ATTR_GENERIC_COUNT);
+                vs_outputs->generic[index] = i;
+                break;
+
+            case TGSI_SEMANTIC_FOG:
+                assert(index == 0);
+                vs_outputs->fog = i;
                 break;
+
+            case TGSI_SEMANTIC_EDGEFLAG:
+                assert(index == 0);
+                fprintf(stderr, "r300 VP: cannot handle edgeflag output\n");
+                assert(0);
+                break;
+            default:
+                assert(0);
         }
     }
+}
 
-    tgsi_parse_init(&parser, vs->state.tokens);
+static void r300_shader_vap_output_fmt(struct r300_vertex_shader* vs)
+{
+    struct r300_shader_semantics* vs_outputs = &vs->outputs;
+    uint32_t* hwfmt = vs->hwfmt;
+    int i, gen_count;
+    boolean any_bcolor_used = vs_outputs->bcolor[0] != ATTR_UNUSED ||
+                              vs_outputs->bcolor[1] != ATTR_UNUSED;
+
+    /* Do the actual vertex_info setup.
+     *
+     * vertex_info has four uints of hardware-specific data in it.
+     * vinfo.hwfmt[0] is R300_VAP_VTX_STATE_CNTL
+     * vinfo.hwfmt[1] is R300_VAP_VSM_VTX_ASSM
+     * vinfo.hwfmt[2] is R300_VAP_OUTPUT_VTX_FMT_0
+     * vinfo.hwfmt[3] is R300_VAP_OUTPUT_VTX_FMT_1 */
+
+    hwfmt[0] = 0x5555; /* XXX this is classic Mesa bonghits */
+
+    /* Position. */
+    if (vs_outputs->pos != ATTR_UNUSED) {
+        hwfmt[1] |= R300_INPUT_CNTL_POS;
+        hwfmt[2] |= R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT;
+    } else {
+        assert(0);
+    }
 
-    while (!tgsi_parse_end_of_tokens(&parser)) {
-        tgsi_parse_token(&parser);
+    /* Point size. */
+    if (vs_outputs->psize != ATTR_UNUSED) {
+        hwfmt[2] |= R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT;
+    }
 
-        if (parser.FullToken.Token.Type != TGSI_TOKEN_TYPE_DECLARATION)
-            continue;
+    /* Colors. */
+    for (i = 0; i < ATTR_COLOR_COUNT; i++) {
+        if (vs_outputs->color[i] != ATTR_UNUSED || any_bcolor_used) {
+            hwfmt[1] |= R300_INPUT_CNTL_COLOR;
+            hwfmt[2] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_0_PRESENT << i;
+        }
+    }
 
-        decl = &parser.FullToken.FullDeclaration;
+    /* Back-face colors. */
+    if (any_bcolor_used) {
+        for (i = 0; i < ATTR_COLOR_COUNT; i++) {
+            hwfmt[1] |= R300_INPUT_CNTL_COLOR;
+            hwfmt[2] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_0_PRESENT << (2+i);
+        }
+    }
 
-        if (decl->Declaration.File != TGSI_FILE_OUTPUT)
-            continue;
+    /* Texture coordinates. */
+    gen_count = 0;
+    for (i = 0; i < ATTR_GENERIC_COUNT; i++) {
+        if (vs_outputs->generic[i] != ATTR_UNUSED) {
+            hwfmt[1] |= (R300_INPUT_CNTL_TC0 << gen_count);
+            hwfmt[3] |= (4 << (3 * gen_count));
+            gen_count++;
+        }
+    }
 
-        switch (decl->Semantic.SemanticName) {
-            case TGSI_SEMANTIC_POSITION:
-                c->code->outputs[decl->DeclarationRange.First] = 0;
-                break;
-            case TGSI_SEMANTIC_PSIZE:
-                c->code->outputs[decl->DeclarationRange.First] = 1;
-                break;
-            case TGSI_SEMANTIC_COLOR:
-                c->code->outputs[decl->DeclarationRange.First] = 1 +
-                    (pointsize ? 1 : 0) +
-                    colors++;
-                break;
-            case TGSI_SEMANTIC_FOG:
-            case TGSI_SEMANTIC_GENERIC:
-                c->code->outputs[decl->DeclarationRange.First] = 1 +
-                    (pointsize ? 1 : 0) +
-                    out_colors +
-                    generic++;
-                break;
-            default:
-                debug_printf("r300: vs: Bad semantic declaration %d\n",
-                    decl->Semantic.SemanticName);
-                break;
+    /* Fog coordinates. */
+    if (vs_outputs->fog != ATTR_UNUSED) {
+        hwfmt[1] |= (R300_INPUT_CNTL_TC0 << gen_count);
+        hwfmt[3] |= (4 << (3 * gen_count));
+        gen_count++;
+    }
+
+    /* XXX magic */
+    assert(gen_count <= 8);
+
+    /* WPOS. */
+    vs->wpos_tex_output = gen_count;
+}
+
+/* Sets up stream mapping to equivalent VS outputs if TCL is bypassed
+ * or isn't present. */
+static void r300_stream_locations_notcl(
+    struct r300_shader_semantics* vs_outputs,
+    int* stream_loc)
+{
+    int i, tabi = 0, gen_count;
+    boolean any_bcolor_used = vs_outputs->bcolor[0] != ATTR_UNUSED ||
+                              vs_outputs->bcolor[1] != ATTR_UNUSED;
+
+    /* Position. */
+    stream_loc[tabi++] = 0;
+
+    /* Point size. */
+    if (vs_outputs->psize != ATTR_UNUSED) {
+        stream_loc[tabi++] = 1;
+    }
+
+    /* Colors. */
+    for (i = 0; i < ATTR_COLOR_COUNT; i++) {
+        if (vs_outputs->color[i] != ATTR_UNUSED || any_bcolor_used) {
+            stream_loc[tabi++] = 2 + i;
+        }
+    }
+
+    /* Back-face colors. */
+    if (any_bcolor_used) {
+        for (i = 0; i < ATTR_COLOR_COUNT; i++) {
+            stream_loc[tabi++] = 4 + i;
         }
     }
 
-    tgsi_parse_free(&parser);
+    /* Texture coordinates. */
+    gen_count = 0;
+    for (i = 0; i < ATTR_GENERIC_COUNT; i++) {
+        if (vs_outputs->generic[i] != ATTR_UNUSED) {
+            assert(tabi < 16);
+            stream_loc[tabi++] = 6 + gen_count;
+            gen_count++;
+        }
+    }
+
+    /* Fog coordinates. */
+    if (vs_outputs->fog != ATTR_UNUSED) {
+        assert(tabi < 16);
+        stream_loc[tabi++] = 6 + gen_count;
+        gen_count++;
+    }
+
+    /* WPOS. */
+    if (vs_outputs->wpos != ATTR_UNUSED) {
+        assert(tabi < 16);
+        stream_loc[tabi++] = 6 + gen_count;
+        gen_count++;
+    }
+
+    for (; tabi < 16;) {
+        stream_loc[tabi++] = -1;
+    }
 }
 
+static void set_vertex_inputs_outputs(struct r300_vertex_program_compiler * c)
+{
+    struct r300_vertex_shader * vs = c->UserData;
+    struct r300_shader_semantics* outputs = &vs->outputs;
+    struct tgsi_shader_info* info = &vs->info;
+    int i, reg = 0;
+    boolean any_bcolor_used = outputs->bcolor[0] != ATTR_UNUSED ||
+                              outputs->bcolor[1] != ATTR_UNUSED;
+
+    /* Fill in the input mapping */
+    for (i = 0; i < info->num_inputs; i++)
+        c->code->inputs[i] = i;
+
+    /* Position. */
+    if (outputs->pos != ATTR_UNUSED) {
+        c->code->outputs[outputs->pos] = reg++;
+    } else {
+        assert(0);
+    }
+
+    /* Point size. */
+    if (outputs->psize != ATTR_UNUSED) {
+        c->code->outputs[outputs->psize] = 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.
+     */
+
+    /* Colors. */
+    for (i = 0; i < ATTR_COLOR_COUNT; i++) {
+        if (outputs->color[i] != ATTR_UNUSED) {
+            c->code->outputs[outputs->color[i]] = reg++;
+        } else if (any_bcolor_used) {
+            reg++;
+        }
+    }
+
+    /* Back-face colors. */
+    for (i = 0; i < ATTR_COLOR_COUNT; i++) {
+        if (outputs->bcolor[i] != ATTR_UNUSED) {
+            c->code->outputs[outputs->bcolor[i]] = reg++;
+        } else if (any_bcolor_used) {
+            reg++;
+        }
+    }
+
+    /* Texture coordinates. */
+    for (i = 0; i < ATTR_GENERIC_COUNT; i++) {
+        if (outputs->generic[i] != ATTR_UNUSED) {
+            c->code->outputs[outputs->generic[i]] = reg++;
+        }
+    }
+
+    /* Fog coordinates. */
+    if (outputs->fog != ATTR_UNUSED) {
+        c->code->outputs[outputs->fog] = reg++;
+    }
+
+    /* WPOS. */
+    if (outputs->wpos != ATTR_UNUSED) {
+        c->code->outputs[outputs->wpos] = reg++;
+    }
+}
+
+static void r300_insert_wpos(struct r300_vertex_program_compiler* c,
+                             struct r300_shader_semantics* outputs)
+{
+    int i, lastOutput = 0;
+
+    /* Find the max output index. */
+    lastOutput = MAX2(lastOutput, outputs->psize);
+    for (i = 0; i < ATTR_COLOR_COUNT; i++) {
+        lastOutput = MAX2(lastOutput, outputs->color[i]);
+        lastOutput = MAX2(lastOutput, outputs->bcolor[i]);
+    }
+    for (i = 0; i < ATTR_GENERIC_COUNT; i++) {
+        lastOutput = MAX2(lastOutput, outputs->generic[i]);
+    }
+    lastOutput = MAX2(lastOutput, outputs->fog);
+
+    /* Set WPOS after the last output. */
+    lastOutput++;
+    rc_copy_output(&c->Base, 0, lastOutput); /* out[lastOutput] = out[0]; */
+    outputs->wpos = lastOutput;
+}
 
 void r300_translate_vertex_shader(struct r300_context* r300,
                                   struct r300_vertex_shader* vs)
@@ -113,6 +319,9 @@ void r300_translate_vertex_shader(struct r300_context* r300,
     struct r300_vertex_program_compiler compiler;
     struct tgsi_to_rc ttr;
 
+    /* Initialize. */
+    r300_shader_read_vs_outputs(&vs->info, &vs->outputs);
+
     /* Setup the compiler */
     rc_init(&compiler.Base);
 
@@ -131,13 +340,19 @@ void r300_translate_vertex_shader(struct r300_context* r300,
 
     r300_tgsi_to_rc(&ttr, vs->state.tokens);
 
-    compiler.RequiredOutputs = ~(~0 << vs->info.num_outputs);
+    compiler.RequiredOutputs = ~(~0 << (vs->info.num_outputs+1));
     compiler.SetHwInputOutput = &set_vertex_inputs_outputs;
 
+    /* Insert the WPOS output. */
+    r300_insert_wpos(&compiler, &vs->outputs);
+
+    r300_shader_vap_output_fmt(vs);
+    r300_stream_locations_notcl(&vs->outputs, vs->stream_loc_notcl);
+
     /* Invoke the compiler */
     r3xx_compile_vertex_program(&compiler);
     if (compiler.Base.Error) {
-        /* Todo: Fail gracefully */
+        /* XXX We should fallback using Draw. */
         fprintf(stderr, "r300 VP: Compiler error\n");
         abort();
     }
@@ -147,88 +362,29 @@ void r300_translate_vertex_shader(struct r300_context* r300,
     vs->translated = TRUE;
 }
 
-
-/* XXX get these to r300_reg */
-#define R300_PVS_DST_OPCODE(x)   ((x) << 0)
-#   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)
-#   define R300_PVS_DST_REG_TEMPORARY     0
-#   define R300_PVS_DST_REG_A0            1
-#   define R300_PVS_DST_REG_OUT           2
-#   define R300_PVS_DST_REG_OUT_REPL_X    3
-#   define R300_PVS_DST_REG_ALT_TEMPORARY 4
-#   define R300_PVS_DST_REG_INPUT         5
-#define R300_PVS_DST_OFFSET(x)   ((x) << 13)
-#define R300_PVS_DST_WE(x)       ((x) << 20)
-#define R300_PVS_DST_WE_XYZW     (0xf << 20)
-
-#define R300_PVS_SRC_REG_TYPE(x) ((x) << 0)
-#   define R300_PVS_SRC_REG_TEMPORARY     0
-#   define R300_PVS_SRC_REG_INPUT         1
-#   define R300_PVS_SRC_REG_CONSTANT      2
-#   define R300_PVS_SRC_REG_ALT_TEMPORARY 3
-#define R300_PVS_SRC_OFFSET(x)   ((x) << 5)
-#define R300_PVS_SRC_SWIZZLE(x)  ((x) << 13)
-#   define R300_PVS_SRC_SELECT_X          0
-#   define R300_PVS_SRC_SELECT_Y          1
-#   define R300_PVS_SRC_SELECT_Z          2
-#   define R300_PVS_SRC_SELECT_W          3
-#   define R300_PVS_SRC_SELECT_FORCE_0    4
-#   define R300_PVS_SRC_SELECT_FORCE_1    5
-#   define R300_PVS_SRC_SWIZZLE_XYZW \
-    ((R300_PVS_SRC_SELECT_X | (R300_PVS_SRC_SELECT_Y << 3) | \
-     (R300_PVS_SRC_SELECT_Z << 6) | (R300_PVS_SRC_SELECT_W << 9)) << 13)
-#   define R300_PVS_SRC_SWIZZLE_ZERO \
-    ((R300_PVS_SRC_SELECT_FORCE_0 | (R300_PVS_SRC_SELECT_FORCE_0 << 3) | \
-     (R300_PVS_SRC_SELECT_FORCE_0 << 6) | \
-      (R300_PVS_SRC_SELECT_FORCE_0 << 9)) << 13)
-#   define R300_PVS_SRC_SWIZZLE_ONE \
-    ((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)
-
-struct r300_vertex_program_code r300_passthrough_vertex_shader = {
-    .length = 8, /* two instructions */
-
-    /* MOV out[0], in[0] */
-    .body.d[0] = R300_PVS_DST_OPCODE(R300_VE_ADD) |
-        R300_PVS_DST_REG_TYPE(R300_PVS_DST_REG_OUT) |
-        R300_PVS_DST_OFFSET(0) | R300_PVS_DST_WE_XYZW,
-    .body.d[1] = R300_PVS_SRC_REG_TYPE(R300_PVS_SRC_REG_INPUT) |
-        R300_PVS_SRC_OFFSET(0) | R300_PVS_SRC_SWIZZLE_XYZW,
-    .body.d[2] = R300_PVS_SRC_SWIZZLE_ZERO,
-    .body.d[3] = 0x0,
-
-    /* MOV out[1], in[1] */
-    .body.d[4] = R300_PVS_DST_OPCODE(R300_VE_ADD) |
-        R300_PVS_DST_REG_TYPE(R300_PVS_DST_REG_OUT) |
-        R300_PVS_DST_OFFSET(1) | R300_PVS_DST_WE_XYZW,
-    .body.d[5] = R300_PVS_SRC_REG_TYPE(R300_PVS_SRC_REG_INPUT) |
-        R300_PVS_SRC_OFFSET(1) | R300_PVS_SRC_SWIZZLE_XYZW,
-    .body.d[6] = R300_PVS_SRC_SWIZZLE_ZERO,
-    .body.d[7] = 0x0,
-
-    .inputs[0] = 0,
-    .inputs[1] = 1,
-    .outputs[0] = 0,
-    .outputs[1] = 1,
-
-    .InputsRead = 3,
-    .OutputsWritten = 3
-};
-
+boolean r300_vertex_shader_setup_wpos(struct r300_context* r300)
+{
+    struct r300_vertex_shader* vs = r300->vs;
+    int tex_output = r300->vs->wpos_tex_output;
+    uint32_t tex_fmt = R300_INPUT_CNTL_TC0 << tex_output;
+    uint32_t* hwfmt = vs->hwfmt;
+
+    if (r300->fs->inputs.wpos != ATTR_UNUSED) {
+        /* Enable WPOS in VAP. */
+        if (!(hwfmt[1] & tex_fmt)) {
+            hwfmt[1] |= tex_fmt;
+            hwfmt[3] |= (4 << (3 * tex_output));
+
+            assert(tex_output < 8);
+            return TRUE;
+        }
+    } else {
+        /* Disable WPOS in VAP. */
+        if (hwfmt[1] & tex_fmt) {
+            hwfmt[1] &= ~tex_fmt;
+            hwfmt[3] &= ~(4 << (3 * tex_output));
+            return TRUE;
+        }
+    }
+    return FALSE;
+}
index 2a4ce315e3213c06f85244d9ddffd8e381e95538..18cfeee3cd457e62f84414e455cb097d42caa654 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright 2009 Corbin Simpson <MostAwesomeDude@gmail.com>
+ * Copyright 2009 Marek Olšák <maraeo@gmail.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
 
 #include "pipe/p_state.h"
 #include "tgsi/tgsi_scan.h"
-
 #include "radeon_code.h"
 
+#include "r300_shader_semantics.h"
+
 struct r300_context;
 
 struct r300_vertex_shader {
     /* Parent class */
     struct pipe_shader_state state;
+
     struct tgsi_shader_info info;
+    struct r300_shader_semantics outputs;
+    uint hwfmt[4];
+
+    /* Stream locations for SWTCL or if TCL is bypassed. */
+    int stream_loc_notcl[16];
 
-    /* Fallback shader, because Draw has issues */
-    struct draw_vertex_shader* draw;
+    /* Output stream location for WPOS. */
+    int wpos_tex_output;
 
     /* Has this shader been translated yet? */
     boolean translated;
@@ -45,10 +53,10 @@ struct r300_vertex_shader {
     struct r300_vertex_program_code code;
 };
 
-
-extern struct r300_vertex_program_code r300_passthrough_vertex_shader;
-
 void r300_translate_vertex_shader(struct r300_context* r300,
                                   struct r300_vertex_shader* vs);
 
+/* Return TRUE if VAP (hwfmt) needs to be re-emitted. */
+boolean r300_vertex_shader_setup_wpos(struct r300_context* r300);
+
 #endif /* R300_VS_H */
index f18ad75a47d8c6ef6ad1f60a08216407b29229d4..1ae6de70feeb8d460ab5c85c0a0fadf15dd37673 100644 (file)
@@ -35,67 +35,10 @@ extern "C" {
 #include "pipe/p_state.h"
 #include "pipe/internal/p_winsys_screen.h"
 
-struct r300_winsys {
-    /* Parent class */
-    struct pipe_winsys base;
-
-    /* Opaque Radeon-specific winsys object. */
-    void* radeon_winsys;
-
-    /* PCI ID */
-    uint32_t pci_id;
-
-    /* GB pipe count */
-    uint32_t gb_pipes;
-
-    /* GART size. */
-    uint32_t gart_size;
-
-    /* VRAM size. */
-    uint32_t vram_size;
-
-    /* Add a pipe_buffer to the list of buffer objects to validate. */
-    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. */
-    boolean (*validate)(struct r300_winsys* winsys);
-
-    /* Check to see if there's room for commands. */
-    boolean (*check_cs)(struct r300_winsys* winsys, int size);
-
-    /* Start a command emit. */
-    void (*begin_cs)(struct r300_winsys* winsys,
-                     int size,
-                     const char* file,
-                     const char* function,
-                     int line);
-
-    /* Write a dword to the command buffer. */
-    void (*write_cs_dword)(struct r300_winsys* winsys, uint32_t dword);
-
-    /* Write a relocated dword to the command buffer. */
-    void (*write_cs_reloc)(struct r300_winsys* winsys,
-                           struct pipe_buffer* bo,
-                           uint32_t rd,
-                           uint32_t wd,
-                           uint32_t flags);
-
-    /* Finish a command emit. */
-    void (*end_cs)(struct r300_winsys* winsys,
-                   const char* file,
-                   const char* function,
-                   int line);
-
-    /* Flush the CS. */
-    void (*flush_cs)(struct r300_winsys* winsys);
-};
+#include "radeon_winsys.h"
 
 struct pipe_context* r300_create_context(struct pipe_screen* screen,
-                                         struct r300_winsys* r300_winsys);
+                                         struct radeon_winsys* radeon_winsys);
 
 boolean r300_get_texture_buffer(struct pipe_texture* texture,
                                 struct pipe_buffer** buffer,
diff --git a/src/gallium/drivers/r300/r3xx_fs.c b/src/gallium/drivers/r300/r3xx_fs.c
deleted file mode 100644 (file)
index c1c1194..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
- *                Joakim Sindholt <opensource@zhasha.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. */
-
-#include "r3xx_fs.h"
-
-#include "r300_reg.h"
-
-struct rX00_fragment_program_code r3xx_passthrough_fragment_shader = {
-    .code.r300.alu.length = 1,
-    .code.r300.tex.length = 0,
-
-    .code.r300.config = 0,
-    .code.r300.pixsize = 0,
-    .code.r300.code_offset = 0,
-    .code.r300.code_addr[3] = R300_RGBA_OUT,
-
-    .code.r300.alu.inst[0].rgb_inst = R300_RGB_SWIZA(R300_ALU_ARGC_SRC0C_XYZ) |
-        R300_RGB_SWIZB(R300_ALU_ARGC_SRC0C_XYZ) |
-        R300_RGB_SWIZC(R300_ALU_ARGC_ZERO) |
-        R300_ALU_OUTC_CMP,
-    .code.r300.alu.inst[0].rgb_addr = R300_RGB_ADDR0(0) | R300_RGB_ADDR1(0) |
-        R300_RGB_ADDR2(0) | R300_ALU_DSTC_OUTPUT_XYZ,
-    .code.r300.alu.inst[0].alpha_inst = R300_ALPHA_SWIZA(R300_ALU_ARGA_SRC0A) |
-        R300_ALPHA_SWIZB(R300_ALU_ARGA_SRC0A) |
-        R300_ALPHA_SWIZC(R300_ALU_ARGA_ZERO) |
-        R300_ALU_OUTA_CMP,
-    .code.r300.alu.inst[0].alpha_addr = R300_ALPHA_ADDR0(0) |
-        R300_ALPHA_ADDR1(0) | R300_ALPHA_ADDR2(0) | R300_ALU_DSTA_OUTPUT,
-};
-
-struct rX00_fragment_program_code r3xx_texture_fragment_shader = {
-    .code.r300.alu.length = 1,
-    .code.r300.tex.length = 1,
-
-    .code.r300.config = R300_PFS_CNTL_FIRST_NODE_HAS_TEX,
-    .code.r300.pixsize = 0,
-    .code.r300.code_offset = 0,
-    .code.r300.code_addr[3] = R300_RGBA_OUT,
-
-    .code.r300.tex.inst[0] = R300_TEX_OP_LD << R300_TEX_INST_SHIFT,
-
-    .code.r300.alu.inst[0].rgb_inst = R300_RGB_SWIZA(R300_ALU_ARGC_SRC0C_XYZ) |
-        R300_RGB_SWIZB(R300_ALU_ARGC_SRC0C_XYZ) |
-        R300_RGB_SWIZC(R300_ALU_ARGC_ZERO) |
-        R300_ALU_OUTC_CMP,
-    .code.r300.alu.inst[0].rgb_addr = R300_RGB_ADDR0(0) | R300_RGB_ADDR1(0) |
-        R300_RGB_ADDR2(0) | R300_ALU_DSTC_OUTPUT_XYZ,
-    .code.r300.alu.inst[0].alpha_inst = R300_ALPHA_SWIZA(R300_ALU_ARGA_SRC0A) |
-        R300_ALPHA_SWIZB(R300_ALU_ARGA_SRC0A) |
-        R300_ALPHA_SWIZC(R300_ALU_ARGA_ZERO) |
-        R300_ALU_OUTA_CMP,
-    .code.r300.alu.inst[0].alpha_addr = R300_ALPHA_ADDR0(0) |
-        R300_ALPHA_ADDR1(0) | R300_ALPHA_ADDR2(0) | R300_ALU_DSTA_OUTPUT,
-};
diff --git a/src/gallium/drivers/r300/r3xx_fs.h b/src/gallium/drivers/r300/r3xx_fs.h
deleted file mode 100644 (file)
index 51cd245..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
- *                Joakim Sindholt <opensource@zhasha.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 R3XX_FS_H
-#define R3XX_FS_H
-
-#include "radeon_code.h"
-
-struct rX00_fragment_program_code r3xx_passthrough_fragment_shader;
-struct rX00_fragment_program_code r3xx_texture_fragment_shader;
-
-#endif /* R3XX_FS_H */
diff --git a/src/gallium/drivers/r300/r5xx_fs.c b/src/gallium/drivers/r300/r5xx_fs.c
deleted file mode 100644 (file)
index f072dea..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
- *                Joakim Sindholt <opensource@zhasha.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. */
-
-#include "r5xx_fs.h"
-
-#include "r300_reg.h"
-
-/* XXX this all should find its way back to r300_reg */
-/* Swizzle tools */
-#define R500_SWIZZLE_ZERO 4
-#define R500_SWIZZLE_HALF 5
-#define R500_SWIZZLE_ONE 6
-#define R500_SWIZ_RGB_ZERO ((4 << 0) | (4 << 3) | (4 << 6))
-#define R500_SWIZ_RGB_ONE ((6 << 0) | (6 << 3) | (6 << 6))
-#define R500_SWIZ_RGB_RGB ((0 << 0) | (1 << 3) | (2 << 6))
-#define R500_SWIZ_MOD_NEG 1
-#define R500_SWIZ_MOD_ABS 2
-#define R500_SWIZ_MOD_NEG_ABS 3
-/* Swizzles for inst2 */
-#define R500_SWIZ_TEX_STRQ(x) ((x) << 8)
-#define R500_SWIZ_TEX_RGBA(x) ((x) << 24)
-/* Swizzles for inst3 */
-#define R500_SWIZ_RGB_A(x) ((x) << 2)
-#define R500_SWIZ_RGB_B(x) ((x) << 15)
-/* Swizzles for inst4 */
-#define R500_SWIZ_ALPHA_A(x) ((x) << 14)
-#define R500_SWIZ_ALPHA_B(x) ((x) << 21)
-/* Swizzle for inst5 */
-#define R500_SWIZ_RGBA_C(x) ((x) << 14)
-#define R500_SWIZ_ALPHA_C(x) ((x) << 27)
-/* Writemasks */
-#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)
-
-struct rX00_fragment_program_code r5xx_passthrough_fragment_shader = {
-    .code.r500.max_temp_idx = 0,
-    .code.r500.inst_end = 0,
-
-    .code.r500.inst[0].inst0 = R500_INST_TYPE_OUT |
-        R500_INST_TEX_SEM_WAIT | R500_INST_LAST |
-        R500_INST_RGB_OMASK_RGB | R500_INST_ALPHA_OMASK |
-        R500_INST_RGB_CLAMP | R500_INST_ALPHA_CLAMP,
-    .code.r500.inst[0].inst1 =
-        R500_RGB_ADDR0(0) | R500_RGB_ADDR1(0) | R500_RGB_ADDR1_CONST |
-        R500_RGB_ADDR2(0) | R500_RGB_ADDR2_CONST,
-    .code.r500.inst[0].inst2 =
-        R500_ALPHA_ADDR0(0) | R500_ALPHA_ADDR1(0) | R500_ALPHA_ADDR1_CONST |
-        R500_ALPHA_ADDR2(0) | R500_ALPHA_ADDR2_CONST,
-    .code.r500.inst[0].inst3 =
-        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,
-    .code.r500.inst[0].inst4 =
-        R500_ALPHA_OP_CMP | R500_ALPHA_SWIZ_A_A | R500_ALPHA_SWIZ_B_A,
-    .code.r500.inst[0].inst5 =
-        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,
-};
-
-struct rX00_fragment_program_code r5xx_texture_fragment_shader = {
-    .code.r500.max_temp_idx = 0,
-    .code.r500.inst_end = 1,
-
-    .code.r500.inst[0].inst0 = R500_INST_TYPE_TEX |
-        R500_INST_TEX_SEM_WAIT |
-        R500_INST_RGB_WMASK_RGB | R500_INST_ALPHA_WMASK |
-        R500_INST_RGB_CLAMP | R500_INST_ALPHA_CLAMP,
-    .code.r500.inst[0].inst1 = R500_TEX_ID(0) | R500_TEX_INST_LD |
-        R500_TEX_SEM_ACQUIRE | R500_TEX_IGNORE_UNCOVERED,
-    .code.r500.inst[0].inst2 = R500_TEX_SRC_ADDR(0) |
-        R500_TEX_SRC_S_SWIZ_R | R500_TEX_SRC_T_SWIZ_G |
-        R500_TEX_SRC_R_SWIZ_B | R500_TEX_SRC_Q_SWIZ_A |
-        R500_TEX_DST_ADDR(0) |
-        R500_TEX_DST_R_SWIZ_R | R500_TEX_DST_G_SWIZ_G |
-        R500_TEX_DST_B_SWIZ_B | R500_TEX_DST_A_SWIZ_A,
-    .code.r500.inst[0].inst3 = 0x0,
-    .code.r500.inst[0].inst4 = 0x0,
-    .code.r500.inst[0].inst5 = 0x0,
-
-    .code.r500.inst[1].inst0 = R500_INST_TYPE_OUT |
-        R500_INST_TEX_SEM_WAIT | R500_INST_LAST |
-        R500_INST_RGB_OMASK_RGB | R500_INST_ALPHA_OMASK |
-        R500_INST_RGB_CLAMP | R500_INST_ALPHA_CLAMP,
-    .code.r500.inst[1].inst1 =
-        R500_RGB_ADDR0(0) | R500_RGB_ADDR1(0) | R500_RGB_ADDR1_CONST |
-        R500_RGB_ADDR2(0) | R500_RGB_ADDR2_CONST,
-    .code.r500.inst[1].inst2 =
-        R500_ALPHA_ADDR0(0) | R500_ALPHA_ADDR1(0) | R500_ALPHA_ADDR1_CONST |
-        R500_ALPHA_ADDR2(0) | R500_ALPHA_ADDR2_CONST,
-    .code.r500.inst[1].inst3 =
-        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,
-    .code.r500.inst[1].inst4 =
-        R500_ALPHA_OP_CMP | R500_ALPHA_SWIZ_A_A | R500_ALPHA_SWIZ_B_A,
-    .code.r500.inst[1].inst5 =
-        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,
-};
diff --git a/src/gallium/drivers/r300/r5xx_fs.h b/src/gallium/drivers/r300/r5xx_fs.h
deleted file mode 100644 (file)
index a4addde..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
- *                Joakim Sindholt <opensource@zhasha.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 R5XX_FS_H
-#define R5XX_FS_H
-
-#include "radeon_code.h"
-
-struct rX00_fragment_program_code r5xx_passthrough_fragment_shader;
-struct rX00_fragment_program_code r5xx_texture_fragment_shader;
-
-#endif /* R5XX_FS_H */
index 8fac8e6e05ffd528510f699f6f4b6a5c50be9854..5f130453c3968da6d2dc106325bd06208fc22799 100644 (file)
@@ -36,6 +36,7 @@
 #include "util/u_pack_color.h"
 #include "sp_clear.h"
 #include "sp_context.h"
+#include "sp_query.h"
 #include "sp_tile_cache.h"
 
 
@@ -48,12 +49,16 @@ softpipe_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba,
                double depth, unsigned stencil)
 {
    struct softpipe_context *softpipe = softpipe_context(pipe);
+   union util_color uc;
    unsigned cv;
    uint i;
 
    if (softpipe->no_rast)
       return;
 
+   if (!softpipe_check_render_cond(softpipe))
+      return;
+
 #if 0
    softpipe_update_derived(softpipe); /* not needed?? */
 #endif
@@ -62,12 +67,12 @@ softpipe_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba,
       for (i = 0; i < softpipe->framebuffer.nr_cbufs; i++) {
          struct pipe_surface *ps = softpipe->framebuffer.cbufs[i];
 
-         util_pack_color(rgba, ps->format, &cv);
-         sp_tile_cache_clear(softpipe->cbuf_cache[i], rgba, cv);
+         util_pack_color(rgba, ps->format, &uc);
+         sp_tile_cache_clear(softpipe->cbuf_cache[i], rgba, uc.ui);
 
 #if !TILE_CLEAR_OPTIMIZATION
          /* non-cached surface */
-         pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, cv);
+         pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, uc.ui);
 #endif
       }
    }
index 94d000a5accacf0a20110bd3704e16f64bacd5a3..f3ac6760db5494d6c34365b100f7a8cf9d87e4bc 100644 (file)
@@ -90,14 +90,15 @@ softpipe_destroy( struct pipe_context *pipe )
    if (softpipe->draw)
       draw_destroy( softpipe->draw );
 
-      softpipe->quad.shade->destroy( softpipe->quad.shade );
-      softpipe->quad.depth_test->destroy( softpipe->quad.depth_test );
-      softpipe->quad.blend->destroy( softpipe->quad.blend );
+   softpipe->quad.shade->destroy( softpipe->quad.shade );
+   softpipe->quad.depth_test->destroy( softpipe->quad.depth_test );
+   softpipe->quad.blend->destroy( softpipe->quad.blend );
 
    for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
       sp_destroy_tile_cache(softpipe->cbuf_cache[i]);
       pipe_surface_reference(&softpipe->framebuffer.cbufs[i], NULL);
    }
+
    sp_destroy_tile_cache(softpipe->zsbuf_cache);
    pipe_surface_reference(&softpipe->framebuffer.zsbuf, NULL);
 
@@ -106,6 +107,11 @@ softpipe_destroy( struct pipe_context *pipe )
       pipe_texture_reference(&softpipe->texture[i], NULL);
    }
 
+   for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
+      sp_destroy_tex_tile_cache(softpipe->vertex_tex_cache[i]);
+      pipe_texture_reference(&softpipe->vertex_textures[i], NULL);
+   }
+
    for (i = 0; i < Elements(softpipe->constants); i++) {
       if (softpipe->constants[i].buffer) {
          pipe_buffer_reference(&softpipe->constants[i].buffer, NULL);
@@ -120,7 +126,7 @@ softpipe_destroy( struct pipe_context *pipe )
  * if (the texture is being used as a framebuffer surface)
  *    return PIPE_REFERENCED_FOR_WRITE
  * else if (the texture is a bound texture source)
- *    return PIPE_REFERENCED_FOR_READ  XXX not done yet
+ *    return PIPE_REFERENCED_FOR_READ
  * else
  *    return PIPE_UNREFERENCED
  */
@@ -132,6 +138,7 @@ softpipe_is_texture_referenced( struct pipe_context *pipe,
    struct softpipe_context *softpipe = softpipe_context( pipe );
    unsigned i;
 
+   /* check if any of the bound drawing surfaces are this texture */
    if (softpipe->dirty_render_cache) {
       for (i = 0; i < softpipe->framebuffer.nr_cbufs; i++) {
          if (softpipe->framebuffer.cbufs[i] && 
@@ -145,7 +152,17 @@ softpipe_is_texture_referenced( struct pipe_context *pipe,
       }
    }
    
-   /* FIXME: we also need to do the same for the texture cache */
+   /* check if any of the tex_cache textures are this texture */
+   for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
+      if (softpipe->tex_cache[i] &&
+          softpipe->tex_cache[i]->texture == texture)
+         return PIPE_REFERENCED_FOR_READ;
+   }
+   for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
+      if (softpipe->vertex_tex_cache[i] &&
+          softpipe->vertex_tex_cache[i]->texture == texture)
+         return PIPE_REFERENCED_FOR_READ;
+   }
    
    return PIPE_UNREFERENCED;
 }
@@ -159,6 +176,19 @@ softpipe_is_buffer_referenced( struct pipe_context *pipe,
 }
 
 
+static void
+softpipe_render_condition( struct pipe_context *pipe,
+                           struct pipe_query *query,
+                           uint mode )
+{
+   struct softpipe_context *softpipe = softpipe_context( pipe );
+
+   softpipe->render_cond_query = query;
+   softpipe->render_cond_mode = mode;
+}
+
+
+
 struct pipe_context *
 softpipe_create( struct pipe_screen *screen )
 {
@@ -174,6 +204,7 @@ softpipe_create( struct pipe_screen *screen )
 #endif
 
    softpipe->dump_fs = debug_get_bool_option( "GALLIUM_DUMP_FS", FALSE );
+   softpipe->dump_gs = debug_get_bool_option( "SOFTPIPE_DUMP_GS", FALSE );
 
    softpipe->pipe.winsys = screen->winsys;
    softpipe->pipe.screen = screen;
@@ -185,7 +216,8 @@ softpipe_create( struct pipe_screen *screen )
    softpipe->pipe.delete_blend_state = softpipe_delete_blend_state;
 
    softpipe->pipe.create_sampler_state = softpipe_create_sampler_state;
-   softpipe->pipe.bind_sampler_states  = softpipe_bind_sampler_states;
+   softpipe->pipe.bind_fragment_sampler_states  = softpipe_bind_sampler_states;
+   softpipe->pipe.bind_vertex_sampler_states = softpipe_bind_vertex_sampler_states;
    softpipe->pipe.delete_sampler_state = softpipe_delete_sampler_state;
 
    softpipe->pipe.create_depth_stencil_alpha_state = softpipe_create_depth_stencil_state;
@@ -204,13 +236,18 @@ softpipe_create( struct pipe_screen *screen )
    softpipe->pipe.bind_vs_state   = softpipe_bind_vs_state;
    softpipe->pipe.delete_vs_state = softpipe_delete_vs_state;
 
+   softpipe->pipe.create_gs_state = softpipe_create_gs_state;
+   softpipe->pipe.bind_gs_state   = softpipe_bind_gs_state;
+   softpipe->pipe.delete_gs_state = softpipe_delete_gs_state;
+
    softpipe->pipe.set_blend_color = softpipe_set_blend_color;
    softpipe->pipe.set_clip_state = softpipe_set_clip_state;
    softpipe->pipe.set_constant_buffer = softpipe_set_constant_buffer;
    softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state;
    softpipe->pipe.set_polygon_stipple = softpipe_set_polygon_stipple;
    softpipe->pipe.set_scissor_state = softpipe_set_scissor_state;
-   softpipe->pipe.set_sampler_textures = softpipe_set_sampler_textures;
+   softpipe->pipe.set_fragment_sampler_textures = softpipe_set_sampler_textures;
+   softpipe->pipe.set_vertex_sampler_textures = softpipe_set_vertex_sampler_textures;
    softpipe->pipe.set_viewport_state = softpipe_set_viewport_state;
 
    softpipe->pipe.set_vertex_buffers = softpipe_set_vertex_buffers;
@@ -219,8 +256,6 @@ softpipe_create( struct pipe_screen *screen )
    softpipe->pipe.draw_arrays = softpipe_draw_arrays;
    softpipe->pipe.draw_elements = softpipe_draw_elements;
    softpipe->pipe.draw_range_elements = softpipe_draw_range_elements;
-   softpipe->pipe.set_edgeflags = softpipe_set_edgeflags;
-
 
    softpipe->pipe.clear = softpipe_clear;
    softpipe->pipe.flush = softpipe_flush;
@@ -230,6 +265,8 @@ softpipe_create( struct pipe_screen *screen )
 
    softpipe_init_query_funcs( softpipe );
 
+   softpipe->pipe.render_condition = softpipe_render_condition;
+
    /*
     * Alloc caches for accessing drawing surfaces and textures.
     * Must be before quad stage setup!
@@ -240,12 +277,14 @@ softpipe_create( struct pipe_screen *screen )
 
    for (i = 0; i < PIPE_MAX_SAMPLERS; i++)
       softpipe->tex_cache[i] = sp_create_tex_tile_cache( screen );
-
+   for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
+      softpipe->vertex_tex_cache[i] = sp_create_tex_tile_cache(screen);
+   }
 
    /* setup quad rendering stages */
-      softpipe->quad.shade = sp_quad_shade_stage(softpipe);
-      softpipe->quad.depth_test = sp_quad_depth_test_stage(softpipe);
-      softpipe->quad.blend = sp_quad_blend_stage(softpipe);
+   softpipe->quad.shade = sp_quad_shade_stage(softpipe);
+   softpipe->quad.depth_test = sp_quad_depth_test_stage(softpipe);
+   softpipe->quad.blend = sp_quad_blend_stage(softpipe);
 
 
    /*
@@ -256,7 +295,7 @@ softpipe_create( struct pipe_screen *screen )
       goto fail;
 
    draw_texture_samplers(softpipe->draw,
-                         PIPE_MAX_SAMPLERS,
+                         PIPE_MAX_VERTEX_SAMPLERS,
                          (struct tgsi_sampler **)
                             softpipe->tgsi.vert_samplers_list);
 
@@ -275,7 +314,6 @@ softpipe_create( struct pipe_screen *screen )
    draw_set_render(softpipe->draw, softpipe->vbuf_backend);
 
 
-
    /* plug in AA line/point stages */
    draw_install_aaline_stage(softpipe->draw, &softpipe->pipe);
    draw_install_aapoint_stage(softpipe->draw, &softpipe->pipe);
@@ -291,4 +329,3 @@ softpipe_create( struct pipe_screen *screen )
    softpipe_destroy(&softpipe->pipe);
    return NULL;
 }
-
index a735573d6fbe432012c6637ecf9cb10efc4764f0..73fa744f9d4805a7ca2185f212fe9a7dd7fdb38f 100644 (file)
@@ -53,10 +53,12 @@ struct softpipe_context {
    /** Constant state objects */
    struct pipe_blend_state *blend;
    struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS];
+   struct pipe_sampler_state *vertex_samplers[PIPE_MAX_VERTEX_SAMPLERS];
    struct pipe_depth_stencil_alpha_state *depth_stencil;
    struct pipe_rasterizer_state *rasterizer;
    struct sp_fragment_shader *fs;
    struct sp_vertex_shader *vs;
+   struct sp_geometry_shader *gs;
 
    /** Other rendering state */
    struct pipe_blend_color blend_color;
@@ -66,12 +68,15 @@ struct softpipe_context {
    struct pipe_poly_stipple poly_stipple;
    struct pipe_scissor_state scissor;
    struct pipe_texture *texture[PIPE_MAX_SAMPLERS];
+   struct pipe_texture *vertex_textures[PIPE_MAX_VERTEX_SAMPLERS];
    struct pipe_viewport_state viewport;
    struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
    struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS];
 
    unsigned num_samplers;
    unsigned num_textures;
+   unsigned num_vertex_samplers;
+   unsigned num_vertex_textures;
    unsigned num_vertex_elements;
    unsigned num_vertex_buffers;
 
@@ -111,6 +116,10 @@ struct softpipe_context {
 
    unsigned line_stipple_counter;
 
+   /** Conditional query object and mode */
+   struct pipe_query *render_cond_query;
+   uint render_cond_mode;
+
    /** Software quad rendering pipeline */
    struct {
       struct quad_stage *shade;
@@ -121,7 +130,7 @@ struct softpipe_context {
 
    /** TGSI exec things */
    struct {
-      struct sp_sampler_varient *vert_samplers_list[PIPE_MAX_SAMPLERS];
+      struct sp_sampler_varient *vert_samplers_list[PIPE_MAX_VERTEX_SAMPLERS];
       struct sp_sampler_varient *frag_samplers_list[PIPE_MAX_SAMPLERS];
    } tgsi;
 
@@ -139,9 +148,11 @@ struct softpipe_context {
 
    unsigned tex_timestamp;
    struct softpipe_tex_tile_cache *tex_cache[PIPE_MAX_SAMPLERS];
+   struct softpipe_tex_tile_cache *vertex_tex_cache[PIPE_MAX_VERTEX_SAMPLERS];
 
    unsigned use_sse : 1;
    unsigned dump_fs : 1;
+   unsigned dump_gs : 1;
    unsigned no_rast : 1;
 };
 
index d4045816d03ed7a428d8ea6849d057ad84c3b956..03d35fb3cb59e4a4cef97d4bbf651020ffd5e313 100644 (file)
@@ -38,6 +38,7 @@
 #include "util/u_prim.h"
 
 #include "sp_context.h"
+#include "sp_query.h"
 #include "sp_state.h"
 
 #include "draw/draw_context.h"
@@ -48,7 +49,7 @@ static void
 softpipe_map_constant_buffers(struct softpipe_context *sp)
 {
    struct pipe_winsys *ws = sp->pipe.winsys;
-   uint i, size;
+   uint i, vssize, gssize;
 
    for (i = 0; i < PIPE_SHADER_TYPES; i++) {
       if (sp->constants[i].buffer && sp->constants[i].buffer->size)
@@ -57,13 +58,21 @@ softpipe_map_constant_buffers(struct softpipe_context *sp)
    }
 
    if (sp->constants[PIPE_SHADER_VERTEX].buffer)
-      size = sp->constants[PIPE_SHADER_VERTEX].buffer->size;
+      vssize = sp->constants[PIPE_SHADER_VERTEX].buffer->size;
    else
-      size = 0;
+      vssize = 0;
 
-   draw_set_mapped_constant_buffer(sp->draw,
+   if (sp->constants[PIPE_SHADER_GEOMETRY].buffer)
+      gssize = sp->constants[PIPE_SHADER_GEOMETRY].buffer->size;
+   else
+      gssize = 0;
+
+   draw_set_mapped_constant_buffer(sp->draw, PIPE_SHADER_VERTEX,
                                    sp->mapped_constants[PIPE_SHADER_VERTEX],
-                                   size);
+                                   vssize);
+   draw_set_mapped_constant_buffer(sp->draw, PIPE_SHADER_GEOMETRY,
+                                   sp->mapped_constants[PIPE_SHADER_GEOMETRY],
+                                   gssize);
 }
 
 
@@ -78,9 +87,10 @@ softpipe_unmap_constant_buffers(struct softpipe_context *sp)
     */
    draw_flush(sp->draw);
 
-   draw_set_mapped_constant_buffer(sp->draw, NULL, 0);
+   draw_set_mapped_constant_buffer(sp->draw, PIPE_SHADER_VERTEX, NULL, 0);
+   draw_set_mapped_constant_buffer(sp->draw, PIPE_SHADER_GEOMETRY, NULL, 0);
 
-   for (i = 0; i < 2; i++) {
+   for (i = 0; i < PIPE_SHADER_TYPES; i++) {
       if (sp->constants[i].buffer && sp->constants[i].buffer->size)
          ws->buffer_unmap(ws, sp->constants[i].buffer);
       sp->mapped_constants[i] = NULL;
@@ -88,11 +98,11 @@ softpipe_unmap_constant_buffers(struct softpipe_context *sp)
 }
 
 
-boolean
+void
 softpipe_draw_arrays(struct pipe_context *pipe, unsigned mode,
                      unsigned start, unsigned count)
 {
-   return softpipe_draw_elements(pipe, NULL, 0, mode, start, count);
+   softpipe_draw_elements(pipe, NULL, 0, mode, start, count);
 }
 
 
@@ -101,7 +111,7 @@ softpipe_draw_arrays(struct pipe_context *pipe, unsigned mode,
  * Basically, map the vertex buffers (and drawing surfaces), then hand off
  * the drawing to the 'draw' module.
  */
-boolean
+void
 softpipe_draw_range_elements(struct pipe_context *pipe,
                              struct pipe_buffer *indexBuffer,
                              unsigned indexSize,
@@ -113,6 +123,9 @@ softpipe_draw_range_elements(struct pipe_context *pipe,
    struct draw_context *draw = sp->draw;
    unsigned i;
 
+   if (!softpipe_check_render_cond(sp))
+      return;
+
    sp->reduced_api_prim = u_reduced_prim(mode);
 
    if (sp->dirty)
@@ -168,27 +181,17 @@ softpipe_draw_range_elements(struct pipe_context *pipe,
    softpipe_unmap_constant_buffers(sp);
 
    sp->dirty_render_cache = TRUE;
-   
-   return TRUE;
 }
 
 
-boolean
+void
 softpipe_draw_elements(struct pipe_context *pipe,
                        struct pipe_buffer *indexBuffer,
                        unsigned indexSize,
                        unsigned mode, unsigned start, unsigned count)
 {
-   return softpipe_draw_range_elements( pipe, indexBuffer,
-                                        indexSize,
-                                        0, 0xffffffff,
-                                        mode, start, count );
-}
-
-
-void
-softpipe_set_edgeflags(struct pipe_context *pipe, const unsigned *edgeflags)
-{
-   struct softpipe_context *sp = softpipe_context(pipe);
-   draw_set_edgeflags(sp->draw, edgeflags);
+   softpipe_draw_range_elements( pipe, indexBuffer,
+                                 indexSize,
+                                 0, 0xffffffff,
+                                 mode, start, count );
 }
index e38b767cf2c03fed2b9177f1dbb5f69e803f9042..75dac810a12afe00d5b33abaed4974abe6cf5680 100644 (file)
@@ -55,6 +55,9 @@ softpipe_flush( struct pipe_context *pipe,
       for (i = 0; i < softpipe->num_textures; i++) {
          sp_flush_tex_tile_cache(softpipe->tex_cache[i]);
       }
+      for (i = 0; i < softpipe->num_vertex_textures; i++) {
+         sp_flush_tex_tile_cache(softpipe->vertex_tex_cache[i]);
+      }
    }
 
    if (flags & PIPE_FLUSH_SWAPBUFFERS) {
index 4076114d392a894165e5e6c3419eb63fc4d6a0e5..27fa126b7c391e5e8e77e34b74af414b804c9206 100644 (file)
@@ -126,7 +126,10 @@ exec_run( const struct sp_fragment_shader *base,
    setup_pos_vector(quad->posCoef, 
                     (float)quad->input.x0, (float)quad->input.y0, 
                     &machine->QuadPos);
-   
+
+   /* convert 0 to 1.0 and 1 to -1.0 */
+   machine->Face = (float) (quad->input.facing * -2 + 1);
+
    quad->inout.mask &= tgsi_exec_machine_run( machine );
    if (quad->inout.mask == 0)
       return FALSE;
index 5fbac06a535ff4231aa782f4414929d2e8133c5b..7f573aef3c361dd781c7c33877a3e9f89825791b 100644 (file)
@@ -128,6 +128,7 @@ sp_vbuf_unmap_vertices(struct vbuf_render *vbr,
 {
    struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr);
    assert( cvbr->vertex_buffer_size >= (max_index+1) * cvbr->vertex_size );
+   (void) cvbr;
    /* do nothing */
 }
 
index e243c63fa23efd256cc19c3e780c81ed4097d086..d9babe81dad5d165e10a19fafabd412ad654ae86 100644 (file)
@@ -229,7 +229,7 @@ blend_quad(struct quad_stage *qs,
    static const float zero[4] = { 0, 0, 0, 0 };
    static const float one[4] = { 1, 1, 1, 1 };
    struct softpipe_context *softpipe = qs->softpipe;
-   float source[4][QUAD_SIZE];
+   float source[4][QUAD_SIZE] = { { 0 } };
 
    /*
     * Compute src/first term RGB
@@ -478,7 +478,15 @@ blend_quad(struct quad_stage *qs,
       VEC4_MUL(dest[2], dest[2], dest[2]); /* B */
       break;
    case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
-      assert(0); /* illegal */
+   {
+      const float *alpha = quadColor[3];
+      float diff[4], temp[4];
+      VEC4_SUB(diff, one, dest[3]);
+      VEC4_MIN(temp, alpha, diff);
+      VEC4_MUL(dest[0], quadColor[0], temp); /* R */
+      VEC4_MUL(dest[1], quadColor[1], temp); /* G */
+      VEC4_MUL(dest[2], quadColor[2], temp); /* B */
+   }
       break;
    case PIPE_BLENDFACTOR_CONST_COLOR:
    {
@@ -600,7 +608,7 @@ blend_quad(struct quad_stage *qs,
       VEC4_MUL(dest[3], dest[3], dest[3]); /* A */
       break;
    case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
-      assert(0); /* illegal */
+      /* dest = dest * 1   NO-OP, leave dest as-is */
       break;
    case PIPE_BLENDFACTOR_CONST_COLOR:
       /* fall-through */
@@ -946,15 +954,15 @@ choose_blend_quad(struct quad_stage *qs,
       qs->run = blend_noop;
    }
    else if (!softpipe->blend->logicop_enable &&
-            softpipe->blend->colormask == 0xf) 
+            softpipe->blend->colormask == 0xf &&
+            softpipe->framebuffer.nr_cbufs == 1)
    {
       if (!blend->blend_enable) {
          qs->run = single_output_color;
       }
       else if (blend->rgb_src_factor == blend->alpha_src_factor &&
                blend->rgb_dst_factor == blend->alpha_dst_factor &&
-               blend->rgb_func == blend->alpha_func &&
-               softpipe->framebuffer.nr_cbufs == 1)
+               blend->rgb_func == blend->alpha_func)
       {
          if (blend->alpha_func == PIPE_BLEND_ADD) {
             if (blend->rgb_src_factor == PIPE_BLENDFACTOR_ONE &&
index 379cf4ad064d201f35d12bea4e8b7bf53a001a98..4ef5d9f7b1db3e3172bd272d72b5ce4e5647722d 100644 (file)
@@ -99,6 +99,32 @@ softpipe_get_query_result(struct pipe_context *pipe,
 }
 
 
+/**
+ * Called by rendering function to check rendering is conditional.
+ * \return TRUE if we should render, FALSE if we should skip rendering
+ */
+boolean
+softpipe_check_render_cond(struct softpipe_context *sp)
+{
+   struct pipe_context *pipe = &sp->pipe;
+   boolean b, wait;
+   uint64_t result;
+
+   if (!sp->render_cond_query) {
+      return TRUE;  /* no query predicate, draw normally */
+   }
+
+   wait = (sp->render_cond_mode == PIPE_RENDER_COND_WAIT ||
+           sp->render_cond_mode == PIPE_RENDER_COND_BY_REGION_WAIT);
+
+   b = pipe->get_query_result(pipe, sp->render_cond_query, wait, &result);
+   if (b)
+      return result > 0;
+   else
+      return TRUE;
+}
+
+
 void softpipe_init_query_funcs(struct softpipe_context *softpipe )
 {
    softpipe->pipe.create_query = softpipe_create_query;
index 05060a457593ab979e2565e65039ab0e947d0424..736c033897e27b0d7f1a67d3f9c31fb081dca313 100644 (file)
 #ifndef SP_QUERY_H
 #define SP_QUERY_H
 
+extern boolean
+softpipe_check_render_cond(struct softpipe_context *sp);
+
+
 struct softpipe_context;
 extern void softpipe_init_query_funcs(struct softpipe_context * );
 
index 81fb7aa20c67e2ec4c1fdeffc0800ab071ab63c2..bd3532de4f445f1b90ad4581c5a3c11619e5714a 100644 (file)
@@ -58,7 +58,9 @@ softpipe_get_param(struct pipe_screen *screen, int param)
    case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
       return PIPE_MAX_SAMPLERS;
    case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS:
-      return PIPE_MAX_SAMPLERS;
+      return PIPE_MAX_VERTEX_SAMPLERS;
+   case PIPE_CAP_MAX_COMBINED_SAMPLERS:
+      return PIPE_MAX_SAMPLERS + PIPE_MAX_VERTEX_SAMPLERS;
    case PIPE_CAP_NPOT_TEXTURES:
       return 1;
    case PIPE_CAP_TWO_SIDED_STENCIL:
@@ -143,6 +145,11 @@ softpipe_is_format_supported( struct pipe_screen *screen,
    case PIPE_FORMAT_DXT3_RGBA:
    case PIPE_FORMAT_DXT5_RGBA:
    case PIPE_FORMAT_Z32_FLOAT:
+   case PIPE_FORMAT_R8G8_SNORM:
+   case PIPE_FORMAT_B6UG5SR5S_NORM:
+   case PIPE_FORMAT_X8UB8UG8SR8S_NORM:
+   case PIPE_FORMAT_A8B8G8R8_SNORM:
+   case PIPE_FORMAT_NONE:
       return FALSE;
    default:
       return TRUE;
index e55e209fd1567bd5fcf6d5e247f960c8aecff78a..3da75364c5d7090c274244e47768408ce5d96dd7 100644 (file)
@@ -87,6 +87,8 @@ struct setup_context {
    float oneoverarea;
    int facing;
 
+   float pixel_offset;
+
    struct quad_header quad[MAX_QUADS];
    struct quad_header *quad_ptrs[MAX_QUADS];
    unsigned count;
@@ -106,6 +108,7 @@ struct setup_context {
 #endif
 
    unsigned winding;           /* which winding to cull */
+   unsigned nr_vertex_attrs;
 };
 
 
@@ -268,8 +271,8 @@ static void print_vertex(const struct setup_context *setup,
                          const float (*v)[4])
 {
    int i;
-   debug_printf("   Vertex: (%p)\n", v);
-   for (i = 0; i < setup->quad[0].nr_attrs; i++) {
+   debug_printf("   Vertex: (%p)\n", (void *) v);
+   for (i = 0; i < setup->nr_vertex_attrs; i++) {
       debug_printf("     %d: %f %f %f %f\n",  i,
               v[i][0], v[i][1], v[i][2], v[i][3]);
       if (util_is_inf_or_nan(v[i][0])) {
@@ -378,6 +381,16 @@ static boolean setup_sort_vertices( struct setup_context *setup,
       ((det > 0.0) ^ 
        (setup->softpipe->rasterizer->front_winding == PIPE_WINDING_CW));
 
+   /* Prepare pixel offset for rasterisation:
+    *  - pixel center (0.5, 0.5) for GL, or
+    *  - assume (0.0, 0.0) for other APIs.
+    */
+   if (setup->softpipe->rasterizer->gl_rasterization_rules) {
+      setup->pixel_offset = 0.5f;
+   } else {
+      setup->pixel_offset = 0.0f;
+   }
+
    return TRUE;
 }
 
@@ -426,7 +439,7 @@ static void tri_linear_coeff( struct setup_context *setup,
 
    /* calculate a0 as the value which would be sampled for the
     * fragment at (0,0), taking into account that we want to sample at
-    * pixel centers, in other words (0.5, 0.5).
+    * pixel centers, in other words (pixel_offset, pixel_offset).
     *
     * this is neat but unfortunately not a good way to do things for
     * triangles with very large values of dadx or dady as it will
@@ -437,8 +450,8 @@ static void tri_linear_coeff( struct setup_context *setup,
     * instead - i'll switch to this later.
     */
    coef->a0[i] = (setup->vmin[vertSlot][i] -
-                  (dadx * (setup->vmin[0][0] - 0.5f) +
-                   dady * (setup->vmin[0][1] - 0.5f)));
+                  (dadx * (setup->vmin[0][0] - setup->pixel_offset) +
+                   dady * (setup->vmin[0][1] - setup->pixel_offset)));
 
    /*
    debug_printf("attr[%d].%c: %f dx:%f dy:%f\n",
@@ -486,8 +499,8 @@ static void tri_persp_coeff( struct setup_context *setup,
    coef->dadx[i] = dadx;
    coef->dady[i] = dady;
    coef->a0[i] = (mina -
-                  (dadx * (setup->vmin[0][0] - 0.5f) +
-                   dady * (setup->vmin[0][1] - 0.5f)));
+                  (dadx * (setup->vmin[0][0] - setup->pixel_offset) +
+                   dady * (setup->vmin[0][1] - setup->pixel_offset)));
 }
 
 
@@ -574,12 +587,12 @@ static void setup_tri_coefficients( struct setup_context *setup )
 
 static void setup_tri_edges( struct setup_context *setup )
 {
-   float vmin_x = setup->vmin[0][0] + 0.5f;
-   float vmid_x = setup->vmid[0][0] + 0.5f;
+   float vmin_x = setup->vmin[0][0] + setup->pixel_offset;
+   float vmid_x = setup->vmid[0][0] + setup->pixel_offset;
 
-   float vmin_y = setup->vmin[0][1] - 0.5f;
-   float vmid_y = setup->vmid[0][1] - 0.5f;
-   float vmax_y = setup->vmax[0][1] - 0.5f;
+   float vmin_y = setup->vmin[0][1] - setup->pixel_offset;
+   float vmid_y = setup->vmid[0][1] - setup->pixel_offset;
+   float vmax_y = setup->vmax[0][1] - setup->pixel_offset;
 
    setup->emaj.sy = ceilf(vmin_y);
    setup->emaj.lines = (int) ceilf(vmax_y - setup->emaj.sy);
@@ -779,8 +792,8 @@ line_linear_coeff(const struct setup_context *setup,
    coef->dadx[i] = dadx;
    coef->dady[i] = dady;
    coef->a0[i] = (setup->vmin[vertSlot][i] -
-                  (dadx * (setup->vmin[0][0] - 0.5f) +
-                   dady * (setup->vmin[0][1] - 0.5f)));
+                  (dadx * (setup->vmin[0][0] - setup->pixel_offset) +
+                   dady * (setup->vmin[0][1] - setup->pixel_offset)));
 }
 
 
@@ -802,8 +815,8 @@ line_persp_coeff(const struct setup_context *setup,
    coef->dadx[i] = dadx;
    coef->dady[i] = dady;
    coef->a0[i] = (setup->vmin[vertSlot][i] -
-                  (dadx * (setup->vmin[0][0] - 0.5f) +
-                   dady * (setup->vmin[0][1] - 0.5f)));
+                  (dadx * (setup->vmin[0][0] - setup->pixel_offset) +
+                   dady * (setup->vmin[0][1] - setup->pixel_offset)));
 }
 
 
@@ -1254,6 +1267,9 @@ void sp_setup_prepare( struct setup_context *setup )
       softpipe_update_derived(sp);
    }
 
+   /* Note: nr_attrs is only used for debugging (vertex printing) */
+   setup->nr_vertex_attrs = draw_num_shader_outputs(sp->draw);
+
    sp->quad.first->begin( sp->quad.first );
 
    if (sp->reduced_api_prim == PIPE_PRIM_TRIANGLES &&
index 77ee3c1136bba64015eec2e157d1a70e2ef2aae8..9b18dac67bd0c1a8ac17931f989fe84f9248560c 100644 (file)
@@ -50,6 +50,7 @@
 #define SP_NEW_VERTEX        0x1000
 #define SP_NEW_VS            0x2000
 #define SP_NEW_QUERY         0x4000
+#define SP_NEW_GS            0x8000
 
 
 struct tgsi_sampler;
@@ -90,6 +91,11 @@ struct sp_vertex_shader {
    int max_sampler;             /* -1 if no samplers */
 };
 
+/** Subclass of pipe_shader_state */
+struct sp_geometry_shader {
+   struct pipe_shader_state shader;
+   struct draw_geometry_shader *draw_data;
+};
 
 
 void *
@@ -104,6 +110,10 @@ void *
 softpipe_create_sampler_state(struct pipe_context *,
                               const struct pipe_sampler_state *);
 void softpipe_bind_sampler_states(struct pipe_context *, unsigned, void **);
+void
+softpipe_bind_vertex_sampler_states(struct pipe_context *,
+                                    unsigned num_samplers,
+                                    void **samplers);
 void softpipe_delete_sampler_state(struct pipe_context *, void *);
 
 void *
@@ -139,6 +149,10 @@ void *softpipe_create_vs_state(struct pipe_context *,
                                const struct pipe_shader_state *);
 void softpipe_bind_vs_state(struct pipe_context *, void *);
 void softpipe_delete_vs_state(struct pipe_context *, void *);
+void *softpipe_create_gs_state(struct pipe_context *,
+                               const struct pipe_shader_state *);
+void softpipe_bind_gs_state(struct pipe_context *, void *);
+void softpipe_delete_gs_state(struct pipe_context *, void *);
 
 void softpipe_set_polygon_stipple( struct pipe_context *,
                                  const struct pipe_poly_stipple * );
@@ -150,6 +164,11 @@ void softpipe_set_sampler_textures( struct pipe_context *,
                                     unsigned num,
                                     struct pipe_texture ** );
 
+void
+softpipe_set_vertex_sampler_textures(struct pipe_context *,
+                                     unsigned num_textures,
+                                     struct pipe_texture **);
+
 void softpipe_set_viewport_state( struct pipe_context *,
                                   const struct pipe_viewport_state * );
 
@@ -165,14 +184,14 @@ void softpipe_set_vertex_buffers(struct pipe_context *,
 void softpipe_update_derived( struct softpipe_context *softpipe );
 
 
-boolean softpipe_draw_arrays(struct pipe_context *pipe, unsigned mode,
-                            unsigned start, unsigned count);
+void softpipe_draw_arrays(struct pipe_context *pipe, unsigned mode,
+                          unsigned start, unsigned count);
 
-boolean softpipe_draw_elements(struct pipe_context *pipe,
-                              struct pipe_buffer *indexBuffer,
-                              unsigned indexSize,
-                              unsigned mode, unsigned start, unsigned count);
-boolean
+void softpipe_draw_elements(struct pipe_context *pipe,
+                            struct pipe_buffer *indexBuffer,
+                            unsigned indexSize,
+                            unsigned mode, unsigned start, unsigned count);
+void
 softpipe_draw_range_elements(struct pipe_context *pipe,
                              struct pipe_buffer *indexBuffer,
                              unsigned indexSize,
@@ -180,10 +199,6 @@ softpipe_draw_range_elements(struct pipe_context *pipe,
                              unsigned max_index,
                              unsigned mode, unsigned start, unsigned count);
 
-void
-softpipe_set_edgeflags(struct pipe_context *pipe, const unsigned *edgeflags);
-
-
 void
 softpipe_map_transfers(struct softpipe_context *sp);
 
index efed082f823f05d8c383a933d642b0a517af7b84..95ab32343375aaf76c592a12e478b68fa3604d1f 100644 (file)
@@ -29,6 +29,7 @@
  */
 
 #include "util/u_memory.h"
+#include "draw/draw_context.h"
 #include "sp_context.h"
 #include "sp_state.h"
 
@@ -45,6 +46,8 @@ void softpipe_bind_blend_state( struct pipe_context *pipe,
 {
    struct softpipe_context *softpipe = softpipe_context(pipe);
 
+   draw_flush(softpipe->draw);
+
    softpipe->blend = (struct pipe_blend_state *)blend;
 
    softpipe->dirty |= SP_NEW_BLEND;
@@ -62,6 +65,8 @@ void softpipe_set_blend_color( struct pipe_context *pipe,
 {
    struct softpipe_context *softpipe = softpipe_context(pipe);
 
+   draw_flush(softpipe->draw);
+
    softpipe->blend_color = *blend_color;
 
    softpipe->dirty |= SP_NEW_BLEND;
index 1faeca1c2a34d3d9a65ec6e0e265fddc011270df..f6856a5f69102dd22bf1d5649840f5057a1bbdaf 100644 (file)
@@ -66,10 +66,8 @@ softpipe_get_vertex_info(struct softpipe_context *softpipe)
    if (vinfo->num_attribs == 0) {
       /* compute vertex layout now */
       const struct sp_fragment_shader *spfs = softpipe->fs;
-      const enum interp_mode colorInterp
-         = softpipe->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR;
       struct vertex_info *vinfo_vbuf = &softpipe->vertex_info_vbuf;
-      const uint num = draw_num_vs_outputs(softpipe->draw);
+      const uint num = draw_current_shader_outputs(softpipe->draw);
       uint i;
 
       /* Tell draw_vbuf to simply emit the whole post-xform vertex
@@ -108,36 +106,24 @@ softpipe_get_vertex_info(struct softpipe_context *softpipe)
 
          switch (spfs->info.input_semantic_name[i]) {
          case TGSI_SEMANTIC_POSITION:
-            src = draw_find_vs_output(softpipe->draw,
-                                      TGSI_SEMANTIC_POSITION, 0);
-            draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_POS, src);
+            interp = INTERP_POS;
             break;
 
          case TGSI_SEMANTIC_COLOR:
-            src = draw_find_vs_output(softpipe->draw, TGSI_SEMANTIC_COLOR, 
-                                 spfs->info.input_semantic_index[i]);
-            draw_emit_vertex_attr(vinfo, EMIT_4F, colorInterp, src);
+            if (softpipe->rasterizer->flatshade) {
+               interp = INTERP_CONSTANT;
+            }
             break;
-
-         case TGSI_SEMANTIC_FOG:
-            src = draw_find_vs_output(softpipe->draw, TGSI_SEMANTIC_FOG, 0);
-            draw_emit_vertex_attr(vinfo, EMIT_4F, interp, src);
-            break;
-
-         case TGSI_SEMANTIC_GENERIC:
-         case TGSI_SEMANTIC_FACE:
-            /* this includes texcoords and varying vars */
-            src = draw_find_vs_output(softpipe->draw, TGSI_SEMANTIC_GENERIC,
-                                      spfs->info.input_semantic_index[i]);
-            draw_emit_vertex_attr(vinfo, EMIT_4F, interp, src);
-            break;
-
-         default:
-            assert(0);
          }
+
+         /* this includes texcoords and varying vars */
+         src = draw_find_shader_output(softpipe->draw,
+                                       spfs->info.input_semantic_name[i],
+                                       spfs->info.input_semantic_index[i]);
+         draw_emit_vertex_attr(vinfo, EMIT_4F, interp, src);
       }
 
-      softpipe->psize_slot = draw_find_vs_output(softpipe->draw,
+      softpipe->psize_slot = draw_find_shader_output(softpipe->draw,
                                                  TGSI_SEMANTIC_PSIZE, 0);
       if (softpipe->psize_slot > 0) {
          draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_CONSTANT,
@@ -227,6 +213,19 @@ update_tgsi_samplers( struct softpipe_context *softpipe )
          }
       }
    }
+
+   for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
+      struct softpipe_tex_tile_cache *tc = softpipe->vertex_tex_cache[i];
+
+      if (tc->texture) {
+         struct softpipe_texture *spt = softpipe_texture(tc->texture);
+
+         if (spt->timestamp != tc->timestamp) {
+           sp_tex_tile_cache_validate_texture(tc);
+            tc->timestamp = spt->timestamp;
+         }
+      }
+   }
 }
 
 
index 256faa94b84207cda61ca4b27bdb712cd3a4a8eb..aa12bb215a8e4db13f842fe73099a83824ebb134 100644 (file)
@@ -69,7 +69,14 @@ softpipe_bind_fs_state(struct pipe_context *pipe, void *fs)
 {
    struct softpipe_context *softpipe = softpipe_context(pipe);
 
-   softpipe->fs = (struct sp_fragment_shader *) fs;
+   draw_flush(softpipe->draw);
+
+   if (softpipe->fs == fs)
+      return;
+
+   draw_flush(softpipe->draw);
+
+   softpipe->fs = fs;
 
    softpipe->dirty |= SP_NEW_FS;
 }
@@ -143,6 +150,7 @@ softpipe_delete_vs_state(struct pipe_context *pipe, void *vs)
    struct sp_vertex_shader *state = (struct sp_vertex_shader *) vs;
 
    draw_delete_vertex_shader(softpipe->draw, state->draw_data);
+   FREE( (void *)state->shader.tokens );
    FREE( state );
 }
 
@@ -158,9 +166,75 @@ softpipe_set_constant_buffer(struct pipe_context *pipe,
    assert(shader < PIPE_SHADER_TYPES);
    assert(index == 0);
 
+   draw_flush(softpipe->draw);
+
    /* note: reference counting */
    pipe_buffer_reference(&softpipe->constants[shader].buffer,
                         buf ? buf->buffer : NULL);
 
    softpipe->dirty |= SP_NEW_CONSTANTS;
 }
+
+void *
+softpipe_create_gs_state(struct pipe_context *pipe,
+                         const struct pipe_shader_state *templ)
+{
+   struct softpipe_context *softpipe = softpipe_context(pipe);
+   struct sp_geometry_shader *state;
+
+   state = CALLOC_STRUCT(sp_geometry_shader);
+   if (state == NULL )
+      goto fail;
+
+   /* debug */
+   if (softpipe->dump_gs)
+      tgsi_dump(templ->tokens, 0);
+
+   /* copy shader tokens, the ones passed in will go away.
+    */
+   state->shader.tokens = tgsi_dup_tokens(templ->tokens);
+   if (state->shader.tokens == NULL)
+      goto fail;
+
+   state->draw_data = draw_create_geometry_shader(softpipe->draw, templ);
+   if (state->draw_data == NULL)
+      goto fail;
+
+   return state;
+
+fail:
+   if (state) {
+      FREE( (void *)state->shader.tokens );
+      FREE( state->draw_data );
+      FREE( state );
+   }
+   return NULL;
+}
+
+
+void
+softpipe_bind_gs_state(struct pipe_context *pipe, void *gs)
+{
+   struct softpipe_context *softpipe = softpipe_context(pipe);
+
+   softpipe->gs = (struct sp_geometry_shader *)gs;
+
+   draw_bind_geometry_shader(softpipe->draw,
+                             (softpipe->gs ? softpipe->gs->draw_data : NULL));
+
+   softpipe->dirty |= SP_NEW_GS;
+}
+
+
+void
+softpipe_delete_gs_state(struct pipe_context *pipe, void *gs)
+{
+   struct softpipe_context *softpipe = softpipe_context(pipe);
+
+   struct sp_geometry_shader *state =
+      (struct sp_geometry_shader *)gs;
+
+   draw_delete_geometry_shader(softpipe->draw,
+                               (state) ? state->draw_data : 0);
+   FREE(state);
+}
index 87b72196838f6865df06890f0ca3dd6639160b2d..a5b00336d44d9d6660244beab73110ea9d1ddcdf 100644 (file)
@@ -41,14 +41,17 @@ softpipe_create_rasterizer_state(struct pipe_context *pipe,
 }
 
 void softpipe_bind_rasterizer_state(struct pipe_context *pipe,
-                                    void *setup)
+                                    void *rasterizer)
 {
    struct softpipe_context *softpipe = softpipe_context(pipe);
 
+   if (softpipe->rasterizer == rasterizer)
+      return;
+
    /* pass-through to draw module */
-   draw_set_rasterizer_state(softpipe->draw, setup);
+   draw_set_rasterizer_state(softpipe->draw, rasterizer);
 
-   softpipe->rasterizer = (struct pipe_rasterizer_state *)setup;
+   softpipe->rasterizer = rasterizer;
 
    softpipe->dirty |= SP_NEW_RASTERIZER;
 }
index db0b8ab76b1722a039b99cb779cf956f927c4e78..ceb4e338f1a5b4c893387975d5c8cf21ed14ecd0 100644 (file)
@@ -93,6 +93,34 @@ softpipe_bind_sampler_states(struct pipe_context *pipe,
 }
 
 
+void
+softpipe_bind_vertex_sampler_states(struct pipe_context *pipe,
+                                    unsigned num_samplers,
+                                    void **samplers)
+{
+   struct softpipe_context *softpipe = softpipe_context(pipe);
+   unsigned i;
+
+   assert(num_samplers <= PIPE_MAX_VERTEX_SAMPLERS);
+
+   /* Check for no-op */
+   if (num_samplers == softpipe->num_vertex_samplers &&
+       !memcmp(softpipe->vertex_samplers, samplers, num_samplers * sizeof(void *)))
+      return;
+
+   draw_flush(softpipe->draw);
+
+   for (i = 0; i < num_samplers; ++i)
+      softpipe->vertex_samplers[i] = samplers[i];
+   for (i = num_samplers; i < PIPE_MAX_VERTEX_SAMPLERS; ++i)
+      softpipe->vertex_samplers[i] = NULL;
+
+   softpipe->num_vertex_samplers = num_samplers;
+
+   softpipe->dirty |= SP_NEW_SAMPLER;
+}
+
+
 void
 softpipe_set_sampler_textures(struct pipe_context *pipe,
                               unsigned num, struct pipe_texture **texture)
@@ -122,6 +150,37 @@ softpipe_set_sampler_textures(struct pipe_context *pipe,
 }
 
 
+void
+softpipe_set_vertex_sampler_textures(struct pipe_context *pipe,
+                                     unsigned num_textures,
+                                     struct pipe_texture **textures)
+{
+   struct softpipe_context *softpipe = softpipe_context(pipe);
+   uint i;
+
+   assert(num_textures <= PIPE_MAX_VERTEX_SAMPLERS);
+
+   /* Check for no-op */
+   if (num_textures == softpipe->num_vertex_textures &&
+       !memcmp(softpipe->vertex_textures, textures, num_textures * sizeof(struct pipe_texture *))) {
+      return;
+   }
+
+   draw_flush(softpipe->draw);
+
+   for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
+      struct pipe_texture *tex = i < num_textures ? textures[i] : NULL;
+
+      pipe_texture_reference(&softpipe->vertex_textures[i], tex);
+      sp_tex_tile_cache_set_texture(softpipe->vertex_tex_cache[i], tex);
+   }
+
+   softpipe->num_vertex_textures = num_textures;
+
+   softpipe->dirty |= SP_NEW_TEXTURE;
+}
+
+
 /**
  * Find/create an sp_sampler_varient object for sampling the given texture,
  * sampler and tex unit.
@@ -185,16 +244,16 @@ softpipe_reset_sampler_varients(struct softpipe_context *softpipe)
     * fragment programs.
     */
    for (i = 0; i <= softpipe->vs->max_sampler; i++) {
-      if (softpipe->sampler[i]) {
+      if (softpipe->vertex_samplers[i]) {
          softpipe->tgsi.vert_samplers_list[i] = 
             get_sampler_varient( i,
-                                 sp_sampler(softpipe->sampler[i]),
-                                 softpipe->texture[i],
+                                sp_sampler(softpipe->vertex_samplers[i]),
+                                softpipe->vertex_textures[i],
                                  TGSI_PROCESSOR_VERTEX );
 
          sp_sampler_varient_bind_texture( softpipe->tgsi.vert_samplers_list[i], 
-                                          softpipe->tex_cache[i],
-                                          softpipe->texture[i] );
+                                         softpipe->vertex_tex_cache[i],
+                                         softpipe->vertex_textures[i] );
       }
    }
 
index bc0e2011300910c1af2a434562d0361f29c595de..f6154109ea831dae4d555249261bd46de91f96f9 100644 (file)
@@ -35,6 +35,8 @@
 
 #include "draw/draw_context.h"
 
+#include "util/u_format.h"
+
 
 /**
  * XXX this might get moved someday
@@ -49,6 +51,8 @@ softpipe_set_framebuffer_state(struct pipe_context *pipe,
    struct softpipe_context *sp = softpipe_context(pipe);
    uint i;
 
+   draw_flush(sp->draw);
+
    for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
       /* check if changing cbuf */
       if (sp->framebuffer.cbufs[i] != fb->cbufs[i]) {
@@ -80,8 +84,9 @@ softpipe_set_framebuffer_state(struct pipe_context *pipe,
       if (sp->framebuffer.zsbuf) {
          int depth_bits;
          double mrd;
-         depth_bits = pf_get_component_bits(sp->framebuffer.zsbuf->format,
-                                            PIPE_FORMAT_COMP_Z);
+         depth_bits = util_format_get_component_bits(sp->framebuffer.zsbuf->format,
+                                                     UTIL_FORMAT_COLORSPACE_ZS,
+                                                     0);
          if (depth_bits > 16) {
             mrd = 0.0000001;
          }
index c22ee86b66c4f670375ffcb796b24c6e3498b5b3..1ae8fecacf7706c46bf80d732d0c440d7a887f1a 100644 (file)
@@ -2,7 +2,7 @@
  * 
  * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
  * All Rights Reserved.
- * Copyright 2008 VMware, Inc.  All rights reserved.
+ * Copyright 2008-2010 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
@@ -514,21 +514,15 @@ static float
 compute_lambda_1d(const struct sp_sampler_varient *samp,
                   const float s[QUAD_SIZE],
                   const float t[QUAD_SIZE],
-                  const float p[QUAD_SIZE],
-                  float lodbias)
+                  const float p[QUAD_SIZE])
 {
    const struct pipe_texture *texture = samp->texture;
    const struct pipe_sampler_state *sampler = samp->sampler;
    float dsdx = fabsf(s[QUAD_BOTTOM_RIGHT] - s[QUAD_BOTTOM_LEFT]);
    float dsdy = fabsf(s[QUAD_TOP_LEFT]     - s[QUAD_BOTTOM_LEFT]);
-   float rho = MAX2(dsdx, dsdy) * texture->width[0];
-   float lambda;
-
-   lambda = util_fast_log2(rho);
-   lambda += lodbias + sampler->lod_bias;
-   lambda = CLAMP(lambda, sampler->min_lod, sampler->max_lod);
+   float rho = MAX2(dsdx, dsdy) * texture->width0;
 
-   return lambda;
+   return util_fast_log2(rho);
 }
 
 
@@ -536,8 +530,7 @@ static float
 compute_lambda_2d(const struct sp_sampler_varient *samp,
                   const float s[QUAD_SIZE],
                   const float t[QUAD_SIZE],
-                  const float p[QUAD_SIZE],
-                  float lodbias)
+                  const float p[QUAD_SIZE])
 {
    const struct pipe_texture *texture = samp->texture;
    const struct pipe_sampler_state *sampler = samp->sampler;
@@ -545,16 +538,11 @@ compute_lambda_2d(const struct sp_sampler_varient *samp,
    float dsdy = fabsf(s[QUAD_TOP_LEFT]     - s[QUAD_BOTTOM_LEFT]);
    float dtdx = fabsf(t[QUAD_BOTTOM_RIGHT] - t[QUAD_BOTTOM_LEFT]);
    float dtdy = fabsf(t[QUAD_TOP_LEFT]     - t[QUAD_BOTTOM_LEFT]);
-   float maxx = MAX2(dsdx, dsdy) * texture->width[0];
-   float maxy = MAX2(dtdx, dtdy) * texture->height[0];
+   float maxx = MAX2(dsdx, dsdy) * texture->width0;
+   float maxy = MAX2(dtdx, dtdy) * texture->height0;
    float rho  = MAX2(maxx, maxy);
-   float lambda;
 
-   lambda = util_fast_log2(rho);
-   lambda += lodbias + sampler->lod_bias;
-   lambda = CLAMP(lambda, sampler->min_lod, sampler->max_lod);
-
-   return lambda;
+   return util_fast_log2(rho);
 }
 
 
@@ -562,8 +550,7 @@ static float
 compute_lambda_3d(const struct sp_sampler_varient *samp,
                   const float s[QUAD_SIZE],
                   const float t[QUAD_SIZE],
-                  const float p[QUAD_SIZE],
-                  float lodbias)
+                  const float p[QUAD_SIZE])
 {
    const struct pipe_texture *texture = samp->texture;
    const struct pipe_sampler_state *sampler = samp->sampler;
@@ -573,34 +560,29 @@ compute_lambda_3d(const struct sp_sampler_varient *samp,
    float dtdy = fabsf(t[QUAD_TOP_LEFT]     - t[QUAD_BOTTOM_LEFT]);
    float dpdx = fabsf(p[QUAD_BOTTOM_RIGHT] - p[QUAD_BOTTOM_LEFT]);
    float dpdy = fabsf(p[QUAD_TOP_LEFT]     - p[QUAD_BOTTOM_LEFT]);
-   float maxx = MAX2(dsdx, dsdy) * texture->width[0];
-   float maxy = MAX2(dtdx, dtdy) * texture->height[0];
-   float maxz = MAX2(dpdx, dpdy) * texture->depth[0];
-   float rho, lambda;
+   float maxx = MAX2(dsdx, dsdy) * texture->width0;
+   float maxy = MAX2(dtdx, dtdy) * texture->height0;
+   float maxz = MAX2(dpdx, dpdy) * texture->depth0;
+   float rho;
 
    rho = MAX2(maxx, maxy);
    rho = MAX2(rho, maxz);
 
-   lambda = util_fast_log2(rho);
-   lambda += lodbias + sampler->lod_bias;
-   lambda = CLAMP(lambda, sampler->min_lod, sampler->max_lod);
-
-   return lambda;
+   return util_fast_log2(rho);
 }
 
 
 /**
  * Compute lambda for a vertex texture sampler.
- * Since there aren't derivatives to use, just return the LOD bias.
+ * Since there aren't derivatives to use, just return 0.
  */
 static float
 compute_lambda_vert(const struct sp_sampler_varient *samp,
                     const float s[QUAD_SIZE],
                     const float t[QUAD_SIZE],
-                    const float p[QUAD_SIZE],
-                    float lodbias)
+                    const float p[QUAD_SIZE])
 {
-   return lodbias;
+   return 0.0f;
 }
 
 
@@ -644,8 +626,8 @@ get_texel_2d(const struct sp_sampler_varient *samp,
    const struct pipe_texture *texture = samp->texture;
    unsigned level = addr.bits.level;
 
-   if (x < 0 || x >= (int) texture->width[level] ||
-       y < 0 || y >= (int) texture->height[level]) {
+   if (x < 0 || x >= (int) u_minify(texture->width0, level) ||
+       y < 0 || y >= (int) u_minify(texture->height0, level)) {
       return samp->sampler->border_color;
    }
    else {
@@ -737,9 +719,9 @@ get_texel_3d(const struct sp_sampler_varient *samp,
    const struct pipe_texture *texture = samp->texture;
    unsigned level = addr.bits.level;
 
-   if (x < 0 || x >= (int) texture->width[level] ||
-       y < 0 || y >= (int) texture->height[level] ||
-       z < 0 || z >= (int) texture->depth[level]) {
+   if (x < 0 || x >= (int) u_minify(texture->width0, level) ||
+       y < 0 || y >= (int) u_minify(texture->height0, level) ||
+       z < 0 || z >= (int) u_minify(texture->depth0, level)) {
       return samp->sampler->border_color;
    }
    else {
@@ -769,7 +751,8 @@ img_filter_2d_linear_repeat_POT(struct tgsi_sampler *tgsi_sampler,
                                 const float s[QUAD_SIZE],
                                 const float t[QUAD_SIZE],
                                 const float p[QUAD_SIZE],
-                                float lodbias,
+                                const float c0[QUAD_SIZE],
+                                enum tgsi_sampler_control control,
                                 float rgba[NUM_CHANNELS][QUAD_SIZE])
 {
    const struct sp_sampler_varient *samp = sp_sampler_varient(tgsi_sampler);
@@ -827,7 +810,8 @@ img_filter_2d_nearest_repeat_POT(struct tgsi_sampler *tgsi_sampler,
                                  const float s[QUAD_SIZE],
                                  const float t[QUAD_SIZE],
                                  const float p[QUAD_SIZE],
-                                 float lodbias,
+                                 const float c0[QUAD_SIZE],
+                                 enum tgsi_sampler_control control,
                                  float rgba[NUM_CHANNELS][QUAD_SIZE])
 {
    const struct sp_sampler_varient *samp = sp_sampler_varient(tgsi_sampler);
@@ -866,7 +850,8 @@ img_filter_2d_nearest_clamp_POT(struct tgsi_sampler *tgsi_sampler,
                                 const float s[QUAD_SIZE],
                                 const float t[QUAD_SIZE],
                                 const float p[QUAD_SIZE],
-                                float lodbias,
+                                const float c0[QUAD_SIZE],
+                                enum tgsi_sampler_control control,
                                 float rgba[NUM_CHANNELS][QUAD_SIZE])
 {
    const struct sp_sampler_varient *samp = sp_sampler_varient(tgsi_sampler);
@@ -914,7 +899,8 @@ img_filter_1d_nearest(struct tgsi_sampler *tgsi_sampler,
                         const float s[QUAD_SIZE],
                         const float t[QUAD_SIZE],
                         const float p[QUAD_SIZE],
-                        float lodbias,
+                        const float c0[QUAD_SIZE],
+                        enum tgsi_sampler_control control,
                         float rgba[NUM_CHANNELS][QUAD_SIZE])
 {
    const struct sp_sampler_varient *samp = sp_sampler_varient(tgsi_sampler);
@@ -925,7 +911,7 @@ img_filter_1d_nearest(struct tgsi_sampler *tgsi_sampler,
    union tex_tile_address addr;
 
    level0 = samp->level;
-   width = texture->width[level0];
+   width = u_minify(texture->width0, level0);
 
    assert(width > 0);
 
@@ -949,7 +935,8 @@ img_filter_2d_nearest(struct tgsi_sampler *tgsi_sampler,
                       const float s[QUAD_SIZE],
                       const float t[QUAD_SIZE],
                       const float p[QUAD_SIZE],
-                      float lodbias,
+                      const float c0[QUAD_SIZE],
+                      enum tgsi_sampler_control control,
                       float rgba[NUM_CHANNELS][QUAD_SIZE])
 {
    const struct sp_sampler_varient *samp = sp_sampler_varient(tgsi_sampler);
@@ -961,8 +948,8 @@ img_filter_2d_nearest(struct tgsi_sampler *tgsi_sampler,
 
 
    level0 = samp->level;
-   width = texture->width[level0];
-   height = texture->height[level0];
+   width = u_minify(texture->width0, level0);
+   height = u_minify(texture->height0, level0);
 
    assert(width > 0);
    assert(height > 0);
@@ -996,7 +983,8 @@ img_filter_cube_nearest(struct tgsi_sampler *tgsi_sampler,
                         const float s[QUAD_SIZE],
                         const float t[QUAD_SIZE],
                         const float p[QUAD_SIZE],
-                        float lodbias,
+                        const float c0[QUAD_SIZE],
+                        enum tgsi_sampler_control control,
                         float rgba[NUM_CHANNELS][QUAD_SIZE])
 {
    const struct sp_sampler_varient *samp = sp_sampler_varient(tgsi_sampler);
@@ -1008,8 +996,8 @@ img_filter_cube_nearest(struct tgsi_sampler *tgsi_sampler,
    union tex_tile_address addr;
 
    level0 = samp->level;
-   width = texture->width[level0];
-   height = texture->height[level0];
+   width = u_minify(texture->width0, level0);
+   height = u_minify(texture->height0, level0);
 
    assert(width > 0);
    assert(height > 0);
@@ -1035,7 +1023,8 @@ img_filter_3d_nearest(struct tgsi_sampler *tgsi_sampler,
                       const float s[QUAD_SIZE],
                       const float t[QUAD_SIZE],
                       const float p[QUAD_SIZE],
-                      float lodbias,
+                      const float c0[QUAD_SIZE],
+                      enum tgsi_sampler_control control,
                       float rgba[NUM_CHANNELS][QUAD_SIZE])
 {
    const struct sp_sampler_varient *samp = sp_sampler_varient(tgsi_sampler);
@@ -1046,9 +1035,9 @@ img_filter_3d_nearest(struct tgsi_sampler *tgsi_sampler,
    union tex_tile_address addr;
 
    level0 = samp->level;
-   width = texture->width[level0];
-   height = texture->height[level0];
-   depth = texture->depth[level0];
+   width = u_minify(texture->width0, level0);
+   height = u_minify(texture->height0, level0);
+   depth = u_minify(texture->depth0, level0);
 
    assert(width > 0);
    assert(height > 0);
@@ -1076,7 +1065,8 @@ img_filter_1d_linear(struct tgsi_sampler *tgsi_sampler,
                      const float s[QUAD_SIZE],
                      const float t[QUAD_SIZE],
                      const float p[QUAD_SIZE],
-                     float lodbias,
+                     const float c0[QUAD_SIZE],
+                     enum tgsi_sampler_control control,
                      float rgba[NUM_CHANNELS][QUAD_SIZE])
 {
    const struct sp_sampler_varient *samp = sp_sampler_varient(tgsi_sampler);
@@ -1088,7 +1078,7 @@ img_filter_1d_linear(struct tgsi_sampler *tgsi_sampler,
    union tex_tile_address addr;
 
    level0 = samp->level;
-   width = texture->width[level0];
+   width = u_minify(texture->width0, level0);
 
    assert(width > 0);
 
@@ -1115,7 +1105,8 @@ img_filter_2d_linear(struct tgsi_sampler *tgsi_sampler,
                      const float s[QUAD_SIZE],
                      const float t[QUAD_SIZE],
                      const float p[QUAD_SIZE],
-                     float lodbias,
+                     const float c0[QUAD_SIZE],
+                     enum tgsi_sampler_control control,
                      float rgba[NUM_CHANNELS][QUAD_SIZE])
 {
    const struct sp_sampler_varient *samp = sp_sampler_varient(tgsi_sampler);
@@ -1127,8 +1118,8 @@ img_filter_2d_linear(struct tgsi_sampler *tgsi_sampler,
    union tex_tile_address addr;
 
    level0 = samp->level;
-   width = texture->width[level0];
-   height = texture->height[level0];
+   width = u_minify(texture->width0, level0);
+   height = u_minify(texture->height0, level0);
 
    assert(width > 0);
    assert(height > 0);
@@ -1161,7 +1152,8 @@ img_filter_cube_linear(struct tgsi_sampler *tgsi_sampler,
                        const float s[QUAD_SIZE],
                        const float t[QUAD_SIZE],
                        const float p[QUAD_SIZE],
-                       float lodbias,
+                       const float c0[QUAD_SIZE],
+                       enum tgsi_sampler_control control,
                        float rgba[NUM_CHANNELS][QUAD_SIZE])
 {
    const struct sp_sampler_varient *samp = sp_sampler_varient(tgsi_sampler);
@@ -1174,8 +1166,8 @@ img_filter_cube_linear(struct tgsi_sampler *tgsi_sampler,
    union tex_tile_address addr;
 
    level0 = samp->level;
-   width = texture->width[level0];
-   height = texture->height[level0];
+   width = u_minify(texture->width0, level0);
+   height = u_minify(texture->height0, level0);
 
    assert(width > 0);
    assert(height > 0);
@@ -1209,7 +1201,8 @@ img_filter_3d_linear(struct tgsi_sampler *tgsi_sampler,
                      const float s[QUAD_SIZE],
                      const float t[QUAD_SIZE],
                      const float p[QUAD_SIZE],
-                     float lodbias,
+                     const float c0[QUAD_SIZE],
+                     enum tgsi_sampler_control control,
                      float rgba[NUM_CHANNELS][QUAD_SIZE])
 {
    const struct sp_sampler_varient *samp = sp_sampler_varient(tgsi_sampler);
@@ -1221,9 +1214,9 @@ img_filter_3d_linear(struct tgsi_sampler *tgsi_sampler,
    union tex_tile_address addr;
 
    level0 = samp->level;
-   width = texture->width[level0];
-   height = texture->height[level0];
-   depth = texture->depth[level0];
+   width = u_minify(texture->width0, level0);
+   height = u_minify(texture->height0, level0);
+   depth = u_minify(texture->depth0, level0);
 
    addr.value = 0;
    addr.bits.level = level0;
@@ -1261,29 +1254,60 @@ img_filter_3d_linear(struct tgsi_sampler *tgsi_sampler,
 }
 
 
+/* Calculate level of detail for every fragment.
+ * Note that lambda has already been biased by global LOD bias.
+ */
+static INLINE void
+compute_lod(const struct pipe_sampler_state *sampler,
+            const float biased_lambda,
+            const float lodbias[QUAD_SIZE],
+            float lod[QUAD_SIZE])
+{
+   uint i;
+
+   for (i = 0; i < QUAD_SIZE; i++) {
+      lod[i] = biased_lambda + lodbias[i];
+      lod[i] = CLAMP(lod[i], sampler->min_lod, sampler->max_lod);
+   }
+}
+
+
 static void
 mip_filter_linear(struct tgsi_sampler *tgsi_sampler,
                   const float s[QUAD_SIZE],
                   const float t[QUAD_SIZE],
                   const float p[QUAD_SIZE],
-                  float lodbias,
+                  const float c0[QUAD_SIZE],
+                  enum tgsi_sampler_control control,
                   float rgba[NUM_CHANNELS][QUAD_SIZE])
 {
    struct sp_sampler_varient *samp = sp_sampler_varient(tgsi_sampler);
    const struct pipe_texture *texture = samp->texture;
    int level0;
    float lambda;
+   float lod[QUAD_SIZE];
+
+   if (control == tgsi_sampler_lod_bias) {
+      lambda = samp->compute_lambda(samp, s, t, p) + samp->sampler->lod_bias;
+      compute_lod(samp->sampler, lambda, c0, lod);
+   } else {
+      assert(control == tgsi_sampler_lod_explicit);
 
-   lambda = samp->compute_lambda(samp, s, t, p, lodbias);
+      memcpy(lod, c0, sizeof(lod));
+   }
+
+   /* XXX: Take into account all lod values.
+    */
+   lambda = lod[0];
    level0 = (int)lambda;
 
    if (lambda < 0.0) { 
       samp->level = 0;
-      samp->mag_img_filter( tgsi_sampler, s, t, p, 0, rgba );
+      samp->mag_img_filter(tgsi_sampler, s, t, p, NULL, tgsi_sampler_lod_bias, rgba);
    }
    else if (level0 >= texture->last_level) {
       samp->level = texture->last_level;
-      samp->min_img_filter( tgsi_sampler, s, t, p, 0, rgba );
+      samp->min_img_filter(tgsi_sampler, s, t, p, NULL, tgsi_sampler_lod_bias, rgba);
    }
    else {
       float levelBlend = lambda - level0;
@@ -1292,10 +1316,10 @@ mip_filter_linear(struct tgsi_sampler *tgsi_sampler,
       int c,j;
 
       samp->level = level0;
-      samp->min_img_filter( tgsi_sampler, s, t, p, 0, rgba0 );
+      samp->min_img_filter(tgsi_sampler, s, t, p, NULL, tgsi_sampler_lod_bias, rgba0);
 
       samp->level = level0+1;
-      samp->min_img_filter( tgsi_sampler, s, t, p, 0, rgba1 );
+      samp->min_img_filter(tgsi_sampler, s, t, p, NULL, tgsi_sampler_lod_bias, rgba1);
 
       for (j = 0; j < QUAD_SIZE; j++) {
          for (c = 0; c < 4; c++) {
@@ -1311,23 +1335,36 @@ mip_filter_nearest(struct tgsi_sampler *tgsi_sampler,
                    const float s[QUAD_SIZE],
                    const float t[QUAD_SIZE],
                    const float p[QUAD_SIZE],
-                   float lodbias,
+                   const float c0[QUAD_SIZE],
+                   enum tgsi_sampler_control control,
                    float rgba[NUM_CHANNELS][QUAD_SIZE])
 {
    struct sp_sampler_varient *samp = sp_sampler_varient(tgsi_sampler);
    const struct pipe_texture *texture = samp->texture;
    float lambda;
+   float lod[QUAD_SIZE];
 
-   lambda = samp->compute_lambda(samp, s, t, p, lodbias);
+   if (control == tgsi_sampler_lod_bias) {
+      lambda = samp->compute_lambda(samp, s, t, p) + samp->sampler->lod_bias;
+      compute_lod(samp->sampler, lambda, c0, lod);
+   } else {
+      assert(control == tgsi_sampler_lod_explicit);
+
+      memcpy(lod, c0, sizeof(lod));
+   }
+
+   /* XXX: Take into account all lod values.
+    */
+   lambda = lod[0];
 
    if (lambda < 0.0) { 
       samp->level = 0;
-      samp->mag_img_filter( tgsi_sampler, s, t, p, 0, rgba );
+      samp->mag_img_filter(tgsi_sampler, s, t, p, NULL, tgsi_sampler_lod_bias, rgba);
    }
    else {
       samp->level = (int)(lambda + 0.5) ;
       samp->level = MIN2(samp->level, (int)texture->last_level);
-      samp->min_img_filter( tgsi_sampler, s, t, p, 0, rgba );
+      samp->min_img_filter(tgsi_sampler, s, t, p, NULL, tgsi_sampler_lod_bias, rgba);
    }
 
 #if 0
@@ -1345,17 +1382,32 @@ mip_filter_none(struct tgsi_sampler *tgsi_sampler,
                 const float s[QUAD_SIZE],
                 const float t[QUAD_SIZE],
                 const float p[QUAD_SIZE],
-                float lodbias,
+                const float c0[QUAD_SIZE],
+                enum tgsi_sampler_control control,
                 float rgba[NUM_CHANNELS][QUAD_SIZE])
 {
    struct sp_sampler_varient *samp = sp_sampler_varient(tgsi_sampler);
-   float lambda = samp->compute_lambda(samp, s, t, p, lodbias);
+   float lambda;
+   float lod[QUAD_SIZE];
+
+   if (control == tgsi_sampler_lod_bias) {
+      lambda = samp->compute_lambda(samp, s, t, p) + samp->sampler->lod_bias;
+      compute_lod(samp->sampler, lambda, c0, lod);
+   } else {
+      assert(control == tgsi_sampler_lod_explicit);
+
+      memcpy(lod, c0, sizeof(lod));
+   }
+
+   /* XXX: Take into account all lod values.
+    */
+   lambda = lod[0];
 
    if (lambda < 0.0) { 
-      samp->mag_img_filter( tgsi_sampler, s, t, p, 0, rgba );
+      samp->mag_img_filter(tgsi_sampler, s, t, p, NULL, tgsi_sampler_lod_bias, rgba);
    }
    else {
-      samp->min_img_filter( tgsi_sampler, s, t, p, 0, rgba );
+      samp->min_img_filter(tgsi_sampler, s, t, p, NULL, tgsi_sampler_lod_bias, rgba);
    }
 }
 
@@ -1371,15 +1423,28 @@ mip_filter_linear_2d_linear_repeat_POT(
    const float s[QUAD_SIZE],
    const float t[QUAD_SIZE],
    const float p[QUAD_SIZE],
-   float lodbias,
+   const float c0[QUAD_SIZE],
+   enum tgsi_sampler_control control,
    float rgba[NUM_CHANNELS][QUAD_SIZE])
 {
    struct sp_sampler_varient *samp = sp_sampler_varient(tgsi_sampler);
    const struct pipe_texture *texture = samp->texture;
    int level0;
    float lambda;
+   float lod[QUAD_SIZE];
 
-   lambda = compute_lambda_2d(samp, s, t, p, lodbias);
+   if (control == tgsi_sampler_lod_bias) {
+      lambda = samp->compute_lambda(samp, s, t, p) + samp->sampler->lod_bias;
+      compute_lod(samp->sampler, lambda, c0, lod);
+   } else {
+      assert(control == tgsi_sampler_lod_explicit);
+
+      memcpy(lod, c0, sizeof(lod));
+   }
+
+   /* XXX: Take into account all lod values.
+    */
+   lambda = lod[0];
    level0 = (int)lambda;
 
    /* Catches both negative and large values of level0:
@@ -1390,7 +1455,7 @@ mip_filter_linear_2d_linear_repeat_POT(
       else
          samp->level = texture->last_level;
 
-      img_filter_2d_linear_repeat_POT( tgsi_sampler, s, t, p, 0, rgba );
+      img_filter_2d_linear_repeat_POT(tgsi_sampler, s, t, p, NULL, tgsi_sampler_lod_bias, rgba);
    }
    else {
       float levelBlend = lambda - level0;
@@ -1399,10 +1464,10 @@ mip_filter_linear_2d_linear_repeat_POT(
       int c,j;
 
       samp->level = level0;
-      img_filter_2d_linear_repeat_POT( tgsi_sampler, s, t, p, 0, rgba0 );
+      img_filter_2d_linear_repeat_POT(tgsi_sampler, s, t, p, NULL, tgsi_sampler_lod_bias, rgba0);
 
       samp->level = level0+1;
-      img_filter_2d_linear_repeat_POT( tgsi_sampler, s, t, p, 0, rgba1 );
+      img_filter_2d_linear_repeat_POT(tgsi_sampler, s, t, p, NULL, tgsi_sampler_lod_bias, rgba1);
 
       for (j = 0; j < QUAD_SIZE; j++) {
          for (c = 0; c < 4; c++) {
@@ -1422,7 +1487,8 @@ sample_compare(struct tgsi_sampler *tgsi_sampler,
                const float s[QUAD_SIZE],
                const float t[QUAD_SIZE],
                const float p[QUAD_SIZE],
-               float lodbias,
+               const float c0[QUAD_SIZE],
+               enum tgsi_sampler_control control,
                float rgba[NUM_CHANNELS][QUAD_SIZE])
 {
    struct sp_sampler_varient *samp = sp_sampler_varient(tgsi_sampler);
@@ -1430,7 +1496,7 @@ sample_compare(struct tgsi_sampler *tgsi_sampler,
    int j, k0, k1, k2, k3;
    float val;
 
-   samp->mip_filter( tgsi_sampler, s, t, p, lodbias, rgba );
+   samp->mip_filter(tgsi_sampler, s, t, p, c0, control, rgba);
 
    /**
     * Compare texcoord 'p' (aka R) against texture value 'rgba[0]'
@@ -1508,7 +1574,8 @@ sample_cube(struct tgsi_sampler *tgsi_sampler,
             const float s[QUAD_SIZE],
             const float t[QUAD_SIZE],
             const float p[QUAD_SIZE],
-            float lodbias,
+            const float c0[QUAD_SIZE],
+            enum tgsi_sampler_control control,
             float rgba[NUM_CHANNELS][QUAD_SIZE])
 {
    struct sp_sampler_varient *samp = sp_sampler_varient(tgsi_sampler);
@@ -1589,7 +1656,7 @@ sample_cube(struct tgsi_sampler *tgsi_sampler,
     * is not active, this will point somewhere deeper into the
     * pipeline, eg. to mip_filter or even img_filter.
     */
-   samp->compare(tgsi_sampler, ssss, tttt, NULL, lodbias, rgba);
+   samp->compare(tgsi_sampler, ssss, tttt, NULL, c0, control, rgba);
 }
 
 
@@ -1778,8 +1845,8 @@ sp_sampler_varient_bind_texture( struct sp_sampler_varient *samp,
 
    samp->texture = texture;
    samp->cache = tex_cache;
-   samp->xpot = util_unsigned_logbase2( texture->width[0] );
-   samp->ypot = util_unsigned_logbase2( texture->height[0] );
+   samp->xpot = util_unsigned_logbase2( texture->width0 );
+   samp->ypot = util_unsigned_logbase2( texture->height0 );
    samp->level = CLAMP((int) sampler->min_lod, 0, (int) texture->last_level);
 }
 
@@ -1862,7 +1929,7 @@ sp_create_sampler_varient( const struct pipe_sampler_state *sampler,
       break;
    }
 
-   if (sampler->compare_mode != FALSE) {
+   if (sampler->compare_mode != PIPE_TEX_COMPARE_NONE) {
       samp->compare = sample_compare;
    }
    else {
index b0797711d374da0cf8abf251b9f420d549e35984..b6e66c998aebd635b74f03bb98598c9a0a142435 100644 (file)
@@ -2,6 +2,7 @@
  * 
  * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
  * All Rights Reserved.
+ * Copyright 2010 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
@@ -46,14 +47,14 @@ typedef void (*wrap_linear_func)(const float s[4],
 typedef float (*compute_lambda_func)(const struct sp_sampler_varient *sampler,
                                      const float s[QUAD_SIZE],
                                      const float t[QUAD_SIZE],
-                                     const float p[QUAD_SIZE],
-                                     float lodbias);
+                                     const float p[QUAD_SIZE]);
 
 typedef void (*filter_func)(struct tgsi_sampler *tgsi_sampler,
                             const float s[QUAD_SIZE],
                             const float t[QUAD_SIZE],
                             const float p[QUAD_SIZE],
-                            float lodbias,
+                            const float c0[QUAD_SIZE],
+                            enum tgsi_sampler_control control,
                             float rgba[NUM_CHANNELS][QUAD_SIZE]);
 
 
index 407a22a9f4bd02c3c6bb857c137dae05d6ba67d7..e50a76a73bc9b9809d525a50d66dfb374a4c0ea6 100644 (file)
@@ -35,6 +35,7 @@
 #include "pipe/p_inlines.h"
 #include "util/u_memory.h"
 #include "util/u_tile.h"
+#include "util/u_math.h"
 #include "sp_context.h"
 #include "sp_surface.h"
 #include "sp_texture.h"
@@ -246,9 +247,9 @@ sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc,
                                      addr.bits.level, 
                                      addr.bits.z, 
                                      PIPE_TRANSFER_READ, 0, 0,
-                                     tc->texture->width[addr.bits.level],
-                                     tc->texture->height[addr.bits.level]);
-
+                                     u_minify(tc->texture->width0, addr.bits.level),
+                                     u_minify(tc->texture->height0, addr.bits.level));
+         
          tc->tex_trans_map = screen->transfer_map(screen, tc->tex_trans);
 
          tc->tex_face = addr.bits.face;
index 7caf2928b4ba11ac8c2ca59d6d7749476c39ea15..a9436a33942b299f0ada7ee10b190ed2e8b190ff 100644 (file)
@@ -32,6 +32,8 @@
 
 #include "pipe/p_defines.h"
 #include "pipe/p_inlines.h"
+
+#include "util/u_format.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
 
@@ -52,29 +54,28 @@ softpipe_texture_layout(struct pipe_screen *screen,
 {
    struct pipe_texture *pt = &spt->base;
    unsigned level;
-   unsigned width = pt->width[0];
-   unsigned height = pt->height[0];
-   unsigned depth = pt->depth[0];
+   unsigned width = pt->width0;
+   unsigned height = pt->height0;
+   unsigned depth = pt->depth0;
 
    unsigned buffer_size = 0;
 
+   pt->width0 = width;
+   pt->height0 = height;
+   pt->depth0 = depth;
+
    for (level = 0; level <= pt->last_level; level++) {
-      pt->width[level] = width;
-      pt->height[level] = height;
-      pt->depth[level] = depth;
-      pt->nblocksx[level] = pf_get_nblocksx(&pt->block, width);  
-      pt->nblocksy[level] = pf_get_nblocksy(&pt->block, height);  
-      spt->stride[level] = pt->nblocksx[level]*pt->block.size;
+      spt->stride[level] = util_format_get_stride(pt->format, width);
 
       spt->level_offset[level] = buffer_size;
 
-      buffer_size += (pt->nblocksy[level] *
+      buffer_size += (util_format_get_nblocksy(pt->format, height) *
                       ((pt->target == PIPE_TEXTURE_CUBE) ? 6 : depth) *
                       spt->stride[level]);
 
-      width  = minify(width);
-      height = minify(height);
-      depth = minify(depth);
+      width  = u_minify(width, 1);
+      height = u_minify(height, 1);
+      depth = u_minify(depth, 1);
    }
 
    spt->buffer = screen->buffer_create(screen, 32,
@@ -96,12 +97,9 @@ softpipe_displaytarget_layout(struct pipe_screen *screen,
                      PIPE_BUFFER_USAGE_GPU_READ_WRITE);
    unsigned tex_usage = spt->base.tex_usage;
 
-   spt->base.nblocksx[0] = pf_get_nblocksx(&spt->base.block, spt->base.width[0]);  
-   spt->base.nblocksy[0] = pf_get_nblocksy(&spt->base.block, spt->base.height[0]);  
-
    spt->buffer = screen->surface_buffer_create( screen, 
-                                                spt->base.width[0]
-                                                spt->base.height[0],
+                                                spt->base.width0
+                                                spt->base.height0,
                                                 spt->base.format,
                                                 usage,
                                                 tex_usage,
@@ -126,9 +124,9 @@ softpipe_texture_create(struct pipe_screen *screen,
    pipe_reference_init(&spt->base.reference, 1);
    spt->base.screen = screen;
 
-   spt->pot = (util_is_power_of_two(template->width[0]) &&
-               util_is_power_of_two(template->height[0]) &&
-               util_is_power_of_two(template->depth[0]));
+   spt->pot = (util_is_power_of_two(template->width0) &&
+               util_is_power_of_two(template->height0) &&
+               util_is_power_of_two(template->depth0));
 
    if (spt->base.tex_usage & (PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
                               PIPE_TEXTURE_USAGE_PRIMARY)) {
@@ -163,7 +161,7 @@ softpipe_texture_blanket(struct pipe_screen * screen,
    /* Only supports one type */
    if (base->target != PIPE_TEXTURE_2D ||
        base->last_level != 0 ||
-       base->depth[0] != 1) {
+       base->depth0 != 1) {
       return NULL;
    }
 
@@ -174,8 +172,6 @@ softpipe_texture_blanket(struct pipe_screen * screen,
    spt->base = *base;
    pipe_reference_init(&spt->base.reference, 1);
    spt->base.screen = screen;
-   spt->base.nblocksx[0] = pf_get_nblocksx(&spt->base.block, spt->base.width[0]);  
-   spt->base.nblocksy[0] = pf_get_nblocksy(&spt->base.block, spt->base.height[0]);  
    spt->stride[0] = stride[0];
 
    pipe_buffer_reference(&spt->buffer, buffer);
@@ -213,8 +209,8 @@ softpipe_get_tex_surface(struct pipe_screen *screen,
       pipe_reference_init(&ps->reference, 1);
       pipe_texture_reference(&ps->texture, pt);
       ps->format = pt->format;
-      ps->width = pt->width[level];
-      ps->height = pt->height[level];
+      ps->width = u_minify(pt->width0, level);
+      ps->height = u_minify(pt->height0, level);
       ps->offset = spt->level_offset[level];
       ps->usage = usage;
 
@@ -243,10 +239,12 @@ softpipe_get_tex_surface(struct pipe_screen *screen,
       ps->zslice = zslice;
 
       if (pt->target == PIPE_TEXTURE_CUBE) {
-         ps->offset += face * pt->nblocksy[level] * spt->stride[level];
+         ps->offset += face * util_format_get_nblocksy(pt->format, u_minify(pt->height0, level)) *
+                       spt->stride[level];
       }
       else if (pt->target == PIPE_TEXTURE_3D) {
-         ps->offset += zslice * pt->nblocksy[level] * spt->stride[level];
+         ps->offset += zslice * util_format_get_nblocksy(pt->format, u_minify(pt->height0, level)) *
+                       spt->stride[level];
       }
       else {
          assert(face == 0);
@@ -301,15 +299,12 @@ softpipe_get_tex_transfer(struct pipe_screen *screen,
    spt = CALLOC_STRUCT(softpipe_transfer);
    if (spt) {
       struct pipe_transfer *pt = &spt->base;
+      int nblocksy = util_format_get_nblocksy(texture->format, u_minify(texture->height0, level));
       pipe_texture_reference(&pt->texture, texture);
-      pt->format = texture->format;
-      pt->block = texture->block;
       pt->x = x;
       pt->y = y;
       pt->width = w;
       pt->height = h;
-      pt->nblocksx = texture->nblocksx[level];
-      pt->nblocksy = texture->nblocksy[level];
       pt->stride = sptex->stride[level];
       pt->usage = usage;
       pt->face = face;
@@ -319,10 +314,10 @@ softpipe_get_tex_transfer(struct pipe_screen *screen,
       spt->offset = sptex->level_offset[level];
 
       if (texture->target == PIPE_TEXTURE_CUBE) {
-         spt->offset += face * pt->nblocksy * pt->stride;
+         spt->offset += face * nblocksy * pt->stride;
       }
       else if (texture->target == PIPE_TEXTURE_3D) {
-         spt->offset += zslice * pt->nblocksy * pt->stride;
+         spt->offset += zslice * nblocksy * pt->stride;
       }
       else {
          assert(face == 0);
@@ -360,9 +355,11 @@ softpipe_transfer_map( struct pipe_screen *screen,
 {
    ubyte *map, *xfer_map;
    struct softpipe_texture *spt;
+   enum pipe_format format;
 
    assert(transfer->texture);
    spt = softpipe_texture(transfer->texture);
+   format = transfer->texture->format;
 
    map = pipe_buffer_map(screen, spt->buffer, pipe_transfer_buffer_flags(transfer));
    if (map == NULL)
@@ -379,8 +376,8 @@ softpipe_transfer_map( struct pipe_screen *screen,
    }
 
    xfer_map = map + softpipe_transfer(transfer)->offset +
-      transfer->y / transfer->block.height * transfer->stride +
-      transfer->x / transfer->block.width * transfer->block.size;
+      transfer->y / util_format_get_blockheight(format) * transfer->stride +
+      transfer->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
    /*printf("map = %p  xfer map = %p\n", map, xfer_map);*/
    return xfer_map;
 }
@@ -434,10 +431,9 @@ softpipe_video_surface_create(struct pipe_screen *screen,
    template.format = PIPE_FORMAT_X8R8G8B8_UNORM;
    template.last_level = 0;
    /* vl_mpeg12_mc_renderer expects this when it's initialized with pot_buffers=true */
-   template.width[0] = util_next_power_of_two(width);
-   template.height[0] = util_next_power_of_two(height);
-   template.depth[0] = 1;
-   pf_get_block(template.format, &template.block);
+   template.width0 = util_next_power_of_two(width);
+   template.height0 = util_next_power_of_two(height);
+   template.depth0 = 1;
    template.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER | PIPE_TEXTURE_USAGE_RENDER_TARGET;
 
    sp_vsfc->tex = screen->texture_create(screen, &template);
index 83fb4e0d151f6ed3c5b69bfbfdbe4a1b119e1556..112a6fe0cf36cf09425a953fbf6538b3a04e8a05 100644 (file)
@@ -33,6 +33,7 @@
  */
 
 #include "pipe/p_inlines.h"
+#include "util/u_format.h"
 #include "util/u_memory.h"
 #include "util/u_tile.h"
 #include "sp_tile_cache.h"
@@ -97,7 +98,12 @@ sp_create_tile_cache( struct pipe_screen *screen )
       }
       tc->last_tile = &tc->entries[0]; /* any tile */
 
-#if TILE_CLEAR_OPTIMIZATION
+      /* XXX this code prevents valgrind warnings about use of uninitialized
+       * memory in programs that don't clear the surface before rendering.
+       * However, it breaks clearing in other situations (such as in
+       * progs/tests/drawbuffers, see bug 24402).
+       */
+#if 0 && TILE_CLEAR_OPTIMIZATION
       /* set flags to indicate all the tiles are cleared */
       memset(tc->clear_flags, 255, sizeof(tc->clear_flags));
 #endif
@@ -233,7 +239,7 @@ clear_tile(struct softpipe_cached_tile *tile,
 {
    uint i, j;
 
-   switch (pf_get_size(format)) {
+   switch (util_format_get_blocksize(format)) {
    case 1:
       memset(tile->data.any, clear_value, TILE_SIZE * TILE_SIZE);
       break;
@@ -279,8 +285,9 @@ sp_tile_cache_flush_clear(struct softpipe_tile_cache *tc)
    uint x, y;
    uint numCleared = 0;
 
+   assert(pt->texture);
    /* clear the scratch tile to the clear value */
-   clear_tile(&tc->tile, pt->format, tc->clear_val);
+   clear_tile(&tc->tile, pt->texture->format, tc->clear_val);
 
    /* push the tile to all positions marked as clear */
    for (y = 0; y < h; y += TILE_SIZE) {
@@ -367,6 +374,7 @@ sp_find_cached_tile(struct softpipe_tile_cache *tc,
 
    if (addr.value != tile->addr.value) {
 
+      assert(pt->texture);
       if (tile->addr.bits.invalid == 0) {
          /* put dirty tile back in framebuffer */
          if (tc->depth_stencil) {
@@ -390,10 +398,10 @@ sp_find_cached_tile(struct softpipe_tile_cache *tc,
       if (is_clear_flag_set(tc->clear_flags, addr)) {
          /* don't get tile from framebuffer, just clear it */
          if (tc->depth_stencil) {
-            clear_tile(tile, pt->format, tc->clear_val);
+            clear_tile(tile, pt->texture->format, tc->clear_val);
          }
          else {
-            clear_tile_rgba(tile, pt->format, tc->clear_color);
+            clear_tile_rgba(tile, pt->texture->format, tc->clear_color);
          }
          clear_clear_flag(tc->clear_flags, addr);
       }
index 9e571862b7516f7a0fbd33119c8fb78532be9ff0..f203ded29eee72a6bdf674117faa2804d6ad1e9a 100644 (file)
 #ifndef SP_WINSYS_H
 #define SP_WINSYS_H
 
-
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+#include "pipe/p_defines.h"
 
 struct pipe_screen;
 struct pipe_winsys;
 struct pipe_context;
+struct pipe_texture;
+struct pipe_buffer;
 
 
 struct pipe_context *softpipe_create( struct pipe_screen * );
diff --git a/src/gallium/drivers/svga/Makefile b/src/gallium/drivers/svga/Makefile
new file mode 100644 (file)
index 0000000..f361908
--- /dev/null
@@ -0,0 +1,60 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+LIBNAME = svga
+
+C_SOURCES = \
+       svgadump/svga_shader_dump.c \
+       svgadump/svga_shader_op.c \
+       svgadump/svga_dump.c \
+       svga_cmd.c \
+       svga_context.c \
+       svga_draw.c \
+       svga_draw_arrays.c \
+       svga_draw_elements.c \
+       svga_pipe_blend.c \
+       svga_pipe_blit.c \
+       svga_pipe_clear.c \
+       svga_pipe_constants.c \
+       svga_pipe_depthstencil.c \
+       svga_pipe_draw.c \
+       svga_pipe_flush.c \
+       svga_pipe_fs.c \
+       svga_pipe_misc.c \
+       svga_pipe_query.c \
+       svga_pipe_rasterizer.c \
+       svga_pipe_sampler.c \
+       svga_pipe_vertex.c \
+       svga_pipe_vs.c \
+       svga_screen.c \
+       svga_screen_buffer.c \
+       svga_screen_texture.c \
+       svga_screen_cache.c \
+       svga_state.c \
+       svga_state_need_swtnl.c \
+       svga_state_constants.c \
+       svga_state_framebuffer.c \
+       svga_state_rss.c \
+       svga_state_tss.c \
+       svga_state_vdecl.c \
+       svga_state_fs.c \
+       svga_state_vs.c \
+       svga_swtnl_backend.c \
+       svga_swtnl_draw.c \
+       svga_swtnl_state.c \
+       svga_tgsi.c \
+       svga_tgsi_decl_sm20.c \
+       svga_tgsi_decl_sm30.c \
+       svga_tgsi_insn.c
+
+LIBRARY_INCLUDES = \
+       -I$(TOP)/src/gallium/drivers/svga/include
+
+# With linux-debug we get a lots of warnings, filter out the bad flags.
+CFLAGS := $(filter-out -pedantic, $(filter-out -ansi, $(CFLAGS)))
+
+LIBRARY_DEFINES = \
+       -std=gnu99 -fvisibility=hidden \
+       -DHAVE_STDINT_H -DHAVE_SYS_TYPES_H
+
+include ../../Makefile.template
diff --git a/src/gallium/drivers/svga/SConscript b/src/gallium/drivers/svga/SConscript
new file mode 100644 (file)
index 0000000..737b791
--- /dev/null
@@ -0,0 +1,72 @@
+Import('*')
+
+env = env.Clone()
+
+if env['platform'] in ['linux']:
+       env.Append(CCFLAGS = ['-fvisibility=hidden'])
+
+if env['gcc']:
+       env.Append(CPPDEFINES = [
+               'HAVE_STDINT_H', 
+               'HAVE_SYS_TYPES_H',
+       ])
+       
+env.Prepend(CPPPATH = [
+       'include',
+])
+
+env.Append(CPPDEFINES = [
+])
+
+sources = [
+    'svga_cmd.c',
+    'svga_context.c',
+    'svga_draw.c',
+    'svga_draw_arrays.c',
+    'svga_draw_elements.c',
+    'svga_pipe_blend.c',
+    'svga_pipe_blit.c',
+    'svga_pipe_clear.c',
+    'svga_pipe_constants.c',
+    'svga_pipe_depthstencil.c',
+    'svga_pipe_draw.c',
+    'svga_pipe_flush.c',
+    'svga_pipe_fs.c',
+    'svga_pipe_misc.c',
+    'svga_pipe_query.c',
+    'svga_pipe_rasterizer.c',
+    'svga_pipe_sampler.c',
+    'svga_pipe_vertex.c',
+    'svga_pipe_vs.c',
+    'svga_screen.c',
+    'svga_screen_buffer.c',
+    'svga_screen_cache.c',
+    'svga_screen_texture.c',
+    'svga_state.c',
+    'svga_state_constants.c',
+    'svga_state_framebuffer.c',
+    'svga_state_need_swtnl.c',
+    'svga_state_rss.c',
+    'svga_state_tss.c',
+    'svga_state_vdecl.c',
+    'svga_state_fs.c',
+    'svga_state_vs.c',
+    'svga_swtnl_backend.c',
+    'svga_swtnl_draw.c',
+    'svga_swtnl_state.c',
+    'svga_tgsi.c',
+    'svga_tgsi_decl_sm20.c',
+    'svga_tgsi_decl_sm30.c',
+    'svga_tgsi_insn.c',
+    
+    'svgadump/svga_dump.c',
+    'svgadump/svga_shader_dump.c',
+    'svgadump/svga_shader_op.c',
+]
+
+svga = env.ConvenienceLibrary(
+       target = 'svga',
+       source = sources,
+)
+
+Export('svga')
diff --git a/src/gallium/drivers/svga/include/README b/src/gallium/drivers/svga/include/README
new file mode 100644 (file)
index 0000000..a0b8916
--- /dev/null
@@ -0,0 +1,3 @@
+This directory contains the headers from the VMware SVGA Device Developer Kit:
+
+   https://vmware-svga.svn.sourceforge.net/svnroot/vmware-svga/trunk/lib/vmware/
diff --git a/src/gallium/drivers/svga/include/svga3d_caps.h b/src/gallium/drivers/svga/include/svga3d_caps.h
new file mode 100644 (file)
index 0000000..714ce9f
--- /dev/null
@@ -0,0 +1,139 @@
+/**********************************************************
+ * Copyright 2007-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+/*
+ * svga3d_caps.h --
+ *
+ *       Definitions for SVGA3D hardware capabilities.  Capabilities
+ *       are used to query for optional rendering features during
+ *       driver initialization. The capability data is stored as very
+ *       basic key/value dictionary within the "FIFO register" memory
+ *       area at the beginning of BAR2.
+ *
+ *       Note that these definitions are only for 3D capabilities.
+ *       The SVGA device also has "device capabilities" and "FIFO
+ *       capabilities", which are non-3D-specific and are stored as
+ *       bitfields rather than key/value pairs.
+ */
+
+#ifndef _SVGA3D_CAPS_H_
+#define _SVGA3D_CAPS_H_
+
+#define SVGA_FIFO_3D_CAPS_SIZE   (SVGA_FIFO_3D_CAPS_LAST - \
+                                  SVGA_FIFO_3D_CAPS + 1)
+
+
+/*
+ * SVGA3dCapsRecordType
+ *
+ *    Record types that can be found in the caps block.
+ *    Related record types are grouped together numerically so that
+ *    SVGA3dCaps_FindRecord() can be applied on a range of record
+ *    types.
+ */
+
+typedef enum {
+   SVGA3DCAPS_RECORD_UNKNOWN        = 0,
+   SVGA3DCAPS_RECORD_DEVCAPS_MIN    = 0x100,
+   SVGA3DCAPS_RECORD_DEVCAPS        = 0x100,
+   SVGA3DCAPS_RECORD_DEVCAPS_MAX    = 0x1ff,
+} SVGA3dCapsRecordType;
+
+
+/*
+ * SVGA3dCapsRecordHeader
+ *
+ *    Header field leading each caps block record. Contains the offset (in
+ *    register words, NOT bytes) to the next caps block record (or the end
+ *    of caps block records which will be a zero word) and the record type
+ *    as defined above.
+ */
+
+typedef
+struct SVGA3dCapsRecordHeader {
+   uint32 length;
+   SVGA3dCapsRecordType type;
+}
+SVGA3dCapsRecordHeader;
+
+
+/*
+ * SVGA3dCapsRecord
+ *
+ *    Caps block record; "data" is a placeholder for the actual data structure
+ *    contained within the record; for example a record containing a FOOBAR
+ *    structure would be of size "sizeof(SVGA3dCapsRecordHeader) +
+ *    sizeof(FOOBAR)".
+ */
+
+typedef
+struct SVGA3dCapsRecord {
+   SVGA3dCapsRecordHeader header;
+   uint32 data[1];
+}
+SVGA3dCapsRecord;
+
+
+typedef uint32 SVGA3dCapPair[2];
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SVGA3dCaps_FindRecord
+ *
+ *    Finds the record with the highest-valued type within the given range
+ *    in the caps block.
+ *
+ *    Result: pointer to found record, or NULL if not found.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static INLINE SVGA3dCapsRecord *
+SVGA3dCaps_FindRecord(const uint32 *capsBlock,
+                      SVGA3dCapsRecordType recordTypeMin,
+                      SVGA3dCapsRecordType recordTypeMax)
+{
+   SVGA3dCapsRecord *record, *found = NULL;
+   uint32 offset;
+
+   /*
+    * Search linearly through the caps block records for the specified type.
+    */
+   for (offset = 0; capsBlock[offset] != 0; offset += capsBlock[offset]) {
+      record = (SVGA3dCapsRecord *) (capsBlock + offset);
+      if ((record->header.type >= recordTypeMin) &&
+          (record->header.type <= recordTypeMax) &&
+          (!found || (record->header.type > found->header.type))) {
+         found = record;
+      }
+   }
+
+   return found;
+}
+
+
+#endif // _SVGA3D_CAPS_H_
diff --git a/src/gallium/drivers/svga/include/svga3d_reg.h b/src/gallium/drivers/svga/include/svga3d_reg.h
new file mode 100644 (file)
index 0000000..77cb453
--- /dev/null
@@ -0,0 +1,1793 @@
+/**********************************************************
+ * Copyright 1998-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+/*
+ * svga3d_reg.h --
+ *
+ *       SVGA 3D hardware definitions
+ */
+
+#ifndef _SVGA3D_REG_H_
+#define _SVGA3D_REG_H_
+
+#include "svga_reg.h"
+
+
+/*
+ * 3D Hardware Version
+ *
+ *   The hardware version is stored in the SVGA_FIFO_3D_HWVERSION fifo
+ *   register.   Is set by the host and read by the guest.  This lets
+ *   us make new guest drivers which are backwards-compatible with old
+ *   SVGA hardware revisions.  It does not let us support old guest
+ *   drivers.  Good enough for now.
+ *
+ */
+
+#define SVGA3D_MAKE_HWVERSION(major, minor)      (((major) << 16) | ((minor) & 0xFF))
+#define SVGA3D_MAJOR_HWVERSION(version)          ((version) >> 16)
+#define SVGA3D_MINOR_HWVERSION(version)          ((version) & 0xFF)
+
+typedef enum {
+   SVGA3D_HWVERSION_WS5_RC1   = SVGA3D_MAKE_HWVERSION(0, 1),
+   SVGA3D_HWVERSION_WS5_RC2   = SVGA3D_MAKE_HWVERSION(0, 2),
+   SVGA3D_HWVERSION_WS51_RC1  = SVGA3D_MAKE_HWVERSION(0, 3),
+   SVGA3D_HWVERSION_WS6_B1    = SVGA3D_MAKE_HWVERSION(1, 1),
+   SVGA3D_HWVERSION_FUSION_11 = SVGA3D_MAKE_HWVERSION(1, 4),
+   SVGA3D_HWVERSION_WS65_B1   = SVGA3D_MAKE_HWVERSION(2, 0),
+   SVGA3D_HWVERSION_CURRENT   = SVGA3D_HWVERSION_WS65_B1,
+} SVGA3dHardwareVersion;
+
+/*
+ * Generic Types
+ */
+
+typedef uint32 SVGA3dBool; /* 32-bit Bool definition */
+#define SVGA3D_NUM_CLIPPLANES                   6
+#define SVGA3D_MAX_SIMULTANEOUS_RENDER_TARGETS  8
+
+
+/*
+ * Surface formats.
+ *
+ * If you modify this list, be sure to keep GLUtil.c in sync. It
+ * includes the internal format definition of each surface in
+ * GLUtil_ConvertSurfaceFormat, and it contains a table of
+ * human-readable names in GLUtil_GetFormatName.
+ */
+
+typedef enum SVGA3dSurfaceFormat {
+   SVGA3D_FORMAT_INVALID = 0,
+
+   SVGA3D_X8R8G8B8       = 1,
+   SVGA3D_A8R8G8B8       = 2,
+
+   SVGA3D_R5G6B5         = 3,
+   SVGA3D_X1R5G5B5       = 4,
+   SVGA3D_A1R5G5B5       = 5,
+   SVGA3D_A4R4G4B4       = 6,
+
+   SVGA3D_Z_D32          = 7,
+   SVGA3D_Z_D16          = 8,
+   SVGA3D_Z_D24S8        = 9,
+   SVGA3D_Z_D15S1        = 10,
+
+   SVGA3D_LUMINANCE8            = 11,
+   SVGA3D_LUMINANCE4_ALPHA4     = 12,
+   SVGA3D_LUMINANCE16           = 13,
+   SVGA3D_LUMINANCE8_ALPHA8     = 14,
+
+   SVGA3D_DXT1           = 15,
+   SVGA3D_DXT2           = 16,
+   SVGA3D_DXT3           = 17,
+   SVGA3D_DXT4           = 18,
+   SVGA3D_DXT5           = 19,
+
+   SVGA3D_BUMPU8V8       = 20,
+   SVGA3D_BUMPL6V5U5     = 21,
+   SVGA3D_BUMPX8L8V8U8   = 22,
+   SVGA3D_BUMPL8V8U8     = 23,
+
+   SVGA3D_ARGB_S10E5     = 24,   /* 16-bit floating-point ARGB */
+   SVGA3D_ARGB_S23E8     = 25,   /* 32-bit floating-point ARGB */
+
+   SVGA3D_A2R10G10B10    = 26,
+
+   /* signed formats */
+   SVGA3D_V8U8           = 27,
+   SVGA3D_Q8W8V8U8       = 28,
+   SVGA3D_CxV8U8         = 29,
+
+   /* mixed formats */
+   SVGA3D_X8L8V8U8       = 30,
+   SVGA3D_A2W10V10U10    = 31,
+
+   SVGA3D_ALPHA8         = 32,
+
+   /* Single- and dual-component floating point formats */
+   SVGA3D_R_S10E5        = 33,
+   SVGA3D_R_S23E8        = 34,
+   SVGA3D_RG_S10E5       = 35,
+   SVGA3D_RG_S23E8       = 36,
+
+   /*
+    * Any surface can be used as a buffer object, but SVGA3D_BUFFER is
+    * the most efficient format to use when creating new surfaces
+    * expressly for index or vertex data.
+    */
+   SVGA3D_BUFFER         = 37,
+
+   SVGA3D_Z_D24X8        = 38,
+
+   SVGA3D_V16U16         = 39,
+
+   SVGA3D_G16R16         = 40,
+   SVGA3D_A16B16G16R16   = 41,
+
+   /* Packed Video formats */
+   SVGA3D_UYVY           = 42,
+   SVGA3D_YUY2           = 43,
+
+   SVGA3D_FORMAT_MAX
+} SVGA3dSurfaceFormat;
+
+typedef uint32 SVGA3dColor; /* a, r, g, b */
+
+/*
+ * These match the D3DFORMAT_OP definitions used by Direct3D. We need
+ * them so that we can query the host for what the supported surface
+ * operations are (when we're using the D3D backend, in particular),
+ * and so we can send those operations to the guest.
+ */
+typedef enum {
+   SVGA3DFORMAT_OP_TEXTURE                               = 0x00000001,
+   SVGA3DFORMAT_OP_VOLUMETEXTURE                         = 0x00000002,
+   SVGA3DFORMAT_OP_CUBETEXTURE                           = 0x00000004,
+   SVGA3DFORMAT_OP_OFFSCREEN_RENDERTARGET                = 0x00000008,
+   SVGA3DFORMAT_OP_SAME_FORMAT_RENDERTARGET              = 0x00000010,
+   SVGA3DFORMAT_OP_ZSTENCIL                              = 0x00000040,
+   SVGA3DFORMAT_OP_ZSTENCIL_WITH_ARBITRARY_COLOR_DEPTH   = 0x00000080,
+
+/*
+ * This format can be used as a render target if the current display mode
+ * is the same depth if the alpha channel is ignored. e.g. if the device
+ * can render to A8R8G8B8 when the display mode is X8R8G8B8, then the
+ * format op list entry for A8R8G8B8 should have this cap.
+ */
+   SVGA3DFORMAT_OP_SAME_FORMAT_UP_TO_ALPHA_RENDERTARGET  = 0x00000100,
+
+/*
+ * This format contains DirectDraw support (including Flip).  This flag
+ * should not to be set on alpha formats.
+ */
+   SVGA3DFORMAT_OP_DISPLAYMODE                           = 0x00000400,
+
+/*
+ * The rasterizer can support some level of Direct3D support in this format
+ * and implies that the driver can create a Context in this mode (for some
+ * render target format).  When this flag is set, the SVGA3DFORMAT_OP_DISPLAYMODE
+ * flag must also be set.
+ */
+   SVGA3DFORMAT_OP_3DACCELERATION                        = 0x00000800,
+
+/*
+ * This is set for a private format when the driver has put the bpp in
+ * the structure.
+ */
+   SVGA3DFORMAT_OP_PIXELSIZE                             = 0x00001000,
+
+/*
+ * Indicates that this format can be converted to any RGB format for which
+ * SVGA3DFORMAT_OP_MEMBEROFGROUP_ARGB is specified
+ */
+   SVGA3DFORMAT_OP_CONVERT_TO_ARGB                       = 0x00002000,
+
+/*
+ * Indicates that this format can be used to create offscreen plain surfaces.
+ */
+   SVGA3DFORMAT_OP_OFFSCREENPLAIN                        = 0x00004000,
+
+/*
+ * Indicated that this format can be read as an SRGB texture (meaning that the
+ * sampler will linearize the looked up data)
+ */
+   SVGA3DFORMAT_OP_SRGBREAD                              = 0x00008000,
+
+/*
+ * Indicates that this format can be used in the bumpmap instructions
+ */
+   SVGA3DFORMAT_OP_BUMPMAP                               = 0x00010000,
+
+/*
+ * Indicates that this format can be sampled by the displacement map sampler
+ */
+   SVGA3DFORMAT_OP_DMAP                                  = 0x00020000,
+
+/*
+ * Indicates that this format cannot be used with texture filtering
+ */
+   SVGA3DFORMAT_OP_NOFILTER                              = 0x00040000,
+
+/*
+ * Indicates that format conversions are supported to this RGB format if
+ * SVGA3DFORMAT_OP_CONVERT_TO_ARGB is specified in the source format.
+ */
+   SVGA3DFORMAT_OP_MEMBEROFGROUP_ARGB                    = 0x00080000,
+
+/*
+ * Indicated that this format can be written as an SRGB target (meaning that the
+ * pixel pipe will DE-linearize data on output to format)
+ */
+   SVGA3DFORMAT_OP_SRGBWRITE                             = 0x00100000,
+
+/*
+ * Indicates that this format cannot be used with alpha blending
+ */
+   SVGA3DFORMAT_OP_NOALPHABLEND                          = 0x00200000,
+
+/*
+ * Indicates that the device can auto-generated sublevels for resources
+ * of this format
+ */
+   SVGA3DFORMAT_OP_AUTOGENMIPMAP                         = 0x00400000,
+
+/*
+ * Indicates that this format can be used by vertex texture sampler
+ */
+   SVGA3DFORMAT_OP_VERTEXTEXTURE                         = 0x00800000,
+
+/*
+ * Indicates that this format supports neither texture coordinate wrap
+ * modes, nor mipmapping
+ */
+   SVGA3DFORMAT_OP_NOTEXCOORDWRAPNORMIP                  = 0x01000000
+} SVGA3dFormatOp;
+
+/*
+ * This structure is a conversion of SVGA3DFORMAT_OP_*.
+ * Entries must be located at the same position.
+ */
+typedef union {
+   uint32 value;
+   struct {
+      uint32 texture : 1;
+      uint32 volumeTexture : 1;
+      uint32 cubeTexture : 1;
+      uint32 offscreenRenderTarget : 1;
+      uint32 sameFormatRenderTarget : 1;
+      uint32 unknown1 : 1;
+      uint32 zStencil : 1;
+      uint32 zStencilArbitraryDepth : 1;
+      uint32 sameFormatUpToAlpha : 1;
+      uint32 unknown2 : 1;
+      uint32 displayMode : 1;
+      uint32 acceleration3d : 1;
+      uint32 pixelSize : 1;
+      uint32 convertToARGB : 1;
+      uint32 offscreenPlain : 1;
+      uint32 sRGBRead : 1;
+      uint32 bumpMap : 1;
+      uint32 dmap : 1;
+      uint32 noFilter : 1;
+      uint32 memberOfGroupARGB : 1;
+      uint32 sRGBWrite : 1;
+      uint32 noAlphaBlend : 1;
+      uint32 autoGenMipMap : 1;
+      uint32 vertexTexture : 1;
+      uint32 noTexCoordWrapNorMip : 1;
+   };
+} SVGA3dSurfaceFormatCaps;
+
+/*
+ * SVGA_3D_CMD_SETRENDERSTATE Types.  All value types
+ * must fit in a uint32.
+ */
+
+typedef enum {
+   SVGA3D_RS_INVALID                   = 0,
+   SVGA3D_RS_ZENABLE                   = 1,     /* SVGA3dBool */
+   SVGA3D_RS_ZWRITEENABLE              = 2,     /* SVGA3dBool */
+   SVGA3D_RS_ALPHATESTENABLE           = 3,     /* SVGA3dBool */
+   SVGA3D_RS_DITHERENABLE              = 4,     /* SVGA3dBool */
+   SVGA3D_RS_BLENDENABLE               = 5,     /* SVGA3dBool */
+   SVGA3D_RS_FOGENABLE                 = 6,     /* SVGA3dBool */
+   SVGA3D_RS_SPECULARENABLE            = 7,     /* SVGA3dBool */
+   SVGA3D_RS_STENCILENABLE             = 8,     /* SVGA3dBool */
+   SVGA3D_RS_LIGHTINGENABLE            = 9,     /* SVGA3dBool */
+   SVGA3D_RS_NORMALIZENORMALS          = 10,    /* SVGA3dBool */
+   SVGA3D_RS_POINTSPRITEENABLE         = 11,    /* SVGA3dBool */
+   SVGA3D_RS_POINTSCALEENABLE          = 12,    /* SVGA3dBool */
+   SVGA3D_RS_STENCILREF                = 13,    /* uint32 */
+   SVGA3D_RS_STENCILMASK               = 14,    /* uint32 */
+   SVGA3D_RS_STENCILWRITEMASK          = 15,    /* uint32 */
+   SVGA3D_RS_FOGSTART                  = 16,    /* float */
+   SVGA3D_RS_FOGEND                    = 17,    /* float */
+   SVGA3D_RS_FOGDENSITY                = 18,    /* float */
+   SVGA3D_RS_POINTSIZE                 = 19,    /* float */
+   SVGA3D_RS_POINTSIZEMIN              = 20,    /* float */
+   SVGA3D_RS_POINTSIZEMAX              = 21,    /* float */
+   SVGA3D_RS_POINTSCALE_A              = 22,    /* float */
+   SVGA3D_RS_POINTSCALE_B              = 23,    /* float */
+   SVGA3D_RS_POINTSCALE_C              = 24,    /* float */
+   SVGA3D_RS_FOGCOLOR                  = 25,    /* SVGA3dColor */
+   SVGA3D_RS_AMBIENT                   = 26,    /* SVGA3dColor */
+   SVGA3D_RS_CLIPPLANEENABLE           = 27,    /* SVGA3dClipPlanes */
+   SVGA3D_RS_FOGMODE                   = 28,    /* SVGA3dFogMode */
+   SVGA3D_RS_FILLMODE                  = 29,    /* SVGA3dFillMode */
+   SVGA3D_RS_SHADEMODE                 = 30,    /* SVGA3dShadeMode */
+   SVGA3D_RS_LINEPATTERN               = 31,    /* SVGA3dLinePattern */
+   SVGA3D_RS_SRCBLEND                  = 32,    /* SVGA3dBlendOp */
+   SVGA3D_RS_DSTBLEND                  = 33,    /* SVGA3dBlendOp */
+   SVGA3D_RS_BLENDEQUATION             = 34,    /* SVGA3dBlendEquation */
+   SVGA3D_RS_CULLMODE                  = 35,    /* SVGA3dFace */
+   SVGA3D_RS_ZFUNC                     = 36,    /* SVGA3dCmpFunc */
+   SVGA3D_RS_ALPHAFUNC                 = 37,    /* SVGA3dCmpFunc */
+   SVGA3D_RS_STENCILFUNC               = 38,    /* SVGA3dCmpFunc */
+   SVGA3D_RS_STENCILFAIL               = 39,    /* SVGA3dStencilOp */
+   SVGA3D_RS_STENCILZFAIL              = 40,    /* SVGA3dStencilOp */
+   SVGA3D_RS_STENCILPASS               = 41,    /* SVGA3dStencilOp */
+   SVGA3D_RS_ALPHAREF                  = 42,    /* float (0.0 .. 1.0) */
+   SVGA3D_RS_FRONTWINDING              = 43,    /* SVGA3dFrontWinding */
+   SVGA3D_RS_COORDINATETYPE            = 44,    /* SVGA3dCoordinateType */
+   SVGA3D_RS_ZBIAS                     = 45,    /* float */
+   SVGA3D_RS_RANGEFOGENABLE            = 46,    /* SVGA3dBool */
+   SVGA3D_RS_COLORWRITEENABLE          = 47,    /* SVGA3dColorMask */
+   SVGA3D_RS_VERTEXMATERIALENABLE      = 48,    /* SVGA3dBool */
+   SVGA3D_RS_DIFFUSEMATERIALSOURCE     = 49,    /* SVGA3dVertexMaterial */
+   SVGA3D_RS_SPECULARMATERIALSOURCE    = 50,    /* SVGA3dVertexMaterial */
+   SVGA3D_RS_AMBIENTMATERIALSOURCE     = 51,    /* SVGA3dVertexMaterial */
+   SVGA3D_RS_EMISSIVEMATERIALSOURCE    = 52,    /* SVGA3dVertexMaterial */
+   SVGA3D_RS_TEXTUREFACTOR             = 53,    /* SVGA3dColor */
+   SVGA3D_RS_LOCALVIEWER               = 54,    /* SVGA3dBool */
+   SVGA3D_RS_SCISSORTESTENABLE         = 55,    /* SVGA3dBool */
+   SVGA3D_RS_BLENDCOLOR                = 56,    /* SVGA3dColor */
+   SVGA3D_RS_STENCILENABLE2SIDED       = 57,    /* SVGA3dBool */
+   SVGA3D_RS_CCWSTENCILFUNC            = 58,    /* SVGA3dCmpFunc */
+   SVGA3D_RS_CCWSTENCILFAIL            = 59,    /* SVGA3dStencilOp */
+   SVGA3D_RS_CCWSTENCILZFAIL           = 60,    /* SVGA3dStencilOp */
+   SVGA3D_RS_CCWSTENCILPASS            = 61,    /* SVGA3dStencilOp */
+   SVGA3D_RS_VERTEXBLEND               = 62,    /* SVGA3dVertexBlendFlags */
+   SVGA3D_RS_SLOPESCALEDEPTHBIAS       = 63,    /* float */
+   SVGA3D_RS_DEPTHBIAS                 = 64,    /* float */
+
+
+   /*
+    * Output Gamma Level
+    *
+    * Output gamma effects the gamma curve of colors that are output from the
+    * rendering pipeline.  A value of 1.0 specifies a linear color space. If the
+    * value is <= 0.0, gamma correction is ignored and linear color space is
+    * used.
+    */
+
+   SVGA3D_RS_OUTPUTGAMMA               = 65,    /* float */
+   SVGA3D_RS_ZVISIBLE                  = 66,    /* SVGA3dBool */
+   SVGA3D_RS_LASTPIXEL                 = 67,    /* SVGA3dBool */
+   SVGA3D_RS_CLIPPING                  = 68,    /* SVGA3dBool */
+   SVGA3D_RS_WRAP0                     = 69,    /* SVGA3dWrapFlags */
+   SVGA3D_RS_WRAP1                     = 70,    /* SVGA3dWrapFlags */
+   SVGA3D_RS_WRAP2                     = 71,    /* SVGA3dWrapFlags */
+   SVGA3D_RS_WRAP3                     = 72,    /* SVGA3dWrapFlags */
+   SVGA3D_RS_WRAP4                     = 73,    /* SVGA3dWrapFlags */
+   SVGA3D_RS_WRAP5                     = 74,    /* SVGA3dWrapFlags */
+   SVGA3D_RS_WRAP6                     = 75,    /* SVGA3dWrapFlags */
+   SVGA3D_RS_WRAP7                     = 76,    /* SVGA3dWrapFlags */
+   SVGA3D_RS_WRAP8                     = 77,    /* SVGA3dWrapFlags */
+   SVGA3D_RS_WRAP9                     = 78,    /* SVGA3dWrapFlags */
+   SVGA3D_RS_WRAP10                    = 79,    /* SVGA3dWrapFlags */
+   SVGA3D_RS_WRAP11                    = 80,    /* SVGA3dWrapFlags */
+   SVGA3D_RS_WRAP12                    = 81,    /* SVGA3dWrapFlags */
+   SVGA3D_RS_WRAP13                    = 82,    /* SVGA3dWrapFlags */
+   SVGA3D_RS_WRAP14                    = 83,    /* SVGA3dWrapFlags */
+   SVGA3D_RS_WRAP15                    = 84,    /* SVGA3dWrapFlags */
+   SVGA3D_RS_MULTISAMPLEANTIALIAS      = 85,    /* SVGA3dBool */
+   SVGA3D_RS_MULTISAMPLEMASK           = 86,    /* uint32 */
+   SVGA3D_RS_INDEXEDVERTEXBLENDENABLE  = 87,    /* SVGA3dBool */
+   SVGA3D_RS_TWEENFACTOR               = 88,    /* float */
+   SVGA3D_RS_ANTIALIASEDLINEENABLE     = 89,    /* SVGA3dBool */
+   SVGA3D_RS_COLORWRITEENABLE1         = 90,    /* SVGA3dColorMask */
+   SVGA3D_RS_COLORWRITEENABLE2         = 91,    /* SVGA3dColorMask */
+   SVGA3D_RS_COLORWRITEENABLE3         = 92,    /* SVGA3dColorMask */
+   SVGA3D_RS_SEPARATEALPHABLENDENABLE  = 93,    /* SVGA3dBool */
+   SVGA3D_RS_SRCBLENDALPHA             = 94,    /* SVGA3dBlendOp */
+   SVGA3D_RS_DSTBLENDALPHA             = 95,    /* SVGA3dBlendOp */
+   SVGA3D_RS_BLENDEQUATIONALPHA        = 96,    /* SVGA3dBlendEquation */
+   SVGA3D_RS_MAX
+} SVGA3dRenderStateName;
+
+typedef enum {
+   SVGA3D_VERTEXMATERIAL_NONE     = 0,    /* Use the value in the current material */
+   SVGA3D_VERTEXMATERIAL_DIFFUSE  = 1,    /* Use the value in the diffuse component */
+   SVGA3D_VERTEXMATERIAL_SPECULAR = 2,    /* Use the value in the specular component */
+} SVGA3dVertexMaterial;
+
+typedef enum {
+   SVGA3D_FILLMODE_INVALID = 0,
+   SVGA3D_FILLMODE_POINT   = 1,
+   SVGA3D_FILLMODE_LINE    = 2,
+   SVGA3D_FILLMODE_FILL    = 3,
+   SVGA3D_FILLMODE_MAX
+} SVGA3dFillModeType;
+
+
+typedef
+union {
+   struct {
+      uint16   mode;       /* SVGA3dFillModeType */
+      uint16   face;       /* SVGA3dFace */
+   };
+   uint32 uintValue;
+} SVGA3dFillMode;
+
+typedef enum {
+   SVGA3D_SHADEMODE_INVALID = 0,
+   SVGA3D_SHADEMODE_FLAT    = 1,
+   SVGA3D_SHADEMODE_SMOOTH  = 2,
+   SVGA3D_SHADEMODE_PHONG   = 3,     /* Not supported */
+   SVGA3D_SHADEMODE_MAX
+} SVGA3dShadeMode;
+
+typedef
+union {
+   struct {
+      uint16 repeat;
+      uint16 pattern;
+   };
+   uint32 uintValue;
+} SVGA3dLinePattern;
+
+typedef enum {
+   SVGA3D_BLENDOP_INVALID            = 0,
+   SVGA3D_BLENDOP_ZERO               = 1,
+   SVGA3D_BLENDOP_ONE                = 2,
+   SVGA3D_BLENDOP_SRCCOLOR           = 3,
+   SVGA3D_BLENDOP_INVSRCCOLOR        = 4,
+   SVGA3D_BLENDOP_SRCALPHA           = 5,
+   SVGA3D_BLENDOP_INVSRCALPHA        = 6,
+   SVGA3D_BLENDOP_DESTALPHA          = 7,
+   SVGA3D_BLENDOP_INVDESTALPHA       = 8,
+   SVGA3D_BLENDOP_DESTCOLOR          = 9,
+   SVGA3D_BLENDOP_INVDESTCOLOR       = 10,
+   SVGA3D_BLENDOP_SRCALPHASAT        = 11,
+   SVGA3D_BLENDOP_BLENDFACTOR        = 12,
+   SVGA3D_BLENDOP_INVBLENDFACTOR     = 13,
+   SVGA3D_BLENDOP_MAX
+} SVGA3dBlendOp;
+
+typedef enum {
+   SVGA3D_BLENDEQ_INVALID            = 0,
+   SVGA3D_BLENDEQ_ADD                = 1,
+   SVGA3D_BLENDEQ_SUBTRACT           = 2,
+   SVGA3D_BLENDEQ_REVSUBTRACT        = 3,
+   SVGA3D_BLENDEQ_MINIMUM            = 4,
+   SVGA3D_BLENDEQ_MAXIMUM            = 5,
+   SVGA3D_BLENDEQ_MAX
+} SVGA3dBlendEquation;
+
+typedef enum {
+   SVGA3D_FRONTWINDING_INVALID = 0,
+   SVGA3D_FRONTWINDING_CW      = 1,
+   SVGA3D_FRONTWINDING_CCW     = 2,
+   SVGA3D_FRONTWINDING_MAX
+} SVGA3dFrontWinding;
+
+typedef enum {
+   SVGA3D_FACE_INVALID  = 0,
+   SVGA3D_FACE_NONE     = 1,
+   SVGA3D_FACE_FRONT    = 2,
+   SVGA3D_FACE_BACK     = 3,
+   SVGA3D_FACE_FRONT_BACK = 4,
+   SVGA3D_FACE_MAX
+} SVGA3dFace;
+
+/*
+ * The order and the values should not be changed
+ */
+
+typedef enum {
+   SVGA3D_CMP_INVALID              = 0,
+   SVGA3D_CMP_NEVER                = 1,
+   SVGA3D_CMP_LESS                 = 2,
+   SVGA3D_CMP_EQUAL                = 3,
+   SVGA3D_CMP_LESSEQUAL            = 4,
+   SVGA3D_CMP_GREATER              = 5,
+   SVGA3D_CMP_NOTEQUAL             = 6,
+   SVGA3D_CMP_GREATEREQUAL         = 7,
+   SVGA3D_CMP_ALWAYS               = 8,
+   SVGA3D_CMP_MAX
+} SVGA3dCmpFunc;
+
+/*
+ * SVGA3D_FOGFUNC_* specifies the fog equation, or PER_VERTEX which allows
+ * the fog factor to be specified in the alpha component of the specular
+ * (a.k.a. secondary) vertex color.
+ */
+typedef enum {
+   SVGA3D_FOGFUNC_INVALID          = 0,
+   SVGA3D_FOGFUNC_EXP              = 1,
+   SVGA3D_FOGFUNC_EXP2             = 2,
+   SVGA3D_FOGFUNC_LINEAR           = 3,
+   SVGA3D_FOGFUNC_PER_VERTEX       = 4
+} SVGA3dFogFunction;
+
+/*
+ * SVGA3D_FOGTYPE_* specifies if fog factors are computed on a per-vertex
+ * or per-pixel basis.
+ */
+typedef enum {
+   SVGA3D_FOGTYPE_INVALID          = 0,
+   SVGA3D_FOGTYPE_VERTEX           = 1,
+   SVGA3D_FOGTYPE_PIXEL            = 2,
+   SVGA3D_FOGTYPE_MAX              = 3
+} SVGA3dFogType;
+
+/*
+ * SVGA3D_FOGBASE_* selects depth or range-based fog. Depth-based fog is
+ * computed using the eye Z value of each pixel (or vertex), whereas range-
+ * based fog is computed using the actual distance (range) to the eye.
+ */
+typedef enum {
+   SVGA3D_FOGBASE_INVALID          = 0,
+   SVGA3D_FOGBASE_DEPTHBASED       = 1,
+   SVGA3D_FOGBASE_RANGEBASED       = 2,
+   SVGA3D_FOGBASE_MAX              = 3
+} SVGA3dFogBase;
+
+typedef enum {
+   SVGA3D_STENCILOP_INVALID        = 0,
+   SVGA3D_STENCILOP_KEEP           = 1,
+   SVGA3D_STENCILOP_ZERO           = 2,
+   SVGA3D_STENCILOP_REPLACE        = 3,
+   SVGA3D_STENCILOP_INCRSAT        = 4,
+   SVGA3D_STENCILOP_DECRSAT        = 5,
+   SVGA3D_STENCILOP_INVERT         = 6,
+   SVGA3D_STENCILOP_INCR           = 7,
+   SVGA3D_STENCILOP_DECR           = 8,
+   SVGA3D_STENCILOP_MAX
+} SVGA3dStencilOp;
+
+typedef enum {
+   SVGA3D_CLIPPLANE_0              = (1 << 0),
+   SVGA3D_CLIPPLANE_1              = (1 << 1),
+   SVGA3D_CLIPPLANE_2              = (1 << 2),
+   SVGA3D_CLIPPLANE_3              = (1 << 3),
+   SVGA3D_CLIPPLANE_4              = (1 << 4),
+   SVGA3D_CLIPPLANE_5              = (1 << 5),
+} SVGA3dClipPlanes;
+
+typedef enum {
+   SVGA3D_CLEAR_COLOR              = 0x1,
+   SVGA3D_CLEAR_DEPTH              = 0x2,
+   SVGA3D_CLEAR_STENCIL            = 0x4
+} SVGA3dClearFlag;
+
+typedef enum {
+   SVGA3D_RT_DEPTH                 = 0,
+   SVGA3D_RT_STENCIL               = 1,
+   SVGA3D_RT_COLOR0                = 2,
+   SVGA3D_RT_COLOR1                = 3,
+   SVGA3D_RT_COLOR2                = 4,
+   SVGA3D_RT_COLOR3                = 5,
+   SVGA3D_RT_COLOR4                = 6,
+   SVGA3D_RT_COLOR5                = 7,
+   SVGA3D_RT_COLOR6                = 8,
+   SVGA3D_RT_COLOR7                = 9,
+   SVGA3D_RT_MAX,
+   SVGA3D_RT_INVALID               = ((uint32)-1),
+} SVGA3dRenderTargetType;
+
+#define SVGA3D_MAX_RT_COLOR (SVGA3D_RT_COLOR7 - SVGA3D_RT_COLOR0 + 1)
+
+typedef
+union {
+   struct {
+      uint32  red   : 1;
+      uint32  green : 1;
+      uint32  blue  : 1;
+      uint32  alpha : 1;
+   };
+   uint32 uintValue;
+} SVGA3dColorMask;
+
+typedef enum {
+   SVGA3D_VBLEND_DISABLE            = 0,
+   SVGA3D_VBLEND_1WEIGHT            = 1,
+   SVGA3D_VBLEND_2WEIGHT            = 2,
+   SVGA3D_VBLEND_3WEIGHT            = 3,
+} SVGA3dVertexBlendFlags;
+
+typedef enum {
+   SVGA3D_WRAPCOORD_0   = 1 << 0,
+   SVGA3D_WRAPCOORD_1   = 1 << 1,
+   SVGA3D_WRAPCOORD_2   = 1 << 2,
+   SVGA3D_WRAPCOORD_3   = 1 << 3,
+   SVGA3D_WRAPCOORD_ALL = 0xF,
+} SVGA3dWrapFlags;
+
+/*
+ * SVGA_3D_CMD_TEXTURESTATE Types.  All value types
+ * must fit in a uint32.
+ */
+
+typedef enum {
+   SVGA3D_TS_INVALID                    = 0,
+   SVGA3D_TS_BIND_TEXTURE               = 1,    /* SVGA3dSurfaceId */
+   SVGA3D_TS_COLOROP                    = 2,    /* SVGA3dTextureCombiner */
+   SVGA3D_TS_COLORARG1                  = 3,    /* SVGA3dTextureArgData */
+   SVGA3D_TS_COLORARG2                  = 4,    /* SVGA3dTextureArgData */
+   SVGA3D_TS_ALPHAOP                    = 5,    /* SVGA3dTextureCombiner */
+   SVGA3D_TS_ALPHAARG1                  = 6,    /* SVGA3dTextureArgData */
+   SVGA3D_TS_ALPHAARG2                  = 7,    /* SVGA3dTextureArgData */
+   SVGA3D_TS_ADDRESSU                   = 8,    /* SVGA3dTextureAddress */
+   SVGA3D_TS_ADDRESSV                   = 9,    /* SVGA3dTextureAddress */
+   SVGA3D_TS_MIPFILTER                  = 10,   /* SVGA3dTextureFilter */
+   SVGA3D_TS_MAGFILTER                  = 11,   /* SVGA3dTextureFilter */
+   SVGA3D_TS_MINFILTER                  = 12,   /* SVGA3dTextureFilter */
+   SVGA3D_TS_BORDERCOLOR                = 13,   /* SVGA3dColor */
+   SVGA3D_TS_TEXCOORDINDEX              = 14,   /* uint32 */
+   SVGA3D_TS_TEXTURETRANSFORMFLAGS      = 15,   /* SVGA3dTexTransformFlags */
+   SVGA3D_TS_TEXCOORDGEN                = 16,   /* SVGA3dTextureCoordGen */
+   SVGA3D_TS_BUMPENVMAT00               = 17,   /* float */
+   SVGA3D_TS_BUMPENVMAT01               = 18,   /* float */
+   SVGA3D_TS_BUMPENVMAT10               = 19,   /* float */
+   SVGA3D_TS_BUMPENVMAT11               = 20,   /* float */
+   SVGA3D_TS_TEXTURE_MIPMAP_LEVEL       = 21,   /* uint32 */
+   SVGA3D_TS_TEXTURE_LOD_BIAS           = 22,   /* float */
+   SVGA3D_TS_TEXTURE_ANISOTROPIC_LEVEL  = 23,   /* uint32 */
+   SVGA3D_TS_ADDRESSW                   = 24,   /* SVGA3dTextureAddress */
+
+
+   /*
+    * Sampler Gamma Level
+    *
+    * Sampler gamma effects the color of samples taken from the sampler.  A
+    * value of 1.0 will produce linear samples.  If the value is <= 0.0 the
+    * gamma value is ignored and a linear space is used.
+    */
+
+   SVGA3D_TS_GAMMA                      = 25,   /* float */
+   SVGA3D_TS_BUMPENVLSCALE              = 26,   /* float */
+   SVGA3D_TS_BUMPENVLOFFSET             = 27,   /* float */
+   SVGA3D_TS_COLORARG0                  = 28,   /* SVGA3dTextureArgData */
+   SVGA3D_TS_ALPHAARG0                  = 29,   /* SVGA3dTextureArgData */
+   SVGA3D_TS_MAX
+} SVGA3dTextureStateName;
+
+typedef enum {
+   SVGA3D_TC_INVALID                   = 0,
+   SVGA3D_TC_DISABLE                   = 1,
+   SVGA3D_TC_SELECTARG1                = 2,
+   SVGA3D_TC_SELECTARG2                = 3,
+   SVGA3D_TC_MODULATE                  = 4,
+   SVGA3D_TC_ADD                       = 5,
+   SVGA3D_TC_ADDSIGNED                 = 6,
+   SVGA3D_TC_SUBTRACT                  = 7,
+   SVGA3D_TC_BLENDTEXTUREALPHA         = 8,
+   SVGA3D_TC_BLENDDIFFUSEALPHA         = 9,
+   SVGA3D_TC_BLENDCURRENTALPHA         = 10,
+   SVGA3D_TC_BLENDFACTORALPHA          = 11,
+   SVGA3D_TC_MODULATE2X                = 12,
+   SVGA3D_TC_MODULATE4X                = 13,
+   SVGA3D_TC_DSDT                      = 14,
+   SVGA3D_TC_DOTPRODUCT3               = 15,
+   SVGA3D_TC_BLENDTEXTUREALPHAPM       = 16,
+   SVGA3D_TC_ADDSIGNED2X               = 17,
+   SVGA3D_TC_ADDSMOOTH                 = 18,
+   SVGA3D_TC_PREMODULATE               = 19,
+   SVGA3D_TC_MODULATEALPHA_ADDCOLOR    = 20,
+   SVGA3D_TC_MODULATECOLOR_ADDALPHA    = 21,
+   SVGA3D_TC_MODULATEINVALPHA_ADDCOLOR = 22,
+   SVGA3D_TC_MODULATEINVCOLOR_ADDALPHA = 23,
+   SVGA3D_TC_BUMPENVMAPLUMINANCE       = 24,
+   SVGA3D_TC_MULTIPLYADD               = 25,
+   SVGA3D_TC_LERP                      = 26,
+   SVGA3D_TC_MAX
+} SVGA3dTextureCombiner;
+
+#define SVGA3D_TC_CAP_BIT(svga3d_tc_op) (svga3d_tc_op ? (1 << (svga3d_tc_op - 1)) : 0)
+
+typedef enum {
+   SVGA3D_TEX_ADDRESS_INVALID    = 0,
+   SVGA3D_TEX_ADDRESS_WRAP       = 1,
+   SVGA3D_TEX_ADDRESS_MIRROR     = 2,
+   SVGA3D_TEX_ADDRESS_CLAMP      = 3,
+   SVGA3D_TEX_ADDRESS_BORDER     = 4,
+   SVGA3D_TEX_ADDRESS_MIRRORONCE = 5,
+   SVGA3D_TEX_ADDRESS_EDGE       = 6,
+   SVGA3D_TEX_ADDRESS_MAX
+} SVGA3dTextureAddress;
+
+/*
+ * SVGA3D_TEX_FILTER_NONE as the minification filter means mipmapping is
+ * disabled, and the rasterizer should use the magnification filter instead.
+ */
+typedef enum {
+   SVGA3D_TEX_FILTER_NONE           = 0,
+   SVGA3D_TEX_FILTER_NEAREST        = 1,
+   SVGA3D_TEX_FILTER_LINEAR         = 2,
+   SVGA3D_TEX_FILTER_ANISOTROPIC    = 3,
+   SVGA3D_TEX_FILTER_FLATCUBIC      = 4, // Deprecated, not implemented
+   SVGA3D_TEX_FILTER_GAUSSIANCUBIC  = 5, // Deprecated, not implemented
+   SVGA3D_TEX_FILTER_PYRAMIDALQUAD  = 6, // Not currently implemented
+   SVGA3D_TEX_FILTER_GAUSSIANQUAD   = 7, // Not currently implemented
+   SVGA3D_TEX_FILTER_MAX
+} SVGA3dTextureFilter;
+
+typedef enum {
+   SVGA3D_TEX_TRANSFORM_OFF    = 0,
+   SVGA3D_TEX_TRANSFORM_S      = (1 << 0),
+   SVGA3D_TEX_TRANSFORM_T      = (1 << 1),
+   SVGA3D_TEX_TRANSFORM_R      = (1 << 2),
+   SVGA3D_TEX_TRANSFORM_Q      = (1 << 3),
+   SVGA3D_TEX_PROJECTED        = (1 << 15),
+} SVGA3dTexTransformFlags;
+
+typedef enum {
+   SVGA3D_TEXCOORD_GEN_OFF              = 0,
+   SVGA3D_TEXCOORD_GEN_EYE_POSITION     = 1,
+   SVGA3D_TEXCOORD_GEN_EYE_NORMAL       = 2,
+   SVGA3D_TEXCOORD_GEN_REFLECTIONVECTOR = 3,
+   SVGA3D_TEXCOORD_GEN_SPHERE           = 4,
+   SVGA3D_TEXCOORD_GEN_MAX
+} SVGA3dTextureCoordGen;
+
+/*
+ * Texture argument constants for texture combiner
+ */
+typedef enum {
+   SVGA3D_TA_INVALID    = 0,
+   SVGA3D_TA_CONSTANT   = 1,
+   SVGA3D_TA_PREVIOUS   = 2,
+   SVGA3D_TA_DIFFUSE    = 3,
+   SVGA3D_TA_TEXTURE    = 4,
+   SVGA3D_TA_SPECULAR   = 5,
+   SVGA3D_TA_MAX
+} SVGA3dTextureArgData;
+
+#define SVGA3D_TM_MASK_LEN 4
+
+/* Modifiers for texture argument constants defined above. */
+typedef enum {
+   SVGA3D_TM_NONE       = 0,
+   SVGA3D_TM_ALPHA      = (1 << SVGA3D_TM_MASK_LEN),
+   SVGA3D_TM_ONE_MINUS  = (2 << SVGA3D_TM_MASK_LEN),
+} SVGA3dTextureArgModifier;
+
+#define SVGA3D_INVALID_ID         ((uint32)-1)
+#define SVGA3D_MAX_CLIP_PLANES    6
+
+/*
+ * This is the limit to the number of fixed-function texture
+ * transforms and texture coordinates we can support. It does *not*
+ * correspond to the number of texture image units (samplers) we
+ * support!
+ */
+#define SVGA3D_MAX_TEXTURE_COORDS 8
+
+/*
+ * Vertex declarations
+ *
+ * Notes:
+ *
+ * SVGA3D_DECLUSAGE_POSITIONT is for pre-transformed vertices. If you
+ * draw with any POSITIONT vertex arrays, the programmable vertex
+ * pipeline will be implicitly disabled. Drawing will take place as if
+ * no vertex shader was bound.
+ */
+
+typedef enum {
+   SVGA3D_DECLUSAGE_POSITION     = 0,
+   SVGA3D_DECLUSAGE_BLENDWEIGHT,       //  1
+   SVGA3D_DECLUSAGE_BLENDINDICES,      //  2
+   SVGA3D_DECLUSAGE_NORMAL,            //  3
+   SVGA3D_DECLUSAGE_PSIZE,             //  4
+   SVGA3D_DECLUSAGE_TEXCOORD,          //  5
+   SVGA3D_DECLUSAGE_TANGENT,           //  6
+   SVGA3D_DECLUSAGE_BINORMAL,          //  7
+   SVGA3D_DECLUSAGE_TESSFACTOR,        //  8
+   SVGA3D_DECLUSAGE_POSITIONT,         //  9
+   SVGA3D_DECLUSAGE_COLOR,             // 10
+   SVGA3D_DECLUSAGE_FOG,               // 11
+   SVGA3D_DECLUSAGE_DEPTH,             // 12
+   SVGA3D_DECLUSAGE_SAMPLE,            // 13
+   SVGA3D_DECLUSAGE_MAX
+} SVGA3dDeclUsage;
+
+typedef enum {
+   SVGA3D_DECLMETHOD_DEFAULT     = 0,
+   SVGA3D_DECLMETHOD_PARTIALU,
+   SVGA3D_DECLMETHOD_PARTIALV,
+   SVGA3D_DECLMETHOD_CROSSUV,          // Normal
+   SVGA3D_DECLMETHOD_UV,
+   SVGA3D_DECLMETHOD_LOOKUP,           // Lookup a displacement map
+   SVGA3D_DECLMETHOD_LOOKUPPRESAMPLED, // Lookup a pre-sampled displacement map
+} SVGA3dDeclMethod;
+
+typedef enum {
+   SVGA3D_DECLTYPE_FLOAT1        =  0,
+   SVGA3D_DECLTYPE_FLOAT2        =  1,
+   SVGA3D_DECLTYPE_FLOAT3        =  2,
+   SVGA3D_DECLTYPE_FLOAT4        =  3,
+   SVGA3D_DECLTYPE_D3DCOLOR      =  4,
+   SVGA3D_DECLTYPE_UBYTE4        =  5,
+   SVGA3D_DECLTYPE_SHORT2        =  6,
+   SVGA3D_DECLTYPE_SHORT4        =  7,
+   SVGA3D_DECLTYPE_UBYTE4N       =  8,
+   SVGA3D_DECLTYPE_SHORT2N       =  9,
+   SVGA3D_DECLTYPE_SHORT4N       = 10,
+   SVGA3D_DECLTYPE_USHORT2N      = 11,
+   SVGA3D_DECLTYPE_USHORT4N      = 12,
+   SVGA3D_DECLTYPE_UDEC3         = 13,
+   SVGA3D_DECLTYPE_DEC3N         = 14,
+   SVGA3D_DECLTYPE_FLOAT16_2     = 15,
+   SVGA3D_DECLTYPE_FLOAT16_4     = 16,
+   SVGA3D_DECLTYPE_MAX,
+} SVGA3dDeclType;
+
+/*
+ * This structure is used for the divisor for geometry instancing;
+ * it's a direct translation of the Direct3D equivalent.
+ */
+typedef union {
+   struct {
+      /*
+       * For index data, this number represents the number of instances to draw.
+       * For instance data, this number represents the number of
+       * instances/vertex in this stream
+       */
+      uint32 count : 30;
+
+      /*
+       * This is 1 if this is supposed to be the data that is repeated for
+       * every instance.
+       */
+      uint32 indexedData : 1;
+
+      /*
+       * This is 1 if this is supposed to be the per-instance data.
+       */
+      uint32 instanceData : 1;
+   };
+
+   uint32 value;
+} SVGA3dVertexDivisor;
+
+typedef enum {
+   SVGA3D_PRIMITIVE_INVALID                     = 0,
+   SVGA3D_PRIMITIVE_TRIANGLELIST                = 1,
+   SVGA3D_PRIMITIVE_POINTLIST                   = 2,
+   SVGA3D_PRIMITIVE_LINELIST                    = 3,
+   SVGA3D_PRIMITIVE_LINESTRIP                   = 4,
+   SVGA3D_PRIMITIVE_TRIANGLESTRIP               = 5,
+   SVGA3D_PRIMITIVE_TRIANGLEFAN                 = 6,
+   SVGA3D_PRIMITIVE_MAX
+} SVGA3dPrimitiveType;
+
+typedef enum {
+   SVGA3D_COORDINATE_INVALID                   = 0,
+   SVGA3D_COORDINATE_LEFTHANDED                = 1,
+   SVGA3D_COORDINATE_RIGHTHANDED               = 2,
+   SVGA3D_COORDINATE_MAX
+} SVGA3dCoordinateType;
+
+typedef enum {
+   SVGA3D_TRANSFORM_INVALID                     = 0,
+   SVGA3D_TRANSFORM_WORLD                       = 1,
+   SVGA3D_TRANSFORM_VIEW                        = 2,
+   SVGA3D_TRANSFORM_PROJECTION                  = 3,
+   SVGA3D_TRANSFORM_TEXTURE0                    = 4,
+   SVGA3D_TRANSFORM_TEXTURE1                    = 5,
+   SVGA3D_TRANSFORM_TEXTURE2                    = 6,
+   SVGA3D_TRANSFORM_TEXTURE3                    = 7,
+   SVGA3D_TRANSFORM_TEXTURE4                    = 8,
+   SVGA3D_TRANSFORM_TEXTURE5                    = 9,
+   SVGA3D_TRANSFORM_TEXTURE6                    = 10,
+   SVGA3D_TRANSFORM_TEXTURE7                    = 11,
+   SVGA3D_TRANSFORM_WORLD1                      = 12,
+   SVGA3D_TRANSFORM_WORLD2                      = 13,
+   SVGA3D_TRANSFORM_WORLD3                      = 14,
+   SVGA3D_TRANSFORM_MAX
+} SVGA3dTransformType;
+
+typedef enum {
+   SVGA3D_LIGHTTYPE_INVALID                     = 0,
+   SVGA3D_LIGHTTYPE_POINT                       = 1,
+   SVGA3D_LIGHTTYPE_SPOT1                       = 2, /* 1-cone, in degrees */
+   SVGA3D_LIGHTTYPE_SPOT2                       = 3, /* 2-cone, in radians */
+   SVGA3D_LIGHTTYPE_DIRECTIONAL                 = 4,
+   SVGA3D_LIGHTTYPE_MAX
+} SVGA3dLightType;
+
+typedef enum {
+   SVGA3D_CUBEFACE_POSX                         = 0,
+   SVGA3D_CUBEFACE_NEGX                         = 1,
+   SVGA3D_CUBEFACE_POSY                         = 2,
+   SVGA3D_CUBEFACE_NEGY                         = 3,
+   SVGA3D_CUBEFACE_POSZ                         = 4,
+   SVGA3D_CUBEFACE_NEGZ                         = 5,
+} SVGA3dCubeFace;
+
+typedef enum {
+   SVGA3D_SHADERTYPE_COMPILED_DX8               = 0,
+   SVGA3D_SHADERTYPE_VS                         = 1,
+   SVGA3D_SHADERTYPE_PS                         = 2,
+   SVGA3D_SHADERTYPE_MAX
+} SVGA3dShaderType;
+
+typedef enum {
+   SVGA3D_CONST_TYPE_FLOAT                      = 0,
+   SVGA3D_CONST_TYPE_INT                        = 1,
+   SVGA3D_CONST_TYPE_BOOL                       = 2,
+} SVGA3dShaderConstType;
+
+#define SVGA3D_MAX_SURFACE_FACES                6
+
+typedef enum {
+   SVGA3D_STRETCH_BLT_POINT                     = 0,
+   SVGA3D_STRETCH_BLT_LINEAR                    = 1,
+   SVGA3D_STRETCH_BLT_MAX
+} SVGA3dStretchBltMode;
+
+typedef enum {
+   SVGA3D_QUERYTYPE_OCCLUSION                   = 0,
+   SVGA3D_QUERYTYPE_MAX
+} SVGA3dQueryType;
+
+typedef enum {
+   SVGA3D_QUERYSTATE_PENDING     = 0,      /* Waiting on the host (set by guest) */
+   SVGA3D_QUERYSTATE_SUCCEEDED   = 1,      /* Completed successfully (set by host) */
+   SVGA3D_QUERYSTATE_FAILED      = 2,      /* Completed unsuccessfully (set by host) */
+   SVGA3D_QUERYSTATE_NEW         = 3,      /* Never submitted (For guest use only) */
+} SVGA3dQueryState;
+
+typedef enum {
+   SVGA3D_WRITE_HOST_VRAM        = 1,
+   SVGA3D_READ_HOST_VRAM         = 2,
+} SVGA3dTransferType;
+
+/*
+ * The maximum number vertex arrays we're guaranteed to support in
+ * SVGA_3D_CMD_DRAWPRIMITIVES.
+ */
+#define SVGA3D_MAX_VERTEX_ARRAYS   32
+
+/*
+ * Identifiers for commands in the command FIFO.
+ *
+ * IDs between 1000 and 1039 (inclusive) were used by obsolete versions of
+ * the SVGA3D protocol and remain reserved; they should not be used in the
+ * future.
+ *
+ * IDs between 1040 and 1999 (inclusive) are available for use by the
+ * current SVGA3D protocol.
+ *
+ * FIFO clients other than SVGA3D should stay below 1000, or at 2000
+ * and up.
+ */
+
+#define SVGA_3D_CMD_LEGACY_BASE            1000
+#define SVGA_3D_CMD_BASE                   1040
+
+#define SVGA_3D_CMD_SURFACE_DEFINE         SVGA_3D_CMD_BASE + 0
+#define SVGA_3D_CMD_SURFACE_DESTROY        SVGA_3D_CMD_BASE + 1
+#define SVGA_3D_CMD_SURFACE_COPY           SVGA_3D_CMD_BASE + 2
+#define SVGA_3D_CMD_SURFACE_STRETCHBLT     SVGA_3D_CMD_BASE + 3
+#define SVGA_3D_CMD_SURFACE_DMA            SVGA_3D_CMD_BASE + 4
+#define SVGA_3D_CMD_CONTEXT_DEFINE         SVGA_3D_CMD_BASE + 5
+#define SVGA_3D_CMD_CONTEXT_DESTROY        SVGA_3D_CMD_BASE + 6
+#define SVGA_3D_CMD_SETTRANSFORM           SVGA_3D_CMD_BASE + 7
+#define SVGA_3D_CMD_SETZRANGE              SVGA_3D_CMD_BASE + 8
+#define SVGA_3D_CMD_SETRENDERSTATE         SVGA_3D_CMD_BASE + 9
+#define SVGA_3D_CMD_SETRENDERTARGET        SVGA_3D_CMD_BASE + 10
+#define SVGA_3D_CMD_SETTEXTURESTATE        SVGA_3D_CMD_BASE + 11
+#define SVGA_3D_CMD_SETMATERIAL            SVGA_3D_CMD_BASE + 12
+#define SVGA_3D_CMD_SETLIGHTDATA           SVGA_3D_CMD_BASE + 13
+#define SVGA_3D_CMD_SETLIGHTENABLED        SVGA_3D_CMD_BASE + 14
+#define SVGA_3D_CMD_SETVIEWPORT            SVGA_3D_CMD_BASE + 15
+#define SVGA_3D_CMD_SETCLIPPLANE           SVGA_3D_CMD_BASE + 16
+#define SVGA_3D_CMD_CLEAR                  SVGA_3D_CMD_BASE + 17
+#define SVGA_3D_CMD_PRESENT                SVGA_3D_CMD_BASE + 18    // Deprecated
+#define SVGA_3D_CMD_SHADER_DEFINE          SVGA_3D_CMD_BASE + 19
+#define SVGA_3D_CMD_SHADER_DESTROY         SVGA_3D_CMD_BASE + 20
+#define SVGA_3D_CMD_SET_SHADER             SVGA_3D_CMD_BASE + 21
+#define SVGA_3D_CMD_SET_SHADER_CONST       SVGA_3D_CMD_BASE + 22
+#define SVGA_3D_CMD_DRAW_PRIMITIVES        SVGA_3D_CMD_BASE + 23
+#define SVGA_3D_CMD_SETSCISSORRECT         SVGA_3D_CMD_BASE + 24
+#define SVGA_3D_CMD_BEGIN_QUERY            SVGA_3D_CMD_BASE + 25
+#define SVGA_3D_CMD_END_QUERY              SVGA_3D_CMD_BASE + 26
+#define SVGA_3D_CMD_WAIT_FOR_QUERY         SVGA_3D_CMD_BASE + 27
+#define SVGA_3D_CMD_PRESENT_READBACK       SVGA_3D_CMD_BASE + 28    // Deprecated
+#define SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN SVGA_3D_CMD_BASE + 29
+#define SVGA_3D_CMD_MAX                    SVGA_3D_CMD_BASE + 30
+
+#define SVGA_3D_CMD_FUTURE_MAX             2000
+
+/*
+ * Common substructures used in multiple FIFO commands:
+ */
+
+typedef struct {
+   union {
+      struct {
+         uint16  function;       // SVGA3dFogFunction
+         uint8   type;           // SVGA3dFogType
+         uint8   base;           // SVGA3dFogBase
+      };
+      uint32     uintValue;
+   };
+} SVGA3dFogMode;
+
+/*
+ * Uniquely identify one image (a 1D/2D/3D array) from a surface. This
+ * is a surface ID as well as face/mipmap indices.
+ */
+
+typedef
+struct SVGA3dSurfaceImageId {
+   uint32               sid;
+   uint32               face;
+   uint32               mipmap;
+} SVGA3dSurfaceImageId;
+
+typedef
+struct SVGA3dGuestImage {
+   SVGAGuestPtr         ptr;
+
+   /*
+    * A note on interpretation of pitch: This value of pitch is the
+    * number of bytes between vertically adjacent image
+    * blocks. Normally this is the number of bytes between the first
+    * pixel of two adjacent scanlines. With compressed textures,
+    * however, this may represent the number of bytes between
+    * compression blocks rather than between rows of pixels.
+    *
+    * XXX: Compressed textures currently must be tightly packed in guest memory.
+    *
+    * If the image is 1-dimensional, pitch is ignored.
+    *
+    * If 'pitch' is zero, the SVGA3D device calculates a pitch value
+    * assuming each row of blocks is tightly packed.
+    */
+   uint32 pitch;
+} SVGA3dGuestImage;
+
+
+/*
+ * FIFO command format definitions:
+ */
+
+/*
+ * The data size header following cmdNum for every 3d command
+ */
+typedef
+struct {
+   uint32               id;
+   uint32               size;
+} SVGA3dCmdHeader;
+
+/*
+ * A surface is a hierarchy of host VRAM surfaces: 1D, 2D, or 3D, with
+ * optional mipmaps and cube faces.
+ */
+
+typedef
+struct {
+   uint32               width;
+   uint32               height;
+   uint32               depth;
+} SVGA3dSize;
+
+typedef enum {
+   SVGA3D_SURFACE_CUBEMAP              = (1 << 0),
+   SVGA3D_SURFACE_HINT_STATIC          = (1 << 1),
+   SVGA3D_SURFACE_HINT_DYNAMIC         = (1 << 2),
+   SVGA3D_SURFACE_HINT_INDEXBUFFER     = (1 << 3),
+   SVGA3D_SURFACE_HINT_VERTEXBUFFER    = (1 << 4),
+   SVGA3D_SURFACE_HINT_TEXTURE         = (1 << 5),
+   SVGA3D_SURFACE_HINT_RENDERTARGET    = (1 << 6),
+   SVGA3D_SURFACE_HINT_DEPTHSTENCIL    = (1 << 7),
+   SVGA3D_SURFACE_HINT_WRITEONLY       = (1 << 8),
+} SVGA3dSurfaceFlags;
+
+typedef
+struct {
+   uint32               numMipLevels;
+} SVGA3dSurfaceFace;
+
+typedef
+struct {
+   uint32                      sid;
+   SVGA3dSurfaceFlags          surfaceFlags;
+   SVGA3dSurfaceFormat         format;
+   SVGA3dSurfaceFace           face[SVGA3D_MAX_SURFACE_FACES];
+   /*
+    * Followed by an SVGA3dSize structure for each mip level in each face.
+    *
+    * A note on surface sizes: Sizes are always specified in pixels,
+    * even if the true surface size is not a multiple of the minimum
+    * block size of the surface's format. For example, a 3x3x1 DXT1
+    * compressed texture would actually be stored as a 4x4x1 image in
+    * memory.
+    */
+} SVGA3dCmdDefineSurface;       /* SVGA_3D_CMD_SURFACE_DEFINE */
+
+typedef
+struct {
+   uint32               sid;
+} SVGA3dCmdDestroySurface;      /* SVGA_3D_CMD_SURFACE_DESTROY */
+
+typedef
+struct {
+   uint32               cid;
+} SVGA3dCmdDefineContext;       /* SVGA_3D_CMD_CONTEXT_DEFINE */
+
+typedef
+struct {
+   uint32               cid;
+} SVGA3dCmdDestroyContext;      /* SVGA_3D_CMD_CONTEXT_DESTROY */
+
+typedef
+struct {
+   uint32               cid;
+   SVGA3dClearFlag      clearFlag;
+   uint32               color;
+   float                depth;
+   uint32               stencil;
+   /* Followed by variable number of SVGA3dRect structures */
+} SVGA3dCmdClear;               /* SVGA_3D_CMD_CLEAR */
+
+typedef
+struct SVGA3dCopyRect {
+   uint32               x;
+   uint32               y;
+   uint32               w;
+   uint32               h;
+   uint32               srcx;
+   uint32               srcy;
+} SVGA3dCopyRect;
+
+typedef
+struct SVGA3dCopyBox {
+   uint32               x;
+   uint32               y;
+   uint32               z;
+   uint32               w;
+   uint32               h;
+   uint32               d;
+   uint32               srcx;
+   uint32               srcy;
+   uint32               srcz;
+} SVGA3dCopyBox;
+
+typedef
+struct {
+   uint32               x;
+   uint32               y;
+   uint32               w;
+   uint32               h;
+} SVGA3dRect;
+
+typedef
+struct {
+   uint32               x;
+   uint32               y;
+   uint32               z;
+   uint32               w;
+   uint32               h;
+   uint32               d;
+} SVGA3dBox;
+
+typedef
+struct {
+   uint32               x;
+   uint32               y;
+   uint32               z;
+} SVGA3dPoint;
+
+typedef
+struct {
+   SVGA3dLightType      type;
+   SVGA3dBool           inWorldSpace;
+   float                diffuse[4];
+   float                specular[4];
+   float                ambient[4];
+   float                position[4];
+   float                direction[4];
+   float                range;
+   float                falloff;
+   float                attenuation0;
+   float                attenuation1;
+   float                attenuation2;
+   float                theta;
+   float                phi;
+} SVGA3dLightData;
+
+typedef
+struct {
+   uint32               sid;
+   /* Followed by variable number of SVGA3dCopyRect structures */
+} SVGA3dCmdPresent;             /* SVGA_3D_CMD_PRESENT */
+
+typedef
+struct {
+   SVGA3dRenderStateName   state;
+   union {
+      uint32               uintValue;
+      float                floatValue;
+   };
+} SVGA3dRenderState;
+
+typedef
+struct {
+   uint32               cid;
+   /* Followed by variable number of SVGA3dRenderState structures */
+} SVGA3dCmdSetRenderState;      /* SVGA_3D_CMD_SETRENDERSTATE */
+
+typedef
+struct {
+   uint32                 cid;
+   SVGA3dRenderTargetType type;
+   SVGA3dSurfaceImageId   target;
+} SVGA3dCmdSetRenderTarget;     /* SVGA_3D_CMD_SETRENDERTARGET */
+
+typedef
+struct {
+   SVGA3dSurfaceImageId  src;
+   SVGA3dSurfaceImageId  dest;
+   /* Followed by variable number of SVGA3dCopyBox structures */
+} SVGA3dCmdSurfaceCopy;               /* SVGA_3D_CMD_SURFACE_COPY */
+
+typedef
+struct {
+   SVGA3dSurfaceImageId  src;
+   SVGA3dSurfaceImageId  dest;
+   SVGA3dBox             boxSrc;
+   SVGA3dBox             boxDest;
+   SVGA3dStretchBltMode  mode;
+} SVGA3dCmdSurfaceStretchBlt;         /* SVGA_3D_CMD_SURFACE_STRETCHBLT */
+
+typedef
+struct {
+   /*
+    * If the discard flag is present in a surface DMA operation, the host may
+    * discard the contents of the current mipmap level and face of the target
+    * surface before applying the surface DMA contents.
+    */
+   uint32 discard : 1;
+
+   /*
+    * If the unsynchronized flag is present, the host may perform this upload
+    * without syncing to pending reads on this surface.
+    */
+   uint32 unsynchronized : 1;
+
+   /*
+    * Guests *MUST* set the reserved bits to 0 before submitting the command
+    * suffix as future flags may occupy these bits.
+    */
+   uint32 reserved : 30;
+} SVGA3dSurfaceDMAFlags;
+
+typedef
+struct {
+   SVGA3dGuestImage      guest;
+   SVGA3dSurfaceImageId  host;
+   SVGA3dTransferType    transfer;
+   /*
+    * Followed by variable number of SVGA3dCopyBox structures. For consistency
+    * in all clipping logic and coordinate translation, we define the
+    * "source" in each copyBox as the guest image and the
+    * "destination" as the host image, regardless of transfer
+    * direction.
+    *
+    * For efficiency, the SVGA3D device is free to copy more data than
+    * specified. For example, it may round copy boxes outwards such
+    * that they lie on particular alignment boundaries.
+    */
+} SVGA3dCmdSurfaceDMA;                /* SVGA_3D_CMD_SURFACE_DMA */
+
+/*
+ * SVGA3dCmdSurfaceDMASuffix --
+ *
+ *    This is a command suffix that will appear after a SurfaceDMA command in
+ *    the FIFO.  It contains some extra information that hosts may use to
+ *    optimize performance or protect the guest.  This suffix exists to preserve
+ *    backwards compatibility while also allowing for new functionality to be
+ *    implemented.
+ */
+
+typedef
+struct {
+   uint32 suffixSize;
+
+   /*
+    * The maximum offset is used to determine the maximum offset from the
+    * guestPtr base address that will be accessed or written to during this
+    * surfaceDMA.  If the suffix is supported, the host will respect this
+    * boundary while performing surface DMAs.
+    *
+    * Defaults to MAX_UINT32
+    */
+   uint32 maximumOffset;
+
+   /*
+    * A set of flags that describes optimizations that the host may perform
+    * while performing this surface DMA operation.  The guest should never rely
+    * on behaviour that is different when these flags are set for correctness.
+    *
+    * Defaults to 0
+    */
+   SVGA3dSurfaceDMAFlags flags;
+} SVGA3dCmdSurfaceDMASuffix;
+
+/*
+ * SVGA_3D_CMD_DRAW_PRIMITIVES --
+ *
+ *   This command is the SVGA3D device's generic drawing entry point.
+ *   It can draw multiple ranges of primitives, optionally using an
+ *   index buffer, using an arbitrary collection of vertex buffers.
+ *
+ *   Each SVGA3dVertexDecl defines a distinct vertex array to bind
+ *   during this draw call. The declarations specify which surface
+ *   the vertex data lives in, what that vertex data is used for,
+ *   and how to interpret it.
+ *
+ *   Each SVGA3dPrimitiveRange defines a collection of primitives
+ *   to render using the same vertex arrays. An index buffer is
+ *   optional.
+ */
+
+typedef
+struct {
+   /*
+    * A range hint is an optional specification for the range of indices
+    * in an SVGA3dArray that will be used. If 'last' is zero, it is assumed
+    * that the entire array will be used.
+    *
+    * These are only hints. The SVGA3D device may use them for
+    * performance optimization if possible, but it's also allowed to
+    * ignore these values.
+    */
+   uint32               first;
+   uint32               last;
+} SVGA3dArrayRangeHint;
+
+typedef
+struct {
+   /*
+    * Define the origin and shape of a vertex or index array. Both
+    * 'offset' and 'stride' are in bytes. The provided surface will be
+    * reinterpreted as a flat array of bytes in the same format used
+    * by surface DMA operations. To avoid unnecessary conversions, the
+    * surface should be created with the SVGA3D_BUFFER format.
+    *
+    * Index 0 in the array starts 'offset' bytes into the surface.
+    * Index 1 begins at byte 'offset + stride', etc. Array indices may
+    * not be negative.
+    */
+   uint32               surfaceId;
+   uint32               offset;
+   uint32               stride;
+} SVGA3dArray;
+
+typedef
+struct {
+   /*
+    * Describe a vertex array's data type, and define how it is to be
+    * used by the fixed function pipeline or the vertex shader. It
+    * isn't useful to have two VertexDecls with the same
+    * VertexArrayIdentity in one draw call.
+    */
+   SVGA3dDeclType       type;
+   SVGA3dDeclMethod     method;
+   SVGA3dDeclUsage      usage;
+   uint32               usageIndex;
+} SVGA3dVertexArrayIdentity;
+
+typedef
+struct {
+   SVGA3dVertexArrayIdentity  identity;
+   SVGA3dArray                array;
+   SVGA3dArrayRangeHint       rangeHint;
+} SVGA3dVertexDecl;
+
+typedef
+struct {
+   /*
+    * Define a group of primitives to render, from sequential indices.
+    *
+    * The value of 'primitiveType' and 'primitiveCount' imply the
+    * total number of vertices that will be rendered.
+    */
+   SVGA3dPrimitiveType  primType;
+   uint32               primitiveCount;
+
+   /*
+    * Optional index buffer. If indexArray.surfaceId is
+    * SVGA3D_INVALID_ID, we render without an index buffer. Rendering
+    * without an index buffer is identical to rendering with an index
+    * buffer containing the sequence [0, 1, 2, 3, ...].
+    *
+    * If an index buffer is in use, indexWidth specifies the width in
+    * bytes of each index value. It must be less than or equal to
+    * indexArray.stride.
+    *
+    * (Currently, the SVGA3D device requires index buffers to be tightly
+    * packed. In other words, indexWidth == indexArray.stride)
+    */
+   SVGA3dArray          indexArray;
+   uint32               indexWidth;
+
+   /*
+    * Optional index bias. This number is added to all indices from
+    * indexArray before they are used as vertex array indices. This
+    * can be used in multiple ways:
+    *
+    *  - When not using an indexArray, this bias can be used to
+    *    specify where in the vertex arrays to begin rendering.
+    *
+    *  - A positive number here is equivalent to increasing the
+    *    offset in each vertex array.
+    *
+    *  - A negative number can be used to render using a small
+    *    vertex array and an index buffer that contains large
+    *    values. This may be used by some applications that
+    *    crop a vertex buffer without modifying their index
+    *    buffer.
+    *
+    * Note that rendering with a negative bias value may be slower and
+    * use more memory than rendering with a positive or zero bias.
+    */
+   int32                indexBias;
+} SVGA3dPrimitiveRange;
+
+typedef
+struct {
+   uint32               cid;
+   uint32               numVertexDecls;
+   uint32               numRanges;
+
+   /*
+    * There are two variable size arrays after the
+    * SVGA3dCmdDrawPrimitives structure. In order,
+    * they are:
+    *
+    * 1. SVGA3dVertexDecl, quantity 'numVertexDecls'
+    * 2. SVGA3dPrimitiveRange, quantity 'numRanges'
+    * 3. Optionally, SVGA3dVertexDivisor, quantity 'numVertexDecls' (contains
+    *    the frequency divisor for this the corresponding vertex decl)
+    */
+} SVGA3dCmdDrawPrimitives;      /* SVGA_3D_CMD_DRAWPRIMITIVES */
+
+typedef
+struct {
+   uint32                   stage;
+   SVGA3dTextureStateName   name;
+   union {
+      uint32                value;
+      float                 floatValue;
+   };
+} SVGA3dTextureState;
+
+typedef
+struct {
+   uint32               cid;
+   /* Followed by variable number of SVGA3dTextureState structures */
+} SVGA3dCmdSetTextureState;      /* SVGA_3D_CMD_SETTEXTURESTATE */
+
+typedef
+struct {
+   uint32                   cid;
+   SVGA3dTransformType      type;
+   float                    matrix[16];
+} SVGA3dCmdSetTransform;          /* SVGA_3D_CMD_SETTRANSFORM */
+
+typedef
+struct {
+   float                min;
+   float                max;
+} SVGA3dZRange;
+
+typedef
+struct {
+   uint32               cid;
+   SVGA3dZRange         zRange;
+} SVGA3dCmdSetZRange;             /* SVGA_3D_CMD_SETZRANGE */
+
+typedef
+struct {
+   float                diffuse[4];
+   float                ambient[4];
+   float                specular[4];
+   float                emissive[4];
+   float                shininess;
+} SVGA3dMaterial;
+
+typedef
+struct {
+   uint32               cid;
+   SVGA3dFace           face;
+   SVGA3dMaterial       material;
+} SVGA3dCmdSetMaterial;           /* SVGA_3D_CMD_SETMATERIAL */
+
+typedef
+struct {
+   uint32               cid;
+   uint32               index;
+   SVGA3dLightData      data;
+} SVGA3dCmdSetLightData;           /* SVGA_3D_CMD_SETLIGHTDATA */
+
+typedef
+struct {
+   uint32               cid;
+   uint32               index;
+   uint32               enabled;
+} SVGA3dCmdSetLightEnabled;      /* SVGA_3D_CMD_SETLIGHTENABLED */
+
+typedef
+struct {
+   uint32               cid;
+   SVGA3dRect           rect;
+} SVGA3dCmdSetViewport;           /* SVGA_3D_CMD_SETVIEWPORT */
+
+typedef
+struct {
+   uint32               cid;
+   SVGA3dRect           rect;
+} SVGA3dCmdSetScissorRect;         /* SVGA_3D_CMD_SETSCISSORRECT */
+
+typedef
+struct {
+   uint32               cid;
+   uint32               index;
+   float                plane[4];
+} SVGA3dCmdSetClipPlane;           /* SVGA_3D_CMD_SETCLIPPLANE */
+
+typedef
+struct {
+   uint32               cid;
+   uint32               shid;
+   SVGA3dShaderType     type;
+   /* Followed by variable number of DWORDs for shader bycode */
+} SVGA3dCmdDefineShader;           /* SVGA_3D_CMD_SHADER_DEFINE */
+
+typedef
+struct {
+   uint32               cid;
+   uint32               shid;
+   SVGA3dShaderType     type;
+} SVGA3dCmdDestroyShader;         /* SVGA_3D_CMD_SHADER_DESTROY */
+
+typedef
+struct {
+   uint32                  cid;
+   uint32                  reg;     /* register number */
+   SVGA3dShaderType        type;
+   SVGA3dShaderConstType   ctype;
+   uint32                  values[4];
+} SVGA3dCmdSetShaderConst;        /* SVGA_3D_CMD_SET_SHADER_CONST */
+
+typedef
+struct {
+   uint32               cid;
+   SVGA3dShaderType     type;
+   uint32               shid;
+} SVGA3dCmdSetShader;             /* SVGA_3D_CMD_SET_SHADER */
+
+typedef
+struct {
+   uint32               cid;
+   SVGA3dQueryType      type;
+} SVGA3dCmdBeginQuery;           /* SVGA_3D_CMD_BEGIN_QUERY */
+
+typedef
+struct {
+   uint32               cid;
+   SVGA3dQueryType      type;
+   SVGAGuestPtr         guestResult;  /* Points to an SVGA3dQueryResult structure */
+} SVGA3dCmdEndQuery;                  /* SVGA_3D_CMD_END_QUERY */
+
+typedef
+struct {
+   uint32               cid;          /* Same parameters passed to END_QUERY */
+   SVGA3dQueryType      type;
+   SVGAGuestPtr         guestResult;
+} SVGA3dCmdWaitForQuery;              /* SVGA_3D_CMD_WAIT_FOR_QUERY */
+
+typedef
+struct {
+   uint32               totalSize;    /* Set by guest before query is ended. */
+   SVGA3dQueryState     state;        /* Set by host or guest. See SVGA3dQueryState. */
+   union {                            /* Set by host on exit from PENDING state */
+      uint32            result32;
+   };
+} SVGA3dQueryResult;
+
+/*
+ * SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN --
+ *
+ *    This is a blit from an SVGA3D surface to a Screen Object. Just
+ *    like GMR-to-screen blits, this blit may be directed at a
+ *    specific screen or to the virtual coordinate space.
+ *
+ *    The blit copies from a rectangular region of an SVGA3D surface
+ *    image to a rectangular region of a screen or screens.
+ *
+ *    This command takes an optional variable-length list of clipping
+ *    rectangles after the body of the command. If no rectangles are
+ *    specified, there is no clipping region. The entire destRect is
+ *    drawn to. If one or more rectangles are included, they describe
+ *    a clipping region. The clip rectangle coordinates are measured
+ *    relative to the top-left corner of destRect.
+ *
+ *    This clipping region serves multiple purposes:
+ *
+ *      - It can be used to perform an irregularly shaped blit more
+ *        efficiently than by issuing many separate blit commands.
+ *
+ *      - It is equivalent to allowing blits with non-integer
+ *        source coordinates. You could blit just one half-pixel
+ *        of a source, for example, by specifying a larger
+ *        destination rectangle than you need, then removing
+ *        part of it using a clip rectangle.
+ *
+ * Availability:
+ *    SVGA_FIFO_CAP_SCREEN_OBJECT
+ *
+ * Limitations:
+ *
+ *    - Currently, no backend supports blits from a mipmap or face
+ *      other than the first one.
+ */
+
+typedef
+struct {
+   SVGA3dSurfaceImageId srcImage;
+   SVGASignedRect       srcRect;
+   uint32               destScreenId; /* Screen ID or SVGA_ID_INVALID for virt. coords */
+   SVGASignedRect       destRect;     /* Supports scaling if src/rest different size */
+   /* Clipping: zero or more SVGASignedRects follow */
+} SVGA3dCmdBlitSurfaceToScreen;         /* SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN */
+
+
+/*
+ * Capability query index.
+ *
+ * Notes:
+ *
+ *   1. SVGA3D_DEVCAP_MAX_TEXTURES reflects the maximum number of
+ *      fixed-function texture units available. Each of these units
+ *      work in both FFP and Shader modes, and they support texture
+ *      transforms and texture coordinates. The host may have additional
+ *      texture image units that are only usable with shaders.
+ *
+ *   2. The BUFFER_FORMAT capabilities are deprecated, and they always
+ *      return TRUE. Even on physical hardware that does not support
+ *      these formats natively, the SVGA3D device will provide an emulation
+ *      which should be invisible to the guest OS.
+ *
+ *      In general, the SVGA3D device should support any operation on
+ *      any surface format, it just may perform some of these
+ *      operations in software depending on the capabilities of the
+ *      available physical hardware.
+ *
+ *      XXX: In the future, we will add capabilities that describe in
+ *      detail what formats are supported in hardware for what kinds
+ *      of operations.
+ */
+
+typedef enum {
+   SVGA3D_DEVCAP_3D                                = 0,
+   SVGA3D_DEVCAP_MAX_LIGHTS                        = 1,
+   SVGA3D_DEVCAP_MAX_TEXTURES                      = 2,  /* See note (1) */
+   SVGA3D_DEVCAP_MAX_CLIP_PLANES                   = 3,
+   SVGA3D_DEVCAP_VERTEX_SHADER_VERSION             = 4,
+   SVGA3D_DEVCAP_VERTEX_SHADER                     = 5,
+   SVGA3D_DEVCAP_FRAGMENT_SHADER_VERSION           = 6,
+   SVGA3D_DEVCAP_FRAGMENT_SHADER                   = 7,
+   SVGA3D_DEVCAP_MAX_RENDER_TARGETS                = 8,
+   SVGA3D_DEVCAP_S23E8_TEXTURES                    = 9,
+   SVGA3D_DEVCAP_S10E5_TEXTURES                    = 10,
+   SVGA3D_DEVCAP_MAX_FIXED_VERTEXBLEND             = 11,
+   SVGA3D_DEVCAP_D16_BUFFER_FORMAT                 = 12, /* See note (2) */
+   SVGA3D_DEVCAP_D24S8_BUFFER_FORMAT               = 13, /* See note (2) */
+   SVGA3D_DEVCAP_D24X8_BUFFER_FORMAT               = 14, /* See note (2) */
+   SVGA3D_DEVCAP_QUERY_TYPES                       = 15,
+   SVGA3D_DEVCAP_TEXTURE_GRADIENT_SAMPLING         = 16,
+   SVGA3D_DEVCAP_MAX_POINT_SIZE                    = 17,
+   SVGA3D_DEVCAP_MAX_SHADER_TEXTURES               = 18,
+   SVGA3D_DEVCAP_MAX_TEXTURE_WIDTH                 = 19,
+   SVGA3D_DEVCAP_MAX_TEXTURE_HEIGHT                = 20,
+   SVGA3D_DEVCAP_MAX_VOLUME_EXTENT                 = 21,
+   SVGA3D_DEVCAP_MAX_TEXTURE_REPEAT                = 22,
+   SVGA3D_DEVCAP_MAX_TEXTURE_ASPECT_RATIO          = 23,
+   SVGA3D_DEVCAP_MAX_TEXTURE_ANISOTROPY            = 24,
+   SVGA3D_DEVCAP_MAX_PRIMITIVE_COUNT               = 25,
+   SVGA3D_DEVCAP_MAX_VERTEX_INDEX                  = 26,
+   SVGA3D_DEVCAP_MAX_VERTEX_SHADER_INSTRUCTIONS    = 27,
+   SVGA3D_DEVCAP_MAX_FRAGMENT_SHADER_INSTRUCTIONS  = 28,
+   SVGA3D_DEVCAP_MAX_VERTEX_SHADER_TEMPS           = 29,
+   SVGA3D_DEVCAP_MAX_FRAGMENT_SHADER_TEMPS         = 30,
+   SVGA3D_DEVCAP_TEXTURE_OPS                       = 31,
+   SVGA3D_DEVCAP_SURFACEFMT_X8R8G8B8               = 32,
+   SVGA3D_DEVCAP_SURFACEFMT_A8R8G8B8               = 33,
+   SVGA3D_DEVCAP_SURFACEFMT_A2R10G10B10            = 34,
+   SVGA3D_DEVCAP_SURFACEFMT_X1R5G5B5               = 35,
+   SVGA3D_DEVCAP_SURFACEFMT_A1R5G5B5               = 36,
+   SVGA3D_DEVCAP_SURFACEFMT_A4R4G4B4               = 37,
+   SVGA3D_DEVCAP_SURFACEFMT_R5G6B5                 = 38,
+   SVGA3D_DEVCAP_SURFACEFMT_LUMINANCE16            = 39,
+   SVGA3D_DEVCAP_SURFACEFMT_LUMINANCE8_ALPHA8      = 40,
+   SVGA3D_DEVCAP_SURFACEFMT_ALPHA8                 = 41,
+   SVGA3D_DEVCAP_SURFACEFMT_LUMINANCE8             = 42,
+   SVGA3D_DEVCAP_SURFACEFMT_Z_D16                  = 43,
+   SVGA3D_DEVCAP_SURFACEFMT_Z_D24S8                = 44,
+   SVGA3D_DEVCAP_SURFACEFMT_Z_D24X8                = 45,
+   SVGA3D_DEVCAP_SURFACEFMT_DXT1                   = 46,
+   SVGA3D_DEVCAP_SURFACEFMT_DXT2                   = 47,
+   SVGA3D_DEVCAP_SURFACEFMT_DXT3                   = 48,
+   SVGA3D_DEVCAP_SURFACEFMT_DXT4                   = 49,
+   SVGA3D_DEVCAP_SURFACEFMT_DXT5                   = 50,
+   SVGA3D_DEVCAP_SURFACEFMT_BUMPX8L8V8U8           = 51,
+   SVGA3D_DEVCAP_SURFACEFMT_A2W10V10U10            = 52,
+   SVGA3D_DEVCAP_SURFACEFMT_BUMPU8V8               = 53,
+   SVGA3D_DEVCAP_SURFACEFMT_Q8W8V8U8               = 54,
+   SVGA3D_DEVCAP_SURFACEFMT_CxV8U8                 = 55,
+   SVGA3D_DEVCAP_SURFACEFMT_R_S10E5                = 56,
+   SVGA3D_DEVCAP_SURFACEFMT_R_S23E8                = 57,
+   SVGA3D_DEVCAP_SURFACEFMT_RG_S10E5               = 58,
+   SVGA3D_DEVCAP_SURFACEFMT_RG_S23E8               = 59,
+   SVGA3D_DEVCAP_SURFACEFMT_ARGB_S10E5             = 60,
+   SVGA3D_DEVCAP_SURFACEFMT_ARGB_S23E8             = 61,
+   SVGA3D_DEVCAP_MAX_VERTEX_SHADER_TEXTURES        = 63,
+
+   /*
+    * Note that MAX_SIMULTANEOUS_RENDER_TARGETS is a maximum count of color
+    * render targets.  This does no include the depth or stencil targets.
+    */
+   SVGA3D_DEVCAP_MAX_SIMULTANEOUS_RENDER_TARGETS   = 64,
+
+   SVGA3D_DEVCAP_SURFACEFMT_V16U16                 = 65,
+   SVGA3D_DEVCAP_SURFACEFMT_G16R16                 = 66,
+   SVGA3D_DEVCAP_SURFACEFMT_A16B16G16R16           = 67,
+   SVGA3D_DEVCAP_SURFACEFMT_UYVY                   = 68,
+   SVGA3D_DEVCAP_SURFACEFMT_YUY2                   = 69,
+
+   /*
+    * Don't add new caps into the previous section; the values in this
+    * enumeration must not change. You can put new values right before
+    * SVGA3D_DEVCAP_MAX.
+    */
+   SVGA3D_DEVCAP_MAX                                  /* This must be the last index. */
+} SVGA3dDevCapIndex;
+
+typedef union {
+   Bool   b;
+   uint32 u;
+   int32  i;
+   float  f;
+} SVGA3dDevCapResult;
+
+#endif /* _SVGA3D_REG_H_ */
diff --git a/src/gallium/drivers/svga/include/svga3d_shaderdefs.h b/src/gallium/drivers/svga/include/svga3d_shaderdefs.h
new file mode 100644 (file)
index 0000000..2078c4a
--- /dev/null
@@ -0,0 +1,519 @@
+/**********************************************************
+ * Copyright 2007-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+/*
+ * svga3d_shaderdefs.h --
+ *
+ * SVGA3D byte code format and limit definitions.
+ *
+ * The format of the byte code directly corresponds to that defined
+ * by Microsoft DirectX SDK 9.0c (file d3d9types.h). The format can
+ * also be extended so that different shader formats can be supported
+ * for example GLSL, ARB vp/fp, NV/ATI shader formats, etc.
+ *
+ */
+
+#ifndef __SVGA3D_SHADER_DEFS__
+#define __SVGA3D_SHADER_DEFS__
+
+/* SVGA3D shader hardware limits. */
+
+#define SVGA3D_INPUTREG_MAX            16
+#define SVGA3D_OUTPUTREG_MAX           12
+#define SVGA3D_VERTEX_SAMPLERREG_MAX   4
+#define SVGA3D_PIXEL_SAMPLERREG_MAX    16
+#define SVGA3D_SAMPLERREG_MAX          (SVGA3D_PIXEL_SAMPLERREG_MAX+\
+                                        SVGA3D_VERTEX_SAMPLERREG_MAX)
+#define SVGA3D_TEMPREG_MAX             32
+#define SVGA3D_CONSTREG_MAX            256
+#define SVGA3D_CONSTINTREG_MAX         16
+#define SVGA3D_CONSTBOOLREG_MAX        16
+#define SVGA3D_ADDRREG_MAX             1
+#define SVGA3D_PREDREG_MAX             1
+
+/* SVGA3D byte code specific limits */
+
+#define SVGA3D_MAX_SRC_REGS      4
+#define SVGA3D_MAX_NESTING_LEVEL 32
+
+/* SVGA3D version information. */
+
+#define SVGA3D_VS_TYPE  0xFFFE
+#define SVGA3D_PS_TYPE  0xFFFF
+
+typedef struct {
+   union {
+      struct {
+         uint32 minor : 8;
+         uint32 major : 8;
+         uint32 type : 16;
+      };
+
+      uint32 value;
+   };
+} SVGA3dShaderVersion;
+
+#define SVGA3D_VS_10 ((SVGA3D_VS_TYPE << 16) | 1 << 8)
+#define SVGA3D_VS_11 (SVGA3D_VS_10 | 1)
+#define SVGA3D_VS_20 ((SVGA3D_VS_TYPE << 16) | 2 << 8)
+#define SVGA3D_VS_30 ((SVGA3D_VS_TYPE << 16) | 3 << 8)
+
+#define SVGA3D_PS_10 ((SVGA3D_PS_TYPE << 16) | 1 << 8)
+#define SVGA3D_PS_11 (SVGA3D_PS_10 | 1)
+#define SVGA3D_PS_12 (SVGA3D_PS_10 | 2)
+#define SVGA3D_PS_13 (SVGA3D_PS_10 | 3)
+#define SVGA3D_PS_14 (SVGA3D_PS_10 | 4)
+#define SVGA3D_PS_20 ((SVGA3D_PS_TYPE << 16) | 2 << 8)
+#define SVGA3D_PS_30 ((SVGA3D_PS_TYPE << 16) | 3 << 8)
+
+/* The *_ENABLED are for backwards compatibility with old drivers */
+typedef enum {
+   SVGA3DPSVERSION_NONE = 0,
+   SVGA3DPSVERSION_ENABLED = 1,
+   SVGA3DPSVERSION_11 = 3,
+   SVGA3DPSVERSION_12 = 5,
+   SVGA3DPSVERSION_13 = 7,
+   SVGA3DPSVERSION_14 = 9,
+   SVGA3DPSVERSION_20 = 11,
+   SVGA3DPSVERSION_30 = 13,
+   SVGA3DPSVERSION_40 = 15,
+   SVGA3DPSVERSION_MAX
+} SVGA3dPixelShaderVersion;
+
+typedef enum {
+   SVGA3DVSVERSION_NONE = 0,
+   SVGA3DVSVERSION_ENABLED = 1,
+   SVGA3DVSVERSION_11 = 3,
+   SVGA3DVSVERSION_20 = 5,
+   SVGA3DVSVERSION_30 = 7,
+   SVGA3DVSVERSION_40 = 9,
+   SVGA3DVSVERSION_MAX
+} SVGA3dVertexShaderVersion;
+
+/* SVGA3D instruction op codes. */
+
+typedef enum {
+   SVGA3DOP_NOP = 0,
+   SVGA3DOP_MOV,
+   SVGA3DOP_ADD,
+   SVGA3DOP_SUB,
+   SVGA3DOP_MAD,
+   SVGA3DOP_MUL,
+   SVGA3DOP_RCP,
+   SVGA3DOP_RSQ,
+   SVGA3DOP_DP3,
+   SVGA3DOP_DP4,
+   SVGA3DOP_MIN,
+   SVGA3DOP_MAX,
+   SVGA3DOP_SLT,
+   SVGA3DOP_SGE,
+   SVGA3DOP_EXP,
+   SVGA3DOP_LOG,
+   SVGA3DOP_LIT,
+   SVGA3DOP_DST,
+   SVGA3DOP_LRP,
+   SVGA3DOP_FRC,
+   SVGA3DOP_M4x4,
+   SVGA3DOP_M4x3,
+   SVGA3DOP_M3x4,
+   SVGA3DOP_M3x3,
+   SVGA3DOP_M3x2,
+   SVGA3DOP_CALL,
+   SVGA3DOP_CALLNZ,
+   SVGA3DOP_LOOP,
+   SVGA3DOP_RET,
+   SVGA3DOP_ENDLOOP,
+   SVGA3DOP_LABEL,
+   SVGA3DOP_DCL,
+   SVGA3DOP_POW,
+   SVGA3DOP_CRS,
+   SVGA3DOP_SGN,
+   SVGA3DOP_ABS,
+   SVGA3DOP_NRM,
+   SVGA3DOP_SINCOS,
+   SVGA3DOP_REP,
+   SVGA3DOP_ENDREP,
+   SVGA3DOP_IF,
+   SVGA3DOP_IFC,
+   SVGA3DOP_ELSE,
+   SVGA3DOP_ENDIF,
+   SVGA3DOP_BREAK,
+   SVGA3DOP_BREAKC,
+   SVGA3DOP_MOVA,
+   SVGA3DOP_DEFB,
+   SVGA3DOP_DEFI,
+   SVGA3DOP_TEXCOORD = 64,
+   SVGA3DOP_TEXKILL,
+   SVGA3DOP_TEX,
+   SVGA3DOP_TEXBEM,
+   SVGA3DOP_TEXBEML,
+   SVGA3DOP_TEXREG2AR,
+   SVGA3DOP_TEXREG2GB = 70,
+   SVGA3DOP_TEXM3x2PAD,
+   SVGA3DOP_TEXM3x2TEX,
+   SVGA3DOP_TEXM3x3PAD,
+   SVGA3DOP_TEXM3x3TEX,
+   SVGA3DOP_RESERVED0,
+   SVGA3DOP_TEXM3x3SPEC,
+   SVGA3DOP_TEXM3x3VSPEC,
+   SVGA3DOP_EXPP,
+   SVGA3DOP_LOGP,
+   SVGA3DOP_CND = 80,
+   SVGA3DOP_DEF,
+   SVGA3DOP_TEXREG2RGB,
+   SVGA3DOP_TEXDP3TEX,
+   SVGA3DOP_TEXM3x2DEPTH,
+   SVGA3DOP_TEXDP3,
+   SVGA3DOP_TEXM3x3,
+   SVGA3DOP_TEXDEPTH,
+   SVGA3DOP_CMP,
+   SVGA3DOP_BEM,
+   SVGA3DOP_DP2ADD = 90,
+   SVGA3DOP_DSX,
+   SVGA3DOP_DSY,
+   SVGA3DOP_TEXLDD,
+   SVGA3DOP_SETP,
+   SVGA3DOP_TEXLDL,
+   SVGA3DOP_BREAKP = 96,
+   SVGA3DOP_LAST_INST,
+   SVGA3DOP_PHASE = 0xFFFD,
+   SVGA3DOP_COMMENT = 0xFFFE,
+   SVGA3DOP_END = 0xFFFF,
+} SVGA3dShaderOpCodeType;
+
+/* SVGA3D operation control/comparison function types */
+
+typedef enum {
+   SVGA3DOPCONT_NONE,
+   SVGA3DOPCONT_PROJECT,   /* Projective texturing */
+   SVGA3DOPCONT_BIAS,      /* Texturing with a LOD bias */
+} SVGA3dShaderOpCodeControlFnType;
+
+typedef enum {
+   SVGA3DOPCOMP_RESERVED0 = 0,
+   SVGA3DOPCOMP_GT,
+   SVGA3DOPCOMP_EQ,
+   SVGA3DOPCOMP_GE,
+   SVGA3DOPCOMP_LT,
+   SVGA3DOPCOMPC_NE,
+   SVGA3DOPCOMP_LE,
+   SVGA3DOPCOMP_RESERVED1
+} SVGA3dShaderOpCodeCompFnType;
+
+/* SVGA3D register types */
+
+typedef enum {
+    SVGA3DREG_TEMP = 0,       /* Temporary register file */
+    SVGA3DREG_INPUT,          /* Input register file */
+    SVGA3DREG_CONST,          /* Constant register file */
+    SVGA3DREG_ADDR,           /* Address register for VS */
+    SVGA3DREG_TEXTURE = 3,    /* Texture register file for PS */
+    SVGA3DREG_RASTOUT,        /* Rasterizer register file */
+    SVGA3DREG_ATTROUT,        /* Attribute output register file */
+    SVGA3DREG_TEXCRDOUT,      /* Texture coordinate output register file */
+    SVGA3DREG_OUTPUT = 6,     /* Output register file for VS 3.0+ */
+    SVGA3DREG_CONSTINT,       /* Constant integer vector register file */
+    SVGA3DREG_COLOROUT,       /* Color output register file */
+    SVGA3DREG_DEPTHOUT,       /* Depth output register file */
+    SVGA3DREG_SAMPLER,        /* Sampler state register file */
+    SVGA3DREG_CONST2,         /* Constant register file 2048 - 4095 */
+    SVGA3DREG_CONST3,         /* Constant register file 4096 - 6143 */
+    SVGA3DREG_CONST4,         /* Constant register file 6144 - 8191 */
+    SVGA3DREG_CONSTBOOL,      /* Constant boolean register file */
+    SVGA3DREG_LOOP,           /* Loop counter register file */
+    SVGA3DREG_TEMPFLOAT16,    /* 16-bit float temp register file */
+    SVGA3DREG_MISCTYPE,       /* Miscellaneous (single) registers */
+    SVGA3DREG_LABEL,          /* Label */
+    SVGA3DREG_PREDICATE,      /* Predicate register */
+} SVGA3dShaderRegType;
+
+/* SVGA3D rasterizer output register types */
+
+typedef enum {
+   SVGA3DRASTOUT_POSITION = 0,
+   SVGA3DRASTOUT_FOG,
+   SVGA3DRASTOUT_PSIZE
+} SVGA3dShaderRastOutRegType;
+
+/* SVGA3D miscellaneous register types */
+
+typedef enum {
+   SVGA3DMISCREG_POSITION = 0,   /* Input position x,y,z,rhw (PS) */
+   SVGA3DMISCREG_FACE            /* Floating point primitive area (PS) */
+} SVGA3DShaderMiscRegType;
+
+/* SVGA3D sampler types */
+
+typedef enum {
+   SVGA3DSAMP_UNKNOWN = 0, /* Uninitialized value */
+   SVGA3DSAMP_2D = 2,      /* dcl_2d s# (for declaring a 2-D texture) */
+   SVGA3DSAMP_CUBE,        /* dcl_cube s# (for declaring a cube texture) */
+   SVGA3DSAMP_VOLUME,      /* dcl_volume s# (for declaring a volume texture) */
+} SVGA3dShaderSamplerType;
+
+/* SVGA3D sampler format classes */
+
+typedef enum {
+   SVGA3DSAMPFORMAT_ARGB,        /* ARGB formats */
+   SVGA3DSAMPFORMAT_V8U8,        /* Sign and normalize (SNORM) V & U */
+   SVGA3DSAMPFORMAT_Q8W8V8U8,    /* SNORM all */
+   SVGA3DSAMPFORMAT_CxV8U8,      /* SNORM V & U, C=SQRT(1-U^2-V^2) */
+   SVGA3DSAMPFORMAT_X8L8V8U8,    /* SNORM V & U */
+   SVGA3DSAMPFORMAT_A2W10V10U10, /* SNORM W, V & U */
+   SVGA3DSAMPFORMAT_DXT_PMA,     /* DXT pre-multiplied alpha */
+   SVGA3DSAMPFORMAT_YUV,         /* YUV video format */
+   SVGA3DSAMPFORMAT_UYVY,        /* UYVY video format */
+   SVGA3DSAMPFORMAT_Rx,          /* R16F/32F */
+   SVGA3DSAMPFORMAT_RxGx,        /* R16FG16F, R32FG32F */
+   SVGA3DSAMPFORMAT_V16U16,      /* SNORM all */
+} SVGA3DShaderSamplerFormatClass;
+
+/* SVGA3D write mask */
+
+#define SVGA3DWRITEMASK_0    1 /* Component 0 (X;Red) */
+#define SVGA3DWRITEMASK_1    2 /* Component 1 (Y;Green) */
+#define SVGA3DWRITEMASK_2    4 /* Component 2 (Z;Blue) */
+#define SVGA3DWRITEMASK_3    8 /* Component 3 (W;Alpha) */
+#define SVGA3DWRITEMASK_ALL 15 /* All components */
+
+/* SVGA3D destination modifiers */
+
+#define SVGA3DDSTMOD_NONE              0 /* nop */
+#define SVGA3DDSTMOD_SATURATE          1 /* clamp to [0, 1] */
+#define SVGA3DDSTMOD_PARTIALPRECISION  2 /* Partial precision hint */
+
+/*
+ * Relevant to multisampling only:
+ * When the pixel center is not covered, sample
+ * attribute or compute gradients/LOD
+ * using multisample "centroid" location.
+ * "Centroid" is some location within the covered
+ * region of the pixel.
+ */
+
+#define SVGA3DDSTMOD_MSAMPCENTROID     4
+
+/* SVGA3D source swizzle */
+
+#define SVGA3DSWIZZLE_REPLICATEX 0x00
+#define SVGA3DSWIZZLE_REPLICATEY 0x55
+#define SVGA3DSWIZZLE_REPLICATEZ 0xAA
+#define SVGA3DSWIZZLE_REPLICATEW 0xFF
+#define SVGA3DSWIZZLE_NONE       0xE4
+#define SVGA3DSWIZZLE_YZXW       0xC9
+#define SVGA3DSWIZZLE_ZXYW       0xD2
+#define SVGA3DSWIZZLE_WXYZ       0x1B
+
+/* SVGA3D source modifiers */
+
+typedef enum {
+    SVGA3DSRCMOD_NONE = 0, /* nop */
+    SVGA3DSRCMOD_NEG,      /* negate */
+    SVGA3DSRCMOD_BIAS,     /* bias */
+    SVGA3DSRCMOD_BIASNEG,  /* bias and negate */
+    SVGA3DSRCMOD_SIGN,     /* sign */
+    SVGA3DSRCMOD_SIGNNEG,  /* sign and negate */
+    SVGA3DSRCMOD_COMP,     /* complement */
+    SVGA3DSRCMOD_X2,       /* x2 */
+    SVGA3DSRCMOD_X2NEG,    /* x2 and negate */
+    SVGA3DSRCMOD_DZ,       /* divide through by z component */
+    SVGA3DSRCMOD_DW,       /* divide through by w component */
+    SVGA3DSRCMOD_ABS,      /* abs() */
+    SVGA3DSRCMOD_ABSNEG,   /* -abs() */
+    SVGA3DSRCMOD_NOT,      /* ! (for predicate register) */
+} SVGA3dShaderSrcModType;
+
+/* SVGA3D instruction token */
+
+typedef struct {
+   union {
+      struct {
+         uint32 comment_op : 16;
+         uint32 comment_size : 16;
+      };
+
+      struct {
+         uint32 op : 16;
+         uint32 control : 3;
+         uint32 reserved2 : 5;
+         uint32 size : 4;
+         uint32 predicated : 1;
+         uint32 reserved1 : 1;
+         uint32 coissue : 1;
+         uint32 reserved0 : 1;
+      };
+
+      uint32 value;
+   };
+} SVGA3dShaderInstToken;
+
+/* SVGA3D destination parameter token */
+
+typedef struct {
+   union {
+      struct {
+         uint32 num : 11;
+         uint32 type_upper : 2;
+         uint32 relAddr : 1;
+         uint32 reserved1 : 2;
+         uint32 mask : 4;
+         uint32 dstMod : 4;
+         uint32 shfScale : 4;
+         uint32 type_lower : 3;
+         uint32 reserved0 : 1;
+      };
+
+      uint32 value;
+   };
+} SVGA3dShaderDestToken;
+
+/* SVGA3D source parameter token */
+
+typedef struct {
+   union {
+      struct {
+         uint32 num : 11;
+         uint32 type_upper : 2;
+         uint32 relAddr : 1;
+         uint32 reserved1 : 2;
+         uint32 swizzle : 8;
+         uint32 srcMod : 4;
+         uint32 type_lower : 3;
+         uint32 reserved0 : 1;
+      };
+
+      uint32 value;
+   };
+} SVGA3dShaderSrcToken;
+
+/* SVGA3DOP_DCL parameter tokens */
+
+typedef struct {
+   union {
+      struct {
+         union {
+            struct {
+               uint32 usage : 5;
+               uint32 reserved1 : 11;
+               uint32 index : 4;
+               uint32 reserved0 : 12;
+            }; /* input / output declaration */
+
+            struct {
+               uint32 reserved3 : 27;
+               uint32 type : 4;
+               uint32 reserved2 : 1;
+            }; /* sampler declaration */
+         };
+
+         SVGA3dShaderDestToken dst;
+      };
+
+      uint32 values[2];
+   };
+} SVGA3DOpDclArgs;
+
+/* SVGA3DOP_DEF parameter tokens */
+
+typedef struct {
+   union {
+      struct {
+         SVGA3dShaderDestToken dst;
+
+         union {
+            float constValues[4];
+            int constIValues[4];
+            Bool constBValue;
+         };
+      };
+
+      uint32 values[5];
+   };
+} SVGA3DOpDefArgs;
+
+/* SVGA3D shader token */
+
+typedef union {
+   uint32 value;
+   SVGA3dShaderInstToken inst;
+   SVGA3dShaderDestToken dest;
+   SVGA3dShaderSrcToken src;
+} SVGA3dShaderToken;
+
+/* SVGA3D shader program */
+
+typedef struct {
+   SVGA3dShaderVersion version;
+   /* SVGA3dShaderToken stream */
+} SVGA3dShaderProgram;
+
+/* SVGA3D version specific register assignments */
+
+static const uint32 SVGA3D_INPUT_REG_POSITION_VS11 = 0;
+static const uint32 SVGA3D_INPUT_REG_PSIZE_VS11 = 1;
+static const uint32 SVGA3D_INPUT_REG_FOG_VS11 = 3;
+static const uint32 SVGA3D_INPUT_REG_FOG_MASK_VS11 = SVGA3DWRITEMASK_3;
+static const uint32 SVGA3D_INPUT_REG_COLOR_BASE_VS11 = 2;
+static const uint32 SVGA3D_INPUT_REG_TEXCOORD_BASE_VS11 = 4;
+
+static const uint32 SVGA3D_INPUT_REG_COLOR_BASE_PS11 = 0;
+static const uint32 SVGA3D_INPUT_REG_TEXCOORD_BASE_PS11 = 2;
+static const uint32 SVGA3D_OUTPUT_REG_DEPTH_PS11 = 0;
+static const uint32 SVGA3D_OUTPUT_REG_COLOR_PS11 = 1;
+
+static const uint32 SVGA3D_INPUT_REG_COLOR_BASE_PS20 = 0;
+static const uint32 SVGA3D_INPUT_REG_COLOR_NUM_PS20 = 2;
+static const uint32 SVGA3D_INPUT_REG_TEXCOORD_BASE_PS20 = 2;
+static const uint32 SVGA3D_INPUT_REG_TEXCOORD_NUM_PS20 = 8;
+static const uint32 SVGA3D_OUTPUT_REG_COLOR_BASE_PS20 = 1;
+static const uint32 SVGA3D_OUTPUT_REG_COLOR_NUM_PS20 = 4;
+static const uint32 SVGA3D_OUTPUT_REG_DEPTH_BASE_PS20 = 0;
+static const uint32 SVGA3D_OUTPUT_REG_DEPTH_NUM_PS20 = 1;
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SVGA3dShaderGetRegType --
+ *
+ *      As the register type is split into two non sequential fields,
+ *      this function provides an useful way of accessing the actual
+ *      register type without having to manually concatenate the
+ *      type_upper and type_lower fields.
+ *
+ * Results:
+ *      Returns the register type.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static INLINE SVGA3dShaderRegType
+SVGA3dShaderGetRegType(uint32 token)
+{
+   SVGA3dShaderSrcToken src;
+   src.value = token;
+   return (SVGA3dShaderRegType)(src.type_upper << 3 | src.type_lower);
+}
+
+#endif /* __SVGA3D_SHADER_DEFS__ */
diff --git a/src/gallium/drivers/svga/include/svga_escape.h b/src/gallium/drivers/svga/include/svga_escape.h
new file mode 100644 (file)
index 0000000..7b85e9b
--- /dev/null
@@ -0,0 +1,89 @@
+/**********************************************************
+ * Copyright 2007-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+/*
+ * svga_escape.h --
+ *
+ *    Definitions for our own (vendor-specific) SVGA Escape commands.
+ */
+
+#ifndef _SVGA_ESCAPE_H_
+#define _SVGA_ESCAPE_H_
+
+
+/*
+ * Namespace IDs for the escape command
+ */
+
+#define SVGA_ESCAPE_NSID_VMWARE 0x00000000
+#define SVGA_ESCAPE_NSID_DEVEL  0xFFFFFFFF
+
+
+/*
+ * Within SVGA_ESCAPE_NSID_VMWARE, we multiplex commands according to
+ * the first DWORD of escape data (after the nsID and size). As a
+ * guideline we're using the high word and low word as a major and
+ * minor command number, respectively.
+ *
+ * Major command number allocation:
+ *
+ *   0000: Reserved
+ *   0001: SVGA_ESCAPE_VMWARE_LOG (svga_binary_logger.h)
+ *   0002: SVGA_ESCAPE_VMWARE_VIDEO (svga_overlay.h)
+ *   0003: SVGA_ESCAPE_VMWARE_HINT (svga_escape.h)
+ */
+
+#define SVGA_ESCAPE_VMWARE_MAJOR_MASK  0xFFFF0000
+
+
+/*
+ * SVGA Hint commands.
+ *
+ * These escapes let the SVGA driver provide optional information to
+ * he host about the state of the guest or guest applications. The
+ * host can use these hints to make user interface or performance
+ * decisions.
+ *
+ * Notes:
+ *
+ *   - SVGA_ESCAPE_VMWARE_HINT_FULLSCREEN is deprecated for guests
+ *     that use the SVGA Screen Object extension. Instead of sending
+ *     this escape, use the SVGA_SCREEN_FULLSCREEN_HINT flag on your
+ *     Screen Object.
+ */
+
+#define SVGA_ESCAPE_VMWARE_HINT               0x00030000
+#define SVGA_ESCAPE_VMWARE_HINT_FULLSCREEN    0x00030001  // Deprecated
+
+typedef
+struct {
+   uint32 command;
+   uint32 fullscreen;
+   struct {
+      int32 x, y;
+   } monitorPosition;
+} SVGAEscapeHintFullscreen;
+
+#endif /* _SVGA_ESCAPE_H_ */
diff --git a/src/gallium/drivers/svga/include/svga_overlay.h b/src/gallium/drivers/svga/include/svga_overlay.h
new file mode 100644 (file)
index 0000000..82c1d3f
--- /dev/null
@@ -0,0 +1,201 @@
+/**********************************************************
+ * Copyright 2007-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+/*
+ * svga_overlay.h --
+ *
+ *    Definitions for video-overlay support.
+ */
+
+#ifndef _SVGA_OVERLAY_H_
+#define _SVGA_OVERLAY_H_
+
+#include "svga_reg.h"
+
+/*
+ * Video formats we support
+ */
+
+#define VMWARE_FOURCC_YV12 0x32315659 // 'Y' 'V' '1' '2'
+#define VMWARE_FOURCC_YUY2 0x32595559 // 'Y' 'U' 'Y' '2'
+#define VMWARE_FOURCC_UYVY 0x59565955 // 'U' 'Y' 'V' 'Y'
+
+typedef enum {
+   SVGA_OVERLAY_FORMAT_INVALID = 0,
+   SVGA_OVERLAY_FORMAT_YV12 = VMWARE_FOURCC_YV12,
+   SVGA_OVERLAY_FORMAT_YUY2 = VMWARE_FOURCC_YUY2,
+   SVGA_OVERLAY_FORMAT_UYVY = VMWARE_FOURCC_UYVY,
+} SVGAOverlayFormat;
+
+#define SVGA_VIDEO_COLORKEY_MASK             0x00ffffff
+
+#define SVGA_ESCAPE_VMWARE_VIDEO             0x00020000
+
+#define SVGA_ESCAPE_VMWARE_VIDEO_SET_REGS    0x00020001
+        /* FIFO escape layout:
+         * Type, Stream Id, (Register Id, Value) pairs */
+
+#define SVGA_ESCAPE_VMWARE_VIDEO_FLUSH       0x00020002
+        /* FIFO escape layout:
+         * Type, Stream Id */
+
+typedef
+struct SVGAEscapeVideoSetRegs {
+   struct {
+      uint32 cmdType;
+      uint32 streamId;
+   } header;
+
+   // May include zero or more items.
+   struct {
+      uint32 registerId;
+      uint32 value;
+   } items[1];
+} SVGAEscapeVideoSetRegs;
+
+typedef
+struct SVGAEscapeVideoFlush {
+   uint32 cmdType;
+   uint32 streamId;
+} SVGAEscapeVideoFlush;
+
+
+/*
+ * Struct definitions for the video overlay commands built on
+ * SVGAFifoCmdEscape.
+ */
+typedef
+struct {
+   uint32 command;
+   uint32 overlay;
+} SVGAFifoEscapeCmdVideoBase;
+
+typedef
+struct {
+   SVGAFifoEscapeCmdVideoBase videoCmd;
+} SVGAFifoEscapeCmdVideoFlush;
+
+typedef
+struct {
+   SVGAFifoEscapeCmdVideoBase videoCmd;
+   struct {
+      uint32 regId;
+      uint32 value;
+   } items[1];
+} SVGAFifoEscapeCmdVideoSetRegs;
+
+typedef
+struct {
+   SVGAFifoEscapeCmdVideoBase videoCmd;
+   struct {
+      uint32 regId;
+      uint32 value;
+   } items[SVGA_VIDEO_NUM_REGS];
+} SVGAFifoEscapeCmdVideoSetAllRegs;
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * VMwareVideoGetAttributes --
+ *
+ *      Computes the size, pitches and offsets for YUV frames.
+ *
+ * Results:
+ *      TRUE on success; otherwise FALSE on failure.
+ *
+ * Side effects:
+ *      Pitches and offsets for the given YUV frame are put in 'pitches'
+ *      and 'offsets' respectively. They are both optional though.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static INLINE Bool
+VMwareVideoGetAttributes(const SVGAOverlayFormat format,    // IN
+                         uint32 *width,                     // IN / OUT
+                         uint32 *height,                    // IN / OUT
+                         uint32 *size,                      // OUT
+                         uint32 *pitches,                   // OUT (optional)
+                         uint32 *offsets)                   // OUT (optional)
+{
+    int tmp;
+
+    *width = (*width + 1) & ~1;
+
+    if (offsets) {
+        offsets[0] = 0;
+    }
+
+    switch (format) {
+    case VMWARE_FOURCC_YV12:
+       *height = (*height + 1) & ~1;
+       *size = (*width + 3) & ~3;
+
+       if (pitches) {
+          pitches[0] = *size;
+       }
+
+       *size *= *height;
+
+       if (offsets) {
+          offsets[1] = *size;
+       }
+
+       tmp = ((*width >> 1) + 3) & ~3;
+
+       if (pitches) {
+          pitches[1] = pitches[2] = tmp;
+       }
+
+       tmp *= (*height >> 1);
+       *size += tmp;
+
+       if (offsets) {
+          offsets[2] = *size;
+       }
+
+       *size += tmp;
+       break;
+
+    case VMWARE_FOURCC_YUY2:
+    case VMWARE_FOURCC_UYVY:
+       *size = *width * 2;
+
+       if (pitches) {
+          pitches[0] = *size;
+       }
+
+       *size *= *height;
+       break;
+
+    default:
+       return FALSE;
+    }
+
+    return TRUE;
+}
+
+#endif // _SVGA_OVERLAY_H_
diff --git a/src/gallium/drivers/svga/include/svga_reg.h b/src/gallium/drivers/svga/include/svga_reg.h
new file mode 100644 (file)
index 0000000..1b96c2e
--- /dev/null
@@ -0,0 +1,1346 @@
+/**********************************************************
+ * Copyright 1998-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+/*
+ * svga_reg.h --
+ *
+ *    Virtual hardware definitions for the VMware SVGA II device.
+ */
+
+#ifndef _SVGA_REG_H_
+#define _SVGA_REG_H_
+
+/*
+ * PCI device IDs.
+ */
+#define PCI_VENDOR_ID_VMWARE            0x15AD
+#define PCI_DEVICE_ID_VMWARE_SVGA2      0x0405
+
+/*
+ * Legal values for the SVGA_REG_CURSOR_ON register in old-fashioned
+ * cursor bypass mode. This is still supported, but no new guest
+ * drivers should use it.
+ */
+#define SVGA_CURSOR_ON_HIDE            0x0   /* Must be 0 to maintain backward compatibility */
+#define SVGA_CURSOR_ON_SHOW            0x1   /* Must be 1 to maintain backward compatibility */
+#define SVGA_CURSOR_ON_REMOVE_FROM_FB  0x2   /* Remove the cursor from the framebuffer because we need to see what's under it */
+#define SVGA_CURSOR_ON_RESTORE_TO_FB   0x3   /* Put the cursor back in the framebuffer so the user can see it */
+
+/*
+ * The maximum framebuffer size that can traced for e.g. guests in VESA mode.
+ * The changeMap in the monitor is proportional to this number. Therefore, we'd
+ * like to keep it as small as possible to reduce monitor overhead (using
+ * SVGA_VRAM_MAX_SIZE for this increases the size of the shared area by over
+ * 4k!).
+ *
+ * NB: For compatibility reasons, this value must be greater than 0xff0000.
+ *     See bug 335072.
+ */
+#define SVGA_FB_MAX_TRACEABLE_SIZE      0x1000000
+
+#define SVGA_MAX_PSEUDOCOLOR_DEPTH      8
+#define SVGA_MAX_PSEUDOCOLORS           (1 << SVGA_MAX_PSEUDOCOLOR_DEPTH)
+#define SVGA_NUM_PALETTE_REGS           (3 * SVGA_MAX_PSEUDOCOLORS)
+
+#define SVGA_MAGIC         0x900000UL
+#define SVGA_MAKE_ID(ver)  (SVGA_MAGIC << 8 | (ver))
+
+/* Version 2 let the address of the frame buffer be unsigned on Win32 */
+#define SVGA_VERSION_2     2
+#define SVGA_ID_2          SVGA_MAKE_ID(SVGA_VERSION_2)
+
+/* Version 1 has new registers starting with SVGA_REG_CAPABILITIES so
+   PALETTE_BASE has moved */
+#define SVGA_VERSION_1     1
+#define SVGA_ID_1          SVGA_MAKE_ID(SVGA_VERSION_1)
+
+/* Version 0 is the initial version */
+#define SVGA_VERSION_0     0
+#define SVGA_ID_0          SVGA_MAKE_ID(SVGA_VERSION_0)
+
+/* "Invalid" value for all SVGA IDs. (Version ID, screen object ID, surface ID...) */
+#define SVGA_ID_INVALID    0xFFFFFFFF
+
+/* Port offsets, relative to BAR0 */
+#define SVGA_INDEX_PORT         0x0
+#define SVGA_VALUE_PORT         0x1
+#define SVGA_BIOS_PORT          0x2
+#define SVGA_IRQSTATUS_PORT     0x8
+
+/*
+ * Interrupt source flags for IRQSTATUS_PORT and IRQMASK.
+ *
+ * Interrupts are only supported when the
+ * SVGA_CAP_IRQMASK capability is present.
+ */
+#define SVGA_IRQFLAG_ANY_FENCE            0x1    /* Any fence was passed */
+#define SVGA_IRQFLAG_FIFO_PROGRESS        0x2    /* Made forward progress in the FIFO */
+#define SVGA_IRQFLAG_FENCE_GOAL           0x4    /* SVGA_FIFO_FENCE_GOAL reached */
+
+/*
+ * Registers
+ */
+
+enum {
+   SVGA_REG_ID = 0,
+   SVGA_REG_ENABLE = 1,
+   SVGA_REG_WIDTH = 2,
+   SVGA_REG_HEIGHT = 3,
+   SVGA_REG_MAX_WIDTH = 4,
+   SVGA_REG_MAX_HEIGHT = 5,
+   SVGA_REG_DEPTH = 6,
+   SVGA_REG_BITS_PER_PIXEL = 7,       /* Current bpp in the guest */
+   SVGA_REG_PSEUDOCOLOR = 8,
+   SVGA_REG_RED_MASK = 9,
+   SVGA_REG_GREEN_MASK = 10,
+   SVGA_REG_BLUE_MASK = 11,
+   SVGA_REG_BYTES_PER_LINE = 12,
+   SVGA_REG_FB_START = 13,            /* (Deprecated) */
+   SVGA_REG_FB_OFFSET = 14,
+   SVGA_REG_VRAM_SIZE = 15,
+   SVGA_REG_FB_SIZE = 16,
+
+   /* ID 0 implementation only had the above registers, then the palette */
+
+   SVGA_REG_CAPABILITIES = 17,
+   SVGA_REG_MEM_START = 18,           /* (Deprecated) */
+   SVGA_REG_MEM_SIZE = 19,
+   SVGA_REG_CONFIG_DONE = 20,         /* Set when memory area configured */
+   SVGA_REG_SYNC = 21,                /* See "FIFO Synchronization Registers" */
+   SVGA_REG_BUSY = 22,                /* See "FIFO Synchronization Registers" */
+   SVGA_REG_GUEST_ID = 23,            /* Set guest OS identifier */
+   SVGA_REG_CURSOR_ID = 24,           /* (Deprecated) */
+   SVGA_REG_CURSOR_X = 25,            /* (Deprecated) */
+   SVGA_REG_CURSOR_Y = 26,            /* (Deprecated) */
+   SVGA_REG_CURSOR_ON = 27,           /* (Deprecated) */
+   SVGA_REG_HOST_BITS_PER_PIXEL = 28, /* (Deprecated) */
+   SVGA_REG_SCRATCH_SIZE = 29,        /* Number of scratch registers */
+   SVGA_REG_MEM_REGS = 30,            /* Number of FIFO registers */
+   SVGA_REG_NUM_DISPLAYS = 31,        /* (Deprecated) */
+   SVGA_REG_PITCHLOCK = 32,           /* Fixed pitch for all modes */
+   SVGA_REG_IRQMASK = 33,             /* Interrupt mask */
+
+   /* Legacy multi-monitor support */
+   SVGA_REG_NUM_GUEST_DISPLAYS = 34,/* Number of guest displays in X/Y direction */
+   SVGA_REG_DISPLAY_ID = 35,        /* Display ID for the following display attributes */
+   SVGA_REG_DISPLAY_IS_PRIMARY = 36,/* Whether this is a primary display */
+   SVGA_REG_DISPLAY_POSITION_X = 37,/* The display position x */
+   SVGA_REG_DISPLAY_POSITION_Y = 38,/* The display position y */
+   SVGA_REG_DISPLAY_WIDTH = 39,     /* The display's width */
+   SVGA_REG_DISPLAY_HEIGHT = 40,    /* The display's height */
+
+   /* See "Guest memory regions" below. */
+   SVGA_REG_GMR_ID = 41,
+   SVGA_REG_GMR_DESCRIPTOR = 42,
+   SVGA_REG_GMR_MAX_IDS = 43,
+   SVGA_REG_GMR_MAX_DESCRIPTOR_LENGTH = 44,
+
+   SVGA_REG_TRACES = 45,            /* Enable trace-based updates even when FIFO is on */
+   SVGA_REG_TOP = 46,               /* Must be 1 more than the last register */
+
+   SVGA_PALETTE_BASE = 1024,        /* Base of SVGA color map */
+   /* Next 768 (== 256*3) registers exist for colormap */
+
+   SVGA_SCRATCH_BASE = SVGA_PALETTE_BASE + SVGA_NUM_PALETTE_REGS
+                                    /* Base of scratch registers */
+   /* Next reg[SVGA_REG_SCRATCH_SIZE] registers exist for scratch usage:
+      First 4 are reserved for VESA BIOS Extension; any remaining are for
+      the use of the current SVGA driver. */
+};
+
+
+/*
+ * Guest memory regions (GMRs):
+ *
+ * This is a new memory mapping feature available in SVGA devices
+ * which have the SVGA_CAP_GMR bit set. Previously, there were two
+ * fixed memory regions available with which to share data between the
+ * device and the driver: the FIFO ('MEM') and the framebuffer. GMRs
+ * are our name for an extensible way of providing arbitrary DMA
+ * buffers for use between the driver and the SVGA device. They are a
+ * new alternative to framebuffer memory, usable for both 2D and 3D
+ * graphics operations.
+ *
+ * Since GMR mapping must be done synchronously with guest CPU
+ * execution, we use a new pair of SVGA registers:
+ *
+ *   SVGA_REG_GMR_ID --
+ *
+ *     Read/write.
+ *     This register holds the 32-bit ID (a small positive integer)
+ *     of a GMR to create, delete, or redefine. Writing this register
+ *     has no side-effects.
+ *
+ *   SVGA_REG_GMR_DESCRIPTOR --
+ *
+ *     Write-only.
+ *     Writing this register will create, delete, or redefine the GMR
+ *     specified by the above ID register. If this register is zero,
+ *     the GMR is deleted. Any pointers into this GMR (including those
+ *     currently being processed by FIFO commands) will be
+ *     synchronously invalidated.
+ *
+ *     If this register is nonzero, it must be the physical page
+ *     number (PPN) of a data structure which describes the physical
+ *     layout of the memory region this GMR should describe. The
+ *     descriptor structure will be read synchronously by the SVGA
+ *     device when this register is written. The descriptor need not
+ *     remain allocated for the lifetime of the GMR.
+ *
+ *     The guest driver should write SVGA_REG_GMR_ID first, then
+ *     SVGA_REG_GMR_DESCRIPTOR.
+ *
+ *   SVGA_REG_GMR_MAX_IDS --
+ *
+ *     Read-only.
+ *     The SVGA device may choose to support a maximum number of
+ *     user-defined GMR IDs. This register holds the number of supported
+ *     IDs. (The maximum supported ID plus 1)
+ *
+ *   SVGA_REG_GMR_MAX_DESCRIPTOR_LENGTH --
+ *
+ *     Read-only.
+ *     The SVGA device may choose to put a limit on the total number
+ *     of SVGAGuestMemDescriptor structures it will read when defining
+ *     a single GMR.
+ *
+ * The descriptor structure is an array of SVGAGuestMemDescriptor
+ * structures. Each structure may do one of three things:
+ *
+ *   - Terminate the GMR descriptor list.
+ *     (ppn==0, numPages==0)
+ *
+ *   - Add a PPN or range of PPNs to the GMR's virtual address space.
+ *     (ppn != 0, numPages != 0)
+ *
+ *   - Provide the PPN of the next SVGAGuestMemDescriptor, in order to
+ *     support multi-page GMR descriptor tables without forcing the
+ *     driver to allocate physically contiguous memory.
+ *     (ppn != 0, numPages == 0)
+ *
+ * Note that each physical page of SVGAGuestMemDescriptor structures
+ * can describe at least 2MB of guest memory. If the driver needs to
+ * use more than one page of descriptor structures, it must use one of
+ * its SVGAGuestMemDescriptors to point to an additional page.  The
+ * device will never automatically cross a page boundary.
+ *
+ * Once the driver has described a GMR, it is immediately available
+ * for use via any FIFO command that uses an SVGAGuestPtr structure.
+ * These pointers include a GMR identifier plus an offset into that
+ * GMR.
+ *
+ * The driver must check the SVGA_CAP_GMR bit before using the GMR
+ * registers.
+ */
+
+/*
+ * Special GMR IDs, allowing SVGAGuestPtrs to point to framebuffer
+ * memory as well.  In the future, these IDs could even be used to
+ * allow legacy memory regions to be redefined by the guest as GMRs.
+ *
+ * Using the guest framebuffer (GFB) at BAR1 for general purpose DMA
+ * is being phased out. Please try to use user-defined GMRs whenever
+ * possible.
+ */
+#define SVGA_GMR_NULL         ((uint32) -1)
+#define SVGA_GMR_FRAMEBUFFER  ((uint32) -2)  // Guest Framebuffer (GFB)
+
+typedef
+struct SVGAGuestMemDescriptor {
+   uint32 ppn;
+   uint32 numPages;
+} SVGAGuestMemDescriptor;
+
+typedef
+struct SVGAGuestPtr {
+   uint32 gmrId;
+   uint32 offset;
+} SVGAGuestPtr;
+
+
+/*
+ * SVGAGMRImageFormat --
+ *
+ *    This is a packed representation of the source 2D image format
+ *    for a GMR-to-screen blit. Currently it is defined as an encoding
+ *    of the screen's color depth and bits-per-pixel, however, 16 bits
+ *    are reserved for future use to identify other encodings (such as
+ *    RGBA or higher-precision images).
+ *
+ *    Currently supported formats:
+ *
+ *       bpp depth  Format Name
+ *       --- -----  -----------
+ *        32    24  32-bit BGRX
+ *        24    24  24-bit BGR
+ *        16    16  RGB 5-6-5
+ *        16    15  RGB 5-5-5
+ *
+ */
+
+typedef
+struct SVGAGMRImageFormat {
+   union {
+      struct {
+         uint32 bitsPerPixel : 8;
+         uint32 colorDepth   : 8;
+         uint32 reserved     : 16;  // Must be zero
+      };
+
+      uint32 value;
+   };
+} SVGAGMRImageFormat;
+
+/*
+ * SVGAColorBGRX --
+ *
+ *    A 24-bit color format (BGRX), which does not depend on the
+ *    format of the legacy guest framebuffer (GFB) or the current
+ *    GMRFB state.
+ */
+
+typedef
+struct SVGAColorBGRX {
+   union {
+      struct {
+         uint32 b : 8;
+         uint32 g : 8;
+         uint32 r : 8;
+         uint32 x : 8;  // Unused
+      };
+
+      uint32 value;
+   };
+} SVGAColorBGRX;
+
+
+/*
+ * SVGASignedRect --
+ * SVGASignedPoint --
+ *
+ *    Signed rectangle and point primitives. These are used by the new
+ *    2D primitives for drawing to Screen Objects, which can occupy a
+ *    signed virtual coordinate space.
+ *
+ *    SVGASignedRect specifies a half-open interval: the (left, top)
+ *    pixel is part of the rectangle, but the (right, bottom) pixel is
+ *    not.
+ */
+
+typedef
+struct SVGASignedRect {
+   int32  left;
+   int32  top;
+   int32  right;
+   int32  bottom;
+} SVGASignedRect;
+
+typedef
+struct SVGASignedPoint {
+   int32  x;
+   int32  y;
+} SVGASignedPoint;
+
+
+/*
+ *  Capabilities
+ *
+ *  Note the holes in the bitfield. Missing bits have been deprecated,
+ *  and must not be reused. Those capabilities will never be reported
+ *  by new versions of the SVGA device.
+ */
+
+#define SVGA_CAP_NONE               0x00000000
+#define SVGA_CAP_RECT_COPY          0x00000002
+#define SVGA_CAP_CURSOR             0x00000020
+#define SVGA_CAP_CURSOR_BYPASS      0x00000040   // Legacy (Use Cursor Bypass 3 instead)
+#define SVGA_CAP_CURSOR_BYPASS_2    0x00000080   // Legacy (Use Cursor Bypass 3 instead)
+#define SVGA_CAP_8BIT_EMULATION     0x00000100
+#define SVGA_CAP_ALPHA_CURSOR       0x00000200
+#define SVGA_CAP_3D                 0x00004000
+#define SVGA_CAP_EXTENDED_FIFO      0x00008000
+#define SVGA_CAP_MULTIMON           0x00010000   // Legacy multi-monitor support
+#define SVGA_CAP_PITCHLOCK          0x00020000
+#define SVGA_CAP_IRQMASK            0x00040000
+#define SVGA_CAP_DISPLAY_TOPOLOGY   0x00080000   // Legacy multi-monitor support
+#define SVGA_CAP_GMR                0x00100000
+#define SVGA_CAP_TRACES             0x00200000
+
+
+/*
+ * FIFO register indices.
+ *
+ * The FIFO is a chunk of device memory mapped into guest physmem.  It
+ * is always treated as 32-bit words.
+ *
+ * The guest driver gets to decide how to partition it between
+ * - FIFO registers (there are always at least 4, specifying where the
+ *   following data area is and how much data it contains; there may be
+ *   more registers following these, depending on the FIFO protocol
+ *   version in use)
+ * - FIFO data, written by the guest and slurped out by the VMX.
+ * These indices are 32-bit word offsets into the FIFO.
+ */
+
+enum {
+   /*
+    * Block 1 (basic registers): The originally defined FIFO registers.
+    * These exist and are valid for all versions of the FIFO protocol.
+    */
+
+   SVGA_FIFO_MIN = 0,
+   SVGA_FIFO_MAX,       /* The distance from MIN to MAX must be at least 10K */
+   SVGA_FIFO_NEXT_CMD,
+   SVGA_FIFO_STOP,
+
+   /*
+    * Block 2 (extended registers): Mandatory registers for the extended
+    * FIFO.  These exist if the SVGA caps register includes
+    * SVGA_CAP_EXTENDED_FIFO; some of them are valid only if their
+    * associated capability bit is enabled.
+    *
+    * Note that when originally defined, SVGA_CAP_EXTENDED_FIFO implied
+    * support only for (FIFO registers) CAPABILITIES, FLAGS, and FENCE.
+    * This means that the guest has to test individually (in most cases
+    * using FIFO caps) for the presence of registers after this; the VMX
+    * can define "extended FIFO" to mean whatever it wants, and currently
+    * won't enable it unless there's room for that set and much more.
+    */
+
+   SVGA_FIFO_CAPABILITIES = 4,
+   SVGA_FIFO_FLAGS,
+   // Valid with SVGA_FIFO_CAP_FENCE:
+   SVGA_FIFO_FENCE,
+
+   /*
+    * Block 3a (optional extended registers): Additional registers for the
+    * extended FIFO, whose presence isn't actually implied by
+    * SVGA_CAP_EXTENDED_FIFO; these exist if SVGA_FIFO_MIN is high enough to
+    * leave room for them.
+    *
+    * These in block 3a, the VMX currently considers mandatory for the
+    * extended FIFO.
+    */
+
+   // Valid if exists (i.e. if extended FIFO enabled):
+   SVGA_FIFO_3D_HWVERSION,       /* See SVGA3dHardwareVersion in svga3d_reg.h */
+   // Valid with SVGA_FIFO_CAP_PITCHLOCK:
+   SVGA_FIFO_PITCHLOCK,
+
+   // Valid with SVGA_FIFO_CAP_CURSOR_BYPASS_3:
+   SVGA_FIFO_CURSOR_ON,          /* Cursor bypass 3 show/hide register */
+   SVGA_FIFO_CURSOR_X,           /* Cursor bypass 3 x register */
+   SVGA_FIFO_CURSOR_Y,           /* Cursor bypass 3 y register */
+   SVGA_FIFO_CURSOR_COUNT,       /* Incremented when any of the other 3 change */
+   SVGA_FIFO_CURSOR_LAST_UPDATED,/* Last time the host updated the cursor */
+
+   // Valid with SVGA_FIFO_CAP_RESERVE:
+   SVGA_FIFO_RESERVED,           /* Bytes past NEXT_CMD with real contents */
+
+   /*
+    * Valid with SVGA_FIFO_CAP_SCREEN_OBJECT:
+    *
+    * By default this is SVGA_ID_INVALID, to indicate that the cursor
+    * coordinates are specified relative to the virtual root. If this
+    * is set to a specific screen ID, cursor position is reinterpreted
+    * as a signed offset relative to that screen's origin. This is the
+    * only way to place the cursor on a non-rooted screen.
+    */
+   SVGA_FIFO_CURSOR_SCREEN_ID,
+
+   /*
+    * XXX: The gap here, up until SVGA_FIFO_3D_CAPS, can be used for new
+    * registers, but this must be done carefully and with judicious use of
+    * capability bits, since comparisons based on SVGA_FIFO_MIN aren't
+    * enough to tell you whether the register exists: we've shipped drivers
+    * and products that used SVGA_FIFO_3D_CAPS but didn't know about some of
+    * the earlier ones.  The actual order of introduction was:
+    * - PITCHLOCK
+    * - 3D_CAPS
+    * - CURSOR_* (cursor bypass 3)
+    * - RESERVED
+    * So, code that wants to know whether it can use any of the
+    * aforementioned registers, or anything else added after PITCHLOCK and
+    * before 3D_CAPS, needs to reason about something other than
+    * SVGA_FIFO_MIN.
+    */
+
+   /*
+    * 3D caps block space; valid with 3D hardware version >=
+    * SVGA3D_HWVERSION_WS6_B1.
+    */
+   SVGA_FIFO_3D_CAPS      = 32,
+   SVGA_FIFO_3D_CAPS_LAST = 32 + 255,
+
+   /*
+    * End of VMX's current definition of "extended-FIFO registers".
+    * Registers before here are always enabled/disabled as a block; either
+    * the extended FIFO is enabled and includes all preceding registers, or
+    * it's disabled entirely.
+    *
+    * Block 3b (truly optional extended registers): Additional registers for
+    * the extended FIFO, which the VMX already knows how to enable and
+    * disable with correct granularity.
+    *
+    * Registers after here exist if and only if the guest SVGA driver
+    * sets SVGA_FIFO_MIN high enough to leave room for them.
+    */
+
+   // Valid if register exists:
+   SVGA_FIFO_GUEST_3D_HWVERSION, /* Guest driver's 3D version */
+   SVGA_FIFO_FENCE_GOAL,         /* Matching target for SVGA_IRQFLAG_FENCE_GOAL */
+   SVGA_FIFO_BUSY,               /* See "FIFO Synchronization Registers" */
+
+   /*
+    * Always keep this last.  This defines the maximum number of
+    * registers we know about.  At power-on, this value is placed in
+    * the SVGA_REG_MEM_REGS register, and we expect the guest driver
+    * to allocate this much space in FIFO memory for registers.
+    */
+    SVGA_FIFO_NUM_REGS
+};
+
+
+/*
+ * Definition of registers included in extended FIFO support.
+ *
+ * The guest SVGA driver gets to allocate the FIFO between registers
+ * and data.  It must always allocate at least 4 registers, but old
+ * drivers stopped there.
+ *
+ * The VMX will enable extended FIFO support if and only if the guest
+ * left enough room for all registers defined as part of the mandatory
+ * set for the extended FIFO.
+ *
+ * Note that the guest drivers typically allocate the FIFO only at
+ * initialization time, not at mode switches, so it's likely that the
+ * number of FIFO registers won't change without a reboot.
+ *
+ * All registers less than this value are guaranteed to be present if
+ * svgaUser->fifo.extended is set. Any later registers must be tested
+ * individually for compatibility at each use (in the VMX).
+ *
+ * This value is used only by the VMX, so it can change without
+ * affecting driver compatibility; keep it that way?
+ */
+#define SVGA_FIFO_EXTENDED_MANDATORY_REGS  (SVGA_FIFO_3D_CAPS_LAST + 1)
+
+
+/*
+ * FIFO Synchronization Registers
+ *
+ *  This explains the relationship between the various FIFO
+ *  sync-related registers in IOSpace and in FIFO space.
+ *
+ *  SVGA_REG_SYNC --
+ *
+ *       The SYNC register can be used in two different ways by the guest:
+ *
+ *         1. If the guest wishes to fully sync (drain) the FIFO,
+ *            it will write once to SYNC then poll on the BUSY
+ *            register. The FIFO is sync'ed once BUSY is zero.
+ *
+ *         2. If the guest wants to asynchronously wake up the host,
+ *            it will write once to SYNC without polling on BUSY.
+ *            Ideally it will do this after some new commands have
+ *            been placed in the FIFO, and after reading a zero
+ *            from SVGA_FIFO_BUSY.
+ *
+ *       (1) is the original behaviour that SYNC was designed to
+ *       support.  Originally, a write to SYNC would implicitly
+ *       trigger a read from BUSY. This causes us to synchronously
+ *       process the FIFO.
+ *
+ *       This behaviour has since been changed so that writing SYNC
+ *       will *not* implicitly cause a read from BUSY. Instead, it
+ *       makes a channel call which asynchronously wakes up the MKS
+ *       thread.
+ *
+ *       New guests can use this new behaviour to implement (2)
+ *       efficiently. This lets guests get the host's attention
+ *       without waiting for the MKS to poll, which gives us much
+ *       better CPU utilization on SMP hosts and on UP hosts while
+ *       we're blocked on the host GPU.
+ *
+ *       Old guests shouldn't notice the behaviour change. SYNC was
+ *       never guaranteed to process the entire FIFO, since it was
+ *       bounded to a particular number of CPU cycles. Old guests will
+ *       still loop on the BUSY register until the FIFO is empty.
+ *
+ *       Writing to SYNC currently has the following side-effects:
+ *
+ *         - Sets SVGA_REG_BUSY to TRUE (in the monitor)
+ *         - Asynchronously wakes up the MKS thread for FIFO processing
+ *         - The value written to SYNC is recorded as a "reason", for
+ *           stats purposes.
+ *
+ *       If SVGA_FIFO_BUSY is available, drivers are advised to only
+ *       write to SYNC if SVGA_FIFO_BUSY is FALSE. Drivers should set
+ *       SVGA_FIFO_BUSY to TRUE after writing to SYNC. The MKS will
+ *       eventually set SVGA_FIFO_BUSY on its own, but this approach
+ *       lets the driver avoid sending multiple asynchronous wakeup
+ *       messages to the MKS thread.
+ *
+ *  SVGA_REG_BUSY --
+ *
+ *       This register is set to TRUE when SVGA_REG_SYNC is written,
+ *       and it reads as FALSE when the FIFO has been completely
+ *       drained.
+ *
+ *       Every read from this register causes us to synchronously
+ *       process FIFO commands. There is no guarantee as to how many
+ *       commands each read will process.
+ *
+ *       CPU time spent processing FIFO commands will be billed to
+ *       the guest.
+ *
+ *       New drivers should avoid using this register unless they
+ *       need to guarantee that the FIFO is completely drained. It
+ *       is overkill for performing a sync-to-fence. Older drivers
+ *       will use this register for any type of synchronization.
+ *
+ *  SVGA_FIFO_BUSY --
+ *
+ *       This register is a fast way for the guest driver to check
+ *       whether the FIFO is already being processed. It reads and
+ *       writes at normal RAM speeds, with no monitor intervention.
+ *
+ *       If this register reads as TRUE, the host is guaranteeing that
+ *       any new commands written into the FIFO will be noticed before
+ *       the MKS goes back to sleep.
+ *
+ *       If this register reads as FALSE, no such guarantee can be
+ *       made.
+ *
+ *       The guest should use this register to quickly determine
+ *       whether or not it needs to wake up the host. If the guest
+ *       just wrote a command or group of commands that it would like
+ *       the host to begin processing, it should:
+ *
+ *         1. Read SVGA_FIFO_BUSY. If it reads as TRUE, no further
+ *            action is necessary.
+ *
+ *         2. Write TRUE to SVGA_FIFO_BUSY. This informs future guest
+ *            code that we've already sent a SYNC to the host and we
+ *            don't need to send a duplicate.
+ *
+ *         3. Write a reason to SVGA_REG_SYNC. This will send an
+ *            asynchronous wakeup to the MKS thread.
+ */
+
+
+/*
+ * FIFO Capabilities
+ *
+ *      Fence -- Fence register and command are supported
+ *      Accel Front -- Front buffer only commands are supported
+ *      Pitch Lock -- Pitch lock register is supported
+ *      Video -- SVGA Video overlay units are supported
+ *      Escape -- Escape command is supported
+ *
+ * XXX: Add longer descriptions for each capability, including a list
+ *      of the new features that each capability provides.
+ *
+ * SVGA_FIFO_CAP_SCREEN_OBJECT --
+ *
+ *    Provides dynamic multi-screen rendering, for improved Unity and
+ *    multi-monitor modes. With Screen Object, the guest can
+ *    dynamically create and destroy 'screens', which can represent
+ *    Unity windows or virtual monitors. Screen Object also provides
+ *    strong guarantees that DMA operations happen only when
+ *    guest-initiated. Screen Object deprecates the BAR1 guest
+ *    framebuffer (GFB) and all commands that work only with the GFB.
+ *
+ *    New registers:
+ *       FIFO_CURSOR_SCREEN_ID, VIDEO_DATA_GMRID, VIDEO_DST_SCREEN_ID
+ *
+ *    New 2D commands:
+ *       DEFINE_SCREEN, DESTROY_SCREEN, DEFINE_GMRFB, BLIT_GMRFB_TO_SCREEN,
+ *       BLIT_SCREEN_TO_GMRFB, ANNOTATION_FILL, ANNOTATION_COPY
+ *
+ *    New 3D commands:
+ *       BLIT_SURFACE_TO_SCREEN
+ *
+ *    New guarantees:
+ *
+ *       - The host will not read or write guest memory, including the GFB,
+ *         except when explicitly initiated by a DMA command.
+ *
+ *       - All DMA, including legacy DMA like UPDATE and PRESENT_READBACK,
+ *         is guaranteed to complete before any subsequent FENCEs.
+ *
+ *       - All legacy commands which affect a Screen (UPDATE, PRESENT,
+ *         PRESENT_READBACK) as well as new Screen blit commands will
+ *         all behave consistently as blits, and memory will be read
+ *         or written in FIFO order.
+ *
+ *         For example, if you PRESENT from one SVGA3D surface to multiple
+ *         places on the screen, the data copied will always be from the
+ *         SVGA3D surface at the time the PRESENT was issued in the FIFO.
+ *         This was not necessarily true on devices without Screen Object.
+ *
+ *         This means that on devices that support Screen Object, the
+ *         PRESENT_READBACK command should not be necessary unless you
+ *         actually want to read back the results of 3D rendering into
+ *         system memory. (And for that, the BLIT_SCREEN_TO_GMRFB
+ *         command provides a strict superset of functionality.)
+ *
+ *       - When a screen is resized, either using Screen Object commands or
+ *         legacy multimon registers, its contents are preserved.
+ */
+
+#define SVGA_FIFO_CAP_NONE                  0
+#define SVGA_FIFO_CAP_FENCE             (1<<0)
+#define SVGA_FIFO_CAP_ACCELFRONT        (1<<1)
+#define SVGA_FIFO_CAP_PITCHLOCK         (1<<2)
+#define SVGA_FIFO_CAP_VIDEO             (1<<3)
+#define SVGA_FIFO_CAP_CURSOR_BYPASS_3   (1<<4)
+#define SVGA_FIFO_CAP_ESCAPE            (1<<5)
+#define SVGA_FIFO_CAP_RESERVE           (1<<6)
+#define SVGA_FIFO_CAP_SCREEN_OBJECT     (1<<7)
+
+
+/*
+ * FIFO Flags
+ *
+ *      Accel Front -- Driver should use front buffer only commands
+ */
+
+#define SVGA_FIFO_FLAG_NONE                 0
+#define SVGA_FIFO_FLAG_ACCELFRONT       (1<<0)
+#define SVGA_FIFO_FLAG_RESERVED        (1<<31) // Internal use only
+
+/*
+ * FIFO reservation sentinel value
+ */
+
+#define SVGA_FIFO_RESERVED_UNKNOWN      0xffffffff
+
+
+/*
+ * Video overlay support
+ */
+
+#define SVGA_NUM_OVERLAY_UNITS 32
+
+
+/*
+ * Video capabilities that the guest is currently using
+ */
+
+#define SVGA_VIDEO_FLAG_COLORKEY        0x0001
+
+
+/*
+ * Offsets for the video overlay registers
+ */
+
+enum {
+   SVGA_VIDEO_ENABLED = 0,
+   SVGA_VIDEO_FLAGS,
+   SVGA_VIDEO_DATA_OFFSET,
+   SVGA_VIDEO_FORMAT,
+   SVGA_VIDEO_COLORKEY,
+   SVGA_VIDEO_SIZE,          // Deprecated
+   SVGA_VIDEO_WIDTH,
+   SVGA_VIDEO_HEIGHT,
+   SVGA_VIDEO_SRC_X,
+   SVGA_VIDEO_SRC_Y,
+   SVGA_VIDEO_SRC_WIDTH,
+   SVGA_VIDEO_SRC_HEIGHT,
+   SVGA_VIDEO_DST_X,         // Signed int32
+   SVGA_VIDEO_DST_Y,         // Signed int32
+   SVGA_VIDEO_DST_WIDTH,
+   SVGA_VIDEO_DST_HEIGHT,
+   SVGA_VIDEO_PITCH_1,
+   SVGA_VIDEO_PITCH_2,
+   SVGA_VIDEO_PITCH_3,
+   SVGA_VIDEO_DATA_GMRID,    // Optional, defaults to SVGA_GMR_FRAMEBUFFER
+   SVGA_VIDEO_DST_SCREEN_ID, // Optional, defaults to virtual coords (SVGA_ID_INVALID)
+   SVGA_VIDEO_NUM_REGS
+};
+
+
+/*
+ * SVGA Overlay Units
+ *
+ *      width and height relate to the entire source video frame.
+ *      srcX, srcY, srcWidth and srcHeight represent subset of the source
+ *      video frame to be displayed.
+ */
+
+typedef struct SVGAOverlayUnit {
+   uint32 enabled;
+   uint32 flags;
+   uint32 dataOffset;
+   uint32 format;
+   uint32 colorKey;
+   uint32 size;
+   uint32 width;
+   uint32 height;
+   uint32 srcX;
+   uint32 srcY;
+   uint32 srcWidth;
+   uint32 srcHeight;
+   int32  dstX;
+   int32  dstY;
+   uint32 dstWidth;
+   uint32 dstHeight;
+   uint32 pitches[3];
+   uint32 dataGMRId;
+   uint32 dstScreenId;
+} SVGAOverlayUnit;
+
+
+/*
+ * SVGAScreenObject --
+ *
+ *    This is a new way to represent a guest's multi-monitor screen or
+ *    Unity window. Screen objects are only supported if the
+ *    SVGA_FIFO_CAP_SCREEN_OBJECT capability bit is set.
+ *
+ *    If Screen Objects are supported, they can be used to fully
+ *    replace the functionality provided by the framebuffer registers
+ *    (SVGA_REG_WIDTH, HEIGHT, etc.) and by SVGA_CAP_DISPLAY_TOPOLOGY.
+ *
+ *    The screen object is a struct with guaranteed binary
+ *    compatibility. New flags can be added, and the struct may grow,
+ *    but existing fields must retain their meaning.
+ *
+ */
+
+#define SVGA_SCREEN_HAS_ROOT    (1 << 0)  // Screen is present in the virtual coord space
+#define SVGA_SCREEN_IS_PRIMARY  (1 << 1)  // Guest considers this screen to be 'primary'
+#define SVGA_SCREEN_FULLSCREEN_HINT (1 << 2)   // Guest is running a fullscreen app here
+
+typedef
+struct SVGAScreenObject {
+   uint32 structSize;   // sizeof(SVGAScreenObject)
+   uint32 id;
+   uint32 flags;
+   struct {
+      uint32 width;
+      uint32 height;
+   } size;
+   struct {
+      int32 x;
+      int32 y;
+   } root;              // Only used if SVGA_SCREEN_HAS_ROOT is set.
+} SVGAScreenObject;
+
+
+/*
+ *  Commands in the command FIFO:
+ *
+ *  Command IDs defined below are used for the traditional 2D FIFO
+ *  communication (not all commands are available for all versions of the
+ *  SVGA FIFO protocol).
+ *
+ *  Note the holes in the command ID numbers: These commands have been
+ *  deprecated, and the old IDs must not be reused.
+ *
+ *  Command IDs from 1000 to 1999 are reserved for use by the SVGA3D
+ *  protocol.
+ *
+ *  Each command's parameters are described by the comments and
+ *  structs below.
+ */
+
+typedef enum {
+   SVGA_CMD_INVALID_CMD           = 0,
+   SVGA_CMD_UPDATE                = 1,
+   SVGA_CMD_RECT_COPY             = 3,
+   SVGA_CMD_DEFINE_CURSOR         = 19,
+   SVGA_CMD_DEFINE_ALPHA_CURSOR   = 22,
+   SVGA_CMD_UPDATE_VERBOSE        = 25,
+   SVGA_CMD_FRONT_ROP_FILL        = 29,
+   SVGA_CMD_FENCE                 = 30,
+   SVGA_CMD_ESCAPE                = 33,
+   SVGA_CMD_DEFINE_SCREEN         = 34,
+   SVGA_CMD_DESTROY_SCREEN        = 35,
+   SVGA_CMD_DEFINE_GMRFB          = 36,
+   SVGA_CMD_BLIT_GMRFB_TO_SCREEN  = 37,
+   SVGA_CMD_BLIT_SCREEN_TO_GMRFB  = 38,
+   SVGA_CMD_ANNOTATION_FILL       = 39,
+   SVGA_CMD_ANNOTATION_COPY       = 40,
+   SVGA_CMD_MAX
+} SVGAFifoCmdId;
+
+#define SVGA_CMD_MAX_ARGS           64
+
+
+/*
+ * SVGA_CMD_UPDATE --
+ *
+ *    This is a DMA transfer which copies from the Guest Framebuffer
+ *    (GFB) at BAR1 + SVGA_REG_FB_OFFSET to any screens which
+ *    intersect with the provided virtual rectangle.
+ *
+ *    This command does not support using arbitrary guest memory as a
+ *    data source- it only works with the pre-defined GFB memory.
+ *    This command also does not support signed virtual coordinates.
+ *    If you have defined screens (using SVGA_CMD_DEFINE_SCREEN) with
+ *    negative root x/y coordinates, the negative portion of those
+ *    screens will not be reachable by this command.
+ *
+ *    This command is not necessary when using framebuffer
+ *    traces. Traces are automatically enabled if the SVGA FIFO is
+ *    disabled, and you may explicitly enable/disable traces using
+ *    SVGA_REG_TRACES. With traces enabled, any write to the GFB will
+ *    automatically act as if a subsequent SVGA_CMD_UPDATE was issued.
+ *
+ *    Traces and SVGA_CMD_UPDATE are the only supported ways to render
+ *    pseudocolor screen updates. The newer Screen Object commands
+ *    only support true color formats.
+ *
+ * Availability:
+ *    Always available.
+ */
+
+typedef
+struct {
+   uint32 x;
+   uint32 y;
+   uint32 width;
+   uint32 height;
+} SVGAFifoCmdUpdate;
+
+
+/*
+ * SVGA_CMD_RECT_COPY --
+ *
+ *    Perform a rectangular DMA transfer from one area of the GFB to
+ *    another, and copy the result to any screens which intersect it.
+ *
+ * Availability:
+ *    SVGA_CAP_RECT_COPY
+ */
+
+typedef
+struct {
+   uint32 srcX;
+   uint32 srcY;
+   uint32 destX;
+   uint32 destY;
+   uint32 width;
+   uint32 height;
+} SVGAFifoCmdRectCopy;
+
+
+/*
+ * SVGA_CMD_DEFINE_CURSOR --
+ *
+ *    Provide a new cursor image, as an AND/XOR mask.
+ *
+ *    The recommended way to position the cursor overlay is by using
+ *    the SVGA_FIFO_CURSOR_* registers, supported by the
+ *    SVGA_FIFO_CAP_CURSOR_BYPASS_3 capability.
+ *
+ * Availability:
+ *    SVGA_CAP_CURSOR
+ */
+
+typedef
+struct {
+   uint32 id;             // Reserved, must be zero.
+   uint32 hotspotX;
+   uint32 hotspotY;
+   uint32 width;
+   uint32 height;
+   uint32 andMaskDepth;   // Value must be 1 or equal to BITS_PER_PIXEL
+   uint32 xorMaskDepth;   // Value must be 1 or equal to BITS_PER_PIXEL
+   /*
+    * Followed by scanline data for AND mask, then XOR mask.
+    * Each scanline is padded to a 32-bit boundary.
+   */
+} SVGAFifoCmdDefineCursor;
+
+
+/*
+ * SVGA_CMD_DEFINE_ALPHA_CURSOR --
+ *
+ *    Provide a new cursor image, in 32-bit BGRA format.
+ *
+ *    The recommended way to position the cursor overlay is by using
+ *    the SVGA_FIFO_CURSOR_* registers, supported by the
+ *    SVGA_FIFO_CAP_CURSOR_BYPASS_3 capability.
+ *
+ * Availability:
+ *    SVGA_CAP_ALPHA_CURSOR
+ */
+
+typedef
+struct {
+   uint32 id;             // Reserved, must be zero.
+   uint32 hotspotX;
+   uint32 hotspotY;
+   uint32 width;
+   uint32 height;
+   /* Followed by scanline data */
+} SVGAFifoCmdDefineAlphaCursor;
+
+
+/*
+ * SVGA_CMD_UPDATE_VERBOSE --
+ *
+ *    Just like SVGA_CMD_UPDATE, but also provide a per-rectangle
+ *    'reason' value, an opaque cookie which is used by internal
+ *    debugging tools. Third party drivers should not use this
+ *    command.
+ *
+ * Availability:
+ *    SVGA_CAP_EXTENDED_FIFO
+ */
+
+typedef
+struct {
+   uint32 x;
+   uint32 y;
+   uint32 width;
+   uint32 height;
+   uint32 reason;
+} SVGAFifoCmdUpdateVerbose;
+
+
+/*
+ * SVGA_CMD_FRONT_ROP_FILL --
+ *
+ *    This is a hint which tells the SVGA device that the driver has
+ *    just filled a rectangular region of the GFB with a solid
+ *    color. Instead of reading these pixels from the GFB, the device
+ *    can assume that they all equal 'color'. This is primarily used
+ *    for remote desktop protocols.
+ *
+ * Availability:
+ *    SVGA_FIFO_CAP_ACCELFRONT
+ */
+
+#define  SVGA_ROP_COPY                    0x03
+
+typedef
+struct {
+   uint32 color;     // In the same format as the GFB
+   uint32 x;
+   uint32 y;
+   uint32 width;
+   uint32 height;
+   uint32 rop;       // Must be SVGA_ROP_COPY
+} SVGAFifoCmdFrontRopFill;
+
+
+/*
+ * SVGA_CMD_FENCE --
+ *
+ *    Insert a synchronization fence.  When the SVGA device reaches
+ *    this command, it will copy the 'fence' value into the
+ *    SVGA_FIFO_FENCE register. It will also compare the fence against
+ *    SVGA_FIFO_FENCE_GOAL. If the fence matches the goal and the
+ *    SVGA_IRQFLAG_FENCE_GOAL interrupt is enabled, the device will
+ *    raise this interrupt.
+ *
+ * Availability:
+ *    SVGA_FIFO_FENCE for this command,
+ *    SVGA_CAP_IRQMASK for SVGA_FIFO_FENCE_GOAL.
+ */
+
+typedef
+struct {
+   uint32 fence;
+} SVGAFifoCmdFence;
+
+
+/*
+ * SVGA_CMD_ESCAPE --
+ *
+ *    Send an extended or vendor-specific variable length command.
+ *    This is used for video overlay, third party plugins, and
+ *    internal debugging tools. See svga_escape.h
+ *
+ * Availability:
+ *    SVGA_FIFO_CAP_ESCAPE
+ */
+
+typedef
+struct {
+   uint32 nsid;
+   uint32 size;
+   /* followed by 'size' bytes of data */
+} SVGAFifoCmdEscape;
+
+
+/*
+ * SVGA_CMD_DEFINE_SCREEN --
+ *
+ *    Define or redefine an SVGAScreenObject. See the description of
+ *    SVGAScreenObject above.  The video driver is responsible for
+ *    generating new screen IDs. They should be small positive
+ *    integers. The virtual device will have an implementation
+ *    specific upper limit on the number of screen IDs
+ *    supported. Drivers are responsible for recycling IDs. The first
+ *    valid ID is zero.
+ *
+ *    - Interaction with other registers:
+ *
+ *    For backwards compatibility, when the GFB mode registers (WIDTH,
+ *    HEIGHT, PITCHLOCK, BITS_PER_PIXEL) are modified, the SVGA device
+ *    deletes all screens other than screen #0, and redefines screen
+ *    #0 according to the specified mode. Drivers that use
+ *    SVGA_CMD_DEFINE_SCREEN should destroy or redefine screen #0.
+ *
+ *    If you use screen objects, do not use the legacy multi-mon
+ *    registers (SVGA_REG_NUM_GUEST_DISPLAYS, SVGA_REG_DISPLAY_*).
+ *
+ * Availability:
+ *    SVGA_FIFO_CAP_SCREEN_OBJECT
+ */
+
+typedef
+struct {
+   SVGAScreenObject screen;   // Variable-length according to version
+} SVGAFifoCmdDefineScreen;
+
+
+/*
+ * SVGA_CMD_DESTROY_SCREEN --
+ *
+ *    Destroy an SVGAScreenObject. Its ID is immediately available for
+ *    re-use.
+ *
+ * Availability:
+ *    SVGA_FIFO_CAP_SCREEN_OBJECT
+ */
+
+typedef
+struct {
+   uint32 screenId;
+} SVGAFifoCmdDestroyScreen;
+
+
+/*
+ * SVGA_CMD_DEFINE_GMRFB --
+ *
+ *    This command sets a piece of SVGA device state called the
+ *    Guest Memory Region Framebuffer, or GMRFB. The GMRFB is a
+ *    piece of light-weight state which identifies the location and
+ *    format of an image in guest memory or in BAR1. The GMRFB has
+ *    an arbitrary size, and it doesn't need to match the geometry
+ *    of the GFB or any screen object.
+ *
+ *    The GMRFB can be redefined as often as you like. You could
+ *    always use the same GMRFB, you could redefine it before
+ *    rendering from a different guest screen, or you could even
+ *    redefine it before every blit.
+ *
+ *    There are multiple ways to use this command. The simplest way is
+ *    to use it to move the framebuffer either to elsewhere in the GFB
+ *    (BAR1) memory region, or to a user-defined GMR. This lets a
+ *    driver use a framebuffer allocated entirely out of normal system
+ *    memory, which we encourage.
+ *
+ *    Another way to use this command is to set up a ring buffer of
+ *    updates in GFB memory. If a driver wants to ensure that no
+ *    frames are skipped by the SVGA device, it is important that the
+ *    driver not modify the source data for a blit until the device is
+ *    done processing the command. One efficient way to accomplish
+ *    this is to use a ring of small DMA buffers. Each buffer is used
+ *    for one blit, then we move on to the next buffer in the
+ *    ring. The FENCE mechanism is used to protect each buffer from
+ *    re-use until the device is finished with that buffer's
+ *    corresponding blit.
+ *
+ *    This command does not affect the meaning of SVGA_CMD_UPDATE.
+ *    UPDATEs always occur from the legacy GFB memory area. This
+ *    command has no support for pseudocolor GMRFBs. Currently only
+ *    true-color 15, 16, and 24-bit depths are supported. Future
+ *    devices may expose capabilities for additional framebuffer
+ *    formats.
+ *
+ *    The default GMRFB value is undefined. Drivers must always send
+ *    this command at least once before performing any blit from the
+ *    GMRFB.
+ *
+ * Availability:
+ *    SVGA_FIFO_CAP_SCREEN_OBJECT
+ */
+
+typedef
+struct {
+   SVGAGuestPtr        ptr;
+   uint32              bytesPerLine;
+   SVGAGMRImageFormat  format;
+} SVGAFifoCmdDefineGMRFB;
+
+
+/*
+ * SVGA_CMD_BLIT_GMRFB_TO_SCREEN --
+ *
+ *    This is a guest-to-host blit. It performs a DMA operation to
+ *    copy a rectangular region of pixels from the current GMRFB to
+ *    one or more Screen Objects.
+ *
+ *    The destination coordinate may be specified relative to a
+ *    screen's origin (if a screen ID is specified) or relative to the
+ *    virtual coordinate system's origin (if the screen ID is
+ *    SVGA_ID_INVALID). The actual destination may span zero or more
+ *    screens, in the case of a virtual destination rect or a rect
+ *    which extends off the edge of the specified screen.
+ *
+ *    This command writes to the screen's "base layer": the underlying
+ *    framebuffer which exists below any cursor or video overlays. No
+ *    action is necessary to explicitly hide or update any overlays
+ *    which exist on top of the updated region.
+ *
+ *    The SVGA device is guaranteed to finish reading from the GMRFB
+ *    by the time any subsequent FENCE commands are reached.
+ *
+ *    This command consumes an annotation. See the
+ *    SVGA_CMD_ANNOTATION_* commands for details.
+ *
+ * Availability:
+ *    SVGA_FIFO_CAP_SCREEN_OBJECT
+ */
+
+typedef
+struct {
+   SVGASignedPoint  srcOrigin;
+   SVGASignedRect   destRect;
+   uint32           destScreenId;
+} SVGAFifoCmdBlitGMRFBToScreen;
+
+
+/*
+ * SVGA_CMD_BLIT_SCREEN_TO_GMRFB --
+ *
+ *    This is a host-to-guest blit. It performs a DMA operation to
+ *    copy a rectangular region of pixels from a single Screen Object
+ *    back to the current GMRFB.
+ *
+ *    Usage note: This command should be used rarely. It will
+ *    typically be inefficient, but it is necessary for some types of
+ *    synchronization between 3D (GPU) and 2D (CPU) rendering into
+ *    overlapping areas of a screen.
+ *
+ *    The source coordinate is specified relative to a screen's
+ *    origin. The provided screen ID must be valid. If any parameters
+ *    are invalid, the resulting pixel values are undefined.
+ *
+ *    This command reads the screen's "base layer". Overlays like
+ *    video and cursor are not included, but any data which was sent
+ *    using a blit-to-screen primitive will be available, no matter
+ *    whether the data's original source was the GMRFB or the 3D
+ *    acceleration hardware.
+ *
+ *    Note that our guest-to-host blits and host-to-guest blits aren't
+ *    symmetric in their current implementation. While the parameters
+ *    are identical, host-to-guest blits are a lot less featureful.
+ *    They do not support clipping: If the source parameters don't
+ *    fully fit within a screen, the blit fails. They must originate
+ *    from exactly one screen. Virtual coordinates are not directly
+ *    supported.
+ *
+ *    Host-to-guest blits do support the same set of GMRFB formats
+ *    offered by guest-to-host blits.
+ *
+ *    The SVGA device is guaranteed to finish writing to the GMRFB by
+ *    the time any subsequent FENCE commands are reached.
+ *
+ * Availability:
+ *    SVGA_FIFO_CAP_SCREEN_OBJECT
+ */
+
+typedef
+struct {
+   SVGASignedPoint  destOrigin;
+   SVGASignedRect   srcRect;
+   uint32           srcScreenId;
+} SVGAFifoCmdBlitScreenToGMRFB;
+
+
+/*
+ * SVGA_CMD_ANNOTATION_FILL --
+ *
+ *    This is a blit annotation. This command stores a small piece of
+ *    device state which is consumed by the next blit-to-screen
+ *    command. The state is only cleared by commands which are
+ *    specifically documented as consuming an annotation. Other
+ *    commands (such as ESCAPEs for debugging) may intervene between
+ *    the annotation and its associated blit.
+ *
+ *    This annotation is a promise about the contents of the next
+ *    blit: The video driver is guaranteeing that all pixels in that
+ *    blit will have the same value, specified here as a color in
+ *    SVGAColorBGRX format.
+ *
+ *    The SVGA device can still render the blit correctly even if it
+ *    ignores this annotation, but the annotation may allow it to
+ *    perform the blit more efficiently, for example by ignoring the
+ *    source data and performing a fill in hardware.
+ *
+ *    This annotation is most important for performance when the
+ *    user's display is being remoted over a network connection.
+ *
+ * Availability:
+ *    SVGA_FIFO_CAP_SCREEN_OBJECT
+ */
+
+typedef
+struct {
+   SVGAColorBGRX  color;
+} SVGAFifoCmdAnnotationFill;
+
+
+/*
+ * SVGA_CMD_ANNOTATION_COPY --
+ *
+ *    This is a blit annotation. See SVGA_CMD_ANNOTATION_FILL for more
+ *    information about annotations.
+ *
+ *    This annotation is a promise about the contents of the next
+ *    blit: The video driver is guaranteeing that all pixels in that
+ *    blit will have the same value as those which already exist at an
+ *    identically-sized region on the same or a different screen.
+ *
+ *    Note that the source pixels for the COPY in this annotation are
+ *    sampled before applying the anqnotation's associated blit. They
+ *    are allowed to overlap with the blit's destination pixels.
+ *
+ *    The copy source rectangle is specified the same way as the blit
+ *    destination: it can be a rectangle which spans zero or more
+ *    screens, specified relative to either a screen or to the virtual
+ *    coordinate system's origin. If the source rectangle includes
+ *    pixels which are not from exactly one screen, the results are
+ *    undefined.
+ *
+ * Availability:
+ *    SVGA_FIFO_CAP_SCREEN_OBJECT
+ */
+
+typedef
+struct {
+   SVGASignedPoint  srcOrigin;
+   uint32           srcScreenId;
+} SVGAFifoCmdAnnotationCopy;
+
+#endif
diff --git a/src/gallium/drivers/svga/include/svga_types.h b/src/gallium/drivers/svga/include/svga_types.h
new file mode 100644 (file)
index 0000000..7fd9bab
--- /dev/null
@@ -0,0 +1,46 @@
+/**********************************************************
+ * Copyright 1998-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#ifndef _SVGA_TYPES_H_
+#define _SVGA_TYPES_H_
+
+#include "pipe/p_compiler.h"
+
+typedef int64_t int64;
+typedef uint64_t uint64;
+
+typedef int32_t int32;
+typedef uint32_t uint32;
+
+typedef int16_t int16;
+typedef uint16_t uint16;
+
+typedef int8_t int8;
+typedef uint8_t uint8;
+
+typedef uint8_t Bool;
+
+#endif /* _SVGA_TYPES_H_ */
+
diff --git a/src/gallium/drivers/svga/svga_cmd.c b/src/gallium/drivers/svga/svga_cmd.c
new file mode 100644 (file)
index 0000000..a0da7d7
--- /dev/null
@@ -0,0 +1,1427 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+/**
+ * svga_cmd.c --
+ *
+ *      Command construction utility for the SVGA3D protocol used by
+ *      the VMware SVGA device, based on the svgautil library.
+ */
+
+#include "svga_winsys.h"
+#include "svga_screen_buffer.h"
+#include "svga_screen_texture.h"
+#include "svga_cmd.h"
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * surface_to_surfaceid --
+ *
+ *      Utility function for surface ids.
+ *      Can handle null surface. Does a surface_reallocation so you need
+ *      to have allocated the fifo space before converting.
+ *
+ * Results:
+ *      id is filld out.
+ *
+ * Side effects:
+ *      One surface relocation is preformed for texture handle.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static INLINE
+void surface_to_surfaceid(struct svga_winsys_context *swc, // IN
+                          struct pipe_surface *surface,    // IN
+                          SVGA3dSurfaceImageId *id,        // OUT
+                          unsigned flags)                  // IN
+{
+   if(surface) {
+      struct svga_surface *s = svga_surface(surface);
+      swc->surface_relocation(swc, &id->sid, s->handle, flags);
+      id->face = s->real_face; /* faces have the same order */
+      id->mipmap = s->real_level;
+   }
+   else {
+      id->sid = SVGA3D_INVALID_ID;
+      id->face = 0;
+      id->mipmap = 0;
+   }
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SVGA3D_FIFOReserve --
+ *
+ *      Reserve space for an SVGA3D FIFO command.
+ *
+ *      The 2D SVGA commands have been around for a while, so they
+ *      have a rather asymmetric structure. The SVGA3D protocol is
+ *      more uniform: each command begins with a header containing the
+ *      command number and the full size.
+ *
+ *      This is a convenience wrapper around SVGA_FIFOReserve. We
+ *      reserve space for the whole command, and write the header.
+ *
+ *      This function must be paired with SVGA_FIFOCommitAll().
+ *
+ * Results:
+ *      Returns a pointer to the space reserved for command-specific
+ *      data. It must be 'cmdSize' bytes long.
+ *
+ * Side effects:
+ *      Begins a FIFO reservation.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void *
+SVGA3D_FIFOReserve(struct svga_winsys_context *swc,
+                   uint32 cmd,       // IN
+                   uint32 cmdSize,   // IN
+                   uint32 nr_relocs) // IN
+{
+   SVGA3dCmdHeader *header;
+
+   header = swc->reserve(swc, sizeof *header + cmdSize, nr_relocs);
+   if(!header)
+      return NULL;
+
+   header->id = cmd;
+   header->size = cmdSize;
+
+   return &header[1];
+}
+
+
+void
+SVGA_FIFOCommitAll(struct svga_winsys_context *swc)
+{
+   swc->commit(swc);
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SVGA3D_DefineContext --
+ *
+ *      Create a new context, to be referred to with the provided ID.
+ *
+ *      Context objects encapsulate all render state, and shader
+ *      objects are per-context.
+ *
+ *      Surfaces are not per-context. The same surface can be shared
+ *      between multiple contexts, and surface operations can occur
+ *      without a context.
+ *
+ *      If the provided context ID already existed, it is redefined.
+ *
+ *      Context IDs are arbitrary small non-negative integers,
+ *      global to the entire SVGA device.
+ *
+ * Results:
+ *      None.
+ *
+ * Side effects:
+ *      None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+enum pipe_error
+SVGA3D_DefineContext(struct svga_winsys_context *swc)  // IN
+{
+   SVGA3dCmdDefineContext *cmd;
+
+   cmd = SVGA3D_FIFOReserve(swc,
+                            SVGA_3D_CMD_CONTEXT_DEFINE, sizeof *cmd, 0);
+   if(!cmd)
+      return PIPE_ERROR_OUT_OF_MEMORY;
+
+   cmd->cid = swc->cid;
+
+   swc->commit(swc);
+   
+   return PIPE_OK;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SVGA3D_DestroyContext --
+ *
+ *      Delete a context created with SVGA3D_DefineContext.
+ *
+ * Results:
+ *      None.
+ *
+ * Side effects:
+ *      None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+enum pipe_error
+SVGA3D_DestroyContext(struct svga_winsys_context *swc)  // IN
+{
+   SVGA3dCmdDestroyContext *cmd;
+   
+   cmd = SVGA3D_FIFOReserve(swc,
+                            SVGA_3D_CMD_CONTEXT_DESTROY, sizeof *cmd, 0);
+   if(!cmd)
+      return PIPE_ERROR_OUT_OF_MEMORY;
+   
+   cmd->cid = swc->cid;
+   
+   swc->commit(swc);
+   
+   return PIPE_OK;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SVGA3D_BeginDefineSurface --
+ *
+ *      Begin a SURFACE_DEFINE command. This reserves space for it in
+ *      the FIFO, and returns pointers to the command's faces and
+ *      mipsizes arrays.
+ *
+ *      This function must be paired with SVGA_FIFOCommitAll().
+ *      The faces and mipSizes arrays are initialized to zero.
+ *
+ *      This creates a "surface" object in the SVGA3D device,
+ *      with the provided surface ID (sid). Surfaces are generic
+ *      containers for host VRAM objects like textures, vertex
+ *      buffers, and depth/stencil buffers.
+ *
+ *      Surfaces are hierarchial:
+ *
+ *        - Surface may have multiple faces (for cube maps)
+ *
+ *          - Each face has a list of mipmap levels
+ *
+ *             - Each mipmap image may have multiple volume
+ *               slices, if the image is three dimensional.
+ *
+ *                - Each slice is a 2D array of 'blocks'
+ *
+ *                   - Each block may be one or more pixels.
+ *                     (Usually 1, more for DXT or YUV formats.)
+ *
+ *      Surfaces are generic host VRAM objects. The SVGA3D device
+ *      may optimize surfaces according to the format they were
+ *      created with, but this format does not limit the ways in
+ *      which the surface may be used. For example, a depth surface
+ *      can be used as a texture, or a floating point image may
+ *      be used as a vertex buffer. Some surface usages may be
+ *      lower performance, due to software emulation, but any
+ *      usage should work with any surface.
+ *
+ *      If 'sid' is already defined, the old surface is deleted
+ *      and this new surface replaces it.
+ *
+ *      Surface IDs are arbitrary small non-negative integers,
+ *      global to the entire SVGA device.
+ *
+ * Results:
+ *      Returns pointers to arrays allocated in the FIFO for 'faces'
+ *      and 'mipSizes'.
+ *
+ * Side effects:
+ *      Begins a FIFO reservation.
+ *
+ *----------------------------------------------------------------------
+ */
+
+enum pipe_error
+SVGA3D_BeginDefineSurface(struct svga_winsys_context *swc,
+                          struct svga_winsys_surface *sid, // IN
+                          SVGA3dSurfaceFlags flags,    // IN
+                          SVGA3dSurfaceFormat format,  // IN
+                          SVGA3dSurfaceFace **faces,   // OUT
+                          SVGA3dSize **mipSizes,       // OUT
+                          uint32 numMipSizes)          // IN
+{
+   SVGA3dCmdDefineSurface *cmd;
+
+   cmd = SVGA3D_FIFOReserve(swc,
+                            SVGA_3D_CMD_SURFACE_DEFINE, sizeof *cmd +
+                            sizeof **mipSizes * numMipSizes, 1);
+   if(!cmd)
+      return PIPE_ERROR_OUT_OF_MEMORY;
+
+   swc->surface_relocation(swc, &cmd->sid, sid, PIPE_BUFFER_USAGE_GPU_WRITE);
+   cmd->surfaceFlags = flags;
+   cmd->format = format;
+
+   *faces = &cmd->face[0];
+   *mipSizes = (SVGA3dSize*) &cmd[1];
+
+   memset(*faces, 0, sizeof **faces * SVGA3D_MAX_SURFACE_FACES);
+   memset(*mipSizes, 0, sizeof **mipSizes * numMipSizes);
+   
+   return PIPE_OK;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SVGA3D_DefineSurface2D --
+ *
+ *      This is a simplified version of SVGA3D_BeginDefineSurface(),
+ *      which does not support cube maps, mipmaps, or volume textures.
+ *
+ * Results:
+ *      None.
+ *
+ * Side effects:
+ *      None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+enum pipe_error
+SVGA3D_DefineSurface2D(struct svga_winsys_context *swc,    // IN
+                       struct svga_winsys_surface *sid, // IN
+                       uint32 width,                // IN
+                       uint32 height,               // IN
+                       SVGA3dSurfaceFormat format)  // IN
+{
+   SVGA3dSize *mipSizes;
+   SVGA3dSurfaceFace *faces;
+   enum pipe_error ret;
+
+   ret = SVGA3D_BeginDefineSurface(swc,
+                                   sid, 0, format, &faces, &mipSizes, 1);
+   if(ret != PIPE_OK)
+      return ret;
+
+   faces[0].numMipLevels = 1;
+
+   mipSizes[0].width = width;
+   mipSizes[0].height = height;
+   mipSizes[0].depth = 1;
+   swc->commit(swc);;
+   
+   return PIPE_OK;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SVGA3D_DestroySurface --
+ *
+ *      Release the host VRAM encapsulated by a particular surface ID.
+ *
+ * Results:
+ *      None.
+ *
+ * Side effects:
+ *      None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+enum pipe_error
+SVGA3D_DestroySurface(struct svga_winsys_context *swc,
+                      struct svga_winsys_surface *sid)  // IN
+{
+   SVGA3dCmdDestroySurface *cmd;
+   
+   cmd = SVGA3D_FIFOReserve(swc,
+                            SVGA_3D_CMD_SURFACE_DESTROY, sizeof *cmd, 1);
+   if(!cmd)
+      return PIPE_ERROR_OUT_OF_MEMORY;
+   
+   swc->surface_relocation(swc, &cmd->sid, sid, PIPE_BUFFER_USAGE_GPU_READ);
+   swc->commit(swc);;
+   
+   return PIPE_OK;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SVGA3D_BeginSurfaceDMA--
+ *
+ *      Begin a SURFACE_DMA command. This reserves space for it in
+ *      the FIFO, and returns a pointer to the command's box array.
+ *      This function must be paired with SVGA_FIFOCommitAll().
+ *
+ *      When the SVGA3D device asynchronously processes this FIFO
+ *      command, a DMA operation is performed between host VRAM and
+ *      a generic SVGAGuestPtr. The guest pointer may refer to guest
+ *      VRAM (provided by the SVGA PCI device) or to guest system
+ *      memory that has been set up as a Guest Memory Region (GMR)
+ *      by the SVGA device.
+ *
+ *      The guest's DMA buffer must remain valid (not freed, paged out,
+ *      or overwritten) until the host has finished processing this
+ *      command. The guest can determine that the host has finished
+ *      by using the SVGA device's FIFO Fence mechanism.
+ *
+ *      The guest's image buffer can be an arbitrary size and shape.
+ *      Guest image data is interpreted according to the SVGA3D surface
+ *      format specified when the surface was defined.
+ *
+ *      The caller may optionally define the guest image's pitch.
+ *      guestImage->pitch can either be zero (assume image is tightly
+ *      packed) or it must be the number of bytes between vertically
+ *      adjacent image blocks.
+ *
+ *      The provided copybox list specifies which regions of the source
+ *      image are to be copied, and where they appear on the destination.
+ *
+ *      NOTE: srcx/srcy are always on the guest image and x/y are
+ *      always on the host image, regardless of the actual transfer
+ *      direction!
+ *
+ *      For efficiency, the SVGA3D device is free to copy more data
+ *      than specified. For example, it may round copy boxes outwards
+ *      such that they lie on particular alignment boundaries.
+ *
+ *----------------------------------------------------------------------
+ */
+
+enum pipe_error
+SVGA3D_SurfaceDMA(struct svga_winsys_context *swc,
+                  struct svga_transfer *st,         // IN
+                  SVGA3dTransferType transfer,      // IN
+                  const SVGA3dCopyBox *boxes,       // IN
+                  uint32 numBoxes)                  // IN
+{
+   struct svga_texture *texture = svga_texture(st->base.texture); 
+   SVGA3dCmdSurfaceDMA *cmd;
+   SVGA3dCmdSurfaceDMASuffix *pSuffix;
+   uint32 boxesSize = sizeof *boxes * numBoxes;
+   unsigned region_flags;
+   unsigned surface_flags;
+   
+   if(transfer == SVGA3D_WRITE_HOST_VRAM) {
+      region_flags = PIPE_BUFFER_USAGE_GPU_READ;
+      surface_flags = PIPE_BUFFER_USAGE_GPU_WRITE;
+   }
+   else if(transfer == SVGA3D_READ_HOST_VRAM) {
+      region_flags = PIPE_BUFFER_USAGE_GPU_WRITE;
+      surface_flags = PIPE_BUFFER_USAGE_GPU_READ;
+   }
+   else {
+      assert(0);
+      return PIPE_ERROR_BAD_INPUT;
+   }
+   
+   cmd = SVGA3D_FIFOReserve(swc,
+                            SVGA_3D_CMD_SURFACE_DMA,
+                            sizeof *cmd + boxesSize + sizeof *pSuffix,
+                            2);
+   if(!cmd)
+      return PIPE_ERROR_OUT_OF_MEMORY;
+
+   swc->region_relocation(swc, &cmd->guest.ptr, st->hwbuf, 0, region_flags);
+   cmd->guest.pitch = st->base.stride;
+
+   swc->surface_relocation(swc, &cmd->host.sid, texture->handle, surface_flags);
+   cmd->host.face = st->base.face; /* PIPE_TEX_FACE_* and SVGA3D_CUBEFACE_* match */
+   cmd->host.mipmap = st->base.level;
+
+   cmd->transfer = transfer;
+
+   memcpy(&cmd[1], boxes, boxesSize);
+   
+   pSuffix = (SVGA3dCmdSurfaceDMASuffix *)((uint8_t*)cmd + sizeof *cmd + boxesSize);
+   pSuffix->suffixSize = sizeof *pSuffix;
+   pSuffix->maximumOffset = st->hw_nblocksy*st->base.stride;
+   memset(&pSuffix->flags, 0, sizeof pSuffix->flags);
+
+   swc->commit(swc);
+
+   return PIPE_OK;
+}
+
+
+enum pipe_error
+SVGA3D_BufferDMA(struct svga_winsys_context *swc,
+                 struct svga_winsys_buffer *guest,
+                 struct svga_winsys_surface *host,
+                 SVGA3dTransferType transfer,      // IN
+                 uint32 size,                      // IN
+                 uint32 offset,                    // IN
+                 SVGA3dSurfaceDMAFlags flags)      // IN
+{
+   SVGA3dCmdSurfaceDMA *cmd;
+   SVGA3dCopyBox *box;
+   SVGA3dCmdSurfaceDMASuffix *pSuffix;
+   unsigned region_flags;
+   unsigned surface_flags;
+   
+   if(transfer == SVGA3D_WRITE_HOST_VRAM) {
+      region_flags = PIPE_BUFFER_USAGE_GPU_READ;
+      surface_flags = PIPE_BUFFER_USAGE_GPU_WRITE;
+   }
+   else if(transfer == SVGA3D_READ_HOST_VRAM) {
+      region_flags = PIPE_BUFFER_USAGE_GPU_WRITE;
+      surface_flags = PIPE_BUFFER_USAGE_GPU_READ;
+   }
+   else {
+      assert(0);
+      return PIPE_ERROR_BAD_INPUT;
+   }
+   
+   cmd = SVGA3D_FIFOReserve(swc,
+                            SVGA_3D_CMD_SURFACE_DMA,
+                            sizeof *cmd + sizeof *box + sizeof *pSuffix,
+                            2);
+   if(!cmd)
+      return PIPE_ERROR_OUT_OF_MEMORY;
+
+   swc->region_relocation(swc, &cmd->guest.ptr, guest, 0, region_flags);
+   cmd->guest.pitch = 0;
+
+   swc->surface_relocation(swc, &cmd->host.sid, host, surface_flags);
+   cmd->host.face = 0;
+   cmd->host.mipmap = 0;
+
+   cmd->transfer = transfer;
+
+   box = (SVGA3dCopyBox *)&cmd[1];
+   box->x = offset;
+   box->y = 0;
+   box->z = 0;
+   box->w = size;
+   box->h = 1;
+   box->d = 1;
+   box->srcx = offset;
+   box->srcy = 0;
+   box->srcz = 0;
+   
+   pSuffix = (SVGA3dCmdSurfaceDMASuffix *)((uint8_t*)cmd + sizeof *cmd + sizeof *box);
+   pSuffix->suffixSize = sizeof *pSuffix;
+   pSuffix->maximumOffset = offset + size;
+   pSuffix->flags = flags;
+
+   swc->commit(swc);
+
+   return PIPE_OK;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SVGA3D_SetRenderTarget --
+ *
+ *      Bind a surface object to a particular render target attachment
+ *      point on the current context. Render target attachment points
+ *      exist for color buffers, a depth buffer, and a stencil buffer.
+ *
+ *      The SVGA3D device is quite lenient about the types of surfaces
+ *      that may be used as render targets. The color buffers must
+ *      all be the same size, but the depth and stencil buffers do not
+ *      have to be the same size as the color buffer. All attachments
+ *      are optional.
+ *
+ *      Some combinations of render target formats may require software
+ *      emulation, depending on the capabilities of the host graphics
+ *      API and graphics hardware.
+ *
+ * Results:
+ *      None.
+ *
+ * Side effects:
+ *      None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+enum pipe_error
+SVGA3D_SetRenderTarget(struct svga_winsys_context *swc,
+                       SVGA3dRenderTargetType type,   // IN
+                       struct pipe_surface *surface)  // IN
+{
+   SVGA3dCmdSetRenderTarget *cmd;
+   
+   cmd = SVGA3D_FIFOReserve(swc,
+                            SVGA_3D_CMD_SETRENDERTARGET, sizeof *cmd, 1);
+   if(!cmd)
+      return PIPE_ERROR_OUT_OF_MEMORY;
+
+
+   cmd->cid = swc->cid;
+
+   cmd->type = type;
+
+   surface_to_surfaceid(swc, surface, &cmd->target, PIPE_BUFFER_USAGE_GPU_WRITE);
+
+   swc->commit(swc);
+
+   return PIPE_OK;
+}
+
+
+
+
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SVGA3D_DefineShader --
+ *
+ *      Upload the bytecode for a new shader. The bytecode is "SVGA3D
+ *      format", which is theoretically a binary-compatible superset
+ *      of Microsoft's DirectX shader bytecode. In practice, the
+ *      SVGA3D bytecode doesn't yet have any extensions to DirectX's
+ *      bytecode format.
+ *
+ *      The SVGA3D device supports shader models 1.1 through 2.0.
+ *
+ *      The caller chooses a shader ID (small positive integer) by
+ *      which this shader will be identified in future commands. This
+ *      ID is in a namespace which is per-context and per-shader-type.
+ *
+ *      'bytecodeLen' is specified in bytes. It must be a multiple of 4.
+ *
+ * Results:
+ *      None.
+ *
+ * Side effects:
+ *      None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+enum pipe_error
+SVGA3D_DefineShader(struct svga_winsys_context *swc,
+                    uint32 shid,                  // IN
+                    SVGA3dShaderType type,        // IN
+                    const uint32 *bytecode,       // IN
+                    uint32 bytecodeLen)           // IN
+{
+   SVGA3dCmdDefineShader *cmd;
+
+   assert(bytecodeLen % 4 == 0);
+
+   cmd = SVGA3D_FIFOReserve(swc,
+                            SVGA_3D_CMD_SHADER_DEFINE, sizeof *cmd + bytecodeLen,
+                            0);
+   if(!cmd)
+      return PIPE_ERROR_OUT_OF_MEMORY;
+
+   cmd->cid = swc->cid;
+   cmd->shid = shid;
+   cmd->type = type;
+   memcpy(&cmd[1], bytecode, bytecodeLen);
+   swc->commit(swc);
+
+   return PIPE_OK;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SVGA3D_DestroyShader --
+ *
+ *      Delete a shader that was created by SVGA3D_DefineShader. If
+ *      the shader was the current vertex or pixel shader for its
+ *      context, rendering results are undefined until a new shader is
+ *      bound.
+ *
+ * Results:
+ *      None.
+ *
+ * Side effects:
+ *      None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+enum pipe_error
+SVGA3D_DestroyShader(struct svga_winsys_context *swc,
+                     uint32 shid,            // IN
+                     SVGA3dShaderType type)  // IN
+{
+   SVGA3dCmdDestroyShader *cmd;
+   
+   cmd = SVGA3D_FIFOReserve(swc,
+                            SVGA_3D_CMD_SHADER_DESTROY, sizeof *cmd,
+                            0);
+   if(!cmd)
+      return PIPE_ERROR_OUT_OF_MEMORY;
+
+   cmd->cid = swc->cid;
+   cmd->shid = shid;
+   cmd->type = type;
+   swc->commit(swc);
+
+   return PIPE_OK;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SVGA3D_SetShaderConst --
+ *
+ *      Set the value of a shader constant.
+ *
+ *      Shader constants are analogous to uniform variables in GLSL,
+ *      except that they belong to the render context rather than to
+ *      an individual shader.
+ *
+ *      Constants may have one of three types: A 4-vector of floats,
+ *      a 4-vector of integers, or a single boolean flag.
+ *
+ * Results:
+ *      None.
+ *
+ * Side effects:
+ *      None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+enum pipe_error
+SVGA3D_SetShaderConst(struct svga_winsys_context *swc,
+                      uint32 reg,                   // IN
+                      SVGA3dShaderType type,        // IN
+                      SVGA3dShaderConstType ctype,  // IN
+                      const void *value)            // IN
+{
+   SVGA3dCmdSetShaderConst *cmd;
+   
+   cmd = SVGA3D_FIFOReserve(swc,
+                            SVGA_3D_CMD_SET_SHADER_CONST, sizeof *cmd,
+                            0);
+   if(!cmd)
+      return PIPE_ERROR_OUT_OF_MEMORY;
+
+   cmd->cid = swc->cid;
+   cmd->reg = reg;
+   cmd->type = type;
+   cmd->ctype = ctype;
+
+   switch (ctype) {
+
+   case SVGA3D_CONST_TYPE_FLOAT:
+   case SVGA3D_CONST_TYPE_INT:
+      memcpy(&cmd->values, value, sizeof cmd->values);
+      break;
+
+   case SVGA3D_CONST_TYPE_BOOL:
+      memset(&cmd->values, 0, sizeof cmd->values);
+      cmd->values[0] = *(uint32*)value;
+      break;
+
+   default:
+      assert(0);
+      break;
+
+   }
+   swc->commit(swc);
+
+   return PIPE_OK;
+}
+
+
+
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SVGA3D_SetShader --
+ *
+ *      Switch active shaders. This binds a new vertex or pixel shader
+ *      to the specified context.
+ *
+ *      A shader ID of SVGA3D_INVALID_ID unbinds any shader, switching
+ *      back to the fixed function vertex or pixel pipeline.
+ *
+ * Results:
+ *      None.
+ *
+ * Side effects:
+ *      None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+enum pipe_error
+SVGA3D_SetShader(struct svga_winsys_context *swc,
+                 SVGA3dShaderType type,  // IN
+                 uint32 shid)            // IN
+{
+   SVGA3dCmdSetShader *cmd;
+   
+   cmd = SVGA3D_FIFOReserve(swc,
+                            SVGA_3D_CMD_SET_SHADER, sizeof *cmd,
+                            0);
+   if(!cmd)
+      return PIPE_ERROR_OUT_OF_MEMORY;
+   
+   cmd->cid = swc->cid;
+   cmd->type = type;
+   cmd->shid = shid;
+   swc->commit(swc);
+
+   return PIPE_OK;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SVGA3D_BeginClear --
+ *
+ *      Begin a CLEAR command. This reserves space for it in the FIFO,
+ *      and returns a pointer to the command's rectangle array.  This
+ *      function must be paired with SVGA_FIFOCommitAll().
+ *
+ *      Clear is a rendering operation which fills a list of
+ *      rectangles with constant values on all render target types
+ *      indicated by 'flags'.
+ *
+ *      Clear is not affected by clipping, depth test, or other
+ *      render state which affects the fragment pipeline.
+ *
+ * Results:
+ *      None.
+ *
+ * Side effects:
+ *      May write to attached render target surfaces.
+ *
+ *----------------------------------------------------------------------
+ */
+
+enum pipe_error
+SVGA3D_BeginClear(struct svga_winsys_context *swc,
+                  SVGA3dClearFlag flags,  // IN
+                  uint32 color,           // IN
+                  float depth,            // IN
+                  uint32 stencil,         // IN
+                  SVGA3dRect **rects,     // OUT
+                  uint32 numRects)        // IN
+{
+   SVGA3dCmdClear *cmd;
+   
+   cmd = SVGA3D_FIFOReserve(swc,
+                            SVGA_3D_CMD_CLEAR, 
+                            sizeof *cmd + sizeof **rects * numRects,
+                            0);
+   if(!cmd)
+      return PIPE_ERROR_OUT_OF_MEMORY;
+
+   cmd->cid = swc->cid;
+   cmd->clearFlag = flags;
+   cmd->color = color;
+   cmd->depth = depth;
+   cmd->stencil = stencil;
+   *rects = (SVGA3dRect*) &cmd[1];
+
+   return PIPE_OK;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SVGA3D_ClearRect --
+ *
+ *      This is a simplified version of SVGA3D_BeginClear().
+ *
+ * Results:
+ *      None.
+ *
+ * Side effects:
+ *      None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+enum pipe_error
+SVGA3D_ClearRect(struct svga_winsys_context *swc,
+                 SVGA3dClearFlag flags,  // IN
+                 uint32 color,           // IN
+                 float depth,            // IN
+                 uint32 stencil,         // IN
+                 uint32 x,               // IN
+                 uint32 y,               // IN
+                 uint32 w,               // IN
+                 uint32 h)               // IN
+{
+   SVGA3dRect *rect;
+   enum pipe_error ret;
+
+   ret = SVGA3D_BeginClear(swc, flags, color, depth, stencil, &rect, 1);
+   if(ret != PIPE_OK)
+      return PIPE_ERROR_OUT_OF_MEMORY;
+
+   memset(rect, 0, sizeof *rect);
+   rect->x = x;
+   rect->y = y;
+   rect->w = w;
+   rect->h = h;
+   swc->commit(swc);
+
+   return PIPE_OK;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SVGA3D_BeginDrawPrimitives --
+ *
+ *      Begin a DRAW_PRIMITIVES command. This reserves space for it in
+ *      the FIFO, and returns a pointer to the command's arrays.
+ *      This function must be paired with SVGA_FIFOCommitAll().
+ *
+ *      Drawing commands consist of two variable-length arrays:
+ *      SVGA3dVertexDecl elements declare a set of vertex buffers to
+ *      use while rendering, and SVGA3dPrimitiveRange elements specify
+ *      groups of primitives each with an optional index buffer.
+ *
+ *      The decls and ranges arrays are initialized to zero.
+ *
+ * Results:
+ *      None.
+ *
+ * Side effects:
+ *      May write to attached render target surfaces.
+ *
+ *----------------------------------------------------------------------
+ */
+
+enum pipe_error
+SVGA3D_BeginDrawPrimitives(struct svga_winsys_context *swc,
+                           SVGA3dVertexDecl **decls,      // OUT
+                           uint32 numVertexDecls,         // IN
+                           SVGA3dPrimitiveRange **ranges, // OUT
+                           uint32 numRanges)              // IN
+{
+   SVGA3dCmdDrawPrimitives *cmd;
+   SVGA3dVertexDecl *declArray;
+   SVGA3dPrimitiveRange *rangeArray;
+   uint32 declSize = sizeof **decls * numVertexDecls;
+   uint32 rangeSize = sizeof **ranges * numRanges;
+
+   cmd = SVGA3D_FIFOReserve(swc,
+                            SVGA_3D_CMD_DRAW_PRIMITIVES, 
+                            sizeof *cmd + declSize + rangeSize,
+                            numVertexDecls + numRanges);
+   if(!cmd)
+      return PIPE_ERROR_OUT_OF_MEMORY;
+
+   cmd->cid = swc->cid;
+   cmd->numVertexDecls = numVertexDecls;
+   cmd->numRanges = numRanges;
+
+   declArray = (SVGA3dVertexDecl*) &cmd[1];
+   rangeArray = (SVGA3dPrimitiveRange*) &declArray[numVertexDecls];
+
+   memset(declArray, 0, declSize);
+   memset(rangeArray, 0, rangeSize);
+
+   *decls = declArray;
+   *ranges = rangeArray;
+
+   return PIPE_OK;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SVGA3D_BeginSurfaceCopy --
+ *
+ *      Begin a SURFACE_COPY command. This reserves space for it in
+ *      the FIFO, and returns a pointer to the command's arrays.  This
+ *      function must be paired with SVGA_FIFOCommitAll().
+ *
+ *      The box array is initialized with zeroes.
+ *
+ * Results:
+ *      None.
+ *
+ * Side effects:
+ *      Asynchronously copies a list of boxes from surface to surface.
+ *
+ *----------------------------------------------------------------------
+ */
+
+enum pipe_error
+SVGA3D_BeginSurfaceCopy(struct svga_winsys_context *swc,
+                        struct pipe_surface *src,    // IN
+                        struct pipe_surface *dest,   // IN
+                        SVGA3dCopyBox **boxes,       // OUT
+                        uint32 numBoxes)             // IN
+{
+   SVGA3dCmdSurfaceCopy *cmd;
+   uint32 boxesSize = sizeof **boxes * numBoxes;
+
+   cmd = SVGA3D_FIFOReserve(swc,
+                            SVGA_3D_CMD_SURFACE_COPY, sizeof *cmd + boxesSize,
+                            2);
+   if(!cmd)
+      return PIPE_ERROR_OUT_OF_MEMORY;
+
+   surface_to_surfaceid(swc, src, &cmd->src, PIPE_BUFFER_USAGE_GPU_READ);
+   surface_to_surfaceid(swc, dest, &cmd->dest, PIPE_BUFFER_USAGE_GPU_WRITE);
+   *boxes = (SVGA3dCopyBox*) &cmd[1];
+
+   memset(*boxes, 0, boxesSize);
+
+   return PIPE_OK;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SVGA3D_SurfaceStretchBlt --
+ *
+ *      Issue a SURFACE_STRETCHBLT command: an asynchronous
+ *      surface-to-surface blit, with scaling.
+ *
+ * Results:
+ *      None.
+ *
+ * Side effects:
+ *      Asynchronously copies one box from surface to surface.
+ *
+ *----------------------------------------------------------------------
+ */
+
+enum pipe_error
+SVGA3D_SurfaceStretchBlt(struct svga_winsys_context *swc,
+                         struct pipe_surface *src,    // IN
+                         struct pipe_surface *dest,   // IN
+                         SVGA3dBox *boxSrc,           // IN
+                         SVGA3dBox *boxDest,          // IN
+                         SVGA3dStretchBltMode mode)   // IN
+{
+   SVGA3dCmdSurfaceStretchBlt *cmd;
+   
+   cmd = SVGA3D_FIFOReserve(swc,
+                            SVGA_3D_CMD_SURFACE_STRETCHBLT, sizeof *cmd,
+                            2);
+   if(!cmd)
+      return PIPE_ERROR_OUT_OF_MEMORY;
+
+   surface_to_surfaceid(swc, src, &cmd->src, PIPE_BUFFER_USAGE_GPU_READ);
+   surface_to_surfaceid(swc, dest, &cmd->dest, PIPE_BUFFER_USAGE_GPU_WRITE);
+   cmd->boxSrc = *boxSrc;
+   cmd->boxDest = *boxDest;
+   cmd->mode = mode;
+   swc->commit(swc);
+
+   return PIPE_OK;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SVGA3D_SetViewport --
+ *
+ *      Set the current context's viewport rectangle. The viewport
+ *      is clipped to the dimensions of the current render target,
+ *      then all rendering is clipped to the viewport.
+ *
+ * Results:
+ *      None.
+ *
+ * Side effects:
+ *      None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+enum pipe_error
+SVGA3D_SetViewport(struct svga_winsys_context *swc,
+                   SVGA3dRect *rect)  // IN
+{
+   SVGA3dCmdSetViewport *cmd;
+   
+   cmd = SVGA3D_FIFOReserve(swc,
+                            SVGA_3D_CMD_SETVIEWPORT, sizeof *cmd,
+                            0);
+   if(!cmd)
+      return PIPE_ERROR_OUT_OF_MEMORY;
+
+   cmd->cid = swc->cid;
+   cmd->rect = *rect;
+   swc->commit(swc);
+
+   return PIPE_OK;
+}
+
+
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SVGA3D_SetScissorRect --
+ *
+ *      Set the current context's scissor rectangle. If scissor
+ *      is enabled then all rendering is clipped to the scissor.
+ *
+ * Results:
+ *      None.
+ *
+ * Side effects:
+ *      None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+enum pipe_error
+SVGA3D_SetScissorRect(struct svga_winsys_context *swc,
+                      SVGA3dRect *rect)  // IN
+{
+   SVGA3dCmdSetScissorRect *cmd;
+   
+   cmd = SVGA3D_FIFOReserve(swc,
+                            SVGA_3D_CMD_SETSCISSORRECT, sizeof *cmd,
+                            0);
+   if(!cmd)
+      return PIPE_ERROR_OUT_OF_MEMORY;
+
+   cmd->cid = swc->cid;
+   cmd->rect = *rect;
+   swc->commit(swc);
+
+   return PIPE_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SVGA3D_SetClipPlane --
+ *
+ *      Set one of the current context's clip planes. If the clip
+ *      plane is enabled then all 3d rendering is clipped to against
+ *      the plane.
+ *
+ * Results:
+ *      None.
+ *
+ * Side effects:
+ *      None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+enum pipe_error SVGA3D_SetClipPlane(struct svga_winsys_context *swc,
+                         uint32 index, const float *plane)
+{
+   SVGA3dCmdSetClipPlane *cmd;
+   
+   cmd = SVGA3D_FIFOReserve(swc,
+                            SVGA_3D_CMD_SETCLIPPLANE, sizeof *cmd,
+                            0);
+   if(!cmd)
+      return PIPE_ERROR_OUT_OF_MEMORY;
+
+   cmd->cid = swc->cid;
+   cmd->index = index;
+   cmd->plane[0] = plane[0];
+   cmd->plane[1] = plane[1];
+   cmd->plane[2] = plane[2];
+   cmd->plane[3] = plane[3];
+   swc->commit(swc);
+
+   return PIPE_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SVGA3D_SetZRange --
+ *
+ *      Set the range of the depth buffer to use. 'min' and 'max'
+ *      are values between 0.0 and 1.0.
+ *
+ * Results:
+ *      None.
+ *
+ * Side effects:
+ *      None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+enum pipe_error
+SVGA3D_SetZRange(struct svga_winsys_context *swc,
+                 float zMin,  // IN
+                 float zMax)  // IN
+{
+   SVGA3dCmdSetZRange *cmd;
+   
+   cmd = SVGA3D_FIFOReserve(swc,
+                            SVGA_3D_CMD_SETZRANGE, sizeof *cmd,
+                            0);
+   if(!cmd)
+      return PIPE_ERROR_OUT_OF_MEMORY;
+
+   cmd->cid = swc->cid;
+   cmd->zRange.min = zMin;
+   cmd->zRange.max = zMax;
+   swc->commit(swc);
+
+   return PIPE_OK;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SVGA3D_BeginSetTextureState --
+ *
+ *      Begin a SETTEXTURESTATE command. This reserves space for it in
+ *      the FIFO, and returns a pointer to the command's texture state
+ *      array.  This function must be paired with SVGA_FIFOCommitAll().
+ *
+ *      This command sets rendering state which is per-texture-unit.
+ *
+ *      XXX: Individual texture states need documentation. However,
+ *           they are very similar to the texture states defined by
+ *           Direct3D. The D3D documentation is a good starting point
+ *           for understanding SVGA3D texture states.
+ *
+ * Results:
+ *      None.
+ *
+ * Side effects:
+ *      None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+enum pipe_error
+SVGA3D_BeginSetTextureState(struct svga_winsys_context *swc,
+                            SVGA3dTextureState **states,  // OUT
+                            uint32 numStates)             // IN
+{
+   SVGA3dCmdSetTextureState *cmd;
+   
+   cmd = SVGA3D_FIFOReserve(swc,
+                            SVGA_3D_CMD_SETTEXTURESTATE, 
+                            sizeof *cmd + sizeof **states * numStates,
+                            numStates);
+   if(!cmd)
+      return PIPE_ERROR_OUT_OF_MEMORY;
+
+   cmd->cid = swc->cid;
+   *states = (SVGA3dTextureState*) &cmd[1];
+
+   return PIPE_OK;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SVGA3D_BeginSetRenderState --
+ *
+ *      Begin a SETRENDERSTATE command. This reserves space for it in
+ *      the FIFO, and returns a pointer to the command's texture state
+ *      array.  This function must be paired with SVGA_FIFOCommitAll().
+ *
+ *      This command sets rendering state which is global to the context.
+ *
+ *      XXX: Individual render states need documentation. However,
+ *           they are very similar to the render states defined by
+ *           Direct3D. The D3D documentation is a good starting point
+ *           for understanding SVGA3D render states.
+ *
+ * Results:
+ *      None.
+ *
+ * Side effects:
+ *      None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+enum pipe_error
+SVGA3D_BeginSetRenderState(struct svga_winsys_context *swc,
+                           SVGA3dRenderState **states,  // OUT
+                           uint32 numStates)            // IN
+{
+   SVGA3dCmdSetRenderState *cmd;
+   
+   cmd = SVGA3D_FIFOReserve(swc,
+                            SVGA_3D_CMD_SETRENDERSTATE, 
+                            sizeof *cmd + sizeof **states * numStates,
+                            0);
+   if(!cmd)
+      return PIPE_ERROR_OUT_OF_MEMORY;
+
+   cmd->cid = swc->cid;
+   *states = (SVGA3dRenderState*) &cmd[1];
+
+   return PIPE_OK;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SVGA3D_BeginQuery--
+ *
+ *      Issues a SVGA_3D_CMD_BEGIN_QUERY command.
+ *
+ * Results:
+ *      None.
+ *
+ * Side effects:
+ *      Commits space in the FIFO memory.
+ *
+ *----------------------------------------------------------------------
+ */
+
+enum pipe_error
+SVGA3D_BeginQuery(struct svga_winsys_context *swc,
+                  SVGA3dQueryType type) // IN
+{
+   SVGA3dCmdBeginQuery *cmd;
+
+   cmd = SVGA3D_FIFOReserve(swc,
+                            SVGA_3D_CMD_BEGIN_QUERY,
+                            sizeof *cmd,
+                            0);
+   if(!cmd)
+      return PIPE_ERROR_OUT_OF_MEMORY;
+
+   cmd->cid = swc->cid;
+   cmd->type = type;
+
+   swc->commit(swc);
+   
+   return PIPE_OK;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SVGA3D_EndQuery--
+ *
+ *      Issues a SVGA_3D_CMD_END_QUERY command.
+ *
+ * Results:
+ *      None.
+ *
+ * Side effects:
+ *      Commits space in the FIFO memory.
+ *
+ *----------------------------------------------------------------------
+ */
+
+enum pipe_error
+SVGA3D_EndQuery(struct svga_winsys_context *swc,
+                SVGA3dQueryType type,              // IN
+                struct svga_winsys_buffer *buffer) // IN/OUT
+{
+   SVGA3dCmdEndQuery *cmd;
+
+   cmd = SVGA3D_FIFOReserve(swc,
+                            SVGA_3D_CMD_END_QUERY, 
+                            sizeof *cmd,
+                            1);
+   if(!cmd)
+      return PIPE_ERROR_OUT_OF_MEMORY;
+
+   cmd->cid = swc->cid;
+   cmd->type = type;
+
+   swc->region_relocation(swc, &cmd->guestResult, buffer, 0,
+                          PIPE_BUFFER_USAGE_GPU_WRITE);
+
+   swc->commit(swc);
+   
+   return PIPE_OK;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SVGA3D_WaitForQuery--
+ *
+ *      Issues a SVGA_3D_CMD_WAIT_FOR_QUERY command.  This reserves space
+ *      for it in the FIFO.  This doesn't actually wait for the query to
+ *      finish but instead tells the host to start a wait at the driver
+ *      level.  The caller can wait on the status variable in the
+ *      guestPtr memory or send an insert fence instruction after this
+ *      command and wait on the fence.
+ *
+ * Results:
+ *      None.
+ *
+ * Side effects:
+ *      Commits space in the FIFO memory.
+ *
+ *----------------------------------------------------------------------
+ */
+
+enum pipe_error
+SVGA3D_WaitForQuery(struct svga_winsys_context *swc,
+                    SVGA3dQueryType type,              // IN
+                    struct svga_winsys_buffer *buffer) // IN/OUT
+{
+   SVGA3dCmdWaitForQuery *cmd;
+
+   cmd = SVGA3D_FIFOReserve(swc,
+                            SVGA_3D_CMD_WAIT_FOR_QUERY, 
+                            sizeof *cmd,
+                            1);
+   if(!cmd)
+      return PIPE_ERROR_OUT_OF_MEMORY;
+
+   cmd->cid = swc->cid;
+   cmd->type = type;
+   
+   swc->region_relocation(swc, &cmd->guestResult, buffer, 0,
+                          PIPE_BUFFER_USAGE_GPU_WRITE);
+
+   swc->commit(swc);
+   
+   return PIPE_OK;
+}
diff --git a/src/gallium/drivers/svga/svga_cmd.h b/src/gallium/drivers/svga/svga_cmd.h
new file mode 100644 (file)
index 0000000..8041054
--- /dev/null
@@ -0,0 +1,235 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+/*
+ * svga_cmd.h --
+ *
+ *      Command construction utility for the SVGA3D protocol used by
+ *      the VMware SVGA device, based on the svgautil library.
+ */
+
+#ifndef __SVGA3D_H__
+#define __SVGA3D_H__
+
+
+#include "svga_types.h"
+#include "svga_reg.h"
+#include "svga3d_reg.h"
+
+#include "pipe/p_defines.h"
+
+
+struct pipe_buffer;
+struct pipe_surface;
+struct svga_transfer;
+struct svga_winsys_context;
+struct svga_winsys_buffer;
+struct svga_winsys_surface;
+
+
+/*
+ * SVGA Device Interoperability
+ */
+
+void *
+SVGA3D_FIFOReserve(struct svga_winsys_context *swc, uint32 cmd, uint32 cmdSize, uint32 nr_relocs);
+
+void
+SVGA_FIFOCommitAll(struct svga_winsys_context *swc);
+
+
+/*
+ * Context Management
+ */
+
+enum pipe_error
+SVGA3D_DefineContext(struct svga_winsys_context *swc);
+
+enum pipe_error
+SVGA3D_DestroyContext(struct svga_winsys_context *swc);
+
+
+/*
+ * Surface Management
+ */
+
+enum pipe_error
+SVGA3D_BeginDefineSurface(struct svga_winsys_context *swc,
+                          struct svga_winsys_surface *sid,
+                          SVGA3dSurfaceFlags flags,
+                          SVGA3dSurfaceFormat format,
+                          SVGA3dSurfaceFace **faces,
+                          SVGA3dSize **mipSizes,
+                          uint32 numMipSizes);
+enum pipe_error
+SVGA3D_DefineSurface2D(struct svga_winsys_context *swc,
+                       struct svga_winsys_surface *sid,
+                       uint32 width,
+                       uint32 height,
+                       SVGA3dSurfaceFormat format);
+enum pipe_error
+SVGA3D_DestroySurface(struct svga_winsys_context *swc,
+                      struct svga_winsys_surface *sid);
+
+
+/*
+ * Surface Operations
+ */
+
+enum pipe_error
+SVGA3D_SurfaceDMA(struct svga_winsys_context *swc,
+                  struct svga_transfer *st,
+                  SVGA3dTransferType transfer,
+                  const SVGA3dCopyBox *boxes,
+                  uint32 numBoxes);
+
+enum pipe_error
+SVGA3D_BufferDMA(struct svga_winsys_context *swc,
+                 struct svga_winsys_buffer *guest,
+                 struct svga_winsys_surface *host,
+                 SVGA3dTransferType transfer,
+                 uint32 size,
+                 uint32 offset,
+                 SVGA3dSurfaceDMAFlags flags);
+
+/*
+ * Drawing Operations
+ */
+
+
+enum pipe_error
+SVGA3D_BeginClear(struct svga_winsys_context *swc,
+                  SVGA3dClearFlag flags,
+                  uint32 color, float depth, uint32 stencil,
+                  SVGA3dRect **rects, uint32 numRects);
+
+enum pipe_error
+SVGA3D_ClearRect(struct svga_winsys_context *swc,
+                 SVGA3dClearFlag flags, uint32 color, float depth,
+                 uint32 stencil, uint32 x, uint32 y, uint32 w, uint32 h);
+
+enum pipe_error
+SVGA3D_BeginDrawPrimitives(struct svga_winsys_context *swc,
+                           SVGA3dVertexDecl **decls,
+                           uint32 numVertexDecls,
+                           SVGA3dPrimitiveRange **ranges,
+                           uint32 numRanges);
+
+/*
+ * Blits
+ */
+
+enum pipe_error
+SVGA3D_BeginSurfaceCopy(struct svga_winsys_context *swc,
+                        struct pipe_surface *src,
+                        struct pipe_surface *dest,
+                        SVGA3dCopyBox **boxes, uint32 numBoxes);
+
+
+enum pipe_error
+SVGA3D_SurfaceStretchBlt(struct svga_winsys_context *swc,
+                         struct pipe_surface *src,
+                         struct pipe_surface *dest,
+                         SVGA3dBox *boxSrc, SVGA3dBox *boxDest,
+                         SVGA3dStretchBltMode mode);
+
+/*
+ * Shared FFP/Shader Render State
+ */
+
+enum pipe_error
+SVGA3D_SetRenderTarget(struct svga_winsys_context *swc,
+                       SVGA3dRenderTargetType type,
+                       struct pipe_surface *surface);
+
+enum pipe_error
+SVGA3D_SetZRange(struct svga_winsys_context *swc,
+                 float zMin, float zMax);
+
+enum pipe_error
+SVGA3D_SetViewport(struct svga_winsys_context *swc,
+                   SVGA3dRect *rect);
+
+enum pipe_error
+SVGA3D_SetScissorRect(struct svga_winsys_context *swc,
+                      SVGA3dRect *rect);
+
+enum pipe_error
+SVGA3D_SetClipPlane(struct svga_winsys_context *swc,
+                    uint32 index, const float *plane);
+
+enum pipe_error
+SVGA3D_BeginSetTextureState(struct svga_winsys_context *swc,
+                            SVGA3dTextureState **states,
+                            uint32 numStates);
+
+enum pipe_error
+SVGA3D_BeginSetRenderState(struct svga_winsys_context *swc,
+                           SVGA3dRenderState **states,
+                           uint32 numStates);
+
+
+/*
+ * Shaders
+ */
+
+enum pipe_error
+SVGA3D_DefineShader(struct svga_winsys_context *swc,
+                    uint32 shid, SVGA3dShaderType type,
+                    const uint32 *bytecode, uint32 bytecodeLen);
+
+enum pipe_error
+SVGA3D_DestroyShader(struct svga_winsys_context *swc,
+                     uint32 shid, SVGA3dShaderType type);
+
+enum pipe_error
+SVGA3D_SetShaderConst(struct svga_winsys_context *swc,
+                      uint32 reg, SVGA3dShaderType type,
+                      SVGA3dShaderConstType ctype, const void *value);
+
+enum pipe_error
+SVGA3D_SetShader(struct svga_winsys_context *swc,
+                 SVGA3dShaderType type, uint32 shid);
+
+
+/*
+ * Queries
+ */
+
+enum pipe_error
+SVGA3D_BeginQuery(struct svga_winsys_context *swc,
+                  SVGA3dQueryType type);
+
+enum pipe_error
+SVGA3D_EndQuery(struct svga_winsys_context *swc,
+                SVGA3dQueryType type,
+                struct svga_winsys_buffer *buffer);
+
+enum pipe_error
+SVGA3D_WaitForQuery(struct svga_winsys_context *swc,
+                    SVGA3dQueryType type,
+                    struct svga_winsys_buffer *buffer);
+
+#endif /* __SVGA3D_H__ */
diff --git a/src/gallium/drivers/svga/svga_context.c b/src/gallium/drivers/svga/svga_context.c
new file mode 100644 (file)
index 0000000..af99c9d
--- /dev/null
@@ -0,0 +1,287 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "svga_cmd.h"
+
+#include "pipe/p_defines.h"
+#include "pipe/p_inlines.h"
+#include "pipe/p_screen.h"
+#include "util/u_memory.h"
+#include "util/u_bitmask.h"
+#include "util/u_upload_mgr.h"
+
+#include "svga_context.h"
+#include "svga_screen.h"
+#include "svga_screen_texture.h"
+#include "svga_screen_buffer.h"
+#include "svga_winsys.h"
+#include "svga_swtnl.h"
+#include "svga_draw.h"
+#include "svga_debug.h"
+#include "svga_state.h"
+
+
+static void svga_destroy( struct pipe_context *pipe )
+{
+   struct svga_context *svga = svga_context( pipe );
+   unsigned shader;
+
+   svga_cleanup_framebuffer( svga );
+   svga_cleanup_tss_binding( svga );
+
+   svga_hwtnl_destroy( svga->hwtnl );
+
+   svga_cleanup_vertex_state(svga);
+   
+   svga->swc->destroy(svga->swc);
+   
+   svga_destroy_swtnl( svga );
+
+   u_upload_destroy( svga->upload_vb );
+   u_upload_destroy( svga->upload_ib );
+
+   util_bitmask_destroy( svga->vs_bm );
+   util_bitmask_destroy( svga->fs_bm );
+
+   for(shader = 0; shader < PIPE_SHADER_TYPES; ++shader)
+      pipe_buffer_reference( &svga->curr.cb[shader], NULL );
+
+   FREE( svga );
+}
+
+static unsigned int
+svga_is_texture_referenced( struct pipe_context *pipe,
+                           struct pipe_texture *texture,
+                           unsigned face, unsigned level)
+{
+   struct svga_texture *tex = svga_texture(texture);
+   struct svga_screen *ss = svga_screen(pipe->screen);
+
+   /**
+    * The screen does not cache texture writes.
+    */
+
+   if (!tex->handle || ss->sws->surface_is_flushed(ss->sws, tex->handle))
+      return PIPE_UNREFERENCED;
+
+   /**
+    * sws->surface_is_flushed() does not distinguish between read references
+    * and write references. So assume a reference is both.
+    */
+
+   return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
+}
+
+static unsigned int
+svga_is_buffer_referenced( struct pipe_context *pipe,
+                          struct pipe_buffer *buf)
+
+{
+   struct svga_screen *ss = svga_screen(pipe->screen);
+   struct svga_buffer *sbuf = svga_buffer(buf);
+
+   /**
+    * XXX: Check this.
+    * The screen may cache buffer writes, but when we map, we map out
+    * of those cached writes, so we don't need to set a
+    * PIPE_REFERENCED_FOR_WRITE flag for cached buffers.
+    */
+
+   if (!sbuf->handle || ss->sws->surface_is_flushed(ss->sws, sbuf->handle))
+     return PIPE_UNREFERENCED;
+
+   /**
+    * sws->surface_is_flushed() does not distinguish between read references
+    * and write references. So assume a reference is both,
+    * however, we make an exception for index- and vertex buffers, to avoid
+    * a flush in st_bufferobj_get_subdata, during display list replay.
+    */
+
+   if (sbuf->base.usage & (PIPE_BUFFER_USAGE_VERTEX | PIPE_BUFFER_USAGE_INDEX))
+      return PIPE_REFERENCED_FOR_READ;
+
+   return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
+}
+
+
+struct pipe_context *svga_context_create( struct pipe_screen *screen )
+{
+   struct svga_screen *svgascreen = svga_screen(screen);
+   struct svga_context *svga = NULL;
+   enum pipe_error ret;
+
+   svga = CALLOC_STRUCT(svga_context);
+   if (svga == NULL)
+      goto no_svga;
+
+   svga->pipe.winsys = screen->winsys;
+   svga->pipe.screen = screen;
+   svga->pipe.destroy = svga_destroy;
+   svga->pipe.clear = svga_clear;
+
+   svga->pipe.is_texture_referenced = svga_is_texture_referenced;
+   svga->pipe.is_buffer_referenced = svga_is_buffer_referenced;
+
+   svga->swc = svgascreen->sws->context_create(svgascreen->sws);
+   if(!svga->swc)
+      goto no_swc;
+
+   svga_init_blend_functions(svga);
+   svga_init_blit_functions(svga);
+   svga_init_depth_stencil_functions(svga);
+   svga_init_draw_functions(svga);
+   svga_init_flush_functions(svga);
+   svga_init_misc_functions(svga);
+   svga_init_rasterizer_functions(svga);
+   svga_init_sampler_functions(svga);
+   svga_init_fs_functions(svga);
+   svga_init_vs_functions(svga);
+   svga_init_vertex_functions(svga);
+   svga_init_constbuffer_functions(svga);
+   svga_init_query_functions(svga);
+
+   /* debug */
+   svga->debug.no_swtnl = debug_get_bool_option("SVGA_NO_SWTNL", FALSE);
+   svga->debug.force_swtnl = debug_get_bool_option("SVGA_FORCE_SWTNL", FALSE);
+   svga->debug.use_min_mipmap = debug_get_bool_option("SVGA_USE_MIN_MIPMAP", FALSE);
+   svga->debug.disable_shader = debug_get_num_option("SVGA_DISABLE_SHADER", ~0);
+
+   if (!svga_init_swtnl(svga))
+      goto no_swtnl;
+
+   svga->fs_bm = util_bitmask_create();
+   if (svga->fs_bm == NULL)
+      goto no_fs_bm;
+
+   svga->vs_bm = util_bitmask_create();
+   if (svga->vs_bm == NULL)
+      goto no_vs_bm;
+
+   svga->upload_ib = u_upload_create( svga->pipe.screen,
+                                      32 * 1024,
+                                      16,
+                                      PIPE_BUFFER_USAGE_INDEX );
+   if (svga->upload_ib == NULL)
+      goto no_upload_ib;
+
+   svga->upload_vb = u_upload_create( svga->pipe.screen,
+                                      128 * 1024,
+                                      16,
+                                      PIPE_BUFFER_USAGE_VERTEX );
+   if (svga->upload_vb == NULL)
+      goto no_upload_vb;
+
+   svga->hwtnl = svga_hwtnl_create( svga,
+                                    svga->upload_ib,
+                                    svga->swc );
+   if (svga->hwtnl == NULL)
+      goto no_hwtnl;
+
+
+   ret = svga_emit_initial_state( svga );
+   if (ret)
+      goto no_state;
+   
+   /* Avoid shortcircuiting state with initial value of zero.
+    */
+   memset(&svga->state.hw_clear, 0xcd, sizeof(svga->state.hw_clear));
+   memset(&svga->state.hw_clear.framebuffer, 0x0, 
+          sizeof(svga->state.hw_clear.framebuffer));
+
+   memset(&svga->state.hw_draw, 0xcd, sizeof(svga->state.hw_draw));
+   memset(&svga->state.hw_draw.views, 0x0, sizeof(svga->state.hw_draw.views));
+   svga->state.hw_draw.num_views = 0;
+
+   svga->dirty = ~0;
+   svga->state.white_fs_id = SVGA3D_INVALID_ID;
+
+   LIST_INITHEAD(&svga->dirty_buffers);
+
+   return &svga->pipe;
+
+no_state:
+   svga_hwtnl_destroy( svga->hwtnl );
+no_hwtnl:
+   u_upload_destroy( svga->upload_vb );
+no_upload_vb:
+   u_upload_destroy( svga->upload_ib );
+no_upload_ib:
+   util_bitmask_destroy( svga->vs_bm );
+no_vs_bm:
+   util_bitmask_destroy( svga->fs_bm );
+no_fs_bm:
+   svga_destroy_swtnl(svga);
+no_swtnl:
+   svga->swc->destroy(svga->swc);
+no_swc:
+   FREE(svga);
+no_svga:
+   return NULL;
+}
+
+
+void svga_context_flush( struct svga_context *svga, 
+                         struct pipe_fence_handle **pfence )
+{
+   struct svga_screen *svgascreen = svga_screen(svga->pipe.screen);
+
+   svga->curr.nr_fbs = 0;
+
+   /* Unmap upload manager buffers: 
+    */
+   u_upload_flush(svga->upload_vb);
+   u_upload_flush(svga->upload_ib);
+
+   /* Flush screen, to ensure that texture dma uploads are processed
+    * before submitting commands.
+    */
+   svga_screen_flush(svgascreen, NULL);
+   
+   svga_context_flush_buffers(svga);
+
+   /* Flush pending commands to hardware:
+    */
+   svga->swc->flush(svga->swc, pfence);
+
+   if (SVGA_DEBUG & DEBUG_SYNC) {
+      if (pfence && *pfence)
+         svga->pipe.screen->fence_finish( svga->pipe.screen, *pfence, 0);
+   }
+}
+
+
+void svga_hwtnl_flush_retry( struct svga_context *svga )
+{
+   enum pipe_error ret = PIPE_OK;
+
+   ret = svga_hwtnl_flush( svga->hwtnl );
+   if (ret == PIPE_ERROR_OUT_OF_MEMORY) {
+      svga_context_flush( svga, NULL );
+      ret = svga_hwtnl_flush( svga->hwtnl );
+   }
+
+   assert(ret == 0);
+}
+
diff --git a/src/gallium/drivers/svga/svga_context.h b/src/gallium/drivers/svga/svga_context.h
new file mode 100644 (file)
index 0000000..66259fd
--- /dev/null
@@ -0,0 +1,446 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#ifndef SVGA_CONTEXT_H
+#define SVGA_CONTEXT_H
+
+
+#include "pipe/p_context.h"
+#include "pipe/p_defines.h"
+#include "pipe/p_state.h"
+
+#include "util/u_double_list.h"
+
+#include "tgsi/tgsi_scan.h"
+
+
+#define SVGA_TEX_UNITS 8
+
+struct draw_vertex_shader;
+struct svga_shader_result;
+struct SVGACmdMemory;
+struct util_bitmask;
+struct u_upload_mgr;
+
+
+struct svga_shader
+{
+   const struct tgsi_token *tokens;
+
+   struct tgsi_shader_info info;
+
+   struct svga_shader_result *results;
+
+   unsigned id;
+
+   boolean use_sm30;
+};
+
+struct svga_fragment_shader
+{
+   struct svga_shader base;
+};
+
+struct svga_vertex_shader
+{
+   struct svga_shader base;
+
+   struct draw_vertex_shader *draw_shader;
+};
+
+
+struct svga_cache_context;
+struct svga_tracked_state;
+
+struct svga_blend_state {
+
+   boolean need_white_fragments;
+
+   /* Should be per-render-target:
+    */
+   struct {
+      uint8_t writemask;
+
+      boolean blend_enable;
+      uint8_t srcblend;
+      uint8_t dstblend;
+      uint8_t blendeq;
+      
+      boolean separate_alpha_blend_enable;
+      uint8_t srcblend_alpha;
+      uint8_t dstblend_alpha;
+      uint8_t blendeq_alpha;
+
+   } rt[1];
+};
+
+struct svga_depth_stencil_state {
+   unsigned zfunc:8;
+   unsigned zenable:1;
+   unsigned zwriteenable:1;
+
+   unsigned alphatestenable:1;
+   unsigned alphafunc:8;
+  
+   struct {
+      unsigned enabled:1;
+      unsigned func:8;
+      unsigned fail:8;
+      unsigned zfail:8;
+      unsigned pass:8;
+   } stencil[2];
+   
+   /* SVGA3D has one ref/mask/writemask triple shared between front &
+    * back face stencil.  We really need two:
+    */
+   unsigned stencil_ref:8;
+   unsigned stencil_mask:8;
+   unsigned stencil_writemask:8;
+
+   float    alpharef;
+};
+
+#define SVGA_UNFILLED_DISABLE 0
+#define SVGA_UNFILLED_LINE    1
+#define SVGA_UNFILLED_POINT   2
+
+#define SVGA_PIPELINE_FLAG_POINTS   (1<<PIPE_PRIM_POINTS)
+#define SVGA_PIPELINE_FLAG_LINES    (1<<PIPE_PRIM_LINES)
+#define SVGA_PIPELINE_FLAG_TRIS     (1<<PIPE_PRIM_TRIANGLES)
+
+struct svga_rasterizer_state {
+   struct pipe_rasterizer_state templ; /* needed for draw module */
+
+   unsigned shademode:8;
+   unsigned cullmode:8;
+   unsigned scissortestenable:1;
+   unsigned multisampleantialias:1;
+   unsigned antialiasedlineenable:1;
+   unsigned lastpixel:1;
+
+   unsigned linepattern;
+
+   float slopescaledepthbias;
+   float depthbias;
+   float pointsize;
+   float pointsize_min;
+   float pointsize_max;
+   
+   unsigned hw_unfilled:16;         /* PIPE_POLYGON_MODE_x */
+   unsigned need_pipeline:16;    /* which prims do we need help for? */
+};
+
+struct svga_sampler_state {
+   unsigned mipfilter;
+   unsigned magfilter;
+   unsigned minfilter;
+   unsigned aniso_level;
+   float lod_bias;
+   unsigned addressu;
+   unsigned addressv;
+   unsigned addressw;
+   unsigned bordercolor;
+   unsigned normalized_coords:1;
+   unsigned compare_mode:1;
+   unsigned compare_func:3;
+
+   unsigned min_lod;
+   unsigned view_min_lod;
+   unsigned view_max_lod;
+};
+
+/* Use to calculate differences between state emitted to hardware and
+ * current driver-calculated state.  
+ */
+struct svga_state 
+{
+   const struct svga_blend_state *blend;
+   const struct svga_depth_stencil_state *depth;
+   const struct svga_rasterizer_state *rast;
+   const struct svga_sampler_state *sampler[PIPE_MAX_SAMPLERS];
+
+   struct pipe_texture *texture[PIPE_MAX_SAMPLERS]; /* or texture ID's? */
+   struct svga_fragment_shader *fs;
+   struct svga_vertex_shader *vs;
+
+   struct pipe_vertex_buffer vb[PIPE_MAX_ATTRIBS];
+   struct pipe_vertex_element ve[PIPE_MAX_ATTRIBS];
+   struct pipe_buffer *cb[PIPE_SHADER_TYPES];
+
+   struct pipe_framebuffer_state framebuffer;
+   float depthscale;
+
+   /* Hack to limit the number of different render targets between
+    * flushes.  Helps avoid blowing out our surface cache in EXA.
+    */
+   int nr_fbs;
+
+   struct pipe_poly_stipple poly_stipple;
+   struct pipe_scissor_state scissor;
+   struct pipe_blend_color blend_color;
+   struct pipe_clip_state clip;
+   struct pipe_viewport_state viewport;
+
+   unsigned num_samplers;
+   unsigned num_textures;
+   unsigned num_vertex_elements;
+   unsigned num_vertex_buffers;
+   unsigned reduced_prim;
+
+   struct {
+      unsigned flag_1d;
+      unsigned flag_srgb;
+   } tex_flags;
+
+   boolean any_user_vertex_buffers;
+
+   unsigned zero_stride_vertex_elements;
+   unsigned num_zero_stride_vertex_elements;
+   /* ### maybe dynamically allocate this */
+   float zero_stride_constants[PIPE_MAX_ATTRIBS*4];
+};
+
+#define RS_MAX 97
+#define TS_MAX 30
+#define CB_MAX 256
+
+struct svga_prescale {
+   float translate[4];
+   float scale[4];
+   boolean enabled;
+};
+
+
+/* Updated by calling svga_update_state( SVGA_STATE_HW_VIEWPORT )
+ */
+struct svga_hw_clear_state
+{
+   struct {
+      unsigned x,y,w,h;
+   } viewport;
+
+   struct {
+      float zmin, zmax;
+   } depthrange;
+   
+   struct pipe_framebuffer_state framebuffer;
+   struct svga_prescale prescale;
+};
+
+struct svga_hw_view_state
+{
+   struct pipe_texture *texture;
+   struct svga_sampler_view *v;
+   unsigned min_lod;
+   unsigned max_lod;
+   int dirty;
+};
+
+/* Updated by calling svga_update_state( SVGA_STATE_HW_DRAW )
+ */
+struct svga_hw_draw_state
+{
+   unsigned rs[RS_MAX];
+   unsigned ts[16][TS_MAX];
+   float cb[PIPE_SHADER_TYPES][CB_MAX][4];
+
+   struct svga_shader_result *fs;
+   struct svga_shader_result *vs;
+   struct svga_hw_view_state views[PIPE_MAX_SAMPLERS];
+
+   unsigned num_views;
+};
+
+
+/* Updated by calling svga_update_state( SVGA_STATE_NEED_SWTNL )
+ */
+struct svga_sw_state
+{
+   unsigned ve_format[PIPE_MAX_ATTRIBS]; /* NEW_VELEMENT */
+
+   /* which parts we need */
+   boolean need_swvfetch;
+   boolean need_pipeline;
+   boolean need_swtnl;
+};
+
+
+/* Queue some state updates (like rss) and submit them to hardware in
+ * a single packet.
+ */
+struct svga_hw_queue;
+
+struct svga_query;
+
+struct svga_context
+{
+   struct pipe_context pipe;
+   struct svga_winsys_context *swc;
+
+   struct {
+      boolean no_swtnl;
+      boolean force_swtnl;
+      boolean use_min_mipmap;
+
+      /* incremented for each shader */
+      unsigned shader_id;
+
+      unsigned disable_shader;
+   } debug;
+
+   struct {
+      struct draw_context *draw;
+      struct vbuf_render *backend;
+      unsigned hw_prim;
+      boolean new_vbuf;
+      boolean new_vdecl;
+   } swtnl;
+
+   /* Bitmask of used shader IDs */
+   struct util_bitmask *fs_bm;
+   struct util_bitmask *vs_bm;
+
+   struct {
+      unsigned dirty[4];
+
+      unsigned texture_timestamp;
+
+      /* Internally generated shaders:
+       */
+      unsigned white_fs_id;
+
+      /* 
+       */
+      struct svga_sw_state          sw;
+      struct svga_hw_draw_state     hw_draw;
+      struct svga_hw_clear_state    hw_clear;
+   } state;
+
+   struct svga_state curr;      /* state from the state tracker */
+   unsigned dirty;              /* statechanges since last update_state() */
+
+   struct u_upload_mgr *upload_ib;
+   struct u_upload_mgr *upload_vb;
+   struct svga_hwtnl *hwtnl;
+
+   /** The occlusion query currently in progress */
+   struct svga_query *sq;
+
+   /** List of buffers with queued transfers */
+   struct list_head dirty_buffers;
+};
+
+/* A flag for each state_tracker state object:
+ */
+#define SVGA_NEW_BLEND               0x1
+#define SVGA_NEW_DEPTH_STENCIL       0x2
+#define SVGA_NEW_RAST                0x4
+#define SVGA_NEW_SAMPLER             0x8
+#define SVGA_NEW_TEXTURE             0x10
+#define SVGA_NEW_VBUFFER             0x20
+#define SVGA_NEW_VELEMENT            0x40
+#define SVGA_NEW_FS                  0x80
+#define SVGA_NEW_VS                  0x100
+#define SVGA_NEW_FS_CONST_BUFFER     0x200
+#define SVGA_NEW_VS_CONST_BUFFER     0x400
+#define SVGA_NEW_FRAME_BUFFER        0x800
+#define SVGA_NEW_STIPPLE             0x1000
+#define SVGA_NEW_SCISSOR             0x2000
+#define SVGA_NEW_BLEND_COLOR         0x4000
+#define SVGA_NEW_CLIP                0x8000
+#define SVGA_NEW_VIEWPORT            0x10000
+#define SVGA_NEW_PRESCALE            0x20000
+#define SVGA_NEW_REDUCED_PRIMITIVE   0x40000
+#define SVGA_NEW_TEXTURE_BINDING     0x80000
+#define SVGA_NEW_NEED_PIPELINE       0x100000
+#define SVGA_NEW_NEED_SWVFETCH       0x200000
+#define SVGA_NEW_NEED_SWTNL          0x400000
+#define SVGA_NEW_FS_RESULT           0x800000
+#define SVGA_NEW_VS_RESULT           0x1000000
+#define SVGA_NEW_ZERO_STRIDE         0x2000000
+#define SVGA_NEW_TEXTURE_FLAGS       0x4000000
+
+
+
+
+
+/***********************************************************************
+ * svga_clear.c: 
+ */
+void svga_clear(struct pipe_context *pipe, 
+                unsigned buffers,
+                const float *rgba,
+                double depth,
+                unsigned stencil);
+
+
+/***********************************************************************
+ * svga_screen_texture.c: 
+ */
+void svga_mark_surfaces_dirty(struct svga_context *svga);
+
+
+
+
+void svga_init_state_functions( struct svga_context *svga );
+void svga_init_flush_functions( struct svga_context *svga );
+void svga_init_string_functions( struct svga_context *svga );
+void svga_init_blit_functions(struct svga_context *svga);
+
+void svga_init_blend_functions( struct svga_context *svga );
+void svga_init_depth_stencil_functions( struct svga_context *svga );
+void svga_init_misc_functions( struct svga_context *svga );
+void svga_init_rasterizer_functions( struct svga_context *svga );
+void svga_init_sampler_functions( struct svga_context *svga );
+void svga_init_fs_functions( struct svga_context *svga );
+void svga_init_vs_functions( struct svga_context *svga );
+void svga_init_vertex_functions( struct svga_context *svga );
+void svga_init_constbuffer_functions( struct svga_context *svga );
+void svga_init_draw_functions( struct svga_context *svga );
+void svga_init_query_functions( struct svga_context *svga );
+
+void svga_cleanup_vertex_state( struct svga_context *svga );
+void svga_cleanup_tss_binding( struct svga_context *svga );
+void svga_cleanup_framebuffer( struct svga_context *svga );
+
+void svga_context_flush( struct svga_context *svga,
+                         struct pipe_fence_handle **pfence );
+
+void svga_hwtnl_flush_retry( struct svga_context *svga );
+
+
+/***********************************************************************
+ * Inline conversion functions.  These are better-typed than the
+ * macros used previously:
+ */
+static INLINE struct svga_context *
+svga_context( struct pipe_context *pipe )
+{
+   return (struct svga_context *)pipe;
+}
+
+
+
+#endif
diff --git a/src/gallium/drivers/svga/svga_debug.h b/src/gallium/drivers/svga/svga_debug.h
new file mode 100644 (file)
index 0000000..3a3fcd8
--- /dev/null
@@ -0,0 +1,75 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#ifndef SVGA_DEBUG_H
+#define SVGA_DEBUG_H
+
+#include "pipe/p_compiler.h"
+#include "util/u_debug.h"
+
+#define DEBUG_DMA      0x1
+#define DEBUG_TGSI     0x4
+#define DEBUG_PIPE     0x8
+#define DEBUG_STATE    0x10
+#define DEBUG_SCREEN   0x20
+#define DEBUG_TEX      0x40
+#define DEBUG_SWTNL    0x80
+#define DEBUG_CONSTS   0x100
+#define DEBUG_VIEWPORT 0x200
+#define DEBUG_VIEWS    0x400
+#define DEBUG_PERF     0x800    /* print something when we hit any slow path operation */
+#define DEBUG_FLUSH    0x1000   /* flush after every draw */
+#define DEBUG_SYNC     0x2000   /* sync after every flush */
+#define DEBUG_QUERY    0x4000
+#define DEBUG_CACHE    0x8000
+
+#ifdef DEBUG
+extern int SVGA_DEBUG;
+#define DBSTR(x) x
+#else
+#define SVGA_DEBUG 0
+#define DBSTR(x) ""
+#endif
+
+static INLINE void
+SVGA_DBG( unsigned flag, const char *fmt, ... )
+{
+#ifdef DEBUG 
+    if (SVGA_DEBUG & flag)
+    {
+        va_list args;
+
+        va_start( args, fmt );
+        debug_vprintf( fmt, args );
+        va_end( args );
+    }
+#else
+    (void)flag;
+    (void)fmt;
+#endif
+}
+
+
+#endif
diff --git a/src/gallium/drivers/svga/svga_draw.c b/src/gallium/drivers/svga/svga_draw.c
new file mode 100644 (file)
index 0000000..ca73cf9
--- /dev/null
@@ -0,0 +1,378 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_inlines.h"
+#include "pipe/p_defines.h"
+#include "util/u_memory.h"
+#include "util/u_math.h"
+
+#include "svga_context.h"
+#include "svga_draw.h"
+#include "svga_draw_private.h"
+#include "svga_debug.h"
+#include "svga_screen.h"
+#include "svga_screen_buffer.h"
+#include "svga_screen_texture.h"
+#include "svga_winsys.h"
+#include "svga_cmd.h"
+
+
+struct svga_hwtnl *svga_hwtnl_create( struct svga_context *svga,
+                                      struct u_upload_mgr *upload_ib,
+                                      struct svga_winsys_context *swc )
+{
+   struct svga_hwtnl *hwtnl = CALLOC_STRUCT(svga_hwtnl);
+   if (hwtnl == NULL)
+      goto fail;
+
+   hwtnl->svga = svga;
+   hwtnl->upload_ib = upload_ib;
+   
+   hwtnl->cmd.swc = swc;
+
+   return hwtnl;
+
+fail:
+   return NULL;
+}
+
+void svga_hwtnl_destroy( struct svga_hwtnl *hwtnl )
+{
+   int i, j;
+
+   for (i = 0; i < PIPE_PRIM_MAX; i++) {
+      for (j = 0; j < IDX_CACHE_MAX; j++) {
+         pipe_buffer_reference( &hwtnl->index_cache[i][j].buffer,
+                                NULL );
+      }
+   }
+
+   for (i = 0; i < hwtnl->cmd.vdecl_count; i++)
+      pipe_buffer_reference(&hwtnl->cmd.vdecl_vb[i], NULL);
+
+   for (i = 0; i < hwtnl->cmd.prim_count; i++)
+      pipe_buffer_reference(&hwtnl->cmd.prim_ib[i], NULL);
+      
+
+   FREE(hwtnl);
+}
+
+
+void svga_hwtnl_set_flatshade( struct svga_hwtnl *hwtnl,
+                               boolean flatshade,
+                               boolean flatshade_first )
+{
+   hwtnl->hw_pv = PV_FIRST;
+   hwtnl->api_pv = (flatshade && !flatshade_first) ? PV_LAST : PV_FIRST;
+}                               
+
+void svga_hwtnl_set_unfilled( struct svga_hwtnl *hwtnl,
+                              unsigned mode )
+{
+   hwtnl->api_fillmode = mode;
+}                               
+
+void svga_hwtnl_reset_vdecl( struct svga_hwtnl *hwtnl,
+                             unsigned count )
+{
+   unsigned i;
+
+   assert(hwtnl->cmd.prim_count == 0);
+
+   for (i = count; i < hwtnl->cmd.vdecl_count; i++) {
+      pipe_buffer_reference(&hwtnl->cmd.vdecl_vb[i],
+                            NULL);
+   }
+
+   hwtnl->cmd.vdecl_count = count;
+}
+
+
+void svga_hwtnl_vdecl( struct svga_hwtnl *hwtnl,
+                          unsigned i,
+                          const SVGA3dVertexDecl *decl,
+                          struct pipe_buffer *vb)
+{
+   assert(hwtnl->cmd.prim_count == 0);
+
+   assert( i < hwtnl->cmd.vdecl_count );
+
+   hwtnl->cmd.vdecl[i] = *decl;
+
+   pipe_buffer_reference(&hwtnl->cmd.vdecl_vb[i],
+                         vb);   
+}
+
+
+
+enum pipe_error
+svga_hwtnl_flush( struct svga_hwtnl *hwtnl )
+{
+   struct svga_winsys_context *swc = hwtnl->cmd.swc;
+   struct svga_context *svga = hwtnl->svga;
+   enum pipe_error ret;
+
+   if (hwtnl->cmd.prim_count) {
+      struct svga_winsys_surface *vb_handle[SVGA3D_INPUTREG_MAX];
+      struct svga_winsys_surface *ib_handle[QSZ];
+      struct svga_winsys_surface *handle;
+      SVGA3dVertexDecl *vdecl;
+      SVGA3dPrimitiveRange *prim;
+      unsigned i;
+
+      for (i = 0; i < hwtnl->cmd.vdecl_count; i++) {
+         handle = svga_buffer_handle(svga, hwtnl->cmd.vdecl_vb[i]);
+         if (handle == NULL)
+            return PIPE_ERROR_OUT_OF_MEMORY;
+
+         vb_handle[i] = handle;
+      }
+
+      for (i = 0; i < hwtnl->cmd.prim_count; i++) {
+         if (hwtnl->cmd.prim_ib[i]) {
+            handle = svga_buffer_handle(svga, hwtnl->cmd.prim_ib[i]);
+            if (handle == NULL)
+               return PIPE_ERROR_OUT_OF_MEMORY;
+         }
+         else
+            handle = NULL;
+
+         ib_handle[i] = handle;
+      }
+
+      SVGA_DBG(DEBUG_DMA, "draw to sid %p, %d prims\n",
+               svga->curr.framebuffer.cbufs[0] ?
+               svga_surface(svga->curr.framebuffer.cbufs[0])->handle : NULL,
+               hwtnl->cmd.prim_count);
+
+      ret = SVGA3D_BeginDrawPrimitives(swc, 
+                                       &vdecl, 
+                                       hwtnl->cmd.vdecl_count, 
+                                       &prim, 
+                                       hwtnl->cmd.prim_count);
+      if (ret != PIPE_OK) 
+         return ret;
+
+      
+      memcpy( vdecl,
+              hwtnl->cmd.vdecl,
+              hwtnl->cmd.vdecl_count * sizeof hwtnl->cmd.vdecl[0]);
+
+      for (i = 0; i < hwtnl->cmd.vdecl_count; i++) {
+         /* Given rangeHint is considered to be relative to indexBias, and 
+          * indexBias varies per primitive, we cannot accurately supply an 
+          * rangeHint when emitting more than one primitive per draw command.
+          */
+         if (hwtnl->cmd.prim_count == 1) {
+            vdecl[i].rangeHint.first = hwtnl->cmd.min_index[0];
+            vdecl[i].rangeHint.last = hwtnl->cmd.max_index[0] + 1;
+         }
+         else {
+            vdecl[i].rangeHint.first = 0;
+            vdecl[i].rangeHint.last = 0;
+         }
+
+         swc->surface_relocation(swc,
+                                 &vdecl[i].array.surfaceId,
+                                 vb_handle[i],
+                                 PIPE_BUFFER_USAGE_GPU_READ);
+      }
+
+      memcpy( prim,
+              hwtnl->cmd.prim,
+              hwtnl->cmd.prim_count * sizeof hwtnl->cmd.prim[0]);
+
+      for (i = 0; i < hwtnl->cmd.prim_count; i++) {
+         swc->surface_relocation(swc,
+                                 &prim[i].indexArray.surfaceId,
+                                 ib_handle[i],
+                                 PIPE_BUFFER_USAGE_GPU_READ);
+         pipe_buffer_reference(&hwtnl->cmd.prim_ib[i], NULL);
+      }
+      
+      SVGA_FIFOCommitAll( swc );
+      hwtnl->cmd.prim_count = 0;
+   }
+
+   return PIPE_OK;
+}
+
+
+
+
+
+/***********************************************************************
+ * Internal functions:
+ */
+
+enum pipe_error svga_hwtnl_prim( struct svga_hwtnl *hwtnl,
+                                 const SVGA3dPrimitiveRange *range,
+                                 unsigned min_index,
+                                 unsigned max_index,
+                                 struct pipe_buffer *ib )
+{
+   int ret = PIPE_OK;
+
+#ifdef DEBUG
+   {
+      unsigned i;
+      for (i = 0; i < hwtnl->cmd.vdecl_count; i++) {
+         struct pipe_buffer *vb = hwtnl->cmd.vdecl_vb[i];
+         unsigned size = vb ? vb->size : 0;
+         unsigned offset = hwtnl->cmd.vdecl[i].array.offset;
+         unsigned stride = hwtnl->cmd.vdecl[i].array.stride;
+         unsigned index_bias = range->indexBias;
+         unsigned width;
+
+         assert(vb);
+         assert(size);
+         assert(offset < size);
+         assert(index_bias >= 0);
+         assert(min_index <= max_index);
+         assert(offset + index_bias*stride < size);
+         assert(offset + (index_bias + min_index)*stride < size);
+
+         switch (hwtnl->cmd.vdecl[i].identity.type) {
+         case SVGA3D_DECLTYPE_FLOAT1:
+            width = 4;
+            break;
+         case SVGA3D_DECLTYPE_FLOAT2:
+            width = 4*2;
+            break;
+         case SVGA3D_DECLTYPE_FLOAT3:
+            width = 4*3;
+            break;
+         case SVGA3D_DECLTYPE_FLOAT4:
+            width = 4*4;
+            break;
+         case SVGA3D_DECLTYPE_D3DCOLOR:
+            width = 4;
+            break;
+         case SVGA3D_DECLTYPE_UBYTE4:
+            width = 1*4;
+            break;
+         case SVGA3D_DECLTYPE_SHORT2:
+            width = 2*2;
+            break;
+         case SVGA3D_DECLTYPE_SHORT4:
+            width = 2*4;
+            break;
+         case SVGA3D_DECLTYPE_UBYTE4N:
+            width = 1*4;
+            break;
+         case SVGA3D_DECLTYPE_SHORT2N:
+            width = 2*2;
+            break;
+         case SVGA3D_DECLTYPE_SHORT4N:
+            width = 2*4;
+            break;
+         case SVGA3D_DECLTYPE_USHORT2N:
+            width = 2*2;
+            break;
+         case SVGA3D_DECLTYPE_USHORT4N:
+            width = 2*4;
+            break;
+         case SVGA3D_DECLTYPE_UDEC3:
+            width = 4;
+            break;
+         case SVGA3D_DECLTYPE_DEC3N:
+            width = 4;
+            break;
+         case SVGA3D_DECLTYPE_FLOAT16_2:
+            width = 2*2;
+            break;
+         case SVGA3D_DECLTYPE_FLOAT16_4:
+            width = 2*4;
+            break;
+         default:
+            assert(0);
+            width = 0;
+            break;
+         }
+
+         assert(!stride || width <= stride);
+         assert(offset + (index_bias + max_index)*stride + width <= size);
+      }
+
+      assert(range->indexWidth == range->indexArray.stride);
+
+      if(ib) {
+         unsigned size = ib->size;
+         unsigned offset = range->indexArray.offset;
+         unsigned stride = range->indexArray.stride;
+         unsigned count;
+
+         assert(size);
+         assert(offset < size);
+         assert(stride);
+
+         switch (range->primType) {
+         case SVGA3D_PRIMITIVE_POINTLIST:
+            count = range->primitiveCount;
+            break;
+         case SVGA3D_PRIMITIVE_LINELIST:
+            count = range->primitiveCount * 2;
+            break;
+         case SVGA3D_PRIMITIVE_LINESTRIP:
+            count = range->primitiveCount + 1;
+            break;
+         case SVGA3D_PRIMITIVE_TRIANGLELIST:
+            count = range->primitiveCount * 3;
+            break;
+         case SVGA3D_PRIMITIVE_TRIANGLESTRIP:
+            count = range->primitiveCount + 2;
+            break;
+         case SVGA3D_PRIMITIVE_TRIANGLEFAN:
+            count = range->primitiveCount + 2;
+            break;
+         default:
+            assert(0);
+            count = 0;
+            break;
+         }
+
+         assert(offset + count*stride <= size);
+      }
+   }
+#endif
+
+   if (hwtnl->cmd.prim_count+1 >= QSZ) {
+      ret = svga_hwtnl_flush( hwtnl );
+      if (ret != PIPE_OK)
+         return ret;
+   }
+   
+   /* min/max indices are relative to bias */
+   hwtnl->cmd.min_index[hwtnl->cmd.prim_count] = min_index;
+   hwtnl->cmd.max_index[hwtnl->cmd.prim_count] = max_index;
+
+   hwtnl->cmd.prim[hwtnl->cmd.prim_count] = *range;
+
+   pipe_buffer_reference(&hwtnl->cmd.prim_ib[hwtnl->cmd.prim_count], ib);
+   hwtnl->cmd.prim_count++;
+
+   return ret;
+}
diff --git a/src/gallium/drivers/svga/svga_draw.h b/src/gallium/drivers/svga/svga_draw.h
new file mode 100644 (file)
index 0000000..14553b1
--- /dev/null
@@ -0,0 +1,83 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#ifndef SVGA_DRAW_H
+#define SVGA_DRAW_H
+
+#include "pipe/p_compiler.h"
+
+#include "svga_hw_reg.h"
+
+struct svga_hwtnl;
+struct svga_winsys_context;
+struct svga_screen;
+struct svga_context;
+struct pipe_buffer;
+struct u_upload_mgr;
+
+struct svga_hwtnl *svga_hwtnl_create( struct svga_context *svga,
+                                      struct u_upload_mgr *upload_ib,
+                                      struct svga_winsys_context *swc );
+
+void svga_hwtnl_destroy( struct svga_hwtnl *hwtnl );
+
+void svga_hwtnl_set_flatshade( struct svga_hwtnl *hwtnl,
+                               boolean flatshade,
+                               boolean flatshade_first );
+
+void svga_hwtnl_set_unfilled( struct svga_hwtnl *hwtnl,
+                              unsigned mode );
+
+void svga_hwtnl_vdecl( struct svga_hwtnl *hwtnl,
+                       unsigned i,
+                       const SVGA3dVertexDecl *decl,
+                       struct pipe_buffer *vb);
+
+void svga_hwtnl_reset_vdecl( struct svga_hwtnl *hwtnl,
+                             unsigned count );
+
+
+enum pipe_error 
+svga_hwtnl_draw_arrays( struct svga_hwtnl *hwtnl,
+                        unsigned prim, 
+                        unsigned start, 
+                        unsigned count);
+
+enum pipe_error
+svga_hwtnl_draw_range_elements( struct svga_hwtnl *hwtnl,
+                                struct pipe_buffer *indexBuffer,
+                                unsigned index_size,
+                                unsigned min_index,
+                                unsigned max_index,
+                                unsigned prim, 
+                                unsigned start, 
+                                unsigned count,
+                                unsigned bias );
+
+enum pipe_error
+svga_hwtnl_flush( struct svga_hwtnl *hwtnl );
+
+
+#endif /* SVGA_DRAW_H_ */
diff --git a/src/gallium/drivers/svga/svga_draw_arrays.c b/src/gallium/drivers/svga/svga_draw_arrays.c
new file mode 100644 (file)
index 0000000..75492df
--- /dev/null
@@ -0,0 +1,297 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "svga_cmd.h"
+
+#include "pipe/p_inlines.h"
+#include "util/u_prim.h"
+#include "indices/u_indices.h"
+
+#include "svga_hw_reg.h"
+#include "svga_draw.h"
+#include "svga_draw_private.h"
+#include "svga_context.h"
+
+
+#define DBG 0
+
+
+
+
+static enum pipe_error generate_indices( struct svga_hwtnl *hwtnl,
+                                         unsigned nr,
+                                         unsigned index_size,
+                                         u_generate_func generate,
+                                         struct pipe_buffer **out_buf )
+{
+   struct pipe_screen *screen = hwtnl->svga->pipe.screen;
+   unsigned size = index_size * nr;
+   struct pipe_buffer *dst = NULL;
+   void *dst_map = NULL;
+
+   dst = screen->buffer_create( screen, 32, 
+                                PIPE_BUFFER_USAGE_INDEX |
+                                PIPE_BUFFER_USAGE_CPU_WRITE |
+                                PIPE_BUFFER_USAGE_GPU_READ, 
+                                size );
+   if (dst == NULL)
+      goto fail;
+
+   dst_map = pipe_buffer_map( screen, dst, PIPE_BUFFER_USAGE_CPU_WRITE );
+   if (dst_map == NULL)
+      goto fail;
+
+   generate( nr,
+             dst_map );
+
+   pipe_buffer_unmap( screen, dst );
+
+   *out_buf = dst;
+   return PIPE_OK;
+
+fail:
+   if (dst_map)
+      screen->buffer_unmap( screen, dst );
+
+   if (dst)
+      screen->buffer_destroy( dst );
+
+   return PIPE_ERROR_OUT_OF_MEMORY;
+}
+
+static boolean compare( unsigned cached_nr,
+                        unsigned nr,
+                        unsigned type )
+{
+   if (type == U_GENERATE_REUSABLE)
+      return cached_nr >= nr;
+   else
+      return cached_nr == nr;
+}
+
+static enum pipe_error retrieve_or_generate_indices( struct svga_hwtnl *hwtnl,
+                                                     unsigned prim,
+                                                     unsigned gen_type,
+                                                     unsigned gen_nr,
+                                                     unsigned gen_size,
+                                                     u_generate_func generate,
+                                                     struct pipe_buffer **out_buf )
+{
+   enum pipe_error ret = PIPE_OK;
+   int i;
+
+   for (i = 0; i < IDX_CACHE_MAX; i++) {
+      if (hwtnl->index_cache[prim][i].buffer != NULL &&
+          hwtnl->index_cache[prim][i].generate == generate)
+      {
+         if (compare(hwtnl->index_cache[prim][i].gen_nr, gen_nr, gen_type))
+         {
+            pipe_buffer_reference( out_buf,
+                                   hwtnl->index_cache[prim][i].buffer );
+
+            if (DBG) 
+               debug_printf("%s retrieve %d/%d\n", __FUNCTION__, i, gen_nr);
+
+            return PIPE_OK;
+         }
+         else if (gen_type == U_GENERATE_REUSABLE) 
+         {
+            pipe_buffer_reference( &hwtnl->index_cache[prim][i].buffer,
+                                   NULL );
+
+            if (DBG) 
+               debug_printf("%s discard %d/%d\n", __FUNCTION__, 
+                            i, hwtnl->index_cache[prim][i].gen_nr);
+
+            break;
+         }
+      }
+   }
+
+   if (i == IDX_CACHE_MAX)
+   {
+      unsigned smallest = 0;
+      unsigned smallest_size = ~0;
+      
+      for (i = 0; i < IDX_CACHE_MAX && smallest_size; i++) {
+         if (hwtnl->index_cache[prim][i].buffer == NULL)
+         {
+            smallest = i;
+            smallest_size = 0;
+         }
+         else if (hwtnl->index_cache[prim][i].gen_nr < smallest)
+         {
+            smallest = i;
+            smallest_size = hwtnl->index_cache[prim][i].gen_nr;
+         }
+      }
+
+      assert (smallest != IDX_CACHE_MAX);
+
+      pipe_buffer_reference( &hwtnl->index_cache[prim][smallest].buffer,
+                             NULL );
+
+      if (DBG)
+         debug_printf("%s discard smallest %d/%d\n", __FUNCTION__, 
+                      smallest, smallest_size);
+      
+      i = smallest;
+   }
+      
+      
+   ret = generate_indices( hwtnl, 
+                           gen_nr,
+                           gen_size,
+                           generate,
+                           out_buf );
+   if (ret != PIPE_OK)
+      return ret;
+
+
+   hwtnl->index_cache[prim][i].generate = generate;
+   hwtnl->index_cache[prim][i].gen_nr = gen_nr;
+   pipe_buffer_reference( &hwtnl->index_cache[prim][i].buffer,
+                          *out_buf );
+
+   if (DBG)
+      debug_printf("%s cache %d/%d\n", __FUNCTION__, 
+                   i, hwtnl->index_cache[prim][i].gen_nr);
+
+   return PIPE_OK;
+}
+
+
+
+static enum pipe_error
+simple_draw_arrays( struct svga_hwtnl *hwtnl,
+                    unsigned prim, unsigned start, unsigned count )
+{
+   SVGA3dPrimitiveRange range;
+   unsigned hw_prim;
+   unsigned hw_count;
+
+   hw_prim = svga_translate_prim(prim, count, &hw_count);
+   if (hw_count == 0)
+      return PIPE_ERROR_BAD_INPUT;
+      
+   range.primType = hw_prim;
+   range.primitiveCount = hw_count;
+   range.indexArray.surfaceId = SVGA3D_INVALID_ID;
+   range.indexArray.offset = 0;
+   range.indexArray.stride = 0;
+   range.indexWidth = 0;
+   range.indexBias = start;
+
+   /* Min/max index should be calculated prior to applying bias, so we
+    * end up with min_index = 0, max_index = count - 1 and everybody
+    * looking at those numbers knows to adjust them by
+    * range.indexBias.
+    */
+   return svga_hwtnl_prim( hwtnl, &range, 0, count - 1, NULL );
+}
+
+
+
+
+
+
+
+
+
+
+enum pipe_error 
+svga_hwtnl_draw_arrays( struct svga_hwtnl *hwtnl,
+                        unsigned prim, 
+                        unsigned start, 
+                        unsigned count)
+{
+   unsigned gen_prim, gen_size, gen_nr, gen_type;
+   u_generate_func gen_func;
+   enum pipe_error ret = PIPE_OK;
+
+   if (hwtnl->api_fillmode != PIPE_POLYGON_MODE_FILL && 
+       prim >= PIPE_PRIM_TRIANGLES) 
+   {
+      gen_type = u_unfilled_generator( prim,
+                                       start,
+                                       count,
+                                       hwtnl->api_fillmode,
+                                       &gen_prim,
+                                       &gen_size,
+                                       &gen_nr,
+                                       &gen_func );
+   }
+   else {
+      gen_type = u_index_generator( svga_hw_prims,
+                                    prim,
+                                    start,
+                                    count,
+                                    hwtnl->api_pv,
+                                    hwtnl->hw_pv,
+                                    &gen_prim,
+                                    &gen_size,
+                                    &gen_nr,
+                                    &gen_func );
+   }
+
+   if (gen_type == U_GENERATE_LINEAR) {
+      return simple_draw_arrays( hwtnl, gen_prim, start, count );
+   }
+   else {
+      struct pipe_buffer *gen_buf = NULL;
+
+      /* Need to draw as indexed primitive. 
+       * Potentially need to run the gen func to build an index buffer.
+       */
+      ret = retrieve_or_generate_indices( hwtnl,
+                                          prim,
+                                          gen_type,
+                                          gen_nr,
+                                          gen_size,
+                                          gen_func,
+                                          &gen_buf );
+      if (ret)
+         goto done;
+
+      ret = svga_hwtnl_simple_draw_range_elements( hwtnl,
+                                                   gen_buf,
+                                                   gen_size,
+                                                   0,
+                                                   count - 1,
+                                                   gen_prim,
+                                                   0,
+                                                   gen_nr,
+                                                   start );
+      if (ret)
+         goto done;
+
+   done:
+      if (gen_buf)
+         pipe_buffer_reference( &gen_buf, NULL );
+
+      return ret;
+   }
+}
+
diff --git a/src/gallium/drivers/svga/svga_draw_elements.c b/src/gallium/drivers/svga/svga_draw_elements.c
new file mode 100644 (file)
index 0000000..167d817
--- /dev/null
@@ -0,0 +1,255 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "pipe/p_inlines.h"
+#include "util/u_prim.h"
+#include "util/u_upload_mgr.h"
+#include "indices/u_indices.h"
+
+#include "svga_cmd.h"
+#include "svga_draw.h"
+#include "svga_draw_private.h"
+#include "svga_screen_buffer.h"
+#include "svga_winsys.h"
+#include "svga_context.h"
+
+#include "svga_hw_reg.h"
+
+
+static enum pipe_error
+translate_indices( struct svga_hwtnl *hwtnl,
+                   struct pipe_buffer *src,
+                   unsigned offset,
+                   unsigned nr,
+                   unsigned index_size,
+                   u_translate_func translate,
+                   struct pipe_buffer **out_buf )
+{
+   struct pipe_screen *screen = hwtnl->svga->pipe.screen;
+   unsigned size = index_size * nr;
+   const void *src_map = NULL;
+   struct pipe_buffer *dst = NULL;
+   void *dst_map = NULL;
+
+   dst = screen->buffer_create( screen, 32, 
+                                PIPE_BUFFER_USAGE_INDEX |
+                                PIPE_BUFFER_USAGE_CPU_WRITE |
+                                PIPE_BUFFER_USAGE_GPU_READ, 
+                                size );
+   if (dst == NULL)
+      goto fail;
+
+   src_map = pipe_buffer_map( screen, src, PIPE_BUFFER_USAGE_CPU_READ );
+   if (src_map == NULL)
+      goto fail;
+
+   dst_map = pipe_buffer_map( screen, dst, PIPE_BUFFER_USAGE_CPU_WRITE );
+   if (dst_map == NULL)
+      goto fail;
+
+   translate( (const char *)src_map + offset,
+              nr,
+              dst_map );
+
+   pipe_buffer_unmap( screen, src );
+   pipe_buffer_unmap( screen, dst );
+
+   *out_buf = dst;
+   return PIPE_OK;
+
+fail:
+   if (src_map)
+      screen->buffer_unmap( screen, src );
+
+   if (dst_map)
+      screen->buffer_unmap( screen, dst );
+
+   if (dst)
+      screen->buffer_destroy( dst );
+
+   return PIPE_ERROR_OUT_OF_MEMORY;
+}
+
+
+
+
+
+enum pipe_error
+svga_hwtnl_simple_draw_range_elements( struct svga_hwtnl *hwtnl,
+                                       struct pipe_buffer *index_buffer,
+                                       unsigned index_size,
+                                       unsigned min_index,
+                                       unsigned max_index,
+                                       unsigned prim, 
+                                       unsigned start,
+                                       unsigned count,
+                                       unsigned bias )
+{
+   struct pipe_buffer *upload_buffer = NULL;
+   SVGA3dPrimitiveRange range;
+   unsigned hw_prim;
+   unsigned hw_count;
+   unsigned index_offset = start * index_size;
+   int ret = PIPE_OK;
+
+   hw_prim = svga_translate_prim(prim, count, &hw_count);
+   if (hw_count == 0)
+      goto done;
+
+   if (index_buffer && 
+       svga_buffer_is_user_buffer(index_buffer)) 
+   {
+      assert( index_buffer->size >= index_offset + count * index_size );
+
+      ret = u_upload_buffer( hwtnl->upload_ib,
+                             index_offset,
+                             count * index_size,
+                             index_buffer,
+                             &index_offset,
+                             &upload_buffer );
+      if (ret)
+         goto done;
+
+      /* Don't need to worry about refcounting index_buffer as this is
+       * just a stack variable without a counted reference of its own.
+       * The caller holds the reference.
+       */
+      index_buffer = upload_buffer;
+   }
+
+   range.primType = hw_prim;
+   range.primitiveCount = hw_count;
+   range.indexArray.offset = index_offset;
+   range.indexArray.stride = index_size;
+   range.indexWidth = index_size;
+   range.indexBias = bias;
+      
+   ret = svga_hwtnl_prim( hwtnl, &range, min_index, max_index, index_buffer );
+   if (ret)
+      goto done;
+
+done:
+   if (upload_buffer)
+      pipe_buffer_reference( &upload_buffer, NULL );
+
+   return ret;
+}
+
+
+
+
+enum pipe_error
+svga_hwtnl_draw_range_elements( struct svga_hwtnl *hwtnl,
+                                struct pipe_buffer *index_buffer,
+                                unsigned index_size,
+                                unsigned min_index,
+                                unsigned max_index,
+                                unsigned prim, unsigned start, unsigned count,
+                                unsigned bias)
+{
+   unsigned gen_prim, gen_size, gen_nr, gen_type;
+   u_translate_func gen_func;
+   enum pipe_error ret = PIPE_OK;
+
+   if (hwtnl->api_fillmode != PIPE_POLYGON_MODE_FILL && 
+       prim >= PIPE_PRIM_TRIANGLES) 
+   {
+      gen_type = u_unfilled_translator( prim,
+                                        index_size,
+                                        count,
+                                        hwtnl->api_fillmode,
+                                        &gen_prim,
+                                        &gen_size,
+                                        &gen_nr,
+                                        &gen_func );
+   }
+   else
+   {
+      gen_type = u_index_translator( svga_hw_prims,
+                                     prim,
+                                     index_size,
+                                     count,
+                                     hwtnl->api_pv,
+                                     hwtnl->hw_pv,
+                                     &gen_prim,
+                                     &gen_size,
+                                     &gen_nr,
+                                     &gen_func );
+   }
+
+   
+   if (gen_type == U_TRANSLATE_MEMCPY) {
+      /* No need for translation, just pass through to hardware: 
+       */
+      return svga_hwtnl_simple_draw_range_elements( hwtnl, index_buffer,
+                                                    index_size,
+                                                    min_index,
+                                                    max_index,
+                                                    gen_prim, start, count, bias );
+   }
+   else {
+      struct pipe_buffer *gen_buf = NULL;
+
+      /* Need to allocate a new index buffer and run the translate
+       * func to populate it.  Could potentially cache this translated
+       * index buffer with the original to avoid future
+       * re-translations.  Not much point if we're just accelerating
+       * GL though, as index buffers are typically used only once
+       * there.
+       */
+      ret = translate_indices( hwtnl,
+                               index_buffer,
+                               start * index_size,
+                               gen_nr,
+                               gen_size,
+                               gen_func,
+                               &gen_buf );
+      if (ret)
+         goto done;
+
+      ret = svga_hwtnl_simple_draw_range_elements( hwtnl,
+                                                   gen_buf,
+                                                   gen_size,
+                                                   min_index,
+                                                   max_index,
+                                                   gen_prim,
+                                                   0,
+                                                   gen_nr,
+                                                   bias );
+      if (ret)
+         goto done;
+
+   done:
+      if (gen_buf)
+         pipe_buffer_reference( &gen_buf, NULL );
+
+      return ret;
+   }
+}
+
+
+
+
+
diff --git a/src/gallium/drivers/svga/svga_draw_private.h b/src/gallium/drivers/svga/svga_draw_private.h
new file mode 100644 (file)
index 0000000..9aa40e1
--- /dev/null
@@ -0,0 +1,158 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#ifndef SVGA_DRAW_H_
+#define SVGA_DRAW_H_
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_defines.h"
+#include "indices/u_indices.h"
+#include "svga_hw_reg.h"
+#include "svga3d_shaderdefs.h"
+
+struct svga_context;
+struct u_upload_mgr;
+
+/* Should include polygon?
+ */
+static const unsigned svga_hw_prims = 
+   ((1 << PIPE_PRIM_POINTS) |
+    (1 << PIPE_PRIM_LINES) |
+    (1 << PIPE_PRIM_LINE_STRIP) |
+    (1 << PIPE_PRIM_TRIANGLES) |
+    (1 << PIPE_PRIM_TRIANGLE_STRIP) |
+    (1 << PIPE_PRIM_TRIANGLE_FAN));
+
+
+static INLINE unsigned svga_translate_prim(unsigned mode, 
+                                           unsigned count,
+                                           unsigned *out_count)
+{
+   switch (mode) {
+   case PIPE_PRIM_POINTS:
+      *out_count = count;
+      return SVGA3D_PRIMITIVE_POINTLIST;
+
+   case PIPE_PRIM_LINES:
+      *out_count = count / 2;
+      return SVGA3D_PRIMITIVE_LINELIST; 
+
+   case PIPE_PRIM_LINE_STRIP:
+      *out_count = count - 1;
+      return SVGA3D_PRIMITIVE_LINESTRIP; 
+
+   case PIPE_PRIM_TRIANGLES:
+      *out_count = count / 3;
+      return SVGA3D_PRIMITIVE_TRIANGLELIST; 
+
+   case PIPE_PRIM_TRIANGLE_STRIP:
+      *out_count = count - 2;
+      return SVGA3D_PRIMITIVE_TRIANGLESTRIP; 
+
+   case PIPE_PRIM_TRIANGLE_FAN:
+      *out_count = count - 2;
+      return SVGA3D_PRIMITIVE_TRIANGLEFAN; 
+
+   default:
+      assert(0);
+      *out_count = 0;
+      return 0;
+   }
+}
+
+
+struct index_cache {
+   u_generate_func generate;
+   unsigned gen_nr;
+
+   /* If non-null, this buffer is filled by calling 
+    *   generate(nr, map(buffer))
+    */
+   struct pipe_buffer *buffer;
+};
+
+#define QSZ 32
+
+struct draw_cmd {
+   struct svga_winsys_context *swc;
+
+   SVGA3dVertexDecl vdecl[SVGA3D_INPUTREG_MAX];
+   struct pipe_buffer *vdecl_vb[SVGA3D_INPUTREG_MAX];
+   unsigned vdecl_count;
+
+   SVGA3dPrimitiveRange prim[QSZ];
+   struct pipe_buffer *prim_ib[QSZ];
+   unsigned prim_count;
+   unsigned min_index[QSZ];
+   unsigned max_index[QSZ];
+};
+
+#define IDX_CACHE_MAX  8
+
+struct svga_hwtnl {
+   struct svga_context *svga;
+   struct u_upload_mgr *upload_ib;
+   
+   /* Flatshade information:
+    */
+   unsigned api_pv;
+   unsigned hw_pv;
+   unsigned api_fillmode;
+
+   /* Cache the results of running a particular generate func on each
+    * primitive type.
+    */
+   struct index_cache index_cache[PIPE_PRIM_MAX][IDX_CACHE_MAX];
+
+   /* Try to build the maximal draw command packet before emitting:
+    */
+   struct draw_cmd cmd;
+};
+
+
+
+/***********************************************************************
+ * Internal functions
+ */
+enum pipe_error 
+svga_hwtnl_prim( struct svga_hwtnl *hwtnl,
+                 const SVGA3dPrimitiveRange *range,
+                 unsigned min_index,
+                 unsigned max_index,
+                 struct pipe_buffer *ib );
+
+enum pipe_error
+svga_hwtnl_simple_draw_range_elements( struct svga_hwtnl *hwtnl,
+                                       struct pipe_buffer *indexBuffer,
+                                       unsigned index_size,
+                                       unsigned min_index,
+                                       unsigned max_index,
+                                       unsigned prim, 
+                                       unsigned start,
+                                       unsigned count,
+                                       unsigned bias );
+
+
+#endif
diff --git a/src/gallium/drivers/svga/svga_hw_reg.h b/src/gallium/drivers/svga/svga_hw_reg.h
new file mode 100644 (file)
index 0000000..183f4b9
--- /dev/null
@@ -0,0 +1,42 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#ifndef SVGA_HW_REG_H
+#define SVGA_HW_REG_H
+
+#include "pipe/p_compiler.h"
+
+#if defined(PIPE_CC_GCC)
+#ifndef HAVE_STDINT_H
+#define HAVE_STDINT_H
+#endif
+#endif
+
+#include "svga_types.h"
+
+#include "svga3d_reg.h"
+
+
+#endif
diff --git a/src/gallium/drivers/svga/svga_pipe_blend.c b/src/gallium/drivers/svga/svga_pipe_blend.c
new file mode 100644 (file)
index 0000000..855d228
--- /dev/null
@@ -0,0 +1,246 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "pipe/p_inlines.h"
+#include "pipe/p_defines.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
+#include "svga_context.h"
+#include "svga_state.h"
+
+#include "svga_hw_reg.h"
+
+
+static INLINE unsigned
+svga_translate_blend_factor(unsigned factor)
+{
+   switch (factor) {
+   case PIPE_BLENDFACTOR_ZERO:            return SVGA3D_BLENDOP_ZERO;
+   case PIPE_BLENDFACTOR_SRC_ALPHA:       return SVGA3D_BLENDOP_SRCALPHA;
+   case PIPE_BLENDFACTOR_ONE:             return SVGA3D_BLENDOP_ONE;
+   case PIPE_BLENDFACTOR_SRC_COLOR:       return SVGA3D_BLENDOP_SRCCOLOR;
+   case PIPE_BLENDFACTOR_INV_SRC_COLOR:   return SVGA3D_BLENDOP_INVSRCCOLOR;
+   case PIPE_BLENDFACTOR_DST_COLOR:       return SVGA3D_BLENDOP_DESTCOLOR;
+   case PIPE_BLENDFACTOR_INV_DST_COLOR:   return SVGA3D_BLENDOP_INVDESTCOLOR;
+   case PIPE_BLENDFACTOR_INV_SRC_ALPHA:   return SVGA3D_BLENDOP_INVSRCALPHA;
+   case PIPE_BLENDFACTOR_DST_ALPHA:       return SVGA3D_BLENDOP_DESTALPHA;
+   case PIPE_BLENDFACTOR_INV_DST_ALPHA:   return SVGA3D_BLENDOP_INVDESTALPHA;
+   case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE: return SVGA3D_BLENDOP_SRCALPHASAT;
+   case PIPE_BLENDFACTOR_CONST_COLOR:     return SVGA3D_BLENDOP_BLENDFACTOR;
+   case PIPE_BLENDFACTOR_INV_CONST_COLOR: return SVGA3D_BLENDOP_INVBLENDFACTOR;
+   case PIPE_BLENDFACTOR_CONST_ALPHA:     return SVGA3D_BLENDOP_BLENDFACTOR; /* ? */
+   case PIPE_BLENDFACTOR_INV_CONST_ALPHA: return SVGA3D_BLENDOP_INVBLENDFACTOR; /* ? */
+   default:
+      assert(0);
+      return SVGA3D_BLENDOP_ZERO;
+   }
+}
+
+static INLINE unsigned
+svga_translate_blend_func(unsigned mode)
+{
+   switch (mode) {
+   case PIPE_BLEND_ADD:              return SVGA3D_BLENDEQ_ADD;
+   case PIPE_BLEND_SUBTRACT:         return SVGA3D_BLENDEQ_SUBTRACT;
+   case PIPE_BLEND_REVERSE_SUBTRACT: return SVGA3D_BLENDEQ_REVSUBTRACT;
+   case PIPE_BLEND_MIN:              return SVGA3D_BLENDEQ_MINIMUM;
+   case PIPE_BLEND_MAX:              return SVGA3D_BLENDEQ_MAXIMUM;
+   default:
+      assert(0);
+      return SVGA3D_BLENDEQ_ADD;
+   }
+}
+
+
+static void *
+svga_create_blend_state(struct pipe_context *pipe,
+                        const struct pipe_blend_state *templ)
+{
+   struct svga_blend_state *blend = CALLOC_STRUCT( svga_blend_state );
+   unsigned i;
+
+   /* Fill in the per-rendertarget blend state.  We currently only
+    * have one rendertarget.
+    */
+   for (i = 0; i < 1; i++) {
+      /* No way to set this in SVGA3D, and no way to correctly implement it on
+       * top of D3D9 API.  Instead we try to simulate with various blend modes.
+       */
+      if (templ->logicop_enable) {
+         switch (templ->logicop_func) {
+         case PIPE_LOGICOP_XOR:
+            blend->need_white_fragments = TRUE;
+            blend->rt[i].blend_enable = TRUE;
+            blend->rt[i].srcblend       = SVGA3D_BLENDOP_ONE;
+            blend->rt[i].dstblend       = SVGA3D_BLENDOP_ONE;
+            blend->rt[i].blendeq        = SVGA3D_BLENDEQ_SUBTRACT;
+            break;
+         case PIPE_LOGICOP_CLEAR:
+            blend->rt[i].blend_enable = TRUE;
+            blend->rt[i].srcblend       = SVGA3D_BLENDOP_ZERO;
+            blend->rt[i].dstblend       = SVGA3D_BLENDOP_ZERO;
+            blend->rt[i].blendeq        = SVGA3D_BLENDEQ_MINIMUM;
+            break;
+         case PIPE_LOGICOP_COPY:
+            blend->rt[i].blend_enable = FALSE;
+            break;
+         case PIPE_LOGICOP_COPY_INVERTED:
+            blend->rt[i].blend_enable   = TRUE;
+            blend->rt[i].srcblend       = SVGA3D_BLENDOP_INVSRCCOLOR;
+            blend->rt[i].dstblend       = SVGA3D_BLENDOP_ZERO;
+            blend->rt[i].blendeq        = SVGA3D_BLENDEQ_ADD;
+            break;
+         case PIPE_LOGICOP_NOOP:
+            blend->rt[i].blend_enable   = TRUE;
+            blend->rt[i].srcblend       = SVGA3D_BLENDOP_ZERO;
+            blend->rt[i].dstblend       = SVGA3D_BLENDOP_DESTCOLOR;
+            blend->rt[i].blendeq        = SVGA3D_BLENDEQ_ADD;
+            break;
+         case PIPE_LOGICOP_SET:
+            blend->rt[i].blend_enable = TRUE;
+            blend->rt[i].srcblend       = SVGA3D_BLENDOP_ONE;
+            blend->rt[i].dstblend       = SVGA3D_BLENDOP_ONE;
+            blend->rt[i].blendeq        = SVGA3D_BLENDEQ_MAXIMUM;
+            break;
+         case PIPE_LOGICOP_INVERT:
+            blend->rt[i].blend_enable = TRUE;
+            blend->rt[i].srcblend       = SVGA3D_BLENDOP_INVSRCCOLOR;
+            blend->rt[i].dstblend       = SVGA3D_BLENDOP_ZERO;
+            blend->rt[i].blendeq        = SVGA3D_BLENDEQ_ADD;
+            break;
+         case PIPE_LOGICOP_AND:
+            /* Approximate with minimum - works for the 0 & anything case: */
+            blend->rt[i].blend_enable = TRUE;
+            blend->rt[i].srcblend       = SVGA3D_BLENDOP_SRCCOLOR;
+            blend->rt[i].dstblend       = SVGA3D_BLENDOP_DESTCOLOR;
+            blend->rt[i].blendeq        = SVGA3D_BLENDEQ_MINIMUM;
+            break;
+         case PIPE_LOGICOP_AND_REVERSE:
+            blend->rt[i].blend_enable = TRUE;
+            blend->rt[i].srcblend       = SVGA3D_BLENDOP_SRCCOLOR;
+            blend->rt[i].dstblend       = SVGA3D_BLENDOP_INVDESTCOLOR;
+            blend->rt[i].blendeq        = SVGA3D_BLENDEQ_MINIMUM;
+            break;
+         case PIPE_LOGICOP_AND_INVERTED:
+            blend->rt[i].blend_enable = TRUE;
+            blend->rt[i].srcblend       = SVGA3D_BLENDOP_INVSRCCOLOR;
+            blend->rt[i].dstblend       = SVGA3D_BLENDOP_DESTCOLOR;
+            blend->rt[i].blendeq        = SVGA3D_BLENDEQ_MINIMUM;
+            break;
+         case PIPE_LOGICOP_OR:
+            /* Approximate with maximum - works for the 1 | anything case: */
+            blend->rt[i].blend_enable = TRUE;
+            blend->rt[i].srcblend       = SVGA3D_BLENDOP_SRCCOLOR;
+            blend->rt[i].dstblend       = SVGA3D_BLENDOP_DESTCOLOR;
+            blend->rt[i].blendeq        = SVGA3D_BLENDEQ_MAXIMUM;
+            break;
+         case PIPE_LOGICOP_OR_REVERSE:
+            blend->rt[i].blend_enable = TRUE;
+            blend->rt[i].srcblend       = SVGA3D_BLENDOP_SRCCOLOR;
+            blend->rt[i].dstblend       = SVGA3D_BLENDOP_INVDESTCOLOR;
+            blend->rt[i].blendeq        = SVGA3D_BLENDEQ_MAXIMUM;
+            break;
+         case PIPE_LOGICOP_OR_INVERTED:
+            blend->rt[i].blend_enable = TRUE;
+            blend->rt[i].srcblend       = SVGA3D_BLENDOP_INVSRCCOLOR;
+            blend->rt[i].dstblend       = SVGA3D_BLENDOP_DESTCOLOR;
+            blend->rt[i].blendeq        = SVGA3D_BLENDEQ_MAXIMUM;
+            break;
+         case PIPE_LOGICOP_NAND:
+         case PIPE_LOGICOP_NOR:
+         case PIPE_LOGICOP_EQUIV:
+            /* Fill these in with plausible values */
+            blend->rt[i].blend_enable = FALSE;
+            break;
+         default:
+            assert(0);
+            break;
+         }
+      }
+      else {
+         blend->rt[i].blend_enable   = templ->blend_enable;
+
+         if (templ->blend_enable) {
+            blend->rt[i].srcblend       = svga_translate_blend_factor(templ->rgb_src_factor);
+            blend->rt[i].dstblend       = svga_translate_blend_factor(templ->rgb_dst_factor);
+            blend->rt[i].blendeq        = svga_translate_blend_func(templ->rgb_func);
+            blend->rt[i].srcblend_alpha = svga_translate_blend_factor(templ->alpha_src_factor);
+            blend->rt[i].dstblend_alpha = svga_translate_blend_factor(templ->alpha_dst_factor);
+            blend->rt[i].blendeq_alpha  = svga_translate_blend_func(templ->alpha_func);
+
+            if (blend->rt[i].srcblend_alpha != blend->rt[i].srcblend ||
+                blend->rt[i].dstblend_alpha != blend->rt[i].dstblend ||
+                blend->rt[i].blendeq_alpha  != blend->rt[i].blendeq)
+            {
+               blend->rt[i].separate_alpha_blend_enable = TRUE;
+            }
+         }
+      }
+
+      blend->rt[i].writemask = templ->colormask;
+   }
+
+   return blend;
+}
+
+static void svga_bind_blend_state(struct pipe_context *pipe,
+                                  void *blend)
+{
+   struct svga_context *svga = svga_context(pipe);
+
+   svga->curr.blend = (struct svga_blend_state*)blend;
+   svga->dirty |= SVGA_NEW_BLEND;
+}
+
+
+static void svga_delete_blend_state(struct pipe_context *pipe, void *blend)
+{
+   FREE(blend);
+}
+
+static void svga_set_blend_color( struct pipe_context *pipe,
+                                  const struct pipe_blend_color *blend_color )
+{
+   struct svga_context *svga = svga_context(pipe);
+
+   svga->curr.blend_color = *blend_color;
+
+   svga->dirty |= SVGA_NEW_BLEND;
+}
+
+
+void svga_init_blend_functions( struct svga_context *svga )
+{
+   svga->pipe.create_blend_state = svga_create_blend_state;
+   svga->pipe.bind_blend_state = svga_bind_blend_state;
+   svga->pipe.delete_blend_state = svga_delete_blend_state;
+
+   svga->pipe.set_blend_color = svga_set_blend_color;
+}
+
+
+
diff --git a/src/gallium/drivers/svga/svga_pipe_blit.c b/src/gallium/drivers/svga/svga_pipe_blit.c
new file mode 100644 (file)
index 0000000..4f575b0
--- /dev/null
@@ -0,0 +1,92 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "svga_screen_texture.h"
+#include "svga_context.h"
+#include "svga_debug.h"
+#include "svga_cmd.h"
+
+#define FILE_DEBUG_FLAG DEBUG_BLIT
+
+
+static void svga_surface_copy(struct pipe_context *pipe,
+                              struct pipe_surface *dest,
+                              unsigned destx, unsigned desty,
+                              struct pipe_surface *src,
+                              unsigned srcx, unsigned srcy,
+                              unsigned width, unsigned height)
+{
+   struct svga_context *svga = svga_context(pipe);
+   SVGA3dCopyBox *box;
+   enum pipe_error ret;
+
+   svga_hwtnl_flush_retry( svga );
+
+   SVGA_DBG(DEBUG_DMA, "blit to sid %p (%d,%d), from sid %p (%d,%d) sz %dx%d\n",
+            svga_surface(dest)->handle,
+            destx, desty,
+            svga_surface(src)->handle,
+            srcx, srcy,
+            width, height);
+
+   ret = SVGA3D_BeginSurfaceCopy(svga->swc,
+                                 src,
+                                 dest,
+                                 &box,
+                                 1);
+   if(ret != PIPE_OK) {
+
+      svga_context_flush(svga, NULL);
+
+      ret = SVGA3D_BeginSurfaceCopy(svga->swc,
+                                    src,
+                                    dest,
+                                    &box,
+                                    1);
+      assert(ret == PIPE_OK);
+   }
+
+   box->x = destx;
+   box->y = desty;
+   box->z = 0;
+   box->w = width;
+   box->h = height;
+   box->d = 1;
+   box->srcx = srcx;
+   box->srcy = srcy;
+   box->srcz = 0;
+
+   SVGA_FIFOCommitAll(svga->swc);
+
+   svga_surface(dest)->dirty = TRUE;
+   svga_propagate_surface(pipe, dest);
+}
+
+
+void
+svga_init_blit_functions(struct svga_context *svga)
+{
+   svga->pipe.surface_copy = svga_surface_copy;
+}
diff --git a/src/gallium/drivers/svga/svga_pipe_clear.c b/src/gallium/drivers/svga/svga_pipe_clear.c
new file mode 100644 (file)
index 0000000..409b3b4
--- /dev/null
@@ -0,0 +1,125 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "svga_cmd.h"
+#include "svga_debug.h"
+
+#include "pipe/p_defines.h"
+#include "util/u_pack_color.h"
+
+#include "svga_context.h"
+#include "svga_state.h"
+#include "svga_screen_texture.h"
+
+
+static enum pipe_error
+try_clear(struct svga_context *svga, 
+          unsigned buffers,
+          const float *rgba,
+          double depth,
+          unsigned stencil)
+{
+   int ret = PIPE_OK;
+   SVGA3dRect rect = { 0, 0, 0, 0 };
+   boolean restore_viewport = FALSE;
+   SVGA3dClearFlag flags = 0;
+   struct pipe_framebuffer_state *fb = &svga->curr.framebuffer;
+   union util_color uc;
+
+   ret = svga_update_state(svga, SVGA_STATE_HW_CLEAR);
+   if (ret)
+      return ret;
+
+   if ((buffers & PIPE_CLEAR_COLOR) && fb->cbufs[0]) {
+      flags |= SVGA3D_CLEAR_COLOR;
+      util_pack_color(rgba, PIPE_FORMAT_A8R8G8B8_UNORM, &uc);
+
+      rect.w = fb->cbufs[0]->width;
+      rect.h = fb->cbufs[0]->height;
+   }
+
+   if ((buffers & PIPE_CLEAR_DEPTHSTENCIL) && fb->zsbuf) {
+      flags |= SVGA3D_CLEAR_DEPTH;
+
+      if (svga->curr.framebuffer.zsbuf->format == PIPE_FORMAT_Z24S8_UNORM)
+         flags |= SVGA3D_CLEAR_STENCIL;
+
+      rect.w = MAX2(rect.w, fb->zsbuf->width);
+      rect.h = MAX2(rect.h, fb->zsbuf->height);
+   }
+
+   if (memcmp(&rect, &svga->state.hw_clear.viewport, sizeof(rect)) != 0) {
+      restore_viewport = TRUE;
+      ret = SVGA3D_SetViewport(svga->swc, &rect);
+      if (ret)
+         return ret;
+   }
+
+   ret = SVGA3D_ClearRect(svga->swc, flags, uc.ui, depth, stencil,
+                          rect.x, rect.y, rect.w, rect.h);
+   if (ret != PIPE_OK)
+      return ret;
+
+   if (restore_viewport) {
+      memcpy(&rect, &svga->state.hw_clear.viewport, sizeof rect);
+      ret = SVGA3D_SetViewport(svga->swc, &rect);
+   }
+   
+   return ret;
+}
+
+/**
+ * Clear the given surface to the specified value.
+ * No masking, no scissor (clear entire buffer).
+ */
+void
+svga_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba,
+          double depth, unsigned stencil)
+{
+   struct svga_context *svga = svga_context( pipe );
+   int ret;
+   
+   if (buffers & PIPE_CLEAR_COLOR)
+      SVGA_DBG(DEBUG_DMA, "clear sid %p\n",
+               svga_surface(svga->curr.framebuffer.cbufs[0])->handle);
+
+   ret = try_clear( svga, buffers, rgba, depth, stencil );
+
+   if (ret == PIPE_ERROR_OUT_OF_MEMORY) {
+      /* Flush command buffer and retry:
+       */
+      svga_context_flush( svga, NULL );
+
+      ret = try_clear( svga, buffers, rgba, depth, stencil );
+   }
+
+   /*
+    * Mark target surfaces as dirty
+    * TODO Mark only cleared surfaces.
+    */
+   svga_mark_surfaces_dirty(svga);
+
+   assert (ret == PIPE_OK);
+}
diff --git a/src/gallium/drivers/svga/svga_pipe_constants.c b/src/gallium/drivers/svga/svga_pipe_constants.c
new file mode 100644 (file)
index 0000000..10e7a12
--- /dev/null
@@ -0,0 +1,74 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "pipe/p_inlines.h"
+#include "pipe/p_defines.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+#include "tgsi/tgsi_parse.h"
+
+#include "svga_context.h"
+#include "svga_state.h"
+#include "svga_hw_reg.h"
+#include "svga_cmd.h"
+
+/***********************************************************************
+ * Constant buffers 
+ */
+
+struct svga_constbuf 
+{
+   unsigned type;
+   float (*data)[4];
+   unsigned count;
+};
+
+
+
+static void svga_set_constant_buffer(struct pipe_context *pipe,
+                                     uint shader, uint index,
+                                     const struct pipe_constant_buffer *buf)
+{
+   struct svga_context *svga = svga_context(pipe);
+
+   assert(shader < PIPE_SHADER_TYPES);
+   assert(index == 0);
+
+   pipe_buffer_reference( &svga->curr.cb[shader],
+                          buf->buffer );
+
+   if (shader == PIPE_SHADER_FRAGMENT)
+      svga->dirty |= SVGA_NEW_FS_CONST_BUFFER;
+   else
+      svga->dirty |= SVGA_NEW_VS_CONST_BUFFER;
+}
+
+
+
+void svga_init_constbuffer_functions( struct svga_context *svga )
+{
+   svga->pipe.set_constant_buffer = svga_set_constant_buffer;
+}
+
diff --git a/src/gallium/drivers/svga/svga_pipe_depthstencil.c b/src/gallium/drivers/svga/svga_pipe_depthstencil.c
new file mode 100644 (file)
index 0000000..df636c0
--- /dev/null
@@ -0,0 +1,153 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "pipe/p_inlines.h"
+#include "pipe/p_defines.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
+#include "svga_context.h"
+#include "svga_state.h"
+#include "svga_hw_reg.h"
+
+
+static INLINE unsigned
+svga_translate_compare_func(unsigned func)
+{
+   switch (func) {
+   case PIPE_FUNC_NEVER:     return SVGA3D_CMP_NEVER;
+   case PIPE_FUNC_LESS:      return SVGA3D_CMP_LESS;
+   case PIPE_FUNC_LEQUAL:    return SVGA3D_CMP_LESSEQUAL;
+   case PIPE_FUNC_GREATER:   return SVGA3D_CMP_GREATER;
+   case PIPE_FUNC_GEQUAL:    return SVGA3D_CMP_GREATEREQUAL;
+   case PIPE_FUNC_NOTEQUAL:  return SVGA3D_CMP_NOTEQUAL;
+   case PIPE_FUNC_EQUAL:     return SVGA3D_CMP_EQUAL;
+   case PIPE_FUNC_ALWAYS:    return SVGA3D_CMP_ALWAYS;
+   default:
+      assert(0);
+      return SVGA3D_CMP_ALWAYS;
+   }
+}
+
+static INLINE unsigned
+svga_translate_stencil_op(unsigned op)
+{
+   switch (op) {
+   case PIPE_STENCIL_OP_KEEP:      return SVGA3D_STENCILOP_KEEP;
+   case PIPE_STENCIL_OP_ZERO:      return SVGA3D_STENCILOP_ZERO;
+   case PIPE_STENCIL_OP_REPLACE:   return SVGA3D_STENCILOP_REPLACE;
+   case PIPE_STENCIL_OP_INCR:      return SVGA3D_STENCILOP_INCR;
+   case PIPE_STENCIL_OP_DECR:      return SVGA3D_STENCILOP_DECR;
+   case PIPE_STENCIL_OP_INCR_WRAP: return SVGA3D_STENCILOP_INCRSAT; /* incorrect? */
+   case PIPE_STENCIL_OP_DECR_WRAP: return SVGA3D_STENCILOP_DECRSAT; /* incorrect? */
+   case PIPE_STENCIL_OP_INVERT:    return SVGA3D_STENCILOP_INVERT;
+   default:
+      assert(0);
+      return SVGA3D_STENCILOP_KEEP;
+   }
+}
+
+
+static void *
+svga_create_depth_stencil_state(struct pipe_context *pipe,
+                               const struct pipe_depth_stencil_alpha_state *templ)
+{
+   struct svga_depth_stencil_state *ds = CALLOC_STRUCT( svga_depth_stencil_state );
+
+   /* Don't try to figure out CW/CCW correspondence with
+    * stencil[0]/[1] at this point.  Presumably this can change as
+    * back/front face are modified.
+    */
+   ds->stencil[0].enabled = templ->stencil[0].enabled;
+   if (ds->stencil[0].enabled) {
+      ds->stencil[0].func  = svga_translate_compare_func(templ->stencil[0].func);
+      ds->stencil[0].fail  = svga_translate_stencil_op(templ->stencil[0].fail_op);
+      ds->stencil[0].zfail = svga_translate_stencil_op(templ->stencil[0].zfail_op);
+      ds->stencil[0].pass  = svga_translate_stencil_op(templ->stencil[0].zpass_op);
+      
+      /* SVGA3D has one ref/mask/writemask triple shared between front &
+       * back face stencil.  We really need two:
+       */
+      ds->stencil_ref       = templ->stencil[0].ref_value & 0xff;
+      ds->stencil_mask      = templ->stencil[0].valuemask & 0xff;
+      ds->stencil_writemask = templ->stencil[0].writemask & 0xff;
+   }
+
+
+   ds->stencil[1].enabled = templ->stencil[1].enabled;
+   if (templ->stencil[1].enabled) {
+      ds->stencil[1].func   = svga_translate_compare_func(templ->stencil[1].func);
+      ds->stencil[1].fail   = svga_translate_stencil_op(templ->stencil[1].fail_op);
+      ds->stencil[1].zfail  = svga_translate_stencil_op(templ->stencil[1].zfail_op);
+      ds->stencil[1].pass   = svga_translate_stencil_op(templ->stencil[1].zpass_op);
+
+      ds->stencil_ref       = templ->stencil[1].ref_value & 0xff;
+      ds->stencil_mask      = templ->stencil[1].valuemask & 0xff;
+      ds->stencil_writemask = templ->stencil[1].writemask & 0xff;
+   }
+
+
+   ds->zenable = templ->depth.enabled;
+   if (ds->zenable) {
+      ds->zfunc = svga_translate_compare_func(templ->depth.func);
+      ds->zwriteenable = templ->depth.writemask;
+   }
+
+   ds->alphatestenable = templ->alpha.enabled;
+   if (ds->alphatestenable) {
+      ds->alphafunc = svga_translate_compare_func(templ->alpha.func);
+      ds->alpharef = templ->alpha.ref_value;
+   }
+
+   return ds;
+}
+
+static void svga_bind_depth_stencil_state(struct pipe_context *pipe,
+                                          void *depth_stencil)
+{
+   struct svga_context *svga = svga_context(pipe);
+
+   svga->curr.depth = (const struct svga_depth_stencil_state *)depth_stencil;
+   svga->dirty |= SVGA_NEW_DEPTH_STENCIL;
+}
+
+static void svga_delete_depth_stencil_state(struct pipe_context *pipe,
+                                            void *depth_stencil)
+{
+   FREE(depth_stencil);
+}
+
+
+
+void svga_init_depth_stencil_functions( struct svga_context *svga )
+{
+   svga->pipe.create_depth_stencil_alpha_state = svga_create_depth_stencil_state;
+   svga->pipe.bind_depth_stencil_alpha_state = svga_bind_depth_stencil_state;
+   svga->pipe.delete_depth_stencil_alpha_state = svga_delete_depth_stencil_state;
+}
+
+
+
+
diff --git a/src/gallium/drivers/svga/svga_pipe_draw.c b/src/gallium/drivers/svga/svga_pipe_draw.c
new file mode 100644 (file)
index 0000000..0f24ef4
--- /dev/null
@@ -0,0 +1,259 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "svga_cmd.h"
+
+#include "pipe/p_inlines.h"
+#include "util/u_prim.h"
+#include "util/u_time.h"
+#include "indices/u_indices.h"
+
+#include "svga_hw_reg.h"
+#include "svga_context.h"
+#include "svga_screen.h"
+#include "svga_winsys.h"
+#include "svga_draw.h"
+#include "svga_state.h"
+#include "svga_swtnl.h"
+#include "svga_debug.h"
+
+
+
+static enum pipe_error
+retry_draw_range_elements( struct svga_context *svga,
+                           struct pipe_buffer *index_buffer,
+                           unsigned index_size,
+                           unsigned min_index,
+                           unsigned max_index,
+                           unsigned prim, 
+                           unsigned start, 
+                           unsigned count,
+                           boolean do_retry )
+{
+   enum pipe_error ret = 0;
+
+   svga_hwtnl_set_unfilled( svga->hwtnl,
+                            svga->curr.rast->hw_unfilled );
+
+   svga_hwtnl_set_flatshade( svga->hwtnl,
+                             svga->curr.rast->templ.flatshade,
+                             svga->curr.rast->templ.flatshade_first );
+
+
+   ret = svga_update_state( svga, SVGA_STATE_HW_DRAW );
+   if (ret)
+      goto retry;
+
+   ret = svga_hwtnl_draw_range_elements( svga->hwtnl,
+                                         index_buffer, index_size,
+                                         min_index, max_index,
+                                         prim, start, count, 0 );
+   if (ret)
+      goto retry;
+
+   if (svga->curr.any_user_vertex_buffers) {
+      ret = svga_hwtnl_flush( svga->hwtnl );
+      if (ret)
+         goto retry;
+   }
+
+   return PIPE_OK;
+
+retry:
+   svga_context_flush( svga, NULL );
+
+   if (do_retry)
+   {
+      return retry_draw_range_elements( svga,
+                                        index_buffer, index_size,
+                                        min_index, max_index,
+                                        prim, start, count,
+                                        FALSE );
+   }
+
+   return ret;
+}
+
+
+static enum pipe_error
+retry_draw_arrays( struct svga_context *svga,
+                   unsigned prim, 
+                   unsigned start, 
+                   unsigned count,
+                   boolean do_retry )
+{
+   enum pipe_error ret;
+
+   svga_hwtnl_set_unfilled( svga->hwtnl,
+                            svga->curr.rast->hw_unfilled );
+
+   svga_hwtnl_set_flatshade( svga->hwtnl,
+                             svga->curr.rast->templ.flatshade,
+                             svga->curr.rast->templ.flatshade_first );
+
+   ret = svga_update_state( svga, SVGA_STATE_HW_DRAW );
+   if (ret)
+      goto retry;
+
+   ret = svga_hwtnl_draw_arrays( svga->hwtnl, prim,
+                                 start, count );
+   if (ret)
+      goto retry;
+
+   if (svga->curr.any_user_vertex_buffers) {
+      ret = svga_hwtnl_flush( svga->hwtnl );
+      if (ret)
+         goto retry;
+   }
+
+   return 0;
+
+retry:
+   if (ret == PIPE_ERROR_OUT_OF_MEMORY && do_retry) 
+   {
+      svga_context_flush( svga, NULL );
+
+      return retry_draw_arrays( svga,
+                                prim,
+                                start,
+                                count,
+                                FALSE );
+   }
+
+   return ret;
+}
+
+
+
+
+
+static void
+svga_draw_range_elements( struct pipe_context *pipe,
+                          struct pipe_buffer *index_buffer,
+                          unsigned index_size,
+                          unsigned min_index,
+                          unsigned max_index,
+                          unsigned prim, unsigned start, unsigned count)
+{
+   struct svga_context *svga = svga_context( pipe );
+   unsigned reduced_prim = u_reduced_prim(prim);
+   enum pipe_error ret = 0;
+
+   if (!u_trim_pipe_prim( prim, &count ))
+      return;
+
+   /*
+    * Mark currently bound target surfaces as dirty
+    * doesn't really matter if it is done before drawing.
+    *
+    * TODO If we ever normaly return something other then
+    * true we should not mark it as dirty then.
+    */
+   svga_mark_surfaces_dirty(svga_context(pipe));
+
+   if (svga->curr.reduced_prim != reduced_prim) {
+      svga->curr.reduced_prim = reduced_prim;
+      svga->dirty |= SVGA_NEW_REDUCED_PRIMITIVE;
+   }
+   
+   svga_update_state_retry( svga, SVGA_STATE_NEED_SWTNL );
+
+#ifdef DEBUG
+   if (svga->curr.vs->base.id == svga->debug.disable_shader ||
+       svga->curr.fs->base.id == svga->debug.disable_shader)
+      return;
+#endif
+
+   if (svga->state.sw.need_swtnl)
+   {
+      ret = svga_swtnl_draw_range_elements( svga, 
+                                            index_buffer, 
+                                            index_size,
+                                            min_index, max_index,
+                                            prim,
+                                            start, count );
+   }
+   else {
+      if (index_buffer) {
+         ret = retry_draw_range_elements( svga,
+                                          index_buffer,
+                                          index_size,
+                                          min_index,
+                                          max_index,
+                                          prim,
+                                          start,
+                                          count,
+                                          TRUE );
+      }
+      else {
+         ret = retry_draw_arrays( svga, 
+                                  prim, 
+                                  start, 
+                                  count,
+                                  TRUE );
+      }
+   }
+
+   if (SVGA_DEBUG & DEBUG_FLUSH) {
+      static unsigned id;
+      debug_printf("%s %d\n", __FUNCTION__, id++);
+      if (id > 1300)
+         util_time_sleep( 2000 );
+
+      svga_hwtnl_flush_retry( svga );
+      svga_context_flush(svga, NULL);
+   }
+}
+
+
+static void
+svga_draw_elements( struct pipe_context *pipe,
+                    struct pipe_buffer *index_buffer,
+                    unsigned index_size,
+                    unsigned prim, unsigned start, unsigned count)
+{
+   svga_draw_range_elements( pipe, index_buffer,
+                             index_size,
+                             0, 0xffffffff,
+                             prim, start, count );
+}
+
+static void
+svga_draw_arrays( struct pipe_context *pipe,
+                  unsigned prim, unsigned start, unsigned count)
+{
+   svga_draw_range_elements(pipe, NULL, 0, 
+                            start, start + count - 1, 
+                            prim, 
+                            start, count);
+}
+
+
+void svga_init_draw_functions( struct svga_context *svga )
+{
+   svga->pipe.draw_arrays = svga_draw_arrays;
+   svga->pipe.draw_elements = svga_draw_elements;
+   svga->pipe.draw_range_elements = svga_draw_range_elements;
+}
diff --git a/src/gallium/drivers/svga/svga_pipe_flush.c b/src/gallium/drivers/svga/svga_pipe_flush.c
new file mode 100644 (file)
index 0000000..0becb07
--- /dev/null
@@ -0,0 +1,71 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "pipe/p_defines.h"
+#include "svga_screen.h"
+#include "svga_screen_texture.h"
+#include "svga_context.h"
+#include "svga_winsys.h"
+#include "svga_draw.h"
+#include "svga_debug.h"
+
+#include "svga_hw_reg.h"
+
+
+
+
+static void svga_flush( struct pipe_context *pipe,
+                        unsigned flags,
+                        struct pipe_fence_handle **fence )
+{
+   struct svga_context *svga = svga_context(pipe);
+   int i;
+
+   /* Emit buffered drawing commands.
+    */
+   svga_hwtnl_flush_retry( svga );
+
+   /* Emit back-copy from render target view to texture.
+    */
+   for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
+      if (svga->curr.framebuffer.cbufs[i])
+         svga_propagate_surface(pipe, svga->curr.framebuffer.cbufs[i]);
+   }
+   if (svga->curr.framebuffer.zsbuf)
+      svga_propagate_surface(pipe, svga->curr.framebuffer.zsbuf);
+
+   /* Flush command queue.
+    */
+   svga_context_flush(svga, fence);
+
+   SVGA_DBG(DEBUG_DMA|DEBUG_PERF, "%s flags %x fence_ptr %p\n",
+            __FUNCTION__, flags, fence ? *fence : 0x0);
+}
+
+
+void svga_init_flush_functions( struct svga_context *svga )
+{
+   svga->pipe.flush = svga_flush;
+}
diff --git a/src/gallium/drivers/svga/svga_pipe_fs.c b/src/gallium/drivers/svga/svga_pipe_fs.c
new file mode 100644 (file)
index 0000000..5f1213e
--- /dev/null
@@ -0,0 +1,134 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "pipe/p_inlines.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+#include "util/u_bitmask.h"
+#include "tgsi/tgsi_parse.h"
+#include "tgsi/tgsi_text.h"
+
+#include "svga_screen.h"
+#include "svga_context.h"
+#include "svga_state.h"
+#include "svga_tgsi.h"
+#include "svga_hw_reg.h"
+#include "svga_cmd.h"
+#include "svga_draw.h"
+#include "svga_debug.h"
+
+
+/***********************************************************************
+ * Fragment shaders 
+ */
+
+static void *
+svga_create_fs_state(struct pipe_context *pipe,
+                     const struct pipe_shader_state *templ)
+{
+   struct svga_context *svga = svga_context(pipe);
+   struct svga_screen *svgascreen = svga_screen(pipe->screen);
+   struct svga_fragment_shader *fs;
+
+   fs = CALLOC_STRUCT(svga_fragment_shader);
+   if (!fs)
+      return NULL;
+
+   fs->base.tokens = tgsi_dup_tokens(templ->tokens);
+
+   /* Collect basic info that we'll need later:
+    */
+   tgsi_scan_shader(fs->base.tokens, &fs->base.info);
+
+   fs->base.id = svga->debug.shader_id++;
+   fs->base.use_sm30 = svgascreen->use_ps30;
+   
+   if (SVGA_DEBUG & DEBUG_TGSI || 0) {
+      debug_printf("%s id: %u, inputs: %u, outputs: %u\n",
+                   __FUNCTION__, fs->base.id,
+                   fs->base.info.num_inputs, fs->base.info.num_outputs);
+   }
+
+   return fs;
+}
+
+static void
+svga_bind_fs_state(struct pipe_context *pipe, void *shader)
+{
+   struct svga_fragment_shader *fs = (struct svga_fragment_shader *) shader;
+   struct svga_context *svga = svga_context(pipe);
+
+   svga->curr.fs = fs;
+   svga->dirty |= SVGA_NEW_FS;
+}
+
+static
+void svga_delete_fs_state(struct pipe_context *pipe, void *shader)
+{
+   struct svga_context *svga = svga_context(pipe);
+   struct svga_fragment_shader *fs = (struct svga_fragment_shader *) shader;
+   struct svga_shader_result *result, *tmp;
+   enum pipe_error ret;
+
+   svga_hwtnl_flush_retry( svga );
+
+   for (result = fs->base.results; result; result = tmp ) {
+      tmp = result->next;
+
+      ret = SVGA3D_DestroyShader(svga->swc, 
+                                 result->id,
+                                 SVGA3D_SHADERTYPE_PS );
+      if(ret != PIPE_OK) {
+         svga_context_flush(svga, NULL);
+         ret = SVGA3D_DestroyShader(svga->swc, 
+                                    result->id,
+                                    SVGA3D_SHADERTYPE_PS );
+         assert(ret == PIPE_OK);
+      }
+
+      util_bitmask_clear( svga->fs_bm, result->id );
+
+      svga_destroy_shader_result( result );
+
+      /*
+       * Remove stale references to this result to ensure a new result on the
+       * same address will be detected as a change.
+       */
+      if(result == svga->state.hw_draw.fs)
+         svga->state.hw_draw.fs = NULL;
+   }
+
+   FREE((void *)fs->base.tokens);
+   FREE(fs);
+}
+
+
+void svga_init_fs_functions( struct svga_context *svga )
+{
+   svga->pipe.create_fs_state = svga_create_fs_state;
+   svga->pipe.bind_fs_state = svga_bind_fs_state;
+   svga->pipe.delete_fs_state = svga_delete_fs_state;
+}
+
diff --git a/src/gallium/drivers/svga/svga_pipe_misc.c b/src/gallium/drivers/svga/svga_pipe_misc.c
new file mode 100644 (file)
index 0000000..58cb1e6
--- /dev/null
@@ -0,0 +1,187 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "svga_cmd.h"
+
+#include "svga_context.h"
+#include "svga_screen_texture.h"
+#include "svga_state.h"
+#include "svga_winsys.h"
+
+#include "svga_hw_reg.h"
+
+
+
+
+static void svga_set_scissor_state( struct pipe_context *pipe,
+                                 const struct pipe_scissor_state *scissor )
+{
+   struct svga_context *svga = svga_context(pipe);
+
+   memcpy( &svga->curr.scissor, scissor, sizeof(*scissor) );
+   svga->dirty |= SVGA_NEW_SCISSOR;
+}
+
+
+static void svga_set_polygon_stipple( struct pipe_context *pipe,
+                                      const struct pipe_poly_stipple *stipple )
+{
+   /* overridden by the draw module */
+}
+
+
+void svga_cleanup_framebuffer(struct svga_context *svga)
+{
+   struct pipe_framebuffer_state *curr = &svga->curr.framebuffer;
+   struct pipe_framebuffer_state *hw = &svga->state.hw_clear.framebuffer;
+   int i;
+
+   for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
+      pipe_surface_reference(&curr->cbufs[i], NULL);
+      pipe_surface_reference(&hw->cbufs[i], NULL);
+   }
+
+   pipe_surface_reference(&curr->zsbuf, NULL);
+   pipe_surface_reference(&hw->zsbuf, NULL);
+}
+
+
+#define DEPTH_BIAS_SCALE_FACTOR_D16    ((float)(1<<15))
+#define DEPTH_BIAS_SCALE_FACTOR_D24S8  ((float)(1<<23))
+#define DEPTH_BIAS_SCALE_FACTOR_D32    ((float)(1<<31))
+
+
+static void svga_set_framebuffer_state(struct pipe_context *pipe,
+                                      const struct pipe_framebuffer_state *fb)
+{
+   struct svga_context *svga = svga_context(pipe);
+   struct pipe_framebuffer_state *dst = &svga->curr.framebuffer;
+   boolean propagate = FALSE;
+   int i;
+
+   dst->width = fb->width;
+   dst->height = fb->height;
+   dst->nr_cbufs = fb->nr_cbufs;
+
+   /* check if we need to propaget any of the target surfaces */
+   for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
+      if (dst->cbufs[i] && dst->cbufs[i] != fb->cbufs[i])
+         if (svga_surface_needs_propagation(dst->cbufs[i]))
+            propagate = TRUE;
+   }
+
+   if (propagate) {
+      /* make sure that drawing calls comes before propagation calls */
+      svga_hwtnl_flush_retry( svga );
+   
+      for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++)
+         if (dst->cbufs[i] && dst->cbufs[i] != fb->cbufs[i])
+            svga_propagate_surface(pipe, dst->cbufs[i]);
+   }
+
+   /* XXX: Actually the virtual hardware may support rendertargets with
+    * different size, depending on the host API and driver, but since we cannot
+    * know that make no such assumption here. */
+   for(i = 0; i < fb->nr_cbufs; ++i) {
+      if (fb->zsbuf && fb->cbufs[i]) {
+         assert(fb->zsbuf->width == fb->cbufs[i]->width); 
+         assert(fb->zsbuf->height == fb->cbufs[i]->height); 
+      }
+   }
+
+   for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++)
+      pipe_surface_reference(&dst->cbufs[i], fb->cbufs[i]);
+   pipe_surface_reference(&dst->zsbuf, fb->zsbuf);
+
+
+   if (svga->curr.framebuffer.zsbuf)
+   {
+      switch (svga->curr.framebuffer.zsbuf->format) {
+      case PIPE_FORMAT_Z16_UNORM:
+         svga->curr.depthscale = 1.0f / DEPTH_BIAS_SCALE_FACTOR_D16;
+         break;
+      case PIPE_FORMAT_S8Z24_UNORM:
+      case PIPE_FORMAT_X8Z24_UNORM:
+      case PIPE_FORMAT_Z24S8_UNORM:
+      case PIPE_FORMAT_Z24X8_UNORM:
+         svga->curr.depthscale = 1.0f / DEPTH_BIAS_SCALE_FACTOR_D24S8;
+         break;
+      case PIPE_FORMAT_Z32_UNORM:
+         svga->curr.depthscale = 1.0f / DEPTH_BIAS_SCALE_FACTOR_D32;
+         break;
+      case PIPE_FORMAT_Z32_FLOAT:
+         svga->curr.depthscale = 1.0f / ((float)(1<<23));
+         break;
+      default:
+         svga->curr.depthscale = 0.0f;
+         break;
+      }
+   }
+   else {
+      svga->curr.depthscale = 0.0f;
+   }
+
+   svga->dirty |= SVGA_NEW_FRAME_BUFFER;
+}
+
+
+
+static void svga_set_clip_state( struct pipe_context *pipe,
+                                 const struct pipe_clip_state *clip )
+{
+   struct svga_context *svga = svga_context(pipe);
+
+   svga->curr.clip = *clip; /* struct copy */
+
+   svga->dirty |= SVGA_NEW_CLIP;
+}
+
+
+
+/* Called when driver state tracker notices changes to the viewport
+ * matrix:
+ */
+static void svga_set_viewport_state( struct pipe_context *pipe,
+                                    const struct pipe_viewport_state *viewport )
+{
+   struct svga_context *svga = svga_context(pipe);
+
+   svga->curr.viewport = *viewport; /* struct copy */
+
+   svga->dirty |= SVGA_NEW_VIEWPORT;
+}
+
+
+
+void svga_init_misc_functions( struct svga_context *svga )
+{
+   svga->pipe.set_scissor_state = svga_set_scissor_state;
+   svga->pipe.set_polygon_stipple = svga_set_polygon_stipple;
+   svga->pipe.set_framebuffer_state = svga_set_framebuffer_state;
+   svga->pipe.set_clip_state = svga_set_clip_state;
+   svga->pipe.set_viewport_state = svga_set_viewport_state;
+}
+
+
diff --git a/src/gallium/drivers/svga/svga_pipe_query.c b/src/gallium/drivers/svga/svga_pipe_query.c
new file mode 100644 (file)
index 0000000..01336b0
--- /dev/null
@@ -0,0 +1,267 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "pipe/p_state.h"
+#include "pipe/p_context.h"
+#include "util/u_memory.h"
+
+#include "svga_cmd.h"
+#include "svga_context.h"
+#include "svga_screen.h"
+#include "svga_screen_buffer.h"
+#include "svga_winsys.h"
+#include "svga_draw.h"
+#include "svga_debug.h"
+
+
+/* Fixme: want a public base class for all pipe structs, even if there
+ * isn't much in them.
+ */
+struct pipe_query {
+   int dummy;
+};
+
+struct svga_query {
+   struct pipe_query base;
+   SVGA3dQueryType type;
+   struct svga_winsys_buffer *hwbuf;
+   volatile SVGA3dQueryResult *queryResult;
+   struct pipe_fence_handle *fence;
+};
+
+/***********************************************************************
+ * Inline conversion functions.  These are better-typed than the
+ * macros used previously:
+ */
+static INLINE struct svga_query *
+svga_query( struct pipe_query *q )
+{
+   return (struct svga_query *)q;
+}
+
+static boolean svga_get_query_result(struct pipe_context *pipe, 
+                                     struct pipe_query *q,
+                                     boolean wait,
+                                     uint64_t *result);
+
+static struct pipe_query *svga_create_query( struct pipe_context *pipe,
+                                             unsigned query_type )
+{
+   struct svga_screen *svgascreen = svga_screen(pipe->screen);
+   struct svga_winsys_screen *sws = svgascreen->sws;
+   struct svga_query *sq;
+
+   SVGA_DBG(DEBUG_QUERY, "%s\n", __FUNCTION__);
+
+   sq = CALLOC_STRUCT(svga_query);
+   if (!sq)
+      goto no_sq;
+
+   sq->type = SVGA3D_QUERYTYPE_OCCLUSION;
+
+   sq->hwbuf = svga_winsys_buffer_create(svgascreen, 
+                                         1,
+                                         SVGA_BUFFER_USAGE_PINNED,
+                                         sizeof *sq->queryResult);
+   if(!sq->hwbuf)
+      goto no_hwbuf;
+    
+   sq->queryResult = (SVGA3dQueryResult *)sws->buffer_map(sws, 
+                                                          sq->hwbuf, 
+                                                          PIPE_BUFFER_USAGE_CPU_WRITE);
+   if(!sq->queryResult)
+      goto no_query_result;
+
+   sq->queryResult->totalSize = sizeof *sq->queryResult;
+   sq->queryResult->state = SVGA3D_QUERYSTATE_NEW;
+
+   /*
+    * We request the buffer to be pinned and assume it is always mapped.
+    * 
+    * The reason is that we don't want to wait for fences when checking the
+    * query status.
+    */
+   sws->buffer_unmap(sws, sq->hwbuf);
+
+   return &sq->base;
+
+no_query_result:
+   sws->buffer_destroy(sws, sq->hwbuf);
+no_hwbuf:
+   FREE(sq);
+no_sq:
+   return NULL;
+}
+
+static void svga_destroy_query(struct pipe_context *pipe,
+                               struct pipe_query *q)
+{
+   struct svga_screen *svgascreen = svga_screen(pipe->screen);
+   struct svga_winsys_screen *sws = svgascreen->sws;
+   struct svga_query *sq = svga_query( q );
+
+   SVGA_DBG(DEBUG_QUERY, "%s\n", __FUNCTION__);
+   sws->buffer_destroy(sws, sq->hwbuf);
+   sws->fence_reference(sws, &sq->fence, NULL);
+   FREE(sq);
+}
+
+static void svga_begin_query(struct pipe_context *pipe, 
+                             struct pipe_query *q)
+{
+   struct svga_screen *svgascreen = svga_screen(pipe->screen);
+   struct svga_winsys_screen *sws = svgascreen->sws;
+   struct svga_context *svga = svga_context( pipe );
+   struct svga_query *sq = svga_query( q );
+   enum pipe_error ret;
+
+   SVGA_DBG(DEBUG_QUERY, "%s\n", __FUNCTION__);
+   
+   assert(!svga->sq);
+
+   /* Need to flush out buffered drawing commands so that they don't
+    * get counted in the query results.
+    */
+   svga_hwtnl_flush_retry(svga);
+   
+   if(sq->queryResult->state == SVGA3D_QUERYSTATE_PENDING) {
+      /* The application doesn't care for the pending query result. We cannot
+       * let go the existing buffer and just get a new one because its storage
+       * may be reused for other purposes and clobbered by the host when it
+       * determines the query result. So the only option here is to wait for
+       * the existing query's result -- not a big deal, given that no sane
+       * application would do this.
+       */
+      uint64_t result;
+
+      svga_get_query_result(pipe, q, TRUE, &result);
+      
+      assert(sq->queryResult->state != SVGA3D_QUERYSTATE_PENDING);
+   }
+   
+   sq->queryResult->state = SVGA3D_QUERYSTATE_NEW;
+   sws->fence_reference(sws, &sq->fence, NULL);
+
+   ret = SVGA3D_BeginQuery(svga->swc, sq->type);
+   if(ret != PIPE_OK) {
+      svga_context_flush(svga, NULL);
+      ret = SVGA3D_BeginQuery(svga->swc, sq->type);
+      assert(ret == PIPE_OK);
+   }
+
+   svga->sq = sq;
+}
+
+static void svga_end_query(struct pipe_context *pipe, 
+                           struct pipe_query *q)
+{
+   struct svga_context *svga = svga_context( pipe );
+   struct svga_query *sq = svga_query( q );
+   enum pipe_error ret;
+
+   SVGA_DBG(DEBUG_QUERY, "%s\n", __FUNCTION__);
+   assert(svga->sq == sq);
+
+   svga_hwtnl_flush_retry(svga);
+   
+   /* Set to PENDING before sending EndQuery. */
+   sq->queryResult->state = SVGA3D_QUERYSTATE_PENDING;
+
+   ret = SVGA3D_EndQuery( svga->swc, sq->type, sq->hwbuf);
+   if(ret != PIPE_OK) {
+      svga_context_flush(svga, NULL);
+      ret = SVGA3D_EndQuery( svga->swc, sq->type, sq->hwbuf);
+      assert(ret == PIPE_OK);
+   }
+   
+   /* TODO: Delay flushing. We don't really need to flush here, just ensure 
+    * that there is one flush before svga_get_query_result attempts to get the
+    * result */
+   svga_context_flush(svga, NULL);
+
+   svga->sq = NULL;
+}
+
+static boolean svga_get_query_result(struct pipe_context *pipe, 
+                                     struct pipe_query *q,
+                                     boolean wait,
+                                     uint64_t *result)
+{
+   struct svga_context *svga = svga_context( pipe );
+   struct svga_screen *svgascreen = svga_screen( pipe->screen );
+   struct svga_winsys_screen *sws = svgascreen->sws;
+   struct svga_query *sq = svga_query( q );
+   SVGA3dQueryState state;
+   
+   SVGA_DBG(DEBUG_QUERY, "%s wait: %d\n", __FUNCTION__);
+
+   /* The query status won't be updated by the host unless 
+    * SVGA_3D_CMD_WAIT_FOR_QUERY is emitted. Unfortunately this will cause a 
+    * synchronous wait on the host */
+   if(!sq->fence) {
+      enum pipe_error ret;
+
+      ret = SVGA3D_WaitForQuery( svga->swc, sq->type, sq->hwbuf);
+      if(ret != PIPE_OK) {
+         svga_context_flush(svga, NULL);
+         ret = SVGA3D_WaitForQuery( svga->swc, sq->type, sq->hwbuf);
+         assert(ret == PIPE_OK);
+      }
+   
+      svga_context_flush(svga, &sq->fence);
+      
+      assert(sq->fence);
+   }
+
+   state = sq->queryResult->state;
+   if(state == SVGA3D_QUERYSTATE_PENDING) {
+      if(!wait)
+         return FALSE;
+   
+      sws->fence_finish(sws, sq->fence, 0);
+      
+      state = sq->queryResult->state;
+   }
+
+   assert(state == SVGA3D_QUERYSTATE_SUCCEEDED || 
+          state == SVGA3D_QUERYSTATE_FAILED);
+   
+   *result = (uint64_t)sq->queryResult->result32;
+
+   SVGA_DBG(DEBUG_QUERY, "%s result %d\n", __FUNCTION__, (unsigned)*result);
+
+   return TRUE;
+}
+
+
+
+void svga_init_query_functions( struct svga_context *svga )
+{
+   svga->pipe.create_query = svga_create_query;
+   svga->pipe.destroy_query = svga_destroy_query;
+   svga->pipe.begin_query = svga_begin_query;
+   svga->pipe.end_query = svga_end_query;
+   svga->pipe.get_query_result = svga_get_query_result;
+}
diff --git a/src/gallium/drivers/svga/svga_pipe_rasterizer.c b/src/gallium/drivers/svga/svga_pipe_rasterizer.c
new file mode 100644 (file)
index 0000000..b03f8eb
--- /dev/null
@@ -0,0 +1,250 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "draw/draw_context.h"
+#include "pipe/p_inlines.h"
+#include "pipe/p_defines.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
+#include "svga_context.h"
+#include "svga_state.h"
+
+#include "svga_hw_reg.h"
+
+/* Hardware frontwinding is always set up as SVGA3D_FRONTWINDING_CW.
+ */
+static SVGA3dFace svga_translate_cullmode( unsigned mode,
+                                           unsigned front_winding )
+{
+   switch (mode) {
+   case PIPE_WINDING_NONE:
+      return SVGA3D_FACE_NONE;
+   case PIPE_WINDING_CCW:
+      return SVGA3D_FACE_BACK;
+   case PIPE_WINDING_CW:
+      return SVGA3D_FACE_FRONT;
+   case PIPE_WINDING_BOTH:
+      return SVGA3D_FACE_FRONT_BACK;
+   default:
+      assert(0);
+      return SVGA3D_FACE_NONE;
+   }
+}
+
+static SVGA3dShadeMode svga_translate_flatshade( unsigned mode )
+{
+   return mode ? SVGA3D_SHADEMODE_FLAT : SVGA3D_SHADEMODE_SMOOTH;
+}
+
+
+static void *
+svga_create_rasterizer_state(struct pipe_context *pipe,
+                             const struct pipe_rasterizer_state *templ)
+{
+   struct svga_rasterizer_state *rast = CALLOC_STRUCT( svga_rasterizer_state );
+   /* need this for draw module. */
+   rast->templ = *templ;
+
+   /* light_twoside          - XXX: need fragment shader varient */
+   /* poly_smooth            - XXX: no fallback available */
+   /* poly_stipple_enable    - draw module */
+   /* point_sprite           - ? */
+   /* point_size_per_vertex  - ? */
+   /* sprite_coord_mode      - ??? */
+   /* bypass_vs_viewport_and_clip        - handled by viewport setup */
+   /* flatshade_first        - handled by index translation */
+   /* gl_rasterization_rules - XXX - viewport code */
+   /* line_width             - draw module */
+   /* fill_cw, fill_ccw      - draw module or index translation */
+
+   rast->shademode = svga_translate_flatshade( templ->flatshade );
+   rast->cullmode = svga_translate_cullmode( templ->cull_mode, 
+                                             templ->front_winding );
+   rast->scissortestenable = templ->scissor;
+   rast->multisampleantialias = templ->multisample;
+   rast->antialiasedlineenable = templ->line_smooth;
+   rast->lastpixel = templ->line_last_pixel;
+   rast->pointsize = templ->point_size;
+   rast->pointsize_min = templ->point_size_min;
+   rast->pointsize_max = templ->point_size_max;
+   rast->hw_unfilled = PIPE_POLYGON_MODE_FILL;
+
+   /* Use swtnl + decomposition implement these:
+    */
+   if (templ->poly_stipple_enable)
+      rast->need_pipeline |= SVGA_PIPELINE_FLAG_TRIS;
+
+   if (templ->line_width != 1.0 &&
+       templ->line_width != 0.0)
+      rast->need_pipeline |= SVGA_PIPELINE_FLAG_LINES;
+
+   if (templ->line_stipple_enable) {
+      /* LinePattern not implemented on all backends. 
+       */
+      if (0) {
+         SVGA3dLinePattern lp;
+         lp.repeat = templ->line_stipple_factor + 1;
+         lp.pattern = templ->line_stipple_pattern;
+         rast->linepattern = lp.uintValue;
+      }
+      else {
+         rast->need_pipeline |= SVGA_PIPELINE_FLAG_LINES;
+      }
+   } 
+
+   if (templ->point_smooth)
+      rast->need_pipeline |= SVGA_PIPELINE_FLAG_POINTS;
+
+   {
+      boolean offset_cw = templ->offset_cw;
+      boolean offset_ccw = templ->offset_ccw;
+      boolean offset  = 0;
+      int fill_cw = templ->fill_cw;
+      int fill_ccw = templ->fill_ccw;
+      int fill = PIPE_POLYGON_MODE_FILL;
+
+      switch (templ->cull_mode) {
+      case PIPE_WINDING_BOTH:
+         offset = 0;
+         fill = PIPE_POLYGON_MODE_FILL;
+         break;
+
+      case PIPE_WINDING_CW:
+         offset = offset_ccw;
+         fill = fill_ccw;
+         break;
+
+      case PIPE_WINDING_CCW:
+         offset = offset_cw;
+         fill = fill_cw;
+         break;
+
+      case PIPE_WINDING_NONE:
+         if (fill_cw != fill_ccw || offset_cw != offset_ccw) 
+         {
+            /* Always need the draw module to work out different
+             * front/back fill modes:
+             */
+            rast->need_pipeline |= SVGA_PIPELINE_FLAG_TRIS;
+         }
+         else {
+            offset = offset_ccw;
+            fill = fill_ccw;
+         }
+         break;
+
+      default:
+         assert(0);
+         break;
+      }
+
+      /* Unfilled primitive modes aren't implemented on all virtual
+       * hardware.  We can do some unfilled processing with index
+       * translation, but otherwise need the draw module:
+       */
+      if (fill != PIPE_POLYGON_MODE_FILL &&
+          (templ->flatshade ||
+           templ->light_twoside ||
+           offset ||
+           templ->cull_mode != PIPE_WINDING_NONE)) 
+      {
+         fill = PIPE_POLYGON_MODE_FILL;
+         rast->need_pipeline |= SVGA_PIPELINE_FLAG_TRIS;
+      }
+
+      /* If we are decomposing to lines, and lines need the pipeline,
+       * then we also need the pipeline for tris.
+       */
+      if (fill == PIPE_POLYGON_MODE_LINE &&
+          (rast->need_pipeline & SVGA_PIPELINE_FLAG_LINES))
+      {
+         fill = PIPE_POLYGON_MODE_FILL;
+         rast->need_pipeline |= SVGA_PIPELINE_FLAG_TRIS;
+      }
+
+      /* Similarly for points:
+       */
+      if (fill == PIPE_POLYGON_MODE_POINT &&
+          (rast->need_pipeline & SVGA_PIPELINE_FLAG_POINTS))
+      {
+         fill = PIPE_POLYGON_MODE_FILL;
+         rast->need_pipeline |= SVGA_PIPELINE_FLAG_TRIS;
+      }
+
+      if (offset) {
+         rast->slopescaledepthbias = templ->offset_scale;
+         rast->depthbias = templ->offset_units;
+      }
+
+      rast->hw_unfilled = fill;
+   }
+
+
+
+
+   if (rast->need_pipeline & SVGA_PIPELINE_FLAG_TRIS) {
+      /* Turn off stuff which will get done in the draw module:
+       */
+      rast->hw_unfilled = PIPE_POLYGON_MODE_FILL;
+      rast->slopescaledepthbias = 0;
+      rast->depthbias = 0;
+   }
+
+   return rast;
+}
+
+static void svga_bind_rasterizer_state( struct pipe_context *pipe,
+                                        void *state )
+{
+   struct svga_context *svga = svga_context(pipe);
+   struct svga_rasterizer_state *raster = (struct svga_rasterizer_state *)state;
+
+   svga->curr.rast = raster;
+
+   draw_set_rasterizer_state(svga->swtnl.draw, raster ? &raster->templ : NULL);
+   
+   svga->dirty |= SVGA_NEW_RAST;
+}
+
+static void svga_delete_rasterizer_state(struct pipe_context *pipe,
+                                         void *raster)
+{
+   FREE(raster);
+}
+
+
+void svga_init_rasterizer_functions( struct svga_context *svga )
+{
+   svga->pipe.create_rasterizer_state = svga_create_rasterizer_state;
+   svga->pipe.bind_rasterizer_state = svga_bind_rasterizer_state;
+   svga->pipe.delete_rasterizer_state = svga_delete_rasterizer_state;
+}
+
+
+/***********************************************************************
+ * Hardware state update
+ */
+
diff --git a/src/gallium/drivers/svga/svga_pipe_sampler.c b/src/gallium/drivers/svga/svga_pipe_sampler.c
new file mode 100644 (file)
index 0000000..460a101
--- /dev/null
@@ -0,0 +1,245 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "pipe/p_inlines.h"
+#include "pipe/p_defines.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+#include "util/u_pack_color.h"
+#include "tgsi/tgsi_parse.h"
+
+#include "svga_context.h"
+#include "svga_screen_texture.h"
+#include "svga_state.h"
+
+#include "svga_hw_reg.h"
+
+#include "svga_debug.h"
+
+static INLINE unsigned
+translate_wrap_mode(unsigned wrap)
+{
+   switch (wrap) {
+   case PIPE_TEX_WRAP_REPEAT: 
+      return SVGA3D_TEX_ADDRESS_WRAP;
+
+   case PIPE_TEX_WRAP_CLAMP: 
+      return SVGA3D_TEX_ADDRESS_CLAMP;
+
+   case PIPE_TEX_WRAP_CLAMP_TO_EDGE: 
+      /* Unfortunately SVGA3D_TEX_ADDRESS_EDGE not respected by
+       * hardware.
+       */
+      return SVGA3D_TEX_ADDRESS_CLAMP;
+
+   case PIPE_TEX_WRAP_CLAMP_TO_BORDER: 
+      return SVGA3D_TEX_ADDRESS_BORDER;
+
+   case PIPE_TEX_WRAP_MIRROR_REPEAT: 
+      return SVGA3D_TEX_ADDRESS_MIRROR;
+
+   case PIPE_TEX_WRAP_MIRROR_CLAMP:  
+   case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:   
+   case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER: 
+      return SVGA3D_TEX_ADDRESS_MIRRORONCE;
+
+   default:
+      assert(0);
+      return SVGA3D_TEX_ADDRESS_WRAP;
+   }
+}
+
+static INLINE unsigned translate_img_filter( unsigned filter )
+{
+   switch (filter) {
+   case PIPE_TEX_FILTER_NEAREST: return SVGA3D_TEX_FILTER_NEAREST;
+   case PIPE_TEX_FILTER_LINEAR:  return SVGA3D_TEX_FILTER_LINEAR;
+   default:
+      assert(0);
+      return SVGA3D_TEX_FILTER_NEAREST;
+   }
+}
+
+static INLINE unsigned translate_mip_filter( unsigned filter )
+{
+   switch (filter) {
+   case PIPE_TEX_MIPFILTER_NONE:    return SVGA3D_TEX_FILTER_NONE;
+   case PIPE_TEX_MIPFILTER_NEAREST: return SVGA3D_TEX_FILTER_NEAREST;
+   case PIPE_TEX_MIPFILTER_LINEAR:  return SVGA3D_TEX_FILTER_LINEAR;
+   default:
+      assert(0);
+      return SVGA3D_TEX_FILTER_NONE;
+   }
+}
+
+static void *
+svga_create_sampler_state(struct pipe_context *pipe,
+                          const struct pipe_sampler_state *sampler)
+{
+   struct svga_context *svga = svga_context(pipe);
+   struct svga_sampler_state *cso = CALLOC_STRUCT( svga_sampler_state );
+   union util_color uc;
+   
+   cso->mipfilter = translate_mip_filter(sampler->min_mip_filter);
+   cso->magfilter = translate_img_filter( sampler->mag_img_filter );
+   cso->minfilter = translate_img_filter( sampler->min_img_filter );
+   cso->aniso_level = MAX2( (unsigned) sampler->max_anisotropy, 1 );
+   if(cso->aniso_level != 1)
+      cso->magfilter = cso->minfilter = SVGA3D_TEX_FILTER_ANISOTROPIC;
+   cso->lod_bias = sampler->lod_bias;
+   cso->addressu = translate_wrap_mode(sampler->wrap_s);
+   cso->addressv = translate_wrap_mode(sampler->wrap_t);
+   cso->addressw = translate_wrap_mode(sampler->wrap_r);
+   cso->normalized_coords = sampler->normalized_coords;
+   cso->compare_mode = sampler->compare_mode;
+   cso->compare_func = sampler->compare_func;
+
+   {
+      ubyte r = float_to_ubyte(sampler->border_color[0]);
+      ubyte g = float_to_ubyte(sampler->border_color[1]);
+      ubyte b = float_to_ubyte(sampler->border_color[2]);
+      ubyte a = float_to_ubyte(sampler->border_color[3]);
+
+      util_pack_color_ub( r, g, b, a,
+                          PIPE_FORMAT_B8G8R8A8_UNORM, &uc);
+      cso->bordercolor = uc.ui;
+   }
+
+   /* No SVGA3D support for:
+    *    - min/max LOD clamping
+    */
+   cso->min_lod = 0;
+   cso->view_min_lod = MAX2(sampler->min_lod, 0);
+   cso->view_max_lod = MAX2(sampler->max_lod, 0);
+
+   /* Use min_mipmap */
+   if (svga->debug.use_min_mipmap) {
+      if (cso->view_min_lod == cso->view_max_lod) {
+         cso->min_lod = cso->view_min_lod;
+         cso->view_min_lod = 0;
+         cso->view_max_lod = 1000; /* Just a high number */
+         cso->mipfilter = SVGA3D_TEX_FILTER_NONE;
+      }
+   }
+
+   SVGA_DBG(DEBUG_VIEWS, "min %u, view(min %u, max %u) lod, mipfilter %s\n",
+            cso->min_lod, cso->view_min_lod, cso->view_max_lod,
+            cso->mipfilter == SVGA3D_TEX_FILTER_NONE ? "SVGA3D_TEX_FILTER_NONE" : "SOMETHING");
+
+   return cso;
+}
+
+static void svga_bind_sampler_states(struct pipe_context *pipe,
+                                     unsigned num, void **sampler)
+{
+   struct svga_context *svga = svga_context(pipe);
+   unsigned i;
+
+   assert(num <= PIPE_MAX_SAMPLERS);
+
+   /* Check for no-op */
+   if (num == svga->curr.num_samplers &&
+       !memcmp(svga->curr.sampler, sampler, num * sizeof(void *))) {
+      debug_printf("sampler noop\n");
+      return;
+   }
+
+   for (i = 0; i < num; i++)
+      svga->curr.sampler[i] = sampler[i];
+
+   for (i = num; i < svga->curr.num_samplers; i++)
+      svga->curr.sampler[i] = NULL;
+
+   svga->curr.num_samplers = num;
+   svga->dirty |= SVGA_NEW_SAMPLER;
+}
+
+static void svga_delete_sampler_state(struct pipe_context *pipe,
+                                      void *sampler)
+{
+   FREE(sampler);
+}
+
+
+static void svga_set_sampler_textures(struct pipe_context *pipe,
+                                      unsigned num,
+                                      struct pipe_texture **texture)
+{
+   struct svga_context *svga = svga_context(pipe);
+   unsigned flag_1d = 0;
+   unsigned flag_srgb = 0;
+   uint i;
+
+   assert(num <= PIPE_MAX_SAMPLERS);
+
+   /* Check for no-op */
+   if (num == svga->curr.num_textures &&
+       !memcmp(svga->curr.texture, texture, num * sizeof(struct pipe_texture *))) {
+      if (0) debug_printf("texture noop\n");
+      return;
+   }
+
+   for (i = 0; i < num; i++) {
+      pipe_texture_reference(&svga->curr.texture[i],
+                             texture[i]);
+
+      if (!texture[i])
+         continue;
+
+      if (texture[i]->format == PIPE_FORMAT_A8R8G8B8_SRGB)
+         flag_srgb |= 1 << i;
+
+      if (texture[i]->target == PIPE_TEXTURE_1D)
+         flag_1d |= 1 << i;
+   }
+
+   for (i = num; i < svga->curr.num_textures; i++)
+      pipe_texture_reference(&svga->curr.texture[i],
+                             NULL);
+
+   svga->curr.num_textures = num;
+   svga->dirty |= SVGA_NEW_TEXTURE_BINDING;
+
+   if (flag_srgb != svga->curr.tex_flags.flag_srgb ||
+       flag_1d != svga->curr.tex_flags.flag_1d) 
+   {
+      svga->dirty |= SVGA_NEW_TEXTURE_FLAGS;
+      svga->curr.tex_flags.flag_1d = flag_1d;
+      svga->curr.tex_flags.flag_srgb = flag_srgb;
+   }  
+}
+
+
+
+void svga_init_sampler_functions( struct svga_context *svga )
+{
+   svga->pipe.create_sampler_state = svga_create_sampler_state;
+   svga->pipe.bind_fragment_sampler_states = svga_bind_sampler_states;
+   svga->pipe.delete_sampler_state = svga_delete_sampler_state;
+   svga->pipe.set_fragment_sampler_textures = svga_set_sampler_textures;
+}
+
+
+
diff --git a/src/gallium/drivers/svga/svga_pipe_vertex.c b/src/gallium/drivers/svga/svga_pipe_vertex.c
new file mode 100644 (file)
index 0000000..42f290d
--- /dev/null
@@ -0,0 +1,102 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "pipe/p_inlines.h"
+#include "pipe/p_defines.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+#include "tgsi/tgsi_parse.h"
+
+#include "svga_screen.h"
+#include "svga_screen_buffer.h"
+#include "svga_context.h"
+#include "svga_state.h"
+#include "svga_winsys.h"
+
+#include "svga_hw_reg.h"
+
+
+static void svga_set_vertex_buffers(struct pipe_context *pipe,
+                                    unsigned count,
+                                    const struct pipe_vertex_buffer *buffers)
+{
+   struct svga_context *svga = svga_context(pipe);
+   unsigned i;
+   boolean any_user_buffer = FALSE;
+
+   /* Check for no change */
+   if (count == svga->curr.num_vertex_buffers &&
+       memcmp(svga->curr.vb, buffers, count * sizeof buffers[0]) == 0)
+      return;
+
+   /* Adjust refcounts */
+   for (i = 0; i < count; i++) {
+      pipe_buffer_reference(&svga->curr.vb[i].buffer, buffers[i].buffer);
+      if (svga_buffer(buffers[i].buffer)->user)
+         any_user_buffer = TRUE;
+   }
+
+   for ( ; i < svga->curr.num_vertex_buffers; i++)
+      pipe_buffer_reference(&svga->curr.vb[i].buffer, NULL);
+
+   /* Copy remaining data */
+   memcpy(svga->curr.vb, buffers, count * sizeof buffers[0]);
+   svga->curr.num_vertex_buffers = count;
+   svga->curr.any_user_vertex_buffers = any_user_buffer;
+
+   svga->dirty |= SVGA_NEW_VBUFFER;
+}
+
+static void svga_set_vertex_elements(struct pipe_context *pipe,
+                                     unsigned count,
+                                     const struct pipe_vertex_element *elements)
+{
+   struct svga_context *svga = svga_context(pipe);
+   unsigned i;
+
+   for (i = 0; i < count; i++)
+      svga->curr.ve[i] = elements[i];
+
+   svga->curr.num_vertex_elements = count;
+   svga->dirty |= SVGA_NEW_VELEMENT;
+}
+
+
+void svga_cleanup_vertex_state( struct svga_context *svga )
+{
+   unsigned i;
+   
+   for (i = 0 ; i < svga->curr.num_vertex_buffers; i++)
+      pipe_buffer_reference(&svga->curr.vb[i].buffer, NULL);
+}
+
+
+void svga_init_vertex_functions( struct svga_context *svga )
+{
+   svga->pipe.set_vertex_buffers = svga_set_vertex_buffers;
+   svga->pipe.set_vertex_elements = svga_set_vertex_elements;
+}
+
+
diff --git a/src/gallium/drivers/svga/svga_pipe_vs.c b/src/gallium/drivers/svga/svga_pipe_vs.c
new file mode 100644 (file)
index 0000000..7e6ab57
--- /dev/null
@@ -0,0 +1,199 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "draw/draw_context.h"
+#include "pipe/p_inlines.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+#include "util/u_bitmask.h"
+#include "tgsi/tgsi_parse.h"
+#include "tgsi/tgsi_text.h"
+
+#include "svga_screen.h"
+#include "svga_context.h"
+#include "svga_state.h"
+#include "svga_tgsi.h"
+#include "svga_hw_reg.h"
+#include "svga_cmd.h"
+#include "svga_debug.h"
+
+
+static const struct tgsi_token *substitute_vs( 
+   unsigned shader_id,
+   const struct tgsi_token *old_tokens )
+{
+#if 0
+   if (shader_id == 12) {
+   static struct tgsi_token tokens[300];
+
+   const char *text = 
+      "VERT\n"
+      "DCL IN[0]\n"
+      "DCL IN[1]\n"
+      "DCL IN[2]\n"
+      "DCL OUT[0], POSITION\n"
+      "DCL TEMP[0..4]\n"
+      "IMM FLT32 {     1.0000,     1.0000,     1.0000,     1.0000 }\n"
+      "IMM FLT32 {     0.45,     1.0000,     1.0000,     1.0000 }\n"
+      "IMM FLT32 { 1.297863, 0.039245, 0.035993, 0.035976}\n"
+      "IMM FLT32 { -0.019398, 1.696131, -0.202151, -0.202050  }\n"
+      "IMM FLT32 { 0.051711, -0.348713, -0.979204, -0.978714  }\n"
+      "IMM FLT32 { 0.000000, 0.000003, 139.491577, 141.421356 }\n"
+      "DCL CONST[0..7]\n"
+      "DCL CONST[9..16]\n"
+      "  MOV TEMP[2], IMM[0]\n"
+
+      "  MOV TEMP[2].xyz, IN[2]\n"
+      "  MOV TEMP[2].xyz, IN[0]\n"
+      "  MOV TEMP[2].xyz, IN[1]\n"
+
+      "  MUL TEMP[1], IMM[3], TEMP[2].yyyy\n"
+      "  MAD TEMP[3], IMM[2],  TEMP[2].xxxx, TEMP[1]\n"
+      "  MAD TEMP[1], IMM[4], TEMP[2].zzzz, TEMP[3]\n"
+      "  MAD TEMP[4], IMM[5], TEMP[2].wwww, TEMP[1]\n"
+
+      "  MOV OUT[0], TEMP[4]\n"
+      "  END\n";
+
+   if (!tgsi_text_translate( text,
+                             tokens,
+                             Elements(tokens) ))
+   {
+      assert(0);
+      return NULL;
+   }
+
+   return tokens;
+   }
+#endif
+
+   return old_tokens;
+}
+
+
+/***********************************************************************
+ * Vertex shaders 
+ */
+
+static void *
+svga_create_vs_state(struct pipe_context *pipe,
+                     const struct pipe_shader_state *templ)
+{
+   struct svga_context *svga = svga_context(pipe);
+   struct svga_screen *svgascreen = svga_screen(pipe->screen);
+   struct svga_vertex_shader *vs = CALLOC_STRUCT(svga_vertex_shader);
+   if (!vs)
+      return NULL;
+
+   /* substitute a debug shader?
+    */
+   vs->base.tokens = tgsi_dup_tokens(substitute_vs(svga->debug.shader_id,
+                                                   templ->tokens));
+
+
+   /* Collect basic info that we'll need later:
+    */
+   tgsi_scan_shader(vs->base.tokens, &vs->base.info);
+
+   {
+      /* Need to do construct a new template in case we substitued a
+       * debug shader.
+       */
+      struct pipe_shader_state tmp2 = *templ;
+      tmp2.tokens = vs->base.tokens;
+      vs->draw_shader = draw_create_vertex_shader(svga->swtnl.draw, &tmp2);
+   }
+
+   vs->base.id = svga->debug.shader_id++;
+   vs->base.use_sm30 = svgascreen->use_vs30;
+
+   if (SVGA_DEBUG & DEBUG_TGSI || 0) {
+      debug_printf("%s id: %u, inputs: %u, outputs: %u\n",
+                   __FUNCTION__, vs->base.id,
+                   vs->base.info.num_inputs, vs->base.info.num_outputs);
+   }
+
+   return vs;
+}
+
+static void svga_bind_vs_state(struct pipe_context *pipe, void *shader)
+{
+   struct svga_vertex_shader *vs = (struct svga_vertex_shader *)shader;
+   struct svga_context *svga = svga_context(pipe);
+
+   svga->curr.vs = vs;
+   svga->dirty |= SVGA_NEW_VS;
+}
+
+
+static void svga_delete_vs_state(struct pipe_context *pipe, void *shader)
+{
+   struct svga_context *svga = svga_context(pipe);
+   struct svga_vertex_shader *vs = (struct svga_vertex_shader *)shader;
+   struct svga_shader_result *result, *tmp;
+   enum pipe_error ret;
+
+   svga_hwtnl_flush_retry( svga );
+
+   draw_delete_vertex_shader(svga->swtnl.draw, vs->draw_shader);
+   
+   for (result = vs->base.results; result; result = tmp ) {
+      tmp = result->next;
+
+      ret = SVGA3D_DestroyShader(svga->swc, 
+                                 result->id,
+                                 SVGA3D_SHADERTYPE_VS );
+      if(ret != PIPE_OK) {
+         svga_context_flush(svga, NULL);
+         ret = SVGA3D_DestroyShader(svga->swc, 
+                                    result->id,
+                                    SVGA3D_SHADERTYPE_VS );
+         assert(ret == PIPE_OK);
+      }
+
+      util_bitmask_clear( svga->vs_bm, result->id );
+
+      svga_destroy_shader_result( result );
+
+      /*
+       * Remove stale references to this result to ensure a new result on the
+       * same address will be detected as a change.
+       */
+      if(result == svga->state.hw_draw.vs)
+         svga->state.hw_draw.vs = NULL;
+   }
+
+   FREE((void *)vs->base.tokens);
+   FREE(vs);
+}
+
+
+void svga_init_vs_functions( struct svga_context *svga )
+{
+   svga->pipe.create_vs_state = svga_create_vs_state;
+   svga->pipe.bind_vs_state = svga_bind_vs_state;
+   svga->pipe.delete_vs_state = svga_delete_vs_state;
+}
+
diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c
new file mode 100644 (file)
index 0000000..fc1b3c9
--- /dev/null
@@ -0,0 +1,440 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "util/u_memory.h"
+#include "pipe/p_inlines.h"
+#include "util/u_string.h"
+#include "util/u_math.h"
+
+#include "svga_winsys.h"
+#include "svga_context.h"
+#include "svga_screen.h"
+#include "svga_screen_texture.h"
+#include "svga_screen_buffer.h"
+#include "svga_cmd.h"
+#include "svga_debug.h"
+
+#include "svga_hw_reg.h"
+#include "svga3d_shaderdefs.h"
+
+
+#ifdef DEBUG
+int SVGA_DEBUG = 0;
+
+static const struct debug_named_value svga_debug_flags[] = {
+   { "dma",      DEBUG_DMA },
+   { "tgsi",     DEBUG_TGSI },
+   { "pipe",     DEBUG_PIPE },
+   { "state",    DEBUG_STATE },
+   { "screen",   DEBUG_SCREEN },
+   { "tex",      DEBUG_TEX },
+   { "swtnl",    DEBUG_SWTNL },
+   { "const",    DEBUG_CONSTS },
+   { "viewport", DEBUG_VIEWPORT },
+   { "views",    DEBUG_VIEWS },
+   { "perf",     DEBUG_PERF },
+   { "flush",    DEBUG_FLUSH },
+   { "sync",     DEBUG_SYNC },
+   { "cache",    DEBUG_CACHE },
+   {NULL, 0}
+};
+#endif
+
+static const char *
+svga_get_vendor( struct pipe_screen *pscreen )
+{
+   return "VMware, Inc.";
+}
+
+
+static const char *
+svga_get_name( struct pipe_screen *pscreen )
+{
+#ifdef DEBUG
+   /* Only return internal details in the DEBUG version:
+    */
+   return "SVGA3D; build: DEBUG; mutex: " PIPE_ATOMIC;
+#else
+   return "SVGA3D; build: RELEASE; ";
+#endif
+}
+
+
+
+
+static float
+svga_get_paramf(struct pipe_screen *screen, int param)
+{
+   struct svga_screen *svgascreen = svga_screen(screen);
+   struct svga_winsys_screen *sws = svgascreen->sws;
+   SVGA3dDevCapResult result;
+
+   switch (param) {
+   case PIPE_CAP_MAX_LINE_WIDTH:
+      /* fall-through */
+   case PIPE_CAP_MAX_LINE_WIDTH_AA:
+      return 7.0;
+
+   case PIPE_CAP_MAX_POINT_WIDTH:
+      /* fall-through */
+   case PIPE_CAP_MAX_POINT_WIDTH_AA:
+      /* Keep this to a reasonable size to avoid failures in
+       * conform/pntaa.c:
+       */
+      return 80.0;
+
+   case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
+      return 4.0;
+
+   case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
+      return 16.0;
+
+   case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
+      return 16;
+   case PIPE_CAP_NPOT_TEXTURES:
+      return 1;
+   case PIPE_CAP_TWO_SIDED_STENCIL:
+      return 1;
+   case PIPE_CAP_GLSL:
+      return svgascreen->use_ps30 && svgascreen->use_vs30;
+   case PIPE_CAP_ANISOTROPIC_FILTER:
+      return 1;
+   case PIPE_CAP_POINT_SPRITE:
+      return 1;
+   case PIPE_CAP_MAX_RENDER_TARGETS:
+      if(!sws->get_cap(sws, SVGA3D_DEVCAP_MAX_RENDER_TARGETS, &result))
+         return 1;
+      if(!result.u)
+         return 1;
+      return MIN2(result.u, PIPE_MAX_COLOR_BUFS);
+   case PIPE_CAP_OCCLUSION_QUERY:
+      return 1;
+   case PIPE_CAP_TEXTURE_SHADOW_MAP:
+      return 1;
+   case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
+      return SVGA_MAX_TEXTURE_LEVELS;
+   case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
+      return 8;  /* max 128x128x128 */
+   case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
+      return SVGA_MAX_TEXTURE_LEVELS;
+
+   case PIPE_CAP_TEXTURE_MIRROR_REPEAT: /* req. for GL 1.4 */
+      return 1;
+
+   case PIPE_CAP_BLEND_EQUATION_SEPARATE: /* req. for GL 1.5 */
+      return 1;
+
+   default:
+      return 0;
+   }
+}
+
+
+/* This is a fairly pointless interface
+ */
+static int
+svga_get_param(struct pipe_screen *screen, int param)
+{
+   return (int) svga_get_paramf( screen, param );
+}
+
+
+static INLINE SVGA3dDevCapIndex
+svga_translate_format_cap(enum pipe_format format)
+{
+   switch(format) {
+   
+   case PIPE_FORMAT_A8R8G8B8_UNORM:
+      return SVGA3D_DEVCAP_SURFACEFMT_A8R8G8B8;
+   case PIPE_FORMAT_X8R8G8B8_UNORM:
+      return SVGA3D_DEVCAP_SURFACEFMT_X8R8G8B8;
+
+   case PIPE_FORMAT_R5G6B5_UNORM:
+      return SVGA3D_DEVCAP_SURFACEFMT_R5G6B5;
+   case PIPE_FORMAT_A1R5G5B5_UNORM:
+      return SVGA3D_DEVCAP_SURFACEFMT_A1R5G5B5;
+   case PIPE_FORMAT_A4R4G4B4_UNORM:
+      return SVGA3D_DEVCAP_SURFACEFMT_A4R4G4B4;
+
+   case PIPE_FORMAT_Z16_UNORM:
+      return SVGA3D_DEVCAP_SURFACEFMT_Z_D16;
+   case PIPE_FORMAT_Z24S8_UNORM:
+      return SVGA3D_DEVCAP_SURFACEFMT_Z_D24S8;
+   case PIPE_FORMAT_Z24X8_UNORM:
+      return SVGA3D_DEVCAP_SURFACEFMT_Z_D24X8;
+
+   case PIPE_FORMAT_A8_UNORM:
+      return SVGA3D_DEVCAP_SURFACEFMT_ALPHA8;
+   case PIPE_FORMAT_L8_UNORM:
+      return SVGA3D_DEVCAP_SURFACEFMT_LUMINANCE8;
+
+   case PIPE_FORMAT_DXT1_RGB:
+   case PIPE_FORMAT_DXT1_RGBA:
+      return SVGA3D_DEVCAP_SURFACEFMT_DXT1;
+   case PIPE_FORMAT_DXT3_RGBA:
+      return SVGA3D_DEVCAP_SURFACEFMT_DXT3;
+   case PIPE_FORMAT_DXT5_RGBA:
+      return SVGA3D_DEVCAP_SURFACEFMT_DXT5;
+
+   default:
+      return SVGA3D_DEVCAP_MAX;
+   }
+}
+
+
+static boolean
+svga_is_format_supported( struct pipe_screen *screen,
+                          enum pipe_format format, 
+                          enum pipe_texture_target target,
+                          unsigned tex_usage, 
+                          unsigned geom_flags )
+{
+   struct svga_winsys_screen *sws = svga_screen(screen)->sws;
+   SVGA3dDevCapIndex index;
+   SVGA3dDevCapResult result;
+   
+   assert(tex_usage);
+
+   /* Override host capabilities */
+   if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) {
+      switch(format) { 
+
+      /* Often unsupported/problematic. This means we end up with the same
+       * visuals for all virtual hardware implementations.
+       */
+      case PIPE_FORMAT_A4R4G4B4_UNORM:
+      case PIPE_FORMAT_A1R5G5B5_UNORM:
+         return FALSE;
+         
+      /* Simulate ability to render into compressed textures */
+      case PIPE_FORMAT_DXT1_RGB:
+      case PIPE_FORMAT_DXT1_RGBA:
+      case PIPE_FORMAT_DXT3_RGBA:
+      case PIPE_FORMAT_DXT5_RGBA:
+         return TRUE;
+
+      default:
+         break;
+      }
+   }
+   
+   /* Try to query the host */
+   index = svga_translate_format_cap(format);
+   if( index < SVGA3D_DEVCAP_MAX && 
+       sws->get_cap(sws, index, &result) )
+   {
+      SVGA3dSurfaceFormatCaps mask;
+      
+      mask.value = 0;
+      if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET)
+         mask.offscreenRenderTarget = 1;
+      if (tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL)
+         mask.zStencil = 1;
+      if (tex_usage & PIPE_TEXTURE_USAGE_SAMPLER)
+         mask.texture = 1;
+
+      if ((result.u & mask.value) == mask.value)
+         return TRUE;
+      else
+         return FALSE;
+   }
+
+   /* Use our translate functions directly rather than relying on a
+    * duplicated list of supported formats which is prone to getting
+    * out of sync:
+    */
+   if(tex_usage & (PIPE_TEXTURE_USAGE_RENDER_TARGET | PIPE_TEXTURE_USAGE_DEPTH_STENCIL))
+      return svga_translate_format_render(format) != SVGA3D_FORMAT_INVALID;
+   else
+      return svga_translate_format(format) != SVGA3D_FORMAT_INVALID;
+}
+
+
+static void
+svga_fence_reference(struct pipe_screen *screen,
+                     struct pipe_fence_handle **ptr,
+                     struct pipe_fence_handle *fence)
+{
+   struct svga_winsys_screen *sws = svga_screen(screen)->sws;
+   sws->fence_reference(sws, ptr, fence);
+}
+
+
+static int
+svga_fence_signalled(struct pipe_screen *screen,
+                     struct pipe_fence_handle *fence,
+                     unsigned flag)
+{
+   struct svga_winsys_screen *sws = svga_screen(screen)->sws;
+   return sws->fence_signalled(sws, fence, flag);
+}
+
+
+static int
+svga_fence_finish(struct pipe_screen *screen,
+                  struct pipe_fence_handle *fence,
+                  unsigned flag)
+{
+   struct svga_winsys_screen *sws = svga_screen(screen)->sws;
+
+   SVGA_DBG(DEBUG_DMA|DEBUG_PERF, "%s fence_ptr %p\n",
+            __FUNCTION__, fence);
+
+   return sws->fence_finish(sws, fence, flag);
+}
+
+
+static void
+svga_destroy_screen( struct pipe_screen *screen )
+{
+   struct svga_screen *svgascreen = svga_screen(screen);
+   
+   svga_screen_cache_cleanup(svgascreen);
+
+   pipe_mutex_destroy(svgascreen->swc_mutex);
+   pipe_mutex_destroy(svgascreen->tex_mutex);
+
+   svgascreen->swc->destroy(svgascreen->swc);
+   
+   svgascreen->sws->destroy(svgascreen->sws);
+   
+   FREE(svgascreen);
+}
+
+
+/**
+ * Create a new svga_screen object
+ */
+struct pipe_screen *
+svga_screen_create(struct svga_winsys_screen *sws)
+{
+   struct svga_screen *svgascreen;
+   struct pipe_screen *screen;
+   SVGA3dDevCapResult result;
+
+#ifdef DEBUG
+   SVGA_DEBUG = debug_get_flags_option("SVGA_DEBUG", svga_debug_flags, 0 );
+#endif
+
+   svgascreen = CALLOC_STRUCT(svga_screen);
+   if (!svgascreen)
+      goto error1;
+
+   svgascreen->debug.force_level_surface_view =
+      debug_get_bool_option("SVGA_FORCE_LEVEL_SURFACE_VIEW", FALSE);
+   svgascreen->debug.force_surface_view =
+      debug_get_bool_option("SVGA_FORCE_SURFACE_VIEW", FALSE);
+   svgascreen->debug.force_sampler_view =
+      debug_get_bool_option("SVGA_FORCE_SAMPLER_VIEW", FALSE);
+   svgascreen->debug.no_surface_view =
+      debug_get_bool_option("SVGA_NO_SURFACE_VIEW", FALSE);
+   svgascreen->debug.no_sampler_view =
+      debug_get_bool_option("SVGA_NO_SAMPLER_VIEW", FALSE);
+
+   screen = &svgascreen->screen;
+
+   screen->destroy = svga_destroy_screen;
+   screen->get_name = svga_get_name;
+   screen->get_vendor = svga_get_vendor;
+   screen->get_param = svga_get_param;
+   screen->get_paramf = svga_get_paramf;
+   screen->is_format_supported = svga_is_format_supported;
+   screen->fence_reference = svga_fence_reference;
+   screen->fence_signalled = svga_fence_signalled;
+   screen->fence_finish = svga_fence_finish;
+   svgascreen->sws = sws;
+
+   svga_screen_init_texture_functions(screen);
+   svga_screen_init_buffer_functions(screen);
+
+   svgascreen->use_ps30 =
+      sws->get_cap(sws, SVGA3D_DEVCAP_FRAGMENT_SHADER_VERSION, &result) &&
+      result.u >= SVGA3DPSVERSION_30 ? TRUE : FALSE;
+
+   svgascreen->use_vs30 =
+      sws->get_cap(sws, SVGA3D_DEVCAP_VERTEX_SHADER_VERSION, &result) &&
+      result.u >= SVGA3DVSVERSION_30 ? TRUE : FALSE;
+
+#if 1
+   /* Shader model 2.0 is unsupported at the moment. */
+   if(!svgascreen->use_ps30 || !svgascreen->use_vs30)
+      goto error2;
+#else
+   if(debug_get_bool_option("SVGA_NO_SM30", FALSE))
+      svgascreen->use_vs30 = svgascreen->use_ps30 = FALSE;
+#endif
+
+   svgascreen->swc = sws->context_create(sws);
+   if(!svgascreen->swc)
+      goto error2;
+
+   pipe_mutex_init(svgascreen->tex_mutex);
+   pipe_mutex_init(svgascreen->swc_mutex);
+
+   LIST_INITHEAD(&svgascreen->cached_buffers);
+   
+   svga_screen_cache_init(svgascreen);
+
+   return screen;
+error2:
+   FREE(svgascreen);
+error1:
+   return NULL;
+}
+
+void svga_screen_flush( struct svga_screen *svgascreen, 
+                        struct pipe_fence_handle **pfence )
+{
+   struct pipe_fence_handle *fence = NULL;
+
+   SVGA_DBG(DEBUG_PERF, "%s\n", __FUNCTION__);
+   
+   pipe_mutex_lock(svgascreen->swc_mutex);
+   svgascreen->swc->flush(svgascreen->swc, &fence);
+   pipe_mutex_unlock(svgascreen->swc_mutex);
+   
+   svga_screen_cache_flush(svgascreen, fence);
+   
+   if(pfence)
+      *pfence = fence;
+   else
+      svgascreen->sws->fence_reference(svgascreen->sws, &fence, NULL);
+}
+
+struct svga_winsys_screen *
+svga_winsys_screen(struct pipe_screen *screen)
+{
+   return svga_screen(screen)->sws;
+}
+
+#ifdef DEBUG
+struct svga_screen *
+svga_screen(struct pipe_screen *screen)
+{
+   assert(screen);
+   assert(screen->destroy == svga_destroy_screen);
+   return (struct svga_screen *)screen;
+}
+#endif
diff --git a/src/gallium/drivers/svga/svga_screen.h b/src/gallium/drivers/svga/svga_screen.h
new file mode 100644 (file)
index 0000000..b94ca7f
--- /dev/null
@@ -0,0 +1,95 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#ifndef SVGA_SCREEN_H
+#define SVGA_SCREEN_H
+
+
+#include "pipe/p_screen.h"
+#include "pipe/p_thread.h"
+
+#include "util/u_double_list.h"
+
+#include "svga_screen_cache.h"
+
+
+struct svga_winsys_screen;
+struct svga_winsys_context;
+struct SVGACmdMemory;
+
+#define SVGA_COMBINE_USERBUFFERS 1
+
+/**
+ * Subclass of pipe_screen
+ */
+struct svga_screen
+{
+   struct pipe_screen screen;
+   struct svga_winsys_screen *sws;
+
+   unsigned use_ps30;
+   unsigned use_vs30;
+   
+   struct {
+      boolean force_level_surface_view;
+      boolean force_surface_view;
+      boolean no_surface_view;
+      boolean force_sampler_view;
+      boolean no_sampler_view;
+   } debug;
+
+   /* The screen needs its own context */
+   struct svga_winsys_context *swc;
+   struct SVGACmdMemory *fifo;
+
+   unsigned texture_timestamp;
+   pipe_mutex tex_mutex; 
+   pipe_mutex swc_mutex; /* Protects the use of swc and dirty_buffers */
+   
+   /** 
+    * List of buffers with cached GMR. Ordered from the most recently used to
+    * the least recently used 
+    */
+   struct list_head cached_buffers;
+   
+   struct svga_host_surface_cache cache;
+};
+
+#ifndef DEBUG
+/** cast wrapper */
+static INLINE struct svga_screen *
+svga_screen(struct pipe_screen *pscreen)
+{
+   return (struct svga_screen *) pscreen;
+}
+#else
+struct svga_screen *
+svga_screen(struct pipe_screen *screen);
+#endif
+
+void svga_screen_flush( struct svga_screen *svga_screen, 
+                        struct pipe_fence_handle **pfence );
+
+#endif /* SVGA_SCREEN_H */
diff --git a/src/gallium/drivers/svga/svga_screen_buffer.c b/src/gallium/drivers/svga/svga_screen_buffer.c
new file mode 100644 (file)
index 0000000..58a1aba
--- /dev/null
@@ -0,0 +1,825 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "svga_cmd.h"
+
+#include "pipe/p_state.h"
+#include "pipe/p_defines.h"
+#include "pipe/p_inlines.h"
+#include "pipe/p_thread.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
+#include "svga_context.h"
+#include "svga_screen.h"
+#include "svga_screen_buffer.h"
+#include "svga_winsys.h"
+#include "svga_debug.h"
+
+
+/**
+ * Vertex and index buffers have to be treated slightly differently from 
+ * regular guest memory regions because the SVGA device sees them as 
+ * surfaces, and the state tracker can create/destroy without the pipe 
+ * driver, therefore we must do the uploads from the vws.
+ */
+static INLINE boolean
+svga_buffer_needs_hw_storage(unsigned usage)
+{
+   return usage & (PIPE_BUFFER_USAGE_VERTEX | PIPE_BUFFER_USAGE_INDEX);
+}
+
+
+static INLINE enum pipe_error
+svga_buffer_create_host_surface(struct svga_screen *ss,
+                                struct svga_buffer *sbuf)
+{
+   if(!sbuf->handle) {
+      sbuf->key.flags = 0;
+      
+      sbuf->key.format = SVGA3D_BUFFER;
+      if(sbuf->base.usage & PIPE_BUFFER_USAGE_VERTEX)
+         sbuf->key.flags |= SVGA3D_SURFACE_HINT_VERTEXBUFFER;
+      if(sbuf->base.usage & PIPE_BUFFER_USAGE_INDEX)
+         sbuf->key.flags |= SVGA3D_SURFACE_HINT_INDEXBUFFER;
+      
+      sbuf->key.size.width = sbuf->base.size;
+      sbuf->key.size.height = 1;
+      sbuf->key.size.depth = 1;
+      
+      sbuf->key.numFaces = 1;
+      sbuf->key.numMipLevels = 1;
+      sbuf->key.cachable = 1;
+      
+      SVGA_DBG(DEBUG_DMA, "surface_create for buffer sz %d\n", sbuf->base.size);
+
+      sbuf->handle = svga_screen_surface_create(ss, &sbuf->key);
+      if(!sbuf->handle)
+         return PIPE_ERROR_OUT_OF_MEMORY;
+   
+      /* Always set the discard flag on the first time the buffer is written
+       * as svga_screen_surface_create might have passed a recycled host
+       * buffer.
+       */
+      sbuf->hw.flags.discard = TRUE;
+
+      SVGA_DBG(DEBUG_DMA, "   --> got sid %p sz %d (buffer)\n", sbuf->handle, sbuf->base.size);
+   }
+   
+   return PIPE_OK;
+}   
+
+
+static INLINE void
+svga_buffer_destroy_host_surface(struct svga_screen *ss,
+                                 struct svga_buffer *sbuf)
+{
+   if(sbuf->handle) {
+      SVGA_DBG(DEBUG_DMA, " ungrab sid %p sz %d\n", sbuf->handle, sbuf->base.size);
+      svga_screen_surface_destroy(ss, &sbuf->key, &sbuf->handle);
+   }
+}   
+
+
+static INLINE void
+svga_buffer_destroy_hw_storage(struct svga_screen *ss, struct svga_buffer *sbuf)
+{
+   struct svga_winsys_screen *sws = ss->sws;
+
+   assert(!sbuf->map.count);
+   assert(sbuf->hw.buf);
+   if(sbuf->hw.buf) {
+      sws->buffer_destroy(sws, sbuf->hw.buf);
+      sbuf->hw.buf = NULL;
+      assert(sbuf->head.prev && sbuf->head.next);
+      LIST_DEL(&sbuf->head);
+#ifdef DEBUG
+      sbuf->head.next = sbuf->head.prev = NULL; 
+#endif
+   }
+}
+
+static INLINE enum pipe_error
+svga_buffer_backup(struct svga_screen *ss, struct svga_buffer *sbuf)
+{
+   if (sbuf->hw.buf && sbuf->hw.num_ranges) {
+      void *src;
+
+      if (!sbuf->swbuf)
+        sbuf->swbuf = align_malloc(sbuf->base.size, sbuf->base.alignment);
+      if (!sbuf->swbuf)
+        return PIPE_ERROR_OUT_OF_MEMORY;
+
+      src = ss->sws->buffer_map(ss->sws, sbuf->hw.buf,
+                               PIPE_BUFFER_USAGE_CPU_READ);
+      if (!src)
+        return PIPE_ERROR;
+
+      memcpy(sbuf->swbuf, src, sbuf->base.size);
+      ss->sws->buffer_unmap(ss->sws, sbuf->hw.buf);
+   }
+
+   return PIPE_OK;
+}
+
+/**
+ * Try to make GMR space available by freeing the hardware storage of 
+ * unmapped
+ */
+boolean
+svga_buffer_free_cached_hw_storage(struct svga_screen *ss)
+{
+   struct list_head *curr;
+   struct svga_buffer *sbuf;
+   enum pipe_error ret = PIPE_OK;
+
+   curr = ss->cached_buffers.prev;
+   
+   /* free the least recently used buffer's hw storage which is not mapped */
+   do {
+      if(curr == &ss->cached_buffers)
+         return FALSE;
+
+      sbuf = LIST_ENTRY(struct svga_buffer, curr, head);
+      
+      curr = curr->prev;
+      if (sbuf->map.count == 0)
+        ret = svga_buffer_backup(ss, sbuf);
+
+   } while(sbuf->map.count != 0 || ret != PIPE_OK);
+   
+   svga_buffer_destroy_hw_storage(ss, sbuf);
+   
+   return TRUE;
+}
+
+struct svga_winsys_buffer *
+svga_winsys_buffer_create( struct svga_screen *ss,
+                           unsigned alignment, 
+                           unsigned usage,
+                           unsigned size )
+{
+   struct svga_winsys_screen *sws = ss->sws;
+   struct svga_winsys_buffer *buf;
+   
+   /* Just try */
+   buf = sws->buffer_create(sws, alignment, usage, size);
+   if(!buf) {
+
+      SVGA_DBG(DEBUG_DMA|DEBUG_PERF, "flushing screen to find %d bytes GMR\n", 
+               size); 
+      
+      /* Try flushing all pending DMAs */
+      svga_screen_flush(ss, NULL);
+      buf = sws->buffer_create(sws, alignment, usage, size);
+
+      SVGA_DBG(DEBUG_DMA|DEBUG_PERF, "evicting buffers to find %d bytes GMR\n", 
+               size);
+
+      /* Try evicing all buffer storage */
+      while(!buf && svga_buffer_free_cached_hw_storage(ss))
+         buf = sws->buffer_create(sws, alignment, usage, size);
+   }
+   
+   return buf;
+}
+
+
+/**
+ * Allocate DMA'ble storage for the buffer. 
+ * 
+ * Called before mapping a buffer.
+ */
+static INLINE enum pipe_error
+svga_buffer_create_hw_storage(struct svga_screen *ss,
+                              struct svga_buffer *sbuf)
+{
+   if(!sbuf->hw.buf) {
+      unsigned alignment = sbuf->base.alignment;
+      unsigned usage = 0;
+      unsigned size = sbuf->base.size;
+      
+      sbuf->hw.buf = svga_winsys_buffer_create(ss, alignment, usage, size);
+      if(!sbuf->hw.buf)
+         return PIPE_ERROR_OUT_OF_MEMORY;
+      
+      assert(!sbuf->needs_flush);
+      assert(!sbuf->head.prev && !sbuf->head.next);
+      LIST_ADD(&sbuf->head, &ss->cached_buffers);
+   }
+   
+   return PIPE_OK;
+}
+
+
+/**
+ * Variant of SVGA3D_BufferDMA which leaves the copy box temporarily in blank.
+ */
+static enum pipe_error
+svga_buffer_upload_command(struct svga_context *svga,
+                           struct svga_buffer *sbuf)
+{
+   struct svga_winsys_context *swc = svga->swc;
+   struct svga_winsys_buffer *guest = sbuf->hw.buf;
+   struct svga_winsys_surface *host = sbuf->handle;
+   SVGA3dTransferType transfer = SVGA3D_WRITE_HOST_VRAM;
+   SVGA3dSurfaceDMAFlags flags = sbuf->hw.flags;
+   SVGA3dCmdSurfaceDMA *cmd;
+   uint32 numBoxes = sbuf->hw.num_ranges;
+   SVGA3dCopyBox *boxes;
+   SVGA3dCmdSurfaceDMASuffix *pSuffix;
+   unsigned region_flags;
+   unsigned surface_flags;
+   struct pipe_buffer *dummy;
+
+   if(transfer == SVGA3D_WRITE_HOST_VRAM) {
+      region_flags = PIPE_BUFFER_USAGE_GPU_READ;
+      surface_flags = PIPE_BUFFER_USAGE_GPU_WRITE;
+   }
+   else if(transfer == SVGA3D_READ_HOST_VRAM) {
+      region_flags = PIPE_BUFFER_USAGE_GPU_WRITE;
+      surface_flags = PIPE_BUFFER_USAGE_GPU_READ;
+   }
+   else {
+      assert(0);
+      return PIPE_ERROR_BAD_INPUT;
+   }
+
+   assert(numBoxes);
+
+   cmd = SVGA3D_FIFOReserve(swc,
+                            SVGA_3D_CMD_SURFACE_DMA,
+                            sizeof *cmd + numBoxes * sizeof *boxes + sizeof *pSuffix,
+                            2);
+   if(!cmd)
+      return PIPE_ERROR_OUT_OF_MEMORY;
+
+   swc->region_relocation(swc, &cmd->guest.ptr, guest, 0, region_flags);
+   cmd->guest.pitch = 0;
+
+   swc->surface_relocation(swc, &cmd->host.sid, host, surface_flags);
+   cmd->host.face = 0;
+   cmd->host.mipmap = 0;
+
+   cmd->transfer = transfer;
+
+   sbuf->hw.boxes = (SVGA3dCopyBox *)&cmd[1];
+   sbuf->hw.svga = svga;
+
+   /* Increment reference count */
+   dummy = NULL;
+   pipe_buffer_reference(&dummy, &sbuf->base);
+
+   pSuffix = (SVGA3dCmdSurfaceDMASuffix *)((uint8_t*)cmd + sizeof *cmd + numBoxes * sizeof *boxes);
+   pSuffix->suffixSize = sizeof *pSuffix;
+   pSuffix->maximumOffset = sbuf->base.size;
+   pSuffix->flags = flags;
+
+   swc->commit(swc);
+
+   return PIPE_OK;
+}
+
+
+/**
+ * Patch up the upload DMA command reserved by svga_buffer_upload_command
+ * with the final ranges.
+ */
+static void
+svga_buffer_upload_flush(struct svga_context *svga,
+                         struct svga_buffer *sbuf)
+{
+   struct svga_screen *ss = svga_screen(svga->pipe.screen);
+   SVGA3dCopyBox *boxes;
+   unsigned i;
+
+   assert(sbuf->handle); 
+   assert(sbuf->hw.buf);
+   assert(sbuf->hw.num_ranges);
+   assert(sbuf->hw.svga == svga);
+   assert(sbuf->hw.boxes);
+   
+   /*
+    * Patch the DMA command with the final copy box.
+    */
+
+   SVGA_DBG(DEBUG_DMA, "dma to sid %p\n", sbuf->handle);
+
+   boxes = sbuf->hw.boxes;
+   for(i = 0; i < sbuf->hw.num_ranges; ++i) {
+      SVGA_DBG(DEBUG_DMA, "  bytes %u - %u\n",
+               sbuf->hw.ranges[i].start, sbuf->hw.ranges[i].end);
+
+      boxes[i].x = sbuf->hw.ranges[i].start;
+      boxes[i].y = 0;
+      boxes[i].z = 0;
+      boxes[i].w = sbuf->hw.ranges[i].end - sbuf->hw.ranges[i].start;
+      boxes[i].h = 1;
+      boxes[i].d = 1;
+      boxes[i].srcx = sbuf->hw.ranges[i].start;
+      boxes[i].srcy = 0;
+      boxes[i].srcz = 0;
+   }
+
+   sbuf->hw.num_ranges = 0;
+   memset(&sbuf->hw.flags, 0, sizeof sbuf->hw.flags);
+
+   assert(sbuf->head.prev && sbuf->head.next);
+   LIST_DEL(&sbuf->head);
+   sbuf->needs_flush = FALSE;
+   /* XXX: do we care about cached_buffers any more ?*/
+   LIST_ADD(&sbuf->head, &ss->cached_buffers);
+
+   sbuf->hw.svga = NULL;
+   sbuf->hw.boxes = NULL;
+
+   /* Decrement reference count */
+   pipe_reference(&(sbuf->base.reference), NULL);
+   sbuf = NULL;
+}
+
+
+/**
+ * Queue a DMA upload of a range of this buffer to the host.
+ *
+ * This function only notes the range down. It doesn't actually emit a DMA
+ * upload command. That only happens when a context tries to refer to this
+ * buffer, and the DMA upload command is added to that context's command buffer.
+ * 
+ * We try to lump as many contiguous DMA transfers together as possible.
+ */
+static void
+svga_buffer_upload_queue(struct svga_buffer *sbuf,
+                         unsigned start,
+                         unsigned end)
+{
+   unsigned i;
+
+   assert(sbuf->hw.buf);
+   assert(end > start);
+   
+   /*
+    * Try to grow one of the ranges.
+    *
+    * Note that it is not this function task to care about overlapping ranges,
+    * as the GMR was already given so it is too late to do anything. Situations
+    * where overlapping ranges may pose a problem should be detected via
+    * pipe_context::is_buffer_referenced and the context that refers to the
+    * buffer should be flushed.
+    */
+
+   for(i = 0; i < sbuf->hw.num_ranges; ++i) {
+      if(start <= sbuf->hw.ranges[i].end && sbuf->hw.ranges[i].start <= end) {
+         sbuf->hw.ranges[i].start = MIN2(sbuf->hw.ranges[i].start, start);
+         sbuf->hw.ranges[i].end   = MAX2(sbuf->hw.ranges[i].end,    end);
+         return;
+      }
+   }
+
+   /*
+    * We cannot add a new range to an existing DMA command, so patch-up the
+    * pending DMA upload and start clean.
+    */
+
+   if(sbuf->needs_flush)
+      svga_buffer_upload_flush(sbuf->hw.svga, sbuf);
+
+   assert(!sbuf->needs_flush);
+   assert(!sbuf->hw.svga);
+   assert(!sbuf->hw.boxes);
+
+   /*
+    * Add a new range.
+    */
+
+   sbuf->hw.ranges[sbuf->hw.num_ranges].start = start;
+   sbuf->hw.ranges[sbuf->hw.num_ranges].end = end;
+   ++sbuf->hw.num_ranges;
+}
+
+
+static void *
+svga_buffer_map_range( struct pipe_screen *screen,
+                       struct pipe_buffer *buf,
+                       unsigned offset, unsigned length,
+                       unsigned usage )
+{
+   struct svga_screen *ss = svga_screen(screen); 
+   struct svga_winsys_screen *sws = ss->sws;
+   struct svga_buffer *sbuf = svga_buffer( buf );
+   void *map;
+
+   if(sbuf->swbuf) {
+      /* User/malloc buffer */
+      map = sbuf->swbuf;
+   }
+   else {
+      if(!sbuf->hw.buf) {
+         struct svga_winsys_surface *handle = sbuf->handle;
+
+         if(svga_buffer_create_hw_storage(ss, sbuf) != PIPE_OK)
+            return NULL;
+         
+         /* Populate the hardware storage if the host surface pre-existed */
+         if((usage & PIPE_BUFFER_USAGE_CPU_READ) && handle) {
+            SVGA3dSurfaceDMAFlags flags;
+            enum pipe_error ret;
+            struct pipe_fence_handle *fence = NULL;
+            
+            SVGA_DBG(DEBUG_DMA|DEBUG_PERF, "dma from sid %p (buffer), bytes %u - %u\n", 
+                     sbuf->handle, 0, sbuf->base.size);
+
+            memset(&flags, 0, sizeof flags);
+            
+            ret = SVGA3D_BufferDMA(ss->swc,
+                                   sbuf->hw.buf,
+                                   sbuf->handle,
+                                   SVGA3D_READ_HOST_VRAM,
+                                   sbuf->base.size,
+                                   0,
+                                   flags);
+            if(ret != PIPE_OK) {
+               ss->swc->flush(ss->swc, NULL);
+               
+               ret = SVGA3D_BufferDMA(ss->swc,
+                                      sbuf->hw.buf,
+                                      sbuf->handle,
+                                      SVGA3D_READ_HOST_VRAM,
+                                      sbuf->base.size,
+                                      0,
+                                      flags);
+               assert(ret == PIPE_OK);
+            }
+            
+            ss->swc->flush(ss->swc, &fence);
+            sws->fence_finish(sws, fence, 0);
+            sws->fence_reference(sws, &fence, NULL);
+         }
+      }
+      else {
+         if((usage & PIPE_BUFFER_USAGE_CPU_READ) && !sbuf->needs_flush) {
+            /* We already had the hardware storage but we would have to issue
+             * a download if we hadn't, so move the buffer to the begginning
+             * of the LRU list.
+             */
+            assert(sbuf->head.prev && sbuf->head.next);
+            LIST_DEL(&sbuf->head);
+            LIST_ADD(&sbuf->head, &ss->cached_buffers);
+         }
+      }
+         
+      map = sws->buffer_map(sws, sbuf->hw.buf, usage);
+   }
+
+   if(map) {
+      pipe_mutex_lock(ss->swc_mutex);
+
+      ++sbuf->map.count;
+
+      if (usage & PIPE_BUFFER_USAGE_CPU_WRITE) {
+         assert(sbuf->map.count <= 1);
+         sbuf->map.writing = TRUE;
+         if (usage & PIPE_BUFFER_USAGE_FLUSH_EXPLICIT)
+            sbuf->map.flush_explicit = TRUE;
+      }
+      
+      pipe_mutex_unlock(ss->swc_mutex);
+   }
+   
+   return map;
+}
+
+static void 
+svga_buffer_flush_mapped_range( struct pipe_screen *screen,
+                                struct pipe_buffer *buf,
+                                unsigned offset, unsigned length)
+{
+   struct svga_buffer *sbuf = svga_buffer( buf );
+   struct svga_screen *ss = svga_screen(screen);
+   
+   pipe_mutex_lock(ss->swc_mutex);
+   assert(sbuf->map.writing);
+   if(sbuf->map.writing) {
+      assert(sbuf->map.flush_explicit);
+      if(sbuf->hw.buf)
+         svga_buffer_upload_queue(sbuf, offset, offset + length);
+   }
+   pipe_mutex_unlock(ss->swc_mutex);
+}
+
+static void 
+svga_buffer_unmap( struct pipe_screen *screen,
+                   struct pipe_buffer *buf)
+{
+   struct svga_screen *ss = svga_screen(screen); 
+   struct svga_winsys_screen *sws = ss->sws;
+   struct svga_buffer *sbuf = svga_buffer( buf );
+   
+   pipe_mutex_lock(ss->swc_mutex);
+   
+   assert(sbuf->map.count);
+   if(sbuf->map.count)
+      --sbuf->map.count;
+
+   if(sbuf->hw.buf)
+      sws->buffer_unmap(sws, sbuf->hw.buf);
+
+   if(sbuf->map.writing) {
+      if(!sbuf->map.flush_explicit) {
+         /* No mapped range was flushed -- flush the whole buffer */
+         SVGA_DBG(DEBUG_DMA, "flushing the whole buffer\n");
+   
+         if(sbuf->hw.buf)
+            svga_buffer_upload_queue(sbuf, 0, sbuf->base.size);
+      }
+      
+      sbuf->map.writing = FALSE;
+      sbuf->map.flush_explicit = FALSE;
+   }
+
+   pipe_mutex_unlock(ss->swc_mutex);
+}
+
+static void
+svga_buffer_destroy( struct pipe_buffer *buf )
+{
+   struct svga_screen *ss = svga_screen(buf->screen); 
+   struct svga_buffer *sbuf = svga_buffer( buf );
+
+   assert(!p_atomic_read(&buf->reference.count));
+   
+   assert(!sbuf->needs_flush);
+
+   if(sbuf->handle) {
+      SVGA_DBG(DEBUG_DMA, "release sid %p sz %d\n", sbuf->handle, sbuf->base.size);
+      svga_screen_surface_destroy(ss, &sbuf->key, &sbuf->handle);
+   }
+   
+   if(sbuf->hw.buf)
+      svga_buffer_destroy_hw_storage(ss, sbuf);
+   
+   if(sbuf->swbuf && !sbuf->user)
+      align_free(sbuf->swbuf);
+   
+   FREE(sbuf);
+}
+
+static struct pipe_buffer *
+svga_buffer_create(struct pipe_screen *screen,
+                   unsigned alignment,
+                   unsigned usage,
+                   unsigned size)
+{
+   struct svga_screen *ss = svga_screen(screen);
+   struct svga_buffer *sbuf;
+   
+   sbuf = CALLOC_STRUCT(svga_buffer);
+   if(!sbuf)
+      goto error1;
+      
+   sbuf->magic = SVGA_BUFFER_MAGIC;
+   
+   pipe_reference_init(&sbuf->base.reference, 1);
+   sbuf->base.screen = screen;
+   sbuf->base.alignment = alignment;
+   sbuf->base.usage = usage;
+   sbuf->base.size = size;
+
+   if(svga_buffer_needs_hw_storage(usage)) {
+      if(svga_buffer_create_host_surface(ss, sbuf) != PIPE_OK)
+         goto error2;
+   }
+   else {
+      if(alignment < sizeof(void*))
+         alignment = sizeof(void*);
+
+      usage |= PIPE_BUFFER_USAGE_CPU_READ_WRITE;
+      
+      sbuf->swbuf = align_malloc(size, alignment);
+      if(!sbuf->swbuf)
+         goto error2;
+   }
+      
+   return &sbuf->base; 
+
+error2:
+   FREE(sbuf);
+error1:
+   return NULL;
+}
+
+static struct pipe_buffer *
+svga_user_buffer_create(struct pipe_screen *screen,
+                        void *ptr,
+                        unsigned bytes)
+{
+   struct svga_buffer *sbuf;
+   
+   sbuf = CALLOC_STRUCT(svga_buffer);
+   if(!sbuf)
+      goto no_sbuf;
+      
+   sbuf->magic = SVGA_BUFFER_MAGIC;
+   
+   sbuf->swbuf = ptr;
+   sbuf->user = TRUE;
+   
+   pipe_reference_init(&sbuf->base.reference, 1);
+   sbuf->base.screen = screen;
+   sbuf->base.alignment = 1;
+   sbuf->base.usage = 0;
+   sbuf->base.size = bytes;
+   
+   return &sbuf->base; 
+
+no_sbuf:
+   return NULL;
+}
+
+   
+void
+svga_screen_init_buffer_functions(struct pipe_screen *screen)
+{
+   screen->buffer_create = svga_buffer_create;
+   screen->user_buffer_create = svga_user_buffer_create;
+   screen->buffer_map_range = svga_buffer_map_range;
+   screen->buffer_flush_mapped_range = svga_buffer_flush_mapped_range;
+   screen->buffer_unmap = svga_buffer_unmap;
+   screen->buffer_destroy = svga_buffer_destroy;
+}
+
+
+/** 
+ * Copy the contents of the user buffer / malloc buffer to a hardware buffer.
+ */
+static INLINE enum pipe_error
+svga_buffer_update_hw(struct svga_screen *ss, struct svga_buffer *sbuf)
+{
+   if(!sbuf->hw.buf) {
+      enum pipe_error ret;
+      void *map;
+      
+      assert(sbuf->swbuf);
+      if(!sbuf->swbuf)
+         return PIPE_ERROR;
+      
+      ret = svga_buffer_create_hw_storage(ss, sbuf);
+      assert(ret == PIPE_OK);
+      if(ret != PIPE_OK)
+         return ret;
+
+      pipe_mutex_lock(ss->swc_mutex);
+      map = ss->sws->buffer_map(ss->sws, sbuf->hw.buf, PIPE_BUFFER_USAGE_CPU_WRITE);
+      assert(map);
+      if(!map) {
+        pipe_mutex_unlock(ss->swc_mutex);
+         return PIPE_ERROR_OUT_OF_MEMORY;
+      }
+
+      memcpy(map, sbuf->swbuf, sbuf->base.size);
+      ss->sws->buffer_unmap(ss->sws, sbuf->hw.buf);
+
+      /* This user/malloc buffer is now indistinguishable from a gpu buffer */
+      assert(!sbuf->map.count);
+      if(!sbuf->map.count) {
+         if(sbuf->user)
+            sbuf->user = FALSE;
+         else
+            align_free(sbuf->swbuf);
+         sbuf->swbuf = NULL;
+      }
+      
+      svga_buffer_upload_queue(sbuf, 0, sbuf->base.size);
+   }
+   
+   pipe_mutex_unlock(ss->swc_mutex);
+   return PIPE_OK;
+}
+
+
+struct svga_winsys_surface *
+svga_buffer_handle(struct svga_context *svga,
+                   struct pipe_buffer *buf)
+{
+   struct pipe_screen *screen = svga->pipe.screen;
+   struct svga_screen *ss = svga_screen(screen);
+   struct svga_buffer *sbuf;
+   enum pipe_error ret;
+
+   if(!buf)
+      return NULL;
+
+   sbuf = svga_buffer(buf);
+   
+   assert(!sbuf->map.count);
+   
+   if(!sbuf->handle) {
+      ret = svga_buffer_create_host_surface(ss, sbuf);
+      if(ret != PIPE_OK)
+        return NULL;
+
+      ret = svga_buffer_update_hw(ss, sbuf);
+      if(ret != PIPE_OK)
+        return NULL;
+   }
+
+   if(!sbuf->needs_flush && sbuf->hw.num_ranges) {
+      /* Queue the buffer for flushing */
+      ret = svga_buffer_upload_command(svga, sbuf);
+      if(ret != PIPE_OK)
+         /* XXX: Should probably have a richer return value */
+         return NULL;
+
+      assert(sbuf->hw.svga == svga);
+
+      sbuf->needs_flush = TRUE;
+      assert(sbuf->head.prev && sbuf->head.next);
+      LIST_DEL(&sbuf->head);
+      LIST_ADDTAIL(&sbuf->head, &svga->dirty_buffers);
+   }
+
+   return sbuf->handle;
+}
+
+struct pipe_buffer *
+svga_screen_buffer_wrap_surface(struct pipe_screen *screen,
+                               enum SVGA3dSurfaceFormat format,
+                               struct svga_winsys_surface *srf)
+{
+   struct pipe_buffer *buf;
+   struct svga_buffer *sbuf;
+   struct svga_winsys_screen *sws = svga_winsys_screen(screen);
+
+   buf = svga_buffer_create(screen, 0, SVGA_BUFFER_USAGE_WRAPPED, 0);
+   if (!buf)
+      return NULL;
+
+   sbuf = svga_buffer(buf);
+
+   /*
+    * We are not the creator of this surface and therefore we must not
+    * cache it for reuse. Set the cacheable flag to zero in the key to
+    * prevent this.
+    */
+   sbuf->key.format = format;
+   sbuf->key.cachable = 0;
+   sws->surface_reference(sws, &sbuf->handle, srf);
+
+   return buf;
+}
+
+
+struct svga_winsys_surface *
+svga_screen_buffer_get_winsys_surface(struct pipe_buffer *buffer)
+{
+   struct svga_winsys_screen *sws = svga_winsys_screen(buffer->screen);
+   struct svga_winsys_surface *vsurf = NULL;
+
+   assert(svga_buffer(buffer)->key.cachable == 0);
+   svga_buffer(buffer)->key.cachable = 0;
+   sws->surface_reference(sws, &vsurf, svga_buffer(buffer)->handle);
+   return vsurf;
+}
+
+void
+svga_context_flush_buffers(struct svga_context *svga)
+{
+   struct list_head *curr, *next;
+   struct svga_buffer *sbuf;
+
+   curr = svga->dirty_buffers.next;
+   next = curr->next;
+   while(curr != &svga->dirty_buffers) {
+      sbuf = LIST_ENTRY(struct svga_buffer, curr, head);
+
+      assert(p_atomic_read(&sbuf->base.reference.count) != 0);
+      assert(sbuf->needs_flush);
+      
+      svga_buffer_upload_flush(svga, sbuf);
+
+      curr = next; 
+      next = curr->next;
+   }
+}
diff --git a/src/gallium/drivers/svga/svga_screen_buffer.h b/src/gallium/drivers/svga/svga_screen_buffer.h
new file mode 100644 (file)
index 0000000..5d7af5a
--- /dev/null
@@ -0,0 +1,190 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#ifndef SVGA_BUFFER_H
+#define SVGA_BUFFER_H
+
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_state.h"
+
+#include "util/u_double_list.h"
+
+#include "svga_screen_cache.h"
+
+
+#define SVGA_BUFFER_MAGIC 0x344f9005
+
+/**
+ * Maximum number of discontiguous ranges
+ */
+#define SVGA_BUFFER_MAX_RANGES 32
+
+
+struct svga_screen;
+struct svga_context;
+struct svga_winsys_buffer;
+struct svga_winsys_surface;
+
+
+struct svga_buffer_range
+{
+   unsigned start;
+   unsigned end;
+};
+
+
+/**
+ * Describe a
+ *
+ * This holds the information to emit a SVGA3dCmdSurfaceDMA.
+ */
+struct svga_buffer_upload
+{
+   /**
+    * Guest memory region.
+    */
+   struct svga_winsys_buffer *buf;
+
+   struct svga_buffer_range ranges[SVGA_BUFFER_MAX_RANGES];
+   unsigned num_ranges;
+
+   SVGA3dSurfaceDMAFlags flags;
+
+   /**
+    * Pointer to the DMA copy box *inside* the command buffer.
+    */
+   SVGA3dCopyBox *boxes;
+
+   /**
+    * Context that has the pending DMA to this buffer.
+    */
+   struct svga_context *svga;
+};
+
+
+/**
+ * SVGA pipe buffer.
+ */
+struct svga_buffer 
+{
+   struct pipe_buffer base;
+
+   /** 
+    * Marker to detect bad casts in runtime.
+    */ 
+   uint32_t magic;
+
+   /**
+    * Regular (non DMA'able) memory.
+    * 
+    * Used for user buffers or for buffers which we know before hand that can
+    * never be used by the virtual hardware directly, such as constant buffers.
+    */
+   void *swbuf;
+   
+   /** 
+    * Whether swbuf was created by the user or not.
+    */
+   boolean user;
+   
+   /**
+    * DMA'ble memory.
+    * 
+    * A piece of GMR memory. It is created when mapping the buffer, and will be
+    * used to upload/download vertex data from the host.
+    */
+   struct svga_buffer_upload hw;
+
+   /**
+    * Creation key for the host surface handle.
+    * 
+    * This structure describes all the host surface characteristics so that it 
+    * can be looked up in cache, since creating a host surface is often a slow
+    * operation.
+    */
+   struct svga_host_surface_cache_key key;
+   
+   /**
+    * Host surface handle.
+    * 
+    * This is a platform independent abstraction for host SID. We create when 
+    * trying to bind
+    */
+   struct svga_winsys_surface *handle;
+   
+   struct {
+      unsigned count;
+      boolean writing;
+      boolean flush_explicit;
+   } map;
+   
+   boolean needs_flush;
+   struct list_head head;
+};
+
+
+static INLINE struct svga_buffer *
+svga_buffer(struct pipe_buffer *buffer)
+{
+   if (buffer) {
+      assert(((struct svga_buffer *)buffer)->magic == SVGA_BUFFER_MAGIC);
+      return (struct svga_buffer *)buffer;
+   }
+   return NULL;
+}
+
+
+/**
+ * Returns TRUE for user buffers.  We may
+ * decide to use an alternate upload path for these buffers.
+ */
+static INLINE boolean 
+svga_buffer_is_user_buffer( struct pipe_buffer *buffer )
+{
+   return svga_buffer(buffer)->user;
+}
+
+
+void
+svga_screen_init_buffer_functions(struct pipe_screen *screen);
+
+struct svga_winsys_surface *
+svga_buffer_handle(struct svga_context *svga,
+                   struct pipe_buffer *buf);
+
+void
+svga_context_flush_buffers(struct svga_context *svga);
+
+boolean
+svga_buffer_free_cached_hw_storage(struct svga_screen *ss);
+
+struct svga_winsys_buffer *
+svga_winsys_buffer_create(struct svga_screen *ss,
+                          unsigned alignment, 
+                          unsigned usage,
+                          unsigned size);
+
+#endif /* SVGA_BUFFER_H */
diff --git a/src/gallium/drivers/svga/svga_screen_cache.c b/src/gallium/drivers/svga/svga_screen_cache.c
new file mode 100644 (file)
index 0000000..eff36e0
--- /dev/null
@@ -0,0 +1,347 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "util/u_memory.h"
+#include "util/u_hash.h"
+
+#include "svga_debug.h"
+#include "svga_winsys.h"
+#include "svga_screen.h"
+#include "svga_screen_cache.h"
+
+
+#define SVGA_SURFACE_CACHE_ENABLED 1
+
+
+/** 
+ * Compute the bucket for this key. 
+ */
+static INLINE unsigned
+svga_screen_cache_bucket(const struct svga_host_surface_cache_key *key)
+{
+   return util_hash_crc32( key, sizeof *key ) % SVGA_HOST_SURFACE_CACHE_BUCKETS;
+}
+
+
+static INLINE struct svga_winsys_surface *
+svga_screen_cache_lookup(struct svga_screen *svgascreen,
+                         const struct svga_host_surface_cache_key *key)
+{
+   struct svga_host_surface_cache *cache = &svgascreen->cache;
+   struct svga_winsys_screen *sws = svgascreen->sws;
+   struct svga_host_surface_cache_entry *entry;
+   struct svga_winsys_surface *handle = NULL;
+   struct list_head *curr, *next;
+   unsigned bucket;
+   unsigned tries = 0;
+
+   assert(key->cachable);
+
+   bucket = svga_screen_cache_bucket(key);
+
+   pipe_mutex_lock(cache->mutex);
+
+   curr = cache->bucket[bucket].next;
+   next = curr->next;
+   while(curr != &cache->bucket[bucket]) {
+      ++tries;
+      
+      entry = LIST_ENTRY(struct svga_host_surface_cache_entry, curr, bucket_head);
+
+      assert(entry->handle);
+      
+      if(memcmp(&entry->key, key, sizeof *key) == 0 &&
+         sws->fence_signalled( sws, entry->fence, 0 ) == 0) {
+         assert(sws->surface_is_flushed(sws, entry->handle));
+         
+         handle = entry->handle; // Reference is transfered here.
+         entry->handle = NULL;
+         
+         LIST_DEL(&entry->bucket_head);
+
+         LIST_DEL(&entry->head);
+         
+         LIST_ADD(&entry->head, &cache->empty);
+
+         break;
+      }
+
+      curr = next; 
+      next = curr->next;
+   }
+
+   pipe_mutex_unlock(cache->mutex);
+   
+   if (SVGA_DEBUG & DEBUG_DMA)
+      debug_printf("%s: cache %s after %u tries (bucket %d)\n", __FUNCTION__, 
+                   handle ? "hit" : "miss", tries, bucket);
+   
+   return handle;
+}
+
+
+/*
+ * Transfers a handle reference.
+ */
+                           
+static INLINE void
+svga_screen_cache_add(struct svga_screen *svgascreen,
+                      const struct svga_host_surface_cache_key *key, 
+                      struct svga_winsys_surface **p_handle)
+{
+   struct svga_host_surface_cache *cache = &svgascreen->cache;
+   struct svga_winsys_screen *sws = svgascreen->sws;
+   struct svga_host_surface_cache_entry *entry = NULL;
+   struct svga_winsys_surface *handle = *p_handle;
+   
+   assert(key->cachable);
+
+   assert(handle);
+   if(!handle)
+      return;
+   
+   *p_handle = NULL;
+   pipe_mutex_lock(cache->mutex);
+   
+   if(!LIST_IS_EMPTY(&cache->empty)) {
+      /* use the first empty entry */
+      entry = LIST_ENTRY(struct svga_host_surface_cache_entry, cache->empty.next, head);
+        
+      LIST_DEL(&entry->head);
+   }
+   else if(!LIST_IS_EMPTY(&cache->unused)) {
+      /* free the last used buffer and reuse its entry */
+      entry = LIST_ENTRY(struct svga_host_surface_cache_entry, cache->unused.prev, head);
+      SVGA_DBG(DEBUG_CACHE|DEBUG_DMA,
+               "unref sid %p (make space)\n", entry->handle);
+      sws->surface_reference(sws, &entry->handle, NULL);
+
+      LIST_DEL(&entry->bucket_head);
+
+      LIST_DEL(&entry->head);
+   }
+
+   if(entry) {
+      entry->handle = handle;
+      memcpy(&entry->key, key, sizeof entry->key);
+   
+      SVGA_DBG(DEBUG_CACHE|DEBUG_DMA,
+               "cache sid %p\n", entry->handle);
+      LIST_ADD(&entry->head, &cache->validated);
+   }
+   else {
+      /* Couldn't cache the buffer -- this really shouldn't happen */
+      SVGA_DBG(DEBUG_CACHE|DEBUG_DMA,
+               "unref sid %p (couldn't find space)\n", handle);
+      sws->surface_reference(sws, &handle, NULL);
+   }
+   
+   pipe_mutex_unlock(cache->mutex);
+}
+
+
+/**
+ * Called during the screen flush to move all buffers not in a validate list
+ * into the unused list.
+ */
+void
+svga_screen_cache_flush(struct svga_screen *svgascreen,
+                        struct pipe_fence_handle *fence)
+{
+   struct svga_host_surface_cache *cache = &svgascreen->cache;
+   struct svga_winsys_screen *sws = svgascreen->sws;
+   struct svga_host_surface_cache_entry *entry;
+   struct list_head *curr, *next;
+   unsigned bucket;
+
+   pipe_mutex_lock(cache->mutex);
+
+   curr = cache->validated.next;
+   next = curr->next;
+   while(curr != &cache->validated) {
+      entry = LIST_ENTRY(struct svga_host_surface_cache_entry, curr, head);
+
+      assert(entry->handle);
+
+      if(sws->surface_is_flushed(sws, entry->handle)) {
+         LIST_DEL(&entry->head);
+         
+         svgascreen->sws->fence_reference(svgascreen->sws, &entry->fence, fence);
+
+         LIST_ADD(&entry->head, &cache->unused);
+
+         bucket = svga_screen_cache_bucket(&entry->key);
+         LIST_ADD(&entry->bucket_head, &cache->bucket[bucket]);
+      }
+
+      curr = next; 
+      next = curr->next;
+   }
+
+   pipe_mutex_unlock(cache->mutex);
+}
+
+
+void
+svga_screen_cache_cleanup(struct svga_screen *svgascreen)
+{
+   struct svga_host_surface_cache *cache = &svgascreen->cache;
+   struct svga_winsys_screen *sws = svgascreen->sws;
+   unsigned i;
+   
+   for(i = 0; i < SVGA_HOST_SURFACE_CACHE_SIZE; ++i) {
+      if(cache->entries[i].handle) {
+        SVGA_DBG(DEBUG_CACHE|DEBUG_DMA,
+                  "unref sid %p (shutdown)\n", cache->entries[i].handle);
+        sws->surface_reference(sws, &cache->entries[i].handle, NULL);
+      }
+
+      if(cache->entries[i].fence)
+         svgascreen->sws->fence_reference(svgascreen->sws, &cache->entries[i].fence, NULL);
+   }
+   
+   pipe_mutex_destroy(cache->mutex);
+}
+
+
+enum pipe_error
+svga_screen_cache_init(struct svga_screen *svgascreen)
+{
+   struct svga_host_surface_cache *cache = &svgascreen->cache;
+   unsigned i;
+
+   pipe_mutex_init(cache->mutex);
+   
+   for(i = 0; i < SVGA_HOST_SURFACE_CACHE_BUCKETS; ++i)
+      LIST_INITHEAD(&cache->bucket[i]);
+
+   LIST_INITHEAD(&cache->unused);
+   
+   LIST_INITHEAD(&cache->validated);
+   
+   LIST_INITHEAD(&cache->empty);
+   for(i = 0; i < SVGA_HOST_SURFACE_CACHE_SIZE; ++i)
+      LIST_ADDTAIL(&cache->entries[i].head, &cache->empty);
+
+   return PIPE_OK;
+}
+
+                           
+struct svga_winsys_surface *
+svga_screen_surface_create(struct svga_screen *svgascreen,
+                           struct svga_host_surface_cache_key *key)
+{
+   struct svga_winsys_screen *sws = svgascreen->sws;
+   struct svga_winsys_surface *handle = NULL;
+   boolean cachable = SVGA_SURFACE_CACHE_ENABLED && key->cachable;
+
+   SVGA_DBG(DEBUG_CACHE|DEBUG_DMA,
+            "%s sz %dx%dx%d mips %d faces %d cachable %d\n", 
+            __FUNCTION__,
+            key->size.width,
+            key->size.height,
+            key->size.depth,
+            key->numMipLevels,
+            key->numFaces,
+            key->cachable);
+
+   if (cachable) {
+      if (key->format == SVGA3D_BUFFER) {
+         /* For buffers, round the buffer size up to the nearest power
+          * of two to increase the probability of cache hits.  Keep
+          * texture surface dimensions unchanged.
+          */
+         uint32_t size = 1;
+         while(size < key->size.width)
+            size <<= 1;
+         key->size.width = size;
+        /* Since we're reusing buffers we're effectively transforming all
+         * of them into dynamic buffers.
+         *
+         * It would be nice to not cache long lived static buffers. But there
+         * is no way to detect the long lived from short lived ones yet. A
+         * good heuristic would be buffer size.
+         */
+        key->flags &= ~SVGA3D_SURFACE_HINT_STATIC;
+        key->flags |= SVGA3D_SURFACE_HINT_DYNAMIC;
+      }
+
+      handle = svga_screen_cache_lookup(svgascreen, key);
+      if (handle) {
+         if (key->format == SVGA3D_BUFFER)
+            SVGA_DBG(DEBUG_CACHE|DEBUG_DMA,
+                     "reuse sid %p sz %d (buffer)\n", handle, 
+                     key->size.width);
+         else
+            SVGA_DBG(DEBUG_CACHE|DEBUG_DMA,
+                     "reuse sid %p sz %dx%dx%d mips %d faces %d\n", handle, 
+                     key->size.width,
+                     key->size.height,
+                     key->size.depth,
+                     key->numMipLevels,
+                     key->numFaces);
+      }
+   }
+
+   if (!handle) {
+      handle = sws->surface_create(sws,
+                                   key->flags,
+                                   key->format,
+                                   key->size, 
+                                   key->numFaces, 
+                                   key->numMipLevels);
+      if (handle)
+         SVGA_DBG(DEBUG_CACHE|DEBUG_DMA,
+                  "  CREATE sid %p sz %dx%dx%d\n", 
+                  handle, 
+                  key->size.width,
+                  key->size.height,
+                  key->size.depth);
+   }
+
+   return handle;
+}
+
+
+void
+svga_screen_surface_destroy(struct svga_screen *svgascreen,
+                            const struct svga_host_surface_cache_key *key,
+                            struct svga_winsys_surface **p_handle)
+{
+   struct svga_winsys_screen *sws = svgascreen->sws;
+   
+   /* We only set the cachable flag for surfaces of which we are the
+    * exclusive owner.  So just hold onto our existing reference in
+    * that case.
+    */
+   if(SVGA_SURFACE_CACHE_ENABLED && key->cachable) {
+      svga_screen_cache_add(svgascreen, key, p_handle);
+   }
+   else {
+      SVGA_DBG(DEBUG_DMA,
+               "unref sid %p (uncachable)\n", *p_handle);
+      sws->surface_reference(sws, p_handle, NULL);
+   }
+}
diff --git a/src/gallium/drivers/svga/svga_screen_cache.h b/src/gallium/drivers/svga/svga_screen_cache.h
new file mode 100644 (file)
index 0000000..f5aa740
--- /dev/null
@@ -0,0 +1,144 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#ifndef SVGA_SCREEN_CACHE_H_
+#define SVGA_SCREEN_CACHE_H_
+
+
+#include "svga_types.h"
+#include "svga_reg.h"
+#include "svga3d_reg.h"
+
+#include "pipe/p_thread.h"
+
+#include "util/u_double_list.h"
+
+
+/* Guess the storage size of cached surfaces and try and keep it under
+ * this amount:
+ */ 
+#define SVGA_HOST_SURFACE_CACHE_BYTES 16*1024*1024
+
+/* Maximum number of discrete surfaces in the cache:
+ */
+#define SVGA_HOST_SURFACE_CACHE_SIZE 1024
+
+/* Number of hash buckets:
+ */
+#define SVGA_HOST_SURFACE_CACHE_BUCKETS 256
+
+
+struct svga_winsys_surface;
+struct svga_screen;
+
+/**
+ * Same as svga_winsys_screen::surface_create.
+ */
+struct svga_host_surface_cache_key
+{
+   SVGA3dSurfaceFlags flags;
+   SVGA3dSurfaceFormat format;
+   SVGA3dSize size;
+   uint32_t numFaces:24;
+   uint32_t numMipLevels:7;
+   uint32_t cachable:1;         /* False if this is a shared surface */
+};
+
+
+struct svga_host_surface_cache_entry 
+{
+   /** 
+    * Head for the LRU list, svga_host_surface_cache::unused, and
+    * svga_host_surface_cache::empty
+    */
+   struct list_head head;
+   
+   /** Head for the bucket lists. */
+   struct list_head bucket_head;
+
+   struct svga_host_surface_cache_key key;
+   struct svga_winsys_surface *handle;
+   
+   struct pipe_fence_handle *fence;
+};
+
+
+/**
+ * Cache of the host surfaces.
+ * 
+ * A cache entry can be in the following stages:
+ * 1. empty
+ * 2. holding a buffer in a validate list
+ * 3. holding a flushed buffer (not in any validate list) with an active fence
+ * 4. holding a flushed buffer with an expired fence
+ * 
+ * An entry progresses from 1 -> 2 -> 3 -> 4. When we need an entry to put a 
+ * buffer into we preferencial take from 1, or from the least recentely used 
+ * buffer from 3/4.
+ */
+struct svga_host_surface_cache 
+{
+   pipe_mutex mutex;
+   
+   /* Unused buffers are put in buckets to speed up lookups */
+   struct list_head bucket[SVGA_HOST_SURFACE_CACHE_BUCKETS];
+   
+   /* Entries with unused buffers, ordered from most to least recently used 
+    * (3 and 4) */
+   struct list_head unused;
+   
+   /* Entries with buffers still in validate lists (2) */
+   struct list_head validated;
+   
+   /** Empty entries (1) */
+   struct list_head empty;
+
+   /** The actual storage for the entries */
+   struct svga_host_surface_cache_entry entries[SVGA_HOST_SURFACE_CACHE_SIZE];
+};
+
+
+void
+svga_screen_cache_cleanup(struct svga_screen *svgascreen);
+
+void
+svga_screen_cache_flush(struct svga_screen *svgascreen,
+                        struct pipe_fence_handle *fence);
+
+enum pipe_error
+svga_screen_cache_init(struct svga_screen *svgascreen);
+
+
+struct svga_winsys_surface *
+svga_screen_surface_create(struct svga_screen *svgascreen,
+                           struct svga_host_surface_cache_key *key);
+
+void
+svga_screen_surface_destroy(struct svga_screen *svgascreen,
+                            const struct svga_host_surface_cache_key *key,
+                            struct svga_winsys_surface **handle);
+
+
+#endif /* SVGA_SCREEN_CACHE_H_ */
diff --git a/src/gallium/drivers/svga/svga_screen_texture.c b/src/gallium/drivers/svga/svga_screen_texture.c
new file mode 100644 (file)
index 0000000..2224c2d
--- /dev/null
@@ -0,0 +1,1090 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "svga_cmd.h"
+
+#include "pipe/p_state.h"
+#include "pipe/p_defines.h"
+#include "pipe/p_inlines.h"
+#include "pipe/p_thread.h"
+#include "util/u_format.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
+#include "svga_screen.h"
+#include "svga_context.h"
+#include "svga_screen_texture.h"
+#include "svga_screen_buffer.h"
+#include "svga_winsys.h"
+#include "svga_debug.h"
+#include "svga_screen_buffer.h"
+
+#include <util/u_string.h>
+
+
+/* XXX: This isn't a real hardware flag, but just a hack for kernel to
+ * know about primary surfaces. Find a better way to accomplish this.
+ */
+#define SVGA3D_SURFACE_HINT_SCANOUT (1 << 9)
+
+
+/*
+ * Helper function and arrays
+ */
+
+SVGA3dSurfaceFormat
+svga_translate_format(enum pipe_format format)
+{
+   switch(format) {
+   
+   case PIPE_FORMAT_A8R8G8B8_UNORM:
+      return SVGA3D_A8R8G8B8;
+   case PIPE_FORMAT_X8R8G8B8_UNORM:
+      return SVGA3D_X8R8G8B8;
+
+      /* Required for GL2.1:
+       */
+   case PIPE_FORMAT_A8R8G8B8_SRGB:
+      return SVGA3D_A8R8G8B8;
+
+   case PIPE_FORMAT_R5G6B5_UNORM:
+      return SVGA3D_R5G6B5;
+   case PIPE_FORMAT_A1R5G5B5_UNORM:
+      return SVGA3D_A1R5G5B5;
+   case PIPE_FORMAT_A4R4G4B4_UNORM:
+      return SVGA3D_A4R4G4B4;
+
+      
+   /* XXX: Doesn't seem to work properly.
+   case PIPE_FORMAT_Z32_UNORM:
+      return SVGA3D_Z_D32;
+    */
+   case PIPE_FORMAT_Z16_UNORM:
+      return SVGA3D_Z_D16;
+   case PIPE_FORMAT_Z24S8_UNORM:
+      return SVGA3D_Z_D24S8;
+   case PIPE_FORMAT_Z24X8_UNORM:
+      return SVGA3D_Z_D24X8;
+
+   case PIPE_FORMAT_A8_UNORM:
+      return SVGA3D_ALPHA8;
+   case PIPE_FORMAT_L8_UNORM:
+      return SVGA3D_LUMINANCE8;
+
+   case PIPE_FORMAT_DXT1_RGB:
+   case PIPE_FORMAT_DXT1_RGBA:
+      return SVGA3D_DXT1;
+   case PIPE_FORMAT_DXT3_RGBA:
+      return SVGA3D_DXT3;
+   case PIPE_FORMAT_DXT5_RGBA:
+      return SVGA3D_DXT5;
+
+   default:
+      return SVGA3D_FORMAT_INVALID;
+   }
+}
+
+
+SVGA3dSurfaceFormat
+svga_translate_format_render(enum pipe_format format)
+{
+   switch(format) { 
+   case PIPE_FORMAT_A8R8G8B8_UNORM:
+   case PIPE_FORMAT_X8R8G8B8_UNORM:
+   case PIPE_FORMAT_A1R5G5B5_UNORM:
+   case PIPE_FORMAT_A4R4G4B4_UNORM:
+   case PIPE_FORMAT_R5G6B5_UNORM:
+   case PIPE_FORMAT_Z24S8_UNORM:
+   case PIPE_FORMAT_Z24X8_UNORM:
+   case PIPE_FORMAT_Z32_UNORM:
+   case PIPE_FORMAT_Z16_UNORM:
+   case PIPE_FORMAT_L8_UNORM:
+      return svga_translate_format(format);
+
+#if 1
+   /* For on host conversion */
+   case PIPE_FORMAT_DXT1_RGB:
+      return SVGA3D_X8R8G8B8;
+   case PIPE_FORMAT_DXT1_RGBA:
+   case PIPE_FORMAT_DXT3_RGBA:
+   case PIPE_FORMAT_DXT5_RGBA:
+      return SVGA3D_A8R8G8B8;
+#endif
+
+   default:
+      return SVGA3D_FORMAT_INVALID;
+   }
+}
+
+
+static INLINE void
+svga_transfer_dma_band(struct svga_transfer *st,
+                       SVGA3dTransferType transfer,
+                       unsigned y, unsigned h, unsigned srcy)
+{
+   struct svga_texture *texture = svga_texture(st->base.texture); 
+   struct svga_screen *screen = svga_screen(texture->base.screen);
+   SVGA3dCopyBox box;
+   enum pipe_error ret;
+   
+   SVGA_DBG(DEBUG_DMA, "dma %s sid %p, face %u, (%u, %u, %u) - (%u, %u, %u), %ubpp\n",
+                transfer == SVGA3D_WRITE_HOST_VRAM ? "to" : "from", 
+                texture->handle,
+                st->base.face,
+                st->base.x,
+                y,
+                st->base.zslice,
+                st->base.x + st->base.width,
+                y + h,
+                st->base.zslice + 1,
+                util_format_get_blocksize(texture->base.format)*8/
+                (util_format_get_blockwidth(texture->base.format)*util_format_get_blockheight(texture->base.format)));
+   
+   box.x = st->base.x;
+   box.y = y;
+   box.z = st->base.zslice;
+   box.w = st->base.width;
+   box.h = h;
+   box.d = 1;
+   box.srcx = 0;
+   box.srcy = srcy;
+   box.srcz = 0;
+
+   pipe_mutex_lock(screen->swc_mutex);
+   ret = SVGA3D_SurfaceDMA(screen->swc, st, transfer, &box, 1);
+   if(ret != PIPE_OK) {
+      screen->swc->flush(screen->swc, NULL);
+      ret = SVGA3D_SurfaceDMA(screen->swc, st, transfer, &box, 1);
+      assert(ret == PIPE_OK);
+   }
+   pipe_mutex_unlock(screen->swc_mutex);
+}
+
+
+static INLINE void
+svga_transfer_dma(struct svga_transfer *st,
+                 SVGA3dTransferType transfer)
+{
+   struct svga_texture *texture = svga_texture(st->base.texture); 
+   struct svga_screen *screen = svga_screen(texture->base.screen);
+   struct svga_winsys_screen *sws = screen->sws;
+   struct pipe_fence_handle *fence = NULL;
+   
+   if (transfer == SVGA3D_READ_HOST_VRAM) {
+      SVGA_DBG(DEBUG_PERF, "%s: readback transfer\n", __FUNCTION__);
+   }
+
+
+   if(!st->swbuf) {
+      /* Do the DMA transfer in a single go */
+      
+      svga_transfer_dma_band(st, transfer, st->base.y, st->base.height, 0);
+
+      if(transfer == SVGA3D_READ_HOST_VRAM) {
+         svga_screen_flush(screen, &fence);
+         sws->fence_finish(sws, fence, 0);
+         //sws->fence_reference(sws, &fence, NULL);
+      }
+   }
+   else {
+      unsigned y, h, srcy;
+      unsigned blockheight = util_format_get_blockheight(st->base.texture->format);
+      h = st->hw_nblocksy * blockheight;
+      srcy = 0;
+      for(y = 0; y < st->base.height; y += h) {
+         unsigned offset, length;
+         void *hw, *sw;
+
+         if (y + h > st->base.height)
+            h = st->base.height - y;
+
+         /* Transfer band must be aligned to pixel block boundaries */
+         assert(y % blockheight == 0);
+         assert(h % blockheight == 0);
+         
+         offset = y * st->base.stride / blockheight;
+         length = h * st->base.stride / blockheight;
+
+         sw = (uint8_t *)st->swbuf + offset;
+         
+         if(transfer == SVGA3D_WRITE_HOST_VRAM) {
+            /* Wait for the previous DMAs to complete */
+            /* TODO: keep one DMA (at half the size) in the background */
+            if(y) {
+               svga_screen_flush(screen, &fence);
+               sws->fence_finish(sws, fence, 0);
+               //sws->fence_reference(sws, &fence, NULL);
+            }
+
+            hw = sws->buffer_map(sws, st->hwbuf, PIPE_BUFFER_USAGE_CPU_WRITE);
+            assert(hw);
+            if(hw) {
+               memcpy(hw, sw, length);
+               sws->buffer_unmap(sws, st->hwbuf);
+            }
+         }
+         
+         svga_transfer_dma_band(st, transfer, y, h, srcy);
+         
+         if(transfer == SVGA3D_READ_HOST_VRAM) {
+            svga_screen_flush(screen, &fence);
+            sws->fence_finish(sws, fence, 0);
+
+            hw = sws->buffer_map(sws, st->hwbuf, PIPE_BUFFER_USAGE_CPU_READ);
+            assert(hw);
+            if(hw) {
+               memcpy(sw, hw, length);
+               sws->buffer_unmap(sws, st->hwbuf);
+            }
+         }
+      }
+   }
+}
+
+
+static struct pipe_texture *
+svga_texture_create(struct pipe_screen *screen,
+                    const struct pipe_texture *templat)
+{
+   struct svga_screen *svgascreen = svga_screen(screen);
+   struct svga_texture *tex = CALLOC_STRUCT(svga_texture);
+   unsigned width, height, depth;
+   unsigned level;
+   
+   if (!tex)
+      goto error1;
+
+   tex->base = *templat;
+   pipe_reference_init(&tex->base.reference, 1);
+   tex->base.screen = screen;
+
+   assert(templat->last_level < SVGA_MAX_TEXTURE_LEVELS);
+   if(templat->last_level >= SVGA_MAX_TEXTURE_LEVELS)
+      goto error2;
+   
+   width = templat->width0;
+   height = templat->height0;
+   depth = templat->depth0;
+   for(level = 0; level <= templat->last_level; ++level) {
+      width = u_minify(width, 1);
+      height = u_minify(height, 1);
+      depth = u_minify(depth, 1);
+   }
+   
+   tex->key.flags = 0;
+   tex->key.size.width = templat->width0;
+   tex->key.size.height = templat->height0;
+   tex->key.size.depth = templat->depth0;
+   
+   if(templat->target == PIPE_TEXTURE_CUBE) {
+      tex->key.flags |= SVGA3D_SURFACE_CUBEMAP;
+      tex->key.numFaces = 6;
+   }
+   else {
+      tex->key.numFaces = 1;
+   }
+
+   if(templat->tex_usage & PIPE_TEXTURE_USAGE_SAMPLER)
+      tex->key.flags |= SVGA3D_SURFACE_HINT_TEXTURE;
+
+   if(templat->tex_usage & PIPE_TEXTURE_USAGE_PRIMARY)
+      tex->key.flags |= SVGA3D_SURFACE_HINT_SCANOUT;
+   
+   /* 
+    * XXX: Never pass the SVGA3D_SURFACE_HINT_RENDERTARGET hint. Mesa cannot
+    * know beforehand whether a texture will be used as a rendertarget or not
+    * and it always requests PIPE_TEXTURE_USAGE_RENDER_TARGET, therefore
+    * passing the SVGA3D_SURFACE_HINT_RENDERTARGET here defeats its purpose.
+    */
+#if 0
+   if((templat->tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) &&
+      !util_format_is_compressed(templat->format))
+      tex->key.flags |= SVGA3D_SURFACE_HINT_RENDERTARGET;
+#endif
+   
+   if(templat->tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL)
+      tex->key.flags |= SVGA3D_SURFACE_HINT_DEPTHSTENCIL;
+   
+   tex->key.numMipLevels = templat->last_level + 1;
+   
+   tex->key.format = svga_translate_format(templat->format);
+   if(tex->key.format == SVGA3D_FORMAT_INVALID)
+      goto error2;
+
+   tex->key.cachable = 1;
+   
+   SVGA_DBG(DEBUG_DMA, "surface_create for texture\n", tex->handle);
+   tex->handle = svga_screen_surface_create(svgascreen, &tex->key);
+   if (tex->handle)
+      SVGA_DBG(DEBUG_DMA, "  --> got sid %p (texture)\n", tex->handle);
+
+   return &tex->base;
+
+error2:
+   FREE(tex);
+error1:
+   return NULL;
+}
+
+
+static struct pipe_texture *
+svga_texture_blanket(struct pipe_screen * screen,
+                     const struct pipe_texture *base,
+                     const unsigned *stride,
+                     struct pipe_buffer *buffer)
+{
+   struct svga_texture *tex;
+   struct svga_buffer *sbuf = svga_buffer(buffer);
+   struct svga_winsys_screen *sws = svga_winsys_screen(screen);
+   assert(screen);
+
+   /* Only supports one type */
+   if (base->target != PIPE_TEXTURE_2D ||
+       base->last_level != 0 ||
+       base->depth0 != 1) {
+      return NULL;
+   }
+
+   /**
+    * We currently can't do texture blanket on
+    * SVGA3D_BUFFER. Need to blit to a temporary surface?
+    */
+
+   assert(sbuf->handle);
+   if (!sbuf->handle)
+      return NULL;
+
+   if (svga_translate_format(base->format) != sbuf->key.format) {
+      unsigned f1 = svga_translate_format(base->format);
+      unsigned f2 = sbuf->key.format;
+
+      /* It's okay for XRGB and ARGB or depth with/out stencil to get mixed up */
+      if ( !( (f1 == SVGA3D_X8R8G8B8 && f2 == SVGA3D_A8R8G8B8) ||
+              (f1 == SVGA3D_A8R8G8B8 && f2 == SVGA3D_X8R8G8B8) ||
+              (f1 == SVGA3D_Z_D24X8 && f2 == SVGA3D_Z_D24S8) ) ) {
+         debug_printf("%s wrong format %u != %u\n", __FUNCTION__, f1, f2);
+         return NULL;
+      }
+   }
+
+   tex = CALLOC_STRUCT(svga_texture);
+   if (!tex)
+      return NULL;
+
+   tex->base = *base;
+   
+
+   if (sbuf->key.format == 1)
+      tex->base.format = PIPE_FORMAT_X8R8G8B8_UNORM;
+   else if (sbuf->key.format == 2)
+      tex->base.format = PIPE_FORMAT_A8R8G8B8_UNORM;
+
+   pipe_reference_init(&tex->base.reference, 1);
+   tex->base.screen = screen;
+
+   SVGA_DBG(DEBUG_DMA, "blanket sid %p\n", sbuf->handle);
+
+   /* We don't own this storage, so don't try to cache it.
+    */
+   assert(sbuf->key.cachable == 0);
+   tex->key.cachable = 0;
+   sws->surface_reference(sws, &tex->handle, sbuf->handle);
+
+   return &tex->base;
+}
+
+
+static void
+svga_texture_destroy(struct pipe_texture *pt)
+{
+   struct svga_screen *ss = svga_screen(pt->screen);
+   struct svga_texture *tex = (struct svga_texture *)pt;
+
+   ss->texture_timestamp++;
+
+   svga_sampler_view_reference(&tex->cached_view, NULL);
+
+   /*
+     DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
+   */
+   SVGA_DBG(DEBUG_DMA, "unref sid %p (texture)\n", tex->handle);
+   svga_screen_surface_destroy(ss, &tex->key, &tex->handle);
+
+   FREE(tex);
+}
+
+
+static void
+svga_texture_copy_handle(struct svga_context *svga,
+                         struct svga_screen *ss,
+                         struct svga_winsys_surface *src_handle,
+                         unsigned src_x, unsigned src_y, unsigned src_z,
+                         unsigned src_level, unsigned src_face,
+                         struct svga_winsys_surface *dst_handle,
+                         unsigned dst_x, unsigned dst_y, unsigned dst_z,
+                         unsigned dst_level, unsigned dst_face,
+                         unsigned width, unsigned height, unsigned depth)
+{
+   struct svga_surface dst, src;
+   enum pipe_error ret;
+   SVGA3dCopyBox box, *boxes;
+
+   assert(svga || ss);
+
+   src.handle = src_handle;
+   src.real_level = src_level;
+   src.real_face = src_face;
+   src.real_zslice = 0;
+
+   dst.handle = dst_handle;
+   dst.real_level = dst_level;
+   dst.real_face = dst_face;
+   dst.real_zslice = 0;
+
+   box.x = dst_x;
+   box.y = dst_y;
+   box.z = dst_z;
+   box.w = width;
+   box.h = height;
+   box.d = depth;
+   box.srcx = src_x;
+   box.srcy = src_y;
+   box.srcz = src_z;
+
+/*
+   SVGA_DBG(DEBUG_VIEWS, "mipcopy src: %p %u (%ux%ux%u), dst: %p %u (%ux%ux%u)\n",
+            src_handle, src_level, src_x, src_y, src_z,
+            dst_handle, dst_level, dst_x, dst_y, dst_z);
+*/
+
+   if (svga) {
+      ret = SVGA3D_BeginSurfaceCopy(svga->swc,
+                                    &src.base,
+                                    &dst.base,
+                                    &boxes, 1);
+      if(ret != PIPE_OK) {
+         svga_context_flush(svga, NULL);
+         ret = SVGA3D_BeginSurfaceCopy(svga->swc,
+                                       &src.base,
+                                       &dst.base,
+                                       &boxes, 1);
+         assert(ret == PIPE_OK);
+      }
+      *boxes = box;
+      SVGA_FIFOCommitAll(svga->swc);
+   } else {
+      pipe_mutex_lock(ss->swc_mutex);
+      ret = SVGA3D_BeginSurfaceCopy(ss->swc,
+                                    &src.base,
+                                    &dst.base,
+                                    &boxes, 1);
+      if(ret != PIPE_OK) {
+         ss->swc->flush(ss->swc, NULL);
+         ret = SVGA3D_BeginSurfaceCopy(ss->swc,
+                                       &src.base,
+                                       &dst.base,
+                                       &boxes, 1);
+         assert(ret == PIPE_OK);
+      }
+      *boxes = box;
+      SVGA_FIFOCommitAll(ss->swc);
+      pipe_mutex_unlock(ss->swc_mutex);
+   }
+}
+
+static struct svga_winsys_surface *
+svga_texture_view_surface(struct pipe_context *pipe,
+                          struct svga_texture *tex,
+                          SVGA3dSurfaceFormat format,
+                          unsigned start_mip,
+                          unsigned num_mip,
+                          int face_pick,
+                          int zslice_pick,
+                          struct svga_host_surface_cache_key *key) /* OUT */
+{
+   struct svga_screen *ss = svga_screen(tex->base.screen);
+   struct svga_winsys_surface *handle;
+   uint32_t i, j;
+   unsigned z_offset = 0;
+
+   SVGA_DBG(DEBUG_PERF, 
+            "svga: Create surface view: face %d zslice %d mips %d..%d\n",
+            face_pick, zslice_pick, start_mip, start_mip+num_mip-1);
+
+   key->flags = 0;
+   key->format = format;
+   key->numMipLevels = num_mip;
+   key->size.width = u_minify(tex->base.width0, start_mip);
+   key->size.height = u_minify(tex->base.height0, start_mip);
+   key->size.depth = zslice_pick < 0 ? u_minify(tex->base.depth0, start_mip) : 1;
+   key->cachable = 1;
+   assert(key->size.depth == 1);
+   
+   if(tex->base.target == PIPE_TEXTURE_CUBE && face_pick < 0) {
+      key->flags |= SVGA3D_SURFACE_CUBEMAP;
+      key->numFaces = 6;
+   } else {
+      key->numFaces = 1;
+   }
+
+   if(key->format == SVGA3D_FORMAT_INVALID) {
+      key->cachable = 0;
+      return NULL;
+   }
+
+   SVGA_DBG(DEBUG_DMA, "surface_create for texture view\n");
+   handle = svga_screen_surface_create(ss, key);
+   if (!handle) {
+      key->cachable = 0;
+      return NULL;
+   }
+
+   SVGA_DBG(DEBUG_DMA, " --> got sid %p (texture view)\n", handle);
+
+   if (face_pick < 0)
+      face_pick = 0;
+
+   if (zslice_pick >= 0)
+       z_offset = zslice_pick;
+
+   for (i = 0; i < key->numMipLevels; i++) {
+      for (j = 0; j < key->numFaces; j++) {
+         if(tex->defined[j + face_pick][i + start_mip]) {
+            unsigned depth = (zslice_pick < 0 ?
+                              u_minify(tex->base.depth0, i + start_mip) :
+                              1);
+
+            svga_texture_copy_handle(svga_context(pipe),
+                                     ss,
+                                     tex->handle, 
+                                     0, 0, z_offset, 
+                                     i + start_mip, 
+                                     j + face_pick,
+                                     handle, 0, 0, 0, i, j,
+                                     u_minify(tex->base.width0, i + start_mip),
+                                     u_minify(tex->base.height0, i + start_mip),
+                                     depth);
+         }
+      }
+   }
+
+   return handle;
+}
+
+
+static struct pipe_surface *
+svga_get_tex_surface(struct pipe_screen *screen,
+                     struct pipe_texture *pt,
+                     unsigned face, unsigned level, unsigned zslice,
+                     unsigned flags)
+{
+   struct svga_texture *tex = svga_texture(pt);
+   struct svga_surface *s;
+   boolean render = flags & PIPE_BUFFER_USAGE_GPU_WRITE ? TRUE : FALSE;
+   boolean view = FALSE;
+   SVGA3dSurfaceFormat format;
+
+   s = CALLOC_STRUCT(svga_surface);
+   if (!s)
+      return NULL;
+
+   pipe_reference_init(&s->base.reference, 1);
+   pipe_texture_reference(&s->base.texture, pt);
+   s->base.format = pt->format;
+   s->base.width = u_minify(pt->width0, level);
+   s->base.height = u_minify(pt->height0, level);
+   s->base.usage = flags;
+   s->base.level = level;
+   s->base.face = face;
+   s->base.zslice = zslice;
+
+   if (!render)
+      format = svga_translate_format(pt->format);
+   else
+      format = svga_translate_format_render(pt->format);
+
+   assert(format != SVGA3D_FORMAT_INVALID);
+   assert(!(flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE));
+
+
+   if (svga_screen(screen)->debug.force_surface_view)
+      view = TRUE;
+
+   /* Currently only used for compressed textures */
+   if (render && 
+       format != svga_translate_format(pt->format)) {
+      view = TRUE;
+   }
+
+   if (level != 0 && 
+       svga_screen(screen)->debug.force_level_surface_view)
+      view = TRUE;
+
+   if (pt->target == PIPE_TEXTURE_3D)
+      view = TRUE;
+
+   if (svga_screen(screen)->debug.no_surface_view)
+      view = FALSE;
+
+   if (view) {
+      SVGA_DBG(DEBUG_VIEWS, "svga: Surface view: yes %p, level %u face %u z %u, %p\n",
+               pt, level, face, zslice, s);
+
+      s->handle = svga_texture_view_surface(NULL, tex, format, level, 1, face, zslice,
+                                            &s->key);
+      s->real_face = 0;
+      s->real_level = 0;
+      s->real_zslice = 0;
+   } else {
+      SVGA_DBG(DEBUG_VIEWS, "svga: Surface view: no %p, level %u, face %u, z %u, %p\n",
+               pt, level, face, zslice, s);
+
+      memset(&s->key, 0, sizeof s->key);
+      s->handle = tex->handle;
+      s->real_face = face;
+      s->real_level = level;
+      s->real_zslice = zslice;
+   }
+
+   return &s->base;
+}
+
+
+static void
+svga_tex_surface_destroy(struct pipe_surface *surf)
+{
+   struct svga_surface *s = svga_surface(surf);
+   struct svga_texture *t = svga_texture(surf->texture);
+   struct svga_screen *ss = svga_screen(surf->texture->screen);
+
+   if(s->handle != t->handle) {
+      SVGA_DBG(DEBUG_DMA, "unref sid %p (tex surface)\n", s->handle);
+      svga_screen_surface_destroy(ss, &s->key, &s->handle);
+   }
+
+   pipe_texture_reference(&surf->texture, NULL);
+   FREE(surf);
+}
+
+
+static INLINE void 
+svga_mark_surface_dirty(struct pipe_surface *surf)
+{
+   struct svga_surface *s = svga_surface(surf);
+
+   if(!s->dirty) {
+      struct svga_texture *tex = svga_texture(surf->texture);
+
+      s->dirty = TRUE;
+
+      if (s->handle == tex->handle)
+         tex->defined[surf->face][surf->level] = TRUE;
+      else {
+         /* this will happen later in svga_propagate_surface */
+      }
+   }
+}
+
+
+void svga_mark_surfaces_dirty(struct svga_context *svga)
+{
+   unsigned i;
+
+   for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
+      if (svga->curr.framebuffer.cbufs[i])
+         svga_mark_surface_dirty(svga->curr.framebuffer.cbufs[i]);
+   }
+   if (svga->curr.framebuffer.zsbuf)
+      svga_mark_surface_dirty(svga->curr.framebuffer.zsbuf);
+}
+
+/**
+ * Progagate any changes from surfaces to texture.
+ * pipe is optional context to inline the blit command in.
+ */
+void
+svga_propagate_surface(struct pipe_context *pipe, struct pipe_surface *surf)
+{
+   struct svga_surface *s = svga_surface(surf);
+   struct svga_texture *tex = svga_texture(surf->texture);
+   struct svga_screen *ss = svga_screen(surf->texture->screen);
+
+   if (!s->dirty)
+      return;
+
+   s->dirty = FALSE;
+   ss->texture_timestamp++;
+   tex->view_age[surf->level] = ++(tex->age);
+
+   if (s->handle != tex->handle) {
+      SVGA_DBG(DEBUG_VIEWS, "svga: Surface propagate: tex %p, level %u, from %p\n", tex, surf->level, surf);
+      svga_texture_copy_handle(svga_context(pipe), ss,
+                               s->handle, 0, 0, 0, s->real_level, s->real_face,
+                               tex->handle, 0, 0, surf->zslice, surf->level, surf->face,
+                               u_minify(tex->base.width0, surf->level),
+                               u_minify(tex->base.height0, surf->level), 1);
+      tex->defined[surf->face][surf->level] = TRUE;
+   }
+}
+
+/**
+ * Check if we should call svga_propagate_surface on the surface.
+ */
+extern boolean
+svga_surface_needs_propagation(struct pipe_surface *surf)
+{
+   struct svga_surface *s = svga_surface(surf);
+   struct svga_texture *tex = svga_texture(surf->texture);
+
+   return s->dirty && s->handle != tex->handle;
+}
+
+
+static struct pipe_transfer *
+svga_get_tex_transfer(struct pipe_screen *screen,
+                     struct pipe_texture *texture,
+                     unsigned face, unsigned level, unsigned zslice,
+                     enum pipe_transfer_usage usage, unsigned x, unsigned y,
+                     unsigned w, unsigned h)
+{
+   struct svga_screen *ss = svga_screen(screen);
+   struct svga_winsys_screen *sws = ss->sws;
+   struct svga_transfer *st;
+   unsigned nblocksx = util_format_get_nblocksx(texture->format, w);
+   unsigned nblocksy = util_format_get_nblocksy(texture->format, h);
+
+   /* We can't map texture storage directly */
+   if (usage & PIPE_TRANSFER_MAP_DIRECTLY)
+      return NULL;
+
+   st = CALLOC_STRUCT(svga_transfer);
+   if (!st)
+      return NULL;
+   
+   st->base.x = x;
+   st->base.y = y;
+   st->base.width = w;
+   st->base.height = h;
+   st->base.stride = nblocksx*util_format_get_blocksize(texture->format);
+   st->base.usage = usage;
+   st->base.face = face;
+   st->base.level = level;
+   st->base.zslice = zslice;
+
+   st->hw_nblocksy = nblocksy;
+   
+   st->hwbuf = svga_winsys_buffer_create(ss, 
+                                         1, 
+                                         0,
+                                         st->hw_nblocksy*st->base.stride);
+   while(!st->hwbuf && (st->hw_nblocksy /= 2)) {
+      st->hwbuf = svga_winsys_buffer_create(ss, 
+                                            1, 
+                                            0,
+                                            st->hw_nblocksy*st->base.stride);
+   }
+
+   if(!st->hwbuf)
+      goto no_hwbuf;
+
+   if(st->hw_nblocksy < nblocksy) {
+      /* We couldn't allocate a hardware buffer big enough for the transfer, 
+       * so allocate regular malloc memory instead */
+      debug_printf("%s: failed to allocate %u KB of DMA, splitting into %u x %u KB DMA transfers\n",
+                   __FUNCTION__,
+                   (nblocksy*st->base.stride + 1023)/1024,
+                   (nblocksy + st->hw_nblocksy - 1)/st->hw_nblocksy,
+                   (st->hw_nblocksy*st->base.stride + 1023)/1024);
+      st->swbuf = MALLOC(nblocksy*st->base.stride);
+      if(!st->swbuf)
+         goto no_swbuf;
+   }
+   
+   pipe_texture_reference(&st->base.texture, texture);
+
+   if (usage & PIPE_TRANSFER_READ)
+      svga_transfer_dma(st, SVGA3D_READ_HOST_VRAM);
+
+   return &st->base;
+
+no_swbuf:
+   sws->buffer_destroy(sws, st->hwbuf);
+no_hwbuf:
+   FREE(st);
+   return NULL;
+}
+
+
+static void *
+svga_transfer_map( struct pipe_screen *screen,
+                   struct pipe_transfer *transfer )
+{
+   struct svga_screen *ss = svga_screen(screen);
+   struct svga_winsys_screen *sws = ss->sws;
+   struct svga_transfer *st = svga_transfer(transfer);
+
+   if(st->swbuf)
+      return st->swbuf;
+   else
+      /* The wait for read transfers already happened when svga_transfer_dma
+       * was called. */
+      return sws->buffer_map(sws, st->hwbuf,
+                             pipe_transfer_buffer_flags(transfer));
+}
+
+
+static void
+svga_transfer_unmap(struct pipe_screen *screen,
+                    struct pipe_transfer *transfer)
+{
+   struct svga_screen *ss = svga_screen(screen);
+   struct svga_winsys_screen *sws = ss->sws;
+   struct svga_transfer *st = svga_transfer(transfer);
+   
+   if(!st->swbuf)
+      sws->buffer_unmap(sws, st->hwbuf);
+}
+
+
+static void
+svga_tex_transfer_destroy(struct pipe_transfer *transfer)
+{
+   struct svga_texture *tex = svga_texture(transfer->texture);
+   struct svga_screen *ss = svga_screen(transfer->texture->screen);
+   struct svga_winsys_screen *sws = ss->sws;
+   struct svga_transfer *st = svga_transfer(transfer);
+
+   if (st->base.usage & PIPE_TRANSFER_WRITE) {
+      svga_transfer_dma(st, SVGA3D_WRITE_HOST_VRAM);
+      ss->texture_timestamp++;
+      tex->view_age[transfer->level] = ++(tex->age);
+      tex->defined[transfer->face][transfer->level] = TRUE;
+   }
+
+   pipe_texture_reference(&st->base.texture, NULL);
+   FREE(st->swbuf);
+   sws->buffer_destroy(sws, st->hwbuf);
+   FREE(st);
+}
+
+void
+svga_screen_init_texture_functions(struct pipe_screen *screen)
+{
+   screen->texture_create = svga_texture_create;
+   screen->texture_destroy = svga_texture_destroy;
+   screen->get_tex_surface = svga_get_tex_surface;
+   screen->tex_surface_destroy = svga_tex_surface_destroy;
+   screen->texture_blanket = svga_texture_blanket;
+   screen->get_tex_transfer = svga_get_tex_transfer;
+   screen->transfer_map = svga_transfer_map;
+   screen->transfer_unmap = svga_transfer_unmap;
+   screen->tex_transfer_destroy = svga_tex_transfer_destroy;
+}
+
+/*********************************************************************** 
+ */
+
+struct svga_sampler_view *
+svga_get_tex_sampler_view(struct pipe_context *pipe, struct pipe_texture *pt,
+                          unsigned min_lod, unsigned max_lod)
+{
+   struct svga_screen *ss = svga_screen(pt->screen);
+   struct svga_texture *tex = svga_texture(pt); 
+   struct svga_sampler_view *sv = NULL;
+   SVGA3dSurfaceFormat format = svga_translate_format(pt->format);
+   boolean view = TRUE;
+
+   assert(pt);
+   assert(min_lod >= 0);
+   assert(min_lod <= max_lod);
+   assert(max_lod <= pt->last_level);
+
+
+   /* Is a view needed */
+   {
+      /*
+       * Can't control max lod. For first level views and when we only
+       * look at one level we disable mip filtering to achive the same
+       * results as a view.
+       */
+      if (min_lod == 0 && max_lod >= pt->last_level)
+         view = FALSE;
+
+      if (util_format_is_compressed(pt->format) && view) {
+         format = svga_translate_format_render(pt->format);
+      }
+
+      if (ss->debug.no_sampler_view)
+         view = FALSE;
+
+      if (ss->debug.force_sampler_view)
+         view = TRUE;
+   }
+
+   /* First try the cache */
+   if (view) {
+      pipe_mutex_lock(ss->tex_mutex);
+      if (tex->cached_view &&
+          tex->cached_view->min_lod == min_lod &&
+          tex->cached_view->max_lod == max_lod) {
+         svga_sampler_view_reference(&sv, tex->cached_view);
+         pipe_mutex_unlock(ss->tex_mutex);
+         SVGA_DBG(DEBUG_VIEWS, "svga: Sampler view: reuse %p, %u %u, last %u\n",
+                              pt, min_lod, max_lod, pt->last_level);
+         svga_validate_sampler_view(svga_context(pipe), sv);
+         return sv;
+      }
+      pipe_mutex_unlock(ss->tex_mutex);
+   }
+
+   sv = CALLOC_STRUCT(svga_sampler_view);
+   pipe_reference_init(&sv->reference, 1);
+   pipe_texture_reference(&sv->texture, pt);
+   sv->min_lod = min_lod;
+   sv->max_lod = max_lod;
+
+   /* No view needed just use the whole texture */
+   if (!view) {
+      SVGA_DBG(DEBUG_VIEWS,
+               "svga: Sampler view: no %p, mips %u..%u, nr %u, size (%ux%ux%u), last %u\n",
+               pt, min_lod, max_lod,
+               max_lod - min_lod + 1,
+               pt->width0,
+               pt->height0,
+               pt->depth0,
+               pt->last_level);
+      sv->key.cachable = 0;
+      sv->handle = tex->handle;
+      return sv;
+   }
+
+   SVGA_DBG(DEBUG_VIEWS,
+            "svga: Sampler view: yes %p, mips %u..%u, nr %u, size (%ux%ux%u), last %u\n",
+            pt, min_lod, max_lod,
+            max_lod - min_lod + 1,
+            pt->width0,
+            pt->height0,
+            pt->depth0,
+            pt->last_level);
+
+   sv->age = tex->age;
+   sv->handle = svga_texture_view_surface(pipe, tex, format,
+                                          min_lod,
+                                          max_lod - min_lod + 1,
+                                          -1, -1,
+                                          &sv->key);
+
+   if (!sv->handle) {
+      assert(0);
+      sv->key.cachable = 0;
+      sv->handle = tex->handle;
+      return sv;
+   }
+
+   pipe_mutex_lock(ss->tex_mutex);
+   svga_sampler_view_reference(&tex->cached_view, sv);
+   pipe_mutex_unlock(ss->tex_mutex);
+
+   return sv;
+}
+
+void
+svga_validate_sampler_view(struct svga_context *svga, struct svga_sampler_view *v)
+{
+   struct svga_texture *tex = svga_texture(v->texture);
+   unsigned numFaces;
+   unsigned age = 0;
+   int i, k;
+
+   assert(svga);
+
+   if (v->handle == tex->handle)
+      return;
+
+   age = tex->age;
+
+   if(tex->base.target == PIPE_TEXTURE_CUBE)
+      numFaces = 6;
+   else
+      numFaces = 1;
+
+   for (i = v->min_lod; i <= v->max_lod; i++) {
+      for (k = 0; k < numFaces; k++) {
+         if (v->age < tex->view_age[i])
+            svga_texture_copy_handle(svga, NULL,
+                                     tex->handle, 0, 0, 0, i, k,
+                                     v->handle, 0, 0, 0, i - v->min_lod, k,
+                                     u_minify(tex->base.width0, i),
+                                     u_minify(tex->base.height0, i),
+                                     u_minify(tex->base.depth0, i));
+      }
+   }
+
+   v->age = age;
+}
+
+void
+svga_destroy_sampler_view_priv(struct svga_sampler_view *v)
+{
+   struct svga_texture *tex = svga_texture(v->texture);
+
+   if(v->handle != tex->handle) {
+      struct svga_screen *ss = svga_screen(v->texture->screen);
+      SVGA_DBG(DEBUG_DMA, "unref sid %p (sampler view)\n", v->handle);
+      svga_screen_surface_destroy(ss, &v->key, &v->handle);
+   }
+   pipe_texture_reference(&v->texture, NULL);
+   FREE(v);
+}
+
+boolean
+svga_screen_buffer_from_texture(struct pipe_texture *texture,
+                               struct pipe_buffer **buffer,
+                               unsigned *stride)
+{
+   struct svga_texture *stex = svga_texture(texture);
+
+   *buffer = svga_screen_buffer_wrap_surface
+      (texture->screen,
+       svga_translate_format(texture->format),
+       stex->handle);
+
+   *stride = util_format_get_stride(texture->format, texture->width0);
+
+   return *buffer != NULL;
+}
+
+
+struct svga_winsys_surface *
+svga_screen_texture_get_winsys_surface(struct pipe_texture *texture)
+{
+   struct svga_winsys_screen *sws = svga_winsys_screen(texture->screen);
+   struct svga_winsys_surface *vsurf = NULL;
+
+   assert(svga_texture(texture)->key.cachable == 0);
+   svga_texture(texture)->key.cachable = 0;
+   sws->surface_reference(sws, &vsurf, svga_texture(texture)->handle);
+   return vsurf;
+}
diff --git a/src/gallium/drivers/svga/svga_screen_texture.h b/src/gallium/drivers/svga/svga_screen_texture.h
new file mode 100644 (file)
index 0000000..89ae242
--- /dev/null
@@ -0,0 +1,195 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#ifndef SVGA_TEXTURE_H
+#define SVGA_TEXTURE_H
+
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_state.h"
+#include "svga_screen_cache.h"
+
+struct pipe_context;
+struct pipe_screen;
+struct svga_context;
+struct svga_winsys_surface;
+enum SVGA3dSurfaceFormat;
+
+
+#define SVGA_MAX_TEXTURE_LEVELS 12 /* 2048x2048 */
+
+
+/**
+ * A sampler's view into a texture
+ *
+ * We currently cache one sampler view on
+ * the texture and in there by holding a reference
+ * from the texture to the sampler view.
+ *
+ * Because of this we can not hold a refernce to the
+ * texture from the sampler view. So the user
+ * of the sampler views must make sure that the
+ * texture has a reference take for as long as
+ * the sampler view is refrenced.
+ *
+ * Just unreferencing the sampler_view before the
+ * texture is enough.
+ */
+struct svga_sampler_view
+{
+   struct pipe_reference reference;
+
+   struct pipe_texture *texture;
+
+   int min_lod;
+   int max_lod;
+
+   unsigned age;
+
+   struct svga_host_surface_cache_key key;
+   struct svga_winsys_surface *handle;
+};
+
+
+struct svga_texture 
+{
+   struct pipe_texture base;
+
+   boolean defined[6][PIPE_MAX_TEXTURE_LEVELS];
+   
+   struct svga_sampler_view *cached_view;
+
+   unsigned view_age[SVGA_MAX_TEXTURE_LEVELS];
+   unsigned age;
+
+   boolean views_modified;
+
+   /**
+    * Creation key for the host surface handle.
+    * 
+    * This structure describes all the host surface characteristics so that it 
+    * can be looked up in cache, since creating a host surface is often a slow
+    * operation.
+    */
+   struct svga_host_surface_cache_key key;
+
+   /**
+    * Handle for the host side surface.
+    *
+    * This handle is owned by this texture. Views should hold on to a reference
+    * to this texture and never destroy this handle directly.
+    */
+   struct svga_winsys_surface *handle;
+};
+
+
+struct svga_surface
+{
+   struct pipe_surface base;
+
+   struct svga_host_surface_cache_key key;
+   struct svga_winsys_surface *handle;
+
+   unsigned real_face;
+   unsigned real_level;
+   unsigned real_zslice;
+
+   boolean dirty;
+};
+
+
+struct svga_transfer
+{
+   struct pipe_transfer base;
+
+   struct svga_winsys_buffer *hwbuf;
+
+   /* Height of the hardware buffer in pixel blocks */
+   unsigned hw_nblocksy;
+
+   /* Temporary malloc buffer when we can't allocate a hardware buffer
+    * big enough */
+   void *swbuf;
+};
+
+
+static INLINE struct svga_texture *
+svga_texture(struct pipe_texture *texture)
+{
+   return (struct svga_texture *)texture;
+}
+
+static INLINE struct svga_surface *
+svga_surface(struct pipe_surface *surface)
+{
+   assert(surface);
+   return (struct svga_surface *)surface;
+}
+
+static INLINE struct svga_transfer *
+svga_transfer(struct pipe_transfer *transfer)
+{
+   assert(transfer);
+   return (struct svga_transfer *)transfer;
+}
+
+extern struct svga_sampler_view *
+svga_get_tex_sampler_view(struct pipe_context *pipe,
+                          struct pipe_texture *pt,
+                          unsigned min_lod, unsigned max_lod);
+
+void
+svga_validate_sampler_view(struct svga_context *svga, struct svga_sampler_view *v);
+
+void
+svga_destroy_sampler_view_priv(struct svga_sampler_view *v);
+
+static INLINE void
+svga_sampler_view_reference(struct svga_sampler_view **ptr, struct svga_sampler_view *v)
+{
+   struct svga_sampler_view *old = *ptr;
+
+   if (pipe_reference(&(*ptr)->reference, &v->reference))
+      svga_destroy_sampler_view_priv(old);
+   *ptr = v;
+}
+
+extern void
+svga_propagate_surface(struct pipe_context *pipe, struct pipe_surface *surf);
+
+extern boolean
+svga_surface_needs_propagation(struct pipe_surface *surf);
+
+extern void
+svga_screen_init_texture_functions(struct pipe_screen *screen);
+
+enum SVGA3dSurfaceFormat
+svga_translate_format(enum pipe_format format);
+
+enum SVGA3dSurfaceFormat
+svga_translate_format_render(enum pipe_format format);
+
+
+#endif /* SVGA_TEXTURE_H */
diff --git a/src/gallium/drivers/svga/svga_state.c b/src/gallium/drivers/svga/svga_state.c
new file mode 100644 (file)
index 0000000..1c21d3a
--- /dev/null
@@ -0,0 +1,278 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "util/u_debug.h"
+#include "pipe/p_defines.h"
+#include "util/u_memory.h"
+#include "draw/draw_context.h"
+
+#include "svga_context.h"
+#include "svga_screen.h"
+#include "svga_state.h"
+#include "svga_draw.h"
+#include "svga_cmd.h"
+#include "svga_hw_reg.h"
+
+/* This is just enough to decide whether we need to use the draw
+ * module (swtnl) or not.
+ */
+static const struct svga_tracked_state *need_swtnl_state[] =
+{
+   &svga_update_need_swvfetch,
+   &svga_update_need_pipeline,
+   &svga_update_need_swtnl,
+   NULL
+};
+
+
+/* Atoms to update hardware state prior to emitting a clear or draw
+ * packet.
+ */
+static const struct svga_tracked_state *hw_clear_state[] =
+{
+   &svga_hw_scissor,
+   &svga_hw_viewport,
+   &svga_hw_framebuffer,
+   NULL
+};
+
+
+/* Atoms to update hardware state prior to emitting a draw packet.
+ */
+static const struct svga_tracked_state *hw_draw_state[] =
+{
+   &svga_hw_update_zero_stride,
+   &svga_hw_fs,
+   &svga_hw_vs,
+   &svga_hw_rss,
+   &svga_hw_tss,
+   &svga_hw_tss_binding,
+   &svga_hw_clip_planes,
+   &svga_hw_vdecl,
+   &svga_hw_fs_parameters,
+   &svga_hw_vs_parameters,
+   NULL
+};
+
+
+static const struct svga_tracked_state *swtnl_draw_state[] =
+{
+   &svga_update_swtnl_draw,
+   &svga_update_swtnl_vdecl,
+   NULL
+};
+
+/* Flattens the graph of state dependencies.  Could swap the positions
+ * of hw_clear_state and need_swtnl_state without breaking anything.
+ */
+static const struct svga_tracked_state **state_levels[] = 
+{
+   need_swtnl_state,
+   hw_clear_state,
+   hw_draw_state,
+   swtnl_draw_state
+};
+
+
+
+static unsigned check_state( unsigned a,
+                             unsigned b )
+{
+   return (a & b);
+}
+
+static void accumulate_state( unsigned *a,
+                             unsigned b )
+{
+   *a |= b;
+}
+
+
+static void xor_states( unsigned *result,
+                        unsigned a,
+                        unsigned b )
+{
+   *result = a ^ b;
+}
+
+
+
+static int update_state( struct svga_context *svga,
+                         const struct svga_tracked_state *atoms[],
+                         unsigned *state )
+{
+   boolean debug = TRUE;
+   enum pipe_error ret = 0;
+   unsigned i;
+
+   ret = svga_hwtnl_flush( svga->hwtnl );
+   if (ret != 0)
+      return ret;
+
+   if (debug) {
+      /* Debug version which enforces various sanity checks on the
+       * state flags which are generated and checked to help ensure
+       * state atoms are ordered correctly in the list.
+       */
+      unsigned examined, prev;      
+
+      examined = 0;
+      prev = *state;
+
+      for (i = 0; atoms[i] != NULL; i++) {      
+        unsigned generated;
+
+        assert(atoms[i]->dirty); 
+        assert(atoms[i]->update);
+
+        if (check_state(*state, atoms[i]->dirty)) {
+           if (0)
+               debug_printf("update: %s\n", atoms[i]->name);
+           ret = atoms[i]->update( svga, *state );
+            if (ret != 0)
+               return ret;
+        }
+
+        /* generated = (prev ^ state)
+         * if (examined & generated)
+         *     fail;
+         */
+        xor_states(&generated, prev, *state);
+        if (check_state(examined, generated)) {
+           debug_printf("state atom %s generated state already examined\n", 
+                         atoms[i]->name);
+           assert(0);
+        }
+                        
+        prev = *state;
+        accumulate_state(&examined, atoms[i]->dirty);
+      }
+   }
+   else {
+      for (i = 0; atoms[i] != NULL; i++) {      
+        if (check_state(*state, atoms[i]->dirty)) {
+           ret = atoms[i]->update( svga, *state );
+            if (ret != 0)
+               return ret;
+         }
+      }
+   }
+
+   return 0;
+}
+
+
+
+int svga_update_state( struct svga_context *svga,
+                       unsigned max_level )
+{
+   struct svga_screen *screen = svga_screen(svga->pipe.screen);
+   int ret = 0;
+   int i;
+
+   /* Check for updates to bound textures.  This can't be done in an
+    * atom as there is no flag which could provoke this test, and we
+    * cannot create one.
+    */
+   if (svga->state.texture_timestamp != screen->texture_timestamp) {
+      svga->state.texture_timestamp = screen->texture_timestamp;
+      svga->dirty |= SVGA_NEW_TEXTURE;
+   }
+
+   for (i = 0; i <= max_level; i++) {
+      svga->dirty |= svga->state.dirty[i];
+
+      if (svga->dirty) {
+         ret = update_state( svga, 
+                             state_levels[i], 
+                             &svga->dirty );
+         if (ret != 0)
+            return ret;
+
+         svga->state.dirty[i] = 0;
+      }
+   }
+   
+   for (; i < SVGA_STATE_MAX; i++) 
+      svga->state.dirty[i] |= svga->dirty;
+
+   svga->dirty = 0;
+   return 0;
+}
+
+
+
+
+void svga_update_state_retry( struct svga_context *svga,
+                              unsigned max_level )
+{
+   int ret;
+
+   ret = svga_update_state( svga, max_level );
+
+   if (ret == PIPE_ERROR_OUT_OF_MEMORY) {
+      svga_context_flush(svga, NULL);
+      ret = svga_update_state( svga, max_level );
+   }
+
+   assert( ret == 0 );
+}
+
+
+
+#define EMIT_RS(_rs, _count, _name, _value)     \
+do {                                            \
+   _rs[_count].state = _name;                   \
+   _rs[_count].uintValue = _value;              \
+   _count++;                                    \
+} while (0)
+
+
+/* Setup any hardware state which will be constant through the life of
+ * a context.
+ */
+enum pipe_error svga_emit_initial_state( struct svga_context *svga )
+{
+   SVGA3dRenderState *rs;
+   unsigned count = 0;
+   const unsigned COUNT = 2;
+   enum pipe_error ret;
+
+   ret = SVGA3D_BeginSetRenderState( svga->swc, &rs, COUNT );
+   if (ret)
+      return ret;
+
+   /* Always use D3D style coordinate space as this is the only one
+    * which is implemented on all backends.
+    */
+   EMIT_RS(rs, count, SVGA3D_RS_COORDINATETYPE, SVGA3D_COORDINATE_LEFTHANDED );
+   EMIT_RS(rs, count, SVGA3D_RS_FRONTWINDING, SVGA3D_FRONTWINDING_CW );
+   
+   assert( COUNT == count );
+   SVGA_FIFOCommitAll( svga->swc );
+
+   return 0;
+
+}
diff --git a/src/gallium/drivers/svga/svga_state.h b/src/gallium/drivers/svga/svga_state.h
new file mode 100644 (file)
index 0000000..22d5a6d
--- /dev/null
@@ -0,0 +1,95 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#ifndef SVGA_STATE_H
+#define SVGA_STATE_H
+
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_defines.h"
+
+struct svga_context;
+
+
+void svga_init_state( struct svga_context *svga );
+void svga_destroy_state( struct svga_context *svga );
+
+
+struct svga_tracked_state {
+   const char *name;
+   unsigned dirty;
+   int (*update)( struct svga_context *svga, unsigned dirty );
+};
+
+/* NEED_SWTNL
+ */
+extern struct svga_tracked_state svga_update_need_swvfetch;
+extern struct svga_tracked_state svga_update_need_pipeline;
+extern struct svga_tracked_state svga_update_need_swtnl;
+
+/* HW_CLEAR
+ */
+extern struct svga_tracked_state svga_hw_viewport;
+extern struct svga_tracked_state svga_hw_scissor;
+extern struct svga_tracked_state svga_hw_framebuffer;
+
+/* HW_DRAW
+ */
+extern struct svga_tracked_state svga_hw_vs;
+extern struct svga_tracked_state svga_hw_fs;
+extern struct svga_tracked_state svga_hw_rss;
+extern struct svga_tracked_state svga_hw_tss;
+extern struct svga_tracked_state svga_hw_tss_binding;
+extern struct svga_tracked_state svga_hw_clip_planes;
+extern struct svga_tracked_state svga_hw_vdecl;
+extern struct svga_tracked_state svga_hw_fs_parameters;
+extern struct svga_tracked_state svga_hw_vs_parameters;
+extern struct svga_tracked_state svga_hw_update_zero_stride;
+
+/* SWTNL_DRAW
+ */
+extern struct svga_tracked_state svga_update_swtnl_draw;
+extern struct svga_tracked_state svga_update_swtnl_vdecl;
+
+/* Bring the hardware fully up-to-date so that we can emit draw
+ * commands.
+ */
+#define SVGA_STATE_NEED_SWTNL        0
+#define SVGA_STATE_HW_CLEAR          1
+#define SVGA_STATE_HW_DRAW           2
+#define SVGA_STATE_SWTNL_DRAW        3
+#define SVGA_STATE_MAX               4
+
+
+enum pipe_error svga_update_state( struct svga_context *svga,
+                                   unsigned level );
+
+void svga_update_state_retry( struct svga_context *svga,
+                              unsigned level );
+
+
+enum pipe_error svga_emit_initial_state( struct svga_context *svga );
+
+#endif
diff --git a/src/gallium/drivers/svga/svga_state_constants.c b/src/gallium/drivers/svga/svga_state_constants.c
new file mode 100644 (file)
index 0000000..6b0e511
--- /dev/null
@@ -0,0 +1,240 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "pipe/p_inlines.h"
+#include "pipe/p_defines.h"
+
+#include "svga_context.h"
+#include "svga_state.h"
+#include "svga_cmd.h"
+#include "svga_tgsi.h"
+#include "svga_debug.h"
+
+#include "svga_hw_reg.h"
+
+/***********************************************************************
+ * Hardware update 
+ */
+
+/* Convert from PIPE_SHADER_* to SVGA3D_SHADERTYPE_*
+ */
+static int svga_shader_type( int unit )
+{
+   return unit + 1;
+}
+
+
+static int emit_const( struct svga_context *svga,
+                       int unit,
+                       int i,
+                       const float *value )
+{
+   int ret = PIPE_OK;
+
+   if (memcmp(svga->state.hw_draw.cb[unit][i], value, 4 * sizeof(float)) != 0) {
+      if (SVGA_DEBUG & DEBUG_CONSTS)
+         debug_printf("%s %s %d: %f %f %f %f\n",
+                      __FUNCTION__,
+                      unit == PIPE_SHADER_VERTEX ? "VERT" : "FRAG",
+                      i,
+                      value[0],
+                      value[1],
+                      value[2],
+                      value[3]);
+
+      ret = SVGA3D_SetShaderConst( svga->swc, 
+                                   i,
+                                   svga_shader_type(unit),
+                                   SVGA3D_CONST_TYPE_FLOAT,
+                                   value );
+      if (ret)
+         return ret;
+
+      memcpy(svga->state.hw_draw.cb[unit][i], value, 4 * sizeof(float));
+   }
+   
+   return ret;
+}
+
+static int emit_consts( struct svga_context *svga,
+                        int offset,
+                        int unit )
+{
+   struct pipe_screen *screen = svga->pipe.screen;
+   unsigned count;
+   const float (*data)[4] = NULL;
+   unsigned i;
+   int ret = PIPE_OK;
+
+   if (svga->curr.cb[unit] == NULL)
+      goto done;
+
+   count = svga->curr.cb[unit]->size / (4 * sizeof(float));
+
+   data = (const float (*)[4])pipe_buffer_map(screen,
+                                              svga->curr.cb[unit],
+                                              PIPE_BUFFER_USAGE_CPU_READ);
+   if (data == NULL) {
+      ret = PIPE_ERROR_OUT_OF_MEMORY;
+      goto done;
+   }
+
+   for (i = 0; i < count; i++) {
+      ret = emit_const( svga, unit, offset + i, data[i] );
+      if (ret)
+         goto done;
+   }
+
+done:
+   if (data)
+      pipe_buffer_unmap(screen, svga->curr.cb[unit]);
+
+   return ret;
+}
+   
+static int emit_fs_consts( struct svga_context *svga,
+                           unsigned dirty )
+{
+   const struct svga_shader_result *result = svga->state.hw_draw.fs;
+   const struct svga_fs_compile_key *key = &result->key.fkey;
+   int ret = 0;
+
+   ret = emit_consts( svga, 0, PIPE_SHADER_FRAGMENT );
+   if (ret)
+      return ret;
+
+   /* The internally generated fragment shader for xor blending
+    * doesn't have a 'result' struct.  It should be fixed to avoid
+    * this special case, but work around it with a NULL check:
+    */
+   if (result != NULL &&
+       key->num_unnormalized_coords)
+   {
+      unsigned offset = result->shader->info.file_max[TGSI_FILE_CONSTANT] + 1;
+      int i;
+
+      for (i = 0; i < key->num_textures; i++) {
+         if (key->tex[i].unnormalized) {
+            struct pipe_texture *tex = svga->curr.texture[i];
+            float data[4];
+
+            data[0] = 1.0 / (float)tex->width0;
+            data[1] = 1.0 / (float)tex->height0;
+            data[2] = 1.0;
+            data[3] = 1.0;
+
+            ret = emit_const( svga,
+                              PIPE_SHADER_FRAGMENT,
+                              key->tex[i].width_height_idx + offset,
+                              data );
+            if (ret)
+               return ret;
+         }
+      }
+
+      offset += key->num_unnormalized_coords;
+   }
+
+   return 0;
+}
+
+
+struct svga_tracked_state svga_hw_fs_parameters = 
+{
+   "hw fs params",
+   (SVGA_NEW_FS_CONST_BUFFER |
+    SVGA_NEW_FS_RESULT |
+    SVGA_NEW_TEXTURE_BINDING),
+   emit_fs_consts
+};
+
+/***********************************************************************
+ */
+
+static int emit_vs_consts( struct svga_context *svga,
+                           unsigned dirty )
+{
+   const struct svga_shader_result *result = svga->state.hw_draw.vs;
+   const struct svga_vs_compile_key *key = &result->key.vkey;
+   int ret = 0;
+   unsigned offset;
+
+   /* SVGA_NEW_VS_RESULT
+    */
+   if (result == NULL) 
+      return 0;
+
+   /* SVGA_NEW_VS_CONST_BUFFER 
+    */
+   ret = emit_consts( svga, 0, PIPE_SHADER_VERTEX );
+   if (ret)
+      return ret;
+
+   offset = result->shader->info.file_max[TGSI_FILE_CONSTANT] + 1;
+
+   /* SVGA_NEW_VS_RESULT
+    */
+   if (key->need_prescale) {
+      ret = emit_const( svga, PIPE_SHADER_VERTEX, offset++,
+                        svga->state.hw_clear.prescale.scale );
+      if (ret)
+         return ret;
+
+      ret = emit_const( svga, PIPE_SHADER_VERTEX, offset++,
+                        svga->state.hw_clear.prescale.translate );
+      if (ret)
+         return ret;
+   }
+
+   /* SVGA_NEW_ZERO_STRIDE
+    */
+   if (key->zero_stride_vertex_elements) {
+      unsigned i, curr_zero_stride = 0;
+      for (i = 0; i < PIPE_MAX_ATTRIBS; ++i) {
+         if (key->zero_stride_vertex_elements & (1 << i)) {
+            ret = emit_const( svga, PIPE_SHADER_VERTEX, offset++,
+                              svga->curr.zero_stride_constants +
+                              4 * curr_zero_stride );
+            if (ret)
+               return ret;
+            ++curr_zero_stride;
+         }
+      }
+   }
+
+   return 0;
+}
+
+
+struct svga_tracked_state svga_hw_vs_parameters = 
+{
+   "hw vs params",
+   (SVGA_NEW_PRESCALE |
+    SVGA_NEW_VS_CONST_BUFFER |
+    SVGA_NEW_ZERO_STRIDE |
+    SVGA_NEW_VS_RESULT),
+   emit_vs_consts
+};
+
diff --git a/src/gallium/drivers/svga/svga_state_framebuffer.c b/src/gallium/drivers/svga/svga_state_framebuffer.c
new file mode 100644 (file)
index 0000000..cfdcae4
--- /dev/null
@@ -0,0 +1,458 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "pipe/p_inlines.h"
+#include "pipe/p_defines.h"
+#include "util/u_math.h"
+
+#include "svga_context.h"
+#include "svga_state.h"
+#include "svga_cmd.h"
+#include "svga_debug.h"
+
+#include "svga_hw_reg.h"
+
+
+/***********************************************************************
+ * Hardware state update
+ */
+
+
+static int emit_framebuffer( struct svga_context *svga,
+                             unsigned dirty )
+{
+   const struct pipe_framebuffer_state *curr = &svga->curr.framebuffer;
+   struct pipe_framebuffer_state *hw = &svga->state.hw_clear.framebuffer;
+   unsigned i;
+   enum pipe_error ret;
+
+   /* XXX: Need shadow state in svga->hw to eliminate redundant
+    * uploads, especially of NULL buffers.
+    */
+   
+   for(i = 0; i < PIPE_MAX_COLOR_BUFS; ++i) {
+      if (curr->cbufs[i] != hw->cbufs[i]) {
+         if (svga->curr.nr_fbs++ > 8)
+            return PIPE_ERROR_OUT_OF_MEMORY;
+
+         ret = SVGA3D_SetRenderTarget(svga->swc, SVGA3D_RT_COLOR0 + i, curr->cbufs[i]);
+         if (ret != PIPE_OK)
+            return ret;
+         
+         pipe_surface_reference(&hw->cbufs[i], curr->cbufs[i]);
+      }
+   }
+
+   
+   if (curr->zsbuf != hw->zsbuf) {
+      ret = SVGA3D_SetRenderTarget(svga->swc, SVGA3D_RT_DEPTH, curr->zsbuf);
+      if (ret != PIPE_OK)
+         return ret;
+
+      if (curr->zsbuf &&
+          curr->zsbuf->format == PIPE_FORMAT_Z24S8_UNORM) {
+         ret = SVGA3D_SetRenderTarget(svga->swc, SVGA3D_RT_STENCIL, curr->zsbuf);
+         if (ret != PIPE_OK)
+            return ret;
+      }
+      else {
+         ret = SVGA3D_SetRenderTarget(svga->swc, SVGA3D_RT_STENCIL, NULL);
+         if (ret != PIPE_OK)
+            return ret;
+      }
+      
+      pipe_surface_reference(&hw->zsbuf, curr->zsbuf);
+   }
+
+
+   return 0;
+}
+
+
+struct svga_tracked_state svga_hw_framebuffer = 
+{
+   "hw framebuffer state",
+   SVGA_NEW_FRAME_BUFFER,
+   emit_framebuffer
+};
+
+
+
+
+/*********************************************************************** 
+ */
+
+static int emit_viewport( struct svga_context *svga,
+                          unsigned dirty )
+{
+   const struct pipe_viewport_state *viewport = &svga->curr.viewport;
+   struct svga_prescale prescale;
+   SVGA3dRect rect;
+   /* Not sure if this state is relevant with POSITIONT.  Probably
+    * not, but setting to 0,1 avoids some state pingponging.
+    */
+   float range_min = 0.0;
+   float range_max = 1.0;
+   float flip = -1.0;
+   boolean degenerate = FALSE;
+   enum pipe_error ret;
+
+   float fb_width = svga->curr.framebuffer.width;
+   float fb_height = svga->curr.framebuffer.height;
+
+   memset( &prescale, 0, sizeof(prescale) );
+
+   if (svga->curr.rast->templ.bypass_vs_clip_and_viewport) {
+
+      /* Avoid POSITIONT as it has a non trivial implementation outside the D3D
+       * API. Always generate a vertex shader.
+       */
+      rect.x = 0;
+      rect.y = 0;
+      rect.w = svga->curr.framebuffer.width;
+      rect.h = svga->curr.framebuffer.height;
+
+      prescale.scale[0] = 2.0 / (float)rect.w;
+      prescale.scale[1] = - 2.0 / (float)rect.h;
+      prescale.scale[2] = 1.0;
+      prescale.scale[3] = 1.0;
+      prescale.translate[0] = -1.0f;
+      prescale.translate[1] = 1.0f;
+      prescale.translate[2] = 0;
+      prescale.translate[3] = 0;
+      prescale.enabled = TRUE;
+   } else {
+
+      /* Examine gallium viewport transformation and produce a screen
+       * rectangle and possibly vertex shader pre-transformation to
+       * get the same results.
+       */
+      float fx =        viewport->scale[0] * -1.0 + viewport->translate[0];
+      float fy = flip * viewport->scale[1] * -1.0 + viewport->translate[1];
+      float fw =        viewport->scale[0] * 2; 
+      float fh = flip * viewport->scale[1] * 2; 
+
+      SVGA_DBG(DEBUG_VIEWPORT,
+               "\ninitial %f,%f %fx%f\n",
+               fx,
+               fy,
+               fw,
+               fh);
+
+      prescale.scale[0] = 1.0;
+      prescale.scale[1] = 1.0;
+      prescale.scale[2] = 1.0;
+      prescale.scale[3] = 1.0;
+      prescale.translate[0] = 0;
+      prescale.translate[1] = 0;
+      prescale.translate[2] = 0;
+      prescale.translate[3] = 0;
+      prescale.enabled = TRUE;
+
+
+
+      if (fw < 0) {
+         prescale.scale[0] *= -1.0;
+         prescale.translate[0] += -fw;
+         fw = -fw;
+         fx =        viewport->scale[0] * 1.0 + viewport->translate[0];
+      }
+
+      if (fh < 0) {
+         prescale.scale[1] *= -1.0;
+         prescale.translate[1] += -fh;
+         fh = -fh;
+         fy = flip * viewport->scale[1] * 1.0 + viewport->translate[1];
+      }
+
+      if (fx < 0) {
+         prescale.translate[0] += fx;
+         prescale.scale[0] *= fw / (fw + fx); 
+         fw += fx;
+         fx = 0;
+      }
+
+      if (fy < 0) {
+         prescale.translate[1] += fy;
+         prescale.scale[1] *= fh / (fh + fy); 
+         fh += fy;
+         fy = 0;
+      }
+
+      if (fx + fw > fb_width) {
+         prescale.scale[0] *= fw / (fb_width - fx); 
+         prescale.translate[0] -= fx * (fw / (fb_width - fx));
+         prescale.translate[0] += fx;
+         fw = fb_width - fx;
+         
+      }
+
+      if (fy + fh > fb_height) {
+         prescale.scale[1] *= fh / (fb_height - fy);
+         prescale.translate[1] -= fy * (fh / (fb_height - fy));
+         prescale.translate[1] += fy;
+         fh = fb_height - fy;
+      }
+
+      if (fw < 0 || fh < 0) {
+         fw = fh = fx = fy = 0;
+         degenerate = TRUE;
+         goto out;
+      }
+
+
+      /* D3D viewport is integer space.  Convert fx,fy,etc. to
+       * integers.
+       *
+       * TODO: adjust pretranslate correct for any subpixel error
+       * introduced converting to integers.
+       */
+      rect.x = fx;
+      rect.y = fy;
+      rect.w = fw;
+      rect.h = fh;
+
+      SVGA_DBG(DEBUG_VIEWPORT,
+               "viewport error %f,%f %fx%f\n",
+               fabs((float)rect.x - fx),
+               fabs((float)rect.y - fy),
+               fabs((float)rect.w - fw),
+               fabs((float)rect.h - fh));
+
+      SVGA_DBG(DEBUG_VIEWPORT,
+               "viewport %d,%d %dx%d\n",
+               rect.x,
+               rect.y,
+               rect.w,
+               rect.h);
+      
+
+      /* Finally, to get GL rasterization rules, need to tweak the
+       * screen-space coordinates slightly relative to D3D which is
+       * what hardware implements natively.
+       */
+      if (svga->curr.rast->templ.gl_rasterization_rules) {
+         float adjust_x = 0.0;
+         float adjust_y = 0.0;
+
+         switch (svga->curr.reduced_prim) {
+         case PIPE_PRIM_LINES:
+            adjust_x = -0.5;
+            adjust_y = 0;
+            break;
+         case PIPE_PRIM_POINTS:
+         case PIPE_PRIM_TRIANGLES:
+            adjust_x = -0.375;
+            adjust_y = -0.5;
+            break;
+         }
+
+         prescale.translate[0] += adjust_x;
+         prescale.translate[1] += adjust_y;
+         prescale.translate[2] = 0.5; /* D3D clip space */
+         prescale.scale[2]     = 0.5; /* D3D clip space */
+      }
+
+
+      range_min = viewport->scale[2] * -1.0 + viewport->translate[2];
+      range_max = viewport->scale[2] *  1.0 + viewport->translate[2];
+
+      /* D3D (and by implication SVGA) doesn't like dealing with zmax
+       * less than zmin.  Detect that case, flip the depth range and
+       * invert our z-scale factor to achieve the same effect.
+       */
+      if (range_min > range_max) {
+         float range_tmp;
+         range_tmp = range_min; 
+         range_min = range_max; 
+         range_max = range_tmp;
+         prescale.scale[2]     = -prescale.scale[2];
+      }
+   }
+
+   if (prescale.enabled) {
+      float H[2];
+      float J[2];
+      int i;
+
+      SVGA_DBG(DEBUG_VIEWPORT,
+               "prescale %f,%f %fx%f\n",
+               prescale.translate[0],
+               prescale.translate[1],
+               prescale.scale[0],
+               prescale.scale[1]);
+
+      H[0] = (float)rect.w / 2.0;
+      H[1] = -(float)rect.h / 2.0;
+      J[0] = (float)rect.x + (float)rect.w / 2.0;
+      J[1] = (float)rect.y + (float)rect.h / 2.0;
+
+      SVGA_DBG(DEBUG_VIEWPORT,
+               "H %f,%f\n"
+               "J %fx%f\n",
+               H[0],
+               H[1],
+               J[0],
+               J[1]);
+
+      /* Adjust prescale to take into account the fact that it is
+       * going to be applied prior to the perspective divide and
+       * viewport transformation.
+       * 
+       * Vwin = H(Vc/Vc.w) + J
+       *
+       * We want to tweak Vwin with scale and translation from above,
+       * as in:
+       *
+       * Vwin' = S Vwin + T
+       *
+       * But we can only modify the values at Vc.  Plugging all the
+       * above together, and rearranging, eventually we get:
+       *
+       *   Vwin' = H(Vc'/Vc'.w) + J
+       * where:
+       *   Vc' = SVc + KVc.w
+       *   K = (T + (S-1)J) / H
+       *
+       * Overwrite prescale.translate with values for K:
+       */
+      for (i = 0; i < 2; i++) {
+         prescale.translate[i] = ((prescale.translate[i] +
+                                   (prescale.scale[i] - 1.0) * J[i]) / H[i]);
+      }
+
+      SVGA_DBG(DEBUG_VIEWPORT,
+               "clipspace %f,%f %fx%f\n",
+               prescale.translate[0],
+               prescale.translate[1],
+               prescale.scale[0],
+               prescale.scale[1]);
+   }
+
+out:
+   if (degenerate) {
+      rect.x = 0;
+      rect.y = 0;
+      rect.w = 1;
+      rect.h = 1;
+      prescale.enabled = FALSE;
+   }
+
+   if (memcmp(&rect, &svga->state.hw_clear.viewport, sizeof(rect)) != 0) {
+      ret = SVGA3D_SetViewport(svga->swc, &rect);
+      if(ret != PIPE_OK)
+         return ret;
+
+      memcpy(&svga->state.hw_clear.viewport, &rect, sizeof(rect));
+      assert(sizeof(rect) == sizeof(svga->state.hw_clear.viewport));
+   }
+
+   if (svga->state.hw_clear.depthrange.zmin != range_min ||
+       svga->state.hw_clear.depthrange.zmax != range_max) 
+   {
+      ret = SVGA3D_SetZRange(svga->swc, range_min, range_max );
+      if(ret != PIPE_OK)
+         return ret;
+
+      svga->state.hw_clear.depthrange.zmin = range_min;
+      svga->state.hw_clear.depthrange.zmax = range_max;
+   }
+
+   if (memcmp(&prescale, &svga->state.hw_clear.prescale, sizeof prescale) != 0) {
+      svga->dirty |= SVGA_NEW_PRESCALE;
+      svga->state.hw_clear.prescale = prescale;
+   }
+
+   return 0;
+}
+
+
+struct svga_tracked_state svga_hw_viewport = 
+{
+   "hw viewport state",
+   ( SVGA_NEW_FRAME_BUFFER |
+     SVGA_NEW_VIEWPORT |
+     SVGA_NEW_RAST |
+     SVGA_NEW_REDUCED_PRIMITIVE ),
+   emit_viewport
+};
+
+
+/***********************************************************************
+ * Scissor state
+ */
+static int emit_scissor_rect( struct svga_context *svga,
+                              unsigned dirty )
+{
+   const struct pipe_scissor_state *scissor = &svga->curr.scissor;
+   SVGA3dRect rect;
+
+   rect.x = scissor->minx;
+   rect.y = scissor->miny;
+   rect.w = scissor->maxx - scissor->minx; /* + 1 ?? */
+   rect.h = scissor->maxy - scissor->miny; /* + 1 ?? */
+   
+   return SVGA3D_SetScissorRect(svga->swc, &rect);
+}
+
+
+struct svga_tracked_state svga_hw_scissor = 
+{
+   "hw scissor state",
+   SVGA_NEW_SCISSOR,
+   emit_scissor_rect
+};
+
+
+/***********************************************************************
+ * Userclip state
+ */
+
+static int emit_clip_planes( struct svga_context *svga,
+                             unsigned dirty )
+{
+   unsigned i;
+   enum pipe_error ret;
+
+   /* TODO: just emit directly from svga_set_clip_state()?
+    */
+   for (i = 0; i < svga->curr.clip.nr; i++) {
+      ret = SVGA3D_SetClipPlane( svga->swc,
+                                 i,
+                                 svga->curr.clip.ucp[i] );
+      if(ret != PIPE_OK)
+         return ret;
+   }
+
+   return 0;
+}
+
+
+struct svga_tracked_state svga_hw_clip_planes = 
+{
+   "hw viewport state",
+   SVGA_NEW_CLIP,
+   emit_clip_planes
+};
diff --git a/src/gallium/drivers/svga/svga_state_fs.c b/src/gallium/drivers/svga/svga_state_fs.c
new file mode 100644 (file)
index 0000000..bba80a9
--- /dev/null
@@ -0,0 +1,302 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "pipe/p_inlines.h"
+#include "pipe/p_defines.h"
+#include "util/u_math.h"
+#include "util/u_bitmask.h"
+
+#include "svga_context.h"
+#include "svga_state.h"
+#include "svga_cmd.h"
+#include "svga_tgsi.h"
+
+#include "svga_hw_reg.h"
+
+
+
+static INLINE int compare_fs_keys( const struct svga_fs_compile_key *a,
+                                   const struct svga_fs_compile_key *b )
+{
+   unsigned keysize_a = svga_fs_key_size( a );
+   unsigned keysize_b = svga_fs_key_size( b );
+
+   if (keysize_a != keysize_b) {
+      return (int)(keysize_a - keysize_b);
+   }
+   return memcmp( a, b, keysize_a );
+}
+
+
+static struct svga_shader_result *search_fs_key( struct svga_fragment_shader *fs,
+                                                 const struct svga_fs_compile_key *key )
+{
+   struct svga_shader_result *result = fs->base.results;
+
+   assert(key);
+
+   for ( ; result; result = result->next) {
+      if (compare_fs_keys( key, &result->key.fkey ) == 0)
+         return result;
+   }
+   
+   return NULL;
+}
+
+
+static enum pipe_error compile_fs( struct svga_context *svga,
+                                   struct svga_fragment_shader *fs,
+                                   const struct svga_fs_compile_key *key,
+                                   struct svga_shader_result **out_result )
+{
+   struct svga_shader_result *result;
+   enum pipe_error ret;
+
+   result = svga_translate_fragment_program( fs, key );
+   if (result == NULL) {
+      ret = PIPE_ERROR_OUT_OF_MEMORY;
+      goto fail;
+   }
+
+   result->id = util_bitmask_add(svga->fs_bm);
+   if(result->id == UTIL_BITMASK_INVALID_INDEX)
+      goto fail;
+
+   ret = SVGA3D_DefineShader(svga->swc, 
+                             result->id,
+                             SVGA3D_SHADERTYPE_PS,
+                             result->tokens, 
+                             result->nr_tokens * sizeof result->tokens[0]);
+   if (ret)
+      goto fail;
+
+   *out_result = result;
+   result->next = fs->base.results;
+   fs->base.results = result;
+   return PIPE_OK;
+
+fail:
+   if (result) {
+      if (result->id != UTIL_BITMASK_INVALID_INDEX)
+         util_bitmask_clear( svga->fs_bm, result->id );
+      svga_destroy_shader_result( result );
+   }
+   return ret;
+}
+
+/* The blend workaround for simulating logicop xor behaviour requires
+ * that the incoming fragment color be white.  This change achieves
+ * that by hooking up a hard-wired fragment shader that just emits
+ * color 1,1,1,1
+ *   
+ * This is a slightly incomplete solution as it assumes that the
+ * actual bound shader has no other effects beyond generating a
+ * fragment color.  In particular shaders containing TEXKIL and/or
+ * depth-write will not have the correct behaviour, nor will those
+ * expecting to use alphatest.
+ *   
+ * These are avoidable issues, but they are not much worse than the
+ * unavoidable ones associated with this technique, so it's not clear
+ * how much effort should be expended trying to resolve them - the
+ * ultimate result will still not be correct in most cases.
+ *
+ * Shader below was generated with:
+ *   SVGA_DEBUG=tgsi ./mesa/progs/fp/fp-tri white.txt
+ */
+static int emit_white_fs( struct svga_context *svga )
+{
+   int ret = PIPE_ERROR;
+
+   /* ps_3_0
+    * def c0, 1.000000, 0.000000, 0.000000, 1.000000
+    * mov oC0, c0.x
+    * end
+    */
+   static const unsigned white_tokens[] = {
+      0xffff0300,
+      0x05000051,
+      0xa00f0000,
+      0x3f800000,
+      0x00000000,
+      0x00000000,
+      0x3f800000,
+      0x02000001,
+      0x800f0800,
+      0xa0000000,
+      0x0000ffff,
+   };
+
+   assert(SVGA3D_INVALID_ID == UTIL_BITMASK_INVALID_INDEX);
+   svga->state.white_fs_id = util_bitmask_add(svga->fs_bm);
+   if(svga->state.white_fs_id == SVGA3D_INVALID_ID)
+      goto no_fs_id;
+
+   ret = SVGA3D_DefineShader(svga->swc, 
+                             svga->state.white_fs_id,
+                             SVGA3D_SHADERTYPE_PS,
+                             white_tokens, 
+                             sizeof(white_tokens));
+   if (ret)
+      goto no_definition;
+
+   return 0;
+
+no_definition:
+   util_bitmask_clear(svga->fs_bm, svga->state.white_fs_id);
+   svga->state.white_fs_id = SVGA3D_INVALID_ID;
+no_fs_id:
+   return ret;
+}
+
+
+/* SVGA_NEW_TEXTURE_BINDING
+ * SVGA_NEW_RAST
+ * SVGA_NEW_NEED_SWTNL
+ * SVGA_NEW_SAMPLER
+ */
+static int make_fs_key( const struct svga_context *svga,
+                        struct svga_fs_compile_key *key )
+{
+   int i;
+   int idx = 0;
+
+   memset(key, 0, sizeof *key);
+
+   /* Only need fragment shader fixup for twoside lighting if doing
+    * hwtnl.  Otherwise the draw module does the whole job for us.
+    *
+    * SVGA_NEW_SWTNL
+    */
+   if (!svga->state.sw.need_swtnl) {
+      /* SVGA_NEW_RAST
+       */
+      key->light_twoside = svga->curr.rast->templ.light_twoside;
+      key->front_cw = (svga->curr.rast->templ.front_winding == 
+                       PIPE_WINDING_CW);
+   }
+
+   
+   /* XXX: want to limit this to the textures that the shader actually
+    * refers to.
+    *
+    * SVGA_NEW_TEXTURE_BINDING | SVGA_NEW_SAMPLER
+    */
+   for (i = 0; i < svga->curr.num_textures; i++) {
+      if (svga->curr.texture[i]) {
+         assert(svga->curr.sampler[i]);
+         key->tex[i].texture_target = svga->curr.texture[i]->target;
+         if (!svga->curr.sampler[i]->normalized_coords) {
+            key->tex[i].width_height_idx = idx++;
+            key->tex[i].unnormalized = TRUE;
+            ++key->num_unnormalized_coords;
+         }
+      }
+   }
+   key->num_textures = svga->curr.num_textures;
+
+   idx = 0;
+   for (i = 0; i < svga->curr.num_samplers; ++i) {
+      if (svga->curr.sampler[i]) {
+         key->tex[i].compare_mode = svga->curr.sampler[i]->compare_mode;
+         key->tex[i].compare_func = svga->curr.sampler[i]->compare_func;
+      }
+   }
+
+   return 0;
+}
+
+
+
+static int emit_hw_fs( struct svga_context *svga,
+                       unsigned dirty )
+{
+   struct svga_shader_result *result = NULL;
+   unsigned id = SVGA3D_INVALID_ID;
+   int ret = 0;
+
+   /* SVGA_NEW_BLEND
+    */
+   if (svga->curr.blend->need_white_fragments) {
+      if (svga->state.white_fs_id == SVGA3D_INVALID_ID) {
+         ret = emit_white_fs( svga );
+         if (ret)
+            return ret;
+      }
+      id = svga->state.white_fs_id;
+   }
+   else {
+      struct svga_fragment_shader *fs = svga->curr.fs;
+      struct svga_fs_compile_key key;
+
+      /* SVGA_NEW_TEXTURE_BINDING
+       * SVGA_NEW_RAST
+       * SVGA_NEW_NEED_SWTNL
+       * SVGA_NEW_SAMPLER
+       */
+      ret = make_fs_key( svga, &key );
+      if (ret)
+         return ret;
+
+      result = search_fs_key( fs, &key );
+      if (!result) {
+         ret = compile_fs( svga, fs, &key, &result );
+         if (ret)
+            return ret;
+      }
+
+      assert (result);
+      id = result->id;
+   }
+
+   assert(id != SVGA3D_INVALID_ID);
+
+   if (result != svga->state.hw_draw.fs) {
+      ret = SVGA3D_SetShader(svga->swc,
+                             SVGA3D_SHADERTYPE_PS,
+                             id );
+      if (ret)
+         return ret;
+
+      svga->dirty |= SVGA_NEW_FS_RESULT;
+      svga->state.hw_draw.fs = result;      
+   }
+
+   return 0;
+}
+
+struct svga_tracked_state svga_hw_fs = 
+{
+   "fragment shader (hwtnl)",
+   (SVGA_NEW_FS |
+    SVGA_NEW_TEXTURE_BINDING |
+    SVGA_NEW_NEED_SWTNL |
+    SVGA_NEW_RAST |
+    SVGA_NEW_SAMPLER |
+    SVGA_NEW_BLEND),
+   emit_hw_fs
+};
+
+
+
diff --git a/src/gallium/drivers/svga/svga_state_need_swtnl.c b/src/gallium/drivers/svga/svga_state_need_swtnl.c
new file mode 100644 (file)
index 0000000..3c35a85
--- /dev/null
@@ -0,0 +1,200 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "pipe/p_inlines.h"
+#include "pipe/p_state.h"
+
+
+#include "svga_context.h"
+#include "svga_state.h"
+#include "svga_debug.h"
+#include "svga_hw_reg.h"
+
+/***********************************************************************
+ */
+
+static INLINE SVGA3dDeclType 
+svga_translate_vertex_format(enum pipe_format format)
+{
+   switch (format) {
+   case PIPE_FORMAT_R32_FLOAT:            return SVGA3D_DECLTYPE_FLOAT1;
+   case PIPE_FORMAT_R32G32_FLOAT:         return SVGA3D_DECLTYPE_FLOAT2;
+   case PIPE_FORMAT_R32G32B32_FLOAT:      return SVGA3D_DECLTYPE_FLOAT3;
+   case PIPE_FORMAT_R32G32B32A32_FLOAT:   return SVGA3D_DECLTYPE_FLOAT4;
+   case PIPE_FORMAT_B8G8R8A8_UNORM:       return SVGA3D_DECLTYPE_D3DCOLOR;
+   case PIPE_FORMAT_R8G8B8A8_USCALED:     return SVGA3D_DECLTYPE_UBYTE4;
+   case PIPE_FORMAT_R16G16_SSCALED:       return SVGA3D_DECLTYPE_SHORT2;
+   case PIPE_FORMAT_R16G16B16A16_SSCALED: return SVGA3D_DECLTYPE_SHORT4;
+   case PIPE_FORMAT_R8G8B8A8_UNORM:       return SVGA3D_DECLTYPE_UBYTE4N;
+   case PIPE_FORMAT_R16G16_SNORM:         return SVGA3D_DECLTYPE_SHORT2N;
+   case PIPE_FORMAT_R16G16B16A16_SNORM:   return SVGA3D_DECLTYPE_SHORT4N;
+   case PIPE_FORMAT_R16G16_UNORM:         return SVGA3D_DECLTYPE_USHORT2N;
+   case PIPE_FORMAT_R16G16B16A16_UNORM:   return SVGA3D_DECLTYPE_USHORT4N;
+
+   /* These formats don't exist yet:
+    * 
+   case PIPE_FORMAT_R10G10B10_USCALED:    return SVGA3D_DECLTYPE_UDEC3;
+   case PIPE_FORMAT_R10G10B10_SNORM:      return SVGA3D_DECLTYPE_DEC3N;
+   case PIPE_FORMAT_R16G16_FLOAT:         return SVGA3D_DECLTYPE_FLOAT16_2;
+   case PIPE_FORMAT_R16G16B16A16_FLOAT:   return SVGA3D_DECLTYPE_FLOAT16_4;
+   */
+
+   default:
+      /* There are many formats without hardware support.  This case
+       * will be hit regularly, meaning we'll need swvfetch.
+       */
+      return SVGA3D_DECLTYPE_MAX;
+   }
+}
+
+
+static int update_need_swvfetch( struct svga_context *svga,
+                                 unsigned dirty )
+{
+   unsigned i;
+   boolean need_swvfetch = FALSE;
+
+   for (i = 0; i < svga->curr.num_vertex_elements; i++) {
+      svga->state.sw.ve_format[i] = svga_translate_vertex_format(svga->curr.ve[i].src_format);
+      if (svga->state.sw.ve_format[i] == SVGA3D_DECLTYPE_MAX) {
+         need_swvfetch = TRUE;
+         break;
+      }
+   }
+
+   if (need_swvfetch != svga->state.sw.need_swvfetch) {
+      svga->state.sw.need_swvfetch = need_swvfetch;
+      svga->dirty |= SVGA_NEW_NEED_SWVFETCH;
+   }
+   
+   return 0;
+}
+
+struct svga_tracked_state svga_update_need_swvfetch = 
+{
+   "update need_swvfetch",
+   ( SVGA_NEW_VELEMENT ),
+   update_need_swvfetch
+};
+
+
+/*********************************************************************** 
+ */
+
+static int update_need_pipeline( struct svga_context *svga,
+                                 unsigned dirty )
+{
+   
+   boolean need_pipeline = FALSE;
+   struct svga_vertex_shader *vs = svga->curr.vs;
+
+   /* SVGA_NEW_RAST, SVGA_NEW_REDUCED_PRIMITIVE
+    */
+   if (svga->curr.rast->need_pipeline & (1 << svga->curr.reduced_prim)) {
+      SVGA_DBG(DEBUG_SWTNL, "%s: rast need_pipeline (%d) & prim (%x)\n", 
+                 __FUNCTION__,
+                 svga->curr.rast->need_pipeline,
+                 (1 << svga->curr.reduced_prim) );
+      need_pipeline = TRUE;
+   }
+
+   /* EDGEFLAGS
+    */
+    if (vs->base.info.writes_edgeflag) {
+      SVGA_DBG(DEBUG_SWTNL, "%s: edgeflags\n", __FUNCTION__);
+      need_pipeline = TRUE;
+   }
+
+   /* SVGA_NEW_CLIP 
+    */
+   if (!svga->curr.rast->templ.bypass_vs_clip_and_viewport &&
+       svga->curr.clip.nr) {
+      SVGA_DBG(DEBUG_SWTNL, "%s: userclip\n", __FUNCTION__);
+      need_pipeline = TRUE;
+   }
+
+   if (need_pipeline != svga->state.sw.need_pipeline) {
+      svga->state.sw.need_pipeline = need_pipeline;
+      svga->dirty |= SVGA_NEW_NEED_PIPELINE;
+   }
+
+   return 0;
+}
+
+
+struct svga_tracked_state svga_update_need_pipeline = 
+{
+   "need pipeline",
+   (SVGA_NEW_RAST |
+    SVGA_NEW_CLIP |
+    SVGA_NEW_VS |
+    SVGA_NEW_REDUCED_PRIMITIVE),
+   update_need_pipeline
+};
+
+
+/*********************************************************************** 
+ */
+
+static int update_need_swtnl( struct svga_context *svga,
+                              unsigned dirty )
+{
+   boolean need_swtnl;
+
+   if (svga->debug.no_swtnl) {
+      svga->state.sw.need_swvfetch = 0;
+      svga->state.sw.need_pipeline = 0;
+   }
+
+   need_swtnl = (svga->state.sw.need_swvfetch ||
+                 svga->state.sw.need_pipeline);
+
+   if (svga->debug.force_swtnl) {
+      need_swtnl = 1;
+   }
+
+   if (need_swtnl != svga->state.sw.need_swtnl) {
+      SVGA_DBG(DEBUG_SWTNL|DEBUG_PERF,
+               "%s need_swvfetch: %s, need_pipeline %s\n",
+               __FUNCTION__,
+               svga->state.sw.need_swvfetch ? "true" : "false",
+               svga->state.sw.need_pipeline ? "true" : "false");
+
+      svga->state.sw.need_swtnl = need_swtnl;
+      svga->dirty |= SVGA_NEW_NEED_SWTNL;
+      svga->swtnl.new_vdecl = TRUE;
+   }
+  
+   return 0;
+}
+
+
+struct svga_tracked_state svga_update_need_swtnl =
+{
+   "need swtnl",
+   (SVGA_NEW_NEED_PIPELINE |
+    SVGA_NEW_NEED_SWVFETCH),
+   update_need_swtnl
+};
diff --git a/src/gallium/drivers/svga/svga_state_rss.c b/src/gallium/drivers/svga/svga_state_rss.c
new file mode 100644 (file)
index 0000000..8b6803a
--- /dev/null
@@ -0,0 +1,268 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "pipe/p_inlines.h"
+#include "pipe/p_defines.h"
+#include "util/u_math.h"
+
+#include "svga_context.h"
+#include "svga_state.h"
+#include "svga_cmd.h"
+
+#include "svga_hw_reg.h"
+
+
+
+struct rs_queue {
+   unsigned rs_count;
+   SVGA3dRenderState rs[SVGA3D_RS_MAX];
+};
+
+
+#define EMIT_RS(svga, value, token, fail)                       \
+do {                                                            \
+   if (svga->state.hw_draw.rs[SVGA3D_RS_##token] != value) {    \
+      svga_queue_rs( &queue, SVGA3D_RS_##token, value );        \
+      svga->state.hw_draw.rs[SVGA3D_RS_##token] = value;        \
+   }                                                            \
+} while (0)
+
+#define EMIT_RS_FLOAT(svga, fvalue, token, fail)                \
+do {                                                            \
+   unsigned value = fui(fvalue);                                \
+   if (svga->state.hw_draw.rs[SVGA3D_RS_##token] != value) {    \
+      svga_queue_rs( &queue, SVGA3D_RS_##token, value );        \
+      svga->state.hw_draw.rs[SVGA3D_RS_##token] = value;        \
+   }                                                            \
+} while (0)
+
+
+static INLINE void
+svga_queue_rs( struct rs_queue *q,
+               unsigned rss,
+               unsigned value )
+{
+   q->rs[q->rs_count].state = rss;
+   q->rs[q->rs_count].uintValue = value;
+   q->rs_count++;
+}
+
+
+/* Compare old and new render states and emit differences between them
+ * to hardware.  Simplest implementation would be to emit the whole of
+ * the "to" state.
+ */
+static int emit_rss( struct svga_context *svga,
+                     unsigned dirty )
+{
+   struct rs_queue queue;
+
+   queue.rs_count = 0;
+
+   if (dirty & SVGA_NEW_BLEND) {
+      const struct svga_blend_state *curr = svga->curr.blend;
+
+      EMIT_RS( svga, curr->rt[0].writemask, COLORWRITEENABLE, fail );
+      EMIT_RS( svga, curr->rt[0].blend_enable, BLENDENABLE, fail );
+
+      if (curr->rt[0].blend_enable) {
+         EMIT_RS( svga, curr->rt[0].srcblend, SRCBLEND, fail );
+         EMIT_RS( svga, curr->rt[0].dstblend, DSTBLEND, fail );
+         EMIT_RS( svga, curr->rt[0].blendeq, BLENDEQUATION, fail );
+
+         EMIT_RS( svga, curr->rt[0].separate_alpha_blend_enable, 
+                  SEPARATEALPHABLENDENABLE, fail );
+
+         if (curr->rt[0].separate_alpha_blend_enable) {
+            EMIT_RS( svga, curr->rt[0].srcblend_alpha, SRCBLENDALPHA, fail );
+            EMIT_RS( svga, curr->rt[0].dstblend_alpha, DSTBLENDALPHA, fail );
+            EMIT_RS( svga, curr->rt[0].blendeq_alpha, BLENDEQUATIONALPHA, fail );
+         }
+      }
+   }
+
+
+   if (dirty & (SVGA_NEW_DEPTH_STENCIL | SVGA_NEW_RAST)) {
+      const struct svga_depth_stencil_state *curr = svga->curr.depth; 
+      const struct svga_rasterizer_state *rast = svga->curr.rast; 
+
+      if (!curr->stencil[0].enabled) 
+      {
+         /* Stencil disabled
+          */
+         EMIT_RS( svga, FALSE, STENCILENABLE, fail );
+         EMIT_RS( svga, FALSE, STENCILENABLE2SIDED, fail );
+      }
+      else if (curr->stencil[0].enabled && !curr->stencil[1].enabled)
+      {
+         /* Regular stencil
+          */
+         EMIT_RS( svga, TRUE, STENCILENABLE, fail );
+         EMIT_RS( svga, FALSE, STENCILENABLE2SIDED, fail );
+
+         EMIT_RS( svga, curr->stencil[0].func,  STENCILFUNC, fail );
+         EMIT_RS( svga, curr->stencil[0].fail,  STENCILFAIL, fail );
+         EMIT_RS( svga, curr->stencil[0].zfail, STENCILZFAIL, fail );
+         EMIT_RS( svga, curr->stencil[0].pass,  STENCILPASS, fail );
+         
+         EMIT_RS( svga, curr->stencil_ref, STENCILREF, fail );
+         EMIT_RS( svga, curr->stencil_mask, STENCILMASK, fail );
+         EMIT_RS( svga, curr->stencil_writemask, STENCILWRITEMASK, fail );
+      }
+      else 
+      {
+         int cw, ccw;
+
+         /* Hardware frontwinding is always CW, so if ours is also CW,
+          * then our definition of front face agrees with hardware.
+          * Otherwise need to flip.
+          */
+         if (rast->templ.front_winding == PIPE_WINDING_CW) {
+            cw = 0;
+            ccw = 1;
+         }
+         else {
+            cw = 1;
+            ccw = 0;
+         }
+
+         /* Twoside stencil
+          */
+         EMIT_RS( svga, TRUE, STENCILENABLE, fail );
+         EMIT_RS( svga, TRUE, STENCILENABLE2SIDED, fail );
+
+         EMIT_RS( svga, curr->stencil[cw].func,  STENCILFUNC, fail );
+         EMIT_RS( svga, curr->stencil[cw].fail,  STENCILFAIL, fail );
+         EMIT_RS( svga, curr->stencil[cw].zfail, STENCILZFAIL, fail );
+         EMIT_RS( svga, curr->stencil[cw].pass,  STENCILPASS, fail );
+
+         EMIT_RS( svga, curr->stencil[ccw].func,  CCWSTENCILFUNC, fail );
+         EMIT_RS( svga, curr->stencil[ccw].fail,  CCWSTENCILFAIL, fail );
+         EMIT_RS( svga, curr->stencil[ccw].zfail, CCWSTENCILZFAIL, fail );
+         EMIT_RS( svga, curr->stencil[ccw].pass,  CCWSTENCILPASS, fail );
+
+         EMIT_RS( svga, curr->stencil_ref, STENCILREF, fail );
+         EMIT_RS( svga, curr->stencil_mask, STENCILMASK, fail );
+         EMIT_RS( svga, curr->stencil_writemask, STENCILWRITEMASK, fail );
+      }
+
+      EMIT_RS( svga, curr->zenable, ZENABLE, fail );
+      if (curr->zenable) {
+         EMIT_RS( svga, curr->zfunc, ZFUNC, fail );
+         EMIT_RS( svga, curr->zwriteenable, ZWRITEENABLE, fail );
+      }
+
+      EMIT_RS( svga, curr->alphatestenable, ALPHATESTENABLE, fail );
+      if (curr->alphatestenable) {
+         EMIT_RS( svga, curr->alphafunc, ALPHAFUNC, fail );
+         EMIT_RS_FLOAT( svga, curr->alpharef, ALPHAREF, fail );
+      }
+   }
+
+
+   if (dirty & SVGA_NEW_RAST)
+   {
+      const struct svga_rasterizer_state *curr = svga->curr.rast; 
+
+      /* Shademode: still need to rearrange index list to move
+       * flat-shading PV first vertex.
+       */
+      EMIT_RS( svga, curr->shademode, SHADEMODE, fail );
+      EMIT_RS( svga, curr->cullmode, CULLMODE, fail );
+      EMIT_RS( svga, curr->scissortestenable, SCISSORTESTENABLE, fail );
+      EMIT_RS( svga, curr->multisampleantialias, MULTISAMPLEANTIALIAS, fail );
+      EMIT_RS( svga, curr->lastpixel, LASTPIXEL, fail );
+      EMIT_RS( svga, curr->linepattern, LINEPATTERN, fail );
+      EMIT_RS_FLOAT( svga, curr->pointsize, POINTSIZE, fail );
+      EMIT_RS_FLOAT( svga, curr->pointsize_min, POINTSIZEMIN, fail );
+      EMIT_RS_FLOAT( svga, curr->pointsize_max, POINTSIZEMAX, fail );
+   }
+
+   if (dirty & (SVGA_NEW_RAST | SVGA_NEW_FRAME_BUFFER | SVGA_NEW_NEED_PIPELINE))
+   {
+      const struct svga_rasterizer_state *curr = svga->curr.rast; 
+      float slope = 0.0;
+      float bias  = 0.0;
+
+      /* Need to modify depth bias according to bound depthbuffer
+       * format.  Don't do hardware depthbias while the software
+       * pipeline is active.
+       */
+      if (!svga->state.sw.need_pipeline &&
+          svga->curr.framebuffer.zsbuf)
+      {
+         slope = curr->slopescaledepthbias;
+         bias  = svga->curr.depthscale * curr->depthbias;
+      }
+
+      EMIT_RS_FLOAT( svga, slope, SLOPESCALEDEPTHBIAS, fail );
+      EMIT_RS_FLOAT( svga, bias, DEPTHBIAS, fail );
+   }
+
+
+   if (queue.rs_count) {
+      SVGA3dRenderState *rs;
+
+      if (SVGA3D_BeginSetRenderState( svga->swc,
+                                      &rs,
+                                      queue.rs_count ) != PIPE_OK)
+         goto fail;
+
+      memcpy( rs,
+              queue.rs,
+              queue.rs_count * sizeof queue.rs[0]);
+      
+      SVGA_FIFOCommitAll( svga->swc );
+   }
+
+   /* Also blend color:
+    */
+
+   return 0;
+
+fail:
+   /* XXX: need to poison cached hardware state on failure to ensure
+    * dirty state gets re-emitted.  Fix this by re-instating partial
+    * FIFOCommit command and only updating cached hw state once the
+    * initial allocation has succeeded.
+    */
+   memset(svga->state.hw_draw.rs, 0xcd, sizeof(svga->state.hw_draw.rs));
+
+   return PIPE_ERROR_OUT_OF_MEMORY;
+}
+
+
+struct svga_tracked_state svga_hw_rss = 
+{
+   "hw rss state",
+
+   (SVGA_NEW_BLEND |
+    SVGA_NEW_DEPTH_STENCIL |
+    SVGA_NEW_RAST |
+    SVGA_NEW_FRAME_BUFFER |
+    SVGA_NEW_NEED_PIPELINE),
+
+   emit_rss
+};
diff --git a/src/gallium/drivers/svga/svga_state_tss.c b/src/gallium/drivers/svga/svga_state_tss.c
new file mode 100644 (file)
index 0000000..b313794
--- /dev/null
@@ -0,0 +1,279 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "pipe/p_inlines.h"
+#include "pipe/p_defines.h"
+#include "util/u_math.h"
+
+#include "svga_screen_texture.h"
+#include "svga_winsys.h"
+#include "svga_context.h"
+#include "svga_state.h"
+#include "svga_cmd.h"
+
+#include "svga_hw_reg.h"
+
+
+void svga_cleanup_tss_binding(struct svga_context *svga)
+{
+   int i;
+   unsigned count = MAX2( svga->curr.num_textures,
+                          svga->state.hw_draw.num_views );
+
+   for (i = 0; i < count; i++) {
+      struct svga_hw_view_state *view = &svga->state.hw_draw.views[i];
+
+      svga_sampler_view_reference(&view->v, NULL);
+      pipe_texture_reference( &svga->curr.texture[i], NULL );
+      pipe_texture_reference( &view->texture, NULL );
+
+      view->dirty = 1;
+   }
+}
+
+
+static int
+update_tss_binding(struct svga_context *svga, 
+                   unsigned dirty )
+{
+   unsigned i;
+   unsigned count = MAX2( svga->curr.num_textures,
+                          svga->state.hw_draw.num_views );
+   unsigned min_lod;
+   unsigned max_lod;
+
+
+   struct {
+      struct {
+         unsigned unit;
+         struct svga_hw_view_state *view;
+      } bind[PIPE_MAX_SAMPLERS];
+
+      unsigned bind_count;
+   } queue;
+
+   queue.bind_count = 0;
+   
+   for (i = 0; i < count; i++) {
+      const struct svga_sampler_state *s = svga->curr.sampler[i];
+      struct svga_hw_view_state *view = &svga->state.hw_draw.views[i];
+
+      /* get min max lod */
+      if (svga->curr.texture[i]) {
+         min_lod = MAX2(s->view_min_lod, 0);
+         max_lod = MIN2(s->view_max_lod, svga->curr.texture[i]->last_level);
+      } else {
+         min_lod = 0;
+         max_lod = 0;
+      }
+
+      if (view->texture != svga->curr.texture[i] ||
+          view->min_lod != min_lod ||
+          view->max_lod != max_lod) {
+
+         svga_sampler_view_reference(&view->v, NULL);
+         pipe_texture_reference( &view->texture, svga->curr.texture[i] );
+
+         view->dirty = TRUE;
+         view->min_lod = min_lod;
+         view->max_lod = max_lod;
+
+         if (svga->curr.texture[i])
+            view->v = svga_get_tex_sampler_view(&svga->pipe, 
+                                                svga->curr.texture[i], 
+                                                min_lod,
+                                                max_lod);
+      }
+
+      if (view->dirty) {
+         queue.bind[queue.bind_count].unit = i;
+         queue.bind[queue.bind_count].view = view;
+         queue.bind_count++;
+      } 
+      else if (view->v) {
+         svga_validate_sampler_view(svga, view->v);
+      }
+   }
+
+   svga->state.hw_draw.num_views = svga->curr.num_textures;
+
+   if (queue.bind_count) {
+      SVGA3dTextureState *ts;
+
+      if (SVGA3D_BeginSetTextureState( svga->swc,
+                                       &ts,
+                                       queue.bind_count ) != PIPE_OK)
+         goto fail;
+
+      for (i = 0; i < queue.bind_count; i++) {
+         ts[i].stage = queue.bind[i].unit;
+         ts[i].name = SVGA3D_TS_BIND_TEXTURE;
+
+         if (queue.bind[i].view->v) {
+            svga->swc->surface_relocation(svga->swc,
+                                          &ts[i].value,
+                                          queue.bind[i].view->v->handle,
+                                          PIPE_BUFFER_USAGE_GPU_READ);
+         }
+         else {
+            ts[i].value = SVGA3D_INVALID_ID;
+         }
+         
+         queue.bind[i].view->dirty = FALSE;
+      }
+
+      SVGA_FIFOCommitAll( svga->swc );
+   }
+
+   return 0;
+
+fail:
+   return PIPE_ERROR_OUT_OF_MEMORY;
+}
+
+
+struct svga_tracked_state svga_hw_tss_binding = {
+   "texture binding emit",
+   SVGA_NEW_TEXTURE_BINDING |
+   SVGA_NEW_SAMPLER,
+   update_tss_binding
+};
+
+
+/***********************************************************************
+ */
+
+struct ts_queue {
+   unsigned ts_count;
+   SVGA3dTextureState ts[PIPE_MAX_SAMPLERS*SVGA3D_TS_MAX];
+};
+
+
+#define EMIT_TS(svga, unit, val, token, fail)                           \
+do {                                                                    \
+   if (svga->state.hw_draw.ts[unit][SVGA3D_TS_##token] != val) {        \
+      svga_queue_tss( &queue, unit, SVGA3D_TS_##token, val );           \
+      svga->state.hw_draw.ts[unit][SVGA3D_TS_##token] = val;            \
+   }                                                                    \
+} while (0)
+
+#define EMIT_TS_FLOAT(svga, unit, fvalue, token, fail)                  \
+do {                                                                    \
+   unsigned val = fui(fvalue);                                          \
+   if (svga->state.hw_draw.ts[unit][SVGA3D_TS_##token] != val) {        \
+      svga_queue_tss( &queue, unit, SVGA3D_TS_##token, val );           \
+      svga->state.hw_draw.ts[unit][SVGA3D_TS_##token] = val;            \
+   }                                                                    \
+} while (0)
+
+
+static INLINE void 
+svga_queue_tss( struct ts_queue *q,
+                unsigned unit,
+                unsigned tss,
+                unsigned value )
+{
+   assert(q->ts_count < sizeof(q->ts)/sizeof(q->ts[0]));
+   q->ts[q->ts_count].stage = unit;
+   q->ts[q->ts_count].name = tss;
+   q->ts[q->ts_count].value = value;
+   q->ts_count++;
+}
+
+
+static int
+update_tss(struct svga_context *svga, 
+           unsigned dirty )
+{
+   unsigned i;
+   struct ts_queue queue;
+
+   queue.ts_count = 0;
+   for (i = 0; i < svga->curr.num_samplers; i++) {
+      if (svga->curr.sampler[i]) {
+         const struct svga_sampler_state *curr = svga->curr.sampler[i];
+
+         EMIT_TS(svga, i, curr->mipfilter, MIPFILTER, fail);
+         EMIT_TS(svga, i, curr->min_lod, TEXTURE_MIPMAP_LEVEL, fail);
+         EMIT_TS(svga, i, curr->magfilter, MAGFILTER, fail);
+         EMIT_TS(svga, i, curr->minfilter, MINFILTER, fail);
+         EMIT_TS(svga, i, curr->aniso_level, TEXTURE_ANISOTROPIC_LEVEL, fail);
+         EMIT_TS_FLOAT(svga, i, curr->lod_bias, TEXTURE_LOD_BIAS, fail);
+         EMIT_TS(svga, i, curr->addressu, ADDRESSU, fail);
+         EMIT_TS(svga, i, curr->addressw, ADDRESSW, fail);
+         EMIT_TS(svga, i, curr->bordercolor, BORDERCOLOR, fail);
+         // TEXCOORDINDEX -- hopefully not needed
+
+         if (svga->curr.tex_flags.flag_1d & (1 << i)) {
+            debug_printf("wrap 1d tex %d\n", i);
+            EMIT_TS(svga, i, SVGA3D_TEX_ADDRESS_WRAP, ADDRESSV, fail);
+         }
+         else
+            EMIT_TS(svga, i, curr->addressv, ADDRESSV, fail);
+
+         if (svga->curr.tex_flags.flag_srgb & (1 << i))
+            EMIT_TS_FLOAT(svga, i, 2.2f, GAMMA, fail);
+         else
+            EMIT_TS_FLOAT(svga, i, 1.0f, GAMMA, fail);
+
+      }
+   }
+   if (queue.ts_count) {
+      SVGA3dTextureState *ts;
+
+      if (SVGA3D_BeginSetTextureState( svga->swc,
+                                       &ts,
+                                       queue.ts_count ) != PIPE_OK)
+         goto fail;
+
+      memcpy( ts,
+              queue.ts,
+              queue.ts_count * sizeof queue.ts[0]);
+      
+      SVGA_FIFOCommitAll( svga->swc );
+   }
+
+   return 0;
+
+fail:
+   /* XXX: need to poison cached hardware state on failure to ensure
+    * dirty state gets re-emitted.  Fix this by re-instating partial
+    * FIFOCommit command and only updating cached hw state once the
+    * initial allocation has succeeded.
+    */
+   memset(svga->state.hw_draw.ts, 0xcd, sizeof(svga->state.hw_draw.ts));
+
+   return PIPE_ERROR_OUT_OF_MEMORY;
+}
+
+
+struct svga_tracked_state svga_hw_tss = {
+   "texture state emit",
+   (SVGA_NEW_SAMPLER |
+    SVGA_NEW_TEXTURE_FLAGS),
+   update_tss
+};
+
diff --git a/src/gallium/drivers/svga/svga_state_vdecl.c b/src/gallium/drivers/svga/svga_state_vdecl.c
new file mode 100644 (file)
index 0000000..c534308
--- /dev/null
@@ -0,0 +1,182 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "pipe/p_inlines.h"
+#include "pipe/p_defines.h"
+#include "util/u_math.h"
+#include "util/u_upload_mgr.h"
+
+#include "svga_context.h"
+#include "svga_state.h"
+#include "svga_draw.h"
+#include "svga_tgsi.h"
+#include "svga_screen.h"
+#include "svga_screen_buffer.h"
+
+#include "svga_hw_reg.h"
+
+
+static int
+upload_user_buffers( struct svga_context *svga )
+{
+   enum pipe_error ret = PIPE_OK;
+   int i;
+   int nr;
+
+   if (0) 
+      debug_printf("%s: %d\n", __FUNCTION__, svga->curr.num_vertex_buffers);
+
+   nr = svga->curr.num_vertex_buffers;
+
+   for (i = 0; i < nr; i++) 
+   {
+      if (svga_buffer_is_user_buffer(svga->curr.vb[i].buffer))
+      {
+         struct pipe_buffer *upload_buffer = NULL;
+         unsigned offset = /*svga->curr.vb[i].buffer_offset*/ 0;
+         unsigned size = svga->curr.vb[i].buffer->size /*- offset*/;
+         unsigned upload_offset;
+
+         ret = u_upload_buffer( svga->upload_vb,
+                                offset,
+                                size,
+                                svga->curr.vb[i].buffer,
+                                &upload_offset,
+                                &upload_buffer );
+         if (ret)
+            return ret;
+
+         if (0)
+            debug_printf("%s: %d: orig buf %p upl buf %p ofs %d sz %d\n", 
+                         __FUNCTION__, 
+                         i,
+                         svga->curr.vb[i].buffer,
+                         upload_buffer, upload_offset, size);
+
+         /* Make sure we release the old buffer and end up with the
+          * correct refcount on the uploaded buffer.
+          */
+         pipe_buffer_reference( &svga->curr.vb[i].buffer, NULL );
+         svga->curr.vb[i].buffer = upload_buffer;
+         svga->curr.vb[i].buffer_offset = upload_offset;
+      }
+   }
+
+   if (0)
+      debug_printf("%s: DONE\n", __FUNCTION__);
+
+   return ret;
+}
+
+
+/***********************************************************************
+ */
+
+
+static int emit_hw_vs_vdecl( struct svga_context *svga,
+                             unsigned dirty )
+{
+   const struct pipe_vertex_element *ve = svga->curr.ve;
+   SVGA3dVertexDecl decl;
+   unsigned i;
+
+   assert(svga->curr.num_vertex_elements >=
+          svga->curr.vs->base.info.file_count[TGSI_FILE_INPUT]);
+
+   svga_hwtnl_reset_vdecl( svga->hwtnl, 
+                           svga->curr.num_vertex_elements );
+
+   for (i = 0; i < svga->curr.num_vertex_elements; i++) {
+      const struct pipe_vertex_buffer *vb = &svga->curr.vb[ve[i].vertex_buffer_index];
+      unsigned usage, index;
+
+
+      svga_generate_vdecl_semantics( i, &usage, &index );
+
+      /* SVGA_NEW_VELEMENT
+       */
+      decl.identity.type = svga->state.sw.ve_format[i];
+      decl.identity.method = SVGA3D_DECLMETHOD_DEFAULT;
+      decl.identity.usage = usage;
+      decl.identity.usageIndex = index;
+      decl.array.stride = vb->stride;
+      decl.array.offset = (vb->buffer_offset +
+                           ve[i].src_offset);
+
+      svga_hwtnl_vdecl( svga->hwtnl,
+                        i,
+                        &decl,
+                        vb->buffer );
+   }
+
+   return 0;
+}
+
+
+static int emit_hw_vdecl( struct svga_context *svga,
+                          unsigned dirty )
+{
+   int ret = 0;
+
+   /* SVGA_NEW_NEED_SWTNL
+    */
+   if (svga->state.sw.need_swtnl)
+      return 0; /* Do not emit during swtnl */
+
+   /* If we get to here, we know that we're going to draw.  Upload
+    * userbuffers now and try to combine multiple userbuffers from
+    * multiple draw calls into a single host buffer for performance.
+    */
+   if (svga->curr.any_user_vertex_buffers &&
+       SVGA_COMBINE_USERBUFFERS)
+   {
+      ret = upload_user_buffers( svga );
+      if (ret)
+         return ret;
+
+      svga->curr.any_user_vertex_buffers = FALSE;
+   }
+
+   return emit_hw_vs_vdecl( svga, dirty );
+}
+
+
+struct svga_tracked_state svga_hw_vdecl = 
+{
+   "hw vertex decl state (hwtnl version)",
+   ( SVGA_NEW_NEED_SWTNL |
+     SVGA_NEW_VELEMENT |
+     SVGA_NEW_VBUFFER |
+     SVGA_NEW_RAST |
+     SVGA_NEW_FS |
+     SVGA_NEW_VS ),
+   emit_hw_vdecl
+};
+
+
+
+
+
+
diff --git a/src/gallium/drivers/svga/svga_state_vs.c b/src/gallium/drivers/svga/svga_state_vs.c
new file mode 100644 (file)
index 0000000..ae1e77e
--- /dev/null
@@ -0,0 +1,246 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "pipe/p_inlines.h"
+#include "pipe/p_defines.h"
+#include "util/u_format.h"
+#include "util/u_math.h"
+#include "util/u_bitmask.h"
+#include "translate/translate.h"
+
+#include "svga_context.h"
+#include "svga_state.h"
+#include "svga_cmd.h"
+#include "svga_tgsi.h"
+
+#include "svga_hw_reg.h"
+
+/***********************************************************************
+ */
+
+
+static INLINE int compare_vs_keys( const struct svga_vs_compile_key *a,
+                                   const struct svga_vs_compile_key *b )
+{
+   unsigned keysize = svga_vs_key_size( a );
+   return memcmp( a, b, keysize );
+}
+
+
+static struct svga_shader_result *search_vs_key( struct svga_vertex_shader *vs,
+                                                 const struct svga_vs_compile_key *key )
+{
+   struct svga_shader_result *result = vs->base.results;
+
+   assert(key);
+
+   for ( ; result; result = result->next) {
+      if (compare_vs_keys( key, &result->key.vkey ) == 0)
+         return result;
+   }
+   
+   return NULL;
+}
+
+
+static enum pipe_error compile_vs( struct svga_context *svga,
+                                   struct svga_vertex_shader *vs,
+                                   const struct svga_vs_compile_key *key,
+                                   struct svga_shader_result **out_result )
+{
+   struct svga_shader_result *result;
+   enum pipe_error ret = PIPE_OK;
+
+   result = svga_translate_vertex_program( vs, key );
+   if (result == NULL) {
+      ret = PIPE_ERROR_OUT_OF_MEMORY;
+      goto fail;
+   }
+
+   result->id = util_bitmask_add(svga->vs_bm);
+   if(result->id == UTIL_BITMASK_INVALID_INDEX)
+      goto fail;
+
+   ret = SVGA3D_DefineShader(svga->swc, 
+                             result->id,
+                             SVGA3D_SHADERTYPE_VS,
+                             result->tokens, 
+                             result->nr_tokens * sizeof result->tokens[0]);
+   if (ret)
+      goto fail;
+
+   *out_result = result;
+   result->next = vs->base.results;
+   vs->base.results = result;
+   return PIPE_OK;
+
+fail:
+   if (result) {
+      if (result->id != UTIL_BITMASK_INVALID_INDEX)
+         util_bitmask_clear( svga->vs_bm, result->id );
+      svga_destroy_shader_result( result );
+   }
+   return ret;
+}
+
+/* SVGA_NEW_PRESCALE, SVGA_NEW_RAST, SVGA_NEW_ZERO_STRIDE
+ */
+static int make_vs_key( struct svga_context *svga,
+                        struct svga_vs_compile_key *key )
+{
+   memset(key, 0, sizeof *key);
+   key->need_prescale = svga->state.hw_clear.prescale.enabled;
+   key->allow_psiz = svga->curr.rast->templ.point_size_per_vertex;
+   key->zero_stride_vertex_elements =
+      svga->curr.zero_stride_vertex_elements;
+   key->num_zero_stride_vertex_elements =
+      svga->curr.num_zero_stride_vertex_elements;
+   return 0;
+}
+
+
+
+static int emit_hw_vs( struct svga_context *svga,
+                       unsigned dirty )
+{
+   struct svga_shader_result *result = NULL;
+   unsigned id = SVGA3D_INVALID_ID;
+   int ret = 0;
+
+   /* SVGA_NEW_NEED_SWTNL */
+   if (!svga->state.sw.need_swtnl) {
+      struct svga_vertex_shader *vs = svga->curr.vs;
+      struct svga_vs_compile_key key;
+
+      ret = make_vs_key( svga, &key );
+      if (ret)
+         return ret;
+
+      result = search_vs_key( vs, &key );
+      if (!result) {
+         ret = compile_vs( svga, vs, &key, &result );
+         if (ret)
+            return ret;
+      }
+
+      assert (result);
+      id = result->id;
+   }
+
+   if (result != svga->state.hw_draw.vs) {
+      ret = SVGA3D_SetShader(svga->swc,
+                             SVGA3D_SHADERTYPE_VS,
+                             id );
+      if (ret)
+         return ret;
+
+      svga->dirty |= SVGA_NEW_VS_RESULT;
+      svga->state.hw_draw.vs = result;      
+   }
+
+   return 0;
+}
+
+struct svga_tracked_state svga_hw_vs = 
+{
+   "vertex shader (hwtnl)",
+   (SVGA_NEW_VS |
+    SVGA_NEW_PRESCALE |
+    SVGA_NEW_NEED_SWTNL |
+    SVGA_NEW_ZERO_STRIDE),
+   emit_hw_vs
+};
+
+
+/***********************************************************************
+ */
+static int update_zero_stride( struct svga_context *svga,
+                               unsigned dirty )
+{
+   unsigned i;
+
+   svga->curr.zero_stride_vertex_elements = 0;
+   svga->curr.num_zero_stride_vertex_elements = 0;
+
+   for (i = 0; i < svga->curr.num_vertex_elements; i++) {
+      const struct pipe_vertex_element *vel = &svga->curr.ve[i];
+      const struct pipe_vertex_buffer *vbuffer = &svga->curr.vb[
+         vel->vertex_buffer_index];
+      if (vbuffer->stride == 0) {
+         unsigned const_idx =
+            svga->curr.num_zero_stride_vertex_elements;
+         struct translate *translate;
+         struct translate_key key;
+         void *mapped_buffer;
+
+         svga->curr.zero_stride_vertex_elements |= (1 << i);
+         ++svga->curr.num_zero_stride_vertex_elements;
+
+         key.output_stride = 4 * sizeof(float);
+         key.nr_elements = 1;
+         key.element[0].input_format = vel->src_format;
+         key.element[0].output_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
+         key.element[0].input_buffer = vel->vertex_buffer_index;
+         key.element[0].input_offset = vel->src_offset;
+         key.element[0].output_offset = const_idx * 4 * sizeof(float);
+
+         translate_key_sanitize(&key);
+         /* translate_generic_create is technically private but
+          * we don't want to code-generate, just want generic
+          * translation */
+         translate = translate_generic_create(&key);
+
+         assert(vel->src_offset == 0);
+         
+         mapped_buffer = pipe_buffer_map_range(svga->pipe.screen, 
+                                               vbuffer->buffer,
+                                               vel->src_offset,
+                                               util_format_get_blocksize(vel->src_format),
+                                               PIPE_BUFFER_USAGE_CPU_READ);
+         translate->set_buffer(translate, vel->vertex_buffer_index,
+                               mapped_buffer,
+                               vbuffer->stride);
+         translate->run(translate, 0, 1,
+                        svga->curr.zero_stride_constants);
+
+         pipe_buffer_unmap(svga->pipe.screen,
+                           vbuffer->buffer);
+         translate->release(translate);
+      }
+   }
+
+   if (svga->curr.num_zero_stride_vertex_elements)
+      svga->dirty |= SVGA_NEW_ZERO_STRIDE;
+
+   return 0;
+}
+
+struct svga_tracked_state svga_hw_update_zero_stride =
+{
+   "update zero_stride",
+   ( SVGA_NEW_VELEMENT |
+     SVGA_NEW_VBUFFER ),
+   update_zero_stride
+};
diff --git a/src/gallium/drivers/svga/svga_swtnl.h b/src/gallium/drivers/svga/svga_swtnl.h
new file mode 100644 (file)
index 0000000..4882f26
--- /dev/null
@@ -0,0 +1,52 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#ifndef SVGA_SWTNL_H
+#define SVGA_SWTNL_H
+
+#include "pipe/p_compiler.h"
+
+struct svga_context;
+struct pipe_context;
+struct pipe_buffer;
+struct vbuf_render;
+
+
+boolean svga_init_swtnl( struct svga_context *svga );
+void svga_destroy_swtnl( struct svga_context *svga );
+
+
+enum pipe_error
+svga_swtnl_draw_range_elements(struct svga_context *svga,
+                               struct pipe_buffer *indexBuffer,
+                               unsigned indexSize,
+                               unsigned min_index,
+                               unsigned max_index,
+                               unsigned prim, 
+                               unsigned start, 
+                               unsigned count);
+
+
+#endif
diff --git a/src/gallium/drivers/svga/svga_swtnl_backend.c b/src/gallium/drivers/svga/svga_swtnl_backend.c
new file mode 100644 (file)
index 0000000..b4f757a
--- /dev/null
@@ -0,0 +1,349 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "draw/draw_vbuf.h"
+#include "draw/draw_context.h"
+#include "draw/draw_vertex.h"
+
+#include "util/u_debug.h"
+#include "pipe/p_inlines.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+#include "util/u_simple_shaders.h"
+
+#include "svga_context.h"
+#include "svga_state.h"
+#include "svga_swtnl.h"
+
+#include "svga_types.h"
+#include "svga_reg.h"
+#include "svga3d_reg.h"
+#include "svga_draw.h"
+#include "svga_swtnl_private.h"
+
+
+static const struct vertex_info *
+svga_vbuf_render_get_vertex_info( struct vbuf_render *render )
+{
+   struct svga_vbuf_render *svga_render = svga_vbuf_render(render);
+   struct svga_context *svga = svga_render->svga;
+
+   svga_swtnl_update_vdecl(svga);
+
+   return &svga_render->vertex_info;
+}
+
+
+static boolean
+svga_vbuf_render_allocate_vertices( struct vbuf_render *render,
+                                    ushort vertex_size,
+                                    ushort nr_vertices )
+{
+   struct svga_vbuf_render *svga_render = svga_vbuf_render(render);
+   struct svga_context *svga = svga_render->svga;
+   struct pipe_screen *screen = svga->pipe.screen;
+   size_t size = (size_t)nr_vertices * (size_t)vertex_size;
+   boolean new_vbuf = FALSE;
+   boolean new_ibuf = FALSE;
+
+   if (svga_render->vertex_size != vertex_size)
+      svga->swtnl.new_vdecl = TRUE;
+   svga_render->vertex_size = (size_t)vertex_size;
+
+   if (svga->swtnl.new_vbuf)
+      new_ibuf = new_vbuf = TRUE;
+   svga->swtnl.new_vbuf = FALSE;
+
+   if (svga_render->vbuf_size < svga_render->vbuf_offset + svga_render->vbuf_used + size)
+      new_vbuf = TRUE;
+
+   if (new_vbuf)
+      pipe_buffer_reference(&svga_render->vbuf, NULL);
+   if (new_ibuf)
+      pipe_buffer_reference(&svga_render->ibuf, NULL);
+
+   if (!svga_render->vbuf) {
+      svga_render->vbuf_size = MAX2(size, svga_render->vbuf_alloc_size);
+      svga_render->vbuf = pipe_buffer_create(screen,
+                                             0,
+                                             PIPE_BUFFER_USAGE_VERTEX,
+                                             svga_render->vbuf_size);
+      if(!svga_render->vbuf) {
+         svga_context_flush(svga, NULL);
+         svga_render->vbuf = pipe_buffer_create(screen,
+                                                0,
+                                                PIPE_BUFFER_USAGE_VERTEX,
+                                                svga_render->vbuf_size);
+         assert(svga_render->vbuf);
+      }
+
+      svga->swtnl.new_vdecl = TRUE;
+      svga_render->vbuf_offset = 0;
+   } else {
+      svga_render->vbuf_offset += svga_render->vbuf_used;
+   }
+
+   svga_render->vbuf_used = 0;
+
+   if (svga->swtnl.new_vdecl)
+      svga_render->vdecl_offset = svga_render->vbuf_offset;
+
+   return TRUE;
+}
+
+static void *
+svga_vbuf_render_map_vertices( struct vbuf_render *render )
+{
+   struct svga_vbuf_render *svga_render = svga_vbuf_render(render);
+   struct svga_context *svga = svga_render->svga;
+   struct pipe_screen *screen = svga->pipe.screen;
+
+   char *ptr = (char*)pipe_buffer_map(screen,
+                                      svga_render->vbuf,
+                                      PIPE_BUFFER_USAGE_CPU_WRITE | 
+                                      PIPE_BUFFER_USAGE_FLUSH_EXPLICIT);
+   return ptr + svga_render->vbuf_offset;
+}
+
+static void
+svga_vbuf_render_unmap_vertices( struct vbuf_render *render,
+                                 ushort min_index,
+                                 ushort max_index )
+{
+   struct svga_vbuf_render *svga_render = svga_vbuf_render(render);
+   struct svga_context *svga = svga_render->svga;
+   struct pipe_screen *screen = svga->pipe.screen;
+   unsigned offset, length;
+   size_t used = svga_render->vertex_size * ((size_t)max_index + 1);
+
+   offset = svga_render->vbuf_offset + svga_render->vertex_size * min_index;
+   length = svga_render->vertex_size * (max_index + 1 - min_index);
+   pipe_buffer_flush_mapped_range(screen, svga_render->vbuf, offset, length);
+   pipe_buffer_unmap(screen, svga_render->vbuf);
+   svga_render->min_index = min_index;
+   svga_render->max_index = max_index;
+   svga_render->vbuf_used = MAX2(svga_render->vbuf_used, used);
+}
+
+static boolean
+svga_vbuf_render_set_primitive( struct vbuf_render *render,
+                                unsigned prim )
+{
+   struct svga_vbuf_render *svga_render = svga_vbuf_render(render);
+   svga_render->prim = prim;
+
+   return TRUE;
+}
+
+static void
+svga_vbuf_sumbit_state( struct svga_vbuf_render *svga_render )
+{
+   struct svga_context *svga = svga_render->svga;
+   SVGA3dVertexDecl vdecl[PIPE_MAX_ATTRIBS];
+   enum pipe_error ret;
+   int i;
+
+   /* if the vdecl or vbuf hasn't changed do nothing */
+   if (!svga->swtnl.new_vdecl)
+      return;
+
+   memcpy(vdecl, svga_render->vdecl, sizeof(vdecl));
+
+   /* flush the hw state */
+   ret = svga_hwtnl_flush(svga->hwtnl);
+   if (ret) {
+      svga_context_flush(svga, NULL);
+      ret = svga_hwtnl_flush(svga->hwtnl);
+      /* if we hit this path we might become synced with hw */
+      svga->swtnl.new_vbuf = TRUE;
+      assert(ret == 0);
+   }
+
+   svga_hwtnl_reset_vdecl(svga->hwtnl, svga_render->vdecl_count);
+
+   for (i = 0; i < svga_render->vdecl_count; i++) {
+      vdecl[i].array.offset += svga_render->vdecl_offset;
+
+      svga_hwtnl_vdecl( svga->hwtnl,
+                        i,
+                        &vdecl[i],
+                        svga_render->vbuf );
+   }
+
+   /* We have already taken care of flatshading, so let the hwtnl
+    * module use whatever is most convenient:
+    */
+   if (svga->state.sw.need_pipeline) {
+      svga_hwtnl_set_flatshade(svga->hwtnl, FALSE, FALSE);
+      svga_hwtnl_set_unfilled(svga->hwtnl, PIPE_POLYGON_MODE_FILL);
+   }
+   else {
+      svga_hwtnl_set_flatshade( svga->hwtnl,
+                                svga->curr.rast->templ.flatshade,
+                                svga->curr.rast->templ.flatshade_first );
+
+      svga_hwtnl_set_unfilled( svga->hwtnl,
+                               svga->curr.rast->hw_unfilled );
+   }
+
+   svga->swtnl.new_vdecl = FALSE;
+}
+
+static void
+svga_vbuf_render_draw_arrays( struct vbuf_render *render,
+                              unsigned start,
+                              uint nr )
+{
+   struct svga_vbuf_render *svga_render = svga_vbuf_render(render);
+   struct svga_context *svga = svga_render->svga;
+   unsigned bias = (svga_render->vbuf_offset - svga_render->vdecl_offset) / svga_render->vertex_size;
+   enum pipe_error ret = 0;
+
+   svga_vbuf_sumbit_state(svga_render);
+
+   /* Need to call update_state() again as the draw module may have
+    * altered some of our state behind our backs.  Testcase:
+    * redbook/polys.c
+    */
+   svga_update_state_retry( svga, SVGA_STATE_HW_DRAW );
+
+   ret = svga_hwtnl_draw_arrays(svga->hwtnl, svga_render->prim, start + bias, nr);
+   if (ret != PIPE_OK) {
+      svga_context_flush(svga, NULL);
+      ret = svga_hwtnl_draw_arrays(svga->hwtnl, svga_render->prim, start + bias, nr);
+      svga->swtnl.new_vbuf = TRUE;
+      assert(ret == PIPE_OK);
+   }
+}
+
+
+static void
+svga_vbuf_render_draw( struct vbuf_render *render,
+                       const ushort *indices,
+                       uint nr_indices)
+{
+   struct svga_vbuf_render *svga_render = svga_vbuf_render(render);
+   struct svga_context *svga = svga_render->svga;
+   struct pipe_screen *screen = svga->pipe.screen;
+   unsigned bias = (svga_render->vbuf_offset - svga_render->vdecl_offset) / svga_render->vertex_size;
+   boolean ret;
+   size_t size = 2 * nr_indices;
+
+   assert(( svga_render->vbuf_offset - svga_render->vdecl_offset) % svga_render->vertex_size == 0);
+   
+   if (svga_render->ibuf_size < svga_render->ibuf_offset + size)
+      pipe_buffer_reference(&svga_render->ibuf, NULL);
+
+   if (!svga_render->ibuf) {
+      svga_render->ibuf_size = MAX2(size, svga_render->ibuf_alloc_size);
+      svga_render->ibuf = pipe_buffer_create(screen,
+                                             0,
+                                             PIPE_BUFFER_USAGE_VERTEX,
+                                             svga_render->ibuf_size);
+      svga_render->ibuf_offset = 0;
+   }
+
+   pipe_buffer_write(screen, svga_render->ibuf,
+                     svga_render->ibuf_offset, 2 * nr_indices, indices);
+
+
+   /* off to hardware */
+   svga_vbuf_sumbit_state(svga_render);
+
+   /* Need to call update_state() again as the draw module may have
+    * altered some of our state behind our backs.  Testcase:
+    * redbook/polys.c
+    */
+   svga_update_state_retry( svga, SVGA_STATE_HW_DRAW );
+
+   ret = svga_hwtnl_draw_range_elements(svga->hwtnl,
+                                        svga_render->ibuf,
+                                        2,
+                                        svga_render->min_index,
+                                        svga_render->max_index,
+                                        svga_render->prim,
+                                        svga_render->ibuf_offset / 2, nr_indices, bias);
+   if(ret != PIPE_OK) {
+      svga_context_flush(svga, NULL);
+      ret = svga_hwtnl_draw_range_elements(svga->hwtnl,
+                                           svga_render->ibuf,
+                                           2,
+                                           svga_render->min_index,
+                                           svga_render->max_index,
+                                           svga_render->prim,
+                                           svga_render->ibuf_offset / 2, nr_indices, bias);
+      svga->swtnl.new_vbuf = TRUE;
+      assert(ret == PIPE_OK);
+   }
+
+   svga_render->ibuf_offset += size;
+}
+
+
+static void
+svga_vbuf_render_release_vertices( struct vbuf_render *render )
+{
+
+}
+
+
+static void
+svga_vbuf_render_destroy( struct vbuf_render *render )
+{
+   struct svga_vbuf_render *svga_render = svga_vbuf_render(render);
+
+   pipe_buffer_reference(&svga_render->vbuf, NULL);
+   pipe_buffer_reference(&svga_render->ibuf, NULL);
+   FREE(svga_render);
+}
+
+
+/**
+ * Create a new primitive render.
+ */
+struct vbuf_render *
+svga_vbuf_render_create( struct svga_context *svga )
+{
+   struct svga_vbuf_render *svga_render = CALLOC_STRUCT(svga_vbuf_render);
+
+   svga_render->svga = svga;
+   svga_render->ibuf_size = 0;
+   svga_render->vbuf_size = 0;
+   svga_render->ibuf_alloc_size = 4*1024;
+   svga_render->vbuf_alloc_size = 64*1024;
+   svga_render->base.max_vertex_buffer_bytes = 64*1024/10;
+   svga_render->base.max_indices = 65536;
+   svga_render->base.get_vertex_info = svga_vbuf_render_get_vertex_info;
+   svga_render->base.allocate_vertices = svga_vbuf_render_allocate_vertices;
+   svga_render->base.map_vertices = svga_vbuf_render_map_vertices;
+   svga_render->base.unmap_vertices = svga_vbuf_render_unmap_vertices;
+   svga_render->base.set_primitive = svga_vbuf_render_set_primitive;
+   svga_render->base.draw = svga_vbuf_render_draw;
+   svga_render->base.draw_arrays = svga_vbuf_render_draw_arrays;
+   svga_render->base.release_vertices = svga_vbuf_render_release_vertices;
+   svga_render->base.destroy = svga_vbuf_render_destroy;
+
+   return &svga_render->base;
+}
diff --git a/src/gallium/drivers/svga/svga_swtnl_draw.c b/src/gallium/drivers/svga/svga_swtnl_draw.c
new file mode 100644 (file)
index 0000000..7655121
--- /dev/null
@@ -0,0 +1,170 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "draw/draw_context.h"
+#include "draw/draw_vbuf.h"
+#include "pipe/p_inlines.h"
+#include "pipe/p_state.h"
+#include "util/u_memory.h"
+
+#include "svga_context.h"
+#include "svga_swtnl.h"
+#include "svga_state.h"
+#include "svga_swtnl_private.h"
+
+
+
+enum pipe_error
+svga_swtnl_draw_range_elements(struct svga_context *svga,
+                               struct pipe_buffer *indexBuffer,
+                               unsigned indexSize,
+                               unsigned min_index,
+                               unsigned max_index,
+                               unsigned prim, unsigned start, unsigned count)
+{
+   struct draw_context *draw = svga->swtnl.draw;
+   unsigned i;
+   const void *map;
+   enum pipe_error ret;
+
+   assert(!svga->dirty);
+   assert(svga->state.sw.need_swtnl);
+   assert(draw);
+
+   ret = svga_update_state(svga, SVGA_STATE_SWTNL_DRAW);
+   if (ret) {
+      svga_context_flush(svga, NULL);
+      ret = svga_update_state(svga, SVGA_STATE_SWTNL_DRAW);
+      svga->swtnl.new_vbuf = TRUE;
+      assert(ret == PIPE_OK);
+   }
+
+   /*
+    * Map vertex buffers
+    */
+   for (i = 0; i < svga->curr.num_vertex_buffers; i++) {
+      map = pipe_buffer_map(svga->pipe.screen,
+                            svga->curr.vb[i].buffer,
+                            PIPE_BUFFER_USAGE_CPU_READ);
+
+      draw_set_mapped_vertex_buffer(draw, i, map);
+   }
+
+   /* Map index buffer, if present */
+   if (indexBuffer) {
+      map = pipe_buffer_map(svga->pipe.screen, indexBuffer,
+                            PIPE_BUFFER_USAGE_CPU_READ);
+
+      draw_set_mapped_element_buffer_range(draw, 
+                                           indexSize, 
+                                           min_index,
+                                           max_index,
+                                           map);
+   }
+   
+   if (svga->curr.cb[PIPE_SHADER_VERTEX]) {
+      map = pipe_buffer_map(svga->pipe.screen,
+                            svga->curr.cb[PIPE_SHADER_VERTEX],
+                            PIPE_BUFFER_USAGE_CPU_READ);
+      assert(map);
+      draw_set_mapped_constant_buffer(
+         draw, PIPE_SHADER_VERTEX,
+         map,
+         svga->curr.cb[PIPE_SHADER_VERTEX]->size);
+   }
+
+   draw_arrays(svga->swtnl.draw, prim, start, count);
+
+   draw_flush(svga->swtnl.draw);
+
+   /* Ensure the draw module didn't touch this */
+   assert(i == svga->curr.num_vertex_buffers);
+   
+   /*
+    * unmap vertex/index buffers
+    */
+   for (i = 0; i < svga->curr.num_vertex_buffers; i++) {
+      pipe_buffer_unmap(svga->pipe.screen, svga->curr.vb[i].buffer);
+      draw_set_mapped_vertex_buffer(draw, i, NULL);
+   }
+
+   if (indexBuffer) {
+      pipe_buffer_unmap(svga->pipe.screen, indexBuffer);
+      draw_set_mapped_element_buffer(draw, 0, NULL);
+   }
+
+   if (svga->curr.cb[PIPE_SHADER_VERTEX]) {
+      pipe_buffer_unmap(svga->pipe.screen,
+                        svga->curr.cb[PIPE_SHADER_VERTEX]);
+   }
+
+   return ret;
+}
+
+
+
+
+boolean svga_init_swtnl( struct svga_context *svga )
+{
+   svga->swtnl.backend = svga_vbuf_render_create(svga);
+   if(!svga->swtnl.backend)
+      goto fail;
+
+   /*
+    * Create drawing context and plug our rendering stage into it.
+    */
+   svga->swtnl.draw = draw_create();
+   if (svga->swtnl.draw == NULL)
+      goto fail;
+
+
+   draw_set_rasterize_stage(svga->swtnl.draw, 
+                            draw_vbuf_stage( svga->swtnl.draw, svga->swtnl.backend ));
+
+   draw_set_render(svga->swtnl.draw, svga->swtnl.backend);
+
+   draw_install_aaline_stage(svga->swtnl.draw, &svga->pipe);
+   draw_install_aapoint_stage(svga->swtnl.draw, &svga->pipe);
+   draw_install_pstipple_stage(svga->swtnl.draw, &svga->pipe);
+
+   draw_set_driver_clipping(svga->swtnl.draw, debug_get_bool_option("SVGA_SWTNL_FSE", FALSE));
+
+   return TRUE;
+
+fail:
+   if (svga->swtnl.backend)
+      svga->swtnl.backend->destroy( svga->swtnl.backend );
+
+   if (svga->swtnl.draw)
+      draw_destroy( svga->swtnl.draw );
+
+   return FALSE;
+}
+
+
+void svga_destroy_swtnl( struct svga_context *svga )
+{
+   draw_destroy( svga->swtnl.draw );
+}
diff --git a/src/gallium/drivers/svga/svga_swtnl_private.h b/src/gallium/drivers/svga/svga_swtnl_private.h
new file mode 100644 (file)
index 0000000..9bbb429
--- /dev/null
@@ -0,0 +1,93 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#ifndef SVGA_SWTNL_PRIVATE_H
+#define SVGA_SWTNL_PRIVATE_H
+
+#include "svga_swtnl.h"
+#include "draw/draw_vertex.h"
+
+#include "svga_types.h"
+#include "svga3d_reg.h"
+
+/**
+ * Primitive renderer for svga.
+ */
+struct svga_vbuf_render {
+   struct vbuf_render base;
+
+   struct svga_context *svga;
+   struct vertex_info vertex_info;
+
+   unsigned vertex_size;
+
+   unsigned prim;
+
+   struct pipe_buffer *vbuf;
+   struct pipe_buffer *ibuf;
+
+   /* current size of buffer */
+   size_t vbuf_size;
+   size_t ibuf_size;
+
+   /* size of that the buffer should be */
+   size_t vbuf_alloc_size;
+   size_t ibuf_alloc_size;
+
+   /* current write place */
+   size_t vbuf_offset;
+   size_t ibuf_offset;
+
+   /* currently used */
+   size_t vbuf_used;
+
+   SVGA3dVertexDecl vdecl[PIPE_MAX_ATTRIBS];
+   unsigned vdecl_offset;
+   unsigned vdecl_count;
+
+   ushort min_index;
+   ushort max_index;
+};
+
+/**
+ * Basically a cast wrapper.
+ */
+static INLINE struct svga_vbuf_render *
+svga_vbuf_render( struct vbuf_render *render )
+{
+   assert(render);
+   return (struct svga_vbuf_render *)render;
+}
+
+
+struct vbuf_render *
+svga_vbuf_render_create( struct svga_context *svga );
+
+
+int
+svga_swtnl_update_vdecl( struct svga_context *svga );
+
+
+#endif
diff --git a/src/gallium/drivers/svga/svga_swtnl_state.c b/src/gallium/drivers/svga/svga_swtnl_state.c
new file mode 100644 (file)
index 0000000..94b6ccc
--- /dev/null
@@ -0,0 +1,237 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#include "draw/draw_context.h"
+#include "draw/draw_vbuf.h"
+#include "pipe/p_inlines.h"
+#include "pipe/p_state.h"
+#include "util/u_memory.h"
+
+#include "svga_context.h"
+#include "svga_swtnl.h"
+#include "svga_state.h"
+
+#include "svga_swtnl_private.h"
+
+
+#define SVGA_POINT_ADJ_X -0.375
+#define SVGA_POINT_ADJ_Y -0.5
+
+#define SVGA_LINE_ADJ_X -0.5
+#define SVGA_LINE_ADJ_Y -0.5
+
+#define SVGA_TRIANGLE_ADJ_X -0.375
+#define SVGA_TRIANGLE_ADJ_Y -0.5
+
+
+static void set_draw_viewport( struct svga_context *svga )
+{
+   struct pipe_viewport_state vp = svga->curr.viewport;
+   float adjx = 0;
+   float adjy = 0;
+
+   switch (svga->curr.reduced_prim) {
+   case PIPE_PRIM_POINTS:
+      adjx = SVGA_POINT_ADJ_X;
+      adjy = SVGA_POINT_ADJ_Y;
+      break;
+   case PIPE_PRIM_LINES:
+      /* XXX: This is to compensate for the fact that wide lines are
+       * going to be drawn with triangles, but we're not catching all
+       * cases where that will happen.
+       */
+      if (svga->curr.rast->templ.line_width > 1.0) 
+      {
+         adjx = SVGA_LINE_ADJ_X + 0.175;
+         adjy = SVGA_LINE_ADJ_Y - 0.175;
+      }
+      else {
+         adjx = SVGA_LINE_ADJ_X;
+         adjy = SVGA_LINE_ADJ_Y;
+      }
+      break;
+   case PIPE_PRIM_TRIANGLES:
+      adjx += SVGA_TRIANGLE_ADJ_X;
+      adjy += SVGA_TRIANGLE_ADJ_Y;
+      break;
+   }
+
+   vp.translate[0] += adjx;
+   vp.translate[1] += adjy;
+
+   draw_set_viewport_state(svga->swtnl.draw, &vp);
+}
+
+static int update_swtnl_draw( struct svga_context *svga,
+                              unsigned dirty )
+{
+   draw_flush( svga->swtnl.draw );
+
+   if (dirty & SVGA_NEW_VS) 
+      draw_bind_vertex_shader(svga->swtnl.draw,
+                              svga->curr.vs->draw_shader);
+
+   if (dirty & SVGA_NEW_VBUFFER)
+      draw_set_vertex_buffers(svga->swtnl.draw, 
+                              svga->curr.num_vertex_buffers, 
+                              svga->curr.vb);
+
+   if (dirty & SVGA_NEW_VELEMENT)
+      draw_set_vertex_elements(svga->swtnl.draw, 
+                               svga->curr.num_vertex_elements, 
+                               svga->curr.ve );
+
+   if (dirty & SVGA_NEW_CLIP)
+      draw_set_clip_state(svga->swtnl.draw, 
+                          &svga->curr.clip);
+
+   if (dirty & (SVGA_NEW_VIEWPORT |
+                SVGA_NEW_REDUCED_PRIMITIVE | 
+                SVGA_NEW_RAST))
+      set_draw_viewport( svga );
+
+   if (dirty & SVGA_NEW_RAST)
+      draw_set_rasterizer_state(svga->swtnl.draw,
+                                &svga->curr.rast->templ);
+
+   if (dirty & SVGA_NEW_FRAME_BUFFER)
+      draw_set_mrd(svga->swtnl.draw, 
+                   svga->curr.depthscale);
+
+   return 0;
+}
+
+
+struct svga_tracked_state svga_update_swtnl_draw =
+{
+   "update draw module state",
+   (SVGA_NEW_VS |
+    SVGA_NEW_VBUFFER |
+    SVGA_NEW_VELEMENT |
+    SVGA_NEW_CLIP |
+    SVGA_NEW_VIEWPORT |
+    SVGA_NEW_RAST |
+    SVGA_NEW_FRAME_BUFFER |
+    SVGA_NEW_REDUCED_PRIMITIVE),
+   update_swtnl_draw
+};
+
+
+int svga_swtnl_update_vdecl( struct svga_context *svga )
+{
+   struct svga_vbuf_render *svga_render = svga_vbuf_render(svga->swtnl.backend);
+   struct draw_context *draw = svga->swtnl.draw;
+   struct vertex_info *vinfo = &svga_render->vertex_info;
+   SVGA3dVertexDecl vdecl[PIPE_MAX_ATTRIBS];
+   const enum interp_mode colorInterp =
+      svga->curr.rast->templ.flatshade ? INTERP_CONSTANT : INTERP_LINEAR;
+   const struct svga_fragment_shader *fs = svga->curr.fs;
+   int offset = 0;
+   int nr_decls = 0;
+   int src, i;
+
+   memset(vinfo, 0, sizeof(*vinfo));
+   memset(vdecl, 0, sizeof(vdecl));
+
+   /* always add position */
+   src = draw_find_shader_output(draw, TGSI_SEMANTIC_POSITION, 0);
+   draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_LINEAR, src);
+   vinfo->attrib[0].emit = EMIT_4F;
+   vdecl[0].array.offset = offset;
+   vdecl[0].identity.type = SVGA3D_DECLTYPE_FLOAT4;
+   vdecl[0].identity.usage = SVGA3D_DECLUSAGE_POSITIONT;
+   vdecl[0].identity.usageIndex = 0;
+   offset += 16;
+   nr_decls++;
+
+   for (i = 0; i < fs->base.info.num_inputs; i++) {
+      unsigned name = fs->base.info.input_semantic_name[i];
+      unsigned index = fs->base.info.input_semantic_index[i];
+      src = draw_find_shader_output(draw, name, index);
+      vdecl[nr_decls].array.offset = offset;
+      vdecl[nr_decls].identity.usageIndex = fs->base.info.input_semantic_index[i];
+
+      switch (name) {
+      case TGSI_SEMANTIC_COLOR:
+         draw_emit_vertex_attr(vinfo, EMIT_4F, colorInterp, src);
+         vdecl[nr_decls].identity.usage = SVGA3D_DECLUSAGE_COLOR;
+         vdecl[nr_decls].identity.type = SVGA3D_DECLTYPE_FLOAT4;
+         offset += 16;
+         nr_decls++;
+         break;
+      case TGSI_SEMANTIC_GENERIC:
+         draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src);
+         vdecl[nr_decls].identity.usage = SVGA3D_DECLUSAGE_TEXCOORD;
+         vdecl[nr_decls].identity.type = SVGA3D_DECLTYPE_FLOAT4;
+         vdecl[nr_decls].identity.usageIndex += 1;
+         offset += 16;
+         nr_decls++;
+         break;
+      case TGSI_SEMANTIC_FOG:
+         draw_emit_vertex_attr(vinfo, EMIT_1F, INTERP_PERSPECTIVE, src);
+         vdecl[nr_decls].identity.usage = SVGA3D_DECLUSAGE_TEXCOORD;
+         vdecl[nr_decls].identity.type = SVGA3D_DECLTYPE_FLOAT1;
+         assert(vdecl[nr_decls].identity.usageIndex == 0);
+         offset += 4;
+         nr_decls++;
+         break;
+      case TGSI_SEMANTIC_POSITION:
+         /* generated internally, not a vertex shader output */
+         break;
+      default:
+         assert(0);
+      }
+   }
+
+   draw_compute_vertex_size(vinfo);
+
+   svga_render->vdecl_count = nr_decls;
+   for (i = 0; i < svga_render->vdecl_count; i++)
+      vdecl[i].array.stride = offset;
+
+   if (memcmp(svga_render->vdecl, vdecl, sizeof(vdecl)) == 0)
+      return 0;
+
+   memcpy(svga_render->vdecl, vdecl, sizeof(vdecl));
+   svga->swtnl.new_vdecl = TRUE;
+
+   return 0;
+}
+
+
+static int update_swtnl_vdecl( struct svga_context *svga,
+                               unsigned dirty )
+{
+   return svga_swtnl_update_vdecl( svga );
+}
+
+
+struct svga_tracked_state svga_update_swtnl_vdecl =
+{
+   "update draw module vdecl",
+   (SVGA_NEW_VS |
+    SVGA_NEW_FS),
+   update_swtnl_vdecl
+};
diff --git a/src/gallium/drivers/svga/svga_tgsi.c b/src/gallium/drivers/svga/svga_tgsi.c
new file mode 100644 (file)
index 0000000..0cd6201
--- /dev/null
@@ -0,0 +1,282 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_shader_tokens.h"
+#include "pipe/p_defines.h"
+#include "tgsi/tgsi_parse.h"
+#include "tgsi/tgsi_dump.h"
+#include "tgsi/tgsi_scan.h"
+#include "util/u_memory.h"
+#include "util/u_bitmask.h"
+
+#include "svgadump/svga_shader_dump.h"
+
+#include "svga_context.h"
+#include "svga_tgsi.h"
+#include "svga_tgsi_emit.h"
+#include "svga_debug.h"
+
+#include "svga_hw_reg.h"
+#include "svga3d_shaderdefs.h"
+
+
+/* Sinkhole used only in error conditions.
+ */
+static char err_buf[128];
+
+#if 0
+static void svga_destroy_shader_emitter( struct svga_shader_emitter *emit )
+{
+   if (emit->buf != err_buf)
+      FREE(emit->buf);
+}
+#endif
+
+
+static boolean svga_shader_expand( struct svga_shader_emitter *emit )
+{
+   char *new_buf;
+   unsigned newsize = emit->size * 2;
+
+   if(emit->buf != err_buf)
+      new_buf = REALLOC(emit->buf, emit->size, newsize);
+   else
+      new_buf = NULL;
+
+   if (new_buf == NULL) {
+      emit->ptr = err_buf;
+      emit->buf = err_buf;
+      emit->size = sizeof(err_buf);
+      return FALSE;
+   }
+
+   emit->size = newsize;
+   emit->ptr = new_buf + (emit->ptr - emit->buf);
+   emit->buf = new_buf;
+   return TRUE;
+}   
+
+static INLINE boolean reserve(  struct svga_shader_emitter *emit,
+                                unsigned nr_dwords )
+{
+   if (emit->ptr - emit->buf + nr_dwords * sizeof(unsigned) >= emit->size) {
+      if (!svga_shader_expand( emit ))
+         return FALSE;
+   }
+
+   return TRUE;
+}
+
+boolean svga_shader_emit_dword( struct svga_shader_emitter *emit,
+                                unsigned dword )
+{
+   if (!reserve(emit, 1))
+      return FALSE;
+
+   *(unsigned *)emit->ptr = dword;
+   emit->ptr += sizeof dword;
+   return TRUE;
+}
+
+boolean svga_shader_emit_dwords( struct svga_shader_emitter *emit,
+                                 const unsigned *dwords,
+                                 unsigned nr )
+{
+   if (!reserve(emit, nr))
+      return FALSE;
+
+   memcpy( emit->ptr, dwords, nr * sizeof *dwords );
+   emit->ptr += nr * sizeof *dwords;
+   return TRUE;
+}
+
+boolean svga_shader_emit_opcode( struct svga_shader_emitter *emit,
+                                 unsigned opcode )
+{
+   SVGA3dShaderInstToken *here;
+
+   if (!reserve(emit, 1))
+      return FALSE;
+
+   here = (SVGA3dShaderInstToken *)emit->ptr;
+   here->value = opcode;
+
+   if (emit->insn_offset) {
+      SVGA3dShaderInstToken *prev = (SVGA3dShaderInstToken *)(emit->buf + 
+                                                              emit->insn_offset);
+      prev->size = (here - prev) - 1;
+   }
+   
+   emit->insn_offset = emit->ptr - emit->buf;
+   emit->ptr += sizeof(unsigned);
+   return TRUE;
+}
+
+#define SVGA3D_PS_2X (SVGA3D_PS_20 | 1)
+#define SVGA3D_VS_2X (SVGA3D_VS_20 | 1)
+
+static boolean svga_shader_emit_header( struct svga_shader_emitter *emit )
+{
+   SVGA3dShaderVersion header;
+
+   memset( &header, 0, sizeof header );
+
+   switch (emit->unit) {
+   case PIPE_SHADER_FRAGMENT:
+      header.value = emit->use_sm30 ? SVGA3D_PS_30 : SVGA3D_PS_2X;
+      break;
+   case PIPE_SHADER_VERTEX:
+      header.value = emit->use_sm30 ? SVGA3D_VS_30 : SVGA3D_VS_2X;
+      break;
+   }
+   return svga_shader_emit_dword( emit, header.value );
+}
+
+
+
+
+
+/* Parse TGSI shader and translate to SVGA/DX9 serialized
+ * representation.  
+ *
+ * In this function SVGA shader is emitted to an in-memory buffer that
+ * can be dynamically grown.  Once we've finished and know how large
+ * it is, it will be copied to a hardware buffer for upload.
+ */
+static struct svga_shader_result *
+svga_tgsi_translate( const struct svga_shader *shader,
+                     union svga_compile_key key,
+                     unsigned unit )
+{
+   struct svga_shader_result *result = NULL;
+   struct svga_shader_emitter emit;
+   int ret = 0;
+
+   memset(&emit, 0, sizeof(emit));
+
+   emit.use_sm30 = shader->use_sm30;
+   emit.size = 1024;
+   emit.buf = MALLOC(emit.size);
+   if (emit.buf == NULL) {
+      ret = PIPE_ERROR_OUT_OF_MEMORY;
+      goto fail;
+   }
+
+   emit.ptr = emit.buf;
+   emit.unit = unit;
+   emit.key = key;
+
+   tgsi_scan_shader( shader->tokens, &emit.info);
+
+   emit.imm_start = emit.info.file_max[TGSI_FILE_CONSTANT] + 1;
+   
+   if (unit == PIPE_SHADER_FRAGMENT)
+      emit.imm_start += key.fkey.num_unnormalized_coords;
+
+   if (unit == PIPE_SHADER_VERTEX) {
+      emit.imm_start += key.vkey.need_prescale ? 2 : 0;
+      emit.imm_start += key.vkey.num_zero_stride_vertex_elements;
+   }
+
+   emit.nr_hw_const = (emit.imm_start + emit.info.file_max[TGSI_FILE_IMMEDIATE] + 1);
+
+   emit.nr_hw_temp = emit.info.file_max[TGSI_FILE_TEMPORARY] + 1;
+   emit.in_main_func = TRUE;
+
+   if (!svga_shader_emit_header( &emit ))
+      goto fail;
+
+   if (!svga_shader_emit_instructions( &emit, shader->tokens ))
+      goto fail;
+   
+   result = CALLOC_STRUCT(svga_shader_result);
+   if (result == NULL)
+      goto fail;
+
+   result->shader = shader;
+   result->tokens = (const unsigned *)emit.buf;
+   result->nr_tokens = (emit.ptr - emit.buf) / sizeof(unsigned);
+   memcpy(&result->key, &key, sizeof key);
+   result->id = UTIL_BITMASK_INVALID_INDEX;
+
+   if (SVGA_DEBUG & DEBUG_TGSI) 
+   {
+      debug_printf( "#####################################\n" );
+      debug_printf( "Shader %u below\n", shader->id );
+      tgsi_dump( shader->tokens, 0 );
+      if (SVGA_DEBUG & DEBUG_TGSI) {
+         debug_printf( "Shader %u compiled below\n", shader->id );
+         svga_shader_dump( result->tokens,
+                           result->nr_tokens ,
+                           FALSE );
+      }
+      debug_printf( "#####################################\n" );
+   }
+
+   return result;
+
+fail:
+   FREE(result);
+   FREE(emit.buf);
+   return NULL;
+}
+
+
+
+
+struct svga_shader_result *
+svga_translate_fragment_program( const struct svga_fragment_shader *fs,
+                                 const struct svga_fs_compile_key *fkey )
+{
+   union svga_compile_key key;
+   memcpy(&key.fkey, fkey, sizeof *fkey);
+
+   return svga_tgsi_translate( &fs->base, 
+                               key,
+                               PIPE_SHADER_FRAGMENT );
+}
+
+struct svga_shader_result *
+svga_translate_vertex_program( const struct svga_vertex_shader *vs,
+                               const struct svga_vs_compile_key *vkey )
+{
+   union svga_compile_key key;
+   memcpy(&key.vkey, vkey, sizeof *vkey);
+
+   return svga_tgsi_translate( &vs->base, 
+                               key,
+                               PIPE_SHADER_VERTEX );
+}
+
+
+void svga_destroy_shader_result( struct svga_shader_result *result )
+{
+   FREE((unsigned *)result->tokens);
+   FREE(result);
+}
+
diff --git a/src/gallium/drivers/svga/svga_tgsi.h b/src/gallium/drivers/svga/svga_tgsi.h
new file mode 100644 (file)
index 0000000..737a221
--- /dev/null
@@ -0,0 +1,136 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#ifndef SVGA_TGSI_H
+#define SVGA_TGSI_H
+
+#include "pipe/p_state.h"
+
+#include "svga_hw_reg.h"
+
+struct svga_fragment_shader;
+struct svga_vertex_shader;
+struct svga_shader;
+struct tgsi_shader_info;
+struct tgsi_token;
+
+
+struct svga_vs_compile_key
+{
+   unsigned zero_stride_vertex_elements;
+   unsigned need_prescale:1;
+   unsigned allow_psiz:1;
+   unsigned num_zero_stride_vertex_elements:6;
+};
+
+struct svga_fs_compile_key
+{
+   unsigned light_twoside:1;
+   unsigned front_cw:1;
+   unsigned num_textures:8;
+   unsigned num_unnormalized_coords:8;
+   struct {
+      unsigned compare_mode:1;
+      unsigned compare_func:3;
+      unsigned unnormalized:1;
+      unsigned width_height_idx:7;
+      unsigned texture_target:8;
+   } tex[PIPE_MAX_SAMPLERS];
+};
+
+union svga_compile_key {
+   struct svga_vs_compile_key vkey;
+   struct svga_fs_compile_key fkey;
+};
+
+struct svga_shader_result
+{
+   const struct svga_shader *shader;
+
+   /* Parameters used to generate this compilation result:
+    */
+   union svga_compile_key key;
+
+   /* Compiled shader tokens:
+    */
+   const unsigned *tokens;
+   unsigned nr_tokens;
+
+   /* SVGA Shader ID:
+    */
+   unsigned id;
+   
+   /* Next compilation result:
+    */
+   struct svga_shader_result *next;
+};
+
+
+/* TGSI doesn't provide use with VS input semantics (they're actually
+ * pretty meaningless), so we just generate some plausible ones here.
+ * This is called both from within the TGSI translator and when
+ * building vdecls to ensure they match up.
+ *
+ * The real use of this information is matching vertex elements to
+ * fragment shader inputs in the case where vertex shader is disabled.
+ */
+static INLINE void svga_generate_vdecl_semantics( unsigned idx,
+                                                  unsigned *usage,
+                                                  unsigned *usage_index )
+{
+   if (idx == 0) {
+      *usage = SVGA3D_DECLUSAGE_POSITION;
+      *usage_index = 0;
+   }
+   else {
+      *usage = SVGA3D_DECLUSAGE_TEXCOORD;
+      *usage_index = idx - 1;
+   }
+}
+
+
+
+static INLINE unsigned svga_vs_key_size( const struct svga_vs_compile_key *key )
+{
+   return sizeof *key;
+}
+
+static INLINE unsigned svga_fs_key_size( const struct svga_fs_compile_key *key )
+{
+   return (const char *)&key->tex[key->num_textures] - (const char *)key;
+}
+
+struct svga_shader_result *
+svga_translate_fragment_program( const struct svga_fragment_shader *fs,
+                                 const struct svga_fs_compile_key *fkey );
+
+struct svga_shader_result *
+svga_translate_vertex_program( const struct svga_vertex_shader *fs,
+                               const struct svga_vs_compile_key *vkey );
+
+
+void svga_destroy_shader_result( struct svga_shader_result *result );
+
+#endif
diff --git a/src/gallium/drivers/svga/svga_tgsi_decl_sm20.c b/src/gallium/drivers/svga/svga_tgsi_decl_sm20.c
new file mode 100644 (file)
index 0000000..23b3ace
--- /dev/null
@@ -0,0 +1,280 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+
+#include "pipe/p_shader_tokens.h"
+#include "tgsi/tgsi_parse.h"
+#include "util/u_memory.h"
+
+#include "svga_tgsi_emit.h"
+#include "svga_context.h"
+
+
+
+
+static boolean ps20_input( struct svga_shader_emitter *emit,
+                           struct tgsi_declaration_semantic semantic,
+                           unsigned idx )
+{
+   struct src_register reg;
+   SVGA3DOpDclArgs dcl;
+   SVGA3dShaderInstToken opcode;
+
+   opcode = inst_token( SVGA3DOP_DCL );
+   dcl.values[0] = 0;
+   dcl.values[1] = 0;
+
+   switch (semantic.Name) {
+   case TGSI_SEMANTIC_POSITION:
+      /* Special case:
+       */
+      reg = src_register( SVGA3DREG_MISCTYPE, 
+                          SVGA3DMISCREG_POSITION );
+      break;
+   case TGSI_SEMANTIC_COLOR:
+      reg = src_register( SVGA3DREG_INPUT, 
+                          semantic.Index );
+      break;
+   case TGSI_SEMANTIC_FOG:
+      assert(semantic.Index == 0);
+      reg = src_register( SVGA3DREG_TEXTURE, 0 );
+      break;
+   case TGSI_SEMANTIC_GENERIC:
+      reg = src_register( SVGA3DREG_TEXTURE,
+                          semantic.Index + 1 );
+      break;
+   default:
+      assert(0);
+      return TRUE;
+   }
+
+   emit->input_map[idx] = reg;
+
+   dcl.dst = dst( reg );
+
+   dcl.usage = 0;
+   dcl.index = 0;
+
+   dcl.values[0] |= 1<<31;
+
+   return  (emit_instruction(emit, opcode) &&
+            svga_shader_emit_dwords( emit, dcl.values, Elements(dcl.values)));
+}
+
+
+static boolean ps20_output( struct svga_shader_emitter *emit,
+                            struct tgsi_declaration_semantic semantic,
+                            unsigned idx )
+{
+   SVGA3dShaderDestToken reg;
+
+   switch (semantic.Name) {
+   case TGSI_SEMANTIC_COLOR:
+      if (semantic.Index < PIPE_MAX_COLOR_BUFS) {
+         unsigned cbuf = semantic.Index;
+
+         emit->output_map[idx] = dst_register( SVGA3DREG_TEMP,
+                                               emit->nr_hw_temp++ );
+         emit->temp_col[cbuf] = emit->output_map[idx];
+         emit->true_col[cbuf] = dst_register( SVGA3DREG_COLOROUT, 
+                                              semantic.Index );
+      }
+      else {
+         assert(0);
+         reg = dst_register( SVGA3DREG_COLOROUT, 0 );
+      }
+      break;
+   case TGSI_SEMANTIC_POSITION:
+      emit->output_map[idx] = dst_register( SVGA3DREG_TEMP,
+                                            emit->nr_hw_temp++ );
+      emit->temp_pos = emit->output_map[idx];
+      emit->true_pos = dst_register( SVGA3DREG_DEPTHOUT, 
+                                     semantic.Index );
+      break;
+   default:
+      assert(0);
+      reg = dst_register( SVGA3DREG_COLOROUT, 0 );
+      break;
+   }
+
+   return TRUE;
+}
+
+
+static boolean vs20_input( struct svga_shader_emitter *emit,
+                           struct tgsi_declaration_semantic semantic,
+                           unsigned idx )
+{
+   SVGA3DOpDclArgs dcl;
+   SVGA3dShaderInstToken opcode;
+
+   opcode = inst_token( SVGA3DOP_DCL );
+   dcl.values[0] = 0;
+   dcl.values[1] = 0;
+
+   emit->input_map[idx] = src_register( SVGA3DREG_INPUT, idx );
+   dcl.dst = dst_register( SVGA3DREG_INPUT, idx );
+
+   assert(dcl.dst.reserved0);
+
+   /* Mesa doesn't provide use with VS input semantics (they're
+    * actually pretty meaningless), so we just generate some plausible
+    * ones here.  This has to match what we declare in the vdecl code
+    * in svga_pipe_vertex.c.
+    */
+   if (idx == 0) {
+      dcl.usage = SVGA3D_DECLUSAGE_POSITION;
+      dcl.index = 0;
+   }
+   else {
+      dcl.usage = SVGA3D_DECLUSAGE_TEXCOORD;
+      dcl.index = idx - 1;
+   }
+
+   dcl.values[0] |= 1<<31;
+
+   return  (emit_instruction(emit, opcode) &&
+            svga_shader_emit_dwords( emit, dcl.values, Elements(dcl.values)));
+}
+
+
+static boolean vs20_output( struct svga_shader_emitter *emit,
+                         struct tgsi_declaration_semantic semantic,
+                         unsigned idx )
+{
+   /* Don't emit dcl instruction for vs20 inputs
+    */
+
+   /* Just build the register map table: 
+    */
+   switch (semantic.Name) {
+   case TGSI_SEMANTIC_POSITION:
+      assert(semantic.Index == 0);
+      emit->output_map[idx] = dst_register( SVGA3DREG_TEMP,
+                                            emit->nr_hw_temp++ );
+      emit->temp_pos = emit->output_map[idx];
+      emit->true_pos = dst_register( SVGA3DREG_RASTOUT, 
+                                     SVGA3DRASTOUT_POSITION);
+      break;
+   case TGSI_SEMANTIC_PSIZE:
+      assert(semantic.Index == 0);
+      emit->output_map[idx] = dst_register( SVGA3DREG_TEMP,
+                                            emit->nr_hw_temp++ );
+      emit->temp_psiz = emit->output_map[idx];
+      emit->true_psiz = dst_register( SVGA3DREG_RASTOUT, 
+                                      SVGA3DRASTOUT_PSIZE );
+      break;
+   case TGSI_SEMANTIC_FOG:
+      assert(semantic.Index == 0);
+      emit->output_map[idx] = dst_register( SVGA3DREG_TEXCRDOUT, 0 );
+      break;
+   case TGSI_SEMANTIC_COLOR:
+      /* oD0 */
+      emit->output_map[idx] = dst_register( SVGA3DREG_ATTROUT,
+                                            semantic.Index );
+      break;
+   case TGSI_SEMANTIC_GENERIC:
+      emit->output_map[idx] = dst_register( SVGA3DREG_TEXCRDOUT,
+                                            semantic.Index + 1 );
+      break;
+   default:
+      assert(0);
+      emit->output_map[idx] = dst_register(  SVGA3DREG_TEMP, 0 );
+      return FALSE;
+   }
+
+   return TRUE;
+}
+
+static boolean ps20_sampler( struct svga_shader_emitter *emit,
+                          struct tgsi_declaration_semantic semantic,
+                          unsigned idx )
+{
+   SVGA3DOpDclArgs dcl;
+   SVGA3dShaderInstToken opcode;
+
+   opcode = inst_token( SVGA3DOP_DCL );
+   dcl.values[0] = 0;
+   dcl.values[1] = 0;
+
+   dcl.dst = dst_register( SVGA3DREG_SAMPLER, idx );
+   dcl.type = svga_tgsi_sampler_type( emit, idx );
+
+   return  (emit_instruction(emit, opcode) &&
+            svga_shader_emit_dwords( emit, dcl.values, Elements(dcl.values)));
+}
+
+
+boolean svga_translate_decl_sm20( struct svga_shader_emitter *emit,
+                             const struct tgsi_full_declaration *decl )
+{
+   unsigned first = decl->Range.First;
+   unsigned last = decl->Range.Last;
+   unsigned semantic = 0;
+   unsigned semantic_idx = 0;
+   unsigned idx;
+   
+   if (decl->Declaration.Semantic) {
+      semantic = decl->Semantic.Name;
+      semantic_idx = decl->Semantic.Index;
+   }
+
+   for( idx = first; idx <= last; idx++ ) {
+      boolean ok;
+
+      switch (decl->Declaration.File) {
+      case TGSI_FILE_SAMPLER:
+         assert (emit->unit == PIPE_SHADER_FRAGMENT);
+         ok = ps20_sampler( emit, decl->Semantic, idx );
+         break;
+
+      case TGSI_FILE_INPUT:
+         if (emit->unit == PIPE_SHADER_VERTEX)
+            ok = vs20_input( emit, decl->Semantic, idx );
+         else
+            ok = ps20_input( emit, decl->Semantic, idx );
+         break;
+
+      case TGSI_FILE_OUTPUT:
+         if (emit->unit == PIPE_SHADER_VERTEX)
+            ok = vs20_output( emit, decl->Semantic, idx );
+         else
+            ok = ps20_output( emit, decl->Semantic, idx );
+         break;
+
+      default:
+         /* don't need to declare other vars */
+         ok = TRUE;
+      }
+
+      if (!ok)
+         return FALSE;
+   }
+
+   return TRUE;
+}
+
+
+
diff --git a/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c b/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c
new file mode 100644 (file)
index 0000000..d1c7336
--- /dev/null
@@ -0,0 +1,385 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+
+#include "pipe/p_shader_tokens.h"
+#include "tgsi/tgsi_parse.h"
+#include "util/u_memory.h"
+
+#include "svga_tgsi_emit.h"
+#include "svga_context.h"
+
+static boolean translate_vs_ps_semantic( struct tgsi_declaration_semantic semantic,
+                                         unsigned *usage,
+                                         unsigned *idx )
+{
+   switch (semantic.Name) {
+   case TGSI_SEMANTIC_POSITION:  
+      *idx = semantic.Index;
+      *usage = SVGA3D_DECLUSAGE_POSITION;
+      break;
+   case TGSI_SEMANTIC_COLOR:     
+
+      *idx = semantic.Index;
+      *usage = SVGA3D_DECLUSAGE_COLOR;
+      break;
+   case TGSI_SEMANTIC_BCOLOR:
+      *idx = semantic.Index + 2; /* sharing with COLOR */
+      *usage = SVGA3D_DECLUSAGE_COLOR;
+      break;
+   case TGSI_SEMANTIC_FOG:       
+      *idx = 0;
+      assert(semantic.Index == 0);
+      *usage = SVGA3D_DECLUSAGE_TEXCOORD;
+      break;
+   case TGSI_SEMANTIC_PSIZE:     
+      *idx = semantic.Index;
+      *usage = SVGA3D_DECLUSAGE_PSIZE;
+      break;
+   case TGSI_SEMANTIC_GENERIC:   
+      *idx = semantic.Index + 1; /* texcoord[0] is reserved for fog */
+      *usage = SVGA3D_DECLUSAGE_TEXCOORD;
+      break;
+   case TGSI_SEMANTIC_NORMAL:    
+      *idx = semantic.Index;
+      *usage = SVGA3D_DECLUSAGE_NORMAL;
+      break;
+   default:
+      assert(0);
+      *usage = SVGA3D_DECLUSAGE_TEXCOORD;
+      *idx = 0;
+      return FALSE;
+   }
+
+   return TRUE;
+}
+
+
+static boolean emit_decl( struct svga_shader_emitter *emit,
+                          SVGA3dShaderDestToken reg,
+                          unsigned usage, 
+                          unsigned index )
+{
+   SVGA3DOpDclArgs dcl;
+   SVGA3dShaderInstToken opcode;
+
+   opcode = inst_token( SVGA3DOP_DCL );
+   dcl.values[0] = 0;
+   dcl.values[1] = 0;
+
+   dcl.dst = reg;
+   dcl.usage = usage;
+   dcl.index = index;
+   dcl.values[0] |= 1<<31;
+
+   return  (emit_instruction(emit, opcode) &&
+            svga_shader_emit_dwords( emit, dcl.values, Elements(dcl.values)));
+}
+
+static boolean emit_vface_decl( struct svga_shader_emitter *emit )
+{
+   if (!emit->emitted_vface) {
+      SVGA3dShaderDestToken reg =
+         dst_register( SVGA3DREG_MISCTYPE,
+                       SVGA3DMISCREG_FACE );
+
+      if (!emit_decl( emit, reg, 0, 0 ))
+         return FALSE;
+
+      emit->emitted_vface = TRUE;
+   }
+   return TRUE;
+}
+
+static boolean ps30_input( struct svga_shader_emitter *emit,
+                           struct tgsi_declaration_semantic semantic,
+                           unsigned idx )
+{
+   unsigned usage, index;
+   SVGA3dShaderDestToken reg;
+
+   if (semantic.Name == TGSI_SEMANTIC_POSITION) {
+      emit->input_map[idx] = src_register( SVGA3DREG_MISCTYPE,
+                                           SVGA3DMISCREG_POSITION );
+
+      emit->input_map[idx].base.swizzle = TRANSLATE_SWIZZLE( TGSI_SWIZZLE_X,
+                                                             TGSI_SWIZZLE_Y,
+                                                             TGSI_SWIZZLE_Y,
+                                                             TGSI_SWIZZLE_Y );
+
+      reg = writemask( dst(emit->input_map[idx]),
+                       TGSI_WRITEMASK_XY );
+
+      return emit_decl( emit, reg, 0, 0 );
+   }
+   else if (emit->key.fkey.light_twoside &&
+            (semantic.Name == TGSI_SEMANTIC_COLOR)) {
+
+      if (!translate_vs_ps_semantic( semantic, &usage, &index ))
+         return FALSE;
+
+      emit->internal_color_idx[emit->internal_color_count] = idx;
+      emit->input_map[idx] = src_register( SVGA3DREG_INPUT, emit->ps30_input_count );
+      emit->ps30_input_count++;
+      emit->internal_color_count++;
+
+      reg = dst( emit->input_map[idx] );
+
+      if (!emit_decl( emit, reg, usage, index ))
+         return FALSE;
+
+      semantic.Name = TGSI_SEMANTIC_BCOLOR;
+      if (!translate_vs_ps_semantic( semantic, &usage, &index ))
+         return FALSE;
+
+      reg = dst_register( SVGA3DREG_INPUT, emit->ps30_input_count++ );
+
+      if (!emit_decl( emit, reg, usage, index ))
+         return FALSE;
+
+      if (!emit_vface_decl( emit ))
+         return FALSE;
+
+      return TRUE;
+   }
+   else if (semantic.Name == TGSI_SEMANTIC_FACE) {
+      if (!emit_vface_decl( emit ))
+         return FALSE;
+      emit->emit_frontface = TRUE;
+      emit->internal_frontface_idx = idx;
+      return TRUE;
+   }
+   else {
+
+      if (!translate_vs_ps_semantic( semantic, &usage, &index ))
+         return FALSE;
+
+      emit->input_map[idx] = src_register( SVGA3DREG_INPUT, emit->ps30_input_count++ );
+      reg = dst( emit->input_map[idx] );
+
+      return emit_decl( emit, reg, usage, index );
+   }
+
+}
+
+
+/* PS output registers are the same as 2.0
+ */
+static boolean ps30_output( struct svga_shader_emitter *emit,
+                            struct tgsi_declaration_semantic semantic,
+                            unsigned idx )
+{
+   SVGA3dShaderDestToken reg;
+
+   switch (semantic.Name) {
+   case TGSI_SEMANTIC_COLOR:
+      emit->output_map[idx] = dst_register( SVGA3DREG_COLOROUT, 
+                                            semantic.Index );
+      break;
+   case TGSI_SEMANTIC_POSITION:
+      emit->output_map[idx] = dst_register( SVGA3DREG_TEMP,
+                                            emit->nr_hw_temp++ );
+      emit->temp_pos = emit->output_map[idx];
+      emit->true_pos = dst_register( SVGA3DREG_DEPTHOUT, 
+                                     semantic.Index );
+      break;
+   default:
+      assert(0);
+      reg = dst_register( SVGA3DREG_COLOROUT, 0 );
+      break;
+   }
+
+   return TRUE;
+}
+
+
+/* We still make up the input semantics the same as in 2.0
+ */
+static boolean vs30_input( struct svga_shader_emitter *emit,
+                           struct tgsi_declaration_semantic semantic,
+                           unsigned idx )
+{
+   SVGA3DOpDclArgs dcl;
+   SVGA3dShaderInstToken opcode;
+   unsigned usage, index;
+
+   opcode = inst_token( SVGA3DOP_DCL );
+   dcl.values[0] = 0;
+   dcl.values[1] = 0;
+
+   if (emit->key.vkey.zero_stride_vertex_elements & (1 << idx)) {
+      unsigned i;
+      unsigned offset = 0;
+      unsigned start_idx = emit->info.file_max[TGSI_FILE_CONSTANT] + 1;
+      /* adjust for prescale constants */
+      start_idx += emit->key.vkey.need_prescale ? 2 : 0;
+      /* compute the offset from the start of zero stride constants */
+      for (i = 0; i < PIPE_MAX_ATTRIBS && i < idx; ++i) {
+         if (emit->key.vkey.zero_stride_vertex_elements & (1<<i))
+            ++offset;
+      }
+      emit->input_map[idx] = src_register( SVGA3DREG_CONST,
+                                           start_idx + offset );
+   } else {
+      emit->input_map[idx] = src_register( SVGA3DREG_INPUT, idx );
+      dcl.dst = dst_register( SVGA3DREG_INPUT, idx );
+
+      assert(dcl.dst.reserved0);
+
+      svga_generate_vdecl_semantics( idx, &usage, &index );
+
+      dcl.usage = usage;
+      dcl.index = index;
+      dcl.values[0] |= 1<<31;
+
+      return  (emit_instruction(emit, opcode) &&
+               svga_shader_emit_dwords( emit, dcl.values, Elements(dcl.values)));
+   }
+   return TRUE;
+}
+
+/* VS3.0 outputs have proper declarations and semantic info for
+ * matching against PS inputs.
+ */
+static boolean vs30_output( struct svga_shader_emitter *emit,
+                         struct tgsi_declaration_semantic semantic,
+                         unsigned idx )
+{
+   SVGA3DOpDclArgs dcl;
+   SVGA3dShaderInstToken opcode;
+   unsigned usage, index;
+
+   opcode = inst_token( SVGA3DOP_DCL );
+   dcl.values[0] = 0;
+   dcl.values[1] = 0;
+
+   if (!translate_vs_ps_semantic( semantic, &usage, &index ))
+      return FALSE;
+
+   dcl.dst = dst_register( SVGA3DREG_OUTPUT, idx );
+   dcl.usage = usage;
+   dcl.index = index;
+   dcl.values[0] |= 1<<31;
+
+   if (semantic.Name == TGSI_SEMANTIC_POSITION) {
+      assert(idx == 0);
+      emit->output_map[idx] = dst_register( SVGA3DREG_TEMP,
+                                            emit->nr_hw_temp++ );
+      emit->temp_pos = emit->output_map[idx];
+      emit->true_pos = dcl.dst;
+   }
+   else if (semantic.Name == TGSI_SEMANTIC_PSIZE) {
+      emit->output_map[idx] = dst_register( SVGA3DREG_TEMP,
+                                            emit->nr_hw_temp++ );
+      emit->temp_psiz = emit->output_map[idx];
+
+      /* This has the effect of not declaring psiz (below) and not 
+       * emitting the final MOV to true_psiz in the postamble.
+       */
+      if (!emit->key.vkey.allow_psiz)
+         return TRUE;
+
+      emit->true_psiz = dcl.dst;
+   }
+   else {
+      emit->output_map[idx] = dcl.dst;
+   }
+
+
+   return  (emit_instruction(emit, opcode) &&
+            svga_shader_emit_dwords( emit, dcl.values, Elements(dcl.values)));
+}
+
+static boolean ps30_sampler( struct svga_shader_emitter *emit,
+                          struct tgsi_declaration_semantic semantic,
+                          unsigned idx )
+{
+   SVGA3DOpDclArgs dcl;
+   SVGA3dShaderInstToken opcode;
+
+   opcode = inst_token( SVGA3DOP_DCL );
+   dcl.values[0] = 0;
+   dcl.values[1] = 0;
+
+   dcl.dst = dst_register( SVGA3DREG_SAMPLER, idx );
+   dcl.type = svga_tgsi_sampler_type( emit, idx );
+   dcl.values[0] |= 1<<31;
+
+   return  (emit_instruction(emit, opcode) &&
+            svga_shader_emit_dwords( emit, dcl.values, Elements(dcl.values)));
+}
+
+
+boolean svga_translate_decl_sm30( struct svga_shader_emitter *emit,
+                             const struct tgsi_full_declaration *decl )
+{
+   unsigned first = decl->Range.First;
+   unsigned last = decl->Range.Last;
+   unsigned semantic = 0;
+   unsigned semantic_idx = 0;
+   unsigned idx;
+
+   if (decl->Declaration.Semantic) {
+      semantic = decl->Semantic.Name;
+      semantic_idx = decl->Semantic.Index;
+   }
+
+   for( idx = first; idx <= last; idx++ ) {
+      boolean ok;
+
+      switch (decl->Declaration.File) {
+      case TGSI_FILE_SAMPLER:
+         assert (emit->unit == PIPE_SHADER_FRAGMENT);
+         ok = ps30_sampler( emit, decl->Semantic, idx );
+         break;
+
+      case TGSI_FILE_INPUT:
+         if (emit->unit == PIPE_SHADER_VERTEX)
+            ok = vs30_input( emit, decl->Semantic, idx );
+         else
+            ok = ps30_input( emit, decl->Semantic, idx );
+         break;
+
+      case TGSI_FILE_OUTPUT:
+         if (emit->unit == PIPE_SHADER_VERTEX)
+            ok = vs30_output( emit, decl->Semantic, idx );
+         else
+            ok = ps30_output( emit, decl->Semantic, idx );
+         break;
+
+      default:
+         /* don't need to declare other vars */
+         ok = TRUE;
+      }
+
+      if (!ok)
+         return FALSE;
+   }
+
+   return TRUE;
+}
+
+
+
diff --git a/src/gallium/drivers/svga/svga_tgsi_emit.h b/src/gallium/drivers/svga/svga_tgsi_emit.h
new file mode 100644 (file)
index 0000000..2557824
--- /dev/null
@@ -0,0 +1,345 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#ifndef SVGA_TGSI_EMIT_H
+#define SVGA_TGSI_EMIT_H
+
+#include "tgsi/tgsi_scan.h"
+#include "svga_hw_reg.h"
+#include "svga_tgsi.h"
+#include "svga3d_shaderdefs.h"
+
+struct src_register
+{
+   SVGA3dShaderSrcToken base;
+   SVGA3dShaderSrcToken indirect;
+};
+
+
+struct svga_arl_consts {
+   int number;
+   int idx;
+   int swizzle;
+   int arl_num;
+};
+
+/* Internal functions:
+ */
+
+struct svga_shader_emitter
+{
+   boolean use_sm30;
+   
+   unsigned size;
+   char *buf;
+   char *ptr;
+
+   union svga_compile_key key;
+   struct tgsi_shader_info info;
+   int unit;
+
+   int imm_start;
+
+   int nr_hw_const;
+   int nr_hw_temp;
+   
+   int insn_offset;
+
+   int internal_temp_count;
+   int internal_imm_count;
+
+   int internal_color_idx[2]; /* diffuse, specular */
+   int internal_color_count;
+
+   boolean emitted_vface;
+   boolean emit_frontface;
+   int internal_frontface_idx;
+
+   int ps30_input_count;
+
+   boolean in_main_func;
+
+   boolean created_zero_immediate;
+   int zero_immediate_idx;
+
+   boolean created_loop_const;
+   int loop_const_idx;
+
+   boolean created_sincos_consts;
+   int sincos_consts_idx;
+
+   unsigned label[32];
+   unsigned nr_labels;
+
+   struct src_register input_map[PIPE_MAX_ATTRIBS];
+   SVGA3dShaderDestToken output_map[PIPE_MAX_ATTRIBS];
+
+   struct src_register imm_0055;
+   SVGA3dShaderDestToken temp_pos;
+   SVGA3dShaderDestToken true_pos;
+
+   SVGA3dShaderDestToken temp_col[PIPE_MAX_COLOR_BUFS];
+   SVGA3dShaderDestToken true_col[PIPE_MAX_COLOR_BUFS];
+
+   SVGA3dShaderDestToken temp_psiz;
+   SVGA3dShaderDestToken true_psiz;
+
+   struct svga_arl_consts arl_consts[12];
+   int num_arl_consts;
+   int current_arl;
+};
+
+
+boolean svga_shader_emit_dword( struct svga_shader_emitter *emit,
+                                unsigned dword );
+
+boolean svga_shader_emit_dwords( struct svga_shader_emitter *emit,
+                                 const unsigned *dwords,
+                                 unsigned nr );
+
+boolean svga_shader_emit_opcode( struct svga_shader_emitter *emit,
+                                 unsigned opcode );
+
+boolean svga_shader_emit_instructions( struct svga_shader_emitter *emit,
+                                       const struct tgsi_token *tokens );
+
+boolean svga_translate_decl_sm20( struct svga_shader_emitter *emit,
+                               const struct tgsi_full_declaration *decl );
+
+boolean svga_translate_decl_sm30( struct svga_shader_emitter *emit,
+                               const struct tgsi_full_declaration *decl );
+
+
+static INLINE boolean emit_dst( struct svga_shader_emitter *emit,
+                         SVGA3dShaderDestToken dest )
+{
+   assert(dest.reserved0);
+   return svga_shader_emit_dword( emit, dest.value );
+}
+
+static INLINE boolean emit_src( struct svga_shader_emitter *emit,
+                         const struct src_register src )
+{
+   if (src.base.relAddr) {
+      assert(src.base.reserved0);
+      assert(src.indirect.reserved0);
+      return (svga_shader_emit_dword( emit, src.base.value ) &&
+              svga_shader_emit_dword( emit, src.indirect.value ));
+   }
+   else {
+      assert(src.base.reserved0);
+      return svga_shader_emit_dword( emit, src.base.value );
+   }
+}
+
+
+static INLINE boolean emit_instruction( struct svga_shader_emitter *emit,
+                                 SVGA3dShaderInstToken opcode )
+{
+   return svga_shader_emit_opcode( emit, opcode.value );
+}
+
+
+static INLINE boolean emit_op1( struct svga_shader_emitter *emit,
+                         SVGA3dShaderInstToken inst,
+                         SVGA3dShaderDestToken dest,
+                         struct src_register src0 )
+{
+   return (emit_instruction( emit, inst ) &&
+           emit_dst( emit, dest ) &&
+           emit_src( emit, src0 ));
+}
+
+static INLINE boolean emit_op2( struct svga_shader_emitter *emit,
+                     SVGA3dShaderInstToken inst,
+                     SVGA3dShaderDestToken dest,
+                     struct src_register src0,
+                     struct src_register src1 )
+{
+   return (emit_instruction( emit, inst ) &&
+           emit_dst( emit, dest ) &&
+           emit_src( emit, src0 ) &&
+           emit_src( emit, src1 ));
+}
+
+static INLINE boolean emit_op3( struct svga_shader_emitter *emit,
+                         SVGA3dShaderInstToken inst,
+                         SVGA3dShaderDestToken dest,
+                         struct src_register src0,
+                         struct src_register src1,
+                         struct src_register src2 )
+{
+   return (emit_instruction( emit, inst ) &&
+           emit_dst( emit, dest ) &&
+           emit_src( emit, src0 ) &&
+           emit_src( emit, src1 ) &&
+           emit_src( emit, src2 ));
+}
+
+
+#define TRANSLATE_SWIZZLE(x,y,z,w)  ((x) | ((y) << 2) | ((z) << 4) | ((w) << 6))
+#define SWIZZLE_XYZW  \
+ TRANSLATE_SWIZZLE(TGSI_SWIZZLE_X,TGSI_SWIZZLE_Y,TGSI_SWIZZLE_Z,TGSI_SWIZZLE_W)
+#define SWIZZLE_XXXX  \
+ TRANSLATE_SWIZZLE(TGSI_SWIZZLE_X,TGSI_SWIZZLE_X,TGSI_SWIZZLE_X,TGSI_SWIZZLE_X)
+#define SWIZZLE_YYYY  \
+ TRANSLATE_SWIZZLE(TGSI_SWIZZLE_Y,TGSI_SWIZZLE_Y,TGSI_SWIZZLE_Y,TGSI_SWIZZLE_Y)
+#define SWIZZLE_ZZZZ  \
+ TRANSLATE_SWIZZLE(TGSI_SWIZZLE_Z,TGSI_SWIZZLE_Z,TGSI_SWIZZLE_Z,TGSI_SWIZZLE_Z)
+#define SWIZZLE_WWWW  \
+ TRANSLATE_SWIZZLE(TGSI_SWIZZLE_W,TGSI_SWIZZLE_W,TGSI_SWIZZLE_W,TGSI_SWIZZLE_W)
+
+
+
+static INLINE SVGA3dShaderInstToken
+inst_token( unsigned opcode )
+{
+   SVGA3dShaderInstToken inst;
+
+   inst.value = 0;
+   inst.op = opcode;
+
+   return inst;
+}
+
+static INLINE SVGA3dShaderDestToken 
+dst_register( unsigned file,
+              int number )
+{
+   SVGA3dShaderDestToken dest;
+
+   dest.value = 0;
+   dest.num = number;
+   dest.type_upper = file >> 3;
+   dest.relAddr = 0;
+   dest.reserved1 = 0;
+   dest.mask = 0xf;
+   dest.dstMod = 0;
+   dest.shfScale = 0;
+   dest.type_lower = file & 0x7;
+   dest.reserved0 = 1;          /* is_reg */
+   
+   return dest;
+}
+
+static INLINE SVGA3dShaderDestToken
+writemask( SVGA3dShaderDestToken dest,
+           unsigned mask )
+{
+   dest.mask &= mask;
+   return dest;
+}
+
+
+static INLINE SVGA3dShaderSrcToken 
+src_token( unsigned file, int number )
+{
+   SVGA3dShaderSrcToken src;
+
+   src.value = 0;
+   src.num = number;
+   src.type_upper = file >> 3;
+   src.relAddr = 0;
+   src.reserved1 = 0;
+   src.swizzle = SWIZZLE_XYZW;
+   src.srcMod = 0;
+   src.type_lower = file & 0x7;
+   src.reserved0 = 1;           /* is_reg */
+
+   return src;
+}
+
+
+static INLINE struct src_register 
+absolute( struct src_register src )
+{
+   src.base.srcMod = SVGA3DSRCMOD_ABS;
+
+   return src;
+}
+
+
+static INLINE struct src_register 
+negate( struct src_register src )
+{
+   switch (src.base.srcMod) {
+   case SVGA3DSRCMOD_ABS:
+      src.base.srcMod = SVGA3DSRCMOD_ABSNEG;
+      break;
+   case SVGA3DSRCMOD_ABSNEG:
+      src.base.srcMod = SVGA3DSRCMOD_ABS;
+      break;
+   case SVGA3DSRCMOD_NEG:
+      src.base.srcMod = SVGA3DSRCMOD_NONE;
+      break;
+   case SVGA3DSRCMOD_NONE:
+      src.base.srcMod = SVGA3DSRCMOD_NEG;
+      break;
+   }
+   return src;
+}
+
+
+static INLINE struct src_register 
+src_register( unsigned file, int number )
+{
+   struct src_register src;
+   
+   src.base = src_token( file, number );
+   src.indirect.value = 0;
+
+   return src;
+}
+
+static INLINE SVGA3dShaderDestToken dst( struct src_register src )
+{
+   return dst_register( SVGA3dShaderGetRegType( src.base.value ),
+                        src.base.num );
+}
+
+static INLINE struct src_register src( SVGA3dShaderDestToken dst )
+{
+   return src_register( SVGA3dShaderGetRegType( dst.value ),
+                        dst.num );
+}
+
+static INLINE ubyte svga_tgsi_sampler_type( struct svga_shader_emitter *emit,
+                                            int idx )
+{
+   switch (emit->key.fkey.tex[idx].texture_target) {
+   case PIPE_TEXTURE_1D:
+      return SVGA3DSAMP_2D;
+   case PIPE_TEXTURE_2D:
+      return SVGA3DSAMP_2D;
+   case PIPE_TEXTURE_3D:
+      return SVGA3DSAMP_VOLUME;
+   case PIPE_TEXTURE_CUBE:
+      return SVGA3DSAMP_CUBE;
+   }
+
+   return SVGA3DSAMP_UNKNOWN;
+}
+
+#endif
diff --git a/src/gallium/drivers/svga/svga_tgsi_insn.c b/src/gallium/drivers/svga/svga_tgsi_insn.c
new file mode 100644 (file)
index 0000000..dc5eb8f
--- /dev/null
@@ -0,0 +1,2716 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+
+#include "pipe/p_shader_tokens.h"
+#include "tgsi/tgsi_parse.h"
+#include "util/u_memory.h"
+
+#include "svga_tgsi_emit.h"
+#include "svga_context.h"
+
+
+static boolean emit_vs_postamble( struct svga_shader_emitter *emit );
+static boolean emit_ps_postamble( struct svga_shader_emitter *emit );
+
+
+
+static unsigned
+translate_opcode(
+   uint opcode )
+{
+   switch (opcode) {
+   case TGSI_OPCODE_ABS:        return SVGA3DOP_ABS;
+   case TGSI_OPCODE_ADD:        return SVGA3DOP_ADD;
+   case TGSI_OPCODE_BREAKC:     return SVGA3DOP_BREAKC;
+   case TGSI_OPCODE_DDX:        return SVGA3DOP_DSX;
+   case TGSI_OPCODE_DDY:        return SVGA3DOP_DSY;
+   case TGSI_OPCODE_DP2A:       return SVGA3DOP_DP2ADD;
+   case TGSI_OPCODE_DP3:        return SVGA3DOP_DP3;
+   case TGSI_OPCODE_DP4:        return SVGA3DOP_DP4;
+   case TGSI_OPCODE_ENDFOR:     return SVGA3DOP_ENDLOOP;
+   case TGSI_OPCODE_FRC:        return SVGA3DOP_FRC;
+   case TGSI_OPCODE_BGNFOR:     return SVGA3DOP_LOOP;
+   case TGSI_OPCODE_MAD:        return SVGA3DOP_MAD;
+   case TGSI_OPCODE_MAX:        return SVGA3DOP_MAX;
+   case TGSI_OPCODE_MIN:        return SVGA3DOP_MIN;
+   case TGSI_OPCODE_MOV:        return SVGA3DOP_MOV;
+   case TGSI_OPCODE_MUL:        return SVGA3DOP_MUL;
+   case TGSI_OPCODE_NOP:        return SVGA3DOP_NOP;
+   case TGSI_OPCODE_NRM4:       return SVGA3DOP_NRM;
+   case TGSI_OPCODE_SSG:        return SVGA3DOP_SGN;
+   default:
+      debug_printf("Unkown opcode %u\n", opcode);
+      assert( 0 );
+      return SVGA3DOP_LAST_INST;
+   }
+}
+
+
+static unsigned translate_file( unsigned file )
+{
+   switch (file) {
+   case TGSI_FILE_TEMPORARY: return SVGA3DREG_TEMP;
+   case TGSI_FILE_INPUT:     return SVGA3DREG_INPUT;
+   case TGSI_FILE_OUTPUT:    return SVGA3DREG_OUTPUT; /* VS3.0+ only */
+   case TGSI_FILE_IMMEDIATE: return SVGA3DREG_CONST;
+   case TGSI_FILE_CONSTANT:  return SVGA3DREG_CONST;
+   case TGSI_FILE_SAMPLER:   return SVGA3DREG_SAMPLER;
+   case TGSI_FILE_ADDRESS:   return SVGA3DREG_ADDR;
+   default:
+      assert( 0 );
+      return SVGA3DREG_TEMP;
+   }
+}
+
+
+
+
+
+
+static SVGA3dShaderDestToken 
+translate_dst_register( struct svga_shader_emitter *emit,
+                        const struct tgsi_full_instruction *insn,
+                        unsigned idx )
+{
+   const struct tgsi_full_dst_register *reg = &insn->Dst[idx];
+   SVGA3dShaderDestToken dest;
+
+   switch (reg->Register.File) {
+   case TGSI_FILE_OUTPUT:
+      /* Output registers encode semantic information in their name.
+       * Need to lookup a table built at decl time:
+       */
+      dest = emit->output_map[reg->Register.Index];
+      break;
+
+   default:
+      dest = dst_register( translate_file( reg->Register.File ),
+                           reg->Register.Index );
+      break;
+   }
+
+   dest.mask = reg->Register.WriteMask;
+
+   if (insn->Instruction.Saturate) 
+      dest.dstMod = SVGA3DDSTMOD_SATURATE;
+
+   return dest;
+}
+
+
+static struct src_register 
+swizzle( struct src_register src,
+         int x,
+         int y,
+         int z,
+         int w )
+{
+   x = (src.base.swizzle >> (x * 2)) & 0x3;
+   y = (src.base.swizzle >> (y * 2)) & 0x3;
+   z = (src.base.swizzle >> (z * 2)) & 0x3;
+   w = (src.base.swizzle >> (w * 2)) & 0x3;
+
+   src.base.swizzle = TRANSLATE_SWIZZLE(x,y,z,w);
+
+   return src;
+}
+
+static struct src_register
+scalar( struct src_register src,
+        int comp )
+{
+   return swizzle( src, comp, comp, comp, comp );
+}
+
+static INLINE boolean
+svga_arl_needs_adjustment( const struct svga_shader_emitter *emit )
+{
+   int i;
+
+   for (i = 0; i < emit->num_arl_consts; ++i) {
+      if (emit->arl_consts[i].arl_num == emit->current_arl)
+         return TRUE;
+   }
+   return FALSE;
+}
+
+static INLINE int
+svga_arl_adjustment( const struct svga_shader_emitter *emit )
+{
+   int i;
+
+   for (i = 0; i < emit->num_arl_consts; ++i) {
+      if (emit->arl_consts[i].arl_num == emit->current_arl)
+         return emit->arl_consts[i].number;
+   }
+   return 0;
+}
+
+static struct src_register 
+translate_src_register( const struct svga_shader_emitter *emit,
+                        const struct tgsi_full_src_register *reg )
+{
+   struct src_register src;
+
+   switch (reg->Register.File) {
+   case TGSI_FILE_INPUT:
+      /* Input registers are referred to by their semantic name rather
+       * than by index.  Use the mapping build up from the decls:
+       */
+      src = emit->input_map[reg->Register.Index];
+      break;
+       
+   case TGSI_FILE_IMMEDIATE:
+      /* Immediates are appended after TGSI constants in the D3D
+       * constant buffer.
+       */
+      src = src_register( translate_file( reg->Register.File ),
+                          reg->Register.Index + 
+                          emit->imm_start );
+      break;
+
+   default:
+      src = src_register( translate_file( reg->Register.File ),
+                          reg->Register.Index );
+
+      break;
+   }
+
+   /* Indirect addressing (for coninstant buffer lookups only)
+    */
+   if (reg->Register.Indirect)
+   {
+      /* we shift the offset towards the minimum */
+      if (svga_arl_needs_adjustment( emit )) {
+         src.base.num -= svga_arl_adjustment( emit );
+      }
+      src.base.relAddr = 1;
+
+      /* Not really sure what should go in the second token:
+       */
+      src.indirect = src_token( SVGA3DREG_ADDR,
+                                reg->Indirect.Index );
+
+      src.indirect.swizzle = SWIZZLE_XXXX;
+   }
+
+   src = swizzle( src,
+                  reg->Register.SwizzleX,
+                  reg->Register.SwizzleY,
+                  reg->Register.SwizzleZ,
+                  reg->Register.SwizzleW );
+
+   /* src.mod isn't a bitfield, unfortunately:
+    * See tgsi_util_get_full_src_register_sign_mode for implementation details.
+    */
+   if (reg->Register.Absolute) {
+      if (reg->Register.Negate)
+         src.base.srcMod = SVGA3DSRCMOD_ABSNEG;
+      else
+         src.base.srcMod = SVGA3DSRCMOD_ABS;
+   }
+   else {
+      if (reg->Register.Negate)
+         src.base.srcMod = SVGA3DSRCMOD_NEG;
+      else
+         src.base.srcMod = SVGA3DSRCMOD_NONE;
+   }
+
+   return src;
+}
+
+
+/*
+ * Get a temporary register, return -1 if none available
+ */
+static INLINE SVGA3dShaderDestToken 
+get_temp( struct svga_shader_emitter *emit )
+{
+   int i = emit->nr_hw_temp + emit->internal_temp_count++;
+
+   return dst_register( SVGA3DREG_TEMP, i );
+}
+
+/* Release a single temp.  Currently only effective if it was the last
+ * allocated temp, otherwise release will be delayed until the next
+ * call to reset_temp_regs().
+ */
+static INLINE void 
+release_temp( struct svga_shader_emitter *emit,
+              SVGA3dShaderDestToken temp )
+{
+   if (temp.num == emit->internal_temp_count - 1)
+      emit->internal_temp_count--;
+}
+
+static void reset_temp_regs( struct svga_shader_emitter *emit )
+{
+   emit->internal_temp_count = 0;
+}
+   
+
+static boolean submit_op0( struct svga_shader_emitter *emit,
+                           SVGA3dShaderInstToken inst,
+                           SVGA3dShaderDestToken dest )
+{
+   return (emit_instruction( emit, inst ) && 
+           emit_dst( emit, dest ));
+}
+
+static boolean submit_op1( struct svga_shader_emitter *emit,
+                           SVGA3dShaderInstToken inst,
+                           SVGA3dShaderDestToken dest,
+                           struct src_register src0 )
+{
+   return emit_op1( emit, inst, dest, src0 );
+}
+
+
+/* SVGA shaders may not refer to >1 constant register in a single
+ * instruction.  This function checks for that usage and inserts a
+ * move to temporary if detected.
+ *
+ * The same applies to input registers -- at most a single input
+ * register may be read by any instruction.
+ */
+static boolean submit_op2( struct svga_shader_emitter *emit,
+                           SVGA3dShaderInstToken inst,
+                           SVGA3dShaderDestToken dest,
+                           struct src_register src0,
+                           struct src_register src1 )
+{
+   SVGA3dShaderDestToken temp;
+   SVGA3dShaderRegType type0, type1;
+   boolean need_temp = FALSE;
+
+   temp.value = 0;
+   type0 = SVGA3dShaderGetRegType( src0.base.value );
+   type1 = SVGA3dShaderGetRegType( src1.base.value );
+
+   if (type0 == SVGA3DREG_CONST &&
+       type1 == SVGA3DREG_CONST &&
+       src0.base.num != src1.base.num)
+      need_temp = TRUE;
+
+   if (type0 == SVGA3DREG_INPUT &&
+       type1 == SVGA3DREG_INPUT &&
+       src0.base.num != src1.base.num)
+      need_temp = TRUE;
+
+   if (need_temp)
+   {
+      temp = get_temp( emit );
+
+      if (!emit_op1( emit, inst_token( SVGA3DOP_MOV ), temp, src0 ))
+         return FALSE;
+
+      src0 = src( temp );
+   }
+
+   if (!emit_op2( emit, inst, dest, src0, src1 ))
+      return FALSE;
+
+   if (need_temp)
+      release_temp( emit, temp );
+
+   return TRUE;
+}
+
+
+/* SVGA shaders may not refer to >1 constant register in a single
+ * instruction.  This function checks for that usage and inserts a
+ * move to temporary if detected.
+ */
+static boolean submit_op3( struct svga_shader_emitter *emit,
+                           SVGA3dShaderInstToken inst,
+                           SVGA3dShaderDestToken dest,
+                           struct src_register src0,
+                           struct src_register src1,
+                           struct src_register src2 )
+{
+   SVGA3dShaderDestToken temp0;
+   SVGA3dShaderDestToken temp1;
+   boolean need_temp0 = FALSE;
+   boolean need_temp1 = FALSE;
+   SVGA3dShaderRegType type0, type1, type2;
+
+   temp0.value = 0;
+   temp1.value = 0;
+   type0 = SVGA3dShaderGetRegType( src0.base.value );
+   type1 = SVGA3dShaderGetRegType( src1.base.value );
+   type2 = SVGA3dShaderGetRegType( src2.base.value );
+
+   if (inst.op != SVGA3DOP_SINCOS) {
+      if (type0 == SVGA3DREG_CONST &&
+          ((type1 == SVGA3DREG_CONST && src0.base.num != src1.base.num) ||
+           (type2 == SVGA3DREG_CONST && src0.base.num != src2.base.num)))
+         need_temp0 = TRUE;
+
+      if (type1 == SVGA3DREG_CONST &&
+          (type2 == SVGA3DREG_CONST && src1.base.num != src2.base.num))
+         need_temp1 = TRUE;
+   }
+
+   if (type0 == SVGA3DREG_INPUT &&
+       ((type1 == SVGA3DREG_INPUT && src0.base.num != src1.base.num) ||
+        (type2 == SVGA3DREG_INPUT && src0.base.num != src2.base.num)))
+      need_temp0 = TRUE;
+
+   if (type1 == SVGA3DREG_INPUT &&
+       (type2 == SVGA3DREG_INPUT && src1.base.num != src2.base.num))
+      need_temp1 = TRUE;
+
+   if (need_temp0)
+   {
+      temp0 = get_temp( emit );
+      if (!emit_op1( emit, inst_token( SVGA3DOP_MOV ), temp0, src0 ))
+         return FALSE;
+         
+      src0 = src( temp0 );
+   }
+
+   if (need_temp1)
+   {
+      temp1 = get_temp( emit );
+
+      if (!emit_op1( emit, inst_token( SVGA3DOP_MOV ), temp1, src1 ))
+         return FALSE;
+
+      src1 = src( temp1 );
+   }
+
+   if (!emit_op3( emit, inst, dest, src0, src1, src2 ))
+      return FALSE;
+
+   if (need_temp1)
+      release_temp( emit, temp1 );
+   if (need_temp0)
+      release_temp( emit, temp0 );
+   return TRUE;
+}
+
+
+static boolean emit_def_const( struct svga_shader_emitter *emit,
+                               SVGA3dShaderConstType type,
+                               unsigned idx,
+                               float a,
+                               float b,
+                               float c,
+                               float d )
+{
+   SVGA3DOpDefArgs def;
+   SVGA3dShaderInstToken opcode;
+
+   switch (type) {
+   case SVGA3D_CONST_TYPE_FLOAT:
+      opcode = inst_token( SVGA3DOP_DEF );
+      def.dst = dst_register( SVGA3DREG_CONST, idx );
+      def.constValues[0] = a;
+      def.constValues[1] = b;
+      def.constValues[2] = c;
+      def.constValues[3] = d;
+      break;
+   case SVGA3D_CONST_TYPE_INT:
+      opcode = inst_token( SVGA3DOP_DEFI );
+      def.dst = dst_register( SVGA3DREG_CONSTINT, idx );
+      def.constIValues[0] = (int)a;
+      def.constIValues[1] = (int)b;
+      def.constIValues[2] = (int)c;
+      def.constIValues[3] = (int)d;
+      break;
+   default:
+      assert(0);
+      break;
+   }
+
+   if (!emit_instruction(emit, opcode) ||
+       !svga_shader_emit_dwords( emit, def.values, Elements(def.values)))
+      return FALSE;
+
+   return TRUE;
+}
+
+static INLINE boolean
+create_zero_immediate( struct svga_shader_emitter *emit )
+{
+   unsigned idx = emit->nr_hw_const++;
+
+   if (!emit_def_const( emit, SVGA3D_CONST_TYPE_FLOAT,
+                        idx, 0, 0, 0, 1 ))
+      return FALSE;
+
+   emit->zero_immediate_idx = idx;
+   emit->created_zero_immediate = TRUE;
+
+   return TRUE;
+}
+
+static INLINE boolean
+create_loop_const( struct svga_shader_emitter *emit )
+{
+   unsigned idx = emit->nr_hw_const++;
+
+   if (!emit_def_const( emit, SVGA3D_CONST_TYPE_INT, idx,
+                        255, /* iteration count */
+                        0, /* initial value */
+                        1, /* step size */
+                        0 /* not used, must be 0 */))
+      return FALSE;
+
+   emit->loop_const_idx = idx;
+   emit->created_loop_const = TRUE;
+
+   return TRUE;
+}
+
+static INLINE boolean
+create_sincos_consts( struct svga_shader_emitter *emit )
+{
+   unsigned idx = emit->nr_hw_const++;
+
+   if (!emit_def_const( emit, SVGA3D_CONST_TYPE_FLOAT, idx,
+                        -1.5500992e-006f,
+                        -2.1701389e-005f,
+                        0.0026041667f,
+                        0.00026041668f ))
+      return FALSE;
+
+   emit->sincos_consts_idx = idx;
+   idx = emit->nr_hw_const++;
+
+   if (!emit_def_const( emit, SVGA3D_CONST_TYPE_FLOAT, idx,
+                        -0.020833334f,
+                        -0.12500000f,
+                        1.0f,
+                        0.50000000f ))
+      return FALSE;
+
+   emit->created_sincos_consts = TRUE;
+
+   return TRUE;
+}
+
+static INLINE boolean
+create_arl_consts( struct svga_shader_emitter *emit )
+{
+   int i;
+
+   for (i = 0; i < emit->num_arl_consts; i += 4) {
+      int j;
+      unsigned idx = emit->nr_hw_const++;
+      float vals[4];
+      for (j = 0; j < 4 && (j + i) < emit->num_arl_consts; ++j) {
+         vals[j] = emit->arl_consts[i + j].number;
+         emit->arl_consts[i + j].idx = idx;
+         switch (j) {
+         case 0:
+            emit->arl_consts[i + 0].swizzle = TGSI_SWIZZLE_X;
+            break;
+         case 1:
+            emit->arl_consts[i + 0].swizzle = TGSI_SWIZZLE_Y;
+            break;
+         case 2:
+            emit->arl_consts[i + 0].swizzle = TGSI_SWIZZLE_Z;
+            break;
+         case 3:
+            emit->arl_consts[i + 0].swizzle = TGSI_SWIZZLE_W;
+            break;
+         }
+      }
+      while (j < 4)
+         vals[j++] = 0;
+
+      if (!emit_def_const( emit, SVGA3D_CONST_TYPE_FLOAT, idx,
+                           vals[0], vals[1],
+                           vals[2], vals[3]))
+         return FALSE;
+   }
+
+   return TRUE;
+}
+
+static INLINE struct src_register
+get_vface( struct svga_shader_emitter *emit )
+{
+   assert(emit->emitted_vface);
+   return src_register(SVGA3DREG_MISCTYPE, 
+                       SVGA3DMISCREG_FACE);
+}
+
+/* returns {0, 0, 0, 1} immediate */
+static INLINE struct src_register
+get_zero_immediate( struct svga_shader_emitter *emit )
+{
+   assert(emit->created_zero_immediate);
+   assert(emit->zero_immediate_idx >= 0);
+   return src_register( SVGA3DREG_CONST,
+                        emit->zero_immediate_idx );
+}
+
+/* returns the loop const */
+static INLINE struct src_register
+get_loop_const( struct svga_shader_emitter *emit )
+{
+   assert(emit->created_loop_const);
+   assert(emit->loop_const_idx >= 0);
+   return src_register( SVGA3DREG_CONSTINT,
+                        emit->loop_const_idx );
+}
+
+/* returns a sincos const */
+static INLINE struct src_register
+get_sincos_const( struct svga_shader_emitter *emit,
+                  unsigned index )
+{
+   assert(emit->created_sincos_consts);
+   assert(emit->sincos_consts_idx >= 0);
+   assert(index == 0 || index == 1);
+   return src_register( SVGA3DREG_CONST,
+                        emit->sincos_consts_idx + index );
+}
+
+static INLINE struct src_register
+get_fake_arl_const( struct svga_shader_emitter *emit )
+{
+   struct src_register reg;
+   int idx = 0, swizzle = 0, i;
+
+   for (i = 0; i < emit->num_arl_consts; ++ i) {
+      if (emit->arl_consts[i].arl_num == emit->current_arl) {
+         idx = emit->arl_consts[i].idx;
+         swizzle = emit->arl_consts[i].swizzle;
+      }
+   }
+
+   reg = src_register( SVGA3DREG_CONST, idx );
+   return scalar(reg, swizzle);
+}
+
+static INLINE struct src_register
+get_tex_dimensions( struct svga_shader_emitter *emit, int sampler_num )
+{
+   int idx;
+   struct src_register reg;
+
+   /* the width/height indexes start right after constants */
+   idx = emit->key.fkey.tex[sampler_num].width_height_idx +
+         emit->info.file_max[TGSI_FILE_CONSTANT] + 1;
+
+   reg = src_register( SVGA3DREG_CONST, idx );
+   return reg;
+}
+
+static boolean emit_fake_arl(struct svga_shader_emitter *emit,
+                             const struct tgsi_full_instruction *insn)
+{
+   const struct src_register src0 = translate_src_register(
+      emit, &insn->Src[0] );
+   struct src_register src1 = get_fake_arl_const( emit );
+   SVGA3dShaderDestToken dst = translate_dst_register( emit, insn, 0 );
+   SVGA3dShaderDestToken tmp = get_temp( emit );
+
+   if (!submit_op1(emit, inst_token( SVGA3DOP_MOV ), tmp, src0))
+      return FALSE;
+
+   if (!submit_op2( emit, inst_token( SVGA3DOP_ADD ), tmp, src( tmp ),
+                    src1))
+      return FALSE;
+
+   /* replicate the original swizzle */
+   src1 = src(tmp);
+   src1.base.swizzle = src0.base.swizzle;
+
+   return submit_op1( emit, inst_token( SVGA3DOP_MOVA ),
+                      dst, src1 );
+}
+
+static boolean emit_if(struct svga_shader_emitter *emit,
+                       const struct tgsi_full_instruction *insn)
+{
+   const struct src_register src = translate_src_register(
+      emit, &insn->Src[0] );
+   struct src_register zero = get_zero_immediate( emit );
+   SVGA3dShaderInstToken if_token = inst_token( SVGA3DOP_IFC );
+
+   if_token.control = SVGA3DOPCOMPC_NE;
+   zero = scalar(zero, TGSI_SWIZZLE_X);
+
+   return (emit_instruction( emit, if_token ) &&
+           emit_src( emit, src ) &&
+           emit_src( emit, zero ) );
+}
+
+static boolean emit_endif(struct svga_shader_emitter *emit,
+                       const struct tgsi_full_instruction *insn)
+{
+   return (emit_instruction( emit,
+                             inst_token( SVGA3DOP_ENDIF )));
+}
+
+static boolean emit_else(struct svga_shader_emitter *emit,
+                         const struct tgsi_full_instruction *insn)
+{
+   return (emit_instruction( emit,
+                             inst_token( SVGA3DOP_ELSE )));
+}
+
+/* Translate the following TGSI FLR instruction.
+ *    FLR  DST, SRC
+ * To the following SVGA3D instruction sequence.
+ *    FRC  TMP, SRC
+ *    SUB  DST, SRC, TMP
+ */
+static boolean emit_floor(struct svga_shader_emitter *emit,
+                          const struct tgsi_full_instruction *insn )
+{
+   SVGA3dShaderDestToken dst = translate_dst_register( emit, insn, 0 );
+   const struct src_register src0 = translate_src_register(
+      emit, &insn->Src[0] );
+   SVGA3dShaderDestToken temp = get_temp( emit );
+
+   /* FRC  TMP, SRC */
+   if (!submit_op1( emit, inst_token( SVGA3DOP_FRC ), temp, src0 ))
+      return FALSE;
+
+   /* SUB  DST, SRC, TMP */
+   if (!submit_op2( emit, inst_token( SVGA3DOP_ADD ), dst, src0,
+                    negate( src( temp ) ) ))
+      return FALSE;
+
+   return TRUE;
+}
+
+
+/* Translate the following TGSI CMP instruction.
+ *    CMP  DST, SRC0, SRC1, SRC2
+ * To the following SVGA3D instruction sequence.
+ *    CMP  DST, SRC0, SRC2, SRC1
+ */
+static boolean emit_cmp(struct svga_shader_emitter *emit,
+                          const struct tgsi_full_instruction *insn )
+{
+   SVGA3dShaderDestToken dst = translate_dst_register( emit, insn, 0 );
+   const struct src_register src0 = translate_src_register(
+      emit, &insn->Src[0] );
+   const struct src_register src1 = translate_src_register(
+      emit, &insn->Src[1] );
+   const struct src_register src2 = translate_src_register(
+      emit, &insn->Src[2] );
+
+   /* CMP  DST, SRC0, SRC2, SRC1 */
+   return submit_op3( emit, inst_token( SVGA3DOP_CMP ), dst, src0, src2, src1);
+}
+
+
+
+/* Translate the following TGSI DIV instruction.
+ *    DIV  DST.xy, SRC0, SRC1
+ * To the following SVGA3D instruction sequence.
+ *    RCP  TMP.x, SRC1.xxxx
+ *    RCP  TMP.y, SRC1.yyyy
+ *    MUL  DST.xy, SRC0, TMP
+ */
+static boolean emit_div(struct svga_shader_emitter *emit,
+                        const struct tgsi_full_instruction *insn )
+{
+   SVGA3dShaderDestToken dst = translate_dst_register( emit, insn, 0 );
+   const struct src_register src0 = translate_src_register(
+      emit, &insn->Src[0] );
+   const struct src_register src1 = translate_src_register(
+      emit, &insn->Src[1] );
+   SVGA3dShaderDestToken temp = get_temp( emit );
+   int i;
+
+   /* For each enabled element, perform a RCP instruction.  Note that
+    * RCP is scalar in SVGA3D:
+    */
+   for (i = 0; i < 4; i++) {
+      unsigned channel = 1 << i;
+      if (dst.mask & channel) {
+         /* RCP  TMP.?, SRC1.???? */
+         if (!submit_op1( emit, inst_token( SVGA3DOP_RCP ), 
+                          writemask(temp, channel), 
+                          scalar(src1, i) ))
+            return FALSE;
+      }
+   }
+
+   /* Then multiply them out with a single mul:
+    *
+    * MUL  DST, SRC0, TMP
+    */
+   if (!submit_op2( emit, inst_token( SVGA3DOP_MUL ), dst, src0,
+                    src( temp ) ))
+      return FALSE;
+
+   return TRUE;
+}
+
+/* Translate the following TGSI DP2 instruction.
+ *    DP2  DST, SRC1, SRC2
+ * To the following SVGA3D instruction sequence.
+ *    MUL  TMP, SRC1, SRC2
+ *    ADD  DST, TMP.xxxx, TMP.yyyy
+ */
+static boolean emit_dp2(struct svga_shader_emitter *emit,
+                        const struct tgsi_full_instruction *insn )
+{
+   SVGA3dShaderDestToken dst = translate_dst_register( emit, insn, 0 );
+   const struct src_register src0 = translate_src_register(
+      emit, &insn->Src[0] );
+   const struct src_register src1 = translate_src_register(
+      emit, &insn->Src[1] );
+   SVGA3dShaderDestToken temp = get_temp( emit );
+   struct src_register temp_src0, temp_src1;
+
+   /* MUL  TMP, SRC1, SRC2 */
+   if (!submit_op2( emit, inst_token( SVGA3DOP_MUL ), temp, src0, src1 ))
+      return FALSE;
+
+   temp_src0 = scalar(src( temp ), TGSI_SWIZZLE_X);
+   temp_src1 = scalar(src( temp ), TGSI_SWIZZLE_Y);
+
+   /* ADD  DST, TMP.xxxx, TMP.yyyy */
+   if (!submit_op2( emit, inst_token( SVGA3DOP_ADD ), dst,
+                    temp_src0, temp_src1 ))
+      return FALSE;
+
+   return TRUE;
+}
+
+
+/* Translate the following TGSI DPH instruction.
+ *    DPH  DST, SRC1, SRC2
+ * To the following SVGA3D instruction sequence.
+ *    DP3  TMP, SRC1, SRC2
+ *    ADD  DST, TMP, SRC2.wwww
+ */
+static boolean emit_dph(struct svga_shader_emitter *emit,
+                        const struct tgsi_full_instruction *insn )
+{
+   SVGA3dShaderDestToken dst = translate_dst_register( emit, insn, 0 );
+   const struct src_register src0 = translate_src_register(
+      emit, &insn->Src[0] );
+   struct src_register src1 = translate_src_register(
+      emit, &insn->Src[1] );
+   SVGA3dShaderDestToken temp = get_temp( emit );
+
+   /* DP3  TMP, SRC1, SRC2 */
+   if (!submit_op2( emit, inst_token( SVGA3DOP_DP3 ), temp, src0, src1 ))
+      return FALSE;
+
+   src1 = scalar(src1, TGSI_SWIZZLE_W);
+
+   /* ADD  DST, TMP, SRC2.wwww */
+   if (!submit_op2( emit, inst_token( SVGA3DOP_ADD ), dst,
+                    src( temp ), src1 ))
+      return FALSE;
+
+   return TRUE;
+}
+
+/* Translate the following TGSI DST instruction.
+ *    NRM  DST, SRC
+ * To the following SVGA3D instruction sequence.
+ *    DP3  TMP, SRC, SRC
+ *    RSQ  TMP, TMP
+ *    MUL  DST, SRC, TMP
+ */
+static boolean emit_nrm(struct svga_shader_emitter *emit,
+                        const struct tgsi_full_instruction *insn )
+{
+   SVGA3dShaderDestToken dst = translate_dst_register( emit, insn, 0 );
+   const struct src_register src0 = translate_src_register(
+      emit, &insn->Src[0] );
+   SVGA3dShaderDestToken temp = get_temp( emit );
+
+   /* DP3  TMP, SRC, SRC */
+   if (!submit_op2( emit, inst_token( SVGA3DOP_DP3 ), temp, src0, src0 ))
+      return FALSE;
+
+   /* RSQ  TMP, TMP */
+   if (!submit_op1( emit, inst_token( SVGA3DOP_RSQ ), temp, src( temp )))
+      return FALSE;
+
+   /* MUL  DST, SRC, TMP */
+   if (!submit_op2( emit, inst_token( SVGA3DOP_MUL ), dst,
+                    src0, src( temp )))
+      return FALSE;
+
+   return TRUE;
+
+}
+
+static boolean do_emit_sincos(struct svga_shader_emitter *emit,
+                              SVGA3dShaderDestToken dst,
+                              struct src_register src0)
+{
+   src0 = scalar(src0, TGSI_SWIZZLE_X);
+
+   if (emit->use_sm30) {
+      return submit_op1( emit, inst_token( SVGA3DOP_SINCOS ),
+                         dst, src0 );
+   } else {
+      struct src_register const1 = get_sincos_const( emit, 0 );
+      struct src_register const2 = get_sincos_const( emit, 1 );
+
+      return submit_op3( emit, inst_token( SVGA3DOP_SINCOS ),
+                         dst, src0, const1, const2 );
+   }
+}
+
+static boolean emit_sincos(struct svga_shader_emitter *emit,
+                           const struct tgsi_full_instruction *insn)
+{
+   SVGA3dShaderDestToken dst = translate_dst_register( emit, insn, 0 );
+   struct src_register src0 = translate_src_register(
+      emit, &insn->Src[0] );
+   SVGA3dShaderDestToken temp = get_temp( emit );
+
+   /* SCS TMP SRC */
+   if (!do_emit_sincos(emit, writemask(temp, TGSI_WRITEMASK_XY), src0 ))
+      return FALSE;
+
+   /* MOV DST TMP */
+   if (!submit_op1( emit, inst_token( SVGA3DOP_MOV ), dst, src( temp ) ))
+      return FALSE;
+
+   return TRUE;
+}
+
+/*
+ * SCS TMP SRC
+ * MOV DST TMP.yyyy
+ */
+static boolean emit_sin(struct svga_shader_emitter *emit,
+                        const struct tgsi_full_instruction *insn )
+{
+   SVGA3dShaderDestToken dst = translate_dst_register( emit, insn, 0 );
+   struct src_register src0 = translate_src_register(
+      emit, &insn->Src[0] );
+   SVGA3dShaderDestToken temp = get_temp( emit );
+
+   /* SCS TMP SRC */
+   if (!do_emit_sincos(emit, writemask(temp, TGSI_WRITEMASK_Y), src0))
+      return FALSE;
+
+   src0 = scalar(src( temp ), TGSI_SWIZZLE_Y);
+
+   /* MOV DST TMP.yyyy */
+   if (!submit_op1( emit, inst_token( SVGA3DOP_MOV ), dst, src0 ))
+      return FALSE;
+
+   return TRUE;
+}
+
+/*
+ * SCS TMP SRC
+ * MOV DST TMP.xxxx
+ */
+static boolean emit_cos(struct svga_shader_emitter *emit,
+                        const struct tgsi_full_instruction *insn )
+{
+   SVGA3dShaderDestToken dst = translate_dst_register( emit, insn, 0 );
+   struct src_register src0 = translate_src_register(
+      emit, &insn->Src[0] );
+   SVGA3dShaderDestToken temp = get_temp( emit );
+
+   /* SCS TMP SRC */
+   if (!do_emit_sincos( emit, writemask(temp, TGSI_WRITEMASK_X), src0 ))
+      return FALSE;
+
+   src0 = scalar(src( temp ), TGSI_SWIZZLE_X);
+
+   /* MOV DST TMP.xxxx */
+   if (!submit_op1( emit, inst_token( SVGA3DOP_MOV ), dst, src0 ))
+      return FALSE;
+
+   return TRUE;
+}
+
+
+/*
+ * ADD DST SRC0, negate(SRC0)
+ */
+static boolean emit_sub(struct svga_shader_emitter *emit,
+                        const struct tgsi_full_instruction *insn)
+{
+   SVGA3dShaderDestToken dst = translate_dst_register( emit, insn, 0 );
+   struct src_register src0 = translate_src_register(
+      emit, &insn->Src[0] );
+   struct src_register src1 = translate_src_register(
+      emit, &insn->Src[1] );
+
+   src1 = negate(src1);
+
+   if (!submit_op2( emit, inst_token( SVGA3DOP_ADD ), dst,
+                    src0, src1 ))
+      return FALSE;
+
+   return TRUE;
+}
+
+
+static boolean emit_kil(struct svga_shader_emitter *emit,
+                        const struct tgsi_full_instruction *insn )
+{
+   SVGA3dShaderInstToken inst;
+   const struct tgsi_full_src_register *reg = &insn->Src[0];
+   struct src_register src0;
+
+   inst = inst_token( SVGA3DOP_TEXKILL );
+   src0 = translate_src_register( emit, reg );
+
+   if (reg->Register.Absolute ||
+       reg->Register.Negate ||
+       reg->Register.Indirect ||
+       reg->Register.SwizzleX != 0 ||
+       reg->Register.SwizzleY != 1 ||
+       reg->Register.SwizzleZ != 2 ||
+       reg->Register.File != TGSI_FILE_TEMPORARY)
+   {
+      SVGA3dShaderDestToken temp = get_temp( emit );
+
+      submit_op1( emit, inst_token( SVGA3DOP_MOV ), temp, src0 );
+      src0 = src( temp );
+   }
+
+   return submit_op0( emit, inst, dst(src0) );
+}
+
+
+/* mesa state tracker always emits kilp as an unconditional
+ * kil */
+static boolean emit_kilp(struct svga_shader_emitter *emit,
+                        const struct tgsi_full_instruction *insn )
+{
+   SVGA3dShaderInstToken inst;
+   SVGA3dShaderDestToken temp;
+   struct src_register one = get_zero_immediate( emit );
+
+   inst = inst_token( SVGA3DOP_TEXKILL );
+   one = scalar( one, TGSI_SWIZZLE_W );
+
+   /* texkill doesn't allow negation on the operand so lets move
+    * negation of {1} to a temp register */
+   temp = get_temp( emit );
+   if (!submit_op1( emit, inst_token( SVGA3DOP_MOV ), temp,
+                    negate( one ) ))
+      return FALSE;
+
+   return submit_op0( emit, inst, temp );
+}
+
+/* Implement conditionals by initializing destination reg to 'fail',
+ * then set predicate reg with UFOP_SETP, then move 'pass' to dest
+ * based on predicate reg.
+ *
+ * SETP src0, cmp, src1  -- do this first to avoid aliasing problems.
+ * MOV dst, fail
+ * MOV dst, pass, p0 
+ */
+static boolean
+emit_conditional(struct svga_shader_emitter *emit,
+                 unsigned compare_func,
+                 SVGA3dShaderDestToken dst,
+                 struct src_register src0,
+                 struct src_register src1,
+                 struct src_register pass,
+                 struct src_register fail)
+{
+   SVGA3dShaderDestToken pred_reg = dst_register( SVGA3DREG_PREDICATE, 0 );
+   SVGA3dShaderInstToken setp_token, mov_token;
+   setp_token = inst_token( SVGA3DOP_SETP );
+
+   switch (compare_func) {
+   case PIPE_FUNC_NEVER:
+      return submit_op1( emit, inst_token( SVGA3DOP_MOV ),
+                         dst, fail );
+      break;
+   case PIPE_FUNC_LESS:
+      setp_token.control = SVGA3DOPCOMP_LT;
+      break;
+   case PIPE_FUNC_EQUAL:
+      setp_token.control = SVGA3DOPCOMP_EQ;
+      break;
+   case PIPE_FUNC_LEQUAL:
+      setp_token.control = SVGA3DOPCOMP_LE;
+      break;
+   case PIPE_FUNC_GREATER:
+      setp_token.control = SVGA3DOPCOMP_GT;
+      break;
+   case PIPE_FUNC_NOTEQUAL:
+      setp_token.control = SVGA3DOPCOMPC_NE;
+      break;
+   case PIPE_FUNC_GEQUAL:
+      setp_token.control = SVGA3DOPCOMP_GE;
+      break;
+   case PIPE_FUNC_ALWAYS:
+      return submit_op1( emit, inst_token( SVGA3DOP_MOV ),
+                         dst, pass );
+      break;
+   }
+
+   /* SETP src0, COMPOP, src1 */
+   if (!submit_op2( emit, setp_token, pred_reg,
+                    src0, src1 ))
+      return FALSE;
+
+   mov_token = inst_token( SVGA3DOP_MOV );
+
+   /* MOV dst, fail */
+   if (!submit_op1( emit, mov_token, dst,
+                    fail ))
+      return FALSE;
+
+   /* MOV dst, pass (predicated)
+    *
+    * Note that the predicate reg (and possible modifiers) is passed
+    * as the first source argument.
+    */
+   mov_token.predicated = 1;
+   if (!submit_op2( emit, mov_token, dst,
+                    src( pred_reg ), pass ))
+      return FALSE;
+
+   return TRUE;
+}
+
+
+static boolean
+emit_select(struct svga_shader_emitter *emit,
+            unsigned compare_func,
+            SVGA3dShaderDestToken dst,
+            struct src_register src0,
+            struct src_register src1 )
+{
+   /* There are some SVGA instructions which implement some selects
+    * directly, but they are only available in the vertex shader.
+    */
+   if (emit->unit == PIPE_SHADER_VERTEX) {
+      switch (compare_func) {
+      case PIPE_FUNC_GEQUAL:
+         return submit_op2( emit, inst_token( SVGA3DOP_SGE ), dst, src0, src1 );
+      case PIPE_FUNC_LEQUAL:
+         return submit_op2( emit, inst_token( SVGA3DOP_SGE ), dst, src1, src0 );
+      case PIPE_FUNC_GREATER:
+         return submit_op2( emit, inst_token( SVGA3DOP_SLT ), dst, src1, src0 );
+      case PIPE_FUNC_LESS:
+         return submit_op2( emit, inst_token( SVGA3DOP_SLT ), dst, src0, src1 );
+      default:
+         break;
+      }
+   }
+
+
+   /* Otherwise, need to use the setp approach:
+    */
+   {
+      struct src_register one, zero;
+      /* zero immediate is 0,0,0,1 */
+      zero = get_zero_immediate( emit );
+      one  = scalar( zero, TGSI_SWIZZLE_W );
+      zero = scalar( zero, TGSI_SWIZZLE_X );
+
+      return emit_conditional(
+         emit,
+         compare_func,
+         dst,
+         src0,
+         src1,
+         one, zero);
+   }
+}
+
+
+static boolean emit_select_op(struct svga_shader_emitter *emit,
+                              unsigned compare,
+                              const struct tgsi_full_instruction *insn)
+{
+   SVGA3dShaderDestToken dst = translate_dst_register( emit, insn, 0 );
+   struct src_register src0 = translate_src_register(
+      emit, &insn->Src[0] );
+   struct src_register src1 = translate_src_register(
+      emit, &insn->Src[1] );
+      
+   return emit_select( emit, compare, dst, src0, src1 );
+}
+
+
+/* Translate texture instructions to SVGA3D representation.
+ */
+static boolean emit_tex2(struct svga_shader_emitter *emit,
+                         const struct tgsi_full_instruction *insn,
+                         SVGA3dShaderDestToken dst )
+{
+   SVGA3dShaderInstToken inst;
+   struct src_register src0;
+   struct src_register src1;
+
+   inst.value = 0;
+   inst.op = SVGA3DOP_TEX;
+
+   switch (insn->Instruction.Opcode) {
+   case TGSI_OPCODE_TEX:
+      break;
+   case TGSI_OPCODE_TXP:
+      inst.control = SVGA3DOPCONT_PROJECT;
+      break;
+   case TGSI_OPCODE_TXB:
+      inst.control = SVGA3DOPCONT_BIAS;
+      break;
+   default:
+      assert(0);
+      return FALSE;
+   }
+
+   src0 = translate_src_register( emit, &insn->Src[0] );
+   src1 = translate_src_register( emit, &insn->Src[1] );
+
+   if (emit->key.fkey.tex[src1.base.num].unnormalized) {
+      struct src_register wh = get_tex_dimensions( emit, src1.base.num );
+      SVGA3dShaderDestToken tmp = get_temp( emit );
+
+      /* MUL  tmp, SRC0, WH */
+      if (!submit_op2( emit, inst_token( SVGA3DOP_MUL ),
+                       tmp, src0, wh ))
+         return FALSE;
+      src0 = src( tmp );
+   }
+
+   return submit_op2( emit, inst, dst, src0, src1 );
+}
+
+
+
+
+/* Translate texture instructions to SVGA3D representation.
+ */
+static boolean emit_tex3(struct svga_shader_emitter *emit,
+                         const struct tgsi_full_instruction *insn,
+                         SVGA3dShaderDestToken dst )
+{
+   SVGA3dShaderInstToken inst;
+   struct src_register src0;
+   struct src_register src1;
+   struct src_register src2;
+
+   inst.value = 0;
+
+   switch (insn->Instruction.Opcode) {
+   case TGSI_OPCODE_TXD: 
+      inst.op = SVGA3DOP_TEXLDD;
+      break;
+   case TGSI_OPCODE_TXL:
+      inst.op = SVGA3DOP_TEXLDL;
+      break;
+   }
+
+   src0 = translate_src_register( emit, &insn->Src[0] );
+   src1 = translate_src_register( emit, &insn->Src[1] );
+   src2 = translate_src_register( emit, &insn->Src[2] );
+
+   return submit_op3( emit, inst, dst, src0, src1, src2 );
+}
+
+
+static boolean emit_tex(struct svga_shader_emitter *emit,
+                        const struct tgsi_full_instruction *insn )
+{
+   SVGA3dShaderDestToken dst = 
+      translate_dst_register( emit, insn, 0 );
+   struct src_register src0 =
+      translate_src_register( emit, &insn->Src[0] );
+   struct src_register src1 =
+      translate_src_register( emit, &insn->Src[1] );
+
+   SVGA3dShaderDestToken tex_result;
+
+   /* check for shadow samplers */
+   boolean compare = (emit->key.fkey.tex[src1.base.num].compare_mode ==
+                      PIPE_TEX_COMPARE_R_TO_TEXTURE);
+
+
+   /* If doing compare processing, need to put this value into a
+    * temporary so it can be used as a source later on.
+    */
+   if (compare ||
+       (!emit->use_sm30 && dst.mask != TGSI_WRITEMASK_XYZW) ) {
+      tex_result = get_temp( emit );
+   }
+   else {
+      tex_result = dst;
+   }
+
+   switch(insn->Instruction.Opcode) {
+   case TGSI_OPCODE_TEX:
+   case TGSI_OPCODE_TXB:
+   case TGSI_OPCODE_TXP:
+      if (!emit_tex2( emit, insn, tex_result ))
+         return FALSE;
+      break;
+   case TGSI_OPCODE_TXL:
+   case TGSI_OPCODE_TXD:
+      if (!emit_tex3( emit, insn, tex_result ))
+         return FALSE;
+      break;
+   default:
+      assert(0);
+   }
+
+
+   if (compare) {
+      SVGA3dShaderDestToken src0_zdivw = get_temp( emit );
+      struct src_register tex_src_x = scalar(src(tex_result), TGSI_SWIZZLE_Y);
+      struct src_register one =
+         scalar( get_zero_immediate( emit ), TGSI_SWIZZLE_W );
+
+      /* Divide texcoord R by Q */
+      if (!submit_op1( emit, inst_token( SVGA3DOP_RCP ),
+                       src0_zdivw,
+                       scalar(src0, TGSI_SWIZZLE_W) ))
+         return FALSE;
+
+      if (!submit_op2( emit, inst_token( SVGA3DOP_MUL ),
+                       src0_zdivw,
+                       scalar(src0, TGSI_SWIZZLE_Z),
+                       src(src0_zdivw) ))
+         return FALSE;
+
+      if (!emit_select(
+             emit,
+             emit->key.fkey.tex[src1.base.num].compare_func,
+             dst,
+             src(src0_zdivw),
+             tex_src_x))
+         return FALSE;
+
+      return submit_op1( emit, inst_token( SVGA3DOP_MOV ),
+                         writemask( dst, TGSI_WRITEMASK_W),
+                         one );
+   }
+   else if (!emit->use_sm30 && dst.mask != TGSI_WRITEMASK_XYZW) 
+   {
+      if (!emit_op1( emit, inst_token( SVGA3DOP_MOV ), dst, src(tex_result) ))
+         return FALSE;
+   }
+
+   return TRUE;
+}
+
+static boolean emit_bgnloop2( struct svga_shader_emitter *emit,
+                              const struct tgsi_full_instruction *insn )
+{
+   SVGA3dShaderInstToken inst = inst_token( SVGA3DOP_LOOP );
+   struct src_register loop_reg = src_register( SVGA3DREG_LOOP, 0 );
+   struct src_register const_int = get_loop_const( emit );
+
+   return (emit_instruction( emit, inst ) &&
+           emit_src( emit, loop_reg ) &&
+           emit_src( emit, const_int ) );
+}
+
+static boolean emit_endloop2( struct svga_shader_emitter *emit,
+                              const struct tgsi_full_instruction *insn )
+{
+   SVGA3dShaderInstToken inst = inst_token( SVGA3DOP_ENDLOOP );
+   return emit_instruction( emit, inst );
+}
+
+static boolean emit_brk( struct svga_shader_emitter *emit,
+                         const struct tgsi_full_instruction *insn )
+{
+   SVGA3dShaderInstToken inst = inst_token( SVGA3DOP_BREAK );
+   return emit_instruction( emit, inst );
+}
+
+static boolean emit_scalar_op1( struct svga_shader_emitter *emit,
+                                unsigned opcode,
+                                const struct tgsi_full_instruction *insn )
+{
+   SVGA3dShaderInstToken inst;
+   SVGA3dShaderDestToken dst;
+   struct src_register src;
+
+   inst = inst_token( opcode );
+   dst = translate_dst_register( emit, insn, 0 );
+   src = translate_src_register( emit, &insn->Src[0] );
+   src = scalar( src, TGSI_SWIZZLE_X );
+
+   return submit_op1( emit, inst, dst, src );
+}
+
+
+static boolean emit_simple_instruction(struct svga_shader_emitter *emit,
+                                       unsigned opcode,
+                                       const struct tgsi_full_instruction *insn )
+{
+   const struct tgsi_full_src_register *src = insn->Src;
+   SVGA3dShaderInstToken inst;
+   SVGA3dShaderDestToken dst;
+
+   inst = inst_token( opcode );
+   dst = translate_dst_register( emit, insn, 0 );
+
+   switch (insn->Instruction.NumSrcRegs) {
+   case 0:
+      return submit_op0( emit, inst, dst );
+   case 1:
+      return submit_op1( emit, inst, dst,
+                         translate_src_register( emit, &src[0] ));
+   case 2:
+      return submit_op2( emit, inst, dst,
+                         translate_src_register( emit, &src[0] ),
+                         translate_src_register( emit, &src[1] ) );
+   case 3:
+      return submit_op3( emit, inst, dst,
+                         translate_src_register( emit, &src[0] ),
+                         translate_src_register( emit, &src[1] ),
+                         translate_src_register( emit, &src[2] ) );
+   default:
+      assert(0);
+      return FALSE;
+   }
+}
+
+static boolean emit_arl(struct svga_shader_emitter *emit,
+                        const struct tgsi_full_instruction *insn)
+{
+   ++emit->current_arl;
+   if (svga_arl_needs_adjustment( emit )) {
+      return emit_fake_arl( emit, insn );
+   } else {
+      /* no need to adjust, just emit straight arl */
+      return emit_simple_instruction(emit, SVGA3DOP_MOVA, insn);
+   }
+}
+
+static boolean alias_src_dst( struct src_register src,
+                              SVGA3dShaderDestToken dst )
+{
+   if (src.base.num != dst.num)
+      return FALSE;
+
+   if (SVGA3dShaderGetRegType(dst.value) != 
+       SVGA3dShaderGetRegType(src.base.value))
+      return FALSE;
+
+   return TRUE;
+}
+
+static boolean emit_pow(struct svga_shader_emitter *emit,
+                        const struct tgsi_full_instruction *insn)
+{
+   SVGA3dShaderDestToken dst = translate_dst_register( emit, insn, 0 );
+   struct src_register src0 = translate_src_register(
+      emit, &insn->Src[0] );
+   struct src_register src1 = translate_src_register(
+      emit, &insn->Src[1] );
+   boolean need_tmp = FALSE;
+   
+   /* POW can only output to a temporary */
+   if (insn->Dst[0].Register.File != TGSI_FILE_TEMPORARY)
+      need_tmp = TRUE;
+   
+   /* POW src1 must not be the same register as dst */
+   if (alias_src_dst( src1, dst ))
+      need_tmp = TRUE;
+
+   /* it's a scalar op */
+   src0 = scalar( src0, TGSI_SWIZZLE_X );
+   src1 = scalar( src1, TGSI_SWIZZLE_X );
+
+   if (need_tmp) {
+      SVGA3dShaderDestToken tmp = writemask(get_temp( emit ), TGSI_WRITEMASK_X );
+
+      if (!submit_op2(emit, inst_token( SVGA3DOP_POW ), tmp, src0, src1))
+         return FALSE;
+
+      return submit_op1(emit, inst_token( SVGA3DOP_MOV ), dst, scalar(src(tmp), 0) );
+   } 
+   else {
+      return submit_op2(emit, inst_token( SVGA3DOP_POW ), dst, src0, src1);
+   }
+}
+
+static boolean emit_xpd(struct svga_shader_emitter *emit,
+                        const struct tgsi_full_instruction *insn)
+{
+   SVGA3dShaderDestToken dst = translate_dst_register( emit, insn, 0 );
+   const struct src_register src0 = translate_src_register(
+      emit, &insn->Src[0] );
+   const struct src_register src1 = translate_src_register(
+      emit, &insn->Src[1] );
+   boolean need_dst_tmp = FALSE;
+
+   /* XPD can only output to a temporary */
+   if (SVGA3dShaderGetRegType(dst.value) != SVGA3DREG_TEMP) 
+      need_dst_tmp = TRUE;
+
+   /* The dst reg must not be the same as src0 or src1*/
+   if (alias_src_dst(src0, dst) ||
+       alias_src_dst(src1, dst))
+      need_dst_tmp = TRUE;
+
+   if (need_dst_tmp) {
+      SVGA3dShaderDestToken tmp = get_temp( emit );
+
+      /* Obey DX9 restrictions on mask:
+       */
+      tmp.mask = dst.mask & TGSI_WRITEMASK_XYZ;
+
+      if (!submit_op2(emit, inst_token( SVGA3DOP_CRS ), tmp, src0, src1))
+         return FALSE;
+
+      if (!submit_op1(emit, inst_token( SVGA3DOP_MOV ), dst, src( tmp )))
+         return FALSE;
+   } 
+   else {
+      if (!submit_op2(emit, inst_token( SVGA3DOP_CRS ), dst, src0, src1))
+         return FALSE;
+   }
+
+   /* Need to emit 1.0 to dst.w?
+    */
+   if (dst.mask & TGSI_WRITEMASK_W) {
+      struct src_register zero = get_zero_immediate( emit );
+
+      if (!submit_op1(emit, 
+                      inst_token( SVGA3DOP_MOV ), 
+                      writemask(dst, TGSI_WRITEMASK_W),
+                      zero))
+         return FALSE;
+   }
+
+   return TRUE;
+}
+
+
+static boolean emit_lrp(struct svga_shader_emitter *emit,
+                        const struct tgsi_full_instruction *insn)
+{
+   SVGA3dShaderDestToken dst = translate_dst_register( emit, insn, 0 );
+   SVGA3dShaderDestToken tmp;
+   const struct src_register src0 = translate_src_register(
+      emit, &insn->Src[0] );
+   const struct src_register src1 = translate_src_register(
+      emit, &insn->Src[1] );
+   const struct src_register src2 = translate_src_register(
+      emit, &insn->Src[2] );
+   boolean need_dst_tmp = FALSE;
+
+   /* The dst reg must not be the same as src0 or src2 */
+   if (alias_src_dst(src0, dst) ||
+       alias_src_dst(src2, dst))
+      need_dst_tmp = TRUE;
+
+   if (need_dst_tmp) {
+      tmp = get_temp( emit );
+      tmp.mask = dst.mask;
+   }
+   else {
+      tmp = dst;
+   }
+
+   if (!submit_op3(emit, inst_token( SVGA3DOP_LRP ), tmp, src0, src1, src2))
+      return FALSE;
+
+   if (need_dst_tmp) {
+      if (!submit_op1(emit, inst_token( SVGA3DOP_MOV ), dst, src( tmp )))
+         return FALSE;      
+   } 
+
+   return TRUE;
+}
+
+
+static boolean emit_dst_insn(struct svga_shader_emitter *emit,
+                             const struct tgsi_full_instruction *insn )
+{
+   if (emit->unit == PIPE_SHADER_VERTEX) {
+      /* SVGA/DX9 has a DST instruction, but only for vertex shaders:
+       */
+      return emit_simple_instruction(emit, SVGA3DOP_DST, insn);
+   }
+   else {
+
+      /* result[0] = 1    * 1;
+       * result[1] = a[1] * b[1];
+       * result[2] = a[2] * 1;
+       * result[3] = 1    * b[3];
+       */
+
+      SVGA3dShaderDestToken dst = translate_dst_register( emit, insn, 0 );
+      SVGA3dShaderDestToken tmp;
+      const struct src_register src0 = translate_src_register(
+         emit, &insn->Src[0] );
+      const struct src_register src1 = translate_src_register(
+         emit, &insn->Src[1] );
+      struct src_register zero = get_zero_immediate( emit );
+      boolean need_tmp = FALSE;
+
+      if (SVGA3dShaderGetRegType(dst.value) != SVGA3DREG_TEMP ||
+          alias_src_dst(src0, dst) ||
+          alias_src_dst(src1, dst))
+         need_tmp = TRUE;
+
+      if (need_tmp) {
+         tmp = get_temp( emit );
+      }
+      else {
+         tmp = dst;
+      }
+
+      /* tmp.xw = 1.0
+       */
+      if (tmp.mask & TGSI_WRITEMASK_XW) {
+         if (!submit_op1( emit, inst_token( SVGA3DOP_MOV ), 
+                          writemask(tmp, TGSI_WRITEMASK_XW ),
+                          scalar( zero, 3 )))
+            return FALSE;
+      }
+      
+      /* tmp.yz = src0
+       */
+      if (tmp.mask & TGSI_WRITEMASK_YZ) {
+         if (!submit_op1( emit, inst_token( SVGA3DOP_MOV ), 
+                          writemask(tmp, TGSI_WRITEMASK_YZ ),
+                          src0))
+            return FALSE;
+      }
+
+      /* tmp.yw = tmp * src1
+       */
+      if (tmp.mask & TGSI_WRITEMASK_YW) {
+         if (!submit_op2( emit, inst_token( SVGA3DOP_MUL ), 
+                          writemask(tmp, TGSI_WRITEMASK_YW ),
+                          src(tmp),
+                          src1))
+            return FALSE;
+      }
+
+      /* dst = tmp
+       */
+      if (need_tmp) {
+         if (!submit_op1( emit, inst_token( SVGA3DOP_MOV ), 
+                          dst,
+                          src(tmp)))
+            return FALSE;
+      }      
+   }
+   
+   return TRUE;
+}
+
+
+static boolean emit_exp(struct svga_shader_emitter *emit,
+                        const struct tgsi_full_instruction *insn)
+{
+   SVGA3dShaderDestToken dst = translate_dst_register( emit, insn, 0 );
+   struct src_register src0 =
+      translate_src_register( emit, &insn->Src[0] );
+   struct src_register zero = get_zero_immediate( emit );
+   SVGA3dShaderDestToken fraction;
+
+   if (dst.mask & TGSI_WRITEMASK_Y)
+      fraction = dst;
+   else if (dst.mask & TGSI_WRITEMASK_X)
+      fraction = get_temp( emit );
+
+   /* If y is being written, fill it with src0 - floor(src0).
+    */
+   if (dst.mask & TGSI_WRITEMASK_XY) {
+      if (!submit_op1( emit, inst_token( SVGA3DOP_FRC ),
+                       writemask( fraction, TGSI_WRITEMASK_Y ),
+                       src0 ))
+         return FALSE;
+   }
+
+   /* If x is being written, fill it with 2 ^ floor(src0).
+    */
+   if (dst.mask & TGSI_WRITEMASK_X) {
+      if (!submit_op2( emit, inst_token( SVGA3DOP_ADD ),
+                       writemask( dst, dst.mask & TGSI_WRITEMASK_X ),
+                       src0,
+                       scalar( negate( src( fraction ) ), TGSI_SWIZZLE_Y ) ) )
+         return FALSE;
+
+      if (!submit_op1( emit, inst_token( SVGA3DOP_EXP ),
+                       writemask( dst, dst.mask & TGSI_WRITEMASK_X ),
+                       scalar( src( dst ), TGSI_SWIZZLE_X ) ) )
+         return FALSE;
+
+      if (!(dst.mask & TGSI_WRITEMASK_Y))
+         release_temp( emit, fraction );
+   }
+
+   /* If z is being written, fill it with 2 ^ src0 (partial precision).
+    */
+   if (dst.mask & TGSI_WRITEMASK_Z) {
+      if (!submit_op1( emit, inst_token( SVGA3DOP_EXPP ),
+                       writemask( dst, dst.mask & TGSI_WRITEMASK_Z ),
+                       src0 ) )
+         return FALSE;
+   }
+
+   /* If w is being written, fill it with one.
+    */
+   if (dst.mask & TGSI_WRITEMASK_W) {
+      if (!submit_op1( emit, inst_token( SVGA3DOP_MOV ),
+                       writemask(dst, TGSI_WRITEMASK_W),
+                       scalar( zero, TGSI_SWIZZLE_W ) ))
+         return FALSE;
+   }
+
+   return TRUE;
+}
+
+static boolean emit_lit(struct svga_shader_emitter *emit,
+                             const struct tgsi_full_instruction *insn )
+{
+   if (emit->unit == PIPE_SHADER_VERTEX) {
+      /* SVGA/DX9 has a LIT instruction, but only for vertex shaders:
+       */
+      return emit_simple_instruction(emit, SVGA3DOP_LIT, insn);
+   }
+   else {
+
+      /* D3D vs. GL semantics can be fairly easily accomodated by
+       * variations on this sequence.
+       *
+       * GL:
+       *   tmp.y = src.x
+       *   tmp.z = pow(src.y,src.w)
+       *   p0 = src0.xxxx > 0
+       *   result = zero.wxxw
+       *   (p0) result.yz = tmp
+       *
+       * D3D:
+       *   tmp.y = src.x
+       *   tmp.z = pow(src.y,src.w)
+       *   p0 = src0.xxyy > 0
+       *   result = zero.wxxw
+       *   (p0) result.yz = tmp
+       *
+       * Will implement the GL version for now.
+       */
+
+      SVGA3dShaderDestToken dst = translate_dst_register( emit, insn, 0 );
+      SVGA3dShaderDestToken tmp = get_temp( emit );
+      const struct src_register src0 = translate_src_register(
+         emit, &insn->Src[0] );
+      struct src_register zero = get_zero_immediate( emit );
+
+      /* tmp = pow(src.y, src.w)
+       */
+      if (dst.mask & TGSI_WRITEMASK_Z) {
+         if (!submit_op2(emit, inst_token( SVGA3DOP_POW ), 
+                         tmp, 
+                         scalar(src0, 1), 
+                         scalar(src0, 3)))
+            return FALSE;
+      }
+
+      /* tmp.y = src.x
+       */
+      if (dst.mask & TGSI_WRITEMASK_Y) {
+         if (!submit_op1( emit, inst_token( SVGA3DOP_MOV ), 
+                          writemask(tmp, TGSI_WRITEMASK_Y ),
+                          scalar(src0, 0)))
+            return FALSE;
+      }
+      
+      /* Can't quite do this with emit conditional due to the extra
+       * writemask on the predicated mov:
+       */
+      {
+         SVGA3dShaderDestToken pred_reg = dst_register( SVGA3DREG_PREDICATE, 0 );
+         SVGA3dShaderInstToken setp_token, mov_token;
+         struct src_register predsrc;
+
+         setp_token = inst_token( SVGA3DOP_SETP );
+         mov_token = inst_token( SVGA3DOP_MOV );
+
+         setp_token.control = SVGA3DOPCOMP_GT;
+
+         /* D3D vs GL semantics:
+          */
+         if (0)
+            predsrc = swizzle(src0, 0, 0, 1, 1); /* D3D */
+         else
+            predsrc = swizzle(src0, 0, 0, 0, 0); /* GL */
+
+         /* SETP src0.xxyy, GT, {0}.x */
+         if (!submit_op2( emit, setp_token, pred_reg,
+                          predsrc, 
+                          swizzle(zero, 0, 0, 0, 0) ))
+            return FALSE;
+         
+         /* MOV dst, fail */
+         if (!submit_op1( emit, inst_token( SVGA3DOP_MOV ), dst,
+                          swizzle(zero, 3, 0, 0, 3 )))
+             return FALSE;
+
+         /* MOV dst.yz, tmp (predicated)
+          *
+          * Note that the predicate reg (and possible modifiers) is passed
+          * as the first source argument.
+          */
+         if (dst.mask & TGSI_WRITEMASK_YZ) {
+            mov_token.predicated = 1;
+            if (!submit_op2( emit, mov_token,
+                             writemask(dst, TGSI_WRITEMASK_YZ),
+                             src( pred_reg ), src( tmp ) ))
+               return FALSE;
+         }
+      }
+   }
+
+   return TRUE;
+}
+
+
+
+
+static boolean emit_ex2( struct svga_shader_emitter *emit,
+                         const struct tgsi_full_instruction *insn )
+{
+   SVGA3dShaderInstToken inst;
+   SVGA3dShaderDestToken dst;
+   struct src_register src0;
+
+   inst = inst_token( SVGA3DOP_EXP );
+   dst = translate_dst_register( emit, insn, 0 );
+   src0 = translate_src_register( emit, &insn->Src[0] );
+   src0 = scalar( src0, TGSI_SWIZZLE_X );
+
+   if (dst.mask != TGSI_WRITEMASK_XYZW) {
+      SVGA3dShaderDestToken tmp = get_temp( emit );
+
+      if (!submit_op1( emit, inst, tmp, src0 ))
+         return FALSE;
+
+      return submit_op1( emit, inst_token( SVGA3DOP_MOV ),
+                         dst,
+                         scalar( src( tmp ), TGSI_SWIZZLE_X ) );
+   }
+
+   return submit_op1( emit, inst, dst, src0 );
+}
+
+
+static boolean emit_log(struct svga_shader_emitter *emit,
+                        const struct tgsi_full_instruction *insn)
+{
+   SVGA3dShaderDestToken dst = translate_dst_register( emit, insn, 0 );
+   struct src_register src0 =
+      translate_src_register( emit, &insn->Src[0] );
+   struct src_register zero = get_zero_immediate( emit );
+   SVGA3dShaderDestToken abs_tmp;
+   struct src_register abs_src0;
+   SVGA3dShaderDestToken log2_abs;
+
+   if (dst.mask & TGSI_WRITEMASK_Z)
+      log2_abs = dst;
+   else if (dst.mask & TGSI_WRITEMASK_XY)
+      log2_abs = get_temp( emit );
+
+   /* If z is being written, fill it with log2( abs( src0 ) ).
+    */
+   if (dst.mask & TGSI_WRITEMASK_XYZ) {
+      if (!src0.base.srcMod || src0.base.srcMod == SVGA3DSRCMOD_ABS)
+         abs_src0 = src0;
+      else {
+         abs_tmp = get_temp( emit );
+
+         if (!submit_op1( emit, inst_token( SVGA3DOP_MOV ),
+                          abs_tmp,
+                          src0 ) )
+            return FALSE;
+
+         abs_src0 = src( abs_tmp );
+      }
+
+      abs_src0 = absolute( scalar( abs_src0, TGSI_SWIZZLE_X ) );
+
+      if (!submit_op1( emit, inst_token( SVGA3DOP_LOG ),
+                       writemask( log2_abs, TGSI_WRITEMASK_Z ),
+                       abs_src0 ) )
+         return FALSE;
+   }
+
+   if (dst.mask & TGSI_WRITEMASK_XY) {
+      SVGA3dShaderDestToken floor_log2;
+
+      if (dst.mask & TGSI_WRITEMASK_X)
+         floor_log2 = dst;
+      else
+         floor_log2 = get_temp( emit );
+
+      /* If x is being written, fill it with floor( log2( abs( src0 ) ) ).
+       */
+      if (!submit_op1( emit, inst_token( SVGA3DOP_FRC ),
+                       writemask( floor_log2, TGSI_WRITEMASK_X ),
+                       scalar( src( log2_abs ), TGSI_SWIZZLE_Z ) ) )
+         return FALSE;
+
+      if (!submit_op2( emit, inst_token( SVGA3DOP_ADD ),
+                       writemask( floor_log2, TGSI_WRITEMASK_X ),
+                       scalar( src( log2_abs ), TGSI_SWIZZLE_Z ),
+                       negate( src( floor_log2 ) ) ) )
+         return FALSE;
+
+      /* If y is being written, fill it with
+       * abs ( src0 ) / ( 2 ^ floor( log2( abs( src0 ) ) ) ).
+       */
+      if (dst.mask & TGSI_WRITEMASK_Y) {
+         if (!submit_op1( emit, inst_token( SVGA3DOP_EXP ),
+                          writemask( dst, TGSI_WRITEMASK_Y ),
+                          negate( scalar( src( floor_log2 ),
+                                          TGSI_SWIZZLE_X ) ) ) )
+            return FALSE;
+
+         if (!submit_op2( emit, inst_token( SVGA3DOP_MUL ),
+                          writemask( dst, TGSI_WRITEMASK_Y ),
+                          src( dst ),
+                          abs_src0 ) )
+            return FALSE;
+      }
+
+      if (!(dst.mask & TGSI_WRITEMASK_X))
+         release_temp( emit, floor_log2 );
+
+      if (!(dst.mask & TGSI_WRITEMASK_Z))
+         release_temp( emit, log2_abs );
+   }
+
+   if (dst.mask & TGSI_WRITEMASK_XYZ && src0.base.srcMod &&
+       src0.base.srcMod != SVGA3DSRCMOD_ABS)
+      release_temp( emit, abs_tmp );
+
+   /* If w is being written, fill it with one.
+    */
+   if (dst.mask & TGSI_WRITEMASK_W) {
+      if (!submit_op1( emit, inst_token( SVGA3DOP_MOV ),
+                       writemask(dst, TGSI_WRITEMASK_W),
+                       scalar( zero, TGSI_SWIZZLE_W ) ))
+         return FALSE;
+   }
+
+   return TRUE;
+}
+
+
+static boolean emit_bgnsub( struct svga_shader_emitter *emit,
+                           unsigned position,
+                           const struct tgsi_full_instruction *insn )
+{
+   unsigned i;
+
+   /* Note that we've finished the main function and are now emitting
+    * subroutines.  This affects how we terminate the generated
+    * shader.
+    */
+   emit->in_main_func = FALSE;
+   
+   for (i = 0; i < emit->nr_labels; i++) {
+      if (emit->label[i] == position) {
+         return (emit_instruction( emit, inst_token( SVGA3DOP_RET ) ) &&
+                 emit_instruction( emit, inst_token( SVGA3DOP_LABEL ) ) &&
+                 emit_src( emit, src_register( SVGA3DREG_LABEL, i )));
+      }
+   }
+
+   assert(0);
+   return TRUE;
+}
+
+static boolean emit_call( struct svga_shader_emitter *emit,
+                           const struct tgsi_full_instruction *insn )
+{
+   unsigned position = insn->Label.Label;
+   unsigned i;
+   
+   for (i = 0; i < emit->nr_labels; i++) {
+      if (emit->label[i] == position) 
+         break;
+   }
+
+   if (emit->nr_labels == Elements(emit->label))
+      return FALSE;
+
+   if (i == emit->nr_labels) {
+      emit->label[i] = position;
+      emit->nr_labels++;
+   }
+
+   return (emit_instruction( emit, inst_token( SVGA3DOP_CALL ) ) &&
+           emit_src( emit, src_register( SVGA3DREG_LABEL, i )));
+}
+
+
+static boolean emit_end( struct svga_shader_emitter *emit )
+{
+   if (emit->unit == PIPE_SHADER_VERTEX) {
+      return emit_vs_postamble( emit );
+   }
+   else {
+      return emit_ps_postamble( emit );
+   }
+}
+
+
+
+static boolean svga_emit_instruction( struct svga_shader_emitter *emit,
+                                      unsigned position,
+                                      const struct tgsi_full_instruction *insn )
+{
+   switch (insn->Instruction.Opcode) {
+
+   case TGSI_OPCODE_ARL:
+      return emit_arl( emit, insn );
+
+   case TGSI_OPCODE_TEX:
+   case TGSI_OPCODE_TXB:
+   case TGSI_OPCODE_TXP:
+   case TGSI_OPCODE_TXL:
+   case TGSI_OPCODE_TXD:
+      return emit_tex( emit, insn );
+
+   case TGSI_OPCODE_BGNSUB:
+      return emit_bgnsub( emit, position, insn );
+
+   case TGSI_OPCODE_ENDSUB:
+      return TRUE;
+
+   case TGSI_OPCODE_CAL:
+      return emit_call( emit, insn );
+
+   case TGSI_OPCODE_FLR:
+   case TGSI_OPCODE_TRUNC:        /* should be TRUNC, not FLR */
+      return emit_floor( emit, insn );
+
+   case TGSI_OPCODE_CMP:
+      return emit_cmp( emit, insn );
+
+   case TGSI_OPCODE_DIV:
+      return emit_div( emit, insn );
+
+   case TGSI_OPCODE_DP2:
+      return emit_dp2( emit, insn );
+
+   case TGSI_OPCODE_DPH:
+      return emit_dph( emit, insn );
+
+   case TGSI_OPCODE_NRM:
+      return emit_nrm( emit, insn );
+
+   case TGSI_OPCODE_COS:
+      return emit_cos( emit, insn );
+
+   case TGSI_OPCODE_SIN:
+      return emit_sin( emit, insn );
+
+   case TGSI_OPCODE_SCS:
+      return emit_sincos( emit, insn );
+
+   case TGSI_OPCODE_END:
+      /* TGSI always finishes the main func with an END */
+      return emit_end( emit );
+
+   case TGSI_OPCODE_KIL:
+      return emit_kil( emit, insn );
+
+      /* Selection opcodes.  The underlying language is fairly
+       * non-orthogonal about these.
+       */
+   case TGSI_OPCODE_SEQ:
+      return emit_select_op( emit, PIPE_FUNC_EQUAL, insn );
+
+   case TGSI_OPCODE_SNE:
+      return emit_select_op( emit, PIPE_FUNC_NOTEQUAL, insn );
+
+   case TGSI_OPCODE_SGT:
+      return emit_select_op( emit, PIPE_FUNC_GREATER, insn );
+
+   case TGSI_OPCODE_SGE:
+      return emit_select_op( emit, PIPE_FUNC_GEQUAL, insn );
+
+   case TGSI_OPCODE_SLT:
+      return emit_select_op( emit, PIPE_FUNC_LESS, insn );
+
+   case TGSI_OPCODE_SLE:
+      return emit_select_op( emit, PIPE_FUNC_LEQUAL, insn );
+
+   case TGSI_OPCODE_SUB:
+      return emit_sub( emit, insn );
+
+   case TGSI_OPCODE_POW:
+      return emit_pow( emit, insn );
+
+   case TGSI_OPCODE_EX2:
+      return emit_ex2( emit, insn );
+
+   case TGSI_OPCODE_EXP:
+      return emit_exp( emit, insn );
+
+   case TGSI_OPCODE_LOG:
+      return emit_log( emit, insn );
+
+   case TGSI_OPCODE_LG2:
+      return emit_scalar_op1( emit, SVGA3DOP_LOG, insn );
+
+   case TGSI_OPCODE_RSQ:
+      return emit_scalar_op1( emit, SVGA3DOP_RSQ, insn );
+
+   case TGSI_OPCODE_RCP:
+      return emit_scalar_op1( emit, SVGA3DOP_RCP, insn );
+
+   case TGSI_OPCODE_CONT:
+   case TGSI_OPCODE_RET:
+      /* This is a noop -- we tell mesa that we can't support RET
+       * within a function (early return), so this will always be
+       * followed by an ENDSUB.
+       */
+      return TRUE;
+
+      /* These aren't actually used by any of the frontends we care
+       * about:
+       */
+   case TGSI_OPCODE_CLAMP:
+   case TGSI_OPCODE_ROUND:
+   case TGSI_OPCODE_AND:
+   case TGSI_OPCODE_OR:
+   case TGSI_OPCODE_I2F:
+   case TGSI_OPCODE_NOT:
+   case TGSI_OPCODE_SHL:
+   case TGSI_OPCODE_ISHR:
+   case TGSI_OPCODE_XOR:
+      return FALSE;
+
+   case TGSI_OPCODE_IF:
+      return emit_if( emit, insn );
+   case TGSI_OPCODE_ELSE:
+      return emit_else( emit, insn );
+   case TGSI_OPCODE_ENDIF:
+      return emit_endif( emit, insn );
+
+   case TGSI_OPCODE_BGNLOOP:
+      return emit_bgnloop2( emit, insn );
+   case TGSI_OPCODE_ENDLOOP:
+      return emit_endloop2( emit, insn );
+   case TGSI_OPCODE_BRK:
+      return emit_brk( emit, insn );
+
+   case TGSI_OPCODE_XPD:
+      return emit_xpd( emit, insn );
+
+   case TGSI_OPCODE_KILP:
+      return emit_kilp( emit, insn );
+
+   case TGSI_OPCODE_DST:
+      return emit_dst_insn( emit, insn );
+
+   case TGSI_OPCODE_LIT:
+      return emit_lit( emit, insn );
+
+   case TGSI_OPCODE_LRP:
+      return emit_lrp( emit, insn );
+
+   default: {
+      unsigned opcode = translate_opcode(insn->Instruction.Opcode);
+
+      if (opcode == SVGA3DOP_LAST_INST)
+         return FALSE;
+
+      if (!emit_simple_instruction( emit, opcode, insn ))
+         return FALSE;
+   }
+   }
+
+   return TRUE;
+}
+
+
+static boolean svga_emit_immediate( struct svga_shader_emitter *emit,
+                                    struct tgsi_full_immediate *imm)
+{
+   static const float id[4] = {0,0,0,1};
+   float value[4];
+   unsigned i;
+
+   assert(1 <= imm->Immediate.NrTokens && imm->Immediate.NrTokens <= 5);
+   for (i = 0; i < imm->Immediate.NrTokens - 1; i++)
+      value[i] = imm->u[i].Float;
+
+   for ( ; i < 4; i++ )
+      value[i] = id[i];
+
+   return emit_def_const( emit, SVGA3D_CONST_TYPE_FLOAT,
+                          emit->imm_start + emit->internal_imm_count++,
+                          value[0], value[1], value[2], value[3]);
+}
+
+static boolean make_immediate( struct svga_shader_emitter *emit,
+                               float a,
+                               float b,
+                               float c,
+                               float d,
+                               struct src_register *out )
+{
+   unsigned idx = emit->nr_hw_const++;
+
+   if (!emit_def_const( emit, SVGA3D_CONST_TYPE_FLOAT,
+                        idx, a, b, c, d ))
+      return FALSE;
+
+   *out = src_register( SVGA3DREG_CONST, idx );
+
+   return TRUE;
+}
+
+static boolean emit_vs_preamble( struct svga_shader_emitter *emit )
+{
+   if (!emit->key.vkey.need_prescale) {
+      if (!make_immediate( emit, 0, 0, .5, .5,
+                           &emit->imm_0055))
+         return FALSE;
+   }
+
+   return TRUE;
+}
+
+static boolean emit_ps_preamble( struct svga_shader_emitter *emit )
+{
+   unsigned i;
+
+   /* For SM20, need to initialize the temporaries we're using to hold
+    * color outputs to some value.  Shaders which don't set all of
+    * these values are likely to be rejected by the DX9 runtime.
+    */
+   if (!emit->use_sm30) {
+      struct src_register zero = get_zero_immediate( emit );
+      for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
+         if (SVGA3dShaderGetRegType(emit->true_col[i].value) != 0) {
+            
+            if (!submit_op1( emit,
+                             inst_token(SVGA3DOP_MOV),
+                             emit->temp_col[i],
+                             zero ))
+               return FALSE;
+         }
+      }
+   }
+   
+   return TRUE;
+}
+
+static boolean emit_ps_postamble( struct svga_shader_emitter *emit )
+{
+   unsigned i;
+
+   /* PS oDepth is incredibly fragile and it's very hard to catch the
+    * types of usage that break it during shader emit.  Easier just to
+    * redirect the main program to a temporary and then only touch
+    * oDepth with a hand-crafted MOV below.
+    */
+   if (SVGA3dShaderGetRegType(emit->true_pos.value) != 0) {
+
+      if (!submit_op1( emit,
+                       inst_token(SVGA3DOP_MOV),
+                       emit->true_pos,
+                       scalar(src(emit->temp_pos), TGSI_SWIZZLE_Z) ))
+         return FALSE;
+   }
+
+   /* Similarly for SM20 color outputs...  Luckily SM30 isn't so
+    * fragile.
+    */
+   for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
+      if (SVGA3dShaderGetRegType(emit->true_col[i].value) != 0) {
+
+         if (!submit_op1( emit,
+                          inst_token(SVGA3DOP_MOV),
+                          emit->true_col[i],
+                          src(emit->temp_col[i]) ))
+            return FALSE;
+      }
+   }
+
+   return TRUE;
+}
+
+static boolean emit_vs_postamble( struct svga_shader_emitter *emit )
+{
+   /* PSIZ output is incredibly fragile and it's very hard to catch
+    * the types of usage that break it during shader emit.  Easier
+    * just to redirect the main program to a temporary and then only
+    * touch PSIZ with a hand-crafted MOV below.
+    */
+   if (SVGA3dShaderGetRegType(emit->true_psiz.value) != 0) {
+      
+      if (!submit_op1( emit,
+                       inst_token(SVGA3DOP_MOV),
+                       emit->true_psiz,
+                       scalar(src(emit->temp_psiz), TGSI_SWIZZLE_X) ))
+         return FALSE;
+   }
+
+   /* Need to perform various manipulations on vertex position to cope
+    * with the different GL and D3D clip spaces.
+    */
+   if (emit->key.vkey.need_prescale) {
+      SVGA3dShaderDestToken temp_pos = emit->temp_pos;
+      SVGA3dShaderDestToken pos = emit->true_pos;
+      unsigned offset = emit->info.file_max[TGSI_FILE_CONSTANT] + 1;
+      struct src_register prescale_scale = src_register( SVGA3DREG_CONST, 
+                                                         offset + 0 ); 
+      struct src_register prescale_trans = src_register( SVGA3DREG_CONST, 
+                                                         offset + 1 ); 
+
+      /* MUL temp_pos.xyz,    temp_pos,      prescale.scale
+       * MAD result.position, temp_pos.wwww, prescale.trans, temp_pos
+       *   --> Note that prescale.trans.w == 0
+       */
+      if (!submit_op2( emit, 
+                       inst_token(SVGA3DOP_MUL), 
+                       writemask(temp_pos, TGSI_WRITEMASK_XYZ), 
+                       src(temp_pos),
+                       prescale_scale ))
+         return FALSE;
+
+      if (!submit_op3( emit, 
+                       inst_token(SVGA3DOP_MAD), 
+                       pos, 
+                       swizzle(src(temp_pos), 3, 3, 3, 3),
+                       prescale_trans,
+                       src(temp_pos)))
+         return FALSE;
+   }
+   else {
+      SVGA3dShaderDestToken temp_pos = emit->temp_pos;
+      SVGA3dShaderDestToken pos = emit->true_pos;
+      struct src_register imm_0055 = emit->imm_0055;
+
+      /* Adjust GL clipping coordinate space to hardware (D3D-style):
+       *
+       * DP4 temp_pos.z, {0,0,.5,.5}, temp_pos
+       * MOV result.position, temp_pos 
+       */
+      if (!submit_op2( emit, 
+                       inst_token(SVGA3DOP_DP4), 
+                       writemask(temp_pos, TGSI_WRITEMASK_Z), 
+                       imm_0055, 
+                       src(temp_pos) ))
+         return FALSE;
+
+      if (!submit_op1( emit,
+                       inst_token(SVGA3DOP_MOV),
+                       pos,
+                       src(temp_pos) ))
+         return FALSE;
+   }
+
+   return TRUE;
+}
+
+/*
+  0: IF VFACE :4
+  1:   COLOR = FrontColor;
+  2: ELSE
+  3:   COLOR = BackColor;
+  4: ENDIF
+ */
+static boolean emit_light_twoside( struct svga_shader_emitter *emit )
+{
+   struct src_register vface, zero;
+   struct src_register front[2];
+   struct src_register back[2];
+   SVGA3dShaderDestToken color[2];
+   int count =  emit->internal_color_count;
+   int i;
+   SVGA3dShaderInstToken if_token;
+
+   if (count == 0)
+      return TRUE;
+
+   vface = get_vface( emit );
+   zero = get_zero_immediate( emit );
+
+   /* Can't use get_temp() to allocate the color reg as such
+    * temporaries will be reclaimed after each instruction by the call
+    * to reset_temp_regs().
+    */
+   for (i = 0; i < count; i++) {
+      color[i] = dst_register( SVGA3DREG_TEMP, 
+                               emit->nr_hw_temp++ );
+
+      front[i] = emit->input_map[emit->internal_color_idx[i]];
+
+      /* Back is always the next input:
+       */
+      back[i] = front[i];
+      back[i].base.num = front[i].base.num + 1;
+
+      /* Reassign the input_map to the actual front-face color:
+       */
+      emit->input_map[emit->internal_color_idx[i]] = src(color[i]);
+   }
+   
+   if_token = inst_token( SVGA3DOP_IFC );
+
+   if (emit->key.fkey.front_cw)
+      if_token.control = SVGA3DOPCOMP_GT;
+   else
+      if_token.control = SVGA3DOPCOMP_LT;
+
+   zero = scalar(zero, TGSI_SWIZZLE_X);
+
+   if (!(emit_instruction( emit, if_token ) &&
+         emit_src( emit, vface ) &&
+         emit_src( emit, zero ) ))
+      return FALSE;
+
+   for (i = 0; i < count; i++) {
+      if (!submit_op1( emit, inst_token( SVGA3DOP_MOV ), color[i], front[i] ))
+         return FALSE;
+   }
+
+   if (!(emit_instruction( emit, inst_token( SVGA3DOP_ELSE))))
+      return FALSE;
+   
+   for (i = 0; i < count; i++) {
+      if (!submit_op1( emit, inst_token( SVGA3DOP_MOV ), color[i], back[i] ))
+         return FALSE;
+   }
+
+   if (!emit_instruction( emit, inst_token( SVGA3DOP_ENDIF ) ))
+      return FALSE;
+
+   return TRUE;
+}
+
+/*
+  0: SETP_GT TEMP, VFACE, 0
+  where TEMP is a fake frontface register
+ */
+static boolean emit_frontface( struct svga_shader_emitter *emit )
+{
+   struct src_register vface, zero;
+   SVGA3dShaderDestToken temp;
+   struct src_register pass, fail;
+
+   vface = get_vface( emit );
+   zero = get_zero_immediate( emit );
+
+   /* Can't use get_temp() to allocate the fake frontface reg as such
+    * temporaries will be reclaimed after each instruction by the call
+    * to reset_temp_regs().
+    */
+   temp = dst_register( SVGA3DREG_TEMP,
+                        emit->nr_hw_temp++ );
+
+   if (emit->key.fkey.front_cw) {
+      pass = scalar( zero, TGSI_SWIZZLE_W );
+      fail = scalar( zero, TGSI_SWIZZLE_X );
+   } else {
+      pass = scalar( zero, TGSI_SWIZZLE_X );
+      fail = scalar( zero, TGSI_SWIZZLE_W );
+   }
+
+   if (!emit_conditional(emit, PIPE_FUNC_GREATER,
+                         temp, vface, scalar( zero, TGSI_SWIZZLE_X ),
+                         pass, fail))
+      return FALSE;
+
+   /* Reassign the input_map to the actual front-face color:
+    */
+   emit->input_map[emit->internal_frontface_idx] = src(temp);
+
+   return TRUE;
+}
+
+static INLINE boolean
+needs_to_create_zero( struct svga_shader_emitter *emit )
+{
+   int i;
+
+   if (emit->unit == PIPE_SHADER_FRAGMENT) {
+      if (!emit->use_sm30)
+         return TRUE;
+
+      if (emit->key.fkey.light_twoside)
+         return TRUE;
+
+      if (emit->emit_frontface)
+         return TRUE;
+
+      if (emit->info.opcode_count[TGSI_OPCODE_DST] >= 1 ||
+          emit->info.opcode_count[TGSI_OPCODE_LIT] >= 1)
+         return TRUE;
+   }
+
+   if (emit->info.opcode_count[TGSI_OPCODE_IF] >= 1 ||
+       emit->info.opcode_count[TGSI_OPCODE_SGE] >= 1 ||
+       emit->info.opcode_count[TGSI_OPCODE_SGT] >= 1 ||
+       emit->info.opcode_count[TGSI_OPCODE_SLE] >= 1 ||
+       emit->info.opcode_count[TGSI_OPCODE_SLT] >= 1 ||
+       emit->info.opcode_count[TGSI_OPCODE_SNE] >= 1 ||
+       emit->info.opcode_count[TGSI_OPCODE_SEQ] >= 1 ||
+       emit->info.opcode_count[TGSI_OPCODE_EXP] >= 1 ||
+       emit->info.opcode_count[TGSI_OPCODE_LOG] >= 1 ||
+       emit->info.opcode_count[TGSI_OPCODE_XPD] >= 1 ||
+       emit->info.opcode_count[TGSI_OPCODE_KILP] >= 1)
+      return TRUE;
+
+   for (i = 0; i < emit->key.fkey.num_textures; i++) {
+      if (emit->key.fkey.tex[i].compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE)
+         return TRUE;
+   }
+
+   return FALSE;
+}
+
+static INLINE boolean
+needs_to_create_loop_const( struct svga_shader_emitter *emit )
+{
+   return (emit->info.opcode_count[TGSI_OPCODE_BGNLOOP] >= 1);
+}
+
+static INLINE boolean
+needs_to_create_sincos_consts( struct svga_shader_emitter *emit )
+{
+   return !emit->use_sm30 && (emit->info.opcode_count[TGSI_OPCODE_SIN] >= 1 ||
+                              emit->info.opcode_count[TGSI_OPCODE_COS] >= 1 ||
+                              emit->info.opcode_count[TGSI_OPCODE_SCS] >= 1);
+}
+
+static INLINE boolean
+needs_to_create_arl_consts( struct svga_shader_emitter *emit )
+{
+   return (emit->num_arl_consts > 0);
+}
+
+static INLINE boolean
+pre_parse_add_indirect( struct svga_shader_emitter *emit,
+                        int num, int current_arl)
+{
+   int i;
+   assert(num < 0);
+
+   for (i = 0; i < emit->num_arl_consts; ++i) {
+      if (emit->arl_consts[i].arl_num == current_arl)
+         break;
+   }
+   /* new entry */
+   if (emit->num_arl_consts == i) {
+      ++emit->num_arl_consts;
+   }
+   emit->arl_consts[i].number = (emit->arl_consts[i].number > num) ?
+                                num :
+                                emit->arl_consts[i].number;
+   emit->arl_consts[i].arl_num = current_arl;
+   return TRUE;
+}
+
+static boolean
+pre_parse_instruction( struct svga_shader_emitter *emit,
+                       const struct tgsi_full_instruction *insn,
+                       int current_arl)
+{
+   if (insn->Src[0].Register.Indirect &&
+       insn->Src[0].Indirect.File == TGSI_FILE_ADDRESS) {
+      const struct tgsi_full_src_register *reg = &insn->Src[0];
+      if (reg->Register.Index < 0) {
+         pre_parse_add_indirect(emit, reg->Register.Index, current_arl);
+      }
+   }
+
+   if (insn->Src[1].Register.Indirect &&
+       insn->Src[1].Indirect.File == TGSI_FILE_ADDRESS) {
+      const struct tgsi_full_src_register *reg = &insn->Src[1];
+      if (reg->Register.Index < 0) {
+         pre_parse_add_indirect(emit, reg->Register.Index, current_arl);
+      }
+   }
+
+   if (insn->Src[2].Register.Indirect &&
+       insn->Src[2].Indirect.File == TGSI_FILE_ADDRESS) {
+      const struct tgsi_full_src_register *reg = &insn->Src[2];
+      if (reg->Register.Index < 0) {
+         pre_parse_add_indirect(emit, reg->Register.Index, current_arl);
+      }
+   }
+
+   return TRUE;
+}
+
+static boolean
+pre_parse_tokens( struct svga_shader_emitter *emit,
+                  const struct tgsi_token *tokens )
+{
+   struct tgsi_parse_context parse;
+   int current_arl = 0;
+
+   tgsi_parse_init( &parse, tokens );
+
+   while (!tgsi_parse_end_of_tokens( &parse )) {
+      tgsi_parse_token( &parse );
+      switch (parse.FullToken.Token.Type) {
+      case TGSI_TOKEN_TYPE_IMMEDIATE:
+      case TGSI_TOKEN_TYPE_DECLARATION:
+         break;
+      case TGSI_TOKEN_TYPE_INSTRUCTION:
+         if (parse.FullToken.FullInstruction.Instruction.Opcode ==
+             TGSI_OPCODE_ARL) {
+            ++current_arl;
+         }
+         if (!pre_parse_instruction( emit, &parse.FullToken.FullInstruction,
+                                     current_arl ))
+            return FALSE;
+         break;
+      default:
+         break;
+      }
+
+   }
+   return TRUE;
+}
+
+static boolean svga_shader_emit_helpers( struct svga_shader_emitter *emit )
+
+{
+   if (needs_to_create_zero( emit )) {
+      create_zero_immediate( emit );
+   }
+   if (needs_to_create_loop_const( emit )) {
+      create_loop_const( emit );
+   }
+   if (needs_to_create_sincos_consts( emit )) {
+      create_sincos_consts( emit );
+   }
+   if (needs_to_create_arl_consts( emit )) {
+      create_arl_consts( emit );
+   }
+
+   if (emit->unit == PIPE_SHADER_FRAGMENT) {
+      if (!emit_ps_preamble( emit ))
+         return FALSE;
+
+      if (emit->key.fkey.light_twoside) {
+         if (!emit_light_twoside( emit ))
+            return FALSE;
+      }
+      if (emit->emit_frontface) {
+         if (!emit_frontface( emit ))
+            return FALSE;
+      }
+   }
+
+   return TRUE;
+}
+
+boolean svga_shader_emit_instructions( struct svga_shader_emitter *emit,
+                                       const struct tgsi_token *tokens )
+{
+   struct tgsi_parse_context parse;
+   boolean ret = TRUE;
+   boolean helpers_emitted = FALSE;
+   unsigned line_nr = 0;
+
+   tgsi_parse_init( &parse, tokens );
+   emit->internal_imm_count = 0;
+
+   if (emit->unit == PIPE_SHADER_VERTEX) {
+      ret = emit_vs_preamble( emit );
+      if (!ret)
+         goto done;
+   }
+
+   pre_parse_tokens(emit, tokens);
+
+   while (!tgsi_parse_end_of_tokens( &parse )) {
+      tgsi_parse_token( &parse );
+
+      switch (parse.FullToken.Token.Type) {
+      case TGSI_TOKEN_TYPE_IMMEDIATE:
+         ret = svga_emit_immediate( emit, &parse.FullToken.FullImmediate );
+         if (!ret)
+            goto done;
+         break;
+
+      case TGSI_TOKEN_TYPE_DECLARATION:
+         if (emit->use_sm30)
+            ret = svga_translate_decl_sm30( emit, &parse.FullToken.FullDeclaration );
+         else
+            ret = svga_translate_decl_sm20( emit, &parse.FullToken.FullDeclaration );
+         if (!ret)
+            goto done;
+         break;
+         
+      case TGSI_TOKEN_TYPE_INSTRUCTION:
+         if (!helpers_emitted) {
+            if (!svga_shader_emit_helpers( emit ))
+               goto done;
+            helpers_emitted = TRUE;
+         }
+         ret = svga_emit_instruction( emit, 
+                                      line_nr++,
+                                      &parse.FullToken.FullInstruction );
+         if (!ret)
+            goto done;
+         break;
+      default:
+         break;
+      }
+      
+      reset_temp_regs( emit );
+   }
+
+   /* Need to terminate the current subroutine.  Note that the
+    * hardware doesn't tolerate shaders without sub-routines
+    * terminating with RET+END.
+    */
+   if (!emit->in_main_func) {
+      ret = emit_instruction( emit, inst_token( SVGA3DOP_RET ) );
+      if (!ret)
+         goto done;
+   }
+
+   /* Need to terminate the whole shader:
+    */
+   ret = emit_instruction( emit, inst_token( SVGA3DOP_END ) );
+   if (!ret)
+      goto done;
+
+done:
+   assert(ret);
+   tgsi_parse_free( &parse );
+   return ret;
+}
+
diff --git a/src/gallium/drivers/svga/svga_winsys.h b/src/gallium/drivers/svga/svga_winsys.h
new file mode 100644 (file)
index 0000000..59f299c
--- /dev/null
@@ -0,0 +1,299 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+/**
+ * @file
+ * VMware SVGA specific winsys interface.
+ * 
+ * @author Jose Fonseca <jfonseca@vmware.com>
+ * 
+ * Documentation taken from the VMware SVGA DDK.
+ */
+
+#ifndef SVGA_WINSYS_H_
+#define SVGA_WINSYS_H_
+
+
+#include "svga_types.h"
+#include "svga_reg.h"
+#include "svga3d_reg.h"
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_defines.h"
+
+
+struct svga_winsys_screen;
+struct svga_winsys_buffer;
+struct pipe_screen;
+struct pipe_context;
+struct pipe_fence_handle;
+struct pipe_texture;
+struct svga_region;
+
+
+#define SVGA_BUFFER_USAGE_PINNED  (PIPE_BUFFER_USAGE_CUSTOM << 0)
+#define SVGA_BUFFER_USAGE_WRAPPED (PIPE_BUFFER_USAGE_CUSTOM << 1)
+
+
+/** Opaque surface handle */
+struct svga_winsys_surface;
+
+/** Opaque buffer handle */
+struct svga_winsys_handle;
+
+
+/**
+ * SVGA per-context winsys interface.
+ */
+struct svga_winsys_context
+{
+   void
+   (*destroy)(struct svga_winsys_context *swc);
+
+   void *       
+   (*reserve)(struct svga_winsys_context *swc, 
+             uint32_t nr_bytes, uint32_t nr_relocs );
+   
+   /**
+    * Emit a relocation for a host surface.
+    * 
+    * @param flags PIPE_BUFFER_USAGE_GPU_READ/WRITE
+    * 
+    * NOTE: Order of this call does matter. It should be the same order
+    * as relocations appear in the command buffer.
+    */
+   void
+   (*surface_relocation)(struct svga_winsys_context *swc, 
+                        uint32 *sid, 
+                        struct svga_winsys_surface *surface,
+                        unsigned flags);
+   
+   /**
+    * Emit a relocation for a guest memory region.
+    * 
+    * @param flags PIPE_BUFFER_USAGE_GPU_READ/WRITE
+    * 
+    * NOTE: Order of this call does matter. It should be the same order
+    * as relocations appear in the command buffer.
+    */
+   void
+   (*region_relocation)(struct svga_winsys_context *swc, 
+                       struct SVGAGuestPtr *ptr, 
+                       struct svga_winsys_buffer *buffer,
+                       uint32 offset,
+                        unsigned flags);
+
+   void
+   (*commit)(struct svga_winsys_context *swc);
+   
+   enum pipe_error
+   (*flush)(struct svga_winsys_context *swc, 
+           struct pipe_fence_handle **pfence);
+
+   /** 
+    * Context ID used to fill in the commands
+    * 
+    * Context IDs are arbitrary small non-negative integers,
+    * global to the entire SVGA device.
+    */
+   uint32 cid;
+};
+
+
+/**
+ * SVGA per-screen winsys interface.
+ */
+struct svga_winsys_screen
+{
+   void
+   (*destroy)(struct svga_winsys_screen *sws);
+   
+   boolean
+   (*get_cap)(struct svga_winsys_screen *sws,
+              SVGA3dDevCapIndex index,
+              SVGA3dDevCapResult *result);
+   
+   /**
+    * Create a new context.
+    *
+    * Context objects encapsulate all render state, and shader
+    * objects are per-context.
+    *
+    * Surfaces are not per-context. The same surface can be shared
+    * between multiple contexts, and surface operations can occur
+    * without a context.
+    */
+   struct svga_winsys_context *
+   (*context_create)(struct svga_winsys_screen *sws);
+   
+   
+   /**
+    * This creates a "surface" object in the SVGA3D device,
+    * and returns the surface ID (sid). Surfaces are generic
+    * containers for host VRAM objects like textures, vertex
+    * buffers, and depth/stencil buffers.
+    *
+    * Surfaces are hierarchial:
+    *
+    * - Surface may have multiple faces (for cube maps)
+    *
+    * - Each face has a list of mipmap levels
+    *
+    * - Each mipmap image may have multiple volume
+    *   slices, if the image is three dimensional.
+    *
+    * - Each slice is a 2D array of 'blocks'
+    *
+    * - Each block may be one or more pixels.
+    *   (Usually 1, more for DXT or YUV formats.)
+    *
+    * Surfaces are generic host VRAM objects. The SVGA3D device
+    * may optimize surfaces according to the format they were
+    * created with, but this format does not limit the ways in
+    * which the surface may be used. For example, a depth surface
+    * can be used as a texture, or a floating point image may
+    * be used as a vertex buffer. Some surface usages may be
+    * lower performance, due to software emulation, but any
+    * usage should work with any surface.
+    */
+   struct svga_winsys_surface *
+   (*surface_create)(struct svga_winsys_screen *sws,
+                     SVGA3dSurfaceFlags flags,
+                     SVGA3dSurfaceFormat format,
+                     SVGA3dSize size,
+                     uint32 numFaces,
+                     uint32 numMipLevels);
+
+   /**
+    * Whether this surface is sitting in a validate list
+    */
+   boolean
+   (*surface_is_flushed)(struct svga_winsys_screen *sws,
+                         struct svga_winsys_surface *surface);
+
+   /**
+    * Reference a SVGA3D surface object. This allows sharing of a
+    * surface between different objects.
+    */
+   void 
+   (*surface_reference)(struct svga_winsys_screen *sws,
+                       struct svga_winsys_surface **pdst,
+                       struct svga_winsys_surface *src);
+
+   /**
+    * Buffer management. Buffer attributes are mostly fixed over its lifetime.
+    *
+    * Remember that gallium gets to choose the interface it needs, and the
+    * window systems must then implement that interface (rather than the
+    * other way around...).
+    *
+    * usage is a bitmask of PIPE_BUFFER_USAGE_PIXEL/VERTEX/INDEX/CONSTANT. This
+    * usage argument is only an optimization hint, not a guarantee, therefore 
+    * proper behavior must be observed in all circumstances.
+    *
+    * alignment indicates the client's alignment requirements, eg for
+    * SSE instructions.
+    */
+   struct svga_winsys_buffer *
+   (*buffer_create)( struct svga_winsys_screen *sws, 
+                    unsigned alignment, 
+                    unsigned usage,
+                    unsigned size );
+
+   /** 
+    * Map the entire data store of a buffer object into the client's address.
+    * flags is a bitmask of:
+    * - PIPE_BUFFER_USAGE_CPU_READ/WRITE
+    * - PIPE_BUFFER_USAGE_DONTBLOCK
+    * - PIPE_BUFFER_USAGE_UNSYNCHRONIZED
+    */
+   void *
+   (*buffer_map)( struct svga_winsys_screen *sws, 
+                 struct svga_winsys_buffer *buf,
+                 unsigned usage );
+   
+   void 
+   (*buffer_unmap)( struct svga_winsys_screen *sws, 
+                    struct svga_winsys_buffer *buf );
+
+   void 
+   (*buffer_destroy)( struct svga_winsys_screen *sws,
+                     struct svga_winsys_buffer *buf );
+
+
+   /**
+    * Reference a fence object.
+    */
+   void
+   (*fence_reference)( struct svga_winsys_screen *sws,
+                       struct pipe_fence_handle **pdst,
+                       struct pipe_fence_handle *src );
+
+   /**
+    * Checks whether the fence has been signalled.
+    * \param flags  driver-specific meaning
+    * \return zero on success.
+    */
+   int (*fence_signalled)( struct svga_winsys_screen *sws,
+                           struct pipe_fence_handle *fence,
+                           unsigned flag );
+
+   /**
+    * Wait for the fence to finish.
+    * \param flags  driver-specific meaning
+    * \return zero on success.
+    */
+   int (*fence_finish)( struct svga_winsys_screen *sws,
+                        struct pipe_fence_handle *fence,
+                        unsigned flag );
+
+};
+
+
+struct pipe_context *
+svga_context_create(struct pipe_screen *screen);
+
+struct pipe_screen *
+svga_screen_create(struct svga_winsys_screen *sws);
+
+struct svga_winsys_screen *
+svga_winsys_screen(struct pipe_screen *screen);
+
+struct pipe_buffer *
+svga_screen_buffer_wrap_surface(struct pipe_screen *screen,
+                               enum SVGA3dSurfaceFormat format,
+                               struct svga_winsys_surface *srf);
+
+struct svga_winsys_surface *
+svga_screen_texture_get_winsys_surface(struct pipe_texture *texture);
+struct svga_winsys_surface *
+svga_screen_buffer_get_winsys_surface(struct pipe_buffer *buffer);
+
+boolean
+svga_screen_buffer_from_texture(struct pipe_texture *texture,
+                               struct pipe_buffer **buffer,
+                               unsigned *stride);
+
+#endif /* SVGA_WINSYS_H_ */
diff --git a/src/gallium/drivers/svga/svgadump/svga_dump.c b/src/gallium/drivers/svga/svgadump/svga_dump.c
new file mode 100644 (file)
index 0000000..d59fb89
--- /dev/null
@@ -0,0 +1,1784 @@
+/**********************************************************
+ * 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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+/**
+ * @file
+ * Dump SVGA commands.
+ *
+ * Generated automatically from svga3d_reg.h by svga_dump.py.
+ */
+
+#include "svga_types.h"
+#include "svga_shader_dump.h"
+#include "svga3d_reg.h"
+
+#include "util/u_debug.h"
+#include "svga_dump.h"
+
+static void
+dump_SVGA3dVertexDecl(const SVGA3dVertexDecl *cmd)
+{
+   switch((*cmd).identity.type) {
+   case SVGA3D_DECLTYPE_FLOAT1:
+      _debug_printf("\t\t.identity.type = SVGA3D_DECLTYPE_FLOAT1\n");
+      break;
+   case SVGA3D_DECLTYPE_FLOAT2:
+      _debug_printf("\t\t.identity.type = SVGA3D_DECLTYPE_FLOAT2\n");
+      break;
+   case SVGA3D_DECLTYPE_FLOAT3:
+      _debug_printf("\t\t.identity.type = SVGA3D_DECLTYPE_FLOAT3\n");
+      break;
+   case SVGA3D_DECLTYPE_FLOAT4:
+      _debug_printf("\t\t.identity.type = SVGA3D_DECLTYPE_FLOAT4\n");
+      break;
+   case SVGA3D_DECLTYPE_D3DCOLOR:
+      _debug_printf("\t\t.identity.type = SVGA3D_DECLTYPE_D3DCOLOR\n");
+      break;
+   case SVGA3D_DECLTYPE_UBYTE4:
+      _debug_printf("\t\t.identity.type = SVGA3D_DECLTYPE_UBYTE4\n");
+      break;
+   case SVGA3D_DECLTYPE_SHORT2:
+      _debug_printf("\t\t.identity.type = SVGA3D_DECLTYPE_SHORT2\n");
+      break;
+   case SVGA3D_DECLTYPE_SHORT4:
+      _debug_printf("\t\t.identity.type = SVGA3D_DECLTYPE_SHORT4\n");
+      break;
+   case SVGA3D_DECLTYPE_UBYTE4N:
+      _debug_printf("\t\t.identity.type = SVGA3D_DECLTYPE_UBYTE4N\n");
+      break;
+   case SVGA3D_DECLTYPE_SHORT2N:
+      _debug_printf("\t\t.identity.type = SVGA3D_DECLTYPE_SHORT2N\n");
+      break;
+   case SVGA3D_DECLTYPE_SHORT4N:
+      _debug_printf("\t\t.identity.type = SVGA3D_DECLTYPE_SHORT4N\n");
+      break;
+   case SVGA3D_DECLTYPE_USHORT2N:
+      _debug_printf("\t\t.identity.type = SVGA3D_DECLTYPE_USHORT2N\n");
+      break;
+   case SVGA3D_DECLTYPE_USHORT4N:
+      _debug_printf("\t\t.identity.type = SVGA3D_DECLTYPE_USHORT4N\n");
+      break;
+   case SVGA3D_DECLTYPE_UDEC3:
+      _debug_printf("\t\t.identity.type = SVGA3D_DECLTYPE_UDEC3\n");
+      break;
+   case SVGA3D_DECLTYPE_DEC3N:
+      _debug_printf("\t\t.identity.type = SVGA3D_DECLTYPE_DEC3N\n");
+      break;
+   case SVGA3D_DECLTYPE_FLOAT16_2:
+      _debug_printf("\t\t.identity.type = SVGA3D_DECLTYPE_FLOAT16_2\n");
+      break;
+   case SVGA3D_DECLTYPE_FLOAT16_4:
+      _debug_printf("\t\t.identity.type = SVGA3D_DECLTYPE_FLOAT16_4\n");
+      break;
+   case SVGA3D_DECLTYPE_MAX:
+      _debug_printf("\t\t.identity.type = SVGA3D_DECLTYPE_MAX\n");
+      break;
+   default:
+      _debug_printf("\t\t.identity.type = %i\n", (*cmd).identity.type);
+      break;
+   }
+   switch((*cmd).identity.method) {
+   case SVGA3D_DECLMETHOD_DEFAULT:
+      _debug_printf("\t\t.identity.method = SVGA3D_DECLMETHOD_DEFAULT\n");
+      break;
+   case SVGA3D_DECLMETHOD_PARTIALU:
+      _debug_printf("\t\t.identity.method = SVGA3D_DECLMETHOD_PARTIALU\n");
+      break;
+   case SVGA3D_DECLMETHOD_PARTIALV:
+      _debug_printf("\t\t.identity.method = SVGA3D_DECLMETHOD_PARTIALV\n");
+      break;
+   case SVGA3D_DECLMETHOD_CROSSUV:
+      _debug_printf("\t\t.identity.method = SVGA3D_DECLMETHOD_CROSSUV\n");
+      break;
+   case SVGA3D_DECLMETHOD_UV:
+      _debug_printf("\t\t.identity.method = SVGA3D_DECLMETHOD_UV\n");
+      break;
+   case SVGA3D_DECLMETHOD_LOOKUP:
+      _debug_printf("\t\t.identity.method = SVGA3D_DECLMETHOD_LOOKUP\n");
+      break;
+   case SVGA3D_DECLMETHOD_LOOKUPPRESAMPLED:
+      _debug_printf("\t\t.identity.method = SVGA3D_DECLMETHOD_LOOKUPPRESAMPLED\n");
+      break;
+   default:
+      _debug_printf("\t\t.identity.method = %i\n", (*cmd).identity.method);
+      break;
+   }
+   switch((*cmd).identity.usage) {
+   case SVGA3D_DECLUSAGE_POSITION:
+      _debug_printf("\t\t.identity.usage = SVGA3D_DECLUSAGE_POSITION\n");
+      break;
+   case SVGA3D_DECLUSAGE_BLENDWEIGHT:
+      _debug_printf("\t\t.identity.usage = SVGA3D_DECLUSAGE_BLENDWEIGHT\n");
+      break;
+   case SVGA3D_DECLUSAGE_BLENDINDICES:
+      _debug_printf("\t\t.identity.usage = SVGA3D_DECLUSAGE_BLENDINDICES\n");
+      break;
+   case SVGA3D_DECLUSAGE_NORMAL:
+      _debug_printf("\t\t.identity.usage = SVGA3D_DECLUSAGE_NORMAL\n");
+      break;
+   case SVGA3D_DECLUSAGE_PSIZE:
+      _debug_printf("\t\t.identity.usage = SVGA3D_DECLUSAGE_PSIZE\n");
+      break;
+   case SVGA3D_DECLUSAGE_TEXCOORD:
+      _debug_printf("\t\t.identity.usage = SVGA3D_DECLUSAGE_TEXCOORD\n");
+      break;
+   case SVGA3D_DECLUSAGE_TANGENT:
+      _debug_printf("\t\t.identity.usage = SVGA3D_DECLUSAGE_TANGENT\n");
+      break;
+   case SVGA3D_DECLUSAGE_BINORMAL:
+      _debug_printf("\t\t.identity.usage = SVGA3D_DECLUSAGE_BINORMAL\n");
+      break;
+   case SVGA3D_DECLUSAGE_TESSFACTOR:
+      _debug_printf("\t\t.identity.usage = SVGA3D_DECLUSAGE_TESSFACTOR\n");
+      break;
+   case SVGA3D_DECLUSAGE_POSITIONT:
+      _debug_printf("\t\t.identity.usage = SVGA3D_DECLUSAGE_POSITIONT\n");
+      break;
+   case SVGA3D_DECLUSAGE_COLOR:
+      _debug_printf("\t\t.identity.usage = SVGA3D_DECLUSAGE_COLOR\n");
+      break;
+   case SVGA3D_DECLUSAGE_FOG:
+      _debug_printf("\t\t.identity.usage = SVGA3D_DECLUSAGE_FOG\n");
+      break;
+   case SVGA3D_DECLUSAGE_DEPTH:
+      _debug_printf("\t\t.identity.usage = SVGA3D_DECLUSAGE_DEPTH\n");
+      break;
+   case SVGA3D_DECLUSAGE_SAMPLE:
+      _debug_printf("\t\t.identity.usage = SVGA3D_DECLUSAGE_SAMPLE\n");
+      break;
+   case SVGA3D_DECLUSAGE_MAX:
+      _debug_printf("\t\t.identity.usage = SVGA3D_DECLUSAGE_MAX\n");
+      break;
+   default:
+      _debug_printf("\t\t.identity.usage = %i\n", (*cmd).identity.usage);
+      break;
+   }
+   _debug_printf("\t\t.identity.usageIndex = %u\n", (*cmd).identity.usageIndex);
+   _debug_printf("\t\t.array.surfaceId = %u\n", (*cmd).array.surfaceId);
+   _debug_printf("\t\t.array.offset = %u\n", (*cmd).array.offset);
+   _debug_printf("\t\t.array.stride = %u\n", (*cmd).array.stride);
+   _debug_printf("\t\t.rangeHint.first = %u\n", (*cmd).rangeHint.first);
+   _debug_printf("\t\t.rangeHint.last = %u\n", (*cmd).rangeHint.last);
+}
+
+static void
+dump_SVGA3dTextureState(const SVGA3dTextureState *cmd)
+{
+   _debug_printf("\t\t.stage = %u\n", (*cmd).stage);
+   switch((*cmd).name) {
+   case SVGA3D_TS_INVALID:
+      _debug_printf("\t\t.name = SVGA3D_TS_INVALID\n");
+      break;
+   case SVGA3D_TS_BIND_TEXTURE:
+      _debug_printf("\t\t.name = SVGA3D_TS_BIND_TEXTURE\n");
+      break;
+   case SVGA3D_TS_COLOROP:
+      _debug_printf("\t\t.name = SVGA3D_TS_COLOROP\n");
+      break;
+   case SVGA3D_TS_COLORARG1:
+      _debug_printf("\t\t.name = SVGA3D_TS_COLORARG1\n");
+      break;
+   case SVGA3D_TS_COLORARG2:
+      _debug_printf("\t\t.name = SVGA3D_TS_COLORARG2\n");
+      break;
+   case SVGA3D_TS_ALPHAOP:
+      _debug_printf("\t\t.name = SVGA3D_TS_ALPHAOP\n");
+      break;
+   case SVGA3D_TS_ALPHAARG1:
+      _debug_printf("\t\t.name = SVGA3D_TS_ALPHAARG1\n");
+      break;
+   case SVGA3D_TS_ALPHAARG2:
+      _debug_printf("\t\t.name = SVGA3D_TS_ALPHAARG2\n");
+      break;
+   case SVGA3D_TS_ADDRESSU:
+      _debug_printf("\t\t.name = SVGA3D_TS_ADDRESSU\n");
+      break;
+   case SVGA3D_TS_ADDRESSV:
+      _debug_printf("\t\t.name = SVGA3D_TS_ADDRESSV\n");
+      break;
+   case SVGA3D_TS_MIPFILTER:
+      _debug_printf("\t\t.name = SVGA3D_TS_MIPFILTER\n");
+      break;
+   case SVGA3D_TS_MAGFILTER:
+      _debug_printf("\t\t.name = SVGA3D_TS_MAGFILTER\n");
+      break;
+   case SVGA3D_TS_MINFILTER:
+      _debug_printf("\t\t.name = SVGA3D_TS_MINFILTER\n");
+      break;
+   case SVGA3D_TS_BORDERCOLOR:
+      _debug_printf("\t\t.name = SVGA3D_TS_BORDERCOLOR\n");
+      break;
+   case SVGA3D_TS_TEXCOORDINDEX:
+      _debug_printf("\t\t.name = SVGA3D_TS_TEXCOORDINDEX\n");
+      break;
+   case SVGA3D_TS_TEXTURETRANSFORMFLAGS:
+      _debug_printf("\t\t.name = SVGA3D_TS_TEXTURETRANSFORMFLAGS\n");
+      break;
+   case SVGA3D_TS_TEXCOORDGEN:
+      _debug_printf("\t\t.name = SVGA3D_TS_TEXCOORDGEN\n");
+      break;
+   case SVGA3D_TS_BUMPENVMAT00:
+      _debug_printf("\t\t.name = SVGA3D_TS_BUMPENVMAT00\n");
+      break;
+   case SVGA3D_TS_BUMPENVMAT01:
+      _debug_printf("\t\t.name = SVGA3D_TS_BUMPENVMAT01\n");
+      break;
+   case SVGA3D_TS_BUMPENVMAT10:
+      _debug_printf("\t\t.name = SVGA3D_TS_BUMPENVMAT10\n");
+      break;
+   case SVGA3D_TS_BUMPENVMAT11:
+      _debug_printf("\t\t.name = SVGA3D_TS_BUMPENVMAT11\n");
+      break;
+   case SVGA3D_TS_TEXTURE_MIPMAP_LEVEL:
+      _debug_printf("\t\t.name = SVGA3D_TS_TEXTURE_MIPMAP_LEVEL\n");
+      break;
+   case SVGA3D_TS_TEXTURE_LOD_BIAS:
+      _debug_printf("\t\t.name = SVGA3D_TS_TEXTURE_LOD_BIAS\n");
+      break;
+   case SVGA3D_TS_TEXTURE_ANISOTROPIC_LEVEL:
+      _debug_printf("\t\t.name = SVGA3D_TS_TEXTURE_ANISOTROPIC_LEVEL\n");
+      break;
+   case SVGA3D_TS_ADDRESSW:
+      _debug_printf("\t\t.name = SVGA3D_TS_ADDRESSW\n");
+      break;
+   case SVGA3D_TS_GAMMA:
+      _debug_printf("\t\t.name = SVGA3D_TS_GAMMA\n");
+      break;
+   case SVGA3D_TS_BUMPENVLSCALE:
+      _debug_printf("\t\t.name = SVGA3D_TS_BUMPENVLSCALE\n");
+      break;
+   case SVGA3D_TS_BUMPENVLOFFSET:
+      _debug_printf("\t\t.name = SVGA3D_TS_BUMPENVLOFFSET\n");
+      break;
+   case SVGA3D_TS_COLORARG0:
+      _debug_printf("\t\t.name = SVGA3D_TS_COLORARG0\n");
+      break;
+   case SVGA3D_TS_ALPHAARG0:
+      _debug_printf("\t\t.name = SVGA3D_TS_ALPHAARG0\n");
+      break;
+   case SVGA3D_TS_MAX:
+      _debug_printf("\t\t.name = SVGA3D_TS_MAX\n");
+      break;
+   default:
+      _debug_printf("\t\t.name = %i\n", (*cmd).name);
+      break;
+   }
+   _debug_printf("\t\t.value = %u\n", (*cmd).value);
+   _debug_printf("\t\t.floatValue = %f\n", (*cmd).floatValue);
+}
+
+static void
+dump_SVGA3dCopyBox(const SVGA3dCopyBox *cmd)
+{
+   _debug_printf("\t\t.x = %u\n", (*cmd).x);
+   _debug_printf("\t\t.y = %u\n", (*cmd).y);
+   _debug_printf("\t\t.z = %u\n", (*cmd).z);
+   _debug_printf("\t\t.w = %u\n", (*cmd).w);
+   _debug_printf("\t\t.h = %u\n", (*cmd).h);
+   _debug_printf("\t\t.d = %u\n", (*cmd).d);
+   _debug_printf("\t\t.srcx = %u\n", (*cmd).srcx);
+   _debug_printf("\t\t.srcy = %u\n", (*cmd).srcy);
+   _debug_printf("\t\t.srcz = %u\n", (*cmd).srcz);
+}
+
+static void
+dump_SVGA3dCmdSetClipPlane(const SVGA3dCmdSetClipPlane *cmd)
+{
+   _debug_printf("\t\t.cid = %u\n", (*cmd).cid);
+   _debug_printf("\t\t.index = %u\n", (*cmd).index);
+   _debug_printf("\t\t.plane[0] = %f\n", (*cmd).plane[0]);
+   _debug_printf("\t\t.plane[1] = %f\n", (*cmd).plane[1]);
+   _debug_printf("\t\t.plane[2] = %f\n", (*cmd).plane[2]);
+   _debug_printf("\t\t.plane[3] = %f\n", (*cmd).plane[3]);
+}
+
+static void
+dump_SVGA3dCmdWaitForQuery(const SVGA3dCmdWaitForQuery *cmd)
+{
+   _debug_printf("\t\t.cid = %u\n", (*cmd).cid);
+   switch((*cmd).type) {
+   case SVGA3D_QUERYTYPE_OCCLUSION:
+      _debug_printf("\t\t.type = SVGA3D_QUERYTYPE_OCCLUSION\n");
+      break;
+   case SVGA3D_QUERYTYPE_MAX:
+      _debug_printf("\t\t.type = SVGA3D_QUERYTYPE_MAX\n");
+      break;
+   default:
+      _debug_printf("\t\t.type = %i\n", (*cmd).type);
+      break;
+   }
+   _debug_printf("\t\t.guestResult.gmrId = %u\n", (*cmd).guestResult.gmrId);
+   _debug_printf("\t\t.guestResult.offset = %u\n", (*cmd).guestResult.offset);
+}
+
+static void
+dump_SVGA3dCmdSetRenderTarget(const SVGA3dCmdSetRenderTarget *cmd)
+{
+   _debug_printf("\t\t.cid = %u\n", (*cmd).cid);
+   switch((*cmd).type) {
+   case SVGA3D_RT_DEPTH:
+      _debug_printf("\t\t.type = SVGA3D_RT_DEPTH\n");
+      break;
+   case SVGA3D_RT_STENCIL:
+      _debug_printf("\t\t.type = SVGA3D_RT_STENCIL\n");
+      break;
+   default:
+      _debug_printf("\t\t.type = SVGA3D_RT_COLOR%u\n", (*cmd).type - SVGA3D_RT_COLOR0);
+      break;
+   }
+   _debug_printf("\t\t.target.sid = %u\n", (*cmd).target.sid);
+   _debug_printf("\t\t.target.face = %u\n", (*cmd).target.face);
+   _debug_printf("\t\t.target.mipmap = %u\n", (*cmd).target.mipmap);
+}
+
+static void
+dump_SVGA3dCmdSetTextureState(const SVGA3dCmdSetTextureState *cmd)
+{
+   _debug_printf("\t\t.cid = %u\n", (*cmd).cid);
+}
+
+static void
+dump_SVGA3dCmdSurfaceCopy(const SVGA3dCmdSurfaceCopy *cmd)
+{
+   _debug_printf("\t\t.src.sid = %u\n", (*cmd).src.sid);
+   _debug_printf("\t\t.src.face = %u\n", (*cmd).src.face);
+   _debug_printf("\t\t.src.mipmap = %u\n", (*cmd).src.mipmap);
+   _debug_printf("\t\t.dest.sid = %u\n", (*cmd).dest.sid);
+   _debug_printf("\t\t.dest.face = %u\n", (*cmd).dest.face);
+   _debug_printf("\t\t.dest.mipmap = %u\n", (*cmd).dest.mipmap);
+}
+
+static void
+dump_SVGA3dCmdSetMaterial(const SVGA3dCmdSetMaterial *cmd)
+{
+   _debug_printf("\t\t.cid = %u\n", (*cmd).cid);
+   switch((*cmd).face) {
+   case SVGA3D_FACE_INVALID:
+      _debug_printf("\t\t.face = SVGA3D_FACE_INVALID\n");
+      break;
+   case SVGA3D_FACE_NONE:
+      _debug_printf("\t\t.face = SVGA3D_FACE_NONE\n");
+      break;
+   case SVGA3D_FACE_FRONT:
+      _debug_printf("\t\t.face = SVGA3D_FACE_FRONT\n");
+      break;
+   case SVGA3D_FACE_BACK:
+      _debug_printf("\t\t.face = SVGA3D_FACE_BACK\n");
+      break;
+   case SVGA3D_FACE_FRONT_BACK:
+      _debug_printf("\t\t.face = SVGA3D_FACE_FRONT_BACK\n");
+      break;
+   case SVGA3D_FACE_MAX:
+      _debug_printf("\t\t.face = SVGA3D_FACE_MAX\n");
+      break;
+   default:
+      _debug_printf("\t\t.face = %i\n", (*cmd).face);
+      break;
+   }
+   _debug_printf("\t\t.material.diffuse[0] = %f\n", (*cmd).material.diffuse[0]);
+   _debug_printf("\t\t.material.diffuse[1] = %f\n", (*cmd).material.diffuse[1]);
+   _debug_printf("\t\t.material.diffuse[2] = %f\n", (*cmd).material.diffuse[2]);
+   _debug_printf("\t\t.material.diffuse[3] = %f\n", (*cmd).material.diffuse[3]);
+   _debug_printf("\t\t.material.ambient[0] = %f\n", (*cmd).material.ambient[0]);
+   _debug_printf("\t\t.material.ambient[1] = %f\n", (*cmd).material.ambient[1]);
+   _debug_printf("\t\t.material.ambient[2] = %f\n", (*cmd).material.ambient[2]);
+   _debug_printf("\t\t.material.ambient[3] = %f\n", (*cmd).material.ambient[3]);
+   _debug_printf("\t\t.material.specular[0] = %f\n", (*cmd).material.specular[0]);
+   _debug_printf("\t\t.material.specular[1] = %f\n", (*cmd).material.specular[1]);
+   _debug_printf("\t\t.material.specular[2] = %f\n", (*cmd).material.specular[2]);
+   _debug_printf("\t\t.material.specular[3] = %f\n", (*cmd).material.specular[3]);
+   _debug_printf("\t\t.material.emissive[0] = %f\n", (*cmd).material.emissive[0]);
+   _debug_printf("\t\t.material.emissive[1] = %f\n", (*cmd).material.emissive[1]);
+   _debug_printf("\t\t.material.emissive[2] = %f\n", (*cmd).material.emissive[2]);
+   _debug_printf("\t\t.material.emissive[3] = %f\n", (*cmd).material.emissive[3]);
+   _debug_printf("\t\t.material.shininess = %f\n", (*cmd).material.shininess);
+}
+
+static void
+dump_SVGA3dCmdSetLightData(const SVGA3dCmdSetLightData *cmd)
+{
+   _debug_printf("\t\t.cid = %u\n", (*cmd).cid);
+   _debug_printf("\t\t.index = %u\n", (*cmd).index);
+   switch((*cmd).data.type) {
+   case SVGA3D_LIGHTTYPE_INVALID:
+      _debug_printf("\t\t.data.type = SVGA3D_LIGHTTYPE_INVALID\n");
+      break;
+   case SVGA3D_LIGHTTYPE_POINT:
+      _debug_printf("\t\t.data.type = SVGA3D_LIGHTTYPE_POINT\n");
+      break;
+   case SVGA3D_LIGHTTYPE_SPOT1:
+      _debug_printf("\t\t.data.type = SVGA3D_LIGHTTYPE_SPOT1\n");
+      break;
+   case SVGA3D_LIGHTTYPE_SPOT2:
+      _debug_printf("\t\t.data.type = SVGA3D_LIGHTTYPE_SPOT2\n");
+      break;
+   case SVGA3D_LIGHTTYPE_DIRECTIONAL:
+      _debug_printf("\t\t.data.type = SVGA3D_LIGHTTYPE_DIRECTIONAL\n");
+      break;
+   case SVGA3D_LIGHTTYPE_MAX:
+      _debug_printf("\t\t.data.type = SVGA3D_LIGHTTYPE_MAX\n");
+      break;
+   default:
+      _debug_printf("\t\t.data.type = %i\n", (*cmd).data.type);
+      break;
+   }
+   _debug_printf("\t\t.data.inWorldSpace = %u\n", (*cmd).data.inWorldSpace);
+   _debug_printf("\t\t.data.diffuse[0] = %f\n", (*cmd).data.diffuse[0]);
+   _debug_printf("\t\t.data.diffuse[1] = %f\n", (*cmd).data.diffuse[1]);
+   _debug_printf("\t\t.data.diffuse[2] = %f\n", (*cmd).data.diffuse[2]);
+   _debug_printf("\t\t.data.diffuse[3] = %f\n", (*cmd).data.diffuse[3]);
+   _debug_printf("\t\t.data.specular[0] = %f\n", (*cmd).data.specular[0]);
+   _debug_printf("\t\t.data.specular[1] = %f\n", (*cmd).data.specular[1]);
+   _debug_printf("\t\t.data.specular[2] = %f\n", (*cmd).data.specular[2]);
+   _debug_printf("\t\t.data.specular[3] = %f\n", (*cmd).data.specular[3]);
+   _debug_printf("\t\t.data.ambient[0] = %f\n", (*cmd).data.ambient[0]);
+   _debug_printf("\t\t.data.ambient[1] = %f\n", (*cmd).data.ambient[1]);
+   _debug_printf("\t\t.data.ambient[2] = %f\n", (*cmd).data.ambient[2]);
+   _debug_printf("\t\t.data.ambient[3] = %f\n", (*cmd).data.ambient[3]);
+   _debug_printf("\t\t.data.position[0] = %f\n", (*cmd).data.position[0]);
+   _debug_printf("\t\t.data.position[1] = %f\n", (*cmd).data.position[1]);
+   _debug_printf("\t\t.data.position[2] = %f\n", (*cmd).data.position[2]);
+   _debug_printf("\t\t.data.position[3] = %f\n", (*cmd).data.position[3]);
+   _debug_printf("\t\t.data.direction[0] = %f\n", (*cmd).data.direction[0]);
+   _debug_printf("\t\t.data.direction[1] = %f\n", (*cmd).data.direction[1]);
+   _debug_printf("\t\t.data.direction[2] = %f\n", (*cmd).data.direction[2]);
+   _debug_printf("\t\t.data.direction[3] = %f\n", (*cmd).data.direction[3]);
+   _debug_printf("\t\t.data.range = %f\n", (*cmd).data.range);
+   _debug_printf("\t\t.data.falloff = %f\n", (*cmd).data.falloff);
+   _debug_printf("\t\t.data.attenuation0 = %f\n", (*cmd).data.attenuation0);
+   _debug_printf("\t\t.data.attenuation1 = %f\n", (*cmd).data.attenuation1);
+   _debug_printf("\t\t.data.attenuation2 = %f\n", (*cmd).data.attenuation2);
+   _debug_printf("\t\t.data.theta = %f\n", (*cmd).data.theta);
+   _debug_printf("\t\t.data.phi = %f\n", (*cmd).data.phi);
+}
+
+static void
+dump_SVGA3dCmdSetViewport(const SVGA3dCmdSetViewport *cmd)
+{
+   _debug_printf("\t\t.cid = %u\n", (*cmd).cid);
+   _debug_printf("\t\t.rect.x = %u\n", (*cmd).rect.x);
+   _debug_printf("\t\t.rect.y = %u\n", (*cmd).rect.y);
+   _debug_printf("\t\t.rect.w = %u\n", (*cmd).rect.w);
+   _debug_printf("\t\t.rect.h = %u\n", (*cmd).rect.h);
+}
+
+static void
+dump_SVGA3dCmdSetScissorRect(const SVGA3dCmdSetScissorRect *cmd)
+{
+   _debug_printf("\t\t.cid = %u\n", (*cmd).cid);
+   _debug_printf("\t\t.rect.x = %u\n", (*cmd).rect.x);
+   _debug_printf("\t\t.rect.y = %u\n", (*cmd).rect.y);
+   _debug_printf("\t\t.rect.w = %u\n", (*cmd).rect.w);
+   _debug_printf("\t\t.rect.h = %u\n", (*cmd).rect.h);
+}
+
+static void
+dump_SVGA3dCopyRect(const SVGA3dCopyRect *cmd)
+{
+   _debug_printf("\t\t.x = %u\n", (*cmd).x);
+   _debug_printf("\t\t.y = %u\n", (*cmd).y);
+   _debug_printf("\t\t.w = %u\n", (*cmd).w);
+   _debug_printf("\t\t.h = %u\n", (*cmd).h);
+   _debug_printf("\t\t.srcx = %u\n", (*cmd).srcx);
+   _debug_printf("\t\t.srcy = %u\n", (*cmd).srcy);
+}
+
+static void
+dump_SVGA3dCmdSetShader(const SVGA3dCmdSetShader *cmd)
+{
+   _debug_printf("\t\t.cid = %u\n", (*cmd).cid);
+   switch((*cmd).type) {
+   case SVGA3D_SHADERTYPE_COMPILED_DX8:
+      _debug_printf("\t\t.type = SVGA3D_SHADERTYPE_COMPILED_DX8\n");
+      break;
+   case SVGA3D_SHADERTYPE_VS:
+      _debug_printf("\t\t.type = SVGA3D_SHADERTYPE_VS\n");
+      break;
+   case SVGA3D_SHADERTYPE_PS:
+      _debug_printf("\t\t.type = SVGA3D_SHADERTYPE_PS\n");
+      break;
+   case SVGA3D_SHADERTYPE_MAX:
+      _debug_printf("\t\t.type = SVGA3D_SHADERTYPE_MAX\n");
+      break;
+   default:
+      _debug_printf("\t\t.type = %i\n", (*cmd).type);
+      break;
+   }
+   _debug_printf("\t\t.shid = %u\n", (*cmd).shid);
+}
+
+static void
+dump_SVGA3dCmdEndQuery(const SVGA3dCmdEndQuery *cmd)
+{
+   _debug_printf("\t\t.cid = %u\n", (*cmd).cid);
+   switch((*cmd).type) {
+   case SVGA3D_QUERYTYPE_OCCLUSION:
+      _debug_printf("\t\t.type = SVGA3D_QUERYTYPE_OCCLUSION\n");
+      break;
+   case SVGA3D_QUERYTYPE_MAX:
+      _debug_printf("\t\t.type = SVGA3D_QUERYTYPE_MAX\n");
+      break;
+   default:
+      _debug_printf("\t\t.type = %i\n", (*cmd).type);
+      break;
+   }
+   _debug_printf("\t\t.guestResult.gmrId = %u\n", (*cmd).guestResult.gmrId);
+   _debug_printf("\t\t.guestResult.offset = %u\n", (*cmd).guestResult.offset);
+}
+
+static void
+dump_SVGA3dSize(const SVGA3dSize *cmd)
+{
+   _debug_printf("\t\t.width = %u\n", (*cmd).width);
+   _debug_printf("\t\t.height = %u\n", (*cmd).height);
+   _debug_printf("\t\t.depth = %u\n", (*cmd).depth);
+}
+
+static void
+dump_SVGA3dCmdDestroySurface(const SVGA3dCmdDestroySurface *cmd)
+{
+   _debug_printf("\t\t.sid = %u\n", (*cmd).sid);
+}
+
+static void
+dump_SVGA3dCmdDefineContext(const SVGA3dCmdDefineContext *cmd)
+{
+   _debug_printf("\t\t.cid = %u\n", (*cmd).cid);
+}
+
+static void
+dump_SVGA3dRect(const SVGA3dRect *cmd)
+{
+   _debug_printf("\t\t.x = %u\n", (*cmd).x);
+   _debug_printf("\t\t.y = %u\n", (*cmd).y);
+   _debug_printf("\t\t.w = %u\n", (*cmd).w);
+   _debug_printf("\t\t.h = %u\n", (*cmd).h);
+}
+
+static void
+dump_SVGA3dCmdBeginQuery(const SVGA3dCmdBeginQuery *cmd)
+{
+   _debug_printf("\t\t.cid = %u\n", (*cmd).cid);
+   switch((*cmd).type) {
+   case SVGA3D_QUERYTYPE_OCCLUSION:
+      _debug_printf("\t\t.type = SVGA3D_QUERYTYPE_OCCLUSION\n");
+      break;
+   case SVGA3D_QUERYTYPE_MAX:
+      _debug_printf("\t\t.type = SVGA3D_QUERYTYPE_MAX\n");
+      break;
+   default:
+      _debug_printf("\t\t.type = %i\n", (*cmd).type);
+      break;
+   }
+}
+
+static void
+dump_SVGA3dRenderState(const SVGA3dRenderState *cmd)
+{
+   switch((*cmd).state) {
+   case SVGA3D_RS_INVALID:
+      _debug_printf("\t\t.state = SVGA3D_RS_INVALID\n");
+      break;
+   case SVGA3D_RS_ZENABLE:
+      _debug_printf("\t\t.state = SVGA3D_RS_ZENABLE\n");
+      break;
+   case SVGA3D_RS_ZWRITEENABLE:
+      _debug_printf("\t\t.state = SVGA3D_RS_ZWRITEENABLE\n");
+      break;
+   case SVGA3D_RS_ALPHATESTENABLE:
+      _debug_printf("\t\t.state = SVGA3D_RS_ALPHATESTENABLE\n");
+      break;
+   case SVGA3D_RS_DITHERENABLE:
+      _debug_printf("\t\t.state = SVGA3D_RS_DITHERENABLE\n");
+      break;
+   case SVGA3D_RS_BLENDENABLE:
+      _debug_printf("\t\t.state = SVGA3D_RS_BLENDENABLE\n");
+      break;
+   case SVGA3D_RS_FOGENABLE:
+      _debug_printf("\t\t.state = SVGA3D_RS_FOGENABLE\n");
+      break;
+   case SVGA3D_RS_SPECULARENABLE:
+      _debug_printf("\t\t.state = SVGA3D_RS_SPECULARENABLE\n");
+      break;
+   case SVGA3D_RS_STENCILENABLE:
+      _debug_printf("\t\t.state = SVGA3D_RS_STENCILENABLE\n");
+      break;
+   case SVGA3D_RS_LIGHTINGENABLE:
+      _debug_printf("\t\t.state = SVGA3D_RS_LIGHTINGENABLE\n");
+      break;
+   case SVGA3D_RS_NORMALIZENORMALS:
+      _debug_printf("\t\t.state = SVGA3D_RS_NORMALIZENORMALS\n");
+      break;
+   case SVGA3D_RS_POINTSPRITEENABLE:
+      _debug_printf("\t\t.state = SVGA3D_RS_POINTSPRITEENABLE\n");
+      break;
+   case SVGA3D_RS_POINTSCALEENABLE:
+      _debug_printf("\t\t.state = SVGA3D_RS_POINTSCALEENABLE\n");
+      break;
+   case SVGA3D_RS_STENCILREF:
+      _debug_printf("\t\t.state = SVGA3D_RS_STENCILREF\n");
+      break;
+   case SVGA3D_RS_STENCILMASK:
+      _debug_printf("\t\t.state = SVGA3D_RS_STENCILMASK\n");
+      break;
+   case SVGA3D_RS_STENCILWRITEMASK:
+      _debug_printf("\t\t.state = SVGA3D_RS_STENCILWRITEMASK\n");
+      break;
+   case SVGA3D_RS_FOGSTART:
+      _debug_printf("\t\t.state = SVGA3D_RS_FOGSTART\n");
+      break;
+   case SVGA3D_RS_FOGEND:
+      _debug_printf("\t\t.state = SVGA3D_RS_FOGEND\n");
+      break;
+   case SVGA3D_RS_FOGDENSITY:
+      _debug_printf("\t\t.state = SVGA3D_RS_FOGDENSITY\n");
+      break;
+   case SVGA3D_RS_POINTSIZE:
+      _debug_printf("\t\t.state = SVGA3D_RS_POINTSIZE\n");
+      break;
+   case SVGA3D_RS_POINTSIZEMIN:
+      _debug_printf("\t\t.state = SVGA3D_RS_POINTSIZEMIN\n");
+      break;
+   case SVGA3D_RS_POINTSIZEMAX:
+      _debug_printf("\t\t.state = SVGA3D_RS_POINTSIZEMAX\n");
+      break;
+   case SVGA3D_RS_POINTSCALE_A:
+      _debug_printf("\t\t.state = SVGA3D_RS_POINTSCALE_A\n");
+      break;
+   case SVGA3D_RS_POINTSCALE_B:
+      _debug_printf("\t\t.state = SVGA3D_RS_POINTSCALE_B\n");
+      break;
+   case SVGA3D_RS_POINTSCALE_C:
+      _debug_printf("\t\t.state = SVGA3D_RS_POINTSCALE_C\n");
+      break;
+   case SVGA3D_RS_FOGCOLOR:
+      _debug_printf("\t\t.state = SVGA3D_RS_FOGCOLOR\n");
+      break;
+   case SVGA3D_RS_AMBIENT:
+      _debug_printf("\t\t.state = SVGA3D_RS_AMBIENT\n");
+      break;
+   case SVGA3D_RS_CLIPPLANEENABLE:
+      _debug_printf("\t\t.state = SVGA3D_RS_CLIPPLANEENABLE\n");
+      break;
+   case SVGA3D_RS_FOGMODE:
+      _debug_printf("\t\t.state = SVGA3D_RS_FOGMODE\n");
+      break;
+   case SVGA3D_RS_FILLMODE:
+      _debug_printf("\t\t.state = SVGA3D_RS_FILLMODE\n");
+      break;
+   case SVGA3D_RS_SHADEMODE:
+      _debug_printf("\t\t.state = SVGA3D_RS_SHADEMODE\n");
+      break;
+   case SVGA3D_RS_LINEPATTERN:
+      _debug_printf("\t\t.state = SVGA3D_RS_LINEPATTERN\n");
+      break;
+   case SVGA3D_RS_SRCBLEND:
+      _debug_printf("\t\t.state = SVGA3D_RS_SRCBLEND\n");
+      break;
+   case SVGA3D_RS_DSTBLEND:
+      _debug_printf("\t\t.state = SVGA3D_RS_DSTBLEND\n");
+      break;
+   case SVGA3D_RS_BLENDEQUATION:
+      _debug_printf("\t\t.state = SVGA3D_RS_BLENDEQUATION\n");
+      break;
+   case SVGA3D_RS_CULLMODE:
+      _debug_printf("\t\t.state = SVGA3D_RS_CULLMODE\n");
+      break;
+   case SVGA3D_RS_ZFUNC:
+      _debug_printf("\t\t.state = SVGA3D_RS_ZFUNC\n");
+      break;
+   case SVGA3D_RS_ALPHAFUNC:
+      _debug_printf("\t\t.state = SVGA3D_RS_ALPHAFUNC\n");
+      break;
+   case SVGA3D_RS_STENCILFUNC:
+      _debug_printf("\t\t.state = SVGA3D_RS_STENCILFUNC\n");
+      break;
+   case SVGA3D_RS_STENCILFAIL:
+      _debug_printf("\t\t.state = SVGA3D_RS_STENCILFAIL\n");
+      break;
+   case SVGA3D_RS_STENCILZFAIL:
+      _debug_printf("\t\t.state = SVGA3D_RS_STENCILZFAIL\n");
+      break;
+   case SVGA3D_RS_STENCILPASS:
+      _debug_printf("\t\t.state = SVGA3D_RS_STENCILPASS\n");
+      break;
+   case SVGA3D_RS_ALPHAREF:
+      _debug_printf("\t\t.state = SVGA3D_RS_ALPHAREF\n");
+      break;
+   case SVGA3D_RS_FRONTWINDING:
+      _debug_printf("\t\t.state = SVGA3D_RS_FRONTWINDING\n");
+      break;
+   case SVGA3D_RS_COORDINATETYPE:
+      _debug_printf("\t\t.state = SVGA3D_RS_COORDINATETYPE\n");
+      break;
+   case SVGA3D_RS_ZBIAS:
+      _debug_printf("\t\t.state = SVGA3D_RS_ZBIAS\n");
+      break;
+   case SVGA3D_RS_RANGEFOGENABLE:
+      _debug_printf("\t\t.state = SVGA3D_RS_RANGEFOGENABLE\n");
+      break;
+   case SVGA3D_RS_COLORWRITEENABLE:
+      _debug_printf("\t\t.state = SVGA3D_RS_COLORWRITEENABLE\n");
+      break;
+   case SVGA3D_RS_VERTEXMATERIALENABLE:
+      _debug_printf("\t\t.state = SVGA3D_RS_VERTEXMATERIALENABLE\n");
+      break;
+   case SVGA3D_RS_DIFFUSEMATERIALSOURCE:
+      _debug_printf("\t\t.state = SVGA3D_RS_DIFFUSEMATERIALSOURCE\n");
+      break;
+   case SVGA3D_RS_SPECULARMATERIALSOURCE:
+      _debug_printf("\t\t.state = SVGA3D_RS_SPECULARMATERIALSOURCE\n");
+      break;
+   case SVGA3D_RS_AMBIENTMATERIALSOURCE:
+      _debug_printf("\t\t.state = SVGA3D_RS_AMBIENTMATERIALSOURCE\n");
+      break;
+   case SVGA3D_RS_EMISSIVEMATERIALSOURCE:
+      _debug_printf("\t\t.state = SVGA3D_RS_EMISSIVEMATERIALSOURCE\n");
+      break;
+   case SVGA3D_RS_TEXTUREFACTOR:
+      _debug_printf("\t\t.state = SVGA3D_RS_TEXTUREFACTOR\n");
+      break;
+   case SVGA3D_RS_LOCALVIEWER:
+      _debug_printf("\t\t.state = SVGA3D_RS_LOCALVIEWER\n");
+      break;
+   case SVGA3D_RS_SCISSORTESTENABLE:
+      _debug_printf("\t\t.state = SVGA3D_RS_SCISSORTESTENABLE\n");
+      break;
+   case SVGA3D_RS_BLENDCOLOR:
+      _debug_printf("\t\t.state = SVGA3D_RS_BLENDCOLOR\n");
+      break;
+   case SVGA3D_RS_STENCILENABLE2SIDED:
+      _debug_printf("\t\t.state = SVGA3D_RS_STENCILENABLE2SIDED\n");
+      break;
+   case SVGA3D_RS_CCWSTENCILFUNC:
+      _debug_printf("\t\t.state = SVGA3D_RS_CCWSTENCILFUNC\n");
+      break;
+   case SVGA3D_RS_CCWSTENCILFAIL:
+      _debug_printf("\t\t.state = SVGA3D_RS_CCWSTENCILFAIL\n");
+      break;
+   case SVGA3D_RS_CCWSTENCILZFAIL:
+      _debug_printf("\t\t.state = SVGA3D_RS_CCWSTENCILZFAIL\n");
+      break;
+   case SVGA3D_RS_CCWSTENCILPASS:
+      _debug_printf("\t\t.state = SVGA3D_RS_CCWSTENCILPASS\n");
+      break;
+   case SVGA3D_RS_VERTEXBLEND:
+      _debug_printf("\t\t.state = SVGA3D_RS_VERTEXBLEND\n");
+      break;
+   case SVGA3D_RS_SLOPESCALEDEPTHBIAS:
+      _debug_printf("\t\t.state = SVGA3D_RS_SLOPESCALEDEPTHBIAS\n");
+      break;
+   case SVGA3D_RS_DEPTHBIAS:
+      _debug_printf("\t\t.state = SVGA3D_RS_DEPTHBIAS\n");
+      break;
+   case SVGA3D_RS_OUTPUTGAMMA:
+      _debug_printf("\t\t.state = SVGA3D_RS_OUTPUTGAMMA\n");
+      break;
+   case SVGA3D_RS_ZVISIBLE:
+      _debug_printf("\t\t.state = SVGA3D_RS_ZVISIBLE\n");
+      break;
+   case SVGA3D_RS_LASTPIXEL:
+      _debug_printf("\t\t.state = SVGA3D_RS_LASTPIXEL\n");
+      break;
+   case SVGA3D_RS_CLIPPING:
+      _debug_printf("\t\t.state = SVGA3D_RS_CLIPPING\n");
+      break;
+   case SVGA3D_RS_WRAP0:
+      _debug_printf("\t\t.state = SVGA3D_RS_WRAP0\n");
+      break;
+   case SVGA3D_RS_WRAP1:
+      _debug_printf("\t\t.state = SVGA3D_RS_WRAP1\n");
+      break;
+   case SVGA3D_RS_WRAP2:
+      _debug_printf("\t\t.state = SVGA3D_RS_WRAP2\n");
+      break;
+   case SVGA3D_RS_WRAP3:
+      _debug_printf("\t\t.state = SVGA3D_RS_WRAP3\n");
+      break;
+   case SVGA3D_RS_WRAP4:
+      _debug_printf("\t\t.state = SVGA3D_RS_WRAP4\n");
+      break;
+   case SVGA3D_RS_WRAP5:
+      _debug_printf("\t\t.state = SVGA3D_RS_WRAP5\n");
+      break;
+   case SVGA3D_RS_WRAP6:
+      _debug_printf("\t\t.state = SVGA3D_RS_WRAP6\n");
+      break;
+   case SVGA3D_RS_WRAP7:
+      _debug_printf("\t\t.state = SVGA3D_RS_WRAP7\n");
+      break;
+   case SVGA3D_RS_WRAP8:
+      _debug_printf("\t\t.state = SVGA3D_RS_WRAP8\n");
+      break;
+   case SVGA3D_RS_WRAP9:
+      _debug_printf("\t\t.state = SVGA3D_RS_WRAP9\n");
+      break;
+   case SVGA3D_RS_WRAP10:
+      _debug_printf("\t\t.state = SVGA3D_RS_WRAP10\n");
+      break;
+   case SVGA3D_RS_WRAP11:
+      _debug_printf("\t\t.state = SVGA3D_RS_WRAP11\n");
+      break;
+   case SVGA3D_RS_WRAP12:
+      _debug_printf("\t\t.state = SVGA3D_RS_WRAP12\n");
+      break;
+   case SVGA3D_RS_WRAP13:
+      _debug_printf("\t\t.state = SVGA3D_RS_WRAP13\n");
+      break;
+   case SVGA3D_RS_WRAP14:
+      _debug_printf("\t\t.state = SVGA3D_RS_WRAP14\n");
+      break;
+   case SVGA3D_RS_WRAP15:
+      _debug_printf("\t\t.state = SVGA3D_RS_WRAP15\n");
+      break;
+   case SVGA3D_RS_MULTISAMPLEANTIALIAS:
+      _debug_printf("\t\t.state = SVGA3D_RS_MULTISAMPLEANTIALIAS\n");
+      break;
+   case SVGA3D_RS_MULTISAMPLEMASK:
+      _debug_printf("\t\t.state = SVGA3D_RS_MULTISAMPLEMASK\n");
+      break;
+   case SVGA3D_RS_INDEXEDVERTEXBLENDENABLE:
+      _debug_printf("\t\t.state = SVGA3D_RS_INDEXEDVERTEXBLENDENABLE\n");
+      break;
+   case SVGA3D_RS_TWEENFACTOR:
+      _debug_printf("\t\t.state = SVGA3D_RS_TWEENFACTOR\n");
+      break;
+   case SVGA3D_RS_ANTIALIASEDLINEENABLE:
+      _debug_printf("\t\t.state = SVGA3D_RS_ANTIALIASEDLINEENABLE\n");
+      break;
+   case SVGA3D_RS_COLORWRITEENABLE1:
+      _debug_printf("\t\t.state = SVGA3D_RS_COLORWRITEENABLE1\n");
+      break;
+   case SVGA3D_RS_COLORWRITEENABLE2:
+      _debug_printf("\t\t.state = SVGA3D_RS_COLORWRITEENABLE2\n");
+      break;
+   case SVGA3D_RS_COLORWRITEENABLE3:
+      _debug_printf("\t\t.state = SVGA3D_RS_COLORWRITEENABLE3\n");
+      break;
+   case SVGA3D_RS_SEPARATEALPHABLENDENABLE:
+      _debug_printf("\t\t.state = SVGA3D_RS_SEPARATEALPHABLENDENABLE\n");
+      break;
+   case SVGA3D_RS_SRCBLENDALPHA:
+      _debug_printf("\t\t.state = SVGA3D_RS_SRCBLENDALPHA\n");
+      break;
+   case SVGA3D_RS_DSTBLENDALPHA:
+      _debug_printf("\t\t.state = SVGA3D_RS_DSTBLENDALPHA\n");
+      break;
+   case SVGA3D_RS_BLENDEQUATIONALPHA:
+      _debug_printf("\t\t.state = SVGA3D_RS_BLENDEQUATIONALPHA\n");
+      break;
+   case SVGA3D_RS_MAX:
+      _debug_printf("\t\t.state = SVGA3D_RS_MAX\n");
+      break;
+   default:
+      _debug_printf("\t\t.state = %i\n", (*cmd).state);
+      break;
+   }
+   _debug_printf("\t\t.uintValue = %u\n", (*cmd).uintValue);
+   _debug_printf("\t\t.floatValue = %f\n", (*cmd).floatValue);
+}
+
+static void
+dump_SVGA3dVertexDivisor(const SVGA3dVertexDivisor *cmd)
+{
+   _debug_printf("\t\t.value = %u\n", (*cmd).value);
+   _debug_printf("\t\t.count = %u\n", (*cmd).count);
+   _debug_printf("\t\t.indexedData = %u\n", (*cmd).indexedData);
+   _debug_printf("\t\t.instanceData = %u\n", (*cmd).instanceData);
+}
+
+static void
+dump_SVGA3dCmdDefineShader(const SVGA3dCmdDefineShader *cmd)
+{
+   _debug_printf("\t\t.cid = %u\n", (*cmd).cid);
+   _debug_printf("\t\t.shid = %u\n", (*cmd).shid);
+   switch((*cmd).type) {
+   case SVGA3D_SHADERTYPE_COMPILED_DX8:
+      _debug_printf("\t\t.type = SVGA3D_SHADERTYPE_COMPILED_DX8\n");
+      break;
+   case SVGA3D_SHADERTYPE_VS:
+      _debug_printf("\t\t.type = SVGA3D_SHADERTYPE_VS\n");
+      break;
+   case SVGA3D_SHADERTYPE_PS:
+      _debug_printf("\t\t.type = SVGA3D_SHADERTYPE_PS\n");
+      break;
+   case SVGA3D_SHADERTYPE_MAX:
+      _debug_printf("\t\t.type = SVGA3D_SHADERTYPE_MAX\n");
+      break;
+   default:
+      _debug_printf("\t\t.type = %i\n", (*cmd).type);
+      break;
+   }
+}
+
+static void
+dump_SVGA3dCmdSetShaderConst(const SVGA3dCmdSetShaderConst *cmd)
+{
+   _debug_printf("\t\t.cid = %u\n", (*cmd).cid);
+   _debug_printf("\t\t.reg = %u\n", (*cmd).reg);
+   switch((*cmd).type) {
+   case SVGA3D_SHADERTYPE_COMPILED_DX8:
+      _debug_printf("\t\t.type = SVGA3D_SHADERTYPE_COMPILED_DX8\n");
+      break;
+   case SVGA3D_SHADERTYPE_VS:
+      _debug_printf("\t\t.type = SVGA3D_SHADERTYPE_VS\n");
+      break;
+   case SVGA3D_SHADERTYPE_PS:
+      _debug_printf("\t\t.type = SVGA3D_SHADERTYPE_PS\n");
+      break;
+   case SVGA3D_SHADERTYPE_MAX:
+      _debug_printf("\t\t.type = SVGA3D_SHADERTYPE_MAX\n");
+      break;
+   default:
+      _debug_printf("\t\t.type = %i\n", (*cmd).type);
+      break;
+   }
+   switch((*cmd).ctype) {
+   case SVGA3D_CONST_TYPE_FLOAT:
+      _debug_printf("\t\t.ctype = SVGA3D_CONST_TYPE_FLOAT\n");
+      _debug_printf("\t\t.values[0] = %f\n", *(const float *)&(*cmd).values[0]);
+      _debug_printf("\t\t.values[1] = %f\n", *(const float *)&(*cmd).values[1]);
+      _debug_printf("\t\t.values[2] = %f\n", *(const float *)&(*cmd).values[2]);
+      _debug_printf("\t\t.values[3] = %f\n", *(const float *)&(*cmd).values[3]);
+      break;
+   case SVGA3D_CONST_TYPE_INT:
+      _debug_printf("\t\t.ctype = SVGA3D_CONST_TYPE_INT\n");
+      _debug_printf("\t\t.values[0] = %u\n", (*cmd).values[0]);
+      _debug_printf("\t\t.values[1] = %u\n", (*cmd).values[1]);
+      _debug_printf("\t\t.values[2] = %u\n", (*cmd).values[2]);
+      _debug_printf("\t\t.values[3] = %u\n", (*cmd).values[3]);
+      break;
+   case SVGA3D_CONST_TYPE_BOOL:
+      _debug_printf("\t\t.ctype = SVGA3D_CONST_TYPE_BOOL\n");
+      _debug_printf("\t\t.values[0] = %u\n", (*cmd).values[0]);
+      _debug_printf("\t\t.values[1] = %u\n", (*cmd).values[1]);
+      _debug_printf("\t\t.values[2] = %u\n", (*cmd).values[2]);
+      _debug_printf("\t\t.values[3] = %u\n", (*cmd).values[3]);
+      break;
+   default:
+      _debug_printf("\t\t.ctype = %i\n", (*cmd).ctype);
+      _debug_printf("\t\t.values[0] = %u\n", (*cmd).values[0]);
+      _debug_printf("\t\t.values[1] = %u\n", (*cmd).values[1]);
+      _debug_printf("\t\t.values[2] = %u\n", (*cmd).values[2]);
+      _debug_printf("\t\t.values[3] = %u\n", (*cmd).values[3]);
+      break;
+   }
+}
+
+static void
+dump_SVGA3dCmdSetZRange(const SVGA3dCmdSetZRange *cmd)
+{
+   _debug_printf("\t\t.cid = %u\n", (*cmd).cid);
+   _debug_printf("\t\t.zRange.min = %f\n", (*cmd).zRange.min);
+   _debug_printf("\t\t.zRange.max = %f\n", (*cmd).zRange.max);
+}
+
+static void
+dump_SVGA3dCmdDrawPrimitives(const SVGA3dCmdDrawPrimitives *cmd)
+{
+   _debug_printf("\t\t.cid = %u\n", (*cmd).cid);
+   _debug_printf("\t\t.numVertexDecls = %u\n", (*cmd).numVertexDecls);
+   _debug_printf("\t\t.numRanges = %u\n", (*cmd).numRanges);
+}
+
+static void
+dump_SVGA3dCmdSetLightEnabled(const SVGA3dCmdSetLightEnabled *cmd)
+{
+   _debug_printf("\t\t.cid = %u\n", (*cmd).cid);
+   _debug_printf("\t\t.index = %u\n", (*cmd).index);
+   _debug_printf("\t\t.enabled = %u\n", (*cmd).enabled);
+}
+
+static void
+dump_SVGA3dPrimitiveRange(const SVGA3dPrimitiveRange *cmd)
+{
+   switch((*cmd).primType) {
+   case SVGA3D_PRIMITIVE_INVALID:
+      _debug_printf("\t\t.primType = SVGA3D_PRIMITIVE_INVALID\n");
+      break;
+   case SVGA3D_PRIMITIVE_TRIANGLELIST:
+      _debug_printf("\t\t.primType = SVGA3D_PRIMITIVE_TRIANGLELIST\n");
+      break;
+   case SVGA3D_PRIMITIVE_POINTLIST:
+      _debug_printf("\t\t.primType = SVGA3D_PRIMITIVE_POINTLIST\n");
+      break;
+   case SVGA3D_PRIMITIVE_LINELIST:
+      _debug_printf("\t\t.primType = SVGA3D_PRIMITIVE_LINELIST\n");
+      break;
+   case SVGA3D_PRIMITIVE_LINESTRIP:
+      _debug_printf("\t\t.primType = SVGA3D_PRIMITIVE_LINESTRIP\n");
+      break;
+   case SVGA3D_PRIMITIVE_TRIANGLESTRIP:
+      _debug_printf("\t\t.primType = SVGA3D_PRIMITIVE_TRIANGLESTRIP\n");
+      break;
+   case SVGA3D_PRIMITIVE_TRIANGLEFAN:
+      _debug_printf("\t\t.primType = SVGA3D_PRIMITIVE_TRIANGLEFAN\n");
+      break;
+   case SVGA3D_PRIMITIVE_MAX:
+      _debug_printf("\t\t.primType = SVGA3D_PRIMITIVE_MAX\n");
+      break;
+   default:
+      _debug_printf("\t\t.primType = %i\n", (*cmd).primType);
+      break;
+   }
+   _debug_printf("\t\t.primitiveCount = %u\n", (*cmd).primitiveCount);
+   _debug_printf("\t\t.indexArray.surfaceId = %u\n", (*cmd).indexArray.surfaceId);
+   _debug_printf("\t\t.indexArray.offset = %u\n", (*cmd).indexArray.offset);
+   _debug_printf("\t\t.indexArray.stride = %u\n", (*cmd).indexArray.stride);
+   _debug_printf("\t\t.indexWidth = %u\n", (*cmd).indexWidth);
+   _debug_printf("\t\t.indexBias = %i\n", (*cmd).indexBias);
+}
+
+static void
+dump_SVGA3dCmdPresent(const SVGA3dCmdPresent *cmd)
+{
+   _debug_printf("\t\t.sid = %u\n", (*cmd).sid);
+}
+
+static void
+dump_SVGA3dCmdSetRenderState(const SVGA3dCmdSetRenderState *cmd)
+{
+   _debug_printf("\t\t.cid = %u\n", (*cmd).cid);
+}
+
+static void
+dump_SVGA3dCmdSurfaceStretchBlt(const SVGA3dCmdSurfaceStretchBlt *cmd)
+{
+   _debug_printf("\t\t.src.sid = %u\n", (*cmd).src.sid);
+   _debug_printf("\t\t.src.face = %u\n", (*cmd).src.face);
+   _debug_printf("\t\t.src.mipmap = %u\n", (*cmd).src.mipmap);
+   _debug_printf("\t\t.dest.sid = %u\n", (*cmd).dest.sid);
+   _debug_printf("\t\t.dest.face = %u\n", (*cmd).dest.face);
+   _debug_printf("\t\t.dest.mipmap = %u\n", (*cmd).dest.mipmap);
+   _debug_printf("\t\t.boxSrc.x = %u\n", (*cmd).boxSrc.x);
+   _debug_printf("\t\t.boxSrc.y = %u\n", (*cmd).boxSrc.y);
+   _debug_printf("\t\t.boxSrc.z = %u\n", (*cmd).boxSrc.z);
+   _debug_printf("\t\t.boxSrc.w = %u\n", (*cmd).boxSrc.w);
+   _debug_printf("\t\t.boxSrc.h = %u\n", (*cmd).boxSrc.h);
+   _debug_printf("\t\t.boxSrc.d = %u\n", (*cmd).boxSrc.d);
+   _debug_printf("\t\t.boxDest.x = %u\n", (*cmd).boxDest.x);
+   _debug_printf("\t\t.boxDest.y = %u\n", (*cmd).boxDest.y);
+   _debug_printf("\t\t.boxDest.z = %u\n", (*cmd).boxDest.z);
+   _debug_printf("\t\t.boxDest.w = %u\n", (*cmd).boxDest.w);
+   _debug_printf("\t\t.boxDest.h = %u\n", (*cmd).boxDest.h);
+   _debug_printf("\t\t.boxDest.d = %u\n", (*cmd).boxDest.d);
+   switch((*cmd).mode) {
+   case SVGA3D_STRETCH_BLT_POINT:
+      _debug_printf("\t\t.mode = SVGA3D_STRETCH_BLT_POINT\n");
+      break;
+   case SVGA3D_STRETCH_BLT_LINEAR:
+      _debug_printf("\t\t.mode = SVGA3D_STRETCH_BLT_LINEAR\n");
+      break;
+   case SVGA3D_STRETCH_BLT_MAX:
+      _debug_printf("\t\t.mode = SVGA3D_STRETCH_BLT_MAX\n");
+      break;
+   default:
+      _debug_printf("\t\t.mode = %i\n", (*cmd).mode);
+      break;
+   }
+}
+
+static void
+dump_SVGA3dCmdSurfaceDMA(const SVGA3dCmdSurfaceDMA *cmd)
+{
+   _debug_printf("\t\t.guest.ptr.gmrId = %u\n", (*cmd).guest.ptr.gmrId);
+   _debug_printf("\t\t.guest.ptr.offset = %u\n", (*cmd).guest.ptr.offset);
+   _debug_printf("\t\t.guest.pitch = %u\n", (*cmd).guest.pitch);
+   _debug_printf("\t\t.host.sid = %u\n", (*cmd).host.sid);
+   _debug_printf("\t\t.host.face = %u\n", (*cmd).host.face);
+   _debug_printf("\t\t.host.mipmap = %u\n", (*cmd).host.mipmap);
+   switch((*cmd).transfer) {
+   case SVGA3D_WRITE_HOST_VRAM:
+      _debug_printf("\t\t.transfer = SVGA3D_WRITE_HOST_VRAM\n");
+      break;
+   case SVGA3D_READ_HOST_VRAM:
+      _debug_printf("\t\t.transfer = SVGA3D_READ_HOST_VRAM\n");
+      break;
+   default:
+      _debug_printf("\t\t.transfer = %i\n", (*cmd).transfer);
+      break;
+   }
+}
+
+static void
+dump_SVGA3dCmdSurfaceDMASuffix(const SVGA3dCmdSurfaceDMASuffix *cmd)
+{
+   _debug_printf("\t\t.suffixSize = %u\n", (*cmd).suffixSize);
+   _debug_printf("\t\t.maximumOffset = %u\n", (*cmd).maximumOffset);
+   _debug_printf("\t\t.flags.discard = %u\n", (*cmd).flags.discard);
+   _debug_printf("\t\t.flags.unsynchronized = %u\n", (*cmd).flags.unsynchronized);
+}
+
+static void
+dump_SVGA3dCmdSetTransform(const SVGA3dCmdSetTransform *cmd)
+{
+   _debug_printf("\t\t.cid = %u\n", (*cmd).cid);
+   switch((*cmd).type) {
+   case SVGA3D_TRANSFORM_INVALID:
+      _debug_printf("\t\t.type = SVGA3D_TRANSFORM_INVALID\n");
+      break;
+   case SVGA3D_TRANSFORM_WORLD:
+      _debug_printf("\t\t.type = SVGA3D_TRANSFORM_WORLD\n");
+      break;
+   case SVGA3D_TRANSFORM_VIEW:
+      _debug_printf("\t\t.type = SVGA3D_TRANSFORM_VIEW\n");
+      break;
+   case SVGA3D_TRANSFORM_PROJECTION:
+      _debug_printf("\t\t.type = SVGA3D_TRANSFORM_PROJECTION\n");
+      break;
+   case SVGA3D_TRANSFORM_TEXTURE0:
+      _debug_printf("\t\t.type = SVGA3D_TRANSFORM_TEXTURE0\n");
+      break;
+   case SVGA3D_TRANSFORM_TEXTURE1:
+      _debug_printf("\t\t.type = SVGA3D_TRANSFORM_TEXTURE1\n");
+      break;
+   case SVGA3D_TRANSFORM_TEXTURE2:
+      _debug_printf("\t\t.type = SVGA3D_TRANSFORM_TEXTURE2\n");
+      break;
+   case SVGA3D_TRANSFORM_TEXTURE3:
+      _debug_printf("\t\t.type = SVGA3D_TRANSFORM_TEXTURE3\n");
+      break;
+   case SVGA3D_TRANSFORM_TEXTURE4:
+      _debug_printf("\t\t.type = SVGA3D_TRANSFORM_TEXTURE4\n");
+      break;
+   case SVGA3D_TRANSFORM_TEXTURE5:
+      _debug_printf("\t\t.type = SVGA3D_TRANSFORM_TEXTURE5\n");
+      break;
+   case SVGA3D_TRANSFORM_TEXTURE6:
+      _debug_printf("\t\t.type = SVGA3D_TRANSFORM_TEXTURE6\n");
+      break;
+   case SVGA3D_TRANSFORM_TEXTURE7:
+      _debug_printf("\t\t.type = SVGA3D_TRANSFORM_TEXTURE7\n");
+      break;
+   case SVGA3D_TRANSFORM_WORLD1:
+      _debug_printf("\t\t.type = SVGA3D_TRANSFORM_WORLD1\n");
+      break;
+   case SVGA3D_TRANSFORM_WORLD2:
+      _debug_printf("\t\t.type = SVGA3D_TRANSFORM_WORLD2\n");
+      break;
+   case SVGA3D_TRANSFORM_WORLD3:
+      _debug_printf("\t\t.type = SVGA3D_TRANSFORM_WORLD3\n");
+      break;
+   case SVGA3D_TRANSFORM_MAX:
+      _debug_printf("\t\t.type = SVGA3D_TRANSFORM_MAX\n");
+      break;
+   default:
+      _debug_printf("\t\t.type = %i\n", (*cmd).type);
+      break;
+   }
+   _debug_printf("\t\t.matrix[0] = %f\n", (*cmd).matrix[0]);
+   _debug_printf("\t\t.matrix[1] = %f\n", (*cmd).matrix[1]);
+   _debug_printf("\t\t.matrix[2] = %f\n", (*cmd).matrix[2]);
+   _debug_printf("\t\t.matrix[3] = %f\n", (*cmd).matrix[3]);
+   _debug_printf("\t\t.matrix[4] = %f\n", (*cmd).matrix[4]);
+   _debug_printf("\t\t.matrix[5] = %f\n", (*cmd).matrix[5]);
+   _debug_printf("\t\t.matrix[6] = %f\n", (*cmd).matrix[6]);
+   _debug_printf("\t\t.matrix[7] = %f\n", (*cmd).matrix[7]);
+   _debug_printf("\t\t.matrix[8] = %f\n", (*cmd).matrix[8]);
+   _debug_printf("\t\t.matrix[9] = %f\n", (*cmd).matrix[9]);
+   _debug_printf("\t\t.matrix[10] = %f\n", (*cmd).matrix[10]);
+   _debug_printf("\t\t.matrix[11] = %f\n", (*cmd).matrix[11]);
+   _debug_printf("\t\t.matrix[12] = %f\n", (*cmd).matrix[12]);
+   _debug_printf("\t\t.matrix[13] = %f\n", (*cmd).matrix[13]);
+   _debug_printf("\t\t.matrix[14] = %f\n", (*cmd).matrix[14]);
+   _debug_printf("\t\t.matrix[15] = %f\n", (*cmd).matrix[15]);
+}
+
+static void
+dump_SVGA3dCmdDestroyShader(const SVGA3dCmdDestroyShader *cmd)
+{
+   _debug_printf("\t\t.cid = %u\n", (*cmd).cid);
+   _debug_printf("\t\t.shid = %u\n", (*cmd).shid);
+   switch((*cmd).type) {
+   case SVGA3D_SHADERTYPE_COMPILED_DX8:
+      _debug_printf("\t\t.type = SVGA3D_SHADERTYPE_COMPILED_DX8\n");
+      break;
+   case SVGA3D_SHADERTYPE_VS:
+      _debug_printf("\t\t.type = SVGA3D_SHADERTYPE_VS\n");
+      break;
+   case SVGA3D_SHADERTYPE_PS:
+      _debug_printf("\t\t.type = SVGA3D_SHADERTYPE_PS\n");
+      break;
+   case SVGA3D_SHADERTYPE_MAX:
+      _debug_printf("\t\t.type = SVGA3D_SHADERTYPE_MAX\n");
+      break;
+   default:
+      _debug_printf("\t\t.type = %i\n", (*cmd).type);
+      break;
+   }
+}
+
+static void
+dump_SVGA3dCmdDestroyContext(const SVGA3dCmdDestroyContext *cmd)
+{
+   _debug_printf("\t\t.cid = %u\n", (*cmd).cid);
+}
+
+static void
+dump_SVGA3dCmdClear(const SVGA3dCmdClear *cmd)
+{
+   _debug_printf("\t\t.cid = %u\n", (*cmd).cid);
+   switch((*cmd).clearFlag) {
+   case SVGA3D_CLEAR_COLOR:
+      _debug_printf("\t\t.clearFlag = SVGA3D_CLEAR_COLOR\n");
+      break;
+   case SVGA3D_CLEAR_DEPTH:
+      _debug_printf("\t\t.clearFlag = SVGA3D_CLEAR_DEPTH\n");
+      break;
+   case SVGA3D_CLEAR_STENCIL:
+      _debug_printf("\t\t.clearFlag = SVGA3D_CLEAR_STENCIL\n");
+      break;
+   default:
+      _debug_printf("\t\t.clearFlag = %i\n", (*cmd).clearFlag);
+      break;
+   }
+   _debug_printf("\t\t.color = %u\n", (*cmd).color);
+   _debug_printf("\t\t.depth = %f\n", (*cmd).depth);
+   _debug_printf("\t\t.stencil = %u\n", (*cmd).stencil);
+}
+
+static void
+dump_SVGA3dCmdDefineSurface(const SVGA3dCmdDefineSurface *cmd)
+{
+   _debug_printf("\t\t.sid = %u\n", (*cmd).sid);
+   switch((*cmd).surfaceFlags) {
+   case SVGA3D_SURFACE_CUBEMAP:
+      _debug_printf("\t\t.surfaceFlags = SVGA3D_SURFACE_CUBEMAP\n");
+      break;
+   case SVGA3D_SURFACE_HINT_STATIC:
+      _debug_printf("\t\t.surfaceFlags = SVGA3D_SURFACE_HINT_STATIC\n");
+      break;
+   case SVGA3D_SURFACE_HINT_DYNAMIC:
+      _debug_printf("\t\t.surfaceFlags = SVGA3D_SURFACE_HINT_DYNAMIC\n");
+      break;
+   case SVGA3D_SURFACE_HINT_INDEXBUFFER:
+      _debug_printf("\t\t.surfaceFlags = SVGA3D_SURFACE_HINT_INDEXBUFFER\n");
+      break;
+   case SVGA3D_SURFACE_HINT_VERTEXBUFFER:
+      _debug_printf("\t\t.surfaceFlags = SVGA3D_SURFACE_HINT_VERTEXBUFFER\n");
+      break;
+   default:
+      _debug_printf("\t\t.surfaceFlags = %i\n", (*cmd).surfaceFlags);
+      break;
+   }
+   switch((*cmd).format) {
+   case SVGA3D_FORMAT_INVALID:
+      _debug_printf("\t\t.format = SVGA3D_FORMAT_INVALID\n");
+      break;
+   case SVGA3D_X8R8G8B8:
+      _debug_printf("\t\t.format = SVGA3D_X8R8G8B8\n");
+      break;
+   case SVGA3D_A8R8G8B8:
+      _debug_printf("\t\t.format = SVGA3D_A8R8G8B8\n");
+      break;
+   case SVGA3D_R5G6B5:
+      _debug_printf("\t\t.format = SVGA3D_R5G6B5\n");
+      break;
+   case SVGA3D_X1R5G5B5:
+      _debug_printf("\t\t.format = SVGA3D_X1R5G5B5\n");
+      break;
+   case SVGA3D_A1R5G5B5:
+      _debug_printf("\t\t.format = SVGA3D_A1R5G5B5\n");
+      break;
+   case SVGA3D_A4R4G4B4:
+      _debug_printf("\t\t.format = SVGA3D_A4R4G4B4\n");
+      break;
+   case SVGA3D_Z_D32:
+      _debug_printf("\t\t.format = SVGA3D_Z_D32\n");
+      break;
+   case SVGA3D_Z_D16:
+      _debug_printf("\t\t.format = SVGA3D_Z_D16\n");
+      break;
+   case SVGA3D_Z_D24S8:
+      _debug_printf("\t\t.format = SVGA3D_Z_D24S8\n");
+      break;
+   case SVGA3D_Z_D15S1:
+      _debug_printf("\t\t.format = SVGA3D_Z_D15S1\n");
+      break;
+   case SVGA3D_LUMINANCE8:
+      _debug_printf("\t\t.format = SVGA3D_LUMINANCE8\n");
+      break;
+   case SVGA3D_LUMINANCE4_ALPHA4:
+      _debug_printf("\t\t.format = SVGA3D_LUMINANCE4_ALPHA4\n");
+      break;
+   case SVGA3D_LUMINANCE16:
+      _debug_printf("\t\t.format = SVGA3D_LUMINANCE16\n");
+      break;
+   case SVGA3D_LUMINANCE8_ALPHA8:
+      _debug_printf("\t\t.format = SVGA3D_LUMINANCE8_ALPHA8\n");
+      break;
+   case SVGA3D_DXT1:
+      _debug_printf("\t\t.format = SVGA3D_DXT1\n");
+      break;
+   case SVGA3D_DXT2:
+      _debug_printf("\t\t.format = SVGA3D_DXT2\n");
+      break;
+   case SVGA3D_DXT3:
+      _debug_printf("\t\t.format = SVGA3D_DXT3\n");
+      break;
+   case SVGA3D_DXT4:
+      _debug_printf("\t\t.format = SVGA3D_DXT4\n");
+      break;
+   case SVGA3D_DXT5:
+      _debug_printf("\t\t.format = SVGA3D_DXT5\n");
+      break;
+   case SVGA3D_BUMPU8V8:
+      _debug_printf("\t\t.format = SVGA3D_BUMPU8V8\n");
+      break;
+   case SVGA3D_BUMPL6V5U5:
+      _debug_printf("\t\t.format = SVGA3D_BUMPL6V5U5\n");
+      break;
+   case SVGA3D_BUMPX8L8V8U8:
+      _debug_printf("\t\t.format = SVGA3D_BUMPX8L8V8U8\n");
+      break;
+   case SVGA3D_BUMPL8V8U8:
+      _debug_printf("\t\t.format = SVGA3D_BUMPL8V8U8\n");
+      break;
+   case SVGA3D_ARGB_S10E5:
+      _debug_printf("\t\t.format = SVGA3D_ARGB_S10E5\n");
+      break;
+   case SVGA3D_ARGB_S23E8:
+      _debug_printf("\t\t.format = SVGA3D_ARGB_S23E8\n");
+      break;
+   case SVGA3D_A2R10G10B10:
+      _debug_printf("\t\t.format = SVGA3D_A2R10G10B10\n");
+      break;
+   case SVGA3D_V8U8:
+      _debug_printf("\t\t.format = SVGA3D_V8U8\n");
+      break;
+   case SVGA3D_Q8W8V8U8:
+      _debug_printf("\t\t.format = SVGA3D_Q8W8V8U8\n");
+      break;
+   case SVGA3D_CxV8U8:
+      _debug_printf("\t\t.format = SVGA3D_CxV8U8\n");
+      break;
+   case SVGA3D_X8L8V8U8:
+      _debug_printf("\t\t.format = SVGA3D_X8L8V8U8\n");
+      break;
+   case SVGA3D_A2W10V10U10:
+      _debug_printf("\t\t.format = SVGA3D_A2W10V10U10\n");
+      break;
+   case SVGA3D_ALPHA8:
+      _debug_printf("\t\t.format = SVGA3D_ALPHA8\n");
+      break;
+   case SVGA3D_R_S10E5:
+      _debug_printf("\t\t.format = SVGA3D_R_S10E5\n");
+      break;
+   case SVGA3D_R_S23E8:
+      _debug_printf("\t\t.format = SVGA3D_R_S23E8\n");
+      break;
+   case SVGA3D_RG_S10E5:
+      _debug_printf("\t\t.format = SVGA3D_RG_S10E5\n");
+      break;
+   case SVGA3D_RG_S23E8:
+      _debug_printf("\t\t.format = SVGA3D_RG_S23E8\n");
+      break;
+   case SVGA3D_BUFFER:
+      _debug_printf("\t\t.format = SVGA3D_BUFFER\n");
+      break;
+   case SVGA3D_Z_D24X8:
+      _debug_printf("\t\t.format = SVGA3D_Z_D24X8\n");
+      break;
+   case SVGA3D_FORMAT_MAX:
+      _debug_printf("\t\t.format = SVGA3D_FORMAT_MAX\n");
+      break;
+   default:
+      _debug_printf("\t\t.format = %i\n", (*cmd).format);
+      break;
+   }
+   _debug_printf("\t\t.face[0].numMipLevels = %u\n", (*cmd).face[0].numMipLevels);
+   _debug_printf("\t\t.face[1].numMipLevels = %u\n", (*cmd).face[1].numMipLevels);
+   _debug_printf("\t\t.face[2].numMipLevels = %u\n", (*cmd).face[2].numMipLevels);
+   _debug_printf("\t\t.face[3].numMipLevels = %u\n", (*cmd).face[3].numMipLevels);
+   _debug_printf("\t\t.face[4].numMipLevels = %u\n", (*cmd).face[4].numMipLevels);
+   _debug_printf("\t\t.face[5].numMipLevels = %u\n", (*cmd).face[5].numMipLevels);
+}
+
+static void
+dump_SVGASignedRect(const SVGASignedRect *cmd)
+{
+   _debug_printf("\t\t.left = %i\n", (*cmd).left);
+   _debug_printf("\t\t.top = %i\n", (*cmd).top);
+   _debug_printf("\t\t.right = %i\n", (*cmd).right);
+   _debug_printf("\t\t.bottom = %i\n", (*cmd).bottom);
+}
+
+static void
+dump_SVGA3dCmdBlitSurfaceToScreen(const SVGA3dCmdBlitSurfaceToScreen *cmd)
+{
+   _debug_printf("\t\t.srcImage.sid = %u\n", (*cmd).srcImage.sid);
+   _debug_printf("\t\t.srcImage.face = %u\n", (*cmd).srcImage.face);
+   _debug_printf("\t\t.srcImage.mipmap = %u\n", (*cmd).srcImage.mipmap);
+   _debug_printf("\t\t.srcRect.left = %i\n", (*cmd).srcRect.left);
+   _debug_printf("\t\t.srcRect.top = %i\n", (*cmd).srcRect.top);
+   _debug_printf("\t\t.srcRect.right = %i\n", (*cmd).srcRect.right);
+   _debug_printf("\t\t.srcRect.bottom = %i\n", (*cmd).srcRect.bottom);
+   _debug_printf("\t\t.destScreenId = %u\n", (*cmd).destScreenId);
+   _debug_printf("\t\t.destRect.left = %i\n", (*cmd).destRect.left);
+   _debug_printf("\t\t.destRect.top = %i\n", (*cmd).destRect.top);
+   _debug_printf("\t\t.destRect.right = %i\n", (*cmd).destRect.right);
+   _debug_printf("\t\t.destRect.bottom = %i\n", (*cmd).destRect.bottom);
+}
+
+
+void            
+svga_dump_command(uint32_t cmd_id, const void *data, uint32_t size)
+{
+   const uint8_t *body = (const uint8_t *)data;
+   const uint8_t *next = body + size;
+  
+   switch(cmd_id) {
+   case SVGA_3D_CMD_SURFACE_DEFINE:
+      _debug_printf("\tSVGA_3D_CMD_SURFACE_DEFINE\n");
+      {
+         const SVGA3dCmdDefineSurface *cmd = (const SVGA3dCmdDefineSurface *)body;
+         dump_SVGA3dCmdDefineSurface(cmd);
+         body = (const uint8_t *)&cmd[1];
+         while(body + sizeof(SVGA3dSize) <= next) {
+            dump_SVGA3dSize((const SVGA3dSize *)body);
+            body += sizeof(SVGA3dSize);
+         }
+      }
+      break;
+   case SVGA_3D_CMD_SURFACE_DESTROY:
+      _debug_printf("\tSVGA_3D_CMD_SURFACE_DESTROY\n");
+      {
+         const SVGA3dCmdDestroySurface *cmd = (const SVGA3dCmdDestroySurface *)body;
+         dump_SVGA3dCmdDestroySurface(cmd);
+         body = (const uint8_t *)&cmd[1];
+      }
+      break;
+   case SVGA_3D_CMD_SURFACE_COPY:
+      _debug_printf("\tSVGA_3D_CMD_SURFACE_COPY\n");
+      {
+         const SVGA3dCmdSurfaceCopy *cmd = (const SVGA3dCmdSurfaceCopy *)body;
+         dump_SVGA3dCmdSurfaceCopy(cmd);
+         body = (const uint8_t *)&cmd[1];
+         while(body + sizeof(SVGA3dCopyBox) <= next) {
+            dump_SVGA3dCopyBox((const SVGA3dCopyBox *)body);
+            body += sizeof(SVGA3dCopyBox);
+         }
+      }
+      break;
+   case SVGA_3D_CMD_SURFACE_STRETCHBLT:
+      _debug_printf("\tSVGA_3D_CMD_SURFACE_STRETCHBLT\n");
+      {
+         const SVGA3dCmdSurfaceStretchBlt *cmd = (const SVGA3dCmdSurfaceStretchBlt *)body;
+         dump_SVGA3dCmdSurfaceStretchBlt(cmd);
+         body = (const uint8_t *)&cmd[1];
+      }
+      break;
+   case SVGA_3D_CMD_SURFACE_DMA:
+      _debug_printf("\tSVGA_3D_CMD_SURFACE_DMA\n");
+      {
+         const SVGA3dCmdSurfaceDMA *cmd = (const SVGA3dCmdSurfaceDMA *)body;
+         dump_SVGA3dCmdSurfaceDMA(cmd);
+         body = (const uint8_t *)&cmd[1];
+         while(body + sizeof(SVGA3dCopyBox) <= next) {
+            dump_SVGA3dCopyBox((const SVGA3dCopyBox *)body);
+            body += sizeof(SVGA3dCopyBox);
+         }
+         while(body + sizeof(SVGA3dCmdSurfaceDMASuffix) <= next) {
+            dump_SVGA3dCmdSurfaceDMASuffix((const SVGA3dCmdSurfaceDMASuffix *)body);
+            body += sizeof(SVGA3dCmdSurfaceDMASuffix);
+         }
+      }
+      break;
+   case SVGA_3D_CMD_CONTEXT_DEFINE:
+      _debug_printf("\tSVGA_3D_CMD_CONTEXT_DEFINE\n");
+      {
+         const SVGA3dCmdDefineContext *cmd = (const SVGA3dCmdDefineContext *)body;
+         dump_SVGA3dCmdDefineContext(cmd);
+         body = (const uint8_t *)&cmd[1];
+      }
+      break;
+   case SVGA_3D_CMD_CONTEXT_DESTROY:
+      _debug_printf("\tSVGA_3D_CMD_CONTEXT_DESTROY\n");
+      {
+         const SVGA3dCmdDestroyContext *cmd = (const SVGA3dCmdDestroyContext *)body;
+         dump_SVGA3dCmdDestroyContext(cmd);
+         body = (const uint8_t *)&cmd[1];
+      }
+      break;
+   case SVGA_3D_CMD_SETTRANSFORM:
+      _debug_printf("\tSVGA_3D_CMD_SETTRANSFORM\n");
+      {
+         const SVGA3dCmdSetTransform *cmd = (const SVGA3dCmdSetTransform *)body;
+         dump_SVGA3dCmdSetTransform(cmd);
+         body = (const uint8_t *)&cmd[1];
+      }
+      break;
+   case SVGA_3D_CMD_SETZRANGE:
+      _debug_printf("\tSVGA_3D_CMD_SETZRANGE\n");
+      {
+         const SVGA3dCmdSetZRange *cmd = (const SVGA3dCmdSetZRange *)body;
+         dump_SVGA3dCmdSetZRange(cmd);
+         body = (const uint8_t *)&cmd[1];
+      }
+      break;
+   case SVGA_3D_CMD_SETRENDERSTATE:
+      _debug_printf("\tSVGA_3D_CMD_SETRENDERSTATE\n");
+      {
+         const SVGA3dCmdSetRenderState *cmd = (const SVGA3dCmdSetRenderState *)body;
+         dump_SVGA3dCmdSetRenderState(cmd);
+         body = (const uint8_t *)&cmd[1];
+         while(body + sizeof(SVGA3dRenderState) <= next) {
+            dump_SVGA3dRenderState((const SVGA3dRenderState *)body);
+            body += sizeof(SVGA3dRenderState);
+         }
+      }
+      break;
+   case SVGA_3D_CMD_SETRENDERTARGET:
+      _debug_printf("\tSVGA_3D_CMD_SETRENDERTARGET\n");
+      {
+         const SVGA3dCmdSetRenderTarget *cmd = (const SVGA3dCmdSetRenderTarget *)body;
+         dump_SVGA3dCmdSetRenderTarget(cmd);
+         body = (const uint8_t *)&cmd[1];
+      }
+      break;
+   case SVGA_3D_CMD_SETTEXTURESTATE:
+      _debug_printf("\tSVGA_3D_CMD_SETTEXTURESTATE\n");
+      {
+         const SVGA3dCmdSetTextureState *cmd = (const SVGA3dCmdSetTextureState *)body;
+         dump_SVGA3dCmdSetTextureState(cmd);
+         body = (const uint8_t *)&cmd[1];
+         while(body + sizeof(SVGA3dTextureState) <= next) {
+            dump_SVGA3dTextureState((const SVGA3dTextureState *)body);
+            body += sizeof(SVGA3dTextureState);
+         }
+      }
+      break;
+   case SVGA_3D_CMD_SETMATERIAL:
+      _debug_printf("\tSVGA_3D_CMD_SETMATERIAL\n");
+      {
+         const SVGA3dCmdSetMaterial *cmd = (const SVGA3dCmdSetMaterial *)body;
+         dump_SVGA3dCmdSetMaterial(cmd);
+         body = (const uint8_t *)&cmd[1];
+      }
+      break;
+   case SVGA_3D_CMD_SETLIGHTDATA:
+      _debug_printf("\tSVGA_3D_CMD_SETLIGHTDATA\n");
+      {
+         const SVGA3dCmdSetLightData *cmd = (const SVGA3dCmdSetLightData *)body;
+         dump_SVGA3dCmdSetLightData(cmd);
+         body = (const uint8_t *)&cmd[1];
+      }
+      break;
+   case SVGA_3D_CMD_SETLIGHTENABLED:
+      _debug_printf("\tSVGA_3D_CMD_SETLIGHTENABLED\n");
+      {
+         const SVGA3dCmdSetLightEnabled *cmd = (const SVGA3dCmdSetLightEnabled *)body;
+         dump_SVGA3dCmdSetLightEnabled(cmd);
+         body = (const uint8_t *)&cmd[1];
+      }
+      break;
+   case SVGA_3D_CMD_SETVIEWPORT:
+      _debug_printf("\tSVGA_3D_CMD_SETVIEWPORT\n");
+      {
+         const SVGA3dCmdSetViewport *cmd = (const SVGA3dCmdSetViewport *)body;
+         dump_SVGA3dCmdSetViewport(cmd);
+         body = (const uint8_t *)&cmd[1];
+      }
+      break;
+   case SVGA_3D_CMD_SETCLIPPLANE:
+      _debug_printf("\tSVGA_3D_CMD_SETCLIPPLANE\n");
+      {
+         const SVGA3dCmdSetClipPlane *cmd = (const SVGA3dCmdSetClipPlane *)body;
+         dump_SVGA3dCmdSetClipPlane(cmd);
+         body = (const uint8_t *)&cmd[1];
+      }
+      break;
+   case SVGA_3D_CMD_CLEAR:
+      _debug_printf("\tSVGA_3D_CMD_CLEAR\n");
+      {
+         const SVGA3dCmdClear *cmd = (const SVGA3dCmdClear *)body;
+         dump_SVGA3dCmdClear(cmd);
+         body = (const uint8_t *)&cmd[1];
+         while(body + sizeof(SVGA3dRect) <= next) {
+            dump_SVGA3dRect((const SVGA3dRect *)body);
+            body += sizeof(SVGA3dRect);
+         }
+      }
+      break;
+   case SVGA_3D_CMD_PRESENT:
+      _debug_printf("\tSVGA_3D_CMD_PRESENT\n");
+      {
+         const SVGA3dCmdPresent *cmd = (const SVGA3dCmdPresent *)body;
+         dump_SVGA3dCmdPresent(cmd);
+         body = (const uint8_t *)&cmd[1];
+         while(body + sizeof(SVGA3dCopyRect) <= next) {
+            dump_SVGA3dCopyRect((const SVGA3dCopyRect *)body);
+            body += sizeof(SVGA3dCopyRect);
+         }
+      }
+      break;
+   case SVGA_3D_CMD_SHADER_DEFINE:
+      _debug_printf("\tSVGA_3D_CMD_SHADER_DEFINE\n");
+      {
+         const SVGA3dCmdDefineShader *cmd = (const SVGA3dCmdDefineShader *)body;
+         dump_SVGA3dCmdDefineShader(cmd);
+         body = (const uint8_t *)&cmd[1];
+         svga_shader_dump((const uint32_t *)body, 
+                      (unsigned)(next - body)/sizeof(uint32_t),
+                      FALSE );
+         body = next;
+      }
+      break;
+   case SVGA_3D_CMD_SHADER_DESTROY:
+      _debug_printf("\tSVGA_3D_CMD_SHADER_DESTROY\n");
+      {
+         const SVGA3dCmdDestroyShader *cmd = (const SVGA3dCmdDestroyShader *)body;
+         dump_SVGA3dCmdDestroyShader(cmd);
+         body = (const uint8_t *)&cmd[1];
+      }
+      break;
+   case SVGA_3D_CMD_SET_SHADER:
+      _debug_printf("\tSVGA_3D_CMD_SET_SHADER\n");
+      {
+         const SVGA3dCmdSetShader *cmd = (const SVGA3dCmdSetShader *)body;
+         dump_SVGA3dCmdSetShader(cmd);
+         body = (const uint8_t *)&cmd[1];
+      }
+      break;
+   case SVGA_3D_CMD_SET_SHADER_CONST:
+      _debug_printf("\tSVGA_3D_CMD_SET_SHADER_CONST\n");
+      {
+         const SVGA3dCmdSetShaderConst *cmd = (const SVGA3dCmdSetShaderConst *)body;
+         dump_SVGA3dCmdSetShaderConst(cmd);
+         body = (const uint8_t *)&cmd[1];
+      }
+      break;
+   case SVGA_3D_CMD_DRAW_PRIMITIVES:
+      _debug_printf("\tSVGA_3D_CMD_DRAW_PRIMITIVES\n");
+      {
+         const SVGA3dCmdDrawPrimitives *cmd = (const SVGA3dCmdDrawPrimitives *)body;
+         unsigned i, j;
+         dump_SVGA3dCmdDrawPrimitives(cmd);
+         body = (const uint8_t *)&cmd[1];
+         for(i = 0; i < cmd->numVertexDecls; ++i) {
+            dump_SVGA3dVertexDecl((const SVGA3dVertexDecl *)body);
+            body += sizeof(SVGA3dVertexDecl);
+         }
+         for(j = 0; j < cmd->numRanges; ++j) {
+            dump_SVGA3dPrimitiveRange((const SVGA3dPrimitiveRange *)body);
+            body += sizeof(SVGA3dPrimitiveRange);
+         }
+         while(body + sizeof(SVGA3dVertexDivisor) <= next) {
+            dump_SVGA3dVertexDivisor((const SVGA3dVertexDivisor *)body);
+            body += sizeof(SVGA3dVertexDivisor);
+         }
+      }
+      break;
+   case SVGA_3D_CMD_SETSCISSORRECT:
+      _debug_printf("\tSVGA_3D_CMD_SETSCISSORRECT\n");
+      {
+         const SVGA3dCmdSetScissorRect *cmd = (const SVGA3dCmdSetScissorRect *)body;
+         dump_SVGA3dCmdSetScissorRect(cmd);
+         body = (const uint8_t *)&cmd[1];
+      }
+      break;
+   case SVGA_3D_CMD_BEGIN_QUERY:
+      _debug_printf("\tSVGA_3D_CMD_BEGIN_QUERY\n");
+      {
+         const SVGA3dCmdBeginQuery *cmd = (const SVGA3dCmdBeginQuery *)body;
+         dump_SVGA3dCmdBeginQuery(cmd);
+         body = (const uint8_t *)&cmd[1];
+      }
+      break;
+   case SVGA_3D_CMD_END_QUERY:
+      _debug_printf("\tSVGA_3D_CMD_END_QUERY\n");
+      {
+         const SVGA3dCmdEndQuery *cmd = (const SVGA3dCmdEndQuery *)body;
+         dump_SVGA3dCmdEndQuery(cmd);
+         body = (const uint8_t *)&cmd[1];
+      }
+      break;
+   case SVGA_3D_CMD_WAIT_FOR_QUERY:
+      _debug_printf("\tSVGA_3D_CMD_WAIT_FOR_QUERY\n");
+      {
+         const SVGA3dCmdWaitForQuery *cmd = (const SVGA3dCmdWaitForQuery *)body;
+         dump_SVGA3dCmdWaitForQuery(cmd);
+         body = (const uint8_t *)&cmd[1];
+      }
+      break;
+   case SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN:
+      _debug_printf("\tSVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN\n");
+      {
+         const SVGA3dCmdBlitSurfaceToScreen *cmd = (const SVGA3dCmdBlitSurfaceToScreen *)body;
+         dump_SVGA3dCmdBlitSurfaceToScreen(cmd);
+         body = (const uint8_t *)&cmd[1];
+         while(body + sizeof(SVGASignedRect) <= next) {
+            dump_SVGASignedRect((const SVGASignedRect *)body);
+            body += sizeof(SVGASignedRect);
+         }
+      }
+      break;
+   default:
+      _debug_printf("\t0x%08x\n", cmd_id);
+      break;
+   }
+
+   while(body + sizeof(uint32_t) <= next) {
+      _debug_printf("\t\t0x%08x\n", *(const uint32_t *)body);
+      body += sizeof(uint32_t);
+   }
+   while(body + sizeof(uint32_t) <= next)
+      _debug_printf("\t\t0x%02x\n", *body++);
+}
+
+
+void            
+svga_dump_commands(const void *commands, uint32_t size)
+{
+   const uint8_t *next = commands;
+   const uint8_t *last = next + size;
+   
+   assert(size % sizeof(uint32_t) == 0);
+   
+   while(next < last) {
+      const uint32_t cmd_id = *(const uint32_t *)next;
+
+      if(SVGA_3D_CMD_BASE <= cmd_id && cmd_id < SVGA_3D_CMD_MAX) {
+         const SVGA3dCmdHeader *header = (const SVGA3dCmdHeader *)next;
+         const uint8_t *body = (const uint8_t *)&header[1];
+
+         next = body + header->size;
+         if(next > last)
+            break;
+
+         svga_dump_command(cmd_id, body, header->size);
+      }
+      else if(cmd_id == SVGA_CMD_FENCE) {
+         _debug_printf("\tSVGA_CMD_FENCE\n");
+         _debug_printf("\t\t0x%08x\n", ((const uint32_t *)next)[1]);
+         next += 2*sizeof(uint32_t);
+      }
+      else {
+         _debug_printf("\t0x%08x\n", cmd_id);
+         next += sizeof(uint32_t);
+      }
+   }
+}
+
diff --git a/src/gallium/drivers/svga/svgadump/svga_dump.h b/src/gallium/drivers/svga/svgadump/svga_dump.h
new file mode 100644 (file)
index 0000000..ca01543
--- /dev/null
@@ -0,0 +1,37 @@
+/**********************************************************
+ * 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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#ifndef SVGA_DUMP_H_
+#define SVGA_DUMP_H_
+
+#include "pipe/p_compiler.h"
+
+void            
+svga_dump_command(uint32_t cmd_id, const void *data, uint32_t size);
+
+void
+svga_dump_commands(const void *commands, uint32_t size);
+
+#endif /* SVGA_DUMP_H_ */
diff --git a/src/gallium/drivers/svga/svgadump/svga_dump.py b/src/gallium/drivers/svga/svgadump/svga_dump.py
new file mode 100755 (executable)
index 0000000..0bc0b3a
--- /dev/null
@@ -0,0 +1,340 @@
+#!/usr/bin/env python
+'''
+Generates dumper for the SVGA 3D command stream using pygccxml.
+
+Jose Fonseca <jfonseca@vmware.com>
+'''
+
+copyright = '''
+/**********************************************************
+ * 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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+ '''
+
+import os
+import sys
+
+from pygccxml import parser
+from pygccxml import declarations
+
+from pygccxml.declarations import algorithm
+from pygccxml.declarations import decl_visitor
+from pygccxml.declarations import type_traits
+from pygccxml.declarations import type_visitor
+
+
+enums = True
+
+
+class decl_dumper_t(decl_visitor.decl_visitor_t):
+
+    def __init__(self, instance = '', decl = None):
+        decl_visitor.decl_visitor_t.__init__(self)
+        self._instance = instance
+        self.decl = decl
+
+    def clone(self):
+        return decl_dumper_t(self._instance, self.decl)
+
+    def visit_class(self):
+        class_ = self.decl
+        assert self.decl.class_type in ('struct', 'union')
+
+        for variable in class_.variables():
+            if variable.name != '':
+                #print 'variable = %r' % variable.name
+                dump_type(self._instance + '.' + variable.name, variable.type)
+
+    def visit_enumeration(self):
+        if enums:
+            print '   switch(%s) {' % ("(*cmd)" + self._instance,)
+            for name, value in self.decl.values:
+                print '   case %s:' % (name,)
+                print '      _debug_printf("\\t\\t%s = %s\\n");' % (self._instance, name)
+                print '      break;'
+            print '   default:'
+            print '      _debug_printf("\\t\\t%s = %%i\\n", %s);' % (self._instance, "(*cmd)" + self._instance)
+            print '      break;'
+            print '   }'
+        else:
+            print '   _debug_printf("\\t\\t%s = %%i\\n", %s);' % (self._instance, "(*cmd)" + self._instance)
+
+
+def dump_decl(instance, decl):
+    dumper = decl_dumper_t(instance, decl)
+    algorithm.apply_visitor(dumper, decl)
+
+
+class type_dumper_t(type_visitor.type_visitor_t):
+
+    def __init__(self, instance, type_):
+        type_visitor.type_visitor_t.__init__(self)
+        self.instance = instance
+        self.type = type_
+
+    def clone(self):
+        return type_dumper_t(self.instance, self.type)
+
+    def visit_char(self):
+        self.print_instance('%i')
+        
+    def visit_unsigned_char(self):
+        self.print_instance('%u')
+
+    def visit_signed_char(self):
+        self.print_instance('%i')
+    
+    def visit_wchar(self):
+        self.print_instance('%i')
+        
+    def visit_short_int(self):
+        self.print_instance('%i')
+        
+    def visit_short_unsigned_int(self):
+        self.print_instance('%u')
+        
+    def visit_bool(self):
+        self.print_instance('%i')
+        
+    def visit_int(self):
+        self.print_instance('%i')
+        
+    def visit_unsigned_int(self):
+        self.print_instance('%u')
+        
+    def visit_long_int(self):
+        self.print_instance('%li')
+        
+    def visit_long_unsigned_int(self):
+        self.print_instance('%lu')
+        
+    def visit_long_long_int(self):
+        self.print_instance('%lli')
+        
+    def visit_long_long_unsigned_int(self):
+        self.print_instance('%llu')
+        
+    def visit_float(self):
+        self.print_instance('%f')
+        
+    def visit_double(self):
+        self.print_instance('%f')
+        
+    def visit_array(self):
+        for i in range(type_traits.array_size(self.type)):
+            dump_type(self.instance + '[%i]' % i, type_traits.base_type(self.type))
+
+    def visit_pointer(self):
+        self.print_instance('%p')
+
+    def visit_declarated(self):
+        #print 'decl = %r' % self.type.decl_string
+        decl = type_traits.remove_declarated(self.type)
+        dump_decl(self.instance, decl)
+
+    def print_instance(self, format):
+        print '   _debug_printf("\\t\\t%s = %s\\n", %s);' % (self.instance, format, "(*cmd)" + self.instance)
+
+
+def dump_type(instance, type_):
+    type_ = type_traits.remove_alias(type_)
+    visitor = type_dumper_t(instance, type_)
+    algorithm.apply_visitor(visitor, type_)
+
+
+def dump_struct(decls, class_):
+    print 'static void'
+    print 'dump_%s(const %s *cmd)' % (class_.name, class_.name)
+    print '{'
+    dump_decl('', class_)
+    print '}'
+    print ''
+
+
+cmds = [
+    ('SVGA_3D_CMD_SURFACE_DEFINE', 'SVGA3dCmdDefineSurface', (), 'SVGA3dSize'),
+    ('SVGA_3D_CMD_SURFACE_DESTROY', 'SVGA3dCmdDestroySurface', (), None),
+    ('SVGA_3D_CMD_SURFACE_COPY', 'SVGA3dCmdSurfaceCopy', (), 'SVGA3dCopyBox'),
+    ('SVGA_3D_CMD_SURFACE_STRETCHBLT', 'SVGA3dCmdSurfaceStretchBlt', (), None),
+    ('SVGA_3D_CMD_SURFACE_DMA', 'SVGA3dCmdSurfaceDMA', (), 'SVGA3dCopyBox'),
+    ('SVGA_3D_CMD_CONTEXT_DEFINE', 'SVGA3dCmdDefineContext', (), None),
+    ('SVGA_3D_CMD_CONTEXT_DESTROY', 'SVGA3dCmdDestroyContext', (), None),
+    ('SVGA_3D_CMD_SETTRANSFORM', 'SVGA3dCmdSetTransform', (), None),
+    ('SVGA_3D_CMD_SETZRANGE', 'SVGA3dCmdSetZRange', (), None),
+    ('SVGA_3D_CMD_SETRENDERSTATE', 'SVGA3dCmdSetRenderState', (), 'SVGA3dRenderState'),
+    ('SVGA_3D_CMD_SETRENDERTARGET', 'SVGA3dCmdSetRenderTarget', (), None),
+    ('SVGA_3D_CMD_SETTEXTURESTATE', 'SVGA3dCmdSetTextureState', (), 'SVGA3dTextureState'),
+    ('SVGA_3D_CMD_SETMATERIAL', 'SVGA3dCmdSetMaterial', (), None),
+    ('SVGA_3D_CMD_SETLIGHTDATA', 'SVGA3dCmdSetLightData', (), None),
+    ('SVGA_3D_CMD_SETLIGHTENABLED', 'SVGA3dCmdSetLightEnabled', (), None),
+    ('SVGA_3D_CMD_SETVIEWPORT', 'SVGA3dCmdSetViewport', (), None),
+    ('SVGA_3D_CMD_SETCLIPPLANE', 'SVGA3dCmdSetClipPlane', (), None),
+    ('SVGA_3D_CMD_CLEAR', 'SVGA3dCmdClear', (), 'SVGA3dRect'),
+    ('SVGA_3D_CMD_PRESENT', 'SVGA3dCmdPresent', (), 'SVGA3dCopyRect'),
+    ('SVGA_3D_CMD_SHADER_DEFINE', 'SVGA3dCmdDefineShader', (), None),
+    ('SVGA_3D_CMD_SHADER_DESTROY', 'SVGA3dCmdDestroyShader', (), None),
+    ('SVGA_3D_CMD_SET_SHADER', 'SVGA3dCmdSetShader', (), None),
+    ('SVGA_3D_CMD_SET_SHADER_CONST', 'SVGA3dCmdSetShaderConst', (), None),
+    ('SVGA_3D_CMD_DRAW_PRIMITIVES', 'SVGA3dCmdDrawPrimitives', (('SVGA3dVertexDecl', 'numVertexDecls'), ('SVGA3dPrimitiveRange', 'numRanges')), 'SVGA3dVertexDivisor'),
+    ('SVGA_3D_CMD_SETSCISSORRECT', 'SVGA3dCmdSetScissorRect', (), None),
+    ('SVGA_3D_CMD_BEGIN_QUERY', 'SVGA3dCmdBeginQuery', (), None),
+    ('SVGA_3D_CMD_END_QUERY', 'SVGA3dCmdEndQuery', (), None),
+    ('SVGA_3D_CMD_WAIT_FOR_QUERY', 'SVGA3dCmdWaitForQuery', (), None),
+    #('SVGA_3D_CMD_PRESENT_READBACK', None, (), None),
+    ('SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN', 'SVGA3dCmdBlitSurfaceToScreen', (), 'SVGASignedRect'),
+]
+
+def dump_cmds():
+    print r'''
+void            
+svga_dump_command(uint32_t cmd_id, const void *data, uint32_t size)
+{
+   const uint8_t *body = (const uint8_t *)data;
+   const uint8_t *next = body + size;
+'''
+    print '   switch(cmd_id) {'
+    indexes = 'ijklmn'
+    for id, header, body, footer in cmds:
+        print '   case %s:' % id
+        print '      _debug_printf("\\t%s\\n");' % id
+        print '      {'
+        print '         const %s *cmd = (const %s *)body;' % (header, header)
+        if len(body):
+            print '         unsigned ' + ', '.join(indexes[:len(body)]) + ';'
+        print '         dump_%s(cmd);' % header
+        print '         body = (const uint8_t *)&cmd[1];'
+        for i in range(len(body)):
+            struct, count = body[i]
+            idx = indexes[i]
+            print '         for(%s = 0; %s < cmd->%s; ++%s) {' % (idx, idx, count, idx)
+            print '            dump_%s((const %s *)body);' % (struct, struct)
+            print '            body += sizeof(%s);' % struct
+            print '         }'
+        if footer is not None:
+            print '         while(body + sizeof(%s) <= next) {' % footer
+            print '            dump_%s((const %s *)body);' % (footer, footer)
+            print '            body += sizeof(%s);' % footer
+            print '         }'
+        if id == 'SVGA_3D_CMD_SHADER_DEFINE':
+            print '         svga_shader_dump((const uint32_t *)body,'
+            print '                          (unsigned)(next - body)/sizeof(uint32_t),'
+            print '                          FALSE);'
+            print '         body = next;'
+        print '      }'
+        print '      break;'
+    print '   default:'
+    print '      _debug_printf("\\t0x%08x\\n", cmd_id);'
+    print '      break;'
+    print '   }'
+    print r'''
+   while(body + sizeof(uint32_t) <= next) {
+      _debug_printf("\t\t0x%08x\n", *(const uint32_t *)body);
+      body += sizeof(uint32_t);
+   }
+   while(body + sizeof(uint32_t) <= next)
+      _debug_printf("\t\t0x%02x\n", *body++);
+}
+'''
+    print r'''
+void            
+svga_dump_commands(const void *commands, uint32_t size)
+{
+   const uint8_t *next = commands;
+   const uint8_t *last = next + size;
+   
+   assert(size % sizeof(uint32_t) == 0);
+   
+   while(next < last) {
+      const uint32_t cmd_id = *(const uint32_t *)next;
+
+      if(SVGA_3D_CMD_BASE <= cmd_id && cmd_id < SVGA_3D_CMD_MAX) {
+         const SVGA3dCmdHeader *header = (const SVGA3dCmdHeader *)next;
+         const uint8_t *body = (const uint8_t *)&header[1];
+
+         next = body + header->size;
+         if(next > last)
+            break;
+
+         svga_dump_command(cmd_id, body, header->size);
+      }
+      else if(cmd_id == SVGA_CMD_FENCE) {
+         _debug_printf("\tSVGA_CMD_FENCE\n");
+         _debug_printf("\t\t0x%08x\n", ((const uint32_t *)next)[1]);
+         next += 2*sizeof(uint32_t);
+      }
+      else {
+         _debug_printf("\t0x%08x\n", cmd_id);
+         next += sizeof(uint32_t);
+      }
+   }
+}
+'''
+
+def main():
+    print copyright.strip()
+    print
+    print '/**'
+    print ' * @file'
+    print ' * Dump SVGA commands.'
+    print ' *'
+    print ' * Generated automatically from svga3d_reg.h by svga_dump.py.'
+    print ' */'
+    print
+    print '#include "svga_types.h"'
+    print '#include "svga_shader_dump.h"'
+    print '#include "svga3d_reg.h"'
+    print
+    print '#include "util/u_debug.h"'
+    print '#include "svga_dump.h"'
+    print
+
+    config = parser.config_t(
+        include_paths = ['../../../include', '../include'],
+        compiler = 'gcc',
+    )
+
+    headers = [
+        'svga_types.h', 
+        'svga3d_reg.h', 
+    ]
+
+    decls = parser.parse(headers, config, parser.COMPILATION_MODE.ALL_AT_ONCE)
+    global_ns = declarations.get_global_namespace(decls)
+
+    names = set()
+    for id, header, body, footer in cmds:
+        names.add(header)
+        for struct, count in body:
+            names.add(struct)
+        if footer is not None:
+            names.add(footer)
+
+    for class_ in global_ns.classes(lambda decl: decl.name in names):
+        dump_struct(decls, class_)
+
+    dump_cmds()
+
+
+if __name__ == '__main__':
+    main()
diff --git a/src/gallium/drivers/svga/svgadump/svga_shader.h b/src/gallium/drivers/svga/svgadump/svga_shader.h
new file mode 100644 (file)
index 0000000..9217af2
--- /dev/null
@@ -0,0 +1,220 @@
+/**********************************************************
+ * Copyright 2007-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+/**
+ * @file
+ * SVGA Shader Token Definitions
+ * 
+ * @author Michal Krol <michal@vmware.com>
+ */
+
+#ifndef ST_SHADER_SVGA_H
+#define ST_SHADER_SVGA_H
+
+#include "pipe/p_compiler.h"
+
+struct sh_op
+{
+   unsigned opcode:16;
+   unsigned control:8;
+   unsigned length:4;
+   unsigned predicated:1;
+   unsigned unused:1;
+   unsigned coissue:1;
+   unsigned is_reg:1;
+};
+
+struct sh_reg
+{
+   unsigned number:11;
+   unsigned type_hi:2;
+   unsigned relative:1;
+   unsigned unused:14;
+   unsigned type_lo:3;
+   unsigned is_reg:1;
+};
+
+static INLINE unsigned
+sh_reg_type( struct sh_reg reg )
+{
+   return reg.type_lo | (reg.type_hi << 3);
+}
+
+struct sh_cdata
+{
+   float xyzw[4];
+};
+
+struct sh_def
+{
+   struct sh_op op;
+   struct sh_reg reg;
+   struct sh_cdata cdata;
+};
+
+struct sh_defb
+{
+   struct sh_op op;
+   struct sh_reg reg;
+   uint data;
+};
+
+struct sh_idata
+{
+   int xyzw[4];
+};
+
+struct sh_defi
+{
+   struct sh_op op;
+   struct sh_reg reg;
+   struct sh_idata idata;
+};
+
+#define PS_TEXTURETYPE_UNKNOWN   SVGA3DSAMP_UNKNOWN
+#define PS_TEXTURETYPE_2D        SVGA3DSAMP_2D
+#define PS_TEXTURETYPE_CUBE      SVGA3DSAMP_CUBE
+#define PS_TEXTURETYPE_VOLUME    SVGA3DSAMP_VOLUME
+
+struct ps_sampleinfo
+{
+   unsigned unused:27;
+   unsigned texture_type:4;
+   unsigned is_reg:1;
+};
+
+struct vs_semantic
+{
+   unsigned usage:5;
+   unsigned unused1:11;
+   unsigned usage_index:4;
+   unsigned unused2:12;
+};
+
+struct sh_dstreg
+{
+   unsigned number:11;
+   unsigned type_hi:2;
+   unsigned relative:1;
+   unsigned unused:2;
+   unsigned write_mask:4;
+   unsigned modifier:4;
+   unsigned shift_scale:4;
+   unsigned type_lo:3;
+   unsigned is_reg:1;
+};
+
+static INLINE unsigned
+sh_dstreg_type( struct sh_dstreg reg )
+{
+   return reg.type_lo | (reg.type_hi << 3);
+}
+
+struct sh_dcl
+{
+   struct sh_op op;
+   union {
+      struct {
+         struct ps_sampleinfo sampleinfo;
+      } ps;
+      struct {
+         struct vs_semantic semantic;
+      } vs;
+   } u;
+   struct sh_dstreg reg;
+};
+
+
+struct sh_srcreg
+{
+   unsigned number:11;
+   unsigned type_hi:2;
+   unsigned relative:1;
+   unsigned unused:2;
+   unsigned swizzle_x:2;
+   unsigned swizzle_y:2;
+   unsigned swizzle_z:2;
+   unsigned swizzle_w:2;
+   unsigned modifier:4;
+   unsigned type_lo:3;
+   unsigned is_reg:1;
+};
+
+static INLINE unsigned
+sh_srcreg_type( struct sh_srcreg reg )
+{
+   return reg.type_lo | (reg.type_hi << 3);
+}
+
+struct sh_dstop
+{
+   struct sh_op op;
+   struct sh_dstreg dst;
+};
+
+struct sh_srcop
+{
+   struct sh_op op;
+   struct sh_srcreg src;
+};
+
+struct sh_src2op
+{
+   struct sh_op op;
+   struct sh_srcreg src0;
+   struct sh_srcreg src1;
+};
+
+struct sh_unaryop
+{
+   struct sh_op op;
+   struct sh_dstreg dst;
+   struct sh_srcreg src;
+};
+
+struct sh_binaryop
+{
+   struct sh_op op;
+   struct sh_dstreg dst;
+   struct sh_srcreg src0;
+   struct sh_srcreg src1;
+};
+
+struct sh_trinaryop
+{
+   struct sh_op op;
+   struct sh_dstreg dst;
+   struct sh_srcreg src0;
+   struct sh_srcreg src1;
+   struct sh_srcreg src2;
+};
+
+struct sh_comment
+{
+   unsigned opcode:16;
+   unsigned size:16;
+};
+
+#endif /* ST_SHADER_SVGA_H */
diff --git a/src/gallium/drivers/svga/svgadump/svga_shader_dump.c b/src/gallium/drivers/svga/svgadump/svga_shader_dump.c
new file mode 100644 (file)
index 0000000..70e27d8
--- /dev/null
@@ -0,0 +1,654 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+/**
+ * @file
+ * SVGA Shader Dump Facilities
+ * 
+ * @author Michal Krol <michal@vmware.com>
+ */
+
+#include "svga_shader.h"
+#include "svga_shader_dump.h"
+#include "svga_shader_op.h"
+#include "util/u_debug.h"
+
+#include "../svga_hw_reg.h"
+#include "svga3d_shaderdefs.h"
+
+struct dump_info
+{
+   SVGA3dShaderVersion version;
+   boolean is_ps;
+};
+
+static void dump_op( struct sh_op op, const char *mnemonic )
+{
+   assert( op.predicated == 0 );
+   assert( op.is_reg == 0 );
+
+   if (op.coissue)
+      _debug_printf( "+" );
+   _debug_printf( "%s", mnemonic );
+   switch (op.control) {
+   case 0:
+      break;
+   case SVGA3DOPCONT_PROJECT:
+      _debug_printf( "p" );
+      break;
+   case SVGA3DOPCONT_BIAS:
+      _debug_printf( "b" );
+      break;
+   default:
+      assert( 0 );
+   }
+}
+
+
+static void dump_comp_op( struct sh_op op, const char *mnemonic )
+{
+   assert( op.is_reg == 0 );
+
+   if (op.coissue)
+      _debug_printf( "+" );
+   _debug_printf( "%s", mnemonic );
+   switch (op.control) {
+   case SVGA3DOPCOMP_RESERVED0:
+      break;
+   case SVGA3DOPCOMP_GT:
+      _debug_printf("_gt");
+      break;
+   case SVGA3DOPCOMP_EQ:
+      _debug_printf("_eq");
+      break;
+   case SVGA3DOPCOMP_GE:
+      _debug_printf("_ge");
+      break;
+   case SVGA3DOPCOMP_LT:
+      _debug_printf("_lt");
+      break;
+   case SVGA3DOPCOMPC_NE:
+      _debug_printf("_ne");
+      break;
+   case SVGA3DOPCOMP_LE:
+      _debug_printf("_le");
+      break;
+   case SVGA3DOPCOMP_RESERVED1:
+   default:
+      assert( 0 );
+   }
+}
+
+
+static void dump_reg( struct sh_reg reg, struct sh_srcreg *indreg, const struct dump_info *di )
+{
+   assert( sh_reg_type( reg ) == SVGA3DREG_CONST || reg.relative == 0 );
+   assert( reg.is_reg == 1 );
+
+   switch (sh_reg_type( reg )) {
+   case SVGA3DREG_TEMP:
+      _debug_printf( "r%u", reg.number );
+      break;
+
+   case SVGA3DREG_INPUT:
+      _debug_printf( "v%u", reg.number );
+      break;
+
+   case SVGA3DREG_CONST:
+      if (reg.relative) {
+         if (sh_srcreg_type( *indreg ) == SVGA3DREG_LOOP)
+            _debug_printf( "c[aL+%u]", reg.number );
+         else
+            _debug_printf( "c[a%u.x+%u]", indreg->number, reg.number );
+      }
+      else
+         _debug_printf( "c%u", reg.number );
+      break;
+
+   case SVGA3DREG_ADDR:    /* VS */
+   /* SVGA3DREG_TEXTURE */ /* PS */
+      if (di->is_ps)
+         _debug_printf( "t%u", reg.number );
+      else
+         _debug_printf( "a%u", reg.number );
+      break;
+
+   case SVGA3DREG_RASTOUT:
+      switch (reg.number) {
+      case 0 /*POSITION*/:
+         _debug_printf( "oPos" );
+         break;
+      case 1 /*FOG*/:
+         _debug_printf( "oFog" );
+         break;
+      case 2 /*POINT_SIZE*/:
+         _debug_printf( "oPts" );
+         break;
+      default:
+         assert( 0 );
+         _debug_printf( "???" );
+      }
+      break;
+
+   case SVGA3DREG_ATTROUT:
+      assert( reg.number < 2 );
+      _debug_printf( "oD%u", reg.number );
+      break;
+
+   case SVGA3DREG_TEXCRDOUT:
+   /* SVGA3DREG_OUTPUT */
+      _debug_printf( "oT%u", reg.number );
+      break;
+
+   case SVGA3DREG_COLOROUT:
+      _debug_printf( "oC%u", reg.number );
+      break;
+
+   case SVGA3DREG_DEPTHOUT:
+      _debug_printf( "oD%u", reg.number );
+      break;
+
+   case SVGA3DREG_SAMPLER:
+      _debug_printf( "s%u", reg.number );
+      break;
+
+   case SVGA3DREG_CONSTBOOL:
+      assert( !reg.relative );
+      _debug_printf( "b%u", reg.number );
+      break;
+
+   case SVGA3DREG_CONSTINT:
+      assert( !reg.relative );
+      _debug_printf( "i%u", reg.number );
+      break;
+
+   case SVGA3DREG_LOOP:
+      assert( reg.number == 0 );
+      _debug_printf( "aL" );
+      break;
+
+   case SVGA3DREG_MISCTYPE:
+      switch (reg.number) {
+      case SVGA3DMISCREG_POSITION:
+         _debug_printf( "vPos" );
+         break;
+      case SVGA3DMISCREG_FACE:
+         _debug_printf( "vFace" );
+         break;
+      default:
+         assert(0);
+         break;
+      }
+      break;
+
+   case SVGA3DREG_LABEL:
+      _debug_printf( "l%u", reg.number );
+      break;
+
+   case SVGA3DREG_PREDICATE:
+      _debug_printf( "p%u", reg.number );
+      break;
+
+
+   default:
+      assert( 0 );
+      _debug_printf( "???" );
+   }
+}
+
+static void dump_cdata( struct sh_cdata cdata )
+{
+   _debug_printf( "%f, %f, %f, %f", cdata.xyzw[0], cdata.xyzw[1], cdata.xyzw[2], cdata.xyzw[3] );
+}
+
+static void dump_idata( struct sh_idata idata )
+{
+   _debug_printf( "%d, %d, %d, %d", idata.xyzw[0], idata.xyzw[1], idata.xyzw[2], idata.xyzw[3] );
+}
+
+static void dump_bdata( boolean bdata )
+{
+   _debug_printf( bdata ? "TRUE" : "FALSE" );
+}
+
+static void dump_sampleinfo( struct ps_sampleinfo sampleinfo )
+{
+   switch (sampleinfo.texture_type) {
+   case SVGA3DSAMP_2D:
+      _debug_printf( "_2d" );
+      break;
+   case SVGA3DSAMP_CUBE:
+      _debug_printf( "_cube" );
+      break;
+   case SVGA3DSAMP_VOLUME:
+      _debug_printf( "_volume" );
+      break;
+   default:
+      assert( 0 );
+   }
+}
+
+
+static void dump_usageinfo( struct vs_semantic semantic )
+{
+   switch (semantic.usage) {
+   case SVGA3D_DECLUSAGE_POSITION:
+      _debug_printf("_position" );
+      break;
+   case SVGA3D_DECLUSAGE_BLENDWEIGHT:
+      _debug_printf("_blendweight" );
+      break;
+   case SVGA3D_DECLUSAGE_BLENDINDICES:
+      _debug_printf("_blendindices" );
+      break;
+   case SVGA3D_DECLUSAGE_NORMAL:
+      _debug_printf("_normal" );
+      break;
+   case SVGA3D_DECLUSAGE_PSIZE:
+      _debug_printf("_psize" );
+      break;
+   case SVGA3D_DECLUSAGE_TEXCOORD:
+      _debug_printf("_texcoord");
+      break;
+   case SVGA3D_DECLUSAGE_TANGENT:
+      _debug_printf("_tangent" );
+      break;
+   case SVGA3D_DECLUSAGE_BINORMAL:
+      _debug_printf("_binormal" );
+      break;
+   case SVGA3D_DECLUSAGE_TESSFACTOR:
+      _debug_printf("_tessfactor" );
+      break;
+   case SVGA3D_DECLUSAGE_POSITIONT:
+      _debug_printf("_positiont" );
+      break;
+   case SVGA3D_DECLUSAGE_COLOR:
+      _debug_printf("_color" );
+      break;
+   case SVGA3D_DECLUSAGE_FOG:
+      _debug_printf("_fog" );
+      break;
+   case SVGA3D_DECLUSAGE_DEPTH:
+      _debug_printf("_depth" );
+      break;
+   case SVGA3D_DECLUSAGE_SAMPLE:
+      _debug_printf("_sample");
+      break;
+   default:
+      assert( 0 );
+      return;
+   }
+
+   if (semantic.usage_index != 0) {
+      _debug_printf("%d", semantic.usage_index );
+   }
+}
+
+static void dump_dstreg( struct sh_dstreg dstreg, const struct dump_info *di )
+{
+   union {
+      struct sh_reg reg;
+      struct sh_dstreg dstreg;
+   } u;
+
+   assert( (dstreg.modifier & (SVGA3DDSTMOD_SATURATE | SVGA3DDSTMOD_PARTIALPRECISION)) == dstreg.modifier );
+
+   if (dstreg.modifier & SVGA3DDSTMOD_SATURATE)
+      _debug_printf( "_sat" );
+   if (dstreg.modifier & SVGA3DDSTMOD_PARTIALPRECISION)
+      _debug_printf( "_pp" );
+   switch (dstreg.shift_scale) {
+   case 0:
+      break;
+   case 1:
+      _debug_printf( "_x2" );
+      break;
+   case 2:
+      _debug_printf( "_x4" );
+      break;
+   case 3:
+      _debug_printf( "_x8" );
+      break;
+   case 13:
+      _debug_printf( "_d8" );
+      break;
+   case 14:
+      _debug_printf( "_d4" );
+      break;
+   case 15:
+      _debug_printf( "_d2" );
+      break;
+   default:
+      assert( 0 );
+   }
+   _debug_printf( " " );
+
+   u.dstreg = dstreg;
+   dump_reg( u.reg, NULL, di );
+   if (dstreg.write_mask != SVGA3DWRITEMASK_ALL) {
+      _debug_printf( "." );
+      if (dstreg.write_mask & SVGA3DWRITEMASK_0)
+         _debug_printf( "x" );
+      if (dstreg.write_mask & SVGA3DWRITEMASK_1)
+         _debug_printf( "y" );
+      if (dstreg.write_mask & SVGA3DWRITEMASK_2)
+         _debug_printf( "z" );
+      if (dstreg.write_mask & SVGA3DWRITEMASK_3)
+         _debug_printf( "w" );
+   }
+}
+
+static void dump_srcreg( struct sh_srcreg srcreg, struct sh_srcreg *indreg, const struct dump_info *di )
+{
+   union {
+      struct sh_reg reg;
+      struct sh_srcreg srcreg;
+   } u;
+
+   switch (srcreg.modifier) {
+   case SVGA3DSRCMOD_NEG:
+   case SVGA3DSRCMOD_BIASNEG:
+   case SVGA3DSRCMOD_SIGNNEG:
+   case SVGA3DSRCMOD_X2NEG:
+      _debug_printf( "-" );
+      break;
+   case SVGA3DSRCMOD_ABS:
+      _debug_printf( "|" );
+      break;
+   case SVGA3DSRCMOD_ABSNEG:
+      _debug_printf( "-|" );
+      break;
+   case SVGA3DSRCMOD_COMP:
+      _debug_printf( "1-" );
+      break;
+   case SVGA3DSRCMOD_NOT:
+      _debug_printf( "!" );
+   }
+
+   u.srcreg = srcreg;
+   dump_reg( u.reg, indreg, di );
+   switch (srcreg.modifier) {
+   case SVGA3DSRCMOD_NONE:
+   case SVGA3DSRCMOD_NEG:
+   case SVGA3DSRCMOD_COMP:
+   case SVGA3DSRCMOD_NOT:
+      break;
+   case SVGA3DSRCMOD_ABS:
+   case SVGA3DSRCMOD_ABSNEG:
+      _debug_printf( "|" );
+      break;
+   case SVGA3DSRCMOD_BIAS:
+   case SVGA3DSRCMOD_BIASNEG:
+      _debug_printf( "_bias" );
+      break;
+   case SVGA3DSRCMOD_SIGN:
+   case SVGA3DSRCMOD_SIGNNEG:
+      _debug_printf( "_bx2" );
+      break;
+   case SVGA3DSRCMOD_X2:
+   case SVGA3DSRCMOD_X2NEG:
+      _debug_printf( "_x2" );
+      break;
+   case SVGA3DSRCMOD_DZ:
+      _debug_printf( "_dz" );
+      break;
+   case SVGA3DSRCMOD_DW:
+      _debug_printf( "_dw" );
+      break;
+   default:
+      assert( 0 );
+   }
+   if (srcreg.swizzle_x != 0 || srcreg.swizzle_y != 1 || srcreg.swizzle_z != 2 || srcreg.swizzle_w != 3) {
+      _debug_printf( "." );
+      if (srcreg.swizzle_x == srcreg.swizzle_y && srcreg.swizzle_y == srcreg.swizzle_z && srcreg.swizzle_z == srcreg.swizzle_w) {
+         _debug_printf( "%c", "xyzw"[srcreg.swizzle_x] );
+      }
+      else {
+         _debug_printf( "%c", "xyzw"[srcreg.swizzle_x] );
+         _debug_printf( "%c", "xyzw"[srcreg.swizzle_y] );
+         _debug_printf( "%c", "xyzw"[srcreg.swizzle_z] );
+         _debug_printf( "%c", "xyzw"[srcreg.swizzle_w] );
+      }
+   }
+}
+
+void
+svga_shader_dump(
+   const unsigned *assem,
+   unsigned dwords,
+   unsigned do_binary )
+{
+   const unsigned *start = assem;
+   boolean finished = FALSE;
+   struct dump_info di;
+   unsigned i;
+
+   if (do_binary) {
+      for (i = 0; i < dwords; i++) 
+         _debug_printf("  0x%08x,\n", assem[i]);
+      
+      _debug_printf("\n\n");
+   }
+
+   di.version.value = *assem++;
+   di.is_ps = (di.version.type == SVGA3D_PS_TYPE);
+
+   _debug_printf(
+      "%s_%u_%u\n",
+      di.is_ps ? "ps" : "vs",
+      di.version.major,
+      di.version.minor );
+
+   while (!finished) {
+      struct sh_op op = *(struct sh_op *) assem;
+
+      if (assem - start >= dwords) {
+         _debug_printf("... ran off end of buffer\n");
+         assert(0);
+         return;
+      }
+
+      switch (op.opcode) {
+      case SVGA3DOP_DCL:
+         {
+            struct sh_dcl dcl = *(struct sh_dcl *) assem;
+
+            _debug_printf( "dcl" );
+            if (sh_dstreg_type( dcl.reg ) == SVGA3DREG_SAMPLER)
+               dump_sampleinfo( dcl.u.ps.sampleinfo );
+            else if (di.is_ps) {
+               if (di.version.major == 3 && 
+                   sh_dstreg_type( dcl.reg ) != SVGA3DREG_MISCTYPE)
+                  dump_usageinfo( dcl.u.vs.semantic );
+            }
+            else
+               dump_usageinfo( dcl.u.vs.semantic );
+            dump_dstreg( dcl.reg, &di );
+            _debug_printf( "\n" );
+            assem += sizeof( struct sh_dcl ) / sizeof( unsigned );
+         }
+         break;
+
+      case SVGA3DOP_DEFB:
+         {
+            struct sh_defb defb = *(struct sh_defb *) assem;
+
+            _debug_printf( "defb " );
+            dump_reg( defb.reg, NULL, &di );
+            _debug_printf( ", " );
+            dump_bdata( defb.data );
+            _debug_printf( "\n" );
+            assem += sizeof( struct sh_defb ) / sizeof( unsigned );
+         }
+         break;
+
+      case SVGA3DOP_DEFI:
+         {
+            struct sh_defi defi = *(struct sh_defi *) assem;
+
+            _debug_printf( "defi " );
+            dump_reg( defi.reg, NULL, &di );
+            _debug_printf( ", " );
+            dump_idata( defi.idata );
+            _debug_printf( "\n" );
+            assem += sizeof( struct sh_defi ) / sizeof( unsigned );
+         }
+         break;
+
+      case SVGA3DOP_TEXCOORD:
+         assert( di.is_ps );
+         dump_op( op, "texcoord" );
+         if (0) {
+            struct sh_dstop dstop = *(struct sh_dstop *) assem;
+            dump_dstreg( dstop.dst, &di );
+            assem += sizeof( struct sh_dstop ) / sizeof( unsigned );
+         }
+         else {
+            struct sh_unaryop unaryop = *(struct sh_unaryop *) assem;
+            dump_dstreg( unaryop.dst, &di );
+            _debug_printf( ", " );
+            dump_srcreg( unaryop.src, NULL, &di );
+            assem += sizeof( struct sh_unaryop ) / sizeof( unsigned );
+         }
+         _debug_printf( "\n" );
+         break;
+
+      case SVGA3DOP_TEX:
+         assert( di.is_ps );
+         if (0) {
+            dump_op( op, "tex" );
+            if (0) {
+               struct sh_dstop dstop = *(struct sh_dstop *) assem;
+
+               dump_dstreg( dstop.dst, &di );
+               assem += sizeof( struct sh_dstop ) / sizeof( unsigned );
+            }
+            else {
+               struct sh_unaryop unaryop = *(struct sh_unaryop *) assem;
+
+               dump_dstreg( unaryop.dst, &di );
+               _debug_printf( ", " );
+               dump_srcreg( unaryop.src, NULL, &di );
+               assem += sizeof( struct sh_unaryop ) / sizeof( unsigned );
+            }
+         }
+         else {
+            struct sh_binaryop binaryop = *(struct sh_binaryop *) assem;
+
+            dump_op( op, "texld" );
+            dump_dstreg( binaryop.dst, &di );
+            _debug_printf( ", " );
+            dump_srcreg( binaryop.src0, NULL, &di );
+            _debug_printf( ", " );
+            dump_srcreg( binaryop.src1, NULL, &di );
+            assem += sizeof( struct sh_binaryop ) / sizeof( unsigned );
+         }
+         _debug_printf( "\n" );
+         break;
+
+      case SVGA3DOP_DEF:
+         {
+            struct sh_def def = *(struct sh_def *) assem;
+
+            _debug_printf( "def " );
+            dump_reg( def.reg, NULL, &di );
+            _debug_printf( ", " );
+            dump_cdata( def.cdata );
+            _debug_printf( "\n" );
+            assem += sizeof( struct sh_def ) / sizeof( unsigned );
+         }
+         break;
+
+      case SVGA3DOP_PHASE:
+         _debug_printf( "phase\n" );
+         assem += sizeof( struct sh_op ) / sizeof( unsigned );
+         break;
+
+      case SVGA3DOP_COMMENT:
+         {
+            struct sh_comment comment = *(struct sh_comment *)assem;
+
+            /* Ignore comment contents. */
+            assem += sizeof(struct sh_comment) / sizeof(unsigned) + comment.size;
+         }
+         break;
+
+      case SVGA3DOP_RET:
+         _debug_printf( "ret\n" );
+         assem += sizeof( struct sh_op ) / sizeof( unsigned );
+         break;
+
+      case SVGA3DOP_END:
+         _debug_printf( "end\n" );
+         finished = TRUE;
+         break;
+
+      default:
+         {
+            const struct sh_opcode_info *info = svga_opcode_info( op.opcode );
+            uint i;
+            uint num_src = info->num_src + op.predicated;
+            boolean not_first_arg = FALSE;
+
+            assert( info->num_dst <= 1 );
+
+            if (op.opcode == SVGA3DOP_SINCOS && di.version.major < 3)
+               num_src += 2;
+
+            dump_comp_op( op, info->mnemonic );
+            assem += sizeof( struct sh_op ) / sizeof( unsigned );
+
+            if (info->num_dst > 0) {
+               struct sh_dstreg dstreg = *(struct sh_dstreg *) assem;
+
+               dump_dstreg( dstreg, &di );
+               assem += sizeof( struct sh_dstreg ) / sizeof( unsigned );
+               not_first_arg = TRUE;
+            }
+
+            for (i = 0; i < num_src; i++) {
+               struct sh_srcreg srcreg;
+               struct sh_srcreg indreg;
+
+               srcreg = *(struct sh_srcreg *) assem;
+               assem += sizeof( struct sh_srcreg ) / sizeof( unsigned );
+               if (srcreg.relative && !di.is_ps && di.version.major >= 2) {
+                  indreg = *(struct sh_srcreg *) assem;
+                  assem += sizeof( struct sh_srcreg ) / sizeof( unsigned );
+               }
+
+               if (not_first_arg)
+                  _debug_printf( ", " );
+               else
+                  _debug_printf( " " );
+               dump_srcreg( srcreg, &indreg, &di );
+               not_first_arg = TRUE;
+            }
+
+            _debug_printf( "\n" );
+         }
+      }
+   }
+}
diff --git a/src/gallium/drivers/svga/svgadump/svga_shader_dump.h b/src/gallium/drivers/svga/svgadump/svga_shader_dump.h
new file mode 100644 (file)
index 0000000..a2657ac
--- /dev/null
@@ -0,0 +1,42 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+/**
+ * @file
+ * SVGA Shader Dump Facilities
+ * 
+ * @author Michal Krol <michal@vmware.com>
+ */
+
+#ifndef SVGA_SHADER_DUMP_H
+#define SVGA_SHADER_DUMP_H
+
+void
+svga_shader_dump(
+   const unsigned *assem,
+   unsigned dwords,
+   unsigned do_binary );
+
+#endif /* SVGA_SHADER_DUMP_H */
diff --git a/src/gallium/drivers/svga/svgadump/svga_shader_op.c b/src/gallium/drivers/svga/svgadump/svga_shader_op.c
new file mode 100644 (file)
index 0000000..8343bfd
--- /dev/null
@@ -0,0 +1,168 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+/**
+ * @file
+ * SVGA Shader Token Opcode Info
+ * 
+ * @author Michal Krol <michal@vmware.com>
+ */
+
+#include "util/u_debug.h"
+#include "svga_shader_op.h"
+
+#include "../svga_hw_reg.h"
+#include "svga3d_shaderdefs.h"
+
+#define SVGA3DOP_INVALID SVGA3DOP_END
+#define TGSI_OPCODE_INVALID TGSI_OPCODE_LAST
+
+static struct sh_opcode_info opcode_info[] =
+{
+   { "nop",          0, 0, SVGA3DOP_NOP          },
+   { "mov",          1, 1, SVGA3DOP_MOV,         },
+   { "add",          1, 2, SVGA3DOP_ADD,         },
+   { "sub",          1, 2, SVGA3DOP_SUB,         },
+   { "mad",          1, 3, SVGA3DOP_MAD,         },
+   { "mul",          1, 2, SVGA3DOP_MUL,         },
+   { "rcp",          1, 1, SVGA3DOP_RCP,         },
+   { "rsq",          1, 1, SVGA3DOP_RSQ,         },
+   { "dp3",          1, 2, SVGA3DOP_DP3,         },
+   { "dp4",          1, 2, SVGA3DOP_DP4,         },
+   { "min",          1, 2, SVGA3DOP_MIN,         },
+   { "max",          1, 2, SVGA3DOP_MAX,         },
+   { "slt",          1, 2, SVGA3DOP_SLT,         },
+   { "sge",          1, 2, SVGA3DOP_SGE,         },
+   { "exp",          1, 1, SVGA3DOP_EXP,         },
+   { "log",          1, 1, SVGA3DOP_LOG,         },
+   { "lit",          1, 1, SVGA3DOP_LIT,         },
+   { "dst",          1, 2, SVGA3DOP_DST,         },
+   { "lrp",          1, 3, SVGA3DOP_LRP,         },
+   { "frc",          1, 1, SVGA3DOP_FRC,         },
+   { "m4x4",         1, 2, SVGA3DOP_M4x4,        },
+   { "m4x3",         1, 2, SVGA3DOP_M4x3,        },
+   { "m3x4",         1, 2, SVGA3DOP_M3x4,        },
+   { "m3x3",         1, 2, SVGA3DOP_M3x3,        },
+   { "m3x2",         1, 2, SVGA3DOP_M3x2,        },
+   { "call",         0, 1, SVGA3DOP_CALL,        },
+   { "callnz",       0, 2, SVGA3DOP_CALLNZ,      },
+   { "loop",         0, 2, SVGA3DOP_LOOP,        },
+   { "ret",          0, 0, SVGA3DOP_RET,         },
+   { "endloop",      0, 0, SVGA3DOP_ENDLOOP,     },
+   { "label",        0, 1, SVGA3DOP_LABEL,       },
+   { "dcl",          0, 0, SVGA3DOP_DCL,         },
+   { "pow",          1, 2, SVGA3DOP_POW,         },
+   { "crs",          1, 2, SVGA3DOP_CRS,         },
+   { "sgn",          1, 3, SVGA3DOP_SGN,         },
+   { "abs",          1, 1, SVGA3DOP_ABS,         },
+   { "nrm",          1, 1, SVGA3DOP_NRM,         }, /* 3-componenet normalization */
+   { "sincos",       1, 1, SVGA3DOP_SINCOS,      },
+   { "rep",          0, 1, SVGA3DOP_REP,         },
+   { "endrep",       0, 0, SVGA3DOP_ENDREP,      },
+   { "if",           0, 1, SVGA3DOP_IF,          },
+   { "ifc",          0, 2, SVGA3DOP_IFC,         },
+   { "else",         0, 0, SVGA3DOP_ELSE,        },
+   { "endif",        0, 0, SVGA3DOP_ENDIF,       },
+   { "break",        0, 0, SVGA3DOP_BREAK,       },
+   { "breakc",       0, 0, SVGA3DOP_BREAKC,      },
+   { "mova",         1, 1, SVGA3DOP_MOVA,        },
+   { "defb",         0, 0, SVGA3DOP_DEFB,        },
+   { "defi",         0, 0, SVGA3DOP_DEFI,        },
+   { "???",          0, 0, SVGA3DOP_INVALID,     },
+   { "???",          0, 0, SVGA3DOP_INVALID,     },
+   { "???",          0, 0, SVGA3DOP_INVALID,     },
+   { "???",          0, 0, SVGA3DOP_INVALID,     },
+   { "???",          0, 0, SVGA3DOP_INVALID,     },
+   { "???",          0, 0, SVGA3DOP_INVALID,     },
+   { "???",          0, 0, SVGA3DOP_INVALID,     },
+   { "???",          0, 0, SVGA3DOP_INVALID,     },
+   { "???",          0, 0, SVGA3DOP_INVALID,     },
+   { "???",          0, 0, SVGA3DOP_INVALID,     },
+   { "???",          0, 0, SVGA3DOP_INVALID,     },
+   { "???",          0, 0, SVGA3DOP_INVALID,     },
+   { "???",          0, 0, SVGA3DOP_INVALID,     },
+   { "???",          0, 0, SVGA3DOP_INVALID,     },
+   { "???",          0, 0, SVGA3DOP_INVALID,     },
+   { "texcoord",     0, 0, SVGA3DOP_TEXCOORD,    },
+   { "texkill",      1, 0, SVGA3DOP_TEXKILL,     },
+   { "tex",          0, 0, SVGA3DOP_TEX,         },
+   { "texbem",       1, 1, SVGA3DOP_TEXBEM,      },
+   { "texbeml",      1, 1, SVGA3DOP_TEXBEML,     },
+   { "texreg2ar",    1, 1, SVGA3DOP_TEXREG2AR,   },
+   { "texreg2gb",    1, 1, SVGA3DOP_TEXREG2GB,   },
+   { "texm3x2pad",   1, 1, SVGA3DOP_TEXM3x2PAD,  },
+   { "texm3x2tex",   1, 1, SVGA3DOP_TEXM3x2TEX,  },
+   { "texm3x3pad",   1, 1, SVGA3DOP_TEXM3x3PAD,  },
+   { "texm3x3tex",   1, 1, SVGA3DOP_TEXM3x3TEX,  },
+   { "reserved0",    0, 0, SVGA3DOP_RESERVED0,   },
+   { "texm3x3spec",  1, 2, SVGA3DOP_TEXM3x3SPEC, },
+   { "texm3x3vspec", 1, 1, SVGA3DOP_TEXM3x3VSPEC,},
+   { "expp",         1, 1, SVGA3DOP_EXPP,        },
+   { "logp",         1, 1, SVGA3DOP_LOGP,        },
+   { "cnd",          1, 3, SVGA3DOP_CND,         },
+   { "def",          0, 0, SVGA3DOP_DEF,         },
+   { "texreg2rgb",   1, 1, SVGA3DOP_TEXREG2RGB,  },
+   { "texdp3tex",    1, 1, SVGA3DOP_TEXDP3TEX,   },
+   { "texm3x2depth", 1, 1, SVGA3DOP_TEXM3x2DEPTH,},
+   { "texdp3",       1, 1, SVGA3DOP_TEXDP3,      },
+   { "texm3x3",      1, 1, SVGA3DOP_TEXM3x3,     },
+   { "texdepth",     1, 0, SVGA3DOP_TEXDEPTH,    },
+   { "cmp",          1, 3, SVGA3DOP_CMP,         },
+   { "bem",          1, 2, SVGA3DOP_BEM,         },
+   { "dp2add",       1, 3, SVGA3DOP_DP2ADD,      },
+   { "dsx",          1, 1, SVGA3DOP_INVALID,     },
+   { "dsy",          1, 1, SVGA3DOP_INVALID,     },
+   { "texldd",       1, 1, SVGA3DOP_INVALID,     },
+   { "setp",         1, 2, SVGA3DOP_SETP,        },
+   { "texldl",       1, 1, SVGA3DOP_INVALID,     },
+   { "breakp",       1, 1, SVGA3DOP_INVALID,     },
+};
+
+const struct sh_opcode_info *svga_opcode_info( uint op )
+{
+   struct sh_opcode_info *info;
+
+   if (op >= sizeof( opcode_info ) / sizeof( opcode_info[0] )) {
+      /* The opcode is either PHASE, COMMENT, END or out of range.
+       */
+      assert( 0 );
+      return NULL;
+   }
+
+   info = &opcode_info[op];
+
+   if (info->svga_opcode == SVGA3DOP_INVALID) {
+      /* No valid information. Please provide number of dst/src registers.
+       */
+      assert( 0 );
+      return NULL;
+   }
+
+   /* Sanity check.
+    */
+   assert( op == info->svga_opcode );
+
+   return info;
+}
diff --git a/src/gallium/drivers/svga/svgadump/svga_shader_op.h b/src/gallium/drivers/svga/svgadump/svga_shader_op.h
new file mode 100644 (file)
index 0000000..e558de0
--- /dev/null
@@ -0,0 +1,46 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+/**
+ * @file
+ * SVGA Shader Token Opcode Info
+ * 
+ * @author Michal Krol <michal@vmware.com>
+ */
+
+#ifndef SVGA_SHADER_OP_H
+#define SVGA_SHADER_OP_H
+
+struct sh_opcode_info
+{
+   const char *mnemonic;
+   unsigned num_dst:8;
+   unsigned num_src:8;
+   unsigned svga_opcode:16;
+};
+
+const struct sh_opcode_info *svga_opcode_info( unsigned op );
+
+#endif /* SVGA_SHADER_OP_H */
index 1000c31e49aa9da084d0b354066ec8b79e22fd7c..203c3851bc3ccf779ab2ccb25be6238a216e4bbc 100644 (file)
@@ -24,11 +24,10 @@ ensure the right libGL.so is being picked by doing
 
  ldd progs/trivial/tri 
 
-== Traceing ==
+== Tracing ==
 
-For traceing then do
+For tracing then do
 
- export XMESA_TRACE=y
  GALLIUM_TRACE=tri.trace progs/trivial/tri
 
 which should create a tri.trace file, which is an XML file. You can view copying 
index bf470b46ae1d01d753995e588ccf2c89228e6017..075e4f9a0b2d02087ab2ce5f378ab947ad24c7a1 100644 (file)
@@ -52,6 +52,7 @@ trace_buffer_unwrap(struct trace_context *tr_ctx,
 
    assert(tr_buf->buffer);
    assert(tr_buf->buffer->screen == tr_scr->screen);
+   (void) tr_scr;
    return tr_buf->buffer;
 }
 
@@ -90,29 +91,11 @@ trace_surface_unwrap(struct trace_context *tr_ctx,
 
    assert(tr_surf->surface);
    assert(tr_surf->surface->texture->screen == tr_scr->screen);
+   (void) tr_scr;
    return tr_surf->surface;
 }
 
 
-static INLINE void
-trace_context_set_edgeflags(struct pipe_context *_pipe,
-                            const unsigned *bitfield)
-{
-   struct trace_context *tr_ctx = trace_context(_pipe);
-   struct pipe_context *pipe = tr_ctx->pipe;
-
-   trace_dump_call_begin("pipe_context", "set_edgeflags");
-
-   trace_dump_arg(ptr, pipe);
-   /* FIXME: we don't know how big this array is */
-   trace_dump_arg(ptr, bitfield);
-
-   pipe->set_edgeflags(pipe, bitfield);;
-
-   trace_dump_call_end();
-}
-
-
 static INLINE void
 trace_context_draw_block(struct trace_context *tr_ctx, int flag)
 {
@@ -143,10 +126,16 @@ trace_context_draw_block(struct trace_context *tr_ctx, int flag)
          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)
+      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;
+         for (k = 0; k < tr_ctx->curr.num_vert_texs; k++) {
+            if (tr_ctx->draw_rule.tex == tr_ctx->curr.vert_tex[k]) {
+               block = TRUE;
+            }
+         }
+      }
 
       if (block)
          tr_ctx->draw_blocked |= (flag | 4);
@@ -172,16 +161,15 @@ trace_context_draw_block(struct trace_context *tr_ctx, int flag)
    pipe_mutex_unlock(tr_ctx->draw_mutex);
 }
 
-static INLINE boolean
+static INLINE void
 trace_context_draw_arrays(struct pipe_context *_pipe,
                           unsigned mode, unsigned start, unsigned count)
 {
    struct trace_context *tr_ctx = trace_context(_pipe);
    struct pipe_context *pipe = tr_ctx->pipe;
-   boolean result;
 
    if (tr_ctx->curr.fs->disabled || tr_ctx->curr.vs->disabled)
-      return 0;
+      return;
 
    trace_context_draw_block(tr_ctx, 1);
 
@@ -192,19 +180,15 @@ trace_context_draw_arrays(struct pipe_context *_pipe,
    trace_dump_arg(uint, start);
    trace_dump_arg(uint, count);
 
-   result = pipe->draw_arrays(pipe, mode, start, count);;
-
-   trace_dump_ret(bool, result);
+   pipe->draw_arrays(pipe, mode, start, count);
 
    trace_dump_call_end();
 
    trace_context_draw_block(tr_ctx, 2);
-
-   return result;
 }
 
 
-static INLINE boolean
+static INLINE void
 trace_context_draw_elements(struct pipe_context *_pipe,
                           struct pipe_buffer *_indexBuffer,
                           unsigned indexSize,
@@ -214,10 +198,9 @@ trace_context_draw_elements(struct pipe_context *_pipe,
    struct trace_buffer *tr_buf = trace_buffer(_indexBuffer);
    struct pipe_context *pipe = tr_ctx->pipe;
    struct pipe_buffer *indexBuffer = tr_buf->buffer;
-   boolean result;
 
    if (tr_ctx->curr.fs->disabled || tr_ctx->curr.vs->disabled)
-      return 0;
+      return;
 
    trace_context_draw_block(tr_ctx, 1);
 
@@ -232,19 +215,15 @@ trace_context_draw_elements(struct pipe_context *_pipe,
    trace_dump_arg(uint, start);
    trace_dump_arg(uint, count);
 
-   result = pipe->draw_elements(pipe, indexBuffer, indexSize, mode, start, count);;
-
-   trace_dump_ret(bool, result);
+   pipe->draw_elements(pipe, indexBuffer, indexSize, mode, start, count);
 
    trace_dump_call_end();
 
    trace_context_draw_block(tr_ctx, 2);
-
-   return result;
 }
 
 
-static INLINE boolean
+static INLINE void
 trace_context_draw_range_elements(struct pipe_context *_pipe,
                                   struct pipe_buffer *_indexBuffer,
                                   unsigned indexSize,
@@ -258,10 +237,9 @@ trace_context_draw_range_elements(struct pipe_context *_pipe,
    struct trace_buffer *tr_buf = trace_buffer(_indexBuffer);
    struct pipe_context *pipe = tr_ctx->pipe;
    struct pipe_buffer *indexBuffer = tr_buf->buffer;
-   boolean result;
 
    if (tr_ctx->curr.fs->disabled || tr_ctx->curr.vs->disabled)
-      return 0;
+      return;
 
    trace_context_draw_block(tr_ctx, 1);
 
@@ -278,18 +256,14 @@ trace_context_draw_range_elements(struct pipe_context *_pipe,
    trace_dump_arg(uint, start);
    trace_dump_arg(uint, count);
 
-   result = pipe->draw_range_elements(pipe,
-                                      indexBuffer,
-                                      indexSize, minIndex, maxIndex,
-                                      mode, start, count);
-
-   trace_dump_ret(bool, result);
+   pipe->draw_range_elements(pipe,
+                             indexBuffer,
+                             indexSize, minIndex, maxIndex,
+                             mode, start, count);
 
    trace_dump_call_end();
 
    trace_context_draw_block(tr_ctx, 2);
-
-   return result;
 }
 
 
@@ -306,7 +280,7 @@ trace_context_create_query(struct pipe_context *_pipe,
    trace_dump_arg(ptr, pipe);
    trace_dump_arg(uint, query_type);
 
-   result = pipe->create_query(pipe, query_type);;
+   result = pipe->create_query(pipe, query_type);
 
    trace_dump_ret(ptr, result);
 
@@ -328,7 +302,7 @@ trace_context_destroy_query(struct pipe_context *_pipe,
    trace_dump_arg(ptr, pipe);
    trace_dump_arg(ptr, query);
 
-   pipe->destroy_query(pipe, query);;
+   pipe->destroy_query(pipe, query);
 
    trace_dump_call_end();
 }
@@ -346,7 +320,7 @@ trace_context_begin_query(struct pipe_context *_pipe,
    trace_dump_arg(ptr, pipe);
    trace_dump_arg(ptr, query);
 
-   pipe->begin_query(pipe, query);;
+   pipe->begin_query(pipe, query);
 
    trace_dump_call_end();
 }
@@ -385,7 +359,7 @@ trace_context_get_query_result(struct pipe_context *_pipe,
 
    trace_dump_arg(ptr, pipe);
 
-   _result = pipe->get_query_result(pipe, query, wait, presult);;
+   _result = pipe->get_query_result(pipe, query, wait, presult);
    result = *presult;
 
    trace_dump_arg(uint, result);
@@ -410,7 +384,7 @@ trace_context_create_blend_state(struct pipe_context *_pipe,
    trace_dump_arg(ptr, pipe);
    trace_dump_arg(blend_state, state);
 
-   result = pipe->create_blend_state(pipe, state);;
+   result = pipe->create_blend_state(pipe, state);
 
    trace_dump_ret(ptr, result);
 
@@ -432,7 +406,7 @@ trace_context_bind_blend_state(struct pipe_context *_pipe,
    trace_dump_arg(ptr, pipe);
    trace_dump_arg(ptr, state);
 
-   pipe->bind_blend_state(pipe, state);;
+   pipe->bind_blend_state(pipe, state);
 
    trace_dump_call_end();
 }
@@ -450,7 +424,7 @@ trace_context_delete_blend_state(struct pipe_context *_pipe,
    trace_dump_arg(ptr, pipe);
    trace_dump_arg(ptr, state);
 
-   pipe->delete_blend_state(pipe, state);;
+   pipe->delete_blend_state(pipe, state);
 
    trace_dump_call_end();
 }
@@ -469,7 +443,7 @@ trace_context_create_sampler_state(struct pipe_context *_pipe,
    trace_dump_arg(ptr, pipe);
    trace_dump_arg(sampler_state, state);
 
-   result = pipe->create_sampler_state(pipe, state);;
+   result = pipe->create_sampler_state(pipe, state);
 
    trace_dump_ret(ptr, result);
 
@@ -480,19 +454,40 @@ trace_context_create_sampler_state(struct pipe_context *_pipe,
 
 
 static INLINE void
-trace_context_bind_sampler_states(struct pipe_context *_pipe,
-                                  unsigned num_states, void **states)
+trace_context_bind_fragment_sampler_states(struct pipe_context *_pipe,
+                                           unsigned num_states,
+                                           void **states)
 {
    struct trace_context *tr_ctx = trace_context(_pipe);
    struct pipe_context *pipe = tr_ctx->pipe;
 
-   trace_dump_call_begin("pipe_context", "bind_sampler_states");
+   trace_dump_call_begin("pipe_context", "bind_fragment_sampler_states");
 
    trace_dump_arg(ptr, pipe);
    trace_dump_arg(uint, num_states);
    trace_dump_arg_array(ptr, states, num_states);
 
-   pipe->bind_sampler_states(pipe, num_states, states);;
+   pipe->bind_fragment_sampler_states(pipe, num_states, states);
+
+   trace_dump_call_end();
+}
+
+
+static INLINE void
+trace_context_bind_vertex_sampler_states(struct pipe_context *_pipe,
+                                         unsigned num_states,
+                                         void **states)
+{
+   struct trace_context *tr_ctx = trace_context(_pipe);
+   struct pipe_context *pipe = tr_ctx->pipe;
+
+   trace_dump_call_begin("pipe_context", "bind_vertex_sampler_states");
+
+   trace_dump_arg(ptr, pipe);
+   trace_dump_arg(uint, num_states);
+   trace_dump_arg_array(ptr, states, num_states);
+
+   pipe->bind_vertex_sampler_states(pipe, num_states, states);
 
    trace_dump_call_end();
 }
@@ -510,7 +505,7 @@ trace_context_delete_sampler_state(struct pipe_context *_pipe,
    trace_dump_arg(ptr, pipe);
    trace_dump_arg(ptr, state);
 
-   pipe->delete_sampler_state(pipe, state);;
+   pipe->delete_sampler_state(pipe, state);
 
    trace_dump_call_end();
 }
@@ -529,7 +524,7 @@ trace_context_create_rasterizer_state(struct pipe_context *_pipe,
    trace_dump_arg(ptr, pipe);
    trace_dump_arg(rasterizer_state, state);
 
-   result = pipe->create_rasterizer_state(pipe, state);;
+   result = pipe->create_rasterizer_state(pipe, state);
 
    trace_dump_ret(ptr, result);
 
@@ -551,7 +546,7 @@ trace_context_bind_rasterizer_state(struct pipe_context *_pipe,
    trace_dump_arg(ptr, pipe);
    trace_dump_arg(ptr, state);
 
-   pipe->bind_rasterizer_state(pipe, state);;
+   pipe->bind_rasterizer_state(pipe, state);
 
    trace_dump_call_end();
 }
@@ -569,7 +564,7 @@ trace_context_delete_rasterizer_state(struct pipe_context *_pipe,
    trace_dump_arg(ptr, pipe);
    trace_dump_arg(ptr, state);
 
-   pipe->delete_rasterizer_state(pipe, state);;
+   pipe->delete_rasterizer_state(pipe, state);
 
    trace_dump_call_end();
 }
@@ -585,7 +580,7 @@ trace_context_create_depth_stencil_alpha_state(struct pipe_context *_pipe,
 
    trace_dump_call_begin("pipe_context", "create_depth_stencil_alpha_state");
 
-   result = pipe->create_depth_stencil_alpha_state(pipe, state);;
+   result = pipe->create_depth_stencil_alpha_state(pipe, state);
 
    trace_dump_arg(ptr, pipe);
    trace_dump_arg(depth_stencil_alpha_state, state);
@@ -610,7 +605,7 @@ trace_context_bind_depth_stencil_alpha_state(struct pipe_context *_pipe,
    trace_dump_arg(ptr, pipe);
    trace_dump_arg(ptr, state);
 
-   pipe->bind_depth_stencil_alpha_state(pipe, state);;
+   pipe->bind_depth_stencil_alpha_state(pipe, state);
 
    trace_dump_call_end();
 }
@@ -628,7 +623,7 @@ trace_context_delete_depth_stencil_alpha_state(struct pipe_context *_pipe,
    trace_dump_arg(ptr, pipe);
    trace_dump_arg(ptr, state);
 
-   pipe->delete_depth_stencil_alpha_state(pipe, state);;
+   pipe->delete_depth_stencil_alpha_state(pipe, state);
 
    trace_dump_call_end();
 }
@@ -647,7 +642,7 @@ trace_context_create_fs_state(struct pipe_context *_pipe,
    trace_dump_arg(ptr, pipe);
    trace_dump_arg(shader_state, state);
 
-   result = pipe->create_fs_state(pipe, state);;
+   result = pipe->create_fs_state(pipe, state);
 
    trace_dump_ret(ptr, result);
 
@@ -750,7 +745,7 @@ trace_context_bind_vs_state(struct pipe_context *_pipe,
    if (tr_shdr && tr_shdr->replaced)
       state = tr_shdr->replaced;
 
-   pipe->bind_vs_state(pipe, state);;
+   pipe->bind_vs_state(pipe, state);
 
    trace_dump_call_end();
 }
@@ -770,7 +765,7 @@ trace_context_delete_vs_state(struct pipe_context *_pipe,
    trace_dump_arg(ptr, pipe);
    trace_dump_arg(ptr, state);
 
-   pipe->delete_vs_state(pipe, state);;
+   pipe->delete_vs_state(pipe, state);
 
    trace_dump_call_end();
 
@@ -790,7 +785,7 @@ trace_context_set_blend_color(struct pipe_context *_pipe,
    trace_dump_arg(ptr, pipe);
    trace_dump_arg(blend_color, state);
 
-   pipe->set_blend_color(pipe, state);;
+   pipe->set_blend_color(pipe, state);
 
    trace_dump_call_end();
 }
@@ -808,7 +803,7 @@ trace_context_set_clip_state(struct pipe_context *_pipe,
    trace_dump_arg(ptr, pipe);
    trace_dump_arg(clip_state, state);
 
-   pipe->set_clip_state(pipe, state);;
+   pipe->set_clip_state(pipe, state);
 
    trace_dump_call_end();
 }
@@ -880,7 +875,7 @@ trace_context_set_framebuffer_state(struct pipe_context *_pipe,
    trace_dump_arg(ptr, pipe);
    trace_dump_arg(framebuffer_state, state);
 
-   pipe->set_framebuffer_state(pipe, state);;
+   pipe->set_framebuffer_state(pipe, state);
 
    trace_dump_call_end();
 }
@@ -898,7 +893,7 @@ trace_context_set_polygon_stipple(struct pipe_context *_pipe,
    trace_dump_arg(ptr, pipe);
    trace_dump_arg(poly_stipple, state);
 
-   pipe->set_polygon_stipple(pipe, state);;
+   pipe->set_polygon_stipple(pipe, state);
 
    trace_dump_call_end();
 }
@@ -916,7 +911,7 @@ trace_context_set_scissor_state(struct pipe_context *_pipe,
    trace_dump_arg(ptr, pipe);
    trace_dump_arg(scissor_state, state);
 
-   pipe->set_scissor_state(pipe, state);;
+   pipe->set_scissor_state(pipe, state);
 
    trace_dump_call_end();
 }
@@ -934,16 +929,16 @@ trace_context_set_viewport_state(struct pipe_context *_pipe,
    trace_dump_arg(ptr, pipe);
    trace_dump_arg(viewport_state, state);
 
-   pipe->set_viewport_state(pipe, state);;
+   pipe->set_viewport_state(pipe, state);
 
    trace_dump_call_end();
 }
 
 
 static INLINE void
-trace_context_set_sampler_textures(struct pipe_context *_pipe,
-                                   unsigned num_textures,
-                                   struct pipe_texture **textures)
+trace_context_set_fragment_sampler_textures(struct pipe_context *_pipe,
+                                            unsigned num_textures,
+                                            struct pipe_texture **textures)
 {
    struct trace_context *tr_ctx = trace_context(_pipe);
    struct trace_texture *tr_tex;
@@ -959,13 +954,44 @@ trace_context_set_sampler_textures(struct pipe_context *_pipe,
    }
    textures = unwrapped_textures;
 
-   trace_dump_call_begin("pipe_context", "set_sampler_textures");
+   trace_dump_call_begin("pipe_context", "set_fragment_sampler_textures");
+
+   trace_dump_arg(ptr, pipe);
+   trace_dump_arg(uint, num_textures);
+   trace_dump_arg_array(ptr, textures, num_textures);
+
+   pipe->set_fragment_sampler_textures(pipe, num_textures, textures);
+
+   trace_dump_call_end();
+}
+
+
+static INLINE void
+trace_context_set_vertex_sampler_textures(struct pipe_context *_pipe,
+                                          unsigned num_textures,
+                                          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_VERTEX_SAMPLERS];
+   unsigned i;
+
+   tr_ctx->curr.num_vert_texs = num_textures;
+   for(i = 0; i < num_textures; ++i) {
+      tr_tex = trace_texture(textures[i]);
+      tr_ctx->curr.vert_tex[i] = tr_tex;
+      unwrapped_textures[i] = tr_tex ? tr_tex->texture : NULL;
+   }
+   textures = unwrapped_textures;
+
+   trace_dump_call_begin("pipe_context", "set_vertex_sampler_textures");
 
    trace_dump_arg(ptr, pipe);
    trace_dump_arg(uint, num_textures);
    trace_dump_arg_array(ptr, textures, num_textures);
 
-   pipe->set_sampler_textures(pipe, num_textures, textures);;
+   pipe->set_vertex_sampler_textures(pipe, num_textures, textures);
 
    trace_dump_call_end();
 }
@@ -1024,7 +1050,7 @@ trace_context_set_vertex_elements(struct pipe_context *_pipe,
    trace_dump_struct_array(vertex_element, elements, num_elements);
    trace_dump_arg_end();
 
-   pipe->set_vertex_elements(pipe, num_elements, elements);;
+   pipe->set_vertex_elements(pipe, num_elements, elements);
 
    trace_dump_call_end();
 }
@@ -1085,7 +1111,7 @@ trace_context_surface_fill(struct pipe_context *_pipe,
    trace_dump_arg(uint, width);
    trace_dump_arg(uint, height);
 
-   pipe->surface_fill(pipe, dst, dstx, dsty, width, height, value);;
+   pipe->surface_fill(pipe, dst, dstx, dsty, width, height, value);
 
    trace_dump_call_end();
 }
@@ -1128,7 +1154,7 @@ trace_context_flush(struct pipe_context *_pipe,
    trace_dump_arg(ptr, pipe);
    trace_dump_arg(uint, flags);
 
-   pipe->flush(pipe, flags, fence);;
+   pipe->flush(pipe, flags, fence);
 
    if(fence)
       trace_dump_ret(ptr, *fence);
@@ -1240,7 +1266,6 @@ trace_context_create(struct pipe_screen *_screen,
    tr_ctx->base.winsys = _screen->winsys;
    tr_ctx->base.screen = _screen;
    tr_ctx->base.destroy = trace_context_destroy;
-   tr_ctx->base.set_edgeflags = trace_context_set_edgeflags;
    tr_ctx->base.draw_arrays = trace_context_draw_arrays;
    tr_ctx->base.draw_elements = trace_context_draw_elements;
    tr_ctx->base.draw_range_elements = trace_context_draw_range_elements;
@@ -1253,7 +1278,8 @@ trace_context_create(struct pipe_screen *_screen,
    tr_ctx->base.bind_blend_state = trace_context_bind_blend_state;
    tr_ctx->base.delete_blend_state = trace_context_delete_blend_state;
    tr_ctx->base.create_sampler_state = trace_context_create_sampler_state;
-   tr_ctx->base.bind_sampler_states = trace_context_bind_sampler_states;
+   tr_ctx->base.bind_fragment_sampler_states = trace_context_bind_fragment_sampler_states;
+   tr_ctx->base.bind_vertex_sampler_states = trace_context_bind_vertex_sampler_states;
    tr_ctx->base.delete_sampler_state = trace_context_delete_sampler_state;
    tr_ctx->base.create_rasterizer_state = trace_context_create_rasterizer_state;
    tr_ctx->base.bind_rasterizer_state = trace_context_bind_rasterizer_state;
@@ -1274,7 +1300,8 @@ trace_context_create(struct pipe_screen *_screen,
    tr_ctx->base.set_polygon_stipple = trace_context_set_polygon_stipple;
    tr_ctx->base.set_scissor_state = trace_context_set_scissor_state;
    tr_ctx->base.set_viewport_state = trace_context_set_viewport_state;
-   tr_ctx->base.set_sampler_textures = trace_context_set_sampler_textures;
+   tr_ctx->base.set_fragment_sampler_textures = trace_context_set_fragment_sampler_textures;
+   tr_ctx->base.set_vertex_sampler_textures = trace_context_set_vertex_sampler_textures;
    tr_ctx->base.set_vertex_buffers = trace_context_set_vertex_buffers;
    tr_ctx->base.set_vertex_elements = trace_context_set_vertex_elements;
    if (pipe->surface_copy)
index 6febe4b41143b9a0cc78d7a74bc864a9ce4e71f4..852b480765a03deb12402d543af51ff18ab6943c 100644 (file)
@@ -54,6 +54,9 @@ struct trace_context
       struct trace_texture *tex[PIPE_MAX_SAMPLERS];
       unsigned num_texs;
 
+      struct trace_texture *vert_tex[PIPE_MAX_VERTEX_SAMPLERS];
+      unsigned num_vert_texs;
+
       unsigned nr_cbufs;
       struct trace_texture *cbufs[PIPE_MAX_COLOR_BUFS];
       struct trace_texture *zsbuf;
index 781ca5d3bc0cbc9c7eb8d960915fd987f85bd791..48d1c4051cc274a258b96be292da2b1ba13a0a55 100644 (file)
@@ -150,7 +150,9 @@ trace_drm_destroy(struct drm_api *_api)
 {
    struct trace_drm_api *tr_api = trace_drm_api(_api);
    struct drm_api *api = tr_api->api;
-   api->destroy(api);
+
+   if (api->destroy)
+      api->destroy(api);
 
    free(tr_api);
 }
index 7e2ccbcfdc575b5e3e3c4599ec20b285fcb80c0a..0f45e211a32d43ac705f45b64d4978be5b5e4c0f 100644 (file)
@@ -40,7 +40,7 @@
 
 #include "pipe/p_config.h"
 
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE)
 #include <stdlib.h>
 #endif
 
@@ -258,7 +258,7 @@ boolean trace_dump_trace_begin()
       trace_dump_writes("<?xml-stylesheet type='text/xsl' href='trace.xsl'?>\n");
       trace_dump_writes("<trace version='0.1'>\n");
 
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE)
       /* Linux applications rarely cleanup GL / Gallium resources so catch
        * application exit here */
       atexit(trace_dump_trace_close);
index bcf6751af4fae5090f12ab94c50ce8b3be3c4a1e..86237e03bcc0410bd4c3c524e69dadd486866593 100644 (file)
@@ -43,19 +43,6 @@ void trace_dump_format(enum pipe_format format)
 }
 
 
-void trace_dump_block(const struct pipe_format_block *block)
-{
-   if (!trace_dumping_enabled_locked())
-      return;
-
-   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)
 {
    if (!trace_dumping_enabled_locked())
@@ -83,19 +70,15 @@ void trace_dump_template(const struct pipe_texture *templat)
    trace_dump_member(format, templat, format);
 
    trace_dump_member_begin("width");
-   trace_dump_array(uint, templat->width, 1);
+   trace_dump_uint(templat->width0);
    trace_dump_member_end();
 
    trace_dump_member_begin("height");
-   trace_dump_array(uint, templat->height, 1);
+   trace_dump_uint(templat->height0);
    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_uint(templat->depth0);
    trace_dump_member_end();
 
    trace_dump_member(uint, templat, last_level);
@@ -426,7 +409,7 @@ void trace_dump_sampler_state(const struct pipe_sampler_state *state)
    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_mode);
    trace_dump_member(uint, state, compare_func);
    trace_dump_member(bool, state, normalized_coords);
    trace_dump_member(uint, state, prefilter);
@@ -483,16 +466,9 @@ void trace_dump_transfer(const struct pipe_transfer *state)
 
    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);
 
index 05b821adb64318e00e1f1010c12ddafcac3fa1bb..07ad6fbb205ffdd2e38aea50bb311fe53729cfef 100644 (file)
 
 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);
index 81e0a6f3b000a539a08909286a8b2e0ba1c13e38..0546aad9b508759693c3a9748b0500e32579c4f2 100644 (file)
@@ -26,6 +26,7 @@
  **************************************************************************/
 
 
+#include "util/u_format.h"
 #include "util/u_string.h"
 #include "util/u_memory.h"
 #include "util/u_simple_list.h"
@@ -44,7 +45,7 @@
 
 #if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
 #  define sleep Sleep
-#elif defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD)
+#elif defined(PIPE_OS_LINUX) || defined(PIPE_OS_APPLE)
 void usleep(int);
 #  define sleep usleep
 #else
@@ -179,7 +180,7 @@ 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 trace_texture *tr_tex = NULL;
    struct rbug_proto_texture_info *gpti = (struct rbug_proto_texture_info *)header;
    struct tr_list *ptr;
    struct pipe_texture *t;
@@ -200,10 +201,12 @@ trace_rbug_texture_info(struct trace_rbug *tr_rbug, struct rbug_header *header,
    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->width0, 1,
+                               &t->height0, 1,
+                               &t->depth0, 1,
+                               util_format_get_blockwidth(t->format),
+                               util_format_get_blockheight(t->format),
+                               util_format_get_blocksize(t->format),
                                t->last_level,
                                t->nr_samples,
                                t->tex_usage,
@@ -220,7 +223,7 @@ trace_rbug_texture_read(struct trace_rbug *tr_rbug, struct rbug_header *header,
    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 trace_texture *tr_tex = NULL;
    struct tr_list *ptr;
 
    struct pipe_screen *screen = tr_scr->screen;
@@ -251,9 +254,12 @@ trace_rbug_texture_read(struct trace_rbug *tr_rbug, struct rbug_header *header,
    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->texture->format,
+                                util_format_get_blockwidth(t->texture->format),
+                                util_format_get_blockheight(t->texture->format),
+                                util_format_get_blocksize(t->texture->format),
+                                (uint8_t*)map,
+                                t->stride * util_format_get_nblocksy(t->texture->format, t->height),
                                 t->stride,
                                 NULL);
 
index ab605c7fc8761bcf155636c004139cdffec31bc6..117503aaff694c8346e14fd53365362a7a2eb849 100644 (file)
@@ -25,6 +25,7 @@
  *
  **************************************************************************/
 
+#include "util/u_format.h"
 #include "util/u_memory.h"
 #include "util/u_simple_list.h"
 
@@ -35,6 +36,7 @@
 #include "tr_screen.h"
 
 #include "pipe/p_inlines.h"
+#include "pipe/p_format.h"
 
 
 static boolean trace = FALSE;
@@ -366,7 +368,8 @@ trace_screen_get_tex_transfer(struct pipe_screen *_screen,
 
    trace_dump_call_end();
 
-   result = trace_transfer_create(tr_tex, result);
+   if (result)
+      result = trace_transfer_create(tr_tex, result);
 
    return result;
 }
@@ -423,7 +426,7 @@ trace_screen_transfer_unmap(struct pipe_screen *_screen,
    struct pipe_transfer *transfer = tr_trans->transfer;
 
    if(tr_trans->map) {
-      size_t size = transfer->nblocksy * transfer->stride;
+      size_t size = util_format_get_nblocksy(transfer->texture->format, transfer->height) * transfer->stride;
 
       trace_dump_call_begin("pipe_screen", "transfer_write");
 
index 1c16042ee5a901498be46a3057762f0f0b3e0f99..e2f981d0513897d479e6b1de8f82c4a0e7e0c86d 100644 (file)
@@ -32,7 +32,7 @@ struct tgsi_token;
 enum trace_shader_type {
    TRACE_SHADER_FRAGMENT = 0,
    TRACE_SHADER_VERTEX   = 1,
-   TRACE_SHADER_GEOMETRY = 2,
+   TRACE_SHADER_GEOMETRY = 2
 };
 
 struct trace_shader
index c13cffceb0a48e65a2ccb761e7cd84039f03e4cf..f7368bb95b354819322765af1c146aa7deb2766a 100644 (file)
@@ -167,11 +167,17 @@ typedef unsigned char boolean;
 #define ALIGN16_ASSIGN(NAME) NAME##___aligned
 #define ALIGN16_ATTRIB  __attribute__(( aligned( 16 ) ))
 #define ALIGN8_ATTRIB  __attribute__(( aligned( 8 ) ))
+#if (__GNUC__ > 4 || (__GNUC__ == 4 &&__GNUC_MINOR__>1)) && !defined(PIPE_ARCH_X86_64)
+#define ALIGN_STACK __attribute__((force_align_arg_pointer))
+#else
+#define ALIGN_STACK
+#endif
 #else
 #define ALIGN16_DECL(TYPE, NAME, SIZE)  TYPE NAME##___unaligned[SIZE + 1]
 #define ALIGN16_ASSIGN(NAME) align16(NAME##___unaligned)
 #define ALIGN16_ATTRIB
 #define ALIGN8_ATTRIB
+#define ALIGN_STACK
 #endif
 
 
index f6feea5f74d7ac568f15beeaca061d8dd12d7153..064605a4a059189973751f9780aefe64575eae0d 100644 (file)
@@ -53,6 +53,7 @@
 
 #if defined(__GNUC__)
 #define PIPE_CC_GCC
+#define PIPE_CC_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
 #endif
 
 /*
index 39620a7198027dfefe846401b5b761fda5cc97be..d2f8085b42123c3a0327e281fe28460b58298c9b 100644 (file)
@@ -57,41 +57,41 @@ struct pipe_context {
 
    void (*destroy)( struct pipe_context * );
 
-   
-   /* Possible interface for setting edgeflags.  These aren't really
-    * vertex elements, so don't fit there.
-    */
-   void (*set_edgeflags)( struct pipe_context *,
-                          const unsigned *bitfield );
-
-
    /**
     * VBO drawing (return false on fallbacks (temporary??))
     */
    /*@{*/
-   boolean (*draw_arrays)( struct pipe_context *pipe,
-                          unsigned mode, unsigned start, unsigned count);
+   void (*draw_arrays)( struct pipe_context *pipe,
+                        unsigned mode, unsigned start, unsigned count);
 
-   boolean (*draw_elements)( struct pipe_context *pipe,
-                            struct pipe_buffer *indexBuffer,
-                            unsigned indexSize,
-                            unsigned mode, unsigned start, unsigned count);
+   void (*draw_elements)( struct pipe_context *pipe,
+                          struct pipe_buffer *indexBuffer,
+                          unsigned indexSize,
+                          unsigned mode, unsigned start, unsigned count);
 
    /* XXX: this is (probably) a temporary entrypoint, as the range
     * information should be available from the vertex_buffer state.
     * Using this to quickly evaluate a specialized path in the draw
     * module.
     */
-   boolean (*draw_range_elements)( struct pipe_context *pipe,
-                                   struct pipe_buffer *indexBuffer,
-                                   unsigned indexSize,
-                                   unsigned minIndex,
-                                   unsigned maxIndex,
-                                   unsigned mode, 
-                                   unsigned start, 
-                                   unsigned count);
+   void (*draw_range_elements)( struct pipe_context *pipe,
+                                struct pipe_buffer *indexBuffer,
+                                unsigned indexSize,
+                                unsigned minIndex,
+                                unsigned maxIndex,
+                                unsigned mode, 
+                                unsigned start, 
+                                unsigned count);
    /*@}*/
 
+   /**
+    * Predicate subsequent rendering on occlusion query result
+    * \param query  the query predicate, or NULL if no predicate
+    * \param mode  one of PIPE_COND_RENDER_x
+    */
+   void (*render_condition)( struct pipe_context *pipe,
+                             struct pipe_query *query,
+                             uint mode );
 
    /**
     * Query objects
@@ -123,7 +123,12 @@ struct pipe_context {
 
    void * (*create_sampler_state)(struct pipe_context *,
                                   const struct pipe_sampler_state *);
-   void   (*bind_sampler_states)(struct pipe_context *, unsigned num, void **);
+   void   (*bind_fragment_sampler_states)(struct pipe_context *,
+                                          unsigned num_samplers,
+                                          void **samplers);
+   void   (*bind_vertex_sampler_states)(struct pipe_context *,
+                                        unsigned num_samplers,
+                                        void **samplers);
    void   (*delete_sampler_state)(struct pipe_context *, void *);
 
    void * (*create_rasterizer_state)(struct pipe_context *,
@@ -145,6 +150,12 @@ struct pipe_context {
                              const struct pipe_shader_state *);
    void   (*bind_vs_state)(struct pipe_context *, void *);
    void   (*delete_vs_state)(struct pipe_context *, void *);
+
+   void * (*create_gs_state)(struct pipe_context *,
+                             const struct pipe_shader_state *);
+   void   (*bind_gs_state)(struct pipe_context *, void *);
+   void   (*delete_gs_state)(struct pipe_context *, void *);
+
    /*@}*/
 
    /**
@@ -173,9 +184,13 @@ struct pipe_context {
    void (*set_viewport_state)( struct pipe_context *,
                                const struct pipe_viewport_state * );
 
-   void (*set_sampler_textures)( struct pipe_context *,
-                                 unsigned num_textures,
-                                 struct pipe_texture ** );
+   void (*set_fragment_sampler_textures)(struct pipe_context *,
+                                         unsigned num_textures,
+                                         struct pipe_texture **);
+
+   void (*set_vertex_sampler_textures)(struct pipe_context *,
+                                       unsigned num_textures,
+                                       struct pipe_texture **);
 
    void (*set_vertex_buffers)( struct pipe_context *,
                                unsigned num_buffers,
@@ -189,6 +204,9 @@ struct pipe_context {
 
    /**
     * Surface functions
+    *
+    * The pipe driver is allowed to set these functions to NULL, and in that
+    * case, they will not be available.
     */
    /*@{*/
 
index f8fa1e3f49dc157ece6e71ba6c9fd734510db282..35f3830ebcf076ba9d7305b6ba62b64bf89466ae 100644 (file)
 extern "C" {
 #endif
 
+/**
+ * Gallium error codes.
+ *
+ * - A zero value always means success.
+ * - A negative value always means failure.
+ * - The meaning of a positive value is function dependent.
+ */
+enum pipe_error {
+   PIPE_OK = 0,
+   PIPE_ERROR = -1,    /**< Generic error */
+   PIPE_ERROR_BAD_INPUT = -2,
+   PIPE_ERROR_OUT_OF_MEMORY = -3,
+   PIPE_ERROR_RETRY = -4
+   /* TODO */
+};
+
+
 #define PIPE_BLENDFACTOR_ONE                 0x1
 #define PIPE_BLENDFACTOR_SRC_COLOR           0x2
 #define PIPE_BLENDFACTOR_SRC_ALPHA           0x3
@@ -123,7 +140,8 @@ enum pipe_texture_target {
    PIPE_TEXTURE_1D   = 0,
    PIPE_TEXTURE_2D   = 1,
    PIPE_TEXTURE_3D   = 2,
-   PIPE_TEXTURE_CUBE = 3
+   PIPE_TEXTURE_CUBE = 3,
+   PIPE_MAX_TEXTURE_TYPES
 };
 
 #define PIPE_TEX_FACE_POS_X 0
@@ -153,8 +171,6 @@ enum pipe_texture_target {
  */
 #define PIPE_TEX_FILTER_NEAREST      0
 #define PIPE_TEX_FILTER_LINEAR       1
-#define PIPE_TEX_FILTER_ANISO        2 
-
 
 #define PIPE_TEX_COMPARE_NONE          0
 #define PIPE_TEX_COMPARE_R_TO_TEXTURE  1
@@ -208,9 +224,10 @@ enum pipe_transfer_usage {
 };
 
 
-/**
+/*
  * Buffer usage flags
  */
+
 #define PIPE_BUFFER_USAGE_CPU_READ  (1 << 0)
 #define PIPE_BUFFER_USAGE_CPU_WRITE (1 << 1)
 #define PIPE_BUFFER_USAGE_GPU_READ  (1 << 2)
@@ -219,9 +236,63 @@ enum pipe_transfer_usage {
 #define PIPE_BUFFER_USAGE_VERTEX    (1 << 5)
 #define PIPE_BUFFER_USAGE_INDEX     (1 << 6)
 #define PIPE_BUFFER_USAGE_CONSTANT  (1 << 7)
+
+/*
+ * CPU access flags.
+ *
+ * These flags should only be used for texture transfers or when mapping
+ * buffers.
+ *
+ * Note that the PIPE_BUFFER_USAGE_CPU_xxx flags above are also used for
+ * mapping. Either PIPE_BUFFER_USAGE_CPU_READ or PIPE_BUFFER_USAGE_CPU_WRITE
+ * must be set.
+ */
+
+/**
+ * Discards the memory within the mapped region.
+ *
+ * It should not be used with PIPE_BUFFER_USAGE_CPU_READ.
+ *
+ * See also:
+ * - OpenGL's ARB_map_buffer_range extension, MAP_INVALIDATE_RANGE_BIT flag.
+ * - Direct3D's D3DLOCK_DISCARD flag.
+ */
 #define PIPE_BUFFER_USAGE_DISCARD   (1 << 8)
+
+/**
+ * Fail if the resource cannot be mapped immediately.
+ *
+ * See also:
+ * - Direct3D's D3DLOCK_DONOTWAIT flag.
+ * - Mesa3D's MESA_MAP_NOWAIT_BIT flag.
+ * - WDDM's D3DDDICB_LOCKFLAGS.DonotWait flag.
+ */
 #define PIPE_BUFFER_USAGE_DONTBLOCK (1 << 9)
-#define PIPE_BUFFER_USAGE_FLUSH_EXPLICIT (1 << 10) /**< See pipe_screen::buffer_flush_mapped_range */
+
+/**
+ * Do not attempt to synchronize pending operations on the resource when mapping.
+ *
+ * It should not be used with PIPE_BUFFER_USAGE_CPU_READ.
+ *
+ * See also:
+ * - OpenGL's ARB_map_buffer_range extension, MAP_UNSYNCHRONIZED_BIT flag.
+ * - Direct3D's D3DLOCK_NOOVERWRITE flag.
+ * - WDDM's D3DDDICB_LOCKFLAGS.IgnoreSync flag.
+ */
+#define PIPE_BUFFER_USAGE_UNSYNCHRONIZED (1 << 10)
+
+/**
+ * Written ranges will be notified later with
+ * pipe_screen::buffer_flush_mapped_range.
+ *
+ * It should not be used with PIPE_BUFFER_USAGE_CPU_READ.
+ *
+ * See also:
+ * - pipe_screen::buffer_flush_mapped_range
+ * - OpenGL's ARB_map_buffer_range extension, MAP_FLUSH_EXPLICIT_BIT flag.
+ */
+#define PIPE_BUFFER_USAGE_FLUSH_EXPLICIT (1 << 11)
+
 /** Pipe driver custom usage flags should be greater or equal to this value */
 #define PIPE_BUFFER_USAGE_CUSTOM    (1 << 16)
 
@@ -248,23 +319,28 @@ enum pipe_transfer_usage {
  */
 #define PIPE_SHADER_VERTEX   0
 #define PIPE_SHADER_FRAGMENT 1
-#define PIPE_SHADER_TYPES    2
+#define PIPE_SHADER_GEOMETRY 2
+#define PIPE_SHADER_TYPES    3
 
 
 /**
  * Primitive types:
  */
-#define PIPE_PRIM_POINTS          0
-#define PIPE_PRIM_LINES           1
-#define PIPE_PRIM_LINE_LOOP       2
-#define PIPE_PRIM_LINE_STRIP      3
-#define PIPE_PRIM_TRIANGLES       4
-#define PIPE_PRIM_TRIANGLE_STRIP  5
-#define PIPE_PRIM_TRIANGLE_FAN    6
-#define PIPE_PRIM_QUADS           7
-#define PIPE_PRIM_QUAD_STRIP      8
-#define PIPE_PRIM_POLYGON         9
-#define PIPE_PRIM_MAX             10
+#define PIPE_PRIM_POINTS               0
+#define PIPE_PRIM_LINES                1
+#define PIPE_PRIM_LINE_LOOP            2
+#define PIPE_PRIM_LINE_STRIP           3
+#define PIPE_PRIM_TRIANGLES            4
+#define PIPE_PRIM_TRIANGLE_STRIP       5
+#define PIPE_PRIM_TRIANGLE_FAN         6
+#define PIPE_PRIM_QUADS                7
+#define PIPE_PRIM_QUAD_STRIP           8
+#define PIPE_PRIM_POLYGON              9
+#define PIPE_PRIM_LINES_ADJACENCY          10
+#define PIPE_PRIM_LINE_STRIP_ADJACENCY    11
+#define PIPE_PRIM_TRIANGLES_ADJACENCY      12
+#define PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY 13
+#define PIPE_PRIM_MAX                      14
 
 
 /**
@@ -276,6 +352,15 @@ enum pipe_transfer_usage {
 #define PIPE_QUERY_TYPES                 3
 
 
+/**
+ * Conditional rendering modes
+ */
+#define PIPE_RENDER_COND_WAIT              0
+#define PIPE_RENDER_COND_NO_WAIT           1
+#define PIPE_RENDER_COND_BY_REGION_WAIT    2
+#define PIPE_RENDER_COND_BY_REGION_NO_WAIT 3
+
+
 /**
  * Point sprite coord modes
  */
@@ -316,6 +401,10 @@ enum pipe_transfer_usage {
 #define PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS 26
 #define PIPE_CAP_TGSI_CONT_SUPPORTED     27
 #define PIPE_CAP_BLEND_EQUATION_SEPARATE 28
+#define PIPE_CAP_SM3                     29  /*< Shader Model 3 supported */
+#define PIPE_CAP_MAX_PREDICATE_REGISTERS 30
+#define PIPE_CAP_MAX_COMBINED_SAMPLERS   31  /*< Maximum texture image units accessible from vertex
+                                                 and fragment shaders combined */
 
 
 /**
diff --git a/src/gallium/include/pipe/p_error.h b/src/gallium/include/pipe/p_error.h
deleted file mode 100644 (file)
index b865b22..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/**************************************************************************
- * 
- * 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.
- * 
- **************************************************************************/
-
-/**
- * @file
- * Gallium error codes.
- * 
- * @author José Fonseca <jrfonseca@tungstengraphics.com>
- */
-
-#ifndef P_ERROR_H_
-#define P_ERROR_H_
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-   
-/**
- * Gallium error codes.
- * 
- * - A zero value always means success.
- * - A negative value always means failure.
- * - The meaning of a positive value is function dependent. 
- */
-enum pipe_error {
-   PIPE_OK = 0,
-   PIPE_ERROR = -1,    /**< Generic error */
-   PIPE_ERROR_BAD_INPUT = -2, 
-   PIPE_ERROR_OUT_OF_MEMORY = -3,
-   PIPE_ERROR_RETRY = -4
-   /* TODO */
-};
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* P_ERROR_H_ */
index af2308092015f909f27acdd6f3499a1258a58486..6bfff1cc59ca847c10c891e87087c5c8efb24175 100644 (file)
 extern "C" {
 #endif
 
-/**
- * The pipe_format enum is a 32-bit wide bitfield that encodes all the
- * information needed to uniquely describe a pixel format.
- */
-
-/**
- * Possible format layouts are encoded in the first 2 bits.
- * The interpretation of the remaining 30 bits depends on a particular
- * format layout.
- */
-#define PIPE_FORMAT_LAYOUT_RGBAZS   0
-#define PIPE_FORMAT_LAYOUT_YCBCR    1
-#define PIPE_FORMAT_LAYOUT_DXT      2  /**< XXX temporary? */
-#define PIPE_FORMAT_LAYOUT_MIXED    3
-
-static INLINE uint pf_layout(uint f)  /**< PIPE_FORMAT_LAYOUT_ */
-{
-   return f & 0x3;
-}
-
-/**
- * RGBAZS Format Layout.
- */
-
-/**
- * Format component selectors for RGBAZS & MIXED layout.
- */
-#define PIPE_FORMAT_COMP_R    0
-#define PIPE_FORMAT_COMP_G    1
-#define PIPE_FORMAT_COMP_B    2
-#define PIPE_FORMAT_COMP_A    3
-#define PIPE_FORMAT_COMP_0    4
-#define PIPE_FORMAT_COMP_1    5
-#define PIPE_FORMAT_COMP_Z    6
-#define PIPE_FORMAT_COMP_S    7
-
-/**
- * Format types for RGBAZS layout.
- */
-#define PIPE_FORMAT_TYPE_UNKNOWN 0
-#define PIPE_FORMAT_TYPE_FLOAT   1  /**< 16/32/64-bit/channel formats */
-#define PIPE_FORMAT_TYPE_UNORM   2  /**< uints, normalized to [0,1] */
-#define PIPE_FORMAT_TYPE_SNORM   3  /**< ints, normalized to [-1,1] */
-#define PIPE_FORMAT_TYPE_USCALED 4  /**< uints, not normalized */
-#define PIPE_FORMAT_TYPE_SSCALED 5  /**< ints, not normalized */
-#define PIPE_FORMAT_TYPE_SRGB    6  /**< sRGB colorspace */
-#define PIPE_FORMAT_TYPE_FIXED   7  /**< 16.16 fixed point */
-
-
-/**
- * Because the destination vector is assumed to be RGBA FLOAT, we
- * need to know how to swizzle and expand components from the source
- * vector.
- * Let's take U_A1_R5_G5_B5 as an example. X swizzle is A, X size
- * is 1 bit and type is UNORM. So we take the most significant bit
- * from source vector, convert 0 to 0.0 and 1 to 1.0 and save it
- * in the last component of the destination RGBA component.
- * Next, Y swizzle is R, Y size is 5 and type is UNORM. We normalize
- * those 5 bits into [0.0; 1.0] range and put it into second
- * component of the destination vector. Rinse and repeat for
- * components Z and W.
- * If any of size fields is zero, it means the source format contains
- * less than four components.
- * If any swizzle is 0 or 1, the corresponding destination component
- * should be filled with 0.0 and 1.0, respectively.
- */
-typedef uint pipe_format_rgbazs_t;
-
-static INLINE uint pf_get(pipe_format_rgbazs_t f, uint shift, uint mask)
-{
-   return (f >> shift) & mask;
-}
-
-#define pf_swizzle_x(f)       pf_get(f, 2, 0x7)  /**< PIPE_FORMAT_COMP_ */
-#define pf_swizzle_y(f)       pf_get(f, 5, 0x7)  /**< PIPE_FORMAT_COMP_ */
-#define pf_swizzle_z(f)       pf_get(f, 8, 0x7)  /**< PIPE_FORMAT_COMP_ */
-#define pf_swizzle_w(f)       pf_get(f, 11, 0x7) /**< PIPE_FORMAT_COMP_ */
-#define pf_swizzle_xyzw(f,i)  pf_get(f, 2+((i)*3), 0x7)
-#define pf_size_x(f)          pf_get(f, 14, 0x7) /**< Size of X */
-#define pf_size_y(f)          pf_get(f, 17, 0x7) /**< Size of Y */
-#define pf_size_z(f)          pf_get(f, 20, 0x7) /**< Size of Z */
-#define pf_size_w(f)          pf_get(f, 23, 0x7) /**< Size of W */
-#define pf_size_xyzw(f,i)     pf_get(f, 14+((i)*3), 0x7)
-#define pf_exp2(f)            pf_get(f, 26, 0x7) /**< Scale size by 2 ^ exp2 */
-#define pf_type(f)            pf_get(f, 29, 0x7) /**< PIPE_FORMAT_TYPE_ */
-
-/**
- * Helper macro to encode the above structure into a 32-bit value.
- */
-#define _PIPE_FORMAT_RGBAZS( SWZ, SIZEX, SIZEY, SIZEZ, SIZEW, EXP2, TYPE ) (\
-   (PIPE_FORMAT_LAYOUT_RGBAZS << 0) |\
-   ((SWZ) << 2) |\
-   ((SIZEX) << 14) |\
-   ((SIZEY) << 17) |\
-   ((SIZEZ) << 20) |\
-   ((SIZEW) << 23) |\
-   ((EXP2) << 26) |\
-   ((TYPE) << 29) )
-
-/**
- * Helper macro to encode the swizzle part of the structure above.
- */
-#define _PIPE_FORMAT_SWZ( SWZX, SWZY, SWZZ, SWZW ) (((SWZX) << 0) | ((SWZY) << 3) | ((SWZZ) << 6) | ((SWZW) << 9))
-
-/**
- * Shorthand macro for RGBAZS layout with component sizes in 1-bit units.
- */
-#define _PIPE_FORMAT_RGBAZS_1( SWZ, SIZEX, SIZEY, SIZEZ, SIZEW, TYPE )\
-   _PIPE_FORMAT_RGBAZS( SWZ, SIZEX, SIZEY, SIZEZ, SIZEW, 0, TYPE )
-
-/**
- * Shorthand macro for RGBAZS layout with component sizes in 2-bit units.
- */
-#define _PIPE_FORMAT_RGBAZS_2( SWZ, SIZEX, SIZEY, SIZEZ, SIZEW, TYPE )\
-   _PIPE_FORMAT_RGBAZS( SWZ, SIZEX, SIZEY, SIZEZ, SIZEW, 1, TYPE )
-
-/**
- * Shorthand macro for RGBAZS layout with component sizes in 8-bit units.
- */
-#define _PIPE_FORMAT_RGBAZS_8( SWZ, SIZEX, SIZEY, SIZEZ, SIZEW, TYPE )\
-   _PIPE_FORMAT_RGBAZS( SWZ, SIZEX, SIZEY, SIZEZ, SIZEW, 3, TYPE )
-
-/**
- * Shorthand macro for RGBAZS layout with component sizes in 64-bit units.
- */
-#define _PIPE_FORMAT_RGBAZS_64( SWZ, SIZEX, SIZEY, SIZEZ, SIZEW, TYPE )\
-   _PIPE_FORMAT_RGBAZS( SWZ, SIZEX, SIZEY, SIZEZ, SIZEW, 6, TYPE )
-
-typedef uint pipe_format_mixed_t;
-
-/* NOTE: Use pf_swizzle_* and pf_size_* macros for swizzles and sizes.
- */
-
-#define pf_mixed_sign_x(f)       pf_get( f, 26, 0x1 )       /*< Sign of X */
-#define pf_mixed_sign_y(f)       pf_get( f, 27, 0x1 )       /*< Sign of Y */
-#define pf_mixed_sign_z(f)       pf_get( f, 28, 0x1 )       /*< Sign of Z */
-#define pf_mixed_sign_w(f)       pf_get( f, 29, 0x1 )       /*< Sign of W */
-#define pf_mixed_sign_xyzw(f, i) pf_get( f, 26 + (i), 0x1 )
-#define pf_mixed_normalized(f)   pf_get( f, 30, 0x1 )       /*< Type is NORM (1) or SCALED (0) */
-#define pf_mixed_scale8(f)       pf_get( f, 31, 0x1 )       /*< Scale size by either one (0) or eight (1) */
-
-/**
- * Helper macro to encode the above structure into a 32-bit value.
- */
-#define _PIPE_FORMAT_MIXED( SWZ, SIZEX, SIZEY, SIZEZ, SIZEW, SIGNX, SIGNY, SIGNZ, SIGNW, NORMALIZED, SCALE8 ) (\
-   (PIPE_FORMAT_LAYOUT_MIXED << 0) |\
-   ((SWZ) << 2) |\
-   ((SIZEX) << 14) |\
-   ((SIZEY) << 17) |\
-   ((SIZEZ) << 20) |\
-   ((SIZEW) << 23) |\
-   ((SIGNX) << 26) |\
-   ((SIGNY) << 27) |\
-   ((SIGNZ) << 28) |\
-   ((SIGNW) << 29) |\
-   ((NORMALIZED) << 30) |\
-   ((SCALE8) << 31) )
-
-/**
- * Shorthand macro for common format swizzles.
- */
-#define _PIPE_FORMAT_R001 _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_1 )
-#define _PIPE_FORMAT_RG01 _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_G, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_1 )
-#define _PIPE_FORMAT_RGB1 _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_G, PIPE_FORMAT_COMP_B, PIPE_FORMAT_COMP_1 )
-#define _PIPE_FORMAT_RGBA _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_G, PIPE_FORMAT_COMP_B, PIPE_FORMAT_COMP_A )
-#define _PIPE_FORMAT_ARGB _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_A, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_G, PIPE_FORMAT_COMP_B )
-#define _PIPE_FORMAT_ABGR _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_A, PIPE_FORMAT_COMP_B, PIPE_FORMAT_COMP_G, PIPE_FORMAT_COMP_R )
-#define _PIPE_FORMAT_BGRA _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_B, PIPE_FORMAT_COMP_G, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_A )
-#define _PIPE_FORMAT_1RGB _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_1, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_G, PIPE_FORMAT_COMP_B )
-#define _PIPE_FORMAT_1BGR _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_1, PIPE_FORMAT_COMP_B, PIPE_FORMAT_COMP_G, PIPE_FORMAT_COMP_R )
-#define _PIPE_FORMAT_BGR1 _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_B, PIPE_FORMAT_COMP_G, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_1 )
-#define _PIPE_FORMAT_0000 _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0 )
-#define _PIPE_FORMAT_000R _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_R )
-#define _PIPE_FORMAT_RRR1 _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_1 )
-#define _PIPE_FORMAT_RRRR _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_R )
-#define _PIPE_FORMAT_RRRG _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_G )
-#define _PIPE_FORMAT_Z000 _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_Z, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0 )
-#define _PIPE_FORMAT_0Z00 _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_Z, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0 )
-#define _PIPE_FORMAT_SZ00 _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_S, PIPE_FORMAT_COMP_Z, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0 )
-#define _PIPE_FORMAT_ZS00 _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_Z, PIPE_FORMAT_COMP_S, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0 )
-#define _PIPE_FORMAT_S000 _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_S, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0 )
-
-/**
- * YCBCR Format Layout.
- */
-
-/**
- * This only contains a flag that indicates whether the format is reversed or
- * not.
- */
-typedef uint pipe_format_ycbcr_t;
-
-/**
- * Helper macro to encode the above structure into a 32-bit value.
- */
-#define _PIPE_FORMAT_YCBCR( REV ) (\
-   (PIPE_FORMAT_LAYOUT_YCBCR << 0) |\
-   ((REV) << 2) )
-
-static INLINE uint pf_rev(pipe_format_ycbcr_t f)
-{
-   return (f >> 2) & 0x1;
-}
-
-
-/**
-  * Compresssed format layouts (this will probably change)
-  */
-#define _PIPE_FORMAT_DXT( LEVEL, RSIZE, GSIZE, BSIZE, ASIZE, TYPE ) \
-   ((PIPE_FORMAT_LAYOUT_DXT << 0) | \
-    ((LEVEL) << 2) | \
-    ((RSIZE) << 5) | \
-    ((GSIZE) << 8) | \
-    ((BSIZE) << 11) | \
-    ((ASIZE) << 14) | \
-    ((TYPE) << 29))
-
-
-
 /**
  * Texture/surface image formats (preliminary)
  */
 
 /* KW: Added lots of surface formats to support vertex element layout
- * definitions, and eventually render-to-vertex-buffer.  Could
- * consider making float/int/uint/scaled/normalized a separate
- * parameter, but on the other hand there are special cases like
- * z24s8, compressed textures, ycbcr, etc that won't fit that model.
+ * definitions, and eventually render-to-vertex-buffer.
  */
 
 enum pipe_format {
-   PIPE_FORMAT_NONE                  = _PIPE_FORMAT_RGBAZS_1 ( _PIPE_FORMAT_0000, 0, 0, 0, 0, PIPE_FORMAT_TYPE_UNKNOWN ),
-   PIPE_FORMAT_A8R8G8B8_UNORM        = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_ARGB, 1, 1, 1, 1, PIPE_FORMAT_TYPE_UNORM ),
-   PIPE_FORMAT_X8R8G8B8_UNORM        = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_1RGB, 1, 1, 1, 1, PIPE_FORMAT_TYPE_UNORM ),
-   PIPE_FORMAT_B8G8R8A8_UNORM        = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_BGRA, 1, 1, 1, 1, PIPE_FORMAT_TYPE_UNORM ),
-   PIPE_FORMAT_B8G8R8X8_UNORM        = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_BGR1, 1, 1, 1, 1, PIPE_FORMAT_TYPE_UNORM ),
-   PIPE_FORMAT_A1R5G5B5_UNORM        = _PIPE_FORMAT_RGBAZS_1 ( _PIPE_FORMAT_ARGB, 1, 5, 5, 5, PIPE_FORMAT_TYPE_UNORM ),
-   PIPE_FORMAT_A4R4G4B4_UNORM        = _PIPE_FORMAT_RGBAZS_1 ( _PIPE_FORMAT_ARGB, 4, 4, 4, 4, PIPE_FORMAT_TYPE_UNORM ),
-   PIPE_FORMAT_R5G6B5_UNORM          = _PIPE_FORMAT_RGBAZS_1 ( _PIPE_FORMAT_RGB1, 5, 6, 5, 0, PIPE_FORMAT_TYPE_UNORM ),
-   PIPE_FORMAT_A2B10G10R10_UNORM     = _PIPE_FORMAT_RGBAZS_2 ( _PIPE_FORMAT_ABGR, 1, 5, 5, 5, PIPE_FORMAT_TYPE_UNORM ),
-   PIPE_FORMAT_L8_UNORM              = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RRR1, 1, 1, 1, 0, PIPE_FORMAT_TYPE_UNORM ), /**< ubyte luminance */
-   PIPE_FORMAT_A8_UNORM              = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_000R, 0, 0, 0, 1, PIPE_FORMAT_TYPE_UNORM ), /**< ubyte alpha */
-   PIPE_FORMAT_I8_UNORM              = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RRRR, 1, 1, 1, 1, PIPE_FORMAT_TYPE_UNORM ), /**< ubyte intensity */
-   PIPE_FORMAT_A8L8_UNORM            = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RRRG, 1, 1, 1, 1, PIPE_FORMAT_TYPE_UNORM ), /**< ubyte alpha, luminance */
-   PIPE_FORMAT_L16_UNORM             = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RRR1, 2, 2, 2, 0, PIPE_FORMAT_TYPE_UNORM ), /**< ushort luminance */
-   PIPE_FORMAT_YCBCR                 = _PIPE_FORMAT_YCBCR( 0 ),
-   PIPE_FORMAT_YCBCR_REV             = _PIPE_FORMAT_YCBCR( 1 ),
-   PIPE_FORMAT_Z16_UNORM             = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_Z000, 2, 0, 0, 0, PIPE_FORMAT_TYPE_UNORM ),
-   PIPE_FORMAT_Z32_UNORM             = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_Z000, 4, 0, 0, 0, PIPE_FORMAT_TYPE_UNORM ),
-   PIPE_FORMAT_Z32_FLOAT             = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_Z000, 4, 0, 0, 0, PIPE_FORMAT_TYPE_FLOAT ),
-   PIPE_FORMAT_S8Z24_UNORM           = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_SZ00, 1, 3, 0, 0, PIPE_FORMAT_TYPE_UNORM ),
-   PIPE_FORMAT_Z24S8_UNORM           = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_ZS00, 3, 1, 0, 0, PIPE_FORMAT_TYPE_UNORM ),
-   PIPE_FORMAT_X8Z24_UNORM           = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_0Z00, 1, 3, 0, 0, PIPE_FORMAT_TYPE_UNORM ),
-   PIPE_FORMAT_Z24X8_UNORM           = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_Z000, 3, 1, 0, 0, PIPE_FORMAT_TYPE_UNORM ),
-   PIPE_FORMAT_S8_UNORM              = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_S000, 1, 0, 0, 0, PIPE_FORMAT_TYPE_UNORM ), /**< ubyte stencil */
-   PIPE_FORMAT_R64_FLOAT             = _PIPE_FORMAT_RGBAZS_64( _PIPE_FORMAT_R001, 1, 0, 0, 0, PIPE_FORMAT_TYPE_FLOAT ),
-   PIPE_FORMAT_R64G64_FLOAT          = _PIPE_FORMAT_RGBAZS_64( _PIPE_FORMAT_RG01, 1, 1, 0, 0, PIPE_FORMAT_TYPE_FLOAT ),
-   PIPE_FORMAT_R64G64B64_FLOAT       = _PIPE_FORMAT_RGBAZS_64( _PIPE_FORMAT_RGB1, 1, 1, 1, 0, PIPE_FORMAT_TYPE_FLOAT ),
-   PIPE_FORMAT_R64G64B64A64_FLOAT    = _PIPE_FORMAT_RGBAZS_64( _PIPE_FORMAT_RGBA, 1, 1, 1, 1, PIPE_FORMAT_TYPE_FLOAT ),
-   PIPE_FORMAT_R32_FLOAT             = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R001, 4, 0, 0, 0, PIPE_FORMAT_TYPE_FLOAT ),
-   PIPE_FORMAT_R32G32_FLOAT          = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG01, 4, 4, 0, 0, PIPE_FORMAT_TYPE_FLOAT ),
-   PIPE_FORMAT_R32G32B32_FLOAT       = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 4, 4, 4, 0, PIPE_FORMAT_TYPE_FLOAT ),
-   PIPE_FORMAT_R32G32B32A32_FLOAT    = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 4, 4, 4, 4, PIPE_FORMAT_TYPE_FLOAT ),
-   PIPE_FORMAT_R32_UNORM             = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R001, 4, 0, 0, 0, PIPE_FORMAT_TYPE_UNORM ),
-   PIPE_FORMAT_R32G32_UNORM          = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG01, 4, 4, 0, 0, PIPE_FORMAT_TYPE_UNORM ),
-   PIPE_FORMAT_R32G32B32_UNORM       = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 4, 4, 4, 0, PIPE_FORMAT_TYPE_UNORM ),
-   PIPE_FORMAT_R32G32B32A32_UNORM    = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 4, 4, 4, 4, PIPE_FORMAT_TYPE_UNORM ),
-   PIPE_FORMAT_R32_USCALED           = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R001, 4, 0, 0, 0, PIPE_FORMAT_TYPE_USCALED ),
-   PIPE_FORMAT_R32G32_USCALED        = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG01, 4, 4, 0, 0, PIPE_FORMAT_TYPE_USCALED ),
-   PIPE_FORMAT_R32G32B32_USCALED     = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 4, 4, 4, 0, PIPE_FORMAT_TYPE_USCALED ),
-   PIPE_FORMAT_R32G32B32A32_USCALED  = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 4, 4, 4, 4, PIPE_FORMAT_TYPE_USCALED ),
-   PIPE_FORMAT_R32_SNORM             = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R001, 4, 0, 0, 0, PIPE_FORMAT_TYPE_SNORM ),
-   PIPE_FORMAT_R32G32_SNORM          = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG01, 4, 4, 0, 0, PIPE_FORMAT_TYPE_SNORM ),
-   PIPE_FORMAT_R32G32B32_SNORM       = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 4, 4, 4, 0, PIPE_FORMAT_TYPE_SNORM ),
-   PIPE_FORMAT_R32G32B32A32_SNORM    = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 4, 4, 4, 4, PIPE_FORMAT_TYPE_SNORM ),
-   PIPE_FORMAT_R32_SSCALED           = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R001, 4, 0, 0, 0, PIPE_FORMAT_TYPE_SSCALED ),
-   PIPE_FORMAT_R32G32_SSCALED        = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG01, 4, 4, 0, 0, PIPE_FORMAT_TYPE_SSCALED ),
-   PIPE_FORMAT_R32G32B32_SSCALED     = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 4, 4, 4, 0, PIPE_FORMAT_TYPE_SSCALED ),
-   PIPE_FORMAT_R32G32B32A32_SSCALED  = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 4, 4, 4, 4, PIPE_FORMAT_TYPE_SSCALED ),
-   PIPE_FORMAT_R16_UNORM             = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R001, 2, 0, 0, 0, PIPE_FORMAT_TYPE_UNORM ),
-   PIPE_FORMAT_R16G16_UNORM          = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG01, 2, 2, 0, 0, PIPE_FORMAT_TYPE_UNORM ),
-   PIPE_FORMAT_R16G16B16_UNORM       = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 2, 2, 2, 0, PIPE_FORMAT_TYPE_UNORM ),
-   PIPE_FORMAT_R16G16B16A16_UNORM    = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 2, 2, 2, 2, PIPE_FORMAT_TYPE_UNORM ),
-   PIPE_FORMAT_R16_USCALED           = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R001, 2, 0, 0, 0, PIPE_FORMAT_TYPE_USCALED ),
-   PIPE_FORMAT_R16G16_USCALED        = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG01, 2, 2, 0, 0, PIPE_FORMAT_TYPE_USCALED ),
-   PIPE_FORMAT_R16G16B16_USCALED     = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 2, 2, 2, 0, PIPE_FORMAT_TYPE_USCALED ),
-   PIPE_FORMAT_R16G16B16A16_USCALED  = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 2, 2, 2, 2, PIPE_FORMAT_TYPE_USCALED ),
-   PIPE_FORMAT_R16_SNORM             = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R001, 2, 0, 0, 0, PIPE_FORMAT_TYPE_SNORM ),
-   PIPE_FORMAT_R16G16_SNORM          = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG01, 2, 2, 0, 0, PIPE_FORMAT_TYPE_SNORM ),
-   PIPE_FORMAT_R16G16B16_SNORM       = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 2, 2, 2, 0, PIPE_FORMAT_TYPE_SNORM ),
-   PIPE_FORMAT_R16G16B16A16_SNORM    = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 2, 2, 2, 2, PIPE_FORMAT_TYPE_SNORM ),
-   PIPE_FORMAT_R16_SSCALED           = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R001, 2, 0, 0, 0, PIPE_FORMAT_TYPE_SSCALED ),
-   PIPE_FORMAT_R16G16_SSCALED        = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG01, 2, 2, 0, 0, PIPE_FORMAT_TYPE_SSCALED ),
-   PIPE_FORMAT_R16G16B16_SSCALED     = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 2, 2, 2, 0, PIPE_FORMAT_TYPE_SSCALED ),
-   PIPE_FORMAT_R16G16B16A16_SSCALED  = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 2, 2, 2, 2, PIPE_FORMAT_TYPE_SSCALED ),
-   PIPE_FORMAT_R8_UNORM              = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R001, 1, 0, 0, 0, PIPE_FORMAT_TYPE_UNORM ),
-   PIPE_FORMAT_R8G8_UNORM            = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG01, 1, 1, 0, 0, PIPE_FORMAT_TYPE_UNORM ),
-   PIPE_FORMAT_R8G8B8_UNORM          = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 1, 1, 1, 0, PIPE_FORMAT_TYPE_UNORM ),
-   PIPE_FORMAT_R8G8B8A8_UNORM        = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 1, 1, 1, 1, PIPE_FORMAT_TYPE_UNORM ),
-   PIPE_FORMAT_R8G8B8X8_UNORM        = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 1, 1, 1, 1, PIPE_FORMAT_TYPE_UNORM ),
-   PIPE_FORMAT_R8_USCALED            = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R001, 1, 0, 0, 0, PIPE_FORMAT_TYPE_USCALED ),
-   PIPE_FORMAT_R8G8_USCALED          = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG01, 1, 1, 0, 0, PIPE_FORMAT_TYPE_USCALED ),
-   PIPE_FORMAT_R8G8B8_USCALED        = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 1, 1, 1, 0, PIPE_FORMAT_TYPE_USCALED ),
-   PIPE_FORMAT_R8G8B8A8_USCALED      = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 1, 1, 1, 1, PIPE_FORMAT_TYPE_USCALED ),
-   PIPE_FORMAT_R8G8B8X8_USCALED      = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 1, 1, 1, 1, PIPE_FORMAT_TYPE_USCALED ),
-   PIPE_FORMAT_R8_SNORM              = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R001, 1, 0, 0, 0, PIPE_FORMAT_TYPE_SNORM ),
-   PIPE_FORMAT_R8G8_SNORM            = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG01, 1, 1, 0, 0, PIPE_FORMAT_TYPE_SNORM ),
-   PIPE_FORMAT_R8G8B8_SNORM          = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 1, 1, 1, 0, PIPE_FORMAT_TYPE_SNORM ),
-   PIPE_FORMAT_R8G8B8A8_SNORM        = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SNORM ),
-   PIPE_FORMAT_R8G8B8X8_SNORM        = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SNORM ),
-   PIPE_FORMAT_B6G5R5_SNORM          = _PIPE_FORMAT_RGBAZS_1 ( _PIPE_FORMAT_BGR1, 6, 5, 5, 0, PIPE_FORMAT_TYPE_SNORM ),
-   PIPE_FORMAT_A8B8G8R8_SNORM        = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_BGRA, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SNORM ),
-   PIPE_FORMAT_X8B8G8R8_SNORM        = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_BGR1, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SNORM ),
-   PIPE_FORMAT_R8_SSCALED            = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R001, 1, 0, 0, 0, PIPE_FORMAT_TYPE_SSCALED ),
-   PIPE_FORMAT_R8G8_SSCALED          = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG01, 1, 1, 0, 0, PIPE_FORMAT_TYPE_SSCALED ),
-   PIPE_FORMAT_R8G8B8_SSCALED        = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 1, 1, 1, 0, PIPE_FORMAT_TYPE_SSCALED ),
-   PIPE_FORMAT_R8G8B8A8_SSCALED      = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SSCALED ),
-   PIPE_FORMAT_R8G8B8X8_SSCALED      = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SSCALED ),
-   PIPE_FORMAT_R32_FIXED             = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R001, 4, 0, 0, 0, PIPE_FORMAT_TYPE_FIXED ),
-   PIPE_FORMAT_R32G32_FIXED          = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG01, 4, 4, 0, 0, PIPE_FORMAT_TYPE_FIXED ),
-   PIPE_FORMAT_R32G32B32_FIXED       = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 4, 4, 4, 0, PIPE_FORMAT_TYPE_FIXED ),
-   PIPE_FORMAT_R32G32B32A32_FIXED    = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 4, 4, 4, 4, PIPE_FORMAT_TYPE_FIXED ),
+   PIPE_FORMAT_NONE                  = 0,
+   PIPE_FORMAT_A8R8G8B8_UNORM        = 1,
+   PIPE_FORMAT_X8R8G8B8_UNORM        = 2,
+   PIPE_FORMAT_B8G8R8A8_UNORM        = 3,
+   PIPE_FORMAT_B8G8R8X8_UNORM        = 4,
+   PIPE_FORMAT_A1R5G5B5_UNORM        = 5,
+   PIPE_FORMAT_A4R4G4B4_UNORM        = 6,
+   PIPE_FORMAT_R5G6B5_UNORM          = 7,
+   PIPE_FORMAT_A2B10G10R10_UNORM     = 8,
+   PIPE_FORMAT_L8_UNORM              = 9,    /**< ubyte luminance */
+   PIPE_FORMAT_A8_UNORM              = 10,   /**< ubyte alpha */
+   PIPE_FORMAT_I8_UNORM              = 11,   /**< ubyte intensity */
+   PIPE_FORMAT_A8L8_UNORM            = 12,   /**< ubyte alpha, luminance */
+   PIPE_FORMAT_L16_UNORM             = 13,   /**< ushort luminance */
+   PIPE_FORMAT_YCBCR                 = 14,
+   PIPE_FORMAT_YCBCR_REV             = 15,
+   PIPE_FORMAT_Z16_UNORM             = 16,
+   PIPE_FORMAT_Z32_UNORM             = 17,
+   PIPE_FORMAT_Z32_FLOAT             = 18,
+   PIPE_FORMAT_S8Z24_UNORM           = 19,
+   PIPE_FORMAT_Z24S8_UNORM           = 20,
+   PIPE_FORMAT_X8Z24_UNORM           = 21,
+   PIPE_FORMAT_Z24X8_UNORM           = 22,
+   PIPE_FORMAT_S8_UNORM              = 23,   /**< ubyte stencil */
+   PIPE_FORMAT_R64_FLOAT             = 24,
+   PIPE_FORMAT_R64G64_FLOAT          = 25,
+   PIPE_FORMAT_R64G64B64_FLOAT       = 26,
+   PIPE_FORMAT_R64G64B64A64_FLOAT    = 27,
+   PIPE_FORMAT_R32_FLOAT             = 28,
+   PIPE_FORMAT_R32G32_FLOAT          = 29,
+   PIPE_FORMAT_R32G32B32_FLOAT       = 30,
+   PIPE_FORMAT_R32G32B32A32_FLOAT    = 31,
+   PIPE_FORMAT_R32_UNORM             = 32,
+   PIPE_FORMAT_R32G32_UNORM          = 33,
+   PIPE_FORMAT_R32G32B32_UNORM       = 34,
+   PIPE_FORMAT_R32G32B32A32_UNORM    = 35,
+   PIPE_FORMAT_R32_USCALED           = 36,
+   PIPE_FORMAT_R32G32_USCALED        = 37,
+   PIPE_FORMAT_R32G32B32_USCALED     = 38,
+   PIPE_FORMAT_R32G32B32A32_USCALED  = 39,
+   PIPE_FORMAT_R32_SNORM             = 40,
+   PIPE_FORMAT_R32G32_SNORM          = 41,
+   PIPE_FORMAT_R32G32B32_SNORM       = 42,
+   PIPE_FORMAT_R32G32B32A32_SNORM    = 43,
+   PIPE_FORMAT_R32_SSCALED           = 44,
+   PIPE_FORMAT_R32G32_SSCALED        = 45,
+   PIPE_FORMAT_R32G32B32_SSCALED     = 46,
+   PIPE_FORMAT_R32G32B32A32_SSCALED  = 47,
+   PIPE_FORMAT_R16_UNORM             = 48,
+   PIPE_FORMAT_R16G16_UNORM          = 49,
+   PIPE_FORMAT_R16G16B16_UNORM       = 50,
+   PIPE_FORMAT_R16G16B16A16_UNORM    = 51,
+   PIPE_FORMAT_R16_USCALED           = 52,
+   PIPE_FORMAT_R16G16_USCALED        = 53,
+   PIPE_FORMAT_R16G16B16_USCALED     = 54,
+   PIPE_FORMAT_R16G16B16A16_USCALED  = 55,
+   PIPE_FORMAT_R16_SNORM             = 56,
+   PIPE_FORMAT_R16G16_SNORM          = 57,
+   PIPE_FORMAT_R16G16B16_SNORM       = 58,
+   PIPE_FORMAT_R16G16B16A16_SNORM    = 59,
+   PIPE_FORMAT_R16_SSCALED           = 60,
+   PIPE_FORMAT_R16G16_SSCALED        = 61,
+   PIPE_FORMAT_R16G16B16_SSCALED     = 62,
+   PIPE_FORMAT_R16G16B16A16_SSCALED  = 63,
+   PIPE_FORMAT_R8_UNORM              = 64,
+   PIPE_FORMAT_R8G8_UNORM            = 65,
+   PIPE_FORMAT_R8G8B8_UNORM          = 66,
+   PIPE_FORMAT_R8G8B8A8_UNORM        = 67,
+   PIPE_FORMAT_R8G8B8X8_UNORM        = 68,
+   PIPE_FORMAT_R8_USCALED            = 69,
+   PIPE_FORMAT_R8G8_USCALED          = 70,
+   PIPE_FORMAT_R8G8B8_USCALED        = 71,
+   PIPE_FORMAT_R8G8B8A8_USCALED      = 72,
+   PIPE_FORMAT_R8G8B8X8_USCALED      = 73,
+   PIPE_FORMAT_R8_SNORM              = 74,
+   PIPE_FORMAT_R8G8_SNORM            = 75,
+   PIPE_FORMAT_R8G8B8_SNORM          = 76,
+   PIPE_FORMAT_R8G8B8A8_SNORM        = 77,
+   PIPE_FORMAT_R8G8B8X8_SNORM        = 78,
+   PIPE_FORMAT_B6G5R5_SNORM          = 79,
+   PIPE_FORMAT_A8B8G8R8_SNORM        = 80,
+   PIPE_FORMAT_X8B8G8R8_SNORM        = 81,
+   PIPE_FORMAT_R8_SSCALED            = 82,
+   PIPE_FORMAT_R8G8_SSCALED          = 83,
+   PIPE_FORMAT_R8G8B8_SSCALED        = 84,
+   PIPE_FORMAT_R8G8B8A8_SSCALED      = 85,
+   PIPE_FORMAT_R8G8B8X8_SSCALED      = 86,
+   PIPE_FORMAT_R32_FIXED             = 87,
+   PIPE_FORMAT_R32G32_FIXED          = 88,
+   PIPE_FORMAT_R32G32B32_FIXED       = 89,
+   PIPE_FORMAT_R32G32B32A32_FIXED    = 90,
    /* sRGB formats */
-   PIPE_FORMAT_L8_SRGB               = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RRR1, 1, 1, 1, 0, PIPE_FORMAT_TYPE_SRGB ),
-   PIPE_FORMAT_A8L8_SRGB             = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RRRG, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SRGB ),
-   PIPE_FORMAT_R8G8B8_SRGB           = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 1, 1, 1, 0, PIPE_FORMAT_TYPE_SRGB ),
-   PIPE_FORMAT_R8G8B8A8_SRGB         = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SRGB ),
-   PIPE_FORMAT_R8G8B8X8_SRGB         = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SRGB ),
-   PIPE_FORMAT_A8R8G8B8_SRGB         = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_ARGB, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SRGB ),
-   PIPE_FORMAT_X8R8G8B8_SRGB         = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_1RGB, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SRGB ),
-   PIPE_FORMAT_B8G8R8A8_SRGB         = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_BGRA, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SRGB ),
-   PIPE_FORMAT_B8G8R8X8_SRGB         = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_BGR1, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SRGB ),
+   PIPE_FORMAT_L8_SRGB               = 91,
+   PIPE_FORMAT_A8L8_SRGB             = 92,
+   PIPE_FORMAT_R8G8B8_SRGB           = 93,
+   PIPE_FORMAT_R8G8B8A8_SRGB         = 94,
+   PIPE_FORMAT_R8G8B8X8_SRGB         = 95,
+   PIPE_FORMAT_A8R8G8B8_SRGB         = 96,
+   PIPE_FORMAT_X8R8G8B8_SRGB         = 97,
+   PIPE_FORMAT_B8G8R8A8_SRGB         = 98,
+   PIPE_FORMAT_B8G8R8X8_SRGB         = 99,
 
    /* mixed formats */
-   PIPE_FORMAT_X8UB8UG8SR8S_NORM     = _PIPE_FORMAT_MIXED( _PIPE_FORMAT_1BGR, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1 ),
-   PIPE_FORMAT_B6UG5SR5S_NORM        = _PIPE_FORMAT_MIXED( _PIPE_FORMAT_BGR1, 6, 5, 5, 0, 0, 1, 1, 0, 1, 0 ),
+   PIPE_FORMAT_X8UB8UG8SR8S_NORM     = 100,
+   PIPE_FORMAT_B6UG5SR5S_NORM        = 101,
 
    /* compressed formats */
-   PIPE_FORMAT_DXT1_RGB              = _PIPE_FORMAT_DXT( 1, 8, 8, 8, 0, PIPE_FORMAT_TYPE_UNORM ),
-   PIPE_FORMAT_DXT1_RGBA             = _PIPE_FORMAT_DXT( 1, 8, 8, 8, 8, PIPE_FORMAT_TYPE_UNORM ),
-   PIPE_FORMAT_DXT3_RGBA             = _PIPE_FORMAT_DXT( 3, 8, 8, 8, 8, PIPE_FORMAT_TYPE_UNORM ),
-   PIPE_FORMAT_DXT5_RGBA             = _PIPE_FORMAT_DXT( 5, 8, 8, 8, 8, PIPE_FORMAT_TYPE_UNORM ),
+   PIPE_FORMAT_DXT1_RGB              = 102,
+   PIPE_FORMAT_DXT1_RGBA             = 103,
+   PIPE_FORMAT_DXT3_RGBA             = 104,
+   PIPE_FORMAT_DXT5_RGBA             = 105,
 
    /* sRGB, compressed */
-   PIPE_FORMAT_DXT1_SRGB             = _PIPE_FORMAT_DXT( 1, 8, 8, 8, 0, PIPE_FORMAT_TYPE_SRGB ),
-   PIPE_FORMAT_DXT1_SRGBA            = _PIPE_FORMAT_DXT( 1, 8, 8, 8, 8, PIPE_FORMAT_TYPE_SRGB ),
-   PIPE_FORMAT_DXT3_SRGBA            = _PIPE_FORMAT_DXT( 3, 8, 8, 8, 8, PIPE_FORMAT_TYPE_SRGB ),
-   PIPE_FORMAT_DXT5_SRGBA            = _PIPE_FORMAT_DXT( 5, 8, 8, 8, 8, PIPE_FORMAT_TYPE_SRGB )
+   PIPE_FORMAT_DXT1_SRGB             = 106,
+   PIPE_FORMAT_DXT1_SRGBA            = 107,
+   PIPE_FORMAT_DXT3_SRGBA            = 108,
+   PIPE_FORMAT_DXT5_SRGBA            = 109,
+
+   PIPE_FORMAT_COUNT
 };
 
 /**
@@ -394,224 +174,6 @@ enum pipe_format {
  */
 extern const char *pf_name( enum pipe_format format );
 
-/**
- * Return bits for a particular component.
- * \param comp  component index, starting at 0
- */
-static INLINE uint pf_get_component_bits( enum pipe_format format, uint comp )
-{
-   uint size;
-
-   if (pf_swizzle_x(format) == comp) {
-      size = pf_size_x(format);
-   }
-   else if (pf_swizzle_y(format) == comp) {
-      size = pf_size_y(format);
-   }
-   else if (pf_swizzle_z(format) == comp) {
-      size = pf_size_z(format);
-   }
-   else if (pf_swizzle_w(format) == comp) {
-      size = pf_size_w(format);
-   }
-   else {
-      size = 0;
-   }
-   if (pf_layout( format ) == PIPE_FORMAT_LAYOUT_RGBAZS)
-      return size << pf_exp2( format );
-   return size << (pf_mixed_scale8( format ) * 3);
-}
-
-/**
- * Return total bits needed for the pixel format.
- */
-static INLINE uint pf_get_bits( enum pipe_format format )
-{
-   switch (pf_layout(format)) {
-   case PIPE_FORMAT_LAYOUT_RGBAZS:
-   case PIPE_FORMAT_LAYOUT_MIXED:
-      return
-         pf_get_component_bits( format, PIPE_FORMAT_COMP_0 ) +
-         pf_get_component_bits( format, PIPE_FORMAT_COMP_1 ) +
-         pf_get_component_bits( format, PIPE_FORMAT_COMP_R ) +
-         pf_get_component_bits( format, PIPE_FORMAT_COMP_G ) +
-         pf_get_component_bits( format, PIPE_FORMAT_COMP_B ) +
-         pf_get_component_bits( format, PIPE_FORMAT_COMP_A ) +
-         pf_get_component_bits( format, PIPE_FORMAT_COMP_Z ) +
-         pf_get_component_bits( format, PIPE_FORMAT_COMP_S );
-   case PIPE_FORMAT_LAYOUT_YCBCR:
-      assert( format == PIPE_FORMAT_YCBCR || format == PIPE_FORMAT_YCBCR_REV );
-      /* return effective bits per pixel */
-      return 16; 
-   default:
-      assert( 0 );
-      return 0;
-   }
-}
-
-/**
- * Return bytes per pixel for the given format.
- */
-static INLINE uint pf_get_size( enum pipe_format format )
-{
-   assert(pf_get_bits(format) % 8 == 0);
-   return pf_get_bits(format) / 8;
-}
-
-/**
- * Describe accurately the pixel format.
- * 
- * The chars-per-pixel concept falls apart with compressed and yuv images, where
- * more than one pixel are coded in a single data block. This structure 
- * describes that block.
- * 
- * Simple pixel formats are effectively a 1x1xcpp block.
- */
-struct pipe_format_block
-{
-   /** Block size in bytes */
-   unsigned size;
-   
-   /** Block width in pixels */
-   unsigned width;
-   
-   /** Block height in pixels */
-   unsigned height;
-};
-
-/**
- * Describe pixel format's block.   
- * 
- * @sa http://msdn2.microsoft.com/en-us/library/ms796147.aspx
- */
-static INLINE void 
-pf_get_block(enum pipe_format format, struct pipe_format_block *block)
-{
-   switch(format) {
-   case PIPE_FORMAT_DXT1_RGBA:
-   case PIPE_FORMAT_DXT1_RGB:
-   case PIPE_FORMAT_DXT1_SRGBA:
-   case PIPE_FORMAT_DXT1_SRGB:
-      block->size = 8;
-      block->width = 4;
-      block->height = 4;
-      break;
-   case PIPE_FORMAT_DXT3_RGBA:
-   case PIPE_FORMAT_DXT5_RGBA:
-   case PIPE_FORMAT_DXT3_SRGBA:
-   case PIPE_FORMAT_DXT5_SRGBA:
-      block->size = 16;
-      block->width = 4;
-      block->height = 4;
-      break;
-   case PIPE_FORMAT_YCBCR:
-   case PIPE_FORMAT_YCBCR_REV:
-      block->size = 4; /* 2*cpp */
-      block->width = 2;
-      block->height = 1;
-      break;
-   default:
-      block->size = pf_get_size(format);
-      block->width = 1;
-      block->height = 1;
-      break;
-   }
-}
-
-static INLINE unsigned
-pf_get_nblocksx(const struct pipe_format_block *block, unsigned x)
-{
-   return (x + block->width - 1)/block->width;
-}
-
-static INLINE unsigned
-pf_get_nblocksy(const struct pipe_format_block *block, unsigned y)
-{
-   return (y + block->height - 1)/block->height;
-}
-
-static INLINE unsigned
-pf_get_nblocks(const struct pipe_format_block *block, unsigned width, unsigned height)
-{
-   return pf_get_nblocksx(block, width)*pf_get_nblocksy(block, height);
-}
-
-static INLINE size_t
-pf_get_stride(const struct pipe_format_block *block, unsigned width)
-{
-   return pf_get_nblocksx(block, width)*block->size;
-}
-
-static INLINE size_t
-pf_get_2d_size(const struct pipe_format_block *block, size_t stride, unsigned height)
-{
-   return pf_get_nblocksy(block, height)*stride;
-}
-
-static INLINE boolean 
-pf_is_depth_or_stencil( enum pipe_format format )
-{
-   return (pf_get_component_bits( format, PIPE_FORMAT_COMP_Z ) +
-           pf_get_component_bits( format, PIPE_FORMAT_COMP_S )) != 0;
-}
-
-static INLINE boolean 
-pf_is_depth_and_stencil( enum pipe_format format )
-{
-   return (pf_get_component_bits( format, PIPE_FORMAT_COMP_Z ) != 0 &&
-           pf_get_component_bits( format, PIPE_FORMAT_COMP_S ) != 0);
-}
-
-/** DEPRECATED: For backwards compatibility */
-static INLINE boolean
-pf_is_depth_stencil( enum pipe_format format )
-{
-   return pf_is_depth_or_stencil( format );
-}
-
-static INLINE boolean 
-pf_is_compressed( enum pipe_format format )
-{
-   return pf_layout(format) == PIPE_FORMAT_LAYOUT_DXT ? TRUE : FALSE;
-}
-
-static INLINE boolean 
-pf_is_ycbcr( enum pipe_format format )
-{
-   return pf_layout(format) == PIPE_FORMAT_LAYOUT_YCBCR ? TRUE : FALSE;
-}
-
-static INLINE boolean 
-pf_has_alpha( enum pipe_format format )
-{
-   switch (pf_layout(format)) {
-   case PIPE_FORMAT_LAYOUT_RGBAZS:
-   case PIPE_FORMAT_LAYOUT_MIXED:
-      /* FIXME: pf_get_component_bits( PIPE_FORMAT_A8L8_UNORM, PIPE_FORMAT_COMP_A ) should not return 0 right? */
-      if(format == PIPE_FORMAT_A8_UNORM || 
-         format == PIPE_FORMAT_A8L8_UNORM || 
-         format == PIPE_FORMAT_A8L8_SRGB)
-         return TRUE;
-      return pf_get_component_bits( format, PIPE_FORMAT_COMP_A ) ? TRUE : FALSE;
-   case PIPE_FORMAT_LAYOUT_YCBCR:
-      return FALSE; 
-   case PIPE_FORMAT_LAYOUT_DXT:
-      switch (format) {
-      case PIPE_FORMAT_DXT1_RGBA:
-      case PIPE_FORMAT_DXT3_RGBA:
-      case PIPE_FORMAT_DXT5_RGBA:
-      case PIPE_FORMAT_DXT1_SRGBA:
-      case PIPE_FORMAT_DXT3_SRGBA:
-      case PIPE_FORMAT_DXT5_SRGBA:
-         return TRUE;
-      default:
-         return FALSE;
-      }
-   default:
-      assert( 0 );
-      return FALSE;
-   }
-}
 
 enum pipe_video_chroma_format
 {
index 1f9088b3e9c87f4b5efc26731cae3933aa89697e..c1c7415e023f974370b09e95ab67d129e952a63d 100644 (file)
@@ -51,7 +51,7 @@ pipe_reference_init(struct pipe_reference *reference, unsigned count)
 }
 
 
-static INLINE bool
+static INLINE boolean
 pipe_is_referenced(struct pipe_reference *reference)
 {
    return p_atomic_read(&reference->count) != 0;
@@ -59,30 +59,29 @@ pipe_is_referenced(struct pipe_reference *reference)
 
 
 /**
- * Set 'ptr' to point to 'reference' and update reference counting.
- * The old thing pointed to, if any, will be unreferenced first.
- * 'reference' may be NULL.
+ * Update reference counting.
+ * The old thing pointed to, if any, will be unreferenced.
+ * Both 'ptr' and 'reference' may be NULL.
+ * \return TRUE if the object's refcount hits zero and should be destroyed.
  */
-static INLINE bool
-pipe_reference(struct pipe_reference **ptr, struct pipe_reference *reference)
+static INLINE boolean
+pipe_reference(struct pipe_reference *ptr, struct pipe_reference *reference)
 {
-   bool destroy = FALSE;
+   boolean destroy = FALSE;
 
-   if(*ptr != reference) {
+   if(ptr != reference) {
       /* bump the reference.count first */
       if (reference) {
          assert(pipe_is_referenced(reference));
          p_atomic_inc(&reference->count);
       }
    
-      if (*ptr) {
-         assert(pipe_is_referenced(*ptr));
-         if (p_atomic_dec_zero(&(*ptr)->count)) {
+      if (ptr) {
+         assert(pipe_is_referenced(ptr));
+         if (p_atomic_dec_zero(&ptr->count)) {
             destroy = TRUE;
          }
       }
-   
-      *ptr = reference;
    }
 
    return destroy;
index 5fa6c9af30b163aba4b6295638d9bd72af94802c..550e2abc32a8d746203aabff41063af003f02f0b 100644 (file)
@@ -1,6 +1,7 @@
 /**************************************************************************
  * 
  * 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
@@ -25,8 +26,8 @@
  * 
  **************************************************************************/
 
-#ifndef TGSI_TOKEN_H
-#define TGSI_TOKEN_H
+#ifndef P_SHADER_TOKENS_H
+#define P_SHADER_TOKENS_H
 
 #ifdef __cplusplus
 extern "C" {
@@ -34,12 +35,6 @@ extern "C" {
 
 #include "p_compiler.h"
 
-struct tgsi_version
-{
-   unsigned MajorVersion  : 8;
-   unsigned MinorVersion  : 8;
-   unsigned Padding       : 16;
-};
 
 struct tgsi_header
 {
@@ -60,25 +55,27 @@ struct tgsi_processor
 #define TGSI_TOKEN_TYPE_DECLARATION    0
 #define TGSI_TOKEN_TYPE_IMMEDIATE      1
 #define TGSI_TOKEN_TYPE_INSTRUCTION    2
+#define TGSI_TOKEN_TYPE_PROPERTY       3
 
 struct tgsi_token
 {
    unsigned Type       : 4;  /**< TGSI_TOKEN_TYPE_x */
    unsigned NrTokens   : 8;  /**< UINT */
-   unsigned Padding    : 19;
-   unsigned Extended   : 1;  /**< BOOL */
+   unsigned Padding    : 20;
 };
 
 enum tgsi_file_type {
-   TGSI_FILE_NULL        =0,
-   TGSI_FILE_CONSTANT    =1,
-   TGSI_FILE_INPUT       =2,
-   TGSI_FILE_OUTPUT      =3,
-   TGSI_FILE_TEMPORARY   =4,
-   TGSI_FILE_SAMPLER     =5,
-   TGSI_FILE_ADDRESS     =6,
-   TGSI_FILE_IMMEDIATE   =7,
-   TGSI_FILE_LOOP        =8,
+   TGSI_FILE_NULL         =0,
+   TGSI_FILE_CONSTANT     =1,
+   TGSI_FILE_INPUT        =2,
+   TGSI_FILE_OUTPUT       =3,
+   TGSI_FILE_TEMPORARY    =4,
+   TGSI_FILE_SAMPLER      =5,
+   TGSI_FILE_ADDRESS      =6,
+   TGSI_FILE_IMMEDIATE    =7,
+   TGSI_FILE_LOOP         =8,
+   TGSI_FILE_PREDICATE    =9,
+   TGSI_FILE_SYSTEM_VALUE =10,
    TGSI_FILE_COUNT      /**< how many TGSI_FILE_ types */
 };
 
@@ -115,8 +112,7 @@ struct tgsi_declaration
    unsigned Semantic    : 1;  /**< BOOL, any semantic info? */
    unsigned Centroid    : 1;  /**< centroid sampling? */
    unsigned Invariant   : 1;  /**< invariant optimization? */
-   unsigned Padding     : 4;
-   unsigned Extended    : 1;  /**< BOOL */
+   unsigned Padding     : 5;
 };
 
 struct tgsi_declaration_range
@@ -125,37 +121,58 @@ struct tgsi_declaration_range
    unsigned Last    : 16; /**< UINT */
 };
 
-#define TGSI_SEMANTIC_POSITION 0
-#define TGSI_SEMANTIC_COLOR    1
-#define TGSI_SEMANTIC_BCOLOR   2 /**< back-face color */
-#define TGSI_SEMANTIC_FOG      3
-#define TGSI_SEMANTIC_PSIZE    4
-#define TGSI_SEMANTIC_GENERIC  5
-#define TGSI_SEMANTIC_NORMAL   6
-#define TGSI_SEMANTIC_FACE     7
-#define TGSI_SEMANTIC_COUNT    8 /**< number of semantic values */
+#define TGSI_SEMANTIC_POSITION  0
+#define TGSI_SEMANTIC_COLOR     1
+#define TGSI_SEMANTIC_BCOLOR    2 /**< back-face color */
+#define TGSI_SEMANTIC_FOG       3
+#define TGSI_SEMANTIC_PSIZE     4
+#define TGSI_SEMANTIC_GENERIC   5
+#define TGSI_SEMANTIC_NORMAL    6
+#define TGSI_SEMANTIC_FACE      7
+#define TGSI_SEMANTIC_EDGEFLAG  8
+#define TGSI_SEMANTIC_PRIMID    9
+#define TGSI_SEMANTIC_COUNT    10 /**< number of semantic values */
 
 struct tgsi_declaration_semantic
 {
-   unsigned SemanticName   : 8;  /**< one of TGSI_SEMANTIC_x */
-   unsigned SemanticIndex  : 16; /**< UINT */
+   unsigned Name           : 8;  /**< one of TGSI_SEMANTIC_x */
+   unsigned Index          : 16; /**< UINT */
    unsigned Padding        : 8;
 };
 
 #define TGSI_IMM_FLOAT32   0
+#define TGSI_IMM_UINT32    1
+#define TGSI_IMM_INT32     2
 
 struct tgsi_immediate
 {
    unsigned Type       : 4;  /**< TGSI_TOKEN_TYPE_IMMEDIATE */
    unsigned NrTokens   : 8;  /**< UINT */
    unsigned DataType   : 4;  /**< one of TGSI_IMM_x */
-   unsigned Padding    : 15;
-   unsigned Extended   : 1;  /**< BOOL */
+   unsigned Padding    : 16;
 };
 
 union tgsi_immediate_data
 {
    float Float;
+   unsigned Uint;
+   int Int;
+};
+
+#define TGSI_PROPERTY_GS_INPUT_PRIM          0
+#define TGSI_PROPERTY_GS_OUTPUT_PRIM         1
+#define TGSI_PROPERTY_GS_MAX_VERTICES        2
+#define TGSI_PROPERTY_COUNT                  3
+
+struct tgsi_property {
+   unsigned Type         : 4;  /**< TGSI_TOKEN_TYPE_PROPERTY */
+   unsigned NrTokens     : 8;  /**< UINT */
+   unsigned PropertyName : 8;  /**< one of TGSI_PROPERTY */
+   unsigned Padding      : 12;
+};
+
+struct tgsi_property_data {
+   unsigned Data;
 };
 
 /* TGSI opcodes.  
@@ -251,7 +268,7 @@ union tgsi_immediate_data
 #define TGSI_OPCODE_NOT                 85
 #define TGSI_OPCODE_TRUNC               86
 #define TGSI_OPCODE_SHL                 87
-#define TGSI_OPCODE_SHR                 88
+                                /* gap */
 #define TGSI_OPCODE_AND                 89
 #define TGSI_OPCODE_OR                  90
 #define TGSI_OPCODE_MOD                 91
@@ -266,10 +283,7 @@ union tgsi_immediate_data
 #define TGSI_OPCODE_BGNSUB              100
 #define TGSI_OPCODE_ENDLOOP             101
 #define TGSI_OPCODE_ENDSUB              102
-#define TGSI_OPCODE_NOISE1              103
-#define TGSI_OPCODE_NOISE2              104
-#define TGSI_OPCODE_NOISE3              105
-#define TGSI_OPCODE_NOISE4              106
+                                /* gap */
 #define TGSI_OPCODE_NOP                 107
                                 /* gap */
 #define TGSI_OPCODE_NRM4                112
@@ -278,8 +292,34 @@ union tgsi_immediate_data
 #define TGSI_OPCODE_BREAKC              115
 #define TGSI_OPCODE_KIL                 116  /* conditional kill */
 #define TGSI_OPCODE_END                 117  /* aka HALT */
-#define TGSI_OPCODE_SWZ                 118
-#define TGSI_OPCODE_LAST                119
+                                /* gap */
+#define TGSI_OPCODE_F2I                 119
+#define TGSI_OPCODE_IDIV                120
+#define TGSI_OPCODE_IMAX                121
+#define TGSI_OPCODE_IMIN                122
+#define TGSI_OPCODE_INEG                123
+#define TGSI_OPCODE_ISGE                124
+#define TGSI_OPCODE_ISHR                125
+#define TGSI_OPCODE_ISLT                126
+#define TGSI_OPCODE_F2U                 127
+#define TGSI_OPCODE_U2F                 128
+#define TGSI_OPCODE_UADD                129
+#define TGSI_OPCODE_UDIV                130
+#define TGSI_OPCODE_UMAD                131
+#define TGSI_OPCODE_UMAX                132
+#define TGSI_OPCODE_UMIN                133
+#define TGSI_OPCODE_UMOD                134
+#define TGSI_OPCODE_UMUL                135
+#define TGSI_OPCODE_USEQ                136
+#define TGSI_OPCODE_USGE                137
+#define TGSI_OPCODE_USHR                138
+#define TGSI_OPCODE_USLT                139
+#define TGSI_OPCODE_USNE                140
+#define TGSI_OPCODE_SWITCH              141
+#define TGSI_OPCODE_CASE                142
+#define TGSI_OPCODE_DEFAULT             143
+#define TGSI_OPCODE_ENDSWITCH           144
+#define TGSI_OPCODE_LAST                145
 
 #define TGSI_SAT_NONE            0  /* do not saturate */
 #define TGSI_SAT_ZERO_ONE        1  /* clamp to [0,1] */
@@ -294,7 +334,7 @@ union tgsi_immediate_data
  * respectively. For a given operation code, those numbers are fixed and are
  * present here only for convenience.
  *
- * If Extended is TRUE, it is now executed.
+ * If Predicate is TRUE, tgsi_instruction_predicate token immediately follows.
  *
  * Saturate controls how are final results in destination registers modified.
  */
@@ -307,12 +347,16 @@ struct tgsi_instruction
    unsigned Saturate   : 2;  /* TGSI_SAT_ */
    unsigned NumDstRegs : 2;  /* UINT */
    unsigned NumSrcRegs : 4;  /* UINT */
-   unsigned Padding    : 3;
-   unsigned Extended   : 1;  /* BOOL */
+   unsigned Predicate  : 1;  /* BOOL */
+   unsigned Label      : 1;
+   unsigned Texture    : 1;
+   unsigned Padding    : 1;
 };
 
 /*
- * If tgsi_instruction::Extended is TRUE, tgsi_instruction_ext follows.
+ * If tgsi_instruction::Label is TRUE, tgsi_instruction_label follows.
+ *
+ * If tgsi_instruction::Texture is TRUE, tgsi_instruction_texture follows.
  * 
  * Then, tgsi_instruction::NumDstRegs of tgsi_dst_register follow.
  * 
@@ -322,91 +366,15 @@ struct tgsi_instruction
  * instruction, including the instruction word.
  */
 
-#define TGSI_INSTRUCTION_EXT_TYPE_NV        0
-#define TGSI_INSTRUCTION_EXT_TYPE_LABEL     1
-#define TGSI_INSTRUCTION_EXT_TYPE_TEXTURE   2
-#define TGSI_INSTRUCTION_EXT_TYPE_PREDICATE 3
-
-struct tgsi_instruction_ext
-{
-   unsigned Type       : 4;  /* TGSI_INSTRUCTION_EXT_TYPE_ */
-   unsigned Padding    : 27;
-   unsigned Extended   : 1;  /* BOOL */
-};
-
-/*
- * If tgsi_instruction_ext::Type is TGSI_INSTRUCTION_EXT_TYPE_NV, it should
- * be cast to tgsi_instruction_ext_nv.
- * 
- * If tgsi_instruction_ext::Type is TGSI_INSTRUCTION_EXT_TYPE_LABEL, it
- * should be cast to tgsi_instruction_ext_label.
- * 
- * If tgsi_instruction_ext::Type is TGSI_INSTRUCTION_EXT_TYPE_TEXTURE, it
- * should be cast to tgsi_instruction_ext_texture.
- * 
- * If tgsi_instruction_ext::Type is TGSI_INSTRUCTION_EXT_TYPE_PREDICATE, it
- * should be cast to tgsi_instruction_ext_predicate.
- * 
- * If tgsi_instruction_ext::Extended is TRUE, another tgsi_instruction_ext
- * follows.
- */
-
-#define TGSI_PRECISION_DEFAULT      0
-#define TGSI_PRECISION_FLOAT32      1
-#define TGSI_PRECISION_FLOAT16      2
-#define TGSI_PRECISION_FIXED12      3
-
-#define TGSI_CC_GT      0
-#define TGSI_CC_EQ      1
-#define TGSI_CC_LT      2
-#define TGSI_CC_GE      3
-#define TGSI_CC_LE      4
-#define TGSI_CC_NE      5
-#define TGSI_CC_TR      6
-#define TGSI_CC_FL      7
-
 #define TGSI_SWIZZLE_X      0
 #define TGSI_SWIZZLE_Y      1
 #define TGSI_SWIZZLE_Z      2
 #define TGSI_SWIZZLE_W      3
 
-/**
- * Precision controls the precision at which the operation should be executed.
- *
- * CondDstUpdate enables condition code register writes. When this field is
- * TRUE, CondDstIndex specifies the index of the condition code register to
- * update.
- *
- * CondFlowEnable enables conditional execution of the operation. When this
- * field is TRUE, CondFlowIndex specifies the index of the condition code
- * register to test against CondMask with component swizzle controled by
- * CondSwizzleX, CondSwizzleY, CondSwizzleZ and CondSwizzleW. If the test fails,
- * the operation is not executed.
- */
-
-struct tgsi_instruction_ext_nv
+struct tgsi_instruction_label
 {
-   unsigned Type             : 4;    /* TGSI_INSTRUCTION_EXT_TYPE_NV */
-   unsigned Precision        : 4;    /* TGSI_PRECISION_ */
-   unsigned CondDstIndex     : 4;    /* UINT */
-   unsigned CondFlowIndex    : 4;    /* UINT */
-   unsigned CondMask         : 4;    /* TGSI_CC_ */
-   unsigned CondSwizzleX     : 2;    /* TGSI_SWIZZLE_ */
-   unsigned CondSwizzleY     : 2;    /* TGSI_SWIZZLE_ */
-   unsigned CondSwizzleZ     : 2;    /* TGSI_SWIZZLE_ */
-   unsigned CondSwizzleW     : 2;    /* TGSI_SWIZZLE_ */
-   unsigned CondDstUpdate    : 1;    /* BOOL */
-   unsigned CondFlowEnable   : 1;    /* BOOL */
-   unsigned Padding          : 1;
-   unsigned Extended         : 1;    /* BOOL */
-};
-
-struct tgsi_instruction_ext_label
-{
-   unsigned Type     : 4;    /* TGSI_INSTRUCTION_EXT_TYPE_LABEL */
    unsigned Label    : 24;   /* UINT */
-   unsigned Padding  : 3;
-   unsigned Extended : 1;    /* BOOL */
+   unsigned Padding  : 8;
 };
 
 #define TGSI_TEXTURE_UNKNOWN        0
@@ -420,21 +388,25 @@ struct tgsi_instruction_ext_label
 #define TGSI_TEXTURE_SHADOWRECT     8
 #define TGSI_TEXTURE_COUNT          9
 
-struct tgsi_instruction_ext_texture
+struct tgsi_instruction_texture
 {
-   unsigned Type     : 4;    /* TGSI_INSTRUCTION_EXT_TYPE_TEXTURE */
    unsigned Texture  : 8;    /* TGSI_TEXTURE_ */
-   unsigned Padding  : 19;
-   unsigned Extended : 1;    /* BOOL */
+   unsigned Padding  : 24;
 };
 
-struct tgsi_instruction_ext_predicate
+/*
+ * For SM3, the following constraint applies.
+ *   - Swizzle is either set to identity or replicate.
+ */
+struct tgsi_instruction_predicate
 {
-   unsigned Type             : 4;    /* TGSI_INSTRUCTION_EXT_TYPE_PREDICATE */
-   unsigned PredDstIndex     : 4;    /* UINT */
-   unsigned PredWriteMask    : 4;    /* TGSI_WRITEMASK_ */
-   unsigned Padding          : 19;
-   unsigned Extended         : 1;    /* BOOL */
+   int      Index    : 16; /* SINT */
+   unsigned SwizzleX : 2;  /* TGSI_SWIZZLE_x */
+   unsigned SwizzleY : 2;  /* TGSI_SWIZZLE_x */
+   unsigned SwizzleZ : 2;  /* TGSI_SWIZZLE_x */
+   unsigned SwizzleW : 2;  /* TGSI_SWIZZLE_x */
+   unsigned Negate   : 1;  /* BOOL */
+   unsigned Padding  : 7;
 };
 
 /**
@@ -451,26 +423,24 @@ struct tgsi_instruction_ext_predicate
  * The fetched register components are swizzled according to SwizzleX, SwizzleY,
  * SwizzleZ and SwizzleW.
  *
- * If Extended is TRUE, any further modifications to the source register are
- * made to this temporary storage.
  */
 
 struct tgsi_src_register
 {
    unsigned File        : 4;  /* TGSI_FILE_ */
+   unsigned Indirect    : 1;  /* BOOL */
+   unsigned Dimension   : 1;  /* BOOL */
+   int      Index       : 16; /* SINT */
    unsigned SwizzleX    : 2;  /* TGSI_SWIZZLE_ */
    unsigned SwizzleY    : 2;  /* TGSI_SWIZZLE_ */
    unsigned SwizzleZ    : 2;  /* TGSI_SWIZZLE_ */
    unsigned SwizzleW    : 2;  /* TGSI_SWIZZLE_ */
-   unsigned Negate      : 1;  /* BOOL */
-   unsigned Indirect    : 1;  /* BOOL */
-   unsigned Dimension   : 1;  /* BOOL */
-   int      Index       : 16; /* SINT */
-   unsigned Extended    : 1;  /* BOOL */
+   unsigned Absolute    : 1;    /* BOOL */
+   unsigned Negate      : 1;    /* BOOL */
 };
 
 /**
- * If tgsi_src_register::Extended is TRUE, tgsi_src_register_ext follows.
+ * If tgsi_src_register::Modifier is TRUE, tgsi_src_register_modifier follows.
  * 
  * Then, if tgsi_src_register::Indirect is TRUE, another tgsi_src_register
  * follows.
@@ -478,95 +448,13 @@ struct tgsi_src_register
  * Then, if tgsi_src_register::Dimension is TRUE, tgsi_dimension follows.
  */
 
-#define TGSI_SRC_REGISTER_EXT_TYPE_SWZ      0
-#define TGSI_SRC_REGISTER_EXT_TYPE_MOD      1
-
-struct tgsi_src_register_ext
-{
-   unsigned Type     : 4;    /* TGSI_SRC_REGISTER_EXT_TYPE_ */
-   unsigned Padding  : 27;
-   unsigned Extended : 1;    /* BOOL */
-};
-
-/**
- * If tgsi_src_register_ext::Type is TGSI_SRC_REGISTER_EXT_TYPE_SWZ,
- * it should be cast to tgsi_src_register_ext_swz.
- * 
- * If tgsi_src_register_ext::Type is TGSI_SRC_REGISTER_EXT_TYPE_MOD,
- * it should be cast to tgsi_src_register_ext_mod.
- * 
- * If tgsi_dst_register_ext::Extended is TRUE, another tgsi_dst_register_ext
- * follows.
- */
-
-#define TGSI_EXTSWIZZLE_X       TGSI_SWIZZLE_X
-#define TGSI_EXTSWIZZLE_Y       TGSI_SWIZZLE_Y
-#define TGSI_EXTSWIZZLE_Z       TGSI_SWIZZLE_Z
-#define TGSI_EXTSWIZZLE_W       TGSI_SWIZZLE_W
-#define TGSI_EXTSWIZZLE_ZERO    4
-#define TGSI_EXTSWIZZLE_ONE     5
-
-/**
- * ExtSwizzleX, ExtSwizzleY, ExtSwizzleZ and ExtSwizzleW swizzle the source
- * register in an extended manner.
- *
- * NegateX, NegateY, NegateZ and NegateW negate individual components of the
- * source register.
- *
- * NOTE: To simplify matter, if this token is present, the corresponding Swizzle
- *       and Negate fields in tgsi_src_register should be set to X,Y,Z,W
- *       and FALSE, respectively.
- */
-
-struct tgsi_src_register_ext_swz
-{
-   unsigned Type         : 4;    /* TGSI_SRC_REGISTER_EXT_TYPE_SWZ */
-   unsigned ExtSwizzleX  : 4;    /* TGSI_EXTSWIZZLE_ */
-   unsigned ExtSwizzleY  : 4;    /* TGSI_EXTSWIZZLE_ */
-   unsigned ExtSwizzleZ  : 4;    /* TGSI_EXTSWIZZLE_ */
-   unsigned ExtSwizzleW  : 4;    /* TGSI_EXTSWIZZLE_ */
-   unsigned NegateX      : 1;    /* BOOL */
-   unsigned NegateY      : 1;    /* BOOL */
-   unsigned NegateZ      : 1;    /* BOOL */
-   unsigned NegateW      : 1;    /* BOOL */
-   unsigned Padding      : 7;
-   unsigned Extended     : 1;    /* BOOL */
-};
-
-/**
- * Extra src register modifiers
- *
- * If Complement is TRUE, the source register is modified by subtracting it
- * from 1.0.
- *
- * If Bias is TRUE, the source register is modified by subtracting 0.5 from it.
- *
- * If Scale2X is TRUE, the source register is modified by multiplying it by 2.0.
- *
- * If Absolute is TRUE, the source register is modified by removing the sign.
- *
- * If Negate is TRUE, the source register is modified by negating it.
- */
-
-struct tgsi_src_register_ext_mod
-{
-   unsigned Type         : 4;    /* TGSI_SRC_REGISTER_EXT_TYPE_MOD */
-   unsigned Complement   : 1;    /* BOOL */
-   unsigned Bias         : 1;    /* BOOL */
-   unsigned Scale2X      : 1;    /* BOOL */
-   unsigned Absolute     : 1;    /* BOOL */
-   unsigned Negate       : 1;    /* BOOL */
-   unsigned Padding      : 22;
-   unsigned Extended     : 1;    /* BOOL */
-};
 
 struct tgsi_dimension
 {
    unsigned Indirect    : 1;  /* BOOL */
    unsigned Dimension   : 1;  /* BOOL */
-   unsigned Padding     : 13;
+   unsigned Padding     : 14;
    int      Index       : 16; /* SINT */
-   unsigned Extended    : 1;  /* BOOL */
 };
 
 struct tgsi_dst_register
@@ -576,90 +464,7 @@ struct tgsi_dst_register
    unsigned Indirect    : 1;  /* BOOL */
    unsigned Dimension   : 1;  /* BOOL */
    int      Index       : 16; /* SINT */
-   unsigned Padding     : 5;
-   unsigned Extended    : 1;  /* BOOL */
-};
-
-/*
- * If tgsi_dst_register::Extended is TRUE, tgsi_dst_register_ext follows.
- * 
- * Then, if tgsi_dst_register::Indirect is TRUE, tgsi_src_register follows.
- */
-
-#define TGSI_DST_REGISTER_EXT_TYPE_CONDCODE     0
-#define TGSI_DST_REGISTER_EXT_TYPE_MODULATE     1
-#define TGSI_DST_REGISTER_EXT_TYPE_PREDICATE    2
-
-struct tgsi_dst_register_ext
-{
-   unsigned Type     : 4;    /* TGSI_DST_REGISTER_EXT_TYPE_ */
-   unsigned Padding  : 27;
-   unsigned Extended : 1;    /* BOOL */
-};
-
-/**
- * Extra destination register modifiers
- *
- * If tgsi_dst_register_ext::Type is TGSI_DST_REGISTER_EXT_TYPE_CONDCODE,
- * it should be cast to tgsi_dst_register_ext_condcode.
- * 
- * If tgsi_dst_register_ext::Type is TGSI_DST_REGISTER_EXT_TYPE_MODULATE,
- * it should be cast to tgsi_dst_register_ext_modulate.
- * 
- * If tgsi_dst_register_ext::Type is TGSI_DST_REGISTER_EXT_TYPE_PREDICATE,
- * it should be cast to tgsi_dst_register_ext_predicate.
- * 
- * If tgsi_dst_register_ext::Extended is TRUE, another tgsi_dst_register_ext
- * follows.
- */
-struct tgsi_dst_register_ext_concode
-{
-   unsigned Type         : 4;    /* TGSI_DST_REGISTER_EXT_TYPE_CONDCODE */
-   unsigned CondMask     : 4;    /* TGSI_CC_ */
-   unsigned CondSwizzleX : 2;    /* TGSI_SWIZZLE_ */
-   unsigned CondSwizzleY : 2;    /* TGSI_SWIZZLE_ */
-   unsigned CondSwizzleZ : 2;    /* TGSI_SWIZZLE_ */
-   unsigned CondSwizzleW : 2;    /* TGSI_SWIZZLE_ */
-   unsigned CondSrcIndex : 4;    /* UINT */
-   unsigned Padding      : 11;
-   unsigned Extended     : 1;    /* BOOL */
-};
-
-#define TGSI_MODULATE_1X        0
-#define TGSI_MODULATE_2X        1
-#define TGSI_MODULATE_4X        2
-#define TGSI_MODULATE_8X        3
-#define TGSI_MODULATE_HALF      4
-#define TGSI_MODULATE_QUARTER   5
-#define TGSI_MODULATE_EIGHTH    6
-#define TGSI_MODULATE_COUNT     7
-
-struct tgsi_dst_register_ext_modulate
-{
-   unsigned Type     : 4;    /* TGSI_DST_REGISTER_EXT_TYPE_MODULATE */
-   unsigned Modulate : 4;    /* TGSI_MODULATE_ */
-   unsigned Padding  : 23;
-   unsigned Extended : 1;    /* BOOL */
-};
-
-/*
- * Currently, the following constraints apply.
- *
- * - PredSwizzleXYZW is either set to identity or replicate.
- * - PredSrcIndex is 0.
- */
-
-struct tgsi_dst_register_ext_predicate
-{
-   unsigned Type         : 4;    /* TGSI_DST_REGISTER_EXT_TYPE_PREDICATE */
-   unsigned PredSwizzleX : 2;    /* TGSI_SWIZZLE_ */
-   unsigned PredSwizzleY : 2;    /* TGSI_SWIZZLE_ */
-   unsigned PredSwizzleZ : 2;    /* TGSI_SWIZZLE_ */
-   unsigned PredSwizzleW : 2;    /* TGSI_SWIZZLE_ */
-   unsigned PredSrcIndex : 4;    /* UINT */
-   unsigned Negate       : 1;    /* BOOL */
-   unsigned Padding      : 14;
-   unsigned Extended     : 1;    /* BOOL */
+   unsigned Padding     : 6;
 };
 
 
@@ -667,5 +472,4 @@ struct tgsi_dst_register_ext_predicate
 }
 #endif
 
-#endif /* TGSI_TOKEN_H */
-
+#endif /* P_SHADER_TOKENS_H */
index 287b424e4aca6abd6c783a0dcdfe02236cb02634..60e96b98debb3d90690e3f5e125933285e9d5c1e 100644 (file)
@@ -60,6 +60,7 @@ extern "C" {
 #define PIPE_MAX_COLOR_BUFS        8
 #define PIPE_MAX_CONSTANT         32
 #define PIPE_MAX_SAMPLERS         16
+#define PIPE_MAX_VERTEX_SAMPLERS  16
 #define PIPE_MAX_SHADER_INPUTS    16
 #define PIPE_MAX_SHADER_OUTPUTS   16
 #define PIPE_MAX_TEXTURE_LEVELS   16
@@ -315,14 +316,10 @@ struct pipe_surface
  */
 struct pipe_transfer
 {
-   enum pipe_format format;      /**< PIPE_FORMAT_x */
    unsigned x;                   /**< x offset from start of texture image */
    unsigned y;                   /**< y offset from start of texture image */
    unsigned width;               /**< logical width in pixels */
    unsigned height;              /**< logical height in pixels */
-   struct pipe_format_block block;
-   unsigned nblocksx;            /**< allocated width in blocks */
-   unsigned nblocksy;            /**< allocated height in blocks */
    unsigned stride;              /**< stride in bytes between rows of blocks */
    enum pipe_transfer_usage usage; /**< PIPE_TRANSFER_*  */
 
@@ -343,13 +340,9 @@ struct pipe_texture
    enum pipe_texture_target target; /**< PIPE_TEXTURE_x */
    enum pipe_format format;         /**< PIPE_FORMAT_x */
 
-   unsigned width[PIPE_MAX_TEXTURE_LEVELS];
-   unsigned height[PIPE_MAX_TEXTURE_LEVELS];
-   unsigned depth[PIPE_MAX_TEXTURE_LEVELS];
-
-   struct pipe_format_block block;
-   unsigned nblocksx[PIPE_MAX_TEXTURE_LEVELS]; /**< allocated width in blocks */
-   unsigned nblocksy[PIPE_MAX_TEXTURE_LEVELS]; /**< allocated height in blocks */
+   unsigned width0;
+   unsigned height0;
+   unsigned depth0;
 
    unsigned last_level:8;    /**< Index of last mipmap level present/defined */
 
@@ -399,8 +392,9 @@ pipe_buffer_reference(struct pipe_buffer **ptr, struct pipe_buffer *buf)
 {
    struct pipe_buffer *old_buf = *ptr;
 
-   if (pipe_reference((struct pipe_reference **)ptr, &buf->reference))
+   if (pipe_reference(&(*ptr)->reference, &buf->reference))
       old_buf->screen->buffer_destroy(old_buf);
+   *ptr = buf;
 }
 
 static INLINE void
@@ -408,8 +402,9 @@ pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf)
 {
    struct pipe_surface *old_surf = *ptr;
 
-   if (pipe_reference((struct pipe_reference **)ptr, &surf->reference))
+   if (pipe_reference(&(*ptr)->reference, &surf->reference))
       old_surf->texture->screen->tex_surface_destroy(old_surf);
+   *ptr = surf;
 }
 
 static INLINE void
@@ -417,8 +412,9 @@ pipe_texture_reference(struct pipe_texture **ptr, struct pipe_texture *tex)
 {
    struct pipe_texture *old_tex = *ptr;
 
-   if (pipe_reference((struct pipe_reference **)ptr, &tex->reference))
+   if (pipe_reference(&(*ptr)->reference, &tex->reference))
       old_tex->screen->texture_destroy(old_tex);
+   *ptr = tex;
 }
 
 
index 4da26d608cf23326ed4c3412125368d2aeba7516..b85f01c2b02c66fb4843ca895f0b8dc733980949 100644 (file)
@@ -56,8 +56,9 @@ pipe_video_surface_reference(struct pipe_video_surface **ptr, struct pipe_video_
 {
    struct pipe_video_surface *old_surf = *ptr;
 
-   if (pipe_reference((struct pipe_reference **)ptr, &surf->reference))
+   if (pipe_reference(&(*ptr)->reference, &surf->reference))
       old_surf->screen->video_surface_destroy(old_surf);
+   *ptr = surf;
 }
 
 struct pipe_video_rect
index 8819936fcaf13127659854e46dfe2ddc01070395..f2e5f3fb23c7be29cfdb5cd63069a6b87160ffc0 100644 (file)
@@ -44,9 +44,9 @@
 
 GLboolean
 dri_create_context(const __GLcontextModes * visual,
-                  __DRIcontextPrivate * cPriv, void *sharedContextPrivate)
+                  __DRIcontext * cPriv, void *sharedContextPrivate)
 {
-   __DRIscreenPrivate *sPriv = cPriv->driScreenPriv;
+   __DRIscreen *sPriv = cPriv->driScreenPriv;
    struct dri_screen *screen = dri_screen(sPriv);
    struct dri_context *ctx = NULL;
    struct st_context *st_share = NULL;
@@ -97,7 +97,7 @@ dri_create_context(const __GLcontextModes * visual,
 }
 
 void
-dri_destroy_context(__DRIcontextPrivate * cPriv)
+dri_destroy_context(__DRIcontext * cPriv)
 {
    struct dri_context *ctx = dri_context(cPriv);
 
@@ -116,7 +116,7 @@ dri_destroy_context(__DRIcontextPrivate * cPriv)
 }
 
 GLboolean
-dri_unbind_context(__DRIcontextPrivate * cPriv)
+dri_unbind_context(__DRIcontext * cPriv)
 {
    if (cPriv) {
       struct dri_context *ctx = dri_context(cPriv);
@@ -133,9 +133,9 @@ dri_unbind_context(__DRIcontextPrivate * cPriv)
 }
 
 GLboolean
-dri_make_current(__DRIcontextPrivate * cPriv,
-                __DRIdrawablePrivate * driDrawPriv,
-                __DRIdrawablePrivate * driReadPriv)
+dri_make_current(__DRIcontext * cPriv,
+                __DRIdrawable * driDrawPriv,
+                __DRIdrawable * driReadPriv)
 {
    if (cPriv) {
       struct dri_context *ctx = dri_context(cPriv);
index 46501787340806610c7f8a450973e46df0aaf6d0..13f497462f7545ae6320b9f44d429280ef149c44 100644 (file)
@@ -44,10 +44,10 @@ struct dri_drawable;
 struct dri_context
 {
    /* dri */
-   __DRIscreenPrivate *sPriv;
-   __DRIcontextPrivate *cPriv;
-   __DRIdrawablePrivate *dPriv;
-   __DRIdrawablePrivate *rPriv;
+   __DRIscreen *sPriv;
+   __DRIcontext *cPriv;
+   __DRIdrawable *dPriv;
+   __DRIdrawable *rPriv;
 
    driOptionCache optionCache;
 
@@ -67,7 +67,7 @@ struct dri_context
 };
 
 static INLINE struct dri_context *
-dri_context(__DRIcontextPrivate * driContextPriv)
+dri_context(__DRIcontext * driContextPriv)
 {
    return (struct dri_context *)driContextPriv->driverPrivate;
 }
@@ -99,18 +99,18 @@ dri_unlock(struct dri_context *ctx)
  */
 extern struct dri1_api_lock_funcs dri1_lf;
 
-void dri_destroy_context(__DRIcontextPrivate * driContextPriv);
+void dri_destroy_context(__DRIcontext * driContextPriv);
 
-boolean dri_unbind_context(__DRIcontextPrivate * driContextPriv);
+boolean dri_unbind_context(__DRIcontext * driContextPriv);
 
 boolean
-dri_make_current(__DRIcontextPrivate * driContextPriv,
-                __DRIdrawablePrivate * driDrawPriv,
-                __DRIdrawablePrivate * driReadPriv);
+dri_make_current(__DRIcontext * driContextPriv,
+                __DRIdrawable * driDrawPriv,
+                __DRIdrawable * driReadPriv);
 
 boolean
 dri_create_context(const __GLcontextModes * visual,
-                  __DRIcontextPrivate * driContextPriv,
+                  __DRIcontext * driContextPriv,
                   void *sharedContextPrivate);
 
 /***********************************************************************
index c67cc8dacb61f60fb4d932153fe521555c999132..1058dd38c258c0e1eb78d6fe82e3dd1ca8cd1b7d 100644 (file)
 #include "state_tracker/st_context.h"
 #include "state_tracker/st_cb_fbo.h"
 
+#include "util/u_format.h"
 #include "util/u_memory.h"
-
+#include "util/u_rect.h"
 static struct pipe_surface *
 dri_surface_from_handle(struct drm_api *api,
                        struct pipe_screen *screen,
@@ -61,11 +63,10 @@ dri_surface_from_handle(struct drm_api *api,
    templat.tex_usage |= PIPE_TEXTURE_USAGE_RENDER_TARGET;
    templat.target = PIPE_TEXTURE_2D;
    templat.last_level = 0;
-   templat.depth[0] = 1;
+   templat.depth0 = 1;
    templat.format = format;
-   templat.width[0] = width;
-   templat.height[0] = height;
-   pf_get_block(templat.format, &templat.block);
+   templat.width0 = width;
+   templat.height0 = height;
 
    texture = api->texture_from_shared_handle(api, screen, &templat,
                                              "dri2 buffer", pitch, handle);
@@ -117,7 +118,7 @@ dri2_check_if_pixmap(__DRIbuffer *buffers, int count)
  * This will be called a drawable is known to have been resized.
  */
 void
-dri_get_buffers(__DRIdrawablePrivate * dPriv)
+dri_get_buffers(__DRIdrawable * dPriv)
 {
 
    struct dri_drawable *drawable = dri_drawable(dPriv);
@@ -298,8 +299,8 @@ dri_flush_frontbuffer(struct pipe_screen *screen,
  * This is called when we need to set up GL rendering to a new X window.
  */
 boolean
-dri_create_buffer(__DRIscreenPrivate * sPriv,
-                 __DRIdrawablePrivate * dPriv,
+dri_create_buffer(__DRIscreen * sPriv,
+                 __DRIdrawable * dPriv,
                  const __GLcontextModes * visual, boolean isPixmap)
 {
    struct dri_screen *screen = sPriv->private;
@@ -415,7 +416,7 @@ dri_swap_fences_push_back(struct dri_drawable *draw,
 }
 
 void
-dri_destroy_buffer(__DRIdrawablePrivate * dPriv)
+dri_destroy_buffer(__DRIdrawable * dPriv)
 {
    struct dri_drawable *drawable = dri_drawable(dPriv);
    struct pipe_fence_handle *fence;
@@ -433,8 +434,8 @@ dri_destroy_buffer(__DRIdrawablePrivate * dPriv)
 
 static void
 dri1_update_drawables_locked(struct dri_context *ctx,
-                            __DRIdrawablePrivate * driDrawPriv,
-                            __DRIdrawablePrivate * driReadPriv)
+                            __DRIdrawable * driDrawPriv,
+                            __DRIdrawable * driReadPriv)
 {
    if (ctx->stLostLock) {
       ctx->stLostLock = FALSE;
@@ -457,8 +458,8 @@ dri1_update_drawables_locked(struct dri_context *ctx,
 static void
 dri1_propagate_drawable_change(struct dri_context *ctx)
 {
-   __DRIdrawablePrivate *dPriv = ctx->dPriv;
-   __DRIdrawablePrivate *rPriv = ctx->rPriv;
+   __DRIdrawable *dPriv = ctx->dPriv;
+   __DRIdrawable *rPriv = ctx->rPriv;
    boolean flushed = FALSE;
 
    if (dPriv && ctx->d_stamp != dPriv->lastStamp) {
@@ -531,7 +532,7 @@ static void
 dri1_swap_copy(struct dri_context *ctx,
               struct pipe_surface *dst,
               struct pipe_surface *src,
-              __DRIdrawablePrivate * dPriv, const struct drm_clip_rect *bbox)
+              __DRIdrawable * dPriv, const struct drm_clip_rect *bbox)
 {
    struct pipe_context *pipe = ctx->pipe;
    struct drm_clip_rect clip;
@@ -541,19 +542,28 @@ dri1_swap_copy(struct dri_context *ctx,
    cur = dPriv->pClipRects;
 
    for (i = 0; i < dPriv->numClipRects; ++i) {
-      if (dri1_intersect_src_bbox(&clip, dPriv->x, dPriv->y, cur++, bbox))
-        pipe->surface_copy(pipe, dst, clip.x1, clip.y1,
-                           src,
-                           (int)clip.x1 - dPriv->x,
-                           (int)clip.y1 - dPriv->y,
-                           clip.x2 - clip.x1, clip.y2 - clip.y1);
+      if (dri1_intersect_src_bbox(&clip, dPriv->x, dPriv->y, cur++, bbox)) {
+         if (pipe->surface_copy) {
+            pipe->surface_copy(pipe, dst, clip.x1, clip.y1,
+                               src,
+                               (int)clip.x1 - dPriv->x,
+                               (int)clip.y1 - dPriv->y,
+                               clip.x2 - clip.x1, clip.y2 - clip.y1);
+         } else {
+            util_surface_copy(pipe, FALSE, dst, clip.x1, clip.y1,
+                              src,
+                              (int)clip.x1 - dPriv->x,
+                              (int)clip.y1 - dPriv->y,
+                              clip.x2 - clip.x1, clip.y2 - clip.y1);
+         }
+      }
    }
 }
 
 static void
 dri1_copy_to_front(struct dri_context *ctx,
                   struct pipe_surface *surf,
-                  __DRIdrawablePrivate * dPriv,
+                  __DRIdrawable * dPriv,
                   const struct drm_clip_rect *sub_box,
                   struct pipe_fence_handle **fence)
 {
@@ -626,7 +636,7 @@ dri1_flush_frontbuffer(struct pipe_screen *screen,
 }
 
 void
-dri_swap_buffers(__DRIdrawablePrivate * dPriv)
+dri_swap_buffers(__DRIdrawable * dPriv)
 {
    struct dri_context *ctx;
    struct pipe_surface *back_surf;
@@ -658,7 +668,7 @@ dri_swap_buffers(__DRIdrawablePrivate * dPriv)
 }
 
 void
-dri_copy_sub_buffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h)
+dri_copy_sub_buffer(__DRIdrawable * dPriv, int x, int y, int w, int h)
 {
    struct pipe_screen *screen = dri_screen(dPriv->driScreenPriv)->pipe_screen;
    struct drm_clip_rect sub_bbox;
index b910930db4235c58f5c4e8bba595071b491040fe..80bb5d7f617f19bd5dabb3284774dc2528fbf171 100644 (file)
@@ -41,8 +41,8 @@ struct dri_context;
 struct dri_drawable
 {
    /* dri */
-   __DRIdrawablePrivate *dPriv;
-   __DRIscreenPrivate *sPriv;
+   __DRIdrawable *dPriv;
+   __DRIscreen *sPriv;
 
    unsigned attachments[8];
    unsigned num_attachments;
@@ -67,7 +67,7 @@ struct dri_drawable
 };
 
 static INLINE struct dri_drawable *
-dri_drawable(__DRIdrawablePrivate * driDrawPriv)
+dri_drawable(__DRIdrawable * driDrawPriv)
 {
    return (struct dri_drawable *)driDrawPriv->driverPrivate;
 }
@@ -76,22 +76,22 @@ dri_drawable(__DRIdrawablePrivate * driDrawPriv)
  * dri_drawable.c
  */
 boolean
-dri_create_buffer(__DRIscreenPrivate * sPriv,
-                 __DRIdrawablePrivate * dPriv,
+dri_create_buffer(__DRIscreen * sPriv,
+                 __DRIdrawable * dPriv,
                  const __GLcontextModes * visual, boolean isPixmap);
 
 void
 dri_flush_frontbuffer(struct pipe_screen *screen,
                      struct pipe_surface *surf, void *context_private);
 
-void dri_swap_buffers(__DRIdrawablePrivate * dPriv);
+void dri_swap_buffers(__DRIdrawable * dPriv);
 
 void
-dri_copy_sub_buffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h);
+dri_copy_sub_buffer(__DRIdrawable * dPriv, int x, int y, int w, int h);
 
-void dri_get_buffers(__DRIdrawablePrivate * dPriv);
+void dri_get_buffers(__DRIdrawable * dPriv);
 
-void dri_destroy_buffer(__DRIdrawablePrivate * dPriv);
+void dri_destroy_buffer(__DRIdrawable * dPriv);
 
 void dri2_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target,
                           GLint glx_texture_format, __DRIdrawable *dPriv);
index f39a305531e06610f21ebff2aa065f44bcdaf53b..8b014a2a8b8bf897b5939febdfb72114a3ca664e 100644 (file)
@@ -37,6 +37,7 @@
 #define need_GL_ARB_multisample
 #define need_GL_ARB_occlusion_query
 #define need_GL_ARB_point_parameters
+#define need_GL_ARB_provoking_vertex
 #define need_GL_ARB_shader_objects
 #define need_GL_ARB_texture_compression
 #define need_GL_ARB_vertex_array_object
 #define need_GL_EXT_fog_coord
 #define need_GL_EXT_framebuffer_object
 #define need_GL_EXT_multi_draw_arrays
+#define need_GL_EXT_provoking_vertex
 #define need_GL_EXT_secondary_color
+#define need_GL_EXT_stencil_two_side
 #define need_GL_APPLE_vertex_array_object
 #define need_GL_NV_vertex_program
 #define need_GL_VERSION_2_0
 #define need_GL_VERSION_2_1
-#include "extension_helper.h"
+#include "main/remap_helper.h"
+#include "utils.h"
 
 /**
  * Extension strings exported by the driver.
  */
-const struct dri_extension card_extensions[] = {
+static const struct dri_extension card_extensions[] = {
    {"GL_ARB_fragment_shader", NULL},
    {"GL_ARB_map_buffer_range", GL_ARB_map_buffer_range_functions},
    {"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_provoking_vertex", GL_ARB_provoking_vertex_functions},
    {"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 },
@@ -80,6 +85,7 @@ const struct dri_extension card_extensions[] = {
    {"GL_ARB_texture_env_combine", NULL},
    {"GL_ARB_texture_env_dot3", NULL},
    {"GL_ARB_texture_mirrored_repeat", NULL},
+   {"GL_ARB_texture_non_power_of_two", NULL},
    {"GL_ARB_texture_rectangle", NULL},
    {"GL_ARB_vertex_array_object", GL_ARB_vertex_array_object_functions},
    {"GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions},
@@ -97,7 +103,9 @@ const struct dri_extension card_extensions[] = {
    {"GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions},
    {"GL_EXT_packed_depth_stencil", NULL},
    {"GL_EXT_pixel_buffer_object", NULL},
+   {"GL_EXT_provoking_vertex", GL_EXT_provoking_vertex_functions},
    {"GL_EXT_secondary_color", GL_EXT_secondary_color_functions},
+   {"GL_EXT_stencil_two_side", GL_EXT_stencil_two_side_functions},
    {"GL_EXT_stencil_wrap", NULL},
    {"GL_EXT_texture_edge_clamp", NULL},
    {"GL_EXT_texture_env_combine", NULL},
@@ -123,10 +131,7 @@ dri_init_extensions(struct dri_context *ctx)
     * capabilities of the pipe_screen. This is actually something
     * that can/should be done inside st_create_context().
     */
-   if (ctx)
-      driInitExtensions(ctx->st->ctx, card_extensions, GL_TRUE);
-   else
-      driInitExtensions(NULL, card_extensions, GL_FALSE);
+   driInitExtensions(ctx->st->ctx, card_extensions, GL_TRUE);
 }
 
 /* vim: set sw=3 ts=8 sts=3 expandtab: */
index 884b6d50111d38d7b999ff1654955c7162b2cd1a..bb12baf2815d62a6d02c4a6b2fda6d204bcce3d7 100644 (file)
@@ -202,7 +202,7 @@ dri_fill_in_modes(struct dri_screen *screen,
  * Get information about previous buffer swaps.
  */
 static int
-dri_get_swap_info(__DRIdrawablePrivate * dPriv, __DRIswapInfo * sInfo)
+dri_get_swap_info(__DRIdrawable * dPriv, __DRIswapInfo * sInfo)
 {
    if (dPriv == NULL || dPriv->driverPrivate == NULL || sInfo == NULL)
       return -1;
@@ -220,14 +220,12 @@ dri_copy_version(struct dri1_api_version *dst,
 }
 
 static const __DRIconfig **
-dri_init_screen(__DRIscreenPrivate * sPriv)
+dri_init_screen(__DRIscreen * sPriv)
 {
    struct dri_screen *screen;
    const __DRIconfig **configs;
    struct dri1_create_screen_arg arg;
 
-   dri_init_extensions(NULL);
-
    screen = CALLOC_STRUCT(dri_screen);
    if (!screen)
       return NULL;
@@ -287,14 +285,11 @@ dri_init_screen(__DRIscreenPrivate * sPriv)
  * Returns the __GLcontextModes supported by this driver.
  */
 static const __DRIconfig **
-dri_init_screen2(__DRIscreenPrivate * sPriv)
+dri_init_screen2(__DRIscreen * sPriv)
 {
    struct dri_screen *screen;
    struct drm_create_screen_arg arg;
 
-   /* Set up dispatch table to cope with all known extensions */
-   dri_init_extensions(NULL);
-
    screen = CALLOC_STRUCT(dri_screen);
    if (!screen)
       goto fail;
@@ -324,7 +319,7 @@ dri_init_screen2(__DRIscreenPrivate * sPriv)
 }
 
 static void
-dri_destroy_screen(__DRIscreenPrivate * sPriv)
+dri_destroy_screen(__DRIscreen * sPriv)
 {
    struct dri_screen *screen = dri_screen(sPriv);
 
@@ -351,4 +346,12 @@ PUBLIC const struct __DriverAPIRec driDriverAPI = {
    .InitScreen2 = dri_init_screen2,
 };
 
+/* This is the table of extensions that the loader will dlsym() for. */
+PUBLIC const __DRIextension *__driDriverExtensions[] = {
+    &driCoreExtension.base,
+    &driLegacyExtension.base,
+    &driDRI2Extension.base,
+    NULL
+};
+
 /* vim: set sw=3 ts=8 sts=3 expandtab: */
index f6c56d0f0c5ccfeaccc624a10ba3febb2fe5367d..03387a0e81361eb1729ed85aed73caa91a40a3f4 100644 (file)
@@ -42,7 +42,7 @@
 struct dri_screen
 {
    /* dri */
-   __DRIscreenPrivate *sPriv;
+   __DRIscreen *sPriv;
 
    /**
     * Configuration cache with default values for all contexts
@@ -63,7 +63,7 @@ struct dri_screen
 
 /** cast wrapper */
 static INLINE struct dri_screen *
-dri_screen(__DRIscreenPrivate * sPriv)
+dri_screen(__DRIscreen * sPriv)
 {
    return (struct dri_screen *)sPriv->private;
 }
index e21a4a1095b47700fc498ec9adb05b297b8966a6..fee186c60107b3640c0858a06e6cdd20889cd339 100644 (file)
 
 #include "GL/internal/glcore.h"
 
-#define need_GL_ARB_multisample
-#define need_GL_ARB_point_parameters
-#define need_GL_ARB_texture_compression
-#define need_GL_ARB_vertex_buffer_object
-#define need_GL_ARB_vertex_program
-#define need_GL_ARB_window_pos
-#define need_GL_EXT_blend_color
-#define need_GL_EXT_blend_equation_separate
-#define need_GL_EXT_blend_func_separate
-#define need_GL_EXT_blend_minmax
-#define need_GL_EXT_cull_vertex
-#define need_GL_EXT_fog_coord
-#define need_GL_EXT_framebuffer_object
-#define need_GL_EXT_multi_draw_arrays
-#define need_GL_EXT_secondary_color
-#define need_GL_NV_vertex_program
-#include "extension_helper.h"
-
-/**
- * TODO HACK! FUGLY!
- * Copied for intel extentions.
- */
-const struct dri_extension card_extensions[] = {
-       {"GL_ARB_multisample", GL_ARB_multisample_functions},
-       {"GL_ARB_multitexture", NULL},
-       {"GL_ARB_point_parameters", GL_ARB_point_parameters_functions},
-       {"GL_ARB_texture_border_clamp", NULL},
-       {"GL_ARB_texture_compression", GL_ARB_texture_compression_functions},
-       {"GL_ARB_texture_cube_map", NULL},
-       {"GL_ARB_texture_env_add", NULL},
-       {"GL_ARB_texture_env_combine", NULL},
-       {"GL_ARB_texture_env_dot3", NULL},
-       {"GL_ARB_texture_mirrored_repeat", NULL},
-       {"GL_ARB_texture_rectangle", NULL},
-       {"GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions},
-       {"GL_ARB_pixel_buffer_object", NULL},
-       {"GL_ARB_vertex_program", GL_ARB_vertex_program_functions},
-       {"GL_ARB_window_pos", GL_ARB_window_pos_functions},
-       {"GL_EXT_blend_color", GL_EXT_blend_color_functions},
-       {"GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions},
-       {"GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions},
-       {"GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions},
-       {"GL_EXT_blend_subtract", NULL},
-       {"GL_EXT_cull_vertex", GL_EXT_cull_vertex_functions},
-       {"GL_EXT_fog_coord", GL_EXT_fog_coord_functions},
-       {"GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions},
-       {"GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions},
-       {"GL_EXT_packed_depth_stencil", NULL},
-       {"GL_EXT_pixel_buffer_object", NULL},
-       {"GL_EXT_secondary_color", GL_EXT_secondary_color_functions},
-       {"GL_EXT_stencil_wrap", NULL},
-       {"GL_EXT_texture_edge_clamp", NULL},
-       {"GL_EXT_texture_env_combine", NULL},
-       {"GL_EXT_texture_env_dot3", NULL},
-       {"GL_EXT_texture_filter_anisotropic", NULL},
-       {"GL_EXT_texture_lod_bias", NULL},
-       {"GL_3DFX_texture_compression_FXT1", NULL},
-       {"GL_APPLE_client_storage", NULL},
-       {"GL_MESA_pack_invert", NULL},
-       {"GL_MESA_ycbcr_texture", NULL},
-       {"GL_NV_blend_square", NULL},
-       {"GL_NV_vertex_program", GL_NV_vertex_program_functions},
-       {"GL_NV_vertex_program1_1", NULL},
-       {"GL_SGIS_generate_mipmap", NULL },
-       {NULL, NULL}
-};
-
 _EGLContext *
 drm_create_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, _EGLContext *share_list, const EGLint *attrib_list)
 {
index 7911a8834e01576c888d34332d4c7d888043f86b..d55aa51b82d98b5d776e698d0376e9862bc49fcc 100644 (file)
@@ -12,6 +12,9 @@
 
 #include "state_tracker/drm_api.h"
 
+#include "util/u_format.h"
+#include "util/u_rect.h"
+
 /*
  * Util functions
  */
@@ -33,34 +36,62 @@ drm_find_mode(drmModeConnectorPtr connector, _EGLMode *mode)
 }
 
 static struct st_framebuffer *
-drm_create_framebuffer(const __GLcontextModes *visual,
+drm_create_framebuffer(struct pipe_screen *screen,
+                       const __GLcontextModes *visual,
                        unsigned width,
                        unsigned height,
                        void *priv)
 {
-       enum pipe_format colorFormat, depthFormat, stencilFormat;
-
-       if (visual->redBits == 5)
-               colorFormat = PIPE_FORMAT_R5G6B5_UNORM;
-       else
-               colorFormat = PIPE_FORMAT_A8R8G8B8_UNORM;
-
-       if (visual->depthBits == 16)
-               depthFormat = PIPE_FORMAT_Z16_UNORM;
-       else if (visual->depthBits == 24)
-               depthFormat = PIPE_FORMAT_S8Z24_UNORM;
-       else
-               depthFormat = PIPE_FORMAT_NONE;
+       enum pipe_format color_format, depth_stencil_format;
+       boolean d_depth_bits_last;
+       boolean ds_depth_bits_last;
+
+       d_depth_bits_last =
+               screen->is_format_supported(screen, PIPE_FORMAT_X8Z24_UNORM,
+                                           PIPE_TEXTURE_2D,
+                                           PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
+       ds_depth_bits_last =
+               screen->is_format_supported(screen, PIPE_FORMAT_S8Z24_UNORM,
+                                           PIPE_TEXTURE_2D,
+                                           PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
+
+       if (visual->redBits == 8) {
+               if (visual->alphaBits == 8)
+                       color_format = PIPE_FORMAT_A8R8G8B8_UNORM;
+               else
+                       color_format = PIPE_FORMAT_X8R8G8B8_UNORM;
+       } else {
+               color_format = PIPE_FORMAT_R5G6B5_UNORM;
+       }
 
-       if (visual->stencilBits == 8)
-               stencilFormat = PIPE_FORMAT_S8Z24_UNORM;
-       else
-               stencilFormat = PIPE_FORMAT_NONE;
+       switch(visual->depthBits) {
+               default:
+               case 0:
+                       depth_stencil_format = PIPE_FORMAT_NONE;
+                       break;
+               case 16:
+                       depth_stencil_format = PIPE_FORMAT_Z16_UNORM;
+                       break;
+               case 24:
+                       if (visual->stencilBits == 0) {
+                               depth_stencil_format = (d_depth_bits_last) ?
+                                       PIPE_FORMAT_X8Z24_UNORM:
+                                       PIPE_FORMAT_Z24X8_UNORM;
+                       } else {
+                               depth_stencil_format = (ds_depth_bits_last) ?
+                                       PIPE_FORMAT_S8Z24_UNORM:
+                                       PIPE_FORMAT_Z24S8_UNORM;
+                       }
+                       break;
+               case 32:
+                       depth_stencil_format = PIPE_FORMAT_Z32_UNORM;
+                       break;
+       }
 
        return st_create_framebuffer(visual,
-                                    colorFormat,
-                                    depthFormat,
-                                    stencilFormat,
+                                    color_format,
+                                    depth_stencil_format,
+                                    depth_stencil_format,
                                     width,
                                     height,
                                     priv);
@@ -84,11 +115,10 @@ drm_create_texture(_EGLDisplay *dpy,
        templat.tex_usage |= PIPE_TEXTURE_USAGE_PRIMARY;
        templat.target = PIPE_TEXTURE_2D;
        templat.last_level = 0;
-       templat.depth[0] = 1;
+       templat.depth0 = 1;
        templat.format = PIPE_FORMAT_A8R8G8B8_UNORM;
-       templat.width[0] = w;
-       templat.height[0] = h;
-       pf_get_block(templat.format, &templat.block);
+       templat.width0 = w;
+       templat.height0 = h;
 
        texture = screen->texture_create(dev->screen,
                                         &templat);
@@ -141,9 +171,9 @@ drm_takedown_shown_screen(_EGLDisplay *dpy, struct drm_screen *screen)
        drmModeSetCrtc(
                dev->drmFD,
                screen->crtcID,
-               0, // FD
+               0, /* FD */
                0, 0,
-               NULL, 0, // List of output ids
+               NULL, 0, /* List of output ids */
                NULL);
 
        drmModeRmFB(dev->drmFD, screen->fbID);
@@ -156,6 +186,9 @@ drm_takedown_shown_screen(_EGLDisplay *dpy, struct drm_screen *screen)
        screen->shown = 0;
 }
 
+/**
+ * Called by libEGL's eglCreateWindowSurface().
+ */
 _EGLSurface *
 drm_create_window_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, NativeWindowType window, const EGLint *attrib_list)
 {
@@ -163,6 +196,9 @@ drm_create_window_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, N
 }
 
 
+/**
+ * Called by libEGL's eglCreatePixmapSurface().
+ */
 _EGLSurface *
 drm_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, NativePixmapType pixmap, const EGLint *attrib_list)
 {
@@ -170,10 +206,14 @@ drm_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, N
 }
 
 
+/**
+ * Called by libEGL's eglCreatePbufferSurface().
+ */
 _EGLSurface *
 drm_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf,
                            const EGLint *attrib_list)
 {
+       struct drm_device *dev = lookup_drm_device(dpy);
        int i;
        int width = -1;
        int height = -1;
@@ -210,9 +250,8 @@ drm_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf,
        surf->h = height;
 
        visual = drm_visual_from_config(conf);
-       surf->stfb = drm_create_framebuffer(visual,
-                                           width,
-                                           height,
+       surf->stfb = drm_create_framebuffer(dev->screen, visual,
+                                           width, height,
                                            (void*)surf);
        drm_visual_modes_destroy(visual);
 
@@ -224,6 +263,9 @@ err:
        return NULL;
 }
 
+/**
+ * Called by libEGL's eglCreateScreenSurfaceMESA().
+ */
 _EGLSurface *
 drm_create_screen_surface_mesa(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *cfg,
                                const EGLint *attrib_list)
@@ -233,6 +275,9 @@ drm_create_screen_surface_mesa(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *cf
        return surf;
 }
 
+/**
+ * Called by libEGL's eglShowScreenSurfaceMESA().
+ */
 EGLBoolean
 drm_show_screen_surface_mesa(_EGLDriver *drv, _EGLDisplay *dpy,
                              _EGLScreen *screen,
@@ -329,6 +374,9 @@ err_tex:
        return EGL_FALSE;
 }
 
+/**
+ * Called by libEGL's eglDestroySurface().
+ */
 EGLBoolean
 drm_destroy_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface)
 {
@@ -342,6 +390,9 @@ drm_destroy_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface)
        return EGL_TRUE;
 }
 
+/**
+ * Called by libEGL's eglSwapBuffers().
+ */
 EGLBoolean
 drm_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw)
 {
@@ -360,12 +411,21 @@ drm_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw)
                st_notify_swapbuffers(surf->stfb);
 
                if (ctx && surf->screen) {
-                       ctx->pipe->surface_copy(ctx->pipe,
-                               surf->screen->surface,
-                               0, 0,
-                               back_surf,
-                               0, 0,
-                               surf->w, surf->h);
+            if (ctx->pipe->surface_copy) {
+                ctx->pipe->surface_copy(ctx->pipe,
+                    surf->screen->surface,
+                    0, 0,
+                    back_surf,
+                    0, 0,
+                    surf->w, surf->h);
+            } else {
+                util_surface_copy(ctx->pipe, FALSE,
+                    surf->screen->surface,
+                    0, 0,
+                    back_surf,
+                    0, 0,
+                    surf->w, surf->h);
+            }
                        ctx->pipe->flush(ctx->pipe, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_TEXTURE_CACHE, NULL);
 
 #ifdef DRM_MODE_FEATURE_DIRTYFB
index 5140755001c51e47f790a69dc42737de7563f3c7..9345b0f490851a04ae3cc67fa2fc2b3244f219d1 100644 (file)
 
 /** HACK */
 void* driDriverAPI;
-extern const struct dri_extension card_extensions[];
 
 
 /*
  * Exported functions
  */
 
+/** Called by libEGL just prior to unloading/closing the driver.
+ */
 static void
 drm_unload(_EGLDriver *drv)
 {
@@ -32,6 +33,8 @@ drm_unload(_EGLDriver *drv)
 /**
  * The bootstrap function.  Return a new drm_driver object and
  * plug in API functions.
+ * libEGL finds this function with dlopen()/dlsym() and calls it from
+ * "load driver" function.
  */
 _EGLDriver *
 _eglMain(const char *args)
@@ -85,11 +88,11 @@ drm_get_device_id(struct drm_device *device)
        }
 
        ret = fgets(path, sizeof( path ), file);
+       fclose(file);
        if (!ret)
                return;
 
        sscanf(path, "%x", &device->deviceID);
-       fclose(file);
 }
 
 static void
@@ -149,6 +152,7 @@ drm_initialize(_EGLDriver *drv, _EGLDisplay *disp, EGLint *major, EGLint *minor)
        int num_screens = 0;
        EGLint i;
        int fd;
+       _EGLConfig *config;
 
        dev = (struct drm_device *) calloc(1, sizeof(struct drm_device));
        if (!dev)
@@ -168,8 +172,7 @@ drm_initialize(_EGLDriver *drv, _EGLDisplay *disp, EGLint *major, EGLint *minor)
                goto err_screen;
        dev->winsys = dev->screen->winsys;
 
-       /* TODO HACK */
-       driInitExtensions(NULL, card_extensions, GL_FALSE);
+       driInitExtensions(NULL, NULL, GL_FALSE);
 
        drm_update_res(dev);
        res = dev->res;
@@ -204,7 +207,7 @@ drm_initialize(_EGLDriver *drv, _EGLDisplay *disp, EGLint *major, EGLint *minor)
        disp->DriverData = dev;
 
        /* for now we only have one config */
-       _EGLConfig *config = calloc(1, sizeof(*config));
+       config = calloc(1, sizeof(*config));
        memset(config, 1, sizeof(*config));
        _eglInitConfig(config, 1);
        _eglSetConfigAttrib(config, EGL_RED_SIZE, 8);
index 556eefb1b1787f0fb1b3f64c4f83ce13a7056a9b..228ac9a20e93ff1fcd5162763e50ad2bfba00a30 100644 (file)
@@ -644,6 +644,7 @@ register_with_display(Display *dpy)
       XExtCodes *c = XAddExtension(dpy);
       ext = dpy->ext_procs;  /* new extension is at head of list */
       assert(c->extension == ext->codes.extension);
+      (void) c;
       ext->name = _mesa_strdup(extName);
       ext->close_display = close_display_callback;
    }
@@ -1311,13 +1312,15 @@ glXCopyContext( Display *dpy, GLXContext src, GLXContext dst,
 Bool
 glXQueryExtension( Display *dpy, int *errorBase, int *eventBase )
 {
+   int op, ev, err;
    /* Mesa's GLX isn't really an X extension but we try to act like one. */
-   (void) dpy;
+   if (!XQueryExtension(dpy, GLX_EXTENSION_NAME, &op, &ev, &err))
+      ev = err = 0;
    if (errorBase)
-      *errorBase = 0;
+      *errorBase = err;
    if (eventBase)
-      *eventBase = 0;
-   return True;
+      *eventBase = ev;
+   return True; /* we're faking GLX so always return success */
 }
 
 
index c76dfb31d2b86783fe0db0baa73726e6b0b5ba81..1783bc504d91bec3b87668b0c1bedd39276efbe9 100644 (file)
 #include "pipe/p_screen.h"
 #include "pipe/p_context.h"
 
+#include "trace/tr_screen.h"
+#include "trace/tr_context.h"
+#include "trace/tr_texture.h"
+
 #include "xm_winsys.h"
 #include <GL/glx.h>
 
@@ -87,6 +91,8 @@ void xmesa_set_driver( const struct xm_driver *templ )
  */
 pipe_mutex _xmesa_lock;
 
+static struct pipe_screen *_screen = NULL;
+static struct pipe_screen *screen = NULL;
 
 
 /**********************************************************************/
@@ -754,7 +760,7 @@ PUBLIC
 XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
 {
    static GLboolean firstTime = GL_TRUE;
-   static struct pipe_screen *screen = NULL;
+   struct pipe_context *_pipe = NULL;
    struct pipe_context *pipe = NULL;
    XMesaContext c;
    GLcontext *mesaCtx;
@@ -762,7 +768,8 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
 
    if (firstTime) {
       pipe_mutex_init(_xmesa_lock);
-      screen = driver.create_pipe_screen();
+      _screen = driver.create_pipe_screen();
+      screen = trace_screen_create( _screen );
       firstTime = GL_FALSE;
    }
 
@@ -781,9 +788,11 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
    if (screen == NULL)
       goto fail;
 
-   pipe = driver.create_pipe_context(screen, (void *) c);
-   if (pipe == NULL)
+   _pipe = driver.create_pipe_context(_screen, (void *) c);
+   if (_pipe == NULL)
       goto fail;
+   pipe = trace_context_create(screen, _pipe);
+   pipe->priv = c;
 
    c->st = st_create_context(pipe, 
                              &v->mesa_visual,
@@ -1110,6 +1119,12 @@ void XMesaSwapBuffers( XMesaBuffer b )
    st_swapbuffers(b->stfb, &frontLeftSurf, NULL);
 
    if (frontLeftSurf) {
+      if (_screen != screen) {
+         struct trace_surface *tr_surf = trace_surface( frontLeftSurf );
+         struct pipe_surface *surf = tr_surf->surface;
+         frontLeftSurf = surf;
+      }
+
       driver.display_surface(b, frontLeftSurf);
    }
 
index ec385e7c447f841672f927a88567561c5f6e6923..d4fdd43688f817e3a0eefd0aba6ee37dcf0f8e59 100644 (file)
@@ -38,10 +38,12 @@ if 'python' in env['statetrackers']:
         ],
     )
 
+    env['no_import_lib'] = 1
+
     env.SharedLibrary(
         target = '_gallium',
         source = [
             'st_hardpipe_winsys.c',
         ],
-        LIBS = [pyst, softpipe, trace] + auxiliaries + env['LIBS'],
+        LIBS = [pyst, softpipe, trace] + gallium + env['LIBS'],
     )
index 3f79cc1a3d74be0afc1790bb29c054613c85f3c3..96b13c2258e859d87fbd6141b59b68d9c6ac3d26 100644 (file)
@@ -46,6 +46,7 @@
 #include "util/u_draw_quad.h"
 #include "util/u_tile.h"
 #include "util/u_math.h"
+#include "util/u_format.h"
 #include "util/u_memory.h"
 #include "tgsi/tgsi_text.h"
 #include "tgsi/tgsi_dump.h"
@@ -80,7 +81,6 @@
 %rename(Stencil) pipe_stencil_state;
 %rename(Alpha) pipe_alpha_state;
 %rename(DepthStencilAlpha) pipe_depth_stencil_alpha_state;
-%rename(FormatBlock) pipe_format_block;
 %rename(Framebuffer) pipe_framebuffer_state;
 %rename(PolyStipple) pipe_poly_stipple;
 %rename(Rasterizer) pipe_rasterizer_state;
index a40aa1e518772fdc6b5ac278f473d6a8ee6d327d..84ce1a41e6d98207f4bef6f16f80770ef3dea918 100644 (file)
@@ -52,11 +52,16 @@ struct st_context {
       cso_set_blend($self->cso, state);
    }
    
-   void set_sampler( unsigned index, const struct pipe_sampler_state *state ) {
+   void set_fragment_sampler( unsigned index, const struct pipe_sampler_state *state ) {
       cso_single_sampler($self->cso, index, state);
       cso_single_sampler_done($self->cso);
    }
 
+   void set_vertex_sampler( unsigned index, const struct pipe_sampler_state *state ) {
+      cso_single_vertex_sampler($self->cso, index, state);
+      cso_single_vertex_sampler_done($self->cso);
+   }
+
    void set_rasterizer( const struct pipe_rasterizer_state *state ) {
       cso_set_rasterizer($self->cso, state);
    }
@@ -103,6 +108,25 @@ struct st_context {
       $self->vs = vs;
    }
 
+   void set_geometry_shader( const struct pipe_shader_state *state ) {
+      void *gs;
+
+      if(!state) {
+         cso_set_geometry_shader_handle($self->cso, NULL);
+         return;
+      }
+
+      gs = $self->pipe->create_gs_state($self->pipe, state);
+      if(!gs)
+         return;
+
+      if(cso_set_geometry_shader_handle($self->cso, gs) != PIPE_OK)
+         return;
+
+      cso_delete_geometry_shader($self->cso, $self->gs);
+      $self->gs = gs;
+   }
+
    /*
     * Parameter-like state (or properties)
     */
@@ -142,14 +166,24 @@ struct st_context {
       cso_set_viewport($self->cso, state);
    }
 
-   void set_sampler_texture(unsigned index,
-                            struct pipe_texture *texture) {
+   void set_fragment_sampler_texture(unsigned index,
+                                     struct pipe_texture *texture) {
+      if(!texture)
+         texture = $self->default_texture;
+      pipe_texture_reference(&$self->fragment_sampler_textures[index], texture);
+      $self->pipe->set_fragment_sampler_textures($self->pipe,
+                                                 PIPE_MAX_SAMPLERS,
+                                                 $self->fragment_sampler_textures);
+   }
+
+   void set_vertex_sampler_texture(unsigned index,
+                                   struct pipe_texture *texture) {
       if(!texture)
          texture = $self->default_texture;
-      pipe_texture_reference(&$self->sampler_textures[index], texture);
-      $self->pipe->set_sampler_textures($self->pipe, 
-                                        PIPE_MAX_SAMPLERS,
-                                        $self->sampler_textures);
+      pipe_texture_reference(&$self->vertex_sampler_textures[index], texture);
+      $self->pipe->set_vertex_sampler_textures($self->pipe,
+                                               PIPE_MAX_VERTEX_SAMPLERS,
+                                               $self->vertex_sampler_textures);
    }
 
    void set_vertex_buffer(unsigned index,
index f16fe5b0ff70182f978dfb2d4fa9f3b9eb43abca..2dc995adb07687ba7e1a1835d8fd36ae51fe9b71 100644 (file)
@@ -112,10 +112,9 @@ struct st_device {
       struct pipe_texture templat;
       memset(&templat, 0, sizeof(templat));
       templat.format = format;
-      pf_get_block(templat.format, &templat.block);
-      templat.width[0] = width;
-      templat.height[0] = height;
-      templat.depth[0] = depth;
+      templat.width0 = width;
+      templat.height0 = height;
+      templat.depth0 = depth;
       templat.last_level = last_level;
       templat.target = target;
       templat.tex_usage = tex_usage;
index 26fb12b387f821886ad9f4357fb7de2336dd949e..68df0093315b737bd5b058e3ed0dc42cd4849ea2 100644 (file)
@@ -152,11 +152,3 @@ enum pipe_format {
    PIPE_FORMAT_DXT5_SRGBA,
 };
 
-
-struct pipe_format_block
-{
-   unsigned size;
-   unsigned width;
-   unsigned height;
-};
-
index 1d513abf3c75489a751cf7de42e4b6299c655c22..761587dc533bbd4b24350a63570026789ec7f02b 100644 (file)
    }
    
    unsigned get_width(unsigned level=0) {
-      return $self->width[level];
+      return u_minify($self->width0, level);
    }
    
    unsigned get_height(unsigned level=0) {
-      return $self->height[level];
+      return u_minify($self->height0, level);
    }
    
    unsigned get_depth(unsigned level=0) {
-      return $self->depth[level];
+      return u_minify($self->depth0, level);
    }
-   
-   unsigned get_nblocksx(unsigned level=0) {
-      return $self->nblocksx[level];
-   }
-   
-   unsigned get_nblocksy(unsigned level=0) {
-      return $self->nblocksy[level];
-   }
-   
+  
    /** Get a surface which is a "view" into a texture */
    struct st_surface *
    get_surface(unsigned face=0, unsigned level=0, unsigned zslice=0)
@@ -88,7 +80,7 @@
          SWIG_exception(SWIG_ValueError, "face out of bounds");
       if(level > $self->last_level)
          SWIG_exception(SWIG_ValueError, "level out of bounds");
-      if(zslice >= $self->depth[level])
+      if(zslice >= u_minify($self->depth0, level))
          SWIG_exception(SWIG_ValueError, "zslice out of bounds");
       
       surface = CALLOC_STRUCT(st_surface);
@@ -126,8 +118,6 @@ struct st_surface
    unsigned format;
    unsigned width;
    unsigned height;
-   unsigned nblocksx;
-   unsigned nblocksy;
    
    ~st_surface() {
       pipe_texture_reference(&$self->texture, NULL);
@@ -142,8 +132,8 @@ struct st_surface
       struct pipe_transfer *transfer;
       unsigned stride;
 
-      stride = pf_get_nblocksx(&texture->block, w) * texture->block.size;
-      *LENGTH = pf_get_nblocksy(&texture->block, h) * stride;
+      stride = util_format_get_stride(texture->format, w);
+      *LENGTH = util_format_get_nblocksy(texture->format, h) * stride;
       *STRING = (char *) malloc(*LENGTH);
       if(!*STRING)
          return;
@@ -169,9 +159,9 @@ struct st_surface
       struct pipe_transfer *transfer;
      
       if(stride == 0)
-         stride = pf_get_nblocksx(&texture->block, w) * texture->block.size;
+         stride = util_format_get_stride(texture->format, w);
       
-      if(LENGTH < pf_get_nblocksy(&texture->block, h) * stride)
+      if(LENGTH < util_format_get_nblocksy(texture->format, h) * stride)
          SWIG_exception(SWIG_ValueError, "offset must be smaller than buffer size");
          
       transfer = screen->get_tex_transfer(screen,
@@ -375,25 +365,13 @@ struct st_surface
    static unsigned
    st_surface_width_get(struct st_surface *surface)
    {
-      return surface->texture->width[surface->level];
+      return u_minify(surface->texture->width0, surface->level);
    }
    
    static unsigned
    st_surface_height_get(struct st_surface *surface)
    {
-      return surface->texture->height[surface->level];
-   }
-
-   static unsigned
-   st_surface_nblocksx_get(struct st_surface *surface)
-   {
-      return surface->texture->nblocksx[surface->level];
-   }
-   
-   static unsigned
-   st_surface_nblocksy_get(struct st_surface *surface)
-   {
-      return surface->texture->nblocksy[surface->level];
+      return u_minify(surface->texture->height0, surface->level);
    }
 %}
 
index f4ed2fde4dc161ebf53185323442b6ca3cc214e5..a68709f5cf34b5b59d9df1b75c68171b69d0f5d8 100755 (executable)
@@ -52,10 +52,10 @@ def make_image(surface, x=None, y=None, w=None, h=None):
         w = surface.width - x
     if h is None:
         h = surface.height - y
-    data = surface.get_tile_rgba8(0, 0, surface.width, surface.height)
+    data = surface.get_tile_rgba8(x, y, surface.width, surface.height)
 
     import Image
-    outimage = Image.fromstring('RGBA', (surface.width, surface.height), data, "raw", 'RGBA', 0, 1)
+    outimage = Image.fromstring('RGBA', (w, h), data, "raw", 'RGBA', 0, 1)
     return outimage
 
 def save_image(filename, surface, x=None, y=None, w=None, h=None):
@@ -99,7 +99,6 @@ struct_factories = {
     "pipe_stencil_state": gallium.Stencil,
     "pipe_alpha_state": gallium.Alpha,
     "pipe_depth_stencil_alpha_state": gallium.DepthStencilAlpha,
-    "pipe_format_block": gallium.FormatBlock,
     #"pipe_framebuffer_state": gallium.Framebuffer,
     "pipe_poly_stipple": gallium.PolyStipple,
     "pipe_rasterizer_state": gallium.Rasterizer,
@@ -279,9 +278,9 @@ class Screen(Object):
     def texture_create(self, templat):
         return self.real.texture_create(
             format = templat.format,
-            width = templat.width[0],
-            height = templat.height[0],
-            depth = templat.depth[0],
+            width = templat.width,
+            height = templat.height,
+            depth = templat.depth,
             last_level = templat.last_level,
             target = templat.target,
             tex_usage = templat.tex_usage,
@@ -307,14 +306,14 @@ class Screen(Object):
     def surface_write(self, surface, data, stride, size):
         if surface is None:
             return
-        assert surface.nblocksy * stride == size 
+#        assert surface.nblocksy * stride == size 
         surface.put_tile_raw(0, 0, surface.width, surface.height, data, stride)
 
     def get_tex_transfer(self, texture, face, level, zslice, usage, x, y, w, h):
         if texture is None:
             return None
         transfer = Transfer(texture.get_surface(face, level, zslice), x, y, w, h)
-        if transfer and usage & gallium.PIPE_TRANSFER_READ
+        if transfer and usage & gallium.PIPE_TRANSFER_READ:
             if self.interpreter.options.all:
                 self.interpreter.present(transfer.surface, 'transf_read', x, y, w, h)
         return transfer
@@ -388,9 +387,13 @@ class Context(Object):
     def delete_sampler_state(self, state):
         pass
 
-    def bind_sampler_states(self, num_states, states):
+    def bind_vertex_sampler_states(self, num_states, states):
         for i in range(num_states):
-            self.real.set_sampler(i, states[i])
+            self.real.set_vertex_sampler(i, states[i])
+        
+    def bind_fragment_sampler_states(self, num_states, states):
+        for i in range(num_states):
+            self.real.set_fragment_sampler(i, states[i])
         
     def create_rasterizer_state(self, state):
         return state
@@ -459,7 +462,7 @@ class Context(Object):
         sys.stdout.flush()
 
     def set_constant_buffer(self, shader, index, buffer):
-        if buffer is not None:
+        if buffer is not None and buffer.buffer is not None:
             self.real.set_constant_buffer(shader, index, buffer.buffer)
 
             self.dump_constant_buffer(buffer.buffer)
@@ -486,9 +489,13 @@ class Context(Object):
     def set_viewport_state(self, state):
         self.real.set_viewport(state)
 
-    def set_sampler_textures(self, num_textures, textures):
+    def set_fragment_sampler_textures(self, num_textures, textures):
+        for i in range(num_textures):
+            self.real.set_fragment_sampler_texture(i, textures[i])
+
+    def set_vertex_sampler_textures(self, num_textures, textures):
         for i in range(num_textures):
-            self.real.set_sampler_texture(i, textures[i])
+            self.real.set_vertex_sampler_texture(i, textures[i])
 
     def set_vertex_buffers(self, num_buffers, buffers):
         self.vbufs = buffers[0:num_buffers]
@@ -508,10 +515,6 @@ class Context(Object):
             self.real.set_vertex_element(i, elements[i])
         self.real.set_vertex_elements(num_elements)
 
-    def set_edgeflags(self, bitfield):
-        # FIXME
-        pass
-    
     def dump_vertices(self, start, count):
         if not self.interpreter.verbosity(2):
             return
diff --git a/src/gallium/state_trackers/python/samples/gs.py b/src/gallium/state_trackers/python/samples/gs.py
new file mode 100644 (file)
index 0000000..1ceead5
--- /dev/null
@@ -0,0 +1,254 @@
+#!/usr/bin/env python
+##########################################################################
+#
+# Copyright 2009 VMware
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and 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.
+#
+##########################################################################
+
+
+from gallium import *
+
+
+def make_image(surface):
+    data = surface.get_tile_rgba8(0, 0, surface.width, surface.height)
+
+    import Image
+    outimage = Image.fromstring('RGBA', (surface.width, surface.height), data, "raw", 'RGBA', 0, 1)
+    return outimage
+
+def save_image(filename, surface):
+    outimage = make_image(surface)
+    outimage.save(filename, "PNG")
+
+def show_image(surface):
+    outimage = make_image(surface)
+
+    import Tkinter as tk
+    from PIL import Image, ImageTk
+    root = tk.Tk()
+
+    root.title('background image')
+
+    image1 = ImageTk.PhotoImage(outimage)
+    w = image1.width()
+    h = image1.height()
+    x = 100
+    y = 100
+    root.geometry("%dx%d+%d+%d" % (w, h, x, y))
+    panel1 = tk.Label(root, image=image1)
+    panel1.pack(side='top', fill='both', expand='yes')
+    panel1.image = image1
+    root.mainloop()
+
+
+def test(dev):
+    ctx = dev.context_create()
+
+    width = 255
+    height = 255
+    minz = 0.0
+    maxz = 1.0
+
+    # disabled blending/masking
+    blend = Blend()
+    blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE
+    blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE
+    blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO
+    blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO
+    blend.colormask = PIPE_MASK_RGBA
+    ctx.set_blend(blend)
+
+    # depth/stencil/alpha
+    depth_stencil_alpha = DepthStencilAlpha()
+    depth_stencil_alpha.depth.enabled = 1
+    depth_stencil_alpha.depth.writemask = 1
+    depth_stencil_alpha.depth.func = PIPE_FUNC_LESS
+    ctx.set_depth_stencil_alpha(depth_stencil_alpha)
+
+    # rasterizer
+    rasterizer = Rasterizer()
+    rasterizer.front_winding = PIPE_WINDING_CW
+    rasterizer.cull_mode = PIPE_WINDING_NONE
+    rasterizer.scissor = 1
+    ctx.set_rasterizer(rasterizer)
+
+    # viewport
+    viewport = Viewport()
+    scale = FloatArray(4)
+    scale[0] = width / 2.0
+    scale[1] = -height / 2.0
+    scale[2] = (maxz - minz) / 2.0
+    scale[3] = 1.0
+    viewport.scale = scale
+    translate = FloatArray(4)
+    translate[0] = width / 2.0
+    translate[1] = height / 2.0
+    translate[2] = (maxz - minz) / 2.0
+    translate[3] = 0.0
+    viewport.translate = translate
+    ctx.set_viewport(viewport)
+
+    # samplers
+    sampler = Sampler()
+    sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE
+    sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE
+    sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE
+    sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE
+    sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST
+    sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST
+    sampler.normalized_coords = 1
+    ctx.set_sampler(0, sampler)
+
+    # scissor
+    scissor = Scissor()
+    scissor.minx = 0
+    scissor.miny = 0
+    scissor.maxx = width
+    scissor.maxy = height
+    ctx.set_scissor(scissor)
+
+    clip = Clip()
+    clip.nr = 0
+    ctx.set_clip(clip)
+
+    # framebuffer
+    cbuf = dev.texture_create(
+        PIPE_FORMAT_X8R8G8B8_UNORM,
+        width, height,
+        tex_usage=PIPE_TEXTURE_USAGE_DISPLAY_TARGET,
+    ).get_surface()
+    zbuf = dev.texture_create(
+        PIPE_FORMAT_Z16_UNORM,
+        width, height,
+        tex_usage=PIPE_TEXTURE_USAGE_DEPTH_STENCIL,
+    ).get_surface()
+    fb = Framebuffer()
+    fb.width = width
+    fb.height = height
+    fb.nr_cbufs = 1
+    fb.set_cbuf(0, cbuf)
+    fb.set_zsbuf(zbuf)
+    ctx.set_framebuffer(fb)
+    rgba = FloatArray(4);
+    rgba[0] = 0.0
+    rgba[1] = 0.0
+    rgba[2] = 0.0
+    rgba[3] = 0.0
+    ctx.clear(PIPE_CLEAR_COLOR | PIPE_CLEAR_DEPTHSTENCIL, rgba, 1.0, 0xff)
+
+    # vertex shader
+    vs = Shader('''
+        VERT
+        DCL IN[0], POSITION, CONSTANT
+        DCL IN[1], COLOR, CONSTANT
+        DCL OUT[0], POSITION, CONSTANT
+        DCL OUT[1], COLOR, CONSTANT
+        0:MOV OUT[0], IN[0]
+        1:MOV OUT[1], IN[1]
+        2:END
+    ''')
+    ctx.set_vertex_shader(vs)
+
+    gs = Shader('''
+        GEOM
+        PROPERTY GS_INPUT_PRIMITIVE TRIANGLES
+        PROPERTY GS_OUTPUT_PRIMITIVE TRIANGLE_STRIP
+        DCL IN[][0], POSITION, CONSTANT
+        DCL IN[][1], COLOR, CONSTANT
+        DCL OUT[0], POSITION, CONSTANT
+        DCL OUT[1], COLOR, CONSTANT
+        0:MOV OUT[0], IN[0][0]
+        1:MOV OUT[1], IN[0][1]
+        2:EMIT
+        3:MOV OUT[0], IN[1][0]
+        4:MOV OUT[1], IN[1][1]
+        5:EMIT
+        6:MOV OUT[0], IN[2][0]
+        7:MOV OUT[1], IN[2][1]
+        8:EMIT
+        9:ENDPRIM
+        10:END
+    ''')
+    ctx.set_geometry_shader(gs)
+
+    # fragment shader
+    fs = Shader('''
+        FRAG
+        DCL IN[0], COLOR, LINEAR
+        DCL OUT[0], COLOR, CONSTANT
+        0:MOV OUT[0], IN[0]
+        1:END
+    ''')
+    ctx.set_fragment_shader(fs)
+
+    nverts = 3
+    nattrs = 2
+    verts = FloatArray(nverts * nattrs * 4)
+
+    verts[ 0] =   0.0 # x1
+    verts[ 1] =   0.8 # y1
+    verts[ 2] =   0.2 # z1
+    verts[ 3] =   1.0 # w1
+    verts[ 4] =   1.0 # r1
+    verts[ 5] =   0.0 # g1
+    verts[ 6] =   0.0 # b1
+    verts[ 7] =   1.0 # a1
+    verts[ 8] =  -0.8 # x2
+    verts[ 9] =  -0.8 # y2
+    verts[10] =   0.5 # z2
+    verts[11] =   1.0 # w2
+    verts[12] =   0.0 # r2
+    verts[13] =   1.0 # g2
+    verts[14] =   0.0 # b2
+    verts[15] =   1.0 # a2
+    verts[16] =   0.8 # x3
+    verts[17] =  -0.8 # y3
+    verts[18] =   0.8 # z3
+    verts[19] =   1.0 # w3
+    verts[20] =   0.0 # r3
+    verts[21] =   0.0 # g3
+    verts[22] =   1.0 # b3
+    verts[23] =   1.0 # a3
+
+    ctx.draw_vertices(PIPE_PRIM_TRIANGLES,
+                      nverts,
+                      nattrs,
+                      verts)
+
+    ctx.flush()
+
+    show_image(cbuf)
+    #show_image(zbuf)
+    #save_image('cbuf.png', cbuf)
+    #save_image('zbuf.png', zbuf)
+
+
+
+def main():
+    dev = Device()
+    test(dev)
+
+
+if __name__ == '__main__':
+    main()
index b721e0b5750a6ef1cf3ed13f7fbd16440f5ff4f8..af80426dc6cdc90965fe11bcfba68d18aad33ef6 100644 (file)
@@ -118,7 +118,7 @@ def test(dev):
     sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST
     sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST
     sampler.normalized_coords = 1
-    ctx.set_sampler(0, sampler)
+    ctx.set_fragment_sampler(0, sampler)
 
     # scissor
     scissor = Scissor()
@@ -159,7 +159,7 @@ def test(dev):
     
     # vertex shader
     vs = Shader('''
-        VERT1.1
+        VERT
         DCL IN[0], POSITION, CONSTANT
         DCL IN[1], COLOR, CONSTANT
         DCL OUT[0], POSITION, CONSTANT
@@ -172,7 +172,7 @@ def test(dev):
 
     # fragment shader
     fs = Shader('''
-        FRAG1.1
+        FRAG
         DCL IN[0], COLOR, LINEAR
         DCL OUT[0], COLOR, CONSTANT
         0:MOV OUT[0], IN[0]
index ea7d18738f69a19ba12a9c4d381195ad3a9d94db..d144af2447d1d8c0955f9b8acd5ba0ee1d723694 100644 (file)
@@ -62,8 +62,9 @@ st_device_reference(struct st_device **ptr, struct st_device *st_dev)
 {
    struct st_device *old_dev = *ptr;
 
-   if (pipe_reference((struct pipe_reference **)ptr, &st_dev->reference))
+   if (pipe_reference(&(*ptr)->reference, &st_dev->reference))
       st_device_really_destroy(old_dev);
+   *ptr = st_dev;
 }
 
 
@@ -134,7 +135,9 @@ st_context_destroy(struct st_context *st_ctx)
          st_ctx->pipe->destroy(st_ctx->pipe);
       
       for(i = 0; i < PIPE_MAX_SAMPLERS; ++i)
-         pipe_texture_reference(&st_ctx->sampler_textures[i], NULL);
+         pipe_texture_reference(&st_ctx->fragment_sampler_textures[i], NULL);
+      for(i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; ++i)
+         pipe_texture_reference(&st_ctx->vertex_sampler_textures[i], NULL);
       pipe_texture_reference(&st_ctx->default_texture, NULL);
 
       FREE(st_ctx);
@@ -249,12 +252,9 @@ st_context_create(struct st_device *st_dev)
       memset( &templat, 0, sizeof( templat ) );
       templat.target = PIPE_TEXTURE_2D;
       templat.format = PIPE_FORMAT_A8R8G8B8_UNORM;
-      templat.block.size = 4;
-      templat.block.width = 1;
-      templat.block.height = 1;
-      templat.width[0] = 1;
-      templat.height[0] = 1;
-      templat.depth[0] = 1;
+      templat.width0 = 1;
+      templat.height0 = 1;
+      templat.depth0 = 1;
       templat.last_level = 0;
    
       st_ctx->default_texture = screen->texture_create( screen, &templat );
@@ -264,8 +264,8 @@ st_context_create(struct st_device *st_dev)
                                              0, 0, 0,
                                              PIPE_TRANSFER_WRITE,
                                              0, 0,
-                                             st_ctx->default_texture->width[0],
-                                             st_ctx->default_texture->height[0]);
+                                             st_ctx->default_texture->width0,
+                                             st_ctx->default_texture->height0);
          if (transfer) {
             uint32_t *map;
             map = (uint32_t *) screen->transfer_map(screen, transfer);
@@ -278,9 +278,12 @@ st_context_create(struct st_device *st_dev)
       }
    
       for (i = 0; i < PIPE_MAX_SAMPLERS; i++)
-         pipe_texture_reference(&st_ctx->sampler_textures[i], st_ctx->default_texture);
+         pipe_texture_reference(&st_ctx->fragment_sampler_textures[i], st_ctx->default_texture);
+      for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++)
+         pipe_texture_reference(&st_ctx->vertex_sampler_textures[i], st_ctx->default_texture);
       
-      cso_set_sampler_textures(st_ctx->cso, PIPE_MAX_SAMPLERS, st_ctx->sampler_textures);
+      cso_set_sampler_textures(st_ctx->cso, PIPE_MAX_SAMPLERS, st_ctx->fragment_sampler_textures);
+      cso_set_vertex_sampler_textures(st_ctx->cso, PIPE_MAX_VERTEX_SAMPLERS, st_ctx->vertex_sampler_textures);
    }
    
    /* vertex shader */
index a246b6a1f25b495e5e3f03d7679fc598f043f60e..f786e1341189ac1b32c15eb26658b0fe6eb6879d 100644 (file)
@@ -57,9 +57,11 @@ struct st_context {
    
    void *vs;
    void *fs;
+   void *gs;
 
    struct pipe_texture *default_texture;
-   struct pipe_texture *sampler_textures[PIPE_MAX_SAMPLERS];
+   struct pipe_texture *fragment_sampler_textures[PIPE_MAX_SAMPLERS];
+   struct pipe_texture *vertex_sampler_textures[PIPE_MAX_VERTEX_SAMPLERS];
    
    unsigned num_vertex_buffers;
    struct pipe_vertex_buffer vertex_buffers[PIPE_MAX_ATTRIBS];
index 53a01891e128759346c06809ecc4fd183641b139..963774142112d37761a6bbae1fc678dc6f3f8a14 100644 (file)
@@ -30,6 +30,7 @@
 #include "pipe/p_format.h"
 #include "pipe/p_state.h"
 #include "pipe/p_inlines.h"
+#include "util/u_format.h"
 #include "util/u_tile.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
@@ -423,7 +424,6 @@ dxt5_rgba_data[] = {
 
 static INLINE void 
 st_sample_dxt_pixel_block(enum pipe_format format, 
-                          const struct pipe_format_block *block,
                           uint8_t *raw,
                           float *rgba, unsigned rgba_stride, 
                           unsigned w, unsigned h)
@@ -462,21 +462,21 @@ st_sample_dxt_pixel_block(enum pipe_format format,
          for(ch = 0; ch < 4; ++ch)
             rgba[y*rgba_stride + x*4 + ch] = (float)(data[i].rgba[y*4*4 + x*4 + ch])/255.0f;
    
-   memcpy(raw, data[i].raw, block->size);
+   memcpy(raw, data[i].raw, util_format_get_blocksize(format));
 }
 
 
 static INLINE void 
 st_sample_generic_pixel_block(enum pipe_format format, 
-                              const struct pipe_format_block *block,
                               uint8_t *raw,
                               float *rgba, unsigned rgba_stride,
                               unsigned w, unsigned h)
 {
    unsigned i;
    unsigned x, y, ch;
+   int blocksize = util_format_get_blocksize(format);
    
-   for(i = 0; i < block->size; ++i)
+   for(i = 0; i < blocksize; ++i)
       raw[i] = (uint8_t)st_random();
    
    
@@ -503,7 +503,6 @@ st_sample_generic_pixel_block(enum pipe_format format,
  */
 void 
 st_sample_pixel_block(enum pipe_format format,
-                      const struct pipe_format_block *block,
                       void *raw,
                       float *rgba, unsigned rgba_stride,
                       unsigned w, unsigned h)
@@ -513,11 +512,11 @@ st_sample_pixel_block(enum pipe_format format,
    case PIPE_FORMAT_DXT1_RGBA:
    case PIPE_FORMAT_DXT3_RGBA:
    case PIPE_FORMAT_DXT5_RGBA:
-      st_sample_dxt_pixel_block(format, block, raw, rgba, rgba_stride, w, h);
+      st_sample_dxt_pixel_block(format, raw, rgba, rgba_stride, w, h);
       break;
 
    default:
-      st_sample_generic_pixel_block(format, block, raw, rgba, rgba_stride, w, h);
+      st_sample_generic_pixel_block(format, raw, rgba, rgba_stride, w, h);
       break;
    }
 }
@@ -528,8 +527,8 @@ st_sample_surface(struct st_surface *surface, float *rgba)
 {
    struct pipe_texture *texture = surface->texture;
    struct pipe_screen *screen = texture->screen;
-   unsigned width = texture->width[surface->level];
-   unsigned height = texture->height[surface->level];
+   unsigned width = u_minify(texture->width0, surface->level);
+   unsigned height = u_minify(texture->height0, surface->level);
    uint rgba_stride = width * 4;
    struct pipe_transfer *transfer;
    void *raw;
@@ -548,18 +547,23 @@ st_sample_surface(struct st_surface *surface, float *rgba)
 
    raw = screen->transfer_map(screen, transfer);
    if (raw) {
-      const struct pipe_format_block *block = &texture->block;
+      enum pipe_format format = texture->format;
       uint x, y;
+      int nblocksx = util_format_get_nblocksx(format, width);
+      int nblocksy = util_format_get_nblocksy(format, height);
+      int blockwidth = util_format_get_blockwidth(format);
+      int blockheight = util_format_get_blockheight(format);
+      int blocksize = util_format_get_blocksize(format);
 
-      for (y = 0; y < transfer->nblocksy; ++y) {
-         for (x = 0; x < transfer->nblocksx; ++x) {
-            st_sample_pixel_block(texture->format,
-                                  block,
-                                  (uint8_t *) raw + y * transfer->stride + x * block->size,
-                                  rgba + y * block->height * rgba_stride + x * block->width * 4,
+
+      for (y = 0; y < nblocksy; ++y) {
+         for (x = 0; x < nblocksx; ++x) {
+            st_sample_pixel_block(format,
+                                  (uint8_t *) raw + y * transfer->stride + x * blocksize,
+                                  rgba + y * blockheight * rgba_stride + x * blockwidth * 4,
                                   rgba_stride,
-                                  MIN2(block->width, width - x*block->width),
-                                  MIN2(block->height, height - y*block->height));
+                                  MIN2(blockwidth, width - x*blockwidth),
+                                  MIN2(blockheight, height - y*blockheight));
          }
       }
 
index 0a27083549fa6dc6281891ec95449a5659188b5b..888114d3021d899c76f564fb92f9cc26442dbedc 100644 (file)
@@ -35,7 +35,6 @@
 
 void 
 st_sample_pixel_block(enum pipe_format format,
-                      const struct pipe_format_block *block,
                       void *raw,
                       float *rgba, unsigned rgba_stride,
                       unsigned w, unsigned h);
index f0abd12e3dcad2127cfe396aabb27067645731a9..a3294e877a62217e938f63bb2d60f6719afbdb9f 100644 (file)
@@ -40,6 +40,7 @@
 #include "pipe/p_format.h"
 #include "pipe/p_context.h"
 #include "pipe/p_inlines.h"
+#include "util/u_format.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
 #include "softpipe/sp_winsys.h"
@@ -157,16 +158,6 @@ st_softpipe_user_buffer_create(struct pipe_winsys *winsys,
 }
 
 
-/**
- * Round n up to next multiple.
- */
-static INLINE unsigned
-round_up(unsigned n, unsigned multiple)
-{
-   return (n + multiple - 1) & ~(multiple - 1);
-}
-
-
 static struct pipe_buffer *
 st_softpipe_surface_buffer_create(struct pipe_winsys *winsys,
                                   unsigned width, unsigned height,
@@ -176,13 +167,10 @@ st_softpipe_surface_buffer_create(struct pipe_winsys *winsys,
                                   unsigned *stride)
 {
    const unsigned alignment = 64;
-   struct pipe_format_block block;
-   unsigned nblocksx, nblocksy;
+   unsigned nblocksy;
 
-   pf_get_block(format, &block);
-   nblocksx = pf_get_nblocksx(&block, width);
-   nblocksy = pf_get_nblocksy(&block, height);
-   *stride = round_up(nblocksx * block.size, alignment);
+   nblocksy = util_format_get_nblocksy(format, height);
+   *stride = align(util_format_get_stride(format, width), alignment);
 
    return winsys->buffer_create(winsys, alignment,
                                 usage,
index 202ccfc35097fbf1e364c63fe34342cfa2012b05..b022d073fda815a77dae2be07fcf3bdf6df76a06 100755 (executable)
@@ -47,7 +47,7 @@ for name, value in globals().items():
         formats[value] = name
 
 def is_depth_stencil_format(format):
-    # FIXME: make and use binding to pf_is_depth_stencil
+    # FIXME: make and use binding to util_format_is_depth_or_stencil
     return format in (
         PIPE_FORMAT_Z32_UNORM,
         PIPE_FORMAT_Z24S8_UNORM,
index 7a0006bf660006bc55069dd3a83b68ddc1b2895c..103d7497f48fa922626a93a85957a569d5503e57 100644 (file)
@@ -1,4 +1,4 @@
-FRAG1.1
+FRAG
 
 DCL IN[0], COLOR, LINEAR
 DCL OUT[0], COLOR
index f7836c85ddba71199de9b1d03c20c8bc98eb80ee..bcb942059639f20246dff215e773ab86084a9461 100644 (file)
@@ -1,4 +1,4 @@
-FRAG1.1
+FRAG
 
 DCL IN[0], COLOR, LINEAR
 DCL OUT[0], COLOR
index c89cd748a80655907f38057337adcfeba6b96525..b5281975d4a60c3589558ce09818cb30bfc34057 100644 (file)
@@ -1,4 +1,4 @@
-FRAG1.1
+FRAG
 
 DCL IN[0], COLOR, LINEAR
 DCL OUT[0], COLOR
index 6517e3c494572aeb7003b852c08e8b5026ddafd2..d59df76e70b3e2a6d3ae259e622369086dd90130 100644 (file)
@@ -1,4 +1,4 @@
-FRAG1.1
+FRAG
 
 DCL IN[0], COLOR, LINEAR
 DCL OUT[0], COLOR
index 464880ba68f18a03312589744c76fa83d3f561b6..fbb20fa9f6268f47449f5c44c565cc2b6e1d7025 100644 (file)
@@ -1,4 +1,4 @@
-FRAG1.1
+FRAG
 
 DCL IN[0], COLOR, LINEAR
 DCL OUT[0], COLOR
index 2684076f1d61884a449ea9d9da86c7bc4da529da..b511288f4b6b4c4cd2b4f99456a0b7bdb84e4dec 100644 (file)
@@ -1,4 +1,4 @@
-FRAG1.1
+FRAG
 
 DCL IN[0], COLOR, LINEAR
 DCL OUT[0], COLOR
index ad11e28918abca141d539937d6ffc30ad0722cd0..99a2f96103ac2c67569fd51e5841321197832470 100644 (file)
@@ -1,4 +1,4 @@
-FRAG1.1
+FRAG
 
 DCL IN[0], COLOR, LINEAR
 DCL OUT[0], COLOR
index 4f3aa30d666fbf65444d33d1765d3e467b830918..a54c2623b0a47f2c1ac1a01092cb0202623475a3 100644 (file)
@@ -1,4 +1,4 @@
-FRAG1.1
+FRAG
 
 DCL IN[0], COLOR, LINEAR
 DCL OUT[0], COLOR
index 54c7c64459867a46b617a2d1655fa785ad9ec581..5f5b4be1092c6c10fdc18c48ab570104e65ca370 100644 (file)
@@ -1,4 +1,4 @@
-FRAG1.1
+FRAG
 
 DCL IN[0], COLOR, LINEAR
 DCL OUT[0], COLOR
index 0e78ef86b54cbca46727178eae0abeefebc5befb..6323c4712dc0fe37fad6d6fa18f9b0301232467c 100644 (file)
@@ -1,4 +1,4 @@
-FRAG1.1
+FRAG
 
 DCL IN[0], COLOR, LINEAR
 DCL OUT[0], COLOR
index e9ee0f81478a84203f214e2830633d8dd7599bd6..740809d22e001844b8fbc2e58b94187474697f0f 100644 (file)
@@ -1,4 +1,4 @@
-FRAG1.1
+FRAG
 
 DCL IN[0], COLOR, LINEAR
 DCL OUT[0], COLOR
index 439acd5bbdec6dfa5756c9f12969fd5fd72e2496..413b9dc39164bb6e8970531a48ffd6d0a62d862d 100644 (file)
@@ -1,4 +1,4 @@
-FRAG1.1
+FRAG
 
 DCL IN[0], COLOR, LINEAR
 DCL OUT[0], COLOR
index ab21b245dd8cf7c5a126d9e4d9c257f96f81b1d2..b69f2132612a9fea7c9fbaafa2c29709965bfd60 100644 (file)
@@ -1,4 +1,4 @@
-FRAG1.1
+FRAG
 
 DCL IN[0], COLOR, LINEAR
 DCL OUT[0], COLOR
index 969ae73d98efea710483edbdd6759eba47455658..df284f49e71ea7c8f1256637538b91909b60efe1 100644 (file)
@@ -1,4 +1,4 @@
-FRAG1.1
+FRAG
 
 DCL IN[0], COLOR, LINEAR
 DCL OUT[0], COLOR
index 612975e05709422a3081f6bded5da33e90a4ce1e..64af72f381ba5896c1cf9c906d28cbfd190493f4 100644 (file)
@@ -1,4 +1,4 @@
-FRAG1.1
+FRAG
 
 DCL IN[0], COLOR, LINEAR
 DCL OUT[0], COLOR
index ed158b0fc6923fc564b90f850e94936deb46bcaf..bdd0b0026b9a01a38047791540289bde00e94f9d 100644 (file)
@@ -1,4 +1,4 @@
-FRAG1.1
+FRAG
 
 DCL IN[0], COLOR, LINEAR
 DCL OUT[0], COLOR
index cc9feef07e1398f8c0b573c73587f5898e0b3f70..f4b611b26abf7803db3fbd1791c0da0ffb75034b 100644 (file)
@@ -1,4 +1,4 @@
-FRAG1.1
+FRAG
 
 DCL IN[0], COLOR, LINEAR
 DCL OUT[0], COLOR
index 695621fdc97c88fe9f7a807208e7bc8640baed8c..d1e9b0b53be4b0c09364bc5eb996fe1b7aee5c46 100644 (file)
@@ -1,4 +1,4 @@
-FRAG1.1
+FRAG
 
 DCL IN[0], COLOR, LINEAR
 DCL OUT[0], COLOR
index 9505bc3c3e32c4b9ec6a91ef4ca072a9cd007c88..1f33fac472789a007e91299214452ccb51d78b29 100644 (file)
@@ -1,4 +1,4 @@
-FRAG1.1
+FRAG
 
 DCL IN[0], COLOR, LINEAR
 DCL OUT[0], COLOR
index 83441fa8207fb4b2f6b5208581b5f694c8d3b177..673fca139aa93868570e6ef34be4a6a86a2a0c92 100644 (file)
@@ -1,4 +1,4 @@
-FRAG1.1
+FRAG
 
 DCL IN[0], COLOR, LINEAR
 DCL OUT[0], COLOR
index d6f66c4927ab00453ad7c82b298e12fb09199eeb..6ec8b1184cc37bf9f7d2e712bda85d87708ccdf3 100644 (file)
@@ -1,4 +1,4 @@
-FRAG1.1
+FRAG
 
 DCL IN[0], COLOR, LINEAR
 DCL OUT[0], COLOR
index d60fb38d1ae6c28201341c64a26d82baf2fccc9a..eed6cdd1e6460be4771991ee5463d7d95a949bed 100644 (file)
@@ -96,7 +96,7 @@ def test(dev, name):
     sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST
     sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST
     sampler.normalized_coords = 1
-    ctx.set_sampler(0, sampler)
+    ctx.set_fragment_sampler(0, sampler)
 
     # scissor
     scissor = Scissor()
@@ -131,7 +131,7 @@ def test(dev, name):
 
     # vertex shader
     vs = Shader('''
-        VERT1.1
+        VERT
         DCL IN[0], POSITION
         DCL IN[1], COLOR
         DCL OUT[0], POSITION
index 7638e96346e1ad8e2390ca8211a9ada22d9f8782..321140e89e8f77469be6efe20752ef81fbac5595 100644 (file)
@@ -1,4 +1,4 @@
-VERT1.1
+VERT
 
 DCL IN[0], POSITION
 DCL OUT[0], POSITION
index 28ce6f9a0cf03330fa789df4f4350563371a9baf..d60ea46b3672a080ae4da43c6d6e38ba8d94d3f0 100644 (file)
@@ -1,4 +1,4 @@
-VERT1.1
+VERT
 
 DCL IN[0], POSITION
 DCL OUT[0], POSITION
index 44ad708119decd052382f7cbc5e320cc787b0732..aa80d6e394c4f39b5f4b9e5522e6c065936487ba 100644 (file)
@@ -1,4 +1,4 @@
-VERT1.1
+VERT
 
 DCL IN[0], POSITION
 DCL OUT[0], POSITION
index d179749de84acb6d8f30705a814cb1d62f9c8543..64d1a494e13f46e637865ae4fa39080354e886a8 100644 (file)
@@ -1,4 +1,4 @@
-VERT1.1
+VERT
 
 DCL IN[0], POSITION
 DCL OUT[0], POSITION
index 472769f259232f1d50de2aa206caffacb7847cf6..41bebd0604a423029f033c06b7ca2c29d4d25213 100644 (file)
@@ -96,7 +96,7 @@ def test(dev, name):
     sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST
     sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST
     sampler.normalized_coords = 1
-    ctx.set_sampler(0, sampler)
+    ctx.set_fragment_sampler(0, sampler)
 
     # scissor
     scissor = Scissor()
@@ -135,7 +135,7 @@ def test(dev, name):
 
     # fragment shader
     fs = Shader('''
-        FRAG1.1
+        FRAG
         DCL IN[0], COLOR, LINEAR
         DCL OUT[0], COLOR, CONSTANT
         0:MOV OUT[0], IN[0]
index 3ceecbbd3aa6deb0354adbca38bc31805fdaa4ed..df5babb78af0f91cc512977a3a11ddca31a232b2 100755 (executable)
@@ -98,9 +98,10 @@ class TextureTest(TestCase):
         y = 0
         w = dst_surface.width
         h = dst_surface.height
-    
-        stride = dst_surface.nblocksx * dst_texture.block.size
-        size = dst_surface.nblocksy * stride
+
+        # ???
+        stride = pf_get_stride(texture->format, w)
+        size = pf_get_nblocksy(texture->format) * stride
         src_raw = os.urandom(size)
 
         src_surface.put_tile_raw(0, 0, w, h, src_raw, stride)
index 0b76932b6ede275d521235a551932b80a1e08db3..79287f2caceaa115907cd1b9d7a588ea71d13598 100755 (executable)
@@ -144,8 +144,8 @@ class TextureTest(TestCase):
         sampler.normalized_coords = 1
         sampler.min_lod = 0
         sampler.max_lod = PIPE_MAX_TEXTURE_LEVELS - 1
-        ctx.set_sampler(0, sampler)
-        ctx.set_sampler_texture(0, src_texture)
+        ctx.set_fragment_sampler(0, sampler)
+        ctx.set_fragment_sampler_texture(0, src_texture)
 
         #  framebuffer 
         cbuf_tex = dev.texture_create(
@@ -171,7 +171,7 @@ class TextureTest(TestCase):
     
         # vertex shader
         vs = Shader('''
-            VERT1.1
+            VERT
             DCL IN[0], POSITION, CONSTANT
             DCL IN[1], GENERIC, CONSTANT
             DCL OUT[0], POSITION, CONSTANT
@@ -185,7 +185,7 @@ class TextureTest(TestCase):
     
         # fragment shader
         fs = Shader('''
-            FRAG1.1
+            FRAG
             DCL IN[0], GENERIC[0], LINEAR
             DCL OUT[0], COLOR, CONSTANT
             DCL SAMP[0], CONSTANT
index c7b78abbbec4de163a24a25931260359d2832058..520961c8051ef9e98f002c9312827dbfe1bab747 100755 (executable)
@@ -169,7 +169,7 @@ class TextureColorSampleTest(TestCase):
         sampler.normalized_coords = 1
         sampler.min_lod = 0
         sampler.max_lod = PIPE_MAX_TEXTURE_LEVELS - 1
-        ctx.set_sampler(0, sampler)
+        ctx.set_fragment_sampler(0, sampler)
     
         #  texture 
         texture = dev.texture_create(
@@ -189,7 +189,7 @@ class TextureColorSampleTest(TestCase):
             zslice = zslice,
         ).sample_rgba(expected_rgba)
         
-        ctx.set_sampler_texture(0, texture)
+        ctx.set_fragment_sampler_texture(0, texture)
 
         #  framebuffer 
         cbuf_tex = dev.texture_create(
@@ -216,7 +216,7 @@ class TextureColorSampleTest(TestCase):
     
         # vertex shader
         vs = Shader('''
-            VERT1.1
+            VERT
             DCL IN[0], POSITION, CONSTANT
             DCL IN[1], GENERIC, CONSTANT
             DCL OUT[0], POSITION, CONSTANT
@@ -236,7 +236,7 @@ class TextureColorSampleTest(TestCase):
             PIPE_TEXTURE_CUBE: "CUBE",
         }[target]
         fs = Shader('''
-            FRAG1.1
+            FRAG
             DCL IN[0], GENERIC[0], LINEAR
             DCL OUT[0], COLOR, CONSTANT
             DCL SAMP[0], CONSTANT
@@ -359,7 +359,7 @@ class TextureDepthSampleTest(TestCase):
         sampler.normalized_coords = 1
         sampler.min_lod = 0
         sampler.max_lod = PIPE_MAX_TEXTURE_LEVELS - 1
-        ctx.set_sampler(0, sampler)
+        ctx.set_fragment_sampler(0, sampler)
     
         #  texture 
         texture = dev.texture_create(
@@ -379,7 +379,7 @@ class TextureDepthSampleTest(TestCase):
             zslice = zslice,
         ).sample_rgba(expected_rgba)
         
-        ctx.set_sampler_texture(0, texture)
+        ctx.set_fragment_sampler_texture(0, texture)
 
         #  framebuffer 
         cbuf_tex = dev.texture_create(
@@ -415,7 +415,7 @@ class TextureDepthSampleTest(TestCase):
     
         # vertex shader
         vs = Shader('''
-            VERT1.1
+            VERT
             DCL IN[0], POSITION, CONSTANT
             DCL IN[1], GENERIC, CONSTANT
             DCL OUT[0], POSITION, CONSTANT
@@ -435,7 +435,7 @@ class TextureDepthSampleTest(TestCase):
             PIPE_TEXTURE_CUBE: "CUBE",
         }[target]
         fs = Shader('''
-            FRAG1.1
+            FRAG
             DCL IN[0], GENERIC[0], LINEAR
             DCL SAMP[0], CONSTANT
             DCL OUT[0].z, POSITION
index e65b425adf4e28429daa59240e84afe6c6cbfb41..35daca9e498990f726cedf3f6c4cf2c9011e3c83 100755 (executable)
@@ -86,8 +86,9 @@ class TextureTest(TestCase):
         
         surface = texture.get_surface(face, level, zslice)
         
-        stride = surface.nblocksx * texture.block.size
-        size = surface.nblocksy * stride
+        # ???
+        stride = pf_get_stride(texture->format, w)
+        size = pf_get_nblocksy(texture->format) * stride
 
         in_raw = os.urandom(size)
 
index b8c805b06c4f4301bc54b3bee73bd4986953ccd9..fc97bf51f8fed9d6994e2a978c1b6d8925474c61 100644 (file)
@@ -61,14 +61,7 @@ VG_MINOR = 0
 VG_TINY = 0
 
 GALLIUM_LIBS = \
-       $(GALLIUM)/src/gallium/auxiliary/pipebuffer/libpipebuffer.a \
-       $(GALLIUM)/src/gallium/auxiliary/sct/libsct.a \
-       $(GALLIUM)/src/gallium/auxiliary/draw/libdraw.a \
-       $(GALLIUM)/src/gallium/auxiliary/rtasm/librtasm.a \
-       $(GALLIUM)/src/gallium/auxiliary/translate/libtranslate.a \
-       $(GALLIUM)/src/gallium/auxiliary/cso_cache/libcso_cache.a \
-       $(GALLIUM)/src/gallium/auxiliary/util/libutil.a \
-       $(GALLIUM)/src/gallium/auxiliary/tgsi/libtgsi.a
+       $(GALLIUM)/src/gallium/auxiliary/libgallium.a
 
 .SUFFIXES : .cpp
 
index 862cbb03c439673c570105b285ea39ad3656379e..2f984fb7b9afa012d4c6ea47ad9851bcf68512ef 100644 (file)
@@ -38,6 +38,7 @@
 #include "pipe/p_screen.h"
 #include "pipe/p_shader_tokens.h"
 
+#include "util/u_format.h"
 #include "util/u_memory.h"
 
 
@@ -68,10 +69,9 @@ static INLINE struct pipe_texture *create_texture_1d(struct vg_context *ctx,
    templ.target = PIPE_TEXTURE_1D;
    templ.format = PIPE_FORMAT_A8R8G8B8_UNORM;
    templ.last_level = 0;
-   templ.width[0] = color_data_len;
-   templ.height[0] = 1;
-   templ.depth[0] = 1;
-   pf_get_block(PIPE_FORMAT_A8R8G8B8_UNORM, &templ.block);
+   templ.width0 = color_data_len;
+   templ.height0 = 1;
+   templ.depth0 = 1;
    templ.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER;
 
    tex = screen->texture_create(screen, &templ);
@@ -81,7 +81,7 @@ static INLINE struct pipe_texture *create_texture_1d(struct vg_context *ctx,
          screen->get_tex_transfer(screen, tex,
                                   0, 0, 0,
                                   PIPE_TRANSFER_READ_WRITE ,
-                                  0, 0, tex->width[0], tex->height[0]);
+                                  0, 0, tex->width0, tex->height0);
       void *map = screen->transfer_map(screen, transfer);
       memcpy(map, color_data, sizeof(VGint)*color_data_len);
       screen->transfer_unmap(screen, transfer);
index a6b7a2bb93a5ecf973cac404d78992716ff81123..15ac1900f4b1e503cade9fc49f16d9fbc57c3846 100644 (file)
@@ -164,8 +164,7 @@ void vgAppendPathData(VGPath dstPath,
       return;
    }
    for (i = 0; i < numSegments; ++i) {
-      if (pathSegments[i] < VG_CLOSE_PATH ||
-          pathSegments[i] > VG_LCWARC_TO_REL) {
+      if (pathSegments[i] > VG_LCWARC_TO_REL) {
          vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR);
          return;
       }
index e74c7f033456fbc8a38e073647509aa1cf153219..2d1234087024194fd3ca1459a30cb6d62f5a6bb9 100644 (file)
@@ -537,8 +537,9 @@ static INLINE int num_beziers_needed(struct arc *arc)
       double d_eta = (max_eta - min_eta) / n;
       if (d_eta <= 0.5 * M_PI) {
          double eta_b = min_eta;
+         int i;
          found = VG_TRUE;
-         for (int i = 0; found && (i < n); ++i) {
+         for (i = 0; found && (i < n); ++i) {
             double etaA = eta_b;
             eta_b += d_eta;
             found = (estimate_error(arc, etaA, eta_b) <= threshold);
@@ -554,6 +555,7 @@ static void arc_to_beziers(struct arc *arc,
                            struct arc_cb cb,
                            struct matrix *matrix)
 {
+   int i;
    int n = 1;
    double d_eta, eta_b, cos_eta_b,
       sin_eta_b, a_cos_eta_b, b_sin_eta_b, a_sin_eta_b,
@@ -607,7 +609,7 @@ static void arc_to_beziers(struct arc *arc,
    t     = tan(0.5 * d_eta);
    alpha = sin(d_eta) * (sqrt(4 + 3 * t * t) - 1) / 3;
 
-   for (int i = 0; i < n; ++i) {
+   for (i = 0; i < n; ++i) {
       struct bezier bezier;
       double xA    = x_b;
       double yA    = y_b;
index 9a49f2e12d0139bf3eb0167fc7b521b8e0ec30b7..60bed197e28c5aad3ecc74d90c97ff6153f84a18 100644 (file)
@@ -28,7 +28,7 @@
 #define ASM_FILTERS_H
 
 static const char color_matrix_asm[] =
-   "FRAG1.1\n"
+   "FRAG\n"
    "DCL IN[0], GENERIC[0], PERSPECTIVE\n"
    "DCL OUT[0], COLOR, CONSTANT\n"
    "DCL CONST[0..4], CONSTANT\n"
@@ -51,7 +51,7 @@ static const char color_matrix_asm[] =
    "END\n";
 
 static const char convolution_asm[] =
-   "FRAG1.1\n"
+   "FRAG\n"
    "DCL IN[0], GENERIC[0], PERSPECTIVE\n"
    "DCL OUT[0], COLOR, CONSTANT\n"
    "DCL TEMP[0..4], CONSTANT\n"
@@ -78,7 +78,7 @@ static const char convolution_asm[] =
 
 
 static const char lookup_asm[] =
-   "FRAG1.1\n"
+   "FRAG\n"
    "DCL IN[0], GENERIC[0], PERSPECTIVE\n"
    "DCL OUT[0], COLOR, CONSTANT\n"
    "DCL TEMP[0..2], CONSTANT\n"
@@ -103,7 +103,7 @@ static const char lookup_asm[] =
 
 
 static const char lookup_single_asm[] =
-   "FRAG1.1\n"
+   "FRAG\n"
    "DCL IN[0], GENERIC[0], PERSPECTIVE\n"
    "DCL OUT[0], COLOR, CONSTANT\n"
    "DCL TEMP[0..2], CONSTANT\n"
index 218e1d166db8c7e8e4c5b6f1f98a557e03dc532c..903bfc88a4d2fdd39757bc01c3be8ad9fb5c249b 100644 (file)
@@ -29,7 +29,7 @@
 
 
 static const char pass_through_depth_asm[] =
-   "FRAG1.1\n"
+   "FRAG\n"
    "DCL IN[0], POSITION, LINEAR\n"
    "DCL OUT[0].z, POSITION, CONSTANT\n"
    "0: MOV OUT[0].z, IN[0].zzzz\n"
@@ -39,7 +39,7 @@ static const char pass_through_depth_asm[] =
 
 /* μnew = μmask */
 static const char set_mask_asm[] =
-   "FRAG1.1\n"
+   "FRAG\n"
    "DCL IN[0], GENERIC[0], PERSPECTIVE\n"
    "DCL SAMP[0], CONSTANT\n"
    "DCL OUT[0], COLOR, CONSTANT\n"
@@ -48,7 +48,7 @@ static const char set_mask_asm[] =
 
 /* μnew = 1 – (1 – μmask)*(1 – μprev) */
 static const char union_mask_asm[] =
-   "FRAG1.1\n"
+   "FRAG\n"
    "DCL IN[0], GENERIC[0], PERSPECTIVE\n"
    "DCL IN[1], POSITION, LINEAR\n"
    "DCL CONST[0], CONSTANT\n"
@@ -65,7 +65,7 @@ static const char union_mask_asm[] =
 
 /* μnew = μmask *μprev */
 static const char intersect_mask_asm[] =
-   "FRAG1.1\n"
+   "FRAG\n"
    "DCL IN[0], GENERIC[0], PERSPECTIVE\n"
    "DCL IN[1], POSITION, LINEAR\n"
    "DCL CONST[0], CONSTANT\n"
@@ -79,7 +79,7 @@ static const char intersect_mask_asm[] =
 
 /* μnew = μprev*(1 – μmask) */
 static const char subtract_mask_asm[] =
-   "FRAG1.1\n"
+   "FRAG\n"
    "DCL IN[0], GENERIC[0], PERSPECTIVE\n"
    "DCL IN[1], POSITION, LINEAR\n"
    "DCL CONST[0], CONSTANT\n"
@@ -94,7 +94,7 @@ static const char subtract_mask_asm[] =
 
 
 static const char vs_plain_asm[] =
-   "VERT1.1\n"
+   "VERT\n"
    "DCL IN[0]\n"
    "DCL OUT[0], POSITION\n"
    "DCL TEMP[0]\n"
@@ -105,7 +105,7 @@ static const char vs_plain_asm[] =
    "3: END\n";
 
 static const char vs_clear_asm[] =
-   "VERT1.1\n"
+   "VERT\n"
    "DCL IN[0]\n"
    "DCL IN[1]\n"
    "DCL OUT[0], POSITION\n"
@@ -120,7 +120,7 @@ static const char vs_clear_asm[] =
 
 
 static const char vs_texture_asm[] =
-   "VERT1.1\n"
+   "VERT\n"
    "DCL IN[0]\n"
    "DCL IN[1]\n"
    "DCL OUT[0], POSITION\n"
index 39a7ade016181774c1d6507f1ead4f19cc7ee440..5769e8ea868ec6998a66667360de7c58d5bf8fc5 100644 (file)
@@ -255,7 +255,8 @@ static enum shift_result good_offset(const struct bezier *b1,
    const float max_dist_line = threshold*offset*offset;
    const float max_dist_normal = threshold*offset;
    const float spacing = 0.25;
-   for (float i = spacing; i < 0.99; i += spacing) {
+   float i;
+   for (i = spacing; i < 0.99; i += spacing) {
       float p1[2],p2[2], d, l;
       float normal[2];
       bezier_point_at(b1, i, p1);
@@ -330,6 +331,7 @@ static enum shift_result shift(const struct bezier *orig,
                                struct bezier *shifted,
                                float offset, float threshold)
 {
+   int i;
    int map[4];
    VGboolean p1_p2_equal = (orig->x1 == orig->x2 && orig->y1 == orig->y2);
    VGboolean p2_p3_equal = (orig->x2 == orig->x3 && orig->y2 == orig->y3);
@@ -404,7 +406,7 @@ static enum shift_result shift(const struct bezier *orig,
    points_shifted[0][0] = points[0][0] + offset * prev_normal[0];
    points_shifted[0][1] = points[0][1] + offset * prev_normal[1];
 
-   for (int i = 1; i < np - 1; ++i) {
+   for (i = 1; i < np - 1; ++i) {
       float normal_sum[2], r;
       float next_normal[2];
       compute_pt_normal(points[i], points[i + 1], next_normal);
index 9a722980d522e4881af6075316e1a10271c0eac7..1112ad9839d5811304d9b4c4ad777e51e451f47f 100644 (file)
@@ -39,6 +39,7 @@
 #include "pipe/p_screen.h"
 #include "pipe/p_inlines.h"
 #include "util/u_blit.h"
+#include "util/u_format.h"
 #include "util/u_tile.h"
 #include "util/u_memory.h"
 #include "util/u_math.h"
@@ -93,8 +94,8 @@ static void vg_copy_texture(struct vg_context *ctx,
    dst_loc[3] = height;
    dst_bounds[0] = 0.f;
    dst_bounds[1] = 0.f;
-   dst_bounds[2] = dst->width[0];
-   dst_bounds[3] = dst->height[0];
+   dst_bounds[2] = dst->width0;
+   dst_bounds[3] = dst->height0;
 
    src_loc[0] = sx;
    src_loc[1] = sy;
@@ -102,8 +103,8 @@ static void vg_copy_texture(struct vg_context *ctx,
    src_loc[3] = height;
    src_bounds[0] = 0.f;
    src_bounds[1] = 0.f;
-   src_bounds[2] = src->width[0];
-   src_bounds[3] = src->height[0];
+   src_bounds[2] = src->width0;
+   src_bounds[3] = src->height0;
 
    vg_bound_rect(src_loc, src_bounds, src_shift);
    vg_bound_rect(dst_loc, dst_bounds, dst_shift);
@@ -270,11 +271,10 @@ struct vg_image * image_create(VGImageFormat format,
    memset(&pt, 0, sizeof(pt));
    pt.target = PIPE_TEXTURE_2D;
    pt.format = pformat;
-   pf_get_block(pformat, &pt.block);
    pt.last_level = 0;
-   pt.width[0] = width;
-   pt.height[0] = height;
-   pt.depth[0] = 1;
+   pt.width0 = width;
+   pt.height0 = height;
+   pt.depth0 = 1;
    pt.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER;
 
    newtex = screen->texture_create(screen, &pt);
@@ -414,7 +414,7 @@ void image_sub_data(struct vg_image *image,
    { /* upload color_data */
       struct pipe_transfer *transfer = screen->get_tex_transfer(
          screen, texture, 0, 0, 0,
-         PIPE_TRANSFER_WRITE, 0, 0, texture->width[0], texture->height[0]);
+         PIPE_TRANSFER_WRITE, 0, 0, texture->width0, texture->height0);
       src += (dataStride * yoffset);
       for (i = 0; i < height; i++) {
          _vega_unpack_float_span_rgba(ctx, width, xoffset, src, dataFormat, temp);
@@ -644,7 +644,7 @@ VGint image_sampler_filter(struct vg_context *ctx)
        return PIPE_TEX_FILTER_NEAREST;
        break;
     case VG_IMAGE_QUALITY_BETTER:
-       /*return PIPE_TEX_FILTER_ANISO;*/
+       /* possibly use anisotropic filtering */
        return PIPE_TEX_FILTER_LINEAR;
        break;
     default:
index 24650a37d502f30a8012948387934a8b9c3ad797..42300bb6d573fdbd0c6d5be10a4a7b847ce10ac8 100644 (file)
@@ -36,6 +36,7 @@
 #include "pipe/p_context.h"
 #include "pipe/p_screen.h"
 #include "pipe/p_inlines.h"
+#include "util/u_format.h"
 #include "util/u_memory.h"
 
 struct vg_mask_layer {
@@ -426,7 +427,7 @@ static void mask_using_texture(struct pipe_texture *texture,
    if (!surface)
       return;
    if (!intersect_rectangles(surface->width, surface->height,
-                             texture->width[0], texture->height[0],
+                             texture->width0, texture->height0,
                              x, y, width, height,
                              offsets, loc))
       return;
@@ -491,11 +492,10 @@ struct vg_mask_layer * mask_layer_create(VGint width, VGint height)
       memset(&pt, 0, sizeof(pt));
       pt.target = PIPE_TEXTURE_2D;
       pt.format = PIPE_FORMAT_A8R8G8B8_UNORM;
-      pf_get_block(PIPE_FORMAT_A8R8G8B8_UNORM, &pt.block);
       pt.last_level = 0;
-      pt.width[0] = width;
-      pt.height[0] = height;
-      pt.depth[0] = 1;
+      pt.width0 = width;
+      pt.height0 = height;
+      pt.depth0 = 1;
       pt.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER;
       pt.compressed = 0;
 
@@ -607,8 +607,8 @@ void mask_render_to(struct path *path,
    struct vg_mask_layer *temp_layer;
    VGint width, height;
 
-   width = fb_buffers->alpha_mask->width[0];
-   height = fb_buffers->alpha_mask->width[0];
+   width = fb_buffers->alpha_mask->width0;
+   height = fb_buffers->alpha_mask->width0;
 
    temp_layer = mask_layer_create(width, height);
 
index 04a6ba9cdcd307b4aff905b37c7d186d84c87a8f..cc73771d358704ef24014e4a3da03fc4db9ceca0 100644 (file)
@@ -34,6 +34,7 @@
 #include "pipe/p_compiler.h"
 #include "pipe/p_inlines.h"
 
+#include "util/u_format.h"
 #include "util/u_memory.h"
 #include "util/u_math.h"
 
@@ -151,10 +152,9 @@ static INLINE struct pipe_texture *create_gradient_texture(struct vg_paint *p)
    templ.target = PIPE_TEXTURE_1D;
    templ.format = PIPE_FORMAT_A8R8G8B8_UNORM;
    templ.last_level = 0;
-   templ.width[0] = 1024;
-   templ.height[0] = 1;
-   templ.depth[0] = 1;
-   pf_get_block(PIPE_FORMAT_A8R8G8B8_UNORM, &templ.block);
+   templ.width0 = 1024;
+   templ.height0 = 1;
+   templ.depth0 = 1;
    templ.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER;
 
    tex = screen->texture_create(screen, &templ);
@@ -328,8 +328,8 @@ static INLINE void  paint_pattern_buffer(struct vg_paint *paint, void *buffer)
 
    map[4] = 0.f;
    map[5] = 1.f;
-   map[6] = paint->pattern.texture->width[0];
-   map[7] = paint->pattern.texture->height[0];
+   map[6] = paint->pattern.texture->width0;
+   map[7] = paint->pattern.texture->height0;
    {
       struct matrix mat;
       memcpy(&mat, &ctx->state.vg.fill_paint_to_user_matrix,
index f7c5f2f0cdf3f715516f6ba60d6189b2b905b67c..64e3a7c5453573189e36202573ebb0bf9b992088 100644 (file)
 #include "pipe/p_shader_tokens.h"
 
 #include "util/u_draw_quad.h"
+#include "util/u_format.h"
 #include "util/u_simple_shaders.h"
 #include "util/u_memory.h"
+#include "util/u_rect.h"
 
 #include "cso_cache/cso_context.h"
 
@@ -55,7 +57,7 @@ static void setup_shaders(struct renderer *ctx)
 {
    struct pipe_context *pipe = ctx->pipe;
    /* fragment shader */
-   ctx->fs = util_make_fragment_tex_shader(pipe);
+   ctx->fs = util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_2D);
 }
 
 static struct pipe_buffer *
@@ -229,13 +231,13 @@ void renderer_draw_texture(struct renderer *r,
    struct pipe_buffer *buf;
    VGfloat s0, t0, s1, t1;
 
-   assert(tex->width[0] != 0);
-   assert(tex->height[0] != 0);
+   assert(tex->width0 != 0);
+   assert(tex->height0 != 0);
 
-   s0 = x1offset / tex->width[0];
-   s1 = x2offset / tex->width[0];
-   t0 = y1offset / tex->height[0];
-   t1 = y2offset / tex->height[0];
+   s0 = x1offset / tex->width0;
+   s1 = x2offset / tex->width0;
+   t0 = y1offset / tex->height0;
+   t1 = y2offset / tex->height0;
 
    cso_save_vertex_shader(r->cso);
    /* shaders */
@@ -275,10 +277,10 @@ void renderer_copy_texture(struct renderer *ctx,
    struct pipe_framebuffer_state fb;
    float s0, t0, s1, t1;
 
-   assert(src->width[0] != 0);
-   assert(src->height[0] != 0);
-   assert(dst->width[0] != 0);
-   assert(dst->height[0] != 0);
+   assert(src->width0 != 0);
+   assert(src->height0 != 0);
+   assert(dst->width0 != 0);
+   assert(dst->height0 != 0);
 
 #if 0
    debug_printf("copy texture [%f, %f, %f, %f], [%f, %f, %f, %f]\n",
@@ -286,10 +288,10 @@ void renderer_copy_texture(struct renderer *ctx,
 #endif
 
 #if 1
-   s0 = sx1 / src->width[0];
-   s1 = sx2 / src->width[0];
-   t0 = sy1 / src->height[0];
-   t1 = sy2 / src->height[0];
+   s0 = sx1 / src->width0;
+   s1 = sx2 / src->width0;
+   t0 = sy1 / src->height0;
+   t1 = sy2 / src->height0;
 #else
    s0 = 0;
    s1 = 1;
@@ -444,10 +446,9 @@ void renderer_copy_surface(struct renderer *ctx,
    texTemp.target = PIPE_TEXTURE_2D;
    texTemp.format = src->format;
    texTemp.last_level = 0;
-   texTemp.width[0] = srcW;
-   texTemp.height[0] = srcH;
-   texTemp.depth[0] = 1;
-   pf_get_block(src->format, &texTemp.block);
+   texTemp.width0 = srcW;
+   texTemp.height0 = srcH;
+   texTemp.depth0 = 1;
 
    tex = screen->texture_create(screen, &texTemp);
    if (!tex)
@@ -457,10 +458,17 @@ void renderer_copy_surface(struct renderer *ctx,
                                      PIPE_BUFFER_USAGE_GPU_WRITE);
 
    /* load temp texture */
-   pipe->surface_copy(pipe,
-                      texSurf, 0, 0,   /* dest */
-                      src, srcLeft, srcTop, /* src */
-                      srcW, srcH);     /* size */
+   if (pipe->surface_copy) {
+      pipe->surface_copy(pipe,
+                         texSurf, 0, 0,   /* dest */
+                         src, srcLeft, srcTop, /* src */
+                         srcW, srcH);     /* size */
+   } else {
+      util_surface_copy(pipe, FALSE,
+                        texSurf, 0, 0,   /* dest */
+                        src, srcLeft, srcTop, /* src */
+                        srcW, srcH);     /* size */
+   }
 
    /* free the surface, update the texture if necessary.*/
    screen->tex_surface_destroy(texSurf);
@@ -562,13 +570,13 @@ void renderer_texture_quad(struct renderer *r,
    struct pipe_buffer *buf;
    VGfloat s0, t0, s1, t1;
 
-   assert(tex->width[0] != 0);
-   assert(tex->height[0] != 0);
+   assert(tex->width0 != 0);
+   assert(tex->height0 != 0);
 
-   s0 = x1offset / tex->width[0];
-   s1 = x2offset / tex->width[0];
-   t0 = y1offset / tex->height[0];
-   t1 = y2offset / tex->height[0];
+   s0 = x1offset / tex->width0;
+   s1 = x2offset / tex->width0;
+   t0 = y1offset / tex->height0;
+   t1 = y2offset / tex->height0;
 
    cso_save_vertex_shader(r->cso);
    /* shaders */
index fd0831fab1f70ee27b598b975f4c03ee9d342c46..f620075d0bc95a34e3a78a6298494a151e25f8d5 100644 (file)
@@ -97,7 +97,7 @@ static INLINE struct tgsi_token *tokens_from_assembly(const char *txt, int num_t
 
 /*
 static const char max_shader_preamble[] =
-   "FRAG1.1\n"
+   "FRAG\n"
    "DCL IN[0], POSITION, LINEAR\n"
    "DCL IN[1], GENERIC[0], PERSPECTIVE\n"
    "DCL OUT[0], COLOR, CONSTANT\n"
@@ -168,7 +168,7 @@ create_preamble(char *txt,
    --end_temp;
    --end_sampler;
 
-   sprintf(txt, "FRAG1.1\n");
+   sprintf(txt, "FRAG\n");
 
    if (declare_input) {
       sprintf(txt + strlen(txt), "DCL IN[0], POSITION, LINEAR\n");
index 1b92d2b5c62cd50a7b62e174f6af2472f68598bf..68a52029db06ace6e7b24569a60e01a44bd74f3b 100644 (file)
@@ -476,7 +476,7 @@ static enum intersection_type line_intersect(const VGfloat *l1,
                                              const VGfloat *l2,
                                              float *intersection_point)
 {
-   VGfloat isect[2];
+   VGfloat isect[2] = { 0 };
    enum intersection_type type;
    VGboolean dx_zero, ldx_zero;
 
@@ -649,7 +649,7 @@ static void create_joins(struct stroker *stroker,
       VGfloat prev_line[] = {stroker->back2_x, stroker->back2_y,
                              stroker->back1_x, stroker->back1_y};
 
-      VGfloat isect[2];
+      VGfloat isect[2] = { 0 };
       enum intersection_type type = line_intersect(prev_line, next_line, isect);
 
       if (join == SquareJoin) {
index e0ff02f3a997565ec66f987df24321027a2945e2..00d23f5c2277c4c0605d52511dfb2e2d58919e5e 100644 (file)
@@ -231,6 +231,8 @@ static void update_clip_state(struct vg_context *ctx)
    if (state->scissoring) {
       struct pipe_blend_state *blend = &ctx->state.g3d.blend;
       struct pipe_framebuffer_state *fb = &ctx->state.g3d.fb;
+      int i;
+
       dsa->depth.writemask = 1;/*glDepthMask(TRUE);*/
       dsa->depth.func = PIPE_FUNC_ALWAYS;
       dsa->depth.enabled = 1;
@@ -254,7 +256,7 @@ static void update_clip_state(struct vg_context *ctx)
       cso_set_blend(ctx->cso_context, blend);
 
       /* enable scissoring */
-      for (int i = 0; i < state->scissor_rects_num; ++i) {
+      for (i = 0; i < state->scissor_rects_num; ++i) {
          const float x      = state->scissor_rects[i * 4 + 0].f;
          const float y      = state->scissor_rects[i * 4 + 1].f;
          const float width  = state->scissor_rects[i * 4 + 2].f;
index 56cc60aebe1889eabd775869b44291a92932565a..e5039132758c8893d7b0089d8336ca8ee73245fd 100644 (file)
 #include "pipe/p_context.h"
 #include "pipe/p_inlines.h"
 #include "pipe/p_screen.h"
+#include "util/u_format.h"
 #include "util/u_memory.h"
 #include "util/u_math.h"
+#include "util/u_rect.h"
 
 static struct pipe_texture *
 create_texture(struct pipe_context *pipe, enum pipe_format format,
@@ -50,13 +52,12 @@ create_texture(struct pipe_context *pipe, enum pipe_format format,
    }
 
    templ.target = PIPE_TEXTURE_2D;
-   pf_get_block(templ.format, &templ.block);
-   templ.width[0] = width;
-   templ.height[0] = height;
-   templ.depth[0] = 1;
+   templ.width0 = width;
+   templ.height0 = height;
+   templ.depth0 = 1;
    templ.last_level = 0;
 
-   if (pf_get_component_bits(format, PIPE_FORMAT_COMP_S)) {
+   if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 1)) {
       templ.tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL;
    } else {
       templ.tex_usage = (PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
@@ -235,13 +236,23 @@ static void setup_new_alpha_mask(struct vg_context *ctx,
          old_texture,
          0, 0, 0,
          PIPE_BUFFER_USAGE_GPU_READ);
-      pipe->surface_copy(pipe,
-                         surface,
-                         0, 0,
-                         old_surface,
-                         0, 0,
-                         MIN2(old_surface->width, width),
-                         MIN2(old_surface->height, height));
+      if (pipe->surface_copy) {
+         pipe->surface_copy(pipe,
+                            surface,
+                            0, 0,
+                            old_surface,
+                            0, 0,
+                            MIN2(old_surface->width, width),
+                            MIN2(old_surface->height, height));
+      } else {
+         util_surface_copy(pipe, FALSE,
+                           surface,
+                           0, 0,
+                           old_surface,
+                           0, 0,
+                           MIN2(old_surface->width, width),
+                           MIN2(old_surface->height, height));
+      }
       if (surface)
          pipe_surface_reference(&surface, NULL);
       if (old_surface)
index 00e07647062aa15aa978fe8f09d7938dd335180f..03575ca3ddd56da66a3b1847071f69e9ae55e190 100644 (file)
@@ -474,6 +474,7 @@ void _vega_unpack_float_span_rgba(struct vg_context *ctx,
                                   VGfloat rgba[][4])
 {
    VGint i;
+   union util_color uc;
 
    switch (dataFormat) {
    case VG_sRGBX_8888: {
@@ -486,8 +487,11 @@ void _vega_unpack_float_span_rgba(struct vg_context *ctx,
          b = (*src >>  8) & 0xff;
          a = 0xff;
 
-         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT,
-                            rgba[i]);
+         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT, &uc);
+         rgba[i][0] = uc.f[0];
+         rgba[i][1] = uc.f[1];
+         rgba[i][2] = uc.f[2];
+         rgba[i][3] = uc.f[3];
          ++src;
       }
    }
@@ -502,8 +506,11 @@ void _vega_unpack_float_span_rgba(struct vg_context *ctx,
          b = (*src >>  8) & 0xff;
          a = (*src >>  0) & 0xff;
 
-         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT,
-                            rgba[i]);
+         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT, &uc);
+         rgba[i][0] = uc.f[0];
+         rgba[i][1] = uc.f[1];
+         rgba[i][2] = uc.f[2];
+         rgba[i][3] = uc.f[3];
          ++src;
       }
       return;
@@ -519,8 +526,11 @@ void _vega_unpack_float_span_rgba(struct vg_context *ctx,
          b = (*src >>  8) & 0xff;
          a = (*src >>  0) & 0xff;
 
-         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT,
-                            rgba[i]);
+         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT, &uc);
+         rgba[i][0] = uc.f[0];
+         rgba[i][1] = uc.f[1];
+         rgba[i][2] = uc.f[2];
+         rgba[i][3] = uc.f[3];
          ++src;
       }
       return;
@@ -536,8 +546,11 @@ void _vega_unpack_float_span_rgba(struct vg_context *ctx,
          clr[2] = ((*src >>  0) & 31)/31.;
          clr[3] = 1.f;
 
-         util_pack_color(clr, PIPE_FORMAT_R32G32B32A32_FLOAT,
-                         rgba[i]);
+         util_pack_color(clr, PIPE_FORMAT_R32G32B32A32_FLOAT, &uc);
+         rgba[i][0] = uc.f[0];
+         rgba[i][1] = uc.f[1];
+         rgba[i][2] = uc.f[2];
+         rgba[i][3] = uc.f[3];
          ++src;
       }
    }
@@ -552,8 +565,11 @@ void _vega_unpack_float_span_rgba(struct vg_context *ctx,
          clr[2] = ((*src >>  1) & 31)/31.;
          clr[3] = ((*src >>  0) & 1)/1.;
 
-         util_pack_color(clr, PIPE_FORMAT_R32G32B32A32_FLOAT,
-                         rgba[i]);
+         util_pack_color(clr, PIPE_FORMAT_R32G32B32A32_FLOAT, &uc);
+         rgba[i][0] = uc.f[0];
+         rgba[i][1] = uc.f[1];
+         rgba[i][2] = uc.f[2];
+         rgba[i][3] = uc.f[3];
          ++src;
       }
    }
@@ -568,8 +584,11 @@ void _vega_unpack_float_span_rgba(struct vg_context *ctx,
          clr[2] = ((*src >>  4) & 15)/15.;
          clr[3] = ((*src >>  0) & 15)/15.;
 
-         util_pack_color(clr, PIPE_FORMAT_R32G32B32A32_FLOAT,
-                         rgba[i]);
+         util_pack_color(clr, PIPE_FORMAT_R32G32B32A32_FLOAT, &uc);
+         rgba[i][0] = uc.f[0];
+         rgba[i][1] = uc.f[1];
+         rgba[i][2] = uc.f[2];
+         rgba[i][3] = uc.f[3];
          ++src;
       }
    }
@@ -578,8 +597,11 @@ void _vega_unpack_float_span_rgba(struct vg_context *ctx,
       VGubyte *src = (VGubyte *)data;
       src += offset;
       for (i = 0; i < n; ++i) {
-         util_pack_color_ub(0xff, 0xff, 0xff, *src, PIPE_FORMAT_R32G32B32A32_FLOAT,
-                         rgba[i]);
+         util_pack_color_ub(0xff, 0xff, 0xff, *src, PIPE_FORMAT_R32G32B32A32_FLOAT, &uc);
+         rgba[i][0] = uc.f[0];
+         rgba[i][1] = uc.f[1];
+         rgba[i][2] = uc.f[2];
+         rgba[i][3] = uc.f[3];
          ++src;
       }
    }
@@ -594,8 +616,11 @@ void _vega_unpack_float_span_rgba(struct vg_context *ctx,
          b = (*src >>  8) & 0xff;
          a = 0xff;
 
-         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT,
-                            rgba[i]);
+         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT, &uc);
+         rgba[i][0] = uc.f[0];
+         rgba[i][1] = uc.f[1];
+         rgba[i][2] = uc.f[2];
+         rgba[i][3] = uc.f[3];
          ++src;
       }
    }
@@ -610,8 +635,11 @@ void _vega_unpack_float_span_rgba(struct vg_context *ctx,
          b = (*src >>  8) & 0xff;
          a = (*src >>  0) & 0xff;
 
-         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT,
-                            rgba[i]);
+         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT, &uc);
+         rgba[i][0] = uc.f[0];
+         rgba[i][1] = uc.f[1];
+         rgba[i][2] = uc.f[2];
+         rgba[i][3] = uc.f[3];
          ++src;
       }
       return;
@@ -627,8 +655,11 @@ void _vega_unpack_float_span_rgba(struct vg_context *ctx,
          b = (*src >>  8) & 0xff;
          a = (*src >>  0) & 0xff;
 
-         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT,
-                            rgba[i]);
+         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT, &uc);
+         rgba[i][0] = uc.f[0];
+         rgba[i][1] = uc.f[1];
+         rgba[i][2] = uc.f[2];
+         rgba[i][3] = uc.f[3];
          ++src;
       }
       return;
@@ -638,8 +669,11 @@ void _vega_unpack_float_span_rgba(struct vg_context *ctx,
       VGubyte *src = (VGubyte *)data;
       src += offset;
       for (i = 0; i < n; ++i) {
-         util_pack_color_ub(0xff, 0xff, 0xff, *src, PIPE_FORMAT_R32G32B32A32_FLOAT,
-                         rgba[i]);
+         util_pack_color_ub(0xff, 0xff, 0xff, *src, PIPE_FORMAT_R32G32B32A32_FLOAT, &uc);
+         rgba[i][0] = uc.f[0];
+         rgba[i][1] = uc.f[1];
+         rgba[i][2] = uc.f[2];
+         rgba[i][3] = uc.f[3];
          ++src;
       }
    }
@@ -648,8 +682,11 @@ void _vega_unpack_float_span_rgba(struct vg_context *ctx,
       VGubyte *src = (VGubyte *)data;
       src += offset;
       for (i = 0; i < n; ++i) {
-         util_pack_color_ub(0xff, 0xff, 0xff, *src, PIPE_FORMAT_R32G32B32A32_FLOAT,
-                            rgba[i]);
+         util_pack_color_ub(0xff, 0xff, 0xff, *src, PIPE_FORMAT_R32G32B32A32_FLOAT, &uc);
+         rgba[i][0] = uc.f[0];
+         rgba[i][1] = uc.f[1];
+         rgba[i][2] = uc.f[2];
+         rgba[i][3] = uc.f[3];
          ++src;
       }
    }
@@ -667,8 +704,11 @@ void _vega_unpack_float_span_rgba(struct vg_context *ctx,
             clr[2] = clr[0];
             clr[3] = 1.f;
 
-            util_pack_color(clr, PIPE_FORMAT_R32G32B32A32_FLOAT,
-                            rgba[i+j]);
+            util_pack_color(clr, PIPE_FORMAT_R32G32B32A32_FLOAT, &uc);
+            rgba[i+j][0] = uc.f[0];
+            rgba[i+j][1] = uc.f[1];
+            rgba[i+j][2] = uc.f[2];
+            rgba[i+j][3] = uc.f[3];
          }
          ++src;
       }
@@ -688,8 +728,11 @@ void _vega_unpack_float_span_rgba(struct vg_context *ctx,
             clr[2] = 0.f;
             clr[3] = (((*src) & (1<<shift)) >> shift);
 
-            util_pack_color(clr, PIPE_FORMAT_R32G32B32A32_FLOAT,
-                            rgba[i+j]);
+            util_pack_color(clr, PIPE_FORMAT_R32G32B32A32_FLOAT, &uc);
+            rgba[i+j][0] = uc.f[0];
+            rgba[i+j][1] = uc.f[1];
+            rgba[i+j][2] = uc.f[2];
+            rgba[i+j][3] = uc.f[3];
          }
          ++src;
       }
@@ -715,8 +758,11 @@ void _vega_unpack_float_span_rgba(struct vg_context *ctx,
             clr[2] = 0.f;
             clr[3] = ((*src) & (bitter)) >> shift;
 
-            util_pack_color(clr, PIPE_FORMAT_R32G32B32A32_FLOAT,
-                            rgba[i +j]);
+            util_pack_color(clr, PIPE_FORMAT_R32G32B32A32_FLOAT, &uc);
+            rgba[i+j][0] = uc.f[0];
+            rgba[i+j][1] = uc.f[1];
+            rgba[i+j][2] = uc.f[2];
+            rgba[i+j][3] = uc.f[3];
          }
          ++src;
       }
@@ -735,8 +781,11 @@ void _vega_unpack_float_span_rgba(struct vg_context *ctx,
          g = (*src >>  8) & 0xff;
          b = (*src >>  0) & 0xff;
 
-         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT,
-                            rgba[i]);
+         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT, &uc);
+         rgba[i][0] = uc.f[0];
+         rgba[i][1] = uc.f[1];
+         rgba[i][2] = uc.f[2];
+         rgba[i][3] = uc.f[3];
          ++src;
       }
       return;
@@ -752,8 +801,11 @@ void _vega_unpack_float_span_rgba(struct vg_context *ctx,
          g = (*src >>  8) & 0xff;
          b = (*src >>  0) & 0xff;
 
-         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT,
-                            rgba[i]);
+         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT, &uc);
+         rgba[i][0] = uc.f[0];
+         rgba[i][1] = uc.f[1];
+         rgba[i][2] = uc.f[2];
+         rgba[i][3] = uc.f[3];
          ++src;
       }
       return;
@@ -775,8 +827,11 @@ void _vega_unpack_float_span_rgba(struct vg_context *ctx,
          g = (*src >>  8) & 0xff;
          b = (*src >>  0) & 0xff;
 
-         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT,
-                            rgba[i]);
+         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT, &uc);
+         rgba[i][0] = uc.f[0];
+         rgba[i][1] = uc.f[1];
+         rgba[i][2] = uc.f[2];
+         rgba[i][3] = uc.f[3];
          ++src;
       }
       return;
@@ -792,8 +847,11 @@ void _vega_unpack_float_span_rgba(struct vg_context *ctx,
          g = (*src >>  8) & 0xff;
          b = (*src >>  0) & 0xff;
 
-         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT,
-                            rgba[i]);
+         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT, &uc);
+         rgba[i][0] = uc.f[0];
+         rgba[i][1] = uc.f[1];
+         rgba[i][2] = uc.f[2];
+         rgba[i][3] = uc.f[3];
          ++src;
       }
       return;
@@ -811,8 +869,11 @@ void _vega_unpack_float_span_rgba(struct vg_context *ctx,
          r = (*src >>  8) & 0xff;
          a = (*src >>  0) & 0xff;
 
-         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT,
-                            rgba[i]);
+         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT, &uc);
+         rgba[i][0] = uc.f[0];
+         rgba[i][1] = uc.f[1];
+         rgba[i][2] = uc.f[2];
+         rgba[i][3] = uc.f[3];
          ++src;
       }
       return;
@@ -828,8 +889,11 @@ void _vega_unpack_float_span_rgba(struct vg_context *ctx,
          r = (*src >>  8) & 0xff;
          a = (*src >>  0) & 0xff;
 
-         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT,
-                            rgba[i]);
+         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT, &uc);
+         rgba[i][0] = uc.f[0];
+         rgba[i][1] = uc.f[1];
+         rgba[i][2] = uc.f[2];
+         rgba[i][3] = uc.f[3];
          ++src;
       }
       return;
@@ -853,8 +917,11 @@ void _vega_unpack_float_span_rgba(struct vg_context *ctx,
          r = (*src >>  8) & 0xff;
          a = (*src >>  0) & 0xff;
 
-         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT,
-                            rgba[i]);
+         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT, &uc);
+         rgba[i][0] = uc.f[0];
+         rgba[i][1] = uc.f[1];
+         rgba[i][2] = uc.f[2];
+         rgba[i][3] = uc.f[3];
          ++src;
       }
       return;
@@ -870,8 +937,11 @@ void _vega_unpack_float_span_rgba(struct vg_context *ctx,
          r = (*src >>  8) & 0xff;
          a = (*src >>  0) & 0xff;
 
-         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT,
-                            rgba[i]);
+         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT, &uc);
+         rgba[i][0] = uc.f[0];
+         rgba[i][1] = uc.f[1];
+         rgba[i][2] = uc.f[2];
+         rgba[i][3] = uc.f[3];
          ++src;
       }
       return;
@@ -889,8 +959,11 @@ void _vega_unpack_float_span_rgba(struct vg_context *ctx,
          g = (*src >>  8) & 0xff;
          r = (*src >>  0) & 0xff;
 
-         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT,
-                            rgba[i]);
+         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT, &uc);
+         rgba[i][0] = uc.f[0];
+         rgba[i][1] = uc.f[1];
+         rgba[i][2] = uc.f[2];
+         rgba[i][3] = uc.f[3];
          ++src;
       }
       return;
@@ -906,8 +979,11 @@ void _vega_unpack_float_span_rgba(struct vg_context *ctx,
          g = (*src >>  8) & 0xff;
          r = (*src >>  0) & 0xff;
 
-         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT,
-                            rgba[i]);
+         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT, &uc);
+         rgba[i][0] = uc.f[0];
+         rgba[i][1] = uc.f[1];
+         rgba[i][2] = uc.f[2];
+         rgba[i][3] = uc.f[3];
          ++src;
       }
       return;
@@ -929,8 +1005,11 @@ void _vega_unpack_float_span_rgba(struct vg_context *ctx,
          g = (*src >>  8) & 0xff;
          r = (*src >>  0) & 0xff;
 
-         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT,
-                            rgba[i]);
+         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT, &uc);
+         rgba[i][0] = uc.f[0];
+         rgba[i][1] = uc.f[1];
+         rgba[i][2] = uc.f[2];
+         rgba[i][3] = uc.f[3];
          ++src;
       }
       return;
@@ -946,8 +1025,11 @@ void _vega_unpack_float_span_rgba(struct vg_context *ctx,
          g = (*src >>  8) & 0xff;
          r = (*src >>  0) & 0xff;
 
-         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT,
-                            rgba[i]);
+         util_pack_color_ub(r, g, b, a, PIPE_FORMAT_R32G32B32A32_FLOAT, &uc);
+         rgba[i][0] = uc.f[0];
+         rgba[i][1] = uc.f[1];
+         rgba[i][2] = uc.f[2];
+         rgba[i][3] = uc.f[3];
          ++src;
       }
       return;
index b05944a33b3e56c56c7468ff5c855c2226f324a1..352c087475eb89841d7fabcd658c087e973601ab 100644 (file)
@@ -11,10 +11,11 @@ if env['platform'] in ['windows']:
        '.',
     ])
      
-    env.Append(CPPDEFINES = [
+    env.AppendUnique(CPPDEFINES = [
         '_GDI32_', # prevent wgl* being declared __declspec(dllimport)
         'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers 
         'WIN32_THREADS', # use Win32 thread API
+        'WIN32_LEAN_AND_MEAN', # http://msdn2.microsoft.com/en-us/library/6dwk3a1z.aspx
     ])
      
     sources = [
index 985b8f0456a9f6f36cd631d72c3e46d665836b31..7785aba46775b9c910503dc4ac8dd64f01dd84d3 100644 (file)
@@ -72,19 +72,7 @@ stw_flush_frontbuffer(struct pipe_screen *screen,
       return;
    }
 
-#if DEBUG
-   {
-      /* ensure that a random surface was not passed to us */
-      struct pipe_surface *surface2;
-
-      if(!st_get_framebuffer_surface( fb->stfb, ST_SURFACE_FRONT_LEFT, &surface2 ))
-         assert(0);
-      else
-         assert(surface2 == surface);
-   }
-#endif
-
-   stw_framebuffer_present_locked(hdc, fb, ST_SURFACE_FRONT_LEFT);
+   stw_framebuffer_present_locked(hdc, fb, surface);
 }
 
 
index 8a3e11b6b4075cd71b0765c537a81c0164e41902..129a6298a7771a97b4086faf09740f007731ea1a 100644 (file)
@@ -30,6 +30,7 @@
 #include "main/context.h"
 #include "pipe/p_format.h"
 #include "pipe/p_screen.h"
+#include "util/u_format.h"
 #include "state_tracker/st_context.h"
 #include "state_tracker/st_public.h"
 
@@ -267,15 +268,13 @@ stw_framebuffer_allocate(
       enum pipe_format colorFormat, depthFormat, stencilFormat;
 
       colorFormat = pfi->color_format;
-      
-      assert(pf_layout( pfi->depth_stencil_format ) == PIPE_FORMAT_LAYOUT_RGBAZS );
-   
-      if(pf_get_component_bits( pfi->depth_stencil_format, PIPE_FORMAT_COMP_Z ))
+
+      if(util_format_get_component_bits(pfi->depth_stencil_format, UTIL_FORMAT_COLORSPACE_ZS, 0))
          depthFormat = pfi->depth_stencil_format;
       else
          depthFormat = PIPE_FORMAT_NONE;
    
-      if(pf_get_component_bits( pfi->depth_stencil_format, PIPE_FORMAT_COMP_S ))
+      if(util_format_get_component_bits(pfi->depth_stencil_format, UTIL_FORMAT_COLORSPACE_ZS, 1))
          stencilFormat = pfi->depth_stencil_format;
       else
          stencilFormat = PIPE_FORMAT_NONE;
@@ -475,8 +474,6 @@ DrvPresentBuffers(HDC hdc, PGLPRESENTBUFFERSDATA data)
    struct stw_framebuffer *fb;
    struct pipe_screen *screen;
    struct pipe_surface *surface;
-   unsigned surface_index;
-   BOOL ret = FALSE;
 
    fb = stw_framebuffer_from_hdc( hdc );
    if (fb == NULL)
@@ -484,9 +481,7 @@ DrvPresentBuffers(HDC hdc, PGLPRESENTBUFFERSDATA data)
 
    screen = stw_dev->screen;
 
-   surface_index = (unsigned)(uintptr_t)data->pPrivateData;
-   if(!st_get_framebuffer_surface( fb->stfb, surface_index, &surface ))
-      goto fail;
+   surface = (struct pipe_surface *)data->pPrivateData;
 
 #ifdef DEBUG
    if(stw_dev->trace_running) {
@@ -520,15 +515,11 @@ DrvPresentBuffers(HDC hdc, PGLPRESENTBUFFERSDATA data)
       stw_dev->stw_winsys->present( screen, surface, hdc );
    }
 
-   ret = TRUE;
-
-fail:
-
    stw_framebuffer_update(fb);
 
    stw_framebuffer_release(fb);
 
-   return ret;
+   return TRUE;
 }
 
 
@@ -540,7 +531,7 @@ fail:
 BOOL
 stw_framebuffer_present_locked(HDC hdc,
                                struct stw_framebuffer *fb,
-                               unsigned surface_index)
+                               struct pipe_surface *surface)
 {
    if(stw_dev->callbacks.wglCbPresentBuffers &&
       stw_dev->stw_winsys->compose) {
@@ -551,7 +542,7 @@ stw_framebuffer_present_locked(HDC hdc,
       data.magic2 = 0;
       data.AdapterLuid = stw_dev->AdapterLuid;
       data.rect = fb->client_rect;
-      data.pPrivateData = (void *)(uintptr_t)surface_index;
+      data.pPrivateData = (void *)surface;
 
       stw_framebuffer_release(fb);
 
@@ -559,13 +550,6 @@ stw_framebuffer_present_locked(HDC hdc,
    }
    else {
       struct pipe_screen *screen = stw_dev->screen;
-      struct pipe_surface *surface;
-
-      if(!st_get_framebuffer_surface( fb->stfb, surface_index, &surface )) {
-         /* FIXME: this shouldn't happen, but does on glean */
-         stw_framebuffer_release(fb);
-         return FALSE;
-      }
 
 #ifdef DEBUG
       if(stw_dev->trace_running) {
@@ -590,6 +574,7 @@ DrvSwapBuffers(
    HDC hdc )
 {
    struct stw_framebuffer *fb;
+   struct pipe_surface *surface = NULL;
 
    fb = stw_framebuffer_from_hdc( hdc );
    if (fb == NULL)
@@ -600,12 +585,9 @@ DrvSwapBuffers(
       return TRUE;
    }
 
-   /* If we're swapping the buffer associated with the current context
-    * we have to flush any pending rendering commands first.
-    */
-   st_notify_swapbuffers( fb->stfb );
+   st_swapbuffers(fb->stfb, &surface, NULL);
 
-   return stw_framebuffer_present_locked(hdc, fb, ST_SURFACE_BACK_LEFT);
+   return stw_framebuffer_present_locked(hdc, fb, surface);
 }
 
 
index 5afbe749086c82ce6f39ab75aa21b33f9e5c6df9..b80d168a7cead3382107047c954733f36691d800 100644 (file)
@@ -34,6 +34,7 @@
 
 #include "pipe/p_thread.h"
 
+struct pipe_surface;
 struct stw_pixelformat_info;
 
 /**
@@ -140,7 +141,7 @@ stw_framebuffer_allocate(
 BOOL
 stw_framebuffer_present_locked(HDC hdc,
                                struct stw_framebuffer *fb,
-                               unsigned surface_index);
+                               struct pipe_surface *surface);
 
 void
 stw_framebuffer_update(
index 7abe5d9f7fa19a9cadaefc1dcccc31f6d295198b..54cc36141290385106d9d9d52e9b90ef641d6d57 100644 (file)
@@ -32,6 +32,7 @@
 #include "pipe/p_defines.h"
 #include "pipe/p_screen.h"
 
+#include "util/u_format.h"
 #include "util/u_debug.h"
 
 #include "stw_icd.h"
@@ -132,14 +133,12 @@ stw_pixelformat_add(
    if(stw_dev->pixelformat_extended_count >= STW_MAX_PIXELFORMATS)
       return;
 
-   assert(pf_layout( color->format ) == PIPE_FORMAT_LAYOUT_RGBAZS );
-   assert(pf_get_component_bits( color->format, PIPE_FORMAT_COMP_R ) == color->bits.red );
-   assert(pf_get_component_bits( color->format, PIPE_FORMAT_COMP_G ) == color->bits.green );
-   assert(pf_get_component_bits( color->format, PIPE_FORMAT_COMP_B ) == color->bits.blue );
-   assert(pf_get_component_bits( color->format, PIPE_FORMAT_COMP_A ) == color->bits.alpha );
-   assert(pf_layout( depth->format ) == PIPE_FORMAT_LAYOUT_RGBAZS );
-   assert(pf_get_component_bits( depth->format, PIPE_FORMAT_COMP_Z ) == depth->bits.depth );
-   assert(pf_get_component_bits( depth->format, PIPE_FORMAT_COMP_S ) == depth->bits.stencil );
+   assert(util_format_get_component_bits(color->format, UTIL_FORMAT_COLORSPACE_RGB, 0) == color->bits.red);
+   assert(util_format_get_component_bits(color->format, UTIL_FORMAT_COLORSPACE_RGB, 1) == color->bits.green);
+   assert(util_format_get_component_bits(color->format, UTIL_FORMAT_COLORSPACE_RGB, 2) == color->bits.blue);
+   assert(util_format_get_component_bits(color->format, UTIL_FORMAT_COLORSPACE_RGB, 3) == color->bits.alpha);
+   assert(util_format_get_component_bits(depth->format, UTIL_FORMAT_COLORSPACE_ZS, 0) == depth->bits.depth);
+   assert(util_format_get_component_bits(depth->format, UTIL_FORMAT_COLORSPACE_ZS, 1) == depth->bits.stencil);
    
    pfi = &stw_dev->pixelformats[stw_dev->pixelformat_extended_count];
    
index 1ead47d6e637c35c5fe50c23cfa63afc14ca94ce..1de6e906d0df1e7277b1282b36ebd711a822eb90 100644 (file)
@@ -73,7 +73,7 @@ struct stw_winsys
                           HANDLE hSharedSurface);
 
    /**
-    * Open a shared surface (optional).
+    * Close a shared surface (optional).
     */
    void
    (*shared_surface_close)(struct pipe_screen *screen,
index 27a1990724d4cfa220091a2afa3a56608ebfefe7..cb2c3aea410806f01c59cf72b68bfacc1e935848 100644 (file)
@@ -5,6 +5,11 @@ LIBNAME = xorgtracker
 
 LIBRARY_INCLUDES = \
        -DHAVE_CONFIG_H \
+       $(shell pkg-config xextproto --atleast-version=7.0.99.1 \
+                               && echo "-DHAVE_XEXTPROTO_71") \
+       $(shell pkg-config libkms --atleast-version=1.0 \
+                               && echo "-DHAVE_LIBKMS") \
+       $(shell pkg-config libkms --silence-errors --cflags-only-I) \
        $(shell pkg-config --cflags-only-I pixman-1 xorg-server libdrm xproto) \
        -I$(TOP)/src/gallium/include \
        -I$(TOP)/src/gallium/auxiliary \
index 65f55ea378abf715b6e1090d8f9db8c67906486e..5d0b6613ac75e02f3180f76a5004416a105adf2f 100644 (file)
@@ -13,6 +13,11 @@ if 'xorg' in env['statetrackers']:
 
     env.ParseConfig('pkg-config --cflags --libs xorg-server')
 
+    conf = env.Configure()
+
+    if conf.CheckHeader('X11/extensions/dpmsconst.h'):
+        env.Append(CPPDEFINES = [('HAVE_XEXTPROTO_71', '1')])
+
     st_xorg = env.ConvenienceLibrary(
        target = 'st_xorg',
        source = [ 'xorg_composite.c',
@@ -22,6 +27,8 @@ if 'xorg' in env['statetrackers']:
                'xorg_exa.c',
                'xorg_exa_tgsi.c',
                'xorg_output.c',
+               'xorg_renderer.c',
+               'xorg_xv.c',
                ]
     )
     Export('st_xorg')
index 7037d17e43f3fa9b6eb7c3c1da6ec417b5ff05fb..1c248a629e681e24625a98125bb6d0323492d761 100644 (file)
@@ -1,5 +1,6 @@
 #include "xorg_composite.h"
 
+#include "xorg_renderer.h"
 #include "xorg_exa_tgsi.h"
 
 #include "cso_cache/cso_context.h"
@@ -8,37 +9,47 @@
 
 #include "pipe/p_inlines.h"
 
+/*XXX also in Xrender.h but the including it here breaks compilition */
+#define XFixedToDouble(f)    (((double) (f)) / 65536.)
+
 struct xorg_composite_blend {
-   int op:8;
+   int op : 8;
 
-   unsigned rgb_src_factor:5;    /**< PIPE_BLENDFACTOR_x */
-   unsigned alpha_src_factor:5;  /**< PIPE_BLENDFACTOR_x */
+   unsigned alpha_dst : 4;
+   unsigned alpha_src : 4;
 
-   unsigned rgb_dst_factor:5;    /**< PIPE_BLENDFACTOR_x */
-   unsigned alpha_dst_factor:5;  /**< PIPE_BLENDFACTOR_x */
+   unsigned rgb_src : 8;    /**< PIPE_BLENDFACTOR_x */
+   unsigned rgb_dst : 8;    /**< PIPE_BLENDFACTOR_x */
 };
 
 #define BLEND_OP_OVER 3
 static const struct xorg_composite_blend xorg_blends[] = {
    { PictOpClear,
-     PIPE_BLENDFACTOR_CONST_COLOR, PIPE_BLENDFACTOR_CONST_ALPHA,
-     PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_ZERO },
-
+     0, 0, PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_ZERO},
    { PictOpSrc,
-     PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_ONE,
-     PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_ZERO },
-
+     0, 0, PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_ZERO},
    { PictOpDst,
-     PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_ZERO,
-     PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_ONE },
-
+     0, 0, PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_ONE},
    { PictOpOver,
-     PIPE_BLENDFACTOR_SRC_ALPHA, PIPE_BLENDFACTOR_ONE,
-     PIPE_BLENDFACTOR_INV_SRC_ALPHA, PIPE_BLENDFACTOR_INV_SRC_ALPHA },
-
+     0, 1, PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_INV_SRC_ALPHA},
    { PictOpOverReverse,
-     PIPE_BLENDFACTOR_SRC_ALPHA, PIPE_BLENDFACTOR_ONE,
-     PIPE_BLENDFACTOR_INV_SRC_ALPHA, PIPE_BLENDFACTOR_INV_SRC_ALPHA },
+     1, 0, PIPE_BLENDFACTOR_INV_DST_ALPHA, PIPE_BLENDFACTOR_ONE},
+   { PictOpIn,
+     1, 0, PIPE_BLENDFACTOR_DST_ALPHA, PIPE_BLENDFACTOR_ZERO},
+   { PictOpInReverse,
+     0, 1, PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_SRC_ALPHA},
+   { PictOpOut,
+     1, 0, PIPE_BLENDFACTOR_INV_DST_ALPHA, PIPE_BLENDFACTOR_ZERO},
+   { PictOpOutReverse,
+     0, 1, PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_INV_SRC_ALPHA},
+   { PictOpAtop,
+     1, 1, PIPE_BLENDFACTOR_DST_ALPHA, PIPE_BLENDFACTOR_INV_SRC_ALPHA},
+   { PictOpAtopReverse,
+     1, 1, PIPE_BLENDFACTOR_INV_DST_ALPHA, PIPE_BLENDFACTOR_SRC_ALPHA},
+   { PictOpXor,
+     1, 1, PIPE_BLENDFACTOR_INV_DST_ALPHA, PIPE_BLENDFACTOR_INV_SRC_ALPHA},
+   { PictOpAdd,
+     0, 0, PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_ONE},
 };
 
 
@@ -57,40 +68,49 @@ pixel_to_float4(Pixel pixel, float *color)
    color[3] = ((float)a) / 255.;
 }
 
-struct acceleration_info {
-   int op : 16;
-   int with_mask : 1;
-   int component_alpha : 1;
-};
-static const struct acceleration_info accelerated_ops[] = {
-   {PictOpClear,       1, 0},
-   {PictOpSrc,         1, 0},
-   {PictOpDst,         1, 0},
-   {PictOpOver,        1, 0},
-   {PictOpOverReverse, 1, 0},
-   {PictOpIn,          1, 0},
-   {PictOpInReverse,   1, 0},
-   {PictOpOut,         1, 0},
-   {PictOpOutReverse,  1, 0},
-   {PictOpAtop,        1, 0},
-   {PictOpAtopReverse, 1, 0},
-   {PictOpXor,         1, 0},
-   {PictOpAdd,         1, 0},
-   {PictOpSaturate,    1, 0},
-};
-
-static struct xorg_composite_blend
-blend_for_op(int op)
+static boolean
+blend_for_op(struct xorg_composite_blend *blend,
+             int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
+             PicturePtr pDstPicture)
 {
    const int num_blends =
       sizeof(xorg_blends)/sizeof(struct xorg_composite_blend);
    int i;
+   boolean supported = FALSE;
+
+   /* our default in case something goes wrong */
+   *blend = xorg_blends[BLEND_OP_OVER];
 
    for (i = 0; i < num_blends; ++i) {
-      if (xorg_blends[i].op == op)
-         return xorg_blends[i];
+      if (xorg_blends[i].op == op) {
+         *blend = xorg_blends[i];
+         supported = TRUE;
+      }
+   }
+
+   /* If there's no dst alpha channel, adjust the blend op so that we'll treat
+    * it as always 1. */
+   if (pDstPicture &&
+       PICT_FORMAT_A(pDstPicture->format) == 0 && blend->alpha_dst) {
+      if (blend->rgb_src == PIPE_BLENDFACTOR_DST_ALPHA)
+         blend->rgb_src = PIPE_BLENDFACTOR_ONE;
+      else if (blend->rgb_src == PIPE_BLENDFACTOR_INV_DST_ALPHA)
+         blend->rgb_src = PIPE_BLENDFACTOR_ZERO;
    }
-   return xorg_blends[BLEND_OP_OVER];
+
+   /* If the source alpha is being used, then we should only be in a case where
+    * the source blend factor is 0, and the source blend value is the mask
+    * channels multiplied by the source picture's alpha. */
+   if (pMaskPicture && pMaskPicture->componentAlpha &&
+       PICT_FORMAT_RGB(pMaskPicture->format) && blend->alpha_src) {
+      if (blend->rgb_dst == PIPE_BLENDFACTOR_SRC_ALPHA) {
+         blend->rgb_dst = PIPE_BLENDFACTOR_SRC_COLOR;
+      } else if (blend->rgb_dst == PIPE_BLENDFACTOR_INV_SRC_ALPHA) {
+         blend->rgb_dst = PIPE_BLENDFACTOR_INV_SRC_COLOR;
+      }
+   }
+
+   return supported;
 }
 
 static INLINE int
@@ -98,7 +118,7 @@ render_repeat_to_gallium(int mode)
 {
    switch(mode) {
    case RepeatNone:
-      return PIPE_TEX_WRAP_CLAMP;
+      return PIPE_TEX_WRAP_CLAMP_TO_BORDER;
    case RepeatNormal:
       return PIPE_TEX_WRAP_REPEAT;
    case RepeatReflect:
@@ -111,171 +131,44 @@ render_repeat_to_gallium(int mode)
    return PIPE_TEX_WRAP_REPEAT;
 }
 
+static INLINE boolean
+render_filter_to_gallium(int xrender_filter, int *out_filter)
+{
+
+   switch (xrender_filter) {
+   case PictFilterNearest:
+      *out_filter = PIPE_TEX_FILTER_NEAREST;
+      break;
+   case PictFilterBilinear:
+      *out_filter = PIPE_TEX_FILTER_LINEAR;
+      break;
+   case PictFilterFast:
+      *out_filter = PIPE_TEX_FILTER_NEAREST;
+      break;
+   case PictFilterGood:
+      *out_filter = PIPE_TEX_FILTER_LINEAR;
+      break;
+   case PictFilterBest:
+      *out_filter = PIPE_TEX_FILTER_LINEAR;
+      break;
+   case PictFilterConvolution:
+      *out_filter = PIPE_TEX_FILTER_NEAREST;
+      return FALSE;
+   default:
+      debug_printf("Unknown xrender filter\n");
+      *out_filter = PIPE_TEX_FILTER_NEAREST;
+      return FALSE;
+   }
 
-static INLINE void
-setup_vertex0(float vertex[2][4], float x, float y,
-              float color[4])
-{
-   vertex[0][0] = x;
-   vertex[0][1] = y;
-   vertex[0][2] = 0.f; /*z*/
-   vertex[0][3] = 1.f; /*w*/
-
-   vertex[1][0] = color[0]; /*r*/
-   vertex[1][1] = color[1]; /*g*/
-   vertex[1][2] = color[2]; /*b*/
-   vertex[1][3] = color[3]; /*a*/
-}
-
-static struct pipe_buffer *
-setup_vertex_data0(struct exa_context *ctx,
-                   int srcX, int srcY, int maskX, int maskY,
-                   int dstX, int dstY, int width, int height)
-{
-   /* 1st vertex */
-   setup_vertex0(ctx->vertices2[0], dstX, dstY,
-                 ctx->solid_color);
-   /* 2nd vertex */
-   setup_vertex0(ctx->vertices2[1], dstX + width, dstY,
-                 ctx->solid_color);
-   /* 3rd vertex */
-   setup_vertex0(ctx->vertices2[2], dstX + width, dstY + height,
-                 ctx->solid_color);
-   /* 4th vertex */
-   setup_vertex0(ctx->vertices2[3], dstX, dstY + height,
-                 ctx->solid_color);
-
-   return pipe_user_buffer_create(ctx->pipe->screen,
-                                  ctx->vertices2,
-                                  sizeof(ctx->vertices2));
-}
-
-static INLINE void
-setup_vertex1(float vertex[2][4], float x, float y, float s, float t)
-{
-   vertex[0][0] = x;
-   vertex[0][1] = y;
-   vertex[0][2] = 0.f; /*z*/
-   vertex[0][3] = 1.f; /*w*/
-
-   vertex[1][0] = s;   /*s*/
-   vertex[1][1] = t;   /*t*/
-   vertex[1][2] = 0.f; /*r*/
-   vertex[1][3] = 1.f; /*q*/
-}
-
-static struct pipe_buffer *
-setup_vertex_data1(struct exa_context *ctx,
-                   int srcX, int srcY, int maskX, int maskY,
-                   int dstX, int dstY, int width, int height)
-{
-   float s0, t0, s1, t1;
-   struct pipe_texture *src = ctx->bound_textures[0];
-
-   s0 = srcX / src->width[0];
-   s1 = srcX + width / src->width[0];
-   t0 = srcY / src->height[0];
-   t1 = srcY + height / src->height[0];
-
-   /* 1st vertex */
-   setup_vertex1(ctx->vertices2[0], dstX, dstY,
-                 s0, t0);
-   /* 2nd vertex */
-   setup_vertex1(ctx->vertices2[1], dstX + width, dstY,
-                 s1, t0);
-   /* 3rd vertex */
-   setup_vertex1(ctx->vertices2[2], dstX + width, dstY + height,
-                 s1, t1);
-   /* 4th vertex */
-   setup_vertex1(ctx->vertices2[3], dstX, dstY + height,
-                 s0, t1);
-
-   return pipe_user_buffer_create(ctx->pipe->screen,
-                                  ctx->vertices2,
-                                  sizeof(ctx->vertices2));
-}
-
-static struct pipe_buffer *
-setup_vertex_data_tex(struct exa_context *ctx,
-                      float x0, float y0, float x1, float y1,
-                      float s0, float t0, float s1, float t1,
-                      float z)
-{
-   /* 1st vertex */
-   setup_vertex1(ctx->vertices2[0], x0, y0,
-                 s0, t0);
-   /* 2nd vertex */
-   setup_vertex1(ctx->vertices2[1], x1, y0,
-                 s1, t0);
-   /* 3rd vertex */
-   setup_vertex1(ctx->vertices2[2], x1, y1,
-                 s1, t1);
-   /* 4th vertex */
-   setup_vertex1(ctx->vertices2[3], x0, y1,
-                 s0, t1);
-
-   return pipe_user_buffer_create(ctx->pipe->screen,
-                                  ctx->vertices2,
-                                  sizeof(ctx->vertices2));
-}
-
-
-
-static INLINE void
-setup_vertex2(float vertex[3][4], float x, float y,
-              float s0, float t0, float s1, float t1)
-{
-   vertex[0][0] = x;
-   vertex[0][1] = y;
-   vertex[0][2] = 0.f; /*z*/
-   vertex[0][3] = 1.f; /*w*/
-
-   vertex[1][0] = s0;  /*s*/
-   vertex[1][1] = t0;  /*t*/
-   vertex[1][2] = 0.f; /*r*/
-   vertex[1][3] = 1.f; /*q*/
-
-   vertex[2][0] = s1;  /*s*/
-   vertex[2][1] = t1;  /*t*/
-   vertex[2][2] = 0.f; /*r*/
-   vertex[2][3] = 1.f; /*q*/
+   return TRUE;
 }
 
-static struct pipe_buffer *
-setup_vertex_data2(struct exa_context *ctx,
-                   int srcX, int srcY, int maskX, int maskY,
-                   int dstX, int dstY, int width, int height)
+static boolean is_filter_accelerated(PicturePtr pic)
 {
-   float st0[4], st1[4];
-   struct pipe_texture *src = ctx->bound_textures[0];
-   struct pipe_texture *mask = ctx->bound_textures[0];
-
-   st0[0] = srcX / src->width[0];
-   st0[1] = srcY / src->height[0];
-   st0[2] = srcX + width / src->width[0];
-   st0[3] = srcY + height / src->height[0];
-
-   st1[0] = maskX / mask->width[0];
-   st1[1] = maskY / mask->height[0];
-   st1[2] = maskX + width / mask->width[0];
-   st1[3] = maskY + height / mask->height[0];
-
-   /* 1st vertex */
-   setup_vertex2(ctx->vertices3[0], dstX, dstY,
-                 st0[0], st0[1], st1[0], st1[1]);
-   /* 2nd vertex */
-   setup_vertex2(ctx->vertices3[1], dstX + width, dstY,
-                 st0[2], st0[1], st1[2], st1[1]);
-   /* 3rd vertex */
-   setup_vertex2(ctx->vertices3[2], dstX + width, dstY + height,
-                 st0[2], st0[3], st1[2], st1[3]);
-   /* 4th vertex */
-   setup_vertex2(ctx->vertices3[3], dstX, dstY + height,
-                 st0[0], st0[3], st1[0], st1[3]);
-
-   return pipe_user_buffer_create(ctx->pipe->screen,
-                                  ctx->vertices3,
-                                  sizeof(ctx->vertices3));
+   int filter;
+   if (pic && !render_filter_to_gallium(pic->filter, &filter))
+       return FALSE;
+   return TRUE;
 }
 
 boolean xorg_composite_accelerated(int op,
@@ -283,137 +176,127 @@ boolean xorg_composite_accelerated(int op,
                                    PicturePtr pMaskPicture,
                                    PicturePtr pDstPicture)
 {
-   unsigned i;
-   unsigned accel_ops_count =
-      sizeof(accelerated_ops)/sizeof(struct acceleration_info);
+   ScreenPtr pScreen = pDstPicture->pDrawable->pScreen;
+   ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+   modesettingPtr ms = modesettingPTR(pScrn);
+   struct xorg_composite_blend blend;
+
+   if (!is_filter_accelerated(pSrcPicture) ||
+       !is_filter_accelerated(pMaskPicture)) {
+      XORG_FALLBACK("Unsupported Xrender filter");
+   }
 
    if (pSrcPicture->pSourcePict) {
-      /* Gradients not yet supported */
       if (pSrcPicture->pSourcePict->type != SourcePictTypeSolidFill)
-         return FALSE;
-
-      /* Solid source with mask not yet handled properly */
-      if (pMaskPicture)
-         return FALSE;
+         XORG_FALLBACK("Gradients not enabled (haven't been well tested)");
    }
 
-   for (i = 0; i < accel_ops_count; ++i) {
-      if (op == accelerated_ops[i].op) {
-         /* Check for unsupported component alpha */
-         if ((pSrcPicture->componentAlpha &&
-              !accelerated_ops[i].component_alpha) ||
-             (pMaskPicture &&
-              (!accelerated_ops[i].with_mask ||
-               (pMaskPicture->componentAlpha &&
-                !accelerated_ops[i].component_alpha))))
-            return FALSE;
-         return TRUE;
+   if (blend_for_op(&blend, op,
+                    pSrcPicture, pMaskPicture, pDstPicture)) {
+      /* Check for component alpha */
+      if (pMaskPicture && pMaskPicture->componentAlpha &&
+          PICT_FORMAT_RGB(pMaskPicture->format)) {
+         if (blend.alpha_src && blend.rgb_src != PIPE_BLENDFACTOR_ZERO) {
+            XORG_FALLBACK("Component alpha not supported with source "
+                          "alpha and source value blending. (op=%d)",
+                          op);
+         }
       }
-   }
-   return FALSE;
-}
-
-static void
-bind_clip_state(struct exa_context *exa)
-{
-}
-
-static void
-bind_framebuffer_state(struct exa_context *exa, struct exa_pixmap_priv *pDst)
-{
-   unsigned i;
-   struct pipe_framebuffer_state state;
-   struct pipe_surface *surface = exa_gpu_surface(exa, pDst);
-   memset(&state, 0, sizeof(struct pipe_framebuffer_state));
-
-   state.width  = pDst->tex->width[0];
-   state.height = pDst->tex->height[0];
-
-   state.nr_cbufs = 1;
-   state.cbufs[0] = surface;
-   for (i = 1; i < PIPE_MAX_COLOR_BUFS; ++i)
-      state.cbufs[i] = 0;
-
-   /* currently we don't use depth/stencil */
-   state.zsbuf = 0;
-
-   cso_set_framebuffer(exa->cso, &state);
-
-   /* we do fire and forget for the framebuffer, this is the forget part */
-   pipe_surface_reference(&surface, NULL);
-}
-
-enum AxisOrientation {
-   Y0_BOTTOM,
-   Y0_TOP
-};
-
-static void
-set_viewport(struct exa_context *exa, int width, int height,
-             enum AxisOrientation orientation)
-{
-   struct pipe_viewport_state viewport;
-   float y_scale = (orientation == Y0_BOTTOM) ? -2.f : 2.f;
-
-   viewport.scale[0] =  width / 2.f;
-   viewport.scale[1] =  height / y_scale;
-   viewport.scale[2] =  1.0;
-   viewport.scale[3] =  1.0;
-   viewport.translate[0] = width / 2.f;
-   viewport.translate[1] = height / 2.f;
-   viewport.translate[2] = 0.0;
-   viewport.translate[3] = 0.0;
-
-   cso_set_viewport(exa->cso, &viewport);
-}
-
-static void
-bind_viewport_state(struct exa_context *exa, struct exa_pixmap_priv *pDst)
-{
-   int width = pDst->tex->width[0];
-   int height = pDst->tex->height[0];
 
-   /*debug_printf("Bind viewport (%d, %d)\n", width, height);*/
-
-   set_viewport(exa, width, height, Y0_TOP);
+      return TRUE;
+   }
+   XORG_FALLBACK("Unsupported composition operation = %d", op);
 }
 
 static void
 bind_blend_state(struct exa_context *exa, int op,
-                 PicturePtr pSrcPicture, PicturePtr pMaskPicture)
+                 PicturePtr pSrcPicture,
+                 PicturePtr pMaskPicture,
+                 PicturePtr pDstPicture)
 {
    struct xorg_composite_blend blend_opt;
    struct pipe_blend_state blend;
 
-   blend_opt = blend_for_op(op);
+   blend_for_op(&blend_opt, op, pSrcPicture, pMaskPicture, pDstPicture);
 
    memset(&blend, 0, sizeof(struct pipe_blend_state));
    blend.blend_enable = 1;
-   blend.colormask |= PIPE_MASK_R;
-   blend.colormask |= PIPE_MASK_G;
-   blend.colormask |= PIPE_MASK_B;
-   blend.colormask |= PIPE_MASK_A;
+   blend.colormask |= PIPE_MASK_RGBA;
+
+   blend.rgb_src_factor   = blend_opt.rgb_src;
+   blend.alpha_src_factor = blend_opt.rgb_src;
+   blend.rgb_dst_factor   = blend_opt.rgb_dst;
+   blend.alpha_dst_factor = blend_opt.rgb_dst;
+
+   cso_set_blend(exa->renderer->cso, &blend);
+}
+
+static unsigned
+picture_format_fixups(struct exa_pixmap_priv *pSrc, PicturePtr pSrcPicture, boolean mask,
+                      PicturePtr pDstPicture)
+{
+   boolean set_alpha = FALSE;
+   boolean swizzle = FALSE;
+   unsigned ret = 0;
+
+   if (pSrc->picture_format == pSrcPicture->format) {
+      if (pSrc->picture_format == PICT_a8) {
+         if (mask)
+            return FS_MASK_LUMINANCE;
+         else if (pDstPicture->format != PICT_a8) {
+            /* if both dst and src are luminance then
+             * we don't want to swizzle the alpha (X) of the
+             * source into W component of the dst because
+             * it will break our destination */
+            return FS_SRC_LUMINANCE;
+         }
+      }
+      return 0;
+   }
 
-   blend.rgb_src_factor   = blend_opt.rgb_src_factor;
-   blend.alpha_src_factor = blend_opt.alpha_src_factor;
-   blend.rgb_dst_factor   = blend_opt.rgb_dst_factor;
-   blend.alpha_dst_factor = blend_opt.alpha_dst_factor;
+   if (pSrc->picture_format != PICT_a8r8g8b8) {
+      assert(!"can not handle formats");
+      return 0;
+   }
 
-   cso_set_blend(exa->cso, &blend);
-}
+   /* pSrc->picture_format == PICT_a8r8g8b8 */
+   switch (pSrcPicture->format) {
+   case PICT_x8b8g8r8:
+   case PICT_b8g8r8:
+      set_alpha = TRUE; /* fall trough */
+   case PICT_a8b8g8r8:
+      swizzle = TRUE;
+      break;
+   case PICT_x8r8g8b8:
+   case PICT_r8g8b8:
+      set_alpha = TRUE; /* fall through */
+   case PICT_a8r8g8b8:
+      break;
+#ifdef PICT_TYPE_BGRA
+   case PICT_b8g8r8a8:
+   case PICT_b8g8r8x8:
+   case PICT_a2r10g10b10:
+   case PICT_x2r10g10b10:
+   case PICT_a2b10g10r10:
+   case PICT_x2b10g10r10:
+#endif
+   default:
+      assert(!"can not handle formats");
+      return 0;
+   }
 
-static void
-bind_rasterizer_state(struct exa_context *exa)
-{
-   struct pipe_rasterizer_state raster;
-   memset(&raster, 0, sizeof(struct pipe_rasterizer_state));
-   raster.gl_rasterization_rules = 1;
-   cso_set_rasterizer(exa->cso, &raster);
+   if (set_alpha)
+      ret |= mask ? FS_MASK_SET_ALPHA : FS_SRC_SET_ALPHA;
+   if (swizzle)
+      ret |= mask ? FS_MASK_SWIZZLE_RGB : FS_SRC_SWIZZLE_RGB;
+
+   return ret;
 }
 
 static void
 bind_shaders(struct exa_context *exa, int op,
-             PicturePtr pSrcPicture, PicturePtr pMaskPicture)
+             PicturePtr pSrcPicture, PicturePtr pMaskPicture, PicturePtr pDstPicture,
+             struct exa_pixmap_priv *pSrc, struct exa_pixmap_priv *pMask)
 {
    unsigned vs_traits = 0, fs_traits = 0;
    struct xorg_shader shader;
@@ -421,6 +304,9 @@ bind_shaders(struct exa_context *exa, int op,
    exa->has_solid_color = FALSE;
 
    if (pSrcPicture) {
+      if (pSrcPicture->repeatType == RepeatNone && pSrcPicture->transform)
+         fs_traits |= FS_SRC_REPEAT_NONE;
+
       if (pSrcPicture->pSourcePict) {
          if (pSrcPicture->pSourcePict->type == SourcePictTypeSolidFill) {
             fs_traits |= FS_SOLID_FILL;
@@ -436,19 +322,33 @@ bind_shaders(struct exa_context *exa, int op,
          fs_traits |= FS_COMPOSITE;
          vs_traits |= VS_COMPOSITE;
       }
+
+      fs_traits |= picture_format_fixups(pSrc, pSrcPicture, FALSE, pDstPicture);
    }
 
    if (pMaskPicture) {
       vs_traits |= VS_MASK;
       fs_traits |= FS_MASK;
+      if (pMaskPicture->repeatType == RepeatNone && pMaskPicture->transform)
+         fs_traits |= FS_MASK_REPEAT_NONE;
+      if (pMaskPicture->componentAlpha) {
+         struct xorg_composite_blend blend;
+         blend_for_op(&blend, op,
+                      pSrcPicture, pMaskPicture, NULL);
+         if (blend.alpha_src) {
+            fs_traits |= FS_CA_SRCALPHA;
+         } else
+            fs_traits |= FS_CA_FULL;
+      }
+
+      fs_traits |= picture_format_fixups(pMask, pMaskPicture, TRUE, pDstPicture);
    }
 
-   shader = xorg_shaders_get(exa->shaders, vs_traits, fs_traits);
-   cso_set_vertex_shader_handle(exa->cso, shader.vs);
-   cso_set_fragment_shader_handle(exa->cso, shader.fs);
+   shader = xorg_shaders_get(exa->renderer->shaders, vs_traits, fs_traits);
+   cso_set_vertex_shader_handle(exa->renderer->cso, shader.vs);
+   cso_set_fragment_shader_handle(exa->renderer->cso, shader.fs);
 }
 
-
 static void
 bind_samplers(struct exa_context *exa, int op,
               PicturePtr pSrcPicture, PicturePtr pMaskPicture,
@@ -462,100 +362,103 @@ bind_samplers(struct exa_context *exa, int op,
 
    exa->num_bound_samplers = 0;
 
+#if 0
+   if ((pSrc && (exa->pipe->is_texture_referenced(exa->pipe, pSrc->tex, 0, 0) &
+                 PIPE_REFERENCED_FOR_WRITE)) ||
+       (pMask && (exa->pipe->is_texture_referenced(exa->pipe, pMask->tex, 0, 0) &
+        PIPE_REFERENCED_FOR_WRITE)))
+      xorg_exa_flush(exa, PIPE_FLUSH_RENDER_CACHE, NULL);
+#endif
+
    memset(&src_sampler, 0, sizeof(struct pipe_sampler_state));
    memset(&mask_sampler, 0, sizeof(struct pipe_sampler_state));
 
-   if ((pSrc && exa->pipe->is_texture_referenced(exa->pipe, pSrc->tex, 0, 0) &
-        PIPE_REFERENCED_FOR_WRITE) ||
-       (pMask && exa->pipe->is_texture_referenced(exa->pipe, pMask->tex, 0, 0) &
-        PIPE_REFERENCED_FOR_WRITE))
-      exa->pipe->flush(exa->pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
-
    if (pSrcPicture && pSrc) {
-      unsigned src_wrap = render_repeat_to_gallium(
-         pSrcPicture->repeatType);
-      src_sampler.wrap_s = src_wrap;
-      src_sampler.wrap_t = src_wrap;
-      src_sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST;
-      src_sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST;
-      src_sampler.normalized_coords = 1;
-      samplers[0] = &src_sampler;
-      exa->bound_textures[0] = pSrc->tex;
-      ++exa->num_bound_samplers;
+      if (exa->has_solid_color) {
+         debug_assert(!"solid color with textures");
+         samplers[0] = NULL;
+         exa->bound_textures[0] = NULL;
+      } else {
+         unsigned src_wrap = render_repeat_to_gallium(
+            pSrcPicture->repeatType);
+         int filter;
+
+         render_filter_to_gallium(pSrcPicture->filter, &filter);
+
+         src_sampler.wrap_s = src_wrap;
+         src_sampler.wrap_t = src_wrap;
+         src_sampler.min_img_filter = filter;
+         src_sampler.mag_img_filter = filter;
+         src_sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST;
+         src_sampler.normalized_coords = 1;
+         samplers[0] = &src_sampler;
+         exa->bound_textures[0] = pSrc->tex;
+         exa->num_bound_samplers = 1;
+      }
    }
 
    if (pMaskPicture && pMask) {
       unsigned mask_wrap = render_repeat_to_gallium(
          pMaskPicture->repeatType);
+      int filter;
+
+      render_filter_to_gallium(pMaskPicture->filter, &filter);
+
       mask_sampler.wrap_s = mask_wrap;
       mask_sampler.wrap_t = mask_wrap;
-      mask_sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST;
-      mask_sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST;
+      mask_sampler.min_img_filter = filter;
+      mask_sampler.mag_img_filter = filter;
+      src_sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST;
       mask_sampler.normalized_coords = 1;
       samplers[1] = &mask_sampler;
       exa->bound_textures[1] = pMask->tex;
-      ++exa->num_bound_samplers;
+      exa->num_bound_samplers = 2;
    }
 
-   cso_set_samplers(exa->cso, exa->num_bound_samplers,
+   cso_set_samplers(exa->renderer->cso, exa->num_bound_samplers,
                     (const struct pipe_sampler_state **)samplers);
-   cso_set_sampler_textures(exa->cso, exa->num_bound_samplers,
+   cso_set_sampler_textures(exa->renderer->cso, exa->num_bound_samplers,
                             exa->bound_textures);
 }
 
-static void
-setup_vs_constant_buffer(struct exa_context *exa,
-                         int width, int height)
-{
-   const int param_bytes = 8 * sizeof(float);
-   float vs_consts[8] = {
-      2.f/width, 2.f/height, 1, 1,
-      -1, -1, 0, 0
-   };
-   struct pipe_constant_buffer *cbuf = &exa->vs_const_buffer;
-
-   pipe_buffer_reference(&cbuf->buffer, NULL);
-   cbuf->buffer = pipe_buffer_create(exa->pipe->screen, 16,
-                                     PIPE_BUFFER_USAGE_CONSTANT,
-                                     param_bytes);
-
-   if (cbuf->buffer) {
-      pipe_buffer_write(exa->pipe->screen, cbuf->buffer,
-                        0, param_bytes, vs_consts);
-   }
-   exa->pipe->set_constant_buffer(exa->pipe, PIPE_SHADER_VERTEX, 0, cbuf);
-}
 
 
-static void
-setup_fs_constant_buffer(struct exa_context *exa)
+static INLINE boolean matrix_from_pict_transform(PictTransform *trans, float *matrix)
 {
-   const int param_bytes = 4 * sizeof(float);
-   float fs_consts[8] = {
-      0, 0, 0, 1,
-   };
-   struct pipe_constant_buffer *cbuf = &exa->fs_const_buffer;
-
-   pipe_buffer_reference(&cbuf->buffer, NULL);
-   cbuf->buffer = pipe_buffer_create(exa->pipe->screen, 16,
-                                     PIPE_BUFFER_USAGE_CONSTANT,
-                                     param_bytes);
-
-   if (cbuf->buffer) {
-      pipe_buffer_write(exa->pipe->screen, cbuf->buffer,
-                        0, param_bytes, fs_consts);
-   }
-   exa->pipe->set_constant_buffer(exa->pipe, PIPE_SHADER_FRAGMENT, 0, cbuf);
+   if (!trans)
+      return FALSE;
+
+   matrix[0] = XFixedToDouble(trans->matrix[0][0]);
+   matrix[3] = XFixedToDouble(trans->matrix[0][1]);
+   matrix[6] = XFixedToDouble(trans->matrix[0][2]);
+
+   matrix[1] = XFixedToDouble(trans->matrix[1][0]);
+   matrix[4] = XFixedToDouble(trans->matrix[1][1]);
+   matrix[7] = XFixedToDouble(trans->matrix[1][2]);
+
+   matrix[2] = XFixedToDouble(trans->matrix[2][0]);
+   matrix[5] = XFixedToDouble(trans->matrix[2][1]);
+   matrix[8] = XFixedToDouble(trans->matrix[2][2]);
+
+   return TRUE;
 }
 
 static void
-setup_constant_buffers(struct exa_context *exa, struct exa_pixmap_priv *pDst)
+setup_transforms(struct  exa_context *exa,
+                 PicturePtr pSrcPicture, PicturePtr pMaskPicture)
 {
-   int width = pDst->tex->width[0];
-   int height = pDst->tex->height[0];
+   PictTransform *src_t = NULL;
+   PictTransform *mask_t = NULL;
+
+   if (pSrcPicture)
+      src_t = pSrcPicture->transform;
+   if (pMaskPicture)
+      mask_t = pMaskPicture->transform;
 
-   setup_vs_constant_buffer(exa, width, height);
-   setup_fs_constant_buffer(exa);
+   exa->transform.has_src  =
+      matrix_from_pict_transform(src_t, exa->transform.src);
+   exa->transform.has_mask =
+      matrix_from_pict_transform(mask_t, exa->transform.mask);
 }
 
 boolean xorg_composite_bind_state(struct exa_context *exa,
@@ -567,17 +470,30 @@ boolean xorg_composite_bind_state(struct exa_context *exa,
                                   struct exa_pixmap_priv *pMask,
                                   struct exa_pixmap_priv *pDst)
 {
-   bind_framebuffer_state(exa, pDst);
-   bind_viewport_state(exa, pDst);
-   bind_blend_state(exa, op, pSrcPicture, pMaskPicture);
-   bind_rasterizer_state(exa);
-   bind_shaders(exa, op, pSrcPicture, pMaskPicture);
+   struct pipe_surface *dst_surf = xorg_gpu_surface(exa->scrn, pDst);
+
+   renderer_bind_destination(exa->renderer, dst_surf,
+                             pDst->width,
+                             pDst->height);
+
+   bind_blend_state(exa, op, pSrcPicture, pMaskPicture, pDstPicture);
+   bind_shaders(exa, op, pSrcPicture, pMaskPicture, pDstPicture, pSrc, pMask);
    bind_samplers(exa, op, pSrcPicture, pMaskPicture,
                  pDstPicture, pSrc, pMask, pDst);
-   bind_clip_state(exa);
-   setup_constant_buffers(exa, pDst);
 
-   return FALSE;
+   setup_transforms(exa, pSrcPicture, pMaskPicture);
+
+   if (exa->num_bound_samplers == 0 ) { /* solid fill */
+      renderer_begin_solid(exa->renderer);
+   } else {
+      renderer_begin_textures(exa->renderer,
+                              exa->bound_textures,
+                              exa->num_bound_samplers);
+   }
+
+
+   pipe_surface_reference(&dst_surf, NULL);
+   return TRUE;
 }
 
 void xorg_composite(struct exa_context *exa,
@@ -585,42 +501,25 @@ void xorg_composite(struct exa_context *exa,
                     int srcX, int srcY, int maskX, int maskY,
                     int dstX, int dstY, int width, int height)
 {
-   struct pipe_context *pipe = exa->pipe;
-   struct pipe_buffer *buf = 0;
-
    if (exa->num_bound_samplers == 0 ) { /* solid fill */
-      buf = setup_vertex_data0(exa,
-                               srcX, srcY, maskX, maskY,
-                               dstX, dstY, width, height);
-   } else if (exa->num_bound_samplers == 1 ) /* src */
-      buf = setup_vertex_data1(exa,
-                               srcX, srcY, maskX, maskY,
-                               dstX, dstY, width, height);
-   else if (exa->num_bound_samplers == 2) /* src + mask */
-      buf = setup_vertex_data2(exa,
-                               srcX, srcY, maskX, maskY,
-                               dstX, dstY, width, height);
-   else if (exa->num_bound_samplers == 3) { /* src + mask + dst */
-      debug_assert(!"src/mask/dst not handled right now");
-#if 0
-      buf = setup_vertex_data2(exa,
-                               srcX, srcY, maskX, maskY,
-                               dstX, dstY, width, height);
-#endif
-   }
-
-   if (buf) {
-      int num_attribs = 1; /*pos*/
-      num_attribs += exa->num_bound_samplers;
-      if (exa->has_solid_color)
-         ++num_attribs;
-
-      util_draw_vertex_buffer(pipe, buf, 0,
-                              PIPE_PRIM_TRIANGLE_FAN,
-                              4,  /* verts */
-                              num_attribs); /* attribs/vert */
-
-      pipe_buffer_reference(&buf, NULL);
+      renderer_solid(exa->renderer,
+                     dstX, dstY, dstX + width, dstY + height,
+                     exa->solid_color);
+   } else {
+      int pos[6] = {srcX, srcY, maskX, maskY, dstX, dstY};
+      float *src_matrix = NULL;
+      float *mask_matrix = NULL;
+
+      if (exa->transform.has_src)
+         src_matrix = exa->transform.src;
+      if (exa->transform.has_mask)
+         mask_matrix = exa->transform.mask;
+
+      renderer_texture(exa->renderer,
+                       pos, width, height,
+                       exa->bound_textures,
+                       exa->num_bound_samplers,
+                       src_matrix, mask_matrix);
    }
 }
 
@@ -628,14 +527,13 @@ boolean xorg_solid_bind_state(struct exa_context *exa,
                               struct exa_pixmap_priv *pixmap,
                               Pixel fg)
 {
+   struct pipe_surface *dst_surf = xorg_gpu_surface(exa->scrn, pixmap);
    unsigned vs_traits, fs_traits;
    struct xorg_shader shader;
 
    pixel_to_float4(fg, exa->solid_color);
    exa->has_solid_color = TRUE;
 
-   exa->solid_color[3] = 1.f;
-
 #if 0
    debug_printf("Color Pixel=(%d, %d, %d, %d), RGBA=(%f, %f, %f, %f)\n",
                 (fg >> 24) & 0xff, (fg >> 16) & 0xff,
@@ -647,17 +545,19 @@ boolean xorg_solid_bind_state(struct exa_context *exa,
    vs_traits = VS_SOLID_FILL;
    fs_traits = FS_SOLID_FILL;
 
-   bind_framebuffer_state(exa, pixmap);
-   bind_viewport_state(exa, pixmap);
-   bind_rasterizer_state(exa);
-   bind_blend_state(exa, PictOpSrc, NULL, NULL);
-   setup_constant_buffers(exa, pixmap);
-   bind_clip_state(exa);
+   renderer_bind_destination(exa->renderer, dst_surf, 
+                             pixmap->width, pixmap->height);
+   bind_blend_state(exa, PictOpSrc, NULL, NULL, NULL);
+   cso_set_samplers(exa->renderer->cso, 0, NULL);
+   cso_set_sampler_textures(exa->renderer->cso, 0, NULL);
+
+   shader = xorg_shaders_get(exa->renderer->shaders, vs_traits, fs_traits);
+   cso_set_vertex_shader_handle(exa->renderer->cso, shader.vs);
+   cso_set_fragment_shader_handle(exa->renderer->cso, shader.fs);
 
-   shader = xorg_shaders_get(exa->shaders, vs_traits, fs_traits);
-   cso_set_vertex_shader_handle(exa->cso, shader.vs);
-   cso_set_fragment_shader_handle(exa->cso, shader.fs);
+   renderer_begin_solid(exa->renderer);
 
+   pipe_surface_reference(&dst_surf, NULL);
    return TRUE;
 }
 
@@ -665,402 +565,17 @@ void xorg_solid(struct exa_context *exa,
                 struct exa_pixmap_priv *pixmap,
                 int x0, int y0, int x1, int y1)
 {
-   struct pipe_context *pipe = exa->pipe;
-   struct pipe_buffer *buf = 0;
-
-   /* 1st vertex */
-   setup_vertex0(exa->vertices2[0], x0, y0,
-                 exa->solid_color);
-   /* 2nd vertex */
-   setup_vertex0(exa->vertices2[1], x1, y0,
-                 exa->solid_color);
-   /* 3rd vertex */
-   setup_vertex0(exa->vertices2[2], x1, y1,
-                 exa->solid_color);
-   /* 4th vertex */
-   setup_vertex0(exa->vertices2[3], x0, y1,
-                 exa->solid_color);
-
-   buf = pipe_user_buffer_create(exa->pipe->screen,
-                                 exa->vertices2,
-                                 sizeof(exa->vertices2));
-
-
-   if (buf) {
-      util_draw_vertex_buffer(pipe, buf, 0,
-                              PIPE_PRIM_TRIANGLE_FAN,
-                              4,  /* verts */
-                              2); /* attribs/vert */
-
-      pipe_buffer_reference(&buf, NULL);
-   }
-}
-
-
-static INLINE void shift_rectx(float coords[4],
-                               const float *bounds,
-                               const float shift)
-{
-   coords[0] += shift;
-   coords[2] -= shift;
-   if (bounds) {
-      coords[2] = MIN2(coords[2], bounds[2]);
-      /* bound x/y + width/height */
-      if ((coords[0] + coords[2]) > (bounds[0] + bounds[2])) {
-         coords[2] = (bounds[0] + bounds[2]) - coords[0];
-      }
-   }
-}
-
-static INLINE void shift_recty(float coords[4],
-                               const float *bounds,
-                               const float shift)
-{
-   coords[1] += shift;
-   coords[3] -= shift;
-   if (bounds) {
-      coords[3] = MIN2(coords[3], bounds[3]);
-      if ((coords[1] + coords[3]) > (bounds[1] + bounds[3])) {
-         coords[3] = (bounds[1] + bounds[3]) - coords[1];
-      }
-   }
+   renderer_solid(exa->renderer,
+                  x0, y0, x1, y1, exa->solid_color);
 }
 
-static INLINE void bound_rect(float coords[4],
-                              const float bounds[4],
-                              float shift[4])
+void
+xorg_composite_done(struct exa_context *exa)
 {
-   /* if outside the bounds */
-   if (coords[0] > (bounds[0] + bounds[2]) ||
-       coords[1] > (bounds[1] + bounds[3]) ||
-       (coords[0] + coords[2]) < bounds[0] ||
-       (coords[1] + coords[3]) < bounds[1]) {
-      coords[0] = 0.f;
-      coords[1] = 0.f;
-      coords[2] = 0.f;
-      coords[3] = 0.f;
-      shift[0] = 0.f;
-      shift[1] = 0.f;
-      return;
-   }
-
-   /* bound x */
-   if (coords[0] < bounds[0]) {
-      shift[0] = bounds[0] - coords[0];
-      coords[2] -= shift[0];
-      coords[0] = bounds[0];
-   } else
-      shift[0] = 0.f;
-
-   /* bound y */
-   if (coords[1] < bounds[1]) {
-      shift[1] = bounds[1] - coords[1];
-      coords[3] -= shift[1];
-      coords[1] = bounds[1];
-   } else
-      shift[1] = 0.f;
-
-   shift[2] = bounds[2] - coords[2];
-   shift[3] = bounds[3] - coords[3];
-   /* bound width/height */
-   coords[2] = MIN2(coords[2], bounds[2]);
-   coords[3] = MIN2(coords[3], bounds[3]);
-
-   /* bound x/y + width/height */
-   if ((coords[0] + coords[2]) > (bounds[0] + bounds[2])) {
-      coords[2] = (bounds[0] + bounds[2]) - coords[0];
-   }
-   if ((coords[1] + coords[3]) > (bounds[1] + bounds[3])) {
-      coords[3] = (bounds[1] + bounds[3]) - coords[1];
-   }
-
-   /* if outside the bounds */
-   if ((coords[0] + coords[2]) < bounds[0] ||
-       (coords[1] + coords[3]) < bounds[1]) {
-      coords[0] = 0.f;
-      coords[1] = 0.f;
-      coords[2] = 0.f;
-      coords[3] = 0.f;
-      return;
-   }
-}
-
-static INLINE void sync_size(float *src_loc, float *dst_loc)
-{
-   src_loc[2] = MIN2(src_loc[2], dst_loc[2]);
-   src_loc[3] = MIN2(src_loc[3], dst_loc[3]);
-   dst_loc[2] = src_loc[2];
-   dst_loc[3] = src_loc[3];
-}
-
-
-static void renderer_copy_texture(struct exa_context *exa,
-                                  struct pipe_texture *src,
-                                  float sx1, float sy1,
-                                  float sx2, float sy2,
-                                  struct pipe_texture *dst,
-                                  float dx1, float dy1,
-                                  float dx2, float dy2)
-{
-   struct pipe_context *pipe = exa->pipe;
-   struct pipe_screen *screen = pipe->screen;
-   struct pipe_buffer *buf;
-   struct pipe_surface *dst_surf = screen->get_tex_surface(
-      screen, dst, 0, 0, 0,
-      PIPE_BUFFER_USAGE_GPU_WRITE);
-   struct pipe_framebuffer_state fb;
-   float s0, t0, s1, t1;
-   struct xorg_shader shader;
-
-   assert(src->width[0] != 0);
-   assert(src->height[0] != 0);
-   assert(dst->width[0] != 0);
-   assert(dst->height[0] != 0);
-
-#if 1
-   s0 = sx1 / src->width[0];
-   s1 = sx2 / src->width[0];
-   t0 = sy1 / src->height[0];
-   t1 = sy2 / src->height[0];
-#else
-   s0 = 0;
-   s1 = 1;
-   t0 = 0;
-   t1 = 1;
-#endif
-
-#if 0
-   debug_printf("copy texture src=[%f, %f, %f, %f], dst=[%f, %f, %f, %f], tex=[%f, %f, %f, %f]\n",
-                sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2,
-                s0, t0, s1, t1);
-#endif
+   renderer_draw_flush(exa->renderer);
 
-   assert(screen->is_format_supported(screen, dst_surf->format,
-                                      PIPE_TEXTURE_2D,
-                                      PIPE_TEXTURE_USAGE_RENDER_TARGET,
-                                      0));
-
-   /* save state (restored below) */
-   cso_save_blend(exa->cso);
-   cso_save_samplers(exa->cso);
-   cso_save_sampler_textures(exa->cso);
-   cso_save_framebuffer(exa->cso);
-   cso_save_fragment_shader(exa->cso);
-   cso_save_vertex_shader(exa->cso);
-
-   cso_save_viewport(exa->cso);
-
-
-   /* set misc state we care about */
-   {
-      struct pipe_blend_state blend;
-      memset(&blend, 0, sizeof(blend));
-      blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE;
-      blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE;
-      blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
-      blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
-      blend.colormask = PIPE_MASK_RGBA;
-      cso_set_blend(exa->cso, &blend);
-   }
-
-   /* sampler */
-   {
-      struct pipe_sampler_state sampler;
-      memset(&sampler, 0, sizeof(sampler));
-      sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
-      sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
-      sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
-      sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
-      sampler.min_img_filter = PIPE_TEX_FILTER_NEAREST;
-      sampler.mag_img_filter = PIPE_TEX_FILTER_NEAREST;
-      sampler.normalized_coords = 1;
-      cso_single_sampler(exa->cso, 0, &sampler);
-      cso_single_sampler_done(exa->cso);
-   }
-
-   set_viewport(exa, dst_surf->width, dst_surf->height, Y0_TOP);
-
-   /* texture */
-   cso_set_sampler_textures(exa->cso, 1, &src);
-
-   bind_rasterizer_state(exa);
-
-   /* shaders */
-   shader = xorg_shaders_get(exa->shaders,
-                             VS_COMPOSITE,
-                             FS_COMPOSITE);
-   cso_set_vertex_shader_handle(exa->cso, shader.vs);
-   cso_set_fragment_shader_handle(exa->cso, shader.fs);
-
-   /* drawing dest */
-   memset(&fb, 0, sizeof(fb));
-   fb.width = dst_surf->width;
-   fb.height = dst_surf->height;
-   fb.nr_cbufs = 1;
-   fb.cbufs[0] = dst_surf;
-   {
-      int i;
-      for (i = 1; i < PIPE_MAX_COLOR_BUFS; ++i)
-         fb.cbufs[i] = 0;
-   }
-   cso_set_framebuffer(exa->cso, &fb);
-   setup_vs_constant_buffer(exa, fb.width, fb.height);
-   setup_fs_constant_buffer(exa);
-
-   /* draw quad */
-   buf = setup_vertex_data_tex(exa,
-                               dx1, dy1,
-                               dx2, dy2,
-                               s0, t0, s1, t1,
-                               0.0f);
-
-   if (buf) {
-      util_draw_vertex_buffer(exa->pipe, buf, 0,
-                              PIPE_PRIM_TRIANGLE_FAN,
-                              4,  /* verts */
-                              2); /* attribs/vert */
-
-      pipe_buffer_reference(&buf, NULL);
-   }
-
-   /* restore state we changed */
-   cso_restore_blend(exa->cso);
-   cso_restore_samplers(exa->cso);
-   cso_restore_sampler_textures(exa->cso);
-   cso_restore_framebuffer(exa->cso);
-   cso_restore_vertex_shader(exa->cso);
-   cso_restore_fragment_shader(exa->cso);
-   cso_restore_viewport(exa->cso);
-
-   pipe_surface_reference(&dst_surf, NULL);
-}
-
-
-static struct pipe_texture *
-create_sampler_texture(struct exa_context *ctx,
-                       struct pipe_texture *src)
-{
-   enum pipe_format format;
-   struct pipe_context *pipe = ctx->pipe;
-   struct pipe_screen *screen = pipe->screen;
-   struct pipe_texture *pt;
-   struct pipe_texture templ;
-
-   pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
-
-   /* the coming in texture should already have that invariance */
-   debug_assert(screen->is_format_supported(screen, src->format,
-                                            PIPE_TEXTURE_2D,
-                                            PIPE_TEXTURE_USAGE_SAMPLER, 0));
-
-   format = src->format;
-
-   memset(&templ, 0, sizeof(templ));
-   templ.target = PIPE_TEXTURE_2D;
-   templ.format = format;
-   templ.last_level = 0;
-   templ.width[0] = src->width[0];
-   templ.height[0] = src->height[0];
-   templ.depth[0] = 1;
-   pf_get_block(format, &templ.block);
-   templ.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER;
-
-   pt = screen->texture_create(screen, &templ);
-
-   debug_assert(!pt || pipe_is_referenced(&pt->reference));
-
-   if (!pt)
-      return NULL;
-
-   {
-      /* copy source framebuffer surface into texture */
-      struct pipe_surface *ps_read = screen->get_tex_surface(
-         screen, src, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ);
-      struct pipe_surface *ps_tex = screen->get_tex_surface(
-         screen, pt, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE );
-      pipe->surface_copy(pipe,
-                        ps_tex, /* dest */
-                        0, 0, /* destx/y */
-                        ps_read,
-                        0, 0, src->width[0], src->height[0]);
-      pipe_surface_reference(&ps_read, NULL);
-      pipe_surface_reference(&ps_tex, NULL);
-   }
-
-   return pt;
-}
-
-void xorg_copy_pixmap(struct exa_context *ctx,
-                      struct exa_pixmap_priv *dst_priv, int dx, int dy,
-                      struct exa_pixmap_priv *src_priv, int sx, int sy,
-                      int width, int height)
-{
-   float dst_loc[4], src_loc[4];
-   float dst_bounds[4], src_bounds[4];
-   float src_shift[4], dst_shift[4], shift[4];
-   struct pipe_texture *dst = dst_priv->tex;
-   struct pipe_texture *src = src_priv->tex;
-
-   if (ctx->pipe->is_texture_referenced(ctx->pipe, src, 0, 0) &
-       PIPE_REFERENCED_FOR_WRITE)
-      ctx->pipe->flush(ctx->pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
-
-   dst_loc[0] = dx;
-   dst_loc[1] = dy;
-   dst_loc[2] = width;
-   dst_loc[3] = height;
-   dst_bounds[0] = 0.f;
-   dst_bounds[1] = 0.f;
-   dst_bounds[2] = dst->width[0];
-   dst_bounds[3] = dst->height[0];
-
-   src_loc[0] = sx;
-   src_loc[1] = sy;
-   src_loc[2] = width;
-   src_loc[3] = height;
-   src_bounds[0] = 0.f;
-   src_bounds[1] = 0.f;
-   src_bounds[2] = src->width[0];
-   src_bounds[3] = src->height[0];
-
-   bound_rect(src_loc, src_bounds, src_shift);
-   bound_rect(dst_loc, dst_bounds, dst_shift);
-   shift[0] = src_shift[0] - dst_shift[0];
-   shift[1] = src_shift[1] - dst_shift[1];
-
-   if (shift[0] < 0)
-      shift_rectx(src_loc, src_bounds, -shift[0]);
-   else
-      shift_rectx(dst_loc, dst_bounds, shift[0]);
-
-   if (shift[1] < 0)
-      shift_recty(src_loc, src_bounds, -shift[1]);
-   else
-      shift_recty(dst_loc, dst_bounds, shift[1]);
-
-   sync_size(src_loc, dst_loc);
-
-   if (src_loc[2] >= 0 && src_loc[3] >= 0 &&
-       dst_loc[2] >= 0 && dst_loc[3] >= 0) {
-      struct pipe_texture *temp_src = src;
-
-      if (src == dst)
-         temp_src = create_sampler_texture(ctx, src);
-
-      renderer_copy_texture(ctx,
-                            temp_src,
-                            src_loc[0],
-                            src_loc[1],
-                            src_loc[0] + src_loc[2],
-                            src_loc[1] + src_loc[3],
-                            dst,
-                            dst_loc[0],
-                            dst_loc[1],
-                            dst_loc[0] + dst_loc[2],
-                            dst_loc[1] + dst_loc[3]);
-
-      if (src == dst)
-         pipe_texture_reference(&temp_src, NULL);
-   }
+   exa->transform.has_src = FALSE;
+   exa->transform.has_mask = FALSE;
+   exa->has_solid_color = FALSE;
+   exa->num_bound_samplers = 0;
 }
-
index e73f1c704a8bd61867e386b4bb7ed674b00d1110..ec71ebfe0dc3d9d2564134c068ed6e24166b1c7d 100644 (file)
@@ -29,9 +29,8 @@ void xorg_solid(struct exa_context *exa,
                 struct exa_pixmap_priv *pixmap,
                 int x0, int y0, int x1, int y1);
 
-void xorg_copy_pixmap(struct exa_context *ctx,
-                      struct exa_pixmap_priv *dst, int dx, int dy,
-                      struct exa_pixmap_priv *src, int sx, int sy,
-                      int width, int height);
+
+void
+xorg_composite_done(struct exa_context *exa);
 
 #endif
index 67fe29a69dab535eed641bdf6fc9d14d5a2e492e..650d2c0d1dbc7cd6c103909fb622bb2e05484733 100644 (file)
 #endif
 
 #include "pipe/p_inlines.h"
+#include "util/u_format.h"
 #include "util/u_rect.h"
 
+#ifdef HAVE_LIBKMS
+#include "libkms.h"
+#endif
+
 struct crtc_private
 {
     drmModeCrtcPtr drm_crtc;
 
     /* hwcursor */
     struct pipe_texture *cursor_tex;
+    struct kms_bo *cursor_bo;
+
     unsigned cursor_handle;
 };
 
 static void
 crtc_dpms(xf86CrtcPtr crtc, int mode)
 {
-    //ScrnInfoPtr pScrn = crtc->scrn;
+    /* ScrnInfoPtr pScrn = crtc->scrn; */
 
     switch (mode) {
     case DPMSModeOn:
@@ -77,44 +84,29 @@ crtc_dpms(xf86CrtcPtr crtc, int mode)
 }
 
 static Bool
-crtc_lock(xf86CrtcPtr crtc)
-{
-    return FALSE;
-}
-
-static void
-crtc_unlock(xf86CrtcPtr crtc)
-{
-}
-
-static void
-crtc_prepare(xf86CrtcPtr crtc)
-{
-}
-
-static void
-crtc_commit(xf86CrtcPtr crtc)
-{
-}
-
-static Bool
-crtc_mode_fixup(xf86CrtcPtr crtc, DisplayModePtr mode,
-               DisplayModePtr adjusted_mode)
-{
-    return TRUE;
-}
-
-static void
-crtc_mode_set(xf86CrtcPtr crtc, DisplayModePtr mode,
-             DisplayModePtr adjusted_mode, int x, int y)
+crtc_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
+                   Rotation rotation, int x, int y)
 {
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
     modesettingPtr ms = modesettingPTR(crtc->scrn);
-    xf86OutputPtr output = config->output[config->compat_output];
-    drmModeConnectorPtr drm_connector = output->driver_private;
+    xf86OutputPtr output = NULL;
+    drmModeConnectorPtr drm_connector;
     struct crtc_private *crtcp = crtc->driver_private;
     drmModeCrtcPtr drm_crtc = crtcp->drm_crtc;
     drmModeModeInfo drm_mode;
+    int i, ret;
+
+    for (i = 0; i < config->num_output; output = NULL, i++) {
+       output = config->output[i];
+
+       if (output->crtc == crtc)
+           break;
+    }
+
+    if (!output)
+       return FALSE;
+
+    drm_connector = output->driver_private;
 
     drm_mode.clock = mode->Clock;
     drm_mode.hdisplay = mode->HDisplay;
@@ -131,30 +123,34 @@ crtc_mode_set(xf86CrtcPtr crtc, DisplayModePtr mode,
     drm_mode.vrefresh = mode->VRefresh;
     if (!mode->name)
        xf86SetModeDefaultName(mode);
-    strncpy(drm_mode.name, mode->name, DRM_DISPLAY_MODE_LEN);
+    strncpy(drm_mode.name, mode->name, DRM_DISPLAY_MODE_LEN - 1);
+    drm_mode.name[DRM_DISPLAY_MODE_LEN - 1] = '\0';
 
-    drmModeSetCrtc(ms->fd, drm_crtc->crtc_id, ms->fb_id, x, y,
-                  &drm_connector->connector_id, 1, &drm_mode);
-}
+    ret = drmModeSetCrtc(ms->fd, drm_crtc->crtc_id, ms->fb_id, x, y,
+                        &drm_connector->connector_id, 1, &drm_mode);
 
-#if 0
-static void
-crtc_load_lut(xf86CrtcPtr crtc)
-{
-    //ScrnInfoPtr pScrn = crtc->scrn;
+    if (ret)
+       return FALSE;
+
+    crtc->x = x;
+    crtc->y = y;
+    crtc->mode = *mode;
+    crtc->rotation = rotation;
+
+    return TRUE;
 }
-#endif
 
 static void
 crtc_gamma_set(xf86CrtcPtr crtc, CARD16 * red, CARD16 * green, CARD16 * blue,
               int size)
 {
+    /* XXX: hockup */
 }
 
 static void *
 crtc_shadow_allocate(xf86CrtcPtr crtc, int width, int height)
 {
-    //ScrnInfoPtr pScrn = crtc->scrn;
+    /* ScrnInfoPtr pScrn = crtc->scrn; */
 
     return NULL;
 }
@@ -162,7 +158,7 @@ crtc_shadow_allocate(xf86CrtcPtr crtc, int width, int height)
 static PixmapPtr
 crtc_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height)
 {
-    //ScrnInfoPtr pScrn = crtc->scrn;
+    /* ScrnInfoPtr pScrn = crtc->scrn; */
 
     return NULL;
 }
@@ -170,23 +166,30 @@ crtc_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height)
 static void
 crtc_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap, void *data)
 {
-    //ScrnInfoPtr pScrn = crtc->scrn;
+    /* ScrnInfoPtr pScrn = crtc->scrn; */
 }
 
+/*
+ * Cursor functions
+ */
+
 static void
-crtc_destroy(xf86CrtcPtr crtc)
+crtc_set_cursor_colors(xf86CrtcPtr crtc, int bg, int fg)
 {
-    struct crtc_private *crtcp = crtc->driver_private;
+    /* XXX: See if this one is needed, as we only support ARGB cursors */
+}
 
-    if (crtcp->cursor_tex)
-       pipe_texture_reference(&crtcp->cursor_tex, NULL);
+static void
+crtc_set_cursor_position(xf86CrtcPtr crtc, int x, int y)
+{
+    modesettingPtr ms = modesettingPTR(crtc->scrn);
+    struct crtc_private *crtcp = crtc->driver_private;
 
-    drmModeFreeCrtc(crtcp->drm_crtc);
-    xfree(crtcp);
+    drmModeMoveCursor(ms->fd, crtcp->drm_crtc->crtc_id, x, y);
 }
 
 static void
-crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 * image)
+crtc_load_cursor_argb_ga3d(xf86CrtcPtr crtc, CARD32 * image)
 {
     unsigned char *ptr;
     modesettingPtr ms = modesettingPTR(crtc->scrn);
@@ -202,11 +205,10 @@ crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 * image)
        templat.tex_usage |= PIPE_TEXTURE_USAGE_PRIMARY;
        templat.target = PIPE_TEXTURE_2D;
        templat.last_level = 0;
-       templat.depth[0] = 1;
+       templat.depth0 = 1;
        templat.format = PIPE_FORMAT_A8R8G8B8_UNORM;
-       templat.width[0] = 64;
-       templat.height[0] = 64;
-       pf_get_block(templat.format, &templat.block);
+       templat.width0 = 64;
+       templat.height0 = 64;
 
        crtcp->cursor_tex = ms->screen->texture_create(ms->screen,
                                                       &templat);
@@ -222,20 +224,61 @@ crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 * image)
                                            PIPE_TRANSFER_WRITE,
                                            0, 0, 64, 64);
     ptr = ms->screen->transfer_map(ms->screen, transfer);
-    util_copy_rect(ptr, &crtcp->cursor_tex->block,
+    util_copy_rect(ptr, crtcp->cursor_tex->format,
                   transfer->stride, 0, 0,
                   64, 64, (void*)image, 64 * 4, 0, 0);
     ms->screen->transfer_unmap(ms->screen, transfer);
     ms->screen->tex_transfer_destroy(transfer);
 }
 
+#if HAVE_LIBKMS
 static void
-crtc_set_cursor_position(xf86CrtcPtr crtc, int x, int y)
+crtc_load_cursor_argb_kms(xf86CrtcPtr crtc, CARD32 * image)
 {
     modesettingPtr ms = modesettingPTR(crtc->scrn);
     struct crtc_private *crtcp = crtc->driver_private;
+    unsigned char *ptr;
 
-    drmModeMoveCursor(ms->fd, crtcp->drm_crtc->crtc_id, x, y);
+    if (!crtcp->cursor_bo) {
+       unsigned attr[8];
+
+       attr[0] = KMS_BO_TYPE;
+       attr[1] = KMS_BO_TYPE_CURSOR;
+       attr[2] = KMS_WIDTH;
+       attr[3] = 64;
+       attr[4] = KMS_HEIGHT;
+       attr[5] = 64;
+       attr[6] = 0;
+
+        if (kms_bo_create(ms->kms, attr, &crtcp->cursor_bo))
+          return;
+
+       if (kms_bo_get_prop(crtcp->cursor_bo, KMS_HANDLE,
+                           &crtcp->cursor_handle))
+           goto err_bo_destroy;
+    }
+
+    kms_bo_map(crtcp->cursor_bo, (void**)&ptr);
+    memcpy(ptr, image, 64*64*4);
+    kms_bo_unmap(crtcp->cursor_bo);
+
+    return;
+
+err_bo_destroy:
+    kms_bo_destroy(&crtcp->cursor_bo);
+}
+#endif
+
+static void
+crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 * image)
+{
+    modesettingPtr ms = modesettingPTR(crtc->scrn);
+    if (ms->screen)
+       crtc_load_cursor_argb_ga3d(crtc, image);
+#ifdef HAVE_LIBKMS
+    else if (ms->kms)
+       crtc_load_cursor_argb_kms(crtc, image);
+#endif
 }
 
 static void
@@ -244,7 +287,7 @@ crtc_show_cursor(xf86CrtcPtr crtc)
     modesettingPtr ms = modesettingPTR(crtc->scrn);
     struct crtc_private *crtcp = crtc->driver_private;
 
-    if (crtcp->cursor_tex)
+    if (crtcp->cursor_tex || crtcp->cursor_bo)
        drmModeSetCursor(ms->fd, crtcp->drm_crtc->crtc_id,
                         crtcp->cursor_handle, 64, 64);
 }
@@ -258,41 +301,59 @@ crtc_hide_cursor(xf86CrtcPtr crtc)
     drmModeSetCursor(ms->fd, crtcp->drm_crtc->crtc_id, 0, 0, 0);
 }
 
+/**
+ * Called at vt leave
+ */
+void
+xorg_crtc_cursor_destroy(xf86CrtcPtr crtc)
+{
+    struct crtc_private *crtcp = crtc->driver_private;
+
+    if (crtcp->cursor_tex)
+       pipe_texture_reference(&crtcp->cursor_tex, NULL);
+#ifdef HAVE_LIBKMS
+    if (crtcp->cursor_bo)
+       kms_bo_destroy(&crtcp->cursor_bo);
+#endif
+}
+
+/*
+ * Misc functions
+ */
+
+static void
+crtc_destroy(xf86CrtcPtr crtc)
+{
+    struct crtc_private *crtcp = crtc->driver_private;
+
+    xorg_crtc_cursor_destroy(crtc);
+
+    drmModeFreeCrtc(crtcp->drm_crtc);
+
+    xfree(crtcp);
+    crtc->driver_private = NULL;
+}
+
 static const xf86CrtcFuncsRec crtc_funcs = {
     .dpms = crtc_dpms,
-    .save = NULL,
-    .restore = NULL,
-    .lock = crtc_lock,
-    .unlock = crtc_unlock,
-    .mode_fixup = crtc_mode_fixup,
-    .prepare = crtc_prepare,
-    .mode_set = crtc_mode_set,
-    .commit = crtc_commit,
-    .gamma_set = crtc_gamma_set,
-    .shadow_create = crtc_shadow_create,
-    .shadow_allocate = crtc_shadow_allocate,
-    .shadow_destroy = crtc_shadow_destroy,
+    .set_mode_major = crtc_set_mode_major,
+
+    .set_cursor_colors = crtc_set_cursor_colors,
     .set_cursor_position = crtc_set_cursor_position,
     .show_cursor = crtc_show_cursor,
     .hide_cursor = crtc_hide_cursor,
-    .load_cursor_image = NULL,        /* lets convert to argb only */
-    .set_cursor_colors = NULL,        /* using argb only */
     .load_cursor_argb = crtc_load_cursor_argb,
-    .destroy = crtc_destroy,
-};
 
-void
-crtc_cursor_destroy(xf86CrtcPtr crtc)
-{
-    struct crtc_private *crtcp = crtc->driver_private;
+    .shadow_create = crtc_shadow_create,
+    .shadow_allocate = crtc_shadow_allocate,
+    .shadow_destroy = crtc_shadow_destroy,
 
-    if (crtcp->cursor_tex) {
-       pipe_texture_reference(&crtcp->cursor_tex, NULL);
-    }
-}
+    .gamma_set = crtc_gamma_set,
+    .destroy = crtc_destroy,
+};
 
 void
-crtc_init(ScrnInfoPtr pScrn)
+xorg_crtc_init(ScrnInfoPtr pScrn)
 {
     modesettingPtr ms = modesettingPTR(pScrn);
     xf86CrtcPtr crtc;
@@ -309,6 +370,7 @@ crtc_init(ScrnInfoPtr pScrn)
 
     for (c = 0; c < res->count_crtcs; c++) {
        drm_crtc = drmModeGetCrtc(ms->fd, res->crtcs[c]);
+
        if (!drm_crtc)
            continue;
 
@@ -325,7 +387,6 @@ crtc_init(ScrnInfoPtr pScrn)
        crtcp->drm_crtc = drm_crtc;
 
        crtc->driver_private = crtcp;
-
     }
 
   out:
index 8a362596c751d21fd4af8b7b846d12562305eda5..fd82f4fa1d1db4d31aca8003aac5db16446f6c82 100644 (file)
 #include "pipe/p_state.h"
 #include "pipe/p_inlines.h"
 
+#include "util/u_format.h"
 #include "util/u_rect.h"
 
+/* Make all the #if cases in the code esier to read */
+/* XXX can it be set to 1? */
+#ifndef DRI2INFOREC_VERSION
+#define DRI2INFOREC_VERSION 0
+#endif
+
 typedef struct {
     PixmapPtr pPixmap;
     struct pipe_texture *tex;
@@ -49,7 +56,7 @@ typedef struct {
 } *BufferPrivatePtr;
 
 static Bool
-driDoCreateBuffer(DrawablePtr pDraw, DRI2BufferPtr buffer, unsigned int format)
+dri2_do_create_buffer(DrawablePtr pDraw, DRI2BufferPtr buffer, unsigned int format)
 {
     struct pipe_texture *tex = NULL;
     ScreenPtr pScreen = pDraw->pScreen;
@@ -79,13 +86,16 @@ driDoCreateBuffer(DrawablePtr pDraw, DRI2BufferPtr buffer, unsigned int format)
     case DRI2BufferFrontLeft:
        break;
     case DRI2BufferStencil:
-#if defined(DRI2INFOREC_VERSION) && DRI2INFOREC_VERSION > 2
+#if DRI2INFOREC_VERSION >= 3
     case DRI2BufferDepthStencil:
+#else
+    /* Works on old X servers because sanity checking is for the weak */
+    case 9:
+#endif
        if (exa_priv->depth_stencil_tex &&
-           !pf_is_depth_stencil(exa_priv->depth_stencil_tex->format))
+           !util_format_is_depth_or_stencil(exa_priv->depth_stencil_tex->format))
            exa_priv->depth_stencil_tex = NULL;
         /* Fall through */
-#endif
     case DRI2BufferDepth:
        if (exa_priv->depth_stencil_tex)
            pipe_texture_reference(&tex, exa_priv->depth_stencil_tex);
@@ -99,10 +109,9 @@ driDoCreateBuffer(DrawablePtr pDraw, DRI2BufferPtr buffer, unsigned int format)
            else
                template.format = ms->ds_depth_bits_last ?
                    PIPE_FORMAT_S8Z24_UNORM : PIPE_FORMAT_Z24S8_UNORM;
-           pf_get_block(template.format, &template.block);
-           template.width[0] = pDraw->width;
-           template.height[0] = pDraw->height;
-           template.depth[0] = 1;
+           template.width0 = pDraw->width;
+           template.height0 = pDraw->height;
+           template.depth0 = 1;
            template.last_level = 0;
            template.tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL |
                PIPE_TEXTURE_USAGE_DISPLAY_TARGET;
@@ -118,9 +127,12 @@ driDoCreateBuffer(DrawablePtr pDraw, DRI2BufferPtr buffer, unsigned int format)
     }
 
     if (!tex) {
+       /* First call to make sure we have a pixmap private */
        exaMoveInPixmap(private->pPixmap);
        xorg_exa_set_shared_usage(private->pPixmap);
        pScreen->ModifyPixmapHeader(private->pPixmap, 0, 0, 0, 0, 0, NULL);
+       /* Second call to make sure texture has valid contents */
+       exaMoveInPixmap(private->pPixmap);
        tex = xorg_exa_get_texture(private->pPixmap);
     }
 
@@ -134,13 +146,18 @@ driDoCreateBuffer(DrawablePtr pDraw, DRI2BufferPtr buffer, unsigned int format)
     buffer->cpp = 4;
     buffer->driverPrivate = private;
     buffer->flags = 0; /* not tiled */
+#if DRI2INFOREC_VERSION == 2
+    ((DRI2Buffer2Ptr)buffer)->format = 0;
+#elif DRI2INFOREC_VERSION >= 3
+    buffer->format = 0;
+#endif
     private->tex = tex;
 
     return TRUE;
 }
 
 static void
-driDoDestroyBuffer(DrawablePtr pDraw, DRI2BufferPtr buffer)
+dri2_do_destroy_buffer(DrawablePtr pDraw, DRI2BufferPtr buffer)
 {
     ScreenPtr pScreen = pDraw->pScreen;
     ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
@@ -154,12 +171,12 @@ driDoDestroyBuffer(DrawablePtr pDraw, DRI2BufferPtr buffer)
     (*pScreen->DestroyPixmap)(private->pPixmap);
 }
 
-#if defined(DRI2INFOREC_VERSION) && DRI2INFOREC_VERSION > 2
+#if DRI2INFOREC_VERSION >= 2
 
-static DRI2BufferPtr
-driCreateBuffer(DrawablePtr pDraw, unsigned int attachment, unsigned int format)
+static DRI2Buffer2Ptr
+dri2_create_buffer(DrawablePtr pDraw, unsigned int attachment, unsigned int format)
 {
-    DRI2BufferPtr buffer;
+    DRI2Buffer2Ptr buffer;
     BufferPrivatePtr private;
 
     buffer = xcalloc(1, sizeof *buffer);
@@ -174,7 +191,8 @@ driCreateBuffer(DrawablePtr pDraw, unsigned int attachment, unsigned int format)
     buffer->attachment = attachment;
     buffer->driverPrivate = private;
 
-    if (driDoCreateBuffer(pDraw, buffer, format))
+    /* So far it is safe to downcast a DRI2Buffer2Ptr to DRI2BufferPtr */
+    if (dri2_do_create_buffer(pDraw, (DRI2BufferPtr)buffer, format))
        return buffer;
 
     xfree(private);
@@ -184,18 +202,19 @@ fail:
 }
 
 static void
-driDestroyBuffer(DrawablePtr pDraw, DRI2BufferPtr buffer)
+dri2_destroy_buffer(DrawablePtr pDraw, DRI2Buffer2Ptr buffer)
 {
-    driDoDestroyBuffer(pDraw, buffer);
+    /* So far it is safe to downcast a DRI2Buffer2Ptr to DRI2BufferPtr */
+    dri2_do_destroy_buffer(pDraw, (DRI2BufferPtr)buffer);
 
     xfree(buffer->driverPrivate);
     xfree(buffer);
 }
 
-#else /* DRI2INFOREC_VERSION <= 2 */
+#else /* DRI2INFOREC_VERSION < 2 */
 
 static DRI2BufferPtr
-driCreateBuffers(DrawablePtr pDraw, unsigned int *attachments, int count)
+dri2_create_buffers(DrawablePtr pDraw, unsigned int *attachments, int count)
 {
     BufferPrivatePtr privates;
     DRI2BufferPtr buffers;
@@ -213,7 +232,7 @@ driCreateBuffers(DrawablePtr pDraw, unsigned int *attachments, int count)
        buffers[i].attachment = attachments[i];
        buffers[i].driverPrivate = &privates[i];
 
-       if (!driDoCreateBuffer(pDraw, &buffers[i], 0))
+       if (!dri2_do_create_buffer(pDraw, &buffers[i], 0))
            goto fail;
     }
 
@@ -228,12 +247,12 @@ fail_buffers:
 }
 
 static void
-driDestroyBuffers(DrawablePtr pDraw, DRI2BufferPtr buffers, int count)
+dri2_destroy_buffers(DrawablePtr pDraw, DRI2BufferPtr buffers, int count)
 {
     int i;
 
     for (i = 0; i < count; i++) {
-       driDoDestroyBuffer(pDraw, &buffers[i]);
+       dri2_do_destroy_buffer(pDraw, &buffers[i]);
     }
 
     if (buffers) {
@@ -242,21 +261,22 @@ driDestroyBuffers(DrawablePtr pDraw, DRI2BufferPtr buffers, int count)
     }
 }
 
-#endif /* DRI2INFOREC_VERSION */
+#endif /* DRI2INFOREC_VERSION >= 2 */
 
 static void
-driCopyRegion(DrawablePtr pDraw, RegionPtr pRegion,
-              DRI2BufferPtr pDestBuffer, DRI2BufferPtr pSrcBuffer)
+dri2_copy_region(DrawablePtr pDraw, RegionPtr pRegion,
+                 DRI2BufferPtr pDestBuffer, DRI2BufferPtr pSrcBuffer)
 {
     ScreenPtr pScreen = pDraw->pScreen;
     ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
     modesettingPtr ms = modesettingPTR(pScrn);
     BufferPrivatePtr dst_priv = pDestBuffer->driverPrivate;
     BufferPrivatePtr src_priv = pSrcBuffer->driverPrivate;
-    PixmapPtr src_pixmap;
-    PixmapPtr dst_pixmap;
+    DrawablePtr src_draw;
+    DrawablePtr dst_draw;
     GCPtr gc;
     RegionPtr copy_clip;
+    Bool save_accel;
 
     /*
      * In driCreateBuffers we dewrap windows into the
@@ -264,12 +284,10 @@ driCopyRegion(DrawablePtr pDraw, RegionPtr pRegion,
      * We need to use the real drawable in CopyArea
      * so that cliprects and offsets are correct.
      */
-    src_pixmap = src_priv->pPixmap;
-    dst_pixmap = dst_priv->pPixmap;
-    if (pSrcBuffer->attachment == DRI2BufferFrontLeft)
-       src_pixmap = (PixmapPtr)pDraw;
-    if (pDestBuffer->attachment == DRI2BufferFrontLeft)
-       dst_pixmap = (PixmapPtr)pDraw;
+    src_draw = (pSrcBuffer->attachment == DRI2BufferFrontLeft) ? pDraw :
+       &src_priv->pPixmap->drawable;
+    dst_draw = (pDestBuffer->attachment == DRI2BufferFrontLeft) ? pDraw :
+       &dst_priv->pPixmap->drawable;
 
     /*
      * The clients implements glXWaitX with a copy front to fake and then
@@ -288,7 +306,7 @@ driCopyRegion(DrawablePtr pDraw, RegionPtr pRegion,
      * must in the glXWaitGL case but we don't know if this is a glXWaitGL
      * or a glFlush/glFinish call.
      */
-    if (dst_pixmap == src_pixmap) {
+    if (dst_priv->pPixmap == src_priv->pPixmap) {
        /* pixmap glXWaitX */
        if (pSrcBuffer->attachment == DRI2BufferFrontLeft &&
            pDestBuffer->attachment == DRI2BufferFakeFrontLeft) {
@@ -309,7 +327,7 @@ driCopyRegion(DrawablePtr pDraw, RegionPtr pRegion,
     copy_clip = REGION_CREATE(pScreen, NULL, 0);
     REGION_COPY(pScreen, copy_clip, pRegion);
     (*gc->funcs->ChangeClip) (gc, CT_REGION, copy_clip, 0);
-    ValidateGC(&dst_pixmap->drawable, gc);
+    ValidateGC(dst_draw, gc);
 
     /* If this is a full buffer swap, throttle on the previous one */
     if (dst_priv->fence && REGION_NUM_RECTS(pRegion) == 1) {
@@ -322,8 +340,21 @@ driCopyRegion(DrawablePtr pDraw, RegionPtr pRegion,
        }
     }
 
-    (*gc->ops->CopyArea)(&src_pixmap->drawable, &dst_pixmap->drawable, gc,
+    /* Try to make sure the blit will be accelerated */
+    save_accel = ms->exa->accel;
+    ms->exa->accel = TRUE;
+
+    /* In case it won't be though, make sure the GPU copy contents of the
+     * source pixmap will be used for the software fallback - presumably the
+     * client modified them before calling in here.
+     */
+    exaMoveInPixmap(src_priv->pPixmap);
+    DamageRegionAppend(src_draw, pRegion);
+    DamageRegionProcessPending(src_draw);
+
+    (*gc->ops->CopyArea)(src_draw, dst_draw, gc,
                         0, 0, pDraw->width, pDraw->height, 0, 0);
+    ms->exa->accel = save_accel;
 
     FreeScratchGC(gc);
 
@@ -333,13 +364,13 @@ driCopyRegion(DrawablePtr pDraw, RegionPtr pRegion,
 }
 
 Bool
-driScreenInit(ScreenPtr pScreen)
+xorg_dri2_init(ScreenPtr pScreen)
 {
     ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
     modesettingPtr ms = modesettingPTR(pScrn);
     DRI2InfoRec dri2info;
 
-#if defined(DRI2INFOREC_VERSION)
+#if DRI2INFOREC_VERSION >= 2
     dri2info.version = DRI2INFOREC_VERSION;
 #else
     dri2info.version = 1;
@@ -349,14 +380,14 @@ driScreenInit(ScreenPtr pScreen)
     dri2info.driverName = pScrn->driverName;
     dri2info.deviceName = "/dev/dri/card0"; /* FIXME */
 
-#if defined(DRI2INFOREC_VERSION) && DRI2INFOREC_VERSION > 2
-    dri2info.CreateBuffer = driCreateBuffer;
-    dri2info.DestroyBuffer = driDestroyBuffer;
+#if DRI2INFOREC_VERSION >= 2
+    dri2info.CreateBuffer = dri2_create_buffer;
+    dri2info.DestroyBuffer = dri2_destroy_buffer;
 #else
-    dri2info.CreateBuffers = driCreateBuffers;
-    dri2info.DestroyBuffers = driDestroyBuffers;
+    dri2info.CreateBuffers = dri2_create_buffers;
+    dri2info.DestroyBuffers = dri2_destroy_buffers;
 #endif
-    dri2info.CopyRegion = driCopyRegion;
+    dri2info.CopyRegion = dri2_copy_region;
     dri2info.Wait = NULL;
 
     ms->d_depth_bits_last =
@@ -372,7 +403,7 @@ driScreenInit(ScreenPtr pScreen)
 }
 
 void
-driCloseScreen(ScreenPtr pScreen)
+xorg_dri2_close(ScreenPtr pScreen)
 {
     DRI2CloseScreen(pScreen);
 }
index 4bc87aa613d083ab3bc454666fc627a3cb26544f..b02fe68f313aee83aab0bf1488db8a5892ee4a65 100644 (file)
 #include "xorg_tracker.h"
 #include "xorg_winsys.h"
 
-static void AdjustFrame(int scrnIndex, int x, int y, int flags);
-static Bool CloseScreen(int scrnIndex, ScreenPtr pScreen);
-static Bool EnterVT(int scrnIndex, int flags);
-static Bool SaveHWState(ScrnInfoPtr pScrn);
-static Bool RestoreHWState(ScrnInfoPtr pScrn);
-
-
-static ModeStatus ValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose,
-                           int flags);
-static void FreeScreen(int scrnIndex, int flags);
-static void LeaveVT(int scrnIndex, int flags);
-static Bool SwitchMode(int scrnIndex, DisplayModePtr mode, int flags);
-static Bool ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc,
-                      char **argv);
-static Bool PreInit(ScrnInfoPtr pScrn, int flags);
+#ifdef HAVE_LIBKMS
+#include "libkms.h"
+#endif
+
+/*
+ * Functions and symbols exported to Xorg via pointers.
+ */
+
+static Bool drv_pre_init(ScrnInfoPtr pScrn, int flags);
+static Bool drv_screen_init(int scrnIndex, ScreenPtr pScreen, int argc,
+                           char **argv);
+static Bool drv_switch_mode(int scrnIndex, DisplayModePtr mode, int flags);
+static void drv_adjust_frame(int scrnIndex, int x, int y, int flags);
+static Bool drv_enter_vt(int scrnIndex, int flags);
+static void drv_leave_vt(int scrnIndex, int flags);
+static void drv_free_screen(int scrnIndex, int flags);
+static ModeStatus drv_valid_mode(int scrnIndex, DisplayModePtr mode, Bool verbose,
+                                int flags);
 
 typedef enum
 {
     OPTION_SW_CURSOR,
-} modesettingOpts;
+    OPTION_2D_ACCEL,
+} drv_option_enums;
 
-static const OptionInfoRec Options[] = {
+static const OptionInfoRec drv_options[] = {
     {OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE},
+    {OPTION_2D_ACCEL, "2DAccel", OPTV_BOOLEAN, {0}, FALSE},
     {-1, NULL, OPTV_NONE, {0}, FALSE}
 };
 
+
 /*
  * Exported Xorg driver functions to winsys
  */
@@ -89,28 +95,39 @@ static const OptionInfoRec Options[] = {
 const OptionInfoRec *
 xorg_tracker_available_options(int chipid, int busid)
 {
-    return Options;
+    return drv_options;
 }
 
 void
 xorg_tracker_set_functions(ScrnInfoPtr scrn)
 {
-    scrn->PreInit = PreInit;
-    scrn->ScreenInit = ScreenInit;
-    scrn->SwitchMode = SwitchMode;
-    scrn->AdjustFrame = AdjustFrame;
-    scrn->EnterVT = EnterVT;
-    scrn->LeaveVT = LeaveVT;
-    scrn->FreeScreen = FreeScreen;
-    scrn->ValidMode = ValidMode;
+    scrn->PreInit = drv_pre_init;
+    scrn->ScreenInit = drv_screen_init;
+    scrn->SwitchMode = drv_switch_mode;
+    scrn->AdjustFrame = drv_adjust_frame;
+    scrn->EnterVT = drv_enter_vt;
+    scrn->LeaveVT = drv_leave_vt;
+    scrn->FreeScreen = drv_free_screen;
+    scrn->ValidMode = drv_valid_mode;
 }
 
+
+/*
+ * Internal function definitions
+ */
+
+static Bool drv_init_front_buffer_functions(ScrnInfoPtr pScrn);
+static Bool drv_close_screen(int scrnIndex, ScreenPtr pScreen);
+static Bool drv_save_hw_state(ScrnInfoPtr pScrn);
+static Bool drv_restore_hw_state(ScrnInfoPtr pScrn);
+
+
 /*
- * Static Xorg funtctions
+ * Internal functions
  */
 
 static Bool
-GetRec(ScrnInfoPtr pScrn)
+drv_get_rec(ScrnInfoPtr pScrn)
 {
     if (pScrn->driverPrivate)
        return TRUE;
@@ -121,7 +138,7 @@ GetRec(ScrnInfoPtr pScrn)
 }
 
 static void
-FreeRec(ScrnInfoPtr pScrn)
+drv_free_rec(ScrnInfoPtr pScrn)
 {
     if (!pScrn)
        return;
@@ -135,85 +152,143 @@ FreeRec(ScrnInfoPtr pScrn)
 }
 
 static void
-ProbeDDC(ScrnInfoPtr pScrn, int index)
+drv_probe_ddc(ScrnInfoPtr pScrn, int index)
 {
     ConfiguredMonitor = NULL;
 }
 
 static Bool
-CreateFrontBuffer(ScrnInfoPtr pScrn)
+drv_crtc_resize(ScrnInfoPtr pScrn, int width, int height)
 {
     modesettingPtr ms = modesettingPTR(pScrn);
+    PixmapPtr rootPixmap;
     ScreenPtr pScreen = pScrn->pScreen;
-    PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen);
-    unsigned handle, stride;
 
-    ms->noEvict = TRUE;
-    xorg_exa_set_displayed_usage(rootPixmap);
-    pScreen->ModifyPixmapHeader(rootPixmap,
-                               pScrn->virtualX, pScrn->virtualY,
-                               pScrn->depth, pScrn->bitsPerPixel,
-                               pScrn->displayWidth * pScrn->bitsPerPixel / 8,
-                               NULL);
-    ms->noEvict = FALSE;
+    if (width == pScrn->virtualX && height == pScrn->virtualY)
+       return TRUE;
+
+    pScrn->virtualX = width;
+    pScrn->virtualY = height;
 
-    handle = xorg_exa_get_pixmap_handle(rootPixmap, &stride);
+    /*
+     * Remove the old framebuffer & texture.
+     */
+    drmModeRmFB(ms->fd, ms->fb_id);
+    if (!ms->destroy_front_buffer(pScrn))
+       FatalError("failed to destroy front buffer\n");
 
-    drmModeAddFB(ms->fd,
-                pScrn->virtualX,
-                pScrn->virtualY,
-                pScrn->depth,
-                pScrn->bitsPerPixel,
-                stride,
-                handle,
-                &ms->fb_id);
+    rootPixmap = pScreen->GetScreenPixmap(pScreen);
+    if (!pScreen->ModifyPixmapHeader(rootPixmap, width, height, -1, -1, -1, NULL))
+       return FALSE;
 
-    pScrn->frameX0 = 0;
-    pScrn->frameY0 = 0;
-    AdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+    pScrn->displayWidth = rootPixmap->devKind / (rootPixmap->drawable.bitsPerPixel / 8);
+
+    /* now create new frontbuffer */
+    return ms->create_front_buffer(pScrn) && ms->bind_front_buffer(pScrn);
+}
+
+static const xf86CrtcConfigFuncsRec crtc_config_funcs = {
+    .resize = drv_crtc_resize
+};
+
+static Bool
+drv_init_drm(ScrnInfoPtr pScrn)
+{
+    modesettingPtr ms = modesettingPTR(pScrn);
+
+    /* deal with server regeneration */
+    if (ms->fd < 0) {
+       char *BusID;
+
+       BusID = xalloc(64);
+       sprintf(BusID, "PCI:%d:%d:%d",
+               ((ms->PciInfo->domain << 8) | ms->PciInfo->bus),
+               ms->PciInfo->dev, ms->PciInfo->func
+           );
+
+       ms->fd = drmOpen(NULL, BusID);
+
+       if (ms->fd < 0)
+           return FALSE;
+    }
 
     return TRUE;
 }
 
 static Bool
-crtc_resize(ScrnInfoPtr pScrn, int width, int height)
+drv_init_resource_management(ScrnInfoPtr pScrn)
 {
     modesettingPtr ms = modesettingPTR(pScrn);
-    //ScreenPtr pScreen = pScrn->pScreen;
-    //PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen);
-    //Bool fbAccessDisabled;
-    //CARD8 *fbstart;
+    /*
+    ScreenPtr pScreen = pScrn->pScreen;
+    PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen);
+    Bool fbAccessDisabled;
+    CARD8 *fbstart;
+     */
 
-    if (width == pScrn->virtualX && height == pScrn->virtualY)
+    if (ms->screen || ms->kms)
        return TRUE;
 
-    ErrorF("RESIZING TO %dx%d\n", width, height);
+    ms->api = drm_api_create();
+    if (ms->api) {
+       ms->screen = ms->api->create_screen(ms->api, ms->fd, NULL);
 
-    pScrn->virtualX = width;
-    pScrn->virtualY = height;
+       if (ms->screen)
+           return TRUE;
 
-    /* HW dependent - FIXME */
-    pScrn->displayWidth = pScrn->virtualX;
+       if (ms->api->destroy)
+           ms->api->destroy(ms->api);
 
-    drmModeRmFB(ms->fd, ms->fb_id);
+       ms->api = NULL;
+    }
 
-    /* now create new frontbuffer */
-    return CreateFrontBuffer(pScrn);
+#ifdef HAVE_LIBKMS
+    if (!kms_create(ms->fd, &ms->kms))
+       return TRUE;
+#endif
+
+    return FALSE;
 }
 
-static const xf86CrtcConfigFuncsRec crtc_config_funcs = {
-    crtc_resize
-};
+static Bool
+drv_close_resource_management(ScrnInfoPtr pScrn)
+{
+    modesettingPtr ms = modesettingPTR(pScrn);
+    int i;
+
+    if (ms->screen) {
+       assert(ms->ctx == NULL);
+
+       for (i = 0; i < XORG_NR_FENCES; i++) {
+           if (ms->fence[i]) {
+               ms->screen->fence_finish(ms->screen, ms->fence[i], 0);
+               ms->screen->fence_reference(ms->screen, &ms->fence[i], NULL);
+           }
+       }
+       ms->screen->destroy(ms->screen);
+    }
+    ms->screen = NULL;
+
+    if (ms->api && ms->api->destroy)
+       ms->api->destroy(ms->api);
+    ms->api = NULL;
+
+#ifdef HAVE_LIBKMS
+    if (ms->kms)
+       kms_destroy(&ms->kms);
+#endif
+
+    return TRUE;
+}
 
 static Bool
-PreInit(ScrnInfoPtr pScrn, int flags)
+drv_pre_init(ScrnInfoPtr pScrn, int flags)
 {
     xf86CrtcConfigPtr xf86_config;
     modesettingPtr ms;
     rgb defaultWeight = { 0, 0, 0 };
     EntityInfoPtr pEnt;
     EntPtr msEnt = NULL;
-    char *BusID;
     int max_width, max_height;
 
     if (pScrn->numEntities != 1)
@@ -222,12 +297,12 @@ PreInit(ScrnInfoPtr pScrn, int flags)
     pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
 
     if (flags & PROBE_DETECT) {
-       ProbeDDC(pScrn, pEnt->index);
+       drv_probe_ddc(pScrn, pEnt->index);
        return TRUE;
     }
 
     /* Allocate driverPrivate */
-    if (!GetRec(pScrn))
+    if (!drv_get_rec(pScrn))
        return FALSE;
 
     ms = modesettingPTR(pScrn);
@@ -262,16 +337,9 @@ PreInit(ScrnInfoPtr pScrn, int flags)
        }
     }
 
-    BusID = xalloc(64);
-    sprintf(BusID, "PCI:%d:%d:%d",
-           ((ms->PciInfo->domain << 8) | ms->PciInfo->bus),
-           ms->PciInfo->dev, ms->PciInfo->func
-       );
-
-    ms->api = drm_api_create();
-    ms->fd = drmOpen(NULL, BusID);
-
-    if (ms->fd < 0)
+    ms->fd = -1;
+    ms->api = NULL;
+    if (!drv_init_drm(pScrn))
        return FALSE;
 
     pScrn->monitor = pScrn->confScreen->monitor;
@@ -303,9 +371,9 @@ PreInit(ScrnInfoPtr pScrn, int flags)
 
     /* Process the options */
     xf86CollectOptions(pScrn, NULL);
-    if (!(ms->Options = xalloc(sizeof(Options))))
+    if (!(ms->Options = xalloc(sizeof(drv_options))))
        return FALSE;
-    memcpy(ms->Options, Options, sizeof(Options));
+    memcpy(ms->Options, drv_options, sizeof(drv_options));
     xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, ms->Options);
 
     /* Allocate an xf86CrtcConfig */
@@ -320,18 +388,18 @@ PreInit(ScrnInfoPtr pScrn, int flags)
        ms->SWCursor = TRUE;
     }
 
-    SaveHWState(pScrn);
+    drv_save_hw_state(pScrn);
 
-    crtc_init(pScrn);
-    output_init(pScrn);
+    xorg_crtc_init(pScrn);
+    xorg_output_init(pScrn);
 
     if (!xf86InitialConfiguration(pScrn, TRUE)) {
        xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes.\n");
-       RestoreHWState(pScrn);
+       drv_restore_hw_state(pScrn);
        return FALSE;
     }
 
-    RestoreHWState(pScrn);
+    drv_restore_hw_state(pScrn);
 
     /*
      * If the driver can do gamma correction, it should call xf86SetGamma() here.
@@ -355,21 +423,23 @@ PreInit(ScrnInfoPtr pScrn, int flags)
     xf86SetDpi(pScrn, 0, 0);
 
     /* Load the required sub modules */
-    if (!xf86LoadSubModule(pScrn, "fb")) {
+    if (!xf86LoadSubModule(pScrn, "fb"))
        return FALSE;
-    }
 
-    xf86LoadSubModule(pScrn, "exa");
+    /* XXX: these aren't needed when we are using libkms */
+    if (!xf86LoadSubModule(pScrn, "exa"))
+       return FALSE;
 
 #ifdef DRI2
-    xf86LoadSubModule(pScrn, "dri2");
+    if (!xf86LoadSubModule(pScrn, "dri2"))
+       return FALSE;
 #endif
 
     return TRUE;
 }
 
 static Bool
-SaveHWState(ScrnInfoPtr pScrn)
+drv_save_hw_state(ScrnInfoPtr pScrn)
 {
     /*xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);*/
 
@@ -377,24 +447,45 @@ SaveHWState(ScrnInfoPtr pScrn)
 }
 
 static Bool
-RestoreHWState(ScrnInfoPtr pScrn)
+drv_restore_hw_state(ScrnInfoPtr pScrn)
 {
     /*xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);*/
 
     return TRUE;
 }
 
-static void xorgBlockHandler(int i, pointer blockData, pointer pTimeout,
-                             pointer pReadmask)
+static void drv_block_handler(int i, pointer blockData, pointer pTimeout,
+                              pointer pReadmask)
 {
     ScreenPtr pScreen = screenInfo.screens[i];
     modesettingPtr ms = modesettingPTR(xf86Screens[pScreen->myNum]);
 
     pScreen->BlockHandler = ms->blockHandler;
     pScreen->BlockHandler(i, blockData, pTimeout, pReadmask);
-    pScreen->BlockHandler = xorgBlockHandler;
-
-    ms->ctx->flush(ms->ctx, PIPE_FLUSH_RENDER_CACHE, NULL);
+    pScreen->BlockHandler = drv_block_handler;
+
+    if (ms->ctx) {
+       int j;
+
+       ms->ctx->flush(ms->ctx, PIPE_FLUSH_RENDER_CACHE, &ms->fence[XORG_NR_FENCES-1]);
+       
+       if (ms->fence[0])
+          ms->ctx->screen->fence_finish(ms->ctx->screen, ms->fence[0], 0);
+  
+       /* The amount of rendering generated by a block handler can be
+        * quite small.  Let us get a fair way ahead of hardware before
+        * throttling.
+        */
+       for (j = 0; j < XORG_NR_FENCES - 1; j++)
+          ms->screen->fence_reference(ms->screen,
+                                      &ms->fence[j],
+                                      ms->fence[j+1]);
+
+       ms->screen->fence_reference(ms->screen,
+                                   &ms->fence[XORG_NR_FENCES-1],
+                                   NULL);
+    }
+        
 
 #ifdef DRM_MODE_FEATURE_DIRTYFB
     {
@@ -404,17 +495,22 @@ static void xorgBlockHandler(int i, pointer blockData, pointer pTimeout,
        if (num_cliprects) {
            drmModeClip *clip = alloca(num_cliprects * sizeof(drmModeClip));
            BoxPtr rect = REGION_RECTS(dirty);
-           int i;
+           int i, ret;
 
+           /* XXX no need for copy? */
            for (i = 0; i < num_cliprects; i++, rect++) {
-               clip[i].x = rect->x1;
-               clip[i].y = rect->y1;
-               clip[i].width = rect->x2 - rect->x1;
-               clip[i].height = rect->y2 - rect->y1;
+               clip[i].x1 = rect->x1;
+               clip[i].y1 = rect->y1;
+               clip[i].x2 = rect->x2;
+               clip[i].y2 = rect->y2;
            }
 
            /* TODO query connector property to see if this is needed */
-           drmModeDirtyFB(ms->fd, ms->fb_id, clip, num_cliprects);
+           ret = drmModeDirtyFB(ms->fd, ms->fb_id, clip, num_cliprects);
+           if (ret) {
+               debug_printf("%s: failed to send dirty (%i, %s)\n",
+                            __func__, ret, strerror(-ret));
+           }
 
            DamageEmpty(ms->damage);
        }
@@ -423,43 +519,27 @@ static void xorgBlockHandler(int i, pointer blockData, pointer pTimeout,
 }
 
 static Bool
-CreateScreenResources(ScreenPtr pScreen)
+drv_create_screen_resources(ScreenPtr pScreen)
 {
     ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
     modesettingPtr ms = modesettingPTR(pScrn);
     PixmapPtr rootPixmap;
     Bool ret;
-    unsigned handle, stride;
 
     ms->noEvict = TRUE;
 
     pScreen->CreateScreenResources = ms->createScreenResources;
     ret = pScreen->CreateScreenResources(pScreen);
-    pScreen->CreateScreenResources = CreateScreenResources;
-
-    rootPixmap = pScreen->GetScreenPixmap(pScreen);
+    pScreen->CreateScreenResources = drv_create_screen_resources;
 
-    xorg_exa_set_displayed_usage(rootPixmap);
-    xorg_exa_set_shared_usage(rootPixmap);
-    if (!pScreen->ModifyPixmapHeader(rootPixmap, -1, -1, -1, -1, -1, NULL))
-       FatalError("Couldn't adjust screen pixmap\n");
+    ms->bind_front_buffer(pScrn);
 
     ms->noEvict = FALSE;
 
-    handle = xorg_exa_get_pixmap_handle(rootPixmap, &stride);
-
-    drmModeAddFB(ms->fd,
-                pScrn->virtualX,
-                pScrn->virtualY,
-                pScrn->depth,
-                pScrn->bitsPerPixel,
-                stride,
-                handle,
-                 &ms->fb_id);
-
-    AdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+    drv_adjust_frame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
 
 #ifdef DRM_MODE_FEATURE_DIRTYFB
+    rootPixmap = pScreen->GetScreenPixmap(pScreen);
     ms->damage = DamageCreate(NULL, NULL, DamageReportNone, TRUE,
                               pScreen, rootPixmap);
 
@@ -472,41 +552,33 @@ CreateScreenResources(ScreenPtr pScreen)
                   "Failed to create screen damage record\n");
        return FALSE;
     }
+#else
+    (void)rootPixmap;
 #endif
 
     return ret;
 }
 
 static Bool
-ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+drv_screen_init(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
 {
     ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
     modesettingPtr ms = modesettingPTR(pScrn);
     VisualPtr visual;
 
-    /* deal with server regeneration */
-    if (ms->fd < 0) {
-       char *BusID;
-
-       BusID = xalloc(64);
-       sprintf(BusID, "PCI:%d:%d:%d",
-               ((ms->PciInfo->domain << 8) | ms->PciInfo->bus),
-               ms->PciInfo->dev, ms->PciInfo->func
-           );
-
-       ms->fd = drmOpen(NULL, BusID);
-
-       if (ms->fd < 0)
-           return FALSE;
+    if (!drv_init_drm(pScrn)) {
+       FatalError("Could not init DRM");
+       return FALSE;
     }
 
-    if (!ms->screen) {
-       ms->screen = ms->api->create_screen(ms->api, ms->fd, NULL);
+    if (!drv_init_resource_management(pScrn)) {
+       FatalError("Could not init resource management (!pipe_screen && !libkms)");
+       return FALSE;
+    }
 
-       if (!ms->screen) {
-           FatalError("Could not init pipe_screen\n");
-           return FALSE;
-       }
+    if (!drv_init_front_buffer_functions(pScrn)) {
+       FatalError("Could not init front buffer manager");
+       return FALSE;
     }
 
     pScrn->pScreen = pScreen;
@@ -551,14 +623,22 @@ ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
     fbPictureInit(pScreen, NULL, 0);
 
     ms->blockHandler = pScreen->BlockHandler;
-    pScreen->BlockHandler = xorgBlockHandler;
+    pScreen->BlockHandler = drv_block_handler;
     ms->createScreenResources = pScreen->CreateScreenResources;
-    pScreen->CreateScreenResources = CreateScreenResources;
+    pScreen->CreateScreenResources = drv_create_screen_resources;
 
     xf86SetBlackWhitePixels(pScreen);
 
-    ms->exa = xorg_exa_init(pScrn);
-    ms->debug_fallback = debug_get_bool_option("XORG_DEBUG_FALLBACK", TRUE);
+    if (ms->screen) {
+       ms->exa = xorg_exa_init(pScrn, xf86ReturnOptValBool(ms->Options,
+                                                           OPTION_2D_ACCEL, TRUE));
+       ms->debug_fallback = debug_get_bool_option("XORG_DEBUG_FALLBACK", TRUE);
+
+       xorg_xv_init(pScreen);
+#ifdef DRI2
+       xorg_dri2_init(pScreen);
+#endif
+    }
 
     miInitializeBackingStore(pScreen);
     xf86SetBackingStore(pScreen);
@@ -577,7 +657,7 @@ ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
 
     pScreen->SaveScreen = xf86SaveScreen;
     ms->CloseScreen = pScreen->CloseScreen;
-    pScreen->CloseScreen = CloseScreen;
+    pScreen->CloseScreen = drv_close_screen;
 
     if (!xf86CrtcScreenInit(pScreen))
        return FALSE;
@@ -590,17 +670,14 @@ ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
     if (serverGeneration == 1)
        xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
 
-#if 1
-#ifdef DRI2
-    driScreenInit(pScreen);
-#endif
-#endif
+    if (ms->winsys_screen_init)
+       ms->winsys_screen_init(pScrn);
 
-    return EnterVT(scrnIndex, 1);
+    return drv_enter_vt(scrnIndex, 1);
 }
 
 static void
-AdjustFrame(int scrnIndex, int x, int y, int flags)
+drv_adjust_frame(int scrnIndex, int x, int y, int flags)
 {
     ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
@@ -608,31 +685,34 @@ AdjustFrame(int scrnIndex, int x, int y, int flags)
     xf86CrtcPtr crtc = output->crtc;
 
     if (crtc && crtc->enabled) {
-       crtc->funcs->mode_set(crtc, pScrn->currentMode, pScrn->currentMode, x,
-                             y);
+       crtc->funcs->set_mode_major(crtc, pScrn->currentMode,
+                                   RR_Rotate_0, x, y);
        crtc->x = output->initial_x + x;
        crtc->y = output->initial_y + y;
     }
 }
 
 static void
-FreeScreen(int scrnIndex, int flags)
+drv_free_screen(int scrnIndex, int flags)
 {
-    FreeRec(xf86Screens[scrnIndex]);
+    drv_free_rec(xf86Screens[scrnIndex]);
 }
 
 static void
-LeaveVT(int scrnIndex, int flags)
+drv_leave_vt(int scrnIndex, int flags)
 {
     ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
     modesettingPtr ms = modesettingPTR(pScrn);
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
     int o;
 
+    if (ms->winsys_leave_vt)
+       ms->winsys_leave_vt(pScrn);
+
     for (o = 0; o < config->num_crtc; o++) {
        xf86CrtcPtr crtc = config->crtc[o];
 
-       crtc_cursor_destroy(crtc);
+       xorg_crtc_cursor_destroy(crtc);
 
        if (crtc->rotatedPixmap || crtc->rotatedData) {
            crtc->funcs->shadow_destroy(crtc, crtc->rotatedPixmap,
@@ -644,7 +724,7 @@ LeaveVT(int scrnIndex, int flags)
 
     drmModeRmFB(ms->fd, ms->fb_id);
 
-    RestoreHWState(pScrn);
+    drv_restore_hw_state(pScrn);
 
     if (drmDropMaster(ms->fd))
        xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
@@ -657,7 +737,7 @@ LeaveVT(int scrnIndex, int flags)
  * This gets called when gaining control of the VT, and from ScreenInit().
  */
 static Bool
-EnterVT(int scrnIndex, int flags)
+drv_enter_vt(int scrnIndex, int flags)
 {
     ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
     modesettingPtr ms = modesettingPTR(pScrn);
@@ -679,20 +759,26 @@ EnterVT(int scrnIndex, int flags)
      */
     if (ms->SaveGeneration != serverGeneration) {
        ms->SaveGeneration = serverGeneration;
-       SaveHWState(pScrn);
+       drv_save_hw_state(pScrn);
     }
 
-    if (!flags)                               /* signals startup as we'll do this in CreateScreenResources */
-       CreateFrontBuffer(pScrn);
+    if (!ms->create_front_buffer(pScrn))
+       return FALSE;
+
+    if (!flags && !ms->bind_front_buffer(pScrn))
+       return FALSE;
 
     if (!xf86SetDesiredModes(pScrn))
        return FALSE;
 
+    if (ms->winsys_enter_vt)
+       ms->winsys_enter_vt(pScrn);
+
     return TRUE;
 }
 
 static Bool
-SwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
+drv_switch_mode(int scrnIndex, DisplayModePtr mode, int flags)
 {
     ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
 
@@ -700,16 +786,21 @@ SwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
 }
 
 static Bool
-CloseScreen(int scrnIndex, ScreenPtr pScreen)
+drv_close_screen(int scrnIndex, ScreenPtr pScreen)
 {
     ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
     modesettingPtr ms = modesettingPTR(pScrn);
 
     if (pScrn->vtSema) {
-       LeaveVT(scrnIndex, 0);
+       drv_leave_vt(scrnIndex, 0);
     }
+
+    if (ms->winsys_screen_close)
+       ms->winsys_screen_close(pScrn);
+
 #ifdef DRI2
-    driCloseScreen(pScreen);
+    if (ms->screen)
+       xorg_dri2_close(pScreen);
 #endif
 
     pScreen->BlockHandler = ms->blockHandler;
@@ -723,12 +814,14 @@ CloseScreen(int scrnIndex, ScreenPtr pScreen)
     }
 #endif
 
+    drmModeRmFB(ms->fd, ms->fb_id);
+    ms->destroy_front_buffer(pScrn);
+
     if (ms->exa)
        xorg_exa_close(pScrn);
+    ms->exa = NULL;
 
-    if (ms->api->destroy)
-       ms->api->destroy(ms->api);
-    ms->api = NULL;
+    drv_close_resource_management(pScrn);
 
     drmClose(ms->fd);
     ms->fd = -1;
@@ -739,9 +832,217 @@ CloseScreen(int scrnIndex, ScreenPtr pScreen)
 }
 
 static ModeStatus
-ValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
+drv_valid_mode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
 {
     return MODE_OK;
 }
 
+
+/*
+ * Front buffer backing store functions.
+ */
+
+static Bool
+drv_destroy_front_buffer_ga3d(ScrnInfoPtr pScrn)
+{
+    modesettingPtr ms = modesettingPTR(pScrn);
+    pipe_texture_reference(&ms->root_texture, NULL);
+    return TRUE;
+}
+
+static Bool
+drv_create_front_buffer_ga3d(ScrnInfoPtr pScrn)
+{
+    modesettingPtr ms = modesettingPTR(pScrn);
+    unsigned handle, stride;
+    struct pipe_texture *tex;
+    int ret;
+
+    ms->noEvict = TRUE;
+
+    tex = xorg_exa_create_root_texture(pScrn, pScrn->virtualX, pScrn->virtualY,
+                                      pScrn->depth, pScrn->bitsPerPixel);
+
+    if (!tex)
+       return FALSE;
+
+    if (!ms->api->local_handle_from_texture(ms->api, ms->screen,
+                                           tex,
+                                           &stride,
+                                           &handle))
+       goto err_destroy;
+
+    ret = drmModeAddFB(ms->fd,
+                      pScrn->virtualX,
+                      pScrn->virtualY,
+                      pScrn->depth,
+                      pScrn->bitsPerPixel,
+                      stride,
+                      handle,
+                      &ms->fb_id);
+    if (ret) {
+       debug_printf("%s: failed to create framebuffer (%i, %s)",
+                    __func__, ret, strerror(-ret));
+       goto err_destroy;
+    }
+
+    pScrn->frameX0 = 0;
+    pScrn->frameY0 = 0;
+    drv_adjust_frame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+
+    pipe_texture_reference(&ms->root_texture, tex);
+    pipe_texture_reference(&tex, NULL);
+
+    return TRUE;
+
+err_destroy:
+    pipe_texture_reference(&tex, NULL);
+    return FALSE;
+}
+
+static Bool
+drv_bind_front_buffer_ga3d(ScrnInfoPtr pScrn)
+{
+    modesettingPtr ms = modesettingPTR(pScrn);
+    ScreenPtr pScreen = pScrn->pScreen;
+    PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen);
+    struct pipe_texture *check;
+
+    xorg_exa_set_displayed_usage(rootPixmap);
+    xorg_exa_set_shared_usage(rootPixmap);
+    xorg_exa_set_texture(rootPixmap, ms->root_texture);
+    if (!pScreen->ModifyPixmapHeader(rootPixmap, -1, -1, -1, -1, -1, NULL))
+       FatalError("Couldn't adjust screen pixmap\n");
+
+    check = xorg_exa_get_texture(rootPixmap);
+    if (ms->root_texture != check)
+       FatalError("Created new root texture\n");
+
+    pipe_texture_reference(&check, NULL);
+    return TRUE;
+}
+
+#ifdef HAVE_LIBKMS
+static Bool
+drv_destroy_front_buffer_kms(ScrnInfoPtr pScrn)
+{
+    modesettingPtr ms = modesettingPTR(pScrn);
+    ScreenPtr pScreen = pScrn->pScreen;
+    PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen);
+
+    /* XXX Do something with the rootPixmap.
+     * This currently works fine but if we are getting crashes in
+     * the fb functions after VT switches maybe look more into it.
+     */
+    (void)rootPixmap;
+
+    if (!ms->root_bo)
+       return TRUE;
+
+    kms_bo_unmap(ms->root_bo);
+    kms_bo_destroy(&ms->root_bo);
+    return TRUE;
+}
+
+static Bool
+drv_create_front_buffer_kms(ScrnInfoPtr pScrn)
+{
+    modesettingPtr ms = modesettingPTR(pScrn);
+    unsigned handle, stride;
+    struct kms_bo *bo;
+    unsigned attr[8];
+    int ret;
+
+    attr[0] = KMS_BO_TYPE;
+    attr[1] = KMS_BO_TYPE_SCANOUT;
+    attr[2] = KMS_WIDTH;
+    attr[3] = pScrn->virtualX;
+    attr[4] = KMS_HEIGHT;
+    attr[5] = pScrn->virtualY;
+    attr[6] = 0;
+
+    if (kms_bo_create(ms->kms, attr, &bo))
+       return FALSE;
+
+    if (kms_bo_get_prop(bo, KMS_PITCH, &stride))
+       goto err_destroy;
+
+    if (kms_bo_get_prop(bo, KMS_HANDLE, &handle))
+       goto err_destroy;
+
+    ret = drmModeAddFB(ms->fd,
+                      pScrn->virtualX,
+                      pScrn->virtualY,
+                      pScrn->depth,
+                      pScrn->bitsPerPixel,
+                      stride,
+                      handle,
+                      &ms->fb_id);
+    if (ret) {
+       debug_printf("%s: failed to create framebuffer (%i, %s)",
+                    __func__, ret, strerror(-ret));
+       goto err_destroy;
+    }
+
+    pScrn->frameX0 = 0;
+    pScrn->frameY0 = 0;
+    drv_adjust_frame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+    ms->root_bo = bo;
+
+    return TRUE;
+
+err_destroy:
+    kms_bo_destroy(&bo);
+    return FALSE;
+}
+
+static Bool
+drv_bind_front_buffer_kms(ScrnInfoPtr pScrn)
+{
+    modesettingPtr ms = modesettingPTR(pScrn);
+    ScreenPtr pScreen = pScrn->pScreen;
+    PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen);
+    unsigned stride;
+    void *ptr;
+
+    if (kms_bo_get_prop(ms->root_bo, KMS_PITCH, &stride))
+       return FALSE;
+
+    if (kms_bo_map(ms->root_bo, &ptr))
+       goto err_destroy;
+
+    pScreen->ModifyPixmapHeader(rootPixmap,
+                               pScreen->width,
+                               pScreen->height,
+                               pScreen->rootDepth,
+                               pScrn->bitsPerPixel,
+                               stride,
+                               ptr);
+    return TRUE;
+
+err_destroy:
+    kms_bo_destroy(&ms->root_bo);
+    return FALSE;
+}
+#endif /* HAVE_LIBKMS */
+
+static Bool drv_init_front_buffer_functions(ScrnInfoPtr pScrn)
+{
+    modesettingPtr ms = modesettingPTR(pScrn);
+    if (ms->screen) {
+       ms->destroy_front_buffer = drv_destroy_front_buffer_ga3d;
+       ms->create_front_buffer = drv_create_front_buffer_ga3d;
+       ms->bind_front_buffer = drv_bind_front_buffer_ga3d;
+#ifdef HAVE_LIBKMS
+    } else if (ms->kms) {
+       ms->destroy_front_buffer = drv_destroy_front_buffer_kms;
+       ms->create_front_buffer = drv_create_front_buffer_kms;
+       ms->bind_front_buffer = drv_bind_front_buffer_kms;
+#endif
+    } else
+       return FALSE;
+
+    return TRUE;
+}
+
 /* vim: set sw=4 ts=8 sts=4: */
index f7949bafaaecb237dfa83d9c56e185d7aa5e0655..d9432babf185080afced01fe76db5b105e8d5c3f 100644 (file)
 #include "pipe/p_state.h"
 #include "pipe/p_inlines.h"
 
-#include "cso_cache/cso_context.h"
-
+#include "util/u_format.h"
 #include "util/u_rect.h"
+#include "util/u_math.h"
+#include "util/u_debug.h"
 
 #define DEBUG_PRINT 0
-#define DEBUG_SOLID 0
-#define DISABLE_ACCEL 0
+#define ROUND_UP_TEXTURES 1
 
 /*
  * Helper functions
  */
+struct render_format_str {
+   int format;
+   const char *name;
+};
+static const struct render_format_str formats_info[] =
+{
+   {PICT_a8r8g8b8, "PICT_a8r8g8b8"},
+   {PICT_x8r8g8b8, "PICT_x8r8g8b8"},
+   {PICT_a8b8g8r8, "PICT_a8b8g8r8"},
+   {PICT_x8b8g8r8, "PICT_x8b8g8r8"},
+#ifdef PICT_TYPE_BGRA
+   {PICT_b8g8r8a8, "PICT_b8g8r8a8"},
+   {PICT_b8g8r8x8, "PICT_b8g8r8x8"},
+   {PICT_a2r10g10b10, "PICT_a2r10g10b10"},
+   {PICT_x2r10g10b10, "PICT_x2r10g10b10"},
+   {PICT_a2b10g10r10, "PICT_a2b10g10r10"},
+   {PICT_x2b10g10r10, "PICT_x2b10g10r10"},
+#endif
+   {PICT_r8g8b8, "PICT_r8g8b8"},
+   {PICT_b8g8r8, "PICT_b8g8r8"},
+   {PICT_r5g6b5, "PICT_r5g6b5"},
+   {PICT_b5g6r5, "PICT_b5g6r5"},
+   {PICT_a1r5g5b5, "PICT_a1r5g5b5"},
+   {PICT_x1r5g5b5, "PICT_x1r5g5b5"},
+   {PICT_a1b5g5r5, "PICT_a1b5g5r5"},
+   {PICT_x1b5g5r5, "PICT_x1b5g5r5"},
+   {PICT_a4r4g4b4, "PICT_a4r4g4b4"},
+   {PICT_x4r4g4b4, "PICT_x4r4g4b4"},
+   {PICT_a4b4g4r4, "PICT_a4b4g4r4"},
+   {PICT_x4b4g4r4, "PICT_x4b4g4r4"},
+   {PICT_a8, "PICT_a8"},
+   {PICT_r3g3b2, "PICT_r3g3b2"},
+   {PICT_b2g3r3, "PICT_b2g3r3"},
+   {PICT_a2r2g2b2, "PICT_a2r2g2b2"},
+   {PICT_a2b2g2r2, "PICT_a2b2g2r2"},
+   {PICT_c8, "PICT_c8"},
+   {PICT_g8, "PICT_g8"},
+   {PICT_x4a4, "PICT_x4a4"},
+   {PICT_x4c4, "PICT_x4c4"},
+   {PICT_x4g4, "PICT_x4g4"},
+   {PICT_a4, "PICT_a4"},
+   {PICT_r1g2b1, "PICT_r1g2b1"},
+   {PICT_b1g2r1, "PICT_b1g2r1"},
+   {PICT_a1r1g1b1, "PICT_a1r1g1b1"},
+   {PICT_a1b1g1r1, "PICT_a1b1g1r1"},
+   {PICT_c4, "PICT_c4"},
+   {PICT_g4, "PICT_g4"},
+   {PICT_a1, "PICT_a1"},
+   {PICT_g1, "PICT_g1"}
+};
+static const char *render_format_name(int format)
+{
+   int i = 0;
+   for (i = 0; i < sizeof(formats_info)/sizeof(formats_info[0]); ++i) {
+      if (formats_info[i].format == format)
+         return formats_info[i].name;
+   }
+   return NULL;
+}
 
 static void
-exa_get_pipe_format(int depth, enum pipe_format *format, int *bbp)
+exa_get_pipe_format(int depth, enum pipe_format *format, int *bbp, int *picture_format)
 {
     switch (depth) {
     case 32:
        *format = PIPE_FORMAT_A8R8G8B8_UNORM;
+       *picture_format = PICT_a8r8g8b8;
        assert(*bbp == 32);
        break;
     case 24:
        *format = PIPE_FORMAT_X8R8G8B8_UNORM;
+       *picture_format = PICT_x8r8g8b8;
        assert(*bbp == 32);
        break;
     case 16:
        *format = PIPE_FORMAT_R5G6B5_UNORM;
+       *picture_format = PICT_r5g6b5;
        assert(*bbp == 16);
        break;
     case 15:
        *format = PIPE_FORMAT_A1R5G5B5_UNORM;
+       *picture_format = PICT_x1r5g5b5;
        assert(*bbp == 16);
        break;
     case 8:
-       *format = PIPE_FORMAT_I8_UNORM;
+       *format = PIPE_FORMAT_L8_UNORM;
+       *picture_format = PICT_a8;
        assert(*bbp == 8);
        break;
     case 4:
@@ -89,24 +153,6 @@ exa_get_pipe_format(int depth, enum pipe_format *format, int *bbp)
     }
 }
 
-static void
-xorg_exa_init_state(struct exa_context *exa)
-{
-   struct pipe_depth_stencil_alpha_state dsa;
-
-   /* set common initial clip state */
-   memset(&dsa, 0, sizeof(struct pipe_depth_stencil_alpha_state));
-   cso_set_depth_stencil_alpha(exa->cso, &dsa);
-}
-
-static void
-xorg_exa_common_done(struct exa_context *exa)
-{
-   exa->copy.src = NULL;
-   exa->copy.dst = NULL;
-   exa->has_solid_color = FALSE;
-   exa->num_bound_samplers = 0;
-}
 
 /*
  * Static exported EXA functions
@@ -115,14 +161,20 @@ xorg_exa_common_done(struct exa_context *exa)
 static void
 ExaWaitMarker(ScreenPtr pScreen, int marker)
 {
+   /* Nothing to do, handled in the PrepareAccess hook */
 }
 
 static int
 ExaMarkSync(ScreenPtr pScreen)
 {
-    return 1;
+   return 1;
 }
 
+
+/***********************************************************************
+ * Screen upload/download
+ */
+
 static Bool
 ExaDownloadFromScreen(PixmapPtr pPix, int x,  int y, int w,  int h, char *dst,
                      int dst_pitch)
@@ -146,7 +198,12 @@ ExaDownloadFromScreen(PixmapPtr pPix, int x,  int y, int w,  int h, char *dst,
     if (!transfer)
        return FALSE;
 
-    util_copy_rect((unsigned char*)dst, &priv->tex->block, dst_pitch, 0, 0,
+#if DEBUG_PRINT
+    debug_printf("------ ExaDownloadFromScreen(%d, %d, %d, %d, %d)\n",
+                 x, y, w, h, dst_pitch);
+#endif
+
+    util_copy_rect((unsigned char*)dst, priv->tex->format, dst_pitch, 0, 0,
                   w, h, exa->scrn->transfer_map(exa->scrn, transfer),
                   transfer->stride, 0, 0);
 
@@ -170,13 +227,23 @@ ExaUploadToScreen(PixmapPtr pPix, int x, int y, int w, int h, char *src,
     if (!priv || !priv->tex)
        return FALSE;
 
+    /* make sure that any pending operations are flushed to hardware */
+    if (exa->pipe->is_texture_referenced(exa->pipe, priv->tex, 0, 0) &
+       (PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE))
+       xorg_exa_flush(exa, 0, NULL);
+
     transfer = exa->scrn->get_tex_transfer(exa->scrn, priv->tex, 0, 0, 0,
                                           PIPE_TRANSFER_WRITE, x, y, w, h);
     if (!transfer)
        return FALSE;
 
+#if DEBUG_PRINT
+    debug_printf("++++++ ExaUploadToScreen(%d, %d, %d, %d, %d)\n",
+                 x, y, w, h, src_pitch);
+#endif
+
     util_copy_rect(exa->scrn->transfer_map(exa->scrn, transfer),
-                  &priv->tex->block, transfer->stride, 0, 0, w, h,
+                  priv->tex->format, transfer->stride, 0, 0, w, h,
                   (unsigned char*)src, src_pitch, 0, 0);
 
     exa->scrn->transfer_unmap(exa->scrn, transfer);
@@ -208,15 +275,24 @@ ExaPrepareAccess(PixmapPtr pPix, int index)
            PIPE_REFERENCED_FOR_WRITE)
            exa->pipe->flush(exa->pipe, 0, NULL);
 
+        assert(pPix->drawable.width <= priv->tex->width0);
+        assert(pPix->drawable.height <= priv->tex->height0);
+
        priv->map_transfer =
            exa->scrn->get_tex_transfer(exa->scrn, priv->tex, 0, 0, 0,
 #ifdef EXA_MIXED_PIXMAPS
                                        PIPE_TRANSFER_MAP_DIRECTLY |
 #endif
                                        PIPE_TRANSFER_READ_WRITE,
-                                       0, 0, priv->tex->width[0], priv->tex->height[0]);
-        if (!priv->map_transfer)
+                                       0, 0, 
+                                        pPix->drawable.width,
+                                        pPix->drawable.height );
+       if (!priv->map_transfer)
+#ifdef EXA_MIXED_PIXMAPS
            return FALSE;
+#else
+           FatalError("failed to create transfer\n");
+#endif
 
        pPix->devPrivate.ptr =
            exa->scrn->transfer_map(exa->scrn, priv->map_transfer);
@@ -253,34 +329,9 @@ ExaFinishAccess(PixmapPtr pPix, int index)
     }
 }
 
-static void
-ExaDone(PixmapPtr pPixmap)
-{
-    ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
-    modesettingPtr ms = modesettingPTR(pScrn);
-    struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap);
-    struct exa_context *exa = ms->exa;
-
-    if (!priv)
-       return;
-
-#if 1
-    xorg_exa_flush(exa, PIPE_FLUSH_RENDER_CACHE, NULL);
-#else
-    xorg_exa_finish(exa);
-#endif
-    xorg_exa_common_done(exa);
-}
-
-static void
-ExaDoneComposite(PixmapPtr pPixmap)
-{
-   ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
-   modesettingPtr ms = modesettingPTR(pScrn);
-   struct exa_context *exa = ms->exa;
-
-   xorg_exa_common_done(exa);
-}
+/***********************************************************************
+ * Solid Fills
+ */
 
 static Bool
 ExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg)
@@ -293,33 +344,28 @@ ExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg)
 #if DEBUG_PRINT
     debug_printf("ExaPrepareSolid(0x%x)\n", fg);
 #endif
+    if (!exa->accel)
+       return FALSE;
+
     if (!exa->pipe)
-       XORG_FALLBACK("solid accle not enabled");
+       XORG_FALLBACK("accle not enabled");
 
     if (!priv || !priv->tex)
-       XORG_FALLBACK("solid !priv || !priv->tex");
+       XORG_FALLBACK("%s", !priv ? "!priv" : "!priv->tex");
 
     if (!EXA_PM_IS_SOLID(&pPixmap->drawable, planeMask))
-       XORG_FALLBACK("solid planeMask is not solid");
+       XORG_FALLBACK("planeMask is not solid");
 
     if (alu != GXcopy)
-       XORG_FALLBACK("solid not GXcopy");
+       XORG_FALLBACK("not GXcopy");
 
     if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format,
                                         priv->tex->target,
                                         PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) {
-       XORG_FALLBACK("solid bad format %s", pf_name(priv->tex->format));
+       XORG_FALLBACK("format %s", pf_name(priv->tex->format));
     }
 
-#if DEBUG_SOLID
-    fg = 0xffff0000;
-#endif
-
-#if DISABLE_ACCEL
-    return FALSE;
-#else
     return xorg_solid_bind_state(exa, priv, fg);
-#endif
 }
 
 static void
@@ -334,48 +380,34 @@ ExaSolid(PixmapPtr pPixmap, int x0, int y0, int x1, int y1)
     debug_printf("\tExaSolid(%d, %d, %d, %d)\n", x0, y0, x1, y1);
 #endif
 
-#if 0
     if (x0 == 0 && y0 == 0 &&
-        x1 == priv->tex->width[0] &&
-        y1 == priv->tex->height[0]) {
-       exa->ctx->clear(exa->pipe, PIPE_CLEAR_COLOR,
-                       exa->solid_color, 1., 0);
-    } else
-#endif
+        x1 == pPixmap->drawable.width && y1 == pPixmap->drawable.height) {
+       exa->pipe->clear(exa->pipe, PIPE_CLEAR_COLOR, exa->solid_color, 0.0, 0);
+       return;
+    }
 
-#if DEBUG_SOLID
-       exa->solid_color[0] = 0.f;
-       exa->solid_color[1] = 1.f;
-       exa->solid_color[2] = 0.f;
-       exa->solid_color[3] = 1.f;
-    xorg_solid(exa, priv, 0, 0, 1024, 768);
-       exa->solid_color[0] = 1.f;
-       exa->solid_color[1] = 0.f;
-       exa->solid_color[2] = 0.f;
-       exa->solid_color[3] = 1.f;
-       xorg_solid(exa, priv, 0, 0, 300, 300);
-       xorg_solid(exa, priv, 300, 300, 350, 350);
-       xorg_solid(exa, priv, 350, 350, 500, 500);
-
-       xorg_solid(exa, priv,
-               priv->tex->width[0] - 10,
-               priv->tex->height[0] - 10,
-               priv->tex->width[0],
-               priv->tex->height[0]);
-
-    exa->solid_color[0] = 0.f;
-    exa->solid_color[1] = 0.f;
-    exa->solid_color[2] = 1.f;
-    exa->solid_color[3] = 1.f;
-
-    exa->has_solid_color = FALSE;
-    ExaPrepareCopy(pPixmap, pPixmap, 0, 0, GXcopy, 0xffffffff);
-    ExaCopy(pPixmap, 0, 0, 50, 50, 500, 500);
-#else
     xorg_solid(exa, priv, x0, y0, x1, y1) ;
-#endif
 }
 
+
+static void
+ExaDoneSolid(PixmapPtr pPixmap)
+{
+    ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
+    modesettingPtr ms = modesettingPTR(pScrn);
+    struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap);
+    struct exa_context *exa = ms->exa;
+
+    if (!priv)
+       return;
+   
+    xorg_composite_done(exa);
+}
+
+/***********************************************************************
+ * Copy Blits
+ */
+
 static Bool
 ExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir,
               int ydir, int alu, Pixel planeMask)
@@ -389,39 +421,84 @@ ExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir,
 #if DEBUG_PRINT
     debug_printf("ExaPrepareCopy\n");
 #endif
+
+    if (!exa->accel)
+       return FALSE;
+
     if (!exa->pipe)
-       XORG_FALLBACK("copy accle not enabled");
+       XORG_FALLBACK("accle not enabled");
 
-    if (!priv || !src_priv)
-       XORG_FALLBACK("copy !priv || !src_priv");
+    if (!priv || !priv->tex)
+       XORG_FALLBACK("pDst %s", !priv ? "!priv" : "!priv->tex");
 
-    if (!priv->tex || !src_priv->tex)
-       XORG_FALLBACK("copy !priv->tex || !src_priv->tex");
+    if (!src_priv || !src_priv->tex)
+       XORG_FALLBACK("pSrc %s", !src_priv ? "!priv" : "!priv->tex");
 
     if (!EXA_PM_IS_SOLID(&pSrcPixmap->drawable, planeMask))
-       XORG_FALLBACK("copy planeMask is not solid");
+       XORG_FALLBACK("planeMask is not solid");
 
     if (alu != GXcopy)
-       XORG_FALLBACK("copy alu not GXcopy");
+       XORG_FALLBACK("alu not GXcopy");
 
     if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format,
                                         priv->tex->target,
                                         PIPE_TEXTURE_USAGE_RENDER_TARGET, 0))
-       XORG_FALLBACK("copy pDst format %s", pf_name(priv->tex->format));
+       XORG_FALLBACK("pDst format %s", pf_name(priv->tex->format));
 
     if (!exa->scrn->is_format_supported(exa->scrn, src_priv->tex->format,
                                         src_priv->tex->target,
                                         PIPE_TEXTURE_USAGE_SAMPLER, 0))
-       XORG_FALLBACK("copy pSrc format %s", pf_name(src_priv->tex->format));
+       XORG_FALLBACK("pSrc format %s", pf_name(src_priv->tex->format));
 
     exa->copy.src = src_priv;
     exa->copy.dst = priv;
 
-#if DISABLE_ACCEL
-    return FALSE;
-#else
+    /* For same-surface copies, the pipe->surface_copy path is clearly
+     * superior, providing it is implemented.  In other cases it's not
+     * clear what the better path would be, and eventually we'd
+     * probably want to gather timings and choose dynamically.
+     */
+    if (exa->pipe->surface_copy &&
+        exa->copy.src == exa->copy.dst) {
+
+       exa->copy.use_surface_copy = TRUE;
+       
+       exa->copy.src_surface =
+          exa->scrn->get_tex_surface( exa->scrn,
+                                      exa->copy.src->tex,
+                                      0, 0, 0,
+                                      PIPE_BUFFER_USAGE_GPU_READ);
+
+       exa->copy.dst_surface =
+          exa->scrn->get_tex_surface( exa->scrn, 
+                                      exa->copy.dst->tex,
+                                      0, 0, 0, 
+                                      PIPE_BUFFER_USAGE_GPU_WRITE );
+    }
+    else {
+       exa->copy.use_surface_copy = FALSE;
+
+       if (exa->copy.dst == exa->copy.src)
+          exa->copy.src_texture = renderer_clone_texture( exa->renderer,
+                                                          exa->copy.src->tex );
+       else
+          pipe_texture_reference(&exa->copy.src_texture,
+                                 exa->copy.src->tex);
+
+       exa->copy.dst_surface =
+          exa->scrn->get_tex_surface(exa->scrn,
+                                     exa->copy.dst->tex,
+                                     0, 0, 0,
+                                     PIPE_BUFFER_USAGE_GPU_WRITE);
+
+
+       renderer_copy_prepare(exa->renderer, 
+                             exa->copy.dst_surface,
+                             exa->copy.src_texture );
+    }
+
+
     return TRUE;
-#endif
 }
 
 static void
@@ -439,12 +516,113 @@ ExaCopy(PixmapPtr pDstPixmap, int srcX, int srcY, int dstX, int dstY,
 #endif
 
    debug_assert(priv == exa->copy.dst);
+   (void) priv;
+
+   if (exa->copy.use_surface_copy) {
+      /* XXX: consider exposing >1 box in surface_copy interface.
+       */
+      exa->pipe->surface_copy( exa->pipe,
+                             exa->copy.dst_surface,
+                             dstX, dstY,
+                             exa->copy.src_surface,
+                             srcX, srcY,
+                             width, height );
+   }
+   else {
+      renderer_copy_pixmap(exa->renderer, 
+                           dstX, dstY,
+                           srcX, srcY,
+                           width, height,
+                           exa->copy.src_texture->width0,
+                           exa->copy.src_texture->height0);
+   }
+}
+
+static void
+ExaDoneCopy(PixmapPtr pPixmap)
+{
+    ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
+    modesettingPtr ms = modesettingPTR(pScrn);
+    struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap);
+    struct exa_context *exa = ms->exa;
+
+    if (!priv)
+       return;
+
+   renderer_draw_flush(exa->renderer);
 
-   xorg_copy_pixmap(exa, exa->copy.dst, dstX, dstY,
-                    exa->copy.src, srcX, srcY,
-                    width, height);
+   exa->copy.src = NULL;
+   exa->copy.dst = NULL;
+   pipe_surface_reference(&exa->copy.src_surface, NULL);
+   pipe_surface_reference(&exa->copy.dst_surface, NULL);
+   pipe_texture_reference(&exa->copy.src_texture, NULL);
 }
 
+
+
+static Bool
+picture_check_formats(struct exa_pixmap_priv *pSrc, PicturePtr pSrcPicture)
+{
+   if (pSrc->picture_format == pSrcPicture->format)
+      return TRUE;
+
+   if (pSrc->picture_format != PICT_a8r8g8b8)
+      return FALSE;
+
+   /* pSrc->picture_format == PICT_a8r8g8b8 */
+   switch (pSrcPicture->format) {
+   case PICT_a8r8g8b8:
+   case PICT_x8r8g8b8:
+   case PICT_a8b8g8r8:
+   case PICT_x8b8g8r8:
+   /* just treat these two as x8... */
+   case PICT_r8g8b8:
+   case PICT_b8g8r8:
+      return TRUE;
+#ifdef PICT_TYPE_BGRA
+   case PICT_b8g8r8a8:
+   case PICT_b8g8r8x8:
+      return FALSE; /* does not support swizzleing the alpha channel yet */
+   case PICT_a2r10g10b10:
+   case PICT_x2r10g10b10:
+   case PICT_a2b10g10r10:
+   case PICT_x2b10g10r10:
+      return FALSE;
+#endif
+   default:
+      return FALSE;
+   }
+   return FALSE;
+}
+
+/***********************************************************************
+ * Composite entrypoints
+ */
+
+static Bool
+ExaCheckComposite(int op,
+                 PicturePtr pSrcPicture, PicturePtr pMaskPicture,
+                 PicturePtr pDstPicture)
+{
+   ScrnInfoPtr pScrn = xf86Screens[pDstPicture->pDrawable->pScreen->myNum];
+   modesettingPtr ms = modesettingPTR(pScrn);
+   struct exa_context *exa = ms->exa;
+
+#if DEBUG_PRINT
+   debug_printf("ExaCheckComposite(%d, %p, %p, %p) = %d\n",
+                op, pSrcPicture, pMaskPicture, pDstPicture, accelerated);
+#endif
+
+   if (!exa->accel)
+       return FALSE;
+
+   return xorg_composite_accelerated(op,
+                                    pSrcPicture,
+                                    pMaskPicture,
+                                    pDstPicture);
+}
+
+
 static Bool
 ExaPrepareComposite(int op, PicturePtr pSrcPicture,
                    PicturePtr pMaskPicture, PicturePtr pDstPicture,
@@ -455,53 +633,72 @@ ExaPrepareComposite(int op, PicturePtr pSrcPicture,
    struct exa_context *exa = ms->exa;
    struct exa_pixmap_priv *priv;
 
+   if (!exa->accel)
+       return FALSE;
+
 #if DEBUG_PRINT
-   debug_printf("ExaPrepareComposite\n");
+   debug_printf("ExaPrepareComposite(%d, src=0x%p, mask=0x%p, dst=0x%p)\n",
+                op, pSrcPicture, pMaskPicture, pDstPicture);
+   debug_printf("\tFormats: src(%s), mask(%s), dst(%s)\n",
+                pSrcPicture ? render_format_name(pSrcPicture->format) : "none",
+                pMaskPicture ? render_format_name(pMaskPicture->format) : "none",
+                pDstPicture ? render_format_name(pDstPicture->format) : "none");
 #endif
    if (!exa->pipe)
-      XORG_FALLBACK("comp accle not enabled");
+      XORG_FALLBACK("accle not enabled");
 
    priv = exaGetPixmapDriverPrivate(pDst);
    if (!priv || !priv->tex)
-      XORG_FALLBACK("comp pDst %s", !priv ? "!priv" : "!priv->tex");
+      XORG_FALLBACK("pDst %s", !priv ? "!priv" : "!priv->tex");
 
    if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format,
                                        priv->tex->target,
                                        PIPE_TEXTURE_USAGE_RENDER_TARGET, 0))
-      XORG_FALLBACK("copy pDst format: %s", pf_name(priv->tex->format));
+      XORG_FALLBACK("pDst format: %s", pf_name(priv->tex->format));
+
+   if (priv->picture_format != pDstPicture->format)
+      XORG_FALLBACK("pDst pic_format: %s != %s",
+                    render_format_name(priv->picture_format),
+                    render_format_name(pDstPicture->format));
 
    if (pSrc) {
       priv = exaGetPixmapDriverPrivate(pSrc);
       if (!priv || !priv->tex)
-         XORG_FALLBACK("comp pSrc %s", !priv ? "!priv" : "!priv->tex");
+         XORG_FALLBACK("pSrc %s", !priv ? "!priv" : "!priv->tex");
 
       if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format,
                                           priv->tex->target,
                                           PIPE_TEXTURE_USAGE_SAMPLER, 0))
-         XORG_FALLBACK("copy pSrc format: %s", pf_name(priv->tex->format));
+         XORG_FALLBACK("pSrc format: %s", pf_name(priv->tex->format));
+
+      if (!picture_check_formats(priv, pSrcPicture))
+         XORG_FALLBACK("pSrc pic_format: %s != %s",
+                       render_format_name(priv->picture_format),
+                       render_format_name(pSrcPicture->format));
+
    }
 
    if (pMask) {
       priv = exaGetPixmapDriverPrivate(pMask);
       if (!priv || !priv->tex)
-         XORG_FALLBACK("comp pMask %s", !priv ? "!priv" : "!priv->tex");
+         XORG_FALLBACK("pMask %s", !priv ? "!priv" : "!priv->tex");
 
       if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format,
                                           priv->tex->target,
                                           PIPE_TEXTURE_USAGE_SAMPLER, 0))
-         XORG_FALLBACK("copy pMask format: %s", pf_name(priv->tex->format));
+         XORG_FALLBACK("pMask format: %s", pf_name(priv->tex->format));
+
+      if (!picture_check_formats(priv, pMaskPicture))
+         XORG_FALLBACK("pMask pic_format: %s != %s",
+                       render_format_name(priv->picture_format),
+                       render_format_name(pMaskPicture->format));
    }
 
-#if DISABLE_ACCEL
-   (void) exa;
-   return FALSE;
-#else
    return xorg_composite_bind_state(exa, op, pSrcPicture, pMaskPicture,
                                     pDstPicture,
                                     pSrc ? exaGetPixmapDriverPrivate(pSrc) : NULL,
                                     pMask ? exaGetPixmapDriverPrivate(pMask) : NULL,
                                     exaGetPixmapDriverPrivate(pDst));
-#endif
 }
 
 static void
@@ -514,29 +711,33 @@ ExaComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY,
    struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pDst);
 
 #if DEBUG_PRINT
-   debug_printf("\tExaComposite\n");
+   debug_printf("\tExaComposite(src[%d,%d], mask=[%d, %d], dst=[%d, %d], dim=[%d, %d])\n",
+                srcX, srcY, maskX, maskY, dstX, dstY, width, height);
+   debug_printf("\t   Num bound samplers = %d\n",
+                exa->num_bound_samplers);
 #endif
 
    xorg_composite(exa, priv, srcX, srcY, maskX, maskY,
                   dstX, dstY, width, height);
 }
 
-static Bool
-ExaCheckComposite(int op,
-                 PicturePtr pSrcPicture, PicturePtr pMaskPicture,
-                 PicturePtr pDstPicture)
+
+
+static void
+ExaDoneComposite(PixmapPtr pPixmap)
 {
-   boolean accelerated = xorg_composite_accelerated(op,
-                                                    pSrcPicture,
-                                                    pMaskPicture,
-                                                    pDstPicture);
-#if DEBUG_PRINT
-   debug_printf("ExaCheckComposite(%d, %p, %p, %p) = %d\n",
-                op, pSrcPicture, pMaskPicture, pDstPicture, accelerated);
-#endif
-   return accelerated;
+   ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
+   modesettingPtr ms = modesettingPTR(pScrn);
+   struct exa_context *exa = ms->exa;
+
+   xorg_composite_done(exa);
 }
 
+
+/***********************************************************************
+ * Pixmaps
+ */
+
 static void *
 ExaCreatePixmap(ScreenPtr pScreen, int size, int align)
 {
@@ -610,33 +811,22 @@ xorg_exa_set_shared_usage(PixmapPtr pPixmap)
     return 0;
 }
 
-unsigned
-xorg_exa_get_pixmap_handle(PixmapPtr pPixmap, unsigned *stride_out)
-{
-    ScreenPtr pScreen = pPixmap->drawable.pScreen;
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-    modesettingPtr ms = modesettingPTR(pScrn);
-    struct exa_pixmap_priv *priv;
-    unsigned handle;
-    unsigned stride;
 
-    if (!ms->exa) {
-       FatalError("NO MS->EXA\n");
-       return 0;
-    }
 
-    priv = exaGetPixmapDriverPrivate(pPixmap);
-
-    if (!priv) {
-       FatalError("NO PIXMAP PRIVATE\n");
-       return 0;
-    }
+static Bool
+size_match( int width, int tex_width )
+{
+#if ROUND_UP_TEXTURES
+   if (width > tex_width)
+      return FALSE;
 
-    ms->api->local_handle_from_texture(ms->api, ms->screen, priv->tex, &stride, &handle);
-    if (stride_out)
-       *stride_out = stride;
+   if (width * 2 < tex_width)
+      return FALSE;
 
-    return handle;
+   return TRUE;
+#else
+   return width == tex_width;
+#endif
 }
 
 static Bool
@@ -653,6 +843,17 @@ ExaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height,
     if (!priv || pPixData)
        return FALSE;
 
+    if (0) {
+       debug_printf("%s pixmap %p sz %dx%dx%d devKind %d\n",
+                    __FUNCTION__, pPixmap, width, height, bitsPerPixel, devKind);
+       
+       if (priv->tex)
+          debug_printf("  ==> old texture %dx%d\n",
+                       priv->tex->width0, 
+                       priv->tex->height0);
+    }
+
+
     if (depth <= 0)
        depth = pPixmap->drawable.depth;
 
@@ -671,21 +872,31 @@ ExaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height,
     miModifyPixmapHeader(pPixmap, width, height, depth,
                             bitsPerPixel, devKind, NULL);
 
+    priv->width = width;
+    priv->height = height;
+
     /* Deal with screen resize */
-    if (!priv->tex ||
-        (priv->tex->width[0] != width ||
-         priv->tex->height[0] != height ||
+    if ((exa->accel || priv->flags) &&
+        (!priv->tex ||
+         !size_match(width, priv->tex->width0) ||
+         !size_match(height, priv->tex->height0) ||
          priv->tex_flags != priv->flags)) {
        struct pipe_texture *texture = NULL;
        struct pipe_texture template;
 
        memset(&template, 0, sizeof(template));
        template.target = PIPE_TEXTURE_2D;
-       exa_get_pipe_format(depth, &template.format, &bitsPerPixel);
-       pf_get_block(template.format, &template.block);
-       template.width[0] = width;
-       template.height[0] = height;
-       template.depth[0] = 1;
+       exa_get_pipe_format(depth, &template.format, &bitsPerPixel, &priv->picture_format);
+        if (ROUND_UP_TEXTURES && priv->flags == 0) {
+           template.width0 = util_next_power_of_two(width);
+           template.height0 = util_next_power_of_two(height);
+        }
+        else {
+           template.width0 = width;
+           template.height0 = height;
+        }
+
+       template.depth0 = 1;
        template.last_level = 0;
        template.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET | priv->flags;
        priv->tex_flags = priv->flags;
@@ -697,10 +908,16 @@ ExaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height,
 
            dst_surf = exa->scrn->get_tex_surface(
                exa->scrn, texture, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE);
-           src_surf = exa_gpu_surface(exa, priv);
-           exa->pipe->surface_copy(exa->pipe, dst_surf, 0, 0, src_surf,
-                                   0, 0, min(width, texture->width[0]),
-                                   min(height, texture->height[0]));
+           src_surf = xorg_gpu_surface(exa->pipe->screen, priv);
+            if (exa->pipe->surface_copy) {
+               exa->pipe->surface_copy(exa->pipe, dst_surf, 0, 0, src_surf,
+                                       0, 0, min(width, texture->width0),
+                                       min(height, texture->height0));
+            } else {
+               util_surface_copy(exa->pipe, FALSE, dst_surf, 0, 0, src_surf,
+                                 0, 0, min(width, texture->width0),
+                                 min(height, texture->height0));
+            }
            exa->scrn->tex_surface_destroy(dst_surf);
            exa->scrn->tex_surface_destroy(src_surf);
        }
@@ -722,31 +939,63 @@ xorg_exa_get_texture(PixmapPtr pPixmap)
    return tex;
 }
 
+Bool
+xorg_exa_set_texture(PixmapPtr pPixmap, struct  pipe_texture *tex)
+{
+    struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap);
+
+    int mask = PIPE_TEXTURE_USAGE_PRIMARY | PIPE_TEXTURE_USAGE_DISPLAY_TARGET;
+
+    if (!priv)
+       return FALSE;
+
+    if (pPixmap->drawable.width != tex->width0 ||
+       pPixmap->drawable.height != tex->height0)
+       return FALSE;
+
+    pipe_texture_reference(&priv->tex, tex);
+    priv->tex_flags = tex->tex_usage & mask;
+
+    return TRUE;
+}
+
+struct pipe_texture *
+xorg_exa_create_root_texture(ScrnInfoPtr pScrn,
+                            int width, int height,
+                            int depth, int bitsPerPixel)
+{
+    modesettingPtr ms = modesettingPTR(pScrn);
+    struct exa_context *exa = ms->exa;
+    struct pipe_texture template;
+    int dummy;
+
+    memset(&template, 0, sizeof(template));
+    template.target = PIPE_TEXTURE_2D;
+    exa_get_pipe_format(depth, &template.format, &bitsPerPixel, &dummy);
+    template.width0 = width;
+    template.height0 = height;
+    template.depth0 = 1;
+    template.last_level = 0;
+    template.tex_usage |= PIPE_TEXTURE_USAGE_RENDER_TARGET;
+    template.tex_usage |= PIPE_TEXTURE_USAGE_PRIMARY;
+    template.tex_usage |= PIPE_TEXTURE_USAGE_DISPLAY_TARGET;
+
+    return exa->scrn->texture_create(exa->scrn, &template);
+}
+
 void
 xorg_exa_close(ScrnInfoPtr pScrn)
 {
    modesettingPtr ms = modesettingPTR(pScrn);
    struct exa_context *exa = ms->exa;
-   struct pipe_constant_buffer *vsbuf = &exa->vs_const_buffer;
-   struct pipe_constant_buffer *fsbuf = &exa->fs_const_buffer;
 
-   if (exa->shaders) {
-      xorg_shaders_destroy(exa->shaders);
-   }
-
-   if (vsbuf && vsbuf->buffer)
-      pipe_buffer_reference(&vsbuf->buffer, NULL);
-
-   if (fsbuf && fsbuf->buffer)
-      pipe_buffer_reference(&fsbuf->buffer, NULL);
-
-   if (exa->cso) {
-      cso_release_all(exa->cso);
-      cso_destroy_context(exa->cso);
-   }
+   renderer_destroy(exa->renderer);
 
    if (exa->pipe)
       exa->pipe->destroy(exa->pipe);
+   exa->pipe = NULL;
+   /* Since this was shared be proper with the pointer */
+   ms->ctx = NULL;
 
    exaDriverFini(pScrn->pScreen);
    xfree(exa);
@@ -754,7 +1003,7 @@ xorg_exa_close(ScrnInfoPtr pScrn)
 }
 
 void *
-xorg_exa_init(ScrnInfoPtr pScrn)
+xorg_exa_init(ScrnInfoPtr pScrn, Bool accel)
 {
    modesettingPtr ms = modesettingPTR(pScrn);
    struct exa_context *exa;
@@ -792,10 +1041,10 @@ xorg_exa_init(ScrnInfoPtr pScrn)
    pExa->MarkSync           = ExaMarkSync;
    pExa->PrepareSolid       = ExaPrepareSolid;
    pExa->Solid              = ExaSolid;
-   pExa->DoneSolid          = ExaDone;
+   pExa->DoneSolid          = ExaDoneSolid;
    pExa->PrepareCopy        = ExaPrepareCopy;
    pExa->Copy               = ExaCopy;
-   pExa->DoneCopy           = ExaDone;
+   pExa->DoneCopy           = ExaDoneCopy;
    pExa->CheckComposite     = ExaCheckComposite;
    pExa->PrepareComposite   = ExaPrepareComposite;
    pExa->Composite          = ExaComposite;
@@ -818,10 +1067,8 @@ xorg_exa_init(ScrnInfoPtr pScrn)
    /* Share context with DRI */
    ms->ctx = exa->pipe;
 
-   exa->cso = cso_create_context(exa->pipe);
-   exa->shaders = xorg_shaders_create(exa);
-
-   xorg_exa_init_state(exa);
+   exa->renderer = renderer_create(exa->pipe);
+   exa->accel = accel;
 
    return (void *)exa;
 
@@ -832,11 +1079,11 @@ out_err:
 }
 
 struct pipe_surface *
-exa_gpu_surface(struct exa_context *exa, struct exa_pixmap_priv *priv)
+xorg_gpu_surface(struct pipe_screen *scrn, struct exa_pixmap_priv *priv)
 {
-   return exa->scrn->get_tex_surface(exa->scrn, priv->tex, 0, 0, 0,
-                                     PIPE_BUFFER_USAGE_GPU_READ |
-                                     PIPE_BUFFER_USAGE_GPU_WRITE);
+   return scrn->get_tex_surface(scrn, priv->tex, 0, 0, 0,
+                                PIPE_BUFFER_USAGE_GPU_READ |
+                                PIPE_BUFFER_USAGE_GPU_WRITE);
 
 }
 
index d3f25ca844bfd8f93acac54f888c1eb3038aae2f..f2cefe23b99df79aafe6728d124bf6ffc2a0b167 100644 (file)
@@ -16,11 +16,7 @@ struct exa_context
    ExaDriverPtr pExa;
    struct pipe_context *pipe;
    struct pipe_screen *scrn;
-   struct cso_context *cso;
-   struct xorg_shaders *shaders;
-
-   struct pipe_constant_buffer vs_const_buffer;
-   struct pipe_constant_buffer fs_const_buffer;
+   struct xorg_renderer *renderer;
 
    struct pipe_texture *bound_textures[MAX_EXA_SAMPLERS];
    int num_bound_samplers;
@@ -28,21 +24,38 @@ struct exa_context
    float solid_color[4];
    boolean has_solid_color;
 
+   boolean accel;
+
+   /* float[9] projective matrix bound to pictures */
    struct {
+      float    src[9];
+      float   mask[9];
+      boolean has_src;
+      boolean has_mask;
+   } transform;
+
+   struct {
+      boolean use_surface_copy;
+
       struct exa_pixmap_priv *src;
       struct exa_pixmap_priv *dst;
-   } copy;
 
-   /* we should combine these two */
-   float vertices2[4][2][4];
-   float vertices3[4][3][4];
+      struct pipe_surface *src_surface;
+      struct pipe_surface *dst_surface;
+
+      struct pipe_texture *src_texture;
+   } copy;
 };
 
 struct exa_pixmap_priv
 {
+   int width, height;
+
    int flags;
    int tex_flags;
 
+   int picture_format;
+
    struct pipe_texture *tex;
    struct pipe_texture *depth_stencil_tex;
 
@@ -50,17 +63,17 @@ struct exa_pixmap_priv
    unsigned map_count;
 };
 
-#define XORG_FALLBACK(s, arg...)              \
-do {                                          \
-   if (ms->debug_fallback) {                  \
-      xf86DrvMsg(pScrn->scrnIndex, X_INFO,    \
-                 "fallback: " s "\n", ##arg); \
-   }                                          \
-   return FALSE;                              \
+#define XORG_FALLBACK(s, arg...)                              \
+do {                                                          \
+   if (ms->debug_fallback) {                                  \
+      xf86DrvMsg(pScrn->scrnIndex, X_INFO,                    \
+                 "%s fallback " s "\n", __FUNCTION__, ##arg); \
+   }                                                          \
+   return FALSE;                                              \
 } while(0)
 
 struct pipe_surface *
-exa_gpu_surface(struct exa_context *exa, struct exa_pixmap_priv *priv);
+xorg_gpu_surface(struct pipe_screen *scrn, struct exa_pixmap_priv *priv);
 
 void xorg_exa_flush(struct exa_context *exa, uint pipeFlushFlags,
                     struct pipe_fence_handle **fence);
index bb5a42af37e8198f05936f7029efa924bf54cb5d..bed17caab77da7a2bb8afd616d8999767cd0ef71 100644 (file)
  * OUT[0] = color
  */
 
+static void
+print_fs_traits(int fs_traits)
+{
+   const char *strings[] = {
+      "FS_COMPOSITE",       /* = 1 << 0, */
+      "FS_MASK",            /* = 1 << 1, */
+      "FS_SOLID_FILL",      /* = 1 << 2, */
+      "FS_LINGRAD_FILL",    /* = 1 << 3, */
+      "FS_RADGRAD_FILL",    /* = 1 << 4, */
+      "FS_CA_FULL",         /* = 1 << 5, */ /* src.rgba * mask.rgba */
+      "FS_CA_SRCALPHA",     /* = 1 << 6, */ /* src.aaaa * mask.rgba */
+      "FS_YUV",             /* = 1 << 7, */
+      "FS_SRC_REPEAT_NONE", /* = 1 << 8, */
+      "FS_MASK_REPEAT_NONE",/* = 1 << 9, */
+      "FS_SRC_SWIZZLE_RGB", /* = 1 << 10, */
+      "FS_MASK_SWIZZLE_RGB",/* = 1 << 11, */
+      "FS_SRC_SET_ALPHA",   /* = 1 << 12, */
+      "FS_MASK_SET_ALPHA",  /* = 1 << 13, */
+      "FS_SRC_LUMINANCE",   /* = 1 << 14, */
+      "FS_MASK_LUMINANCE",  /* = 1 << 15, */
+   };
+   int i, k;
+   debug_printf("%s: ", __func__);
+
+   for (i = 0, k = 1; k < (1 << 16); i++, k <<= 1) {
+      if (fs_traits & k)
+         debug_printf("%s, ", strings[i]);
+   }
+
+   debug_printf("\n");
+}
+
 struct xorg_shaders {
-   struct exa_context *exa;
+   struct xorg_renderer *r;
 
    struct cso_hash *vs_hash;
    struct cso_hash *fs_hash;
 };
 
-static const char over_op[] =
-   "SUB TEMP[3], CONST[0].wwww, TEMP[1].wwww\n"
-   "MAD TEMP[3], TEMP[0], TEMP[3], TEMP[0]\n";
-
-
-static INLINE void
-create_preamble(struct ureg_program *ureg)
-{
-}
-
-
 static INLINE void
 src_in_mask(struct ureg_program *ureg,
             struct ureg_dst dst,
             struct ureg_src src,
-            struct ureg_src mask)
+            struct ureg_src mask,
+            unsigned component_alpha,
+            unsigned mask_luminance)
 {
-   /* MUL dst, src, mask.wwww */
-   ureg_MUL(ureg, dst, src,
-            ureg_scalar(mask, TGSI_SWIZZLE_W));
+   if (component_alpha == FS_CA_FULL) {
+      ureg_MUL(ureg, dst, src, mask);
+   } else if (component_alpha == FS_CA_SRCALPHA) {
+      ureg_MUL(ureg, dst,
+               ureg_scalar(src, TGSI_SWIZZLE_W), mask);
+   }
+   else {
+      if (mask_luminance)
+         ureg_MUL(ureg, dst, src,
+                  ureg_scalar(mask, TGSI_SWIZZLE_X));
+      else
+         ureg_MUL(ureg, dst, src,
+                  ureg_scalar(mask, TGSI_SWIZZLE_W));
+   }
 }
 
 static struct ureg_src
@@ -236,9 +270,10 @@ create_vs(struct pipe_context *pipe,
    struct ureg_src src;
    struct ureg_dst dst;
    struct ureg_src const0, const1;
-   boolean is_fill = vs_traits & VS_FILL;
-   boolean is_composite = vs_traits & VS_COMPOSITE;
-   boolean has_mask = vs_traits & VS_MASK;
+   boolean is_fill = (vs_traits & VS_FILL) != 0;
+   boolean is_composite = (vs_traits & VS_COMPOSITE) != 0;
+   boolean has_mask = (vs_traits & VS_MASK) != 0;
+   boolean is_yuv = (vs_traits & VS_YUV) != 0;
    unsigned input_slot = 0;
 
    ureg = ureg_create(TGSI_PROCESSOR_VERTEX);
@@ -249,7 +284,7 @@ create_vs(struct pipe_context *pipe,
    const1 = ureg_DECL_constant(ureg, 1);
 
    /* it has to be either a fill or a composite op */
-   debug_assert(is_fill ^ is_composite);
+   debug_assert((is_fill ^ is_composite) ^ is_yuv);
 
    src = ureg_DECL_vs_input(ureg, input_slot++);
    dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_POSITION, 0);
@@ -257,6 +292,12 @@ create_vs(struct pipe_context *pipe,
                              const0, const1);
    ureg_MOV(ureg, dst, src);
 
+   if (is_yuv) {
+      src = ureg_DECL_vs_input(ureg, input_slot++);
+      dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_GENERIC, 0);
+      ureg_MOV(ureg, dst, src);
+   }
+
    if (is_composite) {
       src = ureg_DECL_vs_input(ureg, input_slot++);
       dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_GENERIC, 0);
@@ -271,7 +312,7 @@ create_vs(struct pipe_context *pipe,
 
    if (has_mask) {
       src = ureg_DECL_vs_input(ureg, input_slot++);
-      dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_GENERIC, 2);
+      dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_GENERIC, 1);
       ureg_MOV(ureg, dst, src);
    }
 
@@ -280,6 +321,138 @@ create_vs(struct pipe_context *pipe,
    return ureg_create_shader_and_destroy(ureg, pipe);
 }
 
+static void *
+create_yuv_shader(struct pipe_context *pipe, struct ureg_program *ureg)
+{
+   struct ureg_src y_sampler, u_sampler, v_sampler;
+   struct ureg_src pos;
+   struct ureg_src matrow0, matrow1, matrow2;
+   struct ureg_dst y, u, v, rgb;
+   struct ureg_dst out = ureg_DECL_output(ureg,
+                                          TGSI_SEMANTIC_COLOR,
+                                          0);
+
+   pos = ureg_DECL_fs_input(ureg,
+                            TGSI_SEMANTIC_GENERIC,
+                            0,
+                            TGSI_INTERPOLATE_PERSPECTIVE);
+
+   rgb = ureg_DECL_temporary(ureg);
+   y = ureg_DECL_temporary(ureg);
+   u = ureg_DECL_temporary(ureg);
+   v = ureg_DECL_temporary(ureg);
+
+   y_sampler = ureg_DECL_sampler(ureg, 0);
+   u_sampler = ureg_DECL_sampler(ureg, 1);
+   v_sampler = ureg_DECL_sampler(ureg, 2);
+
+   matrow0 = ureg_DECL_constant(ureg, 0);
+   matrow1 = ureg_DECL_constant(ureg, 1);
+   matrow2 = ureg_DECL_constant(ureg, 2);
+
+   ureg_TEX(ureg, y,
+            TGSI_TEXTURE_2D, pos, y_sampler);
+   ureg_TEX(ureg, u,
+            TGSI_TEXTURE_2D, pos, u_sampler);
+   ureg_TEX(ureg, v,
+            TGSI_TEXTURE_2D, pos, v_sampler);
+
+   ureg_SUB(ureg, u, ureg_src(u),
+            ureg_scalar(matrow0, TGSI_SWIZZLE_W));
+   ureg_SUB(ureg, v, ureg_src(v),
+            ureg_scalar(matrow0, TGSI_SWIZZLE_W));
+
+   ureg_MUL(ureg, rgb,
+            ureg_scalar(ureg_src(y), TGSI_SWIZZLE_X),
+            matrow0);
+   ureg_MAD(ureg, rgb,
+            ureg_scalar(ureg_src(u), TGSI_SWIZZLE_X),
+            matrow1,
+            ureg_src(rgb));
+   ureg_MAD(ureg, rgb,
+            ureg_scalar(ureg_src(v), TGSI_SWIZZLE_X),
+            matrow2,
+            ureg_src(rgb));
+
+   /* rgb.a = 1; */
+   ureg_MOV(ureg, ureg_writemask(rgb, TGSI_WRITEMASK_W),
+            ureg_scalar(matrow0, TGSI_SWIZZLE_X));
+
+   ureg_MOV(ureg, out, ureg_src(rgb));
+
+   ureg_release_temporary(ureg, rgb);
+   ureg_release_temporary(ureg, y);
+   ureg_release_temporary(ureg, u);
+   ureg_release_temporary(ureg, v);
+
+   ureg_END(ureg);
+
+   return ureg_create_shader_and_destroy(ureg, pipe);
+}
+
+
+static INLINE void
+xrender_tex(struct ureg_program *ureg,
+            struct ureg_dst dst,
+            struct ureg_src coords,
+            struct ureg_src sampler,
+            struct ureg_src imm0,
+            boolean repeat_none,
+            boolean swizzle,
+            boolean set_alpha)
+{
+   if (repeat_none) {
+      struct ureg_dst tmp0 = ureg_DECL_temporary(ureg);
+      struct ureg_dst tmp1 = ureg_DECL_temporary(ureg);
+      ureg_SGT(ureg, tmp1, ureg_swizzle(coords,
+                                        TGSI_SWIZZLE_X,
+                                        TGSI_SWIZZLE_Y,
+                                        TGSI_SWIZZLE_X,
+                                        TGSI_SWIZZLE_Y),
+               ureg_scalar(imm0, TGSI_SWIZZLE_X));
+      ureg_SLT(ureg, tmp0, ureg_swizzle(coords,
+                                        TGSI_SWIZZLE_X,
+                                        TGSI_SWIZZLE_Y,
+                                        TGSI_SWIZZLE_X,
+                                        TGSI_SWIZZLE_Y),
+               ureg_scalar(imm0, TGSI_SWIZZLE_W));
+      ureg_MIN(ureg, tmp0, ureg_src(tmp0), ureg_src(tmp1));
+      ureg_MIN(ureg, tmp0, ureg_scalar(ureg_src(tmp0), TGSI_SWIZZLE_X),
+               ureg_scalar(ureg_src(tmp0), TGSI_SWIZZLE_Y));
+      ureg_TEX(ureg, tmp1, TGSI_TEXTURE_2D, coords, sampler);
+      if (swizzle)
+         ureg_MOV(ureg, tmp1, ureg_swizzle(ureg_src(tmp1),
+                                           TGSI_SWIZZLE_Z,
+                                           TGSI_SWIZZLE_Y,
+                                           TGSI_SWIZZLE_X,
+                                           TGSI_SWIZZLE_W));
+      if (set_alpha)
+         ureg_MOV(ureg,
+                  ureg_writemask(tmp1, TGSI_WRITEMASK_W),
+                  ureg_scalar(imm0, TGSI_SWIZZLE_W));
+      ureg_MUL(ureg, dst, ureg_src(tmp1), ureg_src(tmp0));
+      ureg_release_temporary(ureg, tmp0);
+      ureg_release_temporary(ureg, tmp1);
+   } else {
+      if (swizzle) {
+         struct ureg_dst tmp = ureg_DECL_temporary(ureg);
+         ureg_TEX(ureg, tmp, TGSI_TEXTURE_2D, coords, sampler);
+         ureg_MOV(ureg, dst, ureg_swizzle(ureg_src(tmp),
+                                          TGSI_SWIZZLE_Z,
+                                          TGSI_SWIZZLE_Y,
+                                          TGSI_SWIZZLE_X,
+                                          TGSI_SWIZZLE_W));
+         ureg_release_temporary(ureg, tmp);
+      } else {
+         ureg_TEX(ureg, dst, TGSI_TEXTURE_2D, coords, sampler);
+      }
+      if (set_alpha)
+         ureg_MOV(ureg,
+                  ureg_writemask(dst, TGSI_WRITEMASK_W),
+                  ureg_scalar(imm0, TGSI_SWIZZLE_W));
+   }
+}
+
 static void *
 create_fs(struct pipe_context *pipe,
           unsigned fs_traits)
@@ -289,32 +462,54 @@ create_fs(struct pipe_context *pipe,
    struct ureg_src /*dst_pos,*/ src_input, mask_pos;
    struct ureg_dst src, mask;
    struct ureg_dst out;
-   boolean has_mask = fs_traits & FS_MASK;
-   boolean is_fill = fs_traits & FS_FILL;
-   boolean is_composite = fs_traits & FS_COMPOSITE;
-   boolean is_solid   = fs_traits & FS_SOLID_FILL;
-   boolean is_lingrad = fs_traits & FS_LINGRAD_FILL;
-   boolean is_radgrad = fs_traits & FS_RADGRAD_FILL;
+   struct ureg_src imm0 = { 0 };
+   unsigned has_mask = (fs_traits & FS_MASK) != 0;
+   unsigned is_fill = (fs_traits & FS_FILL) != 0;
+   unsigned is_composite = (fs_traits & FS_COMPOSITE) != 0;
+   unsigned is_solid   = (fs_traits & FS_SOLID_FILL) != 0;
+   unsigned is_lingrad = (fs_traits & FS_LINGRAD_FILL) != 0;
+   unsigned is_radgrad = (fs_traits & FS_RADGRAD_FILL) != 0;
+   unsigned comp_alpha_mask = fs_traits & FS_COMPONENT_ALPHA;
+   unsigned is_yuv = (fs_traits & FS_YUV) != 0;
+   unsigned src_repeat_none = (fs_traits & FS_SRC_REPEAT_NONE) != 0;
+   unsigned mask_repeat_none = (fs_traits & FS_MASK_REPEAT_NONE) != 0;
+   unsigned src_swizzle = (fs_traits & FS_SRC_SWIZZLE_RGB) != 0;
+   unsigned mask_swizzle = (fs_traits & FS_MASK_SWIZZLE_RGB) != 0;
+   unsigned src_set_alpha = (fs_traits & FS_SRC_SET_ALPHA) != 0;
+   unsigned mask_set_alpha = (fs_traits & FS_MASK_SET_ALPHA) != 0;
+   unsigned src_luminance = (fs_traits & FS_SRC_LUMINANCE) != 0;
+   unsigned mask_luminance = (fs_traits & FS_MASK_LUMINANCE) != 0;
+
+#if 0
+   print_fs_traits(fs_traits);
+#else
+   (void)print_fs_traits;
+#endif
 
    ureg = ureg_create(TGSI_PROCESSOR_FRAGMENT);
    if (ureg == NULL)
       return 0;
 
-   /* it has to be either a fill or a composite op */
-   debug_assert(is_fill ^ is_composite);
+   /* it has to be either a fill, a composite op or a yuv conversion */
+   debug_assert((is_fill ^ is_composite) ^ is_yuv);
+   (void) is_yuv;
 
    out = ureg_DECL_output(ureg,
                           TGSI_SEMANTIC_COLOR,
                           0);
 
+   if (src_repeat_none || mask_repeat_none ||
+       src_set_alpha || mask_set_alpha ||
+       src_luminance) {
+      imm0 = ureg_imm4f(ureg, 0, 0, 0, 1);
+   }
    if (is_composite) {
       src_sampler = ureg_DECL_sampler(ureg, 0);
       src_input = ureg_DECL_fs_input(ureg,
                                      TGSI_SEMANTIC_GENERIC,
                                      0,
                                      TGSI_INTERPOLATE_PERSPECTIVE);
-   } else {
-      debug_assert(is_fill);
+   } else if (is_fill) {
       if (is_solid)
          src_input = ureg_DECL_fs_input(ureg,
                                         TGSI_SEMANTIC_COLOR,
@@ -325,6 +520,9 @@ create_fs(struct pipe_context *pipe,
                                         TGSI_SEMANTIC_POSITION,
                                         0,
                                         TGSI_INTERPOLATE_PERSPECTIVE);
+   } else {
+      debug_assert(is_yuv);
+      return create_yuv_shader(pipe, ureg);
    }
 
    if (has_mask) {
@@ -343,16 +541,17 @@ create_fs(struct pipe_context *pipe,
                                 TGSI_INTERPOLATE_PERSPECTIVE);
 #endif
 
+
    if (is_composite) {
-      if (has_mask)
+      if (has_mask || src_luminance)
          src = ureg_DECL_temporary(ureg);
       else
          src = out;
-      ureg_TEX(ureg, src,
-               TGSI_TEXTURE_2D, src_input, src_sampler);
+      xrender_tex(ureg, src, src_input, src_sampler, imm0,
+                  src_repeat_none, src_swizzle, src_set_alpha);
    } else if (is_fill) {
       if (is_solid) {
-         if (has_mask)
+         if (has_mask || src_luminance)
             src = ureg_dst(src_input);
          else
             ureg_MOV(ureg, out, src_input);
@@ -360,7 +559,7 @@ create_fs(struct pipe_context *pipe,
          struct ureg_src coords, const0124,
             matrow0, matrow1, matrow2;
 
-         if (has_mask)
+         if (has_mask || src_luminance)
             src = ureg_DECL_temporary(ureg);
          else
             src = out;
@@ -385,13 +584,22 @@ create_fs(struct pipe_context *pipe,
       } else
          debug_assert(!"Unknown fill type!");
    }
+   if (src_luminance) {
+      ureg_MOV(ureg, src,
+               ureg_scalar(ureg_src(src), TGSI_SWIZZLE_X));
+      ureg_MOV(ureg, ureg_writemask(src, TGSI_WRITEMASK_XYZ),
+               ureg_scalar(imm0, TGSI_SWIZZLE_X));
+      if (!has_mask)
+         ureg_MOV(ureg, out, ureg_src(src));
+   }
 
    if (has_mask) {
       mask = ureg_DECL_temporary(ureg);
-      ureg_TEX(ureg, mask,
-               TGSI_TEXTURE_2D, mask_pos, mask_sampler);
+      xrender_tex(ureg, mask, mask_pos, mask_sampler, imm0,
+                  mask_repeat_none, mask_swizzle, mask_set_alpha);
       /* src IN mask */
-      src_in_mask(ureg, out, ureg_src(src), ureg_src(mask));
+      src_in_mask(ureg, out, ureg_src(src), ureg_src(mask),
+                  comp_alpha_mask, mask_luminance);
       ureg_release_temporary(ureg, mask);
    }
 
@@ -400,11 +608,11 @@ create_fs(struct pipe_context *pipe,
    return ureg_create_shader_and_destroy(ureg, pipe);
 }
 
-struct xorg_shaders * xorg_shaders_create(struct exa_context *exa)
+struct xorg_shaders * xorg_shaders_create(struct xorg_renderer *r)
 {
    struct xorg_shaders *sc = CALLOC_STRUCT(xorg_shaders);
 
-   sc->exa = exa;
+   sc->r = r;
    sc->vs_hash = cso_hash_create();
    sc->fs_hash = cso_hash_create();
 
@@ -431,9 +639,9 @@ cache_destroy(struct cso_context *cso,
 
 void xorg_shaders_destroy(struct xorg_shaders *sc)
 {
-   cache_destroy(sc->exa->cso, sc->vs_hash,
+   cache_destroy(sc->r->cso, sc->vs_hash,
                  PIPE_SHADER_VERTEX);
-   cache_destroy(sc->exa->cso, sc->fs_hash,
+   cache_destroy(sc->r->cso, sc->fs_hash,
                  PIPE_SHADER_FRAGMENT);
 
    free(sc);
@@ -468,9 +676,9 @@ struct xorg_shader xorg_shaders_get(struct xorg_shaders *sc,
    struct xorg_shader shader = { NULL, NULL };
    void *vs, *fs;
 
-   vs = shader_from_cache(sc->exa->pipe, PIPE_SHADER_VERTEX,
+   vs = shader_from_cache(sc->r->pipe, PIPE_SHADER_VERTEX,
                           sc->vs_hash, vs_traits);
-   fs = shader_from_cache(sc->exa->pipe, PIPE_SHADER_FRAGMENT,
+   fs = shader_from_cache(sc->r->pipe, PIPE_SHADER_FRAGMENT,
                           sc->fs_hash, fs_traits);
 
    debug_assert(vs && fs);
index 1535a0c8c30c145f03389bb9cc47cd34a171fc74..6f2a361d030c7064e2af57959d3c29cad339bef4 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef XORG_EXA_TGSI_H
 #define XORG_EXA_TGSI_H
 
-#include "xorg_exa.h"
+#include "xorg_renderer.h"
 
 enum xorg_vs_traits {
    VS_COMPOSITE        = 1 << 0,
@@ -9,10 +9,12 @@ enum xorg_vs_traits {
    VS_SOLID_FILL       = 1 << 2,
    VS_LINGRAD_FILL     = 1 << 3,
    VS_RADGRAD_FILL     = 1 << 4,
+   VS_YUV              = 1 << 5,
+
+
    VS_FILL             = (VS_SOLID_FILL |
                           VS_LINGRAD_FILL |
                           VS_RADGRAD_FILL)
-   /*VS_TRANSFORM      = 1 << 5*/
 };
 
 enum xorg_fs_traits {
@@ -21,9 +23,23 @@ enum xorg_fs_traits {
    FS_SOLID_FILL       = 1 << 2,
    FS_LINGRAD_FILL     = 1 << 3,
    FS_RADGRAD_FILL     = 1 << 4,
+   FS_CA_FULL          = 1 << 5, /* src.rgba * mask.rgba */
+   FS_CA_SRCALPHA      = 1 << 6, /* src.aaaa * mask.rgba */
+   FS_YUV              = 1 << 7,
+   FS_SRC_REPEAT_NONE  = 1 << 8,
+   FS_MASK_REPEAT_NONE = 1 << 9,
+   FS_SRC_SWIZZLE_RGB  = 1 << 10,
+   FS_MASK_SWIZZLE_RGB = 1 << 11,
+   FS_SRC_SET_ALPHA    = 1 << 12,
+   FS_MASK_SET_ALPHA   = 1 << 13,
+   FS_SRC_LUMINANCE    = 1 << 14,
+   FS_MASK_LUMINANCE   = 1 << 15,
+
    FS_FILL             = (FS_SOLID_FILL |
                           FS_LINGRAD_FILL |
-                          FS_RADGRAD_FILL)
+                          FS_RADGRAD_FILL),
+   FS_COMPONENT_ALPHA  = (FS_CA_FULL |
+                          FS_CA_SRCALPHA)
 };
 
 struct xorg_shader {
@@ -33,7 +49,7 @@ struct xorg_shader {
 
 struct xorg_shaders;
 
-struct xorg_shaders *xorg_shaders_create(struct exa_context *exa);
+struct xorg_shaders *xorg_shaders_create(struct xorg_renderer *renderer);
 void xorg_shaders_destroy(struct xorg_shaders *shaders);
 
 struct xorg_shader xorg_shaders_get(struct xorg_shaders *shaders,
index 26f45f8d64592b7ae1deefec210d815904f8633c..251f331ea7ad5aa4b7983bc099f650218fad0e90 100644 (file)
 
 #include "xorg_tracker.h"
 
-static char *connector_enum_list[] = {
+static char *output_enum_list[] = {
     "Unknown",
     "VGA",
-    "DVI-I",
-    "DVI-D",
-    "DVI-A",
+    "DVI",
+    "DVI",
+    "DVI",
     "Composite",
     "SVIDEO",
     "LVDS",
-    "Component",
-    "9-pin DIN",
-    "DisplayPort",
-    "HDMI Type A",
-    "HDMI Type B",
+    "CTV",
+    "DIN",
+    "DP",
+    "HDMI",
+    "HDMI",
 };
 
 static void
-dpms(xf86OutputPtr output, int mode)
-{
-}
-
-static void
-save(xf86OutputPtr output)
-{
-}
-
-static void
-restore(xf86OutputPtr output)
-{
-}
-
-static int
-mode_valid(xf86OutputPtr output, DisplayModePtr pMode)
-{
-    return MODE_OK;
-}
-
-static Bool
-mode_fixup(xf86OutputPtr output, DisplayModePtr mode,
-          DisplayModePtr adjusted_mode)
-{
-    return TRUE;
-}
-
-static void
-prepare(xf86OutputPtr output)
-{
-    dpms(output, DPMSModeOff);
-}
-
-static void
-mode_set(xf86OutputPtr output, DisplayModePtr mode,
-        DisplayModePtr adjusted_mode)
+output_create_resources(xf86OutputPtr output)
 {
+#ifdef RANDR_12_INTERFACE
+#endif /* RANDR_12_INTERFACE */
 }
 
 static void
-commit(xf86OutputPtr output)
+output_dpms(xf86OutputPtr output, int mode)
 {
-    dpms(output, DPMSModeOn);
-
-    if (output->scrn->pScreen != NULL)
-       xf86_reload_cursors(output->scrn->pScreen);
 }
 
 static xf86OutputStatus
-detect(xf86OutputPtr output)
+output_detect(xf86OutputPtr output)
 {
     drmModeConnectorPtr drm_connector = output->driver_private;
 
@@ -134,7 +97,7 @@ detect(xf86OutputPtr output)
 }
 
 static DisplayModePtr
-get_modes(xf86OutputPtr output)
+output_get_modes(xf86OutputPtr output)
 {
     drmModeConnectorPtr drm_connector = output->driver_private;
     drmModeModeInfoPtr drm_mode = NULL;
@@ -147,7 +110,6 @@ get_modes(xf86OutputPtr output)
            mode = xcalloc(1, sizeof(DisplayModeRec));
            if (!mode)
                continue;
-           mode->type = 0;
            mode->Clock = drm_mode->clock;
            mode->HDisplay = drm_mode->hdisplay;
            mode->HSyncStart = drm_mode->hsync_start;
@@ -162,6 +124,11 @@ get_modes(xf86OutputPtr output)
            mode->VScan = drm_mode->vscan;
            mode->VRefresh = xf86ModeVRefresh(mode);
            mode->Private = (void *)drm_mode;
+           mode->type = 0;
+           if (drm_mode->type & DRM_MODE_TYPE_PREFERRED)
+               mode->type |= M_T_PREFERRED;
+           if (drm_mode->type & DRM_MODE_TYPE_DRIVER)
+               mode->type |= M_T_DRIVER;
            xf86SetModeDefaultName(mode);
            modes = xf86ModesAdd(modes, mode);
            xf86PrintModeline(0, mode);
@@ -171,22 +138,15 @@ get_modes(xf86OutputPtr output)
     return modes;
 }
 
-static void
-destroy(xf86OutputPtr output)
-{
-    drmModeFreeConnector(output->driver_private);
-}
-
-static void
-create_resources(xf86OutputPtr output)
+static int
+output_mode_valid(xf86OutputPtr output, DisplayModePtr pMode)
 {
-#ifdef RANDR_12_INTERFACE
-#endif /* RANDR_12_INTERFACE */
+    return MODE_OK;
 }
 
 #ifdef RANDR_12_INTERFACE
 static Bool
-set_property(xf86OutputPtr output, Atom property, RRPropertyValuePtr value)
+output_set_property(xf86OutputPtr output, Atom property, RRPropertyValuePtr value)
 {
     return TRUE;
 }
@@ -194,53 +154,43 @@ set_property(xf86OutputPtr output, Atom property, RRPropertyValuePtr value)
 
 #ifdef RANDR_13_INTERFACE
 static Bool
-get_property(xf86OutputPtr output, Atom property)
+output_get_property(xf86OutputPtr output, Atom property)
 {
     return TRUE;
 }
 #endif /* RANDR_13_INTERFACE */
 
-#ifdef RANDR_GET_CRTC_INTERFACE
-static xf86CrtcPtr
-get_crtc(xf86OutputPtr output)
+static void
+output_destroy(xf86OutputPtr output)
 {
-    return NULL;
+    drmModeFreeConnector(output->driver_private);
 }
-#endif
 
 static const xf86OutputFuncsRec output_funcs = {
-    .create_resources = create_resources,
-    .dpms = dpms,
-    .save = save,
-    .restore = restore,
-    .mode_valid = mode_valid,
-    .mode_fixup = mode_fixup,
-    .prepare = prepare,
-    .mode_set = mode_set,
-    .commit = commit,
-    .detect = detect,
-    .get_modes = get_modes,
+    .create_resources = output_create_resources,
 #ifdef RANDR_12_INTERFACE
-    .set_property = set_property,
+    .set_property = output_set_property,
 #endif
 #ifdef RANDR_13_INTERFACE
-    .get_property = get_property,
-#endif
-    .destroy = destroy,
-#ifdef RANDR_GET_CRTC_INTERFACE
-    .get_crtc = get_crtc,
+    .get_property = output_get_property,
 #endif
+    .dpms = output_dpms,
+    .detect = output_detect,
+
+    .get_modes = output_get_modes,
+    .mode_valid = output_mode_valid,
+    .destroy = output_destroy,
 };
 
 void
-output_init(ScrnInfoPtr pScrn)
+xorg_output_init(ScrnInfoPtr pScrn)
 {
     modesettingPtr ms = modesettingPTR(pScrn);
     xf86OutputPtr output;
     drmModeResPtr res;
     drmModeConnectorPtr drm_connector = NULL;
     drmModeEncoderPtr drm_encoder = NULL;
-    char *name;
+    char name[32];
     int c, v, p;
 
     res = drmModeGetResources(ms->fd);
@@ -273,7 +223,10 @@ output_init(ScrnInfoPtr pScrn)
        (void)v;
 #endif
 
-       name = connector_enum_list[drm_connector->connector_type];
+       snprintf(name, 32, "%s%d",
+                output_enum_list[drm_connector->connector_type],
+                drm_connector->connector_type_id);
+
 
        output = xf86OutputCreate(pScrn, &output_funcs, name);
        if (!output)
diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.c b/src/gallium/state_trackers/xorg/xorg_renderer.c
new file mode 100644 (file)
index 0000000..d80f341
--- /dev/null
@@ -0,0 +1,700 @@
+#include "xorg_exa.h"
+#include "xorg_renderer.h"
+
+#include "xorg_exa_tgsi.h"
+
+#include "cso_cache/cso_context.h"
+#include "util/u_draw_quad.h"
+#include "util/u_format.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+#include "util/u_rect.h"
+
+#include "pipe/p_inlines.h"
+
+#include <math.h>
+
+#define floatsEqual(x, y) (fabs(x - y) <= 0.00001f * MIN2(fabs(x), fabs(y)))
+#define floatIsZero(x) (floatsEqual((x) + 1, 1))
+
+#define NUM_COMPONENTS 4
+
+static INLINE boolean is_affine(float *matrix)
+{
+   return floatIsZero(matrix[2]) && floatIsZero(matrix[5])
+      && floatsEqual(matrix[8], 1);
+}
+static INLINE void map_point(float *mat, float x, float y,
+                             float *out_x, float *out_y)
+{
+   if (!mat) {
+      *out_x = x;
+      *out_y = y;
+      return;
+   }
+
+   *out_x = mat[0]*x + mat[3]*y + mat[6];
+   *out_y = mat[1]*x + mat[4]*y + mat[7];
+   if (!is_affine(mat)) {
+      float w = 1/(mat[2]*x + mat[5]*y + mat[8]);
+      *out_x *= w;
+      *out_y *= w;
+   }
+}
+
+static INLINE struct pipe_buffer *
+renderer_buffer_create(struct xorg_renderer *r)
+{
+   struct pipe_buffer *buf =
+      pipe_user_buffer_create(r->pipe->screen,
+                              r->buffer,
+                              sizeof(float)*
+                              r->buffer_size);
+   r->buffer_size = 0;
+
+   return buf;
+}
+
+static INLINE void
+renderer_draw(struct xorg_renderer *r)
+{
+   struct pipe_context *pipe = r->pipe;
+   struct pipe_buffer *buf = 0;
+   int num_verts = r->buffer_size/(r->attrs_per_vertex * NUM_COMPONENTS);
+
+   if (!r->buffer_size)
+      return;
+
+   buf = renderer_buffer_create(r);
+
+
+   if (buf) {
+      util_draw_vertex_buffer(pipe, buf, 0,
+                              PIPE_PRIM_QUADS,
+                              num_verts,  /* verts */
+                              r->attrs_per_vertex); /* attribs/vert */
+
+      pipe_buffer_reference(&buf, NULL);
+   }
+}
+
+static INLINE void
+renderer_draw_conditional(struct xorg_renderer *r,
+                          int next_batch)
+{
+   if (r->buffer_size + next_batch >= BUF_SIZE ||
+       (next_batch == 0 && r->buffer_size)) {
+      renderer_draw(r);
+   }
+}
+
+static void
+renderer_init_state(struct xorg_renderer *r)
+{
+   struct pipe_depth_stencil_alpha_state dsa;
+   struct pipe_rasterizer_state raster;
+
+   /* set common initial clip state */
+   memset(&dsa, 0, sizeof(struct pipe_depth_stencil_alpha_state));
+   cso_set_depth_stencil_alpha(r->cso, &dsa);
+
+
+   /* XXX: move to renderer_init_state? */
+   memset(&raster, 0, sizeof(struct pipe_rasterizer_state));
+   raster.gl_rasterization_rules = 1;
+   cso_set_rasterizer(r->cso, &raster);
+
+}
+
+
+static INLINE void
+add_vertex_color(struct xorg_renderer *r,
+                 float x, float y,
+                 float color[4])
+{
+   float *vertex = r->buffer + r->buffer_size;
+
+   vertex[0] = x;
+   vertex[1] = y;
+   vertex[2] = 0.f; /*z*/
+   vertex[3] = 1.f; /*w*/
+
+   vertex[4] = color[0]; /*r*/
+   vertex[5] = color[1]; /*g*/
+   vertex[6] = color[2]; /*b*/
+   vertex[7] = color[3]; /*a*/
+
+   r->buffer_size += 8;
+}
+
+static INLINE void
+add_vertex_1tex(struct xorg_renderer *r,
+                float x, float y, float s, float t)
+{
+   float *vertex = r->buffer + r->buffer_size;
+
+   vertex[0] = x;
+   vertex[1] = y;
+   vertex[2] = 0.f; /*z*/
+   vertex[3] = 1.f; /*w*/
+
+   vertex[4] = s;   /*s*/
+   vertex[5] = t;   /*t*/
+   vertex[6] = 0.f; /*r*/
+   vertex[7] = 1.f; /*q*/
+
+   r->buffer_size += 8;
+}
+
+static void
+add_vertex_data1(struct xorg_renderer *r,
+                 float srcX, float srcY,  float dstX, float dstY,
+                 float width, float height,
+                 struct pipe_texture *src, float *src_matrix)
+{
+   float s0, t0, s1, t1, s2, t2, s3, t3;
+   float pt0[2], pt1[2], pt2[2], pt3[2];
+
+   pt0[0] = srcX;
+   pt0[1] = srcY;
+   pt1[0] = (srcX + width);
+   pt1[1] = srcY;
+   pt2[0] = (srcX + width);
+   pt2[1] = (srcY + height);
+   pt3[0] = srcX;
+   pt3[1] = (srcY + height);
+
+   if (src_matrix) {
+      map_point(src_matrix, pt0[0], pt0[1], &pt0[0], &pt0[1]);
+      map_point(src_matrix, pt1[0], pt1[1], &pt1[0], &pt1[1]);
+      map_point(src_matrix, pt2[0], pt2[1], &pt2[0], &pt2[1]);
+      map_point(src_matrix, pt3[0], pt3[1], &pt3[0], &pt3[1]);
+   }
+
+   s0 =  pt0[0] / src->width0;
+   s1 =  pt1[0] / src->width0;
+   s2 =  pt2[0] / src->width0;
+   s3 =  pt3[0] / src->width0;
+   t0 =  pt0[1] / src->height0;
+   t1 =  pt1[1] / src->height0;
+   t2 =  pt2[1] / src->height0;
+   t3 =  pt3[1] / src->height0;
+
+   /* 1st vertex */
+   add_vertex_1tex(r, dstX, dstY, s0, t0);
+   /* 2nd vertex */
+   add_vertex_1tex(r, dstX + width, dstY, s1, t1);
+   /* 3rd vertex */
+   add_vertex_1tex(r, dstX + width, dstY + height, s2, t2);
+   /* 4th vertex */
+   add_vertex_1tex(r, dstX, dstY + height, s3, t3);
+}
+
+
+static INLINE void
+add_vertex_2tex(struct xorg_renderer *r,
+                float x, float y,
+                float s0, float t0, float s1, float t1)
+{
+   float *vertex = r->buffer + r->buffer_size;
+
+   vertex[0] = x;
+   vertex[1] = y;
+   vertex[2] = 0.f; /*z*/
+   vertex[3] = 1.f; /*w*/
+
+   vertex[4] = s0;  /*s*/
+   vertex[5] = t0;  /*t*/
+   vertex[6] = 0.f; /*r*/
+   vertex[7] = 1.f; /*q*/
+
+   vertex[8] = s1;  /*s*/
+   vertex[9] = t1;  /*t*/
+   vertex[10] = 0.f; /*r*/
+   vertex[11] = 1.f; /*q*/
+
+   r->buffer_size += 12;
+}
+
+static void
+add_vertex_data2(struct xorg_renderer *r,
+                 float srcX, float srcY, float maskX, float maskY,
+                 float dstX, float dstY, float width, float height,
+                 struct pipe_texture *src,
+                 struct pipe_texture *mask,
+                 float *src_matrix, float *mask_matrix)
+{
+   float src_s0, src_t0, src_s1, src_t1;
+   float mask_s0, mask_t0, mask_s1, mask_t1;
+   float spt0[2], spt1[2];
+   float mpt0[2], mpt1[2];
+
+   spt0[0] = srcX;
+   spt0[1] = srcY;
+   spt1[0] = srcX + width;
+   spt1[1] = srcY + height;
+
+   mpt0[0] = maskX;
+   mpt0[1] = maskY;
+   mpt1[0] = maskX + width;
+   mpt1[1] = maskY + height;
+
+   if (src_matrix) {
+      map_point(src_matrix, spt0[0], spt0[1], &spt0[0], &spt0[1]);
+      map_point(src_matrix, spt1[0], spt1[1], &spt1[0], &spt1[1]);
+   }
+
+   if (mask_matrix) {
+      map_point(mask_matrix, mpt0[0], mpt0[1], &mpt0[0], &mpt0[1]);
+      map_point(mask_matrix, mpt1[0], mpt1[1], &mpt1[0], &mpt1[1]);
+   }
+
+   src_s0 = spt0[0] / src->width0;
+   src_t0 = spt0[1] / src->height0;
+   src_s1 = spt1[0] / src->width0;
+   src_t1 = spt1[1] / src->height0;
+
+   mask_s0 = mpt0[0] / mask->width0;
+   mask_t0 = mpt0[1] / mask->height0;
+   mask_s1 = mpt1[0] / mask->width0;
+   mask_t1 = mpt1[1] / mask->height0;
+
+   /* 1st vertex */
+   add_vertex_2tex(r, dstX, dstY,
+                   src_s0, src_t0, mask_s0, mask_t0);
+   /* 2nd vertex */
+   add_vertex_2tex(r, dstX + width, dstY,
+                   src_s1, src_t0, mask_s1, mask_t0);
+   /* 3rd vertex */
+   add_vertex_2tex(r, dstX + width, dstY + height,
+                   src_s1, src_t1, mask_s1, mask_t1);
+   /* 4th vertex */
+   add_vertex_2tex(r, dstX, dstY + height,
+                   src_s0, src_t1, mask_s0, mask_t1);
+}
+
+static struct pipe_buffer *
+setup_vertex_data_yuv(struct xorg_renderer *r,
+                      float srcX, float srcY, float srcW, float srcH,
+                      float dstX, float dstY, float dstW, float dstH,
+                      struct pipe_texture **tex)
+{
+   float s0, t0, s1, t1;
+   float spt0[2], spt1[2];
+
+   spt0[0] = srcX;
+   spt0[1] = srcY;
+   spt1[0] = srcX + srcW;
+   spt1[1] = srcY + srcH;
+
+   s0 = spt0[0] / tex[0]->width0;
+   t0 = spt0[1] / tex[0]->height0;
+   s1 = spt1[0] / tex[0]->width0;
+   t1 = spt1[1] / tex[0]->height0;
+
+   /* 1st vertex */
+   add_vertex_1tex(r, dstX, dstY, s0, t0);
+   /* 2nd vertex */
+   add_vertex_1tex(r, dstX + dstW, dstY,
+                   s1, t0);
+   /* 3rd vertex */
+   add_vertex_1tex(r, dstX + dstW, dstY + dstH,
+                   s1, t1);
+   /* 4th vertex */
+   add_vertex_1tex(r, dstX, dstY + dstH,
+                   s0, t1);
+
+   return renderer_buffer_create(r);
+}
+
+
+
+/* Set up framebuffer, viewport and vertex shader constant buffer
+ * state for a particular destinaton surface.  In all our rendering,
+ * these concepts are linked.
+ */
+void renderer_bind_destination(struct xorg_renderer *r,
+                               struct pipe_surface *surface,
+                               int width,
+                               int height )
+{
+
+   struct pipe_framebuffer_state fb;
+   struct pipe_viewport_state viewport;
+
+   /* Framebuffer uses actual surface width/height
+    */
+   memset(&fb, 0, sizeof fb);
+   fb.width  = surface->width;
+   fb.height = surface->height;
+   fb.nr_cbufs = 1;
+   fb.cbufs[0] = surface;
+   fb.zsbuf = 0;
+
+   /* Viewport just touches the bit we're interested in:
+    */
+   viewport.scale[0] =  width / 2.f;
+   viewport.scale[1] =  height / 2.f;
+   viewport.scale[2] =  1.0;
+   viewport.scale[3] =  1.0;
+   viewport.translate[0] = width / 2.f;
+   viewport.translate[1] = height / 2.f;
+   viewport.translate[2] = 0.0;
+   viewport.translate[3] = 0.0;
+
+   /* Constant buffer set up to match viewport dimensions:
+    */
+   if (r->fb_width != width ||
+       r->fb_height != height) 
+   {
+      float vs_consts[8] = {
+         2.f/width, 2.f/height, 1, 1,
+         -1, -1, 0, 0
+      };
+
+      r->fb_width = width;
+      r->fb_height = height;
+
+      renderer_set_constants(r, PIPE_SHADER_VERTEX,
+                             vs_consts, sizeof vs_consts);
+   }
+
+   cso_set_framebuffer(r->cso, &fb);
+   cso_set_viewport(r->cso, &viewport);
+}
+
+
+struct xorg_renderer * renderer_create(struct pipe_context *pipe)
+{
+   struct xorg_renderer *renderer = CALLOC_STRUCT(xorg_renderer);
+
+   renderer->pipe = pipe;
+   renderer->cso = cso_create_context(pipe);
+   renderer->shaders = xorg_shaders_create(renderer);
+
+   renderer_init_state(renderer);
+
+   return renderer;
+}
+
+void renderer_destroy(struct xorg_renderer *r)
+{
+   struct pipe_constant_buffer *vsbuf = &r->vs_const_buffer;
+   struct pipe_constant_buffer *fsbuf = &r->fs_const_buffer;
+
+   if (vsbuf && vsbuf->buffer)
+      pipe_buffer_reference(&vsbuf->buffer, NULL);
+
+   if (fsbuf && fsbuf->buffer)
+      pipe_buffer_reference(&fsbuf->buffer, NULL);
+
+   if (r->shaders) {
+      xorg_shaders_destroy(r->shaders);
+      r->shaders = NULL;
+   }
+
+   if (r->cso) {
+      cso_release_all(r->cso);
+      cso_destroy_context(r->cso);
+      r->cso = NULL;
+   }
+}
+
+
+
+
+
+void renderer_set_constants(struct xorg_renderer *r,
+                            int shader_type,
+                            const float *params,
+                            int param_bytes)
+{
+   struct pipe_constant_buffer *cbuf =
+      (shader_type == PIPE_SHADER_VERTEX) ? &r->vs_const_buffer :
+      &r->fs_const_buffer;
+
+   pipe_buffer_reference(&cbuf->buffer, NULL);
+   cbuf->buffer = pipe_buffer_create(r->pipe->screen, 16,
+                                     PIPE_BUFFER_USAGE_CONSTANT,
+                                     param_bytes);
+
+   if (cbuf->buffer) {
+      pipe_buffer_write(r->pipe->screen, cbuf->buffer,
+                        0, param_bytes, params);
+   }
+   r->pipe->set_constant_buffer(r->pipe, shader_type, 0, cbuf);
+}
+
+
+void renderer_copy_prepare(struct xorg_renderer *r,
+                           struct pipe_surface *dst_surface,
+                           struct pipe_texture *src_texture)
+{
+   struct pipe_context *pipe = r->pipe;
+   struct pipe_screen *screen = pipe->screen;
+   struct xorg_shader shader;
+
+   assert(screen->is_format_supported(screen, dst_surface->format,
+                                      PIPE_TEXTURE_2D,
+                                      PIPE_TEXTURE_USAGE_RENDER_TARGET,
+                                      0));
+   (void) screen;
+
+
+   /* set misc state we care about */
+   {
+      struct pipe_blend_state blend;
+      memset(&blend, 0, sizeof(blend));
+      blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE;
+      blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE;
+      blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
+      blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
+      blend.colormask = PIPE_MASK_RGBA;
+      cso_set_blend(r->cso, &blend);
+   }
+
+   /* sampler */
+   {
+      struct pipe_sampler_state sampler;
+      memset(&sampler, 0, sizeof(sampler));
+      sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
+      sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
+      sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
+      sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
+      sampler.min_img_filter = PIPE_TEX_FILTER_NEAREST;
+      sampler.mag_img_filter = PIPE_TEX_FILTER_NEAREST;
+      sampler.normalized_coords = 1;
+      cso_single_sampler(r->cso, 0, &sampler);
+      cso_single_sampler_done(r->cso);
+   }
+
+   renderer_bind_destination(r, dst_surface, 
+                             dst_surface->width,
+                             dst_surface->height);
+
+   /* texture */
+   cso_set_sampler_textures(r->cso, 1, &src_texture);
+
+   /* shaders */
+   shader = xorg_shaders_get(r->shaders,
+                             VS_COMPOSITE,
+                             FS_COMPOSITE);
+   cso_set_vertex_shader_handle(r->cso, shader.vs);
+   cso_set_fragment_shader_handle(r->cso, shader.fs);
+
+   r->buffer_size = 0;
+   r->attrs_per_vertex = 2;
+}
+
+struct pipe_texture *
+renderer_clone_texture(struct xorg_renderer *r,
+                       struct pipe_texture *src)
+{
+   enum pipe_format format;
+   struct pipe_context *pipe = r->pipe;
+   struct pipe_screen *screen = pipe->screen;
+   struct pipe_texture *pt;
+   struct pipe_texture templ;
+
+   if (pipe->is_texture_referenced(pipe, src, 0, 0) &
+       PIPE_REFERENCED_FOR_WRITE)
+      pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
+
+   /* the coming in texture should already have that invariance */
+   debug_assert(screen->is_format_supported(screen, src->format,
+                                            PIPE_TEXTURE_2D,
+                                            PIPE_TEXTURE_USAGE_SAMPLER, 0));
+
+   format = src->format;
+
+   memset(&templ, 0, sizeof(templ));
+   templ.target = PIPE_TEXTURE_2D;
+   templ.format = format;
+   templ.last_level = 0;
+   templ.width0 = src->width0;
+   templ.height0 = src->height0;
+   templ.depth0 = 1;
+   templ.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER;
+
+   pt = screen->texture_create(screen, &templ);
+
+   debug_assert(!pt || pipe_is_referenced(&pt->reference));
+
+   if (!pt)
+      return NULL;
+
+   {
+      /* copy source framebuffer surface into texture */
+      struct pipe_surface *ps_read = screen->get_tex_surface(
+         screen, src, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ);
+      struct pipe_surface *ps_tex = screen->get_tex_surface(
+         screen, pt, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE );
+      if (pipe->surface_copy) {
+         pipe->surface_copy(pipe,
+                ps_tex, /* dest */
+                0, 0, /* destx/y */
+                ps_read,
+                0, 0, src->width0, src->height0);
+      } else {
+          util_surface_copy(pipe, FALSE,
+                ps_tex, /* dest */
+                0, 0, /* destx/y */
+                ps_read,
+                0, 0, src->width0, src->height0);
+      }
+      pipe_surface_reference(&ps_read, NULL);
+      pipe_surface_reference(&ps_tex, NULL);
+   }
+
+   return pt;
+}
+
+
+void renderer_copy_pixmap(struct xorg_renderer *r,
+                          int dx, int dy,
+                          int sx, int sy,
+                          int width, int height,
+                          float src_width,
+                          float src_height)
+{
+   float s0, t0, s1, t1;
+   float x0, y0, x1, y1;
+
+
+   /* XXX: could put the texcoord scaling calculation into the vertex
+    * shader.
+    */
+   s0 = sx            / src_width;
+   s1 = (sx + width)  / src_width;
+   t0 = sy            / src_height;
+   t1 = (sy + height) / src_height;
+
+   x0 = dx;
+   x1 = dx + width;
+   y0 = dy;
+   y1 = dy + height;
+
+   /* draw quad */
+   renderer_draw_conditional(r, 4*8);
+   add_vertex_1tex(r, x0, y0, s0, t0);
+   add_vertex_1tex(r, x1, y0, s1, t0);
+   add_vertex_1tex(r, x1, y1, s1, t1);
+   add_vertex_1tex(r, x0, y1, s0, t1);
+}
+
+
+
+
+void renderer_draw_yuv(struct xorg_renderer *r,
+                       int src_x, int src_y, int src_w, int src_h,
+                       int dst_x, int dst_y, int dst_w, int dst_h,
+                       struct pipe_texture **textures)
+{
+   struct pipe_context *pipe = r->pipe;
+   struct pipe_buffer *buf = 0;
+
+   buf = setup_vertex_data_yuv(r,
+                               src_x, src_y, src_w, src_h,
+                               dst_x, dst_y, dst_w, dst_h,
+                               textures);
+
+   if (buf) {
+      const int num_attribs = 2; /*pos + tex coord*/
+
+      util_draw_vertex_buffer(pipe, buf, 0,
+                              PIPE_PRIM_QUADS,
+                              4,  /* verts */
+                              num_attribs); /* attribs/vert */
+
+      pipe_buffer_reference(&buf, NULL);
+   }
+}
+
+void renderer_begin_solid(struct xorg_renderer *r)
+{
+   r->buffer_size = 0;
+   r->attrs_per_vertex = 2;
+}
+
+void renderer_solid(struct xorg_renderer *r,
+                    int x0, int y0,
+                    int x1, int y1,
+                    float *color)
+{
+   /*
+   debug_printf("solid rect[(%d, %d), (%d, %d)], rgba[%f, %f, %f, %f]\n",
+   x0, y0, x1, y1, color[0], color[1], color[2], color[3]);*/
+
+   renderer_draw_conditional(r, 4 * 8);
+
+   /* 1st vertex */
+   add_vertex_color(r, x0, y0, color);
+   /* 2nd vertex */
+   add_vertex_color(r, x1, y0, color);
+   /* 3rd vertex */
+   add_vertex_color(r, x1, y1, color);
+   /* 4th vertex */
+   add_vertex_color(r, x0, y1, color);
+}
+
+void renderer_draw_flush(struct xorg_renderer *r)
+{
+   renderer_draw_conditional(r, 0);
+}
+
+void renderer_begin_textures(struct xorg_renderer *r,
+                             struct pipe_texture **textures,
+                             int num_textures)
+{
+   r->attrs_per_vertex = 1 + num_textures;
+   r->buffer_size = 0;
+}
+
+void renderer_texture(struct xorg_renderer *r,
+                      int *pos,
+                      int width, int height,
+                      struct pipe_texture **textures,
+                      int num_textures,
+                      float *src_matrix,
+                      float *mask_matrix)
+{
+
+#if 0
+   if (src_matrix) {
+      debug_printf("src_matrix = \n");
+      debug_printf("%f, %f, %f\n", src_matrix[0], src_matrix[1], src_matrix[2]);
+      debug_printf("%f, %f, %f\n", src_matrix[3], src_matrix[4], src_matrix[5]);
+      debug_printf("%f, %f, %f\n", src_matrix[6], src_matrix[7], src_matrix[8]);
+   }
+   if (mask_matrix) {
+      debug_printf("mask_matrix = \n");
+      debug_printf("%f, %f, %f\n", mask_matrix[0], mask_matrix[1], mask_matrix[2]);
+      debug_printf("%f, %f, %f\n", mask_matrix[3], mask_matrix[4], mask_matrix[5]);
+      debug_printf("%f, %f, %f\n", mask_matrix[6], mask_matrix[7], mask_matrix[8]);
+   }
+#endif
+
+   switch(r->attrs_per_vertex) {
+   case 2:
+      renderer_draw_conditional(r, 4 * 8);
+      add_vertex_data1(r,
+                       pos[0], pos[1], /* src */
+                       pos[4], pos[5], /* dst */
+                       width, height,
+                       textures[0], src_matrix);
+      break;
+   case 3:
+      renderer_draw_conditional(r, 4 * 12);
+      add_vertex_data2(r,
+                       pos[0], pos[1], /* src */
+                       pos[2], pos[3], /* mask */
+                       pos[4], pos[5], /* dst */
+                       width, height,
+                       textures[0], textures[1],
+                       src_matrix, mask_matrix);
+      break;
+   default:
+      debug_assert(!"Unsupported number of textures");
+      break;
+   }
+}
diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.h b/src/gallium/state_trackers/xorg/xorg_renderer.h
new file mode 100644 (file)
index 0000000..5272cde
--- /dev/null
@@ -0,0 +1,95 @@
+#ifndef XORG_RENDERER_H
+#define XORG_RENDERER_H
+
+#include "pipe/p_context.h"
+#include "pipe/p_state.h"
+
+struct xorg_shaders;
+struct exa_pixmap_priv;
+
+/* max number of vertices *
+ * max number of attributes per vertex *
+ * max number of components per attribute
+ *
+ * currently the max is 100 quads
+ */
+#define BUF_SIZE (100 * 4 * 3 * 4)
+
+struct xorg_renderer {
+   struct pipe_context *pipe;
+
+   struct cso_context *cso;
+   struct xorg_shaders *shaders;
+
+   int fb_width;
+   int fb_height;
+   struct pipe_constant_buffer vs_const_buffer;
+   struct pipe_constant_buffer fs_const_buffer;
+
+   float buffer[BUF_SIZE];
+   int buffer_size;
+
+   /* number of attributes per vertex for the current
+    * draw operation */
+   int attrs_per_vertex;
+};
+
+struct xorg_renderer *renderer_create(struct pipe_context *pipe);
+void renderer_destroy(struct xorg_renderer *renderer);
+
+void renderer_bind_destination(struct xorg_renderer *r,
+                               struct pipe_surface *surface,
+                               int width,
+                               int height );
+
+void renderer_bind_framebuffer(struct xorg_renderer *r,
+                               struct exa_pixmap_priv *priv);
+void renderer_bind_viewport(struct xorg_renderer *r,
+                            struct exa_pixmap_priv *dst);
+void renderer_set_constants(struct xorg_renderer *r,
+                            int shader_type,
+                            const float *buffer,
+                            int size);
+
+
+void renderer_draw_yuv(struct xorg_renderer *r,
+                       int src_x, int src_y, int src_w, int src_h,
+                       int dst_x, int dst_y, int dst_w, int dst_h,
+                       struct pipe_texture **textures);
+
+void renderer_begin_solid(struct xorg_renderer *r);
+void renderer_solid(struct xorg_renderer *r,
+                    int x0, int y0,
+                    int x1, int y1,
+                    float *color);
+
+void renderer_begin_textures(struct xorg_renderer *r,
+                             struct pipe_texture **textures,
+                             int num_textures);
+void renderer_texture(struct xorg_renderer *r,
+                      int *pos,
+                      int width, int height,
+                      struct pipe_texture **textures,
+                      int num_textures,
+                      float *src_matrix,
+                      float *mask_matrix);
+
+void renderer_draw_flush(struct xorg_renderer *r);
+
+struct pipe_texture *
+renderer_clone_texture(struct xorg_renderer *r,
+                       struct pipe_texture *src);
+
+void renderer_copy_prepare(struct xorg_renderer *r,
+                           struct pipe_surface *dst_surface,
+                           struct pipe_texture *src_texture);
+
+void renderer_copy_pixmap(struct xorg_renderer *r,
+                          int dx, int dy,
+                          int sx, int sy,
+                          int width, int height,
+                          float src_width,
+                          float src_height);
+
+
+#endif
index db2f16f63ea24eac8bc59c24bddc34a79cd95328..4d5d4780dc412eef6652b3a67bf41ad474b72fa4 100644 (file)
 
 #define DRV_ERROR(msg) xf86DrvMsg(pScrn->scrnIndex, X_ERROR, msg);
 
+struct kms_bo;
+struct kms_driver;
+struct exa_context;
+
 typedef struct
 {
     int lastInstance;
@@ -59,6 +63,8 @@ typedef struct
     ScrnInfoPtr pScrn_2;
 } EntRec, *EntPtr;
 
+#define XORG_NR_FENCES 3
+
 typedef struct _modesettingRec
 {
     /* drm */
@@ -82,20 +88,39 @@ typedef struct _modesettingRec
     unsigned int SaveGeneration;
 
     void (*blockHandler)(int, pointer, pointer, pointer);
+    struct pipe_fence_handle *fence[XORG_NR_FENCES];
+
     CreateScreenResourcesProcPtr createScreenResources;
 
+    /* for frontbuffer backing store */
+    Bool (*destroy_front_buffer)(ScrnInfoPtr pScrn);
+    Bool (*create_front_buffer)(ScrnInfoPtr pScrn);
+    Bool (*bind_front_buffer)(ScrnInfoPtr pScrn);
+
+    /* kms */
+    struct kms_driver *kms;
+    struct kms_bo *root_bo;
+
     /* gallium */
     struct drm_api *api;
     struct pipe_screen *screen;
     struct pipe_context *ctx;
     boolean d_depth_bits_last;
     boolean ds_depth_bits_last;
+    struct pipe_texture *root_texture;
 
     /* exa */
-    void *exa;
+    struct exa_context *exa;
     Bool noEvict;
     Bool debug_fallback;
 
+    /* winsys hocks */
+    Bool (*winsys_screen_init)(ScrnInfoPtr pScr);
+    Bool (*winsys_screen_close)(ScrnInfoPtr pScr);
+    Bool (*winsys_enter_vt)(ScrnInfoPtr pScr);
+    Bool (*winsys_leave_vt)(ScrnInfoPtr pScr);
+    void *winsys_priv;
+
 #ifdef DRM_MODE_FEATURE_DIRTYFB
     DamagePtr damage;
 #endif
@@ -110,17 +135,22 @@ typedef struct _modesettingRec
 struct pipe_texture *
 xorg_exa_get_texture(PixmapPtr pPixmap);
 
-unsigned
-xorg_exa_get_pixmap_handle(PixmapPtr pPixmap, unsigned *stride);
-
 int
 xorg_exa_set_displayed_usage(PixmapPtr pPixmap);
 
 int
 xorg_exa_set_shared_usage(PixmapPtr pPixmap);
 
+Bool
+xorg_exa_set_texture(PixmapPtr pPixmap, struct  pipe_texture *tex);
+
+struct pipe_texture *
+xorg_exa_create_root_texture(ScrnInfoPtr pScrn,
+                            int width, int height,
+                            int depth, int bpp);
+
 void *
-xorg_exa_init(ScrnInfoPtr pScrn);
+xorg_exa_init(ScrnInfoPtr pScrn, Bool accel);
 
 void
 xorg_exa_close(ScrnInfoPtr pScrn);
@@ -130,33 +160,34 @@ xorg_exa_close(ScrnInfoPtr pScrn);
  * xorg_dri2.c
  */
 Bool
-driScreenInit(ScreenPtr pScreen);
+xorg_dri2_init(ScreenPtr pScreen);
 
 void
-driCloseScreen(ScreenPtr pScreen);
+xorg_dri2_close(ScreenPtr pScreen);
 
 
 /***********************************************************************
  * xorg_crtc.c
  */
 void
-crtc_init(ScrnInfoPtr pScrn);
+xorg_crtc_init(ScrnInfoPtr pScrn);
 
 void
-crtc_cursor_destroy(xf86CrtcPtr crtc);
+xorg_crtc_cursor_destroy(xf86CrtcPtr crtc);
 
 
 /***********************************************************************
  * xorg_output.c
  */
 void
-output_init(ScrnInfoPtr pScrn);
+xorg_output_init(ScrnInfoPtr pScrn);
+
 
 /***********************************************************************
  * xorg_xv.c
  */
 void
-xorg_init_video(ScreenPtr pScreen);
+xorg_xv_init(ScreenPtr pScreen);
 
 
 #endif /* _XORG_TRACKER_H_ */
index 88955d47fd39542969cf9825ad0774ce140c72b9..6b5a41a372724cba2ba69c3ac456f386b9e4dd07 100644 (file)
@@ -4,10 +4,53 @@
 #include <X11/extensions/Xv.h>
 #include <fourcc.h>
 
+#include "xorg_exa.h"
+#include "xorg_renderer.h"
+#include "xorg_exa_tgsi.h"
+
+#include "cso_cache/cso_context.h"
+
+#include "pipe/p_screen.h"
+#include "pipe/p_inlines.h"
+
+#include "util/u_format.h"
+
 /*XXX get these from pipe's texture limits */
 #define IMAGE_MAX_WIDTH                2048
 #define IMAGE_MAX_HEIGHT       2048
 
+#define RES_720P_X 1280
+#define RES_720P_Y 720
+
+
+/* The ITU-R BT.601 conversion matrix for SDTV. */
+/* original, matrix, but we transpose it to
+ * make the shader easier
+static const float bt_601[] = {
+    1.0, 0.0, 1.4075,   ,
+    1.0, -0.3455, -0.7169, 0,
+    1.0, 1.7790, 0., 0,
+};*/
+static const float bt_601[] = {
+    1.0, 1.0, 1.0,        0.5,
+    0.0, -0.3455, 1.7790, 0,
+    1.4075, -0.7169, 0.,  0,
+};
+
+/* The ITU-R BT.709 conversion matrix for HDTV. */
+/* original, but we transpose to make the conversion
+ * in the shader easier
+static const float bt_709[] = {
+    1.0, 0.0, 1.581, 0,
+    1.0, -0.1881, -0.47, 0,
+    1.0, 1.8629, 0., 0,
+};*/
+static const float bt_709[] = {
+    1.0,   1.0,     1.0,     0.5,
+    0.0,  -0.1881,  1.8629,  0,
+    1.581,-0.47   , 0.0,     0,
+};
+
 #define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE)
 
 static Atom xvBrightness, xvContrast;
@@ -32,34 +75,70 @@ static XF86VideoEncodingRec DummyEncoding[1] = {
    }
 };
 
-#define NUM_IMAGES 2
+#define NUM_IMAGES 3
 static XF86ImageRec Images[NUM_IMAGES] = {
    XVIMAGE_UYVY,
    XVIMAGE_YUY2,
+   XVIMAGE_YV12,
 };
 
 struct xorg_xv_port_priv {
+   struct xorg_renderer *r;
+
    RegionRec clip;
+
+   int brightness;
+   int contrast;
+
+   int current_set;
+   /* juggle two sets of seperate Y, U and V
+    * textures */
+   struct pipe_texture *yuv[2][3];
 };
 
 
 static void
 stop_video(ScrnInfoPtr pScrn, pointer data, Bool shutdown)
 {
+   struct xorg_xv_port_priv *priv = (struct xorg_xv_port_priv *)data;
+
+   REGION_EMPTY(pScrn->pScreen, &priv->clip);
 }
 
 static int
 set_port_attribute(ScrnInfoPtr pScrn,
                    Atom attribute, INT32 value, pointer data)
 {
-   return 0;
+   struct xorg_xv_port_priv *priv = (struct xorg_xv_port_priv *)data;
+
+   if (attribute == xvBrightness) {
+      if ((value < -128) || (value > 127))
+         return BadValue;
+      priv->brightness = value;
+   } else if (attribute == xvContrast) {
+      if ((value < 0) || (value > 255))
+         return BadValue;
+      priv->contrast = value;
+   } else
+      return BadMatch;
+
+   return Success;
 }
 
 static int
 get_port_attribute(ScrnInfoPtr pScrn,
                    Atom attribute, INT32 * value, pointer data)
 {
-   return 0;
+   struct xorg_xv_port_priv *priv = (struct xorg_xv_port_priv *)data;
+
+   if (attribute == xvBrightness)
+      *value = priv->brightness;
+   else if (attribute == xvContrast)
+      *value = priv->contrast;
+   else
+      return BadMatch;
+
+   return Success;
 }
 
 static void
@@ -69,6 +148,408 @@ query_best_size(ScrnInfoPtr pScrn,
                 short drw_w, short drw_h,
                 unsigned int *p_w, unsigned int *p_h, pointer data)
 {
+   if (vid_w > (drw_w << 1))
+      drw_w = vid_w >> 1;
+   if (vid_h > (drw_h << 1))
+      drw_h = vid_h >> 1;
+
+   *p_w = drw_w;
+   *p_h = drw_h;
+}
+
+static INLINE struct pipe_texture *
+create_component_texture(struct pipe_context *pipe,
+                         int width, int height)
+{
+   struct pipe_screen *screen = pipe->screen;
+   struct pipe_texture *tex = 0;
+   struct pipe_texture templ;
+
+   memset(&templ, 0, sizeof(templ));
+   templ.target = PIPE_TEXTURE_2D;
+   templ.format = PIPE_FORMAT_L8_UNORM;
+   templ.last_level = 0;
+   templ.width0 = width;
+   templ.height0 = height;
+   templ.depth0 = 1;
+   templ.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER;
+
+   tex = screen->texture_create(screen, &templ);
+
+   return tex;
+}
+
+static int
+check_yuv_textures(struct xorg_xv_port_priv *priv,  int width, int height)
+{
+   struct pipe_texture **dst = priv->yuv[priv->current_set];
+   if (!dst[0] ||
+       dst[0]->width0 != width ||
+       dst[0]->height0 != height) {
+      pipe_texture_reference(&dst[0], NULL);
+   }
+   if (!dst[1] ||
+       dst[1]->width0 != width ||
+       dst[1]->height0 != height) {
+      pipe_texture_reference(&dst[1], NULL);
+   }
+   if (!dst[2] ||
+       dst[2]->width0 != width ||
+       dst[2]->height0 != height) {
+      pipe_texture_reference(&dst[2], NULL);
+   }
+
+   if (!dst[0])
+      dst[0] = create_component_texture(priv->r->pipe, width, height);
+
+   if (!dst[1])
+      dst[1] = create_component_texture(priv->r->pipe, width, height);
+
+   if (!dst[2])
+      dst[2] = create_component_texture(priv->r->pipe, width, height);
+
+   if (!dst[0] || !dst[1] || !dst[2])
+      return BadAlloc;
+
+   return Success;
+}
+
+static int
+query_image_attributes(ScrnInfoPtr pScrn,
+                       int id,
+                       unsigned short *w, unsigned short *h,
+                       int *pitches, int *offsets)
+{
+   int size, tmp;
+
+   if (*w > IMAGE_MAX_WIDTH)
+      *w = IMAGE_MAX_WIDTH;
+   if (*h > IMAGE_MAX_HEIGHT)
+      *h = IMAGE_MAX_HEIGHT;
+
+   *w = (*w + 1) & ~1;
+   if (offsets)
+      offsets[0] = 0;
+
+   switch (id) {
+   case FOURCC_YV12:
+      *h = (*h + 1) & ~1;
+      size = (*w + 3) & ~3;
+      if (pitches) {
+         pitches[0] = size;
+      }
+      size *= *h;
+      if (offsets) {
+         offsets[1] = size;
+      }
+      tmp = ((*w >> 1) + 3) & ~3;
+      if (pitches) {
+         pitches[1] = pitches[2] = tmp;
+      }
+      tmp *= (*h >> 1);
+      size += tmp;
+      if (offsets) {
+         offsets[2] = size;
+      }
+      size += tmp;
+      break;
+   case FOURCC_UYVY:
+   case FOURCC_YUY2:
+   default:
+      size = *w << 1;
+      if (pitches)
+        pitches[0] = size;
+      size *= *h;
+      break;
+   }
+
+   return size;
+}
+
+static void
+copy_packed_data(ScrnInfoPtr pScrn,
+                 struct xorg_xv_port_priv *port,
+                 int id,
+                 unsigned char *buf,
+                 int left,
+                 int top,
+                 unsigned short w, unsigned short h)
+{
+   int i, j;
+   struct pipe_texture **dst = port->yuv[port->current_set];
+   struct pipe_transfer *ytrans, *utrans, *vtrans;
+   struct pipe_screen *screen = port->r->pipe->screen;
+   char *ymap, *vmap, *umap;
+   unsigned char y1, y2, u, v;
+   int yidx, uidx, vidx;
+   int y_array_size = w * h;
+
+   ytrans = screen->get_tex_transfer(screen, dst[0],
+                                     0, 0, 0,
+                                     PIPE_TRANSFER_WRITE,
+                                     left, top, w, h);
+   utrans = screen->get_tex_transfer(screen, dst[1],
+                                     0, 0, 0,
+                                     PIPE_TRANSFER_WRITE,
+                                     left, top, w, h);
+   vtrans = screen->get_tex_transfer(screen, dst[2],
+                                     0, 0, 0,
+                                     PIPE_TRANSFER_WRITE,
+                                     left, top, w, h);
+
+   ymap = (char*)screen->transfer_map(screen, ytrans);
+   umap = (char*)screen->transfer_map(screen, utrans);
+   vmap = (char*)screen->transfer_map(screen, vtrans);
+
+   yidx = uidx = vidx = 0;
+
+   switch (id) {
+   case FOURCC_YV12: {
+      int pitches[3], offsets[3];
+      unsigned char *y, *u, *v;
+      query_image_attributes(pScrn, FOURCC_YV12,
+                             &w, &h, pitches, offsets);
+
+      y = buf + offsets[0];
+      v = buf + offsets[1];
+      u = buf + offsets[2];
+      for (i = 0; i < h; ++i) {
+         for (j = 0; j < w; ++j) {
+            int yoffset = (w*i+j);
+            int ii = (i|1), jj = (j|1);
+            int vuoffset = (w/2)*(ii/2) + (jj/2);
+            ymap[yidx++] = y[yoffset];
+            umap[uidx++] = u[vuoffset];
+            vmap[vidx++] = v[vuoffset];
+         }
+      }
+   }
+      break;
+   case FOURCC_UYVY:
+      for (i = 0; i < y_array_size; i +=2 ) {
+         /* extracting two pixels */
+         u  = buf[0];
+         y1 = buf[1];
+         v  = buf[2];
+         y2 = buf[3];
+         buf += 4;
+
+         ymap[yidx++] = y1;
+         ymap[yidx++] = y2;
+         umap[uidx++] = u;
+         umap[uidx++] = u;
+         vmap[vidx++] = v;
+         vmap[vidx++] = v;
+      }
+      break;
+   case FOURCC_YUY2:
+      for (i = 0; i < y_array_size; i +=2 ) {
+         /* extracting two pixels */
+         y1 = buf[0];
+         u  = buf[1];
+         y2 = buf[2];
+         v  = buf[3];
+
+         buf += 4;
+
+         ymap[yidx++] = y1;
+         ymap[yidx++] = y2;
+         umap[uidx++] = u;
+         umap[uidx++] = u;
+         vmap[vidx++] = v;
+         vmap[vidx++] = v;
+      }
+      break;
+   default:
+      debug_assert(!"Unsupported yuv format!");
+      break;
+   }
+
+   screen->transfer_unmap(screen, ytrans);
+   screen->transfer_unmap(screen, utrans);
+   screen->transfer_unmap(screen, vtrans);
+   screen->tex_transfer_destroy(ytrans);
+   screen->tex_transfer_destroy(utrans);
+   screen->tex_transfer_destroy(vtrans);
+}
+
+
+static void
+setup_fs_video_constants(struct xorg_renderer *r, boolean hdtv)
+{
+   const int param_bytes = 12 * sizeof(float);
+   const float *video_constants = (hdtv) ? bt_709 : bt_601;
+
+   renderer_set_constants(r, PIPE_SHADER_FRAGMENT,
+                          video_constants, param_bytes);
+}
+
+static void
+draw_yuv(struct xorg_xv_port_priv *port,
+         int src_x, int src_y, int src_w, int src_h,
+         int dst_x, int dst_y, int dst_w, int dst_h)
+{
+   struct pipe_texture **textures = port->yuv[port->current_set];
+
+   renderer_draw_yuv(port->r,
+                     src_x, src_y, src_w, src_h,
+                     dst_x, dst_y, dst_w, dst_h,
+                     textures);
+}
+
+static void
+bind_blend_state(struct xorg_xv_port_priv *port)
+{
+   struct pipe_blend_state blend;
+
+   memset(&blend, 0, sizeof(struct pipe_blend_state));
+   blend.blend_enable = 1;
+   blend.colormask |= PIPE_MASK_RGBA;
+
+   /* porter&duff src */
+   blend.rgb_src_factor   = PIPE_BLENDFACTOR_ONE;
+   blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE;
+   blend.rgb_dst_factor   = PIPE_BLENDFACTOR_ZERO;
+   blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
+
+   cso_set_blend(port->r->cso, &blend);
+}
+
+
+static void
+bind_shaders(struct xorg_xv_port_priv *port)
+{
+   unsigned vs_traits = 0, fs_traits = 0;
+   struct xorg_shader shader;
+
+   vs_traits |= VS_YUV;
+   fs_traits |= FS_YUV;
+
+   shader = xorg_shaders_get(port->r->shaders, vs_traits, fs_traits);
+   cso_set_vertex_shader_handle(port->r->cso, shader.vs);
+   cso_set_fragment_shader_handle(port->r->cso, shader.fs);
+}
+
+static INLINE void
+conditional_flush(struct pipe_context *pipe, struct pipe_texture **tex,
+                  int num)
+{
+   int i;
+   for (i = 0; i < num; ++i) {
+      if (tex[i] && pipe->is_texture_referenced(pipe, tex[i], 0, 0) &
+          PIPE_REFERENCED_FOR_WRITE) {
+         pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
+         return;
+      }
+   }
+}
+
+static void
+bind_samplers(struct xorg_xv_port_priv *port)
+{
+   struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS];
+   struct pipe_sampler_state sampler;
+   struct pipe_texture **dst = port->yuv[port->current_set];
+
+   memset(&sampler, 0, sizeof(struct pipe_sampler_state));
+
+   conditional_flush(port->r->pipe, dst, 3);
+
+   sampler.wrap_s = PIPE_TEX_WRAP_CLAMP;
+   sampler.wrap_t = PIPE_TEX_WRAP_CLAMP;
+   sampler.min_img_filter = PIPE_TEX_FILTER_LINEAR;
+   sampler.mag_img_filter = PIPE_TEX_FILTER_LINEAR;
+   sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST;
+   sampler.normalized_coords = 1;
+
+   samplers[0] = &sampler;
+   samplers[1] = &sampler;
+   samplers[2] = &sampler;
+
+
+   cso_set_samplers(port->r->cso, 3,
+                    (const struct pipe_sampler_state **)samplers);
+   cso_set_sampler_textures(port->r->cso, 3,
+                            dst);
+}
+
+static int
+display_video(ScrnInfoPtr pScrn, struct xorg_xv_port_priv *pPriv, int id,
+              RegionPtr dstRegion,
+              int src_x, int src_y, int src_w, int src_h,
+              int dstX, int dstY, int dst_w, int dst_h,
+              PixmapPtr pPixmap)
+{
+   modesettingPtr ms = modesettingPTR(pScrn);
+   BoxPtr pbox;
+   int nbox;
+   int dxo, dyo;
+   Bool hdtv;
+   int x, y, w, h;
+   struct exa_pixmap_priv *dst = exaGetPixmapDriverPrivate(pPixmap);
+   struct pipe_surface *dst_surf = xorg_gpu_surface(pPriv->r->pipe->screen, dst);
+
+   if (dst && !dst->tex) {
+       xorg_exa_set_shared_usage(pPixmap);
+       pScrn->pScreen->ModifyPixmapHeader(pPixmap, 0, 0, 0, 0, 0, NULL);
+   }
+
+   if (!dst || !dst->tex)
+      XORG_FALLBACK("Xv destination %s", !dst ? "!dst" : "!dst->tex");
+
+   hdtv = ((src_w >= RES_720P_X) && (src_h >= RES_720P_Y));
+
+   REGION_TRANSLATE(pScrn->pScreen, dstRegion, -pPixmap->screen_x,
+                    -pPixmap->screen_y);
+
+   dxo = dstRegion->extents.x1;
+   dyo = dstRegion->extents.y1;
+
+   pbox = REGION_RECTS(dstRegion);
+   nbox = REGION_NUM_RECTS(dstRegion);
+
+   renderer_bind_destination(pPriv->r, dst_surf, 
+                             dst_surf->width, dst_surf->height);
+
+   bind_blend_state(pPriv);
+   bind_shaders(pPriv);
+   bind_samplers(pPriv);
+   setup_fs_video_constants(pPriv->r, hdtv);
+
+   exaMoveInPixmap(pPixmap);
+   DamageDamageRegion(&pPixmap->drawable, dstRegion);
+
+   while (nbox--) {
+      int box_x1 = pbox->x1;
+      int box_y1 = pbox->y1;
+      int box_x2 = pbox->x2;
+      int box_y2 = pbox->y2;
+      float diff_x = (float)src_w / (float)dst_w;
+      float diff_y = (float)src_h / (float)dst_h;
+      int offset_x = box_x1 - dstX + pPixmap->screen_x;
+      int offset_y = box_y1 - dstY + pPixmap->screen_y;
+      int offset_w;
+      int offset_h;
+
+      x = box_x1;
+      y = box_y1;
+      w = box_x2 - box_x1;
+      h = box_y2 - box_y1;
+
+      offset_w = dst_w - w;
+      offset_h = dst_h - h;
+
+      draw_yuv(pPriv, src_x + offset_x*diff_x, src_y + offset_y*diff_y,
+               src_w - offset_w*diff_x, src_h - offset_h*diff_x,
+               x, y, w, h);
+
+      pbox++;
+   }
+   DamageRegionProcessPending(&pPixmap->drawable);
+
+   pipe_surface_reference(&dst_surf, NULL);
+
+   return TRUE;
 }
 
 static int
@@ -82,23 +563,54 @@ put_image(ScrnInfoPtr pScrn,
           Bool sync, RegionPtr clipBoxes, pointer data,
           DrawablePtr pDraw)
 {
-   return 0;
-}
+   struct xorg_xv_port_priv *pPriv = (struct xorg_xv_port_priv *) data;
+   ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
+   PixmapPtr pPixmap;
+   INT32 x1, x2, y1, y2;
+   BoxRec dstBox;
+   int ret;
+
+   /* Clip */
+   x1 = src_x;
+   x2 = src_x + src_w;
+   y1 = src_y;
+   y2 = src_y + src_h;
+
+   dstBox.x1 = drw_x;
+   dstBox.x2 = drw_x + drw_w;
+   dstBox.y1 = drw_y;
+   dstBox.y2 = drw_y + drw_h;
+
+   if (!xf86XVClipVideoHelper(&dstBox, &x1, &x2, &y1, &y2, clipBoxes,
+                             width, height))
+      return Success;
+
+   ret = check_yuv_textures(pPriv, width, height);
+
+   if (ret)
+      return ret;
+
+   copy_packed_data(pScrn, pPriv, id, buf,
+                    src_x, src_y, width, height);
+
+   if (pDraw->type == DRAWABLE_WINDOW) {
+      pPixmap = (*pScreen->GetWindowPixmap)((WindowPtr)pDraw);
+   } else {
+      pPixmap = (PixmapPtr)pDraw;
+   }
 
-static int
-query_image_attributes(ScrnInfoPtr pScrn,
-                       int id,
-                       unsigned short *w, unsigned short *h,
-                       int *pitches, int *offsets)
-{
-   return 0;
+   display_video(pScrn, pPriv, id, clipBoxes,
+                 src_x, src_y, src_w, src_h,
+                 drw_x, drw_y,
+                 drw_w, drw_h, pPixmap);
+
+   pPriv->current_set = (pPriv->current_set + 1) & 1;
+   return Success;
 }
 
 static struct xorg_xv_port_priv *
-port_priv_create(ScreenPtr pScreen)
+port_priv_create(struct xorg_renderer *r)
 {
-   /*ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];*/
-   /*modesettingPtr ms = modesettingPTR(pScrn);*/
    struct xorg_xv_port_priv *priv = NULL;
 
    priv = calloc(1, sizeof(struct xorg_xv_port_priv));
@@ -106,7 +618,11 @@ port_priv_create(ScreenPtr pScreen)
    if (!priv)
       return NULL;
 
-    REGION_NULL(pScreen, &priv->clip);
+   priv->r = r;
+
+   REGION_NULL(pScreen, &priv->clip);
+
+   debug_assert(priv && priv->r);
 
    return priv;
 }
@@ -114,8 +630,8 @@ port_priv_create(ScreenPtr pScreen)
 static XF86VideoAdaptorPtr
 xorg_setup_textured_adapter(ScreenPtr pScreen)
 {
-   /*ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];*/
-   /*modesettingPtr ms = modesettingPTR(pScrn);*/
+   ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+   modesettingPtr ms = modesettingPTR(pScrn);
    XF86VideoAdaptorPtr adapt;
    XF86AttributePtr attrs;
    DevUnion *dev_unions;
@@ -124,6 +640,9 @@ xorg_setup_textured_adapter(ScreenPtr pScreen)
 
    nattributes = NUM_TEXTURED_ATTRIBUTES;
 
+   debug_assert(ms->exa);
+   debug_assert(ms->exa->renderer);
+
    adapt = calloc(1, sizeof(XF86VideoAdaptorRec));
    dev_unions = calloc(nports, sizeof(DevUnion));
    attrs = calloc(nattributes, sizeof(XF86AttributeRec));
@@ -161,7 +680,7 @@ xorg_setup_textured_adapter(ScreenPtr pScreen)
 
    for (i = 0; i < nports; i++) {
       struct xorg_xv_port_priv *priv =
-         port_priv_create(pScreen);
+         port_priv_create(ms->exa->renderer);
 
       adapt->pPortPrivates[i].ptr = (pointer) (priv);
       adapt->nPorts++;
@@ -171,7 +690,7 @@ xorg_setup_textured_adapter(ScreenPtr pScreen)
 }
 
 void
-xorg_init_video(ScreenPtr pScreen)
+xorg_xv_init(ScreenPtr pScreen)
 {
    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
    /*modesettingPtr ms = modesettingPTR(pScrn);*/
index 942692d1bb95edd370963bb613f159b9f0cc5149..c8a389385a80796e8db10624ffdbd2cd52509a75 100644 (file)
@@ -195,7 +195,7 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, int surface_type_id,
       return BadAlloc;
    }
 
-   vpipe = vl_video_create(screen, ProfileToPipe(mc_type),
+   vpipe = vl_video_create(dpy, scrn, screen, ProfileToPipe(mc_type),
                            FormatToPipe(chroma_format), width, height);
 
    if (!vpipe) {
index bf9038f356e4d4eb11e5edd2499138343068fcc4..0e39a390c69b2296110621566cb3e3d8c275b867 100644 (file)
@@ -1,8 +1,8 @@
 /**************************************************************************
- * 
+ *
  * Copyright 2009 Younes Manton.
  * All Rights Reserved.
- * 
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the
  * "Software"), to deal in the Software without restriction, including
  * distribute, sub license, and/or sell copies of the Software, and to
  * permit persons to whom the Software is furnished to do so, subject to
  * the following conditions:
- * 
+ *
  * The above copyright notice and this permission notice (including the
  * next paragraph) shall be included in all copies or substantial portions
  * of the Software.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
@@ -22,7 +22,7 @@
  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- * 
+ *
  **************************************************************************/
 
 #include <assert.h>
@@ -103,10 +103,9 @@ CreateOrResizeBackBuffer(struct pipe_video_context *vpipe, unsigned int width, u
    /* XXX: Needs to match the drawable's format? */
    template.format = PIPE_FORMAT_X8R8G8B8_UNORM;
    template.last_level = 0;
-   template.width[0] = width;
-   template.height[0] = height;
-   template.depth[0] = 1;
-   pf_get_block(template.format, &template.block);
+   template.width0 = width;
+   template.height0 = height;
+   template.depth0 = 1;
    template.tex_usage = PIPE_TEXTURE_USAGE_DISPLAY_TARGET;
 
    tex = vpipe->screen->texture_create(vpipe->screen, &template);
index a9e9f2682a7eb36ffac1a5b3222e3ef8bb2fe44f..66b73a8bf93140bec38c103b31160a6df0d49c8c 100644 (file)
@@ -48,11 +48,21 @@ if env['dri']:
        #       $(INSTALL) -d $(DRI_DRIVER_INSTALL_DIR)
        #       $(INSTALL) -m 755 $(LIBNAME) $(DRI_DRIVER_INSTALL_DIR)
 
+       if 'vmware' in env['winsys']:
+               SConscript([
+                       'vmware/SConscript',
+               ])
+
        if 'intel' in env['winsys']:
                SConscript([
                        'intel/SConscript',
                ])
 
+       if 'i965' in env['winsys']:
+               SConscript([
+                       'i965/SConscript',
+               ])
+
        if 'radeon' in env['winsys']:
                SConscript([
                        'radeon/SConscript',
diff --git a/src/gallium/winsys/drm/i965/Makefile b/src/gallium/winsys/drm/i965/Makefile
new file mode 100644 (file)
index 0000000..d8feef6
--- /dev/null
@@ -0,0 +1,12 @@
+# src/gallium/winsys/drm/intel/Makefile
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+SUBDIRS = gem $(GALLIUM_STATE_TRACKERS_DIRS)
+
+default install clean:
+       @for dir in $(SUBDIRS) ; do \
+               if [ -d $$dir ] ; then \
+                       (cd $$dir && $(MAKE) $@) || exit 1; \
+               fi \
+       done
diff --git a/src/gallium/winsys/drm/i965/SConscript b/src/gallium/winsys/drm/i965/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'])
diff --git a/src/gallium/winsys/drm/i965/dri/Makefile b/src/gallium/winsys/drm/i965/dri/Makefile
new file mode 100644 (file)
index 0000000..f7e81ee
--- /dev/null
@@ -0,0 +1,26 @@
+TOP = ../../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = i965_dri.so
+
+PIPE_DRIVERS = \
+       $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \
+       $(TOP)/src/gallium/winsys/drm/i965/gem/libi965drm.a \
+       $(TOP)/src/gallium/drivers/trace/libtrace.a \
+       $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
+       $(TOP)/src/gallium/drivers/identity/libidentity.a \
+       $(TOP)/src/gallium/drivers/i965/libi965.a
+
+
+DRIVER_SOURCES =
+
+C_SOURCES = \
+       $(COMMON_GALLIUM_SOURCES) \
+       $(DRIVER_SOURCES)
+
+include ../../Makefile.template
+
+DRI_LIB_DEPS += -ldrm_intel
+
+symlinks: $(TOP)/$(LIB_DIR)/gallium
+       @rm -f $(TOP)/$(LIB_DIR)/gallium/i965_dri.so
diff --git a/src/gallium/winsys/drm/i965/dri/SConscript b/src/gallium/winsys/drm/i965/dri/SConscript
new file mode 100644 (file)
index 0000000..a99533f
--- /dev/null
@@ -0,0 +1,19 @@
+Import('*')
+
+env = drienv.Clone()
+
+env.ParseConfig('pkg-config --cflags --libs libdrm_intel')
+
+drivers = [
+    st_dri,
+    i965drm,
+    i965,
+    trace,
+]
+
+env.LoadableModule(
+    target ='i965_dri.so',
+    source = COMMON_GALLIUM_SOURCES,
+    LIBS = drivers + mesa + gallium + env['LIBS'],
+    SHLIBPREFIX = '',
+)
diff --git a/src/gallium/winsys/drm/i965/egl/Makefile b/src/gallium/winsys/drm/i965/egl/Makefile
new file mode 100644 (file)
index 0000000..a1b32eb
--- /dev/null
@@ -0,0 +1,29 @@
+TOP = ../../../../../..
+GALLIUMDIR = ../../../..
+include $(TOP)/configs/current
+
+LIBNAME = EGL_i965.so
+
+PIPE_DRIVERS = \
+       $(TOP)/src/gallium/state_trackers/egl/libegldrm.a \
+       $(GALLIUMDIR)/winsys/drm/i965/gem/libi965drm.a \
+       $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
+       $(TOP)/src/gallium/drivers/trace/libtrace.a \
+       $(TOP)/src/gallium/drivers/i965/libi965.a
+
+DRIVER_SOURCES =
+
+C_SOURCES = \
+       $(COMMON_GALLIUM_SOURCES) \
+       $(DRIVER_SOURCES)
+
+DRIVER_EXTRAS = -ldrm_intel
+
+ASM_SOURCES = 
+
+DRIVER_DEFINES = -I../gem $(shell pkg-config libdrm --atleast-version=2.3.1 \
+                               && echo "-DDRM_VBLANK_FLIP=DRM_VBLANK_FLIP")
+
+include ../../Makefile.template
+
+symlinks:
diff --git a/src/gallium/winsys/drm/i965/gem/Makefile b/src/gallium/winsys/drm/i965/gem/Makefile
new file mode 100644 (file)
index 0000000..6a7497b
--- /dev/null
@@ -0,0 +1,14 @@
+TOP = ../../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = i965drm
+
+C_SOURCES = \
+       i965_drm_buffer.c \
+       i965_drm_api.c
+
+LIBRARY_INCLUDES = $(shell pkg-config libdrm --cflags-only-I)
+
+LIBRARY_DEFINES = $(shell pkg-config libdrm --cflags-only-other)
+
+include ../../../../Makefile.template
diff --git a/src/gallium/winsys/drm/i965/gem/SConscript b/src/gallium/winsys/drm/i965/gem/SConscript
new file mode 100644 (file)
index 0000000..6256ec6
--- /dev/null
@@ -0,0 +1,15 @@
+Import('*')
+
+env = drienv.Clone()
+
+i965drm_sources = [
+    'i965_drm_api.c',
+    'i965_drm_buffer.c',
+]
+
+i965drm = env.ConvenienceLibrary(
+    target ='i965drm',
+    source = i965drm_sources,
+)
+
+Export('i965drm')
diff --git a/src/gallium/winsys/drm/i965/gem/i965_drm_api.c b/src/gallium/winsys/drm/i965/gem/i965_drm_api.c
new file mode 100644 (file)
index 0000000..fc9678d
--- /dev/null
@@ -0,0 +1,243 @@
+
+#include <stdio.h>
+#include "state_tracker/drm_api.h"
+
+#include "i965_drm_winsys.h"
+#include "util/u_memory.h"
+
+#include "i965/brw_context.h"        /* XXX: shouldn't be doing this */
+#include "i965/brw_screen.h"         /* XXX: shouldn't be doing this */
+
+#include "trace/tr_drm.h"
+
+/*
+ * Helper functions
+ */
+
+
+static void
+i965_libdrm_get_device_id(unsigned int *device_id)
+{
+   char path[512];
+   FILE *file;
+   void *shutup_gcc;
+
+   /*
+    * FIXME: Fix this up to use a drm ioctl or whatever.
+    */
+
+   snprintf(path, sizeof(path), "/sys/class/drm/card0/device/device");
+   file = fopen(path, "r");
+   if (!file) {
+      return;
+   }
+
+   shutup_gcc = fgets(path, sizeof(path), file);
+   sscanf(path, "%x", device_id);
+   fclose(file);
+}
+
+static struct i965_libdrm_buffer *
+i965_libdrm_buffer_from_handle(struct i965_libdrm_winsys *idws,
+                               const char* name, unsigned handle)
+{
+   struct i965_libdrm_buffer *buf = CALLOC_STRUCT(i965_libdrm_buffer);
+   uint32_t swizzle = 0;
+
+   if (BRW_DUMP)
+      debug_printf("%s\n", __FUNCTION__);
+
+   if (!buf)
+      return NULL;
+   pipe_reference_init(&buf->base.reference, 1);
+   buf->bo = drm_intel_bo_gem_create_from_name(idws->gem, name, handle);
+   buf->base.size = buf->bo->size;
+   buf->base.sws = &idws->base;
+   buf->flinked = TRUE;
+   buf->flink = handle;
+
+
+   if (!buf->bo)
+      goto err;
+
+   drm_intel_bo_get_tiling(buf->bo, &buf->tiling, &swizzle);
+   if (buf->tiling != 0)
+      buf->map_gtt = TRUE;
+
+   return buf;
+
+err:
+   FREE(buf);
+   return NULL;
+}
+
+
+/*
+ * Exported functions
+ */
+
+
+static struct pipe_texture *
+i965_libdrm_texture_from_shared_handle(struct drm_api *api,
+                                       struct pipe_screen *screen,
+                                       struct pipe_texture *template,
+                                       const char* name,
+                                       unsigned pitch,
+                                       unsigned handle)
+{
+   /* XXX: this is silly -- there should be a way to get directly from
+    * the "drm_api" struct to ourselves, without peering into
+    * unrelated code:
+    */
+   struct i965_libdrm_winsys *idws = i965_libdrm_winsys(brw_screen(screen)->sws);
+   struct i965_libdrm_buffer *buffer;
+
+   if (BRW_DUMP)
+      debug_printf("%s %s pitch %d handle 0x%x\n", __FUNCTION__,
+                  name, pitch, handle);
+
+   buffer = i965_libdrm_buffer_from_handle(idws, name, handle);
+   if (!buffer)
+      return NULL;
+
+   return brw_texture_blanket_winsys_buffer(screen, template, pitch,
+                                           buffer->tiling,
+                                           &buffer->base);
+}
+
+
+static boolean
+i965_libdrm_shared_handle_from_texture(struct drm_api *api,
+                                       struct pipe_screen *screen,
+                                       struct pipe_texture *texture,
+                                       unsigned *pitch,
+                                       unsigned *handle)
+{
+   struct i965_libdrm_buffer *buf = NULL;
+   struct brw_winsys_buffer *buffer = NULL;
+
+   if (BRW_DUMP)
+      debug_printf("%s\n", __FUNCTION__);
+
+   if (!brw_texture_get_winsys_buffer(texture, &buffer, pitch))
+      return FALSE;
+
+   buf = i965_libdrm_buffer(buffer);
+   if (!buf->flinked) {
+      if (drm_intel_bo_flink(buf->bo, &buf->flink))
+         return FALSE;
+      buf->flinked = TRUE;
+   }
+
+   *handle = buf->flink;
+
+   if (BRW_DUMP)
+      debug_printf("   -> pitch %d handle 0x%x\n", *pitch, *handle);
+
+   return TRUE;
+}
+
+static boolean
+i965_libdrm_local_handle_from_texture(struct drm_api *api,
+                                      struct pipe_screen *screen,
+                                      struct pipe_texture *texture,
+                                      unsigned *pitch,
+                                      unsigned *handle)
+{
+   struct brw_winsys_buffer *buffer = NULL;
+
+   if (BRW_DUMP)
+      debug_printf("%s\n", __FUNCTION__);
+
+   if (!brw_texture_get_winsys_buffer(texture, &buffer, pitch))
+      return FALSE;
+
+   *handle = i965_libdrm_buffer(buffer)->bo->handle;
+
+   if (BRW_DUMP)
+      debug_printf("   -> pitch %d handle 0x%x\n", *pitch, *handle);
+
+   return TRUE;
+}
+
+static void
+i965_libdrm_winsys_destroy(struct brw_winsys_screen *iws)
+{
+   struct i965_libdrm_winsys *idws = i965_libdrm_winsys(iws);
+
+   if (BRW_DUMP)
+      debug_printf("%s\n", __FUNCTION__);
+
+   drm_intel_bufmgr_destroy(idws->gem);
+
+   FREE(idws);
+}
+
+static struct pipe_screen *
+i965_libdrm_create_screen(struct drm_api *api, int drmFD,
+                          struct drm_create_screen_arg *arg)
+{
+   struct i965_libdrm_winsys *idws;
+   unsigned int deviceID;
+
+   debug_printf("%s\n", __FUNCTION__);
+
+   if (arg != NULL) {
+      switch(arg->mode) {
+      case DRM_CREATE_NORMAL:
+         break;
+      default:
+         return NULL;
+      }
+   }
+
+   idws = CALLOC_STRUCT(i965_libdrm_winsys);
+   if (!idws)
+      return NULL;
+
+   i965_libdrm_get_device_id(&deviceID);
+
+   i965_libdrm_winsys_init_buffer_functions(idws);
+
+   idws->fd = drmFD;
+   idws->id = deviceID;
+
+   idws->base.destroy = i965_libdrm_winsys_destroy;
+
+   idws->gem = drm_intel_bufmgr_gem_init(idws->fd, BRW_BATCH_SIZE);
+   drm_intel_bufmgr_gem_enable_reuse(idws->gem);
+
+   idws->send_cmd = !debug_get_bool_option("BRW_NO_HW", FALSE);
+
+   return brw_create_screen(&idws->base, deviceID);
+}
+
+static struct pipe_context *
+i965_libdrm_create_context(struct drm_api *api, struct pipe_screen *screen)
+{
+   return brw_create_context(screen);
+}
+
+static void
+destroy(struct drm_api *api)
+{
+   if (BRW_DUMP)
+      debug_printf("%s\n", __FUNCTION__);
+
+}
+
+struct drm_api i965_libdrm_api =
+{
+   .create_context = i965_libdrm_create_context,
+   .create_screen = i965_libdrm_create_screen,
+   .texture_from_shared_handle = i965_libdrm_texture_from_shared_handle,
+   .shared_handle_from_texture = i965_libdrm_shared_handle_from_texture,
+   .local_handle_from_texture = i965_libdrm_local_handle_from_texture,
+   .destroy = destroy,
+};
+
+struct drm_api *
+drm_api_create()
+{
+   return trace_drm_create(&i965_libdrm_api);
+}
diff --git a/src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c b/src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c
new file mode 100644 (file)
index 0000000..a4a72b3
--- /dev/null
@@ -0,0 +1,427 @@
+
+#include "i965_drm_winsys.h"
+#include "util/u_memory.h"
+
+#include "i915_drm.h"
+#include "intel_bufmgr.h"
+
+
+
+const char *names[BRW_BUFFER_TYPE_MAX] = {
+   "TEXTURE",
+   "SCANOUT",
+   "VERTEX",
+   "CURBE",
+   "QUERY",
+   "SHADER_CONSTANTS",
+   "WM_SCRATCH",
+   "BATCH",
+   "GENERAL_STATE",
+   "SURFACE_STATE",
+   "PIXEL",
+   "GENERIC",
+};
+
+const char *usages[BRW_USAGE_MAX] = {
+   "STATE",
+   "QUERY_RESULT",
+   "RENDER_TARGET",
+   "DEPTH_BUFFER",
+   "BLIT_SOURCE",
+   "BLIT_DEST",
+   "SAMPLER",
+   "VERTEX",
+   "SCRATCH"
+};
+
+
+const char *data_types[BRW_DATA_MAX] =
+{
+   "GS: CC_VP",
+   "GS: CC_UNIT",
+   "GS: WM_PROG",
+   "GS: SAMPLER_DEFAULT_COLOR",
+   "GS: SAMPLER",
+   "GS: WM_UNIT",
+   "GS: SF_PROG",
+   "GS: SF_VP",
+   "GS: SF_UNIT",
+   "GS: VS_UNIT",
+   "GS: VS_PROG",
+   "GS: GS_UNIT",
+   "GS: GS_PROG",
+   "GS: CLIP_VP",
+   "GS: CLIP_UNIT",
+   "GS: CLIP_PROG",
+   "SS: SURFACE",
+   "SS: SURF_BIND",
+   "CONSTANT DATA",
+   "BATCH DATA",
+   "(untyped)"
+};
+
+static enum pipe_error 
+i965_libdrm_bo_alloc(struct brw_winsys_screen *sws,
+                     enum brw_buffer_type type,
+                     unsigned size,
+                     unsigned alignment,
+                     struct brw_winsys_buffer **bo_out)
+{
+   struct i965_libdrm_winsys *idws = i965_libdrm_winsys(sws);
+   struct i965_libdrm_buffer *buf;
+
+   if (BRW_DUMP)
+      debug_printf("%s type %s sz %d align %d\n",
+                  __FUNCTION__, names[type], size, alignment );
+
+   buf = CALLOC_STRUCT(i965_libdrm_buffer);
+   if (!buf)
+      return PIPE_ERROR_OUT_OF_MEMORY;
+
+   switch (type) {
+   case BRW_BUFFER_TYPE_TEXTURE:
+/* case BRW_BUFFER_TYPE_SCANOUT:*/
+   case BRW_BUFFER_TYPE_VERTEX:
+   case BRW_BUFFER_TYPE_CURBE:
+   case BRW_BUFFER_TYPE_QUERY:
+   case BRW_BUFFER_TYPE_SHADER_CONSTANTS:
+   case BRW_BUFFER_TYPE_SHADER_SCRATCH:
+   case BRW_BUFFER_TYPE_BATCH:
+   case BRW_BUFFER_TYPE_GENERAL_STATE:
+   case BRW_BUFFER_TYPE_SURFACE_STATE:
+   case BRW_BUFFER_TYPE_PIXEL:
+   case BRW_BUFFER_TYPE_GENERIC:
+      break;
+   case BRW_BUFFER_TYPE_SCANOUT:
+      buf->map_gtt = TRUE;
+      break;
+   default:
+      assert(0);
+      break;
+   }
+
+   buf->bo = drm_intel_bo_alloc(idws->gem, 
+                                names[type], 
+                                size, 
+                                alignment);
+
+   if (!buf->bo)
+      goto err;
+
+   pipe_reference_init(&buf->base.reference, 1);
+   buf->base.size = size;
+   buf->base.sws = sws;
+
+   *bo_out = &buf->base;
+   return PIPE_OK;
+
+err:
+   assert(0);
+   FREE(buf);
+   return PIPE_ERROR_OUT_OF_MEMORY;
+}
+
+static void 
+i965_libdrm_bo_destroy(struct brw_winsys_buffer *buffer)
+{
+   struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
+
+   if (BRW_DUMP)
+      debug_printf("%s\n", __FUNCTION__);
+
+   drm_intel_bo_unreference(buf->bo);
+   FREE(buffer);
+}
+
+static enum pipe_error
+i965_libdrm_bo_emit_reloc(struct brw_winsys_buffer *buffer,
+                          enum brw_buffer_usage usage,
+                          unsigned delta,
+                          unsigned offset,
+                          struct brw_winsys_buffer *buffer2)
+{
+   struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
+   struct i965_libdrm_buffer *buf2 = i965_libdrm_buffer(buffer2);
+   int read, write;
+   int ret;
+
+   if (BRW_DUMP)
+      debug_printf("%s buf %p offset %x delta %x buf2 %p/%s/%s\n",
+                  __FUNCTION__, (void *)buffer, 
+                  offset, delta,
+                  (void *)buffer2, names[buf2->data_type], usages[usage]);
+
+   switch (usage) {
+   case BRW_USAGE_STATE:
+      read = I915_GEM_DOMAIN_INSTRUCTION;
+      write = 0;
+      break;
+   case BRW_USAGE_QUERY_RESULT:
+      read = I915_GEM_DOMAIN_INSTRUCTION;
+      write = I915_GEM_DOMAIN_INSTRUCTION;
+      break;
+   case BRW_USAGE_RENDER_TARGET:
+      read = I915_GEM_DOMAIN_RENDER;
+      write = 0;
+      break;
+   case BRW_USAGE_DEPTH_BUFFER:
+      read = I915_GEM_DOMAIN_RENDER;
+      write = I915_GEM_DOMAIN_RENDER;
+      break;
+   case BRW_USAGE_BLIT_SOURCE:
+      read = 0;
+      write = I915_GEM_DOMAIN_RENDER;
+      break;
+   case BRW_USAGE_BLIT_DEST:
+      read = I915_GEM_DOMAIN_RENDER;
+      write = I915_GEM_DOMAIN_RENDER;
+      break;
+   case BRW_USAGE_SAMPLER:
+      read = I915_GEM_DOMAIN_SAMPLER;
+      write = 0;
+      break;
+   case BRW_USAGE_VERTEX:
+      read = I915_GEM_DOMAIN_VERTEX;
+      write = 0;
+      break;
+   case BRW_USAGE_SCRATCH:
+      read = 0;
+      write = 0;
+      break;
+   default:
+      assert(0);
+      return -1;
+   }
+
+   /* Needed??
+   ((uint32_t *)buf->bo->virtual)[offset/4] = (delta +
+                                              buf2->bo->offset);
+    */
+
+   ret = dri_bo_emit_reloc( buf->bo, read, write, delta, offset, buf2->bo );
+   if (ret)
+      return -1;
+
+   return 0;
+}
+
+static enum pipe_error 
+i965_libdrm_bo_exec(struct brw_winsys_buffer *buffer,
+                    unsigned bytes_used)
+{
+   struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
+   struct i965_libdrm_winsys *idws = i965_libdrm_winsys(buffer->sws);
+   int ret;
+
+   if (BRW_DUMP)
+      debug_printf("execute buffer %p, bytes %d\n", (void *)buffer, bytes_used);
+
+   if (idws->send_cmd) {
+      ret = dri_bo_exec(buf->bo, bytes_used, NULL, 0, 0);
+      if (ret)
+         return PIPE_ERROR;
+   }
+
+   return PIPE_OK;
+}
+
+static enum pipe_error
+i965_libdrm_bo_subdata(struct brw_winsys_buffer *buffer,
+                       enum brw_buffer_data_type data_type,
+                       size_t offset,
+                       size_t size,
+                       const void *data,
+                       const struct brw_winsys_reloc *reloc,
+                       unsigned nr_reloc)
+{
+   struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
+   struct i965_libdrm_winsys *idws = i965_libdrm_winsys(buffer->sws);
+   int ret, i;
+
+   (void)data_type;
+
+   if (BRW_DUMP)
+      debug_printf("%s buf %p off %d sz %d %s relocs: %d\n", 
+                  __FUNCTION__, 
+                  (void *)buffer, offset, size, 
+                  data_types[data_type],
+                  nr_reloc);
+
+   if (BRW_DUMP)
+      brw_dump_data( idws->id,
+                    data_type,
+                    buf->bo->offset + offset, 
+                    data, size );
+
+   /* XXX: use bo_map_gtt/memcpy/unmap_gtt under some circumstances???
+    */
+   ret = drm_intel_bo_subdata(buf->bo, offset, size, (void*)data);
+   if (ret)
+      return PIPE_ERROR;
+  
+   for (i = 0; i < nr_reloc; i++) {
+      i965_libdrm_bo_emit_reloc(buffer, reloc[i].usage, reloc[i].delta,
+                                reloc[i].offset, reloc[i].bo);
+   }
+
+   return PIPE_OK;
+}
+
+static boolean 
+i965_libdrm_bo_is_busy(struct brw_winsys_buffer *buffer)
+{
+   struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
+   boolean ret;
+
+   if (BRW_DUMP)
+      debug_printf("%s %p\n", __FUNCTION__, (void *)buffer);
+
+   ret = drm_intel_bo_busy(buf->bo);
+
+   if (BRW_DUMP)
+      debug_printf("  --> %d\n", ret);
+
+   return ret;
+}
+
+static boolean 
+i965_libdrm_bo_references(struct brw_winsys_buffer *a,
+                          struct brw_winsys_buffer *b)
+{
+   struct i965_libdrm_buffer *bufa = i965_libdrm_buffer(a);
+   struct i965_libdrm_buffer *bufb = i965_libdrm_buffer(b);
+   boolean ret;
+
+   if (BRW_DUMP)
+      debug_printf("%s %p %p\n", __FUNCTION__, (void *)a, (void *)b);
+
+   ret = drm_intel_bo_references(bufa->bo, bufb->bo);
+
+   if (BRW_DUMP)
+      debug_printf("  --> %d\n", ret);
+
+   return ret;
+}
+
+/* XXX: couldn't this be handled by returning true/false on
+ * bo_emit_reloc?
+ */
+static enum pipe_error
+i965_libdrm_check_aperture_space(struct brw_winsys_screen *iws,
+                                 struct brw_winsys_buffer **buffers,
+                                 unsigned count)
+{
+   static drm_intel_bo *bos[128];
+   int i;
+   int ret;
+
+   if (BRW_DUMP)
+      debug_printf("%s\n", __FUNCTION__);
+
+   if (count > Elements(bos)) {
+      assert(0);
+      return FALSE;
+   }
+
+   for (i = 0; i < count; i++)
+      bos[i] = i965_libdrm_buffer(buffers[i])->bo;
+
+   /* XXX: converting from ??? to pipe_error:
+    */
+   ret = dri_bufmgr_check_aperture_space(bos, count);
+
+   if (BRW_DUMP)
+      debug_printf("  --> %d (ok == %d)\n", ret, PIPE_OK);
+
+   return ret;
+}
+
+static void *
+i965_libdrm_bo_map(struct brw_winsys_buffer *buffer,
+                   enum brw_buffer_data_type data_type,
+                   unsigned offset,
+                   unsigned length,
+                   boolean write,
+                   boolean discard,
+                   boolean flush_explicit)
+{
+   struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
+   int ret;
+
+
+   if (BRW_DUMP)
+      debug_printf("%s %p %s %s\n", __FUNCTION__, (void *)buffer, 
+                  write ? "read/write" : "read",
+                  write ? data_types[data_type] : "");
+
+   if (!buf->map_count) {
+      if (buf->map_gtt) {
+         ret = drm_intel_gem_bo_map_gtt(buf->bo);
+         if (ret)
+            return NULL;
+      }
+      else {
+         ret = drm_intel_bo_map(buf->bo, write);
+         if (ret)
+            return NULL;
+      }
+   }
+
+   buf->data_type = data_type;
+   buf->map_count++;
+   return buf->bo->virtual;
+}
+
+static void
+i965_libdrm_bo_flush_range(struct brw_winsys_buffer *buffer,
+                           unsigned offset,
+                           unsigned length)
+{
+   struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
+   struct i965_libdrm_winsys *idws = i965_libdrm_winsys(buffer->sws);
+
+   if (BRW_DUMP)
+      debug_printf("%s %s offset %d len %d\n", __FUNCTION__,
+                  data_types[buf->data_type],
+                  offset, length);
+
+   if (BRW_DUMP)
+      brw_dump_data( idws->id,
+                    buf->data_type,
+                    buf->bo->offset + offset, 
+                    buf->bo->virtual + offset, 
+                    length );
+}
+
+static void 
+i965_libdrm_bo_unmap(struct brw_winsys_buffer *buffer)
+{
+   struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
+
+   if (BRW_DUMP)
+      debug_printf("%s\n", __FUNCTION__);
+
+   if (--buf->map_count > 0)
+      return;
+
+   if (buf->map_gtt)
+      drm_intel_gem_bo_unmap_gtt(buf->bo);
+   else
+      drm_intel_bo_unmap(buf->bo);
+}
+
+void
+i965_libdrm_winsys_init_buffer_functions(struct i965_libdrm_winsys *idws)
+{
+   idws->base.bo_alloc             = i965_libdrm_bo_alloc;
+   idws->base.bo_destroy           = i965_libdrm_bo_destroy;
+   idws->base.bo_emit_reloc        = i965_libdrm_bo_emit_reloc;
+   idws->base.bo_exec              = i965_libdrm_bo_exec;
+   idws->base.bo_subdata           = i965_libdrm_bo_subdata;
+   idws->base.bo_is_busy           = i965_libdrm_bo_is_busy;
+   idws->base.bo_references        = i965_libdrm_bo_references;
+   idws->base.check_aperture_space = i965_libdrm_check_aperture_space;
+   idws->base.bo_map               = i965_libdrm_bo_map;
+   idws->base.bo_flush_range       = i965_libdrm_bo_flush_range;
+   idws->base.bo_unmap             = i965_libdrm_bo_unmap;
+}
diff --git a/src/gallium/winsys/drm/i965/gem/i965_drm_winsys.h b/src/gallium/winsys/drm/i965/gem/i965_drm_winsys.h
new file mode 100644 (file)
index 0000000..c6a7d4a
--- /dev/null
@@ -0,0 +1,64 @@
+
+#ifndef INTEL_DRM_WINSYS_H
+#define INTEL_DRM_WINSYS_H
+
+#include "i965/brw_winsys.h"
+
+#include "drm.h"
+#include "intel_bufmgr.h"
+
+
+
+/*
+ * Winsys
+ */
+
+
+struct i965_libdrm_winsys
+{
+   struct brw_winsys_screen base;
+   drm_intel_bufmgr *gem;
+
+   boolean send_cmd;
+
+   int fd; /**< Drm file discriptor */
+
+   unsigned id;
+};
+
+static INLINE struct i965_libdrm_winsys *
+i965_libdrm_winsys(struct brw_winsys_screen *iws)
+{
+   return (struct i965_libdrm_winsys *)iws;
+}
+
+struct i965_libdrm_winsys *i965_libdrm_winsys_create(int fd, unsigned pci_id);
+
+void i965_libdrm_winsys_init_buffer_functions(struct i965_libdrm_winsys *idws);
+
+
+/* Buffer.  
+ */
+struct i965_libdrm_buffer {
+   struct brw_winsys_buffer base;
+
+   drm_intel_bo *bo;
+
+   void *ptr;
+   unsigned map_count;
+   unsigned data_type;         /* valid while mapped */
+   unsigned tiling;
+
+   boolean map_gtt;
+   boolean flinked;
+   unsigned flink;
+};
+
+static INLINE struct i965_libdrm_buffer *
+i965_libdrm_buffer(struct brw_winsys_buffer *buffer)
+{
+   return (struct i965_libdrm_buffer *)buffer;
+}
+
+
+#endif
diff --git a/src/gallium/winsys/drm/i965/xlib/Makefile b/src/gallium/winsys/drm/i965/xlib/Makefile
new file mode 100644 (file)
index 0000000..0efa0ca
--- /dev/null
@@ -0,0 +1,97 @@
+# src/gallium/winsys/xlib/Makefile
+
+# This makefile produces a "stand-alone" libGL.so which is based on
+# Xlib (no DRI HW acceleration)
+
+
+TOP = ../../../../../..
+include $(TOP)/configs/current
+
+
+GL_MAJOR = 1
+GL_MINOR = 5
+GL_TINY = 0$(MESA_MAJOR)0$(MESA_MINOR)0$(MESA_TINY)
+
+
+INCLUDE_DIRS = \
+       -I$(TOP)/include \
+       -I$(TOP)/src/mesa \
+       -I$(TOP)/src/mesa/main \
+       -I$(TOP)/src/gallium/include \
+       -I$(TOP)/src/gallium/drivers \
+       -I$(TOP)/src/gallium/drivers/i965 \
+       -I$(TOP)/src/gallium/drivers/i965/include \
+       -I$(TOP)/src/gallium/state_trackers/glx/xlib \
+       -I$(TOP)/src/gallium/auxiliary \
+       -I/usr/include/drm
+
+XLIB_WINSYS_SOURCES = \
+       xlib_i965.c \
+
+
+
+XLIB_WINSYS_OBJECTS = $(XLIB_WINSYS_SOURCES:.c=.o)
+
+
+
+LIBS = \
+       $(TOP)/src/gallium/drivers/i965/libi965.a \
+       $(TOP)/src/gallium/drivers/trace/libtrace.a \
+       $(TOP)/src/gallium/state_trackers/glx/xlib/libxlib.a \
+       $(TOP)/src/mesa/libglapi.a \
+       $(TOP)/src/mesa/libmesagallium.a \
+       $(GALLIUM_AUXILIARIES) 
+
+#      $(TOP)/src/gallium/drivers/i965/lib/libi9xx.a \
+
+.SUFFIXES : .cpp
+
+.c.o:
+       $(CC) -c $(INCLUDE_DIRS) $(DEFINES) $(CFLAGS) $< -o $@
+
+.cpp.o:
+       $(CXX) -c $(INCLUDE_DIRS) $(DEFINES) $(CXXFLAGS) $< -o $@
+
+
+
+default: $(TOP)/$(LIB_DIR)/gallium $(TOP)/$(LIB_DIR)/gallium/$(GL_LIB_NAME)
+
+$(TOP)/$(LIB_DIR)/gallium:
+       @ mkdir -p $(TOP)/$(LIB_DIR)/gallium
+
+# Make the libGL.so library
+$(TOP)/$(LIB_DIR)/gallium/$(GL_LIB_NAME): $(XLIB_WINSYS_OBJECTS) $(LIBS) Makefile
+       $(TOP)/bin/mklib -o $(GL_LIB) \
+               -linker "$(CC)" \
+               -major $(GL_MAJOR) -minor $(GL_MINOR) -patch $(GL_TINY) \
+               -install $(TOP)/$(LIB_DIR)/gallium \
+               $(MKLIB_OPTIONS) $(XLIB_WINSYS_OBJECTS) \
+               -Wl,--start-group $(LIBS) -Wl,--end-group $(GL_LIB_DEPS)
+
+
+depend: $(XLIB_WINSYS_SOURCES)
+       @ echo "running $(MKDEP)"
+       @ rm -f depend  # workaround oops on gutsy?!?
+       @ touch depend
+       $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) $(XLIB_WINSYS_SOURCES) \
+               > /dev/null 2>/dev/null
+
+
+install: default
+       $(INSTALL) -d $(INSTALL_DIR)/include/GL
+       $(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 \
+               $(MINSTALL) $(TOP)/$(LIB_DIR)/libGL* $(INSTALL_DIR)/$(LIB_DIR); \
+       fi
+
+
+# Emacs tags
+tags:
+       etags `find . -name \*.[ch]` $(TOP)/include/GL/*.h
+
+clean:
+       -rm -f *.o
+
+
+include depend
diff --git a/src/gallium/winsys/drm/i965/xlib/xlib_i965.c b/src/gallium/winsys/drm/i965/xlib/xlib_i965.c
new file mode 100644 (file)
index 0000000..d2b9a1a
--- /dev/null
@@ -0,0 +1,522 @@
+/**************************************************************************
+ * 
+ * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * 
+ **************************************************************************/
+
+/*
+ * Authors:
+ *   Keith Whitwell
+ *   Brian Paul
+ */
+
+
+#include "util/u_memory.h"
+#include "util/u_math.h"
+#include "pipe/p_error.h"
+#include "pipe/p_context.h"
+
+#include "xm_winsys.h"
+
+#include "i965/brw_winsys.h"
+#include "i965/brw_screen.h"
+#include "i965/brw_reg.h"
+#include "i965/brw_structs_dump.h"
+
+#define MAX_VRAM (128*1024*1024)
+
+
+
+extern int brw_disasm (FILE *file, 
+                       const struct brw_instruction *inst,
+                       unsigned count );
+
+extern int intel_decode(const uint32_t *data, 
+                        int count,
+                        uint32_t hw_offset,
+                        uint32_t devid);
+
+struct xlib_brw_buffer
+{
+   struct brw_winsys_buffer base;
+   char *virtual;
+   unsigned offset;
+   unsigned type;
+   int map_count;
+   boolean modified;
+};
+
+
+/**
+ * Subclass of brw_winsys_screen for Xlib winsys
+ */
+struct xlib_brw_winsys
+{
+   struct brw_winsys_screen base;
+   struct brw_chipset chipset;
+
+   unsigned size;
+   unsigned used;
+};
+
+static struct xlib_brw_winsys *
+xlib_brw_winsys( struct brw_winsys_screen *screen )
+{
+   return (struct xlib_brw_winsys *)screen;
+}
+
+
+static struct xlib_brw_buffer *
+xlib_brw_buffer( struct brw_winsys_buffer *buffer )
+{
+   return (struct xlib_brw_buffer *)buffer;
+}
+
+
+
+const char *names[BRW_BUFFER_TYPE_MAX] = {
+   "TEXTURE",
+   "SCANOUT",
+   "VERTEX",
+   "CURBE",
+   "QUERY",
+   "SHADER_CONSTANTS",
+   "WM_SCRATCH",
+   "BATCH",
+   "GENERAL_STATE",
+   "SURFACE_STATE",
+   "PIXEL",
+   "GENERIC",
+};
+
+const char *usages[BRW_USAGE_MAX] = {
+   "STATE",
+   "QUERY_RESULT",
+   "RENDER_TARGET",
+   "DEPTH_BUFFER",
+   "BLIT_SOURCE",
+   "BLIT_DEST",
+   "SAMPLER",
+   "VERTEX",
+   "SCRATCH"
+};
+
+
+const char *data_types[BRW_DATA_MAX] =
+{
+   "GS: CC_VP",
+   "GS: CC_UNIT",
+   "GS: WM_PROG",
+   "GS: SAMPLER_DEFAULT_COLOR",
+   "GS: SAMPLER",
+   "GS: WM_UNIT",
+   "GS: SF_PROG",
+   "GS: SF_VP",
+   "GS: SF_UNIT",
+   "GS: VS_UNIT",
+   "GS: VS_PROG",
+   "GS: GS_UNIT",
+   "GS: GS_PROG",
+   "GS: CLIP_VP",
+   "GS: CLIP_UNIT",
+   "GS: CLIP_PROG",
+   "SS: SURFACE",
+   "SS: SURF_BIND",
+   "CONSTANT DATA",
+   "BATCH DATA",
+   "(untyped)"
+};
+
+
+static enum pipe_error
+xlib_brw_bo_alloc( struct brw_winsys_screen *sws,
+                   enum brw_buffer_type type,
+                   unsigned size,
+                   unsigned alignment,
+                   struct brw_winsys_buffer **bo_out )
+{
+   struct xlib_brw_winsys *xbw = xlib_brw_winsys(sws);
+   struct xlib_brw_buffer *buf;
+
+   if (BRW_DEBUG & DEBUG_WINSYS)
+      debug_printf("%s type %s sz %d align %d\n",
+                   __FUNCTION__, names[type], size, alignment );
+
+   buf = CALLOC_STRUCT(xlib_brw_buffer);
+   if (!buf)
+      return PIPE_ERROR_OUT_OF_MEMORY;
+
+   pipe_reference_init(&buf->base.reference, 1);
+
+   buf->offset = align(xbw->used, alignment);
+   buf->type = type;
+   buf->virtual = MALLOC(size);
+   buf->base.size = size;
+   buf->base.sws = sws;
+
+   xbw->used = align(xbw->used, alignment) + size;
+   if (xbw->used > MAX_VRAM)
+      goto err;
+
+   /* XXX: possibly rentrant call to bo_destroy:
+    */
+   bo_reference(bo_out, &buf->base);
+   return PIPE_OK;
+
+err:
+   assert(0);
+   FREE(buf->virtual);
+   FREE(buf);
+   return PIPE_ERROR_OUT_OF_MEMORY;
+}
+
+static void 
+xlib_brw_bo_destroy( struct brw_winsys_buffer *buffer )
+{
+   struct xlib_brw_buffer *buf = xlib_brw_buffer(buffer);
+
+   FREE(buf);
+}
+
+static int 
+xlib_brw_bo_emit_reloc( struct brw_winsys_buffer *buffer,
+                        enum brw_buffer_usage usage,
+                        unsigned delta,
+                        unsigned offset,
+                        struct brw_winsys_buffer *buffer2)
+{
+   struct xlib_brw_buffer *buf = xlib_brw_buffer(buffer);
+   struct xlib_brw_buffer *buf2 = xlib_brw_buffer(buffer2);
+
+   if (BRW_DEBUG & DEBUG_WINSYS)
+      debug_printf("%s buf %p offset %x val %x + %x buf2 %p/%s/%s\n",
+                   __FUNCTION__, (void *)buffer, offset,
+                   buf2->offset, delta,
+                   (void *)buffer2, names[buf2->type], usages[usage]);
+
+   *(uint32_t *)(buf->virtual + offset) = buf2->offset + delta;
+
+   return 0;
+}
+
+static int 
+xlib_brw_bo_exec( struct brw_winsys_buffer *buffer,
+                    unsigned bytes_used )
+{
+   if (BRW_DEBUG & DEBUG_WINSYS)
+      debug_printf("execute buffer %p, bytes %d\n", (void *)buffer, bytes_used);
+
+   return 0;
+}
+
+
+
+
+static int
+xlib_brw_bo_subdata(struct brw_winsys_buffer *buffer,
+                    enum brw_buffer_data_type data_type,
+                    size_t offset,
+                    size_t size,
+                    const void *data,
+                    const struct brw_winsys_reloc *reloc,
+                    unsigned nr_relocs)
+{
+   struct xlib_brw_buffer *buf = xlib_brw_buffer(buffer);
+   struct xlib_brw_winsys *xbw = xlib_brw_winsys(buffer->sws);
+   unsigned i;
+
+   if (BRW_DEBUG & DEBUG_WINSYS)
+      debug_printf("%s buf %p off %d sz %d %s relocs: %d\n", 
+                   __FUNCTION__, 
+                   (void *)buffer, offset, size, 
+                   data_types[data_type],
+                   nr_relocs);
+
+   assert(buf->base.size >= offset + size);
+   memcpy(buf->virtual + offset, data, size);
+
+   /* Apply the relocations:
+    */
+   for (i = 0; i < nr_relocs; i++) {
+      if (BRW_DEBUG & DEBUG_WINSYS)
+         debug_printf("\treloc[%d] usage %s off %d value %x+%x\n", 
+                      i, usages[reloc[i].usage], reloc[i].offset,
+                      xlib_brw_buffer(reloc[i].bo)->offset, reloc[i].delta);
+
+      *(unsigned *)(buf->virtual + offset + reloc[i].offset) = 
+         xlib_brw_buffer(reloc[i].bo)->offset + reloc[i].delta;
+   }
+
+   if (BRW_DUMP)
+      brw_dump_data( xbw->chipset.pci_id,
+                    data_type,
+                    buf->offset + offset, 
+                    buf->virtual + offset, size );
+
+
+   return 0;
+}
+
+
+static boolean 
+xlib_brw_bo_is_busy(struct brw_winsys_buffer *buffer)
+{
+   if (BRW_DEBUG & DEBUG_WINSYS)
+      debug_printf("%s %p\n", __FUNCTION__, (void *)buffer);
+   return TRUE;
+}
+
+static boolean 
+xlib_brw_bo_references(struct brw_winsys_buffer *a,
+                         struct brw_winsys_buffer *b)
+{
+   if (BRW_DEBUG & DEBUG_WINSYS)
+      debug_printf("%s %p %p\n", __FUNCTION__, (void *)a, (void *)b);
+   return TRUE;
+}
+
+static enum pipe_error
+xlib_brw_check_aperture_space( struct brw_winsys_screen *iws,
+                                struct brw_winsys_buffer **buffers,
+                                unsigned count )
+{
+   unsigned tot_size = 0;
+   unsigned i;
+
+   for (i = 0; i < count; i++)
+      tot_size += buffers[i]->size;
+
+   if (BRW_DEBUG & DEBUG_WINSYS)
+      debug_printf("%s %d bufs, tot_size: %d kb\n", 
+                   __FUNCTION__, count, 
+                   (tot_size + 1023) / 1024);
+
+   return PIPE_OK;
+}
+
+static void *
+xlib_brw_bo_map(struct brw_winsys_buffer *buffer,
+                enum brw_buffer_data_type data_type,
+                unsigned offset,
+                unsigned length,
+                boolean write,
+                boolean discard,
+                boolean explicit)
+{
+   struct xlib_brw_buffer *buf = xlib_brw_buffer(buffer);
+
+   if (BRW_DEBUG & DEBUG_WINSYS)
+      debug_printf("%s %p %s %s\n", __FUNCTION__, (void *)buffer, 
+                   write ? "read/write" : "read",
+                   write ? data_types[data_type] : "");
+
+   if (write)
+      buf->modified = 1;
+
+   buf->map_count++;
+   return buf->virtual;
+}
+
+
+static void
+xlib_brw_bo_flush_range( struct brw_winsys_buffer *buffer,
+                         unsigned offset,
+                         unsigned length )
+{
+}
+
+
+static void 
+xlib_brw_bo_unmap(struct brw_winsys_buffer *buffer)
+{
+   struct xlib_brw_buffer *buf = xlib_brw_buffer(buffer);
+
+   if (BRW_DEBUG & DEBUG_WINSYS)
+      debug_printf("%s %p\n", __FUNCTION__, (void *)buffer);
+
+   --buf->map_count;
+   assert(buf->map_count >= 0);
+
+   if (buf->map_count == 0 &&
+       buf->modified) {
+
+      buf->modified = 0;
+      
+      /* Consider dumping new buffer contents here, using the
+       * flush-range info to minimize verbosity.
+       */
+   }
+}
+
+
+static void
+xlib_brw_bo_wait_idle( struct brw_winsys_buffer *buffer )
+{
+}
+
+
+static void
+xlib_brw_winsys_destroy( struct brw_winsys_screen *sws )
+{
+   struct xlib_brw_winsys *xbw = xlib_brw_winsys(sws);
+
+   FREE(xbw);
+}
+
+static struct brw_winsys_screen *
+xlib_create_brw_winsys_screen( void )
+{
+   struct xlib_brw_winsys *ws;
+
+   ws = CALLOC_STRUCT(xlib_brw_winsys);
+   if (!ws)
+      return NULL;
+
+   ws->used = 0;
+
+   ws->base.destroy              = xlib_brw_winsys_destroy;
+   ws->base.bo_alloc             = xlib_brw_bo_alloc;
+   ws->base.bo_destroy           = xlib_brw_bo_destroy;
+   ws->base.bo_emit_reloc        = xlib_brw_bo_emit_reloc;
+   ws->base.bo_exec              = xlib_brw_bo_exec;
+   ws->base.bo_subdata           = xlib_brw_bo_subdata;
+   ws->base.bo_is_busy           = xlib_brw_bo_is_busy;
+   ws->base.bo_references        = xlib_brw_bo_references;
+   ws->base.check_aperture_space = xlib_brw_check_aperture_space;
+   ws->base.bo_map               = xlib_brw_bo_map;
+   ws->base.bo_flush_range       = xlib_brw_bo_flush_range;
+   ws->base.bo_unmap             = xlib_brw_bo_unmap;
+   ws->base.bo_wait_idle         = xlib_brw_bo_wait_idle;
+
+   return &ws->base;
+}
+
+
+/***********************************************************************
+ * Implementation of Xlib co-state-tracker's winsys interface
+ */
+
+static void
+xlib_i965_display_surface(struct xmesa_buffer *xm_buffer,
+                          struct pipe_surface *surf)
+{
+   struct brw_surface *surface = brw_surface(surf);
+   struct xlib_brw_buffer *bo = xlib_brw_buffer(surface->bo);
+
+   if (BRW_DEBUG & DEBUG_WINSYS)
+      debug_printf("%s offset %x+%x sz %dx%d\n", __FUNCTION__, 
+                   bo->offset,
+                   surface->draw_offset,
+                   surf->width,
+                   surf->height);
+}
+
+static void
+xlib_i965_flush_frontbuffer(struct pipe_screen *screen,
+                           struct pipe_surface *surf,
+                           void *context_private)
+{
+   xlib_i965_display_surface(NULL, surf);
+}
+
+
+static struct pipe_screen *
+xlib_create_i965_screen( void )
+{
+   struct brw_winsys_screen *winsys;
+   struct pipe_screen *screen;
+
+   winsys = xlib_create_brw_winsys_screen();
+   if (winsys == NULL)
+      return NULL;
+
+   screen = brw_create_screen(winsys, PCI_CHIP_GM45_GM);
+   if (screen == NULL)
+      goto fail;
+
+   xlib_brw_winsys(winsys)->chipset = brw_screen(screen)->chipset;
+
+   screen->flush_frontbuffer = xlib_i965_flush_frontbuffer;
+   return screen;
+
+fail:
+   if (winsys)
+      winsys->destroy( winsys );
+
+   return NULL;
+}
+
+
+static struct pipe_context *
+xlib_create_i965_context( struct pipe_screen *screen,
+                          void *context_private )
+{
+   struct pipe_context *pipe;
+   
+   pipe = brw_create_context(screen);
+   if (pipe == NULL)
+      goto fail;
+
+   pipe->priv = context_private;
+   return pipe;
+
+fail:
+   /* Free stuff here */
+   return NULL;
+}
+
+
+
+
+struct xm_driver xlib_i965_driver = 
+{
+   .create_pipe_screen = xlib_create_i965_screen,
+   .create_pipe_context = xlib_create_i965_context,
+   .display_surface = xlib_i965_display_surface
+};
+
+
+/* Register this driver at library load: 
+ */
+static void _init( void ) __attribute__((constructor));
+static void _init( void )
+{
+   xmesa_set_driver( &xlib_i965_driver );
+}
+
+
+
+/***********************************************************************
+ *
+ * Butt-ugly hack to convince the linker not to throw away public GL
+ * symbols (they are all referenced from getprocaddress, I guess).
+ */
+extern void (*linker_foo(const unsigned char *procName))();
+extern void (*glXGetProcAddress(const unsigned char *procName))();
+
+extern void (*linker_foo(const unsigned char *procName))()
+{
+   return glXGetProcAddress(procName);
+}
diff --git a/src/gallium/winsys/drm/i965/xorg/Makefile b/src/gallium/winsys/drm/i965/xorg/Makefile
new file mode 100644 (file)
index 0000000..d91d000
--- /dev/null
@@ -0,0 +1,57 @@
+TARGET     = modesetting_drv.so
+CFILES     = $(wildcard ./*.c)
+OBJECTS    = $(patsubst ./%.c,./%.o,$(CFILES))
+TOP        = ../../../../../..
+
+include $(TOP)/configs/current
+
+INCLUDES = \
+       $(shell pkg-config --cflags-only-I pixman-1 xorg-server libdrm xproto) \
+       -I../gem \
+       -I$(TOP)/src/gallium/include \
+       -I$(TOP)/src/gallium/drivers \
+       -I$(TOP)/src/gallium/auxiliary \
+       -I$(TOP)/src/mesa \
+       -I$(TOP)/include \
+       -I$(TOP)/src/egl/main
+
+LIBS = \
+       $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \
+       $(TOP)/src/gallium/winsys/drm/i965/gem/libi965drm.a \
+       $(TOP)/src/gallium/drivers/i965/libi965.a \
+       $(TOP)/src/gallium/drivers/trace/libtrace.a \
+       $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
+       $(GALLIUM_AUXILIARIES)
+
+DRIVER_DEFINES = \
+       -DHAVE_CONFIG_H
+
+
+#############################################
+
+
+
+all default: $(TARGET)
+
+$(TARGET): $(OBJECTS) Makefile $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a $(LIBS)
+       $(TOP)/bin/mklib -noprefix -o $@ \
+       $(OBJECTS) $(LIBS) $(shell pkg-config --libs libdrm) -ldrm_intel
+
+clean:
+       rm -rf $(OBJECTS) $(TARGET)
+
+install:
+       $(INSTALL) -d $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
+       $(MINSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
+
+
+##############################################
+
+
+.c.o:
+       $(CC) -c $(CFLAGS) $(INCLUDES) $(DRIVER_DEFINES) $< -o $@
+
+
+##############################################
+
+.PHONY = all clean install
diff --git a/src/gallium/winsys/drm/i965/xorg/intel_xorg.c b/src/gallium/winsys/drm/i965/xorg/intel_xorg.c
new file mode 100644 (file)
index 0000000..ac691cb
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+ * 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.
+ *
+ *
+ * Author: Alan Hourihane <alanh@tungstengraphics.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ *
+ */
+
+#include "../../../../state_trackers/xorg/xorg_winsys.h"
+
+static void intel_xorg_identify(int flags);
+static Bool intel_xorg_pci_probe(DriverPtr driver,
+                                int entity_num,
+                                struct pci_device *device,
+                                intptr_t match_data);
+
+static const struct pci_id_match intel_xorg_device_match[] = {
+    {0x8086, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, 0},
+    {0, 0, 0},
+};
+
+static SymTabRec intel_xorg_chipsets[] = {
+    {PCI_MATCH_ANY, "Intel Graphics Device"},
+    {-1, NULL}
+};
+
+static PciChipsets intel_xorg_pci_devices[] = {
+    {PCI_MATCH_ANY, PCI_MATCH_ANY, NULL},
+    {-1, -1, NULL}
+};
+
+static XF86ModuleVersionInfo intel_xorg_version = {
+    "modesetting",
+    MODULEVENDORSTRING,
+    MODINFOSTRING1,
+    MODINFOSTRING2,
+    XORG_VERSION_CURRENT,
+    0, 1, 0, /* major, minor, patch */
+    ABI_CLASS_VIDEODRV,
+    ABI_VIDEODRV_VERSION,
+    MOD_CLASS_VIDEODRV,
+    {0, 0, 0, 0}
+};
+
+/*
+ * Xorg driver exported structures
+ */
+
+_X_EXPORT DriverRec modesetting = {
+    1,
+    "modesetting",
+    intel_xorg_identify,
+    NULL,
+    xorg_tracker_available_options,
+    NULL,
+    0,
+    NULL,
+    intel_xorg_device_match,
+    intel_xorg_pci_probe
+};
+
+static MODULESETUPPROTO(intel_xorg_setup);
+
+_X_EXPORT XF86ModuleData modesettingModuleData = {
+    &intel_xorg_version,
+    intel_xorg_setup,
+    NULL
+};
+
+/*
+ * Xorg driver functions
+ */
+
+static pointer
+intel_xorg_setup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+    static Bool setupDone = 0;
+
+    /* This module should be loaded only once, but check to be sure.
+     */
+    if (!setupDone) {
+       setupDone = 1;
+       xf86AddDriver(&modesetting, module, HaveDriverFuncs);
+
+       /*
+        * The return value must be non-NULL on success even though there
+        * is no TearDownProc.
+        */
+       return (pointer) 1;
+    } else {
+       if (errmaj)
+           *errmaj = LDR_ONCEONLY;
+       return NULL;
+    }
+}
+
+static void
+intel_xorg_identify(int flags)
+{
+    xf86PrintChipsets("modesetting", "Driver for Modesetting Kernel Drivers",
+                     intel_xorg_chipsets);
+}
+
+static Bool
+intel_xorg_pci_probe(DriverPtr driver,
+         int entity_num, struct pci_device *device, intptr_t match_data)
+{
+    ScrnInfoPtr scrn = NULL;
+    EntityInfoPtr entity;
+
+    scrn = xf86ConfigPciEntity(scrn, 0, entity_num, intel_xorg_pci_devices,
+                              NULL, NULL, NULL, NULL, NULL);
+    if (scrn != NULL) {
+       scrn->driverVersion = 1;
+       scrn->driverName = "i965";
+       scrn->name = "modesetting";
+       scrn->Probe = NULL;
+
+       entity = xf86GetEntityInfo(entity_num);
+
+       /* Use all the functions from the xorg tracker */
+       xorg_tracker_set_functions(scrn);
+    }
+    return scrn != NULL;
+}
index c0ecd9680e2cdcad3f813a694d1e8ff1f4fd7f9c..26aae4122eb0283e8d88be3573b2c2fdc9d15b8c 100644 (file)
@@ -24,4 +24,3 @@ DRI_LIB_DEPS += -ldrm_intel
 
 symlinks: $(TOP)/$(LIB_DIR)/gallium
        @rm -f $(TOP)/$(LIB_DIR)/gallium/i965_dri.so
-       ln -s i915_dri.so $(TOP)/$(LIB_DIR)/gallium/i965_dri.so
index b1b654d9f8b0ee0148a3b7a58d971aee757daa12..104e987083f4b290850a31652c8f494f6afbed4d 100644 (file)
@@ -15,6 +15,6 @@ drivers = [
 env.LoadableModule(
     target ='i915_dri.so',
     source = COMMON_GALLIUM_SOURCES,
-    LIBS = drivers + mesa + auxiliaries + env['LIBS'],
+    LIBS = drivers + mesa + gallium + env['LIBS'],
     SHLIBPREFIX = '',
 )
index 9ed570ff6e46125edceaed2c75b89cbb80fbff51..5ed2a10af1cee27cdc7ccac70f387a849e1ba876 100644 (file)
@@ -32,6 +32,7 @@ intel_drm_get_device_id(unsigned int *device_id)
    }
 
    shutup_gcc = fgets(path, sizeof(path), file);
+   (void) shutup_gcc;
    sscanf(path, "%x", device_id);
    fclose(file);
 }
index e70bfe7b44e336911701a9c69db734d748236702..e8b58742ab721b592499df5a8ec09e095559abaf 100644 (file)
@@ -39,11 +39,12 @@ intel_drm_fence_reference(struct intel_winsys *iws,
    struct intel_drm_fence *old = (struct intel_drm_fence *)*ptr;
    struct intel_drm_fence *f = (struct intel_drm_fence *)fence;
 
-   if (pipe_reference((struct pipe_reference**)ptr, &f->reference)) {
+   if (pipe_reference(&((struct intel_drm_fence *)(*ptr))->reference, &f->reference)) {
       if (old->bo)
          drm_intel_bo_unreference(old->bo);
       FREE(old);
    }
+   *ptr = fence;
 }
 
 static int
index f512c0e5f328dba0e802bd4c4c97e579c6c45ada..7106a06492d934f3f5306c07a9115d543a037944 100644 (file)
@@ -1,5 +1,6 @@
 #include "pipe/p_context.h"
 #include "pipe/p_state.h"
+#include "util/u_format.h"
 #include "util/u_memory.h"
 
 #include "nouveau_drm_api.h"
@@ -21,15 +22,13 @@ dri_surface_from_handle(struct drm_api *api, struct pipe_screen *pscreen,
        struct pipe_texture tmpl;
 
        memset(&tmpl, 0, sizeof(tmpl));
-       tmpl.tex_usage = PIPE_TEXTURE_USAGE_PRIMARY |
-                        NOUVEAU_TEXTURE_USAGE_LINEAR;
+       tmpl.tex_usage = PIPE_TEXTURE_USAGE_PRIMARY;
        tmpl.target = PIPE_TEXTURE_2D;
        tmpl.last_level = 0;
-       tmpl.depth[0] = 1;
+       tmpl.depth0 = 1;
        tmpl.format = format;
-       tmpl.width[0] = width;
-       tmpl.height[0] = height;
-       pf_get_block(tmpl.format, &tmpl.block);
+       tmpl.width0 = width;
+       tmpl.height0 = height;
 
        pt = api->texture_from_shared_handle(api, pscreen, &tmpl,
                                             "front buffer", pitch, handle);
@@ -248,7 +247,7 @@ nouveau_drm_handle_from_pt(struct drm_api *api, struct pipe_screen *pscreen,
                return false;
 
        *handle = mt->bo->handle;
-       *stride = mt->base.nblocksx[0] * mt->base.block.size;
+       *stride = util_format_get_stride(mt->base.format, mt->base.width0);
        return true;
 }
 
index 42a6f4abc21898c86c6c1e94efdd4eaf3e9debc3..860cbb6dbf8af3c8e40d932f8a142246f70ac24b 100644 (file)
@@ -7,8 +7,7 @@ LIBNAME = radeonwinsys
 C_SOURCES = \
        radeon_buffer.c \
        radeon_drm.c \
-       radeon_r300.c \
-       radeon_winsys_softpipe.c
+       radeon_r300.c
 
 LIBRARY_INCLUDES = -I$(TOP)/src/gallium/drivers/r300 \
                   $(shell pkg-config libdrm --cflags-only-I)
index 2ad68e403fe359d55c9c5a9a3556c20d3dad1e39..f4e9c397bdf46a06635e8a916d47a355daeae266 100644 (file)
@@ -6,7 +6,6 @@ radeon_sources = [
     'radeon_buffer.c',
     'radeon_drm.c',
     'radeon_r300.c',
-    'radeon_winsys_softpipe.c',
 ]
 
 env.Append(CPPPATH = '#/src/gallium/drivers/r300')
index 7bf23cba236520c0749b511e487de47b72ce86d1..d2367b245a2b490b7568b07a586bb4d98947c28d 100644 (file)
 #include "radeon_buffer.h"
 
 #include "radeon_bo_gem.h"
+#include "softpipe/sp_texture.h"
+#include "r300_context.h"
+#include "util/u_format.h"
+#include "util/u_math.h"
+#include <X11/Xutil.h>
+
+struct radeon_vl_context
+{
+    Display *display;
+    int screen;
+    Drawable drawable;
+};
 
 static const char *radeon_get_name(struct pipe_winsys *ws)
 {
@@ -104,17 +116,13 @@ static struct pipe_buffer *radeon_surface_buffer_create(struct pipe_winsys *ws,
                                                         unsigned tex_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;
+    const unsigned alignment = 64;
+    unsigned nblocksy, size;
+
+    nblocksy = util_format_get_nblocksy(format, height);
+    *stride = align(util_format_get_stride(format, width), alignment);
     size = *stride * nblocksy;
 
     return radeon_buffer_create(ws, 64, usage, size);
@@ -133,10 +141,15 @@ static void *radeon_buffer_map(struct pipe_winsys *ws,
                                struct pipe_buffer *buffer,
                                unsigned flags)
 {
+    struct radeon_winsys_priv *priv = ((struct radeon_winsys *)ws)->priv;
     struct radeon_pipe_buffer *radeon_buffer =
         (struct radeon_pipe_buffer*)buffer;
     int write = 0;
 
+    if (radeon_bo_is_referenced_by_cs(radeon_buffer->bo, priv->cs)) {
+        priv->flush_cb(priv->flush_data);
+    }
+
     if (flags & PIPE_BUFFER_USAGE_DONTBLOCK) {
         uint32_t domain;
 
@@ -183,11 +196,53 @@ static int radeon_fence_finish(struct pipe_winsys *ws,
     return 0;
 }
 
+static void radeon_display_surface(struct pipe_winsys *pws,
+                                   struct pipe_surface *psurf,
+                                   struct radeon_vl_context *rvl_ctx)
+{
+    struct r300_texture *r300tex = (struct r300_texture *)(psurf->texture);
+    XImage *ximage;
+    void *data;
+
+    ximage = XCreateImage(rvl_ctx->display,
+                          XDefaultVisual(rvl_ctx->display, rvl_ctx->screen),
+                          XDefaultDepth(rvl_ctx->display, rvl_ctx->screen),
+                          ZPixmap, 0,   /* format, offset */
+                          NULL,         /* data */
+                          0, 0,         /* size */
+                          32,           /* bitmap_pad */
+                          0);           /* bytes_per_line */
+
+    assert(ximage->format);
+    assert(ximage->bitmap_unit);
+
+    data = pws->buffer_map(pws, r300tex->buffer, 0);
+
+    /* update XImage's fields */
+    ximage->data = data;
+    ximage->width = psurf->width;
+    ximage->height = psurf->height;
+    ximage->bytes_per_line = psurf->width * (ximage->bits_per_pixel >> 3);
+
+    XPutImage(rvl_ctx->display, rvl_ctx->drawable,
+              XDefaultGC(rvl_ctx->display, rvl_ctx->screen),
+              ximage, 0, 0, 0, 0, psurf->width, psurf->height);
+
+    XSync(rvl_ctx->display, 0);
+
+    ximage->data = NULL;
+    XDestroyImage(ximage);
+
+    pws->buffer_unmap(pws, r300tex->buffer);
+}
+
 static void radeon_flush_frontbuffer(struct pipe_winsys *pipe_winsys,
                                      struct pipe_surface *pipe_surface,
                                      void *context_private)
 {
-    /* XXX TODO: call dri2CopyRegion */
+    struct radeon_vl_context *rvl_ctx;
+    rvl_ctx = (struct radeon_vl_context *) context_private;
+    radeon_display_surface(pipe_winsys, pipe_surface, rvl_ctx);
 }
 
 struct radeon_winsys* radeon_pipe_winsys(int fd)
@@ -266,13 +321,10 @@ struct pipe_surface *radeon_surface_from_handle(struct radeon_context *radeon_co
     memset(&tmpl, 0, sizeof(tmpl));
     tmpl.tex_usage = PIPE_TEXTURE_USAGE_DISPLAY_TARGET;
     tmpl.target = PIPE_TEXTURE_2D;
-    tmpl.width[0] = w;
-    tmpl.height[0] = h;
-    tmpl.depth[0] = 1;
+    tmpl.width0 = w;
+    tmpl.height0 = h;
+    tmpl.depth0 = 1;
     tmpl.format = format;
-    pf_get_block(tmpl.format, &tmpl.block);
-    tmpl.nblocksx[0] = pf_get_nblocksx(&tmpl.block, w);
-    tmpl.nblocksy[0] = pf_get_nblocksy(&tmpl.block, h);
 
     pt = pipe_screen->texture_blanket(pipe_screen, &tmpl, &pitch, pb);
     if (pt == NULL) {
index f5153b06af535aae6c8a046ed95139c57a74134b..d7f17564a9f75b780711bf30fd824ac360242393 100644 (file)
@@ -45,6 +45,8 @@
 
 #include "radeon_drm.h"
 
+#include "radeon_winsys.h"
+
 struct radeon_pipe_buffer {
     struct pipe_buffer  base;
     struct radeon_bo    *bo;
@@ -66,14 +68,10 @@ struct radeon_winsys_priv {
 
     /* Current CS. */
     struct radeon_cs* cs;
-};
-
-struct radeon_winsys {
-    /* Parent class. */
-    struct pipe_winsys base;
 
-    /* This corresponds to void* radeon_winsys in r300_winsys. */
-    struct radeon_winsys_priv* priv;
+    /* Flush CB */
+    void (*flush_cb)(void *);
+    void *flush_data;
 };
 
 struct radeon_winsys* radeon_pipe_winsys(int fb);
index caab33de1ccc0879bd5af3fe53f0b392e55c3ace..05194fc52a2d1ad7371515ae349c545ef3eb44c0 100644 (file)
  *      Joakim Sindholt <opensource@zhasha.com>
  */
 
+#include "softpipe/sp_winsys.h"
+
 #include "radeon_drm.h"
 
+/* Helper function to do the ioctls needed for setup and init. */
+static void do_ioctls(int fd, struct radeon_winsys* winsys)
+{
+    struct drm_radeon_gem_info gem_info = {0};
+    struct drm_radeon_info info = {0};
+    int target = 0;
+    int retval;
+
+    info.value = (unsigned long)&target;
+
+    /* We do things in a specific order here.
+     *
+     * First, the PCI ID. This is essential and should return usable numbers
+     * for all Radeons. If this fails, we probably got handed an FD for some
+     * non-Radeon card.
+     *
+     * The GB and Z pipe requests should always succeed, but they might not
+     * return sensical values for all chipsets, but that's alright because
+     * the pipe drivers already know that.
+     *
+     * The GEM info is actually bogus on the kernel side, as well as our side
+     * (see radeon_gem_info_ioctl in radeon_gem.c) but that's alright because
+     * we don't actually use the info for anything yet.
+     * XXX update the above when we can safely use vram_size instead of vram_visible */
+    info.request = RADEON_INFO_DEVICE_ID;
+    retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info));
+    if (retval) {
+        fprintf(stderr, "%s: Failed to get PCI ID, "
+                "error number %d\n", __FUNCTION__, retval);
+        exit(1);
+    }
+    winsys->pci_id = target;
+
+    info.request = RADEON_INFO_NUM_GB_PIPES;
+    retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info));
+    if (retval) {
+        fprintf(stderr, "%s: Failed to get GB pipe count, "
+                "error number %d\n", __FUNCTION__, retval);
+        exit(1);
+    }
+    winsys->gb_pipes = target;
+
+    info.request = RADEON_INFO_NUM_Z_PIPES;
+    retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info));
+    if (retval) {
+        fprintf(stderr, "%s: Failed to get Z pipe count, "
+                "error number %d\n", __FUNCTION__, retval);
+        exit(1);
+    }
+    winsys->z_pipes = target;
+
+    retval = drmCommandWriteRead(fd, DRM_RADEON_GEM_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 = gem_info.gart_size;
+    /* XXX */
+    winsys->vram_size = gem_info.vram_visible;
+}
+
+/* Guess at whether this chipset should use r300g.
+ *
+ * I believe that this check is valid, but I haven't been exhaustive. */
+static boolean is_r3xx(int pciid)
+{
+    return (pciid > 0x3150) && (pciid < 0x796f);
+}
+
 /* Create a pipe_screen. */
 struct pipe_screen* radeon_create_screen(struct drm_api* api,
                                          int drmFB,
                                          struct drm_create_screen_arg *arg)
 {
-    struct radeon_winsys* winsys = radeon_pipe_winsys(drmFB);
+    struct radeon_winsys* rwinsys = radeon_pipe_winsys(drmFB);
+    do_ioctls(drmFB, rwinsys);
 
-    if (getenv("RADEON_SOFTPIPE")) {
-        return softpipe_create_screen((struct pipe_winsys*)winsys);
+    if (!is_r3xx(rwinsys->pci_id) ||
+        debug_get_bool_option("RADEON_SOFTPIPE", FALSE)) {
+        return softpipe_create_screen((struct pipe_winsys*)rwinsys);
     } else {
-        struct r300_winsys* r300 = radeon_create_r300_winsys(drmFB, winsys);
-        FREE(winsys);
-        return r300_create_screen(r300);
+        radeon_setup_winsys(drmFB, rwinsys);
+        return r300_create_screen(rwinsys);
     }
 }
 
@@ -51,11 +125,13 @@ struct pipe_screen* radeon_create_screen(struct drm_api* api,
 struct pipe_context* radeon_create_context(struct drm_api* api,
                                            struct pipe_screen* screen)
 {
-    if (getenv("RADEON_SOFTPIPE")) {
-        return radeon_create_softpipe(screen->winsys);
+    struct radeon_winsys* rwinsys = (struct radeon_winsys*)screen->winsys;
+
+    if (!is_r3xx(rwinsys->pci_id) ||
+        debug_get_bool_option("RADEON_SOFTPIPE", FALSE)) {
+        return softpipe_create(screen);
     } else {
-        return r300_create_context(screen,
-                                   (struct r300_winsys*)screen->winsys);
+        return r300_create_context(screen, rwinsys);
     }
 }
 
@@ -130,7 +206,7 @@ static boolean radeon_shared_handle_from_texture(struct drm_api *api,
     int retval, fd;
     struct drm_gem_flink flink;
     struct radeon_pipe_buffer* radeon_buffer;
-    struct pipe_buffer *buffer;
+    struct pipe_buffer *buffer = NULL;
 
     if (!radeon_buffer_from_texture(api, texture, &buffer, stride)) {
         return FALSE;
@@ -163,7 +239,7 @@ static boolean radeon_local_handle_from_texture(struct drm_api *api,
                                                 unsigned *stride,
                                                 unsigned *handle)
 {
-    struct pipe_buffer *buffer;
+    struct pipe_buffer *buffer = NULL;
     if (!radeon_buffer_from_texture(api, texture, &buffer, stride)) {
         return FALSE;
     }
index 88a5c82b284b67ed822bc771e0618833365d891a..bf0e78138d75e829150386cfd9bfab9f89a3fe7f 100644 (file)
 #include "pipe/p_screen.h"
 
 #include "trace/tr_drm.h"
+#include "util/u_debug.h"
 #include "util/u_memory.h"
 
 #include "state_tracker/drm_api.h"
 
 #include "radeon_buffer.h"
 #include "radeon_r300.h"
-#include "radeon_winsys_softpipe.h"
 
 /* XXX */
 #include "r300_screen.h"
index d2d84f1a8f0ee31b57db8dcb8e38c9710e8e6e07..0875ee41cbfd76d0311258cd5871331f44bff330 100644 (file)
 
 #include "radeon_r300.h"
 
-static boolean radeon_r300_add_buffer(struct r300_winsys* winsys,
-                                      struct pipe_buffer* pbuffer,
-                                      uint32_t rd,
-                                      uint32_t wd)
+static void radeon_set_flush_cb(struct radeon_winsys *winsys,
+                                void (*flush_cb)(void *),
+                                void *data)
+{
+    winsys->priv->flush_cb = flush_cb;
+    winsys->priv->flush_data = data;
+    radeon_cs_space_set_flush(winsys->priv->cs, flush_cb, data);
+}
+
+static boolean radeon_add_buffer(struct radeon_winsys* winsys,
+                                 struct pipe_buffer* pbuffer,
+                                 uint32_t rd,
+                                 uint32_t wd)
 {
-    struct radeon_winsys_priv* priv =
-        (struct radeon_winsys_priv*)winsys->radeon_winsys;
     struct radeon_bo* bo = ((struct radeon_pipe_buffer*)pbuffer)->bo;
 
-    radeon_cs_space_add_persistent_bo(priv->cs, bo, rd, wd);
+    radeon_cs_space_add_persistent_bo(winsys->priv->cs, bo, rd, wd);
     return TRUE;
 }
 
-static boolean radeon_r300_validate(struct r300_winsys* winsys)
+static boolean radeon_validate(struct radeon_winsys* winsys)
 {
-    struct radeon_winsys_priv* priv =
-        (struct radeon_winsys_priv*)winsys->radeon_winsys;
-
-    if (radeon_cs_space_check(priv->cs) < 0) {
+    if (radeon_cs_space_check(winsys->priv->cs) < 0) {
         return FALSE;
     }
 
@@ -48,45 +52,37 @@ static boolean radeon_r300_validate(struct r300_winsys* winsys)
     return TRUE;
 }
 
-static boolean radeon_r300_check_cs(struct r300_winsys* winsys, int size)
+static boolean radeon_check_cs(struct radeon_winsys* winsys, int size)
 {
-    /* XXX check size here, lazy ass! */
-    /* XXX also validate buffers */
-    return TRUE;
+    struct radeon_cs* cs = winsys->priv->cs;
+
+    return radeon_validate(winsys) && cs->cdw + size <= cs->ndw;
 }
 
-static void radeon_r300_begin_cs(struct r300_winsys* winsys,
-                                 int size,
-                                 const char* file,
-                                 const char* function,
-                                 int line)
+static void radeon_begin_cs(struct radeon_winsys* winsys,
+                            int size,
+                            const char* file,
+                            const char* function,
+                            int line)
 {
-    struct radeon_winsys_priv* priv =
-        (struct radeon_winsys_priv*)winsys->radeon_winsys;
-
-    radeon_cs_begin(priv->cs, size, file, function, line);
+    radeon_cs_begin(winsys->priv->cs, size, file, function, line);
 }
 
-static void radeon_r300_write_cs_dword(struct r300_winsys* winsys,
-                                       uint32_t dword)
+static void radeon_write_cs_dword(struct radeon_winsys* winsys,
+                                  uint32_t dword)
 {
-    struct radeon_winsys_priv* priv =
-        (struct radeon_winsys_priv*)winsys->radeon_winsys;
-
-    radeon_cs_write_dword(priv->cs, dword);
+    radeon_cs_write_dword(winsys->priv->cs, dword);
 }
 
-static void radeon_r300_write_cs_reloc(struct r300_winsys* winsys,
-                                       struct pipe_buffer* pbuffer,
-                                       uint32_t rd,
-                                       uint32_t wd,
-                                       uint32_t flags)
+static void radeon_write_cs_reloc(struct radeon_winsys* winsys,
+                                  struct pipe_buffer* pbuffer,
+                                  uint32_t rd,
+                                  uint32_t wd,
+                                  uint32_t flags)
 {
-    struct radeon_winsys_priv* priv =
-        (struct radeon_winsys_priv*)winsys->radeon_winsys;
     int retval = 0;
 
-    retval = radeon_cs_write_reloc(priv->cs,
+    retval = radeon_cs_write_reloc(winsys->priv->cs,
             ((struct radeon_pipe_buffer*)pbuffer)->bo, rd, wd, flags);
 
     if (retval) {
@@ -95,116 +91,60 @@ static void radeon_r300_write_cs_reloc(struct r300_winsys* winsys,
     }
 }
 
-static void radeon_r300_end_cs(struct r300_winsys* winsys,
-                               const char* file,
-                               const char* function,
-                               int line)
+static void radeon_reset_bos(struct radeon_winsys *winsys)
 {
-    struct radeon_winsys_priv* priv =
-        (struct radeon_winsys_priv*)winsys->radeon_winsys;
+    radeon_cs_space_reset_bos(winsys->priv->cs);
+}
 
-    radeon_cs_end(priv->cs, file, function, line);
+static void radeon_end_cs(struct radeon_winsys* winsys,
+                          const char* file,
+                          const char* function,
+                          int line)
+{
+    radeon_cs_end(winsys->priv->cs, file, function, line);
 }
 
-static void radeon_r300_flush_cs(struct r300_winsys* winsys)
+static void radeon_flush_cs(struct radeon_winsys* winsys)
 {
-    struct radeon_winsys_priv* priv =
-        (struct radeon_winsys_priv*)winsys->radeon_winsys;
     int retval;
 
     /* Emit the CS. */
-    retval = radeon_cs_emit(priv->cs);
+    retval = radeon_cs_emit(winsys->priv->cs);
     if (retval) {
         debug_printf("radeon: Bad CS, dumping...\n");
-        radeon_cs_print(priv->cs, stderr);
+        radeon_cs_print(winsys->priv->cs, stderr);
     }
 
-    /* Clean out BOs. */
-    radeon_cs_space_reset_bos(priv->cs);
-
     /* Reset CS.
      * Someday, when we care about performance, we should really find a way
      * to rotate between two or three CS objects so that the GPU can be
      * spinning through one CS while another one is being filled. */
-    radeon_cs_erase(priv->cs);
-}
-
-/* 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 gem_info = {0};
-    struct drm_radeon_info info = {0};
-    int target = 0;
-    int retval;
-
-    info.value = (unsigned long)&target;
-
-    /* First, get the number of pixel pipes */
-    info.request = RADEON_INFO_NUM_GB_PIPES;
-    retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info));
-    if (retval) {
-        fprintf(stderr, "%s: Failed to get GB pipe count, "
-                "error number %d\n", __FUNCTION__, retval);
-        exit(1);
-    }
-    winsys->gb_pipes = target;
-
-    /* Then, 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 PCI ID, "
-                "error number %d\n", __FUNCTION__, retval);
-        exit(1);
-    }
-    winsys->pci_id = target;
-
-    /* Finally, retrieve MM info */
-    retval = drmCommandWriteRead(fd, DRM_RADEON_GEM_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 = gem_info.gart_size;
-    /* XXX */
-    winsys->vram_size = gem_info.vram_visible;
+    radeon_cs_erase(winsys->priv->cs);
 }
 
-struct r300_winsys*
-radeon_create_r300_winsys(int fd, struct radeon_winsys* old_winsys)
+void
+radeon_setup_winsys(int fd, struct radeon_winsys* winsys)
 {
-    struct r300_winsys* winsys = CALLOC_STRUCT(r300_winsys);
-    struct radeon_winsys_priv* priv;
-
-    if (winsys == NULL) {
-        return NULL;
-    }
-
-    priv = old_winsys->priv;
-
-    do_ioctls(winsys, fd);
+    struct radeon_winsys_priv* priv = winsys->priv;
 
     priv->csm = radeon_cs_manager_gem_ctor(fd);
 
+    /* Size limit on IBs is 64 kibibytes. */
     priv->cs = radeon_cs_create(priv->csm, 1024 * 64 / 4);
     radeon_cs_set_limit(priv->cs,
             RADEON_GEM_DOMAIN_GTT, winsys->gart_size);
     radeon_cs_set_limit(priv->cs,
             RADEON_GEM_DOMAIN_VRAM, winsys->vram_size);
 
-    winsys->add_buffer = radeon_r300_add_buffer;
-    winsys->validate = radeon_r300_validate;
-
-    winsys->check_cs = radeon_r300_check_cs;
-    winsys->begin_cs = radeon_r300_begin_cs;
-    winsys->write_cs_dword = radeon_r300_write_cs_dword;
-    winsys->write_cs_reloc = radeon_r300_write_cs_reloc;
-    winsys->end_cs = radeon_r300_end_cs;
-    winsys->flush_cs = radeon_r300_flush_cs;
-
-    memcpy(winsys, old_winsys, sizeof(struct radeon_winsys));
-
-    return winsys;
+    winsys->add_buffer = radeon_add_buffer;
+    winsys->validate = radeon_validate;
+
+    winsys->check_cs = radeon_check_cs;
+    winsys->begin_cs = radeon_begin_cs;
+    winsys->write_cs_dword = radeon_write_cs_dword;
+    winsys->write_cs_reloc = radeon_write_cs_reloc;
+    winsys->end_cs = radeon_end_cs;
+    winsys->flush_cs = radeon_flush_cs;
+    winsys->reset_bos = radeon_reset_bos;
+    winsys->set_flush_cb = radeon_set_flush_cb;
 }
index 775d7937fd85e002c01be668c9693a3a6916260a..cfbdb302661eebb9368bc62726cf4460c4ddfbc4 100644 (file)
@@ -34,9 +34,6 @@
 
 #include "radeon_buffer.h"
 
-struct radeon_winsys;
-
-struct r300_winsys*
-radeon_create_r300_winsys(int fd, struct radeon_winsys* old_winsys);
+void radeon_setup_winsys(int fd, struct radeon_winsys* winsys);
 
 #endif /* RADEON_R300_H */
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_winsys.h b/src/gallium/winsys/drm/radeon/core/radeon_winsys.h
new file mode 100644 (file)
index 0000000..9edc9e0
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * Copyright © 2009 Corbin Simpson
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and 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:
+ *      Corbin Simpson <MostAwesomeDude@gmail.com>
+ */
+#ifndef RADEON_WINSYS_H
+#define RADEON_WINSYS_H
+
+#include "pipe/internal/p_winsys_screen.h"
+
+struct radeon_winsys_priv;
+
+struct radeon_winsys {
+    /* Parent class. */
+    struct pipe_winsys base;
+
+    /* Winsys private */
+    struct radeon_winsys_priv* priv;
+
+    /* PCI ID */
+    uint32_t pci_id;
+
+    /* GB pipe count */
+    uint32_t gb_pipes;
+
+    /* Z pipe count (rv530 only) */
+    uint32_t z_pipes;
+
+    /* GART size. */
+    uint32_t gart_size;
+
+    /* VRAM size. */
+    uint32_t vram_size;
+
+    /* Add a pipe_buffer to the list of buffer objects to validate. */
+    boolean (*add_buffer)(struct radeon_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. */
+    boolean (*validate)(struct radeon_winsys* winsys);
+
+    /* Check to see if there's room for commands. */
+    boolean (*check_cs)(struct radeon_winsys* winsys, int size);
+
+    /* Start a command emit. */
+    void (*begin_cs)(struct radeon_winsys* winsys,
+                     int size,
+                     const char* file,
+                     const char* function,
+                     int line);
+
+    /* Write a dword to the command buffer. */
+    void (*write_cs_dword)(struct radeon_winsys* winsys, uint32_t dword);
+
+    /* Write a relocated dword to the command buffer. */
+    void (*write_cs_reloc)(struct radeon_winsys* winsys,
+                           struct pipe_buffer* bo,
+                           uint32_t rd,
+                           uint32_t wd,
+                           uint32_t flags);
+
+    /* Finish a command emit. */
+    void (*end_cs)(struct radeon_winsys* winsys,
+                   const char* file,
+                   const char* function,
+                   int line);
+
+    /* Flush the CS. */
+    void (*flush_cs)(struct radeon_winsys* winsys);
+
+    /* winsys flush - callback from winsys when flush required */
+    void (*set_flush_cb)(struct radeon_winsys *winsys,
+                        void (*flush_cb)(void *), void *data);
+
+    void (*reset_bos)(struct radeon_winsys *winsys);
+};
+
+#endif
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_winsys_softpipe.c b/src/gallium/winsys/drm/radeon/core/radeon_winsys_softpipe.c
deleted file mode 100644 (file)
index f038bfa..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
- * All Rights Reserved.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- * 
- * 
- **************************************************************************/
-/*
- * Authors: Keith Whitwell <keithw-at-tungstengraphics-dot-com>
- */
-
-#include "radeon_winsys_softpipe.h"
-
-struct pipe_context *radeon_create_softpipe(struct pipe_winsys* winsys)
-{
-    struct pipe_screen *pipe_screen;
-
-    pipe_screen = softpipe_create_screen(winsys);
-
-    return softpipe_create(pipe_screen);
-}
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_winsys_softpipe.h b/src/gallium/winsys/drm/radeon/core/radeon_winsys_softpipe.h
deleted file mode 100644 (file)
index 04740e4..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/* 
- * 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_WINSYS_SOFTPIPE_H
-#define RADEON_WINSYS_SOFTPIPE_H
-
-#include <stdio.h>
-
-#include "pipe/p_defines.h"
-#include "pipe/p_format.h"
-
-#include "softpipe/sp_winsys.h"
-
-#include "util/u_memory.h"
-
-struct pipe_context *radeon_create_softpipe(struct pipe_winsys* winsys);
-
-#endif
index aea987a3acaf4310d5ac9078bdffd167a686253c..c4989d1b595e1f252abd8efcfbdc104d6f203592 100644 (file)
@@ -13,5 +13,5 @@ drivers = [
 env.SharedLibrary(
     target ='radeon_dri.so',
     source = COMMON_GALLIUM_SOURCES,
-    LIBS = st_dri + radeonwinsys + mesa + drivers + auxiliaries + env['LIBS'],
+    LIBS = st_dri + radeonwinsys + mesa + drivers + gallium + env['LIBS'],
 )
index 3200fd8d1b065165cb0410419aa3f794a0d413f9..91cae986975715a525eaa64664880ccfeb2ac2ef 100644 (file)
@@ -29,5 +29,5 @@ if env['platform'] == 'linux':
     env.SharedLibrary(
         target ='_gallium',
         source = sources,
-        LIBS = [pyst] + drivers + auxiliaries + env['LIBS'],
+        LIBS = [pyst] + drivers + gallium + env['LIBS'],
     )
index 9fa16dab24cc79c1c9bc848840d7323b3f6c1378..0eb1b3988f36acfb2df83730de48e3de845a0ce8 100644 (file)
@@ -1,11 +1,16 @@
-TARGET     = modesetting_drv.so
-CFILES     = $(wildcard ./*.c)
-OBJECTS    = $(patsubst ./%.c,./%.o,$(CFILES))
-GALLIUMDIR = ../../../..
 TOP        = ../../../../../..
 
+
+GALLIUMDIR = $(TOP)/src/gallium
+
+TARGET     = radeong_drv.so
+
+CFILES     = $(wildcard ./*.c)
+
 include ${TOP}/configs/current
 
+OBJECTS    = $(patsubst ./%.c,./%.o,$(CFILES))
+
 CFLAGS = -DHAVE_CONFIG_H \
          -g -Wall -Wimplicit-function-declaration -fPIC \
          $(shell pkg-config --cflags pixman-1 xorg-server libdrm xproto) \
@@ -24,16 +29,21 @@ LIBS = \
        $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
        $(GALLIUM_AUXILIARIES)
 
+TARGET_STAGING = $(TOP)/$(LIB_DIR)/gallium/$(TARGET)
 #############################################
 
+all default: $(TARGET) $(TARGET_STAGING)
 
-
-all default: $(TARGET)
-
-$(TARGET): $(OBJECTS) Makefile $(GALLIUMDIR)/state_trackers/xorg/libxorgtracker.a
+$(TARGET): $(OBJECTS) Makefile $(GALLIUMDIR)/state_trackers/xorg/libxorgtracker.a $(LIBS)
        $(TOP)/bin/mklib -noprefix -o $@ \
        $(OBJECTS) $(LIBS) $(shell pkg-config --libs libdrm) -ldrm_radeon
 
+$(TOP)/$(LIB_DIR)/gallium:
+       mkdir -p $@
+
+$(TARGET_STAGING): $(TARGET) $(TOP)/$(LIB_DIR)/gallium
+       $(INSTALL) $(TARGET) $(TOP)/$(LIB_DIR)/gallium
+
 clean:
        rm -rf $(OBJECTS) $(TARGET)
 
index 837f2aa8fec5106021e384eeff00f3783afba05c..bb76cc03499d61efe3c947e86ab26718c102819a 100644 (file)
@@ -53,7 +53,7 @@ static PciChipsets radeon_xorg_pci_devices[] = {
 };
 
 static XF86ModuleVersionInfo radeon_xorg_version = {
-    "modesetting",
+    "radeong",
     MODULEVENDORSTRING,
     MODINFOSTRING1,
     MODINFOSTRING2,
@@ -69,9 +69,9 @@ static XF86ModuleVersionInfo radeon_xorg_version = {
  * Xorg driver exported structures
  */
 
-_X_EXPORT DriverRec modesetting = {
+_X_EXPORT DriverRec radeong = {
     1,
-    "modesetting",
+    "radeong",
     radeon_xorg_identify,
     NULL,
     xorg_tracker_available_options,
@@ -84,7 +84,7 @@ _X_EXPORT DriverRec modesetting = {
 
 static MODULESETUPPROTO(radeon_xorg_setup);
 
-_X_EXPORT XF86ModuleData modesettingModuleData = {
+_X_EXPORT XF86ModuleData radeongModuleData = {
     &radeon_xorg_version,
     radeon_xorg_setup,
     NULL
@@ -103,7 +103,7 @@ radeon_xorg_setup(pointer module, pointer opts, int *errmaj, int *errmin)
      */
     if (!setupDone) {
        setupDone = 1;
-       xf86AddDriver(&modesetting, module, HaveDriverFuncs);
+       xf86AddDriver(&radeong, module, HaveDriverFuncs);
 
        /*
         * The return value must be non-NULL on success even though there
@@ -120,7 +120,7 @@ radeon_xorg_setup(pointer module, pointer opts, int *errmaj, int *errmin)
 static void
 radeon_xorg_identify(int flags)
 {
-    xf86PrintChipsets("modesetting", "Driver for Modesetting Kernel Drivers",
+    xf86PrintChipsets("radeong", "Driver for Radeon Gallium with KMS",
                      radeon_xorg_chipsets);
 }
 
@@ -135,8 +135,8 @@ radeon_xorg_pci_probe(DriverPtr driver,
                               NULL, NULL, NULL, NULL, NULL);
     if (scrn != NULL) {
        scrn->driverVersion = 1;
-       scrn->driverName = "radeon";
-       scrn->name = "modesetting";
+       scrn->driverName = "radeong";
+       scrn->name = "radeong";
        scrn->Probe = NULL;
 
        entity = xf86GetEntityInfo(entity_num);
diff --git a/src/gallium/winsys/drm/vmware/Makefile b/src/gallium/winsys/drm/vmware/Makefile
new file mode 100644 (file)
index 0000000..2ae6dea
--- /dev/null
@@ -0,0 +1,12 @@
+# src/gallium/winsys/drm/vmware/Makefile
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+SUBDIRS = core $(GALLIUM_STATE_TRACKERS_DIRS)
+
+default install clean:
+       @for dir in $(SUBDIRS) ; do \
+               if [ -d $$dir ] ; then \
+                       (cd $$dir && $(MAKE) $@) || exit 1; \
+               fi \
+       done
diff --git a/src/gallium/winsys/drm/vmware/SConscript b/src/gallium/winsys/drm/vmware/SConscript
new file mode 100644 (file)
index 0000000..06e6d5b
--- /dev/null
@@ -0,0 +1,11 @@
+Import('*')
+
+SConscript(['core/SConscript',])
+
+if 'mesa' in env['statetrackers']:
+
+    SConscript(['dri/SConscript'])
+
+if 'xorg' in env['statetrackers']:
+
+    SConscript(['xorg/SConscript'])
diff --git a/src/gallium/winsys/drm/vmware/core/Makefile b/src/gallium/winsys/drm/vmware/core/Makefile
new file mode 100644 (file)
index 0000000..a52957c
--- /dev/null
@@ -0,0 +1,35 @@
+TOP = ../../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = svgadrm
+
+C_SOURCES = \
+        vmw_buffer.c \
+        vmw_context.c  \
+        vmw_fence.c  \
+        vmw_screen.c  \
+        vmw_screen_dri.c  \
+        vmw_screen_ioctl.c  \
+        vmw_screen_pools.c  \
+        vmw_screen_svga.c  \
+        vmw_surface.c
+
+LIBRARY_INCLUDES = \
+       -I$(TOP)/src/gallium/drivers/svga \
+       -I$(TOP)/src/gallium/drivers/svga/include \
+       -I$(GALLIUM)/src/mesa/drivers/dri/common \
+       -I$(GALLIUM)/include \
+       -I$(GALLIUM)/include/GL/internal \
+       -I$(GALLIUM)/src/mesa \
+       -I$(GALLIUM)/src/mesa/main \
+       -I$(GALLIUM)/src/mesa/glapi \
+       -I$(GALLIUM)/src/egl/main \
+       -I$(GALLIUM)/src/egl/drivers/dri \
+       $(shell pkg-config libdrm --cflags-only-I)
+
+LIBRARY_DEFINES = \
+       -std=gnu99 -fvisibility=hidden \
+       -DHAVE_STDINT_H -D_FILE_OFFSET_BITS=64 \
+       $(shell pkg-config libdrm --cflags-only-other)
+
+include ../../../../Makefile.template
diff --git a/src/gallium/winsys/drm/vmware/core/SConscript b/src/gallium/winsys/drm/vmware/core/SConscript
new file mode 100644 (file)
index 0000000..edaf945
--- /dev/null
@@ -0,0 +1,39 @@
+Import('*')
+
+env = env.Clone()
+
+if env['gcc']:
+       env.Append(CCFLAGS = ['-fvisibility=hidden'])
+       env.Append(CPPDEFINES = [
+               'HAVE_STDINT_H', 
+               'HAVE_SYS_TYPES_H',
+                '-D_FILE_OFFSET_BITS=64',
+       ])
+       
+env.Prepend(CPPPATH = [
+       'include',
+        '#/src/gallium/drivers/svga',
+        '#/src/gallium/drivers/svga/include',
+])
+
+env.Append(CPPDEFINES = [
+])
+
+sources = [
+        'vmw_buffer.c',
+        'vmw_context.c',
+        'vmw_fence.c',
+        'vmw_screen.c',
+        'vmw_screen_dri.c',
+        'vmw_screen_ioctl.c',
+        'vmw_screen_pools.c',
+        'vmw_screen_svga.c',
+        'vmw_surface.c',
+]
+
+svgadrm = env.ConvenienceLibrary(
+       target = 'svgadrm',
+       source = sources,
+)
+
+Export('svgadrm')
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_buffer.c b/src/gallium/winsys/drm/vmware/core/vmw_buffer.c
new file mode 100644 (file)
index 0000000..b812fb5
--- /dev/null
@@ -0,0 +1,274 @@
+/**********************************************************
+ * 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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+/**
+ * @file
+ * SVGA buffer manager for Guest Memory Regions (GMRs).
+ * 
+ * GMRs are used for pixel and vertex data upload/download to/from the virtual
+ * SVGA hardware. There is a limited number of GMRs available, and 
+ * creating/destroying them is also a slow operation so we must suballocate 
+ * them.
+ * 
+ * This file implements a pipebuffer library's buffer manager, so that we can
+ * use pipepbuffer's suballocation, fencing, and debugging facilities with GMRs. 
+ * 
+ * @author Jose Fonseca <jfonseca@vmware.com>
+ */
+
+
+#include "svga_cmd.h"
+
+#include "pipe/p_inlines.h"
+#include "util/u_memory.h"
+#include "pipebuffer/pb_buffer.h"
+#include "pipebuffer/pb_bufmgr.h"
+
+#include "svga_winsys.h"
+
+#include "vmw_screen.h"
+#include "vmw_buffer.h"
+
+
+struct vmw_gmr_bufmgr;
+
+
+struct vmw_gmr_buffer
+{
+   struct pb_buffer base;
+   
+   struct vmw_gmr_bufmgr *mgr;
+   
+   struct vmw_region *region;
+   void *map;
+   
+#ifdef DEBUG
+   struct pipe_fence_handle *last_fence;
+#endif
+};
+
+
+extern const struct pb_vtbl vmw_gmr_buffer_vtbl;
+
+
+static INLINE struct vmw_gmr_buffer *
+vmw_gmr_buffer(struct pb_buffer *buf)
+{
+   assert(buf);
+   assert(buf->vtbl == &vmw_gmr_buffer_vtbl);
+   return (struct vmw_gmr_buffer *)buf;
+}
+
+
+struct vmw_gmr_bufmgr
+{
+   struct pb_manager base;
+   
+   struct vmw_winsys_screen *vws;
+};
+
+
+static INLINE struct vmw_gmr_bufmgr *
+vmw_gmr_bufmgr(struct pb_manager *mgr)
+{
+   assert(mgr);
+   return (struct vmw_gmr_bufmgr *)mgr;
+}
+
+
+static void
+vmw_gmr_buffer_destroy(struct pb_buffer *_buf)
+{
+   struct vmw_gmr_buffer *buf = vmw_gmr_buffer(_buf);
+
+#ifdef DEBUG
+   if(buf->last_fence) {
+      struct svga_winsys_screen *sws = &buf->mgr->vws->base;
+      assert(sws->fence_signalled(sws, buf->last_fence, 0) == 0);
+   }
+#endif
+
+   vmw_ioctl_region_unmap(buf->region);
+   
+   vmw_ioctl_region_destroy(buf->region);
+
+   FREE(buf);
+}
+
+
+static void *
+vmw_gmr_buffer_map(struct pb_buffer *_buf,
+               unsigned flags)
+{
+   struct vmw_gmr_buffer *buf = vmw_gmr_buffer(_buf);
+   return buf->map;
+}
+
+
+static void
+vmw_gmr_buffer_unmap(struct pb_buffer *_buf)
+{
+   /* Do nothing */
+   (void)_buf;
+}
+
+
+static void
+vmw_gmr_buffer_get_base_buffer(struct pb_buffer *buf,
+                           struct pb_buffer **base_buf,
+                           unsigned *offset)
+{
+   *base_buf = buf;
+   *offset = 0;
+}
+
+
+static enum pipe_error
+vmw_gmr_buffer_validate( struct pb_buffer *_buf, 
+                         struct pb_validate *vl,
+                         unsigned flags )
+{
+   /* Always pinned */
+   return PIPE_OK;
+}
+
+
+static void
+vmw_gmr_buffer_fence( struct pb_buffer *_buf, 
+                      struct pipe_fence_handle *fence )
+{
+   /* We don't need to do anything, as the pipebuffer library
+    * will take care of delaying the destruction of fenced buffers */  
+#ifdef DEBUG
+   struct vmw_gmr_buffer *buf = vmw_gmr_buffer(_buf);
+   if(fence)
+      buf->last_fence = fence;
+#endif
+}
+
+
+const struct pb_vtbl vmw_gmr_buffer_vtbl = {
+   vmw_gmr_buffer_destroy,
+   vmw_gmr_buffer_map,
+   vmw_gmr_buffer_unmap,
+   vmw_gmr_buffer_validate,
+   vmw_gmr_buffer_fence,
+   vmw_gmr_buffer_get_base_buffer
+};
+
+
+static struct pb_buffer *
+vmw_gmr_bufmgr_create_buffer(struct pb_manager *_mgr,
+                         pb_size size,
+                         const struct pb_desc *desc) 
+{
+   struct vmw_gmr_bufmgr *mgr = vmw_gmr_bufmgr(_mgr);
+   struct vmw_winsys_screen *vws = mgr->vws;
+   struct vmw_gmr_buffer *buf;
+   
+   buf = CALLOC_STRUCT(vmw_gmr_buffer);
+   if(!buf)
+      goto error1;
+
+   pipe_reference_init(&buf->base.base.reference, 1);
+   buf->base.base.alignment = desc->alignment;
+   buf->base.base.usage = desc->usage;
+   buf->base.base.size = size;
+   buf->base.vtbl = &vmw_gmr_buffer_vtbl;
+   buf->mgr = mgr;
+
+   buf->region = vmw_ioctl_region_create(vws, size);
+   if(!buf->region)
+      goto error2;
+        
+   buf->map = vmw_ioctl_region_map(buf->region);
+   if(!buf->map)
+      goto error3;
+
+   return &buf->base;
+
+error3:
+   vmw_ioctl_region_destroy(buf->region);
+error2:
+   FREE(buf);
+error1:
+   return NULL;
+}
+
+
+static void
+vmw_gmr_bufmgr_flush(struct pb_manager *mgr) 
+{
+   /* No-op */
+}
+
+
+static void
+vmw_gmr_bufmgr_destroy(struct pb_manager *_mgr) 
+{
+   struct vmw_gmr_bufmgr *mgr = vmw_gmr_bufmgr(_mgr);
+   FREE(mgr);
+}
+
+
+struct pb_manager *
+vmw_gmr_bufmgr_create(struct vmw_winsys_screen *vws) 
+{
+   struct vmw_gmr_bufmgr *mgr;
+   
+   mgr = CALLOC_STRUCT(vmw_gmr_bufmgr);
+   if(!mgr)
+      return NULL;
+
+   mgr->base.destroy = vmw_gmr_bufmgr_destroy;
+   mgr->base.create_buffer = vmw_gmr_bufmgr_create_buffer;
+   mgr->base.flush = vmw_gmr_bufmgr_flush;
+   
+   mgr->vws = vws;
+   
+   return &mgr->base;
+}
+
+
+boolean
+vmw_gmr_bufmgr_region_ptr(struct pb_buffer *buf, 
+                          struct SVGAGuestPtr *ptr)
+{
+   struct pb_buffer *base_buf;
+   unsigned offset = 0;
+   struct vmw_gmr_buffer *gmr_buf;
+   
+   pb_get_base_buffer( buf, &base_buf, &offset );
+   
+   gmr_buf = vmw_gmr_buffer(base_buf);
+   if(!gmr_buf)
+      return FALSE;
+   
+   *ptr = vmw_ioctl_region_ptr(gmr_buf->region);
+   
+   ptr->offset += offset;
+   
+   return TRUE;
+}
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_buffer.h b/src/gallium/winsys/drm/vmware/core/vmw_buffer.h
new file mode 100644 (file)
index 0000000..634bdca
--- /dev/null
@@ -0,0 +1,65 @@
+/**********************************************************
+ * 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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+
+#ifndef VMW_BUFFER_H_
+#define VMW_BUFFER_H_
+
+
+#include "pipe/p_compiler.h"
+
+struct SVGAGuestPtr;
+struct pb_buffer;
+struct pb_manager;
+struct svga_winsys_buffer;
+struct svga_winsys_surface;
+struct vmw_winsys_screen;
+
+
+static INLINE struct pb_buffer *
+vmw_pb_buffer(struct svga_winsys_buffer *buffer)
+{
+   assert(buffer);
+   return (struct pb_buffer *)buffer;
+}
+
+
+static INLINE struct svga_winsys_buffer *
+vmw_svga_winsys_buffer(struct pb_buffer *buffer)
+{
+   assert(buffer);
+   return (struct svga_winsys_buffer *)buffer;
+}
+
+
+struct pb_manager *
+vmw_gmr_bufmgr_create(struct vmw_winsys_screen *vws);
+
+boolean
+vmw_gmr_bufmgr_region_ptr(struct pb_buffer *buf, 
+                          struct SVGAGuestPtr *ptr);
+
+
+#endif /* VMW_BUFFER_H_ */
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_context.c b/src/gallium/winsys/drm/vmware/core/vmw_context.c
new file mode 100644 (file)
index 0000000..b699758
--- /dev/null
@@ -0,0 +1,297 @@
+/**********************************************************
+ * 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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+
+#include "svga_cmd.h"
+
+#include "util/u_debug.h"
+#include "util/u_memory.h"
+#include "util/u_debug_stack.h"
+#include "pipebuffer/pb_buffer.h"
+#include "pipebuffer/pb_validate.h"
+
+#include "svga_winsys.h"
+#include "vmw_context.h"
+#include "vmw_screen.h"
+#include "vmw_buffer.h"
+#include "vmw_surface.h"
+#include "vmw_fence.h"
+
+#define VMW_COMMAND_SIZE (64*1024)
+#define VMW_SURFACE_RELOCS (1024)
+
+#define VMW_MUST_FLUSH_STACK 8
+
+struct vmw_svga_winsys_context
+{
+   struct svga_winsys_context base;
+
+   struct vmw_winsys_screen *vws;
+
+#ifdef DEBUG
+   boolean must_flush;
+   struct debug_stack_frame must_flush_stack[VMW_MUST_FLUSH_STACK];
+#endif
+
+   struct {
+      uint8_t buffer[VMW_COMMAND_SIZE];
+      uint32_t size;
+      uint32_t used;
+      uint32_t reserved;
+   } command;
+
+   struct {
+      struct vmw_svga_winsys_surface *handles[VMW_SURFACE_RELOCS];
+      uint32_t size;
+      uint32_t used;
+      uint32_t staged;
+      uint32_t reserved;
+   } surface;
+
+   struct pb_validate *validate;
+
+   uint32_t last_fence;
+};
+
+
+static INLINE struct vmw_svga_winsys_context *
+vmw_svga_winsys_context(struct svga_winsys_context *swc)
+{
+   assert(swc);
+   return (struct vmw_svga_winsys_context *)swc;
+}
+
+
+static enum pipe_error
+vmw_swc_flush(struct svga_winsys_context *swc,
+              struct pipe_fence_handle **pfence)
+{
+   struct vmw_svga_winsys_context *vswc = vmw_svga_winsys_context(swc);
+   struct pipe_fence_handle *fence = NULL;
+   unsigned i;
+   enum pipe_error ret;
+
+   ret = pb_validate_validate(vswc->validate);
+   assert(ret == PIPE_OK);
+   if(ret == PIPE_OK) {
+
+      if (vswc->command.used)
+         vmw_ioctl_command(vswc->vws,
+                           vswc->command.buffer,
+                           vswc->command.used,
+                           &vswc->last_fence);
+
+      fence = vmw_pipe_fence(vswc->last_fence);
+
+      pb_validate_fence(vswc->validate, fence);
+   }
+
+   vswc->command.used = 0;
+   vswc->command.reserved = 0;
+
+   for(i = 0; i < vswc->surface.used + vswc->surface.staged; ++i) {
+      struct vmw_svga_winsys_surface *vsurf =
+        vswc->surface.handles[i];
+      p_atomic_dec(&vsurf->validated);
+      vmw_svga_winsys_surface_reference(&vswc->surface.handles[i], NULL);
+   }
+
+   vswc->surface.used = 0;
+   vswc->surface.reserved = 0;
+
+#ifdef DEBUG
+   vswc->must_flush = FALSE;
+#endif
+
+   if(pfence)
+      *pfence = fence;
+
+   return ret;
+}
+
+
+static void *
+vmw_swc_reserve(struct svga_winsys_context *swc,
+                uint32_t nr_bytes, uint32_t nr_relocs )
+{
+   struct vmw_svga_winsys_context *vswc = vmw_svga_winsys_context(swc);
+
+#ifdef DEBUG
+   /* Check if somebody forgot to check the previous failure */
+   if(vswc->must_flush) {
+      debug_printf("Forgot to flush:\n");
+      debug_backtrace_dump(vswc->must_flush_stack, VMW_MUST_FLUSH_STACK);
+      assert(!vswc->must_flush);
+   }
+#endif
+
+   assert(nr_bytes <= vswc->command.size);
+   if(nr_bytes > vswc->command.size)
+      return NULL;
+
+   if(vswc->command.used + nr_bytes > vswc->command.size ||
+      vswc->surface.used + nr_relocs > vswc->surface.size) {
+#ifdef DEBUG
+      vswc->must_flush = TRUE;
+      debug_backtrace_capture(vswc->must_flush_stack, 1,
+                              VMW_MUST_FLUSH_STACK);
+#endif
+      return NULL;
+   }
+
+   assert(vswc->command.used + nr_bytes <= vswc->command.size);
+   assert(vswc->surface.used + nr_relocs <= vswc->surface.size);
+
+   vswc->command.reserved = nr_bytes;
+   vswc->surface.reserved = nr_relocs;
+   vswc->surface.staged = 0;
+
+   return vswc->command.buffer + vswc->command.used;
+}
+
+
+static void
+vmw_swc_surface_relocation(struct svga_winsys_context *swc,
+                           uint32 *where,
+                           struct svga_winsys_surface *surface,
+                           unsigned flags)
+{
+   struct vmw_svga_winsys_context *vswc = vmw_svga_winsys_context(swc);
+   struct vmw_svga_winsys_surface *vsurf;
+
+   if(!surface) {
+      *where = SVGA3D_INVALID_ID;
+      return;
+   }
+
+   assert(vswc->surface.staged < vswc->surface.reserved);
+
+   vsurf = vmw_svga_winsys_surface(surface);
+
+   *where = vsurf->sid;
+
+   vmw_svga_winsys_surface_reference(&vswc->surface.handles[vswc->surface.used + vswc->surface.staged], vsurf);
+   p_atomic_inc(&vsurf->validated);
+   ++vswc->surface.staged;
+}
+
+
+static void
+vmw_swc_region_relocation(struct svga_winsys_context *swc,
+                          struct SVGAGuestPtr *where,
+                          struct svga_winsys_buffer *buffer,
+                          uint32 offset,
+                          unsigned flags)
+{
+   struct vmw_svga_winsys_context *vswc = vmw_svga_winsys_context(swc);
+   struct SVGAGuestPtr ptr;
+   struct pb_buffer *buf = vmw_pb_buffer(buffer);
+   enum pipe_error ret;
+
+   if(!vmw_gmr_bufmgr_region_ptr(buf, &ptr))
+      assert(0);
+
+   ptr.offset += offset;
+
+   *where = ptr;
+
+   ret = pb_validate_add_buffer(vswc->validate, buf, flags);
+   /* TODO: Update pipebuffer to reserve buffers and not fail here */
+   assert(ret == PIPE_OK);
+}
+
+
+static void
+vmw_swc_commit(struct svga_winsys_context *swc)
+{
+   struct vmw_svga_winsys_context *vswc = vmw_svga_winsys_context(swc);
+
+   assert(vswc->command.reserved);
+   assert(vswc->command.used + vswc->command.reserved <= vswc->command.size);
+   vswc->command.used += vswc->command.reserved;
+   vswc->command.reserved = 0;
+
+   assert(vswc->surface.staged <= vswc->surface.reserved);
+   assert(vswc->surface.used + vswc->surface.staged <= vswc->surface.size);
+   vswc->surface.used += vswc->surface.staged;
+   vswc->surface.staged = 0;
+   vswc->surface.reserved = 0;
+}
+
+
+static void
+vmw_swc_destroy(struct svga_winsys_context *swc)
+{
+   struct vmw_svga_winsys_context *vswc = vmw_svga_winsys_context(swc);
+   unsigned i;
+   for(i = 0; i < vswc->surface.used; ++i) {
+      p_atomic_dec(&vswc->surface.handles[i]->validated);
+      vmw_svga_winsys_surface_reference(&vswc->surface.handles[i], NULL);
+   }
+   pb_validate_destroy(vswc->validate);
+   vmw_ioctl_context_destroy(vswc->vws, swc->cid);
+   FREE(vswc);
+}
+
+
+struct svga_winsys_context *
+vmw_svga_winsys_context_create(struct svga_winsys_screen *sws)
+{
+   struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
+   struct vmw_svga_winsys_context *vswc;
+
+   vswc = CALLOC_STRUCT(vmw_svga_winsys_context);
+   if(!vswc)
+      return NULL;
+
+   vswc->base.destroy = vmw_swc_destroy;
+   vswc->base.reserve = vmw_swc_reserve;
+   vswc->base.surface_relocation = vmw_swc_surface_relocation;
+   vswc->base.region_relocation = vmw_swc_region_relocation;
+   vswc->base.commit = vmw_swc_commit;
+   vswc->base.flush = vmw_swc_flush;
+
+   vswc->base.cid = vmw_ioctl_context_create(vws);
+
+   vswc->vws = vws;
+
+   vswc->command.size = VMW_COMMAND_SIZE;
+   vswc->surface.size = VMW_SURFACE_RELOCS;
+
+   vswc->validate = pb_validate_create();
+   if(!vswc->validate) {
+      FREE(vswc);
+      return NULL;
+   }
+
+   return &vswc->base;
+}
+
+
+struct pipe_context *
+vmw_svga_context_create(struct pipe_screen *screen)
+{
+   return svga_context_create(screen);
+}
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_context.h b/src/gallium/winsys/drm/vmware/core/vmw_context.h
new file mode 100644 (file)
index 0000000..305ce9b
--- /dev/null
@@ -0,0 +1,59 @@
+/**********************************************************
+ * 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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+/**
+ * @author Jose Fonseca <jfonseca@vmware.com>
+ */
+
+
+#ifndef VMW_CONTEXT_H_
+#define VMW_CONTEXT_H_
+
+#include "pipe/p_compiler.h"
+
+struct svga_winsys_screen;
+struct svga_winsys_context;
+struct pipe_context;
+struct pipe_screen;
+
+#define VMW_DEBUG 0
+
+#if VMW_DEBUG
+#define vmw_printf debug_printf
+#define VMW_FUNC  debug_printf("%s\n", __FUNCTION__)
+#else
+#define VMW_FUNC
+#define vmw_printf(...)
+#endif
+
+
+struct svga_winsys_context *
+vmw_svga_winsys_context_create(struct svga_winsys_screen *sws);
+
+struct pipe_context *
+vmw_svga_context_create(struct pipe_screen *screen);
+
+
+#endif /* VMW_CONTEXT_H_ */
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_fence.c b/src/gallium/winsys/drm/vmware/core/vmw_fence.c
new file mode 100644 (file)
index 0000000..873dd51
--- /dev/null
@@ -0,0 +1,108 @@
+/**********************************************************
+ * 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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+
+#include "util/u_memory.h"
+#include "pipebuffer/pb_buffer_fenced.h"
+
+#include "vmw_screen.h"
+#include "vmw_fence.h"
+
+
+
+struct vmw_fence_ops 
+{
+   struct pb_fence_ops base;
+
+   struct vmw_winsys_screen *vws;
+};
+
+
+static INLINE struct vmw_fence_ops *
+vmw_fence_ops(struct pb_fence_ops *ops)
+{
+   assert(ops);
+   return (struct vmw_fence_ops *)ops;
+}
+
+
+static void
+vmw_fence_ops_fence_reference(struct pb_fence_ops *ops,
+                              struct pipe_fence_handle **ptr,
+                              struct pipe_fence_handle *fence)
+{
+   *ptr = fence;
+}
+
+
+static int
+vmw_fence_ops_fence_signalled(struct pb_fence_ops *ops,
+                              struct pipe_fence_handle *fence,
+                              unsigned flag)
+{
+   struct vmw_winsys_screen *vws = vmw_fence_ops(ops)->vws;
+   (void)flag;
+   return vmw_ioctl_fence_signalled(vws, vmw_fence(fence));
+}
+
+
+static int
+vmw_fence_ops_fence_finish(struct pb_fence_ops *ops,
+                           struct pipe_fence_handle *fence,
+                           unsigned flag)
+{
+   struct vmw_winsys_screen *vws = vmw_fence_ops(ops)->vws;
+   (void)flag;
+   return vmw_ioctl_fence_finish(vws, vmw_fence(fence));
+}
+
+
+static void
+vmw_fence_ops_destroy(struct pb_fence_ops *ops)
+{
+   FREE(ops);
+}
+
+
+struct pb_fence_ops *
+vmw_fence_ops_create(struct vmw_winsys_screen *vws) 
+{
+   struct vmw_fence_ops *ops;
+
+   ops = CALLOC_STRUCT(vmw_fence_ops);
+   if(!ops)
+      return NULL;
+
+   ops->base.destroy = &vmw_fence_ops_destroy;
+   ops->base.fence_reference = &vmw_fence_ops_fence_reference;
+   ops->base.fence_signalled = &vmw_fence_ops_fence_signalled;
+   ops->base.fence_finish = &vmw_fence_ops_fence_finish;
+
+   ops->vws = vws;
+
+   return &ops->base;
+}
+
+
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_fence.h b/src/gallium/winsys/drm/vmware/core/vmw_fence.h
new file mode 100644 (file)
index 0000000..5357b4f
--- /dev/null
@@ -0,0 +1,59 @@
+/**********************************************************
+ * 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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+
+#ifndef VMW_FENCE_H_
+#define VMW_FENCE_H_
+
+
+#include "pipe/p_compiler.h"
+
+
+struct pipe_fence_handle;
+struct pb_fence_ops;
+struct vmw_winsys_screen;
+
+
+/** Cast from a pipe_fence_handle pointer into a SVGA fence */
+static INLINE uint32_t
+vmw_fence( struct pipe_fence_handle *fence )
+{
+   return (uint32_t)(uintptr_t)fence;
+}
+
+
+/** Cast from a SVGA fence number to pipe_fence_handle pointer */
+static INLINE struct pipe_fence_handle *
+vmw_pipe_fence( uint32_t fence )
+{
+   return (struct pipe_fence_handle *)(uintptr_t)fence;
+}
+
+
+struct pb_fence_ops *
+vmw_fence_ops_create(struct vmw_winsys_screen *vws); 
+
+
+#endif /* VMW_FENCE_H_ */
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen.c b/src/gallium/winsys/drm/vmware/core/vmw_screen.c
new file mode 100644 (file)
index 0000000..911eec5
--- /dev/null
@@ -0,0 +1,74 @@
+/**********************************************************
+ * 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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+
+#include "vmw_screen.h"
+
+#include "vmw_context.h"
+
+#include "util/u_memory.h"
+#include "pipe/p_compiler.h"
+
+
+/* Called from vmw_drm_create_screen(), creates and initializes the
+ * vmw_winsys_screen structure, which is the main entity in this
+ * module.
+ */
+struct vmw_winsys_screen *
+vmw_winsys_create( int fd )
+{
+   struct vmw_winsys_screen *vws = CALLOC_STRUCT(vmw_winsys_screen);
+   if (!vws)
+      goto out_no_vws;
+
+   vws->ioctl.drm_fd = fd;
+
+   if (!vmw_ioctl_init(vws))
+      goto out_no_ioctl;
+
+   if(!vmw_pools_init(vws))
+      goto out_no_pools;
+
+   if (!vmw_winsys_screen_init_svga(vws))
+      goto out_no_svga;
+
+   return vws;
+out_no_svga:
+   vmw_pools_cleanup(vws);
+out_no_pools:
+   vmw_ioctl_cleanup(vws);
+out_no_ioctl:
+   FREE(vws);
+out_no_vws:
+   return NULL;
+}
+
+void
+vmw_winsys_destroy(struct vmw_winsys_screen *vws)
+{
+   vmw_pools_cleanup(vws);
+   vmw_ioctl_cleanup(vws);
+   FREE(vws);
+}
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen.h b/src/gallium/winsys/drm/vmware/core/vmw_screen.h
new file mode 100644 (file)
index 0000000..a875107
--- /dev/null
@@ -0,0 +1,134 @@
+/**********************************************************
+ * 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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+/**
+ * @file
+ * Common definitions for the VMware SVGA winsys.
+ *
+ * @author Jose Fonseca <jfonseca@vmware.com>
+ */
+
+
+#ifndef VMW_SCREEN_H_
+#define VMW_SCREEN_H_
+
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_state.h"
+
+#include "svga_winsys.h"
+
+struct pb_manager;
+struct vmw_region;
+
+
+struct vmw_winsys_screen
+{
+   struct svga_winsys_screen base;
+
+   struct {
+      volatile uint32_t *fifo_map;
+      uint64_t last_fence;
+      int drm_fd;
+   } ioctl;
+
+   struct {
+      struct pb_manager *gmr;
+      struct pb_manager *gmr_mm;
+      struct pb_manager *gmr_fenced;
+   } pools;
+};
+
+
+static INLINE struct vmw_winsys_screen *
+vmw_winsys_screen(struct svga_winsys_screen *base)
+{
+   return (struct vmw_winsys_screen *)base;
+}
+
+/*  */
+uint32
+vmw_ioctl_context_create(struct vmw_winsys_screen *vws);
+
+void
+vmw_ioctl_context_destroy(struct vmw_winsys_screen *vws,
+                          uint32 cid);
+
+uint32
+vmw_ioctl_surface_create(struct vmw_winsys_screen *vws,
+                              SVGA3dSurfaceFlags flags,
+                              SVGA3dSurfaceFormat format,
+                              SVGA3dSize size,
+                              uint32 numFaces,
+                              uint32 numMipLevels);
+
+void
+vmw_ioctl_surface_destroy(struct vmw_winsys_screen *vws,
+                          uint32 sid);
+
+void
+vmw_ioctl_command(struct vmw_winsys_screen *vws,
+                       void *commands,
+                       uint32_t size,
+                       uint32_t *fence);
+
+struct vmw_region *
+vmw_ioctl_region_create(struct vmw_winsys_screen *vws, uint32_t size);
+
+void
+vmw_ioctl_region_destroy(struct vmw_region *region);
+
+struct SVGAGuestPtr
+vmw_ioctl_region_ptr(struct vmw_region *region);
+
+void *
+vmw_ioctl_region_map(struct vmw_region *region);
+void
+vmw_ioctl_region_unmap(struct vmw_region *region);
+
+
+int
+vmw_ioctl_fence_finish(struct vmw_winsys_screen *vws,
+                       uint32_t fence);
+
+int
+vmw_ioctl_fence_signalled(struct vmw_winsys_screen *vws,
+                          uint32_t fence);
+
+
+/* Initialize parts of vmw_winsys_screen at startup:
+ */
+boolean vmw_ioctl_init(struct vmw_winsys_screen *vws);
+boolean vmw_pools_init(struct vmw_winsys_screen *vws);
+boolean vmw_winsys_screen_init_svga(struct vmw_winsys_screen *vws);
+
+void vmw_ioctl_cleanup(struct vmw_winsys_screen *vws);
+void vmw_pools_cleanup(struct vmw_winsys_screen *vws);
+
+struct vmw_winsys_screen *vmw_winsys_create(int fd);
+void vmw_winsys_destroy(struct vmw_winsys_screen *sws);
+
+
+#endif /* VMW_SCREEN_H_ */
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c b/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c
new file mode 100644 (file)
index 0000000..5995eee
--- /dev/null
@@ -0,0 +1,371 @@
+/**********************************************************
+ * 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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_inlines.h"
+#include "util/u_memory.h"
+#include "vmw_screen.h"
+
+#include "trace/tr_drm.h"
+
+#include "vmw_screen.h"
+#include "vmw_surface.h"
+#include "vmw_fence.h"
+#include "vmw_context.h"
+
+#include <state_tracker/dri1_api.h>
+#include <state_tracker/drm_api.h>
+#include <vmwgfx_drm.h>
+#include <xf86drm.h>
+
+#include <stdio.h>
+
+static struct dri1_api dri1_api_hooks;
+static struct dri1_api_version ddx_required = { 0, 1, 0 };
+static struct dri1_api_version ddx_compat = { 0, 0, 0 };
+static struct dri1_api_version dri_required = { 4, 0, 0 };
+static struct dri1_api_version dri_compat = { 4, 0, 0 };
+static struct dri1_api_version drm_required = { 0, 1, 0 };
+static struct dri1_api_version drm_compat = { 0, 0, 0 };
+
+static boolean
+vmw_dri1_check_version(const struct dri1_api_version *cur,
+                      const struct dri1_api_version *required,
+                      const struct dri1_api_version *compat,
+                      const char component[])
+{
+   if (cur->major > required->major && cur->major <= compat->major)
+      return TRUE;
+   if (cur->major == required->major && cur->minor >= required->minor)
+      return TRUE;
+
+   fprintf(stderr, "%s version failure.\n", component);
+   fprintf(stderr, "%s version is %d.%d.%d and this driver can only work\n"
+          "with versions %d.%d.x through %d.x.x.\n",
+          component,
+          cur->major,
+          cur->minor,
+          cur->patch_level, required->major, required->minor, compat->major);
+   return FALSE;
+}
+
+/* This is actually the entrypoint to the entire driver, called by the
+ * libGL (or EGL, or ...) code via the drm_api_hooks table at the
+ * bottom of the file.
+ */
+static struct pipe_screen *
+vmw_drm_create_screen(struct drm_api *drm_api,
+                      int fd,
+                      struct drm_create_screen_arg *arg)
+{
+   struct vmw_winsys_screen *vws;
+   struct pipe_screen *screen;
+   struct dri1_create_screen_arg *dri1;
+
+   if (arg != NULL) {
+      switch (arg->mode) {
+      case DRM_CREATE_NORMAL:
+        break;
+      case DRM_CREATE_DRI1:
+        dri1 = (struct dri1_create_screen_arg *)arg;
+        if (!vmw_dri1_check_version(&dri1->ddx_version, &ddx_required,
+                                    &ddx_compat, "ddx - driver api"))
+           return NULL;
+        if (!vmw_dri1_check_version(&dri1->dri_version, &dri_required,
+                                    &dri_compat, "dri info"))
+           return NULL;
+        if (!vmw_dri1_check_version(&dri1->drm_version, &drm_required,
+                                    &drm_compat, "vmwgfx drm driver"))
+           return NULL;
+        dri1->api = &dri1_api_hooks;
+        break;
+      default:
+        return NULL;
+      }
+   }
+
+   vws = vmw_winsys_create( fd );
+   if (!vws)
+      goto out_no_vws;
+
+   screen = svga_screen_create( &vws->base );
+   if (!screen)
+      goto out_no_screen;
+
+   return screen;
+
+   /* Failure cases:
+    */
+out_no_screen:
+   vmw_winsys_destroy( vws );
+
+out_no_vws:
+   return NULL;
+}
+
+static INLINE boolean
+vmw_dri1_intersect_src_bbox(struct drm_clip_rect *dst,
+                           int dst_x,
+                           int dst_y,
+                           const struct drm_clip_rect *src,
+                           const struct drm_clip_rect *bbox)
+{
+   int xy1;
+   int xy2;
+
+   xy1 = ((int)src->x1 > (int)bbox->x1 + dst_x) ? src->x1 :
+      (int)bbox->x1 + dst_x;
+   xy2 = ((int)src->x2 < (int)bbox->x2 + dst_x) ? src->x2 :
+      (int)bbox->x2 + dst_x;
+   if (xy1 >= xy2 || xy1 < 0)
+      return FALSE;
+
+   dst->x1 = xy1;
+   dst->x2 = xy2;
+
+   xy1 = ((int)src->y1 > (int)bbox->y1 + dst_y) ? src->y1 :
+      (int)bbox->y1 + dst_y;
+   xy2 = ((int)src->y2 < (int)bbox->y2 + dst_y) ? src->y2 :
+      (int)bbox->y2 + dst_y;
+   if (xy1 >= xy2 || xy1 < 0)
+      return FALSE;
+
+   dst->y1 = xy1;
+   dst->y2 = xy2;
+   return TRUE;
+}
+
+/**
+ * No fancy get-surface-from-sarea stuff here.
+ * Just use the present blit.
+ */
+
+static void
+vmw_dri1_present_locked(struct pipe_context *locked_pipe,
+                       struct pipe_surface *surf,
+                       const struct drm_clip_rect *rect,
+                       unsigned int num_clip,
+                       int x_draw, int y_draw,
+                       const struct drm_clip_rect *bbox,
+                       struct pipe_fence_handle **p_fence)
+{
+   struct svga_winsys_surface *srf =
+      svga_screen_texture_get_winsys_surface(surf->texture);
+   struct vmw_svga_winsys_surface *vsrf = vmw_svga_winsys_surface(srf);
+   struct vmw_winsys_screen *vws =
+      vmw_winsys_screen(svga_winsys_screen(locked_pipe->screen));
+   struct drm_clip_rect clip;
+   int i;
+   struct
+   {
+      SVGA3dCmdHeader header;
+      SVGA3dCmdPresent body;
+      SVGA3dCopyRect rect;
+   } cmd;
+   boolean visible = FALSE;
+   uint32_t fence_seq = 0;
+
+   VMW_FUNC;
+   cmd.header.id = SVGA_3D_CMD_PRESENT;
+   cmd.header.size = sizeof cmd.body + sizeof cmd.rect;
+   cmd.body.sid = vsrf->sid;
+
+   for (i = 0; i < num_clip; ++i) {
+      if (!vmw_dri1_intersect_src_bbox(&clip, x_draw, y_draw, rect++, bbox))
+        continue;
+
+      cmd.rect.x = clip.x1;
+      cmd.rect.y = clip.y1;
+      cmd.rect.w = clip.x2 - clip.x1;
+      cmd.rect.h = clip.y2 - clip.y1;
+      cmd.rect.srcx = (int)clip.x1 - x_draw;
+      cmd.rect.srcy = (int)clip.y1 - y_draw;
+
+      vmw_printf("%s: Clip %d x %d y %d w %d h %d srcx %d srcy %d\n",
+                  __FUNCTION__,
+                  i,
+                  cmd.rect.x,
+                  cmd.rect.y,
+                  cmd.rect.w, cmd.rect.h, cmd.rect.srcx, cmd.rect.srcy);
+
+      vmw_ioctl_command(vws, &cmd, sizeof cmd.header + cmd.header.size,
+                        &fence_seq);
+      visible = TRUE;
+   }
+
+   *p_fence = (visible) ? vmw_pipe_fence(fence_seq) : NULL;
+   vmw_svga_winsys_surface_reference(&vsrf, NULL);
+}
+
+/**
+ * FIXME: We'd probably want to cache these buffers in the
+ * screen, based on handle.
+ */
+
+static struct pipe_buffer *
+vmw_drm_buffer_from_handle(struct drm_api *drm_api,
+                           struct pipe_screen *screen,
+                          const char *name,
+                          unsigned handle)
+{
+    struct vmw_svga_winsys_surface *vsrf;
+    struct svga_winsys_surface *ssrf;
+    struct vmw_winsys_screen *vws =
+       vmw_winsys_screen(svga_winsys_screen(screen));
+    struct pipe_buffer *buf;
+    union drm_vmw_surface_reference_arg arg;
+    struct drm_vmw_surface_arg *req = &arg.req;
+    struct drm_vmw_surface_create_req *rep = &arg.rep;
+    int ret;
+    int i;
+
+    /**
+     * The vmware device specific handle is the hardware SID.
+     * FIXME: We probably want to move this to the ioctl implementations.
+     */
+
+    memset(&arg, 0, sizeof(arg));
+    req->sid = handle;
+
+    ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_REF_SURFACE,
+                             &arg, sizeof(arg));
+
+    if (ret) {
+       fprintf(stderr, "Failed referencing shared surface. SID %d.\n"
+               "Error %d (%s).\n",
+               handle, ret, strerror(-ret));
+       return NULL;
+    }
+
+    if (rep->mip_levels[0] != 1) {
+       fprintf(stderr, "Incorrect number of mipmap levels on shared surface."
+               " SID %d, levels %d\n",
+               handle, rep->mip_levels[0]);
+       goto out_mip;
+    }
+
+    for (i=1; i < DRM_VMW_MAX_SURFACE_FACES; ++i) {
+       if (rep->mip_levels[i] != 0) {
+           fprintf(stderr, "Incorrect number of faces levels on shared surface."
+                   " SID %d, face %d present.\n",
+                   handle, i);
+           goto out_mip;
+       }
+    }
+
+    vsrf = CALLOC_STRUCT(vmw_svga_winsys_surface);
+    if (!vsrf)
+       goto out_mip;
+
+    pipe_reference_init(&vsrf->refcnt, 1);
+    p_atomic_set(&vsrf->validated, 0);
+    vsrf->sid = handle;
+    ssrf = svga_winsys_surface(vsrf);
+    buf = svga_screen_buffer_wrap_surface(screen, rep->format, ssrf);
+    if (!buf)
+       vmw_svga_winsys_surface_reference(&vsrf, NULL);
+
+    return buf;
+  out_mip:
+    vmw_ioctl_surface_destroy(vws, handle);
+    return NULL;
+}
+
+static struct pipe_texture *
+vmw_drm_texture_from_handle(struct drm_api *drm_api,
+                           struct pipe_screen *screen,
+                           struct pipe_texture *templat,
+                           const char *name,
+                           unsigned stride,
+                           unsigned handle)
+{
+    struct pipe_buffer *buffer;
+    buffer = vmw_drm_buffer_from_handle(drm_api, screen, name, handle);
+
+    if (!buffer)
+       return NULL;
+
+    return screen->texture_blanket(screen, templat, &stride, buffer);
+}
+
+static boolean
+vmw_drm_handle_from_buffer(struct drm_api *drm_api,
+                           struct pipe_screen *screen,
+                          struct pipe_buffer *buffer,
+                          unsigned *handle)
+{
+    struct svga_winsys_surface *surface =
+       svga_screen_buffer_get_winsys_surface(buffer);
+    struct vmw_svga_winsys_surface *vsrf;
+
+    if (!surface)
+       return FALSE;
+
+    vsrf = vmw_svga_winsys_surface(surface);
+    *handle = vsrf->sid;
+    vmw_svga_winsys_surface_reference(&vsrf, NULL);
+    return TRUE;
+}
+
+static boolean
+vmw_drm_handle_from_texture(struct drm_api *drm_api,
+                           struct pipe_screen *screen,
+                           struct pipe_texture *texture,
+                           unsigned *stride,
+                           unsigned *handle)
+{
+    struct pipe_buffer *buffer;
+
+    if (!svga_screen_buffer_from_texture(texture, &buffer, stride))
+       return FALSE;
+
+    return vmw_drm_handle_from_buffer(drm_api, screen, buffer, handle);
+}
+
+static struct pipe_context*
+vmw_drm_create_context(struct drm_api *drm_api,
+                       struct pipe_screen *screen)
+{
+   return vmw_svga_context_create(screen);
+}
+
+static struct dri1_api dri1_api_hooks = {
+   .front_srf_locked = NULL,
+   .present_locked = vmw_dri1_present_locked
+};
+
+static struct drm_api vmw_drm_api_hooks = {
+   .create_screen = vmw_drm_create_screen,
+   .create_context = vmw_drm_create_context,
+   .texture_from_shared_handle = vmw_drm_texture_from_handle,
+   .shared_handle_from_texture = vmw_drm_handle_from_texture,
+   .local_handle_from_texture = vmw_drm_handle_from_texture,
+};
+
+struct drm_api* drm_api_create()
+{
+   return trace_drm_create(&vmw_drm_api_hooks);
+}
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen_ioctl.c b/src/gallium/winsys/drm/vmware/core/vmw_screen_ioctl.c
new file mode 100644 (file)
index 0000000..ccd0b41
--- /dev/null
@@ -0,0 +1,513 @@
+/**********************************************************
+ * 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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+/**
+ * @file
+ *
+ * Wrappers for DRM ioctl functionlaity used by the rest of the vmw
+ * drm winsys.
+ *
+ * Based on svgaicd_escape.c
+ */
+
+
+#include "svga_cmd.h"
+#include "util/u_memory.h"
+#include "util/u_math.h"
+#include "svgadump/svga_dump.h"
+#include "vmw_screen.h"
+#include "vmw_context.h"
+#include "xf86drm.h"
+#include "vmwgfx_drm.h"
+
+#include <sys/mman.h>
+#include <errno.h>
+#include <unistd.h>
+
+struct vmw_region
+{
+   SVGAGuestPtr ptr;
+   uint32_t handle;
+   uint64_t map_handle;
+   void *data;
+   uint32_t map_count;
+   int drm_fd;
+   uint32_t size;
+};
+
+static void
+vmw_check_last_cmd(struct vmw_winsys_screen *vws)
+{
+   static uint32_t buffer[16384];
+   struct drm_vmw_fifo_debug_arg arg;
+   int ret;
+
+   return;
+   memset(&arg, 0, sizeof(arg));
+   arg.debug_buffer = (unsigned long)buffer;
+   arg.debug_buffer_size = 65536;
+
+   ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_FIFO_DEBUG,
+                            &arg, sizeof(arg));
+
+   if (ret) {
+      debug_printf("%s Ioctl error: \"%s\".\n", __FUNCTION__, strerror(-ret));
+      return;
+   }
+
+   if (arg.did_not_fit) {
+      debug_printf("%s Command did not fit completely.\n", __FUNCTION__);
+   }
+
+   svga_dump_commands(buffer, arg.used_size);
+}
+
+static void
+vmw_ioctl_fifo_unmap(struct vmw_winsys_screen *vws, void *mapping)
+{
+   VMW_FUNC;
+   (void)munmap(mapping, getpagesize());
+}
+
+
+static void *
+vmw_ioctl_fifo_map(struct vmw_winsys_screen *vws,
+                   uint32_t fifo_offset )
+{
+   void *map;
+
+   VMW_FUNC;
+
+   map = mmap(NULL, getpagesize(), PROT_READ, MAP_SHARED,
+             vws->ioctl.drm_fd, fifo_offset);
+
+   if (map == MAP_FAILED) {
+      debug_printf("Map failed %s\n", strerror(errno));
+      return NULL;
+   }
+
+   vmw_printf("Fifo (min) is 0x%08x\n", ((uint32_t *) map)[SVGA_FIFO_MIN]);
+
+   return map;
+}
+
+uint32
+vmw_ioctl_context_create(struct vmw_winsys_screen *vws)
+{
+   struct drm_vmw_context_arg c_arg;
+   int ret;
+
+   VMW_FUNC;
+
+   ret = drmCommandRead(vws->ioctl.drm_fd, DRM_VMW_CREATE_CONTEXT,
+                       &c_arg, sizeof(c_arg));
+
+   if (ret)
+      return -1;
+
+   vmw_check_last_cmd(vws);
+   vmw_printf("Context id is %d\n", c_arg.cid);
+
+   return c_arg.cid;
+}
+
+void
+vmw_ioctl_context_destroy(struct vmw_winsys_screen *vws, uint32 cid)
+{
+   struct drm_vmw_context_arg c_arg;
+
+   VMW_FUNC;
+
+   memset(&c_arg, 0, sizeof(c_arg));
+   c_arg.cid = cid;
+
+   (void)drmCommandWrite(vws->ioctl.drm_fd, DRM_VMW_UNREF_CONTEXT,
+                        &c_arg, sizeof(c_arg));
+
+   vmw_check_last_cmd(vws);
+}
+
+uint32
+vmw_ioctl_surface_create(struct vmw_winsys_screen *vws,
+                             SVGA3dSurfaceFlags flags,
+                             SVGA3dSurfaceFormat format,
+                             SVGA3dSize size,
+                             uint32_t numFaces, uint32_t numMipLevels)
+{
+   union drm_vmw_surface_create_arg s_arg;
+   struct drm_vmw_surface_create_req *req = &s_arg.req;
+   struct drm_vmw_surface_arg *rep = &s_arg.rep;
+   struct drm_vmw_size sizes[DRM_VMW_MAX_SURFACE_FACES*
+                            DRM_VMW_MAX_MIP_LEVELS];
+   struct drm_vmw_size *cur_size;
+   uint32_t iFace;
+   uint32_t iMipLevel;
+   int ret;
+
+   vmw_printf("%s flags %d format %d\n", __FUNCTION__, flags, format);
+
+   memset(&s_arg, 0, sizeof(s_arg));
+   req->flags = (uint32_t) flags;
+   req->format = (uint32_t) format;
+   req->shareable = 1;
+
+   assert(numFaces * numMipLevels < DRM_VMW_MAX_SURFACE_FACES*
+         DRM_VMW_MAX_MIP_LEVELS);
+   cur_size = sizes;
+   for (iFace = 0; iFace < numFaces; ++iFace) {
+      SVGA3dSize mipSize = size;
+
+      req->mip_levels[iFace] = numMipLevels;
+      for (iMipLevel = 0; iMipLevel < numMipLevels; ++iMipLevel) {
+        cur_size->width = mipSize.width;
+        cur_size->height = mipSize.height;
+        cur_size->depth = mipSize.depth;
+        mipSize.width = MAX2(mipSize.width >> 1, 1);
+        mipSize.height = MAX2(mipSize.height >> 1, 1);
+        mipSize.depth = MAX2(mipSize.depth >> 1, 1);
+        cur_size++;
+      }
+   }
+   for (iFace = numFaces; iFace < SVGA3D_MAX_SURFACE_FACES; ++iFace) {
+      req->mip_levels[iFace] = 0;
+   }
+
+   req->size_addr = (unsigned long)&sizes;
+
+   ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_CREATE_SURFACE,
+                            &s_arg, sizeof(s_arg));
+
+   if (ret)
+      return -1;
+
+   vmw_printf("Surface id is %d\n", rep->sid);
+   vmw_check_last_cmd(vws);
+
+   return rep->sid;
+}
+
+void
+vmw_ioctl_surface_destroy(struct vmw_winsys_screen *vws, uint32 sid)
+{
+   struct drm_vmw_surface_arg s_arg;
+
+   VMW_FUNC;
+
+   memset(&s_arg, 0, sizeof(s_arg));
+   s_arg.sid = sid;
+
+   (void)drmCommandWrite(vws->ioctl.drm_fd, DRM_VMW_UNREF_SURFACE,
+                        &s_arg, sizeof(s_arg));
+   vmw_check_last_cmd(vws);
+
+}
+
+void
+vmw_ioctl_command(struct vmw_winsys_screen *vws, void *commands, uint32_t size,
+                      uint32_t * pfence)
+{
+   struct drm_vmw_execbuf_arg arg;
+   struct drm_vmw_fence_rep rep;
+   int ret;
+
+#ifdef DEBUG
+   {
+      static boolean firsttime = TRUE;
+      static boolean debug = FALSE;
+      static boolean skip = FALSE;
+      if (firsttime) {
+         debug = debug_get_bool_option("SVGA_DUMP_CMD", FALSE);
+         skip = debug_get_bool_option("SVGA_SKIP_CMD", FALSE);
+      }
+      if (debug) {
+         VMW_FUNC;
+         svga_dump_commands(commands, size);
+      }
+      firsttime = FALSE;
+      if (skip) {
+         size = 0;
+      }
+   }
+#endif
+
+   memset(&arg, 0, sizeof(arg));
+   memset(&rep, 0, sizeof(rep));
+
+   rep.error = -EFAULT;
+   arg.fence_rep = (unsigned long)&rep;
+   arg.commands = (unsigned long)commands;
+   arg.command_size = size;
+
+   do {
+       ret = drmCommandWrite(vws->ioctl.drm_fd, DRM_VMW_EXECBUF, &arg, sizeof(arg));
+   } while(ret == -ERESTART);
+   if (ret) {
+      debug_printf("%s error %s.\n", __FUNCTION__, strerror(-ret));
+   }
+   if (rep.error) {
+
+      /*
+       * Kernel has synced and put the last fence sequence in the FIFO
+       * register.
+       */
+
+      if (rep.error == -EFAULT)
+        rep.fence_seq = vws->ioctl.fifo_map[SVGA_FIFO_FENCE];
+
+      debug_printf("%s Fence error %s.\n", __FUNCTION__,
+                  strerror(-rep.error));
+   }
+
+   vws->ioctl.last_fence = rep.fence_seq;
+
+   if (pfence)
+      *pfence = rep.fence_seq;
+   vmw_check_last_cmd(vws);
+
+}
+
+
+struct vmw_region *
+vmw_ioctl_region_create(struct vmw_winsys_screen *vws, uint32_t size)
+{
+   struct vmw_region *region;
+   union drm_vmw_alloc_dmabuf_arg arg;
+   struct drm_vmw_alloc_dmabuf_req *req = &arg.req;
+   struct drm_vmw_dmabuf_rep *rep = &arg.rep;
+   int ret;
+
+   vmw_printf("%s: size = %u\n", __FUNCTION__, size);
+
+   region = CALLOC_STRUCT(vmw_region);
+   if (!region)
+      goto out_err1;
+
+   memset(&arg, 0, sizeof(arg));
+   req->size = size;
+   do {
+      ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_ALLOC_DMABUF, &arg,
+                               sizeof(arg));
+   } while (ret == -ERESTART);
+
+   if (ret) {
+      debug_printf("IOCTL failed %d: %s\n", ret, strerror(-ret));
+      goto out_err1;
+   }
+
+   region->ptr.gmrId = rep->cur_gmr_id;
+   region->ptr.offset = rep->cur_gmr_offset;
+   region->data = NULL;
+   region->handle = rep->handle;
+   region->map_handle = rep->map_handle;
+   region->map_count = 0;
+   region->size = size;
+   region->drm_fd = vws->ioctl.drm_fd;
+
+   vmw_printf("   gmrId = %u, offset = %u\n",
+              region->ptr.gmrId, region->ptr.offset);
+
+   return region;
+
+ out_err1:
+   FREE(region);
+   return NULL;
+}
+
+void
+vmw_ioctl_region_destroy(struct vmw_region *region)
+{
+   struct drm_vmw_unref_dmabuf_arg arg;
+
+   vmw_printf("%s: gmrId = %u, offset = %u\n", __FUNCTION__,
+              region->ptr.gmrId, region->ptr.offset);
+
+   if (region->data) {
+      munmap(region->data, region->size);
+      region->data = NULL;
+   }
+
+   memset(&arg, 0, sizeof(arg));
+   arg.handle = region->handle;
+   drmCommandWrite(region->drm_fd, DRM_VMW_UNREF_DMABUF, &arg, sizeof(arg));
+
+   FREE(region);
+}
+
+SVGAGuestPtr
+vmw_ioctl_region_ptr(struct vmw_region *region)
+{
+   return region->ptr;
+}
+
+void *
+vmw_ioctl_region_map(struct vmw_region *region)
+{
+   void *map;
+
+   vmw_printf("%s: gmrId = %u, offset = %u\n", __FUNCTION__,
+              region->ptr.gmrId, region->ptr.offset);
+
+   if (region->data == NULL) {
+      map = mmap(NULL, region->size, PROT_READ | PROT_WRITE, MAP_SHARED,
+                region->drm_fd, region->map_handle);
+      if (map == MAP_FAILED) {
+        debug_printf("%s: Map failed.\n", __FUNCTION__);
+        return NULL;
+      }
+
+      region->data = map;
+   }
+
+   ++region->map_count;
+
+   return region->data;
+}
+
+void
+vmw_ioctl_region_unmap(struct vmw_region *region)
+{
+   vmw_printf("%s: gmrId = %u, offset = %u\n", __FUNCTION__,
+              region->ptr.gmrId, region->ptr.offset);
+   --region->map_count;
+}
+
+
+int
+vmw_ioctl_fence_signalled(struct vmw_winsys_screen *vws,
+                          uint32_t fence)
+{
+   uint32_t expected;
+   uint32_t current;
+   
+   assert(fence);
+   if(!fence)
+      return 0;
+   
+   expected = fence;
+   current = vws->ioctl.fifo_map[SVGA_FIFO_FENCE];
+   
+   if ((int32)(current - expected) >= 0)
+      return 0; /* fence passed */
+   else
+      return -1;
+}
+
+
+static void
+vmw_ioctl_sync(struct vmw_winsys_screen *vws, 
+                   uint32_t fence)
+{
+   uint32_t cur_fence;
+   struct drm_vmw_fence_wait_arg arg;
+   int ret;
+
+   vmw_printf("%s: fence = %lu\n", __FUNCTION__,
+              (unsigned long)fence);
+
+   cur_fence = vws->ioctl.fifo_map[SVGA_FIFO_FENCE];
+   vmw_printf("%s: Fence id read is 0x%08x\n", __FUNCTION__,
+              (unsigned int)cur_fence);
+
+   if ((cur_fence - fence) < (1 << 24))
+      return;
+
+   memset(&arg, 0, sizeof(arg));
+   arg.sequence = fence;
+
+   do {
+       ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_FENCE_WAIT, &arg,
+                                sizeof(arg));
+   } while (ret == -ERESTART);
+}
+
+
+int
+vmw_ioctl_fence_finish(struct vmw_winsys_screen *vws,
+                       uint32_t fence)
+{
+   assert(fence);
+   
+   if(fence) {
+      if(vmw_ioctl_fence_signalled(vws, fence) != 0) {
+         vmw_ioctl_sync(vws, fence);
+      }
+   }
+   
+   return 0;
+}
+
+
+boolean
+vmw_ioctl_init(struct vmw_winsys_screen *vws)
+{
+   struct drm_vmw_getparam_arg gp_arg;
+   int ret;
+
+   VMW_FUNC;
+
+   memset(&gp_arg, 0, sizeof(gp_arg));
+   gp_arg.param = DRM_VMW_PARAM_3D;
+   ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_GET_PARAM,
+                            &gp_arg, sizeof(gp_arg));
+   if (ret || gp_arg.value == 0) {
+      debug_printf("No 3D enabled (%i, %s)\n", ret, strerror(-ret));
+      goto out_err1;
+   }
+
+   memset(&gp_arg, 0, sizeof(gp_arg));
+   gp_arg.param = DRM_VMW_PARAM_FIFO_OFFSET;
+   ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_GET_PARAM,
+                            &gp_arg, sizeof(gp_arg));
+
+   if (ret) {
+      debug_printf("GET_PARAM on %d returned %d: %s\n",
+                  vws->ioctl.drm_fd, ret, strerror(-ret));
+      goto out_err1;
+   }
+
+   vmw_printf("Offset to map is 0x%08llx\n",
+              (unsigned long long)gp_arg.value);
+
+   vws->ioctl.fifo_map = vmw_ioctl_fifo_map(vws, gp_arg.value);
+   if (vws->ioctl.fifo_map == NULL)
+      goto out_err1;
+
+   vmw_printf("%s OK\n", __FUNCTION__);
+   return TRUE;
+
+ out_err1:
+   debug_printf("%s Failed\n", __FUNCTION__);
+   return FALSE;
+}
+
+
+
+void
+vmw_ioctl_cleanup(struct vmw_winsys_screen *vws)
+{
+   VMW_FUNC;
+
+   vmw_ioctl_fifo_unmap(vws, (void *)vws->ioctl.fifo_map);
+}
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen_pools.c b/src/gallium/winsys/drm/vmware/core/vmw_screen_pools.c
new file mode 100644 (file)
index 0000000..b1c24b0
--- /dev/null
@@ -0,0 +1,79 @@
+/**********************************************************
+ * 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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+
+#include "vmw_screen.h"
+
+#include "vmw_buffer.h"
+#include "vmw_fence.h"
+
+#include "pipebuffer/pb_buffer.h"
+#include "pipebuffer/pb_bufmgr.h"
+
+void
+vmw_pools_cleanup(struct vmw_winsys_screen *vws)
+{
+   if(vws->pools.gmr_fenced)
+      vws->pools.gmr_fenced->destroy(vws->pools.gmr_fenced);
+
+   /* gmr_mm pool is already destroyed above */
+
+   if(vws->pools.gmr)
+      vws->pools.gmr->destroy(vws->pools.gmr);
+}
+
+
+boolean
+vmw_pools_init(struct vmw_winsys_screen *vws)
+{
+   vws->pools.gmr = vmw_gmr_bufmgr_create(vws);
+   if(!vws->pools.gmr)
+      goto error;
+
+   vws->pools.gmr_mm = mm_bufmgr_create(vws->pools.gmr,
+                                        16*1024*1024,
+                                        12 /* 4096 alignment */);
+   if(!vws->pools.gmr_mm)
+      goto error;
+
+   vws->pools.gmr_fenced = fenced_bufmgr_create(
+      vws->pools.gmr_mm,
+      vmw_fence_ops_create(vws));
+
+#ifdef DEBUG
+   vws->pools.gmr_fenced = pb_debug_manager_create(vws->pools.gmr_fenced,
+                                                  4096,
+                                                  4096);
+#endif
+   if(!vws->pools.gmr_fenced)
+      goto error;
+
+   return TRUE;
+
+error:
+   vmw_pools_cleanup(vws);
+   return FALSE;
+}
+
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen_svga.c b/src/gallium/winsys/drm/vmware/core/vmw_screen_svga.c
new file mode 100644 (file)
index 0000000..d7d0088
--- /dev/null
@@ -0,0 +1,295 @@
+/**********************************************************
+ * 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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+/**
+ * @file
+ * This file implements the SVGA interface into this winsys, defined
+ * in drivers/svga/svga_winsys.h.
+ *
+ * @author Keith Whitwell
+ * @author Jose Fonseca
+ */
+
+
+#include "svga_cmd.h"
+#include "svga3d_caps.h"
+
+#include "pipe/p_inlines.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+#include "pipebuffer/pb_buffer.h"
+#include "pipebuffer/pb_bufmgr.h"
+#include "svga_winsys.h"
+#include "vmw_context.h"
+#include "vmw_screen.h"
+#include "vmw_surface.h"
+#include "vmw_buffer.h"
+#include "vmw_fence.h"
+
+
+static struct svga_winsys_buffer *
+vmw_svga_winsys_buffer_create(struct svga_winsys_screen *sws,
+                              unsigned alignment,
+                              unsigned usage,
+                              unsigned size)
+{
+   struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
+   struct pb_desc desc;
+   struct pb_manager *provider;
+   struct pb_buffer *buffer;
+
+   memset(&desc, 0, sizeof desc);
+   desc.alignment = alignment;
+   desc.usage = usage;
+
+   provider = vws->pools.gmr_fenced;
+
+   assert(provider);
+   buffer = provider->create_buffer(provider, size, &desc);
+   if(!buffer)
+      return NULL;
+
+   return vmw_svga_winsys_buffer(buffer);
+}
+
+
+static void *
+vmw_svga_winsys_buffer_map(struct svga_winsys_screen *sws,
+                           struct svga_winsys_buffer *buf,
+                           unsigned flags)
+{
+   (void)sws;
+   return pb_map(vmw_pb_buffer(buf), flags);
+}
+
+
+static void
+vmw_svga_winsys_buffer_unmap(struct svga_winsys_screen *sws,
+                             struct svga_winsys_buffer *buf)
+{
+   (void)sws;
+   pb_unmap(vmw_pb_buffer(buf));
+}
+
+
+static void
+vmw_svga_winsys_buffer_destroy(struct svga_winsys_screen *sws,
+                               struct svga_winsys_buffer *buf)
+{
+   struct pb_buffer *pbuf = vmw_pb_buffer(buf);
+   (void)sws;
+   pb_reference(&pbuf, NULL);
+}
+
+
+static void
+vmw_svga_winsys_fence_reference(struct svga_winsys_screen *sws,
+                                struct pipe_fence_handle **pdst,
+                                struct pipe_fence_handle *src)
+{
+   (void)sws;
+   *pdst = src;
+}
+
+
+static int
+vmw_svga_winsys_fence_signalled(struct svga_winsys_screen *sws,
+                                struct pipe_fence_handle *fence,
+                                unsigned flag)
+{
+   struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
+   (void)flag;
+   return vmw_ioctl_fence_signalled(vws, vmw_fence(fence));
+}
+
+
+static int
+vmw_svga_winsys_fence_finish(struct svga_winsys_screen *sws,
+                             struct pipe_fence_handle *fence,
+                             unsigned flag)
+{
+   struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
+   (void)flag;
+   return vmw_ioctl_fence_finish(vws, vmw_fence(fence));
+}
+
+
+
+static struct svga_winsys_surface *
+vmw_svga_winsys_surface_create(struct svga_winsys_screen *sws,
+                               SVGA3dSurfaceFlags flags,
+                               SVGA3dSurfaceFormat format,
+                               SVGA3dSize size,
+                               uint32 numFaces,
+                               uint32 numMipLevels)
+{
+   struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
+   struct vmw_svga_winsys_surface *surface;
+
+   surface = CALLOC_STRUCT(vmw_svga_winsys_surface);
+   if(!surface)
+      goto no_surface;
+
+   pipe_reference_init(&surface->refcnt, 1);
+   p_atomic_set(&surface->validated, 0);
+   surface->screen = vws;
+   surface->sid = vmw_ioctl_surface_create(vws,
+                                           flags, format, size,
+                                           numFaces, numMipLevels);
+   if(surface->sid == SVGA3D_INVALID_ID)
+      goto no_sid;
+
+   return svga_winsys_surface(surface);
+
+no_sid:
+   FREE(surface);
+no_surface:
+   return NULL;
+}
+
+
+static boolean
+vmw_svga_winsys_surface_is_flushed(struct svga_winsys_screen *sws,
+                                   struct svga_winsys_surface *surface)
+{
+   struct vmw_svga_winsys_surface *vsurf = vmw_svga_winsys_surface(surface);
+   return (p_atomic_read(&vsurf->validated) == 0);
+}
+
+
+static void
+vmw_svga_winsys_surface_ref(struct svga_winsys_screen *sws,
+                           struct svga_winsys_surface **pDst,
+                           struct svga_winsys_surface *src)
+{
+   struct vmw_svga_winsys_surface *d_vsurf = vmw_svga_winsys_surface(*pDst);
+   struct vmw_svga_winsys_surface *s_vsurf = vmw_svga_winsys_surface(src);
+
+   vmw_svga_winsys_surface_reference(&d_vsurf, s_vsurf);
+   *pDst = svga_winsys_surface(d_vsurf);
+}
+
+
+static void
+vmw_svga_winsys_destroy(struct svga_winsys_screen *sws)
+{
+   struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
+
+   vmw_winsys_destroy(vws);
+}
+
+
+static boolean
+vmw_svga_winsys_get_cap(struct svga_winsys_screen *sws,
+                        SVGA3dDevCapIndex index,
+                        SVGA3dDevCapResult *result)
+{
+   struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
+   const uint32 *capsBlock;
+   const SVGA3dCapsRecord *capsRecord = NULL;
+   uint32 offset;
+   const SVGA3dCapPair *capArray;
+   int numCaps, first, last;
+
+   if(!vws->ioctl.fifo_map)
+      return FALSE;
+
+   if(vws->ioctl.fifo_map[SVGA_FIFO_3D_HWVERSION] < SVGA3D_HWVERSION_WS6_B1)
+      return FALSE;
+
+   /*
+    * Search linearly through the caps block records for the specified type.
+    */
+   capsBlock = (const uint32 *)&vws->ioctl.fifo_map[SVGA_FIFO_3D_CAPS];
+   for (offset = 0; capsBlock[offset] != 0; offset += capsBlock[offset]) {
+      const SVGA3dCapsRecord *record;
+      assert(offset < SVGA_FIFO_3D_CAPS_SIZE);
+      record = (const SVGA3dCapsRecord *) (capsBlock + offset);
+      if ((record->header.type >= SVGA3DCAPS_RECORD_DEVCAPS_MIN) &&
+          (record->header.type <= SVGA3DCAPS_RECORD_DEVCAPS_MAX) &&
+          (!capsRecord || (record->header.type > capsRecord->header.type))) {
+         capsRecord = record;
+      }
+   }
+
+   if(!capsRecord)
+      return FALSE;
+
+   /*
+    * Calculate the number of caps from the size of the record.
+    */
+   capArray = (const SVGA3dCapPair *) capsRecord->data;
+   numCaps = (int) ((capsRecord->header.length * sizeof(uint32) -
+                     sizeof capsRecord->header) / (2 * sizeof(uint32)));
+
+   /*
+    * Binary-search for the cap with the specified index.
+    */
+   for (first = 0, last = numCaps - 1; first <= last; ) {
+      int mid = (first + last) / 2;
+
+      if ((SVGA3dDevCapIndex) capArray[mid][0] == index) {
+         /*
+          * Found it.
+          */
+         result->u = capArray[mid][1];
+         return TRUE;
+      }
+
+      /*
+       * Divide and conquer.
+       */
+      if ((SVGA3dDevCapIndex) capArray[mid][0] > index) {
+         last = mid - 1;
+      } else {
+         first = mid + 1;
+      }
+   }
+
+   return FALSE;
+}
+
+
+boolean
+vmw_winsys_screen_init_svga(struct vmw_winsys_screen *vws)
+{
+   vws->base.destroy = vmw_svga_winsys_destroy;
+   vws->base.get_cap = vmw_svga_winsys_get_cap;
+   vws->base.context_create = vmw_svga_winsys_context_create;
+   vws->base.surface_create = vmw_svga_winsys_surface_create;
+   vws->base.surface_is_flushed = vmw_svga_winsys_surface_is_flushed;
+   vws->base.surface_reference = vmw_svga_winsys_surface_ref;
+   vws->base.buffer_create = vmw_svga_winsys_buffer_create;
+   vws->base.buffer_map = vmw_svga_winsys_buffer_map;
+   vws->base.buffer_unmap = vmw_svga_winsys_buffer_unmap;
+   vws->base.buffer_destroy = vmw_svga_winsys_buffer_destroy;
+   vws->base.fence_reference = vmw_svga_winsys_fence_reference;
+   vws->base.fence_signalled = vmw_svga_winsys_fence_signalled;
+   vws->base.fence_finish = vmw_svga_winsys_fence_finish;
+
+   return TRUE;
+}
+
+
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_surface.c b/src/gallium/winsys/drm/vmware/core/vmw_surface.c
new file mode 100644 (file)
index 0000000..5f1b9ad
--- /dev/null
@@ -0,0 +1,61 @@
+/**********************************************************
+ * 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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+
+#include "svga_cmd.h"
+#include "util/u_debug.h"
+#include "util/u_memory.h"
+
+#include "vmw_surface.h"
+#include "vmw_screen.h"
+
+void
+vmw_svga_winsys_surface_reference(struct vmw_svga_winsys_surface **pdst,
+                                  struct vmw_svga_winsys_surface *src)
+{
+   struct pipe_reference *src_ref;
+   struct pipe_reference *dst_ref;
+   struct vmw_svga_winsys_surface *dst;
+
+   if(pdst == NULL || *pdst == src)
+      return;
+
+   dst = *pdst;
+
+   src_ref = src ? &src->refcnt : NULL;
+   dst_ref = dst ? &dst->refcnt : NULL;
+
+   if (pipe_reference(dst_ref, src_ref)) {
+      vmw_ioctl_surface_destroy(dst->screen, dst->sid);
+#ifdef DEBUG
+      /* to detect dangling pointers */
+      assert(p_atomic_read(&dst->validated) == 0);
+      dst->sid = SVGA3D_INVALID_ID;
+#endif
+      FREE(dst);
+   }
+
+   *pdst = src;
+}
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_surface.h b/src/gallium/winsys/drm/vmware/core/vmw_surface.h
new file mode 100644 (file)
index 0000000..340cc15
--- /dev/null
@@ -0,0 +1,79 @@
+/**********************************************************
+ * 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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+/**
+ * @file
+ * Surfaces for VMware SVGA winsys.
+ * 
+ * @author Jose Fonseca <jfonseca@vmware.com>
+ */
+
+
+#ifndef VMW_SURFACE_H_
+#define VMW_SURFACE_H_
+
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_atomic.h"
+#include "pipe/p_refcnt.h"
+
+#define VMW_MAX_PRESENTS 3
+
+
+
+struct vmw_svga_winsys_surface
+{
+   struct pipe_atomic validated;
+   struct pipe_reference refcnt;
+
+   struct vmw_winsys_screen *screen;
+   uint32_t sid;
+
+   /* FIXME: make this thread safe */
+   unsigned next_present_no;
+   uint32_t present_fences[VMW_MAX_PRESENTS];
+};
+
+
+static INLINE struct svga_winsys_surface *
+svga_winsys_surface(struct vmw_svga_winsys_surface *surf)
+{
+   assert(!surf || surf->sid != SVGA3D_INVALID_ID);
+   return (struct svga_winsys_surface *)surf;
+}
+
+
+static INLINE struct vmw_svga_winsys_surface *
+vmw_svga_winsys_surface(struct svga_winsys_surface *surf)
+{
+   return (struct vmw_svga_winsys_surface *)surf;
+}
+
+
+void
+vmw_svga_winsys_surface_reference(struct vmw_svga_winsys_surface **pdst,
+                                  struct vmw_svga_winsys_surface *src);
+
+#endif /* VMW_SURFACE_H_ */
diff --git a/src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h b/src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h
new file mode 100644 (file)
index 0000000..2be7e12
--- /dev/null
@@ -0,0 +1,574 @@
+/**************************************************************************
+ *
+ * Copyright © 2009 VMware, Inc., Palo Alto, CA., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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.
+ *
+ **************************************************************************/
+
+#ifndef __VMWGFX_DRM_H__
+#define __VMWGFX_DRM_H__
+
+#define DRM_VMW_MAX_SURFACE_FACES 6
+#define DRM_VMW_MAX_MIP_LEVELS 24
+
+#define DRM_VMW_EXT_NAME_LEN 128
+
+#define DRM_VMW_GET_PARAM            0
+#define DRM_VMW_ALLOC_DMABUF         1
+#define DRM_VMW_UNREF_DMABUF         2
+#define DRM_VMW_CURSOR_BYPASS        3
+/* guarded by DRM_VMW_PARAM_NUM_STREAMS != 0*/
+#define DRM_VMW_CONTROL_STREAM       4
+#define DRM_VMW_CLAIM_STREAM         5
+#define DRM_VMW_UNREF_STREAM         6
+/* guarded by DRM_VMW_PARAM_3D == 1 */
+#define DRM_VMW_CREATE_CONTEXT       7
+#define DRM_VMW_UNREF_CONTEXT        8
+#define DRM_VMW_CREATE_SURFACE       9
+#define DRM_VMW_UNREF_SURFACE        10
+#define DRM_VMW_REF_SURFACE          11
+#define DRM_VMW_EXECBUF              12
+#define DRM_VMW_FIFO_DEBUG           13
+#define DRM_VMW_FENCE_WAIT           14
+
+
+/*************************************************************************/
+/**
+ * DRM_VMW_GET_PARAM - get device information.
+ *
+ * DRM_VMW_PARAM_FIFO_OFFSET:
+ * Offset to use to map the first page of the FIFO read-only.
+ * The fifo is mapped using the mmap() system call on the drm device.
+ *
+ * DRM_VMW_PARAM_OVERLAY_IOCTL:
+ * Does the driver support the overlay ioctl.
+ */
+
+#define DRM_VMW_PARAM_NUM_STREAMS      0
+#define DRM_VMW_PARAM_NUM_FREE_STREAMS 1
+#define DRM_VMW_PARAM_3D               2
+#define DRM_VMW_PARAM_FIFO_OFFSET      3
+
+
+/**
+ * struct drm_vmw_getparam_arg
+ *
+ * @value: Returned value. //Out
+ * @param: Parameter to query. //In.
+ *
+ * Argument to the DRM_VMW_GET_PARAM Ioctl.
+ */
+
+struct drm_vmw_getparam_arg {
+       uint64_t value;
+       uint32_t param;
+       uint32_t pad64;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_EXTENSION - Query device extensions.
+ */
+
+/**
+ * struct drm_vmw_extension_rep
+ *
+ * @exists: The queried extension exists.
+ * @driver_ioctl_offset: Ioctl number of the first ioctl in the extension.
+ * @driver_sarea_offset: Offset to any space in the DRI SAREA
+ * used by the extension.
+ * @major: Major version number of the extension.
+ * @minor: Minor version number of the extension.
+ * @pl: Patch level version number of the extension.
+ *
+ * Output argument to the DRM_VMW_EXTENSION Ioctl.
+ */
+
+struct drm_vmw_extension_rep {
+       int32_t exists;
+       uint32_t driver_ioctl_offset;
+       uint32_t driver_sarea_offset;
+       uint32_t major;
+       uint32_t minor;
+       uint32_t pl;
+       uint32_t pad64;
+};
+
+/**
+ * union drm_vmw_extension_arg
+ *
+ * @extension - Ascii name of the extension to be queried. //In
+ * @rep - Reply as defined above. //Out
+ *
+ * Argument to the DRM_VMW_EXTENSION Ioctl.
+ */
+
+union drm_vmw_extension_arg {
+       char extension[DRM_VMW_EXT_NAME_LEN];
+       struct drm_vmw_extension_rep rep;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_CREATE_CONTEXT - Create a host context.
+ *
+ * Allocates a device unique context id, and queues a create context command
+ * for the host. Does not wait for host completion.
+ */
+
+/**
+ * struct drm_vmw_context_arg
+ *
+ * @cid: Device unique context ID.
+ *
+ * Output argument to the DRM_VMW_CREATE_CONTEXT Ioctl.
+ * Input argument to the DRM_VMW_UNREF_CONTEXT Ioctl.
+ */
+
+struct drm_vmw_context_arg {
+       int32_t cid;
+       uint32_t pad64;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_UNREF_CONTEXT - Create a host context.
+ *
+ * Frees a global context id, and queues a destroy host command for the host.
+ * Does not wait for host completion. The context ID can be used directly
+ * in the command stream and shows up as the same context ID on the host.
+ */
+
+/*************************************************************************/
+/**
+ * DRM_VMW_CREATE_SURFACE - Create a host suface.
+ *
+ * Allocates a device unique surface id, and queues a create surface command
+ * for the host. Does not wait for host completion. The surface ID can be
+ * used directly in the command stream and shows up as the same surface
+ * ID on the host.
+ */
+
+/**
+ * struct drm_wmv_surface_create_req
+ *
+ * @flags: Surface flags as understood by the host.
+ * @format: Surface format as understood by the host.
+ * @mip_levels: Number of mip levels for each face.
+ * An unused face should have 0 encoded.
+ * @size_addr: Address of a user-space array of sruct drm_vmw_size
+ * cast to an uint64_t for 32-64 bit compatibility.
+ * The size of the array should equal the total number of mipmap levels.
+ * @shareable: Boolean whether other clients (as identified by file descriptors)
+ * may reference this surface.
+ *
+ * Input data to the DRM_VMW_CREATE_SURFACE Ioctl.
+ * Output data from the DRM_VMW_REF_SURFACE Ioctl.
+ */
+
+struct drm_vmw_surface_create_req {
+       uint32_t flags;
+       uint32_t format;
+       uint32_t mip_levels[DRM_VMW_MAX_SURFACE_FACES];
+       uint64_t size_addr;
+       int32_t shareable;
+       uint32_t pad64;
+};
+
+/**
+ * struct drm_wmv_surface_arg
+ *
+ * @sid: Surface id of created surface or surface to destroy or reference.
+ *
+ * Output data from the DRM_VMW_CREATE_SURFACE Ioctl.
+ * Input argument to the DRM_VMW_UNREF_SURFACE Ioctl.
+ * Input argument to the DRM_VMW_REF_SURFACE Ioctl.
+ */
+
+struct drm_vmw_surface_arg {
+       int32_t sid;
+       uint32_t pad64;
+};
+
+/**
+ * struct drm_vmw_size ioctl.
+ *
+ * @width - mip level width
+ * @height - mip level height
+ * @depth - mip level depth
+ *
+ * Description of a mip level.
+ * Input data to the DRM_WMW_CREATE_SURFACE Ioctl.
+ */
+
+struct drm_vmw_size {
+       uint32_t width;
+       uint32_t height;
+       uint32_t depth;
+       uint32_t pad64;
+};
+
+/**
+ * union drm_vmw_surface_create_arg
+ *
+ * @rep: Output data as described above.
+ * @req: Input data as described above.
+ *
+ * Argument to the DRM_VMW_CREATE_SURFACE Ioctl.
+ */
+
+union drm_vmw_surface_create_arg {
+       struct drm_vmw_surface_arg rep;
+       struct drm_vmw_surface_create_req req;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_REF_SURFACE - Reference a host surface.
+ *
+ * Puts a reference on a host surface with a give sid, as previously
+ * returned by the DRM_VMW_CREATE_SURFACE ioctl.
+ * A reference will make sure the surface isn't destroyed while we hold
+ * it and will allow the calling client to use the surface ID in the command
+ * stream.
+ *
+ * On successful return, the Ioctl returns the surface information given
+ * in the DRM_VMW_CREATE_SURFACE ioctl.
+ */
+
+/**
+ * union drm_vmw_surface_reference_arg
+ *
+ * @rep: Output data as described above.
+ * @req: Input data as described above.
+ *
+ * Argument to the DRM_VMW_REF_SURFACE Ioctl.
+ */
+
+union drm_vmw_surface_reference_arg {
+       struct drm_vmw_surface_create_req rep;
+       struct drm_vmw_surface_arg req;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_UNREF_SURFACE - Unreference a host surface.
+ *
+ * Clear a reference previously put on a host surface.
+ * When all references are gone, including the one implicitly placed
+ * on creation,
+ * a destroy surface command will be queued for the host.
+ * Does not wait for completion.
+ */
+
+/*************************************************************************/
+/**
+ * DRM_VMW_EXECBUF
+ *
+ * Submit a command buffer for execution on the host, and return a
+ * fence sequence that when signaled, indicates that the command buffer has
+ * executed.
+ */
+
+/**
+ * struct drm_vmw_execbuf_arg
+ *
+ * @commands: User-space address of a command buffer cast to an uint64_t.
+ * @command-size: Size in bytes of the command buffer.
+ * @fence_rep: User-space address of a struct drm_vmw_fence_rep cast to an
+ * uint64_t.
+ *
+ * Argument to the DRM_VMW_EXECBUF Ioctl.
+ */
+
+struct drm_vmw_execbuf_arg {
+       uint64_t commands;
+       uint32_t command_size;
+       uint32_t pad64;
+       uint64_t fence_rep;
+};
+
+/**
+ * struct drm_vmw_fence_rep
+ *
+ * @fence_seq: Fence sequence associated with a command submission.
+ * @error: This member should've been set to -EFAULT on submission.
+ * The following actions should be take on completion:
+ * error == -EFAULT: Fence communication failed. The host is synchronized.
+ * Use the last fence id read from the FIFO fence register.
+ * error != 0 && error != -EFAULT:
+ * Fence submission failed. The host is synchronized. Use the fence_seq member.
+ * error == 0: All is OK, The host may not be synchronized.
+ * Use the fence_seq member.
+ *
+ * Input / Output data to the DRM_VMW_EXECBUF Ioctl.
+ */
+
+struct drm_vmw_fence_rep {
+       uint64_t fence_seq;
+       int32_t error;
+       uint32_t pad64;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_ALLOC_DMABUF
+ *
+ * Allocate a DMA buffer that is visible also to the host.
+ * NOTE: The buffer is
+ * identified by a handle and an offset, which are private to the guest, but
+ * useable in the command stream. The guest kernel may translate these
+ * and patch up the command stream accordingly. In the future, the offset may
+ * be zero at all times, or it may disappear from the interface before it is
+ * fixed.
+ *
+ * The DMA buffer may stay user-space mapped in the guest at all times,
+ * and is thus suitable for sub-allocation.
+ *
+ * DMA buffers are mapped using the mmap() syscall on the drm device.
+ */
+
+/**
+ * struct drm_vmw_alloc_dmabuf_req
+ *
+ * @size: Required minimum size of the buffer.
+ *
+ * Input data to the DRM_VMW_ALLOC_DMABUF Ioctl.
+ */
+
+struct drm_vmw_alloc_dmabuf_req {
+       uint32_t size;
+       uint32_t pad64;
+};
+
+/**
+ * struct drm_vmw_dmabuf_rep
+ *
+ * @map_handle: Offset to use in the mmap() call used to map the buffer.
+ * @handle: Handle unique to this buffer. Used for unreferencing.
+ * @cur_gmr_id: GMR id to use in the command stream when this buffer is
+ * referenced. See not above.
+ * @cur_gmr_offset: Offset to use in the command stream when this buffer is
+ * referenced. See note above.
+ *
+ * Output data from the DRM_VMW_ALLOC_DMABUF Ioctl.
+ */
+
+struct drm_vmw_dmabuf_rep {
+       uint64_t map_handle;
+       uint32_t handle;
+       uint32_t cur_gmr_id;
+       uint32_t cur_gmr_offset;
+       uint32_t pad64;
+};
+
+/**
+ * union drm_vmw_dmabuf_arg
+ *
+ * @req: Input data as described above.
+ * @rep: Output data as described above.
+ *
+ * Argument to the DRM_VMW_ALLOC_DMABUF Ioctl.
+ */
+
+union drm_vmw_alloc_dmabuf_arg {
+       struct drm_vmw_alloc_dmabuf_req req;
+       struct drm_vmw_dmabuf_rep rep;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_UNREF_DMABUF - Free a DMA buffer.
+ *
+ */
+
+/**
+ * struct drm_vmw_unref_dmabuf_arg
+ *
+ * @handle: Handle indicating what buffer to free. Obtained from the
+ * DRM_VMW_ALLOC_DMABUF Ioctl.
+ *
+ * Argument to the DRM_VMW_UNREF_DMABUF Ioctl.
+ */
+
+struct drm_vmw_unref_dmabuf_arg {
+       uint32_t handle;
+       uint32_t pad64;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_FIFO_DEBUG - Get last FIFO submission.
+ *
+ * This IOCTL copies the last FIFO submission directly out of the FIFO buffer.
+ */
+
+/**
+ * struct drm_vmw_fifo_debug_arg
+ *
+ * @debug_buffer: User space address of a debug_buffer cast to an uint64_t //In
+ * @debug_buffer_size: Size in bytes of debug buffer //In
+ * @used_size: Number of bytes copied to the buffer // Out
+ * @did_not_fit: Boolean indicating that the fifo contents did not fit. //Out
+ *
+ * Argument to the DRM_VMW_FIFO_DEBUG Ioctl.
+ */
+
+struct drm_vmw_fifo_debug_arg {
+       uint64_t debug_buffer;
+       uint32_t debug_buffer_size;
+       uint32_t used_size;
+       int32_t did_not_fit;
+       uint32_t pad64;
+};
+
+struct drm_vmw_fence_wait_arg {
+       uint64_t sequence;
+       uint64_t kernel_cookie;
+       int32_t cookie_valid;
+       int32_t pad64;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_CONTROL_STREAM - Control overlays, aka streams.
+ *
+ * This IOCTL controls the overlay units of the svga device.
+ * The SVGA overlay units does not work like regular hardware units in
+ * that they do not automaticaly read back the contents of the given dma
+ * buffer. But instead only read back for each call to this ioctl, and
+ * at any point between this call being made and a following call that
+ * either changes the buffer or disables the stream.
+ */
+
+/**
+ * struct drm_vmw_rect
+ *
+ * Defines a rectangle. Used in the overlay ioctl to define
+ * source and destination rectangle.
+ */
+
+struct drm_vmw_rect {
+       int32_t x;
+       int32_t y;
+       uint32_t w;
+       uint32_t h;
+};
+
+/**
+ * struct drm_vmw_control_stream_arg
+ *
+ * @stream_id: Stearm to control
+ * @enabled: If false all following arguments are ignored.
+ * @handle: Handle to buffer for getting data from.
+ * @format: Format of the overlay as understood by the host.
+ * @width: Width of the overlay.
+ * @height: Height of the overlay.
+ * @size: Size of the overlay in bytes.
+ * @pitch: Array of pitches, the two last are only used for YUV12 formats.
+ * @offset: Offset from start of dma buffer to overlay.
+ * @src: Source rect, must be within the defined area above.
+ * @dst: Destination rect, x and y may be negative.
+ *
+ * Argument to the DRM_VMW_CONTROL_STREAM Ioctl.
+ */
+
+struct drm_vmw_control_stream_arg {
+       uint32_t stream_id;
+       uint32_t enabled;
+
+       uint32_t flags;
+       uint32_t color_key;
+
+       uint32_t handle;
+       uint32_t offset;
+       int32_t format;
+       uint32_t size;
+       uint32_t width;
+       uint32_t height;
+       uint32_t pitch[3];
+
+       uint32_t pad64;
+       struct drm_vmw_rect src;
+       struct drm_vmw_rect dst;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_CURSOR_BYPASS - Give extra information about cursor bypass.
+ *
+ */
+
+#define DRM_VMW_CURSOR_BYPASS_ALL    (1 << 0)
+#define DRM_VMW_CURSOR_BYPASS_FLAGS       (1)
+
+/**
+ * struct drm_vmw_cursor_bypass_arg
+ *
+ * @flags: Flags.
+ * @crtc_id: Crtc id, only used if DMR_CURSOR_BYPASS_ALL isn't passed.
+ * @xpos: X position of cursor.
+ * @ypos: Y position of cursor.
+ * @xhot: X hotspot.
+ * @yhot: Y hotspot.
+ *
+ * Argument to the DRM_VMW_CURSOR_BYPASS Ioctl.
+ */
+
+struct drm_vmw_cursor_bypass_arg {
+       uint32_t flags;
+       uint32_t crtc_id;
+       int32_t xpos;
+       int32_t ypos;
+       int32_t xhot;
+       int32_t yhot;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_CLAIM_STREAM - Claim a single stream.
+ */
+
+/**
+ * struct drm_vmw_context_arg
+ *
+ * @stream_id: Device unique context ID.
+ *
+ * Output argument to the DRM_VMW_CREATE_CONTEXT Ioctl.
+ * Input argument to the DRM_VMW_UNREF_CONTEXT Ioctl.
+ */
+
+struct drm_vmw_stream_arg {
+       uint32_t stream_id;
+       uint32_t pad64;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_UNREF_STREAM - Unclaim a stream.
+ *
+ * Return a single stream that was claimed by this process. Also makes
+ * sure that the stream has been stopped.
+ */
+
+#endif
diff --git a/src/gallium/winsys/drm/vmware/dri/Makefile b/src/gallium/winsys/drm/vmware/dri/Makefile
new file mode 100644 (file)
index 0000000..8a39e23
--- /dev/null
@@ -0,0 +1,18 @@
+
+TOP = ../../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = vmwgfx_dri.so
+
+PIPE_DRIVERS = \
+       $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \
+       $(TOP)/src/gallium/winsys/drm/vmware/core/libsvgadrm.a \
+       $(TOP)/src/gallium/drivers/trace/libtrace.a \
+       $(TOP)/src/gallium/drivers/svga/libsvga.a
+
+C_SOURCES = \
+       $(COMMON_GALLIUM_SOURCES)
+
+include ../../Makefile.template
+
+symlinks:
diff --git a/src/gallium/winsys/drm/vmware/dri/SConscript b/src/gallium/winsys/drm/vmware/dri/SConscript
new file mode 100644 (file)
index 0000000..84319f9
--- /dev/null
@@ -0,0 +1,62 @@
+import os
+import os.path
+
+Import('*')
+
+if env['platform'] == 'linux':
+
+   if env['dri']:
+      env = env.Clone()
+
+      sources = [
+        '#/src/mesa/drivers/dri/common/utils.c',
+        '#/src/mesa/drivers/dri/common/vblank.c',
+        '#/src/mesa/drivers/dri/common/dri_util.c',
+        '#/src/mesa/drivers/dri/common/xmlconfig.c',
+         ]
+   
+      
+      env.ParseConfig('pkg-config --cflags --libs libdrm')
+      
+      env.Prepend(CPPPATH = [
+            '#/src/mesa/state_tracker',
+            '#/src/mesa/drivers/dri/common',
+            '#/src/mesa/main',
+            '#/src/mesa/glapi',
+            '#/src/mesa',
+            '#/include',
+            '#/src/gallium/drivers/svga',
+            '#/src/gallium/drivers/svga/include',
+            ])
+      
+      env.Append(CPPDEFINES = [
+            'HAVE_STDINT_H', 
+            'HAVE_SYS_TYPES_H',
+            ])
+
+      env.Append(CFLAGS = [
+            '-std=gnu99',
+            '-D_FILE_OFFSET_BITS=64',
+            ])
+      
+      env.Prepend(LIBPATH = [
+            ])
+      
+      env.Prepend(LIBS = [
+            trace,
+            st_dri,
+            svgadrm,
+            svga,
+            mesa,
+            gallium,
+            ])
+      
+      # TODO: write a wrapper function http://www.scons.org/wiki/WrapperFunctions
+      env.LoadableModule(
+         target ='vmwgfx_dri.so',
+         source = sources,
+         LIBS = env['LIBS'],
+         SHLIBPREFIX = '',
+         )
+      
+
diff --git a/src/gallium/winsys/drm/vmware/egl/Makefile b/src/gallium/winsys/drm/vmware/egl/Makefile
new file mode 100644 (file)
index 0000000..8e2980c
--- /dev/null
@@ -0,0 +1,18 @@
+
+TOP = ../../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = EGL_svga.so
+
+PIPE_DRIVERS = \
+       $(TOP)/src/gallium/state_trackers/egl/libegldrm.a \
+       $(TOP)/src/gallium/winsys/drm/vmware/core/libsvgadrm.a \
+       $(TOP)/src/gallium/drivers/trace/libtrace.a \
+       $(TOP)/src/gallium/drivers/svga/libsvga.a
+
+C_SOURCES = \
+       $(COMMON_GALLIUM_SOURCES)
+
+include ../../Makefile.template
+
+symlinks:
diff --git a/src/gallium/winsys/drm/vmware/xorg/Makefile b/src/gallium/winsys/drm/vmware/xorg/Makefile
new file mode 100644 (file)
index 0000000..49e28ae
--- /dev/null
@@ -0,0 +1,71 @@
+TOP        = ../../../../../..
+
+include $(TOP)/configs/current
+
+TARGET = vmwgfx_drv.so
+
+CFILES = \
+       vmw_xorg.c \
+       vmw_video.c \
+       vmw_ioctl.c \
+       vmw_screen.c
+
+OBJECTS = $(patsubst %.c,%.o,$(CFILES))
+
+INCLUDES = \
+       $(shell pkg-config --cflags-only-I pixman-1 xorg-server libdrm xproto) \
+       -I$(TOP)/src/gallium/include \
+       -I$(TOP)/src/gallium/drivers \
+       -I$(TOP)/src/gallium/auxiliary \
+       -I$(TOP)/src/gallium
+
+LIBS = \
+       $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \
+       $(TOP)/src/gallium/winsys/drm/vmware/core/libsvgadrm.a \
+       $(TOP)/src/gallium/drivers/trace/libtrace.a \
+       $(TOP)/src/gallium/drivers/svga/libsvga.a \
+       $(GALLIUM_AUXILIARIES)
+
+LINKS = \
+       $(shell pkg-config --libs --silence-errors libkms) \
+       $(shell pkg-config --libs libdrm)
+
+DRIVER_DEFINES = \
+       -std=gnu99 \
+       -DHAVE_CONFIG_H
+
+TARGET_STAGING = $(TOP)/$(LIB_DIR)/gallium/$(TARGET)
+
+#############################################
+
+
+
+all default: $(TARGET) $(TARGET_STAGING)
+
+$(TARGET): $(OBJECTS) Makefile $(LIBS)
+       $(MKLIB) -noprefix -o $@ $(OBJECTS) $(LIBS) $(LINKS)
+
+$(TOP)/$(LIB_DIR)/gallium:
+       mkdir -p $@
+
+$(TARGET_STAGING): $(TARGET) $(TOP)/$(LIB_DIR)/gallium
+       $(INSTALL) $(TARGET) $(TOP)/$(LIB_DIR)/gallium
+
+clean:
+       rm -rf $(OBJECTS) $(TARGET)
+
+install:
+       $(INSTALL) -d $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
+       $(MINSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
+
+
+##############################################
+
+
+.c.o:
+       $(CC) -c $(CFLAGS) $(INCLUDES) $(DRIVER_DEFINES) $< -o $@
+
+
+##############################################
+
+.PHONY = all clean install
diff --git a/src/gallium/winsys/drm/vmware/xorg/SConscript b/src/gallium/winsys/drm/vmware/xorg/SConscript
new file mode 100644 (file)
index 0000000..1e5d8ff
--- /dev/null
@@ -0,0 +1,57 @@
+import os.path
+
+Import('*')
+
+if env['platform'] == 'linux':
+
+       env = env.Clone()
+
+       env.ParseConfig('pkg-config --cflags --libs libdrm xorg-server')
+
+       env.Prepend(CPPPATH = [
+               '#/include',
+               '#/src/gallium',
+               '#/src/mesa',
+               '#/src/gallium/drivers/svga',
+               '#/src/gallium/drivers/svga/include',
+       ])
+
+       env.Append(CPPDEFINES = [
+       ])
+
+       if env['gcc']:
+               env.Append(CPPDEFINES = [
+                       'HAVE_STDINT_H',
+                       'HAVE_SYS_TYPES_H',
+               ])
+
+       env.Append(CFLAGS = [
+               '-std=gnu99',
+               '-D_FILE_OFFSET_BITS=64',
+       ])
+
+       env.Prepend(LIBPATH = [
+       ])
+
+       env.Prepend(LIBS = [
+               trace,
+               st_xorg,
+               svgadrm,
+               svga,
+                gallium,
+       ])
+
+       sources = [
+               'vmw_ioctl.c',
+               'vmw_screen.c',
+               'vmw_video.c',
+               'vmw_xorg.c',
+       ]
+
+       # TODO: write a wrapper function http://www.scons.org/wiki/WrapperFunctions
+       env.LoadableModule(
+               target ='vmwgfx_drv.so',
+               source = sources,
+               LIBS = env['LIBS'],
+               SHLIBPREFIX = '',
+       )
diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_driver.h b/src/gallium/winsys/drm/vmware/xorg/vmw_driver.h
new file mode 100644 (file)
index 0000000..3efe851
--- /dev/null
@@ -0,0 +1,101 @@
+/**********************************************************
+ * 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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+/**
+ * @file
+ * Contains the shared resources for VMware Xorg driver
+ * that sits ontop of the Xorg State Traker.
+ *
+ * It is initialized in vmw_screen.c.
+ *
+ * @author Jakob Bornecrantz <jakob@vmware.com>
+ */
+
+#ifndef VMW_DRIVER_H_
+#define VMW_DRIVER_H_
+
+#include "state_trackers/xorg/xorg_tracker.h"
+
+struct vmw_dma_buffer;
+
+struct vmw_driver
+{
+    int fd;
+
+    void *cursor_priv;
+
+    /* vmw_video.c */
+    void *video_priv;
+};
+
+static INLINE struct vmw_driver *
+vmw_driver(ScrnInfoPtr pScrn)
+{
+    modesettingPtr ms = modesettingPTR(pScrn);
+    return ms ? (struct vmw_driver *)ms->winsys_priv : NULL;
+}
+
+
+/***********************************************************************
+ * vmw_video.c
+ */
+
+Bool vmw_video_init(ScrnInfoPtr pScrn, struct vmw_driver *vmw);
+
+Bool vmw_video_close(ScrnInfoPtr pScrn, struct vmw_driver *vmw);
+
+void vmw_video_stop_all(ScrnInfoPtr pScrn, struct vmw_driver *vmw);
+
+
+/***********************************************************************
+ * vmw_ioctl.c
+ */
+
+int vmw_ioctl_cursor_bypass(struct vmw_driver *vmw, int xhot, int yhot);
+
+struct vmw_dma_buffer * vmw_ioctl_buffer_create(struct vmw_driver *vmw,
+                                               uint32_t size,
+                                               unsigned *handle);
+
+void * vmw_ioctl_buffer_map(struct vmw_driver *vmw,
+                           struct vmw_dma_buffer *buf);
+
+void vmw_ioctl_buffer_unmap(struct vmw_driver *vmw,
+                           struct vmw_dma_buffer *buf);
+
+void vmw_ioctl_buffer_destroy(struct vmw_driver *vmw,
+                             struct vmw_dma_buffer *buf);
+
+int vmw_ioctl_supports_streams(struct vmw_driver *vmw);
+
+int vmw_ioctl_num_streams(struct vmw_driver *vmw,
+                         uint32_t *ntot, uint32_t *nfree);
+
+int vmw_ioctl_unref_stream(struct vmw_driver *vmw, uint32_t stream_id);
+
+int vmw_ioctl_claim_stream(struct vmw_driver *vmw, uint32_t *out);
+
+
+#endif
diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_hook.h b/src/gallium/winsys/drm/vmware/xorg/vmw_hook.h
new file mode 100644 (file)
index 0000000..224a2d9
--- /dev/null
@@ -0,0 +1,39 @@
+/**********************************************************
+ * 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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+#ifndef VMW_HOOK_H_
+#define VMW_HOOK_H_
+
+#include "state_trackers/xorg/xorg_winsys.h"
+
+
+/***********************************************************************
+ * vmw_screen.c
+ */
+
+void vmw_screen_set_functions(ScrnInfoPtr pScrn);
+
+
+#endif
diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_ioctl.c b/src/gallium/winsys/drm/vmware/xorg/vmw_ioctl.c
new file mode 100644 (file)
index 0000000..ab2b5fa
--- /dev/null
@@ -0,0 +1,242 @@
+/**********************************************************
+ * 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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+/**
+ * @file
+ * Contains the functions for creating dma buffers by calling
+ * the kernel via driver specific ioctls.
+ *
+ * @author Jakob Bornecrantz <jakob@vmware.com>
+ */
+
+#ifndef HAVE_STDINT_H
+#define HAVE_STDINT_H 1
+#endif
+#define _FILE_OFFSET_BITS 64
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <sys/mman.h>
+#include "xf86drm.h"
+#include "../core/vmwgfx_drm.h"
+
+#include "vmw_driver.h"
+#include "util/u_debug.h"
+
+struct vmw_dma_buffer
+{
+    void *data;
+    unsigned handle;
+    uint64_t map_handle;
+    unsigned map_count;
+    uint32_t size;
+};
+
+static int
+vmw_ioctl_get_param(struct vmw_driver *vmw, uint32_t param, uint64_t *out)
+{
+    struct drm_vmw_getparam_arg gp_arg;
+    int ret;
+
+    memset(&gp_arg, 0, sizeof(gp_arg));
+    gp_arg.param = param;
+    ret = drmCommandWriteRead(vmw->fd, DRM_VMW_GET_PARAM,
+           &gp_arg, sizeof(gp_arg));
+
+    if (ret == 0) {
+       *out = gp_arg.value;
+    }
+
+    return ret;
+}
+
+int
+vmw_ioctl_supports_streams(struct vmw_driver *vmw)
+{
+    uint64_t value;
+    int ret;
+
+    ret = vmw_ioctl_get_param(vmw, DRM_VMW_PARAM_NUM_STREAMS, &value);
+    if (ret)
+       return ret;
+
+    return value ? 0 : -ENOSYS;
+}
+
+int
+vmw_ioctl_num_streams(struct vmw_driver *vmw,
+                     uint32_t *ntot, uint32_t *nfree)
+{
+    uint64_t v1, v2;
+    int ret;
+
+    ret = vmw_ioctl_get_param(vmw, DRM_VMW_PARAM_NUM_STREAMS, &v1);
+    if (ret)
+       return ret;
+
+    ret = vmw_ioctl_get_param(vmw, DRM_VMW_PARAM_NUM_FREE_STREAMS, &v2);
+    if (ret)
+       return ret;
+
+    *ntot = (uint32_t)v1;
+    *nfree = (uint32_t)v2;
+
+    return 0;
+}
+
+int
+vmw_ioctl_claim_stream(struct vmw_driver *vmw, uint32_t *out)
+{
+    struct drm_vmw_stream_arg s_arg;
+    int ret;
+
+    ret = drmCommandRead(vmw->fd, DRM_VMW_CLAIM_STREAM,
+                        &s_arg, sizeof(s_arg));
+
+    if (ret)
+       return -1;
+
+    *out = s_arg.stream_id;
+    return 0;
+}
+
+int
+vmw_ioctl_unref_stream(struct vmw_driver *vmw, uint32_t stream_id)
+{
+    struct drm_vmw_stream_arg s_arg;
+    int ret;
+
+    memset(&s_arg, 0, sizeof(s_arg));
+    s_arg.stream_id = stream_id;
+
+    ret = drmCommandRead(vmw->fd, DRM_VMW_CLAIM_STREAM,
+                        &s_arg, sizeof(s_arg));
+
+    return 0;
+}
+
+int
+vmw_ioctl_cursor_bypass(struct vmw_driver *vmw, int xhot, int yhot)
+{
+    struct drm_vmw_cursor_bypass_arg arg;
+    int ret;
+
+    memset(&arg, 0, sizeof(arg));
+    arg.flags = DRM_VMW_CURSOR_BYPASS_ALL;
+    arg.xhot = xhot;
+    arg.yhot = yhot;
+
+    ret = drmCommandWrite(vmw->fd, DRM_VMW_CURSOR_BYPASS,
+                         &arg, sizeof(arg));
+
+    return ret;
+}
+
+struct vmw_dma_buffer *
+vmw_ioctl_buffer_create(struct vmw_driver *vmw, uint32_t size, unsigned *handle)
+{
+    struct vmw_dma_buffer *buf;
+    union drm_vmw_alloc_dmabuf_arg arg;
+    struct drm_vmw_alloc_dmabuf_req *req = &arg.req;
+    struct drm_vmw_dmabuf_rep *rep = &arg.rep;
+    int ret;
+
+    buf = xcalloc(1, sizeof(*buf));
+    if (!buf)
+       goto err;
+
+    memset(&arg, 0, sizeof(arg));
+    req->size = size;
+    do {
+       ret = drmCommandWriteRead(vmw->fd, DRM_VMW_ALLOC_DMABUF, &arg, sizeof(arg));
+    } while (ret == -ERESTART);
+
+    if (ret) {
+       debug_printf("IOCTL failed %d: %s\n", ret, strerror(-ret));
+       goto err_free;
+    }
+
+
+    buf->data = NULL;
+    buf->handle = rep->handle;
+    buf->map_handle = rep->map_handle;
+    buf->map_count = 0;
+    buf->size = size;
+
+    *handle = rep->handle;
+
+    return buf;
+
+err_free:
+    xfree(buf);
+err:
+    return NULL;
+}
+
+void
+vmw_ioctl_buffer_destroy(struct vmw_driver *vmw, struct vmw_dma_buffer *buf) 
+{ 
+    struct drm_vmw_unref_dmabuf_arg arg; 
+
+    if (buf->data) { 
+       munmap(buf->data, buf->size); 
+       buf->data = NULL; 
+    } 
+
+    memset(&arg, 0, sizeof(arg)); 
+    arg.handle = buf->handle; 
+    drmCommandWrite(vmw->fd, DRM_VMW_UNREF_DMABUF, &arg, sizeof(arg)); 
+
+    xfree(buf); 
+} 
+
+void *
+vmw_ioctl_buffer_map(struct vmw_driver *vmw, struct vmw_dma_buffer *buf)
+{
+    void *map;
+
+    if (buf->data == NULL) {
+       map = mmap(NULL, buf->size, PROT_READ | PROT_WRITE, MAP_SHARED,
+                  vmw->fd, buf->map_handle);
+       if (map == MAP_FAILED) {
+           debug_printf("%s: Map failed.\n", __FUNCTION__);
+           return NULL;
+       }
+
+       buf->data = map;
+    }
+
+    ++buf->map_count;
+
+    return buf->data;
+}
+
+void
+vmw_ioctl_buffer_unmap(struct vmw_driver *vmw, struct vmw_dma_buffer *buf)
+{
+    --buf->map_count;
+}
diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_screen.c b/src/gallium/winsys/drm/vmware/xorg/vmw_screen.c
new file mode 100644 (file)
index 0000000..7c9757c
--- /dev/null
@@ -0,0 +1,178 @@
+/**********************************************************
+ * 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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+/**
+ * @file
+ * Contains the init code for the VMware Xorg driver.
+ *
+ * @author Jakob Bornecrantz <jakob@vmware.com>
+ */
+
+#include "vmw_hook.h"
+#include "vmw_driver.h"
+
+#include "cursorstr.h"
+
+/* modified version of crtc functions */
+xf86CrtcFuncsRec vmw_screen_crtc_funcs;
+
+static void
+vmw_screen_cursor_load_argb(xf86CrtcPtr crtc, CARD32 *image)
+{
+    struct vmw_driver *vmw = modesettingPTR(crtc->scrn)->winsys_priv;
+    xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
+    xf86CrtcFuncsPtr funcs = vmw->cursor_priv;
+    CursorPtr c = config->cursor;
+
+    /* Run the ioctl before uploading the image */
+    vmw_ioctl_cursor_bypass(vmw, c->bits->xhot, c->bits->yhot);
+
+    funcs->load_cursor_argb(crtc, image);
+}
+
+static void
+vmw_screen_cursor_init(ScrnInfoPtr pScrn, struct vmw_driver *vmw)
+{
+    xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+    int i;
+
+    /* XXX assume that all crtc's have the same function struct */
+
+    /* Save old struct need to call the old functions as well */
+    vmw->cursor_priv = (void*)(config->crtc[0]->funcs);
+    memcpy(&vmw_screen_crtc_funcs, vmw->cursor_priv, sizeof(xf86CrtcFuncsRec));
+    vmw_screen_crtc_funcs.load_cursor_argb = vmw_screen_cursor_load_argb;
+
+    for (i = 0; i < config->num_crtc; i++)
+       config->crtc[i]->funcs = &vmw_screen_crtc_funcs;
+}
+
+static void
+vmw_screen_cursor_close(ScrnInfoPtr pScrn, struct vmw_driver *vmw)
+{
+    xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+    int i;
+
+    vmw_ioctl_cursor_bypass(vmw, 0, 0);
+
+    for (i = 0; i < config->num_crtc; i++)
+       config->crtc[i]->funcs = vmw->cursor_priv;
+}
+
+static Bool
+vmw_screen_init(ScrnInfoPtr pScrn)
+{
+    modesettingPtr ms = modesettingPTR(pScrn);
+    struct vmw_driver *vmw;
+
+    vmw = xnfcalloc(sizeof(*vmw), 1);
+    if (!vmw)
+       return FALSE;
+
+    vmw->fd = ms->fd;
+    ms->winsys_priv = vmw;
+
+    vmw_screen_cursor_init(pScrn, vmw);
+
+    /* if gallium is used then we don't need to do anything more. */
+    if (ms->screen)
+       return TRUE;
+
+    vmw_video_init(pScrn, vmw);
+
+    return TRUE;
+}
+
+static Bool
+vmw_screen_close(ScrnInfoPtr pScrn)
+{
+    modesettingPtr ms = modesettingPTR(pScrn);
+    struct vmw_driver *vmw = vmw_driver(pScrn);
+
+    if (!vmw)
+       return TRUE;
+
+    vmw_screen_cursor_close(pScrn, vmw);
+
+    vmw_video_close(pScrn, vmw);
+
+    ms->winsys_priv = NULL;
+    xfree(vmw);
+
+    return TRUE;
+}
+
+static Bool
+vmw_screen_enter_vt(ScrnInfoPtr pScrn)
+{
+    debug_printf("%s: enter\n", __func__);
+
+    return TRUE;
+}
+
+static Bool
+vmw_screen_leave_vt(ScrnInfoPtr pScrn)
+{
+    struct vmw_driver *vmw = vmw_driver(pScrn);
+
+    debug_printf("%s: enter\n", __func__);
+
+    vmw_video_stop_all(pScrn, vmw);
+
+    return TRUE;
+}
+
+/*
+ * Functions for setting up hooks into the xorg state tracker
+ */
+
+static Bool (*vmw_screen_pre_init_saved)(ScrnInfoPtr pScrn, int flags) = NULL;
+
+static Bool
+vmw_screen_pre_init(ScrnInfoPtr pScrn, int flags)
+{
+    modesettingPtr ms;
+
+    pScrn->PreInit = vmw_screen_pre_init_saved;
+    if (!pScrn->PreInit(pScrn, flags))
+       return FALSE;
+
+    ms = modesettingPTR(pScrn);
+    ms->winsys_screen_init = vmw_screen_init;
+    ms->winsys_screen_close = vmw_screen_close;
+    ms->winsys_enter_vt = vmw_screen_enter_vt;
+    ms->winsys_leave_vt = vmw_screen_leave_vt;
+
+    return TRUE;
+}
+
+void
+vmw_screen_set_functions(ScrnInfoPtr pScrn)
+{
+    assert(!vmw_screen_pre_init_saved);
+
+    vmw_screen_pre_init_saved = pScrn->PreInit;
+    pScrn->PreInit = vmw_screen_pre_init;
+}
diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_video.c b/src/gallium/winsys/drm/vmware/xorg/vmw_video.c
new file mode 100644 (file)
index 0000000..b065b96
--- /dev/null
@@ -0,0 +1,1068 @@
+/*
+ * Copyright 2007 by VMware, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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 HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/*
+ * vmwarevideo.c --
+ *
+ *      Xv extension support.
+ *      See http://www.xfree86.org/current/DESIGN16.html
+ *
+ */
+
+
+#include "xf86xv.h"
+#include "fourcc.h"
+
+#include "pipe/p_compiler.h"
+/*
+ * We can't incude svga_types.h due to conflicting types for Bool.
+ */
+typedef int64_t int64;
+typedef uint64_t uint64;
+
+typedef int32_t int32;
+typedef uint32_t uint32;
+
+typedef int16_t int16;
+typedef uint16_t uint16;
+
+typedef int8_t int8;
+typedef uint8_t uint8;
+
+#include "svga/include/svga_reg.h"
+#include "svga/include/svga_escape.h"
+#include "svga/include/svga_overlay.h"
+
+#include "vmw_driver.h"
+
+#include <X11/extensions/Xv.h>
+
+#include "xf86drm.h"
+#include "../core/vmwgfx_drm.h"
+
+#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE)
+
+/*
+ * Number of videos that can be played simultaneously
+ */
+#define VMWARE_VID_NUM_PORTS 1
+
+/*
+ * Using a dark shade as the default colorKey
+ */
+#define VMWARE_VIDEO_COLORKEY 0x100701
+
+/*
+ * Maximum dimensions
+ */
+#define VMWARE_VID_MAX_WIDTH    2048
+#define VMWARE_VID_MAX_HEIGHT   2048
+
+#define VMWARE_VID_NUM_ENCODINGS 1
+static XF86VideoEncodingRec vmwareVideoEncodings[] =
+{
+    {
+       0,
+       "XV_IMAGE",
+       VMWARE_VID_MAX_WIDTH, VMWARE_VID_MAX_HEIGHT,
+       {1, 1}
+    }
+};
+
+#define VMWARE_VID_NUM_FORMATS 2
+static XF86VideoFormatRec vmwareVideoFormats[] =
+{
+    { 16, TrueColor},
+    { 24, TrueColor}
+};
+
+#define VMWARE_VID_NUM_IMAGES 3
+static XF86ImageRec vmwareVideoImages[] =
+{
+    XVIMAGE_YV12,
+    XVIMAGE_YUY2,
+    XVIMAGE_UYVY
+};
+
+#define VMWARE_VID_NUM_ATTRIBUTES 2
+static XF86AttributeRec vmwareVideoAttributes[] =
+{
+    {
+        XvGettable | XvSettable,
+        0x000000,
+        0xffffff,
+        "XV_COLORKEY"
+    },
+    {
+        XvGettable | XvSettable,
+        0,
+        1,
+        "XV_AUTOPAINT_COLORKEY"
+    }
+};
+
+/*
+ * Video frames are stored in a circular list of buffers.
+ * Must be power or two, See vmw_video_port_play.
+ */
+#define VMWARE_VID_NUM_BUFFERS 1
+
+/*
+ * Defines the structure used to hold and pass video data to the host
+ */
+struct vmw_video_buffer
+{
+    unsigned handle;
+    int size;
+    void *data;
+    void *extra_data;
+    struct vmw_dma_buffer *buf;
+};
+
+
+/**
+ * Structure representing a single video stream, aka port.
+ *
+ * Ports maps one to one to a SVGA stream. Port is just
+ * what Xv calls a SVGA stream.
+ */
+struct vmw_video_port
+{
+    /*
+     * Function prototype same as XvPutImage.
+     *
+     * This is either set to vmw_video_port_init or vmw_video_port_play.
+     * At init this function is set to port_init. In port_init we set it
+     * to port_play and call it, after initializing the struct.
+     */
+    int (*play)(ScrnInfoPtr, struct vmw_video_port *,
+                short, short, short, short, short,
+                short, short, short, int, unsigned char*,
+                short, short, RegionPtr);
+
+    /* values to go into the SVGAOverlayUnit */
+    uint32 streamId;
+    uint32 colorKey;
+    uint32 flags;
+
+    /* round robin of buffers */
+    unsigned currBuf;
+    struct vmw_video_buffer bufs[VMWARE_VID_NUM_BUFFERS];
+
+    /* properties that applies to all buffers */
+    int size;
+    int pitches[3];
+    int offsets[3];
+
+    /* things for X */
+    RegionRec clipBoxes;
+    Bool isAutoPaintColorkey;
+};
+
+
+/**
+ * Structure holding all the infromation for video.
+ */
+struct vmw_video_private
+{
+    int fd;
+
+    /** ports */
+    struct vmw_video_port port[VMWARE_VID_NUM_PORTS];
+
+    /** Used to store port pointers pointers */
+    DevUnion port_ptr[VMWARE_VID_NUM_PORTS];
+};
+
+
+/*
+ * Callback functions exported to Xv, prefixed with vmw_xv_*.
+ */
+static int vmw_xv_put_image(ScrnInfoPtr pScrn, short src_x, short src_y,
+                            short drw_x, short drw_y, short src_w, short src_h,
+                            short drw_w, short drw_h, int image,
+                            unsigned char *buf, short width, short height,
+                            Bool sync, RegionPtr clipBoxes, pointer data,
+                            DrawablePtr dst);
+static void vmw_xv_stop_video(ScrnInfoPtr pScrn, pointer data, Bool Cleanup);
+static int vmw_xv_query_image_attributes(ScrnInfoPtr pScrn, int format,
+                                         unsigned short *width,
+                                         unsigned short *height, int *pitches,
+                                         int *offsets);
+static int vmw_xv_set_port_attribute(ScrnInfoPtr pScrn, Atom attribute,
+                                     INT32 value, pointer data);
+static int vmw_xv_get_port_attribute(ScrnInfoPtr pScrn, Atom attribute,
+                                     INT32 *value, pointer data);
+static void vmw_xv_query_best_size(ScrnInfoPtr pScrn, Bool motion,
+                                short vid_w, short vid_h, short drw_w,
+                                short drw_h, unsigned int *p_w,
+                                unsigned int *p_h, pointer data);
+
+
+/*
+ * Local functions.
+ */
+static XF86VideoAdaptorPtr vmw_video_init_adaptor(ScrnInfoPtr pScrn, struct vmw_driver *vmw);
+
+static int vmw_video_port_init(ScrnInfoPtr pScrn,
+                               struct vmw_video_port *port,
+                               short src_x, short src_y, short drw_x,
+                               short drw_y, short src_w, short src_h,
+                               short drw_w, short drw_h, int format,
+                               unsigned char *buf, short width,
+                               short height, RegionPtr clipBoxes);
+static int vmw_video_port_play(ScrnInfoPtr pScrn, struct vmw_video_port *port,
+                               short src_x, short src_y, short drw_x,
+                               short drw_y, short src_w, short src_h,
+                               short drw_w, short drw_h, int format,
+                               unsigned char *buf, short width,
+                               short height, RegionPtr clipBoxes);
+static void vmw_video_port_cleanup(ScrnInfoPtr pScrn, struct vmw_video_port *port);
+
+static int vmw_video_buffer_alloc(struct vmw_driver *vmw, int size,
+                                  struct vmw_video_buffer *out);
+static int vmw_video_buffer_free(struct vmw_driver *vmw,
+                                 struct vmw_video_buffer *out);
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_video_init --
+ *
+ *    Initializes Xv support.
+ *
+ * Results:
+ *    TRUE on success, FALSE on error.
+ *
+ * Side effects:
+ *    Xv support is initialized. Memory is allocated for all supported
+ *    video streams.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+Bool
+vmw_video_init(ScrnInfoPtr pScrn, struct vmw_driver *vmw)
+{
+    ScreenPtr pScreen = pScrn->pScreen;
+    XF86VideoAdaptorPtr *overlayAdaptors, *newAdaptors = NULL;
+    XF86VideoAdaptorPtr newAdaptor = NULL;
+    int numAdaptors;
+    unsigned int ntot, nfree;
+
+    debug_printf("%s: enter\n", __func__);
+
+    if (vmw_ioctl_num_streams(vmw, &ntot, &nfree) != 0) {
+        debug_printf("No stream ioctl support\n");
+        return FALSE;
+    }
+
+    if (nfree == 0) {
+        debug_printf("No free streams\n");
+        return FALSE;
+    }
+
+    numAdaptors = xf86XVListGenericAdaptors(pScrn, &overlayAdaptors);
+
+    newAdaptor = vmw_video_init_adaptor(pScrn, vmw);
+    if (!newAdaptor) {
+        debug_printf("Failed to initialize Xv extension\n");
+        return FALSE;
+    }
+
+    if (!numAdaptors) {
+        numAdaptors = 1;
+        overlayAdaptors = &newAdaptor;
+    } else {
+         newAdaptors = xalloc((numAdaptors + 1) *
+                              sizeof(XF86VideoAdaptorPtr*));
+         if (!newAdaptors) {
+            xf86XVFreeVideoAdaptorRec(newAdaptor);
+            return FALSE;
+         }
+
+         memcpy(newAdaptors, overlayAdaptors,
+                numAdaptors * sizeof(XF86VideoAdaptorPtr));
+         newAdaptors[numAdaptors++] = newAdaptor;
+         overlayAdaptors = newAdaptors;
+    }
+
+    if (!xf86XVScreenInit(pScreen, overlayAdaptors, numAdaptors)) {
+        debug_printf("Failed to initialize Xv extension\n");
+        xf86XVFreeVideoAdaptorRec(newAdaptor);
+        return FALSE;
+    }
+
+    if (newAdaptors) {
+        xfree(newAdaptors);
+    }
+
+    debug_printf("Initialized VMware Xv extension successfully\n");
+
+    return TRUE;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_video_close --
+ *
+ *    Unitializes video.
+ *
+ * Results:
+ *    TRUE.
+ *
+ * Side effects:
+ *    vmw->video_priv = NULL
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+Bool
+vmw_video_close(ScrnInfoPtr pScrn, struct vmw_driver *vmw)
+{
+    struct vmw_video_private *video;
+    int i;
+
+    debug_printf("%s: enter\n", __func__);
+
+    video = vmw->video_priv;
+    if (!video)
+       return TRUE;
+
+    for (i = 0; i < VMWARE_VID_NUM_PORTS; ++i) {
+       /* make sure the port is stoped as well */
+       vmw_xv_stop_video(pScrn, &video->port[i], TRUE);
+       vmw_ioctl_unref_stream(vmw, video->port[i].streamId);
+    }
+
+    /* XXX: I'm sure this function is missing code for turning off Xv */
+
+    free(vmw->video_priv);
+    vmw->video_priv = NULL;
+
+    return TRUE;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_video_stop_all --
+ *
+ *    Stop all video streams from playing.
+ *
+ * Results:
+ *    None.
+ *
+ * Side effects:
+ *    All buffers are freed.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+void vmw_video_stop_all(ScrnInfoPtr pScrn, struct vmw_driver *vmw)
+{
+    struct vmw_video_private *video = vmw->video_priv;
+    int i;
+
+    debug_printf("%s: enter\n", __func__);
+
+    if (!video)
+       return;
+
+    for (i = 0; i < VMWARE_VID_NUM_PORTS; ++i) {
+       vmw_xv_stop_video(pScrn, &video->port[i], TRUE);
+    }
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_video_init_adaptor --
+ *
+ *    Initializes a XF86VideoAdaptor structure with the capabilities and
+ *    functions supported by this video driver.
+ *
+ * Results:
+ *    On success initialized XF86VideoAdaptor struct or NULL on error
+ *
+ * Side effects:
+ *    None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static XF86VideoAdaptorPtr
+vmw_video_init_adaptor(ScrnInfoPtr pScrn, struct vmw_driver *vmw)
+{
+    XF86VideoAdaptorPtr adaptor;
+    struct vmw_video_private *video;
+    int i;
+
+    debug_printf("%s: enter \n", __func__);
+
+    adaptor = xf86XVAllocateVideoAdaptorRec(pScrn);
+    if (!adaptor) {
+        debug_printf("Not enough memory\n");
+        return NULL;
+    }
+
+    video = xcalloc(1, sizeof(*video));
+    if (!video) {
+        debug_printf("Not enough memory.\n");
+        xf86XVFreeVideoAdaptorRec(adaptor);
+        return NULL;
+    }
+
+    vmw->video_priv = video;
+
+    adaptor->type = XvInputMask | XvImageMask | XvWindowMask;
+    adaptor->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
+    adaptor->name = "VMware Video Engine";
+    adaptor->nEncodings = VMWARE_VID_NUM_ENCODINGS;
+    adaptor->pEncodings = vmwareVideoEncodings;
+    adaptor->nFormats = VMWARE_VID_NUM_FORMATS;
+    adaptor->pFormats = vmwareVideoFormats;
+    adaptor->nPorts = VMWARE_VID_NUM_PORTS;
+    adaptor->pPortPrivates = video->port_ptr;
+
+    for (i = 0; i < VMWARE_VID_NUM_PORTS; ++i) {
+        vmw_ioctl_claim_stream(vmw, &video->port[i].streamId);
+        video->port[i].play = vmw_video_port_init;
+        video->port[i].flags = SVGA_VIDEO_FLAG_COLORKEY;
+        video->port[i].colorKey = VMWARE_VIDEO_COLORKEY;
+        video->port[i].isAutoPaintColorkey = TRUE;
+        adaptor->pPortPrivates[i].ptr = &video->port[i];
+    }
+
+    adaptor->nAttributes = VMWARE_VID_NUM_ATTRIBUTES;
+    adaptor->pAttributes = vmwareVideoAttributes;
+
+    adaptor->nImages = VMWARE_VID_NUM_IMAGES;
+    adaptor->pImages = vmwareVideoImages;
+
+    adaptor->PutVideo = NULL;
+    adaptor->PutStill = NULL;
+    adaptor->GetVideo = NULL;
+    adaptor->GetStill = NULL;
+    adaptor->StopVideo = vmw_xv_stop_video;
+    adaptor->SetPortAttribute = vmw_xv_set_port_attribute;
+    adaptor->GetPortAttribute = vmw_xv_get_port_attribute;
+    adaptor->QueryBestSize = vmw_xv_query_best_size;
+    adaptor->PutImage = vmw_xv_put_image;
+    adaptor->QueryImageAttributes = vmw_xv_query_image_attributes;
+
+    debug_printf("%s: done %p\n", __func__, adaptor);
+
+    return adaptor;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_video_port_init --
+ *
+ *    Initializes a video stream in response to the first PutImage() on a
+ *    video stream. The process goes as follows:
+ *    - Figure out characteristics according to format
+ *    - Allocate offscreen memory
+ *    - Pass on video to Play() functions
+ *
+ * Results:
+ *    Success or XvBadAlloc on failure.
+ *
+ * Side effects:
+ *    Video stream is initialized and its first frame sent to the host
+ *    (done by VideoPlay() function called at the end)
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static int
+vmw_video_port_init(ScrnInfoPtr pScrn, struct vmw_video_port *port,
+                    short src_x, short src_y, short drw_x,
+                    short drw_y, short src_w, short src_h,
+                    short drw_w, short drw_h, int format,
+                    unsigned char *buf, short width,
+                    short height, RegionPtr clipBoxes)
+{
+    struct vmw_driver *vmw = vmw_driver(pScrn);
+    unsigned short w, h;
+    int i, ret;
+
+    debug_printf("\t%s: id %d, format %d\n", __func__, port->streamId, format);
+
+    w = width;
+    h = height;
+    /* init all the format attributes, used for buffers */
+    port->size = vmw_xv_query_image_attributes(pScrn, format, &w, &h,
+                                               port->pitches, port->offsets);
+
+    if (port->size == -1)
+        return XvBadAlloc;
+
+    port->play = vmw_video_port_play;
+
+    for (i = 0; i < VMWARE_VID_NUM_BUFFERS; ++i) {
+       ret = vmw_video_buffer_alloc(vmw, port->size, &port->bufs[i]);
+       if (ret != Success)
+           break;
+    }
+
+    /* Free all allocated buffers on failure */
+    if (ret != Success) {
+       for (--i; i >= 0; --i) {
+           vmw_video_buffer_free(vmw, &port->bufs[i]);
+       }
+       return ret;
+    }
+
+    port->currBuf = 0;
+
+    REGION_COPY(pScrn->pScreen, &port->clipBoxes, clipBoxes);
+
+    if (port->isAutoPaintColorkey)
+        xf86XVFillKeyHelper(pScrn->pScreen, port->colorKey, clipBoxes);
+
+    return port->play(pScrn, port, src_x, src_y, drw_x, drw_y, src_w, src_h,
+                      drw_w, drw_h, format, buf, width, height, clipBoxes);
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_video_port_play --
+ *
+ *    Sends all the attributes associated with the video frame using the
+ *    FIFO ESCAPE mechanism to the host.
+ *
+ * Results:
+ *    Always returns Success.
+ *
+ * Side effects:
+ *    None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static int
+vmw_video_port_play(ScrnInfoPtr pScrn, struct vmw_video_port *port,
+                    short src_x, short src_y, short drw_x,
+                    short drw_y, short src_w, short src_h,
+                    short drw_w, short drw_h, int format,
+                    unsigned char *buf, short width,
+                    short height, RegionPtr clipBoxes)
+{
+    struct vmw_driver *vmw = vmw_driver(pScrn);
+    struct drm_vmw_control_stream_arg arg;
+    unsigned short w, h;
+    int size;
+    int ret;
+
+    debug_printf("\t%s: enter\n", __func__);
+
+    w = width;
+    h = height;
+
+    /* we don't update the ports size */
+    size = vmw_xv_query_image_attributes(pScrn, format, &w, &h,
+                                         port->pitches, port->offsets);
+
+    if (size > port->size) {
+        debug_printf("\t%s: Increase in size of Xv video frame streamId:%d.\n",
+                     __func__, port->streamId);
+        vmw_xv_stop_video(pScrn, port, TRUE);
+        return port->play(pScrn, port, src_x, src_y, drw_x, drw_y, src_w,
+                          src_h, drw_w, drw_h, format, buf, width, height,
+                          clipBoxes);
+    }
+
+    memcpy(port->bufs[port->currBuf].data, buf, port->size);
+
+    memset(&arg, 0, sizeof(arg));
+
+    arg.stream_id = port->streamId;
+    arg.enabled = TRUE;
+    arg.flags = port->flags;
+    arg.color_key = port->colorKey;
+    arg.handle = port->bufs[port->currBuf].handle;
+    arg.format = format;
+    arg.size = port->size;
+    arg.width = w;
+    arg.height = h;
+    arg.src.x = src_x;
+    arg.src.y = src_y;
+    arg.src.w = src_w;
+    arg.src.h = src_h;
+    arg.dst.x = drw_x;
+    arg.dst.y = drw_y;
+    arg.dst.w = drw_w;
+    arg.dst.h = drw_h;
+    arg.pitch[0] = port->pitches[0];
+    arg.pitch[1] = port->pitches[1];
+    arg.pitch[2] = port->pitches[2];
+    arg.offset = 0;
+
+    /*
+     *  Update the clipList and paint the colorkey, if required.
+     */
+    if (!REGION_EQUAL(pScrn->pScreen, &port->clipBoxes, clipBoxes)) {
+        REGION_COPY(pScrn->pScreen, &port->clipBoxes, clipBoxes);
+        if (port->isAutoPaintColorkey) {
+            xf86XVFillKeyHelper(pScrn->pScreen, port->colorKey, clipBoxes);
+        }
+    }
+
+    ret = drmCommandWrite(vmw->fd, DRM_VMW_CONTROL_STREAM, &arg, sizeof(arg));
+    if (ret) {
+       vmw_video_port_cleanup(pScrn, port);
+       return XvBadAlloc;
+    }
+
+    port->currBuf = ++port->currBuf & (VMWARE_VID_NUM_BUFFERS - 1);
+
+    return Success;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_video_port_cleanup --
+ *
+ *    Frees up all resources (if any) taken by a video stream.
+ *
+ * Results:
+ *    None.
+ *
+ * Side effects:
+ *    Same as above.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static void
+vmw_video_port_cleanup(ScrnInfoPtr pScrn, struct vmw_video_port *port)
+{
+    struct vmw_driver *vmw = vmw_driver(pScrn);
+    uint32 id, colorKey, flags;
+    Bool isAutoPaintColorkey;
+    int i;
+
+    debug_printf("\t%s: enter\n", __func__);
+
+    for (i = 0; i < VMWARE_VID_NUM_BUFFERS; i++) {
+       vmw_video_buffer_free(vmw, &port->bufs[i]);
+    }
+
+    /*
+     * reset stream for next video
+     */
+    id = port->streamId;
+    colorKey = port->colorKey;
+    flags = port->flags;
+    isAutoPaintColorkey = port->isAutoPaintColorkey;
+
+    memset(port, 0, sizeof(*port));
+
+    port->streamId = id;
+    port->play = vmw_video_port_init;
+    port->colorKey = colorKey;
+    port->flags = flags;
+    port->isAutoPaintColorkey = isAutoPaintColorkey;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_video_buffer_alloc --
+ *
+ *    Allocates and map a kernel buffer to be used as data storage.
+ *
+ * Results:
+ *    XvBadAlloc on failure, otherwise Success.
+ *
+ * Side effects:
+ *    Calls into the kernel, sets members of out.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static int
+vmw_video_buffer_alloc(struct vmw_driver *vmw, int size,
+                       struct vmw_video_buffer *out)
+{
+    out->buf = vmw_ioctl_buffer_create(vmw, size, &out->handle);
+    if (!out->buf)
+       return XvBadAlloc;
+
+    out->data = vmw_ioctl_buffer_map(vmw, out->buf);
+    if (!out->data) {
+       vmw_ioctl_buffer_destroy(vmw, out->buf);
+
+       out->handle = 0;
+       out->buf = NULL;
+
+       return XvBadAlloc;
+    }
+
+    out->size = size;
+    out->extra_data = xcalloc(1, size);
+
+    debug_printf("\t\t%s: allocated buffer %p of size %i\n", __func__, out, size);
+
+    return Success;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_video_buffer_free --
+ *
+ *    Frees and unmaps an allocated kernel buffer.
+ *
+ * Results:
+ *    Success.
+ *
+ * Side effects:
+ *    Calls into the kernel, sets members of out to 0.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static int
+vmw_video_buffer_free(struct vmw_driver *vmw,
+                      struct vmw_video_buffer *out)
+{
+    if (out->size == 0)
+       return Success;
+
+    xfree(out->extra_data);
+    vmw_ioctl_buffer_unmap(vmw, out->buf);
+    vmw_ioctl_buffer_destroy(vmw, out->buf);
+
+    out->buf = NULL;
+    out->data = NULL;
+    out->handle = 0;
+    out->size = 0;
+
+    debug_printf("\t\t%s: freed buffer %p\n", __func__, out);
+
+    return Success;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_xv_put_image --
+ *
+ *    Main video playback function. It copies the passed data which is in
+ *    the specified format (e.g. FOURCC_YV12) into the overlay.
+ *
+ *    If sync is TRUE the driver should not return from this
+ *    function until it is through reading the data from buf.
+ *
+ * Results:
+ *    Success or XvBadAlloc on failure
+ *
+ * Side effects:
+ *    Video port will be played(initialized if 1st frame) on success
+ *    or will fail on error.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static int
+vmw_xv_put_image(ScrnInfoPtr pScrn, short src_x, short src_y,
+                 short drw_x, short drw_y, short src_w, short src_h,
+                 short drw_w, short drw_h, int format,
+                 unsigned char *buf, short width, short height,
+                 Bool sync, RegionPtr clipBoxes, pointer data,
+                 DrawablePtr dst)
+{
+    struct vmw_driver *vmw = vmw_driver(pScrn);
+    struct vmw_video_port *port = data;
+
+    debug_printf("%s: enter (%u, %u) (%ux%u) (%u, %u) (%ux%u) (%ux%u)\n", __func__,
+                src_x, src_y, src_w, src_h,
+                drw_x, drw_y, drw_w, drw_h,
+                width, height);
+
+    if (!vmw->video_priv)
+        return XvBadAlloc;
+
+    return port->play(pScrn, port, src_x, src_y, drw_x, drw_y, src_w, src_h,
+                      drw_w, drw_h, format, buf, width, height, clipBoxes);
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_xv_stop_video --
+ *
+ *    Called when we should stop playing video for a particular stream. If
+ *    Cleanup is FALSE, the "stop" operation is only temporary, and thus we
+ *    don't do anything. If Cleanup is TRUE we kill the video port by
+ *    sending a message to the host and freeing up the stream.
+ *
+ * Results:
+ *    None.
+ *
+ * Side effects:
+ *    See above.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static void
+vmw_xv_stop_video(ScrnInfoPtr pScrn, pointer data, Bool cleanup)
+{
+    struct vmw_driver *vmw = vmw_driver(pScrn);
+    struct vmw_video_port *port = data;
+    struct drm_vmw_control_stream_arg arg;
+    int ret;
+
+    debug_printf("%s: cleanup is %s\n", __func__, cleanup ? "TRUE" : "FALSE");
+
+    if (!vmw->video_priv)
+        return;
+
+    if (!cleanup)
+        return;
+
+
+    memset(&arg, 0, sizeof(arg));
+    arg.stream_id = port->streamId;
+    arg.enabled = FALSE;
+
+    ret = drmCommandWrite(vmw->fd, DRM_VMW_CONTROL_STREAM, &arg, sizeof(arg));
+    assert(ret == 0);
+
+    vmw_video_port_cleanup(pScrn, port);
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_xv_query_image_attributes --
+ *
+ *    From the spec: This function is called to let the driver specify how data
+ *    for a particular image of size width by height should be stored.
+ *    Sometimes only the size and corrected width and height are needed. In
+ *    that case pitches and offsets are NULL.
+ *
+ * Results:
+ *    The size of the memory required for the image, or -1 on error.
+ *
+ * Side effects:
+ *    None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static int
+vmw_xv_query_image_attributes(ScrnInfoPtr pScrn, int format,
+                              unsigned short *width, unsigned short *height,
+                              int *pitches, int *offsets)
+{
+    INT32 size, tmp;
+
+    if (*width > VMWARE_VID_MAX_WIDTH) {
+        *width = VMWARE_VID_MAX_WIDTH;
+    }
+    if (*height > VMWARE_VID_MAX_HEIGHT) {
+        *height = VMWARE_VID_MAX_HEIGHT;
+    }
+
+    *width = (*width + 1) & ~1;
+    if (offsets != NULL) {
+        offsets[0] = 0;
+    }
+
+    switch (format) {
+       case FOURCC_YV12:
+           *height = (*height + 1) & ~1;
+           size = (*width + 3) & ~3;
+           if (pitches) {
+               pitches[0] = size;
+           }
+           size *= *height;
+           if (offsets) {
+               offsets[1] = size;
+           }
+           tmp = ((*width >> 1) + 3) & ~3;
+           if (pitches) {
+                pitches[1] = pitches[2] = tmp;
+           }
+           tmp *= (*height >> 1);
+           size += tmp;
+           if (offsets) {
+               offsets[2] = size;
+           }
+           size += tmp;
+           break;
+       case FOURCC_UYVY:
+       case FOURCC_YUY2:
+           size = *width * 2;
+           if (pitches) {
+               pitches[0] = size;
+           }
+           size *= *height;
+           break;
+       default:
+           debug_printf("Query for invalid video format %d\n", format);
+           return -1;
+    }
+    return size;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_xv_set_port_attribute --
+ *
+ *    From the spec: A port may have particular attributes such as colorKey, hue,
+ *    saturation, brightness or contrast. Xv clients set these
+ *    attribute values by sending attribute strings (Atoms) to the server.
+ *
+ * Results:
+ *    Success if the attribute exists and XvBadAlloc otherwise.
+ *
+ * Side effects:
+ *    The respective attribute gets the new value.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static int
+vmw_xv_set_port_attribute(ScrnInfoPtr pScrn, Atom attribute,
+                          INT32 value, pointer data)
+{
+    struct vmw_video_port *port = data;
+    Atom xvColorKey = MAKE_ATOM("XV_COLORKEY");
+    Atom xvAutoPaint = MAKE_ATOM("XV_AUTOPAINT_COLORKEY");
+
+    if (attribute == xvColorKey) {
+        debug_printf("%s: Set colorkey:0x%x\n", __func__, (unsigned)value);
+        port->colorKey = value;
+    } else if (attribute == xvAutoPaint) {
+        debug_printf("%s: Set autoPaint: %s\n", __func__, value? "TRUE": "FALSE");
+        port->isAutoPaintColorkey = value;
+    } else {
+        return XvBadAlloc;
+    }
+
+    return Success;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_xv_get_port_attribute --
+ *
+ *    From the spec: A port may have particular attributes such as hue,
+ *    saturation, brightness or contrast. Xv clients get these
+ *    attribute values by sending attribute strings (Atoms) to the server
+ *
+ * Results:
+ *    Success if the attribute exists and XvBadAlloc otherwise.
+ *
+ * Side effects:
+ *    "value" contains the requested attribute on success.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static int
+vmw_xv_get_port_attribute(ScrnInfoPtr pScrn, Atom attribute,
+                          INT32 *value, pointer data)
+{
+    struct vmw_video_port *port = data;
+    Atom xvColorKey = MAKE_ATOM("XV_COLORKEY");
+    Atom xvAutoPaint = MAKE_ATOM("XV_AUTOPAINT_COLORKEY");
+
+    if (attribute == xvColorKey) {
+        *value = port->colorKey;
+    } else if (attribute == xvAutoPaint) {
+        *value = port->isAutoPaintColorkey;
+    } else {
+        return XvBadAlloc;
+    }
+
+    return Success;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_xv_query_best_size --
+ *
+ *    From the spec: QueryBestSize provides the client with a way to query what
+ *    the destination dimensions would end up being if they were to request
+ *    that an area vid_w by vid_h from the video stream be scaled to rectangle
+ *    of drw_w by drw_h on the screen. Since it is not expected that all
+ *    hardware will be able to get the target dimensions exactly, it is
+ *    important that the driver provide this function.
+ *
+ *    This function seems to never be called, but to be on the safe side
+ *    we apply the same logic that QueryImageAttributes has for width
+ *    and height.
+ *
+ * Results:
+ *    None.
+ *
+ * Side effects:
+ *    None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static void
+vmw_xv_query_best_size(ScrnInfoPtr pScrn, Bool motion,
+                       short vid_w, short vid_h, short drw_w,
+                       short drw_h, unsigned int *p_w,
+                       unsigned int *p_h, pointer data)
+{
+    *p_w = (drw_w + 1) & ~1;
+    *p_h = drw_h;
+
+    return;
+}
diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c b/src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c
new file mode 100644 (file)
index 0000000..4b20871
--- /dev/null
@@ -0,0 +1,152 @@
+/**********************************************************
+ * Copyright 2008-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, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ *
+ **********************************************************/
+
+/**
+ * @file
+ * Glue file for Xorg State Tracker.
+ *
+ * @author Alan Hourihane <alanh@tungstengraphics.com>
+ * @author Jakob Bornecrantz <wallbraker@gmail.com>
+ */
+
+#include "vmw_hook.h"
+
+static void vmw_xorg_identify(int flags);
+static Bool vmw_xorg_pci_probe(DriverPtr driver,
+                              int entity_num,
+                              struct pci_device *device,
+                              intptr_t match_data);
+
+static const struct pci_id_match vmw_xorg_device_match[] = {
+    {0x15ad, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, 0},
+    {0, 0, 0, 0, 0, 0, 0},
+};
+
+static SymTabRec vmw_xorg_chipsets[] = {
+    {PCI_MATCH_ANY, "VMware SVGA Device"},
+    {-1, NULL}
+};
+
+static PciChipsets vmw_xorg_pci_devices[] = {
+    {PCI_MATCH_ANY, PCI_MATCH_ANY, NULL},
+    {-1, -1, NULL}
+};
+
+static XF86ModuleVersionInfo vmw_xorg_version = {
+    "vmwgfx",
+    MODULEVENDORSTRING,
+    MODINFOSTRING1,
+    MODINFOSTRING2,
+    XORG_VERSION_CURRENT,
+    0, 1, 0, /* major, minor, patch */
+    ABI_CLASS_VIDEODRV,
+    ABI_VIDEODRV_VERSION,
+    MOD_CLASS_VIDEODRV,
+    {0, 0, 0, 0}
+};
+
+/*
+ * Xorg driver exported structures
+ */
+
+_X_EXPORT DriverRec vmwgfx = {
+    1,
+    "vmwgfx",
+    vmw_xorg_identify,
+    NULL,
+    xorg_tracker_available_options,
+    NULL,
+    0,
+    NULL,
+    vmw_xorg_device_match,
+    vmw_xorg_pci_probe
+};
+
+static MODULESETUPPROTO(vmw_xorg_setup);
+
+_X_EXPORT XF86ModuleData vmwgfxModuleData = {
+    &vmw_xorg_version,
+    vmw_xorg_setup,
+    NULL
+};
+
+/*
+ * Xorg driver functions
+ */
+
+static pointer
+vmw_xorg_setup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+    static Bool setupDone = 0;
+
+    /* This module should be loaded only once, but check to be sure.
+     */
+    if (!setupDone) {
+       setupDone = 1;
+       xf86AddDriver(&vmwgfx, module, HaveDriverFuncs);
+
+       /*
+        * The return value must be non-NULL on success even though there
+        * is no TearDownProc.
+        */
+       return (pointer) 1;
+    } else {
+       if (errmaj)
+           *errmaj = LDR_ONCEONLY;
+       return NULL;
+    }
+}
+
+static void
+vmw_xorg_identify(int flags)
+{
+    xf86PrintChipsets("vmwgfx", "Driver for VMware SVGA device",
+                     vmw_xorg_chipsets);
+}
+
+static Bool
+vmw_xorg_pci_probe(DriverPtr driver,
+         int entity_num, struct pci_device *device, intptr_t match_data)
+{
+    ScrnInfoPtr scrn = NULL;
+    EntityInfoPtr entity;
+
+    scrn = xf86ConfigPciEntity(scrn, 0, entity_num, vmw_xorg_pci_devices,
+                              NULL, NULL, NULL, NULL, NULL);
+    if (scrn != NULL) {
+       scrn->driverVersion = 1;
+       scrn->driverName = "vmwgfx";
+       scrn->name = "vmwgfx";
+       scrn->Probe = NULL;
+
+       entity = xf86GetEntityInfo(entity_num);
+
+       /* Use all the functions from the xorg tracker */
+       xorg_tracker_set_functions(scrn);
+
+       vmw_screen_set_functions(scrn);
+    }
+    return scrn != NULL;
+}
index d02f82504781b794a3c91c6aceeaeaf1778ee8ae..599973ce127ce3caacb57e6afe29c0b516dc6de8 100644 (file)
@@ -41,6 +41,7 @@
 #include "pipe/p_state.h"
 #include "pipe/internal/p_winsys_screen.h"
 #include "util/u_memory.h"
+#include "util/u_math.h"
 #include "softpipe/sp_winsys.h"
 #include "softpipe/sp_texture.h"
 
@@ -138,17 +139,6 @@ lookup_context(_EGLContext *ctx)
 }
 
 
-static unsigned int
-bitcount(unsigned int n)
-{
-   unsigned int bits;
-   for (bits = 0; n > 0; n = n >> 1) {
-      bits += (n & 1);
-   }
-   return bits;
-}
-
-
 /**
  * Create the EGLConfigs.  (one per X visual)
  */
@@ -174,9 +164,9 @@ create_configs(struct xlib_egl_display *xdpy, _EGLDisplay *disp)
    for (i = 0; i < num_visuals; i++) {
       _EGLConfig *config = calloc(1, sizeof(_EGLConfig));
       int id = i + 1;
-      int rbits = bitcount(visInfo[i].red_mask);
-      int gbits = bitcount(visInfo[i].green_mask);
-      int bbits = bitcount(visInfo[i].blue_mask);
+      int rbits = util_bitcount(visInfo[i].red_mask);
+      int gbits = util_bitcount(visInfo[i].green_mask);
+      int bbits = util_bitcount(visInfo[i].blue_mask);
       int abits = bbits == 8 ? 8 : 0;
       int zbits = 24;
       int sbits = 8;
index 79ff2cc985d1b5120389fb7b1904ab923c0bb2a1..6ee3ede38cb0d772cb1c5ca4d96dcebfcf89ef15 100644 (file)
@@ -38,6 +38,7 @@
 #include "pipe/internal/p_winsys_screen.h"
 #include "pipe/p_state.h"
 #include "pipe/p_inlines.h"
+#include "util/u_format.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
 
@@ -71,16 +72,6 @@ sw_pipe_buffer(struct pipe_buffer *b)
 }
 
 
-/**
- * Round n up to next multiple.
- */
-static INLINE unsigned
-round_up(unsigned n, unsigned multiple)
-{
-   return (n + multiple - 1) & ~(multiple - 1);
-}
-
-
 static const char *
 get_name(struct pipe_winsys *pws)
 {
@@ -170,13 +161,10 @@ surface_buffer_create(struct pipe_winsys *winsys,
                       unsigned *stride)
 {
    const unsigned alignment = 64;
-   struct pipe_format_block block;
-   unsigned nblocksx, nblocksy;
+   unsigned nblocksy;
 
-   pf_get_block(format, &block);
-   nblocksx = pf_get_nblocksx(&block, width);
-   nblocksy = pf_get_nblocksy(&block, height);
-   *stride = round_up(nblocksx * block.size, alignment);
+   nblocksy = util_format_get_nblocksy(format, height);
+   *stride = align(util_format_get_stride(format, width), alignment);
 
    return winsys->buffer_create(winsys, alignment,
                                 usage,
index 2997f6b79ce4e012fb51af04d87e1c7fa5cdd815..3965bd949f48afb3913d1a3187bdf3a9bc6daead 100644 (file)
@@ -19,11 +19,7 @@ CFLAGS               += -g -Wall -Werror=implicit-function-declaration -fPIC \
 LDFLAGS                += -L${DRMDIR}/lib                              \
                   -L${DRIDIR}/lib                              \
                   -L${GALLIUMDIR}/winsys/drm/nouveau/common    \
-                  -L${GALLIUMDIR}/auxiliary/draw               \
-                  -L${GALLIUMDIR}/auxiliary/tgsi               \
-                  -L${GALLIUMDIR}/auxiliary/translate          \
-                  -L${GALLIUMDIR}/auxiliary/rtasm              \
-                  -L${GALLIUMDIR}/auxiliary/cso_cache          \
+                  -L${GALLIUMDIR}/auxiliary                    \
                   -L${GALLIUMDIR}/drivers/nv04                 \
                   -L${GALLIUMDIR}/drivers/nv10                 \
                   -L${GALLIUMDIR}/drivers/nv20                 \
@@ -31,7 +27,7 @@ LDFLAGS               += -L${DRMDIR}/lib                              \
                   -L${GALLIUMDIR}/drivers/nv40                 \
                   -L${GALLIUMDIR}/drivers/nv50
 
-LIBS           += -lnouveaudrm -ldriclient -ldrm_nouveau -ldrm -lnv04 -lnv10 -lnv20 -lnv30 -lnv40 -lnv50 -ldraw -ltgsi -ltranslate -lrtasm -lcso_cache -lm
+LIBS           += -lnouveaudrm -ldriclient -ldrm_nouveau -ldrm -lnv04 -lnv10 -lnv20 -lnv30 -lnv40 -lnv50 -lgallium -lm
 
 #############################################
 
index 22119f95595582660061af3127d906e983d301f2..b4fa0d67a1b532c7caf522006310718c0cdcd91e 100644 (file)
@@ -39,7 +39,8 @@ struct pipe_screen*
 vl_screen_create(Display *display, int screen);
 
 struct pipe_video_context*
-vl_video_create(struct pipe_screen *screen,
+vl_video_create(Display *display, int screen,
+                struct pipe_screen *p_screen,
                 enum pipe_video_profile profile,
                 enum pipe_video_chroma_format chroma_format,
                 unsigned width, unsigned height);
index cf765ef51a5db214b83bc42e6c74de2f5afa1045..9877660a27695e827b722d050ea6b90cf259c425 100644 (file)
@@ -25,13 +25,7 @@ SOURCES = xsp_winsys.c
 OBJECTS = $(SOURCES:.c=.o) $(TOP)/src/gallium/state_trackers/xorg/xvmc/*.o
 
 LIBS = $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
-       $(TOP)/src/gallium/auxiliary/vl/libvl.a \
-       $(TOP)/src/gallium/auxiliary/tgsi/libtgsi.a \
-       $(TOP)/src/gallium/auxiliary/draw/libdraw.a \
-       $(TOP)/src/gallium/auxiliary/translate/libtranslate.a \
-       $(TOP)/src/gallium/auxiliary/cso_cache/libcso_cache.a \
-       $(TOP)/src/gallium/auxiliary/rtasm/librtasm.a \
-       $(TOP)/src/gallium/auxiliary/util/libutil.a
+       $(TOP)/src/gallium/auxiliary/libgallium.a
 
 .c.o:
        $(CC) -c $(INCLUDES) $(DEFINES) $(CFLAGS) $< -o $@
index 0e5f5a587b440a51d3dfd062c038891e0719362b..f15bcd37b501ec11a144b166d955049c93996896 100644 (file)
@@ -30,6 +30,7 @@
 #include <pipe/internal/p_winsys_screen.h>
 #include <pipe/p_state.h>
 #include <pipe/p_inlines.h>
+#include <util/u_format.h>
 #include <util/u_memory.h>
 #include <util/u_math.h>
 #include <softpipe/sp_winsys.h>
@@ -138,13 +139,10 @@ static struct pipe_buffer* xsp_surface_buffer_create
 )
 {
    const unsigned int ALIGNMENT = 1;
-   struct pipe_format_block block;
-   unsigned nblocksx, nblocksy;
+   unsigned nblocksy;
 
-   pf_get_block(format, &block);
-   nblocksx = pf_get_nblocksx(&block, width);
-   nblocksy = pf_get_nblocksy(&block, height);
-   *stride = align(nblocksx * block.size, ALIGNMENT);
+   nblocksy = util_format_get_nblocksy(format, height);
+   *stride = align(util_format_get_stride(format, width), ALIGNMENT);
 
    return pws->buffer_create(pws, ALIGNMENT, usage,
                              *stride * nblocksy);
@@ -300,7 +298,8 @@ vl_screen_create(Display *display, int screen)
 }
 
 struct pipe_video_context*
-vl_video_create(struct pipe_screen *screen,
+vl_video_create(Display *display, int screen,
+                struct pipe_screen *p_screen,
                 enum pipe_video_profile profile,
                 enum pipe_video_chroma_format chroma_format,
                 unsigned width, unsigned height)
@@ -308,10 +307,10 @@ vl_video_create(struct pipe_screen *screen,
    struct pipe_video_context *vpipe;
    struct xsp_context *xsp_context;
 
-   assert(screen);
+   assert(p_screen);
    assert(width && height);
 
-   vpipe = sp_video_create(screen, profile, chroma_format, width, height);
+   vpipe = sp_video_create(p_screen, profile, chroma_format, width, height);
    if (!vpipe)
       return NULL;
 
index f5e6d36d89c2ae8082c444ce03aac9d0a9806191..4cbc86f3311212596d5e00c0c551efbaefe4e254 100644 (file)
@@ -18,14 +18,20 @@ if env['platform'] == 'windows':
         'ws2_32',
     ])
 
-    if 'llvmpipe' in env['drivers']:
-        sources = ['gdi_llvmpipe_winsys.c']
-        drivers = [llvmpipe]
-        env.Tool('llvm')
-    elif 'softpipe' in env['drivers']:
+    sources = []
+    drivers = []
+
+    if 'softpipe' in env['drivers']:
         sources = ['gdi_softpipe_winsys.c']
         drivers = [softpipe]
-    else:
+
+    if 'llvmpipe' in env['drivers']:
+        env.Tool('llvm')
+        if 'LLVM_VERSION' in env:
+            sources = ['gdi_llvmpipe_winsys.c']
+            drivers = [llvmpipe]
+
+    if not sources or not drivers:
         print 'warning: softpipe or llvmpipe not selected, gdi winsys disabled'
         Return()
     
@@ -36,8 +42,10 @@ if env['platform'] == 'windows':
         
     drivers += [trace]
 
+    env['no_import_lib'] = 1
+
     env.SharedLibrary(
         target ='opengl32',
         source = sources,
-        LIBS = wgl + glapi + mesa + drivers + auxiliaries + env['LIBS'],
+        LIBS = wgl + glapi + mesa + drivers + gallium + glsl + env['LIBS'],
     )
index e8bc0f55ac4d81118167c895f1ef2d0bf498251e..7d076be3a31c5264cb3d2db74069651a0e19c230 100644 (file)
@@ -39,6 +39,7 @@
 #include "pipe/p_format.h"
 #include "pipe/p_context.h"
 #include "pipe/p_inlines.h"
+#include "util/u_format.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
 #include "llvmpipe/lp_winsys.h"
@@ -49,7 +50,6 @@
 struct gdi_llvmpipe_displaytarget
 {
    enum pipe_format format;
-   struct pipe_format_block block;
    unsigned width;
    unsigned height;
    unsigned stride;
@@ -118,16 +118,6 @@ gdi_llvmpipe_displaytarget_destroy(struct llvmpipe_winsys *winsys,
 }
 
 
-/**
- * Round n up to next multiple.
- */
-static INLINE unsigned
-round_up(unsigned n, unsigned multiple)
-{
-   return (n + multiple - 1) & ~(multiple - 1);
-}
-
-
 static struct llvmpipe_displaytarget *
 gdi_llvmpipe_displaytarget_create(struct llvmpipe_winsys *winsys,
                                   enum pipe_format format,
@@ -147,10 +137,10 @@ gdi_llvmpipe_displaytarget_create(struct llvmpipe_winsys *winsys,
    gdt->width = width;
    gdt->height = height;
 
-   bpp = pf_get_bits(format);
-   cpp = pf_get_size(format);
+   bpp = util_format_get_blocksizebits(format);
+   cpp = util_format_get_blocksize(format);
    
-   gdt->stride = round_up(width * cpp, alignment);
+   gdt->stride = align(width * cpp, alignment);
    gdt->size = gdt->stride * height;
    
    gdt->data = align_malloc(gdt->size, alignment);
index 5e0ccf32f48f77bbf6711158505ffebc4b39e892..2ad794c3f0fcfca1d1887d5a5dfe517a2dd3c7f1 100644 (file)
@@ -42,6 +42,7 @@
 #include "pipe/p_format.h"
 #include "pipe/p_context.h"
 #include "pipe/p_inlines.h"
+#include "util/u_format.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
 #include "softpipe/sp_winsys.h"
@@ -151,16 +152,6 @@ gdi_softpipe_user_buffer_create(struct pipe_winsys *winsys,
 }
 
 
-/**
- * Round n up to next multiple.
- */
-static INLINE unsigned
-round_up(unsigned n, unsigned multiple)
-{
-   return (n + multiple - 1) & ~(multiple - 1);
-}
-
-
 static struct pipe_buffer *
 gdi_softpipe_surface_buffer_create(struct pipe_winsys *winsys,
                                    unsigned width, unsigned height,
@@ -170,13 +161,10 @@ gdi_softpipe_surface_buffer_create(struct pipe_winsys *winsys,
                                    unsigned *stride)
 {
    const unsigned alignment = 64;
-   struct pipe_format_block block;
-   unsigned nblocksx, nblocksy;
+   unsigned nblocksy;
 
-   pf_get_block(format, &block);
-   nblocksx = pf_get_nblocksx(&block, width);
-   nblocksy = pf_get_nblocksy(&block, height);
-   *stride = round_up(nblocksx * block.size, alignment);
+   nblocksy = util_format_get_nblocksy(format, height);
+   *stride = align(util_format_get_stride(format, width), alignment);
 
    return winsys->buffer_create(winsys, alignment,
                                 usage,
@@ -283,10 +271,10 @@ gdi_softpipe_present(struct pipe_screen *screen,
 
     memset(&bmi, 0, sizeof(BITMAPINFO));
     bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
-    bmi.bmiHeader.biWidth = texture->stride[surface->level] / pf_get_size(surface->format);
+    bmi.bmiHeader.biWidth = texture->stride[surface->level] / util_format_get_blocksize(surface->format);
     bmi.bmiHeader.biHeight= -(long)surface->height;
     bmi.bmiHeader.biPlanes = 1;
-    bmi.bmiHeader.biBitCount = pf_get_bits(surface->format);
+    bmi.bmiHeader.biBitCount = util_format_get_blocksizebits(surface->format);
     bmi.bmiHeader.biCompression = BI_RGB;
     bmi.bmiHeader.biSizeImage = 0;
     bmi.bmiHeader.biXPelsPerMeter = 0;
index 3dc38a78e451121a03172c5ed56b2c9322459fd3..9482e8f9b11963ef18a61e6ab53b128afceb13e9 100644 (file)
@@ -23,17 +23,14 @@ INCLUDE_DIRS = \
        -I$(TOP)/src/gallium/auxiliary
 
 DEFINES += \
-       -DGALLIUM_SOFTPIPE \
-       -DGALLIUM_TRACE \
-       -DGALLIUM_BRW
+       -DGALLIUM_SOFTPIPE
 #-DGALLIUM_CELL will be defined by the config */
 
 XLIB_WINSYS_SOURCES = \
        xlib.c \
        xlib_cell.c \
        xlib_llvmpipe.c \
-       xlib_softpipe.c \
-       xlib_trace.c 
+       xlib_softpipe.c
 
 
 XLIB_WINSYS_OBJECTS = $(XLIB_WINSYS_SOURCES:.c=.o)
@@ -84,11 +81,11 @@ depend: $(XLIB_WINSYS_SOURCES)
 
 
 install: default
-       $(INSTALL) -d $(INSTALL_DIR)/include/GL
-       $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR)
-       $(INSTALL) -m 644 $(TOP)/include/GL/*.h $(INSTALL_DIR)/include/GL
+       $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GL
+       $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
+       $(INSTALL) -m 644 $(TOP)/include/GL/*.h $(DESTDIR)$(INSTALL_DIR)/include/GL
        @if [ -e $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) ]; then \
-               $(MINSTALL) $(TOP)/$(LIB_DIR)/libGL* $(INSTALL_DIR)/$(LIB_DIR); \
+               $(MINSTALL) $(TOP)/$(LIB_DIR)/libGL* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR); \
        fi
 
 
index 14d4ca7c33b361ddcee6c975ab896ee3da0c9eea..a4dabb7804cca9a361958b7a3b192e17d4f79614 100644 (file)
@@ -3,55 +3,66 @@
 
 Import('*')
 
-if env['platform'] == 'linux' \
-        and 'mesa' in env['statetrackers'] \
-        and set(('softpipe', 'llvmpipe', 'i915simple', 'trace')).intersection(env['drivers']) \
-        and not env['dri']:
-
-    env = env.Clone()
-
-    env.Append(CPPPATH = [
-        '#/src/mesa',
-        '#/src/mesa/main',
-        '#src/gallium/state_trackers/glx/xlib',
-    ])
-
-    env.Append(CPPDEFINES = ['USE_XSHM'])
-
-    sources = [
-        'xlib.c',
-    ]
-
-    drivers = []
-        
-    if 'softpipe' in env['drivers']:
-        env.Append(CPPDEFINES = 'GALLIUM_SOFTPIPE')
-        sources += ['xlib_softpipe.c']
-        drivers += [softpipe]
-
-    if 'llvmpipe' in env['drivers']:
-        env.Tool('llvm')
-        if 'LLVM_VERSION' in env:
-            env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
-            env.Tool('udis86')
-            sources += ['xlib_llvmpipe.c']
-            drivers += [llvmpipe]
-        
-    if 'cell' in env['drivers']:
-        env.Append(CPPDEFINES = 'GALLIUM_CELL')
-        sources += ['xlib_cell.c']
-        drivers += [cell]
-
-    if 'trace' in env['drivers']:
-        env.Append(CPPDEFINES = 'GALLIUM_TRACE')
-        sources += ['xlib_trace.c']
-        drivers += [trace]
-
-    # TODO: write a wrapper function http://www.scons.org/wiki/WrapperFunctions
-    libgl = env.SharedLibrary(
-        target ='GL',
-        source = sources,
-        LIBS = st_xlib + glapi + mesa + drivers + auxiliaries + env['LIBS'],
-    )
+if env['platform'] != 'linux':
+    Return()
 
+if 'mesa' not in env['statetrackers']:
+    print 'warning: Mesa state tracker disabled: skipping build of xlib libGL.so'
+    Return()
+
+if env['dri']:
+    print 'warning: DRI enabled: skipping build of xlib libGL.so'
+    Return()
+
+if 'trace' not in env['drivers']:
+    print 'warning: trace pipe driver disabled: skipping build of xlib libGL.so'
+    Return()
+
+if not set(('softpipe', 'llvmpipe', 'trace')).intersection(env['drivers']):
+    print 'warning: no supported pipe driver: skipping build of xlib libGL.so'
+    Return()
+
+env = env.Clone()
+
+env.Append(CPPPATH = [
+    '#/src/mesa',
+    '#/src/mesa/main',
+    '#src/gallium/state_trackers/glx/xlib',
+])
+
+env.Append(CPPDEFINES = ['USE_XSHM'])
+
+sources = [
+    'xlib.c',
+]
+
+drivers = [trace]
+    
+if 'softpipe' in env['drivers']:
+    env.Append(CPPDEFINES = 'GALLIUM_SOFTPIPE')
+    sources += ['xlib_softpipe.c']
+    drivers += [softpipe]
+
+if 'llvmpipe' in env['drivers']:
+    env.Tool('llvm')
+    if 'LLVM_VERSION' in env:
+        env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
+        env.Tool('udis86')
+        sources += ['xlib_llvmpipe.c']
+        drivers += [llvmpipe]
+    
+if 'cell' in env['drivers']:
+    env.Append(CPPDEFINES = 'GALLIUM_CELL')
+    sources += ['xlib_cell.c']
+    drivers += [cell]
+
+# TODO: write a wrapper function http://www.scons.org/wiki/WrapperFunctions
+libgl = env.SharedLibrary(
+    target ='GL',
+    source = sources,
+    LIBS = st_xlib + glapi + mesa + glsl + drivers + gallium + env['LIBS'],
+)
+
+if not env['dri']:
+    # Only install this libGL.so if DRI not enabled
     env.InstallSharedLibrary(libgl, version=(1, 5))
index 163cc8863cb6f3117d1f87ce480956d6f5234a13..6dbe05f193eb040e0ff03f0d335a56d65ce5f5bd 100644 (file)
@@ -42,7 +42,6 @@
  */
 
 enum mode {
-   MODE_TRACE,
    MODE_CELL,
    MODE_LLVMPIPE,
    MODE_SOFTPIPE
@@ -51,9 +50,6 @@ enum mode {
 
 static enum mode get_mode()
 {
-   if (getenv("XMESA_TRACE"))
-      return MODE_TRACE;
-
 #ifdef GALLIUM_CELL
    if (!getenv("GALLIUM_NOCELL")) 
       return MODE_CELL;
@@ -73,11 +69,6 @@ static void _init( void )
    enum mode xlib_mode = get_mode();
 
    switch (xlib_mode) {
-   case MODE_TRACE:
-#if defined(GALLIUM_TRACE) && defined(GALLIUM_SOFTPIPE)
-      xmesa_set_driver( &xlib_trace_driver );
-#endif
-      break;
    case MODE_CELL:
 #if defined(GALLIUM_CELL)
       xmesa_set_driver( &xlib_cell_driver );
index f0855035f77a30d8276e57fdc88b5bb04c98a5a8..8e091d0c0842043b8a033564e5a0395108c348df 100644 (file)
@@ -5,7 +5,6 @@
 #include "pipe/p_compiler.h"
 #include "xm_winsys.h"
 
-extern struct xm_driver xlib_trace_driver;
 extern struct xm_driver xlib_softpipe_driver;
 extern struct xm_driver xlib_llvmpipe_driver;
 extern struct xm_driver xlib_cell_driver;
diff --git a/src/gallium/winsys/xlib/xlib_brw_context.c b/src/gallium/winsys/xlib/xlib_brw_context.c
new file mode 100644 (file)
index 0000000..fc9addd
--- /dev/null
@@ -0,0 +1,209 @@
+/**************************************************************************
+ * 
+ * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * 
+ **************************************************************************/
+
+/*
+ * Authors:
+ *   Keith Whitwell
+ *   Brian Paul
+ */
+
+
+/* #include "glxheader.h" */
+/* #include "xmesaP.h" */
+
+#include "pipe/internal/p_winsys_screen.h"
+#include "pipe/p_inlines.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+#include "i965simple/brw_winsys.h"
+#include "xlib_brw_aub.h"
+#include "xlib_brw.h"
+
+
+
+
+#define XBCWS_BATCHBUFFER_SIZE 1024
+
+
+/* The backend to the brw driver (ie struct brw_winsys) is actually a
+ * per-context entity.
+ */
+struct xlib_brw_context_winsys {
+   struct brw_winsys brw_context_winsys;   /**< batch buffer funcs */
+   struct aub_context *aub;
+                         
+   struct pipe_winsys *pipe_winsys;
+
+   unsigned batch_data[XBCWS_BATCHBUFFER_SIZE];
+   unsigned batch_nr;
+   unsigned batch_size;
+   unsigned batch_alloc;
+};
+
+
+/* Turn a brw_winsys into an xlib_brw_context_winsys:
+ */
+static inline struct xlib_brw_context_winsys *
+xlib_brw_context_winsys( struct brw_winsys *sws )
+{
+   return (struct xlib_brw_context_winsys *)sws;
+}
+
+
+/* Simple batchbuffer interface:
+ */
+
+static unsigned *xbcws_batch_start( struct brw_winsys *sws,
+                                        unsigned dwords,
+                                        unsigned relocs )
+{
+   struct xlib_brw_context_winsys *xbcws = xlib_brw_context_winsys(sws);
+
+   if (xbcws->batch_size < xbcws->batch_nr + dwords)
+      return NULL;
+
+   xbcws->batch_alloc = xbcws->batch_nr + dwords;
+   return (void *)1;                   /* not a valid pointer! */
+}
+
+static void xbcws_batch_dword( struct brw_winsys *sws,
+                                   unsigned dword )
+{
+   struct xlib_brw_context_winsys *xbcws = xlib_brw_context_winsys(sws);
+
+   assert(xbcws->batch_nr < xbcws->batch_alloc);
+   xbcws->batch_data[xbcws->batch_nr++] = dword;
+}
+
+static void xbcws_batch_reloc( struct brw_winsys *sws,
+                            struct pipe_buffer *buf,
+                            unsigned access_flags,
+                            unsigned delta )
+{
+   struct xlib_brw_context_winsys *xbcws = xlib_brw_context_winsys(sws);
+
+   assert(xbcws->batch_nr < xbcws->batch_alloc);
+   xbcws->batch_data[xbcws->batch_nr++] = 
+      ( xlib_brw_get_buffer_offset( NULL, buf, access_flags ) +
+        delta );
+}
+
+static void xbcws_batch_end( struct brw_winsys *sws )
+{
+   struct xlib_brw_context_winsys *xbcws = xlib_brw_context_winsys(sws);
+
+   assert(xbcws->batch_nr <= xbcws->batch_alloc);
+   xbcws->batch_alloc = 0;
+}
+
+static void xbcws_batch_flush( struct brw_winsys *sws,
+                                   struct pipe_fence_handle **fence )
+{
+   struct xlib_brw_context_winsys *xbcws = xlib_brw_context_winsys(sws);
+   assert(xbcws->batch_nr <= xbcws->batch_size);
+
+   if (xbcws->batch_nr) {
+      xlib_brw_commands_aub( xbcws->pipe_winsys,
+                             xbcws->batch_data,
+                             xbcws->batch_nr );
+   }
+
+   xbcws->batch_nr = 0;
+}
+
+  
+
+/* Really a per-device function, just pass through:
+ */
+static unsigned xbcws_get_buffer_offset( struct brw_winsys *sws,
+                                         struct pipe_buffer *buf,
+                                         unsigned access_flags )
+{
+   struct xlib_brw_context_winsys *xbcws = xlib_brw_context_winsys(sws);
+
+   return xlib_brw_get_buffer_offset( xbcws->pipe_winsys,
+                                      buf,
+                                      access_flags );
+}
+
+
+/* Really a per-device function, just pass through:
+ */
+static void xbcws_buffer_subdata_typed( struct brw_winsys *sws,
+                                       struct pipe_buffer *buf,
+                                       unsigned long offset, 
+                                       unsigned long size, 
+                                       const void *data,
+                                       unsigned data_type )
+{
+   struct xlib_brw_context_winsys *xbcws = xlib_brw_context_winsys(sws);
+
+   xlib_brw_buffer_subdata_typed( xbcws->pipe_winsys,
+                                  buf,
+                                  offset,
+                                  size,
+                                  data,
+                                  data_type );
+}
+
+
+/**
+ * Create i965 hardware rendering context, but plugged into a
+ * dump-to-aubfile backend.
+ */
+struct pipe_context *
+xlib_create_brw_context( struct pipe_screen *screen,
+                         void *unused )
+{
+   struct xlib_brw_context_winsys *xbcws = CALLOC_STRUCT( xlib_brw_context_winsys );
+   
+   /* Fill in this struct with callbacks that i965simple will need to
+    * communicate with the window system, buffer manager, etc. 
+    */
+   xbcws->brw_context_winsys.batch_start = xbcws_batch_start;
+   xbcws->brw_context_winsys.batch_dword = xbcws_batch_dword;
+   xbcws->brw_context_winsys.batch_reloc = xbcws_batch_reloc;
+   xbcws->brw_context_winsys.batch_end = xbcws_batch_end;
+   xbcws->brw_context_winsys.batch_flush = xbcws_batch_flush;
+   xbcws->brw_context_winsys.buffer_subdata_typed = xbcws_buffer_subdata_typed;
+   xbcws->brw_context_winsys.get_buffer_offset = xbcws_get_buffer_offset;
+
+   xbcws->pipe_winsys = screen->winsys; /* redundant */
+
+   xbcws->batch_size = XBCWS_BATCHBUFFER_SIZE;
+
+   /* Create the i965simple context:
+    */
+#ifdef GALLIUM_CELL
+   return NULL;
+#else
+   return brw_create( screen,
+                     &xbcws->brw_context_winsys,
+                     0 );
+#endif
+}
index 13e609f58fe059242782e1c3c36cf77c380da3b8..47ae0519a4baa5fcdab7b3abd14cdf3daacb1fd3 100644 (file)
@@ -45,6 +45,7 @@
 #include "pipe/p_format.h"
 #include "pipe/p_context.h"
 #include "pipe/p_inlines.h"
+#include "util/u_format.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
 
@@ -277,35 +278,24 @@ xm_user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes)
 
 
 
-/**
- * Round n up to next multiple.
- */
-static INLINE unsigned
-round_up(unsigned n, unsigned multiple)
-{
-   return (n + multiple - 1) & ~(multiple - 1);
-}
-
 static struct pipe_buffer *
 xm_surface_buffer_create(struct pipe_winsys *winsys,
                          unsigned width, unsigned height,
                          enum pipe_format format,
                          unsigned usage,
+                         unsigned tex_usage,
                          unsigned *stride)
 {
    const unsigned alignment = 64;
-   struct pipe_format_block block;
-   unsigned nblocksx, nblocksy;
+   unsigned nblocksy;
 
-   pf_get_block(format, &block);
-   nblocksx = pf_get_nblocksx(&block, width);
-   nblocksy = pf_get_nblocksy(&block, height);
-   *stride = round_up(nblocksx * block.size, alignment);
+   nblocksy = util_format_get_nblocksy(format, height);
+   *stride = align(util_format_get_stride(format, width), alignment);
 
    return winsys->buffer_create(winsys, alignment,
                                 usage,
                                 /* XXX a bit of a hack */
-                                *stride * round_up(nblocksy, TILE_SIZE));
+                                *stride * align(nblocksy, TILE_SIZE));
 }
 
 
index 3dd15e099b043278e5722640a900a11e73beb0b0..2a434b5fd216c45488715cb759b0d2bec9e4ba7c 100644 (file)
@@ -44,6 +44,7 @@
 #include "pipe/p_format.h"
 #include "pipe/p_context.h"
 #include "pipe/p_inlines.h"
+#include "util/u_format.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
 #include "llvmpipe/lp_winsys.h"
@@ -58,7 +59,6 @@
 struct xm_displaytarget
 {
    enum pipe_format format;
-   struct pipe_format_block block;
    unsigned width;
    unsigned height;
    unsigned stride;
@@ -262,10 +262,10 @@ xm_llvmpipe_display(struct xmesa_buffer *xm_buffer,
    {
       if (xm_dt->tempImage == NULL)
       {
-         assert(xm_dt->block.width == 1);
-         assert(xm_dt->block.height == 1);
+         assert(util_format_get_blockwidth(xm_dt->format) == 1);
+         assert(util_format_get_blockheight(xm_dt->format) == 1);
          alloc_shm_ximage(xm_dt, xm_buffer,
-                          xm_dt->stride / xm_dt->block.size,
+                          xm_dt->stride / util_format_get_blocksize(xm_dt->format),
                           xm_dt->height);
       }
 
@@ -321,7 +321,7 @@ xm_displaytarget_create(struct llvmpipe_winsys *winsys,
                         unsigned *stride)
 {
    struct xm_displaytarget *xm_dt = CALLOC_STRUCT(xm_displaytarget);
-   unsigned nblocksx, nblocksy, size;
+   unsigned nblocksy, size;
 
    xm_dt = CALLOC_STRUCT(xm_displaytarget);
    if(!xm_dt)
@@ -331,10 +331,8 @@ xm_displaytarget_create(struct llvmpipe_winsys *winsys,
    xm_dt->width = width;
    xm_dt->height = height;
 
-   pf_get_block(format, &xm_dt->block);
-   nblocksx = pf_get_nblocksx(&xm_dt->block, width);
-   nblocksy = pf_get_nblocksy(&xm_dt->block, height);
-   xm_dt->stride = align(nblocksx * xm_dt->block.size, alignment);
+   nblocksy = util_format_get_nblocksy(format, height);
+   xm_dt->stride = align(util_format_get_stride(format, width), alignment);
    size = xm_dt->stride * nblocksy;
 
 #ifdef USE_XSHM
index 260b39e2a0fb1dd93922baa8175590ff8b2a21bd..f7c0099584e8f77cead739623b443007b81609c5 100644 (file)
@@ -42,6 +42,7 @@
 #include "pipe/p_format.h"
 #include "pipe/p_context.h"
 #include "pipe/p_inlines.h"
+#include "util/u_format.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
 #include "softpipe/sp_winsys.h"
@@ -254,10 +255,10 @@ xlib_softpipe_display_surface(struct xmesa_buffer *b,
    {
       if (xm_buf->tempImage == NULL) 
       {
-         assert(surf->texture->block.width == 1);
-         assert(surf->texture->block.height == 1);
+         assert(util_format_get_blockwidth(surf->texture->format) == 1);
+         assert(util_format_get_blockheight(surf->texture->format) == 1);
          alloc_shm_ximage(xm_buf, b, spt->stride[surf->level] /
-                          surf->texture->block.size, surf->height);
+                          util_format_get_blocksize(surf->texture->format), surf->height);
       }
 
       ximage = xm_buf->tempImage;
@@ -360,13 +361,10 @@ xm_surface_buffer_create(struct pipe_winsys *winsys,
                          unsigned *stride)
 {
    const unsigned alignment = 64;
-   struct pipe_format_block block;
-   unsigned nblocksx, nblocksy, size;
+   unsigned nblocksy, size;
 
-   pf_get_block(format, &block);
-   nblocksx = pf_get_nblocksx(&block, width);
-   nblocksy = pf_get_nblocksy(&block, height);
-   *stride = align(nblocksx * block.size, alignment);
+   nblocksy = util_format_get_nblocksy(format, height);
+   *stride = align(util_format_get_stride(format, width), alignment);
    size = *stride * nblocksy;
 
 #ifdef USE_XSHM
diff --git a/src/gallium/winsys/xlib/xlib_trace.c b/src/gallium/winsys/xlib/xlib_trace.c
deleted file mode 100644 (file)
index dbea655..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA
- * All Rights Reserved.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- * 
- * 
- **************************************************************************/
-
-/*
- * Authors:
- *   Keith Whitwell
- *   Brian Paul
- */
-
-
-#include "xlib.h"
-
-#include "trace/tr_screen.h"
-#include "trace/tr_context.h"
-#include "trace/tr_texture.h"
-
-#include "pipe/p_screen.h"
-
-
-
-static struct pipe_screen *
-xlib_create_trace_screen( void )
-{
-   struct pipe_screen *screen, *trace_screen;
-
-   screen = xlib_softpipe_driver.create_pipe_screen();
-   if (screen == NULL)
-      goto fail;
-
-   /* Wrap it:
-    */
-   trace_screen = trace_screen_create(screen);
-   if (trace_screen == NULL)
-      goto fail;
-
-   return trace_screen;
-
-fail:
-   if (screen)
-      screen->destroy( screen );
-   return NULL;
-}
-
-static struct pipe_context *
-xlib_create_trace_context( struct pipe_screen *_screen,
-                           void *priv )
-{
-   struct trace_screen *tr_scr = trace_screen( _screen );
-   struct pipe_screen *screen = tr_scr->screen;
-   struct pipe_context *pipe, *trace_pipe;
-   
-   pipe = xlib_softpipe_driver.create_pipe_context( screen, priv );
-   if (pipe == NULL)
-      goto fail;
-
-   /* Wrap it:
-    */
-   trace_pipe = trace_context_create(_screen, pipe);
-   if (trace_pipe == NULL)
-      goto fail;
-
-   trace_pipe->priv = priv;
-
-   return trace_pipe;
-
-fail:
-   if (pipe)
-      pipe->destroy( pipe );
-   return NULL;
-}
-
-static void
-xlib_trace_display_surface( struct xmesa_buffer *buffer,
-                            struct pipe_surface *_surf )
-{
-   struct trace_surface *tr_surf = trace_surface( _surf );
-   struct pipe_surface *surf = tr_surf->surface;
-
-   xlib_softpipe_driver.display_surface( buffer, surf );
-}
-
-
-struct xm_driver xlib_trace_driver = 
-{
-   .create_pipe_screen = xlib_create_trace_screen,
-   .create_pipe_context = xlib_create_trace_context,
-   .display_surface = xlib_trace_display_surface,
-};
index 1161be6e633e5731dfd24a8a5f9882211ba7d7a3..ce6e71e1570751ecd40f6e018af3b13d7818fa48 100644 (file)
@@ -1,29 +1,12 @@
 Import('*')
 
-if env['platform'] not in ['windows', 'linux']:
-    Return()
-
+# Shared environment settings
 env = env.Clone()
 
-env.Append(CPPDEFINES = [
-    'GLEW_BUILD',
-    'GLEW_STATIC',
-    #'GLEW_MX', # Multiple Rendering Contexts support
-])
-
 env.PrependUnique(CPPPATH = [
     '#/include',
 ])
 
-glew = env.StaticLibrary(
-    target = 'glew',
-    source = [
-        'glew.c',
-    ],
-)
-
-env = env.Clone()
-
 if env['platform'] == 'windows':
     env.PrependUnique(LIBS = [
         'glu32', 
@@ -37,14 +20,46 @@ else:
         'GL',
         'X11',
     ])
-env.Prepend(LIBS = [glew])
 
-env.Program(
+# Library specific environment settings
+lib_env = env.Clone()
+
+lib_env.Append(CPPDEFINES = [
+    'GLEW_BUILD',
+    #'GLEW_MX', # Multiple Rendering Contexts support
+])
+
+if lib_env['platform'] == 'windows':
+    target = 'glew'
+else:
+    target = 'GLEW'
+
+source = [
+    'glew.c',
+]
+
+if lib_env['platform'] == 'windows':
+    glew = lib_env.SharedLibrary(target = target, source = source) 
+    env.InstallSharedLibrary(glew, version=(1, 5, 2))
+    glew = lib_env.FindIxes(glew, 'LIBPREFIX', 'LIBSUFFIX')
+else:
+    # Use static library on Unices to avoid binary compatability issues
+    lib_env.Append(CPPDEFINES = ['GLEW_STATIC'])
+    glew = lib_env.StaticLibrary(target = target, source = source) 
+
+# Program specific environment settings
+prog_env = env.Clone()
+
+prog_env.Prepend(LIBS = [glew])
+
+prog_env.Program(
     target = 'glewinfo',
     source = ['glewinfo.c'],
 )
 
-env.Program(
+prog_env.Program(
     target = 'visualinfo',
     source = ['visualinfo.c'],
 )
+
+Export('glew')
index aa2278f6c0345aab7645f9ea0fbb93af5f4e4c43..624222f9fb1dbafcce9c83615d8b6706e3c227dd 100644 (file)
 #endif /* GLEW_MX */
 
 #if defined(__APPLE__)
-#include <mach-o/dyld.h>
 #include <stdlib.h>
 #include <string.h>
+#include <AvailabilityMacros.h>
+
+#ifdef MAC_OS_X_VERSION_10_3
+
+#include <dlfcn.h>
+
+void* NSGLGetProcAddress (const GLubyte *name)
+{
+  static void* image = NULL;
+  if (NULL == image) 
+  {
+    image = dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", RTLD_LAZY);
+  }
+  return image ? dlsym(image, (const char*)name) : NULL;
+}
+#else
+
+#include <mach-o/dyld.h>
 
 void* NSGLGetProcAddress (const GLubyte *name)
 {
@@ -90,6 +107,7 @@ void* NSGLGetProcAddress (const GLubyte *name)
   free(symbolName);
   return symbol ? NSAddressOfSymbol(symbol) : NULL;
 }
+#endif /* MAC_OS_X_VERSION_10_3 */
 #endif /* __APPLE__ */
 
 #if defined(__sgi) || defined (__sun)
@@ -444,8 +462,6 @@ PFNGLUNIFORMMATRIX4X3FVPROC __glewUniformMatrix4x3fv = NULL;
 
 PFNGLBEGINCONDITIONALRENDERPROC __glewBeginConditionalRender = NULL;
 PFNGLBEGINTRANSFORMFEEDBACKPROC __glewBeginTransformFeedback = NULL;
-PFNGLBINDBUFFERBASEPROC __glewBindBufferBase = NULL;
-PFNGLBINDBUFFERRANGEPROC __glewBindBufferRange = NULL;
 PFNGLBINDFRAGDATALOCATIONPROC __glewBindFragDataLocation = NULL;
 PFNGLCLAMPCOLORPROC __glewClampColor = NULL;
 PFNGLCLEARBUFFERFIPROC __glewClearBufferfi = NULL;
@@ -459,7 +475,6 @@ PFNGLENDCONDITIONALRENDERPROC __glewEndConditionalRender = NULL;
 PFNGLENDTRANSFORMFEEDBACKPROC __glewEndTransformFeedback = NULL;
 PFNGLGETBOOLEANI_VPROC __glewGetBooleani_v = NULL;
 PFNGLGETFRAGDATALOCATIONPROC __glewGetFragDataLocation = NULL;
-PFNGLGETINTEGERI_VPROC __glewGetIntegeri_v = NULL;
 PFNGLGETSTRINGIPROC __glewGetStringi = NULL;
 PFNGLGETTEXPARAMETERIIVPROC __glewGetTexParameterIiv = NULL;
 PFNGLGETTEXPARAMETERIUIVPROC __glewGetTexParameterIuiv = NULL;
@@ -501,8 +516,37 @@ PFNGLVERTEXATTRIBI4UIVPROC __glewVertexAttribI4uiv = NULL;
 PFNGLVERTEXATTRIBI4USVPROC __glewVertexAttribI4usv = NULL;
 PFNGLVERTEXATTRIBIPOINTERPROC __glewVertexAttribIPointer = NULL;
 
+PFNGLDRAWARRAYSINSTANCEDPROC __glewDrawArraysInstanced = NULL;
+PFNGLDRAWELEMENTSINSTANCEDPROC __glewDrawElementsInstanced = NULL;
+PFNGLPRIMITIVERESTARTINDEXPROC __glewPrimitiveRestartIndex = NULL;
+PFNGLTEXBUFFERPROC __glewTexBuffer = NULL;
+
+PFNGLFRAMEBUFFERTEXTUREPROC __glewFramebufferTexture = NULL;
+PFNGLGETBUFFERPARAMETERI64VPROC __glewGetBufferParameteri64v = NULL;
+PFNGLGETINTEGER64I_VPROC __glewGetInteger64i_v = NULL;
+
 PFNGLTBUFFERMASK3DFXPROC __glewTbufferMask3DFX = NULL;
 
+PFNGLBLENDEQUATIONINDEXEDAMDPROC __glewBlendEquationIndexedAMD = NULL;
+PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC __glewBlendEquationSeparateIndexedAMD = NULL;
+PFNGLBLENDFUNCINDEXEDAMDPROC __glewBlendFuncIndexedAMD = NULL;
+PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC __glewBlendFuncSeparateIndexedAMD = NULL;
+
+PFNGLBEGINPERFMONITORAMDPROC __glewBeginPerfMonitorAMD = NULL;
+PFNGLDELETEPERFMONITORSAMDPROC __glewDeletePerfMonitorsAMD = NULL;
+PFNGLENDPERFMONITORAMDPROC __glewEndPerfMonitorAMD = NULL;
+PFNGLGENPERFMONITORSAMDPROC __glewGenPerfMonitorsAMD = NULL;
+PFNGLGETPERFMONITORCOUNTERDATAAMDPROC __glewGetPerfMonitorCounterDataAMD = NULL;
+PFNGLGETPERFMONITORCOUNTERINFOAMDPROC __glewGetPerfMonitorCounterInfoAMD = NULL;
+PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC __glewGetPerfMonitorCounterStringAMD = NULL;
+PFNGLGETPERFMONITORCOUNTERSAMDPROC __glewGetPerfMonitorCountersAMD = NULL;
+PFNGLGETPERFMONITORGROUPSTRINGAMDPROC __glewGetPerfMonitorGroupStringAMD = NULL;
+PFNGLGETPERFMONITORGROUPSAMDPROC __glewGetPerfMonitorGroupsAMD = NULL;
+PFNGLSELECTPERFMONITORCOUNTERSAMDPROC __glewSelectPerfMonitorCountersAMD = NULL;
+
+PFNGLTESSELLATIONFACTORAMDPROC __glewTessellationFactorAMD = NULL;
+PFNGLTESSELLATIONMODEAMDPROC __glewTessellationModeAMD = NULL;
+
 PFNGLDRAWELEMENTARRAYAPPLEPROC __glewDrawElementArrayAPPLE = NULL;
 PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC __glewDrawRangeElementArrayAPPLE = NULL;
 PFNGLELEMENTPOINTERAPPLEPROC __glewElementPointerAPPLE = NULL;
@@ -521,6 +565,10 @@ PFNGLTESTOBJECTAPPLEPROC __glewTestObjectAPPLE = NULL;
 PFNGLBUFFERPARAMETERIAPPLEPROC __glewBufferParameteriAPPLE = NULL;
 PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC __glewFlushMappedBufferRangeAPPLE = NULL;
 
+PFNGLGETOBJECTPARAMETERIVAPPLEPROC __glewGetObjectParameterivAPPLE = NULL;
+PFNGLOBJECTPURGEABLEAPPLEPROC __glewObjectPurgeableAPPLE = NULL;
+PFNGLOBJECTUNPURGEABLEAPPLEPROC __glewObjectUnpurgeableAPPLE = NULL;
+
 PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC __glewGetTexParameterPointervAPPLE = NULL;
 PFNGLTEXTURERANGEAPPLEPROC __glewTextureRangeAPPLE = NULL;
 
@@ -533,10 +581,30 @@ PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC __glewFlushVertexArrayRangeAPPLE = NULL;
 PFNGLVERTEXARRAYPARAMETERIAPPLEPROC __glewVertexArrayParameteriAPPLE = NULL;
 PFNGLVERTEXARRAYRANGEAPPLEPROC __glewVertexArrayRangeAPPLE = NULL;
 
+PFNGLDISABLEVERTEXATTRIBAPPLEPROC __glewDisableVertexAttribAPPLE = NULL;
+PFNGLENABLEVERTEXATTRIBAPPLEPROC __glewEnableVertexAttribAPPLE = NULL;
+PFNGLISVERTEXATTRIBENABLEDAPPLEPROC __glewIsVertexAttribEnabledAPPLE = NULL;
+PFNGLMAPVERTEXATTRIB1DAPPLEPROC __glewMapVertexAttrib1dAPPLE = NULL;
+PFNGLMAPVERTEXATTRIB1FAPPLEPROC __glewMapVertexAttrib1fAPPLE = NULL;
+PFNGLMAPVERTEXATTRIB2DAPPLEPROC __glewMapVertexAttrib2dAPPLE = NULL;
+PFNGLMAPVERTEXATTRIB2FAPPLEPROC __glewMapVertexAttrib2fAPPLE = NULL;
+
 PFNGLCLAMPCOLORARBPROC __glewClampColorARB = NULL;
 
+PFNGLCOPYBUFFERSUBDATAPROC __glewCopyBufferSubData = NULL;
+
 PFNGLDRAWBUFFERSARBPROC __glewDrawBuffersARB = NULL;
 
+PFNGLBLENDEQUATIONSEPARATEIARBPROC __glewBlendEquationSeparateiARB = NULL;
+PFNGLBLENDEQUATIONIARBPROC __glewBlendEquationiARB = NULL;
+PFNGLBLENDFUNCSEPARATEIARBPROC __glewBlendFuncSeparateiARB = NULL;
+PFNGLBLENDFUNCIARBPROC __glewBlendFunciARB = NULL;
+
+PFNGLDRAWELEMENTSBASEVERTEXPROC __glewDrawElementsBaseVertex = NULL;
+PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC __glewDrawElementsInstancedBaseVertex = NULL;
+PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC __glewDrawRangeElementsBaseVertex = NULL;
+PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC __glewMultiDrawElementsBaseVertex = NULL;
+
 PFNGLDRAWARRAYSINSTANCEDARBPROC __glewDrawArraysInstancedARB = NULL;
 PFNGLDRAWELEMENTSINSTANCEDARBPROC __glewDrawElementsInstancedARB = NULL;
 
@@ -547,10 +615,10 @@ PFNGLCHECKFRAMEBUFFERSTATUSPROC __glewCheckFramebufferStatus = NULL;
 PFNGLDELETEFRAMEBUFFERSPROC __glewDeleteFramebuffers = NULL;
 PFNGLDELETERENDERBUFFERSPROC __glewDeleteRenderbuffers = NULL;
 PFNGLFRAMEBUFFERRENDERBUFFERPROC __glewFramebufferRenderbuffer = NULL;
-PFNGLFRAMEBUFFERTEXTURELAYERPROC __glewFramebufferTextureLayer = NULL;
 PFNGLFRAMEBUFFERTEXTURE1DPROC __glewFramebufferTexture1D = NULL;
 PFNGLFRAMEBUFFERTEXTURE2DPROC __glewFramebufferTexture2D = NULL;
 PFNGLFRAMEBUFFERTEXTURE3DPROC __glewFramebufferTexture3D = NULL;
+PFNGLFRAMEBUFFERTEXTURELAYERPROC __glewFramebufferTextureLayer = NULL;
 PFNGLGENFRAMEBUFFERSPROC __glewGenFramebuffers = NULL;
 PFNGLGENRENDERBUFFERSPROC __glewGenRenderbuffers = NULL;
 PFNGLGENERATEMIPMAPPROC __glewGenerateMipmap = NULL;
@@ -659,6 +727,10 @@ PFNGLISQUERYARBPROC __glewIsQueryARB = NULL;
 PFNGLPOINTPARAMETERFARBPROC __glewPointParameterfARB = NULL;
 PFNGLPOINTPARAMETERFVARBPROC __glewPointParameterfvARB = NULL;
 
+PFNGLPROVOKINGVERTEXPROC __glewProvokingVertex = NULL;
+
+PFNGLMINSAMPLESHADINGARBPROC __glewMinSampleShadingARB = NULL;
+
 PFNGLATTACHOBJECTARBPROC __glewAttachObjectARB = NULL;
 PFNGLCOMPILESHADERARBPROC __glewCompileShaderARB = NULL;
 PFNGLCREATEPROGRAMOBJECTARBPROC __glewCreateProgramObjectARB = NULL;
@@ -699,6 +771,14 @@ PFNGLUNIFORMMATRIX4FVARBPROC __glewUniformMatrix4fvARB = NULL;
 PFNGLUSEPROGRAMOBJECTARBPROC __glewUseProgramObjectARB = NULL;
 PFNGLVALIDATEPROGRAMARBPROC __glewValidateProgramARB = NULL;
 
+PFNGLCLIENTWAITSYNCPROC __glewClientWaitSync = NULL;
+PFNGLDELETESYNCPROC __glewDeleteSync = NULL;
+PFNGLFENCESYNCPROC __glewFenceSync = NULL;
+PFNGLGETINTEGER64VPROC __glewGetInteger64v = NULL;
+PFNGLGETSYNCIVPROC __glewGetSynciv = NULL;
+PFNGLISSYNCPROC __glewIsSync = NULL;
+PFNGLWAITSYNCPROC __glewWaitSync = NULL;
+
 PFNGLTEXBUFFERARBPROC __glewTexBufferARB = NULL;
 
 PFNGLCOMPRESSEDTEXIMAGE1DARBPROC __glewCompressedTexImage1DARB = NULL;
@@ -709,11 +789,27 @@ PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC __glewCompressedTexSubImage2DARB = NULL;
 PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC __glewCompressedTexSubImage3DARB = NULL;
 PFNGLGETCOMPRESSEDTEXIMAGEARBPROC __glewGetCompressedTexImageARB = NULL;
 
+PFNGLGETMULTISAMPLEFVPROC __glewGetMultisamplefv = NULL;
+PFNGLSAMPLEMASKIPROC __glewSampleMaski = NULL;
+PFNGLTEXIMAGE2DMULTISAMPLEPROC __glewTexImage2DMultisample = NULL;
+PFNGLTEXIMAGE3DMULTISAMPLEPROC __glewTexImage3DMultisample = NULL;
+
 PFNGLLOADTRANSPOSEMATRIXDARBPROC __glewLoadTransposeMatrixdARB = NULL;
 PFNGLLOADTRANSPOSEMATRIXFARBPROC __glewLoadTransposeMatrixfARB = NULL;
 PFNGLMULTTRANSPOSEMATRIXDARBPROC __glewMultTransposeMatrixdARB = NULL;
 PFNGLMULTTRANSPOSEMATRIXFARBPROC __glewMultTransposeMatrixfARB = NULL;
 
+PFNGLBINDBUFFERBASEPROC __glewBindBufferBase = NULL;
+PFNGLBINDBUFFERRANGEPROC __glewBindBufferRange = NULL;
+PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC __glewGetActiveUniformBlockName = NULL;
+PFNGLGETACTIVEUNIFORMBLOCKIVPROC __glewGetActiveUniformBlockiv = NULL;
+PFNGLGETACTIVEUNIFORMNAMEPROC __glewGetActiveUniformName = NULL;
+PFNGLGETACTIVEUNIFORMSIVPROC __glewGetActiveUniformsiv = NULL;
+PFNGLGETINTEGERI_VPROC __glewGetIntegeri_v = NULL;
+PFNGLGETUNIFORMBLOCKINDEXPROC __glewGetUniformBlockIndex = NULL;
+PFNGLGETUNIFORMINDICESPROC __glewGetUniformIndices = NULL;
+PFNGLUNIFORMBLOCKBINDINGPROC __glewUniformBlockBinding = NULL;
+
 PFNGLBINDVERTEXARRAYPROC __glewBindVertexArray = NULL;
 PFNGLDELETEVERTEXARRAYSPROC __glewDeleteVertexArrays = NULL;
 PFNGLGENVERTEXARRAYSPROC __glewGenVertexArrays = NULL;
@@ -988,7 +1084,14 @@ PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC __glewCopyTextureSubImage1DEXT = NULL;
 PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC __glewCopyTextureSubImage2DEXT = NULL;
 PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC __glewCopyTextureSubImage3DEXT = NULL;
 PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC __glewDisableClientStateIndexedEXT = NULL;
+PFNGLDISABLECLIENTSTATEIEXTPROC __glewDisableClientStateiEXT = NULL;
+PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC __glewDisableVertexArrayAttribEXT = NULL;
+PFNGLDISABLEVERTEXARRAYEXTPROC __glewDisableVertexArrayEXT = NULL;
 PFNGLENABLECLIENTSTATEINDEXEDEXTPROC __glewEnableClientStateIndexedEXT = NULL;
+PFNGLENABLECLIENTSTATEIEXTPROC __glewEnableClientStateiEXT = NULL;
+PFNGLENABLEVERTEXARRAYATTRIBEXTPROC __glewEnableVertexArrayAttribEXT = NULL;
+PFNGLENABLEVERTEXARRAYEXTPROC __glewEnableVertexArrayEXT = NULL;
+PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC __glewFlushMappedNamedBufferRangeEXT = NULL;
 PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC __glewFramebufferDrawBufferEXT = NULL;
 PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC __glewFramebufferDrawBuffersEXT = NULL;
 PFNGLFRAMEBUFFERREADBUFFEREXTPROC __glewFramebufferReadBufferEXT = NULL;
@@ -997,7 +1100,9 @@ PFNGLGENERATETEXTUREMIPMAPEXTPROC __glewGenerateTextureMipmapEXT = NULL;
 PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC __glewGetCompressedMultiTexImageEXT = NULL;
 PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC __glewGetCompressedTextureImageEXT = NULL;
 PFNGLGETDOUBLEINDEXEDVEXTPROC __glewGetDoubleIndexedvEXT = NULL;
+PFNGLGETDOUBLEI_VEXTPROC __glewGetDoublei_vEXT = NULL;
 PFNGLGETFLOATINDEXEDVEXTPROC __glewGetFloatIndexedvEXT = NULL;
+PFNGLGETFLOATI_VEXTPROC __glewGetFloati_vEXT = NULL;
 PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC __glewGetFramebufferParameterivEXT = NULL;
 PFNGLGETMULTITEXENVFVEXTPROC __glewGetMultiTexEnvfvEXT = NULL;
 PFNGLGETMULTITEXENVIVEXTPROC __glewGetMultiTexEnvivEXT = NULL;
@@ -1023,6 +1128,7 @@ PFNGLGETNAMEDPROGRAMSTRINGEXTPROC __glewGetNamedProgramStringEXT = NULL;
 PFNGLGETNAMEDPROGRAMIVEXTPROC __glewGetNamedProgramivEXT = NULL;
 PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC __glewGetNamedRenderbufferParameterivEXT = NULL;
 PFNGLGETPOINTERINDEXEDVEXTPROC __glewGetPointerIndexedvEXT = NULL;
+PFNGLGETPOINTERI_VEXTPROC __glewGetPointeri_vEXT = NULL;
 PFNGLGETTEXTUREIMAGEEXTPROC __glewGetTextureImageEXT = NULL;
 PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC __glewGetTextureLevelParameterfvEXT = NULL;
 PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC __glewGetTextureLevelParameterivEXT = NULL;
@@ -1030,7 +1136,12 @@ PFNGLGETTEXTUREPARAMETERIIVEXTPROC __glewGetTextureParameterIivEXT = NULL;
 PFNGLGETTEXTUREPARAMETERIUIVEXTPROC __glewGetTextureParameterIuivEXT = NULL;
 PFNGLGETTEXTUREPARAMETERFVEXTPROC __glewGetTextureParameterfvEXT = NULL;
 PFNGLGETTEXTUREPARAMETERIVEXTPROC __glewGetTextureParameterivEXT = NULL;
+PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC __glewGetVertexArrayIntegeri_vEXT = NULL;
+PFNGLGETVERTEXARRAYINTEGERVEXTPROC __glewGetVertexArrayIntegervEXT = NULL;
+PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC __glewGetVertexArrayPointeri_vEXT = NULL;
+PFNGLGETVERTEXARRAYPOINTERVEXTPROC __glewGetVertexArrayPointervEXT = NULL;
 PFNGLMAPNAMEDBUFFEREXTPROC __glewMapNamedBufferEXT = NULL;
+PFNGLMAPNAMEDBUFFERRANGEEXTPROC __glewMapNamedBufferRangeEXT = NULL;
 PFNGLMATRIXFRUSTUMEXTPROC __glewMatrixFrustumEXT = NULL;
 PFNGLMATRIXLOADIDENTITYEXTPROC __glewMatrixLoadIdentityEXT = NULL;
 PFNGLMATRIXLOADTRANSPOSEDEXTPROC __glewMatrixLoadTransposedEXT = NULL;
@@ -1077,6 +1188,7 @@ PFNGLMULTITEXSUBIMAGE2DEXTPROC __glewMultiTexSubImage2DEXT = NULL;
 PFNGLMULTITEXSUBIMAGE3DEXTPROC __glewMultiTexSubImage3DEXT = NULL;
 PFNGLNAMEDBUFFERDATAEXTPROC __glewNamedBufferDataEXT = NULL;
 PFNGLNAMEDBUFFERSUBDATAEXTPROC __glewNamedBufferSubDataEXT = NULL;
+PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC __glewNamedCopyBufferSubDataEXT = NULL;
 PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC __glewNamedFramebufferRenderbufferEXT = NULL;
 PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC __glewNamedFramebufferTexture1DEXT = NULL;
 PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC __glewNamedFramebufferTexture2DEXT = NULL;
@@ -1148,6 +1260,17 @@ PFNGLTEXTURESUBIMAGE1DEXTPROC __glewTextureSubImage1DEXT = NULL;
 PFNGLTEXTURESUBIMAGE2DEXTPROC __glewTextureSubImage2DEXT = NULL;
 PFNGLTEXTURESUBIMAGE3DEXTPROC __glewTextureSubImage3DEXT = NULL;
 PFNGLUNMAPNAMEDBUFFEREXTPROC __glewUnmapNamedBufferEXT = NULL;
+PFNGLVERTEXARRAYCOLOROFFSETEXTPROC __glewVertexArrayColorOffsetEXT = NULL;
+PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC __glewVertexArrayEdgeFlagOffsetEXT = NULL;
+PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC __glewVertexArrayFogCoordOffsetEXT = NULL;
+PFNGLVERTEXARRAYINDEXOFFSETEXTPROC __glewVertexArrayIndexOffsetEXT = NULL;
+PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC __glewVertexArrayMultiTexCoordOffsetEXT = NULL;
+PFNGLVERTEXARRAYNORMALOFFSETEXTPROC __glewVertexArrayNormalOffsetEXT = NULL;
+PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC __glewVertexArraySecondaryColorOffsetEXT = NULL;
+PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC __glewVertexArrayTexCoordOffsetEXT = NULL;
+PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC __glewVertexArrayVertexAttribIOffsetEXT = NULL;
+PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC __glewVertexArrayVertexAttribOffsetEXT = NULL;
+PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC __glewVertexArrayVertexOffsetEXT = NULL;
 
 PFNGLCOLORMASKINDEXEDEXTPROC __glewColorMaskIndexedEXT = NULL;
 PFNGLDISABLEINDEXEDEXTPROC __glewDisableIndexedEXT = NULL;
@@ -1293,6 +1416,8 @@ PFNGLPOINTPARAMETERFVEXTPROC __glewPointParameterfvEXT = NULL;
 
 PFNGLPOLYGONOFFSETEXTPROC __glewPolygonOffsetEXT = NULL;
 
+PFNGLPROVOKINGVERTEXEXTPROC __glewProvokingVertexEXT = NULL;
+
 PFNGLBEGINSCENEEXTPROC __glewBeginSceneEXT = NULL;
 PFNGLENDSCENEEXTPROC __glewEndSceneEXT = NULL;
 
@@ -1314,6 +1439,10 @@ PFNGLSECONDARYCOLOR3USEXTPROC __glewSecondaryColor3usEXT = NULL;
 PFNGLSECONDARYCOLOR3USVEXTPROC __glewSecondaryColor3usvEXT = NULL;
 PFNGLSECONDARYCOLORPOINTEREXTPROC __glewSecondaryColorPointerEXT = NULL;
 
+PFNGLACTIVEPROGRAMEXTPROC __glewActiveProgramEXT = NULL;
+PFNGLCREATESHADERPROGRAMEXTPROC __glewCreateShaderProgramEXT = NULL;
+PFNGLUSESHADERPROGRAMEXTPROC __glewUseShaderProgramEXT = NULL;
+
 PFNGLACTIVESTENCILFACEEXTPROC __glewActiveStencilFaceEXT = NULL;
 
 PFNGLTEXSUBIMAGE1DEXTPROC __glewTexSubImage1DEXT = NULL;
@@ -1475,6 +1604,8 @@ PFNGLWINDOWPOS4SVMESAPROC __glewWindowPos4svMESA = NULL;
 PFNGLBEGINCONDITIONALRENDERNVPROC __glewBeginConditionalRenderNV = NULL;
 PFNGLENDCONDITIONALRENDERNVPROC __glewEndConditionalRenderNV = NULL;
 
+PFNGLCOPYIMAGESUBDATANVPROC __glewCopyImageSubDataNV = NULL;
+
 PFNGLCLEARDEPTHDNVPROC __glewClearDepthdNV = NULL;
 PFNGLDEPTHBOUNDSDNVPROC __glewDepthBoundsdNV = NULL;
 PFNGLDEPTHRANGEDNVPROC __glewDepthRangedNV = NULL;
@@ -1596,7 +1727,6 @@ PFNGLGETVIDEOUI64VNVPROC __glewGetVideoui64vNV = NULL;
 PFNGLGETVIDEOUIVNVPROC __glewGetVideouivNV = NULL;
 PFNGLPRESENTFRAMEDUALFILLNVPROC __glewPresentFrameDualFillNV = NULL;
 PFNGLPRESENTFRAMEKEYEDNVPROC __glewPresentFrameKeyedNV = NULL;
-PFNGLVIDEOPARAMETERIVNVPROC __glewVideoParameterivNV = NULL;
 
 PFNGLPRIMITIVERESTARTINDEXNVPROC __glewPrimitiveRestartIndexNV = NULL;
 PFNGLPRIMITIVERESTARTNVPROC __glewPrimitiveRestartNV = NULL;
@@ -1618,6 +1748,23 @@ PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC __glewGetFinalCombinerInputParameter
 PFNGLCOMBINERSTAGEPARAMETERFVNVPROC __glewCombinerStageParameterfvNV = NULL;
 PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC __glewGetCombinerStageParameterfvNV = NULL;
 
+PFNGLGETBUFFERPARAMETERUI64VNVPROC __glewGetBufferParameterui64vNV = NULL;
+PFNGLGETINTEGERUI64VNVPROC __glewGetIntegerui64vNV = NULL;
+PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC __glewGetNamedBufferParameterui64vNV = NULL;
+PFNGLGETUNIFORMUI64VNVPROC __glewGetUniformui64vNV = NULL;
+PFNGLISBUFFERRESIDENTNVPROC __glewIsBufferResidentNV = NULL;
+PFNGLISNAMEDBUFFERRESIDENTNVPROC __glewIsNamedBufferResidentNV = NULL;
+PFNGLMAKEBUFFERNONRESIDENTNVPROC __glewMakeBufferNonResidentNV = NULL;
+PFNGLMAKEBUFFERRESIDENTNVPROC __glewMakeBufferResidentNV = NULL;
+PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC __glewMakeNamedBufferNonResidentNV = NULL;
+PFNGLMAKENAMEDBUFFERRESIDENTNVPROC __glewMakeNamedBufferResidentNV = NULL;
+PFNGLPROGRAMUNIFORMUI64NVPROC __glewProgramUniformui64NV = NULL;
+PFNGLPROGRAMUNIFORMUI64VNVPROC __glewProgramUniformui64vNV = NULL;
+PFNGLUNIFORMUI64NVPROC __glewUniformui64NV = NULL;
+PFNGLUNIFORMUI64VNVPROC __glewUniformui64vNV = NULL;
+
+PFNGLTEXTUREBARRIERNVPROC __glewTextureBarrierNV = NULL;
+
 PFNGLACTIVEVARYINGNVPROC __glewActiveVaryingNV = NULL;
 PFNGLBEGINTRANSFORMFEEDBACKNVPROC __glewBeginTransformFeedbackNV = NULL;
 PFNGLBINDBUFFERBASENVPROC __glewBindBufferBaseNV = NULL;
@@ -1630,9 +1777,30 @@ PFNGLGETVARYINGLOCATIONNVPROC __glewGetVaryingLocationNV = NULL;
 PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC __glewTransformFeedbackAttribsNV = NULL;
 PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC __glewTransformFeedbackVaryingsNV = NULL;
 
+PFNGLBINDTRANSFORMFEEDBACKNVPROC __glewBindTransformFeedbackNV = NULL;
+PFNGLDELETETRANSFORMFEEDBACKSNVPROC __glewDeleteTransformFeedbacksNV = NULL;
+PFNGLDRAWTRANSFORMFEEDBACKNVPROC __glewDrawTransformFeedbackNV = NULL;
+PFNGLGENTRANSFORMFEEDBACKSNVPROC __glewGenTransformFeedbacksNV = NULL;
+PFNGLISTRANSFORMFEEDBACKNVPROC __glewIsTransformFeedbackNV = NULL;
+PFNGLPAUSETRANSFORMFEEDBACKNVPROC __glewPauseTransformFeedbackNV = NULL;
+PFNGLRESUMETRANSFORMFEEDBACKNVPROC __glewResumeTransformFeedbackNV = NULL;
+
 PFNGLFLUSHVERTEXARRAYRANGENVPROC __glewFlushVertexArrayRangeNV = NULL;
 PFNGLVERTEXARRAYRANGENVPROC __glewVertexArrayRangeNV = NULL;
 
+PFNGLBUFFERADDRESSRANGENVPROC __glewBufferAddressRangeNV = NULL;
+PFNGLCOLORFORMATNVPROC __glewColorFormatNV = NULL;
+PFNGLEDGEFLAGFORMATNVPROC __glewEdgeFlagFormatNV = NULL;
+PFNGLFOGCOORDFORMATNVPROC __glewFogCoordFormatNV = NULL;
+PFNGLGETINTEGERUI64I_VNVPROC __glewGetIntegerui64i_vNV = NULL;
+PFNGLINDEXFORMATNVPROC __glewIndexFormatNV = NULL;
+PFNGLNORMALFORMATNVPROC __glewNormalFormatNV = NULL;
+PFNGLSECONDARYCOLORFORMATNVPROC __glewSecondaryColorFormatNV = NULL;
+PFNGLTEXCOORDFORMATNVPROC __glewTexCoordFormatNV = NULL;
+PFNGLVERTEXATTRIBFORMATNVPROC __glewVertexAttribFormatNV = NULL;
+PFNGLVERTEXATTRIBIFORMATNVPROC __glewVertexAttribIFormatNV = NULL;
+PFNGLVERTEXFORMATNVPROC __glewVertexFormatNV = NULL;
+
 PFNGLAREPROGRAMSRESIDENTNVPROC __glewAreProgramsResidentNV = NULL;
 PFNGLBINDPROGRAMNVPROC __glewBindProgramNV = NULL;
 PFNGLDELETEPROGRAMSNVPROC __glewDeleteProgramsNV = NULL;
@@ -1849,26 +2017,43 @@ GLboolean __GLEW_VERSION_1_5 = GL_FALSE;
 GLboolean __GLEW_VERSION_2_0 = GL_FALSE;
 GLboolean __GLEW_VERSION_2_1 = GL_FALSE;
 GLboolean __GLEW_VERSION_3_0 = GL_FALSE;
+GLboolean __GLEW_VERSION_3_1 = GL_FALSE;
+GLboolean __GLEW_VERSION_3_2 = GL_FALSE;
 GLboolean __GLEW_3DFX_multisample = GL_FALSE;
 GLboolean __GLEW_3DFX_tbuffer = GL_FALSE;
 GLboolean __GLEW_3DFX_texture_compression_FXT1 = GL_FALSE;
+GLboolean __GLEW_AMD_draw_buffers_blend = GL_FALSE;
+GLboolean __GLEW_AMD_performance_monitor = GL_FALSE;
+GLboolean __GLEW_AMD_texture_texture4 = GL_FALSE;
+GLboolean __GLEW_AMD_vertex_shader_tessellator = GL_FALSE;
+GLboolean __GLEW_APPLE_aux_depth_stencil = GL_FALSE;
 GLboolean __GLEW_APPLE_client_storage = GL_FALSE;
 GLboolean __GLEW_APPLE_element_array = GL_FALSE;
 GLboolean __GLEW_APPLE_fence = GL_FALSE;
 GLboolean __GLEW_APPLE_float_pixels = GL_FALSE;
 GLboolean __GLEW_APPLE_flush_buffer_range = GL_FALSE;
+GLboolean __GLEW_APPLE_object_purgeable = GL_FALSE;
 GLboolean __GLEW_APPLE_pixel_buffer = GL_FALSE;
+GLboolean __GLEW_APPLE_rgb_422 = GL_FALSE;
+GLboolean __GLEW_APPLE_row_bytes = GL_FALSE;
 GLboolean __GLEW_APPLE_specular_vector = GL_FALSE;
 GLboolean __GLEW_APPLE_texture_range = GL_FALSE;
 GLboolean __GLEW_APPLE_transform_hint = GL_FALSE;
 GLboolean __GLEW_APPLE_vertex_array_object = GL_FALSE;
 GLboolean __GLEW_APPLE_vertex_array_range = GL_FALSE;
+GLboolean __GLEW_APPLE_vertex_program_evaluators = GL_FALSE;
 GLboolean __GLEW_APPLE_ycbcr_422 = GL_FALSE;
 GLboolean __GLEW_ARB_color_buffer_float = GL_FALSE;
+GLboolean __GLEW_ARB_compatibility = GL_FALSE;
+GLboolean __GLEW_ARB_copy_buffer = GL_FALSE;
 GLboolean __GLEW_ARB_depth_buffer_float = GL_FALSE;
+GLboolean __GLEW_ARB_depth_clamp = GL_FALSE;
 GLboolean __GLEW_ARB_depth_texture = GL_FALSE;
 GLboolean __GLEW_ARB_draw_buffers = GL_FALSE;
+GLboolean __GLEW_ARB_draw_buffers_blend = GL_FALSE;
+GLboolean __GLEW_ARB_draw_elements_base_vertex = GL_FALSE;
 GLboolean __GLEW_ARB_draw_instanced = GL_FALSE;
+GLboolean __GLEW_ARB_fragment_coord_conventions = GL_FALSE;
 GLboolean __GLEW_ARB_fragment_program = GL_FALSE;
 GLboolean __GLEW_ARB_fragment_program_shadow = GL_FALSE;
 GLboolean __GLEW_ARB_fragment_shader = GL_FALSE;
@@ -1887,25 +2072,36 @@ GLboolean __GLEW_ARB_occlusion_query = GL_FALSE;
 GLboolean __GLEW_ARB_pixel_buffer_object = GL_FALSE;
 GLboolean __GLEW_ARB_point_parameters = GL_FALSE;
 GLboolean __GLEW_ARB_point_sprite = GL_FALSE;
+GLboolean __GLEW_ARB_provoking_vertex = GL_FALSE;
+GLboolean __GLEW_ARB_sample_shading = GL_FALSE;
+GLboolean __GLEW_ARB_seamless_cube_map = GL_FALSE;
 GLboolean __GLEW_ARB_shader_objects = GL_FALSE;
+GLboolean __GLEW_ARB_shader_texture_lod = GL_FALSE;
 GLboolean __GLEW_ARB_shading_language_100 = GL_FALSE;
 GLboolean __GLEW_ARB_shadow = GL_FALSE;
 GLboolean __GLEW_ARB_shadow_ambient = GL_FALSE;
+GLboolean __GLEW_ARB_sync = GL_FALSE;
 GLboolean __GLEW_ARB_texture_border_clamp = GL_FALSE;
 GLboolean __GLEW_ARB_texture_buffer_object = GL_FALSE;
 GLboolean __GLEW_ARB_texture_compression = GL_FALSE;
 GLboolean __GLEW_ARB_texture_compression_rgtc = GL_FALSE;
 GLboolean __GLEW_ARB_texture_cube_map = GL_FALSE;
+GLboolean __GLEW_ARB_texture_cube_map_array = GL_FALSE;
 GLboolean __GLEW_ARB_texture_env_add = GL_FALSE;
 GLboolean __GLEW_ARB_texture_env_combine = GL_FALSE;
 GLboolean __GLEW_ARB_texture_env_crossbar = GL_FALSE;
 GLboolean __GLEW_ARB_texture_env_dot3 = GL_FALSE;
 GLboolean __GLEW_ARB_texture_float = GL_FALSE;
+GLboolean __GLEW_ARB_texture_gather = GL_FALSE;
 GLboolean __GLEW_ARB_texture_mirrored_repeat = GL_FALSE;
+GLboolean __GLEW_ARB_texture_multisample = GL_FALSE;
 GLboolean __GLEW_ARB_texture_non_power_of_two = GL_FALSE;
+GLboolean __GLEW_ARB_texture_query_lod = GL_FALSE;
 GLboolean __GLEW_ARB_texture_rectangle = GL_FALSE;
 GLboolean __GLEW_ARB_texture_rg = GL_FALSE;
 GLboolean __GLEW_ARB_transpose_matrix = GL_FALSE;
+GLboolean __GLEW_ARB_uniform_buffer_object = GL_FALSE;
+GLboolean __GLEW_ARB_vertex_array_bgra = GL_FALSE;
 GLboolean __GLEW_ARB_vertex_array_object = GL_FALSE;
 GLboolean __GLEW_ARB_vertex_blend = GL_FALSE;
 GLboolean __GLEW_ARB_vertex_buffer_object = GL_FALSE;
@@ -1921,6 +2117,7 @@ GLboolean __GLEW_ATI_element_array = GL_FALSE;
 GLboolean __GLEW_ATI_envmap_bumpmap = GL_FALSE;
 GLboolean __GLEW_ATI_fragment_shader = GL_FALSE;
 GLboolean __GLEW_ATI_map_object_buffer = GL_FALSE;
+GLboolean __GLEW_ATI_meminfo = GL_FALSE;
 GLboolean __GLEW_ATI_pn_triangles = GL_FALSE;
 GLboolean __GLEW_ATI_separate_stencil = GL_FALSE;
 GLboolean __GLEW_ATI_shader_texture_lod = GL_FALSE;
@@ -1983,9 +2180,11 @@ GLboolean __GLEW_EXT_pixel_transform = GL_FALSE;
 GLboolean __GLEW_EXT_pixel_transform_color_table = GL_FALSE;
 GLboolean __GLEW_EXT_point_parameters = GL_FALSE;
 GLboolean __GLEW_EXT_polygon_offset = GL_FALSE;
+GLboolean __GLEW_EXT_provoking_vertex = GL_FALSE;
 GLboolean __GLEW_EXT_rescale_normal = GL_FALSE;
 GLboolean __GLEW_EXT_scene_marker = GL_FALSE;
 GLboolean __GLEW_EXT_secondary_color = GL_FALSE;
+GLboolean __GLEW_EXT_separate_shader_objects = GL_FALSE;
 GLboolean __GLEW_EXT_separate_specular_color = GL_FALSE;
 GLboolean __GLEW_EXT_shadow_funcs = GL_FALSE;
 GLboolean __GLEW_EXT_shared_texture_palette = GL_FALSE;
@@ -2016,6 +2215,7 @@ GLboolean __GLEW_EXT_texture_perturb_normal = GL_FALSE;
 GLboolean __GLEW_EXT_texture_rectangle = GL_FALSE;
 GLboolean __GLEW_EXT_texture_sRGB = GL_FALSE;
 GLboolean __GLEW_EXT_texture_shared_exponent = GL_FALSE;
+GLboolean __GLEW_EXT_texture_snorm = GL_FALSE;
 GLboolean __GLEW_EXT_texture_swizzle = GL_FALSE;
 GLboolean __GLEW_EXT_timer_query = GL_FALSE;
 GLboolean __GLEW_EXT_transform_feedback = GL_FALSE;
@@ -2048,6 +2248,7 @@ GLboolean __GLEW_MESA_ycbcr_texture = GL_FALSE;
 GLboolean __GLEW_NV_blend_square = GL_FALSE;
 GLboolean __GLEW_NV_conditional_render = GL_FALSE;
 GLboolean __GLEW_NV_copy_depth_to_color = GL_FALSE;
+GLboolean __GLEW_NV_copy_image = GL_FALSE;
 GLboolean __GLEW_NV_depth_buffer_float = GL_FALSE;
 GLboolean __GLEW_NV_depth_clamp = GL_FALSE;
 GLboolean __GLEW_NV_depth_range_unclamped = GL_FALSE;
@@ -2070,14 +2271,17 @@ GLboolean __GLEW_NV_multisample_filter_hint = GL_FALSE;
 GLboolean __GLEW_NV_occlusion_query = GL_FALSE;
 GLboolean __GLEW_NV_packed_depth_stencil = GL_FALSE;
 GLboolean __GLEW_NV_parameter_buffer_object = GL_FALSE;
+GLboolean __GLEW_NV_parameter_buffer_object2 = GL_FALSE;
 GLboolean __GLEW_NV_pixel_data_range = GL_FALSE;
 GLboolean __GLEW_NV_point_sprite = GL_FALSE;
 GLboolean __GLEW_NV_present_video = GL_FALSE;
 GLboolean __GLEW_NV_primitive_restart = GL_FALSE;
 GLboolean __GLEW_NV_register_combiners = GL_FALSE;
 GLboolean __GLEW_NV_register_combiners2 = GL_FALSE;
+GLboolean __GLEW_NV_shader_buffer_load = GL_FALSE;
 GLboolean __GLEW_NV_texgen_emboss = GL_FALSE;
 GLboolean __GLEW_NV_texgen_reflection = GL_FALSE;
+GLboolean __GLEW_NV_texture_barrier = GL_FALSE;
 GLboolean __GLEW_NV_texture_compression_vtc = GL_FALSE;
 GLboolean __GLEW_NV_texture_env_combine4 = GL_FALSE;
 GLboolean __GLEW_NV_texture_expand_normal = GL_FALSE;
@@ -2086,8 +2290,10 @@ GLboolean __GLEW_NV_texture_shader = GL_FALSE;
 GLboolean __GLEW_NV_texture_shader2 = GL_FALSE;
 GLboolean __GLEW_NV_texture_shader3 = GL_FALSE;
 GLboolean __GLEW_NV_transform_feedback = GL_FALSE;
+GLboolean __GLEW_NV_transform_feedback2 = GL_FALSE;
 GLboolean __GLEW_NV_vertex_array_range = GL_FALSE;
 GLboolean __GLEW_NV_vertex_array_range2 = GL_FALSE;
+GLboolean __GLEW_NV_vertex_buffer_unified_memory = GL_FALSE;
 GLboolean __GLEW_NV_vertex_program = GL_FALSE;
 GLboolean __GLEW_NV_vertex_program1_1 = GL_FALSE;
 GLboolean __GLEW_NV_vertex_program2 = GL_FALSE;
@@ -2463,8 +2669,6 @@ static GLboolean _glewInit_GL_VERSION_3_0 (GLEW_CONTEXT_ARG_DEF_INIT)
 
   r = ((glBeginConditionalRender = (PFNGLBEGINCONDITIONALRENDERPROC)glewGetProcAddress((const GLubyte*)"glBeginConditionalRender")) == NULL) || r;
   r = ((glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC)glewGetProcAddress((const GLubyte*)"glBeginTransformFeedback")) == NULL) || r;
-  r = ((glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)glewGetProcAddress((const GLubyte*)"glBindBufferBase")) == NULL) || r;
-  r = ((glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC)glewGetProcAddress((const GLubyte*)"glBindBufferRange")) == NULL) || r;
   r = ((glBindFragDataLocation = (PFNGLBINDFRAGDATALOCATIONPROC)glewGetProcAddress((const GLubyte*)"glBindFragDataLocation")) == NULL) || r;
   r = ((glClampColor = (PFNGLCLAMPCOLORPROC)glewGetProcAddress((const GLubyte*)"glClampColor")) == NULL) || r;
   r = ((glClearBufferfi = (PFNGLCLEARBUFFERFIPROC)glewGetProcAddress((const GLubyte*)"glClearBufferfi")) == NULL) || r;
@@ -2478,7 +2682,6 @@ static GLboolean _glewInit_GL_VERSION_3_0 (GLEW_CONTEXT_ARG_DEF_INIT)
   r = ((glEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC)glewGetProcAddress((const GLubyte*)"glEndTransformFeedback")) == NULL) || r;
   r = ((glGetBooleani_v = (PFNGLGETBOOLEANI_VPROC)glewGetProcAddress((const GLubyte*)"glGetBooleani_v")) == NULL) || r;
   r = ((glGetFragDataLocation = (PFNGLGETFRAGDATALOCATIONPROC)glewGetProcAddress((const GLubyte*)"glGetFragDataLocation")) == NULL) || r;
-  r = ((glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC)glewGetProcAddress((const GLubyte*)"glGetIntegeri_v")) == NULL) || r;
   r = ((glGetStringi = (PFNGLGETSTRINGIPROC)glewGetProcAddress((const GLubyte*)"glGetStringi")) == NULL) || r;
   r = ((glGetTexParameterIiv = (PFNGLGETTEXPARAMETERIIVPROC)glewGetProcAddress((const GLubyte*)"glGetTexParameterIiv")) == NULL) || r;
   r = ((glGetTexParameterIuiv = (PFNGLGETTEXPARAMETERIUIVPROC)glewGetProcAddress((const GLubyte*)"glGetTexParameterIuiv")) == NULL) || r;
@@ -2525,6 +2728,37 @@ static GLboolean _glewInit_GL_VERSION_3_0 (GLEW_CONTEXT_ARG_DEF_INIT)
 
 #endif /* GL_VERSION_3_0 */
 
+#ifdef GL_VERSION_3_1
+
+static GLboolean _glewInit_GL_VERSION_3_1 (GLEW_CONTEXT_ARG_DEF_INIT)
+{
+  GLboolean r = GL_FALSE;
+
+  r = ((glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC)glewGetProcAddress((const GLubyte*)"glDrawArraysInstanced")) == NULL) || r;
+  r = ((glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDPROC)glewGetProcAddress((const GLubyte*)"glDrawElementsInstanced")) == NULL) || r;
+  r = ((glPrimitiveRestartIndex = (PFNGLPRIMITIVERESTARTINDEXPROC)glewGetProcAddress((const GLubyte*)"glPrimitiveRestartIndex")) == NULL) || r;
+  r = ((glTexBuffer = (PFNGLTEXBUFFERPROC)glewGetProcAddress((const GLubyte*)"glTexBuffer")) == NULL) || r;
+
+  return r;
+}
+
+#endif /* GL_VERSION_3_1 */
+
+#ifdef GL_VERSION_3_2
+
+static GLboolean _glewInit_GL_VERSION_3_2 (GLEW_CONTEXT_ARG_DEF_INIT)
+{
+  GLboolean r = GL_FALSE;
+
+  r = ((glFramebufferTexture = (PFNGLFRAMEBUFFERTEXTUREPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexture")) == NULL) || r;
+  r = ((glGetBufferParameteri64v = (PFNGLGETBUFFERPARAMETERI64VPROC)glewGetProcAddress((const GLubyte*)"glGetBufferParameteri64v")) == NULL) || r;
+  r = ((glGetInteger64i_v = (PFNGLGETINTEGER64I_VPROC)glewGetProcAddress((const GLubyte*)"glGetInteger64i_v")) == NULL) || r;
+
+  return r;
+}
+
+#endif /* GL_VERSION_3_2 */
+
 #ifdef GL_3DFX_multisample
 
 #endif /* GL_3DFX_multisample */
@@ -2546,6 +2780,67 @@ static GLboolean _glewInit_GL_3DFX_tbuffer (GLEW_CONTEXT_ARG_DEF_INIT)
 
 #endif /* GL_3DFX_texture_compression_FXT1 */
 
+#ifdef GL_AMD_draw_buffers_blend
+
+static GLboolean _glewInit_GL_AMD_draw_buffers_blend (GLEW_CONTEXT_ARG_DEF_INIT)
+{
+  GLboolean r = GL_FALSE;
+
+  r = ((glBlendEquationIndexedAMD = (PFNGLBLENDEQUATIONINDEXEDAMDPROC)glewGetProcAddress((const GLubyte*)"glBlendEquationIndexedAMD")) == NULL) || r;
+  r = ((glBlendEquationSeparateIndexedAMD = (PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC)glewGetProcAddress((const GLubyte*)"glBlendEquationSeparateIndexedAMD")) == NULL) || r;
+  r = ((glBlendFuncIndexedAMD = (PFNGLBLENDFUNCINDEXEDAMDPROC)glewGetProcAddress((const GLubyte*)"glBlendFuncIndexedAMD")) == NULL) || r;
+  r = ((glBlendFuncSeparateIndexedAMD = (PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC)glewGetProcAddress((const GLubyte*)"glBlendFuncSeparateIndexedAMD")) == NULL) || r;
+
+  return r;
+}
+
+#endif /* GL_AMD_draw_buffers_blend */
+
+#ifdef GL_AMD_performance_monitor
+
+static GLboolean _glewInit_GL_AMD_performance_monitor (GLEW_CONTEXT_ARG_DEF_INIT)
+{
+  GLboolean r = GL_FALSE;
+
+  r = ((glBeginPerfMonitorAMD = (PFNGLBEGINPERFMONITORAMDPROC)glewGetProcAddress((const GLubyte*)"glBeginPerfMonitorAMD")) == NULL) || r;
+  r = ((glDeletePerfMonitorsAMD = (PFNGLDELETEPERFMONITORSAMDPROC)glewGetProcAddress((const GLubyte*)"glDeletePerfMonitorsAMD")) == NULL) || r;
+  r = ((glEndPerfMonitorAMD = (PFNGLENDPERFMONITORAMDPROC)glewGetProcAddress((const GLubyte*)"glEndPerfMonitorAMD")) == NULL) || r;
+  r = ((glGenPerfMonitorsAMD = (PFNGLGENPERFMONITORSAMDPROC)glewGetProcAddress((const GLubyte*)"glGenPerfMonitorsAMD")) == NULL) || r;
+  r = ((glGetPerfMonitorCounterDataAMD = (PFNGLGETPERFMONITORCOUNTERDATAAMDPROC)glewGetProcAddress((const GLubyte*)"glGetPerfMonitorCounterDataAMD")) == NULL) || r;
+  r = ((glGetPerfMonitorCounterInfoAMD = (PFNGLGETPERFMONITORCOUNTERINFOAMDPROC)glewGetProcAddress((const GLubyte*)"glGetPerfMonitorCounterInfoAMD")) == NULL) || r;
+  r = ((glGetPerfMonitorCounterStringAMD = (PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC)glewGetProcAddress((const GLubyte*)"glGetPerfMonitorCounterStringAMD")) == NULL) || r;
+  r = ((glGetPerfMonitorCountersAMD = (PFNGLGETPERFMONITORCOUNTERSAMDPROC)glewGetProcAddress((const GLubyte*)"glGetPerfMonitorCountersAMD")) == NULL) || r;
+  r = ((glGetPerfMonitorGroupStringAMD = (PFNGLGETPERFMONITORGROUPSTRINGAMDPROC)glewGetProcAddress((const GLubyte*)"glGetPerfMonitorGroupStringAMD")) == NULL) || r;
+  r = ((glGetPerfMonitorGroupsAMD = (PFNGLGETPERFMONITORGROUPSAMDPROC)glewGetProcAddress((const GLubyte*)"glGetPerfMonitorGroupsAMD")) == NULL) || r;
+  r = ((glSelectPerfMonitorCountersAMD = (PFNGLSELECTPERFMONITORCOUNTERSAMDPROC)glewGetProcAddress((const GLubyte*)"glSelectPerfMonitorCountersAMD")) == NULL) || r;
+
+  return r;
+}
+
+#endif /* GL_AMD_performance_monitor */
+
+#ifdef GL_AMD_texture_texture4
+
+#endif /* GL_AMD_texture_texture4 */
+
+#ifdef GL_AMD_vertex_shader_tessellator
+
+static GLboolean _glewInit_GL_AMD_vertex_shader_tessellator (GLEW_CONTEXT_ARG_DEF_INIT)
+{
+  GLboolean r = GL_FALSE;
+
+  r = ((glTessellationFactorAMD = (PFNGLTESSELLATIONFACTORAMDPROC)glewGetProcAddress((const GLubyte*)"glTessellationFactorAMD")) == NULL) || r;
+  r = ((glTessellationModeAMD = (PFNGLTESSELLATIONMODEAMDPROC)glewGetProcAddress((const GLubyte*)"glTessellationModeAMD")) == NULL) || r;
+
+  return r;
+}
+
+#endif /* GL_AMD_vertex_shader_tessellator */
+
+#ifdef GL_APPLE_aux_depth_stencil
+
+#endif /* GL_APPLE_aux_depth_stencil */
+
 #ifdef GL_APPLE_client_storage
 
 #endif /* GL_APPLE_client_storage */
@@ -2605,10 +2900,33 @@ static GLboolean _glewInit_GL_APPLE_flush_buffer_range (GLEW_CONTEXT_ARG_DEF_INI
 
 #endif /* GL_APPLE_flush_buffer_range */
 
+#ifdef GL_APPLE_object_purgeable
+
+static GLboolean _glewInit_GL_APPLE_object_purgeable (GLEW_CONTEXT_ARG_DEF_INIT)
+{
+  GLboolean r = GL_FALSE;
+
+  r = ((glGetObjectParameterivAPPLE = (PFNGLGETOBJECTPARAMETERIVAPPLEPROC)glewGetProcAddress((const GLubyte*)"glGetObjectParameterivAPPLE")) == NULL) || r;
+  r = ((glObjectPurgeableAPPLE = (PFNGLOBJECTPURGEABLEAPPLEPROC)glewGetProcAddress((const GLubyte*)"glObjectPurgeableAPPLE")) == NULL) || r;
+  r = ((glObjectUnpurgeableAPPLE = (PFNGLOBJECTUNPURGEABLEAPPLEPROC)glewGetProcAddress((const GLubyte*)"glObjectUnpurgeableAPPLE")) == NULL) || r;
+
+  return r;
+}
+
+#endif /* GL_APPLE_object_purgeable */
+
 #ifdef GL_APPLE_pixel_buffer
 
 #endif /* GL_APPLE_pixel_buffer */
 
+#ifdef GL_APPLE_rgb_422
+
+#endif /* GL_APPLE_rgb_422 */
+
+#ifdef GL_APPLE_row_bytes
+
+#endif /* GL_APPLE_row_bytes */
+
 #ifdef GL_APPLE_specular_vector
 
 #endif /* GL_APPLE_specular_vector */
@@ -2662,6 +2980,25 @@ static GLboolean _glewInit_GL_APPLE_vertex_array_range (GLEW_CONTEXT_ARG_DEF_INI
 
 #endif /* GL_APPLE_vertex_array_range */
 
+#ifdef GL_APPLE_vertex_program_evaluators
+
+static GLboolean _glewInit_GL_APPLE_vertex_program_evaluators (GLEW_CONTEXT_ARG_DEF_INIT)
+{
+  GLboolean r = GL_FALSE;
+
+  r = ((glDisableVertexAttribAPPLE = (PFNGLDISABLEVERTEXATTRIBAPPLEPROC)glewGetProcAddress((const GLubyte*)"glDisableVertexAttribAPPLE")) == NULL) || r;
+  r = ((glEnableVertexAttribAPPLE = (PFNGLENABLEVERTEXATTRIBAPPLEPROC)glewGetProcAddress((const GLubyte*)"glEnableVertexAttribAPPLE")) == NULL) || r;
+  r = ((glIsVertexAttribEnabledAPPLE = (PFNGLISVERTEXATTRIBENABLEDAPPLEPROC)glewGetProcAddress((const GLubyte*)"glIsVertexAttribEnabledAPPLE")) == NULL) || r;
+  r = ((glMapVertexAttrib1dAPPLE = (PFNGLMAPVERTEXATTRIB1DAPPLEPROC)glewGetProcAddress((const GLubyte*)"glMapVertexAttrib1dAPPLE")) == NULL) || r;
+  r = ((glMapVertexAttrib1fAPPLE = (PFNGLMAPVERTEXATTRIB1FAPPLEPROC)glewGetProcAddress((const GLubyte*)"glMapVertexAttrib1fAPPLE")) == NULL) || r;
+  r = ((glMapVertexAttrib2dAPPLE = (PFNGLMAPVERTEXATTRIB2DAPPLEPROC)glewGetProcAddress((const GLubyte*)"glMapVertexAttrib2dAPPLE")) == NULL) || r;
+  r = ((glMapVertexAttrib2fAPPLE = (PFNGLMAPVERTEXATTRIB2FAPPLEPROC)glewGetProcAddress((const GLubyte*)"glMapVertexAttrib2fAPPLE")) == NULL) || r;
+
+  return r;
+}
+
+#endif /* GL_APPLE_vertex_program_evaluators */
+
 #ifdef GL_APPLE_ycbcr_422
 
 #endif /* GL_APPLE_ycbcr_422 */
@@ -2679,10 +3016,31 @@ static GLboolean _glewInit_GL_ARB_color_buffer_float (GLEW_CONTEXT_ARG_DEF_INIT)
 
 #endif /* GL_ARB_color_buffer_float */
 
+#ifdef GL_ARB_compatibility
+
+#endif /* GL_ARB_compatibility */
+
+#ifdef GL_ARB_copy_buffer
+
+static GLboolean _glewInit_GL_ARB_copy_buffer (GLEW_CONTEXT_ARG_DEF_INIT)
+{
+  GLboolean r = GL_FALSE;
+
+  r = ((glCopyBufferSubData = (PFNGLCOPYBUFFERSUBDATAPROC)glewGetProcAddress((const GLubyte*)"glCopyBufferSubData")) == NULL) || r;
+
+  return r;
+}
+
+#endif /* GL_ARB_copy_buffer */
+
 #ifdef GL_ARB_depth_buffer_float
 
 #endif /* GL_ARB_depth_buffer_float */
 
+#ifdef GL_ARB_depth_clamp
+
+#endif /* GL_ARB_depth_clamp */
+
 #ifdef GL_ARB_depth_texture
 
 #endif /* GL_ARB_depth_texture */
@@ -2700,6 +3058,38 @@ static GLboolean _glewInit_GL_ARB_draw_buffers (GLEW_CONTEXT_ARG_DEF_INIT)
 
 #endif /* GL_ARB_draw_buffers */
 
+#ifdef GL_ARB_draw_buffers_blend
+
+static GLboolean _glewInit_GL_ARB_draw_buffers_blend (GLEW_CONTEXT_ARG_DEF_INIT)
+{
+  GLboolean r = GL_FALSE;
+
+  r = ((glBlendEquationSeparateiARB = (PFNGLBLENDEQUATIONSEPARATEIARBPROC)glewGetProcAddress((const GLubyte*)"glBlendEquationSeparateiARB")) == NULL) || r;
+  r = ((glBlendEquationiARB = (PFNGLBLENDEQUATIONIARBPROC)glewGetProcAddress((const GLubyte*)"glBlendEquationiARB")) == NULL) || r;
+  r = ((glBlendFuncSeparateiARB = (PFNGLBLENDFUNCSEPARATEIARBPROC)glewGetProcAddress((const GLubyte*)"glBlendFuncSeparateiARB")) == NULL) || r;
+  r = ((glBlendFunciARB = (PFNGLBLENDFUNCIARBPROC)glewGetProcAddress((const GLubyte*)"glBlendFunciARB")) == NULL) || r;
+
+  return r;
+}
+
+#endif /* GL_ARB_draw_buffers_blend */
+
+#ifdef GL_ARB_draw_elements_base_vertex
+
+static GLboolean _glewInit_GL_ARB_draw_elements_base_vertex (GLEW_CONTEXT_ARG_DEF_INIT)
+{
+  GLboolean r = GL_FALSE;
+
+  r = ((glDrawElementsBaseVertex = (PFNGLDRAWELEMENTSBASEVERTEXPROC)glewGetProcAddress((const GLubyte*)"glDrawElementsBaseVertex")) == NULL) || r;
+  r = ((glDrawElementsInstancedBaseVertex = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)glewGetProcAddress((const GLubyte*)"glDrawElementsInstancedBaseVertex")) == NULL) || r;
+  r = ((glDrawRangeElementsBaseVertex = (PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC)glewGetProcAddress((const GLubyte*)"glDrawRangeElementsBaseVertex")) == NULL) || r;
+  r = ((glMultiDrawElementsBaseVertex = (PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC)glewGetProcAddress((const GLubyte*)"glMultiDrawElementsBaseVertex")) == NULL) || r;
+
+  return r;
+}
+
+#endif /* GL_ARB_draw_elements_base_vertex */
+
 #ifdef GL_ARB_draw_instanced
 
 static GLboolean _glewInit_GL_ARB_draw_instanced (GLEW_CONTEXT_ARG_DEF_INIT)
@@ -2714,6 +3104,10 @@ static GLboolean _glewInit_GL_ARB_draw_instanced (GLEW_CONTEXT_ARG_DEF_INIT)
 
 #endif /* GL_ARB_draw_instanced */
 
+#ifdef GL_ARB_fragment_coord_conventions
+
+#endif /* GL_ARB_fragment_coord_conventions */
+
 #ifdef GL_ARB_fragment_program
 
 #endif /* GL_ARB_fragment_program */
@@ -2739,10 +3133,10 @@ static GLboolean _glewInit_GL_ARB_framebuffer_object (GLEW_CONTEXT_ARG_DEF_INIT)
   r = ((glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glDeleteFramebuffers")) == NULL) || r;
   r = ((glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glDeleteRenderbuffers")) == NULL) || r;
   r = ((glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)glewGetProcAddress((const GLubyte*)"glFramebufferRenderbuffer")) == NULL) || r;
-  r = ((glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTextureLayer")) == NULL) || r;
   r = ((glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexture1D")) == NULL) || r;
   r = ((glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexture2D")) == NULL) || r;
   r = ((glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexture3D")) == NULL) || r;
+  r = ((glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTextureLayer")) == NULL) || r;
   r = ((glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glGenFramebuffers")) == NULL) || r;
   r = ((glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glGenRenderbuffers")) == NULL) || r;
   r = ((glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC)glewGetProcAddress((const GLubyte*)"glGenerateMipmap")) == NULL) || r;
@@ -2976,6 +3370,36 @@ static GLboolean _glewInit_GL_ARB_point_parameters (GLEW_CONTEXT_ARG_DEF_INIT)
 
 #endif /* GL_ARB_point_sprite */
 
+#ifdef GL_ARB_provoking_vertex
+
+static GLboolean _glewInit_GL_ARB_provoking_vertex (GLEW_CONTEXT_ARG_DEF_INIT)
+{
+  GLboolean r = GL_FALSE;
+
+  r = ((glProvokingVertex = (PFNGLPROVOKINGVERTEXPROC)glewGetProcAddress((const GLubyte*)"glProvokingVertex")) == NULL) || r;
+
+  return r;
+}
+
+#endif /* GL_ARB_provoking_vertex */
+
+#ifdef GL_ARB_sample_shading
+
+static GLboolean _glewInit_GL_ARB_sample_shading (GLEW_CONTEXT_ARG_DEF_INIT)
+{
+  GLboolean r = GL_FALSE;
+
+  r = ((glMinSampleShadingARB = (PFNGLMINSAMPLESHADINGARBPROC)glewGetProcAddress((const GLubyte*)"glMinSampleShadingARB")) == NULL) || r;
+
+  return r;
+}
+
+#endif /* GL_ARB_sample_shading */
+
+#ifdef GL_ARB_seamless_cube_map
+
+#endif /* GL_ARB_seamless_cube_map */
+
 #ifdef GL_ARB_shader_objects
 
 static GLboolean _glewInit_GL_ARB_shader_objects (GLEW_CONTEXT_ARG_DEF_INIT)
@@ -3027,6 +3451,10 @@ static GLboolean _glewInit_GL_ARB_shader_objects (GLEW_CONTEXT_ARG_DEF_INIT)
 
 #endif /* GL_ARB_shader_objects */
 
+#ifdef GL_ARB_shader_texture_lod
+
+#endif /* GL_ARB_shader_texture_lod */
+
 #ifdef GL_ARB_shading_language_100
 
 #endif /* GL_ARB_shading_language_100 */
@@ -3039,6 +3467,25 @@ static GLboolean _glewInit_GL_ARB_shader_objects (GLEW_CONTEXT_ARG_DEF_INIT)
 
 #endif /* GL_ARB_shadow_ambient */
 
+#ifdef GL_ARB_sync
+
+static GLboolean _glewInit_GL_ARB_sync (GLEW_CONTEXT_ARG_DEF_INIT)
+{
+  GLboolean r = GL_FALSE;
+
+  r = ((glClientWaitSync = (PFNGLCLIENTWAITSYNCPROC)glewGetProcAddress((const GLubyte*)"glClientWaitSync")) == NULL) || r;
+  r = ((glDeleteSync = (PFNGLDELETESYNCPROC)glewGetProcAddress((const GLubyte*)"glDeleteSync")) == NULL) || r;
+  r = ((glFenceSync = (PFNGLFENCESYNCPROC)glewGetProcAddress((const GLubyte*)"glFenceSync")) == NULL) || r;
+  r = ((glGetInteger64v = (PFNGLGETINTEGER64VPROC)glewGetProcAddress((const GLubyte*)"glGetInteger64v")) == NULL) || r;
+  r = ((glGetSynciv = (PFNGLGETSYNCIVPROC)glewGetProcAddress((const GLubyte*)"glGetSynciv")) == NULL) || r;
+  r = ((glIsSync = (PFNGLISSYNCPROC)glewGetProcAddress((const GLubyte*)"glIsSync")) == NULL) || r;
+  r = ((glWaitSync = (PFNGLWAITSYNCPROC)glewGetProcAddress((const GLubyte*)"glWaitSync")) == NULL) || r;
+
+  return r;
+}
+
+#endif /* GL_ARB_sync */
+
 #ifdef GL_ARB_texture_border_clamp
 
 #endif /* GL_ARB_texture_border_clamp */
@@ -3083,6 +3530,10 @@ static GLboolean _glewInit_GL_ARB_texture_compression (GLEW_CONTEXT_ARG_DEF_INIT
 
 #endif /* GL_ARB_texture_cube_map */
 
+#ifdef GL_ARB_texture_cube_map_array
+
+#endif /* GL_ARB_texture_cube_map_array */
+
 #ifdef GL_ARB_texture_env_add
 
 #endif /* GL_ARB_texture_env_add */
@@ -3103,14 +3554,38 @@ static GLboolean _glewInit_GL_ARB_texture_compression (GLEW_CONTEXT_ARG_DEF_INIT
 
 #endif /* GL_ARB_texture_float */
 
+#ifdef GL_ARB_texture_gather
+
+#endif /* GL_ARB_texture_gather */
+
 #ifdef GL_ARB_texture_mirrored_repeat
 
 #endif /* GL_ARB_texture_mirrored_repeat */
 
+#ifdef GL_ARB_texture_multisample
+
+static GLboolean _glewInit_GL_ARB_texture_multisample (GLEW_CONTEXT_ARG_DEF_INIT)
+{
+  GLboolean r = GL_FALSE;
+
+  r = ((glGetMultisamplefv = (PFNGLGETMULTISAMPLEFVPROC)glewGetProcAddress((const GLubyte*)"glGetMultisamplefv")) == NULL) || r;
+  r = ((glSampleMaski = (PFNGLSAMPLEMASKIPROC)glewGetProcAddress((const GLubyte*)"glSampleMaski")) == NULL) || r;
+  r = ((glTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC)glewGetProcAddress((const GLubyte*)"glTexImage2DMultisample")) == NULL) || r;
+  r = ((glTexImage3DMultisample = (PFNGLTEXIMAGE3DMULTISAMPLEPROC)glewGetProcAddress((const GLubyte*)"glTexImage3DMultisample")) == NULL) || r;
+
+  return r;
+}
+
+#endif /* GL_ARB_texture_multisample */
+
 #ifdef GL_ARB_texture_non_power_of_two
 
 #endif /* GL_ARB_texture_non_power_of_two */
 
+#ifdef GL_ARB_texture_query_lod
+
+#endif /* GL_ARB_texture_query_lod */
+
 #ifdef GL_ARB_texture_rectangle
 
 #endif /* GL_ARB_texture_rectangle */
@@ -3135,6 +3610,32 @@ static GLboolean _glewInit_GL_ARB_transpose_matrix (GLEW_CONTEXT_ARG_DEF_INIT)
 
 #endif /* GL_ARB_transpose_matrix */
 
+#ifdef GL_ARB_uniform_buffer_object
+
+static GLboolean _glewInit_GL_ARB_uniform_buffer_object (GLEW_CONTEXT_ARG_DEF_INIT)
+{
+  GLboolean r = GL_FALSE;
+
+  r = ((glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)glewGetProcAddress((const GLubyte*)"glBindBufferBase")) == NULL) || r;
+  r = ((glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC)glewGetProcAddress((const GLubyte*)"glBindBufferRange")) == NULL) || r;
+  r = ((glGetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)glewGetProcAddress((const GLubyte*)"glGetActiveUniformBlockName")) == NULL) || r;
+  r = ((glGetActiveUniformBlockiv = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC)glewGetProcAddress((const GLubyte*)"glGetActiveUniformBlockiv")) == NULL) || r;
+  r = ((glGetActiveUniformName = (PFNGLGETACTIVEUNIFORMNAMEPROC)glewGetProcAddress((const GLubyte*)"glGetActiveUniformName")) == NULL) || r;
+  r = ((glGetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC)glewGetProcAddress((const GLubyte*)"glGetActiveUniformsiv")) == NULL) || r;
+  r = ((glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC)glewGetProcAddress((const GLubyte*)"glGetIntegeri_v")) == NULL) || r;
+  r = ((glGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC)glewGetProcAddress((const GLubyte*)"glGetUniformBlockIndex")) == NULL) || r;
+  r = ((glGetUniformIndices = (PFNGLGETUNIFORMINDICESPROC)glewGetProcAddress((const GLubyte*)"glGetUniformIndices")) == NULL) || r;
+  r = ((glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC)glewGetProcAddress((const GLubyte*)"glUniformBlockBinding")) == NULL) || r;
+
+  return r;
+}
+
+#endif /* GL_ARB_uniform_buffer_object */
+
+#ifdef GL_ARB_vertex_array_bgra
+
+#endif /* GL_ARB_vertex_array_bgra */
+
 #ifdef GL_ARB_vertex_array_object
 
 static GLboolean _glewInit_GL_ARB_vertex_array_object (GLEW_CONTEXT_ARG_DEF_INIT)
@@ -3413,6 +3914,10 @@ static GLboolean _glewInit_GL_ATI_map_object_buffer (GLEW_CONTEXT_ARG_DEF_INIT)
 
 #endif /* GL_ATI_map_object_buffer */
 
+#ifdef GL_ATI_meminfo
+
+#endif /* GL_ATI_meminfo */
+
 #ifdef GL_ATI_pn_triangles
 
 static GLboolean _glewInit_GL_ATI_pn_triangles (GLEW_CONTEXT_ARG_DEF_INIT)
@@ -3795,7 +4300,14 @@ static GLboolean _glewInit_GL_EXT_direct_state_access (GLEW_CONTEXT_ARG_DEF_INIT
   r = ((glCopyTextureSubImage2DEXT = (PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyTextureSubImage2DEXT")) == NULL) || r;
   r = ((glCopyTextureSubImage3DEXT = (PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyTextureSubImage3DEXT")) == NULL) || r;
   r = ((glDisableClientStateIndexedEXT = (PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC)glewGetProcAddress((const GLubyte*)"glDisableClientStateIndexedEXT")) == NULL) || r;
+  r = ((glDisableClientStateiEXT = (PFNGLDISABLECLIENTSTATEIEXTPROC)glewGetProcAddress((const GLubyte*)"glDisableClientStateiEXT")) == NULL) || r;
+  r = ((glDisableVertexArrayAttribEXT = (PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC)glewGetProcAddress((const GLubyte*)"glDisableVertexArrayAttribEXT")) == NULL) || r;
+  r = ((glDisableVertexArrayEXT = (PFNGLDISABLEVERTEXARRAYEXTPROC)glewGetProcAddress((const GLubyte*)"glDisableVertexArrayEXT")) == NULL) || r;
   r = ((glEnableClientStateIndexedEXT = (PFNGLENABLECLIENTSTATEINDEXEDEXTPROC)glewGetProcAddress((const GLubyte*)"glEnableClientStateIndexedEXT")) == NULL) || r;
+  r = ((glEnableClientStateiEXT = (PFNGLENABLECLIENTSTATEIEXTPROC)glewGetProcAddress((const GLubyte*)"glEnableClientStateiEXT")) == NULL) || r;
+  r = ((glEnableVertexArrayAttribEXT = (PFNGLENABLEVERTEXARRAYATTRIBEXTPROC)glewGetProcAddress((const GLubyte*)"glEnableVertexArrayAttribEXT")) == NULL) || r;
+  r = ((glEnableVertexArrayEXT = (PFNGLENABLEVERTEXARRAYEXTPROC)glewGetProcAddress((const GLubyte*)"glEnableVertexArrayEXT")) == NULL) || r;
+  r = ((glFlushMappedNamedBufferRangeEXT = (PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC)glewGetProcAddress((const GLubyte*)"glFlushMappedNamedBufferRangeEXT")) == NULL) || r;
   r = ((glFramebufferDrawBufferEXT = (PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferDrawBufferEXT")) == NULL) || r;
   r = ((glFramebufferDrawBuffersEXT = (PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferDrawBuffersEXT")) == NULL) || r;
   r = ((glFramebufferReadBufferEXT = (PFNGLFRAMEBUFFERREADBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferReadBufferEXT")) == NULL) || r;
@@ -3804,7 +4316,9 @@ static GLboolean _glewInit_GL_EXT_direct_state_access (GLEW_CONTEXT_ARG_DEF_INIT
   r = ((glGetCompressedMultiTexImageEXT = (PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC)glewGetProcAddress((const GLubyte*)"glGetCompressedMultiTexImageEXT")) == NULL) || r;
   r = ((glGetCompressedTextureImageEXT = (PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC)glewGetProcAddress((const GLubyte*)"glGetCompressedTextureImageEXT")) == NULL) || r;
   r = ((glGetDoubleIndexedvEXT = (PFNGLGETDOUBLEINDEXEDVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetDoubleIndexedvEXT")) == NULL) || r;
+  r = ((glGetDoublei_vEXT = (PFNGLGETDOUBLEI_VEXTPROC)glewGetProcAddress((const GLubyte*)"glGetDoublei_vEXT")) == NULL) || r;
   r = ((glGetFloatIndexedvEXT = (PFNGLGETFLOATINDEXEDVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetFloatIndexedvEXT")) == NULL) || r;
+  r = ((glGetFloati_vEXT = (PFNGLGETFLOATI_VEXTPROC)glewGetProcAddress((const GLubyte*)"glGetFloati_vEXT")) == NULL) || r;
   r = ((glGetFramebufferParameterivEXT = (PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetFramebufferParameterivEXT")) == NULL) || r;
   r = ((glGetMultiTexEnvfvEXT = (PFNGLGETMULTITEXENVFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexEnvfvEXT")) == NULL) || r;
   r = ((glGetMultiTexEnvivEXT = (PFNGLGETMULTITEXENVIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexEnvivEXT")) == NULL) || r;
@@ -3830,6 +4344,7 @@ static GLboolean _glewInit_GL_EXT_direct_state_access (GLEW_CONTEXT_ARG_DEF_INIT
   r = ((glGetNamedProgramivEXT = (PFNGLGETNAMEDPROGRAMIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedProgramivEXT")) == NULL) || r;
   r = ((glGetNamedRenderbufferParameterivEXT = (PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedRenderbufferParameterivEXT")) == NULL) || r;
   r = ((glGetPointerIndexedvEXT = (PFNGLGETPOINTERINDEXEDVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetPointerIndexedvEXT")) == NULL) || r;
+  r = ((glGetPointeri_vEXT = (PFNGLGETPOINTERI_VEXTPROC)glewGetProcAddress((const GLubyte*)"glGetPointeri_vEXT")) == NULL) || r;
   r = ((glGetTextureImageEXT = (PFNGLGETTEXTUREIMAGEEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTextureImageEXT")) == NULL) || r;
   r = ((glGetTextureLevelParameterfvEXT = (PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTextureLevelParameterfvEXT")) == NULL) || r;
   r = ((glGetTextureLevelParameterivEXT = (PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTextureLevelParameterivEXT")) == NULL) || r;
@@ -3837,7 +4352,12 @@ static GLboolean _glewInit_GL_EXT_direct_state_access (GLEW_CONTEXT_ARG_DEF_INIT
   r = ((glGetTextureParameterIuivEXT = (PFNGLGETTEXTUREPARAMETERIUIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTextureParameterIuivEXT")) == NULL) || r;
   r = ((glGetTextureParameterfvEXT = (PFNGLGETTEXTUREPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTextureParameterfvEXT")) == NULL) || r;
   r = ((glGetTextureParameterivEXT = (PFNGLGETTEXTUREPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTextureParameterivEXT")) == NULL) || r;
+  r = ((glGetVertexArrayIntegeri_vEXT = (PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC)glewGetProcAddress((const GLubyte*)"glGetVertexArrayIntegeri_vEXT")) == NULL) || r;
+  r = ((glGetVertexArrayIntegervEXT = (PFNGLGETVERTEXARRAYINTEGERVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetVertexArrayIntegervEXT")) == NULL) || r;
+  r = ((glGetVertexArrayPointeri_vEXT = (PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC)glewGetProcAddress((const GLubyte*)"glGetVertexArrayPointeri_vEXT")) == NULL) || r;
+  r = ((glGetVertexArrayPointervEXT = (PFNGLGETVERTEXARRAYPOINTERVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetVertexArrayPointervEXT")) == NULL) || r;
   r = ((glMapNamedBufferEXT = (PFNGLMAPNAMEDBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glMapNamedBufferEXT")) == NULL) || r;
+  r = ((glMapNamedBufferRangeEXT = (PFNGLMAPNAMEDBUFFERRANGEEXTPROC)glewGetProcAddress((const GLubyte*)"glMapNamedBufferRangeEXT")) == NULL) || r;
   r = ((glMatrixFrustumEXT = (PFNGLMATRIXFRUSTUMEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixFrustumEXT")) == NULL) || r;
   r = ((glMatrixLoadIdentityEXT = (PFNGLMATRIXLOADIDENTITYEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixLoadIdentityEXT")) == NULL) || r;
   r = ((glMatrixLoadTransposedEXT = (PFNGLMATRIXLOADTRANSPOSEDEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixLoadTransposedEXT")) == NULL) || r;
@@ -3884,6 +4404,7 @@ static GLboolean _glewInit_GL_EXT_direct_state_access (GLEW_CONTEXT_ARG_DEF_INIT
   r = ((glMultiTexSubImage3DEXT = (PFNGLMULTITEXSUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexSubImage3DEXT")) == NULL) || r;
   r = ((glNamedBufferDataEXT = (PFNGLNAMEDBUFFERDATAEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedBufferDataEXT")) == NULL) || r;
   r = ((glNamedBufferSubDataEXT = (PFNGLNAMEDBUFFERSUBDATAEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedBufferSubDataEXT")) == NULL) || r;
+  r = ((glNamedCopyBufferSubDataEXT = (PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedCopyBufferSubDataEXT")) == NULL) || r;
   r = ((glNamedFramebufferRenderbufferEXT = (PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferRenderbufferEXT")) == NULL) || r;
   r = ((glNamedFramebufferTexture1DEXT = (PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferTexture1DEXT")) == NULL) || r;
   r = ((glNamedFramebufferTexture2DEXT = (PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferTexture2DEXT")) == NULL) || r;
@@ -3955,6 +4476,17 @@ static GLboolean _glewInit_GL_EXT_direct_state_access (GLEW_CONTEXT_ARG_DEF_INIT
   r = ((glTextureSubImage2DEXT = (PFNGLTEXTURESUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureSubImage2DEXT")) == NULL) || r;
   r = ((glTextureSubImage3DEXT = (PFNGLTEXTURESUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureSubImage3DEXT")) == NULL) || r;
   r = ((glUnmapNamedBufferEXT = (PFNGLUNMAPNAMEDBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glUnmapNamedBufferEXT")) == NULL) || r;
+  r = ((glVertexArrayColorOffsetEXT = (PFNGLVERTEXARRAYCOLOROFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayColorOffsetEXT")) == NULL) || r;
+  r = ((glVertexArrayEdgeFlagOffsetEXT = (PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayEdgeFlagOffsetEXT")) == NULL) || r;
+  r = ((glVertexArrayFogCoordOffsetEXT = (PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayFogCoordOffsetEXT")) == NULL) || r;
+  r = ((glVertexArrayIndexOffsetEXT = (PFNGLVERTEXARRAYINDEXOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayIndexOffsetEXT")) == NULL) || r;
+  r = ((glVertexArrayMultiTexCoordOffsetEXT = (PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayMultiTexCoordOffsetEXT")) == NULL) || r;
+  r = ((glVertexArrayNormalOffsetEXT = (PFNGLVERTEXARRAYNORMALOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayNormalOffsetEXT")) == NULL) || r;
+  r = ((glVertexArraySecondaryColorOffsetEXT = (PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexArraySecondaryColorOffsetEXT")) == NULL) || r;
+  r = ((glVertexArrayTexCoordOffsetEXT = (PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayTexCoordOffsetEXT")) == NULL) || r;
+  r = ((glVertexArrayVertexAttribIOffsetEXT = (PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayVertexAttribIOffsetEXT")) == NULL) || r;
+  r = ((glVertexArrayVertexAttribOffsetEXT = (PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayVertexAttribOffsetEXT")) == NULL) || r;
+  r = ((glVertexArrayVertexOffsetEXT = (PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayVertexOffsetEXT")) == NULL) || r;
 
   return r;
 }
@@ -4372,6 +4904,19 @@ static GLboolean _glewInit_GL_EXT_polygon_offset (GLEW_CONTEXT_ARG_DEF_INIT)
 
 #endif /* GL_EXT_polygon_offset */
 
+#ifdef GL_EXT_provoking_vertex
+
+static GLboolean _glewInit_GL_EXT_provoking_vertex (GLEW_CONTEXT_ARG_DEF_INIT)
+{
+  GLboolean r = GL_FALSE;
+
+  r = ((glProvokingVertexEXT = (PFNGLPROVOKINGVERTEXEXTPROC)glewGetProcAddress((const GLubyte*)"glProvokingVertexEXT")) == NULL) || r;
+
+  return r;
+}
+
+#endif /* GL_EXT_provoking_vertex */
+
 #ifdef GL_EXT_rescale_normal
 
 #endif /* GL_EXT_rescale_normal */
@@ -4419,6 +4964,21 @@ static GLboolean _glewInit_GL_EXT_secondary_color (GLEW_CONTEXT_ARG_DEF_INIT)
 
 #endif /* GL_EXT_secondary_color */
 
+#ifdef GL_EXT_separate_shader_objects
+
+static GLboolean _glewInit_GL_EXT_separate_shader_objects (GLEW_CONTEXT_ARG_DEF_INIT)
+{
+  GLboolean r = GL_FALSE;
+
+  r = ((glActiveProgramEXT = (PFNGLACTIVEPROGRAMEXTPROC)glewGetProcAddress((const GLubyte*)"glActiveProgramEXT")) == NULL) || r;
+  r = ((glCreateShaderProgramEXT = (PFNGLCREATESHADERPROGRAMEXTPROC)glewGetProcAddress((const GLubyte*)"glCreateShaderProgramEXT")) == NULL) || r;
+  r = ((glUseShaderProgramEXT = (PFNGLUSESHADERPROGRAMEXTPROC)glewGetProcAddress((const GLubyte*)"glUseShaderProgramEXT")) == NULL) || r;
+
+  return r;
+}
+
+#endif /* GL_EXT_separate_shader_objects */
+
 #ifdef GL_EXT_separate_specular_color
 
 #endif /* GL_EXT_separate_specular_color */
@@ -4614,6 +5174,10 @@ static GLboolean _glewInit_GL_EXT_texture_perturb_normal (GLEW_CONTEXT_ARG_DEF_I
 
 #endif /* GL_EXT_texture_shared_exponent */
 
+#ifdef GL_EXT_texture_snorm
+
+#endif /* GL_EXT_texture_snorm */
+
 #ifdef GL_EXT_texture_swizzle
 
 #endif /* GL_EXT_texture_swizzle */
@@ -4989,6 +5553,19 @@ static GLboolean _glewInit_GL_NV_conditional_render (GLEW_CONTEXT_ARG_DEF_INIT)
 
 #endif /* GL_NV_copy_depth_to_color */
 
+#ifdef GL_NV_copy_image
+
+static GLboolean _glewInit_GL_NV_copy_image (GLEW_CONTEXT_ARG_DEF_INIT)
+{
+  GLboolean r = GL_FALSE;
+
+  r = ((glCopyImageSubDataNV = (PFNGLCOPYIMAGESUBDATANVPROC)glewGetProcAddress((const GLubyte*)"glCopyImageSubDataNV")) == NULL) || r;
+
+  return r;
+}
+
+#endif /* GL_NV_copy_image */
+
 #ifdef GL_NV_depth_buffer_float
 
 static GLboolean _glewInit_GL_NV_depth_buffer_float (GLEW_CONTEXT_ARG_DEF_INIT)
@@ -5263,6 +5840,10 @@ static GLboolean _glewInit_GL_NV_parameter_buffer_object (GLEW_CONTEXT_ARG_DEF_I
 
 #endif /* GL_NV_parameter_buffer_object */
 
+#ifdef GL_NV_parameter_buffer_object2
+
+#endif /* GL_NV_parameter_buffer_object2 */
+
 #ifdef GL_NV_pixel_data_range
 
 static GLboolean _glewInit_GL_NV_pixel_data_range (GLEW_CONTEXT_ARG_DEF_INIT)
@@ -5303,7 +5884,6 @@ static GLboolean _glewInit_GL_NV_present_video (GLEW_CONTEXT_ARG_DEF_INIT)
   r = ((glGetVideouivNV = (PFNGLGETVIDEOUIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetVideouivNV")) == NULL) || r;
   r = ((glPresentFrameDualFillNV = (PFNGLPRESENTFRAMEDUALFILLNVPROC)glewGetProcAddress((const GLubyte*)"glPresentFrameDualFillNV")) == NULL) || r;
   r = ((glPresentFrameKeyedNV = (PFNGLPRESENTFRAMEKEYEDNVPROC)glewGetProcAddress((const GLubyte*)"glPresentFrameKeyedNV")) == NULL) || r;
-  r = ((glVideoParameterivNV = (PFNGLVIDEOPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)"glVideoParameterivNV")) == NULL) || r;
 
   return r;
 }
@@ -5363,6 +5943,32 @@ static GLboolean _glewInit_GL_NV_register_combiners2 (GLEW_CONTEXT_ARG_DEF_INIT)
 
 #endif /* GL_NV_register_combiners2 */
 
+#ifdef GL_NV_shader_buffer_load
+
+static GLboolean _glewInit_GL_NV_shader_buffer_load (GLEW_CONTEXT_ARG_DEF_INIT)
+{
+  GLboolean r = GL_FALSE;
+
+  r = ((glGetBufferParameterui64vNV = (PFNGLGETBUFFERPARAMETERUI64VNVPROC)glewGetProcAddress((const GLubyte*)"glGetBufferParameterui64vNV")) == NULL) || r;
+  r = ((glGetIntegerui64vNV = (PFNGLGETINTEGERUI64VNVPROC)glewGetProcAddress((const GLubyte*)"glGetIntegerui64vNV")) == NULL) || r;
+  r = ((glGetNamedBufferParameterui64vNV = (PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC)glewGetProcAddress((const GLubyte*)"glGetNamedBufferParameterui64vNV")) == NULL) || r;
+  r = ((glGetUniformui64vNV = (PFNGLGETUNIFORMUI64VNVPROC)glewGetProcAddress((const GLubyte*)"glGetUniformui64vNV")) == NULL) || r;
+  r = ((glIsBufferResidentNV = (PFNGLISBUFFERRESIDENTNVPROC)glewGetProcAddress((const GLubyte*)"glIsBufferResidentNV")) == NULL) || r;
+  r = ((glIsNamedBufferResidentNV = (PFNGLISNAMEDBUFFERRESIDENTNVPROC)glewGetProcAddress((const GLubyte*)"glIsNamedBufferResidentNV")) == NULL) || r;
+  r = ((glMakeBufferNonResidentNV = (PFNGLMAKEBUFFERNONRESIDENTNVPROC)glewGetProcAddress((const GLubyte*)"glMakeBufferNonResidentNV")) == NULL) || r;
+  r = ((glMakeBufferResidentNV = (PFNGLMAKEBUFFERRESIDENTNVPROC)glewGetProcAddress((const GLubyte*)"glMakeBufferResidentNV")) == NULL) || r;
+  r = ((glMakeNamedBufferNonResidentNV = (PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC)glewGetProcAddress((const GLubyte*)"glMakeNamedBufferNonResidentNV")) == NULL) || r;
+  r = ((glMakeNamedBufferResidentNV = (PFNGLMAKENAMEDBUFFERRESIDENTNVPROC)glewGetProcAddress((const GLubyte*)"glMakeNamedBufferResidentNV")) == NULL) || r;
+  r = ((glProgramUniformui64NV = (PFNGLPROGRAMUNIFORMUI64NVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformui64NV")) == NULL) || r;
+  r = ((glProgramUniformui64vNV = (PFNGLPROGRAMUNIFORMUI64VNVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformui64vNV")) == NULL) || r;
+  r = ((glUniformui64NV = (PFNGLUNIFORMUI64NVPROC)glewGetProcAddress((const GLubyte*)"glUniformui64NV")) == NULL) || r;
+  r = ((glUniformui64vNV = (PFNGLUNIFORMUI64VNVPROC)glewGetProcAddress((const GLubyte*)"glUniformui64vNV")) == NULL) || r;
+
+  return r;
+}
+
+#endif /* GL_NV_shader_buffer_load */
+
 #ifdef GL_NV_texgen_emboss
 
 #endif /* GL_NV_texgen_emboss */
@@ -5371,6 +5977,19 @@ static GLboolean _glewInit_GL_NV_register_combiners2 (GLEW_CONTEXT_ARG_DEF_INIT)
 
 #endif /* GL_NV_texgen_reflection */
 
+#ifdef GL_NV_texture_barrier
+
+static GLboolean _glewInit_GL_NV_texture_barrier (GLEW_CONTEXT_ARG_DEF_INIT)
+{
+  GLboolean r = GL_FALSE;
+
+  r = ((glTextureBarrierNV = (PFNGLTEXTUREBARRIERNVPROC)glewGetProcAddress((const GLubyte*)"glTextureBarrierNV")) == NULL) || r;
+
+  return r;
+}
+
+#endif /* GL_NV_texture_barrier */
+
 #ifdef GL_NV_texture_compression_vtc
 
 #endif /* GL_NV_texture_compression_vtc */
@@ -5422,6 +6041,25 @@ static GLboolean _glewInit_GL_NV_transform_feedback (GLEW_CONTEXT_ARG_DEF_INIT)
 
 #endif /* GL_NV_transform_feedback */
 
+#ifdef GL_NV_transform_feedback2
+
+static GLboolean _glewInit_GL_NV_transform_feedback2 (GLEW_CONTEXT_ARG_DEF_INIT)
+{
+  GLboolean r = GL_FALSE;
+
+  r = ((glBindTransformFeedbackNV = (PFNGLBINDTRANSFORMFEEDBACKNVPROC)glewGetProcAddress((const GLubyte*)"glBindTransformFeedbackNV")) == NULL) || r;
+  r = ((glDeleteTransformFeedbacksNV = (PFNGLDELETETRANSFORMFEEDBACKSNVPROC)glewGetProcAddress((const GLubyte*)"glDeleteTransformFeedbacksNV")) == NULL) || r;
+  r = ((glDrawTransformFeedbackNV = (PFNGLDRAWTRANSFORMFEEDBACKNVPROC)glewGetProcAddress((const GLubyte*)"glDrawTransformFeedbackNV")) == NULL) || r;
+  r = ((glGenTransformFeedbacksNV = (PFNGLGENTRANSFORMFEEDBACKSNVPROC)glewGetProcAddress((const GLubyte*)"glGenTransformFeedbacksNV")) == NULL) || r;
+  r = ((glIsTransformFeedbackNV = (PFNGLISTRANSFORMFEEDBACKNVPROC)glewGetProcAddress((const GLubyte*)"glIsTransformFeedbackNV")) == NULL) || r;
+  r = ((glPauseTransformFeedbackNV = (PFNGLPAUSETRANSFORMFEEDBACKNVPROC)glewGetProcAddress((const GLubyte*)"glPauseTransformFeedbackNV")) == NULL) || r;
+  r = ((glResumeTransformFeedbackNV = (PFNGLRESUMETRANSFORMFEEDBACKNVPROC)glewGetProcAddress((const GLubyte*)"glResumeTransformFeedbackNV")) == NULL) || r;
+
+  return r;
+}
+
+#endif /* GL_NV_transform_feedback2 */
+
 #ifdef GL_NV_vertex_array_range
 
 static GLboolean _glewInit_GL_NV_vertex_array_range (GLEW_CONTEXT_ARG_DEF_INIT)
@@ -5440,6 +6078,30 @@ static GLboolean _glewInit_GL_NV_vertex_array_range (GLEW_CONTEXT_ARG_DEF_INIT)
 
 #endif /* GL_NV_vertex_array_range2 */
 
+#ifdef GL_NV_vertex_buffer_unified_memory
+
+static GLboolean _glewInit_GL_NV_vertex_buffer_unified_memory (GLEW_CONTEXT_ARG_DEF_INIT)
+{
+  GLboolean r = GL_FALSE;
+
+  r = ((glBufferAddressRangeNV = (PFNGLBUFFERADDRESSRANGENVPROC)glewGetProcAddress((const GLubyte*)"glBufferAddressRangeNV")) == NULL) || r;
+  r = ((glColorFormatNV = (PFNGLCOLORFORMATNVPROC)glewGetProcAddress((const GLubyte*)"glColorFormatNV")) == NULL) || r;
+  r = ((glEdgeFlagFormatNV = (PFNGLEDGEFLAGFORMATNVPROC)glewGetProcAddress((const GLubyte*)"glEdgeFlagFormatNV")) == NULL) || r;
+  r = ((glFogCoordFormatNV = (PFNGLFOGCOORDFORMATNVPROC)glewGetProcAddress((const GLubyte*)"glFogCoordFormatNV")) == NULL) || r;
+  r = ((glGetIntegerui64i_vNV = (PFNGLGETINTEGERUI64I_VNVPROC)glewGetProcAddress((const GLubyte*)"glGetIntegerui64i_vNV")) == NULL) || r;
+  r = ((glIndexFormatNV = (PFNGLINDEXFORMATNVPROC)glewGetProcAddress((const GLubyte*)"glIndexFormatNV")) == NULL) || r;
+  r = ((glNormalFormatNV = (PFNGLNORMALFORMATNVPROC)glewGetProcAddress((const GLubyte*)"glNormalFormatNV")) == NULL) || r;
+  r = ((glSecondaryColorFormatNV = (PFNGLSECONDARYCOLORFORMATNVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColorFormatNV")) == NULL) || r;
+  r = ((glTexCoordFormatNV = (PFNGLTEXCOORDFORMATNVPROC)glewGetProcAddress((const GLubyte*)"glTexCoordFormatNV")) == NULL) || r;
+  r = ((glVertexAttribFormatNV = (PFNGLVERTEXATTRIBFORMATNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribFormatNV")) == NULL) || r;
+  r = ((glVertexAttribIFormatNV = (PFNGLVERTEXATTRIBIFORMATNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribIFormatNV")) == NULL) || r;
+  r = ((glVertexFormatNV = (PFNGLVERTEXFORMATNVPROC)glewGetProcAddress((const GLubyte*)"glVertexFormatNV")) == NULL) || r;
+
+  return r;
+}
+
+#endif /* GL_NV_vertex_buffer_unified_memory */
+
 #ifdef GL_NV_vertex_program
 
 static GLboolean _glewInit_GL_NV_vertex_program (GLEW_CONTEXT_ARG_DEF_INIT)
@@ -6153,81 +6815,37 @@ static
 GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
 {
   const GLubyte* s;
-  GLuint dot, major, minor;
+  GLuint dot;
+  GLint major, minor;
   /* query opengl version */
   s = glGetString(GL_VERSION);
   dot = _glewStrCLen(s, '.');
-  major = dot-1;
-  minor = dot+1;
-  if (dot == 0 || s[minor] == '\0')
+  if (dot == 0)
+    return GLEW_ERROR_NO_GL_VERSION;
+  
+  major = s[dot-1]-'0';
+  minor = s[dot+1]-'0';
+
+  if (minor < 0 || minor > 9)
+    minor = 0;
+  if (major<0 || major>9)
     return GLEW_ERROR_NO_GL_VERSION;
-  if (s[major] == '1' && s[minor] == '0')
+  
+
+  if (major == 1 && minor == 0)
   {
-       return GLEW_ERROR_GL_VERSION_10_ONLY;
+    return GLEW_ERROR_GL_VERSION_10_ONLY;
   }
   else
   {
-    CONST_CAST(GLEW_VERSION_1_1) = GL_TRUE;
-       if (s[major] >= '2')
-       {
-      CONST_CAST(GLEW_VERSION_1_2) = GL_TRUE;
-      CONST_CAST(GLEW_VERSION_1_3) = GL_TRUE;
-      CONST_CAST(GLEW_VERSION_1_4) = GL_TRUE;
-         CONST_CAST(GLEW_VERSION_1_5) = GL_TRUE;
-         CONST_CAST(GLEW_VERSION_2_0) = GL_TRUE;
-         if (s[minor] >= '1')
-         {
-           CONST_CAST(GLEW_VERSION_2_1) = GL_TRUE;
-      }
-       }
-       else
-       {
-         if (s[minor] >= '5')
-         {
-               CONST_CAST(GLEW_VERSION_1_2) = GL_TRUE;
-               CONST_CAST(GLEW_VERSION_1_3) = GL_TRUE;
-               CONST_CAST(GLEW_VERSION_1_4) = GL_TRUE;
-               CONST_CAST(GLEW_VERSION_1_5) = GL_TRUE;
-               CONST_CAST(GLEW_VERSION_2_0) = GL_FALSE;
-               CONST_CAST(GLEW_VERSION_2_1) = GL_FALSE;
-         }
-         if (s[minor] == '4')
-         {
-               CONST_CAST(GLEW_VERSION_1_2) = GL_TRUE;
-               CONST_CAST(GLEW_VERSION_1_3) = GL_TRUE;
-               CONST_CAST(GLEW_VERSION_1_4) = GL_TRUE;
-               CONST_CAST(GLEW_VERSION_1_5) = GL_FALSE;
-               CONST_CAST(GLEW_VERSION_2_0) = GL_FALSE;
-               CONST_CAST(GLEW_VERSION_2_1) = GL_FALSE;
-         }
-         if (s[minor] == '3')
-         {
-               CONST_CAST(GLEW_VERSION_1_2) = GL_TRUE;
-               CONST_CAST(GLEW_VERSION_1_3) = GL_TRUE;
-               CONST_CAST(GLEW_VERSION_1_4) = GL_FALSE;
-               CONST_CAST(GLEW_VERSION_1_5) = GL_FALSE;
-               CONST_CAST(GLEW_VERSION_2_0) = GL_FALSE;
-               CONST_CAST(GLEW_VERSION_2_1) = GL_FALSE;
-         }
-         if (s[minor] == '2')
-         {
-               CONST_CAST(GLEW_VERSION_1_2) = GL_TRUE;
-               CONST_CAST(GLEW_VERSION_1_3) = GL_FALSE;
-               CONST_CAST(GLEW_VERSION_1_4) = GL_FALSE;
-               CONST_CAST(GLEW_VERSION_1_5) = GL_FALSE;
-               CONST_CAST(GLEW_VERSION_2_0) = GL_FALSE;
-               CONST_CAST(GLEW_VERSION_2_1) = GL_FALSE;
-         }
-         if (s[minor] < '2')
-         {
-               CONST_CAST(GLEW_VERSION_1_2) = GL_FALSE;
-               CONST_CAST(GLEW_VERSION_1_3) = GL_FALSE;
-               CONST_CAST(GLEW_VERSION_1_4) = GL_FALSE;
-               CONST_CAST(GLEW_VERSION_1_5) = GL_FALSE;
-               CONST_CAST(GLEW_VERSION_2_0) = GL_FALSE;
-               CONST_CAST(GLEW_VERSION_2_1) = GL_FALSE;
-         }
-       }
+    CONST_CAST(GLEW_VERSION_3_0) =                                ( major >= 3               ) ? GL_TRUE : GL_FALSE;
+    CONST_CAST(GLEW_VERSION_2_1) = GLEW_VERSION_3_0 == GL_TRUE || ( major == 2 && minor >= 1 ) ? GL_TRUE : GL_FALSE;    
+    CONST_CAST(GLEW_VERSION_2_0) = GLEW_VERSION_2_1 == GL_TRUE || ( major == 2               ) ? GL_TRUE : GL_FALSE;
+    CONST_CAST(GLEW_VERSION_1_5) = GLEW_VERSION_2_0 == GL_TRUE || ( major == 1 && minor >= 5 ) ? GL_TRUE : GL_FALSE;
+    CONST_CAST(GLEW_VERSION_1_4) = GLEW_VERSION_1_5 == GL_TRUE || ( major == 1 && minor >= 4 ) ? GL_TRUE : GL_FALSE;
+    CONST_CAST(GLEW_VERSION_1_3) = GLEW_VERSION_1_4 == GL_TRUE || ( major == 1 && minor >= 3 ) ? GL_TRUE : GL_FALSE;
+    CONST_CAST(GLEW_VERSION_1_2) = GLEW_VERSION_1_3 == GL_TRUE || ( major == 1 && minor >= 2 ) ? GL_TRUE : GL_FALSE;
+    CONST_CAST(GLEW_VERSION_1_1) = GLEW_VERSION_1_2 == GL_TRUE || ( major == 1 && minor >= 1 ) ? GL_TRUE : GL_FALSE;
   }
   /* initialize extensions */
 #ifdef GL_VERSION_1_2
@@ -6251,6 +6869,12 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
 #ifdef GL_VERSION_3_0
   if (glewExperimental || GLEW_VERSION_3_0) CONST_CAST(GLEW_VERSION_3_0) = !_glewInit_GL_VERSION_3_0(GLEW_CONTEXT_ARG_VAR_INIT);
 #endif /* GL_VERSION_3_0 */
+#ifdef GL_VERSION_3_1
+  if (glewExperimental || GLEW_VERSION_3_1) CONST_CAST(GLEW_VERSION_3_1) = !_glewInit_GL_VERSION_3_1(GLEW_CONTEXT_ARG_VAR_INIT);
+#endif /* GL_VERSION_3_1 */
+#ifdef GL_VERSION_3_2
+  if (glewExperimental || GLEW_VERSION_3_2) CONST_CAST(GLEW_VERSION_3_2) = !_glewInit_GL_VERSION_3_2(GLEW_CONTEXT_ARG_VAR_INIT);
+#endif /* GL_VERSION_3_2 */
 #ifdef GL_3DFX_multisample
   CONST_CAST(GLEW_3DFX_multisample) = glewGetExtension("GL_3DFX_multisample");
 #endif /* GL_3DFX_multisample */
@@ -6261,6 +6885,24 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
 #ifdef GL_3DFX_texture_compression_FXT1
   CONST_CAST(GLEW_3DFX_texture_compression_FXT1) = glewGetExtension("GL_3DFX_texture_compression_FXT1");
 #endif /* GL_3DFX_texture_compression_FXT1 */
+#ifdef GL_AMD_draw_buffers_blend
+  CONST_CAST(GLEW_AMD_draw_buffers_blend) = glewGetExtension("GL_AMD_draw_buffers_blend");
+  if (glewExperimental || GLEW_AMD_draw_buffers_blend) CONST_CAST(GLEW_AMD_draw_buffers_blend) = !_glewInit_GL_AMD_draw_buffers_blend(GLEW_CONTEXT_ARG_VAR_INIT);
+#endif /* GL_AMD_draw_buffers_blend */
+#ifdef GL_AMD_performance_monitor
+  CONST_CAST(GLEW_AMD_performance_monitor) = glewGetExtension("GL_AMD_performance_monitor");
+  if (glewExperimental || GLEW_AMD_performance_monitor) CONST_CAST(GLEW_AMD_performance_monitor) = !_glewInit_GL_AMD_performance_monitor(GLEW_CONTEXT_ARG_VAR_INIT);
+#endif /* GL_AMD_performance_monitor */
+#ifdef GL_AMD_texture_texture4
+  CONST_CAST(GLEW_AMD_texture_texture4) = glewGetExtension("GL_AMD_texture_texture4");
+#endif /* GL_AMD_texture_texture4 */
+#ifdef GL_AMD_vertex_shader_tessellator
+  CONST_CAST(GLEW_AMD_vertex_shader_tessellator) = glewGetExtension("GL_AMD_vertex_shader_tessellator");
+  if (glewExperimental || GLEW_AMD_vertex_shader_tessellator) CONST_CAST(GLEW_AMD_vertex_shader_tessellator) = !_glewInit_GL_AMD_vertex_shader_tessellator(GLEW_CONTEXT_ARG_VAR_INIT);
+#endif /* GL_AMD_vertex_shader_tessellator */
+#ifdef GL_APPLE_aux_depth_stencil
+  CONST_CAST(GLEW_APPLE_aux_depth_stencil) = glewGetExtension("GL_APPLE_aux_depth_stencil");
+#endif /* GL_APPLE_aux_depth_stencil */
 #ifdef GL_APPLE_client_storage
   CONST_CAST(GLEW_APPLE_client_storage) = glewGetExtension("GL_APPLE_client_storage");
 #endif /* GL_APPLE_client_storage */
@@ -6279,9 +6921,19 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
   CONST_CAST(GLEW_APPLE_flush_buffer_range) = glewGetExtension("GL_APPLE_flush_buffer_range");
   if (glewExperimental || GLEW_APPLE_flush_buffer_range) CONST_CAST(GLEW_APPLE_flush_buffer_range) = !_glewInit_GL_APPLE_flush_buffer_range(GLEW_CONTEXT_ARG_VAR_INIT);
 #endif /* GL_APPLE_flush_buffer_range */
+#ifdef GL_APPLE_object_purgeable
+  CONST_CAST(GLEW_APPLE_object_purgeable) = glewGetExtension("GL_APPLE_object_purgeable");
+  if (glewExperimental || GLEW_APPLE_object_purgeable) CONST_CAST(GLEW_APPLE_object_purgeable) = !_glewInit_GL_APPLE_object_purgeable(GLEW_CONTEXT_ARG_VAR_INIT);
+#endif /* GL_APPLE_object_purgeable */
 #ifdef GL_APPLE_pixel_buffer
   CONST_CAST(GLEW_APPLE_pixel_buffer) = glewGetExtension("GL_APPLE_pixel_buffer");
 #endif /* GL_APPLE_pixel_buffer */
+#ifdef GL_APPLE_rgb_422
+  CONST_CAST(GLEW_APPLE_rgb_422) = glewGetExtension("GL_APPLE_rgb_422");
+#endif /* GL_APPLE_rgb_422 */
+#ifdef GL_APPLE_row_bytes
+  CONST_CAST(GLEW_APPLE_row_bytes) = glewGetExtension("GL_APPLE_row_bytes");
+#endif /* GL_APPLE_row_bytes */
 #ifdef GL_APPLE_specular_vector
   CONST_CAST(GLEW_APPLE_specular_vector) = glewGetExtension("GL_APPLE_specular_vector");
 #endif /* GL_APPLE_specular_vector */
@@ -6300,6 +6952,10 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
   CONST_CAST(GLEW_APPLE_vertex_array_range) = glewGetExtension("GL_APPLE_vertex_array_range");
   if (glewExperimental || GLEW_APPLE_vertex_array_range) CONST_CAST(GLEW_APPLE_vertex_array_range) = !_glewInit_GL_APPLE_vertex_array_range(GLEW_CONTEXT_ARG_VAR_INIT);
 #endif /* GL_APPLE_vertex_array_range */
+#ifdef GL_APPLE_vertex_program_evaluators
+  CONST_CAST(GLEW_APPLE_vertex_program_evaluators) = glewGetExtension("GL_APPLE_vertex_program_evaluators");
+  if (glewExperimental || GLEW_APPLE_vertex_program_evaluators) CONST_CAST(GLEW_APPLE_vertex_program_evaluators) = !_glewInit_GL_APPLE_vertex_program_evaluators(GLEW_CONTEXT_ARG_VAR_INIT);
+#endif /* GL_APPLE_vertex_program_evaluators */
 #ifdef GL_APPLE_ycbcr_422
   CONST_CAST(GLEW_APPLE_ycbcr_422) = glewGetExtension("GL_APPLE_ycbcr_422");
 #endif /* GL_APPLE_ycbcr_422 */
@@ -6307,9 +6963,19 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
   CONST_CAST(GLEW_ARB_color_buffer_float) = glewGetExtension("GL_ARB_color_buffer_float");
   if (glewExperimental || GLEW_ARB_color_buffer_float) CONST_CAST(GLEW_ARB_color_buffer_float) = !_glewInit_GL_ARB_color_buffer_float(GLEW_CONTEXT_ARG_VAR_INIT);
 #endif /* GL_ARB_color_buffer_float */
+#ifdef GL_ARB_compatibility
+  CONST_CAST(GLEW_ARB_compatibility) = glewGetExtension("GL_ARB_compatibility");
+#endif /* GL_ARB_compatibility */
+#ifdef GL_ARB_copy_buffer
+  CONST_CAST(GLEW_ARB_copy_buffer) = glewGetExtension("GL_ARB_copy_buffer");
+  if (glewExperimental || GLEW_ARB_copy_buffer) CONST_CAST(GLEW_ARB_copy_buffer) = !_glewInit_GL_ARB_copy_buffer(GLEW_CONTEXT_ARG_VAR_INIT);
+#endif /* GL_ARB_copy_buffer */
 #ifdef GL_ARB_depth_buffer_float
   CONST_CAST(GLEW_ARB_depth_buffer_float) = glewGetExtension("GL_ARB_depth_buffer_float");
 #endif /* GL_ARB_depth_buffer_float */
+#ifdef GL_ARB_depth_clamp
+  CONST_CAST(GLEW_ARB_depth_clamp) = glewGetExtension("GL_ARB_depth_clamp");
+#endif /* GL_ARB_depth_clamp */
 #ifdef GL_ARB_depth_texture
   CONST_CAST(GLEW_ARB_depth_texture) = glewGetExtension("GL_ARB_depth_texture");
 #endif /* GL_ARB_depth_texture */
@@ -6317,10 +6983,21 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
   CONST_CAST(GLEW_ARB_draw_buffers) = glewGetExtension("GL_ARB_draw_buffers");
   if (glewExperimental || GLEW_ARB_draw_buffers) CONST_CAST(GLEW_ARB_draw_buffers) = !_glewInit_GL_ARB_draw_buffers(GLEW_CONTEXT_ARG_VAR_INIT);
 #endif /* GL_ARB_draw_buffers */
+#ifdef GL_ARB_draw_buffers_blend
+  CONST_CAST(GLEW_ARB_draw_buffers_blend) = glewGetExtension("GL_ARB_draw_buffers_blend");
+  if (glewExperimental || GLEW_ARB_draw_buffers_blend) CONST_CAST(GLEW_ARB_draw_buffers_blend) = !_glewInit_GL_ARB_draw_buffers_blend(GLEW_CONTEXT_ARG_VAR_INIT);
+#endif /* GL_ARB_draw_buffers_blend */
+#ifdef GL_ARB_draw_elements_base_vertex
+  CONST_CAST(GLEW_ARB_draw_elements_base_vertex) = glewGetExtension("GL_ARB_draw_elements_base_vertex");
+  if (glewExperimental || GLEW_ARB_draw_elements_base_vertex) CONST_CAST(GLEW_ARB_draw_elements_base_vertex) = !_glewInit_GL_ARB_draw_elements_base_vertex(GLEW_CONTEXT_ARG_VAR_INIT);
+#endif /* GL_ARB_draw_elements_base_vertex */
 #ifdef GL_ARB_draw_instanced
   CONST_CAST(GLEW_ARB_draw_instanced) = glewGetExtension("GL_ARB_draw_instanced");
   if (glewExperimental || GLEW_ARB_draw_instanced) CONST_CAST(GLEW_ARB_draw_instanced) = !_glewInit_GL_ARB_draw_instanced(GLEW_CONTEXT_ARG_VAR_INIT);
 #endif /* GL_ARB_draw_instanced */
+#ifdef GL_ARB_fragment_coord_conventions
+  CONST_CAST(GLEW_ARB_fragment_coord_conventions) = glewGetExtension("GL_ARB_fragment_coord_conventions");
+#endif /* GL_ARB_fragment_coord_conventions */
 #ifdef GL_ARB_fragment_program
   CONST_CAST(GLEW_ARB_fragment_program) = glewGetExtension("GL_ARB_fragment_program");
 #endif /* GL_ARB_fragment_program */
@@ -6385,10 +7062,24 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
 #ifdef GL_ARB_point_sprite
   CONST_CAST(GLEW_ARB_point_sprite) = glewGetExtension("GL_ARB_point_sprite");
 #endif /* GL_ARB_point_sprite */
+#ifdef GL_ARB_provoking_vertex
+  CONST_CAST(GLEW_ARB_provoking_vertex) = glewGetExtension("GL_ARB_provoking_vertex");
+  if (glewExperimental || GLEW_ARB_provoking_vertex) CONST_CAST(GLEW_ARB_provoking_vertex) = !_glewInit_GL_ARB_provoking_vertex(GLEW_CONTEXT_ARG_VAR_INIT);
+#endif /* GL_ARB_provoking_vertex */
+#ifdef GL_ARB_sample_shading
+  CONST_CAST(GLEW_ARB_sample_shading) = glewGetExtension("GL_ARB_sample_shading");
+  if (glewExperimental || GLEW_ARB_sample_shading) CONST_CAST(GLEW_ARB_sample_shading) = !_glewInit_GL_ARB_sample_shading(GLEW_CONTEXT_ARG_VAR_INIT);
+#endif /* GL_ARB_sample_shading */
+#ifdef GL_ARB_seamless_cube_map
+  CONST_CAST(GLEW_ARB_seamless_cube_map) = glewGetExtension("GL_ARB_seamless_cube_map");
+#endif /* GL_ARB_seamless_cube_map */
 #ifdef GL_ARB_shader_objects
   CONST_CAST(GLEW_ARB_shader_objects) = glewGetExtension("GL_ARB_shader_objects");
   if (glewExperimental || GLEW_ARB_shader_objects) CONST_CAST(GLEW_ARB_shader_objects) = !_glewInit_GL_ARB_shader_objects(GLEW_CONTEXT_ARG_VAR_INIT);
 #endif /* GL_ARB_shader_objects */
+#ifdef GL_ARB_shader_texture_lod
+  CONST_CAST(GLEW_ARB_shader_texture_lod) = glewGetExtension("GL_ARB_shader_texture_lod");
+#endif /* GL_ARB_shader_texture_lod */
 #ifdef GL_ARB_shading_language_100
   CONST_CAST(GLEW_ARB_shading_language_100) = glewGetExtension("GL_ARB_shading_language_100");
 #endif /* GL_ARB_shading_language_100 */
@@ -6398,6 +7089,10 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
 #ifdef GL_ARB_shadow_ambient
   CONST_CAST(GLEW_ARB_shadow_ambient) = glewGetExtension("GL_ARB_shadow_ambient");
 #endif /* GL_ARB_shadow_ambient */
+#ifdef GL_ARB_sync
+  CONST_CAST(GLEW_ARB_sync) = glewGetExtension("GL_ARB_sync");
+  if (glewExperimental || GLEW_ARB_sync) CONST_CAST(GLEW_ARB_sync) = !_glewInit_GL_ARB_sync(GLEW_CONTEXT_ARG_VAR_INIT);
+#endif /* GL_ARB_sync */
 #ifdef GL_ARB_texture_border_clamp
   CONST_CAST(GLEW_ARB_texture_border_clamp) = glewGetExtension("GL_ARB_texture_border_clamp");
 #endif /* GL_ARB_texture_border_clamp */
@@ -6415,6 +7110,9 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
 #ifdef GL_ARB_texture_cube_map
   CONST_CAST(GLEW_ARB_texture_cube_map) = glewGetExtension("GL_ARB_texture_cube_map");
 #endif /* GL_ARB_texture_cube_map */
+#ifdef GL_ARB_texture_cube_map_array
+  CONST_CAST(GLEW_ARB_texture_cube_map_array) = glewGetExtension("GL_ARB_texture_cube_map_array");
+#endif /* GL_ARB_texture_cube_map_array */
 #ifdef GL_ARB_texture_env_add
   CONST_CAST(GLEW_ARB_texture_env_add) = glewGetExtension("GL_ARB_texture_env_add");
 #endif /* GL_ARB_texture_env_add */
@@ -6430,12 +7128,22 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
 #ifdef GL_ARB_texture_float
   CONST_CAST(GLEW_ARB_texture_float) = glewGetExtension("GL_ARB_texture_float");
 #endif /* GL_ARB_texture_float */
+#ifdef GL_ARB_texture_gather
+  CONST_CAST(GLEW_ARB_texture_gather) = glewGetExtension("GL_ARB_texture_gather");
+#endif /* GL_ARB_texture_gather */
 #ifdef GL_ARB_texture_mirrored_repeat
   CONST_CAST(GLEW_ARB_texture_mirrored_repeat) = glewGetExtension("GL_ARB_texture_mirrored_repeat");
 #endif /* GL_ARB_texture_mirrored_repeat */
+#ifdef GL_ARB_texture_multisample
+  CONST_CAST(GLEW_ARB_texture_multisample) = glewGetExtension("GL_ARB_texture_multisample");
+  if (glewExperimental || GLEW_ARB_texture_multisample) CONST_CAST(GLEW_ARB_texture_multisample) = !_glewInit_GL_ARB_texture_multisample(GLEW_CONTEXT_ARG_VAR_INIT);
+#endif /* GL_ARB_texture_multisample */
 #ifdef GL_ARB_texture_non_power_of_two
   CONST_CAST(GLEW_ARB_texture_non_power_of_two) = glewGetExtension("GL_ARB_texture_non_power_of_two");
 #endif /* GL_ARB_texture_non_power_of_two */
+#ifdef GL_ARB_texture_query_lod
+  CONST_CAST(GLEW_ARB_texture_query_lod) = glewGetExtension("GL_ARB_texture_query_lod");
+#endif /* GL_ARB_texture_query_lod */
 #ifdef GL_ARB_texture_rectangle
   CONST_CAST(GLEW_ARB_texture_rectangle) = glewGetExtension("GL_ARB_texture_rectangle");
 #endif /* GL_ARB_texture_rectangle */
@@ -6446,6 +7154,13 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
   CONST_CAST(GLEW_ARB_transpose_matrix) = glewGetExtension("GL_ARB_transpose_matrix");
   if (glewExperimental || GLEW_ARB_transpose_matrix) CONST_CAST(GLEW_ARB_transpose_matrix) = !_glewInit_GL_ARB_transpose_matrix(GLEW_CONTEXT_ARG_VAR_INIT);
 #endif /* GL_ARB_transpose_matrix */
+#ifdef GL_ARB_uniform_buffer_object
+  CONST_CAST(GLEW_ARB_uniform_buffer_object) = glewGetExtension("GL_ARB_uniform_buffer_object");
+  if (glewExperimental || GLEW_ARB_uniform_buffer_object) CONST_CAST(GLEW_ARB_uniform_buffer_object) = !_glewInit_GL_ARB_uniform_buffer_object(GLEW_CONTEXT_ARG_VAR_INIT);
+#endif /* GL_ARB_uniform_buffer_object */
+#ifdef GL_ARB_vertex_array_bgra
+  CONST_CAST(GLEW_ARB_vertex_array_bgra) = glewGetExtension("GL_ARB_vertex_array_bgra");
+#endif /* GL_ARB_vertex_array_bgra */
 #ifdef GL_ARB_vertex_array_object
   CONST_CAST(GLEW_ARB_vertex_array_object) = glewGetExtension("GL_ARB_vertex_array_object");
   if (glewExperimental || GLEW_ARB_vertex_array_object) CONST_CAST(GLEW_ARB_vertex_array_object) = !_glewInit_GL_ARB_vertex_array_object(GLEW_CONTEXT_ARG_VAR_INIT);
@@ -6502,6 +7217,9 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
   CONST_CAST(GLEW_ATI_map_object_buffer) = glewGetExtension("GL_ATI_map_object_buffer");
   if (glewExperimental || GLEW_ATI_map_object_buffer) CONST_CAST(GLEW_ATI_map_object_buffer) = !_glewInit_GL_ATI_map_object_buffer(GLEW_CONTEXT_ARG_VAR_INIT);
 #endif /* GL_ATI_map_object_buffer */
+#ifdef GL_ATI_meminfo
+  CONST_CAST(GLEW_ATI_meminfo) = glewGetExtension("GL_ATI_meminfo");
+#endif /* GL_ATI_meminfo */
 #ifdef GL_ATI_pn_triangles
   CONST_CAST(GLEW_ATI_pn_triangles) = glewGetExtension("GL_ATI_pn_triangles");
   if (glewExperimental || GLEW_ATI_pn_triangles) CONST_CAST(GLEW_ATI_pn_triangles) = !_glewInit_GL_ATI_pn_triangles(GLEW_CONTEXT_ARG_VAR_INIT);
@@ -6727,6 +7445,10 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
   CONST_CAST(GLEW_EXT_polygon_offset) = glewGetExtension("GL_EXT_polygon_offset");
   if (glewExperimental || GLEW_EXT_polygon_offset) CONST_CAST(GLEW_EXT_polygon_offset) = !_glewInit_GL_EXT_polygon_offset(GLEW_CONTEXT_ARG_VAR_INIT);
 #endif /* GL_EXT_polygon_offset */
+#ifdef GL_EXT_provoking_vertex
+  CONST_CAST(GLEW_EXT_provoking_vertex) = glewGetExtension("GL_EXT_provoking_vertex");
+  if (glewExperimental || GLEW_EXT_provoking_vertex) CONST_CAST(GLEW_EXT_provoking_vertex) = !_glewInit_GL_EXT_provoking_vertex(GLEW_CONTEXT_ARG_VAR_INIT);
+#endif /* GL_EXT_provoking_vertex */
 #ifdef GL_EXT_rescale_normal
   CONST_CAST(GLEW_EXT_rescale_normal) = glewGetExtension("GL_EXT_rescale_normal");
 #endif /* GL_EXT_rescale_normal */
@@ -6738,6 +7460,10 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
   CONST_CAST(GLEW_EXT_secondary_color) = glewGetExtension("GL_EXT_secondary_color");
   if (glewExperimental || GLEW_EXT_secondary_color) CONST_CAST(GLEW_EXT_secondary_color) = !_glewInit_GL_EXT_secondary_color(GLEW_CONTEXT_ARG_VAR_INIT);
 #endif /* GL_EXT_secondary_color */
+#ifdef GL_EXT_separate_shader_objects
+  CONST_CAST(GLEW_EXT_separate_shader_objects) = glewGetExtension("GL_EXT_separate_shader_objects");
+  if (glewExperimental || GLEW_EXT_separate_shader_objects) CONST_CAST(GLEW_EXT_separate_shader_objects) = !_glewInit_GL_EXT_separate_shader_objects(GLEW_CONTEXT_ARG_VAR_INIT);
+#endif /* GL_EXT_separate_shader_objects */
 #ifdef GL_EXT_separate_specular_color
   CONST_CAST(GLEW_EXT_separate_specular_color) = glewGetExtension("GL_EXT_separate_specular_color");
 #endif /* GL_EXT_separate_specular_color */
@@ -6835,6 +7561,9 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
 #ifdef GL_EXT_texture_shared_exponent
   CONST_CAST(GLEW_EXT_texture_shared_exponent) = glewGetExtension("GL_EXT_texture_shared_exponent");
 #endif /* GL_EXT_texture_shared_exponent */
+#ifdef GL_EXT_texture_snorm
+  CONST_CAST(GLEW_EXT_texture_snorm) = glewGetExtension("GL_EXT_texture_snorm");
+#endif /* GL_EXT_texture_snorm */
 #ifdef GL_EXT_texture_swizzle
   CONST_CAST(GLEW_EXT_texture_swizzle) = glewGetExtension("GL_EXT_texture_swizzle");
 #endif /* GL_EXT_texture_swizzle */
@@ -6947,6 +7676,10 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
 #ifdef GL_NV_copy_depth_to_color
   CONST_CAST(GLEW_NV_copy_depth_to_color) = glewGetExtension("GL_NV_copy_depth_to_color");
 #endif /* GL_NV_copy_depth_to_color */
+#ifdef GL_NV_copy_image
+  CONST_CAST(GLEW_NV_copy_image) = glewGetExtension("GL_NV_copy_image");
+  if (glewExperimental || GLEW_NV_copy_image) CONST_CAST(GLEW_NV_copy_image) = !_glewInit_GL_NV_copy_image(GLEW_CONTEXT_ARG_VAR_INIT);
+#endif /* GL_NV_copy_image */
 #ifdef GL_NV_depth_buffer_float
   CONST_CAST(GLEW_NV_depth_buffer_float) = glewGetExtension("GL_NV_depth_buffer_float");
   if (glewExperimental || GLEW_NV_depth_buffer_float) CONST_CAST(GLEW_NV_depth_buffer_float) = !_glewInit_GL_NV_depth_buffer_float(GLEW_CONTEXT_ARG_VAR_INIT);
@@ -7024,6 +7757,9 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
   CONST_CAST(GLEW_NV_parameter_buffer_object) = glewGetExtension("GL_NV_parameter_buffer_object");
   if (glewExperimental || GLEW_NV_parameter_buffer_object) CONST_CAST(GLEW_NV_parameter_buffer_object) = !_glewInit_GL_NV_parameter_buffer_object(GLEW_CONTEXT_ARG_VAR_INIT);
 #endif /* GL_NV_parameter_buffer_object */
+#ifdef GL_NV_parameter_buffer_object2
+  CONST_CAST(GLEW_NV_parameter_buffer_object2) = glewGetExtension("GL_NV_parameter_buffer_object2");
+#endif /* GL_NV_parameter_buffer_object2 */
 #ifdef GL_NV_pixel_data_range
   CONST_CAST(GLEW_NV_pixel_data_range) = glewGetExtension("GL_NV_pixel_data_range");
   if (glewExperimental || GLEW_NV_pixel_data_range) CONST_CAST(GLEW_NV_pixel_data_range) = !_glewInit_GL_NV_pixel_data_range(GLEW_CONTEXT_ARG_VAR_INIT);
@@ -7048,12 +7784,20 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
   CONST_CAST(GLEW_NV_register_combiners2) = glewGetExtension("GL_NV_register_combiners2");
   if (glewExperimental || GLEW_NV_register_combiners2) CONST_CAST(GLEW_NV_register_combiners2) = !_glewInit_GL_NV_register_combiners2(GLEW_CONTEXT_ARG_VAR_INIT);
 #endif /* GL_NV_register_combiners2 */
+#ifdef GL_NV_shader_buffer_load
+  CONST_CAST(GLEW_NV_shader_buffer_load) = glewGetExtension("GL_NV_shader_buffer_load");
+  if (glewExperimental || GLEW_NV_shader_buffer_load) CONST_CAST(GLEW_NV_shader_buffer_load) = !_glewInit_GL_NV_shader_buffer_load(GLEW_CONTEXT_ARG_VAR_INIT);
+#endif /* GL_NV_shader_buffer_load */
 #ifdef GL_NV_texgen_emboss
   CONST_CAST(GLEW_NV_texgen_emboss) = glewGetExtension("GL_NV_texgen_emboss");
 #endif /* GL_NV_texgen_emboss */
 #ifdef GL_NV_texgen_reflection
   CONST_CAST(GLEW_NV_texgen_reflection) = glewGetExtension("GL_NV_texgen_reflection");
 #endif /* GL_NV_texgen_reflection */
+#ifdef GL_NV_texture_barrier
+  CONST_CAST(GLEW_NV_texture_barrier) = glewGetExtension("GL_NV_texture_barrier");
+  if (glewExperimental || GLEW_NV_texture_barrier) CONST_CAST(GLEW_NV_texture_barrier) = !_glewInit_GL_NV_texture_barrier(GLEW_CONTEXT_ARG_VAR_INIT);
+#endif /* GL_NV_texture_barrier */
 #ifdef GL_NV_texture_compression_vtc
   CONST_CAST(GLEW_NV_texture_compression_vtc) = glewGetExtension("GL_NV_texture_compression_vtc");
 #endif /* GL_NV_texture_compression_vtc */
@@ -7079,6 +7823,10 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
   CONST_CAST(GLEW_NV_transform_feedback) = glewGetExtension("GL_NV_transform_feedback");
   if (glewExperimental || GLEW_NV_transform_feedback) CONST_CAST(GLEW_NV_transform_feedback) = !_glewInit_GL_NV_transform_feedback(GLEW_CONTEXT_ARG_VAR_INIT);
 #endif /* GL_NV_transform_feedback */
+#ifdef GL_NV_transform_feedback2
+  CONST_CAST(GLEW_NV_transform_feedback2) = glewGetExtension("GL_NV_transform_feedback2");
+  if (glewExperimental || GLEW_NV_transform_feedback2) CONST_CAST(GLEW_NV_transform_feedback2) = !_glewInit_GL_NV_transform_feedback2(GLEW_CONTEXT_ARG_VAR_INIT);
+#endif /* GL_NV_transform_feedback2 */
 #ifdef GL_NV_vertex_array_range
   CONST_CAST(GLEW_NV_vertex_array_range) = glewGetExtension("GL_NV_vertex_array_range");
   if (glewExperimental || GLEW_NV_vertex_array_range) CONST_CAST(GLEW_NV_vertex_array_range) = !_glewInit_GL_NV_vertex_array_range(GLEW_CONTEXT_ARG_VAR_INIT);
@@ -7086,6 +7834,10 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
 #ifdef GL_NV_vertex_array_range2
   CONST_CAST(GLEW_NV_vertex_array_range2) = glewGetExtension("GL_NV_vertex_array_range2");
 #endif /* GL_NV_vertex_array_range2 */
+#ifdef GL_NV_vertex_buffer_unified_memory
+  CONST_CAST(GLEW_NV_vertex_buffer_unified_memory) = glewGetExtension("GL_NV_vertex_buffer_unified_memory");
+  if (glewExperimental || GLEW_NV_vertex_buffer_unified_memory) CONST_CAST(GLEW_NV_vertex_buffer_unified_memory) = !_glewInit_GL_NV_vertex_buffer_unified_memory(GLEW_CONTEXT_ARG_VAR_INIT);
+#endif /* GL_NV_vertex_buffer_unified_memory */
 #ifdef GL_NV_vertex_program
   CONST_CAST(GLEW_NV_vertex_program) = glewGetExtension("GL_NV_vertex_program");
   if (glewExperimental || GLEW_NV_vertex_program) CONST_CAST(GLEW_NV_vertex_program) = !_glewInit_GL_NV_vertex_program(GLEW_CONTEXT_ARG_VAR_INIT);
@@ -7352,6 +8104,16 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
 
 PFNWGLSETSTEREOEMITTERSTATE3DLPROC __wglewSetStereoEmitterState3DL = NULL;
 
+PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC __wglewBlitContextFramebufferAMD = NULL;
+PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC __wglewCreateAssociatedContextAMD = NULL;
+PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC __wglewCreateAssociatedContextAttribsAMD = NULL;
+PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC __wglewDeleteAssociatedContextAMD = NULL;
+PFNWGLGETCONTEXTGPUIDAMDPROC __wglewGetContextGPUIDAMD = NULL;
+PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC __wglewGetCurrentAssociatedContextAMD = NULL;
+PFNWGLGETGPUIDSAMDPROC __wglewGetGPUIDsAMD = NULL;
+PFNWGLGETGPUINFOAMDPROC __wglewGetGPUInfoAMD = NULL;
+PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC __wglewMakeAssociatedContextCurrentAMD = NULL;
+
 PFNWGLCREATEBUFFERREGIONARBPROC __wglewCreateBufferRegionARB = NULL;
 PFNWGLDELETEBUFFERREGIONARBPROC __wglewDeleteBufferRegionARB = NULL;
 PFNWGLRESTOREBUFFERREGIONARBPROC __wglewRestoreBufferRegionARB = NULL;
@@ -7437,6 +8199,8 @@ PFNWGLENDFRAMETRACKINGI3DPROC __wglewEndFrameTrackingI3D = NULL;
 PFNWGLGETFRAMEUSAGEI3DPROC __wglewGetFrameUsageI3D = NULL;
 PFNWGLQUERYFRAMETRACKINGI3DPROC __wglewQueryFrameTrackingI3D = NULL;
 
+PFNWGLCOPYIMAGESUBDATANVPROC __wglewCopyImageSubDataNV = NULL;
+
 PFNWGLCREATEAFFINITYDCNVPROC __wglewCreateAffinityDCNV = NULL;
 PFNWGLDELETEDCNVPROC __wglewDeleteDCNV = NULL;
 PFNWGLENUMGPUDEVICESNVPROC __wglewEnumGpuDevicesNV = NULL;
@@ -7472,8 +8236,10 @@ PFNWGLWAITFORMSCOMLPROC __wglewWaitForMscOML = NULL;
 PFNWGLWAITFORSBCOMLPROC __wglewWaitForSbcOML = NULL;
 GLboolean __WGLEW_3DFX_multisample = GL_FALSE;
 GLboolean __WGLEW_3DL_stereo_control = GL_FALSE;
+GLboolean __WGLEW_AMD_gpu_association = GL_FALSE;
 GLboolean __WGLEW_ARB_buffer_region = GL_FALSE;
 GLboolean __WGLEW_ARB_create_context = GL_FALSE;
+GLboolean __WGLEW_ARB_create_context_profile = GL_FALSE;
 GLboolean __WGLEW_ARB_extensions_string = GL_FALSE;
 GLboolean __WGLEW_ARB_framebuffer_sRGB = GL_FALSE;
 GLboolean __WGLEW_ARB_make_current_read = GL_FALSE;
@@ -7500,6 +8266,7 @@ GLboolean __WGLEW_I3D_genlock = GL_FALSE;
 GLboolean __WGLEW_I3D_image_buffer = GL_FALSE;
 GLboolean __WGLEW_I3D_swap_frame_lock = GL_FALSE;
 GLboolean __WGLEW_I3D_swap_frame_usage = GL_FALSE;
+GLboolean __WGLEW_NV_copy_image = GL_FALSE;
 GLboolean __WGLEW_NV_float_buffer = GL_FALSE;
 GLboolean __WGLEW_NV_gpu_affinity = GL_FALSE;
 GLboolean __WGLEW_NV_present_video = GL_FALSE;
@@ -7529,6 +8296,27 @@ static GLboolean _glewInit_WGL_3DL_stereo_control (WGLEW_CONTEXT_ARG_DEF_INIT)
 
 #endif /* WGL_3DL_stereo_control */
 
+#ifdef WGL_AMD_gpu_association
+
+static GLboolean _glewInit_WGL_AMD_gpu_association (WGLEW_CONTEXT_ARG_DEF_INIT)
+{
+  GLboolean r = GL_FALSE;
+
+  r = ((wglBlitContextFramebufferAMD = (PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC)glewGetProcAddress((const GLubyte*)"wglBlitContextFramebufferAMD")) == NULL) || r;
+  r = ((wglCreateAssociatedContextAMD = (PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC)glewGetProcAddress((const GLubyte*)"wglCreateAssociatedContextAMD")) == NULL) || r;
+  r = ((wglCreateAssociatedContextAttribsAMD = (PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC)glewGetProcAddress((const GLubyte*)"wglCreateAssociatedContextAttribsAMD")) == NULL) || r;
+  r = ((wglDeleteAssociatedContextAMD = (PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC)glewGetProcAddress((const GLubyte*)"wglDeleteAssociatedContextAMD")) == NULL) || r;
+  r = ((wglGetContextGPUIDAMD = (PFNWGLGETCONTEXTGPUIDAMDPROC)glewGetProcAddress((const GLubyte*)"wglGetContextGPUIDAMD")) == NULL) || r;
+  r = ((wglGetCurrentAssociatedContextAMD = (PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC)glewGetProcAddress((const GLubyte*)"wglGetCurrentAssociatedContextAMD")) == NULL) || r;
+  r = ((wglGetGPUIDsAMD = (PFNWGLGETGPUIDSAMDPROC)glewGetProcAddress((const GLubyte*)"wglGetGPUIDsAMD")) == NULL) || r;
+  r = ((wglGetGPUInfoAMD = (PFNWGLGETGPUINFOAMDPROC)glewGetProcAddress((const GLubyte*)"wglGetGPUInfoAMD")) == NULL) || r;
+  r = ((wglMakeAssociatedContextCurrentAMD = (PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC)glewGetProcAddress((const GLubyte*)"wglMakeAssociatedContextCurrentAMD")) == NULL) || r;
+
+  return r;
+}
+
+#endif /* WGL_AMD_gpu_association */
+
 #ifdef WGL_ARB_buffer_region
 
 static GLboolean _glewInit_WGL_ARB_buffer_region (WGLEW_CONTEXT_ARG_DEF_INIT)
@@ -7558,6 +8346,10 @@ static GLboolean _glewInit_WGL_ARB_create_context (WGLEW_CONTEXT_ARG_DEF_INIT)
 
 #endif /* WGL_ARB_create_context */
 
+#ifdef WGL_ARB_create_context_profile
+
+#endif /* WGL_ARB_create_context_profile */
+
 #ifdef WGL_ARB_extensions_string
 
 static GLboolean _glewInit_WGL_ARB_extensions_string (WGLEW_CONTEXT_ARG_DEF_INIT)
@@ -7859,6 +8651,19 @@ static GLboolean _glewInit_WGL_I3D_swap_frame_usage (WGLEW_CONTEXT_ARG_DEF_INIT)
 
 #endif /* WGL_I3D_swap_frame_usage */
 
+#ifdef WGL_NV_copy_image
+
+static GLboolean _glewInit_WGL_NV_copy_image (WGLEW_CONTEXT_ARG_DEF_INIT)
+{
+  GLboolean r = GL_FALSE;
+
+  r = ((wglCopyImageSubDataNV = (PFNWGLCOPYIMAGESUBDATANVPROC)glewGetProcAddress((const GLubyte*)"wglCopyImageSubDataNV")) == NULL) || r;
+
+  return r;
+}
+
+#endif /* WGL_NV_copy_image */
+
 #ifdef WGL_NV_float_buffer
 
 #endif /* WGL_NV_float_buffer */
@@ -8014,6 +8819,10 @@ GLenum wglewContextInit (WGLEW_CONTEXT_ARG_DEF_LIST)
   CONST_CAST(WGLEW_3DL_stereo_control) = wglewGetExtension("WGL_3DL_stereo_control");
   if (glewExperimental || WGLEW_3DL_stereo_control|| crippled) CONST_CAST(WGLEW_3DL_stereo_control)= !_glewInit_WGL_3DL_stereo_control(GLEW_CONTEXT_ARG_VAR_INIT);
 #endif /* WGL_3DL_stereo_control */
+#ifdef WGL_AMD_gpu_association
+  CONST_CAST(WGLEW_AMD_gpu_association) = wglewGetExtension("WGL_AMD_gpu_association");
+  if (glewExperimental || WGLEW_AMD_gpu_association|| crippled) CONST_CAST(WGLEW_AMD_gpu_association)= !_glewInit_WGL_AMD_gpu_association(GLEW_CONTEXT_ARG_VAR_INIT);
+#endif /* WGL_AMD_gpu_association */
 #ifdef WGL_ARB_buffer_region
   CONST_CAST(WGLEW_ARB_buffer_region) = wglewGetExtension("WGL_ARB_buffer_region");
   if (glewExperimental || WGLEW_ARB_buffer_region|| crippled) CONST_CAST(WGLEW_ARB_buffer_region)= !_glewInit_WGL_ARB_buffer_region(GLEW_CONTEXT_ARG_VAR_INIT);
@@ -8022,6 +8831,9 @@ GLenum wglewContextInit (WGLEW_CONTEXT_ARG_DEF_LIST)
   CONST_CAST(WGLEW_ARB_create_context) = wglewGetExtension("WGL_ARB_create_context");
   if (glewExperimental || WGLEW_ARB_create_context|| crippled) CONST_CAST(WGLEW_ARB_create_context)= !_glewInit_WGL_ARB_create_context(GLEW_CONTEXT_ARG_VAR_INIT);
 #endif /* WGL_ARB_create_context */
+#ifdef WGL_ARB_create_context_profile
+  CONST_CAST(WGLEW_ARB_create_context_profile) = wglewGetExtension("WGL_ARB_create_context_profile");
+#endif /* WGL_ARB_create_context_profile */
 #ifdef WGL_ARB_extensions_string
   CONST_CAST(WGLEW_ARB_extensions_string) = wglewGetExtension("WGL_ARB_extensions_string");
   if (glewExperimental || WGLEW_ARB_extensions_string|| crippled) CONST_CAST(WGLEW_ARB_extensions_string)= !_glewInit_WGL_ARB_extensions_string(GLEW_CONTEXT_ARG_VAR_INIT);
@@ -8117,6 +8929,10 @@ GLenum wglewContextInit (WGLEW_CONTEXT_ARG_DEF_LIST)
   CONST_CAST(WGLEW_I3D_swap_frame_usage) = wglewGetExtension("WGL_I3D_swap_frame_usage");
   if (glewExperimental || WGLEW_I3D_swap_frame_usage|| crippled) CONST_CAST(WGLEW_I3D_swap_frame_usage)= !_glewInit_WGL_I3D_swap_frame_usage(GLEW_CONTEXT_ARG_VAR_INIT);
 #endif /* WGL_I3D_swap_frame_usage */
+#ifdef WGL_NV_copy_image
+  CONST_CAST(WGLEW_NV_copy_image) = wglewGetExtension("WGL_NV_copy_image");
+  if (glewExperimental || WGLEW_NV_copy_image|| crippled) CONST_CAST(WGLEW_NV_copy_image)= !_glewInit_WGL_NV_copy_image(GLEW_CONTEXT_ARG_VAR_INIT);
+#endif /* WGL_NV_copy_image */
 #ifdef WGL_NV_float_buffer
   CONST_CAST(WGLEW_NV_float_buffer) = wglewGetExtension("WGL_NV_float_buffer");
 #endif /* WGL_NV_float_buffer */
@@ -8187,6 +9003,8 @@ PFNGLXGETCONTEXTIDEXTPROC __glewXGetContextIDEXT = NULL;
 PFNGLXIMPORTCONTEXTEXTPROC __glewXImportContextEXT = NULL;
 PFNGLXQUERYCONTEXTINFOEXTPROC __glewXQueryContextInfoEXT = NULL;
 
+PFNGLXSWAPINTERVALEXTPROC __glewXSwapIntervalEXT = NULL;
+
 PFNGLXBINDTEXIMAGEEXTPROC __glewXBindTexImageEXT = NULL;
 PFNGLXRELEASETEXIMAGEEXTPROC __glewXReleaseTexImageEXT = NULL;
 
@@ -8200,6 +9018,8 @@ PFNGLXRELEASEBUFFERSMESAPROC __glewXReleaseBuffersMESA = NULL;
 
 PFNGLXSET3DFXMODEMESAPROC __glewXSet3DfxModeMESA = NULL;
 
+PFNGLXCOPYIMAGESUBDATANVPROC __glewXCopyImageSubDataNV = NULL;
+
 PFNGLXBINDVIDEODEVICENVPROC __glewXBindVideoDeviceNV = NULL;
 PFNGLXENUMERATEVIDEODEVICESNVPROC __glewXEnumerateVideoDevicesNV = NULL;
 
@@ -8285,6 +9105,7 @@ GLboolean __GLXEW_VERSION_1_3 = GL_FALSE;
 GLboolean __GLXEW_VERSION_1_4 = GL_FALSE;
 GLboolean __GLXEW_3DFX_multisample = GL_FALSE;
 GLboolean __GLXEW_ARB_create_context = GL_FALSE;
+GLboolean __GLXEW_ARB_create_context_profile = GL_FALSE;
 GLboolean __GLXEW_ARB_fbconfig_float = GL_FALSE;
 GLboolean __GLXEW_ARB_framebuffer_sRGB = GL_FALSE;
 GLboolean __GLXEW_ARB_get_proc_address = GL_FALSE;
@@ -8295,6 +9116,7 @@ GLboolean __GLXEW_EXT_fbconfig_packed_float = GL_FALSE;
 GLboolean __GLXEW_EXT_framebuffer_sRGB = GL_FALSE;
 GLboolean __GLXEW_EXT_import_context = GL_FALSE;
 GLboolean __GLXEW_EXT_scene_marker = GL_FALSE;
+GLboolean __GLXEW_EXT_swap_control = GL_FALSE;
 GLboolean __GLXEW_EXT_texture_from_pixmap = GL_FALSE;
 GLboolean __GLXEW_EXT_visual_info = GL_FALSE;
 GLboolean __GLXEW_EXT_visual_rating = GL_FALSE;
@@ -8303,6 +9125,7 @@ GLboolean __GLXEW_MESA_copy_sub_buffer = GL_FALSE;
 GLboolean __GLXEW_MESA_pixmap_colormap = GL_FALSE;
 GLboolean __GLXEW_MESA_release_buffers = GL_FALSE;
 GLboolean __GLXEW_MESA_set_3dfx_mode = GL_FALSE;
+GLboolean __GLXEW_NV_copy_image = GL_FALSE;
 GLboolean __GLXEW_NV_float_buffer = GL_FALSE;
 GLboolean __GLXEW_NV_present_video = GL_FALSE;
 GLboolean __GLXEW_NV_swap_group = GL_FALSE;
@@ -8395,6 +9218,10 @@ static GLboolean _glewInit_GLX_ARB_create_context (GLXEW_CONTEXT_ARG_DEF_INIT)
 
 #endif /* GLX_ARB_create_context */
 
+#ifdef GLX_ARB_create_context_profile
+
+#endif /* GLX_ARB_create_context_profile */
+
 #ifdef GLX_ARB_fbconfig_float
 
 #endif /* GLX_ARB_fbconfig_float */
@@ -8458,6 +9285,19 @@ static GLboolean _glewInit_GLX_EXT_import_context (GLXEW_CONTEXT_ARG_DEF_INIT)
 
 #endif /* GLX_EXT_scene_marker */
 
+#ifdef GLX_EXT_swap_control
+
+static GLboolean _glewInit_GLX_EXT_swap_control (GLXEW_CONTEXT_ARG_DEF_INIT)
+{
+  GLboolean r = GL_FALSE;
+
+  r = ((glXSwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)glewGetProcAddress((const GLubyte*)"glXSwapIntervalEXT")) == NULL) || r;
+
+  return r;
+}
+
+#endif /* GLX_EXT_swap_control */
+
 #ifdef GLX_EXT_texture_from_pixmap
 
 static GLboolean _glewInit_GLX_EXT_texture_from_pixmap (GLXEW_CONTEXT_ARG_DEF_INIT)
@@ -8545,6 +9385,19 @@ static GLboolean _glewInit_GLX_MESA_set_3dfx_mode (GLXEW_CONTEXT_ARG_DEF_INIT)
 
 #endif /* GLX_MESA_set_3dfx_mode */
 
+#ifdef GLX_NV_copy_image
+
+static GLboolean _glewInit_GLX_NV_copy_image (GLXEW_CONTEXT_ARG_DEF_INIT)
+{
+  GLboolean r = GL_FALSE;
+
+  r = ((glXCopyImageSubDataNV = (PFNGLXCOPYIMAGESUBDATANVPROC)glewGetProcAddress((const GLubyte*)"glXCopyImageSubDataNV")) == NULL) || r;
+
+  return r;
+}
+
+#endif /* GLX_NV_copy_image */
+
 #ifdef GLX_NV_float_buffer
 
 #endif /* GLX_NV_float_buffer */
@@ -8841,10 +9694,10 @@ GLboolean glxewGetExtension (const char* name)
 {    
   GLubyte* p;
   GLubyte* end;
-  GLuint len = _glewStrLen((const GLubyte*)name);
-/*   if (glXQueryExtensionsString == NULL || glXGetCurrentDisplay == NULL) return GL_FALSE; */
-/*   p = (GLubyte*)glXQueryExtensionsString(glXGetCurrentDisplay(), DefaultScreen(glXGetCurrentDisplay())); */
-  if (glXGetClientString == NULL || glXGetCurrentDisplay == NULL) return GL_FALSE;
+  GLuint len;
+
+  if (glXGetCurrentDisplay == NULL) return GL_FALSE;
+  len = _glewStrLen((const GLubyte*)name);
   p = (GLubyte*)glXGetClientString(glXGetCurrentDisplay(), GLX_EXTENSIONS);
   if (0 == p) return GL_FALSE;
   end = p + _glewStrLen(p);
@@ -8897,6 +9750,9 @@ GLenum glxewContextInit (GLXEW_CONTEXT_ARG_DEF_LIST)
   CONST_CAST(GLXEW_ARB_create_context) = glxewGetExtension("GLX_ARB_create_context");
   if (glewExperimental || GLXEW_ARB_create_context) CONST_CAST(GLXEW_ARB_create_context) = !_glewInit_GLX_ARB_create_context(GLEW_CONTEXT_ARG_VAR_INIT);
 #endif /* GLX_ARB_create_context */
+#ifdef GLX_ARB_create_context_profile
+  CONST_CAST(GLXEW_ARB_create_context_profile) = glxewGetExtension("GLX_ARB_create_context_profile");
+#endif /* GLX_ARB_create_context_profile */
 #ifdef GLX_ARB_fbconfig_float
   CONST_CAST(GLXEW_ARB_fbconfig_float) = glxewGetExtension("GLX_ARB_fbconfig_float");
 #endif /* GLX_ARB_fbconfig_float */
@@ -8929,6 +9785,10 @@ GLenum glxewContextInit (GLXEW_CONTEXT_ARG_DEF_LIST)
 #ifdef GLX_EXT_scene_marker
   CONST_CAST(GLXEW_EXT_scene_marker) = glxewGetExtension("GLX_EXT_scene_marker");
 #endif /* GLX_EXT_scene_marker */
+#ifdef GLX_EXT_swap_control
+  CONST_CAST(GLXEW_EXT_swap_control) = glxewGetExtension("GLX_EXT_swap_control");
+  if (glewExperimental || GLXEW_EXT_swap_control) CONST_CAST(GLXEW_EXT_swap_control) = !_glewInit_GLX_EXT_swap_control(GLEW_CONTEXT_ARG_VAR_INIT);
+#endif /* GLX_EXT_swap_control */
 #ifdef GLX_EXT_texture_from_pixmap
   CONST_CAST(GLXEW_EXT_texture_from_pixmap) = glxewGetExtension("GLX_EXT_texture_from_pixmap");
   if (glewExperimental || GLXEW_EXT_texture_from_pixmap) CONST_CAST(GLXEW_EXT_texture_from_pixmap) = !_glewInit_GLX_EXT_texture_from_pixmap(GLEW_CONTEXT_ARG_VAR_INIT);
@@ -8959,6 +9819,10 @@ GLenum glxewContextInit (GLXEW_CONTEXT_ARG_DEF_LIST)
   CONST_CAST(GLXEW_MESA_set_3dfx_mode) = glxewGetExtension("GLX_MESA_set_3dfx_mode");
   if (glewExperimental || GLXEW_MESA_set_3dfx_mode) CONST_CAST(GLXEW_MESA_set_3dfx_mode) = !_glewInit_GLX_MESA_set_3dfx_mode(GLEW_CONTEXT_ARG_VAR_INIT);
 #endif /* GLX_MESA_set_3dfx_mode */
+#ifdef GLX_NV_copy_image
+  CONST_CAST(GLXEW_NV_copy_image) = glxewGetExtension("GLX_NV_copy_image");
+  if (glewExperimental || GLXEW_NV_copy_image) CONST_CAST(GLXEW_NV_copy_image) = !_glewInit_GLX_NV_copy_image(GLEW_CONTEXT_ARG_VAR_INIT);
+#endif /* GLX_NV_copy_image */
 #ifdef GLX_NV_float_buffer
   CONST_CAST(GLXEW_NV_float_buffer) = glxewGetExtension("GLX_NV_float_buffer");
 #endif /* GLX_NV_float_buffer */
@@ -9076,10 +9940,10 @@ const GLubyte* glewGetString (GLenum name)
   static const GLubyte* _glewString[] =
   {
     (const GLubyte*)NULL,
-    (const GLubyte*)"1.5.1",
+    (const GLubyte*)"1.5.2",
     (const GLubyte*)"1",
     (const GLubyte*)"5",
-    (const GLubyte*)"1"
+    (const GLubyte*)"2"
   };
   const int max_string = sizeof(_glewString)/sizeof(*_glewString) - 1;
   return _glewString[(int)name > max_string ? 0 : (int)name];
@@ -9174,6 +10038,20 @@ GLboolean glewIsSupported (const char* name)
           ret = GLEW_VERSION_3_0;
           continue;
         }
+#endif
+#ifdef GL_VERSION_3_1
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"3_1", 3))
+        {
+          ret = GLEW_VERSION_3_1;
+          continue;
+        }
+#endif
+#ifdef GL_VERSION_3_2
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"3_2", 3))
+        {
+          ret = GLEW_VERSION_3_2;
+          continue;
+        }
 #endif
       }
       if (_glewStrSame2(&pos, &len, (const GLubyte*)"3DFX_", 5))
@@ -9198,10 +10076,48 @@ GLboolean glewIsSupported (const char* name)
           ret = GLEW_3DFX_texture_compression_FXT1;
           continue;
         }
+#endif
+      }
+      if (_glewStrSame2(&pos, &len, (const GLubyte*)"AMD_", 4))
+      {
+#ifdef GL_AMD_draw_buffers_blend
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"draw_buffers_blend", 18))
+        {
+          ret = GLEW_AMD_draw_buffers_blend;
+          continue;
+        }
+#endif
+#ifdef GL_AMD_performance_monitor
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"performance_monitor", 19))
+        {
+          ret = GLEW_AMD_performance_monitor;
+          continue;
+        }
+#endif
+#ifdef GL_AMD_texture_texture4
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_texture4", 16))
+        {
+          ret = GLEW_AMD_texture_texture4;
+          continue;
+        }
+#endif
+#ifdef GL_AMD_vertex_shader_tessellator
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_shader_tessellator", 25))
+        {
+          ret = GLEW_AMD_vertex_shader_tessellator;
+          continue;
+        }
 #endif
       }
       if (_glewStrSame2(&pos, &len, (const GLubyte*)"APPLE_", 6))
       {
+#ifdef GL_APPLE_aux_depth_stencil
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"aux_depth_stencil", 17))
+        {
+          ret = GLEW_APPLE_aux_depth_stencil;
+          continue;
+        }
+#endif
 #ifdef GL_APPLE_client_storage
         if (_glewStrSame3(&pos, &len, (const GLubyte*)"client_storage", 14))
         {
@@ -9237,6 +10153,13 @@ GLboolean glewIsSupported (const char* name)
           continue;
         }
 #endif
+#ifdef GL_APPLE_object_purgeable
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"object_purgeable", 16))
+        {
+          ret = GLEW_APPLE_object_purgeable;
+          continue;
+        }
+#endif
 #ifdef GL_APPLE_pixel_buffer
         if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_buffer", 12))
         {
@@ -9244,6 +10167,20 @@ GLboolean glewIsSupported (const char* name)
           continue;
         }
 #endif
+#ifdef GL_APPLE_rgb_422
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"rgb_422", 7))
+        {
+          ret = GLEW_APPLE_rgb_422;
+          continue;
+        }
+#endif
+#ifdef GL_APPLE_row_bytes
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"row_bytes", 9))
+        {
+          ret = GLEW_APPLE_row_bytes;
+          continue;
+        }
+#endif
 #ifdef GL_APPLE_specular_vector
         if (_glewStrSame3(&pos, &len, (const GLubyte*)"specular_vector", 15))
         {
@@ -9279,6 +10216,13 @@ GLboolean glewIsSupported (const char* name)
           continue;
         }
 #endif
+#ifdef GL_APPLE_vertex_program_evaluators
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_program_evaluators", 25))
+        {
+          ret = GLEW_APPLE_vertex_program_evaluators;
+          continue;
+        }
+#endif
 #ifdef GL_APPLE_ycbcr_422
         if (_glewStrSame3(&pos, &len, (const GLubyte*)"ycbcr_422", 9))
         {
@@ -9296,6 +10240,20 @@ GLboolean glewIsSupported (const char* name)
           continue;
         }
 #endif
+#ifdef GL_ARB_compatibility
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"compatibility", 13))
+        {
+          ret = GLEW_ARB_compatibility;
+          continue;
+        }
+#endif
+#ifdef GL_ARB_copy_buffer
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"copy_buffer", 11))
+        {
+          ret = GLEW_ARB_copy_buffer;
+          continue;
+        }
+#endif
 #ifdef GL_ARB_depth_buffer_float
         if (_glewStrSame3(&pos, &len, (const GLubyte*)"depth_buffer_float", 18))
         {
@@ -9303,6 +10261,13 @@ GLboolean glewIsSupported (const char* name)
           continue;
         }
 #endif
+#ifdef GL_ARB_depth_clamp
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"depth_clamp", 11))
+        {
+          ret = GLEW_ARB_depth_clamp;
+          continue;
+        }
+#endif
 #ifdef GL_ARB_depth_texture
         if (_glewStrSame3(&pos, &len, (const GLubyte*)"depth_texture", 13))
         {
@@ -9317,6 +10282,20 @@ GLboolean glewIsSupported (const char* name)
           continue;
         }
 #endif
+#ifdef GL_ARB_draw_buffers_blend
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"draw_buffers_blend", 18))
+        {
+          ret = GLEW_ARB_draw_buffers_blend;
+          continue;
+        }
+#endif
+#ifdef GL_ARB_draw_elements_base_vertex
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"draw_elements_base_vertex", 25))
+        {
+          ret = GLEW_ARB_draw_elements_base_vertex;
+          continue;
+        }
+#endif
 #ifdef GL_ARB_draw_instanced
         if (_glewStrSame3(&pos, &len, (const GLubyte*)"draw_instanced", 14))
         {
@@ -9324,6 +10303,13 @@ GLboolean glewIsSupported (const char* name)
           continue;
         }
 #endif
+#ifdef GL_ARB_fragment_coord_conventions
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_coord_conventions", 26))
+        {
+          ret = GLEW_ARB_fragment_coord_conventions;
+          continue;
+        }
+#endif
 #ifdef GL_ARB_fragment_program
         if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_program", 16))
         {
@@ -9450,6 +10436,27 @@ GLboolean glewIsSupported (const char* name)
           continue;
         }
 #endif
+#ifdef GL_ARB_provoking_vertex
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"provoking_vertex", 16))
+        {
+          ret = GLEW_ARB_provoking_vertex;
+          continue;
+        }
+#endif
+#ifdef GL_ARB_sample_shading
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"sample_shading", 14))
+        {
+          ret = GLEW_ARB_sample_shading;
+          continue;
+        }
+#endif
+#ifdef GL_ARB_seamless_cube_map
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"seamless_cube_map", 17))
+        {
+          ret = GLEW_ARB_seamless_cube_map;
+          continue;
+        }
+#endif
 #ifdef GL_ARB_shader_objects
         if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_objects", 14))
         {
@@ -9457,6 +10464,13 @@ GLboolean glewIsSupported (const char* name)
           continue;
         }
 #endif
+#ifdef GL_ARB_shader_texture_lod
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_texture_lod", 18))
+        {
+          ret = GLEW_ARB_shader_texture_lod;
+          continue;
+        }
+#endif
 #ifdef GL_ARB_shading_language_100
         if (_glewStrSame3(&pos, &len, (const GLubyte*)"shading_language_100", 20))
         {
@@ -9478,6 +10492,13 @@ GLboolean glewIsSupported (const char* name)
           continue;
         }
 #endif
+#ifdef GL_ARB_sync
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"sync", 4))
+        {
+          ret = GLEW_ARB_sync;
+          continue;
+        }
+#endif
 #ifdef GL_ARB_texture_border_clamp
         if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_border_clamp", 20))
         {
@@ -9513,6 +10534,13 @@ GLboolean glewIsSupported (const char* name)
           continue;
         }
 #endif
+#ifdef GL_ARB_texture_cube_map_array
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_cube_map_array", 22))
+        {
+          ret = GLEW_ARB_texture_cube_map_array;
+          continue;
+        }
+#endif
 #ifdef GL_ARB_texture_env_add
         if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_add", 15))
         {
@@ -9548,6 +10576,13 @@ GLboolean glewIsSupported (const char* name)
           continue;
         }
 #endif
+#ifdef GL_ARB_texture_gather
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_gather", 14))
+        {
+          ret = GLEW_ARB_texture_gather;
+          continue;
+        }
+#endif
 #ifdef GL_ARB_texture_mirrored_repeat
         if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_mirrored_repeat", 23))
         {
@@ -9555,6 +10590,13 @@ GLboolean glewIsSupported (const char* name)
           continue;
         }
 #endif
+#ifdef GL_ARB_texture_multisample
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_multisample", 19))
+        {
+          ret = GLEW_ARB_texture_multisample;
+          continue;
+        }
+#endif
 #ifdef GL_ARB_texture_non_power_of_two
         if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_non_power_of_two", 24))
         {
@@ -9562,6 +10604,13 @@ GLboolean glewIsSupported (const char* name)
           continue;
         }
 #endif
+#ifdef GL_ARB_texture_query_lod
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_query_lod", 17))
+        {
+          ret = GLEW_ARB_texture_query_lod;
+          continue;
+        }
+#endif
 #ifdef GL_ARB_texture_rectangle
         if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_rectangle", 17))
         {
@@ -9583,6 +10632,20 @@ GLboolean glewIsSupported (const char* name)
           continue;
         }
 #endif
+#ifdef GL_ARB_uniform_buffer_object
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"uniform_buffer_object", 21))
+        {
+          ret = GLEW_ARB_uniform_buffer_object;
+          continue;
+        }
+#endif
+#ifdef GL_ARB_vertex_array_bgra
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_bgra", 17))
+        {
+          ret = GLEW_ARB_vertex_array_bgra;
+          continue;
+        }
+#endif
 #ifdef GL_ARB_vertex_array_object
         if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_object", 19))
         {
@@ -9694,6 +10757,13 @@ GLboolean glewIsSupported (const char* name)
           continue;
         }
 #endif
+#ifdef GL_ATI_meminfo
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"meminfo", 7))
+        {
+          ret = GLEW_ATI_meminfo;
+          continue;
+        }
+#endif
 #ifdef GL_ATI_pn_triangles
         if (_glewStrSame3(&pos, &len, (const GLubyte*)"pn_triangles", 12))
         {
@@ -10131,6 +11201,13 @@ GLboolean glewIsSupported (const char* name)
           continue;
         }
 #endif
+#ifdef GL_EXT_provoking_vertex
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"provoking_vertex", 16))
+        {
+          ret = GLEW_EXT_provoking_vertex;
+          continue;
+        }
+#endif
 #ifdef GL_EXT_rescale_normal
         if (_glewStrSame3(&pos, &len, (const GLubyte*)"rescale_normal", 14))
         {
@@ -10152,6 +11229,13 @@ GLboolean glewIsSupported (const char* name)
           continue;
         }
 #endif
+#ifdef GL_EXT_separate_shader_objects
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"separate_shader_objects", 23))
+        {
+          ret = GLEW_EXT_separate_shader_objects;
+          continue;
+        }
+#endif
 #ifdef GL_EXT_separate_specular_color
         if (_glewStrSame3(&pos, &len, (const GLubyte*)"separate_specular_color", 23))
         {
@@ -10362,6 +11446,13 @@ GLboolean glewIsSupported (const char* name)
           continue;
         }
 #endif
+#ifdef GL_EXT_texture_snorm
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_snorm", 13))
+        {
+          ret = GLEW_EXT_texture_snorm;
+          continue;
+        }
+#endif
 #ifdef GL_EXT_texture_swizzle
         if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_swizzle", 15))
         {
@@ -10613,6 +11704,13 @@ GLboolean glewIsSupported (const char* name)
           continue;
         }
 #endif
+#ifdef GL_NV_copy_image
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"copy_image", 10))
+        {
+          ret = GLEW_NV_copy_image;
+          continue;
+        }
+#endif
 #ifdef GL_NV_depth_buffer_float
         if (_glewStrSame3(&pos, &len, (const GLubyte*)"depth_buffer_float", 18))
         {
@@ -10767,6 +11865,13 @@ GLboolean glewIsSupported (const char* name)
           continue;
         }
 #endif
+#ifdef GL_NV_parameter_buffer_object2
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"parameter_buffer_object2", 24))
+        {
+          ret = GLEW_NV_parameter_buffer_object2;
+          continue;
+        }
+#endif
 #ifdef GL_NV_pixel_data_range
         if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_data_range", 16))
         {
@@ -10809,6 +11914,13 @@ GLboolean glewIsSupported (const char* name)
           continue;
         }
 #endif
+#ifdef GL_NV_shader_buffer_load
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_buffer_load", 18))
+        {
+          ret = GLEW_NV_shader_buffer_load;
+          continue;
+        }
+#endif
 #ifdef GL_NV_texgen_emboss
         if (_glewStrSame3(&pos, &len, (const GLubyte*)"texgen_emboss", 13))
         {
@@ -10823,6 +11935,13 @@ GLboolean glewIsSupported (const char* name)
           continue;
         }
 #endif
+#ifdef GL_NV_texture_barrier
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_barrier", 15))
+        {
+          ret = GLEW_NV_texture_barrier;
+          continue;
+        }
+#endif
 #ifdef GL_NV_texture_compression_vtc
         if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_vtc", 23))
         {
@@ -10879,6 +11998,13 @@ GLboolean glewIsSupported (const char* name)
           continue;
         }
 #endif
+#ifdef GL_NV_transform_feedback2
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"transform_feedback2", 19))
+        {
+          ret = GLEW_NV_transform_feedback2;
+          continue;
+        }
+#endif
 #ifdef GL_NV_vertex_array_range
         if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_range", 18))
         {
@@ -10893,6 +12019,13 @@ GLboolean glewIsSupported (const char* name)
           continue;
         }
 #endif
+#ifdef GL_NV_vertex_buffer_unified_memory
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_buffer_unified_memory", 28))
+        {
+          ret = GLEW_NV_vertex_buffer_unified_memory;
+          continue;
+        }
+#endif
 #ifdef GL_NV_vertex_program
         if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_program", 14))
         {
@@ -11505,6 +12638,16 @@ GLboolean wglewIsSupported (const char* name)
           ret = WGLEW_3DL_stereo_control;
           continue;
         }
+#endif
+      }
+      if (_glewStrSame2(&pos, &len, (const GLubyte*)"AMD_", 4))
+      {
+#ifdef WGL_AMD_gpu_association
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"gpu_association", 15))
+        {
+          ret = WGLEW_AMD_gpu_association;
+          continue;
+        }
 #endif
       }
       if (_glewStrSame2(&pos, &len, (const GLubyte*)"ARB_", 4))
@@ -11523,6 +12666,13 @@ GLboolean wglewIsSupported (const char* name)
           continue;
         }
 #endif
+#ifdef WGL_ARB_create_context_profile
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"create_context_profile", 22))
+        {
+          ret = WGLEW_ARB_create_context_profile;
+          continue;
+        }
+#endif
 #ifdef WGL_ARB_extensions_string
         if (_glewStrSame3(&pos, &len, (const GLubyte*)"extensions_string", 17))
         {
@@ -11717,6 +12867,13 @@ GLboolean wglewIsSupported (const char* name)
       }
       if (_glewStrSame2(&pos, &len, (const GLubyte*)"NV_", 3))
       {
+#ifdef WGL_NV_copy_image
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"copy_image", 10))
+        {
+          ret = WGLEW_NV_copy_image;
+          continue;
+        }
+#endif
 #ifdef WGL_NV_float_buffer
         if (_glewStrSame3(&pos, &len, (const GLubyte*)"float_buffer", 12))
         {
@@ -11848,6 +13005,13 @@ GLboolean glxewIsSupported (const char* name)
           continue;
         }
 #endif
+#ifdef GLX_ARB_create_context_profile
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"create_context_profile", 22))
+        {
+          ret = GLXEW_ARB_create_context_profile;
+          continue;
+        }
+#endif
 #ifdef GLX_ARB_fbconfig_float
         if (_glewStrSame3(&pos, &len, (const GLubyte*)"fbconfig_float", 14))
         {
@@ -11924,6 +13088,13 @@ GLboolean glxewIsSupported (const char* name)
           continue;
         }
 #endif
+#ifdef GLX_EXT_swap_control
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_control", 12))
+        {
+          ret = GLXEW_EXT_swap_control;
+          continue;
+        }
+#endif
 #ifdef GLX_EXT_texture_from_pixmap
         if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_from_pixmap", 19))
         {
@@ -11986,6 +13157,13 @@ GLboolean glxewIsSupported (const char* name)
       }
       if (_glewStrSame2(&pos, &len, (const GLubyte*)"NV_", 3))
       {
+#ifdef GLX_NV_copy_image
+        if (_glewStrSame3(&pos, &len, (const GLubyte*)"copy_image", 10))
+        {
+          ret = GLXEW_NV_copy_image;
+          continue;
+        }
+#endif
 #ifdef GLX_NV_float_buffer
         if (_glewStrSame3(&pos, &len, (const GLubyte*)"float_buffer", 12))
         {
index da2b241deab6e60b0070ebd60fd71d2af7472652..6847cbb865261c21df654b0dc86558c41cdf0932 100644 (file)
@@ -389,8 +389,6 @@ static void _glewInfo_GL_VERSION_3_0 (void)
 
   glewInfoFunc("glBeginConditionalRender", glBeginConditionalRender == NULL);
   glewInfoFunc("glBeginTransformFeedback", glBeginTransformFeedback == NULL);
-  glewInfoFunc("glBindBufferBase", glBindBufferBase == NULL);
-  glewInfoFunc("glBindBufferRange", glBindBufferRange == NULL);
   glewInfoFunc("glBindFragDataLocation", glBindFragDataLocation == NULL);
   glewInfoFunc("glClampColor", glClampColor == NULL);
   glewInfoFunc("glClearBufferfi", glClearBufferfi == NULL);
@@ -404,7 +402,6 @@ static void _glewInfo_GL_VERSION_3_0 (void)
   glewInfoFunc("glEndTransformFeedback", glEndTransformFeedback == NULL);
   glewInfoFunc("glGetBooleani_v", glGetBooleani_v == NULL);
   glewInfoFunc("glGetFragDataLocation", glGetFragDataLocation == NULL);
-  glewInfoFunc("glGetIntegeri_v", glGetIntegeri_v == NULL);
   glewInfoFunc("glGetStringi", glGetStringi == NULL);
   glewInfoFunc("glGetTexParameterIiv", glGetTexParameterIiv == NULL);
   glewInfoFunc("glGetTexParameterIuiv", glGetTexParameterIuiv == NULL);
@@ -449,6 +446,33 @@ static void _glewInfo_GL_VERSION_3_0 (void)
 
 #endif /* GL_VERSION_3_0 */
 
+#ifdef GL_VERSION_3_1
+
+static void _glewInfo_GL_VERSION_3_1 (void)
+{
+  glewPrintExt("GL_VERSION_3_1", GLEW_VERSION_3_1, GLEW_VERSION_3_1, GLEW_VERSION_3_1);
+
+  glewInfoFunc("glDrawArraysInstanced", glDrawArraysInstanced == NULL);
+  glewInfoFunc("glDrawElementsInstanced", glDrawElementsInstanced == NULL);
+  glewInfoFunc("glPrimitiveRestartIndex", glPrimitiveRestartIndex == NULL);
+  glewInfoFunc("glTexBuffer", glTexBuffer == NULL);
+}
+
+#endif /* GL_VERSION_3_1 */
+
+#ifdef GL_VERSION_3_2
+
+static void _glewInfo_GL_VERSION_3_2 (void)
+{
+  glewPrintExt("GL_VERSION_3_2", GLEW_VERSION_3_2, GLEW_VERSION_3_2, GLEW_VERSION_3_2);
+
+  glewInfoFunc("glFramebufferTexture", glFramebufferTexture == NULL);
+  glewInfoFunc("glGetBufferParameteri64v", glGetBufferParameteri64v == NULL);
+  glewInfoFunc("glGetInteger64i_v", glGetInteger64i_v == NULL);
+}
+
+#endif /* GL_VERSION_3_2 */
+
 #ifdef GL_3DFX_multisample
 
 static void _glewInfo_GL_3DFX_multisample (void)
@@ -478,6 +502,71 @@ static void _glewInfo_GL_3DFX_texture_compression_FXT1 (void)
 
 #endif /* GL_3DFX_texture_compression_FXT1 */
 
+#ifdef GL_AMD_draw_buffers_blend
+
+static void _glewInfo_GL_AMD_draw_buffers_blend (void)
+{
+  glewPrintExt("GL_AMD_draw_buffers_blend", GLEW_AMD_draw_buffers_blend, glewIsSupported("GL_AMD_draw_buffers_blend"), glewGetExtension("GL_AMD_draw_buffers_blend"));
+
+  glewInfoFunc("glBlendEquationIndexedAMD", glBlendEquationIndexedAMD == NULL);
+  glewInfoFunc("glBlendEquationSeparateIndexedAMD", glBlendEquationSeparateIndexedAMD == NULL);
+  glewInfoFunc("glBlendFuncIndexedAMD", glBlendFuncIndexedAMD == NULL);
+  glewInfoFunc("glBlendFuncSeparateIndexedAMD", glBlendFuncSeparateIndexedAMD == NULL);
+}
+
+#endif /* GL_AMD_draw_buffers_blend */
+
+#ifdef GL_AMD_performance_monitor
+
+static void _glewInfo_GL_AMD_performance_monitor (void)
+{
+  glewPrintExt("GL_AMD_performance_monitor", GLEW_AMD_performance_monitor, glewIsSupported("GL_AMD_performance_monitor"), glewGetExtension("GL_AMD_performance_monitor"));
+
+  glewInfoFunc("glBeginPerfMonitorAMD", glBeginPerfMonitorAMD == NULL);
+  glewInfoFunc("glDeletePerfMonitorsAMD", glDeletePerfMonitorsAMD == NULL);
+  glewInfoFunc("glEndPerfMonitorAMD", glEndPerfMonitorAMD == NULL);
+  glewInfoFunc("glGenPerfMonitorsAMD", glGenPerfMonitorsAMD == NULL);
+  glewInfoFunc("glGetPerfMonitorCounterDataAMD", glGetPerfMonitorCounterDataAMD == NULL);
+  glewInfoFunc("glGetPerfMonitorCounterInfoAMD", glGetPerfMonitorCounterInfoAMD == NULL);
+  glewInfoFunc("glGetPerfMonitorCounterStringAMD", glGetPerfMonitorCounterStringAMD == NULL);
+  glewInfoFunc("glGetPerfMonitorCountersAMD", glGetPerfMonitorCountersAMD == NULL);
+  glewInfoFunc("glGetPerfMonitorGroupStringAMD", glGetPerfMonitorGroupStringAMD == NULL);
+  glewInfoFunc("glGetPerfMonitorGroupsAMD", glGetPerfMonitorGroupsAMD == NULL);
+  glewInfoFunc("glSelectPerfMonitorCountersAMD", glSelectPerfMonitorCountersAMD == NULL);
+}
+
+#endif /* GL_AMD_performance_monitor */
+
+#ifdef GL_AMD_texture_texture4
+
+static void _glewInfo_GL_AMD_texture_texture4 (void)
+{
+  glewPrintExt("GL_AMD_texture_texture4", GLEW_AMD_texture_texture4, glewIsSupported("GL_AMD_texture_texture4"), glewGetExtension("GL_AMD_texture_texture4"));
+}
+
+#endif /* GL_AMD_texture_texture4 */
+
+#ifdef GL_AMD_vertex_shader_tessellator
+
+static void _glewInfo_GL_AMD_vertex_shader_tessellator (void)
+{
+  glewPrintExt("GL_AMD_vertex_shader_tessellator", GLEW_AMD_vertex_shader_tessellator, glewIsSupported("GL_AMD_vertex_shader_tessellator"), glewGetExtension("GL_AMD_vertex_shader_tessellator"));
+
+  glewInfoFunc("glTessellationFactorAMD", glTessellationFactorAMD == NULL);
+  glewInfoFunc("glTessellationModeAMD", glTessellationModeAMD == NULL);
+}
+
+#endif /* GL_AMD_vertex_shader_tessellator */
+
+#ifdef GL_APPLE_aux_depth_stencil
+
+static void _glewInfo_GL_APPLE_aux_depth_stencil (void)
+{
+  glewPrintExt("GL_APPLE_aux_depth_stencil", GLEW_APPLE_aux_depth_stencil, glewIsSupported("GL_APPLE_aux_depth_stencil"), glewGetExtension("GL_APPLE_aux_depth_stencil"));
+}
+
+#endif /* GL_APPLE_aux_depth_stencil */
+
 #ifdef GL_APPLE_client_storage
 
 static void _glewInfo_GL_APPLE_client_storage (void)
@@ -541,6 +630,19 @@ static void _glewInfo_GL_APPLE_flush_buffer_range (void)
 
 #endif /* GL_APPLE_flush_buffer_range */
 
+#ifdef GL_APPLE_object_purgeable
+
+static void _glewInfo_GL_APPLE_object_purgeable (void)
+{
+  glewPrintExt("GL_APPLE_object_purgeable", GLEW_APPLE_object_purgeable, glewIsSupported("GL_APPLE_object_purgeable"), glewGetExtension("GL_APPLE_object_purgeable"));
+
+  glewInfoFunc("glGetObjectParameterivAPPLE", glGetObjectParameterivAPPLE == NULL);
+  glewInfoFunc("glObjectPurgeableAPPLE", glObjectPurgeableAPPLE == NULL);
+  glewInfoFunc("glObjectUnpurgeableAPPLE", glObjectUnpurgeableAPPLE == NULL);
+}
+
+#endif /* GL_APPLE_object_purgeable */
+
 #ifdef GL_APPLE_pixel_buffer
 
 static void _glewInfo_GL_APPLE_pixel_buffer (void)
@@ -550,6 +652,24 @@ static void _glewInfo_GL_APPLE_pixel_buffer (void)
 
 #endif /* GL_APPLE_pixel_buffer */
 
+#ifdef GL_APPLE_rgb_422
+
+static void _glewInfo_GL_APPLE_rgb_422 (void)
+{
+  glewPrintExt("GL_APPLE_rgb_422", GLEW_APPLE_rgb_422, glewIsSupported("GL_APPLE_rgb_422"), glewGetExtension("GL_APPLE_rgb_422"));
+}
+
+#endif /* GL_APPLE_rgb_422 */
+
+#ifdef GL_APPLE_row_bytes
+
+static void _glewInfo_GL_APPLE_row_bytes (void)
+{
+  glewPrintExt("GL_APPLE_row_bytes", GLEW_APPLE_row_bytes, glewIsSupported("GL_APPLE_row_bytes"), glewGetExtension("GL_APPLE_row_bytes"));
+}
+
+#endif /* GL_APPLE_row_bytes */
+
 #ifdef GL_APPLE_specular_vector
 
 static void _glewInfo_GL_APPLE_specular_vector (void)
@@ -607,6 +727,23 @@ static void _glewInfo_GL_APPLE_vertex_array_range (void)
 
 #endif /* GL_APPLE_vertex_array_range */
 
+#ifdef GL_APPLE_vertex_program_evaluators
+
+static void _glewInfo_GL_APPLE_vertex_program_evaluators (void)
+{
+  glewPrintExt("GL_APPLE_vertex_program_evaluators", GLEW_APPLE_vertex_program_evaluators, glewIsSupported("GL_APPLE_vertex_program_evaluators"), glewGetExtension("GL_APPLE_vertex_program_evaluators"));
+
+  glewInfoFunc("glDisableVertexAttribAPPLE", glDisableVertexAttribAPPLE == NULL);
+  glewInfoFunc("glEnableVertexAttribAPPLE", glEnableVertexAttribAPPLE == NULL);
+  glewInfoFunc("glIsVertexAttribEnabledAPPLE", glIsVertexAttribEnabledAPPLE == NULL);
+  glewInfoFunc("glMapVertexAttrib1dAPPLE", glMapVertexAttrib1dAPPLE == NULL);
+  glewInfoFunc("glMapVertexAttrib1fAPPLE", glMapVertexAttrib1fAPPLE == NULL);
+  glewInfoFunc("glMapVertexAttrib2dAPPLE", glMapVertexAttrib2dAPPLE == NULL);
+  glewInfoFunc("glMapVertexAttrib2fAPPLE", glMapVertexAttrib2fAPPLE == NULL);
+}
+
+#endif /* GL_APPLE_vertex_program_evaluators */
+
 #ifdef GL_APPLE_ycbcr_422
 
 static void _glewInfo_GL_APPLE_ycbcr_422 (void)
@@ -627,6 +764,26 @@ static void _glewInfo_GL_ARB_color_buffer_float (void)
 
 #endif /* GL_ARB_color_buffer_float */
 
+#ifdef GL_ARB_compatibility
+
+static void _glewInfo_GL_ARB_compatibility (void)
+{
+  glewPrintExt("GL_ARB_compatibility", GLEW_ARB_compatibility, glewIsSupported("GL_ARB_compatibility"), glewGetExtension("GL_ARB_compatibility"));
+}
+
+#endif /* GL_ARB_compatibility */
+
+#ifdef GL_ARB_copy_buffer
+
+static void _glewInfo_GL_ARB_copy_buffer (void)
+{
+  glewPrintExt("GL_ARB_copy_buffer", GLEW_ARB_copy_buffer, glewIsSupported("GL_ARB_copy_buffer"), glewGetExtension("GL_ARB_copy_buffer"));
+
+  glewInfoFunc("glCopyBufferSubData", glCopyBufferSubData == NULL);
+}
+
+#endif /* GL_ARB_copy_buffer */
+
 #ifdef GL_ARB_depth_buffer_float
 
 static void _glewInfo_GL_ARB_depth_buffer_float (void)
@@ -636,6 +793,15 @@ static void _glewInfo_GL_ARB_depth_buffer_float (void)
 
 #endif /* GL_ARB_depth_buffer_float */
 
+#ifdef GL_ARB_depth_clamp
+
+static void _glewInfo_GL_ARB_depth_clamp (void)
+{
+  glewPrintExt("GL_ARB_depth_clamp", GLEW_ARB_depth_clamp, glewIsSupported("GL_ARB_depth_clamp"), glewGetExtension("GL_ARB_depth_clamp"));
+}
+
+#endif /* GL_ARB_depth_clamp */
+
 #ifdef GL_ARB_depth_texture
 
 static void _glewInfo_GL_ARB_depth_texture (void)
@@ -656,6 +822,34 @@ static void _glewInfo_GL_ARB_draw_buffers (void)
 
 #endif /* GL_ARB_draw_buffers */
 
+#ifdef GL_ARB_draw_buffers_blend
+
+static void _glewInfo_GL_ARB_draw_buffers_blend (void)
+{
+  glewPrintExt("GL_ARB_draw_buffers_blend", GLEW_ARB_draw_buffers_blend, glewIsSupported("GL_ARB_draw_buffers_blend"), glewGetExtension("GL_ARB_draw_buffers_blend"));
+
+  glewInfoFunc("glBlendEquationSeparateiARB", glBlendEquationSeparateiARB == NULL);
+  glewInfoFunc("glBlendEquationiARB", glBlendEquationiARB == NULL);
+  glewInfoFunc("glBlendFuncSeparateiARB", glBlendFuncSeparateiARB == NULL);
+  glewInfoFunc("glBlendFunciARB", glBlendFunciARB == NULL);
+}
+
+#endif /* GL_ARB_draw_buffers_blend */
+
+#ifdef GL_ARB_draw_elements_base_vertex
+
+static void _glewInfo_GL_ARB_draw_elements_base_vertex (void)
+{
+  glewPrintExt("GL_ARB_draw_elements_base_vertex", GLEW_ARB_draw_elements_base_vertex, glewIsSupported("GL_ARB_draw_elements_base_vertex"), glewGetExtension("GL_ARB_draw_elements_base_vertex"));
+
+  glewInfoFunc("glDrawElementsBaseVertex", glDrawElementsBaseVertex == NULL);
+  glewInfoFunc("glDrawElementsInstancedBaseVertex", glDrawElementsInstancedBaseVertex == NULL);
+  glewInfoFunc("glDrawRangeElementsBaseVertex", glDrawRangeElementsBaseVertex == NULL);
+  glewInfoFunc("glMultiDrawElementsBaseVertex", glMultiDrawElementsBaseVertex == NULL);
+}
+
+#endif /* GL_ARB_draw_elements_base_vertex */
+
 #ifdef GL_ARB_draw_instanced
 
 static void _glewInfo_GL_ARB_draw_instanced (void)
@@ -668,6 +862,15 @@ static void _glewInfo_GL_ARB_draw_instanced (void)
 
 #endif /* GL_ARB_draw_instanced */
 
+#ifdef GL_ARB_fragment_coord_conventions
+
+static void _glewInfo_GL_ARB_fragment_coord_conventions (void)
+{
+  glewPrintExt("GL_ARB_fragment_coord_conventions", GLEW_ARB_fragment_coord_conventions, glewIsSupported("GL_ARB_fragment_coord_conventions"), glewGetExtension("GL_ARB_fragment_coord_conventions"));
+}
+
+#endif /* GL_ARB_fragment_coord_conventions */
+
 #ifdef GL_ARB_fragment_program
 
 static void _glewInfo_GL_ARB_fragment_program (void)
@@ -708,10 +911,10 @@ static void _glewInfo_GL_ARB_framebuffer_object (void)
   glewInfoFunc("glDeleteFramebuffers", glDeleteFramebuffers == NULL);
   glewInfoFunc("glDeleteRenderbuffers", glDeleteRenderbuffers == NULL);
   glewInfoFunc("glFramebufferRenderbuffer", glFramebufferRenderbuffer == NULL);
-  glewInfoFunc("glFramebufferTextureLayer", glFramebufferTextureLayer == NULL);
   glewInfoFunc("glFramebufferTexture1D", glFramebufferTexture1D == NULL);
   glewInfoFunc("glFramebufferTexture2D", glFramebufferTexture2D == NULL);
   glewInfoFunc("glFramebufferTexture3D", glFramebufferTexture3D == NULL);
+  glewInfoFunc("glFramebufferTextureLayer", glFramebufferTextureLayer == NULL);
   glewInfoFunc("glGenFramebuffers", glGenFramebuffers == NULL);
   glewInfoFunc("glGenRenderbuffers", glGenRenderbuffers == NULL);
   glewInfoFunc("glGenerateMipmap", glGenerateMipmap == NULL);
@@ -950,6 +1153,37 @@ static void _glewInfo_GL_ARB_point_sprite (void)
 
 #endif /* GL_ARB_point_sprite */
 
+#ifdef GL_ARB_provoking_vertex
+
+static void _glewInfo_GL_ARB_provoking_vertex (void)
+{
+  glewPrintExt("GL_ARB_provoking_vertex", GLEW_ARB_provoking_vertex, glewIsSupported("GL_ARB_provoking_vertex"), glewGetExtension("GL_ARB_provoking_vertex"));
+
+  glewInfoFunc("glProvokingVertex", glProvokingVertex == NULL);
+}
+
+#endif /* GL_ARB_provoking_vertex */
+
+#ifdef GL_ARB_sample_shading
+
+static void _glewInfo_GL_ARB_sample_shading (void)
+{
+  glewPrintExt("GL_ARB_sample_shading", GLEW_ARB_sample_shading, glewIsSupported("GL_ARB_sample_shading"), glewGetExtension("GL_ARB_sample_shading"));
+
+  glewInfoFunc("glMinSampleShadingARB", glMinSampleShadingARB == NULL);
+}
+
+#endif /* GL_ARB_sample_shading */
+
+#ifdef GL_ARB_seamless_cube_map
+
+static void _glewInfo_GL_ARB_seamless_cube_map (void)
+{
+  glewPrintExt("GL_ARB_seamless_cube_map", GLEW_ARB_seamless_cube_map, glewIsSupported("GL_ARB_seamless_cube_map"), glewGetExtension("GL_ARB_seamless_cube_map"));
+}
+
+#endif /* GL_ARB_seamless_cube_map */
+
 #ifdef GL_ARB_shader_objects
 
 static void _glewInfo_GL_ARB_shader_objects (void)
@@ -999,6 +1233,15 @@ static void _glewInfo_GL_ARB_shader_objects (void)
 
 #endif /* GL_ARB_shader_objects */
 
+#ifdef GL_ARB_shader_texture_lod
+
+static void _glewInfo_GL_ARB_shader_texture_lod (void)
+{
+  glewPrintExt("GL_ARB_shader_texture_lod", GLEW_ARB_shader_texture_lod, glewIsSupported("GL_ARB_shader_texture_lod"), glewGetExtension("GL_ARB_shader_texture_lod"));
+}
+
+#endif /* GL_ARB_shader_texture_lod */
+
 #ifdef GL_ARB_shading_language_100
 
 static void _glewInfo_GL_ARB_shading_language_100 (void)
@@ -1026,6 +1269,23 @@ static void _glewInfo_GL_ARB_shadow_ambient (void)
 
 #endif /* GL_ARB_shadow_ambient */
 
+#ifdef GL_ARB_sync
+
+static void _glewInfo_GL_ARB_sync (void)
+{
+  glewPrintExt("GL_ARB_sync", GLEW_ARB_sync, glewIsSupported("GL_ARB_sync"), glewGetExtension("GL_ARB_sync"));
+
+  glewInfoFunc("glClientWaitSync", glClientWaitSync == NULL);
+  glewInfoFunc("glDeleteSync", glDeleteSync == NULL);
+  glewInfoFunc("glFenceSync", glFenceSync == NULL);
+  glewInfoFunc("glGetInteger64v", glGetInteger64v == NULL);
+  glewInfoFunc("glGetSynciv", glGetSynciv == NULL);
+  glewInfoFunc("glIsSync", glIsSync == NULL);
+  glewInfoFunc("glWaitSync", glWaitSync == NULL);
+}
+
+#endif /* GL_ARB_sync */
+
 #ifdef GL_ARB_texture_border_clamp
 
 static void _glewInfo_GL_ARB_texture_border_clamp (void)
@@ -1081,6 +1341,15 @@ static void _glewInfo_GL_ARB_texture_cube_map (void)
 
 #endif /* GL_ARB_texture_cube_map */
 
+#ifdef GL_ARB_texture_cube_map_array
+
+static void _glewInfo_GL_ARB_texture_cube_map_array (void)
+{
+  glewPrintExt("GL_ARB_texture_cube_map_array", GLEW_ARB_texture_cube_map_array, glewIsSupported("GL_ARB_texture_cube_map_array"), glewGetExtension("GL_ARB_texture_cube_map_array"));
+}
+
+#endif /* GL_ARB_texture_cube_map_array */
+
 #ifdef GL_ARB_texture_env_add
 
 static void _glewInfo_GL_ARB_texture_env_add (void)
@@ -1126,6 +1395,15 @@ static void _glewInfo_GL_ARB_texture_float (void)
 
 #endif /* GL_ARB_texture_float */
 
+#ifdef GL_ARB_texture_gather
+
+static void _glewInfo_GL_ARB_texture_gather (void)
+{
+  glewPrintExt("GL_ARB_texture_gather", GLEW_ARB_texture_gather, glewIsSupported("GL_ARB_texture_gather"), glewGetExtension("GL_ARB_texture_gather"));
+}
+
+#endif /* GL_ARB_texture_gather */
+
 #ifdef GL_ARB_texture_mirrored_repeat
 
 static void _glewInfo_GL_ARB_texture_mirrored_repeat (void)
@@ -1135,6 +1413,20 @@ static void _glewInfo_GL_ARB_texture_mirrored_repeat (void)
 
 #endif /* GL_ARB_texture_mirrored_repeat */
 
+#ifdef GL_ARB_texture_multisample
+
+static void _glewInfo_GL_ARB_texture_multisample (void)
+{
+  glewPrintExt("GL_ARB_texture_multisample", GLEW_ARB_texture_multisample, glewIsSupported("GL_ARB_texture_multisample"), glewGetExtension("GL_ARB_texture_multisample"));
+
+  glewInfoFunc("glGetMultisamplefv", glGetMultisamplefv == NULL);
+  glewInfoFunc("glSampleMaski", glSampleMaski == NULL);
+  glewInfoFunc("glTexImage2DMultisample", glTexImage2DMultisample == NULL);
+  glewInfoFunc("glTexImage3DMultisample", glTexImage3DMultisample == NULL);
+}
+
+#endif /* GL_ARB_texture_multisample */
+
 #ifdef GL_ARB_texture_non_power_of_two
 
 static void _glewInfo_GL_ARB_texture_non_power_of_two (void)
@@ -1144,6 +1436,15 @@ static void _glewInfo_GL_ARB_texture_non_power_of_two (void)
 
 #endif /* GL_ARB_texture_non_power_of_two */
 
+#ifdef GL_ARB_texture_query_lod
+
+static void _glewInfo_GL_ARB_texture_query_lod (void)
+{
+  glewPrintExt("GL_ARB_texture_query_lod", GLEW_ARB_texture_query_lod, glewIsSupported("GL_ARB_texture_query_lod"), glewGetExtension("GL_ARB_texture_query_lod"));
+}
+
+#endif /* GL_ARB_texture_query_lod */
+
 #ifdef GL_ARB_texture_rectangle
 
 static void _glewInfo_GL_ARB_texture_rectangle (void)
@@ -1176,6 +1477,35 @@ static void _glewInfo_GL_ARB_transpose_matrix (void)
 
 #endif /* GL_ARB_transpose_matrix */
 
+#ifdef GL_ARB_uniform_buffer_object
+
+static void _glewInfo_GL_ARB_uniform_buffer_object (void)
+{
+  glewPrintExt("GL_ARB_uniform_buffer_object", GLEW_ARB_uniform_buffer_object, glewIsSupported("GL_ARB_uniform_buffer_object"), glewGetExtension("GL_ARB_uniform_buffer_object"));
+
+  glewInfoFunc("glBindBufferBase", glBindBufferBase == NULL);
+  glewInfoFunc("glBindBufferRange", glBindBufferRange == NULL);
+  glewInfoFunc("glGetActiveUniformBlockName", glGetActiveUniformBlockName == NULL);
+  glewInfoFunc("glGetActiveUniformBlockiv", glGetActiveUniformBlockiv == NULL);
+  glewInfoFunc("glGetActiveUniformName", glGetActiveUniformName == NULL);
+  glewInfoFunc("glGetActiveUniformsiv", glGetActiveUniformsiv == NULL);
+  glewInfoFunc("glGetIntegeri_v", glGetIntegeri_v == NULL);
+  glewInfoFunc("glGetUniformBlockIndex", glGetUniformBlockIndex == NULL);
+  glewInfoFunc("glGetUniformIndices", glGetUniformIndices == NULL);
+  glewInfoFunc("glUniformBlockBinding", glUniformBlockBinding == NULL);
+}
+
+#endif /* GL_ARB_uniform_buffer_object */
+
+#ifdef GL_ARB_vertex_array_bgra
+
+static void _glewInfo_GL_ARB_vertex_array_bgra (void)
+{
+  glewPrintExt("GL_ARB_vertex_array_bgra", GLEW_ARB_vertex_array_bgra, glewIsSupported("GL_ARB_vertex_array_bgra"), glewGetExtension("GL_ARB_vertex_array_bgra"));
+}
+
+#endif /* GL_ARB_vertex_array_bgra */
+
 #ifdef GL_ARB_vertex_array_object
 
 static void _glewInfo_GL_ARB_vertex_array_object (void)
@@ -1452,6 +1782,15 @@ static void _glewInfo_GL_ATI_map_object_buffer (void)
 
 #endif /* GL_ATI_map_object_buffer */
 
+#ifdef GL_ATI_meminfo
+
+static void _glewInfo_GL_ATI_meminfo (void)
+{
+  glewPrintExt("GL_ATI_meminfo", GLEW_ATI_meminfo, glewIsSupported("GL_ATI_meminfo"), glewGetExtension("GL_ATI_meminfo"));
+}
+
+#endif /* GL_ATI_meminfo */
+
 #ifdef GL_ATI_pn_triangles
 
 static void _glewInfo_GL_ATI_pn_triangles (void)
@@ -1870,7 +2209,14 @@ static void _glewInfo_GL_EXT_direct_state_access (void)
   glewInfoFunc("glCopyTextureSubImage2DEXT", glCopyTextureSubImage2DEXT == NULL);
   glewInfoFunc("glCopyTextureSubImage3DEXT", glCopyTextureSubImage3DEXT == NULL);
   glewInfoFunc("glDisableClientStateIndexedEXT", glDisableClientStateIndexedEXT == NULL);
+  glewInfoFunc("glDisableClientStateiEXT", glDisableClientStateiEXT == NULL);
+  glewInfoFunc("glDisableVertexArrayAttribEXT", glDisableVertexArrayAttribEXT == NULL);
+  glewInfoFunc("glDisableVertexArrayEXT", glDisableVertexArrayEXT == NULL);
   glewInfoFunc("glEnableClientStateIndexedEXT", glEnableClientStateIndexedEXT == NULL);
+  glewInfoFunc("glEnableClientStateiEXT", glEnableClientStateiEXT == NULL);
+  glewInfoFunc("glEnableVertexArrayAttribEXT", glEnableVertexArrayAttribEXT == NULL);
+  glewInfoFunc("glEnableVertexArrayEXT", glEnableVertexArrayEXT == NULL);
+  glewInfoFunc("glFlushMappedNamedBufferRangeEXT", glFlushMappedNamedBufferRangeEXT == NULL);
   glewInfoFunc("glFramebufferDrawBufferEXT", glFramebufferDrawBufferEXT == NULL);
   glewInfoFunc("glFramebufferDrawBuffersEXT", glFramebufferDrawBuffersEXT == NULL);
   glewInfoFunc("glFramebufferReadBufferEXT", glFramebufferReadBufferEXT == NULL);
@@ -1879,7 +2225,9 @@ static void _glewInfo_GL_EXT_direct_state_access (void)
   glewInfoFunc("glGetCompressedMultiTexImageEXT", glGetCompressedMultiTexImageEXT == NULL);
   glewInfoFunc("glGetCompressedTextureImageEXT", glGetCompressedTextureImageEXT == NULL);
   glewInfoFunc("glGetDoubleIndexedvEXT", glGetDoubleIndexedvEXT == NULL);
+  glewInfoFunc("glGetDoublei_vEXT", glGetDoublei_vEXT == NULL);
   glewInfoFunc("glGetFloatIndexedvEXT", glGetFloatIndexedvEXT == NULL);
+  glewInfoFunc("glGetFloati_vEXT", glGetFloati_vEXT == NULL);
   glewInfoFunc("glGetFramebufferParameterivEXT", glGetFramebufferParameterivEXT == NULL);
   glewInfoFunc("glGetMultiTexEnvfvEXT", glGetMultiTexEnvfvEXT == NULL);
   glewInfoFunc("glGetMultiTexEnvivEXT", glGetMultiTexEnvivEXT == NULL);
@@ -1905,6 +2253,7 @@ static void _glewInfo_GL_EXT_direct_state_access (void)
   glewInfoFunc("glGetNamedProgramivEXT", glGetNamedProgramivEXT == NULL);
   glewInfoFunc("glGetNamedRenderbufferParameterivEXT", glGetNamedRenderbufferParameterivEXT == NULL);
   glewInfoFunc("glGetPointerIndexedvEXT", glGetPointerIndexedvEXT == NULL);
+  glewInfoFunc("glGetPointeri_vEXT", glGetPointeri_vEXT == NULL);
   glewInfoFunc("glGetTextureImageEXT", glGetTextureImageEXT == NULL);
   glewInfoFunc("glGetTextureLevelParameterfvEXT", glGetTextureLevelParameterfvEXT == NULL);
   glewInfoFunc("glGetTextureLevelParameterivEXT", glGetTextureLevelParameterivEXT == NULL);
@@ -1912,7 +2261,12 @@ static void _glewInfo_GL_EXT_direct_state_access (void)
   glewInfoFunc("glGetTextureParameterIuivEXT", glGetTextureParameterIuivEXT == NULL);
   glewInfoFunc("glGetTextureParameterfvEXT", glGetTextureParameterfvEXT == NULL);
   glewInfoFunc("glGetTextureParameterivEXT", glGetTextureParameterivEXT == NULL);
+  glewInfoFunc("glGetVertexArrayIntegeri_vEXT", glGetVertexArrayIntegeri_vEXT == NULL);
+  glewInfoFunc("glGetVertexArrayIntegervEXT", glGetVertexArrayIntegervEXT == NULL);
+  glewInfoFunc("glGetVertexArrayPointeri_vEXT", glGetVertexArrayPointeri_vEXT == NULL);
+  glewInfoFunc("glGetVertexArrayPointervEXT", glGetVertexArrayPointervEXT == NULL);
   glewInfoFunc("glMapNamedBufferEXT", glMapNamedBufferEXT == NULL);
+  glewInfoFunc("glMapNamedBufferRangeEXT", glMapNamedBufferRangeEXT == NULL);
   glewInfoFunc("glMatrixFrustumEXT", glMatrixFrustumEXT == NULL);
   glewInfoFunc("glMatrixLoadIdentityEXT", glMatrixLoadIdentityEXT == NULL);
   glewInfoFunc("glMatrixLoadTransposedEXT", glMatrixLoadTransposedEXT == NULL);
@@ -1959,6 +2313,7 @@ static void _glewInfo_GL_EXT_direct_state_access (void)
   glewInfoFunc("glMultiTexSubImage3DEXT", glMultiTexSubImage3DEXT == NULL);
   glewInfoFunc("glNamedBufferDataEXT", glNamedBufferDataEXT == NULL);
   glewInfoFunc("glNamedBufferSubDataEXT", glNamedBufferSubDataEXT == NULL);
+  glewInfoFunc("glNamedCopyBufferSubDataEXT", glNamedCopyBufferSubDataEXT == NULL);
   glewInfoFunc("glNamedFramebufferRenderbufferEXT", glNamedFramebufferRenderbufferEXT == NULL);
   glewInfoFunc("glNamedFramebufferTexture1DEXT", glNamedFramebufferTexture1DEXT == NULL);
   glewInfoFunc("glNamedFramebufferTexture2DEXT", glNamedFramebufferTexture2DEXT == NULL);
@@ -2030,6 +2385,17 @@ static void _glewInfo_GL_EXT_direct_state_access (void)
   glewInfoFunc("glTextureSubImage2DEXT", glTextureSubImage2DEXT == NULL);
   glewInfoFunc("glTextureSubImage3DEXT", glTextureSubImage3DEXT == NULL);
   glewInfoFunc("glUnmapNamedBufferEXT", glUnmapNamedBufferEXT == NULL);
+  glewInfoFunc("glVertexArrayColorOffsetEXT", glVertexArrayColorOffsetEXT == NULL);
+  glewInfoFunc("glVertexArrayEdgeFlagOffsetEXT", glVertexArrayEdgeFlagOffsetEXT == NULL);
+  glewInfoFunc("glVertexArrayFogCoordOffsetEXT", glVertexArrayFogCoordOffsetEXT == NULL);
+  glewInfoFunc("glVertexArrayIndexOffsetEXT", glVertexArrayIndexOffsetEXT == NULL);
+  glewInfoFunc("glVertexArrayMultiTexCoordOffsetEXT", glVertexArrayMultiTexCoordOffsetEXT == NULL);
+  glewInfoFunc("glVertexArrayNormalOffsetEXT", glVertexArrayNormalOffsetEXT == NULL);
+  glewInfoFunc("glVertexArraySecondaryColorOffsetEXT", glVertexArraySecondaryColorOffsetEXT == NULL);
+  glewInfoFunc("glVertexArrayTexCoordOffsetEXT", glVertexArrayTexCoordOffsetEXT == NULL);
+  glewInfoFunc("glVertexArrayVertexAttribIOffsetEXT", glVertexArrayVertexAttribIOffsetEXT == NULL);
+  glewInfoFunc("glVertexArrayVertexAttribOffsetEXT", glVertexArrayVertexAttribOffsetEXT == NULL);
+  glewInfoFunc("glVertexArrayVertexOffsetEXT", glVertexArrayVertexOffsetEXT == NULL);
 }
 
 #endif /* GL_EXT_direct_state_access */
@@ -2448,6 +2814,17 @@ static void _glewInfo_GL_EXT_polygon_offset (void)
 
 #endif /* GL_EXT_polygon_offset */
 
+#ifdef GL_EXT_provoking_vertex
+
+static void _glewInfo_GL_EXT_provoking_vertex (void)
+{
+  glewPrintExt("GL_EXT_provoking_vertex", GLEW_EXT_provoking_vertex, glewIsSupported("GL_EXT_provoking_vertex"), glewGetExtension("GL_EXT_provoking_vertex"));
+
+  glewInfoFunc("glProvokingVertexEXT", glProvokingVertexEXT == NULL);
+}
+
+#endif /* GL_EXT_provoking_vertex */
+
 #ifdef GL_EXT_rescale_normal
 
 static void _glewInfo_GL_EXT_rescale_normal (void)
@@ -2496,6 +2873,19 @@ static void _glewInfo_GL_EXT_secondary_color (void)
 
 #endif /* GL_EXT_secondary_color */
 
+#ifdef GL_EXT_separate_shader_objects
+
+static void _glewInfo_GL_EXT_separate_shader_objects (void)
+{
+  glewPrintExt("GL_EXT_separate_shader_objects", GLEW_EXT_separate_shader_objects, glewIsSupported("GL_EXT_separate_shader_objects"), glewGetExtension("GL_EXT_separate_shader_objects"));
+
+  glewInfoFunc("glActiveProgramEXT", glActiveProgramEXT == NULL);
+  glewInfoFunc("glCreateShaderProgramEXT", glCreateShaderProgramEXT == NULL);
+  glewInfoFunc("glUseShaderProgramEXT", glUseShaderProgramEXT == NULL);
+}
+
+#endif /* GL_EXT_separate_shader_objects */
+
 #ifdef GL_EXT_separate_specular_color
 
 static void _glewInfo_GL_EXT_separate_specular_color (void)
@@ -2792,6 +3182,15 @@ static void _glewInfo_GL_EXT_texture_shared_exponent (void)
 
 #endif /* GL_EXT_texture_shared_exponent */
 
+#ifdef GL_EXT_texture_snorm
+
+static void _glewInfo_GL_EXT_texture_snorm (void)
+{
+  glewPrintExt("GL_EXT_texture_snorm", GLEW_EXT_texture_snorm, glewIsSupported("GL_EXT_texture_snorm"), glewGetExtension("GL_EXT_texture_snorm"));
+}
+
+#endif /* GL_EXT_texture_snorm */
+
 #ifdef GL_EXT_texture_swizzle
 
 static void _glewInfo_GL_EXT_texture_swizzle (void)
@@ -3215,6 +3614,17 @@ static void _glewInfo_GL_NV_copy_depth_to_color (void)
 
 #endif /* GL_NV_copy_depth_to_color */
 
+#ifdef GL_NV_copy_image
+
+static void _glewInfo_GL_NV_copy_image (void)
+{
+  glewPrintExt("GL_NV_copy_image", GLEW_NV_copy_image, glewIsSupported("GL_NV_copy_image"), glewGetExtension("GL_NV_copy_image"));
+
+  glewInfoFunc("glCopyImageSubDataNV", glCopyImageSubDataNV == NULL);
+}
+
+#endif /* GL_NV_copy_image */
+
 #ifdef GL_NV_depth_buffer_float
 
 static void _glewInfo_GL_NV_depth_buffer_float (void)
@@ -3522,6 +3932,15 @@ static void _glewInfo_GL_NV_parameter_buffer_object (void)
 
 #endif /* GL_NV_parameter_buffer_object */
 
+#ifdef GL_NV_parameter_buffer_object2
+
+static void _glewInfo_GL_NV_parameter_buffer_object2 (void)
+{
+  glewPrintExt("GL_NV_parameter_buffer_object2", GLEW_NV_parameter_buffer_object2, glewIsSupported("GL_NV_parameter_buffer_object2"), glewGetExtension("GL_NV_parameter_buffer_object2"));
+}
+
+#endif /* GL_NV_parameter_buffer_object2 */
+
 #ifdef GL_NV_pixel_data_range
 
 static void _glewInfo_GL_NV_pixel_data_range (void)
@@ -3558,7 +3977,6 @@ static void _glewInfo_GL_NV_present_video (void)
   glewInfoFunc("glGetVideouivNV", glGetVideouivNV == NULL);
   glewInfoFunc("glPresentFrameDualFillNV", glPresentFrameDualFillNV == NULL);
   glewInfoFunc("glPresentFrameKeyedNV", glPresentFrameKeyedNV == NULL);
-  glewInfoFunc("glVideoParameterivNV", glVideoParameterivNV == NULL);
 }
 
 #endif /* GL_NV_present_video */
@@ -3610,6 +4028,30 @@ static void _glewInfo_GL_NV_register_combiners2 (void)
 
 #endif /* GL_NV_register_combiners2 */
 
+#ifdef GL_NV_shader_buffer_load
+
+static void _glewInfo_GL_NV_shader_buffer_load (void)
+{
+  glewPrintExt("GL_NV_shader_buffer_load", GLEW_NV_shader_buffer_load, glewIsSupported("GL_NV_shader_buffer_load"), glewGetExtension("GL_NV_shader_buffer_load"));
+
+  glewInfoFunc("glGetBufferParameterui64vNV", glGetBufferParameterui64vNV == NULL);
+  glewInfoFunc("glGetIntegerui64vNV", glGetIntegerui64vNV == NULL);
+  glewInfoFunc("glGetNamedBufferParameterui64vNV", glGetNamedBufferParameterui64vNV == NULL);
+  glewInfoFunc("glGetUniformui64vNV", glGetUniformui64vNV == NULL);
+  glewInfoFunc("glIsBufferResidentNV", glIsBufferResidentNV == NULL);
+  glewInfoFunc("glIsNamedBufferResidentNV", glIsNamedBufferResidentNV == NULL);
+  glewInfoFunc("glMakeBufferNonResidentNV", glMakeBufferNonResidentNV == NULL);
+  glewInfoFunc("glMakeBufferResidentNV", glMakeBufferResidentNV == NULL);
+  glewInfoFunc("glMakeNamedBufferNonResidentNV", glMakeNamedBufferNonResidentNV == NULL);
+  glewInfoFunc("glMakeNamedBufferResidentNV", glMakeNamedBufferResidentNV == NULL);
+  glewInfoFunc("glProgramUniformui64NV", glProgramUniformui64NV == NULL);
+  glewInfoFunc("glProgramUniformui64vNV", glProgramUniformui64vNV == NULL);
+  glewInfoFunc("glUniformui64NV", glUniformui64NV == NULL);
+  glewInfoFunc("glUniformui64vNV", glUniformui64vNV == NULL);
+}
+
+#endif /* GL_NV_shader_buffer_load */
+
 #ifdef GL_NV_texgen_emboss
 
 static void _glewInfo_GL_NV_texgen_emboss (void)
@@ -3628,6 +4070,17 @@ static void _glewInfo_GL_NV_texgen_reflection (void)
 
 #endif /* GL_NV_texgen_reflection */
 
+#ifdef GL_NV_texture_barrier
+
+static void _glewInfo_GL_NV_texture_barrier (void)
+{
+  glewPrintExt("GL_NV_texture_barrier", GLEW_NV_texture_barrier, glewIsSupported("GL_NV_texture_barrier"), glewGetExtension("GL_NV_texture_barrier"));
+
+  glewInfoFunc("glTextureBarrierNV", glTextureBarrierNV == NULL);
+}
+
+#endif /* GL_NV_texture_barrier */
+
 #ifdef GL_NV_texture_compression_vtc
 
 static void _glewInfo_GL_NV_texture_compression_vtc (void)
@@ -3712,6 +4165,23 @@ static void _glewInfo_GL_NV_transform_feedback (void)
 
 #endif /* GL_NV_transform_feedback */
 
+#ifdef GL_NV_transform_feedback2
+
+static void _glewInfo_GL_NV_transform_feedback2 (void)
+{
+  glewPrintExt("GL_NV_transform_feedback2", GLEW_NV_transform_feedback2, glewIsSupported("GL_NV_transform_feedback2"), glewGetExtension("GL_NV_transform_feedback2"));
+
+  glewInfoFunc("glBindTransformFeedbackNV", glBindTransformFeedbackNV == NULL);
+  glewInfoFunc("glDeleteTransformFeedbacksNV", glDeleteTransformFeedbacksNV == NULL);
+  glewInfoFunc("glDrawTransformFeedbackNV", glDrawTransformFeedbackNV == NULL);
+  glewInfoFunc("glGenTransformFeedbacksNV", glGenTransformFeedbacksNV == NULL);
+  glewInfoFunc("glIsTransformFeedbackNV", glIsTransformFeedbackNV == NULL);
+  glewInfoFunc("glPauseTransformFeedbackNV", glPauseTransformFeedbackNV == NULL);
+  glewInfoFunc("glResumeTransformFeedbackNV", glResumeTransformFeedbackNV == NULL);
+}
+
+#endif /* GL_NV_transform_feedback2 */
+
 #ifdef GL_NV_vertex_array_range
 
 static void _glewInfo_GL_NV_vertex_array_range (void)
@@ -3733,6 +4203,28 @@ static void _glewInfo_GL_NV_vertex_array_range2 (void)
 
 #endif /* GL_NV_vertex_array_range2 */
 
+#ifdef GL_NV_vertex_buffer_unified_memory
+
+static void _glewInfo_GL_NV_vertex_buffer_unified_memory (void)
+{
+  glewPrintExt("GL_NV_vertex_buffer_unified_memory", GLEW_NV_vertex_buffer_unified_memory, glewIsSupported("GL_NV_vertex_buffer_unified_memory"), glewGetExtension("GL_NV_vertex_buffer_unified_memory"));
+
+  glewInfoFunc("glBufferAddressRangeNV", glBufferAddressRangeNV == NULL);
+  glewInfoFunc("glColorFormatNV", glColorFormatNV == NULL);
+  glewInfoFunc("glEdgeFlagFormatNV", glEdgeFlagFormatNV == NULL);
+  glewInfoFunc("glFogCoordFormatNV", glFogCoordFormatNV == NULL);
+  glewInfoFunc("glGetIntegerui64i_vNV", glGetIntegerui64i_vNV == NULL);
+  glewInfoFunc("glIndexFormatNV", glIndexFormatNV == NULL);
+  glewInfoFunc("glNormalFormatNV", glNormalFormatNV == NULL);
+  glewInfoFunc("glSecondaryColorFormatNV", glSecondaryColorFormatNV == NULL);
+  glewInfoFunc("glTexCoordFormatNV", glTexCoordFormatNV == NULL);
+  glewInfoFunc("glVertexAttribFormatNV", glVertexAttribFormatNV == NULL);
+  glewInfoFunc("glVertexAttribIFormatNV", glVertexAttribIFormatNV == NULL);
+  glewInfoFunc("glVertexFormatNV", glVertexFormatNV == NULL);
+}
+
+#endif /* GL_NV_vertex_buffer_unified_memory */
+
 #ifdef GL_NV_vertex_program
 
 static void _glewInfo_GL_NV_vertex_program (void)
@@ -4652,6 +5144,25 @@ static void _glewInfo_WGL_3DL_stereo_control (void)
 
 #endif /* WGL_3DL_stereo_control */
 
+#ifdef WGL_AMD_gpu_association
+
+static void _glewInfo_WGL_AMD_gpu_association (void)
+{
+  glewPrintExt("WGL_AMD_gpu_association", WGLEW_AMD_gpu_association, wglewIsSupported("WGL_AMD_gpu_association"), wglewGetExtension("WGL_AMD_gpu_association"));
+
+  glewInfoFunc("wglBlitContextFramebufferAMD", wglBlitContextFramebufferAMD == NULL);
+  glewInfoFunc("wglCreateAssociatedContextAMD", wglCreateAssociatedContextAMD == NULL);
+  glewInfoFunc("wglCreateAssociatedContextAttribsAMD", wglCreateAssociatedContextAttribsAMD == NULL);
+  glewInfoFunc("wglDeleteAssociatedContextAMD", wglDeleteAssociatedContextAMD == NULL);
+  glewInfoFunc("wglGetContextGPUIDAMD", wglGetContextGPUIDAMD == NULL);
+  glewInfoFunc("wglGetCurrentAssociatedContextAMD", wglGetCurrentAssociatedContextAMD == NULL);
+  glewInfoFunc("wglGetGPUIDsAMD", wglGetGPUIDsAMD == NULL);
+  glewInfoFunc("wglGetGPUInfoAMD", wglGetGPUInfoAMD == NULL);
+  glewInfoFunc("wglMakeAssociatedContextCurrentAMD", wglMakeAssociatedContextCurrentAMD == NULL);
+}
+
+#endif /* WGL_AMD_gpu_association */
+
 #ifdef WGL_ARB_buffer_region
 
 static void _glewInfo_WGL_ARB_buffer_region (void)
@@ -4677,6 +5188,15 @@ static void _glewInfo_WGL_ARB_create_context (void)
 
 #endif /* WGL_ARB_create_context */
 
+#ifdef WGL_ARB_create_context_profile
+
+static void _glewInfo_WGL_ARB_create_context_profile (void)
+{
+  glewPrintExt("WGL_ARB_create_context_profile", WGLEW_ARB_create_context_profile, wglewIsSupported("WGL_ARB_create_context_profile"), wglewGetExtension("WGL_ARB_create_context_profile"));
+}
+
+#endif /* WGL_ARB_create_context_profile */
+
 #ifdef WGL_ARB_extensions_string
 
 static void _glewInfo_WGL_ARB_extensions_string (void)
@@ -4989,6 +5509,17 @@ static void _glewInfo_WGL_I3D_swap_frame_usage (void)
 
 #endif /* WGL_I3D_swap_frame_usage */
 
+#ifdef WGL_NV_copy_image
+
+static void _glewInfo_WGL_NV_copy_image (void)
+{
+  glewPrintExt("WGL_NV_copy_image", WGLEW_NV_copy_image, wglewIsSupported("WGL_NV_copy_image"), wglewGetExtension("WGL_NV_copy_image"));
+
+  glewInfoFunc("wglCopyImageSubDataNV", wglCopyImageSubDataNV == NULL);
+}
+
+#endif /* WGL_NV_copy_image */
+
 #ifdef WGL_NV_float_buffer
 
 static void _glewInfo_WGL_NV_float_buffer (void)
@@ -5173,6 +5704,15 @@ static void _glewInfo_GLX_ARB_create_context (void)
 
 #endif /* GLX_ARB_create_context */
 
+#ifdef GLX_ARB_create_context_profile
+
+static void _glewInfo_GLX_ARB_create_context_profile (void)
+{
+  glewPrintExt("GLX_ARB_create_context_profile", GLXEW_ARB_create_context_profile, glxewIsSupported("GLX_ARB_create_context_profile"), glxewGetExtension("GLX_ARB_create_context_profile"));
+}
+
+#endif /* GLX_ARB_create_context_profile */
+
 #ifdef GLX_ARB_fbconfig_float
 
 static void _glewInfo_GLX_ARB_fbconfig_float (void)
@@ -5272,6 +5812,17 @@ static void _glewInfo_GLX_EXT_scene_marker (void)
 
 #endif /* GLX_EXT_scene_marker */
 
+#ifdef GLX_EXT_swap_control
+
+static void _glewInfo_GLX_EXT_swap_control (void)
+{
+  glewPrintExt("GLX_EXT_swap_control", GLXEW_EXT_swap_control, glxewIsSupported("GLX_EXT_swap_control"), glxewGetExtension("GLX_EXT_swap_control"));
+
+  glewInfoFunc("glXSwapIntervalEXT", glXSwapIntervalEXT == NULL);
+}
+
+#endif /* GLX_EXT_swap_control */
+
 #ifdef GLX_EXT_texture_from_pixmap
 
 static void _glewInfo_GLX_EXT_texture_from_pixmap (void)
@@ -5357,6 +5908,17 @@ static void _glewInfo_GLX_MESA_set_3dfx_mode (void)
 
 #endif /* GLX_MESA_set_3dfx_mode */
 
+#ifdef GLX_NV_copy_image
+
+static void _glewInfo_GLX_NV_copy_image (void)
+{
+  glewPrintExt("GLX_NV_copy_image", GLXEW_NV_copy_image, glxewIsSupported("GLX_NV_copy_image"), glxewGetExtension("GLX_NV_copy_image"));
+
+  glewInfoFunc("glXCopyImageSubDataNV", glXCopyImageSubDataNV == NULL);
+}
+
+#endif /* GLX_NV_copy_image */
+
 #ifdef GLX_NV_float_buffer
 
 static void _glewInfo_GLX_NV_float_buffer (void)
@@ -5678,6 +6240,12 @@ static void glewInfo (void)
 #ifdef GL_VERSION_3_0
   _glewInfo_GL_VERSION_3_0();
 #endif /* GL_VERSION_3_0 */
+#ifdef GL_VERSION_3_1
+  _glewInfo_GL_VERSION_3_1();
+#endif /* GL_VERSION_3_1 */
+#ifdef GL_VERSION_3_2
+  _glewInfo_GL_VERSION_3_2();
+#endif /* GL_VERSION_3_2 */
 #ifdef GL_3DFX_multisample
   _glewInfo_GL_3DFX_multisample();
 #endif /* GL_3DFX_multisample */
@@ -5687,6 +6255,21 @@ static void glewInfo (void)
 #ifdef GL_3DFX_texture_compression_FXT1
   _glewInfo_GL_3DFX_texture_compression_FXT1();
 #endif /* GL_3DFX_texture_compression_FXT1 */
+#ifdef GL_AMD_draw_buffers_blend
+  _glewInfo_GL_AMD_draw_buffers_blend();
+#endif /* GL_AMD_draw_buffers_blend */
+#ifdef GL_AMD_performance_monitor
+  _glewInfo_GL_AMD_performance_monitor();
+#endif /* GL_AMD_performance_monitor */
+#ifdef GL_AMD_texture_texture4
+  _glewInfo_GL_AMD_texture_texture4();
+#endif /* GL_AMD_texture_texture4 */
+#ifdef GL_AMD_vertex_shader_tessellator
+  _glewInfo_GL_AMD_vertex_shader_tessellator();
+#endif /* GL_AMD_vertex_shader_tessellator */
+#ifdef GL_APPLE_aux_depth_stencil
+  _glewInfo_GL_APPLE_aux_depth_stencil();
+#endif /* GL_APPLE_aux_depth_stencil */
 #ifdef GL_APPLE_client_storage
   _glewInfo_GL_APPLE_client_storage();
 #endif /* GL_APPLE_client_storage */
@@ -5702,9 +6285,18 @@ static void glewInfo (void)
 #ifdef GL_APPLE_flush_buffer_range
   _glewInfo_GL_APPLE_flush_buffer_range();
 #endif /* GL_APPLE_flush_buffer_range */
+#ifdef GL_APPLE_object_purgeable
+  _glewInfo_GL_APPLE_object_purgeable();
+#endif /* GL_APPLE_object_purgeable */
 #ifdef GL_APPLE_pixel_buffer
   _glewInfo_GL_APPLE_pixel_buffer();
 #endif /* GL_APPLE_pixel_buffer */
+#ifdef GL_APPLE_rgb_422
+  _glewInfo_GL_APPLE_rgb_422();
+#endif /* GL_APPLE_rgb_422 */
+#ifdef GL_APPLE_row_bytes
+  _glewInfo_GL_APPLE_row_bytes();
+#endif /* GL_APPLE_row_bytes */
 #ifdef GL_APPLE_specular_vector
   _glewInfo_GL_APPLE_specular_vector();
 #endif /* GL_APPLE_specular_vector */
@@ -5720,24 +6312,45 @@ static void glewInfo (void)
 #ifdef GL_APPLE_vertex_array_range
   _glewInfo_GL_APPLE_vertex_array_range();
 #endif /* GL_APPLE_vertex_array_range */
+#ifdef GL_APPLE_vertex_program_evaluators
+  _glewInfo_GL_APPLE_vertex_program_evaluators();
+#endif /* GL_APPLE_vertex_program_evaluators */
 #ifdef GL_APPLE_ycbcr_422
   _glewInfo_GL_APPLE_ycbcr_422();
 #endif /* GL_APPLE_ycbcr_422 */
 #ifdef GL_ARB_color_buffer_float
   _glewInfo_GL_ARB_color_buffer_float();
 #endif /* GL_ARB_color_buffer_float */
+#ifdef GL_ARB_compatibility
+  _glewInfo_GL_ARB_compatibility();
+#endif /* GL_ARB_compatibility */
+#ifdef GL_ARB_copy_buffer
+  _glewInfo_GL_ARB_copy_buffer();
+#endif /* GL_ARB_copy_buffer */
 #ifdef GL_ARB_depth_buffer_float
   _glewInfo_GL_ARB_depth_buffer_float();
 #endif /* GL_ARB_depth_buffer_float */
+#ifdef GL_ARB_depth_clamp
+  _glewInfo_GL_ARB_depth_clamp();
+#endif /* GL_ARB_depth_clamp */
 #ifdef GL_ARB_depth_texture
   _glewInfo_GL_ARB_depth_texture();
 #endif /* GL_ARB_depth_texture */
 #ifdef GL_ARB_draw_buffers
   _glewInfo_GL_ARB_draw_buffers();
 #endif /* GL_ARB_draw_buffers */
+#ifdef GL_ARB_draw_buffers_blend
+  _glewInfo_GL_ARB_draw_buffers_blend();
+#endif /* GL_ARB_draw_buffers_blend */
+#ifdef GL_ARB_draw_elements_base_vertex
+  _glewInfo_GL_ARB_draw_elements_base_vertex();
+#endif /* GL_ARB_draw_elements_base_vertex */
 #ifdef GL_ARB_draw_instanced
   _glewInfo_GL_ARB_draw_instanced();
 #endif /* GL_ARB_draw_instanced */
+#ifdef GL_ARB_fragment_coord_conventions
+  _glewInfo_GL_ARB_fragment_coord_conventions();
+#endif /* GL_ARB_fragment_coord_conventions */
 #ifdef GL_ARB_fragment_program
   _glewInfo_GL_ARB_fragment_program();
 #endif /* GL_ARB_fragment_program */
@@ -5792,9 +6405,21 @@ static void glewInfo (void)
 #ifdef GL_ARB_point_sprite
   _glewInfo_GL_ARB_point_sprite();
 #endif /* GL_ARB_point_sprite */
+#ifdef GL_ARB_provoking_vertex
+  _glewInfo_GL_ARB_provoking_vertex();
+#endif /* GL_ARB_provoking_vertex */
+#ifdef GL_ARB_sample_shading
+  _glewInfo_GL_ARB_sample_shading();
+#endif /* GL_ARB_sample_shading */
+#ifdef GL_ARB_seamless_cube_map
+  _glewInfo_GL_ARB_seamless_cube_map();
+#endif /* GL_ARB_seamless_cube_map */
 #ifdef GL_ARB_shader_objects
   _glewInfo_GL_ARB_shader_objects();
 #endif /* GL_ARB_shader_objects */
+#ifdef GL_ARB_shader_texture_lod
+  _glewInfo_GL_ARB_shader_texture_lod();
+#endif /* GL_ARB_shader_texture_lod */
 #ifdef GL_ARB_shading_language_100
   _glewInfo_GL_ARB_shading_language_100();
 #endif /* GL_ARB_shading_language_100 */
@@ -5804,6 +6429,9 @@ static void glewInfo (void)
 #ifdef GL_ARB_shadow_ambient
   _glewInfo_GL_ARB_shadow_ambient();
 #endif /* GL_ARB_shadow_ambient */
+#ifdef GL_ARB_sync
+  _glewInfo_GL_ARB_sync();
+#endif /* GL_ARB_sync */
 #ifdef GL_ARB_texture_border_clamp
   _glewInfo_GL_ARB_texture_border_clamp();
 #endif /* GL_ARB_texture_border_clamp */
@@ -5819,6 +6447,9 @@ static void glewInfo (void)
 #ifdef GL_ARB_texture_cube_map
   _glewInfo_GL_ARB_texture_cube_map();
 #endif /* GL_ARB_texture_cube_map */
+#ifdef GL_ARB_texture_cube_map_array
+  _glewInfo_GL_ARB_texture_cube_map_array();
+#endif /* GL_ARB_texture_cube_map_array */
 #ifdef GL_ARB_texture_env_add
   _glewInfo_GL_ARB_texture_env_add();
 #endif /* GL_ARB_texture_env_add */
@@ -5834,12 +6465,21 @@ static void glewInfo (void)
 #ifdef GL_ARB_texture_float
   _glewInfo_GL_ARB_texture_float();
 #endif /* GL_ARB_texture_float */
+#ifdef GL_ARB_texture_gather
+  _glewInfo_GL_ARB_texture_gather();
+#endif /* GL_ARB_texture_gather */
 #ifdef GL_ARB_texture_mirrored_repeat
   _glewInfo_GL_ARB_texture_mirrored_repeat();
 #endif /* GL_ARB_texture_mirrored_repeat */
+#ifdef GL_ARB_texture_multisample
+  _glewInfo_GL_ARB_texture_multisample();
+#endif /* GL_ARB_texture_multisample */
 #ifdef GL_ARB_texture_non_power_of_two
   _glewInfo_GL_ARB_texture_non_power_of_two();
 #endif /* GL_ARB_texture_non_power_of_two */
+#ifdef GL_ARB_texture_query_lod
+  _glewInfo_GL_ARB_texture_query_lod();
+#endif /* GL_ARB_texture_query_lod */
 #ifdef GL_ARB_texture_rectangle
   _glewInfo_GL_ARB_texture_rectangle();
 #endif /* GL_ARB_texture_rectangle */
@@ -5849,6 +6489,12 @@ static void glewInfo (void)
 #ifdef GL_ARB_transpose_matrix
   _glewInfo_GL_ARB_transpose_matrix();
 #endif /* GL_ARB_transpose_matrix */
+#ifdef GL_ARB_uniform_buffer_object
+  _glewInfo_GL_ARB_uniform_buffer_object();
+#endif /* GL_ARB_uniform_buffer_object */
+#ifdef GL_ARB_vertex_array_bgra
+  _glewInfo_GL_ARB_vertex_array_bgra();
+#endif /* GL_ARB_vertex_array_bgra */
 #ifdef GL_ARB_vertex_array_object
   _glewInfo_GL_ARB_vertex_array_object();
 #endif /* GL_ARB_vertex_array_object */
@@ -5894,6 +6540,9 @@ static void glewInfo (void)
 #ifdef GL_ATI_map_object_buffer
   _glewInfo_GL_ATI_map_object_buffer();
 #endif /* GL_ATI_map_object_buffer */
+#ifdef GL_ATI_meminfo
+  _glewInfo_GL_ATI_meminfo();
+#endif /* GL_ATI_meminfo */
 #ifdef GL_ATI_pn_triangles
   _glewInfo_GL_ATI_pn_triangles();
 #endif /* GL_ATI_pn_triangles */
@@ -6080,6 +6729,9 @@ static void glewInfo (void)
 #ifdef GL_EXT_polygon_offset
   _glewInfo_GL_EXT_polygon_offset();
 #endif /* GL_EXT_polygon_offset */
+#ifdef GL_EXT_provoking_vertex
+  _glewInfo_GL_EXT_provoking_vertex();
+#endif /* GL_EXT_provoking_vertex */
 #ifdef GL_EXT_rescale_normal
   _glewInfo_GL_EXT_rescale_normal();
 #endif /* GL_EXT_rescale_normal */
@@ -6089,6 +6741,9 @@ static void glewInfo (void)
 #ifdef GL_EXT_secondary_color
   _glewInfo_GL_EXT_secondary_color();
 #endif /* GL_EXT_secondary_color */
+#ifdef GL_EXT_separate_shader_objects
+  _glewInfo_GL_EXT_separate_shader_objects();
+#endif /* GL_EXT_separate_shader_objects */
 #ifdef GL_EXT_separate_specular_color
   _glewInfo_GL_EXT_separate_specular_color();
 #endif /* GL_EXT_separate_specular_color */
@@ -6179,6 +6834,9 @@ static void glewInfo (void)
 #ifdef GL_EXT_texture_shared_exponent
   _glewInfo_GL_EXT_texture_shared_exponent();
 #endif /* GL_EXT_texture_shared_exponent */
+#ifdef GL_EXT_texture_snorm
+  _glewInfo_GL_EXT_texture_snorm();
+#endif /* GL_EXT_texture_snorm */
 #ifdef GL_EXT_texture_swizzle
   _glewInfo_GL_EXT_texture_swizzle();
 #endif /* GL_EXT_texture_swizzle */
@@ -6275,6 +6933,9 @@ static void glewInfo (void)
 #ifdef GL_NV_copy_depth_to_color
   _glewInfo_GL_NV_copy_depth_to_color();
 #endif /* GL_NV_copy_depth_to_color */
+#ifdef GL_NV_copy_image
+  _glewInfo_GL_NV_copy_image();
+#endif /* GL_NV_copy_image */
 #ifdef GL_NV_depth_buffer_float
   _glewInfo_GL_NV_depth_buffer_float();
 #endif /* GL_NV_depth_buffer_float */
@@ -6341,6 +7002,9 @@ static void glewInfo (void)
 #ifdef GL_NV_parameter_buffer_object
   _glewInfo_GL_NV_parameter_buffer_object();
 #endif /* GL_NV_parameter_buffer_object */
+#ifdef GL_NV_parameter_buffer_object2
+  _glewInfo_GL_NV_parameter_buffer_object2();
+#endif /* GL_NV_parameter_buffer_object2 */
 #ifdef GL_NV_pixel_data_range
   _glewInfo_GL_NV_pixel_data_range();
 #endif /* GL_NV_pixel_data_range */
@@ -6359,12 +7023,18 @@ static void glewInfo (void)
 #ifdef GL_NV_register_combiners2
   _glewInfo_GL_NV_register_combiners2();
 #endif /* GL_NV_register_combiners2 */
+#ifdef GL_NV_shader_buffer_load
+  _glewInfo_GL_NV_shader_buffer_load();
+#endif /* GL_NV_shader_buffer_load */
 #ifdef GL_NV_texgen_emboss
   _glewInfo_GL_NV_texgen_emboss();
 #endif /* GL_NV_texgen_emboss */
 #ifdef GL_NV_texgen_reflection
   _glewInfo_GL_NV_texgen_reflection();
 #endif /* GL_NV_texgen_reflection */
+#ifdef GL_NV_texture_barrier
+  _glewInfo_GL_NV_texture_barrier();
+#endif /* GL_NV_texture_barrier */
 #ifdef GL_NV_texture_compression_vtc
   _glewInfo_GL_NV_texture_compression_vtc();
 #endif /* GL_NV_texture_compression_vtc */
@@ -6389,12 +7059,18 @@ static void glewInfo (void)
 #ifdef GL_NV_transform_feedback
   _glewInfo_GL_NV_transform_feedback();
 #endif /* GL_NV_transform_feedback */
+#ifdef GL_NV_transform_feedback2
+  _glewInfo_GL_NV_transform_feedback2();
+#endif /* GL_NV_transform_feedback2 */
 #ifdef GL_NV_vertex_array_range
   _glewInfo_GL_NV_vertex_array_range();
 #endif /* GL_NV_vertex_array_range */
 #ifdef GL_NV_vertex_array_range2
   _glewInfo_GL_NV_vertex_array_range2();
 #endif /* GL_NV_vertex_array_range2 */
+#ifdef GL_NV_vertex_buffer_unified_memory
+  _glewInfo_GL_NV_vertex_buffer_unified_memory();
+#endif /* GL_NV_vertex_buffer_unified_memory */
 #ifdef GL_NV_vertex_program
   _glewInfo_GL_NV_vertex_program();
 #endif /* GL_NV_vertex_program */
@@ -6640,12 +7316,18 @@ static void wglewInfo ()
 #ifdef WGL_3DL_stereo_control
   _glewInfo_WGL_3DL_stereo_control();
 #endif /* WGL_3DL_stereo_control */
+#ifdef WGL_AMD_gpu_association
+  _glewInfo_WGL_AMD_gpu_association();
+#endif /* WGL_AMD_gpu_association */
 #ifdef WGL_ARB_buffer_region
   _glewInfo_WGL_ARB_buffer_region();
 #endif /* WGL_ARB_buffer_region */
 #ifdef WGL_ARB_create_context
   _glewInfo_WGL_ARB_create_context();
 #endif /* WGL_ARB_create_context */
+#ifdef WGL_ARB_create_context_profile
+  _glewInfo_WGL_ARB_create_context_profile();
+#endif /* WGL_ARB_create_context_profile */
 #ifdef WGL_ARB_extensions_string
   _glewInfo_WGL_ARB_extensions_string();
 #endif /* WGL_ARB_extensions_string */
@@ -6724,6 +7406,9 @@ static void wglewInfo ()
 #ifdef WGL_I3D_swap_frame_usage
   _glewInfo_WGL_I3D_swap_frame_usage();
 #endif /* WGL_I3D_swap_frame_usage */
+#ifdef WGL_NV_copy_image
+  _glewInfo_WGL_NV_copy_image();
+#endif /* WGL_NV_copy_image */
 #ifdef WGL_NV_float_buffer
   _glewInfo_WGL_NV_float_buffer();
 #endif /* WGL_NV_float_buffer */
@@ -6772,6 +7457,9 @@ static void glxewInfo ()
 #ifdef GLX_ARB_create_context
   _glewInfo_GLX_ARB_create_context();
 #endif /* GLX_ARB_create_context */
+#ifdef GLX_ARB_create_context_profile
+  _glewInfo_GLX_ARB_create_context_profile();
+#endif /* GLX_ARB_create_context_profile */
 #ifdef GLX_ARB_fbconfig_float
   _glewInfo_GLX_ARB_fbconfig_float();
 #endif /* GLX_ARB_fbconfig_float */
@@ -6802,6 +7490,9 @@ static void glxewInfo ()
 #ifdef GLX_EXT_scene_marker
   _glewInfo_GLX_EXT_scene_marker();
 #endif /* GLX_EXT_scene_marker */
+#ifdef GLX_EXT_swap_control
+  _glewInfo_GLX_EXT_swap_control();
+#endif /* GLX_EXT_swap_control */
 #ifdef GLX_EXT_texture_from_pixmap
   _glewInfo_GLX_EXT_texture_from_pixmap();
 #endif /* GLX_EXT_texture_from_pixmap */
@@ -6826,6 +7517,9 @@ static void glxewInfo ()
 #ifdef GLX_MESA_set_3dfx_mode
   _glewInfo_GLX_MESA_set_3dfx_mode();
 #endif /* GLX_MESA_set_3dfx_mode */
+#ifdef GLX_NV_copy_image
+  _glewInfo_GLX_NV_copy_image();
+#endif /* GLX_NV_copy_image */
 #ifdef GLX_NV_float_buffer
   _glewInfo_GLX_NV_float_buffer();
 #endif /* GLX_NV_float_buffer */
@@ -7071,7 +7765,7 @@ GLboolean glewCreateContext (int* pixelformat)
 void glewDestroyContext ()
 {
   if (NULL != rc) wglMakeCurrent(NULL, NULL);
-  if (NULL != rc) wglDeleteContext(wglGetCurrentContext());
+  if (NULL != rc) wglDeleteContext(rc);
   if (NULL != wnd && NULL != dc) ReleaseDC(wnd, dc);
   if (NULL != wnd) DestroyWindow(wnd);
   UnregisterClass("GLEW", GetModuleHandle(NULL));
@@ -7100,7 +7794,7 @@ GLboolean glewCreateContext ()
   aglDestroyPixelFormat(pf);
   /*aglSetDrawable(ctx, GetWindowPort(wnd));*/
   octx = aglGetCurrentContext();
-  if (NULL == aglSetCurrentContext(ctx)) return GL_TRUE;
+  if (GL_FALSE == aglSetCurrentContext(ctx)) return GL_TRUE;
   return GL_FALSE;
 }
 
index 384313df220da81e2401c02347923423bba87915..f3ae91f2b4f1d6945b3cee5f6335e3775c2c1a43 100644 (file)
@@ -1056,7 +1056,7 @@ GLboolean CreateContext (GLContext* ctx)
   aglDestroyPixelFormat(pf);
   /*aglSetDrawable(ctx, GetWindowPort(wnd));*/
   ctx->octx = aglGetCurrentContext();
-  if (NULL == aglSetCurrentContext(ctx->ctx)) return GL_TRUE;
+  if (GL_FALSE == aglSetCurrentContext(ctx->ctx)) return GL_TRUE;
   return GL_FALSE;
 }
 
diff --git a/src/glsl/Makefile b/src/glsl/Makefile
new file mode 100644 (file)
index 0000000..ca7f2d2
--- /dev/null
@@ -0,0 +1,15 @@
+# src/glsl/Makefile
+
+TOP = ../..
+
+include $(TOP)/configs/current
+
+SUBDIRS = pp cl apps
+
+default install clean:
+       @for dir in $(SUBDIRS) ; do \
+               if [ -d $$dir ] ; then \
+                       (cd $$dir && $(MAKE) $@) || exit 1; \
+               fi \
+       done
+
diff --git a/src/glsl/Makefile.template b/src/glsl/Makefile.template
new file mode 100644 (file)
index 0000000..974987a
--- /dev/null
@@ -0,0 +1,50 @@
+# src/glsl/Makefile.template
+
+# Template makefile for glsl libraries.
+#
+# Usage:
+#   The minimum that the including makefile needs to define
+#   is TOP, LIBNAME and one of of the *_SOURCES.
+#
+# Optional defines:
+#   LIBRARY_INCLUDES are appended to the list of includes directories.
+#   LIBRARY_DEFINES is not used for makedepend, but for compilation.
+
+
+### Basic defines ###
+
+OBJECTS = $(C_SOURCES:.c=.o)
+
+INCLUDES = \
+       -I. \
+       $(LIBRARY_INCLUDES)
+
+
+##### TARGETS #####
+
+default: depend lib$(LIBNAME).a
+
+lib$(LIBNAME).a: $(OBJECTS) Makefile $(TOP)/src/glsl/Makefile.template
+       $(MKLIB) -o $(LIBNAME) -static $(OBJECTS)
+
+depend: $(C_SOURCES)
+       rm -f depend
+       touch depend
+       $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(C_SOURCES) 2> /dev/null
+
+# Remove .o and backup files
+clean:
+       rm -f $(OBJECTS) lib$(LIBNAME).a depend depend.bak
+
+# Dummy target
+install:
+       @echo -n ""
+
+
+##### RULES #####
+
+.c.o:
+       $(CC) -c $(INCLUDES) $(CFLAGS) $(LIBRARY_DEFINES) $< -o $@
+
+-include depend
+
diff --git a/src/glsl/SConscript b/src/glsl/SConscript
new file mode 100644 (file)
index 0000000..8e18626
--- /dev/null
@@ -0,0 +1,69 @@
+import common
+
+Import('*')
+
+env = env.Clone()
+
+sources = [
+    'pp/sl_pp_context.c',
+    'pp/sl_pp_define.c',
+    'pp/sl_pp_dict.c',
+    'pp/sl_pp_error.c',
+    'pp/sl_pp_expression.c',
+    'pp/sl_pp_extension.c',
+    'pp/sl_pp_if.c',
+    'pp/sl_pp_line.c',
+    'pp/sl_pp_macro.c',
+    'pp/sl_pp_pragma.c',
+    'pp/sl_pp_process.c',
+    'pp/sl_pp_purify.c',
+    'pp/sl_pp_token.c',
+    'pp/sl_pp_token_util.c',
+    'pp/sl_pp_version.c',
+    'cl/sl_cl_parse.c',
+]
+
+glsl = env.ConvenienceLibrary(
+    target = 'glsl',
+    source = sources,
+)
+
+Export('glsl')
+
+env = env.Clone()
+
+if env['platform'] == 'windows':
+    env.PrependUnique(LIBS = [
+        'user32',
+    ])
+
+env.Prepend(LIBS = [glsl])
+
+env.Program(
+    target = 'purify',
+    source = ['apps/purify.c'],
+)
+
+env.Program(
+    target = 'tokenise',
+    source = ['apps/tokenise.c'],
+)
+
+env.Program(
+    target = 'version',
+    source = ['apps/version.c'],
+)
+
+env.Program(
+    target = 'process',
+    source = ['apps/process.c'],
+)
+
+glsl_compile = env.Program(
+    target = 'compile',
+    source = ['apps/compile.c'],
+)
+
+if env['platform'] == common.default_platform:
+    # Only export the GLSL compiler when building for the host platform
+    Export('glsl_compile')
diff --git a/src/glsl/apps/.gitignore b/src/glsl/apps/.gitignore
new file mode 100644 (file)
index 0000000..7e011ce
--- /dev/null
@@ -0,0 +1,5 @@
+compile
+process
+purify
+tokenise
+version
diff --git a/src/glsl/apps/Makefile b/src/glsl/apps/Makefile
new file mode 100644 (file)
index 0000000..39a0df7
--- /dev/null
@@ -0,0 +1,43 @@
+# src/glsl/apps/Makefile
+
+TOP = ../../..
+
+include $(TOP)/configs/current
+
+LIBS = \
+       $(TOP)/src/glsl/pp/libglslpp.a \
+       $(TOP)/src/glsl/cl/libglslcl.a
+
+SOURCES = \
+       compile.c \
+       process.c \
+       purify.c \
+       tokenise.c \
+       version.c
+
+APPS = $(SOURCES:%.c=%)
+
+INCLUDES = -I.
+
+
+##### RULES #####
+
+.SUFFIXES:
+.SUFFIXES: .c
+
+.c:
+       $(APP_CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@
+
+.c.o:
+       $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+
+
+##### TARGETS #####
+
+default: $(APPS)
+
+install:
+
+clean:
+       -rm -f $(APPS)
+       -rm -f *.o
diff --git a/src/glsl/apps/compile.c b/src/glsl/apps/compile.c
new file mode 100644 (file)
index 0000000..c9a830b
--- /dev/null
@@ -0,0 +1,191 @@
+/**************************************************************************
+ * 
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include "../pp/sl_pp_public.h"
+#include "../cl/sl_cl_parse.h"
+
+
+static void
+usage(void)
+{
+   printf("Usage:\n");
+   printf("  compile fragment|vertex <source> <output>\n");
+}
+
+int
+main(int argc,
+     char *argv[])
+{
+   FILE *in;
+   long size;
+   char *inbuf;
+   struct sl_pp_purify_options options;
+   char errmsg[100] = "";
+   struct sl_pp_context *context;
+   unsigned int version;
+   FILE *out;
+   unsigned char *outbytes;
+   unsigned int cboutbytes;
+   unsigned int shader_type;
+
+   if (argc != 4) {
+      usage();
+      return 1;
+   }
+
+   if (!strcmp(argv[1], "fragment")) {
+      shader_type = 1;
+   } else if (!strcmp(argv[1], "vertex")) {
+      shader_type = 2;
+   } else {
+      usage();
+      return 1;
+   }
+
+   in = fopen(argv[2], "rb");
+   if (!in) {
+      printf("Could not open `%s' for read.\n", argv[2]);
+      usage();
+      return 1;
+   }
+
+   fseek(in, 0, SEEK_END);
+   size = ftell(in);
+   fseek(in, 0, SEEK_SET);
+
+   out = fopen(argv[3], "w");
+   if (!out) {
+      fclose(in);
+      printf("Could not open `%s' for write.\n", argv[3]);
+      usage();
+      return 1;
+   }
+
+   inbuf = malloc(size + 1);
+   if (!inbuf) {
+      fprintf(out, "$OOMERROR\n");
+
+      fclose(out);
+      fclose(in);
+      printf("Out of memory.\n");
+      return 0;
+   }
+
+   if (fread(inbuf, 1, size, in) != size) {
+      fprintf(out, "$READERROR\n");
+
+      free(inbuf);
+      fclose(out);
+      fclose(in);
+      printf("Could not read from `%s'.\n", argv[2]);
+      return 0;
+   }
+   inbuf[size] = '\0';
+
+   fclose(in);
+
+   memset(&options, 0, sizeof(options));
+
+   context = sl_pp_context_create(inbuf, &options);
+   if (!context) {
+      fprintf(out, "$CONTEXERROR\n");
+
+      free(inbuf);
+      fclose(out);
+      printf("Could not create parse context.\n");
+      return 0;
+   }
+
+   if (sl_pp_version(context, &version)) {
+      fprintf(out, "$ERROR: `%s'\n", sl_pp_context_error_message(context));
+
+      printf("Error: %s\n", sl_pp_context_error_message(context));
+      sl_pp_context_destroy(context);
+      free(inbuf);
+      fclose(out);
+      return 0;
+   }
+
+   if (sl_pp_context_add_extension(context, "ARB_draw_buffers", "GL_ARB_draw_buffers") ||
+       sl_pp_context_add_extension(context, "ARB_texture_rectangle", "GL_ARB_texture_rectangle")) {
+      fprintf(out, "$ERROR: `%s'\n", sl_pp_context_error_message(context));
+
+      printf("Error: %s\n", sl_pp_context_error_message(context));
+      sl_pp_context_destroy(context);
+      free(inbuf);
+      fclose(out);
+      return 0;
+   }
+
+   if (sl_cl_compile(context, shader_type, 1, &outbytes, &cboutbytes, errmsg, sizeof(errmsg)) == 0) {
+      unsigned int i;
+      unsigned int line = 0;
+
+      fprintf(out, "\n/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED FROM THE FOLLOWING FILE: */");
+      fprintf(out, "\n/* %s */", argv[2]);
+      fprintf(out, "\n\n");
+
+      for (i = 0; i < cboutbytes; i++) {
+         unsigned int a;
+
+         if (outbytes[i] < 10) {
+            a = 1;
+         } else if (outbytes[i] < 100) {
+            a = 2;
+         } else {
+            a = 3;
+         }
+         if (i < cboutbytes - 1) {
+            a++;
+         }
+         if (line + a >= 100) {
+            fprintf (out, "\n");
+            line = 0;
+         }
+         line += a;
+         fprintf (out, "%u", outbytes[i]);
+         if (i < cboutbytes - 1) {
+            fprintf (out, ",");
+         }
+      }
+      fprintf (out, "\n");
+      free(outbytes);
+   } else {
+      fprintf(out, "$SYNTAXERROR: `%s'\n", errmsg);
+
+      printf("Error: %s\n", errmsg);
+   }
+
+   sl_pp_context_destroy(context);
+   free(inbuf);
+   fclose(out);
+   return 0;
+}
diff --git a/src/glsl/apps/process.c b/src/glsl/apps/process.c
new file mode 100644 (file)
index 0000000..5698902
--- /dev/null
@@ -0,0 +1,381 @@
+/**************************************************************************
+ * 
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include "../pp/sl_pp_public.h"
+
+
+int
+main(int argc,
+     char *argv[])
+{
+   FILE *in;
+   long size;
+   char *inbuf;
+   struct sl_pp_purify_options options;
+   struct sl_pp_context *context;
+   unsigned int version;
+   struct sl_pp_token_info *outtokens;
+   FILE *out;
+   unsigned int i;
+
+   if (argc != 3) {
+      return 1;
+   }
+
+   in = fopen(argv[1], "rb");
+   if (!in) {
+      return 1;
+   }
+
+   fseek(in, 0, SEEK_END);
+   size = ftell(in);
+   fseek(in, 0, SEEK_SET);
+
+   out = fopen(argv[2], "wb");
+   if (!out) {
+      fclose(in);
+      return 1;
+   }
+
+   inbuf = malloc(size + 1);
+   if (!inbuf) {
+      fprintf(out, "$OOMERROR\n");
+
+      fclose(out);
+      fclose(in);
+      return 1;
+   }
+
+   if (fread(inbuf, 1, size, in) != size) {
+      fprintf(out, "$READERROR\n");
+
+      free(inbuf);
+      fclose(out);
+      fclose(in);
+      return 1;
+   }
+   inbuf[size] = '\0';
+
+   fclose(in);
+
+   memset(&options, 0, sizeof(options));
+
+   context = sl_pp_context_create(inbuf, &options);
+   if (!context) {
+      fprintf(out, "$CONTEXERROR\n");
+
+      free(inbuf);
+      fclose(out);
+      return 1;
+   }
+
+   if (sl_pp_version(context, &version)) {
+      fprintf(out, "$ERROR: `%s'\n", sl_pp_context_error_message(context));
+
+      sl_pp_context_destroy(context);
+      free(inbuf);
+      fclose(out);
+      return -1;
+   }
+
+   if (sl_pp_context_add_extension(context, "ARB_draw_buffers", "GL_ARB_draw_buffers") ||
+       sl_pp_context_add_extension(context, "ARB_texture_rectangle", "GL_ARB_texture_rectangle")) {
+      fprintf(out, "$ERROR: `%s'\n", sl_pp_context_error_message(context));
+
+      printf("Error: %s\n", sl_pp_context_error_message(context));
+      sl_pp_context_destroy(context);
+      free(inbuf);
+      fclose(out);
+      return 0;
+   }
+
+   if (sl_pp_context_add_predefined(context, "__GLSL_PP_PREDEFINED_MACRO_TEST", "1")) {
+      fprintf(out, "$ERROR: `%s'\n", sl_pp_context_error_message(context));
+
+      printf("Error: %s\n", sl_pp_context_error_message(context));
+      sl_pp_context_destroy(context);
+      free(inbuf);
+      fclose(out);
+      return 0;
+   }
+
+   if (sl_pp_process(context, &outtokens)) {
+      fprintf(out, "$ERROR: `%s'\n", sl_pp_context_error_message(context));
+
+      sl_pp_context_destroy(context);
+      free(inbuf);
+      fclose(out);
+      return -1;
+   }
+
+   free(inbuf);
+
+   for (i = 0; outtokens[i].token != SL_PP_EOF; i++) {
+      switch (outtokens[i].token) {
+      case SL_PP_NEWLINE:
+         fprintf(out, "\n");
+         break;
+
+      case SL_PP_COMMA:
+         fprintf(out, ", ");
+         break;
+
+      case SL_PP_SEMICOLON:
+         fprintf(out, "; ");
+         break;
+
+      case SL_PP_LBRACE:
+         fprintf(out, "{ ");
+         break;
+
+      case SL_PP_RBRACE:
+         fprintf(out, "} ");
+         break;
+
+      case SL_PP_LPAREN:
+         fprintf(out, "( ");
+         break;
+
+      case SL_PP_RPAREN:
+         fprintf(out, ") ");
+         break;
+
+      case SL_PP_LBRACKET:
+         fprintf(out, "[ ");
+         break;
+
+      case SL_PP_RBRACKET:
+         fprintf(out, "] ");
+         break;
+
+      case SL_PP_DOT:
+         fprintf(out, ". ");
+         break;
+
+      case SL_PP_INCREMENT:
+         fprintf(out, "++ ");
+         break;
+
+      case SL_PP_ADDASSIGN:
+         fprintf(out, "+= ");
+         break;
+
+      case SL_PP_PLUS:
+         fprintf(out, "+ ");
+         break;
+
+      case SL_PP_DECREMENT:
+         fprintf(out, "-- ");
+         break;
+
+      case SL_PP_SUBASSIGN:
+         fprintf(out, "-= ");
+         break;
+
+      case SL_PP_MINUS:
+         fprintf(out, "- ");
+         break;
+
+      case SL_PP_BITNOT:
+         fprintf(out, "~ ");
+         break;
+
+      case SL_PP_NOTEQUAL:
+         fprintf(out, "!= ");
+         break;
+
+      case SL_PP_NOT:
+         fprintf(out, "! ");
+         break;
+
+      case SL_PP_MULASSIGN:
+         fprintf(out, "*= ");
+         break;
+
+      case SL_PP_STAR:
+         fprintf(out, "* ");
+         break;
+
+      case SL_PP_DIVASSIGN:
+         fprintf(out, "/= ");
+         break;
+
+      case SL_PP_SLASH:
+         fprintf(out, "/ ");
+         break;
+
+      case SL_PP_MODASSIGN:
+         fprintf(out, "%%= ");
+         break;
+
+      case SL_PP_MODULO:
+         fprintf(out, "%% ");
+         break;
+
+      case SL_PP_LSHIFTASSIGN:
+         fprintf(out, "<<= ");
+         break;
+
+      case SL_PP_LSHIFT:
+         fprintf(out, "<< ");
+         break;
+
+      case SL_PP_LESSEQUAL:
+         fprintf(out, "<= ");
+         break;
+
+      case SL_PP_LESS:
+         fprintf(out, "< ");
+         break;
+
+      case SL_PP_RSHIFTASSIGN:
+         fprintf(out, ">>= ");
+         break;
+
+      case SL_PP_RSHIFT:
+         fprintf(out, ">> ");
+         break;
+
+      case SL_PP_GREATEREQUAL:
+         fprintf(out, ">= ");
+         break;
+
+      case SL_PP_GREATER:
+         fprintf(out, "> ");
+         break;
+
+      case SL_PP_EQUAL:
+         fprintf(out, "== ");
+         break;
+
+      case SL_PP_ASSIGN:
+         fprintf(out, "= ");
+         break;
+
+      case SL_PP_AND:
+         fprintf(out, "&& ");
+         break;
+
+      case SL_PP_BITANDASSIGN:
+         fprintf(out, "&= ");
+         break;
+
+      case SL_PP_BITAND:
+         fprintf(out, "& ");
+         break;
+
+      case SL_PP_XOR:
+         fprintf(out, "^^ ");
+         break;
+
+      case SL_PP_BITXORASSIGN:
+         fprintf(out, "^= ");
+         break;
+
+      case SL_PP_BITXOR:
+         fprintf(out, "^ ");
+         break;
+
+      case SL_PP_OR:
+         fprintf(out, "|| ");
+         break;
+
+      case SL_PP_BITORASSIGN:
+         fprintf(out, "|= ");
+         break;
+
+      case SL_PP_BITOR:
+         fprintf(out, "| ");
+         break;
+
+      case SL_PP_QUESTION:
+         fprintf(out, "? ");
+         break;
+
+      case SL_PP_COLON:
+         fprintf(out, ": ");
+         break;
+
+      case SL_PP_IDENTIFIER:
+         fprintf(out, "%s ", sl_pp_context_cstr(context, outtokens[i].data.identifier));
+         break;
+
+      case SL_PP_UINT:
+         fprintf(out, "%s ", sl_pp_context_cstr(context, outtokens[i].data._uint));
+         break;
+
+      case SL_PP_FLOAT:
+         fprintf(out, "%s ", sl_pp_context_cstr(context, outtokens[i].data._float));
+         break;
+
+      case SL_PP_OTHER:
+         fprintf(out, "%c", outtokens[i].data.other);
+         break;
+
+      case SL_PP_PRAGMA_OPTIMIZE:
+         fprintf(out, "#pragma optimize(%s)", outtokens[i].data.pragma ? "on" : "off");
+         break;
+
+      case SL_PP_PRAGMA_DEBUG:
+         fprintf(out, "#pragma debug(%s)", outtokens[i].data.pragma ? "on" : "off");
+         break;
+
+      case SL_PP_EXTENSION_REQUIRE:
+         fprintf(out, "#extension %s : require", sl_pp_context_cstr(context, outtokens[i].data.extension));
+         break;
+
+      case SL_PP_EXTENSION_ENABLE:
+         fprintf(out, "#extension %s : enable", sl_pp_context_cstr(context, outtokens[i].data.extension));
+         break;
+
+      case SL_PP_EXTENSION_WARN:
+         fprintf(out, "#extension %s : warn", sl_pp_context_cstr(context, outtokens[i].data.extension));
+         break;
+
+      case SL_PP_EXTENSION_DISABLE:
+         fprintf(out, "#extension %s : disable", sl_pp_context_cstr(context, outtokens[i].data.extension));
+         break;
+
+      case SL_PP_LINE:
+         fprintf(out, "#line %u %u", outtokens[i].data.line.lineno, outtokens[i].data.line.fileno);
+         break;
+
+      default:
+         assert(0);
+      }
+   }
+
+   sl_pp_context_destroy(context);
+   free(outtokens);
+   fclose(out);
+
+   return 0;
+}
diff --git a/src/glsl/apps/purify.c b/src/glsl/apps/purify.c
new file mode 100644 (file)
index 0000000..8c01f4f
--- /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 the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 
+ **************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "../pp/sl_pp_public.h"
+
+
+int
+main(int argc,
+     char *argv[])
+{
+   FILE *in;
+   long size;
+   char *inbuf;
+   struct sl_pp_purify_options options;
+   char *outbuf;
+   char errmsg[100] = "";
+   unsigned int errline = 0;
+   FILE *out;
+
+   if (argc != 3) {
+      return 1;
+   }
+
+   in = fopen(argv[1], "rb");
+   if (!in) {
+      return 1;
+   }
+
+   fseek(in, 0, SEEK_END);
+   size = ftell(in);
+   fseek(in, 0, SEEK_SET);
+
+   out = fopen(argv[2], "wb");
+   if (!out) {
+      fclose(in);
+      return 1;
+   }
+
+   inbuf = malloc(size + 1);
+   if (!inbuf) {
+      fprintf(out, "$OOMERROR\n");
+
+      fclose(out);
+      fclose(in);
+      return 1;
+   }
+
+   if (fread(inbuf, 1, size, in) != size) {
+      fprintf(out, "$READERROR\n");
+
+      free(inbuf);
+      fclose(out);
+      fclose(in);
+      return 1;
+   }
+   inbuf[size] = '\0';
+
+   fclose(in);
+
+   memset(&options, 0, sizeof(options));
+
+   if (sl_pp_purify(inbuf, &options, &outbuf, errmsg, sizeof(errmsg), &errline)) {
+      fprintf(out, "$PURIFYERROR %u: %s\n", errline, errmsg);
+
+      free(inbuf);
+      fclose(out);
+      return 1;
+   }
+
+   free(inbuf);
+
+   fwrite(outbuf, 1, strlen(outbuf), out);
+
+   free(outbuf);
+   fclose(out);
+
+   return 0;
+}
diff --git a/src/glsl/apps/tokenise.c b/src/glsl/apps/tokenise.c
new file mode 100644 (file)
index 0000000..9ff7315
--- /dev/null
@@ -0,0 +1,333 @@
+/**************************************************************************
+ * 
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include "../pp/sl_pp_public.h"
+
+
+int
+main(int argc,
+     char *argv[])
+{
+   FILE *in;
+   long size;
+   char *inbuf;
+   struct sl_pp_purify_options options;
+   struct sl_pp_context *context;
+   struct sl_pp_token_info *tokens;
+   FILE *out;
+   unsigned int i;
+
+   if (argc != 3) {
+      return 1;
+   }
+
+   in = fopen(argv[1], "rb");
+   if (!in) {
+      return 1;
+   }
+
+   fseek(in, 0, SEEK_END);
+   size = ftell(in);
+   fseek(in, 0, SEEK_SET);
+
+   out = fopen(argv[2], "wb");
+   if (!out) {
+      fclose(in);
+      return 1;
+   }
+
+   inbuf = malloc(size + 1);
+   if (!inbuf) {
+      fprintf(out, "$OOMERROR\n");
+
+      fclose(out);
+      fclose(in);
+      return 1;
+   }
+
+   if (fread(inbuf, 1, size, in) != size) {
+      fprintf(out, "$READERROR\n");
+
+      free(inbuf);
+      fclose(out);
+      fclose(in);
+      return 1;
+   }
+   inbuf[size] = '\0';
+
+   fclose(in);
+
+   memset(&options, 0, sizeof(options));
+
+   context = sl_pp_context_create(inbuf, &options);
+   if (!context) {
+      fprintf(out, "$CONTEXERROR\n");
+
+      free(inbuf);
+      fclose(out);
+      return 1;
+   }
+
+   if (sl_pp_tokenise(context, &tokens)) {
+      fprintf(out, "$ERROR: `%s'\n", sl_pp_context_error_message(context));
+
+      sl_pp_context_destroy(context);
+      free(inbuf);
+      fclose(out);
+      return 1;
+   }
+
+   free(inbuf);
+
+   for (i = 0; tokens[i].token != SL_PP_EOF; i++) {
+      switch (tokens[i].token) {
+      case SL_PP_WHITESPACE:
+         break;
+
+      case SL_PP_NEWLINE:
+         fprintf(out, "\n");
+         break;
+
+      case SL_PP_HASH:
+         fprintf(out, "# ");
+         break;
+
+      case SL_PP_COMMA:
+         fprintf(out, ", ");
+         break;
+
+      case SL_PP_SEMICOLON:
+         fprintf(out, "; ");
+         break;
+
+      case SL_PP_LBRACE:
+         fprintf(out, "{ ");
+         break;
+
+      case SL_PP_RBRACE:
+         fprintf(out, "} ");
+         break;
+
+      case SL_PP_LPAREN:
+         fprintf(out, "( ");
+         break;
+
+      case SL_PP_RPAREN:
+         fprintf(out, ") ");
+         break;
+
+      case SL_PP_LBRACKET:
+         fprintf(out, "[ ");
+         break;
+
+      case SL_PP_RBRACKET:
+         fprintf(out, "] ");
+         break;
+
+      case SL_PP_DOT:
+         fprintf(out, ". ");
+         break;
+
+      case SL_PP_INCREMENT:
+         fprintf(out, "++ ");
+         break;
+
+      case SL_PP_ADDASSIGN:
+         fprintf(out, "+= ");
+         break;
+
+      case SL_PP_PLUS:
+         fprintf(out, "+ ");
+         break;
+
+      case SL_PP_DECREMENT:
+         fprintf(out, "-- ");
+         break;
+
+      case SL_PP_SUBASSIGN:
+         fprintf(out, "-= ");
+         break;
+
+      case SL_PP_MINUS:
+         fprintf(out, "- ");
+         break;
+
+      case SL_PP_BITNOT:
+         fprintf(out, "~ ");
+         break;
+
+      case SL_PP_NOTEQUAL:
+         fprintf(out, "!= ");
+         break;
+
+      case SL_PP_NOT:
+         fprintf(out, "! ");
+         break;
+
+      case SL_PP_MULASSIGN:
+         fprintf(out, "*= ");
+         break;
+
+      case SL_PP_STAR:
+         fprintf(out, "* ");
+         break;
+
+      case SL_PP_DIVASSIGN:
+         fprintf(out, "/= ");
+         break;
+
+      case SL_PP_SLASH:
+         fprintf(out, "/ ");
+         break;
+
+      case SL_PP_MODASSIGN:
+         fprintf(out, "%%= ");
+         break;
+
+      case SL_PP_MODULO:
+         fprintf(out, "%% ");
+         break;
+
+      case SL_PP_LSHIFTASSIGN:
+         fprintf(out, "<<= ");
+         break;
+
+      case SL_PP_LSHIFT:
+         fprintf(out, "<< ");
+         break;
+
+      case SL_PP_LESSEQUAL:
+         fprintf(out, "<= ");
+         break;
+
+      case SL_PP_LESS:
+         fprintf(out, "< ");
+         break;
+
+      case SL_PP_RSHIFTASSIGN:
+         fprintf(out, ">>= ");
+         break;
+
+      case SL_PP_RSHIFT:
+         fprintf(out, ">> ");
+         break;
+
+      case SL_PP_GREATEREQUAL:
+         fprintf(out, ">= ");
+         break;
+
+      case SL_PP_GREATER:
+         fprintf(out, "> ");
+         break;
+
+      case SL_PP_EQUAL:
+         fprintf(out, "== ");
+         break;
+
+      case SL_PP_ASSIGN:
+         fprintf(out, "= ");
+         break;
+
+      case SL_PP_AND:
+         fprintf(out, "&& ");
+         break;
+
+      case SL_PP_BITANDASSIGN:
+         fprintf(out, "&= ");
+         break;
+
+      case SL_PP_BITAND:
+         fprintf(out, "& ");
+         break;
+
+      case SL_PP_XOR:
+         fprintf(out, "^^ ");
+         break;
+
+      case SL_PP_BITXORASSIGN:
+         fprintf(out, "^= ");
+         break;
+
+      case SL_PP_BITXOR:
+         fprintf(out, "^ ");
+         break;
+
+      case SL_PP_OR:
+         fprintf(out, "|| ");
+         break;
+
+      case SL_PP_BITORASSIGN:
+         fprintf(out, "|= ");
+         break;
+
+      case SL_PP_BITOR:
+         fprintf(out, "| ");
+         break;
+
+      case SL_PP_QUESTION:
+         fprintf(out, "? ");
+         break;
+
+      case SL_PP_COLON:
+         fprintf(out, ": ");
+         break;
+
+      case SL_PP_IDENTIFIER:
+         fprintf(out, "%s ", sl_pp_context_cstr(context, tokens[i].data.identifier));
+         break;
+
+      case SL_PP_UINT:
+         fprintf(out, "(%s) ", sl_pp_context_cstr(context, tokens[i].data._uint));
+         break;
+
+      case SL_PP_FLOAT:
+         fprintf(out, "(%s) ", sl_pp_context_cstr(context, tokens[i].data._float));
+         break;
+
+      case SL_PP_OTHER:
+         if (tokens[i].data.other == '\'') {
+            fprintf(out, "'\\'' ");
+         } else {
+            fprintf(out, "'%c' ", tokens[i].data.other);
+         }
+         break;
+
+      default:
+         assert(0);
+      }
+   }
+
+   sl_pp_context_destroy(context);
+   free(tokens);
+   fclose(out);
+
+   return 0;
+}
diff --git a/src/glsl/apps/version.c b/src/glsl/apps/version.c
new file mode 100644 (file)
index 0000000..40a4a06
--- /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 the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 
+ **************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include "../pp/sl_pp_public.h"
+
+
+int
+main(int argc,
+     char *argv[])
+{
+   FILE *in;
+   long size;
+   char *inbuf;
+   struct sl_pp_purify_options options;
+   struct sl_pp_context *context;
+   unsigned int version;
+   FILE *out;
+
+   if (argc != 3) {
+      return 1;
+   }
+
+   in = fopen(argv[1], "rb");
+   if (!in) {
+      return 1;
+   }
+
+   fseek(in, 0, SEEK_END);
+   size = ftell(in);
+   fseek(in, 0, SEEK_SET);
+
+   out = fopen(argv[2], "wb");
+   if (!out) {
+      fclose(in);
+      return 1;
+   }
+
+   inbuf = malloc(size + 1);
+   if (!inbuf) {
+      fprintf(out, "$OOMERROR\n");
+
+      fclose(out);
+      fclose(in);
+      return 1;
+   }
+
+   if (fread(inbuf, 1, size, in) != size) {
+      fprintf(out, "$READERROR\n");
+
+      free(inbuf);
+      fclose(out);
+      fclose(in);
+      return 1;
+   }
+   inbuf[size] = '\0';
+
+   fclose(in);
+
+   memset(&options, 0, sizeof(options));
+
+   context = sl_pp_context_create(inbuf, &options);
+   if (!context) {
+      fprintf(out, "$CONTEXERROR\n");
+
+      free(inbuf);
+      fclose(out);
+      return 1;
+   }
+
+   if (sl_pp_version(context, &version)) {
+      fprintf(out, "$ERROR: `%s'\n", sl_pp_context_error_message(context));
+
+      sl_pp_context_destroy(context);
+      free(inbuf);
+      fclose(out);
+      return -1;
+   }
+
+   sl_pp_context_destroy(context);
+   free(inbuf);
+
+   fprintf(out, "%u\n", version);
+
+   fclose(out);
+
+   return 0;
+}
diff --git a/src/glsl/cl/Makefile b/src/glsl/cl/Makefile
new file mode 100644 (file)
index 0000000..04a52df
--- /dev/null
@@ -0,0 +1,13 @@
+#src/glsl/cl/Makefile
+
+TOP = ../../..
+
+include $(TOP)/configs/current
+
+LIBNAME = glslcl
+
+C_SOURCES = \
+       sl_cl_parse.c
+
+include ../Makefile.template
+
diff --git a/src/glsl/cl/sl_cl_parse.c b/src/glsl/cl/sl_cl_parse.c
new file mode 100644 (file)
index 0000000..e9b3707
--- /dev/null
@@ -0,0 +1,2825 @@
+/**************************************************************************
+ * 
+ * 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 <assert.h>
+#include <stdlib.h>
+#include <string.h>
+#include "../pp/sl_pp_public.h"
+#include "sl_cl_parse.h"
+
+
+/* revision number - increment after each change affecting emitted output */
+#define REVISION                                   5
+
+/* external declaration (or precision or invariant stmt) */
+#define EXTERNAL_NULL                              0
+#define EXTERNAL_FUNCTION_DEFINITION               1
+#define EXTERNAL_DECLARATION                       2
+#define DEFAULT_PRECISION                          3
+#define INVARIANT_STMT                             4
+
+/* precision */
+#define PRECISION_DEFAULT                          0
+#define PRECISION_LOW                              1
+#define PRECISION_MEDIUM                           2
+#define PRECISION_HIGH                             3
+
+/* declaration */
+#define DECLARATION_FUNCTION_PROTOTYPE             1
+#define DECLARATION_INIT_DECLARATOR_LIST           2
+
+/* function type */
+#define FUNCTION_ORDINARY                          0
+#define FUNCTION_CONSTRUCTOR                       1
+#define FUNCTION_OPERATOR                          2
+
+/* function call type */
+#define FUNCTION_CALL_NONARRAY                     0
+#define FUNCTION_CALL_ARRAY                        1
+
+/* operator type */
+#define OPERATOR_ADDASSIGN                         1
+#define OPERATOR_SUBASSIGN                         2
+#define OPERATOR_MULASSIGN                         3
+#define OPERATOR_DIVASSIGN                         4
+/*#define OPERATOR_MODASSIGN                         5*/
+/*#define OPERATOR_LSHASSIGN                         6*/
+/*#define OPERATOR_RSHASSIGN                         7*/
+/*#define OPERATOR_ORASSIGN                          8*/
+/*#define OPERATOR_XORASSIGN                         9*/
+/*#define OPERATOR_ANDASSIGN                         10*/
+#define OPERATOR_LOGICALXOR                        11
+/*#define OPERATOR_BITOR                             12*/
+/*#define OPERATOR_BITXOR                            13*/
+/*#define OPERATOR_BITAND                            14*/
+#define OPERATOR_LESS                              15
+#define OPERATOR_GREATER                           16
+#define OPERATOR_LESSEQUAL                         17
+#define OPERATOR_GREATEREQUAL                      18
+/*#define OPERATOR_LSHIFT                            19*/
+/*#define OPERATOR_RSHIFT                            20*/
+#define OPERATOR_MULTIPLY                          21
+#define OPERATOR_DIVIDE                            22
+/*#define OPERATOR_MODULUS                           23*/
+#define OPERATOR_INCREMENT                         24
+#define OPERATOR_DECREMENT                         25
+#define OPERATOR_PLUS                              26
+#define OPERATOR_MINUS                             27
+/*#define OPERATOR_COMPLEMENT                        28*/
+#define OPERATOR_NOT                               29
+
+/* init declarator list */
+#define DECLARATOR_NONE                            0
+#define DECLARATOR_NEXT                            1
+
+/* variable declaration */
+#define VARIABLE_NONE                              0
+#define VARIABLE_IDENTIFIER                        1
+#define VARIABLE_INITIALIZER                       2
+#define VARIABLE_ARRAY_EXPLICIT                    3
+#define VARIABLE_ARRAY_UNKNOWN                     4
+
+/* type qualifier */
+#define TYPE_QUALIFIER_NONE                        0
+#define TYPE_QUALIFIER_CONST                       1
+#define TYPE_QUALIFIER_ATTRIBUTE                   2
+#define TYPE_QUALIFIER_VARYING                     3
+#define TYPE_QUALIFIER_UNIFORM                     4
+#define TYPE_QUALIFIER_FIXEDOUTPUT                 5
+#define TYPE_QUALIFIER_FIXEDINPUT                  6
+
+/* invariant qualifier */
+#define TYPE_VARIANT                               90
+#define TYPE_INVARIANT                             91
+
+/* centroid qualifier */
+#define TYPE_CENTER                                95
+#define TYPE_CENTROID                              96
+
+/* type specifier */
+#define TYPE_SPECIFIER_VOID                        0
+#define TYPE_SPECIFIER_BOOL                        1
+#define TYPE_SPECIFIER_BVEC2                       2
+#define TYPE_SPECIFIER_BVEC3                       3
+#define TYPE_SPECIFIER_BVEC4                       4
+#define TYPE_SPECIFIER_INT                         5
+#define TYPE_SPECIFIER_IVEC2                       6
+#define TYPE_SPECIFIER_IVEC3                       7
+#define TYPE_SPECIFIER_IVEC4                       8
+#define TYPE_SPECIFIER_FLOAT                       9
+#define TYPE_SPECIFIER_VEC2                        10
+#define TYPE_SPECIFIER_VEC3                        11
+#define TYPE_SPECIFIER_VEC4                        12
+#define TYPE_SPECIFIER_MAT2                        13
+#define TYPE_SPECIFIER_MAT3                        14
+#define TYPE_SPECIFIER_MAT4                        15
+#define TYPE_SPECIFIER_SAMPLER1D                   16
+#define TYPE_SPECIFIER_SAMPLER2D                   17
+#define TYPE_SPECIFIER_SAMPLER3D                   18
+#define TYPE_SPECIFIER_SAMPLERCUBE                 19
+#define TYPE_SPECIFIER_SAMPLER1DSHADOW             20
+#define TYPE_SPECIFIER_SAMPLER2DSHADOW             21
+#define TYPE_SPECIFIER_SAMPLER2DRECT               22
+#define TYPE_SPECIFIER_SAMPLER2DRECTSHADOW         23
+#define TYPE_SPECIFIER_STRUCT                      24
+#define TYPE_SPECIFIER_TYPENAME                    25
+
+/* OpenGL 2.1 */
+#define TYPE_SPECIFIER_MAT23                       26
+#define TYPE_SPECIFIER_MAT32                       27
+#define TYPE_SPECIFIER_MAT24                       28
+#define TYPE_SPECIFIER_MAT42                       29
+#define TYPE_SPECIFIER_MAT34                       30
+#define TYPE_SPECIFIER_MAT43                       31
+
+/* type specifier array */
+#define TYPE_SPECIFIER_NONARRAY                    0
+#define TYPE_SPECIFIER_ARRAY                       1
+
+/* structure field */
+#define FIELD_NONE                                 0
+#define FIELD_NEXT                                 1
+#define FIELD_ARRAY                                2
+
+/* operation */
+#define OP_END                                     0
+#define OP_BLOCK_BEGIN_NO_NEW_SCOPE                1
+#define OP_BLOCK_BEGIN_NEW_SCOPE                   2
+#define OP_DECLARE                                 3
+#define OP_ASM                                     4
+#define OP_BREAK                                   5
+#define OP_CONTINUE                                6
+#define OP_DISCARD                                 7
+#define OP_RETURN                                  8
+#define OP_EXPRESSION                              9
+#define OP_IF                                      10
+#define OP_WHILE                                   11
+#define OP_DO                                      12
+#define OP_FOR                                     13
+#define OP_PUSH_VOID                               14
+#define OP_PUSH_BOOL                               15
+#define OP_PUSH_INT                                16
+#define OP_PUSH_FLOAT                              17
+#define OP_PUSH_IDENTIFIER                         18
+#define OP_SEQUENCE                                19
+#define OP_ASSIGN                                  20
+#define OP_ADDASSIGN                               21
+#define OP_SUBASSIGN                               22
+#define OP_MULASSIGN                               23
+#define OP_DIVASSIGN                               24
+/*#define OP_MODASSIGN                               25*/
+/*#define OP_LSHASSIGN                               26*/
+/*#define OP_RSHASSIGN                               27*/
+/*#define OP_ORASSIGN                                28*/
+/*#define OP_XORASSIGN                               29*/
+/*#define OP_ANDASSIGN                               30*/
+#define OP_SELECT                                  31
+#define OP_LOGICALOR                               32
+#define OP_LOGICALXOR                              33
+#define OP_LOGICALAND                              34
+/*#define OP_BITOR                                   35*/
+/*#define OP_BITXOR                                  36*/
+/*#define OP_BITAND                                  37*/
+#define OP_EQUAL                                   38
+#define OP_NOTEQUAL                                39
+#define OP_LESS                                    40
+#define OP_GREATER                                 41
+#define OP_LESSEQUAL                               42
+#define OP_GREATEREQUAL                            43
+/*#define OP_LSHIFT                                  44*/
+/*#define OP_RSHIFT                                  45*/
+#define OP_ADD                                     46
+#define OP_SUBTRACT                                47
+#define OP_MULTIPLY                                48
+#define OP_DIVIDE                                  49
+/*#define OP_MODULUS                                 50*/
+#define OP_PREINCREMENT                            51
+#define OP_PREDECREMENT                            52
+#define OP_PLUS                                    53
+#define OP_MINUS                                   54
+/*#define OP_COMPLEMENT                              55*/
+#define OP_NOT                                     56
+#define OP_SUBSCRIPT                               57
+#define OP_CALL                                    58
+#define OP_FIELD                                   59
+#define OP_POSTINCREMENT                           60
+#define OP_POSTDECREMENT                           61
+#define OP_PRECISION                               62
+#define OP_METHOD                                  63
+
+/* parameter qualifier */
+#define PARAM_QUALIFIER_IN                         0
+#define PARAM_QUALIFIER_OUT                        1
+#define PARAM_QUALIFIER_INOUT                      2
+
+/* function parameter */
+#define PARAMETER_NONE                             0
+#define PARAMETER_NEXT                             1
+
+/* function parameter array presence */
+#define PARAMETER_ARRAY_NOT_PRESENT                0
+#define PARAMETER_ARRAY_PRESENT                    1
+
+
+struct parse_dict {
+   int _void;
+   int _float;
+   int _int;
+   int _bool;
+   int vec2;
+   int vec3;
+   int vec4;
+   int bvec2;
+   int bvec3;
+   int bvec4;
+   int ivec2;
+   int ivec3;
+   int ivec4;
+   int mat2;
+   int mat3;
+   int mat4;
+   int mat2x3;
+   int mat3x2;
+   int mat2x4;
+   int mat4x2;
+   int mat3x4;
+   int mat4x3;
+   int sampler1D;
+   int sampler2D;
+   int sampler3D;
+   int samplerCube;
+   int sampler1DShadow;
+   int sampler2DShadow;
+   int sampler2DRect;
+   int sampler2DRectShadow;
+
+   int invariant;
+
+   int centroid;
+
+   int precision;
+   int lowp;
+   int mediump;
+   int highp;
+
+   int _const;
+   int attribute;
+   int varying;
+   int uniform;
+   int __fixed_output;
+   int __fixed_input;
+
+   int in;
+   int out;
+   int inout;
+
+   int _struct;
+
+   int __constructor;
+   int __operator;
+   int ___asm;
+
+   int _if;
+   int _else;
+   int _for;
+   int _while;
+   int _do;
+
+   int _continue;
+   int _break;
+   int _return;
+   int discard;
+
+   int _false;
+   int _true;
+};
+
+
+struct parse_context {
+   struct sl_pp_context *context;
+
+   struct parse_dict dict;
+
+   struct sl_pp_token_info *tokens;
+   unsigned int tokens_read;
+   unsigned int tokens_cap;
+
+   unsigned char *out_buf;
+   unsigned int out_cap;
+
+   unsigned int shader_type;
+   unsigned int parsing_builtin;
+
+   char error[256];
+   int process_error;
+};
+
+
+struct parse_state {
+   unsigned int in;
+   unsigned int out;
+};
+
+
+static __inline unsigned int
+_emit(struct parse_context *ctx,
+      unsigned int *out,
+      unsigned char b)
+{
+   if (*out == ctx->out_cap) {
+      ctx->out_cap += 4096;
+      ctx->out_buf = (unsigned char *)realloc(ctx->out_buf, ctx->out_cap * sizeof(unsigned char));
+   }
+   ctx->out_buf[*out] = b;
+   return (*out)++;
+}
+
+
+static void
+_update(struct parse_context *ctx,
+        unsigned int out,
+        unsigned char b)
+{
+   ctx->out_buf[out] = b;
+}
+
+
+static void
+_error(struct parse_context *ctx,
+       const char *msg)
+{
+   if (ctx->error[0] == '\0') {
+      strcpy(ctx->error, msg);
+   }
+}
+
+
+static const struct sl_pp_token_info *
+_fetch_token(struct parse_context *ctx,
+             unsigned int pos)
+{
+   if (ctx->process_error) {
+      return NULL;
+   }
+
+   while (pos >= ctx->tokens_read) {
+      if (ctx->tokens_read == ctx->tokens_cap) {
+         ctx->tokens_cap += 1024;
+         ctx->tokens = realloc(ctx->tokens,
+                               ctx->tokens_cap * sizeof(struct sl_pp_token_info));
+         if (!ctx->tokens) {
+            _error(ctx, "out of memory");
+            ctx->process_error = 1;
+            return NULL;
+         }
+      }
+      if (sl_pp_process_get(ctx->context, &ctx->tokens[ctx->tokens_read])) {
+         _error(ctx, sl_pp_context_error_message(ctx->context));
+         ctx->process_error = 1;
+         return NULL;
+      }
+      switch (ctx->tokens[ctx->tokens_read].token) {
+      case SL_PP_COMMA:
+      case SL_PP_SEMICOLON:
+      case SL_PP_LBRACE:
+      case SL_PP_RBRACE:
+      case SL_PP_LPAREN:
+      case SL_PP_RPAREN:
+      case SL_PP_LBRACKET:
+      case SL_PP_RBRACKET:
+      case SL_PP_DOT:
+      case SL_PP_INCREMENT:
+      case SL_PP_ADDASSIGN:
+      case SL_PP_PLUS:
+      case SL_PP_DECREMENT:
+      case SL_PP_SUBASSIGN:
+      case SL_PP_MINUS:
+      case SL_PP_BITNOT:
+      case SL_PP_NOTEQUAL:
+      case SL_PP_NOT:
+      case SL_PP_MULASSIGN:
+      case SL_PP_STAR:
+      case SL_PP_DIVASSIGN:
+      case SL_PP_SLASH:
+      case SL_PP_MODASSIGN:
+      case SL_PP_MODULO:
+      case SL_PP_LSHIFTASSIGN:
+      case SL_PP_LSHIFT:
+      case SL_PP_LESSEQUAL:
+      case SL_PP_LESS:
+      case SL_PP_RSHIFTASSIGN:
+      case SL_PP_RSHIFT:
+      case SL_PP_GREATEREQUAL:
+      case SL_PP_GREATER:
+      case SL_PP_EQUAL:
+      case SL_PP_ASSIGN:
+      case SL_PP_AND:
+      case SL_PP_BITANDASSIGN:
+      case SL_PP_BITAND:
+      case SL_PP_XOR:
+      case SL_PP_BITXORASSIGN:
+      case SL_PP_BITXOR:
+      case SL_PP_OR:
+      case SL_PP_BITORASSIGN:
+      case SL_PP_BITOR:
+      case SL_PP_QUESTION:
+      case SL_PP_COLON:
+      case SL_PP_IDENTIFIER:
+      case SL_PP_UINT:
+      case SL_PP_FLOAT:
+      case SL_PP_EOF:
+         ctx->tokens_read++;
+         break;
+      default:
+         ; /* no-op */
+      }
+   }
+   return &ctx->tokens[pos];
+}
+
+
+static int
+_parse_token(struct parse_context *ctx,
+             enum sl_pp_token token,
+             struct parse_state *ps)
+{
+   const struct sl_pp_token_info *input = _fetch_token(ctx, ps->in);
+
+   if (input && input->token == token) {
+      ps->in++;
+      return 0;
+   }
+   return -1;
+}
+
+
+static int
+_parse_id(struct parse_context *ctx,
+          int id,
+          struct parse_state *ps)
+{
+   const struct sl_pp_token_info *input = _fetch_token(ctx, ps->in);
+
+   if (input && input->token == SL_PP_IDENTIFIER && input->data.identifier == id) {
+      ps->in++;
+      return 0;
+   }
+   return -1;
+}
+
+
+static int
+_parse_identifier(struct parse_context *ctx,
+                  struct parse_state *ps)
+{
+   const struct sl_pp_token_info *input = _fetch_token(ctx, ps->in);
+
+   if (input && input->token == SL_PP_IDENTIFIER) {
+      const char *cstr = sl_pp_context_cstr(ctx->context, input->data.identifier);
+
+      do {
+         _emit(ctx, &ps->out, *cstr);
+      } while (*cstr++);
+      ps->in++;
+      return 0;
+   }
+   return -1;
+}
+
+
+static int
+_parse_float(struct parse_context *ctx,
+             struct parse_state *ps)
+{
+   const struct sl_pp_token_info *input = _fetch_token(ctx, ps->in);
+
+   if (input && input->token == SL_PP_FLOAT) {
+      const char *cstr = sl_pp_context_cstr(ctx->context, input->data._float);
+
+      _emit(ctx, &ps->out, 1);
+      do {
+         _emit(ctx, &ps->out, *cstr);
+      } while (*cstr++);
+      ps->in++;
+      return 0;
+   }
+   return -1;
+}
+
+
+static int
+_parse_uint(struct parse_context *ctx,
+            struct parse_state *ps)
+{
+   const struct sl_pp_token_info *input = _fetch_token(ctx, ps->in);
+
+   if (input && input->token == SL_PP_UINT) {
+      const char *cstr = sl_pp_context_cstr(ctx->context, input->data._uint);
+
+      _emit(ctx, &ps->out, 1);
+      do {
+         _emit(ctx, &ps->out, *cstr);
+      } while (*cstr++);
+      ps->in++;
+      return 0;
+   }
+   return -1;
+}
+
+
+/**************************************/
+
+
+static int
+_parse_unary_expression(struct parse_context *ctx,
+                        struct parse_state *ps);
+
+static int
+_parse_conditional_expression(struct parse_context *ctx,
+                              struct parse_state *ps);
+
+
+static int
+_parse_constant_expression(struct parse_context *ctx,
+                           struct parse_state *ps);
+
+
+static int
+_parse_primary_expression(struct parse_context *ctx,
+                          struct parse_state *ps);
+
+
+static int
+_parse_statement(struct parse_context *ctx,
+                 struct parse_state *ps);
+
+
+static int
+_parse_type_specifier(struct parse_context *ctx,
+                      struct parse_state *ps);
+
+
+static int
+_parse_declaration(struct parse_context *ctx,
+                   struct parse_state *ps);
+
+
+static int
+_parse_statement_list(struct parse_context *ctx,
+                      struct parse_state *ps);
+
+
+static int
+_parse_assignment_expression(struct parse_context *ctx,
+                             struct parse_state *ps);
+
+
+static int
+_parse_precision(struct parse_context *ctx,
+                 struct parse_state *ps);
+
+
+static int
+_parse_overriden_operator(struct parse_context *ctx,
+                          struct parse_state *ps)
+{
+   unsigned int op;
+
+   if (_parse_token(ctx, SL_PP_INCREMENT, ps) == 0) {
+      op = OPERATOR_INCREMENT;
+   } else if (_parse_token(ctx, SL_PP_ADDASSIGN, ps) == 0) {
+      op = OPERATOR_ADDASSIGN;
+   } else if (_parse_token(ctx, SL_PP_PLUS, ps) == 0) {
+      op = OPERATOR_PLUS;
+   } else if (_parse_token(ctx, SL_PP_DECREMENT, ps) == 0) {
+      op = OPERATOR_DECREMENT;
+   } else if (_parse_token(ctx, SL_PP_SUBASSIGN, ps) == 0) {
+      op = OPERATOR_SUBASSIGN;
+   } else if (_parse_token(ctx, SL_PP_MINUS, ps) == 0) {
+      op = OPERATOR_MINUS;
+   } else if (_parse_token(ctx, SL_PP_NOT, ps) == 0) {
+      op = OPERATOR_NOT;
+   } else if (_parse_token(ctx, SL_PP_MULASSIGN, ps) == 0) {
+      op = OPERATOR_MULASSIGN;
+   } else if (_parse_token(ctx, SL_PP_STAR, ps) == 0) {
+      op = OPERATOR_MULTIPLY;
+   } else if (_parse_token(ctx, SL_PP_DIVASSIGN, ps) == 0) {
+      op = OPERATOR_DIVASSIGN;
+   } else if (_parse_token(ctx, SL_PP_SLASH, ps) == 0) {
+      op = OPERATOR_DIVIDE;
+   } else if (_parse_token(ctx, SL_PP_LESSEQUAL, ps) == 0) {
+      op = OPERATOR_LESSEQUAL;
+   } else if (_parse_token(ctx, SL_PP_LESS, ps) == 0) {
+      op = OPERATOR_LESS;
+   } else if (_parse_token(ctx, SL_PP_GREATEREQUAL, ps) == 0) {
+      op = OPERATOR_GREATEREQUAL;
+   } else if (_parse_token(ctx, SL_PP_GREATER, ps) == 0) {
+      op = OPERATOR_GREATER;
+   } else if (_parse_token(ctx, SL_PP_XOR, ps) == 0) {
+      op = OPERATOR_LOGICALXOR;
+   } else {
+      return -1;
+   }
+
+   _emit(ctx, &ps->out, op);
+   return 0;
+}
+
+
+static int
+_parse_function_decl_identifier(struct parse_context *ctx,
+                                struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+   unsigned int e = _emit(ctx, &p.out, 0);
+
+   if (ctx->parsing_builtin && _parse_id(ctx, ctx->dict.__constructor, &p) == 0) {
+      _update(ctx, e, FUNCTION_CONSTRUCTOR);
+      *ps = p;
+      return 0;
+   }
+
+   if (ctx->parsing_builtin && _parse_id(ctx, ctx->dict.__operator, &p) == 0) {
+      _update(ctx, e, FUNCTION_OPERATOR);
+      if (_parse_overriden_operator(ctx, &p) == 0) {
+         *ps = p;
+         return 0;
+      }
+      return -1;
+   }
+
+   if (_parse_identifier(ctx, &p) == 0) {
+      _update(ctx, e, FUNCTION_ORDINARY);
+      *ps = p;
+      return 0;
+   }
+
+   return -1;
+}
+
+
+static int
+_parse_invariant_qualifier(struct parse_context *ctx,
+                           struct parse_state *ps)
+{
+   if (_parse_id(ctx, ctx->dict.invariant, ps)) {
+      return -1;
+   }
+   _emit(ctx, &ps->out, TYPE_INVARIANT);
+   return 0;
+}
+
+
+static int
+_parse_centroid_qualifier(struct parse_context *ctx,
+                          struct parse_state *ps)
+{
+   if (_parse_id(ctx, ctx->dict.centroid, ps)) {
+      return -1;
+   }
+   _emit(ctx, &ps->out, TYPE_CENTROID);
+   return 0;
+}
+
+
+static int
+_parse_type_qualifier(struct parse_context *ctx,
+                      struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+   const struct sl_pp_token_info *input = _fetch_token(ctx, p.in);
+   unsigned int e = _emit(ctx, &p.out, 0);
+   int id;
+
+   if (!input || input->token != SL_PP_IDENTIFIER) {
+      return -1;
+   }
+   id = input->data.identifier;
+
+   if (id == ctx->dict._const) {
+      _update(ctx, e, TYPE_QUALIFIER_CONST);
+   } else if (ctx->shader_type == 2 && id == ctx->dict.attribute) {
+      _update(ctx, e, TYPE_QUALIFIER_ATTRIBUTE);
+   } else if (id == ctx->dict.varying) {
+      _update(ctx, e, TYPE_QUALIFIER_VARYING);
+   } else if (id == ctx->dict.uniform) {
+      _update(ctx, e, TYPE_QUALIFIER_UNIFORM);
+   } else if (ctx->parsing_builtin && id == ctx->dict.__fixed_output) {
+      _update(ctx, e, TYPE_QUALIFIER_FIXEDOUTPUT);
+   } else if (ctx->parsing_builtin && id == ctx->dict.__fixed_input) {
+      _update(ctx, e, TYPE_QUALIFIER_FIXEDINPUT);
+   } else {
+      return -1;
+   }
+   _parse_token(ctx, SL_PP_IDENTIFIER, &p);
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_struct_declarator(struct parse_context *ctx,
+                         struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+   unsigned int e;
+
+   if (_parse_identifier(ctx, &p)) {
+      return -1;
+   }
+   e = _emit(ctx, &p.out, FIELD_NONE);
+   *ps = p;
+
+   if (_parse_token(ctx, SL_PP_LBRACKET, &p)) {
+      return 0;
+   }
+   if (_parse_constant_expression(ctx, &p)) {
+      _error(ctx, "expected constant integral expression");
+      return -1;
+   }
+   if (_parse_token(ctx, SL_PP_RBRACKET, &p)) {
+      _error(ctx, "expected `]'");
+      return -1;
+   }
+   _update(ctx, e, FIELD_ARRAY);
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_struct_declarator_list(struct parse_context *ctx,
+                              struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_struct_declarator(ctx, &p)) {
+      return -1;
+   }
+
+   for (;;) {
+      *ps = p;
+      _emit(ctx, &p.out, FIELD_NEXT);
+      if (_parse_token(ctx, SL_PP_COMMA, &p)) {
+         return 0;
+      }
+      if (_parse_struct_declarator(ctx, &p)) {
+         return 0;
+      }
+   }
+}
+
+
+static int
+_parse_struct_declaration(struct parse_context *ctx,
+                          struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_type_specifier(ctx, &p)) {
+      return -1;
+   }
+   if (_parse_struct_declarator_list(ctx, &p)) {
+      return -1;
+   }
+   if (_parse_token(ctx, SL_PP_SEMICOLON, &p)) {
+      return -1;
+   }
+   _emit(ctx, &p.out, FIELD_NONE);
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_struct_declaration_list(struct parse_context *ctx,
+                               struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_struct_declaration(ctx, &p)) {
+      return -1;
+   }
+
+   for (;;) {
+      *ps = p;
+      _emit(ctx, &p.out, FIELD_NEXT);
+      if (_parse_struct_declaration(ctx, &p)) {
+         return 0;
+      }
+   }
+}
+
+
+static int
+_parse_struct_specifier(struct parse_context *ctx,
+                        struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_id(ctx, ctx->dict._struct, &p)) {
+      return -1;
+   }
+   if (_parse_identifier(ctx, &p)) {
+      _emit(ctx, &p.out, '\0');
+   }
+   if (_parse_token(ctx, SL_PP_LBRACE, &p)) {
+      _error(ctx, "expected `{'");
+      return -1;
+   }
+   if (_parse_struct_declaration_list(ctx, &p)) {
+      return -1;
+   }
+   if (_parse_token(ctx, SL_PP_RBRACE, &p)) {
+      return -1;
+   }
+   _emit(ctx, &p.out, FIELD_NONE);
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_type_specifier_nonarray(struct parse_context *ctx,
+                               struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+   unsigned int e = _emit(ctx, &p.out, 0);
+   const struct sl_pp_token_info *input;
+   int id;
+
+   if (_parse_struct_specifier(ctx, &p) == 0) {
+      _update(ctx, e, TYPE_SPECIFIER_STRUCT);
+      *ps = p;
+      return 0;
+   }
+
+   input = _fetch_token(ctx, p.in);
+   if (!input || input->token != SL_PP_IDENTIFIER) {
+      return -1;
+   }
+   id = input->data.identifier;
+
+   if (id == ctx->dict._void) {
+      _update(ctx, e, TYPE_SPECIFIER_VOID);
+   } else if (id == ctx->dict._float) {
+      _update(ctx, e, TYPE_SPECIFIER_FLOAT);
+   } else if (id == ctx->dict._int) {
+      _update(ctx, e, TYPE_SPECIFIER_INT);
+   } else if (id == ctx->dict._bool) {
+      _update(ctx, e, TYPE_SPECIFIER_BOOL);
+   } else if (id == ctx->dict.vec2) {
+      _update(ctx, e, TYPE_SPECIFIER_VEC2);
+   } else if (id == ctx->dict.vec3) {
+      _update(ctx, e, TYPE_SPECIFIER_VEC3);
+   } else if (id == ctx->dict.vec4) {
+      _update(ctx, e, TYPE_SPECIFIER_VEC4);
+   } else if (id == ctx->dict.bvec2) {
+      _update(ctx, e, TYPE_SPECIFIER_BVEC2);
+   } else if (id == ctx->dict.bvec3) {
+      _update(ctx, e, TYPE_SPECIFIER_BVEC3);
+   } else if (id == ctx->dict.bvec4) {
+      _update(ctx, e, TYPE_SPECIFIER_BVEC4);
+   } else if (id == ctx->dict.ivec2) {
+      _update(ctx, e, TYPE_SPECIFIER_IVEC2);
+   } else if (id == ctx->dict.ivec3) {
+      _update(ctx, e, TYPE_SPECIFIER_IVEC3);
+   } else if (id == ctx->dict.ivec4) {
+      _update(ctx, e, TYPE_SPECIFIER_IVEC4);
+   } else if (id == ctx->dict.mat2) {
+      _update(ctx, e, TYPE_SPECIFIER_MAT2);
+   } else if (id == ctx->dict.mat3) {
+      _update(ctx, e, TYPE_SPECIFIER_MAT3);
+   } else if (id == ctx->dict.mat4) {
+      _update(ctx, e, TYPE_SPECIFIER_MAT4);
+   } else if (id == ctx->dict.mat2x3) {
+      _update(ctx, e, TYPE_SPECIFIER_MAT23);
+   } else if (id == ctx->dict.mat3x2) {
+      _update(ctx, e, TYPE_SPECIFIER_MAT32);
+   } else if (id == ctx->dict.mat2x4) {
+      _update(ctx, e, TYPE_SPECIFIER_MAT24);
+   } else if (id == ctx->dict.mat4x2) {
+      _update(ctx, e, TYPE_SPECIFIER_MAT42);
+   } else if (id == ctx->dict.mat3x4) {
+      _update(ctx, e, TYPE_SPECIFIER_MAT34);
+   } else if (id == ctx->dict.mat4x3) {
+      _update(ctx, e, TYPE_SPECIFIER_MAT43);
+   } else if (id == ctx->dict.sampler1D) {
+      _update(ctx, e, TYPE_SPECIFIER_SAMPLER1D);
+   } else if (id == ctx->dict.sampler2D) {
+      _update(ctx, e, TYPE_SPECIFIER_SAMPLER2D);
+   } else if (id == ctx->dict.sampler3D) {
+      _update(ctx, e, TYPE_SPECIFIER_SAMPLER3D);
+   } else if (id == ctx->dict.samplerCube) {
+      _update(ctx, e, TYPE_SPECIFIER_SAMPLERCUBE);
+   } else if (id == ctx->dict.sampler1DShadow) {
+      _update(ctx, e, TYPE_SPECIFIER_SAMPLER1DSHADOW);
+   } else if (id == ctx->dict.sampler2DShadow) {
+      _update(ctx, e, TYPE_SPECIFIER_SAMPLER2DSHADOW);
+   } else if (id == ctx->dict.sampler2DRect) {
+      _update(ctx, e, TYPE_SPECIFIER_SAMPLER2DRECT);
+   } else if (id == ctx->dict.sampler2DRectShadow) {
+      _update(ctx, e, TYPE_SPECIFIER_SAMPLER2DRECTSHADOW);
+   } else if (_parse_identifier(ctx, &p) == 0) {
+      _update(ctx, e, TYPE_SPECIFIER_TYPENAME);
+      *ps = p;
+      return 0;
+   } else {
+      return -1;
+   }
+
+   _parse_token(ctx, SL_PP_IDENTIFIER, &p);
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_type_specifier_array(struct parse_context *ctx,
+                            struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_token(ctx, SL_PP_LBRACKET, &p)) {
+      return -1;
+   }
+   if (_parse_constant_expression(ctx, &p)) {
+      _error(ctx, "expected constant integral expression");
+      return -1;
+   }
+   if (_parse_token(ctx, SL_PP_RBRACKET, &p)) {
+      _error(ctx, "expected `]'");
+      return -1;
+   }
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_type_specifier(struct parse_context *ctx,
+                      struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+   unsigned int e;
+
+   if (_parse_type_specifier_nonarray(ctx, &p)) {
+      return -1;
+   }
+
+   e = _emit(ctx, &p.out, TYPE_SPECIFIER_ARRAY);
+   if (_parse_type_specifier_array(ctx, &p)) {
+      _update(ctx, e, TYPE_SPECIFIER_NONARRAY);
+   }
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_fully_specified_type(struct parse_context *ctx,
+                            struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_invariant_qualifier(ctx, &p)) {
+      _emit(ctx, &p.out, TYPE_VARIANT);
+   }
+   if (_parse_centroid_qualifier(ctx, &p)) {
+      _emit(ctx, &p.out, TYPE_CENTER);
+   }
+   if (_parse_type_qualifier(ctx, &p)) {
+      _emit(ctx, &p.out, TYPE_QUALIFIER_NONE);
+   }
+   if (_parse_precision(ctx, &p)) {
+      _emit(ctx, &p.out, PRECISION_DEFAULT);
+   }
+   if (_parse_type_specifier(ctx, &p)) {
+      return -1;
+   }
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_function_header(struct parse_context *ctx,
+                       struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_fully_specified_type(ctx, &p)) {
+      return -1;
+   }
+   if (_parse_function_decl_identifier(ctx, &p)) {
+      return -1;
+   }
+   if (_parse_token(ctx, SL_PP_LPAREN, &p)) {
+      return -1;
+   }
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_parameter_qualifier(struct parse_context *ctx,
+                           struct parse_state *ps)
+{
+   unsigned int e = _emit(ctx, &ps->out, PARAM_QUALIFIER_IN);
+
+   if (_parse_id(ctx, ctx->dict.out, ps) == 0) {
+      _update(ctx, e, PARAM_QUALIFIER_OUT);
+   } else if (_parse_id(ctx, ctx->dict.inout, ps) == 0) {
+      _update(ctx, e, PARAM_QUALIFIER_INOUT);
+   } else {
+      _parse_id(ctx, ctx->dict.in, ps);
+   }
+   return 0;
+}
+
+
+static int
+_parse_function_identifier(struct parse_context *ctx,
+                           struct parse_state *ps)
+{
+   struct parse_state p;
+   unsigned int e;
+
+   if (_parse_identifier(ctx, ps)) {
+      return -1;
+   }
+   e = _emit(ctx, &ps->out, FUNCTION_CALL_NONARRAY);
+
+   p = *ps;
+   if (_parse_token(ctx, SL_PP_LBRACKET, &p)) {
+      return 0;
+   }
+   if (_parse_constant_expression(ctx, &p)) {
+      _error(ctx, "expected constant integral expression");
+      return -1;
+   }
+   if (_parse_token(ctx, SL_PP_RBRACKET, &p)) {
+      _error(ctx, "expected `]'");
+      return -1;
+   }
+   _update(ctx, e, FUNCTION_CALL_ARRAY);
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_function_call_header(struct parse_context *ctx,
+                            struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_function_identifier(ctx, &p)) {
+      return -1;
+   }
+   if (_parse_token(ctx, SL_PP_LPAREN, &p)) {
+      return -1;
+   }
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_assign_expression(struct parse_context *ctx,
+                         struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+   unsigned int op;
+
+   if (_parse_unary_expression(ctx, &p)) {
+      return -1;
+   }
+
+   if (_parse_token(ctx, SL_PP_ASSIGN, &p) == 0) {
+      op = OP_ASSIGN;
+   } else if (_parse_token(ctx, SL_PP_MULASSIGN, &p) == 0) {
+      op = OP_MULASSIGN;
+   } else if (_parse_token(ctx, SL_PP_DIVASSIGN, &p) == 0) {
+      op = OP_DIVASSIGN;
+   } else if (_parse_token(ctx, SL_PP_ADDASSIGN, &p) == 0) {
+      op = OP_ADDASSIGN;
+   } else if (_parse_token(ctx, SL_PP_SUBASSIGN, &p) == 0) {
+      op = OP_SUBASSIGN;
+   } else {
+      return -1;
+   }
+
+   if (_parse_assignment_expression(ctx, &p)) {
+      return -1;
+   }
+   _emit(ctx, &p.out, op);
+
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_assignment_expression(struct parse_context *ctx,
+                             struct parse_state *ps)
+{
+   if (_parse_assign_expression(ctx, ps) == 0) {
+      return 0;
+   }
+
+   if (_parse_conditional_expression(ctx, ps) == 0) {
+      return 0;
+   }
+
+   return -1;
+}
+
+
+static int
+_parse_function_call_header_with_parameters(struct parse_context *ctx,
+                                            struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_function_call_header(ctx, &p)) {
+      return -1;
+   }
+   if (_parse_assignment_expression(ctx, &p)) {
+      return -1;
+   }
+   _emit(ctx, &p.out, OP_END);
+   for (;;) {
+      *ps = p;
+      if (_parse_token(ctx, SL_PP_COMMA, &p)) {
+         return 0;
+      }
+      if (_parse_assignment_expression(ctx, &p)) {
+         return 0;
+      }
+      _emit(ctx, &p.out, OP_END);
+   }
+}
+
+
+static int
+_parse_function_call_header_no_parameters(struct parse_context *ctx,
+                                          struct parse_state *ps)
+{
+   if (_parse_function_call_header(ctx, ps)) {
+      return -1;
+   }
+   _parse_id(ctx, ctx->dict._void, ps);
+   return 0;
+}
+
+
+static int
+_parse_function_call_generic(struct parse_context *ctx,
+                             struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_function_call_header_with_parameters(ctx, &p) == 0) {
+      if (_parse_token(ctx, SL_PP_RPAREN, &p) == 0) {
+         *ps = p;
+         return 0;
+      }
+      _error(ctx, "expected `)'");
+      return -1;
+   }
+
+   p = *ps;
+   if (_parse_function_call_header_no_parameters(ctx, &p) == 0) {
+      if (_parse_token(ctx, SL_PP_RPAREN, &p) == 0) {
+         *ps = p;
+         return 0;
+      }
+      _error(ctx, "expected `)'");
+      return -1;
+   }
+
+   return -1;
+}
+
+
+static int
+_parse_method_call(struct parse_context *ctx,
+                   struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   _emit(ctx, &p.out, OP_METHOD);
+   if (_parse_identifier(ctx, &p)) {
+      return -1;
+   }
+   if (_parse_token(ctx, SL_PP_DOT, &p)) {
+      return -1;
+   }
+   if (_parse_function_call_generic(ctx, &p)) {
+      return -1;
+   }
+   _emit(ctx, &p.out, OP_END);
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_regular_function_call(struct parse_context *ctx,
+                             struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   _emit(ctx, &p.out, OP_CALL);
+   if (_parse_function_call_generic(ctx, &p)) {
+      return -1;
+   }
+   _emit(ctx, &p.out, OP_END);
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_function_call(struct parse_context *ctx,
+                     struct parse_state *ps)
+{
+   if (_parse_regular_function_call(ctx, ps) == 0) {
+      return 0;
+   }
+
+   if (_parse_method_call(ctx, ps) == 0) {
+      return 0;
+   }
+
+   return -1;
+}
+
+
+static int
+_parse_expression(struct parse_context *ctx,
+                  struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_assignment_expression(ctx, &p)) {
+      return -1;
+   }
+
+   for (;;) {
+      *ps = p;
+      if (_parse_token(ctx, SL_PP_COMMA, &p)) {
+         return 0;
+      }
+      if (_parse_assignment_expression(ctx, &p)) {
+         return 0;
+      }
+      _emit(ctx, &p.out, OP_SEQUENCE);
+   }
+}
+
+
+static int
+_parse_postfix_expression(struct parse_context *ctx,
+                          struct parse_state *ps)
+{
+   struct parse_state p;
+
+   if (_parse_function_call(ctx, ps)) {
+      if (_parse_primary_expression(ctx, ps)) {
+         return -1;
+      }
+   }
+
+   for (p = *ps;;) {
+      *ps = p;
+      if (_parse_token(ctx, SL_PP_INCREMENT, &p) == 0) {
+         _emit(ctx, &p.out, OP_POSTINCREMENT);
+      } else if (_parse_token(ctx, SL_PP_DECREMENT, &p) == 0) {
+         _emit(ctx, &p.out, OP_POSTDECREMENT);
+      } else if (_parse_token(ctx, SL_PP_LBRACKET, &p) == 0) {
+         if (_parse_expression(ctx, &p)) {
+            _error(ctx, "expected an integral expression");
+            return -1;
+         }
+         if (_parse_token(ctx, SL_PP_RBRACKET, &p)) {
+            _error(ctx, "expected `]'");
+            return -1;
+         }
+         _emit(ctx, &p.out, OP_SUBSCRIPT);
+      } else if (_parse_token(ctx, SL_PP_DOT, &p) == 0) {
+         _emit(ctx, &p.out, OP_FIELD);
+         if (_parse_identifier(ctx, &p)) {
+            return 0;
+         }
+      } else {
+         return 0;
+      }
+   }
+}
+
+
+static int
+_parse_unary_expression(struct parse_context *ctx,
+                        struct parse_state *ps)
+{
+   struct parse_state p;
+   unsigned int op;
+
+   if (_parse_postfix_expression(ctx, ps) == 0) {
+      return 0;
+   }
+
+   p = *ps;
+   if (_parse_token(ctx, SL_PP_INCREMENT, &p) == 0) {
+      op = OP_PREINCREMENT;
+   } else if (_parse_token(ctx, SL_PP_DECREMENT, &p) == 0) {
+      op = OP_PREDECREMENT;
+   } else if (_parse_token(ctx, SL_PP_PLUS, &p) == 0) {
+      op = OP_PLUS;
+   } else if (_parse_token(ctx, SL_PP_MINUS, &p) == 0) {
+      op = OP_MINUS;
+   } else if (_parse_token(ctx, SL_PP_NOT, &p) == 0) {
+      op = OP_NOT;
+   } else {
+      return -1;
+   }
+
+   if (_parse_unary_expression(ctx, &p)) {
+      return -1;
+   }
+   _emit(ctx, &p.out, op);
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_multiplicative_expression(struct parse_context *ctx,
+                                 struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_unary_expression(ctx, &p)) {
+      return -1;
+   }
+   for (;;) {
+      unsigned int op;
+
+      *ps = p;
+      if (_parse_token(ctx, SL_PP_STAR, &p) == 0) {
+         op = OP_MULTIPLY;
+      } else if (_parse_token(ctx, SL_PP_SLASH, &p) == 0) {
+         op = OP_DIVIDE;
+      } else {
+         return 0;
+      }
+      if (_parse_unary_expression(ctx, &p)) {
+         return 0;
+      }
+      _emit(ctx, &p.out, op);
+   }
+}
+
+
+static int
+_parse_additive_expression(struct parse_context *ctx,
+                           struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_multiplicative_expression(ctx, &p)) {
+      return -1;
+   }
+   for (;;) {
+      unsigned int op;
+
+      *ps = p;
+      if (_parse_token(ctx, SL_PP_PLUS, &p) == 0) {
+         op = OP_ADD;
+      } else if (_parse_token(ctx, SL_PP_MINUS, &p) == 0) {
+         op = OP_SUBTRACT;
+      } else {
+         return 0;
+      }
+      if (_parse_multiplicative_expression(ctx, &p)) {
+         return 0;
+      }
+      _emit(ctx, &p.out, op);
+   }
+}
+
+
+static int
+_parse_relational_expression(struct parse_context *ctx,
+                             struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_additive_expression(ctx, &p)) {
+      return -1;
+   }
+   for (;;) {
+      unsigned int op;
+
+      *ps = p;
+      if (_parse_token(ctx, SL_PP_LESS, &p) == 0) {
+         op = OP_LESS;
+      } else if (_parse_token(ctx, SL_PP_GREATER, &p) == 0) {
+         op = OP_GREATER;
+      } else if (_parse_token(ctx, SL_PP_LESSEQUAL, &p) == 0) {
+         op = OP_LESSEQUAL;
+      } else if (_parse_token(ctx, SL_PP_GREATEREQUAL, &p) == 0) {
+         op = OP_GREATEREQUAL;
+      } else {
+         return 0;
+      }
+      if (_parse_additive_expression(ctx, &p)) {
+         return 0;
+      }
+      _emit(ctx, &p.out, op);
+   }
+}
+
+
+static int
+_parse_equality_expression(struct parse_context *ctx,
+                           struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_relational_expression(ctx, &p)) {
+      return -1;
+   }
+   for (;;) {
+      unsigned int op;
+
+      *ps = p;
+      if (_parse_token(ctx, SL_PP_EQUAL, &p) == 0) {
+         op = OP_EQUAL;
+      } else if (_parse_token(ctx, SL_PP_NOTEQUAL, &p) == 0) {
+         op = OP_NOTEQUAL;
+      } else {
+         return 0;
+      }
+      if (_parse_relational_expression(ctx, &p)) {
+         return -1;
+      }
+      _emit(ctx, &p.out, op);
+   }
+}
+
+
+static int
+_parse_logical_and_expression(struct parse_context *ctx,
+                              struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_equality_expression(ctx, &p)) {
+      return -1;
+   }
+   for (;;) {
+      *ps = p;
+      if (_parse_token(ctx, SL_PP_AND, &p)) {
+         return 0;
+      }
+      if (_parse_equality_expression(ctx, &p)) {
+         return 0;
+      }
+      _emit(ctx, &p.out, OP_LOGICALAND);
+   }
+}
+
+
+static int
+_parse_logical_xor_expression(struct parse_context *ctx,
+                              struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_logical_and_expression(ctx, &p)) {
+      return -1;
+   }
+   for (;;) {
+      *ps = p;
+      if (_parse_token(ctx, SL_PP_XOR, &p)) {
+         return 0;
+      }
+      if (_parse_logical_and_expression(ctx, &p)) {
+         return 0;
+      }
+      _emit(ctx, &p.out, OP_LOGICALXOR);
+   }
+}
+
+
+static int
+_parse_logical_or_expression(struct parse_context *ctx,
+                             struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_logical_xor_expression(ctx, &p)) {
+      return -1;
+   }
+   for (;;) {
+      *ps = p;
+      if (_parse_token(ctx, SL_PP_OR, &p)) {
+         return 0;
+      }
+      if (_parse_logical_xor_expression(ctx, &p)) {
+         return 0;
+      }
+      _emit(ctx, &p.out, OP_LOGICALOR);
+   }
+}
+
+
+static int
+_parse_conditional_expression(struct parse_context *ctx,
+                              struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_logical_or_expression(ctx, &p)) {
+      return -1;
+   }
+   for (;;) {
+      *ps = p;
+      if (_parse_token(ctx, SL_PP_QUESTION, &p)) {
+         return 0;
+      }
+      if (_parse_expression(ctx, &p)) {
+         return 0;
+      }
+      if (_parse_token(ctx, SL_PP_COLON, &p)) {
+         return 0;
+      }
+      if (_parse_conditional_expression(ctx, &p)) {
+         return 0;
+      }
+      _emit(ctx, &p.out, OP_SELECT);
+   }
+}
+
+
+static int
+_parse_constant_expression(struct parse_context *ctx,
+                           struct parse_state *ps)
+{
+   if (_parse_conditional_expression(ctx, ps)) {
+      return -1;
+   }
+   _emit(ctx, &ps->out, OP_END);
+   return 0;
+}
+
+
+static int
+_parse_parameter_declarator_array(struct parse_context *ctx,
+                                  struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_token(ctx, SL_PP_LBRACKET, &p)) {
+      return -1;
+   }
+   if (_parse_constant_expression(ctx, &p)) {
+      _error(ctx, "expected constant integral expression");
+      return -1;
+   }
+   if (_parse_token(ctx, SL_PP_RBRACKET, &p)) {
+      _error(ctx, "expected `]'");
+      return -1;
+   }
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_parameter_declarator(struct parse_context *ctx,
+                            struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+   unsigned int e;
+
+   if (_parse_type_specifier(ctx, &p)) {
+      return -1;
+   }
+   if (_parse_identifier(ctx, &p)) {
+      return -1;
+   }
+   e = _emit(ctx, &p.out, PARAMETER_ARRAY_PRESENT);
+   if (_parse_parameter_declarator_array(ctx, &p)) {
+      _update(ctx, e, PARAMETER_ARRAY_NOT_PRESENT);
+   }
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_parameter_type_specifier_array(struct parse_context *ctx,
+                                      struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_token(ctx, SL_PP_LBRACKET, &p)) {
+      return -1;
+   }
+   if (_parse_constant_expression(ctx, &p)) {
+      _error(ctx, "expected constant integral expression");
+      return -1;
+   }
+   if (_parse_token(ctx, SL_PP_RBRACKET, &p)) {
+      _error(ctx, "expected `]'");
+      return -1;
+   }
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_parameter_type_specifier(struct parse_context *ctx,
+                                struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+   unsigned int e;
+
+   if (_parse_type_specifier(ctx, &p)) {
+      return -1;
+   }
+   _emit(ctx, &p.out, '\0');
+
+   e = _emit(ctx, &p.out, PARAMETER_ARRAY_PRESENT);
+   if (_parse_parameter_type_specifier_array(ctx, &p)) {
+      _update(ctx, e, PARAMETER_ARRAY_NOT_PRESENT);
+   }
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_parameter_declaration(struct parse_context *ctx,
+                             struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+   unsigned int e = _emit(ctx, &p.out, PARAMETER_NEXT);
+
+   (void) e;
+
+   if (_parse_type_qualifier(ctx, &p)) {
+      _emit(ctx, &p.out, TYPE_QUALIFIER_NONE);
+   }
+   _parse_parameter_qualifier(ctx, &p);
+   if (_parse_precision(ctx, &p)) {
+      _emit(ctx, &p.out, PRECISION_DEFAULT);
+   }
+   if (_parse_parameter_declarator(ctx, &p) == 0) {
+      *ps = p;
+      return 0;
+   }
+   if (_parse_parameter_type_specifier(ctx, &p) == 0) {
+      *ps = p;
+      return 0;
+   }
+
+   return -1;
+}
+
+
+static int
+_parse_function_header_with_parameters(struct parse_context *ctx,
+                                       struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_function_header(ctx, &p)) {
+      return -1;
+   }
+   if (_parse_parameter_declaration(ctx, &p)) {
+      return -1;
+   }
+
+   for (;;) {
+      *ps = p;
+      if (_parse_token(ctx, SL_PP_COMMA, &p)) {
+         return 0;
+      }
+      if (_parse_parameter_declaration(ctx, &p)) {
+         return 0;
+      }
+   }
+}
+
+
+static int
+_parse_function_declarator(struct parse_context *ctx,
+                           struct parse_state *ps)
+{
+   if (_parse_function_header_with_parameters(ctx, ps) == 0) {
+      return 0;
+   }
+
+   if (_parse_function_header(ctx, ps) == 0) {
+      return 0;
+   }
+
+   return -1;
+}
+
+
+static int
+_parse_function_prototype(struct parse_context *ctx,
+                          struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_function_header(ctx, &p) == 0) {
+      if (_parse_id(ctx, ctx->dict._void, &p) == 0) {
+         if (_parse_token(ctx, SL_PP_RPAREN, &p) == 0) {
+            _emit(ctx, &p.out, PARAMETER_NONE);
+            *ps = p;
+            return 0;
+         }
+         _error(ctx, "expected `)'");
+         return -1;
+      }
+   }
+
+   p = *ps;
+   if (_parse_function_declarator(ctx, &p) == 0) {
+      if (_parse_token(ctx, SL_PP_RPAREN, &p) == 0) {
+         _emit(ctx, &p.out, PARAMETER_NONE);
+         *ps = p;
+         return 0;
+      }
+      _error(ctx, "expected `)'");
+      return -1;
+   }
+
+   return -1;
+}
+
+
+static int
+_parse_precision(struct parse_context *ctx,
+                 struct parse_state *ps)
+{
+   const struct sl_pp_token_info *input = _fetch_token(ctx, ps->in);
+   int id;
+   unsigned int precision;
+
+   if (!input || input->token != SL_PP_IDENTIFIER) {
+      return -1;
+   }
+   id = input->data.identifier;
+
+   if (id == ctx->dict.lowp) {
+      precision = PRECISION_LOW;
+   } else if (id == ctx->dict.mediump) {
+      precision = PRECISION_MEDIUM;
+   } else if (id == ctx->dict.highp) {
+      precision = PRECISION_HIGH;
+   } else {
+      return -1;
+   }
+
+   _parse_token(ctx, SL_PP_IDENTIFIER, ps);
+   _emit(ctx, &ps->out, precision);
+   return 0;
+}
+
+
+static int
+_parse_prectype(struct parse_context *ctx,
+                 struct parse_state *ps)
+{
+   const struct sl_pp_token_info *input = _fetch_token(ctx, ps->in);
+   int id;
+   unsigned int type;
+
+   if (!input || input->token != SL_PP_IDENTIFIER) {
+      return -1;
+   }
+   id = input->data.identifier;
+
+   if (id == ctx->dict._int) {
+      type = TYPE_SPECIFIER_INT;
+   } else if (id == ctx->dict._float) {
+      type = TYPE_SPECIFIER_FLOAT;
+   } else if (id == ctx->dict.sampler1D) {
+      type = TYPE_SPECIFIER_SAMPLER1D;
+   } else if (id == ctx->dict.sampler2D) {
+      type = TYPE_SPECIFIER_SAMPLER2D;
+   } else if (id == ctx->dict.sampler3D) {
+      type = TYPE_SPECIFIER_SAMPLER3D;
+   } else if (id == ctx->dict.samplerCube) {
+      type = TYPE_SPECIFIER_SAMPLERCUBE;
+   } else if (id == ctx->dict.sampler1DShadow) {
+      type = TYPE_SPECIFIER_SAMPLER1DSHADOW;
+   } else if (id == ctx->dict.sampler2DShadow) {
+      type = TYPE_SPECIFIER_SAMPLER2DSHADOW;
+   } else if (id == ctx->dict.sampler2DRect) {
+      type = TYPE_SPECIFIER_SAMPLER2DRECT;
+   } else if (id == ctx->dict.sampler2DRectShadow) {
+      type = TYPE_SPECIFIER_SAMPLER2DRECTSHADOW;
+   } else {
+      return -1;
+   }
+
+   _parse_token(ctx, SL_PP_IDENTIFIER, ps);
+   _emit(ctx, &ps->out, type);
+   return 0;
+}
+
+
+static int
+_parse_precision_stmt(struct parse_context *ctx,
+                      struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_id(ctx, ctx->dict.precision, &p)) {
+      return -1;
+   }
+   if (_parse_precision(ctx, &p)) {
+      return -1;
+   }
+   if (_parse_prectype(ctx, &p)) {
+      return -1;
+   }
+   if (_parse_token(ctx, SL_PP_SEMICOLON, &p)) {
+      return -1;
+   }
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_floatconstant(struct parse_context *ctx,
+                     struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   _emit(ctx, &p.out, OP_PUSH_FLOAT);
+   if (_parse_float(ctx, &p)) {
+      return -1;
+   }
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_intconstant(struct parse_context *ctx,
+                   struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   _emit(ctx, &p.out, OP_PUSH_INT);
+   if (_parse_uint(ctx, &p)) {
+      return -1;
+   }
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_boolconstant(struct parse_context *ctx,
+                    struct parse_state *ps)
+{
+   if (_parse_id(ctx, ctx->dict._false, ps) == 0) {
+      _emit(ctx, &ps->out, OP_PUSH_BOOL);
+      _emit(ctx, &ps->out, 2);  /* radix */
+      _emit(ctx, &ps->out, '0');
+      _emit(ctx, &ps->out, '\0');
+      return 0;
+   }
+
+   if (_parse_id(ctx, ctx->dict._true, ps) == 0) {
+      _emit(ctx, &ps->out, OP_PUSH_BOOL);
+      _emit(ctx, &ps->out, 2);  /* radix */
+      _emit(ctx, &ps->out, '1');
+      _emit(ctx, &ps->out, '\0');
+      return 0;
+   }
+
+   return -1;
+}
+
+
+static int
+_parse_variable_identifier(struct parse_context *ctx,
+                           struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   _emit(ctx, &p.out, OP_PUSH_IDENTIFIER);
+   if (_parse_identifier(ctx, &p)) {
+      return -1;
+   }
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_primary_expression(struct parse_context *ctx,
+                          struct parse_state *ps)
+{
+   struct parse_state p;
+
+   if (_parse_floatconstant(ctx, ps) == 0) {
+      return 0;
+   }
+   if (_parse_boolconstant(ctx, ps) == 0) {
+      return 0;
+   }
+   if (_parse_intconstant(ctx, ps) == 0) {
+      return 0;
+   }
+   if (_parse_variable_identifier(ctx, ps) == 0) {
+      return 0;
+   }
+
+   p = *ps;
+   if (_parse_token(ctx, SL_PP_LPAREN, &p)) {
+      return -1;
+   }
+   if (_parse_expression(ctx, &p)) {
+      return -1;
+   }
+   if (_parse_token(ctx, SL_PP_RPAREN, &p)) {
+      return -1;
+   }
+
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_asm_argument(struct parse_context *ctx,
+                    struct parse_state *ps)
+{
+   if (_parse_variable_identifier(ctx, ps) == 0) {
+      struct parse_state p = *ps;
+
+      if (_parse_token(ctx, SL_PP_DOT, &p)) {
+         return 0;
+      }
+      _emit(ctx, &p.out, OP_FIELD);
+      if (_parse_identifier(ctx, &p)) {
+         return 0;
+      }
+      *ps = p;
+      return 0;
+   }
+
+   if (_parse_floatconstant(ctx, ps) == 0) {
+      return 0;
+   }
+
+   return -1;
+}
+
+
+static int
+_parse_asm_arguments(struct parse_context *ctx,
+                     struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_asm_argument(ctx, &p)) {
+      return -1;
+   }
+   _emit(ctx, &p.out, OP_END);
+
+   for (;;) {
+      *ps = p;
+      if (_parse_token(ctx, SL_PP_COMMA, &p)) {
+         return 0;
+      }
+      if (_parse_asm_argument(ctx, &p)) {
+         return 0;
+      }
+      _emit(ctx, &p.out, OP_END);
+   }
+}
+
+
+static int
+_parse_asm_statement(struct parse_context *ctx,
+                     struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_id(ctx, ctx->dict.___asm, &p)) {
+      return -1;
+   }
+   if (_parse_identifier(ctx, &p)) {
+      return -1;
+   }
+   if (_parse_asm_arguments(ctx, &p)) {
+      return -1;
+   }
+   if (_parse_token(ctx, SL_PP_SEMICOLON, &p)) {
+      return -1;
+   }
+   _emit(ctx, &p.out, OP_END);
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_selection_statement(struct parse_context *ctx,
+                           struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   _emit(ctx, &p.out, OP_IF);
+   if (_parse_id(ctx, ctx->dict._if, &p)) {
+      return -1;
+   }
+   if (_parse_token(ctx, SL_PP_LPAREN, &p)) {
+      _error(ctx, "expected `('");
+      return -1;
+   }
+   if (_parse_expression(ctx, &p)) {
+      _error(ctx, "expected an expression");
+      return -1;
+   }
+   if (_parse_token(ctx, SL_PP_RPAREN, &p)) {
+      _error(ctx, "expected `)'");
+      return -1;
+   }
+   _emit(ctx, &p.out, OP_END);
+   if (_parse_statement(ctx, &p)) {
+      return -1;
+   }
+
+   *ps = p;
+   if (_parse_id(ctx, ctx->dict._else, &p) == 0) {
+      if (_parse_statement(ctx, &p) == 0) {
+         *ps = p;
+         return 0;
+      }
+   }
+
+   _emit(ctx, &ps->out, OP_EXPRESSION);
+   _emit(ctx, &ps->out, OP_PUSH_VOID);
+   _emit(ctx, &ps->out, OP_END);
+   return 0;
+}
+
+
+static int
+_parse_expression_statement(struct parse_context *ctx,
+                            struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_expression(ctx, &p)) {
+      _emit(ctx, &p.out, OP_PUSH_VOID);
+   }
+   if (_parse_token(ctx, SL_PP_SEMICOLON, &p)) {
+      return -1;
+   }
+   _emit(ctx, &p.out, OP_END);
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_for_init_statement(struct parse_context *ctx,
+                          struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+   unsigned int e = _emit(ctx, &p.out, OP_EXPRESSION);
+
+   if (_parse_expression_statement(ctx, &p) == 0) {
+      *ps = p;
+      return 0;
+   }
+
+   if (_parse_declaration(ctx, &p) == 0) {
+      _update(ctx, e, OP_DECLARE);
+      *ps = p;
+      return 0;
+   }
+
+   return -1;
+}
+
+
+static int
+_parse_initializer(struct parse_context *ctx,
+                   struct parse_state *ps)
+{
+   if (_parse_assignment_expression(ctx, ps) == 0) {
+      _emit(ctx, &ps->out, OP_END);
+      return 0;
+   }
+   return -1;
+}
+
+
+static int
+_parse_condition_initializer(struct parse_context *ctx,
+                             struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   _emit(ctx, &p.out, OP_DECLARE);
+   _emit(ctx, &p.out, DECLARATION_INIT_DECLARATOR_LIST);
+   if (_parse_fully_specified_type(ctx, &p)) {
+      return -1;
+   }
+   _emit(ctx, &p.out, VARIABLE_IDENTIFIER);
+   if (_parse_identifier(ctx, &p)) {
+      return -1;
+   }
+   if (_parse_token(ctx, SL_PP_ASSIGN, &p)) {
+      _error(ctx, "expected `='");
+      return -1;
+   }
+   _emit(ctx, &p.out, VARIABLE_INITIALIZER);
+   if (_parse_initializer(ctx, &p)) {
+      _error(ctx, "expected an initialiser");
+      return -1;
+   }
+   _emit(ctx, &p.out, DECLARATOR_NONE);
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_condition(struct parse_context *ctx,
+                 struct parse_state *ps)
+{
+   struct parse_state p;
+
+   if (_parse_condition_initializer(ctx, ps) == 0) {
+      return 0;
+   }
+
+   p = *ps;
+   _emit(ctx, &p.out, OP_EXPRESSION);
+   if (_parse_expression(ctx, &p) == 0) {
+      _emit(ctx, &p.out, OP_END);
+      *ps = p;
+      return 0;
+   }
+
+   return -1;
+}
+
+
+static int
+_parse_for_rest_statement(struct parse_context *ctx,
+                          struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_condition(ctx, &p)) {
+      _emit(ctx, &p.out, OP_EXPRESSION);
+      _emit(ctx, &p.out, OP_PUSH_BOOL);
+      _emit(ctx, &p.out, 2);
+      _emit(ctx, &p.out, '1');
+      _emit(ctx, &p.out, '\0');
+      _emit(ctx, &p.out, OP_END);
+   }
+   if (_parse_token(ctx, SL_PP_SEMICOLON, &p)) {
+      return -1;
+   }
+   if (_parse_expression(ctx, &p)) {
+      _emit(ctx, &p.out, OP_PUSH_VOID);
+   }
+   _emit(ctx, &p.out, OP_END);
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_iteration_statement(struct parse_context *ctx,
+                           struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_id(ctx, ctx->dict._while, &p) == 0) {
+      _emit(ctx, &p.out, OP_WHILE);
+      if (_parse_token(ctx, SL_PP_LPAREN, &p)) {
+         _error(ctx, "expected `('");
+         return -1;
+      }
+      if (_parse_condition(ctx, &p)) {
+         _error(ctx, "expected an expression");
+         return -1;
+      }
+      if (_parse_token(ctx, SL_PP_RPAREN, &p)) {
+         _error(ctx, "expected `)'");
+         return -1;
+      }
+      if (_parse_statement(ctx, &p)) {
+         return -1;
+      }
+      *ps = p;
+      return 0;
+   }
+
+   if (_parse_id(ctx, ctx->dict._do, &p) == 0) {
+      _emit(ctx, &p.out, OP_DO);
+      if (_parse_statement(ctx, &p)) {
+         return -1;
+      }
+      if (_parse_id(ctx, ctx->dict._while, &p)) {
+         return -1;
+      }
+      if (_parse_token(ctx, SL_PP_LPAREN, &p)) {
+         _error(ctx, "expected `('");
+         return -1;
+      }
+      if (_parse_expression(ctx, &p)) {
+         _error(ctx, "expected an expression");
+         return -1;
+      }
+      if (_parse_token(ctx, SL_PP_RPAREN, &p)) {
+         _error(ctx, "expected `)'");
+         return -1;
+      }
+      _emit(ctx, &p.out, OP_END);
+      if (_parse_token(ctx, SL_PP_SEMICOLON, &p)) {
+         _error(ctx, "expected `;'");
+         return -1;
+      }
+      *ps = p;
+      return 0;
+   }
+
+   if (_parse_id(ctx, ctx->dict._for, &p) == 0) {
+      _emit(ctx, &p.out, OP_FOR);
+      if (_parse_token(ctx, SL_PP_LPAREN, &p)) {
+         _error(ctx, "expected `('");
+         return -1;
+      }
+      if (_parse_for_init_statement(ctx, &p)) {
+         return -1;
+      }
+      if (_parse_for_rest_statement(ctx, &p)) {
+         return -1;
+      }
+      if (_parse_token(ctx, SL_PP_RPAREN, &p)) {
+         _error(ctx, "expected `)'");
+         return -1;
+      }
+      if (_parse_statement(ctx, &p)) {
+         return -1;
+      }
+      *ps = p;
+      return 0;
+   }
+
+   return -1;
+}
+
+
+static int
+_parse_jump_statement(struct parse_context *ctx,
+                      struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+   unsigned int e = _emit(ctx, &p.out, 0);
+
+   if (_parse_id(ctx, ctx->dict._continue, &p) == 0) {
+      _update(ctx, e, OP_CONTINUE);
+   } else if (_parse_id(ctx, ctx->dict._break, &p) == 0) {
+      _update(ctx, e, OP_BREAK);
+   } else if (_parse_id(ctx, ctx->dict._return, &p) == 0) {
+      _update(ctx, e, OP_RETURN);
+      if (_parse_expression(ctx, &p)) {
+         _emit(ctx, &p.out, OP_PUSH_VOID);
+      }
+      _emit(ctx, &p.out, OP_END);
+   } else if (ctx->shader_type == 1 && _parse_id(ctx, ctx->dict.discard, &p) == 0) {
+      _update(ctx, e, OP_DISCARD);
+   } else {
+      return -1;
+   }
+   if (_parse_token(ctx, SL_PP_SEMICOLON, &p)) {
+      return -1;
+   }
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_simple_statement(struct parse_context *ctx,
+                        struct parse_state *ps)
+{
+   struct parse_state p;
+   unsigned int e;
+
+   if (_parse_selection_statement(ctx, ps) == 0) {
+      return 0;
+   }
+
+   if (_parse_iteration_statement(ctx, ps) == 0) {
+      return 0;
+   }
+
+   if (_parse_jump_statement(ctx, ps) == 0) {
+      return 0;
+   }
+
+   p = *ps;
+   e = _emit(ctx, &p.out, OP_EXPRESSION);
+   if (_parse_expression_statement(ctx, &p) == 0) {
+      *ps = p;
+      return 0;
+   }
+
+   if (_parse_precision_stmt(ctx, &p) == 0) {
+      _update(ctx, e, OP_PRECISION);
+      *ps = p;
+      return 0;
+   }
+
+   if (ctx->parsing_builtin && _parse_asm_statement(ctx, &p) == 0) {
+      _update(ctx, e, OP_ASM);
+      *ps = p;
+      return 0;
+   }
+
+   if (_parse_declaration(ctx, &p) == 0) {
+      _update(ctx, e, OP_DECLARE);
+      *ps = p;
+      return 0;
+   }
+
+   return -1;
+}
+
+
+static int
+_parse_compound_statement(struct parse_context *ctx,
+                          struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_token(ctx, SL_PP_LBRACE, &p)) {
+      return -1;
+   }
+   _emit(ctx, &p.out, OP_BLOCK_BEGIN_NEW_SCOPE);
+   _parse_statement_list(ctx, &p);
+   if (_parse_token(ctx, SL_PP_RBRACE, &p)) {
+      return -1;
+   }
+   _emit(ctx, &p.out, OP_END);
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_statement(struct parse_context *ctx,
+                 struct parse_state *ps)
+{
+   if (_parse_compound_statement(ctx, ps) == 0) {
+      return 0;
+   }
+
+   if (_parse_simple_statement(ctx, ps) == 0) {
+      return 0;
+   }
+
+   return -1;
+}
+
+
+static int
+_parse_statement_list(struct parse_context *ctx,
+                      struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_statement(ctx, &p)) {
+      return -1;
+   }
+
+   for (;;) {
+      *ps = p;
+      if (_parse_statement(ctx, &p)) {
+         return 0;
+      }
+   }
+}
+
+
+static int
+_parse_compound_statement_no_new_scope(struct parse_context *ctx,
+                                       struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_token(ctx, SL_PP_LBRACE, &p)) {
+      return -1;
+   }
+   _emit(ctx, &p.out, OP_BLOCK_BEGIN_NO_NEW_SCOPE);
+   _parse_statement_list(ctx, &p);
+   if (_parse_token(ctx, SL_PP_RBRACE, &p)) {
+      return -1;
+   }
+   _emit(ctx, &p.out, OP_END);
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_function_definition(struct parse_context *ctx,
+                           struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_function_prototype(ctx, &p)) {
+      return -1;
+   }
+   if (_parse_compound_statement_no_new_scope(ctx, &p)) {
+      return -1;
+   }
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_invariant_stmt(struct parse_context *ctx,
+                      struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_id(ctx, ctx->dict.invariant, &p)) {
+      return -1;
+   }
+   if (_parse_identifier(ctx, &p)) {
+      return -1;
+   }
+   if (_parse_token(ctx, SL_PP_SEMICOLON, &p)) {
+      return -1;
+   }
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_single_declaration(struct parse_context *ctx,
+                          struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+   unsigned int e;
+
+   if (_parse_fully_specified_type(ctx, &p)) {
+      return -1;
+   }
+
+   e = _emit(ctx, &p.out, VARIABLE_IDENTIFIER);
+   if (_parse_identifier(ctx, &p)) {
+      _update(ctx, e, VARIABLE_NONE);
+      *ps = p;
+      return 0;
+   }
+
+   e = _emit(ctx, &p.out, VARIABLE_NONE);
+   *ps = p;
+
+   if (_parse_token(ctx, SL_PP_ASSIGN, &p) == 0) {
+      _update(ctx, e, VARIABLE_INITIALIZER);
+      if (_parse_initializer(ctx, &p) == 0) {
+         *ps = p;
+         return 0;
+      }
+      _error(ctx, "expected an initialiser");
+      return -1;
+   }
+   p = *ps;
+
+   if (_parse_token(ctx, SL_PP_LBRACKET, &p) == 0) {
+      if (_parse_constant_expression(ctx, &p)) {
+         _update(ctx, e, VARIABLE_ARRAY_UNKNOWN);
+      } else {
+         _update(ctx, e, VARIABLE_ARRAY_EXPLICIT);
+      }
+      if (_parse_token(ctx, SL_PP_RBRACKET, &p) == 0) {
+         *ps = p;
+         return 0;
+      }
+      _error(ctx, "expected `]'");
+      return -1;
+   }
+   return 0;
+}
+
+
+static int
+_parse_init_declarator_list(struct parse_context *ctx,
+                            struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+
+   if (_parse_single_declaration(ctx, &p)) {
+      return -1;
+   }
+
+   for (;;) {
+      unsigned int e;
+
+      *ps = p;
+      if (_parse_token(ctx, SL_PP_COMMA, &p)) {
+         break;
+      }
+      _emit(ctx, &p.out, DECLARATOR_NEXT);
+      _emit(ctx, &p.out, VARIABLE_IDENTIFIER);
+      if (_parse_identifier(ctx, &p)) {
+         break;
+      }
+
+      e = _emit(ctx, &p.out, VARIABLE_NONE);
+      *ps = p;
+
+      if (_parse_token(ctx, SL_PP_ASSIGN, &p) == 0) {
+         if (_parse_initializer(ctx, &p) == 0) {
+            _update(ctx, e, VARIABLE_INITIALIZER);
+            *ps = p;
+            continue;
+         }
+         _error(ctx, "expected an initialiser");
+         break;
+      }
+      p = *ps;
+
+      if (_parse_token(ctx, SL_PP_LBRACKET, &p) == 0) {
+         unsigned int arr;
+
+         if (_parse_constant_expression(ctx, &p)) {
+            arr = VARIABLE_ARRAY_UNKNOWN;
+         } else {
+            arr = VARIABLE_ARRAY_EXPLICIT;
+         }
+         if (_parse_token(ctx, SL_PP_RBRACKET, &p) == 0) {
+            _update(ctx, e, arr);
+            *ps = p;
+            continue;
+         }
+         _error(ctx, "expected `]'");
+         break;
+      }
+      p = *ps;
+   }
+
+   _emit(ctx, &ps->out, DECLARATOR_NONE);
+   return 0;
+}
+
+
+static int
+_parse_declaration(struct parse_context *ctx,
+                   struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+   unsigned int e = _emit(ctx, &p.out, DECLARATION_FUNCTION_PROTOTYPE);
+
+   if (_parse_function_prototype(ctx, &p)) {
+      if (_parse_init_declarator_list(ctx, &p)) {
+         return -1;
+      }
+      _update(ctx, e, DECLARATION_INIT_DECLARATOR_LIST);
+   }
+   if (_parse_token(ctx, SL_PP_SEMICOLON, &p)) {
+      _error(ctx, "expected `;'");
+      return -1;
+   }
+   *ps = p;
+   return 0;
+}
+
+
+static int
+_parse_external_declaration(struct parse_context *ctx,
+                            struct parse_state *ps)
+{
+   struct parse_state p = *ps;
+   unsigned int e = _emit(ctx, &p.out, 0);
+
+   if (_parse_precision_stmt(ctx, &p) == 0) {
+      _update(ctx, e, DEFAULT_PRECISION);
+      *ps = p;
+      return 0;
+   }
+
+   if (_parse_function_definition(ctx, &p) == 0) {
+      _update(ctx, e, EXTERNAL_FUNCTION_DEFINITION);
+      *ps = p;
+      return 0;
+   }
+
+   if (_parse_invariant_stmt(ctx, &p) == 0) {
+      _update(ctx, e, INVARIANT_STMT);
+      *ps = p;
+      return 0;
+   }
+
+   if (_parse_declaration(ctx, &p) == 0) {
+      _update(ctx, e, EXTERNAL_DECLARATION);
+      *ps = p;
+      return 0;
+   }
+
+   _error(ctx, "expected an identifier");
+   return -1;
+}
+
+
+static int
+_parse_translation_unit(struct parse_context *ctx,
+                        struct parse_state *ps)
+{
+   _emit(ctx, &ps->out, REVISION);
+   if (_parse_external_declaration(ctx, ps)) {
+      return -1;
+   }
+   while (_parse_external_declaration(ctx, ps) == 0) {
+   }
+   _emit(ctx, &ps->out, EXTERNAL_NULL);
+   if (_parse_token(ctx, SL_PP_EOF, ps)) {
+      return -1;
+   }
+   return 0;
+}
+
+
+#define ADD_NAME_STR(CTX, NAME, STR)\
+   do {\
+      (CTX).dict.NAME = sl_pp_context_add_unique_str((CTX).context, (STR));\
+      if ((CTX).dict.NAME == -1) {\
+         return -1;\
+      }\
+   } while (0)
+
+#define ADD_NAME(CTX, NAME) ADD_NAME_STR(CTX, NAME, #NAME)
+
+
+int
+sl_cl_compile(struct sl_pp_context *context,
+              unsigned int shader_type,
+              unsigned int parsing_builtin,
+              unsigned char **output,
+              unsigned int *cboutput,
+              char *error,
+              unsigned int cberror)
+{
+   struct parse_context ctx;
+   struct parse_state ps;
+
+   ctx.context = context;
+
+   ADD_NAME_STR(ctx, _void, "void");
+   ADD_NAME_STR(ctx, _float, "float");
+   ADD_NAME_STR(ctx, _int, "int");
+   ADD_NAME_STR(ctx, _bool, "bool");
+   ADD_NAME(ctx, vec2);
+   ADD_NAME(ctx, vec3);
+   ADD_NAME(ctx, vec4);
+   ADD_NAME(ctx, bvec2);
+   ADD_NAME(ctx, bvec3);
+   ADD_NAME(ctx, bvec4);
+   ADD_NAME(ctx, ivec2);
+   ADD_NAME(ctx, ivec3);
+   ADD_NAME(ctx, ivec4);
+   ADD_NAME(ctx, mat2);
+   ADD_NAME(ctx, mat3);
+   ADD_NAME(ctx, mat4);
+   ADD_NAME(ctx, mat2x3);
+   ADD_NAME(ctx, mat3x2);
+   ADD_NAME(ctx, mat2x4);
+   ADD_NAME(ctx, mat4x2);
+   ADD_NAME(ctx, mat3x4);
+   ADD_NAME(ctx, mat4x3);
+   ADD_NAME(ctx, sampler1D);
+   ADD_NAME(ctx, sampler2D);
+   ADD_NAME(ctx, sampler3D);
+   ADD_NAME(ctx, samplerCube);
+   ADD_NAME(ctx, sampler1DShadow);
+   ADD_NAME(ctx, sampler2DShadow);
+   ADD_NAME(ctx, sampler2DRect);
+   ADD_NAME(ctx, sampler2DRectShadow);
+
+   ADD_NAME(ctx, invariant);
+
+   ADD_NAME(ctx, centroid);
+
+   ADD_NAME(ctx, precision);
+   ADD_NAME(ctx, lowp);
+   ADD_NAME(ctx, mediump);
+   ADD_NAME(ctx, highp);
+
+   ADD_NAME_STR(ctx, _const, "const");
+   ADD_NAME(ctx, attribute);
+   ADD_NAME(ctx, varying);
+   ADD_NAME(ctx, uniform);
+   ADD_NAME(ctx, __fixed_output);
+   ADD_NAME(ctx, __fixed_input);
+
+   ADD_NAME(ctx, in);
+   ADD_NAME(ctx, out);
+   ADD_NAME(ctx, inout);
+
+   ADD_NAME_STR(ctx, _struct, "struct");
+
+   ADD_NAME(ctx, __constructor);
+   ADD_NAME(ctx, __operator);
+   ADD_NAME_STR(ctx, ___asm, "__asm");
+
+   ADD_NAME_STR(ctx, _if, "if");
+   ADD_NAME_STR(ctx, _else, "else");
+   ADD_NAME_STR(ctx, _for, "for");
+   ADD_NAME_STR(ctx, _while, "while");
+   ADD_NAME_STR(ctx, _do, "do");
+
+   ADD_NAME_STR(ctx, _continue, "continue");
+   ADD_NAME_STR(ctx, _break, "break");
+   ADD_NAME_STR(ctx, _return, "return");
+   ADD_NAME(ctx, discard);
+
+   ADD_NAME_STR(ctx, _false, "false");
+   ADD_NAME_STR(ctx, _true, "true");
+
+   ctx.out_buf = NULL;
+   ctx.out_cap = 0;
+
+   ctx.shader_type = shader_type;
+   ctx.parsing_builtin = 1;
+
+   ctx.error[0] = '\0';
+   ctx.process_error = 0;
+
+   ctx.tokens_cap = 1024;
+   ctx.tokens_read = 0;
+   ctx.tokens = malloc(ctx.tokens_cap * sizeof(struct sl_pp_token_info));
+   if (!ctx.tokens) {
+      strncpy(error, "out of memory", cberror);
+      return -1;
+   }
+
+   ps.in = 0;
+   ps.out = 0;
+
+   if (_parse_translation_unit(&ctx, &ps)) {
+      strncpy(error, ctx.error, cberror);
+      free(ctx.tokens);
+      return -1;
+   }
+
+   *output = ctx.out_buf;
+   *cboutput = ps.out;
+   free(ctx.tokens);
+   return 0;
+}
diff --git a/src/glsl/cl/sl_cl_parse.h b/src/glsl/cl/sl_cl_parse.h
new file mode 100644 (file)
index 0000000..dd5791d
--- /dev/null
@@ -0,0 +1,40 @@
+/**************************************************************************
+ * 
+ * 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.
+ * 
+ **************************************************************************/
+
+#ifndef SL_CL_PARSE_H
+#define SL_CL_PARSE_H
+
+int
+sl_cl_compile(struct sl_pp_context *context,
+              unsigned int shader_type,
+              unsigned int parsing_builtin,
+              unsigned char **output,
+              unsigned int *cboutput,
+              char *error,
+              unsigned int cberror);
+
+#endif /* SL_CL_PARSE_H */
diff --git a/src/glsl/pp/Makefile b/src/glsl/pp/Makefile
new file mode 100644 (file)
index 0000000..fda1c42
--- /dev/null
@@ -0,0 +1,27 @@
+#src/glsl/pp/Makefile
+
+TOP = ../../..
+
+include $(TOP)/configs/current
+
+LIBNAME = glslpp
+
+C_SOURCES = \
+       sl_pp_context.c \
+       sl_pp_define.c \
+       sl_pp_dict.c \
+       sl_pp_error.c \
+       sl_pp_expression.c \
+       sl_pp_extension.c \
+       sl_pp_if.c \
+       sl_pp_line.c \
+       sl_pp_macro.c \
+       sl_pp_pragma.c \
+       sl_pp_process.c \
+       sl_pp_purify.c \
+       sl_pp_token.c \
+       sl_pp_token_util.c \
+       sl_pp_version.c
+
+include ../Makefile.template
+
diff --git a/src/glsl/pp/sl_pp_context.c b/src/glsl/pp/sl_pp_context.c
new file mode 100644 (file)
index 0000000..74a9bdd
--- /dev/null
@@ -0,0 +1,182 @@
+/**************************************************************************
+ * 
+ * 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 <stdlib.h>
+#include <string.h>
+#include "sl_pp_public.h"
+#include "sl_pp_context.h"
+
+
+struct sl_pp_context *
+sl_pp_context_create(const char *input,
+                     const struct sl_pp_purify_options *options)
+{
+   struct sl_pp_context *context;
+
+   context = calloc(1, sizeof(struct sl_pp_context));
+   if (!context) {
+      return NULL;
+   }
+
+   if (sl_pp_dict_init(context)) {
+      sl_pp_context_destroy(context);
+      return NULL;
+   }
+
+   context->getc_buf_capacity = 64;
+   context->getc_buf = malloc(context->getc_buf_capacity * sizeof(char));
+   if (!context->getc_buf) {
+      sl_pp_context_destroy(context);
+      return NULL;
+   }
+
+   if (sl_pp_token_buffer_init(&context->tokens, context)) {
+      sl_pp_context_destroy(context);
+      return NULL;
+   }
+
+   context->macro_tail = &context->macro;
+   context->if_ptr = SL_PP_MAX_IF_NESTING;
+   context->if_value = 1;
+   memset(context->error_msg, 0, sizeof(context->error_msg));
+   context->error_line = 1;
+   context->line = 1;
+   context->file = 0;
+
+   sl_pp_purify_state_init(&context->pure, input, options);
+
+   memset(&context->process_state, 0, sizeof(context->process_state));
+
+   return context;
+}
+
+void
+sl_pp_context_destroy(struct sl_pp_context *context)
+{
+   if (context) {
+      free(context->cstr_pool);
+      sl_pp_macro_free(context->macro);
+      free(context->getc_buf);
+      sl_pp_token_buffer_destroy(&context->tokens);
+      free(context->process_state.out);
+      free(context);
+   }
+}
+
+const char *
+sl_pp_context_error_message(const struct sl_pp_context *context)
+{
+   return context->error_msg;
+}
+
+void
+sl_pp_context_error_position(const struct sl_pp_context *context,
+                             unsigned int *file,
+                             unsigned int *line)
+{
+   if (file) {
+      *file = 0;
+   }
+   if (line) {
+      *line = context->error_line;
+   }
+}
+
+int
+sl_pp_context_add_predefined(struct sl_pp_context *context,
+                             const char *name,
+                             const char *value)
+{
+   struct sl_pp_predefined pre;
+
+   if (context->num_predefined == SL_PP_MAX_PREDEFINED) {
+      return -1;
+   }
+
+   pre.name = sl_pp_context_add_unique_str(context, name);
+   if (pre.name == -1) {
+      return -1;
+   }
+
+   pre.value = sl_pp_context_add_unique_str(context, value);
+   if (pre.value == -1) {
+      return -1;
+   }
+
+   context->predefined[context->num_predefined++] = pre;
+   return 0;
+}
+
+int
+sl_pp_context_add_unique_str(struct sl_pp_context *context,
+                             const char *str)
+{
+   unsigned int size;
+   unsigned int offset = 0;
+
+   size = strlen(str) + 1;
+
+   /* Find out if this is a unique string. */
+   while (offset < context->cstr_pool_len) {
+      const char *str2;
+      unsigned int size2;
+
+      str2 = &context->cstr_pool[offset];
+      size2 = strlen(str2) + 1;
+      if (size == size2 && !memcmp(str, str2, size - 1)) {
+         return offset;
+      }
+
+      offset += size2;
+   }
+
+   if (context->cstr_pool_len + size > context->cstr_pool_max) {
+      context->cstr_pool_max = (context->cstr_pool_len + size + 0xffff) & ~0xffff;
+      context->cstr_pool = realloc(context->cstr_pool, context->cstr_pool_max);
+   }
+
+   if (!context->cstr_pool) {
+      strcpy(context->error_msg, "out of memory");
+      return -1;
+   }
+
+   offset = context->cstr_pool_len;
+   memcpy(&context->cstr_pool[offset], str, size);
+   context->cstr_pool_len += size;
+
+   return offset;
+}
+
+const char *
+sl_pp_context_cstr(const struct sl_pp_context *context,
+                   int offset)
+{
+   if (offset == -1) {
+      return NULL;
+   }
+   return &context->cstr_pool[offset];
+}
diff --git a/src/glsl/pp/sl_pp_context.h b/src/glsl/pp/sl_pp_context.h
new file mode 100644 (file)
index 0000000..3eada38
--- /dev/null
@@ -0,0 +1,92 @@
+/**************************************************************************
+ * 
+ * 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.
+ * 
+ **************************************************************************/
+
+#ifndef SL_PP_CONTEXT_H
+#define SL_PP_CONTEXT_H
+
+#include "sl_pp_dict.h"
+#include "sl_pp_macro.h"
+#include "sl_pp_process.h"
+#include "sl_pp_purify.h"
+#include "sl_pp_token_util.h"
+
+
+#define SL_PP_MAX_IF_NESTING  64
+
+#define SL_PP_MAX_ERROR_MSG   1024
+
+#define SL_PP_MAX_EXTENSIONS  16
+
+#define SL_PP_MAX_PREDEFINED  16
+
+struct sl_pp_extension {
+   int name;         /*< VENDOR_extension_name */
+   int name_string;  /*< GL_VENDOR_extension_name */
+};
+
+struct sl_pp_predefined {
+   int name;
+   int value;
+};
+
+struct sl_pp_context {
+   char *cstr_pool;
+   unsigned int cstr_pool_max;
+   unsigned int cstr_pool_len;
+   struct sl_pp_dict dict;
+
+   struct sl_pp_macro *macro;
+   struct sl_pp_macro **macro_tail;
+
+   struct sl_pp_extension extensions[SL_PP_MAX_EXTENSIONS];
+   unsigned int num_extensions;
+
+   struct sl_pp_predefined predefined[SL_PP_MAX_PREDEFINED];
+   unsigned int num_predefined;
+
+   unsigned int if_stack[SL_PP_MAX_IF_NESTING];
+   unsigned int if_ptr;
+   unsigned int if_value;
+
+   char error_msg[SL_PP_MAX_ERROR_MSG];
+   unsigned int error_line;
+
+   unsigned int line;
+   unsigned int file;
+
+   struct sl_pp_purify_state pure;
+
+   char *getc_buf;
+   unsigned int getc_buf_size;
+   unsigned int getc_buf_capacity;
+
+   struct sl_pp_token_buffer tokens;
+
+   struct sl_pp_process_state process_state;
+};
+
+#endif /* SL_PP_CONTEXT_H */
diff --git a/src/glsl/pp/sl_pp_define.c b/src/glsl/pp/sl_pp_define.c
new file mode 100644 (file)
index 0000000..808a6a0
--- /dev/null
@@ -0,0 +1,238 @@
+/**************************************************************************
+ * 
+ * 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 <stdlib.h>
+#include <string.h>
+#include "sl_pp_context.h"
+#include "sl_pp_process.h"
+#include "sl_pp_public.h"
+
+
+static void
+skip_whitespace(const struct sl_pp_token_info *input,
+                unsigned int *first,
+                unsigned int last)
+{
+   while (*first < last && input[*first].token == SL_PP_WHITESPACE) {
+      (*first)++;
+   }
+}
+
+
+static int
+_parse_formal_args(struct sl_pp_context *context,
+                   const struct sl_pp_token_info *input,
+                   unsigned int *first,
+                   unsigned int last,
+                   struct sl_pp_macro *macro)
+{
+   struct sl_pp_macro_formal_arg **arg;
+
+   macro->num_args = 0;
+
+   skip_whitespace(input, first, last);
+   if (*first < last) {
+      if (input[*first].token == SL_PP_RPAREN) {
+         (*first)++;
+         return 0;
+      }
+   } else {
+      strcpy(context->error_msg, "expected either macro formal argument or `)'");
+      return -1;
+   }
+
+   arg = &macro->arg;
+
+   for (;;) {
+      if (*first < last && input[*first].token != SL_PP_IDENTIFIER) {
+         strcpy(context->error_msg, "expected macro formal argument");
+         return -1;
+      }
+
+      *arg = malloc(sizeof(struct sl_pp_macro_formal_arg));
+      if (!*arg) {
+         strcpy(context->error_msg, "out of memory");
+         return -1;
+      }
+
+      (**arg).name = input[*first].data.identifier;
+      (*first)++;
+
+      (**arg).next = NULL;
+      arg = &(**arg).next;
+
+      macro->num_args++;
+
+      skip_whitespace(input, first, last);
+      if (*first < last) {
+         if (input[*first].token == SL_PP_COMMA) {
+            (*first)++;
+            skip_whitespace(input, first, last);
+         } else if (input[*first].token == SL_PP_RPAREN) {
+            (*first)++;
+            return 0;
+         } else {
+            strcpy(context->error_msg, "expected either `,' or `)'");
+            return -1;
+         }
+      } else {
+         strcpy(context->error_msg, "expected either `,' or `)'");
+         return -1;
+      }
+   }
+
+   /* Should not gete here. */
+}
+
+
+int
+sl_pp_process_define(struct sl_pp_context *context,
+                     const struct sl_pp_token_info *input,
+                     unsigned int first,
+                     unsigned int last)
+{
+   int macro_name = -1;
+   struct sl_pp_macro *macro;
+   unsigned int i;
+   unsigned int body_len;
+   unsigned int j;
+
+   if (first < last && input[first].token == SL_PP_IDENTIFIER) {
+      macro_name = input[first].data.identifier;
+      first++;
+   }
+   if (macro_name == -1) {
+      strcpy(context->error_msg, "expected macro name");
+      return -1;
+   }
+
+   /* Check for reserved macro names */
+   {
+      const char *name = sl_pp_context_cstr(context, macro_name);
+
+      if (strstr(name, "__")) {
+         strcpy(context->error_msg, "macro names containing `__' are reserved");
+         return 1;
+      }
+      if (name[0] == 'G' && name[1] == 'L' && name[2] == '_') {
+         strcpy(context->error_msg, "macro names prefixed with `GL_' are reserved");
+         return 1;
+      }
+   }
+
+   for (macro = context->macro; macro; macro = macro->next) {
+      if (macro->name == macro_name) {
+         break;
+      }
+   }
+
+   if (!macro) {
+      macro = sl_pp_macro_new();
+      if (!macro) {
+         strcpy(context->error_msg, "out of memory");
+         return -1;
+      }
+
+      *context->macro_tail = macro;
+      context->macro_tail = &macro->next;
+   } else {
+      sl_pp_macro_reset(macro);
+   }
+
+   macro->name = macro_name;
+
+   /*
+    * If there is no whitespace between macro name and left paren, a macro
+    * formal argument list follows. This is the only place where the presence
+    * of a whitespace matters and it's the only reason why we are dealing
+    * with whitespace at this level.
+    */
+   if (first < last && input[first].token == SL_PP_LPAREN) {
+      first++;
+      if (_parse_formal_args(context, input, &first, last, macro)) {
+         return -1;
+      }
+   }
+
+   /* Calculate body size, trim out whitespace, make room for EOF. */
+   body_len = 1;
+   for (i = first; i < last; i++) {
+      if (input[i].token != SL_PP_WHITESPACE) {
+         body_len++;
+      }
+   }
+
+   macro->body = malloc(sizeof(struct sl_pp_token_info) * body_len);
+   if (!macro->body) {
+      strcpy(context->error_msg, "out of memory");
+      return -1;
+   }
+
+   for (j = 0, i = first; i < last; i++) {
+      if (input[i].token != SL_PP_WHITESPACE) {
+         macro->body[j++] = input[i];
+      }
+   }
+   macro->body[j++].token = SL_PP_EOF;
+
+   return 0;
+}
+
+
+int
+sl_pp_process_undef(struct sl_pp_context *context,
+                    const struct sl_pp_token_info *input,
+                    unsigned int first,
+                    unsigned int last)
+{
+   int macro_name = -1;
+   struct sl_pp_macro **pmacro;
+   struct sl_pp_macro *macro;
+
+   if (first < last && input[first].token == SL_PP_IDENTIFIER) {
+      macro_name = input[first].data.identifier;
+   }
+   if (macro_name == -1) {
+      return 0;
+   }
+
+   for (pmacro = &context->macro; *pmacro; pmacro = &(**pmacro).next) {
+      if ((**pmacro).name == macro_name) {
+         break;
+      }
+   }
+   if (!*pmacro) {
+      return 0;
+   }
+
+   macro = *pmacro;
+   *pmacro = macro->next;
+   macro->next = NULL;
+   sl_pp_macro_free(macro);
+
+   return 0;
+}
diff --git a/src/glsl/pp/sl_pp_dict.c b/src/glsl/pp/sl_pp_dict.c
new file mode 100644 (file)
index 0000000..062139e
--- /dev/null
@@ -0,0 +1,85 @@
+/**************************************************************************
+ * 
+ * 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 "sl_pp_public.h"
+#include "sl_pp_context.h"
+#include "sl_pp_dict.h"
+
+
+#define ADD_NAME_STR(CTX, NAME, STR)\
+   do {\
+      (CTX)->dict.NAME = sl_pp_context_add_unique_str((CTX), (STR));\
+      if ((CTX)->dict.NAME == -1) {\
+         return -1;\
+      }\
+   } while (0)
+
+#define ADD_NAME(CTX, NAME) ADD_NAME_STR(CTX, NAME, #NAME)
+
+
+int
+sl_pp_dict_init(struct sl_pp_context *context)
+{
+   ADD_NAME(context, all);
+
+   ADD_NAME(context, require);
+   ADD_NAME(context, enable);
+   ADD_NAME(context, warn);
+   ADD_NAME(context, disable);
+
+   ADD_NAME(context, defined);
+
+   ADD_NAME_STR(context, ___LINE__, "__LINE__");
+   ADD_NAME_STR(context, ___FILE__, "__FILE__");
+   ADD_NAME_STR(context, ___VERSION__, "__VERSION__");
+
+   ADD_NAME(context, optimize);
+   ADD_NAME(context, debug);
+
+   ADD_NAME(context, off);
+   ADD_NAME(context, on);
+
+   ADD_NAME(context, define);
+   ADD_NAME(context, elif);
+   ADD_NAME_STR(context, _else, "else");
+   ADD_NAME(context, endif);
+   ADD_NAME(context, error);
+   ADD_NAME(context, extension);
+   ADD_NAME_STR(context, _if, "if");
+   ADD_NAME(context, ifdef);
+   ADD_NAME(context, ifndef);
+   ADD_NAME(context, line);
+   ADD_NAME(context, pragma);
+   ADD_NAME(context, undef);
+
+   ADD_NAME(context, version);
+
+   ADD_NAME_STR(context, _0, "0");
+   ADD_NAME_STR(context, _1, "1");
+
+   return 0;
+}
diff --git a/src/glsl/pp/sl_pp_dict.h b/src/glsl/pp/sl_pp_dict.h
new file mode 100644 (file)
index 0000000..875217b
--- /dev/null
@@ -0,0 +1,77 @@
+/**************************************************************************
+ * 
+ * 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.
+ * 
+ **************************************************************************/
+
+#ifndef SL_PP_DICT_H
+#define SL_PP_DICT_H
+
+
+struct sl_pp_context;
+
+struct sl_pp_dict {
+   int all;
+
+   int require;
+   int enable;
+   int warn;
+   int disable;
+
+   int defined;
+
+   int ___LINE__;
+   int ___FILE__;
+   int ___VERSION__;
+
+   int optimize;
+   int debug;
+
+   int off;
+   int on;
+
+   int define;
+   int elif;
+   int _else;
+   int endif;
+   int error;
+   int extension;
+   int _if;
+   int ifdef;
+   int ifndef;
+   int line;
+   int pragma;
+   int undef;
+
+   int version;
+
+   int _0;
+   int _1;
+};
+
+
+int
+sl_pp_dict_init(struct sl_pp_context *context);
+
+#endif /* SL_PP_DICT_H */
diff --git a/src/glsl/pp/sl_pp_error.c b/src/glsl/pp/sl_pp_error.c
new file mode 100644 (file)
index 0000000..b628e37
--- /dev/null
@@ -0,0 +1,270 @@
+/**************************************************************************
+ * 
+ * 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 <stdlib.h>
+#include <string.h>
+#include "sl_pp_context.h"
+#include "sl_pp_process.h"
+#include "sl_pp_public.h"
+
+
+void
+sl_pp_process_error(struct sl_pp_context *context,
+                    const struct sl_pp_token_info *input,
+                    unsigned int first,
+                    unsigned int last)
+{
+   unsigned int out_len = 0;
+   unsigned int i;
+
+   for (i = first; i < last; i++) {
+      const char *s = NULL;
+      char buf[2];
+
+      switch (input[i].token) {
+      case SL_PP_WHITESPACE:
+         s = " ";
+         break;
+
+      case SL_PP_NEWLINE:
+         s = "\n";
+         break;
+
+      case SL_PP_HASH:
+         s = "#";
+         break;
+
+      case SL_PP_COMMA:
+         s = ",";
+         break;
+
+      case SL_PP_SEMICOLON:
+         s = ";";
+         break;
+
+      case SL_PP_LBRACE:
+         s = "{";
+         break;
+
+      case SL_PP_RBRACE:
+         s = "}";
+         break;
+
+      case SL_PP_LPAREN:
+         s = "(";
+         break;
+
+      case SL_PP_RPAREN:
+         s = ")";
+         break;
+
+      case SL_PP_LBRACKET:
+         s = "[";
+         break;
+
+      case SL_PP_RBRACKET:
+         s = "]";
+         break;
+
+      case SL_PP_DOT:
+         s = ".";
+         break;
+
+      case SL_PP_INCREMENT:
+         s = "++";
+         break;
+
+      case SL_PP_ADDASSIGN:
+         s = "+=";
+         break;
+
+      case SL_PP_PLUS:
+         s = "+";
+         break;
+
+      case SL_PP_DECREMENT:
+         s = "--";
+         break;
+
+      case SL_PP_SUBASSIGN:
+         s = "-=";
+         break;
+
+      case SL_PP_MINUS:
+         s = "-";
+         break;
+
+      case SL_PP_BITNOT:
+         s = "~";
+         break;
+
+      case SL_PP_NOTEQUAL:
+         s = "!=";
+         break;
+
+      case SL_PP_NOT:
+         s = "!";
+         break;
+
+      case SL_PP_MULASSIGN:
+         s = "*=";
+         break;
+
+      case SL_PP_STAR:
+         s = "*";
+         break;
+
+      case SL_PP_DIVASSIGN:
+         s = "/=";
+         break;
+
+      case SL_PP_SLASH:
+         s = "/";
+         break;
+
+      case SL_PP_MODASSIGN:
+         s = "%=";
+         break;
+
+      case SL_PP_MODULO:
+         s = "%";
+         break;
+
+      case SL_PP_LSHIFTASSIGN:
+         s = "<<=";
+         break;
+
+      case SL_PP_LSHIFT:
+         s = "<<";
+         break;
+
+      case SL_PP_LESSEQUAL:
+         s = "<=";
+         break;
+
+      case SL_PP_LESS:
+         s = "<";
+         break;
+
+      case SL_PP_RSHIFTASSIGN:
+         s = ">>=";
+         break;
+
+      case SL_PP_RSHIFT:
+         s = ">>";
+         break;
+
+      case SL_PP_GREATEREQUAL:
+         s = ">=";
+         break;
+
+      case SL_PP_GREATER:
+         s = ">";
+         break;
+
+      case SL_PP_EQUAL:
+         s = "==";
+         break;
+
+      case SL_PP_ASSIGN:
+         s = "=";
+         break;
+
+      case SL_PP_AND:
+         s = "&&";
+         break;
+
+      case SL_PP_BITANDASSIGN:
+         s = "&=";
+         break;
+
+      case SL_PP_BITAND:
+         s = "&";
+         break;
+
+      case SL_PP_XOR:
+         s = "^^";
+         break;
+
+      case SL_PP_BITXORASSIGN:
+         s = "^=";
+         break;
+
+      case SL_PP_BITXOR:
+         s = "^";
+         break;
+
+      case SL_PP_OR:
+         s = "||";
+         break;
+
+      case SL_PP_BITORASSIGN:
+         s = "|=";
+         break;
+
+      case SL_PP_BITOR:
+         s = "|";
+         break;
+
+      case SL_PP_QUESTION:
+         s = "?";
+         break;
+
+      case SL_PP_COLON:
+         s = ":";
+         break;
+
+      case SL_PP_IDENTIFIER:
+         s = sl_pp_context_cstr(context, input[i].data.identifier);
+         break;
+
+      case SL_PP_UINT:
+         s = sl_pp_context_cstr(context, input[i].data._uint);
+         break;
+
+      case SL_PP_FLOAT:
+         s = sl_pp_context_cstr(context, input[i].data._float);
+         break;
+
+      case SL_PP_OTHER:
+         buf[0] = input[i].data.other;
+         buf[1] = '\0';
+         s = buf;
+         break;
+
+      default:
+         strcpy(context->error_msg, "internal error");
+         return;
+      }
+
+      while (*s != '\0' && out_len < sizeof(context->error_msg) - 1) {
+         context->error_msg[out_len++] = *s++;
+      }
+   }
+
+   context->error_msg[out_len] = '\0';
+}
diff --git a/src/glsl/pp/sl_pp_expression.c b/src/glsl/pp/sl_pp_expression.c
new file mode 100644 (file)
index 0000000..ec90478
--- /dev/null
@@ -0,0 +1,411 @@
+/**************************************************************************
+ * 
+ * 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 <stdlib.h>
+#include <string.h>
+#include "sl_pp_expression.h"
+#include "sl_pp_public.h"
+
+
+struct parse_context {
+   struct sl_pp_context *context;
+   const struct sl_pp_token_info *input;
+};
+
+static int
+_parse_or(struct parse_context *ctx,
+          int *result);
+
+static int
+_parse_primary(struct parse_context *ctx,
+               int *result)
+{
+   if (ctx->input->token == SL_PP_UINT) {
+      *result = atoi(sl_pp_context_cstr(ctx->context, ctx->input->data._uint));
+      ctx->input++;
+   } else {
+      if (ctx->input->token != SL_PP_LPAREN) {
+         strcpy(ctx->context->error_msg, "expected `('");
+         return -1;
+      }
+      ctx->input++;
+      if (_parse_or(ctx, result)) {
+         return -1;
+      }
+      if (ctx->input->token != SL_PP_RPAREN) {
+         strcpy(ctx->context->error_msg, "expected `)'");
+         return -1;
+      }
+      ctx->input++;
+   }
+   return 0;
+}
+
+static int
+_parse_unary(struct parse_context *ctx,
+             int *result)
+{
+   if (!_parse_primary(ctx, result)) {
+      return 0;
+   }
+
+   switch (ctx->input->token) {
+   case SL_PP_PLUS:
+      ctx->input++;
+      if (_parse_unary(ctx, result)) {
+         return -1;
+      }
+      *result = +*result;
+      break;
+
+   case SL_PP_MINUS:
+      ctx->input++;
+      if (_parse_unary(ctx, result)) {
+         return -1;
+      }
+      *result = -*result;
+      break;
+
+   case SL_PP_NOT:
+      ctx->input++;
+      if (_parse_unary(ctx, result)) {
+         return -1;
+      }
+      *result = !*result;
+      break;
+
+   case SL_PP_BITNOT:
+      ctx->input++;
+      if (_parse_unary(ctx, result)) {
+         return -1;
+      }
+      *result = ~*result;
+      break;
+
+   default:
+      return -1;
+   }
+
+   return 0;
+}
+
+static int
+_parse_multiplicative(struct parse_context *ctx,
+                      int *result)
+{
+   if (_parse_unary(ctx, result)) {
+      return -1;
+   }
+   for (;;) {
+      int right;
+
+      switch (ctx->input->token) {
+      case SL_PP_STAR:
+         ctx->input++;
+         if (_parse_unary(ctx, &right)) {
+            return -1;
+         }
+         *result = *result * right;
+         break;
+
+      case SL_PP_SLASH:
+         ctx->input++;
+         if (_parse_unary(ctx, &right)) {
+            return -1;
+         }
+         *result = *result / right;
+         break;
+
+      case SL_PP_MODULO:
+         ctx->input++;
+         if (_parse_unary(ctx, &right)) {
+            return -1;
+         }
+         *result = *result % right;
+         break;
+
+      default:
+         return 0;
+      }
+   }
+}
+
+static int
+_parse_additive(struct parse_context *ctx,
+                int *result)
+{
+   if (_parse_multiplicative(ctx, result)) {
+      return -1;
+   }
+   for (;;) {
+      int right;
+
+      switch (ctx->input->token) {
+      case SL_PP_PLUS:
+         ctx->input++;
+         if (_parse_multiplicative(ctx, &right)) {
+            return -1;
+         }
+         *result = *result + right;
+         break;
+
+      case SL_PP_MINUS:
+         ctx->input++;
+         if (_parse_multiplicative(ctx, &right)) {
+            return -1;
+         }
+         *result = *result - right;
+         break;
+
+      default:
+         return 0;
+      }
+   }
+}
+
+static int
+_parse_shift(struct parse_context *ctx,
+             int *result)
+{
+   if (_parse_additive(ctx, result)) {
+      return -1;
+   }
+   for (;;) {
+      int right;
+
+      switch (ctx->input->token) {
+      case SL_PP_LSHIFT:
+         ctx->input++;
+         if (_parse_additive(ctx, &right)) {
+            return -1;
+         }
+         *result = *result << right;
+         break;
+
+      case SL_PP_RSHIFT:
+         ctx->input++;
+         if (_parse_additive(ctx, &right)) {
+            return -1;
+         }
+         *result = *result >> right;
+         break;
+
+      default:
+         return 0;
+      }
+   }
+}
+
+static int
+_parse_relational(struct parse_context *ctx,
+                  int *result)
+{
+   if (_parse_shift(ctx, result)) {
+      return -1;
+   }
+   for (;;) {
+      int right;
+
+      switch (ctx->input->token) {
+      case SL_PP_LESSEQUAL:
+         ctx->input++;
+         if (_parse_shift(ctx, &right)) {
+            return -1;
+         }
+         *result = *result <= right;
+         break;
+
+      case SL_PP_GREATEREQUAL:
+         ctx->input++;
+         if (_parse_shift(ctx, &right)) {
+            return -1;
+         }
+         *result = *result >= right;
+         break;
+
+      case SL_PP_LESS:
+         ctx->input++;
+         if (_parse_shift(ctx, &right)) {
+            return -1;
+         }
+         *result = *result < right;
+         break;
+
+      case SL_PP_GREATER:
+         ctx->input++;
+         if (_parse_shift(ctx, &right)) {
+            return -1;
+         }
+         *result = *result > right;
+         break;
+
+      default:
+         return 0;
+      }
+   }
+}
+
+static int
+_parse_equality(struct parse_context *ctx,
+                int *result)
+{
+   if (_parse_relational(ctx, result)) {
+      return -1;
+   }
+   for (;;) {
+      int right;
+
+      switch (ctx->input->token) {
+      case SL_PP_EQUAL:
+         ctx->input++;
+         if (_parse_relational(ctx, &right)) {
+            return -1;
+         }
+         *result = *result == right;
+         break;
+
+      case SL_PP_NOTEQUAL:
+         ctx->input++;
+         if (_parse_relational(ctx, &right)) {
+            return -1;
+         }
+         *result = *result != right;
+         break;
+
+      default:
+         return 0;
+      }
+   }
+}
+
+static int
+_parse_bitand(struct parse_context *ctx,
+              int *result)
+{
+   if (_parse_equality(ctx, result)) {
+      return -1;
+   }
+   while (ctx->input->token == SL_PP_BITAND) {
+      int right;
+
+      ctx->input++;
+      if (_parse_equality(ctx, &right)) {
+         return -1;
+      }
+      *result = *result & right;
+   }
+   return 0;
+}
+
+static int
+_parse_xor(struct parse_context *ctx,
+           int *result)
+{
+   if (_parse_bitand(ctx, result)) {
+      return -1;
+   }
+   while (ctx->input->token == SL_PP_XOR) {
+      int right;
+
+      ctx->input++;
+      if (_parse_bitand(ctx, &right)) {
+         return -1;
+      }
+      *result = *result ^ right;
+   }
+   return 0;
+}
+
+static int
+_parse_bitor(struct parse_context *ctx,
+             int *result)
+{
+   if (_parse_xor(ctx, result)) {
+      return -1;
+   }
+   while (ctx->input->token == SL_PP_BITOR) {
+      int right;
+
+      ctx->input++;
+      if (_parse_xor(ctx, &right)) {
+         return -1;
+      }
+      *result = *result | right;
+   }
+   return 0;
+}
+
+static int
+_parse_and(struct parse_context *ctx,
+           int *result)
+{
+   if (_parse_bitor(ctx, result)) {
+      return -1;
+   }
+   while (ctx->input->token == SL_PP_AND) {
+      int right;
+
+      ctx->input++;
+      if (_parse_bitor(ctx, &right)) {
+         return -1;
+      }
+      *result = *result && right;
+   }
+   return 0;
+}
+
+static int
+_parse_or(struct parse_context *ctx,
+          int *result)
+{
+   if (_parse_and(ctx, result)) {
+      return -1;
+   }
+   while (ctx->input->token == SL_PP_OR) {
+      int right;
+
+      ctx->input++;
+      if (_parse_and(ctx, &right)) {
+         return -1;
+      }
+      *result = *result || right;
+   }
+   return 0;
+}
+
+int
+sl_pp_execute_expression(struct sl_pp_context *context,
+                         const struct sl_pp_token_info *input,
+                         int *result)
+{
+   struct parse_context ctx;
+
+   ctx.context = context;
+   ctx.input = input;
+
+   return _parse_or(&ctx, result);
+}
diff --git a/src/glsl/pp/sl_pp_expression.h b/src/glsl/pp/sl_pp_expression.h
new file mode 100644 (file)
index 0000000..377d5b4
--- /dev/null
@@ -0,0 +1,40 @@
+/**************************************************************************
+ * 
+ * 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.
+ * 
+ **************************************************************************/
+
+#ifndef SL_PP_EXPRESSION_H
+#define SL_PP_EXPRESSION_H
+
+#include "sl_pp_context.h"
+#include "sl_pp_token.h"
+
+
+int
+sl_pp_execute_expression(struct sl_pp_context *context,
+                         const struct sl_pp_token_info *input,
+                         int *result);
+
+#endif /* SL_PP_EXPRESSION_H */
diff --git a/src/glsl/pp/sl_pp_extension.c b/src/glsl/pp/sl_pp_extension.c
new file mode 100644 (file)
index 0000000..8af5731
--- /dev/null
@@ -0,0 +1,171 @@
+/**************************************************************************
+ * 
+ * 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 <stdlib.h>
+#include <string.h>
+#include "sl_pp_context.h"
+#include "sl_pp_process.h"
+#include "sl_pp_public.h"
+
+
+int
+sl_pp_context_add_extension(struct sl_pp_context *context,
+                            const char *name,
+                            const char *name_string)
+{
+   struct sl_pp_extension ext;
+
+   if (context->num_extensions == SL_PP_MAX_EXTENSIONS) {
+      return -1;
+   }
+
+   ext.name = sl_pp_context_add_unique_str(context, name);
+   if (ext.name == -1) {
+      return -1;
+   }
+
+   ext.name_string = sl_pp_context_add_unique_str(context, name_string);
+   if (ext.name_string == -1) {
+      return -1;
+   }
+
+   context->extensions[context->num_extensions++] = ext;
+   return 0;
+}
+
+int
+sl_pp_process_extension(struct sl_pp_context *context,
+                        const struct sl_pp_token_info *input,
+                        unsigned int first,
+                        unsigned int last,
+                        struct sl_pp_process_state *state)
+{
+   int extension_name = -1;
+   int behavior = -1;
+   struct sl_pp_token_info out;
+
+   /* Grab the extension name. */
+   if (first < last && input[first].token == SL_PP_IDENTIFIER) {
+      extension_name = input[first].data.identifier;
+      first++;
+   }
+   if (extension_name == -1) {
+      strcpy(context->error_msg, "expected identifier after `#extension'");
+      return -1;
+   }
+
+   /* Make sure the extension is supported. */
+   if (extension_name == context->dict.all) {
+      out.data.extension = extension_name;
+   } else {
+      unsigned int i;
+
+      out.data.extension = -1;
+      for (i = 0; i < context->num_extensions; i++) {
+         if (extension_name == context->extensions[i].name_string) {
+            out.data.extension = extension_name;
+            break;
+         }
+      }
+   }
+
+   /* Grab the colon separating the extension name and behavior. */
+   while (first < last && input[first].token == SL_PP_WHITESPACE) {
+      first++;
+   }
+   if (first < last && input[first].token == SL_PP_COLON) {
+      first++;
+   } else {
+      strcpy(context->error_msg, "expected `:' after extension name");
+      return -1;
+   }
+   while (first < last && input[first].token == SL_PP_WHITESPACE) {
+      first++;
+   }
+
+   /* Grab the behavior name. */
+   if (first < last && input[first].token == SL_PP_IDENTIFIER) {
+      behavior = input[first].data.identifier;
+      first++;
+   }
+   if (behavior == -1) {
+      strcpy(context->error_msg, "expected identifier after `:'");
+      return -1;
+   }
+
+   if (behavior == context->dict.require) {
+      if (out.data.extension == -1) {
+         strcpy(context->error_msg, "the required extension is not supported");
+         return -1;
+      }
+      if (out.data.extension == context->dict.all) {
+         strcpy(context->error_msg, "invalid behavior for `all' extension: `require'");
+         return -1;
+      }
+      out.token = SL_PP_EXTENSION_REQUIRE;
+   } else if (behavior == context->dict.enable) {
+      if (out.data.extension == -1) {
+         /* Warning: the extension cannot be enabled. */
+         return 0;
+      }
+      if (out.data.extension == context->dict.all) {
+         strcpy(context->error_msg, "invalid behavior for `all' extension: `enable'");
+         return -1;
+      }
+      out.token = SL_PP_EXTENSION_ENABLE;
+   } else if (behavior == context->dict.warn) {
+      if (out.data.extension == -1) {
+         /* Warning: the extension is not supported. */
+         return 0;
+      }
+      out.token = SL_PP_EXTENSION_WARN;
+   } else if (behavior == context->dict.disable) {
+      if (out.data.extension == -1) {
+         /* Warning: the extension is not supported. */
+         return 0;
+      }
+      out.token = SL_PP_EXTENSION_DISABLE;
+   } else {
+      strcpy(context->error_msg, "unrecognised behavior name");
+      return -1;
+   }
+
+   /* Grab the end of line. */
+   while (first < last && input[first].token == SL_PP_WHITESPACE) {
+      first++;
+   }
+   if (first < last) {
+      strcpy(context->error_msg, "expected end of line after behavior name");
+      return -1;
+   }
+
+   if (sl_pp_process_out(state, &out)) {
+      return -1;
+   }
+
+   return 0;
+}
diff --git a/src/glsl/pp/sl_pp_if.c b/src/glsl/pp/sl_pp_if.c
new file mode 100644 (file)
index 0000000..f12f0f1
--- /dev/null
@@ -0,0 +1,344 @@
+/**************************************************************************
+ * 
+ * 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 <stdlib.h>
+#include <string.h>
+#include "sl_pp_expression.h"
+#include "sl_pp_process.h"
+
+
+static int
+_parse_defined(struct sl_pp_context *context,
+               struct sl_pp_token_buffer *buffer,
+               struct sl_pp_process_state *state)
+{
+   struct sl_pp_token_info input;
+   int parens = 0;
+   int macro_name;
+   struct sl_pp_macro *macro;
+   int defined = 0;
+   struct sl_pp_token_info result;
+
+   if (sl_pp_token_buffer_skip_white(buffer, &input)) {
+      return -1;
+   }
+
+   if (input.token == SL_PP_LPAREN) {
+      if (sl_pp_token_buffer_skip_white(buffer, &input)) {
+         return -1;
+      }
+      parens = 1;
+   }
+
+   if (input.token != SL_PP_IDENTIFIER) {
+      strcpy(context->error_msg, "expected an identifier");
+      return -1;
+   }
+
+   macro_name = input.data.identifier;
+   for (macro = context->macro; macro; macro = macro->next) {
+      if (macro->name == macro_name) {
+         defined = 1;
+         break;
+      }
+   }
+
+   if (parens) {
+      if (sl_pp_token_buffer_skip_white(buffer, &input)) {
+         return -1;
+      }
+      if (input.token != SL_PP_RPAREN) {
+         strcpy(context->error_msg, "expected `)'");
+         return -1;
+      }
+   }
+
+   result.token = SL_PP_UINT;
+   result.data._uint = (defined ? context->dict._1 : context->dict._0);
+
+   if (sl_pp_process_out(state, &result)) {
+      strcpy(context->error_msg, "out of memory");
+      return -1;
+   }
+
+   return 0;
+}
+
+static unsigned int
+_evaluate_if_stack(struct sl_pp_context *context)
+{
+   unsigned int i;
+
+   for (i = context->if_ptr; i < SL_PP_MAX_IF_NESTING; i++) {
+      if (!(context->if_stack[i] & 1)) {
+         return 0;
+      }
+   }
+   return 1;
+}
+
+static int
+_parse_if(struct sl_pp_context *context,
+          struct sl_pp_token_buffer *buffer)
+{
+   struct sl_pp_process_state state;
+   int found_end = 0;
+   struct sl_pp_token_info eof;
+   int result;
+
+   if (!context->if_ptr) {
+      strcpy(context->error_msg, "`#if' nesting too deep");
+      return -1;
+   }
+
+   memset(&state, 0, sizeof(state));
+   while (!found_end) {
+      struct sl_pp_token_info input;
+
+      sl_pp_token_buffer_get(buffer, &input);
+      switch (input.token) {
+      case SL_PP_WHITESPACE:
+         break;
+
+      case SL_PP_IDENTIFIER:
+         if (input.data.identifier == context->dict.defined) {
+            if (_parse_defined(context, buffer, &state)) {
+               free(state.out);
+               return -1;
+            }
+         } else {
+            sl_pp_token_buffer_unget(buffer, &input);
+            if (sl_pp_macro_expand(context, buffer, NULL, &state, sl_pp_macro_expand_unknown_to_0)) {
+               free(state.out);
+               return -1;
+            }
+         }
+         break;
+
+      case SL_PP_NEWLINE:
+      case SL_PP_EOF:
+         found_end = 1;
+         break;
+
+      default:
+         if (sl_pp_process_out(&state, &input)) {
+            strcpy(context->error_msg, "out of memory");
+            free(state.out);
+            return -1;
+         }
+      }
+   }
+
+   eof.token = SL_PP_EOF;
+   if (sl_pp_process_out(&state, &eof)) {
+      strcpy(context->error_msg, "out of memory");
+      free(state.out);
+      return -1;
+   }
+
+   if (sl_pp_execute_expression(context, state.out, &result)) {
+      free(state.out);
+      return -1;
+   }
+
+   free(state.out);
+
+   context->if_ptr--;
+   context->if_stack[context->if_ptr] = result ? 1 : 0;
+   context->if_value = _evaluate_if_stack(context);
+
+   return 0;
+}
+
+static int
+_parse_else(struct sl_pp_context *context)
+{
+   if (context->if_ptr == SL_PP_MAX_IF_NESTING) {
+      strcpy(context->error_msg, "no matching `#if'");
+      return -1;
+   }
+
+   /* Bit b1 indicates we already went through #else. */
+   if (context->if_stack[context->if_ptr] & 2) {
+      strcpy(context->error_msg, "no matching `#if'");
+      return -1;
+   }
+
+   /* Invert current condition value and mark that we are in the #else block. */
+   context->if_stack[context->if_ptr] = (1 - (context->if_stack[context->if_ptr] & 1)) | 2;
+   context->if_value = _evaluate_if_stack(context);
+
+   return 0;
+}
+
+int
+sl_pp_process_if(struct sl_pp_context *context,
+                 struct sl_pp_token_buffer *buffer)
+{
+   return _parse_if(context, buffer);
+}
+
+int
+sl_pp_process_ifdef(struct sl_pp_context *context,
+                    const struct sl_pp_token_info *input,
+                    unsigned int first,
+                    unsigned int last)
+{
+   unsigned int i;
+
+   if (!context->if_ptr) {
+      strcpy(context->error_msg, "`#if' nesting too deep");
+      return -1;
+   }
+
+   for (i = first; i < last; i++) {
+      switch (input[i].token) {
+      case SL_PP_IDENTIFIER:
+         {
+            struct sl_pp_macro *macro;
+            int macro_name = input[i].data.identifier;
+            int defined = 0;
+
+            for (macro = context->macro; macro; macro = macro->next) {
+               if (macro->name == macro_name) {
+                  defined = 1;
+                  break;
+               }
+            }
+
+            context->if_ptr--;
+            context->if_stack[context->if_ptr] = defined ? 1 : 0;
+            context->if_value = _evaluate_if_stack(context);
+         }
+         return 0;
+
+      case SL_PP_WHITESPACE:
+         break;
+
+      default:
+         strcpy(context->error_msg, "expected an identifier");
+         return -1;
+      }
+   }
+
+   strcpy(context->error_msg, "expected an identifier");
+   return -1;
+}
+
+int
+sl_pp_process_ifndef(struct sl_pp_context *context,
+                     const struct sl_pp_token_info *input,
+                     unsigned int first,
+                     unsigned int last)
+{
+   unsigned int i;
+
+   if (!context->if_ptr) {
+      strcpy(context->error_msg, "`#if' nesting too deep");
+      return -1;
+   }
+
+   for (i = first; i < last; i++) {
+      switch (input[i].token) {
+      case SL_PP_IDENTIFIER:
+         {
+            struct sl_pp_macro *macro;
+            int macro_name = input[i].data.identifier;
+            int defined = 0;
+
+            for (macro = context->macro; macro; macro = macro->next) {
+               if (macro->name == macro_name) {
+                  defined = 1;
+                  break;
+               }
+            }
+
+            context->if_ptr--;
+            context->if_stack[context->if_ptr] = defined ? 0 : 1;
+            context->if_value = _evaluate_if_stack(context);
+         }
+         return 0;
+
+      case SL_PP_WHITESPACE:
+         break;
+
+      default:
+         strcpy(context->error_msg, "expected an identifier");
+         return -1;
+      }
+   }
+
+   strcpy(context->error_msg, "expected an identifier");
+   return -1;
+}
+
+int
+sl_pp_process_elif(struct sl_pp_context *context,
+                   struct sl_pp_token_buffer *buffer)
+{
+   if (_parse_else(context)) {
+      return -1;
+   }
+
+   if (context->if_stack[context->if_ptr] & 1) {
+      context->if_ptr++;
+      if (_parse_if(context, buffer)) {
+         return -1;
+      }
+   }
+
+   /* We are still in the #if block. */
+   context->if_stack[context->if_ptr] = context->if_stack[context->if_ptr] & ~2;
+
+   return 0;
+}
+
+int
+sl_pp_process_else(struct sl_pp_context *context,
+                   const struct sl_pp_token_info *input,
+                   unsigned int first,
+                   unsigned int last)
+{
+   return _parse_else(context);
+}
+
+int
+sl_pp_process_endif(struct sl_pp_context *context,
+                    const struct sl_pp_token_info *input,
+                    unsigned int first,
+                    unsigned int last)
+{
+   if (context->if_ptr == SL_PP_MAX_IF_NESTING) {
+      strcpy(context->error_msg, "no matching `#if'");
+      return -1;
+   }
+
+   context->if_ptr++;
+   context->if_value = _evaluate_if_stack(context);
+
+   return 0;
+}
diff --git a/src/glsl/pp/sl_pp_line.c b/src/glsl/pp/sl_pp_line.c
new file mode 100644 (file)
index 0000000..6f7e9eb
--- /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 the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <stdlib.h>
+#include <string.h>
+#include "sl_pp_context.h"
+#include "sl_pp_public.h"
+#include "sl_pp_process.h"
+
+
+int
+sl_pp_process_line(struct sl_pp_context *context,
+                   struct sl_pp_token_buffer *buffer,
+                   struct sl_pp_process_state *pstate)
+{
+   struct sl_pp_process_state state;
+   int found_end = 0;
+   int line_number = -1;
+   int file_number = -1;
+   unsigned int line;
+   unsigned int file;
+
+   memset(&state, 0, sizeof(state));
+   while (!found_end) {
+      struct sl_pp_token_info input;
+
+      sl_pp_token_buffer_get(buffer, &input);
+      switch (input.token) {
+      case SL_PP_WHITESPACE:
+         break;
+
+      case SL_PP_IDENTIFIER:
+         sl_pp_token_buffer_unget(buffer, &input);
+         if (sl_pp_macro_expand(context, buffer, NULL, &state, sl_pp_macro_expand_normal)) {
+            free(state.out);
+            return -1;
+         }
+         break;
+
+      case SL_PP_NEWLINE:
+      case SL_PP_EOF:
+         found_end = 1;
+         break;
+
+      default:
+         if (sl_pp_process_out(&state, &input)) {
+            strcpy(context->error_msg, "out of memory");
+            free(state.out);
+            return -1;
+         }
+      }
+   }
+
+   if (state.out_len > 0 && state.out[0].token == SL_PP_UINT) {
+      line_number = state.out[0].data._uint;
+   } else {
+      strcpy(context->error_msg, "expected a number after `#line'");
+      free(state.out);
+      return -1;
+   }
+
+   if (state.out_len > 1) {
+      if (state.out[1].token == SL_PP_UINT) {
+         file_number = state.out[1].data._uint;
+      } else {
+         strcpy(context->error_msg, "expected a number after line number");
+         free(state.out);
+         return -1;
+      }
+
+      if (state.out_len > 2) {
+         strcpy(context->error_msg, "expected an end of line after file number");
+         free(state.out);
+         return -1;
+      }
+   }
+
+   free(state.out);
+
+   line = atoi(sl_pp_context_cstr(context, line_number));
+   if (file_number != -1) {
+      file = atoi(sl_pp_context_cstr(context, file_number));
+   } else {
+      file = context->file;
+   }
+
+   if (context->line != line || context->file != file) {
+      struct sl_pp_token_info ti;
+
+      ti.token = SL_PP_LINE;
+      ti.data.line.lineno = line;
+      ti.data.line.fileno = file;
+      if (sl_pp_process_out(pstate, &ti)) {
+         strcpy(context->error_msg, "out of memory");
+         return -1;
+      }
+
+      context->line = line;
+      context->file = file;
+   }
+
+   return 0;
+}
diff --git a/src/glsl/pp/sl_pp_macro.c b/src/glsl/pp/sl_pp_macro.c
new file mode 100644 (file)
index 0000000..9f520b8
--- /dev/null
@@ -0,0 +1,414 @@
+/**************************************************************************
+ * 
+ * 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 <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "sl_pp_context.h"
+#include "sl_pp_public.h"
+#include "sl_pp_macro.h"
+#include "sl_pp_process.h"
+
+
+static void
+_macro_init(struct sl_pp_macro *macro)
+{
+   macro->name = -1;
+   macro->num_args = -1;
+   macro->arg = NULL;
+   macro->body = NULL;
+}
+
+struct sl_pp_macro *
+sl_pp_macro_new(void)
+{
+   struct sl_pp_macro *macro;
+
+   macro = calloc(1, sizeof(struct sl_pp_macro));
+   if (macro) {
+      _macro_init(macro);
+   }
+   return macro;
+}
+
+static void
+_macro_destroy(struct sl_pp_macro *macro)
+{
+   struct sl_pp_macro_formal_arg *arg = macro->arg;
+
+   while (arg) {
+      struct sl_pp_macro_formal_arg *next_arg = arg->next;
+
+      free(arg);
+      arg = next_arg;
+   }
+
+   free(macro->body);
+}
+
+void
+sl_pp_macro_free(struct sl_pp_macro *macro)
+{
+   while (macro) {
+      struct sl_pp_macro *next_macro = macro->next;
+
+      _macro_destroy(macro);
+      free(macro);
+      macro = next_macro;
+   }
+}
+
+void
+sl_pp_macro_reset(struct sl_pp_macro *macro)
+{
+   _macro_destroy(macro);
+   _macro_init(macro);
+}
+
+static int
+_out_number(struct sl_pp_context *context,
+            struct sl_pp_process_state *state,
+            unsigned int number)
+{
+   char buf[32];
+   struct sl_pp_token_info ti;
+
+   sprintf(buf, "%u", number);
+
+   ti.token = SL_PP_UINT;
+   ti.data._uint = sl_pp_context_add_unique_str(context, buf);
+   if (sl_pp_process_out(state, &ti)) {
+      strcpy(context->error_msg, "out of memory");
+      return -1;
+   }
+
+   return 0;
+}
+
+int
+sl_pp_macro_expand(struct sl_pp_context *context,
+                   struct sl_pp_token_buffer *tokens,
+                   struct sl_pp_macro *local,
+                   struct sl_pp_process_state *state,
+                   enum sl_pp_macro_expand_behaviour behaviour)
+{
+   int mute = (behaviour == sl_pp_macro_expand_mute);
+   struct sl_pp_token_info input;
+   int macro_name;
+   struct sl_pp_macro *macro = NULL;
+   struct sl_pp_macro *actual_arg = NULL;
+   unsigned int j;
+
+   if (sl_pp_token_buffer_get(tokens, &input)) {
+      return -1;
+   }
+
+   if (input.token != SL_PP_IDENTIFIER) {
+      strcpy(context->error_msg, "expected an identifier");
+      return -1;
+   }
+
+   macro_name = input.data.identifier;
+
+   /* First look for predefined macros.
+    */
+
+   if (macro_name == context->dict.___LINE__) {
+      if (!mute && _out_number(context, state, context->line)) {
+         return -1;
+      }
+      return 0;
+   }
+   if (macro_name == context->dict.___FILE__) {
+      if (!mute && _out_number(context, state, context->file)) {
+         return -1;
+      }
+      return 0;
+   }
+   if (macro_name == context->dict.___VERSION__) {
+      if (!mute && _out_number(context, state, 110)) {
+         return -1;
+      }
+      return 0;
+   }
+
+   for (j = 0; j < context->num_predefined; j++) {
+      if (macro_name == context->predefined[j].name) {
+         if (!mute) {
+            struct sl_pp_token_info ti;
+
+            ti.token = SL_PP_UINT;
+            ti.data._uint = context->predefined[j].value;
+            if (sl_pp_process_out(state, &ti)) {
+               strcpy(context->error_msg, "out of memory");
+               return -1;
+            }
+         }
+         return 0;
+      }
+   }
+
+   /* Replace extension names with 1.
+    */
+   for (j = 0; j < context->num_extensions; j++) {
+      if (macro_name == context->extensions[j].name) {
+         if (!mute && _out_number(context, state, 1)) {
+            return -1;
+         }
+         return 0;
+      }
+   }
+
+   if (local) {
+      for (macro = local; macro; macro = macro->next) {
+         if (macro->name == macro_name) {
+            break;
+         }
+      }
+   }
+
+   if (!macro) {
+      for (macro = context->macro; macro; macro = macro->next) {
+         if (macro->name == macro_name) {
+            break;
+         }
+      }
+   }
+
+   if (!macro) {
+      if (behaviour == sl_pp_macro_expand_unknown_to_0) {
+         if (_out_number(context, state, 0)) {
+            strcpy(context->error_msg, "out of memory");
+            return -1;
+         }
+      } else if (!mute) {
+         if (sl_pp_process_out(state, &input)) {
+            strcpy(context->error_msg, "out of memory");
+            return -1;
+         }
+      }
+      return 0;
+   }
+
+   if (macro->num_args >= 0) {
+      if (sl_pp_token_buffer_skip_white(tokens, &input)) {
+         return -1;
+      }
+      if (input.token != SL_PP_LPAREN) {
+         strcpy(context->error_msg, "expected `('");
+         return -1;
+      }
+      if (sl_pp_token_buffer_skip_white(tokens, &input)) {
+         return -1;
+      }
+      sl_pp_token_buffer_unget(tokens, &input);
+   }
+
+   if (macro->num_args > 0) {
+      struct sl_pp_macro_formal_arg *formal_arg = macro->arg;
+      struct sl_pp_macro **pmacro = &actual_arg;
+
+      for (j = 0; j < (unsigned int)macro->num_args; j++) {
+         struct sl_pp_process_state arg_state;
+         int done = 0;
+         unsigned int paren_nesting = 0;
+         struct sl_pp_token_info eof;
+
+         memset(&arg_state, 0, sizeof(arg_state));
+
+         while (!done) {
+            if (sl_pp_token_buffer_get(tokens, &input)) {
+               goto fail_arg;
+            }
+            switch (input.token) {
+            case SL_PP_WHITESPACE:
+               break;
+
+            case SL_PP_COMMA:
+               if (!paren_nesting) {
+                  if (j < (unsigned int)macro->num_args - 1) {
+                     done = 1;
+                  } else {
+                     strcpy(context->error_msg, "too many actual macro arguments");
+                     goto fail_arg;
+                  }
+               } else {
+                  if (sl_pp_process_out(&arg_state, &input)) {
+                     strcpy(context->error_msg, "out of memory");
+                     goto fail_arg;
+                  }
+               }
+               break;
+
+            case SL_PP_LPAREN:
+               paren_nesting++;
+               if (sl_pp_process_out(&arg_state, &input)) {
+                  goto oom_arg;
+               }
+               break;
+
+            case SL_PP_RPAREN:
+               if (!paren_nesting) {
+                  if (j == (unsigned int)macro->num_args - 1) {
+                     done = 1;
+                  } else {
+                     strcpy(context->error_msg, "too few actual macro arguments");
+                     goto fail_arg;
+                  }
+               } else {
+                  paren_nesting--;
+                  if (sl_pp_process_out(&arg_state, &input)) {
+                     goto oom_arg;
+                  }
+               }
+               break;
+
+            case SL_PP_IDENTIFIER:
+               sl_pp_token_buffer_unget(tokens, &input);
+               if (sl_pp_macro_expand(context, tokens, local, &arg_state, sl_pp_macro_expand_normal)) {
+                  goto fail_arg;
+               }
+               break;
+
+            case SL_PP_EOF:
+               strcpy(context->error_msg, "too few actual macro arguments");
+               goto fail_arg;
+
+            default:
+               if (sl_pp_process_out(&arg_state, &input)) {
+                  goto oom_arg;
+               }
+            }
+         }
+
+         eof.token = SL_PP_EOF;
+         if (sl_pp_process_out(&arg_state, &eof)) {
+            goto oom_arg;
+         }
+
+         *pmacro = sl_pp_macro_new();
+         if (!*pmacro) {
+            goto oom_arg;
+         }
+
+         (**pmacro).name = formal_arg->name;
+         (**pmacro).body = arg_state.out;
+
+         formal_arg = formal_arg->next;
+         pmacro = &(**pmacro).next;
+
+         continue;
+
+oom_arg:
+         strcpy(context->error_msg, "out of memory");
+fail_arg:
+         free(arg_state.out);
+         goto fail;
+      }
+   }
+
+   /* Right paren for non-empty argument list has already been eaten. */
+   if (macro->num_args == 0) {
+      if (sl_pp_token_buffer_skip_white(tokens, &input)) {
+         goto fail;
+      }
+      if (input.token != SL_PP_RPAREN) {
+         strcpy(context->error_msg, "expected `)'");
+         goto fail;
+      }
+   }
+
+   /* XXX: This is all wrong, we should be ungetting all tokens
+    *      back to the main token buffer.
+    */
+   {
+      struct sl_pp_token_buffer buffer;
+
+      /* Seek to the end.
+       */
+      for (j = 0; macro->body[j].token != SL_PP_EOF; j++) {
+      }
+      j++;
+
+      /* Create a context-less token buffer since we are not going to underrun
+       * its internal buffer.
+       */
+      if (sl_pp_token_buffer_init(&buffer, NULL)) {
+         strcpy(context->error_msg, "out of memory");
+         goto fail;
+      }
+
+      /* Unget the tokens in reverse order so later they will be fetched correctly.
+       */
+      for (; j > 0; j--) {
+         sl_pp_token_buffer_unget(&buffer, &macro->body[j - 1]);
+      }
+
+      /* Expand.
+       */
+      for (;;) {
+         struct sl_pp_token_info input;
+
+         sl_pp_token_buffer_get(&buffer, &input);
+         switch (input.token) {
+         case SL_PP_NEWLINE:
+            if (sl_pp_process_out(state, &input)) {
+               strcpy(context->error_msg, "out of memory");
+               sl_pp_token_buffer_destroy(&buffer);
+               goto fail;
+            }
+            break;
+
+         case SL_PP_IDENTIFIER:
+            sl_pp_token_buffer_unget(&buffer, &input);
+            if (sl_pp_macro_expand(context, &buffer, actual_arg, state, behaviour)) {
+               sl_pp_token_buffer_destroy(&buffer);
+               goto fail;
+            }
+            break;
+
+         case SL_PP_EOF:
+            sl_pp_token_buffer_destroy(&buffer);
+            sl_pp_macro_free(actual_arg);
+            return 0;
+
+         default:
+            if (!mute) {
+               if (sl_pp_process_out(state, &input)) {
+                  strcpy(context->error_msg, "out of memory");
+                  sl_pp_token_buffer_destroy(&buffer);
+                  goto fail;
+               }
+            }
+         }
+      }
+   }
+
+fail:
+   sl_pp_macro_free(actual_arg);
+   return -1;
+}
diff --git a/src/glsl/pp/sl_pp_macro.h b/src/glsl/pp/sl_pp_macro.h
new file mode 100644 (file)
index 0000000..1d21068
--- /dev/null
@@ -0,0 +1,73 @@
+/**************************************************************************
+ * 
+ * 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.
+ * 
+ **************************************************************************/
+
+#ifndef SL_PP_MACRO_H
+#define SL_PP_MACRO_H
+
+#include "sl_pp_token.h"
+
+
+struct sl_pp_context;
+struct sl_pp_process_state;
+struct sl_pp_token_buffer;
+
+struct sl_pp_macro_formal_arg {
+   int name;
+   struct sl_pp_macro_formal_arg *next;
+};
+
+struct sl_pp_macro {
+   int name;
+   int num_args;                       /* -1 means no args, 0 means `()' */
+   struct sl_pp_macro_formal_arg *arg;
+   struct sl_pp_token_info *body;
+   struct sl_pp_macro *next;
+};
+
+struct sl_pp_macro *
+sl_pp_macro_new(void);
+
+void
+sl_pp_macro_free(struct sl_pp_macro *macro);
+
+void
+sl_pp_macro_reset(struct sl_pp_macro *macro);
+
+enum sl_pp_macro_expand_behaviour {
+   sl_pp_macro_expand_normal,
+   sl_pp_macro_expand_mute,
+   sl_pp_macro_expand_unknown_to_0
+};
+
+int
+sl_pp_macro_expand(struct sl_pp_context *context,
+                   struct sl_pp_token_buffer *tokens,
+                   struct sl_pp_macro *local,
+                   struct sl_pp_process_state *state,
+                   enum sl_pp_macro_expand_behaviour behaviour);
+
+#endif /* SL_PP_MACRO_H */
diff --git a/src/glsl/pp/sl_pp_pragma.c b/src/glsl/pp/sl_pp_pragma.c
new file mode 100644 (file)
index 0000000..caf4c63
--- /dev/null
@@ -0,0 +1,109 @@
+/**************************************************************************
+ * 
+ * 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 <stdlib.h>
+#include <string.h>
+#include "sl_pp_context.h"
+#include "sl_pp_process.h"
+
+
+int
+sl_pp_process_pragma(struct sl_pp_context *context,
+                     const struct sl_pp_token_info *input,
+                     unsigned int first,
+                     unsigned int last,
+                     struct sl_pp_process_state *state)
+{
+   int pragma_name = -1;
+   struct sl_pp_token_info out;
+   int arg_name = -1;
+
+   if (first < last && input[first].token == SL_PP_IDENTIFIER) {
+      pragma_name = input[first].data.identifier;
+      first++;
+   }
+   if (pragma_name == -1) {
+      return 0;
+   }
+
+   if (pragma_name == context->dict.optimize) {
+      out.token = SL_PP_PRAGMA_OPTIMIZE;
+   } else if (pragma_name == context->dict.debug) {
+      out.token = SL_PP_PRAGMA_DEBUG;
+   } else {
+      return 0;
+   }
+
+   while (first < last && input[first].token == SL_PP_WHITESPACE) {
+      first++;
+   }
+
+   if (first < last && input[first].token == SL_PP_LPAREN) {
+      first++;
+   } else {
+      return 0;
+   }
+
+   while (first < last && input[first].token == SL_PP_WHITESPACE) {
+      first++;
+   }
+
+   if (first < last && input[first].token == SL_PP_IDENTIFIER) {
+      arg_name = input[first].data.identifier;
+      first++;
+   }
+   if (arg_name == -1) {
+      return 0;
+   }
+
+   if (arg_name == context->dict.off) {
+      out.data.pragma = 0;
+   } else if (arg_name == context->dict.on) {
+      out.data.pragma = 1;
+   } else {
+      return 0;
+   }
+
+   while (first < last && input[first].token == SL_PP_WHITESPACE) {
+      first++;
+   }
+
+   if (first < last && input[first].token == SL_PP_RPAREN) {
+      first++;
+   } else {
+      return 0;
+   }
+
+   /* Ignore the tokens that follow. */
+
+   if (sl_pp_process_out(state, &out)) {
+      strcpy(context->error_msg, "out of memory");
+      return -1;
+   }
+
+   return 0;
+}
diff --git a/src/glsl/pp/sl_pp_process.c b/src/glsl/pp/sl_pp_process.c
new file mode 100644 (file)
index 0000000..f89986d
--- /dev/null
@@ -0,0 +1,327 @@
+/**************************************************************************
+ * 
+ * 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 <stdlib.h>
+#include <string.h>
+#include "sl_pp_context.h"
+#include "sl_pp_process.h"
+#include "sl_pp_public.h"
+
+
+int
+sl_pp_process_out(struct sl_pp_process_state *state,
+                  const struct sl_pp_token_info *token)
+{
+   if (state->out_len >= state->out_max) {
+      unsigned int new_max = state->out_max;
+
+      if (new_max < 0x100) {
+         new_max = 0x100;
+      } else if (new_max < 0x10000) {
+         new_max *= 2;
+      } else {
+         new_max += 0x10000;
+      }
+
+      state->out = realloc(state->out, new_max * sizeof(struct sl_pp_token_info));
+      if (!state->out) {
+         return -1;
+      }
+      state->out_max = new_max;
+   }
+
+   state->out[state->out_len++] = *token;
+   return 0;
+}
+
+int
+sl_pp_process_get(struct sl_pp_context *context,
+                  struct sl_pp_token_info *output)
+{
+   if (!context->process_state.out) {
+      if (context->line > 1) {
+         struct sl_pp_token_info ti;
+
+         ti.token = SL_PP_LINE;
+         ti.data.line.lineno = context->line - 1;
+         ti.data.line.fileno = context->file;
+         if (sl_pp_process_out(&context->process_state, &ti)) {
+            strcpy(context->error_msg, "out of memory");
+            return -1;
+         }
+
+         ti.token = SL_PP_NEWLINE;
+         if (sl_pp_process_out(&context->process_state, &ti)) {
+            strcpy(context->error_msg, "out of memory");
+            return -1;
+         }
+      }
+   }
+
+   for (;;) {
+      struct sl_pp_token_info input;
+      int found_eof = 0;
+
+      if (context->process_state.out_len) {
+         *output = context->process_state.out[0];
+
+         if (context->process_state.out_len > 1) {
+            unsigned int i;
+
+            for (i = 1; i < context->process_state.out_len; i++) {
+               context->process_state.out[i - 1] = context->process_state.out[i];
+            }
+         }
+         context->process_state.out_len--;
+
+         return 0;
+      }
+
+      if (sl_pp_token_buffer_skip_white(&context->tokens, &input)) {
+         return -1;
+      }
+      if (input.token == SL_PP_HASH) {
+         if (sl_pp_token_buffer_skip_white(&context->tokens, &input)) {
+            return -1;
+         }
+         switch (input.token) {
+         case SL_PP_IDENTIFIER:
+            {
+               int name;
+               int found_eol = 0;
+               struct sl_pp_token_info endof;
+               struct sl_pp_token_peek peek;
+               int result = 0;
+
+               /* Directive name. */
+               name = input.data.identifier;
+
+               if (sl_pp_token_buffer_skip_white(&context->tokens, &input)) {
+                  return -1;
+               }
+               sl_pp_token_buffer_unget(&context->tokens, &input);
+
+               if (sl_pp_token_peek_init(&peek, &context->tokens)) {
+                  return -1;
+               }
+
+               while (!found_eol) {
+                  if (sl_pp_token_peek_get(&peek, &input)) {
+                     sl_pp_token_peek_destroy(&peek);
+                     return -1;
+                  }
+                  switch (input.token) {
+                  case SL_PP_NEWLINE:
+                     /* Preserve newline just for the sake of line numbering. */
+                     endof = input;
+                     found_eol = 1;
+                     break;
+
+                  case SL_PP_EOF:
+                     endof = input;
+                     found_eof = 1;
+                     found_eol = 1;
+                     break;
+
+                  default:
+                     break;
+                  }
+               }
+
+               if (name == context->dict._if) {
+                  struct sl_pp_token_buffer buffer;
+
+                  result = sl_pp_token_peek_to_buffer(&peek, &buffer);
+                  if (result == 0) {
+                     result = sl_pp_process_if(context, &buffer);
+                     sl_pp_token_buffer_destroy(&buffer);
+                  }
+               } else if (name == context->dict.ifdef) {
+                  result = sl_pp_process_ifdef(context, peek.tokens, 0, peek.size - 1);
+               } else if (name == context->dict.ifndef) {
+                  result = sl_pp_process_ifndef(context, peek.tokens, 0, peek.size - 1);
+               } else if (name == context->dict.elif) {
+                  struct sl_pp_token_buffer buffer;
+
+                  result = sl_pp_token_peek_to_buffer(&peek, &buffer);
+                  if (result == 0) {
+                     result = sl_pp_process_elif(context, &buffer);
+                     sl_pp_token_buffer_destroy(&buffer);
+                  }
+               } else if (name == context->dict._else) {
+                  result = sl_pp_process_else(context, peek.tokens, 0, peek.size - 1);
+               } else if (name == context->dict.endif) {
+                  result = sl_pp_process_endif(context, peek.tokens, 0, peek.size - 1);
+               } else if (context->if_value) {
+                  if (name == context->dict.define) {
+                     result = sl_pp_process_define(context, peek.tokens, 0, peek.size - 1);
+                  } else if (name == context->dict.error) {
+                     sl_pp_process_error(context, peek.tokens, 0, peek.size - 1);
+                     result = -1;
+                  } else if (name == context->dict.extension) {
+                     result = sl_pp_process_extension(context, peek.tokens, 0, peek.size - 1, &context->process_state);
+                  } else if (name == context->dict.line) {
+                     struct sl_pp_token_buffer buffer;
+
+                     result = sl_pp_token_peek_to_buffer(&peek, &buffer);
+                     if (result == 0) {
+                        result = sl_pp_process_line(context, &buffer, &context->process_state);
+                        sl_pp_token_buffer_destroy(&buffer);
+                     }
+                  } else if (name == context->dict.pragma) {
+                     result = sl_pp_process_pragma(context, peek.tokens, 0, peek.size - 1, &context->process_state);
+                  } else if (name == context->dict.undef) {
+                     result = sl_pp_process_undef(context, peek.tokens, 0, peek.size - 1);
+                  } else {
+                     strcpy(context->error_msg, "unrecognised directive name");
+                     result = -1;
+                  }
+               }
+
+               sl_pp_token_peek_commit(&peek);
+               sl_pp_token_peek_destroy(&peek);
+
+               if (result) {
+                  return result;
+               }
+
+               if (sl_pp_process_out(&context->process_state, &endof)) {
+                  strcpy(context->error_msg, "out of memory");
+                  return -1;
+               }
+               context->line++;
+            }
+            break;
+
+         case SL_PP_NEWLINE:
+            /* Empty directive. */
+            if (sl_pp_process_out(&context->process_state, &input)) {
+               strcpy(context->error_msg, "out of memory");
+               return -1;
+            }
+            context->line++;
+            break;
+
+         case SL_PP_EOF:
+            /* Empty directive. */
+            if (sl_pp_process_out(&context->process_state, &input)) {
+               strcpy(context->error_msg, "out of memory");
+               return -1;
+            }
+            found_eof = 1;
+            break;
+
+         default:
+            strcpy(context->error_msg, "expected a directive name");
+            return -1;
+         }
+      } else {
+         int found_eol = 0;
+
+         sl_pp_token_buffer_unget(&context->tokens, &input);
+
+         while (!found_eol) {
+            if (sl_pp_token_buffer_get(&context->tokens, &input)) {
+               return -1;
+            }
+
+            switch (input.token) {
+            case SL_PP_WHITESPACE:
+               /* Drop whitespace all together at this point. */
+               break;
+
+            case SL_PP_NEWLINE:
+               /* Preserve newline just for the sake of line numbering. */
+               if (sl_pp_process_out(&context->process_state, &input)) {
+                  strcpy(context->error_msg, "out of memory");
+                  return -1;
+               }
+               context->line++;
+               found_eol = 1;
+               break;
+
+            case SL_PP_EOF:
+               if (sl_pp_process_out(&context->process_state, &input)) {
+                  strcpy(context->error_msg, "out of memory");
+                  return -1;
+               }
+               found_eof = 1;
+               found_eol = 1;
+               break;
+
+            case SL_PP_IDENTIFIER:
+               sl_pp_token_buffer_unget(&context->tokens, &input);
+               if (sl_pp_macro_expand(context, &context->tokens, NULL, &context->process_state,
+                                      context->if_value ? sl_pp_macro_expand_normal : sl_pp_macro_expand_mute)) {
+                  return -1;
+               }
+               break;
+
+            default:
+               if (context->if_value) {
+                  if (sl_pp_process_out(&context->process_state, &input)) {
+                     strcpy(context->error_msg, "out of memory");
+                     return -1;
+                  }
+               }
+            }
+         }
+      }
+
+      if (found_eof) {
+         if (context->if_ptr != SL_PP_MAX_IF_NESTING) {
+            strcpy(context->error_msg, "expected `#endif' directive");
+            return -1;
+         }
+      }
+   }
+}
+
+int
+sl_pp_process(struct sl_pp_context *context,
+              struct sl_pp_token_info **output)
+{
+   struct sl_pp_process_state state;
+
+   memset(&state, 0, sizeof(state));
+   for (;;) {
+      struct sl_pp_token_info input;
+
+      if (sl_pp_process_get(context, &input)) {
+         free(state.out);
+         return -1;
+      }
+      if (sl_pp_process_out(&state, &input)) {
+         free(state.out);
+         return -1;
+      }
+      if (input.token == SL_PP_EOF) {
+         *output = state.out;
+         return 0;
+      }
+   }
+}
diff --git a/src/glsl/pp/sl_pp_process.h b/src/glsl/pp/sl_pp_process.h
new file mode 100644 (file)
index 0000000..fe6ff0d
--- /dev/null
@@ -0,0 +1,116 @@
+/**************************************************************************
+ * 
+ * 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.
+ * 
+ **************************************************************************/
+
+#ifndef SL_PP_PROCESS_H
+#define SL_PP_PROCESS_H
+
+#include "sl_pp_macro.h"
+#include "sl_pp_token.h"
+
+
+struct sl_pp_context;
+
+struct sl_pp_process_state {
+   struct sl_pp_token_info *out;
+   unsigned int out_len;
+   unsigned int out_max;
+};
+
+int
+sl_pp_process_define(struct sl_pp_context *context,
+                     const struct sl_pp_token_info *input,
+                     unsigned int first,
+                     unsigned int last);
+
+int
+sl_pp_process_undef(struct sl_pp_context *context,
+                    const struct sl_pp_token_info *input,
+                    unsigned int first,
+                    unsigned int last);
+
+int
+sl_pp_process_if(struct sl_pp_context *context,
+                 struct sl_pp_token_buffer *input);
+
+int
+sl_pp_process_ifdef(struct sl_pp_context *context,
+                    const struct sl_pp_token_info *input,
+                    unsigned int first,
+                    unsigned int last);
+
+int
+sl_pp_process_ifndef(struct sl_pp_context *context,
+                     const struct sl_pp_token_info *input,
+                     unsigned int first,
+                     unsigned int last);
+
+int
+sl_pp_process_elif(struct sl_pp_context *context,
+                   struct sl_pp_token_buffer *buffer);
+
+int
+sl_pp_process_else(struct sl_pp_context *context,
+                   const struct sl_pp_token_info *input,
+                   unsigned int first,
+                   unsigned int last);
+
+int
+sl_pp_process_endif(struct sl_pp_context *context,
+                    const struct sl_pp_token_info *input,
+                    unsigned int first,
+                    unsigned int last);
+
+void
+sl_pp_process_error(struct sl_pp_context *context,
+                    const struct sl_pp_token_info *input,
+                    unsigned int first,
+                    unsigned int last);
+
+int
+sl_pp_process_pragma(struct sl_pp_context *context,
+                     const struct sl_pp_token_info *input,
+                     unsigned int first,
+                     unsigned int last,
+                     struct sl_pp_process_state *state);
+
+int
+sl_pp_process_extension(struct sl_pp_context *context,
+                        const struct sl_pp_token_info *input,
+                        unsigned int first,
+                        unsigned int last,
+                        struct sl_pp_process_state *state);
+
+int
+sl_pp_process_line(struct sl_pp_context *context,
+                   struct sl_pp_token_buffer *buffer,
+                   struct sl_pp_process_state *state);
+
+int
+sl_pp_process_out(struct sl_pp_process_state *state,
+                  const struct sl_pp_token_info *token);
+
+#endif /* SL_PP_PROCESS_H */
diff --git a/src/glsl/pp/sl_pp_public.h b/src/glsl/pp/sl_pp_public.h
new file mode 100644 (file)
index 0000000..12528d6
--- /dev/null
@@ -0,0 +1,84 @@
+/**************************************************************************
+ * 
+ * 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.
+ * 
+ **************************************************************************/
+
+#ifndef SL_PP_PUBLIC_H
+#define SL_PP_PUBLIC_H
+
+
+struct sl_pp_context;
+
+
+#include "sl_pp_purify.h"
+#include "sl_pp_token.h"
+
+
+struct sl_pp_context *
+sl_pp_context_create(const char *input,
+                     const struct sl_pp_purify_options *options);
+
+void
+sl_pp_context_destroy(struct sl_pp_context *context);
+
+const char *
+sl_pp_context_error_message(const struct sl_pp_context *context);
+
+void
+sl_pp_context_error_position(const struct sl_pp_context *context,
+                             unsigned int *file,
+                             unsigned int *line);
+
+int
+sl_pp_context_add_extension(struct sl_pp_context *context,
+                            const char *name,
+                            const char *name_string);
+
+int
+sl_pp_context_add_predefined(struct sl_pp_context *context,
+                             const char *name,
+                             const char *value);
+
+int
+sl_pp_context_add_unique_str(struct sl_pp_context *context,
+                             const char *str);
+
+const char *
+sl_pp_context_cstr(const struct sl_pp_context *context,
+                   int offset);
+
+int
+sl_pp_version(struct sl_pp_context *context,
+              unsigned int *version);
+
+int
+sl_pp_process_get(struct sl_pp_context *context,
+                  struct sl_pp_token_info *output);
+
+int
+sl_pp_process(struct sl_pp_context *context,
+              struct sl_pp_token_info **output);
+
+#endif /* SL_PP_PUBLIC_H */
diff --git a/src/glsl/pp/sl_pp_purify.c b/src/glsl/pp/sl_pp_purify.c
new file mode 100644 (file)
index 0000000..b50f819
--- /dev/null
@@ -0,0 +1,302 @@
+/**************************************************************************
+ * 
+ * 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 <stdlib.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include "sl_pp_purify.h"
+
+
+/*
+ * Preprocessor purifier performs the following tasks.
+ * - Convert all variants of newlines into a Unix newline.
+ * - Merge continued lines into a single long line.
+ * - Remove line comments and replace block comments with whitespace.
+ */
+
+
+static unsigned int
+_purify_newline(const char *input,
+                char *out,
+                unsigned int *current_line)
+{
+   if (input[0] == '\n') {
+      *out = '\n';
+      (*current_line)++;
+      if (input[1] == '\r') {
+         /*
+          * The GLSL spec is not explicit about whether this
+          * combination is a valid newline or not.
+          * Let's assume it is acceptable.
+          */
+         return 2;
+      }
+      return 1;
+   }
+   if (input[0] == '\r') {
+      *out = '\n';
+      (*current_line)++;
+      if (input[1] == '\n') {
+         return 2;
+      }
+      return 1;
+   }
+   *out = input[0];
+   return 1;
+}
+
+
+static unsigned int
+_purify_backslash(const char *input,
+                  char *out,
+                  unsigned int *current_line)
+{
+   unsigned int eaten = 0;
+
+   for (;;) {
+      if (input[0] == '\\') {
+         char next;
+         unsigned int next_eaten;
+         unsigned int next_line = *current_line;
+
+         eaten++;
+         input++;
+
+         next_eaten = _purify_newline(input, &next, &next_line);
+         if (next == '\n') {
+            /*
+             * If this is really a line continuation sequence, eat
+             * it and do not exit the loop.
+             */
+            eaten += next_eaten;
+            input += next_eaten;
+            *current_line = next_line;
+         } else {
+            /*
+             * It is an error to put anything between a backslash
+             * and a newline and still expect it to behave like a line
+             * continuation sequence.
+             * Even if it is an innocent whitespace.
+             */
+            *out = '\\';
+            break;
+         }
+      } else {
+         eaten += _purify_newline(input, out, current_line);
+         break;
+      }
+   }
+   return eaten;
+}
+
+
+static void
+_report_error(char *buf,
+              unsigned int cbbuf,
+              const char *msg,
+              ...)
+{
+   va_list args;
+
+   va_start(args, msg);
+   vsnprintf(buf, cbbuf, msg, args);
+   va_end(args);
+}
+
+
+void
+sl_pp_purify_state_init(struct sl_pp_purify_state *state,
+                        const char *input,
+                        const struct sl_pp_purify_options *options)
+{
+   state->options = *options;
+   state->input = input;
+   state->current_line = 1;
+   state->inside_c_comment = 0;
+}
+
+
+unsigned int
+_purify_comment(struct sl_pp_purify_state *state,
+                char *output,
+                unsigned int *current_line,
+                char *errormsg,
+                unsigned int cberrormsg)
+{
+   for (;;) {
+      unsigned int eaten;
+      char next;
+
+      eaten = _purify_backslash(state->input, &next, current_line);
+      state->input += eaten;
+      while (next == '*') {
+         eaten = _purify_backslash(state->input, &next, current_line);
+         state->input += eaten;
+         if (next == '/') {
+            *output = ' ';
+            state->inside_c_comment = 0;
+            return 1;
+         }
+      }
+      if (next == '\n') {
+         *output = '\n';
+         state->inside_c_comment = 1;
+         return 1;
+      }
+      if (next == '\0') {
+         _report_error(errormsg, cberrormsg, "expected `*/' but end of translation unit found");
+         return 0;
+      }
+   }
+}
+
+
+unsigned int
+sl_pp_purify_getc(struct sl_pp_purify_state *state,
+                  char *output,
+                  unsigned int *current_line,
+                  char *errormsg,
+                  unsigned int cberrormsg)
+{
+   unsigned int eaten;
+
+   if (state->inside_c_comment) {
+      return _purify_comment(state, output, current_line, errormsg, cberrormsg);
+   }
+
+   eaten = _purify_backslash(state->input, output, current_line);
+   state->input += eaten;
+   if (*output == '/') {
+      char next;
+      unsigned int next_line = *current_line;
+
+      eaten = _purify_backslash(state->input, &next, &next_line);
+      if (next == '/') {
+         state->input += eaten;
+         *current_line = next_line;
+
+         /* Replace a line comment with either a newline or nil. */
+         for (;;) {
+            eaten = _purify_backslash(state->input, &next, current_line);
+            state->input += eaten;
+            if (next == '\n' || next == '\0') {
+               *output = next;
+               return eaten;
+            }
+         }
+      } else if (next == '*') {
+         state->input += eaten;
+         *current_line = next_line;
+
+         return _purify_comment(state, output, current_line, errormsg, cberrormsg);
+      }
+   }
+   return eaten;
+}
+
+
+struct out_buf {
+   char *out;
+   unsigned int len;
+   unsigned int capacity;
+   unsigned int current_line;
+   char *errormsg;
+   unsigned int cberrormsg;
+};
+
+
+static int
+_out_buf_putc(struct out_buf *obuf,
+              char c)
+{
+   if (obuf->len >= obuf->capacity) {
+      unsigned int new_max = obuf->capacity;
+
+      if (new_max < 0x100) {
+         new_max = 0x100;
+      } else if (new_max < 0x10000) {
+         new_max *= 2;
+      } else {
+         new_max += 0x10000;
+      }
+
+      obuf->out = realloc(obuf->out, new_max);
+      if (!obuf->out) {
+         _report_error(obuf->errormsg, obuf->cberrormsg, "out of memory");
+         return -1;
+      }
+      obuf->capacity = new_max;
+   }
+
+   obuf->out[obuf->len++] = c;
+
+   return 0;
+}
+
+
+int
+sl_pp_purify(const char *input,
+             const struct sl_pp_purify_options *options,
+             char **output,
+             char *errormsg,
+             unsigned int cberrormsg,
+             unsigned int *errorline)
+{
+   struct out_buf obuf;
+   struct sl_pp_purify_state state;
+
+   obuf.out = NULL;
+   obuf.len = 0;
+   obuf.capacity = 0;
+   obuf.current_line = 1;
+   obuf.errormsg = errormsg;
+   obuf.cberrormsg = cberrormsg;
+
+   sl_pp_purify_state_init(&state, input, options);
+
+   for (;;) {
+      unsigned int eaten;
+      char c;
+
+      eaten = sl_pp_purify_getc(&state, &c, &obuf.current_line, errormsg, cberrormsg);
+      if (!eaten) {
+         *errorline = obuf.current_line;
+         return -1;
+      }
+      if (_out_buf_putc(&obuf, c)) {
+         *errorline = obuf.current_line;
+         return -1;
+      }
+
+      if (c == '\0') {
+         break;
+      }
+   }
+
+   *output = obuf.out;
+   return 0;
+}
diff --git a/src/glsl/pp/sl_pp_purify.h b/src/glsl/pp/sl_pp_purify.h
new file mode 100644 (file)
index 0000000..c0f55cb
--- /dev/null
@@ -0,0 +1,63 @@
+/**************************************************************************
+ * 
+ * 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.
+ * 
+ **************************************************************************/
+
+#ifndef SL_PP_PURIFY_H
+#define SL_PP_PURIFY_H
+
+struct sl_pp_purify_options {
+   unsigned int preserve_columns:1;
+   unsigned int tab_width:4;
+};
+
+int
+sl_pp_purify(const char *input,
+             const struct sl_pp_purify_options *options,
+             char **output,
+             char *errormsg,
+             unsigned int cberrormsg,
+             unsigned int *errorline);
+
+struct sl_pp_purify_state {
+   struct sl_pp_purify_options options;
+   const char *input;
+   unsigned int current_line;
+   unsigned int inside_c_comment:1;
+};
+
+void
+sl_pp_purify_state_init(struct sl_pp_purify_state *state,
+                        const char *input,
+                        const struct sl_pp_purify_options *options);
+
+unsigned int
+sl_pp_purify_getc(struct sl_pp_purify_state *state,
+                  char *output,
+                  unsigned int *current_line,
+                  char *errormsg,
+                  unsigned int cberrormsg);
+
+#endif /* SL_PP_PURIFY_H */
diff --git a/src/glsl/pp/sl_pp_token.c b/src/glsl/pp/sl_pp_token.c
new file mode 100644 (file)
index 0000000..a708978
--- /dev/null
@@ -0,0 +1,854 @@
+/**************************************************************************
+ * 
+ * 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 <assert.h>
+#include <stdlib.h>
+#include <string.h>
+#include "sl_pp_public.h"
+#include "sl_pp_context.h"
+#include "sl_pp_token.h"
+
+
+#define PURE_ERROR 256
+
+static int
+_pure_getc(struct sl_pp_context *context)
+{
+   char c;
+
+   if (context->getc_buf_size) {
+      return context->getc_buf[--context->getc_buf_size];
+   }
+
+   if (sl_pp_purify_getc(&context->pure, &c, &context->error_line, context->error_msg, sizeof(context->error_msg)) == 0) {
+      return PURE_ERROR;
+   }
+   return c;
+}
+
+
+static void
+_pure_ungetc(struct sl_pp_context *context,
+             int c)
+{
+   assert(c != PURE_ERROR);
+
+   if (context->getc_buf_size == context->getc_buf_capacity) {
+      context->getc_buf_capacity += 64;
+      context->getc_buf = realloc(context->getc_buf, context->getc_buf_capacity * sizeof(char));
+      assert(context->getc_buf);                            
+   }
+
+   context->getc_buf[context->getc_buf_size++] = (char)c;
+}
+
+
+struct lookahead_state {
+   char buf[256];
+   unsigned int pos;
+   struct sl_pp_context *context;
+};
+
+
+static void
+_lookahead_init(struct lookahead_state *lookahead,
+                struct sl_pp_context *context)
+{
+   lookahead->pos = 0;
+   lookahead->context = context;
+}
+
+
+static unsigned int
+_lookahead_tell(const struct lookahead_state *lookahead)
+{
+   return lookahead->pos;
+}
+
+
+static const void *
+_lookahead_buf(const struct lookahead_state *lookahead)
+{
+   return lookahead->buf;
+}
+
+
+static void
+_lookahead_revert(struct lookahead_state *lookahead,
+                  unsigned int pos)
+{
+   assert(pos <= lookahead->pos);
+
+   while (lookahead->pos > pos) {
+      _pure_ungetc(lookahead->context, lookahead->buf[--lookahead->pos]);
+   }
+}
+
+
+static int
+_lookahead_getc(struct lookahead_state *lookahead)
+{
+   int c;
+
+   assert(lookahead->pos < sizeof(lookahead->buf) / sizeof(lookahead->buf[0]));
+
+   c = _pure_getc(lookahead->context);
+   if (c != PURE_ERROR) {
+      lookahead->buf[lookahead->pos++] = (char)c;
+   }
+   return c;
+}
+
+
+static int
+_is_identifier_char(char c)
+{
+   return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_';
+}
+
+
+static int
+_tokenise_identifier(struct sl_pp_context *context,
+                     struct sl_pp_token_info *out)
+{
+   int c;
+   char identifier[256];   /* XXX: Remove this artifical limit. */
+   unsigned int i = 0;
+
+   out->token = SL_PP_IDENTIFIER;
+   out->data.identifier = -1;
+
+   c = _pure_getc(context);
+   if (c == PURE_ERROR) {
+      return -1;
+   }
+   identifier[i++] = (char)c;
+   for (;;) {
+      c = _pure_getc(context);
+      if (c == PURE_ERROR) {
+         return -1;
+      }
+
+      if (_is_identifier_char((char)c)) {
+         if (i >= sizeof(identifier) / sizeof(char) - 1) {
+            strcpy(context->error_msg, "out of memory");
+            _pure_ungetc(context, c);
+            while (i) {
+               _pure_ungetc(context, identifier[--i]);
+            }
+            return -1;
+         }
+         identifier[i++] = (char)c;
+      } else {
+         _pure_ungetc(context, c);
+         break;
+      }
+   }
+   identifier[i] = '\0';
+
+   out->data.identifier = sl_pp_context_add_unique_str(context, identifier);
+   if (out->data.identifier == -1) {
+      while (i) {
+         _pure_ungetc(context, identifier[--i]);
+      }
+      return -1;
+   }
+
+   return 0;
+}
+
+
+/*
+ * Return the number of consecutive decimal digits in the input stream.
+ */
+static unsigned int
+_parse_float_digits(struct lookahead_state *lookahead)
+{
+   unsigned int eaten;
+
+   for (eaten = 0;; eaten++) {
+      unsigned int pos = _lookahead_tell(lookahead);
+      char c = _lookahead_getc(lookahead);
+
+      if (c < '0' || c > '9') {
+         _lookahead_revert(lookahead, pos);
+         break;
+      }
+   }
+   return eaten;
+}
+
+
+/*
+ * Try to match one of the following patterns for the fractional part
+ * of a floating point number.
+ *
+ * digits . [digits]
+ * . digits
+ *
+ * Return 0 if the pattern could not be matched, otherwise the number
+ * of eaten characters from the input stream.
+ */
+static unsigned int
+_parse_float_frac(struct lookahead_state *lookahead)
+{
+   unsigned int pos;
+   int c;
+   unsigned int eaten;
+
+   pos = _lookahead_tell(lookahead);
+   c = _lookahead_getc(lookahead);
+   if (c == '.') {
+      eaten = _parse_float_digits(lookahead);
+      if (eaten) {
+         return eaten + 1;
+      }
+      _lookahead_revert(lookahead, pos);
+      return 0;
+   }
+
+   _lookahead_revert(lookahead, pos);
+   eaten = _parse_float_digits(lookahead);
+   if (eaten) {
+      c = _lookahead_getc(lookahead);
+      if (c == '.') {
+         return eaten + 1 + _parse_float_digits(lookahead);
+      }
+   }
+
+   _lookahead_revert(lookahead, pos);
+   return 0;
+}
+
+
+/*
+ * Try to match the following pattern for the exponential part
+ * of a floating point number.
+ *
+ * (e|E) [(+|-)] digits
+ *
+ * Return 0 if the pattern could not be matched, otherwise the number
+ * of eaten characters from the input stream.
+ */
+static unsigned int
+_parse_float_exp(struct lookahead_state *lookahead)
+{
+   unsigned int pos, pos2;
+   int c;
+   unsigned int eaten, digits;
+
+   pos = _lookahead_tell(lookahead);
+   c = _lookahead_getc(lookahead);
+   if (c != 'e' && c != 'E') {
+      _lookahead_revert(lookahead, pos);
+      return 0;
+   }
+
+   pos2 = _lookahead_tell(lookahead);
+   c = _lookahead_getc(lookahead);
+   if (c == '-' || c == '+') {
+      eaten = 2;
+   } else {
+      _lookahead_revert(lookahead, pos2);
+      eaten = 1;
+   }
+
+   digits = _parse_float_digits(lookahead);
+   if (!digits) {
+      _lookahead_revert(lookahead, pos);
+      return 0;
+   }
+
+   return eaten + digits;
+}
+
+
+/*
+ * Try to match one of the following patterns for a floating point number.
+ *
+ * fract [exp] [(f|F)]
+ * digits exp [(f|F)]
+ *
+ * Return 0 if the pattern could not be matched, otherwise the number
+ * of eaten characters from the input stream.
+ */
+static unsigned int
+_parse_float(struct lookahead_state *lookahead)
+{
+   unsigned int eaten;
+
+   eaten = _parse_float_frac(lookahead);
+   if (eaten) {
+      unsigned int pos;
+      int c;
+
+      eaten += _parse_float_exp(lookahead);
+
+      pos = _lookahead_tell(lookahead);
+      c = _lookahead_getc(lookahead);
+      if (c == 'f' || c == 'F') {
+         eaten++;
+      } else {
+         _lookahead_revert(lookahead, pos);
+      }
+
+      return eaten;
+   }
+
+   eaten = _parse_float_digits(lookahead);
+   if (eaten) {
+      unsigned int exponent;
+
+      exponent = _parse_float_exp(lookahead);
+      if (exponent) {
+         unsigned int pos;
+         int c;
+
+         eaten += exponent;
+
+         pos = _lookahead_tell(lookahead);
+         c = _lookahead_getc(lookahead);
+         if (c == 'f' || c == 'F') {
+            eaten++;
+         } else {
+            _lookahead_revert(lookahead, pos);
+         }
+
+         return eaten;
+      }
+   }
+
+   _lookahead_revert(lookahead, 0);
+   return 0;
+}
+
+
+static unsigned int
+_parse_hex(struct lookahead_state *lookahead)
+{
+   int c;
+   unsigned int n;
+
+   c = _lookahead_getc(lookahead);
+   if (c != '0') {
+      _lookahead_revert(lookahead, 0);
+      return 0;
+   }
+
+   c = _lookahead_getc(lookahead);
+   if (c != 'x' && c != 'X') {
+      _lookahead_revert(lookahead, 0);
+      return 0;
+   }
+
+   for (n = 2;;) {
+      unsigned int pos = _lookahead_tell(lookahead);
+
+      c = _lookahead_getc(lookahead);
+      if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')) {
+         n++;
+      } else {
+         _lookahead_revert(lookahead, pos);
+         break;
+      }
+   }
+
+   if (n > 2) {
+      return n;
+   }
+
+   _lookahead_revert(lookahead, 0);
+   return 0;
+}
+
+
+static unsigned int
+_parse_oct(struct lookahead_state *lookahead)
+{
+   int c;
+   unsigned int n;
+
+   c = _lookahead_getc(lookahead);
+   if (c != '0') {
+      _lookahead_revert(lookahead, 0);
+      return 0;
+   }
+
+   for (n = 1;;) {
+      unsigned int pos = _lookahead_tell(lookahead);
+
+      c = _lookahead_getc(lookahead);
+      if ((c >= '0' && c <= '7')) {
+         n++;
+      } else {
+         _lookahead_revert(lookahead, pos);
+         break;
+      }
+   }
+
+   return n;
+}
+
+
+static unsigned int
+_parse_dec(struct lookahead_state *lookahead)
+{
+   unsigned int n = 0;
+
+   for (;;) {
+      unsigned int pos = _lookahead_tell(lookahead);
+      int c = _lookahead_getc(lookahead);
+
+      if ((c >= '0' && c <= '9')) {
+         n++;
+      } else {
+         _lookahead_revert(lookahead, pos);
+         break;
+      }
+   }
+
+   return n;
+}
+
+
+static int
+_tokenise_number(struct sl_pp_context *context,
+                 struct sl_pp_token_info *out)
+{
+   struct lookahead_state lookahead;
+   unsigned int eaten;
+   unsigned int is_float = 0;
+   unsigned int pos;
+   int c;
+   char number[256];   /* XXX: Remove this artifical limit. */
+
+   _lookahead_init(&lookahead, context);
+
+   eaten = _parse_float(&lookahead);
+   if (!eaten) {
+      eaten = _parse_hex(&lookahead);
+      if (!eaten) {
+         eaten = _parse_oct(&lookahead);
+         if (!eaten) {
+            eaten = _parse_dec(&lookahead);
+         }
+      }
+   } else {
+      is_float = 1;
+   }
+
+   if (!eaten) {
+      strcpy(context->error_msg, "expected a number");
+      return -1;
+   }
+
+   pos = _lookahead_tell(&lookahead);
+   c = _lookahead_getc(&lookahead);
+   _lookahead_revert(&lookahead, pos);
+
+   if (_is_identifier_char(c)) {
+      strcpy(context->error_msg, "expected a number");
+      _lookahead_revert(&lookahead, 0);
+      return -1;
+   }
+
+   if (eaten > sizeof(number) - 1) {
+      strcpy(context->error_msg, "out of memory");
+      _lookahead_revert(&lookahead, 0);
+      return -1;
+   }
+
+   assert(_lookahead_tell(&lookahead) == eaten);
+
+   memcpy(number, _lookahead_buf(&lookahead), eaten);
+   number[eaten] = '\0';
+
+   if (is_float) {
+      out->token = SL_PP_FLOAT;
+      out->data._float = sl_pp_context_add_unique_str(context, number);
+      if (out->data._float == -1) {
+         _lookahead_revert(&lookahead, 0);
+         return -1;
+      }
+   } else {
+      out->token = SL_PP_UINT;
+      out->data._uint = sl_pp_context_add_unique_str(context, number);
+      if (out->data._uint == -1) {
+         _lookahead_revert(&lookahead, 0);
+         return -1;
+      }
+   }
+
+   return 0;
+}
+
+
+int
+sl_pp_token_get(struct sl_pp_context *context,
+                struct sl_pp_token_info *out)
+{
+   int c = _pure_getc(context);
+
+   switch (c) {
+   case ' ':
+   case '\t':
+      out->token = SL_PP_WHITESPACE;
+      break;
+
+   case '\n':
+      out->token = SL_PP_NEWLINE;
+      break;
+
+   case '#':
+      out->token = SL_PP_HASH;
+      break;
+
+   case ',':
+      out->token = SL_PP_COMMA;
+      break;
+
+   case ';':
+      out->token = SL_PP_SEMICOLON;
+      break;
+
+   case '{':
+      out->token = SL_PP_LBRACE;
+      break;
+
+   case '}':
+      out->token = SL_PP_RBRACE;
+      break;
+
+   case '(':
+      out->token = SL_PP_LPAREN;
+      break;
+
+   case ')':
+      out->token = SL_PP_RPAREN;
+      break;
+
+   case '[':
+      out->token = SL_PP_LBRACKET;
+      break;
+
+   case ']':
+      out->token = SL_PP_RBRACKET;
+      break;
+
+   case '.':
+      {
+         int c2 = _pure_getc(context);
+
+         if (c2 == PURE_ERROR) {
+            return -1;
+         }
+         if (c2 >= '0' && c2 <= '9') {
+            _pure_ungetc(context, c2);
+            _pure_ungetc(context, c);
+            if (_tokenise_number(context, out)) {
+               return -1;
+            }
+         } else {
+            _pure_ungetc(context, c2);
+            out->token = SL_PP_DOT;
+         }
+      }
+      break;
+
+   case '+':
+      c = _pure_getc(context);
+      if (c == PURE_ERROR) {
+         return -1;
+      }
+      if (c == '+') {
+         out->token = SL_PP_INCREMENT;
+      } else if (c == '=') {
+         out->token = SL_PP_ADDASSIGN;
+      } else {
+         _pure_ungetc(context, c);
+         out->token = SL_PP_PLUS;
+      }
+      break;
+
+   case '-':
+      c = _pure_getc(context);
+      if (c == PURE_ERROR) {
+         return -1;
+      }
+      if (c == '-') {
+         out->token = SL_PP_DECREMENT;
+      } else if (c == '=') {
+         out->token = SL_PP_SUBASSIGN;
+      } else {
+         _pure_ungetc(context, c);
+         out->token = SL_PP_MINUS;
+      }
+      break;
+
+   case '~':
+      out->token = SL_PP_BITNOT;
+      break;
+
+   case '!':
+      c = _pure_getc(context);
+      if (c == PURE_ERROR) {
+         return -1;
+      }
+      if (c == '=') {
+         out->token = SL_PP_NOTEQUAL;
+      } else {
+         _pure_ungetc(context, c);
+         out->token = SL_PP_NOT;
+      }
+      break;
+
+   case '*':
+      c = _pure_getc(context);
+      if (c == PURE_ERROR) {
+         return -1;
+      }
+      if (c == '=') {
+         out->token = SL_PP_MULASSIGN;
+      } else {
+         _pure_ungetc(context, c);
+         out->token = SL_PP_STAR;
+      }
+      break;
+
+   case '/':
+      c = _pure_getc(context);
+      if (c == PURE_ERROR) {
+         return -1;
+      }
+      if (c == '=') {
+         out->token = SL_PP_DIVASSIGN;
+      } else {
+         _pure_ungetc(context, c);
+         out->token = SL_PP_SLASH;
+      }
+      break;
+
+   case '%':
+      c = _pure_getc(context);
+      if (c == PURE_ERROR) {
+         return -1;
+      }
+      if (c == '=') {
+         out->token = SL_PP_MODASSIGN;
+      } else {
+         _pure_ungetc(context, c);
+         out->token = SL_PP_MODULO;
+      }
+      break;
+
+   case '<':
+      c = _pure_getc(context);
+      if (c == PURE_ERROR) {
+         return -1;
+      }
+      if (c == '<') {
+         c = _pure_getc(context);
+         if (c == PURE_ERROR) {
+            return -1;
+         }
+         if (c == '=') {
+            out->token = SL_PP_LSHIFTASSIGN;
+         } else {
+            _pure_ungetc(context, c);
+            out->token = SL_PP_LSHIFT;
+         }
+      } else if (c == '=') {
+         out->token = SL_PP_LESSEQUAL;
+      } else {
+         _pure_ungetc(context, c);
+         out->token = SL_PP_LESS;
+      }
+      break;
+
+   case '>':
+      c = _pure_getc(context);
+      if (c == PURE_ERROR) {
+         return -1;
+      }
+      if (c == '>') {
+         c = _pure_getc(context);
+         if (c == PURE_ERROR) {
+            return -1;
+         }
+         if (c == '=') {
+            out->token = SL_PP_RSHIFTASSIGN;
+         } else {
+            _pure_ungetc(context, c);
+            out->token = SL_PP_RSHIFT;
+         }
+      } else if (c == '=') {
+         out->token = SL_PP_GREATEREQUAL;
+      } else {
+         _pure_ungetc(context, c);
+         out->token = SL_PP_GREATER;
+      }
+      break;
+
+   case '=':
+      c = _pure_getc(context);
+      if (c == PURE_ERROR) {
+         return -1;
+      }
+      if (c == '=') {
+         out->token = SL_PP_EQUAL;
+      } else {
+         _pure_ungetc(context, c);
+         out->token = SL_PP_ASSIGN;
+      }
+      break;
+
+   case '&':
+      c = _pure_getc(context);
+      if (c == PURE_ERROR) {
+         return -1;
+      }
+      if (c == '&') {
+         out->token = SL_PP_AND;
+      } else if (c == '=') {
+         out->token = SL_PP_BITANDASSIGN;
+      } else {
+         _pure_ungetc(context, c);
+         out->token = SL_PP_BITAND;
+      }
+      break;
+
+   case '^':
+      c = _pure_getc(context);
+      if (c == PURE_ERROR) {
+         return -1;
+      }
+      if (c == '^') {
+         out->token = SL_PP_XOR;
+      } else if (c == '=') {
+         out->token = SL_PP_BITXORASSIGN;
+      } else {
+         _pure_ungetc(context, c);
+         out->token = SL_PP_BITXOR;
+      }
+      break;
+
+   case '|':
+      c = _pure_getc(context);
+      if (c == PURE_ERROR) {
+         return -1;
+      }
+      if (c == '|') {
+         out->token = SL_PP_OR;
+      } else if (c == '=') {
+         out->token = SL_PP_BITORASSIGN;
+      } else {
+         _pure_ungetc(context, c);
+         out->token = SL_PP_BITOR;
+      }
+      break;
+
+   case '?':
+      out->token = SL_PP_QUESTION;
+      break;
+
+   case ':':
+      out->token = SL_PP_COLON;
+      break;
+
+   case '\0':
+      out->token = SL_PP_EOF;
+      break;
+
+   case PURE_ERROR:
+      return -1;
+
+   default:
+      if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_') {
+         _pure_ungetc(context, c);
+         if (_tokenise_identifier(context, out)) {
+            return -1;
+         }
+      } else if (c >= '0' && c <= '9') {
+         _pure_ungetc(context, c);
+         if (_tokenise_number(context, out)) {
+            return -1;
+         }
+      } else {
+         out->data.other = c;
+         out->token = SL_PP_OTHER;
+      }
+   }
+
+   return 0;
+}
+
+
+int
+sl_pp_tokenise(struct sl_pp_context *context,
+               struct sl_pp_token_info **output)
+{
+   struct sl_pp_token_info *out = NULL;
+   unsigned int out_len = 0;
+   unsigned int out_max = 0;
+
+   for (;;) {
+      struct sl_pp_token_info info;
+
+      if (sl_pp_token_buffer_get(&context->tokens, &info)) {
+         free(out);
+         return -1;
+      }
+
+      if (out_len >= out_max) {
+         unsigned int new_max = out_max;
+
+         if (new_max < 0x100) {
+            new_max = 0x100;
+         } else if (new_max < 0x10000) {
+            new_max *= 2;
+         } else {
+            new_max += 0x10000;
+         }
+
+         out = realloc(out, new_max * sizeof(struct sl_pp_token_info));
+         if (!out) {
+            strcpy(context->error_msg, "out of memory");
+            return -1;
+         }
+         out_max = new_max;
+      }
+
+      out[out_len++] = info;
+
+      if (info.token == SL_PP_EOF) {
+         break;
+      }
+   }
+
+   *output = out;
+   return 0;
+}
diff --git a/src/glsl/pp/sl_pp_token.h b/src/glsl/pp/sl_pp_token.h
new file mode 100644 (file)
index 0000000..a12b193
--- /dev/null
@@ -0,0 +1,133 @@
+/**************************************************************************
+ * 
+ * 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.
+ * 
+ **************************************************************************/
+
+#ifndef SL_PP_TOKEN_H
+#define SL_PP_TOKEN_H
+
+
+struct sl_pp_context;
+
+enum sl_pp_token {
+   SL_PP_WHITESPACE,
+   SL_PP_NEWLINE,
+   SL_PP_HASH,             /* #   */
+
+   SL_PP_COMMA,            /* ,   */
+   SL_PP_SEMICOLON,        /* ;   */
+   SL_PP_LBRACE,           /* {   */
+   SL_PP_RBRACE,           /* }   */
+   SL_PP_LPAREN,           /* (   */
+   SL_PP_RPAREN,           /* )   */
+   SL_PP_LBRACKET,         /* [   */
+   SL_PP_RBRACKET,         /* ]   */
+   SL_PP_DOT,              /* .   */
+   SL_PP_INCREMENT,        /* ++  */
+   SL_PP_ADDASSIGN,        /* +=  */
+   SL_PP_PLUS,             /* +   */
+   SL_PP_DECREMENT,        /* --  */
+   SL_PP_SUBASSIGN,        /* -=  */
+   SL_PP_MINUS,            /* -   */
+   SL_PP_BITNOT,           /* ~   */
+   SL_PP_NOTEQUAL,         /* !=  */
+   SL_PP_NOT,              /* !   */
+   SL_PP_MULASSIGN,        /* *=  */
+   SL_PP_STAR,             /* *   */
+   SL_PP_DIVASSIGN,        /* /=  */
+   SL_PP_SLASH,            /* /   */
+   SL_PP_MODASSIGN,        /* %=  */
+   SL_PP_MODULO,           /* %   */
+   SL_PP_LSHIFTASSIGN,     /* <<= */
+   SL_PP_LSHIFT,           /* <<  */
+   SL_PP_LESSEQUAL,        /* <=  */
+   SL_PP_LESS,             /* <   */
+   SL_PP_RSHIFTASSIGN,     /* >>= */
+   SL_PP_RSHIFT,           /* >>  */
+   SL_PP_GREATEREQUAL,     /* >=  */
+   SL_PP_GREATER,          /* >   */
+   SL_PP_EQUAL,            /* ==  */
+   SL_PP_ASSIGN,           /* =   */
+   SL_PP_AND,              /* &&  */
+   SL_PP_BITANDASSIGN,     /* &=  */
+   SL_PP_BITAND,           /* &   */
+   SL_PP_XOR,              /* ^^  */
+   SL_PP_BITXORASSIGN,     /* ^=  */
+   SL_PP_BITXOR,           /* ^   */
+   SL_PP_OR,               /* ||  */
+   SL_PP_BITORASSIGN,      /* |=  */
+   SL_PP_BITOR,            /* |   */
+   SL_PP_QUESTION,         /* ?   */
+   SL_PP_COLON,            /* :   */
+
+   SL_PP_IDENTIFIER,
+
+   SL_PP_UINT,
+   SL_PP_FLOAT,
+
+   SL_PP_OTHER,
+
+   SL_PP_PRAGMA_OPTIMIZE,
+   SL_PP_PRAGMA_DEBUG,
+
+   SL_PP_EXTENSION_REQUIRE,
+   SL_PP_EXTENSION_ENABLE,
+   SL_PP_EXTENSION_WARN,
+   SL_PP_EXTENSION_DISABLE,
+
+   SL_PP_LINE,
+
+   SL_PP_EOF
+};
+
+union sl_pp_token_data {
+   int identifier;
+   int _uint;
+   int _float;
+   char other;
+   int pragma;
+   int extension;
+   struct {
+      unsigned int lineno: 24;
+      unsigned int fileno: 8;
+   } line;
+};
+
+struct sl_pp_token_info {
+   enum sl_pp_token token;
+   union sl_pp_token_data data;
+};
+
+struct sl_pp_purify_options;
+
+int
+sl_pp_token_get(struct sl_pp_context *context,
+                struct sl_pp_token_info *out);
+
+int
+sl_pp_tokenise(struct sl_pp_context *context,
+               struct sl_pp_token_info **output);
+
+#endif /* SL_PP_TOKEN_H */
diff --git a/src/glsl/pp/sl_pp_token_util.c b/src/glsl/pp/sl_pp_token_util.c
new file mode 100644 (file)
index 0000000..c85263d
--- /dev/null
@@ -0,0 +1,182 @@
+/**************************************************************************
+ * 
+ * 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 <assert.h>
+#include <stdlib.h>
+#include "sl_pp_token_util.h"
+
+
+int
+sl_pp_token_buffer_init(struct sl_pp_token_buffer *buffer,
+                        struct sl_pp_context *context)
+{
+   buffer->context = context;
+   buffer->size = 0;
+   buffer->capacity = 64;
+   buffer->tokens = malloc(buffer->capacity * sizeof(struct sl_pp_token_info));
+   if (!buffer->tokens) {
+      return -1;
+   }
+   return 0;
+}
+
+void
+sl_pp_token_buffer_destroy(struct sl_pp_token_buffer *buffer)
+{
+   free(buffer->tokens);
+}
+
+int
+sl_pp_token_buffer_get(struct sl_pp_token_buffer *buffer,
+                       struct sl_pp_token_info *out)
+{
+   /* Pop from stack first if not empty. */
+   if (buffer->size) {
+      *out = buffer->tokens[--buffer->size];
+      return 0;
+   }
+
+   assert(buffer->context);
+   return sl_pp_token_get(buffer->context, out);
+}
+
+void
+sl_pp_token_buffer_unget(struct sl_pp_token_buffer *buffer,
+                         const struct sl_pp_token_info *in)
+{
+   /* Resize if needed. */
+   if (buffer->size == buffer->capacity) {
+      buffer->capacity += 64;
+      buffer->tokens = realloc(buffer->tokens,
+                               buffer->capacity * sizeof(struct sl_pp_token_info));
+      assert(buffer->tokens);
+   }
+
+   /* Push token on stack. */
+   buffer->tokens[buffer->size++] = *in;
+}
+
+int
+sl_pp_token_buffer_skip_white(struct sl_pp_token_buffer *buffer,
+                              struct sl_pp_token_info *out)
+{
+   if (sl_pp_token_buffer_get(buffer, out)) {
+      return -1;
+   }
+
+   while (out->token == SL_PP_WHITESPACE) {
+      if (sl_pp_token_buffer_get(buffer, out)) {
+         return -1;
+      }
+   }
+
+   return 0;
+}
+
+
+
+int
+sl_pp_token_peek_init(struct sl_pp_token_peek *peek,
+                      struct sl_pp_token_buffer *buffer)
+{
+   peek->buffer = buffer;
+   peek->size = 0;
+   peek->capacity = 64;
+   peek->tokens = malloc(peek->capacity * sizeof(struct sl_pp_token_info));
+   if (!peek->tokens) {
+      return -1;
+   }
+   return 0;
+}
+
+void
+sl_pp_token_peek_destroy(struct sl_pp_token_peek *peek)
+{
+   /* Abort. */
+   while (peek->size) {
+      sl_pp_token_buffer_unget(peek->buffer, &peek->tokens[--peek->size]);
+   }
+   free(peek->tokens);
+}
+
+int
+sl_pp_token_peek_get(struct sl_pp_token_peek *peek,
+                     struct sl_pp_token_info *out)
+{
+   /* Get token from buffer. */
+   if (sl_pp_token_buffer_get(peek->buffer, out)) {
+      return -1;
+   }
+
+   /* Save it. */
+   if (peek->size == peek->capacity) {
+      peek->capacity += 64;
+      peek->tokens = realloc(peek->tokens,
+                             peek->capacity * sizeof(struct sl_pp_token_info));
+      assert(peek->tokens);
+   }
+   peek->tokens[peek->size++] = *out;
+   return 0;
+}
+
+void
+sl_pp_token_peek_commit(struct sl_pp_token_peek *peek)
+{
+   peek->size = 0;
+}
+
+int
+sl_pp_token_peek_to_buffer(const struct sl_pp_token_peek *peek,
+                           struct sl_pp_token_buffer *buffer)
+{
+   unsigned int i;
+
+   if (sl_pp_token_buffer_init(buffer, NULL)) {
+      return -1;
+   }
+   for (i = peek->size; i > 0; i--) {
+      sl_pp_token_buffer_unget(buffer, &peek->tokens[i - 1]);
+   }
+   return 0;
+}
+
+int
+sl_pp_token_peek_skip_white(struct sl_pp_token_peek *peek,
+                            struct sl_pp_token_info *out)
+{
+   if (sl_pp_token_peek_get(peek, out)) {
+      return -1;
+   }
+
+   while (out->token == SL_PP_WHITESPACE) {
+      if (sl_pp_token_peek_get(peek, out)) {
+         return -1;
+      }
+   }
+
+   return 0;
+}
diff --git a/src/glsl/pp/sl_pp_token_util.h b/src/glsl/pp/sl_pp_token_util.h
new file mode 100644 (file)
index 0000000..2a668ad
--- /dev/null
@@ -0,0 +1,103 @@
+/**************************************************************************
+ * 
+ * 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.
+ * 
+ **************************************************************************/
+
+#ifndef SL_PP_TOKEN_UTIL_H
+#define SL_PP_TOKEN_UTIL_H
+
+#include <assert.h>
+#include <stdlib.h>
+#include "sl_pp_token.h"
+
+
+struct sl_pp_context;
+
+/*
+ * A token buffer allows one to get and unget a token
+ * from a preprocessor context.
+ */
+struct sl_pp_token_buffer {
+   struct sl_pp_context *context;
+   unsigned int size;
+   unsigned int capacity;
+   struct sl_pp_token_info *tokens;
+};
+
+int
+sl_pp_token_buffer_init(struct sl_pp_token_buffer *buffer,
+                        struct sl_pp_context *context);
+
+void
+sl_pp_token_buffer_destroy(struct sl_pp_token_buffer *buffer);
+
+int
+sl_pp_token_buffer_get(struct sl_pp_token_buffer *buffer,
+                       struct sl_pp_token_info *out);
+
+void
+sl_pp_token_buffer_unget(struct sl_pp_token_buffer *buffer,
+                         const struct sl_pp_token_info *in);
+
+int
+sl_pp_token_buffer_skip_white(struct sl_pp_token_buffer *buffer,
+                              struct sl_pp_token_info *out);
+
+
+/*
+ * A token peek allows one to get a number of tokens from a buffer
+ * and then either commit the operation or abort it,
+ * effectively ungetting the peeked tokens.
+ */
+struct sl_pp_token_peek {
+   struct sl_pp_token_buffer *buffer;
+   unsigned int size;
+   unsigned int capacity;
+   struct sl_pp_token_info *tokens;
+};
+
+int
+sl_pp_token_peek_init(struct sl_pp_token_peek *peek,
+                      struct sl_pp_token_buffer *buffer);
+
+void
+sl_pp_token_peek_destroy(struct sl_pp_token_peek *peek);
+
+int
+sl_pp_token_peek_get(struct sl_pp_token_peek *peek,
+                     struct sl_pp_token_info *out);
+
+void
+sl_pp_token_peek_commit(struct sl_pp_token_peek *peek);
+
+int
+sl_pp_token_peek_to_buffer(const struct sl_pp_token_peek *peek,
+                           struct sl_pp_token_buffer *buffer);
+
+int
+sl_pp_token_peek_skip_white(struct sl_pp_token_peek *peek,
+                            struct sl_pp_token_info *out);
+
+#endif /* SL_PP_TOKEN_UTIL_H */
diff --git a/src/glsl/pp/sl_pp_version.c b/src/glsl/pp/sl_pp_version.c
new file mode 100644 (file)
index 0000000..3c995b7
--- /dev/null
@@ -0,0 +1,161 @@
+/**************************************************************************
+ * 
+ * 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 <stdlib.h>
+#include <string.h>
+#include "sl_pp_public.h"
+#include "sl_pp_context.h"
+
+
+int
+sl_pp_version(struct sl_pp_context *context,
+              unsigned int *version)
+{
+   struct sl_pp_token_peek peek;
+   unsigned int line = context->line;
+
+   /* Default values if `#version' is not present. */
+   *version = 110;
+
+   if (sl_pp_token_peek_init(&peek, &context->tokens)) {
+      return -1;
+   }
+
+   /* There can be multiple `#version' directives present.
+    * Accept the value of the last one.
+    */
+   for (;;) {
+      struct sl_pp_token_info input;
+      int found_hash = 0;
+      int found_version = 0;
+      int found_number = 0;
+      int found_end = 0;
+
+      /* Skip whitespace and newlines and seek for hash. */
+      while (!found_hash) {
+         if (sl_pp_token_peek_get(&peek, &input)) {
+            sl_pp_token_peek_destroy(&peek);
+            return -1;
+         }
+
+         switch (input.token) {
+         case SL_PP_NEWLINE:
+            line++;
+            break;
+
+         case SL_PP_WHITESPACE:
+            break;
+
+         case SL_PP_HASH:
+            found_hash = 1;
+            break;
+
+         default:
+            sl_pp_token_peek_destroy(&peek);
+            return 0;
+         }
+      }
+
+      /* Skip whitespace and seek for `version'. */
+      while (!found_version) {
+         if (sl_pp_token_peek_get(&peek, &input)) {
+            sl_pp_token_peek_destroy(&peek);
+            return -1;
+         }
+
+         switch (input.token) {
+         case SL_PP_WHITESPACE:
+            break;
+
+         case SL_PP_IDENTIFIER:
+            if (input.data.identifier != context->dict.version) {
+               sl_pp_token_peek_destroy(&peek);
+               return 0;
+            }
+            found_version = 1;
+            break;
+
+         default:
+            sl_pp_token_peek_destroy(&peek);
+            return 0;
+         }
+      }
+
+      sl_pp_token_peek_commit(&peek);
+
+      /* Skip whitespace and seek for version number. */
+      while (!found_number) {
+         if (sl_pp_token_buffer_get(&context->tokens, &input)) {
+            sl_pp_token_peek_destroy(&peek);
+            return -1;
+         }
+
+         switch (input.token) {
+         case SL_PP_WHITESPACE:
+            break;
+
+         case SL_PP_UINT:
+            *version = atoi(sl_pp_context_cstr(context, input.data._uint));
+            found_number = 1;
+            break;
+
+         default:
+            strcpy(context->error_msg, "expected version number after `#version'");
+            sl_pp_token_peek_destroy(&peek);
+            return -1;
+         }
+      }
+
+      /* Skip whitespace and seek for either newline or eof. */
+      while (!found_end) {
+         if (sl_pp_token_buffer_get(&context->tokens, &input)) {
+            sl_pp_token_peek_destroy(&peek);
+            return -1;
+         }
+
+         switch (input.token) {
+         case SL_PP_WHITESPACE:
+            break;
+
+         case SL_PP_NEWLINE:
+            line++;
+            /* pass thru */
+         case SL_PP_EOF:
+            context->line = line;
+            found_end = 1;
+            break;
+
+         default:
+            strcpy(context->error_msg, "expected end of line after version number");
+            sl_pp_token_peek_destroy(&peek);
+            return -1;
+         }
+      }
+   }
+
+   /* Should not get here. */
+}
index d72dd1e86ce65d7518a209c22be1f061e3929926..a55df92677244cc44761021dcfcca177e37549c3 100644 (file)
@@ -37,7 +37,6 @@
 #define __gluarcsorter_h_
 
 #include "sorter.h"
-#include "arcsorter.h"
 
 class Arc;
 class Subdivider;
index 22cbec37870f1d156ae1660b00f1de834222771c..d009a42513e7bd190bba3e70b5bb6e634ca59540 100644 (file)
@@ -59,6 +59,7 @@ Dlnode::Dlnode( PFVS _work, void *_arg, PFVS _cleanup )
     work = _work;
     arg = _arg;
     cleanup = _cleanup;
+    next = 0;
 }
 
 class DisplayList {
index 36a65c7bdd321ac57dccb47d8653b88abfd892ef..2e27436ef8145072684d63aacc885310ec449b68 100644 (file)
@@ -38,7 +38,7 @@
 
 struct GridVertex {
     long               gparam[2];
-                       GridVertex( void ) {}
+                       GridVertex( void ) { gparam[0] = 0, gparam[1] = 0; }
                        GridVertex( long u, long v ) { gparam[0] = u, gparam[1] = v; }
     void               set( long u, long v ) { gparam[0] = u, gparam[1] = v; }
     long               nextu() { return gparam[0]++; }
index 9eb5cbace948e05a232aebac74ca54e37a9033b9..dcbf0067d854762cb3f2a1a2c14c91ac2954b0f9 100644 (file)
@@ -61,6 +61,9 @@ void Knotvector::init( long _knotcount, long _stride, long _order, INREAL *_knot
 
 Knotvector::Knotvector( void )
 {
+    knotcount = 0;
+    stride = 0;
+    order = 0;
     knotlist = 0;
 }
 
index 8a8dcebb50194295d329ed0969e4917dca07a03b..cae6cada468d022bb0b1566f93b7c2ddf8304a80 100644 (file)
@@ -64,7 +64,7 @@ struct O_curve : public PooledObj {
     int                        save;           /* 1 if in display list         */
     long               nuid;
                        O_curve() { next = 0; used = 0; owner = 0; 
-                                   curve.o_pwlcurve = 0; }
+                                   curve.o_pwlcurve = 0; curvetype = ct_none; save = 0; nuid = 0; }
     };
 
 struct O_nurbscurve : public PooledObj {
@@ -77,7 +77,7 @@ struct O_nurbscurve : public PooledObj {
     int                        save;           /* 1 if in display list         */
     O_curve *          owner;          /* owning curve                 */
                        O_nurbscurve( long _type ) 
-                          { type = _type; owner = 0; next = 0; used = 0; }
+                          { bezier_curves = 0; type = _type; tesselation = 0; method = 0; next = 0; used = 0; save = 0; owner = 0; }
     };
  
 class O_pwlcurve : public PooledObj {
@@ -95,7 +95,7 @@ struct O_trim : public PooledObj {
     O_curve            *o_curve;       /* closed trim loop             */
     O_trim *           next;           /* next loop along trim         */
     int                        save;           /* 1 if in display list         */
-                       O_trim() { next = 0; o_curve = 0; }
+                       O_trim() { next = 0; o_curve = 0; save = 0; }
     };
 
 struct O_nurbssurface : public PooledObj {
@@ -106,7 +106,7 @@ struct O_nurbssurface : public PooledObj {
     int                        save;           /* 1 if in display list         */
     int                        used;           /* 1 if prev called in block    */
                        O_nurbssurface( long _type ) 
-                          { type = _type; owner = 0; next = 0; used = 0; }
+                          { bezier_patches = 0; type = _type; owner = 0; next = 0; save = 0; used = 0; }
     };
 
 struct O_surface : public PooledObj {
@@ -114,7 +114,7 @@ struct O_surface : public PooledObj {
     O_trim *           o_trim;         /* list of trim loops           */
     int                        save;           /* 1 if in display list         */
     long               nuid;
-                       O_surface() { o_trim = 0; o_nurbssurface = 0; }
+                       O_surface() { o_trim = 0; o_nurbssurface = 0; save = 0; nuid = 0; }
     };
 
 struct Property : public PooledObj {
@@ -123,9 +123,9 @@ struct Property : public PooledObj {
     REAL               value;
     int                        save;           /* 1 if in display list         */
                        Property( long _type, long _tag, INREAL _value )
-                       { type = _type; tag = _tag; value = (REAL) _value; }
+                       { type = _type; tag = _tag; value = (REAL) _value; save = 0; }
                        Property( long _tag, INREAL _value )
-                       { type = 0; tag = _tag; value = (REAL) _value; }
+                       { type = 0; tag = _tag; value = (REAL) _value; save = 0; }
     };
 
 class NurbsTessellator;
index cc0b51470652afe530aa6bdf94021600b04ba8ab..ccddc270ff99bd1419bb6af35088841f96e2f836 100644 (file)
@@ -531,16 +531,18 @@ Subdivider::nonSamplingSplit(
                     patchlist.pspec[param].range[1] ) * 0.5;
        split( source, left, right, param, mid );
        Patchlist subpatchlist( patchlist, param, mid );
-       if( left.isnonempty() )
+       if( left.isnonempty() ) {
            if( subpatchlist.cullCheck() == CULL_TRIVIAL_REJECT ) 
                freejarcs( left );
            else
                nonSamplingSplit( left, subpatchlist, subdivisions-1, param );
-       if( right.isnonempty() ) 
+       }
+       if( right.isnonempty() ) {
            if( patchlist.cullCheck() == CULL_TRIVIAL_REJECT ) 
                freejarcs( right );
            else
                nonSamplingSplit( right, patchlist, subdivisions-1, param );
+       }
 
     } else {
        // make bbox calls
index 31cc73a9d086a4240c5af2a2263aaa02383897e8..1cb235443ad3de89634982216d4dc678c21ff915 100644 (file)
@@ -53,8 +53,16 @@ inline long sgn( REAL x )
 
 Varray::Varray( void )
 {
+    int i;
+
     varray = 0;
     size = 0;
+    numquads = 0;
+
+    for (i = 0; i < 1000; i++) {
+        vval[i] = 0;
+        voffset[i] = 0;
+    }
 }
 
 Varray::~Varray( void )
index 74450352d8c32edc904488099fdbe47d2bf9f3f0..d942db7287e7d6ba50d583ffca086ecf9de11d4e 100644 (file)
@@ -309,6 +309,8 @@ directedLine::directedLine()
   nextPolygon = NULL;
   rootBit = 0;/*important to initilzae to 0 meaning not root yet*/
   rootLink = NULL;
+  direction = INCREASING;
+  sline = NULL;
 }
 
 directedLine::~directedLine()
@@ -791,22 +793,30 @@ directedLine* readAllPolygons(char* filename)
 {
   Int i,j;
   FILE* fp = fopen(filename, "r");
-  assert(fp);
   Int nPolygons;
-  fscanf(fp, "%i", &nPolygons);
+  int result;
+
+  assert(fp);
+  result = fscanf(fp, "%i", &nPolygons);
+  assert(result != EOF);
   directedLine *ret = NULL;
 
   for(i=0; i<nPolygons; i++)
     {
       Int nEdges;
-      fscanf(fp, "%i", &nEdges);
-      Real vert[2][2];
+      result = fscanf(fp, "%i", &nEdges);
+      assert(result != EOF);
+      Real vert[2][2] = { { 0 } };
       Real VV[2][2];
       /*the first two vertices*/
-      fscanf(fp, "%f", &(vert[0][0]));
-      fscanf(fp, "%f", &(vert[0][1]));
-      fscanf(fp, "%f", &(vert[1][0]));
-      fscanf(fp, "%f", &(vert[1][1]));
+      result = fscanf(fp, "%f", &(vert[0][0]));
+      assert(result != EOF);
+      result = fscanf(fp, "%f", &(vert[0][1]));
+      assert(result != EOF);
+      result = fscanf(fp, "%f", &(vert[1][0]));
+      assert(result != EOF);
+      result = fscanf(fp, "%f", &(vert[1][1]));
+      assert(result != EOF);
       VV[1][0] = vert[0][0];
       VV[1][1] = vert[0][1];
       sampledLine *sLine = new sampledLine(2, vert);
@@ -818,8 +828,10 @@ thisPoly->rootLinkSet(NULL);
        {
          vert[0][0]=vert[1][0];
          vert[0][1]=vert[1][1];
-         fscanf(fp, "%f", &(vert[1][0]));
-         fscanf(fp, "%f", &(vert[1][1]));
+         result = fscanf(fp, "%f", &(vert[1][0]));
+         assert(result != EOF);
+         result = fscanf(fp, "%f", &(vert[1][1]));
+         assert(result != EOF);
          sLine = new sampledLine(2,vert);
          dLine = new directedLine(INCREASING, sLine);
 dLine->rootLinkSet(thisPoly);
index 814bf32fae019faa3eb943041cc6b32df403285d..b17b9405c1a4979dba38505ea53cfa97066f0e0a 100644 (file)
@@ -127,6 +127,7 @@ monoChain::monoChain(directedLine* cHead, directedLine* cTail)
     current = chainTail;
 
   isKey = 0;
+  keyY = 0;
 }
 
 //insert a new line between prev and this
index 297c6299766ace3f673f4bfe514469223cc85cc2..e097461ac5e92919014b46dd8c7851a5eee62389 100644 (file)
@@ -111,8 +111,8 @@ Int isCusp(directedLine *v)
   else if(A[1] > B[1] && C[1] > B[1])
     return 1;
 
-  if(isAbove(v, v) && isAbove(v, v->getPrev()) ||
-     isBelow(v, v) && isBelow(v, v->getPrev()))
+  if((isAbove(v, v) && isAbove(v, v->getPrev())) ||
+     (isBelow(v, v) && isBelow(v, v->getPrev())))
     return 1;
   else
     return 0;
index e12f88bab12bce73a87c3f9c01485bf2f93fb222..2e70f839363b4aad95ba2409e834fa600eb45d9d 100644 (file)
@@ -207,7 +207,7 @@ void sampleBotRightWithGridLine(Real* botVertex,
     return;
   }
 
-  Int segIndexMono, segIndexPass;
+  Int segIndexMono = 0, segIndexPass;
   findBotRightSegment(rightChain,
                      rightEnd,
                      rightCorner,
@@ -293,7 +293,7 @@ void sampleBotLeftWithGridLine(Real* botVertex,
     return;
   }
 
-  Int segIndexPass, segIndexMono;
+  Int segIndexPass, segIndexMono = 0;
   findBotLeftSegment(leftChain, leftEnd, leftCorner, grid->get_u_value(leftU), segIndexMono, segIndexPass);
 
   sampleBotLeftWithGridLinePost(botVertex,
index b7b929623a2f917e35f2bd3ff88e56d41029ac25..951e937c45f295a120ca70a0578f6ed7381cc693 100644 (file)
@@ -172,7 +172,7 @@ void sampleTopRightWithGridLine(Real* topVertex,
     return;
   }
 
-  Int segIndexSmall, segIndexLarge;
+  Int segIndexSmall = 0, segIndexLarge;
   findTopRightSegment(rightChain,
                       rightStart,
                       rightEnd,
@@ -294,7 +294,7 @@ void sampleTopLeftWithGridLine(Real* topVertex,
                                 primStream* pStream
                                 )
 {
-  Int segIndexSmall, segIndexLarge;
+  Int segIndexSmall = 0, segIndexLarge;
   //if left chain is empty, then there is only one top vertex with one grid 
   //  line
   if(leftEnd < leftStart) {
index 6253a7c09d3767a27a50a8b59d7bded61fa30456..89f6c6e23fe7829ae07d956cb49be6720917c186 100644 (file)
@@ -107,6 +107,9 @@ sampledLine::sampledLine(Real pt1[2], Real pt2[2])
 //needs tp call init to setup
 sampledLine::sampledLine()
 {
+  npoints = 0;
+  points = NULL;
+  next = NULL;
 }
 
 //warning: ONLY pointer is copies!!!
index ae861f864288d350d11283386bb89e244ab791e5..95f87cdc9499dd118d80986137a9ddfcc46fe7b1 100644 (file)
@@ -284,7 +284,12 @@ GLUhalfEdge *__gl_meshMakeEdge( GLUmesh *mesh )
   } 
 
   e = MakeEdge( &mesh->eHead );
-  if (e == NULL) return NULL;
+  if (e == NULL) {
+     memFree(newVertex1);
+     memFree(newVertex2);
+     memFree(newFace);
+     return NULL;
+  }
 
   MakeVertex( newVertex1, e, &mesh->vHead );
   MakeVertex( newVertex2, e->Sym, &mesh->vHead );
index af647af73c98cbc1bda3e61835a01a82142050a1..d1fd5a7d724c2d095399af677846e1c47051025f 100644 (file)
@@ -3526,6 +3526,8 @@ gluScaleImage(GLenum format, GLsizei widthin, GLsizei heightin,
     afterImage =
        malloc(image_size(widthout, heightout, format, GL_UNSIGNED_SHORT));
     if (beforeImage == NULL || afterImage == NULL) {
+       free(beforeImage);
+       free(afterImage);
        return GLU_OUT_OF_MEMORY;
     }
 
@@ -3606,6 +3608,7 @@ int gluBuild1DMipmapLevelsCore(GLenum target, GLint internalFormat,
                    glPixelStorei(GL_UNPACK_SKIP_PIXELS,psm.unpack_skip_pixels);
                    glPixelStorei(GL_UNPACK_ROW_LENGTH, psm.unpack_row_length);
                    glPixelStorei(GL_UNPACK_SWAP_BYTES, psm.unpack_swap_bytes);
+                   free(newImage);
                    return GLU_OUT_OF_MEMORY;
                }
            }
@@ -3760,6 +3763,7 @@ static int bitmapBuild2DMipmaps(GLenum target, GLint internalFormat,
                    glPixelStorei(GL_UNPACK_SKIP_PIXELS,psm.unpack_skip_pixels);
                    glPixelStorei(GL_UNPACK_ROW_LENGTH, psm.unpack_row_length);
                    glPixelStorei(GL_UNPACK_SWAP_BYTES, psm.unpack_swap_bytes);
+                   free(newImage);
                    return GLU_OUT_OF_MEMORY;
                }
            }
@@ -4104,6 +4108,7 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat,
          glPixelStorei(GL_UNPACK_SKIP_PIXELS, psm.unpack_skip_pixels);
          glPixelStorei(GL_UNPACK_ROW_LENGTH, psm.unpack_row_length);
          glPixelStorei(GL_UNPACK_SWAP_BYTES, psm.unpack_swap_bytes);
+         free(srcImage);
          return GLU_OUT_OF_MEMORY;
        }
        /* level userLevel+1 is in srcImage; level userLevel already saved */
@@ -4346,6 +4351,7 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat,
            glPixelStorei(GL_UNPACK_SKIP_PIXELS, psm.unpack_skip_pixels);
            glPixelStorei(GL_UNPACK_ROW_LENGTH, psm.unpack_row_length);
            glPixelStorei(GL_UNPACK_SWAP_BYTES, psm.unpack_swap_bytes);
+           free(srcImage);
            return GLU_OUT_OF_MEMORY;
          }
        }
@@ -7382,6 +7388,8 @@ int gluScaleImage3D(GLenum format,
    afterImage = malloc(imageSize3D(widthOut, heightOut, depthOut, format,
                                   GL_UNSIGNED_SHORT));
    if (beforeImage == NULL || afterImage == NULL) {
+       free(beforeImage);
+       free(afterImage);
        return GLU_OUT_OF_MEMORY;
    }
    retrieveStoreModes3D(&psm);
@@ -8093,6 +8101,7 @@ static int gluBuild3DMipmapLevelsCore(GLenum target, GLint internalFormat,
         glPixelStorei(GL_UNPACK_SWAP_BYTES, psm.unpack_swap_bytes);
         glPixelStorei(GL_UNPACK_SKIP_IMAGES, psm.unpack_skip_images);
         glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, psm.unpack_image_height);
+        free(srcImage);
         return GLU_OUT_OF_MEMORY;
        }
        /* level userLevel+1 is in srcImage; level userLevel already saved */
@@ -8227,6 +8236,7 @@ static int gluBuild3DMipmapLevelsCore(GLenum target, GLint internalFormat,
           glPixelStorei(GL_UNPACK_SWAP_BYTES, psm.unpack_swap_bytes);
           glPixelStorei(GL_UNPACK_SKIP_IMAGES, psm.unpack_skip_images);
           glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, psm.unpack_image_height);
+          free(srcImage);
           return GLU_OUT_OF_MEMORY;
         }
        }
index 938fec03df249547a3c302dca19faf1d2157c102..5234e6d58ac2f4deb6625a5d5a1108b7baf351c9 100644 (file)
@@ -2,11 +2,6 @@ Import('*')
 
 env = env.Clone()
 
-if env['platform'] != 'windows':
-    Return()
-
-target = 'glut32'
-
 env.Replace(CPPDEFINES = [
     'BUILD_GLUT32', 
     'GLUT_BUILDING_LIB', 
@@ -18,14 +13,6 @@ env.AppendUnique(CPPPATH = [
     '#/include',
 ])
 
-env.PrependUnique(LIBS = [
-    'winmm', 
-    'gdi32', 
-    'user32', 
-    'opengl32', 
-    'glu32',
-])
-
 sources = [
     'glut_bitmap.c',
     'glut_bwidth.c',
@@ -61,12 +48,6 @@ sources = [
     'glut_warp.c',
     'glut_win.c',
     'glut_winmisc.c',
-
-    'win32_glx.c',
-    'win32_menu.c',
-    'win32_util.c',
-    'win32_winproc.c',
-    'win32_x11.c',
     
     'glut_8x13.c',
     'glut_9x15.c',
@@ -77,11 +58,52 @@ sources = [
     'glut_roman.c',
     'glut_tr10.c',
     'glut_tr24.c',
-
-    'glut.def',
 ]
 
-env.SharedLibrary(
+if env['platform'] == 'windows':
+    env.PrependUnique(LIBS = [
+        'winmm', 
+        'gdi32', 
+        'user32', 
+        'opengl32', 
+        'glu32',
+    ])
+    target = 'glut32'
+    sources += [
+        'win32_glx.c',
+        'win32_menu.c',
+        'win32_util.c',
+        'win32_winproc.c',
+        'win32_x11.c',
+        'glut.def',
+    ]
+else:
+    env.PrependUnique(LIBS = [
+        'GLU',
+        'GL',
+        'X11',
+        'Xext',
+        'Xmu',
+        'Xi',
+    ])
+    target = 'glut'
+    sources += [
+        'glut_fcb.c',
+        'glut_menu.c',
+        'glut_menu2.c',
+        'glut_glxext.c',
+        'layerutil.c',
+    ]
+
+
+glut = env.SharedLibrary(
     target = target,
     source = sources,
 )
+
+env.InstallSharedLibrary(glut, version=(3, 7, 1))
+
+if env['platform'] == 'windows':
+    glut = env.FindIxes(glut, 'LIBPREFIX', 'LIBSUFFIX')
+
+Export('glut')
index b99e7930564a19899189cff289fb007ad463a25b..fd63fb7c49f98e2b2accb200cbe9696283cb7857 100644 (file)
@@ -321,6 +321,7 @@ captureXFont(Display * dpy, Font font, char *xfont, char *name)
     }
   }
   printf("};\n\n");
+  printf("GLUTAPI const BitmapFontRec %s;\n", name);
   printf("const BitmapFontRec %s = {\n", name);
   printf("\"%s\",\n", xfont);
   printf("%d,\n", last - first + 1);
index 843c63d35ae6d0faecbc56a6f49bd7fad4371f2f..f4e18eb0a4548f8bc1a951f2f871c6a73aa5fe63 100644 (file)
@@ -2064,6 +2064,7 @@ static const BitmapCharRec * const chars[] = {
 &ch255,
 };
 
+GLUTAPI const BitmapFontRec glutBitmap8By13;
 const BitmapFontRec glutBitmap8By13 = {
 "-misc-fixed-medium-r-normal--13-120-75-75-C-80-iso8859-1",
 256,
index 2d5c004e47a653acb622a84ebb8ce245e33982d5..7dbec124d096f88aeb97e17ae97f9c1637fd0342 100644 (file)
@@ -2066,6 +2066,7 @@ static const BitmapCharRec * const chars[] = {
 &ch255,
 };
 
+GLUTAPI const BitmapFontRec glutBitmap9By15;
 const BitmapFontRec glutBitmap9By15 = {
 "-misc-fixed-medium-r-normal--15-140-75-75-C-90-iso8859-1",
 256,
index 703cef38f260571519f55d23501281e19ad4bfd4..3de1750ce6c4c286380c0098559f5e588a0e9eb9 100644 (file)
@@ -1769,6 +1769,7 @@ static const BitmapCharRec * const chars[] = {
 &ch255,
 };
 
+GLUTAPI const BitmapFontRec glutBitmapHelvetica10;
 const BitmapFontRec glutBitmapHelvetica10 = {
 "-adobe-helvetica-medium-r-normal--10-100-75-75-p-56-iso8859-1",
 224,
index 68aed8a2bd65b598bda20c5aac541a76fd996ce7..e6f1bbb5e268f2ed41e483b5bd15f873487aac45 100644 (file)
@@ -1779,6 +1779,7 @@ static const BitmapCharRec * const chars[] = {
 &ch255,
 };
 
+GLUTAPI const BitmapFontRec glutBitmapHelvetica12;
 const BitmapFontRec glutBitmapHelvetica12 = {
 "-adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1",
 224,
index f0800843e8efd1fbaa757b0279890fdac9efa752..3ddcefd6421d85fd1bbb42c1aaa876be3b0019a2 100644 (file)
@@ -1888,6 +1888,7 @@ static const BitmapCharRec * const chars[] = {
 &ch255,
 };
 
+GLUTAPI const BitmapFontRec glutBitmapHelvetica18;
 const BitmapFontRec glutBitmapHelvetica18 = {
 "-adobe-helvetica-medium-r-normal--18-180-75-75-p-98-iso8859-1",
 224,
index 4c4a5ae7503e4f8ea6ed82e17cd1c76a5a0a6f8a..d136823c54f0dbc798b2d987a68c8779dd2ae413 100644 (file)
@@ -225,6 +225,7 @@ menuVisualSetup(void)
             if (!status) {
               XFreeColormap(__glutDisplay, menuColormap);
               free(placeHolders);
+              placeHolders = NULL;
               continue;
             }
           }
@@ -241,6 +242,7 @@ menuVisualSetup(void)
             XFreeColormap(__glutDisplay, menuColormap);
             if (placeHolders) {
               free(placeHolders);
+              placeHolders = NULL;
             }
             continue;
           }
@@ -252,6 +254,7 @@ menuVisualSetup(void)
             XFreeColormap(__glutDisplay, menuColormap);
             if (placeHolders) {
               free(placeHolders);
+              placeHolders = NULL;
             }
             continue;
           }
@@ -263,6 +266,7 @@ menuVisualSetup(void)
             XFreeColormap(__glutDisplay, menuColormap);
             if (placeHolders) {
               free(placeHolders);
+              placeHolders = NULL;
             }
             continue;
           }
@@ -271,6 +275,7 @@ menuVisualSetup(void)
             XFreeColors(__glutDisplay, menuColormap,
               placeHolders, numPlaceHolders, 0);
             free(placeHolders);
+            placeHolders = NULL;
           }
           menuWhite = color.pixel;
           menuVisual = visual->vinfo.visual;
index a29f043b4a8b2ebf8c26a4b0224fc20d905654ac..08f879a5112308f80d45c625c2b52ab85f887d2e 100644 (file)
@@ -1,7 +1,9 @@
 
 /* GENERATED FILE -- DO NOT MODIFY */
 
+#define glutStrokeMonoRoman XXX
 #include "glutstroke.h"
+#undef glutStrokeMonoRoman
 
 /* char: 33 '!' */
 
@@ -2447,5 +2449,6 @@ static const StrokeCharRec chars[] = {
     { 2, char127, 52.381, 104.762 },
 };
 
-StrokeFontRec glutStrokeMonoRoman = { "Roman", 128, chars, 119.048, -33.3333 };
+GLUTAPI const StrokeFontRec glutStrokeMonoRoman;
+const StrokeFontRec glutStrokeMonoRoman = { "Roman", 128, chars, 119.048, -33.3333 };
 
index af2b4ec956d2638c0f150b21c4087089f52366d3..95b9f8160f1cf258bc4de5e7c585f2c2a6f50e2a 100644 (file)
@@ -1,7 +1,9 @@
 
 /* GENERATED FILE -- DO NOT MODIFY */
 
+#define glutStrokeRoman XXX
 #include "glutstroke.h"
+#undef glutStrokeRoman
 
 /* char: 33 '!' */
 
@@ -2447,5 +2449,6 @@ static const StrokeCharRec chars[] = {
     { 2, char127, 33.3333, 66.6667 },
 };
 
-StrokeFontRec glutStrokeRoman = { "Roman", 128, chars, 119.048, -33.3333 };
+GLUTAPI const StrokeFontRec glutStrokeRoman;
+const StrokeFontRec glutStrokeRoman = { "Roman", 128, chars, 119.048, -33.3333 };
 
index 0fac8070ca50a90a95ab1054751b2e026e91e117..dbf5ebde5e068948c14d0fa6b24d15066dadd44d 100644 (file)
@@ -1768,6 +1768,7 @@ static const BitmapCharRec * const chars[] = {
 &ch255,
 };
 
+GLUTAPI const BitmapFontRec glutBitmapTimesRoman10;
 const BitmapFontRec glutBitmapTimesRoman10 = {
 "-adobe-times-medium-r-normal--10-100-75-75-p-54-iso8859-1",
 224,
index 22b0e5160352a245ba6deeeafbee1dc7e26fe83d..5db9d36e197affe60d0f2239e7ae9ccec01bc099 100644 (file)
@@ -2051,6 +2051,7 @@ static const BitmapCharRec * const chars[] = {
 &ch255,
 };
 
+GLUTAPI const BitmapFontRec glutBitmapTimesRoman24;
 const BitmapFontRec glutBitmapTimesRoman24 = {
 "-adobe-times-medium-r-normal--24-240-75-75-p-124-iso8859-1",
 224,
index 74b60314aa2a5b5713264afea5264fbbdc47da41..d6eac7aa516a1586ced00d998a035ecf4d31313a 100644 (file)
@@ -7,6 +7,10 @@
    and is provided without guarantee or warrantee expressed or 
    implied. This program is -not- in the public domain. */
 
+#define GLUT_NO_LIB_PRAGMA  /* Avoid auto library linking when building
+                               the GLUT library itself. */
+#include <GL/glut.h>
+
 #if defined(_MSC_VER)
 #pragma warning (disable:4244)  /* disable bogus conversion warnings */
 #pragma warning (disable:4305)  /* VC++ 5.0 version of above warning. */
index 874b88bc497096e786f8a0e9904d558eeb6365ab..e9a10b4ac731cb9519839e953ca1e267f29458ed 100644 (file)
@@ -2278,14 +2278,14 @@ __glXCreateContextWithConfig(__DRInativeDisplay *dpy, int screen,
         int fbconfigID, void *contextID, drm_context_t *hHWContext)
 {
     __DRIscreen *pDRIScreen;
-    __DRIscreenPrivate *psp;
+    __DRIscreen *psp;
 
     pDRIScreen = __glXFindDRIScreen(dpy, screen);
     if ( (pDRIScreen == NULL) || (pDRIScreen->private == NULL) ) {
         return GL_FALSE;
     }
 
-    psp = (__DRIscreenPrivate *) pDRIScreen->private;
+    psp = (__DRIscreen *) pDRIScreen->private;
 
     if (psp->fd) {
         if (drmCreateContext(psp->fd, hHWContext)) {
@@ -2310,9 +2310,9 @@ __glXGetDrawableInfo(__DRInativeDisplay *dpy, int scrn,
     GLXDrawable drawable = (GLXDrawable) draw;
     drm_clip_rect_t * cliprect;
     Display* display = (Display*)dpy;
-    __DRIscreenPrivate *psp = display->driScreen.private;
-    __DRIcontextPrivate *pcp = (__DRIcontextPrivate *)CurrentContext->driContext.private;
-    __DRIdrawablePrivate *pdp = pcp->driDrawablePriv;
+    __DRIscreen *psp = display->driScreen.private;
+    __DRIcontext *pcp = (__DRIcontext *)CurrentContext->driContext.private;
+    __DRIdrawable *pdp = pcp->driDrawablePriv;
     if (drawable == 0) {
         return GL_FALSE;
     }
@@ -2357,7 +2357,7 @@ xf86DRI_CreateDrawable(__DRInativeDisplay *dpy, int screen, __DRIid drawable,
 {
 
   Display *display = (Display *)dpy;
-  __DRIscreenPrivate *psp = display->driScreen.private;
+  __DRIscreen *psp = display->driScreen.private;
   int ret;
   ret = drmCreateDrawable(psp->fd, hHWDrawable);
   
index e144ed3e1f91aaa4df601cf5f115fd3624dd335f..dad04470a00a52321707490efea5df91792f5831 100644 (file)
@@ -31,6 +31,8 @@
  */
 
 
+#ifdef GLX_DIRECT_RENDERING
+
 #define NEED_REPLIES
 #include <X11/Xlibint.h>
 #include <X11/extensions/Xext.h>
@@ -377,3 +379,5 @@ DRI2CopyRegion(Display * dpy, XID drawable, XserverRegion region,
    UnlockDisplay(dpy);
    SyncHandle();
 }
+
+#endif /* GLX_DIRECT_RENDERING */
index ab24bd8ffe111651478579ad463a06070c52d388..a890feeab2055f21836803c5a8e2656f71489f74 100644 (file)
@@ -280,8 +280,6 @@ static const __DRIextension *loader_extensions[] = {
    NULL
 };
 
-#ifndef GLX_USE_APPLEGL
-
 /**
  * Perform the required libGL-side initialization and call the client-side
  * driver's \c __driCreateNewScreen function.
@@ -292,7 +290,7 @@ static const __DRIextension *loader_extensions[] = {
  * \param driDpy DRI display information.
  * \param createNewScreen  Pointer to the client-side driver's
  *               \c __driCreateNewScreen function.
- * \returns A pointer to the \c __DRIscreenPrivate structure returned by
+ * \returns A pointer to the \c __DRIscreen structure returned by
  *          the client-side driver on success, or \c NULL on failure.
  */
 static void *
@@ -475,17 +473,6 @@ CallCreateNewScreen(Display * dpy, int scrn, __GLXscreenConfigs * psc,
    return NULL;
 }
 
-#else /* !GLX_USE_APPLEGL */
-
-static void *
-CallCreateNewScreen(Display * dpy, int scrn, __GLXscreenConfigs * psc,
-                    __GLXDRIdisplayPrivate * driDpy)
-{
-   return NULL;
-}
-
-#endif /* !GLX_USE_APPLEGL */
-
 static void
 driDestroyContext(__GLXDRIcontext * context,
                   __GLXscreenConfigs * psc, Display * dpy)
@@ -596,8 +583,10 @@ driCreateDrawable(__GLXscreenConfigs * psc,
    pdraw->drawable = drawable;
    pdraw->psc = psc;
 
-   if (!XF86DRICreateDrawable(psc->dpy, psc->scr, drawable, &hwDrawable))
+   if (!XF86DRICreateDrawable(psc->dpy, psc->scr, drawable, &hwDrawable)) {
+      Xfree(pdraw);
       return NULL;
+   }
 
    /* Create a new drawable */
    pdraw->driDrawable =
index 15e15866582c18f84b6db0b07ddaa84d25df1d61..1866b2cc870b5f5bd25914c62b6c1f07a5f8ec9d 100644 (file)
@@ -250,12 +250,14 @@ driCreateContext(__GLXscreenConfigs * psc,
 {
    __GLXDRIcontextPrivate *pcp, *pcp_shared;
    __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) mode;
-   const __DRIcoreExtension *core = psc->core;
+   const __DRIcoreExtension *core;
    __DRIcontext *shared = NULL;
 
    if (!psc || !psc->driScreen)
       return NULL;
 
+   core = psc->core;
+
    if (shareList) {
       pcp_shared = (__GLXDRIcontextPrivate *) shareList->driContext;
       shared = pcp_shared->driContext;
index cd4aede74e4ecddd2ac1d3f345beef6dbd56c6a1..d1c68dd02e1bd359f3f7605c40a2fa533cef9454 100644 (file)
@@ -50,7 +50,7 @@
 #include <xcb/glx.h>
 #endif
 
-static const char __glXGLXClientVendorName[] = "SGI";
+static const char __glXGLXClientVendorName[] = "Mesa Project and SGI";
 static const char __glXGLXClientVersion[] = "1.4";
 
 
@@ -540,6 +540,16 @@ DestroyContext(Display * dpy, GLXContext gc)
    imported = gc->imported;
    gc->xid = None;
 
+   if (gc->currentDpy) {
+      /* This context is bound to some thread.  According to the man page,
+       * we should not actually delete the context until it's unbound.
+       * Note that we set gc->xid = None above.  In MakeContextCurrent()
+       * we check for that and delete the context there.
+       */
+      __glXUnlock();
+      return;
+   }
+
 #ifdef GLX_DIRECT_RENDERING
    /* Destroy the direct rendering context */
    if (gc->driContext) {
@@ -2565,7 +2575,7 @@ glXAllocateMemoryMESA(Display * dpy, int scrn,
    (void) readFreq;
    (void) writeFreq;
    (void) priority;
-#endif /* GLX_DIRECT_RENDERING */
+#endif /* __DRI_ALLOCATE */
 
    return NULL;
 }
@@ -2584,7 +2594,7 @@ glXFreeMemoryMESA(Display * dpy, int scrn, void *pointer)
    (void) dpy;
    (void) scrn;
    (void) pointer;
-#endif /* GLX_DIRECT_RENDERING */
+#endif /* __DRI_ALLOCATE */
 }
 
 
index f1e3e161bec6efd69e51aaa85c80f63335ae76a4..fae1bd9fa629434e69f15266f3279af3f7731a9d 100644 (file)
@@ -475,13 +475,6 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
                IndirectAPI = __glXNewIndirectAPI();
             _glapi_set_dispatch(IndirectAPI);
 
-#ifdef GLX_USE_APPLEGL
-            do {
-               extern void XAppleDRIUseIndirectDispatch(void);
-               XAppleDRIUseIndirectDispatch();
-            } while (0);
-#endif
-
             state = (__GLXattribute *) (gc->client_state_private);
 
             gc->currentContextTag = reply.contextTag;
index e5553cbf76ca32b2ce3c9a4117f1a9fbcd8a1c25..5633a3e4a29a22af80562f49589b96f1ac5e7107 100644 (file)
@@ -150,8 +150,9 @@ FreeScreenConfigs(__GLXdisplayPrivate * priv)
 
 #ifdef GLX_DIRECT_RENDERING
       if (psc->driver_configs) {
-         for (unsigned int i = 0; psc->driver_configs[i]; i++)
-            free((__DRIconfig *) psc->driver_configs[i]);
+         unsigned int j;
+         for (j = 0; psc->driver_configs[j]; j++)
+            free((__DRIconfig *) psc->driver_configs[j]);
          free(psc->driver_configs);
          psc->driver_configs = NULL;
       }
index 473f46d1e504f15517288ed14515ea8e729db7b0..6852128e2ae189032ceedf9886c7c2a3ef0acadf 100644 (file)
@@ -112,6 +112,7 @@ static const struct extension_info known_gl_extensions[] = {
    { GL(ARB_draw_buffers),               VER(0,0), Y, N, N, N },
    { GL(ARB_fragment_program),           VER(0,0), Y, N, N, N },
    { GL(ARB_fragment_program_shadow),    VER(0,0), Y, N, N, N },
+   { GL(ARB_framebuffer_object),         VER(0,0), Y, N, N, N },
    { GL(ARB_imaging),                    VER(0,0), Y, N, N, N },
    { GL(ARB_multisample),                VER(1,3), Y, N, N, N },
    { GL(ARB_multitexture),               VER(1,3), Y, N, N, N },
@@ -150,8 +151,11 @@ static const struct extension_info known_gl_extensions[] = {
    { GL(EXT_depth_bounds_test),          VER(0,0), N, N, N, N },
    { GL(EXT_draw_range_elements),        VER(1,2), Y, N, Y, N },
    { GL(EXT_fog_coord),                  VER(1,4), Y, N, N, N },
+   { GL(EXT_framebuffer_blit),           VER(0,0), Y, N, N, N },
+   { GL(EXT_framebuffer_multisample),    VER(0,0), Y, N, N, N },
    { GL(EXT_framebuffer_object),         VER(0,0), Y, N, N, N },
    { GL(EXT_multi_draw_arrays),          VER(1,4), Y, N, Y, N },
+   { GL(EXT_packed_depth_stencil),       VER(0,0), Y, N, N, N },
    { GL(EXT_packed_pixels),              VER(1,2), Y, N, N, N },
    { GL(EXT_paletted_texture),           VER(0,0), Y, N, N, N },
    { GL(EXT_pixel_buffer_object),        VER(0,0), N, N, N, N },
@@ -209,6 +213,7 @@ static const struct extension_info known_gl_extensions[] = {
    { GL(NV_fragment_program2),           VER(0,0), Y, N, N, N },
    { GL(NV_light_max_exponent),          VER(0,0), Y, N, N, N },
    { GL(NV_multisample_filter_hint),     VER(0,0), Y, N, N, N },
+   { GL(NV_packed_depth_stencil),        VER(0,0), Y, N, N, N },
    { GL(NV_point_sprite),                VER(0,0), Y, N, N, N },
    { GL(NV_texgen_reflection),           VER(0,0), Y, N, N, N },
    { GL(NV_texture_compression_vtc),     VER(0,0), Y, N, N, N },
index 9f1c697487d7b1aa88c236af744f508939c856ef..652c5db1c81078769c3aaa5d01efbdab25019c8b 100644 (file)
@@ -74,6 +74,7 @@ enum
    GL_ARB_draw_buffers_bit,
    GL_ARB_fragment_program_bit,
    GL_ARB_fragment_program_shadow_bit,
+   GL_ARB_framebuffer_object_bit,
    GL_ARB_imaging_bit,
    GL_ARB_multisample_bit,
    GL_ARB_multitexture_bit,
@@ -112,8 +113,11 @@ enum
    GL_EXT_depth_bounds_test_bit,
    GL_EXT_draw_range_elements_bit,
    GL_EXT_fog_coord_bit,
+   GL_EXT_framebuffer_blit_bit,
+   GL_EXT_framebuffer_multisample_bit,
    GL_EXT_framebuffer_object_bit,
    GL_EXT_multi_draw_arrays_bit,
+   GL_EXT_packed_depth_stencil_bit,
    GL_EXT_packed_pixels_bit,
    GL_EXT_paletted_texture_bit,
    GL_EXT_pixel_buffer_object_bit,
@@ -164,6 +168,7 @@ enum
    GL_NV_fragment_program2_bit,
    GL_NV_light_max_exponent_bit,
    GL_NV_multisample_filter_hint_bit,
+   GL_NV_packed_depth_stencil_bit,
    GL_NV_point_sprite_bit,
    GL_NV_texgen_reflection_bit,
    GL_NV_texture_compression_vtc_bit,
index e0cafd43bcb80a18225eedddf54735f9c1d26d07..ea90ce44630d6ac66facc9c37a40d99b99767ff4 100644 (file)
@@ -8604,6 +8604,26 @@ __indirect_glDrawBuffersARB(GLsizei n, const GLenum * bufs)
     }
 }
 
+#define X_GLrop_RenderbufferStorageMultisample 4331
+void
+__indirect_glRenderbufferStorageMultisample(GLenum target, GLsizei samples,
+                                            GLenum internalformat,
+                                            GLsizei width, GLsizei height)
+{
+    __GLXcontext *const gc = __glXGetCurrentContext();
+    const GLuint cmdlen = 24;
+    emit_header(gc->pc, X_GLrop_RenderbufferStorageMultisample, cmdlen);
+    (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4);
+    (void) memcpy((void *) (gc->pc + 8), (void *) (&samples), 4);
+    (void) memcpy((void *) (gc->pc + 12), (void *) (&internalformat), 4);
+    (void) memcpy((void *) (gc->pc + 16), (void *) (&width), 4);
+    (void) memcpy((void *) (gc->pc + 20), (void *) (&height), 4);
+    gc->pc += cmdlen;
+    if (__builtin_expect(gc->pc > gc->limit, 0)) {
+        (void) __glXFlushRenderBuffer(gc, gc->pc);
+    }
+}
+
 #define X_GLrop_SampleMaskSGIS 2048
 void
 __indirect_glSampleMaskSGIS(GLclampf value, GLboolean invert)
@@ -10597,6 +10617,52 @@ __indirect_glRenderbufferStorageEXT(GLenum target, GLenum internalformat,
     }
 }
 
+#define X_GLrop_BlitFramebufferEXT 4330
+void
+__indirect_glBlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1,
+                                GLint srcY1, GLint dstX0, GLint dstY0,
+                                GLint dstX1, GLint dstY1, GLbitfield mask,
+                                GLenum filter)
+{
+    __GLXcontext *const gc = __glXGetCurrentContext();
+    const GLuint cmdlen = 44;
+    emit_header(gc->pc, X_GLrop_BlitFramebufferEXT, cmdlen);
+    (void) memcpy((void *) (gc->pc + 4), (void *) (&srcX0), 4);
+    (void) memcpy((void *) (gc->pc + 8), (void *) (&srcY0), 4);
+    (void) memcpy((void *) (gc->pc + 12), (void *) (&srcX1), 4);
+    (void) memcpy((void *) (gc->pc + 16), (void *) (&srcY1), 4);
+    (void) memcpy((void *) (gc->pc + 20), (void *) (&dstX0), 4);
+    (void) memcpy((void *) (gc->pc + 24), (void *) (&dstY0), 4);
+    (void) memcpy((void *) (gc->pc + 28), (void *) (&dstX1), 4);
+    (void) memcpy((void *) (gc->pc + 32), (void *) (&dstY1), 4);
+    (void) memcpy((void *) (gc->pc + 36), (void *) (&mask), 4);
+    (void) memcpy((void *) (gc->pc + 40), (void *) (&filter), 4);
+    gc->pc += cmdlen;
+    if (__builtin_expect(gc->pc > gc->limit, 0)) {
+        (void) __glXFlushRenderBuffer(gc, gc->pc);
+    }
+}
+
+#define X_GLrop_FramebufferTextureLayerEXT 237
+void
+__indirect_glFramebufferTextureLayerEXT(GLenum target, GLenum attachment,
+                                        GLuint texture, GLint level,
+                                        GLint layer)
+{
+    __GLXcontext *const gc = __glXGetCurrentContext();
+    const GLuint cmdlen = 24;
+    emit_header(gc->pc, X_GLrop_FramebufferTextureLayerEXT, cmdlen);
+    (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4);
+    (void) memcpy((void *) (gc->pc + 8), (void *) (&attachment), 4);
+    (void) memcpy((void *) (gc->pc + 12), (void *) (&texture), 4);
+    (void) memcpy((void *) (gc->pc + 16), (void *) (&level), 4);
+    (void) memcpy((void *) (gc->pc + 20), (void *) (&layer), 4);
+    gc->pc += cmdlen;
+    if (__builtin_expect(gc->pc > gc->limit, 0)) {
+        (void) __glXFlushRenderBuffer(gc, gc->pc);
+    }
+}
+
 
 #  undef FASTCALL
 #  undef NOINLINE
index 0719a1b30243dbac7a80e30b77aa995bc60c954c..19a8c0d134aa34a82bcce54be91e45ef17a14f90 100644 (file)
@@ -572,6 +572,7 @@ extern HIDDEN void __indirect_glGetQueryObjectuivARB(GLuint id, GLenum pname, GL
 extern HIDDEN void __indirect_glGetQueryivARB(GLenum target, GLenum pname, GLint * params);
 extern HIDDEN GLboolean __indirect_glIsQueryARB(GLuint id);
 extern HIDDEN void __indirect_glDrawBuffersARB(GLsizei n, const GLenum * bufs);
+extern HIDDEN void __indirect_glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
 extern HIDDEN void __indirect_glSampleMaskSGIS(GLclampf value, GLboolean invert);
 extern HIDDEN void __indirect_glSamplePatternSGIS(GLenum pattern);
 extern HIDDEN void __indirect_glColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer);
@@ -710,6 +711,8 @@ extern HIDDEN void __indirect_glGetRenderbufferParameterivEXT(GLenum target, GLe
 extern HIDDEN GLboolean __indirect_glIsFramebufferEXT(GLuint framebuffer);
 extern HIDDEN GLboolean __indirect_glIsRenderbufferEXT(GLuint renderbuffer);
 extern HIDDEN void __indirect_glRenderbufferStorageEXT(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+extern HIDDEN void __indirect_glBlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+extern HIDDEN void __indirect_glFramebufferTextureLayerEXT(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
 
 #  undef HIDDEN
 #  undef FASTCALL
index 852fe712c668018adcc31aea2aa8e754a079152c..73ca993027badc05fa252bc9372b7bd2a5c35c3a 100644 (file)
@@ -588,6 +588,10 @@ __GLapi * __glXNewIndirectAPI( void )
 
     glAPI->DrawBuffersARB = __indirect_glDrawBuffersARB;
 
+    /*  45. GL_ARB_framebuffer_object */
+
+    glAPI->RenderbufferStorageMultisample = __indirect_glRenderbufferStorageMultisample;
+
     /*  25. GL_SGIS_multisample */
 
     glAPI->SampleMaskSGIS = __indirect_glSampleMaskSGIS;
@@ -768,6 +772,14 @@ __GLapi * __glXNewIndirectAPI( void )
     glAPI->IsRenderbufferEXT = __indirect_glIsRenderbufferEXT;
     glAPI->RenderbufferStorageEXT = __indirect_glRenderbufferStorageEXT;
 
+    /* 316. GL_EXT_framebuffer_blit */
+
+    glAPI->BlitFramebufferEXT = __indirect_glBlitFramebufferEXT;
+
+    /* 329. GL_EXT_texture_array */
+
+    glAPI->FramebufferTextureLayerEXT = __indirect_glFramebufferTextureLayerEXT;
+
     return glAPI;
 }
 
index f2d0dd54355b6de9b10c5e63e57e7788962d0bb2..ba266003f705dfcb1bbc2840aa68bae64d2e6bb8 100644 (file)
@@ -115,6 +115,10 @@ Bool XF86DRIGetDeviceInfo(Display * dpy, int screen,
                           int *fbSize, int *fbStride, int *devPrivateSize,
                           void **pDevPrivate);
 
+Bool XF86DRIOpenFullScreen(Display * dpy, int screen, Drawable drawable);
+
+Bool XF86DRICloseFullScreen(Display * dpy, int screen, Drawable drawable);
+
 _XFUNCPROTOEND
 #endif /* _XF86DRI_SERVER_ */
 #endif /* _XF86DRI_H_ */
index 8300b3014416f4a51b24dcdcab6e95f93851ec25..a815f46b4a1551514d0f57460522b4b19142539d 100644 (file)
@@ -18,11 +18,10 @@ include sources.mak
 
 
 
-
-# Default: build dependencies, then asm_subdirs, then convenience
-# libs (.a) and finally the device drivers:
-default: depend asm_subdirs libmesa.a libmesagallium.a libglapi.a \
-       driver_subdirs
+# Default: build dependencies, then asm_subdirs, GLSL built-in lib,
+# then convenience libs (.a) and finally the device drivers:
+default: depend asm_subdirs glsl_builtin libmesa.a libmesagallium.a \
+       libglapi.a driver_subdirs
 
 
 
@@ -30,20 +29,16 @@ default: depend asm_subdirs libmesa.a libmesagallium.a libglapi.a \
 # Helper libraries used by many drivers:
 
 # Make archive of core mesa object files
-libmesa.a: $(MESA_OBJECTS)
-       @ $(MKLIB) -o mesa -static $(MESA_OBJECTS)
+libmesa.a: $(MESA_OBJECTS) $(GLSL_LIBS)
+       @ $(MKLIB) -o mesa -static $(MESA_OBJECTS) $(GLSL_LIBS)
 
 # Make archive of subset of core mesa object files for gallium
-libmesagallium.a: $(MESA_GALLIUM_OBJECTS)
-       @ $(MKLIB) -o mesagallium -static $(MESA_GALLIUM_OBJECTS)
+libmesagallium.a: $(MESA_GALLIUM_OBJECTS) $(GLSL_LIBS)
+       @ $(MKLIB) -o mesagallium -static $(MESA_GALLIUM_OBJECTS) $(GLSL_LIBS)
 
 # Make archive of gl* API dispatcher functions only
 libglapi.a: $(GLAPI_OBJECTS)
-       @if [ "${WINDOW_SYSTEM}" = "dri" ] ; then \
-               touch libglapi.a ; \
-       else \
-               $(MKLIB) -o glapi -static $(GLAPI_OBJECTS) ; \
-       fi
+       $(MKLIB) -o glapi -static $(GLAPI_OBJECTS)
 
 ######################################################################
 # Device drivers
@@ -63,6 +58,12 @@ asm_subdirs:
        fi
 
 
+######################################################################
+# GLSL built-in library
+glsl_builtin:
+       (cd shader/slang/library && $(MAKE)) || exit 1 ;
+
+
 ######################################################################
 # Dependency generation
 
@@ -156,6 +157,7 @@ clean:
        -rm -f depend depend.bak libmesa.a libglapi.a
        -rm -f drivers/*/*.o
        -rm -f *.pc
+       -rm -f shader/slang/library/*_gc.h
        -@cd drivers/dri && $(MAKE) clean
        -@cd drivers/x11 && $(MAKE) clean
        -@cd drivers/osmesa && $(MAKE) clean
index 097c390a83e2625e402cc415fcfb2cb021b836ad..e894c6277d19a220df3df28daf7068770e557d18 100644 (file)
@@ -218,7 +218,6 @@ clean:
        -$(call UNLINK,vbo/*.o)
        -$(call UNLINK,shader/*.o)
        -$(call UNLINK,shader/slang/*.o)
-       -$(call UNLINK,shader/grammar/*.o)
        -$(call UNLINK,sparc/*.o)
        -$(call UNLINK,ppc/*.o)
        -$(call UNLINK,swrast/*.o)
index cad56763208de6e46c9903e2d0223b52f1aad470..bdcfffed4baf49e18c566e8af4e10f5f0c90babf 100644 (file)
@@ -38,6 +38,7 @@ if env['platform'] != 'winddk':
                'main/clear.c',
                'main/clip.c',
                'main/colortab.c',
+               'main/condrender.c',
                'main/context.c',
                'main/convolve.c',
                'main/cpuinfo.c',
@@ -56,6 +57,7 @@ if env['platform'] != 'winddk':
                'main/feedback.c',
                'main/ffvertex_prog.c',
                'main/fog.c',
+               'main/formats.c',
                'main/framebuffer.c',
                'main/get.c',
                'main/getstring.c',
@@ -78,6 +80,7 @@ if env['platform'] != 'winddk':
                'main/rastpos.c',
                'main/rbadaptors.c',
                'main/readpix.c',
+               'main/remap.c',
                'main/renderbuffer.c',
                'main/scissor.c',
                'main/shaders.c',
@@ -90,6 +93,7 @@ if env['platform'] != 'winddk':
                'main/texcompress_fxt1.c',
                'main/texenv.c',
                'main/texenvprogram.c',
+               'main/texfetch.c',
                'main/texformat.c',
                'main/texgen.c',
                'main/texgetimage.c',
@@ -100,6 +104,7 @@ if env['platform'] != 'winddk':
                'main/texstate.c',
                'main/texstore.c',
                'main/varray.c',
+               'main/version.c',
                'main/viewport.c',
                'main/vtxfmt.c',
        ]
@@ -158,10 +163,10 @@ if env['platform'] != 'winddk':
                'state_tracker/st_cb_blit.c',
                'state_tracker/st_cb_bufferobjects.c',
                'state_tracker/st_cb_clear.c',
+               'state_tracker/st_cb_condrender.c',
                'state_tracker/st_cb_flush.c',
                'state_tracker/st_cb_drawpixels.c',
                'state_tracker/st_cb_fbo.c',
-               'state_tracker/st_cb_get.c',
                'state_tracker/st_cb_feedback.c',
                'state_tracker/st_cb_program.c',
                'state_tracker/st_cb_queryobj.c',
@@ -187,7 +192,6 @@ if env['platform'] != 'winddk':
                'shader/arbprogparse.c',
                'shader/arbprogram.c',
                'shader/atifragshader.c',
-               'shader/grammar/grammar_mesa.c',
                'shader/hash_table.c',
                'shader/lex.yy.c',
                'shader/nvfragparse.c',
@@ -225,7 +229,6 @@ if env['platform'] != 'winddk':
                'shader/slang/slang_link.c',
                'shader/slang/slang_log.c',
                'shader/slang/slang_mem.c',
-               'shader/slang/slang_preprocess.c',
                'shader/slang/slang_print.c',
                'shader/slang/slang_simplify.c',
                'shader/slang/slang_storage.c',
@@ -336,7 +339,9 @@ if env['platform'] != 'winddk':
                # Add the dir containing the generated header (somewhere inside  the
                # build dir) to the include path  
                env.Append(CPPPATH = [matypes[0].dir])
-       
+
+       SConscript('shader/slang/library/SConscript')
+
        #
        # Libraries
        # 
index 0f8447cb70f4ac16798c67980cea07aa5f1adc2b..5c5e17820d69d800f43c97f2c649f7a6aa14ef11 100644 (file)
@@ -115,7 +115,6 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
    driver->CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d;
    driver->CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d;
    driver->GetCompressedTexImage = _mesa_get_compressed_teximage;
-   driver->CompressedTextureSize = _mesa_compressed_texture_size;
    driver->BindTexture = NULL;
    driver->NewTextureObject = _mesa_new_texture_object;
    driver->DeleteTexture = _mesa_delete_texture_object;
@@ -125,8 +124,6 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
    driver->UnmapTexture = NULL;
    driver->TextureMemCpy = _mesa_memcpy; 
    driver->IsTextureResident = NULL;
-   driver->PrioritizeTexture = NULL;
-   driver->ActiveTexture = NULL;
    driver->UpdateTexturePalette = NULL;
 
    /* imaging */
@@ -183,22 +180,8 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
    driver->TexGen = NULL;
    driver->TexEnv = NULL;
    driver->TexParameter = NULL;
-   driver->TextureMatrix = NULL;
    driver->Viewport = NULL;
 
-   /* vertex arrays */
-   driver->VertexPointer = NULL;
-   driver->NormalPointer = NULL;
-   driver->ColorPointer = NULL;
-   driver->FogCoordPointer = NULL;
-   driver->IndexPointer = NULL;
-   driver->SecondaryColorPointer = NULL;
-   driver->TexCoordPointer = NULL;
-   driver->EdgeFlagPointer = NULL;
-   driver->VertexAttribPointer = NULL;
-   driver->LockArraysEXT = NULL;
-   driver->UnlockArraysEXT = NULL;
-
    /* state queries */
    driver->GetBooleanv = NULL;
    driver->GetDoublev = NULL;
@@ -281,11 +264,23 @@ _mesa_init_driver_state(GLcontext *ctx)
                                  ctx->Color.BlendDstRGB,
                                  ctx->Color.BlendSrcA, ctx->Color.BlendDstA);
 
-   ctx->Driver.ColorMask(ctx,
-                         ctx->Color.ColorMask[RCOMP],
-                         ctx->Color.ColorMask[GCOMP],
-                         ctx->Color.ColorMask[BCOMP],
-                         ctx->Color.ColorMask[ACOMP]);
+   if (ctx->Driver.ColorMaskIndexed) {
+      GLuint i;
+      for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
+         ctx->Driver.ColorMaskIndexed(ctx, i,
+                                      ctx->Color.ColorMask[0][RCOMP],
+                                      ctx->Color.ColorMask[0][GCOMP],
+                                      ctx->Color.ColorMask[0][BCOMP],
+                                      ctx->Color.ColorMask[0][ACOMP]);
+      }
+   }
+   else {
+      ctx->Driver.ColorMask(ctx,
+                            ctx->Color.ColorMask[0][RCOMP],
+                            ctx->Color.ColorMask[0][GCOMP],
+                            ctx->Color.ColorMask[0][BCOMP],
+                            ctx->Color.ColorMask[0][ACOMP]);
+   }
 
    ctx->Driver.CullFace(ctx, ctx->Polygon.CullFaceMode);
    ctx->Driver.DepthFunc(ctx, ctx->Depth.Func);
index e1732241b3a0a98b9e5ff3366b39a051bec156f7..c4dbfa6d7d9bfe1ce4852a6d956842cbd5d98cc5 100644 (file)
@@ -43,6 +43,7 @@
 #include "main/depth.h"
 #include "main/enable.h"
 #include "main/fbobject.h"
+#include "main/formats.h"
 #include "main/image.h"
 #include "main/macros.h"
 #include "main/matrix.h"
@@ -106,11 +107,11 @@ struct save_state
    GLboolean AlphaEnabled;
 
    /** META_BLEND */
-   GLboolean BlendEnabled;
+   GLbitfield BlendEnabled;
    GLboolean ColorLogicOpEnabled;
 
    /** META_COLOR_MASK */
-   GLubyte ColorMask[4];
+   GLubyte ColorMask[MAX_DRAW_BUFFERS][4];
 
    /** META_DEPTH_TEST */
    struct gl_depthbuffer_attrib Depth;
@@ -303,40 +304,10 @@ _mesa_meta_init(GLcontext *ctx)
 void
 _mesa_meta_free(GLcontext *ctx)
 {
-   struct gl_meta_state *meta = ctx->Meta;
-
-   if (_mesa_get_current_context()) {
-      /* if there's no current context, these textures, buffers, etc should
-       * still get freed by _mesa_free_context_data().
-       */
-
-      /* the temporary texture */
-      _mesa_DeleteTextures(1, &meta->TempTex.TexObj);
-
-      /* glBlitFramebuffer */
-      _mesa_DeleteBuffersARB(1, & meta->Blit.VBO);
-      _mesa_DeleteVertexArraysAPPLE(1, &meta->Blit.ArrayObj);
-      _mesa_DeletePrograms(1, &meta->Blit.DepthFP);
-
-      /* glClear */
-      _mesa_DeleteBuffersARB(1, & meta->Clear.VBO);
-      _mesa_DeleteVertexArraysAPPLE(1, &meta->Clear.ArrayObj);
-
-      /* glCopyPixels */
-      _mesa_DeleteBuffersARB(1, & meta->CopyPix.VBO);
-      _mesa_DeleteVertexArraysAPPLE(1, &meta->CopyPix.ArrayObj);
-
-      /* glDrawPixels */
-      _mesa_DeleteVertexArraysAPPLE(1, &meta->DrawPix.ArrayObj);
-      _mesa_DeletePrograms(1, &meta->DrawPix.DepthFP);
-      _mesa_DeletePrograms(1, &meta->DrawPix.StencilFP);
-
-      /* glBitmap */
-      _mesa_DeleteBuffersARB(1, & meta->Bitmap.VBO);
-      _mesa_DeleteVertexArraysAPPLE(1, &meta->Bitmap.ArrayObj);
-      _mesa_DeleteTextures(1, &meta->Bitmap.Tex.TexObj);
-   }
-
+   /* Note: Any textures, VBOs, etc, that we allocate should get
+    * freed by the normal context destruction code.  But this would be
+    * the place to free other meta data someday.
+    */
    _mesa_free(ctx->Meta);
    ctx->Meta = NULL;
 }
@@ -364,19 +335,29 @@ _mesa_meta_begin(GLcontext *ctx, GLbitfield state)
 
    if (state & META_BLEND) {
       save->BlendEnabled = ctx->Color.BlendEnabled;
-      if (ctx->Color.BlendEnabled)
-         _mesa_set_enable(ctx, GL_BLEND, GL_FALSE);
+      if (ctx->Color.BlendEnabled) {
+         if (ctx->Extensions.EXT_draw_buffers2) {
+            GLuint i;
+            for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
+               _mesa_set_enablei(ctx, GL_BLEND, i, GL_FALSE);
+            }
+         }
+         else {
+            _mesa_set_enable(ctx, GL_BLEND, GL_FALSE);
+         }
+      }
       save->ColorLogicOpEnabled = ctx->Color.ColorLogicOpEnabled;
       if (ctx->Color.ColorLogicOpEnabled)
          _mesa_set_enable(ctx, GL_COLOR_LOGIC_OP, GL_FALSE);
    }
 
    if (state & META_COLOR_MASK) {
-      COPY_4V(save->ColorMask, ctx->Color.ColorMask);
-      if (!ctx->Color.ColorMask[0] ||
-          !ctx->Color.ColorMask[1] ||
-          !ctx->Color.ColorMask[2] ||
-          !ctx->Color.ColorMask[3])
+      memcpy(save->ColorMask, ctx->Color.ColorMask,
+             sizeof(ctx->Color.ColorMask));
+      if (!ctx->Color.ColorMask[0][0] ||
+          !ctx->Color.ColorMask[0][1] ||
+          !ctx->Color.ColorMask[0][2] ||
+          !ctx->Color.ColorMask[0][3])
          _mesa_ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
    }
 
@@ -595,16 +576,38 @@ _mesa_meta_end(GLcontext *ctx)
    }
 
    if (state & META_BLEND) {
-      if (ctx->Color.BlendEnabled != save->BlendEnabled)
-         _mesa_set_enable(ctx, GL_BLEND, save->BlendEnabled);
+      if (ctx->Color.BlendEnabled != save->BlendEnabled) {
+         if (ctx->Extensions.EXT_draw_buffers2) {
+            GLuint i;
+            for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
+               _mesa_set_enablei(ctx, GL_BLEND, i, (save->BlendEnabled >> i) & 1);
+            }
+         }
+         else {
+            _mesa_set_enable(ctx, GL_BLEND, (save->BlendEnabled & 1));
+         }
+      }
       if (ctx->Color.ColorLogicOpEnabled != save->ColorLogicOpEnabled)
          _mesa_set_enable(ctx, GL_COLOR_LOGIC_OP, save->ColorLogicOpEnabled);
    }
 
    if (state & META_COLOR_MASK) {
-      if (!TEST_EQ_4V(ctx->Color.ColorMask, save->ColorMask))
-         _mesa_ColorMask(save->ColorMask[0], save->ColorMask[1],
-                         save->ColorMask[2], save->ColorMask[3]);
+      GLuint i;
+      for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
+         if (!TEST_EQ_4V(ctx->Color.ColorMask[i], save->ColorMask[i])) {
+            if (i == 0) {
+               _mesa_ColorMask(save->ColorMask[i][0], save->ColorMask[i][1],
+                               save->ColorMask[i][2], save->ColorMask[i][3]);
+            }
+            else {
+               _mesa_ColorMaskIndexed(i,
+                                      save->ColorMask[i][0],
+                                      save->ColorMask[i][1],
+                                      save->ColorMask[i][2],
+                                      save->ColorMask[i][3]);
+            }
+         }
+      }
    }
 
    if (state & META_DEPTH_TEST) {
@@ -1055,7 +1058,7 @@ init_blit_depth_pixels(GLcontext *ctx)
 
 
 /**
- * Try to do a glBiltFramebuffer using no-copy texturing.
+ * Try to do a glBlitFramebuffer using no-copy texturing.
  * We can do this when the src renderbuffer is actually a texture.
  * But if the src buffer == dst buffer we cannot do this.
  *
@@ -1078,8 +1081,13 @@ blitframebuffer_texture(GLcontext *ctx,
 
       if (readAtt && readAtt->Texture) {
          const struct gl_texture_object *texObj = readAtt->Texture;
+         const GLuint srcLevel = readAtt->TextureLevel;
          const GLenum minFilterSave = texObj->MinFilter;
          const GLenum magFilterSave = texObj->MagFilter;
+         const GLint baseLevelSave = texObj->BaseLevel;
+         const GLint maxLevelSave = texObj->MaxLevel;
+         const GLenum wrapSSave = texObj->WrapS;
+         const GLenum wrapTSave = texObj->WrapT;
          const GLenum target = texObj->Target;
 
          if (drawAtt->Texture == readAtt->Texture) {
@@ -1105,8 +1113,11 @@ blitframebuffer_texture(GLcontext *ctx,
          _mesa_BindTexture(target, texObj->Name);
          _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, filter);
          _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, filter);
+         _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, srcLevel);
+         _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, srcLevel);
+         _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+         _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
          _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-         /*_mesa_set_enable(ctx, GL_TEXTURE_RECTANGLE, GL_FALSE);*/
          _mesa_set_enable(ctx, target, GL_TRUE);
 
          /* Prepare vertex data (the VBO was previously created and bound) */
@@ -1119,8 +1130,7 @@ blitframebuffer_texture(GLcontext *ctx,
 
             if (target == GL_TEXTURE_2D) {
                const struct gl_texture_image *texImage
-                   = _mesa_select_tex_image(ctx, texObj, target,
-                                            readAtt->TextureLevel);
+                   = _mesa_select_tex_image(ctx, texObj, target, srcLevel);
                s0 = srcX0 / (float) texImage->Width;
                s1 = srcX1 / (float) texImage->Width;
                t0 = srcY0 / (float) texImage->Height;
@@ -1157,11 +1167,15 @@ blitframebuffer_texture(GLcontext *ctx,
 
          _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
 
-         /* Restore texture's filter state, the texture binding will
+         /* Restore texture object state, the texture binding will
           * be restored by _mesa_meta_end().
           */
          _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, minFilterSave);
          _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, magFilterSave);
+         _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, baseLevelSave);
+         _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, maxLevelSave);
+         _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, wrapSSave);
+         _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, wrapTSave);
 
          /* Done with color buffer */
          mask &= ~GL_COLOR_BUFFER_BIT;
@@ -1365,8 +1379,6 @@ _mesa_meta_Clear(GLcontext *ctx, GLbitfield buffers)
       /* create vertex array buffer */
       _mesa_GenBuffersARB(1, &clear->VBO);
       _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, clear->VBO);
-      _mesa_BufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(verts),
-                          NULL, GL_DYNAMIC_DRAW_ARB);
 
       /* setup vertex arrays */
       _mesa_VertexPointer(3, GL_FLOAT, sizeof(struct vertex), OFFSET(x));
@@ -1442,7 +1454,8 @@ _mesa_meta_Clear(GLcontext *ctx, GLbitfield buffers)
       }
 
       /* upload new vertex data */
-      _mesa_BufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts);
+      _mesa_BufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(verts), verts,
+                         GL_DYNAMIC_DRAW_ARB);
    }
 
    /* draw quad */
@@ -2083,21 +2096,63 @@ _mesa_meta_Bitmap(GLcontext *ctx,
  * Check if the call to _mesa_meta_GenerateMipmap() will require a
  * software fallback.  The fallback path will require that the texture
  * images are mapped.
+ * \return GL_TRUE if a fallback is needed, GL_FALSE otherwise
  */
 GLboolean
 _mesa_meta_check_generate_mipmap_fallback(GLcontext *ctx, GLenum target,
                                           struct gl_texture_object *texObj)
 {
-   struct gl_texture_image *baseImage =
-      _mesa_select_tex_image(ctx, texObj, target, texObj->BaseLevel);
+   const GLuint fboSave = ctx->DrawBuffer->Name;
+   struct gen_mipmap_state *mipmap = &ctx->Meta->Mipmap;
+   struct gl_texture_image *baseImage;
+   GLuint srcLevel;
+   GLenum status;
 
    /* check for fallbacks */
    if (!ctx->Extensions.EXT_framebuffer_object ||
-       target == GL_TEXTURE_3D ||
-       !baseImage ||
-       baseImage->IsCompressed) {
+       target == GL_TEXTURE_3D) {
       return GL_TRUE;
    }
+
+   srcLevel = texObj->BaseLevel;
+   baseImage = _mesa_select_tex_image(ctx, texObj, target, srcLevel);
+   if (!baseImage || _mesa_is_format_compressed(baseImage->TexFormat)) {
+      return GL_TRUE;
+   }
+
+   /*
+    * Test that we can actually render in the texture's format.
+    */
+   if (!mipmap->FBO)
+      _mesa_GenFramebuffersEXT(1, &mipmap->FBO);
+   _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, mipmap->FBO);
+
+   if (target == GL_TEXTURE_1D) {
+      _mesa_FramebufferTexture1DEXT(GL_FRAMEBUFFER_EXT,
+                                    GL_COLOR_ATTACHMENT0_EXT,
+                                    target, texObj->Name, srcLevel);
+   }
+   else if (target == GL_TEXTURE_3D) {
+      GLint zoffset = 0;
+      _mesa_FramebufferTexture3DEXT(GL_FRAMEBUFFER_EXT,
+                                    GL_COLOR_ATTACHMENT0_EXT,
+                                    target, texObj->Name, srcLevel, zoffset);
+   }
+   else {
+      /* 2D / cube */
+      _mesa_FramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
+                                    GL_COLOR_ATTACHMENT0_EXT,
+                                    target, texObj->Name, srcLevel);
+   }
+
+   status = _mesa_CheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
+
+   _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboSave);
+
+   if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
+      return GL_TRUE;
+   }
+
    return GL_FALSE;
 }
 
@@ -2126,6 +2181,7 @@ _mesa_meta_GenerateMipmap(GLcontext *ctx, GLenum target,
    const GLenum wrapTSave = texObj->WrapT;
    const GLenum wrapRSave = texObj->WrapR;
    const GLuint fboSave = ctx->DrawBuffer->Name;
+   const GLuint original_active_unit = ctx->Texture.CurrentUnit;
    GLenum faceTarget;
    GLuint dstLevel;
    GLuint border = 0;
@@ -2146,6 +2202,9 @@ _mesa_meta_GenerateMipmap(GLcontext *ctx, GLenum target,
 
    _mesa_meta_begin(ctx, META_ALL);
 
+   if (original_active_unit != 0)
+      _mesa_BindTexture(target, texObj->Name);
+
    if (mipmap->ArrayObj == 0) {
       /* one-time setup */
 
@@ -2171,10 +2230,8 @@ _mesa_meta_GenerateMipmap(GLcontext *ctx, GLenum target,
    }
 
    if (!mipmap->FBO) {
-      /* Bind the new renderbuffer to the color attachment point. */
       _mesa_GenFramebuffersEXT(1, &mipmap->FBO);
    }
-
    _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, mipmap->FBO);
 
    _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@@ -2377,7 +2434,7 @@ _mesa_meta_GenerateMipmap(GLcontext *ctx, GLenum target,
       _mesa_DrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
 
       /* sanity check */
-      status = _mesa_CheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT);
+      status = _mesa_CheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
       if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
          abort();
          break;
@@ -2443,7 +2500,6 @@ copy_tex_image(GLcontext *ctx, GLuint dims, GLenum target, GLint level,
                GLenum internalFormat, GLint x, GLint y,
                GLsizei width, GLsizei height, GLint border)
 {
-   struct gl_texture_unit *texUnit;
    struct gl_texture_object *texObj;
    struct gl_texture_image *texImage;
    GLsizei postConvWidth = width, postConvHeight = height;
@@ -2451,8 +2507,7 @@ copy_tex_image(GLcontext *ctx, GLuint dims, GLenum target, GLint level,
    GLint bpp;
    void *buf;
 
-   texUnit = _mesa_get_current_tex_unit(ctx);
-   texObj = _mesa_select_tex_object(ctx, texUnit, target);
+   texObj = _mesa_get_current_tex_object(ctx, target);
    texImage = _mesa_get_tex_image(ctx, texObj, target, level);
 
    format = _mesa_base_tex_format(ctx, internalFormat);
@@ -2472,11 +2527,11 @@ copy_tex_image(GLcontext *ctx, GLuint dims, GLenum target, GLint level,
       return;
    }
 
-   if (texImage->TexFormat == &_mesa_null_texformat)
-       texImage->TexFormat = ctx->Driver.ChooseTextureFormat(ctx,
-                                                             internalFormat,
-                                                             format,
-                                                             type);
+   if (texImage->TexFormat == MESA_FORMAT_NONE)
+      texImage->TexFormat = ctx->Driver.ChooseTextureFormat(ctx,
+                                                            internalFormat,
+                                                            format,
+                                                            type);
 
    _mesa_unlock_texture(ctx, texObj); /* need to unlock first */
 
@@ -2562,18 +2617,16 @@ copy_tex_sub_image(GLcontext *ctx, GLuint dims, GLenum target, GLint level,
                    GLint x, GLint y,
                    GLsizei width, GLsizei height)
 {
-   struct gl_texture_unit *texUnit;
    struct gl_texture_object *texObj;
    struct gl_texture_image *texImage;
    GLenum format, type;
    GLint bpp;
    void *buf;
 
-   texUnit = _mesa_get_current_tex_unit(ctx);
-   texObj = _mesa_select_tex_object(ctx, texUnit, target);
+   texObj = _mesa_get_current_tex_object(ctx, target);
    texImage = _mesa_select_tex_image(ctx, texObj, target, level);
 
-   format = texImage->TexFormat->BaseFormat;
+   format = _mesa_get_format_base_format(texImage->TexFormat);
    type = get_temp_image_type(ctx, format);
    bpp = _mesa_bytes_per_pixel(format, type);
    if (bpp <= 0) {
index 93593403c132052a464ef0e2ba188cb0885b3fb8..62a3269d17188df6f5a2a2cdba4fbbb7ee8107b4 100644 (file)
@@ -407,10 +407,10 @@ dfbClear( GLcontext *ctx, GLbitfield mask )
 #define BUFFER_BIT_MASK (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_FRONT_RIGHT | \
                          BUFFER_BIT_BACK_LEFT  | BUFFER_BIT_BACK_RIGHT  )
      if (mask & BUFFER_BIT_MASK  &&
-         ctx->Color.ColorMask[0] &&
-         ctx->Color.ColorMask[1] &&
-         ctx->Color.ColorMask[2] &&
-         ctx->Color.ColorMask[3])
+         ctx->Color.ColorMask[0][0] &&
+         ctx->Color.ColorMask[0][1] &&
+         ctx->Color.ColorMask[0][2] &&
+         ctx->Color.ColorMask[0][3])
      {
           DFBRegion clip;
           GLubyte   a, r, g, b;
index 32db0978613d798db28737f6d354ce71566b9d98..264648c3fbcab6af85bc9deb26d37883dd54d6bf 100644 (file)
@@ -25,7 +25,7 @@ pcedit = sed \
        -e 's,@INSTALL_LIB_DIR@,$(INSTALL_LIB_DIR),' \
        -e 's,@INSTALL_INC_DIR@,$(INSTALL_INC_DIR),' \
        -e 's,@VERSION@,$(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY),' \
-       -e 's,@DRI_DRIVER_DIR@,$(DRI_DRIVER_SEARCH_DIR),' \
+       -e 's,@DRI_DRIVER_DIR@,$(DRI_DRIVER_INSTALL_DIR),' \
        -e 's,@DRI_PC_REQ_PRIV@,$(DRI_PC_REQ_PRIV),'
 
 dri.pc: dri.pc.in
index 18dbeba24a8916c0f656a966ae75d0c0a148c5b6..39d25ce3f475775d72af874eecda8c931dbdd8a3 100644 (file)
@@ -60,18 +60,40 @@ SHARED_INCLUDES = \
 
 ##### TARGETS #####
 
-default: symlinks depend $(LIBNAME) $(TOP)/$(LIB_DIR)/$(LIBNAME)
+default: subdirs lib
 
 
-$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) $(WINOBJ) Makefile $(TOP)/src/mesa/drivers/dri/Makefile.template
+.PHONY: lib
+lib: symlinks subdirs depend
+       @$(MAKE) $(LIBNAME) $(TOP)/$(LIB_DIR)/$(LIBNAME)
+
+$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) $(WINOBJ) Makefile \
+               $(TOP)/src/mesa/drivers/dri/Makefile.template
        $(MKLIB) -o $@ -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \
-               $(OBJECTS) $(PIPE_DRIVERS) $(MESA_MODULES) $(WINOBJ) $(DRI_LIB_DEPS)
+               $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) $(WINOBJ) \
+               $(DRI_LIB_DEPS)
 
 
 $(TOP)/$(LIB_DIR)/$(LIBNAME): $(LIBNAME)
        $(INSTALL) $(LIBNAME) $(TOP)/$(LIB_DIR) 
 
 
+# If the Makefile defined SUBDIRS, run make in each
+.PHONY: subdirs
+subdirs:
+       @if test -n "$(SUBDIRS)" ; then \
+               for dir in $(SUBDIRS) ; do \
+                       if [ -d $$dir ] ; then \
+                               (cd $$dir && $(MAKE)) || exit 1; \
+                       fi \
+               done \
+       fi
+
+
+.PHONY: symlinks
+symlinks:
+
+
 depend: $(C_SOURCES) $(ASM_SOURCES) $(SYMLINKS)
        @ echo "running $(MKDEP)"
        @ rm -f depend
index e48e10d7c061f6e73ea70cbf4bcbe689e92e2ef9..0e01d742656b4767269109656d4cbee7b4c58feb 100644 (file)
@@ -97,7 +97,7 @@ driIntersectArea( drm_clip_rect_t rect1, drm_clip_rect_t rect2 )
  * 
  * \internal
  * This function calls __DriverAPIRec::UnbindContext, and then decrements
- * __DRIdrawablePrivateRec::refcount which must be non-zero for a successful
+ * __DRIdrawableRec::refcount which must be non-zero for a successful
  * return.
  * 
  * While casting the opaque private pointers associated with the parameters
@@ -167,11 +167,12 @@ static int driBindContext(__DRIcontext *pcp,
                          __DRIdrawable *pdp,
                          __DRIdrawable *prp)
 {
-    __DRIscreenPrivate *psp = pcp->driScreenPriv;
+    __DRIscreen *psp = NULL;
 
     /* Bind the drawable to the context */
 
     if (pcp) {
+       psp = pcp->driScreenPriv;
        pcp->driDrawablePriv = pdp;
        pcp->driReadablePriv = prp;
        if (pdp) {
@@ -219,7 +220,7 @@ static int driBindContext(__DRIcontext *pcp,
  *
  * \param pdp pointer to the private drawable information to update.
  * 
- * This function basically updates the __DRIdrawablePrivate struct's
+ * This function basically updates the __DRIdrawable struct's
  * cliprect information by calling \c __DRIinterfaceMethods::getDrawableInfo.
  * This is usually called by the DRI_VALIDATE_DRAWABLE_INFO macro which
  * compares the __DRIdrwablePrivate pStamp and lastStamp values.  If
@@ -227,10 +228,10 @@ static int driBindContext(__DRIcontext *pcp,
  * info.
  */
 void
-__driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp)
+__driUtilUpdateDrawableInfo(__DRIdrawable *pdp)
 {
-    __DRIscreenPrivate *psp = pdp->driScreenPriv;
-    __DRIcontextPrivate *pcp = pdp->driContextPriv;
+    __DRIscreen *psp = pdp->driScreenPriv;
+    __DRIcontext *pcp = pdp->driContextPriv;
     
     if (!pcp 
        || ((pdp != pcp->driDrawablePriv) && (pdp != pcp->driReadablePriv))) {
@@ -308,7 +309,7 @@ static void driReportDamage(__DRIdrawable *pdp,
  * \param drawablePrivate opaque pointer to the per-drawable private info.
  * 
  * \internal
- * This function calls __DRIdrawablePrivate::swapBuffers.
+ * This function calls __DRIdrawable::swapBuffers.
  * 
  * Is called directly from glXSwapBuffers().
  */
@@ -496,13 +497,13 @@ static void dri_get_drawable(__DRIdrawable *pdp)
        
 static void dri_put_drawable(__DRIdrawable *pdp)
 {
-    __DRIscreenPrivate *psp;
-
-    pdp->refcount--;
-    if (pdp->refcount)
-       return;
+    __DRIscreen *psp;
 
     if (pdp) {
+       pdp->refcount--;
+       if (pdp->refcount)
+           return;
+
        psp = pdp->driScreenPriv;
         (*psp->DriverAPI.DestroyBuffer)(pdp);
        if (pdp->pClipRects) {
@@ -559,7 +560,7 @@ driDestroyContext(__DRIcontext *pcp)
  *          success, or \c NULL on failure.
  * 
  * \internal
- * This function allocates and fills a __DRIcontextPrivateRec structure.  It
+ * This function allocates and fills a __DRIcontextRec structure.  It
  * performs some device independent initialization and passes all the
  * relevent information to __DriverAPIRec::CreateContext to create the
  * context.
@@ -840,7 +841,7 @@ const __DRIlegacyExtension driLegacyExtension = {
     driCreateNewContext,
 };
 
-/** Legacy DRI interface */
+/** DRI2 interface */
 const __DRIdri2Extension driDRI2Extension = {
     { __DRI_DRI2, __DRI_DRI2_VERSION },
     dri2CreateNewScreen,
@@ -848,14 +849,6 @@ const __DRIdri2Extension driDRI2Extension = {
     dri2CreateNewContext,
 };
 
-/* This is the table of extensions that the loader will dlsym() for. */
-PUBLIC const __DRIextension *__driDriverExtensions[] = {
-    &driCoreExtension.base,
-    &driLegacyExtension.base,
-    &driDRI2Extension.base,
-    NULL
-};
-
 static int
 driFrameTracking(__DRIdrawable *drawable, GLboolean enable)
 {
@@ -870,7 +863,7 @@ driQueryFrameTracking(__DRIdrawable *dpriv,
    __DRIswapInfo   sInfo;
    int             status;
    int64_t         ust;
-   __DRIscreenPrivate *psp = dpriv->driScreenPriv;
+   __DRIscreen *psp = dpriv->driScreenPriv;
 
    status = dpriv->driScreenPriv->DriverAPI.GetSwapInfo( dpriv, & sInfo );
    if ( status == 0 ) {
@@ -920,14 +913,14 @@ const __DRIframeTrackingExtension driFrameTrackingExtension = {
  *       be possible to cache the sync rate?
  */
 float
-driCalculateSwapUsage( __DRIdrawablePrivate *dPriv, int64_t last_swap_ust,
+driCalculateSwapUsage( __DRIdrawable *dPriv, int64_t last_swap_ust,
                       int64_t current_ust )
 {
    int32_t   n;
    int32_t   d;
    int       interval;
    float     usage = 1.0;
-   __DRIscreenPrivate *psp = dPriv->driScreenPriv;
+   __DRIscreen *psp = dPriv->driScreenPriv;
 
    if ( (*psp->systemTime->getMSCRate)(dPriv, &n, &d, dPriv->loaderPrivate) ) {
       interval = (dPriv->swap_interval != 0) ? dPriv->swap_interval : 1;
index c95a5c8299a11c672527137bea9f78b4bbea3cf6..35d8b8ff9326b7f9470858cb5633ff633e563a94 100644 (file)
 
 typedef struct __DRIswapInfoRec        __DRIswapInfo;
 
-/* Typedefs to avoid rewriting the world. */
-typedef struct __DRIscreenRec  __DRIscreenPrivate;
-typedef struct __DRIdrawableRec        __DRIdrawablePrivate;
-typedef struct __DRIcontextRec __DRIcontextPrivate;
-
 /**
  * Extensions.
  */
 extern const __DRIlegacyExtension driLegacyExtension;
 extern const __DRIcoreExtension driCoreExtension;
+extern const __DRIdri2Extension driDRI2Extension;
 extern const __DRIextension driReadDrawableExtension;
 extern const __DRIcopySubBufferExtension driCopySubBufferExtension;
 extern const __DRIswapControlExtension driSwapControlExtension;
index 15af99136cd7cd590737484e88d8f1b3cb65c5a4..3126ea847603ee82d5a4f5c3591656597a012de1 100644 (file)
@@ -1,5 +1,6 @@
 
 #include "main/mtypes.h"
+#include "main/formats.h"
 #include "main/framebuffer.h"
 #include "main/renderbuffer.h"
 #include "main/imports.h"
@@ -53,9 +54,9 @@ driDeleteRenderbuffer(struct gl_renderbuffer *rb)
  * \param pitch   pixels per row
  */
 driRenderbuffer *
-driNewRenderbuffer(GLenum format, GLvoid *addr,
+driNewRenderbuffer(gl_format format, GLvoid *addr,
                    GLint cpp, GLint offset, GLint pitch,
-                   __DRIdrawablePrivate *dPriv)
+                   __DRIdrawable *dPriv)
 {
    driRenderbuffer *drb;
 
@@ -79,56 +80,47 @@ driNewRenderbuffer(GLenum format, GLvoid *addr,
       /* Make sure we're using a null-valued GetPointer routine */
       assert(drb->Base.GetPointer(NULL, &drb->Base, 0, 0) == NULL);
 
-      drb->Base.InternalFormat = format;
-
-      if (format == GL_RGBA || format == GL_RGB5 || format == GL_RGBA8) {
-         /* Color */
-         drb->Base._BaseFormat = GL_RGBA;
-         drb->Base.DataType = GL_UNSIGNED_BYTE;
-         if (format == GL_RGB5) {
-            drb->Base.RedBits = 5;
-            drb->Base.GreenBits = 6;
-            drb->Base.BlueBits = 5;
+      switch (format) {
+      case MESA_FORMAT_ARGB8888:
+         if (cpp == 2) {
+            /* override format */
+            format = MESA_FORMAT_RGB565;
          }
-         else {
-            drb->Base.RedBits =
-            drb->Base.GreenBits =
-            drb->Base.BlueBits =
-            drb->Base.AlphaBits = 8;
-         }
-      }
-      else if (format == GL_DEPTH_COMPONENT16) {
-         /* Depth */
-         drb->Base._BaseFormat = GL_DEPTH_COMPONENT;
-         /* we always Get/Put 32-bit Z values */
-         drb->Base.DataType = GL_UNSIGNED_INT;
-         drb->Base.DepthBits = 16;
-      }
-      else if (format == GL_DEPTH_COMPONENT24) {
+         drb->Base.DataType = GL_UNSIGNED_BYTE;
+         break;
+      case MESA_FORMAT_Z16:
          /* Depth */
-         drb->Base._BaseFormat = GL_DEPTH_COMPONENT;
          /* we always Get/Put 32-bit Z values */
          drb->Base.DataType = GL_UNSIGNED_INT;
-         drb->Base.DepthBits = 24;
-      }
-      else if (format == GL_DEPTH_COMPONENT32) {
+         assert(cpp == 2);
+         break;
+      case MESA_FORMAT_Z32:
          /* Depth */
-         drb->Base._BaseFormat = GL_DEPTH_COMPONENT;
          /* we always Get/Put 32-bit Z values */
          drb->Base.DataType = GL_UNSIGNED_INT;
-         drb->Base.DepthBits = 32;
-      }
-      else {
+         assert(cpp == 4);
+         break;
+      case MESA_FORMAT_Z24_S8:
+         drb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT;
+         assert(cpp == 4);
+         break;
+      case MESA_FORMAT_S8_Z24:
+         drb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT;
+         assert(cpp == 4);
+         break;
+      case MESA_FORMAT_S8:
          /* Stencil */
-         ASSERT(format == GL_STENCIL_INDEX8_EXT);
-         drb->Base._BaseFormat = GL_STENCIL_INDEX;
          drb->Base.DataType = GL_UNSIGNED_BYTE;
-         drb->Base.StencilBits = 8;
+         break;
+      default:
+         _mesa_problem(NULL, "Bad format 0x%x in driNewRenderbuffer", format);
+         return NULL;
       }
 
-      /* XXX if we were allocating a user-created renderbuffer, we'd have
-       * to fill in the Red/Green/Blue/.../Bits values too.
-       */
+      drb->Base.Format = format;
+
+      drb->Base.InternalFormat =
+      drb->Base._BaseFormat = _mesa_get_format_base_format(format);
 
       drb->Base.AllocStorage = driRenderbufferStorage;
       drb->Base.Delete = driDeleteRenderbuffer;
@@ -204,7 +196,7 @@ driFlipRenderbuffers(struct gl_framebuffer *fb, GLboolean flipped)
  * gl_framebuffer object.
  */
 void
-driUpdateFramebufferSize(GLcontext *ctx, const __DRIdrawablePrivate *dPriv)
+driUpdateFramebufferSize(GLcontext *ctx, const __DRIdrawable *dPriv)
 {
    struct gl_framebuffer *fb = (struct gl_framebuffer *) dPriv->driverPrivate;
    if (fb && (dPriv->w != fb->Width || dPriv->h != fb->Height)) {
index cf55286b30fd066e1302be52517db8b5d1e92cd3..677511334d360c9327b297719415f86db82499f7 100644 (file)
@@ -11,6 +11,7 @@
 #define DRIRENDERBUFFER_H
 
 #include "main/mtypes.h"
+#include "main/formats.h"
 #include "dri_util.h"
 
 
@@ -42,10 +43,10 @@ typedef struct {
    GLint flippedPitch;
    GLvoid *flippedData;  /* mmap'd address of buffer memory, if used */
 
-   /* Pointer to corresponding __DRIdrawablePrivate.  This is used to compute
+   /* Pointer to corresponding __DRIdrawable.  This is used to compute
     * the window's position within the framebuffer.
     */
-   __DRIdrawablePrivate *dPriv;
+   __DRIdrawable *dPriv;
 
    /* XXX this is for radeon/r200 only.  We should really create a new
     * r200Renderbuffer class, derived from this class...  not a huge deal.
@@ -56,23 +57,23 @@ typedef struct {
     * A handy flag to know if this is the back color buffer.
     * 
     * \note
-    * This is currently only used by s3v and tdfx.
+    * This is currently only used by tdfx.
     */
    GLboolean backBuffer;
 } driRenderbuffer;
 
 
 extern driRenderbuffer *
-driNewRenderbuffer(GLenum format, GLvoid *addr,
+driNewRenderbuffer(gl_format format, GLvoid *addr,
                    GLint cpp, GLint offset, GLint pitch,
-                   __DRIdrawablePrivate *dPriv);
+                   __DRIdrawable *dPriv);
 
 extern void
 driFlipRenderbuffers(struct gl_framebuffer *fb, GLboolean flipped);
 
 
 extern void
-driUpdateFramebufferSize(GLcontext *ctx, const __DRIdrawablePrivate *dPriv);
+driUpdateFramebufferSize(GLcontext *ctx, const __DRIdrawable *dPriv);
 
 
 #endif /* DRIRENDERBUFFER_H */
diff --git a/src/mesa/drivers/dri/common/extension_helper.h b/src/mesa/drivers/dri/common/extension_helper.h
deleted file mode 100644 (file)
index 5e86324..0000000
+++ /dev/null
@@ -1,6647 +0,0 @@
-/* DO NOT EDIT - This file generated automatically by extension_helper.py (from Mesa) script */
-
-/*
- * (C) Copyright IBM Corporation 2005
- * All Rights Reserved.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sub license,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- * 
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
- * IBM,
- * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
- * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include "utils.h"
-#include "glapi/dispatch.h"
-
-#ifndef NULL
-# define NULL 0
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_shader_objects)
-static const char UniformMatrix3fvARB_names[] =
-    "iiip\0" /* Parameter signature */
-    "glUniformMatrix3fv\0"
-    "glUniformMatrix3fvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3) || defined(need_GL_ARB_multisample)
-static const char SampleCoverageARB_names[] =
-    "fi\0" /* Parameter signature */
-    "glSampleCoverage\0"
-    "glSampleCoverageARB\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_convolution)
-static const char ConvolutionFilter1D_names[] =
-    "iiiiip\0" /* Parameter signature */
-    "glConvolutionFilter1D\0"
-    "glConvolutionFilter1DEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_occlusion_query)
-static const char BeginQueryARB_names[] =
-    "ii\0" /* Parameter signature */
-    "glBeginQuery\0"
-    "glBeginQueryARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_NV_point_sprite)
-static const char PointParameteriNV_names[] =
-    "ii\0" /* Parameter signature */
-    "glPointParameteri\0"
-    "glPointParameteriNV\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0)
-static const char GetProgramiv_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetProgramiv\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char MultiTexCoord3sARB_names[] =
-    "iiii\0" /* Parameter signature */
-    "glMultiTexCoord3s\0"
-    "glMultiTexCoord3sARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
-static const char SecondaryColor3iEXT_names[] =
-    "iii\0" /* Parameter signature */
-    "glSecondaryColor3i\0"
-    "glSecondaryColor3iEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_window_pos) || defined(need_GL_MESA_window_pos)
-static const char WindowPos3fMESA_names[] =
-    "fff\0" /* Parameter signature */
-    "glWindowPos3f\0"
-    "glWindowPos3fARB\0"
-    "glWindowPos3fMESA\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIS_pixel_texture)
-static const char PixelTexGenParameterfvSGIS_names[] =
-    "ip\0" /* Parameter signature */
-    "glPixelTexGenParameterfvSGIS\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char ActiveTextureARB_names[] =
-    "i\0" /* Parameter signature */
-    "glActiveTexture\0"
-    "glActiveTextureARB\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_framebuffer_object) || defined(need_GL_EXT_framebuffer_blit)
-static const char BlitFramebufferEXT_names[] =
-    "iiiiiiiiii\0" /* Parameter signature */
-    "glBlitFramebuffer\0"
-    "glBlitFramebufferEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttrib4ubvNV_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib4ubvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_fragment_program)
-static const char GetProgramNamedParameterdvNV_names[] =
-    "iipp\0" /* Parameter signature */
-    "glGetProgramNamedParameterdvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_histogram)
-static const char Histogram_names[] =
-    "iiii\0" /* Parameter signature */
-    "glHistogram\0"
-    "glHistogramEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIS_texture4D)
-static const char TexImage4DSGIS_names[] =
-    "iiiiiiiiiip\0" /* Parameter signature */
-    "glTexImage4DSGIS\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_window_pos) || defined(need_GL_MESA_window_pos)
-static const char WindowPos2dvMESA_names[] =
-    "p\0" /* Parameter signature */
-    "glWindowPos2dv\0"
-    "glWindowPos2dvARB\0"
-    "glWindowPos2dvMESA\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char ReplacementCodeuiColor3fVertex3fvSUN_names[] =
-    "ppp\0" /* Parameter signature */
-    "glReplacementCodeuiColor3fVertex3fvSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_EXT_blend_equation_separate) || defined(need_GL_ATI_blend_equation_separate)
-static const char BlendEquationSeparateEXT_names[] =
-    "ii\0" /* Parameter signature */
-    "glBlendEquationSeparate\0"
-    "glBlendEquationSeparateEXT\0"
-    "glBlendEquationSeparateATI\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_list_priority)
-static const char ListParameterfSGIX_names[] =
-    "iif\0" /* Parameter signature */
-    "glListParameterfSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
-static const char SecondaryColor3bEXT_names[] =
-    "iii\0" /* Parameter signature */
-    "glSecondaryColor3b\0"
-    "glSecondaryColor3bEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char TexCoord4fColor4fNormal3fVertex4fvSUN_names[] =
-    "pppp\0" /* Parameter signature */
-    "glTexCoord4fColor4fNormal3fVertex4fvSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttrib4svNV_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib4svNV\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_vertex_buffer_object)
-static const char GetBufferSubDataARB_names[] =
-    "iiip\0" /* Parameter signature */
-    "glGetBufferSubData\0"
-    "glGetBufferSubDataARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_vertex_buffer_object)
-static const char BufferSubDataARB_names[] =
-    "iiip\0" /* Parameter signature */
-    "glBufferSubData\0"
-    "glBufferSubDataARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char TexCoord2fColor4ubVertex3fvSUN_names[] =
-    "ppp\0" /* Parameter signature */
-    "glTexCoord2fColor4ubVertex3fvSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0)
-static const char AttachShader_names[] =
-    "ii\0" /* Parameter signature */
-    "glAttachShader\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib2fARB_names[] =
-    "iff\0" /* Parameter signature */
-    "glVertexAttrib2f\0"
-    "glVertexAttrib2fARB\0"
-    "";
-#endif
-
-#if defined(need_GL_MESA_shader_debug)
-static const char GetDebugLogLengthMESA_names[] =
-    "iii\0" /* Parameter signature */
-    "glGetDebugLogLengthMESA\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib3fARB_names[] =
-    "ifff\0" /* Parameter signature */
-    "glVertexAttrib3f\0"
-    "glVertexAttrib3fARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_occlusion_query)
-static const char GetQueryivARB_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetQueryiv\0"
-    "glGetQueryivARB\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_texture3D)
-static const char TexImage3D_names[] =
-    "iiiiiiiiip\0" /* Parameter signature */
-    "glTexImage3D\0"
-    "glTexImage3DEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char ReplacementCodeuiVertex3fvSUN_names[] =
-    "pp\0" /* Parameter signature */
-    "glReplacementCodeuiVertex3fvSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_occlusion_query)
-static const char GetQueryObjectivARB_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetQueryObjectiv\0"
-    "glGetQueryObjectivARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char ReplacementCodeuiTexCoord2fVertex3fvSUN_names[] =
-    "ppp\0" /* Parameter signature */
-    "glReplacementCodeuiTexCoord2fVertex3fvSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3) || defined(need_GL_ARB_texture_compression)
-static const char CompressedTexSubImage2DARB_names[] =
-    "iiiiiiiip\0" /* Parameter signature */
-    "glCompressedTexSubImage2D\0"
-    "glCompressedTexSubImage2DARB\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_register_combiners)
-static const char CombinerOutputNV_names[] =
-    "iiiiiiiiii\0" /* Parameter signature */
-    "glCombinerOutputNV\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttribs3fvNV_names[] =
-    "iip\0" /* Parameter signature */
-    "glVertexAttribs3fvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_shader_objects)
-static const char Uniform2fARB_names[] =
-    "iff\0" /* Parameter signature */
-    "glUniform2f\0"
-    "glUniform2fARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib1svARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib1sv\0"
-    "glVertexAttrib1svARB\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttribs1dvNV_names[] =
-    "iip\0" /* Parameter signature */
-    "glVertexAttribs1dvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_shader_objects)
-static const char Uniform2ivARB_names[] =
-    "iip\0" /* Parameter signature */
-    "glUniform2iv\0"
-    "glUniform2ivARB\0"
-    "";
-#endif
-
-#if defined(need_GL_HP_image_transform)
-static const char GetImageTransformParameterfvHP_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetImageTransformParameterfvHP\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_blend)
-static const char WeightubvARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glWeightubvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttrib1fvNV_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib1fvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_convolution)
-static const char CopyConvolutionFilter1D_names[] =
-    "iiiii\0" /* Parameter signature */
-    "glCopyConvolutionFilter1D\0"
-    "glCopyConvolutionFilter1DEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char ReplacementCodeuiNormal3fVertex3fSUN_names[] =
-    "iffffff\0" /* Parameter signature */
-    "glReplacementCodeuiNormal3fVertex3fSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_sync)
-static const char DeleteSync_names[] =
-    "i\0" /* Parameter signature */
-    "glDeleteSync\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_fragment_lighting)
-static const char FragmentMaterialfvSGIX_names[] =
-    "iip\0" /* Parameter signature */
-    "glFragmentMaterialfvSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_blend_color)
-static const char BlendColor_names[] =
-    "ffff\0" /* Parameter signature */
-    "glBlendColor\0"
-    "glBlendColorEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_shader_objects)
-static const char UniformMatrix4fvARB_names[] =
-    "iiip\0" /* Parameter signature */
-    "glUniformMatrix4fv\0"
-    "glUniformMatrix4fvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_array_object) || defined(need_GL_APPLE_vertex_array_object)
-static const char DeleteVertexArraysAPPLE_names[] =
-    "ip\0" /* Parameter signature */
-    "glDeleteVertexArrays\0"
-    "glDeleteVertexArraysAPPLE\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_instruments)
-static const char ReadInstrumentsSGIX_names[] =
-    "i\0" /* Parameter signature */
-    "glReadInstrumentsSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_1)
-static const char UniformMatrix2x4fv_names[] =
-    "iiip\0" /* Parameter signature */
-    "glUniformMatrix2x4fv\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char Color4ubVertex3fvSUN_names[] =
-    "pp\0" /* Parameter signature */
-    "glColor4ubVertex3fvSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_framebuffer_object) || defined(need_GL_EXT_texture_array)
-static const char FramebufferTextureLayerEXT_names[] =
-    "iiiii\0" /* Parameter signature */
-    "glFramebufferTextureLayer\0"
-    "glFramebufferTextureLayerEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_list_priority)
-static const char GetListParameterfvSGIX_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetListParameterfvSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib4NusvARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib4Nusv\0"
-    "glVertexAttrib4NusvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_MESA_window_pos)
-static const char WindowPos4svMESA_names[] =
-    "p\0" /* Parameter signature */
-    "glWindowPos4svMESA\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_shader_objects)
-static const char CreateProgramObjectARB_names[] =
-    "\0" /* Parameter signature */
-    "glCreateProgramObjectARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_fragment_lighting)
-static const char FragmentLightModelivSGIX_names[] =
-    "ip\0" /* Parameter signature */
-    "glFragmentLightModelivSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_1)
-static const char UniformMatrix4x3fv_names[] =
-    "iiip\0" /* Parameter signature */
-    "glUniformMatrix4x3fv\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_texture_object)
-static const char PrioritizeTextures_names[] =
-    "ipp\0" /* Parameter signature */
-    "glPrioritizeTextures\0"
-    "glPrioritizeTexturesEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_async)
-static const char AsyncMarkerSGIX_names[] =
-    "i\0" /* Parameter signature */
-    "glAsyncMarkerSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_global_alpha)
-static const char GlobalAlphaFactorubSUN_names[] =
-    "i\0" /* Parameter signature */
-    "glGlobalAlphaFactorubSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_MESA_shader_debug)
-static const char ClearDebugLogMESA_names[] =
-    "iii\0" /* Parameter signature */
-    "glClearDebugLogMESA\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_histogram)
-static const char ResetHistogram_names[] =
-    "i\0" /* Parameter signature */
-    "glResetHistogram\0"
-    "glResetHistogramEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_fragment_program)
-static const char GetProgramNamedParameterfvNV_names[] =
-    "iipp\0" /* Parameter signature */
-    "glGetProgramNamedParameterfvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_point_parameters) || defined(need_GL_EXT_point_parameters) || defined(need_GL_SGIS_point_parameters)
-static const char PointParameterfEXT_names[] =
-    "if\0" /* Parameter signature */
-    "glPointParameterf\0"
-    "glPointParameterfARB\0"
-    "glPointParameterfEXT\0"
-    "glPointParameterfSGIS\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_polynomial_ffd)
-static const char LoadIdentityDeformationMapSGIX_names[] =
-    "i\0" /* Parameter signature */
-    "glLoadIdentityDeformationMapSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_fence)
-static const char GenFencesNV_names[] =
-    "ip\0" /* Parameter signature */
-    "glGenFencesNV\0"
-    "";
-#endif
-
-#if defined(need_GL_HP_image_transform)
-static const char ImageTransformParameterfHP_names[] =
-    "iif\0" /* Parameter signature */
-    "glImageTransformParameterfHP\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_matrix_palette)
-static const char MatrixIndexusvARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glMatrixIndexusvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_draw_elements_base_vertex)
-static const char DrawElementsBaseVertex_names[] =
-    "iiipi\0" /* Parameter signature */
-    "glDrawElementsBaseVertex\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char DisableVertexAttribArrayARB_names[] =
-    "i\0" /* Parameter signature */
-    "glDisableVertexAttribArray\0"
-    "glDisableVertexAttribArrayARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0)
-static const char StencilMaskSeparate_names[] =
-    "ii\0" /* Parameter signature */
-    "glStencilMaskSeparate\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_program)
-static const char ProgramLocalParameter4dARB_names[] =
-    "iidddd\0" /* Parameter signature */
-    "glProgramLocalParameter4dARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3) || defined(need_GL_ARB_texture_compression)
-static const char CompressedTexImage3DARB_names[] =
-    "iiiiiiiip\0" /* Parameter signature */
-    "glCompressedTexImage3D\0"
-    "glCompressedTexImage3DARB\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_convolution)
-static const char GetConvolutionParameteriv_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetConvolutionParameteriv\0"
-    "glGetConvolutionParameterivEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib1fARB_names[] =
-    "if\0" /* Parameter signature */
-    "glVertexAttrib1f\0"
-    "glVertexAttrib1fARB\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_fence)
-static const char TestFenceNV_names[] =
-    "i\0" /* Parameter signature */
-    "glTestFenceNV\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char MultiTexCoord1fvARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glMultiTexCoord1fv\0"
-    "glMultiTexCoord1fvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_ATI_fragment_shader)
-static const char ColorFragmentOp2ATI_names[] =
-    "iiiiiiiiii\0" /* Parameter signature */
-    "glColorFragmentOp2ATI\0"
-    "";
-#endif
-
-#if defined(need_GL_IBM_vertex_array_lists)
-static const char SecondaryColorPointerListIBM_names[] =
-    "iiipi\0" /* Parameter signature */
-    "glSecondaryColorPointerListIBM\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIS_pixel_texture)
-static const char GetPixelTexGenParameterivSGIS_names[] =
-    "ip\0" /* Parameter signature */
-    "glGetPixelTexGenParameterivSGIS\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttrib4fNV_names[] =
-    "iffff\0" /* Parameter signature */
-    "glVertexAttrib4fNV\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_triangle_list)
-static const char ReplacementCodeubSUN_names[] =
-    "i\0" /* Parameter signature */
-    "glReplacementCodeubSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_async)
-static const char FinishAsyncSGIX_names[] =
-    "p\0" /* Parameter signature */
-    "glFinishAsyncSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_MESA_shader_debug)
-static const char GetDebugLogMESA_names[] =
-    "iiiipp\0" /* Parameter signature */
-    "glGetDebugLogMESA\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_fog_coord)
-static const char FogCoorddEXT_names[] =
-    "d\0" /* Parameter signature */
-    "glFogCoordd\0"
-    "glFogCoorddEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char Color4ubVertex3fSUN_names[] =
-    "iiiifff\0" /* Parameter signature */
-    "glColor4ubVertex3fSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_fog_coord)
-static const char FogCoordfEXT_names[] =
-    "f\0" /* Parameter signature */
-    "glFogCoordf\0"
-    "glFogCoordfEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char TexCoord2fVertex3fSUN_names[] =
-    "fffff\0" /* Parameter signature */
-    "glTexCoord2fVertex3fSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_global_alpha)
-static const char GlobalAlphaFactoriSUN_names[] =
-    "i\0" /* Parameter signature */
-    "glGlobalAlphaFactoriSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttrib2dNV_names[] =
-    "idd\0" /* Parameter signature */
-    "glVertexAttrib2dNV\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0)
-static const char GetProgramInfoLog_names[] =
-    "iipp\0" /* Parameter signature */
-    "glGetProgramInfoLog\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib4NbvARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib4Nbv\0"
-    "glVertexAttrib4NbvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_shader)
-static const char GetActiveAttribARB_names[] =
-    "iiipppp\0" /* Parameter signature */
-    "glGetActiveAttrib\0"
-    "glGetActiveAttribARB\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttrib4ubNV_names[] =
-    "iiiii\0" /* Parameter signature */
-    "glVertexAttrib4ubNV\0"
-    "";
-#endif
-
-#if defined(need_GL_APPLE_texture_range)
-static const char TextureRangeAPPLE_names[] =
-    "iip\0" /* Parameter signature */
-    "glTextureRangeAPPLE\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char TexCoord2fColor4fNormal3fVertex3fSUN_names[] =
-    "ffffffffffff\0" /* Parameter signature */
-    "glTexCoord2fColor4fNormal3fVertex3fSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_register_combiners)
-static const char CombinerParameterfvNV_names[] =
-    "ip\0" /* Parameter signature */
-    "glCombinerParameterfvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttribs3dvNV_names[] =
-    "iip\0" /* Parameter signature */
-    "glVertexAttribs3dvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttribs4fvNV_names[] =
-    "iip\0" /* Parameter signature */
-    "glVertexAttribs4fvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_array_range)
-static const char VertexArrayRangeNV_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexArrayRangeNV\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_fragment_lighting)
-static const char FragmentLightiSGIX_names[] =
-    "iii\0" /* Parameter signature */
-    "glFragmentLightiSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_polygon_offset)
-static const char PolygonOffsetEXT_names[] =
-    "ff\0" /* Parameter signature */
-    "glPolygonOffsetEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_async)
-static const char PollAsyncSGIX_names[] =
-    "p\0" /* Parameter signature */
-    "glPollAsyncSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_ATI_fragment_shader)
-static const char DeleteFragmentShaderATI_names[] =
-    "i\0" /* Parameter signature */
-    "glDeleteFragmentShaderATI\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char TexCoord2fNormal3fVertex3fvSUN_names[] =
-    "ppp\0" /* Parameter signature */
-    "glTexCoord2fNormal3fVertex3fvSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3) || defined(need_GL_ARB_transpose_matrix)
-static const char MultTransposeMatrixdARB_names[] =
-    "p\0" /* Parameter signature */
-    "glMultTransposeMatrixd\0"
-    "glMultTransposeMatrixdARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_window_pos) || defined(need_GL_MESA_window_pos)
-static const char WindowPos2svMESA_names[] =
-    "p\0" /* Parameter signature */
-    "glWindowPos2sv\0"
-    "glWindowPos2svARB\0"
-    "glWindowPos2svMESA\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3) || defined(need_GL_ARB_texture_compression)
-static const char CompressedTexImage1DARB_names[] =
-    "iiiiiip\0" /* Parameter signature */
-    "glCompressedTexImage1D\0"
-    "glCompressedTexImage1DARB\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttrib2sNV_names[] =
-    "iii\0" /* Parameter signature */
-    "glVertexAttrib2sNV\0"
-    "";
-#endif
-
-#if defined(need_GL_IBM_vertex_array_lists)
-static const char NormalPointerListIBM_names[] =
-    "iipi\0" /* Parameter signature */
-    "glNormalPointerListIBM\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_vertex_array)
-static const char IndexPointerEXT_names[] =
-    "iiip\0" /* Parameter signature */
-    "glIndexPointerEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_vertex_array)
-static const char NormalPointerEXT_names[] =
-    "iiip\0" /* Parameter signature */
-    "glNormalPointerEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char MultiTexCoord3dARB_names[] =
-    "iddd\0" /* Parameter signature */
-    "glMultiTexCoord3d\0"
-    "glMultiTexCoord3dARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char MultiTexCoord2iARB_names[] =
-    "iii\0" /* Parameter signature */
-    "glMultiTexCoord2i\0"
-    "glMultiTexCoord2iARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char ReplacementCodeuiTexCoord2fNormal3fVertex3fSUN_names[] =
-    "iffffffff\0" /* Parameter signature */
-    "glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char MultiTexCoord2svARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glMultiTexCoord2sv\0"
-    "glMultiTexCoord2svARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_triangle_list)
-static const char ReplacementCodeubvSUN_names[] =
-    "p\0" /* Parameter signature */
-    "glReplacementCodeubvSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_shader_objects)
-static const char Uniform3iARB_names[] =
-    "iiii\0" /* Parameter signature */
-    "glUniform3i\0"
-    "glUniform3iARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_fragment_lighting)
-static const char GetFragmentMaterialfvSGIX_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetFragmentMaterialfvSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0)
-static const char GetShaderInfoLog_names[] =
-    "iipp\0" /* Parameter signature */
-    "glGetShaderInfoLog\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_blend)
-static const char WeightivARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glWeightivARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_instruments)
-static const char PollInstrumentsSGIX_names[] =
-    "p\0" /* Parameter signature */
-    "glPollInstrumentsSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_global_alpha)
-static const char GlobalAlphaFactordSUN_names[] =
-    "d\0" /* Parameter signature */
-    "glGlobalAlphaFactordSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_register_combiners)
-static const char GetFinalCombinerInputParameterfvNV_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetFinalCombinerInputParameterfvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_framebuffer_object) || defined(need_GL_EXT_framebuffer_object)
-static const char GenerateMipmapEXT_names[] =
-    "i\0" /* Parameter signature */
-    "glGenerateMipmap\0"
-    "glGenerateMipmapEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_ATI_fragment_shader)
-static const char SetFragmentShaderConstantATI_names[] =
-    "ip\0" /* Parameter signature */
-    "glSetFragmentShaderConstantATI\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_evaluators)
-static const char GetMapAttribParameterivNV_names[] =
-    "iiip\0" /* Parameter signature */
-    "glGetMapAttribParameterivNV\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_shader_objects)
-static const char CreateShaderObjectARB_names[] =
-    "i\0" /* Parameter signature */
-    "glCreateShaderObjectARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIS_sharpen_texture)
-static const char GetSharpenTexFuncSGIS_names[] =
-    "ip\0" /* Parameter signature */
-    "glGetSharpenTexFuncSGIS\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_vertex_buffer_object)
-static const char BufferDataARB_names[] =
-    "iipi\0" /* Parameter signature */
-    "glBufferData\0"
-    "glBufferDataARB\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_array_range)
-static const char FlushVertexArrayRangeNV_names[] =
-    "\0" /* Parameter signature */
-    "glFlushVertexArrayRangeNV\0"
-    "";
-#endif
-
-#if defined(need_GL_ATI_fragment_shader)
-static const char SampleMapATI_names[] =
-    "iii\0" /* Parameter signature */
-    "glSampleMapATI\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_vertex_array)
-static const char VertexPointerEXT_names[] =
-    "iiiip\0" /* Parameter signature */
-    "glVertexPointerEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIS_texture_filter4)
-static const char GetTexFilterFuncSGIS_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetTexFilterFuncSGIS\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_register_combiners)
-static const char GetCombinerOutputParameterfvNV_names[] =
-    "iiip\0" /* Parameter signature */
-    "glGetCombinerOutputParameterfvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_subtexture)
-static const char TexSubImage1D_names[] =
-    "iiiiiip\0" /* Parameter signature */
-    "glTexSubImage1D\0"
-    "glTexSubImage1DEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib1sARB_names[] =
-    "ii\0" /* Parameter signature */
-    "glVertexAttrib1s\0"
-    "glVertexAttrib1sARB\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_sync)
-static const char FenceSync_names[] =
-    "ii\0" /* Parameter signature */
-    "glFenceSync\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_register_combiners)
-static const char FinalCombinerInputNV_names[] =
-    "iiii\0" /* Parameter signature */
-    "glFinalCombinerInputNV\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_flush_raster)
-static const char FlushRasterSGIX_names[] =
-    "\0" /* Parameter signature */
-    "glFlushRasterSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char ReplacementCodeuiTexCoord2fVertex3fSUN_names[] =
-    "ifffff\0" /* Parameter signature */
-    "glReplacementCodeuiTexCoord2fVertex3fSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_shader_objects)
-static const char Uniform1fARB_names[] =
-    "if\0" /* Parameter signature */
-    "glUniform1f\0"
-    "glUniform1fARB\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_texture_object)
-static const char AreTexturesResident_names[] =
-    "ipp\0" /* Parameter signature */
-    "glAreTexturesResident\0"
-    "glAreTexturesResidentEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ATI_separate_stencil)
-static const char StencilOpSeparate_names[] =
-    "iiii\0" /* Parameter signature */
-    "glStencilOpSeparate\0"
-    "glStencilOpSeparateATI\0"
-    "";
-#endif
-
-#if defined(need_GL_SGI_color_table)
-static const char ColorTableParameteriv_names[] =
-    "iip\0" /* Parameter signature */
-    "glColorTableParameteriv\0"
-    "glColorTableParameterivSGI\0"
-    "";
-#endif
-
-#if defined(need_GL_IBM_vertex_array_lists)
-static const char FogCoordPointerListIBM_names[] =
-    "iipi\0" /* Parameter signature */
-    "glFogCoordPointerListIBM\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_window_pos) || defined(need_GL_MESA_window_pos)
-static const char WindowPos3dMESA_names[] =
-    "ddd\0" /* Parameter signature */
-    "glWindowPos3d\0"
-    "glWindowPos3dARB\0"
-    "glWindowPos3dMESA\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_point_parameters) || defined(need_GL_EXT_point_parameters) || defined(need_GL_SGIS_point_parameters)
-static const char PointParameterfvEXT_names[] =
-    "ip\0" /* Parameter signature */
-    "glPointParameterfv\0"
-    "glPointParameterfvARB\0"
-    "glPointParameterfvEXT\0"
-    "glPointParameterfvSGIS\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_window_pos) || defined(need_GL_MESA_window_pos)
-static const char WindowPos2fvMESA_names[] =
-    "p\0" /* Parameter signature */
-    "glWindowPos2fv\0"
-    "glWindowPos2fvARB\0"
-    "glWindowPos2fvMESA\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
-static const char SecondaryColor3bvEXT_names[] =
-    "p\0" /* Parameter signature */
-    "glSecondaryColor3bv\0"
-    "glSecondaryColor3bvEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_IBM_vertex_array_lists)
-static const char VertexPointerListIBM_names[] =
-    "iiipi\0" /* Parameter signature */
-    "glVertexPointerListIBM\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_program)
-static const char GetProgramLocalParameterfvARB_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetProgramLocalParameterfvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_fragment_lighting)
-static const char FragmentMaterialfSGIX_names[] =
-    "iif\0" /* Parameter signature */
-    "glFragmentMaterialfSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char TexCoord2fNormal3fVertex3fSUN_names[] =
-    "ffffffff\0" /* Parameter signature */
-    "glTexCoord2fNormal3fVertex3fSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_framebuffer_object) || defined(need_GL_EXT_framebuffer_object)
-static const char RenderbufferStorageEXT_names[] =
-    "iiii\0" /* Parameter signature */
-    "glRenderbufferStorage\0"
-    "glRenderbufferStorageEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_fence)
-static const char IsFenceNV_names[] =
-    "i\0" /* Parameter signature */
-    "glIsFenceNV\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_shader_objects)
-static const char AttachObjectARB_names[] =
-    "ii\0" /* Parameter signature */
-    "glAttachObjectARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_fragment_lighting)
-static const char GetFragmentLightivSGIX_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetFragmentLightivSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_shader_objects)
-static const char UniformMatrix2fvARB_names[] =
-    "iiip\0" /* Parameter signature */
-    "glUniformMatrix2fv\0"
-    "glUniformMatrix2fvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char MultiTexCoord2fARB_names[] =
-    "iff\0" /* Parameter signature */
-    "glMultiTexCoord2f\0"
-    "glMultiTexCoord2fARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SGI_color_table) || defined(need_GL_EXT_paletted_texture)
-static const char ColorTable_names[] =
-    "iiiiip\0" /* Parameter signature */
-    "glColorTable\0"
-    "glColorTableSGI\0"
-    "glColorTableEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_evaluators)
-static const char MapControlPointsNV_names[] =
-    "iiiiiiiip\0" /* Parameter signature */
-    "glMapControlPointsNV\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_convolution)
-static const char ConvolutionFilter2D_names[] =
-    "iiiiiip\0" /* Parameter signature */
-    "glConvolutionFilter2D\0"
-    "glConvolutionFilter2DEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_evaluators)
-static const char MapParameterfvNV_names[] =
-    "iip\0" /* Parameter signature */
-    "glMapParameterfvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib3dvARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib3dv\0"
-    "glVertexAttrib3dvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_PGI_misc_hints)
-static const char HintPGI_names[] =
-    "ii\0" /* Parameter signature */
-    "glHintPGI\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_convolution)
-static const char ConvolutionParameteriv_names[] =
-    "iip\0" /* Parameter signature */
-    "glConvolutionParameteriv\0"
-    "glConvolutionParameterivEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_cull_vertex)
-static const char CullParameterdvEXT_names[] =
-    "ip\0" /* Parameter signature */
-    "glCullParameterdvEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_fragment_program)
-static const char ProgramNamedParameter4fNV_names[] =
-    "iipffff\0" /* Parameter signature */
-    "glProgramNamedParameter4fNV\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char Color3fVertex3fSUN_names[] =
-    "ffffff\0" /* Parameter signature */
-    "glColor3fVertex3fSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_program) || defined(need_GL_NV_vertex_program)
-static const char ProgramEnvParameter4fvARB_names[] =
-    "iip\0" /* Parameter signature */
-    "glProgramEnvParameter4fvARB\0"
-    "glProgramParameter4fvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_fragment_lighting)
-static const char FragmentLightModeliSGIX_names[] =
-    "ii\0" /* Parameter signature */
-    "glFragmentLightModeliSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_convolution)
-static const char ConvolutionParameterfv_names[] =
-    "iip\0" /* Parameter signature */
-    "glConvolutionParameterfv\0"
-    "glConvolutionParameterfvEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_3DFX_tbuffer)
-static const char TbufferMask3DFX_names[] =
-    "i\0" /* Parameter signature */
-    "glTbufferMask3DFX\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char LoadProgramNV_names[] =
-    "iiip\0" /* Parameter signature */
-    "glLoadProgramNV\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_sync)
-static const char WaitSync_names[] =
-    "iii\0" /* Parameter signature */
-    "glWaitSync\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttrib4fvNV_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib4fvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_shader_objects)
-static const char GetAttachedObjectsARB_names[] =
-    "iipp\0" /* Parameter signature */
-    "glGetAttachedObjectsARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_shader_objects)
-static const char Uniform3fvARB_names[] =
-    "iip\0" /* Parameter signature */
-    "glUniform3fv\0"
-    "glUniform3fvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_draw_range_elements)
-static const char DrawRangeElements_names[] =
-    "iiiiip\0" /* Parameter signature */
-    "glDrawRangeElements\0"
-    "glDrawRangeElementsEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_sprite)
-static const char SpriteParameterfvSGIX_names[] =
-    "ip\0" /* Parameter signature */
-    "glSpriteParameterfvSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_framebuffer_object) || defined(need_GL_EXT_framebuffer_object)
-static const char CheckFramebufferStatusEXT_names[] =
-    "i\0" /* Parameter signature */
-    "glCheckFramebufferStatus\0"
-    "glCheckFramebufferStatusEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_global_alpha)
-static const char GlobalAlphaFactoruiSUN_names[] =
-    "i\0" /* Parameter signature */
-    "glGlobalAlphaFactoruiSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_shader_objects)
-static const char GetHandleARB_names[] =
-    "i\0" /* Parameter signature */
-    "glGetHandleARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char GetVertexAttribivARB_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetVertexAttribiv\0"
-    "glGetVertexAttribivARB\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_register_combiners)
-static const char GetCombinerInputParameterfvNV_names[] =
-    "iiiip\0" /* Parameter signature */
-    "glGetCombinerInputParameterfvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0)
-static const char CreateProgram_names[] =
-    "\0" /* Parameter signature */
-    "glCreateProgram\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3) || defined(need_GL_ARB_transpose_matrix)
-static const char LoadTransposeMatrixdARB_names[] =
-    "p\0" /* Parameter signature */
-    "glLoadTransposeMatrixd\0"
-    "glLoadTransposeMatrixdARB\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_histogram)
-static const char GetMinmax_names[] =
-    "iiiip\0" /* Parameter signature */
-    "glGetMinmax\0"
-    "glGetMinmaxEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0)
-static const char StencilFuncSeparate_names[] =
-    "iiii\0" /* Parameter signature */
-    "glStencilFuncSeparate\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
-static const char SecondaryColor3sEXT_names[] =
-    "iii\0" /* Parameter signature */
-    "glSecondaryColor3s\0"
-    "glSecondaryColor3sEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char Color3fVertex3fvSUN_names[] =
-    "pp\0" /* Parameter signature */
-    "glColor3fVertex3fvSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_global_alpha)
-static const char GlobalAlphaFactorbSUN_names[] =
-    "i\0" /* Parameter signature */
-    "glGlobalAlphaFactorbSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_HP_image_transform)
-static const char ImageTransformParameterfvHP_names[] =
-    "iip\0" /* Parameter signature */
-    "glImageTransformParameterfvHP\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib4ivARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib4iv\0"
-    "glVertexAttrib4ivARB\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttrib3fNV_names[] =
-    "ifff\0" /* Parameter signature */
-    "glVertexAttrib3fNV\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttribs2dvNV_names[] =
-    "iip\0" /* Parameter signature */
-    "glVertexAttribs2dvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_timer_query)
-static const char GetQueryObjectui64vEXT_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetQueryObjectui64vEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char MultiTexCoord3fvARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glMultiTexCoord3fv\0"
-    "glMultiTexCoord3fvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
-static const char SecondaryColor3dEXT_names[] =
-    "ddd\0" /* Parameter signature */
-    "glSecondaryColor3d\0"
-    "glSecondaryColor3dEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char GetProgramParameterfvNV_names[] =
-    "iiip\0" /* Parameter signature */
-    "glGetProgramParameterfvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_coordinate_frame)
-static const char TangentPointerEXT_names[] =
-    "iip\0" /* Parameter signature */
-    "glTangentPointerEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char Color4fNormal3fVertex3fvSUN_names[] =
-    "ppp\0" /* Parameter signature */
-    "glColor4fNormal3fVertex3fvSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_instruments)
-static const char GetInstrumentsSGIX_names[] =
-    "\0" /* Parameter signature */
-    "glGetInstrumentsSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_evaluators)
-static const char EvalMapsNV_names[] =
-    "ii\0" /* Parameter signature */
-    "glEvalMapsNV\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_subtexture)
-static const char TexSubImage2D_names[] =
-    "iiiiiiiip\0" /* Parameter signature */
-    "glTexSubImage2D\0"
-    "glTexSubImage2DEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_fragment_lighting)
-static const char FragmentLightivSGIX_names[] =
-    "iip\0" /* Parameter signature */
-    "glFragmentLightivSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_APPLE_texture_range)
-static const char GetTexParameterPointervAPPLE_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetTexParameterPointervAPPLE\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_pixel_transform)
-static const char PixelTransformParameterfvEXT_names[] =
-    "iip\0" /* Parameter signature */
-    "glPixelTransformParameterfvEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib4bvARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib4bv\0"
-    "glVertexAttrib4bvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_ATI_fragment_shader)
-static const char AlphaFragmentOp2ATI_names[] =
-    "iiiiiiiii\0" /* Parameter signature */
-    "glAlphaFragmentOp2ATI\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char MultiTexCoord4sARB_names[] =
-    "iiiii\0" /* Parameter signature */
-    "glMultiTexCoord4s\0"
-    "glMultiTexCoord4sARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_fragment_lighting)
-static const char GetFragmentMaterialivSGIX_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetFragmentMaterialivSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_MESA_window_pos)
-static const char WindowPos4dMESA_names[] =
-    "dddd\0" /* Parameter signature */
-    "glWindowPos4dMESA\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_blend)
-static const char WeightPointerARB_names[] =
-    "iiip\0" /* Parameter signature */
-    "glWeightPointerARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_window_pos) || defined(need_GL_MESA_window_pos)
-static const char WindowPos2dMESA_names[] =
-    "dd\0" /* Parameter signature */
-    "glWindowPos2d\0"
-    "glWindowPos2dARB\0"
-    "glWindowPos2dMESA\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_framebuffer_object) || defined(need_GL_EXT_framebuffer_object)
-static const char FramebufferTexture3DEXT_names[] =
-    "iiiiii\0" /* Parameter signature */
-    "glFramebufferTexture3D\0"
-    "glFramebufferTexture3DEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_blend_minmax)
-static const char BlendEquation_names[] =
-    "i\0" /* Parameter signature */
-    "glBlendEquation\0"
-    "glBlendEquationEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttrib3dNV_names[] =
-    "iddd\0" /* Parameter signature */
-    "glVertexAttrib3dNV\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib3dARB_names[] =
-    "iddd\0" /* Parameter signature */
-    "glVertexAttrib3d\0"
-    "glVertexAttrib3dARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN_names[] =
-    "ppppp\0" /* Parameter signature */
-    "glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib4fARB_names[] =
-    "iffff\0" /* Parameter signature */
-    "glVertexAttrib4f\0"
-    "glVertexAttrib4fARB\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_index_func)
-static const char IndexFuncEXT_names[] =
-    "if\0" /* Parameter signature */
-    "glIndexFuncEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_framebuffer_object) || defined(need_GL_EXT_framebuffer_object)
-static const char FramebufferTexture2DEXT_names[] =
-    "iiiii\0" /* Parameter signature */
-    "glFramebufferTexture2D\0"
-    "glFramebufferTexture2DEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char MultiTexCoord2dvARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glMultiTexCoord2dv\0"
-    "glMultiTexCoord2dvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_cull_vertex)
-static const char CullParameterfvEXT_names[] =
-    "ip\0" /* Parameter signature */
-    "glCullParameterfvEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_fragment_program)
-static const char ProgramNamedParameter4fvNV_names[] =
-    "iipp\0" /* Parameter signature */
-    "glProgramNamedParameter4fvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
-static const char SecondaryColorPointerEXT_names[] =
-    "iiip\0" /* Parameter signature */
-    "glSecondaryColorPointer\0"
-    "glSecondaryColorPointerEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib4fvARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib4fv\0"
-    "glVertexAttrib4fvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_IBM_vertex_array_lists)
-static const char ColorPointerListIBM_names[] =
-    "iiipi\0" /* Parameter signature */
-    "glColorPointerListIBM\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_shader_objects)
-static const char GetActiveUniformARB_names[] =
-    "iiipppp\0" /* Parameter signature */
-    "glGetActiveUniform\0"
-    "glGetActiveUniformARB\0"
-    "";
-#endif
-
-#if defined(need_GL_HP_image_transform)
-static const char ImageTransformParameteriHP_names[] =
-    "iii\0" /* Parameter signature */
-    "glImageTransformParameteriHP\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char MultiTexCoord1svARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glMultiTexCoord1sv\0"
-    "glMultiTexCoord1svARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_occlusion_query)
-static const char EndQueryARB_names[] =
-    "i\0" /* Parameter signature */
-    "glEndQuery\0"
-    "glEndQueryARB\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_fence)
-static const char DeleteFencesNV_names[] =
-    "ip\0" /* Parameter signature */
-    "glDeleteFencesNV\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_polynomial_ffd)
-static const char DeformationMap3dSGIX_names[] =
-    "iddiiddiiddiip\0" /* Parameter signature */
-    "glDeformationMap3dSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0)
-static const char IsShader_names[] =
-    "i\0" /* Parameter signature */
-    "glIsShader\0"
-    "";
-#endif
-
-#if defined(need_GL_HP_image_transform)
-static const char GetImageTransformParameterivHP_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetImageTransformParameterivHP\0"
-    "";
-#endif
-
-#if defined(need_GL_MESA_window_pos)
-static const char WindowPos4ivMESA_names[] =
-    "p\0" /* Parameter signature */
-    "glWindowPos4ivMESA\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char MultiTexCoord3svARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glMultiTexCoord3sv\0"
-    "glMultiTexCoord3svARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char MultiTexCoord4iARB_names[] =
-    "iiiii\0" /* Parameter signature */
-    "glMultiTexCoord4i\0"
-    "glMultiTexCoord4iARB\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_coordinate_frame)
-static const char Binormal3ivEXT_names[] =
-    "p\0" /* Parameter signature */
-    "glBinormal3ivEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_MESA_resize_buffers)
-static const char ResizeBuffersMESA_names[] =
-    "\0" /* Parameter signature */
-    "glResizeBuffersMESA\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_shader_objects)
-static const char GetUniformivARB_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetUniformiv\0"
-    "glGetUniformivARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIS_pixel_texture)
-static const char PixelTexGenParameteriSGIS_names[] =
-    "ii\0" /* Parameter signature */
-    "glPixelTexGenParameteriSGIS\0"
-    "";
-#endif
-
-#if defined(need_GL_INTEL_parallel_arrays)
-static const char VertexPointervINTEL_names[] =
-    "iip\0" /* Parameter signature */
-    "glVertexPointervINTEL\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char ReplacementCodeuiColor4fNormal3fVertex3fvSUN_names[] =
-    "pppp\0" /* Parameter signature */
-    "glReplacementCodeuiColor4fNormal3fVertex3fvSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
-static const char SecondaryColor3uiEXT_names[] =
-    "iii\0" /* Parameter signature */
-    "glSecondaryColor3ui\0"
-    "glSecondaryColor3uiEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_instruments)
-static const char StartInstrumentsSGIX_names[] =
-    "\0" /* Parameter signature */
-    "glStartInstrumentsSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
-static const char SecondaryColor3usvEXT_names[] =
-    "p\0" /* Parameter signature */
-    "glSecondaryColor3usv\0"
-    "glSecondaryColor3usvEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttrib2fvNV_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib2fvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_program)
-static const char ProgramLocalParameter4dvARB_names[] =
-    "iip\0" /* Parameter signature */
-    "glProgramLocalParameter4dvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_matrix_palette)
-static const char MatrixIndexuivARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glMatrixIndexuivARB\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_framebuffer_object)
-static const char RenderbufferStorageMultisample_names[] =
-    "iiiii\0" /* Parameter signature */
-    "glRenderbufferStorageMultisample\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_coordinate_frame)
-static const char Tangent3sEXT_names[] =
-    "iii\0" /* Parameter signature */
-    "glTangent3sEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_global_alpha)
-static const char GlobalAlphaFactorfSUN_names[] =
-    "f\0" /* Parameter signature */
-    "glGlobalAlphaFactorfSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char MultiTexCoord3iARB_names[] =
-    "iiii\0" /* Parameter signature */
-    "glMultiTexCoord3i\0"
-    "glMultiTexCoord3iARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0)
-static const char IsProgram_names[] =
-    "i\0" /* Parameter signature */
-    "glIsProgram\0"
-    "";
-#endif
-
-#if defined(need_GL_IBM_vertex_array_lists)
-static const char TexCoordPointerListIBM_names[] =
-    "iiipi\0" /* Parameter signature */
-    "glTexCoordPointerListIBM\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_global_alpha)
-static const char GlobalAlphaFactorusSUN_names[] =
-    "i\0" /* Parameter signature */
-    "glGlobalAlphaFactorusSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttrib2dvNV_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib2dvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_framebuffer_object) || defined(need_GL_EXT_framebuffer_object)
-static const char FramebufferRenderbufferEXT_names[] =
-    "iiii\0" /* Parameter signature */
-    "glFramebufferRenderbuffer\0"
-    "glFramebufferRenderbufferEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttrib1dvNV_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib1dvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_texture_object)
-static const char GenTextures_names[] =
-    "ip\0" /* Parameter signature */
-    "glGenTextures\0"
-    "glGenTexturesEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_fence)
-static const char SetFenceNV_names[] =
-    "ii\0" /* Parameter signature */
-    "glSetFenceNV\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_framebuffer_object) || defined(need_GL_EXT_framebuffer_object)
-static const char FramebufferTexture1DEXT_names[] =
-    "iiiii\0" /* Parameter signature */
-    "glFramebufferTexture1D\0"
-    "glFramebufferTexture1DEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_register_combiners)
-static const char GetCombinerOutputParameterivNV_names[] =
-    "iiip\0" /* Parameter signature */
-    "glGetCombinerOutputParameterivNV\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIS_pixel_texture)
-static const char PixelTexGenParameterivSGIS_names[] =
-    "ip\0" /* Parameter signature */
-    "glPixelTexGenParameterivSGIS\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_texture_perturb_normal)
-static const char TextureNormalEXT_names[] =
-    "i\0" /* Parameter signature */
-    "glTextureNormalEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_IBM_vertex_array_lists)
-static const char IndexPointerListIBM_names[] =
-    "iipi\0" /* Parameter signature */
-    "glIndexPointerListIBM\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_blend)
-static const char WeightfvARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glWeightfvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_MESA_window_pos)
-static const char WindowPos4fMESA_names[] =
-    "ffff\0" /* Parameter signature */
-    "glWindowPos4fMESA\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_window_pos) || defined(need_GL_MESA_window_pos)
-static const char WindowPos3dvMESA_names[] =
-    "p\0" /* Parameter signature */
-    "glWindowPos3dv\0"
-    "glWindowPos3dvARB\0"
-    "glWindowPos3dvMESA\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_timer_query)
-static const char GetQueryObjecti64vEXT_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetQueryObjecti64vEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char MultiTexCoord1dARB_names[] =
-    "id\0" /* Parameter signature */
-    "glMultiTexCoord1d\0"
-    "glMultiTexCoord1dARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_NV_point_sprite)
-static const char PointParameterivNV_names[] =
-    "ip\0" /* Parameter signature */
-    "glPointParameteriv\0"
-    "glPointParameterivNV\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_shader_objects)
-static const char Uniform2fvARB_names[] =
-    "iip\0" /* Parameter signature */
-    "glUniform2fv\0"
-    "glUniform2fvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_APPLE_flush_buffer_range)
-static const char BufferParameteriAPPLE_names[] =
-    "iii\0" /* Parameter signature */
-    "glBufferParameteriAPPLE\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char MultiTexCoord3dvARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glMultiTexCoord3dv\0"
-    "glMultiTexCoord3dvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char ReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN_names[] =
-    "pppp\0" /* Parameter signature */
-    "glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_shader_objects)
-static const char DeleteObjectARB_names[] =
-    "i\0" /* Parameter signature */
-    "glDeleteObjectARB\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_matrix_palette)
-static const char MatrixIndexPointerARB_names[] =
-    "iiip\0" /* Parameter signature */
-    "glMatrixIndexPointerARB\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_fragment_program)
-static const char ProgramNamedParameter4dvNV_names[] =
-    "iipp\0" /* Parameter signature */
-    "glProgramNamedParameter4dvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_coordinate_frame)
-static const char Tangent3fvEXT_names[] =
-    "p\0" /* Parameter signature */
-    "glTangent3fvEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_array_object)
-static const char GenVertexArrays_names[] =
-    "ip\0" /* Parameter signature */
-    "glGenVertexArrays\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_framebuffer_object) || defined(need_GL_EXT_framebuffer_object)
-static const char BindFramebufferEXT_names[] =
-    "ii\0" /* Parameter signature */
-    "glBindFramebuffer\0"
-    "glBindFramebufferEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_reference_plane)
-static const char ReferencePlaneSGIX_names[] =
-    "p\0" /* Parameter signature */
-    "glReferencePlaneSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_shader_objects)
-static const char ValidateProgramARB_names[] =
-    "i\0" /* Parameter signature */
-    "glValidateProgram\0"
-    "glValidateProgramARB\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_compiled_vertex_array)
-static const char UnlockArraysEXT_names[] =
-    "\0" /* Parameter signature */
-    "glUnlockArraysEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char TexCoord2fColor3fVertex3fSUN_names[] =
-    "ffffffff\0" /* Parameter signature */
-    "glTexCoord2fColor3fVertex3fSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_window_pos) || defined(need_GL_MESA_window_pos)
-static const char WindowPos3fvMESA_names[] =
-    "p\0" /* Parameter signature */
-    "glWindowPos3fv\0"
-    "glWindowPos3fvARB\0"
-    "glWindowPos3fvMESA\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttrib1svNV_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib1svNV\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_copy_texture)
-static const char CopyTexSubImage3D_names[] =
-    "iiiiiiiii\0" /* Parameter signature */
-    "glCopyTexSubImage3D\0"
-    "glCopyTexSubImage3DEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib2dARB_names[] =
-    "idd\0" /* Parameter signature */
-    "glVertexAttrib2d\0"
-    "glVertexAttrib2dARB\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_sync)
-static const char GetInteger64v_names[] =
-    "ip\0" /* Parameter signature */
-    "glGetInteger64v\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIS_texture_color_mask)
-static const char TextureColorMaskSGIS_names[] =
-    "iiii\0" /* Parameter signature */
-    "glTextureColorMaskSGIS\0"
-    "";
-#endif
-
-#if defined(need_GL_SGI_color_table) || defined(need_GL_EXT_paletted_texture)
-static const char GetColorTable_names[] =
-    "iiip\0" /* Parameter signature */
-    "glGetColorTable\0"
-    "glGetColorTableSGI\0"
-    "glGetColorTableEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SGI_color_table)
-static const char CopyColorTable_names[] =
-    "iiiii\0" /* Parameter signature */
-    "glCopyColorTable\0"
-    "glCopyColorTableSGI\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_histogram)
-static const char GetHistogramParameterfv_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetHistogramParameterfv\0"
-    "glGetHistogramParameterfvEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_INTEL_parallel_arrays)
-static const char ColorPointervINTEL_names[] =
-    "iip\0" /* Parameter signature */
-    "glColorPointervINTEL\0"
-    "";
-#endif
-
-#if defined(need_GL_ATI_fragment_shader)
-static const char AlphaFragmentOp1ATI_names[] =
-    "iiiiii\0" /* Parameter signature */
-    "glAlphaFragmentOp1ATI\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char MultiTexCoord3ivARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glMultiTexCoord3iv\0"
-    "glMultiTexCoord3ivARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char MultiTexCoord2sARB_names[] =
-    "iii\0" /* Parameter signature */
-    "glMultiTexCoord2s\0"
-    "glMultiTexCoord2sARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib1dvARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib1dv\0"
-    "glVertexAttrib1dvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_texture_object)
-static const char DeleteTextures_names[] =
-    "ip\0" /* Parameter signature */
-    "glDeleteTextures\0"
-    "glDeleteTexturesEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_vertex_array)
-static const char TexCoordPointerEXT_names[] =
-    "iiiip\0" /* Parameter signature */
-    "glTexCoordPointerEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIS_texture4D)
-static const char TexSubImage4DSGIS_names[] =
-    "iiiiiiiiiiiip\0" /* Parameter signature */
-    "glTexSubImage4DSGIS\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_register_combiners2)
-static const char CombinerStageParameterfvNV_names[] =
-    "iip\0" /* Parameter signature */
-    "glCombinerStageParameterfvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_instruments)
-static const char StopInstrumentsSGIX_names[] =
-    "i\0" /* Parameter signature */
-    "glStopInstrumentsSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char TexCoord4fColor4fNormal3fVertex4fSUN_names[] =
-    "fffffffffffffff\0" /* Parameter signature */
-    "glTexCoord4fColor4fNormal3fVertex4fSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_polynomial_ffd)
-static const char DeformSGIX_names[] =
-    "i\0" /* Parameter signature */
-    "glDeformSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char GetVertexAttribfvARB_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetVertexAttribfv\0"
-    "glGetVertexAttribfvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
-static const char SecondaryColor3ivEXT_names[] =
-    "p\0" /* Parameter signature */
-    "glSecondaryColor3iv\0"
-    "glSecondaryColor3ivEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_1)
-static const char UniformMatrix4x2fv_names[] =
-    "iiip\0" /* Parameter signature */
-    "glUniformMatrix4x2fv\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIS_detail_texture)
-static const char GetDetailTexFuncSGIS_names[] =
-    "ip\0" /* Parameter signature */
-    "glGetDetailTexFuncSGIS\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_register_combiners2)
-static const char GetCombinerStageParameterfvNV_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetCombinerStageParameterfvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_array_object)
-static const char BindVertexArray_names[] =
-    "i\0" /* Parameter signature */
-    "glBindVertexArray\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char Color4ubVertex2fvSUN_names[] =
-    "pp\0" /* Parameter signature */
-    "glColor4ubVertex2fvSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIS_texture_filter4)
-static const char TexFilterFuncSGIS_names[] =
-    "iiip\0" /* Parameter signature */
-    "glTexFilterFuncSGIS\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIS_multisample) || defined(need_GL_EXT_multisample)
-static const char SampleMaskSGIS_names[] =
-    "fi\0" /* Parameter signature */
-    "glSampleMaskSGIS\0"
-    "glSampleMaskEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_shader)
-static const char GetAttribLocationARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glGetAttribLocation\0"
-    "glGetAttribLocationARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib4ubvARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib4ubv\0"
-    "glVertexAttrib4ubvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIS_detail_texture)
-static const char DetailTexFuncSGIS_names[] =
-    "iip\0" /* Parameter signature */
-    "glDetailTexFuncSGIS\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char Normal3fVertex3fSUN_names[] =
-    "ffffff\0" /* Parameter signature */
-    "glNormal3fVertex3fSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_copy_texture)
-static const char CopyTexImage2D_names[] =
-    "iiiiiiii\0" /* Parameter signature */
-    "glCopyTexImage2D\0"
-    "glCopyTexImage2DEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_vertex_buffer_object)
-static const char GetBufferPointervARB_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetBufferPointerv\0"
-    "glGetBufferPointervARB\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_program) || defined(need_GL_NV_vertex_program)
-static const char ProgramEnvParameter4fARB_names[] =
-    "iiffff\0" /* Parameter signature */
-    "glProgramEnvParameter4fARB\0"
-    "glProgramParameter4fNV\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_shader_objects)
-static const char Uniform3ivARB_names[] =
-    "iip\0" /* Parameter signature */
-    "glUniform3iv\0"
-    "glUniform3ivARB\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_fence)
-static const char GetFenceivNV_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetFenceivNV\0"
-    "";
-#endif
-
-#if defined(need_GL_MESA_window_pos)
-static const char WindowPos4dvMESA_names[] =
-    "p\0" /* Parameter signature */
-    "glWindowPos4dvMESA\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_color_subtable)
-static const char ColorSubTable_names[] =
-    "iiiiip\0" /* Parameter signature */
-    "glColorSubTable\0"
-    "glColorSubTableEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char MultiTexCoord4ivARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glMultiTexCoord4iv\0"
-    "glMultiTexCoord4ivARB\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_gpu_program_parameters)
-static const char ProgramLocalParameters4fvEXT_names[] =
-    "iiip\0" /* Parameter signature */
-    "glProgramLocalParameters4fvEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_evaluators)
-static const char GetMapAttribParameterfvNV_names[] =
-    "iiip\0" /* Parameter signature */
-    "glGetMapAttribParameterfvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib4sARB_names[] =
-    "iiiii\0" /* Parameter signature */
-    "glVertexAttrib4s\0"
-    "glVertexAttrib4sARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_occlusion_query)
-static const char GetQueryObjectuivARB_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetQueryObjectuiv\0"
-    "glGetQueryObjectuivARB\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_evaluators)
-static const char MapParameterivNV_names[] =
-    "iip\0" /* Parameter signature */
-    "glMapParameterivNV\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_framebuffer_object) || defined(need_GL_EXT_framebuffer_object)
-static const char GenRenderbuffersEXT_names[] =
-    "ip\0" /* Parameter signature */
-    "glGenRenderbuffers\0"
-    "glGenRenderbuffersEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib2dvARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib2dv\0"
-    "glVertexAttrib2dvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_vertex_array)
-static const char EdgeFlagPointerEXT_names[] =
-    "iip\0" /* Parameter signature */
-    "glEdgeFlagPointerEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttribs2svNV_names[] =
-    "iip\0" /* Parameter signature */
-    "glVertexAttribs2svNV\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_blend)
-static const char WeightbvARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glWeightbvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib2fvARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib2fv\0"
-    "glVertexAttrib2fvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_vertex_buffer_object)
-static const char GetBufferParameterivARB_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetBufferParameteriv\0"
-    "glGetBufferParameterivARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_list_priority)
-static const char ListParameteriSGIX_names[] =
-    "iii\0" /* Parameter signature */
-    "glListParameteriSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char ReplacementCodeuiColor4fNormal3fVertex3fSUN_names[] =
-    "iffffffffff\0" /* Parameter signature */
-    "glReplacementCodeuiColor4fNormal3fVertex3fSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_instruments)
-static const char InstrumentsBufferSGIX_names[] =
-    "ip\0" /* Parameter signature */
-    "glInstrumentsBufferSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib4NivARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib4Niv\0"
-    "glVertexAttrib4NivARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0)
-static const char GetAttachedShaders_names[] =
-    "iipp\0" /* Parameter signature */
-    "glGetAttachedShaders\0"
-    "";
-#endif
-
-#if defined(need_GL_APPLE_vertex_array_object)
-static const char GenVertexArraysAPPLE_names[] =
-    "ip\0" /* Parameter signature */
-    "glGenVertexArraysAPPLE\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_gpu_program_parameters)
-static const char ProgramEnvParameters4fvEXT_names[] =
-    "iiip\0" /* Parameter signature */
-    "glProgramEnvParameters4fvEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char TexCoord2fColor4fNormal3fVertex3fvSUN_names[] =
-    "pppp\0" /* Parameter signature */
-    "glTexCoord2fColor4fNormal3fVertex3fvSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_window_pos) || defined(need_GL_MESA_window_pos)
-static const char WindowPos2iMESA_names[] =
-    "ii\0" /* Parameter signature */
-    "glWindowPos2i\0"
-    "glWindowPos2iARB\0"
-    "glWindowPos2iMESA\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
-static const char SecondaryColor3fvEXT_names[] =
-    "p\0" /* Parameter signature */
-    "glSecondaryColor3fv\0"
-    "glSecondaryColor3fvEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3) || defined(need_GL_ARB_texture_compression)
-static const char CompressedTexSubImage1DARB_names[] =
-    "iiiiiip\0" /* Parameter signature */
-    "glCompressedTexSubImage1D\0"
-    "glCompressedTexSubImage1DARB\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char GetVertexAttribivNV_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetVertexAttribivNV\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_program)
-static const char GetProgramStringARB_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetProgramStringARB\0"
-    "";
-#endif
-
-#if defined(need_GL_ATI_envmap_bumpmap)
-static const char TexBumpParameterfvATI_names[] =
-    "ip\0" /* Parameter signature */
-    "glTexBumpParameterfvATI\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_shader_objects)
-static const char CompileShaderARB_names[] =
-    "i\0" /* Parameter signature */
-    "glCompileShader\0"
-    "glCompileShaderARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0)
-static const char DeleteShader_names[] =
-    "i\0" /* Parameter signature */
-    "glDeleteShader\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_shader_objects)
-static const char Uniform3fARB_names[] =
-    "ifff\0" /* Parameter signature */
-    "glUniform3f\0"
-    "glUniform3fARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_list_priority)
-static const char ListParameterfvSGIX_names[] =
-    "iip\0" /* Parameter signature */
-    "glListParameterfvSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_coordinate_frame)
-static const char Tangent3dvEXT_names[] =
-    "p\0" /* Parameter signature */
-    "glTangent3dvEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char GetVertexAttribfvNV_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetVertexAttribfvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_window_pos) || defined(need_GL_MESA_window_pos)
-static const char WindowPos3sMESA_names[] =
-    "iii\0" /* Parameter signature */
-    "glWindowPos3s\0"
-    "glWindowPos3sARB\0"
-    "glWindowPos3sMESA\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttrib2svNV_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib2svNV\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttribs1fvNV_names[] =
-    "iip\0" /* Parameter signature */
-    "glVertexAttribs1fvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char TexCoord2fVertex3fvSUN_names[] =
-    "pp\0" /* Parameter signature */
-    "glTexCoord2fVertex3fvSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_MESA_window_pos)
-static const char WindowPos4sMESA_names[] =
-    "iiii\0" /* Parameter signature */
-    "glWindowPos4sMESA\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib4NuivARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib4Nuiv\0"
-    "glVertexAttrib4NuivARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char ClientActiveTextureARB_names[] =
-    "i\0" /* Parameter signature */
-    "glClientActiveTexture\0"
-    "glClientActiveTextureARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_pixel_texture)
-static const char PixelTexGenSGIX_names[] =
-    "i\0" /* Parameter signature */
-    "glPixelTexGenSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_triangle_list)
-static const char ReplacementCodeusvSUN_names[] =
-    "p\0" /* Parameter signature */
-    "glReplacementCodeusvSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_shader_objects)
-static const char Uniform4fARB_names[] =
-    "iffff\0" /* Parameter signature */
-    "glUniform4f\0"
-    "glUniform4fARB\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_map_buffer_range)
-static const char FlushMappedBufferRange_names[] =
-    "iii\0" /* Parameter signature */
-    "glFlushMappedBufferRange\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_program) || defined(need_GL_NV_vertex_program)
-static const char IsProgramNV_names[] =
-    "i\0" /* Parameter signature */
-    "glIsProgramARB\0"
-    "glIsProgramNV\0"
-    "";
-#endif
-
-#if defined(need_GL_APPLE_flush_buffer_range)
-static const char FlushMappedBufferRangeAPPLE_names[] =
-    "iii\0" /* Parameter signature */
-    "glFlushMappedBufferRangeAPPLE\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_triangle_list)
-static const char ReplacementCodePointerSUN_names[] =
-    "iip\0" /* Parameter signature */
-    "glReplacementCodePointerSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_program) || defined(need_GL_NV_vertex_program)
-static const char ProgramEnvParameter4dARB_names[] =
-    "iidddd\0" /* Parameter signature */
-    "glProgramEnvParameter4dARB\0"
-    "glProgramParameter4dNV\0"
-    "";
-#endif
-
-#if defined(need_GL_SGI_color_table)
-static const char ColorTableParameterfv_names[] =
-    "iip\0" /* Parameter signature */
-    "glColorTableParameterfv\0"
-    "glColorTableParameterfvSGI\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_fragment_lighting)
-static const char FragmentLightModelfSGIX_names[] =
-    "if\0" /* Parameter signature */
-    "glFragmentLightModelfSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_coordinate_frame)
-static const char Binormal3bvEXT_names[] =
-    "p\0" /* Parameter signature */
-    "glBinormal3bvEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_texture_object)
-static const char IsTexture_names[] =
-    "i\0" /* Parameter signature */
-    "glIsTexture\0"
-    "glIsTextureEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_vertex_weighting)
-static const char VertexWeightfvEXT_names[] =
-    "p\0" /* Parameter signature */
-    "glVertexWeightfvEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib1dARB_names[] =
-    "id\0" /* Parameter signature */
-    "glVertexAttrib1d\0"
-    "glVertexAttrib1dARB\0"
-    "";
-#endif
-
-#if defined(need_GL_HP_image_transform)
-static const char ImageTransformParameterivHP_names[] =
-    "iip\0" /* Parameter signature */
-    "glImageTransformParameterivHP\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_occlusion_query)
-static const char DeleteQueriesARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glDeleteQueries\0"
-    "glDeleteQueriesARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char Color4ubVertex2fSUN_names[] =
-    "iiiiff\0" /* Parameter signature */
-    "glColor4ubVertex2fSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_fragment_lighting)
-static const char FragmentColorMaterialSGIX_names[] =
-    "ii\0" /* Parameter signature */
-    "glFragmentColorMaterialSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_matrix_palette)
-static const char CurrentPaletteMatrixARB_names[] =
-    "i\0" /* Parameter signature */
-    "glCurrentPaletteMatrixARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIS_multisample) || defined(need_GL_EXT_multisample)
-static const char SamplePatternSGIS_names[] =
-    "i\0" /* Parameter signature */
-    "glSamplePatternSGIS\0"
-    "glSamplePatternEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_occlusion_query)
-static const char IsQueryARB_names[] =
-    "i\0" /* Parameter signature */
-    "glIsQuery\0"
-    "glIsQueryARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char ReplacementCodeuiColor4ubVertex3fSUN_names[] =
-    "iiiiifff\0" /* Parameter signature */
-    "glReplacementCodeuiColor4ubVertex3fSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib4usvARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib4usv\0"
-    "glVertexAttrib4usvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_shader_objects)
-static const char LinkProgramARB_names[] =
-    "i\0" /* Parameter signature */
-    "glLinkProgram\0"
-    "glLinkProgramARB\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttrib2fNV_names[] =
-    "iff\0" /* Parameter signature */
-    "glVertexAttrib2fNV\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_shader_objects)
-static const char ShaderSourceARB_names[] =
-    "iipp\0" /* Parameter signature */
-    "glShaderSource\0"
-    "glShaderSourceARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_fragment_lighting)
-static const char FragmentMaterialiSGIX_names[] =
-    "iii\0" /* Parameter signature */
-    "glFragmentMaterialiSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib3svARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib3sv\0"
-    "glVertexAttrib3svARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3) || defined(need_GL_ARB_texture_compression)
-static const char CompressedTexSubImage3DARB_names[] =
-    "iiiiiiiiiip\0" /* Parameter signature */
-    "glCompressedTexSubImage3D\0"
-    "glCompressedTexSubImage3DARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_window_pos) || defined(need_GL_MESA_window_pos)
-static const char WindowPos2ivMESA_names[] =
-    "p\0" /* Parameter signature */
-    "glWindowPos2iv\0"
-    "glWindowPos2ivARB\0"
-    "glWindowPos2ivMESA\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_framebuffer_object) || defined(need_GL_EXT_framebuffer_object)
-static const char IsFramebufferEXT_names[] =
-    "i\0" /* Parameter signature */
-    "glIsFramebuffer\0"
-    "glIsFramebufferEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_shader_objects)
-static const char Uniform4ivARB_names[] =
-    "iip\0" /* Parameter signature */
-    "glUniform4iv\0"
-    "glUniform4ivARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char GetVertexAttribdvARB_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetVertexAttribdv\0"
-    "glGetVertexAttribdvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_ATI_envmap_bumpmap)
-static const char TexBumpParameterivATI_names[] =
-    "ip\0" /* Parameter signature */
-    "glTexBumpParameterivATI\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_convolution)
-static const char GetSeparableFilter_names[] =
-    "iiippp\0" /* Parameter signature */
-    "glGetSeparableFilter\0"
-    "glGetSeparableFilterEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_coordinate_frame)
-static const char Binormal3dEXT_names[] =
-    "ddd\0" /* Parameter signature */
-    "glBinormal3dEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_sprite)
-static const char SpriteParameteriSGIX_names[] =
-    "ii\0" /* Parameter signature */
-    "glSpriteParameteriSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char RequestResidentProgramsNV_names[] =
-    "ip\0" /* Parameter signature */
-    "glRequestResidentProgramsNV\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_tag_sample_buffer)
-static const char TagSampleBufferSGIX_names[] =
-    "\0" /* Parameter signature */
-    "glTagSampleBufferSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_triangle_list)
-static const char ReplacementCodeusSUN_names[] =
-    "i\0" /* Parameter signature */
-    "glReplacementCodeusSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_list_priority)
-static const char ListParameterivSGIX_names[] =
-    "iip\0" /* Parameter signature */
-    "glListParameterivSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_multi_draw_arrays)
-static const char MultiDrawElementsEXT_names[] =
-    "ipipi\0" /* Parameter signature */
-    "glMultiDrawElements\0"
-    "glMultiDrawElementsEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_shader_objects)
-static const char Uniform1ivARB_names[] =
-    "iip\0" /* Parameter signature */
-    "glUniform1iv\0"
-    "glUniform1ivARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_window_pos) || defined(need_GL_MESA_window_pos)
-static const char WindowPos2sMESA_names[] =
-    "ii\0" /* Parameter signature */
-    "glWindowPos2s\0"
-    "glWindowPos2sARB\0"
-    "glWindowPos2sMESA\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_blend)
-static const char WeightusvARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glWeightusvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_fog_coord)
-static const char FogCoordPointerEXT_names[] =
-    "iip\0" /* Parameter signature */
-    "glFogCoordPointer\0"
-    "glFogCoordPointerEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_index_material)
-static const char IndexMaterialEXT_names[] =
-    "ii\0" /* Parameter signature */
-    "glIndexMaterialEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
-static const char SecondaryColor3ubvEXT_names[] =
-    "p\0" /* Parameter signature */
-    "glSecondaryColor3ubv\0"
-    "glSecondaryColor3ubvEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib4dvARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib4dv\0"
-    "glVertexAttrib4dvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_shader)
-static const char BindAttribLocationARB_names[] =
-    "iip\0" /* Parameter signature */
-    "glBindAttribLocation\0"
-    "glBindAttribLocationARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char MultiTexCoord2dARB_names[] =
-    "idd\0" /* Parameter signature */
-    "glMultiTexCoord2d\0"
-    "glMultiTexCoord2dARB\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char ExecuteProgramNV_names[] =
-    "iip\0" /* Parameter signature */
-    "glExecuteProgramNV\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_fragment_lighting)
-static const char LightEnviSGIX_names[] =
-    "ii\0" /* Parameter signature */
-    "glLightEnviSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_triangle_list)
-static const char ReplacementCodeuiSUN_names[] =
-    "i\0" /* Parameter signature */
-    "glReplacementCodeuiSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttribPointerNV_names[] =
-    "iiiip\0" /* Parameter signature */
-    "glVertexAttribPointerNV\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_framebuffer_object) || defined(need_GL_EXT_framebuffer_object)
-static const char GetFramebufferAttachmentParameterivEXT_names[] =
-    "iiip\0" /* Parameter signature */
-    "glGetFramebufferAttachmentParameteriv\0"
-    "glGetFramebufferAttachmentParameterivEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_pixel_transform)
-static const char PixelTransformParameterfEXT_names[] =
-    "iif\0" /* Parameter signature */
-    "glPixelTransformParameterfEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char MultiTexCoord4dvARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glMultiTexCoord4dv\0"
-    "glMultiTexCoord4dvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_pixel_transform)
-static const char PixelTransformParameteriEXT_names[] =
-    "iii\0" /* Parameter signature */
-    "glPixelTransformParameteriEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char TexCoord2fColor4ubVertex3fSUN_names[] =
-    "ffiiiifff\0" /* Parameter signature */
-    "glTexCoord2fColor4ubVertex3fSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_shader_objects)
-static const char Uniform1iARB_names[] =
-    "ii\0" /* Parameter signature */
-    "glUniform1i\0"
-    "glUniform1iARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttribPointerARB_names[] =
-    "iiiiip\0" /* Parameter signature */
-    "glVertexAttribPointer\0"
-    "glVertexAttribPointerARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIS_sharpen_texture)
-static const char SharpenTexFuncSGIS_names[] =
-    "iip\0" /* Parameter signature */
-    "glSharpenTexFuncSGIS\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char MultiTexCoord4fvARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glMultiTexCoord4fv\0"
-    "glMultiTexCoord4fvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_1)
-static const char UniformMatrix2x3fv_names[] =
-    "iiip\0" /* Parameter signature */
-    "glUniformMatrix2x3fv\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char TrackMatrixNV_names[] =
-    "iiii\0" /* Parameter signature */
-    "glTrackMatrixNV\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_register_combiners)
-static const char CombinerParameteriNV_names[] =
-    "ii\0" /* Parameter signature */
-    "glCombinerParameteriNV\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_async)
-static const char DeleteAsyncMarkersSGIX_names[] =
-    "ii\0" /* Parameter signature */
-    "glDeleteAsyncMarkersSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_async)
-static const char IsAsyncMarkerSGIX_names[] =
-    "i\0" /* Parameter signature */
-    "glIsAsyncMarkerSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_framezoom)
-static const char FrameZoomSGIX_names[] =
-    "i\0" /* Parameter signature */
-    "glFrameZoomSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char Normal3fVertex3fvSUN_names[] =
-    "pp\0" /* Parameter signature */
-    "glNormal3fVertex3fvSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib4NsvARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib4Nsv\0"
-    "glVertexAttrib4NsvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib3fvARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib3fv\0"
-    "glVertexAttrib3fvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_sync)
-static const char GetSynciv_names[] =
-    "iiipp\0" /* Parameter signature */
-    "glGetSynciv\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_framebuffer_object) || defined(need_GL_EXT_framebuffer_object)
-static const char DeleteFramebuffersEXT_names[] =
-    "ip\0" /* Parameter signature */
-    "glDeleteFramebuffers\0"
-    "glDeleteFramebuffersEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_global_alpha)
-static const char GlobalAlphaFactorsSUN_names[] =
-    "i\0" /* Parameter signature */
-    "glGlobalAlphaFactorsSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_texture3D)
-static const char TexSubImage3D_names[] =
-    "iiiiiiiiiip\0" /* Parameter signature */
-    "glTexSubImage3D\0"
-    "glTexSubImage3DEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_coordinate_frame)
-static const char Tangent3fEXT_names[] =
-    "fff\0" /* Parameter signature */
-    "glTangent3fEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
-static const char SecondaryColor3uivEXT_names[] =
-    "p\0" /* Parameter signature */
-    "glSecondaryColor3uiv\0"
-    "glSecondaryColor3uivEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_matrix_palette)
-static const char MatrixIndexubvARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glMatrixIndexubvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char Color4fNormal3fVertex3fSUN_names[] =
-    "ffffffffff\0" /* Parameter signature */
-    "glColor4fNormal3fVertex3fSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIS_pixel_texture)
-static const char PixelTexGenParameterfSGIS_names[] =
-    "if\0" /* Parameter signature */
-    "glPixelTexGenParameterfSGIS\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0)
-static const char CreateShader_names[] =
-    "i\0" /* Parameter signature */
-    "glCreateShader\0"
-    "";
-#endif
-
-#if defined(need_GL_SGI_color_table) || defined(need_GL_EXT_paletted_texture)
-static const char GetColorTableParameterfv_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetColorTableParameterfv\0"
-    "glGetColorTableParameterfvSGI\0"
-    "glGetColorTableParameterfvEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_fragment_lighting)
-static const char FragmentLightModelfvSGIX_names[] =
-    "ip\0" /* Parameter signature */
-    "glFragmentLightModelfvSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char MultiTexCoord3fARB_names[] =
-    "ifff\0" /* Parameter signature */
-    "glMultiTexCoord3f\0"
-    "glMultiTexCoord3fARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIS_pixel_texture)
-static const char GetPixelTexGenParameterfvSGIS_names[] =
-    "ip\0" /* Parameter signature */
-    "glGetPixelTexGenParameterfvSGIS\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_framebuffer_object) || defined(need_GL_EXT_framebuffer_object)
-static const char GenFramebuffersEXT_names[] =
-    "ip\0" /* Parameter signature */
-    "glGenFramebuffers\0"
-    "glGenFramebuffersEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char GetProgramParameterdvNV_names[] =
-    "iiip\0" /* Parameter signature */
-    "glGetProgramParameterdvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_array_object) || defined(need_GL_APPLE_vertex_array_object)
-static const char IsVertexArrayAPPLE_names[] =
-    "i\0" /* Parameter signature */
-    "glIsVertexArray\0"
-    "glIsVertexArrayAPPLE\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_fragment_lighting)
-static const char FragmentLightfvSGIX_names[] =
-    "iip\0" /* Parameter signature */
-    "glFragmentLightfvSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0)
-static const char DetachShader_names[] =
-    "ii\0" /* Parameter signature */
-    "glDetachShader\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib4NubARB_names[] =
-    "iiiii\0" /* Parameter signature */
-    "glVertexAttrib4Nub\0"
-    "glVertexAttrib4NubARB\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_program)
-static const char GetProgramEnvParameterfvARB_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetProgramEnvParameterfvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char GetTrackMatrixivNV_names[] =
-    "iiip\0" /* Parameter signature */
-    "glGetTrackMatrixivNV\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttrib3svNV_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib3svNV\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_shader_objects)
-static const char Uniform4fvARB_names[] =
-    "iip\0" /* Parameter signature */
-    "glUniform4fv\0"
-    "glUniform4fvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3) || defined(need_GL_ARB_transpose_matrix)
-static const char MultTransposeMatrixfARB_names[] =
-    "p\0" /* Parameter signature */
-    "glMultTransposeMatrixf\0"
-    "glMultTransposeMatrixfARB\0"
-    "";
-#endif
-
-#if defined(need_GL_ATI_fragment_shader)
-static const char ColorFragmentOp1ATI_names[] =
-    "iiiiiii\0" /* Parameter signature */
-    "glColorFragmentOp1ATI\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_shader_objects)
-static const char GetUniformfvARB_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetUniformfv\0"
-    "glGetUniformfvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN_names[] =
-    "iffffffffffff\0" /* Parameter signature */
-    "glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_shader_objects)
-static const char DetachObjectARB_names[] =
-    "ii\0" /* Parameter signature */
-    "glDetachObjectARB\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_blend)
-static const char VertexBlendARB_names[] =
-    "i\0" /* Parameter signature */
-    "glVertexBlendARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_window_pos) || defined(need_GL_MESA_window_pos)
-static const char WindowPos3iMESA_names[] =
-    "iii\0" /* Parameter signature */
-    "glWindowPos3i\0"
-    "glWindowPos3iARB\0"
-    "glWindowPos3iMESA\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_convolution)
-static const char SeparableFilter2D_names[] =
-    "iiiiiipp\0" /* Parameter signature */
-    "glSeparableFilter2D\0"
-    "glSeparableFilter2DEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char ReplacementCodeuiColor4ubVertex3fvSUN_names[] =
-    "ppp\0" /* Parameter signature */
-    "glReplacementCodeuiColor4ubVertex3fvSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3) || defined(need_GL_ARB_texture_compression)
-static const char CompressedTexImage2DARB_names[] =
-    "iiiiiiip\0" /* Parameter signature */
-    "glCompressedTexImage2D\0"
-    "glCompressedTexImage2DARB\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_vertex_array)
-static const char ArrayElement_names[] =
-    "i\0" /* Parameter signature */
-    "glArrayElement\0"
-    "glArrayElementEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_depth_bounds_test)
-static const char DepthBoundsEXT_names[] =
-    "dd\0" /* Parameter signature */
-    "glDepthBoundsEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char ProgramParameters4fvNV_names[] =
-    "iiip\0" /* Parameter signature */
-    "glProgramParameters4fvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_polynomial_ffd)
-static const char DeformationMap3fSGIX_names[] =
-    "iffiiffiiffiip\0" /* Parameter signature */
-    "glDeformationMap3fSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char GetProgramivNV_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetProgramivNV\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_histogram)
-static const char GetMinmaxParameteriv_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetMinmaxParameteriv\0"
-    "glGetMinmaxParameterivEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_copy_texture)
-static const char CopyTexImage1D_names[] =
-    "iiiiiii\0" /* Parameter signature */
-    "glCopyTexImage1D\0"
-    "glCopyTexImage1DEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_ATI_fragment_shader)
-static const char AlphaFragmentOp3ATI_names[] =
-    "iiiiiiiiiiii\0" /* Parameter signature */
-    "glAlphaFragmentOp3ATI\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char GetVertexAttribdvNV_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetVertexAttribdvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttrib3fvNV_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib3fvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_register_combiners)
-static const char GetFinalCombinerInputParameterivNV_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetFinalCombinerInputParameterivNV\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_evaluators)
-static const char GetMapParameterivNV_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetMapParameterivNV\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_shader_objects)
-static const char Uniform4iARB_names[] =
-    "iiiii\0" /* Parameter signature */
-    "glUniform4i\0"
-    "glUniform4iARB\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_convolution)
-static const char ConvolutionParameteri_names[] =
-    "iii\0" /* Parameter signature */
-    "glConvolutionParameteri\0"
-    "glConvolutionParameteriEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_coordinate_frame)
-static const char Binormal3sEXT_names[] =
-    "iii\0" /* Parameter signature */
-    "glBinormal3sEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_convolution)
-static const char ConvolutionParameterf_names[] =
-    "iif\0" /* Parameter signature */
-    "glConvolutionParameterf\0"
-    "glConvolutionParameterfEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SGI_color_table) || defined(need_GL_EXT_paletted_texture)
-static const char GetColorTableParameteriv_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetColorTableParameteriv\0"
-    "glGetColorTableParameterivSGI\0"
-    "glGetColorTableParameterivEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_program) || defined(need_GL_NV_vertex_program)
-static const char ProgramEnvParameter4dvARB_names[] =
-    "iip\0" /* Parameter signature */
-    "glProgramEnvParameter4dvARB\0"
-    "glProgramParameter4dvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttribs2fvNV_names[] =
-    "iip\0" /* Parameter signature */
-    "glVertexAttribs2fvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_shader_objects)
-static const char UseProgramObjectARB_names[] =
-    "i\0" /* Parameter signature */
-    "glUseProgram\0"
-    "glUseProgramObjectARB\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_evaluators)
-static const char GetMapParameterfvNV_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetMapParameterfvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_ATI_fragment_shader)
-static const char PassTexCoordATI_names[] =
-    "iii\0" /* Parameter signature */
-    "glPassTexCoordATI\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0)
-static const char DeleteProgram_names[] =
-    "i\0" /* Parameter signature */
-    "glDeleteProgram\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_coordinate_frame)
-static const char Tangent3ivEXT_names[] =
-    "p\0" /* Parameter signature */
-    "glTangent3ivEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_coordinate_frame)
-static const char Tangent3dEXT_names[] =
-    "ddd\0" /* Parameter signature */
-    "glTangent3dEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
-static const char SecondaryColor3dvEXT_names[] =
-    "p\0" /* Parameter signature */
-    "glSecondaryColor3dv\0"
-    "glSecondaryColor3dvEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_multi_draw_arrays)
-static const char MultiDrawArraysEXT_names[] =
-    "ippi\0" /* Parameter signature */
-    "glMultiDrawArrays\0"
-    "glMultiDrawArraysEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_framebuffer_object) || defined(need_GL_EXT_framebuffer_object)
-static const char BindRenderbufferEXT_names[] =
-    "ii\0" /* Parameter signature */
-    "glBindRenderbuffer\0"
-    "glBindRenderbufferEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char MultiTexCoord4dARB_names[] =
-    "idddd\0" /* Parameter signature */
-    "glMultiTexCoord4d\0"
-    "glMultiTexCoord4dARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
-static const char SecondaryColor3usEXT_names[] =
-    "iii\0" /* Parameter signature */
-    "glSecondaryColor3us\0"
-    "glSecondaryColor3usEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_program)
-static const char ProgramLocalParameter4fvARB_names[] =
-    "iip\0" /* Parameter signature */
-    "glProgramLocalParameter4fvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_program) || defined(need_GL_NV_vertex_program)
-static const char DeleteProgramsNV_names[] =
-    "ip\0" /* Parameter signature */
-    "glDeleteProgramsARB\0"
-    "glDeleteProgramsNV\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char MultiTexCoord1sARB_names[] =
-    "ii\0" /* Parameter signature */
-    "glMultiTexCoord1s\0"
-    "glMultiTexCoord1sARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char ReplacementCodeuiColor3fVertex3fSUN_names[] =
-    "iffffff\0" /* Parameter signature */
-    "glReplacementCodeuiColor3fVertex3fSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program) || defined(need_GL_NV_vertex_program)
-static const char GetVertexAttribPointervNV_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetVertexAttribPointerv\0"
-    "glGetVertexAttribPointervARB\0"
-    "glGetVertexAttribPointervNV\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char MultiTexCoord1dvARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glMultiTexCoord1dv\0"
-    "glMultiTexCoord1dvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_shader_objects)
-static const char Uniform2iARB_names[] =
-    "iii\0" /* Parameter signature */
-    "glUniform2i\0"
-    "glUniform2iARB\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char GetProgramStringNV_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetProgramStringNV\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_vertex_array)
-static const char ColorPointerEXT_names[] =
-    "iiiip\0" /* Parameter signature */
-    "glColorPointerEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_vertex_buffer_object)
-static const char MapBufferARB_names[] =
-    "ii\0" /* Parameter signature */
-    "glMapBuffer\0"
-    "glMapBufferARB\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_draw_elements_base_vertex)
-static const char MultiDrawElementsBaseVertex_names[] =
-    "ipipip\0" /* Parameter signature */
-    "glMultiDrawElementsBaseVertex\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_coordinate_frame)
-static const char Binormal3svEXT_names[] =
-    "p\0" /* Parameter signature */
-    "glBinormal3svEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_light_texture)
-static const char ApplyTextureEXT_names[] =
-    "i\0" /* Parameter signature */
-    "glApplyTextureEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_light_texture)
-static const char TextureMaterialEXT_names[] =
-    "ii\0" /* Parameter signature */
-    "glTextureMaterialEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_light_texture)
-static const char TextureLightEXT_names[] =
-    "i\0" /* Parameter signature */
-    "glTextureLightEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_histogram)
-static const char ResetMinmax_names[] =
-    "i\0" /* Parameter signature */
-    "glResetMinmax\0"
-    "glResetMinmaxEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_sprite)
-static const char SpriteParameterfSGIX_names[] =
-    "if\0" /* Parameter signature */
-    "glSpriteParameterfSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttrib4sNV_names[] =
-    "iiiii\0" /* Parameter signature */
-    "glVertexAttrib4sNV\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_convolution)
-static const char GetConvolutionParameterfv_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetConvolutionParameterfv\0"
-    "glGetConvolutionParameterfvEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttribs4dvNV_names[] =
-    "iip\0" /* Parameter signature */
-    "glVertexAttribs4dvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_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 */
-    "glVertexAttrib4d\0"
-    "glVertexAttrib4dARB\0"
-    "";
-#endif
-
-#if defined(need_GL_ATI_envmap_bumpmap)
-static const char GetTexBumpParameterfvATI_names[] =
-    "ip\0" /* Parameter signature */
-    "glGetTexBumpParameterfvATI\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_fragment_program)
-static const char ProgramNamedParameter4dNV_names[] =
-    "iipdddd\0" /* Parameter signature */
-    "glProgramNamedParameter4dNV\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_vertex_weighting)
-static const char VertexWeightfEXT_names[] =
-    "f\0" /* Parameter signature */
-    "glVertexWeightfEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_coordinate_frame)
-static const char Binormal3fEXT_names[] =
-    "fff\0" /* Parameter signature */
-    "glBinormal3fEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_fog_coord)
-static const char FogCoordfvEXT_names[] =
-    "p\0" /* Parameter signature */
-    "glFogCoordfv\0"
-    "glFogCoordfvEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char MultiTexCoord1ivARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glMultiTexCoord1iv\0"
-    "glMultiTexCoord1ivARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
-static const char SecondaryColor3ubEXT_names[] =
-    "iii\0" /* Parameter signature */
-    "glSecondaryColor3ub\0"
-    "glSecondaryColor3ubEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char MultiTexCoord2ivARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glMultiTexCoord2iv\0"
-    "glMultiTexCoord2ivARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIS_fog_function)
-static const char FogFuncSGIS_names[] =
-    "ip\0" /* Parameter signature */
-    "glFogFuncSGIS\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_copy_texture)
-static const char CopyTexSubImage2D_names[] =
-    "iiiiiiii\0" /* Parameter signature */
-    "glCopyTexSubImage2D\0"
-    "glCopyTexSubImage2DEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_shader_objects)
-static const char GetObjectParameterivARB_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetObjectParameterivARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char TexCoord4fVertex4fSUN_names[] =
-    "ffffffff\0" /* Parameter signature */
-    "glTexCoord4fVertex4fSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_APPLE_vertex_array_object)
-static const char BindVertexArrayAPPLE_names[] =
-    "i\0" /* Parameter signature */
-    "glBindVertexArrayAPPLE\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_program)
-static const char GetProgramLocalParameterdvARB_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetProgramLocalParameterdvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_histogram)
-static const char GetHistogramParameteriv_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetHistogramParameteriv\0"
-    "glGetHistogramParameterivEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char MultiTexCoord1iARB_names[] =
-    "ii\0" /* Parameter signature */
-    "glMultiTexCoord1i\0"
-    "glMultiTexCoord1iARB\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_convolution)
-static const char GetConvolutionFilter_names[] =
-    "iiip\0" /* Parameter signature */
-    "glGetConvolutionFilter\0"
-    "glGetConvolutionFilterEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_program)
-static const char GetProgramivARB_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetProgramivARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_blend_func_separate) || defined(need_GL_INGR_blend_func_separate)
-static const char BlendFuncSeparateEXT_names[] =
-    "iiii\0" /* Parameter signature */
-    "glBlendFuncSeparate\0"
-    "glBlendFuncSeparateEXT\0"
-    "glBlendFuncSeparateINGR\0"
-    "";
-#endif
-
-#if defined(need_GL_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 */
-    "glProgramParameters4dvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char TexCoord2fColor3fVertex3fvSUN_names[] =
-    "ppp\0" /* Parameter signature */
-    "glTexCoord2fColor3fVertex3fvSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_coordinate_frame)
-static const char Binormal3dvEXT_names[] =
-    "p\0" /* Parameter signature */
-    "glBinormal3dvEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_fence)
-static const char FinishFenceNV_names[] =
-    "i\0" /* Parameter signature */
-    "glFinishFenceNV\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIS_fog_function)
-static const char GetFogFuncSGIS_names[] =
-    "p\0" /* Parameter signature */
-    "glGetFogFuncSGIS\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_shader_objects)
-static const char GetUniformLocationARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glGetUniformLocation\0"
-    "glGetUniformLocationARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
-static const char SecondaryColor3fEXT_names[] =
-    "fff\0" /* Parameter signature */
-    "glSecondaryColor3f\0"
-    "glSecondaryColor3fEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_register_combiners)
-static const char CombinerInputNV_names[] =
-    "iiiiii\0" /* Parameter signature */
-    "glCombinerInputNV\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib3sARB_names[] =
-    "iiii\0" /* Parameter signature */
-    "glVertexAttrib3s\0"
-    "glVertexAttrib3sARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char ReplacementCodeuiNormal3fVertex3fvSUN_names[] =
-    "ppp\0" /* Parameter signature */
-    "glReplacementCodeuiNormal3fVertex3fvSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_program)
-static const char ProgramStringARB_names[] =
-    "iiip\0" /* Parameter signature */
-    "glProgramStringARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char TexCoord4fVertex4fvSUN_names[] =
-    "pp\0" /* Parameter signature */
-    "glTexCoord4fVertex4fvSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttrib3sNV_names[] =
-    "iiii\0" /* Parameter signature */
-    "glVertexAttrib3sNV\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttrib1fNV_names[] =
-    "if\0" /* Parameter signature */
-    "glVertexAttrib1fNV\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_fragment_lighting)
-static const char FragmentLightfSGIX_names[] =
-    "iif\0" /* Parameter signature */
-    "glFragmentLightfSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3) || defined(need_GL_ARB_texture_compression)
-static const char GetCompressedTexImageARB_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetCompressedTexImage\0"
-    "glGetCompressedTexImageARB\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_vertex_weighting)
-static const char VertexWeightPointerEXT_names[] =
-    "iiip\0" /* Parameter signature */
-    "glVertexWeightPointerEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_histogram)
-static const char GetHistogram_names[] =
-    "iiiip\0" /* Parameter signature */
-    "glGetHistogram\0"
-    "glGetHistogramEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_stencil_two_side)
-static const char ActiveStencilFaceEXT_names[] =
-    "i\0" /* Parameter signature */
-    "glActiveStencilFaceEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_ATI_separate_stencil)
-static const char StencilFuncSeparateATI_names[] =
-    "iiii\0" /* Parameter signature */
-    "glStencilFuncSeparateATI\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_shader_objects)
-static const char GetShaderSourceARB_names[] =
-    "iipp\0" /* Parameter signature */
-    "glGetShaderSource\0"
-    "glGetShaderSourceARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_igloo_interface)
-static const char IglooInterfaceSGIX_names[] =
-    "ip\0" /* Parameter signature */
-    "glIglooInterfaceSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttrib4dNV_names[] =
-    "idddd\0" /* Parameter signature */
-    "glVertexAttrib4dNV\0"
-    "";
-#endif
-
-#if defined(need_GL_IBM_multimode_draw_arrays)
-static const char MultiModeDrawElementsIBM_names[] =
-    "ppipii\0" /* Parameter signature */
-    "glMultiModeDrawElementsIBM\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char MultiTexCoord4svARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glMultiTexCoord4sv\0"
-    "glMultiTexCoord4svARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_occlusion_query)
-static const char GenQueriesARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glGenQueries\0"
-    "glGenQueriesARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const char ReplacementCodeuiVertex3fSUN_names[] =
-    "ifff\0" /* Parameter signature */
-    "glReplacementCodeuiVertex3fSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_coordinate_frame)
-static const char Tangent3iEXT_names[] =
-    "iii\0" /* Parameter signature */
-    "glTangent3iEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_mesh_array)
-static const char DrawMeshArraysSUN_names[] =
-    "iiii\0" /* Parameter signature */
-    "glDrawMeshArraysSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_sync)
-static const char IsSync_names[] =
-    "i\0" /* Parameter signature */
-    "glIsSync\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_evaluators)
-static const char GetMapControlPointsNV_names[] =
-    "iiiiiip\0" /* Parameter signature */
-    "glGetMapControlPointsNV\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_draw_buffers) || defined(need_GL_ATI_draw_buffers)
-static const char DrawBuffersARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glDrawBuffers\0"
-    "glDrawBuffersARB\0"
-    "glDrawBuffersATI\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_program)
-static const char ProgramLocalParameter4fARB_names[] =
-    "iiffff\0" /* Parameter signature */
-    "glProgramLocalParameter4fARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_sprite)
-static const char SpriteParameterivSGIX_names[] =
-    "ip\0" /* Parameter signature */
-    "glSpriteParameterivSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_provoking_vertex) || defined(need_GL_ARB_provoking_vertex)
-static const char ProvokingVertexEXT_names[] =
-    "i\0" /* Parameter signature */
-    "glProvokingVertexEXT\0"
-    "glProvokingVertex\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char MultiTexCoord1fARB_names[] =
-    "if\0" /* Parameter signature */
-    "glMultiTexCoord1f\0"
-    "glMultiTexCoord1fARB\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttribs4ubvNV_names[] =
-    "iip\0" /* Parameter signature */
-    "glVertexAttribs4ubvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_blend)
-static const char WeightsvARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glWeightsvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_shader_objects)
-static const char Uniform1fvARB_names[] =
-    "iip\0" /* Parameter signature */
-    "glUniform1fv\0"
-    "glUniform1fvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_copy_texture)
-static const char CopyTexSubImage1D_names[] =
-    "iiiiii\0" /* Parameter signature */
-    "glCopyTexSubImage1D\0"
-    "glCopyTexSubImage1DEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_texture_object)
-static const char BindTexture_names[] =
-    "ii\0" /* Parameter signature */
-    "glBindTexture\0"
-    "glBindTextureEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_ATI_fragment_shader)
-static const char BeginFragmentShaderATI_names[] =
-    "\0" /* Parameter signature */
-    "glBeginFragmentShaderATI\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char MultiTexCoord4fARB_names[] =
-    "iffff\0" /* Parameter signature */
-    "glMultiTexCoord4f\0"
-    "glMultiTexCoord4fARB\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttribs3svNV_names[] =
-    "iip\0" /* Parameter signature */
-    "glVertexAttribs3svNV\0"
-    "";
-#endif
-
-#if defined(need_GL_SUN_triangle_list)
-static const char ReplacementCodeuivSUN_names[] =
-    "p\0" /* Parameter signature */
-    "glReplacementCodeuivSUN\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char EnableVertexAttribArrayARB_names[] =
-    "i\0" /* Parameter signature */
-    "glEnableVertexAttribArray\0"
-    "glEnableVertexAttribArrayARB\0"
-    "";
-#endif
-
-#if defined(need_GL_INTEL_parallel_arrays)
-static const char NormalPointervINTEL_names[] =
-    "ip\0" /* Parameter signature */
-    "glNormalPointervINTEL\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_convolution)
-static const char CopyConvolutionFilter2D_names[] =
-    "iiiiii\0" /* Parameter signature */
-    "glCopyConvolutionFilter2D\0"
-    "glCopyConvolutionFilter2DEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_window_pos) || defined(need_GL_MESA_window_pos)
-static const char WindowPos3ivMESA_names[] =
-    "p\0" /* Parameter signature */
-    "glWindowPos3iv\0"
-    "glWindowPos3ivARB\0"
-    "glWindowPos3ivMESA\0"
-    "";
-#endif
-
-#if defined(need_GL_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 */
-    "glIsBuffer\0"
-    "glIsBufferARB\0"
-    "";
-#endif
-
-#if defined(need_GL_MESA_window_pos)
-static const char WindowPos4iMESA_names[] =
-    "iiii\0" /* Parameter signature */
-    "glWindowPos4iMESA\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib4uivARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib4uiv\0"
-    "glVertexAttrib4uivARB\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_coordinate_frame)
-static const char Tangent3bvEXT_names[] =
-    "p\0" /* Parameter signature */
-    "glTangent3bvEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_1)
-static const char UniformMatrix3x4fv_names[] =
-    "iiip\0" /* Parameter signature */
-    "glUniformMatrix3x4fv\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_draw_elements_base_vertex)
-static const char DrawRangeElementsBaseVertex_names[] =
-    "iiiiipi\0" /* Parameter signature */
-    "glDrawRangeElementsBaseVertex\0"
-    "";
-#endif
-
-#if defined(need_GL_INTEL_parallel_arrays)
-static const char TexCoordPointervINTEL_names[] =
-    "iip\0" /* Parameter signature */
-    "glTexCoordPointervINTEL\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_vertex_buffer_object)
-static const char DeleteBuffersARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glDeleteBuffers\0"
-    "glDeleteBuffersARB\0"
-    "";
-#endif
-
-#if defined(need_GL_MESA_window_pos)
-static const char WindowPos4fvMESA_names[] =
-    "p\0" /* Parameter signature */
-    "glWindowPos4fvMESA\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttrib1sNV_names[] =
-    "ii\0" /* Parameter signature */
-    "glVertexAttrib1sNV\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
-static const char SecondaryColor3svEXT_names[] =
-    "p\0" /* Parameter signature */
-    "glSecondaryColor3sv\0"
-    "glSecondaryColor3svEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3) || defined(need_GL_ARB_transpose_matrix)
-static const char LoadTransposeMatrixfARB_names[] =
-    "p\0" /* Parameter signature */
-    "glLoadTransposeMatrixf\0"
-    "glLoadTransposeMatrixfARB\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_vertex_array)
-static const char GetPointerv_names[] =
-    "ip\0" /* Parameter signature */
-    "glGetPointerv\0"
-    "glGetPointervEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_coordinate_frame)
-static const char Tangent3bEXT_names[] =
-    "iii\0" /* Parameter signature */
-    "glTangent3bEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_register_combiners)
-static const char CombinerParameterfNV_names[] =
-    "if\0" /* Parameter signature */
-    "glCombinerParameterfNV\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_program) || defined(need_GL_NV_vertex_program)
-static const char BindProgramNV_names[] =
-    "ii\0" /* Parameter signature */
-    "glBindProgramARB\0"
-    "glBindProgramNV\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib4svARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib4sv\0"
-    "glVertexAttrib4svARB\0"
-    "";
-#endif
-
-#if defined(need_GL_MESA_shader_debug)
-static const char CreateDebugObjectMESA_names[] =
-    "\0" /* Parameter signature */
-    "glCreateDebugObjectMESA\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0)
-static const char GetShaderiv_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetShaderiv\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_sync)
-static const char ClientWaitSync_names[] =
-    "iii\0" /* Parameter signature */
-    "glClientWaitSync\0"
-    "";
-#endif
-
-#if defined(need_GL_ATI_fragment_shader)
-static const char BindFragmentShaderATI_names[] =
-    "i\0" /* Parameter signature */
-    "glBindFragmentShaderATI\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_vertex_buffer_object)
-static const char UnmapBufferARB_names[] =
-    "i\0" /* Parameter signature */
-    "glUnmapBuffer\0"
-    "glUnmapBufferARB\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_histogram)
-static const char Minmax_names[] =
-    "iii\0" /* Parameter signature */
-    "glMinmax\0"
-    "glMinmaxEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_fog_coord)
-static const char FogCoorddvEXT_names[] =
-    "p\0" /* Parameter signature */
-    "glFogCoorddv\0"
-    "glFogCoorddvEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SUNX_constant_data)
-static const char FinishTextureSUNX_names[] =
-    "\0" /* Parameter signature */
-    "glFinishTextureSUNX\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_fragment_lighting)
-static const char GetFragmentLightfvSGIX_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetFragmentLightfvSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_coordinate_frame)
-static const char Binormal3fvEXT_names[] =
-    "p\0" /* Parameter signature */
-    "glBinormal3fvEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_ATI_fragment_shader)
-static const char ColorFragmentOp3ATI_names[] =
-    "iiiiiiiiiiiii\0" /* Parameter signature */
-    "glColorFragmentOp3ATI\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib2svARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib2sv\0"
-    "glVertexAttrib2svARB\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char AreProgramsResidentNV_names[] =
-    "ipp\0" /* Parameter signature */
-    "glAreProgramsResidentNV\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_window_pos) || defined(need_GL_MESA_window_pos)
-static const char WindowPos3svMESA_names[] =
-    "p\0" /* Parameter signature */
-    "glWindowPos3sv\0"
-    "glWindowPos3svARB\0"
-    "glWindowPos3svMESA\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_color_subtable)
-static const char CopyColorSubTable_names[] =
-    "iiiii\0" /* Parameter signature */
-    "glCopyColorSubTable\0"
-    "glCopyColorSubTableEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_blend)
-static const char WeightdvARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glWeightdvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_framebuffer_object) || defined(need_GL_EXT_framebuffer_object)
-static const char DeleteRenderbuffersEXT_names[] =
-    "ip\0" /* Parameter signature */
-    "glDeleteRenderbuffers\0"
-    "glDeleteRenderbuffersEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib4NubvARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib4Nubv\0"
-    "glVertexAttrib4NubvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttrib3dvNV_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib3dvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_shader_objects)
-static const char GetObjectParameterfvARB_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetObjectParameterfvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_program)
-static const char GetProgramEnvParameterdvARB_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetProgramEnvParameterdvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_compiled_vertex_array)
-static const char LockArraysEXT_names[] =
-    "ii\0" /* Parameter signature */
-    "glLockArraysEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_pixel_transform)
-static const char PixelTransformParameterivEXT_names[] =
-    "iip\0" /* Parameter signature */
-    "glPixelTransformParameterivEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_coordinate_frame)
-static const char BinormalPointerEXT_names[] =
-    "iip\0" /* Parameter signature */
-    "glBinormalPointerEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttrib1dNV_names[] =
-    "id\0" /* Parameter signature */
-    "glVertexAttrib1dNV\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_register_combiners)
-static const char GetCombinerInputParameterivNV_names[] =
-    "iiiip\0" /* Parameter signature */
-    "glGetCombinerInputParameterivNV\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const char MultiTexCoord2fvARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glMultiTexCoord2fv\0"
-    "glMultiTexCoord2fvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_framebuffer_object) || defined(need_GL_EXT_framebuffer_object)
-static const char GetRenderbufferParameterivEXT_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetRenderbufferParameteriv\0"
-    "glGetRenderbufferParameterivEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_register_combiners)
-static const char CombinerParameterivNV_names[] =
-    "ip\0" /* Parameter signature */
-    "glCombinerParameterivNV\0"
-    "";
-#endif
-
-#if defined(need_GL_ATI_fragment_shader)
-static const char GenFragmentShadersATI_names[] =
-    "i\0" /* Parameter signature */
-    "glGenFragmentShadersATI\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_vertex_array)
-static const char DrawArrays_names[] =
-    "iii\0" /* Parameter signature */
-    "glDrawArrays\0"
-    "glDrawArraysEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_blend)
-static const char WeightuivARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glWeightuivARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib2sARB_names[] =
-    "iii\0" /* Parameter signature */
-    "glVertexAttrib2s\0"
-    "glVertexAttrib2sARB\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_async)
-static const char GenAsyncMarkersSGIX_names[] =
-    "i\0" /* Parameter signature */
-    "glGenAsyncMarkersSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_coordinate_frame)
-static const char Tangent3svEXT_names[] =
-    "p\0" /* Parameter signature */
-    "glTangent3svEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_list_priority)
-static const char GetListParameterivSGIX_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetListParameterivSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_vertex_buffer_object)
-static const char BindBufferARB_names[] =
-    "ii\0" /* Parameter signature */
-    "glBindBuffer\0"
-    "glBindBufferARB\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_shader_objects)
-static const char GetInfoLogARB_names[] =
-    "iipp\0" /* Parameter signature */
-    "glGetInfoLogARB\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttribs4svNV_names[] =
-    "iip\0" /* Parameter signature */
-    "glVertexAttribs4svNV\0"
-    "";
-#endif
-
-#if defined(need_GL_IBM_vertex_array_lists)
-static const char EdgeFlagPointerListIBM_names[] =
-    "ipi\0" /* Parameter signature */
-    "glEdgeFlagPointerListIBM\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_1)
-static const char UniformMatrix3x2fv_names[] =
-    "iiip\0" /* Parameter signature */
-    "glUniformMatrix3x2fv\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_histogram)
-static const char GetMinmaxParameterfv_names[] =
-    "iip\0" /* Parameter signature */
-    "glGetMinmaxParameterfv\0"
-    "glGetMinmaxParameterfvEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
-static const char VertexAttrib1fvARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib1fv\0"
-    "glVertexAttrib1fvARB\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_vertex_buffer_object)
-static const char GenBuffersARB_names[] =
-    "ip\0" /* Parameter signature */
-    "glGenBuffers\0"
-    "glGenBuffersARB\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttribs1svNV_names[] =
-    "iip\0" /* Parameter signature */
-    "glVertexAttribs1svNV\0"
-    "";
-#endif
-
-#if defined(need_GL_ATI_envmap_bumpmap)
-static const char GetTexBumpParameterivATI_names[] =
-    "ip\0" /* Parameter signature */
-    "glGetTexBumpParameterivATI\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_coordinate_frame)
-static const char Binormal3bEXT_names[] =
-    "iii\0" /* Parameter signature */
-    "glBinormal3bEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_SGIX_fragment_lighting)
-static const char FragmentMaterialivSGIX_names[] =
-    "iip\0" /* Parameter signature */
-    "glFragmentMaterialivSGIX\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_framebuffer_object) || defined(need_GL_EXT_framebuffer_object)
-static const char IsRenderbufferEXT_names[] =
-    "i\0" /* Parameter signature */
-    "glIsRenderbuffer\0"
-    "glIsRenderbufferEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_ARB_vertex_program) || defined(need_GL_NV_vertex_program)
-static const char GenProgramsNV_names[] =
-    "ip\0" /* Parameter signature */
-    "glGenProgramsARB\0"
-    "glGenProgramsNV\0"
-    "";
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const char VertexAttrib4dvNV_names[] =
-    "ip\0" /* Parameter signature */
-    "glVertexAttrib4dvNV\0"
-    "";
-#endif
-
-#if defined(need_GL_ATI_fragment_shader)
-static const char EndFragmentShaderATI_names[] =
-    "\0" /* Parameter signature */
-    "glEndFragmentShaderATI\0"
-    "";
-#endif
-
-#if defined(need_GL_EXT_coordinate_frame)
-static const char Binormal3iEXT_names[] =
-    "iii\0" /* Parameter signature */
-    "glBinormal3iEXT\0"
-    "";
-#endif
-
-#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_window_pos) || defined(need_GL_MESA_window_pos)
-static const char WindowPos2fMESA_names[] =
-    "ff\0" /* Parameter signature */
-    "glWindowPos2f\0"
-    "glWindowPos2fARB\0"
-    "glWindowPos2fMESA\0"
-    "";
-#endif
-
-#if defined(need_GL_3DFX_tbuffer)
-static const struct dri_extension_function GL_3DFX_tbuffer_functions[] = {
-    { TbufferMask3DFX_names, TbufferMask3DFX_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_APPLE_flush_buffer_range)
-static const struct dri_extension_function GL_APPLE_flush_buffer_range_functions[] = {
-    { BufferParameteriAPPLE_names, BufferParameteriAPPLE_remap_index, -1 },
-    { FlushMappedBufferRangeAPPLE_names, FlushMappedBufferRangeAPPLE_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_APPLE_texture_range)
-static const struct dri_extension_function GL_APPLE_texture_range_functions[] = {
-    { TextureRangeAPPLE_names, TextureRangeAPPLE_remap_index, -1 },
-    { GetTexParameterPointervAPPLE_names, GetTexParameterPointervAPPLE_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_APPLE_vertex_array_object)
-static const struct dri_extension_function GL_APPLE_vertex_array_object_functions[] = {
-    { DeleteVertexArraysAPPLE_names, DeleteVertexArraysAPPLE_remap_index, -1 },
-    { GenVertexArraysAPPLE_names, GenVertexArraysAPPLE_remap_index, -1 },
-    { IsVertexArrayAPPLE_names, IsVertexArrayAPPLE_remap_index, -1 },
-    { BindVertexArrayAPPLE_names, BindVertexArrayAPPLE_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#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 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_ARB_draw_elements_base_vertex)
-static const struct dri_extension_function GL_ARB_draw_elements_base_vertex_functions[] = {
-    { DrawElementsBaseVertex_names, DrawElementsBaseVertex_remap_index, -1 },
-    { MultiDrawElementsBaseVertex_names, MultiDrawElementsBaseVertex_remap_index, -1 },
-    { DrawRangeElementsBaseVertex_names, DrawRangeElementsBaseVertex_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_ARB_framebuffer_object)
-static const struct dri_extension_function GL_ARB_framebuffer_object_functions[] = {
-    { BlitFramebufferEXT_names, BlitFramebufferEXT_remap_index, -1 },
-    { FramebufferTextureLayerEXT_names, FramebufferTextureLayerEXT_remap_index, -1 },
-    { GenerateMipmapEXT_names, GenerateMipmapEXT_remap_index, -1 },
-    { RenderbufferStorageEXT_names, RenderbufferStorageEXT_remap_index, -1 },
-    { CheckFramebufferStatusEXT_names, CheckFramebufferStatusEXT_remap_index, -1 },
-    { FramebufferTexture3DEXT_names, FramebufferTexture3DEXT_remap_index, -1 },
-    { FramebufferTexture2DEXT_names, FramebufferTexture2DEXT_remap_index, -1 },
-    { RenderbufferStorageMultisample_names, RenderbufferStorageMultisample_remap_index, -1 },
-    { FramebufferRenderbufferEXT_names, FramebufferRenderbufferEXT_remap_index, -1 },
-    { FramebufferTexture1DEXT_names, FramebufferTexture1DEXT_remap_index, -1 },
-    { BindFramebufferEXT_names, BindFramebufferEXT_remap_index, -1 },
-    { GenRenderbuffersEXT_names, GenRenderbuffersEXT_remap_index, -1 },
-    { IsFramebufferEXT_names, IsFramebufferEXT_remap_index, -1 },
-    { GetFramebufferAttachmentParameterivEXT_names, GetFramebufferAttachmentParameterivEXT_remap_index, -1 },
-    { DeleteFramebuffersEXT_names, DeleteFramebuffersEXT_remap_index, -1 },
-    { GenFramebuffersEXT_names, GenFramebuffersEXT_remap_index, -1 },
-    { BindRenderbufferEXT_names, BindRenderbufferEXT_remap_index, -1 },
-    { DeleteRenderbuffersEXT_names, DeleteRenderbuffersEXT_remap_index, -1 },
-    { GetRenderbufferParameterivEXT_names, GetRenderbufferParameterivEXT_remap_index, -1 },
-    { IsRenderbufferEXT_names, IsRenderbufferEXT_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#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 },
-    { MatrixIndexuivARB_names, MatrixIndexuivARB_remap_index, -1 },
-    { MatrixIndexPointerARB_names, MatrixIndexPointerARB_remap_index, -1 },
-    { CurrentPaletteMatrixARB_names, CurrentPaletteMatrixARB_remap_index, -1 },
-    { MatrixIndexubvARB_names, MatrixIndexubvARB_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_ARB_multisample)
-static const struct dri_extension_function GL_ARB_multisample_functions[] = {
-    { SampleCoverageARB_names, SampleCoverageARB_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_ARB_occlusion_query)
-static const struct dri_extension_function GL_ARB_occlusion_query_functions[] = {
-    { BeginQueryARB_names, BeginQueryARB_remap_index, -1 },
-    { GetQueryivARB_names, GetQueryivARB_remap_index, -1 },
-    { GetQueryObjectivARB_names, GetQueryObjectivARB_remap_index, -1 },
-    { EndQueryARB_names, EndQueryARB_remap_index, -1 },
-    { GetQueryObjectuivARB_names, GetQueryObjectuivARB_remap_index, -1 },
-    { DeleteQueriesARB_names, DeleteQueriesARB_remap_index, -1 },
-    { IsQueryARB_names, IsQueryARB_remap_index, -1 },
-    { GenQueriesARB_names, GenQueriesARB_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_ARB_point_parameters)
-static const struct dri_extension_function GL_ARB_point_parameters_functions[] = {
-    { PointParameterfEXT_names, PointParameterfEXT_remap_index, -1 },
-    { PointParameterfvEXT_names, PointParameterfvEXT_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_ARB_provoking_vertex)
-static const struct dri_extension_function GL_ARB_provoking_vertex_functions[] = {
-    { ProvokingVertexEXT_names, ProvokingVertexEXT_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_ARB_shader_objects)
-static const struct dri_extension_function GL_ARB_shader_objects_functions[] = {
-    { UniformMatrix3fvARB_names, UniformMatrix3fvARB_remap_index, -1 },
-    { Uniform2fARB_names, Uniform2fARB_remap_index, -1 },
-    { Uniform2ivARB_names, Uniform2ivARB_remap_index, -1 },
-    { UniformMatrix4fvARB_names, UniformMatrix4fvARB_remap_index, -1 },
-    { CreateProgramObjectARB_names, CreateProgramObjectARB_remap_index, -1 },
-    { Uniform3iARB_names, Uniform3iARB_remap_index, -1 },
-    { CreateShaderObjectARB_names, CreateShaderObjectARB_remap_index, -1 },
-    { Uniform1fARB_names, Uniform1fARB_remap_index, -1 },
-    { AttachObjectARB_names, AttachObjectARB_remap_index, -1 },
-    { UniformMatrix2fvARB_names, UniformMatrix2fvARB_remap_index, -1 },
-    { GetAttachedObjectsARB_names, GetAttachedObjectsARB_remap_index, -1 },
-    { Uniform3fvARB_names, Uniform3fvARB_remap_index, -1 },
-    { GetHandleARB_names, GetHandleARB_remap_index, -1 },
-    { GetActiveUniformARB_names, GetActiveUniformARB_remap_index, -1 },
-    { GetUniformivARB_names, GetUniformivARB_remap_index, -1 },
-    { Uniform2fvARB_names, Uniform2fvARB_remap_index, -1 },
-    { DeleteObjectARB_names, DeleteObjectARB_remap_index, -1 },
-    { ValidateProgramARB_names, ValidateProgramARB_remap_index, -1 },
-    { Uniform3ivARB_names, Uniform3ivARB_remap_index, -1 },
-    { CompileShaderARB_names, CompileShaderARB_remap_index, -1 },
-    { Uniform3fARB_names, Uniform3fARB_remap_index, -1 },
-    { Uniform4fARB_names, Uniform4fARB_remap_index, -1 },
-    { LinkProgramARB_names, LinkProgramARB_remap_index, -1 },
-    { ShaderSourceARB_names, ShaderSourceARB_remap_index, -1 },
-    { Uniform4ivARB_names, Uniform4ivARB_remap_index, -1 },
-    { Uniform1ivARB_names, Uniform1ivARB_remap_index, -1 },
-    { Uniform1iARB_names, Uniform1iARB_remap_index, -1 },
-    { Uniform4fvARB_names, Uniform4fvARB_remap_index, -1 },
-    { GetUniformfvARB_names, GetUniformfvARB_remap_index, -1 },
-    { DetachObjectARB_names, DetachObjectARB_remap_index, -1 },
-    { Uniform4iARB_names, Uniform4iARB_remap_index, -1 },
-    { UseProgramObjectARB_names, UseProgramObjectARB_remap_index, -1 },
-    { Uniform2iARB_names, Uniform2iARB_remap_index, -1 },
-    { GetObjectParameterivARB_names, GetObjectParameterivARB_remap_index, -1 },
-    { GetUniformLocationARB_names, GetUniformLocationARB_remap_index, -1 },
-    { GetShaderSourceARB_names, GetShaderSourceARB_remap_index, -1 },
-    { Uniform1fvARB_names, Uniform1fvARB_remap_index, -1 },
-    { GetObjectParameterfvARB_names, GetObjectParameterfvARB_remap_index, -1 },
-    { GetInfoLogARB_names, GetInfoLogARB_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_ARB_sync)
-static const struct dri_extension_function GL_ARB_sync_functions[] = {
-    { DeleteSync_names, DeleteSync_remap_index, -1 },
-    { FenceSync_names, FenceSync_remap_index, -1 },
-    { WaitSync_names, WaitSync_remap_index, -1 },
-    { GetInteger64v_names, GetInteger64v_remap_index, -1 },
-    { GetSynciv_names, GetSynciv_remap_index, -1 },
-    { IsSync_names, IsSync_remap_index, -1 },
-    { ClientWaitSync_names, ClientWaitSync_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_ARB_texture_compression)
-static const struct dri_extension_function GL_ARB_texture_compression_functions[] = {
-    { CompressedTexSubImage2DARB_names, CompressedTexSubImage2DARB_remap_index, -1 },
-    { CompressedTexImage3DARB_names, CompressedTexImage3DARB_remap_index, -1 },
-    { CompressedTexImage1DARB_names, CompressedTexImage1DARB_remap_index, -1 },
-    { CompressedTexSubImage1DARB_names, CompressedTexSubImage1DARB_remap_index, -1 },
-    { CompressedTexSubImage3DARB_names, CompressedTexSubImage3DARB_remap_index, -1 },
-    { CompressedTexImage2DARB_names, CompressedTexImage2DARB_remap_index, -1 },
-    { GetCompressedTexImageARB_names, GetCompressedTexImageARB_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_ARB_transpose_matrix)
-static const struct dri_extension_function GL_ARB_transpose_matrix_functions[] = {
-    { MultTransposeMatrixdARB_names, MultTransposeMatrixdARB_remap_index, -1 },
-    { LoadTransposeMatrixdARB_names, LoadTransposeMatrixdARB_remap_index, -1 },
-    { MultTransposeMatrixfARB_names, MultTransposeMatrixfARB_remap_index, -1 },
-    { LoadTransposeMatrixfARB_names, LoadTransposeMatrixfARB_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_ARB_vertex_array_object)
-static const struct dri_extension_function GL_ARB_vertex_array_object_functions[] = {
-    { DeleteVertexArraysAPPLE_names, DeleteVertexArraysAPPLE_remap_index, -1 },
-    { GenVertexArrays_names, GenVertexArrays_remap_index, -1 },
-    { BindVertexArray_names, BindVertexArray_remap_index, -1 },
-    { IsVertexArrayAPPLE_names, IsVertexArrayAPPLE_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_ARB_vertex_blend)
-static const struct dri_extension_function GL_ARB_vertex_blend_functions[] = {
-    { WeightubvARB_names, WeightubvARB_remap_index, -1 },
-    { WeightivARB_names, WeightivARB_remap_index, -1 },
-    { WeightPointerARB_names, WeightPointerARB_remap_index, -1 },
-    { WeightfvARB_names, WeightfvARB_remap_index, -1 },
-    { WeightbvARB_names, WeightbvARB_remap_index, -1 },
-    { WeightusvARB_names, WeightusvARB_remap_index, -1 },
-    { VertexBlendARB_names, VertexBlendARB_remap_index, -1 },
-    { WeightsvARB_names, WeightsvARB_remap_index, -1 },
-    { WeightdvARB_names, WeightdvARB_remap_index, -1 },
-    { WeightuivARB_names, WeightuivARB_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_ARB_vertex_buffer_object)
-static const struct dri_extension_function GL_ARB_vertex_buffer_object_functions[] = {
-    { GetBufferSubDataARB_names, GetBufferSubDataARB_remap_index, -1 },
-    { BufferSubDataARB_names, BufferSubDataARB_remap_index, -1 },
-    { BufferDataARB_names, BufferDataARB_remap_index, -1 },
-    { GetBufferPointervARB_names, GetBufferPointervARB_remap_index, -1 },
-    { GetBufferParameterivARB_names, GetBufferParameterivARB_remap_index, -1 },
-    { MapBufferARB_names, MapBufferARB_remap_index, -1 },
-    { IsBufferARB_names, IsBufferARB_remap_index, -1 },
-    { DeleteBuffersARB_names, DeleteBuffersARB_remap_index, -1 },
-    { UnmapBufferARB_names, UnmapBufferARB_remap_index, -1 },
-    { BindBufferARB_names, BindBufferARB_remap_index, -1 },
-    { GenBuffersARB_names, GenBuffersARB_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_ARB_vertex_program)
-static const struct dri_extension_function GL_ARB_vertex_program_functions[] = {
-    { VertexAttrib2fARB_names, VertexAttrib2fARB_remap_index, -1 },
-    { VertexAttrib3fARB_names, VertexAttrib3fARB_remap_index, -1 },
-    { VertexAttrib1svARB_names, VertexAttrib1svARB_remap_index, -1 },
-    { VertexAttrib4NusvARB_names, VertexAttrib4NusvARB_remap_index, -1 },
-    { DisableVertexAttribArrayARB_names, DisableVertexAttribArrayARB_remap_index, -1 },
-    { ProgramLocalParameter4dARB_names, ProgramLocalParameter4dARB_remap_index, -1 },
-    { VertexAttrib1fARB_names, VertexAttrib1fARB_remap_index, -1 },
-    { VertexAttrib4NbvARB_names, VertexAttrib4NbvARB_remap_index, -1 },
-    { VertexAttrib1sARB_names, VertexAttrib1sARB_remap_index, -1 },
-    { GetProgramLocalParameterfvARB_names, GetProgramLocalParameterfvARB_remap_index, -1 },
-    { VertexAttrib3dvARB_names, VertexAttrib3dvARB_remap_index, -1 },
-    { ProgramEnvParameter4fvARB_names, ProgramEnvParameter4fvARB_remap_index, -1 },
-    { GetVertexAttribivARB_names, GetVertexAttribivARB_remap_index, -1 },
-    { VertexAttrib4ivARB_names, VertexAttrib4ivARB_remap_index, -1 },
-    { VertexAttrib4bvARB_names, VertexAttrib4bvARB_remap_index, -1 },
-    { VertexAttrib3dARB_names, VertexAttrib3dARB_remap_index, -1 },
-    { VertexAttrib4fARB_names, VertexAttrib4fARB_remap_index, -1 },
-    { VertexAttrib4fvARB_names, VertexAttrib4fvARB_remap_index, -1 },
-    { ProgramLocalParameter4dvARB_names, ProgramLocalParameter4dvARB_remap_index, -1 },
-    { VertexAttrib2dARB_names, VertexAttrib2dARB_remap_index, -1 },
-    { VertexAttrib1dvARB_names, VertexAttrib1dvARB_remap_index, -1 },
-    { GetVertexAttribfvARB_names, GetVertexAttribfvARB_remap_index, -1 },
-    { VertexAttrib4ubvARB_names, VertexAttrib4ubvARB_remap_index, -1 },
-    { ProgramEnvParameter4fARB_names, ProgramEnvParameter4fARB_remap_index, -1 },
-    { VertexAttrib4sARB_names, VertexAttrib4sARB_remap_index, -1 },
-    { VertexAttrib2dvARB_names, VertexAttrib2dvARB_remap_index, -1 },
-    { VertexAttrib2fvARB_names, VertexAttrib2fvARB_remap_index, -1 },
-    { VertexAttrib4NivARB_names, VertexAttrib4NivARB_remap_index, -1 },
-    { GetProgramStringARB_names, GetProgramStringARB_remap_index, -1 },
-    { VertexAttrib4NuivARB_names, VertexAttrib4NuivARB_remap_index, -1 },
-    { IsProgramNV_names, IsProgramNV_remap_index, -1 },
-    { ProgramEnvParameter4dARB_names, ProgramEnvParameter4dARB_remap_index, -1 },
-    { VertexAttrib1dARB_names, VertexAttrib1dARB_remap_index, -1 },
-    { VertexAttrib4usvARB_names, VertexAttrib4usvARB_remap_index, -1 },
-    { VertexAttrib3svARB_names, VertexAttrib3svARB_remap_index, -1 },
-    { GetVertexAttribdvARB_names, GetVertexAttribdvARB_remap_index, -1 },
-    { VertexAttrib4dvARB_names, VertexAttrib4dvARB_remap_index, -1 },
-    { VertexAttribPointerARB_names, VertexAttribPointerARB_remap_index, -1 },
-    { VertexAttrib4NsvARB_names, VertexAttrib4NsvARB_remap_index, -1 },
-    { VertexAttrib3fvARB_names, VertexAttrib3fvARB_remap_index, -1 },
-    { VertexAttrib4NubARB_names, VertexAttrib4NubARB_remap_index, -1 },
-    { GetProgramEnvParameterfvARB_names, GetProgramEnvParameterfvARB_remap_index, -1 },
-    { ProgramEnvParameter4dvARB_names, ProgramEnvParameter4dvARB_remap_index, -1 },
-    { ProgramLocalParameter4fvARB_names, ProgramLocalParameter4fvARB_remap_index, -1 },
-    { DeleteProgramsNV_names, DeleteProgramsNV_remap_index, -1 },
-    { GetVertexAttribPointervNV_names, GetVertexAttribPointervNV_remap_index, -1 },
-    { VertexAttrib4dARB_names, VertexAttrib4dARB_remap_index, -1 },
-    { GetProgramLocalParameterdvARB_names, GetProgramLocalParameterdvARB_remap_index, -1 },
-    { GetProgramivARB_names, GetProgramivARB_remap_index, -1 },
-    { VertexAttrib3sARB_names, VertexAttrib3sARB_remap_index, -1 },
-    { ProgramStringARB_names, ProgramStringARB_remap_index, -1 },
-    { ProgramLocalParameter4fARB_names, ProgramLocalParameter4fARB_remap_index, -1 },
-    { EnableVertexAttribArrayARB_names, EnableVertexAttribArrayARB_remap_index, -1 },
-    { VertexAttrib4uivARB_names, VertexAttrib4uivARB_remap_index, -1 },
-    { BindProgramNV_names, BindProgramNV_remap_index, -1 },
-    { VertexAttrib4svARB_names, VertexAttrib4svARB_remap_index, -1 },
-    { VertexAttrib2svARB_names, VertexAttrib2svARB_remap_index, -1 },
-    { VertexAttrib4NubvARB_names, VertexAttrib4NubvARB_remap_index, -1 },
-    { GetProgramEnvParameterdvARB_names, GetProgramEnvParameterdvARB_remap_index, -1 },
-    { VertexAttrib2sARB_names, VertexAttrib2sARB_remap_index, -1 },
-    { VertexAttrib1fvARB_names, VertexAttrib1fvARB_remap_index, -1 },
-    { GenProgramsNV_names, GenProgramsNV_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_ARB_vertex_shader)
-static const struct dri_extension_function GL_ARB_vertex_shader_functions[] = {
-    { GetActiveAttribARB_names, GetActiveAttribARB_remap_index, -1 },
-    { GetAttribLocationARB_names, GetAttribLocationARB_remap_index, -1 },
-    { BindAttribLocationARB_names, BindAttribLocationARB_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_ARB_window_pos)
-static const struct dri_extension_function GL_ARB_window_pos_functions[] = {
-    { WindowPos3fMESA_names, WindowPos3fMESA_remap_index, -1 },
-    { WindowPos2dvMESA_names, WindowPos2dvMESA_remap_index, -1 },
-    { WindowPos2svMESA_names, WindowPos2svMESA_remap_index, -1 },
-    { WindowPos3dMESA_names, WindowPos3dMESA_remap_index, -1 },
-    { WindowPos2fvMESA_names, WindowPos2fvMESA_remap_index, -1 },
-    { WindowPos2dMESA_names, WindowPos2dMESA_remap_index, -1 },
-    { WindowPos3dvMESA_names, WindowPos3dvMESA_remap_index, -1 },
-    { WindowPos3fvMESA_names, WindowPos3fvMESA_remap_index, -1 },
-    { WindowPos2iMESA_names, WindowPos2iMESA_remap_index, -1 },
-    { WindowPos3sMESA_names, WindowPos3sMESA_remap_index, -1 },
-    { WindowPos2ivMESA_names, WindowPos2ivMESA_remap_index, -1 },
-    { WindowPos2sMESA_names, WindowPos2sMESA_remap_index, -1 },
-    { WindowPos3iMESA_names, WindowPos3iMESA_remap_index, -1 },
-    { WindowPos3ivMESA_names, WindowPos3ivMESA_remap_index, -1 },
-    { WindowPos3svMESA_names, WindowPos3svMESA_remap_index, -1 },
-    { WindowPos2fMESA_names, WindowPos2fMESA_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_ATI_blend_equation_separate)
-static const struct dri_extension_function GL_ATI_blend_equation_separate_functions[] = {
-    { BlendEquationSeparateEXT_names, BlendEquationSeparateEXT_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_ATI_draw_buffers)
-static const struct dri_extension_function GL_ATI_draw_buffers_functions[] = {
-    { DrawBuffersARB_names, DrawBuffersARB_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_ATI_envmap_bumpmap)
-static const struct dri_extension_function GL_ATI_envmap_bumpmap_functions[] = {
-    { TexBumpParameterfvATI_names, TexBumpParameterfvATI_remap_index, -1 },
-    { TexBumpParameterivATI_names, TexBumpParameterivATI_remap_index, -1 },
-    { GetTexBumpParameterfvATI_names, GetTexBumpParameterfvATI_remap_index, -1 },
-    { GetTexBumpParameterivATI_names, GetTexBumpParameterivATI_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_ATI_fragment_shader)
-static const struct dri_extension_function GL_ATI_fragment_shader_functions[] = {
-    { ColorFragmentOp2ATI_names, ColorFragmentOp2ATI_remap_index, -1 },
-    { DeleteFragmentShaderATI_names, DeleteFragmentShaderATI_remap_index, -1 },
-    { SetFragmentShaderConstantATI_names, SetFragmentShaderConstantATI_remap_index, -1 },
-    { SampleMapATI_names, SampleMapATI_remap_index, -1 },
-    { AlphaFragmentOp2ATI_names, AlphaFragmentOp2ATI_remap_index, -1 },
-    { AlphaFragmentOp1ATI_names, AlphaFragmentOp1ATI_remap_index, -1 },
-    { ColorFragmentOp1ATI_names, ColorFragmentOp1ATI_remap_index, -1 },
-    { AlphaFragmentOp3ATI_names, AlphaFragmentOp3ATI_remap_index, -1 },
-    { PassTexCoordATI_names, PassTexCoordATI_remap_index, -1 },
-    { BeginFragmentShaderATI_names, BeginFragmentShaderATI_remap_index, -1 },
-    { BindFragmentShaderATI_names, BindFragmentShaderATI_remap_index, -1 },
-    { ColorFragmentOp3ATI_names, ColorFragmentOp3ATI_remap_index, -1 },
-    { GenFragmentShadersATI_names, GenFragmentShadersATI_remap_index, -1 },
-    { EndFragmentShaderATI_names, EndFragmentShaderATI_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_ATI_separate_stencil)
-static const struct dri_extension_function GL_ATI_separate_stencil_functions[] = {
-    { StencilOpSeparate_names, StencilOpSeparate_remap_index, -1 },
-    { StencilFuncSeparateATI_names, StencilFuncSeparateATI_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_blend_color)
-static const struct dri_extension_function GL_EXT_blend_color_functions[] = {
-    { BlendColor_names, -1, 336 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_blend_equation_separate)
-static const struct dri_extension_function GL_EXT_blend_equation_separate_functions[] = {
-    { BlendEquationSeparateEXT_names, BlendEquationSeparateEXT_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_blend_func_separate)
-static const struct dri_extension_function GL_EXT_blend_func_separate_functions[] = {
-    { BlendFuncSeparateEXT_names, BlendFuncSeparateEXT_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_blend_minmax)
-static const struct dri_extension_function GL_EXT_blend_minmax_functions[] = {
-    { BlendEquation_names, -1, 337 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_color_subtable)
-static const struct dri_extension_function GL_EXT_color_subtable_functions[] = {
-    { ColorSubTable_names, -1, 346 },
-    { CopyColorSubTable_names, -1, 347 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_compiled_vertex_array)
-static const struct dri_extension_function GL_EXT_compiled_vertex_array_functions[] = {
-    { UnlockArraysEXT_names, UnlockArraysEXT_remap_index, -1 },
-    { LockArraysEXT_names, LockArraysEXT_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_convolution)
-static const struct dri_extension_function GL_EXT_convolution_functions[] = {
-    { ConvolutionFilter1D_names, -1, 348 },
-    { CopyConvolutionFilter1D_names, -1, 354 },
-    { GetConvolutionParameteriv_names, -1, 358 },
-    { ConvolutionFilter2D_names, -1, 349 },
-    { ConvolutionParameteriv_names, -1, 353 },
-    { ConvolutionParameterfv_names, -1, 351 },
-    { GetSeparableFilter_names, -1, 359 },
-    { SeparableFilter2D_names, -1, 360 },
-    { ConvolutionParameteri_names, -1, 352 },
-    { ConvolutionParameterf_names, -1, 350 },
-    { GetConvolutionParameterfv_names, -1, 357 },
-    { GetConvolutionFilter_names, -1, 356 },
-    { CopyConvolutionFilter2D_names, -1, 355 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_coordinate_frame)
-static const struct dri_extension_function GL_EXT_coordinate_frame_functions[] = {
-    { TangentPointerEXT_names, TangentPointerEXT_remap_index, -1 },
-    { Binormal3ivEXT_names, Binormal3ivEXT_remap_index, -1 },
-    { Tangent3sEXT_names, Tangent3sEXT_remap_index, -1 },
-    { Tangent3fvEXT_names, Tangent3fvEXT_remap_index, -1 },
-    { Tangent3dvEXT_names, Tangent3dvEXT_remap_index, -1 },
-    { Binormal3bvEXT_names, Binormal3bvEXT_remap_index, -1 },
-    { Binormal3dEXT_names, Binormal3dEXT_remap_index, -1 },
-    { Tangent3fEXT_names, Tangent3fEXT_remap_index, -1 },
-    { Binormal3sEXT_names, Binormal3sEXT_remap_index, -1 },
-    { Tangent3ivEXT_names, Tangent3ivEXT_remap_index, -1 },
-    { Tangent3dEXT_names, Tangent3dEXT_remap_index, -1 },
-    { Binormal3svEXT_names, Binormal3svEXT_remap_index, -1 },
-    { Binormal3fEXT_names, Binormal3fEXT_remap_index, -1 },
-    { Binormal3dvEXT_names, Binormal3dvEXT_remap_index, -1 },
-    { Tangent3iEXT_names, Tangent3iEXT_remap_index, -1 },
-    { Tangent3bvEXT_names, Tangent3bvEXT_remap_index, -1 },
-    { Tangent3bEXT_names, Tangent3bEXT_remap_index, -1 },
-    { Binormal3fvEXT_names, Binormal3fvEXT_remap_index, -1 },
-    { BinormalPointerEXT_names, BinormalPointerEXT_remap_index, -1 },
-    { Tangent3svEXT_names, Tangent3svEXT_remap_index, -1 },
-    { Binormal3bEXT_names, Binormal3bEXT_remap_index, -1 },
-    { Binormal3iEXT_names, Binormal3iEXT_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_copy_texture)
-static const struct dri_extension_function GL_EXT_copy_texture_functions[] = {
-    { CopyTexSubImage3D_names, -1, 373 },
-    { CopyTexImage2D_names, -1, 324 },
-    { CopyTexImage1D_names, -1, 323 },
-    { CopyTexSubImage2D_names, -1, 326 },
-    { CopyTexSubImage1D_names, -1, 325 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_cull_vertex)
-static const struct dri_extension_function GL_EXT_cull_vertex_functions[] = {
-    { CullParameterdvEXT_names, CullParameterdvEXT_remap_index, -1 },
-    { CullParameterfvEXT_names, CullParameterfvEXT_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_depth_bounds_test)
-static const struct dri_extension_function GL_EXT_depth_bounds_test_functions[] = {
-    { DepthBoundsEXT_names, DepthBoundsEXT_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_draw_range_elements)
-static const struct dri_extension_function GL_EXT_draw_range_elements_functions[] = {
-    { DrawRangeElements_names, -1, 338 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_fog_coord)
-static const struct dri_extension_function GL_EXT_fog_coord_functions[] = {
-    { FogCoorddEXT_names, FogCoorddEXT_remap_index, -1 },
-    { FogCoordfEXT_names, FogCoordfEXT_remap_index, -1 },
-    { FogCoordPointerEXT_names, FogCoordPointerEXT_remap_index, -1 },
-    { FogCoordfvEXT_names, FogCoordfvEXT_remap_index, -1 },
-    { FogCoorddvEXT_names, FogCoorddvEXT_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_framebuffer_blit)
-static const struct dri_extension_function GL_EXT_framebuffer_blit_functions[] = {
-    { BlitFramebufferEXT_names, BlitFramebufferEXT_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_framebuffer_object)
-static const struct dri_extension_function GL_EXT_framebuffer_object_functions[] = {
-    { GenerateMipmapEXT_names, GenerateMipmapEXT_remap_index, -1 },
-    { RenderbufferStorageEXT_names, RenderbufferStorageEXT_remap_index, -1 },
-    { CheckFramebufferStatusEXT_names, CheckFramebufferStatusEXT_remap_index, -1 },
-    { FramebufferTexture3DEXT_names, FramebufferTexture3DEXT_remap_index, -1 },
-    { FramebufferTexture2DEXT_names, FramebufferTexture2DEXT_remap_index, -1 },
-    { FramebufferRenderbufferEXT_names, FramebufferRenderbufferEXT_remap_index, -1 },
-    { FramebufferTexture1DEXT_names, FramebufferTexture1DEXT_remap_index, -1 },
-    { BindFramebufferEXT_names, BindFramebufferEXT_remap_index, -1 },
-    { GenRenderbuffersEXT_names, GenRenderbuffersEXT_remap_index, -1 },
-    { IsFramebufferEXT_names, IsFramebufferEXT_remap_index, -1 },
-    { GetFramebufferAttachmentParameterivEXT_names, GetFramebufferAttachmentParameterivEXT_remap_index, -1 },
-    { DeleteFramebuffersEXT_names, DeleteFramebuffersEXT_remap_index, -1 },
-    { GenFramebuffersEXT_names, GenFramebuffersEXT_remap_index, -1 },
-    { BindRenderbufferEXT_names, BindRenderbufferEXT_remap_index, -1 },
-    { DeleteRenderbuffersEXT_names, DeleteRenderbuffersEXT_remap_index, -1 },
-    { GetRenderbufferParameterivEXT_names, GetRenderbufferParameterivEXT_remap_index, -1 },
-    { IsRenderbufferEXT_names, IsRenderbufferEXT_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_gpu_program_parameters)
-static const struct dri_extension_function GL_EXT_gpu_program_parameters_functions[] = {
-    { ProgramLocalParameters4fvEXT_names, ProgramLocalParameters4fvEXT_remap_index, -1 },
-    { ProgramEnvParameters4fvEXT_names, ProgramEnvParameters4fvEXT_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_histogram)
-static const struct dri_extension_function GL_EXT_histogram_functions[] = {
-    { Histogram_names, -1, 367 },
-    { ResetHistogram_names, -1, 369 },
-    { GetMinmax_names, -1, 364 },
-    { GetHistogramParameterfv_names, -1, 362 },
-    { GetMinmaxParameteriv_names, -1, 366 },
-    { ResetMinmax_names, -1, 370 },
-    { GetHistogramParameteriv_names, -1, 363 },
-    { GetHistogram_names, -1, 361 },
-    { Minmax_names, -1, 368 },
-    { GetMinmaxParameterfv_names, -1, 365 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_index_func)
-static const struct dri_extension_function GL_EXT_index_func_functions[] = {
-    { IndexFuncEXT_names, IndexFuncEXT_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_index_material)
-static const struct dri_extension_function GL_EXT_index_material_functions[] = {
-    { IndexMaterialEXT_names, IndexMaterialEXT_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_light_texture)
-static const struct dri_extension_function GL_EXT_light_texture_functions[] = {
-    { ApplyTextureEXT_names, ApplyTextureEXT_remap_index, -1 },
-    { TextureMaterialEXT_names, TextureMaterialEXT_remap_index, -1 },
-    { TextureLightEXT_names, TextureLightEXT_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_multi_draw_arrays)
-static const struct dri_extension_function GL_EXT_multi_draw_arrays_functions[] = {
-    { MultiDrawElementsEXT_names, MultiDrawElementsEXT_remap_index, -1 },
-    { MultiDrawArraysEXT_names, MultiDrawArraysEXT_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_multisample)
-static const struct dri_extension_function GL_EXT_multisample_functions[] = {
-    { SampleMaskSGIS_names, SampleMaskSGIS_remap_index, -1 },
-    { SamplePatternSGIS_names, SamplePatternSGIS_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_paletted_texture)
-static const struct dri_extension_function GL_EXT_paletted_texture_functions[] = {
-    { ColorTable_names, -1, 339 },
-    { GetColorTable_names, -1, 343 },
-    { GetColorTableParameterfv_names, -1, 344 },
-    { GetColorTableParameteriv_names, -1, 345 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_pixel_transform)
-static const struct dri_extension_function GL_EXT_pixel_transform_functions[] = {
-    { PixelTransformParameterfvEXT_names, PixelTransformParameterfvEXT_remap_index, -1 },
-    { PixelTransformParameterfEXT_names, PixelTransformParameterfEXT_remap_index, -1 },
-    { PixelTransformParameteriEXT_names, PixelTransformParameteriEXT_remap_index, -1 },
-    { PixelTransformParameterivEXT_names, PixelTransformParameterivEXT_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_point_parameters)
-static const struct dri_extension_function GL_EXT_point_parameters_functions[] = {
-    { PointParameterfEXT_names, PointParameterfEXT_remap_index, -1 },
-    { PointParameterfvEXT_names, PointParameterfvEXT_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_polygon_offset)
-static const struct dri_extension_function GL_EXT_polygon_offset_functions[] = {
-    { PolygonOffsetEXT_names, PolygonOffsetEXT_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_provoking_vertex)
-static const struct dri_extension_function GL_EXT_provoking_vertex_functions[] = {
-    { ProvokingVertexEXT_names, ProvokingVertexEXT_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_secondary_color)
-static const struct dri_extension_function GL_EXT_secondary_color_functions[] = {
-    { SecondaryColor3iEXT_names, SecondaryColor3iEXT_remap_index, -1 },
-    { SecondaryColor3bEXT_names, SecondaryColor3bEXT_remap_index, -1 },
-    { SecondaryColor3bvEXT_names, SecondaryColor3bvEXT_remap_index, -1 },
-    { SecondaryColor3sEXT_names, SecondaryColor3sEXT_remap_index, -1 },
-    { SecondaryColor3dEXT_names, SecondaryColor3dEXT_remap_index, -1 },
-    { SecondaryColorPointerEXT_names, SecondaryColorPointerEXT_remap_index, -1 },
-    { SecondaryColor3uiEXT_names, SecondaryColor3uiEXT_remap_index, -1 },
-    { SecondaryColor3usvEXT_names, SecondaryColor3usvEXT_remap_index, -1 },
-    { SecondaryColor3ivEXT_names, SecondaryColor3ivEXT_remap_index, -1 },
-    { SecondaryColor3fvEXT_names, SecondaryColor3fvEXT_remap_index, -1 },
-    { SecondaryColor3ubvEXT_names, SecondaryColor3ubvEXT_remap_index, -1 },
-    { SecondaryColor3uivEXT_names, SecondaryColor3uivEXT_remap_index, -1 },
-    { SecondaryColor3dvEXT_names, SecondaryColor3dvEXT_remap_index, -1 },
-    { SecondaryColor3usEXT_names, SecondaryColor3usEXT_remap_index, -1 },
-    { SecondaryColor3ubEXT_names, SecondaryColor3ubEXT_remap_index, -1 },
-    { SecondaryColor3fEXT_names, SecondaryColor3fEXT_remap_index, -1 },
-    { SecondaryColor3svEXT_names, SecondaryColor3svEXT_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_stencil_two_side)
-static const struct dri_extension_function GL_EXT_stencil_two_side_functions[] = {
-    { ActiveStencilFaceEXT_names, ActiveStencilFaceEXT_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_subtexture)
-static const struct dri_extension_function GL_EXT_subtexture_functions[] = {
-    { TexSubImage1D_names, -1, 332 },
-    { TexSubImage2D_names, -1, 333 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_texture3D)
-static const struct dri_extension_function GL_EXT_texture3D_functions[] = {
-    { TexImage3D_names, -1, 371 },
-    { TexSubImage3D_names, -1, 372 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_texture_array)
-static const struct dri_extension_function GL_EXT_texture_array_functions[] = {
-    { FramebufferTextureLayerEXT_names, FramebufferTextureLayerEXT_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_texture_object)
-static const struct dri_extension_function GL_EXT_texture_object_functions[] = {
-    { PrioritizeTextures_names, -1, 331 },
-    { AreTexturesResident_names, -1, 322 },
-    { GenTextures_names, -1, 328 },
-    { DeleteTextures_names, -1, 327 },
-    { IsTexture_names, -1, 330 },
-    { BindTexture_names, -1, 307 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_texture_perturb_normal)
-static const struct dri_extension_function GL_EXT_texture_perturb_normal_functions[] = {
-    { TextureNormalEXT_names, TextureNormalEXT_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_timer_query)
-static const struct dri_extension_function GL_EXT_timer_query_functions[] = {
-    { GetQueryObjectui64vEXT_names, GetQueryObjectui64vEXT_remap_index, -1 },
-    { GetQueryObjecti64vEXT_names, GetQueryObjecti64vEXT_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_vertex_array)
-static const struct dri_extension_function GL_EXT_vertex_array_functions[] = {
-    { IndexPointerEXT_names, IndexPointerEXT_remap_index, -1 },
-    { NormalPointerEXT_names, NormalPointerEXT_remap_index, -1 },
-    { VertexPointerEXT_names, VertexPointerEXT_remap_index, -1 },
-    { TexCoordPointerEXT_names, TexCoordPointerEXT_remap_index, -1 },
-    { EdgeFlagPointerEXT_names, EdgeFlagPointerEXT_remap_index, -1 },
-    { ArrayElement_names, -1, 306 },
-    { ColorPointerEXT_names, ColorPointerEXT_remap_index, -1 },
-    { GetPointerv_names, -1, 329 },
-    { DrawArrays_names, -1, 310 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_EXT_vertex_weighting)
-static const struct dri_extension_function GL_EXT_vertex_weighting_functions[] = {
-    { VertexWeightfvEXT_names, VertexWeightfvEXT_remap_index, -1 },
-    { VertexWeightfEXT_names, VertexWeightfEXT_remap_index, -1 },
-    { VertexWeightPointerEXT_names, VertexWeightPointerEXT_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_HP_image_transform)
-static const struct dri_extension_function GL_HP_image_transform_functions[] = {
-    { GetImageTransformParameterfvHP_names, GetImageTransformParameterfvHP_remap_index, -1 },
-    { ImageTransformParameterfHP_names, ImageTransformParameterfHP_remap_index, -1 },
-    { ImageTransformParameterfvHP_names, ImageTransformParameterfvHP_remap_index, -1 },
-    { ImageTransformParameteriHP_names, ImageTransformParameteriHP_remap_index, -1 },
-    { GetImageTransformParameterivHP_names, GetImageTransformParameterivHP_remap_index, -1 },
-    { ImageTransformParameterivHP_names, ImageTransformParameterivHP_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_IBM_multimode_draw_arrays)
-static const struct dri_extension_function GL_IBM_multimode_draw_arrays_functions[] = {
-    { MultiModeDrawArraysIBM_names, MultiModeDrawArraysIBM_remap_index, -1 },
-    { MultiModeDrawElementsIBM_names, MultiModeDrawElementsIBM_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_IBM_vertex_array_lists)
-static const struct dri_extension_function GL_IBM_vertex_array_lists_functions[] = {
-    { SecondaryColorPointerListIBM_names, SecondaryColorPointerListIBM_remap_index, -1 },
-    { NormalPointerListIBM_names, NormalPointerListIBM_remap_index, -1 },
-    { FogCoordPointerListIBM_names, FogCoordPointerListIBM_remap_index, -1 },
-    { VertexPointerListIBM_names, VertexPointerListIBM_remap_index, -1 },
-    { ColorPointerListIBM_names, ColorPointerListIBM_remap_index, -1 },
-    { TexCoordPointerListIBM_names, TexCoordPointerListIBM_remap_index, -1 },
-    { IndexPointerListIBM_names, IndexPointerListIBM_remap_index, -1 },
-    { EdgeFlagPointerListIBM_names, EdgeFlagPointerListIBM_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_INGR_blend_func_separate)
-static const struct dri_extension_function GL_INGR_blend_func_separate_functions[] = {
-    { BlendFuncSeparateEXT_names, BlendFuncSeparateEXT_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_INTEL_parallel_arrays)
-static const struct dri_extension_function GL_INTEL_parallel_arrays_functions[] = {
-    { VertexPointervINTEL_names, VertexPointervINTEL_remap_index, -1 },
-    { ColorPointervINTEL_names, ColorPointervINTEL_remap_index, -1 },
-    { NormalPointervINTEL_names, NormalPointervINTEL_remap_index, -1 },
-    { TexCoordPointervINTEL_names, TexCoordPointervINTEL_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_MESA_resize_buffers)
-static const struct dri_extension_function GL_MESA_resize_buffers_functions[] = {
-    { ResizeBuffersMESA_names, ResizeBuffersMESA_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_MESA_shader_debug)
-static const struct dri_extension_function GL_MESA_shader_debug_functions[] = {
-    { GetDebugLogLengthMESA_names, GetDebugLogLengthMESA_remap_index, -1 },
-    { ClearDebugLogMESA_names, ClearDebugLogMESA_remap_index, -1 },
-    { GetDebugLogMESA_names, GetDebugLogMESA_remap_index, -1 },
-    { CreateDebugObjectMESA_names, CreateDebugObjectMESA_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_MESA_window_pos)
-static const struct dri_extension_function GL_MESA_window_pos_functions[] = {
-    { WindowPos3fMESA_names, WindowPos3fMESA_remap_index, -1 },
-    { WindowPos2dvMESA_names, WindowPos2dvMESA_remap_index, -1 },
-    { WindowPos4svMESA_names, WindowPos4svMESA_remap_index, -1 },
-    { WindowPos2svMESA_names, WindowPos2svMESA_remap_index, -1 },
-    { WindowPos3dMESA_names, WindowPos3dMESA_remap_index, -1 },
-    { WindowPos2fvMESA_names, WindowPos2fvMESA_remap_index, -1 },
-    { WindowPos4dMESA_names, WindowPos4dMESA_remap_index, -1 },
-    { WindowPos2dMESA_names, WindowPos2dMESA_remap_index, -1 },
-    { WindowPos4ivMESA_names, WindowPos4ivMESA_remap_index, -1 },
-    { WindowPos4fMESA_names, WindowPos4fMESA_remap_index, -1 },
-    { WindowPos3dvMESA_names, WindowPos3dvMESA_remap_index, -1 },
-    { WindowPos3fvMESA_names, WindowPos3fvMESA_remap_index, -1 },
-    { WindowPos4dvMESA_names, WindowPos4dvMESA_remap_index, -1 },
-    { WindowPos2iMESA_names, WindowPos2iMESA_remap_index, -1 },
-    { WindowPos3sMESA_names, WindowPos3sMESA_remap_index, -1 },
-    { WindowPos4sMESA_names, WindowPos4sMESA_remap_index, -1 },
-    { WindowPos2ivMESA_names, WindowPos2ivMESA_remap_index, -1 },
-    { WindowPos2sMESA_names, WindowPos2sMESA_remap_index, -1 },
-    { WindowPos3iMESA_names, WindowPos3iMESA_remap_index, -1 },
-    { WindowPos3ivMESA_names, WindowPos3ivMESA_remap_index, -1 },
-    { WindowPos4iMESA_names, WindowPos4iMESA_remap_index, -1 },
-    { WindowPos4fvMESA_names, WindowPos4fvMESA_remap_index, -1 },
-    { WindowPos3svMESA_names, WindowPos3svMESA_remap_index, -1 },
-    { WindowPos2fMESA_names, WindowPos2fMESA_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_NV_evaluators)
-static const struct dri_extension_function GL_NV_evaluators_functions[] = {
-    { GetMapAttribParameterivNV_names, GetMapAttribParameterivNV_remap_index, -1 },
-    { MapControlPointsNV_names, MapControlPointsNV_remap_index, -1 },
-    { MapParameterfvNV_names, MapParameterfvNV_remap_index, -1 },
-    { EvalMapsNV_names, EvalMapsNV_remap_index, -1 },
-    { GetMapAttribParameterfvNV_names, GetMapAttribParameterfvNV_remap_index, -1 },
-    { MapParameterivNV_names, MapParameterivNV_remap_index, -1 },
-    { GetMapParameterivNV_names, GetMapParameterivNV_remap_index, -1 },
-    { GetMapParameterfvNV_names, GetMapParameterfvNV_remap_index, -1 },
-    { GetMapControlPointsNV_names, GetMapControlPointsNV_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_NV_fence)
-static const struct dri_extension_function GL_NV_fence_functions[] = {
-    { GenFencesNV_names, GenFencesNV_remap_index, -1 },
-    { TestFenceNV_names, TestFenceNV_remap_index, -1 },
-    { IsFenceNV_names, IsFenceNV_remap_index, -1 },
-    { DeleteFencesNV_names, DeleteFencesNV_remap_index, -1 },
-    { SetFenceNV_names, SetFenceNV_remap_index, -1 },
-    { GetFenceivNV_names, GetFenceivNV_remap_index, -1 },
-    { FinishFenceNV_names, FinishFenceNV_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_NV_fragment_program)
-static const struct dri_extension_function GL_NV_fragment_program_functions[] = {
-    { GetProgramNamedParameterdvNV_names, GetProgramNamedParameterdvNV_remap_index, -1 },
-    { GetProgramNamedParameterfvNV_names, GetProgramNamedParameterfvNV_remap_index, -1 },
-    { ProgramNamedParameter4fNV_names, ProgramNamedParameter4fNV_remap_index, -1 },
-    { ProgramNamedParameter4fvNV_names, ProgramNamedParameter4fvNV_remap_index, -1 },
-    { ProgramNamedParameter4dvNV_names, ProgramNamedParameter4dvNV_remap_index, -1 },
-    { ProgramNamedParameter4dNV_names, ProgramNamedParameter4dNV_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_NV_point_sprite)
-static const struct dri_extension_function GL_NV_point_sprite_functions[] = {
-    { PointParameteriNV_names, PointParameteriNV_remap_index, -1 },
-    { PointParameterivNV_names, PointParameterivNV_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_NV_register_combiners)
-static const struct dri_extension_function GL_NV_register_combiners_functions[] = {
-    { CombinerOutputNV_names, CombinerOutputNV_remap_index, -1 },
-    { CombinerParameterfvNV_names, CombinerParameterfvNV_remap_index, -1 },
-    { GetFinalCombinerInputParameterfvNV_names, GetFinalCombinerInputParameterfvNV_remap_index, -1 },
-    { GetCombinerOutputParameterfvNV_names, GetCombinerOutputParameterfvNV_remap_index, -1 },
-    { FinalCombinerInputNV_names, FinalCombinerInputNV_remap_index, -1 },
-    { GetCombinerInputParameterfvNV_names, GetCombinerInputParameterfvNV_remap_index, -1 },
-    { GetCombinerOutputParameterivNV_names, GetCombinerOutputParameterivNV_remap_index, -1 },
-    { CombinerParameteriNV_names, CombinerParameteriNV_remap_index, -1 },
-    { GetFinalCombinerInputParameterivNV_names, GetFinalCombinerInputParameterivNV_remap_index, -1 },
-    { CombinerInputNV_names, CombinerInputNV_remap_index, -1 },
-    { CombinerParameterfNV_names, CombinerParameterfNV_remap_index, -1 },
-    { GetCombinerInputParameterivNV_names, GetCombinerInputParameterivNV_remap_index, -1 },
-    { CombinerParameterivNV_names, CombinerParameterivNV_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_NV_register_combiners2)
-static const struct dri_extension_function GL_NV_register_combiners2_functions[] = {
-    { CombinerStageParameterfvNV_names, CombinerStageParameterfvNV_remap_index, -1 },
-    { GetCombinerStageParameterfvNV_names, GetCombinerStageParameterfvNV_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_NV_vertex_array_range)
-static const struct dri_extension_function GL_NV_vertex_array_range_functions[] = {
-    { VertexArrayRangeNV_names, VertexArrayRangeNV_remap_index, -1 },
-    { FlushVertexArrayRangeNV_names, FlushVertexArrayRangeNV_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_NV_vertex_program)
-static const struct dri_extension_function GL_NV_vertex_program_functions[] = {
-    { VertexAttrib4ubvNV_names, VertexAttrib4ubvNV_remap_index, -1 },
-    { VertexAttrib4svNV_names, VertexAttrib4svNV_remap_index, -1 },
-    { VertexAttribs3fvNV_names, VertexAttribs3fvNV_remap_index, -1 },
-    { VertexAttribs1dvNV_names, VertexAttribs1dvNV_remap_index, -1 },
-    { VertexAttrib1fvNV_names, VertexAttrib1fvNV_remap_index, -1 },
-    { VertexAttrib4fNV_names, VertexAttrib4fNV_remap_index, -1 },
-    { VertexAttrib2dNV_names, VertexAttrib2dNV_remap_index, -1 },
-    { VertexAttrib4ubNV_names, VertexAttrib4ubNV_remap_index, -1 },
-    { VertexAttribs3dvNV_names, VertexAttribs3dvNV_remap_index, -1 },
-    { VertexAttribs4fvNV_names, VertexAttribs4fvNV_remap_index, -1 },
-    { VertexAttrib2sNV_names, VertexAttrib2sNV_remap_index, -1 },
-    { ProgramEnvParameter4fvARB_names, ProgramEnvParameter4fvARB_remap_index, -1 },
-    { LoadProgramNV_names, LoadProgramNV_remap_index, -1 },
-    { VertexAttrib4fvNV_names, VertexAttrib4fvNV_remap_index, -1 },
-    { VertexAttrib3fNV_names, VertexAttrib3fNV_remap_index, -1 },
-    { VertexAttribs2dvNV_names, VertexAttribs2dvNV_remap_index, -1 },
-    { GetProgramParameterfvNV_names, GetProgramParameterfvNV_remap_index, -1 },
-    { VertexAttrib3dNV_names, VertexAttrib3dNV_remap_index, -1 },
-    { VertexAttrib2fvNV_names, VertexAttrib2fvNV_remap_index, -1 },
-    { VertexAttrib2dvNV_names, VertexAttrib2dvNV_remap_index, -1 },
-    { VertexAttrib1dvNV_names, VertexAttrib1dvNV_remap_index, -1 },
-    { VertexAttrib1svNV_names, VertexAttrib1svNV_remap_index, -1 },
-    { ProgramEnvParameter4fARB_names, ProgramEnvParameter4fARB_remap_index, -1 },
-    { VertexAttribs2svNV_names, VertexAttribs2svNV_remap_index, -1 },
-    { GetVertexAttribivNV_names, GetVertexAttribivNV_remap_index, -1 },
-    { GetVertexAttribfvNV_names, GetVertexAttribfvNV_remap_index, -1 },
-    { VertexAttrib2svNV_names, VertexAttrib2svNV_remap_index, -1 },
-    { VertexAttribs1fvNV_names, VertexAttribs1fvNV_remap_index, -1 },
-    { IsProgramNV_names, IsProgramNV_remap_index, -1 },
-    { ProgramEnvParameter4dARB_names, ProgramEnvParameter4dARB_remap_index, -1 },
-    { VertexAttrib2fNV_names, VertexAttrib2fNV_remap_index, -1 },
-    { RequestResidentProgramsNV_names, RequestResidentProgramsNV_remap_index, -1 },
-    { ExecuteProgramNV_names, ExecuteProgramNV_remap_index, -1 },
-    { VertexAttribPointerNV_names, VertexAttribPointerNV_remap_index, -1 },
-    { TrackMatrixNV_names, TrackMatrixNV_remap_index, -1 },
-    { GetProgramParameterdvNV_names, GetProgramParameterdvNV_remap_index, -1 },
-    { GetTrackMatrixivNV_names, GetTrackMatrixivNV_remap_index, -1 },
-    { VertexAttrib3svNV_names, VertexAttrib3svNV_remap_index, -1 },
-    { ProgramParameters4fvNV_names, ProgramParameters4fvNV_remap_index, -1 },
-    { GetProgramivNV_names, GetProgramivNV_remap_index, -1 },
-    { GetVertexAttribdvNV_names, GetVertexAttribdvNV_remap_index, -1 },
-    { VertexAttrib3fvNV_names, VertexAttrib3fvNV_remap_index, -1 },
-    { ProgramEnvParameter4dvARB_names, ProgramEnvParameter4dvARB_remap_index, -1 },
-    { VertexAttribs2fvNV_names, VertexAttribs2fvNV_remap_index, -1 },
-    { DeleteProgramsNV_names, DeleteProgramsNV_remap_index, -1 },
-    { GetVertexAttribPointervNV_names, GetVertexAttribPointervNV_remap_index, -1 },
-    { GetProgramStringNV_names, GetProgramStringNV_remap_index, -1 },
-    { VertexAttrib4sNV_names, VertexAttrib4sNV_remap_index, -1 },
-    { VertexAttribs4dvNV_names, VertexAttribs4dvNV_remap_index, -1 },
-    { ProgramParameters4dvNV_names, ProgramParameters4dvNV_remap_index, -1 },
-    { VertexAttrib3sNV_names, VertexAttrib3sNV_remap_index, -1 },
-    { VertexAttrib1fNV_names, VertexAttrib1fNV_remap_index, -1 },
-    { VertexAttrib4dNV_names, VertexAttrib4dNV_remap_index, -1 },
-    { VertexAttribs4ubvNV_names, VertexAttribs4ubvNV_remap_index, -1 },
-    { VertexAttribs3svNV_names, VertexAttribs3svNV_remap_index, -1 },
-    { VertexAttrib1sNV_names, VertexAttrib1sNV_remap_index, -1 },
-    { BindProgramNV_names, BindProgramNV_remap_index, -1 },
-    { AreProgramsResidentNV_names, AreProgramsResidentNV_remap_index, -1 },
-    { VertexAttrib3dvNV_names, VertexAttrib3dvNV_remap_index, -1 },
-    { VertexAttrib1dNV_names, VertexAttrib1dNV_remap_index, -1 },
-    { VertexAttribs4svNV_names, VertexAttribs4svNV_remap_index, -1 },
-    { VertexAttribs1svNV_names, VertexAttribs1svNV_remap_index, -1 },
-    { GenProgramsNV_names, GenProgramsNV_remap_index, -1 },
-    { VertexAttrib4dvNV_names, VertexAttrib4dvNV_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_PGI_misc_hints)
-static const struct dri_extension_function GL_PGI_misc_hints_functions[] = {
-    { HintPGI_names, HintPGI_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_SGIS_detail_texture)
-static const struct dri_extension_function GL_SGIS_detail_texture_functions[] = {
-    { GetDetailTexFuncSGIS_names, GetDetailTexFuncSGIS_remap_index, -1 },
-    { DetailTexFuncSGIS_names, DetailTexFuncSGIS_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_SGIS_fog_function)
-static const struct dri_extension_function GL_SGIS_fog_function_functions[] = {
-    { FogFuncSGIS_names, FogFuncSGIS_remap_index, -1 },
-    { GetFogFuncSGIS_names, GetFogFuncSGIS_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_SGIS_multisample)
-static const struct dri_extension_function GL_SGIS_multisample_functions[] = {
-    { SampleMaskSGIS_names, SampleMaskSGIS_remap_index, -1 },
-    { SamplePatternSGIS_names, SamplePatternSGIS_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_SGIS_pixel_texture)
-static const struct dri_extension_function GL_SGIS_pixel_texture_functions[] = {
-    { PixelTexGenParameterfvSGIS_names, PixelTexGenParameterfvSGIS_remap_index, -1 },
-    { GetPixelTexGenParameterivSGIS_names, GetPixelTexGenParameterivSGIS_remap_index, -1 },
-    { PixelTexGenParameteriSGIS_names, PixelTexGenParameteriSGIS_remap_index, -1 },
-    { PixelTexGenParameterivSGIS_names, PixelTexGenParameterivSGIS_remap_index, -1 },
-    { PixelTexGenParameterfSGIS_names, PixelTexGenParameterfSGIS_remap_index, -1 },
-    { GetPixelTexGenParameterfvSGIS_names, GetPixelTexGenParameterfvSGIS_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_SGIS_point_parameters)
-static const struct dri_extension_function GL_SGIS_point_parameters_functions[] = {
-    { PointParameterfEXT_names, PointParameterfEXT_remap_index, -1 },
-    { PointParameterfvEXT_names, PointParameterfvEXT_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_SGIS_sharpen_texture)
-static const struct dri_extension_function GL_SGIS_sharpen_texture_functions[] = {
-    { GetSharpenTexFuncSGIS_names, GetSharpenTexFuncSGIS_remap_index, -1 },
-    { SharpenTexFuncSGIS_names, SharpenTexFuncSGIS_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_SGIS_texture4D)
-static const struct dri_extension_function GL_SGIS_texture4D_functions[] = {
-    { TexImage4DSGIS_names, TexImage4DSGIS_remap_index, -1 },
-    { TexSubImage4DSGIS_names, TexSubImage4DSGIS_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_SGIS_texture_color_mask)
-static const struct dri_extension_function GL_SGIS_texture_color_mask_functions[] = {
-    { TextureColorMaskSGIS_names, TextureColorMaskSGIS_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_SGIS_texture_filter4)
-static const struct dri_extension_function GL_SGIS_texture_filter4_functions[] = {
-    { GetTexFilterFuncSGIS_names, GetTexFilterFuncSGIS_remap_index, -1 },
-    { TexFilterFuncSGIS_names, TexFilterFuncSGIS_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_SGIX_async)
-static const struct dri_extension_function GL_SGIX_async_functions[] = {
-    { AsyncMarkerSGIX_names, AsyncMarkerSGIX_remap_index, -1 },
-    { FinishAsyncSGIX_names, FinishAsyncSGIX_remap_index, -1 },
-    { PollAsyncSGIX_names, PollAsyncSGIX_remap_index, -1 },
-    { DeleteAsyncMarkersSGIX_names, DeleteAsyncMarkersSGIX_remap_index, -1 },
-    { IsAsyncMarkerSGIX_names, IsAsyncMarkerSGIX_remap_index, -1 },
-    { GenAsyncMarkersSGIX_names, GenAsyncMarkersSGIX_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_SGIX_flush_raster)
-static const struct dri_extension_function GL_SGIX_flush_raster_functions[] = {
-    { FlushRasterSGIX_names, FlushRasterSGIX_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_SGIX_fragment_lighting)
-static const struct dri_extension_function GL_SGIX_fragment_lighting_functions[] = {
-    { FragmentMaterialfvSGIX_names, FragmentMaterialfvSGIX_remap_index, -1 },
-    { FragmentLightModelivSGIX_names, FragmentLightModelivSGIX_remap_index, -1 },
-    { FragmentLightiSGIX_names, FragmentLightiSGIX_remap_index, -1 },
-    { GetFragmentMaterialfvSGIX_names, GetFragmentMaterialfvSGIX_remap_index, -1 },
-    { FragmentMaterialfSGIX_names, FragmentMaterialfSGIX_remap_index, -1 },
-    { GetFragmentLightivSGIX_names, GetFragmentLightivSGIX_remap_index, -1 },
-    { FragmentLightModeliSGIX_names, FragmentLightModeliSGIX_remap_index, -1 },
-    { FragmentLightivSGIX_names, FragmentLightivSGIX_remap_index, -1 },
-    { GetFragmentMaterialivSGIX_names, GetFragmentMaterialivSGIX_remap_index, -1 },
-    { FragmentLightModelfSGIX_names, FragmentLightModelfSGIX_remap_index, -1 },
-    { FragmentColorMaterialSGIX_names, FragmentColorMaterialSGIX_remap_index, -1 },
-    { FragmentMaterialiSGIX_names, FragmentMaterialiSGIX_remap_index, -1 },
-    { LightEnviSGIX_names, LightEnviSGIX_remap_index, -1 },
-    { FragmentLightModelfvSGIX_names, FragmentLightModelfvSGIX_remap_index, -1 },
-    { FragmentLightfvSGIX_names, FragmentLightfvSGIX_remap_index, -1 },
-    { FragmentLightfSGIX_names, FragmentLightfSGIX_remap_index, -1 },
-    { GetFragmentLightfvSGIX_names, GetFragmentLightfvSGIX_remap_index, -1 },
-    { FragmentMaterialivSGIX_names, FragmentMaterialivSGIX_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_SGIX_framezoom)
-static const struct dri_extension_function GL_SGIX_framezoom_functions[] = {
-    { FrameZoomSGIX_names, FrameZoomSGIX_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_SGIX_igloo_interface)
-static const struct dri_extension_function GL_SGIX_igloo_interface_functions[] = {
-    { IglooInterfaceSGIX_names, IglooInterfaceSGIX_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_SGIX_instruments)
-static const struct dri_extension_function GL_SGIX_instruments_functions[] = {
-    { ReadInstrumentsSGIX_names, ReadInstrumentsSGIX_remap_index, -1 },
-    { PollInstrumentsSGIX_names, PollInstrumentsSGIX_remap_index, -1 },
-    { GetInstrumentsSGIX_names, GetInstrumentsSGIX_remap_index, -1 },
-    { StartInstrumentsSGIX_names, StartInstrumentsSGIX_remap_index, -1 },
-    { StopInstrumentsSGIX_names, StopInstrumentsSGIX_remap_index, -1 },
-    { InstrumentsBufferSGIX_names, InstrumentsBufferSGIX_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_SGIX_list_priority)
-static const struct dri_extension_function GL_SGIX_list_priority_functions[] = {
-    { ListParameterfSGIX_names, ListParameterfSGIX_remap_index, -1 },
-    { GetListParameterfvSGIX_names, GetListParameterfvSGIX_remap_index, -1 },
-    { ListParameteriSGIX_names, ListParameteriSGIX_remap_index, -1 },
-    { ListParameterfvSGIX_names, ListParameterfvSGIX_remap_index, -1 },
-    { ListParameterivSGIX_names, ListParameterivSGIX_remap_index, -1 },
-    { GetListParameterivSGIX_names, GetListParameterivSGIX_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_SGIX_pixel_texture)
-static const struct dri_extension_function GL_SGIX_pixel_texture_functions[] = {
-    { PixelTexGenSGIX_names, PixelTexGenSGIX_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_SGIX_polynomial_ffd)
-static const struct dri_extension_function GL_SGIX_polynomial_ffd_functions[] = {
-    { LoadIdentityDeformationMapSGIX_names, LoadIdentityDeformationMapSGIX_remap_index, -1 },
-    { DeformationMap3dSGIX_names, DeformationMap3dSGIX_remap_index, -1 },
-    { DeformSGIX_names, DeformSGIX_remap_index, -1 },
-    { DeformationMap3fSGIX_names, DeformationMap3fSGIX_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_SGIX_reference_plane)
-static const struct dri_extension_function GL_SGIX_reference_plane_functions[] = {
-    { ReferencePlaneSGIX_names, ReferencePlaneSGIX_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_SGIX_sprite)
-static const struct dri_extension_function GL_SGIX_sprite_functions[] = {
-    { SpriteParameterfvSGIX_names, SpriteParameterfvSGIX_remap_index, -1 },
-    { SpriteParameteriSGIX_names, SpriteParameteriSGIX_remap_index, -1 },
-    { SpriteParameterfSGIX_names, SpriteParameterfSGIX_remap_index, -1 },
-    { SpriteParameterivSGIX_names, SpriteParameterivSGIX_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_SGIX_tag_sample_buffer)
-static const struct dri_extension_function GL_SGIX_tag_sample_buffer_functions[] = {
-    { TagSampleBufferSGIX_names, TagSampleBufferSGIX_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_SGI_color_table)
-static const struct dri_extension_function GL_SGI_color_table_functions[] = {
-    { ColorTableParameteriv_names, -1, 341 },
-    { ColorTable_names, -1, 339 },
-    { GetColorTable_names, -1, 343 },
-    { CopyColorTable_names, -1, 342 },
-    { ColorTableParameterfv_names, -1, 340 },
-    { GetColorTableParameterfv_names, -1, 344 },
-    { GetColorTableParameteriv_names, -1, 345 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_SUNX_constant_data)
-static const struct dri_extension_function GL_SUNX_constant_data_functions[] = {
-    { FinishTextureSUNX_names, FinishTextureSUNX_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_SUN_global_alpha)
-static const struct dri_extension_function GL_SUN_global_alpha_functions[] = {
-    { GlobalAlphaFactorubSUN_names, GlobalAlphaFactorubSUN_remap_index, -1 },
-    { GlobalAlphaFactoriSUN_names, GlobalAlphaFactoriSUN_remap_index, -1 },
-    { GlobalAlphaFactordSUN_names, GlobalAlphaFactordSUN_remap_index, -1 },
-    { GlobalAlphaFactoruiSUN_names, GlobalAlphaFactoruiSUN_remap_index, -1 },
-    { GlobalAlphaFactorbSUN_names, GlobalAlphaFactorbSUN_remap_index, -1 },
-    { GlobalAlphaFactorfSUN_names, GlobalAlphaFactorfSUN_remap_index, -1 },
-    { GlobalAlphaFactorusSUN_names, GlobalAlphaFactorusSUN_remap_index, -1 },
-    { GlobalAlphaFactorsSUN_names, GlobalAlphaFactorsSUN_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_SUN_mesh_array)
-static const struct dri_extension_function GL_SUN_mesh_array_functions[] = {
-    { DrawMeshArraysSUN_names, DrawMeshArraysSUN_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_SUN_triangle_list)
-static const struct dri_extension_function GL_SUN_triangle_list_functions[] = {
-    { ReplacementCodeubSUN_names, ReplacementCodeubSUN_remap_index, -1 },
-    { ReplacementCodeubvSUN_names, ReplacementCodeubvSUN_remap_index, -1 },
-    { ReplacementCodeusvSUN_names, ReplacementCodeusvSUN_remap_index, -1 },
-    { ReplacementCodePointerSUN_names, ReplacementCodePointerSUN_remap_index, -1 },
-    { ReplacementCodeusSUN_names, ReplacementCodeusSUN_remap_index, -1 },
-    { ReplacementCodeuiSUN_names, ReplacementCodeuiSUN_remap_index, -1 },
-    { ReplacementCodeuivSUN_names, ReplacementCodeuivSUN_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_SUN_vertex)
-static const struct dri_extension_function GL_SUN_vertex_functions[] = {
-    { ReplacementCodeuiColor3fVertex3fvSUN_names, ReplacementCodeuiColor3fVertex3fvSUN_remap_index, -1 },
-    { TexCoord4fColor4fNormal3fVertex4fvSUN_names, TexCoord4fColor4fNormal3fVertex4fvSUN_remap_index, -1 },
-    { TexCoord2fColor4ubVertex3fvSUN_names, TexCoord2fColor4ubVertex3fvSUN_remap_index, -1 },
-    { ReplacementCodeuiVertex3fvSUN_names, ReplacementCodeuiVertex3fvSUN_remap_index, -1 },
-    { ReplacementCodeuiTexCoord2fVertex3fvSUN_names, ReplacementCodeuiTexCoord2fVertex3fvSUN_remap_index, -1 },
-    { ReplacementCodeuiNormal3fVertex3fSUN_names, ReplacementCodeuiNormal3fVertex3fSUN_remap_index, -1 },
-    { Color4ubVertex3fvSUN_names, Color4ubVertex3fvSUN_remap_index, -1 },
-    { Color4ubVertex3fSUN_names, Color4ubVertex3fSUN_remap_index, -1 },
-    { TexCoord2fVertex3fSUN_names, TexCoord2fVertex3fSUN_remap_index, -1 },
-    { TexCoord2fColor4fNormal3fVertex3fSUN_names, TexCoord2fColor4fNormal3fVertex3fSUN_remap_index, -1 },
-    { TexCoord2fNormal3fVertex3fvSUN_names, TexCoord2fNormal3fVertex3fvSUN_remap_index, -1 },
-    { ReplacementCodeuiTexCoord2fNormal3fVertex3fSUN_names, ReplacementCodeuiTexCoord2fNormal3fVertex3fSUN_remap_index, -1 },
-    { ReplacementCodeuiTexCoord2fVertex3fSUN_names, ReplacementCodeuiTexCoord2fVertex3fSUN_remap_index, -1 },
-    { TexCoord2fNormal3fVertex3fSUN_names, TexCoord2fNormal3fVertex3fSUN_remap_index, -1 },
-    { Color3fVertex3fSUN_names, Color3fVertex3fSUN_remap_index, -1 },
-    { Color3fVertex3fvSUN_names, Color3fVertex3fvSUN_remap_index, -1 },
-    { Color4fNormal3fVertex3fvSUN_names, Color4fNormal3fVertex3fvSUN_remap_index, -1 },
-    { ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN_names, ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN_remap_index, -1 },
-    { ReplacementCodeuiColor4fNormal3fVertex3fvSUN_names, ReplacementCodeuiColor4fNormal3fVertex3fvSUN_remap_index, -1 },
-    { ReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN_names, ReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN_remap_index, -1 },
-    { TexCoord2fColor3fVertex3fSUN_names, TexCoord2fColor3fVertex3fSUN_remap_index, -1 },
-    { TexCoord4fColor4fNormal3fVertex4fSUN_names, TexCoord4fColor4fNormal3fVertex4fSUN_remap_index, -1 },
-    { Color4ubVertex2fvSUN_names, Color4ubVertex2fvSUN_remap_index, -1 },
-    { Normal3fVertex3fSUN_names, Normal3fVertex3fSUN_remap_index, -1 },
-    { ReplacementCodeuiColor4fNormal3fVertex3fSUN_names, ReplacementCodeuiColor4fNormal3fVertex3fSUN_remap_index, -1 },
-    { TexCoord2fColor4fNormal3fVertex3fvSUN_names, TexCoord2fColor4fNormal3fVertex3fvSUN_remap_index, -1 },
-    { TexCoord2fVertex3fvSUN_names, TexCoord2fVertex3fvSUN_remap_index, -1 },
-    { Color4ubVertex2fSUN_names, Color4ubVertex2fSUN_remap_index, -1 },
-    { ReplacementCodeuiColor4ubVertex3fSUN_names, ReplacementCodeuiColor4ubVertex3fSUN_remap_index, -1 },
-    { TexCoord2fColor4ubVertex3fSUN_names, TexCoord2fColor4ubVertex3fSUN_remap_index, -1 },
-    { Normal3fVertex3fvSUN_names, Normal3fVertex3fvSUN_remap_index, -1 },
-    { Color4fNormal3fVertex3fSUN_names, Color4fNormal3fVertex3fSUN_remap_index, -1 },
-    { ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN_names, ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN_remap_index, -1 },
-    { ReplacementCodeuiColor4ubVertex3fvSUN_names, ReplacementCodeuiColor4ubVertex3fvSUN_remap_index, -1 },
-    { ReplacementCodeuiColor3fVertex3fSUN_names, ReplacementCodeuiColor3fVertex3fSUN_remap_index, -1 },
-    { TexCoord4fVertex4fSUN_names, TexCoord4fVertex4fSUN_remap_index, -1 },
-    { TexCoord2fColor3fVertex3fvSUN_names, TexCoord2fColor3fVertex3fvSUN_remap_index, -1 },
-    { ReplacementCodeuiNormal3fVertex3fvSUN_names, ReplacementCodeuiNormal3fVertex3fvSUN_remap_index, -1 },
-    { TexCoord4fVertex4fvSUN_names, TexCoord4fVertex4fvSUN_remap_index, -1 },
-    { ReplacementCodeuiVertex3fSUN_names, ReplacementCodeuiVertex3fSUN_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_VERSION_1_3)
-static const struct dri_extension_function GL_VERSION_1_3_functions[] = {
-    { SampleCoverageARB_names, SampleCoverageARB_remap_index, -1 },
-    { MultiTexCoord3sARB_names, -1, 398 },
-    { ActiveTextureARB_names, -1, 374 },
-    { CompressedTexSubImage2DARB_names, CompressedTexSubImage2DARB_remap_index, -1 },
-    { CompressedTexImage3DARB_names, CompressedTexImage3DARB_remap_index, -1 },
-    { MultiTexCoord1fvARB_names, -1, 379 },
-    { MultTransposeMatrixdARB_names, MultTransposeMatrixdARB_remap_index, -1 },
-    { CompressedTexImage1DARB_names, CompressedTexImage1DARB_remap_index, -1 },
-    { MultiTexCoord3dARB_names, -1, 392 },
-    { MultiTexCoord2iARB_names, -1, 388 },
-    { MultiTexCoord2svARB_names, -1, 391 },
-    { MultiTexCoord2fARB_names, -1, 386 },
-    { LoadTransposeMatrixdARB_names, LoadTransposeMatrixdARB_remap_index, -1 },
-    { MultiTexCoord3fvARB_names, -1, 395 },
-    { MultiTexCoord4sARB_names, -1, 406 },
-    { MultiTexCoord2dvARB_names, -1, 385 },
-    { MultiTexCoord1svARB_names, -1, 383 },
-    { MultiTexCoord3svARB_names, -1, 399 },
-    { MultiTexCoord4iARB_names, -1, 404 },
-    { MultiTexCoord3iARB_names, -1, 396 },
-    { MultiTexCoord1dARB_names, -1, 376 },
-    { MultiTexCoord3dvARB_names, -1, 393 },
-    { MultiTexCoord3ivARB_names, -1, 397 },
-    { MultiTexCoord2sARB_names, -1, 390 },
-    { MultiTexCoord4ivARB_names, -1, 405 },
-    { CompressedTexSubImage1DARB_names, CompressedTexSubImage1DARB_remap_index, -1 },
-    { ClientActiveTextureARB_names, -1, 375 },
-    { CompressedTexSubImage3DARB_names, CompressedTexSubImage3DARB_remap_index, -1 },
-    { MultiTexCoord2dARB_names, -1, 384 },
-    { MultiTexCoord4dvARB_names, -1, 401 },
-    { MultiTexCoord4fvARB_names, -1, 403 },
-    { MultiTexCoord3fARB_names, -1, 394 },
-    { MultTransposeMatrixfARB_names, MultTransposeMatrixfARB_remap_index, -1 },
-    { CompressedTexImage2DARB_names, CompressedTexImage2DARB_remap_index, -1 },
-    { MultiTexCoord4dARB_names, -1, 400 },
-    { MultiTexCoord1sARB_names, -1, 382 },
-    { MultiTexCoord1dvARB_names, -1, 377 },
-    { MultiTexCoord1ivARB_names, -1, 381 },
-    { MultiTexCoord2ivARB_names, -1, 389 },
-    { MultiTexCoord1iARB_names, -1, 380 },
-    { GetCompressedTexImageARB_names, GetCompressedTexImageARB_remap_index, -1 },
-    { MultiTexCoord4svARB_names, -1, 407 },
-    { MultiTexCoord1fARB_names, -1, 378 },
-    { MultiTexCoord4fARB_names, -1, 402 },
-    { LoadTransposeMatrixfARB_names, LoadTransposeMatrixfARB_remap_index, -1 },
-    { MultiTexCoord2fvARB_names, -1, 387 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_VERSION_1_4)
-static const struct dri_extension_function GL_VERSION_1_4_functions[] = {
-    { PointParameteriNV_names, PointParameteriNV_remap_index, -1 },
-    { SecondaryColor3iEXT_names, SecondaryColor3iEXT_remap_index, -1 },
-    { WindowPos3fMESA_names, WindowPos3fMESA_remap_index, -1 },
-    { WindowPos2dvMESA_names, WindowPos2dvMESA_remap_index, -1 },
-    { SecondaryColor3bEXT_names, SecondaryColor3bEXT_remap_index, -1 },
-    { PointParameterfEXT_names, PointParameterfEXT_remap_index, -1 },
-    { FogCoorddEXT_names, FogCoorddEXT_remap_index, -1 },
-    { FogCoordfEXT_names, FogCoordfEXT_remap_index, -1 },
-    { WindowPos2svMESA_names, WindowPos2svMESA_remap_index, -1 },
-    { WindowPos3dMESA_names, WindowPos3dMESA_remap_index, -1 },
-    { PointParameterfvEXT_names, PointParameterfvEXT_remap_index, -1 },
-    { WindowPos2fvMESA_names, WindowPos2fvMESA_remap_index, -1 },
-    { SecondaryColor3bvEXT_names, SecondaryColor3bvEXT_remap_index, -1 },
-    { SecondaryColor3sEXT_names, SecondaryColor3sEXT_remap_index, -1 },
-    { SecondaryColor3dEXT_names, SecondaryColor3dEXT_remap_index, -1 },
-    { WindowPos2dMESA_names, WindowPos2dMESA_remap_index, -1 },
-    { SecondaryColorPointerEXT_names, SecondaryColorPointerEXT_remap_index, -1 },
-    { SecondaryColor3uiEXT_names, SecondaryColor3uiEXT_remap_index, -1 },
-    { SecondaryColor3usvEXT_names, SecondaryColor3usvEXT_remap_index, -1 },
-    { WindowPos3dvMESA_names, WindowPos3dvMESA_remap_index, -1 },
-    { PointParameterivNV_names, PointParameterivNV_remap_index, -1 },
-    { WindowPos3fvMESA_names, WindowPos3fvMESA_remap_index, -1 },
-    { SecondaryColor3ivEXT_names, SecondaryColor3ivEXT_remap_index, -1 },
-    { WindowPos2iMESA_names, WindowPos2iMESA_remap_index, -1 },
-    { SecondaryColor3fvEXT_names, SecondaryColor3fvEXT_remap_index, -1 },
-    { WindowPos3sMESA_names, WindowPos3sMESA_remap_index, -1 },
-    { WindowPos2ivMESA_names, WindowPos2ivMESA_remap_index, -1 },
-    { MultiDrawElementsEXT_names, MultiDrawElementsEXT_remap_index, -1 },
-    { WindowPos2sMESA_names, WindowPos2sMESA_remap_index, -1 },
-    { FogCoordPointerEXT_names, FogCoordPointerEXT_remap_index, -1 },
-    { SecondaryColor3ubvEXT_names, SecondaryColor3ubvEXT_remap_index, -1 },
-    { SecondaryColor3uivEXT_names, SecondaryColor3uivEXT_remap_index, -1 },
-    { WindowPos3iMESA_names, WindowPos3iMESA_remap_index, -1 },
-    { SecondaryColor3dvEXT_names, SecondaryColor3dvEXT_remap_index, -1 },
-    { MultiDrawArraysEXT_names, MultiDrawArraysEXT_remap_index, -1 },
-    { SecondaryColor3usEXT_names, SecondaryColor3usEXT_remap_index, -1 },
-    { FogCoordfvEXT_names, FogCoordfvEXT_remap_index, -1 },
-    { SecondaryColor3ubEXT_names, SecondaryColor3ubEXT_remap_index, -1 },
-    { BlendFuncSeparateEXT_names, BlendFuncSeparateEXT_remap_index, -1 },
-    { SecondaryColor3fEXT_names, SecondaryColor3fEXT_remap_index, -1 },
-    { WindowPos3ivMESA_names, WindowPos3ivMESA_remap_index, -1 },
-    { SecondaryColor3svEXT_names, SecondaryColor3svEXT_remap_index, -1 },
-    { FogCoorddvEXT_names, FogCoorddvEXT_remap_index, -1 },
-    { WindowPos3svMESA_names, WindowPos3svMESA_remap_index, -1 },
-    { WindowPos2fMESA_names, WindowPos2fMESA_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_VERSION_1_5)
-static const struct dri_extension_function GL_VERSION_1_5_functions[] = {
-    { BeginQueryARB_names, BeginQueryARB_remap_index, -1 },
-    { GetBufferSubDataARB_names, GetBufferSubDataARB_remap_index, -1 },
-    { BufferSubDataARB_names, BufferSubDataARB_remap_index, -1 },
-    { GetQueryivARB_names, GetQueryivARB_remap_index, -1 },
-    { GetQueryObjectivARB_names, GetQueryObjectivARB_remap_index, -1 },
-    { BufferDataARB_names, BufferDataARB_remap_index, -1 },
-    { EndQueryARB_names, EndQueryARB_remap_index, -1 },
-    { GetBufferPointervARB_names, GetBufferPointervARB_remap_index, -1 },
-    { GetQueryObjectuivARB_names, GetQueryObjectuivARB_remap_index, -1 },
-    { GetBufferParameterivARB_names, GetBufferParameterivARB_remap_index, -1 },
-    { DeleteQueriesARB_names, DeleteQueriesARB_remap_index, -1 },
-    { IsQueryARB_names, IsQueryARB_remap_index, -1 },
-    { MapBufferARB_names, MapBufferARB_remap_index, -1 },
-    { GenQueriesARB_names, GenQueriesARB_remap_index, -1 },
-    { IsBufferARB_names, IsBufferARB_remap_index, -1 },
-    { DeleteBuffersARB_names, DeleteBuffersARB_remap_index, -1 },
-    { UnmapBufferARB_names, UnmapBufferARB_remap_index, -1 },
-    { BindBufferARB_names, BindBufferARB_remap_index, -1 },
-    { GenBuffersARB_names, GenBuffersARB_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_VERSION_2_0)
-static const struct dri_extension_function GL_VERSION_2_0_functions[] = {
-    { UniformMatrix3fvARB_names, UniformMatrix3fvARB_remap_index, -1 },
-    { GetProgramiv_names, GetProgramiv_remap_index, -1 },
-    { BlendEquationSeparateEXT_names, BlendEquationSeparateEXT_remap_index, -1 },
-    { AttachShader_names, AttachShader_remap_index, -1 },
-    { VertexAttrib2fARB_names, VertexAttrib2fARB_remap_index, -1 },
-    { VertexAttrib3fARB_names, VertexAttrib3fARB_remap_index, -1 },
-    { Uniform2fARB_names, Uniform2fARB_remap_index, -1 },
-    { VertexAttrib1svARB_names, VertexAttrib1svARB_remap_index, -1 },
-    { Uniform2ivARB_names, Uniform2ivARB_remap_index, -1 },
-    { UniformMatrix4fvARB_names, UniformMatrix4fvARB_remap_index, -1 },
-    { VertexAttrib4NusvARB_names, VertexAttrib4NusvARB_remap_index, -1 },
-    { DisableVertexAttribArrayARB_names, DisableVertexAttribArrayARB_remap_index, -1 },
-    { StencilMaskSeparate_names, StencilMaskSeparate_remap_index, -1 },
-    { VertexAttrib1fARB_names, VertexAttrib1fARB_remap_index, -1 },
-    { GetProgramInfoLog_names, GetProgramInfoLog_remap_index, -1 },
-    { VertexAttrib4NbvARB_names, VertexAttrib4NbvARB_remap_index, -1 },
-    { GetActiveAttribARB_names, GetActiveAttribARB_remap_index, -1 },
-    { Uniform3iARB_names, Uniform3iARB_remap_index, -1 },
-    { GetShaderInfoLog_names, GetShaderInfoLog_remap_index, -1 },
-    { VertexAttrib1sARB_names, VertexAttrib1sARB_remap_index, -1 },
-    { Uniform1fARB_names, Uniform1fARB_remap_index, -1 },
-    { StencilOpSeparate_names, StencilOpSeparate_remap_index, -1 },
-    { UniformMatrix2fvARB_names, UniformMatrix2fvARB_remap_index, -1 },
-    { VertexAttrib3dvARB_names, VertexAttrib3dvARB_remap_index, -1 },
-    { Uniform3fvARB_names, Uniform3fvARB_remap_index, -1 },
-    { GetVertexAttribivARB_names, GetVertexAttribivARB_remap_index, -1 },
-    { CreateProgram_names, CreateProgram_remap_index, -1 },
-    { StencilFuncSeparate_names, StencilFuncSeparate_remap_index, -1 },
-    { VertexAttrib4ivARB_names, VertexAttrib4ivARB_remap_index, -1 },
-    { VertexAttrib4bvARB_names, VertexAttrib4bvARB_remap_index, -1 },
-    { VertexAttrib3dARB_names, VertexAttrib3dARB_remap_index, -1 },
-    { VertexAttrib4fARB_names, VertexAttrib4fARB_remap_index, -1 },
-    { VertexAttrib4fvARB_names, VertexAttrib4fvARB_remap_index, -1 },
-    { GetActiveUniformARB_names, GetActiveUniformARB_remap_index, -1 },
-    { IsShader_names, IsShader_remap_index, -1 },
-    { GetUniformivARB_names, GetUniformivARB_remap_index, -1 },
-    { IsProgram_names, IsProgram_remap_index, -1 },
-    { Uniform2fvARB_names, Uniform2fvARB_remap_index, -1 },
-    { ValidateProgramARB_names, ValidateProgramARB_remap_index, -1 },
-    { VertexAttrib2dARB_names, VertexAttrib2dARB_remap_index, -1 },
-    { VertexAttrib1dvARB_names, VertexAttrib1dvARB_remap_index, -1 },
-    { GetVertexAttribfvARB_names, GetVertexAttribfvARB_remap_index, -1 },
-    { GetAttribLocationARB_names, GetAttribLocationARB_remap_index, -1 },
-    { VertexAttrib4ubvARB_names, VertexAttrib4ubvARB_remap_index, -1 },
-    { Uniform3ivARB_names, Uniform3ivARB_remap_index, -1 },
-    { VertexAttrib4sARB_names, VertexAttrib4sARB_remap_index, -1 },
-    { VertexAttrib2dvARB_names, VertexAttrib2dvARB_remap_index, -1 },
-    { VertexAttrib2fvARB_names, VertexAttrib2fvARB_remap_index, -1 },
-    { VertexAttrib4NivARB_names, VertexAttrib4NivARB_remap_index, -1 },
-    { GetAttachedShaders_names, GetAttachedShaders_remap_index, -1 },
-    { CompileShaderARB_names, CompileShaderARB_remap_index, -1 },
-    { DeleteShader_names, DeleteShader_remap_index, -1 },
-    { Uniform3fARB_names, Uniform3fARB_remap_index, -1 },
-    { VertexAttrib4NuivARB_names, VertexAttrib4NuivARB_remap_index, -1 },
-    { Uniform4fARB_names, Uniform4fARB_remap_index, -1 },
-    { VertexAttrib1dARB_names, VertexAttrib1dARB_remap_index, -1 },
-    { VertexAttrib4usvARB_names, VertexAttrib4usvARB_remap_index, -1 },
-    { LinkProgramARB_names, LinkProgramARB_remap_index, -1 },
-    { ShaderSourceARB_names, ShaderSourceARB_remap_index, -1 },
-    { VertexAttrib3svARB_names, VertexAttrib3svARB_remap_index, -1 },
-    { Uniform4ivARB_names, Uniform4ivARB_remap_index, -1 },
-    { GetVertexAttribdvARB_names, GetVertexAttribdvARB_remap_index, -1 },
-    { Uniform1ivARB_names, Uniform1ivARB_remap_index, -1 },
-    { VertexAttrib4dvARB_names, VertexAttrib4dvARB_remap_index, -1 },
-    { BindAttribLocationARB_names, BindAttribLocationARB_remap_index, -1 },
-    { Uniform1iARB_names, Uniform1iARB_remap_index, -1 },
-    { VertexAttribPointerARB_names, VertexAttribPointerARB_remap_index, -1 },
-    { VertexAttrib4NsvARB_names, VertexAttrib4NsvARB_remap_index, -1 },
-    { VertexAttrib3fvARB_names, VertexAttrib3fvARB_remap_index, -1 },
-    { CreateShader_names, CreateShader_remap_index, -1 },
-    { DetachShader_names, DetachShader_remap_index, -1 },
-    { VertexAttrib4NubARB_names, VertexAttrib4NubARB_remap_index, -1 },
-    { Uniform4fvARB_names, Uniform4fvARB_remap_index, -1 },
-    { GetUniformfvARB_names, GetUniformfvARB_remap_index, -1 },
-    { Uniform4iARB_names, Uniform4iARB_remap_index, -1 },
-    { UseProgramObjectARB_names, UseProgramObjectARB_remap_index, -1 },
-    { DeleteProgram_names, DeleteProgram_remap_index, -1 },
-    { GetVertexAttribPointervNV_names, GetVertexAttribPointervNV_remap_index, -1 },
-    { Uniform2iARB_names, Uniform2iARB_remap_index, -1 },
-    { VertexAttrib4dARB_names, VertexAttrib4dARB_remap_index, -1 },
-    { GetUniformLocationARB_names, GetUniformLocationARB_remap_index, -1 },
-    { VertexAttrib3sARB_names, VertexAttrib3sARB_remap_index, -1 },
-    { GetShaderSourceARB_names, GetShaderSourceARB_remap_index, -1 },
-    { DrawBuffersARB_names, DrawBuffersARB_remap_index, -1 },
-    { Uniform1fvARB_names, Uniform1fvARB_remap_index, -1 },
-    { EnableVertexAttribArrayARB_names, EnableVertexAttribArrayARB_remap_index, -1 },
-    { VertexAttrib4uivARB_names, VertexAttrib4uivARB_remap_index, -1 },
-    { VertexAttrib4svARB_names, VertexAttrib4svARB_remap_index, -1 },
-    { GetShaderiv_names, GetShaderiv_remap_index, -1 },
-    { VertexAttrib2svARB_names, VertexAttrib2svARB_remap_index, -1 },
-    { VertexAttrib4NubvARB_names, VertexAttrib4NubvARB_remap_index, -1 },
-    { VertexAttrib2sARB_names, VertexAttrib2sARB_remap_index, -1 },
-    { VertexAttrib1fvARB_names, VertexAttrib1fvARB_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
-#if defined(need_GL_VERSION_2_1)
-static const struct dri_extension_function GL_VERSION_2_1_functions[] = {
-    { UniformMatrix2x4fv_names, UniformMatrix2x4fv_remap_index, -1 },
-    { UniformMatrix4x3fv_names, UniformMatrix4x3fv_remap_index, -1 },
-    { UniformMatrix4x2fv_names, UniformMatrix4x2fv_remap_index, -1 },
-    { UniformMatrix2x3fv_names, UniformMatrix2x3fv_remap_index, -1 },
-    { UniformMatrix3x4fv_names, UniformMatrix3x4fv_remap_index, -1 },
-    { UniformMatrix3x2fv_names, UniformMatrix3x2fv_remap_index, -1 },
-    { NULL, 0, 0 }
-};
-#endif
-
index 89c815722f6a2a7e70ae6020c6c7a7454d44453c..447f3d15b9516c2c7aca30f47beb68caaf6bde76 100644 (file)
       rgba[3] = 0xff;                                                  \
    } while (0)
 
+#elif (SPANTMP_PIXEL_FMT == GL_RGB)  && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_5_6_5_REV)
+
+/**
+ ** GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV
+ **/
+
+#ifndef GET_VALUE
+#ifndef GET_PTR
+#define GET_PTR(_x, _y) (buf + (_x) * 2 + (_y) * pitch)
+#endif
+
+#define GET_VALUE(_x, _y) *(volatile GLushort *)(GET_PTR(_x, _y))
+#define PUT_VALUE(_x, _y, _v) *(volatile GLushort *)(GET_PTR(_x, _y)) = (_v)
+#endif /* GET_VALUE */
+
+#define INIT_MONO_PIXEL(p, color) \
+  p = PACK_COLOR_565_REV( color[0], color[1], color[2] )
+
+#define WRITE_RGBA( _x, _y, r, g, b, a )                               \
+   PUT_VALUE(_x, _y, PACK_COLOR_565_REV( r, g, b ))
+
+#define WRITE_PIXEL( _x, _y, p ) PUT_VALUE(_x, _y, p)
+
+#define READ_RGBA( rgba, _x, _y )                                      \
+   do {                                                                        \
+      GLushort p = GET_VALUE(_x, _y);                                  \
+      p = p << 8 | p >> 8;                                             \
+      rgba[0] = ((p >> 8) & 0xf8) * 255 / 0xf8;                                \
+      rgba[1] = ((p >> 3) & 0xfc) * 255 / 0xfc;                                \
+      rgba[2] = ((p << 3) & 0xf8) * 255 / 0xf8;                                \
+      rgba[3] = 0xff;                                                  \
+   } while (0)
+
+#elif (SPANTMP_PIXEL_FMT == GL_BGRA)  && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_4_4_4_4)
+
+/**
+ ** GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4
+ **/
+
+#ifndef GET_VALUE
+#ifndef GET_PTR
+#define GET_PTR(_x, _y) (buf + (_x) * 2 + (_y) * pitch)
+#endif
+
+#define GET_VALUE(_x, _y) *(volatile GLushort *)(GET_PTR(_x, _y))
+#define PUT_VALUE(_x, _y, _v) *(volatile GLushort *)(GET_PTR(_x, _y)) = (_v)
+#endif /* GET_VALUE */
+
+#define INIT_MONO_PIXEL(p, color) \
+   p = PACK_COLOR_4444_REV(color[3], color[0], color[1], color[2])
+
+#define WRITE_RGBA( _x, _y, r, g, b, a )                               \
+   PUT_VALUE(_x, _y, PACK_COLOR_4444_REV(a, r, g, b))                  \
+
+#define WRITE_PIXEL( _x, _y, p ) PUT_VALUE(_x, _y, p)
+
+#define READ_RGBA( rgba, _x, _y )                                      \
+   do {                                                                        \
+      GLushort p = GET_VALUE(_x, _y);                                  \
+      rgba[0] = ((p >> 0) & 0xf) * 0x11;                               \
+      rgba[1] = ((p >> 12) & 0xf) * 0x11;                              \
+      rgba[2] = ((p >> 4) & 0xf) * 0x11;                               \
+      rgba[3] = ((p >> 8) & 0xf) * 0x11;                               \
+   } while (0)
+
+
 #elif (SPANTMP_PIXEL_FMT == GL_BGRA)  && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_4_4_4_4_REV)
 
 /**
       rgba[3] = ((p >> 15) & 0x1) * 0xff;                              \
    } while (0)
 
+#elif (SPANTMP_PIXEL_FMT == GL_BGRA)  && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_1_5_5_5)
+
+/**
+ ** GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5
+ **/
+
+#ifndef GET_VALUE
+#ifndef GET_PTR
+#define GET_PTR(_x, _y) (buf + (_x) * 2 + (_y) * pitch)
+#endif
+
+#define GET_VALUE(_x, _y) *(volatile GLushort *)(GET_PTR(_x, _y))
+#define PUT_VALUE(_x, _y, _v) *(volatile GLushort *)(GET_PTR(_x, _y)) = (_v)
+#endif /* GET_VALUE */
+
+#define INIT_MONO_PIXEL(p, color) \
+   p = PACK_COLOR_1555_REV(color[3], color[0], color[1], color[2])
+
+#define WRITE_RGBA( _x, _y, r, g, b, a )                               \
+   PUT_VALUE(_x, _y, PACK_COLOR_1555_REV(a, r, g, b))                  \
+
+#define WRITE_PIXEL( _x, _y, p ) PUT_VALUE(_x, _y, p)
+
+#define READ_RGBA( rgba, _x, _y )                                      \
+   do {                                                                        \
+      GLushort p = GET_VALUE(_x, _y);                                  \
+      p = p << 8 | p >> 8;                                             \
+      rgba[0] = ((p >> 7) & 0xf8) * 255 / 0xf8;                                \
+      rgba[1] = ((p >> 2) & 0xf8) * 255 / 0xf8;                                \
+      rgba[2] = ((p << 3) & 0xf8) * 255 / 0xf8;                                \
+      rgba[3] = ((p >> 15) & 0x1) * 0xff;                              \
+   } while (0)
+
 #elif (SPANTMP_PIXEL_FMT == GL_BGRA) && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV)
 
 /**
      } while (0)
 # endif
 
+#elif (SPANTMP_PIXEL_FMT == GL_BGRA) && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8)
+
+/**
+ ** GL_BGRA, GL_UNSIGNED_INT_8_8_8_8
+ **/
+
+#ifndef GET_VALUE
+#ifndef GET_PTR
+#define GET_PTR(_x, _y) (     buf + (_x) * 4 + (_y) * pitch)
+#endif
+
+#define GET_VALUE(_x, _y) *(volatile GLuint *)(GET_PTR(_x, _y))
+#define PUT_VALUE(_x, _y, _v) *(volatile GLuint *)(GET_PTR(_x, _y)) = (_v)
+#endif /* GET_VALUE */
+
+# define INIT_MONO_PIXEL(p, color)                       \
+     p = PACK_COLOR_8888(color[2], color[1], color[0], color[3]) 
+
+# define WRITE_RGBA(_x, _y, r, g, b, a)                                 \
+   PUT_VALUE(_x, _y, ((r << 8) |                                       \
+                     (g << 16) |                                       \
+                     (b << 24) |                                       \
+                     (a << 0)))
+
+#define WRITE_PIXEL(_x, _y, p) PUT_VALUE(_x, _y, p)
+
+# if defined( USE_X86_ASM )
+#  define READ_RGBA(rgba, _x, _y)                                       \
+    do {                                                                \
+       GLuint p = GET_VALUE(_x, _y);                                   \
+       __asm__ __volatile__( "rorl $8, %0"                             \
+                               : "=r" (p) : "0" (p) );                 \
+       ((GLuint *)rgba)[0] = p;                                         \
+    } while (0)
+# elif defined( MESA_BIG_ENDIAN )
+    /* On PowerPC with GCC 3.4.2 the shift madness below becomes a single
+     * rotlwi instruction.  It also produces good code on SPARC.
+     */
+#  define READ_RGBA( rgba, _x, _y )                                    \
+     do {                                                              \
+        GLuint p = CPU_TO_LE32(GET_VALUE(_x, _y));                      \
+        GLuint t = p;                                                   \
+        *((uint32_t *) rgba) = (t >> 24) | (p << 8);                    \
+     } while (0)
+# else
+#  define READ_RGBA( rgba, _x, _y )                                    \
+     do {                                                              \
+        GLuint p = GET_VALUE(_x, _y);                                  \
+       rgba[0] = (p >>  8) & 0xff;                                     \
+       rgba[1] = (p >> 16) & 0xff;                                     \
+       rgba[2] = (p >> 24) & 0xff;                                     \
+       rgba[3] = (p >>  0) & 0xff;                                     \
+     } while (0)
+# endif
+
+#elif (SPANTMP_PIXEL_FMT == GL_BGR) && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV)
+
+/**
+ ** GL_BGR, GL_UNSIGNED_INT_8_8_8_8_REV
+ **
+ ** This is really for MESA_FORMAT_XRGB8888.  The spantmp code needs to be
+ ** kicked to the curb, and we need to just code-gen this.
+ **/
+
+#ifndef GET_VALUE
+#ifndef GET_PTR
+#define GET_PTR(_x, _y) (     buf + (_x) * 4 + (_y) * pitch)
+#endif
+
+#define GET_VALUE(_x, _y) *(volatile GLuint *)(GET_PTR(_x, _y))
+#define PUT_VALUE(_x, _y, _v) *(volatile GLuint *)(GET_PTR(_x, _y)) = (_v)
+#endif /* GET_VALUE */
+
+# define INIT_MONO_PIXEL(p, color)                       \
+     p = PACK_COLOR_8888(0xff, color[0], color[1], color[2])
+
+# define WRITE_RGBA(_x, _y, r, g, b, a)                                        \
+   PUT_VALUE(_x, _y, ((r << 16) |                                      \
+                     (g << 8) |                                        \
+                     (b << 0) |                                        \
+                     (0xff << 24)))
+
+#define WRITE_PIXEL(_x, _y, p) PUT_VALUE(_x, _y, p)
+
+# if defined( USE_X86_ASM )
+#  define READ_RGBA(rgba, _x, _y)                                       \
+    do {                                                                \
+       GLuint p = GET_VALUE(_x, _y);                                   \
+       __asm__ __volatile__( "bswap    %0; rorl $8, %0"                \
+                               : "=r" (p) : "0" (p) );                 \
+       ((GLuint *)rgba)[0] = p | 0xff000000;                           \
+    } while (0)
+# elif defined( MESA_BIG_ENDIAN )
+    /* On PowerPC with GCC 3.4.2 the shift madness below becomes a single
+     * rotlwi instruction.  It also produces good code on SPARC.
+     */
+#  define READ_RGBA( rgba, _x, _y )                                    \
+     do {                                                              \
+        GLuint p = GET_VALUE(_x, _y);                                  \
+        *((uint32_t *) rgba) = (t << 8) | 0xff;                                \
+     } while (0)
+# else
+#  define READ_RGBA( rgba, _x, _y )                                    \
+     do {                                                              \
+        GLuint p = GET_VALUE(_x, _y);                                  \
+       rgba[0] = (p >> 16) & 0xff;                                     \
+       rgba[1] = (p >>  8) & 0xff;                                     \
+       rgba[2] = (p >>  0) & 0xff;                                     \
+       rgba[3] = 0xff;                                                 \
+     } while (0)
+# endif
+
 #else
 #error SPANTMP_PIXEL_FMT must be set to a valid value!
 #endif
index b64618a03c8dbebb7479e2caf6de154b8b5a4542..895139b55b80e033bacb45b3f55523c5809114e4 100644 (file)
  * application.
  */
 
-#include "texmem.h"
-#include "main/simple_list.h"
 #include "main/imports.h"
 #include "main/macros.h"
-#include "main/texformat.h"
-
-#include <assert.h>
-
+#include "main/simple_list.h"
+#include "texmem.h"
 
 
 static unsigned dummy_swap_counter;
@@ -1302,46 +1298,44 @@ driCalculateTextureFirstLastLevel( driTextureObject * t )
 
 
 /**
- * \name DRI texture formats.  Pointers initialized to either the big- or
- * little-endian Mesa formats.
+ * \name DRI texture formats.  These vars are initialized to either the
+ * big- or little-endian Mesa formats.
  */
 /*@{*/
-const struct gl_texture_format *_dri_texformat_rgba8888 = NULL;
-const struct gl_texture_format *_dri_texformat_argb8888 = NULL;
-const struct gl_texture_format *_dri_texformat_rgb565 = NULL;
-const struct gl_texture_format *_dri_texformat_argb4444 = NULL;
-const struct gl_texture_format *_dri_texformat_argb1555 = NULL;
-const struct gl_texture_format *_dri_texformat_al88 = NULL;
-const struct gl_texture_format *_dri_texformat_a8 = &_mesa_texformat_a8;
-const struct gl_texture_format *_dri_texformat_ci8 = &_mesa_texformat_ci8;
-const struct gl_texture_format *_dri_texformat_i8 = &_mesa_texformat_i8;
-const struct gl_texture_format *_dri_texformat_l8 = &_mesa_texformat_l8;
+gl_format _dri_texformat_rgba8888 = MESA_FORMAT_NONE;
+gl_format _dri_texformat_argb8888 = MESA_FORMAT_NONE;
+gl_format _dri_texformat_rgb565 = MESA_FORMAT_NONE;
+gl_format _dri_texformat_argb4444 = MESA_FORMAT_NONE;
+gl_format _dri_texformat_argb1555 = MESA_FORMAT_NONE;
+gl_format _dri_texformat_al88 = MESA_FORMAT_NONE;
+gl_format _dri_texformat_a8 = MESA_FORMAT_A8;
+gl_format _dri_texformat_ci8 = MESA_FORMAT_CI8;
+gl_format _dri_texformat_i8 = MESA_FORMAT_I8;
+gl_format _dri_texformat_l8 = MESA_FORMAT_L8;
 /*@}*/
 
 
 /**
- * Initialize little endian target, host byte order independent texture formats
+ * Initialize _dri_texformat_* vars according to whether we're on
+ * a big or little endian system.
  */
 void
 driInitTextureFormats(void)
 {
-   const GLuint ui = 1;
-   const GLubyte littleEndian = *((const GLubyte *) &ui);
-
-   if (littleEndian) {
-      _dri_texformat_rgba8888  = &_mesa_texformat_rgba8888;
-      _dri_texformat_argb8888  = &_mesa_texformat_argb8888;
-      _dri_texformat_rgb565    = &_mesa_texformat_rgb565;
-      _dri_texformat_argb4444  = &_mesa_texformat_argb4444;
-      _dri_texformat_argb1555  = &_mesa_texformat_argb1555;
-      _dri_texformat_al88      = &_mesa_texformat_al88;
+   if (_mesa_little_endian()) {
+      _dri_texformat_rgba8888  = MESA_FORMAT_RGBA8888;
+      _dri_texformat_argb8888  = MESA_FORMAT_ARGB8888;
+      _dri_texformat_rgb565    = MESA_FORMAT_RGB565;
+      _dri_texformat_argb4444  = MESA_FORMAT_ARGB4444;
+      _dri_texformat_argb1555  = MESA_FORMAT_ARGB1555;
+      _dri_texformat_al88      = MESA_FORMAT_AL88;
    }
    else {
-      _dri_texformat_rgba8888  = &_mesa_texformat_rgba8888_rev;
-      _dri_texformat_argb8888  = &_mesa_texformat_argb8888_rev;
-      _dri_texformat_rgb565    = &_mesa_texformat_rgb565_rev;
-      _dri_texformat_argb4444  = &_mesa_texformat_argb4444_rev;
-      _dri_texformat_argb1555  = &_mesa_texformat_argb1555_rev;
-      _dri_texformat_al88      = &_mesa_texformat_al88_rev;
+      _dri_texformat_rgba8888  = MESA_FORMAT_RGBA8888_REV;
+      _dri_texformat_argb8888  = MESA_FORMAT_ARGB8888_REV;
+      _dri_texformat_rgb565    = MESA_FORMAT_RGB565_REV;
+      _dri_texformat_argb4444  = MESA_FORMAT_ARGB4444_REV;
+      _dri_texformat_argb1555  = MESA_FORMAT_ARGB1555_REV;
+      _dri_texformat_al88      = MESA_FORMAT_AL88_REV;
    }
 }
index 9c065da8b4f65f1e2468e3a58937826730b146bd..725ba2e11966003253d777c94b710651d1b8f1bb 100644 (file)
@@ -39,6 +39,7 @@
 #define DRI_TEXMEM_H
 
 #include "main/mtypes.h"
+#include "main/formats.h"
 #include "main/mm.h"
 #include "xf86drm.h"
 
@@ -317,16 +318,16 @@ GLboolean driValidateTextureHeaps( driTexHeap * const * texture_heaps,
 extern void driCalculateTextureFirstLastLevel( driTextureObject * t );
 
 
-extern const struct gl_texture_format *_dri_texformat_rgba8888;
-extern const struct gl_texture_format *_dri_texformat_argb8888;
-extern const struct gl_texture_format *_dri_texformat_rgb565;
-extern const struct gl_texture_format *_dri_texformat_argb4444;
-extern const struct gl_texture_format *_dri_texformat_argb1555;
-extern const struct gl_texture_format *_dri_texformat_al88;
-extern const struct gl_texture_format *_dri_texformat_a8;
-extern const struct gl_texture_format *_dri_texformat_ci8;
-extern const struct gl_texture_format *_dri_texformat_i8;
-extern const struct gl_texture_format *_dri_texformat_l8;
+extern gl_format _dri_texformat_rgba8888;
+extern gl_format _dri_texformat_argb8888;
+extern gl_format _dri_texformat_rgb565;
+extern gl_format _dri_texformat_argb4444;
+extern gl_format _dri_texformat_argb1555;
+extern gl_format _dri_texformat_al88;
+extern gl_format _dri_texformat_a8;
+extern gl_format _dri_texformat_ci8;
+extern gl_format _dri_texformat_i8;
+extern gl_format _dri_texformat_l8;
 
 extern void driInitTextureFormats( void );
 
index 66f277c10b25f742e7d1ad2111c5c27565279b0f..b272eb74eaf5f3fd6b2007b65fa09216c98779eb 100644 (file)
@@ -38,9 +38,6 @@
 #include "utils.h"
 
 
-int driDispatchRemapTable[ driDispatchRemapTable_size ];
-
-
 unsigned
 driParseDebugString( const char * debug, 
                     const struct dri_debug_control * control  )
@@ -142,7 +139,7 @@ driGetRendererString( char * buffer, const char * hardware_name,
 #define need_GL_EXT_blend_func_separate
 #define need_GL_NV_vertex_program
 
-#include "extension_helper.h"
+#include "main/remap_helper.h"
 
 static const struct dri_extension all_mesa_extensions[] = {
    { "GL_ARB_draw_buffers",          GL_ARB_draw_buffers_functions },
@@ -165,8 +162,12 @@ static const struct dri_extension all_mesa_extensions[] = {
 
 
 /**
- * Enable extensions supported by the driver.
+ * Enable and map extensions supported by the driver.
  * 
+ * When ctx is NULL, extensions are not enabled, but their functions
+ * are still mapped.  When extensions_to_enable is NULL, all static
+ * functions known to mesa core are mapped.
+ *
  * \bug
  * ARB_imaging isn't handled properly.  In Mesa, enabling ARB_imaging also
  * enables all the sub-extensions that are folded into it.  This means that
@@ -181,18 +182,23 @@ void driInitExtensions( GLcontext * ctx,
    unsigned   i;
 
    if ( first_time ) {
-      for ( i = 0 ; i < driDispatchRemapTable_size ; i++ ) {
-        driDispatchRemapTable[i] = -1;
-      }
-
       first_time = 0;
-      driInitExtensions( ctx, all_mesa_extensions, GL_FALSE );
+      driInitExtensions( NULL, all_mesa_extensions, GL_FALSE );
    }
 
    if ( (ctx != NULL) && enable_imaging ) {
       _mesa_enable_imaging_extensions( ctx );
    }
 
+   /* The caller is too lazy to list any extension */
+   if ( extensions_to_enable == NULL ) {
+      /* Map the static functions.  Together with those mapped by remap
+       * table, this should cover everything mesa core knows.
+       */
+      _mesa_map_static_functions();
+      return;
+   }
+
    for ( i = 0 ; extensions_to_enable[i].name != NULL ; i++ ) {
        driInitSingleExtension( ctx, & extensions_to_enable[i] );
    }
@@ -202,80 +208,18 @@ void driInitExtensions( GLcontext * ctx,
 
 
 /**
- * Enable and add dispatch functions for a single extension
+ * Enable and map functions for a single extension
  * 
  * \param ctx  Context where extension is to be enabled.
  * \param ext  Extension that is to be enabled.
  * 
- * \sa driInitExtensions, _mesa_enable_extension, _glapi_add_entrypoint
- *
- * \todo
- * Determine if it would be better to use \c strlen instead of the hardcoded
- * for-loops.
+ * \sa driInitExtensions, _mesa_enable_extension, _mesa_map_function_array
  */
 void driInitSingleExtension( GLcontext * ctx,
                             const struct dri_extension * ext )
 {
-    unsigned i;
-
-
     if ( ext->functions != NULL ) {
-       for ( i = 0 ; ext->functions[i].strings != NULL ; i++ ) {
-           const char * functions[16];
-           const char * parameter_signature;
-           const char * str = ext->functions[i].strings;
-           unsigned j;
-           unsigned offset;
-
-
-           /* Separate the parameter signature from the rest of the string.
-            * If the parameter signature is empty (i.e., the string starts
-            * with a NUL character), then the function has a void parameter
-            * list.
-            */
-           parameter_signature = str;
-           while ( str[0] != '\0' ) {
-               str++;
-           }
-           str++;
-
-
-           /* Divide the string into the substrings that name each
-            * entry-point for the function.
-            */
-           for ( j = 0 ; j < 16 ; j++ ) {
-               if ( str[0] == '\0' ) {
-                   functions[j] = NULL;
-                   break;
-               }
-
-               functions[j] = str;
-
-               while ( str[0] != '\0' ) {
-                   str++;
-               }
-               str++;
-           }
-
-
-           /* Add each entry-point to the dispatch table.
-            */
-           offset = _glapi_add_dispatch( functions, parameter_signature );
-           if (offset == -1) {
-#if 0 /* this causes noise with egl */
-               fprintf(stderr, "DISPATCH ERROR! _glapi_add_dispatch failed "
-                       "to add %s!\n", functions[0]);
-#endif
-           }
-           else if (ext->functions[i].remap_index != -1) {
-               driDispatchRemapTable[ ext->functions[i].remap_index ] = 
-                 offset;
-           }
-           else if (ext->functions[i].offset != offset) {
-               fprintf(stderr, "DISPATCH ERROR! %s -> %u != %u\n",
-                       functions[0], offset, ext->functions[i].offset);
-           }
-       }
+       _mesa_map_function_array(ext->functions);
     }
 
     if ( ctx != NULL ) {
index 9e9e5bc224b35ba4c4bebea519eb309dbda52f78..2aa6de66c183b317fc29e9bd359adc1688a376fc 100644 (file)
@@ -31,6 +31,7 @@
 #include <GL/gl.h>
 #include <GL/internal/dri_interface.h>
 #include "main/context.h"
+#include "main/remap.h"
 
 typedef struct __DRIutilversionRec2    __DRIutilversion2;
 
@@ -39,35 +40,6 @@ struct dri_debug_control {
     unsigned     flag;
 };
 
-/**
- * Description of the entry-points and parameters for an OpenGL function.
- */
-struct dri_extension_function {
-    /**
-     * \brief
-     * Packed string describing the parameter signature and the entry-point
-     * names.
-     * 
-     * The parameter signature and the names of the entry-points for this
-     * function are packed into a single string.  The substrings are
-     * separated by NUL characters.  The whole string is terminated by
-     * two consecutive NUL characters.
-     */
-    const char * strings;
-
-
-    /**
-     * Location in the remap table where the dispatch offset should be
-     * stored.
-     */
-    int remap_index;
-
-    /**
-     * Offset of the function in the dispatch table.
-     */
-    int offset;
-};
-
 /**
  * Description of the API for an extension to OpenGL.
  */
@@ -83,7 +55,7 @@ struct dri_extension {
      * is terminated by a structure with a \c NULL
      * \c dri_extension_function::strings pointer.
      */
-    const struct dri_extension_function * functions;
+    const struct gl_function_remap * functions;
 };
 
 /**
index 12aeaa108f782960a55743ce63488a6bbd572cb2..49b22a2dc726c6b84172e9ebab14dd6f1192698e 100644 (file)
 #include "vblank.h"
 #include "xmlpool.h"
 
-static unsigned int msc_to_vblank(__DRIdrawablePrivate * dPriv, int64_t msc)
+static unsigned int msc_to_vblank(__DRIdrawable * dPriv, int64_t msc)
 {
    return (unsigned int)(msc - dPriv->msc_base + dPriv->vblank_base);
 }
 
-static int64_t vblank_to_msc(__DRIdrawablePrivate * dPriv, unsigned int vblank)
+static int64_t vblank_to_msc(__DRIdrawable * dPriv, unsigned int vblank)
 {
    return (int64_t)(vblank - dPriv->vblank_base + dPriv->msc_base);
 }
@@ -64,8 +64,8 @@ static int64_t vblank_to_msc(__DRIdrawablePrivate * dPriv, unsigned int vblank)
  * \return       Zero is returned on success.  A negative errno value
  *               is returned on failure.
  */
-int driDrawableGetMSC32( __DRIscreenPrivate * priv,
-                        __DRIdrawablePrivate * dPriv,
+int driDrawableGetMSC32( __DRIscreen * priv,
+                        __DRIdrawable * dPriv,
                         int64_t * count)
 {
    drmVBlank vbl;
@@ -122,7 +122,7 @@ int driDrawableGetMSC32( __DRIscreenPrivate * priv,
  * \return            Zero on success or \c GLX_BAD_CONTEXT on failure.
  */
 
-int driWaitForMSC32( __DRIdrawablePrivate *priv,
+int driWaitForMSC32( __DRIdrawable *priv,
                     int64_t target_msc, int64_t divisor, int64_t remainder,
                     int64_t * msc )
 {
@@ -278,7 +278,7 @@ static int do_wait( drmVBlank * vbl, GLuint * vbl_seq, int fd )
  */
 
 static unsigned
-driGetDefaultVBlankInterval( const  __DRIdrawablePrivate *priv )
+driGetDefaultVBlankInterval( const  __DRIdrawable *priv )
 {
    if ( (priv->vblFlags & (VBLANK_FLAG_THROTTLE | VBLANK_FLAG_SYNC)) != 0 ) {
       return 1;
@@ -295,7 +295,7 @@ driGetDefaultVBlankInterval( const  __DRIdrawablePrivate *priv )
  * direct rendering context.
  */
 
-void driDrawableInitVBlank( __DRIdrawablePrivate *priv )
+void driDrawableInitVBlank( __DRIdrawable *priv )
 {
    if ( priv->swap_interval == (unsigned)-1 &&
        !( priv->vblFlags & VBLANK_FLAG_NO_IRQ ) ) {
@@ -320,7 +320,7 @@ void driDrawableInitVBlank( __DRIdrawablePrivate *priv )
  */
 
 unsigned
-driGetVBlankInterval( const  __DRIdrawablePrivate *priv )
+driGetVBlankInterval( const  __DRIdrawable *priv )
 {
    if ( (priv->vblFlags & VBLANK_FLAG_INTERVAL) != 0 ) {
       /* this must have been initialized when the drawable was first bound
@@ -340,7 +340,7 @@ driGetVBlankInterval( const  __DRIdrawablePrivate *priv )
  */
 
 void
-driGetCurrentVBlank( __DRIdrawablePrivate *priv )
+driGetCurrentVBlank( __DRIdrawable *priv )
 {
    drmVBlank vbl;
 
@@ -366,7 +366,7 @@ driGetCurrentVBlank( __DRIdrawablePrivate *priv )
  */
 
 int
-driWaitForVBlank( __DRIdrawablePrivate *priv, GLboolean * missed_deadline )
+driWaitForVBlank( __DRIdrawable *priv, GLboolean * missed_deadline )
 {
    drmVBlank vbl;
    unsigned   original_seq;
index 8b2c761a1160afec49ea2111847bf5108d786321..29d1ad8003bff84ed7dc492f76bea0cd5cd22025 100644 (file)
 #define VBLANK_FLAG_SECONDARY (1U << 8)  /* Wait for secondary vblank.
                                          */
 
-extern int driGetMSC32( __DRIscreenPrivate * priv, int64_t * count );
-extern int driDrawableGetMSC32( __DRIscreenPrivate * priv,
-                               __DRIdrawablePrivate * drawablePrivate,
+extern int driGetMSC32( __DRIscreen * priv, int64_t * count );
+extern int driDrawableGetMSC32( __DRIscreen * priv,
+                               __DRIdrawable * drawablePrivate,
                                int64_t * count);
-extern int driWaitForMSC32( __DRIdrawablePrivate *priv,
+extern int driWaitForMSC32( __DRIdrawable *priv,
     int64_t target_msc, int64_t divisor, int64_t remainder, int64_t * msc );
 extern GLuint driGetDefaultVBlankFlags( const driOptionCache *optionCache );
-extern void driDrawableInitVBlank ( __DRIdrawablePrivate *priv );
-extern unsigned driGetVBlankInterval( const  __DRIdrawablePrivate *priv );
-extern void driGetCurrentVBlank( __DRIdrawablePrivate *priv );
-extern int driWaitForVBlank( __DRIdrawablePrivate *priv,
+extern void driDrawableInitVBlank ( __DRIdrawable *priv );
+extern unsigned driGetVBlankInterval( const  __DRIdrawable *priv );
+extern void driGetCurrentVBlank( __DRIdrawable *priv );
+extern int driWaitForVBlank( __DRIdrawable *priv,
                             GLboolean * missed_deadline );
 
 #undef usleep
index 309f50b95f88ed3db212414649ea0eccb83a0a8f..cf9b3a85563548f2cb621b8053cb82b22e2c0cff 100644 (file)
@@ -25,5 +25,3 @@ ASM_SOURCES =
 
 include ../Makefile.template
 
-symlinks:
-
index 571b8922d5d6cc7e819cb264fed0c1818b402b59..f37241dd69ad0f45ac44da6bfe74ea3b8cc08021 100644 (file)
@@ -64,9 +64,9 @@ typedef struct {
    GLcontext *glCtx;           /* Mesa context */
 
    struct {
-      __DRIcontextPrivate *context;    
-      __DRIscreenPrivate *screen;      
-      __DRIdrawablePrivate *drawable; /* drawable bound to this ctx */
+      __DRIcontext *context;   
+      __DRIscreen *screen;     
+      __DRIdrawable *drawable; /* drawable bound to this ctx */
    } dri;
    
 } fbContext, *fbContextPtr;
@@ -313,14 +313,14 @@ fbSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
 /* Initialize the driver specific screen private data.
  */
 static GLboolean
-fbInitDriver( __DRIscreenPrivate *sPriv )
+fbInitDriver( __DRIscreen *sPriv )
 {
    sPriv->private = NULL;
    return GL_TRUE;
 }
 
 static void
-fbDestroyScreen( __DRIscreenPrivate *sPriv )
+fbDestroyScreen( __DRIscreen *sPriv )
 {
 }
 
@@ -329,7 +329,7 @@ fbDestroyScreen( __DRIscreenPrivate *sPriv )
  */
 static GLboolean
 fbCreateContext( const __GLcontextModes *glVisual,
-                __DRIcontextPrivate *driContextPriv,
+                __DRIcontext *driContextPriv,
                 void *sharedContextPrivate)
 {
    fbContextPtr fbmesa;
@@ -384,7 +384,7 @@ fbCreateContext( const __GLcontextModes *glVisual,
 
 
 static void
-fbDestroyContext( __DRIcontextPrivate *driContextPriv )
+fbDestroyContext( __DRIcontext *driContextPriv )
 {
    GET_CURRENT_CONTEXT(ctx);
    fbContextPtr fbmesa = (fbContextPtr) driContextPriv->driverPrivate;
@@ -415,8 +415,8 @@ fbDestroyContext( __DRIcontextPrivate *driContextPriv )
  * data.
  */
 static GLboolean
-fbCreateBuffer( __DRIscreenPrivate *driScrnPriv,
-               __DRIdrawablePrivate *driDrawPriv,
+fbCreateBuffer( __DRIscreen *driScrnPriv,
+               __DRIdrawable *driDrawPriv,
                const __GLcontextModes *mesaVis,
                GLboolean isPixmap )
 {
@@ -437,7 +437,7 @@ fbCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       /* XXX double-check these parameters (bpp vs cpp, etc) */
       {
-         driRenderbuffer *drb = driNewRenderbuffer(GL_RGBA,
+         driRenderbuffer *drb = driNewRenderbuffer(MESA_FORMAT_ARGB8888,
                                                    driScrnPriv->pFB,
                                                    driScrnPriv->fbBPP / 8,
                                                    driScrnPriv->fbOrigin,
@@ -451,7 +451,7 @@ fbCreateBuffer( __DRIscreenPrivate *driScrnPriv,
          /* XXX what are the correct origin/stride values? */
          GLvoid *backBuf = _mesa_malloc(driScrnPriv->fbStride
                                         * driScrnPriv->fbHeight);
-         driRenderbuffer *drb = driNewRenderbuffer(GL_RGBA,
+         driRenderbuffer *drb = driNewRenderbuffer(MESA_FORMAT_ARGB8888,
                                                    backBuf,
                                                    driScrnPriv->fbBPP /8,
                                                    driScrnPriv->fbOrigin,
@@ -478,7 +478,7 @@ fbCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
 
 static void
-fbDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+fbDestroyBuffer(__DRIdrawable *driDrawPriv)
 {
    _mesa_reference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)), NULL);
 }
@@ -488,7 +488,7 @@ fbDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
 /* If the backbuffer is on a videocard, this is extraordinarily slow!
  */
 static void
-fbSwapBuffers( __DRIdrawablePrivate *dPriv )
+fbSwapBuffers( __DRIdrawable *dPriv )
 {
    struct gl_framebuffer *mesa_framebuffer = (struct gl_framebuffer *)dPriv->driverPrivate;
    struct gl_renderbuffer * front_renderbuffer = mesa_framebuffer->Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
@@ -532,9 +532,9 @@ fbSwapBuffers( __DRIdrawablePrivate *dPriv )
  * buffer `b'.
  */
 static GLboolean
-fbMakeCurrent( __DRIcontextPrivate *driContextPriv,
-              __DRIdrawablePrivate *driDrawPriv,
-              __DRIdrawablePrivate *driReadPriv )
+fbMakeCurrent( __DRIcontext *driContextPriv,
+              __DRIdrawable *driDrawPriv,
+              __DRIdrawable *driReadPriv )
 {
    if ( driContextPriv ) {
       fbContextPtr newFbCtx = 
@@ -556,7 +556,7 @@ fbMakeCurrent( __DRIcontextPrivate *driContextPriv,
 /* Force the context `c' to be unbound from its buffer.
  */
 static GLboolean
-fbUnbindContext( __DRIcontextPrivate *driContextPriv )
+fbUnbindContext( __DRIcontext *driContextPriv )
 {
    return GL_TRUE;
 }
@@ -657,7 +657,7 @@ struct DRIDriverRec __driDriver = {
 };
 
 static __GLcontextModes *
-fbFillInModes( __DRIscreenPrivate *psp,
+fbFillInModes( __DRIscreen *psp,
               unsigned pixel_bits, unsigned depth_bits,
               unsigned stencil_bits, GLboolean have_back_buffer )
 {
@@ -745,7 +745,7 @@ fbFillInModes( __DRIscreenPrivate *psp,
  * with the \c __GLcontextModes that the driver can support for windows or
  * pbuffers.
  * 
- * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on 
+ * \return A pointer to a \c __DRIscreen on success, or \c NULL on 
  *         failure.
  */
 PUBLIC
@@ -759,7 +759,7 @@ void * __driCreateNewScreen( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc
                                    int internal_api_version,
                                    __GLcontextModes ** driver_modes )
 {
-   __DRIscreenPrivate *psp;
+   __DRIscreen *psp;
    static const __DRIversion ddx_expected = { 4, 0, 0 };
    static const __DRIversion dri_expected = { 4, 0, 0 };
    static const __DRIversion drm_expected = { 1, 5, 0 };
@@ -785,3 +785,10 @@ void * __driCreateNewScreen( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc
 
           return (void *) psp;
 }
+
+/* This is the table of extensions that the loader will dlsym() for. */
+PUBLIC const __DRIextension *__driDriverExtensions[] = {
+    &driCoreExtension.base,
+    &driLegacyExtension.base,
+    NULL
+};
index 4e41860d8c8fe70000fbb9337e8a9918daffbf13..02e44bb8eede89508c50de5b43f35d63d40a8a21 100644 (file)
@@ -84,9 +84,9 @@ typedef struct fb_context
    _EGLContext Base;  /* base class/object */
    GLcontext *glCtx;
    struct {
-      __DRIcontextPrivate *context;    
-      __DRIscreenPrivate *screen;      
-      __DRIdrawablePrivate *drawable; /* drawable bound to this ctx */
+      __DRIcontext *context;   
+      __DRIscreen *screen;     
+      __DRIdrawable *drawable; /* drawable bound to this ctx */
    } dri;
 } fbContext, *fbContextPtr;
 
@@ -692,7 +692,7 @@ fbCreateScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLConfig cfg,
 
    /* front color renderbuffer */
    {
-      driRenderbuffer *drb = driNewRenderbuffer(GL_RGBA, display->pFB,
+      driRenderbuffer *drb = driNewRenderbuffer(MESA_FORMAT_ARGB8888, display->pFB,
                                                 bytesPerPixel,
                                                 origin, stride, NULL);
       fbSetSpanFunctions(drb, &vis);
@@ -703,7 +703,7 @@ fbCreateScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLConfig cfg,
    /* back color renderbuffer */
    if (vis.doubleBufferMode) {
       GLubyte *backBuf = _mesa_malloc(stride * height);
-      driRenderbuffer *drb = driNewRenderbuffer(GL_RGBA, backBuf,
+      driRenderbuffer *drb = driNewRenderbuffer(MESA_FORMAT_ARGB8888, backBuf,
                                                 bytesPerPixel,
                                                 origin, stride, NULL);
       fbSetSpanFunctions(drb, &vis);
index cb73238c030fe5c6b85a2ad931b19a37b3a7c173..e9da8f9066e49dfb5c590773d19d6272a2218b8e 100644 (file)
@@ -33,4 +33,3 @@ ASM_SOURCES =
 
 include ../Makefile.template
 
-symlinks:
index f89c0412dfe15e52f9f204ab6a4a9415be085234..611afddfaf5c229d147b76800973964a09d49c54 100644 (file)
@@ -46,7 +46,7 @@ ffb_bitmap(GLcontext *ctx, GLint px, GLint py,
 {
        ffbContextPtr fmesa = FFB_CONTEXT(ctx);
        ffb_fbcPtr ffb = fmesa->regs;
-       __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+       __DRIdrawable *dPriv = fmesa->driDrawable;
        unsigned int ppc, pixel;
        GLint row, col, row_stride;
        const GLubyte *src;
index 776fb487f8d9df66d0951792ee3f13ad0b9b9573..dfe60f36f2b760f3ec1ba01d3557ea405190bacf 100644 (file)
@@ -123,7 +123,7 @@ CreatorComputePageFillFixups(struct ff_fixups *fixups,
 }
 
 static void
-ffb_do_clear(GLcontext *ctx, __DRIdrawablePrivate *dPriv)
+ffb_do_clear(GLcontext *ctx, __DRIdrawable *dPriv)
 {
        ffbContextPtr fmesa = FFB_CONTEXT(ctx);
        FFBDRIPtr gDRIPriv = (FFBDRIPtr) fmesa->driScreen->pDevPriv;
@@ -252,7 +252,7 @@ ffb_do_clear(GLcontext *ctx, __DRIdrawablePrivate *dPriv)
 void ffbDDClear(GLcontext *ctx, GLbitfield mask)
 {
        ffbContextPtr fmesa = FFB_CONTEXT(ctx);
-       __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+       __DRIdrawable *dPriv = fmesa->driDrawable;
        unsigned int stcmask = BUFFER_BIT_STENCIL;
 
 #ifdef CLEAR_TRACE
index 77f87d41c301c3cb079296ac003b3dba257c7944..4d1d53ff59f71a1f3b12bad8bdca7ec94f6d90d3 100644 (file)
@@ -273,8 +273,8 @@ do {        if ((STATE_MASK) & ~((FMESA)->state_dirty)) {   \
        unsigned int            setupnewinputs;
        unsigned int            new_gl_state;
 
-       __DRIdrawablePrivate    *driDrawable;
-       __DRIscreenPrivate      *driScreen;
+       __DRIdrawable   *driDrawable;
+       __DRIscreen     *driScreen;
        ffbScreenPrivate        *ffbScreen;
        ffb_dri_state_t         *ffb_sarea;
 } ffbContextRec, *ffbContextPtr;
index 71f204d21e2fbe717e28bcfabfe49a0c1ecd713e..5d509ff69630bd4df3164570e78a313ef25d196c 100644 (file)
@@ -49,7 +49,7 @@ static void FFBWriteDepthSpan( GLcontext *ctx,
 #endif
        if (ctx->Depth.Mask) {
                ffbContextPtr fmesa = FFB_CONTEXT(ctx);
-               __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+               __DRIdrawable *dPriv = fmesa->driDrawable;
                GLuint *zptr;
                GLuint i;
 
@@ -110,7 +110,7 @@ static void FFBWriteDepthPixels( GLcontext *ctx,
 #endif
        if (ctx->Depth.Mask) {
                ffbContextPtr fmesa = FFB_CONTEXT(ctx);
-               __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+               __DRIdrawable *dPriv = fmesa->driDrawable;
                char *zbase;
                GLuint i;
 
@@ -153,7 +153,7 @@ static void FFBReadDepthSpan( GLcontext *ctx,
 {
         GLuint *depth = (GLuint *) values;
        ffbContextPtr fmesa = FFB_CONTEXT(ctx);
-       __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+       __DRIdrawable *dPriv = fmesa->driDrawable;
        GLuint *zptr;
        GLuint i;
 
@@ -194,7 +194,7 @@ static void FFBReadDepthPixels( GLcontext *ctx,
 {
         GLuint *depth = (GLuint *) values;
        ffbContextPtr fmesa = FFB_CONTEXT(ctx);
-       __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+       __DRIdrawable *dPriv = fmesa->driDrawable;
        char *zbase;
        GLuint i;
 
index 0d3d604095523cf97c243031ddbde150bcc788b5..8ec33a11bc607adfb92c79f8374ed334ca68b06f 100644 (file)
@@ -45,7 +45,7 @@
                UNLOCK_HARDWARE(fmesa); \
 
 #define LOCAL_VARS                                             \
-       __DRIdrawablePrivate *dPriv = fmesa->driDrawable;       \
+       __DRIdrawable *dPriv = fmesa->driDrawable;      \
        GLuint height = dPriv->h;                               \
         GLuint p;                                              \
        char *buf;                                              \
index 5eb8f417ffb76015bcb38c497bd48d54e50a3d21..6f8a46d1fc798bad16cd2d596bed09f90f5d6244 100644 (file)
@@ -384,7 +384,7 @@ ffbDDStencilOpSeparate(GLcontext *ctx, GLenum face, GLenum fail,
 static void ffbCalcViewportRegs(GLcontext *ctx)
 {
        ffbContextPtr fmesa = FFB_CONTEXT(ctx);
-       __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+       __DRIdrawable *dPriv = fmesa->driDrawable;
        GLuint xmin, xmax, ymin, ymax, zmin, zmax;
        unsigned int vcmin, vcmax;
 
@@ -430,7 +430,7 @@ void ffbCalcViewport(GLcontext *ctx)
        ffbContextPtr fmesa = FFB_CONTEXT(ctx);
        const GLfloat *v = ctx->Viewport._WindowMap.m;
        GLfloat *m = fmesa->hw_viewport;
-       __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+       __DRIdrawable *dPriv = fmesa->driDrawable;
 
        m[MAT_SX] =   v[MAT_SX];
        m[MAT_TX] =   v[MAT_TX] + dPriv->x + SUBPIXEL_X;
@@ -762,7 +762,7 @@ static void ffbDDLineStipple(GLcontext *ctx, GLint factor, GLushort pattern)
 
 void ffbXformAreaPattern(ffbContextPtr fmesa, const GLubyte *mask)
 {
-       __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+       __DRIdrawable *dPriv = fmesa->driDrawable;
        int i, lines, xoff;
 
        lines = 0;
index 921a83d274247c7344d66b004a4852d0ac304ace..ce8ef43c91e159195e57d84808809224c6bb7a9d 100644 (file)
@@ -48,7 +48,7 @@ static void FFBWriteStencilSpan( GLcontext *ctx,
 #endif
        if (ctx->Depth.Mask) {
                ffbContextPtr fmesa = FFB_CONTEXT(ctx);
-               __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+               __DRIdrawable *dPriv = fmesa->driDrawable;
                GLuint *zptr;
                GLuint i;
 
@@ -93,7 +93,7 @@ static void FFBWriteStencilPixels( GLcontext *ctx,
 #endif
        if (ctx->Depth.Mask) {
                ffbContextPtr fmesa = FFB_CONTEXT(ctx);
-               __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+               __DRIdrawable *dPriv = fmesa->driDrawable;
                char *zbase;
                GLuint i;
 
@@ -136,7 +136,7 @@ static void FFBReadStencilSpan( GLcontext *ctx,
 {
         GLubyte *stencil = (GLubyte *) values;
        ffbContextPtr fmesa = FFB_CONTEXT(ctx);
-       __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+       __DRIdrawable *dPriv = fmesa->driDrawable;
        GLuint *zptr;
        GLuint i;
 
@@ -176,7 +176,7 @@ static void FFBReadStencilPixels( GLcontext *ctx,
 {
         GLubyte *stencil = (GLubyte *) values;
        ffbContextPtr fmesa = FFB_CONTEXT(ctx);
-       __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+       __DRIdrawable *dPriv = fmesa->driDrawable;
        char *zbase;
        GLuint i;
 
index d785c1571812c1e9e47221a8818e154b9cc26a7c..8bf5ae498fd93c4b433bbf6c19ed3d5c176c1f22 100644 (file)
@@ -351,8 +351,8 @@ static struct {
 
 #define LOCAL_VARS(n)                          \
    ffbContextPtr fmesa = FFB_CONTEXT(ctx);     \
-   __DRIdrawablePrivate *dPriv = fmesa->driDrawable; \
-   ffb_color color[n];                         \
+   __DRIdrawable *dPriv = fmesa->driDrawable; \
+   ffb_color color[n] = { { 0 } };             \
    (void) color; (void) dPriv;
 
 /***********************************************************************
index 0495d0e2767d900dd86d5aca31c6549fae9cfe76..c548ef3ad58fc35b709ce61c439ed38bea5251d4 100644 (file)
@@ -38,11 +38,11 @@ static void TAG(emit)(GLcontext *ctx, GLuint start, GLuint end)
 #endif
 
 #if (IND & (FFB_VB_RGBA_BIT))
-       col0 = VB->ColorPtr[0]->data;
-       col0_stride = VB->ColorPtr[0]->stride;
+       col0 = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->data;
+       col0_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->stride;
 #if (IND & (FFB_VB_TWOSIDE_BIT))
-       col1 = VB->ColorPtr[1]->data;
-       col1_stride = VB->ColorPtr[1]->stride;
+       col1 = VB->BackfaceColorPtr->data;
+       col1_stride = VB->BackfaceColorPtr->stride;
 #endif
 #endif
 
index 3b9f5c675919c8858c80df1efb38404b4e1d5923..88285f454e9f726ba7c01c87c1e5f6f139df0470 100644 (file)
@@ -62,7 +62,7 @@
 #include "drirenderbuffer.h"
 
 static GLboolean
-ffbInitDriver(__DRIscreenPrivate *sPriv)
+ffbInitDriver(__DRIscreen *sPriv)
 {
        ffbScreenPrivate *ffbScreen;
        FFBDRIPtr gDRIPriv = (FFBDRIPtr) sPriv->pDevPriv;
@@ -154,7 +154,7 @@ ffbInitDriver(__DRIscreenPrivate *sPriv)
 
 
 static void
-ffbDestroyScreen(__DRIscreenPrivate *sPriv)
+ffbDestroyScreen(__DRIscreen *sPriv)
 {
        ffbScreenPrivate *ffbScreen = sPriv->private;
        FFBDRIPtr gDRIPriv = (FFBDRIPtr) sPriv->pDevPriv;
@@ -183,12 +183,12 @@ static const struct tnl_pipeline_stage *ffb_pipeline[] = {
 /* Create and initialize the Mesa and driver specific context data */
 static GLboolean
 ffbCreateContext(const __GLcontextModes *mesaVis,
-                 __DRIcontextPrivate *driContextPriv,
+                 __DRIcontext *driContextPriv,
                  void *sharedContextPrivate)
 {
        ffbContextPtr fmesa;
        GLcontext *ctx, *shareCtx;
-       __DRIscreenPrivate *sPriv;
+       __DRIscreen *sPriv;
        ffbScreenPrivate *ffbScreen;
        char *debug;
        struct dd_function_table functions;
@@ -306,7 +306,7 @@ ffbCreateContext(const __GLcontextModes *mesaVis,
 }
 
 static void
-ffbDestroyContext(__DRIcontextPrivate *driContextPriv)
+ffbDestroyContext(__DRIcontext *driContextPriv)
 {
        ffbContextPtr fmesa = (ffbContextPtr) driContextPriv->driverPrivate;
 
@@ -328,8 +328,8 @@ ffbDestroyContext(__DRIcontextPrivate *driContextPriv)
 
 /* Create and initialize the Mesa and driver specific pixmap buffer data */
 static GLboolean
-ffbCreateBuffer(__DRIscreenPrivate *driScrnPriv,
-                __DRIdrawablePrivate *driDrawPriv,
+ffbCreateBuffer(__DRIscreen *driScrnPriv,
+                __DRIdrawable *driDrawPriv,
                 const __GLcontextModes *mesaVis,
                 GLboolean isPixmap )
 {
@@ -347,7 +347,7 @@ ffbCreateBuffer(__DRIscreenPrivate *driScrnPriv,
 
       {
          driRenderbuffer *frontRb
-            = driNewRenderbuffer(GL_RGBA, NULL, bpp, offset, bogusPitch,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888, NULL, bpp, offset, bogusPitch,
                                  driDrawPriv);
          ffbSetSpanFunctions(frontRb, mesaVis);
          _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
@@ -355,7 +355,7 @@ ffbCreateBuffer(__DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->doubleBufferMode) {
          driRenderbuffer *backRb
-            = driNewRenderbuffer(GL_RGBA, NULL, bpp, offset, bogusPitch,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888, NULL, bpp, offset, bogusPitch,
                                  driDrawPriv);
          ffbSetSpanFunctions(backRb, mesaVis);
          _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
@@ -363,7 +363,7 @@ ffbCreateBuffer(__DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->depthBits == 16) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT16, NULL, bpp, offset,
+            = driNewRenderbuffer(MESA_FORMAT_Z16, NULL, bpp, offset,
                                  bogusPitch, driDrawPriv);
          ffbSetDepthFunctions(depthRb, mesaVis);
          _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
@@ -371,7 +371,7 @@ ffbCreateBuffer(__DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->stencilBits > 0 && !swStencil) {
          driRenderbuffer *stencilRb
-            = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, NULL, bpp, offset,
+            = driNewRenderbuffer(MESA_FORMAT_S8, NULL, bpp, offset,
                                  bogusPitch, driDrawPriv);
          ffbSetStencilFunctions(stencilRb, mesaVis);
          _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
@@ -392,7 +392,7 @@ ffbCreateBuffer(__DRIscreenPrivate *driScrnPriv,
 
 
 static void
-ffbDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+ffbDestroyBuffer(__DRIdrawable *driDrawPriv)
 {
    _mesa_reference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)), NULL);
 }
@@ -401,7 +401,7 @@ ffbDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
 #define USE_FAST_SWAP
 
 static void
-ffbSwapBuffers( __DRIdrawablePrivate *dPriv )
+ffbSwapBuffers( __DRIdrawable *dPriv )
 {
        ffbContextPtr fmesa = (ffbContextPtr) dPriv->driContextPriv->driverPrivate;
        unsigned int fbc, wid, wid_reg_val, dac_db_bit;
@@ -532,9 +532,9 @@ static void ffb_init_wid(ffbContextPtr fmesa, unsigned int wid)
 /* Force the context `c' to be the current context and associate with it
    buffer `b' */
 static GLboolean
-ffbMakeCurrent(__DRIcontextPrivate *driContextPriv,
-               __DRIdrawablePrivate *driDrawPriv,
-               __DRIdrawablePrivate *driReadPriv)
+ffbMakeCurrent(__DRIcontext *driContextPriv,
+               __DRIdrawable *driDrawPriv,
+               __DRIdrawable *driReadPriv)
 {
        if (driContextPriv) {
                ffbContextPtr fmesa = (ffbContextPtr) driContextPriv->driverPrivate;
@@ -581,15 +581,15 @@ ffbMakeCurrent(__DRIcontextPrivate *driContextPriv,
 
 /* Force the context `c' to be unbound from its buffer */
 static GLboolean
-ffbUnbindContext(__DRIcontextPrivate *driContextPriv)
+ffbUnbindContext(__DRIcontext *driContextPriv)
 {
        return GL_TRUE;
 }
 
 void ffbXMesaUpdateState(ffbContextPtr fmesa)
 {
-       __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
-       __DRIscreenPrivate *sPriv = fmesa->driScreen;
+       __DRIdrawable *dPriv = fmesa->driDrawable;
+       __DRIscreen *sPriv = fmesa->driScreen;
        int stamp = dPriv->lastStamp;
 
        DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv);
@@ -607,7 +607,7 @@ void ffbXMesaUpdateState(ffbContextPtr fmesa)
 }
 
 static const __DRIconfig **
-ffbFillInModes( __DRIscreenPrivate *psp,
+ffbFillInModes( __DRIscreen *psp,
                unsigned pixel_bits, unsigned depth_bits,
                unsigned stencil_bits, GLboolean have_back_buffer )
 {
@@ -722,3 +722,10 @@ const struct __DriverAPIRec driDriverAPI = {
    .WaitForSBC      = NULL,
    .SwapBuffersMSC  = NULL
 };
+
+/* This is the table of extensions that the loader will dlsym() for. */
+PUBLIC const __DRIextension *__driDriverExtensions[] = {
+    &driCoreExtension.base,
+    &driLegacyExtension.base,
+    NULL
+};
index 255da4c5f8426d0a503a5887982b1b1f86a5bc9a..2b1740d221952a76f77f827f369e64cef5364511 100644 (file)
@@ -11,7 +11,7 @@
 #include "ffb_fifo.h"
 
 typedef struct {
-       __DRIscreenPrivate              *sPriv;
+       __DRIscreen             *sPriv;
        ffb_fbcPtr                      regs;
        ffb_dacPtr                      dac;
        volatile char                   *sfb8r;
index 250d3ac0891aa33531c48426e231dcdb3c9b30ee..09df1578fc79b4576717cfcb9b2ff93db10aa122 100644 (file)
@@ -32,4 +32,3 @@ ASM_SOURCES =
 
 include ../Makefile.template
 
-symlinks:
index b0ac299daae56ddcd85adeee881b03d1b2e53e94..bab5b69a8e4c5c66268655e4ebb4c4f9c7a9bc92 100644 (file)
@@ -68,11 +68,11 @@ static const struct tnl_pipeline_stage *gamma_pipeline[] = {
 };
 
 GLboolean gammaCreateContext( const __GLcontextModes *glVisual,
-                            __DRIcontextPrivate *driContextPriv,
+                            __DRIcontext *driContextPriv,
                             void *sharedContextPrivate)
 {
    GLcontext *ctx, *shareCtx;
-   __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+   __DRIscreen *sPriv = driContextPriv->driScreenPriv;
    gammaContextPtr gmesa;
    gammaScreenPtr gammascrn;
    GLINTSAREADRIPtr saPriv=(GLINTSAREADRIPtr)(((char*)sPriv->pSAREA)+
index a32ccb6007b9fba7928e0295dc2a847fcefb4be8..c386aa3007a3394f73e8e3b6ce94c30c78aacf0e 100644 (file)
@@ -58,10 +58,10 @@ typedef union {
 #define MAX_TEXTURE_STACK       2
 
 extern void      gammaDDUpdateHWState(GLcontext *ctx);
-extern gammaScreenPtr    gammaCreateScreen(__DRIscreenPrivate *sPriv);
-extern void      gammaDestroyScreen(__DRIscreenPrivate *sPriv);
+extern gammaScreenPtr    gammaCreateScreen(__DRIscreen *sPriv);
+extern void      gammaDestroyScreen(__DRIscreen *sPriv);
 extern GLboolean gammaCreateContext( const __GLcontextModes *glVisual,
-                                     __DRIcontextPrivate *driContextPriv,
+                                     __DRIcontext *driContextPriv,
                                      void *sharedContextPrivate);
 
 #define GAMMA_UPLOAD_ALL       0xffffffff
@@ -230,9 +230,9 @@ typedef void (*gamma_point_func)( gammaContextPtr,
 struct gamma_context {
        GLcontext               *glCtx;         /* Mesa context */
 
-       __DRIcontextPrivate     *driContext;
-       __DRIscreenPrivate      *driScreen;
-       __DRIdrawablePrivate    *driDrawable;
+       __DRIcontext    *driContext;
+       __DRIscreen     *driScreen;
+       __DRIdrawable   *driDrawable;
 
        GLuint                  new_gl_state;
        GLuint                  new_state;
index 8f2d01688c9af4f33e49fe6ad7c42eb0a487ac7e..cd4acef24dabfb061f989fb28c9ac2f4985ca6b7 100644 (file)
@@ -19,8 +19,8 @@ int prevLockLine = 0;
  */
 void gammaGetLock( gammaContextPtr gmesa, GLuint flags )
 {
-   __DRIdrawablePrivate *dPriv = gmesa->driDrawable;
-   __DRIscreenPrivate *sPriv = gmesa->driScreen;
+   __DRIdrawable *dPriv = gmesa->driDrawable;
+   __DRIscreen *sPriv = gmesa->driScreen;
 
    drmGetLock( gmesa->driFd, gmesa->hHWContext, flags );
 
index c15483b770c05756f66ff1f226a0eeb02da9f38a..d962dcdb5666f5510ab32766e195e6536e267735 100644 (file)
@@ -245,8 +245,8 @@ do {                                                                       \
 #ifdef DO_VALIDATE
 #define VALIDATE_DRAWABLE_INFO_NO_LOCK(gcp)                                \
 do {                                                                       \
-    /*__DRIscreenPrivate *psp = gcp->driScreen;*/                          \
-    __DRIdrawablePrivate *pdp = gcp->driDrawable;                          \
+    /*__DRIscreen *psp = gcp->driScreen;*/                          \
+    __DRIdrawable *pdp = gcp->driDrawable;                          \
                                                                            \
     if (*(pdp->pStamp) != pdp->lastStamp) {                                \
        int old_index = pdp->index;                                        \
@@ -301,7 +301,7 @@ do {                                                                       \
 
 #define VALIDATE_DRAWABLE_INFO(gcp)                                    \
 do {                                                                       \
-    __DRIscreenPrivate *psp = gcp->driScreen;                          \
+    __DRIscreen *psp = gcp->driScreen;                          \
 if (gcp->driDrawable) { \
     DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID);            \
     VALIDATE_DRAWABLE_INFO_NO_LOCK(gcp);                               \
index 1b9fd169f46270349ef195df89ed53aaaa6f5c19..a03a93d132cf1c1099abefc3ab40100428d2e888 100644 (file)
@@ -53,13 +53,13 @@ static void gamma_emit( GLcontext *ctx, GLuint start, GLuint end)
    GLfloat (*tc0)[4] = 0;
    GLuint tc0_size = 0;
 
-   col = VB->ColorPtr[0]->data;
-   col_stride = VB->ColorPtr[0]->stride;
+   col = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->data;
+   col_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->stride;
 
    if (ctx->Texture.Unit[0]._ReallyEnabled) {
-      tc0_stride = VB->TexCoordPtr[0]->stride;
-      tc0 = VB->TexCoordPtr[0]->data;
-      tc0_size = VB->TexCoordPtr[0]->size;
+      tc0_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0]->stride;
+      tc0 = VB->AttribPtr[_TNL_ATTRIB_TEX0]->data;
+      tc0_size = VB->AttribPtr[_TNL_ATTRIB_TEX0]->size;
       coord = VB->ClipPtr->data;
       coord_stride = VB->ClipPtr->stride;
    } else {
index f899ebec96d4055b731775d2e5a4dee34b0fbd2e..f72a4a5696981c23db5430d759be98bf3e134641 100644 (file)
@@ -29,7 +29,7 @@
 
 #include "main/imports.h"
 
-gammaScreenPtr gammaCreateScreen( __DRIscreenPrivate *sPriv )
+gammaScreenPtr gammaCreateScreen( __DRIscreen *sPriv )
 {
    gammaScreenPtr gammaScreen;
    GLINTDRIPtr gDRIPriv = (GLINTDRIPtr)sPriv->pDevPriv;
@@ -129,7 +129,7 @@ gammaScreenPtr gammaCreateScreen( __DRIscreenPrivate *sPriv )
 
 /* Destroy the device specific screen private data struct.
  */
-void gammaDestroyScreen( __DRIscreenPrivate *sPriv )
+void gammaDestroyScreen( __DRIscreen *sPriv )
 {
     gammaScreenPtr gammaScreen = (gammaScreenPtr)sPriv->private;
 
index 7f0ed6f80eb4b590f469405db2fa4fab173f77e1..c716ea89c297a7e1988a0d059775f9207977e456 100644 (file)
@@ -11,7 +11,7 @@ typedef struct {
 
     drmBufMapPtr  bufs;              /* Map of DMA buffers */
 
-    __DRIscreenPrivate *driScreen; /* Back pointer to DRI screen */
+    __DRIscreen *driScreen; /* Back pointer to DRI screen */
 
     int                cpp;
     int                frontPitch;
index cdaaac3f3ac36ca6edc684c06d04f29561558a82..3f0b81800c559799b6e8a1a46cf1a0549428c1a8 100644 (file)
@@ -10,8 +10,8 @@
 #define LOCAL_VARS                                                     \
    gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);                         \
    gammaScreenPtr gammascrn = gmesa->gammaScreen;                      \
-   __DRIscreenPrivate *sPriv = gmesa->driScreen;                       \
-   __DRIdrawablePrivate *dPriv = gmesa->driDrawable;                   \
+   __DRIscreen *sPriv = gmesa->driScreen;                      \
+   __DRIdrawable *dPriv = gmesa->driDrawable;                  \
    GLuint pitch = sPriv->fbWidth * gammascrn->cpp;             \
    GLuint height = dPriv->h;                                           \
    char *buf = (char *)(sPriv->pFB +                                   \
@@ -24,8 +24,8 @@
 /* FIXME! Depth/Stencil read/writes don't work ! */
 #define LOCAL_DEPTH_VARS                               \
    gammaScreenPtr gammascrn = gmesa->gammaScreen;      \
-   __DRIdrawablePrivate *dPriv = gmesa->driDrawable;   \
-   __DRIscreenPrivate *sPriv = gmesa->driScreen;       \
+   __DRIdrawable *dPriv = gmesa->driDrawable;  \
+   __DRIscreen *sPriv = gmesa->driScreen;      \
    GLuint pitch = gammascrn->depthPitch;               \
    GLuint height = dPriv->h;                           \
    char *buf = (char *)(sPriv->pFB +                   \
index 59272f9bc917cf368888cec21d086bf6f006d2ee..47df37466d791c09f9c89cab684f81f591496484 100644 (file)
@@ -813,10 +813,10 @@ static void gammaUpdateMasks( GLcontext *ctx )
 
 
    GLuint mask = gammaPackColor( gmesa->gammaScreen->cpp,
-                               ctx->Color.ColorMask[RCOMP],
-                               ctx->Color.ColorMask[GCOMP],
-                               ctx->Color.ColorMask[BCOMP],
-                               ctx->Color.ColorMask[ACOMP] );
+                               ctx->Color.ColorMask[0][RCOMP],
+                               ctx->Color.ColorMask[0][GCOMP],
+                               ctx->Color.ColorMask[0][BCOMP],
+                               ctx->Color.ColorMask[0][ACOMP] );
 
    if (gmesa->gammaScreen->cpp == 2) mask |= mask << 16;
 
@@ -1070,7 +1070,7 @@ static void gammaDDReadBuffer( GLcontext *ctx, GLenum mode )
 void gammaUpdateWindow( GLcontext *ctx )
 {
    gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
-   __DRIdrawablePrivate *dPriv = gmesa->driDrawable;
+   __DRIdrawable *dPriv = gmesa->driDrawable;
    GLfloat xoffset = (GLfloat)dPriv->x;
    GLfloat yoffset = gmesa->driScreen->fbHeight - (GLfloat)dPriv->y - dPriv->h;
    const GLfloat *v = ctx->Viewport._WindowMap.m;
@@ -1109,7 +1109,7 @@ static void gammaDDDepthRange( GLcontext *ctx, GLclampd nearval,
 void gammaUpdateViewportOffset( GLcontext *ctx )
 {
    gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
-   __DRIdrawablePrivate *dPriv = gmesa->driDrawable;
+   __DRIdrawable *dPriv = gmesa->driDrawable;
    GLfloat xoffset = (GLfloat)dPriv->x;
    GLfloat yoffset = gmesa->driScreen->fbHeight - (GLfloat)dPriv->y - dPriv->h;
    const GLfloat *v = ctx->Viewport._WindowMap.m;
index 97797d47882d8fef532b2528e6025b6bb844c1dc..694e5eba5bb8d82e7fcfc01275f9363fa322e25c 100644 (file)
@@ -1,21 +1,18 @@
 
-#include <stdlib.h>
-#include <stdio.h>
-
 #include "main/glheader.h"
 #include "main/mtypes.h"
+#include "main/colormac.h"
 #include "main/imports.h"
 #include "main/simple_list.h"
 #include "main/enums.h"
+#include "main/mm.h"
 #include "main/texstore.h"
-#include "teximage.h"
-#include "main/texformat.h"
-#include "texobj.h"
+#include "main/teximage.h"
+#include "main/texobj.h"
+
 #include "swrast/swrast.h"
 
-#include "main/mm.h"
 #include "gammacontext.h"
-#include "colormac.h"
 
 
 /*
@@ -148,7 +145,7 @@ static void gammaTexParameter( GLcontext *ctx, GLenum target,
       break;
   
    case GL_TEXTURE_BORDER_COLOR:
-      gammaSetTexBorderColor( gmesa, t, tObj->BorderColor );
+      gammaSetTexBorderColor( gmesa, t, tObj->BorderColor.f );
       break;
 
    case GL_TEXTURE_BASE_LEVEL:
@@ -352,7 +349,7 @@ static void gammaBindTexture( GLcontext *ctx, GLenum target,
 
         gammaSetTexWrapping( t, tObj->WrapS, tObj->WrapT );
         gammaSetTexFilter( gmesa, t, tObj->MinFilter, tObj->MagFilter, bias );
-        gammaSetTexBorderColor( gmesa, t, tObj->BorderColor );
+        gammaSetTexBorderColor( gmesa, t, tObj->BorderColor.f );
       }
 }
 
index 7b5b53589c64031a5beae4a97a4547e7eb576959..e49ab5bae35b2c0d6ee7d2a81963121401e34b71 100644 (file)
@@ -36,7 +36,7 @@
 #include "vbo/vbo.h"
 
 static GLboolean 
-gammaInitDriver(__DRIscreenPrivate *sPriv)
+gammaInitDriver(__DRIscreen *sPriv)
 {
     sPriv->private = (void *) gammaCreateScreen( sPriv );
 
@@ -49,7 +49,7 @@ gammaInitDriver(__DRIscreenPrivate *sPriv)
 }
 
 static void 
-gammaDestroyContext(__DRIcontextPrivate *driContextPriv)
+gammaDestroyContext(__DRIcontext *driContextPriv)
 {
     gammaContextPtr gmesa = (gammaContextPtr)driContextPriv->driverPrivate;
 
@@ -72,8 +72,8 @@ gammaDestroyContext(__DRIcontextPrivate *driContextPriv)
 
 
 static GLboolean
-gammaCreateBuffer( __DRIscreenPrivate *driScrnPriv,
-                   __DRIdrawablePrivate *driDrawPriv,
+gammaCreateBuffer( __DRIscreen *driScrnPriv,
+                   __DRIdrawable *driDrawPriv,
                    const __GLcontextModes *mesaVis,
                    GLboolean isPixmap )
 {
@@ -94,17 +94,17 @@ gammaCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
 
 static void
-gammaDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+gammaDestroyBuffer(__DRIdrawable *driDrawPriv)
 {
    _mesa_reference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)), NULL);
 }
 
 static void
-gammaSwapBuffers( __DRIdrawablePrivate *dPriv )
+gammaSwapBuffers( __DRIdrawable *dPriv )
 {
    if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
     gammaContextPtr gmesa;
-    __DRIscreenPrivate *driScrnPriv;
+    __DRIscreen *driScrnPriv;
     GLcontext *ctx;
 
     gmesa = (gammaContextPtr) dPriv->driContextPriv->driverPrivate;
@@ -127,7 +127,7 @@ gammaSwapBuffers( __DRIdrawablePrivate *dPriv )
        int i;
        int nRect = dPriv->numClipRects;
        drm_clip_rect_t *pRect = dPriv->pClipRects;
-       __DRIscreenPrivate *driScrnPriv = gmesa->driScreen;
+       __DRIscreen *driScrnPriv = gmesa->driScreen;
        GLINTDRIPtr gDRIPriv = (GLINTDRIPtr)driScrnPriv->pDevPriv;
 
        CHECK_DMA_BUFFER(gmesa, 2);
@@ -193,9 +193,9 @@ gammaSwapBuffers( __DRIdrawablePrivate *dPriv )
 }
 
 static GLboolean 
-gammaMakeCurrent(__DRIcontextPrivate *driContextPriv,
-                __DRIdrawablePrivate *driDrawPriv,
-                __DRIdrawablePrivate *driReadPriv)
+gammaMakeCurrent(__DRIcontext *driContextPriv,
+                __DRIdrawable *driDrawPriv,
+                __DRIdrawable *driReadPriv)
 {
     if (driContextPriv) {
        GET_CURRENT_CONTEXT(ctx);
@@ -232,7 +232,7 @@ newGammaCtx->new_state |= GAMMA_NEW_WINDOW; /* FIXME */
 
 
 static GLboolean 
-gammaUnbindContext( __DRIcontextPrivate *driContextPriv )
+gammaUnbindContext( __DRIcontext *driContextPriv )
 {
    return GL_TRUE;
 }
@@ -254,12 +254,19 @@ const struct __DriverAPIRec driDriverAPI = {
 /*
  * This is the bootstrap function for the driver.
  * The __driCreateScreen name is the symbol that libGL.so fetches.
- * Return:  pointer to a __DRIscreenPrivate.
+ * Return:  pointer to a __DRIscreen.
  */
 void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
                         int numConfigs, __GLXvisualConfig *config)
 {
-   __DRIscreenPrivate *psp;
+   __DRIscreen *psp;
    psp = __driUtilCreateScreen(dpy, scrn, psc, numConfigs, config, &gammaAPI);
    return (void *) psp;
 }
+
+/* This is the table of extensions that the loader will dlsym() for. */
+PUBLIC const __DRIextension *__driDriverExtensions[] = {
+    &driCoreExtension.base,
+    &driLegacyExtension.base,
+    NULL
+};
index a7825b49b44a746cddf6d987b63201dc797d4ffa..3874faee518e7f9cbff727a2d5b49c06e0fe95ed 100644 (file)
@@ -29,4 +29,3 @@ ASM_SOURCES =
 
 include ../Makefile.template
 
-symlinks:
index 67856556865ca103531097d4dc58142f31b2cad4..bd9cfe5c0f75127637f35e5ba4f2583918868d4d 100644 (file)
@@ -116,7 +116,7 @@ static void i810BufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height)
 
 /* Extension strings exported by the i810 driver.
  */
-const struct dri_extension card_extensions[] =
+static const struct dri_extension card_extensions[] =
 {
     { "GL_ARB_multitexture",               NULL },
     { "GL_ARB_texture_env_add",            NULL },
@@ -170,12 +170,12 @@ static const struct dri_debug_control debug_control[] =
 
 GLboolean
 i810CreateContext( const __GLcontextModes *mesaVis,
-                   __DRIcontextPrivate *driContextPriv,
+                   __DRIcontext *driContextPriv,
                    void *sharedContextPrivate )
 {
    GLcontext *ctx, *shareCtx;
    i810ContextPtr imesa;
-   __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+   __DRIscreen *sPriv = driContextPriv->driScreenPriv;
    i810ScreenPrivate *i810Screen = (i810ScreenPrivate *)sPriv->private;
    I810SAREAPtr saPriv = (I810SAREAPtr)
       (((GLubyte *)sPriv->pSAREA) + i810Screen->sarea_priv_offset);
@@ -337,7 +337,7 @@ i810CreateContext( const __GLcontextModes *mesaVis,
 }
 
 void
-i810DestroyContext(__DRIcontextPrivate *driContextPriv)
+i810DestroyContext(__DRIcontext *driContextPriv)
 {
    i810ContextPtr imesa = (i810ContextPtr) driContextPriv->driverPrivate;
 
@@ -378,7 +378,7 @@ i810DestroyContext(__DRIcontextPrivate *driContextPriv)
 
 void i810XMesaSetFrontClipRects( i810ContextPtr imesa )
 {
-   __DRIdrawablePrivate *dPriv = imesa->driDrawable;
+   __DRIdrawable *dPriv = imesa->driDrawable;
 
    imesa->numClipRects = dPriv->numClipRects;
    imesa->pClipRects = dPriv->pClipRects;
@@ -392,7 +392,7 @@ void i810XMesaSetFrontClipRects( i810ContextPtr imesa )
 
 void i810XMesaSetBackClipRects( i810ContextPtr imesa )
 {
-   __DRIdrawablePrivate *dPriv = imesa->driDrawable;
+   __DRIdrawable *dPriv = imesa->driDrawable;
 
    if (imesa->sarea->pf_enabled == 0 && dPriv->numBackClipRects == 0)
    {
@@ -430,7 +430,7 @@ static void i810XMesaWindowMoved( i810ContextPtr imesa )
 
 
 GLboolean
-i810UnbindContext(__DRIcontextPrivate *driContextPriv)
+i810UnbindContext(__DRIcontext *driContextPriv)
 {
    i810ContextPtr imesa = (i810ContextPtr) driContextPriv->driverPrivate;
    if (imesa) {
@@ -444,9 +444,9 @@ i810UnbindContext(__DRIcontextPrivate *driContextPriv)
 
 
 GLboolean
-i810MakeCurrent(__DRIcontextPrivate *driContextPriv,
-                __DRIdrawablePrivate *driDrawPriv,
-                __DRIdrawablePrivate *driReadPriv)
+i810MakeCurrent(__DRIcontext *driContextPriv,
+                __DRIdrawable *driDrawPriv,
+                __DRIdrawable *driReadPriv)
 {
    if (driContextPriv) {
       i810ContextPtr imesa = (i810ContextPtr) driContextPriv->driverPrivate;
@@ -504,8 +504,8 @@ i810UpdatePageFlipping( i810ContextPtr imesa )
 
 void i810GetLock( i810ContextPtr imesa, GLuint flags )
 {
-   __DRIdrawablePrivate *dPriv = imesa->driDrawable;
-   __DRIscreenPrivate *sPriv = imesa->driScreen;
+   __DRIdrawable *dPriv = imesa->driDrawable;
+   __DRIscreen *sPriv = imesa->driScreen;
    I810SAREAPtr sarea = imesa->sarea;
    int me = imesa->hHWContext;
    unsigned i;
@@ -551,7 +551,7 @@ void i810GetLock( i810ContextPtr imesa, GLuint flags )
 
 
 void
-i810SwapBuffers( __DRIdrawablePrivate *dPriv )
+i810SwapBuffers( __DRIdrawable *dPriv )
 {
    if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
       i810ContextPtr imesa;
index 4b8c71d7c6c41faf66adcccd38ba971d934d0b10..19529db02001b9cb7b3ec12ba928519a020a48bb 100644 (file)
@@ -170,8 +170,8 @@ struct i810_context_t {
    drm_hw_lock_t *driHwLock;
    int driFd;
 
-   __DRIdrawablePrivate *driDrawable;
-   __DRIscreenPrivate *driScreen;
+   __DRIdrawable *driDrawable;
+   __DRIscreen *driScreen;
    i810ScreenPrivate *i810Screen; 
    I810SAREAPtr sarea;
 };
index 3df9c2ac478ca39d5495f3e035b4957e722977dd..c631543d933dc998be7346111f1e1949771badc7 100644 (file)
@@ -50,8 +50,8 @@ static drmBufPtr i810_get_buffer_ioctl( i810ContextPtr imesa )
 static void i810Clear( GLcontext *ctx, GLbitfield mask )
 {
    i810ContextPtr imesa = I810_CONTEXT( ctx );
-   __DRIdrawablePrivate *dPriv = imesa->driDrawable;
-   const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
+   __DRIdrawable *dPriv = imesa->driDrawable;
+   const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask[0]);
    drmI810Clear clear;
    unsigned int i;
 
@@ -149,7 +149,7 @@ static void i810Clear( GLcontext *ctx, GLbitfield mask )
 /*
  * Copy the back buffer to the front buffer. 
  */
-void i810CopyBuffer( const __DRIdrawablePrivate *dPriv ) 
+void i810CopyBuffer( const __DRIdrawable *dPriv ) 
 {
    i810ContextPtr imesa;
    drm_clip_rect_t *pbox;
@@ -197,7 +197,7 @@ void i810CopyBuffer( const __DRIdrawablePrivate *dPriv )
 /*
  * XXX implement when full-screen extension is done.
  */
-void i810PageFlip( const __DRIdrawablePrivate *dPriv ) 
+void i810PageFlip( const __DRIdrawable *dPriv ) 
 {
   i810ContextPtr imesa;
   int tmp, ret;
index dfd6e21088943dd490e7f1ed4aba86c7aaff0777..926e38ce51c8b034838ef5b4497f64c1b89101bb 100644 (file)
@@ -14,8 +14,8 @@ void i810WaitAge( i810ContextPtr imesa, int age );
 void i810DmaFinish( i810ContextPtr imesa );
 void i810RegetLockQuiescent( i810ContextPtr imesa );
 void i810InitIoctlFuncs( struct dd_function_table *functions );
-void i810CopyBuffer( const __DRIdrawablePrivate *dpriv );
-void i810PageFlip( const __DRIdrawablePrivate *dpriv );
+void i810CopyBuffer( const __DRIdrawable *dpriv );
+void i810PageFlip( const __DRIdrawable *dpriv );
 int i810_check_copy(int fd);
 
 #define I810_STATECHANGE(imesa, flag)                          \
index 6e49f3466c3ccea78b6aa50c9f81621fdcef6a48..2a30782afd465da73c150e68b965f3c3be0f248e 100644 (file)
@@ -53,10 +53,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "GL/internal/dri_interface.h"
 
-extern const struct dri_extension card_extensions[];
-
 static const __DRIconfig **
-i810FillInModes( __DRIscreenPrivate *psp,
+i810FillInModes( __DRIscreen *psp,
                 unsigned pixel_bits, unsigned depth_bits,
                 unsigned stencil_bits, GLboolean have_back_buffer )
 {
@@ -166,8 +164,6 @@ i810InitScreen(__DRIscreen *sPriv)
       return NULL;
    }
 
-   driInitExtensions( NULL, card_extensions, GL_TRUE );
-
    if (sPriv->devPrivSize != sizeof(I810DRIRec)) {
       fprintf(stderr,"\nERROR!  sizeof(I810DRIRec) does not match passed size from device driver\n");
       return GL_FALSE;
@@ -259,7 +255,7 @@ i810InitScreen(__DRIscreen *sPriv)
 }
 
 static void
-i810DestroyScreen(__DRIscreenPrivate *sPriv)
+i810DestroyScreen(__DRIscreen *sPriv)
 {
    i810ScreenPrivate *i810Screen = (i810ScreenPrivate *)sPriv->private;
 
@@ -278,8 +274,8 @@ i810DestroyScreen(__DRIscreenPrivate *sPriv)
  * Create a buffer which corresponds to the window.
  */
 static GLboolean
-i810CreateBuffer( __DRIscreenPrivate *driScrnPriv,
-                  __DRIdrawablePrivate *driDrawPriv,
+i810CreateBuffer( __DRIscreen *driScrnPriv,
+                  __DRIdrawable *driDrawPriv,
                   const __GLcontextModes *mesaVis,
                   GLboolean isPixmap )
 {
@@ -293,7 +289,7 @@ i810CreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       {
          driRenderbuffer *frontRb
-            = driNewRenderbuffer(GL_RGBA,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888,
                                  driScrnPriv->pFB,
                                  screen->cpp,
                                  /*screen->frontOffset*/0, screen->backPitch,
@@ -304,7 +300,7 @@ i810CreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->doubleBufferMode) {
          driRenderbuffer *backRb
-            = driNewRenderbuffer(GL_RGBA,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888,
                                  screen->back.map,
                                  screen->cpp,
                                  screen->backOffset, screen->backPitch,
@@ -315,7 +311,7 @@ i810CreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->depthBits == 16) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT16,
+            = driNewRenderbuffer(MESA_FORMAT_Z16,
                                  screen->depth.map,
                                  screen->cpp,
                                  screen->depthOffset, screen->backPitch,
@@ -339,7 +335,7 @@ i810CreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
 
 static void
-i810DestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+i810DestroyBuffer(__DRIdrawable *driDrawPriv)
 {
    _mesa_reference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)), NULL);
 }
@@ -360,3 +356,10 @@ const struct __DriverAPIRec driDriverAPI = {
    .WaitForSBC      = NULL,
    .SwapBuffersMSC  = NULL
 };
+
+/* This is the table of extensions that the loader will dlsym() for. */
+PUBLIC const __DRIextension *__driDriverExtensions[] = {
+    &driCoreExtension.base,
+    &driLegacyExtension.base,
+    NULL
+};
index b29937665af4c1611c2d2131cf8e7d2907fa869c..734e2fb002d965b401dd63dd8d59055ba55c7fa5 100644 (file)
@@ -71,7 +71,7 @@ typedef struct {
    int textureSize;
    int logTextureGranularity;
 
-   __DRIscreenPrivate *driScrnPriv;
+   __DRIscreen *driScrnPriv;
    drmBufMapPtr  bufs;
    unsigned int sarea_priv_offset;
 } i810ScreenPrivate;
@@ -79,21 +79,21 @@ typedef struct {
 
 extern GLboolean
 i810CreateContext( const __GLcontextModes *mesaVis,
-                   __DRIcontextPrivate *driContextPriv,
+                   __DRIcontext *driContextPriv,
                    void *sharedContextPrivate );
 
 extern void
-i810DestroyContext(__DRIcontextPrivate *driContextPriv);
+i810DestroyContext(__DRIcontext *driContextPriv);
 
 extern GLboolean
-i810UnbindContext(__DRIcontextPrivate *driContextPriv);
+i810UnbindContext(__DRIcontext *driContextPriv);
 
 extern GLboolean
-i810MakeCurrent(__DRIcontextPrivate *driContextPriv,
-                __DRIdrawablePrivate *driDrawPriv,
-                __DRIdrawablePrivate *driReadPriv);
+i810MakeCurrent(__DRIcontext *driContextPriv,
+                __DRIdrawable *driDrawPriv,
+                __DRIdrawable *driReadPriv);
 
 extern void
-i810SwapBuffers(__DRIdrawablePrivate *driDrawPriv);
+i810SwapBuffers(__DRIdrawable *driDrawPriv);
 
 #endif
index 510723f44560090b8ad4bd565ea8346c0cb09c69..6576f6745eac0ad9e6e338171779b71498325054 100644 (file)
@@ -15,7 +15,7 @@
 
 #define LOCAL_VARS                                     \
    i810ContextPtr imesa = I810_CONTEXT(ctx);           \
-   __DRIdrawablePrivate *dPriv = imesa->driDrawable;   \
+   __DRIdrawable *dPriv = imesa->driDrawable;  \
    driRenderbuffer *drb = (driRenderbuffer *) rb;      \
    GLuint pitch = drb->pitch;                          \
    GLuint height = dPriv->h;                           \
@@ -27,7 +27,7 @@
 
 #define LOCAL_DEPTH_VARS                               \
    i810ContextPtr imesa = I810_CONTEXT(ctx);           \
-   __DRIdrawablePrivate *dPriv = imesa->driDrawable;   \
+   __DRIdrawable *dPriv = imesa->driDrawable;  \
    driRenderbuffer *drb = (driRenderbuffer *) rb;      \
    GLuint pitch = drb->pitch;                          \
    GLuint height = dPriv->h;                           \
index 1e7a6cfe471b073aacc8e4a09f59af7a7cc826da..642245c61c8b58569909e156908bf34d30a95360 100644 (file)
@@ -641,7 +641,7 @@ static void i810Enable(GLcontext *ctx, GLenum cap, GLboolean state)
 
 void i810EmitDrawingRectangle( i810ContextPtr imesa )
 {
-   __DRIdrawablePrivate *dPriv = imesa->driDrawable;
+   __DRIdrawable *dPriv = imesa->driDrawable;
    i810ScreenPrivate *i810Screen = imesa->i810Screen;
    int x0 = imesa->drawX;
    int y0 = imesa->drawY;
index cd6e1a8e6e831416954ed79e111427d98e25425e..e764644a6c1b8b7e651d88cc12baf43b0bff67fa 100644 (file)
@@ -28,7 +28,6 @@
 #include "main/simple_list.h"
 #include "main/enums.h"
 #include "main/texstore.h"
-#include "main/texformat.h"
 #include "main/teximage.h"
 #include "main/texobj.h"
 #include "main/colormac.h"
@@ -211,7 +210,7 @@ i810AllocTexObj( GLcontext *ctx, struct gl_texture_object *texObj )
       i810SetTexWrapping( t, texObj->WrapS, texObj->WrapT );
       /*i830SetTexMaxAnisotropy( t, texObj->MaxAnisotropy );*/
       i810SetTexFilter( imesa, t, texObj->MinFilter, texObj->MagFilter, bias );
-      i810SetTexBorderColor( t, texObj->BorderColor );
+      i810SetTexBorderColor( t, texObj->BorderColor.f );
    }
 
    return t;
@@ -252,7 +251,7 @@ static void i810TexParameter( GLcontext *ctx, GLenum target,
       break;
   
    case GL_TEXTURE_BORDER_COLOR:
-      i810SetTexBorderColor( t, tObj->BorderColor );
+      i810SetTexBorderColor( t, tObj->BorderColor.f );
       break;
 
    case GL_TEXTURE_BASE_LEVEL:
@@ -440,7 +439,7 @@ static void i810DeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
  * The i810 only supports 5 texture modes that are useful to Mesa.  That
  * makes this routine pretty simple.
  */
-static const struct gl_texture_format *
+static gl_format
 i810ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
                         GLenum format, GLenum type )
 {
@@ -458,9 +457,9 @@ i810ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
       if ( ((format == GL_BGRA) && (type == GL_UNSIGNED_SHORT_1_5_5_5_REV))
           || ((format == GL_RGBA) && (type == GL_UNSIGNED_SHORT_5_5_5_1))
           || (internalFormat == GL_RGB5_A1) ) {
-        return &_mesa_texformat_argb1555;
+        return MESA_FORMAT_ARGB1555;
       }
-      return &_mesa_texformat_argb4444;
+      return MESA_FORMAT_ARGB4444;
 
    case 3:
    case GL_RGB:
@@ -472,7 +471,7 @@ i810ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_RGB10:
    case GL_RGB12:
    case GL_RGB16:
-      return &_mesa_texformat_rgb565;
+      return MESA_FORMAT_RGB565;
 
    case GL_ALPHA:
    case GL_ALPHA4:
@@ -502,21 +501,21 @@ i810ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_INTENSITY12:
    case GL_INTENSITY16:
    case GL_COMPRESSED_INTENSITY:
-      return &_mesa_texformat_al88;
+      return MESA_FORMAT_AL88;
 
    case GL_YCBCR_MESA:
       if (type == GL_UNSIGNED_SHORT_8_8_MESA ||
          type == GL_UNSIGNED_BYTE)
-         return &_mesa_texformat_ycbcr;
+         return MESA_FORMAT_YCBCR;
       else
-         return &_mesa_texformat_ycbcr_rev;
+         return MESA_FORMAT_YCBCR_REV;
 
    default:
       fprintf(stderr, "unexpected texture format in %s\n", __FUNCTION__);
-      return NULL;
+      return MESA_FORMAT_NONE;
    }
 
-   return NULL; /* never get here */
+   return MESA_FORMAT_NONE; /* never get here */
 }
 
 /**
index d9809270308dde19e44b21baeb6b7a218e975a3f..28958dcb4b241261828385cd67c810dc9149a80c 100644 (file)
@@ -29,7 +29,6 @@
 #include "main/mtypes.h"
 #include "main/mm.h"
 
-#include "i810context.h"
 #include "i810_3d_reg.h"
 #include "texmem.h"
 
index 5ad66dbf5cb1e38d6066227757c4fab98833b412..d93afbf9ef6b5b9e3164b2f246b55b312f878e1d 100644 (file)
@@ -30,7 +30,6 @@
 #include "main/enums.h"
 #include "main/colormac.h"
 #include "main/mm.h"
-#include "main/texformat.h"
 
 #include "i810screen.h"
 #include "i810_dri.h"
@@ -92,44 +91,47 @@ static void i810UploadTexLevel( i810ContextPtr imesa,
 {
    const struct gl_texture_image *image = t->image[hwlevel].image;
    int j;
+   GLuint texelBytes;
 
    if (!image || !image->Data)
       return;
 
-   if (image->Width * image->TexFormat->TexelBytes == t->Pitch) {
+   texelBytes = _mesa_get_format_bytes(image->TexFormat);
+
+   if (image->Width * texelBytes == t->Pitch) {
         GLubyte *dst = (GLubyte *)(t->BufAddr + t->image[hwlevel].offset);
         GLubyte *src = (GLubyte *)image->Data;
         
         memcpy( dst, src, t->Pitch * image->Height );
    }
-   else switch (image->TexFormat->TexelBytes) {
-   case 1:
-      {
-        GLubyte *dst = (GLubyte *)(t->BufAddr + t->image[hwlevel].offset);
-        GLubyte *src = (GLubyte *)image->Data;
-
-        for (j = 0 ; j < image->Height ; j++, dst += t->Pitch) {
-           __memcpy(dst, src, image->Width );
-           src += image->Width;
-        }
+   else {
+      switch (texelBytes) {
+      case 1:
+         {
+            GLubyte *dst = (GLubyte *)(t->BufAddr + t->image[hwlevel].offset);
+            GLubyte *src = (GLubyte *)image->Data;
+
+            for (j = 0 ; j < image->Height ; j++, dst += t->Pitch) {
+               __memcpy(dst, src, image->Width );
+               src += image->Width;
+            }
+         }
+         break;
+      case 2:
+         {
+            GLushort *dst = (GLushort *)(t->BufAddr + t->image[hwlevel].offset);
+            GLushort *src = (GLushort *)image->Data;
+
+            for (j = 0 ; j < image->Height ; j++, dst += (t->Pitch/2)) {
+               __memcpy(dst, src, image->Width * 2 );
+               src += image->Width;
+            }
+         }
+         break;
+      default:
+         fprintf(stderr, "%s: Not supported texel size %d\n",
+                 __FUNCTION__, texelBytes);
       }
-      break;
-
-   case 2:
-      {
-        GLushort *dst = (GLushort *)(t->BufAddr + t->image[hwlevel].offset);
-        GLushort *src = (GLushort *)image->Data;
-
-        for (j = 0 ; j < image->Height ; j++, dst += (t->Pitch/2)) {
-           __memcpy(dst, src, image->Width * 2 );
-           src += image->Width;
-        }
-      }
-      break;
-
-   default:
-      fprintf(stderr, "%s: Not supported texel size %d\n",
-             __FUNCTION__, image->TexFormat->TexelBytes);
    }
 }
 
index 0e09f54c41bdf8c3e369c49fa4f6216768c382b4..bff28c11c8942c1503e17eacc07de15db4638520 100644 (file)
@@ -25,7 +25,6 @@
 #include "main/glheader.h"
 #include "main/macros.h"
 #include "main/mtypes.h"
-#include "main/texformat.h"
 #include "main/simple_list.h"
 #include "main/enums.h"
 #include "main/mm.h"
@@ -53,7 +52,7 @@ static void i810SetTexImages( i810ContextPtr imesa,
 /*     fprintf(stderr, "%s\n", __FUNCTION__); */
 
    t->texelBytes = 2;
-   switch (baseImage->TexFormat->MesaFormat) {
+   switch (baseImage->TexFormat) {
    case MESA_FORMAT_ARGB1555:
       textureFormat = MI1_FMT_16BPP | MI1_PF_16BPP_ARGB1555;
       break;
index b508496fb6953a075455eaea187fc00a09480686..213ba541cee24a5da6fab266c47b240430e585bf 100644 (file)
@@ -270,7 +270,8 @@ do {                                                        \
 
 #define LOCAL_VARS(n)                                                  \
    i810ContextPtr imesa = I810_CONTEXT(ctx);                           \
-   GLuint color[n], spec[n];                                           \
+   GLuint color[n] = { 0 };                                            \
+   GLuint spec[n] = { 0 };                                             \
    GLuint coloroffset = (imesa->vertex_size == 4 ? 3 : 4);             \
    GLboolean havespec = (imesa->vertex_size > 4);                      \
    (void) color; (void) spec; (void) coloroffset; (void) havespec;
index 393312e7328ba049922c4d82fa4a4ab47cb5d70e..cf32476f4089c613320b45d1b74aac6bfd1db8d7 100644 (file)
@@ -34,7 +34,6 @@ DRIVER_SOURCES = \
        intel_pixel_read.c \
        intel_buffers.c \
        intel_blit.c \
-       intel_swapbuffers.c \
        i915_tex_layout.c \
        i915_texstate.c \
        i915_context.c \
@@ -64,7 +63,8 @@ DRIVER_DEFINES = -I../intel -I../intel/server -DI915 \
        $(shell pkg-config libdrm --atleast-version=2.3.1 \
                                && echo "-DDRM_VBLANK_FLIP=DRM_VBLANK_FLIP")
 
-DRI_LIB_DEPS += -ldrm_intel
+INCLUDES += $(INTEL_CFLAGS)
+DRI_LIB_DEPS += $(INTEL_LIBS)
 
 include ../Makefile.template
 
@@ -72,4 +72,3 @@ intel_decode.o: ../intel/intel_decode.c
 
 intel_tex_layout.o: ../intel/intel_tex_layout.c
 
-symlinks:
index 840946f908ddb5a3eaca23f74bae65669368efa1..4cb63059884b7cadde81bea3bb02fff28009b94d 100644 (file)
@@ -53,7 +53,7 @@ extern const struct tnl_pipeline_stage *intel_pipeline[];
 
 GLboolean
 i830CreateContext(const __GLcontextModes * mesaVis,
-                  __DRIcontextPrivate * driContextPriv,
+                  __DRIcontext * driContextPriv,
                   void *sharedContextPrivate)
 {
    struct dd_function_table functions;
index f73cbbf88bb9e7dd70f7a9a943154c8326648096..592ae53976103db9bf26eeec26ca7d630ab2e8fa 100644 (file)
@@ -178,7 +178,7 @@ i830_state_draw_region(struct intel_context *intel,
  */
 extern GLboolean
 i830CreateContext(const __GLcontextModes * mesaVis,
-                  __DRIcontextPrivate * driContextPriv,
+                  __DRIcontext * driContextPriv,
                   void *sharedContextPrivate);
 
 /* i830_tex.c, i830_texstate.c
index 645ebe305774410b90153bf7a31ceca0fa9ae888..acda7e70de0dc50ca4bf708700778825fa3203f9 100644 (file)
@@ -620,7 +620,7 @@ i830LineWidth(GLcontext * ctx, GLfloat widthf)
    DBG("%s\n", __FUNCTION__);
    
    width = (int) (widthf * 2);
-   CLAMP_SELF(width, 1, 15);
+   width = CLAMP(width, 1, 15);
 
    state5 = i830->state.Ctx[I830_CTXREG_STATE5] & ~FIXED_LINE_WIDTH_MASK;
    state5 |= (ENABLE_FIXED_LINE_WIDTH | FIXED_LINE_WIDTH(width));
@@ -639,7 +639,7 @@ i830PointSize(GLcontext * ctx, GLfloat size)
 
    DBG("%s\n", __FUNCTION__);
    
-   CLAMP_SELF(point_size, 1, 256);
+   point_size = CLAMP(point_size, 1, 256);
    I830_STATECHANGE(i830, I830_UPLOAD_CTX);
    i830->state.Ctx[I830_CTXREG_STATE5] &= ~FIXED_POINT_WIDTH_MASK;
    i830->state.Ctx[I830_CTXREG_STATE5] |= (ENABLE_FIXED_POINT_WIDTH |
index 09f7f37e7650753a8175b4a7fffcfb19348eeb28..3f64be8c962a0bcf2fde681f33f94309927365c1 100644 (file)
@@ -30,7 +30,6 @@
 #include "main/mtypes.h"
 #include "main/simple_list.h"
 #include "main/enums.h"
-#include "main/texformat.h"
 #include "main/texstore.h"
 #include "main/mm.h"
 
index 6f998fa6f773826eae70dcba0f9f476370cb72e4..7525f9f2e0540b03c7ede9a1295b3fb5d51e53d2 100644 (file)
@@ -27,7 +27,7 @@
 
 #include "main/mtypes.h"
 #include "main/enums.h"
-#include "main/texformat.h"
+#include "main/colormac.h"
 
 #include "intel_mipmap_tree.h"
 #include "intel_tex.h"
@@ -56,10 +56,9 @@ translate_texture_format(GLuint mesa_format, GLuint internal_format)
    case MESA_FORMAT_ARGB4444:
       return MAPSURF_16BIT | MT_16BIT_ARGB4444;
    case MESA_FORMAT_ARGB8888:
-      if (internal_format == GL_RGB)
-        return MAPSURF_32BIT | MT_32BIT_XRGB8888;
-      else
-        return MAPSURF_32BIT | MT_32BIT_ARGB8888;
+      return MAPSURF_32BIT | MT_32BIT_ARGB8888;
+   case MESA_FORMAT_XRGB8888:
+      return MAPSURF_32BIT | MT_32BIT_XRGB8888;
    case MESA_FORMAT_YCBCR_REV:
       return (MAPSURF_422 | MT_422_YCRCB_NORMAL);
    case MESA_FORMAT_YCBCR:
@@ -160,13 +159,20 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
 
       pitch = intelObj->pitchOverride;
    } else {
+      GLuint dst_x, dst_y;
+
+      intel_miptree_get_image_offset(intelObj->mt, intelObj->firstLevel, 0, 0,
+                                    &dst_x, &dst_y);
+
       dri_bo_reference(intelObj->mt->region->buffer);
       i830->state.tex_buffer[unit] = intelObj->mt->region->buffer;
-      i830->state.tex_offset[unit] = intel_miptree_image_offset(intelObj->mt,
-                                                               0, intelObj->
-                                                               firstLevel);
+      /* XXX: This calculation is probably broken for tiled images with
+       * a non-page-aligned offset.
+       */
+      i830->state.tex_offset[unit] = (dst_x + dst_y * intelObj->mt->pitch) *
+        intelObj->mt->cpp;
 
-      format = translate_texture_format(firstImage->TexFormat->MesaFormat,
+      format = translate_texture_format(firstImage->TexFormat,
                                        firstImage->InternalFormat);
       pitch = intelObj->mt->pitch * intelObj->mt->cpp;
    }
@@ -298,16 +304,15 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
    }
 
    /* convert border color from float to ubyte */
-   CLAMPED_FLOAT_TO_UBYTE(border[0], tObj->BorderColor[0]);
-   CLAMPED_FLOAT_TO_UBYTE(border[1], tObj->BorderColor[1]);
-   CLAMPED_FLOAT_TO_UBYTE(border[2], tObj->BorderColor[2]);
-   CLAMPED_FLOAT_TO_UBYTE(border[3], tObj->BorderColor[3]);
-
-   state[I830_TEXREG_TM0S4] = INTEL_PACKCOLOR8888(border[0],
-                                                  border[1],
-                                                  border[2],
-                                                  border[3]);
-
+   CLAMPED_FLOAT_TO_UBYTE(border[0], tObj->BorderColor.f[0]);
+   CLAMPED_FLOAT_TO_UBYTE(border[1], tObj->BorderColor.f[1]);
+   CLAMPED_FLOAT_TO_UBYTE(border[2], tObj->BorderColor.f[2]);
+   CLAMPED_FLOAT_TO_UBYTE(border[3], tObj->BorderColor.f[3]);
+
+   state[I830_TEXREG_TM0S4] = PACK_COLOR_8888(border[3],
+                                             border[0],
+                                             border[1],
+                                             border[2]);
 
    I830_ACTIVESTATE(i830, I830_UPLOAD_TEX(unit), GL_TRUE);
    /* memcmp was already disabled, but definitely won't work as the
index 983f6724c98a0885889cc767e011fcd2920a4774..4471ca2bbbdaa0c19d321a870751a8b6a07b20f8 100644 (file)
@@ -26,7 +26,6 @@
  **************************************************************************/
 
 #include "glapi/glapi.h"
-#include "main/texformat.h"
 
 #include "i830_context.h"
 #include "i830_reg.h"
@@ -127,7 +126,7 @@ i830_render_start(struct intel_context *intel)
 
       for (i = 0; i < I830_TEX_UNITS; i++) {
          if (RENDERINPUTS_TEST(index_bitset, _TNL_ATTRIB_TEX(i))) {
-            GLuint sz = VB->TexCoordPtr[i]->size;
+            GLuint sz = VB->AttribPtr[_TNL_ATTRIB_TEX0 + i]->size;
             GLuint emit;
             GLuint mcs = (i830->state.Tex[i][I830_TEXREG_MCS] &
                           ~TEXCOORDTYPE_MASK);
@@ -299,7 +298,7 @@ i830_emit_invarient_state(struct intel_context *intel)
 {
    BATCH_LOCALS;
 
-   BEGIN_BATCH(29, IGNORE_CLIPRECTS);
+   BEGIN_BATCH(29);
 
    OUT_BATCH(_3DSTATE_DFLT_DIFFUSE_CMD);
    OUT_BATCH(0);
@@ -367,7 +366,7 @@ i830_emit_invarient_state(struct intel_context *intel)
 
 
 #define emit( intel, state, size )                     \
-   intel_batchbuffer_data(intel->batch, state, size, IGNORE_CLIPRECTS )
+   intel_batchbuffer_data(intel->batch, state, size )
 
 static GLuint
 get_dirty(struct i830_hw_state *state)
@@ -430,13 +429,9 @@ i830_emit_state(struct intel_context *intel)
     * It might be better to talk about explicit places where
     * scheduling is allowed, rather than assume that it is whenever a
     * batchbuffer fills up.
-    *
-    * Set the space as LOOP_CLIPRECTS now, since that's what our primitives
-    * will be emitted under.
     */
    intel_batchbuffer_require_space(intel->batch,
-                                  get_state_size(state) + INTEL_PRIM_EMIT_SIZE,
-                                  LOOP_CLIPRECTS);
+                                  get_state_size(state) + INTEL_PRIM_EMIT_SIZE);
    count = 0;
  again:
    aper_count = 0;
@@ -492,17 +487,14 @@ i830_emit_state(struct intel_context *intel)
    }
 
    if (dirty & I830_UPLOAD_BUFFERS) {
-      GLuint count = 9; 
+      GLuint count = 15;
 
       DBG("I830_UPLOAD_BUFFERS:\n");
 
       if (state->depth_region)
           count += 3;
 
-      if (intel->constant_cliprect)
-          count += 6;
-
-      BEGIN_BATCH(count, IGNORE_CLIPRECTS);
+      BEGIN_BATCH(count);
       OUT_BATCH(state->Buffer[I830_DESTREG_CBUFADDR0]);
       OUT_BATCH(state->Buffer[I830_DESTREG_CBUFADDR1]);
       OUT_RELOC(state->draw_region->buffer,
@@ -524,15 +516,13 @@ i830_emit_state(struct intel_context *intel)
       OUT_BATCH(state->Buffer[I830_DESTREG_SR1]);
       OUT_BATCH(state->Buffer[I830_DESTREG_SR2]);
 
-      if (intel->constant_cliprect) {
-        assert(state->Buffer[I830_DESTREG_DRAWRECT0] != MI_NOOP);
-        OUT_BATCH(state->Buffer[I830_DESTREG_DRAWRECT0]);
-        OUT_BATCH(state->Buffer[I830_DESTREG_DRAWRECT1]);
-        OUT_BATCH(state->Buffer[I830_DESTREG_DRAWRECT2]);
-        OUT_BATCH(state->Buffer[I830_DESTREG_DRAWRECT3]);
-        OUT_BATCH(state->Buffer[I830_DESTREG_DRAWRECT4]);
-        OUT_BATCH(state->Buffer[I830_DESTREG_DRAWRECT5]);
-      }
+      assert(state->Buffer[I830_DESTREG_DRAWRECT0] != MI_NOOP);
+      OUT_BATCH(state->Buffer[I830_DESTREG_DRAWRECT0]);
+      OUT_BATCH(state->Buffer[I830_DESTREG_DRAWRECT1]);
+      OUT_BATCH(state->Buffer[I830_DESTREG_DRAWRECT2]);
+      OUT_BATCH(state->Buffer[I830_DESTREG_DRAWRECT3]);
+      OUT_BATCH(state->Buffer[I830_DESTREG_DRAWRECT4]);
+      OUT_BATCH(state->Buffer[I830_DESTREG_DRAWRECT5]);
       ADVANCE_BATCH();
    }
    
@@ -545,7 +535,7 @@ i830_emit_state(struct intel_context *intel)
       if ((dirty & I830_UPLOAD_TEX(i))) {
          DBG("I830_UPLOAD_TEX(%d):\n", i);
 
-         BEGIN_BATCH(I830_TEX_SETUP_SIZE + 1, IGNORE_CLIPRECTS);
+         BEGIN_BATCH(I830_TEX_SETUP_SIZE + 1);
          OUT_BATCH(state->Tex[i][I830_TEXREG_TM0LI]);
 
          if (state->tex_buffer[i]) {
@@ -646,8 +636,9 @@ i830_state_draw_region(struct intel_context *intel,
             DSTORG_VERT_BIAS(0x8) | DEPTH_IS_Z);    /* .5 */
 
    if (irb != NULL) {
-      switch (irb->texformat->MesaFormat) {
+      switch (irb->Base.Format) {
       case MESA_FORMAT_ARGB8888:
+      case MESA_FORMAT_XRGB8888:
         value |= DV_PF_8888;
         break;
       case MESA_FORMAT_RGB565:
@@ -661,7 +652,7 @@ i830_state_draw_region(struct intel_context *intel,
         break;
       default:
         _mesa_problem(ctx, "Bad renderbuffer format: %d\n",
-                      irb->texformat->MesaFormat);
+                      irb->Base.Format);
       }
    }
 
@@ -673,23 +664,14 @@ i830_state_draw_region(struct intel_context *intel,
    }
    state->Buffer[I830_DESTREG_DV1] = value;
 
-   if (intel->constant_cliprect) {
-      state->Buffer[I830_DESTREG_DRAWRECT0] = _3DSTATE_DRAWRECT_INFO;
-      state->Buffer[I830_DESTREG_DRAWRECT1] = 0;
-      state->Buffer[I830_DESTREG_DRAWRECT2] = 0; /* xmin, ymin */
-      state->Buffer[I830_DESTREG_DRAWRECT3] =
-        (ctx->DrawBuffer->Width & 0xffff) |
-        (ctx->DrawBuffer->Height << 16);
-      state->Buffer[I830_DESTREG_DRAWRECT4] = 0; /* xoff, yoff */
-      state->Buffer[I830_DESTREG_DRAWRECT5] = 0;
-   } else {
-      state->Buffer[I830_DESTREG_DRAWRECT0] = MI_NOOP;
-      state->Buffer[I830_DESTREG_DRAWRECT1] = MI_NOOP;
-      state->Buffer[I830_DESTREG_DRAWRECT2] = MI_NOOP;
-      state->Buffer[I830_DESTREG_DRAWRECT3] = MI_NOOP;
-      state->Buffer[I830_DESTREG_DRAWRECT4] = MI_NOOP;
-      state->Buffer[I830_DESTREG_DRAWRECT5] = MI_NOOP;
-   }
+   state->Buffer[I830_DESTREG_DRAWRECT0] = _3DSTATE_DRAWRECT_INFO;
+   state->Buffer[I830_DESTREG_DRAWRECT1] = 0;
+   state->Buffer[I830_DESTREG_DRAWRECT2] = 0; /* xmin, ymin */
+   state->Buffer[I830_DESTREG_DRAWRECT3] =
+      (ctx->DrawBuffer->Width & 0xffff) |
+      (ctx->DrawBuffer->Height << 16);
+   state->Buffer[I830_DESTREG_DRAWRECT4] = 0; /* xoff, yoff */
+   state->Buffer[I830_DESTREG_DRAWRECT5] = 0;
 
    I830_STATECHANGE(i830, I830_UPLOAD_BUFFERS);
 
@@ -714,20 +696,8 @@ i830_new_batch(struct intel_context *intel)
 {
    struct i830_context *i830 = i830_context(&intel->ctx);
    i830->state.emitted = 0;
-
-   /* Check that we didn't just wrap our batchbuffer at a bad time. */
-   assert(!intel->no_batch_wrap);
-}
-
-
-
-static GLuint
-i830_flush_cmd(void)
-{
-   return MI_FLUSH | FLUSH_MAP_CACHE;
 }
 
-
 static void 
 i830_assert_not_dirty( struct intel_context *intel )
 {
@@ -753,7 +723,6 @@ i830InitVtbl(struct i830_context *i830)
    i830->intel.vtbl.reduced_primitive_state = i830_reduced_primitive_state;
    i830->intel.vtbl.set_draw_region = i830_set_draw_region;
    i830->intel.vtbl.update_texture_state = i830UpdateTextureState;
-   i830->intel.vtbl.flush_cmd = i830_flush_cmd;
    i830->intel.vtbl.render_start = i830_render_start;
    i830->intel.vtbl.render_prevalidate = i830_render_prevalidate;
    i830->intel.vtbl.assert_not_dirty = i830_assert_not_dirty;
index 7d4c7cfbabbdd1a1d6e346f7f826c3242a5c30b7..7c7711da099a588a60f31ad98011e59c97db0c70 100644 (file)
@@ -100,7 +100,7 @@ extern const struct tnl_pipeline_stage *intel_pipeline[];
 
 GLboolean
 i915CreateContext(const __GLcontextModes * mesaVis,
-                  __DRIcontextPrivate * driContextPriv,
+                  __DRIcontext * driContextPriv,
                   void *sharedContextPrivate)
 {
    struct dd_function_table functions;
@@ -143,6 +143,9 @@ i915CreateContext(const __GLcontextModes * mesaVis,
    ctx->Const.MaxTextureImageUnits = I915_TEX_UNITS;
    ctx->Const.MaxTextureCoordUnits = I915_TEX_UNITS;
    ctx->Const.MaxVarying = I915_TEX_UNITS;
+   ctx->Const.MaxCombinedTextureImageUnits =
+      ctx->Const.MaxVertexTextureImageUnits +
+      ctx->Const.MaxTextureImageUnits;
 
    /* Advertise the full hardware capabilities.  The new memory
     * manager should cope much better with overload situations:
index 082d614442535a26ba8c0cbf334d589aa86ef5d9..f55b55113983768b6316ea524f5b2fdafad98a2e 100644 (file)
@@ -39,6 +39,7 @@
 #define I915_FALLBACK_LOGICOP           0x20000
 #define I915_FALLBACK_POLYGON_SMOOTH    0x40000
 #define I915_FALLBACK_POINT_SMOOTH      0x80000
+#define I915_FALLBACK_POINT_SPRITE_COORD_ORIGIN         0x100000
 
 #define I915_UPLOAD_CTX              0x1
 #define I915_UPLOAD_BUFFERS          0x2
@@ -317,7 +318,7 @@ do {                                                                        \
  * i915_context.c
  */
 extern GLboolean i915CreateContext(const __GLcontextModes * mesaVis,
-                                   __DRIcontextPrivate * driContextPriv,
+                                   __DRIcontext * driContextPriv,
                                    void *sharedContextPrivate);
 
 
index f7bb7ea44c9338ae4933d4551efb7d894142e8b3..fecfac30339cde498a5186173ab091dfb4ea9cfc 100644 (file)
@@ -806,6 +806,7 @@ static GLboolean i915_debug_packet( struct debug_stream *stream )
       default:
         return debug(stream, "", 0);
       }
+      break;
    default:
       assert(0);
       return 0;
index d9c61446f52d8e8bcbafceafe5019a60c0111011..a273bd28ea1fe8d8e97a7898de0d3fda3c63b839 100644 (file)
@@ -663,7 +663,7 @@ upload_program(struct i915_fragment_program *p)
                         A0_MOV,
                         get_result_vector(p, inst),
                         get_result_flags(inst), 0,
-                        swizzle(src0, ZERO, ZERO, ZERO, ZERO), 0, 0);
+                        swizzle(tmp, ZERO, ZERO, ZERO, ZERO), 0, 0);
 
       case OPCODE_POW:
          src0 = src_vector(p, &inst->SrcReg[0], program);
@@ -1301,7 +1301,7 @@ i915ValidateFragmentProgram(struct i915_context *i915)
 
    for (i = 0; i < p->ctx->Const.MaxTextureCoordUnits; i++) {
       if (inputsRead & FRAG_BIT_TEX(i)) {
-         int sz = VB->TexCoordPtr[i]->size;
+         int sz = VB->AttribPtr[_TNL_ATTRIB_TEX0 + i]->size;
 
          s2 &= ~S2_TEXCOORD_FMT(i, S2_TEXCOORD_FMT0_MASK);
          s2 |= S2_TEXCOORD_FMT(i, SZ_TO_HW(sz));
index e7908bd48fc3e33e30ac74ccf9b569e2292699cf..3902c6909709004ae7c477ae86466647f5326269 100644 (file)
@@ -245,7 +245,7 @@ GLuint i915_emit_texld( struct i915_fragment_program *p,
    }
    else {
       assert(GET_UREG_TYPE(dest) != REG_TYPE_CONST);
-      assert(dest = UREG(GET_UREG_TYPE(dest), GET_UREG_NR(dest)));
+      assert(dest == UREG(GET_UREG_TYPE(dest), GET_UREG_NR(dest)));
       /* Can't use unsaved temps for coords, as the phase boundary would result
        * in the contents becoming undefined.
        */
index b5fa7fddb9636f186ce715e57b45db6f4c181219..7f31ff674f24c478357b38ba807e1de1027d3a79 100644 (file)
 #define    MT_32BIT_AWVU2101010                   (0xA<<3)
 #define    MT_32BIT_GR1616                (0xB<<3)
 #define    MT_32BIT_VU1616                (0xC<<3)
-#define    MT_32BIT_xI824                 (0xD<<3)
-#define    MT_32BIT_xA824                 (0xE<<3)
-#define    MT_32BIT_xL824                 (0xF<<3)
+#define    MT_32BIT_x8I24                 (0xD<<3)
+#define    MT_32BIT_x8L24                 (0xE<<3)
+#define    MT_32BIT_x8A24                 (0xF<<3)
 #define    MT_422_YCRCB_SWAPY             (0<<3)       /* SURFACE_422 */
 #define    MT_422_YCRCB_NORMAL            (1<<3)
 #define    MT_422_YCRCB_SWAPUV            (2<<3)
index b60efea75bdc32c3b749c23fbdae2e7b7a848611..9d7a9e1dfeaa72822d19f727a6db401019b8a393 100644 (file)
@@ -571,7 +571,7 @@ i915LineWidth(GLcontext * ctx, GLfloat widthf)
    DBG("%s\n", __FUNCTION__);
    
    width = (int) (widthf * 2);
-   CLAMP_SELF(width, 1, 0xf);
+   width = CLAMP(width, 1, 0xf);
    lis4 |= width << S4_LINE_WIDTH_SHIFT;
 
    if (lis4 != i915->state.Ctx[I915_CTXREG_LIS4]) {
@@ -585,11 +585,11 @@ i915PointSize(GLcontext * ctx, GLfloat size)
 {
    struct i915_context *i915 = I915_CONTEXT(ctx);
    int lis4 = i915->state.Ctx[I915_CTXREG_LIS4] & ~S4_POINT_WIDTH_MASK;
-   GLint point_size = (int) size;
+   GLint point_size = (int) round(size);
 
    DBG("%s\n", __FUNCTION__);
    
-   CLAMP_SELF(point_size, 1, 255);
+   point_size = CLAMP(point_size, 1, 255);
    lis4 |= point_size << S4_POINT_WIDTH_SHIFT;
 
    if (lis4 != i915->state.Ctx[I915_CTXREG_LIS4]) {
@@ -599,6 +599,24 @@ i915PointSize(GLcontext * ctx, GLfloat size)
 }
 
 
+static void
+i915PointParameterfv(GLcontext * ctx, GLenum pname, const GLfloat *params)
+{
+   struct i915_context *i915 = I915_CONTEXT(ctx);
+
+   switch (pname) {
+   case GL_POINT_SPRITE_COORD_ORIGIN:
+      /* This could be supported, but it would require modifying the fragment
+       * program to invert the y component of the texture coordinate by
+       * inserting a 'SUB tc.y, {1.0}.xxxx, tc' instruction.
+       */
+      FALLBACK(&i915->intel, I915_FALLBACK_POINT_SPRITE_COORD_ORIGIN,
+              (params[0] != GL_UPPER_LEFT));
+      break;
+   }
+}
+
+
 /* =============================================================
  * Color masks
  */
@@ -939,6 +957,17 @@ i915Enable(GLcontext * ctx, GLenum cap, GLboolean state)
    case GL_POLYGON_SMOOTH:
       break;
 
+   case GL_POINT_SPRITE:
+      /* This state change is handled in i915_reduced_primitive_state because
+       * the hardware bit should only be set when rendering points.
+       */
+      I915_STATECHANGE(i915, I915_UPLOAD_CTX);
+      if (state)
+        i915->state.Ctx[I915_CTXREG_LIS4] |= S4_SPRITE_POINT_ENABLE;
+      else
+        i915->state.Ctx[I915_CTXREG_LIS4] &= ~S4_SPRITE_POINT_ENABLE;
+      break;
+
    case GL_POINT_SMOOTH:
       break;
 
@@ -1108,6 +1137,7 @@ i915InitStateFunctions(struct dd_function_table *functions)
    functions->LineWidth = i915LineWidth;
    functions->LogicOpcode = i915LogicOp;
    functions->PointSize = i915PointSize;
+   functions->PointParameterfv = i915PointParameterfv;
    functions->PolygonStipple = i915PolygonStipple;
    functions->Scissor = i915Scissor;
    functions->ShadeModel = i915ShadeModel;
index 32d4b30cf9a610ea02bb1e7f96790ab60c30f399..3ee4c8653a980c9c0299dd294511c2344d2c8af1 100644 (file)
@@ -27,7 +27,8 @@
 
 #include "main/mtypes.h"
 #include "main/enums.h"
-#include "main/texformat.h"
+#include "main/macros.h"
+#include "main/colormac.h"
 
 #include "intel_mipmap_tree.h"
 #include "intel_tex.h"
@@ -37,7 +38,7 @@
 
 
 static GLuint
-translate_texture_format(GLuint mesa_format, GLuint internal_format,
+translate_texture_format(gl_format mesa_format, GLuint internal_format,
                         GLenum DepthMode)
 {
    switch (mesa_format) {
@@ -56,10 +57,9 @@ translate_texture_format(GLuint mesa_format, GLuint internal_format,
    case MESA_FORMAT_ARGB4444:
       return MAPSURF_16BIT | MT_16BIT_ARGB4444;
    case MESA_FORMAT_ARGB8888:
-      if (internal_format == GL_RGB)
-        return MAPSURF_32BIT | MT_32BIT_XRGB8888;
-      else
-        return MAPSURF_32BIT | MT_32BIT_ARGB8888;
+      return MAPSURF_32BIT | MT_32BIT_ARGB8888;
+   case MESA_FORMAT_XRGB8888:
+      return MAPSURF_32BIT | MT_32BIT_XRGB8888;
    case MESA_FORMAT_YCBCR_REV:
       return (MAPSURF_422 | MT_422_YCRCB_NORMAL);
    case MESA_FORMAT_YCBCR:
@@ -82,7 +82,12 @@ translate_texture_format(GLuint mesa_format, GLuint internal_format,
    case MESA_FORMAT_RGBA_DXT5:
       return (MAPSURF_COMPRESSED | MT_COMPRESS_DXT4_5);
    case MESA_FORMAT_S8_Z24:
-      return (MAPSURF_32BIT | MT_32BIT_xI824);
+      if (DepthMode == GL_ALPHA)
+        return (MAPSURF_32BIT | MT_32BIT_x8A24);
+      else if (DepthMode == GL_INTENSITY)
+        return (MAPSURF_32BIT | MT_32BIT_x8I24);
+      else
+        return (MAPSURF_32BIT | MT_32BIT_x8L24);
    default:
       fprintf(stderr, "%s: bad image format %x\n", __FUNCTION__, mesa_format);
       abort();
@@ -134,6 +139,7 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
    GLuint *state = i915->state.Tex[unit], format, pitch;
    GLint lodbias, aniso = 0;
    GLubyte border[4];
+   GLfloat maxlod;
 
    memset(state, 0, sizeof(state));
 
@@ -173,11 +179,9 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
    } else {
       dri_bo_reference(intelObj->mt->region->buffer);
       i915->state.tex_buffer[unit] = intelObj->mt->region->buffer;
-      i915->state.tex_offset[unit] =  intel_miptree_image_offset(intelObj->mt,
-                                                                0, intelObj->
-                                                                firstLevel);
+      i915->state.tex_offset[unit] = 0; /* Always the origin of the miptree */
 
-      format = translate_texture_format(firstImage->TexFormat->MesaFormat, 
+      format = translate_texture_format(firstImage->TexFormat,
                                        firstImage->InternalFormat,
                                        tObj->DepthMode);
       pitch = intelObj->mt->pitch * intelObj->mt->cpp;
@@ -193,11 +197,16 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
         state[I915_TEXREG_MS3] |= MS3_TILE_WALK;
    }
 
+   /* We get one field with fraction bits for the maximum addressable
+    * (lowest resolution) LOD.  Use it to cover both MAX_LEVEL and
+    * MAX_LOD.
+    */
+   maxlod = MIN2(tObj->MaxLod, tObj->_MaxLevel - tObj->BaseLevel);
    state[I915_TEXREG_MS4] =
-     ((((pitch / 4) - 1) << MS4_PITCH_SHIFT) | MS4_CUBE_FACE_ENA_MASK |
-       ((((intelObj->lastLevel - intelObj->firstLevel) * 4)) <<
-       MS4_MAX_LOD_SHIFT) | ((firstImage->Depth - 1) <<
-                             MS4_VOLUME_DEPTH_SHIFT));
+      ((((pitch / 4) - 1) << MS4_PITCH_SHIFT) |
+       MS4_CUBE_FACE_ENA_MASK |
+       (U_FIXED(CLAMP(maxlod, 0.0, 11.0), 2) << MS4_MAX_LOD_SHIFT) |
+       ((firstImage->Depth - 1) << MS4_VOLUME_DEPTH_SHIFT));
 
 
    {
@@ -263,8 +272,8 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
 
       /* YUV conversion:
        */
-      if (firstImage->TexFormat->MesaFormat == MESA_FORMAT_YCBCR ||
-          firstImage->TexFormat->MesaFormat == MESA_FORMAT_YCBCR_REV)
+      if (firstImage->TexFormat == MESA_FORMAT_YCBCR ||
+          firstImage->TexFormat == MESA_FORMAT_YCBCR_REV)
          state[I915_TEXREG_SS2] |= SS2_COLORSPACE_CONVERSION;
 
       /* Shadow:
@@ -293,6 +302,12 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
       GLenum wt = tObj->WrapT;
       GLenum wr = tObj->WrapR;
 
+      /* We program 1D textures as 2D textures, so the 2D texcoord could
+       * result in sampling border values if we don't set the T wrap to
+       * repeat.
+       */
+      if (tObj->Target == GL_TEXTURE_1D)
+        wt = GL_REPEAT;
 
       /* 3D textures don't seem to respect the border color.
        * Fallback if there's ever a danger that they might refer to
@@ -327,28 +342,31 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
           (translate_wrap_mode(wr) << SS3_TCZ_ADDR_MODE_SHIFT));
 
       state[I915_TEXREG_SS3] |= (unit << SS3_TEXTUREMAP_INDEX_SHIFT);
+      state[I915_TEXREG_SS3] |= (U_FIXED(CLAMP(tObj->MinLod, 0.0, 11.0), 4) <<
+                                SS3_MIN_LOD_SHIFT);
+
    }
 
    /* convert border color from float to ubyte */
-   CLAMPED_FLOAT_TO_UBYTE(border[0], tObj->BorderColor[0]);
-   CLAMPED_FLOAT_TO_UBYTE(border[1], tObj->BorderColor[1]);
-   CLAMPED_FLOAT_TO_UBYTE(border[2], tObj->BorderColor[2]);
-   CLAMPED_FLOAT_TO_UBYTE(border[3], tObj->BorderColor[3]);
+   CLAMPED_FLOAT_TO_UBYTE(border[0], tObj->BorderColor.f[0]);
+   CLAMPED_FLOAT_TO_UBYTE(border[1], tObj->BorderColor.f[1]);
+   CLAMPED_FLOAT_TO_UBYTE(border[2], tObj->BorderColor.f[2]);
+   CLAMPED_FLOAT_TO_UBYTE(border[3], tObj->BorderColor.f[3]);
 
    if (firstImage->_BaseFormat == GL_DEPTH_COMPONENT) {
       /* GL specs that border color for depth textures is taken from the
        * R channel, while the hardware uses A.  Spam R into all the channels
        * for safety.
        */
-      state[I915_TEXREG_SS4] = INTEL_PACKCOLOR8888(border[0],
-                                                  border[0],
-                                                  border[0],
-                                                  border[0]);
+      state[I915_TEXREG_SS4] = PACK_COLOR_8888(border[0],
+                                              border[0],
+                                              border[0],
+                                              border[0]);
    } else {
-      state[I915_TEXREG_SS4] = INTEL_PACKCOLOR8888(border[0],
-                                                  border[1],
-                                                  border[2],
-                                                  border[3]);
+      state[I915_TEXREG_SS4] = PACK_COLOR_8888(border[3],
+                                              border[0],
+                                              border[1],
+                                              border[2]);
    }
 
 
index 9e2523932f153c7b34cb7483c2742b7e76346ed2..266e6848c3c845b33292ffa1103dd8bfeb581fc8 100644 (file)
@@ -32,7 +32,6 @@
 #include "main/imports.h"
 #include "main/macros.h"
 #include "main/colormac.h"
-#include "main/texformat.h"
 
 #include "tnl/t_context.h"
 #include "tnl/t_vertex.h"
@@ -175,7 +174,7 @@ i915_emit_invarient_state(struct intel_context *intel)
 {
    BATCH_LOCALS;
 
-   BEGIN_BATCH(17, IGNORE_CLIPRECTS);
+   BEGIN_BATCH(17);
 
    OUT_BATCH(_3DSTATE_AA_CMD |
              AA_LINE_ECAAR_WIDTH_ENABLE |
@@ -221,7 +220,7 @@ i915_emit_invarient_state(struct intel_context *intel)
 
 
 #define emit(intel, state, size )                   \
-   intel_batchbuffer_data(intel->batch, state, size, IGNORE_CLIPRECTS )
+   intel_batchbuffer_data(intel->batch, state, size)
 
 static GLuint
 get_dirty(struct i915_hw_state *state)
@@ -302,13 +301,9 @@ i915_emit_state(struct intel_context *intel)
     * It might be better to talk about explicit places where
     * scheduling is allowed, rather than assume that it is whenever a
     * batchbuffer fills up.
-    *
-    * Set the space as LOOP_CLIPRECTS now, since that's what our primitives
-    * will be emitted under.
     */
    intel_batchbuffer_require_space(intel->batch,
-                                  get_state_size(state) + INTEL_PRIM_EMIT_SIZE,
-                                  LOOP_CLIPRECTS);
+                                  get_state_size(state) + INTEL_PRIM_EMIT_SIZE);
    count = 0;
  again:
    aper_count = 0;
@@ -374,7 +369,7 @@ i915_emit_state(struct intel_context *intel)
    }
 
    if (dirty & I915_UPLOAD_BUFFERS) {
-      GLuint count = 9;
+      GLuint count = 15;
 
       if (INTEL_DEBUG & DEBUG_STATE)
          fprintf(stderr, "I915_UPLOAD_BUFFERS:\n");
@@ -382,10 +377,7 @@ i915_emit_state(struct intel_context *intel)
       if (state->depth_region)
           count += 3;
 
-      if (intel->constant_cliprect)
-          count += 6;
-
-      BEGIN_BATCH(count, IGNORE_CLIPRECTS);
+      BEGIN_BATCH(count);
       OUT_BATCH(state->Buffer[I915_DESTREG_CBUFADDR0]);
       OUT_BATCH(state->Buffer[I915_DESTREG_CBUFADDR1]);
       OUT_RELOC(state->draw_region->buffer,
@@ -407,15 +399,13 @@ i915_emit_state(struct intel_context *intel)
       OUT_BATCH(state->Buffer[I915_DESTREG_SR1]);
       OUT_BATCH(state->Buffer[I915_DESTREG_SR2]);
 
-      if (intel->constant_cliprect) {
-        assert(state->Buffer[I915_DESTREG_DRAWRECT0] != MI_NOOP);
-        OUT_BATCH(state->Buffer[I915_DESTREG_DRAWRECT0]);
-        OUT_BATCH(state->Buffer[I915_DESTREG_DRAWRECT1]);
-        OUT_BATCH(state->Buffer[I915_DESTREG_DRAWRECT2]);
-        OUT_BATCH(state->Buffer[I915_DESTREG_DRAWRECT3]);
-        OUT_BATCH(state->Buffer[I915_DESTREG_DRAWRECT4]);
-        OUT_BATCH(state->Buffer[I915_DESTREG_DRAWRECT5]);
-      }
+      assert(state->Buffer[I915_DESTREG_DRAWRECT0] != MI_NOOP);
+      OUT_BATCH(state->Buffer[I915_DESTREG_DRAWRECT0]);
+      OUT_BATCH(state->Buffer[I915_DESTREG_DRAWRECT1]);
+      OUT_BATCH(state->Buffer[I915_DESTREG_DRAWRECT2]);
+      OUT_BATCH(state->Buffer[I915_DESTREG_DRAWRECT3]);
+      OUT_BATCH(state->Buffer[I915_DESTREG_DRAWRECT4]);
+      OUT_BATCH(state->Buffer[I915_DESTREG_DRAWRECT5]);
 
       ADVANCE_BATCH();
    }
@@ -442,7 +432,7 @@ i915_emit_state(struct intel_context *intel)
          if (dirty & I915_UPLOAD_TEX(i))
             nr++;
 
-      BEGIN_BATCH(2 + nr * 3, IGNORE_CLIPRECTS);
+      BEGIN_BATCH(2 + nr * 3);
       OUT_BATCH(_3DSTATE_MAP_STATE | (3 * nr));
       OUT_BATCH((dirty & I915_UPLOAD_TEX_ALL) >> I915_UPLOAD_TEX_0_SHIFT);
       for (i = 0; i < I915_TEX_UNITS; i++)
@@ -466,7 +456,7 @@ i915_emit_state(struct intel_context *intel)
          }
       ADVANCE_BATCH();
 
-      BEGIN_BATCH(2 + nr * 3, IGNORE_CLIPRECTS);
+      BEGIN_BATCH(2 + nr * 3);
       OUT_BATCH(_3DSTATE_SAMPLER_STATE | (3 * nr));
       OUT_BATCH((dirty & I915_UPLOAD_TEX_ALL) >> I915_UPLOAD_TEX_0_SHIFT);
       for (i = 0; i < I915_TEX_UNITS; i++)
@@ -588,8 +578,9 @@ i915_state_draw_region(struct intel_context *intel,
             DSTORG_VERT_BIAS(0x8) |     /* .5 */
             LOD_PRECLAMP_OGL | TEX_DEFAULT_COLOR_OGL);
    if (irb != NULL) {
-      switch (irb->texformat->MesaFormat) {
+      switch (irb->Base.Format) {
       case MESA_FORMAT_ARGB8888:
+      case MESA_FORMAT_XRGB8888:
         value |= DV_PF_8888;
         break;
       case MESA_FORMAT_RGB565:
@@ -603,7 +594,7 @@ i915_state_draw_region(struct intel_context *intel,
         break;
       default:
         _mesa_problem(ctx, "Bad renderbuffer format: %d\n",
-                      irb->texformat->MesaFormat);
+                      irb->Base.Format);
       }
    }
 
@@ -611,7 +602,7 @@ i915_state_draw_region(struct intel_context *intel,
     * 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 &&
+   if (intel->is_945 && intel->use_early_z &&
        depth_region->tiling != I915_TILING_NONE)
       value |= CLASSIC_EARLY_DEPTH;
 
@@ -623,23 +614,14 @@ i915_state_draw_region(struct intel_context *intel,
    }
    state->Buffer[I915_DESTREG_DV1] = value;
 
-   if (intel->constant_cliprect) {
-      state->Buffer[I915_DESTREG_DRAWRECT0] = _3DSTATE_DRAWRECT_INFO;
-      state->Buffer[I915_DESTREG_DRAWRECT1] = 0;
-      state->Buffer[I915_DESTREG_DRAWRECT2] = 0; /* xmin, ymin */
-      state->Buffer[I915_DESTREG_DRAWRECT3] =
-        (ctx->DrawBuffer->Width & 0xffff) |
-        (ctx->DrawBuffer->Height << 16);
-      state->Buffer[I915_DESTREG_DRAWRECT4] = 0; /* xoff, yoff */
-      state->Buffer[I915_DESTREG_DRAWRECT5] = 0;
-   } else {
-      state->Buffer[I915_DESTREG_DRAWRECT0] = MI_NOOP;
-      state->Buffer[I915_DESTREG_DRAWRECT1] = MI_NOOP;
-      state->Buffer[I915_DESTREG_DRAWRECT2] = MI_NOOP;
-      state->Buffer[I915_DESTREG_DRAWRECT3] = MI_NOOP;
-      state->Buffer[I915_DESTREG_DRAWRECT4] = MI_NOOP;
-      state->Buffer[I915_DESTREG_DRAWRECT5] = MI_NOOP;
-   }
+   state->Buffer[I915_DESTREG_DRAWRECT0] = _3DSTATE_DRAWRECT_INFO;
+   state->Buffer[I915_DESTREG_DRAWRECT1] = 0;
+   state->Buffer[I915_DESTREG_DRAWRECT2] = 0; /* xmin, ymin */
+   state->Buffer[I915_DESTREG_DRAWRECT3] =
+      (ctx->DrawBuffer->Width & 0xffff) |
+      (ctx->DrawBuffer->Height << 16);
+   state->Buffer[I915_DESTREG_DRAWRECT4] = 0; /* xoff, yoff */
+   state->Buffer[I915_DESTREG_DRAWRECT5] = 0;
 
    I915_STATECHANGE(i915, I915_UPLOAD_BUFFERS);
 }
@@ -667,15 +649,6 @@ i915_new_batch(struct intel_context *intel)
     * difficulties associated with them (physical address requirements).
     */
    i915->state.emitted = 0;
-
-   /* Check that we didn't just wrap our batchbuffer at a bad time. */
-   assert(!intel->no_batch_wrap);
-}
-
-static GLuint
-i915_flush_cmd(void)
-{
-   return MI_FLUSH | FLUSH_MAP_CACHE;
 }
 
 static void 
@@ -699,7 +672,6 @@ i915InitVtbl(struct i915_context *i915)
    i915->intel.vtbl.render_prevalidate = i915_render_prevalidate;
    i915->intel.vtbl.set_draw_region = i915_set_draw_region;
    i915->intel.vtbl.update_texture_state = i915UpdateTextureState;
-   i915->intel.vtbl.flush_cmd = i915_flush_cmd;
    i915->intel.vtbl.assert_not_dirty = i915_assert_not_dirty;
    i915->intel.vtbl.finish_batch = intel_finish_vb;
 }
index 410052b3c2be73c0b4c1244c369eb5eba5262554..ec209391ab4be6064640555e4abf62befb20834b 100644 (file)
@@ -117,7 +117,7 @@ intelDmaPrimitive(struct intel_context *intel, GLenum prim)
    intel_set_prim(intel, hw_prim[prim]);
 }
 
-static inline GLuint intel_get_vb_max(struct intel_context *intel)
+static INLINE GLuint intel_get_vb_max(struct intel_context *intel)
 {
    GLuint ret;
 
@@ -129,7 +129,7 @@ static inline GLuint intel_get_vb_max(struct intel_context *intel)
    return ret;
 }
 
-static inline GLuint intel_get_current_max(struct intel_context *intel)
+static INLINE GLuint intel_get_current_max(struct intel_context *intel)
 {
 
    if (intel->intelScreen->no_vbo)
diff --git a/src/mesa/drivers/dri/i915/intel_swapbuffers.c b/src/mesa/drivers/dri/i915/intel_swapbuffers.c
deleted file mode 120000 (symlink)
index 148d521..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../intel/intel_swapbuffers.c
\ No newline at end of file
index 0641e6df9d772d56127beec1d1d19ea291b975ca..e99baf8e0e6e5151a6e5a5246871658d9e043941 100644 (file)
@@ -89,7 +89,6 @@ intel_flush_inline_primitive(struct intel_context *intel)
 
 static void intel_start_inline(struct intel_context *intel, uint32_t prim)
 {
-   uint32_t batch_flags = LOOP_CLIPRECTS;
    BATCH_LOCALS;
 
    intel->vtbl.emit_state(intel);
@@ -101,7 +100,7 @@ static void intel_start_inline(struct intel_context *intel, uint32_t prim)
    /* Emit a slot which will be filled with the inline primitive
     * command later.
     */
-   BEGIN_BATCH(2, batch_flags);
+   BEGIN_BATCH(2);
    OUT_BATCH(0);
 
    assert((intel->batch->dirty_state & (1<<1)) == 0);
@@ -221,7 +220,7 @@ void intel_flush_prim(struct intel_context *intel)
    intel->prim.count = 0;
    offset = intel->prim.start_offset;
    intel->prim.start_offset = intel->prim.current_offset;
-   if (!IS_9XX(intel->intelScreen->deviceID))
+   if (!intel->gen >= 3)
       intel->prim.start_offset = ALIGN(intel->prim.start_offset, 128);
    intel->prim.flush = NULL;
 
@@ -251,8 +250,8 @@ void intel_flush_prim(struct intel_context *intel)
          intel->vertex_size * 4);
 #endif
 
-   if (IS_9XX(intel->intelScreen->deviceID)) {
-      BEGIN_BATCH(5, LOOP_CLIPRECTS);
+   if (intel->gen >= 3) {
+      BEGIN_BATCH(5);
       OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 |
                I1_LOAD_S(0) | I1_LOAD_S(1) | 1);
       assert((offset & !S0_VB_OFFSET_MASK) == 0);
@@ -270,7 +269,7 @@ void intel_flush_prim(struct intel_context *intel)
    } else {
       struct i830_context *i830 = i830_context(&intel->ctx);
 
-      BEGIN_BATCH(5, LOOP_CLIPRECTS);
+      BEGIN_BATCH(5);
       OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 |
                I1_LOAD_S(0) | I1_LOAD_S(2) | 1);
       /* S0 */
@@ -1088,6 +1087,7 @@ intelRenderStart(GLcontext * ctx)
 {
    struct intel_context *intel = intel_context(ctx);
 
+   intel_check_front_buffer_rendering(intel);
    intel->vtbl.render_start(intel_context(ctx));
    intel->vtbl.emit_state(intel);
 }
@@ -1196,12 +1196,16 @@ getFallbackString(GLuint bit)
 
 
 
+/**
+ * Enable/disable a fallback flag.
+ * \param bit  one of INTEL_FALLBACK_x flags.
+ */
 void
-intelFallback(struct intel_context *intel, GLuint bit, GLboolean mode)
+intelFallback(struct intel_context *intel, GLbitfield bit, GLboolean mode)
 {
    GLcontext *ctx = &intel->ctx;
    TNLcontext *tnl = TNL_CONTEXT(ctx);
-   GLuint oldfallback = intel->Fallback;
+   const GLbitfield oldfallback = intel->Fallback;
 
    if (mode) {
       intel->Fallback |= bit;
@@ -1245,81 +1249,6 @@ union fi
    GLint i;
 };
 
-
-/**********************************************************************/
-/*             Used only with the metaops callbacks.                  */
-/**********************************************************************/
-static void
-intel_meta_draw_poly(struct intel_context *intel,
-                     GLuint n,
-                     GLfloat xy[][2],
-                     GLfloat z, GLuint color, GLfloat tex[][2])
-{
-   union fi *vb;
-   GLint i;
-   unsigned int saved_vertex_size = intel->vertex_size;
-
-   LOCK_HARDWARE(intel);
-
-   intel->vertex_size = 6;
-
-   /* All 3d primitives should be emitted with LOOP_CLIPRECTS,
-    * otherwise the drawing origin (DR4) might not be set correctly.
-    */
-   intel_set_prim(intel, PRIM3D_TRIFAN);
-   vb = (union fi *) intel_get_prim_space(intel, n);
-
-   for (i = 0; i < n; i++) {
-      vb[0].f = xy[i][0];
-      vb[1].f = xy[i][1];
-      vb[2].f = z;
-      vb[3].i = color;
-      vb[4].f = tex[i][0];
-      vb[5].f = tex[i][1];
-      vb += 6;
-   }
-
-   INTEL_FIREVERTICES(intel);
-
-   intel->vertex_size = saved_vertex_size;
-
-   UNLOCK_HARDWARE(intel);
-}
-
-static void
-intel_meta_draw_quad(struct intel_context *intel,
-                     GLfloat x0, GLfloat x1,
-                     GLfloat y0, GLfloat y1,
-                     GLfloat z,
-                     GLuint color,
-                     GLfloat s0, GLfloat s1, GLfloat t0, GLfloat t1)
-{
-   GLfloat xy[4][2];
-   GLfloat tex[4][2];
-
-   xy[0][0] = x0;
-   xy[0][1] = y0;
-   xy[1][0] = x1;
-   xy[1][1] = y0;
-   xy[2][0] = x1;
-   xy[2][1] = y1;
-   xy[3][0] = x0;
-   xy[3][1] = y1;
-
-   tex[0][0] = s0;
-   tex[0][1] = t0;
-   tex[1][0] = s1;
-   tex[1][1] = t0;
-   tex[2][0] = s1;
-   tex[2][1] = t1;
-   tex[3][0] = s0;
-   tex[3][1] = t1;
-
-   intel_meta_draw_poly(intel, 4, xy, z, color, tex);
-}
-
-
-
 /**********************************************************************/
 /*                            Initialization.                         */
 /**********************************************************************/
@@ -1328,7 +1257,6 @@ intel_meta_draw_quad(struct intel_context *intel,
 void
 intelInitTriFuncs(GLcontext * ctx)
 {
-   struct intel_context *intel = intel_context(ctx);
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    static int firsttime = 1;
 
@@ -1345,6 +1273,4 @@ intelInitTriFuncs(GLcontext * ctx)
    tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
    tnl->Driver.Render.CopyPV = _tnl_copy_pv;
    tnl->Driver.Render.Interp = _tnl_interp;
-
-   intel->vtbl.meta_draw_quad = intel_meta_draw_quad;
 }
index 57dcc9158695466985d475e7ace98d7b928caea4..7758a792fde9f6c9ca0cfa51042fac090165c0a7 100644 (file)
@@ -24,7 +24,6 @@ DRIVER_SOURCES = \
        intel_pixel_draw.c \
        intel_pixel_read.c \
        intel_state.c \
-       intel_swapbuffers.c \
        intel_syncobj.c \
        intel_tex.c \
        intel_tex_copy.c \
@@ -96,10 +95,10 @@ ASM_SOURCES =
 
 DRIVER_DEFINES = -I../intel -I../intel/server
 
-DRI_LIB_DEPS += -ldrm_intel
+INCLUDES += $(INTEL_CFLAGS)
+DRI_LIB_DEPS += $(INTEL_LIBS)
 
 include ../Makefile.template
 
-symlinks:
 intel_decode.o: ../intel/intel_decode.c
 intel_tex_layout.o: ../intel/intel_tex_layout.c
index 1088a7a6070592ef6489d83f4385a7d7d295dff6..bac1c3a49c3314fc680f0040a71bae1f390012a1 100644 (file)
@@ -34,6 +34,7 @@
 #include "brw_state.h"
 #include "brw_defines.h"
 #include "brw_util.h"
+#include "intel_fbo.h"
 #include "main/macros.h"
 #include "main/enums.h"
 
@@ -44,17 +45,24 @@ static void prepare_cc_vp( struct brw_context *brw )
 
    memset(&ccv, 0, sizeof(ccv));
 
-   /* _NEW_VIEWPORT */
-   ccv.min_depth = ctx->Viewport.Near;
-   ccv.max_depth = ctx->Viewport.Far;
+   /* _NEW_TRANSOFORM */
+   if (ctx->Transform.DepthClamp) {
+      /* _NEW_VIEWPORT */
+      ccv.min_depth = MIN2(ctx->Viewport.Near, ctx->Viewport.Far);
+      ccv.max_depth = MAX2(ctx->Viewport.Near, ctx->Viewport.Far);
+   } else {
+      ccv.min_depth = 0.0;
+      ccv.max_depth = 1.0;
+   }
 
    dri_bo_unreference(brw->cc.vp_bo);
-   brw->cc.vp_bo = brw_cache_data( &brw->cache, BRW_CC_VP, &ccv, NULL, 0 );
+   brw->cc.vp_bo = brw_cache_data(&brw->cache, BRW_CC_VP, &ccv, sizeof(ccv),
+                                 NULL, 0);
 }
 
 const struct brw_tracked_state brw_cc_vp = {
    .dirty = {
-      .mesa = _NEW_VIEWPORT,
+      .mesa = _NEW_VIEWPORT | _NEW_TRANSFORM,
       .brw = BRW_NEW_CONTEXT,
       .cache = 0
    },
@@ -82,6 +90,28 @@ struct brw_cc_unit_key {
    GLenum depth_func;
 };
 
+/**
+ * Modify blend function to force destination alpha to 1.0
+ *
+ * If \c function specifies a blend function that uses destination alpha,
+ * replace it with a function that hard-wires destination alpha to 1.0.  This
+ * is used when rendering to xRGB targets.
+ */
+static GLenum
+fix_xRGB_alpha(GLenum function)
+{
+   switch (function) {
+   case GL_DST_ALPHA:
+      return GL_ONE;
+
+   case GL_ONE_MINUS_DST_ALPHA:
+   case GL_SRC_ALPHA_SATURATE:
+      return GL_ZERO;
+   }
+
+   return function;
+}
+
 static void
 cc_unit_populate_key(struct brw_context *brw, struct brw_cc_unit_key *key)
 {
@@ -125,6 +155,17 @@ cc_unit_populate_key(struct brw_context *brw, struct brw_cc_unit_key *key)
       key->blend_dst_rgb = ctx->Color.BlendDstRGB;
       key->blend_src_a = ctx->Color.BlendSrcA;
       key->blend_dst_a = ctx->Color.BlendDstA;
+
+      /* If the renderbuffer is XRGB, we have to frob the blend function to
+       * force the destination alpha to 1.0.  This means replacing GL_DST_ALPHA
+       * with GL_ONE and GL_ONE_MINUS_DST_ALPHA with GL_ZERO.
+       */
+      if (ctx->DrawBuffer->Visual.alphaBits == 0) {
+        key->blend_src_rgb = fix_xRGB_alpha(key->blend_src_rgb);
+        key->blend_src_a   = fix_xRGB_alpha(key->blend_src_a);
+        key->blend_dst_rgb = fix_xRGB_alpha(key->blend_dst_rgb);
+        key->blend_dst_a   = fix_xRGB_alpha(key->blend_dst_a);
+      }
    }
 
    key->alpha_enabled = ctx->Color.AlphaEnabled;
index 20a927cf386a2f43417e1ca39430492ef5fee53f..af1d975de95cdf477d3c82f896216a6c719fae86 100644 (file)
@@ -50,6 +50,7 @@
 static void compile_clip_prog( struct brw_context *brw,
                             struct brw_clip_prog_key *key )
 {
+   struct intel_context *intel = &brw->intel;
    struct brw_clip_compile c;
    const GLuint *program;
    GLuint program_size;
@@ -65,27 +66,26 @@ static void compile_clip_prog( struct brw_context *brw,
    c.func.single_program_flow = 1;
 
    c.key = *key;
-   c.need_ff_sync = BRW_IS_IGDNG(brw);
 
    /* Need to locate the two positions present in vertex + header.
     * These are currently hardcoded:
     */
    c.header_position_offset = ATTR_SIZE;
 
-   if (BRW_IS_IGDNG(brw))
+   if (intel->is_ironlake)
        delta = 3 * REG_SIZE;
    else
        delta = REG_SIZE;
 
    for (i = 0; i < VERT_RESULT_MAX; i++)
-      if (c.key.attrs & (1<<i)) {
+      if (c.key.attrs & BITFIELD64_BIT(i)) {
         c.offset[i] = delta;
         delta += ATTR_SIZE;
       }
 
    c.nr_attrs = brw_count_bits(c.key.attrs);
    
-   if (BRW_IS_IGDNG(brw))
+   if (intel->is_ironlake)
        c.nr_regs = (c.nr_attrs + 1) / 2 + 3;  /* are vertices packed, or reg-aligned? */
    else
        c.nr_regs = (c.nr_attrs + 1) / 2 + 1;  /* are vertices packed, or reg-aligned? */
@@ -143,7 +143,8 @@ static void compile_clip_prog( struct brw_context *brw,
  */
 static void upload_clip_prog(struct brw_context *brw)
 {
-   GLcontext *ctx = &brw->intel.ctx;
+   struct intel_context *intel = &brw->intel;
+   GLcontext *ctx = &intel->ctx;
    struct brw_clip_prog_key key;
 
    memset(&key, 0, sizeof(key));
@@ -156,10 +157,11 @@ static void upload_clip_prog(struct brw_context *brw)
    key.attrs = brw->vs.prog_data->outputs_written;
    /* _NEW_LIGHT */
    key.do_flat_shading = (ctx->Light.ShadeModel == GL_FLAT);
+   key.pv_first = (ctx->Light.ProvokingVertex == GL_FIRST_VERTEX_CONVENTION);
    /* _NEW_TRANSFORM */
    key.nr_userclip = brw_count_bits(ctx->Transform.ClipPlanesEnabled);
 
-   if (BRW_IS_IGDNG(brw))
+   if (intel->is_ironlake)
        key.clip_mode = BRW_CLIPMODE_KERNEL_CLIP;
    else
        key.clip_mode = BRW_CLIPMODE_NORMAL;
index 957df441ab03e94ad92a8983928dd03028cb86bd..d71bac7f617512fceb6bdc37a55aea96ae55f9e9 100644 (file)
  * up polygon offset and flatshading at this point:
  */
 struct brw_clip_prog_key {
-   GLuint attrs:32;            
+   GLbitfield64 attrs;
    GLuint primitive:4;
    GLuint nr_userclip:3;
    GLuint do_flat_shading:1;
+   GLuint pv_first:1;
    GLuint do_unfilled:1;
    GLuint fill_cw:2;           /* includes cull information */
    GLuint fill_ccw:2;          /* includes cull information */
    GLuint offset_cw:1;
    GLuint offset_ccw:1;
-   GLuint pad0:17;
-
    GLuint copy_bfc_cw:1;
    GLuint copy_bfc_ccw:1;
    GLuint clip_mode:3;
-   GLuint pad1:27;
-   
+   GLuint pad0:11;
+
    GLfloat offset_factor;
    GLfloat offset_units;
 };
@@ -119,7 +118,6 @@ struct brw_clip_compile {
 
    GLuint header_position_offset;
    GLuint offset[VERT_ATTRIB_MAX];
-   GLboolean need_ff_sync;
 };
 
 #define ATTR_SIZE  (4*4)
index 048ca620fabea13d9f65eff63763c1ca236b7cb2..afc0b11049406575fc09944c85d939171ab886db 100644 (file)
@@ -46,6 +46,7 @@
 
 static void brw_clip_line_alloc_regs( struct brw_clip_compile *c )
 {
+   struct intel_context *intel = &c->func.brw->intel;
    GLuint i = 0,j;
 
    /* Register usage is static, precompute here:
@@ -85,7 +86,7 @@ static void brw_clip_line_alloc_regs( struct brw_clip_compile *c )
       i++;
    }
 
-   if (c->need_ff_sync) {
+   if (intel->needs_ff_sync) {
       c->reg.ff_sync = retype(brw_vec1_grf(i, 0), BRW_REGISTER_TYPE_UD);
       i++;
    }
@@ -126,6 +127,7 @@ static void brw_clip_line_alloc_regs( struct brw_clip_compile *c )
 static void clip_and_emit_line( struct brw_clip_compile *c )
 {
    struct brw_compile *p = &c->func;
+   struct brw_context *brw = p->brw;
    struct brw_indirect vtx0     = brw_indirect(0, 0);
    struct brw_indirect vtx1      = brw_indirect(1, 0);
    struct brw_indirect newvtx0   = brw_indirect(2, 0);
@@ -152,7 +154,7 @@ static void clip_and_emit_line( struct brw_clip_compile *c )
    brw_clip_init_clipmask(c);
 
    /* -ve rhw workaround */
-   if (BRW_IS_965(p->brw)) {
+   if (brw->has_negative_rhw_bug) {
       brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
       brw_AND(p, brw_null_reg(), get_element_ud(c->reg.R0, 2),
               brw_imm_ud(1<<20));
@@ -189,7 +191,7 @@ static void clip_and_emit_line( struct brw_clip_compile *c )
               * Both can be negative on GM965/G965 due to RHW workaround
               * if so, this object should be rejected.
               */
-             if (BRW_IS_965(p->brw)) {
+             if (brw->has_negative_rhw_bug) {
                  brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_LE, c->reg.dp0, brw_imm_f(0.0));
                  is_neg2 = brw_IF(p, BRW_EXECUTE_1);
                  {
@@ -214,7 +216,7 @@ static void clip_and_emit_line( struct brw_clip_compile *c )
 
              /* If both are positive, do nothing */
              /* Only on GM965/G965 */
-             if (BRW_IS_965(p->brw)) {
+             if (brw->has_negative_rhw_bug) {
                  brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_L, c->reg.dp0, brw_imm_f(0.0));
                  is_neg2 = brw_IF(p, BRW_EXECUTE_1);
              }
@@ -229,7 +231,7 @@ static void clip_and_emit_line( struct brw_clip_compile *c )
                  brw_set_predicate_control(p, BRW_PREDICATE_NONE);
              }
 
-             if (BRW_IS_965(p->brw)) {
+             if (brw->has_negative_rhw_bug) {
                  brw_ENDIF(p, is_neg2);
              }
          }
@@ -269,8 +271,12 @@ void brw_emit_line_clip( struct brw_clip_compile *c )
    brw_clip_line_alloc_regs(c);
    brw_clip_init_ff_sync(c);
 
-   if (c->key.do_flat_shading)
-      brw_clip_copy_colors(c, 0, 1);
+   if (c->key.do_flat_shading) {
+      if (c->key.pv_first)
+         brw_clip_copy_colors(c, 1, 0);
+      else
+         brw_clip_copy_colors(c, 0, 1);
+   }
                 
    clip_and_emit_line(c);
 }
index 234b3744bfc6717e986b8c41d2db72ec1992b8f3..c8f24a94e4d5feb574ccfd0fbb6ec7f48ef97557 100644 (file)
@@ -74,6 +74,7 @@ static dri_bo *
 clip_unit_create_from_key(struct brw_context *brw,
                          struct brw_clip_unit_key *key)
 {
+   struct intel_context *intel = &brw->intel;
    struct brw_clip_unit_state clip;
    dri_bo *bo;
 
@@ -105,7 +106,7 @@ clip_unit_create_from_key(struct brw_context *brw,
       /* Although up to 16 concurrent Clip threads are allowed on IGDNG, 
        * only 2 threads can output VUEs at a time.
        */
-      if (BRW_IS_IGDNG(brw))
+      if (intel->is_ironlake)
          clip.thread4.max_threads = 16 - 1;        
       else
          clip.thread4.max_threads = 2 - 1;
@@ -130,7 +131,7 @@ clip_unit_create_from_key(struct brw_context *brw,
    clip.clip5.api_mode = BRW_CLIP_API_OGL;
    clip.clip5.clip_mode = key->clip_mode;
 
-   if (BRW_IS_G4X(brw))
+   if (intel->is_g4x)
       clip.clip5.negative_w_clip_test = 1;
 
    clip.clip6.clipper_viewport_state_ptr = 0;
index 0efd77225e2343093e6b2f4e9373a15f1f0cc057..cfbb8f2686aee6421471c5f2d23b439ba14df8cb 100644 (file)
@@ -51,6 +51,7 @@ static void release_tmps( struct brw_clip_compile *c )
 void brw_clip_tri_alloc_regs( struct brw_clip_compile *c, 
                              GLuint nr_verts )
 {
+   struct intel_context *intel = &c->func.brw->intel;
    GLuint i = 0,j;
 
    /* Register usage is static, precompute here:
@@ -78,7 +79,7 @@ void brw_clip_tri_alloc_regs( struct brw_clip_compile *c,
       for (j = 0; j < 3; j++) {
         GLuint delta = c->nr_attrs*16 + 32;
 
-         if (BRW_IS_IGDNG(c->func.brw))
+         if (intel->is_ironlake)
              delta = c->nr_attrs * 16 + 32 * 3;
 
         brw_MOV(&c->func, byte_offset(c->reg.vertex[j], delta), brw_imm_f(0));
@@ -119,7 +120,7 @@ void brw_clip_tri_alloc_regs( struct brw_clip_compile *c,
       i++;
    }
 
-   if (c->need_ff_sync) {
+   if (intel->needs_ff_sync) {
       c->reg.ff_sync = retype(brw_vec1_grf(i, 0), BRW_REGISTER_TYPE_UD);
       i++;
    }
@@ -188,14 +189,20 @@ void brw_clip_tri_flat_shade( struct brw_clip_compile *c )
           brw_imm_ud(_3DPRIM_POLYGON));
 
    is_poly = brw_IF(p, BRW_EXECUTE_1);
-   {   
+   {
       brw_clip_copy_colors(c, 1, 0);
       brw_clip_copy_colors(c, 2, 0);
    }
    is_poly = brw_ELSE(p, is_poly);
    {
-      brw_clip_copy_colors(c, 0, 2);
-      brw_clip_copy_colors(c, 1, 2);
+      if (c->key.pv_first) {
+         brw_clip_copy_colors(c, 1, 0);
+         brw_clip_copy_colors(c, 2, 0);
+      }
+      else {
+         brw_clip_copy_colors(c, 0, 2);
+         brw_clip_copy_colors(c, 1, 2);
+      }
    }
    brw_ENDIF(p, is_poly);
 }
@@ -565,6 +572,7 @@ void brw_emit_tri_clip( struct brw_clip_compile *c )
 {
    struct brw_instruction *neg_rhw;
    struct brw_compile *p = &c->func;
+   struct brw_context *brw = p->brw;
    brw_clip_tri_alloc_regs(c, 3 + c->key.nr_userclip + 6);
    brw_clip_tri_init_vertices(c);
    brw_clip_init_clipmask(c);
@@ -572,7 +580,7 @@ void brw_emit_tri_clip( struct brw_clip_compile *c )
 
    /* if -ve rhw workaround bit is set, 
       do cliptest */
-   if (BRW_IS_965(p->brw)) {
+   if (brw->has_negative_rhw_bug) {
       brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
       brw_AND(p, brw_null_reg(), get_element_ud(c->reg.R0, 2), 
               brw_imm_ud(1<<20));
index 5a73abdfee9d994eaed52b2d5d2d0ef34e1efb29..86fed59fa4b89dfbc90b7747a3407d72d7a38b95 100644 (file)
@@ -135,6 +135,7 @@ void brw_clip_interp_vertex( struct brw_clip_compile *c,
                             GLboolean force_edgeflag)
 {
    struct brw_compile *p = &c->func;
+   struct intel_context *intel = &p->brw->intel;
    struct brw_reg tmp = get_tmp(c);
    GLuint i;
 
@@ -142,7 +143,7 @@ void brw_clip_interp_vertex( struct brw_clip_compile *c,
     */
    /*
     * After CLIP stage, only first 256 bits of the VUE are read
-    * back on IGDNG, so needn't change it
+    * back on Ironlake, so needn't change it
     */
    brw_copy_indirect_to_indirect(p, dest_ptr, v0_ptr, 1);
       
@@ -151,7 +152,7 @@ void brw_clip_interp_vertex( struct brw_clip_compile *c,
    for (i = 0; i < c->nr_attrs; i++) {
       GLuint delta = i*16 + 32;
 
-      if (BRW_IS_IGDNG(p->brw))
+      if (intel->is_ironlake)
           delta = i * 16 + 32 * 3;
 
       if (delta == c->offset[VERT_RESULT_EDGE]) {
@@ -185,7 +186,7 @@ void brw_clip_interp_vertex( struct brw_clip_compile *c,
    if (i & 1) {
       GLuint delta = i*16 + 32;
 
-      if (BRW_IS_IGDNG(p->brw))
+      if (intel->is_ironlake)
           delta = i * 16 + 32 * 3;
 
       brw_MOV(p, deref_4f(dest_ptr, delta), brw_imm_f(0));
@@ -359,7 +360,9 @@ void brw_clip_init_clipmask( struct brw_clip_compile *c )
 
 void brw_clip_ff_sync(struct brw_clip_compile *c)
 {
-    if (c->need_ff_sync) {
+    struct intel_context *intel = &c->func.brw->intel;
+
+    if (intel->needs_ff_sync) {
         struct brw_compile *p = &c->func;
         struct brw_instruction *need_ff_sync;
 
@@ -388,7 +391,9 @@ void brw_clip_ff_sync(struct brw_clip_compile *c)
 
 void brw_clip_init_ff_sync(struct brw_clip_compile *c)
 {
-    if (c->need_ff_sync) {
+    struct intel_context *intel = &c->func.brw->intel;
+
+    if (intel->needs_ff_sync) {
        struct brw_compile *p = &c->func;
         
         brw_MOV(p, c->reg.ff_sync, brw_imm_ud(0));
index c300c33adce838f906ac2523c7854b2659a87cf8..7bb15956b5615aac21a77cd547c01989d2722d62 100644 (file)
@@ -77,7 +77,7 @@ static void brwInitDriverFunctions( struct dd_function_table *functions )
 }
 
 GLboolean brwCreateContext( const __GLcontextModes *mesaVis,
-                           __DRIcontextPrivate *driContextPriv,
+                           __DRIcontext *driContextPriv,
                            void *sharedContextPrivate)
 {
    struct dd_function_table functions;
@@ -105,11 +105,15 @@ GLboolean brwCreateContext( const __GLcontextModes *mesaVis,
 
    TNL_CONTEXT(ctx)->Driver.RunPipeline = _tnl_run_pipeline;
 
+   ctx->Const.MaxDrawBuffers = BRW_MAX_DRAW_BUFFERS;
    ctx->Const.MaxTextureImageUnits = BRW_MAX_TEX_UNIT;
    ctx->Const.MaxTextureCoordUnits = 8; /* Mesa limit */
    ctx->Const.MaxTextureUnits = MIN2(ctx->Const.MaxTextureCoordUnits,
                                      ctx->Const.MaxTextureImageUnits);
    ctx->Const.MaxVertexTextureImageUnits = 0; /* no vertex shader textures */
+   ctx->Const.MaxCombinedTextureImageUnits =
+      ctx->Const.MaxVertexTextureImageUnits +
+      ctx->Const.MaxTextureImageUnits;
 
    /* Mesa limits textures to 4kx4k; it would be nice to fix that someday
     */
@@ -154,6 +158,38 @@ GLboolean brwCreateContext( const __GLcontextModes *mesaVis,
       MIN2(ctx->Const.FragmentProgram.MaxNativeParameters,
           ctx->Const.FragmentProgram.MaxEnvParams);
 
+   if (intel->is_ironlake || intel->is_g4x) {
+      brw->CMD_VF_STATISTICS = CMD_VF_STATISTICS_GM45;
+      brw->CMD_PIPELINE_SELECT = CMD_PIPELINE_SELECT_GM45;
+      brw->has_surface_tile_offset = GL_TRUE;
+      brw->has_compr4 = GL_TRUE;
+      brw->has_aa_line_parameters = GL_TRUE;
+  } else {
+      brw->CMD_VF_STATISTICS = CMD_VF_STATISTICS_965;
+      brw->CMD_PIPELINE_SELECT = CMD_PIPELINE_SELECT_965;
+   }
+
+   /* WM maximum threads is number of EUs times number of threads per EU. */
+   if (intel->is_ironlake) {
+      brw->urb.size = 1024;
+      brw->vs_max_threads = 72;
+      brw->wm_max_threads = 12 * 6;
+   } else if (intel->is_g4x) {
+      brw->urb.size = 384;
+      brw->vs_max_threads = 32;
+      brw->wm_max_threads = 10 * 5;
+   } else {
+      brw->urb.size = 256;
+      brw->vs_max_threads = 16;
+      brw->wm_max_threads = 8 * 4;
+      brw->has_negative_rhw_bug = GL_TRUE;
+   }
+
+   if (INTEL_DEBUG & DEBUG_SINGLE_THREAD) {
+      brw->vs_max_threads = 1;
+      brw->wm_max_threads = 1;
+   }
+
    brw_init_state( brw );
 
    brw->state.dirty.mesa = ~0;
index fa3e32c7ff190c50e3cc1693aec1118d51d80010..0dd3087143f7a813c93b9c8f03c3e2a2a93e99aa 100644 (file)
  * Handles blending and (presumably) depth and stencil testing.
  */
 
-#define BRW_FALLBACK_TEXTURE            0x1
+
 #define BRW_MAX_CURBE                    (32*16)
 
 struct brw_context;
@@ -172,8 +172,8 @@ struct brw_fragment_program {
    GLuint id;  /**< serial no. to identify frag progs, never re-used */
    GLboolean isGLSL;  /**< really, any IF/LOOP/CONT/BREAK instructions */
 
-   dri_bo *const_buffer;    /** Program constant buffer/surface */
    GLboolean use_const_buffer;
+   dri_bo *const_buffer;    /** Program constant buffer/surface */
 
    /** for debugging, which texture units are referenced */
    GLbitfield tex_units_used;
@@ -231,7 +231,7 @@ struct brw_vs_prog_data {
    GLuint curb_read_length;
    GLuint urb_read_length;
    GLuint total_grf;
-   GLuint outputs_written;
+   GLbitfield64 outputs_written;
    GLuint nr_params;       /**< number of float params/constants */
 
    GLuint inputs_read;
@@ -252,20 +252,23 @@ struct brw_vs_ouput_sizes {
 /** Number of texture sampler units */
 #define BRW_MAX_TEX_UNIT 16
 
+/** Max number of render targets in a shader */
+#define BRW_MAX_DRAW_BUFFERS 4
+
 /**
  * Size of our surface binding table for the WM.
  * This contains pointers to the drawing surfaces and current texture
  * objects and shader constant buffers (+2).
  */
-#define BRW_WM_MAX_SURF (MAX_DRAW_BUFFERS + BRW_MAX_TEX_UNIT + 1)
+#define BRW_WM_MAX_SURF (BRW_MAX_DRAW_BUFFERS + BRW_MAX_TEX_UNIT + 1)
 
 /**
  * Helpers to convert drawing buffers, textures and constant buffers
  * to surface binding table indexes, for WM.
  */
 #define SURF_INDEX_DRAW(d)           (d)
-#define SURF_INDEX_FRAG_CONST_BUFFER (MAX_DRAW_BUFFERS) 
-#define SURF_INDEX_TEXTURE(t)        (MAX_DRAW_BUFFERS + 1 + (t))
+#define SURF_INDEX_FRAG_CONST_BUFFER (BRW_MAX_DRAW_BUFFERS) 
+#define SURF_INDEX_TEXTURE(t)        (BRW_MAX_DRAW_BUFFERS + 1 + (t))
 
 /**
  * Size of surface binding table for the VS.
@@ -317,7 +320,6 @@ struct brw_cache_item {
    GLuint nr_reloc_bufs;
 
    dri_bo *bo;
-   GLuint data_size;
 
    struct brw_cache_item *next;
 };   
@@ -330,7 +332,6 @@ struct brw_cache {
    struct brw_cache_item **items;
    GLuint size, n_items;
 
-   GLuint key_size[BRW_MAX_CACHE];             /* for fixed-size keys */
    GLuint aux_size[BRW_MAX_CACHE];
    char *name[BRW_MAX_CACHE];
 
@@ -410,23 +411,6 @@ struct brw_vertex_info {
    GLuint sizes[ATTRIB_BIT_DWORDS * 2]; /* sizes:2[VERT_ATTRIB_MAX] */
 };
 
-
-
-
-/* Cache for TNL programs.
- */
-struct brw_tnl_cache_item {
-   GLuint hash;
-   void *key;
-   void *data;
-   struct brw_tnl_cache_item *next;
-};
-
-struct brw_tnl_cache {
-   struct brw_tnl_cache_item **items;
-   GLuint size, n_items;
-};
-
 struct brw_query_object {
    struct gl_query_object Base;
 
@@ -454,9 +438,11 @@ struct brw_context
    GLuint primitive;
 
    GLboolean emit_state_always;
-   GLboolean tmp_fallback;
-   GLboolean no_batch_wrap;
-
+   GLboolean has_surface_tile_offset;
+   GLboolean has_compr4;
+   GLboolean has_negative_rhw_bug;
+   GLboolean has_aa_line_parameters;
+;
    struct {
       struct brw_state_flags dirty;
 
@@ -532,6 +518,12 @@ struct brw_context
     */
    GLuint next_free_page;
 
+   /* hw-dependent 3DSTATE_VF_STATISTICS opcode */
+   uint32_t CMD_VF_STATISTICS;
+   /* hw-dependent 3DSTATE_PIPELINE_SELECT opcode */
+   uint32_t CMD_PIPELINE_SELECT;
+   int vs_max_threads;
+   int wm_max_threads;
 
    /* BRW_NEW_URB_ALLOCATIONS:
     */
@@ -559,6 +551,7 @@ struct brw_context
       GLuint clip_start;
       GLuint sf_start;
       GLuint cs_start;
+      GLuint size; /* Hardware URB size, in KB. */
    } urb;
 
    
@@ -686,7 +679,7 @@ void brwInitVtbl( struct brw_context *brw );
  * brw_context.c
  */
 GLboolean brwCreateContext( const __GLcontextModes *mesaVis,
-                           __DRIcontextPrivate *driContextPriv,
+                           __DRIcontext *driContextPriv,
                            void *sharedContextPrivate);
 
 /*======================================================================
@@ -759,9 +752,5 @@ brw_fragment_program_const(const struct gl_fragment_program *p)
    return (const struct brw_fragment_program *) p;
 }
 
-
-
-#define DO_SETUP_BITS ((1<<(FRAG_ATTRIB_MAX)) - 1)
-
 #endif
 
index 4be6c77aa1e359d571c1653a30c693d61c7f2790..190310afbb034f1e3002f44dffa392900785a8c3 100644 (file)
@@ -130,7 +130,7 @@ static void calculate_curbe_offsets( struct brw_context *brw )
 const struct brw_tracked_state brw_curbe_offsets = {
    .dirty = {
       .mesa = _NEW_TRANSFORM,
-      .brw  = BRW_NEW_VERTEX_PROGRAM,
+      .brw  = BRW_NEW_VERTEX_PROGRAM | BRW_NEW_CONTEXT,
       .cache = CACHE_NEW_WM_PROG
    },
    .prepare = calculate_curbe_offsets
@@ -340,7 +340,7 @@ static void emit_constant_buffer(struct brw_context *brw)
    struct intel_context *intel = &brw->intel;
    GLuint sz = brw->curbe.total_size;
 
-   BEGIN_BATCH(2, IGNORE_CLIPRECTS);
+   BEGIN_BATCH(2);
    if (sz == 0) {
       OUT_BATCH((CMD_CONST_BUFFER << 16) | (2 - 2));
       OUT_BATCH(0);
index 78d457ad2bebcefbdec7d26e836c3e8192ee5b65..ea0d7e05d4184254b66087962c98fed05bb5f18b 100644 (file)
 #define BRW_SAMPLER_MESSAGE_SIMD8_LD                  3
 #define BRW_SAMPLER_MESSAGE_SIMD16_LD                 3
 
-#define BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_IGDNG            0
-#define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_IGDNG          0
-#define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_IGDNG           0
-#define BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_BIAS_IGDNG       1
-#define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_BIAS_IGDNG     1
-#define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_BIAS_IGDNG      1
-#define BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_LOD_IGDNG        2
-#define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_LOD_IGDNG      2
-#define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_LOD_IGDNG       2
-#define BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_COMPARE_IGDNG    3
-#define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_COMPARE_IGDNG  3
-#define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_COMPARE_IGDNG   3
+#define BRW_SAMPLER_MESSAGE_SAMPLE_IGDNG            0
+#define BRW_SAMPLER_MESSAGE_SAMPLE_BIAS_IGDNG       1
+#define BRW_SAMPLER_MESSAGE_SAMPLE_LOD_IGDNG        2
+#define BRW_SAMPLER_MESSAGE_SAMPLE_COMPARE_IGDNG    3
 
 /* for IGDNG only */
 #define BRW_SAMPLER_SIMD_MODE_SIMD4X2                   0
 
 #include "intel_chipset.h"
 
-#define BRW_IS_G4X(brw)         (IS_G4X((brw)->intel.intelScreen->deviceID))
-#define BRW_IS_IGDNG(brw)         (IS_IGDNG((brw)->intel.intelScreen->deviceID))
-#define BRW_IS_965(brw)         (!(BRW_IS_G4X(brw) || BRW_IS_IGDNG(brw)))
-#define CMD_PIPELINE_SELECT(brw)        ((BRW_IS_G4X(brw) || BRW_IS_IGDNG(brw)) ? CMD_PIPELINE_SELECT_GM45 : CMD_PIPELINE_SELECT_965)
-#define CMD_VF_STATISTICS(brw)          ((BRW_IS_G4X(brw) || BRW_IS_IGDNG(brw)) ? CMD_VF_STATISTICS_GM45 : CMD_VF_STATISTICS_965)
-#define URB_SIZES(brw)                  (BRW_IS_IGDNG(brw) ? 1024 : \
-                                         (BRW_IS_G4X(brw) ? 384 : 256))  /* 512 bit units */
-
 #endif
index 9fef230507fa5970c4513616e595a948fb8af411..a8f6b993ac3d07a92b49f725036aca5ad1ee7c75 100644 (file)
@@ -239,7 +239,7 @@ char *imm_encoding[8] = {
     [2] = "UW",
     [3] = "W",
     [5] = "VF",
-    [5] = "V",
+    [6] = "V",
     [7] = "F"
 };
 
@@ -365,6 +365,7 @@ static int format (FILE *f, char *format, ...)
     va_start (args, format);
 
     vsnprintf (buf, sizeof (buf) - 1, format, args);
+    va_end (args);
     string (f, buf);
     return 0;
 }
index 44bb7bd5882f4f8b405c550a6bdc6e11d1d6d824..df281b27d5c11df8450bc18ccd64d5a61ae4ea69 100644 (file)
@@ -145,7 +145,7 @@ static void brw_emit_prim(struct brw_context *brw,
    prim_packet.base_vert_location = prim->basevertex;
 
    /* Can't wrap here, since we rely on the validated state. */
-   brw->no_batch_wrap = GL_TRUE;
+   intel->no_batch_wrap = GL_TRUE;
 
    /* If we're set to always flush, do it before and after the primitive emit.
     * We want to catch both missed flushes that hurt instruction/state cache
@@ -153,21 +153,17 @@ static void brw_emit_prim(struct brw_context *brw,
     * the besides the draw code.
     */
    if (intel->always_flush_cache) {
-      BEGIN_BATCH(1, IGNORE_CLIPRECTS);
-      OUT_BATCH(intel->vtbl.flush_cmd());
-      ADVANCE_BATCH();
+      intel_batchbuffer_emit_mi_flush(intel->batch);
    }
    if (prim_packet.verts_per_instance) {
       intel_batchbuffer_data( brw->intel.batch, &prim_packet,
-                             sizeof(prim_packet), LOOP_CLIPRECTS);
+                             sizeof(prim_packet));
    }
    if (intel->always_flush_cache) {
-      BEGIN_BATCH(1, IGNORE_CLIPRECTS);
-      OUT_BATCH(intel->vtbl.flush_cmd());
-      ADVANCE_BATCH();
+      intel_batchbuffer_emit_mi_flush(intel->batch);
    }
 
-   brw->no_batch_wrap = GL_FALSE;
+   intel->no_batch_wrap = GL_FALSE;
 }
 
 static void brw_merge_inputs( struct brw_context *brw,
@@ -343,13 +339,6 @@ static GLboolean brw_try_draw_prims( GLcontext *ctx,
     * so can't access it earlier.
     */
 
-   LOCK_HARDWARE(intel);
-
-   if (!intel->constant_cliprect && intel->driDrawable->numClipRects == 0) {
-      UNLOCK_HARDWARE(intel);
-      return GL_TRUE;
-   }
-
    for (i = 0; i < nr_prims; i++) {
       uint32_t hw_prim;
 
@@ -360,8 +349,7 @@ static GLboolean brw_try_draw_prims( GLcontext *ctx,
        * an upper bound of how much we might emit in a single
        * brw_try_draw_prims().
        */
-      intel_batchbuffer_require_space(intel->batch, intel->batch->size / 4,
-                                     LOOP_CLIPRECTS);
+      intel_batchbuffer_require_space(intel->batch, intel->batch->size / 4);
 
       hw_prim = brw_set_prim(brw, prim[i].mode);
 
@@ -408,7 +396,6 @@ static GLboolean brw_try_draw_prims( GLcontext *ctx,
    if (intel->always_flush_batch)
       intel_batchbuffer_flush(intel->batch);
  out:
-   UNLOCK_HARDWARE(intel);
 
    brw_state_cache_check_size(brw);
 
index 765ae5a2fe54837ae807e56c783876aacbc75c80..c773b71507cb9909746fe2b891ebd13e411ad46c 100644 (file)
@@ -243,14 +243,6 @@ static void wrap_buffers( struct brw_context *brw,
       dri_bo_unreference(brw->vb.upload.bo);
    brw->vb.upload.bo = dri_bo_alloc(brw->intel.bufmgr, "temporary VBO",
                                    size, 1);
-
-   /* Set the internal VBO\ to no-backing-store.  We only use them as a
-    * temporary within a brw_try_draw_prims while the lock is held.
-    */
-   /* DON'T DO THIS AS IF WE HAVE TO RE-ORG MEMORY WE NEED SOMEWHERE WITH
-      FAKE TO PUSH THIS STUFF */
-//   if (!brw->intel.ttm)
-//      dri_bo_fake_disable_backing_store(brw->vb.upload.bo, NULL, NULL);
 }
 
 static void get_space( struct brw_context *brw,
@@ -375,7 +367,7 @@ static void brw_prepare_vertices(struct brw_context *brw)
     * isn't an issue at this point.
     */
    if (brw->vb.nr_enabled >= BRW_VEP_MAX) {
-      intel->Fallback = 1;
+      intel->Fallback = GL_TRUE; /* boolean, not bitfield */
       return;
    }
 
@@ -427,7 +419,7 @@ static void brw_prepare_vertices(struct brw_context *brw)
            /* Position array not properly enabled:
             */
             if (input->glarray->StrideB == 0) {
-               intel->Fallback = 1;
+               intel->Fallback = GL_TRUE; /* boolean, not bitfield */
                return;
             }
 
@@ -502,7 +494,7 @@ static void brw_emit_vertices(struct brw_context *brw)
     * a VE loads from them.
     */
    if (brw->vb.nr_enabled == 0) {
-      BEGIN_BATCH(3, IGNORE_CLIPRECTS);
+      BEGIN_BATCH(3);
       OUT_BATCH((CMD_VERTEX_ELEMENT << 16) | 1);
       OUT_BATCH((0 << BRW_VE0_INDEX_SHIFT) |
                BRW_VE0_VALID |
@@ -522,7 +514,7 @@ static void brw_emit_vertices(struct brw_context *brw)
     * are interleaved or from the same VBO.  TBD if this makes a
     * performance difference.
     */
-   BEGIN_BATCH(1 + brw->vb.nr_enabled * 4, IGNORE_CLIPRECTS);
+   BEGIN_BATCH(1 + brw->vb.nr_enabled * 4);
    OUT_BATCH((CMD_VERTEX_BUFFER << 16) |
             ((1 + brw->vb.nr_enabled * 4) - 2));
 
@@ -535,24 +527,17 @@ static void brw_emit_vertices(struct brw_context *brw)
       OUT_RELOC(input->bo,
                I915_GEM_DOMAIN_VERTEX, 0,
                input->offset);
-      if (BRW_IS_IGDNG(brw)) {
-          if (input->stride) {
-              OUT_RELOC(input->bo,
-                        I915_GEM_DOMAIN_VERTEX, 0,
-                        input->offset + input->stride * input->count);
-          } else {
-              assert(input->count == 1);
-              OUT_RELOC(input->bo,
-                        I915_GEM_DOMAIN_VERTEX, 0,
-                        input->offset + input->element_size);
-          }
+      if (intel->is_ironlake) {
+        OUT_RELOC(input->bo,
+                  I915_GEM_DOMAIN_VERTEX, 0,
+                  input->bo->size - 1);
       } else
           OUT_BATCH(input->stride ? input->count : 0);
       OUT_BATCH(0); /* Instance data step rate */
    }
    ADVANCE_BATCH();
 
-   BEGIN_BATCH(1 + brw->vb.nr_enabled * 2, IGNORE_CLIPRECTS);
+   BEGIN_BATCH(1 + brw->vb.nr_enabled * 2);
    OUT_BATCH((CMD_VERTEX_ELEMENT << 16) | ((1 + brw->vb.nr_enabled * 2) - 2));
    for (i = 0; i < brw->vb.nr_enabled; i++) {
       struct brw_vertex_element *input = brw->vb.enabled[i];
@@ -578,7 +563,7 @@ static void brw_emit_vertices(struct brw_context *brw)
                (format << BRW_VE0_FORMAT_SHIFT) |
                (0 << BRW_VE0_SRC_OFFSET_SHIFT));
 
-      if (BRW_IS_IGDNG(brw))
+      if (intel->is_ironlake)
           OUT_BATCH((comp0 << BRW_VE1_COMPONENT_0_SHIFT) |
                     (comp1 << BRW_VE1_COMPONENT_1_SHIFT) |
                     (comp2 << BRW_VE1_COMPONENT_2_SHIFT) |
@@ -719,14 +704,14 @@ static void brw_emit_index_buffer(struct brw_context *brw)
       ib.header.bits.index_format = get_index_type(index_buffer->type);
       ib.header.bits.cut_index_enable = 0;
 
-      BEGIN_BATCH(4, IGNORE_CLIPRECTS);
+      BEGIN_BATCH(4);
       OUT_BATCH( ib.header.dword );
       OUT_RELOC(brw->ib.bo,
                I915_GEM_DOMAIN_VERTEX, 0,
                brw->ib.offset);
       OUT_RELOC(brw->ib.bo,
                I915_GEM_DOMAIN_VERTEX, 0,
-               brw->ib.offset + brw->ib.size);
+               brw->ib.offset + brw->ib.size - 1);
       OUT_BATCH( 0 );
       ADVANCE_BATCH();
    }
index 30603bdd0e66058165d1ff7d21227dc687ac3d11..39eb88d7c2b3baa14a26058589799b1d131d338f 100644 (file)
@@ -170,11 +170,11 @@ static INLINE struct brw_reg brw_reg( GLuint file,
                                       GLuint writemask )
 {
    struct brw_reg reg;
-   if (type == BRW_GENERAL_REGISTER_FILE)
+   if (file == BRW_GENERAL_REGISTER_FILE)
       assert(nr < BRW_MAX_GRF);
-   else if (type == BRW_MESSAGE_REGISTER_FILE)
-      assert(nr < BRW_MAX_MRF);
-   else if (type == BRW_ARCHITECTURE_REGISTER_FILE)
+   else if (file == BRW_MESSAGE_REGISTER_FILE)
+      assert((nr & ~(1 << 7)) < BRW_MAX_MRF);
+   else if (file == BRW_ARCHITECTURE_REGISTER_FILE)
       assert(nr <= BRW_ARF_IP);
 
    reg.type = type;
@@ -538,7 +538,7 @@ static INLINE struct brw_reg brw_mask_reg( GLuint subnr )
 
 static INLINE struct brw_reg brw_message_reg( GLuint nr )
 {
-   assert(nr < BRW_MAX_MRF);
+   assert((nr & ~(1 << 7)) < BRW_MAX_MRF);
    return brw_vec8_reg(BRW_MESSAGE_REGISTER_FILE,
                       nr,
                       0);
index 241cdc33f8606f9735f6b55b612f3d72208311e5..8d6ac0083966c2b48cd180197bb4e28935153067 100644 (file)
@@ -55,7 +55,8 @@ static void guess_execution_size( struct brw_instruction *insn,
 static void brw_set_dest( struct brw_instruction *insn,
                          struct brw_reg dest )
 {
-   if (dest.type != BRW_ARCHITECTURE_REGISTER_FILE)
+   if (dest.file != BRW_ARCHITECTURE_REGISTER_FILE &&
+       dest.file != BRW_MESSAGE_REGISTER_FILE)
       assert(dest.nr < 128);
 
    insn->bits1.da1.dest_reg_file = dest.file;
@@ -198,7 +199,7 @@ void brw_set_src1( struct brw_instruction *insn,
        * in the future:
        */
       assert (reg.address_mode == BRW_ADDRESS_DIRECT);
-      //assert (reg.file == BRW_GENERAL_REGISTER_FILE);
+      /* assert (reg.file == BRW_GENERAL_REGISTER_FILE); */
 
       if (insn->header.access_mode == BRW_ALIGN_1) {
         insn->bits3.da1.src1_subreg_nr = reg.subnr;
@@ -251,9 +252,10 @@ static void brw_set_math_message( struct brw_context *brw,
                                  GLboolean saturate,
                                  GLuint dataType )
 {
+   struct intel_context *intel = &brw->intel;
    brw_set_src1(insn, brw_imm_d(0));
 
-   if (BRW_IS_IGDNG(brw)) {
+   if (intel->is_ironlake) {
        insn->bits3.math_igdng.function = function;
        insn->bits3.math_igdng.int_type = integer_type;
        insn->bits3.math_igdng.precision = low_precision;
@@ -318,9 +320,10 @@ static void brw_set_urb_message( struct brw_context *brw,
                                 GLuint offset,
                                 GLuint swizzle_control )
 {
+    struct intel_context *intel = &brw->intel;
     brw_set_src1(insn, brw_imm_d(0));
 
-    if (BRW_IS_IGDNG(brw)) {
+    if (intel->is_ironlake) {
         insn->bits3.urb_igdng.opcode = 0;      /* ? */
         insn->bits3.urb_igdng.offset = offset;
         insn->bits3.urb_igdng.swizzle_control = swizzle_control;
@@ -357,9 +360,10 @@ static void brw_set_dp_write_message( struct brw_context *brw,
                                      GLuint response_length,
                                      GLuint end_of_thread )
 {
+   struct intel_context *intel = &brw->intel;
    brw_set_src1(insn, brw_imm_d(0));
 
-   if (BRW_IS_IGDNG(brw)) {
+   if (intel->is_ironlake) {
        insn->bits3.dp_write_igdng.binding_table_index = binding_table_index;
        insn->bits3.dp_write_igdng.msg_control = msg_control;
        insn->bits3.dp_write_igdng.pixel_scoreboard_clear = pixel_scoreboard_clear;
@@ -394,9 +398,10 @@ static void brw_set_dp_read_message( struct brw_context *brw,
                                      GLuint response_length,
                                      GLuint end_of_thread )
 {
+   struct intel_context *intel = &brw->intel;
    brw_set_src1(insn, brw_imm_d(0));
 
-   if (BRW_IS_IGDNG(brw)) {
+   if (intel->is_ironlake) {
        insn->bits3.dp_read_igdng.binding_table_index = binding_table_index;
        insn->bits3.dp_read_igdng.msg_control = msg_control;
        insn->bits3.dp_read_igdng.msg_type = msg_type;
@@ -432,10 +437,11 @@ static void brw_set_sampler_message(struct brw_context *brw,
                                     GLuint header_present,
                                     GLuint simd_mode)
 {
+   struct intel_context *intel = &brw->intel;
    assert(eot == 0);
    brw_set_src1(insn, brw_imm_d(0));
 
-   if (BRW_IS_IGDNG(brw)) {
+   if (intel->is_ironlake) {
       insn->bits3.sampler_igdng.binding_table_index = binding_table_index;
       insn->bits3.sampler_igdng.sampler = sampler;
       insn->bits3.sampler_igdng.msg_type = msg_type;
@@ -446,7 +452,7 @@ static void brw_set_sampler_message(struct brw_context *brw,
       insn->bits3.sampler_igdng.end_of_thread = eot;
       insn->bits2.send_igdng.sfid = BRW_MESSAGE_TARGET_SAMPLER;
       insn->bits2.send_igdng.end_of_thread = eot;
-   } else if (BRW_IS_G4X(brw)) {
+   } else if (intel->is_g4x) {
       insn->bits3.sampler_g4x.binding_table_index = binding_table_index;
       insn->bits3.sampler_g4x.sampler = sampler;
       insn->bits3.sampler_g4x.msg_type = msg_type;
@@ -647,10 +653,11 @@ struct brw_instruction *brw_IF(struct brw_compile *p, GLuint execute_size)
 struct brw_instruction *brw_ELSE(struct brw_compile *p, 
                                 struct brw_instruction *if_insn)
 {
+   struct intel_context *intel = &p->brw->intel;
    struct brw_instruction *insn;
    GLuint br = 1;
 
-   if (BRW_IS_IGDNG(p->brw))
+   if (intel->is_ironlake)
       br = 2;
 
    if (p->single_program_flow) {
@@ -689,9 +696,10 @@ struct brw_instruction *brw_ELSE(struct brw_compile *p,
 void brw_ENDIF(struct brw_compile *p, 
               struct brw_instruction *patch_insn)
 {
+   struct intel_context *intel = &p->brw->intel;
    GLuint br = 1;
 
-   if (BRW_IS_IGDNG(p->brw))
+   if (intel->is_ironlake)
       br = 2; 
  
    if (p->single_program_flow) {
@@ -802,10 +810,11 @@ struct brw_instruction *brw_DO(struct brw_compile *p, GLuint execute_size)
 struct brw_instruction *brw_WHILE(struct brw_compile *p, 
                                   struct brw_instruction *do_insn)
 {
+   struct intel_context *intel = &p->brw->intel;
    struct brw_instruction *insn;
    GLuint br = 1;
 
-   if (BRW_IS_IGDNG(p->brw))
+   if (intel->is_ironlake)
       br = 2;
 
    if (p->single_program_flow)
@@ -845,14 +854,15 @@ struct brw_instruction *brw_WHILE(struct brw_compile *p,
 void brw_land_fwd_jump(struct brw_compile *p, 
                       struct brw_instruction *jmp_insn)
 {
+   struct intel_context *intel = &p->brw->intel;
    struct brw_instruction *landing = &p->store[p->nr_insn];
    GLuint jmpi = 1;
 
-   if (BRW_IS_IGDNG(p->brw))
+   if (intel->is_ironlake)
        jmpi = 2;
 
    assert(jmp_insn->header.opcode == BRW_OPCODE_JMPI);
-   assert(jmp_insn->bits1.da1.src1_reg_file = BRW_IMMEDIATE_VALUE);
+   assert(jmp_insn->bits1.da1.src1_reg_file == BRW_IMMEDIATE_VALUE);
 
    jmp_insn->bits3.ud = jmpi * ((landing - jmp_insn) - 1);
 }
index d27c6c24ca50258d647484846fc1f4a6d62891fa..fe5c1ae279100d730ef05eb530e44e9441e42467 100644 (file)
@@ -47,7 +47,6 @@
 
 static GLboolean do_check_fallback(struct brw_context *brw)
 {
-   struct intel_context *intel = &brw->intel;
    GLcontext *ctx = &brw->intel.ctx;
    GLuint i;
 
@@ -86,8 +85,7 @@ static GLboolean do_check_fallback(struct brw_context *brw)
    }
 
    /* _NEW_BUFFERS */
-   if (IS_965(intel->intelScreen->deviceID) &&
-       !IS_G4X(intel->intelScreen->deviceID)) {
+   if (!brw->has_surface_tile_offset) {
       for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {
         struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[i];
         struct intel_renderbuffer *irb = intel_renderbuffer(rb);
@@ -133,7 +131,11 @@ const struct brw_tracked_state brw_check_fallback = {
 
 
 
-/* Not used:
+/**
+ * Called by the INTEL_FALLBACK() macro.
+ * NOTE: this is a no-op for the i965 driver.  The brw->intel.Fallback
+ * field is treated as a boolean, not a bitmask.  It's only set in a
+ * couple of places.
  */
 void intelFallback( struct intel_context *intel, GLuint bit, GLboolean mode )
 {
index 48c2b9a41ce03bb89991232254654a1c089fd49f..1bc3eccf49d9ad05869b5d29f23db42ed3b6fc34 100644 (file)
@@ -47,6 +47,7 @@
 static void compile_gs_prog( struct brw_context *brw,
                             struct brw_gs_prog_key *key )
 {
+   struct intel_context *intel = &brw->intel;
    struct brw_gs_compile c;
    const GLuint *program;
    GLuint program_size;
@@ -54,13 +55,12 @@ static void compile_gs_prog( struct brw_context *brw,
    memset(&c, 0, sizeof(c));
    
    c.key = *key;
-   c.need_ff_sync = BRW_IS_IGDNG(brw);
    /* Need to locate the two positions present in vertex + header.
     * These are currently hardcoded:
     */
    c.nr_attrs = brw_count_bits(c.key.attrs);
 
-   if (BRW_IS_IGDNG(brw))
+   if (intel->is_ironlake)
        c.nr_regs = (c.nr_attrs + 1) / 2 + 3;  /* are vertices packed, or reg-aligned? */
    else
        c.nr_regs = (c.nr_attrs + 1) / 2 + 1;  /* are vertices packed, or reg-aligned? */
@@ -85,10 +85,10 @@ static void compile_gs_prog( struct brw_context *brw,
     */
    switch (key->primitive) {
    case GL_QUADS:
-      brw_gs_quads( &c ); 
+      brw_gs_quads( &c, key );
       break;
    case GL_QUAD_STRIP:
-      brw_gs_quad_strip( &c );
+      brw_gs_quad_strip( &c, key );
       break;
    case GL_LINE_LOOP:
       brw_gs_lines( &c );
@@ -149,6 +149,7 @@ static const GLenum gs_prim[GL_POLYGON+1] = {
 static void populate_key( struct brw_context *brw,
                          struct brw_gs_prog_key *key )
 {
+   GLcontext *ctx = &brw->intel.ctx;
    memset(key, 0, sizeof(*key));
 
    /* CACHE_NEW_VS_PROG */
@@ -158,6 +159,9 @@ static void populate_key( struct brw_context *brw,
    key->primitive = gs_prim[brw->primitive];
 
    key->hint_gs_always = 0;    /* debug code? */
+   
+   /* _NEW_LIGHT */
+   key->pv_first = (ctx->Light.ProvokingVertex == GL_FIRST_VERTEX_CONVENTION);
 
    key->need_gs_prog = (key->hint_gs_always ||
                        brw->primitive == GL_QUADS ||
@@ -193,7 +197,7 @@ static void prepare_gs_prog(struct brw_context *brw)
 
 const struct brw_tracked_state brw_gs_prog = {
    .dirty = {
-      .mesa  = 0,
+      .mesa  = _NEW_LIGHT,
       .brw   = BRW_NEW_PRIMITIVE,
       .cache = CACHE_NEW_VS_PROG
    },
index bbb991ea2e57d67827b5e220f6f722ba862f37bd..813b8d447aebe49fc7878825255a4ee6a9a3631f 100644 (file)
 #define MAX_GS_VERTS (4)            
 
 struct brw_gs_prog_key {
-   GLuint attrs:32;
+   GLbitfield64 attrs;
    GLuint primitive:4;
    GLuint hint_gs_always:1;
+   GLuint pv_first:1;
    GLuint need_gs_prog:1;
-   GLuint pad:26;
+   GLuint pad:25;
 };
 
 struct brw_gs_compile {
@@ -62,13 +63,12 @@ struct brw_gs_compile {
    GLuint nr_attrs;
    GLuint nr_regs;
    GLuint nr_bytes;
-   GLboolean need_ff_sync;
 };
 
 #define ATTR_SIZE  (4*4)
 
-void brw_gs_quads( struct brw_gs_compile *c );
-void brw_gs_quad_strip( struct brw_gs_compile *c );
+void brw_gs_quads( struct brw_gs_compile *c, struct brw_gs_prog_key *key );
+void brw_gs_quad_strip( struct brw_gs_compile *c, struct brw_gs_prog_key *key );
 void brw_gs_tris( struct brw_gs_compile *c );
 void brw_gs_lines( struct brw_gs_compile *c );
 void brw_gs_points( struct brw_gs_compile *c );
index a9b2aa2eacef0d8660104cde36710cd0cee754c2..a81b972ef4b12a574c2cc39b8a45ee161d09ada0 100644 (file)
@@ -120,38 +120,60 @@ static void brw_gs_ff_sync(struct brw_gs_compile *c, int num_prim)
 }
 
 
-void brw_gs_quads( struct brw_gs_compile *c )
+void brw_gs_quads( struct brw_gs_compile *c, struct brw_gs_prog_key *key )
 {
+   struct intel_context *intel = &c->func.brw->intel;
+
    brw_gs_alloc_regs(c, 4);
    
    /* Use polygons for correct edgeflag behaviour. Note that vertex 3
     * is the PV for quads, but vertex 0 for polygons:
     */
-   if (c->need_ff_sync)
-          brw_gs_ff_sync(c, 1);    
-   brw_gs_emit_vue(c, c->reg.vertex[3], 0, ((_3DPRIM_POLYGON << 2) | R02_PRIM_START));
-   brw_gs_emit_vue(c, c->reg.vertex[0], 0, (_3DPRIM_POLYGON << 2));
-   brw_gs_emit_vue(c, c->reg.vertex[1], 0, (_3DPRIM_POLYGON << 2)); 
-   brw_gs_emit_vue(c, c->reg.vertex[2], 1, ((_3DPRIM_POLYGON << 2) | R02_PRIM_END));
+   if (intel->needs_ff_sync)
+          brw_gs_ff_sync(c, 1);
+   if (key->pv_first) {
+      brw_gs_emit_vue(c, c->reg.vertex[0], 0, ((_3DPRIM_POLYGON << 2) | R02_PRIM_START));
+      brw_gs_emit_vue(c, c->reg.vertex[1], 0, (_3DPRIM_POLYGON << 2));
+      brw_gs_emit_vue(c, c->reg.vertex[2], 0, (_3DPRIM_POLYGON << 2));
+      brw_gs_emit_vue(c, c->reg.vertex[3], 1, ((_3DPRIM_POLYGON << 2) | R02_PRIM_END));
+   }
+   else {
+      brw_gs_emit_vue(c, c->reg.vertex[3], 0, ((_3DPRIM_POLYGON << 2) | R02_PRIM_START));
+      brw_gs_emit_vue(c, c->reg.vertex[0], 0, (_3DPRIM_POLYGON << 2));
+      brw_gs_emit_vue(c, c->reg.vertex[1], 0, (_3DPRIM_POLYGON << 2));
+      brw_gs_emit_vue(c, c->reg.vertex[2], 1, ((_3DPRIM_POLYGON << 2) | R02_PRIM_END));
+   }
 }
 
-void brw_gs_quad_strip( struct brw_gs_compile *c )
+void brw_gs_quad_strip( struct brw_gs_compile *c, struct brw_gs_prog_key *key )
 {
+   struct intel_context *intel = &c->func.brw->intel;
+
    brw_gs_alloc_regs(c, 4);
    
-   if (c->need_ff_sync)
+   if (intel->needs_ff_sync)
           brw_gs_ff_sync(c, 1);      
-   brw_gs_emit_vue(c, c->reg.vertex[2], 0, ((_3DPRIM_POLYGON << 2) | R02_PRIM_START));
-   brw_gs_emit_vue(c, c->reg.vertex[3], 0, (_3DPRIM_POLYGON << 2));
-   brw_gs_emit_vue(c, c->reg.vertex[0], 0, (_3DPRIM_POLYGON << 2)); 
-   brw_gs_emit_vue(c, c->reg.vertex[1], 1, ((_3DPRIM_POLYGON << 2) | R02_PRIM_END));
+   if (key->pv_first) {
+      brw_gs_emit_vue(c, c->reg.vertex[0], 0, ((_3DPRIM_POLYGON << 2) | R02_PRIM_START));
+      brw_gs_emit_vue(c, c->reg.vertex[1], 0, (_3DPRIM_POLYGON << 2));
+      brw_gs_emit_vue(c, c->reg.vertex[2], 0, (_3DPRIM_POLYGON << 2));
+      brw_gs_emit_vue(c, c->reg.vertex[3], 1, ((_3DPRIM_POLYGON << 2) | R02_PRIM_END));
+   }
+   else {
+      brw_gs_emit_vue(c, c->reg.vertex[2], 0, ((_3DPRIM_POLYGON << 2) | R02_PRIM_START));
+      brw_gs_emit_vue(c, c->reg.vertex[3], 0, (_3DPRIM_POLYGON << 2));
+      brw_gs_emit_vue(c, c->reg.vertex[0], 0, (_3DPRIM_POLYGON << 2));
+      brw_gs_emit_vue(c, c->reg.vertex[1], 1, ((_3DPRIM_POLYGON << 2) | R02_PRIM_END));
+   }
 }
 
 void brw_gs_tris( struct brw_gs_compile *c )
 {
+   struct intel_context *intel = &c->func.brw->intel;
+
    brw_gs_alloc_regs(c, 3);
 
-   if (c->need_ff_sync)
+   if (intel->needs_ff_sync)
           brw_gs_ff_sync(c, 1);      
    brw_gs_emit_vue(c, c->reg.vertex[0], 0, ((_3DPRIM_TRILIST << 2) | R02_PRIM_START));
    brw_gs_emit_vue(c, c->reg.vertex[1], 0, (_3DPRIM_TRILIST << 2));
@@ -160,9 +182,11 @@ void brw_gs_tris( struct brw_gs_compile *c )
 
 void brw_gs_lines( struct brw_gs_compile *c )
 {
+   struct intel_context *intel = &c->func.brw->intel;
+
    brw_gs_alloc_regs(c, 2);
 
-   if (c->need_ff_sync)
+   if (intel->needs_ff_sync)
           brw_gs_ff_sync(c, 1);      
    brw_gs_emit_vue(c, c->reg.vertex[0], 0, ((_3DPRIM_LINESTRIP << 2) | R02_PRIM_START));
    brw_gs_emit_vue(c, c->reg.vertex[1], 1, ((_3DPRIM_LINESTRIP << 2) | R02_PRIM_END));
@@ -170,9 +194,11 @@ void brw_gs_lines( struct brw_gs_compile *c )
 
 void brw_gs_points( struct brw_gs_compile *c )
 {
+   struct intel_context *intel = &c->func.brw->intel;
+
    brw_gs_alloc_regs(c, 1);
 
-   if (c->need_ff_sync)
+   if (intel->needs_ff_sync)
           brw_gs_ff_sync(c, 1);      
    brw_gs_emit_vue(c, c->reg.vertex[0], 1, ((_3DPRIM_POINTLIST << 2) | R02_PRIM_START | R02_PRIM_END));
 }
index ed9d2ffe605e49ee89f9ee007cd058b0afd9bb9b..1af5790a676445ed17d03dccb937100602de8ccd 100644 (file)
@@ -72,6 +72,7 @@ gs_unit_populate_key(struct brw_context *brw, struct brw_gs_unit_key *key)
 static dri_bo *
 gs_unit_create_from_key(struct brw_context *brw, struct brw_gs_unit_key *key)
 {
+   struct intel_context *intel = &brw->intel;
    struct brw_gs_unit_state gs;
    dri_bo *bo;
 
@@ -98,7 +99,7 @@ gs_unit_create_from_key(struct brw_context *brw, struct brw_gs_unit_key *key)
    else
       gs.thread4.max_threads = 0;
 
-   if (BRW_IS_IGDNG(brw))
+   if (intel->is_ironlake)
       gs.thread4.rendering_enable = 1;
 
    if (INTEL_DEBUG & DEBUG_STATS)
index ea7185754845f1931476d7f5394c648fab933d2b..7b70f787b7b63f0c4bdfeee13f18dbf223f3c183 100644 (file)
@@ -66,7 +66,7 @@ static void upload_blend_constant_color(struct brw_context *brw)
 const struct brw_tracked_state brw_blend_constant_color = {
    .dirty = {
       .mesa = _NEW_COLOR,
-      .brw = 0,
+      .brw = BRW_NEW_CONTEXT,
       .cache = 0
    },
    .emit = upload_blend_constant_color
@@ -78,10 +78,7 @@ static void upload_drawing_rect(struct brw_context *brw)
    struct intel_context *intel = &brw->intel;
    GLcontext *ctx = &intel->ctx;
 
-   if (!intel->constant_cliprect)
-      return;
-
-   BEGIN_BATCH(4, NO_LOOP_CLIPRECTS);
+   BEGIN_BATCH(4);
    OUT_BATCH(_3DSTATE_DRAWRECT_INFO_I965);
    OUT_BATCH(0); /* xmin, ymin */
    OUT_BATCH(((ctx->DrawBuffer->Width - 1) & 0xffff) |
@@ -93,7 +90,7 @@ static void upload_drawing_rect(struct brw_context *brw)
 const struct brw_tracked_state brw_drawing_rect = {
    .dirty = {
       .mesa = _NEW_BUFFERS,
-      .brw = 0,
+      .brw = BRW_NEW_CONTEXT,
       .cache = 0
    },
    .emit = upload_drawing_rect
@@ -116,7 +113,7 @@ static void upload_binding_table_pointers(struct brw_context *brw)
 {
    struct intel_context *intel = &brw->intel;
 
-   BEGIN_BATCH(6, IGNORE_CLIPRECTS);
+   BEGIN_BATCH(6);
    OUT_BATCH(CMD_BINDING_TABLE_PTRS << 16 | (6 - 2));
    if (brw->vs.bind_bo != NULL)
       OUT_RELOC(brw->vs.bind_bo, I915_GEM_DOMAIN_SAMPLER, 0, 0); /* vs */
@@ -150,7 +147,7 @@ static void upload_pipelined_state_pointers(struct brw_context *brw )
 {
    struct intel_context *intel = &brw->intel;
 
-   BEGIN_BATCH(7, IGNORE_CLIPRECTS);
+   BEGIN_BATCH(7);
    OUT_BATCH(CMD_PIPELINED_STATE_POINTERS << 16 | (7 - 2));
    OUT_RELOC(brw->vs.state_bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0);
    if (brw->gs.prog_active)
@@ -212,10 +209,10 @@ static void emit_depthbuffer(struct brw_context *brw)
 {
    struct intel_context *intel = &brw->intel;
    struct intel_region *region = brw->state.depth_region;
-   unsigned int len = (BRW_IS_G4X(brw) || BRW_IS_IGDNG(brw)) ? 6 : 5;
+   unsigned int len = (intel->is_g4x || intel->is_ironlake) ? 6 : 5;
 
    if (region == NULL) {
-      BEGIN_BATCH(len, IGNORE_CLIPRECTS);
+      BEGIN_BATCH(len);
       OUT_BATCH(CMD_DEPTH_BUFFER << 16 | (len - 2));
       OUT_BATCH((BRW_DEPTHFORMAT_D32_FLOAT << 18) |
                (BRW_SURFACE_NULL << 29));
@@ -223,7 +220,7 @@ static void emit_depthbuffer(struct brw_context *brw)
       OUT_BATCH(0);
       OUT_BATCH(0);
 
-      if (BRW_IS_G4X(brw) || BRW_IS_IGDNG(brw))
+      if (intel->is_g4x || intel->is_ironlake)
          OUT_BATCH(0);
 
       ADVANCE_BATCH();
@@ -247,7 +244,7 @@ static void emit_depthbuffer(struct brw_context *brw)
 
       assert(region->tiling != I915_TILING_X);
 
-      BEGIN_BATCH(len, IGNORE_CLIPRECTS);
+      BEGIN_BATCH(len);
       OUT_BATCH(CMD_DEPTH_BUFFER << 16 | (len - 2));
       OUT_BATCH(((region->pitch * region->cpp) - 1) |
                (format << 18) |
@@ -262,7 +259,7 @@ static void emit_depthbuffer(struct brw_context *brw)
                ((region->height - 1) << 19));
       OUT_BATCH(0);
 
-      if (BRW_IS_G4X(brw) || BRW_IS_IGDNG(brw))
+      if (intel->is_g4x || intel->is_ironlake)
          OUT_BATCH(0);
 
       ADVANCE_BATCH();
@@ -317,7 +314,7 @@ static void upload_polygon_stipple(struct brw_context *brw)
 const struct brw_tracked_state brw_polygon_stipple = {
    .dirty = {
       .mesa = _NEW_POLYGONSTIPPLE,
-      .brw = 0,
+      .brw = BRW_NEW_CONTEXT,
       .cache = 0
    },
    .emit = upload_polygon_stipple
@@ -330,7 +327,7 @@ const struct brw_tracked_state brw_polygon_stipple = {
 
 static void upload_polygon_stipple_offset(struct brw_context *brw)
 {
-   __DRIdrawablePrivate *dPriv = brw->intel.driDrawable;
+   __DRIdrawable *dPriv = brw->intel.driDrawable;
    struct brw_polygon_stipple_offset bpso;
 
    memset(&bpso, 0, sizeof(bpso));
@@ -362,7 +359,7 @@ static void upload_polygon_stipple_offset(struct brw_context *brw)
 const struct brw_tracked_state brw_polygon_stipple_offset = {
    .dirty = {
       .mesa = _NEW_WINDOW_POS,
-      .brw = 0,
+      .brw = BRW_NEW_CONTEXT,
       .cache = 0
    },
    .emit = upload_polygon_stipple_offset
@@ -374,8 +371,8 @@ const struct brw_tracked_state brw_polygon_stipple_offset = {
 static void upload_aa_line_parameters(struct brw_context *brw)
 {
    struct brw_aa_line_parameters balp;
-   
-   if (BRW_IS_965(brw))
+
+   if (!brw->has_aa_line_parameters)
       return;
 
    /* use legacy aa line coverage computation */
@@ -425,7 +422,7 @@ static void upload_line_stipple(struct brw_context *brw)
 const struct brw_tracked_state brw_line_stipple = {
    .dirty = {
       .mesa = _NEW_LINE,
-      .brw = 0,
+      .brw = BRW_NEW_CONTEXT,
       .cache = 0
    },
    .emit = upload_line_stipple
@@ -444,7 +441,7 @@ static void upload_invarient_state( struct brw_context *brw )
       struct brw_pipeline_select ps;
 
       memset(&ps, 0, sizeof(ps));
-      ps.header.opcode = CMD_PIPELINE_SELECT(brw);
+      ps.header.opcode = brw->CMD_PIPELINE_SELECT;
       ps.header.pipeline_select = 0;
       BRW_BATCH_STRUCT(brw, &ps);
    }
@@ -480,7 +477,7 @@ static void upload_invarient_state( struct brw_context *brw )
       struct brw_vf_statistics vfs;
       memset(&vfs, 0, sizeof(vfs));
 
-      vfs.opcode = CMD_VF_STATISTICS(brw);
+      vfs.opcode = brw->CMD_VF_STATISTICS;
       if (INTEL_DEBUG & DEBUG_STATS)
         vfs.statistics_enable = 1; 
 
@@ -512,8 +509,8 @@ static void upload_state_base_address( struct brw_context *brw )
    /* Output the structure (brw_state_base_address) directly to the
     * batchbuffer, so we can emit relocations inline.
     */
-   if (BRW_IS_IGDNG(brw)) {
-       BEGIN_BATCH(8, IGNORE_CLIPRECTS);
+   if (intel->is_ironlake) {
+       BEGIN_BATCH(8);
        OUT_BATCH(CMD_STATE_BASE_ADDRESS << 16 | (8 - 2));
        OUT_BATCH(1); /* General state base address */
        OUT_BATCH(1); /* Surface state base address */
@@ -524,7 +521,7 @@ static void upload_state_base_address( struct brw_context *brw )
        OUT_BATCH(1); /* Instruction access upper bound */
        ADVANCE_BATCH();
    } else {
-       BEGIN_BATCH(6, IGNORE_CLIPRECTS);
+       BEGIN_BATCH(6);
        OUT_BATCH(CMD_STATE_BASE_ADDRESS << 16 | (6 - 2));
        OUT_BATCH(1); /* General state base address */
        OUT_BATCH(1); /* Surface state base address */
index a195bc32b07d63ec4327644401de5a8a3b2a07a4..5399a742449a7ca9bf6f97a00082457c9d27c753 100644 (file)
@@ -188,7 +188,7 @@ brw_emit_query_begin(struct brw_context *brw)
    if (brw->query.active || is_empty_list(&brw->query.active_head))
       return;
 
-   BEGIN_BATCH(4, IGNORE_CLIPRECTS);
+   BEGIN_BATCH(4);
    OUT_BATCH(_3DSTATE_PIPE_CONTROL |
             PIPE_CONTROL_DEPTH_STALL |
             PIPE_CONTROL_WRITE_DEPTH_COUNT);
@@ -227,7 +227,7 @@ brw_emit_query_end(struct brw_context *brw)
    if (!brw->query.active)
       return;
 
-   BEGIN_BATCH(4, IGNORE_CLIPRECTS);
+   BEGIN_BATCH(4);
    OUT_BATCH(_3DSTATE_PIPE_CONTROL |
             PIPE_CONTROL_DEPTH_STALL |
             PIPE_CONTROL_WRITE_DEPTH_COUNT);
index e1c2c7777b518b0875d4c0e4274d703f024403a0..968890f7fb19978ec727c5e10b65dc16c71a0a83 100644 (file)
@@ -61,7 +61,7 @@ static void compile_sf_prog( struct brw_context *brw,
    c.key = *key;
    c.nr_attrs = brw_count_bits(c.key.attrs);
    c.nr_attr_regs = (c.nr_attrs+1)/2;
-   c.nr_setup_attrs = brw_count_bits(c.key.attrs & DO_SETUP_BITS);
+   c.nr_setup_attrs = brw_count_bits(c.key.attrs);
    c.nr_setup_regs = (c.nr_setup_attrs+1)/2;
 
    c.prog_data.urb_read_length = c.nr_attr_regs;
@@ -70,7 +70,7 @@ static void compile_sf_prog( struct brw_context *brw,
    /* Construct map from attribute number to position in the vertex.
     */
    for (i = idx = 0; i < VERT_RESULT_MAX; i++) 
-      if (c.key.attrs & (1<<i)) {
+      if (c.key.attrs & BITFIELD64_BIT(i)) {
         c.attr_to_idx[i] = idx;
         c.idx_to_attr[idx] = i;
         if (i >= VERT_RESULT_TEX0 && i <= VERT_RESULT_TEX7) {
@@ -147,7 +147,7 @@ static void upload_sf_prog(struct brw_context *brw)
        * edgeflag testing here, it is already done in the clip
        * program.
        */
-      if (key.attrs & (1<<VERT_RESULT_EDGE))
+      if (key.attrs & BITFIELD64_BIT(VERT_RESULT_EDGE))
         key.primitive = SF_UNFILLED_TRIS;
       else
         key.primitive = SF_TRIANGLES;
@@ -161,7 +161,7 @@ static void upload_sf_prog(struct brw_context *brw)
    }
 
    key.do_point_sprite = ctx->Point.PointSprite;
-   key.SpriteOrigin = ctx->Point.SpriteOrigin;
+   key.sprite_origin_lower_left = (ctx->Point.SpriteOrigin == GL_LOWER_LEFT);
    /* _NEW_LIGHT */
    key.do_flat_shading = (ctx->Light.ShadeModel == GL_FLAT);
    key.do_twoside_color = (ctx->Light.Enabled && ctx->Light.Model.TwoSide);
index 6426b6df9ffa38d207feb5074333200aea6b5e74..0ba731fac99463607d94f41a805e794b1d6e530b 100644 (file)
 #define SF_UNFILLED_TRIS   3
 
 struct brw_sf_prog_key {
-   GLuint attrs:32;
+   GLbitfield64 attrs;
    GLuint primitive:2;
    GLuint do_twoside_color:1;
    GLuint do_flat_shading:1;
    GLuint frontface_ccw:1;
    GLuint do_point_sprite:1;
    GLuint linear_color:1;  /**< linear interp vs. perspective interp */
-   GLuint pad:25;
-   GLenum SpriteOrigin;
+   GLuint sprite_origin_lower_left:1;
+   GLuint pad:24;
 };
 
 struct brw_sf_point_tex {
-       GLboolean CoordReplace; 
+   GLboolean CoordReplace;     
 };
 
 struct brw_sf_compile {
index ca8f97f9f9e96f07711aef2b50d6d95c4264417e..bb08055e3bb6db23587a92aa858cb88aed9d7dd6 100644 (file)
@@ -56,7 +56,7 @@ static struct brw_reg get_vert_attr(struct brw_sf_compile *c,
 static GLboolean have_attr(struct brw_sf_compile *c,
                           GLuint attr)
 {
-   return (c->key.attrs & (1<<attr)) ? 1 : 0;
+   return (c->key.attrs & BITFIELD64_BIT(attr)) ? 1 : 0;
 }
 
 /*********************************************************************** 
@@ -122,8 +122,8 @@ static void do_twoside_color( struct brw_sf_compile *c )
  * Flat shading
  */
 
-#define VERT_RESULT_COLOR_BITS ((1<<VERT_RESULT_COL0) | \
-                                 (1<<VERT_RESULT_COL1))
+#define VERT_RESULT_COLOR_BITS (BITFIELD64_BIT(VERT_RESULT_COL0) | \
+                               BITFIELD64_BIT(VERT_RESULT_COL1))
 
 static void copy_colors( struct brw_sf_compile *c,
                     struct brw_reg dst,
@@ -149,6 +149,7 @@ static void copy_colors( struct brw_sf_compile *c,
 static void do_flatshade_triangle( struct brw_sf_compile *c )
 {
    struct brw_compile *p = &c->func;
+   struct intel_context *intel = &p->brw->intel;
    struct brw_reg ip = brw_ip_reg();
    GLuint nr = brw_count_bits(c->key.attrs & VERT_RESULT_COLOR_BITS);
    GLuint jmpi = 1;
@@ -161,7 +162,7 @@ static void do_flatshade_triangle( struct brw_sf_compile *c )
    if (c->key.primitive == SF_UNFILLED_TRIS)
       return;
 
-   if (BRW_IS_IGDNG(p->brw))
+   if (intel->is_ironlake)
        jmpi = 2;
 
    brw_push_insn_state(p);
@@ -187,6 +188,7 @@ static void do_flatshade_triangle( struct brw_sf_compile *c )
 static void do_flatshade_line( struct brw_sf_compile *c )
 {
    struct brw_compile *p = &c->func;
+   struct intel_context *intel = &p->brw->intel;
    struct brw_reg ip = brw_ip_reg();
    GLuint nr = brw_count_bits(c->key.attrs & VERT_RESULT_COLOR_BITS);
    GLuint jmpi = 1;
@@ -199,7 +201,7 @@ static void do_flatshade_line( struct brw_sf_compile *c )
    if (c->key.primitive == SF_UNFILLED_TRIS)
       return;
 
-   if (BRW_IS_IGDNG(p->brw))
+   if (intel->is_ironlake)
        jmpi = 2;
 
    brw_push_insn_state(p);
@@ -312,8 +314,8 @@ 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;
-   GLuint linear_mask;
+   GLbitfield64 persp_mask;
+   GLbitfield64 linear_mask;
 
    if (c->key.do_flat_shading || c->key.linear_color)
       persp_mask = c->key.attrs & ~(FRAG_BIT_WPOS |
@@ -331,10 +333,10 @@ static GLboolean calculate_masks( struct brw_sf_compile *c,
    *pc_linear = 0;
    *pc = 0xf;
       
-   if (persp_mask & (1 << c->idx_to_attr[reg*2])) 
+   if (persp_mask & BITFIELD64_BIT(c->idx_to_attr[reg*2]))
       *pc_persp = 0xf;
 
-   if (linear_mask & (1 << c->idx_to_attr[reg*2])) 
+   if (linear_mask & BITFIELD64_BIT(c->idx_to_attr[reg*2]))
       *pc_linear = 0xf;
 
    /* Maybe only processs one attribute on the final round:
@@ -342,10 +344,10 @@ static GLboolean calculate_masks( struct brw_sf_compile *c,
    if (reg*2+1 < c->nr_setup_attrs) {
       *pc |= 0xf0;
 
-      if (persp_mask & (1 << c->idx_to_attr[reg*2+1])) 
+      if (persp_mask & BITFIELD64_BIT(c->idx_to_attr[reg*2+1]))
         *pc_persp |= 0xf0;
 
-      if (linear_mask & (1 << c->idx_to_attr[reg*2+1])) 
+      if (linear_mask & BITFIELD64_BIT(c->idx_to_attr[reg*2+1]))
         *pc_linear |= 0xf0;
    }
 
@@ -551,7 +553,7 @@ void brw_emit_point_sprite_setup( struct brw_sf_compile *c, GLboolean allocate)
                  BRW_MATH_DATA_SCALAR,
                  BRW_MATH_PRECISION_FULL);
 
-         if (c->key.SpriteOrigin == GL_LOWER_LEFT) {
+         if (c->key.sprite_origin_lower_left) {
                brw_MUL(p, c->m1Cx, c->tmp, c->inv_w[0]);
                brw_MOV(p, vec1(suboffset(c->m1Cx, 1)), brw_imm_f(0.0));
                brw_MUL(p, c->m2Cy, c->tmp, negate(c->inv_w[0]));
@@ -570,7 +572,7 @@ void brw_emit_point_sprite_setup( struct brw_sf_compile *c, GLboolean allocate)
       {
         brw_set_predicate_control_flag_value(p, pc); 
         if (tex->CoordReplace) {
-            if (c->key.SpriteOrigin == GL_LOWER_LEFT) {
+            if (c->key.sprite_origin_lower_left) {
                 brw_MUL(p, c->m3C0, c->inv_w[0], brw_imm_f(1.0));
                 brw_MOV(p, vec1(suboffset(c->m3C0, 0)), brw_imm_f(0.0));
             }
index bc0f0760738dcdc5f733aed8ee94f09d7b50ca7c..09223b7cfb1d95b01f9be4f39e8567b942ab65fb 100644 (file)
@@ -93,7 +93,8 @@ static void upload_sf_vp(struct brw_context *brw)
    }
 
    dri_bo_unreference(brw->sf.vp_bo);
-   brw->sf.vp_bo = brw_cache_data( &brw->cache, BRW_SF_VP, &sfv, NULL, 0 );
+   brw->sf.vp_bo = brw_cache_data(&brw->cache, BRW_SF_VP, &sfv, sizeof(sfv),
+                                 NULL, 0);
 }
 
 const struct brw_tracked_state brw_sf_vp = {
@@ -113,7 +114,8 @@ struct brw_sf_unit_key {
 
    unsigned int nr_urb_entries, urb_size, sfsize;
 
-   GLenum front_face, cull_face, provoking_vertex;
+   GLenum front_face, cull_face;
+   unsigned pv_first:1;
    unsigned scissor:1;
    unsigned line_smooth:1;
    unsigned point_sprite:1;
@@ -154,7 +156,7 @@ sf_unit_populate_key(struct brw_context *brw, struct brw_sf_unit_key *key)
    key->point_attenuated = ctx->Point._Attenuated;
 
    /* _NEW_LIGHT */
-   key->provoking_vertex = ctx->Light.ProvokingVertex;
+   key->pv_first = (ctx->Light.ProvokingVertex == GL_FIRST_VERTEX_CONVENTION);
 
    key->render_to_fbo = brw->intel.ctx.DrawBuffer->Name != 0;
 }
@@ -163,6 +165,7 @@ static dri_bo *
 sf_unit_create_from_key(struct brw_context *brw, struct brw_sf_unit_key *key,
                        dri_bo **reloc_bufs)
 {
+   struct intel_context *intel = &brw->intel;
    struct brw_sf_unit_state sf;
    dri_bo *bo;
    int chipset_max_threads;
@@ -175,7 +178,7 @@ sf_unit_create_from_key(struct brw_context *brw, struct brw_sf_unit_key *key,
 
    sf.thread3.dispatch_grf_start_reg = 3;
 
-   if (BRW_IS_IGDNG(brw))
+   if (intel->is_ironlake)
        sf.thread3.urb_entry_read_offset = 3;
    else
        sf.thread3.urb_entry_read_offset = 1;
@@ -185,10 +188,10 @@ sf_unit_create_from_key(struct brw_context *brw, struct brw_sf_unit_key *key,
    sf.thread4.nr_urb_entries = key->nr_urb_entries;
    sf.thread4.urb_entry_allocation_size = key->sfsize - 1;
 
-   /* Each SF thread produces 1 PUE, and there can be up to 24(Pre-IGDNG) or 
-    * 48(IGDNG) threads 
+   /* Each SF thread produces 1 PUE, and there can be up to 24 (Pre-Ironlake) or
+    * 48 (Ironlake) threads.
     */
-   if (BRW_IS_IGDNG(brw))
+   if (intel->is_ironlake)
       chipset_max_threads = 48;
    else
       chipset_max_threads = 24;
@@ -287,7 +290,7 @@ sf_unit_create_from_key(struct brw_context *brw, struct brw_sf_unit_key *key,
 
    /* might be BRW_NEW_PRIMITIVE if we have to adjust pv for polygons:
     */
-   if (key->provoking_vertex == GL_LAST_VERTEX_CONVENTION) {
+   if (!key->pv_first) {
       sf.sf7.trifan_pv = 2;
       sf.sf7.linestrip_pv = 1;
       sf.sf7.tristrip_pv = 2;
index d639656b9d41a718e4cad082a386da65cf848339..9c9d145c4b69f67afe2a6a512af28439352747b8 100644 (file)
@@ -35,7 +35,7 @@
 
 #include "brw_context.h"
 
-static inline void
+static INLINE void
 brw_add_validated_bo(struct brw_context *brw, dri_bo *bo)
 {
    assert(brw->state.validated_bo_count < ARRAY_SIZE(brw->state.validated_bos));
@@ -112,6 +112,7 @@ void brw_validate_state(struct brw_context *brw);
 void brw_upload_state(struct brw_context *brw);
 void brw_init_state(struct brw_context *brw);
 void brw_destroy_state(struct brw_context *brw);
+void brw_clear_validated_bos(struct brw_context *brw);
 
 /***********************************************************************
  * brw_state_cache.c
@@ -119,16 +120,10 @@ void brw_destroy_state(struct brw_context *brw);
 dri_bo *brw_cache_data(struct brw_cache *cache,
                       enum brw_cache_id cache_id,
                       const void *data,
+                      GLuint size,
                       dri_bo **reloc_bufs,
                       GLuint nr_reloc_bufs);
 
-dri_bo *brw_cache_data_sz(struct brw_cache *cache,
-                         enum brw_cache_id cache_id,
-                         const void *data,
-                         GLuint data_size,
-                         dri_bo **reloc_bufs,
-                         GLuint nr_reloc_bufs);
-
 dri_bo *brw_upload_cache( struct brw_cache *cache,
                          enum brw_cache_id cache_id,
                          const void *key,
@@ -156,7 +151,7 @@ void brw_state_cache_bo_delete(struct brw_cache *cache, dri_bo *bo);
 /***********************************************************************
  * brw_state_batch.c
  */
-#define BRW_BATCH_STRUCT(brw, s) intel_batchbuffer_data( brw->intel.batch, (s), sizeof(*(s)), IGNORE_CLIPRECTS)
+#define BRW_BATCH_STRUCT(brw, s) intel_batchbuffer_data( brw->intel.batch, (s), sizeof(*(s)))
 #define BRW_CACHED_BATCH_STRUCT(brw, s) brw_cached_batch_struct( brw, (s), sizeof(*(s)) )
 
 GLboolean brw_cached_batch_struct( struct brw_context *brw,
index 7821898cf9b5f5787e0fd06daba668c81f9c120b..ed8120d617fe9ff1f374cfef5965f8f58fc6b1b2 100644 (file)
@@ -48,7 +48,7 @@ GLboolean brw_cached_batch_struct( struct brw_context *brw,
    struct header *newheader = (struct header *)data;
 
    if (brw->emit_state_always) {
-      intel_batchbuffer_data(brw->intel.batch, data, sz, IGNORE_CLIPRECTS);
+      intel_batchbuffer_data(brw->intel.batch, data, sz);
       return GL_TRUE;
    }
 
@@ -75,7 +75,7 @@ GLboolean brw_cached_batch_struct( struct brw_context *brw,
 
  emit:
    memcpy(item->header, newheader, sz);
-   intel_batchbuffer_data(brw->intel.batch, data, sz, IGNORE_CLIPRECTS);
+   intel_batchbuffer_data(brw->intel.batch, data, sz);
    return GL_TRUE;
 }
 
index f8e46aacf710251f058417008828670ef1a26dfd..e4c9ba7d870fccb95137a10ecf8e4c427a5885c2 100644 (file)
@@ -245,7 +245,6 @@ brw_upload_cache( struct brw_cache *cache,
 
    item->bo = bo;
    dri_bo_reference(bo);
-   item->data_size = data_size;
 
    if (cache->n_items > cache->size * 1.5)
       rehash(cache);
@@ -275,15 +274,22 @@ brw_upload_cache( struct brw_cache *cache,
 
 
 /**
- * This doesn't really work with aux data.  Use search/upload instead
+ * Wrapper around brw_cache_data_sz using the cache_id's canonical key size.
+ *
+ * If nr_reloc_bufs is nonzero, brw_search_cache()/brw_upload_cache() would be
+ * better to use, as the potentially changing offsets in the data-used-as-key
+ * will result in excessive cache misses.
+ *
+ * If aux data is involved, use search/upload instead.
+
  */
 dri_bo *
-brw_cache_data_sz(struct brw_cache *cache,
-                 enum brw_cache_id cache_id,
-                 const void *data,
-                 GLuint data_size,
-                 dri_bo **reloc_bufs,
-                 GLuint nr_reloc_bufs)
+brw_cache_data(struct brw_cache *cache,
+              enum brw_cache_id cache_id,
+              const void *data,
+              GLuint data_size,
+              dri_bo **reloc_bufs,
+              GLuint nr_reloc_bufs)
 {
    dri_bo *bo;
    struct brw_cache_item *item;
@@ -306,25 +312,6 @@ brw_cache_data_sz(struct brw_cache *cache,
    return bo;
 }
 
-
-/**
- * Wrapper around brw_cache_data_sz using the cache_id's canonical key size.
- *
- * If nr_reloc_bufs is nonzero, brw_search_cache()/brw_upload_cache() would be
- * better to use, as the potentially changing offsets in the data-used-as-key
- * will result in excessive cache misses.
- */
-dri_bo *
-brw_cache_data(struct brw_cache *cache,
-              enum brw_cache_id cache_id,
-              const void *data,
-              dri_bo **reloc_bufs,
-              GLuint nr_reloc_bufs)
-{
-   return brw_cache_data_sz(cache, cache_id, data, cache->key_size[cache_id],
-                           reloc_bufs, nr_reloc_bufs);
-}
-
 enum pool_type {
    DW_SURFACE_STATE,
    DW_GENERAL_STATE
@@ -335,11 +322,9 @@ static void
 brw_init_cache_id(struct brw_cache *cache,
                   const char *name,
                   enum brw_cache_id id,
-                  GLuint key_size,
                   GLuint aux_size)
 {
    cache->name[id] = strdup(name);
-   cache->key_size[id] = key_size;
    cache->aux_size[id] = aux_size;
 }
 
@@ -359,91 +344,76 @@ brw_init_non_surface_cache(struct brw_context *brw)
    brw_init_cache_id(cache,
                     "CC_VP",
                     BRW_CC_VP,
-                    sizeof(struct brw_cc_viewport),
                     0);
 
    brw_init_cache_id(cache,
                     "CC_UNIT",
                     BRW_CC_UNIT,
-                    sizeof(struct brw_cc_unit_state),
                     0);
 
    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(cache,
                     "SAMPLER_DEFAULT_COLOR",
                     BRW_SAMPLER_DEFAULT_COLOR,
-                    sizeof(struct brw_sampler_default_color),
                     0);
 
    brw_init_cache_id(cache,
                     "SAMPLER",
                     BRW_SAMPLER,
-                    0,         /* variable key/data size */
                     0);
 
    brw_init_cache_id(cache,
                     "WM_UNIT",
                     BRW_WM_UNIT,
-                    sizeof(struct brw_wm_unit_state),
                     0);
 
    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(cache,
                     "SF_VP",
                     BRW_SF_VP,
-                    sizeof(struct brw_sf_viewport),
                     0);
 
    brw_init_cache_id(cache,
                     "SF_UNIT",
                     BRW_SF_UNIT,
-                    sizeof(struct brw_sf_unit_state),
                     0);
 
    brw_init_cache_id(cache,
                     "VS_UNIT",
                     BRW_VS_UNIT,
-                    sizeof(struct brw_vs_unit_state),
                     0);
 
    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(cache,
                     "CLIP_UNIT",
                     BRW_CLIP_UNIT,
-                    sizeof(struct brw_clip_unit_state),
                     0);
 
    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(cache,
                     "GS_UNIT",
                     BRW_GS_UNIT,
-                    sizeof(struct brw_gs_unit_state),
                     0);
 
    brw_init_cache_id(cache,
                     "GS_PROG",
                     BRW_GS_PROG,
-                    sizeof(struct brw_gs_prog_key),
                     sizeof(struct brw_gs_prog_data));
 }
 
@@ -463,13 +433,11 @@ brw_init_surface_cache(struct brw_context *brw)
    brw_init_cache_id(cache,
                     "SS_SURFACE",
                     BRW_SS_SURFACE,
-                    sizeof(struct brw_surface_state),
                     0);
 
    brw_init_cache_id(cache,
                     "SS_SURF_BIND",
                     BRW_SS_SURF_BIND,
-                    0,
                     0);
 }
 
@@ -534,14 +502,9 @@ brw_state_cache_bo_delete(struct brw_cache *cache, dri_bo *bo)
    for (i = 0; i < cache->size; i++) {
       for (prev = &cache->items[i]; *prev;) {
         struct brw_cache_item *c = *prev;
-        int j;
-
-        for (j = 0; j < c->nr_reloc_bufs; j++) {
-           if (c->reloc_bufs[j] == bo)
-              break;
-        }
 
-        if (j != c->nr_reloc_bufs) {
+        if (drm_intel_bo_references(c->bo, bo)) {
+           int j;
 
            *prev = c->next;
 
@@ -551,17 +514,8 @@ brw_state_cache_bo_delete(struct brw_cache *cache, dri_bo *bo)
            free((void *)c->key);
            free(c);
            cache->n_items--;
-
-           /* Delete up the tree.  Notably we're trying to get from
-            * a request to delete the surface, to deleting the surface state
-            * object, to deleting the binding table.  We're slack and restart
-            * the deletion process when we do this because the other delete
-            * may kill our *prev.
-            */
-           brw_state_cache_bo_delete(cache, c->bo);
-           prev = &cache->items[i];
         } else {
-           prev = &(*prev)->next;
+           prev = &c->next;
         }
       }
    }
index b817b741e77fd745b79e76b118f0cecbbbc5d88c..af8dfb4c15c20366c8d5be1a69edf2655343e58a 100644 (file)
@@ -34,6 +34,7 @@
 #include "brw_context.h"
 #include "brw_state.h"
 #include "intel_batchbuffer.h"
+#include "intel_buffers.h"
 
 /* This is used to initialize brw->state.atoms[].  We could use this
  * list directly except for a single atom, brw_constant_buffer, which
@@ -142,7 +143,7 @@ static void xor_states( struct brw_state_flags *result,
    result->cache = a->cache ^ b->cache;
 }
 
-static void
+void
 brw_clear_validated_bos(struct brw_context *brw)
 {
    int i;
@@ -308,7 +309,7 @@ void brw_validate_state( struct brw_context *brw )
    if (brw->state.dirty.brw & BRW_NEW_CONTEXT)
       brw_clear_batch_cache(brw);
 
-   brw->intel.Fallback = 0;
+   brw->intel.Fallback = GL_FALSE; /* boolean, not bitfield */
 
    /* do prepare stage for all atoms */
    for (i = 0; i < Elements(atoms); i++) {
@@ -324,6 +325,8 @@ void brw_validate_state( struct brw_context *brw )
       }
    }
 
+   intel_check_front_buffer_rendering(intel);
+
    /* Make sure that the textures which are referenced by the current
     * brw fragment program are actually present/valid.
     * If this fails, we can experience GPU lock-ups.
index 5986cbffade3ee81180863ec6388dd7d95228dc1..64a9535282bd43f8a0cf17fbf502bc559c859cfc 100644 (file)
@@ -49,7 +49,7 @@ GLboolean brw_miptree_layout(struct intel_context *intel,
 
    switch (mt->target) {
    case GL_TEXTURE_CUBE_MAP:
-      if (IS_IGDNG(intel->intelScreen->deviceID)) {
+      if (intel->is_ironlake) {
           GLuint align_h = 2, align_w = 4;
           GLuint level;
           GLuint x = 0;
@@ -86,10 +86,10 @@ GLboolean brw_miptree_layout(struct intel_context *intel,
           mt->pitch = intel_miptree_pitch_align(intel, mt, tiling, mt->pitch);
 
           if (mt->compressed) {
-              qpitch = (y_pitch + ALIGN(minify(y_pitch), align_h) + 11 * align_h) / 4 * mt->pitch * mt->cpp;
+              qpitch = (y_pitch + ALIGN(minify(y_pitch), align_h) + 11 * align_h) / 4;
               mt->total_height = (y_pitch + ALIGN(minify(y_pitch), align_h) + 11 * align_h) / 4 * 6;
           } else {
-              qpitch = (y_pitch + ALIGN(minify(y_pitch), align_h) + 11 * align_h) * mt->pitch * mt->cpp;
+              qpitch = (y_pitch + ALIGN(minify(y_pitch), align_h) + 11 * align_h);
               mt->total_height = (y_pitch + ALIGN(minify(y_pitch), align_h) + 11 * align_h) * 6;
           }
 
@@ -102,7 +102,8 @@ GLboolean brw_miptree_layout(struct intel_context *intel,
                                            height, 1);
 
               for (q = 0; q < nr_images; q++)
-                  intel_miptree_set_image_offset_ex(mt, level, q, x, y, q * qpitch);
+                  intel_miptree_set_image_offset(mt, level, q,
+                                                x, y + q * qpitch);
 
               if (mt->compressed)
                   img_height = MAX2(1, height/4);
index 8c6f4355a6eccd1bede10b814e48a4886df1694c..f2cdb203b85235ffddf27d1f14e7dbc9524dd85a 100644 (file)
@@ -105,7 +105,8 @@ static GLboolean check_urb_layout( struct brw_context *brw )
    brw->urb.sf_start = brw->urb.clip_start + brw->urb.nr_clip_entries * brw->urb.vsize;
    brw->urb.cs_start = brw->urb.sf_start + brw->urb.nr_sf_entries * brw->urb.sfsize;
 
-   return brw->urb.cs_start + brw->urb.nr_cs_entries * brw->urb.csize <= URB_SIZES(brw);
+   return brw->urb.cs_start + brw->urb.nr_cs_entries *
+      brw->urb.csize <= brw->urb.size;
 }
 
 /* Most minimal update, forces re-emit of URB fence packet after GS
@@ -113,6 +114,7 @@ static GLboolean check_urb_layout( struct brw_context *brw )
  */
 static void recalculate_urb_fence( struct brw_context *brw )
 {
+   struct intel_context *intel = &brw->intel;
    GLuint csize = brw->curbe.total_size;
    GLuint vsize = brw->vs.prog_data->urb_entry_size;
    GLuint sfsize = brw->sf.prog_data->urb_entry_size;
@@ -146,7 +148,7 @@ static void recalculate_urb_fence( struct brw_context *brw )
 
       brw->urb.constrained = 0;
 
-      if (BRW_IS_IGDNG(brw)) {
+      if (intel->is_ironlake) {
          brw->urb.nr_vs_entries = 128;
          brw->urb.nr_sf_entries = 48;
          if (check_urb_layout(brw)) {
@@ -156,7 +158,7 @@ static void recalculate_urb_fence( struct brw_context *brw )
             brw->urb.nr_vs_entries = limits[VS].preferred_nr_entries;
             brw->urb.nr_sf_entries = limits[SF].preferred_nr_entries;
          }
-      } else if (BRW_IS_G4X(brw)) {
+      } else if (intel->is_g4x) {
         brw->urb.nr_vs_entries = 64;
         if (check_urb_layout(brw)) {
            goto done;
@@ -200,7 +202,7 @@ done:
                      brw->urb.clip_start,
                      brw->urb.sf_start,
                      brw->urb.cs_start, 
-                     URB_SIZES(brw));
+                     brw->urb.size);
       
       brw->state.dirty.brw |= BRW_NEW_URB_FENCE;
    }
@@ -244,7 +246,7 @@ void brw_upload_urb_fence(struct brw_context *brw)
    uf.bits0.gs_fence  = brw->urb.clip_start; 
    uf.bits0.clp_fence = brw->urb.sf_start; 
    uf.bits1.sf_fence  = brw->urb.cs_start; 
-   uf.bits1.cs_fence  = URB_SIZES(brw);
+   uf.bits1.cs_fence  = brw->urb.size;
 
    BRW_BATCH_STRUCT(brw, &uf);
 }
index ce21aa48695c47f428a99af2d333bd57cfa1fd93..bba9249d1b43d43b0a1e50750693e2f45760c425 100644 (file)
@@ -35,7 +35,7 @@
 #include "brw_util.h"
 #include "brw_defines.h"
 
-GLuint brw_count_bits( GLuint val )
+GLuint brw_count_bits(uint64_t val)
 {
    GLuint i;
    for (i = 0; val ; val >>= 1)
index 33e7cd87e425f3ef5219956b7b922f005fd042b4..04f3175d3e1b0e8bfc60547d49c3f3ce43c66da6 100644 (file)
@@ -35,7 +35,7 @@
 
 #include "main/mtypes.h"
 
-extern GLuint brw_count_bits( GLuint val );
+extern GLuint brw_count_bits(uint64_t val);
 extern GLuint brw_parameter_list_state_flags(struct gl_program_parameter_list *paramList);
 extern GLuint brw_translate_blend_factor( GLenum factor );
 extern GLuint brw_translate_blend_equation( GLenum mode );
index f0c79efbd964f96c17f7f2a5a0ba4eaf30cebb91..fd055e225e024d5f5148c333b5cfcffb55bf0f9b 100644 (file)
@@ -56,7 +56,7 @@ static void do_vs_prog( struct brw_context *brw,
    c.prog_data.inputs_read = vp->program.Base.InputsRead;
 
    if (c.key.copy_edgeflag) {
-      c.prog_data.outputs_written |= 1<<VERT_RESULT_EDGE;
+      c.prog_data.outputs_written |= BITFIELD64_BIT(VERT_RESULT_EDGE);
       c.prog_data.inputs_read |= 1<<VERT_ATTRIB_EDGEFLAG;
    }
 
index 1638ef81115910bcbebd8524e5446e13b3f3a7ed..1b84dd505f60be1e057bb7c6d6519d983b365041 100644 (file)
@@ -67,6 +67,7 @@ static void release_tmps( struct brw_vs_compile *c )
  */
 static void brw_vs_alloc_regs( struct brw_vs_compile *c )
 {
+   struct intel_context *intel = &c->func.brw->intel;
    GLuint i, reg = 0, mrf;
    int attributes_in_vue;
 
@@ -141,13 +142,13 @@ static void brw_vs_alloc_regs( struct brw_vs_compile *c )
    c->first_output = reg;
    c->first_overflow_output = 0;
 
-   if (BRW_IS_IGDNG(c->func.brw))
+   if (intel->is_ironlake)
        mrf = 8;
    else
        mrf = 4;
 
    for (i = 0; i < VERT_RESULT_MAX; i++) {
-      if (c->prog_data.outputs_written & (1 << i)) {
+      if (c->prog_data.outputs_written & BITFIELD64_BIT(i)) {
         c->nr_outputs++;
          assert(i < Elements(c->regs[PROGRAM_OUTPUT]));
         if (i == VERT_RESULT_HPOS) {
@@ -238,7 +239,7 @@ static void brw_vs_alloc_regs( struct brw_vs_compile *c )
     */
    attributes_in_vue = MAX2(c->nr_outputs, c->nr_inputs);
 
-   if (BRW_IS_IGDNG(c->func.brw))
+   if (intel->is_ironlake)
        c->prog_data.urb_entry_size = (attributes_in_vue + 6 + 3) / 4;
    else
        c->prog_data.urb_entry_size = (attributes_in_vue + 2 + 3) / 4;
@@ -331,63 +332,76 @@ static void unalias3( struct brw_vs_compile *c,
    }
 }
 
-static void emit_sop( struct brw_compile *p,
+static void emit_sop( struct brw_vs_compile *c,
                       struct brw_reg dst,
                       struct brw_reg arg0,
                       struct brw_reg arg1, 
                      GLuint cond)
 {
+   struct brw_compile *p = &c->func;
+
    brw_MOV(p, dst, brw_imm_f(0.0f));
    brw_CMP(p, brw_null_reg(), cond, arg0, arg1);
    brw_MOV(p, dst, brw_imm_f(1.0f));
    brw_set_predicate_control_flag_value(p, 0xff);
 }
 
-static void emit_seq( struct brw_compile *p,
+static void emit_seq( struct brw_vs_compile *c,
                       struct brw_reg dst,
                       struct brw_reg arg0,
                       struct brw_reg arg1 )
 {
-   emit_sop(p, dst, arg0, arg1, BRW_CONDITIONAL_EQ);
+   emit_sop(c, dst, arg0, arg1, BRW_CONDITIONAL_EQ);
 }
 
-static void emit_sne( struct brw_compile *p,
+static void emit_sne( struct brw_vs_compile *c,
                       struct brw_reg dst,
                       struct brw_reg arg0,
                       struct brw_reg arg1 )
 {
-   emit_sop(p, dst, arg0, arg1, BRW_CONDITIONAL_NEQ);
+   emit_sop(c, dst, arg0, arg1, BRW_CONDITIONAL_NEQ);
 }
-static void emit_slt( struct brw_compile *p, 
+static void emit_slt( struct brw_vs_compile *c,
                      struct brw_reg dst,
                      struct brw_reg arg0,
                      struct brw_reg arg1 )
 {
-   emit_sop(p, dst, arg0, arg1, BRW_CONDITIONAL_L);
+   emit_sop(c, dst, arg0, arg1, BRW_CONDITIONAL_L);
 }
 
-static void emit_sle( struct brw_compile *p, 
+static void emit_sle( struct brw_vs_compile *c,
                      struct brw_reg dst,
                      struct brw_reg arg0,
                      struct brw_reg arg1 )
 {
-   emit_sop(p, dst, arg0, arg1, BRW_CONDITIONAL_LE);
+   emit_sop(c, dst, arg0, arg1, BRW_CONDITIONAL_LE);
 }
 
-static void emit_sgt( struct brw_compile *p, 
+static void emit_sgt( struct brw_vs_compile *c,
                      struct brw_reg dst,
                      struct brw_reg arg0,
                      struct brw_reg arg1 )
 {
-   emit_sop(p, dst, arg0, arg1, BRW_CONDITIONAL_G);
+   emit_sop(c, dst, arg0, arg1, BRW_CONDITIONAL_G);
 }
 
-static void emit_sge( struct brw_compile *p, 
+static void emit_sge( struct brw_vs_compile *c,
                      struct brw_reg dst,
                      struct brw_reg arg0,
                      struct brw_reg arg1 )
 {
-  emit_sop(p, dst, arg0, arg1, BRW_CONDITIONAL_GE);
+  emit_sop(c, dst, arg0, arg1, BRW_CONDITIONAL_GE);
+}
+
+static void emit_cmp( struct brw_compile *p,
+                     struct brw_reg dst,
+                     struct brw_reg arg0,
+                     struct brw_reg arg1,
+                     struct brw_reg arg2 )
+{
+   brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_L, arg0, brw_imm_f(0));
+   brw_SEL(p, dst, arg1, arg2);
+   brw_set_predicate_control(p, BRW_PREDICATE_NONE);
 }
 
 static void emit_max( struct brw_compile *p, 
@@ -912,6 +926,7 @@ get_src_reg( struct brw_vs_compile *c,
    case PROGRAM_CONSTANT:
    case PROGRAM_UNIFORM:
    case PROGRAM_ENV_PARAM:
+   case PROGRAM_LOCAL_PARAM:
       if (c->vp->use_const_buffer) {
          return get_constant(c, inst, argIndex);
       }
@@ -930,7 +945,6 @@ get_src_reg( struct brw_vs_compile *c,
       /* this is a normal case since we loop over all three src args */
       return brw_null_reg();
 
-   case PROGRAM_LOCAL_PARAM: 
    case PROGRAM_WRITE_ONLY:
    default:
       assert(0);
@@ -1100,6 +1114,8 @@ static void emit_swz( struct brw_vs_compile *c,
 static void emit_vertex_write( struct brw_vs_compile *c)
 {
    struct brw_compile *p = &c->func;
+   struct brw_context *brw = p->brw;
+   struct intel_context *intel = &brw->intel;
    struct brw_reg m0 = brw_message_reg(0);
    struct brw_reg pos = c->regs[PROGRAM_OUTPUT][VERT_RESULT_HPOS];
    struct brw_reg ndc;
@@ -1122,8 +1138,8 @@ static void emit_vertex_write( struct brw_vs_compile *c)
    /* Update the header for point size, user clipping flags, and -ve rhw
     * workaround.
     */
-   if ((c->prog_data.outputs_written & (1<<VERT_RESULT_PSIZ)) ||
-       c->key.nr_userclip || BRW_IS_965(p->brw))
+   if ((c->prog_data.outputs_written & BITFIELD64_BIT(VERT_RESULT_PSIZ)) ||
+       c->key.nr_userclip || brw->has_negative_rhw_bug)
    {
       struct brw_reg header1 = retype(get_tmp(c), BRW_REGISTER_TYPE_UD);
       GLuint i;
@@ -1132,7 +1148,7 @@ static void emit_vertex_write( struct brw_vs_compile *c)
 
       brw_set_access_mode(p, BRW_ALIGN_16);    
 
-      if (c->prog_data.outputs_written & (1<<VERT_RESULT_PSIZ)) {
+      if (c->prog_data.outputs_written & BITFIELD64_BIT(VERT_RESULT_PSIZ)) {
         struct brw_reg psiz = c->regs[PROGRAM_OUTPUT][VERT_RESULT_PSIZ];
         brw_MUL(p, brw_writemask(header1, WRITEMASK_W), brw_swizzle1(psiz, 0), brw_imm_f(1<<11));
         brw_AND(p, brw_writemask(header1, WRITEMASK_W), header1, brw_imm_ud(0x7ff<<8));
@@ -1154,7 +1170,7 @@ static void emit_vertex_write( struct brw_vs_compile *c)
        * Later, clipping will detect ucp[6] and ensure the primitive is
        * clipped against all fixed planes.
        */
-      if (BRW_IS_965(p->brw)) {
+      if (brw->has_negative_rhw_bug) {
         brw_CMP(p,
                 vec8(brw_null_reg()),
                 BRW_CONDITIONAL_L,
@@ -1182,8 +1198,8 @@ static void emit_vertex_write( struct brw_vs_compile *c)
    brw_set_access_mode(p, BRW_ALIGN_1);
    brw_MOV(p, offset(m0, 2), ndc);
 
-   if (BRW_IS_IGDNG(p->brw)) {
-       /* There are 20 DWs (D0-D19) in VUE vertex header on IGDNG */
+   if (intel->is_ironlake) {
+       /* There are 20 DWs (D0-D19) in VUE vertex header on Ironlake */
        brw_MOV(p, offset(m0, 3), pos); /* a portion of vertex header */
        /* m4, m5 contain the distances from vertex to the user clip planeXXX. 
         * Seems it is useless for us.
@@ -1222,7 +1238,7 @@ static void emit_vertex_write( struct brw_vs_compile *c)
        */
       GLuint i, mrf = 0;
       for (i = c->first_overflow_output; i < VERT_RESULT_MAX; i++) {
-         if (c->prog_data.outputs_written & (1 << i)) {
+         if (c->prog_data.outputs_written & BITFIELD64_BIT(i)) {
             /* move from GRF to MRF */
             brw_MOV(p, brw_message_reg(4+mrf), c->regs[PROGRAM_OUTPUT][i]);
             mrf++;
@@ -1269,6 +1285,38 @@ post_vs_emit( struct brw_vs_compile *c,
    }
 }
 
+static GLboolean
+accumulator_contains(struct brw_vs_compile *c, struct brw_reg val)
+{
+   struct brw_compile *p = &c->func;
+   struct brw_instruction *prev_insn = &p->store[p->nr_insn - 1];
+
+   if (p->nr_insn == 0)
+      return GL_FALSE;
+
+   if (val.address_mode != BRW_ADDRESS_DIRECT)
+      return GL_FALSE;
+
+   switch (prev_insn->header.opcode) {
+   case BRW_OPCODE_MOV:
+   case BRW_OPCODE_MAC:
+   case BRW_OPCODE_MUL:
+      if (prev_insn->header.access_mode == BRW_ALIGN_16 &&
+         prev_insn->header.execution_size == val.width &&
+         prev_insn->bits1.da1.dest_reg_file == val.file &&
+         prev_insn->bits1.da1.dest_reg_type == val.type &&
+         prev_insn->bits1.da1.dest_address_mode == val.address_mode &&
+         prev_insn->bits1.da1.dest_reg_nr == val.nr &&
+         prev_insn->bits1.da16.dest_subreg_nr == val.subnr / 16 &&
+         prev_insn->bits1.da16.dest_writemask == 0xf)
+        return GL_TRUE;
+      else
+        return GL_FALSE;
+   default:
+      return GL_FALSE;
+   }
+}
+
 static uint32_t
 get_predicate(const struct prog_instruction *inst)
 {
@@ -1314,6 +1362,7 @@ void brw_vs_emit(struct brw_vs_compile *c )
 #define MAX_LOOP_DEPTH 32
    struct brw_compile *p = &c->func;
    struct brw_context *brw = p->brw;
+   struct intel_context *intel = &brw->intel;
    const GLuint nr_insns = c->vp->program.Base.NumInstructions;
    GLuint insn, if_depth = 0, loop_depth = 0;
    GLuint end_offset = 0;
@@ -1447,9 +1496,13 @@ void brw_vs_emit(struct brw_vs_compile *c )
         unalias3(c, dst, args[0], args[1], args[2], emit_lrp_noalias);
         break;
       case OPCODE_MAD:
-        brw_MOV(p, brw_acc_reg(), args[2]);
+        if (!accumulator_contains(c, args[2]))
+           brw_MOV(p, brw_acc_reg(), args[2]);
         brw_MAC(p, dst, args[0], args[1]);
         break;
+      case OPCODE_CMP:
+        emit_cmp(p, dst, args[0], args[1], args[2]);
+        break;
       case OPCODE_MAX:
         emit_max(p, dst, args[0], args[1]);
         break;
@@ -1473,25 +1526,25 @@ void brw_vs_emit(struct brw_vs_compile *c )
         break;
 
       case OPCODE_SEQ:
-         emit_seq(p, dst, args[0], args[1]);
+         unalias2(c, dst, args[0], args[1], emit_seq);
          break;
       case OPCODE_SIN:
         emit_math1(c, BRW_MATH_FUNCTION_SIN, dst, args[0], BRW_MATH_PRECISION_FULL);
         break;
       case OPCODE_SNE:
-         emit_sne(p, dst, args[0], args[1]);
+         unalias2(c, dst, args[0], args[1], emit_sne);
          break;
       case OPCODE_SGE:
-        emit_sge(p, dst, args[0], args[1]);
+         unalias2(c, dst, args[0], args[1], emit_sge);
         break;
       case OPCODE_SGT:
-         emit_sgt(p, dst, args[0], args[1]);
+         unalias2(c, dst, args[0], args[1], emit_sgt);
          break;
       case OPCODE_SLT:
-        emit_slt(p, dst, args[0], args[1]);
+         unalias2(c, dst, args[0], args[1], emit_slt);
         break;
       case OPCODE_SLE:
-         emit_sle(p, dst, args[0], args[1]);
+         unalias2(c, dst, args[0], args[1], emit_sle);
          break;
       case OPCODE_SUB:
         brw_ADD(p, dst, args[0], negate(args[1]));
@@ -1543,7 +1596,7 @@ void brw_vs_emit(struct brw_vs_compile *c )
 
             loop_depth--;
 
-           if (BRW_IS_IGDNG(brw))
+           if (intel->is_ironlake)
               br = 2;
 
             inst0 = inst1 = brw_WHILE(p, loop_inst[loop_depth]);
index d790ab65553a31295b2691de6f76df924dd54ed4..345ffa7ee11bc1184ff88353c8ad164f6d62c20f 100644 (file)
@@ -82,9 +82,9 @@ vs_unit_populate_key(struct brw_context *brw, struct brw_vs_unit_key *key)
 static dri_bo *
 vs_unit_create_from_key(struct brw_context *brw, struct brw_vs_unit_key *key)
 {
+   struct intel_context *intel = &brw->intel;
    struct brw_vs_unit_state vs;
    dri_bo *bo;
-   int chipset_max_threads;
 
    memset(&vs, 0, sizeof(vs));
 
@@ -98,7 +98,7 @@ vs_unit_create_from_key(struct brw_context *brw, struct brw_vs_unit_key *key)
     */
    vs.thread1.single_program_flow = 0;
 
-   if (BRW_IS_IGDNG(brw))
+   if (intel->is_ironlake)
       vs.thread1.binding_table_entry_count = 0; /* hardware requirement */
    else
       vs.thread1.binding_table_entry_count = key->nr_surfaces;
@@ -109,24 +109,44 @@ vs_unit_create_from_key(struct brw_context *brw, struct brw_vs_unit_key *key)
    vs.thread3.urb_entry_read_offset = 0;
    vs.thread3.const_urb_entry_read_offset = key->curbe_offset * 2;
 
-   if (BRW_IS_IGDNG(brw))
-       vs.thread4.nr_urb_entries = key->nr_urb_entries >> 2;
-   else
-       vs.thread4.nr_urb_entries = key->nr_urb_entries;
+   if (intel->is_ironlake) {
+      switch (key->nr_urb_entries) {
+      case 8:
+      case 12:
+      case 16:
+      case 32:
+      case 64:
+      case 96:
+      case 128:
+      case 168:
+      case 192:
+      case 224:
+      case 256:
+        vs.thread4.nr_urb_entries = key->nr_urb_entries >> 2;
+        break;
+      default:
+        assert(0);
+      }
+   } else {
+      switch (key->nr_urb_entries) {
+      case 8:
+      case 12:
+      case 16:
+      case 32:
+        break;
+      case 64:
+        assert(intel->is_g4x);
+        break;
+      default:
+        assert(0);
+      }
+      vs.thread4.nr_urb_entries = key->nr_urb_entries;
+   }
 
    vs.thread4.urb_entry_allocation_size = key->urb_size - 1;
 
-   if (BRW_IS_IGDNG(brw))
-      chipset_max_threads = 72;
-   else if (BRW_IS_G4X(brw))
-      chipset_max_threads = 32;
-   else
-      chipset_max_threads = 16;
    vs.thread4.max_threads = CLAMP(key->nr_urb_entries / 2,
-                                 1, chipset_max_threads) - 1;
-
-   if (INTEL_DEBUG & DEBUG_SINGLE_THREAD)
-      vs.thread4.max_threads = 0;
+                                 1, brw->vs_max_threads) - 1;
 
    /* No samplers for ARB_vp programs:
     */
index 89f47522a1c173bfd26fb5513a85f8ade0556da2..3bc9840a9719ad1bb59e452f23fb6afc39a3e91f 100644 (file)
@@ -30,7 +30,6 @@
   */
 
 #include "main/mtypes.h"
-#include "main/texformat.h"
 #include "main/texstore.h"
 #include "shader/prog_parameter.h"
 
@@ -53,6 +52,7 @@ brw_vs_update_constant_buffer(struct brw_context *brw)
    const struct gl_program_parameter_list *params = vp->program.Base.Parameters;
    const int size = params->NumParameters * 4 * sizeof(GLfloat);
    drm_intel_bo *const_buffer;
+   int i;
 
    /* BRW_NEW_VERTEX_PROGRAM */
    if (!vp->use_const_buffer)
@@ -62,7 +62,19 @@ brw_vs_update_constant_buffer(struct brw_context *brw)
                                     size, 64);
 
    /* _NEW_PROGRAM_CONSTANTS */
-   dri_bo_subdata(const_buffer, 0, size, params->ParameterValues);
+
+   /* Updates the ParamaterValues[i] pointers for all parameters of the
+    * basic type of PROGRAM_STATE_VAR.
+    */
+   _mesa_load_state_parameters(&brw->intel.ctx, vp->program.Base.Parameters);
+
+   intel_bo_map_gtt_preferred(intel, const_buffer, GL_TRUE);
+   for (i = 0; i < params->NumParameters; i++) {
+      memcpy(const_buffer->virtual + i * 4 * sizeof(float),
+            params->ParameterValues[i],
+            4 * sizeof(float));
+   }
+   intel_bo_unmap_gtt_preferred(intel, const_buffer);
 
    return const_buffer;
 }
index 124fde25fe0cbf731fbbf568e48e48af95b1a052..72749b3859d3a72b8c186caa256339ea7f618597 100644 (file)
@@ -46,7 +46,7 @@
 #include "brw_state.h"
 #include "brw_fallback.h"
 #include "brw_vs.h"
-
+#include "brw_wm.h"
 
 static void
 dri_bo_release(dri_bo **bo)
@@ -66,8 +66,14 @@ static void brw_destroy_context( struct intel_context *intel )
 
    brw_destroy_state(brw);
    brw_draw_destroy( brw );
-
-   _mesa_free(brw->wm.compile_data);
+   brw_clear_validated_bos(brw);
+   if (brw->wm.compile_data) {
+      _mesa_free(brw->wm.compile_data->instruction);
+      _mesa_free(brw->wm.compile_data->vreg);
+      _mesa_free(brw->wm.compile_data->refs);
+      _mesa_free(brw->wm.compile_data->prog_instructions);
+      _mesa_free(brw->wm.compile_data);
+   }
 
    for (i = 0; i < brw->state.nr_color_regions; i++)
       intel_region_release(&brw->state.color_regions[i]);
@@ -144,9 +150,6 @@ static void brw_new_batch( struct intel_context *intel )
 {
    struct brw_context *brw = brw_context(&intel->ctx);
 
-   /* Check that we didn't just wrap our batchbuffer at a bad time. */
-   assert(!brw->no_batch_wrap);
-
    brw->curbe.need_new_bo = GL_TRUE;
 
    /* Mark all context state as needing to be re-emitted.
@@ -175,20 +178,6 @@ static void brw_note_fence( struct intel_context *intel, GLuint fence )
    brw_context(&intel->ctx)->state.dirty.brw |= BRW_NEW_FENCE;
 }
 
-/* called from intelWaitForIdle() and intelFlush()
- *
- * For now, just flush everything.  Could be smarter later.
- */
-static GLuint brw_flush_cmd( void )
-{
-   struct brw_mi_flush flush;
-   flush.opcode = CMD_MI_FLUSH;
-   flush.pad = 0;
-   flush.flags = BRW_FLUSH_STATE_CACHE;
-   return *(GLuint *)&flush;
-}
-
-
 static void brw_invalidate_state( struct intel_context *intel, GLuint new_state )
 {
    /* nothing */
@@ -209,6 +198,5 @@ void brwInitVtbl( struct brw_context *brw )
    brw->intel.vtbl.finish_batch = brw_finish_batch;
    brw->intel.vtbl.destroy = brw_destroy_context;
    brw->intel.vtbl.set_draw_region = brw_set_draw_region;
-   brw->intel.vtbl.flush_cmd = brw_flush_cmd;
    brw->intel.vtbl.debug_batch = brw_debug_batch;
 }
index 2292de94c44e1b872de79bc1293dfaab3963d3c4..6895f644104a6e0be24507fa6447aebbce2c5625 100644 (file)
@@ -29,7 +29,6 @@
   *   Keith Whitwell <keith@tungstengraphics.com>
   */
              
-#include "main/texformat.h"
 #include "brw_context.h"
 #include "brw_util.h"
 #include "brw_wm.h"
@@ -153,8 +152,21 @@ static void do_wm_prog( struct brw_context *brw,
           */
          return;
       }
+      c->instruction = _mesa_calloc(BRW_WM_MAX_INSN * sizeof(*c->instruction));
+      c->prog_instructions = _mesa_calloc(BRW_WM_MAX_INSN *
+                                         sizeof(*c->prog_instructions));
+      c->vreg = _mesa_calloc(BRW_WM_MAX_VREG * sizeof(*c->vreg));
+      c->refs = _mesa_calloc(BRW_WM_MAX_REF * sizeof(*c->refs));
    } else {
+      void *instruction = c->instruction;
+      void *prog_instructions = c->prog_instructions;
+      void *vreg = c->vreg;
+      void *refs = c->refs;
       memset(c, 0, sizeof(*brw->wm.compile_data));
+      c->instruction = instruction;
+      c->prog_instructions = prog_instructions;
+      c->vreg = vreg;
+      c->refs = refs;
    }
    memcpy(&c->key, key, sizeof(*key));
 
@@ -218,7 +230,7 @@ static void brw_wm_populate_key( struct brw_context *brw,
        ctx->Color.AlphaEnabled)
       lookup |= IZ_PS_KILL_ALPHATEST_BIT;
 
-   if (fp->program.Base.OutputsWritten & (1<<FRAG_RESULT_DEPTH))
+   if (fp->program.Base.OutputsWritten & BITFIELD64_BIT(FRAG_RESULT_DEPTH))
       lookup |= IZ_PS_COMPUTES_DEPTH_BIT;
 
    /* _NEW_DEPTH */
@@ -288,7 +300,7 @@ static void brw_wm_populate_key( struct brw_context *brw,
          const struct gl_texture_image *img = t->Image[0][t->BaseLevel];
         if (img->InternalFormat == GL_YCBCR_MESA) {
            key->yuvtex_mask |= 1 << i;
-           if (img->TexFormat->MesaFormat == MESA_FORMAT_YCBCR)
+           if (img->TexFormat == MESA_FORMAT_YCBCR)
                key->yuvtex_swap_mask |= 1 << i;
         }
 
@@ -309,6 +321,9 @@ static void brw_wm_populate_key( struct brw_context *brw,
     * from the incoming screen origin relative position we get as part of our
     * payload.
     *
+    * This is only needed for the WM_WPOSXY opcode when the fragment program
+    * uses the gl_FragCoord input.
+    *
     * We could avoid recompiling by including this as a constant referenced by
     * our program, but if we were to do that it would also be nice to handle
     * getting that constant updated at batchbuffer submit time (when we
@@ -317,17 +332,21 @@ static void brw_wm_populate_key( struct brw_context *brw,
     * just avoid using this as key data if the program doesn't use
     * fragment.position.
     *
-    * This pretty much becomes moot with DRI2 and redirected buffers anyway,
-    * as our origins will always be zero then.
+    * For DRI2 the origin_x/y will always be (0,0) but we still need the
+    * drawable height in order to invert the Y axis.
     */
-   if (brw->intel.driDrawable != NULL) {
-      key->origin_x = brw->intel.driDrawable->x;
-      key->origin_y = brw->intel.driDrawable->y;
-      key->drawable_height = brw->intel.driDrawable->h;
+   if (fp->program.Base.InputsRead & FRAG_BIT_WPOS) {
+      if (brw->intel.driDrawable != NULL) {
+         key->origin_x = brw->intel.driDrawable->x;
+         key->origin_y = brw->intel.driDrawable->y;
+         key->drawable_height = brw->intel.driDrawable->h;
+      }
    }
 
+   key->nr_color_regions = brw->state.nr_color_regions;
+
    /* CACHE_NEW_VS_PROG */
-   key->vp_outputs_written = brw->vs.prog_data->outputs_written & DO_SETUP_BITS;
+   key->vp_outputs_written = brw->vs.prog_data->outputs_written;
 
    /* The unique fragment program ID */
    key->program_string_id = fp->id;
index 872b1f3ecf43c1bab79ecb1b034de3d54686572a..b9b987ea70a987f47da8bc061d832bd59348b7be 100644 (file)
@@ -67,18 +67,19 @@ struct brw_wm_prog_key {
    GLuint flat_shade:1;
    GLuint linear_color:1;  /**< linear interpolation vs perspective interp */
    GLuint runtime_check_aads_emit:1;
+   GLuint nr_color_regions:2;
    
    GLbitfield proj_attrib_mask; /**< one bit per fragment program attribute */
    GLuint shadowtex_mask:16;
    GLuint yuvtex_mask:16;
    GLuint yuvtex_swap_mask:16; /* UV swaped */
 
-   GLuint tex_swizzles[BRW_MAX_TEX_UNIT];
+   GLushort tex_swizzles[BRW_MAX_TEX_UNIT];
 
+   GLushort origin_x, origin_y;
+   GLushort drawable_height;
+   GLbitfield64 vp_outputs_written;
    GLuint program_string_id:32;
-   GLuint origin_x, origin_y;
-   GLuint drawable_height;
-   GLuint vp_outputs_written;
 };
 
 
@@ -153,15 +154,16 @@ struct brw_wm_instruction {
 };
 
 
-#define BRW_WM_MAX_INSN  (MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS*3 + FRAG_ATTRIB_MAX + 3)
+#define BRW_WM_MAX_INSN  (MAX_PROGRAM_INSTRUCTIONS*3 + FRAG_ATTRIB_MAX + 3)
 #define BRW_WM_MAX_GRF   128           /* hardware limit */
 #define BRW_WM_MAX_VREG  (BRW_WM_MAX_INSN * 4)
 #define BRW_WM_MAX_REF   (BRW_WM_MAX_INSN * 12)
 #define BRW_WM_MAX_PARAM 256
 #define BRW_WM_MAX_CONST 256
-#define BRW_WM_MAX_KILLS MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS
 #define BRW_WM_MAX_SUBROUTINE 16
 
+/* used in masks next to WRITEMASK_*. */
+#define SATURATE (1<<5)
 
 
 /* New opcodes to track internal operations required for WM unit.
@@ -200,7 +202,7 @@ struct brw_wm_compile {
     * simplifying and adding instructions for interpolation and
     * framebuffer writes.
     */
-   struct prog_instruction prog_instructions[BRW_WM_MAX_INSN];
+   struct prog_instruction *prog_instructions;
    GLuint nr_fp_insns;
    GLuint fp_temp;
    GLuint fp_interp_emitted;
@@ -211,7 +213,7 @@ struct brw_wm_compile {
    struct prog_src_register pixel_w;
 
 
-   struct brw_wm_value vreg[BRW_WM_MAX_VREG];
+   struct brw_wm_value *vreg;
    GLuint nr_vreg;
 
    struct brw_wm_value creg[BRW_WM_MAX_PARAM];
@@ -228,10 +230,10 @@ struct brw_wm_compile {
    struct brw_wm_ref undef_ref;
    struct brw_wm_value undef_value;
 
-   struct brw_wm_ref refs[BRW_WM_MAX_REF];
+   struct brw_wm_ref *refs;
    GLuint nr_refs;
 
-   struct brw_wm_instruction instruction[BRW_WM_MAX_INSN];
+   struct brw_wm_instruction *instruction;
    GLuint nr_insns;
 
    struct brw_wm_constref constref[BRW_WM_MAX_CONST];
@@ -271,6 +273,12 @@ struct brw_wm_compile {
 };
 
 
+/** Bits for prog_instruction::Aux field */
+#define INST_AUX_EOT      0x1
+#define INST_AUX_TARGET(T)  (T << 1)
+#define INST_AUX_GET_TARGET(AUX) ((AUX) >> 1)
+
+
 GLuint brw_wm_nr_args( GLuint opcode );
 GLuint brw_wm_is_scalar_result( GLuint opcode );
 
@@ -300,10 +308,141 @@ void brw_wm_lookup_iz( GLuint line_aa,
 GLboolean brw_wm_is_glsl(const struct gl_fragment_program *fp);
 void brw_wm_glsl_emit(struct brw_context *brw, struct brw_wm_compile *c);
 
+/* brw_wm_emit.c */
+void emit_alu1(struct brw_compile *p,
+              struct brw_instruction *(*func)(struct brw_compile *,
+                                              struct brw_reg,
+                                              struct brw_reg),
+              const struct brw_reg *dst,
+              GLuint mask,
+              const struct brw_reg *arg0);
+void emit_alu2(struct brw_compile *p,
+              struct brw_instruction *(*func)(struct brw_compile *,
+                                              struct brw_reg,
+                                              struct brw_reg,
+                                              struct brw_reg),
+              const struct brw_reg *dst,
+              GLuint mask,
+              const struct brw_reg *arg0,
+              const struct brw_reg *arg1);
+void emit_cinterp(struct brw_compile *p,
+                 const struct brw_reg *dst,
+                 GLuint mask,
+                 const struct brw_reg *arg0);
 void emit_ddxy(struct brw_compile *p,
               const struct brw_reg *dst,
               GLuint mask,
               GLboolean is_ddx,
               const struct brw_reg *arg0);
+void emit_delta_xy(struct brw_compile *p,
+                  const struct brw_reg *dst,
+                  GLuint mask,
+                  const struct brw_reg *arg0);
+void emit_dp3(struct brw_compile *p,
+             const struct brw_reg *dst,
+             GLuint mask,
+             const struct brw_reg *arg0,
+             const struct brw_reg *arg1);
+void emit_dp4(struct brw_compile *p,
+             const struct brw_reg *dst,
+             GLuint mask,
+             const struct brw_reg *arg0,
+             const struct brw_reg *arg1);
+void emit_dph(struct brw_compile *p,
+             const struct brw_reg *dst,
+             GLuint mask,
+             const struct brw_reg *arg0,
+             const struct brw_reg *arg1);
+void emit_fb_write(struct brw_wm_compile *c,
+                  struct brw_reg *arg0,
+                  struct brw_reg *arg1,
+                  struct brw_reg *arg2,
+                  GLuint target,
+                  GLuint eot);
+void emit_frontfacing(struct brw_compile *p,
+                     const struct brw_reg *dst,
+                     GLuint mask);
+void emit_linterp(struct brw_compile *p,
+                 const struct brw_reg *dst,
+                 GLuint mask,
+                 const struct brw_reg *arg0,
+                 const struct brw_reg *deltas);
+void emit_lrp(struct brw_compile *p,
+             const struct brw_reg *dst,
+             GLuint mask,
+             const struct brw_reg *arg0,
+             const struct brw_reg *arg1,
+             const struct brw_reg *arg2);
+void emit_mad(struct brw_compile *p,
+             const struct brw_reg *dst,
+             GLuint mask,
+             const struct brw_reg *arg0,
+             const struct brw_reg *arg1,
+             const struct brw_reg *arg2);
+void emit_math1(struct brw_wm_compile *c,
+               GLuint function,
+               const struct brw_reg *dst,
+               GLuint mask,
+               const struct brw_reg *arg0);
+void emit_math2(struct brw_wm_compile *c,
+               GLuint function,
+               const struct brw_reg *dst,
+               GLuint mask,
+               const struct brw_reg *arg0,
+               const struct brw_reg *arg1);
+void emit_min(struct brw_compile *p,
+             const struct brw_reg *dst,
+             GLuint mask,
+             const struct brw_reg *arg0,
+             const struct brw_reg *arg1);
+void emit_max(struct brw_compile *p,
+             const struct brw_reg *dst,
+             GLuint mask,
+             const struct brw_reg *arg0,
+             const struct brw_reg *arg1);
+void emit_pinterp(struct brw_compile *p,
+                 const struct brw_reg *dst,
+                 GLuint mask,
+                 const struct brw_reg *arg0,
+                 const struct brw_reg *deltas,
+                 const struct brw_reg *w);
+void emit_pixel_xy(struct brw_wm_compile *c,
+                  const struct brw_reg *dst,
+                  GLuint mask);
+void emit_pixel_w(struct brw_wm_compile *c,
+                 const struct brw_reg *dst,
+                 GLuint mask,
+                 const struct brw_reg *arg0,
+                 const struct brw_reg *deltas);
+void emit_sop(struct brw_compile *p,
+             const struct brw_reg *dst,
+             GLuint mask,
+             GLuint cond,
+             const struct brw_reg *arg0,
+             const struct brw_reg *arg1);
+void emit_tex(struct brw_wm_compile *c,
+             struct brw_reg *dst,
+             GLuint dst_flags,
+             struct brw_reg *arg,
+             struct brw_reg depth_payload,
+             GLuint tex_idx,
+             GLuint sampler,
+             GLboolean shadow);
+void emit_txb(struct brw_wm_compile *c,
+             struct brw_reg *dst,
+             GLuint dst_flags,
+             struct brw_reg *arg,
+             struct brw_reg depth_payload,
+             GLuint tex_idx,
+             GLuint sampler);
+void emit_wpos_xy(struct brw_wm_compile *c,
+                 const struct brw_reg *dst,
+                 GLuint mask,
+                 const struct brw_reg *arg0);
+void emit_xpd(struct brw_compile *p,
+             const struct brw_reg *dst,
+             GLuint mask,
+             const struct brw_reg *arg0,
+             const struct brw_reg *arg1);
 
 #endif
index bf80a2942a42ba858f5ae8d84fcbdf6d982270fa..cc1052f757c55138813209e4a86e59260084f914 100644 (file)
@@ -44,6 +44,7 @@ static INLINE struct brw_reg sechalf( struct brw_reg reg )
    return reg;
 }
 
+
 /* Payload R0:
  *
  * R0.0 -- pixel mask, one bit for each of 4 pixels in 4 tiles,
@@ -60,42 +61,50 @@ static INLINE struct brw_reg sechalf( struct brw_reg reg )
  * R1.8 -- ?
  */
 
-
-static void emit_pixel_xy(struct brw_compile *p,
-                         const struct brw_reg *dst,
-                         GLuint mask)
+void emit_pixel_xy(struct brw_wm_compile *c,
+                  const struct brw_reg *dst,
+                  GLuint mask)
 {
+   struct brw_compile *p = &c->func;
    struct brw_reg r1 = brw_vec1_grf(1, 0);
    struct brw_reg r1_uw = retype(r1, BRW_REGISTER_TYPE_UW);
+   struct brw_reg dst0_uw, dst1_uw;
 
+   brw_push_insn_state(p);
    brw_set_compression_control(p, BRW_COMPRESSION_NONE);
 
+   if (c->dispatch_width == 16) {
+      dst0_uw = vec16(retype(dst[0], BRW_REGISTER_TYPE_UW));
+      dst1_uw = vec16(retype(dst[1], BRW_REGISTER_TYPE_UW));
+   } else {
+      dst0_uw = vec8(retype(dst[0], BRW_REGISTER_TYPE_UW));
+      dst1_uw = vec8(retype(dst[1], BRW_REGISTER_TYPE_UW));
+   }
+
    /* Calculate pixel centers by adding 1 or 0 to each of the
     * micro-tile coordinates passed in r1.
     */
    if (mask & WRITEMASK_X) {
       brw_ADD(p,
-             vec16(retype(dst[0], BRW_REGISTER_TYPE_UW)),
+             dst0_uw,
              stride(suboffset(r1_uw, 4), 2, 4, 0),
              brw_imm_v(0x10101010));
    }
 
    if (mask & WRITEMASK_Y) {
       brw_ADD(p,
-             vec16(retype(dst[1], BRW_REGISTER_TYPE_UW)),
+             dst1_uw,
              stride(suboffset(r1_uw,5), 2, 4, 0),
              brw_imm_v(0x11001100));
    }
-
-   brw_set_compression_control(p, BRW_COMPRESSION_COMPRESSED);
+   brw_pop_insn_state(p);
 }
 
 
-
-static void emit_delta_xy(struct brw_compile *p,
-                         const struct brw_reg *dst,
-                         GLuint mask,
-                         const struct brw_reg *arg0)
+void emit_delta_xy(struct brw_compile *p,
+                  const struct brw_reg *dst,
+                  GLuint mask,
+                  const struct brw_reg *arg0)
 {
    struct brw_reg r1 = brw_vec1_grf(1, 0);
 
@@ -118,10 +127,10 @@ static void emit_delta_xy(struct brw_compile *p,
    }
 }
 
-static void emit_wpos_xy(struct brw_wm_compile *c,
-                        const struct brw_reg *dst,
-                        GLuint mask,
-                        const struct brw_reg *arg0)
+void emit_wpos_xy(struct brw_wm_compile *c,
+                 const struct brw_reg *dst,
+                 GLuint mask,
+                 const struct brw_reg *arg0)
 {
    struct brw_compile *p = &c->func;
 
@@ -146,12 +155,14 @@ static void emit_wpos_xy(struct brw_wm_compile *c,
 }
 
 
-static void emit_pixel_w( struct brw_compile *p,
-                         const struct brw_reg *dst,
-                         GLuint mask,
-                         const struct brw_reg *arg0,
-                         const struct brw_reg *deltas)
+void emit_pixel_w(struct brw_wm_compile *c,
+                 const struct brw_reg *dst,
+                 GLuint mask,
+                 const struct brw_reg *arg0,
+                 const struct brw_reg *deltas)
 {
+   struct brw_compile *p = &c->func;
+
    /* Don't need this if all you are doing is interpolating color, for
     * instance.
     */
@@ -165,21 +176,29 @@ static void emit_pixel_w( struct brw_compile *p,
       brw_MAC(p, brw_message_reg(2), suboffset(interp3, 1), deltas[1]);
 
       /* Calc w */
-      brw_math_16( p, dst[3],
-                  BRW_MATH_FUNCTION_INV,
-                  BRW_MATH_SATURATE_NONE,
-                  2, brw_null_reg(),
-                  BRW_MATH_PRECISION_FULL);
+      if (c->dispatch_width == 16) {
+        brw_math_16(p, dst[3],
+                    BRW_MATH_FUNCTION_INV,
+                    BRW_MATH_SATURATE_NONE,
+                    2, brw_null_reg(),
+                    BRW_MATH_PRECISION_FULL);
+      } else {
+        brw_math(p, dst[3],
+                 BRW_MATH_FUNCTION_INV,
+                 BRW_MATH_SATURATE_NONE,
+                 2, brw_null_reg(),
+                 BRW_MATH_DATA_VECTOR,
+                 BRW_MATH_PRECISION_FULL);
+      }
    }
 }
 
 
-
-static void emit_linterp( struct brw_compile *p, 
-                        const struct brw_reg *dst,
-                        GLuint mask,
-                        const struct brw_reg *arg0,
-                        const struct brw_reg *deltas )
+void emit_linterp(struct brw_compile *p,
+                 const struct brw_reg *dst,
+                 GLuint mask,
+                 const struct brw_reg *arg0,
+                 const struct brw_reg *deltas)
 {
    struct brw_reg interp[4];
    GLuint nr = arg0[0].nr;
@@ -199,12 +218,12 @@ static void emit_linterp( struct brw_compile *p,
 }
 
 
-static void emit_pinterp( struct brw_compile *p, 
-                         const struct brw_reg *dst,
-                         GLuint mask,
-                         const struct brw_reg *arg0,
-                         const struct brw_reg *deltas,
-                         const struct brw_reg *w)
+void emit_pinterp(struct brw_compile *p,
+                 const struct brw_reg *dst,
+                 GLuint mask,
+                 const struct brw_reg *arg0,
+                 const struct brw_reg *deltas,
+                 const struct brw_reg *w)
 {
    struct brw_reg interp[4];
    GLuint nr = arg0[0].nr;
@@ -229,10 +248,10 @@ static void emit_pinterp( struct brw_compile *p,
 }
 
 
-static void emit_cinterp( struct brw_compile *p, 
-                        const struct brw_reg *dst,
-                        GLuint mask,
-                        const struct brw_reg *arg0 )
+void emit_cinterp(struct brw_compile *p,
+                 const struct brw_reg *dst,
+                 GLuint mask,
+                 const struct brw_reg *arg0)
 {
    struct brw_reg interp[4];
    GLuint nr = arg0[0].nr;
@@ -251,9 +270,9 @@ static void emit_cinterp( struct brw_compile *p,
 }
 
 /* Sets the destination channels to 1.0 or 0.0 according to glFrontFacing. */
-static void emit_frontfacing( struct brw_compile *p,
-                             const struct brw_reg *dst,
-                             GLuint mask )
+void emit_frontfacing(struct brw_compile *p,
+                     const struct brw_reg *dst,
+                     GLuint mask)
 {
    struct brw_reg r1_6ud = retype(brw_vec1_grf(1, 6), BRW_REGISTER_TYPE_UD);
    GLuint i;
@@ -352,13 +371,13 @@ void emit_ddxy(struct brw_compile *p,
       brw_set_saturate(p, 0);
 }
 
-static void emit_alu1( struct brw_compile *p, 
-                      struct brw_instruction *(*func)(struct brw_compile *, 
-                                                      struct brw_reg, 
-                                                      struct brw_reg),
-                      const struct brw_reg *dst,
-                      GLuint mask,
-                      const struct brw_reg *arg0 )
+void emit_alu1(struct brw_compile *p,
+              struct brw_instruction *(*func)(struct brw_compile *,
+                                              struct brw_reg,
+                                              struct brw_reg),
+              const struct brw_reg *dst,
+              GLuint mask,
+              const struct brw_reg *arg0)
 {
    GLuint i;
 
@@ -376,15 +395,15 @@ static void emit_alu1( struct brw_compile *p,
 }
 
 
-static void emit_alu2( struct brw_compile *p, 
-                      struct brw_instruction *(*func)(struct brw_compile *, 
-                                                      struct brw_reg, 
-                                                      struct brw_reg, 
-                                                      struct brw_reg),
-                      const struct brw_reg *dst,
-                      GLuint mask,
-                      const struct brw_reg *arg0,
-                      const struct brw_reg *arg1 )
+void emit_alu2(struct brw_compile *p,
+              struct brw_instruction *(*func)(struct brw_compile *,
+                                              struct brw_reg,
+                                              struct brw_reg,
+                                              struct brw_reg),
+              const struct brw_reg *dst,
+              GLuint mask,
+              const struct brw_reg *arg0,
+              const struct brw_reg *arg1)
 {
    GLuint i;
 
@@ -402,12 +421,12 @@ static void emit_alu2( struct brw_compile *p,
 }
 
 
-static void emit_mad( struct brw_compile *p, 
-                     const struct brw_reg *dst,
-                     GLuint mask,
-                     const struct brw_reg *arg0,
-                     const struct brw_reg *arg1,
-                     const struct brw_reg *arg2 )
+void emit_mad(struct brw_compile *p,
+             const struct brw_reg *dst,
+             GLuint mask,
+             const struct brw_reg *arg0,
+             const struct brw_reg *arg1,
+             const struct brw_reg *arg2)
 {
    GLuint i;
 
@@ -422,26 +441,12 @@ 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,
-                     GLuint mask,
-                     const struct brw_reg *arg0,
-                     const struct brw_reg *arg1,
-                     const struct brw_reg *arg2 )
+void emit_lrp(struct brw_compile *p,
+             const struct brw_reg *dst,
+             GLuint mask,
+             const struct brw_reg *arg0,
+             const struct brw_reg *arg1,
+             const struct brw_reg *arg2)
 {
    GLuint i;
 
@@ -461,21 +466,24 @@ static void emit_lrp( struct brw_compile *p,
    }
 }
 
-static void emit_sop( struct brw_compile *p, 
-                     const struct brw_reg *dst,
-                     GLuint mask,
-                     GLuint cond,
-                     const struct brw_reg *arg0,
-                     const struct brw_reg *arg1 )
+void emit_sop(struct brw_compile *p,
+             const struct brw_reg *dst,
+             GLuint mask,
+             GLuint cond,
+             const struct brw_reg *arg0,
+             const struct brw_reg *arg1)
 {
    GLuint i;
 
    for (i = 0; i < 4; i++) {
       if (mask & (1<<i)) {     
-        brw_MOV(p, dst[i], brw_imm_f(0));
+        brw_push_insn_state(p);
         brw_CMP(p, brw_null_reg(), cond, arg0[i], arg1[i]);
+        brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+        brw_MOV(p, dst[i], brw_imm_f(0));
+        brw_set_predicate_control(p, BRW_PREDICATE_NORMAL);
         brw_MOV(p, dst[i], brw_imm_f(1.0));
-        brw_set_predicate_control_flag_value(p, 0xff);
+        brw_pop_insn_state(p);
       }
    }
 }
@@ -559,11 +567,11 @@ static void emit_cmp( struct brw_compile *p,
    }
 }
 
-static void emit_max( struct brw_compile *p, 
-                     const struct brw_reg *dst,
-                     GLuint mask,
-                     const struct brw_reg *arg0,
-                     const struct brw_reg *arg1 )
+void emit_max(struct brw_compile *p,
+             const struct brw_reg *dst,
+             GLuint mask,
+             const struct brw_reg *arg0,
+             const struct brw_reg *arg1)
 {
    GLuint i;
 
@@ -583,11 +591,11 @@ static void emit_max( struct brw_compile *p,
    }
 }
 
-static void emit_min( struct brw_compile *p, 
-                     const struct brw_reg *dst,
-                     GLuint mask,
-                     const struct brw_reg *arg0,
-                     const struct brw_reg *arg1 )
+void emit_min(struct brw_compile *p,
+             const struct brw_reg *dst,
+             GLuint mask,
+             const struct brw_reg *arg0,
+             const struct brw_reg *arg1)
 {
    GLuint i;
 
@@ -608,11 +616,11 @@ static void emit_min( struct brw_compile *p,
 }
 
 
-static void emit_dp3( struct brw_compile *p, 
-                     const struct brw_reg *dst,
-                     GLuint mask,
-                     const struct brw_reg *arg0,
-                     const struct brw_reg *arg1 )
+void emit_dp3(struct brw_compile *p,
+             const struct brw_reg *dst,
+             GLuint mask,
+             const struct brw_reg *arg0,
+             const struct brw_reg *arg1)
 {
    int dst_chan = _mesa_ffs(mask & WRITEMASK_XYZW) - 1;
 
@@ -630,11 +638,11 @@ static void emit_dp3( struct brw_compile *p,
 }
 
 
-static void emit_dp4( struct brw_compile *p, 
-                     const struct brw_reg *dst,
-                     GLuint mask,
-                     const struct brw_reg *arg0,
-                     const struct brw_reg *arg1 )
+void emit_dp4(struct brw_compile *p,
+             const struct brw_reg *dst,
+             GLuint mask,
+             const struct brw_reg *arg0,
+             const struct brw_reg *arg1)
 {
    int dst_chan = _mesa_ffs(mask & WRITEMASK_XYZW) - 1;
 
@@ -653,11 +661,11 @@ static void emit_dp4( struct brw_compile *p,
 }
 
 
-static void emit_dph( struct brw_compile *p, 
-                     const struct brw_reg *dst,
-                     GLuint mask,
-                     const struct brw_reg *arg0,
-                     const struct brw_reg *arg1 )
+void emit_dph(struct brw_compile *p,
+             const struct brw_reg *dst,
+             GLuint mask,
+             const struct brw_reg *arg0,
+             const struct brw_reg *arg1)
 {
    const int dst_chan = _mesa_ffs(mask & WRITEMASK_XYZW) - 1;
 
@@ -676,11 +684,11 @@ static void emit_dph( struct brw_compile *p,
 }
 
 
-static void emit_xpd( struct brw_compile *p, 
-                     const struct brw_reg *dst,
-                     GLuint mask,
-                     const struct brw_reg *arg0,
-                     const struct brw_reg *arg1 )
+void emit_xpd(struct brw_compile *p,
+             const struct brw_reg *dst,
+             GLuint mask,
+             const struct brw_reg *arg0,
+             const struct brw_reg *arg1)
 {
    GLuint i;
 
@@ -701,41 +709,68 @@ static void emit_xpd( struct brw_compile *p,
 }
 
 
-static void emit_math1( struct brw_compile *p, 
-                       GLuint function,
-                       const struct brw_reg *dst,
-                       GLuint mask,
-                       const struct brw_reg *arg0 )
+void emit_math1(struct brw_wm_compile *c,
+               GLuint function,
+               const struct brw_reg *dst,
+               GLuint mask,
+               const struct brw_reg *arg0)
 {
+   struct brw_compile *p = &c->func;
    int dst_chan = _mesa_ffs(mask & WRITEMASK_XYZW) - 1;
+   GLuint saturate = ((mask & SATURATE) ?
+                     BRW_MATH_SATURATE_SATURATE :
+                     BRW_MATH_SATURATE_NONE);
 
    if (!(mask & WRITEMASK_XYZW))
       return; /* Do not emit dead code */
 
    assert(is_power_of_two(mask & WRITEMASK_XYZW));
 
+   /* If compressed, this will write message reg 2,3 from arg0.x's 16
+    * channels.
+    */
    brw_MOV(p, brw_message_reg(2), arg0[0]);
 
    /* Send two messages to perform all 16 operations:
     */
-   brw_math_16(p, 
-              dst[dst_chan],
+   brw_push_insn_state(p);
+   brw_set_compression_control(p, BRW_COMPRESSION_NONE);
+   brw_math(p,
+           dst[dst_chan],
+           function,
+           saturate,
+           2,
+           brw_null_reg(),
+           BRW_MATH_DATA_VECTOR,
+           BRW_MATH_PRECISION_FULL);
+
+   if (c->dispatch_width == 16) {
+      brw_set_compression_control(p, BRW_COMPRESSION_2NDHALF);
+      brw_math(p,
+              offset(dst[dst_chan],1),
               function,
-              (mask & SATURATE) ? BRW_MATH_SATURATE_SATURATE : BRW_MATH_SATURATE_NONE,
-              2,
+              saturate,
+              3,
               brw_null_reg(),
+              BRW_MATH_DATA_VECTOR,
               BRW_MATH_PRECISION_FULL);
+   }
+   brw_pop_insn_state(p);
 }
 
 
-static void emit_math2( struct brw_compile *p, 
-                       GLuint function,
-                       const struct brw_reg *dst,
-                       GLuint mask,
-                       const struct brw_reg *arg0,
-                       const struct brw_reg *arg1)
+void emit_math2(struct brw_wm_compile *c,
+               GLuint function,
+               const struct brw_reg *dst,
+               GLuint mask,
+               const struct brw_reg *arg0,
+               const struct brw_reg *arg1)
 {
+   struct brw_compile *p = &c->func;
    int dst_chan = _mesa_ffs(mask & WRITEMASK_XYZW) - 1;
+   GLuint saturate = ((mask & SATURATE) ?
+                     BRW_MATH_SATURATE_SATURATE :
+                     BRW_MATH_SATURATE_NONE);
 
    if (!(mask & WRITEMASK_XYZW))
       return; /* Do not emit dead code */
@@ -746,173 +781,233 @@ static void emit_math2( struct brw_compile *p,
 
    brw_set_compression_control(p, BRW_COMPRESSION_NONE);
    brw_MOV(p, brw_message_reg(2), arg0[0]);
-   brw_set_compression_control(p, BRW_COMPRESSION_2NDHALF);
-   brw_MOV(p, brw_message_reg(4), sechalf(arg0[0]));
+   if (c->dispatch_width == 16) {
+      brw_set_compression_control(p, BRW_COMPRESSION_2NDHALF);
+      brw_MOV(p, brw_message_reg(4), sechalf(arg0[0]));
+   }
 
    brw_set_compression_control(p, BRW_COMPRESSION_NONE);
    brw_MOV(p, brw_message_reg(3), arg1[0]);
-   brw_set_compression_control(p, BRW_COMPRESSION_2NDHALF);
-   brw_MOV(p, brw_message_reg(5), sechalf(arg1[0]));
+   if (c->dispatch_width == 16) {
+      brw_set_compression_control(p, BRW_COMPRESSION_2NDHALF);
+      brw_MOV(p, brw_message_reg(5), sechalf(arg1[0]));
+   }
 
-   
-   /* Send two messages to perform all 16 operations:
-    */
    brw_set_compression_control(p, BRW_COMPRESSION_NONE);
    brw_math(p, 
            dst[dst_chan],
            function,
-           (mask & SATURATE) ? BRW_MATH_SATURATE_SATURATE : BRW_MATH_SATURATE_NONE,
+           saturate,
            2,
            brw_null_reg(),
            BRW_MATH_DATA_VECTOR,
            BRW_MATH_PRECISION_FULL);
 
-   brw_set_compression_control(p, BRW_COMPRESSION_2NDHALF);
-   brw_math(p, 
-           offset(dst[dst_chan],1),
-           function,
-           (mask & SATURATE) ? BRW_MATH_SATURATE_SATURATE : BRW_MATH_SATURATE_NONE,
-           4,
-           brw_null_reg(),
-           BRW_MATH_DATA_VECTOR,
-           BRW_MATH_PRECISION_FULL);
-   
+   /* Send two messages to perform all 16 operations:
+    */
+   if (c->dispatch_width == 16) {
+      brw_set_compression_control(p, BRW_COMPRESSION_2NDHALF);
+      brw_math(p,
+              offset(dst[dst_chan],1),
+              function,
+              saturate,
+              4,
+              brw_null_reg(),
+              BRW_MATH_DATA_VECTOR,
+              BRW_MATH_PRECISION_FULL);
+   }
    brw_pop_insn_state(p);
 }
-                    
 
 
-static void emit_tex( struct brw_wm_compile *c,
-                     const struct brw_wm_instruction *inst,
-                     struct brw_reg *dst,
-                     GLuint dst_flags,
-                     struct brw_reg *arg )
+void emit_tex(struct brw_wm_compile *c,
+             struct brw_reg *dst,
+             GLuint dst_flags,
+             struct brw_reg *arg,
+             struct brw_reg depth_payload,
+             GLuint tex_idx,
+             GLuint sampler,
+             GLboolean shadow)
 {
    struct brw_compile *p = &c->func;
-   GLuint msgLength, responseLength;
-   GLuint i, nr;
+   struct intel_context *intel = &p->brw->intel;
+   struct brw_reg dst_retyped;
+   GLuint cur_mrf = 2, response_length;
+   GLuint i, nr_texcoords;
    GLuint emit;
    GLuint msg_type;
+   GLuint mrf_per_channel;
+   GLuint simd_mode;
+
+   if (c->dispatch_width == 16) {
+      mrf_per_channel = 2;
+      response_length = 8;
+      dst_retyped = retype(vec16(dst[0]), BRW_REGISTER_TYPE_UW);
+      simd_mode = BRW_SAMPLER_SIMD_MODE_SIMD16;
+   } else {
+      mrf_per_channel = 1;
+      response_length = 4;
+      dst_retyped = retype(vec8(dst[0]), BRW_REGISTER_TYPE_UW);
+      simd_mode = BRW_SAMPLER_SIMD_MODE_SIMD8;
+   }
 
    /* How many input regs are there?
     */
-   switch (inst->tex_idx) {
+   switch (tex_idx) {
    case TEXTURE_1D_INDEX:
       emit = WRITEMASK_X;
-      nr = 1;
+      nr_texcoords = 1;
       break;
    case TEXTURE_2D_INDEX:
    case TEXTURE_RECT_INDEX:
       emit = WRITEMASK_XY;
-      nr = 2;
+      nr_texcoords = 2;
       break;
    case TEXTURE_3D_INDEX:
    case TEXTURE_CUBE_INDEX:
       emit = WRITEMASK_XYZ;
-      nr = 3;
+      nr_texcoords = 3;
       break;
    default:
       /* unexpected target */
       abort();
    }
 
-   if (inst->tex_shadow) {
-      nr = 4;
-      emit |= WRITEMASK_W;
-   }
+   /* Pre-Ironlake, the 8-wide sampler always took u,v,r. */
+   if (!intel->is_ironlake && c->dispatch_width == 8)
+      nr_texcoords = 3;
 
-   msgLength = 1;
+   /* For shadow comparisons, we have to supply u,v,r. */
+   if (shadow)
+      nr_texcoords = 3;
 
-   for (i = 0; i < nr; i++) {
-      static const GLuint swz[4] = {0,1,2,2};
-      if (emit & (1<<i)) 
-        brw_MOV(p, brw_message_reg(msgLength+1), arg[swz[i]]);
+   /* Emit the texcoords. */
+   for (i = 0; i < nr_texcoords; i++) {
+      if (emit & (1<<i))
+        brw_MOV(p, brw_message_reg(cur_mrf), arg[i]);
       else
-        brw_MOV(p, brw_message_reg(msgLength+1), brw_imm_f(0));
-      msgLength += 2;
+        brw_MOV(p, brw_message_reg(cur_mrf), brw_imm_f(0));
+      cur_mrf += mrf_per_channel;
    }
 
-   responseLength = 8;         /* always */
+   /* Fill in the shadow comparison reference value. */
+   if (shadow) {
+      if (intel->is_ironlake) {
+        /* Fill in the cube map array index value. */
+        brw_MOV(p, brw_message_reg(cur_mrf), brw_imm_f(0));
+        cur_mrf += mrf_per_channel;
+      } else if (c->dispatch_width == 8) {
+        /* Fill in the LOD bias value. */
+        brw_MOV(p, brw_message_reg(cur_mrf), brw_imm_f(0));
+        cur_mrf += mrf_per_channel;
+      }
+      brw_MOV(p, brw_message_reg(cur_mrf), arg[2]);
+      cur_mrf += mrf_per_channel;
+   }
 
-   if (BRW_IS_IGDNG(p->brw)) {
-       if (inst->tex_shadow)
-           msg_type = BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_COMPARE_IGDNG;
-       else
-           msg_type = BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_IGDNG;
+   if (intel->is_ironlake) {
+      if (shadow)
+        msg_type = BRW_SAMPLER_MESSAGE_SAMPLE_COMPARE_IGDNG;
+      else
+        msg_type = BRW_SAMPLER_MESSAGE_SAMPLE_IGDNG;
    } else {
-       if (inst->tex_shadow)
-           msg_type = BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_COMPARE;
-       else
-           msg_type = BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE;
+      /* Note that G45 and older determines shadow compare and dispatch width
+       * from message length for most messages.
+       */
+      if (c->dispatch_width == 16 && shadow)
+        msg_type = BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_COMPARE;
+      else
+        msg_type = BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE;
    }
 
-   brw_SAMPLE(p, 
-             retype(vec16(dst[0]), BRW_REGISTER_TYPE_UW),
+   brw_SAMPLE(p,
+             dst_retyped,
              1,
-             retype(c->payload.depth[0].hw_reg, BRW_REGISTER_TYPE_UW),
-              SURF_INDEX_TEXTURE(inst->tex_unit),
-             inst->tex_unit,     /* sampler */
-             inst->writemask,
-             msg_type, 
-             responseLength,
-             msgLength,
-             0,        
+             retype(depth_payload, BRW_REGISTER_TYPE_UW),
+              SURF_INDEX_TEXTURE(sampler),
+             sampler,
+             dst_flags & WRITEMASK_XYZW,
+             msg_type,
+             response_length,
+             cur_mrf - 1,
+             0,
              1,
-             BRW_SAMPLER_SIMD_MODE_SIMD16);    
+             simd_mode);
 }
 
 
-static void emit_txb( struct brw_wm_compile *c,
-                     const struct brw_wm_instruction *inst,
-                     struct brw_reg *dst,
-                     GLuint dst_flags,
-                     struct brw_reg *arg )
+void emit_txb(struct brw_wm_compile *c,
+             struct brw_reg *dst,
+             GLuint dst_flags,
+             struct brw_reg *arg,
+             struct brw_reg depth_payload,
+             GLuint tex_idx,
+             GLuint sampler)
 {
    struct brw_compile *p = &c->func;
+   struct intel_context *intel = &p->brw->intel;
    GLuint msgLength;
    GLuint msg_type;
-   /* Shadow ignored for txb.
+   GLuint mrf_per_channel;
+   GLuint response_length;
+   struct brw_reg dst_retyped;
+
+   /* The G45 and older chipsets don't support 8-wide dispatch for LOD biased
+    * samples, so we'll use the 16-wide instruction, leave the second halves
+    * undefined, and trust the execution mask to keep the undefined pixels
+    * from mattering.
     */
-   switch (inst->tex_idx) {
+   if (c->dispatch_width == 16 || !intel->is_ironlake) {
+      if (intel->is_ironlake)
+        msg_type = BRW_SAMPLER_MESSAGE_SAMPLE_BIAS_IGDNG;
+      else
+        msg_type = BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_BIAS;
+      mrf_per_channel = 2;
+      dst_retyped = retype(vec16(dst[0]), BRW_REGISTER_TYPE_UW);
+      response_length = 8;
+   } else {
+      msg_type = BRW_SAMPLER_MESSAGE_SAMPLE_BIAS_IGDNG;
+      mrf_per_channel = 1;
+      dst_retyped = retype(vec8(dst[0]), BRW_REGISTER_TYPE_UW);
+      response_length = 4;
+   }
+
+   /* Shadow ignored for txb. */
+   switch (tex_idx) {
    case TEXTURE_1D_INDEX:
-      brw_MOV(p, brw_message_reg(2), arg[0]);
-      brw_MOV(p, brw_message_reg(4), brw_imm_f(0));
-      brw_MOV(p, brw_message_reg(6), brw_imm_f(0));
+      brw_MOV(p, brw_message_reg(2 + 0 * mrf_per_channel), arg[0]);
+      brw_MOV(p, brw_message_reg(2 + 1 * mrf_per_channel), brw_imm_f(0));
+      brw_MOV(p, brw_message_reg(2 + 2 * mrf_per_channel), brw_imm_f(0));
       break;
    case TEXTURE_2D_INDEX:
    case TEXTURE_RECT_INDEX:
-      brw_MOV(p, brw_message_reg(2), arg[0]);
-      brw_MOV(p, brw_message_reg(4), arg[1]);
-      brw_MOV(p, brw_message_reg(6), brw_imm_f(0));
+      brw_MOV(p, brw_message_reg(2 + 0 * mrf_per_channel), arg[0]);
+      brw_MOV(p, brw_message_reg(2 + 1 * mrf_per_channel), arg[1]);
+      brw_MOV(p, brw_message_reg(2 + 2 * mrf_per_channel), brw_imm_f(0));
       break;
    case TEXTURE_3D_INDEX:
    case TEXTURE_CUBE_INDEX:
-      brw_MOV(p, brw_message_reg(2), arg[0]);
-      brw_MOV(p, brw_message_reg(4), arg[1]);
-      brw_MOV(p, brw_message_reg(6), arg[2]);
+      brw_MOV(p, brw_message_reg(2 + 0 * mrf_per_channel), arg[0]);
+      brw_MOV(p, brw_message_reg(2 + 1 * mrf_per_channel), arg[1]);
+      brw_MOV(p, brw_message_reg(2 + 2 * mrf_per_channel), arg[2]);
       break;
    default:
       /* unexpected target */
       abort();
    }
 
-   brw_MOV(p, brw_message_reg(8), arg[3]);
-   msgLength = 9;
-
-   if (BRW_IS_IGDNG(p->brw))
-       msg_type = BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_BIAS_IGDNG;
-   else
-       msg_type = BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_BIAS;
+   brw_MOV(p, brw_message_reg(2 + 3 * mrf_per_channel), arg[3]);
+   msgLength = 2 + 4 * mrf_per_channel - 1;
 
    brw_SAMPLE(p, 
-             retype(vec16(dst[0]), BRW_REGISTER_TYPE_UW),
+             dst_retyped,
              1,
-             retype(c->payload.depth[0].hw_reg, BRW_REGISTER_TYPE_UW),
-              SURF_INDEX_TEXTURE(inst->tex_unit),
-             inst->tex_unit,     /* sampler */
-             inst->writemask,
+             retype(depth_payload, BRW_REGISTER_TYPE_UW),
+              SURF_INDEX_TEXTURE(sampler),
+             sampler,
+             dst_flags & WRITEMASK_XYZW,
              msg_type,
-             8,                /* responseLength */
+             response_length,
              msgLength,
              0,        
              1,
@@ -920,11 +1015,13 @@ static void emit_txb( struct brw_wm_compile *c,
 }
 
 
-static void emit_lit( struct brw_compile *p, 
-                     const struct brw_reg *dst,
-                     GLuint mask,
-                     const struct brw_reg *arg0 )
+static void emit_lit(struct brw_wm_compile *c,
+                    const struct brw_reg *dst,
+                    GLuint mask,
+                    const struct brw_reg *arg0)
 {
+   struct brw_compile *p = &c->func;
+
    assert((mask & WRITEMASK_XW) == 0);
 
    if (mask & WRITEMASK_Y) {
@@ -934,7 +1031,7 @@ static void emit_lit( struct brw_compile *p,
    }
 
    if (mask & WRITEMASK_Z) {
-      emit_math2(p, BRW_MATH_FUNCTION_POW,
+      emit_math2(c, BRW_MATH_FUNCTION_POW,
                 &dst[2],
                 WRITEMASK_X | (mask & SATURATE),
                 &arg0[1],
@@ -989,7 +1086,7 @@ static void emit_kil_nv( struct brw_wm_compile *c )
 
    brw_push_insn_state(p);
    brw_set_mask_control(p, BRW_MASK_DISABLE);
-   brw_NOT(p, c->emit_mask_reg, brw_mask_reg(1)); //IMASK
+   brw_NOT(p, c->emit_mask_reg, brw_mask_reg(1)); /* IMASK */
    brw_AND(p, r0uw, c->emit_mask_reg, r0uw);
    brw_pop_insn_state(p);
 }
@@ -1001,7 +1098,13 @@ static void fire_fb_write( struct brw_wm_compile *c,
                           GLuint eot )
 {
    struct brw_compile *p = &c->func;
-   
+   struct brw_reg dst;
+
+   if (c->dispatch_width == 16)
+      dst = retype(vec16(brw_null_reg()), BRW_REGISTER_TYPE_UW);
+   else
+      dst = retype(vec8(brw_null_reg()), BRW_REGISTER_TYPE_UW);
+
    /* Pass through control information:
     */
 /*  mov (8) m1.0<1>:ud   r1.0<8;8,1>:ud   { Align1 NoMask } */
@@ -1018,7 +1121,7 @@ static void fire_fb_write( struct brw_wm_compile *c,
    /* Send framebuffer write message: */
 /*  send (16) null.0<1>:uw m0               r0.0<8;8,1>:uw   0x85a04000:ud    { Align1 EOT } */
    brw_fb_WRITE(p,
-               retype(vec16(brw_null_reg()), BRW_REGISTER_TYPE_UW),
+               dst,
                base_reg,
                retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UW),
                target,         
@@ -1050,14 +1153,15 @@ static void emit_aa( struct brw_wm_compile *c,
  * \param arg1  the pass-through depth value
  * \param arg2  the shader-computed depth value
  */
-static void emit_fb_write( struct brw_wm_compile *c,
-                          struct brw_reg *arg0,
-                          struct brw_reg *arg1,
-                          struct brw_reg *arg2,
-                          GLuint target,
-                          GLuint eot)
+void emit_fb_write(struct brw_wm_compile *c,
+                  struct brw_reg *arg0,
+                  struct brw_reg *arg1,
+                  struct brw_reg *arg2,
+                  GLuint target,
+                  GLuint eot)
 {
    struct brw_compile *p = &c->func;
+   struct brw_context *brw = p->brw;
    GLuint nr = 2;
    GLuint channel;
 
@@ -1069,30 +1173,37 @@ static void emit_fb_write( struct brw_wm_compile *c,
    /* I don't really understand how this achieves the color interleave
     * (ie RGBARGBA) in the result:  [Do the saturation here]
     */
-   {
-      brw_push_insn_state(p);
-      
-      for (channel = 0; channel < 4; channel++) {
+   brw_push_insn_state(p);
+
+   for (channel = 0; channel < 4; channel++) {
+      if (c->dispatch_width == 16 && brw->has_compr4) {
+        /* By setting the high bit of the MRF register number, we indicate
+         * that we want COMPR4 mode - instead of doing the usual destination
+         * + 1 for the second half we get destination + 4.
+         */
+        brw_MOV(p,
+                brw_message_reg(nr + channel + (1 << 7)),
+                arg0[channel]);
+      } else {
         /*  mov (8) m2.0<1>:ud   r28.0<8;8,1>:ud  { Align1 } */
         /*  mov (8) m6.0<1>:ud   r29.0<8;8,1>:ud  { Align1 SecHalf } */
-
         brw_set_compression_control(p, BRW_COMPRESSION_NONE);
         brw_MOV(p,
                 brw_message_reg(nr + channel),
                 arg0[channel]);
-       
-        brw_set_compression_control(p, BRW_COMPRESSION_2NDHALF);
-        brw_MOV(p,
-                brw_message_reg(nr + channel + 4),
-                sechalf(arg0[channel]));
-      }
 
-      /* skip over the regs populated above:
-       */
-      nr += 8;
-   
-      brw_pop_insn_state(p);
+        if (c->dispatch_width == 16) {
+           brw_set_compression_control(p, BRW_COMPRESSION_2NDHALF);
+           brw_MOV(p,
+                   brw_message_reg(nr + channel + 4),
+                   sechalf(arg0[channel]));
+        }
+      }
    }
+   /* skip over the regs populated above:
+    */
+   nr += 8;
+   brw_pop_insn_state(p);
 
    if (c->key.source_depth_to_render_target)
    {
@@ -1142,7 +1253,7 @@ static void emit_fb_write( struct brw_wm_compile *c,
              get_element_ud(brw_vec8_grf(1,0), 6), 
              brw_imm_ud(1<<26)); 
 
-      jmp = brw_JMPI(p, ip, ip, brw_imm_d(0));
+      jmp = brw_JMPI(p, ip, ip, brw_imm_w(0));
       {
         emit_aa(c, arg1, 2);
         fire_fb_write(c, 0, nr, target, eot);
@@ -1156,7 +1267,6 @@ static void emit_fb_write( struct brw_wm_compile *c,
    }
 }
 
-
 /**
  * Move a GPR to scratch memory. 
  */
@@ -1294,7 +1404,7 @@ void brw_wm_emit( struct brw_wm_compile *c )
         /* Generated instructions for calculating triangle interpolants:
          */
       case WM_PIXELXY:
-        emit_pixel_xy(p, dst, dst_flags);
+        emit_pixel_xy(c, dst, dst_flags);
         break;
 
       case WM_DELTAXY:
@@ -1306,7 +1416,7 @@ void brw_wm_emit( struct brw_wm_compile *c )
         break;
 
       case WM_PIXELW:
-        emit_pixel_w(p, dst, dst_flags, args[0], args[1]);
+        emit_pixel_w(c, dst, dst_flags, args[0], args[1]);
         break;
 
       case WM_LINTERP:
@@ -1364,7 +1474,7 @@ void brw_wm_emit( struct brw_wm_compile *c )
         break;
 
       case OPCODE_TRUNC:
-        emit_trunc(p, dst, dst_flags, args[0]);
+        emit_alu1(p, brw_RNDZ, dst, dst_flags, args[0]);
         break;
 
       case OPCODE_LRP:
@@ -1391,27 +1501,27 @@ void brw_wm_emit( struct brw_wm_compile *c )
         /* Higher math functions:
          */
       case OPCODE_RCP:
-        emit_math1(p, BRW_MATH_FUNCTION_INV, dst, dst_flags, args[0]);
+        emit_math1(c, BRW_MATH_FUNCTION_INV, dst, dst_flags, args[0]);
         break;
 
       case OPCODE_RSQ:
-        emit_math1(p, BRW_MATH_FUNCTION_RSQ, dst, dst_flags, args[0]);
+        emit_math1(c, BRW_MATH_FUNCTION_RSQ, dst, dst_flags, args[0]);
         break;
 
       case OPCODE_SIN:
-        emit_math1(p, BRW_MATH_FUNCTION_SIN, dst, dst_flags, args[0]);
+        emit_math1(c, BRW_MATH_FUNCTION_SIN, dst, dst_flags, args[0]);
         break;
 
       case OPCODE_COS:
-        emit_math1(p, BRW_MATH_FUNCTION_COS, dst, dst_flags, args[0]);
+        emit_math1(c, BRW_MATH_FUNCTION_COS, dst, dst_flags, args[0]);
         break;
 
       case OPCODE_EX2:
-        emit_math1(p, BRW_MATH_FUNCTION_EXP, dst, dst_flags, args[0]);
+        emit_math1(c, BRW_MATH_FUNCTION_EXP, dst, dst_flags, args[0]);
         break;
 
       case OPCODE_LG2:
-        emit_math1(p, BRW_MATH_FUNCTION_LOG, dst, dst_flags, args[0]);
+        emit_math1(c, BRW_MATH_FUNCTION_LOG, dst, dst_flags, args[0]);
         break;
 
       case OPCODE_SCS:
@@ -1419,13 +1529,13 @@ void brw_wm_emit( struct brw_wm_compile *c )
          * fixup for 16-element execution.
          */
         if (dst_flags & WRITEMASK_X)
-           emit_math1(p, BRW_MATH_FUNCTION_COS, dst, (dst_flags&SATURATE)|WRITEMASK_X, args[0]);
+           emit_math1(c, BRW_MATH_FUNCTION_COS, dst, (dst_flags&SATURATE)|WRITEMASK_X, args[0]);
         if (dst_flags & WRITEMASK_Y)
-           emit_math1(p, BRW_MATH_FUNCTION_SIN, dst+1, (dst_flags&SATURATE)|WRITEMASK_X, args[0]);
+           emit_math1(c, BRW_MATH_FUNCTION_SIN, dst+1, (dst_flags&SATURATE)|WRITEMASK_X, args[0]);
         break;
 
       case OPCODE_POW:
-        emit_math2(p, BRW_MATH_FUNCTION_POW, dst, dst_flags, args[0], args[1]);
+        emit_math2(c, BRW_MATH_FUNCTION_POW, dst, dst_flags, args[0], args[1]);
         break;
 
         /* Comparisons:
@@ -1463,17 +1573,20 @@ void brw_wm_emit( struct brw_wm_compile *c )
        break;
 
       case OPCODE_LIT:
-        emit_lit(p, dst, dst_flags, args[0]);
+        emit_lit(c, dst, dst_flags, args[0]);
         break;
 
         /* Texturing operations:
          */
       case OPCODE_TEX:
-        emit_tex(c, inst, dst, dst_flags, args[0]);
+        emit_tex(c, dst, dst_flags, args[0], c->payload.depth[0].hw_reg,
+                 inst->tex_idx, inst->tex_unit,
+                 inst->tex_shadow);
         break;
 
       case OPCODE_TXB:
-        emit_txb(c, inst, dst, dst_flags, args[0]);
+        emit_txb(c, dst, dst_flags, args[0], c->payload.depth[0].hw_reg,
+                 inst->tex_idx, inst->tex_unit);
         break;
 
       case OPCODE_KIL:
index 4e3edfbbffae65dfb29d5b142b42572736afe02d..3737faf26fb33390cda38f12704c4399a12296a7 100644 (file)
@@ -138,7 +138,6 @@ static struct prog_dst_register dst_reg(GLuint file, GLuint idx)
    reg.CondMask = COND_TR;
    reg.CondSwizzle = 0;
    reg.CondSrc = 0;
-   reg.pad = 0;
    return reg;
 }
 
@@ -181,6 +180,9 @@ static void release_temp( struct brw_wm_compile *c, struct prog_dst_register tem
 
 static struct prog_instruction *get_fp_inst(struct brw_wm_compile *c)
 {
+   assert(c->nr_fp_insns < BRW_WM_MAX_INSN);
+   memset(&c->prog_instructions[c->nr_fp_insns], 0,
+         sizeof(*c->prog_instructions));
    return &c->prog_instructions[c->nr_fp_insns++];
 }
 
@@ -447,7 +449,6 @@ static void emit_interp( struct brw_wm_compile *c,
       break;
 
    case FRAG_ATTRIB_FACE:
-      /* XXX review/test this case */
       emit_op(c,
               WM_FRONTFACING,
               dst_mask(dst, WRITEMASK_X),
@@ -956,7 +957,7 @@ static void precalc_txp( struct brw_wm_compile *c,
 
 
 
-static void emit_fb_write( struct brw_wm_compile *c )
+static void emit_render_target_writes( struct brw_wm_compile *c )
 {
    struct prog_src_register payload_r0_depth = src_reg(PROGRAM_PAYLOAD, PAYLOAD_DEPTH);
    struct prog_src_register outdepth = src_reg(PROGRAM_OUTPUT, FRAG_RESULT_DEPTH);
@@ -964,36 +965,34 @@ static void emit_fb_write( struct brw_wm_compile *c )
    GLuint i;
 
    struct prog_instruction *inst, *last_inst;
-   struct brw_context *brw = c->func.brw;
 
    /* The inst->Aux field is used for FB write target and the EOT marker */
 
-   if (brw->state.nr_color_regions > 1) {
-      for (i = 0 ; i < brw->state.nr_color_regions; i++) {
+   if (c->key.nr_color_regions > 1) {
+      for (i = 0 ; i < c->key.nr_color_regions; i++) {
          outcolor = src_reg(PROGRAM_OUTPUT, FRAG_RESULT_DATA0 + i);
-         last_inst = inst = emit_op(c,
-                                    WM_FB_WRITE, dst_mask(dst_undef(),0), 0,
-                                    outcolor, payload_r0_depth, outdepth);
-         inst->Aux = (i<<1);
+         last_inst = inst = emit_op(c, WM_FB_WRITE, dst_mask(dst_undef(), 0),
+                                    0, outcolor, payload_r0_depth, outdepth);
+         inst->Aux = INST_AUX_TARGET(i);
          if (c->fp_fragcolor_emitted) {
             outcolor = src_reg(PROGRAM_OUTPUT, FRAG_RESULT_COLOR);
-            last_inst = inst = emit_op(c, WM_FB_WRITE, dst_mask(dst_undef(),0),
+            last_inst = inst = emit_op(c, WM_FB_WRITE, dst_mask(dst_undef(), 0),
                                        0, outcolor, payload_r0_depth, outdepth);
-            inst->Aux = (i<<1);
+            inst->Aux = INST_AUX_TARGET(i);
          }
       }
-      last_inst->Aux |= 1; //eot
+      last_inst->Aux |= INST_AUX_EOT;
    }
    else {
       /* if gl_FragData[0] is written, use it, else use gl_FragColor */
-      if (c->fp->program.Base.OutputsWritten & (1 << FRAG_RESULT_DATA0))
+      if (c->fp->program.Base.OutputsWritten & BITFIELD64_BIT(FRAG_RESULT_DATA0))
          outcolor = src_reg(PROGRAM_OUTPUT, FRAG_RESULT_DATA0);
       else 
          outcolor = src_reg(PROGRAM_OUTPUT, FRAG_RESULT_COLOR);
 
       inst = emit_op(c, WM_FB_WRITE, dst_mask(dst_undef(),0),
                      0, outcolor, payload_r0_depth, outdepth);
-      inst->Aux = 1|(0<<1);
+      inst->Aux = INST_AUX_EOT | INST_AUX_TARGET(0);
    }
 }
 
@@ -1155,7 +1154,7 @@ void brw_wm_pass_fp( struct brw_wm_compile *c )
         out->DstReg.WriteMask = 0;
         break;
       case OPCODE_END:
-        emit_fb_write(c);
+        emit_render_target_writes(c);
         break;
       case OPCODE_PRINT:
         break;
index c9fe1dd8ad24146dc74cdc0eaa9865d90990cb8e..fde83eea6207cb4857ec2c2b850a613b39504557 100644 (file)
@@ -371,7 +371,7 @@ static void prealloc_reg(struct brw_wm_compile *c)
          for (j = 0; j < 4; j++)
             set_reg(c, PROGRAM_PAYLOAD, fp_input, j, reg);
        }
-       if (c->key.vp_outputs_written & (1 << i)) {
+       if (c->key.vp_outputs_written & BITFIELD64_BIT(i)) {
          reg_index += 2;
        }
     }
@@ -550,42 +550,6 @@ static struct brw_reg get_src_reg(struct brw_wm_compile *c,
     }
 }
 
-
-/**
- * Same as \sa get_src_reg() but if the register is a literal, emit
- * a brw_reg encoding the literal.
- * Note that a brw instruction only allows one src operand to be a literal.
- * For instructions with more than one operand, only the second can be a
- * literal.  This means that we treat some literals as constants/uniforms
- * (which why PROGRAM_CONSTANT is checked in fetch_constants()).
- * 
- */
-static struct brw_reg get_src_reg_imm(struct brw_wm_compile *c, 
-                                      const struct prog_instruction *inst,
-                                      GLuint srcRegIndex, GLuint channel)
-{
-    const struct prog_src_register *src = &inst->SrcReg[srcRegIndex];
-    if (src->File == PROGRAM_CONSTANT) {
-       /* a literal */
-       const int component = GET_SWZ(src->Swizzle, channel);
-       const GLfloat *param =
-          c->fp->program.Base.Parameters->ParameterValues[src->Index];
-       GLfloat value = param[component];
-       if (src->Negate & (1 << channel))
-          value = -value;
-       if (src->Abs)
-          value = FABSF(value);
-#if 0
-       printf("  form immed value %f for chan %d\n", value, channel);
-#endif
-       return brw_imm_f(value);
-    }
-    else {
-       return get_src_reg(c, inst, srcRegIndex, channel);
-    }
-}
-
-
 /**
  * Subroutines are minimal support for resusable instruction sequences.
  * They are implemented as simply as possible to minimise overhead: there
@@ -650,542 +614,110 @@ static void invoke_subroutine( struct brw_wm_compile *c,
     }
 }
 
-static void emit_trunc( struct brw_wm_compile *c,
-                        const struct prog_instruction *inst)
-{
-    int i;
-    struct brw_compile *p = &c->func;
-    GLuint mask = inst->DstReg.WriteMask;
-    brw_set_saturate(p, inst->SaturateMode != SATURATE_OFF);
-    for (i = 0; i < 4; i++) {
-       if (mask & (1<<i)) {
-           struct brw_reg src, dst;
-           dst = get_dst_reg(c, inst, i);
-           src = get_src_reg(c, inst, 0, i);
-           brw_RNDZ(p, dst, src);
-       }
-    }
-    brw_set_saturate(p, 0);
-}
-
-static void emit_mov( struct brw_wm_compile *c,
-                      const struct prog_instruction *inst)
-{
-    int i;
-    struct brw_compile *p = &c->func;
-    GLuint mask = inst->DstReg.WriteMask;
-    brw_set_saturate(p, inst->SaturateMode != SATURATE_OFF);
-    for (i = 0; i < 4; i++) {
-       if (mask & (1<<i)) {
-           struct brw_reg src, dst;
-           dst = get_dst_reg(c, inst, i);
-            /* XXX some moves from immediate value don't work reliably!!! */
-            /*src = get_src_reg_imm(c, inst, 0, i);*/
-            src = get_src_reg(c, inst, 0, i);
-           brw_MOV(p, dst, src);
-       }
-    }
-    brw_set_saturate(p, 0);
-}
-
-static void emit_pixel_xy(struct brw_wm_compile *c,
-                          const struct prog_instruction *inst)
-{
-    struct brw_reg r1 = brw_vec1_grf(1, 0);
-    struct brw_reg r1_uw = retype(r1, BRW_REGISTER_TYPE_UW);
-
-    struct brw_reg dst0, dst1;
-    struct brw_compile *p = &c->func;
-    GLuint mask = inst->DstReg.WriteMask;
-
-    dst0 = get_dst_reg(c, inst, 0);
-    dst1 = get_dst_reg(c, inst, 1);
-    /* Calculate pixel centers by adding 1 or 0 to each of the
-     * micro-tile coordinates passed in r1.
-     */
-    if (mask & WRITEMASK_X) {
-       brw_ADD(p,
-               vec8(retype(dst0, BRW_REGISTER_TYPE_UW)),
-               stride(suboffset(r1_uw, 4), 2, 4, 0),
-               brw_imm_v(0x10101010));
-    }
-
-    if (mask & WRITEMASK_Y) {
-       brw_ADD(p,
-               vec8(retype(dst1, BRW_REGISTER_TYPE_UW)),
-               stride(suboffset(r1_uw, 5), 2, 4, 0),
-               brw_imm_v(0x11001100));
-    }
-}
-
-static void emit_delta_xy(struct brw_wm_compile *c,
-                          const struct prog_instruction *inst)
-{
-    struct brw_reg r1 = brw_vec1_grf(1, 0);
-    struct brw_reg dst0, dst1, src0, src1;
-    struct brw_compile *p = &c->func;
-    GLuint mask = inst->DstReg.WriteMask;
-
-    dst0 = get_dst_reg(c, inst, 0);
-    dst1 = get_dst_reg(c, inst, 1);
-    src0 = get_src_reg(c, inst, 0, 0);
-    src1 = get_src_reg(c, inst, 0, 1);
-    /* Calc delta X,Y by subtracting origin in r1 from the pixel
-     * centers.
-     */
-    if (mask & WRITEMASK_X) {
-       brw_ADD(p,
-               dst0,
-               retype(src0, BRW_REGISTER_TYPE_UW),
-               negate(r1));
-    }
-
-    if (mask & WRITEMASK_Y) {
-       brw_ADD(p,
-               dst1,
-               retype(src1, BRW_REGISTER_TYPE_UW),
-               negate(suboffset(r1,1)));
-
-    }
-}
-
-static void fire_fb_write( struct brw_wm_compile *c,
-                           GLuint base_reg,
-                           GLuint nr,
-                           GLuint target,
-                           GLuint eot)
-{
-    struct brw_compile *p = &c->func;
-    /* Pass through control information:
-     */
-    /*  mov (8) m1.0<1>:ud   r1.0<8;8,1>:ud   { Align1 NoMask } */
-    {
-       brw_push_insn_state(p);
-       brw_set_mask_control(p, BRW_MASK_DISABLE); /* ? */
-       brw_MOV(p,
-               brw_message_reg(base_reg + 1),
-               brw_vec8_grf(1, 0));
-       brw_pop_insn_state(p);
-    }
-    /* Send framebuffer write message: */
-    brw_fb_WRITE(p,
-           retype(vec8(brw_null_reg()), BRW_REGISTER_TYPE_UW),
-           base_reg,
-           retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UW),
-           target,              
-           nr,
-           0,
-           eot);
-}
-
-static void emit_fb_write(struct brw_wm_compile *c,
-                          const struct prog_instruction *inst)
-{
-    struct brw_compile *p = &c->func;
-    int nr = 2;
-    int channel;
-    GLuint target, eot;
-    struct brw_reg src0;
-
-    /* Reserve a space for AA - may not be needed:
-     */
-    if (c->key.aa_dest_stencil_reg)
-       nr += 1;
-
-    brw_push_insn_state(p);
-    for (channel = 0; channel < 4; channel++) {
-        src0 = get_src_reg(c,  inst, 0, channel);
-        /*  mov (8) m2.0<1>:ud   r28.0<8;8,1>:ud  { Align1 } */
-        /*  mov (8) m6.0<1>:ud   r29.0<8;8,1>:ud  { Align1 SecHalf } */
-        brw_MOV(p, brw_message_reg(nr + channel), src0);
-    }
-    /* skip over the regs populated above: */
-    nr += 8;
-    brw_pop_insn_state(p);
-
-    if (c->key.source_depth_to_render_target) {
-       if (c->key.computes_depth) {
-          src0 = get_src_reg(c, inst, 2, 2);
-          brw_MOV(p, brw_message_reg(nr), src0);
-       }
-       else {
-          src0 = get_src_reg(c, inst, 1, 1);
-          brw_MOV(p, brw_message_reg(nr), src0);
-       }
-
-       nr += 2;
-    }
-
-    if (c->key.dest_depth_reg) {
-        const GLuint comp = c->key.dest_depth_reg / 2;
-        const GLuint off = c->key.dest_depth_reg % 2;
-
-        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_0, 1));
-            /* 2nd half? */
-            brw_MOV(p, brw_message_reg(nr+1), arg1_1);
-            brw_pop_insn_state(p);
-        }
-        else
-        {
-            struct brw_reg src =  get_src_reg(c, inst, 1, 1);
-            brw_MOV(p, brw_message_reg(nr), src);
-        }
-        nr += 2;
-   }
-
-    target = inst->Aux >> 1;
-    eot = inst->Aux & 1;
-    fire_fb_write(c, 0, nr, target, eot);
-}
-
-static void emit_pixel_w( struct brw_wm_compile *c,
-                          const struct prog_instruction *inst)
+/* Workaround for using brw_wm_emit.c's emit functions, which expect
+ * destination regs to be uniquely written.  Moves arguments out to
+ * temporaries as necessary for instructions which use their destination as
+ * a temporary.
+ */
+static void
+unalias3(struct brw_wm_compile *c,
+        void (*func)(struct brw_compile *c,
+                     const struct brw_reg *dst,
+                     GLuint mask,
+                     const struct brw_reg *arg0,
+                     const struct brw_reg *arg1,
+                     const struct brw_reg *arg2),
+        const struct brw_reg *dst,
+        GLuint mask,
+        const struct brw_reg *arg0,
+        const struct brw_reg *arg1,
+        const struct brw_reg *arg2)
 {
     struct brw_compile *p = &c->func;
-    GLuint mask = inst->DstReg.WriteMask;
-    if (mask & WRITEMASK_W) {
-       struct brw_reg dst, src0, delta0, delta1;
-       struct brw_reg interp3;
-
-       dst = get_dst_reg(c, inst, 3);
-       src0 = get_src_reg(c, inst, 0, 0);
-       delta0 = get_src_reg(c, inst, 1, 0);
-       delta1 = get_src_reg(c, inst, 1, 1);
-
-       interp3 = brw_vec1_grf(src0.nr+1, 4);
-       /* Calc 1/w - just linterp wpos[3] optimized by putting the
-        * result straight into a message reg.
-        */
-       brw_LINE(p, brw_null_reg(), interp3, delta0);
-       brw_MAC(p, brw_message_reg(2), suboffset(interp3, 1), delta1);
-
-       /* Calc w */
-       brw_math_16( p, dst,
-               BRW_MATH_FUNCTION_INV,
-               BRW_MATH_SATURATE_NONE,
-               2, brw_null_reg(),
-               BRW_MATH_PRECISION_FULL);
-    }
-}
+    struct brw_reg tmp_arg0[4], tmp_arg1[4], tmp_arg2[4];
+    int i, j;
+    int mark = mark_tmps(c);
 
-static void emit_linterp(struct brw_wm_compile *c,
-                         const struct prog_instruction *inst)
-{
-    struct brw_compile *p = &c->func;
-    GLuint mask = inst->DstReg.WriteMask;
-    struct brw_reg interp[4];
-    struct brw_reg dst, delta0, delta1;
-    struct brw_reg src0;
-    GLuint nr, i;
-
-    src0 = get_src_reg(c, inst, 0, 0);
-    delta0 = get_src_reg(c, inst, 1, 0);
-    delta1 = get_src_reg(c, inst, 1, 1);
-    nr = src0.nr;
-
-    interp[0] = brw_vec1_grf(nr, 0);
-    interp[1] = brw_vec1_grf(nr, 4);
-    interp[2] = brw_vec1_grf(nr+1, 0);
-    interp[3] = brw_vec1_grf(nr+1, 4);
-
-    for(i = 0; i < 4; i++ ) {
-       if (mask & (1<<i)) {
-           dst = get_dst_reg(c, inst, i);
-           brw_LINE(p, brw_null_reg(), interp[i], delta0);
-           brw_MAC(p, dst, suboffset(interp[i],1), delta1);
-       }
+    for (j = 0; j < 4; j++) {
+       tmp_arg0[j] = arg0[j];
+       tmp_arg1[j] = arg1[j];
+       tmp_arg2[j] = arg2[j];
     }
-}
-
-static void emit_cinterp(struct brw_wm_compile *c,
-                         const struct prog_instruction *inst)
-{
-    struct brw_compile *p = &c->func;
-    GLuint mask = inst->DstReg.WriteMask;
-
-    struct brw_reg interp[4];
-    struct brw_reg dst, src0;
-    GLuint nr, i;
 
-    src0 = get_src_reg(c, inst, 0, 0);
-    nr = src0.nr;
-
-    interp[0] = brw_vec1_grf(nr, 0);
-    interp[1] = brw_vec1_grf(nr, 4);
-    interp[2] = brw_vec1_grf(nr+1, 0);
-    interp[3] = brw_vec1_grf(nr+1, 4);
-
-    for(i = 0; i < 4; i++ ) {
+    for (i = 0; i < 4; i++) {
        if (mask & (1<<i)) {
-           dst = get_dst_reg(c, inst, i);
-           brw_MOV(p, dst, suboffset(interp[i],3));
+           for (j = 0; j < 4; j++) {
+               if (arg0[j].file == dst[i].file &&
+                   dst[i].nr == arg0[j].nr) {
+                   tmp_arg0[j] = alloc_tmp(c);
+                   brw_MOV(p, tmp_arg0[j], arg0[j]);
+               }
+               if (arg1[j].file == dst[i].file &&
+                   dst[i].nr == arg1[j].nr) {
+                   tmp_arg1[j] = alloc_tmp(c);
+                   brw_MOV(p, tmp_arg1[j], arg1[j]);
+               }
+               if (arg2[j].file == dst[i].file &&
+                   dst[i].nr == arg2[j].nr) {
+                   tmp_arg2[j] = alloc_tmp(c);
+                   brw_MOV(p, tmp_arg2[j], arg2[j]);
+               }
+           }
        }
     }
-}
-
-static void emit_pinterp(struct brw_wm_compile *c,
-                         const struct prog_instruction *inst)
-{
-    struct brw_compile *p = &c->func;
-    GLuint mask = inst->DstReg.WriteMask;
 
-    struct brw_reg interp[4];
-    struct brw_reg dst, delta0, delta1;
-    struct brw_reg src0, w;
-    GLuint nr, i;
+    func(p, dst, mask, tmp_arg0, tmp_arg1, tmp_arg2);
 
-    src0 = get_src_reg(c, inst, 0, 0);
-    delta0 = get_src_reg(c, inst, 1, 0);
-    delta1 = get_src_reg(c, inst, 1, 1);
-    w = get_src_reg(c, inst, 2, 3);
-    nr = src0.nr;
-
-    interp[0] = brw_vec1_grf(nr, 0);
-    interp[1] = brw_vec1_grf(nr, 4);
-    interp[2] = brw_vec1_grf(nr+1, 0);
-    interp[3] = brw_vec1_grf(nr+1, 4);
-
-    for(i = 0; i < 4; i++ ) {
-       if (mask & (1<<i)) {
-           dst = get_dst_reg(c, inst, i);
-           brw_LINE(p, brw_null_reg(), interp[i], delta0);
-           brw_MAC(p, dst, suboffset(interp[i],1), 
-                   delta1);
-           brw_MUL(p, dst, dst, w);
-       }
-    }
+    release_tmps(c, mark);
 }
 
-/* Sets the destination channels to 1.0 or 0.0 according to glFrontFacing. */
-static void emit_frontfacing(struct brw_wm_compile *c,
-                            const struct prog_instruction *inst)
+/* Workaround for using brw_wm_emit.c's emit functions, which expect
+ * destination regs to be uniquely written.  Moves arguments out to
+ * temporaries as necessary for instructions which use their destination as
+ * a temporary.
+ */
+static void
+unalias2(struct brw_wm_compile *c,
+        void (*func)(struct brw_compile *c,
+                     const struct brw_reg *dst,
+                     GLuint mask,
+                     const struct brw_reg *arg0,
+                     const struct brw_reg *arg1),
+        const struct brw_reg *dst,
+        GLuint mask,
+        const struct brw_reg *arg0,
+        const struct brw_reg *arg1)
 {
     struct brw_compile *p = &c->func;
-    struct brw_reg r1_6ud = retype(brw_vec1_grf(1, 6), BRW_REGISTER_TYPE_UD);
-    struct brw_reg dst;
-    GLuint mask = inst->DstReg.WriteMask;
-    int i;
-
-    for (i = 0; i < 4; i++) {
-       if (mask & (1<<i)) {
-           dst = get_dst_reg(c, inst, i);
-           brw_MOV(p, dst, brw_imm_f(0.0));
-       }
-    }
+    struct brw_reg tmp_arg0[4], tmp_arg1[4];
+    int i, j;
+    int mark = mark_tmps(c);
 
-    /* bit 31 is "primitive is back face", so checking < (1 << 31) gives
-     * us front face
-     */
-    brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_L, r1_6ud, brw_imm_ud(1 << 31));
-    for (i = 0; i < 4; i++) {
-       if (mask & (1<<i)) {
-           dst = get_dst_reg(c, inst, i);
-           brw_MOV(p, dst, brw_imm_f(1.0));
-       }
+    for (j = 0; j < 4; j++) {
+       tmp_arg0[j] = arg0[j];
+       tmp_arg1[j] = arg1[j];
     }
-    brw_set_predicate_control_flag_value(p, 0xff);
-}
 
-static void emit_xpd(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst)
-{
-    int i;
-    struct brw_compile *p = &c->func;
-    GLuint mask = inst->DstReg.WriteMask;
     for (i = 0; i < 4; i++) {
-       GLuint i2 = (i+2)%3;
-       GLuint i1 = (i+1)%3;
        if (mask & (1<<i)) {
-           struct brw_reg src0, src1, dst;
-           dst = get_dst_reg(c, inst, i);
-           src0 = negate(get_src_reg(c, inst, 0, i2));
-           src1 = get_src_reg_imm(c, inst, 1, i1);
-           brw_MUL(p, brw_null_reg(), src0, src1);
-           src0 = get_src_reg(c, inst, 0, i1);
-           src1 = get_src_reg_imm(c, inst, 1, i2);
-           brw_set_saturate(p, inst->SaturateMode != SATURATE_OFF);
-           brw_MAC(p, dst, src0, src1);
-           brw_set_saturate(p, 0);
+           for (j = 0; j < 4; j++) {
+               if (arg0[j].file == dst[i].file &&
+                   dst[i].nr == arg0[j].nr) {
+                   tmp_arg0[j] = alloc_tmp(c);
+                   brw_MOV(p, tmp_arg0[j], arg0[j]);
+               }
+               if (arg1[j].file == dst[i].file &&
+                   dst[i].nr == arg1[j].nr) {
+                   tmp_arg1[j] = alloc_tmp(c);
+                   brw_MOV(p, tmp_arg1[j], arg1[j]);
+               }
+           }
        }
     }
-    brw_set_saturate(p, 0);
-}
 
-static void emit_dp3(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst)
-{
-    struct brw_reg src0[3], src1[3], dst;
-    int i;
-    struct brw_compile *p = &c->func;
-    GLuint mask = inst->DstReg.WriteMask;
-    int dst_chan = _mesa_ffs(mask & WRITEMASK_XYZW) - 1;
-
-    if (!(mask & WRITEMASK_XYZW))
-       return;
-
-    assert(is_power_of_two(mask & WRITEMASK_XYZW));
-
-    for (i = 0; i < 3; i++) {
-       src0[i] = get_src_reg(c, inst, 0, i);
-       src1[i] = get_src_reg_imm(c, inst, 1, i);
-    }
-
-    dst = get_dst_reg(c, inst, dst_chan);
-    brw_MUL(p, brw_null_reg(), src0[0], src1[0]);
-    brw_MAC(p, brw_null_reg(), src0[1], src1[1]);
-    brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
-    brw_MAC(p, dst, src0[2], src1[2]);
-    brw_set_saturate(p, 0);
-}
-
-static void emit_dp4(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst)
-{
-    struct brw_reg src0[4], src1[4], dst;
-    int i;
-    struct brw_compile *p = &c->func;
-    GLuint mask = inst->DstReg.WriteMask;
-    int dst_chan = _mesa_ffs(mask & WRITEMASK_XYZW) - 1;
-
-    if (!(mask & WRITEMASK_XYZW))
-       return;
-
-    assert(is_power_of_two(mask & WRITEMASK_XYZW));
-
-    for (i = 0; i < 4; i++) {
-       src0[i] = get_src_reg(c, inst, 0, i);
-       src1[i] = get_src_reg_imm(c, inst, 1, i);
-    }
-    dst = get_dst_reg(c, inst, dst_chan);
-    brw_MUL(p, brw_null_reg(), src0[0], src1[0]);
-    brw_MAC(p, brw_null_reg(), src0[1], src1[1]);
-    brw_MAC(p, brw_null_reg(), src0[2], src1[2]);
-    brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
-    brw_MAC(p, dst, src0[3], src1[3]);
-    brw_set_saturate(p, 0);
-}
-
-static void emit_dph(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst)
-{
-    struct brw_reg src0[4], src1[4], dst;
-    int i;
-    struct brw_compile *p = &c->func;
-    GLuint mask = inst->DstReg.WriteMask;
-    int dst_chan = _mesa_ffs(mask & WRITEMASK_XYZW) - 1;
-
-    if (!(mask & WRITEMASK_XYZW))
-       return;
-
-    assert(is_power_of_two(mask & WRITEMASK_XYZW));
-
-    for (i = 0; i < 4; i++) {
-       src0[i] = get_src_reg(c, inst, 0, i);
-       src1[i] = get_src_reg_imm(c, inst, 1, i);
-    }
-    dst = get_dst_reg(c, inst, dst_chan);
-    brw_MUL(p, brw_null_reg(), src0[0], src1[0]);
-    brw_MAC(p, brw_null_reg(), src0[1], src1[1]);
-    brw_MAC(p, dst, src0[2], src1[2]);
-    brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
-    brw_ADD(p, dst, dst, src1[3]);
-    brw_set_saturate(p, 0);
-}
-
-/**
- * Emit a scalar instruction, like RCP, RSQ, LOG, EXP.
- * Note that the result of the function is smeared across the dest
- * register's X, Y, Z and W channels (subject to writemasking of course).
- */
-static void emit_math1(struct brw_wm_compile *c,
-                       const struct prog_instruction *inst, GLuint func)
-{
-    struct brw_compile *p = &c->func;
-    struct brw_reg src0, dst;
-    GLuint mask = inst->DstReg.WriteMask;
-    int dst_chan = _mesa_ffs(mask & WRITEMASK_XYZW) - 1;
-
-    if (!(mask & WRITEMASK_XYZW))
-       return;
-
-    assert(is_power_of_two(mask & WRITEMASK_XYZW));
-
-    /* Get first component of source register */
-    dst = get_dst_reg(c, inst, dst_chan);
-    src0 = get_src_reg(c, inst, 0, 0);
-
-    brw_MOV(p, brw_message_reg(2), src0);
-    brw_math(p,
-             dst,
-             func,
-             (inst->SaturateMode != SATURATE_OFF) ? BRW_MATH_SATURATE_SATURATE : BRW_MATH_SATURATE_NONE,
-             2,
-             brw_null_reg(),
-             BRW_MATH_DATA_VECTOR,
-             BRW_MATH_PRECISION_FULL);
-}
-
-static void emit_rcp(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst)
-{
-    emit_math1(c, inst, BRW_MATH_FUNCTION_INV);
-}
-
-static void emit_rsq(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst)
-{
-    emit_math1(c, inst, BRW_MATH_FUNCTION_RSQ);
-}
-
-static void emit_sin(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst)
-{
-    emit_math1(c, inst, BRW_MATH_FUNCTION_SIN);
-}
+    func(p, dst, mask, tmp_arg0, tmp_arg1);
 
-static void emit_cos(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst)
-{
-    emit_math1(c, inst, BRW_MATH_FUNCTION_COS);
-}
-
-static void emit_ex2(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst)
-{
-    emit_math1(c, inst, BRW_MATH_FUNCTION_EXP);
-}
-
-static void emit_lg2(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst)
-{
-    emit_math1(c, inst, BRW_MATH_FUNCTION_LOG);
-}
-
-static void emit_add(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst)
-{
-    struct brw_compile *p = &c->func;
-    struct brw_reg src0, src1, dst;
-    GLuint mask = inst->DstReg.WriteMask;
-    int i;
-    brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
-    for (i = 0 ; i < 4; i++) {
-       if (mask & (1<<i)) {
-           dst = get_dst_reg(c, inst, i);
-           src0 = get_src_reg(c, inst, 0, i);
-           src1 = get_src_reg_imm(c, inst, 1, i);
-           brw_ADD(p, dst, src0, src1);
-       }
-    }
-    brw_set_saturate(p, 0);
+    release_tmps(c, mark);
 }
 
 static void emit_arl(struct brw_wm_compile *c,
@@ -1201,180 +733,6 @@ static void emit_arl(struct brw_wm_compile *c,
     brw_set_saturate(p, 0);
 }
 
-
-static void emit_mul(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst)
-{
-    struct brw_compile *p = &c->func;
-    struct brw_reg src0, src1, dst;
-    GLuint mask = inst->DstReg.WriteMask;
-    int i;
-    brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
-    for (i = 0 ; i < 4; i++) {
-       if (mask & (1<<i)) {
-           dst = get_dst_reg(c, inst, i);
-           src0 = get_src_reg(c, inst, 0, i);
-           src1 = get_src_reg_imm(c, inst, 1, i);
-           brw_MUL(p, dst, src0, src1);
-       }
-    }
-    brw_set_saturate(p, 0);
-}
-
-static void emit_frc(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst)
-{
-    struct brw_compile *p = &c->func;
-    struct brw_reg src0, dst;
-    GLuint mask = inst->DstReg.WriteMask;
-    int i;
-    brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
-    for (i = 0 ; i < 4; i++) {
-       if (mask & (1<<i)) {
-           dst = get_dst_reg(c, inst, i);
-           src0 = get_src_reg_imm(c, inst, 0, i);
-           brw_FRC(p, dst, src0);
-       }
-    }
-    if (inst->SaturateMode != SATURATE_OFF)
-       brw_set_saturate(p, 0);
-}
-
-static void emit_flr(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst)
-{
-    struct brw_compile *p = &c->func;
-    struct brw_reg src0, dst;
-    GLuint mask = inst->DstReg.WriteMask;
-    int i;
-    brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
-    for (i = 0 ; i < 4; i++) {
-       if (mask & (1<<i)) {
-           dst = get_dst_reg(c, inst, i);
-           src0 = get_src_reg_imm(c, inst, 0, i);
-           brw_RNDD(p, dst, src0);
-       }
-    }
-    brw_set_saturate(p, 0);
-}
-
-
-static void emit_min_max(struct brw_wm_compile *c,
-                         const struct prog_instruction *inst)
-{
-    struct brw_compile *p = &c->func;
-    const GLuint mask = inst->DstReg.WriteMask;
-    const int mark = mark_tmps(c);
-    int i;
-    brw_push_insn_state(p);
-    for (i = 0; i < 4; i++) {
-       if (mask & (1<<i)) {
-            struct brw_reg real_dst = get_dst_reg(c, inst, i);
-           struct brw_reg src0 = get_src_reg(c, inst, 0, i);
-           struct brw_reg src1 = get_src_reg(c, inst, 1, i);
-            struct brw_reg dst;
-            /* if dst==src0 or dst==src1 we need to use a temp reg */
-            GLboolean use_temp = brw_same_reg(dst, src0) ||
-                                 brw_same_reg(dst, src1);
-            if (use_temp)
-               dst = alloc_tmp(c);
-            else
-               dst = real_dst;
-
-            /*
-            printf("  Min/max: dst %d  src0 %d  src1 %d\n",
-                   dst.nr, src0.nr, src1.nr);
-            */
-           brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
-           brw_MOV(p, dst, src0);
-           brw_set_saturate(p, 0);
-
-            if (inst->Opcode == OPCODE_MIN)
-               brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_L, src1, src0);
-            else
-               brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_G, src1, src0);
-
-           brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
-           brw_set_predicate_control(p, BRW_PREDICATE_NORMAL);
-           brw_MOV(p, dst, src1);
-           brw_set_saturate(p, 0);
-           brw_set_predicate_control_flag_value(p, 0xff);
-            if (use_temp)
-               brw_MOV(p, real_dst, dst);
-       }
-    }
-    brw_pop_insn_state(p);
-    release_tmps(c, mark);
-}
-
-static void emit_pow(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst)
-{
-    struct brw_compile *p = &c->func;
-    struct brw_reg dst, src0, src1;
-    GLuint mask = inst->DstReg.WriteMask;
-    int dst_chan = _mesa_ffs(mask & WRITEMASK_XYZW) - 1;
-
-    if (!(mask & WRITEMASK_XYZW))
-       return;
-
-    assert(is_power_of_two(mask & WRITEMASK_XYZW));
-
-    dst = get_dst_reg(c, inst, dst_chan);
-    src0 = get_src_reg_imm(c, inst, 0, 0);
-    src1 = get_src_reg_imm(c, inst, 1, 0);
-
-    brw_MOV(p, brw_message_reg(2), src0);
-    brw_MOV(p, brw_message_reg(3), src1);
-
-    brw_math(p,
-           dst,
-           BRW_MATH_FUNCTION_POW,
-           (inst->SaturateMode != SATURATE_OFF) ? BRW_MATH_SATURATE_SATURATE : BRW_MATH_SATURATE_NONE,
-           2,
-           brw_null_reg(),
-           BRW_MATH_DATA_VECTOR,
-           BRW_MATH_PRECISION_FULL);
-}
-
-static void emit_lrp(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst)
-{
-    struct brw_compile *p = &c->func;
-    GLuint mask = inst->DstReg.WriteMask;
-    struct brw_reg dst, tmp1, tmp2, src0, src1, src2;
-    int i;
-    int mark = mark_tmps(c);
-    for (i = 0; i < 4; i++) {
-       if (mask & (1<<i)) {
-           dst = get_dst_reg(c, inst, i);
-           src0 = get_src_reg(c, inst, 0, i);
-
-           src1 = get_src_reg_imm(c, inst, 1, i);
-
-           if (src1.nr == dst.nr) {
-               tmp1 = alloc_tmp(c);
-               brw_MOV(p, tmp1, src1);
-           } else
-               tmp1 = src1;
-
-           src2 = get_src_reg(c, inst, 2, i);
-           if (src2.nr == dst.nr) {
-               tmp2 = alloc_tmp(c);
-               brw_MOV(p, tmp2, src2);
-           } else
-               tmp2 = src2;
-
-           brw_ADD(p, dst, negate(src0), brw_imm_f(1.0));
-           brw_MUL(p, brw_null_reg(), dst, tmp2);
-           brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
-           brw_MAC(p, dst, src0, tmp1);
-           brw_set_saturate(p, 0);
-       }
-       release_tmps(c, mark);
-    }
-}
-
 /**
  * For GLSL shaders, this KIL will be unconditional.
  * It may be contained inside an IF/ENDIF structure of course.
@@ -1385,94 +743,11 @@ static void emit_kil(struct brw_wm_compile *c)
     struct brw_reg depth = retype(brw_vec1_grf(0, 0), BRW_REGISTER_TYPE_UW);
     brw_push_insn_state(p);
     brw_set_mask_control(p, BRW_MASK_DISABLE);
-    brw_NOT(p, c->emit_mask_reg, brw_mask_reg(1)); //IMASK
+    brw_NOT(p, c->emit_mask_reg, brw_mask_reg(1)); /* IMASK */
     brw_AND(p, depth, c->emit_mask_reg, depth);
     brw_pop_insn_state(p);
 }
 
-static void emit_mad(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst)
-{
-    struct brw_compile *p = &c->func;
-    GLuint mask = inst->DstReg.WriteMask;
-    struct brw_reg dst, src0, src1, src2;
-    int i;
-
-    for (i = 0; i < 4; i++) {
-       if (mask & (1<<i)) {
-           dst = get_dst_reg(c, inst, i);
-           src0 = get_src_reg(c, inst, 0, i);
-           src1 = get_src_reg_imm(c, inst, 1, i);
-           src2 = get_src_reg_imm(c, inst, 2, i);
-           brw_MUL(p, dst, src0, src1);
-
-           brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
-           brw_ADD(p, dst, dst, src2);
-           brw_set_saturate(p, 0);
-       }
-    }
-}
-
-static void emit_sop(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst, GLuint cond)
-{
-    struct brw_compile *p = &c->func;
-    GLuint mask = inst->DstReg.WriteMask;
-    struct brw_reg dst, src0, src1;
-    int i;
-
-    for (i = 0; i < 4; i++) {
-       if (mask & (1<<i)) {
-           dst = get_dst_reg(c, inst, i);
-           src0 = get_src_reg(c, inst, 0, i);
-           src1 = get_src_reg_imm(c, inst, 1, i);
-           brw_push_insn_state(p);
-           brw_CMP(p, brw_null_reg(), cond, src0, src1);
-           brw_set_predicate_control(p, BRW_PREDICATE_NONE);
-           brw_MOV(p, dst, brw_imm_f(0.0));
-           brw_set_predicate_control(p, BRW_PREDICATE_NORMAL);
-           brw_MOV(p, dst, brw_imm_f(1.0));
-           brw_pop_insn_state(p);
-       }
-    }
-}
-
-static void emit_slt(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst)
-{
-    emit_sop(c, inst, BRW_CONDITIONAL_L);
-}
-
-static void emit_sle(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst)
-{
-    emit_sop(c, inst, BRW_CONDITIONAL_LE);
-}
-
-static void emit_sgt(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst)
-{
-    emit_sop(c, inst, BRW_CONDITIONAL_G);
-}
-
-static void emit_sge(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst)
-{
-    emit_sop(c, inst, BRW_CONDITIONAL_GE);
-}
-
-static void emit_seq(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst)
-{
-    emit_sop(c, inst, BRW_CONDITIONAL_EQ);
-}
-
-static void emit_sne(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst)
-{
-    emit_sop(c, inst, BRW_CONDITIONAL_NEQ);
-}
-
 static INLINE struct brw_reg high_words( struct brw_reg reg )
 {
     return stride( suboffset( retype( reg, BRW_REGISTER_TYPE_W ), 1 ),
@@ -2525,196 +1800,6 @@ static void emit_noise4( struct brw_wm_compile *c,
     
     release_tmps( c, mark );
 }
-    
-static void emit_wpos_xy(struct brw_wm_compile *c,
-                         const struct prog_instruction *inst)
-{
-    struct brw_compile *p = &c->func;
-    GLuint mask = inst->DstReg.WriteMask;
-    struct brw_reg src0[2], dst[2];
-
-    dst[0] = get_dst_reg(c, inst, 0);
-    dst[1] = get_dst_reg(c, inst, 1);
-
-    src0[0] = get_src_reg(c, inst, 0, 0);
-    src0[1] = get_src_reg(c, inst, 0, 1);
-
-    /* Calculate the pixel offset from window bottom left into destination
-     * X and Y channels.
-     */
-    if (mask & WRITEMASK_X) {
-       /* X' = X - origin_x */
-       brw_ADD(p,
-               dst[0],
-               retype(src0[0], BRW_REGISTER_TYPE_W),
-               brw_imm_d(0 - c->key.origin_x));
-    }
-
-    if (mask & WRITEMASK_Y) {
-       /* Y' = height - (Y - origin_y) = height + origin_y - Y */
-       brw_ADD(p,
-               dst[1],
-               negate(retype(src0[1], BRW_REGISTER_TYPE_W)),
-               brw_imm_d(c->key.origin_y + c->key.drawable_height - 1));
-    }
-}
-
-/* TODO
-   BIAS on SIMD8 not working yet...
- */    
-static void emit_txb(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst)
-{
-    struct brw_compile *p = &c->func;
-    struct brw_reg dst[4], src[4], payload_reg;
-    /* Note: TexSrcUnit was already looked up through SamplerTextures[] */
-    const GLuint unit = inst->TexSrcUnit;
-    GLuint i;
-    GLuint msg_type;
-
-    assert(unit < BRW_MAX_TEX_UNIT);
-
-    payload_reg = get_reg(c, PROGRAM_PAYLOAD, PAYLOAD_DEPTH, 0, 1, 0, 0);
-
-    for (i = 0; i < 4; i++) 
-       dst[i] = get_dst_reg(c, inst, i);
-    for (i = 0; i < 4; i++)
-       src[i] = get_src_reg(c, inst, 0, i);
-
-    switch (inst->TexSrcTarget) {
-       case TEXTURE_1D_INDEX:
-           brw_MOV(p, brw_message_reg(2), src[0]);         /* s coord */
-           brw_MOV(p, brw_message_reg(3), brw_imm_f(0));   /* t coord */
-           brw_MOV(p, brw_message_reg(4), brw_imm_f(0));   /* r coord */
-           break;
-       case TEXTURE_2D_INDEX:
-       case TEXTURE_RECT_INDEX:
-           brw_MOV(p, brw_message_reg(2), src[0]);
-           brw_MOV(p, brw_message_reg(3), src[1]);
-           brw_MOV(p, brw_message_reg(4), brw_imm_f(0));
-           break;
-       case TEXTURE_3D_INDEX:
-       case TEXTURE_CUBE_INDEX:
-           brw_MOV(p, brw_message_reg(2), src[0]);
-           brw_MOV(p, brw_message_reg(3), src[1]);
-           brw_MOV(p, brw_message_reg(4), src[2]);
-           break;
-       default:
-            /* invalid target */
-            abort();
-    }
-    brw_MOV(p, brw_message_reg(5), src[3]);          /* bias */
-    brw_MOV(p, brw_message_reg(6), brw_imm_f(0));    /* ref (unused?) */
-
-    if (BRW_IS_IGDNG(p->brw)) {
-        msg_type = BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_BIAS_IGDNG;
-    } else {
-        /* Does it work well on SIMD8? */
-        msg_type = BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_BIAS;
-    }
-
-    brw_SAMPLE(p,
-               retype(vec8(dst[0]), BRW_REGISTER_TYPE_UW),  /* dest */
-               1,                                           /* msg_reg_nr */
-               retype(payload_reg, BRW_REGISTER_TYPE_UW),   /* src0 */
-               SURF_INDEX_TEXTURE(unit),
-               unit,                                        /* sampler */
-               inst->DstReg.WriteMask,                      /* writemask */
-               msg_type,                                    /* msg_type */
-               4,                                           /* response_length */
-               4,                                           /* msg_length */
-               0,                                           /* eot */
-               1,
-               BRW_SAMPLER_SIMD_MODE_SIMD8);   
-}
-
-
-static void emit_tex(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst)
-{
-    struct brw_compile *p = &c->func;
-    struct brw_reg dst[4], src[4], payload_reg;
-    /* Note: TexSrcUnit was already looked up through SamplerTextures[] */
-    const GLuint unit = inst->TexSrcUnit;
-    GLuint msg_len;
-    GLuint i, nr;
-    GLuint emit;
-    GLboolean shadow = (c->key.shadowtex_mask & (1<<unit)) ? 1 : 0;
-    GLuint msg_type;
-
-    assert(unit < BRW_MAX_TEX_UNIT);
-
-    payload_reg = get_reg(c, PROGRAM_PAYLOAD, PAYLOAD_DEPTH, 0, 1, 0, 0);
-
-    for (i = 0; i < 4; i++) 
-       dst[i] = get_dst_reg(c, inst, i);
-    for (i = 0; i < 4; i++)
-       src[i] = get_src_reg(c, inst, 0, i);
-
-    switch (inst->TexSrcTarget) {
-       case TEXTURE_1D_INDEX:
-           emit = WRITEMASK_X;
-           nr = 1;
-           break;
-       case TEXTURE_2D_INDEX:
-       case TEXTURE_RECT_INDEX:
-           emit = WRITEMASK_XY;
-           nr = 2;
-           break;
-       case TEXTURE_3D_INDEX:
-       case TEXTURE_CUBE_INDEX:
-           emit = WRITEMASK_XYZ;
-           nr = 3;
-           break;
-       default:
-           /* invalid target */
-           abort();
-    }
-    msg_len = 1;
-
-    /* move/load S, T, R coords */
-    for (i = 0; i < nr; i++) {
-       static const GLuint swz[4] = {0,1,2,2};
-       if (emit & (1<<i))
-           brw_MOV(p, brw_message_reg(msg_len+1), src[swz[i]]);
-       else
-           brw_MOV(p, brw_message_reg(msg_len+1), brw_imm_f(0));
-       msg_len += 1;
-    }
-
-    if (shadow) {
-       brw_MOV(p, brw_message_reg(5), brw_imm_f(0));  /* lod / bias */
-       brw_MOV(p, brw_message_reg(6), src[2]);        /* ref value / R coord */
-    }
-
-    if (BRW_IS_IGDNG(p->brw)) {
-        if (shadow)
-            msg_type = BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_COMPARE_IGDNG;
-        else
-            msg_type = BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_IGDNG;
-    } else {
-        /* Does it work for shadow on SIMD8 ? */
-        msg_type = BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE;
-    }
-    
-    brw_SAMPLE(p,
-               retype(vec8(dst[0]), BRW_REGISTER_TYPE_UW), /* dest */
-               1,                                          /* msg_reg_nr */
-               retype(payload_reg, BRW_REGISTER_TYPE_UW),  /* src0 */
-               SURF_INDEX_TEXTURE(unit),
-               unit,                                       /* sampler */
-               inst->DstReg.WriteMask,                     /* writemask */
-               msg_type,                                   /* msg_type */
-               4,                                          /* response_length */
-               shadow ? 6 : 4,                             /* msg_length */
-               0,                                          /* eot */
-               1,
-               BRW_SAMPLER_SIMD_MODE_SIMD8);   
-
-    if (shadow)
-       brw_MOV(p, dst[3], brw_imm_f(1.0));
-}
-
 
 /**
  * Resolve subroutine calls after code emit is done.
@@ -2741,6 +1826,7 @@ get_argument_regs(struct brw_wm_compile *c,
 
 static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c)
 {
+   struct intel_context *intel = &brw->intel;
 #define MAX_IF_DEPTH 32
 #define MAX_LOOP_DEPTH 32
     struct brw_instruction *if_inst[MAX_IF_DEPTH], *loop_inst[MAX_LOOP_DEPTH];
@@ -2771,137 +1857,153 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c)
         if (c->fp->use_const_buffer)
            fetch_constants(c, inst);
 
-       if (inst->CondUpdate)
-           brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
-       else
-           brw_set_conditionalmod(p, BRW_CONDITIONAL_NONE);
+       if (inst->Opcode != OPCODE_ARL) {
+          for (j = 0; j < 4; j++) {
+             if (inst->DstReg.WriteMask & (1 << j))
+                dst[j] = get_dst_reg(c, inst, j);
+             else
+                dst[j] = brw_null_reg();
+          }
+       }
+       for (j = 0; j < brw_wm_nr_args(inst->Opcode); j++)
+           get_argument_regs(c, inst, j, args[j], WRITEMASK_XYZW);
 
        dst_flags = inst->DstReg.WriteMask;
        if (inst->SaturateMode == SATURATE_ZERO_ONE)
            dst_flags |= SATURATE;
 
+       if (inst->CondUpdate)
+           brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
+       else
+           brw_set_conditionalmod(p, BRW_CONDITIONAL_NONE);
+
        switch (inst->Opcode) {
            case WM_PIXELXY:
-               emit_pixel_xy(c, inst);
+               emit_pixel_xy(c, dst, dst_flags);
                break;
            case WM_DELTAXY: 
-               emit_delta_xy(c, inst);
+               emit_delta_xy(p, dst, dst_flags, args[0]);
                break;
            case WM_PIXELW:
-               emit_pixel_w(c, inst);
+               emit_pixel_w(c, dst, dst_flags, args[0], args[1]);
                break;  
            case WM_LINTERP:
-               emit_linterp(c, inst);
+               emit_linterp(p, dst, dst_flags, args[0], args[1]);
                break;
            case WM_PINTERP:
-               emit_pinterp(c, inst);
+               emit_pinterp(p, dst, dst_flags, args[0], args[1], args[2]);
                break;
            case WM_CINTERP:
-               emit_cinterp(c, inst);
+               emit_cinterp(p, dst, dst_flags, args[0]);
                break;
            case WM_WPOSXY:
-               emit_wpos_xy(c, inst);
+               emit_wpos_xy(c, dst, dst_flags, args[0]);
                break;
            case WM_FB_WRITE:
-               emit_fb_write(c, inst);
+               emit_fb_write(c, args[0], args[1], args[2],
+                             INST_AUX_GET_TARGET(inst->Aux),
+                             inst->Aux & INST_AUX_EOT);
                break;
            case WM_FRONTFACING:
-               emit_frontfacing(c, inst);
+               emit_frontfacing(p, dst, dst_flags);
                break;
            case OPCODE_ADD:
-               emit_add(c, inst);
+               emit_alu2(p, brw_ADD, dst, dst_flags, args[0], args[1]);
                break;
            case OPCODE_ARL:
                emit_arl(c, inst);
                break;
            case OPCODE_FRC:
-               emit_frc(c, inst);
+               emit_alu1(p, brw_FRC, dst, dst_flags, args[0]);
                break;
            case OPCODE_FLR:
-               emit_flr(c, inst);
+               emit_alu1(p, brw_RNDD, dst, dst_flags, args[0]);
                break;
            case OPCODE_LRP:
-               emit_lrp(c, inst);
+               unalias3(c, emit_lrp,
+                        dst, dst_flags, args[0], args[1], args[2]);
                break;
            case OPCODE_TRUNC:
-               emit_trunc(c, inst);
+               emit_alu1(p, brw_RNDZ, dst, dst_flags, args[0]);
                break;
            case OPCODE_MOV:
            case OPCODE_SWZ:
-               emit_mov(c, inst);
+               emit_alu1(p, brw_MOV, dst, dst_flags, args[0]);
                break;
            case OPCODE_DP3:
-               emit_dp3(c, inst);
+               emit_dp3(p, dst, dst_flags, args[0], args[1]);
                break;
            case OPCODE_DP4:
-               emit_dp4(c, inst);
+               emit_dp4(p, dst, dst_flags, args[0], args[1]);
                break;
            case OPCODE_XPD:
-               emit_xpd(c, inst);
+               emit_xpd(p, dst, dst_flags, args[0], args[1]);
                break;
            case OPCODE_DPH:
-               emit_dph(c, inst);
+               emit_dph(p, dst, dst_flags, args[0], args[1]);
                break;
            case OPCODE_RCP:
-               emit_rcp(c, inst);
+               emit_math1(c, BRW_MATH_FUNCTION_INV, dst, dst_flags, args[0]);
                break;
            case OPCODE_RSQ:
-               emit_rsq(c, inst);
+               emit_math1(c, BRW_MATH_FUNCTION_RSQ, dst, dst_flags, args[0]);
                break;
            case OPCODE_SIN:
-               emit_sin(c, inst);
+               emit_math1(c, BRW_MATH_FUNCTION_SIN, dst, dst_flags, args[0]);
                break;
            case OPCODE_COS:
-               emit_cos(c, inst);
+               emit_math1(c, BRW_MATH_FUNCTION_COS, dst, dst_flags, args[0]);
                break;
            case OPCODE_EX2:
-               emit_ex2(c, inst);
+               emit_math1(c, BRW_MATH_FUNCTION_EXP, dst, dst_flags, args[0]);
                break;
            case OPCODE_LG2:
-               emit_lg2(c, inst);
+               emit_math1(c, BRW_MATH_FUNCTION_LOG, dst, dst_flags, args[0]);
                break;
            case OPCODE_MIN:    
+               unalias2(c, emit_min, dst, dst_flags, args[0], args[1]);
+               break;
            case OPCODE_MAX:    
-               emit_min_max(c, inst);
+               unalias2(c, emit_max, dst, dst_flags, args[0], args[1]);
                break;
            case OPCODE_DDX:
            case OPCODE_DDY:
-               for (j = 0; j < 4; j++) {
-                   if (inst->DstReg.WriteMask & (1 << j))
-                       dst[j] = get_dst_reg(c, inst, j);
-                   else
-                       dst[j] = brw_null_reg();
-               }
-               get_argument_regs(c, inst, 0, args[0], WRITEMASK_XYZW);
                emit_ddxy(p, dst, dst_flags, (inst->Opcode == OPCODE_DDX),
                          args[0]);
                 break;
            case OPCODE_SLT:
-               emit_slt(c, inst);
+               emit_sop(p, dst, dst_flags,
+                        BRW_CONDITIONAL_L, args[0], args[1]);
                break;
            case OPCODE_SLE:
-               emit_sle(c, inst);
+               emit_sop(p, dst, dst_flags,
+                        BRW_CONDITIONAL_LE, args[0], args[1]);
                break;
            case OPCODE_SGT:
-               emit_sgt(c, inst);
+               emit_sop(p, dst, dst_flags,
+                        BRW_CONDITIONAL_G, args[0], args[1]);
                break;
            case OPCODE_SGE:
-               emit_sge(c, inst);
+               emit_sop(p, dst, dst_flags,
+                        BRW_CONDITIONAL_GE, args[0], args[1]);
                break;
            case OPCODE_SEQ:
-               emit_seq(c, inst);
+               emit_sop(p, dst, dst_flags,
+                        BRW_CONDITIONAL_EQ, args[0], args[1]);
                break;
            case OPCODE_SNE:
-               emit_sne(c, inst);
+               emit_sop(p, dst, dst_flags,
+                        BRW_CONDITIONAL_NEQ, args[0], args[1]);
                break;
            case OPCODE_MUL:
-               emit_mul(c, inst);
+               emit_alu2(p, brw_MUL, dst, dst_flags, args[0], args[1]);
                break;
            case OPCODE_POW:
-               emit_pow(c, inst);
+               emit_math2(c, BRW_MATH_FUNCTION_POW,
+                          dst, dst_flags, args[0], args[1]);
                break;
            case OPCODE_MAD:
-               emit_mad(c, inst);
+               emit_mad(p, dst, dst_flags, args[0], args[1], args[2]);
                break;
            case OPCODE_NOISE1:
                emit_noise1(c, inst);
@@ -2916,10 +2018,19 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c)
                emit_noise4(c, inst);
                break;
            case OPCODE_TEX:
-               emit_tex(c, inst);
+               emit_tex(c, dst, dst_flags, args[0],
+                        get_reg(c, PROGRAM_PAYLOAD, PAYLOAD_DEPTH,
+                                0, 1, 0, 0),
+                        inst->TexSrcTarget,
+                        inst->TexSrcUnit,
+                        (c->key.shadowtex_mask & (1 << inst->TexSrcUnit)) != 0);
                break;
            case OPCODE_TXB:
-               emit_txb(c, inst);
+               emit_txb(c, dst, dst_flags, args[0],
+                        get_reg(c, PROGRAM_PAYLOAD, PAYLOAD_DEPTH,
+                                0, 1, 0, 0),
+                        inst->TexSrcTarget,
+                        c->fp->program.Base.SamplerUnits[inst->TexSrcUnit]);
                break;
            case OPCODE_KIL_NV:
                emit_kil(c);
@@ -2929,6 +2040,7 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c)
                if_inst[if_depth++] = brw_IF(p, BRW_EXECUTE_8);
                break;
            case OPCODE_ELSE:
+               assert(if_depth > 0);
                if_inst[if_depth-1]  = brw_ELSE(p, if_inst[if_depth-1]);
                break;
            case OPCODE_ENDIF:
@@ -2982,9 +2094,10 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c)
                   struct brw_instruction *inst0, *inst1;
                   GLuint br = 1;
 
-                  if (BRW_IS_IGDNG(brw))
+                  if (intel->is_ironlake)
                      br = 2;
+
+                 assert(loop_depth > 0);
                   loop_depth--;
                   inst0 = inst1 = brw_WHILE(p, loop_inst[loop_depth]);
                   /* patch all the BREAK/CONT instructions from last BGNLOOP */
index 627925833963aed36e2985608dcb2c2c9e6cb909..ff4c082d5e8f3cd3ca8761ce32b3d862de605f19 100644 (file)
 static struct brw_wm_ref *get_ref( struct brw_wm_compile *c )
 {
    assert(c->nr_refs < BRW_WM_MAX_REF);
+   memset(&c->refs[c->nr_refs], 0, sizeof(*c->refs));
    return &c->refs[c->nr_refs++];
 }
 
 static struct brw_wm_value *get_value( struct brw_wm_compile *c)
 {
    assert(c->nr_refs < BRW_WM_MAX_VREG);
+   memset(&c->vreg[c->nr_vreg], 0, sizeof(*c->vreg));
    return &c->vreg[c->nr_vreg++];
 }
 
@@ -55,6 +57,7 @@ static struct brw_wm_value *get_value( struct brw_wm_compile *c)
 static struct brw_wm_instruction *get_instruction( struct brw_wm_compile *c )
 {
    assert(c->nr_insns < BRW_WM_MAX_INSN);
+   memset(&c->instruction[c->nr_insns], 0, sizeof(*c->instruction));
    return &c->instruction[c->nr_insns++];
 }
 
@@ -322,8 +325,8 @@ translate_insn(struct brw_wm_compile *c,
    out->tex_unit = inst->TexSrcUnit;
    out->tex_idx = inst->TexSrcTarget;
    out->tex_shadow = inst->TexShadow;
-   out->eot = inst->Aux & 1;
-   out->target = inst->Aux >> 1;
+   out->eot = inst->Aux & INST_AUX_EOT;
+   out->target = INST_AUX_GET_TARGET(inst->Aux);
 
    /* Args:
     */
index 6faea018fbcddfa09c354c14845bd2848aa26a61..31303febf09142ba621cddbbeda2285158b41606 100644 (file)
@@ -82,8 +82,8 @@ static void init_registers( struct brw_wm_compile *c )
    for (j = 0; j < c->nr_creg; j++) 
       prealloc_reg(c, &c->creg[j], i++);
 
-   for (j = 0; j < FRAG_ATTRIB_MAX; j++) {
-      if (c->key.vp_outputs_written & (1<<j)) {
+   for (j = 0; j < VERT_RESULT_MAX; j++) {
+      if (c->key.vp_outputs_written & BITFIELD64_BIT(j)) {
         int fp_index;
 
         if (j >= VERT_RESULT_VAR0)
index dff466587a8df8c36640bffe132f1d644ff3148f..ad267a4e6aef554041e0fc3393caa07d316d6f4c 100644 (file)
@@ -66,19 +66,6 @@ static GLuint translate_wrap_mode( GLenum wrap )
    }
 }
 
-
-static GLuint U_FIXED(GLfloat value, GLuint frac_bits)
-{
-   value *= (1<<frac_bits);
-   return value < 0 ? 0 : value;
-}
-
-static GLint S_FIXED(GLfloat value, GLuint frac_bits)
-{
-   return value * (1<<frac_bits);
-}
-
-
 static dri_bo *upload_default_color( struct brw_context *brw,
                                     const GLfloat *color )
 {
@@ -86,8 +73,8 @@ static dri_bo *upload_default_color( struct brw_context *brw,
 
    COPY_4V(sdc.color, color); 
    
-   return brw_cache_data( &brw->cache, BRW_SAMPLER_DEFAULT_COLOR, &sdc,
-                         NULL, 0 );
+   return brw_cache_data(&brw->cache, BRW_SAMPLER_DEFAULT_COLOR,
+                        &sdc, sizeof(sdc), NULL, 0);
 }
 
 
@@ -228,8 +215,8 @@ static void brw_update_sampler_state(struct wm_sampler_entry *key,
     */
    sampler->ss0.base_level = U_FIXED(0, 1);
 
-   sampler->ss1.max_lod = U_FIXED(MIN2(MAX2(key->maxlod, 0), 13), 6);
-   sampler->ss1.min_lod = U_FIXED(MIN2(MAX2(key->minlod, 0), 13), 6);
+   sampler->ss1.max_lod = U_FIXED(CLAMP(key->maxlod, 0, 13), 6);
+   sampler->ss1.min_lod = U_FIXED(CLAMP(key->minlod, 0, 13), 6);
    
    sampler->ss2.default_color_pointer = sdc_bo->offset >> 5; /* reloc */
 }
@@ -275,10 +262,10 @@ brw_wm_sampler_populate_key(struct brw_context *brw,
         dri_bo_unreference(brw->wm.sdc_bo[unit]);
         if (firstImage->_BaseFormat == GL_DEPTH_COMPONENT) {
            float bordercolor[4] = {
-              texObj->BorderColor[0],
-              texObj->BorderColor[0],
-              texObj->BorderColor[0],
-              texObj->BorderColor[0]
+              texObj->BorderColor.f[0],
+              texObj->BorderColor.f[0],
+              texObj->BorderColor.f[0],
+              texObj->BorderColor.f[0]
            };
            /* GL specs that border color for depth textures is taken from the
             * R channel, while the hardware uses A.  Spam R into all the
@@ -287,7 +274,7 @@ brw_wm_sampler_populate_key(struct brw_context *brw,
            brw->wm.sdc_bo[unit] = upload_default_color(brw, bordercolor);
         } else {
            brw->wm.sdc_bo[unit] = upload_default_color(brw,
-                                                       texObj->BorderColor);
+                                                       texObj->BorderColor.f);
         }
         key->sampler_count = unit + 1;
       }
index 361f91292bec0a51221819a323907c34f8870a71..d3373ea79e80fb9b333adc3ad8da01b8f992ef39 100644 (file)
@@ -49,8 +49,6 @@ struct brw_wm_unit_key {
    unsigned int curbe_offset;
    unsigned int urb_size;
 
-   unsigned int max_threads;
-
    unsigned int nr_surfaces, sampler_count;
    GLboolean uses_depth, computes_depth, uses_kill, is_glsl;
    GLboolean polygon_stipple, stats_wm, line_stipple, offset_enable;
@@ -67,18 +65,6 @@ wm_unit_populate_key(struct brw_context *brw, struct brw_wm_unit_key *key)
 
    memset(key, 0, sizeof(*key));
 
-   if (INTEL_DEBUG & DEBUG_SINGLE_THREAD)
-      key->max_threads = 1;
-   else {
-      /* WM maximum threads is number of EUs times number of threads per EU. */
-      if (BRW_IS_IGDNG(brw))
-         key->max_threads = 12 * 6;
-      else if (BRW_IS_G4X(brw))
-        key->max_threads = 10 * 5;
-      else
-        key->max_threads = 8 * 4;
-   }
-
    /* CACHE_NEW_WM_PROG */
    key->total_grf = brw->wm.prog_data->total_grf;
    key->urb_entry_read_length = brw->wm.prog_data->urb_read_length;
@@ -106,7 +92,7 @@ wm_unit_populate_key(struct brw_context *brw, struct brw_wm_unit_key *key)
 
    /* as far as we can tell */
    key->computes_depth =
-      (fp->Base.OutputsWritten & (1 << FRAG_RESULT_DEPTH)) != 0;
+      (fp->Base.OutputsWritten & BITFIELD64_BIT(FRAG_RESULT_DEPTH)) != 0;
    /* BRW_NEW_DEPTH_BUFFER
     * Override for NULL depthbuffer case, required by the Pixel Shader Computed
     * Depth field.
@@ -140,6 +126,7 @@ static dri_bo *
 wm_unit_create_from_key(struct brw_context *brw, struct brw_wm_unit_key *key,
                        dri_bo **reloc_bufs)
 {
+   struct intel_context *intel = &brw->intel;
    struct brw_wm_unit_state wm;
    dri_bo *bo;
 
@@ -150,7 +137,7 @@ wm_unit_create_from_key(struct brw_context *brw, struct brw_wm_unit_key *key,
    wm.thread1.depth_coef_urb_read_offset = 1;
    wm.thread1.floating_point_mode = BRW_FLOATING_POINT_NON_IEEE_754;
 
-   if (BRW_IS_IGDNG(brw))
+   if (intel->is_ironlake)
       wm.thread1.binding_table_entry_count = 0; /* hardware requirement */
    else
       wm.thread1.binding_table_entry_count = key->nr_surfaces;
@@ -170,7 +157,7 @@ wm_unit_create_from_key(struct brw_context *brw, struct brw_wm_unit_key *key,
    wm.thread3.const_urb_entry_read_length = key->curb_entry_read_length;
    wm.thread3.const_urb_entry_read_offset = key->curbe_offset * 2;
 
-   if (BRW_IS_IGDNG(brw)) 
+   if (intel->is_ironlake)
       wm.wm4.sampler_count = 0; /* hardware requirement */
    else
       wm.wm4.sampler_count = (key->sampler_count + 1) / 4;
@@ -191,7 +178,7 @@ wm_unit_create_from_key(struct brw_context *brw, struct brw_wm_unit_key *key,
    else
       wm.wm5.enable_16_pix = 1;
 
-   wm.wm5.max_threads = key->max_threads - 1;
+   wm.wm5.max_threads = brw->wm_max_threads - 1;
    wm.wm5.thread_dispatch_enable = 1;  /* AKA: color_write */
    wm.wm5.legacy_line_rast = 0;
    wm.wm5.legacy_global_depth_bias = 0;
@@ -268,7 +255,7 @@ static void upload_wm_unit( struct brw_context *brw )
     */
    assert(key.total_scratch <= 12 * 1024);
    if (key.total_scratch) {
-      GLuint total = key.total_scratch * key.max_threads;
+      GLuint total = key.total_scratch * brw->wm_max_threads;
 
       if (brw->wm.scratch_bo && total > brw->wm.scratch_bo->size) {
         dri_bo_unreference(brw->wm.scratch_bo);
index 9c28a22a2989843734117046c34b321430fbed87..f26cfabb7dfcda899d15fa9a6efed5f067f1fdf4 100644 (file)
@@ -31,7 +31,6 @@
                    
 
 #include "main/mtypes.h"
-#include "main/texformat.h"
 #include "main/texstore.h"
 #include "shader/prog_parameter.h"
 
@@ -70,7 +69,8 @@ static GLuint translate_tex_target( GLenum target )
 }
 
 
-static GLuint translate_tex_format( GLuint mesa_format, GLenum internal_format,
+static GLuint translate_tex_format( gl_format mesa_format,
+                                    GLenum internal_format,
                                    GLenum depth_mode )
 {
    switch( mesa_format ) {
@@ -86,21 +86,22 @@ static GLuint translate_tex_format( GLuint mesa_format, GLenum internal_format,
    case MESA_FORMAT_AL88:
       return BRW_SURFACEFORMAT_L8A8_UNORM;
 
+   case MESA_FORMAT_AL1616:
+      return BRW_SURFACEFORMAT_L16A16_UNORM;
+
    case MESA_FORMAT_RGB888:
       assert(0);               /* not supported for sampling */
       return BRW_SURFACEFORMAT_R8G8B8_UNORM;      
 
    case MESA_FORMAT_ARGB8888:
-      if (internal_format == GL_RGB)
-        return BRW_SURFACEFORMAT_B8G8R8X8_UNORM;
-      else
-        return BRW_SURFACEFORMAT_B8G8R8A8_UNORM;
+      return BRW_SURFACEFORMAT_B8G8R8A8_UNORM;
+
+   case MESA_FORMAT_XRGB8888:
+      return BRW_SURFACEFORMAT_B8G8R8X8_UNORM;
 
    case MESA_FORMAT_RGBA8888_REV:
-      if (internal_format == GL_RGB)
-        return BRW_SURFACEFORMAT_R8G8B8X8_UNORM;
-      else
-        return BRW_SURFACEFORMAT_R8G8B8A8_UNORM;
+      _mesa_problem(NULL, "unexpected format in i965:translate_tex_format()");
+      return BRW_SURFACEFORMAT_R8G8B8A8_UNORM;
 
    case MESA_FORMAT_RGB565:
       return BRW_SURFACEFORMAT_B5G6R5_UNORM;
@@ -287,7 +288,7 @@ brw_update_texture_surface( GLcontext *ctx, GLuint unit )
       key.bo = NULL;
       key.offset = intelObj->textureOffset;
    } else {
-      key.format = firstImage->TexFormat->MesaFormat;
+      key.format = firstImage->TexFormat;
       key.internal_format = firstImage->InternalFormat;
       key.pitch = intelObj->mt->pitch;
       key.depth = firstImage->Depth;
@@ -354,7 +355,10 @@ brw_create_constant_surface( struct brw_context *brw,
                         NULL, NULL);
 
    if (key->bo) {
-      /* Emit relocation to surface contents */
+      /* Emit relocation to surface contents.  Section 5.1.1 of the gen4
+       * bspec ("Data Cache") says that the data cache does not exist as
+       * a separate cache and is just the sampler cache.
+       */
       dri_bo_emit_reloc(bo,
                        I915_GEM_DOMAIN_SAMPLER, 0,
                        0,
@@ -507,7 +511,8 @@ brw_update_renderbuffer_surface(struct brw_context *brw,
                                struct gl_renderbuffer *rb,
                                unsigned int unit)
 {
-   GLcontext *ctx = &brw->intel.ctx;
+   struct intel_context *intel = &brw->intel;;
+   GLcontext *ctx = &intel->ctx;
    dri_bo *region_bo = NULL;
    struct intel_renderbuffer *irb = intel_renderbuffer(rb);
    struct intel_region *region = irb ? irb->region : NULL;
@@ -518,7 +523,8 @@ brw_update_renderbuffer_surface(struct brw_context *brw,
       GLubyte color_mask[4];
       GLboolean color_blend;
       uint32_t tiling;
-      uint32_t draw_offset;
+      uint32_t draw_x;
+      uint32_t draw_y;
    } key;
 
    memset(&key, 0, sizeof(key));
@@ -527,8 +533,15 @@ brw_update_renderbuffer_surface(struct brw_context *brw,
       region_bo = region->buffer;
 
       key.surface_type = BRW_SURFACE_2D;
-      switch (irb->texformat->MesaFormat) {
+      switch (irb->Base.Format) {
+      /* XRGB and ARGB are treated the same here because the chips in this
+       * family cannot render to XRGB targets.  This means that we have to
+       * mask writes to alpha (ala glColorMask) and reconfigure the alpha
+       * blending hardware to use GL_ONE (or GL_ZERO) for cases where
+       * GL_DST_ALPHA (or GL_ONE_MINUS_DST_ALPHA) is used.
+       */
       case MESA_FORMAT_ARGB8888:
+      case MESA_FORMAT_XRGB8888:
         key.surface_format = BRW_SURFACEFORMAT_B8G8R8A8_UNORM;
         break;
       case MESA_FORMAT_RGB565:
@@ -541,8 +554,7 @@ brw_update_renderbuffer_surface(struct brw_context *brw,
         key.surface_format = BRW_SURFACEFORMAT_B4G4R4A4_UNORM;
         break;
       default:
-        _mesa_problem(ctx, "Bad renderbuffer format: %d\n",
-                      irb->texformat->MesaFormat);
+        _mesa_problem(ctx, "Bad renderbuffer format: %d\n", irb->Base.Format);
       }
       key.tiling = region->tiling;
       if (brw->intel.intelScreen->driScrnPriv->dri2.enabled) {
@@ -554,7 +566,8 @@ brw_update_renderbuffer_surface(struct brw_context *brw,
       }
       key.pitch = region->pitch;
       key.cpp = region->cpp;
-      key.draw_offset = region->draw_offset; /* cur 3d or cube face offset */
+      key.draw_x = region->draw_x;
+      key.draw_y = region->draw_y;
    } else {
       key.surface_type = BRW_SURFACE_NULL;
       key.surface_format = BRW_SURFACEFORMAT_B8G8R8A8_UNORM;
@@ -562,10 +575,19 @@ brw_update_renderbuffer_surface(struct brw_context *brw,
       key.width = 1;
       key.height = 1;
       key.cpp = 4;
-      key.draw_offset = 0;
+      key.draw_x = 0;
+      key.draw_y = 0;
    }
-   memcpy(key.color_mask, ctx->Color.ColorMask,
+   /* _NEW_COLOR */
+   memcpy(key.color_mask, ctx->Color.ColorMask[0],
          sizeof(key.color_mask));
+
+   /* As mentioned above, disable writes to the alpha component when the
+    * renderbuffer is XRGB.
+    */
+   if (ctx->DrawBuffer->Visual.alphaBits == 0)
+     key.color_mask[3] = GL_FALSE;
+
    key.color_blend = (!ctx->Color._LogicOpEnabled &&
                      ctx->Color.BlendEnabled);
 
@@ -584,25 +606,32 @@ brw_update_renderbuffer_surface(struct brw_context *brw,
       surf.ss0.surface_format = key.surface_format;
       surf.ss0.surface_type = key.surface_type;
       if (key.tiling == I915_TILING_NONE) {
-        surf.ss1.base_addr = key.draw_offset;
+        surf.ss1.base_addr = (key.draw_x + key.draw_y * key.pitch) * key.cpp;
       } else {
-        uint32_t tile_offset = key.draw_offset % 4096;
-
-        surf.ss1.base_addr = key.draw_offset - tile_offset;
-
-        assert(BRW_IS_G4X(brw) || tile_offset == 0);
-        if (BRW_IS_G4X(brw)) {
-           if (key.tiling == I915_TILING_X) {
-              /* Note that the low bits of these fields are missing, so
-               * there's the possibility of getting in trouble.
-               */
-              surf.ss5.x_offset = (tile_offset % 512) / key.cpp / 4;
-              surf.ss5.y_offset = tile_offset / 512 / 2;
-           } else {
-              surf.ss5.x_offset = (tile_offset % 128) / key.cpp / 4;
-              surf.ss5.y_offset = tile_offset / 128 / 2;
-           }
+        uint32_t tile_base, tile_x, tile_y;
+        uint32_t pitch = key.pitch * key.cpp;
+
+        if (key.tiling == I915_TILING_X) {
+           tile_x = key.draw_x % (512 / key.cpp);
+           tile_y = key.draw_y % 8;
+           tile_base = ((key.draw_y / 8) * (8 * pitch));
+           tile_base += (key.draw_x - tile_x) / (512 / key.cpp) * 4096;
+        } else {
+           /* Y */
+           tile_x = key.draw_x % (128 / key.cpp);
+           tile_y = key.draw_y % 32;
+           tile_base = ((key.draw_y / 32) * (32 * pitch));
+           tile_base += (key.draw_x - tile_x) / (128 / key.cpp) * 4096;
         }
+        assert(intel->is_g4x || (tile_x == 0 && tile_y == 0));
+        assert(tile_x % 4 == 0);
+        assert(tile_y % 2 == 0);
+        /* Note that the low bits of these fields are missing, so
+         * there's the possibility of getting in trouble.
+         */
+        surf.ss1.base_addr = tile_base;
+        surf.ss5.x_offset = tile_x / 4;
+        surf.ss5.y_offset = tile_y / 2;
       }
       if (region_bo != NULL)
         surf.ss1.base_addr += region_bo->offset; /* reloc */
@@ -693,11 +722,10 @@ brw_wm_get_binding_table(struct brw_context *brw)
 static void prepare_wm_surfaces(struct brw_context *brw )
 {
    GLcontext *ctx = &brw->intel.ctx;
-   struct intel_context *intel = &brw->intel;
    GLuint i;
    int old_nr_surfaces;
 
-   /* _NEW_BUFFERS */
+   /* _NEW_BUFFERS | _NEW_COLOR */
    /* Update surfaces for drawing buffers */
    if (ctx->DrawBuffer->_NumColorDrawBuffers >= 1) {
       for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {
@@ -710,7 +738,7 @@ static void prepare_wm_surfaces(struct brw_context *brw )
    }
 
    old_nr_surfaces = brw->wm.nr_surfaces;
-   brw->wm.nr_surfaces = MAX_DRAW_BUFFERS;
+   brw->wm.nr_surfaces = BRW_MAX_DRAW_BUFFERS;
 
    if (brw->wm.surf_bo[SURF_INDEX_FRAG_CONST_BUFFER] != NULL)
        brw->wm.nr_surfaces = SURF_INDEX_FRAG_CONST_BUFFER + 1;
diff --git a/src/mesa/drivers/dri/i965/intel_swapbuffers.c b/src/mesa/drivers/dri/i965/intel_swapbuffers.c
deleted file mode 120000 (symlink)
index 148d521..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../intel/intel_swapbuffers.c
\ No newline at end of file
index 6aa36d10b1203c34c74fce7d439de8ec2ed07cfb..3a4b21a844fd89edffcf37083c85de88bbda760d 100644 (file)
@@ -80,7 +80,7 @@ intel_batchbuffer_reset(struct intel_batchbuffer *batch)
       batch->buf = NULL;
    }
 
-   if (!batch->buffer && intel->ttm == GL_TRUE)
+   if (!batch->buffer)
       batch->buffer = malloc (intel->maxBatchSize);
 
    batch->buf = dri_bo_alloc(intel->bufmgr, "batchbuffer",
@@ -94,7 +94,6 @@ intel_batchbuffer_reset(struct intel_batchbuffer *batch)
    batch->size = intel->maxBatchSize;
    batch->ptr = batch->map;
    batch->dirty_state = ~0;
-   batch->cliprect_mode = IGNORE_CLIPRECTS;
 }
 
 struct intel_batchbuffer *
@@ -129,13 +128,10 @@ intel_batchbuffer_free(struct intel_batchbuffer *batch)
 /* TODO: Push this whole function into bufmgr.
  */
 static void
-do_flush_locked(struct intel_batchbuffer *batch,
-               GLuint used, GLboolean allow_unlock)
+do_flush_locked(struct intel_batchbuffer *batch, GLuint used)
 {
    struct intel_context *intel = batch->intel;
    int ret = 0;
-   unsigned int num_cliprects = 0;
-   struct drm_clip_rect *cliprects = NULL;
    int x_off = 0, y_off = 0;
 
    if (batch->buffer)
@@ -146,31 +142,7 @@ do_flush_locked(struct intel_batchbuffer *batch,
    batch->map = NULL;
    batch->ptr = NULL;
 
-
-   if (batch->cliprect_mode == LOOP_CLIPRECTS) {
-      intel_get_cliprects(intel, &cliprects, &num_cliprects, &x_off, &y_off);
-   }
-   /* Dispatch the batchbuffer, if it has some effect (nonzero cliprects).
-    * Can't short-circuit like this once we have hardware contexts, but we
-    * should always be in DRI2 mode by then anyway.
-    */
-   if ((batch->cliprect_mode != LOOP_CLIPRECTS ||
-       num_cliprects != 0) && !intel->no_hw) {
-      dri_bo_exec(batch->buf, used, cliprects, num_cliprects,
-                 (x_off & 0xffff) | (y_off << 16));
-   }
-
-   if (batch->cliprect_mode == LOOP_CLIPRECTS && num_cliprects == 0) {
-      if (allow_unlock) {
-        /* If we are not doing any actual user-visible rendering,
-         * do a sched_yield to keep the app from pegging the cpu while
-         * achieving nothing.
-         */
-         UNLOCK_HARDWARE(intel);
-         sched_yield();
-         LOCK_HARDWARE(intel);
-      }
-   }
+   dri_bo_exec(batch->buf, used, NULL, 0, (x_off & 0xffff) | (y_off << 16));
 
    if (INTEL_DEBUG & DEBUG_BATCH) {
       dri_bo_map(batch->buf, GL_FALSE);
@@ -183,7 +155,6 @@ do_flush_locked(struct intel_batchbuffer *batch,
    }
 
    if (ret != 0) {
-      UNLOCK_HARDWARE(intel);
       exit(1);
    }
    intel->vtbl.new_batch(intel);
@@ -201,24 +172,17 @@ _intel_batchbuffer_flush(struct intel_batchbuffer *batch, const char *file,
       drm_intel_bo_reference(intel->first_post_swapbuffers_batch);
    }
 
-   if (intel->first_post_swapbuffers_batch == NULL) {
-      intel->first_post_swapbuffers_batch = intel->batch->buf;
-      drm_intel_bo_reference(intel->first_post_swapbuffers_batch);
-   }
-
-   if (used == 0) {
-      batch->cliprect_mode = IGNORE_CLIPRECTS;
+   if (used == 0)
       return;
-   }
 
    if (INTEL_DEBUG & DEBUG_BATCH)
       fprintf(stderr, "%s:%d: Batchbuffer flush with %db used\n", file, line,
              used);
 
+   batch->reserved_space = 0;
    /* Emit a flush if the bufmgr doesn't do it for us. */
-   if (intel->always_flush_cache || !intel->ttm) {
-      *(GLuint *) (batch->ptr) = intel->vtbl.flush_cmd();
-      batch->ptr += 4;
+   if (intel->always_flush_cache) {
+      intel_batchbuffer_emit_mi_flush(batch);
       used = batch->ptr - batch->map;
    }
 
@@ -249,12 +213,15 @@ _intel_batchbuffer_flush(struct intel_batchbuffer *batch, const char *file,
    if (intel->vtbl.finish_batch)
       intel->vtbl.finish_batch(intel);
 
+   /* Check that we didn't just wrap our batchbuffer at a bad time. */
+   assert(!intel->no_batch_wrap);
+
+   batch->reserved_space = BATCH_RESERVED;
+
    /* TODO: Just pass the relocation list and dma buffer up to the
     * kernel.
     */
-   LOCK_HARDWARE(intel);
-   do_flush_locked(batch, used, GL_FALSE);
-   UNLOCK_HARDWARE(intel);
+   do_flush_locked(batch, used);
 
    if (INTEL_DEBUG & DEBUG_SYNC) {
       fprintf(stderr, "waiting for idle\n");
@@ -296,11 +263,38 @@ intel_batchbuffer_emit_reloc(struct intel_batchbuffer *batch,
 
 void
 intel_batchbuffer_data(struct intel_batchbuffer *batch,
-                       const void *data, GLuint bytes,
-                      enum cliprect_mode cliprect_mode)
+                       const void *data, GLuint bytes)
 {
    assert((bytes & 3) == 0);
-   intel_batchbuffer_require_space(batch, bytes, cliprect_mode);
+   intel_batchbuffer_require_space(batch, bytes);
    __memcpy(batch->ptr, data, bytes);
    batch->ptr += bytes;
 }
+
+/* Emit a pipelined flush to either flush render and texture cache for
+ * reading from a FBO-drawn texture, or flush so that frontbuffer
+ * render appears on the screen in DRI1.
+ *
+ * This is also used for the always_flush_cache driconf debug option.
+ */
+void
+intel_batchbuffer_emit_mi_flush(struct intel_batchbuffer *batch)
+{
+   struct intel_context *intel = batch->intel;
+
+   if (intel->gen >= 4) {
+      BEGIN_BATCH(4);
+      OUT_BATCH(_3DSTATE_PIPE_CONTROL |
+               PIPE_CONTROL_INSTRUCTION_FLUSH |
+               PIPE_CONTROL_WRITE_FLUSH |
+               PIPE_CONTROL_NO_WRITE);
+      OUT_BATCH(0); /* write address */
+      OUT_BATCH(0); /* write data */
+      OUT_BATCH(0); /* write data */
+      ADVANCE_BATCH();
+   } else {
+      BEGIN_BATCH(1);
+      OUT_BATCH(MI_FLUSH);
+      ADVANCE_BATCH();
+   }
+}
index 9a619fbd5cfdf771371d42f5e0d43e5ad4cc00d8..b052b724d8425e9140a0a4477b42943aeff965d9 100644 (file)
 #define BATCH_SZ 16384
 #define BATCH_RESERVED 16
 
-enum cliprect_mode {
-   /**
-    * Batchbuffer contents may be looped over per cliprect, but do not
-    * require it.
-    */
-   IGNORE_CLIPRECTS,
-   /**
-    * Batchbuffer contents require looping over per cliprect at batch submit
-    * time.
-    *
-    * This will be upgraded to NO_LOOP_CLIPRECTS when there's a single
-    * constant cliprect, as in DRI2 or FBO rendering.
-    */
-   LOOP_CLIPRECTS,
-   /**
-    * Batchbuffer contents contain drawing that should not be executed multiple
-    * times.
-    */
-   NO_LOOP_CLIPRECTS,
-   /**
-    * Batchbuffer contents contain drawing that already handles cliprects, such
-    * as 2D drawing to front/back/depth that doesn't respect DRAWING_RECTANGLE.
-    *
-    * Equivalent behavior to NO_LOOP_CLIPRECTS, but may not persist in batch
-    * outside of LOCK/UNLOCK.  This is upgraded to just NO_LOOP_CLIPRECTS when
-    * there's a constant cliprect, as in DRI2 or FBO rendering.
-    */
-   REFERENCES_CLIPRECTS
-};
 
 struct intel_batchbuffer
 {
@@ -51,8 +22,6 @@ struct intel_batchbuffer
    GLubyte *map;
    GLubyte *ptr;
 
-   enum cliprect_mode cliprect_mode;
-
    GLuint size;
 
    /** Tracking of BEGIN_BATCH()/OUT_BATCH()/ADVANCE_BATCH() debugging */
@@ -62,6 +31,7 @@ struct intel_batchbuffer
    } emit;
 
    GLuint dirty_state;
+   GLuint reserved_space;
 };
 
 struct intel_batchbuffer *intel_batchbuffer_alloc(struct intel_context
@@ -84,8 +54,7 @@ void intel_batchbuffer_reset(struct intel_batchbuffer *batch);
  * intel_buffer_dword() calls.
  */
 void intel_batchbuffer_data(struct intel_batchbuffer *batch,
-                            const void *data, GLuint bytes,
-                           enum cliprect_mode cliprect_mode);
+                            const void *data, GLuint bytes);
 
 void intel_batchbuffer_release_space(struct intel_batchbuffer *batch,
                                      GLuint bytes);
@@ -95,6 +64,7 @@ GLboolean intel_batchbuffer_emit_reloc(struct intel_batchbuffer *batch,
                                       uint32_t read_domains,
                                       uint32_t write_domain,
                                       uint32_t offset);
+void intel_batchbuffer_emit_mi_flush(struct intel_batchbuffer *batch);
 
 /* Inline functions - might actually be better off with these
  * non-inlined.  Certainly better off switching all command packets to
@@ -104,7 +74,7 @@ GLboolean intel_batchbuffer_emit_reloc(struct intel_batchbuffer *batch,
 static INLINE GLint
 intel_batchbuffer_space(struct intel_batchbuffer *batch)
 {
-   return (batch->size - BATCH_RESERVED) - (batch->ptr - batch->map);
+   return (batch->size - batch->reserved_space) - (batch->ptr - batch->map);
 }
 
 
@@ -119,36 +89,19 @@ intel_batchbuffer_emit_dword(struct intel_batchbuffer *batch, GLuint dword)
 
 static INLINE void
 intel_batchbuffer_require_space(struct intel_batchbuffer *batch,
-                                GLuint sz,
-                               enum cliprect_mode cliprect_mode)
+                                GLuint sz)
 {
    assert(sz < batch->size - 8);
    if (intel_batchbuffer_space(batch) < sz)
       intel_batchbuffer_flush(batch);
-
-   if ((cliprect_mode == LOOP_CLIPRECTS ||
-       cliprect_mode == REFERENCES_CLIPRECTS) &&
-       batch->intel->constant_cliprect)
-      cliprect_mode = NO_LOOP_CLIPRECTS;
-
-   if (cliprect_mode != IGNORE_CLIPRECTS) {
-      if (batch->cliprect_mode == IGNORE_CLIPRECTS) {
-        batch->cliprect_mode = cliprect_mode;
-      } else {
-        if (batch->cliprect_mode != cliprect_mode) {
-           intel_batchbuffer_flush(batch);
-           batch->cliprect_mode = cliprect_mode;
-        }
-      }
-   }
 }
 
 /* Here are the crusty old macros, to be removed:
  */
 #define BATCH_LOCALS
 
-#define BEGIN_BATCH(n, cliprect_mode) do {                             \
-   intel_batchbuffer_require_space(intel->batch, (n)*4, cliprect_mode); \
+#define BEGIN_BATCH(n) do {                            \
+   intel_batchbuffer_require_space(intel->batch, (n)*4); \
    assert(intel->batch->emit.start_ptr == NULL);                       \
    intel->batch->emit.total = (n) * 4;                                 \
    intel->batch->emit.start_ptr = intel->batch->ptr;                   \
@@ -157,7 +110,7 @@ intel_batchbuffer_require_space(struct intel_batchbuffer *batch,
 #define OUT_BATCH(d) intel_batchbuffer_emit_dword(intel->batch, d)
 
 #define OUT_RELOC(buf, read_domains, write_domain, delta) do {         \
-   assert((unsigned) (delta) <= buf->size);                            \
+   assert((unsigned) (delta) < buf->size);                             \
    intel_batchbuffer_emit_reloc(intel->batch, buf,                     \
                                read_domains, write_domain, delta);     \
 } while (0)
@@ -173,12 +126,4 @@ intel_batchbuffer_require_space(struct intel_batchbuffer *batch,
    intel->batch->emit.start_ptr = NULL;                                        \
 } while(0)
 
-
-static INLINE void
-intel_batchbuffer_emit_mi_flush(struct intel_batchbuffer *batch)
-{
-   intel_batchbuffer_require_space(batch, 4, IGNORE_CLIPRECTS);
-   intel_batchbuffer_emit_dword(batch, MI_FLUSH);
-}
-
 #endif
index 9e114db6c7823ca0fa4f7a7c3616e385510c9e00..55bee0084c175ae08cdc7329a04d2405d49efcde 100644 (file)
@@ -29,7 +29,6 @@
 #include "main/mtypes.h"
 #include "main/context.h"
 #include "main/enums.h"
-#include "main/texformat.h"
 #include "main/colormac.h"
 
 #include "intel_blit.h"
 
 #define FILE_DEBUG_FLAG DEBUG_BLIT
 
-/**
- * Copy the back color buffer to the front color buffer. 
- * Used for SwapBuffers().
- */
-void
-intelCopyBuffer(const __DRIdrawablePrivate * dPriv,
-                const drm_clip_rect_t * rect)
-{
-
-   struct intel_context *intel;
-   const intelScreenPrivate *intelScreen;
-
-   DBG("%s\n", __FUNCTION__);
-
-   assert(dPriv);
-
-   intel = intelScreenContext(dPriv->driScreenPriv->private);
-   if (!intel)
-      return;
-
-   intelScreen = intel->intelScreen;
-
-   /* The LOCK_HARDWARE is required for the cliprects.  Buffer offsets
-    * should work regardless.
-    */
-   LOCK_HARDWARE(intel);
-
-   if (dPriv && dPriv->numClipRects) {
-      struct intel_framebuffer *intel_fb = dPriv->driverPrivate;
-      struct intel_region *src, *dst;
-      int nbox = dPriv->numClipRects;
-      drm_clip_rect_t *pbox = dPriv->pClipRects;
-      int cpp;
-      int src_pitch, dst_pitch;
-      unsigned short src_x, src_y;
-      int BR13, CMD;
-      int i;
-      dri_bo *aper_array[3];
-
-      src = intel_get_rb_region(&intel_fb->Base, BUFFER_BACK_LEFT);
-      dst = intel_get_rb_region(&intel_fb->Base, BUFFER_FRONT_LEFT);
-
-      src_pitch = src->pitch * src->cpp;
-      dst_pitch = dst->pitch * dst->cpp;
-
-      cpp = src->cpp;
-
-      ASSERT(intel_fb);
-      ASSERT(intel_fb->Base.Name == 0);    /* Not a user-created FBO */
-      ASSERT(src);
-      ASSERT(dst);
-      ASSERT(src->cpp == dst->cpp);
-
-      if (cpp == 2) {
-        BR13 = (0xCC << 16) | BR13_565;
-        CMD = XY_SRC_COPY_BLT_CMD;
-      }
-      else {
-        BR13 = (0xCC << 16) | BR13_8888;
-        CMD = XY_SRC_COPY_BLT_CMD | XY_BLT_WRITE_ALPHA | XY_BLT_WRITE_RGB;
-      }
-
-      assert(src->tiling != I915_TILING_Y);
-      assert(dst->tiling != I915_TILING_Y);
-#ifndef I915
-      if (src->tiling != I915_TILING_NONE) {
-        CMD |= XY_SRC_TILED;
-        src_pitch /= 4;
-      }
-      if (dst->tiling != I915_TILING_NONE) {
-        CMD |= XY_DST_TILED;
-        dst_pitch /= 4;
-      }
-#endif
-      /* do space/cliprects check before going any further */
-      intel_batchbuffer_require_space(intel->batch, 8 * 4,
-                                     REFERENCES_CLIPRECTS);
-   again:
-      aper_array[0] = intel->batch->buf;
-      aper_array[1] = dst->buffer;
-      aper_array[2] = src->buffer;
-
-      if (dri_bufmgr_check_aperture_space(aper_array, 3) != 0) {
-       intel_batchbuffer_flush(intel->batch);
-       goto again;
-      }
-
-      for (i = 0; i < nbox; i++, pbox++) {
-        drm_clip_rect_t box = *pbox;
-
-        if (rect) {
-           if (!intel_intersect_cliprects(&box, &box, rect))
-              continue;
-        }
-
-        if (box.x1 >= box.x2 ||
-            box.y1 >= box.y2)
-           continue;
-
-        assert(box.x1 < box.x2);
-        assert(box.y1 < box.y2);
-        src_x = box.x1 - dPriv->x + dPriv->backX;
-        src_y = box.y1 - dPriv->y + dPriv->backY;
-
-        BEGIN_BATCH(8, REFERENCES_CLIPRECTS);
-        OUT_BATCH(CMD);
-        OUT_BATCH(BR13 | dst_pitch);
-        OUT_BATCH((box.y1 << 16) | box.x1);
-        OUT_BATCH((box.y2 << 16) | box.x2);
-
-        OUT_RELOC(dst->buffer,
-                  I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
-                  0);
-        OUT_BATCH((src_y << 16) | src_x);
-        OUT_BATCH(src_pitch);
-        OUT_RELOC(src->buffer,
-                  I915_GEM_DOMAIN_RENDER, 0,
-                  0);
-        ADVANCE_BATCH();
-      }
-
-      /* Flush the rendering and the batch so that the results all land on the
-       * screen in a timely fashion.
-       */
-      intel_batchbuffer_emit_mi_flush(intel->batch);
-      intel_batchbuffer_flush(intel->batch);
-   }
-
-   UNLOCK_HARDWARE(intel);
-}
-
 static GLuint translate_raster_op(GLenum logicop)
 {
    switch(logicop) {
@@ -249,7 +117,6 @@ intelEmitCopyBlit(struct intel_context *intel,
    } while (pass < 2);
 
    if (pass >= 2) {
-       LOCK_HARDWARE(intel);
        dri_bo_map(dst_buffer, GL_TRUE);
        dri_bo_map(src_buffer, GL_FALSE);
        _mesa_copy_rect((GLubyte *)dst_buffer->virtual + dst_offset,
@@ -263,12 +130,11 @@ intelEmitCopyBlit(struct intel_context *intel,
        
        dri_bo_unmap(src_buffer);
        dri_bo_unmap(dst_buffer);
-       UNLOCK_HARDWARE(intel);
 
        return GL_TRUE;
    }
 
-   intel_batchbuffer_require_space(intel->batch, 8 * 4, NO_LOOP_CLIPRECTS);
+   intel_batchbuffer_require_space(intel->batch, 8 * 4);
    DBG("%s src:buf(%p)/%d+%d %d,%d dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n",
        __FUNCTION__,
        src_buffer, src_pitch, src_offset, src_x, src_y,
@@ -313,7 +179,7 @@ intelEmitCopyBlit(struct intel_context *intel,
    assert(dst_x < dst_x2);
    assert(dst_y < dst_y2);
 
-   BEGIN_BATCH(8, NO_LOOP_CLIPRECTS);
+   BEGIN_BATCH(8);
    OUT_BATCH(CMD);
    OUT_BATCH(BR13 | (uint16_t)dst_pitch);
    OUT_BATCH((dst_y << 16) | dst_x);
@@ -371,8 +237,6 @@ intelClearWithBlit(GLcontext *ctx, GLbitfield mask)
       skipBuffers = BUFFER_BIT_STENCIL;
    }
 
-   LOCK_HARDWARE(intel);
-
    intel_get_cliprects(intel, &cliprects, &num_cliprects, &x_off, &y_off);
    if (num_cliprects) {
       GLint cx, cy, cw, ch;
@@ -436,6 +300,10 @@ intelClearWithBlit(GLcontext *ctx, GLbitfield mask)
                   intel_region_buffer(intel, irb->region,
                                       all ? INTEL_WRITE_FULL :
                                       INTEL_WRITE_PART);
+              int x1 = b.x1 + irb->region->draw_x;
+              int y1 = b.y1 + irb->region->draw_y;
+              int x2 = b.x2 + irb->region->draw_x;
+              int y2 = b.y2 + irb->region->draw_y;
 
                GLuint clearVal;
                GLint pitch, cpp;
@@ -444,11 +312,10 @@ intelClearWithBlit(GLcontext *ctx, GLbitfield mask)
                pitch = irb->region->pitch;
                cpp = irb->region->cpp;
 
-               DBG("%s dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n",
+               DBG("%s dst:buf(%p)/%d %d,%d sz:%dx%d\n",
                    __FUNCTION__,
                    irb->region->buffer, (pitch * cpp),
-                   irb->region->draw_offset,
-                   b.x1, b.y1, b.x2 - b.x1, b.y2 - b.y1);
+                   x1, y1, x2 - x1, y2 - y1);
 
               BR13 = 0xf0 << 16;
               CMD = XY_COLOR_BLT_CMD;
@@ -494,12 +361,14 @@ intelClearWithBlit(GLcontext *ctx, GLbitfield mask)
                  CLAMPED_FLOAT_TO_UBYTE(clear[2], color[2]);
                  CLAMPED_FLOAT_TO_UBYTE(clear[3], color[3]);
 
-                 switch (irb->texformat->MesaFormat) {
+                 switch (irb->Base.Format) {
                  case MESA_FORMAT_ARGB8888:
-                    clearVal = intel->ClearColor8888;
+                 case MESA_FORMAT_XRGB8888:
+                    clearVal = PACK_COLOR_8888(clear[3], clear[0],
+                                               clear[1], clear[2]);
                     break;
                  case MESA_FORMAT_RGB565:
-                    clearVal = intel->ClearColor565;
+                    clearVal = PACK_COLOR_565(clear[0], clear[1], clear[2]);
                     break;
                  case MESA_FORMAT_ARGB4444:
                     clearVal = PACK_COLOR_4444(clear[3], clear[0],
@@ -511,7 +380,7 @@ intelClearWithBlit(GLcontext *ctx, GLbitfield mask)
                     break;
                  default:
                     _mesa_problem(ctx, "Unexpected renderbuffer format: %d\n",
-                                  irb->texformat->MesaFormat);
+                                  irb->Base.Format);
                     clearVal = 0;
                  }
               }
@@ -521,17 +390,17 @@ intelClearWithBlit(GLcontext *ctx, GLbitfield mask)
                   buf, irb->Base.Name);
                 */
 
-               assert(b.x1 < b.x2);
-               assert(b.y1 < b.y2);
+               assert(x1 < x2);
+               assert(y1 < y2);
 
-               BEGIN_BATCH(6, REFERENCES_CLIPRECTS);
+               BEGIN_BATCH(6);
                OUT_BATCH(CMD);
                OUT_BATCH(BR13);
-               OUT_BATCH((b.y1 << 16) | b.x1);
-               OUT_BATCH((b.y2 << 16) | b.x2);
+               OUT_BATCH((y1 << 16) | x1);
+               OUT_BATCH((y2 << 16) | x2);
                OUT_RELOC(write_buffer,
                         I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
-                         irb->region->draw_offset);
+                         0);
                OUT_BATCH(clearVal);
                ADVANCE_BATCH();
                clearMask &= ~bufBit;    /* turn off bit, for faster loop exit */
@@ -539,8 +408,6 @@ intelClearWithBlit(GLcontext *ctx, GLbitfield mask)
          }
       }
    }
-
-   UNLOCK_HARDWARE(intel);
 }
 
 GLboolean
@@ -582,8 +449,7 @@ intelEmitImmediateColorExpandBlit(struct intel_context *intel,
    intel_batchbuffer_require_space( intel->batch,
                                    (8 * 4) +
                                    (3 * 4) +
-                                   dwords * 4,
-                                   REFERENCES_CLIPRECTS );
+                                   dwords * 4 );
 
    opcode = XY_SETUP_BLT_CMD;
    if (cpp == 4)
@@ -605,7 +471,7 @@ intelEmitImmediateColorExpandBlit(struct intel_context *intel,
    if (dst_tiling != I915_TILING_NONE)
       blit_cmd |= XY_DST_TILED;
 
-   BEGIN_BATCH(8 + 3, REFERENCES_CLIPRECTS);
+   BEGIN_BATCH(8 + 3);
    OUT_BATCH(opcode);
    OUT_BATCH(br13);
    OUT_BATCH((0 << 16) | 0); /* clip x1, y1 */
@@ -624,8 +490,7 @@ intelEmitImmediateColorExpandBlit(struct intel_context *intel,
 
    intel_batchbuffer_data( intel->batch,
                           src_bits,
-                          dwords * 4,
-                          REFERENCES_CLIPRECTS );
+                          dwords * 4 );
 
    intel_batchbuffer_emit_mi_flush(intel->batch);
 
index 240cb7cd1b619ab02afbd3723eda8c57a0a8a420..eb66fe0481dad2078bffd23d51f8eb3149d0b675 100644 (file)
@@ -30,7 +30,7 @@
 
 #include "intel_context.h"
 
-extern void intelCopyBuffer(const __DRIdrawablePrivate * dpriv,
+extern void intelCopyBuffer(const __DRIdrawable * dpriv,
                             const drm_clip_rect_t * rect);
 
 extern void intelClearWithBlit(GLcontext * ctx, GLbitfield mask);
index a0225936c81648a133c1eec15b2ab95f2185b527..3b7015b5ad39a7842277046c48be24163ee0b5cd 100644 (file)
@@ -209,9 +209,23 @@ intel_bufferobj_subdata(GLcontext * ctx,
       memcpy((char *)intel_obj->sys_buffer + offset, data, size);
    else {
       /* Flush any existing batchbuffer that might reference this data. */
-      intelFlush(ctx);
+      if (drm_intel_bo_busy(intel_obj->buffer) ||
+         drm_intel_bo_references(intel->batch->buf, intel_obj->buffer)) {
+        drm_intel_bo *temp_bo;
+
+        temp_bo = drm_intel_bo_alloc(intel->bufmgr, "subdata temp", size, 64);
+
+        drm_intel_bo_subdata(temp_bo, 0, size, data);
 
-      dri_bo_subdata(intel_obj->buffer, offset, size, data);
+        intel_emit_linear_blit(intel,
+                               intel_obj->buffer, offset,
+                               temp_bo, 0,
+                               size);
+
+        drm_intel_bo_unreference(temp_bo);
+      } else {
+        dri_bo_subdata(intel_obj->buffer, offset, size, data);
+      }
    }
 }
 
@@ -254,13 +268,14 @@ intel_bufferobj_map(GLcontext * ctx,
 
    if (intel_obj->sys_buffer) {
       obj->Pointer = intel_obj->sys_buffer;
+      obj->Length = obj->Size;
+      obj->Offset = 0;
       return obj->Pointer;
    }
 
-   /* Flush any existing batchbuffer that might have written to this
-    * buffer.
-    */
-   intelFlush(ctx);
+   /* Flush any existing batchbuffer that might reference this data. */
+   if (drm_intel_bo_references(intel->batch->buf, intel_obj->buffer))
+      intelFlush(ctx);
 
    if (intel_obj->region)
       intel_bufferobj_cow(intel, intel_obj);
@@ -330,7 +345,8 @@ intel_bufferobj_map_range(GLcontext * ctx,
     * the batchbuffer so that GEM knows about the buffer access for later
     * syncing.
     */
-   if (!(access & GL_MAP_UNSYNCHRONIZED_BIT))
+   if (!(access & GL_MAP_UNSYNCHRONIZED_BIT) &&
+       drm_intel_bo_references(intel->batch->buf, intel_obj->buffer))
       intelFlush(ctx);
 
    if (intel_obj->buffer == NULL) {
index e7357e78c539256da3c2816f4b0efb98e0bebd07..7c4b79f743a8dca6d79d386cea6b4944bafea626 100644 (file)
@@ -102,32 +102,33 @@ intel_get_cliprects(struct intel_context *intel,
                    unsigned int *num_cliprects,
                    int *x_off, int *y_off)
 {
-   __DRIdrawablePrivate *dPriv = intel->driDrawable;
-
-   if (intel->constant_cliprect) {
-      /* FBO or DRI2 rendering, which can just use the fb's size. */
-      intel->fboRect.x1 = 0;
-      intel->fboRect.y1 = 0;
-      intel->fboRect.x2 = intel->ctx.DrawBuffer->Width;
-      intel->fboRect.y2 = intel->ctx.DrawBuffer->Height;
-
-      *cliprects = &intel->fboRect;
-      *num_cliprects = 1;
-      *x_off = 0;
-      *y_off = 0;
-   } else if (intel->front_cliprects || dPriv->numBackClipRects == 0) {
-      /* use the front clip rects */
-      *cliprects = dPriv->pClipRects;
-      *num_cliprects = dPriv->numClipRects;
-      *x_off = dPriv->x;
-      *y_off = dPriv->y;
-   }
-   else {
-      /* use the back clip rects */
-      *num_cliprects = dPriv->numBackClipRects;
-      *cliprects = dPriv->pBackClipRects;
-      *x_off = dPriv->backX;
-      *y_off = dPriv->backY;
+   intel->fboRect.x1 = 0;
+   intel->fboRect.y1 = 0;
+   intel->fboRect.x2 = intel->ctx.DrawBuffer->Width;
+   intel->fboRect.y2 = intel->ctx.DrawBuffer->Height;
+
+   *cliprects = &intel->fboRect;
+   *num_cliprects = 1;
+   *x_off = 0;
+   *y_off = 0;
+}
+
+
+/**
+ * Check if we're about to draw into the front color buffer.
+ * If so, set the intel->front_buffer_dirty field to true.
+ */
+void
+intel_check_front_buffer_rendering(struct intel_context *intel)
+{
+   const struct gl_framebuffer *fb = intel->ctx.DrawBuffer;
+   if (fb->Name == 0) {
+      /* drawing to window system buffer */
+      if (fb->_NumColorDrawBuffers > 0) {
+         if (fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) {
+           intel->front_buffer_dirty = GL_TRUE;
+        }
+      }
    }
 }
 
@@ -172,13 +173,17 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb)
       return;
    }
 
-   /*
-    * How many color buffers are we drawing into?
+   /* How many color buffers are we drawing into?
+    *
+    * If there are zero buffers or the buffer is too big, don't configure any
+    * regions for hardware drawing.  We'll fallback to software below.  Not
+    * having regions set makes some of the software fallback paths faster.
     */
-   if (fb->_NumColorDrawBuffers == 0) {
+   if ((fb->Width > ctx->Const.MaxRenderbufferSize)
+       || (fb->Height > ctx->Const.MaxRenderbufferSize)
+       || (fb->_NumColorDrawBuffers == 0)) {
       /* writing to 0  */
       colorRegions[0] = NULL;
-      intel->constant_cliprect = GL_TRUE;
    }
    else if (fb->_NumColorDrawBuffers > 1) {
        int i;
@@ -188,36 +193,23 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb)
            irb = intel_renderbuffer(fb->_ColorDrawBuffers[i]);
            colorRegions[i] = irb ? irb->region : NULL;
        }
-       intel->constant_cliprect = GL_TRUE;
    }
    else {
       /* Get the intel_renderbuffer for the single colorbuffer we're drawing
-       * into, and set up cliprects if it's .
+       * into.
        */
       if (fb->Name == 0) {
-        intel->constant_cliprect = intel->driScreen->dri2.enabled;
         /* drawing to window system buffer */
-        if (fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) {
-           if (!intel->constant_cliprect && !intel->front_cliprects)
-              intel_batchbuffer_flush(intel->batch);
-           intel->front_cliprects = GL_TRUE;
+        if (fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT)
            colorRegions[0] = intel_get_rb_region(fb, BUFFER_FRONT_LEFT);
-
-           intel->front_buffer_dirty = GL_TRUE;
-        }
-        else {
-           if (!intel->constant_cliprect && intel->front_cliprects)
-              intel_batchbuffer_flush(intel->batch);
-           intel->front_cliprects = GL_FALSE;
-           colorRegions[0]= intel_get_rb_region(fb, BUFFER_BACK_LEFT);
-        }
+        else
+           colorRegions[0] = intel_get_rb_region(fb, BUFFER_BACK_LEFT);
       }
       else {
         /* drawing to user-created FBO */
         struct intel_renderbuffer *irb;
         irb = intel_renderbuffer(fb->_ColorDrawBuffers[0]);
         colorRegions[0] = (irb && irb->region) ? irb->region : NULL;
-        intel->constant_cliprect = GL_TRUE;
       }
    }
 
@@ -257,7 +249,7 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb)
    if (fb->_StencilBuffer && fb->_StencilBuffer->Wrapped) {
       irbStencil = intel_renderbuffer(fb->_StencilBuffer->Wrapped);
       if (irbStencil && irbStencil->region) {
-         ASSERT(irbStencil->Base._ActualFormat == GL_DEPTH24_STENCIL8_EXT);
+         ASSERT(irbStencil->Base.Format == MESA_FORMAT_S8_Z24);
          FALLBACK(intel, INTEL_FALLBACK_STENCIL_BUFFER, GL_FALSE);
       }
       else {
@@ -269,6 +261,12 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb)
       FALLBACK(intel, INTEL_FALLBACK_STENCIL_BUFFER, GL_FALSE);
    }
 
+   /* If we have a (packed) stencil buffer attached but no depth buffer,
+    * we still need to set up the shared depth/stencil state so we can use it.
+    */
+   if (depthRegion == NULL && irbStencil && irbStencil->region)
+      depthRegion = irbStencil->region;
+
    /*
     * Update depth and stencil test state
     */
index 6069d38e9eb7de88deb20f5a3b6e6ebcb183c2c6..d7800f2ca2fd44922985661cb2aa5a10bd9b9ab6 100644 (file)
@@ -45,6 +45,8 @@ extern struct intel_region *intel_readbuf_region(struct intel_context *intel);
 
 extern struct intel_region *intel_drawbuf_region(struct intel_context *intel);
 
+extern void intel_check_front_buffer_rendering(struct intel_context *intel);
+
 extern void intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb);
 
 extern void intelInitBufferFuncs(struct dd_function_table *functions);
index fb62f0f430aa14e1b8a117b04993ffa16eb0fc3d..956f2339ff06bd0378f8e2ef8a781fc7f5a07201 100644 (file)
@@ -68,13 +68,17 @@ static void
 intelClear(GLcontext *ctx, GLbitfield mask)
 {
    struct intel_context *intel = intel_context(ctx);
-   const GLuint colorMask = *((GLuint *) & ctx->Color.ColorMask);
+   const GLuint colorMask = *((GLuint *) & ctx->Color.ColorMask[0]);
    GLbitfield tri_mask = 0;
    GLbitfield blit_mask = 0;
    GLbitfield swrast_mask = 0;
    struct gl_framebuffer *fb = ctx->DrawBuffer;
    GLuint i;
 
+   if (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_FRONT_RIGHT)) {
+      intel->front_buffer_dirty = GL_TRUE;
+   }
+
    if (0)
       fprintf(stderr, "%s\n", __FUNCTION__);
 
index 934f7aa1873496ee06b54548590372eadf933996..13a28f0419de8092ca4948e098aa711ec93aadd7 100644 (file)
 #include "intel_decode.h"
 #include "intel_bufmgr.h"
 #include "intel_screen.h"
-#include "intel_swapbuffers.h"
 
 #include "drirenderbuffer.h"
-#include "vblank.h"
 #include "utils.h"
 #include "xmlpool.h"            /* for symbolic values of enum-type options */
 
@@ -68,7 +66,7 @@ int INTEL_DEBUG = (0);
 #endif
 
 
-#define DRIVER_DATE                     "20090712 2009Q2 RC3"
+#define DRIVER_DATE                     "20091221 DEVELOPMENT"
 #define DRIVER_DATE_GEM                 "GEM " DRIVER_DATE
 
 
@@ -176,9 +174,7 @@ intelGetString(GLcontext * ctx, GLenum name)
          break;
       }
 
-      (void) driGetRendererString(buffer, chipset, 
-                                 (intel->ttm) ? DRIVER_DATE_GEM : DRIVER_DATE,
-                                 0);
+      (void) driGetRendererString(buffer, chipset, DRIVER_DATE_GEM, 0);
       return (GLubyte *) buffer;
 
    default:
@@ -189,28 +185,17 @@ intelGetString(GLcontext * ctx, GLenum name)
 static unsigned
 intel_bits_per_pixel(const struct intel_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;
-   }
+   return _mesa_get_format_bytes(rb->Base.Format) * 8;
 }
 
 void
 intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
 {
-   struct intel_framebuffer *intel_fb = drawable->driverPrivate;
+   struct gl_framebuffer *fb = drawable->driverPrivate;
    struct intel_renderbuffer *rb;
    struct intel_region *region, *depth_region;
    struct intel_context *intel = context->driverPrivate;
+   struct intel_renderbuffer *front_rb, *back_rb, *depth_rb, *stencil_rb;
    __DRIbuffer *buffers = NULL;
    __DRIscreen *screen;
    int i, count;
@@ -226,26 +211,25 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
    if (screen->dri2.loader
        && (screen->dri2.loader->base.version > 2)
        && (screen->dri2.loader->getBuffersWithFormat != NULL)) {
-      struct intel_renderbuffer *depth_rb;
-      struct intel_renderbuffer *stencil_rb;
+
+      front_rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
+      back_rb = intel_get_renderbuffer(fb, BUFFER_BACK_LEFT);
+      depth_rb = intel_get_renderbuffer(fb, BUFFER_DEPTH);
+      stencil_rb = intel_get_renderbuffer(fb, BUFFER_STENCIL);
 
       i = 0;
       if ((intel->is_front_buffer_rendering ||
           intel->is_front_buffer_reading ||
-          !intel_fb->color_rb[1])
-          && intel_fb->color_rb[0]) {
+          !back_rb) && front_rb) {
         attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
-        attachments[i++] = intel_bits_per_pixel(intel_fb->color_rb[0]);
+        attachments[i++] = intel_bits_per_pixel(front_rb);
       }
 
-      if (intel_fb->color_rb[1]) {
+      if (back_rb) {
         attachments[i++] = __DRI_BUFFER_BACK_LEFT;
-        attachments[i++] = intel_bits_per_pixel(intel_fb->color_rb[1]);
+        attachments[i++] = intel_bits_per_pixel(back_rb);
       }
 
-      depth_rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH);
-      stencil_rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL);
-
       if ((depth_rb != NULL) && (stencil_rb != NULL)) {
         attachments[i++] = __DRI_BUFFER_DEPTH_STENCIL;
         attachments[i++] = intel_bits_per_pixel(depth_rb);
@@ -266,13 +250,13 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
                                                      drawable->loaderPrivate);
    } else if (screen->dri2.loader) {
       i = 0;
-      if (intel_fb->color_rb[0])
+      if (intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT))
         attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
-      if (intel_fb->color_rb[1])
+      if (intel_get_renderbuffer(fb, BUFFER_BACK_LEFT))
         attachments[i++] = __DRI_BUFFER_BACK_LEFT;
-      if (intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH))
+      if (intel_get_renderbuffer(fb, BUFFER_DEPTH))
         attachments[i++] = __DRI_BUFFER_DEPTH;
-      if (intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL))
+      if (intel_get_renderbuffer(fb, BUFFER_STENCIL))
         attachments[i++] = __DRI_BUFFER_STENCIL;
 
       buffers = (*screen->dri2.loader->getBuffers)(drawable,
@@ -305,32 +289,32 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
    for (i = 0; i < count; i++) {
        switch (buffers[i].attachment) {
        case __DRI_BUFFER_FRONT_LEFT:
-          rb = intel_fb->color_rb[0];
+          rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
           region_name = "dri2 front buffer";
           break;
 
        case __DRI_BUFFER_FAKE_FRONT_LEFT:
-          rb = intel_fb->color_rb[0];
+          rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
           region_name = "dri2 fake front buffer";
           break;
 
        case __DRI_BUFFER_BACK_LEFT:
-          rb = intel_fb->color_rb[1];
+          rb = intel_get_renderbuffer(fb, BUFFER_BACK_LEFT);
           region_name = "dri2 back buffer";
           break;
 
        case __DRI_BUFFER_DEPTH:
-          rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH);
+          rb = intel_get_renderbuffer(fb, BUFFER_DEPTH);
           region_name = "dri2 depth buffer";
           break;
 
        case __DRI_BUFFER_DEPTH_STENCIL:
-          rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH);
+          rb = intel_get_renderbuffer(fb, BUFFER_DEPTH);
           region_name = "dri2 depth / stencil buffer";
           break;
 
        case __DRI_BUFFER_STENCIL:
-          rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL);
+          rb = intel_get_renderbuffer(fb, BUFFER_STENCIL);
           region_name = "dri2 stencil buffer";
           break;
 
@@ -377,7 +361,7 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
        intel_region_release(&region);
 
        if (buffers[i].attachment == __DRI_BUFFER_DEPTH_STENCIL) {
-         rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL);
+         rb = intel_get_renderbuffer(fb, BUFFER_STENCIL);
          if (rb != NULL) {
             struct intel_region *stencil_region = NULL;
 
@@ -405,9 +389,6 @@ intel_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
     void (*old_viewport)(GLcontext *ctx, GLint x, GLint y,
                         GLsizei w, GLsizei h);
 
-    if (!driContext->driScreenPriv->dri2.enabled)
-       return;
-
     if (!intel->meta.internal_viewport_call && ctx->DrawBuffer->Name == 0) {
        /* If we're rendering to the fake front buffer, make sure all the pending
        * drawing has landed on the real front buffer.  Otherwise when we
@@ -426,7 +407,6 @@ intel_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
     old_viewport = ctx->Driver.Viewport;
     ctx->Driver.Viewport = NULL;
     intel->driDrawable = driContext->driDrawablePriv;
-    intelWindowMoved(intel);
     intel_draw_buffer(ctx, intel->ctx.DrawBuffer);
     ctx->Driver.Viewport = old_viewport;
 }
@@ -489,16 +469,9 @@ intel_flush(GLcontext *ctx, GLboolean needs_mi_flush)
    if (intel->Fallback)
       _swrast_flush(ctx);
 
-   if (!IS_965(intel->intelScreen->deviceID))
+   if (intel->gen < 4)
       INTEL_FIREVERTICES(intel);
 
-   /* Emit a flush so that any frontbuffer rendering that might have occurred
-    * lands onscreen in a timely manner, even if the X Server doesn't trigger
-    * a flush for us.
-    */
-   if (needs_mi_flush)
-      intel_batchbuffer_emit_mi_flush(intel->batch);
-
    if (intel->batch->map != intel->batch->ptr)
       intel_batchbuffer_flush(intel->batch);
 
@@ -604,15 +577,15 @@ intelInitDriverFunctions(struct dd_function_table *functions)
 GLboolean
 intelInitContext(struct intel_context *intel,
                  const __GLcontextModes * mesaVis,
-                 __DRIcontextPrivate * driContextPriv,
+                 __DRIcontext * driContextPriv,
                  void *sharedContextPrivate,
                  struct dd_function_table *functions)
 {
    GLcontext *ctx = &intel->ctx;
    GLcontext *shareCtx = (GLcontext *) sharedContextPrivate;
-   __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+   __DRIscreen *sPriv = driContextPriv->driScreenPriv;
    intelScreenPrivate *intelScreen = (intelScreenPrivate *) sPriv->private;
-   int fthrottle_mode;
+   int bo_reuse_mode;
 
    if (!_mesa_initialize_context(&intel->ctx, mesaVis, shareCtx,
                                  functions, (void *) intel)) {
@@ -623,35 +596,46 @@ intelInitContext(struct intel_context *intel,
    driContextPriv->driverPrivate = intel;
    intel->intelScreen = intelScreen;
    intel->driScreen = sPriv;
-   intel->sarea = intelScreen->sarea;
    intel->driContext = driContextPriv;
-
-   /* Dri stuff */
-   intel->hHWContext = driContextPriv->hHWContext;
    intel->driFd = sPriv->fd;
-   intel->driHwLock = sPriv->lock;
+
+   if (IS_965(intel->intelScreen->deviceID)) {
+      intel->gen = 4;
+   } else if (IS_9XX(intel->intelScreen->deviceID)) {
+      intel->gen = 3;
+      if (IS_945(intel->intelScreen->deviceID)) {
+        intel->is_945 = GL_TRUE;
+      }
+   } else {
+      intel->gen = 2;
+   }
+
+   if (IS_IGDNG(intel->intelScreen->deviceID)) {
+      intel->is_ironlake = GL_TRUE;
+      intel->needs_ff_sync = GL_TRUE;
+      intel->has_luminance_srgb = GL_TRUE;
+   } else if (IS_G4X(intel->intelScreen->deviceID)) {
+      intel->has_luminance_srgb = GL_TRUE;
+      intel->is_g4x = GL_TRUE;
+   }
 
    driParseConfigFiles(&intel->optionCache, &intelScreen->optionCache,
                        intel->driScreen->myNum,
-                      IS_965(intelScreen->deviceID) ? "i965" : "i915");
+                      (intel->gen >= 4) ? "i965" : "i915");
    if (intelScreen->deviceID == PCI_CHIP_I865_G)
       intel->maxBatchSize = 4096;
    else
       intel->maxBatchSize = BATCH_SZ;
 
    intel->bufmgr = intelScreen->bufmgr;
-   intel->ttm = intelScreen->ttm;
-   if (intel->ttm) {
-      int bo_reuse_mode;
 
-      bo_reuse_mode = driQueryOptioni(&intel->optionCache, "bo_reuse");
-      switch (bo_reuse_mode) {
-      case DRI_CONF_BO_REUSE_DISABLED:
-        break;
-      case DRI_CONF_BO_REUSE_ALL:
-        intel_bufmgr_gem_enable_reuse(intel->bufmgr);
-        break;
-      }
+   bo_reuse_mode = driQueryOptioni(&intel->optionCache, "bo_reuse");
+   switch (bo_reuse_mode) {
+   case DRI_CONF_BO_REUSE_DISABLED:
+      break;
+   case DRI_CONF_BO_REUSE_ALL:
+      intel_bufmgr_gem_enable_reuse(intel->bufmgr);
+      break;
    }
 
    /* This doesn't yet catch all non-conformant rendering, but it's a
@@ -695,7 +679,7 @@ intelInitContext(struct intel_context *intel,
 
    meta_init_metaops(ctx, &intel->meta);
    ctx->Const.MaxColorAttachments = 4;  /* XXX FBO: review this */
-   if (IS_965(intelScreen->deviceID)) {
+   if (intel->gen >= 4) {
       if (MAX_WIDTH > 8192)
         ctx->Const.MaxRenderbufferSize = 8192;
    } else {
@@ -732,33 +716,22 @@ intelInitContext(struct intel_context *intel,
       break;
    }
 
-   if (IS_965(intelScreen->deviceID))
+   if (intel->gen >= 4)
       intel->polygon_offset_scale /= 0xffff;
 
    intel->RenderIndex = ~0;
 
-   fthrottle_mode = driQueryOptioni(&intel->optionCache, "fthrottle_mode");
-   intel->irqsEmitted = 0;
-
-   intel->do_irqs = (intel->intelScreen->irq_active &&
-                     fthrottle_mode == DRI_CONF_FTHROTTLE_IRQS);
-
-   intel->do_usleeps = (fthrottle_mode == DRI_CONF_FTHROTTLE_USLEEPS);
-
-   if (IS_965(intelScreen->deviceID) && !intel->intelScreen->irq_active) {
+   if (intel->gen >= 4 && !intel->intelScreen->irq_active) {
       _mesa_printf("IRQs not active.  Exiting\n");
       exit(1);
    }
 
-   intelInitExtensions(ctx, GL_FALSE);
+   intelInitExtensions(ctx);
 
    INTEL_DEBUG = driParseDebugString(getenv("INTEL_DEBUG"), debug_control);
    if (INTEL_DEBUG & DEBUG_BUFMGR)
       dri_bufmgr_set_debug(intel->bufmgr, GL_TRUE);
 
-   if (!sPriv->dri2.enabled)
-      intel_recreate_static_regions(intel);
-
    intel->batch = intel_batchbuffer_alloc(intel);
 
    intel_fbo_init(intel);
@@ -807,7 +780,7 @@ intelInitContext(struct intel_context *intel,
 }
 
 void
-intelDestroyContext(__DRIcontextPrivate * driContextPriv)
+intelDestroyContext(__DRIcontext * driContextPriv)
 {
    struct intel_context *intel =
       (struct intel_context *) driContextPriv->driverPrivate;
@@ -830,7 +803,7 @@ intelDestroyContext(__DRIcontextPrivate * driContextPriv)
       _vbo_DestroyContext(&intel->ctx);
 
       _swrast_DestroyContext(&intel->ctx);
-      intel->Fallback = 0;      /* don't call _swrast_Flush later */
+      intel->Fallback = 0x0;      /* don't call _swrast_Flush later */
 
       intel_batchbuffer_free(intel->batch);
       intel->batch = NULL;
@@ -854,57 +827,6 @@ intelDestroyContext(__DRIcontextPrivate * driContextPriv)
           */
       }
 
-      /* 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);
-
       driDestroyOptionCache(&intel->optionCache);
 
       /* free the Mesa context */
@@ -916,7 +838,7 @@ intelDestroyContext(__DRIcontextPrivate * driContextPriv)
 }
 
 GLboolean
-intelUnbindContext(__DRIcontextPrivate * driContextPriv)
+intelUnbindContext(__DRIcontext * driContextPriv)
 {
    struct intel_context *intel =
       (struct intel_context *) driContextPriv->driverPrivate;
@@ -930,50 +852,33 @@ intelUnbindContext(__DRIcontextPrivate * driContextPriv)
 }
 
 GLboolean
-intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
-                 __DRIdrawablePrivate * driDrawPriv,
-                 __DRIdrawablePrivate * driReadPriv)
+intelMakeCurrent(__DRIcontext * driContextPriv,
+                 __DRIdrawable * driDrawPriv,
+                 __DRIdrawable * driReadPriv)
 {
-   __DRIscreenPrivate *psp = driDrawPriv->driScreenPriv;
+   struct intel_context *intel;
+   GET_CURRENT_CONTEXT(curCtx);
+
+   if (driContextPriv)
+      intel = (struct intel_context *) driContextPriv->driverPrivate;
+   else
+      intel = NULL;
+
+   /* According to the glXMakeCurrent() man page: "Pending commands to
+    * the previous context, if any, are flushed before it is released."
+    * But only flush if we're actually changing contexts.
+    */
+   if (intel_context(curCtx) && intel_context(curCtx) != intel) {
+      _mesa_flush(curCtx);
+   }
 
    if (driContextPriv) {
-      struct intel_context *intel =
-         (struct intel_context *) driContextPriv->driverPrivate;
-      struct intel_framebuffer *intel_fb =
-        (struct intel_framebuffer *) driDrawPriv->driverPrivate;
-      GLframebuffer *readFb = (GLframebuffer *) driReadPriv->driverPrivate;
+      struct gl_framebuffer *fb = driDrawPriv->driverPrivate;
+      struct gl_framebuffer *readFb = driReadPriv->driverPrivate;
  
-      if (driContextPriv->driScreenPriv->dri2.enabled) {     
-          intel_update_renderbuffers(driContextPriv, driDrawPriv);
-          if (driDrawPriv != driReadPriv)
-              intel_update_renderbuffers(driContextPriv, driReadPriv);
-      } else {
-          /* XXX FBO temporary fix-ups!  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);
-         struct intel_renderbuffer *irbStencil
-            = intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL);
-
-         if (intel_fb->color_rb[0]) {
-           intel_renderbuffer_set_region(intel_fb->color_rb[0],
-                                         intel->front_region);
-         }
-         if (intel_fb->color_rb[1]) {
-           intel_renderbuffer_set_region(intel_fb->color_rb[1],
-                                         intel->back_region);
-         }
-
-         if (irbDepth) {
-           intel_renderbuffer_set_region(irbDepth, intel->depth_region);
-         }
-         if (irbStencil) {
-           intel_renderbuffer_set_region(irbStencil, intel->depth_region);
-         }
-      }
+      intel_update_renderbuffers(driContextPriv, driDrawPriv);
+      if (driDrawPriv != driReadPriv)
+        intel_update_renderbuffers(driContextPriv, driReadPriv);
 
       /* set GLframebuffer size to match window, if needed */
       driUpdateFramebufferSize(&intel->ctx, driDrawPriv);
@@ -982,37 +887,10 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
         driUpdateFramebufferSize(&intel->ctx, driReadPriv);
       }
 
-      _mesa_make_current(&intel->ctx, &intel_fb->Base, readFb);
-
+      _mesa_make_current(&intel->ctx, fb, readFb);
       intel->driReadDrawable = driReadPriv;
-
-      if (intel->driDrawable != driDrawPriv) {
-         if (driDrawPriv->swap_interval == (unsigned)-1) {
-            int i;
-
-            driDrawPriv->vblFlags = (intel->intelScreen->irq_active != 0)
-               ? driGetDefaultVBlankFlags(&intel->optionCache)
-               : VBLANK_FLAG_NO_IRQ;
-
-            /* Prevent error printf if one crtc is disabled, this will
-             * be properly calculated in intelWindowMoved() next.
-             */
-            driDrawPriv->vblFlags = intelFixupVblank(intel, driDrawPriv);
-
-            (*psp->systemTime->getUST) (&intel_fb->swap_ust);
-            driDrawableInitVBlank(driDrawPriv);
-            intel_fb->vbl_waited = driDrawPriv->vblSeq;
-
-            for (i = 0; i < 2; i++) {
-               if (intel_fb->color_rb[i])
-                  intel_fb->color_rb[i]->vbl_pending = driDrawPriv->vblSeq;
-            }
-         }
-         intel->driDrawable = driDrawPriv;
-         intelWindowMoved(intel);
-      }
-
-      intel_draw_buffer(&intel->ctx, &intel_fb->Base);
+      intel->driDrawable = driDrawPriv;
+      intel_draw_buffer(&intel->ctx, fb);
    }
    else {
       _mesa_make_current(NULL, NULL, NULL);
@@ -1020,143 +898,3 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
 
    return GL_TRUE;
 }
-
-static void
-intelContendedLock(struct intel_context *intel, GLuint flags)
-{
-   __DRIdrawablePrivate *dPriv = intel->driDrawable;
-   __DRIscreenPrivate *sPriv = intel->driScreen;
-   volatile drm_i915_sarea_t *sarea = intel->sarea;
-   int me = intel->hHWContext;
-
-   drmGetLock(intel->driFd, intel->hHWContext, flags);
-
-   if (INTEL_DEBUG & DEBUG_LOCK)
-      _mesa_printf("%s - got contended lock\n", __progname);
-
-   /* If the window moved, may need to set a new cliprect now.
-    *
-    * NOTE: This releases and regains the hw lock, so all state
-    * checking must be done *after* this call:
-    */
-   if (dPriv)
-       DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv);
-
-   if (sarea && sarea->ctxOwner != me) {
-      if (INTEL_DEBUG & DEBUG_BUFMGR) {
-        fprintf(stderr, "Lost Context: sarea->ctxOwner %x me %x\n",
-                sarea->ctxOwner, me);
-      }
-      sarea->ctxOwner = me;
-   }
-
-   /* If the last consumer of the texture memory wasn't us, notify the fake
-    * bufmgr and record the new owner.  We should have the memory shared
-    * between contexts of a single fake bufmgr, but this will at least make
-    * things correct for now.
-    */
-   if (!intel->ttm && sarea->texAge != intel->hHWContext) {
-      sarea->texAge = intel->hHWContext;
-      intel_bufmgr_fake_contended_lock_take(intel->bufmgr);
-      if (INTEL_DEBUG & DEBUG_BATCH)
-        intel_decode_context_reset();
-      if (INTEL_DEBUG & DEBUG_BUFMGR)
-        fprintf(stderr, "Lost Textures: sarea->texAge %x hw context %x\n",
-                sarea->ctxOwner, intel->hHWContext);
-   }
-
-   /* Drawable changed?
-    */
-   if (dPriv && intel->lastStamp != dPriv->lastStamp) {
-       intelWindowMoved(intel);
-       intel->lastStamp = dPriv->lastStamp;
-   }
-}
-
-
-_glthread_DECLARE_STATIC_MUTEX(lockMutex);
-
-/* Lock the hardware and validate our state.  
- */
-void LOCK_HARDWARE( struct intel_context *intel )
-{
-    __DRIdrawable *dPriv = intel->driDrawable;
-    __DRIscreen *sPriv = intel->driScreen;
-    char __ret = 0;
-    struct intel_framebuffer *intel_fb = NULL;
-    struct intel_renderbuffer *intel_rb = NULL;
-
-    intel->locked++;
-    if (intel->locked >= 2)
-       return;
-
-    if (!sPriv->dri2.enabled)
-       _glthread_LOCK_MUTEX(lockMutex);
-
-    if (intel->driDrawable) {
-       intel_fb = intel->driDrawable->driverPrivate;
-
-       if (intel_fb)
-         intel_rb =
-            intel_get_renderbuffer(&intel_fb->Base,
-                                   intel_fb->Base._ColorDrawBufferIndexes[0]);
-    }
-
-    if (intel_rb && dPriv->vblFlags &&
-       !(dPriv->vblFlags & VBLANK_FLAG_NO_IRQ) &&
-       (intel_fb->vbl_waited - intel_rb->vbl_pending) > (1<<23)) {
-       drmVBlank vbl;
-
-       vbl.request.type = DRM_VBLANK_ABSOLUTE;
-
-       if ( dPriv->vblFlags & VBLANK_FLAG_SECONDARY ) {
-           vbl.request.type |= DRM_VBLANK_SECONDARY;
-       }
-
-       vbl.request.sequence = intel_rb->vbl_pending;
-       drmWaitVBlank(intel->driFd, &vbl);
-       intel_fb->vbl_waited = vbl.reply.sequence;
-    }
-
-    if (!sPriv->dri2.enabled) {
-       DRM_CAS(intel->driHwLock, intel->hHWContext,
-               (DRM_LOCK_HELD|intel->hHWContext), __ret);
-
-       if (__ret)
-           intelContendedLock( intel, 0 );
-    }
-
-
-    if (INTEL_DEBUG & DEBUG_LOCK)
-      _mesa_printf("%s - locked\n", __progname);
-}
-
-
-/* Unlock the hardware using the global current context 
- */
-void UNLOCK_HARDWARE( struct intel_context *intel )
-{
-    __DRIscreen *sPriv = intel->driScreen;
-
-   intel->locked--;
-   if (intel->locked > 0)
-      return;
-
-   assert(intel->locked == 0);
-
-   if (!sPriv->dri2.enabled) {
-      DRM_UNLOCK(intel->driFd, intel->driHwLock, intel->hHWContext);
-      _glthread_UNLOCK_MUTEX(lockMutex);
-   }
-
-   if (INTEL_DEBUG & DEBUG_LOCK)
-      _mesa_printf("%s - unlocked\n", __progname);
-
-   /**
-    * Nothing should be left in batch outside of LOCK/UNLOCK which references
-    * cliprects.
-    */
-   if (intel->batch->cliprect_mode == REFERENCES_CLIPRECTS)
-      intel_batchbuffer_flush(intel->batch);
-}
-
index b104096912cc49a07a9960fce7368cbbc6d24400..c7b72358362be7134cfb9108033e3e0884e35af1 100644 (file)
@@ -61,6 +61,10 @@ typedef void (*intel_line_func) (struct intel_context *, intelVertex *,
                                  intelVertex *);
 typedef void (*intel_point_func) (struct intel_context *, intelVertex *);
 
+/**
+ * Bits for intel->Fallback field
+ */
+/*@{*/
 #define INTEL_FALLBACK_DRAW_BUFFER      0x1
 #define INTEL_FALLBACK_READ_BUFFER      0x2
 #define INTEL_FALLBACK_DEPTH_BUFFER      0x4
@@ -68,8 +72,10 @@ typedef void (*intel_point_func) (struct intel_context *, intelVertex *);
 #define INTEL_FALLBACK_USER             0x10
 #define INTEL_FALLBACK_RENDERMODE       0x20
 #define INTEL_FALLBACK_TEXTURE          0x40
+#define INTEL_FALLBACK_DRIVER            0x1000  /**< first for drivers */
+/*@}*/
 
-extern void intelFallback(struct intel_context *intel, GLuint bit,
+extern void intelFallback(struct intel_context *intel, GLbitfield bit,
                           GLboolean mode);
 #define FALLBACK( intel, bit, mode ) intelFallback( intel, bit, mode )
 
@@ -111,8 +117,6 @@ struct intel_context
                                struct intel_region * depth_region,
                               GLuint num_regions);
 
-      GLuint (*flush_cmd) (void);
-
       void (*reduced_primitive_state) (struct intel_context * intel,
                                        GLenum rprim);
 
@@ -131,14 +135,6 @@ struct intel_context
                                 struct intel_region * draw_region,
                                 struct intel_region * depth_region);
 
-      void (*meta_draw_quad)(struct intel_context *intel,
-                            GLfloat x0, GLfloat x1,
-                            GLfloat y0, GLfloat y1,
-                            GLfloat z,
-                            GLuint color, /* ARGB32 */
-                            GLfloat s0, GLfloat s1,
-                            GLfloat t0, GLfloat t1);
-
       void (*meta_color_mask) (struct intel_context * intel, GLboolean);
 
       void (*meta_stencil_replace) (struct intel_context * intel,
@@ -170,27 +166,27 @@ struct intel_context
 
    struct dri_metaops meta;
 
-   GLint refcount;
-   GLuint Fallback;
+   GLbitfield Fallback;  /**< mask of INTEL_FALLBACK_x bits */
    GLuint NewGLState;
 
    dri_bufmgr *bufmgr;
    unsigned int maxBatchSize;
 
-   struct intel_region *front_region;
-   struct intel_region *back_region;
-   struct intel_region *depth_region;
-
    /**
-    * This value indicates that the kernel memory manager is being used
-    * instead of the fake client-side memory manager.
+    * Generation number of the hardware: 2 is 8xx, 3 is 9xx pre-965, 4 is 965.
     */
-   GLboolean ttm;
+   int gen;
+   GLboolean needs_ff_sync;
+   GLboolean is_ironlake;
+   GLboolean is_g4x;
+   GLboolean is_945;
+   GLboolean has_luminance_srgb;
+
+   int urb_size;
 
    struct intel_batchbuffer *batch;
    drm_intel_bo *first_post_swapbuffers_batch;
    GLboolean no_batch_wrap;
-   unsigned batch_id;
 
    struct
    {
@@ -210,10 +206,6 @@ struct intel_context
    char *prevLockFile;
    int prevLockLine;
 
-   GLuint ClearColor565;
-   GLuint ClearColor8888;
-
-
    /* Offsets of fields within the current vertex:
     */
    GLuint coloroffset;
@@ -230,6 +222,7 @@ struct intel_context
    GLboolean hw_stipple;
    GLboolean depth_buffer_is_float;
    GLboolean no_rast;
+   GLboolean no_hw;
    GLboolean always_flush_batch;
    GLboolean always_flush_cache;
 
@@ -254,19 +247,6 @@ struct intel_context
    intel_line_func draw_line;
    intel_tri_func draw_tri;
 
-   /**
-    * Set to true if a single constant cliprect should be used in the
-    * batchbuffer.  Otherwise, cliprects must be calculated at batchbuffer
-    * flush time while the lock is held.
-    */
-   GLboolean constant_cliprect;
-
-   /**
-    * In !constant_cliprect mode, set to true if the front cliprects should be
-    * used instead of back.
-    */
-   GLboolean front_cliprects;
-
    /**
     * Set if rendering has occured to the drawable's front buffer.
     *
@@ -295,48 +275,23 @@ struct intel_context
    GLboolean use_early_z;
    drm_clip_rect_t fboRect;     /**< cliprect for FBO rendering */
 
-   int perf_boxes;
-
-   GLuint do_usleeps;
-   int do_irqs;
-   GLuint irqsEmitted;
-
-   GLboolean scissor;
    drm_clip_rect_t draw_rect;
    drm_clip_rect_t scissor_rect;
 
-   drm_context_t hHWContext;
-   drmLock *driHwLock;
    int driFd;
 
-   __DRIcontextPrivate *driContext;
-   __DRIdrawablePrivate *driDrawable;
-   __DRIdrawablePrivate *driReadDrawable;
-   __DRIscreenPrivate *driScreen;
+   __DRIcontext *driContext;
+   __DRIdrawable *driDrawable;
+   __DRIdrawable *driReadDrawable;
+   __DRIscreen *driScreen;
    intelScreenPrivate *intelScreen;
-   volatile drm_i915_sarea_t *sarea;
-
-   GLuint lastStamp;
-
-   GLboolean no_hw;
 
    /**
     * Configuration cache
     */
    driOptionCache optionCache;
-
-   int64_t swap_ust;
-   int64_t swap_missed_ust;
-
-   GLuint swap_count;
-   GLuint swap_missed_count;
 };
 
-/* These are functions now:
- */
-void LOCK_HARDWARE( struct intel_context *intel );
-void UNLOCK_HARDWARE( struct intel_context *intel );
-
 extern char *__progname;
 
 
@@ -347,35 +302,25 @@ extern char *__progname;
 #define ALIGN(value, alignment)  ((value + alignment - 1) & ~(alignment - 1))
 #define IS_POWER_OF_TWO(val) (((val) & (val - 1)) == 0)
 
+static INLINE uint32_t
+U_FIXED(float value, uint32_t frac_bits)
+{
+   value *= (1 << frac_bits);
+   return value < 0 ? 0 : value;
+}
+
+static INLINE uint32_t
+S_FIXED(float value, uint32_t frac_bits)
+{
+   return value * (1 << frac_bits);
+}
+
 #define INTEL_FIREVERTICES(intel)              \
 do {                                           \
    if ((intel)->prim.flush)                    \
       (intel)->prim.flush(intel);              \
 } while (0)
 
-/* ================================================================
- * Color packing:
- */
-
-#define INTEL_PACKCOLOR4444(r,g,b,a) \
-  ((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4))
-
-#define INTEL_PACKCOLOR1555(r,g,b,a) \
-  ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \
-    ((a) ? 0x8000 : 0))
-
-#define INTEL_PACKCOLOR565(r,g,b) \
-  ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
-
-#define INTEL_PACKCOLOR8888(r,g,b,a) \
-  ((a<<24) | (r<<16) | (g<<8) | b)
-
-#define INTEL_PACKCOLOR(format, r,  g,  b, a)          \
-(format == DV_PF_555 ? INTEL_PACKCOLOR1555(r,g,b,a) :  \
- (format == DV_PF_565 ? INTEL_PACKCOLOR565(r,g,b) :    \
-  (format == DV_PF_8888 ? INTEL_PACKCOLOR8888(r,g,b,a) :       \
-   0)))
-
 /* ================================================================
  * From linux kernel i386 header files, copes with odd sizes better
  * than COPY_DWORDS would:
@@ -461,12 +406,10 @@ extern int INTEL_DEBUG;
 
 extern GLboolean intelInitContext(struct intel_context *intel,
                                   const __GLcontextModes * mesaVis,
-                                  __DRIcontextPrivate * driContextPriv,
+                                  __DRIcontext * driContextPriv,
                                   void *sharedContextPrivate,
                                   struct dd_function_table *functions);
 
-extern void intelGetLock(struct intel_context *intel, GLuint flags);
-
 extern void intelFinish(GLcontext * ctx);
 extern void intelFlush(GLcontext * ctx);
 
@@ -568,4 +511,25 @@ is_power_of_two(uint32_t value)
    return (value & (value - 1)) == 0;
 }
 
+static INLINE void
+intel_bo_map_gtt_preferred(struct intel_context *intel,
+                          drm_intel_bo *bo,
+                          GLboolean write)
+{
+   if (intel->intelScreen->kernel_exec_fencing)
+      drm_intel_gem_bo_map_gtt(bo);
+   else
+      drm_intel_bo_map(bo, write);
+}
+
+static INLINE void
+intel_bo_unmap_gtt_preferred(struct intel_context *intel,
+                            drm_intel_bo *bo)
+{
+   if (intel->intelScreen->kernel_exec_fencing)
+      drm_intel_gem_bo_unmap_gtt(bo);
+   else
+      drm_intel_bo_unmap(bo);
+}
+
 #endif
index 16d77084530df3040c97e3488328aee3b7b44c7e..a9c75d44cf333b9accd1aaa1eb90cb337dcdc509 100644 (file)
  * all the tiling styles.
  */
 
+#define VALUE_TYPE INTEL_VALUE_TYPE
+#define WRITE_DEPTH(_x, _y, d) \
+   (*(INTEL_VALUE_TYPE *)(irb->region->buffer->virtual +       \
+                         NO_TILE(_x, _y)) = d)
+#define READ_DEPTH(d, _x, _y) \
+   d = *(INTEL_VALUE_TYPE *)(irb->region->buffer->virtual +    \
+                            NO_TILE(_x, _y))
+#define TAG(x) INTEL_TAG(intel_gttmap_##x)
+#include "depthtmp.h"
+
 #define VALUE_TYPE INTEL_VALUE_TYPE
 #define WRITE_DEPTH(_x, _y, d) INTEL_WRITE_DEPTH(NO_TILE(_x, _y), d)
 #define READ_DEPTH(d, _x, _y) d = INTEL_READ_DEPTH(NO_TILE(_x, _y))
index 2eb08a8f057e1918e9f813ec9b00b06c7cb5be2e..5ac5ce10afbfd2dfb8b1c90f1b55aa348e33f212 100644 (file)
@@ -28,6 +28,7 @@
 #include "intel_chipset.h"
 #include "intel_context.h"
 #include "intel_extensions.h"
+#include "utils.h"
 
 
 #define need_GL_ARB_copy_buffer
@@ -63,7 +64,7 @@
 #define need_GL_VERSION_2_0
 #define need_GL_VERSION_2_1
 
-#include "extension_helper.h"
+#include "main/remap_helper.h"
 
 
 /**
@@ -78,6 +79,7 @@ static const struct dri_extension card_extensions[] = {
    { "GL_ARB_half_float_pixel",           NULL },
    { "GL_ARB_map_buffer_range",           GL_ARB_map_buffer_range_functions },
    { "GL_ARB_multitexture",               NULL },
+   { "GL_ARB_pixel_buffer_object",      NULL },
    { "GL_ARB_point_parameters",           GL_ARB_point_parameters_functions },
    { "GL_ARB_point_sprite",               NULL },
    { "GL_ARB_shader_objects",             GL_ARB_shader_objects_functions },
@@ -103,6 +105,8 @@ static const struct dri_extension card_extensions[] = {
    { "GL_EXT_blend_logic_op",             NULL },
    { "GL_EXT_blend_subtract",             NULL },
    { "GL_EXT_cull_vertex",                GL_EXT_cull_vertex_functions },
+   { "GL_EXT_framebuffer_blit",         GL_EXT_framebuffer_blit_functions },
+   { "GL_EXT_framebuffer_object",       GL_EXT_framebuffer_object_functions },
    { "GL_EXT_fog_coord",                  GL_EXT_fog_coord_functions },
    { "GL_EXT_gpu_program_parameters",     GL_EXT_gpu_program_parameters_functions },
    { "GL_EXT_packed_depth_stencil",       NULL },
@@ -120,7 +124,6 @@ static const struct dri_extension card_extensions[] = {
    { "GL_MESA_pack_invert",               NULL },
    { "GL_MESA_ycbcr_texture",             NULL },
    { "GL_NV_blend_square",                NULL },
-   { "GL_NV_point_sprite",                GL_NV_point_sprite_functions },
    { "GL_NV_vertex_program",              GL_NV_vertex_program_functions },
    { "GL_NV_vertex_program1_1",           NULL },
    { "GL_SGIS_generate_mipmap",           NULL },
@@ -175,14 +178,6 @@ static const struct dri_extension arb_oq_extensions[] = {
    { NULL, NULL }
 };
 
-
-static const struct dri_extension ttm_extensions[] = {
-   { "GL_ARB_pixel_buffer_object",      NULL },
-   { "GL_EXT_framebuffer_blit",         GL_EXT_framebuffer_blit_functions },
-   { "GL_EXT_framebuffer_object",       GL_EXT_framebuffer_object_functions },
-   { NULL, NULL }
-};
-
 static const struct dri_extension fragment_shader_extensions[] = {
    { "GL_ARB_fragment_shader",            NULL },
    { NULL, NULL }
@@ -193,31 +188,24 @@ static const struct dri_extension fragment_shader_extensions[] = {
  * extensions for a context.
  */
 void
-intelInitExtensions(GLcontext *ctx, GLboolean enable_imaging)
+intelInitExtensions(GLcontext *ctx)
 {
-   struct intel_context *intel = ctx?intel_context(ctx):NULL;
+   struct intel_context *intel = intel_context(ctx);
 
    /* Disable imaging extension until convolution is working in teximage paths.
     */
-   enable_imaging = GL_FALSE;
-
-   driInitExtensions(ctx, card_extensions, enable_imaging);
-
-   if (intel == NULL || intel->ttm)
-      driInitExtensions(ctx, ttm_extensions, GL_FALSE);
+   driInitExtensions(ctx, card_extensions, GL_FALSE);
 
-   if (intel == NULL || IS_965(intel->intelScreen->deviceID))
+   if (intel->gen >= 4)
       driInitExtensions(ctx, brw_extensions, GL_FALSE);
 
-   if (intel == NULL || IS_915(intel->intelScreen->deviceID)
-       || IS_945(intel->intelScreen->deviceID)) {
+   if (intel->gen == 3) {
       driInitExtensions(ctx, i915_extensions, GL_FALSE);
 
-      if (intel == NULL || driQueryOptionb(&intel->optionCache, "fragment_shader"))
+      if (driQueryOptionb(&intel->optionCache, "fragment_shader"))
         driInitExtensions(ctx, fragment_shader_extensions, GL_FALSE);
 
-      if (intel == NULL || driQueryOptionb(&intel->optionCache,
-                                          "stub_occlusion_query"))
+      if (driQueryOptionb(&intel->optionCache, "stub_occlusion_query"))
         driInitExtensions(ctx, arb_oq_extensions, GL_FALSE);
    }
 }
index 97147ecdb0fd1316ce3e0cc1a3090391786e84f7..1d1c97a4a9be23e810c03bba334b9919244e8b30 100644 (file)
@@ -30,7 +30,7 @@
 
 
 extern void
-intelInitExtensions(GLcontext *ctx, GLboolean enable_imaging);
+intelInitExtensions(GLcontext *ctx);
 
 
 #endif
index 8dfb24290d5c2323818f56c81c088f9c3db86e3d..d58ffd95fa6fef38f26d43193bf70b5342fdb61a 100644 (file)
 #include "main/framebuffer.h"
 #include "main/renderbuffer.h"
 #include "main/context.h"
-#include "main/texformat.h"
 #include "main/texrender.h"
 #include "drivers/common/meta.h"
 
 #include "intel_context.h"
+#include "intel_batchbuffer.h"
 #include "intel_buffers.h"
 #include "intel_fbo.h"
 #include "intel_mipmap_tree.h"
@@ -106,8 +106,8 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
 {
    struct intel_context *intel = intel_context(ctx);
    struct intel_renderbuffer *irb = intel_renderbuffer(rb);
-   GLboolean softwareBuffer = GL_FALSE;
    int cpp;
+   GLuint pitch;
 
    ASSERT(rb->Name != 0);
 
@@ -115,27 +115,16 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
    case GL_R3_G3_B2:
    case GL_RGB4:
    case GL_RGB5:
-      rb->_ActualFormat = GL_RGB5;
+      rb->Format = MESA_FORMAT_RGB565;
       rb->DataType = GL_UNSIGNED_BYTE;
-      rb->RedBits = 5;
-      rb->GreenBits = 6;
-      rb->BlueBits = 5;
-      irb->texformat = &_mesa_texformat_rgb565;
-      cpp = 2;
       break;
    case GL_RGB:
    case GL_RGB8:
    case GL_RGB10:
    case GL_RGB12:
    case GL_RGB16:
-      rb->_ActualFormat = GL_RGB8;
+      rb->Format = MESA_FORMAT_XRGB8888;
       rb->DataType = GL_UNSIGNED_BYTE;
-      rb->RedBits = 8;
-      rb->GreenBits = 8;
-      rb->BlueBits = 8;
-      rb->AlphaBits = 0;
-      irb->texformat = &_mesa_texformat_argb8888; /* XXX: Need xrgb8888 */
-      cpp = 4;
       break;
    case GL_RGBA:
    case GL_RGBA2:
@@ -145,14 +134,8 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
    case GL_RGB10_A2:
    case GL_RGBA12:
    case GL_RGBA16:
-      rb->_ActualFormat = GL_RGBA8;
+      rb->Format = MESA_FORMAT_ARGB8888;
       rb->DataType = GL_UNSIGNED_BYTE;
-      rb->RedBits = 8;
-      rb->GreenBits = 8;
-      rb->BlueBits = 8;
-      rb->AlphaBits = 8;
-      irb->texformat = &_mesa_texformat_argb8888;
-      cpp = 4;
       break;
    case GL_STENCIL_INDEX:
    case GL_STENCIL_INDEX1_EXT:
@@ -160,36 +143,23 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
    case GL_STENCIL_INDEX8_EXT:
    case GL_STENCIL_INDEX16_EXT:
       /* alloc a depth+stencil buffer */
-      rb->_ActualFormat = GL_DEPTH24_STENCIL8_EXT;
+      rb->Format = MESA_FORMAT_S8_Z24;
       rb->DataType = GL_UNSIGNED_INT_24_8_EXT;
-      rb->StencilBits = 8;
-      cpp = 4;
-      irb->texformat = &_mesa_texformat_s8_z24;
       break;
    case GL_DEPTH_COMPONENT16:
-      rb->_ActualFormat = GL_DEPTH_COMPONENT16;
+      rb->Format = MESA_FORMAT_Z16;
       rb->DataType = GL_UNSIGNED_SHORT;
-      rb->DepthBits = 16;
-      cpp = 2;
-      irb->texformat = &_mesa_texformat_z16;
       break;
    case GL_DEPTH_COMPONENT:
    case GL_DEPTH_COMPONENT24:
    case GL_DEPTH_COMPONENT32:
-      rb->_ActualFormat = GL_DEPTH24_STENCIL8_EXT;
+      rb->Format = MESA_FORMAT_S8_Z24;
       rb->DataType = GL_UNSIGNED_INT_24_8_EXT;
-      rb->DepthBits = 24;
-      cpp = 4;
-      irb->texformat = &_mesa_texformat_s8_z24;
       break;
    case GL_DEPTH_STENCIL_EXT:
    case GL_DEPTH24_STENCIL8_EXT:
-      rb->_ActualFormat = GL_DEPTH24_STENCIL8_EXT;
+      rb->Format = MESA_FORMAT_S8_Z24;
       rb->DataType = GL_UNSIGNED_INT_24_8_EXT;
-      rb->DepthBits = 24;
-      rb->StencilBits = 8;
-      cpp = 4;
-      irb->texformat = &_mesa_texformat_s8_z24;
       break;
    default:
       _mesa_problem(ctx,
@@ -197,6 +167,9 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
       return GL_FALSE;
    }
 
+   rb->_BaseFormat = _mesa_base_fbo_format(ctx, internalFormat);
+   cpp = _mesa_get_format_bytes(rb->Format);
+
    intelFlush(ctx);
 
    /* free old region */
@@ -205,32 +178,25 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
    }
 
    /* allocate new memory region/renderbuffer */
-   if (softwareBuffer) {
-      return _mesa_soft_renderbuffer_storage(ctx, rb, internalFormat,
-                                             width, height);
-   }
-   else {
-      /* Choose a pitch to match hardware requirements:
-       */
-      GLuint pitch = ((cpp * width + 63) & ~63) / cpp;
 
-      /* alloc hardware renderbuffer */
-      DBG("Allocating %d x %d Intel RBO (pitch %d)\n", width,
-         height, pitch);
+   /* Choose a pitch to match hardware requirements:
+    */
+   pitch = ((cpp * width + 63) & ~63) / cpp;
+
+   /* alloc hardware renderbuffer */
+   DBG("Allocating %d x %d Intel RBO (pitch %d)\n", width, height, pitch);
 
-      irb->region = intel_region_alloc(intel, I915_TILING_NONE,
-                                      cpp, width, height, pitch,
-                                      GL_TRUE);
-      if (!irb->region)
-         return GL_FALSE;       /* out of memory? */
+   irb->region = intel_region_alloc(intel, I915_TILING_NONE, cpp,
+                                   width, height, pitch, GL_TRUE);
+   if (!irb->region)
+      return GL_FALSE;       /* out of memory? */
 
-      ASSERT(irb->region->buffer);
+   ASSERT(irb->region->buffer);
 
-      rb->Width = width;
-      rb->Height = height;
+   rb->Width = width;
+   rb->Height = height;
 
-      return GL_TRUE;
-   }
+   return GL_TRUE;
 }
 
 
@@ -246,7 +212,7 @@ intel_alloc_window_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
    ASSERT(rb->Name == 0);
    rb->Width = width;
    rb->Height = height;
-   rb->_ActualFormat = internalFormat;
+   rb->InternalFormat = internalFormat;
 
    return GL_TRUE;
 }
@@ -256,7 +222,6 @@ static void
 intel_resize_buffers(GLcontext *ctx, struct gl_framebuffer *fb,
                     GLuint width, GLuint height)
 {
-   struct intel_framebuffer *intel_fb = (struct intel_framebuffer*)fb;
    int i;
 
    _mesa_resize_framebuffer(ctx, fb, width, height);
@@ -267,9 +232,10 @@ intel_resize_buffers(GLcontext *ctx, struct gl_framebuffer *fb,
       return;
    }
 
+
    /* Make sure all window system renderbuffers are up to date */
-   for (i = 0; i < 2; i++) {
-      struct gl_renderbuffer *rb = &intel_fb->color_rb[i]->Base;
+   for (i = BUFFER_FRONT_LEFT; i <= BUFFER_BACK_RIGHT; i++) {
+      struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer;
 
       /* only resize if size is changing */
       if (rb && (rb->Width != width || rb->Height != height)) {
@@ -307,12 +273,11 @@ intel_renderbuffer_set_region(struct intel_renderbuffer *rb,
  * not a user-created renderbuffer.
  */
 struct intel_renderbuffer *
-intel_create_renderbuffer(GLenum intFormat)
+intel_create_renderbuffer(gl_format format)
 {
    GET_CURRENT_CONTEXT(ctx);
 
    struct intel_renderbuffer *irb;
-   const GLuint name = 0;
 
    irb = CALLOC_STRUCT(intel_renderbuffer);
    if (!irb) {
@@ -320,75 +285,43 @@ intel_create_renderbuffer(GLenum intFormat)
       return NULL;
    }
 
-   _mesa_init_renderbuffer(&irb->Base, name);
+   _mesa_init_renderbuffer(&irb->Base, 0);
    irb->Base.ClassID = INTEL_RB_CLASS;
 
-   switch (intFormat) {
-   case GL_RGB5:
-      irb->Base._ActualFormat = GL_RGB5;
-      irb->Base._BaseFormat = GL_RGBA;
-      irb->Base.RedBits = 5;
-      irb->Base.GreenBits = 6;
-      irb->Base.BlueBits = 5;
+   switch (format) {
+   case MESA_FORMAT_RGB565:
+      irb->Base._BaseFormat = GL_RGB;
       irb->Base.DataType = GL_UNSIGNED_BYTE;
-      irb->texformat = &_mesa_texformat_rgb565;
       break;
-   case GL_RGB8:
-      irb->Base._ActualFormat = GL_RGB8;
+   case MESA_FORMAT_XRGB8888:
       irb->Base._BaseFormat = GL_RGB;
-      irb->Base.RedBits = 8;
-      irb->Base.GreenBits = 8;
-      irb->Base.BlueBits = 8;
-      irb->Base.AlphaBits = 0;
       irb->Base.DataType = GL_UNSIGNED_BYTE;
-      irb->texformat = &_mesa_texformat_argb8888; /* XXX: Need xrgb8888 */
       break;
-   case GL_RGBA8:
-      irb->Base._ActualFormat = GL_RGBA8;
+   case MESA_FORMAT_ARGB8888:
       irb->Base._BaseFormat = GL_RGBA;
-      irb->Base.RedBits = 8;
-      irb->Base.GreenBits = 8;
-      irb->Base.BlueBits = 8;
-      irb->Base.AlphaBits = 8;
-      irb->Base.DataType = GL_UNSIGNED_BYTE;
-      irb->texformat = &_mesa_texformat_argb8888;
-      break;
-   case GL_STENCIL_INDEX8_EXT:
-      irb->Base._ActualFormat = GL_STENCIL_INDEX8_EXT;
-      irb->Base._BaseFormat = GL_STENCIL_INDEX;
-      irb->Base.StencilBits = 8;
       irb->Base.DataType = GL_UNSIGNED_BYTE;
-      irb->texformat = &_mesa_texformat_s8_z24;
       break;
-   case GL_DEPTH_COMPONENT16:
-      irb->Base._ActualFormat = GL_DEPTH_COMPONENT16;
+   case MESA_FORMAT_Z16:
       irb->Base._BaseFormat = GL_DEPTH_COMPONENT;
-      irb->Base.DepthBits = 16;
       irb->Base.DataType = GL_UNSIGNED_SHORT;
-      irb->texformat = &_mesa_texformat_z16;
       break;
-   case GL_DEPTH_COMPONENT24:
-      irb->Base._ActualFormat = GL_DEPTH24_STENCIL8_EXT;
+   case MESA_FORMAT_X8_Z24:
       irb->Base._BaseFormat = GL_DEPTH_COMPONENT;
-      irb->Base.DepthBits = 24;
       irb->Base.DataType = GL_UNSIGNED_INT;
-      irb->texformat = &_mesa_texformat_s8_z24;
       break;
-   case GL_DEPTH24_STENCIL8_EXT:
-      irb->Base._ActualFormat = GL_DEPTH24_STENCIL8_EXT;
-      irb->Base._BaseFormat = GL_DEPTH_STENCIL_EXT;
-      irb->Base.DepthBits = 24;
-      irb->Base.StencilBits = 8;
+   case MESA_FORMAT_S8_Z24:
+      irb->Base._BaseFormat = GL_DEPTH_STENCIL;
       irb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT;
-      irb->texformat = &_mesa_texformat_s8_z24;
       break;
    default:
       _mesa_problem(NULL,
                     "Unexpected intFormat in intel_create_renderbuffer");
+      _mesa_free(irb);
       return NULL;
    }
 
-   irb->Base.InternalFormat = intFormat;
+   irb->Base.Format = format;
+   irb->Base.InternalFormat = irb->Base._BaseFormat;
 
    /* intel-specific methods */
    irb->Base.Delete = intel_delete_renderbuffer;
@@ -465,59 +398,46 @@ static GLboolean
 intel_update_wrapper(GLcontext *ctx, struct intel_renderbuffer *irb, 
                     struct gl_texture_image *texImage)
 {
-   irb->texformat = texImage->TexFormat;
-
-   if (texImage->TexFormat == &_mesa_texformat_argb8888) {
-      irb->Base._ActualFormat = GL_RGBA8;
-      irb->Base._BaseFormat = GL_RGBA;
+   if (texImage->TexFormat == MESA_FORMAT_ARGB8888) {
       irb->Base.DataType = GL_UNSIGNED_BYTE;
       DBG("Render to RGBA8 texture OK\n");
    }
-   else if (texImage->TexFormat == &_mesa_texformat_rgb565) {
-      irb->Base._ActualFormat = GL_RGB5;
-      irb->Base._BaseFormat = GL_RGB;
+   else if (texImage->TexFormat == MESA_FORMAT_XRGB8888) {
+      irb->Base.DataType = GL_UNSIGNED_BYTE;
+      DBG("Render to XGBA8 texture OK\n");
+   }
+   else if (texImage->TexFormat == MESA_FORMAT_RGB565) {
       irb->Base.DataType = GL_UNSIGNED_BYTE;
       DBG("Render to RGB5 texture OK\n");
    }
-   else if (texImage->TexFormat == &_mesa_texformat_argb1555) {
-      irb->Base._ActualFormat = GL_RGB5_A1;
-      irb->Base._BaseFormat = GL_RGBA;
+   else if (texImage->TexFormat == MESA_FORMAT_ARGB1555) {
       irb->Base.DataType = GL_UNSIGNED_BYTE;
       DBG("Render to ARGB1555 texture OK\n");
    }
-   else if (texImage->TexFormat == &_mesa_texformat_argb4444) {
-      irb->Base._ActualFormat = GL_RGBA4;
-      irb->Base._BaseFormat = GL_RGBA;
+   else if (texImage->TexFormat == MESA_FORMAT_ARGB4444) {
       irb->Base.DataType = GL_UNSIGNED_BYTE;
       DBG("Render to ARGB4444 texture OK\n");
    }
-   else if (texImage->TexFormat == &_mesa_texformat_z16) {
-      irb->Base._ActualFormat = GL_DEPTH_COMPONENT16;
-      irb->Base._BaseFormat = GL_DEPTH_COMPONENT;
+   else if (texImage->TexFormat == MESA_FORMAT_Z16) {
       irb->Base.DataType = GL_UNSIGNED_SHORT;
       DBG("Render to DEPTH16 texture OK\n");
    }
-   else if (texImage->TexFormat == &_mesa_texformat_s8_z24) {
-      irb->Base._ActualFormat = GL_DEPTH24_STENCIL8_EXT;
-      irb->Base._BaseFormat = GL_DEPTH_STENCIL_EXT;
+   else if (texImage->TexFormat == MESA_FORMAT_S8_Z24) {
       irb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT;
       DBG("Render to DEPTH_STENCIL texture OK\n");
    }
    else {
-      DBG("Render to texture BAD FORMAT %d\n",
-         texImage->TexFormat->MesaFormat);
+      DBG("Render to texture BAD FORMAT %s\n",
+         _mesa_get_format_name(texImage->TexFormat));
       return GL_FALSE;
    }
 
-   irb->Base.InternalFormat = irb->Base._ActualFormat;
+   irb->Base.Format = texImage->TexFormat;
+
+   irb->Base.InternalFormat = texImage->InternalFormat;
+   irb->Base._BaseFormat = _mesa_base_fbo_format(ctx, irb->Base.InternalFormat);
    irb->Base.Width = texImage->Width;
    irb->Base.Height = texImage->Height;
-   irb->Base.RedBits = texImage->TexFormat->RedBits;
-   irb->Base.GreenBits = texImage->TexFormat->GreenBits;
-   irb->Base.BlueBits = texImage->TexFormat->BlueBits;
-   irb->Base.AlphaBits = texImage->TexFormat->AlphaBits;
-   irb->Base.DepthBits = texImage->TexFormat->DepthBits;
-   irb->Base.StencilBits = texImage->TexFormat->StencilBits;
 
    irb->Base.Delete = intel_delete_renderbuffer;
    irb->Base.AllocStorage = intel_nop_alloc_storage;
@@ -571,7 +491,7 @@ intel_render_texture(GLcontext * ctx,
       = att->Texture->Image[att->CubeMapFace][att->TextureLevel];
    struct intel_renderbuffer *irb = intel_renderbuffer(att->Renderbuffer);
    struct intel_texture_image *intel_image;
-   GLuint imageOffset;
+   GLuint dst_x, dst_y;
 
    (void) fb;
 
@@ -618,18 +538,17 @@ intel_render_texture(GLcontext * ctx,
    }
 
    /* compute offset of the particular 2D image within the texture region */
-   imageOffset = intel_miptree_image_offset(intel_image->mt,
-                                            att->CubeMapFace,
-                                            att->TextureLevel);
-
-   if (att->Texture->Target == GL_TEXTURE_3D) {
-      const GLuint *offsets = intel_miptree_depth_offsets(intel_image->mt,
-                                                          att->TextureLevel);
-      imageOffset += offsets[att->Zoffset];
-   }
-
-   /* store that offset in the region */
-   intel_image->mt->region->draw_offset = imageOffset;
+   intel_miptree_get_image_offset(intel_image->mt,
+                                 att->TextureLevel,
+                                 att->CubeMapFace,
+                                 att->Zoffset,
+                                 &dst_x, &dst_y);
+
+   intel_image->mt->region->draw_offset = (dst_y * intel_image->mt->pitch +
+                                          dst_x) * intel_image->mt->cpp;
+   intel_image->mt->region->draw_x = dst_x;
+   intel_image->mt->region->draw_y = dst_y;
+   intel_image->used_as_render_target = GL_TRUE;
 
    /* update drawing region, etc */
    intel_draw_buffer(ctx, fb);
@@ -643,19 +562,23 @@ static void
 intel_finish_render_texture(GLcontext * ctx,
                             struct gl_renderbuffer_attachment *att)
 {
-   /* no-op
-    * Previously we released the renderbuffer's intel_region but
-    * that's not necessary and actually caused problems when trying
-    * to do a glRead/CopyPixels from the renderbuffer later.
-    * The region will be released later if the texture is replaced
-    * or the renderbuffer deleted.
-    *
-    * The intention of this driver hook is more of a "done rendering
-    * to texture, please re-twiddle/etc if necessary".
+   struct intel_context *intel = intel_context(ctx);
+   struct gl_texture_object *tex_obj = att->Texture;
+   struct gl_texture_image *image =
+      tex_obj->Image[att->CubeMapFace][att->TextureLevel];
+   struct intel_texture_image *intel_image = intel_texture_image(image);
+
+   /* Flag that this image may now be validated into the object's miptree. */
+   intel_image->used_as_render_target = GL_FALSE;
+
+   /* Since we've (probably) rendered to the texture and will (likely) use
+    * it in the texture domain later on in this batchbuffer, flush the
+    * batch.  Once again, we wish for a domain tracker in libdrm to cover
+    * usage inside of a batchbuffer like GEM does in the kernel.
     */
+   intel_batchbuffer_emit_mi_flush(intel->batch);
 }
 
-
 /**
  * Do additional "completeness" testing of a framebuffer object.
  */
@@ -668,11 +591,21 @@ intel_validate_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb)
       intel_get_renderbuffer(fb, BUFFER_STENCIL);
    int i;
 
-   if (stencilRb && stencilRb != depthRb) {
-      /* we only support combined depth/stencil buffers, not separate
-       * stencil buffers.
-       */
-      fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
+   if (depthRb && stencilRb && stencilRb != depthRb) {
+      if (ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Type == GL_TEXTURE &&
+         ctx->DrawBuffer->Attachment[BUFFER_STENCIL].Type == GL_TEXTURE &&
+         (ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Texture->Name ==
+          ctx->DrawBuffer->Attachment[BUFFER_STENCIL].Texture->Name)) {
+        /* OK */
+      } else {
+        /* we only support combined depth/stencil buffers, not separate
+         * stencil buffers.
+         */
+        DBG("Only supports combined depth/stencil (found %s, %s)\n",
+            depthRb ? _mesa_get_format_name(depthRb->Base.Format): "NULL",
+            stencilRb ? _mesa_get_format_name(stencilRb->Base.Format): "NULL");
+        fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
+      }
    }
 
    for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
@@ -683,12 +616,14 @@ intel_validate_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb)
         continue;
 
       if (irb == NULL) {
+        DBG("software rendering renderbuffer\n");
         fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
         continue;
       }
 
-      switch (irb->texformat->MesaFormat) {
+      switch (irb->Base.Format) {
       case MESA_FORMAT_ARGB8888:
+      case MESA_FORMAT_XRGB8888:
       case MESA_FORMAT_RGB565:
       case MESA_FORMAT_ARGB1555:
       case MESA_FORMAT_ARGB4444:
index f0665af482e787de9fec3ffee426ea60ae228add..586dbbbb25a198863ea957cf52d0758f77907df9 100644 (file)
 #ifndef INTEL_FBO_H
 #define INTEL_FBO_H
 
+#include "main/formats.h"
 #include "intel_screen.h"
 
 struct intel_context;
 
-/**
- * Intel framebuffer, derived from gl_framebuffer.
- */
-struct intel_framebuffer
-{
-   struct gl_framebuffer Base;
-
-   struct intel_renderbuffer *color_rb[2];
-
-   /* VBI
-    */
-   GLuint vbl_waited;
-
-   int64_t swap_ust;
-   int64_t swap_missed_ust;
-
-   GLuint swap_count;
-   GLuint swap_missed_count;
-};
-
-
 /**
  * Intel renderbuffer, derived from gl_renderbuffer.
  */
@@ -61,10 +41,6 @@ struct intel_renderbuffer
    struct gl_renderbuffer Base;
    struct intel_region *region;
 
-   const struct gl_texture_format *texformat;
-
-   GLuint vbl_pending;   /**< vblank sequence number of pending flip */
-
    uint8_t *span_cache;
    unsigned long span_cache_offset;
 };
@@ -114,7 +90,7 @@ intel_renderbuffer_set_region(struct intel_renderbuffer *irb,
 
 
 extern struct intel_renderbuffer *
-intel_create_renderbuffer(GLenum intFormat);
+intel_create_renderbuffer(gl_format format);
 
 
 extern void
@@ -122,7 +98,7 @@ intel_fbo_init(struct intel_context *intel);
 
 
 extern void
-intel_flip_renderbuffers(struct intel_framebuffer *intel_fb);
+intel_flip_renderbuffers(struct gl_framebuffer *fb);
 
 
 static INLINE struct intel_region *
index 4f5101a312870ff7df302238d0feca45a8035d88..82e4150c6a9dc016082985ee774edabf400fb86f 100644 (file)
@@ -28,6 +28,7 @@
 #include "intel_context.h"
 #include "intel_mipmap_tree.h"
 #include "intel_regions.h"
+#include "intel_tex_layout.h"
 #include "intel_chipset.h"
 #ifndef I915
 #include "brw_state.h"
@@ -36,6 +37,7 @@
 
 #define FILE_DEBUG_FLAG DEBUG_MIPTREE
 
+
 static GLenum
 target_to_target(GLenum target)
 {
@@ -52,6 +54,7 @@ target_to_target(GLenum target)
    }
 }
 
+
 static struct intel_mipmap_tree *
 intel_miptree_create_internal(struct intel_context *intel,
                              GLenum target,
@@ -84,7 +87,7 @@ intel_miptree_create_internal(struct intel_context *intel,
    mt->pitch = 0;
 
 #ifdef I915
-   if (IS_945(intel->intelScreen->deviceID))
+   if (intel->is_945)
       ok = i945_miptree_layout(intel, mt, tiling);
    else
       ok = i915_miptree_layout(intel, mt, tiling);
@@ -101,6 +104,7 @@ intel_miptree_create_internal(struct intel_context *intel,
    return mt;
 }
 
+
 struct intel_mipmap_tree *
 intel_miptree_create(struct intel_context *intel,
                     GLenum target,
@@ -118,7 +122,7 @@ intel_miptree_create(struct intel_context *intel,
 
    if (intel->use_texture_tiling && compress_byte == 0 &&
        intel->intelScreen->kernel_exec_fencing) {
-      if (IS_965(intel->intelScreen->deviceID) &&
+      if (intel->gen >= 4 &&
          (base_format == GL_DEPTH_COMPONENT ||
           base_format == GL_DEPTH_STENCIL_EXT))
         tiling = I915_TILING_Y;
@@ -134,8 +138,10 @@ intel_miptree_create(struct intel_context *intel,
    /*
     * pitch == 0 || height == 0  indicates the null texture
     */
-   if (!mt || !mt->pitch || !mt->total_height)
+   if (!mt || !mt->pitch || !mt->total_height) {
+      free(mt);
       return NULL;
+   }
 
    mt->region = intel_region_alloc(intel,
                                   tiling,
@@ -153,6 +159,7 @@ intel_miptree_create(struct intel_context *intel,
    return mt;
 }
 
+
 struct intel_mipmap_tree *
 intel_miptree_create_for_region(struct intel_context *intel,
                                GLenum target,
@@ -190,7 +197,8 @@ intel_miptree_create_for_region(struct intel_context *intel,
    intel_region_reference(&mt->region, region);
 
    return mt;
- }
+}
+
 
 /**
  * intel_miptree_pitch_align:
@@ -204,7 +212,6 @@ intel_miptree_create_for_region(struct intel_context *intel,
  * Given @pitch, compute a larger value which accounts for
  * any necessary alignment required by the device
  */
-
 int intel_miptree_pitch_align (struct intel_context *intel,
                               struct intel_mipmap_tree *mt,
                               uint32_t tiling,
@@ -217,16 +224,12 @@ int intel_miptree_pitch_align (struct intel_context *intel,
    if (!mt->compressed) {
       int pitch_align;
 
-      if (intel->ttm) {
-        /* XXX: Align pitch to multiple of 64 bytes for now to allow
-         * render-to-texture to work in all cases. This should probably be
-         * replaced at some point by some scheme to only do this when really
-         * necessary.
-         */
-        pitch_align = 64;
-      } else {
-        pitch_align = 4;
-      }
+      /* XXX: Align pitch to multiple of 64 bytes for now to allow
+       * render-to-texture to work in all cases. This should probably be
+       * replaced at some point by some scheme to only do this when really
+       * necessary.
+       */
+      pitch_align = 64;
 
       if (tiling == I915_TILING_X)
         pitch_align = 512;
@@ -250,6 +253,7 @@ int intel_miptree_pitch_align (struct intel_context *intel,
    return pitch;
 }
 
+
 void
 intel_miptree_reference(struct intel_mipmap_tree **dst,
                         struct intel_mipmap_tree *src)
@@ -259,6 +263,7 @@ intel_miptree_reference(struct intel_mipmap_tree **dst,
    DBG("%s %p refcount now %d\n", __FUNCTION__, src, src->refcount);
 }
 
+
 void
 intel_miptree_release(struct intel_context *intel,
                       struct intel_mipmap_tree **mt)
@@ -287,9 +292,10 @@ intel_miptree_release(struct intel_context *intel,
 
       intel_region_release(&((*mt)->region));
 
-      for (i = 0; i < MAX_TEXTURE_LEVELS; i++)
-         if ((*mt)->level[i].image_offset)
-            free((*mt)->level[i].image_offset);
+      for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
+        free((*mt)->level[i].x_offset);
+        free((*mt)->level[i].y_offset);
+      }
 
       free(*mt);
    }
@@ -297,33 +303,31 @@ intel_miptree_release(struct intel_context *intel,
 }
 
 
-
-
-/* Can the image be pulled into a unified mipmap tree.  This mirrors
+/**
+ * Can the image be pulled into a unified mipmap tree?  This mirrors
  * the completeness test in a lot of ways.
  *
  * Not sure whether I want to pass gl_texture_image here.
  */
 GLboolean
 intel_miptree_match_image(struct intel_mipmap_tree *mt,
-                          struct gl_texture_image *image,
-                          GLuint face, GLuint level)
+                          struct gl_texture_image *image)
 {
-   /* Images with borders are never pulled into mipmap trees. 
-    */
-   if (image->Border ||
-       ((image->_BaseFormat == GL_DEPTH_COMPONENT) &&
-        ((image->TexObject->WrapS == GL_CLAMP_TO_BORDER) ||
-         (image->TexObject->WrapT == GL_CLAMP_TO_BORDER)))) 
+   GLboolean isCompressed = _mesa_is_format_compressed(image->TexFormat);
+   struct intel_texture_image *intelImage = intel_texture_image(image);
+   GLuint level = intelImage->level;
+
+   /* Images with borders are never pulled into mipmap trees. */
+   if (image->Border)
       return GL_FALSE;
 
    if (image->InternalFormat != mt->internal_format ||
-       image->IsCompressed != mt->compressed)
+       isCompressed != mt->compressed)
       return GL_FALSE;
 
-   if (!image->IsCompressed &&
+   if (!isCompressed &&
        !mt->compressed &&
-       image->TexFormat->TexelBytes != mt->cpp)
+       _mesa_get_format_bytes(image->TexFormat) != mt->cpp)
       return GL_FALSE;
 
    /* Test image dimensions against the base level image adjusted for
@@ -350,82 +354,59 @@ intel_miptree_set_level_info(struct intel_mipmap_tree *mt,
    mt->level[level].height = h;
    mt->level[level].depth = d;
    mt->level[level].level_offset = (x + y * mt->pitch) * mt->cpp;
+   mt->level[level].level_x = x;
+   mt->level[level].level_y = y;
    mt->level[level].nr_images = nr_images;
 
    DBG("%s level %d size: %d,%d,%d offset %d,%d (0x%x)\n", __FUNCTION__,
        level, w, h, d, x, y, mt->level[level].level_offset);
 
-   /* Not sure when this would happen, but anyway: 
-    */
-   if (mt->level[level].image_offset) {
-      free(mt->level[level].image_offset);
-      mt->level[level].image_offset = NULL;
-   }
-
    assert(nr_images);
+   assert(!mt->level[level].x_offset);
 
-   mt->level[level].image_offset = malloc(nr_images * sizeof(GLuint));
-   mt->level[level].image_offset[0] = 0;
+   mt->level[level].x_offset = malloc(nr_images * sizeof(GLuint));
+   mt->level[level].x_offset[0] = mt->level[level].level_x;
+   mt->level[level].y_offset = malloc(nr_images * sizeof(GLuint));
+   mt->level[level].y_offset[0] = mt->level[level].level_y;
 }
 
 
-void
-intel_miptree_set_image_offset_ex(struct intel_mipmap_tree *mt,
-                                  GLuint level, GLuint img,
-                                  GLuint x, GLuint y, 
-                                  GLuint offset)
-{
-   if (img == 0 && level == 0)
-      assert(x == 0 && y == 0);
-
-   assert(img < mt->level[level].nr_images);
-
-   mt->level[level].image_offset[img] = (x + y * mt->pitch) * mt->cpp + offset;
-
-   DBG("%s level %d img %d pos %d,%d image_offset %x\n",
-       __FUNCTION__, level, img, x, y, mt->level[level].image_offset[img]);
-}
-
 void
 intel_miptree_set_image_offset(struct intel_mipmap_tree *mt,
                               GLuint level, GLuint img,
                               GLuint x, GLuint y)
 {
-    intel_miptree_set_image_offset_ex(mt, level, img, x, y, 0);
-}
+   if (img == 0 && level == 0)
+      assert(x == 0 && y == 0);
 
+   assert(img < mt->level[level].nr_images);
 
-/* Although we use the image_offset[] array to store relative offsets
- * to cube faces, Mesa doesn't know anything about this and expects
- * each cube face to be treated as a separate image.
- *
- * These functions present that view to mesa:
- */
-const GLuint *
-intel_miptree_depth_offsets(struct intel_mipmap_tree *mt, GLuint level)
-{
-   static const GLuint zero = 0;
+   mt->level[level].x_offset[img] = mt->level[level].level_x + x;
+   mt->level[level].y_offset[img] = mt->level[level].level_y + y;
 
-   if (mt->target != GL_TEXTURE_3D || mt->level[level].nr_images == 1)
-      return &zero;
-   else
-      return mt->level[level].image_offset;
+   DBG("%s level %d img %d pos %d,%d\n",
+       __FUNCTION__, level, img,
+       mt->level[level].x_offset[img], mt->level[level].y_offset[img]);
 }
 
 
-GLuint
-intel_miptree_image_offset(struct intel_mipmap_tree *mt,
-                          GLuint face, GLuint level)
+void
+intel_miptree_get_image_offset(struct intel_mipmap_tree *mt,
+                              GLuint level, GLuint face, GLuint depth,
+                              GLuint *x, GLuint *y)
 {
-   if (mt->target == GL_TEXTURE_CUBE_MAP_ARB)
-      return (mt->level[level].level_offset +
-             mt->level[level].image_offset[face]);
-   else
-      return mt->level[level].level_offset;
+   if (mt->target == GL_TEXTURE_CUBE_MAP_ARB) {
+      *x = mt->level[level].x_offset[face];
+      *y = mt->level[level].y_offset[face];
+   } else if (mt->target == GL_TEXTURE_3D) {
+      *x = mt->level[level].x_offset[depth];
+      *y = mt->level[level].y_offset[depth];
+   } else {
+      *x = mt->level[level].x_offset[0];
+      *y = mt->level[level].y_offset[0];
+   }
 }
 
-
-
 /**
  * Map a teximage in a mipmap tree.
  * \param row_stride  returns row stride in bytes
@@ -441,6 +422,7 @@ intel_miptree_image_map(struct intel_context * intel,
                         GLuint level,
                         GLuint * row_stride, GLuint * image_offsets)
 {
+   GLuint x, y;
    DBG("%s \n", __FUNCTION__);
 
    if (row_stride)
@@ -449,19 +431,26 @@ intel_miptree_image_map(struct intel_context * intel,
    if (mt->target == GL_TEXTURE_3D) {
       int i;
 
-      for (i = 0; i < mt->level[level].depth; i++)
-        image_offsets[i] = mt->level[level].image_offset[i] / mt->cpp;
+      for (i = 0; i < mt->level[level].depth; i++) {
+
+        intel_miptree_get_image_offset(mt, level, face, i,
+                                       &x, &y);
+        image_offsets[i] = x + y * mt->pitch;
+      }
+
+      return intel_region_map(intel, mt->region);
    } else {
       assert(mt->level[level].depth == 1);
-      assert(mt->target == GL_TEXTURE_CUBE_MAP ||
-            mt->level[level].image_offset[0] == 0);
+      intel_miptree_get_image_offset(mt, level, face, 0,
+                                    &x, &y);
       image_offsets[0] = 0;
-   }
 
-   return (intel_region_map(intel, mt->region) +
-           intel_miptree_image_offset(mt, face, level));
+      return intel_region_map(intel, mt->region) +
+        (x + y * mt->pitch) * mt->cpp;
+   }
 }
 
+
 void
 intel_miptree_image_unmap(struct intel_context *intel,
                           struct intel_mipmap_tree *mt)
@@ -471,8 +460,8 @@ intel_miptree_image_unmap(struct intel_context *intel,
 }
 
 
-
-/* Upload data for a particular image.
+/**
+ * Upload data for a particular image.
  */
 void
 intel_miptree_image_data(struct intel_context *intel,
@@ -483,21 +472,21 @@ intel_miptree_image_data(struct intel_context *intel,
                         GLuint src_row_pitch,
                         GLuint src_image_pitch)
 {
-   GLuint depth = dst->level[level].depth;
-   GLuint dst_offset = intel_miptree_image_offset(dst, face, level);
-   const GLuint *dst_depth_offset = intel_miptree_depth_offsets(dst, level);
+   const GLuint depth = dst->level[level].depth;
    GLuint i;
-   GLuint height = 0;
 
    DBG("%s: %d/%d\n", __FUNCTION__, face, level);
    for (i = 0; i < depth; i++) {
+      GLuint dst_x, dst_y, height;
+
+      intel_miptree_get_image_offset(dst, level, face, i, &dst_x, &dst_y);
+
       height = dst->level[level].height;
       if(dst->compressed)
         height = (height + 3) / 4;
+
       intel_region_data(intel,
-                       dst->region,
-                       dst_offset + dst_depth_offset[i], /* dst_offset */
-                       0, 0,                             /* dstx, dsty */
+                       dst->region, 0, dst_x, dst_y,
                        src,
                        src_row_pitch,
                        0, 0,                             /* source x, y */
@@ -507,8 +496,9 @@ intel_miptree_image_data(struct intel_context *intel,
    }
 }
 
-extern void intel_get_texture_alignment_unit(GLenum, GLuint *, GLuint *);
-/* Copy mipmap image between trees
+
+/**
+ * Copy mipmap image between trees
  */
 void
 intel_miptree_image_copy(struct intel_context *intel,
@@ -519,38 +509,37 @@ intel_miptree_image_copy(struct intel_context *intel,
    GLuint width = src->level[level].width;
    GLuint height = src->level[level].height;
    GLuint depth = src->level[level].depth;
-   GLuint dst_offset = intel_miptree_image_offset(dst, face, level);
-   GLuint src_offset = intel_miptree_image_offset(src, face, level);
-   const GLuint *dst_depth_offset = intel_miptree_depth_offsets(dst, level);
-   const GLuint *src_depth_offset = intel_miptree_depth_offsets(src, level);
+   GLuint src_x, src_y, dst_x, dst_y;
    GLuint i;
    GLboolean success;
 
    if (dst->compressed) {
        GLuint align_w, align_h;
 
-       intel_get_texture_alignment_unit(dst->internal_format, &align_w, &align_h);
+       intel_get_texture_alignment_unit(dst->internal_format,
+                                        &align_w, &align_h);
        height = (height + 3) / 4;
        width = ALIGN(width, align_w);
    }
 
    for (i = 0; i < depth; i++) {
+      intel_miptree_get_image_offset(src, level, face, i, &src_x, &src_y);
+      intel_miptree_get_image_offset(dst, level, face, i, &dst_x, &dst_y);
       success = intel_region_copy(intel,
-                                 dst->region, dst_offset + dst_depth_offset[i],
-                                 0, 0,
-                                 src->region, src_offset + src_depth_offset[i],
-                                 0, 0, width, height, GL_COPY);
+                                 dst->region, 0, dst_x, dst_y,
+                                 src->region, 0, src_x, src_y, width, height,
+                                 GL_COPY);
       if (!success) {
         GLubyte *src_ptr, *dst_ptr;
 
         src_ptr = intel_region_map(intel, src->region);
         dst_ptr = intel_region_map(intel, dst->region);
 
-        _mesa_copy_rect(dst_ptr + dst_offset + dst_depth_offset[i],
+        _mesa_copy_rect(dst_ptr + dst->cpp * (dst_x + dst_y * dst->pitch),
                         dst->cpp,
                         dst->pitch,
                         0, 0, width, height,
-                        src_ptr + src_offset + src_depth_offset[i],
+                        src_ptr + src->cpp * (src_x + src_y * src->pitch),
                         src->pitch,
                         0, 0);
         intel_region_unmap(intel, src->region);
index c890b2a0d047488747dc2db7aaaaa36a02da5ec8..b19c548def344989cfbea6bf9fef77fdd77ff986 100644 (file)
@@ -70,6 +70,10 @@ struct intel_mipmap_level
     * always zero in that case.
     */
    GLuint level_offset;
+   /** Offset to this miptree level, used in computing x_offset. */
+   GLuint level_x;
+   /** Offset to this miptree level, used in computing y_offset. */
+   GLuint level_y;
    GLuint width;
    GLuint height;
    /** Depth of the mipmap at this level: 1 for 1D/2D/CUBE, n for 3D. */
@@ -86,7 +90,7 @@ struct intel_mipmap_level
     * compute the offsets of depth/cube images within a mipmap level,
     * so have to store them as a lookup table.
     */
-   GLuint *image_offset;
+   GLuint *x_offset, *y_offset;
 };
 
 struct intel_mipmap_tree
@@ -161,8 +165,7 @@ void intel_miptree_release(struct intel_context *intel,
 /* Check if an image fits an existing mipmap tree layout
  */
 GLboolean intel_miptree_match_image(struct intel_mipmap_tree *mt,
-                                    struct gl_texture_image *image,
-                                    GLuint face, GLuint level);
+                                    struct gl_texture_image *image);
 
 /* Return a pointer to an image within a tree.  Return image stride as
  * well.
@@ -176,19 +179,10 @@ GLubyte *intel_miptree_image_map(struct intel_context *intel,
 void intel_miptree_image_unmap(struct intel_context *intel,
                                struct intel_mipmap_tree *mt);
 
-
-/* Return the linear offset of an image relative to the start of the
- * tree:
- */
-GLuint intel_miptree_image_offset(struct intel_mipmap_tree *mt,
-                                  GLuint face, GLuint level);
-
-/* Return pointers to each 2d slice within an image.  Indexed by depth
- * value.
- */
-const GLuint *intel_miptree_depth_offsets(struct intel_mipmap_tree *mt,
-                                          GLuint level);
-
+void
+intel_miptree_get_image_offset(struct intel_mipmap_tree *mt,
+                              GLuint level, GLuint face, GLuint depth,
+                              GLuint *x, GLuint *y);
 
 void intel_miptree_set_level_info(struct intel_mipmap_tree *mt,
                                   GLuint level,
@@ -196,16 +190,10 @@ void intel_miptree_set_level_info(struct intel_mipmap_tree *mt,
                                   GLuint x, GLuint y,
                                   GLuint w, GLuint h, GLuint d);
 
-void intel_miptree_set_image_offset_ex(struct intel_mipmap_tree *mt,
-                                       GLuint level,
-                                       GLuint img, GLuint x, GLuint y,
-                                       GLuint offset);
-
 void intel_miptree_set_image_offset(struct intel_mipmap_tree *mt,
                                     GLuint level,
                                     GLuint img, GLuint x, GLuint y);
 
-
 /* Upload an image into a tree
  */
 void intel_miptree_image_data(struct intel_context *intel,
index 993e427a9927e19591da7901a1ab263f806c9885..5142f3dcd99f0b2b43e0d909c5843bc86b72e3b2 100644 (file)
@@ -88,10 +88,10 @@ intel_check_blit_fragment_ops(GLcontext * ctx, GLboolean src_alpha_is_one)
       return GL_FALSE;
    }
 
-   if (!(ctx->Color.ColorMask[0] &&
-        ctx->Color.ColorMask[1] &&
-        ctx->Color.ColorMask[2] &&
-        ctx->Color.ColorMask[3])) {
+   if (!(ctx->Color.ColorMask[0][0] &&
+        ctx->Color.ColorMask[0][1] &&
+        ctx->Color.ColorMask[0][2] &&
+        ctx->Color.ColorMask[0][3])) {
       DBG("fallback due to color masking\n");
       return GL_FALSE;
    }
index 9a0bcc07a5bdc92708d0215ef3eab96c036b6432..85e5ad2cdd4588bdebcb3ea9efcf61ae6ccbd9bd 100644 (file)
@@ -32,7 +32,9 @@
 #include "main/mtypes.h"
 #include "main/macros.h"
 #include "main/bufferobj.h"
+#include "main/polygon.h"
 #include "main/pixelstore.h"
+#include "main/polygon.h"
 #include "main/state.h"
 #include "main/teximage.h"
 #include "main/texenv.h"
@@ -164,7 +166,7 @@ static GLuint get_bitmap_rect(GLsizei width, GLsizei height,
  * Returns the low Y value of the vertical range given, flipped according to
  * whether the framebuffer is or not.
  */
-static inline int
+static INLINE int
 y_flip(struct gl_framebuffer *fb, int y, int height)
 {
    if (fb->Name != 0)
@@ -227,16 +229,13 @@ do_blit_bitmap( GLcontext *ctx,
    UNCLAMPED_FLOAT_TO_UBYTE(ubcolor[3], tmpColor[3]);
 
    if (dst->cpp == 2)
-      color = INTEL_PACKCOLOR565(ubcolor[0], ubcolor[1], ubcolor[2]);
+      color = PACK_COLOR_565(ubcolor[0], ubcolor[1], ubcolor[2]);
    else
-      color = INTEL_PACKCOLOR8888(ubcolor[0], ubcolor[1],
-                                 ubcolor[2], ubcolor[3]);
+      color = PACK_COLOR_8888(ubcolor[3], ubcolor[0], ubcolor[1], ubcolor[2]);
 
    if (!intel_check_blit_fragment_ops(ctx, tmpColor[3] == 1.0F))
       return GL_FALSE;
 
-   LOCK_HARDWARE(intel);
-
    intel_get_cliprects(intel, &cliprects, &num_cliprects, &x_off, &y_off);
    if (num_cliprects != 0) {
       GLuint i;
@@ -324,7 +323,6 @@ do_blit_bitmap( GLcontext *ctx,
       }
    }
 out:
-   UNLOCK_HARDWARE(intel);
 
    if (INTEL_DEBUG & DEBUG_SYNC)
       intel_batchbuffer_flush(intel->batch);
@@ -335,6 +333,8 @@ out:
                               unpack->BufferObj);
    }
 
+   intel_check_front_buffer_rendering(intel);
+
    return GL_TRUE;
 }
 
@@ -435,13 +435,14 @@ intel_texture_bitmap(GLcontext * ctx,
    }
 
    /* Save GL state before we start setting up our drawing */
-   _mesa_PushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT |
-                   GL_VIEWPORT_BIT);
+   _mesa_PushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT | GL_POLYGON_BIT |
+                    GL_TEXTURE_BIT | GL_VIEWPORT_BIT);
    _mesa_PushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT |
                          GL_CLIENT_PIXEL_STORE_BIT);
    old_active_texture = ctx->Texture.CurrentUnit;
 
    _mesa_Disable(GL_POLYGON_STIPPLE);
+   _mesa_PolygonMode(GL_FRONT_AND_BACK, GL_FILL);
 
    /* Upload our bitmap data to an alpha texture */
    _mesa_ActiveTextureARB(GL_TEXTURE0_ARB);
@@ -500,9 +501,8 @@ intel_texture_bitmap(GLcontext * ctx,
    meta_restore_fragment_program(&intel->meta);
    meta_restore_vertex_program(&intel->meta);
 
-   _mesa_PopClientAttrib();
-   _mesa_Disable(GL_TEXTURE_2D); /* asserted that it was disabled at entry */
    _mesa_ActiveTextureARB(GL_TEXTURE0_ARB + old_active_texture);
+   _mesa_PopClientAttrib();
    _mesa_PopAttrib();
 
    _mesa_DeleteTextures(1, &texname);
index f058b3c8e4dfa21f748297d8f1f016d9f219dedf..e002516cdd04f0ada4cf9209c81855ddac262df5 100644 (file)
 #include "intel_buffers.h"
 #include "intel_regions.h"
 #include "intel_pixel.h"
+#include "intel_fbo.h"
 
 #define FILE_DEBUG_FLAG DEBUG_PIXEL
 
 static struct intel_region *
 copypix_src_region(struct intel_context *intel, GLenum type)
 {
+   struct intel_renderbuffer *depth;
+
+   depth = (struct intel_renderbuffer *)
+      &intel->ctx.DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
+
    switch (type) {
    case GL_COLOR:
       return intel_readbuf_region(intel);
    case GL_DEPTH:
-      /* Don't think this is really possible execpt at 16bpp, when we have no stencil.
-       */
-      if (intel->depth_region && intel->depth_region->cpp == 2)
-         return intel->depth_region;
+      /* Don't think this is really possible execpt at 16bpp, when we
+       * have no stencil. */
+      if (depth && depth->region->cpp == 2)
+         return depth->region;
    case GL_STENCIL:
-      /* Don't think this is really possible. 
-       */
+      /* Don't think this is really possible. */
       break;
    case GL_DEPTH_STENCIL_EXT:
       /* Does it matter whether it is stencil/depth or depth/stencil?
        */
-      return intel->depth_region;
+      return depth->region;
    default:
       break;
    }
@@ -83,10 +88,10 @@ intel_check_copypixel_blit_fragment_ops(GLcontext * ctx)
             ctx->Depth.Test ||
             ctx->Fog.Enabled ||
             ctx->Stencil._Enabled ||
-            !ctx->Color.ColorMask[0] ||
-            !ctx->Color.ColorMask[1] ||
-            !ctx->Color.ColorMask[2] ||
-            !ctx->Color.ColorMask[3] ||
+            !ctx->Color.ColorMask[0][0] ||
+            !ctx->Color.ColorMask[0][1] ||
+            !ctx->Color.ColorMask[0][2] ||
+            !ctx->Color.ColorMask[0][3] ||
             ctx->Texture._EnabledUnits ||
            ctx->FragmentProgram._Enabled ||
            ctx->Color.BlendEnabled);
@@ -134,8 +139,6 @@ do_blit_copypixels(GLcontext * ctx,
 
    intelFlush(&intel->ctx);
 
-   LOCK_HARDWARE(intel);
-
    intel_get_cliprects(intel, &cliprects, &num_cliprects, &x_off, &y_off);
    if (num_cliprects != 0) {
       GLint delta_x;
@@ -214,13 +217,13 @@ do_blit_copypixels(GLcontext * ctx,
                                ctx->Color.ColorLogicOpEnabled ?
                                ctx->Color.LogicOp : GL_COPY)) {
            DBG("%s: blit failure\n", __FUNCTION__);
-           UNLOCK_HARDWARE(intel);
            return GL_FALSE;
         }
       }
    }
 out:
-   UNLOCK_HARDWARE(intel);
+
+   intel_check_front_buffer_rendering(intel);
 
    DBG("%s: success\n", __FUNCTION__);
    return GL_TRUE;
index 5ffa847fd4af62969c41f339c0856575b84f4856..b870e9315e0ce75f71f18165c1b031eeffad010c 100644 (file)
@@ -69,7 +69,6 @@ intel_stencil_drawpixels(GLcontext * ctx,
    GLfloat vertices[4][2];
    struct intel_renderbuffer *irb;
    struct intel_renderbuffer *depth_irb;
-   struct gl_renderbuffer *rb;
    struct gl_pixelstore_attrib old_unpack;
    GLstencil *stencil_pixels;
    int row, y1, y2;
@@ -169,8 +168,7 @@ intel_stencil_drawpixels(GLcontext * ctx,
     * buffer.
     */
    depth_irb = intel_get_renderbuffer(ctx->DrawBuffer, BUFFER_DEPTH);
-   irb = intel_create_renderbuffer(GL_RGBA8);
-   rb = &irb->Base;
+   irb = intel_create_renderbuffer(MESA_FORMAT_ARGB8888);
    irb->Base.Width = depth_irb->Base.Width;
    irb->Base.Height = depth_irb->Base.Height;
    intel_renderbuffer_set_region(irb, depth_irb->region);
index 470750018015b335073c14542ae53dd978cba8cb..9c0fdc6067caa6bb2c31d87f67413de097dd5982 100644 (file)
@@ -77,7 +77,7 @@ do_texture_readpixels(GLcontext * ctx,
    struct intel_context *intel = intel_context(ctx);
    intelScreenPrivate *screen = intel->intelScreen;
    GLint pitch = pack->RowLength ? pack->RowLength : width;
-   __DRIdrawablePrivate *dPriv = intel->driDrawable;
+   __DRIdrawable *dPriv = intel->driDrawable;
    int textureFormat;
    GLenum glTextureFormat;
    int destFormat, depthFormat, destPitch;
@@ -105,15 +105,12 @@ do_texture_readpixels(GLcontext * ctx,
       return GL_FALSE;
    }
 
-   LOCK_HARDWARE(intel);
-
    if (intel->driDrawable->numClipRects) {
       intel->vtbl.install_meta_state(intel);
       intel->vtbl.meta_no_depth_write(intel);
       intel->vtbl.meta_no_stencil_write(intel);
 
       if (!driClipRectToFramebuffer(ctx->ReadBuffer, &x, &y, &width, &height)) {
-         UNLOCK_HARDWARE(intel);
          SET_STATE(i830, state);
          if (INTEL_DEBUG & DEBUG_PIXEL)
             fprintf(stderr, "%s: cliprect failed\n", __FUNCTION__);
@@ -150,7 +147,6 @@ do_texture_readpixels(GLcontext * ctx,
 
       intel->vtbl.leave_meta_state(intel);
    }
-   UNLOCK_HARDWARE(intel);
 
    intel_region_wait_fence(ctx, dest_region);   /* required by GL */
    return GL_TRUE;
@@ -224,7 +220,6 @@ do_blit_readpixels(GLcontext * ctx,
     * fire with lock held to guarentee cliprects are correct.
     */
    intelFlush(&intel->ctx);
-   LOCK_HARDWARE(intel);
 
    if (intel->driReadDrawable->numClipRects) {
       GLboolean all = (width * height * src->cpp == dst->Base.Size &&
@@ -233,7 +228,7 @@ do_blit_readpixels(GLcontext * ctx,
       dri_bo *dst_buffer = intel_bufferobj_buffer(intel, dst,
                                                  all ? INTEL_WRITE_FULL :
                                                  INTEL_WRITE_PART);
-      __DRIdrawablePrivate *dPriv = intel->driReadDrawable;
+      __DRIdrawable *dPriv = intel->driReadDrawable;
       int nbox = dPriv->numClipRects;
       drm_clip_rect_t *box = dPriv->pClipRects;
       drm_clip_rect_t rect;
@@ -261,12 +256,10 @@ do_blit_readpixels(GLcontext * ctx,
                                rect.y2 - src_rect.y2,
                                rect.x2 - rect.x1, rect.y2 - rect.y1,
                                GL_COPY)) {
-           UNLOCK_HARDWARE(intel);
            return GL_FALSE;
         }
       }
    }
-   UNLOCK_HARDWARE(intel);
 
    if (INTEL_DEBUG & DEBUG_PIXEL)
       _mesa_printf("%s - DONE\n", __FUNCTION__);
@@ -285,11 +278,11 @@ intelReadPixels(GLcontext * ctx,
 
    intelFlush(ctx);
 
-#ifdef I915
    if (do_blit_readpixels
        (ctx, x, y, width, height, format, type, pack, pixels))
       return;
 
+#ifdef I915
    if (do_texture_readpixels
        (ctx, x, y, width, height, format, type, pack, pixels))
       return;
index a86c66a8443291b5f24fe876a958cdb9bbfdbbcb..61aefa01b8a184b38e76c6536096e72ee469de37 100644 (file)
@@ -362,14 +362,12 @@ intel_region_data(struct intel_context *intel,
          intel_region_cow(intel, dst);
    }
 
-   LOCK_HARDWARE(intel);
    _mesa_copy_rect(intel_region_map(intel, dst) + dst_offset,
                    dst->cpp,
                    dst->pitch,
                    dstx, dsty, width, height, src, src_pitch, srcx, srcy);
 
    intel_region_unmap(intel, dst);
-   UNLOCK_HARDWARE(intel);
 }
 
 /* Copy rectangular sub-regions. Need better logic about when to
@@ -485,7 +483,6 @@ intel_region_cow(struct intel_context *intel, struct intel_region *region)
    /* Now blit from the texture buffer to the new buffer: 
     */
 
-   LOCK_HARDWARE(intel);
    ok = intelEmitCopyBlit(intel,
                           region->cpp,
                           region->pitch, pbo->buffer, 0, region->tiling,
@@ -494,7 +491,6 @@ intel_region_cow(struct intel_context *intel, struct intel_region *region)
                           region->pitch, region->height,
                           GL_COPY);
    assert(ok);
-   UNLOCK_HARDWARE(intel);
 }
 
 dri_bo *
@@ -510,126 +506,3 @@ intel_region_buffer(struct intel_context *intel,
 
    return region->buffer;
 }
-
-static struct intel_region *
-intel_recreate_static(struct intel_context *intel,
-                     const char *name,
-                     struct intel_region *region,
-                     intelRegion *region_desc)
-{
-   intelScreenPrivate *intelScreen = intel->intelScreen;
-   int ret;
-
-   if (region == NULL) {
-      region = calloc(sizeof(*region), 1);
-      region->refcount = 1;
-      _DBG("%s creating new region %p\n", __FUNCTION__, region);
-   }
-   else {
-      _DBG("%s %p\n", __FUNCTION__, region);
-   }
-
-   if (intel->ctx.Visual.rgbBits == 24)
-      region->cpp = 4;
-   else
-      region->cpp = intel->ctx.Visual.rgbBits / 8;
-   region->pitch = intelScreen->pitch;
-   region->width = intelScreen->width;
-   region->height = intelScreen->height;
-
-   if (region->buffer != NULL) {
-      dri_bo_unreference(region->buffer);
-      region->buffer = NULL;
-   }
-
-   if (intel->ttm) {
-      assert(region_desc->bo_handle != -1);
-      region->buffer = intel_bo_gem_create_from_name(intel->bufmgr,
-                                                    name,
-                                                    region_desc->bo_handle);
-
-      ret = dri_bo_get_tiling(region->buffer, &region->tiling,
-                             &region->bit_6_swizzle);
-      if (ret != 0) {
-        fprintf(stderr, "Couldn't get tiling of buffer %d (%s): %s\n",
-                region_desc->bo_handle, name, strerror(-ret));
-        intel_region_release(&region);
-        return NULL;
-      }
-   } else {
-      if (region->classic_map != NULL) {
-        drmUnmap(region->classic_map,
-                 region->pitch * region->cpp * region->height);
-        region->classic_map = NULL;
-      }
-      ret = drmMap(intel->driFd, region_desc->handle,
-                  region->pitch * region->cpp * region->height,
-                  &region->classic_map);
-      if (ret != 0) {
-        fprintf(stderr, "Failed to drmMap %s buffer\n", name);
-        free(region);
-        return NULL;
-      }
-
-      region->buffer = intel_bo_fake_alloc_static(intel->bufmgr,
-                                                 name,
-                                                 region_desc->offset,
-                                                 region->pitch * region->cpp *
-                                                 region->height,
-                                                 region->classic_map);
-
-      /* The sarea just gives us a boolean for whether it's tiled or not,
-       * instead of which tiling mode it is.  Guess.
-       */
-      if (region_desc->tiled) {
-        if (IS_965(intel->intelScreen->deviceID) &&
-            region_desc == &intelScreen->depth)
-           region->tiling = I915_TILING_Y;
-        else
-           region->tiling = I915_TILING_X;
-      } else {
-        region->tiling = I915_TILING_NONE;
-      }
-
-      region->bit_6_swizzle = I915_BIT_6_SWIZZLE_NONE;
-   }
-
-   assert(region->buffer != NULL);
-
-   return region;
-}
-
-/**
- * Create intel_region structs to describe the static front, back, and depth
- * buffers created by the xserver.
- *
- * Although FBO's mean we now no longer use these as render targets in
- * all circumstances, they won't go away until the back and depth
- * buffers become private, and the front buffer will remain even then.
- *
- * Note that these don't allocate video memory, just describe
- * allocations alread made by the X server.
- */
-void
-intel_recreate_static_regions(struct intel_context *intel)
-{
-   intelScreenPrivate *intelScreen = intel->intelScreen;
-
-   intel->front_region =
-      intel_recreate_static(intel, "front",
-                           intel->front_region,
-                           &intelScreen->front);
-
-   intel->back_region =
-      intel_recreate_static(intel, "back",
-                           intel->back_region,
-                           &intelScreen->back);
-
-   /* Still assumes front.cpp == depth.cpp.  We can kill this when we move to
-    * private buffers.
-    */
-   intel->depth_region =
-      intel_recreate_static(intel, "depth",
-                           intel->depth_region,
-                           &intelScreen->depth);
-}
index 0d379bdc6e273c2483c3cb279fb668fbcefbfe6d..535fcd7be0b2041bd5ac4a8d21f29b659765b300 100644 (file)
@@ -62,6 +62,8 @@ struct intel_region
    GLuint map_refcount;  /**< Reference count for mapping */
 
    GLuint draw_offset; /**< Offset of drawing address within the region */
+   GLuint draw_x, draw_y; /**< Offset of drawing within the region */
+
    uint32_t tiling; /**< Which tiling mode the region is in */
    uint32_t bit_6_swizzle; /**< GEM flag for address swizzling requirement */
    drmAddress classic_map; /**< drmMap of the region when not in GEM mode */
index 24f7fbc992237e417ec53a4aecf2c38a1d387748..5165716e092878ad93cf5b5388ea81527eab67dc 100644 (file)
@@ -31,7 +31,6 @@
 #include "main/renderbuffer.h"
 
 #include "utils.h"
-#include "vblank.h"
 #include "xmlpool.h"
 
 #include "intel_batchbuffer.h"
@@ -41,7 +40,6 @@
 #include "intel_extensions.h"
 #include "intel_fbo.h"
 #include "intel_regions.h"
-#include "intel_swapbuffers.h"
 #include "intel_screen.h"
 #include "intel_span.h"
 #include "intel_tex.h"
@@ -57,7 +55,6 @@
 PUBLIC const char __driConfigOptions[] =
    DRI_CONF_BEGIN
    DRI_CONF_SECTION_PERFORMANCE
-      DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
       DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_ALWAYS_SYNC)
       /* Options correspond to DRI_CONF_BO_REUSE_DISABLED,
        * DRI_CONF_BO_REUSE_ALL
@@ -99,133 +96,12 @@ PUBLIC const char __driConfigOptions[] =
    DRI_CONF_SECTION_END
 DRI_CONF_END;
 
-const GLuint __driNConfigOptions = 12;
+const GLuint __driNConfigOptions = 11;
 
 #ifdef USE_NEW_INTERFACE
 static PFNGLXCREATECONTEXTMODES create_context_modes = NULL;
 #endif /*USE_NEW_INTERFACE */
 
-/**
- * Map all the memory regions described by the screen.
- * \return GL_TRUE if success, GL_FALSE if error.
- */
-GLboolean
-intelMapScreenRegions(__DRIscreenPrivate * sPriv)
-{
-   intelScreenPrivate *intelScreen = (intelScreenPrivate *) sPriv->private;
-
-   if (0)
-      _mesa_printf("TEX 0x%08x ", intelScreen->tex.handle);
-   if (intelScreen->tex.size != 0) {
-      if (drmMap(sPriv->fd,
-                intelScreen->tex.handle,
-                intelScreen->tex.size,
-                (drmAddress *) & intelScreen->tex.map) != 0) {
-        intelUnmapScreenRegions(intelScreen);
-        return GL_FALSE;
-      }
-   }
-
-   return GL_TRUE;
-}
-
-void
-intelUnmapScreenRegions(intelScreenPrivate * intelScreen)
-{
-   if (intelScreen->tex.map) {
-      drmUnmap(intelScreen->tex.map, intelScreen->tex.size);
-      intelScreen->tex.map = NULL;
-   }
-}
-
-
-static void
-intelPrintDRIInfo(intelScreenPrivate * intelScreen,
-                  __DRIscreenPrivate * sPriv, I830DRIPtr gDRIPriv)
-{
-   fprintf(stderr, "*** Front size:   0x%x  offset: 0x%x  pitch: %d\n",
-           intelScreen->front.size, intelScreen->front.offset,
-           intelScreen->pitch);
-   fprintf(stderr, "*** Back size:    0x%x  offset: 0x%x  pitch: %d\n",
-           intelScreen->back.size, intelScreen->back.offset,
-           intelScreen->pitch);
-   fprintf(stderr, "*** Depth size:   0x%x  offset: 0x%x  pitch: %d\n",
-           intelScreen->depth.size, intelScreen->depth.offset,
-           intelScreen->pitch);
-   fprintf(stderr, "*** Texture size: 0x%x  offset: 0x%x\n",
-           intelScreen->tex.size, intelScreen->tex.offset);
-   fprintf(stderr, "*** Memory : 0x%x\n", gDRIPriv->mem);
-}
-
-
-static void
-intelPrintSAREA(const drm_i915_sarea_t * sarea)
-{
-   fprintf(stderr, "SAREA: sarea width %d  height %d\n", sarea->width,
-           sarea->height);
-   fprintf(stderr, "SAREA: pitch: %d\n", sarea->pitch);
-   fprintf(stderr,
-           "SAREA: front offset: 0x%08x  size: 0x%x  handle: 0x%x tiled: %d\n",
-           sarea->front_offset, sarea->front_size,
-           (unsigned) sarea->front_handle, sarea->front_tiled);
-   fprintf(stderr,
-           "SAREA: back  offset: 0x%08x  size: 0x%x  handle: 0x%x tiled: %d\n",
-           sarea->back_offset, sarea->back_size,
-           (unsigned) sarea->back_handle, sarea->back_tiled);
-   fprintf(stderr, "SAREA: depth offset: 0x%08x  size: 0x%x  handle: 0x%x tiled: %d\n",
-           sarea->depth_offset, sarea->depth_size,
-           (unsigned) sarea->depth_handle, sarea->depth_tiled);
-   fprintf(stderr, "SAREA: tex   offset: 0x%08x  size: 0x%x  handle: 0x%x\n",
-           sarea->tex_offset, sarea->tex_size, (unsigned) sarea->tex_handle);
-}
-
-
-/**
- * A number of the screen parameters are obtained/computed from
- * information in the SAREA.  This function updates those parameters.
- */
-static void
-intelUpdateScreenFromSAREA(intelScreenPrivate * intelScreen,
-                           drm_i915_sarea_t * sarea)
-{
-   intelScreen->width = sarea->width;
-   intelScreen->height = sarea->height;
-   intelScreen->pitch = sarea->pitch;
-
-   intelScreen->front.offset = sarea->front_offset;
-   intelScreen->front.handle = sarea->front_handle;
-   intelScreen->front.size = sarea->front_size;
-   intelScreen->front.tiled = sarea->front_tiled;
-
-   intelScreen->back.offset = sarea->back_offset;
-   intelScreen->back.handle = sarea->back_handle;
-   intelScreen->back.size = sarea->back_size;
-   intelScreen->back.tiled = sarea->back_tiled;
-
-   intelScreen->depth.offset = sarea->depth_offset;
-   intelScreen->depth.handle = sarea->depth_handle;
-   intelScreen->depth.size = sarea->depth_size;
-   intelScreen->depth.tiled = sarea->depth_tiled;
-
-   if (intelScreen->driScrnPriv->ddx_version.minor >= 9) {
-      intelScreen->front.bo_handle = sarea->front_bo_handle;
-      intelScreen->back.bo_handle = sarea->back_bo_handle;
-      intelScreen->depth.bo_handle = sarea->depth_bo_handle;
-   } else {
-      intelScreen->front.bo_handle = -1;
-      intelScreen->back.bo_handle = -1;
-      intelScreen->depth.bo_handle = -1;
-   }
-
-   intelScreen->tex.offset = sarea->tex_offset;
-   intelScreen->logTextureGranularity = sarea->log_tex_granularity;
-   intelScreen->tex.handle = sarea->tex_handle;
-   intelScreen->tex.size = sarea->tex_size;
-
-   if (0)
-      intelPrintSAREA(sarea);
-}
-
 static const __DRItexOffsetExtension intelTexOffsetExtension = {
    { __DRI_TEX_OFFSET },
    intelSetTexOffset,
@@ -239,17 +115,13 @@ static const __DRItexBufferExtension intelTexBufferExtension = {
 
 static const __DRIextension *intelScreenExtensions[] = {
     &driReadDrawableExtension,
-    &driCopySubBufferExtension.base,
-    &driSwapControlExtension.base,
-    &driFrameTrackingExtension.base,
-    &driMediaStreamCounterExtension.base,
     &intelTexOffsetExtension.base,
     &intelTexBufferExtension.base,
     NULL
 };
 
 static GLboolean
-intel_get_param(__DRIscreenPrivate *psp, int param, int *value)
+intel_get_param(__DRIscreen *psp, int param, int *value)
 {
    int ret;
    struct drm_i915_getparam gp;
@@ -266,68 +138,12 @@ intel_get_param(__DRIscreenPrivate *psp, int param, int *value)
    return GL_TRUE;
 }
 
-static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv)
-{
-   intelScreenPrivate *intelScreen;
-   I830DRIPtr gDRIPriv = (I830DRIPtr) sPriv->pDevPriv;
-   drm_i915_sarea_t *sarea;
-
-   if (sPriv->devPrivSize != sizeof(I830DRIRec)) {
-      fprintf(stderr,
-              "\nERROR!  sizeof(I830DRIRec) does not match passed size from device driver\n");
-      return GL_FALSE;
-   }
-
-   /* Allocate the private area */
-   intelScreen = (intelScreenPrivate *) CALLOC(sizeof(intelScreenPrivate));
-   if (!intelScreen) {
-      fprintf(stderr, "\nERROR!  Allocating private area failed\n");
-      return GL_FALSE;
-   }
-   /* parse information in __driConfigOptions */
-   driParseOptionInfo(&intelScreen->optionCache,
-                      __driConfigOptions, __driNConfigOptions);
-
-   intelScreen->driScrnPriv = sPriv;
-   sPriv->private = (void *) intelScreen;
-   sarea = (drm_i915_sarea_t *)
-      (((GLubyte *) sPriv->pSAREA) + gDRIPriv->sarea_priv_offset);
-   intelScreen->sarea = sarea;
-
-   intelScreen->deviceID = gDRIPriv->deviceID;
-
-   intelUpdateScreenFromSAREA(intelScreen, sarea);
-
-   if (!intelMapScreenRegions(sPriv)) {
-      fprintf(stderr, "\nERROR!  mapping regions\n");
-      _mesa_free(intelScreen);
-      sPriv->private = NULL;
-      return GL_FALSE;
-   }
-
-   if (0)
-      intelPrintDRIInfo(intelScreen, sPriv, gDRIPriv);
-
-   intelScreen->drmMinor = sPriv->drm_version.minor;
-
-   /* Determine if IRQs are active? */
-   if (!intel_get_param(sPriv, I915_PARAM_IRQ_ACTIVE,
-                       &intelScreen->irq_active))
-      return GL_FALSE;
-
-   sPriv->extensions = intelScreenExtensions;
-
-   return GL_TRUE;
-}
-
-
 static void
-intelDestroyScreen(__DRIscreenPrivate * sPriv)
+intelDestroyScreen(__DRIscreen * sPriv)
 {
    intelScreenPrivate *intelScreen = (intelScreenPrivate *) sPriv->private;
 
    dri_bufmgr_destroy(intelScreen->bufmgr);
-   intelUnmapScreenRegions(intelScreen);
    driDestroyOptionInfo(&intelScreen->optionCache);
 
    FREE(intelScreen);
@@ -339,160 +155,106 @@ intelDestroyScreen(__DRIscreenPrivate * sPriv)
  * This is called when we need to set up GL rendering to a new X window.
  */
 static GLboolean
-intelCreateBuffer(__DRIscreenPrivate * driScrnPriv,
-                  __DRIdrawablePrivate * driDrawPriv,
+intelCreateBuffer(__DRIscreen * driScrnPriv,
+                  __DRIdrawable * driDrawPriv,
                   const __GLcontextModes * mesaVis, GLboolean isPixmap)
 {
+   struct intel_renderbuffer *rb;
+
    if (isPixmap) {
       return GL_FALSE;          /* not implemented */
    }
    else {
       GLboolean swStencil = (mesaVis->stencilBits > 0 &&
                              mesaVis->depthBits != 24);
-      GLenum rgbFormat;
+      gl_format rgbFormat;
 
-      struct intel_framebuffer *intel_fb = CALLOC_STRUCT(intel_framebuffer);
+      struct gl_framebuffer *fb = CALLOC_STRUCT(gl_framebuffer);
 
-      if (!intel_fb)
+      if (!fb)
         return GL_FALSE;
 
-      _mesa_initialize_framebuffer(&intel_fb->Base, mesaVis);
+      _mesa_initialize_framebuffer(fb, mesaVis);
 
       if (mesaVis->redBits == 5)
-        rgbFormat = GL_RGB5;
+        rgbFormat = MESA_FORMAT_RGB565;
       else if (mesaVis->alphaBits == 0)
-        rgbFormat = GL_RGB8;
+        rgbFormat = MESA_FORMAT_XRGB8888;
       else
-        rgbFormat = GL_RGBA8;
+        rgbFormat = MESA_FORMAT_ARGB8888;
 
       /* setup the hardware-based renderbuffers */
-      intel_fb->color_rb[0] = intel_create_renderbuffer(rgbFormat);
-      _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_FRONT_LEFT,
-                            &intel_fb->color_rb[0]->Base);
+      rb = intel_create_renderbuffer(rgbFormat);
+      _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &rb->Base);
 
       if (mesaVis->doubleBufferMode) {
-        intel_fb->color_rb[1] = intel_create_renderbuffer(rgbFormat);
-
-         _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_BACK_LEFT,
-                               &intel_fb->color_rb[1]->Base);
-
+        rb = intel_create_renderbuffer(rgbFormat);
+         _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &rb->Base);
       }
 
       if (mesaVis->depthBits == 24) {
         if (mesaVis->stencilBits == 8) {
            /* combined depth/stencil buffer */
            struct intel_renderbuffer *depthStencilRb
-              = intel_create_renderbuffer(GL_DEPTH24_STENCIL8_EXT);
+              = intel_create_renderbuffer(MESA_FORMAT_S8_Z24);
            /* note: bind RB to two attachment points */
-           _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH,
-                                  &depthStencilRb->Base);
-           _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_STENCIL,
-                                  &depthStencilRb->Base);
+           _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthStencilRb->Base);
+           _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &depthStencilRb->Base);
         } else {
            struct intel_renderbuffer *depthRb
-              = intel_create_renderbuffer(GL_DEPTH_COMPONENT24);
-           _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH,
-                                  &depthRb->Base);
+              = intel_create_renderbuffer(MESA_FORMAT_X8_Z24);
+           _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
         }
       }
       else if (mesaVis->depthBits == 16) {
          /* just 16-bit depth buffer, no hw stencil */
          struct intel_renderbuffer *depthRb
-           = intel_create_renderbuffer(GL_DEPTH_COMPONENT16);
-         _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH, &depthRb->Base);
+           = intel_create_renderbuffer(MESA_FORMAT_Z16);
+         _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
       }
 
       /* now add any/all software-based renderbuffers we may need */
-      _mesa_add_soft_renderbuffers(&intel_fb->Base,
+      _mesa_add_soft_renderbuffers(fb,
                                    GL_FALSE, /* never sw color */
                                    GL_FALSE, /* never sw depth */
                                    swStencil, mesaVis->accumRedBits > 0,
                                    GL_FALSE, /* never sw alpha */
                                    GL_FALSE  /* never sw aux */ );
-      driDrawPriv->driverPrivate = (void *) intel_fb;
+      driDrawPriv->driverPrivate = fb;
 
       return GL_TRUE;
    }
 }
 
 static void
-intelDestroyBuffer(__DRIdrawablePrivate * driDrawPriv)
-{
-   struct intel_framebuffer *intel_fb = driDrawPriv->driverPrivate;
-   struct intel_renderbuffer *depth_rb;
-   struct intel_renderbuffer *stencil_rb;
-
-   if (intel_fb) {
-      if (intel_fb->color_rb[0]) {
-         intel_renderbuffer_set_region(intel_fb->color_rb[0], NULL);
-      }
-
-      if (intel_fb->color_rb[1]) {
-         intel_renderbuffer_set_region(intel_fb->color_rb[1], NULL);
-      }
-
-      depth_rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH);
-      if (depth_rb) {
-         intel_renderbuffer_set_region(depth_rb, NULL);
-      }
-
-      stencil_rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL);
-      if (stencil_rb) {
-         intel_renderbuffer_set_region(stencil_rb, NULL);
-      }
-   }
-
-   _mesa_reference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)), NULL);
-}
-
-
-/**
- * Get information about previous buffer swaps.
- */
-static int
-intelGetSwapInfo(__DRIdrawablePrivate * dPriv, __DRIswapInfo * sInfo)
+intelDestroyBuffer(__DRIdrawable * driDrawPriv)
 {
-   struct intel_framebuffer *intel_fb;
-
-   if ((dPriv == NULL) || (dPriv->driverPrivate == NULL)
-       || (sInfo == NULL)) {
-      return -1;
-   }
-
-   intel_fb = dPriv->driverPrivate;
-   sInfo->swap_count = intel_fb->swap_count;
-   sInfo->swap_ust = intel_fb->swap_ust;
-   sInfo->swap_missed_count = intel_fb->swap_missed_count;
-
-   sInfo->swap_missed_usage = (sInfo->swap_missed_count != 0)
-      ? driCalculateSwapUsage(dPriv, 0, intel_fb->swap_missed_ust)
-      : 0.0;
-
-   return 0;
+    struct gl_framebuffer *fb = driDrawPriv->driverPrivate;
+  
+    _mesa_reference_framebuffer(&fb, NULL);
 }
 
-
 /* There are probably better ways to do this, such as an
  * init-designated function to register chipids and createcontext
  * functions.
  */
 extern GLboolean i830CreateContext(const __GLcontextModes * mesaVis,
-                                   __DRIcontextPrivate * driContextPriv,
+                                   __DRIcontext * driContextPriv,
                                    void *sharedContextPrivate);
 
 extern GLboolean i915CreateContext(const __GLcontextModes * mesaVis,
-                                   __DRIcontextPrivate * driContextPriv,
+                                   __DRIcontext * driContextPriv,
                                    void *sharedContextPrivate);
 extern GLboolean brwCreateContext(const __GLcontextModes * mesaVis,
-                                 __DRIcontextPrivate * driContextPriv,
+                                 __DRIcontext * driContextPriv,
                                  void *sharedContextPrivate);
 
 static GLboolean
 intelCreateContext(const __GLcontextModes * mesaVis,
-                   __DRIcontextPrivate * driContextPriv,
+                   __DRIcontext * driContextPriv,
                    void *sharedContextPrivate)
 {
-   __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+   __DRIscreen *sPriv = driContextPriv->driScreenPriv;
    intelScreenPrivate *intelScreen = (intelScreenPrivate *) sPriv->private;
 
 #ifdef I915
@@ -513,152 +275,20 @@ intelCreateContext(const __GLcontextModes * mesaVis,
    return GL_FALSE;
 }
 
-
-static __DRIconfig **
-intelFillInModes(__DRIscreenPrivate *psp,
-                unsigned pixel_bits, unsigned depth_bits,
-                 unsigned stencil_bits, GLboolean have_back_buffer)
-{
-   __DRIconfig **configs;
-   __GLcontextModes *m;
-   unsigned depth_buffer_factor;
-   unsigned back_buffer_factor;
-   int i;
-
-   /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
-    * support pageflipping at all.
-    */
-   static const GLenum back_buffer_modes[] = {
-      GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML
-   };
-
-   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) {
-      configs = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
-                                depth_bits_array, stencil_bits_array,
-                                depth_buffer_factor, back_buffer_modes,
-                                back_buffer_factor,
-                                msaa_samples_array, 1);
-   }
-   else {
-      __DRIconfig **configs_a8r8g8b8;
-      __DRIconfig **configs_x8r8g8b8;
-
-      configs_a8r8g8b8 = driCreateConfigs(GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
-                                         depth_bits_array,
-                                         stencil_bits_array,
-                                         depth_buffer_factor,
-                                         back_buffer_modes,
-                                         back_buffer_factor,
-                                         msaa_samples_array, 1);
-      configs_x8r8g8b8 = driCreateConfigs(GL_BGR, GL_UNSIGNED_INT_8_8_8_8_REV,
-                                         depth_bits_array,
-                                         stencil_bits_array,
-                                         depth_buffer_factor,
-                                         back_buffer_modes,
-                                         back_buffer_factor,
-                                         msaa_samples_array, 1);
-      configs = driConcatConfigs(configs_a8r8g8b8, configs_x8r8g8b8);
-   }
-
-   if (configs == NULL) {
-    fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
-              __LINE__);
-      return NULL;
-   }
-
-   /* Mark the visual as slow if there are "fake" stencil bits.
-    */
-   for (i = 0; configs[i]; i++) {
-      m = &configs[i]->modes;
-      if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) {
-         m->visualRating = GLX_SLOW_CONFIG;
-      }
-   }
-
-   return configs;
-}
-
 static GLboolean
 intel_init_bufmgr(intelScreenPrivate *intelScreen)
 {
-   GLboolean gem_disable = getenv("INTEL_NO_GEM") != NULL;
-   int gem_kernel = 0;
-   GLboolean gem_supported;
-   struct drm_i915_getparam gp;
-   __DRIscreenPrivate *spriv = intelScreen->driScrnPriv;
+   __DRIscreen *spriv = intelScreen->driScrnPriv;
    int num_fences = 0;
 
    intelScreen->no_hw = getenv("INTEL_NO_HW") != NULL;
 
-   gp.param = I915_PARAM_HAS_GEM;
-   gp.value = &gem_kernel;
-
-   (void) drmCommandWriteRead(spriv->fd, DRM_I915_GETPARAM, &gp, sizeof(gp));
-
-   /* If we've got a new enough DDX that's initializing GEM and giving us
-    * object handles for the shared buffers, use that.
-    */
-   intelScreen->ttm = GL_FALSE;
-   if (intelScreen->driScrnPriv->dri2.enabled)
-       gem_supported = GL_TRUE;
-   else if (intelScreen->driScrnPriv->ddx_version.minor >= 9 &&
-           gem_kernel &&
-           intelScreen->front.bo_handle != -1)
-       gem_supported = GL_TRUE;
-   else
-       gem_supported = GL_FALSE;
-
-   if (!gem_disable && gem_supported) {
-      intelScreen->bufmgr = intel_bufmgr_gem_init(spriv->fd, BATCH_SZ);
-      if (intelScreen->bufmgr != NULL)
-        intelScreen->ttm = GL_TRUE;
-   }
+   intelScreen->bufmgr = intel_bufmgr_gem_init(spriv->fd, BATCH_SZ);
    /* Otherwise, use the classic buffer manager. */
    if (intelScreen->bufmgr == NULL) {
-      if (gem_disable) {
-        _mesa_warning(NULL, "GEM disabled.  Using classic.");
-      } else {
-        _mesa_warning(NULL,
-                       "Failed to initialize GEM.  Falling back to classic.");
-      }
-
-      if (intelScreen->tex.size == 0) {
-        fprintf(stderr, "[%s:%u] Error initializing buffer manager.\n",
-                __func__, __LINE__);
-        return GL_FALSE;
-      }
-
-      intelScreen->bufmgr =
-        intel_bufmgr_fake_init(spriv->fd,
-                               intelScreen->tex.offset,
-                               intelScreen->tex.map,
-                               intelScreen->tex.size,
-                               (unsigned int * volatile)
-                               &intelScreen->sarea->last_dispatch);
+      fprintf(stderr, "[%s:%u] Error initializing buffer manager.\n",
+             __func__, __LINE__);
+      return GL_FALSE;
    }
 
    if (intel_get_param(spriv, I915_PARAM_NUM_FENCES_AVAIL, &num_fences))
@@ -669,75 +299,6 @@ intel_init_bufmgr(intelScreenPrivate *intelScreen)
    return GL_TRUE;
 }
 
-/**
- * This is the driver specific part of the createNewScreen entry point.
- * Called when using legacy DRI.
- * 
- * \todo maybe fold this into intelInitDriver
- *
- * \return the __GLcontextModes supported by this driver
- */
-static const __DRIconfig **intelInitScreen(__DRIscreenPrivate *psp)
-{
-   intelScreenPrivate *intelScreen;
-#ifdef I915
-   static const __DRIversion ddx_expected = { 1, 5, 0 };
-#else
-   static const __DRIversion ddx_expected = { 1, 6, 0 };
-#endif
-   static const __DRIversion dri_expected = { 4, 0, 0 };
-   static const __DRIversion drm_expected = { 1, 5, 0 };
-   I830DRIPtr dri_priv = (I830DRIPtr) psp->pDevPriv;
-
-   if (!driCheckDriDdxDrmVersions2("i915",
-                                   &psp->dri_version, &dri_expected,
-                                   &psp->ddx_version, &ddx_expected,
-                                   &psp->drm_version, &drm_expected)) {
-      return NULL;
-   }
-
-   /* Calling driInitExtensions here, with a NULL context pointer,
-    * does not actually enable the extensions.  It just makes sure
-    * that all the dispatch offsets for all the extensions that
-    * *might* be enables are known.  This is needed because the
-    * dispatch offsets need to be known when _mesa_context_create is
-    * called, but we can't enable the extensions until we have a
-    * context pointer.
-    *
-    * Hello chicken.  Hello egg.  How are you two today?
-    */
-   intelInitExtensions(NULL, GL_TRUE);
-          
-   if (!intelInitDriver(psp))
-       return NULL;
-
-   psp->extensions = intelScreenExtensions;
-
-   intelScreen = psp->private;
-   if (!intel_init_bufmgr(intelScreen))
-       return GL_FALSE;
-
-   return (const __DRIconfig **)
-       intelFillInModes(psp, dri_priv->cpp * 8,
-                       (dri_priv->cpp == 2) ? 16 : 24,
-                       (dri_priv->cpp == 2) ? 0  : 8, 1);
-}
-
-struct intel_context *intelScreenContext(intelScreenPrivate *intelScreen)
-{
-  /*
-   * This should probably change to have the screen allocate a dummy
-   * context at screen creation. For now just use the current context.
-   */
-
-  GET_CURRENT_CONTEXT(ctx);
-  if (ctx == NULL) {
-     _mesa_problem(NULL, "No current context in intelScreenContext\n");
-     return NULL;
-  }
-  return intel_context(ctx);
-}
-
 /**
  * This is the driver specific part of the createNewScreen entry point.
  * Called when using DRI2.
@@ -745,7 +306,7 @@ struct intel_context *intelScreenContext(intelScreenPrivate *intelScreen)
  * \return the __GLcontextModes supported by this driver
  */
 static const
-__DRIconfig **intelInitScreen2(__DRIscreenPrivate *psp)
+__DRIconfig **intelInitScreen2(__DRIscreen *psp)
 {
    intelScreenPrivate *intelScreen;
    GLenum fb_format[3];
@@ -760,18 +321,6 @@ __DRIconfig **intelInitScreen2(__DRIscreenPrivate *psp)
    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?
-    */
-   intelInitExtensions(NULL, GL_TRUE);
-
    /* Allocate the private area */
    intelScreen = (intelScreenPrivate *) CALLOC(sizeof(intelScreenPrivate));
    if (!intelScreen) {
@@ -866,19 +415,19 @@ __DRIconfig **intelInitScreen2(__DRIscreenPrivate *psp)
 }
 
 const struct __DriverAPIRec driDriverAPI = {
-   .InitScreen          = intelInitScreen,
    .DestroyScreen       = intelDestroyScreen,
    .CreateContext       = intelCreateContext,
    .DestroyContext      = intelDestroyContext,
    .CreateBuffer        = intelCreateBuffer,
    .DestroyBuffer       = intelDestroyBuffer,
-   .SwapBuffers                 = intelSwapBuffers,
    .MakeCurrent                 = intelMakeCurrent,
    .UnbindContext       = intelUnbindContext,
-   .GetSwapInfo                 = intelGetSwapInfo,
-   .GetDrawableMSC      = driDrawableGetMSC32,
-   .WaitForMSC          = driWaitForMSC32,
-   .CopySubBuffer       = intelCopySubBuffer,
-
    .InitScreen2                 = intelInitScreen2,
 };
+
+/* This is the table of extensions that the loader will dlsym() for. */
+PUBLIC const __DRIextension *__driDriverExtensions[] = {
+    &driCoreExtension.base,
+    &driDRI2Extension.base,
+    NULL
+};
index a9b9e109a6aeec05838e0900471dd248c466f192..e87e306d86b361a9a9118e46b703562a60b30635 100644 (file)
@@ -66,7 +66,7 @@ typedef struct
 
    int logTextureGranularity;
 
-   __DRIscreenPrivate *driScrnPriv;
+   __DRIscreen *driScrnPriv;
 
    volatile drm_i915_sarea_t *sarea;
 
@@ -77,7 +77,6 @@ typedef struct
    GLboolean no_hw;
 
    GLboolean no_vbo;
-   int ttm;
    dri_bufmgr *bufmgr;
    GLboolean kernel_exec_fencing;
 
@@ -89,18 +88,18 @@ typedef struct
 
 
 
-extern GLboolean intelMapScreenRegions(__DRIscreenPrivate * sPriv);
+extern GLboolean intelMapScreenRegions(__DRIscreen * sPriv);
 
 extern void intelUnmapScreenRegions(intelScreenPrivate * intelScreen);
 
-extern void intelDestroyContext(__DRIcontextPrivate * driContextPriv);
+extern void intelDestroyContext(__DRIcontext * driContextPriv);
 
-extern GLboolean intelUnbindContext(__DRIcontextPrivate * driContextPriv);
+extern GLboolean intelUnbindContext(__DRIcontext * driContextPriv);
 
 extern GLboolean
-intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
-                 __DRIdrawablePrivate * driDrawPriv,
-                 __DRIdrawablePrivate * driReadPriv);
+intelMakeCurrent(__DRIcontext * driContextPriv,
+                 __DRIdrawable * driDrawPriv,
+                 __DRIdrawable * driReadPriv);
 
 extern struct intel_context *intelScreenContext(intelScreenPrivate *intelScreen);
 
index dcfcad1d9522058448e8ab535cfb92a028fdd7ad..605734d8e5867dd4699293b834dc447f857d4d99 100644 (file)
@@ -29,7 +29,6 @@
 #include "main/macros.h"
 #include "main/mtypes.h"
 #include "main/colormac.h"
-#include "main/texformat.h"
 
 #include "intel_buffers.h"
 #include "intel_fbo.h"
@@ -132,18 +131,6 @@ pwrite_8(struct intel_renderbuffer *irb, uint32_t offset, uint8_t val)
    dri_bo_subdata(irb->region->buffer, offset, 1, &val);
 }
 
-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);
-}
-
 static uint32_t no_tile_swizzle(struct intel_renderbuffer *irb,
                                int x, int y)
 {
@@ -163,6 +150,9 @@ static uint32_t x_tile_swizzle(struct intel_renderbuffer *irb,
        int     x_tile_number, y_tile_number;
        int     tile_off, tile_base;
        
+        x += irb->region->draw_x;
+        y += irb->region->draw_y;
+
        tile_stride = (irb->region->pitch * irb->region->cpp) << 3;
 
        xbyte = x * irb->region->cpp;
@@ -218,6 +208,9 @@ static uint32_t y_tile_swizzle(struct intel_renderbuffer *irb,
        int     x_tile_number, y_tile_number;
        int     tile_off, tile_base;
        
+        x += irb->region->draw_x;
+        y += irb->region->draw_y;
+
        tile_stride = (irb->region->pitch * irb->region->cpp) << 5;
 
        xbyte = x * irb->region->cpp;
@@ -273,8 +266,11 @@ static uint32_t y_tile_swizzle(struct intel_renderbuffer *irb,
    unsigned int num_cliprects;                                         \
    struct drm_clip_rect *cliprects;                                    \
    int x_off, y_off;                                                   \
+   int pitch = irb->region->pitch * irb->region->cpp;                  \
+   void *buf = irb->region->buffer->virtual;                           \
    GLuint p;                                                           \
    (void) p;                                                           \
+   (void)buf; (void)pitch; /* unused for non-gttmap. */                        \
    intel_get_cliprects(intel, &cliprects, &num_cliprects, &x_off, &y_off);
 
 /* XXX FBO: this is identical to the macro in spantmp2.h except we get
@@ -296,7 +292,6 @@ static uint32_t y_tile_swizzle(struct intel_renderbuffer *irb,
 
 #define Y_FLIP(_y) ((_y) * yScale + yBias)
 
-/* XXX with GEM, these need to tell the kernel */
 #define HW_LOCK()
 
 #define HW_UNLOCK()
@@ -339,7 +334,7 @@ static uint32_t y_tile_swizzle(struct intel_renderbuffer *irb,
 #include "intel_spantmp.h"
 
 /* x8r8g8b8 color span and pixel functions */
-#define INTEL_PIXEL_FMT GL_BGRA
+#define INTEL_PIXEL_FMT GL_BGR
 #define INTEL_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
 #define INTEL_READ_VALUE(offset) pread_xrgb8888(irb, offset)
 #define INTEL_WRITE_VALUE(offset, v) pwrite_xrgb8888(irb, offset, v)
@@ -354,6 +349,9 @@ static uint32_t y_tile_swizzle(struct intel_renderbuffer *irb,
    unsigned int num_cliprects;                                         \
    struct drm_clip_rect *cliprects;                                    \
    int x_off, y_off;                                                   \
+   int pitch = irb->region->pitch * irb->region->cpp;                  \
+   void *buf = irb->region->buffer->virtual;                           \
+   (void)buf; (void)pitch; /* unused for non-gttmap. */                        \
    intel_get_cliprects(intel, &cliprects, &num_cliprects, &x_off, &y_off);
 
 
@@ -366,20 +364,22 @@ static uint32_t y_tile_swizzle(struct intel_renderbuffer *irb,
 #define INTEL_TAG(name) name##_z16
 #include "intel_depthtmp.h"
 
-/* z24 depthbuffer functions. */
+/* z24x8 depthbuffer functions. */
 #define INTEL_VALUE_TYPE GLuint
 #define INTEL_WRITE_DEPTH(offset, d) pwrite_32(irb, offset, d)
 #define INTEL_READ_DEPTH(offset) pread_32(irb, offset)
-#define INTEL_TAG(name) name##_z24
+#define INTEL_TAG(name) name##_z24_x8
 #include "intel_depthtmp.h"
 
-/* z24s8 depthbuffer functions. */
-#define INTEL_VALUE_TYPE GLuint
-#define INTEL_WRITE_DEPTH(offset, d) pwrite_32(irb, offset, z24s8_to_s8z24(d))
-#define INTEL_READ_DEPTH(offset) s8z24_to_z24s8(pread_32(irb, offset))
-#define INTEL_TAG(name) name##_z24_s8
-#include "intel_depthtmp.h"
 
+/**
+ ** 8-bit stencil function (XXX FBO: This is obsolete)
+ **/
+/* XXX */
+#define WRITE_STENCIL(_x, _y, d) pwrite_8(irb, NO_TILE(_x, _y) + 3, d)
+#define READ_STENCIL(d, _x, _y) d = pread_8(irb, NO_TILE(_x, _y) + 3);
+#define TAG(x) intel_gttmap_##x##_z24_s8
+#include "stenciltmp.h"
 
 /**
  ** 8-bit stencil function (XXX FBO: This is obsolete)
@@ -413,6 +413,9 @@ intel_renderbuffer_map(struct intel_context *intel, struct gl_renderbuffer *rb)
    if (irb == NULL || irb->region == NULL)
       return;
 
+   if (intel->intelScreen->kernel_exec_fencing)
+      drm_intel_gem_bo_map_gtt(irb->region->buffer);
+
    intel_set_span_functions(intel, rb);
 }
 
@@ -425,7 +428,10 @@ intel_renderbuffer_unmap(struct intel_context *intel,
    if (irb == NULL || irb->region == NULL)
       return;
 
-   clear_span_cache(irb);
+   if (intel->intelScreen->kernel_exec_fencing)
+      drm_intel_gem_bo_unmap_gtt(irb->region->buffer);
+   else
+      clear_span_cache(irb);
 
    rb->GetRow = NULL;
    rb->PutRow = NULL;
@@ -494,6 +500,8 @@ intel_map_unmap_framebuffer(struct intel_context *intel,
       else
          intel_renderbuffer_unmap(intel, fb->_StencilBuffer->Wrapped);
    }
+
+   intel_check_front_buffer_rendering(intel);
 }
 
 /**
@@ -509,7 +517,6 @@ intelSpanRenderStart(GLcontext * ctx)
    GLuint i;
 
    intelFlush(&intel->ctx);
-   LOCK_HARDWARE(intel);
 
    for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) {
       if (ctx->Texture.Unit[i]._ReallyEnabled) {
@@ -545,8 +552,6 @@ intelSpanRenderFinish(GLcontext * ctx)
    intel_map_unmap_framebuffer(intel, ctx->DrawBuffer, GL_FALSE);
    if (ctx->ReadBuffer != ctx->DrawBuffer)
       intel_map_unmap_framebuffer(intel, ctx->ReadBuffer, GL_FALSE);
-
-   UNLOCK_HARDWARE(intel);
 }
 
 
@@ -605,17 +610,56 @@ intel_set_span_functions(struct intel_context *intel,
                         struct gl_renderbuffer *rb)
 {
    struct intel_renderbuffer *irb = (struct intel_renderbuffer *) rb;
-   uint32_t tiling;
+   uint32_t tiling = irb->region->tiling;
+
+   if (intel->intelScreen->kernel_exec_fencing) {
+      switch (irb->Base.Format) {
+      case MESA_FORMAT_RGB565:
+        intel_gttmap_InitPointers_RGB565(rb);
+        break;
+      case MESA_FORMAT_ARGB4444:
+        intel_gttmap_InitPointers_ARGB4444(rb);
+        break;
+      case MESA_FORMAT_ARGB1555:
+        intel_gttmap_InitPointers_ARGB1555(rb);
+        break;
+      case MESA_FORMAT_XRGB8888:
+         intel_gttmap_InitPointers_xRGB8888(rb);
+        break;
+      case MESA_FORMAT_ARGB8888:
+        intel_gttmap_InitPointers_ARGB8888(rb);
+        break;
+      case MESA_FORMAT_Z16:
+        intel_gttmap_InitDepthPointers_z16(rb);
+        break;
+      case MESA_FORMAT_X8_Z24:
+        intel_gttmap_InitDepthPointers_z24_x8(rb);
+        break;
+      case MESA_FORMAT_S8_Z24:
+        /* There are a few different ways SW asks us to access the S8Z24 data:
+         * Z24 depth-only depth reads
+         * S8Z24 depth reads
+         * S8Z24 stencil reads.
+         */
+        if (rb->Format == MESA_FORMAT_S8_Z24) {
+           intel_gttmap_InitDepthPointers_z24_x8(rb);
+        } else if (rb->Format == MESA_FORMAT_S8) {
+           intel_gttmap_InitStencilPointers_z24_s8(rb);
+        }
+        break;
+      default:
+        _mesa_problem(NULL,
+                      "Unexpected MesaFormat %d in intelSetSpanFunctions",
+                      irb->Base.Format);
+        break;
+      }
+      return;
+   }
 
    /* If in GEM mode, we need to do the tile address swizzling ourselves,
     * instead of the fence registers handling it.
     */
-   if (intel->ttm)
-      tiling = irb->region->tiling;
-   else
-      tiling = I915_TILING_NONE;
-
-   switch (irb->texformat->MesaFormat) {
+   switch (irb->Base.Format) {
    case MESA_FORMAT_RGB565:
       switch (tiling) {
       case I915_TILING_NONE:
@@ -658,35 +702,33 @@ intel_set_span_functions(struct intel_context *intel,
         break;
       }
       break;
+   case MESA_FORMAT_XRGB8888:
+      switch (tiling) {
+      case I915_TILING_NONE:
+      default:
+         intelInitPointers_xRGB8888(rb);
+         break;
+      case I915_TILING_X:
+         intel_XTile_InitPointers_xRGB8888(rb);
+         break;
+      case I915_TILING_Y:
+         intel_YTile_InitPointers_xRGB8888(rb);
+         break;
+      }
+      break;
    case MESA_FORMAT_ARGB8888:
-      if (rb->AlphaBits == 0) { /* XXX: Need xRGB8888 Mesa format */
-        /* 8888 RGBx */
-        switch (tiling) {
-        case I915_TILING_NONE:
-        default:
-           intelInitPointers_xRGB8888(rb);
-           break;
-        case I915_TILING_X:
-           intel_XTile_InitPointers_xRGB8888(rb);
-           break;
-        case I915_TILING_Y:
-           intel_YTile_InitPointers_xRGB8888(rb);
-           break;
-        }
-      } else {
-        /* 8888 RGBA */
-        switch (tiling) {
-        case I915_TILING_NONE:
-        default:
-           intelInitPointers_ARGB8888(rb);
-           break;
-        case I915_TILING_X:
-           intel_XTile_InitPointers_ARGB8888(rb);
-           break;
-        case I915_TILING_Y:
-           intel_YTile_InitPointers_ARGB8888(rb);
-           break;
-        }
+      /* 8888 RGBA */
+      switch (tiling) {
+      case I915_TILING_NONE:
+      default:
+        intelInitPointers_ARGB8888(rb);
+        break;
+      case I915_TILING_X:
+        intel_XTile_InitPointers_ARGB8888(rb);
+        break;
+      case I915_TILING_Y:
+        intel_YTile_InitPointers_ARGB8888(rb);
+        break;
       }
       break;
    case MESA_FORMAT_Z16:
@@ -703,39 +745,27 @@ intel_set_span_functions(struct intel_context *intel,
         break;
       }
       break;
+   case MESA_FORMAT_X8_Z24:
    case MESA_FORMAT_S8_Z24:
       /* There are a few different ways SW asks us to access the S8Z24 data:
        * Z24 depth-only depth reads
        * S8Z24 depth reads
        * S8Z24 stencil reads.
        */
-      if (rb->_ActualFormat == GL_DEPTH_COMPONENT24) {
-        switch (tiling) {
-        case I915_TILING_NONE:
-        default:
-           intelInitDepthPointers_z24(rb);
-           break;
-        case I915_TILING_X:
-           intel_XTile_InitDepthPointers_z24(rb);
-           break;
-        case I915_TILING_Y:
-           intel_YTile_InitDepthPointers_z24(rb);
-           break;
-        }
-      } else if (rb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT) {
+      if (rb->Format == MESA_FORMAT_S8_Z24) {
         switch (tiling) {
         case I915_TILING_NONE:
         default:
-           intelInitDepthPointers_z24_s8(rb);
+           intelInitDepthPointers_z24_x8(rb);
            break;
         case I915_TILING_X:
-           intel_XTile_InitDepthPointers_z24_s8(rb);
+           intel_XTile_InitDepthPointers_z24_x8(rb);
            break;
         case I915_TILING_Y:
-           intel_YTile_InitDepthPointers_z24_s8(rb);
+           intel_YTile_InitDepthPointers_z24_x8(rb);
            break;
         }
-      } else if (rb->_ActualFormat == GL_STENCIL_INDEX8_EXT) {
+      } else if (rb->Format == MESA_FORMAT_S8) {
         switch (tiling) {
         case I915_TILING_NONE:
         default:
index ead0b1c16831d41987f89dad7ceb5f916fa70de6..bad03398f684793183b746bff10b4862358840de 100644 (file)
  * all the tiling styles.
  */
 
+#define SPANTMP_PIXEL_FMT INTEL_PIXEL_FMT
+#define SPANTMP_PIXEL_TYPE INTEL_PIXEL_TYPE
+#define TAG(x) INTEL_TAG(intel_gttmap_##x)
+#define TAG2(x, y) INTEL_TAG(intel_gttmap_##x##y)
+#include "spantmp2.h"
+
 #define SPANTMP_PIXEL_FMT INTEL_PIXEL_FMT
 #define SPANTMP_PIXEL_TYPE INTEL_PIXEL_TYPE
 #define PUT_VALUE(_x, _y, v) INTEL_WRITE_VALUE(NO_TILE(_x, _y), v)
@@ -48,8 +54,8 @@
 
 #define SPANTMP_PIXEL_FMT INTEL_PIXEL_FMT
 #define SPANTMP_PIXEL_TYPE INTEL_PIXEL_TYPE
-#define PUT_VALUE(_x, _y, v) INTEL_WRITE_VALUE(X_TILE(_x, _y), v)
-#define GET_VALUE(_x, _y) INTEL_READ_VALUE(X_TILE(_x, _y))
+#define PUT_VALUE(_x, _y, v) INTEL_WRITE_VALUE(Y_TILE(_x, _y), v)
+#define GET_VALUE(_x, _y) INTEL_READ_VALUE(Y_TILE(_x, _y))
 #define TAG(x) INTEL_TAG(intel_YTile_##x)
 #define TAG2(x, y) INTEL_TAG(intel_YTile_##x)##y
 #include "spantmp2.h"
index 4ee742377d696e563756afcb3c3ebd2f746123b4..aefae53eb20750fe965b6ceed8db290189726347 100644 (file)
@@ -196,25 +196,6 @@ intel_translate_logic_op(GLenum opcode)
    }
 }
 
-
-static void
-intelClearColor(GLcontext *ctx, const GLfloat color[4])
-{
-   struct intel_context *intel = intel_context(ctx);
-   GLubyte clear[4];
-
-   CLAMPED_FLOAT_TO_UBYTE(clear[0], color[0]);
-   CLAMPED_FLOAT_TO_UBYTE(clear[1], color[1]);
-   CLAMPED_FLOAT_TO_UBYTE(clear[2], color[2]);
-   CLAMPED_FLOAT_TO_UBYTE(clear[3], color[3]);
-
-   /* compute both 32 and 16-bit clear values */
-   intel->ClearColor8888 = INTEL_PACKCOLOR8888(clear[0], clear[1],
-                                               clear[2], clear[3]);
-   intel->ClearColor565 = INTEL_PACKCOLOR565(clear[0], clear[1], clear[2]);
-}
-
-
 /* Fallback to swrast for select and feedback.
  */
 static void
@@ -229,5 +210,4 @@ void
 intelInitStateFuncs(struct dd_function_table *functions)
 {
    functions->RenderMode = intelRenderMode;
-   functions->ClearColor = intelClearColor;
 }
diff --git a/src/mesa/drivers/dri/intel/intel_swapbuffers.c b/src/mesa/drivers/dri/intel/intel_swapbuffers.c
deleted file mode 100644 (file)
index 7d035b9..0000000
+++ /dev/null
@@ -1,248 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- * 
- **************************************************************************/
-
-#include "intel_blit.h"
-#include "intel_buffers.h"
-#include "intel_swapbuffers.h"
-#include "intel_fbo.h"
-#include "intel_batchbuffer.h"
-#include "drirenderbuffer.h"
-#include "vblank.h"
-#include "i915_drm.h"
-
-
-
-/*
- * Correct a drawablePrivate's set of vblank flags WRT the current context.
- * When considering multiple crtcs.
- */
-GLuint
-intelFixupVblank(struct intel_context *intel, __DRIdrawablePrivate *dPriv)
-{
-   if (!intel->intelScreen->driScrnPriv->dri2.enabled &&
-       intel->intelScreen->driScrnPriv->ddx_version.minor >= 7) {
-      volatile drm_i915_sarea_t *sarea = intel->sarea;
-      drm_clip_rect_t drw_rect = { .x1 = dPriv->x, .x2 = dPriv->x + dPriv->w,
-                                  .y1 = dPriv->y, .y2 = dPriv->y + dPriv->h };
-      drm_clip_rect_t planeA_rect = { .x1 = sarea->planeA_x, .y1 = sarea->planeA_y,
-                                    .x2 = sarea->planeA_x + sarea->planeA_w,
-                                    .y2 = sarea->planeA_y + sarea->planeA_h };
-      drm_clip_rect_t planeB_rect = { .x1 = sarea->planeB_x, .y1 = sarea->planeB_y,
-                                    .x2 = sarea->planeB_x + sarea->planeB_w,
-                                    .y2 = sarea->planeB_y + sarea->planeB_h };
-      GLint areaA = driIntersectArea( drw_rect, planeA_rect );
-      GLint areaB = driIntersectArea( drw_rect, planeB_rect );
-      GLuint flags = dPriv->vblFlags;
-
-      /* Update vblank info
-       */
-      if (areaB > areaA || (areaA == areaB && areaB > 0)) {
-        flags = dPriv->vblFlags | VBLANK_FLAG_SECONDARY;
-      } else {
-        flags = dPriv->vblFlags & ~VBLANK_FLAG_SECONDARY;
-      }
-
-      /* Do the stupid test: Is one of them actually disabled?
-       */
-      if (sarea->planeA_w == 0 || sarea->planeA_h == 0) {
-        flags = dPriv->vblFlags | VBLANK_FLAG_SECONDARY;
-      } else if (sarea->planeB_w == 0 || sarea->planeB_h == 0) {
-        flags = dPriv->vblFlags & ~VBLANK_FLAG_SECONDARY;
-      }
-
-      return flags;
-   } else {
-      return dPriv->vblFlags & ~VBLANK_FLAG_SECONDARY;
-   }
-}
-
-
-/**
- * Called from driSwapBuffers()
- */
-void
-intelSwapBuffers(__DRIdrawablePrivate * dPriv)
-{
-   __DRIscreenPrivate *psp = dPriv->driScreenPriv;
-
-   if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
-      GET_CURRENT_CONTEXT(ctx);
-      struct intel_context *intel;
-
-      if (ctx == NULL)
-        return;
-
-      intel = intel_context(ctx);
-
-      if (ctx->Visual.doubleBufferMode) {
-        GLboolean missed_target;
-        struct intel_framebuffer *intel_fb = dPriv->driverPrivate;
-        int64_t ust;
-         
-        _mesa_notifySwapBuffers(ctx);  /* flush pending rendering comands */
-
-       /*
-        * The old swapping ioctl was incredibly racy, just wait for vblank
-        * and do the swap ourselves.
-        */
-        driWaitForVBlank(dPriv, &missed_target);
-
-        /*
-         * Update each buffer's vbl_pending so we don't get too out of
-         * sync
-         */
-        intel_get_renderbuffer(&intel_fb->Base,
-                               BUFFER_BACK_LEFT)->vbl_pending = dPriv->vblSeq;
-         intel_get_renderbuffer(&intel_fb->Base,
-                               BUFFER_FRONT_LEFT)->vbl_pending = dPriv->vblSeq;
-
-        intelCopyBuffer(dPriv, NULL);
-
-        intel_fb->swap_count++;
-        (*psp->systemTime->getUST) (&ust);
-        if (missed_target) {
-           intel_fb->swap_missed_count++;
-           intel_fb->swap_missed_ust = ust - intel_fb->swap_ust;
-        }
-
-        intel_fb->swap_ust = ust;
-      }
-      drmCommandNone(intel->driFd, DRM_I915_GEM_THROTTLE);
-   }
-   else {
-      /* XXX this shouldn't be an error but we can't handle it for now */
-      fprintf(stderr, "%s: drawable has no context!\n", __FUNCTION__);
-   }
-}
-
-
-/**
- * Called from driCopySubBuffer()
- */
-void
-intelCopySubBuffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h)
-{
-   if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
-      struct intel_context *intel =
-         (struct intel_context *) dPriv->driContextPriv->driverPrivate;
-      GLcontext *ctx = &intel->ctx;
-
-      if (ctx->Visual.doubleBufferMode) {
-         drm_clip_rect_t rect;
-         rect.x1 = x + dPriv->x;
-         rect.y1 = (dPriv->h - y - h) + dPriv->y;
-         rect.x2 = rect.x1 + w;
-         rect.y2 = rect.y1 + h;
-         _mesa_notifySwapBuffers(ctx);  /* flush pending rendering comands */
-         intelCopyBuffer(dPriv, &rect);
-      }
-   }
-   else {
-      /* XXX this shouldn't be an error but we can't handle it for now */
-      fprintf(stderr, "%s: drawable has no context!\n", __FUNCTION__);
-   }
-}
-
-
-/**
- * This will be called whenever the currently bound window is moved/resized.
- * XXX: actually, it seems to NOT be called when the window is only moved (BP).
- */
-void
-intelWindowMoved(struct intel_context *intel)
-{
-   GLcontext *ctx = &intel->ctx;
-   __DRIdrawablePrivate *dPriv = intel->driDrawable;
-   struct intel_framebuffer *intel_fb = dPriv->driverPrivate;
-
-   if (!intel->intelScreen->driScrnPriv->dri2.enabled &&
-       intel->intelScreen->driScrnPriv->ddx_version.minor >= 7) {
-      GLuint flags = intelFixupVblank(intel, dPriv);
-
-      /* Check to see if we changed pipes */
-      if (flags != dPriv->vblFlags && dPriv->vblFlags &&
-         !(dPriv->vblFlags & VBLANK_FLAG_NO_IRQ)) {
-        int64_t count;
-        drmVBlank vbl;
-        int i;
-
-        /*
-         * Deal with page flipping
-         */
-        vbl.request.type = DRM_VBLANK_ABSOLUTE;
-
-        if ( dPriv->vblFlags & VBLANK_FLAG_SECONDARY ) {
-           vbl.request.type |= DRM_VBLANK_SECONDARY;
-        }
-
-        for (i = 0; i < 2; i++) {
-           if (!intel_fb->color_rb[i] ||
-               (intel_fb->vbl_waited - intel_fb->color_rb[i]->vbl_pending) <=
-               (1<<23))
-              continue;
-
-           vbl.request.sequence = intel_fb->color_rb[i]->vbl_pending;
-           drmWaitVBlank(intel->driFd, &vbl);
-        }
-
-        /*
-         * Update msc_base from old pipe
-         */
-        driDrawableGetMSC32(dPriv->driScreenPriv, dPriv, &count);
-        dPriv->msc_base = count;
-        /*
-         * Then get new vblank_base and vblSeq values
-         */
-        dPriv->vblFlags = flags;
-        driGetCurrentVBlank(dPriv);
-        dPriv->vblank_base = dPriv->vblSeq;
-
-        intel_fb->vbl_waited = dPriv->vblSeq;
-
-        for (i = 0; i < 2; i++) {
-           if (intel_fb->color_rb[i])
-              intel_fb->color_rb[i]->vbl_pending = intel_fb->vbl_waited;
-        }
-      }
-   } else {
-      dPriv->vblFlags &= ~VBLANK_FLAG_SECONDARY;
-   }
-
-   /* Update Mesa's notion of window size */
-   driUpdateFramebufferSize(ctx, dPriv);
-   intel_fb->Base.Initialized = GL_TRUE; /* XXX remove someday */
-
-   /* Update hardware scissor */
-   if (ctx->Driver.Scissor != NULL) {
-      ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
-                         ctx->Scissor.Width, ctx->Scissor.Height);
-   }
-
-   /* Re-calculate viewport related state */
-   if (ctx->Driver.DepthRange != NULL)
-      ctx->Driver.DepthRange( ctx, ctx->Viewport.Near, ctx->Viewport.Far );
-}
diff --git a/src/mesa/drivers/dri/intel/intel_swapbuffers.h b/src/mesa/drivers/dri/intel/intel_swapbuffers.h
deleted file mode 100644 (file)
index 75bb624..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-
-/**************************************************************************
- * 
- * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- * 
- **************************************************************************/
-
-#ifndef INTEL_SWAPBUFFERS_H
-#define INTEL_SWAPBUFFERS_H
-
-#include "dri_util.h"
-#include "drm.h"
-
-struct intel_context;
-struct intel_framebuffer;
-
-
-extern void
-intelSwapBuffers(__DRIdrawablePrivate * dPriv);
-
-extern void
-intelCopySubBuffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h);
-
-extern GLuint
-intelFixupVblank(struct intel_context *intel, __DRIdrawablePrivate *dPriv);
-
-extern void
-intelWindowMoved(struct intel_context *intel);
-
-
-#endif /* INTEL_SWAPBUFFERS_H */
index 1286fe929bc150f0d5fa501ebf52344eb38a4715..0d7889d3c258179bf74b6ee4ac28aeddbb79d805 100644 (file)
@@ -114,7 +114,7 @@ static void intel_check_sync(GLcontext *ctx, struct gl_sync_object *s)
 {
    struct intel_sync_object *sync = (struct intel_sync_object *)s;
 
-   if (sync->bo && drm_intel_bo_busy(sync->bo)) {
+   if (sync->bo && !drm_intel_bo_busy(sync->bo)) {
       drm_intel_bo_unreference(sync->bo);
       sync->bo = NULL;
       s->StatusFlag = 1;
index 3cbc379dbd32a0cb31b3741887907fb93e6fac97..215a534a5c53105a61b2d0e579c5ec79f458088f 100644 (file)
@@ -177,6 +177,28 @@ intelGenerateMipmap(GLcontext *ctx, GLenum target,
       intel_tex_map_level_images(intel, intelObj, texObj->BaseLevel);
       _mesa_generate_mipmap(ctx, target, texObj);
       intel_tex_unmap_level_images(intel, intelObj, texObj->BaseLevel);
+
+      {
+         GLuint nr_faces = (texObj->Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
+         GLuint face, i;
+         /* 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 =
+                  intel_texture_image(texObj->Image[face][i]);
+               if (!intelImage)
+                  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);
+            }
+         }
+      }
    }
    else {
       _mesa_meta_GenerateMipmap(ctx, target, texObj);
index 57ed0b1aabda20b24064ca55527b8e243f2c47e9..f3cc0fff5c81410eaba8da2d55e48c70e3dfc1c4 100644 (file)
@@ -29,6 +29,7 @@
 #define INTELTEX_INC
 
 #include "main/mtypes.h"
+#include "main/formats.h"
 #include "intel_context.h"
 #include "texmem.h"
 
@@ -41,10 +42,8 @@ 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);
+gl_format intelChooseTextureFormat(GLcontext *ctx, GLint internalFormat,
+                                   GLenum format, GLenum type);
 
 void intelSetTexOffset(__DRIcontext *pDRICtx, GLint texname,
                       unsigned long long offset, GLint depth, GLuint pitch);
index f3e312420dde31127f2984c9b4e8380f33b1bb03..d8e71093c47b06441f79d1de3eb1e38f2ec8c0e6 100644 (file)
@@ -29,6 +29,7 @@
 #include "main/enums.h"
 #include "main/image.h"
 #include "main/teximage.h"
+#include "main/texstate.h"
 #include "main/mipmap.h"
 
 #include "drivers/common/meta.h"
@@ -92,8 +93,7 @@ do_copy_texsubimage(struct intel_context *intel,
                     GLint x, GLint y, GLsizei width, GLsizei height)
 {
    GLcontext *ctx = &intel->ctx;
-   const struct intel_region *src =
-      get_teximage_source(intel, internalFormat);
+   const struct intel_region *src = get_teximage_source(intel, internalFormat);
 
    if (!intelImage->mt || !src) {
       if (INTEL_DEBUG & DEBUG_FALLBACKS)
@@ -109,33 +109,34 @@ do_copy_texsubimage(struct intel_context *intel,
       return GL_FALSE;
    }
 
-   intelFlush(ctx);
-   LOCK_HARDWARE(intel);
+   /* intelFlush(ctx); */
    {
       drm_intel_bo *dst_bo = intel_region_buffer(intel,
                                                 intelImage->mt->region,
                                                 INTEL_WRITE_PART);
-      GLuint image_offset = intel_miptree_image_offset(intelImage->mt,
-                                                       intelImage->face,
-                                                       intelImage->level);
       const GLint orig_x = x;
       const GLint orig_y = y;
+      GLuint image_x, image_y;
       GLshort src_pitch;
 
+      /* get dest x/y in destination texture */
+      intel_miptree_get_image_offset(intelImage->mt,
+                                    intelImage->level,
+                                    intelImage->face,
+                                    0,
+                                    &image_x, &image_y);
       /* Update dst for clipped src.  Need to also clip the source rect. */
       dstx += x - orig_x;
       dsty += y - orig_y;
 
       /* 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);
+      if (intelImage->mt->region->tiling == I915_TILING_Y) {
         return GL_FALSE;
       }
 
       if (ctx->ReadBuffer->Name == 0) {
         /* reading from a window, adjust x, y */
-        const __DRIdrawablePrivate *dPriv = intel->driReadDrawable;
+        const __DRIdrawable *dPriv = intel->driReadDrawable;
         y = dPriv->y + (dPriv->h - (y + height));
         x += dPriv->x;
 
@@ -152,6 +153,7 @@ do_copy_texsubimage(struct intel_context *intel,
         src_pitch = src->pitch;
       }
 
+      /* blit from src buffer to texture */
       if (!intelEmitCopyBlit(intel,
                             intelImage->mt->cpp,
                             src_pitch,
@@ -160,17 +162,16 @@ do_copy_texsubimage(struct intel_context *intel,
                             src->tiling,
                             intelImage->mt->pitch,
                             dst_bo,
-                            image_offset,
+                            0,
                             intelImage->mt->region->tiling,
-                            x, y, dstx, dsty, width, height,
+                            src->draw_x + x, src->draw_y + y,
+                            image_x + dstx, image_y + dsty,
+                            width, height,
                             GL_COPY)) {
-        UNLOCK_HARDWARE(intel);
         return GL_FALSE;
       }
    }
 
-   UNLOCK_HARDWARE(intel);
-
    return GL_TRUE;
 }
 
@@ -180,8 +181,7 @@ intelCopyTexImage1D(GLcontext * ctx, GLenum target, GLint level,
                     GLenum internalFormat,
                     GLint x, GLint y, GLsizei width, GLint border)
 {
-   struct gl_texture_unit *texUnit =
-      &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+   struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
    struct gl_texture_object *texObj =
       _mesa_select_tex_object(ctx, texUnit, target);
    struct gl_texture_image *texImage =
@@ -217,6 +217,8 @@ intelCopyTexImage1D(GLcontext * ctx, GLenum target, GLint level,
    return;
 
  fail:
+   if (INTEL_DEBUG & DEBUG_FALLBACKS)
+      fprintf(stderr, "%s - fallback to swrast\n", __FUNCTION__);
    _mesa_meta_CopyTexImage1D(ctx, target, level, internalFormat, x, y,
                              width, border);
 }
@@ -228,8 +230,7 @@ intelCopyTexImage2D(GLcontext * ctx, GLenum target, GLint level,
                     GLint x, GLint y, GLsizei width, GLsizei height,
                     GLint border)
 {
-   struct gl_texture_unit *texUnit =
-      &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+   struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
    struct gl_texture_object *texObj =
       _mesa_select_tex_object(ctx, texUnit, target);
    struct gl_texture_image *texImage =
@@ -244,7 +245,7 @@ intelCopyTexImage2D(GLcontext * ctx, GLenum target, GLint level,
     */
    ctx->Driver.TexImage2D(ctx, target, level, internalFormat,
                           width, height, border,
-                          GL_RGBA, CHAN_TYPE, NULL,
+                          GL_RGBA, GL_UNSIGNED_BYTE, NULL,
                           &ctx->DefaultPacking, texObj, texImage);
 
    srcx = x;
@@ -265,6 +266,8 @@ intelCopyTexImage2D(GLcontext * ctx, GLenum target, GLint level,
    return;
 
  fail:
+   if (INTEL_DEBUG & DEBUG_FALLBACKS)
+      fprintf(stderr, "%s - fallback to swrast\n", __FUNCTION__);
    _mesa_meta_CopyTexImage2D(ctx, target, level, internalFormat, x, y,
                              width, height, border);
 }
@@ -274,8 +277,7 @@ static void
 intelCopyTexSubImage1D(GLcontext * ctx, GLenum target, GLint level,
                        GLint xoffset, GLint x, GLint y, GLsizei width)
 {
-   struct gl_texture_unit *texUnit =
-      &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+   struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
    struct gl_texture_object *texObj =
       _mesa_select_tex_object(ctx, texUnit, target);
    struct gl_texture_image *texImage =
@@ -290,6 +292,8 @@ intelCopyTexSubImage1D(GLcontext * ctx, GLenum target, GLint level,
    if (!do_copy_texsubimage(intel_context(ctx), target,
                             intel_texture_image(texImage),
                             internalFormat, xoffset, 0, x, y, width, 1)) {
+      if (INTEL_DEBUG & DEBUG_FALLBACKS)
+         fprintf(stderr, "%s - fallback to swrast\n", __FUNCTION__);
       _mesa_meta_CopyTexSubImage1D(ctx, target, level, xoffset, x, y, width);
    }
 }
@@ -300,8 +304,7 @@ intelCopyTexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
                        GLint xoffset, GLint yoffset,
                        GLint x, GLint y, GLsizei width, GLsizei height)
 {
-   struct gl_texture_unit *texUnit =
-      &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+   struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
    struct gl_texture_object *texObj =
       _mesa_select_tex_object(ctx, texUnit, target);
    struct gl_texture_image *texImage =
@@ -316,8 +319,8 @@ intelCopyTexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
                             internalFormat,
                             xoffset, yoffset, x, y, width, height)) {
 
-      DBG("%s - fallback to _mesa_meta_CopyTexSubImage2D\n", __FUNCTION__);
-
+      if (INTEL_DEBUG & DEBUG_FALLBACKS)
+         fprintf(stderr, "%s - fallback to swrast\n", __FUNCTION__);
       _mesa_meta_CopyTexSubImage2D(ctx, target, level,
                                    xoffset, yoffset, x, y, width, height);
    }
index 3322a711307a703f04133020a97fd39b8075073b..a7c6c45ffe41da25a3a25b8ee324a719de0352df 100644 (file)
@@ -1,7 +1,6 @@
 #include "intel_context.h"
 #include "intel_tex.h"
 #include "intel_chipset.h"
-#include "main/texformat.h"
 #include "main/enums.h"
 
 
@@ -16,7 +15,7 @@
  * these if we take the step of simply swizzling the colors
  * immediately after sampling...
  */
-const struct gl_texture_format *
+gl_format
 intelChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
                          GLenum format, GLenum type)
 {
@@ -34,48 +33,48 @@ intelChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
    case GL_COMPRESSED_RGBA:
       if (format == GL_BGRA) {
          if (type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_INT_8_8_8_8_REV) {
-            return &_mesa_texformat_argb8888;
+            return MESA_FORMAT_ARGB8888;
          }
          else if (type == GL_UNSIGNED_SHORT_4_4_4_4_REV) {
-            return &_mesa_texformat_argb4444;
+            return MESA_FORMAT_ARGB4444;
          }
          else if (type == GL_UNSIGNED_SHORT_1_5_5_5_REV) {
-            return &_mesa_texformat_argb1555;
+            return MESA_FORMAT_ARGB1555;
          }
       }
-      return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+      return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444;
 
    case 3:
    case GL_RGB:
    case GL_COMPRESSED_RGB:
       if (format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5) {
-         return &_mesa_texformat_rgb565;
+         return MESA_FORMAT_RGB565;
       }
-      return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
+      return do32bpt ? MESA_FORMAT_XRGB8888 : MESA_FORMAT_RGB565;
 
    case GL_RGBA8:
    case GL_RGB10_A2:
    case GL_RGBA12:
    case GL_RGBA16:
-      return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+      return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444;
 
    case GL_RGBA4:
    case GL_RGBA2:
-      return &_mesa_texformat_argb4444;
+      return MESA_FORMAT_ARGB4444;
 
    case GL_RGB5_A1:
-      return &_mesa_texformat_argb1555;
+      return MESA_FORMAT_ARGB1555;
 
    case GL_RGB8:
    case GL_RGB10:
    case GL_RGB12:
    case GL_RGB16:
-      return &_mesa_texformat_argb8888;
+      return MESA_FORMAT_XRGB8888;
 
    case GL_RGB5:
    case GL_RGB4:
    case GL_R3_G3_B2:
-      return &_mesa_texformat_rgb565;
+      return MESA_FORMAT_RGB565;
 
    case GL_ALPHA:
    case GL_ALPHA4:
@@ -83,7 +82,7 @@ intelChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
    case GL_ALPHA12:
    case GL_ALPHA16:
    case GL_COMPRESSED_ALPHA:
-      return &_mesa_texformat_a8;
+      return MESA_FORMAT_A8;
 
    case 1:
    case GL_LUMINANCE:
@@ -92,18 +91,24 @@ intelChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
    case GL_LUMINANCE12:
    case GL_LUMINANCE16:
    case GL_COMPRESSED_LUMINANCE:
-      return &_mesa_texformat_l8;
+      return MESA_FORMAT_L8;
+
+   case GL_LUMINANCE12_ALPHA4:
+   case GL_LUMINANCE12_ALPHA12:
+   case GL_LUMINANCE16_ALPHA16:
+#ifndef I915
+      return MESA_FORMAT_AL1616;
+#else
+      /* FALLTHROUGH */
+#endif
 
    case 2:
    case GL_LUMINANCE_ALPHA:
    case GL_LUMINANCE4_ALPHA4:
    case GL_LUMINANCE6_ALPHA2:
    case GL_LUMINANCE8_ALPHA8:
-   case GL_LUMINANCE12_ALPHA4:
-   case GL_LUMINANCE12_ALPHA12:
-   case GL_LUMINANCE16_ALPHA16:
    case GL_COMPRESSED_LUMINANCE_ALPHA:
-      return &_mesa_texformat_al88;
+      return MESA_FORMAT_AL88;
 
    case GL_INTENSITY:
    case GL_INTENSITY4:
@@ -111,41 +116,41 @@ intelChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
    case GL_INTENSITY12:
    case GL_INTENSITY16:
    case GL_COMPRESSED_INTENSITY:
-      return &_mesa_texformat_i8;
+      return MESA_FORMAT_I8;
 
    case GL_YCBCR_MESA:
       if (type == GL_UNSIGNED_SHORT_8_8_MESA || type == GL_UNSIGNED_BYTE)
-         return &_mesa_texformat_ycbcr;
+         return MESA_FORMAT_YCBCR;
       else
-         return &_mesa_texformat_ycbcr_rev;
+         return MESA_FORMAT_YCBCR_REV;
 
    case GL_COMPRESSED_RGB_FXT1_3DFX:
-      return &_mesa_texformat_rgb_fxt1;
+      return MESA_FORMAT_RGB_FXT1;
    case GL_COMPRESSED_RGBA_FXT1_3DFX:
-      return &_mesa_texformat_rgba_fxt1;
+      return MESA_FORMAT_RGBA_FXT1;
 
    case GL_RGB_S3TC:
    case GL_RGB4_S3TC:
    case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
-      return &_mesa_texformat_rgb_dxt1;
+      return MESA_FORMAT_RGB_DXT1;
 
    case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
-      return &_mesa_texformat_rgba_dxt1;
+      return MESA_FORMAT_RGBA_DXT1;
 
    case GL_RGBA_S3TC:
    case GL_RGBA4_S3TC:
    case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
-      return &_mesa_texformat_rgba_dxt3;
+      return MESA_FORMAT_RGBA_DXT3;
 
    case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
-      return &_mesa_texformat_rgba_dxt5;
+      return MESA_FORMAT_RGBA_DXT5;
 
    case GL_DEPTH_COMPONENT:
    case GL_DEPTH_COMPONENT16:
    case GL_DEPTH_COMPONENT24:
    case GL_DEPTH_COMPONENT32:
 #if 0
-      return &_mesa_texformat_z16;
+      return MESA_FORMAT_Z16;
 #else
       /* fall-through.
        * 16bpp depth texture can't be paired with a stencil buffer so
@@ -154,7 +159,7 @@ intelChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
 #endif
    case GL_DEPTH_STENCIL_EXT:
    case GL_DEPTH24_STENCIL8_EXT:
-      return &_mesa_texformat_s8_z24;
+      return MESA_FORMAT_S8_Z24;
 
 #ifndef I915
    case GL_SRGB_EXT:
@@ -165,41 +170,41 @@ intelChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
    case GL_COMPRESSED_SRGB_ALPHA_EXT:
    case GL_COMPRESSED_SLUMINANCE_EXT:
    case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT:
-      return &_mesa_texformat_sargb8;
+      return MESA_FORMAT_SARGB8;
    case GL_SLUMINANCE_EXT:
    case GL_SLUMINANCE8_EXT:
-      if (IS_G4X(intel->intelScreen->deviceID))
-         return &_mesa_texformat_sl8;
+      if (intel->has_luminance_srgb)
+         return MESA_FORMAT_SL8;
       else
-         return &_mesa_texformat_sargb8;
+         return MESA_FORMAT_SARGB8;
    case GL_SLUMINANCE_ALPHA_EXT:
    case GL_SLUMINANCE8_ALPHA8_EXT:
-      if (IS_G4X(intel->intelScreen->deviceID))
-         return &_mesa_texformat_sla8;
+      if (intel->has_luminance_srgb)
+         return MESA_FORMAT_SLA8;
       else
-         return &_mesa_texformat_sargb8;
+         return MESA_FORMAT_SARGB8;
    case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
    case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
    case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
    case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
-      return &_mesa_texformat_srgb_dxt1;
+      return MESA_FORMAT_SRGB_DXT1;
 
    /* i915 could also do this */
    case GL_DUDV_ATI:
    case GL_DU8DV8_ATI:
-      return &_mesa_texformat_dudv8;
+      return MESA_FORMAT_DUDV8;
    case GL_RGBA_SNORM:
    case GL_RGBA8_SNORM:
-      return &_mesa_texformat_signed_rgba8888_rev;
+      return MESA_FORMAT_SIGNED_RGBA8888_REV;
 #endif
 
    default:
       fprintf(stderr, "unexpected texture format %s in %s\n",
               _mesa_lookup_enum_by_nr(internalFormat), __FUNCTION__);
-      return NULL;
+      return MESA_FORMAT_NONE;
    }
 
-   return NULL;                 /* never get here */
+   return MESA_FORMAT_NONE;       /* never get here */
 }
 
 int intel_compressed_num_bytes(GLuint mesaFormat)
index 66201b1f465f82bf7d284b1c24fb6d8d3e056ec3..307669f87ec780365f672e5a5dacc2b3775db466 100644 (file)
@@ -6,8 +6,10 @@
 #include "main/bufferobj.h"
 #include "main/convolve.h"
 #include "main/context.h"
+#include "main/formats.h"
+#include "main/image.h"
 #include "main/texcompress.h"
-#include "main/texformat.h"
+#include "main/texstore.h"
 #include "main/texgetimage.h"
 #include "main/texobj.h"
 #include "main/texstore.h"
@@ -69,6 +71,7 @@ guess_and_alloc_mipmap_tree(struct intel_context *intel,
    GLuint depth = intelImage->base.Depth;
    GLuint l2width, l2height, l2depth;
    GLuint i, comp_byte = 0;
+   GLuint texelBytes;
 
    DBG("%s\n", __FUNCTION__);
 
@@ -112,7 +115,8 @@ guess_and_alloc_mipmap_tree(struct intel_context *intel,
     */
    if ((intelObj->base.MinFilter == GL_NEAREST ||
         intelObj->base.MinFilter == GL_LINEAR) &&
-       intelImage->level == firstLevel) {
+       intelImage->level == firstLevel &&
+       (intel->gen < 4 || firstLevel == 0)) {
       lastLevel = firstLevel;
    }
    else {
@@ -123,8 +127,11 @@ guess_and_alloc_mipmap_tree(struct intel_context *intel,
    }
 
    assert(!intelObj->mt);
-   if (intelImage->base.IsCompressed)
-      comp_byte = intel_compressed_num_bytes(intelImage->base.TexFormat->MesaFormat);
+   if (_mesa_is_format_compressed(intelImage->base.TexFormat))
+      comp_byte = intel_compressed_num_bytes(intelImage->base.TexFormat);
+
+   texelBytes = _mesa_get_format_bytes(intelImage->base.TexFormat);
+
    intelObj->mt = intel_miptree_create(intel,
                                        intelObj->base.Target,
                                        intelImage->base._BaseFormat,
@@ -134,7 +141,7 @@ guess_and_alloc_mipmap_tree(struct intel_context *intel,
                                        width,
                                        height,
                                        depth,
-                                       intelImage->base.TexFormat->TexelBytes,
+                                       texelBytes,
                                        comp_byte,
                                       expect_accelerated_upload);
 
@@ -166,7 +173,7 @@ target_to_face(GLenum target)
 static GLboolean
 check_pbo_format(GLint internalFormat,
                  GLenum format, GLenum type,
-                 const struct gl_texture_format *mesa_format)
+                 gl_format mesa_format)
 {
    switch (internalFormat) {
    case 4:
@@ -174,12 +181,12 @@ check_pbo_format(GLint internalFormat,
       return (format == GL_BGRA &&
               (type == GL_UNSIGNED_BYTE ||
                type == GL_UNSIGNED_INT_8_8_8_8_REV) &&
-              mesa_format == &_mesa_texformat_argb8888);
+              mesa_format == MESA_FORMAT_ARGB8888);
    case 3:
    case GL_RGB:
       return (format == GL_RGB &&
               type == GL_UNSIGNED_SHORT_5_6_5 &&
-              mesa_format == &_mesa_texformat_rgb565);
+              mesa_format == MESA_FORMAT_RGB565);
    case GL_YCBCR_MESA:
       return (type == GL_UNSIGNED_SHORT_8_8_MESA || type == GL_UNSIGNED_BYTE);
    default:
@@ -200,7 +207,10 @@ try_pbo_upload(struct intel_context *intel,
 {
    struct intel_buffer_object *pbo = intel_buffer_object(unpack->BufferObj);
    GLuint src_offset, src_stride;
-   GLuint dst_offset, dst_stride;
+   GLuint dst_x, dst_y, dst_stride;
+   dri_bo *dst_buffer = intel_region_buffer(intel,
+                                           intelImage->mt->region,
+                                           INTEL_WRITE_FULL);
 
    if (!_mesa_is_bufferobj(unpack->BufferObj) ||
        intel->ctx._ImageTransferState ||
@@ -217,32 +227,26 @@ try_pbo_upload(struct intel_context *intel,
    else
       src_stride = width;
 
-   dst_offset = intel_miptree_image_offset(intelImage->mt,
-                                           intelImage->face,
-                                           intelImage->level);
+   intel_miptree_get_image_offset(intelImage->mt, intelImage->level,
+                                 intelImage->face, 0,
+                                 &dst_x, &dst_y);
 
    dst_stride = intelImage->mt->pitch;
 
-   intelFlush(&intel->ctx);
-   LOCK_HARDWARE(intel);
+   if (drm_intel_bo_references(intel->batch->buf, dst_buffer))
+      intelFlush(&intel->ctx);
    {
       dri_bo *src_buffer = intel_bufferobj_buffer(intel, pbo, INTEL_READ);
-      dri_bo *dst_buffer = intel_region_buffer(intel,
-                                              intelImage->mt->region,
-                                              INTEL_WRITE_FULL);
-
 
       if (!intelEmitCopyBlit(intel,
                             intelImage->mt->cpp,
                             src_stride, src_buffer, src_offset, GL_FALSE,
-                            dst_stride, dst_buffer, dst_offset, GL_FALSE,
-                            0, 0, 0, 0, width, height,
+                            dst_stride, dst_buffer, 0, GL_FALSE,
+                            0, 0, dst_x, dst_y, width, height,
                             GL_COPY)) {
-        UNLOCK_HARDWARE(intel);
         return GL_FALSE;
       }
    }
-   UNLOCK_HARDWARE(intel);
 
    return GL_TRUE;
 }
@@ -258,7 +262,7 @@ try_pbo_zcopy(struct intel_context *intel,
 {
    struct intel_buffer_object *pbo = intel_buffer_object(unpack->BufferObj);
    GLuint src_offset, src_stride;
-   GLuint dst_offset, dst_stride;
+   GLuint dst_x, dst_y, dst_stride;
 
    if (!_mesa_is_bufferobj(unpack->BufferObj) ||
        intel->ctx._ImageTransferState ||
@@ -275,13 +279,14 @@ try_pbo_zcopy(struct intel_context *intel,
    else
       src_stride = width;
 
-   dst_offset = intel_miptree_image_offset(intelImage->mt,
-                                           intelImage->face,
-                                           intelImage->level);
+   intel_miptree_get_image_offset(intelImage->mt, intelImage->level,
+                                 intelImage->face, 0,
+                                 &dst_x, &dst_y);
 
    dst_stride = intelImage->mt->pitch;
 
-   if (src_stride != dst_stride || dst_offset != 0 || src_offset != 0) {
+   if (src_stride != dst_stride || dst_x != 0 || dst_y != 0 ||
+       src_offset != 0) {
       DBG("%s: failure 2\n", __FUNCTION__);
       return GL_FALSE;
    }
@@ -316,8 +321,6 @@ intelTexImage(GLcontext * ctx,
    DBG("%s target %s level %d %dx%dx%d border %d\n", __FUNCTION__,
        _mesa_lookup_enum_by_nr(target), level, width, height, depth, border);
 
-   intelFlush(ctx);
-
    intelImage->face = target_to_face(target);
    intelImage->level = level;
 
@@ -326,22 +329,11 @@ intelTexImage(GLcontext * ctx,
                                          &postConvHeight);
    }
 
-   /* choose the texture format */
-   texImage->TexFormat = intelChooseTextureFormat(ctx, internalFormat,
-                                                  format, type);
-
-   _mesa_set_fetch_functions(texImage, dims);
-
-   if (texImage->TexFormat->TexelBytes == 0) {
-      /* must be a compressed format */
+   if (_mesa_is_format_compressed(texImage->TexFormat)) {
       texelBytes = 0;
-      texImage->IsCompressed = GL_TRUE;
-      texImage->CompressedSize =
-        ctx->Driver.CompressedTextureSize(ctx, texImage->Width,
-                                          texImage->Height, texImage->Depth,
-                                          texImage->TexFormat->MesaFormat);
-   } else {
-      texelBytes = texImage->TexFormat->TexelBytes;
+   }
+   else {
+      texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
       
       /* Minimum pitch of 32 bytes */
       if (postConvWidth * texelBytes < 32) {
@@ -374,8 +366,7 @@ intelTexImage(GLcontext * ctx,
        intelObj->mt->first_level == level &&
        intelObj->mt->last_level == level &&
        intelObj->mt->target != GL_TEXTURE_CUBE_MAP_ARB &&
-       !intel_miptree_match_image(intelObj->mt, &intelImage->base,
-                                  intelImage->face, intelImage->level)) {
+       !intel_miptree_match_image(intelObj->mt, &intelImage->base)) {
 
       DBG("release it\n");
       intel_miptree_release(intel, &intelObj->mt);
@@ -392,17 +383,17 @@ intelTexImage(GLcontext * ctx,
    assert(!intelImage->mt);
 
    if (intelObj->mt &&
-       intel_miptree_match_image(intelObj->mt, &intelImage->base,
-                                 intelImage->face, intelImage->level)) {
+       intel_miptree_match_image(intelObj->mt, &intelImage->base)) {
 
       intel_miptree_reference(&intelImage->mt, intelObj->mt);
       assert(intelImage->mt);
    } else if (intelImage->base.Border == 0) {
       int comp_byte = 0;
-
-      if (intelImage->base.IsCompressed) {
+      GLuint texelBytes = _mesa_get_format_bytes(intelImage->base.TexFormat);
+      GLenum baseFormat = _mesa_get_format_base_format(intelImage->base.TexFormat);
+      if (_mesa_is_format_compressed(intelImage->base.TexFormat)) {
         comp_byte =
-           intel_compressed_num_bytes(intelImage->base.TexFormat->MesaFormat);
+           intel_compressed_num_bytes(intelImage->base.TexFormat);
       }
 
       /* Didn't fit in the object miptree, but it's suitable for inclusion in
@@ -410,11 +401,11 @@ intelTexImage(GLcontext * ctx,
        * It'll get moved into the object miptree at validate time.
        */
       intelImage->mt = intel_miptree_create(intel, target,
-                                           intelImage->base.TexFormat->BaseFormat,
+                                           baseFormat,
                                            internalFormat,
                                            level, level,
                                            width, height, depth,
-                                           intelImage->base.TexFormat->TexelBytes,
+                                           texelBytes,
                                            comp_byte, pixels == NULL);
 
    }
@@ -475,24 +466,32 @@ intelTexImage(GLcontext * ctx,
                                           pixels, unpack, "glTexImage");
    }
 
-   LOCK_HARDWARE(intel);
-
    if (intelImage->mt) {
-      if (pixels != NULL)
+      if (pixels != NULL) {
+        /* Flush any queued rendering with the texture before mapping. */
+        if (drm_intel_bo_references(intel->batch->buf,
+                                    intelImage->mt->region->buffer)) {
+           intelFlush(ctx);
+        }
          texImage->Data = intel_miptree_image_map(intel,
                                                   intelImage->mt,
                                                   intelImage->face,
                                                   intelImage->level,
                                                   &dstRowStride,
                                                   intelImage->base.ImageOffsets);
+      }
+
       texImage->RowStride = dstRowStride / intelImage->mt->cpp;
    }
    else {
       /* Allocate regular memory and store the image there temporarily.   */
-      if (texImage->IsCompressed) {
-         sizeInBytes = texImage->CompressedSize;
+      if (_mesa_is_format_compressed(texImage->TexFormat)) {
+         sizeInBytes = _mesa_format_image_size(texImage->TexFormat,
+                                               texImage->Width,
+                                               texImage->Height,
+                                               texImage->Depth);
          dstRowStride =
-            _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat, width);
+            _mesa_format_row_stride(texImage->TexFormat, width);
          assert(dims != 3);
       }
       else {
@@ -523,17 +522,20 @@ intelTexImage(GLcontext * ctx,
                               pixels,
                               srcRowStride,
                               0, 0);
-          } else
+          }
+           else {
               memcpy(texImage->Data, pixels, imageSize);
-       } else if (!texImage->TexFormat->StoreImage(ctx, dims, 
-                                                  texImage->_BaseFormat, 
-                                                  texImage->TexFormat, 
-                                                  texImage->Data, 0, 0, 0, /* dstX/Y/Zoffset */
-                                                  dstRowStride,
-                                                  texImage->ImageOffsets,
-                                                  width, height, depth,
-                                                  format, type, pixels, unpack)) {
-          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
+           }
+       }
+       else if (!_mesa_texstore(ctx, dims, 
+                                texImage->_BaseFormat, 
+                                texImage->TexFormat, 
+                                texImage->Data, 0, 0, 0, /* dstX/Y/Zoffset */
+                                dstRowStride,
+                                texImage->ImageOffsets,
+                                width, height, depth,
+                                format, type, pixels, unpack)) {
+          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
        }
    }
 
@@ -544,8 +546,6 @@ intelTexImage(GLcontext * ctx,
          intel_miptree_image_unmap(intel, intelImage->mt);
       texImage->Data = NULL;
    }
-
-   UNLOCK_HARDWARE(intel);
 }
 
 
@@ -661,9 +661,10 @@ intel_get_tex_image(GLcontext * ctx, GLenum target, GLint level,
    if (compressed) {
       _mesa_get_compressed_teximage(ctx, target, level, pixels,
                                    texObj, texImage);
-   } else {
+   }
+   else {
       _mesa_get_teximage(ctx, target, level, format, type, pixels,
-                        texObj, texImage);
+                         texObj, texImage);
    }
      
 
@@ -724,19 +725,18 @@ intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
                   GLint glx_texture_format,
                   __DRIdrawable *dPriv)
 {
-   struct intel_framebuffer *intel_fb = dPriv->driverPrivate;
+   struct gl_framebuffer *fb = dPriv->driverPrivate;
    struct intel_context *intel = pDRICtx->driverPrivate;
+   GLcontext *ctx = &intel->ctx;
    struct intel_texture_object *intelObj;
    struct intel_texture_image *intelImage;
    struct intel_mipmap_tree *mt;
    struct intel_renderbuffer *rb;
-   struct gl_texture_unit *texUnit;
    struct gl_texture_object *texObj;
    struct gl_texture_image *texImage;
-   int level = 0, type, format, internalFormat;
+   int level = 0, internalFormat;
 
-   texUnit = &intel->ctx.Texture.Unit[intel->ctx.Texture.CurrentUnit];
-   texObj = _mesa_select_tex_object(&intel->ctx, texUnit, target);
+   texObj = _mesa_get_current_tex_object(ctx, target);
    intelObj = intel_texture_object(texObj);
 
    if (!intelObj)
@@ -744,15 +744,13 @@ intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
 
    intel_update_renderbuffers(pDRICtx, dPriv);
 
-   rb = intel_fb->color_rb[0];
+   rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
    /* If the region isn't set, then intel_update_renderbuffers was unable
     * to get the buffers for the drawable.
     */
    if (rb->region == NULL)
       return;
 
-   type = GL_BGRA;
-   format = GL_UNSIGNED_BYTE;
    if (glx_texture_format == GLX_TEXTURE_FORMAT_RGB_EXT)
       internalFormat = GL_RGB;
    else
@@ -783,14 +781,14 @@ intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
 
    intelImage->face = target_to_face(target);
    intelImage->level = level;
-   texImage->TexFormat = intelChooseTextureFormat(&intel->ctx, internalFormat,
-                                                  type, format);
-   _mesa_set_fetch_functions(texImage, 2);
+   if (glx_texture_format == GLX_TEXTURE_FORMAT_RGB_EXT)
+      texImage->TexFormat = MESA_FORMAT_XRGB8888;
+   else
+      texImage->TexFormat = MESA_FORMAT_ARGB8888;
    texImage->RowStride = rb->region->pitch;
    intel_miptree_reference(&intelImage->mt, intelObj->mt);
 
-   if (!intel_miptree_match_image(intelObj->mt, &intelImage->base,
-                                 intelImage->face, intelImage->level)) {
+   if (!intel_miptree_match_image(intelObj->mt, &intelImage->base)) {
           fprintf(stderr, "miptree doesn't match image\n");
    }
 
index c9de9b56784163394e60d523eb5a68d1d5c5f1e0..a9ac9e7eb4894863dbb3e5490d38b7b8a473fb5d 100644 (file)
@@ -33,7 +33,7 @@
 #include "main/macros.h"
 
 
-static GLuint minify( GLuint d )
+static INLINE GLuint minify( GLuint d )
 {
    return MAX2(1, d>>1);
 }
index 5a934615259787fe030f6e53eac47a97e8dcd287..3ad10d3d23890fab81eac1c7e39f91a7600c10f5 100644 (file)
@@ -66,6 +66,7 @@ struct intel_texture_image
     * Else there is no image data.
     */
    struct intel_mipmap_tree *mt;
+   GLboolean used_as_render_target;
 };
 
 static INLINE struct intel_texture_object *
index 751ec2c98c278c50a2a21e98f15a09ed23d66742..7f1dc8902208b55db79e5c37111eb6e5e8735c92 100644 (file)
@@ -72,8 +72,6 @@ intelTexSubimage(GLcontext * ctx,
    if (!pixels)
       return;
 
-   LOCK_HARDWARE(intel);
-
    /* Map buffer if necessary.  Need to lock to prevent other contexts
     * from uploading the buffer under us.
     */
@@ -85,13 +83,13 @@ intelTexSubimage(GLcontext * ctx,
                                                &dstRowStride,
                                                texImage->ImageOffsets);
    else {
-      if (texImage->IsCompressed) {
+      if (_mesa_is_format_compressed(texImage->TexFormat)) {
          dstRowStride =
-            _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat, width);
+            _mesa_format_row_stride(texImage->TexFormat, width);
          assert(dims != 3);
       }
       else {
-         dstRowStride = texImage->RowStride * texImage->TexFormat->TexelBytes;
+         dstRowStride = texImage->RowStride * _mesa_get_format_bytes(texImage->TexFormat);
       }
    }
 
@@ -105,18 +103,20 @@ intelTexSubimage(GLcontext * ctx,
                          xoffset, yoffset / 4,
                          (width + 3)  & ~3, (height + 3) / 4,
                          pixels, (width + 3) & ~3, 0, 0);
-      } else
+      }
+      else {
         memcpy(texImage->Data, pixels, imageSize);
+      }
    }
    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)) {
+      if (!_mesa_texstore(ctx, dims, texImage->_BaseFormat,
+                          texImage->TexFormat,
+                          texImage->Data,
+                          xoffset, yoffset, zoffset,
+                          dstRowStride,
+                          texImage->ImageOffsets,
+                          width, height, depth,
+                          format, type, pixels, packing)) {
          _mesa_error(ctx, GL_OUT_OF_MEMORY, "intelTexSubImage");
       }
    }
@@ -127,8 +127,6 @@ intelTexSubimage(GLcontext * ctx,
       intel_miptree_image_unmap(intel, intelImage->mt);
       texImage->Data = NULL;
    }
-
-   UNLOCK_HARDWARE(intel);
 }
 
 
index a284d5475f4bce9227fa5844954e8b46b2b88406..c9a24ac3983381e38b9abf680e482fdd2d945603 100644 (file)
@@ -5,6 +5,7 @@
 #include "intel_batchbuffer.h"
 #include "intel_mipmap_tree.h"
 #include "intel_tex.h"
+#include "intel_chipset.h"
 
 #define FILE_DEBUG_FLAG DEBUG_TEXTURE
 
@@ -14,7 +15,8 @@
  * GL_TEXTURE_MAX_LOD, GL_TEXTURE_BASE_LEVEL, and GL_TEXTURE_MAX_LEVEL.
  */
 static void
-intel_calculate_first_last_level(struct intel_texture_object *intelObj)
+intel_calculate_first_last_level(struct intel_context *intel,
+                                struct intel_texture_object *intelObj)
 {
    struct gl_texture_object *tObj = &intelObj->base;
    const struct gl_texture_image *const baseImage =
@@ -40,27 +42,27 @@ intel_calculate_first_last_level(struct intel_texture_object *intelObj)
          firstLevel = lastLevel = tObj->BaseLevel;
       }
       else {
-#ifdef I915
-         firstLevel = tObj->BaseLevel + (GLint) (tObj->MinLod + 0.5);
-         firstLevel = MAX2(firstLevel, tObj->BaseLevel);
-         firstLevel = MIN2(firstLevel, tObj->BaseLevel + baseImage->MaxLog2);
-         lastLevel = tObj->BaseLevel + (GLint) (tObj->MaxLod + 0.5);
-         lastLevel = MAX2(lastLevel, tObj->BaseLevel);
-         lastLevel = MIN2(lastLevel, tObj->BaseLevel + baseImage->MaxLog2);
-         lastLevel = MIN2(lastLevel, tObj->MaxLevel);
-         lastLevel = MAX2(firstLevel, lastLevel);       /* need at least one level */
-#else
-        /* Currently not taking min/max lod into account here, those
-         * values are programmed as sampler state elsewhere and we
-         * upload the same mipmap levels regardless.  Not sure if
-         * this makes sense as it means it isn't possible for the app
-         * to use min/max lod to reduce texture memory pressure:
-         */
-        firstLevel = tObj->BaseLevel;
-        lastLevel = MIN2(tObj->BaseLevel + baseImage->MaxLog2,
-                         tObj->MaxLevel);
-        lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */
-#endif
+        if (intel->gen == 2) {
+           firstLevel = tObj->BaseLevel + (GLint) (tObj->MinLod + 0.5);
+           firstLevel = MAX2(firstLevel, tObj->BaseLevel);
+           firstLevel = MIN2(firstLevel, tObj->BaseLevel + baseImage->MaxLog2);
+           lastLevel = tObj->BaseLevel + (GLint) (tObj->MaxLod + 0.5);
+           lastLevel = MAX2(lastLevel, tObj->BaseLevel);
+           lastLevel = MIN2(lastLevel, tObj->BaseLevel + baseImage->MaxLog2);
+           lastLevel = MIN2(lastLevel, tObj->MaxLevel);
+           lastLevel = MAX2(firstLevel, lastLevel);       /* need at least one level */
+        } else {
+           /* Min/max LOD are taken into account in sampler state.  We don't
+            * want to re-layout textures just because clamping has been applied
+            * since it means a bunch of blitting around and probably no memory
+            * savings (since we have to keep the other levels around anyway).
+            */
+           firstLevel = tObj->BaseLevel;
+           lastLevel = MIN2(tObj->BaseLevel + baseImage->MaxLog2,
+                            tObj->MaxLevel);
+           /* need at least one level */
+           lastLevel = MAX2(firstLevel, lastLevel);
+        }
       }
       break;
    case GL_TEXTURE_RECTANGLE_NV:
@@ -135,9 +137,8 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
 
    /* What levels must the tree include at a minimum?
     */
-   intel_calculate_first_last_level(intelObj);
-   firstImage =
-      intel_texture_image(intelObj->base.Image[0][intelObj->firstLevel]);
+   intel_calculate_first_last_level(intel, intelObj);
+   firstImage = intel_texture_image(tObj->Image[0][intelObj->firstLevel]);
 
    /* Fallback case:
     */
@@ -165,11 +166,12 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
       intel_miptree_reference(&intelObj->mt, firstImage->mt);
    }
 
-   if (firstImage->base.IsCompressed) {
-      comp_byte = intel_compressed_num_bytes(firstImage->base.TexFormat->MesaFormat);
+   if (_mesa_is_format_compressed(firstImage->base.TexFormat)) {
+      comp_byte = intel_compressed_num_bytes(firstImage->base.TexFormat);
       cpp = comp_byte;
    }
-   else cpp = firstImage->base.TexFormat->TexelBytes;
+   else
+      cpp = _mesa_get_format_bytes(firstImage->base.TexFormat);
 
    /* Check tree can hold all active levels.  Check tree matches
     * target, imageFormat, etc.
@@ -189,7 +191,7 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
        intelObj->mt->height0 != firstImage->base.Height ||
        intelObj->mt->depth0 != firstImage->base.Depth ||
        intelObj->mt->cpp != cpp ||
-       intelObj->mt->compressed != firstImage->base.IsCompressed)) {
+       intelObj->mt->compressed != _mesa_is_format_compressed(firstImage->base.TexFormat))) {
       intel_miptree_release(intel, &intelObj->mt);
    }
 
@@ -220,8 +222,13 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
             intel_texture_image(intelObj->base.Image[face][i]);
 
          /* Need to import images in main memory or held in other trees.
+         * If it's a render target, then its data isn't needed to be in
+         * the object tree (otherwise we'd be FBO incomplete), and we need
+         * to keep track of the image's MT as needing to be pulled in still,
+         * or we'll lose the rendering that's done to it.
           */
-         if (intelObj->mt != intelImage->mt) {
+         if (intelObj->mt != intelImage->mt &&
+            !intelImage->used_as_render_target) {
             copy_image_data_to_tree(intel, intelObj, intelImage);
          }
       }
index 7246d51f5d784f9a0addfbec00c18b405b0e0a3c..a8f463e9fd09a5a576205cc2547db29222e69bdf 100644 (file)
@@ -30,4 +30,3 @@ ASM_SOURCES =
 
 include ../Makefile.template
 
-symlinks:
index 9c7f513c6f5fc4b3afc7c6c243b9d03882ceb077..3b4ef7ffd82a9dc3b2c44f83932652cd3985e226 100644 (file)
@@ -76,7 +76,7 @@ static const struct dri_debug_control debug_control[] =
     { NULL,    0 }
 };
 
-const struct dri_extension card_extensions[] =
+static const struct dri_extension card_extensions[] =
 {
     { "GL_ARB_multitexture",               NULL },
     { "GL_EXT_texture_edge_clamp",         NULL },
@@ -89,11 +89,11 @@ const struct dri_extension card_extensions[] =
 /* Create the device specific context.
   */
 GLboolean mach64CreateContext( const __GLcontextModes *glVisual,
-                              __DRIcontextPrivate *driContextPriv,
+                              __DRIcontext *driContextPriv,
                                void *sharedContextPrivate )
 {
    GLcontext *ctx, *shareCtx;
-   __DRIscreenPrivate *driScreen = driContextPriv->driScreenPriv;
+   __DRIscreen *driScreen = driContextPriv->driScreenPriv;
    struct dd_function_table functions;
    mach64ContextPtr mmesa;
    mach64ScreenPtr mach64Screen;
@@ -260,7 +260,7 @@ GLboolean mach64CreateContext( const __GLcontextModes *glVisual,
 
 /* Destroy the device specific context.
  */
-void mach64DestroyContext( __DRIcontextPrivate *driContextPriv  )
+void mach64DestroyContext( __DRIcontext *driContextPriv  )
 {
    mach64ContextPtr mmesa = (mach64ContextPtr) driContextPriv->driverPrivate;
 
@@ -307,9 +307,9 @@ void mach64DestroyContext( __DRIcontextPrivate *driContextPriv  )
  * buffer `b'.
  */
 GLboolean
-mach64MakeCurrent( __DRIcontextPrivate *driContextPriv,
-                 __DRIdrawablePrivate *driDrawPriv,
-                 __DRIdrawablePrivate *driReadPriv )
+mach64MakeCurrent( __DRIcontext *driContextPriv,
+                 __DRIdrawable *driDrawPriv,
+                 __DRIdrawable *driReadPriv )
 {
    if ( driContextPriv ) {
       GET_CURRENT_CONTEXT(ctx);
@@ -352,7 +352,7 @@ mach64MakeCurrent( __DRIcontextPrivate *driContextPriv,
 /* Force the context `c' to be unbound from its buffer.
  */
 GLboolean
-mach64UnbindContext( __DRIcontextPrivate *driContextPriv )
+mach64UnbindContext( __DRIcontext *driContextPriv )
 {
    return GL_TRUE;
 }
index 854751626d0241fdbfc395bd00a50acf8fe9877e..18fc859d0132f10a9aae333c0c45617d2a782875 100644 (file)
@@ -232,9 +232,9 @@ struct mach64_context {
 
    /* Mirrors of some DRI state
     */
-   __DRIcontextPrivate *driContext;    /* DRI context */
-   __DRIscreenPrivate  *driScreen;     /* DRI screen */
-   __DRIdrawablePrivate        *driDrawable;   /* DRI drawable bound to this ctx */
+   __DRIcontext        *driContext;    /* DRI context */
+   __DRIscreen *driScreen;     /* DRI screen */
+   __DRIdrawable       *driDrawable;   /* DRI drawable bound to this ctx */
 
    unsigned int lastStamp;             /* mirror driDrawable->lastStamp */
 
@@ -274,16 +274,16 @@ struct mach64_context {
 
 
 extern GLboolean mach64CreateContext( const __GLcontextModes *glVisual,
-                                     __DRIcontextPrivate *driContextPriv,
+                                     __DRIcontext *driContextPriv,
                                       void *sharedContextPrivate );
 
-extern void mach64DestroyContext( __DRIcontextPrivate * );
+extern void mach64DestroyContext( __DRIcontext * );
 
-extern GLboolean mach64MakeCurrent( __DRIcontextPrivate *driContextPriv,
-                                    __DRIdrawablePrivate *driDrawPriv,
-                                    __DRIdrawablePrivate *driReadPriv );
+extern GLboolean mach64MakeCurrent( __DRIcontext *driContextPriv,
+                                    __DRIdrawable *driDrawPriv,
+                                    __DRIdrawable *driReadPriv );
 
-extern GLboolean mach64UnbindContext( __DRIcontextPrivate *driContextPriv );
+extern GLboolean mach64UnbindContext( __DRIcontext *driContextPriv );
 
 /* ================================================================
  * Byte ordering
index ef5c0625c3159683849e8e666c3a00fa5afcaf40..03587c44fdab445a062b78abfb8b32085435a523 100644 (file)
@@ -279,7 +279,7 @@ static int mach64WaitForFrameCompletion( mach64ContextPtr mmesa )
 
 /* Copy the back color buffer to the front color buffer.
  */
-void mach64CopyBuffer( __DRIdrawablePrivate *dPriv )
+void mach64CopyBuffer( __DRIdrawable *dPriv )
 {
    mach64ContextPtr mmesa;
    GLint nbox, i, ret;
@@ -668,7 +668,7 @@ void mach64PerformanceBoxesLocked( mach64ContextPtr mmesa )
 static void mach64DDClear( GLcontext *ctx, GLbitfield mask )
 {
    mach64ContextPtr mmesa = MACH64_CONTEXT( ctx );
-   __DRIdrawablePrivate *dPriv = mmesa->driDrawable;
+   __DRIdrawable *dPriv = mmesa->driDrawable;
    drm_mach64_clear_t clear;
    GLuint flags = 0;
    GLint i;
index 6ef9bc0bcaf2b6b9e2575050f85c05f30a1713cd..1ffda1932f1422ad2ed9b5f2504f946ca94ee243 100644 (file)
@@ -78,7 +78,7 @@ extern void mach64FireBlitLocked( mach64ContextPtr mmesa, void *buffer,
                                  GLint offset, GLint pitch, GLint format,
                                  GLint x, GLint y, GLint width, GLint height );
 
-extern void mach64CopyBuffer( __DRIdrawablePrivate *dPriv );
+extern void mach64CopyBuffer( __DRIdrawable *dPriv );
 #if ENABLE_PERF_BOXES
 extern void mach64PerformanceCounters( mach64ContextPtr mmesa );
 extern void mach64PerformanceBoxesLocked( mach64ContextPtr mmesa );
index d018ba417487c0cfc06abb31259b56a05bfc65d9..8653c77da573ba4b78999570998090fe83455d84 100644 (file)
@@ -51,8 +51,8 @@ int   prevLockLine = 0;
  */
 void mach64GetLock( mach64ContextPtr mmesa, GLuint flags )
 {
-   __DRIdrawablePrivate *dPriv = mmesa->driDrawable;
-   __DRIscreenPrivate *sPriv = mmesa->driScreen;
+   __DRIdrawable *dPriv = mmesa->driDrawable;
+   __DRIscreen *sPriv = mmesa->driScreen;
    drm_mach64_sarea_t *sarea = mmesa->sarea;
    int i;
 
index 99f1a14e171c25ab644df7b099a6389cd4e1e96b..816682ec5f13d3b0f6f2d2fbe3a0d16866cd51d7 100644 (file)
@@ -207,19 +207,19 @@ INTERP_QUALIFIER void TAG(interp_extras)( GLcontext *ctx,
    LOCALVARS
    struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
 
-   if (VB->ColorPtr[1]) {
-      assert(VB->ColorPtr[1]->stride == 4 * sizeof(GLfloat));
+   if (VB->BackfaceColorPtr) {
+      assert(VB->BackfaceColorPtr->stride == 4 * sizeof(GLfloat));
       
       INTERP_4F( t,
-                   GET_COLOR(VB->ColorPtr[1], dst),
-                   GET_COLOR(VB->ColorPtr[1], out),
-                   GET_COLOR(VB->ColorPtr[1], in) );
+                GET_COLOR(VB->BackfaceColorPtr, dst),
+                GET_COLOR(VB->BackfaceColorPtr, out),
+                GET_COLOR(VB->BackfaceColorPtr, in) );
 
-      if (VB->SecondaryColorPtr[1]) {
+      if (VB->BackfaceSecondaryColorPtr) {
         INTERP_3F( t,
-                      GET_COLOR(VB->SecondaryColorPtr[1], dst),
-                      GET_COLOR(VB->SecondaryColorPtr[1], out),
-                      GET_COLOR(VB->SecondaryColorPtr[1], in) );
+                   GET_COLOR(VB->BackfaceSecondaryColorPtr, dst),
+                   GET_COLOR(VB->BackfaceSecondaryColorPtr, out),
+                   GET_COLOR(VB->BackfaceSecondaryColorPtr, in) );
       }
    }
 
@@ -236,13 +236,13 @@ INTERP_QUALIFIER void TAG(copy_pv_extras)( GLcontext *ctx,
    LOCALVARS
       struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
 
-   if (VB->ColorPtr[1]) {
-      COPY_4FV( GET_COLOR(VB->ColorPtr[1], dst), 
-               GET_COLOR(VB->ColorPtr[1], src) );
+   if (VB->BackfaceColorPtr) {
+      COPY_4FV( GET_COLOR(VB->BackfaceColorPtr, dst),
+               GET_COLOR(VB->BackfaceColorPtr, src) );
 
-      if (VB->SecondaryColorPtr[1]) {
-        COPY_4FV( GET_COLOR(VB->SecondaryColorPtr[1], dst), 
-                  GET_COLOR(VB->SecondaryColorPtr[1], src) );
+      if (VB->BackfaceSecondaryColorPtr) {
+        COPY_4FV( GET_COLOR(VB->BackfaceSecondaryColorPtr, dst),
+                  GET_COLOR(VB->BackfaceSecondaryColorPtr, src) );
       }
    }
 
index 684f2acc890849ac4fba0e0ad05927879bc5b7e0..6e5fa3520e111f0eb5b06feb0198117bc570c7ac 100644 (file)
@@ -103,10 +103,10 @@ static void TAG(emit)( GLcontext *ctx,
 #if DO_TEX1
    {
       const GLuint t1 = GET_TEXSOURCE(1);
-      tc1 = VB->TexCoordPtr[t1]->data;
-      tc1_stride = VB->TexCoordPtr[t1]->stride;
+      tc1 = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t1]->data;
+      tc1_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t1]->stride;
 #if DO_PTEX
-      tc1_size = VB->TexCoordPtr[t1]->size;
+      tc1_size = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t1]->size;
 #endif
    }
 #endif
@@ -114,18 +114,18 @@ static void TAG(emit)( GLcontext *ctx,
 #if DO_TEX0
    {
       const GLuint t0 = GET_TEXSOURCE(0);
-      tc0 = VB->TexCoordPtr[t0]->data;
-      tc0_stride = VB->TexCoordPtr[t0]->stride;
+      tc0 = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t0]->data;
+      tc0_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t0]->stride;
 #if DO_PTEX
-      tc0_size = VB->TexCoordPtr[t0]->size;
+      tc0_size = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t0]->size;
 #endif
    }
 #endif
 
 #if DO_SPEC
-   if (VB->SecondaryColorPtr[0]) {
-      spec = VB->SecondaryColorPtr[0]->data;
-      spec_stride = VB->SecondaryColorPtr[0]->stride;
+   if (VB->AttribPtr[_TNL_ATTRIB_COLOR1]) {
+      spec = VB->AttribPtr[_TNL_ATTRIB_COLOR1]->data;
+      spec_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR1]->stride;
    } else {
       spec = (GLfloat (*)[4])ctx->Current.Attrib[VERT_ATTRIB_COLOR1];
       spec_stride = 0;
@@ -133,9 +133,9 @@ static void TAG(emit)( GLcontext *ctx,
 #endif
 
 #if DO_FOG
-   if (VB->FogCoordPtr) {
-      fog = VB->FogCoordPtr->data;
-      fog_stride = VB->FogCoordPtr->stride;
+   if (VB->AttribPtr[_TNL_ATTRIB_FOG]) {
+      fog = VB->AttribPtr[_TNL_ATTRIB_FOG]->data;
+      fog_stride = VB->AttribPtr[_TNL_ATTRIB_FOG]->stride;
    } else {
       static GLfloat tmp[4] = {0, 0, 0, 0};
       fog = &tmp;
@@ -144,8 +144,8 @@ static void TAG(emit)( GLcontext *ctx,
 #endif
 
 #if DO_RGBA
-   col = VB->ColorPtr[0]->data;
-   col_stride = VB->ColorPtr[0]->stride;
+   col = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->data;
+   col_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->stride;
 #endif
 
    coord = VB->NdcPtr->data;
@@ -319,8 +319,8 @@ static GLboolean TAG(check_tex_sizes)( GLcontext *ctx )
 
    /* Force 'missing' texcoords to something valid.
     */
-   if (DO_TEX1 && VB->TexCoordPtr[0] == 0)
-      VB->TexCoordPtr[0] = VB->TexCoordPtr[1];
+   if (DO_TEX1 && VB->AttribPtr[_TNL_ATTRIB_TEX0] == 0)
+      VB->AttribPtr[_TNL_ATTRIB_TEX0] = VB->AttribPtr[_TNL_ATTRIB_TEX1];
 
    if (DO_PTEX)
       return GL_TRUE;
@@ -328,12 +328,12 @@ static GLboolean TAG(check_tex_sizes)( GLcontext *ctx )
    /* No hardware support for projective texture.  Can fake it for
     * TEX0 only.
     */
-   if ((DO_TEX1 && VB->TexCoordPtr[GET_TEXSOURCE(1)]->size == 4)) {
+   if ((DO_TEX1 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + GET_TEXSOURCE(1)]->size == 4)) {
       PTEX_FALLBACK();
       return GL_FALSE;
    }
 
-   if (DO_TEX0 && VB->TexCoordPtr[GET_TEXSOURCE(0)]->size == 4) {
+   if (DO_TEX0 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + GET_TEXSOURCE(0)]->size == 4) {
       if (DO_TEX1) {
         PTEX_FALLBACK();
       }
index 6440027ca4a6f0976c3c0c1c83ca295859e81e59..1ed3b0b70ef4d4fd442cb6f5de4d311ef2603dba 100644 (file)
@@ -67,10 +67,8 @@ static const GLuint __driNConfigOptions = 3;
 static const GLuint __driNConfigOptions = 2;
 #endif
 
-extern const struct dri_extension card_extensions[];
-
 static const __DRIconfig **
-mach64FillInModes( __DRIscreenPrivate *psp,
+mach64FillInModes( __DRIscreen *psp,
                   unsigned pixel_bits, unsigned depth_bits,
                   unsigned stencil_bits, GLboolean have_back_buffer )
 {
@@ -146,7 +144,7 @@ mach64FillInModes( __DRIscreenPrivate *psp,
 /* Create the device specific screen private data struct.
  */
 static mach64ScreenRec *
-mach64CreateScreen( __DRIscreenPrivate *sPriv )
+mach64CreateScreen( __DRIscreen *sPriv )
 {
    mach64ScreenPtr mach64Screen;
    ATIDRIPtr serverInfo = (ATIDRIPtr)sPriv->pDevPriv;
@@ -274,7 +272,7 @@ mach64CreateScreen( __DRIscreenPrivate *sPriv )
 /* Destroy the device specific screen private data struct.
  */
 static void
-mach64DestroyScreen( __DRIscreenPrivate *driScreen )
+mach64DestroyScreen( __DRIscreen *driScreen )
 {
    mach64ScreenRec *mach64Screen = (mach64ScreenRec *) driScreen->private;
 
@@ -301,8 +299,8 @@ mach64DestroyScreen( __DRIscreenPrivate *driScreen )
  * data.
  */
 static GLboolean
-mach64CreateBuffer( __DRIscreenPrivate *driScrnPriv,
-                   __DRIdrawablePrivate *driDrawPriv,
+mach64CreateBuffer( __DRIscreen *driScrnPriv,
+                   __DRIdrawable *driDrawPriv,
                    const __GLcontextModes *mesaVis,
                    GLboolean isPixmap )
 {
@@ -316,7 +314,7 @@ mach64CreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       {
          driRenderbuffer *frontRb
-            = driNewRenderbuffer(GL_RGBA,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888,
                                  NULL,
                                  screen->cpp,
                                  screen->frontOffset, screen->frontPitch,
@@ -327,7 +325,7 @@ mach64CreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->doubleBufferMode) {
          driRenderbuffer *backRb
-            = driNewRenderbuffer(GL_RGBA,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888,
                                  NULL,
                                  screen->cpp,
                                  screen->backOffset, screen->backPitch,
@@ -338,7 +336,7 @@ mach64CreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->depthBits == 16) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT16,
+            = driNewRenderbuffer(MESA_FORMAT_Z16,
                                  NULL, screen->cpp,
                                  screen->depthOffset, screen->depthPitch,
                                  driDrawPriv);
@@ -348,7 +346,7 @@ mach64CreateBuffer( __DRIscreenPrivate *driScrnPriv,
       else if (mesaVis->depthBits == 24) {
          /* XXX I don't think 24-bit Z is supported - so this isn't used */
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT24,
+            = driNewRenderbuffer(MESA_FORMAT_Z24_S8,
                                  NULL,
                                  screen->cpp,
                                  screen->depthOffset, screen->depthPitch,
@@ -372,7 +370,7 @@ mach64CreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
 
 static void
-mach64DestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+mach64DestroyBuffer(__DRIdrawable *driDrawPriv)
 {
    _mesa_reference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)), NULL);
 }
@@ -380,7 +378,7 @@ mach64DestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
 
 /* Copy the back color buffer to the front color buffer */
 static void
-mach64SwapBuffers(__DRIdrawablePrivate *dPriv)
+mach64SwapBuffers(__DRIdrawable *dPriv)
 {
    if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
       mach64ContextPtr mmesa;
@@ -402,7 +400,7 @@ mach64SwapBuffers(__DRIdrawablePrivate *dPriv)
 /* Initialize the driver specific screen private data.
  */
 static GLboolean
-mach64InitDriver( __DRIscreenPrivate *driScreen )
+mach64InitDriver( __DRIscreen *driScreen )
 {
    driScreen->private = (void *) mach64CreateScreen( driScreen );
 
@@ -422,7 +420,7 @@ mach64InitDriver( __DRIscreenPrivate *driScreen )
  * \return the __GLcontextModes supported by this driver
  */
 static const __DRIconfig **
-mach64InitScreen(__DRIscreenPrivate *psp)
+mach64InitScreen(__DRIscreen *psp)
 {
    static const __DRIversion ddx_expected = { 6, 4, 0 };
    static const __DRIversion dri_expected = { 4, 0, 0 };
@@ -436,18 +434,6 @@ mach64InitScreen(__DRIscreenPrivate *psp)
       return NULL;
    }
    
-   /* Calling driInitExtensions here, with a NULL context pointer,
-    * does not actually enable the extensions.  It just makes sure
-    * that all the dispatch offsets for all the extensions that
-    * *might* be enables are known.  This is needed because the
-    * dispatch offsets need to be known when _mesa_context_create is
-    * called, but we can't enable the extensions until we have a
-    * context pointer.
-    *
-    * Hello chicken.  Hello egg.  How are you two today?
-    */
-   driInitExtensions( NULL, card_extensions, GL_FALSE );
-
    if (!mach64InitDriver(psp))
       return NULL;
 
@@ -471,3 +457,9 @@ const struct __DriverAPIRec driDriverAPI = {
    .SwapBuffersMSC  = NULL
 };
 
+/* This is the table of extensions that the loader will dlsym() for. */
+PUBLIC const __DRIextension *__driDriverExtensions[] = {
+    &driCoreExtension.base,
+    &driLegacyExtension.base,
+    NULL
+};
index be5e29a3e58ed6e43cf2da13b936fe4cd946396f..1966809c03ce5291ae94e671274e61db9d3eb76b 100644 (file)
@@ -70,7 +70,7 @@ typedef struct {
 
    drmBufMapPtr buffers;
 
-   __DRIscreenPrivate *driScreen;
+   __DRIscreen *driScreen;
 
    driOptionCache optionCache;
 
index 91d46ce32eb4f76c54170e54b27b4bdd56b8f91c..b4ba2a41c98cc250e1f7f28ecd3c39d211096f36 100644 (file)
@@ -40,8 +40,8 @@
 
 #define LOCAL_VARS                                                     \
    mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);                       \
-   __DRIscreenPrivate *sPriv = mmesa->driScreen;                       \
-   __DRIdrawablePrivate *dPriv = mmesa->driDrawable;                   \
+   __DRIscreen *sPriv = mmesa->driScreen;                      \
+   __DRIdrawable *dPriv = mmesa->driDrawable;                  \
    driRenderbuffer *drb = (driRenderbuffer *) rb;                      \
    GLuint height = dPriv->h;                                           \
    GLushort p;                                                         \
@@ -49,8 +49,8 @@
 
 #define LOCAL_DEPTH_VARS                                               \
    mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);                       \
-   __DRIdrawablePrivate *dPriv = mmesa->driDrawable;                   \
-   __DRIscreenPrivate *driScreen = mmesa->driScreen;                   \
+   __DRIdrawable *dPriv = mmesa->driDrawable;                  \
+   __DRIscreen *driScreen = mmesa->driScreen;                  \
    driRenderbuffer *drb = (driRenderbuffer *) rb;                      \
    GLuint height = dPriv->h;                                           \
    char *buf = (char *)(driScreen->pFB + drb->offset +                 \
@@ -157,15 +157,13 @@ void mach64DDInitSpanFuncs( GLcontext *ctx )
 void
 mach64SetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
 {
-   if (drb->Base.InternalFormat == GL_RGBA) {
-      if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
-         mach64InitPointers_RGB565(&drb->Base);
-      }
-      else {
-         mach64InitPointers_ARGB8888(&drb->Base);
-      }
+   if (drb->Base.Format == MESA_FORMAT_RGB565) {
+      mach64InitPointers_RGB565(&drb->Base);
    }
-   else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+   else if (drb->Base.Format == MESA_FORMAT_ARGB8888) {
+      mach64InitPointers_ARGB8888(&drb->Base);
+   }
+   else if (drb->Base.Format == MESA_FORMAT_Z16) {
       mach64InitDepthPointers_z16(&drb->Base);
    }
 }
index 3a023187ce73f776c1d3b0caec2197c678140753..df7cbc8670e50c4ea7e6f8543d9b89fcd06691e2 100644 (file)
@@ -388,7 +388,7 @@ static void mach64UpdateClipping( GLcontext *ctx )
    mach64ScreenPtr mach64Screen = mmesa->mach64Screen;
 
    if ( mmesa->driDrawable ) {
-      __DRIdrawablePrivate *drawable = mmesa->driDrawable;
+      __DRIdrawable *drawable = mmesa->driDrawable;
       int x1 = 0;
       int y1 = 0;
       int x2 = drawable->w - 1;
@@ -527,10 +527,10 @@ static void mach64UpdateMasks( GLcontext *ctx )
    /* mach64 can't color mask with alpha blending enabled */
    if ( !ctx->Color.BlendEnabled ) {
       mask = mach64PackColor( mmesa->mach64Screen->cpp,
-                             ctx->Color.ColorMask[RCOMP],
-                             ctx->Color.ColorMask[GCOMP],
-                             ctx->Color.ColorMask[BCOMP],
-                             ctx->Color.ColorMask[ACOMP] );
+                             ctx->Color.ColorMask[0][RCOMP],
+                             ctx->Color.ColorMask[0][GCOMP],
+                             ctx->Color.ColorMask[0][BCOMP],
+                             ctx->Color.ColorMask[0][ACOMP] );
    }
 
    if ( mmesa->setup.dp_write_mask != mask ) {
@@ -689,7 +689,7 @@ static void mach64DDLogicOpCode( GLcontext *ctx, GLenum opcode )
 void mach64SetCliprects( GLcontext *ctx, GLenum mode )
 {
    mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
-   __DRIdrawablePrivate *dPriv = mmesa->driDrawable;
+   __DRIdrawable *dPriv = mmesa->driDrawable;
 
    switch ( mode ) {
    case GL_FRONT_LEFT:
index 225d23179e10a029e58e9bb948cea6aa8ed34d9f..6627d3c38a05b82e1261186428a5dbe061c54811 100644 (file)
@@ -41,7 +41,6 @@
 #include "main/simple_list.h"
 #include "main/enums.h"
 #include "main/texstore.h"
-#include "main/texformat.h"
 #include "main/teximage.h"
 #include "main/texobj.h"
 #include "main/imports.h"
@@ -131,14 +130,14 @@ mach64AllocTexObj( struct gl_texture_object *texObj )
 
    mach64SetTexWrap( t, texObj->WrapS, texObj->WrapT );
    mach64SetTexFilter( t, texObj->MinFilter, texObj->MagFilter );
-   mach64SetTexBorderColor( t, texObj->BorderColor );
+   mach64SetTexBorderColor( t, texObj->BorderColor.f );
 
    return t;
 }
 
 
 /* Called by the _mesa_store_teximage[123]d() functions. */
-static const struct gl_texture_format *
+static gl_format
 mach64ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
                           GLenum format, GLenum type )
 {
@@ -167,15 +166,15 @@ mach64ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_RGBA2:
    case GL_COMPRESSED_RGBA:
       if (mmesa->mach64Screen->cpp == 4)
-         return &_mesa_texformat_argb8888;
+         return MESA_FORMAT_ARGB8888;
       else
-         return &_mesa_texformat_argb4444;
+         return MESA_FORMAT_ARGB4444;
 
    case GL_RGB5_A1:
       if (mmesa->mach64Screen->cpp == 4)
-         return &_mesa_texformat_argb8888;
+         return MESA_FORMAT_ARGB8888;
       else
-         return &_mesa_texformat_argb1555;
+         return MESA_FORMAT_ARGB1555;
 
    case GL_RGBA8:
    case GL_RGB10_A2:
@@ -183,9 +182,9 @@ mach64ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_RGBA16:
    case GL_RGBA4:
       if (mmesa->mach64Screen->cpp == 4)
-         return &_mesa_texformat_argb8888;
+         return MESA_FORMAT_ARGB8888;
       else
-         return &_mesa_texformat_argb4444;
+         return MESA_FORMAT_ARGB4444;
 
    case 3:
    case GL_RGB:
@@ -198,9 +197,9 @@ mach64ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_RGB16:
    case GL_COMPRESSED_RGB:
       if (mmesa->mach64Screen->cpp == 4)
-         return &_mesa_texformat_argb8888;
+         return MESA_FORMAT_ARGB8888;
       else
-         return &_mesa_texformat_rgb565;
+         return MESA_FORMAT_RGB565;
 
    case 1:
    case GL_LUMINANCE:
@@ -210,9 +209,9 @@ mach64ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_LUMINANCE16:
    case GL_COMPRESSED_LUMINANCE:
       if (mmesa->mach64Screen->cpp == 4)
-         return &_mesa_texformat_argb8888; /* inefficient but accurate */
+         return MESA_FORMAT_ARGB8888; /* inefficient but accurate */
       else
-         return &_mesa_texformat_argb1555;
+         return MESA_FORMAT_ARGB1555;
 
    case GL_INTENSITY4:
    case GL_INTENSITY:
@@ -221,9 +220,9 @@ mach64ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_INTENSITY16:
    case GL_COMPRESSED_INTENSITY:
       if (mmesa->mach64Screen->cpp == 4)
-         return &_mesa_texformat_argb8888; /* inefficient but accurate */
+         return MESA_FORMAT_ARGB8888; /* inefficient but accurate */
       else
-         return &_mesa_texformat_argb4444;
+         return MESA_FORMAT_ARGB4444;
 
    case GL_COLOR_INDEX:
    case GL_COLOR_INDEX1_EXT:
@@ -232,18 +231,18 @@ mach64ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_COLOR_INDEX8_EXT:
    case GL_COLOR_INDEX12_EXT:
    case GL_COLOR_INDEX16_EXT:
-      return &_mesa_texformat_ci8;
+      return MESA_FORMAT_CI8;
 
    case GL_YCBCR_MESA:
       if (type == GL_UNSIGNED_SHORT_8_8_APPLE ||
           type == GL_UNSIGNED_BYTE)
-         return &_mesa_texformat_ycbcr;
+         return MESA_FORMAT_YCBCR;
       else
-         return &_mesa_texformat_ycbcr_rev;
+         return MESA_FORMAT_YCBCR_REV;
 
    default:
       _mesa_problem( ctx, "unexpected format in %s", __FUNCTION__ );
-      return NULL;
+      return MESA_FORMAT_NONE;
    }
 }
 
@@ -471,7 +470,7 @@ static void mach64DDTexParameter( GLcontext *ctx, GLenum target,
 
    case GL_TEXTURE_BORDER_COLOR:
       if ( t->base.bound ) FLUSH_BATCH( mmesa );
-      mach64SetTexBorderColor( t, tObj->BorderColor );
+      mach64SetTexBorderColor( t, tObj->BorderColor.f );
       break;
 
    case GL_TEXTURE_BASE_LEVEL:
@@ -566,8 +565,6 @@ void mach64InitTextureFuncs( struct dd_function_table *functions )
    functions->IsTextureResident                = driIsTextureResident;
 
    functions->UpdateTexturePalette     = NULL;
-   functions->ActiveTexture            = NULL;
-   functions->PrioritizeTexture                = NULL;
 
    driInitTextureFormats();
 }
index 734e547952ec063aee6734f64328d8acbc015a69..b97e9eec25b3da5437dad8bf754b32cae8ead4b2 100644 (file)
  *   Jose Fonseca <j_r_fonseca@yahoo.co.uk>
  */
 
+#include "main/context.h"
+#include "main/macros.h"
+#include "main/simple_list.h"
+#include "main/imports.h"
+
 #include "mach64_context.h"
 #include "mach64_state.h"
 #include "mach64_ioctl.h"
 #include "mach64_tris.h"
 #include "mach64_tex.h"
 
-#include "main/context.h"
-#include "main/macros.h"
-#include "main/simple_list.h"
-#include "main/texformat.h"
-#include "main/imports.h"
-
 
 /* Destroy hardware state associated with texture `t'.
  */
@@ -76,6 +75,7 @@ static void mach64UploadAGPSubImage( mach64ContextPtr mmesa,
    struct gl_texture_image *image;
    int texelsPerDword = 0;
    int dwords;
+   GLuint texelBytes;
 
    /* Ensure we have a valid texture to upload */
    if ( ( level < 0 ) || ( level > mmesa->glCtx->Const.MaxTextureLevels ) )
@@ -85,7 +85,9 @@ static void mach64UploadAGPSubImage( mach64ContextPtr mmesa,
    if ( !image )
       return;
 
-   switch ( image->TexFormat->TexelBytes ) {
+   texelBytes = _mesa_get_format_bytes(image->TexFormat);
+
+   switch ( texelBytes ) {
    case 1: texelsPerDword = 4; break;
    case 2: texelsPerDword = 2; break;
    case 4: texelsPerDword = 1; break;
@@ -118,8 +120,8 @@ static void mach64UploadAGPSubImage( mach64ContextPtr mmesa,
    {
       CARD32 *dst = (CARD32 *)((char *)mach64Screen->agpTextures.map + t->base.memBlock->ofs);
       const GLubyte *src = (const GLubyte *) image->Data +
-        (y * image->Width + x) * image->TexFormat->TexelBytes;
-      const GLuint bytes = width * height * image->TexFormat->TexelBytes;
+        (y * image->Width + x) * texelBytes;
+      const GLuint bytes = width * height * texelBytes;
       memcpy(dst, src, bytes);
    }
 
@@ -140,6 +142,7 @@ static void mach64UploadLocalSubImage( mach64ContextPtr mmesa,
    const int maxdwords = (MACH64_BUFFER_MAX_DWORDS - (MACH64_HOSTDATA_BLIT_OFFSET / 4));
    CARD32 pitch, offset;
    int i;
+   GLuint texelBytes;
 
    /* Ensure we have a valid texture to upload */
    if ( ( level < 0 ) || ( level > mmesa->glCtx->Const.MaxTextureLevels ) )
@@ -149,7 +152,9 @@ static void mach64UploadLocalSubImage( mach64ContextPtr mmesa,
    if ( !image )
       return;
 
-   switch ( image->TexFormat->TexelBytes ) {
+   texelBytes = _mesa_get_format_bytes(image->TexFormat);
+
+   switch ( texelBytes ) {
    case 1: texelsPerDword = 4; break;
    case 2: texelsPerDword = 2; break;
    case 4: texelsPerDword = 1; break;
@@ -259,7 +264,7 @@ static void mach64UploadLocalSubImage( mach64ContextPtr mmesa,
 
        {
           const GLubyte *src = (const GLubyte *) image->Data +
-             (y * image->Width + x) * image->TexFormat->TexelBytes;
+             (y * image->Width + x) * texelBytes;
 
           mach64FireBlitLocked( mmesa, (void *)src, offset, pitch, format,
                                x, y, width, height );
index fd2369dd882f18cc9fc7783a0f871ec5f1b0a1a7..df0a09a5c12d743ae61c55e44f86f5b34f1e8687 100644 (file)
@@ -33,7 +33,6 @@
 #include "main/imports.h"
 #include "main/context.h"
 #include "main/macros.h"
-#include "main/texformat.h"
 
 #include "mach64_context.h"
 #include "mach64_ioctl.h"
@@ -55,7 +54,7 @@ static void mach64SetTexImages( mach64ContextPtr mmesa,
    if ( MACH64_DEBUG & DEBUG_VERBOSE_API )
       fprintf( stderr, "%s( %p )\n", __FUNCTION__, tObj );
 
-   switch (baseImage->TexFormat->MesaFormat) {
+   switch (baseImage->TexFormat) {
    case MESA_FORMAT_ARGB8888:
       t->textureFormat = MACH64_DATATYPE_ARGB8888;
       break;
@@ -89,7 +88,7 @@ static void mach64SetTexImages( mach64ContextPtr mmesa,
 
    totalSize = ( baseImage->Height *
                 baseImage->Width *
-                baseImage->TexFormat->TexelBytes );
+                _mesa_get_format_bytes(baseImage->TexFormat) );
 
    totalSize = (totalSize + 31) & ~31;
 
index f2e8e2e3ae8c59b4bd9b76dd55c5e0b4bba5d959..c2a0adfef02e0a25d6df2d53a48ea8e2dcbb34b5 100644 (file)
@@ -1297,7 +1297,8 @@ do {                                              \
 
 #define LOCAL_VARS(n)                                          \
    mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);               \
-   GLuint color[n], spec[n];                                   \
+   GLuint color[n] = { 0 };                                    \
+   GLuint spec[n] = { 0 };                                     \
    GLuint vertex_size = mmesa->vertex_size;                    \
    const GLuint xyoffset = 9;                                  \
    const GLuint coloroffset = 8;                               \
index 938804af9ecb97f6a851c7c683f8d2102458443a..60bfab8f6dc7f78c60bc7e810a2f06626a434a9b 100644 (file)
@@ -156,53 +156,53 @@ static void TAG(emit)( GLcontext *ctx,
 
    if (DO_TEX3) {
       const GLuint t3 = GET_TEXSOURCE(3);
-      tc3 = VB->TexCoordPtr[t3]->data;
-      tc3_stride = VB->TexCoordPtr[t3]->stride;
+      tc3 = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t3]->data;
+      tc3_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t3]->stride;
       if (DO_PTEX)
-        tc3_size = VB->TexCoordPtr[t3]->size;
+        tc3_size = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t3]->size;
    }
 
    if (DO_TEX2) {
       const GLuint t2 = GET_TEXSOURCE(2);
-      tc2 = VB->TexCoordPtr[t2]->data;
-      tc2_stride = VB->TexCoordPtr[t2]->stride;
+      tc2 = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t2]->data;
+      tc2_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t2]->stride;
       if (DO_PTEX)
-        tc2_size = VB->TexCoordPtr[t2]->size;
+        tc2_size = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t2]->size;
    }
 
    if (DO_TEX1) {
       const GLuint t1 = GET_TEXSOURCE(1);
-      tc1 = VB->TexCoordPtr[t1]->data;
-      tc1_stride = VB->TexCoordPtr[t1]->stride;
+      tc1 = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t1]->data;
+      tc1_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t1]->stride;
       if (DO_PTEX)
-        tc1_size = VB->TexCoordPtr[t1]->size;
+        tc1_size = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t1]->size;
    }
 
    if (DO_TEX0) {
       const GLuint t0 = GET_TEXSOURCE(0);
-      tc0_stride = VB->TexCoordPtr[t0]->stride;
-      tc0 = VB->TexCoordPtr[t0]->data;
+      tc0_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t0]->stride;
+      tc0 = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t0]->data;
       if (DO_PTEX) 
-        tc0_size = VB->TexCoordPtr[t0]->size;
+        tc0_size = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t0]->size;
    }
 
    if (DO_RGBA) {
-      col = VB->ColorPtr[0]->data;
-      col_stride = VB->ColorPtr[0]->stride;
+      col = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->data;
+      col_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->stride;
    }
 
    if (DO_SPEC) {
-      spec = VB->SecondaryColorPtr[0]->data;
-      spec_stride = VB->SecondaryColorPtr[0]->stride;
+      spec = VB->AttribPtr[_TNL_ATTRIB_COLOR1]->data;
+      spec_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR1]->stride;
    } else {
       spec = (GLfloat (*)[4])ctx->Current.Attrib[VERT_ATTRIB_COLOR1];
       spec_stride = 0;
    }
 
    if (DO_FOG) {
-      if (VB->FogCoordPtr) {
-        fog = VB->FogCoordPtr->data;
-        fog_stride = VB->FogCoordPtr->stride;
+      if (VB->AttribPtr[_TNL_ATTRIB_FOG]) {
+        fog = VB->AttribPtr[_TNL_ATTRIB_FOG]->data;
+        fog_stride = VB->AttribPtr[_TNL_ATTRIB_FOG]->stride;
       } else {
         static GLfloat tmp[4] = {0, 0, 0, 0};
         fog = &tmp;
@@ -384,8 +384,8 @@ static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end,
 
    ASSERT(stride == 4);
 
-   col = VB->ColorPtr[0]->data;
-   col_stride = VB->ColorPtr[0]->stride;
+   col = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->data;
+   col_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->stride;
 
    /* Pack what's left into a 4-dword vertex.  Color is in a different
     * place, and there is no 'w' coordinate.
@@ -432,8 +432,8 @@ static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end,
    GLfloat *v = (GLfloat *)dest;
    int i;
 
-   col = VB->ColorPtr[0]->data;
-   col_stride = VB->ColorPtr[0]->stride;
+   col = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->data;
+   col_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->stride;
 
    if (start)
       STRIDE_4F(col, col_stride * start);
@@ -473,22 +473,22 @@ static GLboolean TAG(check_tex_sizes)( GLcontext *ctx )
 
    /* Force 'missing' texcoords to something valid.
     */
-   if (DO_TEX3 && VB->TexCoordPtr[2] == 0)
-      VB->TexCoordPtr[2] = VB->TexCoordPtr[3];
+   if (DO_TEX3 && VB->AttribPtr[_TNL_ATTRIB_TEX2] == 0)
+      VB->AttribPtr[_TNL_ATTRIB_TEX2] = VB->AttribPtr[_TNL_ATTRIB_TEX3];
 
-   if (DO_TEX2 && VB->TexCoordPtr[1] == 0)
-      VB->TexCoordPtr[1] = VB->TexCoordPtr[2];
+   if (DO_TEX2 && VB->AttribPtr[_TNL_ATTRIB_TEX1] == 0)
+      VB->AttribPtr[_TNL_ATTRIB_TEX1] = VB->AttribPtr[_TNL_ATTRIB_TEX2];
 
-   if (DO_TEX1 && VB->TexCoordPtr[0] == 0)
-      VB->TexCoordPtr[0] = VB->TexCoordPtr[1];
+   if (DO_TEX1 && VB->AttribPtr[_TNL_ATTRIB_TEX0] == 0)
+      VB->AttribPtr[_TNL_ATTRIB_TEX0] = VB->AttribPtr[_TNL_ATTRIB_TEX1];
 
    if (DO_PTEX)
       return GL_TRUE;
    
-   if ((DO_TEX3 && VB->TexCoordPtr[GET_TEXSOURCE(3)]->size == 4) ||
-       (DO_TEX2 && VB->TexCoordPtr[GET_TEXSOURCE(2)]->size == 4) ||
-       (DO_TEX1 && VB->TexCoordPtr[GET_TEXSOURCE(1)]->size == 4) ||
-       (DO_TEX0 && VB->TexCoordPtr[GET_TEXSOURCE(0)]->size == 4))
+   if ((DO_TEX3 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + GET_TEXSOURCE(3)]->size == 4) ||
+       (DO_TEX2 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + GET_TEXSOURCE(2)]->size == 4) ||
+       (DO_TEX1 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + GET_TEXSOURCE(1)]->size == 4) ||
+       (DO_TEX0 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + GET_TEXSOURCE(0)]->size == 4))
       return GL_FALSE;
 
    return GL_TRUE;
@@ -501,14 +501,14 @@ static GLboolean TAG(check_tex_sizes)( GLcontext *ctx )
 
    /* Force 'missing' texcoords to something valid.
     */
-   if (DO_TEX3 && VB->TexCoordPtr[2] == 0)
-      VB->TexCoordPtr[2] = VB->TexCoordPtr[3];
+   if (DO_TEX3 && VB->AttribPtr[_TNL_ATTRIB_TEX2] == 0)
+      VB->AttribPtr[_TNL_ATTRIB_TEX2] = VB->AttribPtr[_TNL_ATTRIB_TEX3];
 
-   if (DO_TEX2 && VB->TexCoordPtr[1] == 0)
-      VB->TexCoordPtr[1] = VB->TexCoordPtr[2];
+   if (DO_TEX2 && VB->AttribPtr[_TNL_ATTRIB_TEX1] == 0)
+      VB->AttribPtr[_TNL_ATTRIB_TEX1] = VB->AttribPtr[_TNL_ATTRIB_TEX2];
 
-   if (DO_TEX1 && VB->TexCoordPtr[0] == 0)
-      VB->TexCoordPtr[0] = VB->TexCoordPtr[1];
+   if (DO_TEX1 && VB->AttribPtr[_TNL_ATTRIB_TEX0] == 0)
+      VB->AttribPtr[_TNL_ATTRIB_TEX0] = VB->AttribPtr[_TNL_ATTRIB_TEX1];
 
    if (DO_PTEX)
       return GL_TRUE;
@@ -516,14 +516,14 @@ static GLboolean TAG(check_tex_sizes)( GLcontext *ctx )
    /* No hardware support for projective texture.  Can fake it for
     * TEX0 only.
     */
-   if ((DO_TEX3 && VB->TexCoordPtr[GET_TEXSOURCE(3)]->size == 4) ||
-       (DO_TEX2 && VB->TexCoordPtr[GET_TEXSOURCE(2)]->size == 4) ||
-       (DO_TEX1 && VB->TexCoordPtr[GET_TEXSOURCE(1)]->size == 4)) {
+   if ((DO_TEX3 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + GET_TEXSOURCE(3)]->size == 4) ||
+       (DO_TEX2 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + GET_TEXSOURCE(2)]->size == 4) ||
+       (DO_TEX1 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + GET_TEXSOURCE(1)]->size == 4)) {
       PTEX_FALLBACK();
       return GL_FALSE;
    }
 
-   if (DO_TEX0 && VB->TexCoordPtr[GET_TEXSOURCE(0)]->size == 4) {
+   if (DO_TEX0 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + GET_TEXSOURCE(0)]->size == 4) {
       if (DO_TEX1 || DO_TEX2 || DO_TEX3) {
         PTEX_FALLBACK();
       }
index a871064c629042ccba4ef743b38a1d52d84c7fad..0cc329fb22db18f282497da04d3a724a6929cd61 100644 (file)
@@ -31,4 +31,3 @@ ASM_SOURCES =
 
 include ../Makefile.template
 
-symlinks:
index ad765d1dd76f5ae29d80220b2a1b7ab6e0bd8bce..54eda62a96a58b717ecc41e0f10b16f63e1fdacc 100644 (file)
  *    Keith Whitwell <keithw@tungstengraphics.com>
  */
 
-#include <stdlib.h>
+#include "main/context.h"
+#include "main/enums.h"
+#include "main/macros.h"
 #include "main/mm.h"
+#include "main/imports.h"
+#include "main/simple_list.h"
+
 #include "mgacontext.h"
 #include "mgatex.h"
 #include "mgaregs.h"
 #include "mgatris.h"
 #include "mgaioctl.h"
 
-#include "main/context.h"
-#include "main/enums.h"
-#include "main/macros.h"
-#include "main/imports.h"
-
-#include "main/simple_list.h"
-#include "main/texformat.h"
-
 #define MGA_USE_TABLE_FOR_FORMAT
 #ifdef MGA_USE_TABLE_FOR_FORMAT
 #define TMC_nr_tformat (MESA_FORMAT_YCBCR_REV + 1)
@@ -94,14 +91,14 @@ mgaSetTexImages( mgaContextPtr mmesa,
        return;
     }
 #else
-    if ( (baseImage->TexFormat->MesaFormat >= TMC_nr_tformat)
-        || (TMC_tformat[ baseImage->TexFormat->MesaFormat ] == 0) )
+    if ( (baseImage->TexFormat >= TMC_nr_tformat)
+        || (TMC_tformat[ baseImage->TexFormat ] == 0) )
     {
        _mesa_problem(NULL, "unexpected texture format in %s", __FUNCTION__);
        return;
     }
 
-    txformat = TMC_tformat[ baseImage->TexFormat->MesaFormat ];
+    txformat = TMC_tformat[ baseImage->TexFormat ];
 
 #endif /* MGA_USE_TABLE_FOR_FORMAT */
 
@@ -131,7 +128,7 @@ mgaSetTexImages( mgaContextPtr mmesa,
         break;
 
       size = texImage->Width * texImage->Height *
-         baseImage->TexFormat->TexelBytes;
+         _mesa_get_format_bytes(baseImage->TexFormat);
 
       t->offsets[i] = totalSize;
       t->base.dirty_images[0] |= (1<<i);
index 0dc76fea50a490ad6a850c17f09940250b3c591d..f835cb8bd6bf137850120d9465b3ecc2f12c35e3 100644 (file)
@@ -78,7 +78,7 @@
 #endif
 #define need_GL_APPLE_vertex_array_object
 #define need_GL_NV_vertex_program
-#include "extension_helper.h"
+#include "main/remap_helper.h"
 
 /* MGA configuration
  */
@@ -108,7 +108,7 @@ int MGA_DEBUG = 0;
 #endif
 
 static const __DRIconfig **
-mgaFillInModes( __DRIscreenPrivate *psp,
+mgaFillInModes( __DRIscreen *psp,
                unsigned pixel_bits, unsigned depth_bits,
                unsigned stencil_bits, GLboolean have_back_buffer )
 {
@@ -190,7 +190,7 @@ const __DRIextension *mgaScreenExtensions[] = {
 };
 
 static GLboolean
-mgaInitDriver(__DRIscreenPrivate *sPriv)
+mgaInitDriver(__DRIscreen *sPriv)
 {
    mgaScreenPrivate *mgaScreen;
    MGADRIPtr         serverInfo = (MGADRIPtr)sPriv->pDevPriv;
@@ -332,7 +332,7 @@ mgaInitDriver(__DRIscreenPrivate *sPriv)
 
 
 static void
-mgaDestroyScreen(__DRIscreenPrivate *sPriv)
+mgaDestroyScreen(__DRIscreen *sPriv)
 {
    mgaScreenPrivate *mgaScreen = (mgaScreenPrivate *) sPriv->private;
 
@@ -426,14 +426,14 @@ static const struct dri_debug_control debug_control[] =
 
 static GLboolean
 mgaCreateContext( const __GLcontextModes *mesaVis,
-                  __DRIcontextPrivate *driContextPriv,
+                  __DRIcontext *driContextPriv,
                   void *sharedContextPrivate )
 {
    int i;
    unsigned   maxlevels;
    GLcontext *ctx, *shareCtx;
    mgaContextPtr mmesa;
-   __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+   __DRIscreen *sPriv = driContextPriv->driScreenPriv;
    mgaScreenPrivate *mgaScreen = (mgaScreenPrivate *)sPriv->private;
    drm_mga_sarea_t *saPriv = (drm_mga_sarea_t *)(((char*)sPriv->pSAREA)+
                                              mgaScreen->sarea_priv_offset);
@@ -645,7 +645,7 @@ mgaCreateContext( const __GLcontextModes *mesaVis,
 }
 
 static void
-mgaDestroyContext(__DRIcontextPrivate *driContextPriv)
+mgaDestroyContext(__DRIcontext *driContextPriv)
 {
    mgaContextPtr mmesa = (mgaContextPtr) driContextPriv->driverPrivate;
 
@@ -697,8 +697,8 @@ mgaDestroyContext(__DRIcontextPrivate *driContextPriv)
 
 
 static GLboolean
-mgaCreateBuffer( __DRIscreenPrivate *driScrnPriv,
-                 __DRIdrawablePrivate *driDrawPriv,
+mgaCreateBuffer( __DRIscreen *driScrnPriv,
+                 __DRIdrawable *driDrawPriv,
                  const __GLcontextModes *mesaVis,
                  GLboolean isPixmap )
 {
@@ -723,7 +723,7 @@ mgaCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       {
          driRenderbuffer *frontRb
-            = driNewRenderbuffer(GL_RGBA,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888,
                                  NULL,
                                  screen->cpp,
                                  screen->frontOffset, screen->frontPitch,
@@ -734,7 +734,7 @@ mgaCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->doubleBufferMode) {
          driRenderbuffer *backRb
-            = driNewRenderbuffer(GL_RGBA,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888,
                                  NULL,
                                  screen->cpp,
                                  screen->backOffset, screen->backPitch,
@@ -745,7 +745,7 @@ mgaCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->depthBits == 16) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT16,
+            = driNewRenderbuffer(MESA_FORMAT_Z16,
                                  NULL,
                                  screen->cpp,
                                  screen->depthOffset, screen->depthPitch,
@@ -757,7 +757,7 @@ mgaCreateBuffer( __DRIscreenPrivate *driScrnPriv,
          /* XXX is this right? */
          if (mesaVis->stencilBits) {
             driRenderbuffer *depthRb
-               = driNewRenderbuffer(GL_DEPTH_COMPONENT24,
+               = driNewRenderbuffer(MESA_FORMAT_Z24_S8,
                                     NULL,
                                     screen->cpp,
                                     screen->depthOffset, screen->depthPitch,
@@ -767,7 +767,7 @@ mgaCreateBuffer( __DRIscreenPrivate *driScrnPriv,
          }
          else {
             driRenderbuffer *depthRb
-               = driNewRenderbuffer(GL_DEPTH_COMPONENT32,
+               = driNewRenderbuffer(MESA_FORMAT_Z32,
                                     NULL,
                                     screen->cpp,
                                     screen->depthOffset, screen->depthPitch,
@@ -778,7 +778,7 @@ mgaCreateBuffer( __DRIscreenPrivate *driScrnPriv,
       }
       else if (mesaVis->depthBits == 32) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT32,
+            = driNewRenderbuffer(MESA_FORMAT_Z32,
                                  NULL,
                                  screen->cpp,
                                  screen->depthOffset, screen->depthPitch,
@@ -789,7 +789,7 @@ mgaCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->stencilBits > 0 && !swStencil) {
          driRenderbuffer *stencilRb
-            = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT,
+            = driNewRenderbuffer(MESA_FORMAT_S8,
                                  NULL,
                                  screen->cpp,
                                  screen->depthOffset, screen->depthPitch,
@@ -814,13 +814,13 @@ mgaCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
 
 static void
-mgaDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+mgaDestroyBuffer(__DRIdrawable *driDrawPriv)
 {
    _mesa_reference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)), NULL);
 }
 
 static void
-mgaSwapBuffers(__DRIdrawablePrivate *dPriv)
+mgaSwapBuffers(__DRIdrawable *dPriv)
 {
    if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
       mgaContextPtr mmesa;
@@ -839,7 +839,7 @@ mgaSwapBuffers(__DRIdrawablePrivate *dPriv)
 }
 
 static GLboolean
-mgaUnbindContext(__DRIcontextPrivate *driContextPriv)
+mgaUnbindContext(__DRIcontext *driContextPriv)
 {
    mgaContextPtr mmesa = (mgaContextPtr) driContextPriv->driverPrivate;
    if (mmesa)
@@ -855,9 +855,9 @@ mgaUnbindContext(__DRIcontextPrivate *driContextPriv)
  * But why are we doing context initialization here???
  */
 static GLboolean
-mgaMakeCurrent(__DRIcontextPrivate *driContextPriv,
-               __DRIdrawablePrivate *driDrawPriv,
-               __DRIdrawablePrivate *driReadPriv)
+mgaMakeCurrent(__DRIcontext *driContextPriv,
+               __DRIdrawable *driDrawPriv,
+               __DRIdrawable *driReadPriv)
 {
    if (driContextPriv) {
       mgaContextPtr mmesa = (mgaContextPtr) driContextPriv->driverPrivate;
@@ -892,7 +892,7 @@ mgaMakeCurrent(__DRIcontextPrivate *driContextPriv,
 
 void mgaGetLock( mgaContextPtr mmesa, GLuint flags )
 {
-   __DRIdrawablePrivate *dPriv = mmesa->driDrawable;
+   __DRIdrawable *dPriv = mmesa->driDrawable;
    drm_mga_sarea_t *sarea = mmesa->sarea;
    int me = mmesa->hHWContext;
    int i;
@@ -945,22 +945,6 @@ static const __DRIconfig **mgaInitScreen(__DRIscreen *psp)
       return NULL;
 
 
-   /* Calling driInitExtensions here, with a NULL context pointer,
-    * does not actually enable the extensions.  It just makes sure
-    * that all the dispatch offsets for all the extensions that
-    * *might* be enables are known.  This is needed because the
-    * dispatch offsets need to be known when _mesa_context_create is
-    * called, but we can't enable the extensions until we have a
-    * context pointer.
-    *
-    * Hello chicken.  Hello egg.  How are you two today?
-    */
-
-   driInitExtensions( NULL, card_extensions, GL_FALSE );
-   driInitExtensions( NULL, g400_extensions, GL_FALSE );
-   driInitExtensions(NULL, ARB_vp_extensions, GL_FALSE);
-   driInitExtensions( NULL, NV_vp_extensions, GL_FALSE );
-
    if (!mgaInitDriver(psp))
        return NULL;
 
@@ -976,7 +960,7 @@ static const __DRIconfig **mgaInitScreen(__DRIscreen *psp)
  * Get information about previous buffer swaps.
  */
 static int
-getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo )
+getSwapInfo( __DRIdrawable *dPriv, __DRIswapInfo * sInfo )
 {
    mgaContextPtr  mmesa;
 
@@ -1014,3 +998,10 @@ const struct __DriverAPIRec driDriverAPI = {
    .WaitForSBC      = NULL,
    .SwapBuffersMSC  = NULL
 };
+
+/* This is the table of extensions that the loader will dlsym() for. */
+PUBLIC const __DRIextension *__driDriverExtensions[] = {
+    &driCoreExtension.base,
+    &driLegacyExtension.base,
+    NULL
+};
index 07c22bd596624757ab4f8f3de3dda804942d7ab4..aee146090c0abc58b3196007e8ba5585993c6fff 100644 (file)
@@ -67,7 +67,7 @@ typedef struct mga_screen_private_s {
    char *texVirtual[MGA_NR_TEX_HEAPS];
 
 
-   __DRIscreenPrivate *sPriv;
+   __DRIscreen *sPriv;
    drmBufMapPtr  bufs;
 
    drmRegion mmio;
index 30640a29b35f7f43b371eb58b581df6e0b6e505e..414156593143fbc9522e1b0c4f00c909157ebafe 100644 (file)
@@ -294,10 +294,10 @@ struct mga_context_t {
    drm_context_t hHWContext;
    drm_hw_lock_t *driHwLock;
    int driFd;
-   __DRIdrawablePrivate *driDrawable;
-   __DRIdrawablePrivate *driReadable;
+   __DRIdrawable *driDrawable;
+   __DRIdrawable *driReadable;
 
-   __DRIscreenPrivate *driScreen;
+   __DRIscreen *driScreen;
    struct mga_screen_private_s *mgaScreen;
    drm_mga_sarea_t *sarea;
 
index 4438bad920972a526ea3a7e3c677220561fb3453..8ce5d802ab83008a867eeae8e0b7738d7eefc1d2 100644 (file)
@@ -207,7 +207,7 @@ static void
 mgaClear( GLcontext *ctx, GLbitfield mask )
 {
    mgaContextPtr mmesa = MGA_CONTEXT(ctx);
-   __DRIdrawablePrivate *dPriv = mmesa->driDrawable;
+   __DRIdrawable *dPriv = mmesa->driDrawable;
    GLuint flags = 0;
    GLuint clear_color = mmesa->ClearColor;
    GLuint clear_depth = 0;
@@ -409,7 +409,7 @@ static void mgaWaitForFrameCompletion( mgaContextPtr mmesa )
 /*
  * Copy the back buffer to the front buffer.
  */
-void mgaCopyBuffer( __DRIdrawablePrivate *dPriv )
+void mgaCopyBuffer( __DRIdrawable *dPriv )
 {
    mgaContextPtr mmesa;
    drm_clip_rect_t *pbox;
@@ -417,7 +417,7 @@ void mgaCopyBuffer( __DRIdrawablePrivate *dPriv )
    GLint ret;
    GLint i;
    GLboolean   missed_target;
-   __DRIscreenPrivate *psp = dPriv->driScreenPriv;
+   __DRIscreen *psp = dPriv->driScreenPriv;
 
    assert(dPriv);
    assert(dPriv->driContextPriv);
index dbc823de80203e325f134bb6c83ac017d05066d1..7a8660d2035105040dddfb5cc4983f3702176a62 100644 (file)
@@ -32,7 +32,7 @@
 #include "mgacontext.h"
 #include "mga_xmesa.h"
 
-void mgaCopyBuffer( __DRIdrawablePrivate *dPriv );
+void mgaCopyBuffer( __DRIdrawable *dPriv );
 void mgaWaitForVBlank( mgaContextPtr mmesa );
 
 void mgaGetILoadBufferLocked( mgaContextPtr mmesa );
index 977dfa0b760dfac393321e76f6b21e7671a18157..69415f8a839e36d8d0e121663676fd443b66d4f2 100644 (file)
@@ -134,10 +134,10 @@ check_color_per_fragment_ops( const GLcontext *ctx )
                    ctx->Fog.Enabled ||
                    ctx->Scissor.Enabled ||
                    ctx->Stencil._Enabled ||
-                   !ctx->Color.ColorMask[0] ||
-                   !ctx->Color.ColorMask[1] ||
-                   !ctx->Color.ColorMask[2] ||
-                   !ctx->Color.ColorMask[3] ||
+                   !ctx->Color.ColorMask[0][0] ||
+                   !ctx->Color.ColorMask[0][1] ||
+                   !ctx->Color.ColorMask[0][2] ||
+                   !ctx->Color.ColorMask[0][3] ||
                    ctx->Color.ColorLogicOpEnabled ||
                    ctx->Texture._EnabledUnits
            ) &&
@@ -150,10 +150,10 @@ static GLboolean
 check_depth_per_fragment_ops( const GLcontext *ctx )
 {
    return ( ctx->Current.RasterPosValid &&
-           ctx->Color.ColorMask[RCOMP] == 0 &&
-           ctx->Color.ColorMask[BCOMP] == 0 &&
-           ctx->Color.ColorMask[GCOMP] == 0 &&
-           ctx->Color.ColorMask[ACOMP] == 0 &&
+           ctx->Color.ColorMask[0][RCOMP] == 0 &&
+           ctx->Color.ColorMask[0][BCOMP] == 0 &&
+           ctx->Color.ColorMask[0][GCOMP] == 0 &&
+           ctx->Color.ColorMask[0][ACOMP] == 0 &&
            ctx->Pixel.ZoomX == 1.0F &&
            ( ctx->Pixel.ZoomY == 1.0F || ctx->Pixel.ZoomY == -1.0F ) );
 }
@@ -299,7 +299,7 @@ mgaTryReadPixels( GLcontext *ctx,
 
 #if 0
    {
-      __DRIdrawablePrivate *dPriv = mmesa->driDrawable;
+      __DRIdrawable *dPriv = mmesa->driDrawable;
       int nbox, retcode, i;
 
       UPDATE_LOCK( mmesa, DRM_LOCK_FLUSH | DRM_LOCK_QUIESCENT );
@@ -399,7 +399,7 @@ static void do_draw_pix( GLcontext *ctx,
 #if 0
    mgaContextPtr mmesa = MGA_CONTEXT(ctx);
    drmMGABlit blit;
-   __DRIdrawablePrivate *dPriv = mmesa->driDrawable;
+   __DRIdrawable *dPriv = mmesa->driDrawable;
    drm_clip_rect_t pbox = dPriv->pClipRects;
    int nbox = dPriv->numClipRects;
    int retcode, i;
@@ -525,10 +525,10 @@ mgaTryDrawPixels( GLcontext *ctx,
              mmesa->mgaScreen->backOffset);
 
       planemask = mgaPackColor(cpp,
-                              ctx->Color.ColorMask[RCOMP],
-                              ctx->Color.ColorMask[GCOMP],
-                              ctx->Color.ColorMask[BCOMP],
-                              ctx->Color.ColorMask[ACOMP]);
+                              ctx->Color.ColorMask[0][RCOMP],
+                              ctx->Color.ColorMask[0][GCOMP],
+                              ctx->Color.ColorMask[0][BCOMP],
+                              ctx->Color.ColorMask[0][ACOMP]);
 
       if (cpp == 2)
         planemask |= planemask << 16;
index 5b6d323ca98de16325a321ac9cace926fe570564..10606c152c3afc0b268e8f68d42c1d2477305b00 100644 (file)
@@ -36,9 +36,9 @@
 
 #define LOCAL_VARS                                     \
    mgaContextPtr mmesa = MGA_CONTEXT(ctx);             \
-   __DRIscreenPrivate *sPriv = mmesa->driScreen;       \
+   __DRIscreen *sPriv = mmesa->driScreen;      \
    driRenderbuffer *drb = (driRenderbuffer *) rb;      \
-   const __DRIdrawablePrivate *dPriv = drb->dPriv;     \
+   const __DRIdrawable *dPriv = drb->dPriv;    \
    GLuint pitch = drb->pitch;                          \
    GLuint height = dPriv->h;                           \
    char *buf = (char *)(sPriv->pFB +                   \
@@ -52,9 +52,9 @@
 
 #define LOCAL_DEPTH_VARS                                               \
    mgaContextPtr mmesa = MGA_CONTEXT(ctx);                             \
-   __DRIscreenPrivate *sPriv = mmesa->driScreen;                       \
+   __DRIscreen *sPriv = mmesa->driScreen;                      \
    driRenderbuffer *drb = (driRenderbuffer *) rb;                      \
-   const __DRIdrawablePrivate *dPriv = drb->dPriv;                     \
+   const __DRIdrawable *dPriv = drb->dPriv;                    \
    GLuint pitch = drb->pitch;                                          \
    GLuint height = dPriv->h;                                           \
    char *buf = (char *)(sPriv->pFB +                                   \
@@ -206,24 +206,22 @@ void mgaDDInitSpanFuncs( GLcontext *ctx )
 void
 mgaSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
 {
-   if (drb->Base.InternalFormat == GL_RGBA) {
-      if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
-         mgaInitPointers_565(&drb->Base);
-      }
-      else {
-         mgaInitPointers_8888(&drb->Base);
-      }
+   if (drb->Base.Format == MESA_FORMAT_RGB565) {
+      mgaInitPointers_565(&drb->Base);
    }
-   else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+   else if (drb->Base.Format == MESA_FORMAT_ARGB8888) {
+      mgaInitPointers_8888(&drb->Base);
+   }
+   else if (drb->Base.Format == MESA_FORMAT_Z16) {
       mgaInitDepthPointers_z16(&drb->Base);
    }
-   else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+   else if (drb->Base.Format == MESA_FORMAT_Z24_S8) {
       mgaInitDepthPointers_z24_s8(&drb->Base);
    }
-   else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT32) {
+   else if (drb->Base.Format == MESA_FORMAT_Z32) {
       mgaInitDepthPointers_z32(&drb->Base);
    }
-   else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+   else if (drb->Base.Format == MESA_FORMAT_S8) {
       mgaInitStencilPointers_z24_s8(&drb->Base);
    }
 }
index 7c830ec097464814f99c7a6b599902cdc83fb37c..0253044761dedee1999b7c0b1f97f61244bb6d83 100644 (file)
@@ -374,13 +374,11 @@ static void mgaDDColorMask(GLcontext *ctx,
 {
    mgaContextPtr mmesa = MGA_CONTEXT( ctx );
    mgaScreenPrivate *mgaScreen = mmesa->mgaScreen;
-
-
    GLuint mask = mgaPackColor(mgaScreen->cpp,
-                             ctx->Color.ColorMask[RCOMP],
-                             ctx->Color.ColorMask[GCOMP],
-                             ctx->Color.ColorMask[BCOMP],
-                             ctx->Color.ColorMask[ACOMP]);
+                             ctx->Color.ColorMask[0][RCOMP],
+                             ctx->Color.ColorMask[0][GCOMP],
+                             ctx->Color.ColorMask[0][BCOMP],
+                             ctx->Color.ColorMask[0][ACOMP]);
 
    if (mgaScreen->cpp == 2)
       mask = mask | (mask << 16);
@@ -748,7 +746,7 @@ static void mgaDDLogicOp( GLcontext *ctx, GLenum opcode )
 
 static void mga_set_cliprects(mgaContextPtr mmesa)
 {
-   __DRIdrawablePrivate *driDrawable = mmesa->driDrawable;
+   __DRIdrawable *driDrawable = mmesa->driDrawable;
 
    if ((mmesa->draw_buffer != MGA_FRONT)
        || (driDrawable->numBackClipRects == 0)) {
@@ -776,8 +774,8 @@ static void mga_set_cliprects(mgaContextPtr mmesa)
 
 void mgaUpdateRects( mgaContextPtr mmesa, GLuint buffers )
 {
-   __DRIdrawablePrivate *const driDrawable = mmesa->driDrawable;
-   __DRIdrawablePrivate *const driReadable = mmesa->driReadable;
+   __DRIdrawable *const driDrawable = mmesa->driDrawable;
+   __DRIdrawable *const driReadable = mmesa->driReadable;
 
    mmesa->dirty_cliprects = 0; 
 
index 33eb0be449662f804396518d1f9253068e8cd803..62a9317cd48ab317aa946f2463874e062cc03074 100644 (file)
 
 #include "main/glheader.h"
 #include "main/mm.h"
-#include "mgacontext.h"
-#include "mgatex.h"
-#include "mgaregs.h"
-#include "mgatris.h"
-#include "mgaioctl.h"
-
 #include "main/colormac.h"
 #include "main/context.h"
 #include "main/enums.h"
 #include "main/simple_list.h"
 #include "main/imports.h"
 #include "main/macros.h"
-#include "main/texformat.h"
 #include "main/texstore.h"
 #include "main/teximage.h"
 #include "main/texobj.h"
 
+#include "mgacontext.h"
+#include "mgatex.h"
+#include "mgaregs.h"
+#include "mgatris.h"
+#include "mgaioctl.h"
+
 #include "swrast/swrast.h"
 
 #include "xmlpool.h"
@@ -164,7 +163,7 @@ static void mgaSetTexBorderColor(mgaTextureObjectPtr t, const GLfloat color[4])
 }
 
 
-static const struct gl_texture_format *
+static gl_format
 mgaChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
                        GLenum format, GLenum type )
 {
@@ -182,15 +181,15 @@ mgaChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
       switch ( type ) {
       case GL_UNSIGNED_INT_10_10_10_2:
       case GL_UNSIGNED_INT_2_10_10_10_REV:
-        return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb1555;
+        return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB1555;
       case GL_UNSIGNED_SHORT_4_4_4_4:
       case GL_UNSIGNED_SHORT_4_4_4_4_REV:
-        return &_mesa_texformat_argb4444;
+        return MESA_FORMAT_ARGB4444;
       case GL_UNSIGNED_SHORT_5_5_5_1:
       case GL_UNSIGNED_SHORT_1_5_5_5_REV:
-        return &_mesa_texformat_argb1555;
+        return MESA_FORMAT_ARGB1555;
       default:
-         return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+         return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444;
       }
 
    case 3:
@@ -199,15 +198,15 @@ mgaChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
       switch ( type ) {
       case GL_UNSIGNED_SHORT_4_4_4_4:
       case GL_UNSIGNED_SHORT_4_4_4_4_REV:
-        return &_mesa_texformat_argb4444;
+        return MESA_FORMAT_ARGB4444;
       case GL_UNSIGNED_SHORT_5_5_5_1:
       case GL_UNSIGNED_SHORT_1_5_5_5_REV:
-        return &_mesa_texformat_argb1555;
+        return MESA_FORMAT_ARGB1555;
       case GL_UNSIGNED_SHORT_5_6_5:
       case GL_UNSIGNED_SHORT_5_6_5_REV:
-        return &_mesa_texformat_rgb565;
+        return MESA_FORMAT_RGB565;
       default:
-         return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
+         return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_RGB565;
       }
 
    case GL_RGBA8:
@@ -215,25 +214,25 @@ mgaChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_RGBA12:
    case GL_RGBA16:
       return !force16bpt ?
-         &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+         MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444;
 
    case GL_RGBA4:
    case GL_RGBA2:
-      return &_mesa_texformat_argb4444;
+      return MESA_FORMAT_ARGB4444;
 
    case GL_RGB5_A1:
-      return &_mesa_texformat_argb1555;
+      return MESA_FORMAT_ARGB1555;
 
    case GL_RGB8:
    case GL_RGB10:
    case GL_RGB12:
    case GL_RGB16:
-      return !force16bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
+      return !force16bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_RGB565;
 
    case GL_RGB5:
    case GL_RGB4:
    case GL_R3_G3_B2:
-      return &_mesa_texformat_rgb565;
+      return MESA_FORMAT_RGB565;
 
    case GL_ALPHA:
    case GL_ALPHA4:
@@ -242,7 +241,7 @@ mgaChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_ALPHA16:
    case GL_COMPRESSED_ALPHA:
       /* FIXME: This will report incorrect component sizes... */
-      return MGA_IS_G400(mmesa) ? &_mesa_texformat_al88 : &_mesa_texformat_argb4444;
+      return MGA_IS_G400(mmesa) ? MESA_FORMAT_AL88 : MESA_FORMAT_ARGB4444;
 
    case 1:
    case GL_LUMINANCE:
@@ -252,7 +251,7 @@ mgaChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_LUMINANCE16:
    case GL_COMPRESSED_LUMINANCE:
       /* FIXME: This will report incorrect component sizes... */
-      return MGA_IS_G400(mmesa) ? &_mesa_texformat_al88 : &_mesa_texformat_rgb565;
+      return MGA_IS_G400(mmesa) ? MESA_FORMAT_AL88 : MESA_FORMAT_RGB565;
 
    case 2:
    case GL_LUMINANCE_ALPHA:
@@ -264,7 +263,7 @@ mgaChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_LUMINANCE16_ALPHA16:
    case GL_COMPRESSED_LUMINANCE_ALPHA:
       /* FIXME: This will report incorrect component sizes... */
-      return MGA_IS_G400(mmesa) ? &_mesa_texformat_al88 : &_mesa_texformat_argb4444;
+      return MGA_IS_G400(mmesa) ? MESA_FORMAT_AL88 : MESA_FORMAT_ARGB4444;
 
    case GL_INTENSITY:
    case GL_INTENSITY4:
@@ -273,15 +272,15 @@ mgaChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_INTENSITY16:
    case GL_COMPRESSED_INTENSITY:
       /* FIXME: This will report incorrect component sizes... */
-      return MGA_IS_G400(mmesa) ? &_mesa_texformat_i8 : &_mesa_texformat_argb4444;
+      return MGA_IS_G400(mmesa) ? MESA_FORMAT_I8 : MESA_FORMAT_ARGB4444;
 
    case GL_YCBCR_MESA:
       if (MGA_IS_G400(mmesa) &&
           (type == GL_UNSIGNED_SHORT_8_8_APPLE ||
            type == GL_UNSIGNED_BYTE))
-         return &_mesa_texformat_ycbcr;
+         return MESA_FORMAT_YCBCR;
       else
-         return &_mesa_texformat_ycbcr_rev;
+         return MESA_FORMAT_YCBCR_REV;
 
    case GL_COLOR_INDEX:
    case GL_COLOR_INDEX1_EXT:
@@ -290,14 +289,14 @@ mgaChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_COLOR_INDEX8_EXT:
    case GL_COLOR_INDEX12_EXT:
    case GL_COLOR_INDEX16_EXT:
-      return &_mesa_texformat_ci8;
+      return MESA_FORMAT_CI8;
 
    default:
       _mesa_problem( ctx, "unexpected texture format in %s", __FUNCTION__ );
-      return NULL;
+      return MESA_FORMAT_NONE;
    }
 
-   return NULL; /* never get here */
+   return MESA_FORMAT_NONE; /* never get here */
 }
 
 
@@ -333,7 +332,7 @@ mgaAllocTexObj( struct gl_texture_object *tObj )
 
       mgaSetTexWrapping( t, tObj->WrapS, tObj->WrapT );
       mgaSetTexFilter( t, tObj->MinFilter, tObj->MagFilter );
-      mgaSetTexBorderColor( t, tObj->BorderColor );
+      mgaSetTexBorderColor( t, tObj->BorderColor.f );
    }
 
    return( t );
@@ -462,7 +461,7 @@ mgaTexParameter( GLcontext *ctx, GLenum target,
 
    case GL_TEXTURE_BORDER_COLOR:
       FLUSH_BATCH(mmesa);
-      mgaSetTexBorderColor(t, tObj->BorderColor);
+      mgaSetTexBorderColor(t, tObj->BorderColor.f);
       break;
 
    case GL_TEXTURE_BASE_LEVEL:
index 9a2d62b53b7276cd492df7455f05498b4c96d6df..47be6f3c1858c7846a6988e4bb7b4ed6c2fda1fa 100644 (file)
@@ -137,7 +137,7 @@ static void mgaUploadSubImage( mgaContextPtr mmesa,
     * directly used by the hardware for texturing.
     */
 
-   texelBytes = texImage->TexFormat->TexelBytes;
+   texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
    length = texImage->Width * texImage->Height * texelBytes;
    if ( t->base.heap->heapId == MGA_CARD_HEAP ) {
       unsigned  tex_offset = 0;
index b93a21c3acf40c0937f59dceb2e578b144c024ab..c1bcd4b853147ebc715921ed0a484eb69def25d5 100644 (file)
@@ -397,7 +397,8 @@ do {                                                \
 
 #define LOCAL_VARS(n)                                  \
    mgaContextPtr mmesa = MGA_CONTEXT(ctx);             \
-   GLuint color[n], spec[n];                           \
+   GLuint color[n] = { 0 };                            \
+   GLuint spec[n] = { 0 };                             \
    (void) color; (void) spec;
 
 
index 796dfbc5167ea308e552cc8fef07c46f58413ad2..52c5a38a7052a08fe417924cb66cac37fabe7e6f 100644 (file)
@@ -29,4 +29,3 @@ ASM_SOURCES =
 
 include ../Makefile.template
 
-symlinks:
index f511a67badab2c81d182a563814c685e3ee26ba0..e389e1c87b039d8a8c9f13534ff9b31427fa173b 100644 (file)
@@ -68,9 +68,9 @@ int R128_DEBUG = 0;
 #define need_GL_EXT_blend_minmax
 #define need_GL_EXT_fog_coord
 #define need_GL_EXT_secondary_color
-#include "extension_helper.h"
+#include "main/remap_helper.h"
 
-const struct dri_extension card_extensions[] =
+static const struct dri_extension card_extensions[] =
 {
     { "GL_ARB_multitexture",               NULL },
     { "GL_ARB_texture_env_add",            NULL },
@@ -101,11 +101,11 @@ static const struct dri_debug_control debug_control[] =
 /* Create the device specific context.
  */
 GLboolean r128CreateContext( const __GLcontextModes *glVisual,
-                            __DRIcontextPrivate *driContextPriv,
+                            __DRIcontext *driContextPriv,
                              void *sharedContextPrivate )
 {
    GLcontext *ctx, *shareCtx;
-   __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+   __DRIscreen *sPriv = driContextPriv->driScreenPriv;
    struct dd_function_table functions;
    r128ContextPtr rmesa;
    r128ScreenPtr r128scrn;
@@ -274,7 +274,7 @@ GLboolean r128CreateContext( const __GLcontextModes *glVisual,
 
 /* Destroy the device specific context.
  */
-void r128DestroyContext( __DRIcontextPrivate *driContextPriv  )
+void r128DestroyContext( __DRIcontext *driContextPriv  )
 {
    r128ContextPtr rmesa = (r128ContextPtr) driContextPriv->driverPrivate;
 
@@ -325,9 +325,9 @@ void r128DestroyContext( __DRIcontextPrivate *driContextPriv  )
  * buffer `b'.
  */
 GLboolean
-r128MakeCurrent( __DRIcontextPrivate *driContextPriv,
-                 __DRIdrawablePrivate *driDrawPriv,
-                 __DRIdrawablePrivate *driReadPriv )
+r128MakeCurrent( __DRIcontext *driContextPriv,
+                 __DRIdrawable *driDrawPriv,
+                 __DRIdrawable *driReadPriv )
 {
    if ( driContextPriv ) {
       GET_CURRENT_CONTEXT(ctx);
@@ -364,7 +364,7 @@ r128MakeCurrent( __DRIcontextPrivate *driContextPriv,
 /* Force the context `c' to be unbound from its buffer.
  */
 GLboolean
-r128UnbindContext( __DRIcontextPrivate *driContextPriv )
+r128UnbindContext( __DRIcontext *driContextPriv )
 {
    return GL_TRUE;
 }
index 0e10209a6ad04442766fe8d7cf5a2c7fd4d41f3c..65f845c115955f61c26ae5d9411d9494c532de5f 100644 (file)
@@ -186,9 +186,9 @@ struct r128_context {
 
    /* Mirrors of some DRI state
     */
-   __DRIcontextPrivate *driContext;    /* DRI context */
-   __DRIscreenPrivate  *driScreen;     /* DRI screen */
-   __DRIdrawablePrivate        *driDrawable;   /* DRI drawable bound to this ctx */
+   __DRIcontext        *driContext;    /* DRI context */
+   __DRIscreen *driScreen;     /* DRI screen */
+   __DRIdrawable       *driDrawable;   /* DRI drawable bound to this ctx */
 
    unsigned int lastStamp;             /* mirror driDrawable->lastStamp */
 
@@ -225,16 +225,16 @@ struct r128_context {
 
 
 extern GLboolean r128CreateContext( const __GLcontextModes *glVisual,
-                                   __DRIcontextPrivate *driContextPriv,
+                                   __DRIcontext *driContextPriv,
                                     void *sharedContextPrivate );
 
-extern void r128DestroyContext( __DRIcontextPrivate * );
+extern void r128DestroyContext( __DRIcontext * );
 
-extern GLboolean r128MakeCurrent( __DRIcontextPrivate *driContextPriv,
-                                  __DRIdrawablePrivate *driDrawPriv,
-                                  __DRIdrawablePrivate *driReadPriv );
+extern GLboolean r128MakeCurrent( __DRIcontext *driContextPriv,
+                                  __DRIdrawable *driDrawPriv,
+                                  __DRIdrawable *driReadPriv );
 
-extern GLboolean r128UnbindContext( __DRIcontextPrivate *driContextPriv );
+extern GLboolean r128UnbindContext( __DRIcontext *driContextPriv );
 
 /* ================================================================
  * Debugging:
index 84ac3d9f797e0c5b949521ef01ee511551753a46..56758d971c32986e6c992d6d1498aeba033e5f9e 100644 (file)
@@ -248,7 +248,7 @@ static int r128WaitForFrameCompletion( r128ContextPtr rmesa )
 
 /* Copy the back color buffer to the front color buffer.
  */
-void r128CopyBuffer( __DRIdrawablePrivate *dPriv )
+void r128CopyBuffer( __DRIdrawable *dPriv )
 {
    r128ContextPtr rmesa;
    GLint nbox, i, ret;
@@ -327,7 +327,7 @@ void r128CopyBuffer( __DRIdrawablePrivate *dPriv )
 #endif
 }
 
-void r128PageFlip( __DRIdrawablePrivate *dPriv )
+void r128PageFlip( __DRIdrawable *dPriv )
 {
    r128ContextPtr rmesa;
    GLint ret;
@@ -401,7 +401,7 @@ void r128PageFlip( __DRIdrawablePrivate *dPriv )
 static void r128Clear( GLcontext *ctx, GLbitfield mask )
 {
    r128ContextPtr rmesa = R128_CONTEXT(ctx);
-   __DRIdrawablePrivate *dPriv = rmesa->driDrawable;
+   __DRIdrawable *dPriv = rmesa->driDrawable;
    drm_r128_clear_t clear;
    GLuint flags = 0;
    GLint i;
index 4b0c9cdc7febde7e64cdfb031c562e8471552cf9..84ace900eecc55fab327568d3f65fd9c0a50d1af 100644 (file)
@@ -85,8 +85,8 @@ extern void r128ReadDepthSpanLocked( r128ContextPtr rmesa,
 extern void r128ReadDepthPixelsLocked( r128ContextPtr rmesa, GLuint n,
                                       const GLint x[], const GLint y[] );
 
-extern void r128CopyBuffer( __DRIdrawablePrivate *dPriv );
-extern void r128PageFlip( __DRIdrawablePrivate *dPriv );
+extern void r128CopyBuffer( __DRIdrawable *dPriv );
+extern void r128PageFlip( __DRIdrawable *dPriv );
 void r128WaitForVBlank( r128ContextPtr rmesa );
 
 extern void r128WaitForIdleLocked( r128ContextPtr rmesa );
index 81488a27424312b307924b70c541a716433e8e60..9bc3515b5aa08e6e1dcf9ffd3d2b47aec46fd1a8 100644 (file)
@@ -68,8 +68,8 @@ r128UpdatePageFlipping( r128ContextPtr rmesa )
  */
 void r128GetLock( r128ContextPtr rmesa, GLuint flags )
 {
-   __DRIdrawablePrivate *dPriv = rmesa->driDrawable;
-   __DRIscreenPrivate *sPriv = rmesa->driScreen;
+   __DRIdrawable *dPriv = rmesa->driDrawable;
+   __DRIscreen *sPriv = rmesa->driScreen;
    drm_r128_sarea_t *sarea = rmesa->sarea;
    int i;
 
index f5bcc2f2906bd414486c3d0319c8d858e5a68c14..80b265811ec614c2559028cef5602b83421e980c 100644 (file)
@@ -74,8 +74,6 @@ static const GLuint __driNConfigOptions = 4;
 static const GLuint __driNConfigOptions = 3;
 #endif
 
-extern const struct dri_extension card_extensions[];
-
 #if 1
 /* Including xf86PciInfo.h introduces a bunch of errors...
  */
@@ -93,7 +91,7 @@ extern const struct dri_extension card_extensions[];
 /* Create the device specific screen private data struct.
  */
 static r128ScreenPtr
-r128CreateScreen( __DRIscreenPrivate *sPriv )
+r128CreateScreen( __DRIscreen *sPriv )
 {
    r128ScreenPtr r128Screen;
    R128DRIPtr r128DRIPriv = (R128DRIPtr)sPriv->pDevPriv;
@@ -238,7 +236,7 @@ r128CreateScreen( __DRIscreenPrivate *sPriv )
 /* Destroy the device specific screen private data struct.
  */
 static void
-r128DestroyScreen( __DRIscreenPrivate *sPriv )
+r128DestroyScreen( __DRIscreen *sPriv )
 {
    r128ScreenPtr r128Screen = (r128ScreenPtr)sPriv->private;
 
@@ -264,8 +262,8 @@ r128DestroyScreen( __DRIscreenPrivate *sPriv )
  * data.
  */
 static GLboolean
-r128CreateBuffer( __DRIscreenPrivate *driScrnPriv,
-                  __DRIdrawablePrivate *driDrawPriv,
+r128CreateBuffer( __DRIscreen *driScrnPriv,
+                  __DRIdrawable *driDrawPriv,
                   const __GLcontextModes *mesaVis,
                   GLboolean isPixmap )
 {
@@ -284,7 +282,7 @@ r128CreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       {
          driRenderbuffer *frontRb
-            = driNewRenderbuffer(GL_RGBA,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888,
                                  NULL,
                                  screen->cpp,
                                  screen->frontOffset, screen->frontPitch,
@@ -295,7 +293,7 @@ r128CreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->doubleBufferMode) {
          driRenderbuffer *backRb
-            = driNewRenderbuffer(GL_RGBA,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888,
                                  NULL,
                                  screen->cpp,
                                  screen->backOffset, screen->backPitch,
@@ -306,7 +304,7 @@ r128CreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->depthBits == 16) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT16,
+            = driNewRenderbuffer(MESA_FORMAT_Z16,
                                  NULL,
                                  screen->cpp,
                                  screen->depthOffset, screen->depthPitch,
@@ -316,7 +314,7 @@ r128CreateBuffer( __DRIscreenPrivate *driScrnPriv,
       }
       else if (mesaVis->depthBits == 24) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT24,
+            = driNewRenderbuffer(MESA_FORMAT_S8_Z24,
                                  NULL,
                                  screen->cpp,
                                  screen->depthOffset, screen->depthPitch,
@@ -327,7 +325,7 @@ r128CreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->stencilBits > 0 && !swStencil) {
          driRenderbuffer *stencilRb
-            = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT,
+            = driNewRenderbuffer(MESA_FORMAT_S8,
                                  NULL,
                                  screen->cpp,
                                  screen->depthOffset, screen->depthPitch,
@@ -351,7 +349,7 @@ r128CreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
 
 static void
-r128DestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+r128DestroyBuffer(__DRIdrawable *driDrawPriv)
 {
    _mesa_reference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)), NULL);
 }
@@ -359,7 +357,7 @@ r128DestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
 
 /* Copy the back color buffer to the front color buffer */
 static void
-r128SwapBuffers(__DRIdrawablePrivate *dPriv)
+r128SwapBuffers(__DRIdrawable *dPriv)
 {
    if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
       r128ContextPtr rmesa;
@@ -386,7 +384,7 @@ r128SwapBuffers(__DRIdrawablePrivate *dPriv)
 /* Initialize the driver specific screen private data.
  */
 static GLboolean
-r128InitDriver( __DRIscreenPrivate *sPriv )
+r128InitDriver( __DRIscreen *sPriv )
 {
    sPriv->private = (void *) r128CreateScreen( sPriv );
 
@@ -399,7 +397,7 @@ r128InitDriver( __DRIscreenPrivate *sPriv )
 }
 
 static const __DRIconfig **
-r128FillInModes( __DRIscreenPrivate *psp,
+r128FillInModes( __DRIscreen *psp,
                 unsigned pixel_bits, unsigned depth_bits,
                 unsigned stencil_bits, GLboolean have_back_buffer )
 {
@@ -480,7 +478,7 @@ r128FillInModes( __DRIscreenPrivate *psp,
  * \return the __GLcontextModes supported by this driver
  */
 static const __DRIconfig **
-r128InitScreen(__DRIscreenPrivate *psp)
+r128InitScreen(__DRIscreen *psp)
 {
    static const __DRIversion ddx_expected = { 4, 0, 0 };
    static const __DRIversion dri_expected = { 4, 0, 0 };
@@ -493,18 +491,6 @@ r128InitScreen(__DRIscreenPrivate *psp)
                                      &psp->drm_version, & drm_expected ) )
       return NULL;
 
-   /* Calling driInitExtensions here, with a NULL context pointer,
-    * does not actually enable the extensions.  It just makes sure
-    * that all the dispatch offsets for all the extensions that
-    * *might* be enables are known.  This is needed because the
-    * dispatch offsets need to be known when _mesa_context_create is
-    * called, but we can't enable the extensions until we have a
-    * context pointer.
-    *
-    * Hello chicken.  Hello egg.  How are you two today?
-    */
-   driInitExtensions( NULL, card_extensions, GL_FALSE );
-
    if (!r128InitDriver(psp))
        return NULL;
 
@@ -531,3 +517,10 @@ const struct __DriverAPIRec driDriverAPI = {
    .WaitForSBC      = NULL,
    .SwapBuffersMSC  = NULL
 };
+
+/* This is the table of extensions that the loader will dlsym() for. */
+PUBLIC const __DRIextension *__driDriverExtensions[] = {
+    &driCoreExtension.base,
+    &driLegacyExtension.base,
+    NULL
+};
index e2fa1677c9fa5064bf47cd1baa787173c973dbd6..8d450adff34663a7df188005dd8689f96e38f7e8 100644 (file)
@@ -71,7 +71,7 @@ typedef struct {
 
    drmBufMapPtr buffers;
 
-   __DRIscreenPrivate *driScreen;
+   __DRIscreen *driScreen;
    unsigned int sarea_priv_offset;
 
    /* Configuration cache with default values for all contexts */
index dd177e0def5cceef049858cb7d5f454a02079393..0413e5b4f12e11dd4bf743f2c515071600f21497 100644 (file)
@@ -50,8 +50,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #define LOCAL_VARS                                                     \
    r128ContextPtr rmesa = R128_CONTEXT(ctx);                           \
-   __DRIscreenPrivate *sPriv = rmesa->driScreen;                       \
-   __DRIdrawablePrivate *dPriv = rmesa->driDrawable;                   \
+   __DRIscreen *sPriv = rmesa->driScreen;                      \
+   __DRIdrawable *dPriv = rmesa->driDrawable;                  \
    driRenderbuffer *drb = (driRenderbuffer *) rb;                      \
    GLuint height = dPriv->h;                                           \
    GLuint p;                                                           \
@@ -60,8 +60,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define LOCAL_DEPTH_VARS                                               \
    r128ContextPtr rmesa = R128_CONTEXT(ctx);                           \
    r128ScreenPtr r128scrn = rmesa->r128Screen;                         \
-   __DRIscreenPrivate *sPriv = rmesa->driScreen;                       \
-   __DRIdrawablePrivate *dPriv = rmesa->driDrawable;                   \
+   __DRIscreen *sPriv = rmesa->driScreen;                      \
+   __DRIdrawable *dPriv = rmesa->driDrawable;                  \
    GLuint height = dPriv->h;                                           \
    (void) r128scrn; (void) sPriv; (void) height
 
@@ -433,21 +433,19 @@ void r128DDInitSpanFuncs( GLcontext *ctx )
 void
 r128SetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
 {
-   if (drb->Base.InternalFormat == GL_RGBA) {
-      if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
-         r128InitPointers_RGB565(&drb->Base);
-      }
-      else {
-         r128InitPointers_ARGB8888(&drb->Base);
-      }
+   if (drb->Base.Format == MESA_FORMAT_RGB565) {
+      r128InitPointers_RGB565(&drb->Base);
    }
-   else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+   else if (drb->Base.Format == MESA_FORMAT_ARGB8888) {
+      r128InitPointers_ARGB8888(&drb->Base);
+   }
+   else if (drb->Base.Format == MESA_FORMAT_Z16) {
       r128InitDepthPointers_z16(&drb->Base);
    }
-   else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+   else if (drb->Base.Format == MESA_FORMAT_S8_Z24) {
       r128InitDepthPointers_z24_s8(&drb->Base);
    }
-   else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+   else if (drb->Base.Format == MESA_FORMAT_S8) {
       radeonInitStencilPointers_z24_s8(&drb->Base);
    }
 }
index 4ae7bf5b97dc90de3fc8e30a19a0c13a29650436..2254a7a4ffc7b00560159c5a453637f0ed7b17d3 100644 (file)
@@ -572,7 +572,7 @@ static void r128UpdateClipping( GLcontext *ctx )
    r128ContextPtr rmesa = R128_CONTEXT(ctx);
 
    if ( rmesa->driDrawable ) {
-      __DRIdrawablePrivate *drawable = rmesa->driDrawable;
+      __DRIdrawable *drawable = rmesa->driDrawable;
       int x1 = 0;
       int y1 = 0;
       int x2 = drawable->w - 1;
@@ -702,10 +702,10 @@ static void r128UpdateMasks( GLcontext *ctx )
    r128ContextPtr rmesa = R128_CONTEXT(ctx);
 
    GLuint mask = r128PackColor( rmesa->r128Screen->cpp,
-                               ctx->Color.ColorMask[RCOMP],
-                               ctx->Color.ColorMask[GCOMP],
-                               ctx->Color.ColorMask[BCOMP],
-                               ctx->Color.ColorMask[ACOMP] );
+                               ctx->Color.ColorMask[0][RCOMP],
+                               ctx->Color.ColorMask[0][GCOMP],
+                               ctx->Color.ColorMask[0][BCOMP],
+                               ctx->Color.ColorMask[0][ACOMP] );
 
    if ( rmesa->setup.plane_3d_mask_c != mask ) {
       rmesa->setup.plane_3d_mask_c = mask;
index 0920270d7b606f6ca40824de21fd04888e410e68..f1be7cc1c4f41e297de5cb7f9c9e546deaea9aac 100644 (file)
@@ -44,7 +44,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/simple_list.h"
 #include "main/enums.h"
 #include "main/texstore.h"
-#include "main/texformat.h"
 #include "main/teximage.h"
 #include "main/texobj.h"
 #include "main/imports.h"
@@ -170,7 +169,7 @@ static r128TexObjPtr r128AllocTexObj( struct gl_texture_object *texObj )
 
       r128SetTexWrap( t, texObj->WrapS, texObj->WrapT );
       r128SetTexFilter( t, texObj->MinFilter, texObj->MagFilter );
-      r128SetTexBorderColor( t, texObj->BorderColor );
+      r128SetTexBorderColor( t, texObj->BorderColor.f );
    }
 
    return t;
@@ -178,7 +177,7 @@ static r128TexObjPtr r128AllocTexObj( struct gl_texture_object *texObj )
 
 
 /* Called by the _mesa_store_teximage[123]d() functions. */
-static const struct gl_texture_format *
+static gl_format
 r128ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
                          GLenum format, GLenum type )
 {
@@ -282,13 +281,13 @@ r128ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_YCBCR_MESA:
       if (type == GL_UNSIGNED_SHORT_8_8_APPLE ||
           type == GL_UNSIGNED_BYTE)
-         return &_mesa_texformat_ycbcr;
+         return MESA_FORMAT_YCBCR;
       else
-         return &_mesa_texformat_ycbcr_rev;
+         return MESA_FORMAT_YCBCR_REV;
 
    default:
       _mesa_problem( ctx, "unexpected format in %s", __FUNCTION__ );
-      return NULL;
+      return MESA_FORMAT_NONE;
    }
 }
 
@@ -536,7 +535,7 @@ static void r128TexParameter( GLcontext *ctx, GLenum target,
 
    case GL_TEXTURE_BORDER_COLOR:
       if ( t->base.bound ) FLUSH_BATCH( rmesa );
-      r128SetTexBorderColor( t, tObj->BorderColor );
+      r128SetTexBorderColor( t, tObj->BorderColor.f );
       break;
 
    case GL_TEXTURE_BASE_LEVEL:
index 111fe1fd7424a8746d45f2668e2ea238c297bbdd..4ddcb86bcdc52daf6f15a89e7ff7b984f99e41e5 100644 (file)
@@ -41,7 +41,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/context.h"
 #include "main/macros.h"
 #include "main/simple_list.h"
-#include "main/texformat.h"
 #include "main/imports.h"
 
 #define TEX_0  1
@@ -95,7 +94,7 @@ static void uploadSubImage( r128ContextPtr rmesa, r128TexObjPtr t,
    if ( !image )
       return;
 
-   switch ( image->TexFormat->TexelBytes ) {
+   switch ( _mesa_get_format_bytes(image->TexFormat) ) {
    case 1: texelsPerDword = 4; break;
    case 2: texelsPerDword = 2; break;
    case 4: texelsPerDword = 1; break;
@@ -215,9 +214,11 @@ static void uploadSubImage( r128ContextPtr rmesa, r128TexObjPtr t,
 
       /* Copy the next chunck of the texture image into the blit buffer */
       {
+         const GLuint texelBytes =
+            _mesa_get_format_bytes(image->TexFormat);
          const GLubyte *src = (const GLubyte *) image->Data +
-            (y * image->Width + x) * image->TexFormat->TexelBytes;
-         const GLuint bytes = width * height * image->TexFormat->TexelBytes;
+            (y * image->Width + x) * texelBytes;            
+         const GLuint bytes = width * height * texelBytes;
          memcpy(dst, src, bytes);
       }
 
index a9c9568003b851789e14cdc0dfd3fd7f2cd8ec74..cb2b5f9536099e045e9a4cab672e473a5d5e5d8f 100644 (file)
@@ -36,7 +36,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/imports.h"
 #include "main/context.h"
 #include "main/macros.h"
-#include "main/texformat.h"
 
 #include "r128_context.h"
 #include "r128_state.h"
@@ -61,7 +60,7 @@ static void r128SetTexImages( r128ContextPtr rmesa,
    if ( R128_DEBUG & DEBUG_VERBOSE_API )
       fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *) tObj );
 
-   switch (baseImage->TexFormat->MesaFormat) {
+   switch (baseImage->TexFormat) {
    case MESA_FORMAT_ARGB8888:
    case MESA_FORMAT_ARGB8888_REV:
       t->textureFormat = R128_DATATYPE_ARGB8888;
@@ -123,7 +122,7 @@ static void r128SetTexImages( r128ContextPtr rmesa,
 
       totalSize += (tObj->Image[0][i]->Height *
                    tObj->Image[0][i]->Width *
-                   tObj->Image[0][i]->TexFormat->TexelBytes);
+                   _mesa_get_format_bytes(tObj->Image[0][i]->TexFormat));
 
       /* Offsets must be 32-byte aligned for host data blits and tiling */
       totalSize = (totalSize + 31) & ~31;
index 5b91271d740779be2f6dcb6c8e1df0e7b82cdc40..86d4717b050fa94015877f4e2653518a0ff4ee5e 100644 (file)
@@ -216,7 +216,8 @@ do {                                                        \
 
 #define LOCAL_VARS(n)                                          \
    r128ContextPtr rmesa = R128_CONTEXT(ctx);                   \
-   GLuint color[n], spec[n];                                   \
+   GLuint color[n] = { 0 };                                    \
+   GLuint spec[n] = { 0 };                                     \
    GLuint coloroffset = rmesa->coloroffset;                    \
    GLuint specoffset = rmesa->specoffset;                      \
    GLboolean havespec = (rmesa->specoffset != 0);              \
@@ -650,12 +651,12 @@ static void r128RenderStart( GLcontext *ctx )
    }
 
    if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX(rmesa->tmu_source[0]) )) {
-      if ( VB->TexCoordPtr[rmesa->tmu_source[0]]->size > 2 )
+      if ( VB->AttribPtr[_TNL_ATTRIB_TEX0 + rmesa->tmu_source[0]]->size > 2 )
         fallback_projtex = GL_TRUE;
       EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_2F, R128_CCE_VC_FRMT_S_T, 8 );
    }
    if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX(rmesa->tmu_source[1]) )) {
-      if ( VB->TexCoordPtr[rmesa->tmu_source[1]]->size > 2 )
+      if ( VB->AttribPtr[_TNL_ATTRIB_TEX0 + rmesa->tmu_source[1]]->size > 2 )
         fallback_projtex = GL_TRUE;
       EMIT_ATTR( _TNL_ATTRIB_TEX1, EMIT_2F, R128_CCE_VC_FRMT_S2_T2, 8 );
    }
index fbce70c37bcfda7e7ca7a1c4c90f0c7b687f9f0d..8212dc12031fc49d6e7687ca03bce366eddc13ad 100644 (file)
@@ -14,7 +14,7 @@ EGL_SOURCES = server/radeon_egl.c
 endif
 
 ifeq ($(RADEON_LDFLAGS),)
-CS_SOURCES = radeon_cs_space_drm.c
+CS_SOURCES = radeon_cs_space_drm.c radeon_bo.c radeon_cs.c
 endif
 
 RADEON_COMMON_SOURCES = \
@@ -66,4 +66,3 @@ include ../Makefile.template
 
 #INCLUDES += -I../radeon/server
 
-symlinks:
index 3ddb5bf7d60c4635d158900e6663fa8a5f96c08b..f34e319222d8ef4add82ff01c2a371557de2f6f8 100644 (file)
@@ -75,7 +75,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define need_GL_NV_vertex_program
 #define need_GL_ARB_point_parameters
 #define need_GL_EXT_framebuffer_object
-#include "extension_helper.h"
+#include "main/remap_helper.h"
 
 #define DRIVER_DATE    "20060602"
 
@@ -115,7 +115,7 @@ static const GLubyte *r200GetString( GLcontext *ctx, GLenum name )
 
 /* Extension strings exported by the R200 driver.
  */
-const struct dri_extension card_extensions[] =
+static const struct dri_extension card_extensions[] =
 {
     { "GL_ARB_multitexture",               NULL },
     { "GL_ARB_occlusion_query",                   GL_ARB_occlusion_query_functions},
@@ -146,31 +146,31 @@ const struct dri_extension card_extensions[] =
     { NULL,                                NULL }
 };
 
-const struct dri_extension blend_extensions[] = {
+static const struct dri_extension blend_extensions[] = {
     { "GL_EXT_blend_equation_separate",    GL_EXT_blend_equation_separate_functions },
     { "GL_EXT_blend_func_separate",        GL_EXT_blend_func_separate_functions },
     { NULL,                                NULL }
 };
 
-const struct dri_extension ARB_vp_extension[] = {
+static const struct dri_extension ARB_vp_extension[] = {
     { "GL_ARB_vertex_program",             GL_ARB_vertex_program_functions }
 };
 
-const struct dri_extension NV_vp_extension[] = {
+static const struct dri_extension NV_vp_extension[] = {
     { "GL_NV_vertex_program",              GL_NV_vertex_program_functions }
 };
 
-const struct dri_extension ATI_fs_extension[] = {
+static const struct dri_extension ATI_fs_extension[] = {
     { "GL_ATI_fragment_shader",            GL_ATI_fragment_shader_functions }
 };
 
-const struct dri_extension point_extensions[] = {
+static const struct dri_extension point_extensions[] = {
     { "GL_ARB_point_sprite",               NULL },
     { "GL_ARB_point_parameters",           GL_ARB_point_parameters_functions },
     { NULL,                                NULL }
 };
 
-const struct dri_extension mm_extensions[] = {
+static const struct dri_extension mm_extensions[] = {
   { "GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions },
   { NULL, NULL }
 };
@@ -274,10 +274,10 @@ static void r200_init_vtbl(radeonContextPtr radeon)
 /* Create the device specific rendering context.
  */
 GLboolean r200CreateContext( const __GLcontextModes *glVisual,
-                            __DRIcontextPrivate *driContextPriv,
+                            __DRIcontext *driContextPriv,
                             void *sharedContextPrivate)
 {
-   __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+   __DRIscreen *sPriv = driContextPriv->driScreenPriv;
    radeonScreenPtr screen = (radeonScreenPtr)(sPriv->private);
    struct dd_function_table functions;
    r200ContextPtr rmesa;
@@ -325,9 +325,9 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual,
    _mesa_init_driver_functions(&functions);
    r200InitDriverFuncs(&functions);
    r200InitIoctlFuncs(&functions);
-   r200InitStateFuncs(&functions, screen->kernel_mm);
+   r200InitStateFuncs(&functions);
    r200InitTextureFuncs(&functions);
-   r200InitShaderFuncs(&functions); 
+   r200InitShaderFuncs(&functions);
    radeonInitQueryObjFunctions(&functions);
 
    if (!radeonInitContext(&rmesa->radeon, &functions,
@@ -496,7 +496,7 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual,
 }
 
 
-void r200DestroyContext( __DRIcontextPrivate *driContextPriv )
+void r200DestroyContext( __DRIcontext *driContextPriv )
 {
        int i;
        r200ContextPtr rmesa = (r200ContextPtr)driContextPriv->driverPrivate;
index 246f98c6dc5031818bc35e2328164366e51b1a02..17e4d8962eac59cbeb411038f62b7e8422edf295 100644 (file)
@@ -636,14 +636,14 @@ struct r200_context {
 #define R200_CONTEXT(ctx)              ((r200ContextPtr)(ctx->DriverCtx))
 
 
-extern void r200DestroyContext( __DRIcontextPrivate *driContextPriv );
+extern void r200DestroyContext( __DRIcontext *driContextPriv );
 extern GLboolean r200CreateContext( const __GLcontextModes *glVisual,
-                                   __DRIcontextPrivate *driContextPriv,
+                                   __DRIcontext *driContextPriv,
                                    void *sharedContextPrivate);
-extern GLboolean r200MakeCurrent( __DRIcontextPrivate *driContextPriv,
-                                 __DRIdrawablePrivate *driDrawPriv,
-                                 __DRIdrawablePrivate *driReadPriv );
-extern GLboolean r200UnbindContext( __DRIcontextPrivate *driContextPriv );
+extern GLboolean r200MakeCurrent( __DRIcontext *driContextPriv,
+                                 __DRIdrawable *driDrawPriv,
+                                 __DRIdrawable *driReadPriv );
+extern GLboolean r200UnbindContext( __DRIcontext *driContextPriv );
 
 /* ================================================================
  * Debugging:
index b238adb9721e70ac58d936e65e5c035765200e16..66c5d3655a901c2037ed6af6628eaef63a2e64e1 100644 (file)
@@ -61,7 +61,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 static void r200KernelClear(GLcontext *ctx, GLuint flags)
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   __DRIdrawablePrivate *dPriv = radeon_get_drawable(&rmesa->radeon);
+   __DRIdrawable *dPriv = radeon_get_drawable(&rmesa->radeon);
    GLint cx, cy, cw, ch, ret;
    GLuint i;
 
@@ -185,7 +185,7 @@ static void r200KernelClear(GLcontext *ctx, GLuint flags)
 static void r200Clear( GLcontext *ctx, GLbitfield mask )
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   __DRIdrawablePrivate *dPriv = radeon_get_drawable(&rmesa->radeon);
+   __DRIdrawable *dPriv = radeon_get_drawable(&rmesa->radeon);
    GLuint flags = 0;
    GLuint color_mask = 0;
    GLuint orig_mask = mask;
index 383a0c4b0d3ea6c67c3f8ea1d973a77fcec32f4c..249c0bbc11d2ef7236f5d08d786c010ed7a1e8bc 100644 (file)
@@ -90,12 +90,14 @@ static void r200_emit_vecfog(GLcontext *ctx, struct radeon_aos *aos,
        aos->components = size;
        aos->count = count;
 
+       radeon_bo_map(aos->bo, 1);
        out = (uint32_t*)((char*)aos->bo->ptr + aos->offset);
        for (i = 0; i < count; i++) {
          out[0] = r200ComputeFogBlendFactor( ctx, *(GLfloat *)data );
          out++;
          data += stride;
        }
+       radeon_bo_unmap(aos->bo);
 }
 
 /* Emit any changed arrays to new GART memory, re-emit a packet to
index 95773871e025bed2c3652d1c5ce285d43770f281..bfb7e2a2ed3f8370c3ed357fb691e080e456c56c 100644 (file)
@@ -88,10 +88,10 @@ check_color_per_fragment_ops( const GLcontext *ctx )
                    ctx->Fog.Enabled ||
                    ctx->Scissor.Enabled ||
                    ctx->Stencil._Enabled ||
-                   !ctx->Color.ColorMask[0] ||
-                   !ctx->Color.ColorMask[1] ||
-                   !ctx->Color.ColorMask[2] ||
-                   !ctx->Color.ColorMask[3] ||
+                   !ctx->Color.ColorMask[0][0] ||
+                   !ctx->Color.ColorMask[0][1] ||
+                   !ctx->Color.ColorMask[0][2] ||
+                   !ctx->Color.ColorMask[0][3] ||
                    ctx->Color.ColorLogicOpEnabled ||
                    ctx->Texture._EnabledUnits
            ) &&
@@ -214,7 +214,7 @@ r200TryReadPixels( GLcontext *ctx,
    }
 
    {
-      __DRIdrawablePrivate *dPriv = rmesa->radeon.dri.drawable;
+      __DRIdrawable *dPriv = rmesa->radeon.dri.drawable;
       driRenderbuffer *drb = (driRenderbuffer *) ctx->ReadBuffer->_ColorReadBuffer;
       int nbox = dPriv->numClipRects;
       int src_offset = drb->offset
@@ -298,7 +298,7 @@ static void do_draw_pix( GLcontext *ctx,
 
 #if 0
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   __DRIdrawablePrivate *dPriv = radeon_get_drawable(&rmesa->radeon);
+   __DRIdrawable *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;
@@ -400,10 +400,10 @@ r200TryDrawPixels( GLcontext *ctx,
    case GL_RGBA:
    case GL_BGRA:
       planemask = radeonPackColor(cpp,
-                               ctx->Color.ColorMask[RCOMP],
-                               ctx->Color.ColorMask[GCOMP],
-                               ctx->Color.ColorMask[BCOMP],
-                               ctx->Color.ColorMask[ACOMP]);
+                               ctx->Color.ColorMask[0][RCOMP],
+                               ctx->Color.ColorMask[0][GCOMP],
+                               ctx->Color.ColorMask[0][BCOMP],
+                               ctx->Color.ColorMask[0][ACOMP]);
 
       if (cpp == 2)
         planemask |= planemask << 16;
index d28e96d9d9818223860f3a274217c695c6bdbd31..7fe482fe15f4793473e966efbb711fb3b83e7055 100644 (file)
@@ -721,10 +721,10 @@ static void r200ColorMask( GLcontext *ctx,
    if (!rrb)
      return;
    mask = radeonPackColor( rrb->cpp,
-                          ctx->Color.ColorMask[RCOMP],
-                          ctx->Color.ColorMask[GCOMP],
-                          ctx->Color.ColorMask[BCOMP],
-                          ctx->Color.ColorMask[ACOMP] );
+                          ctx->Color.ColorMask[0][RCOMP],
+                          ctx->Color.ColorMask[0][GCOMP],
+                          ctx->Color.ColorMask[0][BCOMP],
+                          ctx->Color.ColorMask[0][ACOMP] );
 
 
    if (!(r && g && b && a))
@@ -1585,7 +1585,7 @@ static void r200ClearStencil( GLcontext *ctx, GLint s )
 void r200UpdateWindow( GLcontext *ctx )
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   __DRIdrawablePrivate *dPriv = radeon_get_drawable(&rmesa->radeon);
+   __DRIdrawable *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;
@@ -1665,7 +1665,7 @@ static void r200DepthRange( GLcontext *ctx, GLclampd nearval,
 void r200UpdateViewportOffset( GLcontext *ctx )
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   __DRIdrawablePrivate *dPriv = radeon_get_drawable(&rmesa->radeon);
+   __DRIdrawable *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;
@@ -2476,7 +2476,7 @@ static void r200PolygonStipple( GLcontext *ctx, const GLubyte *mask )
 }
 /* Initialize the driver's state functions.
  */
-void r200InitStateFuncs( struct dd_function_table *functions, GLboolean dri2 )
+void r200InitStateFuncs( struct dd_function_table *functions )
 {
    functions->UpdateState              = r200InvalidateState;
    functions->LightingSpaceChange      = r200LightingSpaceChange;
@@ -2510,10 +2510,7 @@ void r200InitStateFuncs( struct dd_function_table *functions, GLboolean dri2 )
    functions->LogicOpcode              = r200LogicOpCode;
    functions->PolygonMode              = r200PolygonMode;
    functions->PolygonOffset            = r200PolygonOffset;
-   if (dri2)
-      functions->PolygonStipple                = r200PolygonStipple;
-   else
-      functions->PolygonStipple                = radeonPolygonStipplePreKMS;
+   functions->PolygonStipple           = r200PolygonStipple;
    functions->PointParameterfv         = r200PointParameter;
    functions->PointSize                        = r200PointSize;
    functions->RenderMode               = r200RenderMode;
index 9c62f0a644682d9281b966eed276aed9dc326605..7b9b0c106aa10876d0574bc82fc9a9b928186c0f 100644 (file)
@@ -38,7 +38,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "r200_context.h"
 
 extern void r200InitState( r200ContextPtr rmesa );
-extern void r200InitStateFuncs( struct dd_function_table *functions, GLboolean dri2 );
+extern void r200InitStateFuncs( struct dd_function_table *functions );
 extern void r200InitTnlFuncs( GLcontext *ctx );
 
 extern void r200UpdateMaterial( GLcontext *ctx );
index 7697306d889717f4b2fce053a4fb7bcfb1700cb0..6c5a0b79eed737ff71725a19d8c4b3b1d4739b18 100644 (file)
@@ -529,16 +529,18 @@ static void ctx_emit_cs(GLcontext *ctx, struct radeon_state_atom *atom)
    atom->cmd[CTX_RB3D_CNTL] &= ~(0xf << 10);
    if (rrb->cpp == 4)
        atom->cmd[CTX_RB3D_CNTL] |= RADEON_COLOR_FORMAT_ARGB8888;
-   else switch (rrb->base._ActualFormat) {
-   case GL_RGB5:
+   else switch (rrb->base.Format) {
+   case MESA_FORMAT_RGB565:
        atom->cmd[CTX_RB3D_CNTL] |= RADEON_COLOR_FORMAT_RGB565;
        break;
-   case GL_RGBA4:
+   case MESA_FORMAT_ARGB4444:
        atom->cmd[CTX_RB3D_CNTL] |= RADEON_COLOR_FORMAT_ARGB4444;
        break;
-   case GL_RGB5_A1:
+   case MESA_FORMAT_ARGB1555:
        atom->cmd[CTX_RB3D_CNTL] |= RADEON_COLOR_FORMAT_ARGB1555;
        break;
+   default:
+       _mesa_problem(ctx, "Unexpected format in ctx_emit_cs");
    }
 
    cbpitch = (rrb->pitch / rrb->cpp);
@@ -638,7 +640,7 @@ static void tex_emit(GLcontext *ctx, struct radeon_state_atom *atom)
    OUT_BATCH_TABLE(atom->cmd, 10);
 
    if (t && t->mt && !t->image_override) {
-     OUT_BATCH_RELOC(t->tile_bits, t->mt->bo, 0,
+     OUT_BATCH_RELOC(t->tile_bits, t->mt->bo, get_base_teximage_offset(t),
                  RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0, 0);
    } else if (!t) {
      /* workaround for old CS mechanism */
@@ -885,10 +887,8 @@ void r200InitState( r200ContextPtr rmesa )
          }
       }
    }
-   /* polygon stipple is done with irq for non-kms */
-   if (rmesa->radeon.radeonScreen->kernel_mm) {
-       ALLOC_STATE( stp, always, STP_STATE_SIZE, "STP/stp", 0 );
-   }
+
+   ALLOC_STATE( stp, always, STP_STATE_SIZE, "STP/stp", 0 );
 
    for (i = 0; i < 6; i++)
       if (rmesa->radeon.radeonScreen->kernel_mm)
@@ -1120,12 +1120,11 @@ void r200InitState( r200ContextPtr rmesa )
    rmesa->hw.sci.cmd[SCI_CMD_1] = CP_PACKET0(R200_RE_TOP_LEFT, 0);
    rmesa->hw.sci.cmd[SCI_CMD_2] = CP_PACKET0(R200_RE_WIDTH_HEIGHT, 0);
 
-   if (rmesa->radeon.radeonScreen->kernel_mm) {
-
-       rmesa->hw.stp.cmd[STP_CMD_0] = CP_PACKET0(RADEON_RE_STIPPLE_ADDR, 0);
-       rmesa->hw.stp.cmd[STP_DATA_0] = 0;
-       rmesa->hw.stp.cmd[STP_CMD_1] = CP_PACKET0_ONE(RADEON_RE_STIPPLE_DATA, 31);
+   rmesa->hw.stp.cmd[STP_CMD_0] = CP_PACKET0(RADEON_RE_STIPPLE_ADDR, 0);
+   rmesa->hw.stp.cmd[STP_DATA_0] = 0;
+   rmesa->hw.stp.cmd[STP_CMD_1] = CP_PACKET0_ONE(RADEON_RE_STIPPLE_DATA, 31);
 
+   if (rmesa->radeon.radeonScreen->kernel_mm) {
         rmesa->hw.mtl[0].emit = mtl_emit;
         rmesa->hw.mtl[1].emit = mtl_emit;
 
index 240fb450780b6107542df24a4a28e30a54d2859c..4596912ddc75ed33bf0676b0b9a8134cba026af8 100644 (file)
@@ -168,7 +168,7 @@ static void r200SetVertexFormat( GLcontext *ctx )
 
       for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
         if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX(i) )) {
-           GLuint sz = VB->TexCoordPtr[i]->size;
+           GLuint sz = VB->AttribPtr[_TNL_ATTRIB_TEX0 + i]->size;
 
            fmt_1 |= sz << (3 * i);
            EMIT_ATTR( _TNL_ATTRIB_TEX0+i, EMIT_1F + sz - 1, 0 );
@@ -297,7 +297,7 @@ void r200_swtcl_flush(GLcontext *ctx, uint32_t current_offset)
    radeonEmitState(&rmesa->radeon);
    r200EmitVertexAOS( rmesa,
                      rmesa->radeon.swtcl.vertex_size,
-                     first_elem(&rmesa->radeon.dma.reserved)->bo,
+                     rmesa->radeon.swtcl.bo,
                      current_offset);
 
 
index c702910ef21e2ca061d89b81035084cda91a7b73..e7d48a7f29f1a7299294d5ebf143fddd85b39229 100644 (file)
@@ -509,25 +509,26 @@ static GLboolean r200_run_tcl_render( GLcontext *ctx,
         prog to a not enabled output however, so just don't mess with it.
         We only need to change compsel. */
       GLuint out_compsel = 0;
-      GLuint vp_out = rmesa->curr_vp_hw->mesa_program.Base.OutputsWritten;
+      const GLbitfield64 vp_out =
+        rmesa->curr_vp_hw->mesa_program.Base.OutputsWritten;
 
       vimap_rev = &rmesa->curr_vp_hw->inputmap_rev[0];
-      assert(vp_out & (1 << VERT_RESULT_HPOS));
+      assert(vp_out & BITFIELD64_BIT(VERT_RESULT_HPOS));
       out_compsel = R200_OUTPUT_XYZW;
-      if (vp_out & (1 << VERT_RESULT_COL0)) {
+      if (vp_out & BITFIELD64_BIT(VERT_RESULT_COL0)) {
         out_compsel |= R200_OUTPUT_COLOR_0;
       }
-      if (vp_out & (1 << VERT_RESULT_COL1)) {
+      if (vp_out & BITFIELD64_BIT(VERT_RESULT_COL1)) {
         out_compsel |= R200_OUTPUT_COLOR_1;
       }
-      if (vp_out & (1 << VERT_RESULT_FOGC)) {
+      if (vp_out & BITFIELD64_BIT(VERT_RESULT_FOGC)) {
          out_compsel |= R200_OUTPUT_DISCRETE_FOG;
       }
-      if (vp_out & (1 << VERT_RESULT_PSIZ)) {
+      if (vp_out & BITFIELD64_BIT(VERT_RESULT_PSIZ)) {
         out_compsel |= R200_OUTPUT_PT_SIZE;
       }
       for (i = VERT_RESULT_TEX0; i < VERT_RESULT_TEX6; i++) {
-        if (vp_out & (1 << i)) {
+        if (vp_out & BITFIELD64_BIT(i)) {
            out_compsel |= R200_OUTPUT_TEX_0 << (i - VERT_RESULT_TEX0);
         }
       }
index 36d9e37d8755bdebb18f901b9a89bc6283474170..5b87ba6ccdf39e888e973a120995436828511e4d 100644 (file)
@@ -38,7 +38,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/enums.h"
 #include "main/image.h"
 #include "main/simple_list.h"
-#include "main/texformat.h"
 #include "main/texstore.h"
 #include "main/teximage.h"
 #include "main/texobj.h"
@@ -379,23 +378,14 @@ static void r200TexParameter( GLcontext *ctx, GLenum target,
       break;
 
    case GL_TEXTURE_BORDER_COLOR:
-      r200SetTexBorderColor( t, texObj->BorderColor );
+      r200SetTexBorderColor( t, texObj->BorderColor.f );
       break;
 
    case GL_TEXTURE_BASE_LEVEL:
    case GL_TEXTURE_MAX_LEVEL:
    case GL_TEXTURE_MIN_LOD:
    case GL_TEXTURE_MAX_LOD:
-      /* This isn't the most efficient solution but there doesn't appear to
-       * be a nice alternative.  Since there's no LOD clamping,
-       * we just have to rely on loading the right subset of mipmap levels
-       * to simulate a clamped LOD.
-       */
-      if (t->mt) {
-         radeon_miptree_unreference(t->mt);
-        t->mt = 0;
-        t->validated = GL_FALSE;
-      }
+      t->validated = GL_FALSE;
       break;
 
    default:
@@ -414,7 +404,7 @@ static void r200DeleteTexture(GLcontext * ctx, struct gl_texture_object *texObj)
              (void *)texObj,
              _mesa_lookup_enum_by_nr(texObj->Target));
    }
-   
+
    if (rmesa) {
       int i;
       radeon_firevertices(&rmesa->radeon);
@@ -426,11 +416,9 @@ static void r200DeleteTexture(GLcontext * ctx, struct gl_texture_object *texObj)
         }
       }      
    }
-   
-   if (t->mt) {
-      radeon_miptree_unreference(t->mt);
-      t->mt = 0;
-   }
+
+   radeon_miptree_unreference(&t->mt);
+
    _mesa_delete_texture_object(ctx, texObj);
 }
 
@@ -482,7 +470,7 @@ static struct gl_texture_object *r200NewTextureObject(GLcontext * ctx,
    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);
+   r200SetTexBorderColor(t, t->base.BorderColor.f);
 
    return &t->base;
 }
index c94834752edca6bb5659c47bc1d30f0b6f5f9d97..e2f9cf0ea86f9a03e3f1764682dfb5e59f9cdfe0 100644 (file)
@@ -36,7 +36,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/imports.h"
 #include "main/context.h"
 #include "main/macros.h"
-#include "main/texformat.h"
 #include "main/teximage.h"
 #include "main/texobj.h"
 #include "main/enums.h"
@@ -798,24 +797,13 @@ void r200SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_fo
            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;
-       }
+       radeon_update_renderbuffers(pDRICtx, dPriv, GL_TRUE);
        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);
@@ -825,20 +813,14 @@ void r200SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_fo
                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;
-       }
+
+       radeon_miptree_unreference(&t->mt);
+       radeon_miptree_unreference(&rImage->mt);
+
        _mesa_init_teximage_fields(radeon->glCtx, target, texImage,
                                   rb->base.Width, rb->base.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;
@@ -1426,10 +1408,9 @@ void set_re_cntl_d3d( GLcontext *ctx, int unit, GLboolean use_d3d )
  */
 static void setup_hardware_state(r200ContextPtr rmesa, radeonTexObj *t)
 {
-   int firstlevel = t->mt ? t->mt->firstLevel : 0;
-   const struct gl_texture_image *firstImage = t->base.Image[0][firstlevel];
+   const struct gl_texture_image *firstImage = t->base.Image[0][t->minLod];
    GLint log2Width, log2Height, log2Depth, texelBytes;
-   
+
    if ( t->bo ) {
        return;
    }
@@ -1437,11 +1418,11 @@ static void setup_hardware_state(r200ContextPtr rmesa, radeonTexObj *t)
    log2Width  = firstImage->WidthLog2;
    log2Height = firstImage->HeightLog2;
    log2Depth  = firstImage->DepthLog2;
-   texelBytes = firstImage->TexFormat->TexelBytes;
+   texelBytes = _mesa_get_format_bytes(firstImage->TexFormat);
 
 
    if (!t->image_override) {
-      if (VALID_FORMAT(firstImage->TexFormat->MesaFormat)) {
+      if (VALID_FORMAT(firstImage->TexFormat)) {
         const struct tx_table *table = _mesa_little_endian() ? tx_table_le :
            tx_table_be;
         
@@ -1449,17 +1430,17 @@ static void setup_hardware_state(r200ContextPtr rmesa, radeonTexObj *t)
                             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;
+        t->pp_txformat |= table[ firstImage->TexFormat ].format;
+        t->pp_txfilter |= table[ firstImage->TexFormat ].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_txfilter |= (t->maxLod - t->minLod) << R200_MAX_MIP_LEVEL_SHIFT;
        
    t->pp_txformat &= ~(R200_TXFORMAT_WIDTH_MASK |
                       R200_TXFORMAT_HEIGHT_MASK |
@@ -1504,7 +1485,7 @@ static void setup_hardware_state(r200ContextPtr rmesa, radeonTexObj *t)
                   | ((firstImage->Height - 1) << R200_PP_TX_HEIGHTMASK_SHIFT));
 
    if ( !t->image_override ) {
-      if (firstImage->IsCompressed)
+      if (_mesa_is_format_compressed(firstImage->TexFormat))
          t->pp_txpitch = (firstImage->Width + 63) & ~(63);
       else
          t->pp_txpitch = ((firstImage->Width * texelBytes) + 63) & ~(63);
diff --git a/src/mesa/drivers/dri/r200/radeon_bo.c b/src/mesa/drivers/dri/r200/radeon_bo.c
new file mode 120000 (symlink)
index 0000000..9448ffe
--- /dev/null
@@ -0,0 +1 @@
+../radeon/radeon_bo.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/r200/radeon_bo_int_drm.h b/src/mesa/drivers/dri/r200/radeon_bo_int_drm.h
new file mode 120000 (symlink)
index 0000000..0294509
--- /dev/null
@@ -0,0 +1 @@
+../radeon/radeon_bo_int_drm.h
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/r200/radeon_cs.c b/src/mesa/drivers/dri/r200/radeon_cs.c
new file mode 120000 (symlink)
index 0000000..66b7ad1
--- /dev/null
@@ -0,0 +1 @@
+../radeon/radeon_cs.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/r200/radeon_cs_int_drm.h b/src/mesa/drivers/dri/r200/radeon_cs_int_drm.h
new file mode 120000 (symlink)
index 0000000..462f524
--- /dev/null
@@ -0,0 +1 @@
+../radeon/radeon_cs_int_drm.h
\ No newline at end of file
index c64f940623f9539b2b787a394affd0b1e01f1d22..be005bd1641f3edeac04c52d9f06641f036e9d1b 100644 (file)
@@ -14,7 +14,7 @@ EGL_SOURCES = server/radeon_egl.c
 endif
 
 ifeq ($(RADEON_LDFLAGS),)
-CS_SOURCES = radeon_cs_space_drm.c
+CS_SOURCES = radeon_cs_space_drm.c radeon_bo.c radeon_cs.c
 endif
 
 COMMON_SOURCES = \
@@ -43,13 +43,14 @@ RADEON_COMMON_SOURCES = \
 
 DRIVER_SOURCES = \
                 radeon_screen.c \
+                r300_blit.c \
                 r300_context.c \
                 r300_draw.c \
-                r300_ioctl.c \
                 r300_cmdbuf.c \
                 r300_state.c \
                 r300_render.c \
                 r300_tex.c \
+                r300_texcopy.c \
                 r300_texstate.c \
                 r300_vertprog.c \
                 r300_fragprog_common.c \
@@ -69,16 +70,12 @@ DRIVER_DEFINES = -DRADEON_R300
 
 DRI_LIB_DEPS += $(RADEON_LDFLAGS)
 
-PIPE_DRIVERS =  compiler/libr300compiler.a
+SUBDIRS = compiler
 
-##### TARGETS #####
+EXTRA_MODULES = compiler/libr300compiler.a
 
-include ../Makefile.template
 
-symlinks:
+##### TARGETS #####
 
-# Mark the archive phony so that we always check for recompilation
-.PHONY : compiler/libr300compiler.a
+include ../Makefile.template
 
-compiler/libr300compiler.a:
-       cd compiler && $(MAKE)
index 37aa2b65798bc3b9dc0ddfea4ca332627648158e..76c7c60d8f56b4a2e34d13343b6c2dd97aa35dcf 100644 (file)
@@ -71,12 +71,14 @@ static void refill_pool(struct memory_pool * pool)
 void * memory_pool_malloc(struct memory_pool * pool, unsigned int bytes)
 {
        if (bytes < POOL_LARGE_ALLOC) {
+               void * ptr;
+
                if (pool->head + bytes > pool->end)
                        refill_pool(pool);
 
                assert(pool->head + bytes <= pool->end);
 
-               void * ptr = pool->head;
+               ptr = pool->head;
 
                pool->head += bytes;
                pool->head = (unsigned char*)(((unsigned long)pool->head + POOL_ALIGN - 1) & ~(POOL_ALIGN - 1));
index 1a3d8bb641284352fc86217d9221370352670c20..853b2becd1b6b63d070e109e21b4423fdb3f1592 100644 (file)
@@ -143,7 +143,8 @@ unsigned rc_constants_add_immediate_scalar(struct rc_constant_list * c, float da
 
        for(index = 0; index < c->Count; ++index) {
                if (c->Constants[index].Type == RC_CONSTANT_IMMEDIATE) {
-                       for(unsigned comp = 0; comp < c->Constants[index].Size; ++comp) {
+                       unsigned comp;
+                       for(comp = 0; comp < c->Constants[index].Size; ++comp) {
                                if (c->Constants[index].u.Immediate[comp] == data) {
                                        *swizzle = RC_MAKE_SWIZZLE(comp, comp, comp, comp);
                                        return index;
index 902b7cfa53b791e46e9bdcd84812fe477af09ffd..6d979bbaecf7b17060dc66e426e31b9dcf0dde37 100644 (file)
@@ -59,7 +59,9 @@ enum {
        RC_STATE_SHADOW_AMBIENT = 0,
 
        RC_STATE_R300_WINDOW_DIMENSION,
-       RC_STATE_R300_TEXRECT_FACTOR
+       RC_STATE_R300_TEXRECT_FACTOR,
+       RC_STATE_R300_VIEWPORT_SCALE,
+       RC_STATE_R300_VIEWPORT_OFFSET
 };
 
 struct rc_constant {
index c0e7a7f7a02fcc11e3cb15c0eb52477d3b2445fa..272f9072d4ae19e53d44d8637717b7558e52c3c7 100644 (file)
@@ -229,15 +229,20 @@ void rc_copy_output(struct radeon_compiler * c, unsigned output, unsigned dup_ou
 /**
  * Introduce standard code fragment to deal with fragment.position.
  */
-void rc_transform_fragment_wpos(struct radeon_compiler * c, unsigned wpos, unsigned new_input)
+void rc_transform_fragment_wpos(struct radeon_compiler * c, unsigned wpos, unsigned new_input,
+                                int full_vtransform)
 {
        unsigned tempregi = rc_find_free_temporary(c);
+       struct rc_instruction * inst_rcp;
+       struct rc_instruction * inst_mul;
+       struct rc_instruction * inst_mad;
+       struct rc_instruction * inst;
 
        c->Program.InputsRead &= ~(1 << wpos);
        c->Program.InputsRead |= 1 << new_input;
 
        /* perspective divide */
-       struct rc_instruction * inst_rcp = rc_insert_new_instruction(c, &c->Program.Instructions);
+       inst_rcp = rc_insert_new_instruction(c, &c->Program.Instructions);
        inst_rcp->U.I.Opcode = RC_OPCODE_RCP;
 
        inst_rcp->U.I.DstReg.File = RC_FILE_TEMPORARY;
@@ -248,7 +253,7 @@ void rc_transform_fragment_wpos(struct radeon_compiler * c, unsigned wpos, unsig
        inst_rcp->U.I.SrcReg[0].Index = new_input;
        inst_rcp->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_WWWW;
 
-       struct rc_instruction * inst_mul = rc_insert_new_instruction(c, inst_rcp);
+       inst_mul = rc_insert_new_instruction(c, inst_rcp);
        inst_mul->U.I.Opcode = RC_OPCODE_MUL;
 
        inst_mul->U.I.DstReg.File = RC_FILE_TEMPORARY;
@@ -263,7 +268,7 @@ void rc_transform_fragment_wpos(struct radeon_compiler * c, unsigned wpos, unsig
        inst_mul->U.I.SrcReg[1].Swizzle = RC_SWIZZLE_WWWW;
 
        /* viewport transformation */
-       struct rc_instruction * inst_mad = rc_insert_new_instruction(c, inst_mul);
+       inst_mad = rc_insert_new_instruction(c, inst_mul);
        inst_mad->U.I.Opcode = RC_OPCODE_MAD;
 
        inst_mad->U.I.DstReg.File = RC_FILE_TEMPORARY;
@@ -275,14 +280,19 @@ void rc_transform_fragment_wpos(struct radeon_compiler * c, unsigned wpos, unsig
        inst_mad->U.I.SrcReg[0].Swizzle = RC_MAKE_SWIZZLE(RC_SWIZZLE_X, RC_SWIZZLE_Y, RC_SWIZZLE_Z, RC_SWIZZLE_ZERO);
 
        inst_mad->U.I.SrcReg[1].File = RC_FILE_CONSTANT;
-       inst_mad->U.I.SrcReg[1].Index = rc_constants_add_state(&c->Program.Constants, RC_STATE_R300_WINDOW_DIMENSION, 0);
        inst_mad->U.I.SrcReg[1].Swizzle = RC_MAKE_SWIZZLE(RC_SWIZZLE_X, RC_SWIZZLE_Y, RC_SWIZZLE_Z, RC_SWIZZLE_ZERO);
 
        inst_mad->U.I.SrcReg[2].File = RC_FILE_CONSTANT;
-       inst_mad->U.I.SrcReg[2].Index = inst_mad->U.I.SrcReg[1].Index;
        inst_mad->U.I.SrcReg[2].Swizzle = RC_MAKE_SWIZZLE(RC_SWIZZLE_X, RC_SWIZZLE_Y, RC_SWIZZLE_Z, RC_SWIZZLE_ZERO);
 
-       struct rc_instruction * inst;
+       if (full_vtransform) {
+               inst_mad->U.I.SrcReg[1].Index = rc_constants_add_state(&c->Program.Constants, RC_STATE_R300_VIEWPORT_SCALE, 0);
+               inst_mad->U.I.SrcReg[2].Index = rc_constants_add_state(&c->Program.Constants, RC_STATE_R300_VIEWPORT_OFFSET, 0);
+       } else {
+               inst_mad->U.I.SrcReg[1].Index =
+               inst_mad->U.I.SrcReg[2].Index = rc_constants_add_state(&c->Program.Constants, RC_STATE_R300_WINDOW_DIMENSION, 0);
+       }
+
        for (inst = inst_mad->Next; inst != &c->Program.Instructions; inst = inst->Next) {
                const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->U.I.Opcode);
                unsigned i;
index 87a732cd90d08489a56a98c5790b2bdd2ebe148e..731adc1af2b772085152bee21c7d486f544f9f34 100644 (file)
@@ -73,7 +73,8 @@ void rc_calculate_inputs_outputs(struct radeon_compiler * c);
 void rc_move_input(struct radeon_compiler * c, unsigned input, struct rc_src_register new_input);
 void rc_move_output(struct radeon_compiler * c, unsigned output, unsigned new_output, unsigned writemask);
 void rc_copy_output(struct radeon_compiler * c, unsigned output, unsigned dup_output);
-void rc_transform_fragment_wpos(struct radeon_compiler * c, unsigned wpos, unsigned new_input);
+void rc_transform_fragment_wpos(struct radeon_compiler * c, unsigned wpos, unsigned new_input,
+                                int full_vtransform);
 
 struct r300_fragment_program_compiler {
        struct radeon_compiler Base;
index 828d0c8e28e7f514aa5ef8d12890cf20652478c2..b2fe7f76b2f8c3b42e09e139884cde38975a12a8 100644 (file)
@@ -49,7 +49,7 @@ struct register_info {
 
        unsigned int Used:1;
        unsigned int Allocated:1;
-       rc_register_file File:3;
+       unsigned int File:3;
        unsigned int Index:RC_REGISTER_INDEX_BITS;
 };
 
index 33db3ea0ff8330ed82aa8152dc6a55a913c3c8a2..e31886769655a048a6003bc441dc97adec080164 100644 (file)
@@ -39,7 +39,7 @@
 struct radeon_compiler;
 
 struct rc_src_register {
-       rc_register_file File:3;
+       unsigned int File:3;
 
        /** Negative values may be used for relative addressing. */
        signed int Index:(RC_REGISTER_INDEX_BITS+1);
@@ -55,7 +55,7 @@ struct rc_src_register {
 };
 
 struct rc_dst_register {
-       rc_register_file File:3;
+       unsigned int File:3;
 
        /** Negative values may be used for relative addressing. */
        signed int Index:(RC_REGISTER_INDEX_BITS+1);
@@ -79,20 +79,20 @@ struct rc_sub_instruction {
        /**
         * Opcode of this instruction, according to \ref rc_opcode enums.
         */
-       rc_opcode Opcode:8;
+       unsigned int Opcode:8;
 
        /**
         * Saturate each value of the result to the range [0,1] or [-1,1],
         * according to \ref rc_saturate_mode enums.
         */
-       rc_saturate_mode SaturateMode:2;
+       unsigned int SaturateMode:2;
 
        /**
         * Writing to the special register RC_SPECIAL_ALU_RESULT
         */
        /*@{*/
-       rc_write_aluresult WriteALUResult:2;
-       rc_compare_func ALUResultCompare:3;
+       unsigned int WriteALUResult:2;
+       unsigned int ALUResultCompare:3;
        /*@}*/
 
        /**
@@ -103,7 +103,7 @@ struct rc_sub_instruction {
        unsigned int TexSrcUnit:5;
 
        /** Source texture target, one of the \ref rc_texture_target enums */
-       rc_texture_target TexSrcTarget:3;
+       unsigned int TexSrcTarget:3;
 
        /** True if tex instruction should do shadow comparison */
        unsigned int TexShadow:1;
@@ -191,7 +191,7 @@ struct rc_src_register lmul_swizzle(unsigned int swizzle, struct rc_src_register
 
 static inline void reset_srcreg(struct rc_src_register* reg)
 {
-       memset(reg, 0, sizeof(reg));
+       memset(reg, 0, sizeof(struct rc_src_register));
        reg->Swizzle = RC_SWIZZLE_XYZW;
 }
 
index 0326d252339047c5a791557bd04db228fc929ea4..b5c08aea49e2aa0578c65ce43145f697a649f496 100644 (file)
@@ -267,9 +267,9 @@ static void transform_LIT(struct radeon_compiler* c,
        temp = inst->U.I.DstReg.Index;
        srctemp = srcreg(RC_FILE_TEMPORARY, temp);
 
-       // tmp.x = max(0.0, Src.x);
-       // tmp.y = max(0.0, Src.y);
-       // tmp.w = clamp(Src.z, -128+eps, 128-eps);
+       /* tmp.x = max(0.0, Src.x); */
+       /* tmp.y = max(0.0, Src.y); */
+       /* tmp.w = clamp(Src.z, -128+eps, 128-eps); */
        emit2(c, inst->Prev, RC_OPCODE_MAX, 0,
                dstregtmpmask(temp, RC_MASK_XYW),
                inst->U.I.SrcReg[0],
@@ -280,7 +280,7 @@ static void transform_LIT(struct radeon_compiler* c,
                swizzle(srctemp, RC_SWIZZLE_W, RC_SWIZZLE_W, RC_SWIZZLE_W, RC_SWIZZLE_W),
                negate(srcregswz(RC_FILE_CONSTANT, constant, constant_swizzle)));
 
-       // tmp.w = Pow(tmp.y, tmp.w)
+       /* tmp.w = Pow(tmp.y, tmp.w) */
        emit1(c, inst->Prev, RC_OPCODE_LG2, 0,
                dstregtmpmask(temp, RC_MASK_W),
                swizzle(srctemp, RC_SWIZZLE_Y, RC_SWIZZLE_Y, RC_SWIZZLE_Y, RC_SWIZZLE_Y));
@@ -292,14 +292,14 @@ static void transform_LIT(struct radeon_compiler* c,
                dstregtmpmask(temp, RC_MASK_W),
                swizzle(srctemp, RC_SWIZZLE_W, RC_SWIZZLE_W, RC_SWIZZLE_W, RC_SWIZZLE_W));
 
-       // tmp.z = (tmp.x > 0) ? tmp.w : 0.0
+       /* tmp.z = (tmp.x > 0) ? tmp.w : 0.0 */
        emit3(c, inst->Prev, RC_OPCODE_CMP, inst->U.I.SaturateMode,
                dstregtmpmask(temp, RC_MASK_Z),
                negate(swizzle(srctemp, RC_SWIZZLE_X, RC_SWIZZLE_X, RC_SWIZZLE_X, RC_SWIZZLE_X)),
                swizzle(srctemp, RC_SWIZZLE_W, RC_SWIZZLE_W, RC_SWIZZLE_W, RC_SWIZZLE_W),
                builtin_zero);
 
-       // tmp.x, tmp.y, tmp.w = 1.0, tmp.x, 1.0
+       /* tmp.x, tmp.y, tmp.w = 1.0, tmp.x, 1.0 */
        emit1(c, inst->Prev, RC_OPCODE_MOV, inst->U.I.SaturateMode,
                dstregtmpmask(temp, RC_MASK_XYW),
                swizzle(srctemp, RC_SWIZZLE_ONE, RC_SWIZZLE_X, RC_SWIZZLE_ONE, RC_SWIZZLE_ONE));
@@ -533,16 +533,16 @@ static void sincos_constants(struct radeon_compiler* c, unsigned int *constants)
 {
        static const float SinCosConsts[2][4] = {
                {
-                       1.273239545,            // 4/PI
-                       -0.405284735,           // -4/(PI*PI)
-                       3.141592654,            // PI
-                       0.2225                  // weight
+                       1.273239545,            /* 4/PI */
+                       -0.405284735,           /* -4/(PI*PI) */
+                       3.141592654,            /* PI */
+                       0.2225                  /* weight */
                },
                {
                        0.75,
                        0.5,
-                       0.159154943,            // 1/(2*PI)
-                       6.283185307             // 2*PI
+                       0.159154943,            /* 1/(2*PI) */
+                       6.283185307             /* 2*PI */
                }
        };
        int i;
@@ -560,23 +560,23 @@ static void sincos_constants(struct radeon_compiler* c, unsigned int *constants)
  * MAD dest, tmp.y, weight, tmp.x
  */
 static void sin_approx(
-       struct radeon_compiler* c, struct rc_instruction * before,
+       struct radeon_compiler* c, struct rc_instruction * inst,
        struct rc_dst_register dst, struct rc_src_register src, const unsigned int* constants)
 {
        unsigned int tempreg = rc_find_free_temporary(c);
 
-       emit2(c, before, RC_OPCODE_MUL, 0, dstregtmpmask(tempreg, RC_MASK_XY),
+       emit2(c, inst->Prev, RC_OPCODE_MUL, 0, dstregtmpmask(tempreg, RC_MASK_XY),
                swizzle(src, RC_SWIZZLE_X, RC_SWIZZLE_X, RC_SWIZZLE_X, RC_SWIZZLE_X),
                srcreg(RC_FILE_CONSTANT, constants[0]));
-       emit3(c, before, RC_OPCODE_MAD, 0, dstregtmpmask(tempreg, RC_MASK_X),
+       emit3(c, inst->Prev, RC_OPCODE_MAD, 0, dstregtmpmask(tempreg, RC_MASK_X),
                swizzle(srcreg(RC_FILE_TEMPORARY, tempreg), RC_SWIZZLE_Y, RC_SWIZZLE_Y, RC_SWIZZLE_Y, RC_SWIZZLE_Y),
                absolute(swizzle(src, RC_SWIZZLE_X, RC_SWIZZLE_X, RC_SWIZZLE_X, RC_SWIZZLE_X)),
                swizzle(srcreg(RC_FILE_TEMPORARY, tempreg), RC_SWIZZLE_X, RC_SWIZZLE_X, RC_SWIZZLE_X, RC_SWIZZLE_X));
-       emit3(c, before, RC_OPCODE_MAD, 0, dstregtmpmask(tempreg, RC_MASK_Y),
+       emit3(c, inst->Prev, RC_OPCODE_MAD, 0, dstregtmpmask(tempreg, RC_MASK_Y),
                swizzle(srcreg(RC_FILE_TEMPORARY, tempreg), RC_SWIZZLE_X, RC_SWIZZLE_X, RC_SWIZZLE_X, RC_SWIZZLE_X),
                absolute(swizzle(srcreg(RC_FILE_TEMPORARY, tempreg), RC_SWIZZLE_X, RC_SWIZZLE_X, RC_SWIZZLE_X, RC_SWIZZLE_X)),
                negate(swizzle(srcreg(RC_FILE_TEMPORARY, tempreg), RC_SWIZZLE_X, RC_SWIZZLE_X, RC_SWIZZLE_X, RC_SWIZZLE_X)));
-       emit3(c, before, RC_OPCODE_MAD, 0, dst,
+       emit3(c, inst->Prev, RC_OPCODE_MAD, 0, dst,
                swizzle(srcreg(RC_FILE_TEMPORARY, tempreg), RC_SWIZZLE_Y, RC_SWIZZLE_Y, RC_SWIZZLE_Y, RC_SWIZZLE_Y),
                swizzle(srcreg(RC_FILE_CONSTANT, constants[0]), RC_SWIZZLE_W, RC_SWIZZLE_W, RC_SWIZZLE_W, RC_SWIZZLE_W),
                swizzle(srcreg(RC_FILE_TEMPORARY, tempreg), RC_SWIZZLE_X, RC_SWIZZLE_X, RC_SWIZZLE_X, RC_SWIZZLE_X));
@@ -602,9 +602,9 @@ int radeonTransformTrigSimple(struct radeon_compiler* c,
        sincos_constants(c, constants);
 
        if (inst->U.I.Opcode == RC_OPCODE_COS) {
-               // MAD tmp.x, src, 1/(2*PI), 0.75
-               // FRC tmp.x, tmp.x
-               // MAD tmp.z, tmp.x, 2*PI, -PI
+               /* MAD tmp.x, src, 1/(2*PI), 0.75 */
+               /* FRC tmp.x, tmp.x */
+               /* MAD tmp.z, tmp.x, 2*PI, -PI */
                emit3(c, inst->Prev, RC_OPCODE_MAD, 0, dstregtmpmask(tempreg, RC_MASK_W),
                        swizzle(inst->U.I.SrcReg[0], RC_SWIZZLE_X, RC_SWIZZLE_X, RC_SWIZZLE_X, RC_SWIZZLE_X),
                        swizzle(srcreg(RC_FILE_CONSTANT, constants[1]), RC_SWIZZLE_Z, RC_SWIZZLE_Z, RC_SWIZZLE_Z, RC_SWIZZLE_Z),
index 1600598428771162aa3c085465967a15f0a99f63..6685ade3ea844eea7224264083395530f908f6cf 100644 (file)
@@ -52,12 +52,12 @@ struct r300_fragment_program_compiler;
 
 struct radeon_pair_instruction_source {
        unsigned int Used:1;
-       rc_register_file File:3;
+       unsigned int File:3;
        unsigned int Index:RC_REGISTER_INDEX_BITS;
 };
 
 struct radeon_pair_instruction_rgb {
-       rc_opcode Opcode:8;
+       unsigned int Opcode:8;
        unsigned int DestIndex:RC_REGISTER_INDEX_BITS;
        unsigned int WriteMask:3;
        unsigned int OutputWriteMask:3;
@@ -74,7 +74,7 @@ struct radeon_pair_instruction_rgb {
 };
 
 struct radeon_pair_instruction_alpha {
-       rc_opcode Opcode:8;
+       unsigned int Opcode:8;
        unsigned int DestIndex:RC_REGISTER_INDEX_BITS;
        unsigned int WriteMask:1;
        unsigned int OutputWriteMask:1;
@@ -95,8 +95,8 @@ struct rc_pair_instruction {
        struct radeon_pair_instruction_rgb RGB;
        struct radeon_pair_instruction_alpha Alpha;
 
-       rc_write_aluresult WriteALUResult:2;
-       rc_compare_func ALUResultCompare:3;
+       unsigned int WriteALUResult:2;
+       unsigned int ALUResultCompare:3;
 };
 
 
diff --git a/src/mesa/drivers/dri/r300/r300_blit.c b/src/mesa/drivers/dri/r300/r300_blit.c
new file mode 100644 (file)
index 0000000..ea626d9
--- /dev/null
@@ -0,0 +1,607 @@
+/*
+ * 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.
+ *
+ */
+
+#include "radeon_common.h"
+#include "r300_context.h"
+
+#include "r300_blit.h"
+#include "r300_cmdbuf.h"
+#include "r300_emit.h"
+#include "r300_tex.h"
+#include "compiler/radeon_compiler.h"
+#include "compiler/radeon_opcodes.h"
+
+static void vp_ins_outs(struct r300_vertex_program_compiler *c)
+{
+    c->code->inputs[VERT_ATTRIB_POS] = 0;
+    c->code->inputs[VERT_ATTRIB_TEX0] = 1;
+    c->code->outputs[VERT_RESULT_HPOS] = 0;
+    c->code->outputs[VERT_RESULT_TEX0] = 1;
+}
+
+static void fp_allocate_hw_inputs(
+    struct r300_fragment_program_compiler * c,
+    void (*allocate)(void * data, unsigned input, unsigned hwreg),
+    void * mydata)
+{
+    allocate(mydata, FRAG_ATTRIB_TEX0, 0);
+}
+
+static void create_vertex_program(struct r300_context *r300)
+{
+    struct r300_vertex_program_compiler compiler;
+    struct rc_instruction *inst;
+
+    rc_init(&compiler.Base);
+
+    inst = rc_insert_new_instruction(&compiler.Base, compiler.Base.Program.Instructions.Prev);
+    inst->U.I.Opcode = RC_OPCODE_MOV;
+    inst->U.I.DstReg.File = RC_FILE_OUTPUT;
+    inst->U.I.DstReg.Index = VERT_RESULT_HPOS;
+    inst->U.I.DstReg.RelAddr = 0;
+    inst->U.I.DstReg.WriteMask = RC_MASK_XYZW;
+    inst->U.I.SrcReg[0].Abs = 0;
+    inst->U.I.SrcReg[0].File = RC_FILE_INPUT;
+    inst->U.I.SrcReg[0].Index = VERT_ATTRIB_POS;
+    inst->U.I.SrcReg[0].Negate = 0;
+    inst->U.I.SrcReg[0].RelAddr = 0;
+    inst->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_XYZW;
+
+    inst = rc_insert_new_instruction(&compiler.Base, compiler.Base.Program.Instructions.Prev);
+    inst->U.I.Opcode = RC_OPCODE_MOV;
+    inst->U.I.DstReg.File = RC_FILE_OUTPUT;
+    inst->U.I.DstReg.Index = VERT_RESULT_TEX0;
+    inst->U.I.DstReg.RelAddr = 0;
+    inst->U.I.DstReg.WriteMask = RC_MASK_XYZW;
+    inst->U.I.SrcReg[0].Abs = 0;
+    inst->U.I.SrcReg[0].File = RC_FILE_INPUT;
+    inst->U.I.SrcReg[0].Index = VERT_ATTRIB_TEX0;
+    inst->U.I.SrcReg[0].Negate = 0;
+    inst->U.I.SrcReg[0].RelAddr = 0;
+    inst->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_XYZW;
+
+    compiler.Base.Program.InputsRead = (1 << VERT_ATTRIB_POS) | (1 << VERT_ATTRIB_TEX0);
+    compiler.RequiredOutputs = compiler.Base.Program.OutputsWritten = (1 << VERT_RESULT_HPOS) | (1 << VERT_RESULT_TEX0);
+    compiler.SetHwInputOutput = vp_ins_outs;
+    compiler.code = &r300->blit.vp_code;
+
+    r3xx_compile_vertex_program(&compiler);
+}
+
+static void create_fragment_program(struct r300_context *r300)
+{
+    struct r300_fragment_program_compiler compiler;
+    struct rc_instruction *inst;
+
+    rc_init(&compiler.Base);
+
+    inst = rc_insert_new_instruction(&compiler.Base, compiler.Base.Program.Instructions.Prev);
+    inst->U.I.Opcode = RC_OPCODE_TEX;
+    inst->U.I.TexSrcTarget = RC_TEXTURE_2D;
+    inst->U.I.TexSrcUnit = 0;
+    inst->U.I.DstReg.File = RC_FILE_OUTPUT;
+    inst->U.I.DstReg.Index = FRAG_RESULT_COLOR;
+    inst->U.I.DstReg.WriteMask = RC_MASK_XYZW;
+    inst->U.I.SrcReg[0].Abs = 0;
+    inst->U.I.SrcReg[0].File = RC_FILE_INPUT;
+    inst->U.I.SrcReg[0].Index = FRAG_ATTRIB_TEX0;
+    inst->U.I.SrcReg[0].Negate = 0;
+    inst->U.I.SrcReg[0].RelAddr = 0;
+    inst->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_XYZW;
+
+    compiler.Base.Program.InputsRead = (1 << FRAG_ATTRIB_TEX0);
+    compiler.OutputColor = FRAG_RESULT_COLOR;
+    compiler.OutputDepth = FRAG_RESULT_DEPTH;
+    compiler.is_r500 = (r300->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515);
+    compiler.code = &r300->blit.fp_code;
+    compiler.AllocateHwInputs = fp_allocate_hw_inputs;
+
+    r3xx_compile_fragment_program(&compiler);
+}
+
+void r300_blit_init(struct r300_context *r300)
+{
+    create_vertex_program(r300);
+    create_fragment_program(r300);
+}
+
+static void r300_emit_tx_setup(struct r300_context *r300,
+                               gl_format mesa_format,
+                               struct radeon_bo *bo,
+                               intptr_t offset,
+                               unsigned width,
+                               unsigned height,
+                               unsigned pitch)
+{
+    BATCH_LOCALS(&r300->radeon);
+
+    assert(width <= 2048);
+    assert(height <= 2048);
+    assert(r300TranslateTexFormat(mesa_format) >= 0);
+    assert(offset % 32 == 0);
+
+    BEGIN_BATCH(17);
+    OUT_BATCH_REGVAL(R300_TX_FILTER0_0,
+                     (R300_TX_CLAMP_TO_EDGE  << R300_TX_WRAP_S_SHIFT) |
+                     (R300_TX_CLAMP_TO_EDGE  << R300_TX_WRAP_T_SHIFT) |
+                     (R300_TX_CLAMP_TO_EDGE  << R300_TX_WRAP_R_SHIFT) |
+                     R300_TX_MIN_FILTER_MIP_NONE |
+                     R300_TX_MIN_FILTER_LINEAR |
+                     R300_TX_MAG_FILTER_LINEAR |
+                     (0 << 28));
+    OUT_BATCH_REGVAL(R300_TX_FILTER1_0, 0);
+    OUT_BATCH_REGVAL(R300_TX_SIZE_0,
+                     ((width-1) << R300_TX_WIDTHMASK_SHIFT) |
+                     ((height-1) << R300_TX_HEIGHTMASK_SHIFT) |
+                     (0 << R300_TX_DEPTHMASK_SHIFT) |
+                     (0 << R300_TX_MAX_MIP_LEVEL_SHIFT) |
+                     R300_TX_SIZE_TXPITCH_EN);
+
+    OUT_BATCH_REGVAL(R300_TX_FORMAT_0, r300TranslateTexFormat(mesa_format));
+    OUT_BATCH_REGVAL(R300_TX_FORMAT2_0, pitch - 1);
+    OUT_BATCH_REGSEQ(R300_TX_OFFSET_0, 1);
+    OUT_BATCH_RELOC(0, bo, offset, RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0, 0);
+
+    OUT_BATCH_REGSEQ(R300_TX_INVALTAGS, 2);
+    OUT_BATCH(0);
+    OUT_BATCH(1);
+
+    END_BATCH();
+}
+
+#define EASY_US_FORMAT(FMT, C0, C1, C2, C3, SIGN) \
+    (FMT  | R500_C0_SEL_##C0 | R500_C1_SEL_##C1 | \
+    R500_C2_SEL_##C2 | R500_C3_SEL_##C3 | R500_OUT_SIGN(SIGN))
+
+static uint32_t mesa_format_to_us_format(gl_format mesa_format)
+{
+    switch(mesa_format)
+    {
+        case MESA_FORMAT_S8_Z24:
+        case MESA_FORMAT_X8_Z24:
+        case MESA_FORMAT_RGBA8888: // x
+            return EASY_US_FORMAT(R500_OUT_FMT_C4_8, A, B, G, R, 0);
+        case MESA_FORMAT_RGB565: // x
+        case MESA_FORMAT_ARGB1555: // x
+        case MESA_FORMAT_RGBA8888_REV: // x
+            return EASY_US_FORMAT(R500_OUT_FMT_C4_8, R, G, B, A, 0);
+        case MESA_FORMAT_ARGB8888: // x
+            return EASY_US_FORMAT(R500_OUT_FMT_C4_8, B, G, R, A, 0);
+        case MESA_FORMAT_ARGB8888_REV:
+            return EASY_US_FORMAT(R500_OUT_FMT_C4_8, A, R, G, B, 0);
+        case MESA_FORMAT_XRGB8888:
+            return EASY_US_FORMAT(R500_OUT_FMT_C4_8, A, R, G, B, 0);
+
+        case MESA_FORMAT_RGB332:
+            return EASY_US_FORMAT(R500_OUT_FMT_C_3_3_2, A, R, G, B, 0);
+
+        case MESA_FORMAT_RGBA_FLOAT32:
+            return EASY_US_FORMAT(R500_OUT_FMT_C4_32_FP, R, G, B, A, 0);
+        case MESA_FORMAT_RGBA_FLOAT16:
+            return EASY_US_FORMAT(R500_OUT_FMT_C4_16_FP, R, G, B, A, 0);
+        case MESA_FORMAT_ALPHA_FLOAT32:
+            return EASY_US_FORMAT(R500_OUT_FMT_C_32_FP, A, A, A, A, 0);
+        case MESA_FORMAT_ALPHA_FLOAT16:
+            return EASY_US_FORMAT(R500_OUT_FMT_C_16_FP, A, A, A, A, 0);
+
+        case MESA_FORMAT_SIGNED_RGBA8888:
+            return EASY_US_FORMAT(R500_OUT_FMT_C4_8, R, G, B, A, 0xf);
+        case MESA_FORMAT_SIGNED_RGBA8888_REV:
+            return EASY_US_FORMAT(R500_OUT_FMT_C4_8, A, B, G, R, 0xf);
+        case MESA_FORMAT_SIGNED_RGBA_16:
+            return EASY_US_FORMAT(R500_OUT_FMT_C4_16, R, G, B, A, 0xf);
+
+        default:
+            assert(!"Invalid format for US output\n");
+            return 0;
+    }
+}
+#undef EASY_US_FORMAT
+
+static void r500_emit_fp_setup(struct r300_context *r300,
+                               struct r500_fragment_program_code *fp,
+                               gl_format dst_format)
+{
+    r500_emit_fp(r300, (uint32_t *)fp->inst, (fp->inst_end + 1) * 6, 0, 0, 0);
+    BATCH_LOCALS(&r300->radeon);
+
+    BEGIN_BATCH(10);
+    OUT_BATCH_REGSEQ(R500_US_CODE_ADDR, 3);
+    OUT_BATCH(R500_US_CODE_START_ADDR(0) | R500_US_CODE_END_ADDR(fp->inst_end));
+    OUT_BATCH(R500_US_CODE_RANGE_ADDR(0) | R500_US_CODE_RANGE_SIZE(fp->inst_end));
+    OUT_BATCH(0);
+    OUT_BATCH_REGVAL(R500_US_CONFIG, 0);
+    OUT_BATCH_REGVAL(R500_US_OUT_FMT_0, mesa_format_to_us_format(dst_format));
+    OUT_BATCH_REGVAL(R500_US_PIXSIZE, fp->max_temp_idx);
+    END_BATCH();
+}
+
+static void r500_emit_rs_setup(struct r300_context *r300)
+{
+    BATCH_LOCALS(&r300->radeon);
+
+    BEGIN_BATCH(7);
+    OUT_BATCH_REGSEQ(R300_RS_COUNT, 2);
+    OUT_BATCH((4 << R300_IT_COUNT_SHIFT) | R300_HIRES_EN);
+    OUT_BATCH(0);
+    OUT_BATCH_REGVAL(R500_RS_INST_0,
+                     (0 << R500_RS_INST_TEX_ID_SHIFT) |
+                     (0 << R500_RS_INST_TEX_ADDR_SHIFT) |
+                     R500_RS_INST_TEX_CN_WRITE |
+                     R500_RS_INST_COL_CN_NO_WRITE);
+    OUT_BATCH_REGVAL(R500_RS_IP_0,
+                     (0 << R500_RS_IP_TEX_PTR_S_SHIFT) |
+                     (1 << R500_RS_IP_TEX_PTR_T_SHIFT) |
+                     (2 << R500_RS_IP_TEX_PTR_R_SHIFT) |
+                     (3 << R500_RS_IP_TEX_PTR_Q_SHIFT));
+    END_BATCH();
+}
+
+static void r300_emit_fp_setup(struct r300_context *r300,
+                               struct r300_fragment_program_code *code,
+                               gl_format dst_format)
+{
+    unsigned i;
+    BATCH_LOCALS(&r300->radeon);
+
+    BEGIN_BATCH((code->alu.length + 1) * 4 + code->tex.length + 1 + 11);
+
+    OUT_BATCH_REGSEQ(R300_US_ALU_RGB_INST_0, code->alu.length);
+    for (i = 0; i < code->alu.length; i++) {
+        OUT_BATCH(code->alu.inst[i].rgb_inst);
+    }
+    OUT_BATCH_REGSEQ(R300_US_ALU_RGB_ADDR_0, code->alu.length);
+    for (i = 0; i < code->alu.length; i++) {
+        OUT_BATCH(code->alu.inst[i].rgb_addr);
+    }
+    OUT_BATCH_REGSEQ(R300_US_ALU_ALPHA_INST_0, code->alu.length);
+    for (i = 0; i < code->alu.length; i++) {
+        OUT_BATCH(code->alu.inst[i].alpha_inst);
+    }
+    OUT_BATCH_REGSEQ(R300_US_ALU_ALPHA_ADDR_0, code->alu.length);
+    for (i = 0; i < code->alu.length; i++) {
+        OUT_BATCH(code->alu.inst[i].alpha_addr);
+    }
+
+    OUT_BATCH_REGSEQ(R300_US_TEX_INST_0, code->tex.length);
+    OUT_BATCH_TABLE(code->tex.inst, code->tex.length);
+
+    OUT_BATCH_REGSEQ(R300_US_CONFIG, 3);
+    OUT_BATCH(R300_PFS_CNTL_FIRST_NODE_HAS_TEX);
+    OUT_BATCH(code->pixsize);
+    OUT_BATCH(code->code_offset);
+    OUT_BATCH_REGSEQ(R300_US_CODE_ADDR_0, 4);
+    OUT_BATCH_TABLE(code->code_addr, 4);
+    OUT_BATCH_REGVAL(R500_US_OUT_FMT_0, mesa_format_to_us_format(dst_format));
+    END_BATCH();
+}
+
+static void r300_emit_rs_setup(struct r300_context *r300)
+{
+    BATCH_LOCALS(&r300->radeon);
+
+    BEGIN_BATCH(7);
+    OUT_BATCH_REGSEQ(R300_RS_COUNT, 2);
+    OUT_BATCH((4 << R300_IT_COUNT_SHIFT) | R300_HIRES_EN);
+    OUT_BATCH(0);
+    OUT_BATCH_REGVAL(R300_RS_INST_0,
+                     R300_RS_INST_TEX_ID(0) |
+                     R300_RS_INST_TEX_ADDR(0) |
+                     R300_RS_INST_TEX_CN_WRITE);
+    OUT_BATCH_REGVAL(R300_RS_IP_0,
+                     R300_RS_TEX_PTR(0) |
+                     R300_RS_SEL_S(R300_RS_SEL_C0) |
+                     R300_RS_SEL_T(R300_RS_SEL_C1) |
+                     R300_RS_SEL_R(R300_RS_SEL_K0) |
+                     R300_RS_SEL_Q(R300_RS_SEL_K1));
+    END_BATCH();
+}
+
+static void emit_pvs_setup(struct r300_context *r300,
+                           uint32_t *vp_code,
+                           unsigned vp_len)
+{
+    BATCH_LOCALS(&r300->radeon);
+
+    r300_emit_vpu(r300, vp_code, vp_len * 4, R300_PVS_CODE_START);
+
+    BEGIN_BATCH(4);
+    OUT_BATCH_REGSEQ(R300_VAP_PVS_CODE_CNTL_0, 3);
+    OUT_BATCH((0 << R300_PVS_FIRST_INST_SHIFT) |
+              ((vp_len - 1)  << R300_PVS_XYZW_VALID_INST_SHIFT) |
+              ((vp_len - 1)<< R300_PVS_LAST_INST_SHIFT));
+    OUT_BATCH(0);
+    OUT_BATCH((vp_len - 1) << R300_PVS_LAST_VTX_SRC_INST_SHIFT);
+    END_BATCH();
+}
+
+static void emit_vap_setup(struct r300_context *r300)
+{
+    BATCH_LOCALS(&r300->radeon);
+
+    BEGIN_BATCH(12);
+    OUT_BATCH_REGSEQ(R300_SE_VTE_CNTL, 2);
+    OUT_BATCH(R300_VTX_XY_FMT | R300_VTX_Z_FMT);
+    OUT_BATCH(4);
+
+    OUT_BATCH_REGVAL(R300_VAP_PSC_SGN_NORM_CNTL, 0xaaaaaaaa);
+    OUT_BATCH_REGVAL(R300_VAP_PROG_STREAM_CNTL_0,
+                     ((R300_DATA_TYPE_FLOAT_2 | (0 << R300_DST_VEC_LOC_SHIFT)) << 0) |
+                     (((1 << R300_DST_VEC_LOC_SHIFT) | R300_DATA_TYPE_FLOAT_2 | R300_LAST_VEC) << 16));
+    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_FP_ZERO << R300_SWIZZLE_SELECT_Z_SHIFT) |
+                       (R300_SWIZZLE_SELECT_FP_ONE << R300_SWIZZLE_SELECT_W_SHIFT) | 
+                       (0xf << R300_WRITE_ENA_SHIFT) ) << 0) |
+                     (((R300_SWIZZLE_SELECT_X << R300_SWIZZLE_SELECT_X_SHIFT) |
+                       (R300_SWIZZLE_SELECT_Y << R300_SWIZZLE_SELECT_Y_SHIFT) |
+                       (R300_SWIZZLE_SELECT_FP_ZERO << R300_SWIZZLE_SELECT_Z_SHIFT) |
+                       (R300_SWIZZLE_SELECT_FP_ONE << R300_SWIZZLE_SELECT_W_SHIFT) |
+                       (0xf << R300_WRITE_ENA_SHIFT) ) << 16) ) );
+    OUT_BATCH_REGSEQ(R300_VAP_OUTPUT_VTX_FMT_0, 2);
+    OUT_BATCH(R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT);
+    OUT_BATCH(R300_VAP_OUTPUT_VTX_FMT_1__4_COMPONENTS);
+    END_BATCH();
+}
+
+static GLboolean validate_buffers(struct r300_context *r300,
+                                  struct radeon_bo *src_bo,
+                                  struct radeon_bo *dst_bo)
+{
+    int ret;
+    radeon_cs_space_add_persistent_bo(r300->radeon.cmdbuf.cs,
+                                      src_bo, RADEON_GEM_DOMAIN_VRAM, 0);
+
+    radeon_cs_space_add_persistent_bo(r300->radeon.cmdbuf.cs,
+                                      dst_bo, 0, RADEON_GEM_DOMAIN_VRAM);
+
+    ret = radeon_cs_space_check_with_bo(r300->radeon.cmdbuf.cs,
+                                        first_elem(&r300->radeon.dma.reserved)->bo,
+                                        RADEON_GEM_DOMAIN_GTT, 0);
+    if (ret)
+        return GL_FALSE;
+
+    return GL_TRUE;
+}
+
+/**
+ * Calculate texcoords for given image region.
+ * Output values are [minx, maxx, miny, maxy]
+ */
+static void calc_tex_coords(float img_width, float img_height,
+                            float x, float y,
+                            float reg_width, float reg_height,
+                            unsigned flip_y, float *buf)
+{
+    buf[0] = x / img_width;
+    buf[1] = buf[0] + reg_width / img_width;
+    buf[2] = y / img_height;
+    buf[3] = buf[2] + reg_height / img_height;
+    if (flip_y)
+    {
+        float tmp = buf[2];
+        buf[2] = 1.0 - buf[3];
+        buf[3] = 1.0 - tmp;
+    }
+}
+
+static void emit_draw_packet(struct r300_context *r300,
+                             unsigned src_width, unsigned src_height,
+                             unsigned src_x_offset, unsigned src_y_offset,
+                             unsigned dst_x_offset, unsigned dst_y_offset,
+                             unsigned reg_width, unsigned reg_height,
+                             unsigned flip_y)
+{
+    float texcoords[4];
+
+    calc_tex_coords(src_width, src_height,
+                    src_x_offset, src_y_offset,
+                    reg_width, reg_height,
+                    flip_y, texcoords);
+
+    float verts[] = { dst_x_offset, dst_y_offset,
+                      texcoords[0], texcoords[3],
+                      dst_x_offset, dst_y_offset + reg_height,
+                      texcoords[0], texcoords[2],
+                      dst_x_offset + reg_width, dst_y_offset + reg_height,
+                      texcoords[1], texcoords[2],
+                      dst_x_offset + reg_width, dst_y_offset,
+                      texcoords[1], texcoords[3] };
+
+    BATCH_LOCALS(&r300->radeon);
+
+    BEGIN_BATCH(19);
+    OUT_BATCH_PACKET3(R300_PACKET3_3D_DRAW_IMMD_2, 16);
+    OUT_BATCH(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_EMBEDDED |
+              (4 << 16) | R300_VAP_VF_CNTL__PRIM_QUADS);
+    OUT_BATCH_TABLE(verts, 16);
+    END_BATCH();
+}
+
+static void other_stuff(struct r300_context *r300)
+{
+    BATCH_LOCALS(&r300->radeon);
+
+    BEGIN_BATCH(15);
+    OUT_BATCH_REGVAL(R300_GA_POLY_MODE,
+                     R300_GA_POLY_MODE_FRONT_PTYPE_TRI | R300_GA_POLY_MODE_BACK_PTYPE_TRI);
+    OUT_BATCH_REGVAL(R300_SU_CULL_MODE, R300_FRONT_FACE_CCW);
+    OUT_BATCH_REGVAL(R300_FG_FOG_BLEND, 0);
+    OUT_BATCH_REGVAL(R300_FG_ALPHA_FUNC, 0);
+    OUT_BATCH_REGSEQ(R300_RB3D_CBLEND, 2);
+    OUT_BATCH(0x0);
+    OUT_BATCH(0x0);
+    OUT_BATCH_REGVAL(R300_VAP_CLIP_CNTL, R300_CLIP_DISABLE);
+    OUT_BATCH_REGVAL(R300_ZB_CNTL, 0);
+    END_BATCH();
+}
+
+static void emit_cb_setup(struct r300_context *r300,
+                          struct radeon_bo *bo,
+                          intptr_t offset,
+                          gl_format mesa_format,
+                          unsigned pitch,
+                          unsigned width,
+                          unsigned height)
+{
+    BATCH_LOCALS(&r300->radeon);
+
+    unsigned x1, y1, x2, y2;
+    x1 = 0;
+    y1 = 0;
+    x2 = width - 1;
+    y2 = 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;
+    }
+
+    r300_emit_cb_setup(r300, bo, offset, mesa_format,
+                       _mesa_get_format_bytes(mesa_format),
+                       _mesa_format_row_stride(mesa_format, pitch));
+
+    BEGIN_BATCH_NO_AUTOSTATE(5);
+    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));
+    OUT_BATCH_REGVAL(R300_RB3D_CCTL, 0);
+    END_BATCH();
+}
+
+/**
+ * Copy a region of [@a width x @a height] pixels from source buffer
+ * to destination buffer.
+ * @param[in] r300 r300 context
+ * @param[in] src_bo source radeon buffer object
+ * @param[in] src_offset offset of the source image in the @a src_bo
+ * @param[in] src_mesaformat source image format
+ * @param[in] src_pitch aligned source image width
+ * @param[in] src_width source image width
+ * @param[in] src_height source image height
+ * @param[in] src_x_offset x offset in the source image
+ * @param[in] src_y_offset y offset in the source image
+ * @param[in] dst_bo destination radeon buffer object
+ * @param[in] dst_offset offset of the destination image in the @a dst_bo
+ * @param[in] dst_mesaformat destination image format
+ * @param[in] dst_pitch aligned destination image width
+ * @param[in] dst_width destination image width
+ * @param[in] dst_height destination image height
+ * @param[in] dst_x_offset x offset in the destination image
+ * @param[in] dst_y_offset y offset in the destination image
+ * @param[in] width region width
+ * @param[in] height region height
+ * @param[in] flip_y set if y coords of the source image need to be flipped
+ */
+GLboolean r300_blit(struct r300_context *r300,
+                    struct radeon_bo *src_bo,
+                    intptr_t src_offset,
+                    gl_format src_mesaformat,
+                    unsigned src_pitch,
+                    unsigned src_width,
+                    unsigned src_height,
+                    unsigned src_x_offset,
+                    unsigned src_y_offset,
+                    struct radeon_bo *dst_bo,
+                    intptr_t dst_offset,
+                    gl_format dst_mesaformat,
+                    unsigned dst_pitch,
+                    unsigned dst_width,
+                    unsigned dst_height,
+                    unsigned dst_x_offset,
+                    unsigned dst_y_offset,
+                    unsigned reg_width,
+                    unsigned reg_height,
+                    unsigned flip_y)
+{
+    /* Need to clamp the region size to make sure
+     * we don't read outside of the source buffer
+     * or write outside of the destination buffer.
+     */
+    if (reg_width + src_x_offset > src_width)
+        reg_width = src_width - src_x_offset;
+    if (reg_height + src_y_offset > src_height)
+        reg_height = src_height - src_y_offset;
+    if (reg_width + dst_x_offset > dst_width)
+        reg_width = dst_width - dst_x_offset;
+    if (reg_height + dst_y_offset > dst_height)
+        reg_height = dst_height - dst_y_offset;
+
+    if (src_bo == dst_bo) {
+        return GL_FALSE;
+    }
+
+    if (0) {
+        fprintf(stderr, "src: size [%d x %d], pitch %d, "
+                "offset [%d x %d], format %s, bo %p\n",
+                src_width, src_height, src_pitch,
+                src_offset, src_y_offset,
+                _mesa_get_format_name(src_mesaformat),
+                src_bo);
+        fprintf(stderr, "dst: pitch %d, offset[%d x %d], format %s, bo %p\n",
+                dst_pitch, dst_x_offset, dst_y_offset,
+                _mesa_get_format_name(dst_mesaformat), dst_bo);
+        fprintf(stderr, "region: %d x %d\n", reg_width, reg_height);
+    }
+
+    if (!validate_buffers(r300, src_bo, dst_bo))
+        return GL_FALSE;
+
+    rcommonEnsureCmdBufSpace(&r300->radeon, 200, __FUNCTION__);
+
+    other_stuff(r300);
+
+    r300_emit_tx_setup(r300, src_mesaformat, src_bo, src_offset, src_width, src_height, src_pitch);
+
+    if (r300->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515) {
+        r500_emit_fp_setup(r300, &r300->blit.fp_code.code.r500, dst_mesaformat);
+        r500_emit_rs_setup(r300);
+    } else {
+        r300_emit_fp_setup(r300, &r300->blit.fp_code.code.r300, dst_mesaformat);
+        r300_emit_rs_setup(r300);
+    }
+
+    emit_pvs_setup(r300, r300->blit.vp_code.body.d, 2);
+    emit_vap_setup(r300);
+
+    emit_cb_setup(r300, dst_bo, dst_offset, dst_mesaformat, dst_pitch, dst_width, dst_height);
+
+    emit_draw_packet(r300, src_width, src_height,
+                     src_x_offset, src_y_offset,
+                     dst_x_offset, dst_y_offset,
+                     reg_width, reg_height,
+                     flip_y);
+
+    r300EmitCacheFlush(r300);
+
+    radeonFlush(r300->radeon.glCtx);
+
+    return GL_TRUE;
+}
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/r300/r300_blit.h b/src/mesa/drivers/dri/r300/r300_blit.h
new file mode 100644 (file)
index 0000000..dc21e88
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * 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_BLIT_H
+#define R300_BLIT_H
+
+void r300_blit_init(struct r300_context *r300);
+
+GLboolean r300_blit(struct r300_context *r300,
+                    struct radeon_bo *src_bo,
+                    intptr_t src_offset,
+                    gl_format src_mesaformat,
+                    unsigned src_pitch,
+                    unsigned src_width,
+                    unsigned src_height,
+                    unsigned src_x_offset,
+                    unsigned src_y_offset,
+                    struct radeon_bo *dst_bo,
+                    intptr_t dst_offset,
+                    gl_format dst_mesaformat,
+                    unsigned dst_pitch,
+                    unsigned dst_width,
+                    unsigned dst_height,
+                    unsigned dst_x_offset,
+                    unsigned dst_y_offset,
+                    unsigned width,
+                    unsigned height,
+                    unsigned flip_y);
+
+#endif // R300_BLIT_H
\ No newline at end of file
index da5b7ba642fabc95a95aa48ae16d50362e156185..e1c33bbb2cfba446c8186f3b5f380d4904840d23 100644 (file)
@@ -45,15 +45,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "radeon_drm.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"
 #include "radeon_queryobj.h"
 
 /** # of dwords reserved for additional instructions that may need to be written
@@ -74,7 +71,7 @@ static unsigned packet0_count(r300ContextPtr r300, uint32_t *pkt)
 #define vpu_count(ptr) (((drm_r300_cmd_header_t*)(ptr))->vpu.count)
 #define r500fp_count(ptr) (((drm_r300_cmd_header_t*)(ptr))->r500fp.count)
 
-int check_vpu(GLcontext *ctx, struct radeon_state_atom *atom)
+static int check_vpu(GLcontext *ctx, struct radeon_state_atom *atom)
 {
        r300ContextPtr r300 = R300_CONTEXT(ctx);
        int cnt;
@@ -88,54 +85,73 @@ int check_vpu(GLcontext *ctx, struct radeon_state_atom *atom)
        return cnt ? (cnt * 4) + extra : 0;
 }
 
+void r300_emit_vpu(struct r300_context *r300,
+                   uint32_t *data,
+                   unsigned len,
+                   uint32_t addr)
+{
+    BATCH_LOCALS(&r300->radeon);
+
+    BEGIN_BATCH_NO_AUTOSTATE(5 + len);
+    OUT_BATCH_REGVAL(R300_VAP_PVS_STATE_FLUSH_REG, 0);
+    OUT_BATCH_REGVAL(R300_VAP_PVS_VECTOR_INDX_REG, addr);
+    OUT_BATCH(CP_PACKET0(R300_VAP_PVS_UPLOAD_DATA, len-1) | RADEON_ONE_REG_WR);
+    OUT_BATCH_TABLE(data, len);
+    END_BATCH();
+}
 
-void emit_vpu(GLcontext *ctx, struct radeon_state_atom * atom)
+static void emit_vpu_state(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;
+    r300ContextPtr r300 = R300_CONTEXT(ctx);
+    drm_r300_cmd_header_t cmd;
+    uint32_t addr, ndw;
+
+    cmd.u = atom->cmd[0];
+    addr = (cmd.vpu.adrhi << 8) | cmd.vpu.adrlo;
+    ndw = atom->check(ctx, atom);
 
-       cmd.u = atom->cmd[0];
-       addr = (cmd.vpu.adrhi << 8) | cmd.vpu.adrlo;
-       ndw = atom->check(ctx, atom);
+    r300_emit_vpu(r300, &atom->cmd[1], vpu_count(atom->cmd) * 4, addr);
+}
+
+void r500_emit_fp(struct r300_context *r300,
+                  uint32_t *data,
+                  unsigned len,
+                  uint32_t addr,
+                  unsigned type,
+                  unsigned clamp)
+{
+    BATCH_LOCALS(&r300->radeon);
 
-       BEGIN_BATCH_NO_AUTOSTATE(ndw);
+    addr |= (type << 16);
+    addr |= (clamp << 17);
 
-       ndw -= 5;
-       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);
-       OUT_BATCH_TABLE(&atom->cmd[1], ndw);
-       OUT_BATCH_REGVAL(R300_VAP_PVS_STATE_FLUSH_REG, 0);
-       END_BATCH();
+    BEGIN_BATCH_NO_AUTOSTATE(len + 3);
+    OUT_BATCH(CP_PACKET0(R500_GA_US_VECTOR_INDEX, 0));
+    OUT_BATCH(addr);
+    OUT_BATCH(CP_PACKET0(R500_GA_US_VECTOR_DATA, len-1) | RADEON_ONE_REG_WR);
+    OUT_BATCH_TABLE(data, len);
+    END_BATCH();
 }
 
-void emit_r500fp(GLcontext *ctx, struct radeon_state_atom * atom)
+static void emit_r500fp_atom(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, sz;
-       int type, clamp;
-
-       ndw = atom->check(ctx, atom);
-
-       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);
-
-       addr |= (type << 16);
-       addr |= (clamp << 17);
-
-       BEGIN_BATCH_NO_AUTOSTATE(ndw);
-       OUT_BATCH(CP_PACKET0(R500_GA_US_VECTOR_INDEX, 0));
-       OUT_BATCH(addr);
-       ndw-=3;
-       OUT_BATCH(CP_PACKET0(R500_GA_US_VECTOR_DATA, ndw-1) | RADEON_ONE_REG_WR);
-       OUT_BATCH_TABLE(&atom->cmd[1], ndw);
-       END_BATCH();
+    r300ContextPtr r300 = R300_CONTEXT(ctx);
+    drm_r300_cmd_header_t cmd;
+    uint32_t addr, count;
+    int type, clamp;
+
+    cmd.u = atom->cmd[0];
+    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);
+
+    if (type) {
+        count = r500fp_count(atom->cmd) * 4;
+    } else {
+        count = r500fp_count(atom->cmd) * 6;
+    }
+
+    r500_emit_fp(r300, &atom->cmd[1], count, addr, type, clamp);
 }
 
 static int check_tex_offsets(GLcontext *ctx, struct radeon_state_atom * atom)
@@ -171,7 +187,7 @@ static void emit_tex_offsets(GLcontext *ctx, struct radeon_state_atom * atom)
                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,
+                       OUT_BATCH_RELOC(t->tile_bits, t->mt->bo, get_base_teximage_offset(t),
                                        RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0, 0);
                        END_BATCH();
                } else if (!t) {
@@ -258,93 +274,136 @@ static int check_cb_offset(GLcontext *ctx, struct radeon_state_atom * atom)
        return dw;
 }
 
-static void emit_cb_offset(GLcontext *ctx, struct radeon_state_atom * atom)
+static void emit_scissor(struct r300_context *r300,
+                         unsigned width,
+                         unsigned height)
 {
-       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;
+    int i;
+    BATCH_LOCALS(&r300->radeon);
+    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(((width - 1) << R300_SCISSORS_X_SHIFT) |
+                ((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(((width - 1) << R300_CLIPRECT_X_SHIFT) | ((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(((width + R300_SCISSORS_OFFSET - 1) << R300_SCISSORS_X_SHIFT) |
+                ((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 + width - 1) << R300_CLIPRECT_X_SHIFT) |
+                        ((R300_SCISSORS_OFFSET + 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();
+    }
+}
 
-       rrb = radeon_get_colorbuffer(&r300->radeon);
-       if (!rrb || !rrb->bo) {
-               fprintf(stderr, "no rrb\n");
-               return;
-       }
+void r300_emit_cb_setup(struct r300_context *r300,
+                        struct radeon_bo *bo,
+                        uint32_t offset,
+                        GLuint format,
+                        unsigned cpp,
+                        unsigned pitch)
+{
+    BATCH_LOCALS(&r300->radeon);
+    uint32_t cbpitch = pitch / cpp;
+    uint32_t dw = 6;
+
+    assert(offset % 32 == 0);
+
+    switch (format) {
+        case MESA_FORMAT_RGB565:
+            assert(_mesa_little_endian());
+            cbpitch |= R300_COLOR_FORMAT_RGB565;
+            break;
+        case MESA_FORMAT_RGB565_REV:
+            assert(!_mesa_little_endian());
+            cbpitch |= R300_COLOR_FORMAT_RGB565;
+            break;
+        case MESA_FORMAT_ARGB4444:
+            assert(_mesa_little_endian());
+            cbpitch |= R300_COLOR_FORMAT_ARGB4444;
+            break;
+        case MESA_FORMAT_ARGB4444_REV:
+            assert(!_mesa_little_endian());
+            cbpitch |= R300_COLOR_FORMAT_ARGB4444;
+            break;
+        case MESA_FORMAT_ARGB1555:
+            assert(_mesa_little_endian());
+            cbpitch |= R300_COLOR_FORMAT_ARGB1555;
+            break;
+        case MESA_FORMAT_ARGB1555_REV:
+            assert(!_mesa_little_endian());
+            cbpitch |= R300_COLOR_FORMAT_ARGB1555;
+            break;
+        default:
+            if (cpp == 4) {
+                cbpitch |= R300_COLOR_FORMAT_ARGB8888;
+            } else {
+                _mesa_problem(r300->radeon.glCtx, "unexpected format in emit_cb_offset()");;
+            }
+            break;
+    }
 
-        if (RADEON_DEBUG & RADEON_STATE)
-           fprintf(stderr,"rrb is %p %d %dx%d\n", rrb, offset, rrb->base.Width, rrb->base.Height);
-       cbpitch = (rrb->pitch / rrb->cpp);
-       if (rrb->cpp == 4)
-               cbpitch |= R300_COLOR_FORMAT_ARGB8888;
-       else switch (rrb->base._ActualFormat) {
-       case GL_RGB5:
-               cbpitch |= R300_COLOR_FORMAT_RGB565;
-               break;
-       case GL_RGBA4:
-               cbpitch |= R300_COLOR_FORMAT_ARGB4444;
-               break;
-       case GL_RGB5_A1:
-               cbpitch |= R300_COLOR_FORMAT_ARGB1555;
-               break;
-       }
+    if (bo->flags & RADEON_BO_FLAGS_MACRO_TILE)
+        cbpitch |= R300_COLOR_TILE_ENABLE;
 
-       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, 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, bo, cbpitch, 0, RADEON_GEM_DOMAIN_VRAM, 0);
+    END_BATCH();
+}
+
+static void emit_cb_offset_atom(GLcontext *ctx, struct radeon_state_atom * atom)
+{
+    r300ContextPtr r300 = R300_CONTEXT(ctx);
+    struct radeon_renderbuffer *rrb;
+    uint32_t offset = r300->radeon.state.color.draw_offset;
+
+    rrb = radeon_get_colorbuffer(&r300->radeon);
+    if (!rrb || !rrb->bo) {
+        fprintf(stderr, "no rrb\n");
+        return;
+    }
+
+    if (RADEON_DEBUG & RADEON_STATE)
+        fprintf(stderr,"rrb is %p %d %dx%d\n", rrb, offset, rrb->base.Width, rrb->base.Height);
+
+    r300_emit_cb_setup(r300, rrb->bo, offset, rrb->base.Format, rrb->cpp, rrb->pitch);
 
-       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->base.Width - 1) << R300_SCISSORS_X_SHIFT) |
-                    ((rrb->base.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->base.Width - 1) << R300_CLIPRECT_X_SHIFT) | ((rrb->base.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->base.Width + R300_SCISSORS_OFFSET - 1) << R300_SCISSORS_X_SHIFT) |
-                    ((rrb->base.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->base.Width - 1) << R300_CLIPRECT_X_SHIFT) |
-                          ((R300_SCISSORS_OFFSET + rrb->base.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();
-        }
+        emit_scissor(r300, rrb->base.Width, rrb->base.Height);
     }
 }
 
@@ -440,7 +499,7 @@ static int check_variable(GLcontext *ctx, struct radeon_state_atom *atom)
        return cnt ? cnt + 1 : 0;
 }
 
-int check_r500fp(GLcontext *ctx, struct radeon_state_atom *atom)
+static int check_r500fp(GLcontext *ctx, struct radeon_state_atom *atom)
 {
        int cnt;
        r300ContextPtr r300 = R300_CONTEXT(ctx);
@@ -452,7 +511,7 @@ int check_r500fp(GLcontext *ctx, struct radeon_state_atom *atom)
        return cnt ? (cnt * 6) + extra : 0;
 }
 
-int check_r500fp_const(GLcontext *ctx, struct radeon_state_atom *atom)
+static int check_r500fp_const(GLcontext *ctx, struct radeon_state_atom *atom)
 {
        int cnt;
        r300ContextPtr r300 = R300_CONTEXT(ctx);
@@ -629,13 +688,13 @@ void r300InitCmdBuf(r300ContextPtr r300)
                r300->hw.r500fp.cmd[R300_FPI_CMD_0] =
                        cmdr500fp(r300->radeon.radeonScreen, 0, 0, 0, 0);
                if (r300->radeon.radeonScreen->kernel_mm)
-                       r300->hw.r500fp.emit = emit_r500fp;
+                       r300->hw.r500fp.emit = emit_r500fp_atom;
 
                ALLOC_STATE(r500fp_const, r500fp_const, R500_FPP_CMDSIZE, 0);
                r300->hw.r500fp_const.cmd[R300_FPI_CMD_0] =
                        cmdr500fp(r300->radeon.radeonScreen, 0, 0, 1, 0);
                if (r300->radeon.radeonScreen->kernel_mm)
-                       r300->hw.r500fp_const.emit = emit_r500fp;
+                       r300->hw.r500fp_const.emit = emit_r500fp_atom;
        } else {
                ALLOC_STATE(fp, always, R300_FP_CMDSIZE, 0);
                r300->hw.fp.cmd[R300_FP_CMD_0] = cmdpacket0(r300->radeon.radeonScreen, R300_US_CONFIG, 3);
@@ -679,7 +738,7 @@ void r300InitCmdBuf(r300ContextPtr r300)
        ALLOC_STATE(rop, always, 2, 0);
        r300->hw.rop.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, R300_RB3D_ROPCNTL, 1);
        ALLOC_STATE(cb, cb_offset, R300_CB_CMDSIZE, 0);
-       r300->hw.cb.emit = &emit_cb_offset;
+       r300->hw.cb.emit = &emit_cb_offset_atom;
        ALLOC_STATE(rb3d_dither_ctl, always, 10, 0);
        r300->hw.rb3d_dither_ctl.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, R300_RB3D_DITHER_CTL, 9);
        ALLOC_STATE(rb3d_aaresolve_ctl, always, 2, 0);
@@ -743,20 +802,20 @@ void r300InitCmdBuf(r300ContextPtr r300)
                r300->hw.vpi.cmd[0] =
                        cmdvpu(r300->radeon.radeonScreen, R300_PVS_CODE_START, 0);
                if (r300->radeon.radeonScreen->kernel_mm)
-                       r300->hw.vpi.emit = emit_vpu;
+                       r300->hw.vpi.emit = emit_vpu_state;
 
                if (is_r500) {
                        ALLOC_STATE(vpp, vpu, R300_VPP_CMDSIZE, 0);
                        r300->hw.vpp.cmd[0] =
                                cmdvpu(r300->radeon.radeonScreen, R500_PVS_CONST_START, 0);
                        if (r300->radeon.radeonScreen->kernel_mm)
-                               r300->hw.vpp.emit = emit_vpu;
+                               r300->hw.vpp.emit = emit_vpu_state;
 
                        ALLOC_STATE(vps, vpu, R300_VPS_CMDSIZE, 0);
                        r300->hw.vps.cmd[0] =
                                cmdvpu(r300->radeon.radeonScreen, R500_POINT_VPORT_SCALE_OFFSET, 1);
                        if (r300->radeon.radeonScreen->kernel_mm)
-                               r300->hw.vps.emit = emit_vpu;
+                               r300->hw.vps.emit = emit_vpu_state;
 
                        for (i = 0; i < 6; i++) {
                                ALLOC_STATE(vpucp[i], vpu, R300_VPUCP_CMDSIZE, 0);
@@ -764,20 +823,20 @@ void r300InitCmdBuf(r300ContextPtr r300)
                                        cmdvpu(r300->radeon.radeonScreen,
                                                        R500_PVS_UCP_START + i, 1);
                                if (r300->radeon.radeonScreen->kernel_mm)
-                                       r300->hw.vpucp[i].emit = emit_vpu;
+                                       r300->hw.vpucp[i].emit = emit_vpu_state;
                        }
                } else {
                        ALLOC_STATE(vpp, vpu, R300_VPP_CMDSIZE, 0);
                        r300->hw.vpp.cmd[0] =
                                cmdvpu(r300->radeon.radeonScreen, R300_PVS_CONST_START, 0);
                        if (r300->radeon.radeonScreen->kernel_mm)
-                               r300->hw.vpp.emit = emit_vpu;
+                               r300->hw.vpp.emit = emit_vpu_state;
 
                        ALLOC_STATE(vps, vpu, R300_VPS_CMDSIZE, 0);
                        r300->hw.vps.cmd[0] =
                                cmdvpu(r300->radeon.radeonScreen, R300_POINT_VPORT_SCALE_OFFSET, 1);
                        if (r300->radeon.radeonScreen->kernel_mm)
-                               r300->hw.vps.emit = emit_vpu;
+                               r300->hw.vps.emit = emit_vpu_state;
 
                        for (i = 0; i < 6; i++) {
                                ALLOC_STATE(vpucp[i], vpu, R300_VPUCP_CMDSIZE, 0);
@@ -785,7 +844,7 @@ void r300InitCmdBuf(r300ContextPtr r300)
                                        cmdvpu(r300->radeon.radeonScreen,
                                                        R300_PVS_UCP_START + i, 1);
                                if (r300->radeon.radeonScreen->kernel_mm)
-                                       r300->hw.vpucp[i].emit = emit_vpu;
+                                       r300->hw.vpucp[i].emit = emit_vpu_state;
                        }
                }
        }
index 1b703e518a0c403196553c27de42e7bf7d5c8201..0e68da928ed51122ddb81487633b3e02b375fb73 100644 (file)
@@ -44,14 +44,26 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define FIREAOS_BUFSZ          (3)
 #define SCISSORS_BUFSZ         (3)
 
-extern void r300InitCmdBuf(r300ContextPtr r300);
+void r300InitCmdBuf(r300ContextPtr r300);
 void r300_emit_scissor(GLcontext *ctx);
 
-void emit_vpu(GLcontext *ctx, struct radeon_state_atom * atom);
-int check_vpu(GLcontext *ctx, struct radeon_state_atom *atom);
+void r300_emit_vpu(struct r300_context *ctx,
+                   uint32_t *data,
+                   unsigned len,
+                   uint32_t addr);
 
-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);
+void r500_emit_fp(struct r300_context *r300,
+                  uint32_t *data,
+                  unsigned len,
+                  uint32_t addr,
+                  unsigned type,
+                  unsigned clamp);
 
-#endif                         /* __R300_CMDBUF_H__ */
+void r300_emit_cb_setup(struct r300_context *r300,
+                        struct radeon_bo *bo,
+                        uint32_t offset,
+                        GLuint format,
+                        unsigned cpp,
+                        unsigned pitch);
+
+#endif /* __R300_CMDBUF_H__ */
index 2c2b16aa98dc60d0e25df6516d4be5b5af3657c5..1f6ccf6ddca93e37dd678a55a3160f5745a9236e 100644 (file)
@@ -55,13 +55,14 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "tnl/t_vp_build.h"
 
 #include "drivers/common/driverfuncs.h"
+#include "drivers/common/meta.h"
 
 #include "r300_context.h"
 #include "radeon_context.h"
 #include "radeon_span.h"
+#include "r300_blit.h"
 #include "r300_cmdbuf.h"
 #include "r300_state.h"
-#include "r300_ioctl.h"
 #include "r300_tex.h"
 #include "r300_emit.h"
 #include "r300_swtcl.h"
@@ -90,10 +91,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define need_GL_ATI_separate_stencil
 #define need_GL_NV_vertex_program
 
-#include "extension_helper.h"
+#include "main/remap_helper.h"
 
+void r300_init_texcopy_functions(struct dd_function_table *table);
 
-const struct dri_extension card_extensions[] = {
+static const struct dri_extension card_extensions[] = {
   /* *INDENT-OFF* */
   {"GL_ARB_depth_texture",             NULL},
   {"GL_ARB_fragment_program",          NULL},
@@ -145,7 +147,7 @@ const struct dri_extension card_extensions[] = {
 };
 
 
-const struct dri_extension mm_extensions[] = {
+static const struct dri_extension mm_extensions[] = {
   { "GL_EXT_framebuffer_blit", GL_EXT_framebuffer_blit_functions },
   { "GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions },
   { NULL, NULL }
@@ -155,7 +157,7 @@ const struct dri_extension mm_extensions[] = {
  * The GL 2.0 functions are needed to make display lists work with
  * functions added by GL_ATI_separate_stencil.
  */
-const struct dri_extension gl_20_extension[] = {
+static const struct dri_extension gl_20_extension[] = {
   {"GL_VERSION_2_0",                   GL_VERSION_2_0_functions },
 };
 
@@ -439,11 +441,11 @@ static void r300InitGLExtensions(GLcontext *ctx)
        if (r300->options.stencil_two_side_disabled)
                _mesa_disable_extension(ctx, "GL_EXT_stencil_two_side");
 
-       if (r300->options.s3tc_force_enabled) {
+       if (r300->options.s3tc_force_disabled) {
+               _mesa_disable_extension(ctx, "GL_EXT_texture_compression_s3tc");
+       } else 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");
        }
 
        if (!r300->radeon.radeonScreen->drmSupportsOcclusionQueries) {
@@ -451,13 +453,20 @@ static void r300InitGLExtensions(GLcontext *ctx)
        }
 }
 
+static void r300InitIoctlFuncs(struct dd_function_table *functions)
+{
+       functions->Clear = _mesa_meta_Clear;
+       functions->Finish = radeonFinish;
+       functions->Flush = radeonFlush;
+}
+
 /* Create the device specific rendering context.
  */
 GLboolean r300CreateContext(const __GLcontextModes * glVisual,
-                           __DRIcontextPrivate * driContextPriv,
+                           __DRIcontext * driContextPriv,
                            void *sharedContextPrivate)
 {
-       __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+       __DRIscreen *sPriv = driContextPriv->driScreenPriv;
        radeonScreenPtr screen = (radeonScreenPtr) (sPriv->private);
        struct dd_function_table functions;
        r300ContextPtr r300;
@@ -484,6 +493,10 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
        radeonInitQueryObjFunctions(&functions);
        radeonInitBufferObjectFuncs(&functions);
 
+       if (r300->radeon.radeonScreen->kernel_mm) {
+               r300_init_texcopy_functions(&functions);
+       }
+
        if (!radeonInitContext(&r300->radeon, &functions,
                               glVisual, driContextPriv,
                               sharedContextPrivate)) {
@@ -530,6 +543,7 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
                r300InitSwtcl(ctx);
        }
 
+       r300_blit_init(r300);
        radeon_fbo_init(&r300->radeon);
        radeonInitSpanFuncs( ctx );
        r300InitCmdBuf(r300);
index 518d5cdbf4f5908a93ecc61091d9e81e411f70a0..546cd8ddde37b53e286bfbb26ead254840bb46a5 100644 (file)
@@ -533,14 +533,19 @@ struct r300_context {
 
        uint32_t fallback;
 
+       struct {
+               struct r300_vertex_program_code vp_code;
+               struct rX00_fragment_program_code fp_code;
+       } blit;
+
        DECLARE_RENDERINPUTS(render_inputs_bitset);
 };
 
 #define R300_CONTEXT(ctx)              ((r300ContextPtr)(ctx->DriverCtx))
 
-extern void r300DestroyContext(__DRIcontextPrivate * driContextPriv);
+extern void r300DestroyContext(__DRIcontext * driContextPriv);
 extern GLboolean r300CreateContext(const __GLcontextModes * glVisual,
-                                  __DRIcontextPrivate * driContextPriv,
+                                  __DRIcontext * driContextPriv,
                                   void *sharedContextPrivate);
 
 extern void r300InitShaderFuncs(struct dd_function_table *functions);
@@ -549,6 +554,8 @@ extern void r300InitShaderFunctions(r300ContextPtr r300);
 
 extern void r300InitDraw(GLcontext *ctx);
 
+extern void r300_init_texcopy_functions(struct dd_function_table *table);
+
 #define r300PackFloat32 radeonPackFloat32
 #define r300PackFloat24 radeonPackFloat24
 
index e9968f9ffeffb8d958ac9f1245e8cd41e196c4b8..3dcd986e2267f3ae09abc6342e0efaa30dbe4456 100644 (file)
@@ -100,7 +100,7 @@ static void r300FixupIndexBuffer(GLcontext *ctx, const struct _mesa_index_buffer
                GLubyte *in = (GLubyte *)src_ptr;
 
                radeonAllocDmaRegion(&r300->radeon, &r300->ind_buf.bo, &r300->ind_buf.bo_offset, size, 4);
-
+               radeon_bo_map(r300->ind_buf.bo, 1);
                assert(r300->ind_buf.bo->ptr != NULL);
                out = (GLuint *)ADD_POINTERS(r300->ind_buf.bo->ptr, r300->ind_buf.bo_offset);
 
@@ -111,7 +111,7 @@ static void r300FixupIndexBuffer(GLcontext *ctx, const struct _mesa_index_buffer
                if (i < mesa_ind_buf->count) {
                        *out++ = in[i];
                }
-
+               radeon_bo_unmap(r300->ind_buf.bo);
 #if MESA_BIG_ENDIAN
        } else { /* if (mesa_ind_buf->type == GL_UNSIGNED_SHORT) */
                GLushort *in = (GLushort *)src_ptr;
@@ -120,6 +120,7 @@ static void r300FixupIndexBuffer(GLcontext *ctx, const struct _mesa_index_buffer
                radeonAllocDmaRegion(&r300->radeon, &r300->ind_buf.bo,
                                     &r300->ind_buf.bo_offset, size, 4);
 
+               radeon_bo_map(r300->ind_buf.bo, 1);
                assert(r300->ind_buf.bo->ptr != NULL);
                out = (GLuint *)ADD_POINTERS(r300->ind_buf.bo->ptr, r300->ind_buf.bo_offset);
 
@@ -130,6 +131,7 @@ static void r300FixupIndexBuffer(GLcontext *ctx, const struct _mesa_index_buffer
                if (i < mesa_ind_buf->count) {
                        *out++ = in[i];
                }
+               radeon_bo_unmap(r300->ind_buf.bo);
 #endif
        }
 
@@ -173,10 +175,12 @@ static void r300SetupIndexBuffer(GLcontext *ctx, const struct _mesa_index_buffer
 
                radeonAllocDmaRegion(&r300->radeon, &r300->ind_buf.bo, &r300->ind_buf.bo_offset, size, 4);
 
+               radeon_bo_map(r300->ind_buf.bo, 1);
                assert(r300->ind_buf.bo->ptr != NULL);
                dst_ptr = ADD_POINTERS(r300->ind_buf.bo->ptr, r300->ind_buf.bo_offset);
                _mesa_memcpy(dst_ptr, src_ptr, size);
 
+               radeon_bo_unmap(r300->ind_buf.bo);
                r300->ind_buf.is_32bit = (mesa_ind_buf->type == GL_UNSIGNED_INT);
                r300->ind_buf.count = mesa_ind_buf->count;
 
@@ -242,6 +246,7 @@ static void r300ConvertAttrib(GLcontext *ctx, int count, const struct gl_client_
        }
 
        radeonAllocDmaRegion(&r300->radeon, &attr->bo, &attr->bo_offset, sizeof(GLfloat) * input->Size * count, 32);
+       radeon_bo_map(attr->bo, 1);
        dst_ptr = (GLfloat *)ADD_POINTERS(attr->bo->ptr, attr->bo_offset);
 
        radeon_print(RADEON_FALLBACKS, RADEON_IMPORTANT,
@@ -280,6 +285,7 @@ static void r300ConvertAttrib(GLcontext *ctx, int count, const struct gl_client_
                        break;
        }
 
+       radeon_bo_unmap(attr->bo);
        if (mapped_named_bo) {
                ctx->Driver.UnmapBuffer(ctx, GL_ARRAY_BUFFER, input->BufferObj);
        }
@@ -294,6 +300,8 @@ static void r300AlignDataToDword(GLcontext *ctx, const struct gl_client_array *i
 
        radeonAllocDmaRegion(&r300->radeon, &attr->bo, &attr->bo_offset, size, 32);
 
+       radeon_bo_map(attr->bo, 1);
+
        if (!input->BufferObj->Pointer) {
                ctx->Driver.MapBuffer(ctx, GL_ARRAY_BUFFER, GL_READ_ONLY_ARB, input->BufferObj);
                mapped_named_bo = GL_TRUE;
@@ -317,6 +325,7 @@ static void r300AlignDataToDword(GLcontext *ctx, const struct gl_client_array *i
                ctx->Driver.UnmapBuffer(ctx, GL_ARRAY_BUFFER, input->BufferObj);
        }
 
+       radeon_bo_unmap(attr->bo);
        attr->stride = dst_stride;
 }
 
@@ -527,6 +536,7 @@ static void r300AllocDmaRegions(GLcontext *ctx, const struct gl_client_array *in
                                }
 
                                radeonAllocDmaRegion(&r300->radeon, &vbuf->attribs[index].bo, &vbuf->attribs[index].bo_offset, size, 32);
+                               radeon_bo_map(vbuf->attribs[index].bo, 1);
                                assert(vbuf->attribs[index].bo->ptr != NULL);
                                dst = (uint32_t *)ADD_POINTERS(vbuf->attribs[index].bo->ptr, vbuf->attribs[index].bo_offset);
                                switch (vbuf->attribs[index].dwords) {
@@ -536,6 +546,7 @@ static void r300AllocDmaRegions(GLcontext *ctx, const struct gl_client_array *in
                                        case 4: radeonEmitVec16(dst, input[i]->Ptr, input[i]->StrideB, local_count); break;
                                        default: assert(0); break;
                                }
+                               radeon_bo_unmap(vbuf->attribs[index].bo);
 
                        }
                }
index 07e62230874cd462727764f769aaca20512e8e8f..15aeaf051480f40554de4a1958e7309c5eac3b7b 100644 (file)
@@ -49,7 +49,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "r300_context.h"
 #include "r300_state.h"
 #include "r300_emit.h"
-#include "r300_ioctl.h"
 #include "r300_render.h"
 #include "r300_swtcl.h"
 
@@ -118,7 +117,7 @@ GLuint r300VAPOutputCntl1(GLcontext * ctx, GLuint vp_writes)
 
        if (first_free_texcoord > 8) {
                fprintf(stderr, "\tout of free texcoords\n");
-               _mesa_exit(-1);
+               exit(-1);
        }
 
        return ret;
index 8e57e354d1dc2e11bf9cbebfdfc3f5c78d9396b8..a456d8867c4aaaa92d9b72dcb8a3708d49727b58 100644 (file)
@@ -42,7 +42,6 @@
 #include "main/glheader.h"
 #include "r300_context.h"
 #include "r300_cmdbuf.h"
-#include "radeon_reg.h"
 
 static INLINE uint32_t cmdpacket0(struct radeon_screen *rscrn,
                                   int reg, int count)
index 267ee81a7a6a1b04fe099794cb7a833c07827f02..2933d31136c400ce8f86b3d2052c27e1fadad3d3 100644 (file)
@@ -120,7 +120,7 @@ static void insert_WPOS_trailer(struct r300_fragment_program_compiler *compiler,
                return;
        }
 
-       rc_transform_fragment_wpos(&compiler->Base, FRAG_ATTRIB_WPOS, fp->wpos_attr);
+       rc_transform_fragment_wpos(&compiler->Base, FRAG_ATTRIB_WPOS, fp->wpos_attr, GL_FALSE);
 }
 
 /**
diff --git a/src/mesa/drivers/dri/r300/r300_ioctl.c b/src/mesa/drivers/dri/r300/r300_ioctl.c
deleted file mode 100644 (file)
index 5cb04e2..0000000
+++ /dev/null
@@ -1,782 +0,0 @@
-/*
-Copyright (C) The Weather Channel, Inc.  2002.
-Copyright (C) 2004 Nicolai Haehnle.
-All Rights Reserved.
-
-The Weather Channel (TM) funded Tungsten Graphics to develop the
-initial release of the Radeon 8500 driver under the XFree86 license.
-This notice must be preserved.
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial
-portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/**
- * \file
- *
- * \author Keith Whitwell <keith@tungstengraphics.com>
- *
- * \author Nicolai Haehnle <prefect_@gmx.net>
- */
-
-#include <sched.h>
-#include <errno.h>
-
-#include "main/glheader.h"
-#include "main/imports.h"
-#include "main/macros.h"
-#include "main/context.h"
-#include "main/simple_list.h"
-#include "swrast/swrast.h"
-
-#include "radeon_common.h"
-#include "radeon_lock.h"
-#include "r300_context.h"
-#include "r300_ioctl.h"
-#include "r300_cmdbuf.h"
-#include "r300_state.h"
-#include "r300_vertprog.h"
-#include "radeon_reg.h"
-#include "r300_emit.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
-
-#if 1
-
-/**
- * Fragment program helper macros
- */
-
-/* Produce unshifted source selectors */
-#define FP_TMP(idx) (idx)
-#define FP_CONST(idx) ((idx) | (1 << 5))
-
-/* Produce source/dest selector dword */
-#define FP_SELC_MASK_NO                0
-#define FP_SELC_MASK_X         1
-#define FP_SELC_MASK_Y         2
-#define FP_SELC_MASK_XY                3
-#define FP_SELC_MASK_Z         4
-#define FP_SELC_MASK_XZ                5
-#define FP_SELC_MASK_YZ                6
-#define FP_SELC_MASK_XYZ       7
-
-#define FP_SELC(destidx,regmask,outmask,src0,src1,src2) \
-       (((destidx) << R300_ALU_DSTC_SHIFT) |           \
-        (FP_SELC_MASK_##regmask << 23) |               \
-        (FP_SELC_MASK_##outmask << 26) |               \
-        ((src0) << R300_ALU_SRC0C_SHIFT) |             \
-        ((src1) << R300_ALU_SRC1C_SHIFT) |             \
-        ((src2) << R300_ALU_SRC2C_SHIFT))
-
-#define FP_SELA_MASK_NO                0
-#define FP_SELA_MASK_W         1
-
-#define FP_SELA(destidx,regmask,outmask,src0,src1,src2) \
-       (((destidx) << R300_ALU_DSTA_SHIFT) |           \
-        (FP_SELA_MASK_##regmask << 23) |               \
-        (FP_SELA_MASK_##outmask << 24) |               \
-        ((src0) << R300_ALU_SRC0A_SHIFT) |             \
-        ((src1) << R300_ALU_SRC1A_SHIFT) |             \
-        ((src2) << R300_ALU_SRC2A_SHIFT))
-
-/* Produce unshifted argument selectors */
-#define FP_ARGC(source)        R300_ALU_ARGC_##source
-#define FP_ARGA(source) R300_ALU_ARGA_##source
-#define FP_ABS(arg) ((arg) | (1 << 6))
-#define FP_NEG(arg) ((arg) ^ (1 << 5))
-
-/* Produce instruction dword */
-#define FP_INSTRC(opcode,arg0,arg1,arg2) \
-       (R300_ALU_OUTC_##opcode |               \
-       ((arg0) << R300_ALU_ARG0C_SHIFT) |      \
-       ((arg1) << R300_ALU_ARG1C_SHIFT) |      \
-       ((arg2) << R300_ALU_ARG2C_SHIFT))
-
-#define FP_INSTRA(opcode,arg0,arg1,arg2) \
-       (R300_ALU_OUTA_##opcode |               \
-       ((arg0) << R300_ALU_ARG0A_SHIFT) |      \
-       ((arg1) << R300_ALU_ARG1A_SHIFT) |      \
-       ((arg2) << R300_ALU_ARG2A_SHIFT))
-
-#endif
-
-static void r300EmitClearState(GLcontext * ctx);
-
-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 = radeon_get_drawable(&r300->radeon);
-       GLuint cbpitch = 0;
-       r300ContextPtr rmesa = r300;
-
-       if (RADEON_DEBUG & RADEON_IOCTL)
-               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;
-        }
-       }
-
-       /* TODO in bufmgr */
-       cp_wait(&r300->radeon, R300_WAIT_3D | R300_WAIT_3D_CLEAN);
-       end_3d(&rmesa->radeon);
-
-       if (flags & CLEARBUFFER_COLOR) {
-               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)) {
-               uint32_t zbpitch = (rrbd->pitch / rrbd->cpp);
-               if (rrbd->bo->flags & RADEON_BO_FLAGS_MACRO_TILE){
-                       zbpitch |= R300_DEPTHMACROTILE_ENABLE;
-        }
-               if (rrbd->bo->flags & RADEON_BO_FLAGS_MICRO_TILE){
-            zbpitch |= 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_REGSEQ(R300_ZB_DEPTHPITCH, 1);
-               if (!r300->radeon.radeonScreen->kernel_mm)
-                       OUT_BATCH(zbpitch);
-               else
-                       OUT_BATCH_RELOC(zbpitch, rrbd->bo, zbpitch, 0, RADEON_GEM_DOMAIN_VRAM, 0);
-               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 {
-               OUT_BATCH(0);
-       }
-
-
-       {
-               uint32_t t1, t2;
-
-               t1 = 0x0;
-               t2 = 0x0;
-
-               if (flags & CLEARBUFFER_DEPTH) {
-                       t1 |= R300_Z_ENABLE | R300_Z_WRITE_ENABLE;
-                       t2 |=
-                           (R300_ZS_ALWAYS << R300_Z_FUNC_SHIFT);
-               }
-
-               if (flags & CLEARBUFFER_STENCIL) {
-                       t1 |= R300_STENCIL_ENABLE;
-                       t2 |=
-                           (R300_ZS_ALWAYS <<
-                            R300_S_FRONT_FUNC_SHIFT) |
-                           (R300_ZS_REPLACE <<
-                            R300_S_FRONT_SFAIL_OP_SHIFT) |
-                           (R300_ZS_REPLACE <<
-                            R300_S_FRONT_ZPASS_OP_SHIFT) |
-                           (R300_ZS_REPLACE <<
-                            R300_S_FRONT_ZFAIL_OP_SHIFT);
-               }
-
-               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();
-       }
-
-       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(&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);
-       BATCH_LOCALS(&r300->radeon);
-       __DRIdrawablePrivate *dPriv = radeon_get_drawable(&r300->radeon);
-       int i;
-       int has_tcl;
-       int is_r500 = 0;
-       GLuint vap_cntl;
-
-       has_tcl = r300->options.hw_tcl_enabled;
-
-       if (r300->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515)
-               is_r500 = 1;
-
-       /* 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.
-        *
-        * 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.
-        */
-       BEGIN_BATCH(31);
-       OUT_BATCH_REGSEQ(R300_VAP_PROG_STREAM_CNTL_0, 1);
-       if (!has_tcl)
-               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
-               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)));
-
-       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) |
-              ((R300_WRITE_ENA_X | R300_WRITE_ENA_Y | R300_WRITE_ENA_Z | R300_WRITE_ENA_W) << R300_WRITE_ENA_SHIFT))
-             << R300_SWIZZLE0_SHIFT) |
-            (((R300_SWIZZLE_SELECT_X << R300_SWIZZLE_SELECT_X_SHIFT) |
-              (R300_SWIZZLE_SELECT_Y << R300_SWIZZLE_SELECT_Y_SHIFT) |
-              (R300_SWIZZLE_SELECT_Z << R300_SWIZZLE_SELECT_Z_SHIFT) |
-              (R300_SWIZZLE_SELECT_W << R300_SWIZZLE_SELECT_W_SHIFT) |
-              ((R300_WRITE_ENA_X | R300_WRITE_ENA_Y | R300_WRITE_ENA_Z | R300_WRITE_ENA_W) << R300_WRITE_ENA_SHIFT))
-             << R300_SWIZZLE1_SHIFT)));
-
-       /* R300_VAP_INPUT_CNTL_0, R300_VAP_INPUT_CNTL_1 */
-       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);
-
-       /* comes from fglrx startup of clear */
-       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);
-
-       OUT_BATCH_REGVAL(R300_VAP_PSC_SGN_NORM_CNTL, 0xaaaaaaaa);
-
-       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 */
-
-       OUT_BATCH_REGVAL(R300_TX_ENABLE, 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);
-
-       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);
-       R300_STATECHANGE(r300, ps);
-
-       if (has_tcl) {
-               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();
-        }
-
-       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);
-               R300_STATECHANGE(r300, rc);
-               R300_STATECHANGE(r300, rr);
-
-               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);
-               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) {
-                       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));
-               }
-
-               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);
-               R300_STATECHANGE(r300, fpi[0]);
-               R300_STATECHANGE(r300, fpi[1]);
-               R300_STATECHANGE(r300, fpi[2]);
-               R300_STATECHANGE(r300, fpi[3]);
-
-               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 {
-               struct radeon_state_atom r500fp;
-               uint32_t _cmd[10];
-
-               R300_STATECHANGE(r300, fp);
-               R300_STATECHANGE(r300, r500fp);
-
-               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;
-               if (r300->radeon.radeonScreen->kernel_mm) {
-                       emit_r500fp(ctx, &r500fp);
-               } else {
-                       int dwords = r500fp.check(ctx,&r500fp);
-                       BEGIN_BATCH_NO_AUTOSTATE(dwords);
-                       OUT_BATCH_TABLE(r500fp.cmd, dwords);
-                       END_BATCH();
-               }
-
-       }
-
-       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) |
-                       (5 << R300_PVS_NUM_CNTLRS_SHIFT) |
-                       (12 << R300_VF_MAX_VTX_NUM_SHIFT));
-               if (r300->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515)
-                       vap_cntl |= R500_TCL_STATE_OPTIMIZATION;
-       } else {
-               vap_cntl = ((10 << R300_PVS_NUM_SLOTS_SHIFT) |
-                       (5 << R300_PVS_NUM_CNTLRS_SHIFT) |
-                       (5 << R300_VF_MAX_VTX_NUM_SHIFT));
-       }
-
-       if (r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV515)
-               vap_cntl |= (2 << R300_PVS_NUM_FPUS_SHIFT);
-       else if ((r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV530) ||
-                (r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV560) ||
-                (r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV570))
-               vap_cntl |= (5 << R300_PVS_NUM_FPUS_SHIFT);
-       else if ((r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV410) ||
-                (r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_R420))
-               vap_cntl |= (6 << R300_PVS_NUM_FPUS_SHIFT);
-       else if ((r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_R520) ||
-                (r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_R580))
-               vap_cntl |= (8 << R300_PVS_NUM_FPUS_SHIFT);
-       else
-               vap_cntl |= (4 << R300_PVS_NUM_FPUS_SHIFT);
-
-       R300_STATECHANGE(r300, 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);
-               R300_STATECHANGE(r300, vap_flush);
-               R300_STATECHANGE(r300, vpi);
-
-               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, NEGATE_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, NEGATE_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,
-                                      NEGATE_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, NEGATE_NONE);
-               vpu.cmd[8] = 0x0;
-
-               if (r300->radeon.radeonScreen->kernel_mm) {
-                       int dwords = r300->hw.vap_flush.check(ctx,&r300->hw.vap_flush);
-                       BEGIN_BATCH_NO_AUTOSTATE(dwords);
-                       OUT_BATCH_TABLE(r300->hw.vap_flush.cmd, dwords);
-                       END_BATCH();
-                       emit_vpu(ctx, &vpu);
-               } else {
-                       int dwords = vpu.check(ctx,&vpu);
-                       BEGIN_BATCH_NO_AUTOSTATE(dwords);
-                       OUT_BATCH_TABLE(vpu.cmd, dwords);
-                       END_BATCH();
-               }
-
-       }
-}
-
-static int r300KernelClear(GLcontext *ctx, GLuint flags)
-{
-       r300ContextPtr r300 = R300_CONTEXT(ctx);
-       __DRIdrawablePrivate *dPriv = radeon_get_drawable(&r300->radeon);
-       struct radeon_framebuffer *rfb = dPriv->driverPrivate;
-       struct radeon_renderbuffer *rrb;
-       struct radeon_renderbuffer *rrbd;
-       int bits = 0, ret;
-
-       /* Make sure it fits there. */
-       radeon_cs_space_reset_bos(r300->radeon.cmdbuf.cs);
-
-       if (flags & BUFFER_BIT_COLOR0) {
-               rrb = radeon_get_renderbuffer(&rfb->base, BUFFER_COLOR0);
-               radeon_cs_space_add_persistent_bo(r300->radeon.cmdbuf.cs,
-                                                 rrb->bo, 0, RADEON_GEM_DOMAIN_VRAM);
-       }
-
-       if (flags & BUFFER_BIT_FRONT_LEFT) {
-               rrb = radeon_get_renderbuffer(&rfb->base, BUFFER_FRONT_LEFT);
-               radeon_cs_space_add_persistent_bo(r300->radeon.cmdbuf.cs,
-                                                 rrb->bo, 0, RADEON_GEM_DOMAIN_VRAM);
-       }
-
-       if (flags & BUFFER_BIT_BACK_LEFT) {
-               rrb = radeon_get_renderbuffer(&rfb->base, BUFFER_BACK_LEFT);
-               radeon_cs_space_add_persistent_bo(r300->radeon.cmdbuf.cs,
-                                                 rrb->bo, 0, RADEON_GEM_DOMAIN_VRAM);
-       }
-
-       rrbd = radeon_get_renderbuffer(&rfb->base, BUFFER_DEPTH);
-       if (rrbd) {
-               radeon_cs_space_add_persistent_bo(r300->radeon.cmdbuf.cs,
-                                                 rrbd->bo, 0, RADEON_GEM_DOMAIN_VRAM);
-       }
-
-       ret = radeon_cs_space_check(r300->radeon.cmdbuf.cs);
-       if (ret)
-         return -1;
-
-       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;
-
-       if (rrbd && (flags & BUFFER_BIT_STENCIL))
-               bits |= CLEARBUFFER_STENCIL;
-
-       if (flags & BUFFER_BIT_COLOR0) {
-               rrb = radeon_get_renderbuffer(&rfb->base, BUFFER_COLOR0);
-               r300ClearBuffer(r300, CLEARBUFFER_COLOR, rrb, NULL);
-               bits = 0;
-       }
-
-       if (flags & BUFFER_BIT_FRONT_LEFT) {
-               rrb = radeon_get_renderbuffer(&rfb->base, BUFFER_FRONT_LEFT);
-               r300ClearBuffer(r300, bits | CLEARBUFFER_COLOR, rrb, rrbd);
-               bits = 0;
-       }
-
-       if (flags & BUFFER_BIT_BACK_LEFT) {
-               rrb = radeon_get_renderbuffer(&rfb->base, BUFFER_BACK_LEFT);
-               r300ClearBuffer(r300, bits | CLEARBUFFER_COLOR, rrb, rrbd);
-               bits = 0;
-       }
-
-       if (bits)
-               r300ClearBuffer(r300, bits, NULL, rrbd);
-
-       COMMIT_BATCH();
-       return 0;
-}
-
-/**
- * Buffer clear
- */
-static void r300Clear(GLcontext * ctx, GLbitfield mask)
-{
-       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, ret;
-       struct gl_framebuffer *fb = ctx->DrawBuffer;
-
-       if (RADEON_DEBUG & RADEON_IOCTL)
-               fprintf(stderr, "r300Clear\n");
-
-       if (!r300->radeon.radeonScreen->driScreen->dri2.enabled) {
-               LOCK_HARDWARE(&r300->radeon);
-               UNLOCK_HARDWARE(&r300->radeon);
-               if (dPriv->numClipRects == 0)
-                       return;
-       }
-
-       /* Flush swtcl vertices if necessary, because we will change hardware
-        * state during clear. See also the state-related comment in
-        * r300EmitClearState.
-        */
-       R300_NEWPRIM(r300);
-
-       if (colorMask == ~0)
-         tri_mask |= (mask & BUFFER_BITS_COLOR);
-       else
-         tri_mask |= (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT));
-
-
-       /* HW stencil */
-       if (mask & BUFFER_BIT_STENCIL) {
-               tri_mask |= BUFFER_BIT_STENCIL;
-       }
-
-       /* HW depth */
-       if (mask & BUFFER_BIT_DEPTH) {
-               tri_mask |= BUFFER_BIT_DEPTH;
-       }
-
-       /* If we're doing a tri pass for depth/stencil, include a likely color
-        * buffer with it.
-        */
-
-       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;
-           }
-         }
-       }
-
-       /* SW fallback clearing */
-       swrast_mask = mask & ~tri_mask;
-
-       ret = 0;
-       if (tri_mask) {
-               if (r300->radeon.radeonScreen->kernel_mm)
-                       radeonUserClear(ctx, tri_mask);
-               else {
-                       /* if kernel clear fails due to size restraints fallback */
-                       ret = r300KernelClear(ctx, tri_mask);
-                       if (ret < 0)
-                               swrast_mask |= tri_mask;
-               }
-       }
-
-       if (swrast_mask) {
-               if (RADEON_DEBUG & RADEON_FALLBACKS)
-                       fprintf(stderr, "%s: swrast clear, mask: %x\n",
-                               __FUNCTION__, swrast_mask);
-               _swrast_Clear(ctx, swrast_mask);
-       }
-}
-
-void r300InitIoctlFuncs(struct dd_function_table *functions)
-{
-       functions->Clear = r300Clear;
-       functions->Finish = radeonFinish;
-       functions->Flush = radeonFlush;
-}
diff --git a/src/mesa/drivers/dri/r300/r300_ioctl.h b/src/mesa/drivers/dri/r300/r300_ioctl.h
deleted file mode 100644 (file)
index 3abfa71..0000000
+++ /dev/null
@@ -1,44 +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>
- *   Nicolai Haehnle <prefect_@gmx.net>
- */
-
-#ifndef __R300_IOCTL_H__
-#define __R300_IOCTL_H__
-
-#include "r300_context.h"
-#include "radeon_drm.h"
-
-extern void r300InitIoctlFuncs(struct dd_function_table *functions);
-
-#endif                         /* __R300_IOCTL_H__ */
index 623da60333f2c8cf153286c490e3626514ee24d8..ea684e7df18d7ff6e7ea7ac683700577a8005b80 100644 (file)
@@ -1789,6 +1789,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #       define R300_ALU_DSTC_OUTPUT_X           (1 << 26)
 #       define R300_ALU_DSTC_OUTPUT_Y           (1 << 27)
 #       define R300_ALU_DSTC_OUTPUT_Z           (1 << 28)
+#       define R300_RGB_TARGET(x)               ((x) << 29)
 
 #define R300_US_ALU_ALPHA_ADDR_0                 0x47C0
 #       define R300_ALU_SRC0A_SHIFT             0
@@ -1806,6 +1807,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #       define R300_ALU_DSTA_REG                (1 << 23)
 #       define R300_ALU_DSTA_OUTPUT             (1 << 24)
 #              define R300_ALU_DSTA_DEPTH              (1 << 27)
+#              define R300_ALPHA_TARGET(x)             ((x) << 25)
 
 #define R300_US_ALU_RGB_INST_0                   0x48C0
 #       define R300_ALU_ARGC_SRC0C_XYZ          0
index 3cd38753b8ad3e2da1a58eae63ae3fa73e0c250a..02c94250a8ffd3a1fe53060eb7300b83fadfdb1c 100644 (file)
@@ -67,10 +67,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "vbo/vbo_split.h"
 #include "tnl/tnl.h"
 #include "tnl/t_vp_build.h"
-#include "radeon_reg.h"
-#include "radeon_macros.h"
 #include "r300_context.h"
-#include "r300_ioctl.h"
 #include "r300_state.h"
 #include "r300_reg.h"
 #include "r300_tex.h"
index 3060f49aaf8ac27376255137bd4300cc80d2be71..c51285aad9313971aa35ab8156f329864a41465f 100644 (file)
@@ -45,7 +45,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/framebuffer.h"
 #include "main/simple_list.h"
 #include "main/api_arrayelt.h"
-#include "main/texformat.h"
 
 #include "swrast/swrast.h"
 #include "swrast_setup/swrast_setup.h"
@@ -56,7 +55,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "tnl/t_vp_build.h"
 
 #include "r300_context.h"
-#include "r300_ioctl.h"
 #include "r300_state.h"
 #include "r300_reg.h"
 #include "r300_emit.h"
@@ -999,7 +997,7 @@ static void r300StencilOpSeparate(GLcontext * ctx, GLenum face,
 static void r300UpdateWindow(GLcontext * ctx)
 {
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
-       __DRIdrawablePrivate *dPriv = radeon_get_drawable(&rmesa->radeon);
+       __DRIdrawable *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;
@@ -1052,7 +1050,7 @@ static void r300DepthRange(GLcontext * ctx, GLclampd nearval, GLclampd farval)
 void r300UpdateViewportOffset(GLcontext * ctx)
 {
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
-       __DRIdrawablePrivate *dPriv = radeon_get_drawable(&rmesa->radeon);
+       __DRIdrawable *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;
@@ -1313,7 +1311,7 @@ static void r300SetupTextures(GLcontext * ctx)
                fprintf(stderr,
                        "Aiiee ! mtu=%d is greater than R300_MAX_TEXTURE_UNITS=%d\n",
                        mtu, R300_MAX_TEXTURE_UNITS);
-               _mesa_exit(-1);
+               exit(-1);
        }
 
        /* We cannot let disabled tmu offsets pass DRM */
@@ -1770,9 +1768,10 @@ static void r300ResetHwState(r300ContextPtr r300)
        radeon_firevertices(&r300->radeon);
 
        r300ColorMask(ctx,
-                     ctx->Color.ColorMask[RCOMP],
-                     ctx->Color.ColorMask[GCOMP],
-                     ctx->Color.ColorMask[BCOMP], ctx->Color.ColorMask[ACOMP]);
+                     ctx->Color.ColorMask[0][RCOMP],
+                     ctx->Color.ColorMask[0][GCOMP],
+                     ctx->Color.ColorMask[0][BCOMP],
+                      ctx->Color.ColorMask[0][ACOMP]);
 
        r300Enable(ctx, GL_DEPTH_TEST, ctx->Depth.Test);
        r300DepthMask(ctx, ctx->Depth.Mask);
@@ -2041,7 +2040,7 @@ static const GLfloat *get_fragmentprogram_constant(GLcontext *ctx, GLuint index,
                }
 
                case RC_STATE_R300_WINDOW_DIMENSION: {
-                       __DRIdrawablePrivate * drawable = radeon_get_drawable(&rmesa->radeon);
+                       __DRIdrawable * drawable = radeon_get_drawable(&rmesa->radeon);
                        buffer[0] = drawable->w * 0.5f; /* width*0.5 */
                        buffer[1] = drawable->h * 0.5f; /* height*0.5 */
                        buffer[2] = 0.5F;       /* for moving range [-1 1] -> [0 1] */
index ee2c71e1a7f81382afc0801f0ce5d224d3ee5555..93983cee2053c781f8e40571f4416618981f0bb1 100644 (file)
@@ -124,7 +124,7 @@ void r300ChooseSwtclVertexFormat(GLcontext *ctx, GLuint *_InputsRead,  GLuint *_
        }
 
        if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) {
-               VB->AttribPtr[VERT_ATTRIB_GENERIC0] = VB->ColorPtr[1];
+               VB->AttribPtr[VERT_ATTRIB_GENERIC0] = VB->BackfaceColorPtr;
                OutputsWritten |= 1 << VERT_RESULT_BFC0;
 #if MESA_LITTLE_ENDIAN
                EMIT_ATTR( _TNL_ATTRIB_GENERIC0, EMIT_4UB_4F_RGBA );
@@ -134,7 +134,7 @@ void r300ChooseSwtclVertexFormat(GLcontext *ctx, GLuint *_InputsRead,  GLuint *_
                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];
+                       VB->AttribPtr[VERT_ATTRIB_GENERIC1] = VB->BackfaceSecondaryColorPtr;
                        GLuint swiz = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_ONE);
                        OutputsWritten |= 1 << VERT_RESULT_BFC1;
 #if MESA_LITTLE_ENDIAN
@@ -159,7 +159,7 @@ void r300ChooseSwtclVertexFormat(GLcontext *ctx, GLuint *_InputsRead,  GLuint *_
                int tex_id = rmesa->selected_fp->wpos_attr - FRAG_ATTRIB_TEX0;
 
                VB->AttribPtr[VERT_ATTRIB_TEX0 + tex_id] = VB->AttribPtr[VERT_ATTRIB_POS];
-               VB->TexCoordPtr[tex_id] = VB->AttribPtr[VERT_ATTRIB_POS];
+               VB->AttribPtr[_TNL_ATTRIB_TEX0 + tex_id] = VB->AttribPtr[VERT_ATTRIB_POS];
                RENDERINPUTS_SET(tnl->render_inputs_bitset, _TNL_ATTRIB_TEX0 + tex_id);
        }
 
@@ -167,7 +167,7 @@ void r300ChooseSwtclVertexFormat(GLcontext *ctx, GLuint *_InputsRead,  GLuint *_
                int tex_id = rmesa->selected_fp->fog_attr - FRAG_ATTRIB_TEX0;
 
                VB->AttribPtr[VERT_ATTRIB_TEX0 + tex_id] = VB->AttribPtr[VERT_ATTRIB_FOG];
-               VB->TexCoordPtr[tex_id] = VB->AttribPtr[VERT_ATTRIB_FOG];
+               VB->AttribPtr[_TNL_ATTRIB_TEX0 + tex_id] = VB->AttribPtr[VERT_ATTRIB_FOG];
                RENDERINPUTS_SET(tnl->render_inputs_bitset, _TNL_ATTRIB_TEX0 + tex_id);
        }
 
@@ -180,7 +180,7 @@ void r300ChooseSwtclVertexFormat(GLcontext *ctx, GLuint *_InputsRead,  GLuint *_
                GLuint swiz, format, hw_format;
                for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
                        if (fp_reads & FRAG_BIT_TEX(i)) {
-                               switch (VB->TexCoordPtr[i]->size) {
+                               switch (VB->AttribPtr[_TNL_ATTRIB_TEX0 + i]->size) {
                                        case 1:
                                                format = EMIT_1F;
                                                hw_format = R300_DATA_TYPE_FLOAT_1;
@@ -215,7 +215,7 @@ void r300ChooseSwtclVertexFormat(GLcontext *ctx, GLuint *_InputsRead,  GLuint *_
 
        if (first_free_tex >= ctx->Const.MaxTextureUnits) {
                fprintf(stderr, "\tout of free texcoords to write fog coordinate\n");
-               _mesa_exit(-1);
+               exit(-1);
        }
 
        R300_NEWPRIM(rmesa);
@@ -665,11 +665,11 @@ void r300_swtcl_flush(GLcontext *ctx, uint32_t current_offset)
        r300EmitCacheFlush(rmesa);
 
        radeonEmitState(&rmesa->radeon);
-    r300_emit_scissor(ctx);
+       r300_emit_scissor(ctx);
        r300EmitVertexAOS(rmesa,
-                       rmesa->radeon.swtcl.vertex_size,
-                       first_elem(&rmesa->radeon.dma.reserved)->bo,
-                       current_offset);
+                         rmesa->radeon.swtcl.vertex_size,
+                         rmesa->radeon.swtcl.bo,
+                         current_offset);
 
        r300EmitVbufPrim(rmesa,
                   rmesa->radeon.swtcl.hw_primitive,
index 433e5a87d48b2cd79dd535c3a38463b918946dc4..963f648cb14b5af8d11bc3e4be1fa7386123fd4f 100644 (file)
@@ -40,7 +40,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/image.h"
 #include "main/mipmap.h"
 #include "main/simple_list.h"
-#include "main/texformat.h"
 #include "main/texstore.h"
 #include "main/teximage.h"
 #include "main/texobj.h"
@@ -49,7 +48,6 @@ 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"
 
@@ -196,6 +194,7 @@ static void r300TexParameter(GLcontext * ctx, GLenum target,
                             GLenum pname, const GLfloat * params)
 {
        radeonTexObj* t = radeon_tex_obj(texObj);
+       GLenum texBaseFormat;
 
        if (RADEON_DEBUG & (RADEON_STATE | RADEON_TEXTURE)) {
                fprintf(stderr, "%s( %s )\n", __FUNCTION__,
@@ -216,30 +215,23 @@ static void r300TexParameter(GLcontext * ctx, GLenum target,
                break;
 
        case GL_TEXTURE_BORDER_COLOR:
-               r300SetTexBorderColor(t, texObj->BorderColor);
+               r300SetTexBorderColor(t, texObj->BorderColor.f);
                break;
 
        case GL_TEXTURE_BASE_LEVEL:
        case GL_TEXTURE_MAX_LEVEL:
        case GL_TEXTURE_MIN_LOD:
        case GL_TEXTURE_MAX_LOD:
-               /* This isn't the most efficient solution but there doesn't appear to
-                * be a nice alternative.  Since there's no LOD clamping,
-                * we just have to rely on loading the right subset of mipmap levels
-                * to simulate a clamped LOD.
-                */
-               if (t->mt) {
-                       radeon_miptree_unreference(t->mt);
-                       t->mt = 0;
-                       t->validated = GL_FALSE;
-               }
+               t->validated = GL_FALSE;
                break;
 
        case GL_DEPTH_TEXTURE_MODE:
                if (!texObj->Image[0][texObj->BaseLevel])
                        return;
-               if (texObj->Image[0][texObj->BaseLevel]->TexFormat->BaseFormat
-                   == GL_DEPTH_COMPONENT) {
+               texBaseFormat = texObj->Image[0][texObj->BaseLevel]->_BaseFormat;
+
+               if (texBaseFormat == GL_DEPTH_COMPONENT ||
+                       texBaseFormat == GL_DEPTH_STENCIL) {
                        r300SetDepthTexMode(texObj);
                        break;
                } else {
@@ -268,7 +260,11 @@ static void r300DeleteTexture(GLcontext * ctx, struct gl_texture_object *texObj)
 
        if (rmesa) {
                int i;
-               radeon_firevertices(&rmesa->radeon);
+               struct radeon_bo *bo;
+               bo = !t->mt ? t->bo : t->mt->bo;
+               if (bo && radeon_bo_is_referenced_by_cs(bo, rmesa->radeon.cmdbuf.cs)) {
+                       radeon_firevertices(&rmesa->radeon);
+               }
 
                for(i = 0; i < R300_MAX_TEXTURE_UNITS; ++i)
                        if (rmesa->hw.textures[i] == t)
@@ -280,10 +276,8 @@ static void r300DeleteTexture(GLcontext * ctx, struct gl_texture_object *texObj)
                t->bo = NULL;
        }
 
-       if (t->mt) {
-               radeon_miptree_unreference(t->mt);
-               t->mt = 0;
-       }
+       radeon_miptree_unreference(&t->mt);
+
        _mesa_delete_texture_object(ctx, texObj);
 }
 
@@ -313,7 +307,7 @@ static struct gl_texture_object *r300NewTextureObject(GLcontext * ctx,
        /* Initialize hardware state */
        r300UpdateTexWrap(t);
        r300SetTexFilter(t, t->base.MinFilter, t->base.MagFilter, t->base.MaxAnisotropy);
-       r300SetTexBorderColor(t, t->base.BorderColor);
+       r300SetTexBorderColor(t, t->base.BorderColor.f);
 
        return &t->base;
 }
index 8a653ea2d11b0b186e384056141f63f9e751562a..6ede0fe25c9047241a2bea540403b6f4e050f55d 100644 (file)
@@ -51,4 +51,6 @@ extern GLboolean r300ValidateBuffers(GLcontext * ctx);
 
 extern void r300InitTextureFuncs(struct dd_function_table *functions);
 
+int32_t r300TranslateTexFormat(gl_format mesaFormat);
+
 #endif                         /* __r300_TEX_H__ */
diff --git a/src/mesa/drivers/dri/r300/r300_texcopy.c b/src/mesa/drivers/dri/r300/r300_texcopy.c
new file mode 100644 (file)
index 0000000..ebc9c05
--- /dev/null
@@ -0,0 +1,168 @@
+/*
+ * 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.
+ *
+ */
+
+#include "radeon_common.h"
+#include "r300_context.h"
+
+#include "main/image.h"
+#include "main/teximage.h"
+#include "main/texstate.h"
+#include "drivers/common/meta.h"
+
+#include "radeon_mipmap_tree.h"
+#include "r300_blit.h"
+#include <main/debug.h>
+
+// TODO:
+// need to pass correct pitch for small dst textures!
+static GLboolean
+do_copy_texsubimage(GLcontext *ctx,
+                    GLenum target, GLint level,
+                    struct radeon_tex_obj *tobj,
+                    radeon_texture_image *timg,
+                    GLint dstx, GLint dsty,
+                    GLint x, GLint y,
+                    GLsizei width, GLsizei height)
+{
+    struct r300_context *r300 = R300_CONTEXT(ctx);
+    struct radeon_renderbuffer *rrb;
+
+    if (_mesa_get_format_bits(timg->base.TexFormat, GL_DEPTH_BITS) > 0) {
+        rrb = radeon_get_depthbuffer(&r300->radeon);
+    } else {
+        rrb = radeon_get_colorbuffer(&r300->radeon);
+    }
+
+    if (!timg->mt) {
+        radeon_validate_texture_miptree(ctx, &tobj->base);
+    }
+
+    assert(rrb && rrb->bo);
+    assert(timg->mt->bo);
+    assert(timg->base.Width >= dstx + width);
+    assert(timg->base.Height >= dsty + height);
+
+    intptr_t src_offset = rrb->draw_offset;
+    intptr_t dst_offset = radeon_miptree_image_offset(timg->mt, _mesa_tex_target_to_face(target), level);
+
+    if (src_offset % 32 || dst_offset % 32) {
+        return GL_FALSE;
+    }
+
+    if (0) {
+        fprintf(stderr, "%s: copying to face %d, level %d\n",
+                __FUNCTION__, _mesa_tex_target_to_face(target), level);
+        fprintf(stderr, "to: x %d, y %d, offset %d\n", dstx, dsty, (uint32_t) dst_offset);
+        fprintf(stderr, "from (%dx%d) width %d, height %d, offset %d, pitch %d\n",
+                x, y, rrb->base.Width, rrb->base.Height, (uint32_t) src_offset, rrb->pitch/rrb->cpp);
+        fprintf(stderr, "src size %d, dst size %d\n", rrb->bo->size, timg->mt->bo->size);
+
+    }
+
+    /* blit from src buffer to texture */
+    return r300_blit(r300, rrb->bo, src_offset, rrb->base.Format, rrb->pitch/rrb->cpp,
+                     rrb->base.Width, rrb->base.Height, x, y,
+                     timg->mt->bo, dst_offset, timg->base.TexFormat,
+                     timg->base.Width, timg->base.Width, timg->base.Height,
+                     dstx, dsty, width, height, 1);
+}
+
+static void
+r300CopyTexImage2D(GLcontext *ctx, GLenum target, GLint level,
+                   GLenum internalFormat,
+                   GLint x, GLint y, GLsizei width, GLsizei height,
+                   GLint border)
+{
+    struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
+    struct gl_texture_object *texObj =
+        _mesa_select_tex_object(ctx, texUnit, target);
+    struct gl_texture_image *texImage =
+        _mesa_select_tex_image(ctx, texObj, target, level);
+    int srcx, srcy, dstx, dsty;
+
+    if (border)
+        goto fail;
+
+    /* Setup or redefine the texture object, mipmap tree and texture
+     * image.  Don't populate yet.
+     */
+    ctx->Driver.TexImage2D(ctx, target, level, internalFormat,
+                           width, height, border,
+                           GL_RGBA, GL_UNSIGNED_BYTE, NULL,
+                           &ctx->DefaultPacking, texObj, texImage);
+
+    srcx = x;
+    srcy = y;
+    dstx = 0;
+    dsty = 0;
+    if (!_mesa_clip_copytexsubimage(ctx,
+                                    &dstx, &dsty,
+                                    &srcx, &srcy,
+                                    &width, &height)) {
+        return;
+    }
+
+    if (!do_copy_texsubimage(ctx, target, level,
+                             radeon_tex_obj(texObj), (radeon_texture_image *)texImage,
+                             0, 0, x, y, width, height)) {
+        goto fail;
+    }
+
+    return;
+
+fail:
+    _mesa_meta_CopyTexImage2D(ctx, target, level, internalFormat, x, y,
+                              width, height, border);
+}
+
+static void
+r300CopyTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
+                      GLint xoffset, GLint yoffset,
+                      GLint x, GLint y,
+                      GLsizei width, GLsizei height)
+{
+    struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
+    struct gl_texture_object *texObj = _mesa_select_tex_object(ctx, texUnit, target);
+    struct gl_texture_image *texImage = _mesa_select_tex_image(ctx, texObj, target, level);
+
+    if (!do_copy_texsubimage(ctx, target, level,
+                             radeon_tex_obj(texObj), (radeon_texture_image *)texImage,
+                             xoffset, yoffset, x, y, width, height)) {
+
+       //DEBUG_FALLBACKS
+
+        _mesa_meta_CopyTexSubImage2D(ctx, target, level,
+                                     xoffset, yoffset, x, y, width, height);
+    }
+}
+
+
+void r300_init_texcopy_functions(struct dd_function_table *table)
+{
+    table->CopyTexImage2D = r300CopyTexImage2D;
+    table->CopyTexSubImage2D = r300CopyTexSubImage2D;
+}
\ No newline at end of file
index f030451b282209fe152a7d85a72b90d8e414209f..78ff54574f623c5b142c0ccde812ec421304b46d 100644 (file)
@@ -39,7 +39,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/imports.h"
 #include "main/context.h"
 #include "main/macros.h"
-#include "main/texformat.h"
 #include "main/teximage.h"
 #include "main/texobj.h"
 #include "main/enums.h"
@@ -47,19 +46,10 @@ 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 "r300_reg.h"
 
-#define VALID_FORMAT(f) ( ((f) <= MESA_FORMAT_RGBA_DXT5                        \
-                          || ((f) >= MESA_FORMAT_RGBA_FLOAT32 &&       \
-                              (f) <= MESA_FORMAT_INTENSITY_FLOAT16))   \
-                         && tx_table[f].flag )
-
-#define _ASSIGN(entry, format)                         \
-       [ MESA_FORMAT_ ## entry ] = { format, 0, 1}
-
 /*
  * Note that the _REV formats are the same as the non-REV formats.  This is
  * because the REV and non-REV formats are identical as a byte string, but
@@ -69,66 +59,119 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  * identically.  -- paulus
  */
 
-static const struct tx_table {
-       GLuint format, filter, flag;
-} tx_table[] = {
-       /* *INDENT-OFF* */
+int32_t r300TranslateTexFormat(gl_format mesaFormat)
+{
+       switch (mesaFormat)
+       {
 #ifdef MESA_LITTLE_ENDIAN
-       _ASSIGN(RGBA8888, R300_EASY_TX_FORMAT(Y, Z, W, X, W8Z8Y8X8)),
-       _ASSIGN(RGBA8888_REV, R300_EASY_TX_FORMAT(Z, Y, X, W, W8Z8Y8X8)),
-       _ASSIGN(ARGB8888, R300_EASY_TX_FORMAT(X, Y, Z, W, W8Z8Y8X8)),
-       _ASSIGN(ARGB8888_REV, R300_EASY_TX_FORMAT(W, Z, Y, X, W8Z8Y8X8)),
+               case MESA_FORMAT_RGBA8888:
+                       return R300_EASY_TX_FORMAT(Y, Z, W, X, W8Z8Y8X8);
+               case MESA_FORMAT_RGBA8888_REV:
+                       return R300_EASY_TX_FORMAT(Z, Y, X, W, W8Z8Y8X8);
+               case MESA_FORMAT_ARGB8888:
+                       return R300_EASY_TX_FORMAT(X, Y, Z, W, W8Z8Y8X8);
+               case MESA_FORMAT_ARGB8888_REV:
+                       return R300_EASY_TX_FORMAT(W, Z, Y, X, W8Z8Y8X8);
 #else
-       _ASSIGN(RGBA8888, R300_EASY_TX_FORMAT(Z, Y, X, W, W8Z8Y8X8)),
-       _ASSIGN(RGBA8888_REV, R300_EASY_TX_FORMAT(Y, Z, W, X, W8Z8Y8X8)),
-       _ASSIGN(ARGB8888, R300_EASY_TX_FORMAT(W, Z, Y, X, W8Z8Y8X8)),
-       _ASSIGN(ARGB8888_REV, R300_EASY_TX_FORMAT(X, Y, Z, W, W8Z8Y8X8)),
+               case MESA_FORMAT_RGBA8888:
+                       return R300_EASY_TX_FORMAT(Z, Y, X, W, W8Z8Y8X8);
+               case MESA_FORMAT_RGBA8888_REV:
+                       return R300_EASY_TX_FORMAT(Y, Z, W, X, W8Z8Y8X8);
+               case MESA_FORMAT_ARGB8888:
+                       return R300_EASY_TX_FORMAT(W, Z, Y, X, W8Z8Y8X8);
+               case MESA_FORMAT_ARGB8888_REV:
+                       return R300_EASY_TX_FORMAT(X, Y, Z, W, W8Z8Y8X8);
 #endif
-       _ASSIGN(RGB888, R300_EASY_TX_FORMAT(X, Y, Z, ONE, W8Z8Y8X8)),
-       _ASSIGN(RGB565, R300_EASY_TX_FORMAT(X, Y, Z, ONE, Z5Y6X5)),
-       _ASSIGN(RGB565_REV, R300_EASY_TX_FORMAT(X, Y, Z, ONE, Z5Y6X5)),
-       _ASSIGN(ARGB4444, R300_EASY_TX_FORMAT(X, Y, Z, W, W4Z4Y4X4)),
-       _ASSIGN(ARGB4444_REV, R300_EASY_TX_FORMAT(X, Y, Z, W, W4Z4Y4X4)),
-       _ASSIGN(ARGB1555, R300_EASY_TX_FORMAT(X, Y, Z, W, W1Z5Y5X5)),
-       _ASSIGN(ARGB1555_REV, R300_EASY_TX_FORMAT(X, Y, Z, W, W1Z5Y5X5)),
-       _ASSIGN(AL88, R300_EASY_TX_FORMAT(X, X, X, Y, Y8X8)),
-       _ASSIGN(AL88_REV, R300_EASY_TX_FORMAT(X, X, X, Y, Y8X8)),
-       _ASSIGN(RGB332, R300_EASY_TX_FORMAT(X, Y, Z, ONE, Z3Y3X2)),
-       _ASSIGN(A8, R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, X, X8)),
-       _ASSIGN(L8, R300_EASY_TX_FORMAT(X, X, X, ONE, X8)),
-       _ASSIGN(I8, R300_EASY_TX_FORMAT(X, X, X, X, X8)),
-       _ASSIGN(CI8, R300_EASY_TX_FORMAT(X, X, X, X, X8)),
-       _ASSIGN(YCBCR, R300_EASY_TX_FORMAT(X, Y, Z, ONE, G8R8_G8B8) | R300_TX_FORMAT_YUV_MODE),
-       _ASSIGN(YCBCR_REV, R300_EASY_TX_FORMAT(X, Y, Z, ONE, G8R8_G8B8) | R300_TX_FORMAT_YUV_MODE),
-       _ASSIGN(RGB_DXT1, R300_EASY_TX_FORMAT(X, Y, Z, ONE, DXT1)),
-       _ASSIGN(RGBA_DXT1, R300_EASY_TX_FORMAT(X, Y, Z, W, DXT1)),
-       _ASSIGN(RGBA_DXT3, R300_EASY_TX_FORMAT(X, Y, Z, W, DXT3)),
-       _ASSIGN(RGBA_DXT5, R300_EASY_TX_FORMAT(Y, Z, W, X, DXT5)),
-       _ASSIGN(RGBA_FLOAT32, R300_EASY_TX_FORMAT(Z, Y, X, W, FL_R32G32B32A32)),
-       _ASSIGN(RGBA_FLOAT16, R300_EASY_TX_FORMAT(Z, Y, X, W, FL_R16G16B16A16)),
-       _ASSIGN(RGB_FLOAT32, 0xffffffff),
-       _ASSIGN(RGB_FLOAT16, 0xffffffff),
-       _ASSIGN(ALPHA_FLOAT32, R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, X, FL_I32)),
-       _ASSIGN(ALPHA_FLOAT16, R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, X, FL_I16)),
-       _ASSIGN(LUMINANCE_FLOAT32, R300_EASY_TX_FORMAT(X, X, X, ONE, FL_I32)),
-       _ASSIGN(LUMINANCE_FLOAT16, R300_EASY_TX_FORMAT(X, X, X, ONE, FL_I16)),
-       _ASSIGN(LUMINANCE_ALPHA_FLOAT32, R300_EASY_TX_FORMAT(X, X, X, Y, FL_I32A32)),
-       _ASSIGN(LUMINANCE_ALPHA_FLOAT16, R300_EASY_TX_FORMAT(X, X, X, Y, FL_I16A16)),
-       _ASSIGN(INTENSITY_FLOAT32, R300_EASY_TX_FORMAT(X, X, X, X, FL_I32)),
-       _ASSIGN(INTENSITY_FLOAT16, R300_EASY_TX_FORMAT(X, X, X, X, FL_I16)),
-       _ASSIGN(Z16, R300_EASY_TX_FORMAT(X, X, X, X, X16)),
-       _ASSIGN(Z24_S8, R300_EASY_TX_FORMAT(X, X, X, X, X24_Y8)),
-       _ASSIGN(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* */
+               case MESA_FORMAT_XRGB8888:
+                       return R300_EASY_TX_FORMAT(X, Y, Z, ONE, W8Z8Y8X8);
+               case MESA_FORMAT_RGB888:
+                       return R300_EASY_TX_FORMAT(X, Y, Z, ONE, W8Z8Y8X8);
+               case MESA_FORMAT_RGB565:
+                       return R300_EASY_TX_FORMAT(X, Y, Z, ONE, Z5Y6X5);
+               case MESA_FORMAT_RGB565_REV:
+                       return R300_EASY_TX_FORMAT(X, Y, Z, ONE, Z5Y6X5);
+               case MESA_FORMAT_ARGB4444:
+                       return R300_EASY_TX_FORMAT(X, Y, Z, W, W4Z4Y4X4);
+               case MESA_FORMAT_ARGB4444_REV:
+                       return R300_EASY_TX_FORMAT(X, Y, Z, W, W4Z4Y4X4);
+               case MESA_FORMAT_ARGB1555:
+                       return R300_EASY_TX_FORMAT(X, Y, Z, W, W1Z5Y5X5);
+               case MESA_FORMAT_ARGB1555_REV:
+                       return R300_EASY_TX_FORMAT(X, Y, Z, W, W1Z5Y5X5);
+               case MESA_FORMAT_AL88:
+                       return R300_EASY_TX_FORMAT(X, X, X, Y, Y8X8);
+               case MESA_FORMAT_AL88_REV:
+                       return R300_EASY_TX_FORMAT(X, X, X, Y, Y8X8);
+               case MESA_FORMAT_RGB332:
+                       return R300_EASY_TX_FORMAT(X, Y, Z, ONE, Z3Y3X2);
+               case MESA_FORMAT_A8:
+                       return R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, X, X8);
+               case MESA_FORMAT_L8:
+                       return R300_EASY_TX_FORMAT(X, X, X, ONE, X8);
+               case MESA_FORMAT_I8:
+                       return R300_EASY_TX_FORMAT(X, X, X, X, X8);
+               case MESA_FORMAT_CI8:
+                       return R300_EASY_TX_FORMAT(X, X, X, X, X8);
+               case MESA_FORMAT_YCBCR:
+                       return R300_EASY_TX_FORMAT(X, Y, Z, ONE, G8R8_G8B8) | R300_TX_FORMAT_YUV_MODE;
+               case MESA_FORMAT_YCBCR_REV:
+                       return R300_EASY_TX_FORMAT(X, Y, Z, ONE, G8R8_G8B8) | R300_TX_FORMAT_YUV_MODE;
+               case MESA_FORMAT_RGB_DXT1:
+                       return R300_EASY_TX_FORMAT(X, Y, Z, ONE, DXT1);
+               case MESA_FORMAT_RGBA_DXT1:
+                       return R300_EASY_TX_FORMAT(X, Y, Z, W, DXT1);
+               case MESA_FORMAT_RGBA_DXT3:
+                       return R300_EASY_TX_FORMAT(X, Y, Z, W, DXT3);
+               case MESA_FORMAT_RGBA_DXT5:
+                       return R300_EASY_TX_FORMAT(Y, Z, W, X, DXT5);
+               case MESA_FORMAT_RGBA_FLOAT32:
+                       return R300_EASY_TX_FORMAT(Z, Y, X, W, FL_R32G32B32A32);
+               case MESA_FORMAT_RGBA_FLOAT16:
+                       return R300_EASY_TX_FORMAT(Z, Y, X, W, FL_R16G16B16A16);
+               case MESA_FORMAT_ALPHA_FLOAT32:
+                       return R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, X, FL_I32);
+               case MESA_FORMAT_ALPHA_FLOAT16:
+                       return R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, X, FL_I16);
+               case MESA_FORMAT_LUMINANCE_FLOAT32:
+                       return R300_EASY_TX_FORMAT(X, X, X, ONE, FL_I32);
+               case MESA_FORMAT_LUMINANCE_FLOAT16:
+                       return R300_EASY_TX_FORMAT(X, X, X, ONE, FL_I16);
+               case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32:
+                       return R300_EASY_TX_FORMAT(X, X, X, Y, FL_I32A32);
+               case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16:
+                       return R300_EASY_TX_FORMAT(X, X, X, Y, FL_I16A16);
+               case MESA_FORMAT_INTENSITY_FLOAT32:
+                       return R300_EASY_TX_FORMAT(X, X, X, X, FL_I32);
+               case MESA_FORMAT_INTENSITY_FLOAT16:
+                       return R300_EASY_TX_FORMAT(X, X, X, X, FL_I16);
+               case MESA_FORMAT_Z16:
+                       return R300_EASY_TX_FORMAT(X, X, X, X, X16);
+               case MESA_FORMAT_Z24_S8:
+                       return R300_EASY_TX_FORMAT(X, X, X, X, X24_Y8);
+               case MESA_FORMAT_S8_Z24:
+                       return R300_EASY_TX_FORMAT(Y, Y, Y, Y, X24_Y8);
+               case MESA_FORMAT_Z32:
+                       return R300_EASY_TX_FORMAT(X, X, X, X, X32);
+               /* EXT_texture_sRGB */
+               case MESA_FORMAT_SRGBA8:
+                       return R300_EASY_TX_FORMAT(Y, Z, W, X, W8Z8Y8X8) | R300_TX_FORMAT_GAMMA;
+               case MESA_FORMAT_SLA8:
+                       return R300_EASY_TX_FORMAT(X, X, X, Y, Y8X8) | R300_TX_FORMAT_GAMMA;
+               case MESA_FORMAT_SL8:
+                       return R300_EASY_TX_FORMAT(X, X, X, ONE, X8) | R300_TX_FORMAT_GAMMA;
+               case MESA_FORMAT_SRGB_DXT1:
+                       return R300_EASY_TX_FORMAT(X, Y, Z, ONE, DXT1) | R300_TX_FORMAT_GAMMA;
+               case MESA_FORMAT_SRGBA_DXT1:
+                       return R300_EASY_TX_FORMAT(X, Y, Z, W, DXT1) | R300_TX_FORMAT_GAMMA;
+               case MESA_FORMAT_SRGBA_DXT3:
+                       return R300_EASY_TX_FORMAT(X, Y, Z, W, DXT3) | R300_TX_FORMAT_GAMMA;
+               case MESA_FORMAT_SRGBA_DXT5:
+                       return R300_EASY_TX_FORMAT(Y, Z, W, X, DXT5) | R300_TX_FORMAT_GAMMA;
+               default:
+                       return -1;
+       }
 };
 
-#undef _ASSIGN
-
 void r300SetDepthTexMode(struct gl_texture_object *tObj)
 {
        static const GLuint formats[3][3] = {
@@ -138,9 +181,9 @@ void r300SetDepthTexMode(struct gl_texture_object *tObj)
                        R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, X, X16),
                },
                {
-                       R300_EASY_TX_FORMAT(X, X, X, ONE, X24_Y8),
-                       R300_EASY_TX_FORMAT(X, X, X, X, X24_Y8),
-                       R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, X, X24_Y8),
+                       R300_EASY_TX_FORMAT(Y, Y, Y, ONE, X24_Y8),
+                       R300_EASY_TX_FORMAT(Y, Y, Y, Y, X24_Y8),
+                       R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, Y, X24_Y8),
                },
                {
                        R300_EASY_TX_FORMAT(X, X, X, ONE, X32),
@@ -156,11 +199,11 @@ void r300SetDepthTexMode(struct gl_texture_object *tObj)
 
        t = radeon_tex_obj(tObj);
 
-       switch (tObj->Image[0][tObj->BaseLevel]->TexFormat->MesaFormat) {
+       switch (tObj->Image[0][tObj->BaseLevel]->TexFormat) {
        case MESA_FORMAT_Z16:
                format = formats[0];
                break;
-       case MESA_FORMAT_Z24_S8:
+       case MESA_FORMAT_S8_Z24:
                format = formats[1];
                break;
        case MESA_FORMAT_Z32:
@@ -203,32 +246,29 @@ void r300SetDepthTexMode(struct gl_texture_object *tObj)
 static void setup_hardware_state(r300ContextPtr rmesa, radeonTexObj *t)
 {
        const struct gl_texture_image *firstImage;
-       int firstlevel = t->mt ? t->mt->firstLevel : 0;
-           
-       firstImage = t->base.Image[0][firstlevel];
+       firstImage = t->base.Image[0][t->minLod];
 
-       if (!t->image_override
-           && VALID_FORMAT(firstImage->TexFormat->MesaFormat)) {
-               if (firstImage->TexFormat->BaseFormat == GL_DEPTH_COMPONENT) {
+       if (!t->image_override) {
+               if (firstImage->_BaseFormat == GL_DEPTH_COMPONENT) {
                        r300SetDepthTexMode(&t->base);
                } else {
-                       t->pp_txformat = tx_table[firstImage->TexFormat->MesaFormat].format;
+                       int32_t txformat = r300TranslateTexFormat(firstImage->TexFormat);
+                       if (txformat < 0) {
+                               _mesa_problem(rmesa->radeon.glCtx, "%s: Invalid format %s",
+                                                         __FUNCTION__, _mesa_get_format_name(firstImage->TexFormat));
+                               exit(1);
+                       }
+                       t->pp_txformat = (uint32_t) txformat;
                }
-
-               t->pp_txfilter |= tx_table[firstImage->TexFormat->MesaFormat].filter;
-       } else if (!t->image_override) {
-               _mesa_problem(NULL, "unexpected texture format in %s",
-                             __FUNCTION__);
-               return;
        }
 
        if (t->image_override && t->bo)
                return;
 
-       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));
+       t->pp_txsize = (((R300_TX_WIDTHMASK_MASK & ((firstImage->Width - 1) << R300_TX_WIDTHMASK_SHIFT)))
+                       | ((R300_TX_HEIGHTMASK_MASK & ((firstImage->Height - 1) << R300_TX_HEIGHTMASK_SHIFT)))
+                       | ((R300_TX_DEPTHMASK_MASK & ((firstImage->DepthLog2) << R300_TX_DEPTHMASK_SHIFT)))
+                       | ((R300_TX_MAX_MIP_LEVEL_MASK & ((t->maxLod - t->minLod) << R300_TX_MAX_MIP_LEVEL_SHIFT))));
 
        t->tile_bits = 0;
 
@@ -239,7 +279,7 @@ static void setup_hardware_state(r300ContextPtr rmesa, radeonTexObj *t)
 
 
        if (t->base.Target == GL_TEXTURE_RECTANGLE_NV) {
-               unsigned int align = (64 / t->mt->bpp) - 1;
+               unsigned int align = (64 / _mesa_get_format_bytes(firstImage->TexFormat)) - 1;
                t->pp_txsize |= R300_TX_SIZE_TXPITCH_EN;
                if (!t->image_override)
                        t->pp_txpitch = ((firstImage->Width + align) & ~align) - 1;
@@ -248,8 +288,12 @@ static void setup_hardware_state(r300ContextPtr rmesa, radeonTexObj *t)
        if (rmesa->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515) {
            if (firstImage->Width > 2048)
                t->pp_txpitch |= R500_TXWIDTH_BIT11;
+            else
+               t->pp_txpitch &= ~R500_TXWIDTH_BIT11;
            if (firstImage->Height > 2048)
                t->pp_txpitch |= R500_TXHEIGHT_BIT11;
+            else
+               t->pp_txpitch &= ~R500_TXHEIGHT_BIT11;
        }
 }
 
@@ -355,18 +399,15 @@ void r300SetTexOffset(__DRIcontext * pDRICtx, GLint texname,
        switch (depth) {
        case 32:
                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->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->pp_txformat = R300_EASY_TX_FORMAT(X, Y, Z, ONE, Z5Y6X5);
-               t->pp_txfilter |= tx_table[5].filter;
                pitch_val /= 2;
                break;
        }
@@ -407,18 +448,7 @@ void r300SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_fo
            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;
-       }
+       radeon_update_renderbuffers(pDRICtx, dPriv, GL_TRUE);
        rb = rfb->color_rb[0];
        if (rb->bo == NULL) {
                /* Failed to BO for the buffer */
@@ -434,20 +464,13 @@ void r300SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_fo
                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;
-       }
+
+       radeon_miptree_unreference(&t->mt);
+       radeon_miptree_unreference(&rImage->mt);
+
        _mesa_init_teximage_fields(radeon->glCtx, target, texImage,
                                   rb->base.Width, rb->base.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;
@@ -463,32 +486,33 @@ void r300SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_fo
                        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->base.Width - 1) << R300_TX_WIDTHMASK_SHIFT) |
-              ((rb->base.Height - 1) << R300_TX_HEIGHTMASK_SHIFT);
+       t->pp_txsize = (((R300_TX_WIDTHMASK_MASK & ((rb->base.Width - 1) << R300_TX_WIDTHMASK_SHIFT)))
+                       | ((R300_TX_HEIGHTMASK_MASK & ((rb->base.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->base.Width > 2048)
                t->pp_txpitch |= R500_TXWIDTH_BIT11;
+            else
+               t->pp_txpitch &= ~R500_TXWIDTH_BIT11;
            if (rb->base.Height > 2048)
                t->pp_txpitch |= R500_TXHEIGHT_BIT11;
+            else
+               t->pp_txpitch &= ~R500_TXHEIGHT_BIT11;
        }
        t->validated = GL_TRUE;
        _mesa_unlock_texture(radeon->glCtx, texObj);
index 43629d643bcc9f34f80c2018bbddeec262d4c9a0..aa98a049aa4aad5d64ab00c5997263a3200c6f25 100644 (file)
@@ -62,12 +62,6 @@ static int r300VertexProgUpdateParams(GLcontext * ctx, struct r300_vertex_progra
                }
        }
 
-       if (vp->code.constants.Count * 4 > VSF_MAX_FRAGMENT_LENGTH) {
-               /* Should have checked this earlier... */
-               fprintf(stderr, "%s:Params exhausted\n", __FUNCTION__);
-               _mesa_exit(-1);
-       }
-
        for(i = 0; i < vp->code.constants.Count; ++i) {
                const float * src = 0;
                const struct rc_constant * constant = &vp->code.constants.Constants[i];
@@ -281,6 +275,11 @@ static struct r300_vertex_program *build_program(GLcontext *ctx,
        }
 
        r3xx_compile_vertex_program(&compiler);
+
+       if (vp->code.constants.Count > ctx->Const.VertexProgram.MaxParameters) {
+               rc_error(&compiler.Base, "Program exceeds constant buffer size limit\n");
+       }
+
        vp->error = compiler.Base.Error;
 
        vp->Base->Base.InputsRead = vp->code.InputsRead;
@@ -334,7 +333,6 @@ struct r300_vertex_program * r300SelectAndTranslateVertexShader(GLcontext *ctx)
 #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)
 
@@ -367,7 +365,7 @@ static void r300EmitVertexProgram(r300ContextPtr r300, int dest, struct r300_ver
                        break;
                default:
                        fprintf(stderr, "%s:%s don't know how to handle dest %04x\n", __FILE__, __FUNCTION__, dest);
-                       _mesa_exit(-1);
+                       exit(-1);
        }
 }
 
diff --git a/src/mesa/drivers/dri/r300/radeon_bo.c b/src/mesa/drivers/dri/r300/radeon_bo.c
new file mode 120000 (symlink)
index 0000000..9448ffe
--- /dev/null
@@ -0,0 +1 @@
+../radeon/radeon_bo.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/r300/radeon_bo_int_drm.h b/src/mesa/drivers/dri/r300/radeon_bo_int_drm.h
new file mode 120000 (symlink)
index 0000000..0294509
--- /dev/null
@@ -0,0 +1 @@
+../radeon/radeon_bo_int_drm.h
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/r300/radeon_cs.c b/src/mesa/drivers/dri/r300/radeon_cs.c
new file mode 120000 (symlink)
index 0000000..66b7ad1
--- /dev/null
@@ -0,0 +1 @@
+../radeon/radeon_cs.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/r300/radeon_cs_int_drm.h b/src/mesa/drivers/dri/r300/radeon_cs_int_drm.h
new file mode 120000 (symlink)
index 0000000..462f524
--- /dev/null
@@ -0,0 +1 @@
+../radeon/radeon_cs_int_drm.h
\ No newline at end of file
index 7d5a7b1ab6f9a3ec33cbbdbbe64387f52739f706..26f47b7268720cce0742a839dabf57f41d779c03 100644 (file)
@@ -14,7 +14,7 @@ EGL_SOURCES = server/radeon_egl.c
 endif
 
 ifeq ($(RADEON_LDFLAGS),)
-CS_SOURCES = radeon_cs_space_drm.c
+CS_SOURCES = radeon_cs_space_drm.c radeon_bo.c radeon_cs.c
 endif
 
 COMMON_SOURCES = \
@@ -76,4 +76,3 @@ DRI_LIB_DEPS += $(RADEON_LDFLAGS)
 
 include ../Makefile.template
 
-symlinks:
index 3cfe03a45f765675860e788f965d6bdad207bdfb..370bb04f93247cb3356c850b585dd1dd7d30a513 100644 (file)
@@ -52,29 +52,49 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "radeon_mipmap_tree.h"
 #include "radeon_reg.h"
 
+#ifdef HAVE_LIBDRM_RADEON
+#include "radeon_cs_int.h"
+#else
+#include "radeon_cs_int_drm.h"
+#endif
 
+struct r600_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 r600_cs_reloc_legacy {
+    struct radeon_cs_reloc  base;
+    uint32_t                cindices;
+    uint32_t                *indices;
+    uint32_t                *reloc_indices;
+};
 
-static struct radeon_cs * r600_cs_create(struct radeon_cs_manager *csm,
-                                   uint32_t ndw)
+static struct radeon_cs_int *r600_cs_create(struct radeon_cs_manager *csm,
+                                           uint32_t ndw)
 {
-    struct radeon_cs *cs;
+    struct radeon_cs_int *csi;
 
-    cs = (struct radeon_cs*)calloc(1, sizeof(struct radeon_cs));
-    if (cs == NULL) {
+    csi = (struct radeon_cs_int*)calloc(1, sizeof(struct radeon_cs_int));
+    if (csi == 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);
+    csi->csm = csm;
+    csi->ndw = (ndw + 0x3FF) & (~0x3FF);
+    csi->packets = (uint32_t*)malloc(4*csi->ndw);
+    if (csi->packets == NULL) {
+        free(csi);
         return NULL;
     }
-    cs->relocs_total_size = 0;
-    return cs;
+    csi->relocs_total_size = 0;
+    return csi;
 }
 
-static int r600_cs_write_reloc(struct radeon_cs *cs,
+static int r600_cs_write_reloc(struct radeon_cs_int *csi,
                               struct radeon_bo *bo,
                               uint32_t read_domain,
                               uint32_t write_domain,
@@ -83,7 +103,7 @@ static int r600_cs_write_reloc(struct radeon_cs *cs,
     struct r600_cs_reloc_legacy *relocs;
     int i;
 
-    relocs = (struct r600_cs_reloc_legacy *)cs->relocs;
+    relocs = (struct r600_cs_reloc_legacy *)csi->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
@@ -98,7 +118,7 @@ static int r600_cs_write_reloc(struct radeon_cs *cs,
         return -EINVAL;
     }
     /* check if bo is already referenced */
-    for(i = 0; i < cs->crelocs; i++) {
+    for(i = 0; i < csi->crelocs; i++) {
         uint32_t *indices;
         uint32_t *reloc_indices;
 
@@ -129,109 +149,108 @@ static int r600_cs_write_reloc(struct radeon_cs *cs,
             }
             relocs[i].indices = indices;
             relocs[i].reloc_indices = reloc_indices;
-            relocs[i].indices[relocs[i].cindices - 1] = cs->cdw;
-            relocs[i].reloc_indices[relocs[i].cindices - 1] = cs->cdw;
-            cs->section_cdw += 2;
-           cs->cdw += 2;
+            relocs[i].indices[relocs[i].cindices - 1] = csi->cdw;
+            relocs[i].reloc_indices[relocs[i].cindices - 1] = csi->cdw;
+            csi->section_cdw += 2;
+           csi->cdw += 2;
 
             return 0;
         }
     }
     /* add bo to reloc */
     relocs = (struct r600_cs_reloc_legacy*)
-             realloc(cs->relocs,
-                     sizeof(struct r600_cs_reloc_legacy) * (cs->crelocs + 1));
+             realloc(csi->relocs,
+                     sizeof(struct r600_cs_reloc_legacy) * (csi->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);
-    relocs[cs->crelocs].reloc_indices = (uint32_t*)malloc(4);
-    if ( (relocs[cs->crelocs].indices == NULL) || (relocs[cs->crelocs].reloc_indices == NULL) )
+    csi->relocs = relocs;
+    relocs[csi->crelocs].base.bo = bo;
+    relocs[csi->crelocs].base.read_domain = read_domain;
+    relocs[csi->crelocs].base.write_domain = write_domain;
+    relocs[csi->crelocs].base.flags = flags;
+    relocs[csi->crelocs].indices = (uint32_t*)malloc(4);
+    relocs[csi->crelocs].reloc_indices = (uint32_t*)malloc(4);
+    if ( (relocs[csi->crelocs].indices == NULL) || (relocs[csi->crelocs].reloc_indices == NULL) )
     {
         return -ENOMEM;
     }
 
-    relocs[cs->crelocs].indices[0] = cs->cdw;
-    relocs[cs->crelocs].reloc_indices[0] = cs->cdw;
-    cs->section_cdw += 2;
-    cs->cdw += 2;
-    relocs[cs->crelocs].cindices = 1;
-    cs->relocs_total_size += radeon_bo_legacy_relocs_size(bo);
-    cs->crelocs++;
+    relocs[csi->crelocs].indices[0] = csi->cdw;
+    relocs[csi->crelocs].reloc_indices[0] = csi->cdw;
+    csi->section_cdw += 2;
+    csi->cdw += 2;
+    relocs[csi->crelocs].cindices = 1;
+    csi->relocs_total_size += radeon_bo_legacy_relocs_size(bo);
+    csi->crelocs++;
 
     radeon_bo_ref(bo);
 
     return 0;
 }
 
-static int r600_cs_begin(struct radeon_cs *cs,
+static int r600_cs_begin(struct radeon_cs_int *csi,
                     uint32_t ndw,
                     const char *file,
                     const char *func,
                     int line)
 {
-    if (cs->section) {
+    if (csi->section_ndw) {
         fprintf(stderr, "CS already in a section(%s,%s,%d)\n",
-                cs->section_file, cs->section_func, cs->section_line);
+                csi->section_file, csi->section_func, csi->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;
+    csi->section_ndw = ndw;
+    csi->section_cdw = 0;
+    csi->section_file = file;
+    csi->section_func = func;
+    csi->section_line = line;
 
-    if (cs->cdw + ndw > cs->ndw) {
+    if (csi->cdw + ndw > csi->ndw) {
         uint32_t tmp, *ptr;
        int num = (ndw > 0x400) ? ndw : 0x400;
 
-        tmp = (cs->cdw + num + 0x3FF) & (~0x3FF);
-        ptr = (uint32_t*)realloc(cs->packets, 4 * tmp);
+        tmp = (csi->cdw + num + 0x3FF) & (~0x3FF);
+        ptr = (uint32_t*)realloc(csi->packets, 4 * tmp);
         if (ptr == NULL) {
             return -ENOMEM;
         }
-        cs->packets = ptr;
-        cs->ndw = tmp;
+        csi->packets = ptr;
+        csi->ndw = tmp;
     }
 
     return 0;
 }
 
-static int r600_cs_end(struct radeon_cs *cs,
+static int r600_cs_end(struct radeon_cs_int *csi,
                   const char *file,
                   const char *func,
                   int line)
 
 {
-    if (!cs->section) {
+    if (!csi->section_ndw) {
         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 ) {
+    if ( csi->section_ndw != csi->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_ndw = %d, cs->cdw = %d, cs->section_cdw = %d \n",
-                cs->section_ndw, cs->cdw, cs->section_cdw);
+                csi->section_file, csi->section_func, csi->section_line, csi->section_ndw, csi->section_cdw);
+        fprintf(stderr, "csi->section_ndw = %d, csi->cdw = %d, csi->section_cdw = %d \n",
+                csi->section_ndw, csi->cdw, csi->section_cdw);
         fprintf(stderr, "CS section end at (%s,%s,%d)\n",
                 file, func, line);
         return -EPIPE;
     }
+    csi->section_ndw = 0;
 
-    if (cs->cdw > cs->ndw) {
+    if (csi->cdw > csi->ndw) {
            fprintf(stderr, "CS section overflow at (%s,%s,%d) cdw %d ndw %d\n",
-                   cs->section_file, cs->section_func, cs->section_line,cs->cdw,cs->ndw);
+                   csi->section_file, csi->section_func, csi->section_line,csi->cdw,csi->ndw);
            fprintf(stderr, "CS section end at (%s,%s,%d)\n",
                    file, func, line);
            assert(0);
@@ -240,21 +259,21 @@ static int r600_cs_end(struct radeon_cs *cs,
     return 0;
 }
 
-static int r600_cs_process_relocs(struct radeon_cs *cs
+static int r600_cs_process_relocs(struct radeon_cs_int *csi
                                   uint32_t * reloc_chunk,
                                   uint32_t * length_dw_reloc_chunk) 
 {
-    struct r600_cs_manager_legacy *csm = (struct r600_cs_manager_legacy*)cs->csm;
+    struct r600_cs_manager_legacy *csm = (struct r600_cs_manager_legacy*)csi->csm;
     struct r600_cs_reloc_legacy *relocs;
     int i, j, r;
 
     uint32_t offset_dw = 0;
 
-    csm = (struct r600_cs_manager_legacy*)cs->csm;
-    relocs = (struct r600_cs_reloc_legacy *)cs->relocs;
+    csm = (struct r600_cs_manager_legacy*)csi->csm;
+    relocs = (struct r600_cs_reloc_legacy *)csi->relocs;
 restart:
-    for (i = 0; i < cs->crelocs; i++) {
-            uint32_t soffset, eoffset, asicoffset;
+    for (i = 0; i < csi->crelocs; i++) {
+            uint32_t soffset, eoffset;
 
             r = radeon_bo_legacy_validate(relocs[i].base.bo,
                                          &soffset, &eoffset);
@@ -262,32 +281,20 @@ restart:
                    goto restart;
             }
             if (r) {
-                   fprintf(stderr, "validated %p [0x%08X, 0x%08X]\n",
+                   fprintf(stderr, "invalid bo(%p) [0x%08X, 0x%08X]\n",
                            relocs[i].base.bo, soffset, eoffset);
                    return r;
             }
-            asicoffset = soffset;
 
            for (j = 0; j < relocs[i].cindices; j++) {
-                   if (asicoffset >= 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;
-                   }
                    /* pkt3 nop header in ib chunk */
-                   cs->packets[relocs[i].reloc_indices[j]] = 0xC0001000;
+                   csi->packets[relocs[i].reloc_indices[j]] = 0xC0001000;
                    /* reloc index in ib chunk */
-                   cs->packets[relocs[i].reloc_indices[j] + 1] = offset_dw;
+                   csi->packets[relocs[i].reloc_indices[j] + 1] = offset_dw;
            }
 
            /* asic offset in reloc chunk */ /* see alex drm r600_nomm_relocate */
-           reloc_chunk[offset_dw] = asicoffset;
+           reloc_chunk[offset_dw] = soffset;
            reloc_chunk[offset_dw + 3] = 0;
 
            offset_dw += 4;
@@ -298,14 +305,14 @@ restart:
     return 0;
 }
 
-static int r600_cs_set_age(struct radeon_cs *cs) /* -------------- */
+static int r600_cs_set_age(struct radeon_cs_int *csi) /* -------------- */
 {
-    struct r600_cs_manager_legacy *csm = (struct r600_cs_manager_legacy*)cs->csm;
+    struct r600_cs_manager_legacy *csm = (struct r600_cs_manager_legacy*)csi->csm;
     struct r600_cs_reloc_legacy *relocs;
     int i;
 
-    relocs = (struct r600_cs_reloc_legacy *)cs->relocs;
-    for (i = 0; i < cs->crelocs; i++) {
+    relocs = (struct r600_cs_reloc_legacy *)csi->relocs;
+    for (i = 0; i < csi->crelocs; i++) {
         radeon_bo_legacy_pending(relocs[i].base.bo, csm->pending_age);
         radeon_bo_unref(relocs[i].base.bo);
     }
@@ -313,21 +320,21 @@ static int r600_cs_set_age(struct radeon_cs *cs) /* -------------- */
 }
 
 #if 0
-static void dump_cmdbuf(struct radeon_cs *cs)
+static void dump_cmdbuf(struct radeon_cs_int *csi)
 {
        int i;
        fprintf(stderr,"--start--\n");
-       for (i = 0; i < cs->cdw; i++){
-               fprintf(stderr,"0x%08x\n", cs->packets[i]);
+       for (i = 0; i < csi->cdw; i++){
+               fprintf(stderr,"0x%08x\n", csi->packets[i]);
        }
        fprintf(stderr,"--end--\n");
 
 }
 #endif
 
-static int r600_cs_emit(struct radeon_cs *cs)
+static int r600_cs_emit(struct radeon_cs_int *csi)
 {
-    struct r600_cs_manager_legacy *csm = (struct r600_cs_manager_legacy*)cs->csm;
+    struct r600_cs_manager_legacy *csm = (struct r600_cs_manager_legacy*)csi->csm;
     struct drm_radeon_cs       cs_cmd;
     struct drm_radeon_cs_chunk cs_chunk[2];
     uint32_t length_dw_reloc_chunk;
@@ -341,9 +348,9 @@ static int r600_cs_emit(struct radeon_cs *cs)
 
     csm->pending_count = 1;
 
-    reloc_chunk = (uint32_t*)calloc(1, cs->crelocs * 4 * 4);
+    reloc_chunk = (uint32_t*)calloc(1, csi->crelocs * 4 * 4);
 
-    r = r600_cs_process_relocs(cs, reloc_chunk, &length_dw_reloc_chunk);
+    r = r600_cs_process_relocs(csi, reloc_chunk, &length_dw_reloc_chunk);
     if (r) {
        free(reloc_chunk);
         return 0;
@@ -351,8 +358,8 @@ static int r600_cs_emit(struct radeon_cs *cs)
 
     /* raw ib chunk */
     cs_chunk[0].chunk_id   = RADEON_CHUNK_ID_IB;
-    cs_chunk[0].length_dw  = cs->cdw;
-    cs_chunk[0].chunk_data = (unsigned long)(cs->packets);
+    cs_chunk[0].length_dw  = csi->cdw;
+    cs_chunk[0].chunk_data = (unsigned long)(csi->packets);
 
     /* reloc chaunk */
     cs_chunk[1].chunk_id   = RADEON_CHUNK_ID_RELOCS;
@@ -370,7 +377,7 @@ static int r600_cs_emit(struct radeon_cs *cs)
 
     do 
     {
-        r = drmCommandWriteRead(cs->csm->fd, DRM_RADEON_CS, &cs_cmd, sizeof(cs_cmd));
+        r = drmCommandWriteRead(csi->csm->fd, DRM_RADEON_CS, &cs_cmd, sizeof(cs_cmd));
         retry++;
     } while (r == -EAGAIN && retry < 1000);
 
@@ -381,11 +388,11 @@ static int r600_cs_emit(struct radeon_cs *cs)
 
     csm->pending_age = cs_cmd.cs_id;
 
-    r600_cs_set_age(cs);
+    r600_cs_set_age(csi);
 
-    cs->csm->read_used = 0;
-    cs->csm->vram_write_used = 0;
-    cs->csm->gart_write_used = 0;
+    csi->csm->read_used = 0;
+    csi->csm->vram_write_used = 0;
+    csi->csm->gart_write_used = 0;
 
     free(reloc_chunk);
 
@@ -405,35 +412,34 @@ static void inline r600_cs_free_reloc(void *relocs_p, int crelocs)
     }
 }
 
-static int r600_cs_destroy(struct radeon_cs *cs)
+static int r600_cs_destroy(struct radeon_cs_int *csi)
 {
-    r600_cs_free_reloc(cs->relocs, cs->crelocs);
-    free(cs->relocs);
-    free(cs->packets);
-    free(cs);
+    r600_cs_free_reloc(csi->relocs, csi->crelocs);
+    free(csi->relocs);
+    free(csi->packets);
+    free(csi);
     return 0;
 }
 
-static int r600_cs_erase(struct radeon_cs *cs)
+static int r600_cs_erase(struct radeon_cs_int *csi)
 {
-    r600_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;
+    r600_cs_free_reloc(csi->relocs, csi->crelocs);
+    free(csi->relocs);
+    csi->relocs_total_size = 0;
+    csi->relocs = NULL;
+    csi->crelocs = 0;
+    csi->cdw = 0;
     return 0;
 }
 
-static int r600_cs_need_flush(struct radeon_cs *cs)
+static int r600_cs_need_flush(struct radeon_cs_int *csi)
 {
     /* 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 r600_cs_print(struct radeon_cs *cs, FILE *file)
+static void r600_cs_print(struct radeon_cs_int *csi, FILE *file)
 {
 }
 
index eba43d37b6b53b8ad4b3d8c75e4f175dbff0d13c..dff000969993c1b87a1e6ac390fd037eb7c04ffb 100644 (file)
@@ -118,22 +118,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define R600_IT_SET_CTL_CONST                     0x00006F00
 #define R600_IT_SURFACE_BASE_UPDATE               0x00007300
 
-struct r600_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 r600_cs_reloc_legacy {
-    struct radeon_cs_reloc  base;
-    uint32_t                cindices;
-    uint32_t                *indices;
-    uint32_t                *reloc_indices;
-};
-
 struct radeon_cs_manager * r600_radeon_cs_manager_legacy_ctor(struct radeon_context *ctx);
 
 /**
index 969144ba12364899d3f670b6219a0f7ef2d4fd98..cb549497f54b61f36f5d0c447f98bf68c4644069 100644 (file)
@@ -64,6 +64,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "r600_cmdbuf.h"
 #include "r600_emit.h"
 #include "radeon_bocs_wrapper.h"
+#include "radeon_queryobj.h"
 
 #include "r700_state.h"
 #include "r700_ioctl.h"
@@ -73,11 +74,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #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 R600_ENABLE_GLSL_TEST 1
 
 #define need_GL_VERSION_2_0
+#define need_GL_ARB_occlusion_query
 #define need_GL_ARB_point_parameters
 #define need_GL_ARB_vertex_program
 #define need_GL_EXT_blend_equation_separate
@@ -92,14 +92,15 @@ int hw_tcl_on = 1;
 #define need_GL_ATI_separate_stencil
 #define need_GL_NV_vertex_program
 
-#include "extension_helper.h"
+#include "main/remap_helper.h"
 
-extern const struct tnl_pipeline_stage *r700_pipeline[];
-
-const struct dri_extension card_extensions[] = {
+static const struct dri_extension card_extensions[] = {
   /* *INDENT-OFF* */
+  {"GL_ARB_depth_clamp",                NULL},
   {"GL_ARB_depth_texture",             NULL},
   {"GL_ARB_fragment_program",          NULL},
+  {"GL_ARB_fragment_program_shadow",   NULL},
+  {"GL_ARB_occlusion_query",            GL_ARB_occlusion_query_functions},
   {"GL_ARB_multitexture",              NULL},
   {"GL_ARB_point_parameters",          GL_ARB_point_parameters_functions},
   {"GL_ARB_shadow",                    NULL},
@@ -111,6 +112,7 @@ const struct dri_extension card_extensions[] = {
   {"GL_ARB_texture_env_crossbar",      NULL},
   {"GL_ARB_texture_env_dot3",          NULL},
   {"GL_ARB_texture_mirrored_repeat",   NULL},
+  {"GL_ARB_texture_non_power_of_two",   NULL},
   {"GL_ARB_vertex_program",            GL_ARB_vertex_program_functions},
   {"GL_EXT_blend_equation_separate",   GL_EXT_blend_equation_separate_functions},
   {"GL_EXT_blend_func_separate",       GL_EXT_blend_func_separate_functions},
@@ -131,6 +133,7 @@ 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_vertex_array_bgra",          NULL},
   {"GL_EXT_texture_sRGB",               NULL},
   {"GL_ATI_separate_stencil",          GL_ATI_separate_stencil_functions},
   {"GL_ATI_texture_env_combine3",      NULL},
@@ -146,7 +149,7 @@ const struct dri_extension card_extensions[] = {
 };
 
 
-const struct dri_extension mm_extensions[] = {
+static const struct dri_extension mm_extensions[] = {
   { "GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions },
   { NULL, NULL }
 };
@@ -155,21 +158,29 @@ const struct dri_extension mm_extensions[] = {
  * The GL 2.0 functions are needed to make display lists work with
  * functions added by GL_ATI_separate_stencil.
  */
-const struct dri_extension gl_20_extension[] = {
+static const struct dri_extension gl_20_extension[] = {
+#ifdef R600_ENABLE_GLSL_TEST
+    {"GL_ARB_shading_language_100",                    GL_VERSION_2_0_functions },
+#else
   {"GL_VERSION_2_0",                   GL_VERSION_2_0_functions },
+#endif /* R600_ENABLE_GLSL_TEST */
+  {NULL, NULL}
 };
 
-
-static void r600RunPipeline(GLcontext * ctx)
-{
-    _mesa_lock_context_textures(ctx);
-
-    if (ctx->NewState)
-        _mesa_update_state_locked(ctx);
-    
-    _tnl_run_pipeline(ctx);
-    _mesa_unlock_context_textures(ctx);
-}
+static const struct tnl_pipeline_stage *r600_pipeline[] = {
+       /* Catch any t&l fallbacks
+        */
+       &_tnl_vertex_transform_stage,
+       &_tnl_normal_transform_stage,
+       &_tnl_lighting_stage,
+       &_tnl_fog_coordinate_stage,
+       &_tnl_texgen_stage,
+       &_tnl_texture_transform_stage,
+       &_tnl_point_attenuation_stage,
+       &_tnl_vertex_program_stage,
+       &_tnl_render_stage,
+       0,
+};
 
 static void r600_get_lock(radeonContextPtr rmesa)
 {
@@ -180,7 +191,7 @@ static void r600_get_lock(radeonContextPtr rmesa)
                if (!rmesa->radeonScreen->kernel_mm)
                        radeon_bo_legacy_texture_age(rmesa->radeonScreen->bom);
        }
-}                
+}
 
 static void r600_vtbl_emit_cs_header(struct radeon_cs *cs, radeonContextPtr rmesa)
 {
@@ -202,6 +213,24 @@ static void r600_fallback(GLcontext *ctx, GLuint bit, GLboolean mode)
                context->radeon.Fallback &= ~bit;
 }
 
+static void r600_emit_query_finish(radeonContextPtr radeon)
+{
+       context_t *context = (context_t*) radeon;
+       BATCH_LOCALS(&context->radeon);
+
+       struct radeon_query_object *query = radeon->query.current;
+
+       BEGIN_BATCH_NO_AUTOSTATE(4 + 2);
+       R600_OUT_BATCH(CP_PACKET3(R600_IT_EVENT_WRITE, 2));
+       R600_OUT_BATCH(ZPASS_DONE);
+       R600_OUT_BATCH(query->curr_offset + 8); /* hw writes qwords */
+       R600_OUT_BATCH(0x00000000);
+       R600_OUT_BATCH_RELOC(VGT_EVENT_INITIATOR, query->bo, 0, 0, RADEON_GEM_DOMAIN_GTT, 0);
+       END_BATCH();
+       assert(query->curr_offset < RADEON_QUERY_PAGE_SIZE);
+       query->emitted_begin = GL_FALSE;
+}
+
 static void r600_init_vtbl(radeonContextPtr radeon)
 {
        radeon->vtbl.get_lock = r600_get_lock;
@@ -210,71 +239,12 @@ static void r600_init_vtbl(radeonContextPtr radeon)
        radeon->vtbl.swtcl_flush = NULL;
        radeon->vtbl.pre_emit_atoms = r600_vtbl_pre_emit_atoms;
        radeon->vtbl.fallback = r600_fallback;
+       radeon->vtbl.emit_query_finish = r600_emit_query_finish;
 }
 
-/* Create the device specific rendering context.
- */
-GLboolean r600CreateContext(const __GLcontextModes * glVisual,
-                           __DRIcontextPrivate * driContextPriv,
-                           void *sharedContextPrivate)
+static void r600InitConstValues(GLcontext *ctx, radeonScreenPtr screen)
 {
-       __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
-       radeonScreenPtr screen = (radeonScreenPtr) (sPriv->private);
-       struct dd_function_table functions;
-       context_t *r600;
-       GLcontext *ctx;
-
-       assert(glVisual);
-       assert(driContextPriv);
-       assert(screen);
-
-       /* Allocate the R600 context */
-       r600 = (context_t*) CALLOC(sizeof(*r600));
-       if (!r600) {
-               radeon_error("Failed to allocate memory for context.\n");
-               return GL_FALSE;
-       }
-
-       if (!(screen->chip_flags & RADEON_CHIPSET_TCL))
-               hw_tcl_on = future_hw_tcl_on = 0;
-
-       r600_init_vtbl(&r600->radeon);
-       /* Parse configuration files.
-        * Do this here so that initialMaxAnisotropy is set before we create
-        * the default textures.
-        */
-       driParseConfigFiles(&r600->radeon.optionCache, &screen->optionCache,
-                           screen->driScreen->myNum, "r600");
-
-       r600->radeon.initialMaxAnisotropy = driQueryOptionf(&r600->radeon.optionCache,
-                                                    "def_max_anisotropy");
-
-       /* Init default driver functions then plug in our R600-specific functions
-        * (the texture functions are especially important)
-        */
-       _mesa_init_driver_functions(&functions);
-
-       r700InitStateFuncs(&functions);
-       r600InitTextureFuncs(&functions);
-       r700InitShaderFuncs(&functions);
-       r700InitIoctlFuncs(&functions);
-    radeonInitBufferObjectFuncs(&functions);
-
-       if (!radeonInitContext(&r600->radeon, &functions,
-                              glVisual, driContextPriv,
-                              sharedContextPrivate)) {
-               radeon_error("Initializing context failed.\n");
-               FREE(r600);
-               return GL_FALSE;
-       }
-
-       /* Init r600 context data */
-       /* 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 = r600->radeon.glCtx;
+       context_t *r600 = R700_CONTEXT(ctx);
 
        ctx->Const.MaxTextureImageUnits =
            driQueryOptioni(&r600->radeon.optionCache, "texture_image_units");
@@ -299,38 +269,7 @@ GLboolean r600CreateContext(const __GLcontextModes * glVisual,
        ctx->Const.MaxLineWidth   = 0xffff / 8.0;
        ctx->Const.MaxLineWidthAA = 0xffff / 8.0;
 
-       /* Needs further modifications */
-#if 0
-       ctx->Const.MaxArrayLockSize =
-           ( /*512 */ RADEON_BUFFER_SIZE * 16 * 1024) / (4 * 4);
-#endif
-
-       ctx->Const.MaxDrawBuffers = 1;
-
-       /* Initialize the software rasterizer and helper modules.
-        */
-       _swrast_CreateContext(ctx);
-       _vbo_CreateContext(ctx);
-       _tnl_CreateContext(ctx);
-       _swsetup_CreateContext(ctx);
-       _swsetup_Wakeup(ctx);
-       _ae_create_context(ctx);
-
-       /* Install the customized pipeline:
-        */
-       _tnl_destroy_pipeline(ctx);
-       _tnl_install_pipeline(ctx, r700_pipeline);
-
-       /* Try and keep materials and vertices separate:
-        */
-/*     _tnl_isolate_materials(ctx, GL_TRUE); */
-
-       /* Configure swrast and TNL to match hardware characteristics:
-        */
-       _swrast_allow_pixel_fog(ctx, GL_FALSE);
-       _swrast_allow_vertex_fog(ctx, GL_TRUE);
-       _tnl_allow_pixel_fog(ctx, GL_FALSE);
-       _tnl_allow_vertex_fog(ctx, GL_TRUE);
+       ctx->Const.MaxDrawBuffers = 1; /* hw supports 8 */
 
        /* 256 for reg-based consts, inline consts also supported */
        ctx->Const.VertexProgram.MaxInstructions = 8192; /* in theory no limit */
@@ -354,15 +293,38 @@ GLboolean r600CreateContext(const __GLcontextModes * glVisual,
        ctx->Const.FragmentProgram.MaxNativeInstructions = 8192;
        ctx->Const.FragmentProgram.MaxNativeTexIndirections = 8; /* ??? */
        ctx->Const.FragmentProgram.MaxNativeAddressRegs = 0;    /* and these are?? */
-       ctx->VertexProgram._MaintainTnlProgram = GL_TRUE;
-       ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
+}
 
-       radeon_init_debug();
+static void r600ParseOptions(context_t *r600, radeonScreenPtr screen)
+{
+       /* Parse configuration files.
+        * Do this here so that initialMaxAnisotropy is set before we create
+        * the default textures.
+        */
+       driParseConfigFiles(&r600->radeon.optionCache, &screen->optionCache,
+                           screen->driScreen->myNum, "r600");
+
+       r600->radeon.initialMaxAnisotropy = driQueryOptionf(&r600->radeon.optionCache,
+                                                           "def_max_anisotropy");
+
+}
+
+static void r600InitGLExtensions(GLcontext *ctx)
+{
+       context_t *r600 = R700_CONTEXT(ctx);
 
        driInitExtensions(ctx, card_extensions, GL_TRUE);
        if (r600->radeon.radeonScreen->kernel_mm)
          driInitExtensions(ctx, mm_extensions, GL_FALSE);
 
+#ifdef R600_ENABLE_GLSL_TEST
+    driInitExtensions(ctx, gl_20_extension, GL_TRUE);
+    _mesa_enable_2_0_extensions(ctx);
+    
+    /* glsl compiler has problem if this is not GL_TRUE */
+    ctx->Shader.EmitCondCodes = GL_TRUE;
+#endif /* R600_ENABLE_GLSL_TEST */
+
        if (driQueryOptionb
            (&r600->radeon.optionCache, "disable_stencil_two_side"))
                _mesa_disable_extension(ctx, "GL_EXT_stencil_two_side");
@@ -377,21 +339,100 @@ GLboolean r600CreateContext(const __GLcontextModes * glVisual,
                _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc");
        }
 
-    r700InitDraw(ctx);
+       /* XXX: RV740 only seems to report results from half of its DBs */
+       if (r600->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV740)
+               _mesa_disable_extension(ctx, "GL_ARB_occlusion_query");
+}
 
-       radeon_fbo_init(&r600->radeon);
-       radeonInitSpanFuncs( ctx );
+/* Create the device specific rendering context.
+ */
+GLboolean r600CreateContext(const __GLcontextModes * glVisual,
+                           __DRIcontext * driContextPriv,
+                           void *sharedContextPrivate)
+{
+       __DRIscreen *sPriv = driContextPriv->driScreenPriv;
+       radeonScreenPtr screen = (radeonScreenPtr) (sPriv->private);
+       struct dd_function_table functions;
+       context_t *r600;
+       GLcontext *ctx;
 
-       r600InitCmdBuf(r600);
+       assert(glVisual);
+       assert(driContextPriv);
+       assert(screen);
 
-       r700InitState(r600->radeon.glCtx);
+       /* Allocate the R600 context */
+       r600 = (context_t*) CALLOC(sizeof(*r600));
+       if (!r600) {
+               radeon_error("Failed to allocate memory for context.\n");
+               return GL_FALSE;
+       }
+
+       r600ParseOptions(r600, screen);
+
+       r600->radeon.radeonScreen = screen;
+       r600_init_vtbl(&r600->radeon);
+
+       /* Init default driver functions then plug in our R600-specific functions
+        * (the texture functions are especially important)
+        */
+       _mesa_init_driver_functions(&functions);
 
-       TNL_CONTEXT(ctx)->Driver.RunPipeline = r600RunPipeline;
+       r700InitStateFuncs(&functions);
+       r600InitTextureFuncs(&functions);
+       r700InitShaderFuncs(&functions);
+       radeonInitQueryObjFunctions(&functions);
+       r700InitIoctlFuncs(&functions);
+       radeonInitBufferObjectFuncs(&functions);
 
-       if (driQueryOptionb(&r600->radeon.optionCache, "no_rast")) {
-               radeon_warning("disabling 3D acceleration\n");
+       if (!radeonInitContext(&r600->radeon, &functions,
+                              glVisual, driContextPriv,
+                              sharedContextPrivate)) {
+               radeon_error("Initializing context failed.\n");
+               FREE(r600);
+               return GL_FALSE;
        }
 
+       ctx = r600->radeon.glCtx;
+
+       ctx->VertexProgram._MaintainTnlProgram = GL_TRUE;
+       ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
+
+       r600InitConstValues(ctx, screen);
+
+       _mesa_set_mvp_with_dp4( ctx, GL_TRUE );
+
+       /* Initialize the software rasterizer and helper modules.
+        */
+       _swrast_CreateContext(ctx);
+       _vbo_CreateContext(ctx);
+       _tnl_CreateContext(ctx);
+       _swsetup_CreateContext(ctx);
+       _swsetup_Wakeup(ctx);
+
+       /* Install the customized pipeline:
+        */
+       _tnl_destroy_pipeline(ctx);
+       _tnl_install_pipeline(ctx, r600_pipeline);
+       TNL_CONTEXT(ctx)->Driver.RunPipeline = _tnl_run_pipeline;
+
+       /* Configure swrast and TNL to match hardware characteristics:
+        */
+       _swrast_allow_pixel_fog(ctx, GL_FALSE);
+       _swrast_allow_vertex_fog(ctx, GL_TRUE);
+       _tnl_allow_pixel_fog(ctx, GL_FALSE);
+       _tnl_allow_vertex_fog(ctx, GL_TRUE);
+
+       radeon_init_debug();
+
+       r700InitDraw(ctx);
+
+       radeon_fbo_init(&r600->radeon);
+       radeonInitSpanFuncs( ctx );
+       r600InitCmdBuf(r600);
+       r700InitState(r600->radeon.glCtx);
+
+       r600InitGLExtensions(ctx);
+
        return GL_TRUE;
 }
 
index 7f68820fda1b55730c4903fbfbcf849943645e3c..a1b4af715e2bc599a238aa571ed454dd61a1d389 100644 (file)
@@ -58,29 +58,6 @@ typedef struct r600_context context_t;
 
 #include "main/mm.h"
 
-/************ DMA BUFFERS **************/
-
-/* The blit width for texture uploads
- */
-#define R600_BLIT_WIDTH_BYTES 1024
-#define R600_MAX_TEXTURE_UNITS 8
-
-struct r600_texture_state {
-       int tc_count;           /* number of incoming texture coordinates from VAP */
-};
-
-/* Perhaps more if we store programs in vmem? */
-/* drm_r600_cmd_header_t->vpu->count is unsigned char */
-#define VSF_MAX_FRAGMENT_LENGTH (255*4)
-
-/* Can be tested with colormat currently. */
-#define VSF_MAX_FRAGMENT_TEMPS (14)
-
-#define STATE_R600_WINDOW_DIMENSION (STATE_INTERNAL_DRIVER+0)
-#define STATE_R600_TEXRECT_FACTOR (STATE_INTERNAL_DRIVER+1)
-
-extern int hw_tcl_on;
-
 #define COLOR_IS_RGBA
 #define TAG(x) r600##x
 #include "tnl_dd/t_dd_vertex.h"
@@ -131,6 +108,7 @@ typedef struct StreamDesc
        GLint   size;   //number of data element
        GLenum  type;  //data element type
        GLsizei stride;
+       GLenum  format; // GL_RGBA,GLBGRA 
 
        struct radeon_bo *bo;
        GLint  bo_offset;
@@ -167,9 +145,6 @@ struct r600_context {
 
        /* Vertex buffers
         */
-       GLvector4f dummy_attrib[_TNL_ATTRIB_MAX];
-       GLvector4f *temp_attrib[_TNL_ATTRIB_MAX];
-
        GLint      nNumActiveAos;
        StreamDesc stream_desc[VERT_ATTRIB_MAX];
     struct r700_index_buffer ind_buf;
@@ -179,7 +154,7 @@ struct r600_context {
 #define GL_CONTEXT(context)     ((GLcontext *)(context->radeon.glCtx))
 
 extern GLboolean r600CreateContext(const __GLcontextModes * glVisual,
-                                  __DRIcontextPrivate * driContextPriv,
+                                  __DRIcontext * driContextPriv,
                                   void *sharedContextPrivate);
 
 #define R700_CONTEXT_STATES(context) ((R700_CHIP_CONTEXT *)(&context->hw))
@@ -203,7 +178,6 @@ extern GLboolean r700SyncSurf(context_t *context,
                              uint32_t write_domain,
                              uint32_t sync_type);
 
-extern void r700SetupStreams(GLcontext * ctx);
 extern void r700Start3D(context_t *context);
 extern void r600InitAtoms(context_t *context);
 extern void r700InitDraw(GLcontext *ctx);
@@ -213,7 +187,4 @@ extern void r700InitDraw(GLcontext *ctx);
 #define RADEON_D_PLAYBACK_RAW 2
 #define RADEON_D_T 3
 
-#define r600PackFloat32 radeonPackFloat32
-#define r600PackFloat24 radeonPackFloat24
-
 #endif                         /* __R600_CONTEXT_H__ */
index f7702c46de5dc53bbb77acca7557eec54cc4ba84..74af7b4fed7772e74fd9d7b1b3f5caf6503adefc 100644 (file)
@@ -415,11 +415,11 @@ enum {
        ALPHA_TO_MASK_ENABLE                              = 1 << 0,
        ALPHA_TO_MASK_OFFSET0_mask                        = 0x03 << 8,
        ALPHA_TO_MASK_OFFSET0_shift                       = 8,
-       ALPHA_TO_MASK_OFFSET1_mask                        = 0x03 << 8,
+       ALPHA_TO_MASK_OFFSET1_mask                        = 0x03 << 10,
        ALPHA_TO_MASK_OFFSET1_shift                       = 10,
-       ALPHA_TO_MASK_OFFSET2_mask                        = 0x03 << 8,
+       ALPHA_TO_MASK_OFFSET2_mask                        = 0x03 << 12,
        ALPHA_TO_MASK_OFFSET2_shift                       = 12,
-       ALPHA_TO_MASK_OFFSET3_mask                        = 0x03 << 8,
+       ALPHA_TO_MASK_OFFSET3_mask                        = 0x03 << 14,
        ALPHA_TO_MASK_OFFSET3_shift                       = 14,
 
 //  SQ_VTX_CONSTANT_WORD2_0                               = 0x00038008,
index e5c01c861aa129e6e843aef23a296ce999cd56b6..eb169bd885d605b50b915bd8612a7d256a89981e 100644 (file)
@@ -143,6 +143,8 @@ enum {
 //  SQ_TEX_SAMPLER_MISC_0                                 = 0x0003d03c,
        R7xx_TRUNCATE_COORD_bit                           = 1 << 9,
        R7xx_DISABLE_CUBE_WRAP_bit                        = 1 << 10,
+//  DB_RENDER_CONTROL                                     = 0x00028d0c,
+       PERFECT_ZPASS_COUNTS_bit                          = 1 << 15,
 
 } ;
 
index d105b90cd18562bdb2b46ea77556dec3b80c8eb6..f745fe3e8a635fb35e9c225e633e1708084f3c22 100644 (file)
@@ -40,7 +40,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/image.h"
 #include "main/mipmap.h"
 #include "main/simple_list.h"
-#include "main/texformat.h"
 #include "main/texstore.h"
 #include "main/teximage.h"
 #include "main/texobj.h"
@@ -286,6 +285,7 @@ static void r600TexParameter(GLcontext * ctx, GLenum target,
                             GLenum pname, const GLfloat * params)
 {
        radeonTexObj* t = radeon_tex_obj(texObj);
+       GLenum baseFormat;
 
        radeon_print(RADEON_STATE | RADEON_TEXTURE, RADEON_VERBOSE,
                        "%s( %s )\n", __FUNCTION__,
@@ -305,30 +305,22 @@ static void r600TexParameter(GLcontext * ctx, GLenum target,
                break;
 
        case GL_TEXTURE_BORDER_COLOR:
-               r600SetTexBorderColor(t, texObj->BorderColor);
+               r600SetTexBorderColor(t, texObj->BorderColor.f);
                break;
 
        case GL_TEXTURE_BASE_LEVEL:
        case GL_TEXTURE_MAX_LEVEL:
        case GL_TEXTURE_MIN_LOD:
        case GL_TEXTURE_MAX_LOD:
-               /* This isn't the most efficient solution but there doesn't appear to
-                * be a nice alternative.  Since there's no LOD clamping,
-                * we just have to rely on loading the right subset of mipmap levels
-                * to simulate a clamped LOD.
-                */
-               if (t->mt) {
-                       radeon_miptree_unreference(t->mt);
-                       t->mt = 0;
-                       t->validated = GL_FALSE;
-               }
+               t->validated = GL_FALSE;
                break;
 
        case GL_DEPTH_TEXTURE_MODE:
                if (!texObj->Image[0][texObj->BaseLevel])
                        return;
-               if (texObj->Image[0][texObj->BaseLevel]->TexFormat->BaseFormat
-                   == GL_DEPTH_COMPONENT) {
+               baseFormat = texObj->Image[0][texObj->BaseLevel]->_BaseFormat;
+               if (baseFormat == GL_DEPTH_COMPONENT ||
+                   baseFormat == GL_DEPTH_STENCIL) {
                        r600SetDepthTexMode(texObj);
                        break;
                } else {
@@ -368,10 +360,8 @@ static void r600DeleteTexture(GLcontext * ctx, struct gl_texture_object *texObj)
                t->bo = NULL;
        }
 
-       if (t->mt) {
-               radeon_miptree_unreference(t->mt);
-               t->mt = 0;
-       }
+       radeon_miptree_unreference(&t->mt);
+
        _mesa_delete_texture_object(ctx, texObj);
 }
 
@@ -401,7 +391,7 @@ static struct gl_texture_object *r600NewTextureObject(GLcontext * ctx,
        r600SetTexDefaultState(t);
        r600UpdateTexWrap(t);
        r600SetTexFilter(t, t->base.MinFilter, t->base.MagFilter, t->base.MaxAnisotropy);
-       r600SetTexBorderColor(t, t->base.BorderColor);
+       r600SetTexBorderColor(t, t->base.BorderColor.f);
 
        return &t->base;
 }
index 7d7e77d355b710d1a4f33f281e7cb37f5c9c1bb0..ae252c995be9d261914bc50e7ddbebb33014ad75 100644 (file)
@@ -39,7 +39,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/imports.h"
 #include "main/context.h"
 #include "main/macros.h"
-#include "main/texformat.h"
 #include "main/teximage.h"
 #include "main/texobj.h"
 #include "main/enums.h"
@@ -78,7 +77,7 @@ void r600UpdateTextureState(GLcontext * ctx)
        }
 }
 
-static GLboolean r600GetTexFormat(struct gl_texture_object *tObj, GLuint mesa_format)
+static GLboolean r600GetTexFormat(struct gl_texture_object *tObj, gl_format mesa_format)
 {
        radeonTexObj *t = radeon_tex_obj(tObj);
 
@@ -87,9 +86,19 @@ static GLboolean r600GetTexFormat(struct gl_texture_object *tObj, GLuint mesa_fo
        CLEARfield(t->SQ_TEX_RESOURCE4, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
        CLEARfield(t->SQ_TEX_RESOURCE4, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
 
+       SETfield(t->SQ_TEX_RESOURCE4, SQ_FORMAT_COMP_UNSIGNED,
+                FORMAT_COMP_X_shift, FORMAT_COMP_X_mask);
+       SETfield(t->SQ_TEX_RESOURCE4, SQ_FORMAT_COMP_UNSIGNED,
+                FORMAT_COMP_Y_shift, FORMAT_COMP_Y_mask);
+       SETfield(t->SQ_TEX_RESOURCE4, SQ_FORMAT_COMP_UNSIGNED,
+                FORMAT_COMP_Z_shift, FORMAT_COMP_Z_mask);
+       SETfield(t->SQ_TEX_RESOURCE4, SQ_FORMAT_COMP_UNSIGNED,
+                FORMAT_COMP_W_shift, FORMAT_COMP_W_mask);
+
        switch (mesa_format) /* This is mesa format. */
        {
        case MESA_FORMAT_RGBA8888:
+       case MESA_FORMAT_SIGNED_RGBA8888:
                SETfield(t->SQ_TEX_RESOURCE1, FMT_8_8_8_8,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
@@ -101,8 +110,19 @@ static GLboolean r600GetTexFormat(struct gl_texture_object *tObj, GLuint mesa_fo
                         SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
                SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
                         SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
+               if (mesa_format == MESA_FORMAT_SIGNED_RGBA8888) {
+                       SETfield(t->SQ_TEX_RESOURCE4, SQ_FORMAT_COMP_SIGNED,
+                                FORMAT_COMP_X_shift, FORMAT_COMP_X_mask);
+                       SETfield(t->SQ_TEX_RESOURCE4, SQ_FORMAT_COMP_SIGNED,
+                                FORMAT_COMP_Y_shift, FORMAT_COMP_Y_mask);
+                       SETfield(t->SQ_TEX_RESOURCE4, SQ_FORMAT_COMP_SIGNED,
+                                FORMAT_COMP_Z_shift, FORMAT_COMP_Z_mask);
+                       SETfield(t->SQ_TEX_RESOURCE4, SQ_FORMAT_COMP_SIGNED,
+                                FORMAT_COMP_W_shift, FORMAT_COMP_W_mask);
+               }
                break;
        case MESA_FORMAT_RGBA8888_REV:
+       case MESA_FORMAT_SIGNED_RGBA8888_REV:
                SETfield(t->SQ_TEX_RESOURCE1, FMT_8_8_8_8,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
@@ -114,6 +134,16 @@ static GLboolean r600GetTexFormat(struct gl_texture_object *tObj, GLuint mesa_fo
                         SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
                SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_W,
                         SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
+               if (mesa_format == MESA_FORMAT_SIGNED_RGBA8888_REV) {
+                       SETfield(t->SQ_TEX_RESOURCE4, SQ_FORMAT_COMP_SIGNED,
+                                FORMAT_COMP_X_shift, FORMAT_COMP_X_mask);
+                       SETfield(t->SQ_TEX_RESOURCE4, SQ_FORMAT_COMP_SIGNED,
+                                FORMAT_COMP_Y_shift, FORMAT_COMP_Y_mask);
+                       SETfield(t->SQ_TEX_RESOURCE4, SQ_FORMAT_COMP_SIGNED,
+                                FORMAT_COMP_Z_shift, FORMAT_COMP_Z_mask);
+                       SETfield(t->SQ_TEX_RESOURCE4, SQ_FORMAT_COMP_SIGNED,
+                                FORMAT_COMP_W_shift, FORMAT_COMP_W_mask);
+               }
                break;
        case MESA_FORMAT_ARGB8888:
                SETfield(t->SQ_TEX_RESOURCE1, FMT_8_8_8_8,
@@ -480,13 +510,21 @@ static GLboolean r600GetTexFormat(struct gl_texture_object *tObj, GLuint mesa_fo
                         SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                break;
        case MESA_FORMAT_Z16:
+       case MESA_FORMAT_X8_Z24:
+       case MESA_FORMAT_S8_Z24:
        case MESA_FORMAT_Z24_S8:
        case MESA_FORMAT_Z32:
+       case MESA_FORMAT_S8:
                switch (mesa_format) {
                case MESA_FORMAT_Z16:
                        SETfield(t->SQ_TEX_RESOURCE1, FMT_16,
                                 SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
                        break;
+               case MESA_FORMAT_X8_Z24:
+               case MESA_FORMAT_S8_Z24:
+                       SETfield(t->SQ_TEX_RESOURCE1, FMT_8_24,
+                                SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
+                       break;
                case MESA_FORMAT_Z24_S8:
                        SETfield(t->SQ_TEX_RESOURCE1, FMT_24_8,
                                 SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
@@ -495,6 +533,12 @@ static GLboolean r600GetTexFormat(struct gl_texture_object *tObj, GLuint mesa_fo
                        SETfield(t->SQ_TEX_RESOURCE1, FMT_32,
                                 SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
                        break;
+               case MESA_FORMAT_S8:
+                       SETfield(t->SQ_TEX_RESOURCE1, FMT_8,
+                                SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
+                       break;
+               default:
+                       break;
                };
                switch (tObj->DepthMode) {
                case GL_LUMINANCE:  /* X, X, X, ONE */
@@ -582,6 +626,31 @@ static GLboolean r600GetTexFormat(struct gl_texture_object *tObj, GLuint mesa_fo
        return GL_TRUE;
 }
 
+static GLuint r600_translate_shadow_func(GLenum func)
+{
+   switch (func) {
+   case GL_NEVER:
+      return SQ_TEX_DEPTH_COMPARE_NEVER;
+   case GL_LESS:
+      return SQ_TEX_DEPTH_COMPARE_LESS;
+   case GL_LEQUAL:
+      return SQ_TEX_DEPTH_COMPARE_LESSEQUAL;
+   case GL_GREATER:
+      return SQ_TEX_DEPTH_COMPARE_GREATER;
+   case GL_GEQUAL:
+      return SQ_TEX_DEPTH_COMPARE_GREATEREQUAL;
+   case GL_NOTEQUAL:
+      return SQ_TEX_DEPTH_COMPARE_NOTEQUAL;
+   case GL_EQUAL:
+      return SQ_TEX_DEPTH_COMPARE_EQUAL;
+   case GL_ALWAYS:
+      return SQ_TEX_DEPTH_COMPARE_ALWAYS;
+   default:
+      WARN_ONCE("Unknown shadow compare function! %d", func);
+      return 0;
+   }
+}
+
 void r600SetDepthTexMode(struct gl_texture_object *tObj)
 {
        radeonTexObjPtr t;
@@ -591,7 +660,7 @@ void r600SetDepthTexMode(struct gl_texture_object *tObj)
 
        t = radeon_tex_obj(tObj);
 
-       r600GetTexFormat(tObj, tObj->Image[0][tObj->BaseLevel]->TexFormat->MesaFormat);
+       r600GetTexFormat(tObj, tObj->Image[0][tObj->BaseLevel]->TexFormat);
 
 }
 
@@ -605,7 +674,6 @@ static void setup_hardware_state(context_t *rmesa, struct gl_texture_object *tex
 {
        radeonTexObj *t = radeon_tex_obj(texObj);
        const struct gl_texture_image *firstImage;
-       int firstlevel = t->mt ? t->mt->firstLevel : 0;
        GLuint uTexelPitch, row_align;
 
        if (rmesa->radeon.radeonScreen->driScreen->dri2.enabled &&
@@ -613,10 +681,10 @@ static void setup_hardware_state(context_t *rmesa, struct gl_texture_object *tex
            t->bo)
                return;
 
-       firstImage = t->base.Image[0][firstlevel];
+       firstImage = t->base.Image[0][t->minLod];
 
        if (!t->image_override) {
-               if (!r600GetTexFormat(texObj, firstImage->TexFormat->MesaFormat)) {
+               if (!r600GetTexFormat(texObj, firstImage->TexFormat)) {
                        radeon_error("unexpected texture format in %s\n",
                                      __FUNCTION__);
                        return;
@@ -648,7 +716,8 @@ static void setup_hardware_state(context_t *rmesa, struct gl_texture_object *tex
        }
 
        row_align = rmesa->radeon.texture_row_align - 1;
-       uTexelPitch = ((firstImage->Width * t->mt->bpp + row_align) & ~row_align) / t->mt->bpp;
+       uTexelPitch = (_mesa_format_row_stride(firstImage->TexFormat, firstImage->Width) + row_align) & ~row_align;
+       uTexelPitch = uTexelPitch / _mesa_get_format_bytes(firstImage->TexFormat);
        uTexelPitch = (uTexelPitch + R700_TEXEL_PITCH_ALIGNMENT_MASK)
                & ~R700_TEXEL_PITCH_ALIGNMENT_MASK;
 
@@ -662,11 +731,22 @@ static void setup_hardware_state(context_t *rmesa, struct gl_texture_object *tex
        SETfield(t->SQ_TEX_RESOURCE1, firstImage->Height - 1,
                 TEX_HEIGHT_shift, TEX_HEIGHT_mask);
 
-       if ((t->mt->lastLevel - t->mt->firstLevel) > 0) {
-               t->SQ_TEX_RESOURCE3 = t->mt->levels[0].size / 256;
-               SETfield(t->SQ_TEX_RESOURCE4, t->mt->firstLevel, BASE_LEVEL_shift, BASE_LEVEL_mask);
-               SETfield(t->SQ_TEX_RESOURCE5, t->mt->lastLevel, LAST_LEVEL_shift, LAST_LEVEL_mask);
+       t->SQ_TEX_RESOURCE2 = get_base_teximage_offset(t) / 256;
+
+       if ((t->maxLod - t->minLod) > 0) {
+               t->SQ_TEX_RESOURCE3 = radeon_miptree_image_offset(t->mt, 0, t->minLod + 1) / 256;
+               SETfield(t->SQ_TEX_RESOURCE4, 0, BASE_LEVEL_shift, BASE_LEVEL_mask);
+               SETfield(t->SQ_TEX_RESOURCE5, t->maxLod - t->minLod, LAST_LEVEL_shift, LAST_LEVEL_mask);
        }
+       if(texObj->CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB)
+       {
+               SETfield(t->SQ_TEX_SAMPLER0, r600_translate_shadow_func(texObj->CompareFunc), DEPTH_COMPARE_FUNCTION_shift, DEPTH_COMPARE_FUNCTION_mask);
+       }
+       else
+       {
+               CLEARfield(t->SQ_TEX_SAMPLER0, DEPTH_COMPARE_FUNCTION_mask);
+       }
+
 }
 
 /**
@@ -764,7 +844,8 @@ void r600SetTexOffset(__DRIcontext * pDRICtx, GLint texname,
        struct gl_texture_object *tObj =
            _mesa_lookup_texture(rmesa->radeon.glCtx, texname);
        radeonTexObjPtr t = radeon_tex_obj(tObj);
-       uint32_t pitch_val, size;
+       const struct gl_texture_image *firstImage;
+       uint32_t pitch_val, size, row_align;
 
        if (!tObj)
                return;
@@ -774,7 +855,9 @@ void r600SetTexOffset(__DRIcontext * pDRICtx, GLint texname,
        if (!offset)
                return;
 
-       size = pitch;//h * w * (depth / 8);
+       firstImage = t->base.Image[0][t->minLod];
+       row_align = rmesa->radeon.texture_row_align - 1;
+       size = ((_mesa_format_row_stride(firstImage->TexFormat, firstImage->Width) + row_align) & ~row_align) * firstImage->Height;
        if (t->bo) {
                radeon_bo_unref(t->bo);
                t->bo = NULL;
@@ -870,18 +953,7 @@ void r600SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_fo
            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;
-       }
+       radeon_update_renderbuffers(pDRICtx, dPriv, GL_TRUE);
        rb = rfb->color_rb[0];
        if (rb->bo == NULL) {
                /* Failed to BO for the buffer */
@@ -897,20 +969,14 @@ void r600SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_fo
                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;
-       }
+
+       radeon_miptree_unreference(&t->mt);
+       radeon_miptree_unreference(&rImage->mt);
+
        _mesa_init_teximage_fields(radeon->glCtx, target, texImage,
                                   rb->base.Width, rb->base.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;
index 903b6968be1125cdb1d121b0dbace09d6d1bd77b..0ff16b4dddc15e3049636f7edcb9a5c9ff7d0151 100644 (file)
 
 #include "main/mtypes.h"
 #include "main/imports.h"
+#include "shader/prog_parameter.h"
 
 #include "radeon_debug.h"
 #include "r600_context.h"
 
 #include "r700_assembler.h"
 
+#define USE_CF_FOR_CONTINUE_BREAK 1
+#define USE_CF_FOR_POP_AFTER      1
+
+struct prog_instruction noise1_insts[12] = { 
+    {OPCODE_BGNSUB , {{13, 0, 1672, 0, 0, 0}, {13, 0, 1672, 0, 0, 0}, {13, 0, 1672, 0, 0, 0}}, {13, 0, 15, 0, 8, 1672, 0}, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0}, 
+    {OPCODE_MOV , {{0, 0, 0, 0, 0, 0}, {13, 0, 1672, 0, 0, 0}, {13, 0, 1672, 0, 0, 0}}, {0, 0, 2, 0, 8, 1672, 0}, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0}, 
+    {OPCODE_MOV , {{8, 0, 0, 0, 0, 0}, {13, 0, 1672, 0, 0, 0}, {13, 0, 1672, 0, 0, 0}}, {0, 0, 4, 0, 8, 1672, 0}, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0}, 
+    {OPCODE_MOV , {{8, 0, 585, 0, 0, 0}, {13, 0, 1672, 0, 0, 0}, {13, 0, 1672, 0, 0, 0}}, {0, 0, 8, 0, 8, 1672, 0}, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0}, 
+    {OPCODE_SGT , {{0, 0, 585, 0, 0, 0}, {8, 0, 1170, 0, 0, 0}, {13, 0, 1672, 0, 0, 0}}, {0, 1, 1, 0, 8, 1672, 0}, 1, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0}, 
+    {OPCODE_IF , {{13, 0, 1672, 0, 0, 0}, {13, 0, 1672, 0, 0, 0}, {13, 0, 1672, 0, 0, 0}}, {13, 0, 15, 0, 7, 0, 0}, 0, 0, 0, 1, 0, 0, 0, 15, 0, 0, 0}, 
+    {OPCODE_MOV , {{0, 0, 1755, 0, 0, 0}, {13, 0, 1672, 0, 0, 0}, {13, 0, 1672, 0, 0, 0}}, {0, 0, 1, 0, 8, 1672, 0}, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0}, 
+    {OPCODE_RET , {{13, 0, 1672, 0, 0, 0}, {13, 0, 1672, 0, 0, 0}, {13, 0, 1672, 0, 0, 0}}, {13, 0, 15, 0, 8, 1672, 0}, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0}, 
+    {OPCODE_ENDIF , {{13, 0, 1672, 0, 0, 0}, {13, 0, 1672, 0, 0, 0}, {13, 0, 1672, 0, 0, 0}}, {13, 0, 15, 0, 8, 1672, 0}, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0}, 
+    {OPCODE_MOV , {{0, 0, 1170, 0, 0, 0}, {13, 0, 1672, 0, 0, 0}, {13, 0, 1672, 0, 0, 0}}, {0, 0, 1, 0, 8, 1672, 0}, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0}, 
+    {OPCODE_RET , {{13, 0, 1672, 0, 0, 0}, {13, 0, 1672, 0, 0, 0}, {13, 0, 1672, 0, 0, 0}}, {13, 0, 15, 0, 8, 1672, 0}, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0}, 
+    {OPCODE_ENDSUB , {{13, 0, 1672, 0, 0, 0}, {13, 0, 1672, 0, 0, 0}, {13, 0, 1672, 0, 0, 0}}, {13, 0, 15, 0, 8, 1672, 0}, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0}
+};
+float noise1_const[2][4] = {
+    {0.300000f, 0.900000f, 0.500000f, 0.300000f}
+};
+
+COMPILED_SUB noise1_presub = {
+    &(noise1_insts[0]),
+    12, 
+    2, 
+    1, 
+    0, 
+    &(noise1_const[0]), 
+    SWIZZLE_X, 
+    SWIZZLE_X, 
+    SWIZZLE_X, 
+    SWIZZLE_X,
+    {0,0,0},
+    0 
+};
+
 BITS addrmode_PVSDST(PVSDST * pPVSDST)
 {
        return pPVSDST->addrmode0 | ((BITS)pPVSDST->addrmode1 << 1);
@@ -327,21 +364,27 @@ GLuint GetSurfaceFormat(GLenum eType, GLuint nChannels, GLuint * pClient_size)
     return(format);
 }
 
-unsigned int r700GetNumOperands(r700_AssemblerBase* pAsm)
+unsigned int r700GetNumOperands(GLuint opcode, GLuint nIsOp3) 
 {
-    if(pAsm->D.dst.op3)
+    if(nIsOp3 > 0)
     {
         return 3;
     }
 
-    switch (pAsm->D.dst.opcode)
+    switch (opcode)
     {
-    case SQ_OP2_INST_ADD:                          
+    case SQ_OP2_INST_ADD:
+    case SQ_OP2_INST_KILLE:
+    case SQ_OP2_INST_KILLGT:
+    case SQ_OP2_INST_KILLGE:
+    case SQ_OP2_INST_KILLNE:
     case SQ_OP2_INST_MUL: 
     case SQ_OP2_INST_MAX:
     case SQ_OP2_INST_MIN:
     //case SQ_OP2_INST_MAX_DX10:
     //case SQ_OP2_INST_MIN_DX10:
+    case SQ_OP2_INST_SETE: 
+    case SQ_OP2_INST_SETNE:
     case SQ_OP2_INST_SETGT:
     case SQ_OP2_INST_SETGE:
     case SQ_OP2_INST_PRED_SETE:
@@ -354,9 +397,10 @@ unsigned int r700GetNumOperands(r700_AssemblerBase* pAsm)
         return 2;  
 
     case SQ_OP2_INST_MOV: 
+    case SQ_OP2_INST_MOVA_FLOOR:
     case SQ_OP2_INST_FRACT:
     case SQ_OP2_INST_FLOOR:
-    case SQ_OP2_INST_KILLGT:
+    case SQ_OP2_INST_TRUNC:
     case SQ_OP2_INST_EXP_IEEE:
     case SQ_OP2_INST_LOG_CLAMPED:
     case SQ_OP2_INST_LOG_IEEE:
@@ -368,7 +412,7 @@ unsigned int r700GetNumOperands(r700_AssemblerBase* pAsm)
         return 1;
         
     default: radeon_error(
-                   "Need instruction operand number for %x.\n", pAsm->D.dst.opcode);
+                   "Need instruction operand number for %x.\n", opcode); 
     };
 
     return 3;
@@ -382,103 +426,128 @@ int Init_r700_AssemblerBase(SHADER_PIPE_TYPE spt, r700_AssemblerBase* pAsm, R700
     pAsm->pR700Shader = pShader;
     pAsm->currentShaderType = spt;
 
-       pAsm->cf_last_export_ptr   = NULL;
+    pAsm->cf_last_export_ptr   = NULL;
+
+    pAsm->cf_current_export_clause_ptr = NULL;
+    pAsm->cf_current_alu_clause_ptr    = NULL;
+    pAsm->cf_current_tex_clause_ptr    = NULL;
+    pAsm->cf_current_vtx_clause_ptr    = NULL;
+    pAsm->cf_current_cf_clause_ptr     = NULL;
 
-       pAsm->cf_current_export_clause_ptr = NULL;
-       pAsm->cf_current_alu_clause_ptr    = NULL;
-       pAsm->cf_current_tex_clause_ptr    = NULL;
-       pAsm->cf_current_vtx_clause_ptr    = NULL;
-       pAsm->cf_current_cf_clause_ptr     = NULL;
+    // No clause has been created yet
+    pAsm->cf_current_clause_type = CF_EMPTY_CLAUSE;
 
-       // No clause has been created yet
-       pAsm->cf_current_clause_type = CF_EMPTY_CLAUSE;
+    pAsm->number_of_colorandz_exports = 0;
+    pAsm->number_of_exports           = 0;
+    pAsm->number_of_export_opcodes    = 0;
 
-       pAsm->number_of_colorandz_exports = 0;
-       pAsm->number_of_exports           = 0;
-       pAsm->number_of_export_opcodes    = 0;
+    pAsm->alu_x_opcode = 0;
 
+    pAsm->D2.bits = 0;
 
-       pAsm->D.bits = 0;
-       pAsm->S[0].bits = 0;
-       pAsm->S[1].bits = 0;
-       pAsm->S[2].bits = 0;
+    pAsm->D.bits = 0;
+    pAsm->S[0].bits = 0;
+    pAsm->S[1].bits = 0;
+    pAsm->S[2].bits = 0;
 
-       pAsm->uLastPosUpdate = 0; 
+    pAsm->uLastPosUpdate = 0; 
        
-       *(BITS *) &pAsm->fp_stOutFmt0 = 0;
+    *(BITS *) &pAsm->fp_stOutFmt0 = 0;
+
+    pAsm->uIIns = 0;
+    pAsm->uOIns = 0;
+    pAsm->number_used_registers = 0;
+    pAsm->uUsedConsts = 256; 
 
-       pAsm->uIIns = 0;
-       pAsm->uOIns = 0;
-       pAsm->number_used_registers = 0;
-       pAsm->uUsedConsts = 256; 
 
+    // Fragment programs
+    pAsm->uBoolConsts = 0;
+    pAsm->uIntConsts = 0;
+    pAsm->uInsts = 0;
+    pAsm->uConsts = 0;
 
-       // Fragment programs
-       pAsm->uBoolConsts = 0;
-       pAsm->uIntConsts = 0;
-       pAsm->uInsts = 0;
-       pAsm->uConsts = 0;
+    pAsm->FCSP = 0;
+    pAsm->fc_stack[0].type = FC_NONE;
 
-       pAsm->FCSP = 0;
-       pAsm->fc_stack[0].type = FC_NONE;
+    pAsm->aArgSubst[0] =
+    pAsm->aArgSubst[1] =
+    pAsm->aArgSubst[2] =
+    pAsm->aArgSubst[3] = (-1);
+
+    pAsm->uOutputs = 0;
 
-       pAsm->branch_depth     = 0;
-       pAsm->max_branch_depth = 0;
+    for (i=0; i<NUMBER_OF_OUTPUT_COLORS; i++) 
+    {
+        pAsm->color_export_register_number[i] = (-1);
+    }
 
-       pAsm->aArgSubst[0] =
-       pAsm->aArgSubst[1] =
-       pAsm->aArgSubst[2] =
-       pAsm->aArgSubst[3] = (-1);
 
-       pAsm->uOutputs = 0;
+    pAsm->depth_export_register_number = (-1);
+    pAsm->stencil_export_register_number = (-1);
+    pAsm->coverage_to_mask_export_register_number = (-1);
+    pAsm->mask_export_register_number = (-1);
 
-       for (i=0; i<NUMBER_OF_OUTPUT_COLORS; i++) 
-       {
-               pAsm->color_export_register_number[i] = (-1);
-       }
+    pAsm->starting_export_register_number = 0;
+    pAsm->starting_vfetch_register_number = 0;
+    pAsm->starting_temp_register_number   = 0;
+    pAsm->uFirstHelpReg = 0;
 
+    pAsm->input_position_is_used = GL_FALSE;
+    pAsm->input_normal_is_used   = GL_FALSE;
 
-       pAsm->depth_export_register_number = (-1);
-       pAsm->stencil_export_register_number = (-1);
-       pAsm->coverage_to_mask_export_register_number = (-1);
-       pAsm->mask_export_register_number = (-1);
+    for (i=0; i<NUMBER_OF_INPUT_COLORS; i++) 
+    {
+        pAsm->input_color_is_used[ i ] = GL_FALSE;
+    }
 
-       pAsm->starting_export_register_number = 0;
-       pAsm->starting_vfetch_register_number = 0;
-       pAsm->starting_temp_register_number   = 0;
-       pAsm->uFirstHelpReg = 0;
+    for (i=0; i<NUMBER_OF_TEXTURE_UNITS; i++) 
+    {
+        pAsm->input_texture_unit_is_used[ i ] = GL_FALSE;
+    }
 
+    for (i=0; i<VERT_ATTRIB_MAX; i++) 
+    {
+        pAsm->vfetch_instruction_ptr_array[ i ] = NULL;
+    }
 
-       pAsm->input_position_is_used = GL_FALSE;
-       pAsm->input_normal_is_used   = GL_FALSE;
+    pAsm->number_of_inputs = 0;
 
+    pAsm->is_tex = GL_FALSE;
+    pAsm->need_tex_barrier = GL_FALSE;
 
-       for (i=0; i<NUMBER_OF_INPUT_COLORS; i++) 
-       {
-               pAsm->input_color_is_used[ i ] = GL_FALSE;
-       }
+    pAsm->subs              = NULL;
+    pAsm->unSubArraySize    = 0;
+    pAsm->unSubArrayPointer = 0;
+    pAsm->callers              = NULL;
+    pAsm->unCallerArraySize    = 0;
+    pAsm->unCallerArrayPointer = 0;
 
-       for (i=0; i<NUMBER_OF_TEXTURE_UNITS; i++) 
-       {
-               pAsm->input_texture_unit_is_used[ i ] = GL_FALSE;
-       }
+    pAsm->CALLSP = 0;
+    pAsm->CALLSTACK[0].FCSP_BeforeEntry = 0;
+    pAsm->CALLSTACK[0].plstCFInstructions_local
+          = &(pAsm->pR700Shader->lstCFInstructions);
 
-       for (i=0; i<VERT_ATTRIB_MAX; i++) 
-       {
-               pAsm->vfetch_instruction_ptr_array[ i ] = NULL;
-       }
+    pAsm->CALLSTACK[0].max = 0;
+    pAsm->CALLSTACK[0].current = 0;
 
-       pAsm->number_of_inputs = 0;
+    SetActiveCFlist(pAsm->pR700Shader, pAsm->CALLSTACK[0].plstCFInstructions_local);
 
-       pAsm->is_tex = GL_FALSE;
-       pAsm->need_tex_barrier = GL_FALSE;
+    pAsm->unCFflags = 0;
 
-       return 0;
+    pAsm->presubs           = NULL;
+    pAsm->unPresubArraySize = 0;
+    pAsm->unNumPresub       = 0;
+    pAsm->unCurNumILInsts   = 0;
+
+    pAsm->unVetTexBits      = 0;
+
+    return 0;
 }
 
 GLboolean IsTex(gl_inst_opcode Opcode)
 {
-    if( (OPCODE_TEX==Opcode) || (OPCODE_TXP==Opcode) || (OPCODE_TXB==Opcode) )
+    if( (OPCODE_TEX==Opcode) || (OPCODE_TXP==Opcode) || (OPCODE_TXB==Opcode) ||
+        (OPCODE_DDX==Opcode) || (OPCODE_DDY==Opcode) )
     {
         return GL_TRUE;
     }
@@ -591,6 +660,31 @@ int check_current_clause(r700_AssemblerBase* pAsm,
     return GL_TRUE;
 }
 
+GLboolean add_cf_instruction(r700_AssemblerBase* pAsm)
+{
+    if(GL_FALSE == check_current_clause(pAsm, CF_OTHER_CLAUSE))
+    {
+        return GL_FALSE;
+    }
+
+    pAsm->cf_current_cf_clause_ptr = 
+      (R700ControlFlowGenericClause*) CALLOC_STRUCT(R700ControlFlowGenericClause);
+
+    if (pAsm->cf_current_cf_clause_ptr != NULL) 
+       {
+               Init_R700ControlFlowGenericClause(pAsm->cf_current_cf_clause_ptr);
+               AddCFInstruction( pAsm->pR700Shader, 
+                          (R700ControlFlowInstruction *)pAsm->cf_current_cf_clause_ptr );
+       }
+       else 
+       {
+        radeon_error("Could not allocate a new VFetch CF instruction.\n");
+               return GL_FALSE;
+       }
+
+    return GL_TRUE;
+}
+
 GLboolean add_vfetch_instruction(r700_AssemblerBase*     pAsm,
                                                                 R700VertexInstruction*  vertex_instruction_ptr)
 {
@@ -797,6 +891,7 @@ GLboolean assemble_vfetch_instruction2(r700_AssemblerBase* pAsm,
                                        GLubyte             element,
                                        GLuint              _signed,
                                        GLboolean           normalize,
+                                       GLenum              format,
                                        VTX_FETCH_METHOD  * pFetchMethod)
 {
     GLuint client_size_inbyte;
@@ -845,10 +940,21 @@ GLboolean assemble_vfetch_instruction2(r700_AssemblerBase* pAsm,
        vfetch_instruction_ptr->m_Word0.f.src_sel_x        = SQ_SEL_X;
        vfetch_instruction_ptr->m_Word0.f.mega_fetch_count = mega_fetch_count;
 
-       vfetch_instruction_ptr->m_Word1.f.dst_sel_x        = (size < 1) ? SQ_SEL_0 : SQ_SEL_X;
-       vfetch_instruction_ptr->m_Word1.f.dst_sel_y        = (size < 2) ? SQ_SEL_0 : SQ_SEL_Y;
-       vfetch_instruction_ptr->m_Word1.f.dst_sel_z        = (size < 3) ? SQ_SEL_0 : SQ_SEL_Z;
-       vfetch_instruction_ptr->m_Word1.f.dst_sel_w        = (size < 4) ? SQ_SEL_1 : SQ_SEL_W;
+       if(format == GL_BGRA)
+       {
+               vfetch_instruction_ptr->m_Word1.f.dst_sel_x        = (size < 1) ? SQ_SEL_0 : SQ_SEL_Z;
+               vfetch_instruction_ptr->m_Word1.f.dst_sel_y        = (size < 2) ? SQ_SEL_0 : SQ_SEL_Y;
+               vfetch_instruction_ptr->m_Word1.f.dst_sel_z        = (size < 3) ? SQ_SEL_0 : SQ_SEL_X;
+               vfetch_instruction_ptr->m_Word1.f.dst_sel_w        = (size < 4) ? SQ_SEL_1 : SQ_SEL_W;
+       }
+       else
+       {
+               vfetch_instruction_ptr->m_Word1.f.dst_sel_x        = (size < 1) ? SQ_SEL_0 : SQ_SEL_X;
+               vfetch_instruction_ptr->m_Word1.f.dst_sel_y        = (size < 2) ? SQ_SEL_0 : SQ_SEL_Y;
+               vfetch_instruction_ptr->m_Word1.f.dst_sel_z        = (size < 3) ? SQ_SEL_0 : SQ_SEL_Z;
+               vfetch_instruction_ptr->m_Word1.f.dst_sel_w        = (size < 4) ? SQ_SEL_1 : SQ_SEL_W;
+
+       }
 
        vfetch_instruction_ptr->m_Word1.f.use_const_fields = 1;
     vfetch_instruction_ptr->m_Word1.f.data_format      = data_format;
@@ -986,7 +1092,8 @@ GLboolean checkop2(r700_AssemblerBase* pAsm)
 
     checkop_init(pAsm);
 
-    if( (pILInst->SrcReg[0].File == PROGRAM_CONSTANT)    ||
+    if( (pILInst->SrcReg[0].File == PROGRAM_UNIFORM)     || 
+        (pILInst->SrcReg[0].File == PROGRAM_CONSTANT)    ||
         (pILInst->SrcReg[0].File == PROGRAM_LOCAL_PARAM) ||
         (pILInst->SrcReg[0].File == PROGRAM_ENV_PARAM)   ||
         (pILInst->SrcReg[0].File == PROGRAM_STATE_VAR) )
@@ -997,7 +1104,8 @@ GLboolean checkop2(r700_AssemblerBase* pAsm)
     {
         bSrcConst[0] = GL_FALSE;
     }
-    if( (pILInst->SrcReg[1].File == PROGRAM_CONSTANT)    ||
+    if( (pILInst->SrcReg[1].File == PROGRAM_UNIFORM)     || 
+        (pILInst->SrcReg[1].File == PROGRAM_CONSTANT)    ||
         (pILInst->SrcReg[1].File == PROGRAM_LOCAL_PARAM) ||
         (pILInst->SrcReg[1].File == PROGRAM_ENV_PARAM)   ||
         (pILInst->SrcReg[1].File == PROGRAM_STATE_VAR) )
@@ -1030,7 +1138,8 @@ GLboolean checkop3(r700_AssemblerBase* pAsm)
 
     checkop_init(pAsm);
 
-    if( (pILInst->SrcReg[0].File == PROGRAM_CONSTANT)    ||
+    if( (pILInst->SrcReg[0].File == PROGRAM_UNIFORM)     || 
+        (pILInst->SrcReg[0].File == PROGRAM_CONSTANT)    ||
         (pILInst->SrcReg[0].File == PROGRAM_LOCAL_PARAM) ||
         (pILInst->SrcReg[0].File == PROGRAM_ENV_PARAM)   ||
         (pILInst->SrcReg[0].File == PROGRAM_STATE_VAR) )
@@ -1041,7 +1150,8 @@ GLboolean checkop3(r700_AssemblerBase* pAsm)
     {
         bSrcConst[0] = GL_FALSE;
     }
-    if( (pILInst->SrcReg[1].File == PROGRAM_CONSTANT)    ||
+    if( (pILInst->SrcReg[1].File == PROGRAM_UNIFORM)     || 
+        (pILInst->SrcReg[1].File == PROGRAM_CONSTANT)    ||
         (pILInst->SrcReg[1].File == PROGRAM_LOCAL_PARAM) ||
         (pILInst->SrcReg[1].File == PROGRAM_ENV_PARAM)   ||
         (pILInst->SrcReg[1].File == PROGRAM_STATE_VAR) )
@@ -1052,7 +1162,8 @@ GLboolean checkop3(r700_AssemblerBase* pAsm)
     {
         bSrcConst[1] = GL_FALSE;
     }
-    if( (pILInst->SrcReg[2].File == PROGRAM_CONSTANT)    ||
+    if( (pILInst->SrcReg[2].File == PROGRAM_UNIFORM)     || 
+        (pILInst->SrcReg[2].File == PROGRAM_CONSTANT)    ||
         (pILInst->SrcReg[2].File == PROGRAM_LOCAL_PARAM) ||
         (pILInst->SrcReg[2].File == PROGRAM_ENV_PARAM)   ||
         (pILInst->SrcReg[2].File == PROGRAM_STATE_VAR) )
@@ -1152,6 +1263,7 @@ GLboolean assemble_src(r700_AssemblerBase *pAsm,
         case PROGRAM_LOCAL_PARAM:
         case PROGRAM_ENV_PARAM:
         case PROGRAM_STATE_VAR:
+        case PROGRAM_UNIFORM:
             if (1 == pILInst->SrcReg[src].RelAddr)
             {
                 setaddrmode_PVSSRC(&(pAsm->S[fld].src), ADDR_RELATIVE_A0);
@@ -1162,10 +1274,18 @@ GLboolean assemble_src(r700_AssemblerBase *pAsm,
             }
 
             pAsm->S[fld].src.rtype = SRC_REG_CONSTANT;
-            pAsm->S[fld].src.reg   = pILInst->SrcReg[src].Index;
+            if(pILInst->SrcReg[src].Index < 0)
+            {
+                WARN_ONCE("Negative register offsets not supported yet!\n");
+                pAsm->S[fld].src.reg  = 0;
+            } 
+            else
+            {
+                pAsm->S[fld].src.reg = pILInst->SrcReg[src].Index;
+            }
             break;      
         case PROGRAM_INPUT:
-            setaddrmode_PVSSRC(&(pAsm->S[fld].src), ADDR_ABSOLUTE);
+            setaddrmode_PVSSRC(&(pAsm->S[fld].src), ADDR_ABSOLUTE); 
             pAsm->S[fld].src.rtype = SRC_REG_INPUT;
             switch (pAsm->currentShaderType)
             {
@@ -1178,7 +1298,7 @@ GLboolean assemble_src(r700_AssemblerBase *pAsm,
             }
             break;      
         default:
-            radeon_error("Invalid source argument type\n");
+            radeon_error("Invalid source argument type : %d \n", pILInst->SrcReg[src].File);
             return GL_FALSE;
         }
     } 
@@ -1234,6 +1354,15 @@ GLboolean assemble_dst(r700_AssemblerBase *pAsm)
     pAsm->D.dst.writez = (pILInst->DstReg.WriteMask >> 2) & 0x1;
     pAsm->D.dst.writew = (pILInst->DstReg.WriteMask >> 3) & 0x1;
   
+    if(pILInst->SaturateMode == SATURATE_ZERO_ONE)
+    {
+        pAsm->D2.dst2.SaturateMode = 1;
+    }
+    else
+    {
+        pAsm->D2.dst2.SaturateMode = 0;
+    }
+
     return GL_TRUE;
 }
 
@@ -1293,6 +1422,7 @@ GLboolean tex_src(r700_AssemblerBase *pAsm)
     else
     {
     switch (pILInst->SrcReg[0].File) {
+        case PROGRAM_UNIFORM: 
         case PROGRAM_CONSTANT:
         case PROGRAM_LOCAL_PARAM:
         case PROGRAM_ENV_PARAM:
@@ -1305,25 +1435,65 @@ GLboolean tex_src(r700_AssemblerBase *pAsm)
             pAsm->S[0].src.rtype = SRC_REG_TEMPORARY;
             break;
         case PROGRAM_INPUT:
-            switch (pILInst->SrcReg[0].Index)
+            if(SPT_VP == pAsm->currentShaderType)
+            {
+                switch (pILInst->SrcReg[0].Index)
+                {
+                    case VERT_ATTRIB_TEX0:
+                    case VERT_ATTRIB_TEX1:
+                    case VERT_ATTRIB_TEX2:
+                    case VERT_ATTRIB_TEX3:
+                    case VERT_ATTRIB_TEX4:
+                    case VERT_ATTRIB_TEX5:
+                    case VERT_ATTRIB_TEX6:
+                    case VERT_ATTRIB_TEX7:
+                        bValidTexCoord = GL_TRUE;
+                        pAsm->S[0].src.reg   =
+                            pAsm->ucVP_AttributeMap[pILInst->SrcReg[0].Index];
+                        pAsm->S[0].src.rtype = SRC_REG_INPUT;
+                        break;
+                }
+            }
+            else
             {
-                case FRAG_ATTRIB_COL0:
-                case FRAG_ATTRIB_COL1:
-                case FRAG_ATTRIB_TEX0:
-                case FRAG_ATTRIB_TEX1:
-                case FRAG_ATTRIB_TEX2:
-               case FRAG_ATTRIB_TEX3:
-                case FRAG_ATTRIB_TEX4:
-                case FRAG_ATTRIB_TEX5:
-                case FRAG_ATTRIB_TEX6:
-                case FRAG_ATTRIB_TEX7:
-                    bValidTexCoord = GL_TRUE;
+                switch (pILInst->SrcReg[0].Index)
+                {
+                    case FRAG_ATTRIB_WPOS:
+                    case FRAG_ATTRIB_COL0:
+                    case FRAG_ATTRIB_COL1:
+                    case FRAG_ATTRIB_FOGC:
+                    case FRAG_ATTRIB_TEX0:
+                    case FRAG_ATTRIB_TEX1:
+                    case FRAG_ATTRIB_TEX2:
+                    case FRAG_ATTRIB_TEX3:
+                    case FRAG_ATTRIB_TEX4:
+                    case FRAG_ATTRIB_TEX5:
+                    case FRAG_ATTRIB_TEX6:
+                    case FRAG_ATTRIB_TEX7:
+                        bValidTexCoord = GL_TRUE;
+                        pAsm->S[0].src.reg   =
+                            pAsm->uiFP_AttributeMap[pILInst->SrcReg[0].Index];
+                        pAsm->S[0].src.rtype = SRC_REG_INPUT;
+                        break;
+                    case FRAG_ATTRIB_FACE:
+                        fprintf(stderr, "FRAG_ATTRIB_FACE unsupported\n");
+                        break;
+                    case FRAG_ATTRIB_PNTC:
+                        fprintf(stderr, "FRAG_ATTRIB_PNTC unsupported\n");
+                        break;
+                }
+
+                if( (pILInst->SrcReg[0].Index >= FRAG_ATTRIB_VAR0) ||
+                    (pILInst->SrcReg[0].Index < FRAG_ATTRIB_MAX) )
+                {
+                                   bValidTexCoord = GL_TRUE;
                     pAsm->S[0].src.reg   =
                         pAsm->uiFP_AttributeMap[pILInst->SrcReg[0].Index];
                     pAsm->S[0].src.rtype = SRC_REG_INPUT;
-                break;
+                }
             }
-        break;
+
+            break;
         }
     }
 
@@ -1368,8 +1538,17 @@ GLboolean assemble_tex_instruction(r700_AssemblerBase *pAsm, GLboolean normalize
     tex_instruction_ptr->m_Word0.f.tex_inst         = pAsm->D.dst.opcode;
     tex_instruction_ptr->m_Word0.f.bc_frac_mode     = 0x0;
     tex_instruction_ptr->m_Word0.f.fetch_whole_quad = 0x0;
+    tex_instruction_ptr->m_Word0.f.alt_const        = 0;
 
-    tex_instruction_ptr->m_Word0.f.resource_id      = texture_unit_source->reg;
+    if(SPT_VP == pAsm->currentShaderType)
+    {
+        tex_instruction_ptr->m_Word0.f.resource_id      = texture_unit_source->reg + VERT_ATTRIB_MAX;
+        pAsm->unVetTexBits |= 1 << texture_unit_source->reg;
+    }
+    else
+    {
+        tex_instruction_ptr->m_Word0.f.resource_id      = texture_unit_source->reg;
+    }
 
     tex_instruction_ptr->m_Word1.f.lod_bias     = 0x0;
     if (normalized) {
@@ -1388,7 +1567,6 @@ GLboolean assemble_tex_instruction(r700_AssemblerBase *pAsm, GLboolean normalize
     tex_instruction_ptr->m_Word2.f.offset_x   = 0x0;
     tex_instruction_ptr->m_Word2.f.offset_y   = 0x0;
     tex_instruction_ptr->m_Word2.f.offset_z   = 0x0;
-
     tex_instruction_ptr->m_Word2.f.sampler_id = texture_unit_source->reg;
 
     // dst
@@ -1505,6 +1683,10 @@ GLboolean assemble_alu_src(R700ALUInstruction*  alu_instruction_ptr,
         {
             src_sel = pSource->reg + CFILE_REGISTER_OFFSET;            
         }
+        else if (pSource->rtype == SRC_REC_LITERAL)
+        {
+            src_sel = SQ_ALU_SRC_LITERAL;            
+        }
         else
         {
             radeon_error("Source (%d) register type (%d) not one of TEMP, INPUT, or CONSTANT.\n",
@@ -1594,7 +1776,8 @@ GLboolean add_alu_instruction(r700_AssemblerBase* pAsm,
         return GL_FALSE;
     }
 
-    if ( pAsm->cf_current_alu_clause_ptr == NULL ||
+    if ( pAsm->alu_x_opcode != 0 ||
+         pAsm->cf_current_alu_clause_ptr == NULL ||
          ( (pAsm->cf_current_alu_clause_ptr != NULL) && 
            (pAsm->cf_current_alu_clause_ptr->m_Word1.f.count >= (GetCFMaxInstructions(pAsm->cf_current_alu_clause_ptr->m_ShaderInstType)-contiguous_slots_needed-1) )
          ) ) 
@@ -1624,9 +1807,17 @@ GLboolean add_alu_instruction(r700_AssemblerBase* pAsm,
         pAsm->cf_current_alu_clause_ptr->m_Word1.f.kcache_addr0 = 0x0;
         pAsm->cf_current_alu_clause_ptr->m_Word1.f.kcache_addr1 = 0x0;
 
-        //cf_current_alu_clause_ptr->m_Word1.f.count           = number_of_scalar_operations - 1;
         pAsm->cf_current_alu_clause_ptr->m_Word1.f.count           = 0x0;
-        pAsm->cf_current_alu_clause_ptr->m_Word1.f.cf_inst         = SQ_CF_INST_ALU;
+
+        if(pAsm->alu_x_opcode != 0)
+        {
+            pAsm->cf_current_alu_clause_ptr->m_Word1.f.cf_inst = pAsm->alu_x_opcode;
+            pAsm->alu_x_opcode = 0;
+        }
+        else
+        {
+            pAsm->cf_current_alu_clause_ptr->m_Word1.f.cf_inst = SQ_CF_INST_ALU;
+        }
 
         pAsm->cf_current_alu_clause_ptr->m_Word1.f.whole_quad_mode = 0x0;
 
@@ -1634,7 +1825,7 @@ GLboolean add_alu_instruction(r700_AssemblerBase* pAsm,
     }
     else 
     {
-        pAsm->cf_current_alu_clause_ptr->m_Word1.f.count++;
+        pAsm->cf_current_alu_clause_ptr->m_Word1.f.count += (GetInstructionSize(alu_instruction_ptr->m_ShaderInstType) / 2);
     }
 
     // If this clause constains any instruction that is forward dependent on a TEX instruction, 
@@ -1911,7 +2102,7 @@ GLboolean check_scalar(r700_AssemblerBase* pAsm,
 
     GLuint swizzle_key;
 
-    GLuint number_of_operands = r700GetNumOperands(pAsm);
+    GLuint number_of_operands = r700GetNumOperands(pAsm->D.dst.opcode, pAsm->D.dst.op3);
 
     for (src=0; src<number_of_operands; src++) 
     {
@@ -2000,7 +2191,7 @@ GLboolean check_vector(r700_AssemblerBase* pAsm,
 
     GLuint swizzle_key;
 
-    GLuint number_of_operands = r700GetNumOperands(pAsm);
+    GLuint number_of_operands = r700GetNumOperands(pAsm->D.dst.opcode, pAsm->D.dst.op3);
 
     for (src=0; src<number_of_operands; src++) 
     {
@@ -2033,7 +2224,7 @@ GLboolean check_vector(r700_AssemblerBase* pAsm,
         if( is_gpr(sel) ) 
         {
             if( GL_FALSE == cycle_for_vector_bank_swizzle(bank_swizzle, src, &cycle) )
-            {
+            {             
                 return GL_FALSE;
             }
 
@@ -2045,7 +2236,7 @@ GLboolean check_vector(r700_AssemblerBase* pAsm,
             else 
             {
                 if( GL_FALSE == reserve_gpr(pAsm, sel, chan, cycle) )
-                {
+                {                    
                     return GL_FALSE;
                 }
             }
@@ -2057,7 +2248,7 @@ GLboolean check_vector(r700_AssemblerBase* pAsm,
             if( is_cfile(sel) ) 
             {        
                 if( GL_FALSE == reserve_cfile(pAsm, sel, chan) )
-                {
+                {                    
                     return GL_FALSE;
                 }
             }
@@ -2069,6 +2260,10 @@ GLboolean check_vector(r700_AssemblerBase* pAsm,
 
 GLboolean assemble_alu_instruction(r700_AssemblerBase *pAsm)
 {
+    R700ALUInstruction            * alu_instruction_ptr;
+    R700ALUInstructionHalfLiteral * alu_instruction_ptr_hl;
+    R700ALUInstructionFullLiteral * alu_instruction_ptr_fl;
+
     GLuint    number_of_scalar_operations;
     GLboolean is_single_scalar_operation;
     GLuint    scalar_channel_index;
@@ -2077,7 +2272,7 @@ GLboolean assemble_alu_instruction(r700_AssemblerBase *pAsm)
     int    current_source_index;
     GLuint contiguous_slots_needed;
 
-    GLuint    uNumSrc = r700GetNumOperands(pAsm);
+    GLuint    uNumSrc = r700GetNumOperands(pAsm->D.dst.opcode, pAsm->D.dst.op3);
     //GLuint    channel_swizzle, j;
     //GLuint    chan_counter[4] = {0, 0, 0, 0};
     //PVSSRC *  pSource[3];
@@ -2134,23 +2329,44 @@ GLboolean assemble_alu_instruction(r700_AssemblerBase *pAsm)
 
     contiguous_slots_needed = 0;
 
-    if(GL_TRUE == is_reduction_opcode(&(pAsm->D)) 
+    if(!is_single_scalar_operation
     {
         contiguous_slots_needed = 4;
     }
 
+    contiguous_slots_needed += pAsm->D2.dst2.literal_slots;
+
     initialize(pAsm);    
 
     for (scalar_channel_index=0;
             scalar_channel_index < number_of_scalar_operations; 
                 scalar_channel_index++) 
     {
-        R700ALUInstruction* alu_instruction_ptr = (R700ALUInstruction*) CALLOC_STRUCT(R700ALUInstruction);
-        if (alu_instruction_ptr == NULL) 
-               {
-                       return GL_FALSE;
-               }
-        Init_R700ALUInstruction(alu_instruction_ptr);
+        if(scalar_channel_index == (number_of_scalar_operations-1))
+        {
+            switch(pAsm->D2.dst2.literal_slots)
+            {
+            case 0:
+                alu_instruction_ptr = (R700ALUInstruction*) CALLOC_STRUCT(R700ALUInstruction);
+                Init_R700ALUInstruction(alu_instruction_ptr);
+                break;
+            case 1:
+                alu_instruction_ptr_hl = (R700ALUInstructionHalfLiteral*) CALLOC_STRUCT(R700ALUInstructionHalfLiteral);
+                Init_R700ALUInstructionHalfLiteral(alu_instruction_ptr_hl, pAsm->C[0].f, pAsm->C[1].f);
+                alu_instruction_ptr = (R700ALUInstruction*)alu_instruction_ptr_hl;
+                break;
+            case 2:
+                alu_instruction_ptr_fl = (R700ALUInstructionFullLiteral*) CALLOC_STRUCT(R700ALUInstructionFullLiteral);
+                Init_R700ALUInstructionFullLiteral(alu_instruction_ptr_fl,pAsm->C[0].f, pAsm->C[1].f, pAsm->C[2].f, pAsm->C[3].f);
+                alu_instruction_ptr = (R700ALUInstruction*)alu_instruction_ptr_fl;
+            break;
+            };
+        }
+        else
+        {
+            alu_instruction_ptr = (R700ALUInstruction*) CALLOC_STRUCT(R700ALUInstruction);
+            Init_R700ALUInstruction(alu_instruction_ptr);
+        }
         
         //src 0
         current_source_index = 0;
@@ -2160,7 +2376,7 @@ GLboolean assemble_alu_instruction(r700_AssemblerBase *pAsm)
                                          current_source_index,
                                          pcurrent_source, 
                                          scalar_channel_index) )     
-        {
+        {            
             return GL_FALSE;
         }
    
@@ -2174,13 +2390,13 @@ GLboolean assemble_alu_instruction(r700_AssemblerBase *pAsm)
                                              current_source_index,
                                              pcurrent_source, 
                                              scalar_channel_index) ) 
-            {
+            {                
                 return GL_FALSE;
             }
         }
 
         //other bits
-        alu_instruction_ptr->m_Word0.f.index_mode = SQ_INDEX_LOOP;
+        alu_instruction_ptr->m_Word0.f.index_mode = pAsm->D2.dst2.index_mode;
 
         if(   (is_single_scalar_operation == GL_TRUE) 
            || (GL_TRUE == bSplitInst) )
@@ -2192,9 +2408,17 @@ GLboolean assemble_alu_instruction(r700_AssemblerBase *pAsm)
             alu_instruction_ptr->m_Word0.f.last = (scalar_channel_index == 3) ?  1 : 0;
         }
 
-        alu_instruction_ptr->m_Word0.f.pred_sel                = 0x0;
-        alu_instruction_ptr->m_Word1_OP2.f.update_pred         = 0x0;  
-        alu_instruction_ptr->m_Word1_OP2.f.update_execute_mask = 0x0;
+        alu_instruction_ptr->m_Word0.f.pred_sel = (pAsm->D.dst.pred_inv > 0) ? 1 : 0;
+        if(1 == pAsm->D.dst.predicated)
+        {
+            alu_instruction_ptr->m_Word1_OP2.f.update_pred         = 0x1;
+            alu_instruction_ptr->m_Word1_OP2.f.update_execute_mask = 0x1;
+        }
+        else
+        {
+            alu_instruction_ptr->m_Word1_OP2.f.update_pred         = 0x0;
+            alu_instruction_ptr->m_Word1_OP2.f.update_execute_mask = 0x0;
+        }
 
         // dst
         if( (pAsm->D.dst.rtype == DST_REG_TEMPORARY) || 
@@ -2203,7 +2427,7 @@ GLboolean assemble_alu_instruction(r700_AssemblerBase *pAsm)
             alu_instruction_ptr->m_Word1.f.dst_gpr  = pAsm->D.dst.reg;
         }
         else 
-        {
+        {            
             radeon_error("Only temp destination registers supported for ALU dest regs.\n");
             return GL_FALSE;
         }
@@ -2233,7 +2457,7 @@ GLboolean assemble_alu_instruction(r700_AssemblerBase *pAsm)
 
         alu_instruction_ptr->m_Word1.f.dst_chan = scalar_channel_index;
 
-        alu_instruction_ptr->m_Word1.f.clamp    = pAsm->pILInst[pAsm->uiCurInst].SaturateMode;
+        alu_instruction_ptr->m_Word1.f.clamp    = pAsm->D2.dst2.SaturateMode;
 
         if (pAsm->D.dst.op3) 
         {            
@@ -2260,8 +2484,8 @@ GLboolean assemble_alu_instruction(r700_AssemblerBase *pAsm)
             {
                 alu_instruction_ptr->m_Word1_OP2.f6.alu_inst           = pAsm->D.dst.opcode;
 
-                alu_instruction_ptr->m_Word1_OP2.f6.src0_abs           = 0x0;
-                alu_instruction_ptr->m_Word1_OP2.f6.src1_abs           = 0x0;
+                alu_instruction_ptr->m_Word1_OP2.f6.src0_abs           = pAsm->S[0].src.abs;
+                alu_instruction_ptr->m_Word1_OP2.f6.src1_abs           = pAsm->S[1].src.abs;
 
                 //alu_instruction_ptr->m_Word1_OP2.f6.update_execute_mask = 0x0;
                 //alu_instruction_ptr->m_Word1_OP2.f6.update_pred         = 0x0;
@@ -2289,8 +2513,8 @@ GLboolean assemble_alu_instruction(r700_AssemblerBase *pAsm)
             {
                 alu_instruction_ptr->m_Word1_OP2.f.alu_inst           = pAsm->D.dst.opcode;
 
-                alu_instruction_ptr->m_Word1_OP2.f.src0_abs           = 0x0;
-                alu_instruction_ptr->m_Word1_OP2.f.src1_abs           = 0x0;
+                alu_instruction_ptr->m_Word1_OP2.f.src0_abs           = pAsm->S[0].src.abs;
+                alu_instruction_ptr->m_Word1_OP2.f.src1_abs           = pAsm->S[1].src.abs;
 
                 //alu_instruction_ptr->m_Word1_OP2.f.update_execute_mask = 0x0;
                 //alu_instruction_ptr->m_Word1_OP2.f.update_pred         = 0x0;
@@ -2317,7 +2541,7 @@ GLboolean assemble_alu_instruction(r700_AssemblerBase *pAsm)
         }
 
         if(GL_FALSE == add_alu_instruction(pAsm, alu_instruction_ptr, contiguous_slots_needed) )
-        {
+        {            
             return GL_FALSE;
         }
 
@@ -2328,19 +2552,19 @@ GLboolean assemble_alu_instruction(r700_AssemblerBase *pAsm)
         if (is_single_scalar_operation) 
         {
             if(GL_FALSE == check_scalar(pAsm, alu_instruction_ptr) )
-            {
+            {                
                 return GL_FALSE;
             }
         }
         else 
         {
             if(GL_FALSE == check_vector(pAsm, alu_instruction_ptr) )
-            {
-                return 1;
+            {                
+                return GL_FALSE; 
             }
         }
 
-        contiguous_slots_needed = 0;
+        contiguous_slots_needed -= 1;
     }
 
     return GL_TRUE;
@@ -2391,11 +2615,14 @@ GLboolean next_ins(r700_AssemblerBase *pAsm)
     
     //reset for next inst.
     pAsm->D.bits    = 0;
+    pAsm->D2.bits   = 0;
     pAsm->S[0].bits = 0;
     pAsm->S[1].bits = 0;
     pAsm->S[2].bits = 0;
     pAsm->is_tex = GL_FALSE;
     pAsm->need_tex_barrier = GL_FALSE;
+    pAsm->D2.bits = 0;
+    pAsm->C[0].bits = pAsm->C[1].bits = pAsm->C[2].bits = pAsm->C[3].bits = 0;
     return GL_TRUE;
 }
 
@@ -2514,6 +2741,35 @@ GLboolean assemble_ADD(r700_AssemblerBase *pAsm)
     return GL_TRUE;
 }
 
+GLboolean assemble_ARL(r700_AssemblerBase *pAsm)
+{ /* TODO: ar values dont' persist between clauses */
+    if( GL_FALSE == checkop1(pAsm) )
+    {
+        return GL_FALSE;
+    }
+
+    pAsm->D.dst.opcode = SQ_OP2_INST_MOVA_FLOOR;
+    setaddrmode_PVSDST(&(pAsm->D.dst), ADDR_ABSOLUTE);
+    pAsm->D.dst.rtype = DST_REG_TEMPORARY;
+    pAsm->D.dst.reg = 0;
+    pAsm->D.dst.writex = 0;
+    pAsm->D.dst.writey = 0;
+    pAsm->D.dst.writez = 0;
+    pAsm->D.dst.writew = 0;
+
+    if( GL_FALSE == assemble_src(pAsm, 0, -1) )
+    {
+        return GL_FALSE;
+    }
+
+    if( GL_FALSE == next_ins(pAsm) )
+    {
+        return GL_FALSE;
+    }
+
+    return GL_TRUE;
+}
+
 GLboolean assemble_BAD(char *opcode_str) 
 {
     radeon_error("Not yet implemented instruction (%s)\n", opcode_str);
@@ -2599,9 +2855,44 @@ GLboolean assemble_CMP(r700_AssemblerBase *pAsm)
     return GL_TRUE;
 }
 
-GLboolean assemble_COS(r700_AssemblerBase *pAsm)
+GLboolean assemble_TRIG(r700_AssemblerBase *pAsm, BITS opcode)
 {
-    return assemble_math_function(pAsm, SQ_OP2_INST_COS);
+    int tmp;
+    checkop1(pAsm);
+
+    tmp = gethelpr(pAsm);
+
+    pAsm->D.dst.opcode = SQ_OP2_INST_MUL;
+    setaddrmode_PVSDST(&(pAsm->D.dst), ADDR_ABSOLUTE);
+    pAsm->D.dst.rtype  = DST_REG_TEMPORARY;
+    pAsm->D.dst.reg    = tmp;
+    pAsm->D.dst.writex = 1;
+
+    assemble_src(pAsm, 0, -1);
+
+    pAsm->S[1].src.rtype = SRC_REC_LITERAL;
+    setswizzle_PVSSRC(&(pAsm->S[1].src), SQ_SEL_X);
+    pAsm->D2.dst2.literal_slots = 1;
+    pAsm->C[0].f = 1/(3.1415926535 * 2);
+    pAsm->C[1].f = 0.0F;
+    next_ins(pAsm);
+
+    pAsm->D.dst.opcode = opcode;
+    pAsm->D.dst.math = 1;
+
+    assemble_dst(pAsm);
+
+    setaddrmode_PVSSRC(&(pAsm->S[0].src), ADDR_ABSOLUTE);
+    pAsm->S[0].src.rtype = SRC_REG_TEMPORARY;
+    pAsm->S[0].src.reg   = tmp;
+    setswizzle_PVSSRC(&(pAsm->S[0].src), SQ_SEL_X);
+    noneg_PVSSRC(&(pAsm->S[0].src));
+
+    next_ins(pAsm);
+
+    //TODO - replicate if more channels set in WriteMask
+    return GL_TRUE;
+
 }
  
 GLboolean assemble_DOT(r700_AssemblerBase *pAsm)
@@ -2635,7 +2926,7 @@ GLboolean assemble_DOT(r700_AssemblerBase *pAsm)
     }
     else if(pAsm->pILInst[pAsm->uiCurInst].Opcode == OPCODE_DPH) 
     {
-        onecomp_PVSSRC(&(pAsm->S[1].src), 3);
+        onecomp_PVSSRC(&(pAsm->S[0].src), 3);
     } 
 
     if ( GL_FALSE == next_ins(pAsm) ) 
@@ -2688,71 +2979,200 @@ GLboolean assemble_EX2(r700_AssemblerBase *pAsm)
 {
     return assemble_math_function(pAsm, SQ_OP2_INST_EXP_IEEE);
 }
-GLboolean assemble_FLR(r700_AssemblerBase *pAsm)
+
+GLboolean assemble_EXP(r700_AssemblerBase *pAsm)
 {
+    BITS tmp;
+
     checkop1(pAsm);
 
-    pAsm->D.dst.opcode = SQ_OP2_INST_FLOOR;  
+    tmp = gethelpr(pAsm);
 
-    if ( GL_FALSE == assemble_dst(pAsm) )
-    {
-        return GL_FALSE;
-    }
+    // FLOOR   tmp.x,    a.x
+    // EX2     dst.x     tmp.x
 
-    if ( GL_FALSE == assemble_src(pAsm, 0, -1) )
-    {
-        return GL_FALSE;
-    }
+    if (pAsm->pILInst->DstReg.WriteMask & 0x1) {
+        pAsm->D.dst.opcode = SQ_OP2_INST_FLOOR;
 
-    if ( GL_FALSE == next_ins(pAsm) ) 
-    {
-        return GL_FALSE;
-    }
+        setaddrmode_PVSDST(&(pAsm->D.dst), ADDR_ABSOLUTE);
+        pAsm->D.dst.rtype  = DST_REG_TEMPORARY;
+        pAsm->D.dst.reg    = tmp;
+        pAsm->D.dst.writex = 1;
 
-    return GL_TRUE;
-}
+        if( GL_FALSE == assemble_src(pAsm, 0, -1) )
+        {
+            return GL_FALSE;
+        }
 
-GLboolean assemble_FLR_INT(r700_AssemblerBase *pAsm)
-{
-    return assemble_math_function(pAsm, SQ_OP2_INST_FLT_TO_INT);
-}
+        if( GL_FALSE == next_ins(pAsm) )
+        {
+            return GL_FALSE;
+        }
 
-GLboolean assemble_FRC(r700_AssemblerBase *pAsm)
-{
-    checkop1(pAsm);
+        pAsm->D.dst.opcode = SQ_OP2_INST_EXP_IEEE;
+        pAsm->D.dst.math = 1;
 
-    pAsm->D.dst.opcode = SQ_OP2_INST_FRACT; 
+        if( GL_FALSE == assemble_dst(pAsm) )
+        {
+            return GL_FALSE;
+        }
 
-    if ( GL_FALSE == assemble_dst(pAsm) )
-    {
-        return GL_FALSE;
-    }
+        pAsm->D.dst.writey = pAsm->D.dst.writez = pAsm->D.dst.writew = 0;
 
-    if ( GL_FALSE == assemble_src(pAsm, 0, -1) )
-    {
-        return GL_FALSE;
-    }
+        setaddrmode_PVSSRC(&(pAsm->S[0].src), ADDR_ABSOLUTE);
+        pAsm->S[0].src.rtype = DST_REG_TEMPORARY;
+        pAsm->S[0].src.reg   = tmp;
 
-    if ( GL_FALSE == next_ins(pAsm) )
-    {
-        return GL_FALSE;
+        setswizzle_PVSSRC(&(pAsm->S[0].src), SQ_SEL_X);
+        noneg_PVSSRC(&(pAsm->S[0].src));
+
+        if( GL_FALSE == next_ins(pAsm) )
+        {
+            return GL_FALSE;
+        }
     }
 
-    return GL_TRUE;
-}
-GLboolean assemble_KIL(r700_AssemblerBase *pAsm)
-{
-    checkop1(pAsm);
+    // FRACT   dst.y     a.x
 
-    pAsm->D.dst.opcode = SQ_OP2_INST_KILLGT;  
-  
-    if ( GL_FALSE == assemble_dst(pAsm) )
-    {
+    if ((pAsm->pILInst->DstReg.WriteMask >> 1) & 0x1) {
+        pAsm->D.dst.opcode = SQ_OP2_INST_FRACT;
+
+        if( GL_FALSE == assemble_dst(pAsm) )
+        {
+            return GL_FALSE;
+        }
+
+        if( GL_FALSE == assemble_src(pAsm, 0, -1) )
+        {
+            return GL_FALSE;
+        }
+
+        pAsm->D.dst.writex = pAsm->D.dst.writez = pAsm->D.dst.writew = 0;
+
+        if( GL_FALSE == next_ins(pAsm) )
+        {
+            return GL_FALSE;
+        }
+    }
+
+    // EX2     dst.z,    a.x
+
+    if ((pAsm->pILInst->DstReg.WriteMask >> 2) & 0x1) {
+        pAsm->D.dst.opcode = SQ_OP2_INST_EXP_IEEE;
+        pAsm->D.dst.math = 1;
+
+        if( GL_FALSE == assemble_dst(pAsm) )
+        {
+            return GL_FALSE;
+        }
+
+        if( GL_FALSE == assemble_src(pAsm, 0, -1) )
+        {
+            return GL_FALSE;
+        }
+
+        pAsm->D.dst.writex = pAsm->D.dst.writey = pAsm->D.dst.writew = 0;
+
+        if( GL_FALSE == next_ins(pAsm) )
+        {
+            return GL_FALSE;
+        }
+    }
+
+    // MOV     dst.w     1.0
+
+    if ((pAsm->pILInst->DstReg.WriteMask >> 3) & 0x1) {
+        pAsm->D.dst.opcode = SQ_OP2_INST_MOV;
+
+        if( GL_FALSE == assemble_dst(pAsm) )
+        {
+            return GL_FALSE;
+        }
+
+        pAsm->D.dst.writex = pAsm->D.dst.writey = pAsm->D.dst.writez = 0;
+
+        setaddrmode_PVSSRC(&(pAsm->S[0].src), ADDR_ABSOLUTE);
+        pAsm->S[0].src.rtype = SRC_REG_TEMPORARY;
+        pAsm->S[0].src.reg   = tmp;
+
+        setswizzle_PVSSRC(&(pAsm->S[0].src), SQ_SEL_1);
+        noneg_PVSSRC(&(pAsm->S[0].src));
+
+        if( GL_FALSE == next_ins(pAsm) )
+        {
+            return GL_FALSE;
+        }
+    }
+
+    return GL_TRUE;
+}
+GLboolean assemble_FLR(r700_AssemblerBase *pAsm)
+{
+    checkop1(pAsm);
+
+    pAsm->D.dst.opcode = SQ_OP2_INST_FLOOR;  
+
+    if ( GL_FALSE == assemble_dst(pAsm) )
+    {
+        return GL_FALSE;
+    }
+
+    if ( GL_FALSE == assemble_src(pAsm, 0, -1) )
+    {
+        return GL_FALSE;
+    }
+
+    if ( GL_FALSE == next_ins(pAsm) ) 
+    {
+        return GL_FALSE;
+    }
+
+    return GL_TRUE;
+}
+
+GLboolean assemble_FLR_INT(r700_AssemblerBase *pAsm)
+{
+    return assemble_math_function(pAsm, SQ_OP2_INST_FLT_TO_INT);
+}
+
+GLboolean assemble_FRC(r700_AssemblerBase *pAsm)
+{
+    checkop1(pAsm);
+
+    pAsm->D.dst.opcode = SQ_OP2_INST_FRACT; 
+
+    if ( GL_FALSE == assemble_dst(pAsm) )
+    {
+        return GL_FALSE;
+    }
+
+    if ( GL_FALSE == assemble_src(pAsm, 0, -1) )
+    {
         return GL_FALSE;
     }
 
+    if ( GL_FALSE == next_ins(pAsm) )
+    {
+        return GL_FALSE;
+    }
+
+    return GL_TRUE;
+}
+GLboolean assemble_KIL(r700_AssemblerBase *pAsm, GLuint opcode)
+{  
+    struct prog_instruction *pILInst = &(pAsm->pILInst[pAsm->uiCurInst]);
+
+    if(pILInst->Opcode == OPCODE_KIL)
+        checkop1(pAsm);
+
+    pAsm->D.dst.opcode = opcode;  
+    //pAsm->D.dst.math = 1;
+
+    setaddrmode_PVSDST(&(pAsm->D.dst), ADDR_ABSOLUTE);
+    pAsm->D.dst.rtype = DST_REG_TEMPORARY;
+    pAsm->D.dst.reg   = 0;
     pAsm->D.dst.writex = 0;
     pAsm->D.dst.writey = 0;
     pAsm->D.dst.writez = 0;
@@ -2761,30 +3181,34 @@ GLboolean assemble_KIL(r700_AssemblerBase *pAsm)
     setaddrmode_PVSSRC(&(pAsm->S[0].src), ADDR_ABSOLUTE);
     pAsm->S[0].src.rtype = SRC_REG_TEMPORARY;
     pAsm->S[0].src.reg = 0;
-
     setswizzle_PVSSRC(&(pAsm->S[0].src), SQ_SEL_0);
     noneg_PVSSRC(&(pAsm->S[0].src));
 
-    pAsm->S[1].src.rtype = SRC_REG_TEMPORARY;
-
-    if(PROGRAM_TEMPORARY == pAsm->pILInst[pAsm->uiCurInst].DstReg.File)
+    if(pILInst->Opcode == OPCODE_KIL_NV)
     {
-        pAsm->S[1].src.reg = pAsm->pILInst[pAsm->uiCurInst].DstReg.Index + pAsm->starting_temp_register_number;
+        setaddrmode_PVSSRC(&(pAsm->S[1].src), ADDR_ABSOLUTE);
+        pAsm->S[1].src.rtype = SRC_REG_TEMPORARY;
+        pAsm->S[1].src.reg = 0;
+        setswizzle_PVSSRC(&(pAsm->S[1].src), SQ_SEL_1);
+        neg_PVSSRC(&(pAsm->S[1].src));
     }
     else
-    {   //PROGRAM_OUTPUT
-        pAsm->S[1].src.reg = pAsm->uiFP_OutputMap[pAsm->pILInst[pAsm->uiCurInst].DstReg.Index];
+    {
+        if( GL_FALSE == assemble_src(pAsm, 0, 1) )
+        {
+            return GL_FALSE;
+        }
+
     }
-  
-    setaddrmode_PVSSRC(&(pAsm->S[1].src), ADDR_ABSOLUTE);
-    noswizzle_PVSSRC(&(pAsm->S[1].src));
-  
+
     if ( GL_FALSE == next_ins(pAsm) )
     {
         return GL_FALSE;
     }
 
+    /* Doc says KILL has to be last(end) ALU clause */
     pAsm->pR700Shader->killIsUsed = GL_TRUE;
+    pAsm->alu_x_opcode = SQ_CF_INST_ALU;
     
     return GL_TRUE;
 }
@@ -2848,6 +3272,7 @@ GLboolean assemble_LRP(r700_AssemblerBase *pAsm)
     {
         return GL_FALSE;
     }
+
     if( GL_FALSE == assemble_src(pAsm, 2, -1) ) 
     {
         return GL_FALSE;
@@ -2878,124 +3303,335 @@ GLboolean assemble_LRP(r700_AssemblerBase *pAsm)
     return GL_TRUE;
 }
 
-GLboolean assemble_MAD(struct r700_AssemblerBase *pAsm) 
+GLboolean assemble_LOG(r700_AssemblerBase *pAsm)
 {
-    int tmp, ii;
-    GLboolean bReplaceDst = GL_FALSE;
-    struct prog_instruction *pILInst = &(pAsm->pILInst[pAsm->uiCurInst]);
-
-       if( GL_FALSE == checkop3(pAsm) )
-    {
-        return GL_FALSE;
-    }
+    BITS tmp1, tmp2, tmp3;
 
-       pAsm->D.dst.opcode = SQ_OP3_INST_MULADD;  
-       pAsm->D.dst.op3     = 1; 
+    checkop1(pAsm);
 
-       tmp = (-1);
+    tmp1 = gethelpr(pAsm);
+    tmp2 = gethelpr(pAsm);
+    tmp3 = gethelpr(pAsm);
 
-    if(PROGRAM_TEMPORARY == pILInst->DstReg.File)
-    {   /* TODO : more investigation on MAD src and dst using same register */
-        for(ii=0; ii<3; ii++)
-        {
-            if(   (PROGRAM_TEMPORARY == pILInst->SrcReg[ii].File)
-               && (pILInst->DstReg.Index == pILInst->SrcReg[ii].Index) )
-            {
-                bReplaceDst = GL_TRUE;
-                break;
-            }
-        }
-    }
-    if(0xF != pILInst->DstReg.WriteMask)
-    {   /* OP3 has no support for write mask */
-        bReplaceDst = GL_TRUE;
-    }
+    // FIXME: The hardware can do fabs() directly on input
+    //        elements, but the compiler doesn't have the
+    //        capability to use that.
 
-       if(GL_TRUE == bReplaceDst)
-    {
-        tmp = gethelpr(pAsm);
+    // MAX     tmp1.x,   a.x,    -a.x   (fabs(a.x))
 
-        setaddrmode_PVSDST(&(pAsm->D.dst), ADDR_ABSOLUTE);
-        pAsm->D.dst.rtype = DST_REG_TEMPORARY;
-        pAsm->D.dst.reg   = tmp;
+    pAsm->D.dst.opcode = SQ_OP2_INST_MAX;  
 
-        nomask_PVSDST(&(pAsm->D.dst));
-    }
-    else 
-    {
-        if( GL_FALSE == assemble_dst(pAsm) )
-        {
-            return GL_FALSE;
-        }
-    }
+    setaddrmode_PVSDST(&(pAsm->D.dst), ADDR_ABSOLUTE);
+    pAsm->D.dst.rtype  = DST_REG_TEMPORARY;
+    pAsm->D.dst.reg    = tmp1;
+    pAsm->D.dst.writex = 1;
 
-       if( GL_FALSE == assemble_src(pAsm, 0, -1) )
-    {
-        return GL_FALSE;
-    }
-              
-    if( GL_FALSE == assemble_src(pAsm, 1, -1) )  
+    if( GL_FALSE == assemble_src(pAsm, 0, -1) )
     {
         return GL_FALSE;
     }
+    pAsm->S[1].bits = pAsm->S[0].bits;
+    flipneg_PVSSRC(&(pAsm->S[1].src));
 
-    if( GL_FALSE == assemble_src(pAsm, 2, -1) ) 
+    if ( GL_FALSE == next_ins(pAsm) ) 
     {
         return GL_FALSE;
     }
 
-    if ( GL_FALSE == next_ins(pAsm) )
+    // Entire algo:
+    //
+    // LG2     tmp2.x,   tmp1.x
+    // FLOOR   tmp3.x,   tmp2.x
+    // MOV     dst.x,    tmp3.x
+    // ADD     tmp3.x,   tmp2.x,    -tmp3.x
+    // EX2     dst.y,    tmp3.x
+    // MOV     dst.z,    tmp2.x
+    // MOV     dst.w,    1.0
+
+    // LG2     tmp2.x,   tmp1.x
+    // FLOOR   tmp3.x,   tmp2.x
+
+    pAsm->D.dst.opcode = SQ_OP2_INST_LOG_IEEE;
+    pAsm->D.dst.math = 1;
+
+    setaddrmode_PVSDST(&(pAsm->D.dst), ADDR_ABSOLUTE);
+    pAsm->D.dst.rtype  = DST_REG_TEMPORARY;
+    pAsm->D.dst.reg    = tmp2;
+    pAsm->D.dst.writex = 1;
+
+    setaddrmode_PVSSRC(&(pAsm->S[0].src), ADDR_ABSOLUTE);
+    pAsm->S[0].src.rtype = DST_REG_TEMPORARY;
+    pAsm->S[0].src.reg   = tmp1;
+
+    setswizzle_PVSSRC(&(pAsm->S[0].src), SQ_SEL_X);
+    noneg_PVSSRC(&(pAsm->S[0].src));
+
+    if( GL_FALSE == next_ins(pAsm) )
     {
         return GL_FALSE;
     }
 
-       if (GL_TRUE == bReplaceDst) 
-    {
-        if( GL_FALSE == assemble_dst(pAsm) )
-        {
-            return GL_FALSE;
-        }
+    pAsm->D.dst.opcode = SQ_OP2_INST_FLOOR;
 
-        pAsm->D.dst.opcode = SQ_OP2_INST_MOV;
+    setaddrmode_PVSDST(&(pAsm->D.dst), ADDR_ABSOLUTE);
+    pAsm->D.dst.rtype  = DST_REG_TEMPORARY;
+    pAsm->D.dst.reg    = tmp3;
+    pAsm->D.dst.writex = 1;
 
-        //tmp for source
-        setaddrmode_PVSSRC(&(pAsm->S[0].src), ADDR_ABSOLUTE);
-        pAsm->S[0].src.rtype = SRC_REG_TEMPORARY;
-        pAsm->S[0].src.reg   = tmp;
+    setaddrmode_PVSSRC(&(pAsm->S[0].src), ADDR_ABSOLUTE);
+    pAsm->S[0].src.rtype = DST_REG_TEMPORARY;
+    pAsm->S[0].src.reg   = tmp2;
 
-        noneg_PVSSRC(&(pAsm->S[0].src));
-        noswizzle_PVSSRC(&(pAsm->S[0].src));
+    setswizzle_PVSSRC(&(pAsm->S[0].src), SQ_SEL_X);
+    noneg_PVSSRC(&(pAsm->S[0].src));
 
-        if( GL_FALSE == next_ins(pAsm) )
-        {
-            return GL_FALSE;
-        }
+    if( GL_FALSE == next_ins(pAsm) )
+    {
+        return GL_FALSE;
     }
 
-    return GL_TRUE;
-}
+    // MOV     dst.x,    tmp3.x
 
-/* LIT dst, src */
-GLboolean assemble_LIT(r700_AssemblerBase *pAsm)
-{
-    unsigned int dstReg;
-    unsigned int dstType;
-    unsigned int srcReg;
-    unsigned int srcType;
-    checkop1(pAsm);
-    int tmp = gethelpr(pAsm);
+    pAsm->D.dst.opcode = SQ_OP2_INST_MOV;
 
     if( GL_FALSE == assemble_dst(pAsm) )
     {
         return GL_FALSE;
     }
-    if( GL_FALSE == assemble_src(pAsm, 0, -1) )
-    {
-        return GL_FALSE;
-    }
-    dstReg  = pAsm->D.dst.reg;
-    dstType = pAsm->D.dst.rtype;
-    srcReg  = pAsm->S[0].src.reg;
+
+    pAsm->D.dst.writey = pAsm->D.dst.writez = pAsm->D.dst.writew = 0;
+
+    setaddrmode_PVSSRC(&(pAsm->S[0].src), ADDR_ABSOLUTE);
+    pAsm->S[0].src.rtype = DST_REG_TEMPORARY;
+    pAsm->S[0].src.reg   = tmp3;
+
+    setswizzle_PVSSRC(&(pAsm->S[0].src), SQ_SEL_X);
+    noneg_PVSSRC(&(pAsm->S[0].src));
+
+    if( GL_FALSE == next_ins(pAsm) )
+    {
+        return GL_FALSE;
+    }
+
+    // ADD     tmp3.x,   tmp2.x,    -tmp3.x
+    // EX2     dst.y,    tmp3.x
+
+    pAsm->D.dst.opcode = SQ_OP2_INST_ADD;
+
+    setaddrmode_PVSDST(&(pAsm->D.dst), ADDR_ABSOLUTE);
+    pAsm->D.dst.rtype  = DST_REG_TEMPORARY;
+    pAsm->D.dst.reg    = tmp3;
+    pAsm->D.dst.writex = 1;
+
+    setaddrmode_PVSSRC(&(pAsm->S[0].src), ADDR_ABSOLUTE);
+    pAsm->S[0].src.rtype = DST_REG_TEMPORARY;
+    pAsm->S[0].src.reg   = tmp2;
+
+    setswizzle_PVSSRC(&(pAsm->S[0].src), SQ_SEL_X);
+    noneg_PVSSRC(&(pAsm->S[0].src));
+
+    setaddrmode_PVSSRC(&(pAsm->S[1].src), ADDR_ABSOLUTE);
+    pAsm->S[1].src.rtype = DST_REG_TEMPORARY;
+    pAsm->S[1].src.reg   = tmp3;
+
+    setswizzle_PVSSRC(&(pAsm->S[1].src), SQ_SEL_X);
+    neg_PVSSRC(&(pAsm->S[1].src));
+
+    if( GL_FALSE == next_ins(pAsm) )
+    {
+        return GL_FALSE;
+    }
+
+    pAsm->D.dst.opcode = SQ_OP2_INST_EXP_IEEE;
+    pAsm->D.dst.math = 1;
+
+    if( GL_FALSE == assemble_dst(pAsm) )
+    {
+        return GL_FALSE;
+    }
+
+    pAsm->D.dst.writex = pAsm->D.dst.writez = pAsm->D.dst.writew = 0;
+
+    setaddrmode_PVSSRC(&(pAsm->S[0].src), ADDR_ABSOLUTE);
+    pAsm->S[0].src.rtype = DST_REG_TEMPORARY;
+    pAsm->S[0].src.reg   = tmp3;
+
+    setswizzle_PVSSRC(&(pAsm->S[0].src), SQ_SEL_X);
+    noneg_PVSSRC(&(pAsm->S[0].src));
+
+    if( GL_FALSE == next_ins(pAsm) )
+    {
+        return GL_FALSE;
+    }
+
+    // MOV     dst.z,    tmp2.x
+
+    pAsm->D.dst.opcode = SQ_OP2_INST_MOV;
+
+    if( GL_FALSE == assemble_dst(pAsm) )
+    {
+        return GL_FALSE;
+    }
+
+    pAsm->D.dst.writex = pAsm->D.dst.writey = pAsm->D.dst.writew = 0;
+
+    setaddrmode_PVSSRC(&(pAsm->S[0].src), ADDR_ABSOLUTE);
+    pAsm->S[0].src.rtype = DST_REG_TEMPORARY;
+    pAsm->S[0].src.reg   = tmp2;
+
+    setswizzle_PVSSRC(&(pAsm->S[0].src), SQ_SEL_X);
+    noneg_PVSSRC(&(pAsm->S[0].src));
+
+    if( GL_FALSE == next_ins(pAsm) )
+    {
+        return GL_FALSE;
+    }
+
+    // MOV     dst.w     1.0
+
+    pAsm->D.dst.opcode = SQ_OP2_INST_MOV;
+
+    if( GL_FALSE == assemble_dst(pAsm) )
+    {
+        return GL_FALSE;
+    }
+
+    pAsm->D.dst.writex = pAsm->D.dst.writey = pAsm->D.dst.writez = 0;
+
+    setaddrmode_PVSSRC(&(pAsm->S[0].src), ADDR_ABSOLUTE);
+    pAsm->S[0].src.rtype = SRC_REG_TEMPORARY;
+    pAsm->S[0].src.reg   = tmp1;
+
+    setswizzle_PVSSRC(&(pAsm->S[0].src), SQ_SEL_1);
+    noneg_PVSSRC(&(pAsm->S[0].src));
+
+    if( GL_FALSE == next_ins(pAsm) )
+    {
+        return GL_FALSE;
+    }
+
+    return GL_TRUE;
+}
+
+GLboolean assemble_MAD(struct r700_AssemblerBase *pAsm) 
+{
+    int tmp, ii;
+    GLboolean bReplaceDst = GL_FALSE;
+    struct prog_instruction *pILInst = &(pAsm->pILInst[pAsm->uiCurInst]);
+
+       if( GL_FALSE == checkop3(pAsm) )
+    {
+        return GL_FALSE;
+    }
+
+       pAsm->D.dst.opcode = SQ_OP3_INST_MULADD;  
+       pAsm->D.dst.op3     = 1; 
+
+       tmp = (-1);
+
+    if(PROGRAM_TEMPORARY == pILInst->DstReg.File)
+    {   /* TODO : more investigation on MAD src and dst using same register */
+        for(ii=0; ii<3; ii++)
+        {
+            if(   (PROGRAM_TEMPORARY == pILInst->SrcReg[ii].File)
+               && (pILInst->DstReg.Index == pILInst->SrcReg[ii].Index) )
+            {
+                bReplaceDst = GL_TRUE;
+                break;
+            }
+        }
+    }
+    if(0xF != pILInst->DstReg.WriteMask)
+    {   /* OP3 has no support for write mask */
+        bReplaceDst = GL_TRUE;
+    }
+
+       if(GL_TRUE == bReplaceDst)
+    {
+        tmp = gethelpr(pAsm);
+
+        setaddrmode_PVSDST(&(pAsm->D.dst), ADDR_ABSOLUTE);
+        pAsm->D.dst.rtype = DST_REG_TEMPORARY;
+        pAsm->D.dst.reg   = tmp;
+
+        nomask_PVSDST(&(pAsm->D.dst));
+    }
+    else 
+    {
+        if( GL_FALSE == assemble_dst(pAsm) )
+        {
+            return GL_FALSE;
+        }
+    }
+
+       if( GL_FALSE == assemble_src(pAsm, 0, -1) )
+    {
+        return GL_FALSE;
+    }
+              
+    if( GL_FALSE == assemble_src(pAsm, 1, -1) )  
+    {
+        return GL_FALSE;
+    }
+
+    if( GL_FALSE == assemble_src(pAsm, 2, -1) ) 
+    {
+        return GL_FALSE;
+    }
+
+    if ( GL_FALSE == next_ins(pAsm) )
+    {
+        return GL_FALSE;
+    }
+
+       if (GL_TRUE == bReplaceDst) 
+    {
+        if( GL_FALSE == assemble_dst(pAsm) )
+        {
+            return GL_FALSE;
+        }
+
+        pAsm->D.dst.opcode = SQ_OP2_INST_MOV;
+
+        //tmp for source
+        setaddrmode_PVSSRC(&(pAsm->S[0].src), ADDR_ABSOLUTE);
+        pAsm->S[0].src.rtype = SRC_REG_TEMPORARY;
+        pAsm->S[0].src.reg   = tmp;
+
+        noneg_PVSSRC(&(pAsm->S[0].src));
+        noswizzle_PVSSRC(&(pAsm->S[0].src));
+
+        if( GL_FALSE == next_ins(pAsm) )
+        {
+            return GL_FALSE;
+        }
+    }
+
+    return GL_TRUE;
+}
+
+/* LIT dst, src */
+GLboolean assemble_LIT(r700_AssemblerBase *pAsm)
+{
+    unsigned int dstReg;
+    unsigned int dstType;
+    unsigned int srcReg;
+    unsigned int srcType;
+    checkop1(pAsm);
+    int tmp = gethelpr(pAsm);
+
+    if( GL_FALSE == assemble_dst(pAsm) )
+    {
+        return GL_FALSE;
+    }
+    if( GL_FALSE == assemble_src(pAsm, 0, -1) )
+    {
+        return GL_FALSE;
+    }
+    dstReg  = pAsm->D.dst.reg;
+    dstType = pAsm->D.dst.rtype;
+    srcReg  = pAsm->S[0].src.reg;
     srcType = pAsm->S[0].src.rtype;
 
     /* dst.xw, <- 1.0  */
@@ -3035,6 +3671,7 @@ GLboolean assemble_LIT(r700_AssemblerBase *pAsm)
     pAsm->S[0].src.rtype = srcType;
     pAsm->S[0].src.reg   = srcReg;
     setaddrmode_PVSSRC(&(pAsm->S[0].src), ADDR_ABSOLUTE);
+    swizzleagain_PVSSRC(&(pAsm->S[0].src), SQ_SEL_X, SQ_SEL_X, SQ_SEL_X, SQ_SEL_X);
     pAsm->S[1].src.rtype = SRC_REG_TEMPORARY;
     pAsm->S[1].src.reg   = tmp;
     setaddrmode_PVSSRC(&(pAsm->S[1].src), ADDR_ABSOLUTE);
@@ -3371,77 +4008,137 @@ GLboolean assemble_RSQ(r700_AssemblerBase *pAsm)
     return assemble_math_function(pAsm, SQ_OP2_INST_RECIPSQRT_IEEE);
 }
  
-GLboolean assemble_SIN(r700_AssemblerBase *pAsm) 
-{
-    return assemble_math_function(pAsm, SQ_OP2_INST_SIN);
-}
 GLboolean assemble_SCS(r700_AssemblerBase *pAsm) 
 {
     BITS tmp;
 
-       checkop1(pAsm);
+    checkop1(pAsm);
 
-       tmp = gethelpr(pAsm);
+    tmp = gethelpr(pAsm);
+    /* tmp.x = src /2*PI */
+    pAsm->D.dst.opcode = SQ_OP2_INST_MUL;
+    setaddrmode_PVSDST(&(pAsm->D.dst), ADDR_ABSOLUTE);
+    pAsm->D.dst.rtype  = DST_REG_TEMPORARY;
+    pAsm->D.dst.reg    = tmp;
+    pAsm->D.dst.writex = 1;
 
-       // COS tmp.x,    a.x
-       pAsm->D.dst.opcode = SQ_OP2_INST_COS;
-       pAsm->D.dst.math = 1;
+    assemble_src(pAsm, 0, -1);
 
-       setaddrmode_PVSDST(&(pAsm->D.dst), ADDR_ABSOLUTE);
-       pAsm->D.dst.rtype = DST_REG_TEMPORARY;
-       pAsm->D.dst.reg = tmp;
-       pAsm->D.dst.writex = 1;
+    pAsm->S[1].src.rtype = SRC_REC_LITERAL;
+    setswizzle_PVSSRC(&(pAsm->S[1].src), SQ_SEL_X);
+    pAsm->D2.dst2.literal_slots = 1;
+    pAsm->C[0].f = 1/(3.1415926535 * 2);
+    pAsm->C[1].f = 0.0F;
 
-       if( GL_FALSE == assemble_src(pAsm, 0, -1) )
-       {
-               return GL_FALSE;
-       }
+    next_ins(pAsm);
 
-       if ( GL_FALSE == next_ins(pAsm) )
-       {
-               return GL_FALSE;
-       }
+    // COS dst.x,    a.x
+    pAsm->D.dst.opcode = SQ_OP2_INST_COS;
+    pAsm->D.dst.math = 1;
 
-       // SIN tmp.y,    a.x
-       pAsm->D.dst.opcode = SQ_OP2_INST_SIN;
-       pAsm->D.dst.math = 1;
+    assemble_dst(pAsm);
+    /* mask y */
+    pAsm->D.dst.writey = 0;
 
-       setaddrmode_PVSDST(&(pAsm->D.dst), ADDR_ABSOLUTE);
-       pAsm->D.dst.rtype = DST_REG_TEMPORARY;
-       pAsm->D.dst.reg = tmp;
-       pAsm->D.dst.writey = 1;
+    setaddrmode_PVSSRC(&(pAsm->S[0].src), ADDR_ABSOLUTE);
+    pAsm->S[0].src.rtype = SRC_REG_TEMPORARY;
+    pAsm->S[0].src.reg   = tmp;
+    setswizzle_PVSSRC(&(pAsm->S[0].src), SQ_SEL_X);
+    noneg_PVSSRC(&(pAsm->S[0].src));
 
-       if( GL_FALSE == assemble_src(pAsm, 0, -1) )
-       {
-               return GL_FALSE;
-       }
+    if ( GL_FALSE == next_ins(pAsm) )
+    {
+        return GL_FALSE;
+    }
 
-       if( GL_FALSE == next_ins(pAsm) )
-       {
-               return GL_FALSE;
-       }
+    // SIN dst.y,    a.x
+    pAsm->D.dst.opcode = SQ_OP2_INST_SIN;
+    pAsm->D.dst.math = 1;
 
-       // MOV dst.mask,     tmp
-       pAsm->D.dst.opcode = SQ_OP2_INST_MOV;
+    assemble_dst(pAsm);
+    /* mask x */
+    pAsm->D.dst.writex = 0;
 
-       if( GL_FALSE == assemble_dst(pAsm) )
-       {
-               return GL_FALSE;
-       }
+    setaddrmode_PVSSRC(&(pAsm->S[0].src), ADDR_ABSOLUTE);
+    pAsm->S[0].src.rtype = SRC_REG_TEMPORARY;
+    pAsm->S[0].src.reg   = tmp;
+    setswizzle_PVSSRC(&(pAsm->S[0].src), SQ_SEL_X);
+    noneg_PVSSRC(&(pAsm->S[0].src));
 
-       setaddrmode_PVSSRC(&(pAsm->S[0].src), ADDR_ABSOLUTE);
-       pAsm->S[0].src.rtype = DST_REG_TEMPORARY;
-       pAsm->S[0].src.reg = tmp;
+    if( GL_FALSE == next_ins(pAsm) )
+    {
+        return GL_FALSE;
+    }
 
-       noswizzle_PVSSRC(&(pAsm->S[0].src));
-       pAsm->S[0].src.swizzlez = SQ_SEL_0;
-       pAsm->S[0].src.swizzlew = SQ_SEL_0;
+    return GL_TRUE;
+}
 
-       if ( GL_FALSE == next_ins(pAsm) )
-       {
-               return GL_FALSE;
-       }
+GLboolean assemble_LOGIC(r700_AssemblerBase *pAsm, BITS opcode) 
+{
+    if( GL_FALSE == checkop2(pAsm) )
+    {
+           return GL_FALSE;
+    }
+
+    pAsm->D.dst.opcode = opcode;
+    //pAsm->D.dst.math   = 1;
+
+    if( GL_FALSE == assemble_dst(pAsm) )
+    {
+           return GL_FALSE;
+    }
+
+    if( GL_FALSE == assemble_src(pAsm, 0, -1) )
+    {
+           return GL_FALSE;
+    }
+
+    if( GL_FALSE == assemble_src(pAsm, 1, -1) )
+    {
+           return GL_FALSE;
+    }
+
+    if( GL_FALSE == next_ins(pAsm) ) 
+    {
+           return GL_FALSE;
+    }
+
+    return GL_TRUE;
+}
+
+GLboolean assemble_LOGIC_PRED(r700_AssemblerBase *pAsm, BITS opcode) 
+{
+    struct prog_instruction *pILInst = &(pAsm->pILInst[pAsm->uiCurInst]);
+
+    pAsm->D.dst.opcode = opcode;
+    pAsm->D.dst.math   = 1;
+    pAsm->D.dst.predicated = 1;
+
+    setaddrmode_PVSDST(&(pAsm->D.dst), ADDR_ABSOLUTE);
+    pAsm->D.dst.rtype = DST_REG_TEMPORARY;
+    pAsm->D.dst.reg = pAsm->uHelpReg;
+    pAsm->D.dst.writex = 1;
+    pAsm->D.dst.writey = pAsm->D.dst.writez = pAsm->D.dst.writew = 0;
+
+    setaddrmode_PVSSRC(&(pAsm->S[0].src), ADDR_ABSOLUTE);
+    pAsm->S[0].src.rtype = SRC_REG_TEMPORARY;
+    pAsm->S[0].src.reg = pAsm->last_cond_register + pAsm->starting_temp_register_number;
+    pAsm->S[0].src.swizzlex = pILInst->DstReg.CondSwizzle & 0x7;
+    noneg_PVSSRC(&(pAsm->S[0].src));
+
+    pAsm->S[1].src.rtype = SRC_REG_TEMPORARY;
+    pAsm->S[1].src.reg   = pAsm->uHelpReg;
+    setaddrmode_PVSSRC(&(pAsm->S[1].src), ADDR_ABSOLUTE);
+    noneg_PVSSRC(&(pAsm->S[1].src));
+    pAsm->S[1].src.swizzlex = SQ_SEL_0;
+    pAsm->S[1].src.swizzley = SQ_SEL_0;
+    pAsm->S[1].src.swizzlez = SQ_SEL_0;
+    pAsm->S[1].src.swizzlew = SQ_SEL_0;
+
+    if( GL_FALSE == next_ins(pAsm) ) 
+    {
+           return GL_FALSE;
+    }
 
     return GL_TRUE;
 }
@@ -3524,6 +4221,7 @@ GLboolean assemble_TEX(r700_AssemblerBase *pAsm)
     
     switch (pAsm->pILInst[pAsm->uiCurInst].SrcReg[0].File)
     {
+    case PROGRAM_UNIFORM: 
     case PROGRAM_CONSTANT:
     case PROGRAM_LOCAL_PARAM:
     case PROGRAM_ENV_PARAM:
@@ -3544,22 +4242,6 @@ GLboolean assemble_TEX(r700_AssemblerBase *pAsm)
            need_barrier = GL_TRUE;
     }
 
-    switch (pAsm->pILInst[pAsm->uiCurInst].Opcode)
-    {
-        case OPCODE_TEX:
-            break;
-        case OPCODE_TXB:
-            radeon_error("do not support TXB yet\n");
-            return GL_FALSE;
-            break;
-        case OPCODE_TXP:
-            break;
-        default:
-            radeon_error("Internal error: bad texture op (not TEX)\n");
-            return GL_FALSE;
-            break;
-    }
-
     if (pAsm->pILInst[pAsm->uiCurInst].Opcode == OPCODE_TXP)
     {
         GLuint tmp = gethelpr(pAsm);
@@ -3637,24 +4319,6 @@ GLboolean assemble_TEX(r700_AssemblerBase *pAsm)
             return GL_FALSE;
         }
  
-        /* tmp1.z = ABS(tmp1.z) dont have abs support in assembler currently
-         * have to do explicit instruction
-         */
-        pAsm->D.dst.opcode = SQ_OP2_INST_MAX;
-        setaddrmode_PVSDST(&(pAsm->D.dst), ADDR_ABSOLUTE);
-        pAsm->D.dst.rtype = DST_REG_TEMPORARY;
-        pAsm->D.dst.reg   = tmp1;
-        pAsm->D.dst.writez = 1;
-
-        setaddrmode_PVSSRC(&(pAsm->S[0].src), ADDR_ABSOLUTE);
-        pAsm->S[0].src.rtype = SRC_REG_TEMPORARY;
-        pAsm->S[0].src.reg = tmp1;
-       noswizzle_PVSSRC(&(pAsm->S[0].src));
-        pAsm->S[1].bits = pAsm->S[0].bits;
-        flipneg_PVSSRC(&(pAsm->S[1].src));
-        
-        next_ins(pAsm);
-
         /* tmp1.z = RCP_e(|tmp1.z|) */
         pAsm->D.dst.opcode = SQ_OP2_INST_RECIP_IEEE;
         pAsm->D.dst.math = 1;
@@ -3667,13 +4331,13 @@ GLboolean assemble_TEX(r700_AssemblerBase *pAsm)
         pAsm->S[0].src.rtype = SRC_REG_TEMPORARY;
         pAsm->S[0].src.reg = tmp1;
         pAsm->S[0].src.swizzlex = SQ_SEL_Z;
+        pAsm->S[0].src.abs = 1;
 
         next_ins(pAsm);
 
         /* MULADD R0.x,  R0.x,  PS1,  (0x3FC00000, 1.5f).x
          * MULADD R0.y,  R0.y,  PS1,  (0x3FC00000, 1.5f).x
          * muladd has no writemask, have to use another temp 
-         * also no support for imm constants, so add 1 here
          */
         pAsm->D.dst.opcode = SQ_OP3_INST_MULADD;
         pAsm->D.dst.op3    = 1;
@@ -3690,30 +4354,12 @@ GLboolean assemble_TEX(r700_AssemblerBase *pAsm)
         pAsm->S[1].src.reg   = tmp1;
         setswizzle_PVSSRC(&(pAsm->S[1].src), SQ_SEL_Z);
         setaddrmode_PVSSRC(&(pAsm->S[2].src), ADDR_ABSOLUTE);
-        pAsm->S[2].src.rtype = SRC_REG_TEMPORARY;
+        /* immediate c 1.5 */
+        pAsm->D2.dst2.literal_slots = 1;
+        pAsm->C[0].f = 1.5F;
+        pAsm->S[2].src.rtype = SRC_REC_LITERAL;
         pAsm->S[2].src.reg   = tmp1;
-        setswizzle_PVSSRC(&(pAsm->S[2].src), SQ_SEL_1);
-
-        next_ins(pAsm);
-
-        /* ADD the remaining .5 */
-        pAsm->D.dst.opcode = SQ_OP2_INST_ADD;
-        setaddrmode_PVSDST(&(pAsm->D.dst), ADDR_ABSOLUTE);
-        pAsm->D.dst.rtype = DST_REG_TEMPORARY;
-        pAsm->D.dst.reg   = tmp2;
-        pAsm->D.dst.writex = 1;
-        pAsm->D.dst.writey = 1;
-        pAsm->D.dst.writez = 0;
-        pAsm->D.dst.writew = 0;
-
-        setaddrmode_PVSSRC(&(pAsm->S[0].src), ADDR_ABSOLUTE);
-        pAsm->S[0].src.rtype = SRC_REG_TEMPORARY;
-        pAsm->S[0].src.reg   = tmp2;
-        noswizzle_PVSSRC(&(pAsm->S[0].src));
-        setaddrmode_PVSSRC(&(pAsm->S[1].src), ADDR_ABSOLUTE);
-        pAsm->S[1].src.rtype = SRC_REG_TEMPORARY;
-        pAsm->S[1].src.reg   = 252; // SQ_ALU_SRC_0_5 
-        noswizzle_PVSSRC(&(pAsm->S[1].src));
+        setswizzle_PVSSRC(&(pAsm->S[2].src), SQ_SEL_X);
 
         next_ins(pAsm);
 
@@ -3738,14 +4384,35 @@ GLboolean assemble_TEX(r700_AssemblerBase *pAsm)
 
     }
 
-    pAsm->D.dst.opcode = SQ_TEX_INST_SAMPLE;
+    switch(pAsm->pILInst[pAsm->uiCurInst].Opcode)
+    {
+        case OPCODE_DDX:
+            /* will these need WQM(1) on CF inst ? */
+            pAsm->D.dst.opcode = SQ_TEX_INST_GET_GRADIENTS_H;
+            break;
+        case OPCODE_DDY:
+            pAsm->D.dst.opcode = SQ_TEX_INST_GET_GRADIENTS_V;
+            break;
+        case OPCODE_TXB:
+            pAsm->D.dst.opcode = SQ_TEX_INST_SAMPLE_L;
+            break;
+        default:
+            if(pAsm->pILInst[pAsm->uiCurInst].TexShadow == 1)
+                pAsm->D.dst.opcode = SQ_TEX_INST_SAMPLE_C;
+            else
+                pAsm->D.dst.opcode = SQ_TEX_INST_SAMPLE;
+    }
+
+    pAsm->is_tex = GL_TRUE;
+    if ( GL_TRUE == need_barrier )
+
     pAsm->is_tex = GL_TRUE;
     if ( GL_TRUE == need_barrier )
     {
         pAsm->need_tex_barrier = GL_TRUE;
     }
     // Set src1 to tex unit id
-    pAsm->S[1].src.reg   = pAsm->pILInst[pAsm->uiCurInst].TexSrcUnit;
+    pAsm->S[1].src.reg   = pAsm->SamplerUnits[pAsm->pILInst[pAsm->uiCurInst].TexSrcUnit];
     pAsm->S[1].src.rtype = SRC_REG_TEMPORARY;
 
     //No sw info from mesa compiler, so hard code here.
@@ -3754,175 +4421,1092 @@ GLboolean assemble_TEX(r700_AssemblerBase *pAsm)
     pAsm->S[1].src.swizzlez = SQ_SEL_Z;
     pAsm->S[1].src.swizzlew = SQ_SEL_W;
 
-    if( GL_FALSE == tex_dst(pAsm) )
+    if( GL_FALSE == tex_dst(pAsm) )
+    {
+        return GL_FALSE;
+    }
+
+    if( GL_FALSE == tex_src(pAsm) )
+    {
+        return GL_FALSE;
+    }
+
+    if(pAsm->pILInst[pAsm->uiCurInst].Opcode == OPCODE_TXP)
+    {
+        /* hopefully did swizzles before */
+        noswizzle_PVSSRC(&(pAsm->S[0].src));
+    }
+   
+    if(pAsm->pILInst[pAsm->uiCurInst].TexSrcTarget == TEXTURE_CUBE_INDEX)
+    {
+        /* SAMPLE dst, tmp.yxwy, CUBE */
+        pAsm->S[0].src.swizzlex = SQ_SEL_Y;
+        pAsm->S[0].src.swizzley = SQ_SEL_X;
+        pAsm->S[0].src.swizzlez = SQ_SEL_W;
+        pAsm->S[0].src.swizzlew = SQ_SEL_Y;
+    }
+    if(pAsm->pILInst[pAsm->uiCurInst].TexShadow == 1)
+    {
+        /* compare value goes to w chan ? */
+        pAsm->S[0].src.swizzlew = SQ_SEL_Z;
+    }
+
+    if ( GL_FALSE == next_ins(pAsm) )
+        {
+            return GL_FALSE;
+        }
+
+    /* add ARB shadow ambient but clamp to 0..1 */
+    if(pAsm->pILInst[pAsm->uiCurInst].TexShadow == 1)
+    {
+       /* ADD_SAT dst,  dst,  ambient[texunit] */
+       pAsm->D.dst.opcode = SQ_OP2_INST_ADD;
+
+       if( GL_FALSE == assemble_dst(pAsm) )
+       {
+           return GL_FALSE;
+       }
+       pAsm->D2.dst2.SaturateMode = 1;
+
+       pAsm->S[0].src.rtype = pAsm->D.dst.rtype;
+       pAsm->S[0].src.reg = pAsm->D.dst.reg;
+       noswizzle_PVSSRC(&(pAsm->S[0].src));
+       noneg_PVSSRC(&(pAsm->S[0].src));
+
+       pAsm->S[1].src.rtype = SRC_REG_CONSTANT;
+       pAsm->S[1].src.reg = pAsm->shadow_regs[pAsm->pILInst[pAsm->uiCurInst].TexSrcUnit];
+       noswizzle_PVSSRC(&(pAsm->S[1].src));
+       noneg_PVSSRC(&(pAsm->S[1].src));
+
+       if( GL_FALSE == next_ins(pAsm) )
+       {
+           return GL_FALSE;
+       }
+
+    }
+
+    return GL_TRUE;
+}
+
+GLboolean assemble_XPD(r700_AssemblerBase *pAsm) 
+{
+    BITS tmp;
+
+    if( GL_FALSE == checkop2(pAsm) )
+    {
+           return GL_FALSE;
+    }
+
+    tmp = gethelpr(pAsm);
+
+    pAsm->D.dst.opcode = SQ_OP2_INST_MUL;
+
+    setaddrmode_PVSDST(&(pAsm->D.dst), ADDR_ABSOLUTE);
+    pAsm->D.dst.rtype = DST_REG_TEMPORARY;
+    pAsm->D.dst.reg   = tmp;
+    nomask_PVSDST(&(pAsm->D.dst));
+  
+    if( GL_FALSE == assemble_src(pAsm, 0, -1) )
+    {
+        return GL_FALSE;
+    }
+
+    if( GL_FALSE == assemble_src(pAsm, 1, -1) )
+    {
+        return GL_FALSE;
+    }
+    swizzleagain_PVSSRC(&(pAsm->S[0].src), SQ_SEL_Z, SQ_SEL_X, SQ_SEL_Y, SQ_SEL_0);
+    swizzleagain_PVSSRC(&(pAsm->S[1].src), SQ_SEL_Y, SQ_SEL_Z, SQ_SEL_X, SQ_SEL_0);
+
+    if( GL_FALSE == next_ins(pAsm) ) 
+    {
+        return GL_FALSE;
+    }
+
+    pAsm->D.dst.opcode = SQ_OP3_INST_MULADD;
+    pAsm->D.dst.op3    = 1;
+
+    if(0xF != pAsm->pILInst[pAsm->uiCurInst].DstReg.WriteMask)
+    {
+        tmp = gethelpr(pAsm);
+
+        setaddrmode_PVSDST(&(pAsm->D.dst), ADDR_ABSOLUTE);
+        pAsm->D.dst.rtype = DST_REG_TEMPORARY;
+        pAsm->D.dst.reg   = tmp;
+
+        nomask_PVSDST(&(pAsm->D.dst));
+    }
+    else 
+    {
+        if( GL_FALSE == assemble_dst(pAsm) )
+        {
+            return GL_FALSE;
+        }
+    }
+
+    if( GL_FALSE == assemble_src(pAsm, 0, -1) )
+    {
+        return GL_FALSE;
+    }
+
+    if( GL_FALSE == assemble_src(pAsm, 1, -1) )
+    {
+        return GL_FALSE;
+    }
+    swizzleagain_PVSSRC(&(pAsm->S[0].src), SQ_SEL_Y, SQ_SEL_Z, SQ_SEL_X, SQ_SEL_0);
+    swizzleagain_PVSSRC(&(pAsm->S[1].src), SQ_SEL_Z, SQ_SEL_X, SQ_SEL_Y, SQ_SEL_0);
+
+    // result1 + (neg) result0
+    setaddrmode_PVSSRC(&(pAsm->S[2].src),ADDR_ABSOLUTE);
+    pAsm->S[2].src.rtype = SRC_REG_TEMPORARY;
+    pAsm->S[2].src.reg   = tmp;
+
+    neg_PVSSRC(&(pAsm->S[2].src));
+    noswizzle_PVSSRC(&(pAsm->S[2].src));
+
+    if( GL_FALSE == next_ins(pAsm) ) 
+    {
+        return GL_FALSE;
+    }
+
+
+    if(0xF != pAsm->pILInst[pAsm->uiCurInst].DstReg.WriteMask) 
+    {
+        if( GL_FALSE == assemble_dst(pAsm) )
+        {
+            return GL_FALSE;
+        }
+
+        pAsm->D.dst.opcode = SQ_OP2_INST_MOV;
+
+        // Use tmp as source
+        setaddrmode_PVSSRC(&(pAsm->S[0].src), ADDR_ABSOLUTE);
+        pAsm->S[0].src.rtype = SRC_REG_TEMPORARY;
+        pAsm->S[0].src.reg   = tmp;
+
+        noneg_PVSSRC(&(pAsm->S[0].src));
+        noswizzle_PVSSRC(&(pAsm->S[0].src));
+
+        if( GL_FALSE == next_ins(pAsm) )
+        {
+            return GL_FALSE;
+        }
+    }
+
+    return GL_TRUE;
+}
+
+GLboolean assemble_EXPORT(r700_AssemblerBase *pAsm)
+{
+    return GL_TRUE;
+}
+
+static inline void decreaseCurrent(r700_AssemblerBase *pAsm, GLuint uReason)
+{
+    switch (uReason)
+    {
+    case FC_PUSH_VPM:
+        pAsm->CALLSTACK[pAsm->CALLSP].current--;
+        break;
+    case FC_PUSH_WQM:
+        pAsm->CALLSTACK[pAsm->CALLSP].current -= 4;
+        break;
+    case FC_LOOP:
+        pAsm->CALLSTACK[pAsm->CALLSP].current -= 4;
+        break;
+    case FC_REP:
+        /* TODO : for 16 vp asic, should -= 2; */
+        pAsm->CALLSTACK[pAsm->CALLSP].current -= 1;
+        break;
+    };
+}
+
+static inline void checkStackDepth(r700_AssemblerBase *pAsm, GLuint uReason, GLboolean bCheckMaxOnly)
+{
+    if(GL_TRUE == bCheckMaxOnly)
+    {
+        switch (uReason)
+        {
+        case FC_PUSH_VPM:
+            if((pAsm->CALLSTACK[pAsm->CALLSP].current + 1)
+                    > pAsm->CALLSTACK[pAsm->CALLSP].max)
+            {
+                pAsm->CALLSTACK[pAsm->CALLSP].max =
+                    pAsm->CALLSTACK[pAsm->CALLSP].current + 1;
+            }
+            break;
+        case FC_PUSH_WQM:
+            if((pAsm->CALLSTACK[pAsm->CALLSP].current + 4)
+                    > pAsm->CALLSTACK[pAsm->CALLSP].max)
+            {
+                pAsm->CALLSTACK[pAsm->CALLSP].max =
+                    pAsm->CALLSTACK[pAsm->CALLSP].current + 4;
+            }
+            break;
+        }
+        return;
+    }
+
+    switch (uReason)
+    {
+    case FC_PUSH_VPM:
+        pAsm->CALLSTACK[pAsm->CALLSP].current++;
+        break;
+    case FC_PUSH_WQM:
+        pAsm->CALLSTACK[pAsm->CALLSP].current += 4;
+        break;
+    case FC_LOOP:
+        pAsm->CALLSTACK[pAsm->CALLSP].current += 4;
+        break;
+    case FC_REP:
+        /* TODO : for 16 vp asic, should += 2; */
+        pAsm->CALLSTACK[pAsm->CALLSP].current += 1;
+        break;
+    };
+
+    if(pAsm->CALLSTACK[pAsm->CALLSP].current
+         > pAsm->CALLSTACK[pAsm->CALLSP].max)
+    {
+        pAsm->CALLSTACK[pAsm->CALLSP].max =
+            pAsm->CALLSTACK[pAsm->CALLSP].current;
+    }
+}
+
+GLboolean jumpToOffest(r700_AssemblerBase *pAsm, GLuint pops, GLint offset)
+{
+    if(GL_FALSE == add_cf_instruction(pAsm) )
+    {
+        return GL_FALSE;
+    }
+
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.pop_count        = pops;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cf_const         = 0x0;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cond             = SQ_CF_COND_ACTIVE;
+
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.end_of_program   = 0x0;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.valid_pixel_mode = 0x0;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cf_inst          = SQ_CF_INST_JUMP;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.whole_quad_mode  = 0x0;
+
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.barrier          = 0x1;
+
+    pAsm->cf_current_cf_clause_ptr->m_Word0.f.addr = pAsm->cf_current_cf_clause_ptr->m_uIndex + offset;
+
+    return GL_TRUE;
+}
+
+GLboolean pops(r700_AssemblerBase *pAsm, GLuint pops)
+{
+    if(GL_FALSE == add_cf_instruction(pAsm) )
+    {
+        return GL_FALSE;
+    }
+
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.pop_count        = pops;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cf_const         = 0x0; 
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cond             = SQ_CF_COND_ACTIVE;
+
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.end_of_program   = 0x0;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.valid_pixel_mode = 0x0; 
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cf_inst          = SQ_CF_INST_POP;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.whole_quad_mode  = 0x0;
+
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.barrier          = 0x1;
+    pAsm->cf_current_cf_clause_ptr->m_Word0.f.addr             = pAsm->cf_current_cf_clause_ptr->m_uIndex + 1;
+
+    return GL_TRUE;
+}
+
+GLboolean assemble_IF(r700_AssemblerBase *pAsm, GLboolean bHasElse)
+{
+    pAsm->alu_x_opcode = SQ_CF_INST_ALU_PUSH_BEFORE;
+
+    assemble_LOGIC_PRED(pAsm, SQ_OP2_INST_PRED_SETNE);
+
+
+    if(GL_FALSE == add_cf_instruction(pAsm) )
+    {
+        return GL_FALSE;
+    }
+
+    if(GL_TRUE != bHasElse)
+    {
+        pAsm->cf_current_cf_clause_ptr->m_Word1.f.pop_count = 1; 
+    }
+    else
+    {
+        pAsm->cf_current_cf_clause_ptr->m_Word1.f.pop_count = 0;
+    }
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cf_const         = 0x0;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cond             = SQ_CF_COND_ACTIVE;
+
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.end_of_program   = 0x0;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.valid_pixel_mode = 0x0;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cf_inst          = SQ_CF_INST_JUMP;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.whole_quad_mode  = 0x0;
+
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.barrier          = 0x1;
+
+    pAsm->FCSP++;
+       pAsm->fc_stack[pAsm->FCSP].type  = FC_IF;
+    pAsm->fc_stack[pAsm->FCSP].mid   = NULL;
+    pAsm->fc_stack[pAsm->FCSP].midLen= 0;
+    pAsm->fc_stack[pAsm->FCSP].first = pAsm->cf_current_cf_clause_ptr;
+
+#ifndef USE_CF_FOR_POP_AFTER
+    if(GL_TRUE != bHasElse)
+    {
+        pAsm->alu_x_opcode = SQ_CF_INST_ALU_POP_AFTER;
+    }
+#endif /* USE_CF_FOR_POP_AFTER */
+
+    checkStackDepth(pAsm, FC_PUSH_VPM, GL_FALSE); 
+
+    return GL_TRUE;
+}
+
+GLboolean assemble_ELSE(r700_AssemblerBase *pAsm)
+{
+    if(GL_FALSE == add_cf_instruction(pAsm) )
+    {
+        return GL_FALSE;
+    }
+
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.pop_count        = 1; ///
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cf_const         = 0x0;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cond             = SQ_CF_COND_ACTIVE;
+
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.end_of_program   = 0x0;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.valid_pixel_mode = 0x0;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cf_inst          = SQ_CF_INST_ELSE;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.whole_quad_mode  = 0x0;
+
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.barrier          = 0x1;
+
+    pAsm->fc_stack[pAsm->FCSP].mid = (R700ControlFlowGenericClause **)_mesa_realloc( (void *)pAsm->fc_stack[pAsm->FCSP].mid,
+                                                                                     0,
+                                                                                     sizeof(R700ControlFlowGenericClause *) );
+    pAsm->fc_stack[pAsm->FCSP].mid[0] = pAsm->cf_current_cf_clause_ptr;
+    //pAsm->fc_stack[pAsm->FCSP].unNumMid = 1;
+
+#ifndef USE_CF_FOR_POP_AFTER
+    pAsm->alu_x_opcode = SQ_CF_INST_ALU_POP_AFTER;
+#endif /* USE_CF_FOR_POP_AFTER */
+
+    pAsm->fc_stack[pAsm->FCSP].first->m_Word0.f.addr = pAsm->pR700Shader->plstCFInstructions_active->uNumOfNode - 1; 
+
+    return GL_TRUE;
+}
+
+GLboolean assemble_ENDIF(r700_AssemblerBase *pAsm)
+{
+#ifdef USE_CF_FOR_POP_AFTER
+    pops(pAsm, 1); 
+#endif /* USE_CF_FOR_POP_AFTER */
+
+    pAsm->alu_x_opcode = SQ_CF_INST_ALU;
+
+    if(NULL == pAsm->fc_stack[pAsm->FCSP].mid)
+    {
+        /* no else in between */
+        pAsm->fc_stack[pAsm->FCSP].first->m_Word0.f.addr = pAsm->pR700Shader->plstCFInstructions_active->uNumOfNode;
+    }
+    else
+    {
+        pAsm->fc_stack[pAsm->FCSP].mid[0]->m_Word0.f.addr = pAsm->pR700Shader->plstCFInstructions_active->uNumOfNode;
+    }
+
+    if(NULL != pAsm->fc_stack[pAsm->FCSP].mid)
+    {
+        FREE(pAsm->fc_stack[pAsm->FCSP].mid);
+    }
+
+    if(pAsm->fc_stack[pAsm->FCSP].type != FC_IF)
+    {
+        radeon_error("if/endif in shader code are not paired. \n");
+        return GL_FALSE;
+    }
+    
+    pAsm->FCSP--;
+
+    decreaseCurrent(pAsm, FC_PUSH_VPM);
+
+    return GL_TRUE;
+}
+
+GLboolean assemble_BGNLOOP(r700_AssemblerBase *pAsm)
+{
+    if(GL_FALSE == add_cf_instruction(pAsm) )
+    {
+        return GL_FALSE;
+    }
+
+    
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.pop_count        = 0;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cf_const         = 0x0; 
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cond             = SQ_CF_COND_ACTIVE;
+
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.end_of_program   = 0x0;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.valid_pixel_mode = 0x0; 
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cf_inst          = SQ_CF_INST_LOOP_START_NO_AL;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.whole_quad_mode  = 0x0;
+
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.barrier          = 0x1;
+
+    pAsm->FCSP++;
+       pAsm->fc_stack[pAsm->FCSP].type  = FC_LOOP;
+    pAsm->fc_stack[pAsm->FCSP].mid   = NULL;
+    pAsm->fc_stack[pAsm->FCSP].unNumMid = 0;
+    pAsm->fc_stack[pAsm->FCSP].midLen   = 0;
+    pAsm->fc_stack[pAsm->FCSP].first    = pAsm->cf_current_cf_clause_ptr;
+
+    checkStackDepth(pAsm, FC_LOOP, GL_FALSE);
+
+    return GL_TRUE;
+}
+
+GLboolean assemble_BRK(r700_AssemblerBase *pAsm)
+{
+#ifdef USE_CF_FOR_CONTINUE_BREAK
+
+    pAsm->alu_x_opcode = SQ_CF_INST_ALU_PUSH_BEFORE;
+
+    assemble_LOGIC_PRED(pAsm, SQ_OP2_INST_PRED_SETNE);
+    
+    unsigned int unFCSP;
+    for(unFCSP=pAsm->FCSP; unFCSP>0; unFCSP--)
+    {
+        if(FC_LOOP == pAsm->fc_stack[unFCSP].type)
+        {
+            break;
+        }
+    }
+    if(0 == FC_LOOP)
+    {
+        radeon_error("Break is not inside loop/endloop pair.\n");
+        return GL_FALSE;
+    }
+
+    if(GL_FALSE == add_cf_instruction(pAsm) )
+    {
+        return GL_FALSE;
+    }
+
+    
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.pop_count        = 1;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cf_const         = 0x0; 
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cond             = SQ_CF_COND_ACTIVE;
+
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.end_of_program   = 0x0;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.valid_pixel_mode = 0x0; 
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cf_inst          = SQ_CF_INST_LOOP_BREAK;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.whole_quad_mode  = 0x0;
+
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.barrier          = 0x1;
+
+    pAsm->fc_stack[unFCSP].mid = (R700ControlFlowGenericClause **)_mesa_realloc( 
+                                              (void *)pAsm->fc_stack[unFCSP].mid,
+                                              sizeof(R700ControlFlowGenericClause *) * pAsm->fc_stack[unFCSP].unNumMid,
+                                              sizeof(R700ControlFlowGenericClause *) * (pAsm->fc_stack[unFCSP].unNumMid + 1) );
+    pAsm->fc_stack[unFCSP].mid[pAsm->fc_stack[unFCSP].unNumMid] = pAsm->cf_current_cf_clause_ptr;
+    pAsm->fc_stack[unFCSP].unNumMid++;
+
+    if(GL_FALSE == add_cf_instruction(pAsm) )
+    {
+        return GL_FALSE;
+    }
+
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.pop_count        = 1;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cf_const         = 0x0; 
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cond             = SQ_CF_COND_ACTIVE;
+
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.end_of_program   = 0x0;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.valid_pixel_mode = 0x0; 
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cf_inst          = SQ_CF_INST_POP;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.whole_quad_mode  = 0x0;
+
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.barrier          = 0x1;
+    pAsm->cf_current_cf_clause_ptr->m_Word0.f.addr             = pAsm->cf_current_cf_clause_ptr->m_uIndex + 1;
+
+    checkStackDepth(pAsm, FC_PUSH_VPM, GL_TRUE);
+
+#endif //USE_CF_FOR_CONTINUE_BREAK
+    return GL_TRUE;
+}
+
+GLboolean assemble_CONT(r700_AssemblerBase *pAsm)
+{
+#ifdef USE_CF_FOR_CONTINUE_BREAK
+    pAsm->alu_x_opcode = SQ_CF_INST_ALU_PUSH_BEFORE;
+
+    assemble_LOGIC_PRED(pAsm, SQ_OP2_INST_PRED_SETNE);
+
+    unsigned int unFCSP;
+    for(unFCSP=pAsm->FCSP; unFCSP>0; unFCSP--)
+    {
+        if(FC_LOOP == pAsm->fc_stack[unFCSP].type)
+        {
+            break;
+        }
+    }
+    if(0 == FC_LOOP)
+    {
+        radeon_error("Continue is not inside loop/endloop pair.\n");
+        return GL_FALSE;
+    }
+
+    if(GL_FALSE == add_cf_instruction(pAsm) )
+    {
+        return GL_FALSE;
+    }
+
+    
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.pop_count        = 1;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cf_const         = 0x0; 
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cond             = SQ_CF_COND_ACTIVE;
+
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.end_of_program   = 0x0;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.valid_pixel_mode = 0x0; 
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cf_inst          = SQ_CF_INST_LOOP_CONTINUE;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.whole_quad_mode  = 0x0;
+
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.barrier          = 0x1;
+
+    pAsm->fc_stack[unFCSP].mid = (R700ControlFlowGenericClause **)_mesa_realloc( 
+                                              (void *)pAsm->fc_stack[unFCSP].mid,
+                                              sizeof(R700ControlFlowGenericClause *) * pAsm->fc_stack[unFCSP].unNumMid,
+                                              sizeof(R700ControlFlowGenericClause *) * (pAsm->fc_stack[unFCSP].unNumMid + 1) );
+    pAsm->fc_stack[unFCSP].mid[pAsm->fc_stack[unFCSP].unNumMid] = pAsm->cf_current_cf_clause_ptr;
+    pAsm->fc_stack[unFCSP].unNumMid++;
+
+    if(GL_FALSE == add_cf_instruction(pAsm) )
+    {
+        return GL_FALSE;
+    }
+
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.pop_count        = 1;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cf_const         = 0x0; 
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cond             = SQ_CF_COND_ACTIVE;
+
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.end_of_program   = 0x0;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.valid_pixel_mode = 0x0; 
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cf_inst          = SQ_CF_INST_POP;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.whole_quad_mode  = 0x0;
+
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.barrier          = 0x1;
+    pAsm->cf_current_cf_clause_ptr->m_Word0.f.addr             = pAsm->cf_current_cf_clause_ptr->m_uIndex + 1;
+
+    checkStackDepth(pAsm, FC_PUSH_VPM, GL_TRUE);
+
+#endif /* USE_CF_FOR_CONTINUE_BREAK */
+
+    return GL_TRUE;
+}
+
+GLboolean assemble_ENDLOOP(r700_AssemblerBase *pAsm)
+{
+    GLuint i;
+
+    if(GL_FALSE == add_cf_instruction(pAsm) )
     {
         return GL_FALSE;
     }
 
-    if( GL_FALSE == tex_src(pAsm) )
+    
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.pop_count        = 0;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cf_const         = 0x0; 
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cond             = SQ_CF_COND_ACTIVE;
+
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.end_of_program   = 0x0;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.valid_pixel_mode = 0x0; 
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cf_inst          = SQ_CF_INST_LOOP_END;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.whole_quad_mode  = 0x0;
+
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.barrier          = 0x1;
+
+    pAsm->cf_current_cf_clause_ptr->m_Word0.f.addr   = pAsm->fc_stack[pAsm->FCSP].first->m_uIndex + 1;
+    pAsm->fc_stack[pAsm->FCSP].first->m_Word0.f.addr = pAsm->cf_current_cf_clause_ptr->m_uIndex + 1;
+
+#ifdef USE_CF_FOR_CONTINUE_BREAK
+    for(i=0; i<pAsm->fc_stack[pAsm->FCSP].unNumMid; i++)
     {
-        return GL_FALSE;
+        pAsm->fc_stack[pAsm->FCSP].mid[i]->m_Word0.f.addr = pAsm->cf_current_cf_clause_ptr->m_uIndex;
     }
-
-    if(pAsm->pILInst[pAsm->uiCurInst].Opcode == OPCODE_TXP)
+    if(NULL != pAsm->fc_stack[pAsm->FCSP].mid)
     {
-        /* hopefully did swizzles before */
-        noswizzle_PVSSRC(&(pAsm->S[0].src));
+        FREE(pAsm->fc_stack[pAsm->FCSP].mid);
     }
-   
-    if(pAsm->pILInst[pAsm->uiCurInst].TexSrcTarget == TEXTURE_CUBE_INDEX)
+#endif
+
+    if(pAsm->fc_stack[pAsm->FCSP].type != FC_LOOP)
     {
-        /* SAMPLE dst, tmp.yxwy, CUBE */
-        pAsm->S[0].src.swizzlex = SQ_SEL_Y;
-        pAsm->S[0].src.swizzley = SQ_SEL_X;
-        pAsm->S[0].src.swizzlez = SQ_SEL_W;
-        pAsm->S[0].src.swizzlew = SQ_SEL_Y;
+        radeon_error("loop/endloop in shader code are not paired. \n");
+        return GL_FALSE;
     }
-    if ( GL_FALSE == next_ins(pAsm) )
+
+    GLuint unFCSP;
+    GLuint unIF = 0;
+    if((pAsm->unCFflags & HAS_CURRENT_LOOPRET) > 0)
+    {        
+        for(unFCSP=(pAsm->FCSP-1); unFCSP>pAsm->CALLSTACK[pAsm->CALLSP].FCSP_BeforeEntry; unFCSP--)
         {
-            return GL_FALSE;
+            if(FC_LOOP == pAsm->fc_stack[unFCSP].type)
+            {
+                breakLoopOnFlag(pAsm, unFCSP);
+                break;
+            }
+            else if(FC_IF == pAsm->fc_stack[unFCSP].type)
+            {
+                unIF++;
+            }
         }
+        if(unFCSP <= pAsm->CALLSTACK[pAsm->CALLSP].FCSP_BeforeEntry)
+        {            
+#ifdef USE_CF_FOR_POP_AFTER
+            returnOnFlag(pAsm, unIF); 
+#else
+            returnOnFlag(pAsm, 0);
+#endif /* USE_CF_FOR_POP_AFTER */
+            pAsm->unCFflags &= ~HAS_CURRENT_LOOPRET;
+        }
+    }
+
+    pAsm->FCSP--;
 
+    decreaseCurrent(pAsm, FC_LOOP);
+    
     return GL_TRUE;
 }
 
-GLboolean assemble_XPD(r700_AssemblerBase *pAsm) 
+void add_return_inst(r700_AssemblerBase *pAsm)
 {
-    BITS tmp;
-
-    if( GL_FALSE == checkop2(pAsm) )
+    if(GL_FALSE == add_cf_instruction(pAsm) )
     {
-           return GL_FALSE;
+        return GL_FALSE;
     }
+    //pAsm->cf_current_cf_clause_ptr->m_Word1.f.pop_count        = 1;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.pop_count        = 0;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cf_const         = 0x0; 
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cond             = SQ_CF_COND_ACTIVE;
 
-    tmp = gethelpr(pAsm);
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.end_of_program   = 0x0;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.valid_pixel_mode = 0x0; 
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cf_inst          = SQ_CF_INST_RETURN;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.whole_quad_mode  = 0x0;
 
-    pAsm->D.dst.opcode = SQ_OP2_INST_MUL;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.barrier          = 0x1;
+}
 
-    setaddrmode_PVSDST(&(pAsm->D.dst), ADDR_ABSOLUTE);
-    pAsm->D.dst.rtype = DST_REG_TEMPORARY;
-    pAsm->D.dst.reg   = tmp;
-    nomask_PVSDST(&(pAsm->D.dst));
-  
-    if( GL_FALSE == assemble_src(pAsm, 0, -1) )
+GLboolean assemble_BGNSUB(r700_AssemblerBase *pAsm, GLint nILindex, GLuint uiIL_Shift)
+{
+    /* Put in sub */
+    if( (pAsm->unSubArrayPointer + 1) > pAsm->unSubArraySize )
     {
-        return GL_FALSE;
+        pAsm->subs = (SUB_OFFSET*)_mesa_realloc( (void *)pAsm->subs,
+                                  sizeof(SUB_OFFSET) * pAsm->unSubArraySize,
+                                  sizeof(SUB_OFFSET) * (pAsm->unSubArraySize + 10) );
+        if(NULL == pAsm->subs)
+        {
+            return GL_FALSE;
+        }
+        pAsm->unSubArraySize += 10;
     }
 
-    if( GL_FALSE == assemble_src(pAsm, 1, -1) )
-    {
-        return GL_FALSE;
-    }
-    swizzleagain_PVSSRC(&(pAsm->S[0].src), SQ_SEL_Z, SQ_SEL_X, SQ_SEL_Y, SQ_SEL_0);
-    swizzleagain_PVSSRC(&(pAsm->S[1].src), SQ_SEL_Y, SQ_SEL_Z, SQ_SEL_X, SQ_SEL_0);
+    pAsm->subs[pAsm->unSubArrayPointer].subIL_Offset = nILindex + uiIL_Shift;
+    pAsm->subs[pAsm->unSubArrayPointer].lstCFInstructions_local.pHead=NULL;  
+    pAsm->subs[pAsm->unSubArrayPointer].lstCFInstructions_local.pTail=NULL;  
+    pAsm->subs[pAsm->unSubArrayPointer].lstCFInstructions_local.uNumOfNode=0;
 
-    if( GL_FALSE == next_ins(pAsm) ) 
+    pAsm->CALLSP++;
+    pAsm->CALLSTACK[pAsm->CALLSP].subDescIndex = pAsm->unSubArrayPointer;
+    pAsm->CALLSTACK[pAsm->CALLSP].FCSP_BeforeEntry = pAsm->FCSP;
+    pAsm->CALLSTACK[pAsm->CALLSP].plstCFInstructions_local
+                   = &(pAsm->subs[pAsm->unSubArrayPointer].lstCFInstructions_local);
+    pAsm->CALLSTACK[pAsm->CALLSP].max = 0;
+    pAsm->CALLSTACK[pAsm->CALLSP].current = 0;
+    SetActiveCFlist(pAsm->pR700Shader, 
+                    pAsm->CALLSTACK[pAsm->CALLSP].plstCFInstructions_local);
+
+    pAsm->unSubArrayPointer++;
+
+    /* start sub */
+    pAsm->alu_x_opcode = SQ_CF_INST_ALU;
+
+    pAsm->FCSP++;
+    pAsm->fc_stack[pAsm->FCSP].type  = FC_REP;
+
+    checkStackDepth(pAsm, FC_REP, GL_FALSE);
+
+    return GL_TRUE;
+}
+
+GLboolean assemble_ENDSUB(r700_AssemblerBase *pAsm)
+{
+    if(pAsm->fc_stack[pAsm->FCSP].type != FC_REP)
     {
+        radeon_error("BGNSUB/ENDSUB in shader code are not paired. \n");
         return GL_FALSE;
     }
 
-    pAsm->D.dst.opcode = SQ_OP3_INST_MULADD;
-    pAsm->D.dst.op3    = 1;
+    /* copy max to sub structure */
+    pAsm->subs[pAsm->CALLSTACK[pAsm->CALLSP].subDescIndex].unStackDepthMax
+        = pAsm->CALLSTACK[pAsm->CALLSP].max;
 
-    if(0xF != pAsm->pILInst[pAsm->uiCurInst].DstReg.WriteMask)
-    {
-        tmp = gethelpr(pAsm);
+    decreaseCurrent(pAsm, FC_REP);
 
-        setaddrmode_PVSDST(&(pAsm->D.dst), ADDR_ABSOLUTE);
-        pAsm->D.dst.rtype = DST_REG_TEMPORARY;
-        pAsm->D.dst.reg   = tmp;
+    pAsm->CALLSP--;
+    SetActiveCFlist(pAsm->pR700Shader, 
+                    pAsm->CALLSTACK[pAsm->CALLSP].plstCFInstructions_local);
+    
+    pAsm->alu_x_opcode = SQ_CF_INST_ALU;
 
-        nomask_PVSDST(&(pAsm->D.dst));
-    }
-    else 
-    {
-        if( GL_FALSE == assemble_dst(pAsm) )
+    pAsm->FCSP--;
+
+    return GL_TRUE;
+}
+
+GLboolean assemble_RET(r700_AssemblerBase *pAsm)
+{
+    GLuint unIF = 0;
+
+    if(pAsm->CALLSP > 0)
+    {   /* in sub */
+        GLuint unFCSP;        
+        for(unFCSP=pAsm->FCSP; unFCSP>pAsm->CALLSTACK[pAsm->CALLSP].FCSP_BeforeEntry; unFCSP--)
         {
-            return GL_FALSE;
+            if(FC_LOOP == pAsm->fc_stack[unFCSP].type)
+            {
+                setRetInLoopFlag(pAsm, SQ_SEL_1);
+                breakLoopOnFlag(pAsm, unFCSP);
+                pAsm->unCFflags |= LOOPRET_FLAGS;
+
+                return GL_TRUE;
+            }
+            else if(FC_IF == pAsm->fc_stack[unFCSP].type)
+            {
+                unIF++;
+            }
         }
     }
 
-    if( GL_FALSE == assemble_src(pAsm, 0, -1) )
+#ifdef USE_CF_FOR_POP_AFTER    
+    if(unIF > 0)
     {
-        return GL_FALSE;
+        pops(pAsm, unIF);
     }
+#endif /* USE_CF_FOR_POP_AFTER */
 
-    if( GL_FALSE == assemble_src(pAsm, 1, -1) )
-    {
-        return GL_FALSE;
-    }
-    swizzleagain_PVSSRC(&(pAsm->S[0].src), SQ_SEL_Y, SQ_SEL_Z, SQ_SEL_X, SQ_SEL_0);
-    swizzleagain_PVSSRC(&(pAsm->S[1].src), SQ_SEL_Z, SQ_SEL_X, SQ_SEL_Y, SQ_SEL_0);
+    add_return_inst(pAsm);
 
-    // result1 + (neg) result0
-    setaddrmode_PVSSRC(&(pAsm->S[2].src),ADDR_ABSOLUTE);
-    pAsm->S[2].src.rtype = SRC_REG_TEMPORARY;
-    pAsm->S[2].src.reg   = tmp;
+    return GL_TRUE;
+}
 
-    neg_PVSSRC(&(pAsm->S[2].src));
-    noswizzle_PVSSRC(&(pAsm->S[2].src));
+GLboolean assemble_CAL(r700_AssemblerBase *pAsm, 
+                       GLint nILindex,
+                       GLuint uiIL_Shift,
+                       GLuint uiNumberInsts,
+                       struct prog_instruction *pILInst,
+                       PRESUB_DESC * pPresubDesc)
+{
+    GLint uiIL_Offset;
 
-    if( GL_FALSE == next_ins(pAsm) ) 
+    pAsm->alu_x_opcode = SQ_CF_INST_ALU;
+
+    if(GL_FALSE == add_cf_instruction(pAsm) )
     {
         return GL_FALSE;
     }
 
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.call_count       = 1;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.pop_count        = 0;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cf_const         = 0x0; 
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cond             = SQ_CF_COND_ACTIVE;
 
-    if(0xF != pAsm->pILInst[pAsm->uiCurInst].DstReg.WriteMask) 
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.end_of_program   = 0x0;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.valid_pixel_mode = 0x0; 
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cf_inst          = SQ_CF_INST_CALL;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.whole_quad_mode  = 0x0;
+
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.barrier          = 0x1;
+
+    /* Put in caller */
+    if( (pAsm->unCallerArrayPointer + 1) > pAsm->unCallerArraySize )
     {
-        if( GL_FALSE == assemble_dst(pAsm) )
+        pAsm->callers = (CALLER_POINTER*)_mesa_realloc( (void *)pAsm->callers, 
+                       sizeof(CALLER_POINTER) * pAsm->unCallerArraySize, 
+                       sizeof(CALLER_POINTER) * (pAsm->unCallerArraySize + 10) );
+        if(NULL == pAsm->callers)
         {
             return GL_FALSE;
         }
+        pAsm->unCallerArraySize += 10;
+    }
+    
+    uiIL_Offset = nILindex + uiIL_Shift;
+    pAsm->callers[pAsm->unCallerArrayPointer].subIL_Offset = uiIL_Offset; 
+    pAsm->callers[pAsm->unCallerArrayPointer].cf_ptr       = pAsm->cf_current_cf_clause_ptr;
+    
+    pAsm->callers[pAsm->unCallerArrayPointer].finale_cf_ptr  = NULL; 
+    pAsm->callers[pAsm->unCallerArrayPointer].prelude_cf_ptr = NULL; 
 
-        pAsm->D.dst.opcode = SQ_OP2_INST_MOV;
+    pAsm->unCallerArrayPointer++;
 
-        // Use tmp as source
-        setaddrmode_PVSSRC(&(pAsm->S[0].src), ADDR_ABSOLUTE);
-        pAsm->S[0].src.rtype = SRC_REG_TEMPORARY;
-        pAsm->S[0].src.reg   = tmp;
+    int j;
+    GLuint max;
+    GLuint unSubID;
+    GLboolean bRet;
+    for(j=0; j<pAsm->unSubArrayPointer; j++)
+    {
+        if(uiIL_Offset == pAsm->subs[j].subIL_Offset)
+        {   /* compiled before */
 
-        noneg_PVSSRC(&(pAsm->S[0].src));
-        noswizzle_PVSSRC(&(pAsm->S[0].src));
+            max = pAsm->subs[j].unStackDepthMax 
+                + pAsm->CALLSTACK[pAsm->CALLSP].current;
+            if(max > pAsm->CALLSTACK[pAsm->CALLSP].max)
+            {
+                pAsm->CALLSTACK[pAsm->CALLSP].max = max;
+            }
+            
+            pAsm->callers[pAsm->unCallerArrayPointer - 1].subDescIndex = j; 
+            return GL_TRUE;
+        }
+    }
 
-        if( GL_FALSE == next_ins(pAsm) )
+    pAsm->callers[pAsm->unCallerArrayPointer - 1].subDescIndex = pAsm->unSubArrayPointer;
+    unSubID = pAsm->unSubArrayPointer;
+
+    bRet = AssembleInstr(nILindex, uiIL_Shift, uiNumberInsts, pILInst, pAsm);
+
+    if(GL_TRUE == bRet)
+    {
+        max = pAsm->subs[unSubID].unStackDepthMax 
+            + pAsm->CALLSTACK[pAsm->CALLSP].current;
+        if(max > pAsm->CALLSTACK[pAsm->CALLSP].max)
         {
-            return GL_FALSE;
+            pAsm->CALLSTACK[pAsm->CALLSP].max = max;
         }
+
+        pAsm->subs[unSubID].pPresubDesc = pPresubDesc;
+    }
+
+    return bRet;
+}
+
+GLboolean setRetInLoopFlag(r700_AssemblerBase *pAsm, GLuint flagValue)
+{
+    GLfloat fLiteral[2] = {0.1, 0.0};
+
+    pAsm->D.dst.opcode   = SQ_OP2_INST_MOV;
+    pAsm->D.dst.op3      = 0;
+    pAsm->D.dst.rtype    = DST_REG_TEMPORARY;
+    pAsm->D.dst.reg      = pAsm->flag_reg_index;
+    pAsm->D.dst.writex   = 1;
+    pAsm->D.dst.writey   = 0;
+    pAsm->D.dst.writez   = 0;
+    pAsm->D.dst.writew   = 0;
+    pAsm->D2.dst2.literal_slots      = 1;
+    pAsm->D2.dst2.SaturateMode = SATURATE_OFF;
+    pAsm->D.dst.predicated     = 0;
+    /* in reloc where dislink flag init inst, only one slot alu inst is handled. */
+    pAsm->D.dst.math           = 1; /* TODO : not math really, but one channel op, more generic alu assembler needed */
+    pAsm->D2.dst2.index_mode = SQ_INDEX_LOOP; /* Check this ! */
+#if 0
+    pAsm->S[0].src.rtype = SRC_REC_LITERAL;
+    //pAsm->S[0].src.reg   = 0;
+    setaddrmode_PVSSRC(&(pAsm->S[0].src), ADDR_ABSOLUTE);
+    noneg_PVSSRC(&(pAsm->S[0].src));
+    pAsm->S[0].src.swizzlex = SQ_SEL_X;
+    pAsm->S[0].src.swizzley = SQ_SEL_Y;
+    pAsm->S[0].src.swizzlez = SQ_SEL_Z;
+    pAsm->S[0].src.swizzlew = SQ_SEL_W;
+
+    if( GL_FALSE == next_ins_literal(pAsm, &(fLiteral[0])) )
+    {
+        return GL_FALSE;
+    }
+#else
+    pAsm->S[0].src.rtype = DST_REG_TEMPORARY;
+    pAsm->S[0].src.reg   = 0;
+    setaddrmode_PVSSRC(&(pAsm->S[0].src), ADDR_ABSOLUTE);
+    noneg_PVSSRC(&(pAsm->S[0].src));
+    pAsm->S[0].src.swizzlex = flagValue;
+    pAsm->S[0].src.swizzley = flagValue;
+    pAsm->S[0].src.swizzlez = flagValue;
+    pAsm->S[0].src.swizzlew = flagValue;
+
+    if( GL_FALSE == next_ins(pAsm) )
+    {
+        return GL_FALSE;
     }
+#endif
 
     return GL_TRUE;
 }
 
-GLboolean assemble_EXPORT(r700_AssemblerBase *pAsm)
+GLboolean testFlag(r700_AssemblerBase *pAsm)
 {
+    GLfloat fLiteral[2] = {0.1, 0.0};
+
+    //Test flag
+    GLuint tmp = gethelpr(pAsm);
+    pAsm->alu_x_opcode = SQ_CF_INST_ALU_PUSH_BEFORE;
+
+    pAsm->D.dst.opcode   = SQ_OP2_INST_PRED_SETE;
+    pAsm->D.dst.math     = 1;
+    pAsm->D.dst.rtype    = DST_REG_TEMPORARY;
+    pAsm->D.dst.reg      = tmp;
+    pAsm->D.dst.writex   = 1;
+    pAsm->D.dst.writey   = 0;
+    pAsm->D.dst.writez   = 0;
+    pAsm->D.dst.writew   = 0;
+    pAsm->D2.dst2.literal_slots      = 1;
+    pAsm->D2.dst2.SaturateMode = SATURATE_OFF;
+    pAsm->D.dst.predicated     = 1;
+    pAsm->D2.dst2.index_mode = SQ_INDEX_LOOP; /* Check this ! */
+
+    pAsm->S[0].src.rtype = DST_REG_TEMPORARY;
+    pAsm->S[0].src.reg   = pAsm->flag_reg_index;
+    setaddrmode_PVSSRC(&(pAsm->S[0].src), ADDR_ABSOLUTE);
+    noneg_PVSSRC(&(pAsm->S[0].src));
+    pAsm->S[0].src.swizzlex = SQ_SEL_X;
+    pAsm->S[0].src.swizzley = SQ_SEL_Y;
+    pAsm->S[0].src.swizzlez = SQ_SEL_Z;
+    pAsm->S[0].src.swizzlew = SQ_SEL_W;
+#if 0
+    pAsm->S[1].src.rtype = SRC_REC_LITERAL;
+    //pAsm->S[1].src.reg   = 0;
+    setaddrmode_PVSSRC(&(pAsm->S[1].src), ADDR_ABSOLUTE);
+    noneg_PVSSRC(&(pAsm->S[1].src));
+    pAsm->S[1].src.swizzlex = SQ_SEL_X;
+    pAsm->S[1].src.swizzley = SQ_SEL_Y;
+    pAsm->S[1].src.swizzlez = SQ_SEL_Z;
+    pAsm->S[1].src.swizzlew = SQ_SEL_W;
+
+    if( GL_FALSE == next_ins_literal(pAsm, &(fLiteral[0])) )
+    {
+        return GL_FALSE;
+    }
+#else
+    pAsm->S[1].src.rtype = DST_REG_TEMPORARY;
+    pAsm->S[1].src.reg   = 0;
+    setaddrmode_PVSSRC(&(pAsm->S[1].src), ADDR_ABSOLUTE);
+    noneg_PVSSRC(&(pAsm->S[1].src));
+    pAsm->S[1].src.swizzlex = SQ_SEL_1;
+    pAsm->S[1].src.swizzley = SQ_SEL_1;
+    pAsm->S[1].src.swizzlez = SQ_SEL_1;
+    pAsm->S[1].src.swizzlew = SQ_SEL_1;
+
+    if( GL_FALSE == next_ins(pAsm) )
+    {
+        return GL_FALSE;
+    }
+#endif
+
+    checkStackDepth(pAsm, FC_PUSH_VPM, GL_TRUE);
+
     return GL_TRUE;
 }
 
-GLboolean assemble_IF(r700_AssemblerBase *pAsm)
+GLboolean returnOnFlag(r700_AssemblerBase *pAsm, GLuint unIF)
 {
+    testFlag(pAsm);
+    jumpToOffest(pAsm, 1, 4);
+    setRetInLoopFlag(pAsm, SQ_SEL_0);
+    pops(pAsm, unIF + 1);
+    add_return_inst(pAsm);
+
     return GL_TRUE;
 }
 
-GLboolean assemble_ENDIF(r700_AssemblerBase *pAsm)
+GLboolean breakLoopOnFlag(r700_AssemblerBase *pAsm, GLuint unFCSP)
 {
+    testFlag(pAsm);
+    //break
+    if(GL_FALSE == add_cf_instruction(pAsm) )
+    {
+        return GL_FALSE;
+    }
+    
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.pop_count        = 1;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cf_const         = 0x0; 
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cond             = SQ_CF_COND_ACTIVE;
+
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.end_of_program   = 0x0;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.valid_pixel_mode = 0x0; 
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.cf_inst          = SQ_CF_INST_LOOP_BREAK;
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.whole_quad_mode  = 0x0;
+
+    pAsm->cf_current_cf_clause_ptr->m_Word1.f.barrier          = 0x1;
+
+    pAsm->fc_stack[unFCSP].mid = (R700ControlFlowGenericClause **)_mesa_realloc( 
+                                              (void *)pAsm->fc_stack[unFCSP].mid,
+                                              sizeof(R700ControlFlowGenericClause *) * pAsm->fc_stack[unFCSP].unNumMid,
+                                              sizeof(R700ControlFlowGenericClause *) * (pAsm->fc_stack[unFCSP].unNumMid + 1) );
+    pAsm->fc_stack[unFCSP].mid[pAsm->fc_stack[unFCSP].unNumMid] = pAsm->cf_current_cf_clause_ptr;
+    pAsm->fc_stack[unFCSP].unNumMid++;
+
+    pops(pAsm, 1);
+               
     return GL_TRUE;
 }
 
-GLboolean AssembleInstr(GLuint uiNumberInsts,
+GLboolean AssembleInstr(GLuint uiFirstInst,
+                        GLuint uiIL_Shift,
+                        GLuint uiNumberInsts,
                         struct prog_instruction *pILInst, 
                                                r700_AssemblerBase *pR700AsmCode)
 {
     GLuint i;
 
     pR700AsmCode->pILInst = pILInst;
-       for(i=0; i<uiNumberInsts; i++)
+       for(i=uiFirstInst; i<uiNumberInsts; i++)
     {
         pR700AsmCode->uiCurInst = i;
 
+#ifndef USE_CF_FOR_CONTINUE_BREAK
+        if(OPCODE_BRK == pILInst[i+1].Opcode)
+        {
+            switch(pILInst[i].Opcode)            
+            {
+            case OPCODE_SLE:
+                pILInst[i].Opcode = OPCODE_SGT;
+                break;
+            case OPCODE_SLT:
+                pILInst[i].Opcode = OPCODE_SGE;
+                break;
+            case OPCODE_SGE:
+                pILInst[i].Opcode = OPCODE_SLT;
+                break;
+            case OPCODE_SGT:
+                pILInst[i].Opcode = OPCODE_SLE;
+                break;
+            case OPCODE_SEQ:
+                pILInst[i].Opcode = OPCODE_SNE;
+                break;
+            case OPCODE_SNE:
+                pILInst[i].Opcode = OPCODE_SEQ;
+                break;
+            default:
+                break;
+            }
+        }
+#endif
+        if(pILInst[i].CondUpdate == 1)
+        {
+            /* remember dest register used for cond evaluation */
+            /* XXX also handle PROGRAM_OUTPUT registers here? */
+            pR700AsmCode->last_cond_register = pILInst[i].DstReg.Index; 
+        }
+
         switch (pILInst[i].Opcode)
         {
         case OPCODE_ABS: 
@@ -3936,8 +5520,7 @@ GLboolean AssembleInstr(GLuint uiNumberInsts,
             break;  
 
         case OPCODE_ARL: 
-            radeon_error("Not yet implemented instruction OPCODE_ARL \n");
-            //if ( GL_FALSE == assemble_BAD("ARL") ) 
+            if ( GL_FALSE == assemble_ARL(pR700AsmCode) ) 
                 return GL_FALSE;
             break;
         case OPCODE_ARR: 
@@ -3951,7 +5534,7 @@ GLboolean AssembleInstr(GLuint uiNumberInsts,
                 return GL_FALSE;
             break;  
         case OPCODE_COS: 
-            if ( GL_FALSE == assemble_COS(pR700AsmCode) ) 
+            if ( GL_FALSE == assemble_TRIG(pR700AsmCode, SQ_OP2_INST_COS) ) 
                 return GL_FALSE;
             break;  
 
@@ -3972,16 +5555,16 @@ GLboolean AssembleInstr(GLuint uiNumberInsts,
                 return GL_FALSE;
             break;  
         case OPCODE_EXP: 
-            radeon_error("Not yet implemented instruction OPCODE_EXP \n");
-            //if ( GL_FALSE == assemble_BAD("EXP") ) 
+            if ( GL_FALSE == assemble_EXP(pR700AsmCode) ) 
                 return GL_FALSE;
-            break; // approx of EX2
+            break;
 
         case OPCODE_FLR:     
             if ( GL_FALSE == assemble_FLR(pR700AsmCode) ) 
                 return GL_FALSE;
             break;  
-        //case OP_FLR_INT: 
+        //case OP_FLR_INT: ;
+
         //    if ( GL_FALSE == assemble_FLR_INT() ) 
         //        return GL_FALSE;
         //    break;  
@@ -3992,7 +5575,8 @@ GLboolean AssembleInstr(GLuint uiNumberInsts,
             break;  
 
         case OPCODE_KIL: 
-            if ( GL_FALSE == assemble_KIL(pR700AsmCode) ) 
+        case OPCODE_KIL_NV: 
+            if ( GL_FALSE == assemble_KIL(pR700AsmCode, SQ_OP2_INST_KILLGT) ) 
                 return GL_FALSE;
             break;
         case OPCODE_LG2: 
@@ -4008,10 +5592,9 @@ GLboolean AssembleInstr(GLuint uiNumberInsts,
                 return GL_FALSE;
             break;  
         case OPCODE_LOG: 
-            radeon_error("Not yet implemented instruction OPCODE_LOG \n");
-            //if ( GL_FALSE == assemble_BAD("LOG") ) 
+            if ( GL_FALSE == assemble_LOG(pR700AsmCode) ) 
                 return GL_FALSE;
-            break; // approx of LG2
+            break;
 
         case OPCODE_MAD: 
             if ( GL_FALSE == assemble_MAD(pR700AsmCode) ) 
@@ -4033,6 +5616,26 @@ GLboolean AssembleInstr(GLuint uiNumberInsts,
         case OPCODE_MUL: 
             if ( GL_FALSE == assemble_MUL(pR700AsmCode) ) 
                 return GL_FALSE;
+            break;
+            
+        case OPCODE_NOISE1:
+            {                                               
+                callPreSub(pR700AsmCode, 
+                           GLSL_NOISE1,                         
+                           &noise1_presub,                                                  
+                           pILInst->DstReg.Index + pR700AsmCode->starting_temp_register_number, 
+                           1); 
+                radeon_error("noise1: not yet supported shader instruction\n");
+            };
+            break; 
+        case OPCODE_NOISE2: 
+            radeon_error("noise2: not yet supported shader instruction\n");
+            break; 
+        case OPCODE_NOISE3: 
+            radeon_error("noise3: not yet supported shader instruction\n");
+            break; 
+        case OPCODE_NOISE4: 
+            radeon_error("noise4: not yet supported shader instruction\n");
             break; 
 
         case OPCODE_POW: 
@@ -4048,22 +5651,78 @@ GLboolean AssembleInstr(GLuint uiNumberInsts,
                 return GL_FALSE;
             break;  
         case OPCODE_SIN: 
-            if ( GL_FALSE == assemble_SIN(pR700AsmCode) ) 
+            if ( GL_FALSE == assemble_TRIG(pR700AsmCode, SQ_OP2_INST_SIN) ) 
                 return GL_FALSE;
             break;  
         case OPCODE_SCS: 
             if ( GL_FALSE == assemble_SCS(pR700AsmCode) ) 
                 return GL_FALSE;
-            break;  
+            break; 
+            
+        case OPCODE_SEQ:
+            if ( GL_FALSE == assemble_LOGIC(pR700AsmCode, SQ_OP2_INST_SETE) ) 
+            {
+                return GL_FALSE;
+            }
+            break;
+
+        case OPCODE_SGT: 
+            if ( GL_FALSE == assemble_LOGIC(pR700AsmCode, SQ_OP2_INST_SETGT) ) 
+            {
+                return GL_FALSE;
+            }
+            break;
 
         case OPCODE_SGE: 
             if ( GL_FALSE == assemble_SGE(pR700AsmCode) ) 
+            { 
                 return GL_FALSE;
-            break; 
+            }
+            break;
+        
+        /* NO LT, LE, TODO : use GE => LE, GT => LT : reverse 2 src order would be simpliest. Or use SQ_CF_COND_FALSE for SQ_CF_COND_ACTIVE.*/
         case OPCODE_SLT: 
-            if ( GL_FALSE == assemble_SLT(pR700AsmCode) ) 
+            {
+                struct prog_src_register SrcRegSave[2];
+                SrcRegSave[0] = pILInst[i].SrcReg[0];
+                SrcRegSave[1] = pILInst[i].SrcReg[1];
+                pILInst[i].SrcReg[0] = SrcRegSave[1];
+                pILInst[i].SrcReg[1] = SrcRegSave[0];
+                if ( GL_FALSE == assemble_LOGIC(pR700AsmCode, SQ_OP2_INST_SETGT) ) 
+                {
+                    pILInst[i].SrcReg[0] = SrcRegSave[0];
+                    pILInst[i].SrcReg[1] = SrcRegSave[1];
+                    return GL_FALSE;
+                }
+                pILInst[i].SrcReg[0] = SrcRegSave[0];
+                pILInst[i].SrcReg[1] = SrcRegSave[1];
+            }
+            break;
+
+        case OPCODE_SLE: 
+            {
+                struct prog_src_register SrcRegSave[2];
+                SrcRegSave[0] = pILInst[i].SrcReg[0];
+                SrcRegSave[1] = pILInst[i].SrcReg[1];
+                pILInst[i].SrcReg[0] = SrcRegSave[1];
+                pILInst[i].SrcReg[1] = SrcRegSave[0];
+                if ( GL_FALSE == assemble_LOGIC(pR700AsmCode, SQ_OP2_INST_SETGE) ) 
+                {
+                    pILInst[i].SrcReg[0] = SrcRegSave[0];
+                    pILInst[i].SrcReg[1] = SrcRegSave[1];
+                    return GL_FALSE;
+                }
+                pILInst[i].SrcReg[0] = SrcRegSave[0];
+                pILInst[i].SrcReg[1] = SrcRegSave[1];
+            }
+            break;
+
+        case OPCODE_SNE: 
+            if ( GL_FALSE == assemble_LOGIC(pR700AsmCode, SQ_OP2_INST_SETNE) ) 
+            {
                 return GL_FALSE;
-            break; 
+            }
+            break;
 
         //case OP_STP: 
         //    if ( GL_FALSE == assemble_STP(pR700AsmCode) ) 
@@ -4089,7 +5748,8 @@ GLboolean AssembleInstr(GLuint uiNumberInsts,
                 }
             }
             break;
-
+        case OPCODE_DDX:
+        case OPCODE_DDY:
         case OPCODE_TEX: 
         case OPCODE_TXB:  
         case OPCODE_TXP: 
@@ -4097,30 +5757,104 @@ GLboolean AssembleInstr(GLuint uiNumberInsts,
                 return GL_FALSE;
             break;
 
+        case OPCODE_TRUNC:
+            if ( GL_FALSE == assemble_math_function(pR700AsmCode, SQ_OP2_INST_TRUNC) )
+                return GL_FALSE;
+            break;
+
         case OPCODE_XPD: 
             if ( GL_FALSE == assemble_XPD(pR700AsmCode) ) 
                 return GL_FALSE;
             break;  
 
-        case OPCODE_IF   : 
-            if ( GL_FALSE == assemble_IF(pR700AsmCode) ) 
-                return GL_FALSE;
+        case OPCODE_IF:
+            {                
+                GLboolean bHasElse = GL_FALSE;
+
+                if(pILInst[pILInst[i].BranchTarget].Opcode == OPCODE_ELSE)
+                {
+                    bHasElse = GL_TRUE;
+                }
+
+                if ( GL_FALSE == assemble_IF(pR700AsmCode, bHasElse) ) 
+                {
+                    return GL_FALSE;
+                }
+            }
             break;
+
         case OPCODE_ELSE : 
-            radeon_error("Not yet implemented instruction OPCODE_ELSE \n");
-            //if ( GL_FALSE == assemble_BAD("ELSE") ) 
+            if ( GL_FALSE == assemble_ELSE(pR700AsmCode) ) 
                 return GL_FALSE;
             break;
+
         case OPCODE_ENDIF: 
             if ( GL_FALSE == assemble_ENDIF(pR700AsmCode) ) 
                 return GL_FALSE;
             break;
 
+        case OPCODE_BGNLOOP:
+            if( GL_FALSE == assemble_BGNLOOP(pR700AsmCode) )
+            {
+                return GL_FALSE;
+            }
+            break;
+
+        case OPCODE_BRK:
+            if( GL_FALSE == assemble_BRK(pR700AsmCode) )
+            {
+                return GL_FALSE;
+            }
+            break;
+
+        case OPCODE_CONT:
+            if( GL_FALSE == assemble_CONT(pR700AsmCode) )
+            {
+                return GL_FALSE;
+            }
+            break;
+
+        case OPCODE_ENDLOOP:
+            if( GL_FALSE == assemble_ENDLOOP(pR700AsmCode) )
+            {
+                return GL_FALSE;
+            }
+            break;
+
+        case OPCODE_BGNSUB:
+            if( GL_FALSE == assemble_BGNSUB(pR700AsmCode, i, uiIL_Shift) )
+            {
+                return GL_FALSE;
+            }
+            break;
+        
+        case OPCODE_RET:
+            if( GL_FALSE == assemble_RET(pR700AsmCode) )
+            {
+                return GL_FALSE;
+            }
+            break;
+        
+        case OPCODE_CAL:
+            if( GL_FALSE == assemble_CAL(pR700AsmCode, 
+                                         pILInst[i].BranchTarget,
+                                         uiIL_Shift,
+                                         uiNumberInsts,
+                                         pILInst,
+                                         NULL) )
+            {
+                return GL_FALSE;
+            }
+            break;
+
         //case OPCODE_EXPORT: 
         //    if ( GL_FALSE == assemble_EXPORT() ) 
         //        return GL_FALSE;
         //    break;
 
+        case OPCODE_ENDSUB:
+            return assemble_ENDSUB(pR700AsmCode);
+
         case OPCODE_END: 
                        //pR700AsmCode->uiCurInst = i;
                        //This is to remaind that if in later exoort there is depth/stencil
@@ -4137,6 +5871,417 @@ GLboolean AssembleInstr(GLuint uiNumberInsts,
     return GL_TRUE;
 }
 
+GLboolean InitShaderProgram(r700_AssemblerBase * pAsm)
+{
+    setRetInLoopFlag(pAsm, SQ_SEL_0);
+    pAsm->alu_x_opcode = SQ_CF_INST_ALU;
+    return GL_TRUE;
+}
+
+GLboolean RelocProgram(r700_AssemblerBase * pAsm, struct gl_program * pILProg)
+{
+    GLuint i;
+    GLuint unCFoffset;
+    TypedShaderList * plstCFmain;
+    TypedShaderList * plstCFsub;
+
+    R700ShaderInstruction *        pInst;
+    R700ControlFlowGenericClause * pCFInst;
+
+    R700ControlFlowALUClause * pCF_ALU;
+    R700ALUInstruction       * pALU;
+    GLuint                     unConstOffset = 0;
+    GLuint                     unRegOffset;
+    GLuint                     unMinRegIndex;
+
+    plstCFmain = pAsm->CALLSTACK[0].plstCFInstructions_local;
+
+    /* remove flags init if they are not used */
+    if((pAsm->unCFflags & HAS_LOOPRET) == 0)
+    {
+        R700ControlFlowALUClause * pCF_ALU;
+        pInst = plstCFmain->pHead;
+        while(pInst)
+        {
+            if(SIT_CF_ALU == pInst->m_ShaderInstType)
+            {
+                pCF_ALU = (R700ControlFlowALUClause *)pInst;
+                if(0 == pCF_ALU->m_Word1.f.count)
+                {
+                    pCF_ALU->m_Word1.f.cf_inst = SQ_CF_INST_NOP;
+                }
+                else
+                {
+                    R700ALUInstruction * pALU = pCF_ALU->m_pLinkedALUInstruction;
+                    
+                    pALU->m_pLinkedALUClause = NULL;
+                    pALU = (R700ALUInstruction *)(pALU->pNextInst);
+                    pALU->m_pLinkedALUClause = pCF_ALU;
+                    pCF_ALU->m_pLinkedALUInstruction = pALU;
+
+                    pCF_ALU->m_Word1.f.count--;
+                }
+                break;
+            }
+            pInst = pInst->pNextInst;
+        };
+    }
+
+    if(pAsm->CALLSTACK[0].max > 0)
+    {
+        pAsm->pR700Shader->uStackSize = ((pAsm->CALLSTACK[0].max + 3)>>2) + 2;
+    }
+
+    if(0 == pAsm->unSubArrayPointer)
+    {
+        return GL_TRUE;
+    }
+
+    unCFoffset = plstCFmain->uNumOfNode;
+
+    if(NULL != pILProg->Parameters)
+    {        
+        unConstOffset = pILProg->Parameters->NumParameters;
+    }
+
+    /* Reloc subs */
+    for(i=0; i<pAsm->unSubArrayPointer; i++)
+    {
+        pAsm->subs[i].unCFoffset = unCFoffset;
+        plstCFsub = &(pAsm->subs[i].lstCFInstructions_local);
+
+        pInst = plstCFsub->pHead;
+
+        /* reloc instructions */
+        while(pInst)
+        {
+            if(SIT_CF_GENERIC == pInst->m_ShaderInstType)
+            {
+                pCFInst = (R700ControlFlowGenericClause *)pInst;
+
+                switch (pCFInst->m_Word1.f.cf_inst)
+                {
+                case SQ_CF_INST_POP:
+                case SQ_CF_INST_JUMP:
+                case SQ_CF_INST_ELSE:
+                case SQ_CF_INST_LOOP_END:
+                case SQ_CF_INST_LOOP_START:
+                case SQ_CF_INST_LOOP_START_NO_AL:
+                case SQ_CF_INST_LOOP_CONTINUE:
+                case SQ_CF_INST_LOOP_BREAK:
+                    pCFInst->m_Word0.f.addr += unCFoffset;
+                    break;
+                default:
+                    break;
+                }
+            }  
+            
+            pInst->m_uIndex += unCFoffset;
+
+            pInst = pInst->pNextInst;
+        };
+
+        if(NULL != pAsm->subs[i].pPresubDesc)
+        {
+            GLuint                     uNumSrc;            
+            
+            unMinRegIndex  = pAsm->subs[i].pPresubDesc->pCompiledSub->MinRegIndex;
+            unRegOffset    = pAsm->subs[i].pPresubDesc->maxStartReg;            
+            unConstOffset += pAsm->subs[i].pPresubDesc->unConstantsStart;
+
+            pInst = plstCFsub->pHead;
+            while(pInst)
+            {
+                if(SIT_CF_ALU == pInst->m_ShaderInstType)
+                {
+                    pCF_ALU = (R700ControlFlowALUClause *)pInst;
+
+                    pALU = pCF_ALU->m_pLinkedALUInstruction;
+                    for(int j=0; j<=pCF_ALU->m_Word1.f.count; j++)
+                    {
+                        pALU->m_Word1.f.dst_gpr = pALU->m_Word1.f.dst_gpr + unRegOffset - unMinRegIndex;
+
+                        if(pALU->m_Word0.f.src0_sel < SQ_ALU_SRC_GPR_SIZE)
+                        {   
+                            pALU->m_Word0.f.src0_sel = pALU->m_Word0.f.src0_sel + unRegOffset - unMinRegIndex;
+                        }
+                        else if(pALU->m_Word0.f.src0_sel >= SQ_ALU_SRC_CFILE_BASE)
+                        {   
+                            pALU->m_Word0.f.src0_sel += unConstOffset;
+                        }
+
+                        if( ((pALU->m_Word1.val >> SQ_ALU_WORD1_OP3_ALU_INST_SHIFT) & 0x0000001F) 
+                            >= SQ_OP3_INST_MUL_LIT )
+                        {   /* op3 : 3 srcs */
+                            if(pALU->m_Word1_OP3.f.src2_sel < SQ_ALU_SRC_GPR_SIZE)
+                            {   
+                                pALU->m_Word1_OP3.f.src2_sel = pALU->m_Word1_OP3.f.src2_sel + unRegOffset - unMinRegIndex;
+                            }
+                            else if(pALU->m_Word1_OP3.f.src2_sel >= SQ_ALU_SRC_CFILE_BASE)
+                            {   
+                                pALU->m_Word1_OP3.f.src2_sel += unConstOffset;
+                            }    
+                            if(pALU->m_Word0.f.src1_sel < SQ_ALU_SRC_GPR_SIZE)
+                            {   
+                                pALU->m_Word0.f.src1_sel = pALU->m_Word0.f.src1_sel + unRegOffset - unMinRegIndex;
+                            }
+                            else if(pALU->m_Word0.f.src1_sel >= SQ_ALU_SRC_CFILE_BASE)
+                            {   
+                                pALU->m_Word0.f.src1_sel += unConstOffset;
+                            }                                 
+                        }
+                        else
+                        {
+                            if(pAsm->bR6xx)
+                            {
+                                uNumSrc = r700GetNumOperands(pALU->m_Word1_OP2.f6.alu_inst, 0);
+                            }
+                            else
+                            {
+                                uNumSrc = r700GetNumOperands(pALU->m_Word1_OP2.f.alu_inst, 0);
+                            }
+                            if(2 == uNumSrc)
+                            {   /* 2 srcs */
+                                if(pALU->m_Word0.f.src1_sel < SQ_ALU_SRC_GPR_SIZE)
+                                {   
+                                    pALU->m_Word0.f.src1_sel = pALU->m_Word0.f.src1_sel + unRegOffset - unMinRegIndex;
+                                }
+                                else if(pALU->m_Word0.f.src1_sel >= SQ_ALU_SRC_CFILE_BASE)
+                                {   
+                                    pALU->m_Word0.f.src1_sel += unConstOffset;
+                                }                                  
+                            }                            
+                        }
+                        pALU = (R700ALUInstruction*)(pALU->pNextInst);
+                    }                    
+                }             
+                pInst = pInst->pNextInst;
+            };
+        }
+
+        /* Put sub into main */
+        plstCFmain->pTail->pNextInst = plstCFsub->pHead;
+        plstCFmain->pTail            = plstCFsub->pTail;
+        plstCFmain->uNumOfNode      += plstCFsub->uNumOfNode;
+
+        unCFoffset += plstCFsub->uNumOfNode;
+    }
+
+    /* reloc callers */
+    for(i=0; i<pAsm->unCallerArrayPointer; i++)
+    {
+        pAsm->callers[i].cf_ptr->m_Word0.f.addr
+            = pAsm->subs[pAsm->callers[i].subDescIndex].unCFoffset; 
+
+        if(NULL != pAsm->subs[pAsm->callers[i].subDescIndex].pPresubDesc)
+        {                 
+            unMinRegIndex = pAsm->subs[pAsm->callers[i].subDescIndex].pPresubDesc->pCompiledSub->MinRegIndex;
+            unRegOffset = pAsm->subs[pAsm->callers[i].subDescIndex].pPresubDesc->maxStartReg;
+
+            if(NULL != pAsm->callers[i].prelude_cf_ptr)
+            {                
+                pCF_ALU = (R700ControlFlowALUClause * )(pAsm->callers[i].prelude_cf_ptr);
+                pALU = pCF_ALU->m_pLinkedALUInstruction;
+                for(int j=0; j<=pCF_ALU->m_Word1.f.count; j++)
+                {
+                    pALU->m_Word1.f.dst_gpr = pALU->m_Word1.f.dst_gpr + unRegOffset - unMinRegIndex;
+                    pALU = (R700ALUInstruction*)(pALU->pNextInst);
+                }
+            }
+            if(NULL != pAsm->callers[i].finale_cf_ptr)
+            {
+                pCF_ALU = (R700ControlFlowALUClause * )(pAsm->callers[i].finale_cf_ptr);
+                pALU = pCF_ALU->m_pLinkedALUInstruction;
+                for(int j=0; j<=pCF_ALU->m_Word1.f.count; j++)
+                {
+                    pALU->m_Word0.f.src0_sel = pALU->m_Word0.f.src0_sel + unRegOffset - unMinRegIndex;
+                    pALU = (R700ALUInstruction*)(pALU->pNextInst);
+                }
+            }
+        }
+    }
+
+    return GL_TRUE;
+}
+
+GLboolean callPreSub(r700_AssemblerBase* pAsm, 
+                         LOADABLE_SCRIPT_SIGNITURE scriptSigniture,                          
+                         COMPILED_SUB * pCompiledSub,                                               
+                         GLshort uOutReg,
+                         GLshort uNumValidSrc)
+{
+    /* save assemble context */
+    GLuint starting_temp_register_number_save;
+    GLuint number_used_registers_save;
+    GLuint uFirstHelpReg_save;
+    GLuint uHelpReg_save;
+    GLuint uiCurInst_save;
+    struct prog_instruction *pILInst_save;
+    PRESUB_DESC * pPresubDesc;
+    GLboolean     bRet;
+    int i;
+
+    R700ControlFlowGenericClause* prelude_cf_ptr = NULL;
+
+    /* copy srcs to presub inputs */  
+    pAsm->alu_x_opcode = SQ_CF_INST_ALU;
+    for(i=0; i<uNumValidSrc; i++)
+    {
+        pAsm->D.dst.opcode = SQ_OP2_INST_MOV;
+        setaddrmode_PVSDST(&(pAsm->D.dst), ADDR_ABSOLUTE);
+        pAsm->D.dst.rtype = DST_REG_TEMPORARY;
+        pAsm->D.dst.reg   = pCompiledSub->srcRegIndex[i];
+        pAsm->D.dst.writex = 1;
+        pAsm->D.dst.writey = 1;
+        pAsm->D.dst.writez = 1;
+        pAsm->D.dst.writew = 1;
+
+        if( GL_FALSE == assemble_src(pAsm, i, 0) )
+        {
+            return GL_FALSE;
+        }
+
+        next_ins(pAsm);
+    }
+    if(uNumValidSrc > 0)
+    {
+        prelude_cf_ptr     = pAsm->cf_current_alu_clause_ptr;
+        pAsm->alu_x_opcode = SQ_CF_INST_ALU;
+    }
+
+    /* browse thro existing presubs. */
+    for(i=0; i<pAsm->unNumPresub; i++)
+    {
+        if(pAsm->presubs[i].sptSigniture == scriptSigniture)
+        {
+            break;
+        }
+    }
+
+    if(i == pAsm->unNumPresub)
+    {   /* not loaded yet */
+        /* save assemble context */
+        number_used_registers_save         = pAsm->number_used_registers;
+        uFirstHelpReg_save                 = pAsm->uFirstHelpReg;
+        uHelpReg_save                      = pAsm->uHelpReg;
+        starting_temp_register_number_save = pAsm->starting_temp_register_number;
+        pILInst_save                       = pAsm->pILInst;
+        uiCurInst_save                     = pAsm->uiCurInst;
+
+        /* alloc in presub */
+        if( (pAsm->unNumPresub + 1) > pAsm->unPresubArraySize )
+        {
+            pAsm->presubs = (PRESUB_DESC*)_mesa_realloc( (void *)pAsm->presubs,
+                                      sizeof(PRESUB_DESC) * pAsm->unPresubArraySize,
+                                      sizeof(PRESUB_DESC) * (pAsm->unPresubArraySize + 4) );
+            if(NULL == pAsm->presubs)
+            {
+                radeon_error("No memeory to allocate built in shader function description structures. \n");
+                return GL_FALSE;
+            }
+            pAsm->unPresubArraySize += 4;
+        }
+        
+        pPresubDesc = &(pAsm->presubs[i]);
+        pPresubDesc->sptSigniture = scriptSigniture;
+
+        /* constants offsets need to be final resolved at reloc. */
+        if(0 == pAsm->unNumPresub)
+        {
+            pPresubDesc->unConstantsStart = 0; 
+        }
+        else
+        {
+            pPresubDesc->unConstantsStart =  pAsm->presubs[i-1].unConstantsStart
+                                           + pAsm->presubs[i-1].pCompiledSub->NumParameters;
+        }
+
+        pPresubDesc->pCompiledSub = pCompiledSub;
+
+        pPresubDesc->subIL_Shift = pAsm->unCurNumILInsts;
+        pPresubDesc->maxStartReg  = uFirstHelpReg_save;
+        pAsm->unCurNumILInsts    += pCompiledSub->NumInstructions;
+
+        pAsm->unNumPresub++;
+
+        /* setup new assemble context */
+        pAsm->starting_temp_register_number = 0;
+        pAsm->number_used_registers = pCompiledSub->NumTemporaries;
+        pAsm->uFirstHelpReg         = pAsm->number_used_registers;
+        pAsm->uHelpReg              = pAsm->uFirstHelpReg;
+
+        bRet = assemble_CAL(pAsm, 
+                            0, 
+                            pPresubDesc->subIL_Shift, 
+                            pCompiledSub->NumInstructions,
+                            pCompiledSub->Instructions,
+                            pPresubDesc);
+
+        
+        pPresubDesc->number_used_registers = pAsm->number_used_registers;        
+
+        /* restore assemble context */
+        pAsm->number_used_registers         = number_used_registers_save; 
+        pAsm->uFirstHelpReg                 = uFirstHelpReg_save;
+        pAsm->uHelpReg                      = uHelpReg_save;
+        pAsm->starting_temp_register_number = starting_temp_register_number_save;
+        pAsm->pILInst                       = pILInst_save; 
+        pAsm->uiCurInst                     = uiCurInst_save;
+    }
+    else
+    {   /* was loaded */
+        pPresubDesc = &(pAsm->presubs[i]);  
+        
+        bRet = assemble_CAL(pAsm, 
+                            0, 
+                            pPresubDesc->subIL_Shift, 
+                            pCompiledSub->NumInstructions,
+                            pCompiledSub->Instructions,
+                            pPresubDesc);
+    }
+
+    if(GL_FALSE == bRet)
+    {
+        radeon_error("Shader presub assemble failed. \n");
+    }
+    else
+    {
+        /* copy presub output to real dst */ 
+        pAsm->alu_x_opcode = SQ_CF_INST_ALU;
+        pAsm->D.dst.opcode = SQ_OP2_INST_MOV;
+
+        if( GL_FALSE == assemble_dst(pAsm) )
+        {
+            return GL_FALSE;
+        }
+
+        setaddrmode_PVSSRC(&(pAsm->S[0].src), ADDR_ABSOLUTE);
+        pAsm->S[0].src.rtype = SRC_REG_TEMPORARY;
+        pAsm->S[0].src.reg   = pCompiledSub->dstRegIndex;
+        pAsm->S[0].src.swizzlex = pCompiledSub->outputSwizzleX;
+        pAsm->S[0].src.swizzley = pCompiledSub->outputSwizzleY;
+        pAsm->S[0].src.swizzlez = pCompiledSub->outputSwizzleZ;
+        pAsm->S[0].src.swizzlew = pCompiledSub->outputSwizzleW;
+
+        next_ins(pAsm);        
+
+        pAsm->callers[pAsm->unCallerArrayPointer - 1].finale_cf_ptr  = pAsm->cf_current_alu_clause_ptr;
+        pAsm->callers[pAsm->unCallerArrayPointer - 1].prelude_cf_ptr = prelude_cf_ptr;
+        pAsm->alu_x_opcode = SQ_CF_INST_ALU;
+    }
+
+    if( (pPresubDesc->number_used_registers + pAsm->uFirstHelpReg) > pAsm->number_used_registers )
+    {
+        pAsm->number_used_registers = pPresubDesc->number_used_registers + pAsm->uFirstHelpReg;
+    }
+    if(pAsm->uFirstHelpReg > pPresubDesc->maxStartReg)
+    {
+        pPresubDesc->maxStartReg = pAsm->uFirstHelpReg;
+    }
+
+    return bRet;
+}
+
 GLboolean Process_Export(r700_AssemblerBase* pAsm,
                          GLuint type,
                          GLuint export_starting_index,
@@ -4282,6 +6427,7 @@ GLboolean Process_Fragment_Exports(r700_AssemblerBase *pR700AsmCode,
                                    GLbitfield          OutputsWritten)  
 { 
     unsigned int unBit;
+    GLuint export_count = 0;
 
     if(pR700AsmCode->depth_export_register_number >= 0) 
     {
@@ -4303,6 +6449,7 @@ GLboolean Process_Fragment_Exports(r700_AssemblerBase *pR700AsmCode,
         {
             return GL_FALSE;
         }
+        export_count++;
        }
        unBit = 1 << FRAG_RESULT_DEPTH;
        if(OutputsWritten & unBit)
@@ -4316,8 +6463,15 @@ GLboolean Process_Fragment_Exports(r700_AssemblerBase *pR700AsmCode,
         {
             return GL_FALSE;
         }
+        export_count++;
        }
-
+    /* Need to export something, otherwise we'll hang
+     * results are undefined anyway */
+    if(export_count == 0)
+    {
+        Process_Export(pR700AsmCode, SQ_EXPORT_PIXEL, 0, 1, 0, GL_FALSE);
+    }
+    
     if(pR700AsmCode->cf_last_export_ptr != NULL) 
     {
         pR700AsmCode->cf_last_export_ptr->m_Word1.f.cf_inst        = SQ_CF_INST_EXPORT_DONE;
@@ -4422,6 +6576,25 @@ GLboolean Process_Vertex_Exports(r700_AssemblerBase *pR700AsmCode,
             export_starting_index++;
                }
        }
+    
+    for(i=VERT_RESULT_VAR0; i<VERT_RESULT_MAX; i++)
+       {
+        unBit = 1 << i;
+        if(OutputsWritten & unBit)
+               {
+            if( GL_FALSE == Process_Export(pR700AsmCode,
+                                          SQ_EXPORT_PARAM, 
+                                          export_starting_index, 
+                                          1, 
+                                          pR700AsmCode->ucVP_OutputMap[i],
+                                          GL_FALSE) )
+            {                
+                return GL_FALSE;
+            }
+
+            export_starting_index++;
+               }
+    }
 
     // At least one param should be exported
     if (export_count) 
@@ -4456,6 +6629,21 @@ GLboolean Clean_Up_Assembler(r700_AssemblerBase *pR700AsmCode)
 {
     FREE(pR700AsmCode->pucOutMask);
     FREE(pR700AsmCode->pInstDeps);
+
+    if(NULL != pR700AsmCode->subs)
+    {
+        FREE(pR700AsmCode->subs);
+    }
+    if(NULL != pR700AsmCode->callers)
+    {
+        FREE(pR700AsmCode->callers);
+    }
+
+    if(NULL != pR700AsmCode->presubs)
+    {
+        FREE(pR700AsmCode->presubs);
+    }
+
     return GL_TRUE;
 }
 
index 0d4283e4bad2ee77494d7633e3761ffa5cb69e4a..56baf5b0d918c39709c3c28a608a4c96c011efc7 100644 (file)
 #include "r700_shaderinst.h"
 #include "r700_shader.h"
 
+typedef enum LOADABLE_SCRIPT_SIGNITURE
+{
+    GLSL_NOISE1 = 0x10000001,
+    GLSL_NOISE2 = 0x10000002,
+    GLSL_NOISE3 = 0x10000003,
+    GLSL_NOISE4 = 0x10000004
+}LOADABLE_SCRIPT_SIGNITURE;
+
+typedef struct COMPILED_SUB
+{
+    struct  prog_instruction *Instructions;
+    GLuint  NumInstructions;
+    GLuint  NumTemporaries;
+    GLuint  NumParameters;
+    GLuint  MinRegIndex;
+    GLfloat (*ParameterValues)[4];
+    GLbyte  outputSwizzleX; 
+    GLbyte  outputSwizzleY;
+    GLbyte  outputSwizzleZ;
+    GLbyte  outputSwizzleW;
+    GLshort srcRegIndex[3];
+    GLushort dstRegIndex;
+}COMPILED_SUB;
+
+typedef struct PRESUB_DESCtag 
+{
+    LOADABLE_SCRIPT_SIGNITURE sptSigniture;
+    GLint  subIL_Shift;
+    struct prog_src_register InReg[3];
+    struct prog_dst_register OutReg;
+
+    GLushort maxStartReg;
+    GLushort number_used_registers;
+
+    GLuint   unConstantsStart;
+
+    COMPILED_SUB * pCompiledSub;
+} PRESUB_DESC;
+
 typedef enum SHADER_PIPE_TYPE 
 {
     SPT_VP = 0,
@@ -72,7 +111,8 @@ typedef enum SrcRegisterType
     SRC_REG_INPUT          = 1,
     SRC_REG_CONSTANT       = 2,
     SRC_REG_ALT_TEMPORARY  = 3,
-    NUMBER_OF_SRC_REG_TYPE = 4
+    SRC_REC_LITERAL        = 4, 
+    NUMBER_OF_SRC_REG_TYPE = 5
 } SrcRegisterType;
 
 typedef enum DstRegisterType 
@@ -111,16 +151,24 @@ typedef struct PVSDSTtag
        BITS addrmode1:1; //32
 } PVSDST;
 
+typedef struct PVSINSTtag
+{
+    BITS literal_slots      :2; 
+    BITS SaturateMode :2; 
+    BITS index_mode   :3;
+} PVSINST;
+
 typedef struct PVSSRCtag 
 {
-       BITS rtype:4;            
+       BITS rtype:3;            
        BITS addrmode0:1;        
-       BITS reg:10;      //15     (8)
+       BITS reg:10;      //14     (8)
        BITS swizzlex:3;
        BITS swizzley:3;
        BITS swizzlez:3;
-       BITS swizzlew:3;  //27        
+       BITS swizzlew:3;  //26        
 
+       BITS abs:1;
        BITS negx:1;
        BITS negy:1;
        BITS negz:1;
@@ -148,6 +196,7 @@ typedef union PVSDWORDtag
 {
        BITS    bits;
        PVSDST  dst;
+    PVSINST dst2;
        PVSSRC  src;
        PVSMATH math;
        float   f;
@@ -251,6 +300,8 @@ enum
     FC_IF = 1,
     FC_LOOP = 2,
     FC_REP = 3,
+    FC_PUSH_VPM = 4,
+    FC_PUSH_WQM = 5,
 
     COND_NONE = 0,
     COND_BOOL = 1,
@@ -263,22 +314,56 @@ enum
 
 typedef struct FC_LEVEL 
 {
-       unsigned int           first; ///< first fc instruction on level (if, rep, loop)
-       unsigned int*          mid; ///< middle instructions - else or all breaks on this level
-       unsigned int           midLen;
-       unsigned int           type;
-       unsigned int           cond;
-       unsigned int           inv;
-       unsigned int           bpush; ///< 1 if first instruction does branch stack push
-                        int           id; ///< id of bool or int variable
+    R700ControlFlowGenericClause *  first;
+    R700ControlFlowGenericClause ** mid;
+    unsigned int unNumMid;
+    unsigned int midLen;
+    unsigned int type;
+    unsigned int cond;
+    unsigned int inv;
+    int id; ///< id of bool or int variable
 } FC_LEVEL;
 
 typedef struct VTX_FETCH_METHOD 
 {
-       GLboolean bEnableMini;
-       GLuint mega_fetch_remainder;
+    GLboolean bEnableMini;
+    GLuint mega_fetch_remainder;
 } VTX_FETCH_METHOD;
 
+typedef struct SUB_OFFSET
+{
+    GLint  subIL_Offset;
+    GLuint unCFoffset;
+    GLuint unStackDepthMax;
+    PRESUB_DESC *   pPresubDesc;
+    TypedShaderList lstCFInstructions_local;
+} SUB_OFFSET;
+
+typedef struct CALLER_POINTER
+{
+    GLint  subIL_Offset;
+    GLint  subDescIndex;
+    R700ControlFlowGenericClause* cf_ptr;
+
+    R700ControlFlowGenericClause* prelude_cf_ptr;
+    R700ControlFlowGenericClause* finale_cf_ptr;
+} CALLER_POINTER;
+
+#define SQ_MAX_CALL_DEPTH 0x00000020
+
+typedef struct CALL_LEVEL
+{
+    unsigned int      FCSP_BeforeEntry;
+    GLint             subDescIndex;
+    GLushort          current;
+    GLushort          max;
+    TypedShaderList * plstCFInstructions_local;
+} CALL_LEVEL;
+
+#define HAS_CURRENT_LOOPRET 0x1L
+#define HAS_LOOPRET         0x2L
+#define LOOPRET_FLAGS       HAS_LOOPRET | HAS_CURRENT_LOOPRET
+
 typedef struct r700_AssemblerBase 
 {
        R700ControlFlowSXClause*      cf_last_export_ptr;
@@ -294,14 +379,19 @@ typedef struct r700_AssemblerBase
        // No clause has been created yet
        CF_CLAUSE_TYPE cf_current_clause_type;
 
+    BITS alu_x_opcode;
+
        GLuint number_of_exports;
        GLuint number_of_colorandz_exports;
        GLuint number_of_export_opcodes;
 
        PVSDWORD D;
+    PVSDWORD D2;
        PVSDWORD S[3];
+        PVSDWORD C[4];
 
        unsigned int uLastPosUpdate;
+       unsigned int last_cond_register;
 
        OUT_FRAGMENT_FMT_0     fp_stOutFmt0;
 
@@ -310,6 +400,8 @@ typedef struct r700_AssemblerBase
        unsigned int number_used_registers;
        unsigned int uUsedConsts; 
 
+    unsigned int flag_reg_index;
+
        // Fragment programs
        unsigned int uiFP_AttributeMap[FRAG_ATTRIB_MAX];
        unsigned int uiFP_OutputMap[FRAG_RESULT_MAX];
@@ -330,9 +422,6 @@ typedef struct r700_AssemblerBase
        unsigned int FCSP;
        FC_LEVEL fc_stack[32];
 
-       unsigned int branch_depth;
-       unsigned int max_branch_depth;
-
        //-----------------------------------------------------------------------------------
        // ArgSubst used in Assemble_Source() function
        //-----------------------------------------------------------------------------------
@@ -373,11 +462,33 @@ typedef struct r700_AssemblerBase
     SHADER_PIPE_TYPE currentShaderType;
     struct prog_instruction * pILInst;
     GLuint             uiCurInst;
+    GLubyte SamplerUnits[MAX_SAMPLERS];
     GLboolean   bR6xx;
     /* helper to decide which type of instruction to assemble */
     GLboolean is_tex;
     /* we inserted helper intructions and need barrier on next TEX ins */ 
     GLboolean need_tex_barrier; 
+
+    SUB_OFFSET     * subs;
+    GLuint           unSubArraySize;
+    GLuint           unSubArrayPointer;
+    CALLER_POINTER * callers;
+    GLuint           unCallerArraySize;
+    GLuint           unCallerArrayPointer;
+    unsigned int     CALLSP;
+    CALL_LEVEL       CALLSTACK[SQ_MAX_CALL_DEPTH];
+
+    GLuint unCFflags;
+
+    PRESUB_DESC * presubs;
+    GLuint        unPresubArraySize;
+    GLuint        unNumPresub;
+    GLuint        unCurNumILInsts;
+
+    GLuint    unVetTexBits;
+
+    GLuint    shadow_regs[R700_MAX_TEXTURE_UNITS];
+
 } r700_AssemblerBase;
 
 //Internal use
@@ -399,7 +510,7 @@ BITS is_depth_component_exported(OUT_FRAGMENT_FMT_0* pFPOutFmt) ;
 GLboolean is_reduction_opcode(PVSDWORD * dest);
 GLuint GetSurfaceFormat(GLenum eType, GLuint nChannels, GLuint * pClient_size);
 
-unsigned int r700GetNumOperands(r700_AssemblerBase* pAsm);
+unsigned int r700GetNumOperands(GLuint opcode, GLuint nIsOp3);
 
 GLboolean IsTex(gl_inst_opcode Opcode);
 GLboolean IsAlu(gl_inst_opcode Opcode);
@@ -422,6 +533,7 @@ GLboolean assemble_vfetch_instruction2(r700_AssemblerBase* pAsm,
                                        GLubyte             element,
                                        GLuint              _signed,
                                        GLboolean           normalize,
+                                       GLenum              format,
                                        VTX_FETCH_METHOD  * pFetchMethod);
 GLboolean cleanup_vfetch_instructions(r700_AssemblerBase* pAsm);
 GLuint gethelpr(r700_AssemblerBase* pAsm);
@@ -446,6 +558,10 @@ GLboolean assemble_alu_src(R700ALUInstruction*  alu_instruction_ptr,
 GLboolean add_alu_instruction(r700_AssemblerBase* pAsm,
                               R700ALUInstruction* alu_instruction_ptr,
                               GLuint              contiguous_slots_needed);
+
+GLboolean add_cf_instruction(r700_AssemblerBase* pAsm);
+void add_return_inst(r700_AssemblerBase *pAsm);
+
 void get_src_properties(R700ALUInstruction*  alu_instruction_ptr,
                         int                  source_index,
                         BITS*                psrc_sel,
@@ -467,21 +583,31 @@ GLboolean check_vector(r700_AssemblerBase* pAsm,
                        R700ALUInstruction* alu_instruction_ptr);
 GLboolean assemble_alu_instruction(r700_AssemblerBase *pAsm);
 GLboolean next_ins(r700_AssemblerBase *pAsm);
+
+GLboolean pops(r700_AssemblerBase *pAsm, GLuint pops);
+GLboolean jumpToOffest(r700_AssemblerBase *pAsm, GLuint pops, GLint offset);
+GLboolean setRetInLoopFlag(r700_AssemblerBase *pAsm, GLuint flagValue);
+GLboolean testFlag(r700_AssemblerBase *pAsm);
+GLboolean breakLoopOnFlag(r700_AssemblerBase *pAsm, GLuint unFCSP);
+GLboolean returnOnFlag(r700_AssemblerBase *pAsm, GLuint unIF);
+
 GLboolean assemble_math_function(r700_AssemblerBase* pAsm, BITS opcode);
 GLboolean assemble_ABS(r700_AssemblerBase *pAsm);
 GLboolean assemble_ADD(r700_AssemblerBase *pAsm);
+GLboolean assemble_ARL(r700_AssemblerBase *pAsm);
 GLboolean assemble_BAD(char *opcode_str);
 GLboolean assemble_CMP(r700_AssemblerBase *pAsm);
-GLboolean assemble_COS(r700_AssemblerBase *pAsm);
 GLboolean assemble_DOT(r700_AssemblerBase *pAsm);
 GLboolean assemble_DST(r700_AssemblerBase *pAsm);
 GLboolean assemble_EX2(r700_AssemblerBase *pAsm);
+GLboolean assemble_EXP(r700_AssemblerBase *pAsm);
 GLboolean assemble_FLR(r700_AssemblerBase *pAsm);
 GLboolean assemble_FLR_INT(r700_AssemblerBase *pAsm);
 GLboolean assemble_FRC(r700_AssemblerBase *pAsm);
-GLboolean assemble_KIL(r700_AssemblerBase *pAsm);
+GLboolean assemble_KIL(r700_AssemblerBase *pAsm, GLuint opcode);
 GLboolean assemble_LG2(r700_AssemblerBase *pAsm);
 GLboolean assemble_LRP(r700_AssemblerBase *pAsm);
+GLboolean assemble_LOG(r700_AssemblerBase *pAsm);
 GLboolean assemble_MAD(r700_AssemblerBase *pAsm);
 GLboolean assemble_LIT(r700_AssemblerBase *pAsm);
 GLboolean assemble_MAX(r700_AssemblerBase *pAsm);
@@ -491,17 +617,37 @@ GLboolean assemble_MUL(r700_AssemblerBase *pAsm);
 GLboolean assemble_POW(r700_AssemblerBase *pAsm);
 GLboolean assemble_RCP(r700_AssemblerBase *pAsm);
 GLboolean assemble_RSQ(r700_AssemblerBase *pAsm);
-GLboolean assemble_SIN(r700_AssemblerBase *pAsm);
 GLboolean assemble_SCS(r700_AssemblerBase *pAsm);
 GLboolean assemble_SGE(r700_AssemblerBase *pAsm);
+
+GLboolean assemble_LOGIC(r700_AssemblerBase *pAsm, BITS opcode);
+GLboolean assemble_LOGIC_PRED(r700_AssemblerBase *pAsm, BITS opcode); 
+GLboolean assemble_TRIG(r700_AssemblerBase *pAsm, BITS opcode);
+
 GLboolean assemble_SLT(r700_AssemblerBase *pAsm);
 GLboolean assemble_STP(r700_AssemblerBase *pAsm);
 GLboolean assemble_TEX(r700_AssemblerBase *pAsm);
 GLboolean assemble_XPD(r700_AssemblerBase *pAsm);
 GLboolean assemble_EXPORT(r700_AssemblerBase *pAsm);
-GLboolean assemble_IF(r700_AssemblerBase *pAsm);
+GLboolean assemble_IF(r700_AssemblerBase *pAsm, GLboolean bHasElse);
+GLboolean assemble_ELSE(r700_AssemblerBase *pAsm);
 GLboolean assemble_ENDIF(r700_AssemblerBase *pAsm);
 
+GLboolean assemble_BGNLOOP(r700_AssemblerBase *pAsm);
+GLboolean assemble_BRK(r700_AssemblerBase *pAsm);
+GLboolean assemble_COND(r700_AssemblerBase *pAsm);
+GLboolean assemble_ENDLOOP(r700_AssemblerBase *pAsm);
+
+GLboolean assemble_BGNSUB(r700_AssemblerBase *pAsm, GLint nILindex, GLuint uiIL_Shift);
+GLboolean assemble_ENDSUB(r700_AssemblerBase *pAsm);
+GLboolean assemble_RET(r700_AssemblerBase *pAsm);
+GLboolean assemble_CAL(r700_AssemblerBase *pAsm, 
+                       GLint nILindex,
+                       GLuint uiIL_Offest,
+                       GLuint uiNumberInsts,
+                       struct prog_instruction *pILInst,
+                       PRESUB_DESC * pPresubDesc);
+
 GLboolean Process_Export(r700_AssemblerBase* pAsm,
                          GLuint type, 
                          GLuint export_starting_index,
@@ -511,14 +657,25 @@ GLboolean Process_Export(r700_AssemblerBase* pAsm,
 GLboolean Move_Depth_Exports_To_Correct_Channels(r700_AssemblerBase *pAsm, 
                                                  BITS depth_channel_select);
 
+GLboolean callPreSub(r700_AssemblerBase* pAsm, 
+                     LOADABLE_SCRIPT_SIGNITURE scriptSigniture,
+                     /* struct prog_instruction ** pILInstParent, */
+                     COMPILED_SUB * pCompiledSub,                                            
+                     GLshort uOutReg,
+                     GLshort uNumValidSrc);
 
 //Interface
-GLboolean AssembleInstr(GLuint uiNumberInsts,
+GLboolean AssembleInstr(GLuint uiFirstInst,
+                        GLuint uiIL_Shift,
+                        GLuint uiNumberInsts,
                         struct prog_instruction *pILInst, 
                                                r700_AssemblerBase *pR700AsmCode);
 GLboolean Process_Fragment_Exports(r700_AssemblerBase *pR700AsmCode, GLbitfield OutputsWritten);  
 GLboolean Process_Vertex_Exports(r700_AssemblerBase *pR700AsmCode, GLbitfield OutputsWritten);
 
+GLboolean RelocProgram(r700_AssemblerBase * pAsm, struct gl_program * pILProg);
+GLboolean InitShaderProgram(r700_AssemblerBase * pAsm);
+
 int       Init_r700_AssemblerBase(SHADER_PIPE_TYPE spt, r700_AssemblerBase* pAsm, R700_Shader* pShader);
 GLboolean Clean_Up_Assembler(r700_AssemblerBase *pR700AsmCode);
 
index 3b7f6fffe0388790a045584487d42755ed750270..3bc2d2ba02b44658fa4fee54c05654a3a4d925b2 100644 (file)
@@ -45,6 +45,9 @@ static void r700SendTexState(GLcontext *ctx, struct radeon_state_atom *atom)
 {
        context_t         *context = R700_CONTEXT(ctx);
        R700_CHIP_CONTEXT *r700 = (R700_CHIP_CONTEXT*)(&context->hw);
+
+    struct r700_vertex_program *vp = context->selected_vp;
+
        struct radeon_bo *bo = NULL;
        unsigned int i;
        BATCH_LOCALS(&context->radeon);
@@ -52,13 +55,14 @@ static void r700SendTexState(GLcontext *ctx, struct radeon_state_atom *atom)
        radeon_print(RADEON_STATE, RADEON_VERBOSE, "%s\n", __func__);
 
        for (i = 0; i < R700_TEXTURE_NUMBERUNITS; i++) {
-               if (ctx->Texture.Unit[i]._ReallyEnabled) {
+               if (ctx->Texture.Unit[i]._ReallyEnabled) {            
                        radeonTexObj *t = r700->textures[i];
                        if (t) {
-                               if (!t->image_override)
+                               if (!t->image_override) {
                                        bo = t->mt->bo;
-                               else
+                               } else {
                                        bo = t->bo;
+                               }
                                if (bo) {
 
                                        r700SyncSurf(context, bo,
@@ -67,7 +71,16 @@ static void r700SendTexState(GLcontext *ctx, struct radeon_state_atom *atom)
 
                                        BEGIN_BATCH_NO_AUTOSTATE(9 + 4);
                                        R600_OUT_BATCH(CP_PACKET3(R600_IT_SET_RESOURCE, 7));
-                                       R600_OUT_BATCH(i * 7);
+
+                    if( (1<<i) & vp->r700AsmCode.unVetTexBits )                    
+                    {   /* vs texture */                                     
+                        R600_OUT_BATCH((i + VERT_ATTRIB_MAX + SQ_FETCH_RESOURCE_VS_OFFSET) * FETCH_RESOURCE_STRIDE);
+                    }
+                    else
+                    {
+                                           R600_OUT_BATCH(i * 7);
+                    }
+
                                        R600_OUT_BATCH(r700->textures[i]->SQ_TEX_RESOURCE0);
                                        R600_OUT_BATCH(r700->textures[i]->SQ_TEX_RESOURCE1);
                                        R600_OUT_BATCH(r700->textures[i]->SQ_TEX_RESOURCE2);
@@ -77,7 +90,7 @@ static void r700SendTexState(GLcontext *ctx, struct radeon_state_atom *atom)
                                        R600_OUT_BATCH(r700->textures[i]->SQ_TEX_RESOURCE6);
                                        R600_OUT_BATCH_RELOC(r700->textures[i]->SQ_TEX_RESOURCE2,
                                                             bo,
-                                                            0,
+                                                            r700->textures[i]->SQ_TEX_RESOURCE2,
                                                             RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0, 0);
                                        R600_OUT_BATCH_RELOC(r700->textures[i]->SQ_TEX_RESOURCE3,
                                                             bo,
@@ -91,21 +104,35 @@ static void r700SendTexState(GLcontext *ctx, struct radeon_state_atom *atom)
        }
 }
 
+#define SAMPLER_STRIDE                 3
+
 static void r700SendTexSamplerState(GLcontext *ctx, struct radeon_state_atom *atom)
 {
        context_t         *context = R700_CONTEXT(ctx);
        R700_CHIP_CONTEXT *r700 = (R700_CHIP_CONTEXT*)(&context->hw);
        unsigned int i;
+
+    struct r700_vertex_program *vp = context->selected_vp;
+
        BATCH_LOCALS(&context->radeon);
        radeon_print(RADEON_STATE, RADEON_VERBOSE, "%s\n", __func__);
 
        for (i = 0; i < R700_TEXTURE_NUMBERUNITS; i++) {
-               if (ctx->Texture.Unit[i]._ReallyEnabled) {
+               if (ctx->Texture.Unit[i]._ReallyEnabled) {            
                        radeonTexObj *t = r700->textures[i];
                        if (t) {
                                BEGIN_BATCH_NO_AUTOSTATE(5);
                                R600_OUT_BATCH(CP_PACKET3(R600_IT_SET_SAMPLER, 3));
-                               R600_OUT_BATCH(i * 3);
+
+                if( (1<<i) & vp->r700AsmCode.unVetTexBits )                    
+                {   /* vs texture */
+                    R600_OUT_BATCH((i+SQ_TEX_SAMPLER_VS_OFFSET) * SAMPLER_STRIDE); //work 1
+                }
+                else
+                {
+                                   R600_OUT_BATCH(i * 3);
+                }
+
                                R600_OUT_BATCH(r700->textures[i]->SQ_TEX_SAMPLER0);
                                R600_OUT_BATCH(r700->textures[i]->SQ_TEX_SAMPLER1);
                                R600_OUT_BATCH(r700->textures[i]->SQ_TEX_SAMPLER2);
@@ -141,77 +168,10 @@ static void r700SendTexBorderColorState(GLcontext *ctx, struct radeon_state_atom
        }
 }
 
+extern int getTypeSize(GLenum type);
 static void r700SetupVTXConstants(GLcontext  * ctx,
-                                 unsigned int nStreamID,
                                  void *       pAos,
-                                 unsigned int size,      /* number of elements in vector */
-                                 unsigned int stride,
-                                 unsigned int count)     /* number of vectors in stream */
-{
-    context_t *context = R700_CONTEXT(ctx);
-    struct radeon_aos * paos = (struct radeon_aos *)pAos;
-    BATCH_LOCALS(&context->radeon);
-    radeon_print(RADEON_STATE, RADEON_VERBOSE, "%s\n", __func__);
-
-    unsigned int uSQ_VTX_CONSTANT_WORD0_0;
-    unsigned int uSQ_VTX_CONSTANT_WORD1_0;
-    unsigned int uSQ_VTX_CONSTANT_WORD2_0 = 0;
-    unsigned int uSQ_VTX_CONSTANT_WORD3_0 = 0;
-    unsigned int uSQ_VTX_CONSTANT_WORD6_0 = 0;
-
-    if (!paos->bo)
-           return;
-
-    if ((context->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV610) ||
-       (context->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV620) ||
-       (context->radeon.radeonScreen->chip_family == CHIP_FAMILY_RS780) ||
-       (context->radeon.radeonScreen->chip_family == CHIP_FAMILY_RS880) ||
-       (context->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV710))
-           r700SyncSurf(context, paos->bo, RADEON_GEM_DOMAIN_GTT, 0, TC_ACTION_ENA_bit);
-    else
-           r700SyncSurf(context, paos->bo, RADEON_GEM_DOMAIN_GTT, 0, VC_ACTION_ENA_bit);
-
-    uSQ_VTX_CONSTANT_WORD0_0 = paos->offset;
-    uSQ_VTX_CONSTANT_WORD1_0 = count * (size * 4) - 1;
-
-    SETfield(uSQ_VTX_CONSTANT_WORD2_0, 0, BASE_ADDRESS_HI_shift, BASE_ADDRESS_HI_mask); /* TODO */
-    SETfield(uSQ_VTX_CONSTANT_WORD2_0, stride, SQ_VTX_CONSTANT_WORD2_0__STRIDE_shift,
-            SQ_VTX_CONSTANT_WORD2_0__STRIDE_mask);
-    SETfield(uSQ_VTX_CONSTANT_WORD2_0, GetSurfaceFormat(GL_FLOAT, size, NULL),
-            SQ_VTX_CONSTANT_WORD2_0__DATA_FORMAT_shift,
-            SQ_VTX_CONSTANT_WORD2_0__DATA_FORMAT_mask); /* TODO : trace back api for initial data type, not only GL_FLOAT */
-    SETfield(uSQ_VTX_CONSTANT_WORD2_0, SQ_NUM_FORMAT_SCALED,
-            SQ_VTX_CONSTANT_WORD2_0__NUM_FORMAT_ALL_shift, SQ_VTX_CONSTANT_WORD2_0__NUM_FORMAT_ALL_mask);
-    SETbit(uSQ_VTX_CONSTANT_WORD2_0, SQ_VTX_CONSTANT_WORD2_0__FORMAT_COMP_ALL_bit);
-
-    SETfield(uSQ_VTX_CONSTANT_WORD3_0, 1, MEM_REQUEST_SIZE_shift, MEM_REQUEST_SIZE_mask);
-    SETfield(uSQ_VTX_CONSTANT_WORD6_0, SQ_TEX_VTX_VALID_BUFFER,
-            SQ_TEX_RESOURCE_WORD6_0__TYPE_shift, SQ_TEX_RESOURCE_WORD6_0__TYPE_mask);
-
-    BEGIN_BATCH_NO_AUTOSTATE(9 + 2);
-
-    R600_OUT_BATCH(CP_PACKET3(R600_IT_SET_RESOURCE, 7));
-    R600_OUT_BATCH((nStreamID + SQ_FETCH_RESOURCE_VS_OFFSET) * FETCH_RESOURCE_STRIDE);
-    R600_OUT_BATCH(uSQ_VTX_CONSTANT_WORD0_0);
-    R600_OUT_BATCH(uSQ_VTX_CONSTANT_WORD1_0);
-    R600_OUT_BATCH(uSQ_VTX_CONSTANT_WORD2_0);
-    R600_OUT_BATCH(uSQ_VTX_CONSTANT_WORD3_0);
-    R600_OUT_BATCH(0);
-    R600_OUT_BATCH(0);
-    R600_OUT_BATCH(uSQ_VTX_CONSTANT_WORD6_0);
-    R600_OUT_BATCH_RELOC(uSQ_VTX_CONSTANT_WORD0_0,
-                         paos->bo,
-                         uSQ_VTX_CONSTANT_WORD0_0,
-                         RADEON_GEM_DOMAIN_GTT, 0, 0);
-    END_BATCH();
-    COMMIT_BATCH();
-
-}
-
-extern int getTypeSize(GLenum type);
-static void r700SetupVTXConstants2(GLcontext  * ctx,
-                                                  void *       pAos,
-                                   StreamDesc * pStreamDesc)     
+                                 StreamDesc * pStreamDesc)
 {
     context_t *context = R700_CONTEXT(ctx);
     struct radeon_aos * paos = (struct radeon_aos *)pAos;
@@ -295,31 +255,6 @@ static void r700SetupVTXConstants2(GLcontext  * ctx,
 
 }
 
-void r700SetupStreams(GLcontext *ctx)
-{
-    context_t         *context = R700_CONTEXT(ctx);
-    struct r700_vertex_program *vp = context->selected_vp;
-    TNLcontext *tnl = TNL_CONTEXT(ctx);
-    struct vertex_buffer *vb = &tnl->vb;
-    unsigned int i, j = 0;
-       radeon_print(RADEON_STATE, RADEON_VERBOSE, "%s\n", __func__);
-
-    R600_STATECHANGE(context, vtx);
-
-    for(i=0; i<VERT_ATTRIB_MAX; i++) {
-           if(vp->mesa_program->Base.InputsRead & (1 << i)) {
-                   rcommon_emit_vector(ctx,
-                                       &context->radeon.tcl.aos[j],
-                                       vb->AttribPtr[i]->data,
-                                       vb->AttribPtr[i]->size,
-                                       vb->AttribPtr[i]->stride,
-                                       vb->Count);
-                   j++;
-           }
-    }
-    context->radeon.tcl.aos_count = j;
-}
-
 static void r700SendVTXState(GLcontext *ctx, struct radeon_state_atom *atom)
 {
     context_t         *context = R700_CONTEXT(ctx);
@@ -343,25 +278,12 @@ static void r700SendVTXState(GLcontext *ctx, struct radeon_state_atom *atom)
     COMMIT_BATCH();
 
     for(i=0; i<VERT_ATTRIB_MAX; i++) {
-           if(vp->mesa_program->Base.InputsRead & (1 << i)) 
-        {
-                   if(1 == context->selected_vp->uiVersion)
-            {
-                       /* currently aos are packed */
-                       r700SetupVTXConstants(ctx,
-                                             i,
-                                             (void*)(&context->radeon.tcl.aos[j]),
-                                             (unsigned int)context->radeon.tcl.aos[j].components,
-                                             (unsigned int)context->radeon.tcl.aos[j].stride * 4,
-                                             (unsigned int)context->radeon.tcl.aos[j].count);
-            }
-            else
-            {   /* context->selected_vp->uiVersion == 2 : aos not always packed */                
-                r700SetupVTXConstants2(ctx,                                        
-                                             (void*)(&context->radeon.tcl.aos[j]),
-                                             &(context->stream_desc[j]));
-            }
-                   j++;
+           if(vp->mesa_program->Base.InputsRead & (1 << i))
+           {
+                r700SetupVTXConstants(ctx,
+                                     (void*)(&context->radeon.tcl.aos[j]),
+                                     &(context->stream_desc[j]));
+               j++;
            }
     }
 }
@@ -463,7 +385,6 @@ static void r700SendDepthTargetState(GLcontext *ctx, struct radeon_state_atom *a
 
        rrb = radeon_get_depthbuffer(&context->radeon);
        if (!rrb || !rrb->bo) {
-               fprintf(stderr, "no rrb\n");
                return;
        }
 
@@ -505,7 +426,6 @@ static void r700SendRenderTargetState(GLcontext *ctx, struct radeon_state_atom *
 
        rrb = radeon_get_colorbuffer(&context->radeon);
        if (!rrb || !rrb->bo) {
-               fprintf(stderr, "no rrb\n");
                return;
        }
 
@@ -549,68 +469,77 @@ static void r700SendRenderTargetState(GLcontext *ctx, struct radeon_state_atom *
 
 static void r700SendPSState(GLcontext *ctx, struct radeon_state_atom *atom)
 {
-       context_t *context = R700_CONTEXT(ctx);
-       R700_CHIP_CONTEXT *r700 = R700_CONTEXT_STATES(context);
-       struct radeon_bo * pbo;
-       BATCH_LOCALS(&context->radeon);
-       radeon_print(RADEON_STATE, RADEON_VERBOSE, "%s\n", __func__);
+    context_t *context = R700_CONTEXT(ctx);
+    R700_CHIP_CONTEXT *r700 = R700_CONTEXT_STATES(context);
+    struct radeon_bo * pbo;
+    BATCH_LOCALS(&context->radeon);
+    radeon_print(RADEON_STATE, RADEON_VERBOSE, "%s\n", __func__);
 
-       pbo = (struct radeon_bo *)r700GetActiveFpShaderBo(GL_CONTEXT(context));
+    pbo = (struct radeon_bo *)r700GetActiveFpShaderBo(GL_CONTEXT(context));
 
-       if (!pbo)
-               return;
+    if (!pbo)
+           return;
 
-       r700SyncSurf(context, pbo, RADEON_GEM_DOMAIN_GTT, 0, SH_ACTION_ENA_bit);
+    r700SyncSurf(context, pbo, RADEON_GEM_DOMAIN_GTT, 0, SH_ACTION_ENA_bit);
 
-        BEGIN_BATCH_NO_AUTOSTATE(3 + 2);
-       R600_OUT_BATCH_REGSEQ(SQ_PGM_START_PS, 1);
-       R600_OUT_BATCH(r700->ps.SQ_PGM_START_PS.u32All);
-       R600_OUT_BATCH_RELOC(r700->ps.SQ_PGM_START_PS.u32All,
-                            pbo,
-                            r700->ps.SQ_PGM_START_PS.u32All,
-                            RADEON_GEM_DOMAIN_GTT, 0, 0);
-       END_BATCH();
+    BEGIN_BATCH_NO_AUTOSTATE(3 + 2);
+    R600_OUT_BATCH_REGSEQ(SQ_PGM_START_PS, 1);
+    R600_OUT_BATCH(r700->ps.SQ_PGM_START_PS.u32All);
+    R600_OUT_BATCH_RELOC(r700->ps.SQ_PGM_START_PS.u32All,
+                        pbo,
+                        r700->ps.SQ_PGM_START_PS.u32All,
+                        RADEON_GEM_DOMAIN_GTT, 0, 0);
+    END_BATCH();
 
-        BEGIN_BATCH_NO_AUTOSTATE(9);
-       R600_OUT_BATCH_REGVAL(SQ_PGM_RESOURCES_PS, r700->ps.SQ_PGM_RESOURCES_PS.u32All);
-       R600_OUT_BATCH_REGVAL(SQ_PGM_EXPORTS_PS, r700->ps.SQ_PGM_EXPORTS_PS.u32All);
-       R600_OUT_BATCH_REGVAL(SQ_PGM_CF_OFFSET_PS, r700->ps.SQ_PGM_CF_OFFSET_PS.u32All);
-        END_BATCH();
+    BEGIN_BATCH_NO_AUTOSTATE(9);
+    R600_OUT_BATCH_REGVAL(SQ_PGM_RESOURCES_PS, r700->ps.SQ_PGM_RESOURCES_PS.u32All);
+    R600_OUT_BATCH_REGVAL(SQ_PGM_EXPORTS_PS, r700->ps.SQ_PGM_EXPORTS_PS.u32All);
+    R600_OUT_BATCH_REGVAL(SQ_PGM_CF_OFFSET_PS, r700->ps.SQ_PGM_CF_OFFSET_PS.u32All);
+    END_BATCH();
 
-       COMMIT_BATCH();
+    BEGIN_BATCH_NO_AUTOSTATE(3);
+    R600_OUT_BATCH_REGVAL(SQ_LOOP_CONST_0, 0x01000FFF);
+    END_BATCH();
+
+    COMMIT_BATCH();
 
 }
 
 static void r700SendVSState(GLcontext *ctx, struct radeon_state_atom *atom)
 {
-       context_t *context = R700_CONTEXT(ctx);
-       R700_CHIP_CONTEXT *r700 = R700_CONTEXT_STATES(context);
-       struct radeon_bo * pbo;
-       BATCH_LOCALS(&context->radeon);
-       radeon_print(RADEON_STATE, RADEON_VERBOSE, "%s\n", __func__);
+    context_t *context = R700_CONTEXT(ctx);
+    R700_CHIP_CONTEXT *r700 = R700_CONTEXT_STATES(context);
+    struct radeon_bo * pbo;
+    BATCH_LOCALS(&context->radeon);
+    radeon_print(RADEON_STATE, RADEON_VERBOSE, "%s\n", __func__);
 
-       pbo = (struct radeon_bo *)r700GetActiveVpShaderBo(GL_CONTEXT(context));
+    pbo = (struct radeon_bo *)r700GetActiveVpShaderBo(GL_CONTEXT(context));
 
-       if (!pbo)
-               return;
+    if (!pbo)
+           return;
 
-       r700SyncSurf(context, pbo, RADEON_GEM_DOMAIN_GTT, 0, SH_ACTION_ENA_bit);
+    r700SyncSurf(context, pbo, RADEON_GEM_DOMAIN_GTT, 0, SH_ACTION_ENA_bit);
 
-        BEGIN_BATCH_NO_AUTOSTATE(3 + 2);
-       R600_OUT_BATCH_REGSEQ(SQ_PGM_START_VS, 1);
-       R600_OUT_BATCH(r700->vs.SQ_PGM_START_VS.u32All);
-       R600_OUT_BATCH_RELOC(r700->vs.SQ_PGM_START_VS.u32All,
-                            pbo,
-                            r700->vs.SQ_PGM_START_VS.u32All,
-                            RADEON_GEM_DOMAIN_GTT, 0, 0);
-       END_BATCH();
+    BEGIN_BATCH_NO_AUTOSTATE(3 + 2);
+    R600_OUT_BATCH_REGSEQ(SQ_PGM_START_VS, 1);
+    R600_OUT_BATCH(r700->vs.SQ_PGM_START_VS.u32All);
+    R600_OUT_BATCH_RELOC(r700->vs.SQ_PGM_START_VS.u32All,
+                        pbo,
+                        r700->vs.SQ_PGM_START_VS.u32All,
+                        RADEON_GEM_DOMAIN_GTT, 0, 0);
+    END_BATCH();
 
-        BEGIN_BATCH_NO_AUTOSTATE(6);
-       R600_OUT_BATCH_REGVAL(SQ_PGM_RESOURCES_VS, r700->vs.SQ_PGM_RESOURCES_VS.u32All);
-       R600_OUT_BATCH_REGVAL(SQ_PGM_CF_OFFSET_VS, r700->vs.SQ_PGM_CF_OFFSET_VS.u32All);
-        END_BATCH();
+    BEGIN_BATCH_NO_AUTOSTATE(6);
+    R600_OUT_BATCH_REGVAL(SQ_PGM_RESOURCES_VS, r700->vs.SQ_PGM_RESOURCES_VS.u32All);
+    R600_OUT_BATCH_REGVAL(SQ_PGM_CF_OFFSET_VS, r700->vs.SQ_PGM_CF_OFFSET_VS.u32All);
+    END_BATCH();
 
-       COMMIT_BATCH();
+    BEGIN_BATCH_NO_AUTOSTATE(3);
+    R600_OUT_BATCH_REGVAL((SQ_LOOP_CONST_0 + 32*4), 0x0100000F);
+    //R600_OUT_BATCH_REGVAL((SQ_LOOP_CONST_0 + (SQ_LOOP_CONST_vs<2)), 0x0100000F);
+    END_BATCH();
+
+    COMMIT_BATCH();
 }
 
 static void r700SendFSState(GLcontext *ctx, struct radeon_state_atom *atom)
@@ -891,8 +820,7 @@ static void r700SendDBState(GLcontext *ctx, struct radeon_state_atom *atom)
        BATCH_LOCALS(&context->radeon);
        radeon_print(RADEON_STATE, RADEON_VERBOSE, "%s\n", __func__);
 
-        BEGIN_BATCH_NO_AUTOSTATE(23);
-       R600_OUT_BATCH_REGVAL(DB_HTILE_DATA_BASE, r700->DB_HTILE_DATA_BASE.u32All);
+       BEGIN_BATCH_NO_AUTOSTATE(17);
 
        R600_OUT_BATCH_REGSEQ(DB_STENCIL_CLEAR, 2);
        R600_OUT_BATCH(r700->DB_STENCIL_CLEAR.u32All);
@@ -905,7 +833,6 @@ static void r700SendDBState(GLcontext *ctx, struct radeon_state_atom *atom)
        R600_OUT_BATCH(r700->DB_RENDER_CONTROL.u32All);
        R600_OUT_BATCH(r700->DB_RENDER_OVERRIDE.u32All);
 
-       R600_OUT_BATCH_REGVAL(DB_HTILE_SURFACE, r700->DB_HTILE_SURFACE.u32All);
        R600_OUT_BATCH_REGVAL(DB_ALPHA_TO_MASK, r700->DB_ALPHA_TO_MASK.u32All);
 
        END_BATCH();
@@ -1205,6 +1132,32 @@ static void r700SendVSConsts(GLcontext *ctx, struct radeon_state_atom *atom)
        COMMIT_BATCH();
 }
 
+static void r700SendQueryBegin(GLcontext *ctx, struct radeon_state_atom *atom)
+{
+       radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+       struct radeon_query_object *query = radeon->query.current;
+       BATCH_LOCALS(radeon);
+       radeon_print(RADEON_STATE, RADEON_VERBOSE, "%s\n", __func__);
+
+       /* clear the buffer */
+       radeon_bo_map(query->bo, GL_FALSE);
+       memset(query->bo->ptr, 0, 4 * 2 * sizeof(uint64_t)); /* 4 DBs, 2 qwords each */
+       radeon_bo_unmap(query->bo);
+
+       radeon_cs_space_check_with_bo(radeon->cmdbuf.cs,
+                                     query->bo,
+                                     0, RADEON_GEM_DOMAIN_GTT);
+
+       BEGIN_BATCH_NO_AUTOSTATE(4 + 2);
+       R600_OUT_BATCH(CP_PACKET3(R600_IT_EVENT_WRITE, 2));
+       R600_OUT_BATCH(ZPASS_DONE);
+       R600_OUT_BATCH(query->curr_offset); /* hw writes qwords */
+       R600_OUT_BATCH(0x00000000);
+       R600_OUT_BATCH_RELOC(VGT_EVENT_INITIATOR, query->bo, 0, 0, RADEON_GEM_DOMAIN_GTT, 0);
+       END_BATCH();
+       query->emitted_begin = GL_TRUE;
+}
+
 static int check_always(GLcontext *ctx, struct radeon_state_atom *atom)
 {
        return atom->cmd_size;
@@ -1233,7 +1186,11 @@ static int check_blnd(GLcontext *ctx, struct radeon_state_atom *atom)
                count += 3;
 
        if (context->radeon.radeonScreen->chip_family > CHIP_FAMILY_R600) {
-               for (ui = 0; ui < R700_MAX_RENDER_TARGETS; ui++) {
+               /* targets are enabled in r700SetRenderTarget but state
+                  size is calculated before that. Until MRT's are done
+                  hardcode target0 as enabled. */
+               count += 3;
+               for (ui = 1; ui < R700_MAX_RENDER_TARGETS; ui++) {
                         if (r700->render_target[ui].enabled)
                                count += 3;
                }
@@ -1313,6 +1270,20 @@ static int check_vs_consts(GLcontext *ctx, struct radeon_state_atom *atom)
        return count;
 }
 
+static int check_queryobj(GLcontext *ctx, struct radeon_state_atom *atom)
+{
+       radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+       struct radeon_query_object *query = radeon->query.current;
+       int count;
+
+       if (!query || query->emitted_begin)
+               count = 0;
+       else
+               count = atom->cmd_size;
+       radeon_print(RADEON_STATE, RADEON_TRACE, "%s %d\n", __func__, count);
+       return count;
+}
+
 #define ALLOC_STATE( ATOM, CHK, SZ, EMIT )                             \
 do {                                                                   \
        context->atoms.ATOM.cmd_size = (SZ);                            \
@@ -1326,6 +1297,19 @@ do {                                                                     \
        insert_at_tail(&context->radeon.hw.atomlist, &context->atoms.ATOM); \
 } while (0)
 
+static void r600_init_query_stateobj(radeonContextPtr radeon, int SZ)
+{
+       radeon->query.queryobj.cmd_size = (SZ);
+       radeon->query.queryobj.cmd = NULL;
+       radeon->query.queryobj.name = "queryobj";
+       radeon->query.queryobj.idx = 0;
+       radeon->query.queryobj.check = check_queryobj;
+       radeon->query.queryobj.dirty = GL_FALSE;
+       radeon->query.queryobj.emit = r700SendQueryBegin;
+       radeon->hw.max_state_size += (SZ);
+       insert_at_tail(&radeon->hw.atomlist, &radeon->query.queryobj);
+}
+
 void r600InitAtoms(context_t *context)
 {
        radeon_print(RADEON_STATE, RADEON_NORMAL, "%s %p\n", __func__, context);
@@ -1336,7 +1320,7 @@ void r600InitAtoms(context_t *context)
        context->radeon.hw.atomlist.name = "atom-list";
 
        ALLOC_STATE(sq, always, 34, r700SendSQConfig);
-       ALLOC_STATE(db, always, 23, r700SendDBState);
+       ALLOC_STATE(db, always, 17, r700SendDBState);
        ALLOC_STATE(stencil, always, 4, r700SendStencilState);
        ALLOC_STATE(db_target, always, 12, r700SendDepthTargetState);
        ALLOC_STATE(sc, always, 15, r700SendSCState);
@@ -1349,22 +1333,23 @@ void r600InitAtoms(context_t *context)
        ALLOC_STATE(poly, always, 10, r700SendPolyState);
        ALLOC_STATE(cb, cb, 18, r700SendCBState);
        ALLOC_STATE(clrcmp, always, 6, r700SendCBCLRCMPState);
+       ALLOC_STATE(cb_target, always, 25, r700SendRenderTargetState);
        ALLOC_STATE(blnd, blnd, (6 + (R700_MAX_RENDER_TARGETS * 3)), r700SendCBBlendState);
        ALLOC_STATE(blnd_clr, always, 6, r700SendCBBlendColorState);
-       ALLOC_STATE(cb_target, always, 25, r700SendRenderTargetState);
        ALLOC_STATE(sx, always, 9, r700SendSXState);
        ALLOC_STATE(vgt, always, 41, r700SendVGTState);
        ALLOC_STATE(spi, always, (59 + R700_MAX_SHADER_EXPORTS), r700SendSPIState);
        ALLOC_STATE(vpt, always, 16, r700SendViewportState);
        ALLOC_STATE(fs, always, 18, r700SendFSState);
-       ALLOC_STATE(vs, always, 18, r700SendVSState);
-       ALLOC_STATE(ps, always, 21, r700SendPSState);
+       ALLOC_STATE(vs, always, 21, r700SendVSState);
+       ALLOC_STATE(ps, always, 24, r700SendPSState);
        ALLOC_STATE(vs_consts, vs_consts, (2 + (R700_MAX_DX9_CONSTS * 4)), r700SendVSConsts);
        ALLOC_STATE(ps_consts, ps_consts, (2 + (R700_MAX_DX9_CONSTS * 4)), r700SendPSConsts);
        ALLOC_STATE(vtx, vtx, (6 + (VERT_ATTRIB_MAX * 18)), r700SendVTXState);
        ALLOC_STATE(tx, tx, (R700_TEXTURE_NUMBERUNITS * 20), r700SendTexState);
        ALLOC_STATE(tx_smplr, tx, (R700_TEXTURE_NUMBERUNITS * 5), r700SendTexSamplerState);
        ALLOC_STATE(tx_brdr_clr, tx, (R700_TEXTURE_NUMBERUNITS * 6), r700SendTexBorderColorState);
+       r600_init_query_stateobj(&context->radeon, 6 * 2);
 
        context->radeon.hw.is_dirty = GL_TRUE;
        context->radeon.hw.all_dirty = GL_TRUE;
index c6546ab00c2e674daa81dd18e7949d33fc173103..98bfdd0937ccd6e0362ed3908f7fbeb012a4fe31 100644 (file)
@@ -49,14 +49,18 @@ static GLboolean r700ClearFast(context_t *context, GLbitfield mask)
 void r700Clear(GLcontext * ctx, GLbitfield mask)
 {
     context_t *context = R700_CONTEXT(ctx);
-    __DRIdrawablePrivate *dPriv = radeon_get_drawable(&context->radeon);
-    const GLuint colorMask = *((GLuint *) & ctx->Color.ColorMask);
+    __DRIdrawable *dPriv = radeon_get_drawable(&context->radeon);
+    const GLuint colorMask = *((GLuint *) & ctx->Color.ColorMask[0]);
     GLbitfield swrast_mask = 0, tri_mask = 0;
     int i;
     struct gl_framebuffer *fb = ctx->DrawBuffer;
 
     radeon_print(RADEON_RENDER, RADEON_VERBOSE, "%s %x\n", __func__, mask);
 
+    if (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_FRONT_RIGHT)) {
+        context->radeon.front_buffer_dirty = GL_TRUE;
+    }
+
     if( GL_TRUE == r700ClearFast(context, mask) )
     {
         return;
index 62a1ea1a22abd9b0fff2aaaf6e26e76fabd4b144..84d51e66069fd69d0dc671e0231513088e80f14a 100644 (file)
@@ -34,6 +34,7 @@
 #include "main/imports.h"
 #include "shader/prog_parameter.h"
 #include "shader/prog_statevars.h"
+#include "shader/program.h"
 
 #include "r600_context.h"
 #include "r600_cmdbuf.h"
 
 #include "r700_debug.h"
 
+void insert_wpos_code(GLcontext *ctx, struct gl_fragment_program *fprog)
+{
+    static const gl_state_index winstate[STATE_LENGTH]
+         = { STATE_INTERNAL, STATE_FB_SIZE, 0, 0, 0};
+    struct prog_instruction *newInst, *inst;
+    GLint  win_size;  /* state reference */
+    GLuint wpos_temp; /* temp register */
+    int i, j;
+
+    /* PARAM win_size = STATE_FB_SIZE */
+    win_size = _mesa_add_state_reference(fprog->Base.Parameters, winstate);
+
+    wpos_temp = fprog->Base.NumTemporaries++;
+
+    /* scan program where WPOS is used and replace with wpos_temp */
+    inst = fprog->Base.Instructions;
+    for (i = 0; i < fprog->Base.NumInstructions; i++) {
+        for (j=0; j < 3; j++) {
+            if(inst->SrcReg[j].File == PROGRAM_INPUT && 
+               inst->SrcReg[j].Index == FRAG_ATTRIB_WPOS) {
+                inst->SrcReg[j].File = PROGRAM_TEMPORARY;
+                inst->SrcReg[j].Index = wpos_temp;
+            }
+        }
+        inst++;
+    }
+
+    _mesa_insert_instructions(&(fprog->Base), 0, 1);
+
+    newInst = fprog->Base.Instructions;
+    /* invert wpos.y
+     * wpos_temp.xyzw = wpos.x-yzw + winsize.0y00 */
+    newInst[0].Opcode = OPCODE_ADD;
+    newInst[0].DstReg.File = PROGRAM_TEMPORARY;
+    newInst[0].DstReg.Index = wpos_temp;
+    newInst[0].DstReg.WriteMask = WRITEMASK_XYZW;
+
+    newInst[0].SrcReg[0].File = PROGRAM_INPUT;
+    newInst[0].SrcReg[0].Index = FRAG_ATTRIB_WPOS;
+    newInst[0].SrcReg[0].Swizzle = SWIZZLE_XYZW;
+    newInst[0].SrcReg[0].Negate = NEGATE_Y;
+
+    newInst[0].SrcReg[1].File = PROGRAM_STATE_VAR;
+    newInst[0].SrcReg[1].Index = win_size;
+    newInst[0].SrcReg[1].Swizzle = MAKE_SWIZZLE4(SWIZZLE_ZERO, SWIZZLE_Y, SWIZZLE_ZERO, SWIZZLE_ZERO);
+
+}
+
 //TODO : Validate FP input with VP output.
 void Map_Fragment_Program(r700_AssemblerBase         *pAsm,
-                                                 struct gl_fragment_program *mesa_fp)
+                                                 struct gl_fragment_program *mesa_fp,
+                          GLcontext *ctx) 
 {
        unsigned int unBit;
     unsigned int i;
     GLuint       ui;
 
+    /* match fp inputs with vp exports. */
+    struct r700_vertex_program_cont *vpc =
+                      (struct r700_vertex_program_cont *)ctx->VertexProgram._Current;
+    GLbitfield OutputsWritten = vpc->mesa_program.Base.OutputsWritten;
+    
        pAsm->number_used_registers = 0;
 
 //Input mapping : mesa_fp->Base.InputsRead set the flag, set in 
@@ -61,32 +116,99 @@ void Map_Fragment_Program(r700_AssemblerBase         *pAsm,
                pAsm->uiFP_AttributeMap[FRAG_ATTRIB_WPOS] = pAsm->number_used_registers++;
        }
 
-       unBit = 1 << FRAG_ATTRIB_COL0;
-       if(mesa_fp->Base.InputsRead & unBit)
+    unBit = 1 << VERT_RESULT_COL0;
+       if(OutputsWritten & unBit)
        {
                pAsm->uiFP_AttributeMap[FRAG_ATTRIB_COL0] = pAsm->number_used_registers++;
        }
 
-       unBit = 1 << FRAG_ATTRIB_COL1;
-       if(mesa_fp->Base.InputsRead & unBit)
+       unBit = 1 << VERT_RESULT_COL1;
+       if(OutputsWritten & unBit)
        {
                pAsm->uiFP_AttributeMap[FRAG_ATTRIB_COL1] = pAsm->number_used_registers++;
        }
 
-        unBit = 1 << FRAG_ATTRIB_FOGC;
-        if(mesa_fp->Base.InputsRead & unBit)
-        {
-                pAsm->uiFP_AttributeMap[FRAG_ATTRIB_FOGC] = pAsm->number_used_registers++;
-        }
+    unBit = 1 << VERT_RESULT_FOGC;
+    if(OutputsWritten & unBit)
+    {
+        pAsm->uiFP_AttributeMap[FRAG_ATTRIB_FOGC] = pAsm->number_used_registers++;
+    }
 
        for(i=0; i<8; i++)
        {
-               unBit = 1 << (FRAG_ATTRIB_TEX0 + i);
-               if(mesa_fp->Base.InputsRead & unBit)
+               unBit = 1 << (VERT_RESULT_TEX0 + i);
+               if(OutputsWritten & unBit)
                {
                        pAsm->uiFP_AttributeMap[FRAG_ATTRIB_TEX0 + i] = pAsm->number_used_registers++;
                }
        }
+/* order has been taken care of */ 
+#if 1
+    for(i=VERT_RESULT_VAR0; i<VERT_RESULT_MAX; i++)
+       {
+        unBit = 1 << i;
+        if(OutputsWritten & unBit)
+               {
+            pAsm->uiFP_AttributeMap[i-VERT_RESULT_VAR0+FRAG_ATTRIB_VAR0] = pAsm->number_used_registers++;
+        }
+    }
+#else
+    if( (mesa_fp->Base.InputsRead >> FRAG_ATTRIB_VAR0) > 0 )
+    {
+           struct r700_vertex_program_cont *vpc =
+                      (struct r700_vertex_program_cont *)ctx->VertexProgram._Current;
+        struct gl_program_parameter_list * VsVarying = vpc->mesa_program.Base.Varying;
+        struct gl_program_parameter_list * PsVarying = mesa_fp->Base.Varying;
+        struct gl_program_parameter      * pVsParam;
+        struct gl_program_parameter      * pPsParam;
+        GLuint j, k;
+        GLuint unMaxVarying = 0;
+
+        for(i=0; i<VsVarying->NumParameters; i++)
+        {
+            pAsm->uiFP_AttributeMap[i + FRAG_ATTRIB_VAR0] = 0;
+        }
+
+        for(i=FRAG_ATTRIB_VAR0; i<FRAG_ATTRIB_MAX; i++)
+           {
+            unBit = 1 << i;
+            if(mesa_fp->Base.InputsRead & unBit)
+                   {
+                j = i - FRAG_ATTRIB_VAR0;
+                pPsParam = PsVarying->Parameters + j;
+
+                for(k=0; k<VsVarying->NumParameters; k++)
+                {                                      
+                    pVsParam = VsVarying->Parameters + k;
+
+                               if( strcmp(pPsParam->Name, pVsParam->Name) == 0)
+                    {
+                        pAsm->uiFP_AttributeMap[i] = pAsm->number_used_registers + k;                  
+                        if(k > unMaxVarying)
+                        {
+                            unMaxVarying = k;
+                        }
+                        break;
+                    }
+                }
+                   }
+        }
+
+        pAsm->number_used_registers += unMaxVarying + 1;
+    }
+#endif
+    unBit = 1 << FRAG_ATTRIB_FACE;
+    if(mesa_fp->Base.InputsRead & unBit)
+    {
+        pAsm->uiFP_AttributeMap[FRAG_ATTRIB_FACE] = pAsm->number_used_registers++;
+    }
+
+    unBit = 1 << FRAG_ATTRIB_PNTC;
+    if(mesa_fp->Base.InputsRead & unBit)
+    {
+        pAsm->uiFP_AttributeMap[FRAG_ATTRIB_PNTC] = pAsm->number_used_registers++;
+    }
 
 /* Map temporary registers (GPRs) */
     pAsm->starting_temp_register_number = pAsm->number_used_registers;
@@ -127,6 +249,8 @@ void Map_Fragment_Program(r700_AssemblerBase         *pAsm,
         pAsm->pucOutMask[ui] = 0x0;
     }
 
+    pAsm->flag_reg_index = pAsm->number_used_registers++;
+
     pAsm->uFirstHelpReg = pAsm->number_used_registers;
 }
 
@@ -135,15 +259,19 @@ GLboolean Find_Instruction_Dependencies_fp(struct r700_fragment_program *fp,
 {
     GLuint i, j;
     GLint * puiTEMPwrites;
+    GLint * puiTEMPreads;
     struct prog_instruction * pILInst;
     InstDeps         *pInstDeps;
     struct prog_instruction * texcoord_DepInst;
     GLint              nDepInstID;
 
     puiTEMPwrites = (GLint*) MALLOC(sizeof(GLuint)*mesa_fp->Base.NumTemporaries);
+    puiTEMPreads = (GLint*) MALLOC(sizeof(GLuint)*mesa_fp->Base.NumTemporaries);
+
     for(i=0; i<mesa_fp->Base.NumTemporaries; i++)
     {
         puiTEMPwrites[i] = -1;
+        puiTEMPreads[i] = -1;
     }
 
     pInstDeps = (InstDeps*)MALLOC(sizeof(InstDeps)*mesa_fp->Base.NumInstructions);
@@ -167,6 +295,11 @@ GLboolean Find_Instruction_Dependencies_fp(struct r700_fragment_program *fp,
             {
                 //Set dep.
                 pInstDeps[i].nSrcDeps[j] = puiTEMPwrites[pILInst->SrcReg[j].Index];
+                //Set first read
+                if(puiTEMPreads[pILInst->SrcReg[j].Index] < 0 )
+                {
+                    puiTEMPreads[pILInst->SrcReg[j].Index] = i;
+                }
             }
             else
             {
@@ -177,8 +310,6 @@ GLboolean Find_Instruction_Dependencies_fp(struct r700_fragment_program *fp,
 
     fp->r700AsmCode.pInstDeps = pInstDeps;
 
-    FREE(puiTEMPwrites);
-
     //Find dep for tex inst    
     for(i=0; i<mesa_fp->Base.NumInstructions; i++)
     {
@@ -203,29 +334,84 @@ GLboolean Find_Instruction_Dependencies_fp(struct r700_fragment_program *fp,
                 {   //... other deps?
                 }
             }
+            // make sure that we dont overwrite src used earlier
+            nDepInstID = puiTEMPreads[pILInst->DstReg.Index];
+            if(nDepInstID < i)
+            {
+                pInstDeps[i].nDstDep = puiTEMPreads[pILInst->DstReg.Index];
+                texcoord_DepInst = &(mesa_fp->Base.Instructions[nDepInstID]);
+                if(GL_TRUE == IsAlu(texcoord_DepInst->Opcode) )
+                {
+                    pInstDeps[nDepInstID].nDstDep = i;
+                }
+            }
+
         }
        }
 
+    FREE(puiTEMPwrites);
+    FREE(puiTEMPreads);
+
     return GL_TRUE;
 }
 
 GLboolean r700TranslateFragmentShader(struct r700_fragment_program *fp,
-                                                            struct gl_fragment_program   *mesa_fp)
+                                                            struct gl_fragment_program   *mesa_fp,
+                                 GLcontext *ctx) 
 {
        GLuint    number_of_colors_exported;
        GLboolean z_enabled = GL_FALSE;
-       GLuint    unBit;
+       GLuint    unBit, shadow_unit;
+       int i;
+       struct prog_instruction *inst;
+       gl_state_index shadow_ambient[STATE_LENGTH]
+           = { STATE_INTERNAL, STATE_SHADOW_AMBIENT, 0, 0, 0};
 
     //Init_Program
        Init_r700_AssemblerBase( SPT_FP, &(fp->r700AsmCode), &(fp->r700Shader) );
-       Map_Fragment_Program(&(fp->r700AsmCode), mesa_fp);
+
+    if(mesa_fp->Base.InputsRead & FRAG_BIT_WPOS)
+    {
+        insert_wpos_code(ctx, mesa_fp);
+    }
+
+    /* add/map  consts for ARB_shadow_ambient */
+    if(mesa_fp->Base.ShadowSamplers)
+    {
+        inst = mesa_fp->Base.Instructions;
+        for (i = 0; i < mesa_fp->Base.NumInstructions; i++)
+        {
+            if(inst->TexShadow == 1)
+            {
+                shadow_unit = inst->TexSrcUnit;
+                shadow_ambient[2] = shadow_unit;
+                fp->r700AsmCode.shadow_regs[shadow_unit] = 
+                    _mesa_add_state_reference(mesa_fp->Base.Parameters, shadow_ambient);
+            }
+            inst++;
+        }
+    }
+
+    Map_Fragment_Program(&(fp->r700AsmCode), mesa_fp, ctx); 
 
     if( GL_FALSE == Find_Instruction_Dependencies_fp(fp, mesa_fp) )
        {
                return GL_FALSE;
     }
+
+    InitShaderProgram(&(fp->r700AsmCode));
        
-       if( GL_FALSE == AssembleInstr(mesa_fp->Base.NumInstructions,
+    for(i=0; i < MAX_SAMPLERS; i++)
+    {
+         fp->r700AsmCode.SamplerUnits[i] = fp->mesa_program.Base.SamplerUnits[i];
+    }
+
+    fp->r700AsmCode.unCurNumILInsts = mesa_fp->Base.NumInstructions;
+
+       if( GL_FALSE == AssembleInstr(0,
+                                  0,
+                                  mesa_fp->Base.NumInstructions,
                                   &(mesa_fp->Base.Instructions[0]), 
                                   &(fp->r700AsmCode)) )
        {
@@ -237,6 +423,11 @@ GLboolean r700TranslateFragmentShader(struct r700_fragment_program *fp,
         return GL_FALSE;
     }
 
+    if( GL_FALSE == RelocProgram(&(fp->r700AsmCode), &(mesa_fp->Base)) )
+    {
+        return GL_FALSE;
+    }
+
     fp->r700Shader.nRegs = (fp->r700AsmCode.number_used_registers == 0) ? 0 
                          : (fp->r700AsmCode.number_used_registers - 1);
 
@@ -251,7 +442,15 @@ GLboolean r700TranslateFragmentShader(struct r700_fragment_program *fp,
                number_of_colors_exported--;
        }
 
-       fp->r700Shader.exportMode = number_of_colors_exported << 1 | z_enabled;
+       /* illegal to set this to 0 */
+       if(number_of_colors_exported || z_enabled)
+       {
+           fp->r700Shader.exportMode = number_of_colors_exported << 1 | z_enabled;
+       }
+       else
+       {
+           fp->r700Shader.exportMode = (1 << 1);
+       }
 
     fp->translated = GL_TRUE;
 
@@ -269,7 +468,7 @@ void r700SelectFragmentShader(GLcontext *ctx)
     }
 
     if (GL_FALSE == fp->translated)
-           r700TranslateFragmentShader(fp, &(fp->mesa_program));
+           r700TranslateFragmentShader(fp, &(fp->mesa_program), ctx); 
 }
 
 void * r700GetActiveFpShaderBo(GLcontext * ctx)
@@ -294,6 +493,7 @@ GLboolean r700SetupFragmentProgram(GLcontext * ctx)
     unsigned int unNumOfReg;
     unsigned int unBit;
     GLuint exportCount;
+    GLboolean point_sprite = GL_FALSE;
 
     if(GL_FALSE == fp->loaded)
     {
@@ -347,6 +547,50 @@ GLboolean r700SetupFragmentProgram(GLcontext * ctx)
         CLEARbit(r700->SPI_INPUT_Z.u32All, PROVIDE_Z_TO_SPI_bit);
     }
 
+    if (mesa_fp->Base.InputsRead & (1 << FRAG_ATTRIB_FACE))
+    {
+        ui += 1;
+        SETfield(r700->SPI_PS_IN_CONTROL_0.u32All, ui, NUM_INTERP_shift, NUM_INTERP_mask);
+        SETbit(r700->SPI_PS_IN_CONTROL_1.u32All, FRONT_FACE_ENA_bit);
+        SETbit(r700->SPI_PS_IN_CONTROL_1.u32All, FRONT_FACE_ALL_BITS_bit);
+        SETfield(r700->SPI_PS_IN_CONTROL_1.u32All, pAsm->uiFP_AttributeMap[FRAG_ATTRIB_FACE], FRONT_FACE_ADDR_shift, FRONT_FACE_ADDR_mask);
+    }
+    else
+    {
+        CLEARbit(r700->SPI_PS_IN_CONTROL_1.u32All, FRONT_FACE_ENA_bit);
+    }
+
+    /* see if we need any point_sprite replacements */
+    for (i = VERT_RESULT_TEX0; i<= VERT_RESULT_TEX7; i++)
+    {
+        if(ctx->Point.CoordReplace[i - VERT_RESULT_TEX0] == GL_TRUE)
+            point_sprite = GL_TRUE;
+    }
+
+    if ((mesa_fp->Base.InputsRead & (1 << FRAG_ATTRIB_PNTC)) || point_sprite)
+    {
+        /* for FRAG_ATTRIB_PNTC we need to increase num_interp */
+        if(mesa_fp->Base.InputsRead & (1 << FRAG_ATTRIB_PNTC))
+        {
+            ui++;
+            SETfield(r700->SPI_PS_IN_CONTROL_0.u32All, ui, NUM_INTERP_shift, NUM_INTERP_mask);
+        }
+        SETbit(r700->SPI_INTERP_CONTROL_0.u32All, PNT_SPRITE_ENA_bit);
+        SETfield(r700->SPI_INTERP_CONTROL_0.u32All, SPI_PNT_SPRITE_SEL_S, PNT_SPRITE_OVRD_X_shift, PNT_SPRITE_OVRD_X_mask);
+        SETfield(r700->SPI_INTERP_CONTROL_0.u32All, SPI_PNT_SPRITE_SEL_T, PNT_SPRITE_OVRD_Y_shift, PNT_SPRITE_OVRD_Y_mask);
+        SETfield(r700->SPI_INTERP_CONTROL_0.u32All, SPI_PNT_SPRITE_SEL_0, PNT_SPRITE_OVRD_Z_shift, PNT_SPRITE_OVRD_Z_mask);
+        SETfield(r700->SPI_INTERP_CONTROL_0.u32All, SPI_PNT_SPRITE_SEL_1, PNT_SPRITE_OVRD_W_shift, PNT_SPRITE_OVRD_W_mask);
+        if(ctx->Point.SpriteOrigin == GL_LOWER_LEFT)
+            SETbit(r700->SPI_INTERP_CONTROL_0.u32All, PNT_SPRITE_TOP_1_bit);
+        else
+            CLEARbit(r700->SPI_INTERP_CONTROL_0.u32All, PNT_SPRITE_TOP_1_bit);
+    }
+    else
+    {
+        CLEARbit(r700->SPI_INTERP_CONTROL_0.u32All, PNT_SPRITE_ENA_bit);
+    }
+
+
     ui = (unNumOfReg < ui) ? ui : unNumOfReg;
 
     SETfield(r700->ps.SQ_PGM_RESOURCES_PS.u32All, ui, NUM_GPRS_shift, NUM_GPRS_mask);
@@ -362,27 +606,14 @@ GLboolean r700SetupFragmentProgram(GLcontext * ctx)
     SETfield(r700->ps.SQ_PGM_EXPORTS_PS.u32All, fp->r700Shader.exportMode,
              EXPORT_MODE_shift, EXPORT_MODE_mask);
 
-    R600_STATECHANGE(context, db);
-
-    if(fp->r700Shader.killIsUsed)
-    {
-           SETbit(r700->DB_SHADER_CONTROL.u32All, KILL_ENABLE_bit);
-    }
-    else
-    {
-        CLEARbit(r700->DB_SHADER_CONTROL.u32All, KILL_ENABLE_bit);
-    }
-
-    if(fp->r700Shader.depthIsExported)
-    {
-           SETbit(r700->DB_SHADER_CONTROL.u32All, Z_EXPORT_ENABLE_bit);
-    }
-    else
-    {
-        CLEARbit(r700->DB_SHADER_CONTROL.u32All, Z_EXPORT_ENABLE_bit);
-    }
-
     // emit ps input map
+    struct r700_vertex_program_cont *vpc =
+                      (struct r700_vertex_program_cont *)ctx->VertexProgram._Current;
+    GLbitfield OutputsWritten = vpc->mesa_program.Base.OutputsWritten;
+    
+    for(ui = 0; ui < R700_MAX_SHADER_EXPORTS; ui++)
+        r700->SPI_PS_INPUT_CNTL[ui].u32All = 0;
+
     unBit = 1 << FRAG_ATTRIB_WPOS;
     if(mesa_fp->Base.InputsRead & unBit)
     {
@@ -396,8 +627,8 @@ GLboolean r700SetupFragmentProgram(GLcontext * ctx)
                     CLEARbit(r700->SPI_PS_INPUT_CNTL[ui].u32All, FLAT_SHADE_bit);
     }
 
-    unBit = 1 << FRAG_ATTRIB_COL0;
-    if(mesa_fp->Base.InputsRead & unBit)
+    unBit = 1 << VERT_RESULT_COL0;
+    if(OutputsWritten & unBit)
     {
            ui = pAsm->uiFP_AttributeMap[FRAG_ATTRIB_COL0];
            SETbit(r700->SPI_PS_INPUT_CNTL[ui].u32All, SEL_CENTROID_bit);
@@ -409,8 +640,8 @@ GLboolean r700SetupFragmentProgram(GLcontext * ctx)
                    CLEARbit(r700->SPI_PS_INPUT_CNTL[ui].u32All, FLAT_SHADE_bit);
     }
 
-    unBit = 1 << FRAG_ATTRIB_COL1;
-    if(mesa_fp->Base.InputsRead & unBit)
+    unBit = 1 << VERT_RESULT_COL1;
+    if(OutputsWritten & unBit)
     {
            ui = pAsm->uiFP_AttributeMap[FRAG_ATTRIB_COL1];
            SETbit(r700->SPI_PS_INPUT_CNTL[ui].u32All, SEL_CENTROID_bit);
@@ -422,8 +653,8 @@ GLboolean r700SetupFragmentProgram(GLcontext * ctx)
                    CLEARbit(r700->SPI_PS_INPUT_CNTL[ui].u32All, FLAT_SHADE_bit);
     }
 
-    unBit = 1 << FRAG_ATTRIB_FOGC;
-    if(mesa_fp->Base.InputsRead & unBit)
+    unBit = 1 << VERT_RESULT_FOGC;
+    if(OutputsWritten & unBit)
     {
             ui = pAsm->uiFP_AttributeMap[FRAG_ATTRIB_FOGC];
             SETbit(r700->SPI_PS_INPUT_CNTL[ui].u32All, SEL_CENTROID_bit);
@@ -437,25 +668,79 @@ GLboolean r700SetupFragmentProgram(GLcontext * ctx)
 
     for(i=0; i<8; i++)
     {
-           unBit = 1 << (FRAG_ATTRIB_TEX0 + i);
-           if(mesa_fp->Base.InputsRead & unBit)
+           unBit = 1 << (VERT_RESULT_TEX0 + i);
+           if(OutputsWritten & unBit)
            {
                    ui = pAsm->uiFP_AttributeMap[FRAG_ATTRIB_TEX0 + i];
                    SETbit(r700->SPI_PS_INPUT_CNTL[ui].u32All, SEL_CENTROID_bit);
                    SETfield(r700->SPI_PS_INPUT_CNTL[ui].u32All, ui,
                             SEMANTIC_shift, SEMANTIC_mask);
                    CLEARbit(r700->SPI_PS_INPUT_CNTL[ui].u32All, FLAT_SHADE_bit);
+                   /* ARB_point_sprite */
+                   if(ctx->Point.CoordReplace[i] == GL_TRUE)
+                   {
+                            SETbit(r700->SPI_PS_INPUT_CNTL[ui].u32All, PT_SPRITE_TEX_bit);
+                   }
            }
     }
 
-    R600_STATECHANGE(context, cb);
+    unBit = 1 << FRAG_ATTRIB_FACE;
+    if(mesa_fp->Base.InputsRead & unBit)
+    {
+            ui = pAsm->uiFP_AttributeMap[FRAG_ATTRIB_FACE];
+            SETbit(r700->SPI_PS_INPUT_CNTL[ui].u32All, SEL_CENTROID_bit);
+            SETfield(r700->SPI_PS_INPUT_CNTL[ui].u32All, ui,
+                     SEMANTIC_shift, SEMANTIC_mask);
+            if (r700->SPI_INTERP_CONTROL_0.u32All & FLAT_SHADE_ENA_bit)
+                    SETbit(r700->SPI_PS_INPUT_CNTL[ui].u32All, FLAT_SHADE_bit);
+            else
+                    CLEARbit(r700->SPI_PS_INPUT_CNTL[ui].u32All, FLAT_SHADE_bit);
+    }
+    unBit = 1 << FRAG_ATTRIB_PNTC;
+    if(mesa_fp->Base.InputsRead & unBit)
+    {
+            ui = pAsm->uiFP_AttributeMap[FRAG_ATTRIB_PNTC];
+            SETbit(r700->SPI_PS_INPUT_CNTL[ui].u32All, SEL_CENTROID_bit);
+            SETfield(r700->SPI_PS_INPUT_CNTL[ui].u32All, ui,
+                     SEMANTIC_shift, SEMANTIC_mask);
+            if (r700->SPI_INTERP_CONTROL_0.u32All & FLAT_SHADE_ENA_bit)
+                    SETbit(r700->SPI_PS_INPUT_CNTL[ui].u32All, FLAT_SHADE_bit);
+            else
+                    CLEARbit(r700->SPI_PS_INPUT_CNTL[ui].u32All, FLAT_SHADE_bit);
+            SETbit(r700->SPI_PS_INPUT_CNTL[ui].u32All, PT_SPRITE_TEX_bit);
+    }
+
+
+
+
+    for(i=VERT_RESULT_VAR0; i<VERT_RESULT_MAX; i++)
+       {
+        unBit = 1 << i;
+        if(OutputsWritten & unBit)
+               {
+            ui = pAsm->uiFP_AttributeMap[i-VERT_RESULT_VAR0+FRAG_ATTRIB_VAR0];
+            SETbit(r700->SPI_PS_INPUT_CNTL[ui].u32All, SEL_CENTROID_bit);
+            SETfield(r700->SPI_PS_INPUT_CNTL[ui].u32All, ui,
+                            SEMANTIC_shift, SEMANTIC_mask);
+            if (r700->SPI_INTERP_CONTROL_0.u32All & FLAT_SHADE_ENA_bit)
+                       SETbit(r700->SPI_PS_INPUT_CNTL[ui].u32All, FLAT_SHADE_bit);
+            else
+                       CLEARbit(r700->SPI_PS_INPUT_CNTL[ui].u32All, FLAT_SHADE_bit);
+        }
+    }
+
     exportCount = (r700->ps.SQ_PGM_EXPORTS_PS.u32All & EXPORT_MODE_mask) / (1 << EXPORT_MODE_shift);
-    r700->CB_SHADER_CONTROL.u32All = (1 << exportCount) - 1;
+    if (r700->CB_SHADER_CONTROL.u32All != ((1 << exportCount) - 1))
+    {
+           R600_STATECHANGE(context, cb);
+           r700->CB_SHADER_CONTROL.u32All = (1 << exportCount) - 1;
+    }
 
     /* sent out shader constants. */
     paramList = fp->mesa_program.Base.Parameters;
 
-    if(NULL != paramList) {
+    if(NULL != paramList) 
+    {
            _mesa_load_state_parameters(ctx, paramList);
 
            if (paramList->NumParameters > R700_MAX_DX9_CONSTS)
@@ -468,14 +753,33 @@ GLboolean r700SetupFragmentProgram(GLcontext * ctx)
            unNumParamData = paramList->NumParameters;
 
            for(ui=0; ui<unNumParamData; ui++) {
-                   r700->ps.consts[ui][0].f32All = paramList->ParameterValues[ui][0];
-                   r700->ps.consts[ui][1].f32All = paramList->ParameterValues[ui][1];
-                   r700->ps.consts[ui][2].f32All = paramList->ParameterValues[ui][2];
-                   r700->ps.consts[ui][3].f32All = paramList->ParameterValues[ui][3];
+                       r700->ps.consts[ui][0].f32All = paramList->ParameterValues[ui][0];
+                       r700->ps.consts[ui][1].f32All = paramList->ParameterValues[ui][1];
+                       r700->ps.consts[ui][2].f32All = paramList->ParameterValues[ui][2];
+                       r700->ps.consts[ui][3].f32All = paramList->ParameterValues[ui][3];
            }
     } else
            r700->ps.num_consts = 0;
 
+    COMPILED_SUB * pCompiledSub;
+    GLuint uj;
+    GLuint unConstOffset = r700->ps.num_consts;
+    for(ui=0; ui<pAsm->unNumPresub; ui++)
+    {
+        pCompiledSub = pAsm->presubs[ui].pCompiledSub;
+
+        r700->ps.num_consts += pCompiledSub->NumParameters;
+
+        for(uj=0; uj<pCompiledSub->NumParameters; uj++)
+        {
+            r700->ps.consts[uj + unConstOffset][0].f32All = pCompiledSub->ParameterValues[uj][0];
+                   r700->ps.consts[uj + unConstOffset][1].f32All = pCompiledSub->ParameterValues[uj][1];
+                   r700->ps.consts[uj + unConstOffset][2].f32All = pCompiledSub->ParameterValues[uj][2];
+                   r700->ps.consts[uj + unConstOffset][3].f32All = pCompiledSub->ParameterValues[uj][3];
+        }
+        unConstOffset += pCompiledSub->NumParameters;
+    }
+
     return GL_TRUE;
 }
 
index cbb108d21280556ac722e05ac54456e672bc05d8..39c59c9201df9e56ae9f590b43e23ad85c3baf3a 100644 (file)
@@ -48,13 +48,17 @@ struct r700_fragment_program
 };
 
 /* Internal */
+void insert_wpos_code(GLcontext *ctx, struct gl_fragment_program *fprog);
+
 void Map_Fragment_Program(r700_AssemblerBase         *pAsm,
-                         struct gl_fragment_program *mesa_fp);
+                         struct gl_fragment_program *mesa_fp,
+                          GLcontext *ctx); 
 GLboolean Find_Instruction_Dependencies_fp(struct r700_fragment_program *fp,
                                           struct gl_fragment_program   *mesa_fp);
 
 GLboolean r700TranslateFragmentShader(struct r700_fragment_program *fp,
-                                     struct gl_fragment_program   *mesa_vp);
+                                     struct gl_fragment_program   *mesa_vp,
+                                      GLcontext *ctx); 
 
 /* Interface */
 extern void r700SelectFragmentShader(GLcontext *ctx);
index 5290ef31be3a4173ef560c47c2c0d26ebb7c1c1b..0d476fcd8639a594c5fff456a287361b1bb1e295 100644 (file)
 #include "r700_vertprog.h"
 
 
+static void freeVertProgCache(GLcontext *ctx, struct r700_vertex_program_cont *cache)
+{
+       struct r700_vertex_program *tmp, *vp = cache->progs;
+
+       while (vp) {
+               tmp = vp->next;
+               /* Release DMA region */
+               r600DeleteShader(ctx, vp->shaderbo);
+               /* Clean up */
+               Clean_Up_Assembler(&(vp->r700AsmCode));
+               Clean_Up_Shader(&(vp->r700Shader));
+               
+               _mesa_reference_vertprog(ctx, &vp->mesa_program, NULL);
+               _mesa_free(vp);
+               vp = tmp;
+       }
+}
+
 static struct gl_program *r700NewProgram(GLcontext * ctx, 
                                          GLenum target,
                                                             GLuint id)
@@ -84,8 +102,7 @@ static struct gl_program *r700NewProgram(GLcontext * ctx,
 
 static void r700DeleteProgram(GLcontext * ctx, struct gl_program *prog)
 {
-    struct r700_vertex_program_cont   * vpc;
-    struct r700_vertex_program *vp, *tmp;
+    struct r700_vertex_program_cont *vpc = (struct r700_vertex_program_cont *)prog;
     struct r700_fragment_program * fp;
 
        radeon_print(RADEON_SHADER, RADEON_VERBOSE,
@@ -95,20 +112,7 @@ static void r700DeleteProgram(GLcontext * ctx, struct gl_program *prog)
     {
     case GL_VERTEX_STATE_PROGRAM_NV:
     case GL_VERTEX_PROGRAM_ARB:            
-        vpc = (struct r700_vertex_program_cont*)prog;
-        vp = vpc->progs;
-       while (vp) {
-               tmp = vp->next;
-               /* Release DMA region */
-        
-               r600DeleteShader(ctx, vp->shaderbo);
-
-               /* Clean up */
-               Clean_Up_Assembler(&(vp->r700AsmCode));
-               Clean_Up_Shader(&(vp->r700Shader));
-               _mesa_free(vp);
-               vp = tmp;
-       }
+           freeVertProgCache(ctx, vpc);
            break;
     case GL_FRAGMENT_PROGRAM_NV:
     case GL_FRAGMENT_PROGRAM_ARB:
@@ -131,7 +135,24 @@ static void r700DeleteProgram(GLcontext * ctx, struct gl_program *prog)
 static void
 r700ProgramStringNotify(GLcontext * ctx, GLenum target, struct gl_program *prog)
 {
-
+       struct r700_vertex_program_cont *vpc = (struct r700_vertex_program_cont *)prog;
+       struct r700_fragment_program * fp = (struct r700_fragment_program*)prog;
+
+       switch (target) {
+       case GL_VERTEX_PROGRAM_ARB:
+               freeVertProgCache(ctx, vpc);
+               vpc->progs = NULL;
+               break;
+       case GL_FRAGMENT_PROGRAM_ARB:
+               r600DeleteShader(ctx, fp->shaderbo);
+               Clean_Up_Assembler(&(fp->r700AsmCode));
+               Clean_Up_Shader(&(fp->r700Shader));
+               fp->translated = GL_FALSE;
+               fp->loaded     = GL_FALSE;
+               fp->shaderbo   = NULL;
+               break;
+       }
+               
 }
 
 static GLboolean r700IsProgramNative(GLcontext * ctx, GLenum target, struct gl_program *prog)
index 4f39d9f1bdfa7afd7f286cd11a9132ab49e2f335..eab27cbd8429aeb9582051b48722a7c557e034f6 100644 (file)
@@ -59,9 +59,7 @@
 
 void r700WaitForIdle(context_t *context);
 void r700WaitForIdleClean(context_t *context);
-GLboolean r700SendTextureState(context_t *context);
 static unsigned int r700PrimitiveType(int prim);
-void r600UpdateTextureState(GLcontext * ctx);
 GLboolean r700SyncSurf(context_t *context,
                       struct radeon_bo *pbo,
                       uint32_t read_domain,
@@ -253,24 +251,12 @@ static void r700RunRenderPrimitive(GLcontext * ctx, int start, int end, int prim
 {
     context_t *context = R700_CONTEXT(ctx);
     BATCH_LOCALS(&context->radeon);
-    int type, i, total_emit;
+    int type, total_emit;
     int num_indices;
     uint32_t vgt_draw_initiator = 0;
     uint32_t vgt_index_type     = 0;
     uint32_t vgt_primitive_type = 0;
     uint32_t vgt_num_indices    = 0;
-    TNLcontext *tnl = TNL_CONTEXT(ctx);
-    struct vertex_buffer *vb = &tnl->vb;
-    GLboolean bUseDrawIndex;
-
-    if(NULL != context->ind_buf.bo)
-    {
-        bUseDrawIndex = GL_TRUE;
-    }
-    else
-    {
-        bUseDrawIndex = GL_FALSE;
-    }
 
     type = r700PrimitiveType(prim);
     num_indices = r700NumVerts(end - start, prim);
@@ -282,90 +268,153 @@ static void r700RunRenderPrimitive(GLcontext * ctx, int start, int end, int prim
     if (type < 0 || num_indices <= 0)
            return;
 
-    if(GL_TRUE == bUseDrawIndex)
-    {
-        total_emit =   3  /* VGT_PRIMITIVE_TYPE */
-                    + 2  /* VGT_INDEX_TYPE */
-                    + 2  /* NUM_INSTANCES */
-                     + 5 + 2; /* DRAW_INDEX */
-    }
-    else
-    {
-        total_emit =   3 /* VGT_PRIMITIVE_TYPE */
-                    + 2 /* VGT_INDEX_TYPE */
-                    + 2 /* NUM_INSTANCES */
-                     + num_indices + 3; /* DRAW_INDEX_IMMD */
-    }
-
-    BEGIN_BATCH_NO_AUTOSTATE(total_emit);
-    // prim
     SETfield(vgt_primitive_type, type,
             VGT_PRIMITIVE_TYPE__PRIM_TYPE_shift, VGT_PRIMITIVE_TYPE__PRIM_TYPE_mask);
-    R600_OUT_BATCH(CP_PACKET3(R600_IT_SET_CONFIG_REG, 1));
-    R600_OUT_BATCH(mmVGT_PRIMITIVE_TYPE - ASIC_CONFIG_BASE_INDEX);
-    R600_OUT_BATCH(vgt_primitive_type);
 
-       // index type
     SETfield(vgt_index_type, DI_INDEX_SIZE_32_BIT, INDEX_TYPE_shift, INDEX_TYPE_mask);
 
-    if(GL_TRUE == bUseDrawIndex)
+    if(GL_TRUE != context->ind_buf.is_32bit)
     {
-        if(GL_TRUE != context->ind_buf.is_32bit)
-        {
             SETfield(vgt_index_type, DI_INDEX_SIZE_16_BIT, INDEX_TYPE_shift, INDEX_TYPE_mask);
-        }
     }
 
+    vgt_num_indices = num_indices;
+    SETfield(vgt_draw_initiator, DI_SRC_SEL_DMA, SOURCE_SELECT_shift, SOURCE_SELECT_mask);
+    SETfield(vgt_draw_initiator, DI_MAJOR_MODE_0, MAJOR_MODE_shift, MAJOR_MODE_mask);
+
+    total_emit =   3  /* VGT_PRIMITIVE_TYPE */
+                + 2  /* VGT_INDEX_TYPE */
+                + 2  /* NUM_INSTANCES */
+                + 5 + 2; /* DRAW_INDEX */
+
+    BEGIN_BATCH_NO_AUTOSTATE(total_emit);
+    // prim
+    R600_OUT_BATCH_REGSEQ(VGT_PRIMITIVE_TYPE, 1);
+    R600_OUT_BATCH(vgt_primitive_type);
+    // index type
     R600_OUT_BATCH(CP_PACKET3(R600_IT_INDEX_TYPE, 0));
     R600_OUT_BATCH(vgt_index_type);
-
     // num instances
     R600_OUT_BATCH(CP_PACKET3(R600_IT_NUM_INSTANCES, 0));
     R600_OUT_BATCH(1);
-
     // draw packet
+    R600_OUT_BATCH(CP_PACKET3(R600_IT_DRAW_INDEX, 3));
+    R600_OUT_BATCH(context->ind_buf.bo_offset);
+    R600_OUT_BATCH(0);
+    R600_OUT_BATCH(vgt_num_indices);
+    R600_OUT_BATCH(vgt_draw_initiator);
+    R600_OUT_BATCH_RELOC(context->ind_buf.bo_offset,
+                        context->ind_buf.bo,
+                        context->ind_buf.bo_offset,
+                        RADEON_GEM_DOMAIN_GTT, 0, 0);
+    END_BATCH();
+    COMMIT_BATCH();
+}
+
+static void r700RunRenderPrimitiveImmediate(GLcontext * ctx, int start, int end, int prim)
+{
+    context_t *context = R700_CONTEXT(ctx);
+    BATCH_LOCALS(&context->radeon);
+    int type, i;
+    uint32_t num_indices, total_emit = 0;
+    uint32_t vgt_draw_initiator = 0;
+    uint32_t vgt_index_type     = 0;
+    uint32_t vgt_primitive_type = 0;
+    uint32_t vgt_num_indices    = 0;
+
+    type = r700PrimitiveType(prim);
+    num_indices = r700NumVerts(end - start, prim);
+
+    radeon_print(RADEON_RENDER, RADEON_TRACE,
+                "%s type %x num_indices %d\n",
+                __func__, type, num_indices);
+
+    if (type < 0 || num_indices <= 0)
+           return;
+
+    SETfield(vgt_primitive_type, type,
+            VGT_PRIMITIVE_TYPE__PRIM_TYPE_shift, VGT_PRIMITIVE_TYPE__PRIM_TYPE_mask);
+
+    if (num_indices > 0xffff)
+    {
+           SETfield(vgt_index_type, DI_INDEX_SIZE_32_BIT, INDEX_TYPE_shift, INDEX_TYPE_mask);
+    }
+    else
+    {
+            SETfield(vgt_index_type, DI_INDEX_SIZE_16_BIT, INDEX_TYPE_shift, INDEX_TYPE_mask);
+    }
+
     vgt_num_indices = num_indices;
+    SETfield(vgt_draw_initiator, DI_MAJOR_MODE_0, MAJOR_MODE_shift, MAJOR_MODE_mask);
 
-    if(GL_TRUE == bUseDrawIndex)
+    if (start == 0)
     {
-        SETfield(vgt_draw_initiator, DI_SRC_SEL_DMA, SOURCE_SELECT_shift, SOURCE_SELECT_mask);
+       SETfield(vgt_draw_initiator, DI_SRC_SEL_AUTO_INDEX, SOURCE_SELECT_shift, SOURCE_SELECT_mask);
     }
     else
     {
-        SETfield(vgt_draw_initiator, DI_SRC_SEL_IMMEDIATE, SOURCE_SELECT_shift, SOURCE_SELECT_mask);
+       if (num_indices > 0xffff)
+       {
+               total_emit += num_indices;
+       }
+       else
+       {
+               total_emit += (num_indices + 1) / 2;
+       }
+       SETfield(vgt_draw_initiator, DI_SRC_SEL_IMMEDIATE, SOURCE_SELECT_shift, SOURCE_SELECT_mask);
     }
 
-       SETfield(vgt_draw_initiator, DI_MAJOR_MODE_0, MAJOR_MODE_shift, MAJOR_MODE_mask);
+    total_emit +=   3 /* VGT_PRIMITIVE_TYPE */
+                 + 2 /* VGT_INDEX_TYPE */
+                 + 2 /* NUM_INSTANCES */
+                 + 3; /* DRAW */
 
-    if(GL_TRUE == bUseDrawIndex)
+    BEGIN_BATCH_NO_AUTOSTATE(total_emit);
+    // prim
+    R600_OUT_BATCH_REGSEQ(VGT_PRIMITIVE_TYPE, 1);
+    R600_OUT_BATCH(vgt_primitive_type);
+    // index type
+    R600_OUT_BATCH(CP_PACKET3(R600_IT_INDEX_TYPE, 0));
+    R600_OUT_BATCH(vgt_index_type);
+    // num instances
+    R600_OUT_BATCH(CP_PACKET3(R600_IT_NUM_INSTANCES, 0));
+    R600_OUT_BATCH(1);
+    // draw packet
+    if(start == 0)
     {
-        R600_OUT_BATCH(CP_PACKET3(R600_IT_DRAW_INDEX, 3));
-        R600_OUT_BATCH(context->ind_buf.bo_offset);
-        R600_OUT_BATCH(0);
+        R600_OUT_BATCH(CP_PACKET3(R600_IT_DRAW_INDEX_AUTO, 1));
         R600_OUT_BATCH(vgt_num_indices);
         R600_OUT_BATCH(vgt_draw_initiator);
-        R600_OUT_BATCH_RELOC(context->ind_buf.bo_offset,
-                             context->ind_buf.bo,
-                             context->ind_buf.bo_offset,
-                             RADEON_GEM_DOMAIN_GTT, 0, 0);
     }
     else
     {
-        R600_OUT_BATCH(CP_PACKET3(R600_IT_DRAW_INDEX_IMMD, (num_indices + 1)));
-        R600_OUT_BATCH(vgt_num_indices);
-        R600_OUT_BATCH(vgt_draw_initiator);
-
-        for (i = start; i < (start + num_indices); i++)
-       {
-            if(vb->Elts)
-            {
-                R600_OUT_BATCH(vb->Elts[i]);
-            }
-            else
+       if (num_indices > 0xffff)
+        {
+           R600_OUT_BATCH(CP_PACKET3(R600_IT_DRAW_INDEX_IMMD, (num_indices + 1)));
+           R600_OUT_BATCH(vgt_num_indices);
+           R600_OUT_BATCH(vgt_draw_initiator);
+           for (i = start; i < (start + num_indices); i++)
            {
-                R600_OUT_BATCH(i);
+               R600_OUT_BATCH(i);
            }
-        }
+       }
+       else
+        {
+           R600_OUT_BATCH(CP_PACKET3(R600_IT_DRAW_INDEX_IMMD, (((num_indices + 1) / 2) + 1)));
+           R600_OUT_BATCH(vgt_num_indices);
+           R600_OUT_BATCH(vgt_draw_initiator);
+           for (i = start; i < (start + num_indices); i += 2)
+           {
+               if ((i + 1) == (start + num_indices))
+               {
+                   R600_OUT_BATCH(i);
+               }
+               else
+               {
+                   R600_OUT_BATCH(((i + 1) << 16) | (i));
+               }
+           }
+       }
     }
 
     END_BATCH();
@@ -375,173 +424,45 @@ static void r700RunRenderPrimitive(GLcontext * ctx, int start, int end, int prim
 /* start 3d, idle, cb/db flush */
 #define PRE_EMIT_STATE_BUFSZ 10 + 5 + 14
 
-static GLuint r700PredictRenderSize(GLcontext* ctx, GLuint nr_prims)
+static GLuint r700PredictRenderSize(GLcontext* ctx,
+                                   const struct _mesa_prim *prim,
+                                   const struct _mesa_index_buffer *ib,
+                                   GLuint nr_prims)
 {
     context_t *context = R700_CONTEXT(ctx);
-    struct r700_vertex_program *vp = context->selected_vp;
     GLboolean flushed;
     GLuint dwords, i;
     GLuint state_size;
-    /* pre calculate aos count so state prediction works */
-    context->radeon.tcl.aos_count = _mesa_bitcount(vp->mesa_program->Base.InputsRead);
 
     dwords = PRE_EMIT_STATE_BUFSZ;
-    if (nr_prims)
+    if (ib)
            dwords += nr_prims * 14;
     else {
-           TNLcontext *tnl = TNL_CONTEXT(ctx);
-           struct vertex_buffer *vb = &tnl->vb;
-
-           for (i = 0; i < vb->PrimitiveCount; i++)
-                   dwords += vb->Primitive[i].count + 10;
+           for (i = 0; i < nr_prims; ++i)
+           {
+                   if (prim[i].start == 0)
+                           dwords += 10;
+                   else if (prim[i].count > 0xffff)
+                           dwords += prim[i].count + 10;
+                   else
+                           dwords += ((prim[i].count + 1) / 2) + 10;
+           }
     }
+
     state_size = radeonCountStateEmitSize(&context->radeon);
     flushed = rcommonEnsureCmdBufSpace(&context->radeon,
-            dwords + state_size, __FUNCTION__);
-
+                                      dwords + state_size,
+                                      __FUNCTION__);
     if (flushed)
-        dwords += radeonCountStateEmitSize(&context->radeon);
+           dwords += radeonCountStateEmitSize(&context->radeon);
     else
-        dwords += state_size;
+           dwords += state_size;
 
-    radeon_print(RADEON_RENDER, RADEON_VERBOSE,
-       "%s: total prediction size is %d.\n", __FUNCTION__, dwords);
+    radeon_print(RADEON_RENDER, RADEON_VERBOSE, "%s: total prediction size is %d.\n", __FUNCTION__, dwords);
     return dwords;
-}
-
-static GLboolean r700RunRender(GLcontext * ctx,
-                              struct tnl_pipeline_stage *stage)
-{
-    context_t *context = R700_CONTEXT(ctx);
-    radeonContextPtr radeon = &context->radeon;
-    unsigned int i, id = 0;
-    TNLcontext *tnl = TNL_CONTEXT(ctx);
-    struct vertex_buffer *vb = &tnl->vb;
-    struct radeon_renderbuffer *rrb;
-
-    radeon_print(RADEON_RENDER, RADEON_NORMAL, "%s: cs begin at %d\n",
-                __func__, context->radeon.cmdbuf.cs->cdw);
-
-    /* always emit CB base to prevent
-     * lock ups on some chips.
-     */
-    R600_STATECHANGE(context, cb_target);
-    /* mark vtx as dirty since it changes per-draw */
-    R600_STATECHANGE(context, vtx);
-
-    r700SetScissor(context);
-    r700SetupVertexProgram(ctx);
-    r700SetupFragmentProgram(ctx);
-    r600UpdateTextureState(ctx);
-
-    GLuint emit_end = r700PredictRenderSize(ctx, 0)
-        + context->radeon.cmdbuf.cs->cdw;
-    r700SetupStreams(ctx);
-
-    radeonEmitState(radeon);
-
-    radeon_debug_add_indent();
-    /* richard test code */
-    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;
-        r700RunRenderPrimitive(ctx, start, end, prim);
-    }
-    radeon_debug_remove_indent();
-
-    /* Flush render op cached for last several quads. */
-    r700WaitForIdleClean(context);
-
-    rrb = radeon_get_colorbuffer(&context->radeon);
-    if (rrb && rrb->bo)
-           r700SyncSurf(context, rrb->bo, 0, RADEON_GEM_DOMAIN_VRAM,
-                        CB_ACTION_ENA_bit | (1 << (id + 6)));
-
-    rrb = radeon_get_depthbuffer(&context->radeon);
-    if (rrb && rrb->bo)
-           r700SyncSurf(context, rrb->bo, 0, RADEON_GEM_DOMAIN_VRAM,
-                        DB_ACTION_ENA_bit | DB_DEST_BASE_ENA_bit);
-
-    radeonReleaseArrays(ctx, ~0);
-
-    radeon_print(RADEON_RENDER, RADEON_TRACE, "%s: cs end at %d\n",
-                __func__, context->radeon.cmdbuf.cs->cdw);
-
-    if ( emit_end < context->radeon.cmdbuf.cs->cdw )
-       WARN_ONCE("Rendering was %d commands larger than predicted size."
-              " We might overflow  command buffer.\n", context->radeon.cmdbuf.cs->cdw - emit_end);
-
-    return GL_FALSE;
-}
-
-static GLboolean r700RunNonTCLRender(GLcontext * ctx,
-                                    struct tnl_pipeline_stage *stage) /* -------------------- */
-{
-       GLboolean bRet = GL_TRUE;
-       
-       return bRet;
-}
-
-static GLboolean r700RunTCLRender(GLcontext * ctx,  /*----------------------*/
-                                 struct tnl_pipeline_stage *stage)
-{
-       GLboolean bRet = GL_FALSE;
 
-    /* TODO : sw fallback */
-
-    /* Need shader bo's setup before bo check */
-    r700UpdateShaders(ctx);
-    /**
-
-    * Ensure all enabled and complete textures are uploaded along with any buffers being used.
-    */
-    if(!r600ValidateBuffers(ctx))
-    {
-        return GL_TRUE;
-    }
-
-    bRet = r700RunRender(ctx, stage);
-
-    return bRet;
-       //GL_FALSE will stop to do other pipe stage in _tnl_run_pipeline
-    //The render here DOES finish the whole pipe, so GL_FALSE should be returned for success.
 }
 
-const struct tnl_pipeline_stage _r700_render_stage = {
-       "r700 Hardware Rasterization",
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       r700RunNonTCLRender
-};
-
-const struct tnl_pipeline_stage _r700_tcl_stage = {
-       "r700 Hardware Transform, Clipping and Lighting",
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       r700RunTCLRender
-};
-
-const struct tnl_pipeline_stage *r700_pipeline[] = 
-{
-    &_r700_tcl_stage,
-    &_tnl_vertex_transform_stage,
-       &_tnl_normal_transform_stage,
-       &_tnl_lighting_stage,
-       &_tnl_fog_coordinate_stage,
-       &_tnl_texgen_stage,
-       &_tnl_texture_transform_stage,
-       &_tnl_vertex_program_stage,
-
-    &_r700_render_stage,
-    &_tnl_render_stage,
-    0,
-};
-
 #define CONVERT( TYPE, MACRO ) do {            \
        GLuint i, j, sz;                                \
        sz = input->Size;                               \
@@ -605,6 +526,9 @@ static void r700ConvertAttrib(GLcontext *ctx, int count,
 
     radeonAllocDmaRegion(&context->radeon, &attr->bo, &attr->bo_offset, 
                          sizeof(GLfloat) * input->Size * count, 32);
+
+    radeon_bo_map(attr->bo, 1);
+
     dst_ptr = (GLfloat *)ADD_POINTERS(attr->bo->ptr, attr->bo_offset);
 
     assert(src_ptr != NULL);
@@ -638,6 +562,8 @@ static void r700ConvertAttrib(GLcontext *ctx, int count,
             break;
     }
 
+    radeon_bo_unmap(attr->bo);
+
     if (mapped_named_bo) 
     {
         ctx->Driver.UnmapBuffer(ctx, GL_ARRAY_BUFFER, input->BufferObj);
@@ -656,6 +582,8 @@ static void r700AlignDataToDword(GLcontext *ctx,
 
     radeonAllocDmaRegion(&context->radeon, &attr->bo, &attr->bo_offset, size, 32);
 
+    radeon_bo_map(attr->bo, 1);
+
     if (!input->BufferObj->Pointer) 
     {
         ctx->Driver.MapBuffer(ctx, GL_ARRAY_BUFFER, GL_READ_ONLY_ARB, input->BufferObj);
@@ -675,6 +603,7 @@ static void r700AlignDataToDword(GLcontext *ctx,
         }
     }
 
+    radeon_bo_unmap(attr->bo);
     if (mapped_named_bo) 
     {
         ctx->Driver.UnmapBuffer(ctx, GL_ARRAY_BUFFER, input->BufferObj);
@@ -683,7 +612,7 @@ static void r700AlignDataToDword(GLcontext *ctx,
     attr->stride = dst_stride;
 }
 
-static void r700SetupStreams2(GLcontext *ctx, const struct gl_client_array *input[], int count)
+static void r700SetupStreams(GLcontext *ctx, const struct gl_client_array *input[], int count)
 {
        context_t *context = R700_CONTEXT(ctx);
     GLuint stride;
@@ -743,32 +672,33 @@ static void r700SetupStreams2(GLcontext *ctx, const struct gl_client_array *inpu
 
                 radeonAllocDmaRegion(&context->radeon, &context->stream_desc[index].bo, 
                                      &context->stream_desc[index].bo_offset, size, 32);
+
+                radeon_bo_map(context->stream_desc[index].bo, 1);
                 assert(context->stream_desc[index].bo->ptr != NULL);
+
+
                 dst = (uint32_t *)ADD_POINTERS(context->stream_desc[index].bo->ptr, 
                                                context->stream_desc[index].bo_offset);
 
                 switch (context->stream_desc[index].dwords) 
                 {
                 case 1:                     
-                    radeonEmitVec4(dst, input[i]->Ptr, input[i]->StrideB, local_count);                         
-                                       context->stream_desc[index].stride = 4; 
+                    radeonEmitVec4(dst, input[i]->Ptr, input[i]->StrideB, local_count);
                     break;
                 case 2: 
                     radeonEmitVec8(dst, input[i]->Ptr, input[i]->StrideB, local_count); 
-                                       context->stream_desc[index].stride = 8; 
                     break;
                 case 3: 
                     radeonEmitVec12(dst, input[i]->Ptr, input[i]->StrideB, local_count); 
-                                       context->stream_desc[index].stride = 12; 
                     break;
                 case 4: 
                     radeonEmitVec16(dst, input[i]->Ptr, input[i]->StrideB, local_count); 
-                                       context->stream_desc[index].stride = 16; 
                     break;
                 default: 
                     assert(0); 
                     break;
                 }
+               radeon_bo_unmap(context->stream_desc[index].bo);
             }
         }
 
@@ -786,7 +716,6 @@ static void r700SetupStreams2(GLcontext *ctx, const struct gl_client_array *inpu
         }
     }
 
-    context->radeon.tcl.aos_count = context->nNumActiveAos;
     ret = radeon_cs_space_check_with_bo(context->radeon.cmdbuf.cs, 
                                         first_elem(&context->radeon.dma.reserved)->bo, 
                                         RADEON_GEM_DOMAIN_GTT, 0);    
@@ -841,6 +770,7 @@ static void r700FixupIndexBuffer(GLcontext *ctx, const struct _mesa_index_buffer
        radeonAllocDmaRegion(&context->radeon, &context->ind_buf.bo,
                             &context->ind_buf.bo_offset, size, 4);
 
+       radeon_bo_map(context->ind_buf.bo, 1);
        assert(context->ind_buf.bo->ptr != NULL);
        out = (GLuint *)ADD_POINTERS(context->ind_buf.bo->ptr, context->ind_buf.bo_offset);
 
@@ -854,6 +784,7 @@ static void r700FixupIndexBuffer(GLcontext *ctx, const struct _mesa_index_buffer
             *out++ = in[i];
         }
 
+       radeon_bo_unmap(context->ind_buf.bo);
 #if MESA_BIG_ENDIAN
     }
     else
@@ -864,6 +795,7 @@ static void r700FixupIndexBuffer(GLcontext *ctx, const struct _mesa_index_buffer
        radeonAllocDmaRegion(&context->radeon, &context->ind_buf.bo,
                             &context->ind_buf.bo_offset, size, 4);
 
+       radeon_bo_map(context->ind_buf.bo, 1);
        assert(context->ind_buf.bo->ptr != NULL);
        out = (GLuint *)ADD_POINTERS(context->ind_buf.bo->ptr, context->ind_buf.bo_offset);
 
@@ -876,6 +808,7 @@ static void r700FixupIndexBuffer(GLcontext *ctx, const struct _mesa_index_buffer
         {
             *out++ = in[i];
         }
+       radeon_bo_unmap(context->ind_buf.bo);
 #endif
     }
 
@@ -921,11 +854,13 @@ static void r700SetupIndexBuffer(GLcontext *ctx, const struct _mesa_index_buffer
 
        radeonAllocDmaRegion(&context->radeon, &context->ind_buf.bo,
                             &context->ind_buf.bo_offset, size, 4);
+       radeon_bo_map(context->ind_buf.bo, 1);
        assert(context->ind_buf.bo->ptr != NULL);
        dst_ptr = ADD_POINTERS(context->ind_buf.bo->ptr, context->ind_buf.bo_offset);
 
         _mesa_memcpy(dst_ptr, src_ptr, size);
 
+       radeon_bo_unmap(context->ind_buf.bo);
         context->ind_buf.is_32bit = (mesa_ind_buf->type == GL_UNSIGNED_INT);
         context->ind_buf.count = mesa_ind_buf->count;
 
@@ -941,12 +876,12 @@ static void r700SetupIndexBuffer(GLcontext *ctx, const struct _mesa_index_buffer
 }
 
 static GLboolean r700TryDrawPrims(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 )
+                                 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 )
 {
     context_t *context = R700_CONTEXT(ctx);
     radeonContextPtr radeon = &context->radeon;
@@ -954,14 +889,12 @@ static GLboolean r700TryDrawPrims(GLcontext *ctx,
     struct radeon_renderbuffer *rrb;
 
     if (ctx->NewState)
-    {
         _mesa_update_state( ctx );
-    }
 
     _tnl_UpdateFixedFunctionProgram(ctx);
     r700SetVertexFormat(ctx, arrays, max_index + 1);
     /* shaders need to be updated before buffers are validated */
-    r700UpdateShaders2(ctx);
+    r700UpdateShaders(ctx);
     if (!r600ValidateBuffers(ctx))
            return GL_FALSE;
 
@@ -975,23 +908,29 @@ static GLboolean r700TryDrawPrims(GLcontext *ctx,
     r700SetScissor(context);
     r700SetupVertexProgram(ctx);
     r700SetupFragmentProgram(ctx);
-    r600UpdateTextureState(ctx);
+    r700UpdateShaderStates(ctx);
 
-    GLuint emit_end = r700PredictRenderSize(ctx, nr_prims)
+    GLuint emit_end = r700PredictRenderSize(ctx, prim, ib, nr_prims)
                     + context->radeon.cmdbuf.cs->cdw;
 
     r700SetupIndexBuffer(ctx, ib);
-    r700SetupStreams2(ctx, arrays, max_index + 1);
+    r700SetupStreams(ctx, arrays, max_index + 1);
 
     radeonEmitState(radeon);
 
     radeon_debug_add_indent();
     for (i = 0; i < nr_prims; ++i)
     {
-           r700RunRenderPrimitive(ctx,
-                               prim[i].start,
-                               prim[i].start + prim[i].count,
-                               prim[i].mode);
+           if (context->ind_buf.bo)
+                   r700RunRenderPrimitive(ctx,
+                                          prim[i].start,
+                                          prim[i].start + prim[i].count,
+                                          prim[i].mode);
+           else
+                   r700RunRenderPrimitiveImmediate(ctx,
+                                                   prim[i].start,
+                                                   prim[i].start + prim[i].count,
+                                                   prim[i].mode);
     }
     radeon_debug_remove_indent();
 
@@ -1019,18 +958,18 @@ static GLboolean r700TryDrawPrims(GLcontext *ctx,
     return GL_TRUE;
 }
 
-static void r700DrawPrimsRe(GLcontext *ctx,
-                        const struct gl_client_array *arrays[],
-                        const struct _mesa_prim *prim,
-                        GLuint nr_prims,
-                        const struct _mesa_index_buffer *ib,
-                        GLboolean index_bounds_valid,
-                        GLuint min_index,
-                        GLuint max_index)
+static void r700DrawPrims(GLcontext *ctx,
+                         const struct gl_client_array *arrays[],
+                         const struct _mesa_prim *prim,
+                         GLuint nr_prims,
+                         const struct _mesa_index_buffer *ib,
+                         GLboolean index_bounds_valid,
+                         GLuint min_index,
+                         GLuint max_index)
 {
-    GLboolean retval = GL_FALSE;
+       GLboolean retval = GL_FALSE;
 
-    /* This check should get folded into just the places that
+       /* This check should get folded into just the places that
         * min/max index are really needed.
         */
        if (!index_bounds_valid) {
@@ -1038,7 +977,7 @@ static void r700DrawPrimsRe(GLcontext *ctx,
        }
 
        if (min_index) {
-               vbo_rebase_prims( ctx, arrays, prim, nr_prims, ib, min_index, max_index, r700DrawPrimsRe );
+               vbo_rebase_prims( ctx, arrays, prim, nr_prims, ib, min_index, max_index, r700DrawPrims );
                return;
        }
 
@@ -1050,30 +989,6 @@ static void r700DrawPrimsRe(GLcontext *ctx,
                _tnl_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index);
 }
 
-static void r700DrawPrims(GLcontext *ctx,
-                        const struct gl_client_array *arrays[],
-                        const struct _mesa_prim *prim,
-                        GLuint nr_prims,
-                        const struct _mesa_index_buffer *ib,
-                        GLboolean index_bounds_valid,
-                        GLuint min_index,
-                        GLuint max_index)
-{
-    context_t *context = R700_CONTEXT(ctx);
-
-    /* For non indexed drawing, using tnl pipe. */
-    if(!ib)
-    {
-        context->ind_buf.bo = NULL;
-
-        _tnl_vbo_draw_prims(ctx, arrays, prim, nr_prims, ib,
-                            index_bounds_valid, min_index, max_index);
-        return;
-    }
-
-       r700DrawPrimsRe(ctx, arrays, prim, nr_prims, ib, index_bounds_valid, min_index, max_index);
-}
-
 void r700InitDraw(GLcontext *ctx)
 {
        struct vbo_context *vbo = vbo_context(ctx);
index 955ea4e4e1da925398c4f72de2ba4f9f04937ba5..2eed1acc2f55f2f26139291e67a4299221bd530f 100644 (file)
@@ -159,13 +159,18 @@ void Init_R700_Shader(R700_Shader * pShader)
        pShader->lstVTXInstructions.uNumOfNode=0;
 }
 
+void SetActiveCFlist(R700_Shader *pShader, TypedShaderList * plstCF)
+{
+    pShader->plstCFInstructions_active = plstCF;
+}
+
 void AddCFInstruction(R700_Shader *pShader, R700ControlFlowInstruction *pCFInst)
 {
     R700ControlFlowSXClause*  pSXClause; 
     R700ControlFlowSMXClause* pSMXClause;
 
-    pCFInst->m_uIndex = pShader->lstCFInstructions.uNumOfNode;
-    AddInstToList(&(pShader->lstCFInstructions)
+    pCFInst->m_uIndex = pShader->plstCFInstructions_active->uNumOfNode;
+    AddInstToList(pShader->plstCFInstructions_active
                   (R700ShaderInstruction*)pCFInst);
     pShader->uShaderBinaryDWORDSize += GetInstructionSize(pCFInst->m_ShaderInstType);
 
index 997cb05aaf806f1806500bff10cb811c782e0465..0599ffd901f8542b61502a65917ad484bec68ff2 100644 (file)
@@ -109,6 +109,7 @@ typedef struct R700_Shader
     GLuint  uStackSize;
     GLuint  uMaxCallDepth;
 
+    TypedShaderList * plstCFInstructions_active;
        TypedShaderList lstCFInstructions;
        TypedShaderList lstALUInstructions;
        TypedShaderList lstTEXInstructions;
@@ -128,16 +129,17 @@ typedef struct R700_Shader
 
 //Internal
 void AddInstToList(TypedShaderList * plstCFInstructions, R700ShaderInstruction * pInst);
+void TakeInstOutFromList(TypedShaderList * plstCFInstructions, R700ShaderInstruction * pInst);
 void ResolveLinks(R700_Shader *pShader);
 void Assemble(R700_Shader *pShader);
 
-
 //Interface
 void Init_R700_Shader(R700_Shader * pShader);
 void AddCFInstruction(R700_Shader *pShader, R700ControlFlowInstruction *pCFInst);
 void AddVTXInstruction(R700_Shader *pShader, R700VertexInstruction *pVTXInst);
 void AddTEXInstruction(R700_Shader *pShader, R700TextureInstruction *pTEXInst);
 void AddALUInstruction(R700_Shader *pShader, R700ALUInstruction *pALUInst);
+void SetActiveCFlist(R700_Shader *pShader, TypedShaderList * plstCF);
 
 void LoadProgram(R700_Shader *pShader);
 void UpdateShaderRegisters(R700_Shader *pShader);
index 2829cca0a3cb1c87af4f583d6dac42ece0591420..cdb9a570f7ccf036442b979fee927eeff5631a06 100644 (file)
 #define SQ_FETCH_RESOURCE_VS_OFFSET    0x000000a0
 #define SQ_FETCH_RESOURCE_VS_COUNT     0x000000b0
 
+//richard dec.10 glsl
+#define SQ_TEX_SAMPLER_PS_OFFSET       0x00000000
+#define SQ_TEX_SAMPLER_PS_COUNT        0x00000012
+#define SQ_TEX_SAMPLER_VS_OFFSET       0x00000012
+#define SQ_TEX_SAMPLER_VS_COUNT        0x00000012
+//-------------------
+
 #define SHADERINST_TYPEMASK_CF  0x10
 #define SHADERINST_TYPEMASK_ALU 0x20
 #define SHADERINST_TYPEMASK_TEX 0x40
index 7e8b48f91ebe0e5409cc552b8513a8919af045d3..3c8cb579f9bcae6e5d0ebbc3e267d3fcf3861dd2 100644 (file)
@@ -46,7 +46,6 @@
 #include "shader/prog_parameter.h"
 #include "shader/prog_statevars.h"
 #include "vbo/vbo.h"
-#include "main/texformat.h"
 
 #include "r600_context.h"
 
 #include "r700_fragprog.h"
 #include "r700_vertprog.h"
 
-
+void r600UpdateTextureState(GLcontext * ctx);
 static void r700SetClipPlaneState(GLcontext * ctx, GLenum cap, GLboolean state);
 static void r700UpdatePolygonMode(GLcontext * ctx);
 static void r700SetPolygonOffsetState(GLcontext * ctx, GLboolean state);
 static void r700SetStencilState(GLcontext * ctx, GLboolean state);
 
-void r700UpdateShaders (GLcontext * ctx)  //----------------------------------
+void r700UpdateShaders(GLcontext * ctx)
 {
     context_t *context = R700_CONTEXT(ctx);
-    GLvector4f dummy_attrib[_TNL_ATTRIB_MAX];
-    GLvector4f *temp_attrib[_TNL_ATTRIB_MAX];
-    int i;
 
     /* should only happenen once, just after context is created */
     /* TODO: shouldn't we fallback to sw here? */
@@ -77,40 +73,7 @@ void r700UpdateShaders (GLcontext * ctx)  //----------------------------------
 
     r700SelectFragmentShader(ctx);
 
-    if (context->radeon.NewGLState) {
-           for (i = _TNL_FIRST_MAT; i <= _TNL_LAST_MAT; i++) {
-                   /* mat states from state var not array for sw */
-                   dummy_attrib[i].stride = 0;
-                   temp_attrib[i] = TNL_CONTEXT(ctx)->vb.AttribPtr[i];
-                   TNL_CONTEXT(ctx)->vb.AttribPtr[i] = &(dummy_attrib[i]);
-           }
-
-           _tnl_UpdateFixedFunctionProgram(ctx);
-
-           for (i = _TNL_FIRST_MAT; i <= _TNL_LAST_MAT; i++) {
-                   TNL_CONTEXT(ctx)->vb.AttribPtr[i] = temp_attrib[i];
-           }
-    }
-
-    r700SelectVertexShader(ctx, 1);
-    r700UpdateStateParameters(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
-    context->radeon.NewGLState = 0;
-}
-
-void r700UpdateShaders2(GLcontext * ctx)  
-{
-    context_t *context = R700_CONTEXT(ctx);
-
-    /* should only happenen once, just after context is created */
-    /* TODO: shouldn't we fallback to sw here? */
-    if (!ctx->FragmentProgram._Current) {
-           _mesa_fprintf(stderr, "No ctx->FragmentProgram._Current!!\n");
-           return;
-    }
-
-    r700SelectFragmentShader(ctx);
-
-    r700SelectVertexShader(ctx, 2);
+    r700SelectVertexShader(ctx);
     r700UpdateStateParameters(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
     context->radeon.NewGLState = 0;
 }
@@ -122,7 +85,7 @@ void r700UpdateViewportOffset(GLcontext * ctx) //------------------
 {
        context_t *context = R700_CONTEXT(ctx);
        R700_CHIP_CONTEXT *r700 = (R700_CHIP_CONTEXT*)(&context->hw);
-       __DRIdrawablePrivate *dPriv = radeon_get_drawable(&context->radeon);
+       __DRIdrawable *dPriv = radeon_get_drawable(&context->radeon);
        GLfloat xoffset = (GLfloat) dPriv->x;
        GLfloat yoffset = (GLfloat) dPriv->y + dPriv->h;
        const GLfloat *v = ctx->Viewport._WindowMap.m;
@@ -228,6 +191,67 @@ static void r700InvalidateState(GLcontext * ctx, GLuint new_state) //-----------
     context->radeon.NewGLState |= new_state;
 }
 
+static void r700SetDBRenderState(GLcontext * ctx)
+{
+       context_t *context = R700_CONTEXT(ctx);
+       R700_CHIP_CONTEXT *r700 = (R700_CHIP_CONTEXT*)(&context->hw);
+       struct r700_fragment_program *fp = (struct r700_fragment_program *)
+               (ctx->FragmentProgram._Current);
+
+       R600_STATECHANGE(context, db);
+
+       SETbit(r700->DB_SHADER_CONTROL.u32All, DUAL_EXPORT_ENABLE_bit);
+       SETfield(r700->DB_SHADER_CONTROL.u32All, EARLY_Z_THEN_LATE_Z, Z_ORDER_shift, Z_ORDER_mask);
+       /* XXX need to enable htile for hiz/s */
+       SETfield(r700->DB_RENDER_OVERRIDE.u32All, FORCE_DISABLE, FORCE_HIZ_ENABLE_shift, FORCE_HIZ_ENABLE_mask);
+       SETfield(r700->DB_RENDER_OVERRIDE.u32All, FORCE_DISABLE, FORCE_HIS_ENABLE0_shift, FORCE_HIS_ENABLE0_mask);
+       SETfield(r700->DB_RENDER_OVERRIDE.u32All, FORCE_DISABLE, FORCE_HIS_ENABLE1_shift, FORCE_HIS_ENABLE1_mask);
+
+       if (context->radeon.query.current)
+       {
+               SETbit(r700->DB_RENDER_OVERRIDE.u32All, NOOP_CULL_DISABLE_bit);
+               if (context->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV770)
+               {
+                       SETbit(r700->DB_RENDER_CONTROL.u32All, PERFECT_ZPASS_COUNTS_bit);
+               }
+       }
+       else
+       {
+               CLEARbit(r700->DB_RENDER_OVERRIDE.u32All, NOOP_CULL_DISABLE_bit);
+               if (context->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV770)
+               {
+                       CLEARbit(r700->DB_RENDER_CONTROL.u32All, PERFECT_ZPASS_COUNTS_bit);
+               }
+       }
+
+       if (fp)
+       {
+               if (fp->r700Shader.killIsUsed)
+               {
+                       SETbit(r700->DB_SHADER_CONTROL.u32All, KILL_ENABLE_bit);
+               }
+               else
+               {
+                       CLEARbit(r700->DB_SHADER_CONTROL.u32All, KILL_ENABLE_bit);
+               }
+
+               if (fp->r700Shader.depthIsExported)
+               {
+                       SETbit(r700->DB_SHADER_CONTROL.u32All, Z_EXPORT_ENABLE_bit);
+               }
+               else
+               {
+                       CLEARbit(r700->DB_SHADER_CONTROL.u32All, Z_EXPORT_ENABLE_bit);
+               }
+       }
+}
+
+void r700UpdateShaderStates(GLcontext * ctx)
+{
+       r700SetDBRenderState(ctx);
+       r600UpdateTextureState(ctx);
+}
+
 static void r700SetDepthState(GLcontext * ctx)
 {
        context_t *context = R700_CONTEXT(ctx);
@@ -681,6 +705,10 @@ static void r700UpdateCulling(GLcontext * ctx)
             CLEARbit(r700->PA_SU_SC_MODE_CNTL.u32All, FACE_bit); /* default: ccw */
             break;
     }
+
+    /* Winding is inverted when rendering to FBO */
+    if (ctx->DrawBuffer && ctx->DrawBuffer->Name)
+           r700->PA_SU_SC_MODE_CNTL.u32All ^= FACE_bit;
 }
 
 static void r700UpdateLineStipple(GLcontext * ctx)
@@ -1043,7 +1071,7 @@ static void r700UpdateWindow(GLcontext * ctx, int id) //--------------------
 {
        context_t *context = R700_CONTEXT(ctx);
        R700_CHIP_CONTEXT *r700 = (R700_CHIP_CONTEXT*)(&context->hw);
-       __DRIdrawablePrivate *dPriv = radeon_get_drawable(&context->radeon);
+       __DRIdrawable *dPriv = radeon_get_drawable(&context->radeon);
        GLfloat xoffset = dPriv ? (GLfloat) dPriv->x : 0;
        GLfloat yoffset = dPriv ? (GLfloat) dPriv->y + dPriv->h : 0;
        const GLfloat *v = ctx->Viewport._WindowMap.m;
@@ -1067,6 +1095,7 @@ static void r700UpdateWindow(GLcontext * ctx, int id) //--------------------
        GLfloat tz = v[MAT_TZ] * depthScale;
 
        R600_STATECHANGE(context, vpt);
+       R600_STATECHANGE(context, cl);
 
        r700->viewport[id].PA_CL_VPORT_XSCALE.f32All  = sx;
        r700->viewport[id].PA_CL_VPORT_XOFFSET.f32All = tx;
@@ -1077,6 +1106,18 @@ static void r700UpdateWindow(GLcontext * ctx, int id) //--------------------
        r700->viewport[id].PA_CL_VPORT_ZSCALE.f32All  = sz;
        r700->viewport[id].PA_CL_VPORT_ZOFFSET.f32All = tz;
 
+       if (ctx->Transform.DepthClamp) {
+               r700->viewport[id].PA_SC_VPORT_ZMIN_0.f32All = MIN2(ctx->Viewport.Near, ctx->Viewport.Far);
+               r700->viewport[id].PA_SC_VPORT_ZMAX_0.f32All = MAX2(ctx->Viewport.Near, ctx->Viewport.Far);
+               SETbit(r700->PA_CL_CLIP_CNTL.u32All, ZCLIP_NEAR_DISABLE_bit);
+               SETbit(r700->PA_CL_CLIP_CNTL.u32All, ZCLIP_FAR_DISABLE_bit);
+       } else {
+               r700->viewport[id].PA_SC_VPORT_ZMIN_0.f32All = 0.0;
+               r700->viewport[id].PA_SC_VPORT_ZMAX_0.f32All = 1.0;
+               CLEARbit(r700->PA_CL_CLIP_CNTL.u32All, ZCLIP_NEAR_DISABLE_bit);
+               CLEARbit(r700->PA_CL_CLIP_CNTL.u32All, ZCLIP_FAR_DISABLE_bit);
+       }
+
        r700->viewport[id].enabled = GL_TRUE;
 
        r700SetScissor(context);
@@ -1190,13 +1231,8 @@ static void r700UpdatePolygonMode(GLcontext * ctx)
                /* Handle GL_CW (clock wise and GL_CCW (counter clock wise)
                 * correctly by selecting the correct front and back face
                 */
-               if (ctx->Polygon.FrontFace == GL_CCW) {
-                       f = ctx->Polygon.FrontMode;
-                       b = ctx->Polygon.BackMode;
-               } else {
-                       f = ctx->Polygon.BackMode;
-                       b = ctx->Polygon.FrontMode;
-               }
+               f = ctx->Polygon.FrontMode;
+               b = ctx->Polygon.BackMode;
 
                /* Enable polygon mode */
                SETfield(r700->PA_SU_SC_MODE_CNTL.u32All, X_DUAL_MODE, POLY_MODE_shift, POLY_MODE_mask);
@@ -1295,11 +1331,15 @@ void r700SetScissor(context_t *context) //---------------
                return;
        }
        if (context->radeon.state.scissor.enabled) {
-               /* r600 has exclusive scissors */
                x1 = context->radeon.state.scissor.rect.x1;
                y1 = context->radeon.state.scissor.rect.y1;
-               x2 = context->radeon.state.scissor.rect.x2 + 1;
-               y2 = context->radeon.state.scissor.rect.y2 + 1;
+               x2 = context->radeon.state.scissor.rect.x2;
+               y2 = context->radeon.state.scissor.rect.y2;
+               /* r600 has exclusive BR scissors */
+               if (context->radeon.radeonScreen->kernel_mm) {
+                       x2++;
+                       y2++;
+               }
        } else {
                if (context->radeon.radeonScreen->driScreen->dri2.enabled) {
                        x1 = 0;
@@ -1378,8 +1418,6 @@ void r700SetScissor(context_t *context) //---------------
        SETfield(r700->viewport[id].PA_SC_VPORT_SCISSOR_0_BR.u32All, y2,
                 PA_SC_VPORT_SCISSOR_0_BR__BR_Y_shift, PA_SC_VPORT_SCISSOR_0_BR__BR_Y_mask);
 
-       r700->viewport[id].PA_SC_VPORT_ZMIN_0.u32All = 0;
-       r700->viewport[id].PA_SC_VPORT_ZMAX_0.u32All = 0x3F800000;
        r700->viewport[id].enabled = GL_TRUE;
 }
 
@@ -1686,27 +1724,18 @@ void r700InitState(GLcontext * ctx) //-------------------
     r700InitSQConfig(ctx);
 
     r700ColorMask(ctx,
-                 ctx->Color.ColorMask[RCOMP],
-                 ctx->Color.ColorMask[GCOMP],
-                 ctx->Color.ColorMask[BCOMP],
-                 ctx->Color.ColorMask[ACOMP]);
+                 ctx->Color.ColorMask[0][RCOMP],
+                 ctx->Color.ColorMask[0][GCOMP],
+                 ctx->Color.ColorMask[0][BCOMP],
+                 ctx->Color.ColorMask[0][ACOMP]);
 
     r700Enable(ctx, GL_DEPTH_TEST, ctx->Depth.Test);
     r700DepthMask(ctx, ctx->Depth.Mask);
     r700DepthFunc(ctx, ctx->Depth.Func);
-    SETbit(r700->DB_SHADER_CONTROL.u32All, DUAL_EXPORT_ENABLE_bit);
-
     r700->DB_DEPTH_CLEAR.u32All     = 0x3F800000;
-
-    r700->DB_RENDER_CONTROL.u32All  = 0;
     SETbit(r700->DB_RENDER_CONTROL.u32All, STENCIL_COMPRESS_DISABLE_bit);
     SETbit(r700->DB_RENDER_CONTROL.u32All, DEPTH_COMPRESS_DISABLE_bit);
-    r700->DB_RENDER_OVERRIDE.u32All = 0;
-    if (context->radeon.radeonScreen->chip_family < CHIP_FAMILY_RV770)
-           SETbit(r700->DB_RENDER_OVERRIDE.u32All, FORCE_SHADER_Z_ORDER_bit);
-    SETfield(r700->DB_RENDER_OVERRIDE.u32All, FORCE_DISABLE, FORCE_HIZ_ENABLE_shift, FORCE_HIZ_ENABLE_mask);
-    SETfield(r700->DB_RENDER_OVERRIDE.u32All, FORCE_DISABLE, FORCE_HIS_ENABLE0_shift, FORCE_HIS_ENABLE0_mask);
-    SETfield(r700->DB_RENDER_OVERRIDE.u32All, FORCE_DISABLE, FORCE_HIS_ENABLE1_shift, FORCE_HIS_ENABLE1_mask);
+    r700SetDBRenderState(ctx);
 
     r700->DB_ALPHA_TO_MASK.u32All = 0;
     SETfield(r700->DB_ALPHA_TO_MASK.u32All, 2, ALPHA_TO_MASK_OFFSET0_shift, ALPHA_TO_MASK_OFFSET0_mask);
index 209189d8d72813f55a45a60d7c2885e85437c122..60c6a7f23ca7d59e508bddd12b9a48ad2e950b07 100644 (file)
@@ -35,7 +35,7 @@
 
 extern void r700UpdateStateParameters(GLcontext * ctx, GLuint new_state);
 extern void r700UpdateShaders (GLcontext * ctx);
-extern void r700UpdateShaders2(GLcontext * ctx);
+extern void r700UpdateShaderStates(GLcontext * ctx);
 
 extern void r700UpdateViewportOffset(GLcontext * ctx);
 
index d12c39c9f73eafed3ae4f48c7addfa77e8128a3d..782f151f5ac42d3824354d89c3b45a5e348b1aef 100644 (file)
@@ -111,6 +111,15 @@ unsigned int Map_Vertex_Output(r700_AssemblerBase       *pAsm,
                }
        }
 
+    for(i=VERT_RESULT_VAR0; i<VERT_RESULT_MAX; i++)
+       {
+               unBit = 1 << i;
+               if(mesa_vp->Base.OutputsWritten & unBit)
+               {
+                       pAsm->ucVP_OutputMap[i] = unTotal++;
+               }
+       }
+
        return (unTotal - unStart);
 }
 
@@ -179,7 +188,8 @@ GLboolean Process_Vertex_Program_Vfetch_Instructions2(
                                       context->stream_desc[i].size,
                                       context->stream_desc[i].element,
                                       context->stream_desc[i]._signed,
-                                      context->stream_desc[i].normalize,                                                           
+                                      context->stream_desc[i].normalize,
+                                      context->stream_desc[i].format,
                                      &vtxFetchMethod);
     }
 
@@ -203,22 +213,11 @@ void Map_Vertex_Program(GLcontext *ctx,
        pAsm->number_used_registers += num_inputs;
 
        // Create VFETCH instructions for inputs
-       if(1 == vp->uiVersion) 
-    {
-           if (GL_TRUE != Process_Vertex_Program_Vfetch_Instructions(vp, mesa_vp) ) 
-           {
-                   radeon_error("Calling Process_Vertex_Program_Vfetch_Instructions return error. \n");
-                   return; 
-           }
-    }
-    else
-    {
-        if (GL_TRUE != Process_Vertex_Program_Vfetch_Instructions2(ctx, vp, mesa_vp) ) 
-           {
-                   radeon_error("Calling Process_Vertex_Program_Vfetch_Instructions2 return error. \n");
-                   return; 
-           }
-    }
+        if (GL_TRUE != Process_Vertex_Program_Vfetch_Instructions2(ctx, vp, mesa_vp) )
+       {
+               radeon_error("Calling Process_Vertex_Program_Vfetch_Instructions2 return error. \n");
+               return;
+       }
 
        // Map Outputs
        pAsm->number_of_exports = Map_Vertex_Output(pAsm, mesa_vp, pAsm->number_used_registers);
@@ -228,7 +227,7 @@ void Map_Vertex_Program(GLcontext *ctx,
        pAsm->number_used_registers += pAsm->number_of_exports;
 
     pAsm->pucOutMask = (unsigned char*) MALLOC(pAsm->number_of_exports);
-    
+
     for(ui=0; ui<pAsm->number_of_exports; ui++)
     {
         pAsm->pucOutMask[ui] = 0x0;
@@ -245,7 +244,9 @@ void Map_Vertex_Program(GLcontext *ctx,
     {   /* fix func t_vp uses NumTemporaries */
         pAsm->number_used_registers += mesa_vp->Base.NumTemporaries;
     }
-       
+
+    pAsm->flag_reg_index = pAsm->number_used_registers++;
+
     pAsm->uFirstHelpReg = pAsm->number_used_registers;
 }
 
@@ -300,18 +301,13 @@ GLboolean Find_Instruction_Dependencies_vp(struct r700_vertex_program *vp,
 }
 
 struct r700_vertex_program* r700TranslateVertexShader(GLcontext *ctx,
-                                               struct gl_vertex_program *mesa_vp,
-                        GLint nVer)
+                                                     struct gl_vertex_program *mesa_vp)
 {
        context_t *context = R700_CONTEXT(ctx);
        struct r700_vertex_program *vp;
-       TNLcontext *tnl = TNL_CONTEXT(ctx);
-       struct vertex_buffer *vb = &tnl->vb;
-       unsigned int unBit;
        unsigned int i;
 
        vp = _mesa_calloc(sizeof(*vp));
-    vp->uiVersion = nVer;
        vp->mesa_program = (struct gl_vertex_program *)_mesa_clone_program(ctx, &mesa_vp->Base);
 
        if (mesa_vp->IsPositionInvariant)
@@ -319,29 +315,14 @@ struct r700_vertex_program* r700TranslateVertexShader(GLcontext *ctx,
                 _mesa_insert_mvp_code(ctx, vp->mesa_program);
         }
 
-       if( 1 == nVer )
+       for(i=0; i<context->nNumActiveAos; i++)
        {
-           for(i=0; i<VERT_ATTRIB_MAX; i++)
-           {
-               unBit = 1 << i;
-               if(vp->mesa_program->Base.InputsRead & unBit) /* ctx->Array.ArrayObj->xxxxxxx */
-               {
-                       vp->aos_desc[i].size   = vb->AttribPtr[i]->size;
-                       vp->aos_desc[i].stride = vb->AttribPtr[i]->size * sizeof(GL_FLOAT);/* when emit array, data is packed. vb->AttribPtr[i]->stride;*/
-                       vp->aos_desc[i].type   = GL_FLOAT;
-               }
-           }
+               vp->aos_desc[i].size   = context->stream_desc[i].size;
+               vp->aos_desc[i].stride = context->stream_desc[i].stride;
+               vp->aos_desc[i].type   = context->stream_desc[i].type;
+               vp->aos_desc[i].format = context->stream_desc[i].format;
        }
-       else
-       {
-               for(i=0; i<context->nNumActiveAos; i++)
-               {
-                       vp->aos_desc[i].size   = context->stream_desc[i].size;
-                       vp->aos_desc[i].stride = context->stream_desc[i].stride;
-                       vp->aos_desc[i].type   = context->stream_desc[i].type;
-               }
-       }       
-       
+
        if (context->radeon.radeonScreen->chip_family < CHIP_FAMILY_RV770)
        {
                vp->r700AsmCode.bR6xx = 1;
@@ -354,20 +335,36 @@ struct r700_vertex_program* r700TranslateVertexShader(GLcontext *ctx,
        if(GL_FALSE == Find_Instruction_Dependencies_vp(vp, vp->mesa_program))
        {
                return NULL;
+       }
+
+    InitShaderProgram(&(vp->r700AsmCode));
+
+    for(i=0; i < MAX_SAMPLERS; i++)
+    {
+        vp->r700AsmCode.SamplerUnits[i] = vp->mesa_program->Base.SamplerUnits[i];
     }
 
-       if(GL_FALSE == AssembleInstr(vp->mesa_program->Base.NumInstructions,
-                                 &(vp->mesa_program->Base.Instructions[0]), 
+    vp->r700AsmCode.unCurNumILInsts = vp->mesa_program->Base.NumInstructions;
+
+       if(GL_FALSE == AssembleInstr(0,
+                                 0,
+                                 vp->mesa_program->Base.NumInstructions,
+                                 &(vp->mesa_program->Base.Instructions[0]),
                                  &(vp->r700AsmCode)) )
        {
                return NULL;
-       } 
+       }
 
     if(GL_FALSE == Process_Vertex_Exports(&(vp->r700AsmCode), vp->mesa_program->Base.OutputsWritten) )
     {
         return NULL;
     }
 
+    if( GL_FALSE == RelocProgram(&(vp->r700AsmCode), &(vp->mesa_program->Base)) )
+    {
+        return GL_FALSE;
+    }
+
     vp->r700Shader.nRegs = (vp->r700AsmCode.number_used_registers == 0) ? 0 
                          : (vp->r700AsmCode.number_used_registers - 1);
 
@@ -378,14 +375,11 @@ struct r700_vertex_program* r700TranslateVertexShader(GLcontext *ctx,
        return vp;
 }
 
-void r700SelectVertexShader(GLcontext *ctx, GLint nVersion)
+void r700SelectVertexShader(GLcontext *ctx)
 {
     context_t *context = R700_CONTEXT(ctx);
     struct r700_vertex_program_cont *vpc;
     struct r700_vertex_program *vp;
-    TNLcontext *tnl = TNL_CONTEXT(ctx);
-    struct vertex_buffer *vb = &tnl->vb;
-    unsigned int unBit;
     unsigned int i;
     GLboolean match;
     GLbitfield InputsRead;
@@ -396,47 +390,28 @@ void r700SelectVertexShader(GLcontext *ctx, GLint nVersion)
     if (vpc->mesa_program.IsPositionInvariant)
     {
        InputsRead |= VERT_BIT_POS;
-    } 
-    
+    }
+
     for (vp = vpc->progs; vp; vp = vp->next)
     {
-       if (vp->uiVersion != nVersion ) 
-           continue;
-       match = GL_TRUE;        
-       if ( 1 == nVersion ) 
+       match = GL_TRUE;
+       for(i=0; i<context->nNumActiveAos; i++)
        {
-           for(i=0; i<VERT_ATTRIB_MAX; i++)
-           {
-               unBit = 1 << i;
-               if(InputsRead & unBit)
+               if (vp->aos_desc[i].size != context->stream_desc[i].size ||
+                   vp->aos_desc[i].format != context->stream_desc[i].format)
                {
-                   if (vp->aos_desc[i].size != vb->AttribPtr[i]->size)
-                   {
                        match = GL_FALSE;
                        break;
-                   }
                }
-           }
        }
-       else
-       {
-           for(i=0; i<context->nNumActiveAos; i++)
-           {
-               if (vp->aos_desc[i].size != context->stream_desc[i].size)
-               {
-                   match = GL_FALSE;
-                   break;
-               }
-           }
-       }       
-       if (match) 
+       if (match)
        {
                context->selected_vp = vp;
                return;
        }
     }
 
-    vp = r700TranslateVertexShader(ctx, &(vpc->mesa_program), nVersion);
+    vp = r700TranslateVertexShader(ctx, &(vpc->mesa_program));
     if(!vp)
     {
        radeon_error("Failed to translate vertex shader. \n");
@@ -526,6 +501,7 @@ static void r700TranslateAttrib(GLcontext *ctx, GLuint unLoc, int count, const s
        pStreamDesc->size = input->Size;
        pStreamDesc->dst_loc = context->nNumActiveAos;
        pStreamDesc->element = unLoc;
+       pStreamDesc->format = input->Format;
 
        switch (pStreamDesc->type) 
        { //GetSurfaceFormat
@@ -570,6 +546,11 @@ void r700SetVertexFormat(GLcontext *ctx, const struct gl_client_array *arrays[],
     unsigned int unBit = mesa_vp->Base.InputsRead;
     context->nNumActiveAos = 0;
 
+    if (mesa_vp->IsPositionInvariant)
+    {
+        unBit |= VERT_BIT_POS;
+    }
+
     while(unBit) 
     {
         if(unBit & 1)
@@ -580,6 +561,7 @@ void r700SetVertexFormat(GLcontext *ctx, const struct gl_client_array *arrays[],
         unBit >>= 1;
         ++unLoc;
     }
+    context->radeon.tcl.aos_count = context->nNumActiveAos;
 }
 
 void * r700GetActiveVpShaderBo(GLcontext * ctx)
@@ -661,6 +643,12 @@ GLboolean r700SetupVertexProgram(GLcontext * ctx)
     paramList = vp->mesa_program->Base.Parameters;
 
     if(NULL != paramList) {
+        /* vp->mesa_program was cloned, not updated by glsl shader api. */
+        /* _mesa_reference_program has already checked glsl shProg is ok and set ctx->VertexProgem._Current */
+        /* so, use ctx->VertexProgem._Current */       
+        struct gl_program_parameter_list *paramListOrginal = 
+                         paramListOrginal = ctx->VertexProgram._Current->Base.Parameters;
+         
            _mesa_load_state_parameters(ctx, paramList);
 
            if (paramList->NumParameters > R700_MAX_DX9_CONSTS)
@@ -673,13 +661,42 @@ GLboolean r700SetupVertexProgram(GLcontext * ctx)
            unNumParamData = paramList->NumParameters;
 
            for(ui=0; ui<unNumParamData; ui++) {
-                   r700->vs.consts[ui][0].f32All = paramList->ParameterValues[ui][0];
-                   r700->vs.consts[ui][1].f32All = paramList->ParameterValues[ui][1];
-                   r700->vs.consts[ui][2].f32All = paramList->ParameterValues[ui][2];
-                   r700->vs.consts[ui][3].f32All = paramList->ParameterValues[ui][3];
+            if(paramList->Parameters[ui].Type == PROGRAM_UNIFORM) 
+            {
+                r700->vs.consts[ui][0].f32All = paramListOrginal->ParameterValues[ui][0];
+                       r700->vs.consts[ui][1].f32All = paramListOrginal->ParameterValues[ui][1];
+                       r700->vs.consts[ui][2].f32All = paramListOrginal->ParameterValues[ui][2];
+                       r700->vs.consts[ui][3].f32All = paramListOrginal->ParameterValues[ui][3];
+            }
+            else
+            {
+                       r700->vs.consts[ui][0].f32All = paramList->ParameterValues[ui][0];
+                       r700->vs.consts[ui][1].f32All = paramList->ParameterValues[ui][1];
+                       r700->vs.consts[ui][2].f32All = paramList->ParameterValues[ui][2];
+                       r700->vs.consts[ui][3].f32All = paramList->ParameterValues[ui][3];
+            }
            }
     } else
            r700->vs.num_consts = 0;
 
+    COMPILED_SUB * pCompiledSub;
+    GLuint uj;
+    GLuint unConstOffset = r700->vs.num_consts;
+    for(ui=0; ui<vp->r700AsmCode.unNumPresub; ui++)
+    {
+        pCompiledSub = vp->r700AsmCode.presubs[ui].pCompiledSub;
+
+        r700->vs.num_consts += pCompiledSub->NumParameters;
+
+        for(uj=0; uj<pCompiledSub->NumParameters; uj++)
+        {
+            r700->vs.consts[uj + unConstOffset][0].f32All = pCompiledSub->ParameterValues[uj][0];
+                   r700->vs.consts[uj + unConstOffset][1].f32All = pCompiledSub->ParameterValues[uj][1];
+                   r700->vs.consts[uj + unConstOffset][2].f32All = pCompiledSub->ParameterValues[uj][2];
+                   r700->vs.consts[uj + unConstOffset][3].f32All = pCompiledSub->ParameterValues[uj][3];
+        }
+        unConstOffset += pCompiledSub->NumParameters;
+    }
+
     return GL_TRUE;
 }
index f9a3e395ee9fbe49d84565be1aa30e0bb82582b8..645c9ac84aae4e7346e4e6f8e53cd3e7d67066ab 100644 (file)
@@ -39,6 +39,7 @@ typedef struct ArrayDesc //TEMP
        GLint size;   //number of data element
        GLenum type;  //data element type
        GLsizei stride;
+       GLenum format; //GL_RGBA or GL_BGRA
 } ArrayDesc;
 
 struct r700_vertex_program 
@@ -52,8 +53,7 @@ struct r700_vertex_program
 
     GLboolean translated;
     GLboolean loaded;
-    GLint     uiVersion;
-       
+
     void * shaderbo;
 
     ArrayDesc              aos_desc[VERT_ATTRIB_MAX];
@@ -87,11 +87,10 @@ GLboolean Find_Instruction_Dependencies_vp(struct r700_vertex_program *vp,
                                           struct gl_vertex_program   *mesa_vp);
 
 struct r700_vertex_program* r700TranslateVertexShader(GLcontext *ctx,
-                                   struct gl_vertex_program   *mesa_vp,
-                    GLint nVer);
+                                                     struct gl_vertex_program   *mesa_vp);
 
 /* Interface */
-extern void r700SelectVertexShader(GLcontext *ctx, GLint nVersion);
+extern void r700SelectVertexShader(GLcontext *ctx);
 extern void r700SetVertexFormat(GLcontext *ctx, const struct gl_client_array *arrays[], int count);
 
 extern GLboolean r700SetupVertexProgram(GLcontext * ctx);
diff --git a/src/mesa/drivers/dri/r600/radeon_bo.c b/src/mesa/drivers/dri/r600/radeon_bo.c
new file mode 120000 (symlink)
index 0000000..9448ffe
--- /dev/null
@@ -0,0 +1 @@
+../radeon/radeon_bo.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/r600/radeon_bo_int_drm.h b/src/mesa/drivers/dri/r600/radeon_bo_int_drm.h
new file mode 120000 (symlink)
index 0000000..0294509
--- /dev/null
@@ -0,0 +1 @@
+../radeon/radeon_bo_int_drm.h
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/r600/radeon_cs.c b/src/mesa/drivers/dri/r600/radeon_cs.c
new file mode 120000 (symlink)
index 0000000..66b7ad1
--- /dev/null
@@ -0,0 +1 @@
+../radeon/radeon_cs.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/r600/radeon_cs_int_drm.h b/src/mesa/drivers/dri/r600/radeon_cs_int_drm.h
new file mode 120000 (symlink)
index 0000000..462f524
--- /dev/null
@@ -0,0 +1 @@
+../radeon/radeon_cs_int_drm.h
\ No newline at end of file
index b1efc72872f8f8ee03d352387d891a0fd64c4a64..2b2f2c4aa7a70851da88e66dbb1184e57df4bf2b 100644 (file)
@@ -11,7 +11,7 @@ LIBNAME = radeon_dri.so
 MINIGLX_SOURCES = server/radeon_dri.c 
 
 ifeq ($(RADEON_LDFLAGS),)
-CS_SOURCES = radeon_cs_space_drm.c
+CS_SOURCES = radeon_cs_space_drm.c radeon_bo.c radeon_cs.c
 endif
 
 RADEON_COMMON_SOURCES = \
@@ -55,4 +55,3 @@ X86_SOURCES =
 
 include ../Makefile.template
 
-symlinks:
diff --git a/src/mesa/drivers/dri/radeon/radeon_bo.c b/src/mesa/drivers/dri/radeon/radeon_bo.c
new file mode 100644 (file)
index 0000000..393d156
--- /dev/null
@@ -0,0 +1,110 @@
+#include <radeon_bocs_wrapper.h>
+#include <radeon_bo_int_drm.h>
+
+void radeon_bo_debug(struct radeon_bo *bo,
+                    const char *op)
+{
+    struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
+
+    fprintf(stderr, "%s %p 0x%08X 0x%08X 0x%08X\n",
+            op, bo, bo->handle, boi->size, boi->cref);
+}
+
+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)
+{
+    struct radeon_bo *bo;
+    bo = bom->funcs->bo_open(bom, handle, size, alignment, domains, flags);
+    return bo;
+}
+
+void radeon_bo_ref(struct radeon_bo *bo)
+{
+    struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
+    boi->cref++;
+    boi->bom->funcs->bo_ref(boi);
+}
+
+struct radeon_bo *radeon_bo_unref(struct radeon_bo *bo)
+{
+    struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
+    boi->cref--;
+    return boi->bom->funcs->bo_unref(boi);
+}
+
+int radeon_bo_map(struct radeon_bo *bo, int write)
+{
+    struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
+    return boi->bom->funcs->bo_map(boi, write);
+}
+
+int radeon_bo_unmap(struct radeon_bo *bo)
+{
+    struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
+    return boi->bom->funcs->bo_unmap(boi);
+}
+
+int radeon_bo_wait(struct radeon_bo *bo)
+{
+    struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
+    if (!boi->bom->funcs->bo_wait)
+       return 0;
+    return boi->bom->funcs->bo_wait(boi);
+}
+
+int radeon_bo_is_busy(struct radeon_bo *bo,
+                     uint32_t *domain)
+{
+    struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
+    return boi->bom->funcs->bo_is_busy(boi, domain);
+}
+
+int radeon_bo_set_tiling(struct radeon_bo *bo,
+                        uint32_t tiling_flags, uint32_t pitch)
+{
+    struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
+    return boi->bom->funcs->bo_set_tiling(boi, tiling_flags, pitch);
+}
+
+int radeon_bo_get_tiling(struct radeon_bo *bo,
+                         uint32_t *tiling_flags, uint32_t *pitch)
+{
+    struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
+    return boi->bom->funcs->bo_get_tiling(boi, tiling_flags, pitch);
+}
+
+int radeon_bo_is_static(struct radeon_bo *bo)
+{
+    struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
+    if (boi->bom->funcs->bo_is_static)
+       return boi->bom->funcs->bo_is_static(boi);
+    return 0;
+}
+
+int radeon_bo_is_referenced_by_cs(struct radeon_bo *bo,
+                                 struct radeon_cs *cs)
+{
+    struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
+    return boi->cref > 1;
+}
+
+uint32_t radeon_bo_get_handle(struct radeon_bo *bo)
+{
+    return bo->handle;
+}
+
+uint32_t radeon_bo_get_src_domain(struct radeon_bo *bo)
+{
+    struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
+    uint32_t src_domain;
+
+    src_domain = boi->space_accounted & 0xffff;
+    if (!src_domain)
+       src_domain = boi->space_accounted >> 16;
+
+    return src_domain;
+}
index 71413716333c5b924c5401e7e5a8c16dfee3977a..beb2369880ab2fcd7a11f914ca8dcf7a97fd7bf4 100644 (file)
 
 #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_cs;
 
 struct radeon_bo {
-    uint32_t                    alignment;
+    void                        *ptr;
+    uint32_t                    flags;
     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);
-    int (*bo_is_static)(struct radeon_bo *bo);
-    int (*bo_set_tiling)(struct radeon_bo *bo, uint32_t tiling_flags,
-                         uint32_t pitch);
-    int (*bo_get_tiling)(struct radeon_bo *bo, uint32_t *tiling_flags,
-                         uint32_t *pitch);
-    int (*bo_is_busy)(struct radeon_bo *bo, uint32_t *domain);
 };
 
-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);
-}
-
-static inline int _radeon_bo_is_busy(struct radeon_bo *bo,
-                                    uint32_t *domain,
-                                     const char *file,
-                                     const char *func,
-                                     int line)
-{
-    return bo->bom->funcs->bo_is_busy(bo, domain);
-}
-
-static inline int radeon_bo_set_tiling(struct radeon_bo *bo,
-                                      uint32_t tiling_flags, uint32_t pitch)
-{
-    return bo->bom->funcs->bo_set_tiling(bo, tiling_flags, pitch);
-}
-
-static inline int radeon_bo_get_tiling(struct radeon_bo *bo,
-                                      uint32_t *tiling_flags, uint32_t *pitch)
-{
-    return bo->bom->funcs->bo_get_tiling(bo, tiling_flags, pitch);
-}
-
-static inline int radeon_bo_is_static(struct radeon_bo *bo)
-{
-       if (bo->bom->funcs->bo_is_static)
-               return bo->bom->funcs->bo_is_static(bo);
-       return 0;
-}
-
-#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__)
-#define radeon_bo_is_busy(bo, domain) \
-    _radeon_bo_is_busy(bo, domain, __FILE__, __func__, __LINE__)
+struct radeon_bo_manager;
 
+void radeon_bo_debug(struct radeon_bo *bo,
+                    const char *op);
+
+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);
+
+void radeon_bo_ref(struct radeon_bo *bo);
+struct radeon_bo *radeon_bo_unref(struct radeon_bo *bo);
+int radeon_bo_map(struct radeon_bo *bo, int write);
+int radeon_bo_unmap(struct radeon_bo *bo);
+int radeon_bo_wait(struct radeon_bo *bo);
+int radeon_bo_is_busy(struct radeon_bo *bo, uint32_t *domain);
+int radeon_bo_set_tiling(struct radeon_bo *bo, uint32_t tiling_flags, uint32_t pitch);
+int radeon_bo_get_tiling(struct radeon_bo *bo, uint32_t *tiling_flags, uint32_t *pitch);
+int radeon_bo_is_static(struct radeon_bo *bo);
+int radeon_bo_is_referenced_by_cs(struct radeon_bo *bo,
+                                 struct radeon_cs *cs);
+uint32_t radeon_bo_get_handle(struct radeon_bo *bo);
+uint32_t radeon_bo_get_src_domain(struct radeon_bo *bo);
 #endif
diff --git a/src/mesa/drivers/dri/radeon/radeon_bo_int_drm.h b/src/mesa/drivers/dri/radeon/radeon_bo_int_drm.h
new file mode 100644 (file)
index 0000000..190c332
--- /dev/null
@@ -0,0 +1,45 @@
+#ifndef RADEON_BO_INT
+#define RADEON_BO_INT
+
+struct radeon_bo_manager {
+    struct radeon_bo_funcs  *funcs;
+    int                     fd;
+};
+
+struct radeon_bo_int {
+    void                        *ptr;
+    uint32_t                    flags;
+    uint32_t                    handle;
+    uint32_t                    size;
+    /* private members */
+    uint32_t                    alignment;
+    uint32_t                    domains;
+    unsigned                    cref;
+    struct radeon_bo_manager    *bom;
+    uint32_t                    space_accounted;
+    uint32_t                    referenced_in_cs;
+};
+
+/* 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_int *bo);
+    struct radeon_bo *(*bo_unref)(struct radeon_bo_int *bo);
+    int (*bo_map)(struct radeon_bo_int *bo, int write);
+    int (*bo_unmap)(struct radeon_bo_int *bo);
+    int (*bo_wait)(struct radeon_bo_int *bo);
+    int (*bo_is_static)(struct radeon_bo_int *bo);
+    int (*bo_set_tiling)(struct radeon_bo_int *bo, uint32_t tiling_flags,
+                         uint32_t pitch);
+    int (*bo_get_tiling)(struct radeon_bo_int *bo, uint32_t *tiling_flags,
+                         uint32_t *pitch);
+    int (*bo_is_busy)(struct radeon_bo_int *bo, uint32_t *domain);
+    int (*bo_is_referenced_by_cs)(struct radeon_bo_int *bo, struct radeon_cs *cs);
+};
+
+#endif
index 3e7547d2f9d26e46b660aabe5cd00197719935b1..cf12664bacdaf48dff604e3502145ebf550e6971 100644 (file)
 #include "radeon_bocs_wrapper.h"
 #include "radeon_macros.h"
 
+#ifdef HAVE_LIBDRM_RADEON
+#include "radeon_bo_int.h"
+#else
+#include "radeon_bo_int_drm.h"
+#endif
+
 /* no seriously texmem.c is this screwed up */
 struct bo_legacy_texture_object {
     driTextureObject    base;
@@ -57,7 +63,7 @@ struct bo_legacy_texture_object {
 };
 
 struct bo_legacy {
-    struct radeon_bo    base;
+    struct radeon_bo_int    base;
     int                 map_count;
     uint32_t            pending;
     int                 is_pending;
@@ -187,10 +193,10 @@ static void legacy_get_current_age(struct bo_manager_legacy *boml)
     }
 }
 
-static int legacy_is_pending(struct radeon_bo *bo)
+static int legacy_is_pending(struct radeon_bo_int *boi)
 {
-    struct bo_manager_legacy *boml = (struct bo_manager_legacy *)bo->bom;
-    struct bo_legacy *bo_legacy = (struct bo_legacy*)bo;
+    struct bo_manager_legacy *boml = (struct bo_manager_legacy *)boi->bom;
+    struct bo_legacy *bo_legacy = (struct bo_legacy*)boi;
 
     if (bo_legacy->is_pending <= 0) {
         bo_legacy->is_pending = 0;
@@ -204,13 +210,13 @@ static int legacy_is_pending(struct radeon_bo *bo)
         if (bo_legacy->pnext) {
             bo_legacy->pnext->pprev = bo_legacy->pprev;
         }
-       assert(bo_legacy->is_pending <= bo->cref);
+       assert(bo_legacy->is_pending <= boi->cref);
         while (bo_legacy->is_pending--) {
-           bo = radeon_bo_unref(bo);
-           if (!bo)
+           boi = (struct radeon_bo_int *)radeon_bo_unref((struct radeon_bo *)boi);
+           if (!boi)
              break;
         }
-       if (bo)
+       if (boi)
          bo_legacy->is_pending = 0;
         boml->cpendings--;
         return 0;
@@ -218,7 +224,7 @@ static int legacy_is_pending(struct radeon_bo *bo)
     return 1;
 }
 
-static int legacy_wait_pending(struct radeon_bo *bo)
+static int legacy_wait_pending(struct radeon_bo_int *bo)
 {
     struct bo_manager_legacy *boml = (struct bo_manager_legacy *)bo->bom;
     struct bo_legacy *bo_legacy = (struct bo_legacy*)bo;
@@ -323,7 +329,7 @@ static struct bo_legacy *bo_allocate(struct bo_manager_legacy *boml,
     return bo_legacy;
 }
 
-static int bo_dma_alloc(struct radeon_bo *bo)
+static int bo_dma_alloc(struct radeon_bo_int *bo)
 {
     struct bo_manager_legacy *boml = (struct bo_manager_legacy *)bo->bom;
     struct bo_legacy *bo_legacy = (struct bo_legacy*)bo;
@@ -333,7 +339,7 @@ static int bo_dma_alloc(struct radeon_bo *bo)
     int r;
 
     /* align size on 4Kb */
-    size = (((4 * 1024) - 1) + bo->size) & ~((4 * 1024) - 1);
+    size = (((4 * 1024) - 1) + bo_legacy->base.size) & ~((4 * 1024) - 1);
     alloc.region = RADEON_MEM_REGION_GART;
     alloc.alignment = bo_legacy->base.alignment;
     alloc.size = size;
@@ -355,7 +361,7 @@ static int bo_dma_alloc(struct radeon_bo *bo)
     return 0;
 }
 
-static int bo_dma_free(struct radeon_bo *bo)
+static int bo_dma_free(struct radeon_bo_int *bo)
 {
     struct bo_manager_legacy *boml = (struct bo_manager_legacy *)bo->bom;
     struct bo_legacy *bo_legacy = (struct bo_legacy*)bo;
@@ -428,7 +434,7 @@ static struct radeon_bo *bo_open(struct radeon_bo_manager *bom,
         bo_legacy = boml->bos.next;
         while (bo_legacy) {
             if (bo_legacy->base.handle == handle) {
-                radeon_bo_ref(&(bo_legacy->base));
+                radeon_bo_ref((struct radeon_bo *)&(bo_legacy->base));
                 return (struct radeon_bo*)bo_legacy;
             }
             bo_legacy = bo_legacy->next;
@@ -468,20 +474,20 @@ retry:
             return NULL;
         }
     }
-    radeon_bo_ref(&(bo_legacy->base));
+    radeon_bo_ref((struct radeon_bo *)&(bo_legacy->base));
 
     return (struct radeon_bo*)bo_legacy;
 }
 
-static void bo_ref(struct radeon_bo *bo)
+static void bo_ref(struct radeon_bo_int *bo)
 {
 }
 
-static struct radeon_bo *bo_unref(struct radeon_bo *bo)
+static struct radeon_bo *bo_unref(struct radeon_bo_int *boi)
 {
-    struct bo_legacy *bo_legacy = (struct bo_legacy*)bo;
+    struct bo_legacy *bo_legacy = (struct bo_legacy*)boi;
 
-    if (bo->cref <= 0) {
+    if (boi->cref <= 0) {
         bo_legacy->prev->next = bo_legacy->next;
         if (bo_legacy->next) {
             bo_legacy->next->prev = bo_legacy->prev;
@@ -491,10 +497,10 @@ static struct radeon_bo *bo_unref(struct radeon_bo *bo)
         }
         return NULL;
     }
-    return bo;
+    return (struct radeon_bo *)boi;
 }
 
-static int bo_map(struct radeon_bo *bo, int write)
+static int bo_map(struct radeon_bo_int *bo, int write)
 {
     struct bo_manager_legacy *boml = (struct bo_manager_legacy *)bo->bom;
     struct bo_legacy *bo_legacy = (struct bo_legacy*)bo;
@@ -528,7 +534,7 @@ static int bo_map(struct radeon_bo *bo, int write)
     return 0;
 }
 
-static int bo_unmap(struct radeon_bo *bo)
+static int bo_unmap(struct radeon_bo_int *bo)
 {
     struct bo_legacy *bo_legacy = (struct bo_legacy*)bo;
 
@@ -542,7 +548,7 @@ static int bo_unmap(struct radeon_bo *bo)
     return 0;
 }
 
-static int bo_is_busy(struct radeon_bo *bo, uint32_t *domain)
+static int bo_is_busy(struct radeon_bo_int *bo, uint32_t *domain)
 {
     *domain = 0;
     if (bo->domains & RADEON_GEM_DOMAIN_GTT)
@@ -555,7 +561,7 @@ static int bo_is_busy(struct radeon_bo *bo, uint32_t *domain)
         return 0;
 }
 
-static int bo_is_static(struct radeon_bo *bo)
+static int bo_is_static(struct radeon_bo_int *bo)
 {
     struct bo_legacy *bo_legacy = (struct bo_legacy*)bo;
     return bo_legacy->static_bo;
@@ -574,7 +580,7 @@ static struct radeon_bo_funcs bo_legacy_funcs = {
     bo_is_busy
 };
 
-static int bo_vram_validate(struct radeon_bo *bo,
+static int bo_vram_validate(struct radeon_bo_int *bo,
                             uint32_t *soffset,
                             uint32_t *eoffset)
 {
@@ -700,25 +706,30 @@ 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 radeon_bo_int *boi = (struct radeon_bo_int *)bo;
+    struct bo_manager_legacy *boml = (struct bo_manager_legacy *)boi->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);
+                bo, boi->size, bo_legacy->map_count);
+        return -EINVAL;
+    }
+    if(boi->size == 0) {
+        fprintf(stderr, "bo(%p) has size 0.\n", bo);
         return -EINVAL;
     }
     if (bo_legacy->static_bo || bo_legacy->validated) {
         *soffset = bo_legacy->offset;
-        *eoffset = bo_legacy->offset + bo->size;
+        *eoffset = bo_legacy->offset + boi->size;
 
         return 0;
     }
-    if (!(bo->domains & RADEON_GEM_DOMAIN_GTT)) {
+    if (!(boi->domains & RADEON_GEM_DOMAIN_GTT)) {
 
-        r = bo_vram_validate(bo, soffset, eoffset);
+        r = bo_vram_validate(boi, soffset, eoffset);
         if (r) {
            legacy_track_pending(&boml->base, 0);
            legacy_kick_all_buffers(boml);
@@ -732,7 +743,7 @@ int radeon_bo_legacy_validate(struct radeon_bo *bo,
         }
     }
     *soffset = bo_legacy->offset;
-    *eoffset = bo_legacy->offset + bo->size;
+    *eoffset = bo_legacy->offset + boi->size;
     bo_legacy->validated = 1;
 
     return 0;
@@ -740,7 +751,8 @@ int radeon_bo_legacy_validate(struct radeon_bo *bo,
 
 void radeon_bo_legacy_pending(struct radeon_bo *bo, uint32_t pending)
 {
-    struct bo_manager_legacy *boml = (struct bo_manager_legacy *)bo->bom;
+    struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
+    struct bo_manager_legacy *boml = (struct bo_manager_legacy *)boi->bom;
     struct bo_legacy *bo_legacy = (struct bo_legacy*)bo;
 
     bo_legacy->pending = pending;
@@ -795,7 +807,7 @@ static struct bo_legacy *radeon_legacy_bo_alloc_static(struct bo_manager_legacy
     if (bo->base.handle > bom->nhandle) {
         bom->nhandle = bo->base.handle + 1;
     }
-    radeon_bo_ref(&(bo->base));
+    radeon_bo_ref((struct radeon_bo *)&(bo->base));
     return bo;
 }
 
@@ -890,12 +902,13 @@ void radeon_bo_legacy_texture_age(struct radeon_bo_manager *bom)
 
 unsigned radeon_bo_legacy_relocs_size(struct radeon_bo *bo)
 {
+    struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
     struct bo_legacy *bo_legacy = (struct bo_legacy*)bo;
 
-    if (bo_legacy->static_bo || (bo->domains & RADEON_GEM_DOMAIN_GTT)) {
+    if (bo_legacy->static_bo || (boi->domains & RADEON_GEM_DOMAIN_GTT)) {
         return 0;
     }
-    return bo->size;
+    return boi->size;
 }
 
 /*
@@ -920,7 +933,7 @@ struct radeon_bo *radeon_legacy_bo_alloc_fake(struct radeon_bo_manager *bom,
     if (bo->base.handle > boml->nhandle) {
         boml->nhandle = bo->base.handle + 1;
     }
-    radeon_bo_ref(&(bo->base));
-    return &(bo->base);
+    radeon_bo_ref((struct radeon_bo *)&(bo->base));
+    return (struct radeon_bo *)&(bo->base);
 }
 
index 4520a7d7d498b36a7c7e4be2b13ee217188d46dc..6c2648b6bd86c99f7787a614145b14520066740f 100644 (file)
 #define RADEON_TILING_MACRO 0x1
 #define RADEON_TILING_MICRO 0x2
 #define RADEON_TILING_SWAP 0x4
+
+#ifndef RADEON_TILING_SURFACE
 #define RADEON_TILING_SURFACE 0x8 /* this object requires a surface
                                   * when mapped - i.e. front buffer */
+#endif
 
 /* to be used to build locally in mesa with no libdrm bits */
 #include "../radeon/radeon_bo_drm.h"
index 8fac5c6c512984ddd69fc842f63eb8d771bb0789..99d3ec7005e25c55d0f58e078f4d48527b3c3386 100644 (file)
@@ -136,8 +136,13 @@ radeonBufferSubData(GLcontext * ctx,
                     const GLvoid * data,
                     struct gl_buffer_object *obj)
 {
+    radeonContextPtr radeon = RADEON_CONTEXT(ctx);
     struct radeon_buffer_object *radeon_obj = get_radeon_buffer_object(obj);
 
+    if (radeon_bo_is_referenced_by_cs(radeon_obj->bo, radeon->cmdbuf.cs)) {
+        radeon_firevertices(radeon);
+    }
+
     radeon_bo_map(radeon_obj->bo, GL_TRUE);
 
     _mesa_memcpy(radeon_obj->bo->ptr + offset, data, size);
index f8a4cdb4954f1f5a4b9f56370c422597423e8cd2..e0b853bc97da97356c99493b0b026718d9ef03e2 100644 (file)
@@ -137,7 +137,7 @@ void radeon_get_cliprects(radeonContextPtr radeon,
                          unsigned int *num_cliprects,
                          int *x_off, int *y_off)
 {
-       __DRIdrawablePrivate *dPriv = radeon_get_drawable(radeon);
+       __DRIdrawable *dPriv = radeon_get_drawable(radeon);
        struct radeon_framebuffer *rfb = dPriv->driverPrivate;
 
        if (radeon->constant_cliprect) {
@@ -169,8 +169,8 @@ void radeon_get_cliprects(radeonContextPtr radeon,
  */
 void radeonSetCliprects(radeonContextPtr radeon)
 {
-       __DRIdrawablePrivate *const drawable = radeon_get_drawable(radeon);
-       __DRIdrawablePrivate *const readable = radeon_get_readable(radeon);
+       __DRIdrawable *const drawable = radeon_get_drawable(radeon);
+       __DRIdrawable *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;
@@ -229,16 +229,15 @@ void radeonUpdateScissor( GLcontext *ctx )
        }
        if (!rmesa->radeonScreen->kernel_mm) {
           /* Fix scissors for dri 1 */
-
-          __DRIdrawablePrivate *dPriv = radeon_get_drawable(rmesa);
+          __DRIdrawable *dPriv = radeon_get_drawable(rmesa);
           x1 += dPriv->x;
-          x2 += dPriv->x;
+          x2 += dPriv->x + 1;
           min_x += dPriv->x;
-          max_x += dPriv->x;
+          max_x += dPriv->x + 1;
           y1 += dPriv->y;
-          y2 += dPriv->y;
+          y2 += dPriv->y + 1;
           min_y += dPriv->y;
-          max_y += dPriv->y;
+          max_y += dPriv->y + 1;
        }
 
        rmesa->state.scissor.rect.x1 = CLAMP(x1,  min_x, max_x);
@@ -263,29 +262,6 @@ void radeonScissor(GLcontext* ctx, GLint x, GLint y, GLsizei w, GLsizei h)
        }
 }
 
-void radeonPolygonStipplePreKMS( GLcontext *ctx, const GLubyte *mask )
-{
-   radeonContextPtr radeon = RADEON_CONTEXT(ctx);
-   GLuint i;
-   drm_radeon_stipple_t stipple;
-
-   /* Must flip pattern upside down.
-   */
-   for ( i = 0 ; i < 32 ; i++ ) {
-      stipple.mask[31 - i] = ((GLuint *) mask)[i];
-   }
-
-   /* TODO: push this into cmd mechanism
-   */
-   radeon_firevertices(radeon);
-   LOCK_HARDWARE( radeon );
-
-   drmCommandWrite( radeon->dri.fd, DRM_RADEON_STIPPLE,
-        &stipple, sizeof(stipple) );
-   UNLOCK_HARDWARE( radeon );
-}
-
-
 /* ================================================================
  * SwapBuffers with client-side throttling
  */
@@ -452,7 +428,7 @@ static void radeon_flip_renderbuffers(struct radeon_framebuffer *rfb)
 
 /* Copy the back color buffer to the front color buffer.
  */
-void radeonCopyBuffer( __DRIdrawablePrivate *dPriv,
+void radeonCopyBuffer( __DRIdrawable *dPriv,
                       const drm_clip_rect_t      *rect)
 {
        radeonContextPtr rmesa;
@@ -520,7 +496,7 @@ void radeonCopyBuffer( __DRIdrawablePrivate *dPriv,
        UNLOCK_HARDWARE( rmesa );
 }
 
-static int radeonScheduleSwap(__DRIdrawablePrivate *dPriv, GLboolean *missed_target)
+static int radeonScheduleSwap(__DRIdrawable *dPriv, GLboolean *missed_target)
 {
        radeonContextPtr rmesa;
 
@@ -543,11 +519,11 @@ static int radeonScheduleSwap(__DRIdrawablePrivate *dPriv, GLboolean *missed_tar
        return 0;
 }
 
-static GLboolean radeonPageFlip( __DRIdrawablePrivate *dPriv )
+static GLboolean radeonPageFlip( __DRIdrawable *dPriv )
 {
        radeonContextPtr radeon;
        GLint ret;
-       __DRIscreenPrivate *psp;
+       __DRIscreen *psp;
        struct radeon_renderbuffer *rrb;
        struct radeon_framebuffer *rfb;
 
@@ -595,10 +571,10 @@ static GLboolean radeonPageFlip( __DRIdrawablePrivate *dPriv )
 /**
  * Swap front and back buffer.
  */
-void radeonSwapBuffers(__DRIdrawablePrivate * dPriv)
+void radeonSwapBuffers(__DRIdrawable * dPriv)
 {
        int64_t ust;
-       __DRIscreenPrivate *psp;
+       __DRIscreen *psp;
 
        if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
                radeonContextPtr radeon;
@@ -639,7 +615,7 @@ void radeonSwapBuffers(__DRIdrawablePrivate * dPriv)
        }
 }
 
-void radeonCopySubBuffer(__DRIdrawablePrivate * dPriv,
+void radeonCopySubBuffer(__DRIdrawable * dPriv,
                         int x, int y, int w, int h )
 {
        if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
@@ -665,6 +641,27 @@ void radeonCopySubBuffer(__DRIdrawablePrivate * dPriv,
        }
 }
 
+/**
+ * Check if we're about to draw into the front color buffer.
+ * If so, set the intel->front_buffer_dirty field to true.
+ */
+void
+radeon_check_front_buffer_rendering(GLcontext *ctx)
+{
+       radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+       const struct gl_framebuffer *fb = ctx->DrawBuffer;
+
+       if (fb->Name == 0) {
+               /* drawing to window system buffer */
+               if (fb->_NumColorDrawBuffers > 0) {
+                       if (fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) {
+                               radeon->front_buffer_dirty = GL_TRUE;
+                       }
+               }
+       }
+}
+
+
 void radeon_draw_buffer(GLcontext *ctx, struct gl_framebuffer *fb)
 {
        radeonContextPtr radeon = RADEON_CONTEXT(ctx);
@@ -841,7 +838,7 @@ void radeonDrawBuffer( GLcontext *ctx, GLenum mode )
        */
                if (!was_front_buffer_rendering && radeon->is_front_buffer_rendering) {
                        radeon_update_renderbuffers(radeon->dri.context,
-                               radeon->dri.context->driDrawablePriv);
+                               radeon->dri.context->driDrawablePriv, GL_FALSE);
       }
        }
 
@@ -858,7 +855,7 @@ void radeonReadBuffer( GLcontext *ctx, GLenum mode )
 
                if (!was_front_buffer_reading && rmesa->is_front_buffer_reading) {
                        radeon_update_renderbuffers(rmesa->dri.context,
-                                                   rmesa->dri.context->driReadablePriv);
+                                                   rmesa->dri.context->driReadablePriv, GL_FALSE);
                }
        }
        /* nothing, until we implement h/w glRead/CopyPixels or CopyTexImage */
@@ -909,9 +906,9 @@ void radeon_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei he
                if (radeon->is_front_buffer_rendering) {
                        ctx->Driver.Flush(ctx);
                }
-               radeon_update_renderbuffers(driContext, driContext->driDrawablePriv);
+               radeon_update_renderbuffers(driContext, driContext->driDrawablePriv, GL_FALSE);
                if (driContext->driDrawablePriv != driContext->driReadablePriv)
-                       radeon_update_renderbuffers(driContext, driContext->driReadablePriv);
+                       radeon_update_renderbuffers(driContext, driContext->driReadablePriv, GL_FALSE);
        }
 
        old_viewport = ctx->Driver.Viewport;
@@ -1119,22 +1116,21 @@ void radeonFlush(GLcontext *ctx)
           then no point flushing anything at all.
        */
        if (!radeon->dma.flush && !radeon->cmdbuf.cs->cdw && is_empty_list(&radeon->dma.reserved))
-               return;
+               goto flush_front;
 
        if (radeon->dma.flush)
                radeon->dma.flush( ctx );
 
-       radeonEmitState(radeon);
-
        if (radeon->cmdbuf.cs->cdw)
                rcommonFlushCmdBuf(radeon, __FUNCTION__);
 
+flush_front:
        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);
+                       __DRIdrawable * drawable = radeon_get_drawable(radeon);
                        (*screen->dri2.loader->flushFrontBuffer)(drawable, drawable->loaderPrivate);
 
                        /* Only clear the dirty bit if front-buffer rendering is no longer
@@ -1148,9 +1144,6 @@ void radeonFlush(GLcontext *ctx)
                        }
                }
        }
-
-       make_empty_list(&radeon->query.not_flushed_head);
-
 }
 
 /* Make sure all commands have been sent to the hardware and have
@@ -1237,7 +1230,7 @@ int rcommonFlushCmdBuf(radeonContextPtr rmesa, const char *caller)
                fprintf(stderr, "drmRadeonCmdBuffer: %d. Kernel failed to "
                                "parse or rejected command stream. See dmesg "
                                "for more info.\n", ret);
-               _mesa_exit(ret);
+               exit(ret);
        }
 
        return ret;
index f3201911ac67bba93e0a094f7cddf4d3ed6fb7a9..f31f08edf368f89aab156399b84256c96b327762 100644 (file)
@@ -10,14 +10,13 @@ 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 radeonPolygonStipplePreKMS( GLcontext *ctx, const GLubyte *mask );
 
 void radeonWaitForIdleLocked(radeonContextPtr radeon);
 extern uint32_t radeonGetAge(radeonContextPtr radeon);
-void radeonCopyBuffer( __DRIdrawablePrivate *dPriv,
+void radeonCopyBuffer( __DRIdrawable *dPriv,
                       const drm_clip_rect_t      *rect);
-void radeonSwapBuffers(__DRIdrawablePrivate * dPriv);
-void radeonCopySubBuffer(__DRIdrawablePrivate * dPriv,
+void radeonSwapBuffers(__DRIdrawable * dPriv);
+void radeonCopySubBuffer(__DRIdrawable * dPriv,
                         int x, int y, int w, int h );
 
 void radeonUpdatePageFlipping(radeonContextPtr rmesa);
@@ -43,7 +42,9 @@ void
 radeon_renderbuffer_set_bo(struct radeon_renderbuffer *rb,
                           struct radeon_bo *bo);
 struct radeon_renderbuffer *
-radeon_create_renderbuffer(GLenum format, __DRIdrawablePrivate *driDrawPriv);
+radeon_create_renderbuffer(gl_format format, __DRIdrawable *driDrawPriv);
+
+void radeon_check_front_buffer_rendering(GLcontext *ctx);
 static inline struct radeon_renderbuffer *radeon_renderbuffer(struct gl_renderbuffer *rb)
 {
        struct radeon_renderbuffer *rrb = (struct radeon_renderbuffer *)rb;
index 6b9b1e3c5e400b1c944e6aeea4d1574ccb1cb31e..b9c29b937e58621de15811f7290798d0e62b4ff5 100644 (file)
@@ -181,10 +181,10 @@ static void radeonInitDriverFuncs(struct dd_function_table *functions)
 GLboolean radeonInitContext(radeonContextPtr radeon,
                            struct dd_function_table* functions,
                            const __GLcontextModes * glVisual,
-                           __DRIcontextPrivate * driContextPriv,
+                           __DRIcontext * driContextPriv,
                            void *sharedContextPrivate)
 {
-       __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+       __DRIscreen *sPriv = driContextPriv->driScreenPriv;
        radeonScreenPtr screen = (radeonScreenPtr) (sPriv->private);
        GLcontext* ctx;
        GLcontext* shareCtx;
@@ -262,10 +262,9 @@ GLboolean radeonInitContext(radeonContextPtr radeon,
                else
                        radeon->texture_row_align = 32;
                radeon->texture_rect_row_align = 64;
-               radeon->texture_compressed_row_align = 64;
+               radeon->texture_compressed_row_align = 32;
        }
 
-       make_empty_list(&radeon->query.not_flushed_head);
        radeon_init_dma(radeon);
 
        return GL_TRUE;
@@ -292,7 +291,7 @@ static void radeon_destroy_atom_list(radeonContextPtr radeon)
  * Cleanup common context fields.
  * Called by r200DestroyContext/r300DestroyContext
  */
-void radeonDestroyContext(__DRIcontextPrivate *driContextPriv )
+void radeonDestroyContext(__DRIcontext *driContextPriv )
 {
 #ifdef RADEON_BO_TRACK
        FILE *track;
@@ -356,7 +355,7 @@ void radeonDestroyContext(__DRIcontextPrivate *driContextPriv )
 
 /* Force the context `c' to be unbound from its buffer.
  */
-GLboolean radeonUnbindContext(__DRIcontextPrivate * driContextPriv)
+GLboolean radeonUnbindContext(__DRIcontext * driContextPriv)
 {
        radeonContextPtr radeon = (radeonContextPtr) driContextPriv->driverPrivate;
 
@@ -496,23 +495,12 @@ radeon_make_renderbuffer_current(radeonContextPtr radeon,
 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;
-   }
+   return _mesa_get_format_bytes(rb->base.Format) * 8; 
 }
 
 void
-radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
+radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable,
+                           GLboolean front_only)
 {
        unsigned int attachments[10];
        __DRIbuffer *buffers = NULL;
@@ -538,7 +526,7 @@ radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
                struct radeon_renderbuffer *stencil_rb;
 
                i = 0;
-               if ((radeon->is_front_buffer_rendering ||
+               if ((front_only || radeon->is_front_buffer_rendering ||
                     radeon->is_front_buffer_reading ||
                     !draw->color_rb[1])
                    && draw->color_rb[0]) {
@@ -546,23 +534,25 @@ radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
                        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]);
-               }
+               if (!front_only) {
+                       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);
+                       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,
@@ -575,12 +565,14 @@ radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
                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;
+               if (!front_only) {
+                       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,
@@ -728,9 +720,9 @@ radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
 /* Force the context `c' to be the current context and associate with it
  * buffer `b'.
  */
-GLboolean radeonMakeCurrent(__DRIcontextPrivate * driContextPriv,
-                           __DRIdrawablePrivate * driDrawPriv,
-                           __DRIdrawablePrivate * driReadPriv)
+GLboolean radeonMakeCurrent(__DRIcontext * driContextPriv,
+                           __DRIdrawable * driDrawPriv,
+                           __DRIdrawable * driReadPriv)
 {
        radeonContextPtr radeon;
        struct radeon_framebuffer *drfb;
@@ -748,9 +740,9 @@ GLboolean radeonMakeCurrent(__DRIcontextPrivate * driContextPriv,
        readfb = driReadPriv->driverPrivate;
 
        if (driContextPriv->driScreenPriv->dri2.enabled) {
-               radeon_update_renderbuffers(driContextPriv, driDrawPriv);
+               radeon_update_renderbuffers(driContextPriv, driDrawPriv, GL_FALSE);
                if (driDrawPriv != driReadPriv)
-                       radeon_update_renderbuffers(driContextPriv, driReadPriv);
+                       radeon_update_renderbuffers(driContextPriv, driReadPriv, GL_FALSE);
                _mesa_reference_renderbuffer(&radeon->state.color.rb,
                        &(radeon_get_renderbuffer(&drfb->base, BUFFER_BACK_LEFT)->base));
                _mesa_reference_renderbuffer(&radeon->state.depth.rb,
index 0309345393d8c4d82cebbb3e46f1702ed7744486..ab79d2dc0f24ce54ef740b2cc6a0c268eb60578a 100644 (file)
@@ -92,7 +92,7 @@ struct radeon_renderbuffer
 
        GLuint pf_pending;  /**< sequence number of pending flip */
        GLuint vbl_pending;   /**< vblank sequence number of pending flip */
-       __DRIdrawablePrivate *dPriv;
+       __DRIdrawable *dPriv;
 };
 
 struct radeon_framebuffer
@@ -208,6 +208,10 @@ struct radeon_tex_obj {
         * and so on.
         */
        GLboolean validated;
+       /* Minimum LOD to be used during rendering */
+       unsigned minLod;
+       /* Miximum LOD to be used during rendering */
+       unsigned maxLod;
 
        GLuint override_offset;
        GLboolean image_override; /* Image overridden by GLX_EXT_tfp */
@@ -324,6 +328,7 @@ struct radeon_swtcl_info {
        GLuint vertex_attr_count;
 
        GLuint emit_prediction;
+        struct radeon_bo *bo;
 };
 
 #define RADEON_MAX_AOS_ARRAYS          16
@@ -376,8 +381,8 @@ struct radeon_store {
 };
 
 struct radeon_dri_mirror {
-       __DRIcontextPrivate *context;   /* DRI context */
-       __DRIscreenPrivate *screen;     /* DRI screen */
+       __DRIcontext *context;  /* DRI context */
+       __DRIscreen *screen;    /* DRI screen */
 
        drm_context_t hwContext;
        drm_hw_lock_t *hwLock;
@@ -401,9 +406,6 @@ struct radeon_state {
        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;
 };
 
 /**
@@ -502,7 +504,6 @@ struct radeon_context {
 
    struct {
        struct radeon_query_object *current;
-       struct radeon_query_object not_flushed_head;
        struct radeon_state_atom queryobj;
    } query;
 
@@ -522,12 +523,12 @@ struct radeon_context {
 
 #define RADEON_CONTEXT(glctx) ((radeonContextPtr)(ctx->DriverCtx))
 
-static inline __DRIdrawablePrivate* radeon_get_drawable(radeonContextPtr radeon)
+static inline __DRIdrawable* radeon_get_drawable(radeonContextPtr radeon)
 {
        return radeon->dri.context->driDrawablePriv;
 }
 
-static inline __DRIdrawablePrivate* radeon_get_readable(radeonContextPtr radeon)
+static inline __DRIdrawable* radeon_get_readable(radeonContextPtr radeon)
 {
        return radeon->dri.context->driReadablePriv;
 }
@@ -580,15 +581,16 @@ static INLINE uint32_t radeonPackFloat24(float f)
 GLboolean radeonInitContext(radeonContextPtr radeon,
                            struct dd_function_table* functions,
                            const __GLcontextModes * glVisual,
-                           __DRIcontextPrivate * driContextPriv,
+                           __DRIcontext * 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);
+GLboolean radeonUnbindContext(__DRIcontext * driContextPriv);
+void radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable,
+                                GLboolean front_only);
+GLboolean radeonMakeCurrent(__DRIcontext * driContextPriv,
+                           __DRIdrawable * driDrawPriv,
+                           __DRIdrawable * driReadPriv);
+extern void radeonDestroyContext(__DRIcontext * driContextPriv);
 
 #endif
index 8f4485aee7c00891df92579d177f776c40dbe73c..3cd305b0a256b5df99c203ed694e309d7d14cd1e 100644 (file)
@@ -69,7 +69,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define need_GL_EXT_fog_coord
 #define need_GL_EXT_secondary_color
 #define need_GL_EXT_framebuffer_object
-#include "extension_helper.h"
+#include "main/remap_helper.h"
 
 #define DRIVER_DATE    "20061018"
 
@@ -79,7 +79,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 /* Extension strings exported by the R100 driver.
  */
-const struct dri_extension card_extensions[] =
+static const struct dri_extension card_extensions[] =
 {
     { "GL_ARB_multitexture",               NULL },
     { "GL_ARB_occlusion_query",                   GL_ARB_occlusion_query_functions},
@@ -109,7 +109,7 @@ const struct dri_extension card_extensions[] =
     { NULL,                                NULL }
 };
 
-const struct dri_extension mm_extensions[] = {
+static const struct dri_extension mm_extensions[] = {
   { "GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions },
   { NULL, NULL }
 };
@@ -208,10 +208,10 @@ static void r100_init_vtbl(radeonContextPtr radeon)
  */
 GLboolean
 r100CreateContext( const __GLcontextModes *glVisual,
-                     __DRIcontextPrivate *driContextPriv,
+                     __DRIcontext *driContextPriv,
                      void *sharedContextPrivate)
 {
-   __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+   __DRIscreen *sPriv = driContextPriv->driScreenPriv;
    radeonScreenPtr screen = (radeonScreenPtr)(sPriv->private);
    struct dd_function_table functions;
    r100ContextPtr rmesa;
index 4e2c52c835cdcebd44378cb23874572fad4ec32a..dfedc38bfd1e3bfb142c9c33bf0dba3a1392fe9c 100644 (file)
@@ -331,8 +331,12 @@ struct r100_hw_state {
        struct radeon_state_atom stp;
 };
 
+struct radeon_stipple_state {
+       GLuint mask[32];
+};
 
 struct r100_state {
+       struct radeon_stipple_state stipple;
        struct radeon_texture_state texture;
 };
 
@@ -447,7 +451,7 @@ struct r100_context {
 #define RADEON_OLD_PACKETS 1
 
 extern GLboolean r100CreateContext( const __GLcontextModes *glVisual,
-                                   __DRIcontextPrivate *driContextPriv,
+                                   __DRIcontext *driContextPriv,
                                    void *sharedContextPrivate);
   
 
diff --git a/src/mesa/drivers/dri/radeon/radeon_cs.c b/src/mesa/drivers/dri/radeon/radeon_cs.c
new file mode 100644 (file)
index 0000000..17e7433
--- /dev/null
@@ -0,0 +1,95 @@
+
+#include <stdio.h>
+#include <stdint.h>
+#include "drm.h"
+#include "radeon_drm.h"
+#include "radeon_bocs_wrapper.h"
+#include "radeon_cs_int_drm.h"
+
+struct radeon_cs *radeon_cs_create(struct radeon_cs_manager *csm,
+                           uint32_t ndw)
+{
+    struct radeon_cs_int *csi = csm->funcs->cs_create(csm, ndw);
+    return (struct radeon_cs *)csi;
+}
+
+int radeon_cs_write_reloc(struct radeon_cs *cs,
+                         struct radeon_bo *bo,
+                         uint32_t read_domain,
+                         uint32_t write_domain,
+                         uint32_t flags)
+{
+    struct radeon_cs_int *csi = (struct radeon_cs_int *)cs;
+
+    return csi->csm->funcs->cs_write_reloc(csi,
+                                          bo,
+                                          read_domain,
+                                          write_domain,
+                                          flags);
+}
+
+int radeon_cs_begin(struct radeon_cs *cs,
+                   uint32_t ndw,
+                   const char *file,
+                   const char *func,
+                   int line)
+{
+    struct radeon_cs_int *csi = (struct radeon_cs_int *)cs;
+    return csi->csm->funcs->cs_begin(csi, ndw, file, func, line);
+}
+
+int radeon_cs_end(struct radeon_cs *cs,
+                 const char *file,
+                 const char *func,
+                 int line)
+{
+    struct radeon_cs_int *csi = (struct radeon_cs_int *)cs;
+    return csi->csm->funcs->cs_end(csi, file, func, line);
+}
+
+int radeon_cs_emit(struct radeon_cs *cs)
+{
+    struct radeon_cs_int *csi = (struct radeon_cs_int *)cs;
+    return csi->csm->funcs->cs_emit(csi);
+}
+
+int radeon_cs_destroy(struct radeon_cs *cs)
+{
+    struct radeon_cs_int *csi = (struct radeon_cs_int *)cs;
+    return csi->csm->funcs->cs_destroy(csi);
+}
+
+int radeon_cs_erase(struct radeon_cs *cs)
+{
+    struct radeon_cs_int *csi = (struct radeon_cs_int *)cs;
+    return csi->csm->funcs->cs_erase(csi);
+}
+
+int radeon_cs_need_flush(struct radeon_cs *cs)
+{
+    struct radeon_cs_int *csi = (struct radeon_cs_int *)cs;
+    return csi->csm->funcs->cs_need_flush(csi);
+}
+
+void radeon_cs_print(struct radeon_cs *cs, FILE *file)
+{
+    struct radeon_cs_int *csi = (struct radeon_cs_int *)cs;
+    csi->csm->funcs->cs_print(csi, file);
+}
+
+void radeon_cs_set_limit(struct radeon_cs *cs, uint32_t domain, uint32_t limit)
+{
+    struct radeon_cs_int *csi = (struct radeon_cs_int *)cs;
+    if (domain == RADEON_GEM_DOMAIN_VRAM)
+       csi->csm->vram_limit = limit;
+    else
+       csi->csm->gart_limit = limit;
+}
+
+void radeon_cs_space_set_flush(struct radeon_cs *cs, void (*fn)(void *), void *data)
+{
+    struct radeon_cs_int *csi = (struct radeon_cs_int *)cs;
+    csi->space_flush_fn = fn;
+    csi->space_flush_data = data;
+}
+
index ab4eca31a3c56ee637b06efac684d8b0f0f428c6..a3f1750c6ed2638b2d4fe26fe303cbc452db7ea1 100644 (file)
@@ -36,6 +36,7 @@
 #include <string.h>
 #include "drm.h"
 #include "radeon_drm.h"
+#include "radeon_bo_drm.h"
 
 struct radeon_cs_reloc {
     struct radeon_bo    *bo;
@@ -49,173 +50,41 @@ struct radeon_cs_reloc {
 #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;
-};
-
-#define MAX_SPACE_BOS (32)
-
-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;
+    uint32_t *packets;
+    unsigned cdw;
+    unsigned ndw;
     unsigned                    section_ndw;
     unsigned                    section_cdw;
-    const char                  *section_file;
-    const char                  *section_func;
-    int                         section_line;
-    struct radeon_cs_space_check bos[MAX_SPACE_BOS];
-    int                         bo_count;
-    void                        (*space_flush_fn)(void *);
-    void                        *space_flush_data;
-};
-
-/* 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);
-};
-
-struct radeon_cs_manager {
-    struct radeon_cs_funcs  *funcs;
-    int                     fd;
-    int32_t vram_limit, gart_limit;
-    int32_t vram_write_used, gart_write_used;
-    int32_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 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;
-    }
-}
-
-static inline void radeon_cs_write_table(struct radeon_cs *cs, void *data, uint32_t size)
-{
-    memcpy(cs->packets + cs->cdw, data, size * 4);
-    cs->cdw += size;
-    if (cs->section) {
-           cs->section_cdw += size;
-    }
-}
+#define MAX_SPACE_BOS (32)
 
-static inline void radeon_cs_space_set_flush(struct radeon_cs *cs, void (*fn)(void *), void *data)
-{
-    cs->space_flush_fn = fn;
-    cs->space_flush_data = data;
-}
+struct radeon_cs_manager;
 
+extern struct radeon_cs *radeon_cs_create(struct radeon_cs_manager *csm,
+                                         uint32_t ndw);
+
+extern int radeon_cs_begin(struct radeon_cs *cs,
+                          uint32_t ndw,
+                          const char *file,
+                          const char *func, int line);
+extern int radeon_cs_end(struct radeon_cs *cs,
+                        const char *file,
+                        const char *func,
+                        int line);
+extern int radeon_cs_emit(struct radeon_cs *cs);
+extern int radeon_cs_destroy(struct radeon_cs *cs);
+extern int radeon_cs_erase(struct radeon_cs *cs);
+extern int radeon_cs_need_flush(struct radeon_cs *cs);
+extern void radeon_cs_print(struct radeon_cs *cs, FILE *file);
+extern void radeon_cs_set_limit(struct radeon_cs *cs, uint32_t domain, uint32_t limit);
+extern void radeon_cs_space_set_flush(struct radeon_cs *cs, void (*fn)(void *), void *data);
+extern int radeon_cs_write_reloc(struct radeon_cs *cs,
+                                struct radeon_bo *bo,
+                                uint32_t read_domain,
+                                uint32_t write_domain,
+                                uint32_t flags);
 
 /*
  * add a persistent BO to the list
@@ -243,4 +112,30 @@ int radeon_cs_space_check_with_bo(struct radeon_cs *cs,
                                  uint32_t read_domains,
                                  uint32_t write_domain);
 
+static inline void radeon_cs_write_dword(struct radeon_cs *cs, uint32_t dword)
+{
+    cs->packets[cs->cdw++] = dword;
+    if (cs->section_ndw) {
+        cs->section_cdw++;
+    }
+}
+
+static inline void radeon_cs_write_qword(struct radeon_cs *cs, uint64_t qword)
+{
+    memcpy(cs->packets + cs->cdw, &qword, sizeof(uint64_t));
+    cs->cdw += 2;
+    if (cs->section_ndw) {
+        cs->section_cdw += 2;
+    }
+}
+
+static inline void radeon_cs_write_table(struct radeon_cs *cs,
+                                        void *data, uint32_t size)
+{
+    memcpy(cs->packets + cs->cdw, data, size * 4);
+    cs->cdw += size;
+    if (cs->section_ndw) {
+       cs->section_cdw += size;
+    }
+}
 #endif
diff --git a/src/mesa/drivers/dri/radeon/radeon_cs_int_drm.h b/src/mesa/drivers/dri/radeon/radeon_cs_int_drm.h
new file mode 100644 (file)
index 0000000..8ba76bf
--- /dev/null
@@ -0,0 +1,66 @@
+
+#ifndef _RADEON_CS_INT_H_
+#define _RADEON_CS_INT_H_
+
+struct radeon_cs_space_check {
+    struct radeon_bo_int *bo;
+    uint32_t read_domains;
+    uint32_t write_domain;
+    uint32_t new_accounted;
+};
+
+struct radeon_cs_int {
+    /* keep first two in same place */
+    uint32_t                    *packets;    
+    unsigned                    cdw;
+    unsigned                    ndw;
+    unsigned                    section_ndw;
+    unsigned                    section_cdw;
+    /* private members */
+    struct radeon_cs_manager    *csm;
+    void                        *relocs;
+    unsigned                    crelocs;
+    unsigned                    relocs_total_size;
+    const char                  *section_file;
+    const char                  *section_func;
+    int                         section_line;
+    struct radeon_cs_space_check bos[MAX_SPACE_BOS];
+    int                         bo_count;
+    void                        (*space_flush_fn)(void *);
+    void                        *space_flush_data;
+};
+
+/* cs functions */
+struct radeon_cs_funcs {
+    struct radeon_cs_int *(*cs_create)(struct radeon_cs_manager *csm,
+                                   uint32_t ndw);
+    int (*cs_write_reloc)(struct radeon_cs_int *cs,
+                          struct radeon_bo *bo,
+                          uint32_t read_domain,
+                          uint32_t write_domain,
+                          uint32_t flags);
+    int (*cs_begin)(struct radeon_cs_int *cs,
+                    uint32_t ndw,
+                   const char *file,
+                   const char *func,
+                   int line);
+    int (*cs_end)(struct radeon_cs_int *cs,
+                 const char *file, const char *func,
+                 int line);
+
+
+    int (*cs_emit)(struct radeon_cs_int *cs);
+    int (*cs_destroy)(struct radeon_cs_int *cs);
+    int (*cs_erase)(struct radeon_cs_int *cs);
+    int (*cs_need_flush)(struct radeon_cs_int *cs);
+    void (*cs_print)(struct radeon_cs_int *cs, FILE *file);
+};
+
+struct radeon_cs_manager {
+    struct radeon_cs_funcs  *funcs;
+    int                     fd;
+    int32_t vram_limit, gart_limit;
+    int32_t vram_write_used, gart_write_used;
+    int32_t read_used;
+};
+#endif
index f1addb299e241d18f4d94f416bace6ddbc12682d..45b608a1b981959a397c7ad19699dff85b78cd11 100644 (file)
  *      Jérôme Glisse <glisse@freedesktop.org>
  */
 #include <errno.h>
+#include <unistd.h>
+#include <stdint.h>
+#include "drm.h"
+#include "radeon_drm.h"
 
 #include "radeon_bocs_wrapper.h"
 #include "radeon_common.h"
-
+#ifdef HAVE_LIBDRM_RADEON
+#include "radeon_cs_int.h"
+#else
+#include "radeon_cs_int_drm.h"
+#endif
 struct cs_manager_legacy {
     struct radeon_cs_manager    base;
     struct radeon_context       *ctx;
@@ -51,27 +59,27 @@ struct cs_reloc_legacy {
 };
 
 
-static struct radeon_cs *cs_create(struct radeon_cs_manager *csm,
-                                   uint32_t ndw)
+static struct radeon_cs_int *cs_create(struct radeon_cs_manager *csm,
+                                      uint32_t ndw)
 {
-    struct radeon_cs *cs;
+    struct radeon_cs_int *csi;
 
-    cs = (struct radeon_cs*)calloc(1, sizeof(struct radeon_cs));
-    if (cs == NULL) {
+    csi = (struct radeon_cs_int*)calloc(1, sizeof(struct radeon_cs_int));
+    if (csi == 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);
+    csi->csm = csm;
+    csi->ndw = (ndw + 0x3FF) & (~0x3FF);
+    csi->packets = (uint32_t*)malloc(4*csi->ndw);
+    if (csi->packets == NULL) {
+        free(csi);
         return NULL;
     }
-    cs->relocs_total_size = 0;
-    return cs;
+    csi->relocs_total_size = 0;
+    return csi;
 }
 
-static int cs_write_reloc(struct radeon_cs *cs,
+static int cs_write_reloc(struct radeon_cs_int *cs,
                           struct radeon_bo *bo,
                           uint32_t read_domain,
                           uint32_t write_domain,
@@ -150,20 +158,19 @@ static int cs_write_reloc(struct radeon_cs *cs,
     return 0;
 }
 
-static int cs_begin(struct radeon_cs *cs,
+static int cs_begin(struct radeon_cs_int *cs,
                     uint32_t ndw,
                     const char *file,
                     const char *func,
                     int line)
 {
-    if (cs->section) {
+    if (cs->section_ndw) {
         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;
@@ -187,18 +194,17 @@ static int cs_begin(struct radeon_cs *cs,
     return 0;
 }
 
-static int cs_end(struct radeon_cs *cs,
+static int cs_end(struct radeon_cs_int *cs,
                   const char *file,
                   const char *func,
                   int line)
 
 {
-    if (!cs->section) {
+    if (!cs->section_ndw) {
         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);
@@ -206,10 +212,12 @@ static int cs_end(struct radeon_cs *cs,
                 file, func, line);
         return -EPIPE;
     }
+    cs->section_ndw = 0;
+
     return 0;
 }
 
-static int cs_process_relocs(struct radeon_cs *cs)
+static int cs_process_relocs(struct radeon_cs_int *cs)
 {
     struct cs_manager_legacy *csm = (struct cs_manager_legacy*)cs->csm;
     struct cs_reloc_legacy *relocs;
@@ -254,7 +262,7 @@ restart:
     return 0;
 }
 
-static int cs_set_age(struct radeon_cs *cs)
+static int cs_set_age(struct radeon_cs_int *cs)
 {
     struct cs_manager_legacy *csm = (struct cs_manager_legacy*)cs->csm;
     struct cs_reloc_legacy *relocs;
@@ -268,7 +276,7 @@ static int cs_set_age(struct radeon_cs *cs)
     return 0;
 }
 
-static int cs_emit(struct radeon_cs *cs)
+static int cs_emit(struct radeon_cs_int *cs)
 {
     struct cs_manager_legacy *csm = (struct cs_manager_legacy*)cs->csm;
     drm_radeon_cmd_buffer_t cmd;
@@ -276,7 +284,7 @@ static int cs_emit(struct radeon_cs *cs)
     uint64_t ull;
     int r;
 
-    csm->ctx->vtbl.emit_cs_header(cs, csm->ctx);
+    csm->ctx->vtbl.emit_cs_header((struct radeon_cs *)cs, csm->ctx);
 
     /* append buffer age */
     if ( IS_R300_CLASS(csm->ctx->radeonScreen) )
@@ -289,9 +297,9 @@ static int cs_emit(struct radeon_cs *cs)
       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);
+      radeon_cs_write_dword((struct radeon_cs *)cs, age.u);
+      radeon_cs_write_qword((struct radeon_cs *)cs, ull);
+      radeon_cs_write_dword((struct radeon_cs *)cs, 0);
     }
 
     r = cs_process_relocs(cs);
@@ -342,7 +350,7 @@ static void inline cs_free_reloc(void *relocs_p, int crelocs)
       free(relocs[i].indices);
 }
 
-static int cs_destroy(struct radeon_cs *cs)
+static int cs_destroy(struct radeon_cs_int *cs)
 {
     cs_free_reloc(cs->relocs, cs->crelocs);
     free(cs->relocs);
@@ -351,7 +359,7 @@ static int cs_destroy(struct radeon_cs *cs)
     return 0;
 }
 
-static int cs_erase(struct radeon_cs *cs)
+static int cs_erase(struct radeon_cs_int *cs)
 {
     cs_free_reloc(cs->relocs, cs->crelocs);
     free(cs->relocs);
@@ -359,18 +367,18 @@ static int cs_erase(struct radeon_cs *cs)
     cs->relocs = NULL;
     cs->crelocs = 0;
     cs->cdw = 0;
-    cs->section = 0;
+    cs->section_ndw = 0;
     return 0;
 }
 
-static int cs_need_flush(struct radeon_cs *cs)
+static int cs_need_flush(struct radeon_cs_int *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 void cs_print(struct radeon_cs_int *cs, FILE *file)
 {
 }
 
index 89cbbb5a6b982fafa60d91c7fedc7d83c87ddc73..e22b437d561a4ac4df4f74fa6ca70fa312c2deb2 100644 (file)
@@ -29,6 +29,8 @@
 #include <errno.h>
 #include <stdlib.h>
 #include "radeon_bocs_wrapper.h"
+#include "radeon_bo_int_drm.h"
+#include "radeon_cs_int_drm.h"
 
 struct rad_sizes {
     int32_t op_read;
@@ -39,7 +41,7 @@ struct rad_sizes {
 static inline int radeon_cs_setup_bo(struct radeon_cs_space_check *sc, struct rad_sizes *sizes)
 {
     uint32_t read_domains, write_domain;
-    struct radeon_bo *bo;
+    struct radeon_bo_int *bo;
 
     bo = sc->bo;
     sc->new_accounted = 0;
@@ -47,7 +49,7 @@ static inline int radeon_cs_setup_bo(struct radeon_cs_space_check *sc, struct ra
     write_domain = sc->write_domain;
 
     /* legacy needs a static check */
-    if (radeon_bo_is_static(bo)) {
+    if (radeon_bo_is_static((struct radeon_bo *)sc->bo)) {
        bo->space_accounted = sc->new_accounted = (read_domains << 16) | write_domain;
        return 0;
     }
@@ -100,11 +102,11 @@ static inline int radeon_cs_setup_bo(struct radeon_cs_space_check *sc, struct ra
     return 0;
 }
 
-static int radeon_cs_do_space_check(struct radeon_cs *cs, struct radeon_cs_space_check *new_tmp)
+static int radeon_cs_do_space_check(struct radeon_cs_int *cs, struct radeon_cs_space_check *new_tmp)
 {
     struct radeon_cs_manager *csm = cs->csm;
     int i;
-    struct radeon_bo *bo;
+    struct radeon_bo_int *bo;
     struct rad_sizes sizes;
     int ret;
 
@@ -158,25 +160,28 @@ static int radeon_cs_do_space_check(struct radeon_cs *cs, struct radeon_cs_space
 
 void radeon_cs_space_add_persistent_bo(struct radeon_cs *cs, struct radeon_bo *bo, uint32_t read_domains, uint32_t write_domain)
 {
+    struct radeon_cs_int *csi = (struct radeon_cs_int *)cs;
+    struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
     int i;
-    for (i = 0; i < cs->bo_count; i++) {
-       if (cs->bos[i].bo == bo &&
-           cs->bos[i].read_domains == read_domains &&
-           cs->bos[i].write_domain == write_domain)
+    for (i = 0; i < csi->bo_count; i++) {
+       if (csi->bos[i].bo == boi &&
+           csi->bos[i].read_domains == read_domains &&
+           csi->bos[i].write_domain == write_domain)
            return;
     }
     radeon_bo_ref(bo);
-    i = cs->bo_count;
-    cs->bos[i].bo = bo;
-    cs->bos[i].read_domains = read_domains;
-    cs->bos[i].write_domain = write_domain;
-    cs->bos[i].new_accounted = 0;
-    cs->bo_count++;
-
-    assert(cs->bo_count < MAX_SPACE_BOS);
+    i = csi->bo_count;
+    csi->bos[i].bo = boi;
+    csi->bos[i].read_domains = read_domains;
+    csi->bos[i].write_domain = write_domain;
+    csi->bos[i].new_accounted = 0;
+    csi->bo_count++;
+
+    assert(csi->bo_count < MAX_SPACE_BOS);
 }
 
-static int radeon_cs_check_space_internal(struct radeon_cs *cs, struct radeon_cs_space_check *tmp_bo)
+static int radeon_cs_check_space_internal(struct radeon_cs_int *cs,
+                                         struct radeon_cs_space_check *tmp_bo)
 {
     int ret;
     int flushed = 0;
@@ -198,37 +203,42 @@ again:
 int radeon_cs_space_check_with_bo(struct radeon_cs *cs,
                                  struct radeon_bo *bo,
                                  uint32_t read_domains, uint32_t write_domain)
-{                                                                      
+{
+    struct radeon_cs_int *csi = (struct radeon_cs_int *)cs;
+    struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
     struct radeon_cs_space_check temp_bo;
+    
     int ret = 0;
 
     if (bo) {
-       temp_bo.bo = bo;
+       temp_bo.bo = boi;
        temp_bo.read_domains = read_domains;
        temp_bo.write_domain = write_domain;
        temp_bo.new_accounted = 0;
     }
 
-    ret = radeon_cs_check_space_internal(cs, bo ? &temp_bo : NULL);
+    ret = radeon_cs_check_space_internal(csi, bo ? &temp_bo : NULL);
     return ret;
 }
 
 int radeon_cs_space_check(struct radeon_cs *cs)
 {
-    return radeon_cs_check_space_internal(cs, NULL);
+    struct radeon_cs_int *csi = (struct radeon_cs_int *)cs;
+    return radeon_cs_check_space_internal(csi, NULL);
 }
 
 void radeon_cs_space_reset_bos(struct radeon_cs *cs)
 {
+    struct radeon_cs_int *csi = (struct radeon_cs_int *)cs;
     int i;
-    for (i = 0; i < cs->bo_count; i++) {
-       radeon_bo_unref(cs->bos[i].bo);
-       cs->bos[i].bo = NULL;
-       cs->bos[i].read_domains = 0;
-       cs->bos[i].write_domain = 0;
-       cs->bos[i].new_accounted = 0;
+    for (i = 0; i < csi->bo_count; i++) {
+       radeon_bo_unref((struct radeon_bo *)csi->bos[i].bo);
+       csi->bos[i].bo = NULL;
+       csi->bos[i].read_domains = 0;
+       csi->bos[i].write_domain = 0;
+       csi->bos[i].new_accounted = 0;
     }
-    cs->bo_count = 0;
+    csi->bo_count = 0;
 }
 
 
index c6edbae9a1b9661da06689ac7a9ebcc60ed7c992..d31e4e47ddbbae1401bd5e14b7c373a76fc0eb42 100644 (file)
@@ -151,6 +151,7 @@ void rcommon_emit_vector(GLcontext * ctx, struct radeon_aos *aos,
        aos->components = size;
        aos->count = count;
 
+       radeon_bo_map(aos->bo, 1);
        out = (uint32_t*)((char*)aos->bo->ptr + aos->offset);
        switch (size) {
        case 1: radeonEmitVec4(out, data, stride, count); break;
@@ -161,6 +162,7 @@ void rcommon_emit_vector(GLcontext * ctx, struct radeon_aos *aos,
                assert(0);
                break;
        }
+       radeon_bo_unmap(aos->bo);
 }
 
 void radeon_init_dma(radeonContextPtr rmesa)
@@ -183,10 +185,6 @@ void radeonRefillCurrentDmaRegion(radeonContextPtr rmesa, int size)
                        __FUNCTION__, size, rmesa->dma.minimum_size);
 
 
-       /* unmap old reserved bo */
-       if (!is_empty_list(&rmesa->dma.reserved))
-               radeon_bo_unmap(first_elem(&rmesa->dma.reserved)->bo);
-
        if (is_empty_list(&rmesa->dma.free)
              || last_elem(&rmesa->dma.free)->bo->size < size) {
                dma_bo = CALLOC_STRUCT(radeon_dma_bo);
@@ -223,8 +221,6 @@ again_alloc:
         /* Cmd buff have been flushed in radeon_revalidate_bos */
                goto again_alloc;
        }
-
-       radeon_bo_map(first_elem(&rmesa->dma.reserved)->bo, 1);
 }
 
 /* Allocates a region from rmesa->dma.current.  If there isn't enough
@@ -281,7 +277,6 @@ void radeonFreeDmaRegions(radeonContextPtr rmesa)
 
        foreach_s(dma_bo, temp, &rmesa->dma.reserved) {
                remove_from_list(dma_bo);
-               radeon_bo_unmap(dma_bo->bo);
                radeon_bo_unref(dma_bo->bo);
                FREE(dma_bo);
        }
@@ -306,10 +301,6 @@ static int radeon_bo_is_idle(struct radeon_bo* bo)
                WARN_ONCE("Your libdrm or kernel doesn't have support for busy query.\n"
                        "This may cause small performance drop for you.\n");
        }
-       /* Protect against bug in legacy bo handling that causes bos stay
-        * referenced even after they should be freed */
-       if (bo->cref != 1)
-               return 0;
        return ret != -EBUSY;
 }
 
@@ -346,9 +337,7 @@ void radeonReleaseDmaRegions(radeonContextPtr rmesa)
        foreach_s(dma_bo, temp, &rmesa->dma.wait) {
                if (dma_bo->expire_counter == time) {
                        WARN_ONCE("Leaking dma buffer object!\n");
-                       /* force free of buffer so we don't realy start
-                        * leaking stuff now*/
-                       while ((dma_bo->bo = radeon_bo_unref(dma_bo->bo))) {}
+                       radeon_bo_unref(dma_bo->bo);
                        remove_from_list(dma_bo);
                        FREE(dma_bo);
                        continue;
@@ -367,9 +356,6 @@ void radeonReleaseDmaRegions(radeonContextPtr rmesa)
                insert_at_tail(&rmesa->dma.free, dma_bo);
        }
 
-       /* unmap the last dma region */
-       if (!is_empty_list(&rmesa->dma.reserved))
-               radeon_bo_unmap(first_elem(&rmesa->dma.reserved)->bo);
        /* move reserved to wait list */
        foreach_s(dma_bo, temp, &rmesa->dma.reserved) {
                /* free objects that are too small to be used because of large request */
@@ -403,11 +389,12 @@ void rcommon_flush_last_swtcl_prim( GLcontext *ctx  )
        radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
        struct radeon_dma *dma = &rmesa->dma;
                
-
        if (RADEON_DEBUG & RADEON_IOCTL)
                fprintf(stderr, "%s\n", __FUNCTION__);
        dma->flush = NULL;
 
+       radeon_bo_unmap(rmesa->swtcl.bo);
+
        if (!is_empty_list(&dma->reserved)) {
            GLuint current_offset = dma->current_used;
 
@@ -422,6 +409,8 @@ void rcommon_flush_last_swtcl_prim( GLcontext *ctx  )
            }
            rmesa->swtcl.numverts = 0;
        }
+       radeon_bo_unref(rmesa->swtcl.bo);
+       rmesa->swtcl.bo = NULL;
 }
 /* Alloc space in the current dma region.
  */
@@ -432,6 +421,7 @@ rcommonAllocDmaLowVerts( radeonContextPtr rmesa, int nverts, int vsize )
        void *head;
        if (RADEON_DEBUG & RADEON_IOCTL)
                fprintf(stderr, "%s\n", __FUNCTION__);
+
        if(is_empty_list(&rmesa->dma.reserved)
              ||rmesa->dma.current_vertexptr + bytes > first_elem(&rmesa->dma.reserved)->bo->size) {
                if (rmesa->dma.flush) {
@@ -455,7 +445,13 @@ rcommonAllocDmaLowVerts( radeonContextPtr rmesa, int nverts, int vsize )
                 rmesa->swtcl.numverts * rmesa->swtcl.vertex_size * 4 ==
                 rmesa->dma.current_vertexptr );
 
-       head = (first_elem(&rmesa->dma.reserved)->bo->ptr + rmesa->dma.current_vertexptr);
+       if (!rmesa->swtcl.bo) {
+               rmesa->swtcl.bo = first_elem(&rmesa->dma.reserved)->bo;
+               radeon_bo_ref(rmesa->swtcl.bo);
+               radeon_bo_map(rmesa->swtcl.bo, 1);
+       }
+
+       head = (rmesa->swtcl.bo->ptr + rmesa->dma.current_vertexptr);
        rmesa->dma.current_vertexptr += bytes;
        rmesa->swtcl.numverts += nverts;
        return head;
index 7ac53ec0ca38c7d04887d7ce52dc9ae1bec8d56a..7b1f84a71548277f24413fd59d3d0df791d1e115 100644 (file)
@@ -33,7 +33,6 @@
 #include "main/framebuffer.h"
 #include "main/renderbuffer.h"
 #include "main/context.h"
-#include "main/texformat.h"
 #include "main/texrender.h"
 #include "drivers/common/meta.h"
 
@@ -91,11 +90,8 @@ radeon_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
    case GL_R3_G3_B2:
    case GL_RGB4:
    case GL_RGB5:
-      rb->_ActualFormat = GL_RGB5;
+      rb->Format = _dri_texformat_rgb565;
       rb->DataType = GL_UNSIGNED_BYTE;
-      rb->RedBits = 5;
-      rb->GreenBits = 6;
-      rb->BlueBits = 5;
       cpp = 2;
       break;
    case GL_RGB:
@@ -103,12 +99,8 @@ radeon_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
    case GL_RGB10:
    case GL_RGB12:
    case GL_RGB16:
-      rb->_ActualFormat = GL_RGB8;
+      rb->Format = _dri_texformat_argb8888;
       rb->DataType = GL_UNSIGNED_BYTE;
-      rb->RedBits = 8;
-      rb->GreenBits = 8;
-      rb->BlueBits = 8;
-      rb->AlphaBits = 0;
       cpp = 4;
       break;
    case GL_RGBA:
@@ -119,12 +111,8 @@ radeon_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
    case GL_RGB10_A2:
    case GL_RGBA12:
    case GL_RGBA16:
-      rb->_ActualFormat = GL_RGBA8;
+      rb->Format = _dri_texformat_argb8888;
       rb->DataType = GL_UNSIGNED_BYTE;
-      rb->RedBits = 8;
-      rb->GreenBits = 8;
-      rb->BlueBits = 8;
-      rb->AlphaBits = 8;
       cpp = 4;
       break;
    case GL_STENCIL_INDEX:
@@ -133,39 +121,36 @@ radeon_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
    case GL_STENCIL_INDEX8_EXT:
    case GL_STENCIL_INDEX16_EXT:
       /* alloc a depth+stencil buffer */
-      rb->_ActualFormat = GL_DEPTH24_STENCIL8_EXT;
+      rb->Format = MESA_FORMAT_S8_Z24;
       rb->DataType = GL_UNSIGNED_INT_24_8_EXT;
-      rb->StencilBits = 8;
       cpp = 4;
       break;
    case GL_DEPTH_COMPONENT16:
-      rb->_ActualFormat = GL_DEPTH_COMPONENT16;
+      rb->Format = MESA_FORMAT_Z16;
       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_DEPTH_COMPONENT24;
+      rb->Format = MESA_FORMAT_X8_Z24;
       rb->DataType = GL_UNSIGNED_INT;
-      rb->DepthBits = 24;
       cpp = 4;
       break;
    case GL_DEPTH_STENCIL_EXT:
    case GL_DEPTH24_STENCIL8_EXT:
-      rb->_ActualFormat = GL_DEPTH24_STENCIL8_EXT;
+      rb->Format = MESA_FORMAT_S8_Z24;
       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");
+                    "Unexpected format in radeon_alloc_renderbuffer_storage");
       return GL_FALSE;
    }
 
+  rb->_BaseFormat = _mesa_base_fbo_format(ctx, internalFormat);
+
   if (ctx->Driver.Flush)
          ctx->Driver.Flush(ctx); /* +r6/r7 */
 
@@ -181,8 +166,9 @@ radeon_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
      uint32_t size;
      uint32_t pitch = ((cpp * width + 63) & ~63) / cpp;
 
-     fprintf(stderr,"Allocating %d x %d radeon RBO (pitch %d)\n", width,
-         height, pitch);
+     if (RADEON_DEBUG & RADEON_MEMORY)
+            fprintf(stderr,"Allocating %d x %d radeon RBO (pitch %d)\n", width,
+                    height, pitch);
 
      size = pitch * height * cpp;
      rrb->pitch = pitch * cpp;
@@ -213,7 +199,7 @@ radeon_alloc_window_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
    ASSERT(rb->Name == 0);
    rb->Width = width;
    rb->Height = height;
-   rb->_ActualFormat = internalFormat;
+   rb->InternalFormat = internalFormat;
 
    return GL_TRUE;
 }
@@ -255,8 +241,13 @@ radeon_nop_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
    return GL_FALSE;
 }
 
+
+/**
+ * Create a renderbuffer for a window's color, depth and/or stencil buffer.
+ * Not used for user-created renderbuffers.
+ */
 struct radeon_renderbuffer *
-radeon_create_renderbuffer(GLenum format, __DRIdrawablePrivate *driDrawPriv)
+radeon_create_renderbuffer(gl_format format, __DRIdrawable *driDrawPriv)
 {
     struct radeon_renderbuffer *rrb;
 
@@ -267,67 +258,64 @@ radeon_create_renderbuffer(GLenum format, __DRIdrawablePrivate *driDrawPriv)
     _mesa_init_renderbuffer(&rrb->base, 0);
     rrb->base.ClassID = RADEON_RB_CLASS;
 
-    /* XXX format junk */
+    rrb->base.Format = format;
+
     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;
+        case MESA_FORMAT_RGB565:
+           assert(_mesa_little_endian());
+           rrb->base.DataType = GL_UNSIGNED_BYTE;
+            rrb->base._BaseFormat = GL_RGB;
+           break;
+        case MESA_FORMAT_RGB565_REV:
+           assert(!_mesa_little_endian());
+           rrb->base.DataType = GL_UNSIGNED_BYTE;
+            rrb->base._BaseFormat = GL_RGB;
+           break;
+        case MESA_FORMAT_XRGB8888:
+           assert(_mesa_little_endian());
            rrb->base.DataType = GL_UNSIGNED_BYTE;
+            rrb->base._BaseFormat = GL_RGB;
            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 = 0;
+        case MESA_FORMAT_XRGB8888_REV:
+           assert(!_mesa_little_endian());
            rrb->base.DataType = GL_UNSIGNED_BYTE;
+            rrb->base._BaseFormat = GL_RGB;
            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;
+       case MESA_FORMAT_ARGB8888:
+           assert(_mesa_little_endian());
            rrb->base.DataType = GL_UNSIGNED_BYTE;
+            rrb->base._BaseFormat = GL_RGBA;
            break;
-       case GL_STENCIL_INDEX8_EXT:
-           rrb->base._ActualFormat = GL_STENCIL_INDEX8_EXT;
-           rrb->base._BaseFormat = GL_STENCIL_INDEX;
-           rrb->base.StencilBits = 8;
+       case MESA_FORMAT_ARGB8888_REV:
+           assert(!_mesa_little_endian());
            rrb->base.DataType = GL_UNSIGNED_BYTE;
+            rrb->base._BaseFormat = GL_RGBA;
            break;
-       case GL_DEPTH_COMPONENT16:
-           rrb->base._ActualFormat = GL_DEPTH_COMPONENT16;
-           rrb->base._BaseFormat = GL_DEPTH_COMPONENT;
-           rrb->base.DepthBits = 16;
+       case MESA_FORMAT_S8:
+           rrb->base.DataType = GL_UNSIGNED_BYTE;
+            rrb->base._BaseFormat = GL_STENCIL_INDEX;
+           break;
+       case MESA_FORMAT_Z16:
            rrb->base.DataType = GL_UNSIGNED_SHORT;
+            rrb->base._BaseFormat = GL_DEPTH_COMPONENT;
            break;
-       case GL_DEPTH_COMPONENT24:
-           rrb->base._ActualFormat = GL_DEPTH_COMPONENT24;
-           rrb->base._BaseFormat = GL_DEPTH_COMPONENT;
-           rrb->base.DepthBits = 24;
+       case MESA_FORMAT_X8_Z24:
            rrb->base.DataType = GL_UNSIGNED_INT;
+            rrb->base._BaseFormat = GL_DEPTH_COMPONENT;
            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;
+       case MESA_FORMAT_S8_Z24:
            rrb->base.DataType = GL_UNSIGNED_INT_24_8_EXT;
+            rrb->base._BaseFormat = GL_DEPTH_STENCIL;
            break;
        default:
-           fprintf(stderr, "%s: Unknown format 0x%04x\n", __FUNCTION__, format);
+           fprintf(stderr, "%s: Unknown format %s\n",
+                    __FUNCTION__, _mesa_get_format_name(format));
            _mesa_delete_renderbuffer(&rrb->base);
            return NULL;
     }
 
     rrb->dPriv = driDrawPriv;
-    rrb->base.InternalFormat = format;
+    rrb->base.InternalFormat = _mesa_get_format_base_format(format);
 
     rrb->base.Delete = radeon_delete_renderbuffer;
     rrb->base.AllocStorage = radeon_alloc_window_storage;
@@ -382,51 +370,41 @@ radeon_framebuffer_renderbuffer(GLcontext * ctx,
 }
 
 
+/* TODO: According to EXT_fbo spec internal format of texture image
+ * once set during glTexImage call, should be preserved when
+ * attaching image to renderbuffer. When HW doesn't support
+ * rendering to format of attached image, set framebuffer
+ * completeness accordingly in radeon_validate_framebuffer (issue #79).
+ */
 static GLboolean
 radeon_update_wrapper(GLcontext *ctx, struct radeon_renderbuffer *rrb, 
                     struct gl_texture_image *texImage)
 {
        int retry = 0;
+       gl_format texFormat;
+
 restart:
-       if (texImage->TexFormat == &_mesa_texformat_argb8888) {
-               rrb->cpp = 4;
-               rrb->base._ActualFormat = GL_RGBA8;
-               rrb->base._BaseFormat = GL_RGBA;
+       if (texImage->TexFormat == _dri_texformat_argb8888) {
                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;
+       else if (texImage->TexFormat == _dri_texformat_rgb565) {
                rrb->base.DataType = GL_UNSIGNED_BYTE;
                DBG("Render to RGB5 texture OK\n");
        }
-       else if (texImage->TexFormat == &_mesa_texformat_argb1555) {
-               rrb->cpp = 2;
-               rrb->base._ActualFormat = GL_RGB5_A1;
-               rrb->base._BaseFormat = GL_RGBA;
+       else if (texImage->TexFormat == _dri_texformat_argb1555) {
                rrb->base.DataType = GL_UNSIGNED_BYTE;
                DBG("Render to ARGB1555 texture OK\n");
        }
-       else if (texImage->TexFormat == &_mesa_texformat_argb4444) {
-               rrb->cpp = 2;
-               rrb->base._ActualFormat = GL_RGBA4;
-               rrb->base._BaseFormat = GL_RGBA;
+       else if (texImage->TexFormat == _dri_texformat_argb4444) {
                rrb->base.DataType = GL_UNSIGNED_BYTE;
-               DBG("Render to ARGB1555 texture OK\n");
+               DBG("Render to ARGB4444 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;
+       else if (texImage->TexFormat == MESA_FORMAT_Z16) {
                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;
+       else if (texImage->TexFormat == MESA_FORMAT_S8_Z24) {
                rrb->base.DataType = GL_UNSIGNED_INT_24_8_EXT;
                DBG("Render to DEPTH_STENCIL texture OK\n");
        }
@@ -434,27 +412,31 @@ restart:
                /* try redoing the FBO */
                if (retry == 1) {
                        DBG("Render to texture BAD FORMAT %d\n",
-                           texImage->TexFormat->MesaFormat);
+                           texImage->TexFormat);
                        return GL_FALSE;
                }
+                /* XXX why is the tex format being set here?
+                 * I think this can be removed.
+                 */
                texImage->TexFormat = radeonChooseTextureFormat(ctx, texImage->InternalFormat, 0,
-                                                               texImage->TexFormat->DataType,
+                                                               _mesa_get_format_datatype(texImage->TexFormat),
                                                                1);
 
                retry++;
                goto restart;
        }
        
+       texFormat = texImage->TexFormat;
+
+       rrb->base.Format = texFormat;
+
+        rrb->cpp = _mesa_get_format_bytes(texFormat);
        rrb->pitch = texImage->Width * rrb->cpp;
-       rrb->base.InternalFormat = rrb->base._ActualFormat;
+       rrb->base.InternalFormat = texImage->InternalFormat;
+        rrb->base._BaseFormat = _mesa_base_fbo_format(ctx, rrb->base.InternalFormat);
+
        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.StencilBits = texImage->TexFormat->StencilBits;
        
        rrb->base.Delete = radeon_delete_renderbuffer;
        rrb->base.AllocStorage = radeon_nop_alloc_storage;
@@ -555,8 +537,10 @@ radeon_render_texture(GLcontext * ctx,
       imageOffset += offsets[att->Zoffset];
    }
 
-   /* store that offset in the region */
+   /* store that offset in the region, along with the correct pitch for
+    * the image we are rendering to */
    rrb->draw_offset = imageOffset;
+   rrb->pitch = radeon_image->mt->levels[att->TextureLevel].rowstride;
 
    /* update drawing region, etc */
    radeon_draw_buffer(ctx, fb);
index a0106d00fa227bc95a1ea6267277e90ddd5b320c..a9d50c5d0781d439fa96fa794321bfa9c7550399 100644 (file)
@@ -449,7 +449,7 @@ void radeonEmitAOS( r100ContextPtr rmesa,
 static void radeonKernelClear(GLcontext *ctx, GLuint flags)
 {
      r100ContextPtr rmesa = R100_CONTEXT(ctx);
-   __DRIdrawablePrivate *dPriv = radeon_get_drawable(&rmesa->radeon);
+   __DRIdrawable *dPriv = radeon_get_drawable(&rmesa->radeon);
    drm_radeon_sarea_t *sarea = rmesa->radeon.sarea;
    uint32_t clear;
    GLint ret, i;
@@ -570,11 +570,15 @@ static void radeonKernelClear(GLcontext *ctx, GLuint flags)
 static void radeonClear( GLcontext *ctx, GLbitfield mask )
 {
    r100ContextPtr rmesa = R100_CONTEXT(ctx);
-   __DRIdrawablePrivate *dPriv = radeon_get_drawable(&rmesa->radeon);
+   __DRIdrawable *dPriv = radeon_get_drawable(&rmesa->radeon);
    GLuint flags = 0;
    GLuint color_mask = 0;
    GLuint orig_mask = mask;
 
+   if (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_FRONT_RIGHT)) {
+      rmesa->radeon.front_buffer_dirty = GL_TRUE;
+   }
+
    if ( RADEON_DEBUG & RADEON_IOCTL ) {
       fprintf( stderr, "radeonClear\n");
    }
index 02de8e5fd1d92716130cc31118ccbc954a2c28ac..9dee691938a0848981f56d29c082e4eb5e3e96b1 100644 (file)
@@ -58,11 +58,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 void radeonGetLock(radeonContextPtr rmesa, GLuint flags)
 {
-       __DRIdrawablePrivate *const drawable = radeon_get_drawable(rmesa);
-       __DRIdrawablePrivate *const readable = radeon_get_readable(rmesa);
-       __DRIscreenPrivate *sPriv = rmesa->dri.screen;
-
-       assert(drawable != NULL);
+       __DRIdrawable *const drawable = radeon_get_drawable(rmesa);
+       __DRIdrawable *const readable = radeon_get_readable(rmesa);
+       __DRIscreen *sPriv = rmesa->dri.screen;
 
        drmGetLock(rmesa->dri.fd, rmesa->dri.hwContext, flags);
 
@@ -74,12 +72,13 @@ void radeonGetLock(radeonContextPtr rmesa, GLuint flags)
         * 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) {
+       if (drawable)
+               DRI_VALIDATE_DRAWABLE_INFO(sPriv, drawable);
+       if (readable && drawable != readable) {
                DRI_VALIDATE_DRAWABLE_INFO(sPriv, readable);
        }
 
-       if (rmesa->lastStamp != drawable->lastStamp) {
+       if (drawable && (rmesa->lastStamp != drawable->lastStamp)) {
                radeon_window_moved(rmesa);
                rmesa->lastStamp = drawable->lastStamp;
        }
index 08e1c5d00df44d1c043b9bc83fdef8d0ac101f35..d810e6080eb786d38f4bb440c705ce1e25f6d117 100644 (file)
@@ -76,12 +76,14 @@ static void emit_vecfog(GLcontext *ctx, struct radeon_aos *aos,
 
    /* Emit the data
     */
+   radeon_bo_map(aos->bo, 1);
    out = (uint32_t*)((char*)aos->bo->ptr + aos->offset);
    for (i = 0; i < count; i++) {
       out[0] = radeonComputeFogBlendFactor( ctx, *(GLfloat *)data );
       out++;
       data += stride;
    }
+   radeon_bo_unmap(aos->bo);
 }
 
 static void emit_s0_vec(uint32_t *out, GLvoid *data, int stride, int count)
@@ -151,6 +153,7 @@ static void emit_tex_vector(GLcontext *ctx, struct radeon_aos *aos,
 
    /* Emit the data
     */
+   radeon_bo_map(aos->bo, 1);
    out = (uint32_t*)((char*)aos->bo->ptr + aos->offset);
    switch (size) {
    case 1:
@@ -170,6 +173,7 @@ static void emit_tex_vector(GLcontext *ctx, struct radeon_aos *aos,
       exit(1);
       break;
    }
+   radeon_bo_unmap(aos->bo);
 }
 
 
@@ -196,12 +200,12 @@ void radeonEmitArrays( GLcontext *ctx, GLuint inputs )
       if (!rmesa->tcl.obj.buf) 
        rcommon_emit_vector( ctx, 
                             &(rmesa->tcl.aos[nr]),
-                            (char *)VB->ObjPtr->data,
-                            VB->ObjPtr->size,
-                            VB->ObjPtr->stride,
+                            (char *)VB->AttribPtr[_TNL_ATTRIB_POS]->data,
+                            VB->AttribPtr[_TNL_ATTRIB_POS]->size,
+                            VB->AttribPtr[_TNL_ATTRIB_POS]->stride,
                             count);
 
-      switch( VB->ObjPtr->size ) {
+      switch( VB->AttribPtr[_TNL_ATTRIB_POS]->size ) {
       case 4: vfmt |= RADEON_CP_VC_FRMT_W0;
       case 3: vfmt |= RADEON_CP_VC_FRMT_Z;
       case 2: vfmt |= RADEON_CP_VC_FRMT_XY;
@@ -216,9 +220,9 @@ void radeonEmitArrays( GLcontext *ctx, GLuint inputs )
       if (!rmesa->tcl.norm.buf)
         rcommon_emit_vector( ctx, 
                              &(rmesa->tcl.aos[nr]),
-                             (char *)VB->NormalPtr->data,
+                             (char *)VB->AttribPtr[_TNL_ATTRIB_NORMAL]->data,
                              3,
-                             VB->NormalPtr->stride,
+                             VB->AttribPtr[_TNL_ATTRIB_NORMAL]->stride,
                              count);
 
       vfmt |= RADEON_CP_VC_FRMT_N0;
@@ -227,9 +231,9 @@ void radeonEmitArrays( GLcontext *ctx, GLuint inputs )
 
    if (inputs & VERT_BIT_COLOR0) {
       int emitsize;
-      if (VB->ColorPtr[0]->size == 4 &&
-         (VB->ColorPtr[0]->stride != 0 ||
-          VB->ColorPtr[0]->data[0][3] != 1.0)) {
+      if (VB->AttribPtr[_TNL_ATTRIB_COLOR0]->size == 4 &&
+         (VB->AttribPtr[_TNL_ATTRIB_COLOR0]->stride != 0 ||
+          VB->AttribPtr[_TNL_ATTRIB_COLOR0]->data[0][3] != 1.0)) {
         vfmt |= RADEON_CP_VC_FRMT_FPCOLOR | RADEON_CP_VC_FRMT_FPALPHA;
         emitsize = 4;
       }
@@ -242,9 +246,9 @@ void radeonEmitArrays( GLcontext *ctx, GLuint inputs )
       if (!rmesa->tcl.rgba.buf)
        rcommon_emit_vector( ctx,
                             &(rmesa->tcl.aos[nr]),
-                            (char *)VB->ColorPtr[0]->data,
+                            (char *)VB->AttribPtr[_TNL_ATTRIB_COLOR0]->data,
                             emitsize,
-                            VB->ColorPtr[0]->stride,
+                            VB->AttribPtr[_TNL_ATTRIB_COLOR0]->stride,
                             count);
 
       nr++;
@@ -256,9 +260,9 @@ void radeonEmitArrays( GLcontext *ctx, GLuint inputs )
 
        rcommon_emit_vector( ctx,
                             &(rmesa->tcl.aos[nr]),
-                            (char *)VB->SecondaryColorPtr[0]->data,
+                            (char *)VB->AttribPtr[_TNL_ATTRIB_COLOR1]->data,
                             3,
-                            VB->SecondaryColorPtr[0]->stride,
+                            VB->AttribPtr[_TNL_ATTRIB_COLOR1]->stride,
                             count);
       }
 
@@ -273,8 +277,8 @@ void radeonEmitArrays( GLcontext *ctx, GLuint inputs )
       if (!rmesa->tcl.fog.buf)
         emit_vecfog( ctx,
                      &(rmesa->tcl.aos[nr]),
-                     (char *)VB->FogCoordPtr->data,
-                     VB->FogCoordPtr->stride,
+                     (char *)VB->AttribPtr[_TNL_ATTRIB_FOG]->data,
+                     VB->AttribPtr[_TNL_ATTRIB_FOG]->stride,
                      count);
 
       vfmt |= RADEON_CP_VC_FRMT_FPFOG;
@@ -290,24 +294,24 @@ void radeonEmitArrays( GLcontext *ctx, GLuint inputs )
         if (!rmesa->tcl.tex[unit].buf)
            emit_tex_vector( ctx,
                             &(rmesa->tcl.aos[nr]),
-                            (char *)VB->TexCoordPtr[unit]->data,
-                            VB->TexCoordPtr[unit]->size,
-                            VB->TexCoordPtr[unit]->stride,
+                            (char *)VB->AttribPtr[_TNL_ATTRIB_TEX0 + unit]->data,
+                            VB->AttribPtr[_TNL_ATTRIB_TEX0 + unit]->size,
+                            VB->AttribPtr[_TNL_ATTRIB_TEX0 + 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
            3 coords are submitted. This may not be 100% correct */
-         if (VB->TexCoordPtr[unit]->size >= 3) {
+         if (VB->AttribPtr[_TNL_ATTRIB_TEX0 + unit]->size >= 3) {
            vtx |= RADEON_Q_BIT(unit);
            vfmt |= RADEON_Q_BIT(unit);
         }
         if ( (ctx->Texture.Unit[unit].TexGenEnabled & (R_BIT | Q_BIT)) )
            vtx |= RADEON_Q_BIT(unit);
-        else if ((VB->TexCoordPtr[unit]->size >= 3) &&
+        else if ((VB->AttribPtr[_TNL_ATTRIB_TEX0 + unit]->size >= 3) &&
                  ((ctx->Texture.Unit[unit]._ReallyEnabled & (TEXTURE_CUBE_BIT)) == 0)) {
-           GLuint swaptexmatcol = (VB->TexCoordPtr[unit]->size - 3);
+           GLuint swaptexmatcol = (VB->AttribPtr[_TNL_ATTRIB_TEX0 + unit]->size - 3);
            if (((rmesa->NeedTexMatrix >> unit) & 1) &&
                 (swaptexmatcol != ((rmesa->TexMatColSwap >> unit) & 1)))
               radeonUploadTexMatrix( rmesa, unit, swaptexmatcol ) ;
index 515783135d6f074872c3eff293fa36ff53a87a09..d764ccb982695191a9a3a19414c59bb97ef6a1fc 100644 (file)
@@ -56,18 +56,18 @@ static void TAG(emit)( GLcontext *ctx,
 
    radeon_print(RADEON_SWRENDER, RADEON_VERBOSE, "%s\n", __FUNCTION__);
 
-   coord = (GLuint (*)[4])VB->ObjPtr->data;
-   coord_stride = VB->ObjPtr->stride;
+   coord = (GLuint (*)[4])VB->AttribPtr[_TNL_ATTRIB_POS]->data;
+   coord_stride = VB->AttribPtr[_TNL_ATTRIB_POS]->stride;
 
    if (DO_TEX2) {
-      if (VB->TexCoordPtr[2]) {
+      if (VB->AttribPtr[_TNL_ATTRIB_TEX2]) {
         const GLuint t2 = GET_TEXSOURCE(2);
-        tc2 = (GLuint (*)[4])VB->TexCoordPtr[t2]->data;
-        tc2_stride = VB->TexCoordPtr[t2]->stride;
-        if (DO_PTEX && VB->TexCoordPtr[t2]->size < 3) {
+        tc2 = (GLuint (*)[4])VB->AttribPtr[_TNL_ATTRIB_TEX0 + t2]->data;
+        tc2_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t2]->stride;
+        if (DO_PTEX && VB->AttribPtr[_TNL_ATTRIB_TEX0 + t2]->size < 3) {
            fill_tex |= (1<<2);
         }
-        else if (DO_PTEX && VB->TexCoordPtr[t2]->size < 4) {
+        else if (DO_PTEX && VB->AttribPtr[_TNL_ATTRIB_TEX0 + t2]->size < 4) {
            rqcoordsnoswap |= (1<<2);
         }
       } else {
@@ -77,14 +77,14 @@ static void TAG(emit)( GLcontext *ctx,
    }
 
    if (DO_TEX1) {
-      if (VB->TexCoordPtr[1]) {
+      if (VB->AttribPtr[_TNL_ATTRIB_TEX1]) {
         const GLuint t1 = GET_TEXSOURCE(1);
-        tc1 = (GLuint (*)[4])VB->TexCoordPtr[t1]->data;
-        tc1_stride = VB->TexCoordPtr[t1]->stride;
-        if (DO_PTEX && VB->TexCoordPtr[t1]->size < 3) {
+        tc1 = (GLuint (*)[4])VB->AttribPtr[_TNL_ATTRIB_TEX0 + t1]->data;
+        tc1_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t1]->stride;
+        if (DO_PTEX && VB->AttribPtr[_TNL_ATTRIB_TEX0 + t1]->size < 3) {
            fill_tex |= (1<<1);
         }
-        else if (DO_PTEX && VB->TexCoordPtr[t1]->size < 4) {
+        else if (DO_PTEX && VB->AttribPtr[_TNL_ATTRIB_TEX0 + t1]->size < 4) {
            rqcoordsnoswap |= (1<<1);
         }
       } else {
@@ -94,14 +94,14 @@ static void TAG(emit)( GLcontext *ctx,
    }
 
    if (DO_TEX0) {
-      if (VB->TexCoordPtr[0]) {
+      if (VB->AttribPtr[_TNL_ATTRIB_TEX0]) {
         const GLuint t0 = GET_TEXSOURCE(0);
-        tc0_stride = VB->TexCoordPtr[t0]->stride;
-        tc0 = (GLuint (*)[4])VB->TexCoordPtr[t0]->data;
-        if (DO_PTEX && VB->TexCoordPtr[t0]->size < 3) {
+        tc0_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t0]->stride;
+        tc0 = (GLuint (*)[4])VB->AttribPtr[_TNL_ATTRIB_TEX0 + t0]->data;
+        if (DO_PTEX && VB->AttribPtr[_TNL_ATTRIB_TEX0 + t0]->size < 3) {
            fill_tex |= (1<<0);
         }
-        else if (DO_PTEX && VB->TexCoordPtr[t0]->size < 4) {
+        else if (DO_PTEX && VB->AttribPtr[_TNL_ATTRIB_TEX0 + t0]->size < 4) {
            rqcoordsnoswap |= (1<<0);
         }
       } else {
@@ -112,9 +112,9 @@ static void TAG(emit)( GLcontext *ctx,
    }
 
    if (DO_NORM) {
-      if (VB->NormalPtr) {
-        norm_stride = VB->NormalPtr->stride;
-        norm = (GLuint (*)[4])VB->NormalPtr->data;
+      if (VB->AttribPtr[_TNL_ATTRIB_NORMAL]) {
+        norm_stride = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->stride;
+        norm = (GLuint (*)[4])VB->AttribPtr[_TNL_ATTRIB_NORMAL]->data;
       } else {
         norm_stride = 0;
         norm = (GLuint (*)[4])&ctx->Current.Attrib[VERT_ATTRIB_NORMAL];
@@ -122,9 +122,9 @@ static void TAG(emit)( GLcontext *ctx,
    }
 
    if (DO_RGBA) {
-      if (VB->ColorPtr[0]) {
-        col = VB->ColorPtr[0]->data;
-        col_stride = VB->ColorPtr[0]->stride;
+      if (VB->AttribPtr[_TNL_ATTRIB_COLOR0]) {
+        col = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->data;
+        col_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->stride;
       } else {
         col = (GLfloat (*)[4])ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
         col_stride = 0;
@@ -132,9 +132,9 @@ static void TAG(emit)( GLcontext *ctx,
    }
 
    if (DO_SPEC_OR_FOG) {
-      if (VB->SecondaryColorPtr[0]) {
-        spec = VB->SecondaryColorPtr[0]->data;
-        spec_stride = VB->SecondaryColorPtr[0]->stride;
+      if (VB->AttribPtr[_TNL_ATTRIB_COLOR1]) {
+        spec = VB->AttribPtr[_TNL_ATTRIB_COLOR1]->data;
+        spec_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR1]->stride;
       } else {
         spec = (GLfloat (*)[4])ctx->Current.Attrib[VERT_ATTRIB_COLOR1];
         spec_stride = 0;
@@ -142,9 +142,9 @@ static void TAG(emit)( GLcontext *ctx,
    }
 
    if (DO_SPEC_OR_FOG) {
-      if (VB->FogCoordPtr) {
-        fog = VB->FogCoordPtr->data;
-        fog_stride = VB->FogCoordPtr->stride;
+      if (VB->AttribPtr[_TNL_ATTRIB_FOG]) {
+        fog = VB->AttribPtr[_TNL_ATTRIB_FOG]->data;
+        fog_stride = VB->AttribPtr[_TNL_ATTRIB_FOG]->stride;
       } else {
         fog = (GLfloat (*)[4])ctx->Current.Attrib[VERT_ATTRIB_FOG];
         fog_stride = 0;
index 78ec1193026bb0e26171803b70c69c7daa1f82a7..98f96ff2a768962b3f4de84ebafca8cfd484f744 100644 (file)
@@ -326,7 +326,7 @@ void radeonEmitArrays( GLcontext *ctx, GLuint inputs )
 
    if (1) {
       req |= RADEON_CP_VC_FRMT_Z;
-      if (VB->ObjPtr->size == 4) {
+      if (VB->AttribPtr[_TNL_ATTRIB_POS]->size == 4) {
         req |= RADEON_CP_VC_FRMT_W0;
       }
    }
@@ -348,15 +348,15 @@ void radeonEmitArrays( GLcontext *ctx, GLuint inputs )
         req |= RADEON_ST_BIT(unit);
         /* assume we need the 3rd coord if texgen is active for r/q OR at least
            3 coords are submitted. This may not be 100% correct */
-        if (VB->TexCoordPtr[unit]->size >= 3) {
+        if (VB->AttribPtr[_TNL_ATTRIB_TEX0 + unit]->size >= 3) {
            req |= RADEON_Q_BIT(unit);
            vtx |= RADEON_Q_BIT(unit);
         }
         if ( (ctx->Texture.Unit[unit].TexGenEnabled & (R_BIT | Q_BIT)) )
            vtx |= RADEON_Q_BIT(unit);
-        else if ((VB->TexCoordPtr[unit]->size >= 3) &&
+        else if ((VB->AttribPtr[_TNL_ATTRIB_TEX0 + unit]->size >= 3) &&
                  ((ctx->Texture.Unit[unit]._ReallyEnabled & (TEXTURE_CUBE_BIT)) == 0)) {
-           GLuint swaptexmatcol = (VB->TexCoordPtr[unit]->size - 3);
+           GLuint swaptexmatcol = (VB->AttribPtr[_TNL_ATTRIB_TEX0 + unit]->size - 3);
            if (((rmesa->NeedTexMatrix >> unit) & 1) &&
                 (swaptexmatcol != ((rmesa->TexMatColSwap >> unit) & 1)))
               radeonUploadTexMatrix( rmesa, unit, swaptexmatcol ) ;
@@ -390,19 +390,19 @@ void radeonEmitArrays( GLcontext *ctx, GLuint inputs )
     * this, add more vertex code (for obj-2, obj-3) or preferably move
     * to maos.  
     */
-   if (VB->ObjPtr->size < 3 || 
-       (VB->ObjPtr->size == 3 && 
+   if (VB->AttribPtr[_TNL_ATTRIB_POS]->size < 3 ||
+       (VB->AttribPtr[_TNL_ATTRIB_POS]->size == 3 &&
        (setup_tab[i].vertex_format & RADEON_CP_VC_FRMT_W0))) {
 
       _math_trans_4f( rmesa->tcl.ObjClean.data,
-                     VB->ObjPtr->data,
-                     VB->ObjPtr->stride,
+                     VB->AttribPtr[_TNL_ATTRIB_POS]->data,
+                     VB->AttribPtr[_TNL_ATTRIB_POS]->stride,
                      GL_FLOAT,
-                     VB->ObjPtr->size,
+                     VB->AttribPtr[_TNL_ATTRIB_POS]->size,
                      0,
                      VB->Count );
 
-      switch (VB->ObjPtr->size) {
+      switch (VB->AttribPtr[_TNL_ATTRIB_POS]->size) {
       case 1:
            _mesa_vector4f_clean_elem(&rmesa->tcl.ObjClean, VB->Count, 1);
       case 2:
@@ -416,14 +416,14 @@ void radeonEmitArrays( GLcontext *ctx, GLuint inputs )
         break;
       }
 
-      VB->ObjPtr = &rmesa->tcl.ObjClean;
+      VB->AttribPtr[_TNL_ATTRIB_POS] = &rmesa->tcl.ObjClean;
    }
 
 
-
+   radeon_bo_map(rmesa->radeon.tcl.aos[0].bo, 1);
    setup_tab[i].emit( ctx, 0, VB->Count, 
                      rmesa->radeon.tcl.aos[0].bo->ptr + rmesa->radeon.tcl.aos[0].offset);
-
+   radeon_bo_unmap(rmesa->radeon.tcl.aos[0].bo);
    //   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;
index 38db305e2a76e76a9405471843e3f0fc3080a047..033f26db2a1b69a7ca92c044380cdbe019aa5cd1 100644 (file)
@@ -1,4 +1,5 @@
 /*
+ * Copyright (C) 2009 Maciej Cencora.
  * Copyright (C) 2008 Nicolai Haehnle.
  *
  * All Rights Reserved.
 
 #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)
+#include "main/teximage.h"
+#include "main/texobj.h"
+#include "radeon_texture.h"
+
+static unsigned get_aligned_compressed_row_stride(
+               gl_format format,
+               unsigned width,
+               unsigned minStride)
 {
-       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;
+       const unsigned blockSize = _mesa_get_format_bytes(format);
+       unsigned blockWidth, blockHeight, numXBlocks;
+
+       _mesa_get_format_block_size(format, &blockWidth, &blockHeight);
+       numXBlocks = (width + blockWidth - 1) / blockWidth;
+
+       while (numXBlocks * blockSize < minStride)
+       {
+               ++numXBlocks;
        }
 
-       return size;
+       return numXBlocks * blockSize;
 }
 
+static unsigned get_compressed_image_size(
+               gl_format format,
+               unsigned rowStride,
+               unsigned height)
+{
+       unsigned blockWidth, blockHeight;
+
+       _mesa_get_format_block_size(format, &blockWidth, &blockHeight);
+
+       return rowStride * ((height + blockHeight - 1) / blockHeight);
+}
 
-static int radeon_compressed_num_bytes(GLuint mesaFormat)
+static int find_next_power_of_two(GLuint value)
 {
-   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;
+       int i, tmp;
+
+       i = 0;
+       tmp = value - 1;
+       while (tmp) {
+               tmp >>= 1;
+               i++;
+       }
+       return (1 << i);
 }
 
 /**
@@ -91,28 +93,28 @@ static void compute_tex_image_offset(radeonContextPtr rmesa, radeon_mipmap_tree
 {
        radeon_mipmap_level *lvl = &mt->levels[level];
        uint32_t row_align;
+       GLuint height;
+
+       height = find_next_power_of_two(lvl->height);
 
        /* Find image size in bytes */
-       if (mt->compressed) {
-               /* TODO: Is this correct? Need test cases for compressed textures! */
-               row_align = rmesa->texture_compressed_row_align - 1;
-               lvl->rowstride = (lvl->width * mt->bpp + row_align) & ~row_align;
-               lvl->size = radeon_compressed_texture_size(mt->radeon->glCtx,
-                                                          lvl->width, lvl->height, lvl->depth, mt->compressed);
+       if (_mesa_is_format_compressed(mt->mesaFormat)) {
+               lvl->rowstride = get_aligned_compressed_row_stride(mt->mesaFormat, lvl->width, rmesa->texture_compressed_row_align);
+               lvl->size = get_compressed_image_size(mt->mesaFormat, lvl->rowstride, height);
        } else if (mt->target == GL_TEXTURE_RECTANGLE_NV) {
                row_align = rmesa->texture_rect_row_align - 1;
-               lvl->rowstride = (lvl->width * mt->bpp + row_align) & ~row_align;
-               lvl->size = lvl->rowstride * lvl->height;
+               lvl->rowstride = (_mesa_format_row_stride(mt->mesaFormat, lvl->width) + row_align) & ~row_align;
+               lvl->size = lvl->rowstride * 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;
+               lvl->rowstride = (_mesa_format_row_stride(mt->mesaFormat, lvl->width) * 2 + 31) & ~31;
+               lvl->size = lvl->rowstride * ((height + 1) / 2) * lvl->depth;
        } else {
                row_align = rmesa->texture_row_align - 1;
-               lvl->rowstride = (lvl->width * mt->bpp + row_align) & ~row_align;
-               lvl->size = lvl->rowstride * lvl->height * lvl->depth;
+               lvl->rowstride = (_mesa_format_row_stride(mt->mesaFormat, lvl->width) + row_align) & ~row_align;
+               lvl->size = lvl->rowstride * height * lvl->depth;
        }
        assert(lvl->size > 0);
 
@@ -124,7 +126,7 @@ static void compute_tex_image_offset(radeonContextPtr rmesa, radeon_mipmap_tree
        if (RADEON_DEBUG & RADEON_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);
+                 level, face, lvl->rowstride, lvl->width, height, lvl->faces[face].offset);
 }
 
 static GLuint minify(GLuint size, GLuint levels)
@@ -138,22 +140,19 @@ static GLuint minify(GLuint size, GLuint levels)
 
 static void calculate_miptree_layout_r100(radeonContextPtr rmesa, radeon_mipmap_tree *mt)
 {
-       GLuint curOffset;
-       GLuint numLevels;
-       GLuint i;
-       GLuint face;
+       GLuint curOffset, i, face, level;
 
-       numLevels = mt->lastLevel - mt->firstLevel + 1;
-       assert(numLevels <= rmesa->glCtx->Const.MaxTextureLevels);
+       assert(mt->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);
+               for(i = 0, level = mt->baseLevel; i < mt->numLevels; i++, level++) {
+                       mt->levels[level].valid = 1;
+                       mt->levels[level].width = minify(mt->width0, i);
+                       mt->levels[level].height = minify(mt->height0, i);
+                       mt->levels[level].depth = minify(mt->depth0, i);
+                       compute_tex_image_offset(rmesa, mt, face, level, &curOffset);
                }
        }
 
@@ -163,23 +162,21 @@ static void calculate_miptree_layout_r100(radeonContextPtr rmesa, radeon_mipmap_
 
 static void calculate_miptree_layout_r300(radeonContextPtr rmesa, radeon_mipmap_tree *mt)
 {
-       GLuint curOffset;
-       GLuint numLevels;
-       GLuint i;
+       GLuint curOffset, i, level;
 
-       numLevels = mt->lastLevel - mt->firstLevel + 1;
-       assert(numLevels <= rmesa->glCtx->Const.MaxTextureLevels);
+       assert(mt->numLevels <= rmesa->glCtx->Const.MaxTextureLevels);
 
        curOffset = 0;
-       for(i = 0; i < numLevels; i++) {
+       for(i = 0, level = mt->baseLevel; i < mt->numLevels; i++, level++) {
                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);
+               mt->levels[level].valid = 1;
+               mt->levels[level].width = minify(mt->width0, i);
+               mt->levels[level].height = minify(mt->height0, i);
+               mt->levels[level].depth = minify(mt->depth0, i);
 
                for(face = 0; face < mt->faces; face++)
-                       compute_tex_image_offset(rmesa, mt, face, i, &curOffset);
+                       compute_tex_image_offset(rmesa, mt, face, level, &curOffset);
        }
 
        /* Note the required size in memory */
@@ -189,27 +186,22 @@ static void calculate_miptree_layout_r300(radeonContextPtr rmesa, radeon_mipmap_
 /**
  * Create a new mipmap tree, calculate its layout and allocate memory.
  */
-radeon_mipmap_tree* radeon_miptree_create(radeonContextPtr rmesa, radeonTexObj *t,
-               GLenum target, GLenum internal_format, GLuint firstLevel, GLuint lastLevel,
-               GLuint width0, GLuint height0, GLuint depth0,
-               GLuint bpp, GLuint tilebits, GLuint compressed)
+static radeon_mipmap_tree* radeon_miptree_create(radeonContextPtr rmesa,
+               GLenum target, gl_format mesaFormat, GLuint baseLevel, GLuint numLevels,
+               GLuint width0, GLuint height0, GLuint depth0, GLuint tilebits)
 {
        radeon_mipmap_tree *mt = CALLOC_STRUCT(_radeon_mipmap_tree);
 
-       mt->radeon = rmesa;
-       mt->internal_format = internal_format;
+       mt->mesaFormat = mesaFormat;
        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->baseLevel = baseLevel;
+       mt->numLevels = numLevels;
        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);
@@ -224,53 +216,43 @@ radeon_mipmap_tree* radeon_miptree_create(radeonContextPtr rmesa, radeonTexObj *
        return mt;
 }
 
-void radeon_miptree_reference(radeon_mipmap_tree *mt)
+void radeon_miptree_reference(radeon_mipmap_tree *mt, radeon_mipmap_tree **ptr)
 {
+       assert(!*ptr);
+
        mt->refcount++;
        assert(mt->refcount > 0);
+
+       *ptr = mt;
 }
 
-void radeon_miptree_unreference(radeon_mipmap_tree *mt)
+void radeon_miptree_unreference(radeon_mipmap_tree **ptr)
 {
+       radeon_mipmap_tree *mt = *ptr;
        if (!mt)
                return;
 
        assert(mt->refcount > 0);
+
        mt->refcount--;
        if (!mt->refcount) {
                radeon_bo_unref(mt->bo);
                free(mt);
        }
-}
 
+       *ptr = 0;
+}
 
 /**
- * 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.
+ * Calculate min and max LOD for the given texture object.
+ * @param[in] tObj texture object whose LOD values to calculate
+ * @param[out] pminLod minimal LOD
+ * @param[out] pmaxLod maximal LOD
  */
-static void calculate_first_last_level(struct gl_texture_object *tObj,
-                                      GLuint *pfirstLevel, GLuint *plastLevel,
-                                      GLuint face, GLuint level)
+static void calculate_min_max_lod(struct gl_texture_object *tObj,
+                                      unsigned *pminLod, unsigned *pmaxLod)
 {
-       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;
-
+       int minLod, maxLod;
        /* Yes, this looks overly complicated, but it's all needed.
        */
        switch (tObj->Target) {
@@ -281,32 +263,30 @@ static void calculate_first_last_level(struct gl_texture_object *tObj,
                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;
+                       minLod = maxLod = 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 */
+                       minLod = tObj->BaseLevel + (GLint)(tObj->MinLod);
+                       minLod = MAX2(minLod, tObj->BaseLevel);
+                       minLod = MIN2(minLod, tObj->MaxLevel);
+                       maxLod = tObj->BaseLevel + (GLint)(tObj->MaxLod + 0.5);
+                       maxLod = MIN2(maxLod, tObj->MaxLevel);
+                       maxLod = MIN2(maxLod, tObj->Image[0][minLod]->MaxLog2 + minLod);
+                       maxLod = MAX2(maxLod, minLod); /* need at least one level */
                }
                break;
        case GL_TEXTURE_RECTANGLE_NV:
        case GL_TEXTURE_4D_SGIS:
-               firstLevel = lastLevel = 0;
+               minLod = maxLod = 0;
                break;
        default:
                return;
        }
 
        /* save these values */
-       *pfirstLevel = firstLevel;
-       *plastLevel = lastLevel;
+       *pminLod = minLod;
+       *pmaxLod = maxLod;
 }
 
-
 /**
  * Checks whether the given miptree can hold the given texture image at the
  * given face and level.
@@ -316,20 +296,15 @@ GLboolean radeon_miptree_matches_image(radeon_mipmap_tree *mt,
 {
        radeon_mipmap_level *lvl;
 
-       if (face >= mt->faces || level < mt->firstLevel || level > mt->lastLevel)
+       if (face >= mt->faces)
                return GL_FALSE;
 
-       if (texImage->InternalFormat != mt->internal_format ||
-           texImage->IsCompressed != mt->compressed)
+       if (texImage->TexFormat != mt->mesaFormat)
                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 = &mt->levels[level];
+       if (!lvl->valid ||
+           lvl->width != texImage->Width ||
            lvl->height != texImage->Height ||
            lvl->depth != texImage->Depth)
                return GL_FALSE;
@@ -337,59 +312,72 @@ GLboolean radeon_miptree_matches_image(radeon_mipmap_tree *mt,
        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)
+static 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->compressed == compressed &&
-               (!mt->compressed ? (mt->bpp == firstImage->TexFormat->TexelBytes) : 1));
-}
+       unsigned numLevels;
+       radeon_mipmap_level *mtBaseLevel;
+
+       if (texObj->BaseLevel < mt->baseLevel)
+               return GL_FALSE;
 
+       mtBaseLevel = &mt->levels[texObj->BaseLevel - mt->baseLevel];
+       firstImage = texObj->Image[0][texObj->BaseLevel];
+       numLevels = MIN2(texObj->MaxLevel - texObj->BaseLevel + 1, firstImage->MaxLog2 + 1);
+
+       if (RADEON_DEBUG & RADEON_TEXTURE) {
+               fprintf(stderr, "Checking if miptree %p matches texObj %p\n", mt, texObj);
+               fprintf(stderr, "target %d vs %d\n", mt->target, texObj->Target);
+               fprintf(stderr, "format %d vs %d\n", mt->mesaFormat, firstImage->TexFormat);
+               fprintf(stderr, "numLevels %d vs %d\n", mt->numLevels, numLevels);
+               fprintf(stderr, "width0 %d vs %d\n", mtBaseLevel->width, firstImage->Width);
+               fprintf(stderr, "height0 %d vs %d\n", mtBaseLevel->height, firstImage->Height);
+               fprintf(stderr, "depth0 %d vs %d\n", mtBaseLevel->depth, firstImage->Depth);
+               if (mt->target == texObj->Target &&
+               mt->mesaFormat == firstImage->TexFormat &&
+               mt->numLevels >= numLevels &&
+               mtBaseLevel->width == firstImage->Width &&
+               mtBaseLevel->height == firstImage->Height &&
+               mtBaseLevel->depth == firstImage->Depth) {
+                       fprintf(stderr, "MATCHED\n");
+               } else {
+                       fprintf(stderr, "NOT MATCHED\n");
+               }
+       }
+
+       return (mt->target == texObj->Target &&
+               mt->mesaFormat == firstImage->TexFormat &&
+               mt->numLevels >= numLevels &&
+               mtBaseLevel->width == firstImage->Width &&
+               mtBaseLevel->height == firstImage->Height &&
+               mtBaseLevel->depth == firstImage->Depth);
+}
 
 /**
- * Try to allocate a mipmap tree for the given texture that will fit the
- * given image in the given position.
+ * Try to allocate a mipmap tree for the given texture object.
+ * @param[in] rmesa radeon context
+ * @param[in] t radeon texture object
  */
-void radeon_try_alloc_miptree(radeonContextPtr rmesa, radeonTexObj *t,
-               radeon_texture_image *image, GLuint face, GLuint level)
+void radeon_try_alloc_miptree(radeonContextPtr rmesa, radeonTexObj *t)
 {
-       GLuint compressed = image->base.IsCompressed ? image->base.TexFormat->MesaFormat : 0;
-       GLuint numfaces = 1;
-       GLuint firstLevel, lastLevel;
+       struct gl_texture_object *texObj = &t->base;
+       struct gl_texture_image *texImg = texObj->Image[0][texObj->BaseLevel];
+       GLuint numLevels;
 
        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)
+       if (!texImg)
                return;
 
-       t->mt = radeon_miptree_create(rmesa, t, t->base.Target,
-               image->base.InternalFormat,
-               firstLevel, lastLevel,
-               image->base.Width, image->base.Height, image->base.Depth,
-               image->base.TexFormat->TexelBytes, t->tile_bits, compressed);
+       numLevels = MIN2(texObj->MaxLevel - texObj->BaseLevel + 1, texImg->MaxLog2 + 1);
+
+       t->mt = radeon_miptree_create(rmesa, t->base.Target,
+               texImg->TexFormat, texObj->BaseLevel,
+               numLevels, texImg->Width, texImg->Height,
+               texImg->Depth, t->tile_bits);
 }
 
 /* Although we use the image_offset[] array to store relative offsets
@@ -401,21 +389,234 @@ void radeon_try_alloc_miptree(radeonContextPtr rmesa, radeonTexObj *t,
 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;
-     }
+       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;
+       if (mt->target == GL_TEXTURE_CUBE_MAP_ARB)
+               return (mt->levels[level].faces[face].offset);
+       else
+               return mt->levels[level].faces[0].offset;
+}
+
+/**
+ * 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];
+       unsigned char *dest;
+
+       assert(image->mt != mt);
+       assert(dstlvl->valid);
+       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.
+                */
+               assert(mt->mesaFormat == image->base.TexFormat);
+
+               radeon_mipmap_level *srclvl = &image->mt->levels[image->mtlevel];
+
+               /* TODO: bring back these assertions once the FBOs are fixed */
+#if 0
+               assert(image->mtlevel == level);
+               assert(srclvl->size == dstlvl->size);
+               assert(srclvl->rowstride == dstlvl->rowstride);
+#endif
+
+               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 if (image->base.Data) {
+               /* This condition should be removed, it's here to workaround
+                * a segfault when mapping textures during software fallbacks.
+                */
+               const uint32_t srcrowstride = _mesa_format_row_stride(image->base.TexFormat, image->base.Width);
+               uint32_t rows = image->base.Height * image->base.Depth;
+
+               if (_mesa_is_format_compressed(image->base.TexFormat)) {
+                       uint32_t blockWidth, blockHeight;
+                       _mesa_get_format_block_size(image->base.TexFormat, &blockWidth, &blockHeight);
+                       rows = (rows + blockHeight - 1) / blockHeight;
+               }
+
+               copy_rows(dest, dstlvl->rowstride, image->base.Data, srcrowstride,
+                                 rows, srcrowstride);
+
+               _mesa_free_texmemory(image->base.Data);
+               image->base.Data = 0;
+       }
+
+       radeon_bo_unmap(mt->bo);
+
+       radeon_miptree_reference(mt, &image->mt);
+       image->mtface = face;
+       image->mtlevel = level;
+}
+
+/**
+ * Filter matching miptrees, and select one with the most of data.
+ * @param[in] texObj radeon texture object
+ * @param[in] firstLevel first texture level to check
+ * @param[in] lastLevel last texture level to check
+ */
+static radeon_mipmap_tree * get_biggest_matching_miptree(radeonTexObj *texObj,
+                                                                                                                unsigned firstLevel,
+                                                                                                                unsigned lastLevel)
+{
+       const unsigned numLevels = lastLevel - firstLevel + 1;
+       unsigned *mtSizes = calloc(numLevels, sizeof(unsigned));
+       radeon_mipmap_tree **mts = calloc(numLevels, sizeof(radeon_mipmap_tree *));
+       unsigned mtCount = 0;
+       unsigned maxMtIndex = 0;
+       radeon_mipmap_tree *tmp;
+
+       for (unsigned level = firstLevel; level <= lastLevel; ++level) {
+               radeon_texture_image *img = get_radeon_texture_image(texObj->base.Image[0][level]);
+               unsigned found = 0;
+               // TODO: why this hack??
+               if (!img)
+                       break;
+
+               if (!img->mt)
+                       continue;
+
+               for (int i = 0; i < mtCount; ++i) {
+                       if (mts[i] == img->mt) {
+                               found = 1;
+                               mtSizes[i] += img->mt->levels[img->mtlevel].size;
+                               break;
+                       }
+               }
+
+               if (!found && radeon_miptree_matches_texture(img->mt, &texObj->base)) {
+                       mtSizes[mtCount] = img->mt->levels[img->mtlevel].size;
+                       mts[mtCount] = img->mt;
+                       mtCount++;
+               }
+       }
+
+       if (mtCount == 0) {
+               return NULL;
+       }
+
+       for (int i = 1; i < mtCount; ++i) {
+               if (mtSizes[i] > mtSizes[maxMtIndex]) {
+                       maxMtIndex = i;
+               }
+       }
+
+       tmp = mts[maxMtIndex];
+       free(mtSizes);
+       free(mts);
+
+       return tmp;
+}
+
+/**
+ * Validate texture mipmap tree.
+ * If individual images are stored in different mipmap trees
+ * use the mipmap tree that has the most of the correct data.
+ */
+int radeon_validate_texture_miptree(GLcontext * ctx, struct gl_texture_object *texObj)
+{
+       radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+       radeonTexObj *t = radeon_tex_obj(texObj);
+
+       if (t->validated || t->image_override) {
+               return GL_TRUE;
+       }
+
+       if (texObj->Image[0][texObj->BaseLevel]->Border > 0)
+               return GL_FALSE;
+
+       _mesa_test_texobj_completeness(rmesa->glCtx, texObj);
+       if (!texObj->_Complete) {
+               return GL_FALSE;
+       }
+
+       calculate_min_max_lod(&t->base, &t->minLod, &t->maxLod);
+
+       if (RADEON_DEBUG & RADEON_TEXTURE)
+               fprintf(stderr, "%s: Validating texture %p now, minLod = %d, maxLod = %d\n",
+                               __FUNCTION__, texObj ,t->minLod, t->maxLod);
+
+       radeon_mipmap_tree *dst_miptree;
+       dst_miptree = get_biggest_matching_miptree(t, t->minLod, t->maxLod);
+
+       if (!dst_miptree) {
+               radeon_miptree_unreference(&t->mt);
+               radeon_try_alloc_miptree(rmesa, t);
+               dst_miptree = t->mt;
+               if (RADEON_DEBUG & RADEON_TEXTURE) {
+                       fprintf(stderr, "%s: No matching miptree found, allocated new one %p\n", __FUNCTION__, t->mt);
+               }
+       } else if (RADEON_DEBUG & RADEON_TEXTURE) {
+               fprintf(stderr, "%s: Using miptree %p\n", __FUNCTION__, t->mt);
+       }
+
+       const unsigned faces = texObj->Target == GL_TEXTURE_CUBE_MAP ? 6 : 1;
+       unsigned face, level;
+       radeon_texture_image *img;
+       /* Validate only the levels that will actually be used during rendering */
+       for (face = 0; face < faces; ++face) {
+               for (level = t->minLod; level <= t->maxLod; ++level) {
+                       img = get_radeon_texture_image(texObj->Image[face][level]);
+
+                       if (RADEON_DEBUG & RADEON_TEXTURE) {
+                               fprintf(stderr, "Checking image level %d, face %d, mt %p ... ", level, face, img->mt);
+                       }
+                       
+                       if (img->mt != dst_miptree) {
+                               if (RADEON_DEBUG & RADEON_TEXTURE) {
+                                       fprintf(stderr, "MIGRATING\n");
+                               }
+                               struct radeon_bo *src_bo = (img->mt) ? img->mt->bo : img->bo;
+                               if (src_bo && radeon_bo_is_referenced_by_cs(src_bo, rmesa->cmdbuf.cs)) {
+                                       radeon_firevertices(rmesa);
+                               }
+                               migrate_image_to_miptree(dst_miptree, img, face, level);
+                       } else if (RADEON_DEBUG & RADEON_TEXTURE) {
+                               fprintf(stderr, "OK\n");
+                       }
+               }
+       }
+
+       t->validated = GL_TRUE;
+
+       return GL_TRUE;
 }
+
+uint32_t get_base_teximage_offset(radeonTexObj *texObj)
+{
+       if (!texObj->mt) {
+               return 0;
+       } else {
+               return radeon_miptree_image_offset(texObj->mt, 0, texObj->minLod);
+       }
+}
\ No newline at end of file
index db28252da374045d9574811b40c1ea4c03b8cd64..a10649b5aeac8ee961d48b04c39f84bb62a44417 100644 (file)
@@ -44,6 +44,7 @@ struct _radeon_mipmap_level {
        GLuint depth;
        GLuint size; /** Size of each image, in bytes */
        GLuint rowstride; /** in bytes */
+       GLuint valid;
        radeon_mipmap_image faces[6];
 };
 
@@ -59,43 +60,35 @@ struct _radeon_mipmap_level {
  * 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 */
-       GLenum internal_format;
+       GLenum mesaFormat; /** MESA_FORMAT_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 baseLevel; /** gl_texture_object->baseLevel it was created for */
+       GLuint numLevels; /** Number of mip levels stored in this mipmap tree */
 
-       GLuint width0; /** Width of firstLevel image */
-       GLuint height0; /** Height of firstLevel image */
-       GLuint depth0; /** Depth of firstLevel image */
+       GLuint width0; /** Width of baseLevel image */
+       GLuint height0; /** Height of baseLevel image */
+       GLuint depth0; /** Depth of baseLevel 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, GLenum internal_format, 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);
+void radeon_miptree_reference(radeon_mipmap_tree *mt, radeon_mipmap_tree **ptr);
+void radeon_miptree_unreference(radeon_mipmap_tree **ptr);
 
 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,
-                             radeon_texture_image *texImage, GLuint face, GLuint level);
+void radeon_try_alloc_miptree(radeonContextPtr rmesa, radeonTexObj *t);
 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);
+
+uint32_t get_base_teximage_offset(radeonTexObj *texObj);
 #endif /* __RADEON_MIPMAP_TREE_H_ */
index b79d864ba2994a56d6c5335a22c4b124ea8ac3d1..98117cdfc14ee7dedeaea4eb3f8acaf4d4d767b6 100644 (file)
 #include "main/imports.h"
 #include "main/simple_list.h"
 
-static int radeonQueryIsFlushed(GLcontext *ctx, struct gl_query_object *q)
-{
-       radeonContextPtr radeon = RADEON_CONTEXT(ctx);
-       struct radeon_query_object *tmp, *query = (struct radeon_query_object *)q;
-
-       foreach(tmp, &radeon->query.not_flushed_head) {
-               if (tmp == query) {
-                       return 0;
-               }
-       }
-
-       return 1;
-}
-
 static void radeonQueryGetResult(GLcontext *ctx, struct gl_query_object *q)
 {
+       radeonContextPtr radeon = RADEON_CONTEXT(ctx);
        struct radeon_query_object *query = (struct radeon_query_object *)q;
-       uint32_t *result;
+        uint32_t *result;
        int i;
 
        radeon_print(RADEON_STATE, RADEON_VERBOSE,
@@ -56,13 +43,35 @@ static void radeonQueryGetResult(GLcontext *ctx, struct gl_query_object *q)
                        __FUNCTION__, query->Base.Id, (int) query->Base.Result);
 
        radeon_bo_map(query->bo, GL_FALSE);
-
-       result = query->bo->ptr;
+        result = query->bo->ptr;
 
        query->Base.Result = 0;
-       for (i = 0; i < query->curr_offset/sizeof(uint32_t); ++i) {
-               query->Base.Result += result[i];
-               radeon_print(RADEON_STATE, RADEON_TRACE, "result[%d] = %d\n", i, result[i]);
+       if (IS_R600_CLASS(radeon->radeonScreen)) {
+               /* ZPASS EVENT writes alternating qwords
+                * At query start we set the start offset to 0 and
+                * hw writes zpass start counts to qwords 0, 2, 4, 6.
+                * At query end we set the start offset to 8 and
+                * hw writes zpass end counts to qwords 1, 3, 5, 7.
+                * then we substract. MSB is the valid bit.
+                */
+               for (i = 0; i < 16; i += 4) {
+                       uint64_t start = (uint64_t)LE32_TO_CPU(result[i]) |
+                                        (uint64_t)LE32_TO_CPU(result[i + 1]) << 32;
+                       uint64_t end = (uint64_t)LE32_TO_CPU(result[i + 2]) |
+                                      (uint64_t)LE32_TO_CPU(result[i + 3]) << 32;
+                       if ((start & 0x8000000000000000) && (end & 0x8000000000000000)) {
+                               uint64_t query_count = end - start;
+                               query->Base.Result += query_count;
+
+                       }
+                       radeon_print(RADEON_STATE, RADEON_TRACE,
+                                    "%d start: %lx, end: %lx %ld\n", i, start, end, end - start);
+               }
+       } else {
+               for (i = 0; i < query->curr_offset/sizeof(uint32_t); ++i) {
+                       query->Base.Result += LE32_TO_CPU(result[i]);
+                       radeon_print(RADEON_STATE, RADEON_TRACE, "result[%d] = %d\n", i, LE32_TO_CPU(result[i]));
+               }
        }
 
        radeon_bo_unmap(query->bo);
@@ -99,10 +108,11 @@ static void radeonDeleteQuery(GLcontext *ctx, struct gl_query_object *q)
 
 static void radeonWaitQuery(GLcontext *ctx, struct gl_query_object *q)
 {
+       radeonContextPtr radeon = RADEON_CONTEXT(ctx);
        struct radeon_query_object *query = (struct radeon_query_object *)q;
 
        /* If the cmdbuf with packets for this query hasn't been flushed yet, do it now */
-       if (!radeonQueryIsFlushed(ctx, q))
+       if (radeon_bo_is_referenced_by_cs(query->bo, radeon->cmdbuf.cs))
                ctx->Driver.Flush(ctx);
 
        radeon_print(RADEON_STATE, RADEON_VERBOSE, "%s: query id %d, bo %p, offset %d\n", __FUNCTION__, q->Id, query->bo, query->curr_offset);
@@ -134,8 +144,6 @@ static void radeonBeginQuery(GLcontext *ctx, struct gl_query_object *q)
 
        radeon->query.queryobj.dirty = GL_TRUE;
        radeon->hw.is_dirty = GL_TRUE;
-       insert_at_tail(&radeon->query.not_flushed_head, query);
-
 }
 
 void radeonEmitQueryEnd(GLcontext *ctx)
@@ -183,7 +191,7 @@ static void radeonCheckQuery(GLcontext *ctx, struct gl_query_object *q)
                uint32_t domain;
 
                /* Need to perform a flush, as per ARB_occlusion_query spec */
-               if (!radeonQueryIsFlushed(ctx, q)) {
+               if (radeon_bo_is_referenced_by_cs(query->bo, radeon->cmdbuf.cs)) {
                        ctx->Driver.Flush(ctx);
                }
 
index 573eb6c9c1870562b580f3c248e0b6c414dc7e5a..3080a0fcd0e75fc372a7b3bc1920712ca9af2536 100644 (file)
@@ -141,12 +141,6 @@ DRI_CONF_BEGIN
 DRI_CONF_END;
 static const GLuint __driNConfigOptions = 17;
 
-extern const struct dri_extension blend_extensions[];
-extern const struct dri_extension ARB_vp_extension[];
-extern const struct dri_extension NV_vp_extension[];
-extern const struct dri_extension ATI_fs_extension[];
-extern const struct dri_extension point_extensions[];
-
 #elif defined(RADEON_R300) || defined(RADEON_R600)
 
 #define DRI_CONF_FP_OPTIMIZATION_SPEED   0
@@ -218,17 +212,12 @@ DRI_CONF_BEGIN
 DRI_CONF_END;
 static const GLuint __driNConfigOptions = 17;
 
-extern const struct dri_extension gl_20_extension[];
-
 #endif
 
-extern const struct dri_extension card_extensions[];
-extern const struct dri_extension mm_extensions[];
-
-static int getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo );
+static int getSwapInfo( __DRIdrawable *dPriv, __DRIswapInfo * sInfo );
 
 static int
-radeonGetParam(__DRIscreenPrivate *sPriv, int param, void *value)
+radeonGetParam(__DRIscreen *sPriv, int param, void *value)
 {
   int ret;
   drm_radeon_getparam_t gp = { 0 };
@@ -260,7 +249,7 @@ radeonGetParam(__DRIscreenPrivate *sPriv, int param, void *value)
 }
 
 static const __DRIconfig **
-radeonFillInModes( __DRIscreenPrivate *psp,
+radeonFillInModes( __DRIscreen *psp,
                   unsigned pixel_bits, unsigned depth_bits,
                   unsigned stencil_bits, GLboolean have_back_buffer )
 {
@@ -401,12 +390,14 @@ static int radeon_set_screen_flags(radeonScreenPtr screen, int device_id)
    screen->device_id = device_id;
    screen->chip_flags = 0;
    switch ( device_id ) {
+   case PCI_CHIP_RN50_515E:
+   case PCI_CHIP_RN50_5969:
+       return -1;
+
    case PCI_CHIP_RADEON_LY:
    case PCI_CHIP_RADEON_LZ:
    case PCI_CHIP_RADEON_QY:
    case PCI_CHIP_RADEON_QZ:
-   case PCI_CHIP_RN50_515E:
-   case PCI_CHIP_RN50_5969:
       screen->chip_family = CHIP_FAMILY_RV100;
       break;
 
@@ -920,7 +911,7 @@ static int radeon_set_screen_flags(radeonScreenPtr screen, int device_id)
 /* Create the device specific screen private data struct.
  */
 static radeonScreenPtr
-radeonCreateScreen( __DRIscreenPrivate *sPriv )
+radeonCreateScreen( __DRIscreen *sPriv )
 {
    radeonScreenPtr screen;
    RADEONDRIPtr dri_priv = (RADEONDRIPtr)sPriv->pDevPriv;
@@ -1259,7 +1250,7 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv )
 }
 
 static radeonScreenPtr
-radeonCreateScreen2(__DRIscreenPrivate *sPriv)
+radeonCreateScreen2(__DRIscreen *sPriv)
 {
    radeonScreenPtr screen;
    int i;
@@ -1410,7 +1401,7 @@ radeonCreateScreen2(__DRIscreenPrivate *sPriv)
 /* Destroy the device specific screen private data struct.
  */
 static void
-radeonDestroyScreen( __DRIscreenPrivate *sPriv )
+radeonDestroyScreen( __DRIscreen *sPriv )
 {
     radeonScreenPtr screen = (radeonScreenPtr)sPriv->private;
 
@@ -1444,7 +1435,7 @@ radeonDestroyScreen( __DRIscreenPrivate *sPriv )
 /* Initialize the driver specific screen private data.
  */
 static GLboolean
-radeonInitDriver( __DRIscreenPrivate *sPriv )
+radeonInitDriver( __DRIscreen *sPriv )
 {
     if (sPriv->dri2.enabled) {
         sPriv->private = (void *) radeonCreateScreen2( sPriv );
@@ -1468,8 +1459,8 @@ radeonInitDriver( __DRIscreenPrivate *sPriv )
  * pbuffers.
  */
 static GLboolean
-radeonCreateBuffer( __DRIscreenPrivate *driScrnPriv,
-                    __DRIdrawablePrivate *driDrawPriv,
+radeonCreateBuffer( __DRIscreen *driScrnPriv,
+                    __DRIdrawable *driDrawPriv,
                     const __GLcontextModes *mesaVis,
                     GLboolean isPixmap )
 {
@@ -1480,7 +1471,7 @@ radeonCreateBuffer( __DRIscreenPrivate *driScrnPriv,
     const GLboolean swAccum = mesaVis->accumRedBits > 0;
     const GLboolean swStencil = mesaVis->stencilBits > 0 &&
        mesaVis->depthBits != 24;
-    GLenum rgbFormat;
+    gl_format rgbFormat;
     struct radeon_framebuffer *rfb;
 
     if (isPixmap)
@@ -1493,11 +1484,11 @@ radeonCreateBuffer( __DRIscreenPrivate *driScrnPriv,
     _mesa_initialize_framebuffer(&rfb->base, mesaVis);
 
     if (mesaVis->redBits == 5)
-        rgbFormat = GL_RGB5;
+        rgbFormat = _mesa_little_endian() ? MESA_FORMAT_RGB565 : MESA_FORMAT_RGB565_REV;
     else if (mesaVis->alphaBits == 0)
-        rgbFormat = GL_RGB8;
+        rgbFormat = _mesa_little_endian() ? MESA_FORMAT_XRGB8888 : MESA_FORMAT_XRGB8888_REV;
     else
-        rgbFormat = GL_RGBA8;
+        rgbFormat = _mesa_little_endian() ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB8888_REV;
 
     /* front color renderbuffer */
     rfb->color_rb[0] = radeon_create_renderbuffer(rgbFormat, driDrawPriv);
@@ -1513,19 +1504,22 @@ radeonCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
     if (mesaVis->depthBits == 24) {
       if (mesaVis->stencilBits == 8) {
-       struct radeon_renderbuffer *depthStencilRb = radeon_create_renderbuffer(GL_DEPTH24_STENCIL8_EXT, driDrawPriv);
+       struct radeon_renderbuffer *depthStencilRb =
+           radeon_create_renderbuffer(MESA_FORMAT_S8_Z24, 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);
+       struct radeon_renderbuffer *depth =
+           radeon_create_renderbuffer(MESA_FORMAT_X8_Z24, 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);
+        /* just 16-bit depth buffer, no hw stencil */
+       struct radeon_renderbuffer *depth =
+           radeon_create_renderbuffer(MESA_FORMAT_Z16, driDrawPriv);
        _mesa_add_renderbuffer(&rfb->base, BUFFER_DEPTH, &depth->base);
        depth->has_surface = screen->depthHasSurface;
     }
@@ -1565,7 +1559,7 @@ static void radeon_cleanup_renderbuffers(struct radeon_framebuffer *rfb)
 }
 
 void
-radeonDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+radeonDestroyBuffer(__DRIdrawable *driDrawPriv)
 {
     struct radeon_framebuffer *rfb;
     if (!driDrawPriv)
@@ -1587,7 +1581,7 @@ radeonDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
  * \return the __GLcontextModes supported by this driver
  */
 static const __DRIconfig **
-radeonInitScreen(__DRIscreenPrivate *psp)
+radeonInitScreen(__DRIscreen *psp)
 {
 #if defined(RADEON_R100)
    static const char *driver_name = "Radeon";
@@ -1619,27 +1613,6 @@ radeonInitScreen(__DRIscreenPrivate *psp)
       return NULL;
    }
 
-   /* Calling driInitExtensions here, with a NULL context pointer,
-    * does not actually enable the extensions.  It just makes sure
-    * that all the dispatch offsets for all the extensions that
-    * *might* be enables are known.  This is needed because the
-    * dispatch offsets need to be known when _mesa_context_create
-    * is called, but we can't enable the extensions until we have a
-    * context pointer.
-    *
-    * Hello chicken.  Hello egg.  How are you two today?
-    */
-   driInitExtensions( NULL, card_extensions, GL_FALSE );
-#if defined(RADEON_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 );
-#elif (defined(RADEON_R300) || defined(RADEON_R600))
-   driInitSingleExtension( NULL, gl_20_extension );
-#endif
-
    if (!radeonInitDriver(psp))
        return NULL;
 
@@ -1658,7 +1631,7 @@ radeonInitScreen(__DRIscreenPrivate *psp)
  * \return the __GLcontextModes supported by this driver
  */
 static const
-__DRIconfig **radeonInitScreen2(__DRIscreenPrivate *psp)
+__DRIconfig **radeonInitScreen2(__DRIscreen *psp)
 {
    GLenum fb_format[3];
    GLenum fb_type[3];
@@ -1672,28 +1645,6 @@ __DRIconfig **radeonInitScreen2(__DRIscreenPrivate *psp)
    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 defined(RADEON_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 );
-#elif (defined(RADEON_R300) || defined(RADEON_R600))
-   driInitSingleExtension( NULL, gl_20_extension );
-#endif
-
    if (!radeonInitDriver(psp)) {
        return NULL;
     }
@@ -1747,7 +1698,7 @@ __DRIconfig **radeonInitScreen2(__DRIscreenPrivate *psp)
  * Get information about previous buffer swaps.
  */
 static int
-getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo )
+getSwapInfo( __DRIdrawable *dPriv, __DRIswapInfo * sInfo )
 {
     struct radeon_framebuffer *rfb;
 
@@ -1800,3 +1751,10 @@ const struct __DriverAPIRec driDriverAPI = {
    .InitScreen2     = radeonInitScreen2,
 };
 
+/* This is the table of extensions that the loader will dlsym() for. */
+PUBLIC const __DRIextension *__driDriverExtensions[] = {
+    &driCoreExtension.base,
+    &driLegacyExtension.base,
+    &driDRI2Extension.base,
+    NULL
+};
index 15744e88284b52fdf4c48181316bc6bb81f8de96..5e6d432e11dbb16e7df222e0099ce26d0c32c3bc 100644 (file)
@@ -86,7 +86,7 @@ typedef struct radeon_screen {
 
    __volatile__ uint32_t *scratch;
 
-   __DRIscreenPrivate *driScreen;
+   __DRIscreen *driScreen;
    unsigned int sarea_priv_offset;
    unsigned int gart_buffer_offset;    /* offset in card memory space */
    unsigned int gart_texture_offset;   /* offset in card memory space */
@@ -123,5 +123,5 @@ typedef struct radeon_screen {
 #define IS_R600_CLASS(screen) \
        ((screen->chip_flags & RADEON_CLASS_MASK) == RADEON_CLASS_R600)
 
-extern void radeonDestroyBuffer(__DRIdrawablePrivate *driDrawPriv);
+extern void radeonDestroyBuffer(__DRIdrawable *driDrawPriv);
 #endif /* __RADEON_SCREEN_H__ */
index 0c49c3713af2ee201272cb93b6aec6fd2459f010..8db3d2b143b51531acb383da9c9dd4011e8cf5a3 100644 (file)
@@ -41,6 +41,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
 #include "main/glheader.h"
+#include "main/texformat.h"
 #include "swrast/swrast.h"
 
 #include "radeon_common.h"
@@ -334,22 +335,6 @@ static GLubyte *radeon_ptr_2byte_8x2(const struct radeon_renderbuffer * rrb,
 
 #endif
 
-#ifndef RADEON_R300
-#ifndef RADEON_R600
-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
-#endif
-
 /*
  * Note that all information needed to access pixels in a renderbuffer
  * should be obtained through the gl_renderbuffer parameter, not per-context
@@ -416,6 +401,18 @@ s8z24_to_z24s8(uint32_t val)
 #endif
 #include "spantmp2.h"
 
+#define SPANTMP_PIXEL_FMT GL_RGB
+#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5_REV
+
+#define TAG(x)    radeon##x##_RGB565_REV
+#define TAG2(x,y) radeon##x##_RGB565_REV##y
+#if defined(RADEON_R600)
+#define GET_PTR(X,Y) r600_ptr_color(rrb, (X) + x_off, (Y) + y_off)
+#else
+#define GET_PTR(X,Y) radeon_ptr_2byte_8x2(rrb, (X) + x_off, (Y) + y_off)
+#endif
+#include "spantmp2.h"
+
 /* 16 bit, ARGB1555 color spanline and pixel functions
  */
 #define SPANTMP_PIXEL_FMT GL_BGRA
@@ -430,6 +427,18 @@ s8z24_to_z24s8(uint32_t val)
 #endif
 #include "spantmp2.h"
 
+#define SPANTMP_PIXEL_FMT GL_BGRA
+#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_1_5_5_5
+
+#define TAG(x)    radeon##x##_ARGB1555_REV
+#define TAG2(x,y) radeon##x##_ARGB1555_REV##y
+#if defined(RADEON_R600)
+#define GET_PTR(X,Y) r600_ptr_color(rrb, (X) + x_off, (Y) + y_off)
+#else
+#define GET_PTR(X,Y) radeon_ptr_2byte_8x2(rrb, (X) + x_off, (Y) + y_off)
+#endif
+#include "spantmp2.h"
+
 /* 16 bit, RGBA4 color spanline and pixel functions
  */
 #define SPANTMP_PIXEL_FMT GL_BGRA
@@ -444,6 +453,18 @@ s8z24_to_z24s8(uint32_t val)
 #endif
 #include "spantmp2.h"
 
+#define SPANTMP_PIXEL_FMT GL_BGRA
+#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_4_4_4_4
+
+#define TAG(x)    radeon##x##_ARGB4444_REV
+#define TAG2(x,y) radeon##x##_ARGB4444_REV##y
+#if defined(RADEON_R600)
+#define GET_PTR(X,Y) r600_ptr_color(rrb, (X) + x_off, (Y) + y_off)
+#else
+#define GET_PTR(X,Y) radeon_ptr_2byte_8x2(rrb, (X) + x_off, (Y) + y_off)
+#endif
+#include "spantmp2.h"
+
 /* 32 bit, xRGB8888 color spanline and pixel functions
  */
 #define SPANTMP_PIXEL_FMT GL_BGRA
@@ -488,6 +509,42 @@ s8z24_to_z24s8(uint32_t val)
 #endif
 #include "spantmp2.h"
 
+/* 32 bit, BGRx8888 color spanline and pixel functions
+ */
+#define SPANTMP_PIXEL_FMT GL_BGRA
+#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8
+
+#define TAG(x)    radeon##x##_BGRx8888
+#define TAG2(x,y) radeon##x##_BGRx8888##y
+#if defined(RADEON_R600)
+#define GET_VALUE(_x, _y) ((*(GLuint*)(r600_ptr_color(rrb, _x + x_off, _y + y_off)) | 0x000000ff))
+#define PUT_VALUE(_x, _y, d) { \
+   GLuint *_ptr = (GLuint*)r600_ptr_color( rrb, _x + x_off, _y + y_off );              \
+   *_ptr = d;                                                          \
+} while (0)
+#else
+#define GET_VALUE(_x, _y) ((*(GLuint*)(radeon_ptr_4byte(rrb, _x + x_off, _y + y_off)) | 0x000000ff))
+#define PUT_VALUE(_x, _y, d) { \
+   GLuint *_ptr = (GLuint*)radeon_ptr_4byte( rrb, _x + x_off, _y + y_off );            \
+   *_ptr = d;                                                          \
+} while (0)
+#endif
+#include "spantmp2.h"
+
+/* 32 bit, BGRA8888 color spanline and pixel functions
+ */
+#define SPANTMP_PIXEL_FMT GL_BGRA
+#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8
+
+#define TAG(x)    radeon##x##_BGRA8888
+#define TAG2(x,y) radeon##x##_BGRA8888##y
+#if defined(RADEON_R600)
+#define GET_PTR(X,Y) r600_ptr_color(rrb, (X) + x_off, (Y) + y_off)
+#else
+#define GET_PTR(X,Y) radeon_ptr_4byte(rrb, (X) + x_off, (Y) + y_off)
+#endif
+#include "spantmp2.h"
+
 /* ================================================================
  * Depth buffer
  */
@@ -542,10 +599,10 @@ s8z24_to_z24s8(uint32_t val)
 #define WRITE_DEPTH( _x, _y, d )                                       \
 do {                                                                   \
    GLuint *_ptr = (GLuint*)radeon_ptr_4byte( rrb, _x + x_off, _y + y_off );            \
-   GLuint tmp = *_ptr;                         \
+   GLuint tmp = LE32_TO_CPU(*_ptr);                                     \
    tmp &= 0x000000ff;                                                  \
    tmp |= ((d << 8) & 0xffffff00);                                     \
-   *_ptr = tmp;                                        \
+   *_ptr = CPU_TO_LE32(tmp);                                            \
 } while (0)
 #elif defined(RADEON_R600)
 #define WRITE_DEPTH( _x, _y, d )                                       \
@@ -560,26 +617,26 @@ do {                                                                      \
 #define WRITE_DEPTH( _x, _y, d )                                       \
 do {                                                                   \
    GLuint *_ptr = (GLuint*)r200_depth_4byte( rrb, _x + x_off, _y + y_off );            \
-   GLuint tmp = *_ptr;                         \
+   GLuint tmp = LE32_TO_CPU(*_ptr);                                     \
    tmp &= 0xff000000;                                                  \
    tmp |= ((d) & 0x00ffffff);                                          \
-   *_ptr = tmp;                                        \
+   *_ptr = CPU_TO_LE32(tmp);                                            \
 } while (0)
 #else
 #define WRITE_DEPTH( _x, _y, d )                                       \
 do {                                                                   \
    GLuint *_ptr = (GLuint*)radeon_ptr_4byte( rrb, _x + x_off, _y + y_off );    \
-   GLuint tmp = *_ptr;                                                 \
+   GLuint tmp = LE32_TO_CPU(*_ptr);                                     \
    tmp &= 0xff000000;                                                  \
    tmp |= ((d) & 0x00ffffff);                                          \
-   *_ptr = tmp;                                        \
+   *_ptr = CPU_TO_LE32(tmp);                                            \
 } while (0)
 #endif
 
 #if defined(RADEON_R300)
 #define READ_DEPTH( d, _x, _y )                                                \
   do {                                                                 \
-    d = (*(GLuint*)(radeon_ptr_4byte(rrb, _x + x_off, _y + y_off)) & 0xffffff00) >> 8; \
+    d = (LE32_TO_CPU(*(GLuint*)(radeon_ptr_4byte(rrb, _x + x_off, _y + y_off))) & 0xffffff00) >> 8; \
   }while(0)
 #elif defined(RADEON_R600)
 #define READ_DEPTH( d, _x, _y )                                                \
@@ -589,11 +646,11 @@ do {                                                                      \
 #elif defined(RADEON_R200)
 #define READ_DEPTH( d, _x, _y )                                                \
   do {                                                                 \
-    d = *(GLuint*)(r200_depth_4byte(rrb, _x + x_off, _y + y_off)) & 0x00ffffff; \
+    d = LE32_TO_CPU(*(GLuint*)(r200_depth_4byte(rrb, _x + x_off, _y + y_off))) & 0x00ffffff; \
   }while(0)
 #else
 #define READ_DEPTH( d, _x, _y )        \
-  d = *(GLuint*)(radeon_ptr_4byte(rrb, _x + x_off,     _y + y_off)) & 0x00ffffff;
+  d = LE32_TO_CPU(*(GLuint*)(radeon_ptr_4byte(rrb, _x + x_off, _y + y_off))) & 0x00ffffff;
 #endif
 
 #define TAG(x) radeon##x##_z24
@@ -611,7 +668,7 @@ do {                                                                        \
 #define WRITE_DEPTH( _x, _y, d )                                       \
 do {                                                                   \
    GLuint *_ptr = (GLuint*)radeon_ptr_4byte( rrb, _x + x_off, _y + y_off );            \
-   *_ptr = d;                                                          \
+   *_ptr = CPU_TO_LE32((((d) & 0xff000000) >> 24) | (((d) & 0x00ffffff) << 8));   \
 } while (0)
 #elif defined(RADEON_R600)
 #define WRITE_DEPTH( _x, _y, d )                                       \
@@ -619,53 +676,52 @@ do {                                                                      \
    GLuint *_ptr = (GLuint*)r600_ptr_depth( rrb, _x + x_off, _y + y_off );              \
    GLuint tmp = *_ptr;                         \
    tmp &= 0xff000000;                                                  \
-   tmp |= (((d) >> 8) & 0x00ffffff);                                   \
+   tmp |= ((d) & 0x00ffffff);                                  \
    *_ptr = tmp;                                        \
    _ptr = (GLuint*)r600_ptr_stencil(rrb, _x + x_off, _y + y_off);              \
    tmp = *_ptr;                                \
    tmp &= 0xffffff00;                                                  \
-   tmp |= (d) & 0xff;                                                  \
+   tmp |= ((d) >> 24) & 0xff;                                          \
    *_ptr = tmp;                                        \
 } while (0)
 #elif defined(RADEON_R200)
 #define WRITE_DEPTH( _x, _y, d )                                       \
 do {                                                                   \
    GLuint *_ptr = (GLuint*)r200_depth_4byte( rrb, _x + x_off, _y + y_off );            \
-   GLuint tmp = z24s8_to_s8z24(d);                                     \
-   *_ptr = tmp;                                                                \
+   *_ptr = CPU_TO_LE32(d);                                             \
 } while (0)
 #else
 #define WRITE_DEPTH( _x, _y, d )                                       \
 do {                                                                   \
    GLuint *_ptr = (GLuint*)radeon_ptr_4byte( rrb, _x + x_off, _y + y_off );    \
-   GLuint tmp = z24s8_to_s8z24(d);                                     \
-   *_ptr = tmp;                                        \
+   *_ptr = CPU_TO_LE32(d);                                             \
 } while (0)
 #endif
 
 #if defined(RADEON_R300)
 #define READ_DEPTH( d, _x, _y )                                                \
   do { \
-    d = (*(GLuint*)(radeon_ptr_4byte(rrb, _x + x_off, _y + y_off)));   \
+    GLuint tmp = (*(GLuint*)(radeon_ptr_4byte(rrb, _x + x_off, _y + y_off)));  \
+    d = LE32_TO_CPU(((tmp & 0x000000ff) << 24) | ((tmp & 0xffffff00) >> 8));   \
   }while(0)
 #elif defined(RADEON_R600)
 #define READ_DEPTH( d, _x, _y )                                                \
   do { \
-    d = ((*(GLuint*)(r600_ptr_depth(rrb, _x + x_off, _y + y_off))) << 8) & 0xffffff00; \
-    d |= (*(GLuint*)(r600_ptr_stencil(rrb, _x + x_off, _y + y_off))) & 0x000000ff;     \
+    d = (*(GLuint*)(r600_ptr_depth(rrb, _x + x_off, _y + y_off))) & 0x00ffffff; \
+    d |= ((*(GLuint*)(r600_ptr_stencil(rrb, _x + x_off, _y + y_off))) << 24) & 0xff000000; \
   }while(0)
 #elif defined(RADEON_R200)
 #define READ_DEPTH( d, _x, _y )                                                \
   do { \
-    d = s8z24_to_z24s8(*(GLuint*)(r200_depth_4byte(rrb, _x + x_off, _y + y_off)));     \
+    d = LE32_TO_CPU(*(GLuint*)(r200_depth_4byte(rrb, _x + x_off, _y + y_off))); \
   }while(0)
 #else
 #define READ_DEPTH( d, _x, _y )        do {                                    \
-    d = s8z24_to_z24s8(*(GLuint*)(radeon_ptr_4byte(rrb, _x + x_off,    _y + y_off ))); \
+    d = LE32_TO_CPU(*(GLuint*)(radeon_ptr_4byte(rrb, _x + x_off, _y + y_off))); \
   } while (0)
 #endif
 
-#define TAG(x) radeon##x##_z24_s8
+#define TAG(x) radeon##x##_s8_z24
 #include "depthtmp.h"
 
 /* ================================================================
@@ -678,10 +734,10 @@ do {                                                                      \
 #define WRITE_STENCIL( _x, _y, d )                                     \
 do {                                                                   \
    GLuint *_ptr = (GLuint*)radeon_ptr_4byte(rrb, _x + x_off, _y + y_off);              \
-   GLuint tmp = *_ptr;                         \
+   GLuint tmp = LE32_TO_CPU(*_ptr);                                     \
    tmp &= 0xffffff00;                                                  \
    tmp |= (d) & 0xff;                                                  \
-   *_ptr = tmp;                                        \
+   *_ptr = CPU_TO_LE32(tmp);                                            \
 } while (0)
 #elif defined(RADEON_R600)
 #define WRITE_STENCIL( _x, _y, d )                                     \
@@ -696,19 +752,19 @@ do {                                                                      \
 #define WRITE_STENCIL( _x, _y, d )                                     \
 do {                                                                   \
    GLuint *_ptr = (GLuint*)r200_depth_4byte(rrb, _x + x_off, _y + y_off);              \
-   GLuint tmp = *_ptr;                         \
+   GLuint tmp = LE32_TO_CPU(*_ptr);                                     \
    tmp &= 0x00ffffff;                                                  \
    tmp |= (((d) & 0xff) << 24);                                                \
-   *_ptr = tmp;                                        \
+   *_ptr = CPU_TO_LE32(tmp);                                            \
 } while (0)
 #else
 #define WRITE_STENCIL( _x, _y, d )                                     \
 do {                                                                   \
    GLuint *_ptr = (GLuint*)radeon_ptr_4byte(rrb, _x + x_off, _y + y_off);              \
-   GLuint tmp = *_ptr;                         \
+   GLuint tmp = LE32_TO_CPU(*_ptr);                                     \
    tmp &= 0x00ffffff;                                                  \
    tmp |= (((d) & 0xff) << 24);                                                \
-   *_ptr = tmp;                                        \
+   *_ptr = CPU_TO_LE32(tmp);                                            \
 } while (0)
 #endif
 
@@ -716,7 +772,7 @@ do {                                                                        \
 #define READ_STENCIL( d, _x, _y )                                      \
 do {                                                                   \
    GLuint *_ptr = (GLuint*)radeon_ptr_4byte( rrb, _x + x_off, _y + y_off );            \
-   GLuint tmp = *_ptr;                         \
+   GLuint tmp = LE32_TO_CPU(*_ptr);                                     \
    d = tmp & 0x000000ff;                                               \
 } while (0)
 #elif defined(RADEON_R600)
@@ -730,19 +786,19 @@ do {                                                                      \
 #define READ_STENCIL( d, _x, _y )                                      \
 do {                                                                   \
    GLuint *_ptr = (GLuint*)r200_depth_4byte( rrb, _x + x_off, _y + y_off );            \
-   GLuint tmp = *_ptr;                         \
+   GLuint tmp = LE32_TO_CPU(*_ptr);                                     \
    d = (tmp & 0xff000000) >> 24;                                       \
 } while (0)
 #else
 #define READ_STENCIL( d, _x, _y )                                      \
 do {                                                                   \
    GLuint *_ptr = (GLuint*)radeon_ptr_4byte( rrb, _x + x_off, _y + y_off );            \
-   GLuint tmp = *_ptr;                         \
+   GLuint tmp = LE32_TO_CPU(*_ptr);                                     \
    d = (tmp & 0xff000000) >> 24;                                       \
 } while (0)
 #endif
 
-#define TAG(x) radeon##x##_z24_s8
+#define TAG(x) radeon##x##_s8_z24
 #include "stenciltmp.h"
 
 
@@ -755,8 +811,7 @@ static void map_unmap_rb(struct gl_renderbuffer *rb, int flag)
                return;
 
        if (flag) {
-               if (rrb->bo->bom->funcs->bo_wait)
-                       radeon_bo_wait(rrb->bo);
+               radeon_bo_wait(rrb->bo);
                r = radeon_bo_map(rrb->bo, 1);
                if (r) {
                        fprintf(stderr, "(%s) error(%d) mapping buffer.\n",
@@ -772,18 +827,21 @@ static void map_unmap_rb(struct gl_renderbuffer *rb, int flag)
 }
 
 static void
-radeon_map_unmap_buffers(GLcontext *ctx, GLboolean map)
+radeon_map_unmap_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb,
+                            GLboolean map)
 {
        GLuint i, j;
 
        /* color draw buffers */
        for (j = 0; j < ctx->DrawBuffer->_NumColorDrawBuffers; j++)
-               map_unmap_rb(ctx->DrawBuffer->_ColorDrawBuffers[j], map);
+               map_unmap_rb(fb->_ColorDrawBuffers[j], map);
+
+       map_unmap_rb(fb->_ColorReadBuffer, map);
 
        /* check for render to textures */
        for (i = 0; i < BUFFER_COUNT; i++) {
                struct gl_renderbuffer_attachment *att =
-                       ctx->DrawBuffer->Attachment + i;
+                       fb->Attachment + i;
                struct gl_texture_object *tex = att->Texture;
                if (tex) {
                        /* Render to texture. Note that a mipmapped texture need not
@@ -799,15 +857,15 @@ radeon_map_unmap_buffers(GLcontext *ctx, GLboolean map)
                                radeon_teximage_unmap(image);
                }
        }
-
-       map_unmap_rb(ctx->ReadBuffer->_ColorReadBuffer, map);
-
+       
        /* depth buffer (Note wrapper!) */
-       if (ctx->DrawBuffer->_DepthBuffer)
-               map_unmap_rb(ctx->DrawBuffer->_DepthBuffer->Wrapped, map);
+       if (fb->_DepthBuffer)
+               map_unmap_rb(fb->_DepthBuffer->Wrapped, map);
+
+       if (fb->_StencilBuffer)
+               map_unmap_rb(fb->_StencilBuffer->Wrapped, map);
 
-       if (ctx->DrawBuffer->_StencilBuffer)
-               map_unmap_rb(ctx->DrawBuffer->_StencilBuffer->Wrapped, map);
+       radeon_check_front_buffer_rendering(ctx);
 }
 
 static void radeonSpanRenderStart(GLcontext * ctx)
@@ -832,23 +890,30 @@ static void radeonSpanRenderStart(GLcontext * ctx)
                        ctx->Driver.MapTexture(ctx, ctx->Texture.Unit[i]._Current);
        }
 
-       radeon_map_unmap_buffers(ctx, 1);
+       radeon_map_unmap_framebuffer(ctx, ctx->DrawBuffer, GL_TRUE);
+       if (ctx->ReadBuffer != ctx->DrawBuffer)
+               radeon_map_unmap_framebuffer(ctx, ctx->ReadBuffer, GL_TRUE);
 }
 
 static void radeonSpanRenderFinish(GLcontext * ctx)
 {
        radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
        int i;
+
        _swrast_flush(ctx);
-       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);
+       radeon_map_unmap_framebuffer(ctx, ctx->DrawBuffer, GL_FALSE);
+       if (ctx->ReadBuffer != ctx->DrawBuffer)
+               radeon_map_unmap_framebuffer(ctx, ctx->ReadBuffer, GL_FALSE);
+
+       if (!rmesa->radeonScreen->driScreen->dri2.enabled) {
+               UNLOCK_HARDWARE(rmesa);
+       }
 }
 
 void radeonInitSpanFuncs(GLcontext * ctx)
@@ -864,25 +929,35 @@ void radeonInitSpanFuncs(GLcontext * ctx)
  */
 static void radeonSetSpanFunctions(struct radeon_renderbuffer *rrb)
 {
-       if (rrb->base._ActualFormat == GL_RGB5) {
+       if (rrb->base.Format == MESA_FORMAT_RGB565) {
                radeonInitPointers_RGB565(&rrb->base);
-       } else if (rrb->base._ActualFormat == GL_RGB8) {
+       } else if (rrb->base.Format == MESA_FORMAT_RGB565_REV) {
+               radeonInitPointers_RGB565_REV(&rrb->base);
+       } else if (rrb->base.Format == MESA_FORMAT_XRGB8888) {
                radeonInitPointers_xRGB8888(&rrb->base);
-       } else if (rrb->base._ActualFormat == GL_RGBA8) {
+        } else if (rrb->base.Format == MESA_FORMAT_XRGB8888_REV) {
+               radeonInitPointers_BGRx8888(&rrb->base);
+       } else if (rrb->base.Format == MESA_FORMAT_ARGB8888) {
                radeonInitPointers_ARGB8888(&rrb->base);
-       } else if (rrb->base._ActualFormat == GL_RGBA4) {
+        } else if (rrb->base.Format == MESA_FORMAT_ARGB8888_REV) {
+               radeonInitPointers_BGRA8888(&rrb->base);
+       } else if (rrb->base.Format == MESA_FORMAT_ARGB4444) {
                radeonInitPointers_ARGB4444(&rrb->base);
-       } else if (rrb->base._ActualFormat == GL_RGB5_A1) {
+       } else if (rrb->base.Format == MESA_FORMAT_ARGB4444_REV) {
+               radeonInitPointers_ARGB4444_REV(&rrb->base);
+       } else if (rrb->base.Format == MESA_FORMAT_ARGB1555) {
                radeonInitPointers_ARGB1555(&rrb->base);
-       } else if (rrb->base._ActualFormat == GL_DEPTH_COMPONENT16) {
+       } else if (rrb->base.Format == MESA_FORMAT_ARGB1555_REV) {
+               radeonInitPointers_ARGB1555_REV(&rrb->base);
+       } else if (rrb->base.Format == MESA_FORMAT_Z16) {
                radeonInitDepthPointers_z16(&rrb->base);
-       } else if (rrb->base._ActualFormat == GL_DEPTH_COMPONENT24) {
+       } else if (rrb->base.Format == MESA_FORMAT_X8_Z24) {
                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);
+       } else if (rrb->base.Format == MESA_FORMAT_S8_Z24) {
+               radeonInitDepthPointers_s8_z24(&rrb->base);
+       } else if (rrb->base.Format == MESA_FORMAT_S8) {
+               radeonInitStencilPointers_s8_z24(&rrb->base);
        } else {
-               fprintf(stderr, "radeonSetSpanFunctions: bad actual format: 0x%04X\n", rrb->base._ActualFormat);
+               fprintf(stderr, "radeonSetSpanFunctions: bad format: 0x%04X\n", rrb->base.Format);
        }
 }
index 4d0d35ee0cd10a0141bed86a4745f690f034ca8f..1c9ec36daec997347980edcba4ad80558261a2cf 100644 (file)
@@ -521,10 +521,10 @@ static void radeonColorMask( GLcontext *ctx,
      return;
 
    mask = radeonPackColor( rrb->cpp,
-                          ctx->Color.ColorMask[RCOMP],
-                          ctx->Color.ColorMask[GCOMP],
-                          ctx->Color.ColorMask[BCOMP],
-                          ctx->Color.ColorMask[ACOMP] );
+                          ctx->Color.ColorMask[0][RCOMP],
+                          ctx->Color.ColorMask[0][GCOMP],
+                          ctx->Color.ColorMask[0][BCOMP],
+                          ctx->Color.ColorMask[0][ACOMP] );
 
    if ( rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK] != mask ) {
       RADEON_STATECHANGE( rmesa, msk );
@@ -550,6 +550,31 @@ static void radeonPolygonOffset( GLcontext *ctx,
    rmesa->hw.zbs.cmd[ZBS_SE_ZBIAS_CONSTANT] = constant.ui32;
 }
 
+static void radeonPolygonStipplePreKMS( GLcontext *ctx, const GLubyte *mask )
+{
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
+   GLuint i;
+   drm_radeon_stipple_t stipple;
+
+   /* Must flip pattern upside down.
+    */
+   for ( i = 0 ; i < 32 ; i++ ) {
+      rmesa->state.stipple.mask[31 - i] = ((GLuint *) mask)[i];
+   }
+
+   /* TODO: push this into cmd mechanism
+    */
+   radeon_firevertices(&rmesa->radeon);
+   LOCK_HARDWARE( &rmesa->radeon );
+
+   /* FIXME: Use window x,y offsets into stipple RAM.
+    */
+   stipple.mask = rmesa->state.stipple.mask;
+   drmCommandWrite( rmesa->radeon.dri.fd, DRM_RADEON_STIPPLE,
+                   &stipple, sizeof(drm_radeon_stipple_t) );
+   UNLOCK_HARDWARE( &rmesa->radeon );
+}
+
 static void radeonPolygonMode( GLcontext *ctx, GLenum face, GLenum mode )
 {
    r100ContextPtr rmesa = R100_CONTEXT(ctx);
@@ -1375,7 +1400,7 @@ static void radeonClearStencil( GLcontext *ctx, GLint s )
 void radeonUpdateWindow( GLcontext *ctx )
 {
    r100ContextPtr rmesa = R100_CONTEXT(ctx);
-   __DRIdrawablePrivate *dPriv = radeon_get_drawable(&rmesa->radeon);
+   __DRIdrawable *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;
@@ -1430,7 +1455,7 @@ static void radeonDepthRange( GLcontext *ctx, GLclampd nearval,
 void radeonUpdateViewportOffset( GLcontext *ctx )
 {
    r100ContextPtr rmesa = R100_CONTEXT(ctx);
-   __DRIdrawablePrivate *dPriv = radeon_get_drawable(&rmesa->radeon);
+   __DRIdrawable *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;
index f3ad0dd17af92715384b2dfe9d6c6611e6dba09a..dd8288825431418ce17c5196c7cf63a597800a9c 100644 (file)
@@ -440,16 +440,18 @@ static void ctx_emit_cs(GLcontext *ctx, struct radeon_state_atom *atom)
    atom->cmd[CTX_RB3D_CNTL] &= ~(0xf << 10);
    if (rrb->cpp == 4)
        atom->cmd[CTX_RB3D_CNTL] |= RADEON_COLOR_FORMAT_ARGB8888;
-   else switch (rrb->base._ActualFormat) {
-   case GL_RGB5:
+   else switch (rrb->base.Format) {
+   case MESA_FORMAT_RGB565:
        atom->cmd[CTX_RB3D_CNTL] |= RADEON_COLOR_FORMAT_RGB565;
        break;
-   case GL_RGBA4:
+   case MESA_FORMAT_ARGB4444:
        atom->cmd[CTX_RB3D_CNTL] |= RADEON_COLOR_FORMAT_ARGB4444;
        break;
-   case GL_RGB5_A1:
+   case MESA_FORMAT_ARGB1555:
        atom->cmd[CTX_RB3D_CNTL] |= RADEON_COLOR_FORMAT_ARGB1555;
        break;
+   default:
+       _mesa_problem(ctx, "unexpected format in ctx_emit_cs()");
    }
 
    cbpitch = (rrb->pitch / rrb->cpp);
@@ -643,11 +645,11 @@ static void tex_emit_cs(GLcontext *ctx, struct radeon_state_atom *atom)
      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];
+            lvl = &t->mt->levels[t->minLod];
            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,
+           OUT_BATCH_RELOC(t->tile_bits, t->mt->bo, get_base_teximage_offset(t),
                     RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0, 0);
         }
       } else {
index e61f59eaeaf89146c8fa13939a023e7079d01326..8bf1bfbc5752d4c38840dd4d926dbd80a8a16806 100644 (file)
@@ -179,7 +179,7 @@ static void radeonSetVertexFormat( GLcontext *ctx )
 
       for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
         if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX(i) )) {
-           GLuint sz = VB->TexCoordPtr[i]->size;
+           GLuint sz = VB->AttribPtr[_TNL_ATTRIB_TEX0 + i]->size;
 
            switch (sz) {
            case 1:
@@ -309,7 +309,7 @@ void r100_swtcl_flush(GLcontext *ctx, uint32_t current_offset)
    radeonEmitState(&rmesa->radeon);
    radeonEmitVertexAOS( rmesa,
                        rmesa->radeon.swtcl.vertex_size,
-                       first_elem(&rmesa->radeon.dma.reserved)->bo,
+                       rmesa->radeon.swtcl.bo,
                        current_offset);
 
                      
index 99865fff27b0ad441ec73eaddc6f765dcd9a3c54..14163f13af4a25c6a46b1b812f87f017baa6831b 100644 (file)
@@ -38,7 +38,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/enums.h"
 #include "main/image.h"
 #include "main/simple_list.h"
-#include "main/texformat.h"
 #include "main/texstore.h"
 #include "main/teximage.h"
 #include "main/texobj.h"
@@ -342,24 +341,14 @@ static void radeonTexParameter( GLcontext *ctx, GLenum target,
       break;
 
    case GL_TEXTURE_BORDER_COLOR:
-      radeonSetTexBorderColor( t, texObj->BorderColor );
+      radeonSetTexBorderColor( t, texObj->BorderColor.f );
       break;
 
    case GL_TEXTURE_BASE_LEVEL:
    case GL_TEXTURE_MAX_LEVEL:
    case GL_TEXTURE_MIN_LOD:
    case GL_TEXTURE_MAX_LOD:
-
-      /* This isn't the most efficient solution but there doesn't appear to
-       * be a nice alternative.  Since there's no LOD clamping,
-       * we just have to rely on loading the right subset of mipmap levels
-       * to simulate a clamped LOD.
-       */
-      if (t->mt) {
-         radeon_miptree_unreference(t->mt);
-        t->mt = 0;
-        t->validated = GL_FALSE;
-      }
+      t->validated = GL_FALSE;
       break;
 
    default:
@@ -389,10 +378,8 @@ static void radeonDeleteTexture( GLcontext *ctx,
      }
    }
 
-   if (t->mt) {
-      radeon_miptree_unreference(t->mt);
-      t->mt = 0;
-   }
+   radeon_miptree_unreference(&t->mt);
+
    /* Free mipmap images and the texture object itself */
    _mesa_delete_texture_object(ctx, texObj);
 }
@@ -441,7 +428,7 @@ radeonNewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
    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 );
+   radeonSetTexBorderColor( t, t->base.BorderColor.f );
    return &t->base;
 }
 
index ae41b90efe5d2be008e9064250151cc5793c8bba..84ddcfd4fd36c9462cc84ec887ad5510ce71ea0d 100644 (file)
@@ -38,8 +38,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/colormac.h"
 #include "main/context.h"
 #include "main/macros.h"
-#include "main/texformat.h"
 #include "main/teximage.h"
+#include "main/texstate.h"
 #include "main/texobj.h"
 #include "main/enums.h"
 
@@ -81,8 +81,10 @@ struct tx_table {
    GLuint format, filter;
 };
 
+/* XXX verify this table against MESA_FORMAT_x values */
 static const struct tx_table tx_table[] =
 {
+   _INVALID(NONE), /* MESA_FORMAT_NONE */
    _ALPHA(RGBA8888),
    _ALPHA_REV(RGBA8888),
    _ALPHA(ARGB8888),
@@ -660,7 +662,7 @@ void radeonSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_
        rmesa = pDRICtx->driverPrivate;
 
        rfb = dPriv->driverPrivate;
-        texUnit = &radeon->glCtx->Texture.Unit[radeon->glCtx->Texture.CurrentUnit];
+        texUnit = _mesa_get_current_tex_unit(radeon->glCtx);
        texObj = _mesa_select_tex_object(radeon->glCtx, texUnit, target);
         texImage = _mesa_get_tex_image(radeon->glCtx, texObj, target, 0);
 
@@ -670,24 +672,13 @@ void radeonSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_
            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;
-       }
+       radeon_update_renderbuffers(pDRICtx, dPriv, GL_TRUE);
        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);
@@ -697,20 +688,14 @@ void radeonSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_
                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;
-       }
+
+       radeon_miptree_unreference(&t->mt);
+       radeon_miptree_unreference(&rImage->mt);
+
        _mesa_init_teximage_fields(radeon->glCtx, target, texImage,
                                   rb->base.Width, rb->base.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;
@@ -718,8 +703,6 @@ void radeonSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_
        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)
@@ -738,12 +721,17 @@ void radeonSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_
                t->pp_txfilter |= tx_table[MESA_FORMAT_RGB565].filter;
                break;
        }
-        t->pp_txsize = ((rb->base.Width - 1) << RADEON_TEX_USIZE_SHIFT)
-                  | ((rb->base.Height - 1) << RADEON_TEX_VSIZE_SHIFT);
-        t->pp_txformat |= RADEON_TXFORMAT_NON_POWER2;
-       t->pp_txpitch = pitch_val;
-        t->pp_txpitch -= 32;
 
+       t->pp_txpitch &= (1 << 13) -1;
+       pitch_val = rb->pitch;
+
+        t->pp_txsize = ((rb->base.Width - 1) << RADEON_TEX_USIZE_SHIFT)
+               | ((rb->base.Height - 1) << RADEON_TEX_VSIZE_SHIFT);
+       if (target == GL_TEXTURE_RECTANGLE_NV) {
+               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;
@@ -1021,7 +1009,7 @@ static GLboolean setup_hardware_state(r100ContextPtr rmesa, radeonTexObj *t, int
        return GL_TRUE;
    }
 
-   firstImage = t->base.Image[0][t->mt->firstLevel];   
+   firstImage = t->base.Image[0][t->minLod];
 
    if (firstImage->Border > 0) {
       fprintf(stderr, "%s: border\n", __FUNCTION__);
@@ -1031,27 +1019,27 @@ static GLboolean setup_hardware_state(r100ContextPtr rmesa, radeonTexObj *t, int
    log2Width  = firstImage->WidthLog2;
    log2Height = firstImage->HeightLog2;
    log2Depth  = firstImage->DepthLog2;
-   texelBytes = firstImage->TexFormat->TexelBytes;
+   texelBytes = _mesa_get_format_bytes(firstImage->TexFormat);
 
    if (!t->image_override) {
-      if (VALID_FORMAT(firstImage->TexFormat->MesaFormat)) {
+      if (VALID_FORMAT(firstImage->TexFormat)) {
        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;
+        t->pp_txformat |= table[ firstImage->TexFormat ].format;
+        t->pp_txfilter |= table[ firstImage->TexFormat ].filter;
       } else {
         _mesa_problem(NULL, "unexpected texture format in %s",
                       __FUNCTION__);
         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_txfilter |= (t->maxLod - t->minLod) << RADEON_MAX_MIP_LEVEL_SHIFT;
        
    t->pp_txformat &= ~(RADEON_TXFORMAT_WIDTH_MASK |
                       RADEON_TXFORMAT_HEIGHT_MASK |
@@ -1060,9 +1048,9 @@ static GLboolean setup_hardware_state(r100ContextPtr rmesa, radeonTexObj *t, int
                       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) |
@@ -1083,7 +1071,7 @@ static GLboolean setup_hardware_state(r100ContextPtr rmesa, radeonTexObj *t, int
                   | ((firstImage->Height - 1) << RADEON_TEX_VSIZE_SHIFT));
 
    if ( !t->image_override ) {
-      if (firstImage->IsCompressed)
+      if (_mesa_is_format_compressed(firstImage->TexFormat))
          t->pp_txpitch = (firstImage->Width + 63) & ~(63);
       else
          t->pp_txpitch = ((firstImage->Width * texelBytes) + 63) & ~(63);
index 7b7392b21798ef395f949ff5e7ec335d15932a4e..03178116c1ab0d6bfd23ab7308b970c5e8947fb0 100644 (file)
@@ -1,4 +1,5 @@
 /*
+ * Copyright (C) 2009 Maciej Cencora.
  * Copyright (C) 2008 Nicolai Haehnle.
  * Copyright (C) The Weather Channel, Inc.  2002.  All Rights Reserved.
  *
@@ -34,7 +35,6 @@
 #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"
@@ -47,7 +47,7 @@
 #include "radeon_mipmap_tree.h"
 
 
-static void copy_rows(void* dst, GLuint dststride, const void* src, GLuint srcstride,
+void copy_rows(void* dst, GLuint dststride, const void* src, GLuint srcstride,
        GLuint numrows, GLuint rowsize)
 {
        assert(rowsize <= dststride);
@@ -82,8 +82,7 @@ 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;
+               radeon_miptree_unreference(&image->mt);
                assert(!image->base.Data);
        } else {
                _mesa_free_texture_image_data(ctx, timage);
@@ -109,7 +108,7 @@ static void teximage_set_map_data(radeon_texture_image *image)
        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;
+       image->base.RowStride = lvl->rowstride / _mesa_get_format_bytes(image->base.TexFormat);
 }
 
 
@@ -144,7 +143,6 @@ static void map_override(GLcontext *ctx, radeonTexObj *t)
        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)
@@ -176,7 +174,7 @@ void radeonMapTexture(GLcontext *ctx, struct gl_texture_object *texObj)
 
        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)
+               for(level = t->minLod; level <= t->maxLod; ++level)
                        teximage_set_map_data(get_radeon_texture_image(texObj->Image[face][level]));
        }
 }
@@ -193,7 +191,7 @@ void radeonUnmapTexture(GLcontext *ctx, struct gl_texture_object *texObj)
          return;
 
        for(face = 0; face < t->mt->faces; ++face) {
-               for(level = t->mt->firstLevel; level <= t->mt->lastLevel; ++level)
+               for(level = t->minLod; level <= t->maxLod; ++level)
                        texObj->Image[face][level]->Data = 0;
        }
        radeon_bo_unmap(t->mt->bo);
@@ -242,8 +240,7 @@ static void radeon_generate_mipmap(GLcontext *ctx, GLenum target,
                        image->mtlevel = i;
                        image->mtface = face;
 
-                       radeon_miptree_unreference(image->mt);
-                       image->mt = NULL;
+                       radeon_miptree_unreference(&image->mt);
                }
        }
        
@@ -261,9 +258,9 @@ void radeonGenerateMipmap(GLcontext* ctx, GLenum target, struct gl_texture_objec
 
 
 /* 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)
+static gl_format radeonChoose8888TexFormat(radeonContextPtr rmesa,
+                                          GLenum srcFormat,
+                                          GLenum srcType, GLboolean fbo)
 {
        const GLuint ui = 1;
        const GLubyte littleEndian = *((const GLubyte *)&ui);
@@ -276,37 +273,37 @@ static const struct gl_texture_format *radeonChoose8888TexFormat(radeonContextPt
            (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;
+               return MESA_FORMAT_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;
+               return MESA_FORMAT_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;
+               return MESA_FORMAT_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;
+               return MESA_FORMAT_ARGB8888;
        } else
                return _dri_texformat_argb8888;
 }
 
-const struct gl_texture_format *radeonChooseTextureFormat_mesa(GLcontext * ctx,
-                                                         GLint internalFormat,
-                                                         GLenum format,
-                                                         GLenum type)
+gl_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)
+gl_format radeonChooseTextureFormat(GLcontext * ctx,
+                                   GLint internalFormat,
+                                   GLenum format,
+                                   GLenum type, GLboolean fbo)
 {
        radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
        const GLboolean do32bpt =
@@ -430,58 +427,72 @@ const struct gl_texture_format *radeonChooseTextureFormat(GLcontext * ctx,
        case GL_YCBCR_MESA:
                if (type == GL_UNSIGNED_SHORT_8_8_APPLE ||
                    type == GL_UNSIGNED_BYTE)
-                       return &_mesa_texformat_ycbcr;
+                       return MESA_FORMAT_YCBCR;
                else
-                       return &_mesa_texformat_ycbcr_rev;
+                       return MESA_FORMAT_YCBCR_REV;
 
        case GL_RGB_S3TC:
        case GL_RGB4_S3TC:
        case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
-               return &_mesa_texformat_rgb_dxt1;
+               return MESA_FORMAT_RGB_DXT1;
 
        case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
-               return &_mesa_texformat_rgba_dxt1;
+               return MESA_FORMAT_RGBA_DXT1;
 
        case GL_RGBA_S3TC:
        case GL_RGBA4_S3TC:
        case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
-               return &_mesa_texformat_rgba_dxt3;
+               return MESA_FORMAT_RGBA_DXT3;
 
        case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
-               return &_mesa_texformat_rgba_dxt5;
+               return MESA_FORMAT_RGBA_DXT5;
 
        case GL_ALPHA16F_ARB:
-               return &_mesa_texformat_alpha_float16;
+               return MESA_FORMAT_ALPHA_FLOAT16;
        case GL_ALPHA32F_ARB:
-               return &_mesa_texformat_alpha_float32;
+               return MESA_FORMAT_ALPHA_FLOAT32;
        case GL_LUMINANCE16F_ARB:
-               return &_mesa_texformat_luminance_float16;
+               return MESA_FORMAT_LUMINANCE_FLOAT16;
        case GL_LUMINANCE32F_ARB:
-               return &_mesa_texformat_luminance_float32;
+               return MESA_FORMAT_LUMINANCE_FLOAT32;
        case GL_LUMINANCE_ALPHA16F_ARB:
-               return &_mesa_texformat_luminance_alpha_float16;
+               return MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16;
        case GL_LUMINANCE_ALPHA32F_ARB:
-               return &_mesa_texformat_luminance_alpha_float32;
+               return MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32;
        case GL_INTENSITY16F_ARB:
-               return &_mesa_texformat_intensity_float16;
+               return MESA_FORMAT_INTENSITY_FLOAT16;
        case GL_INTENSITY32F_ARB:
-               return &_mesa_texformat_intensity_float32;
+               return MESA_FORMAT_INTENSITY_FLOAT32;
        case GL_RGB16F_ARB:
-               return &_mesa_texformat_rgba_float16;
+               return MESA_FORMAT_RGBA_FLOAT16;
        case GL_RGB32F_ARB:
-               return &_mesa_texformat_rgba_float32;
+               return MESA_FORMAT_RGBA_FLOAT32;
        case GL_RGBA16F_ARB:
-               return &_mesa_texformat_rgba_float16;
+               return MESA_FORMAT_RGBA_FLOAT16;
        case GL_RGBA32F_ARB:
-               return &_mesa_texformat_rgba_float32;
+               return MESA_FORMAT_RGBA_FLOAT32;
 
+#ifdef RADEON_R300
        case GL_DEPTH_COMPONENT:
        case GL_DEPTH_COMPONENT16:
+               return MESA_FORMAT_Z16;
        case GL_DEPTH_COMPONENT24:
        case GL_DEPTH_COMPONENT32:
        case GL_DEPTH_STENCIL_EXT:
        case GL_DEPTH24_STENCIL8_EXT:
-               return &_mesa_texformat_s8_z24;
+               if (rmesa->radeonScreen->chip_family >= CHIP_FAMILY_RV515)
+                       return MESA_FORMAT_S8_Z24;
+               else
+                       return MESA_FORMAT_Z16;
+#else
+       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_FORMAT_S8_Z24;
+#endif
 
        /* EXT_texture_sRGB */
        case GL_SRGB:
@@ -490,26 +501,193 @@ const struct gl_texture_format *radeonChooseTextureFormat(GLcontext * ctx,
        case GL_SRGB8_ALPHA8:
        case GL_COMPRESSED_SRGB:
        case GL_COMPRESSED_SRGB_ALPHA:
-               return &_mesa_texformat_srgba8;
+               return MESA_FORMAT_SRGBA8;
 
        case GL_SLUMINANCE:
        case GL_SLUMINANCE8:
        case GL_COMPRESSED_SLUMINANCE:
-               return &_mesa_texformat_sl8;
+               return MESA_FORMAT_SL8;
 
        case GL_SLUMINANCE_ALPHA:
        case GL_SLUMINANCE8_ALPHA8:
        case GL_COMPRESSED_SLUMINANCE_ALPHA:
-               return &_mesa_texformat_sla8;
+               return MESA_FORMAT_SLA8;
 
        default:
                _mesa_problem(ctx,
                              "unexpected internalFormat 0x%x in %s",
                              (int)internalFormat, __func__);
+               return MESA_FORMAT_NONE;
+       }
+
+       return MESA_FORMAT_NONE;                /* never get here */
+}
+
+/** Check if given image is valid within current texture object.
+ */
+static int image_matches_texture_obj(struct gl_texture_object *texObj,
+       struct gl_texture_image *texImage,
+       unsigned level)
+{
+       const struct gl_texture_image *baseImage = texObj->Image[0][texObj->BaseLevel];
+
+       if (!baseImage)
+               return 0;
+
+       if (level < texObj->BaseLevel || level > texObj->MaxLevel)
+               return 0;
+
+       const unsigned levelDiff = level - texObj->BaseLevel;
+       const unsigned refWidth = MAX2(baseImage->Width >> levelDiff, 1);
+       const unsigned refHeight = MAX2(baseImage->Height >> levelDiff, 1);
+       const unsigned refDepth = MAX2(baseImage->Depth >> levelDiff, 1);
+
+       return (texImage->Width == refWidth &&
+                       texImage->Height == refHeight &&
+                       texImage->Depth == refDepth);
+}
+
+static void teximage_assign_miptree(radeonContextPtr rmesa,
+       struct gl_texture_object *texObj,
+       struct gl_texture_image *texImage,
+       unsigned face,
+       unsigned level)
+{
+       radeonTexObj *t = radeon_tex_obj(texObj);
+       radeon_texture_image* image = get_radeon_texture_image(texImage);
+
+       /* Since miptree holds only images for levels <BaseLevel..MaxLevel>
+        * don't allocate the miptree if the teximage won't fit.
+        */
+       if (!image_matches_texture_obj(texObj, texImage, level))
+               return;
+
+       /* Try using current miptree, or create new if there isn't any */
+       if (!t->mt || !radeon_miptree_matches_image(t->mt, texImage, face, level)) {
+               radeon_miptree_unreference(&t->mt);
+               radeon_try_alloc_miptree(rmesa, t);
+               if (RADEON_DEBUG & RADEON_TEXTURE) {
+                       fprintf(stderr, "%s: texObj %p, texImage %p, face %d, level %d, "
+                               "texObj miptree doesn't match, allocated new miptree %p\n",
+                               __FUNCTION__, texObj, texImage, face, level, t->mt);
+               }
+       }
+
+       /* Miptree alocation may have failed,
+        * when there was no image for baselevel specified */
+       if (t->mt) {
+               image->mtface = face;
+               image->mtlevel = level;
+               radeon_miptree_reference(t->mt, &image->mt);
+       }
+}
+
+static GLuint * allocate_image_offsets(GLcontext *ctx,
+       unsigned alignedWidth,
+       unsigned height,
+       unsigned depth)
+{
+       int i;
+       GLuint *offsets;
+
+       offsets = _mesa_malloc(depth * sizeof(GLuint)) ;
+       if (!offsets) {
+               _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTex[Sub]Image");
                return NULL;
        }
 
-       return NULL;            /* never get here */
+       for (i = 0; i < depth; ++i) {
+               offsets[i] = alignedWidth * height * i;
+       }
+
+       return offsets;
+}
+
+/**
+ * Update a subregion of the given texture image.
+ */
+static void radeon_store_teximage(GLcontext* ctx, int dims,
+               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)
+{
+       radeonTexObj *t = radeon_tex_obj(texObj);
+       radeon_texture_image* image = get_radeon_texture_image(texImage);
+
+       GLuint dstRowStride;
+       GLuint *dstImageOffsets;
+
+       if (image->mt) {
+               dstRowStride = image->mt->levels[image->mtlevel].rowstride;
+       } else if (t->bo) {
+               /* TFP case */
+               /* TODO */
+               assert(0);
+       } else {
+               dstRowStride = _mesa_format_row_stride(texImage->TexFormat, texImage->Width);
+       }
+
+       assert(dstRowStride);
+
+       if (dims == 3) {
+               unsigned alignedWidth = dstRowStride/_mesa_get_format_bytes(texImage->TexFormat);
+               dstImageOffsets = allocate_image_offsets(ctx, alignedWidth, texImage->Height, texImage->Depth);
+               if (!dstImageOffsets) {
+                       return;
+               }
+       } else {
+               dstImageOffsets = texImage->ImageOffsets;
+       }
+
+       radeon_teximage_map(image, GL_TRUE);
+
+       if (compressed) {
+               uint32_t srcRowStride, bytesPerRow, rows, block_width, block_height;
+               GLubyte *img_start;
+
+               _mesa_get_format_block_size(texImage->TexFormat, &block_width, &block_height);
+
+               if (!image->mt) {
+                       dstRowStride = _mesa_format_row_stride(texImage->TexFormat, texImage->Width);
+                       img_start = _mesa_compressed_image_address(xoffset, yoffset, 0,
+                                                                       texImage->TexFormat,
+                                                                       texImage->Width, texImage->Data);
+               }
+               else {
+                       uint32_t offset;
+                       offset = dstRowStride / _mesa_get_format_bytes(texImage->TexFormat) * yoffset / block_height + xoffset / block_width;
+                       offset *= _mesa_get_format_bytes(texImage->TexFormat);
+                       img_start = texImage->Data + offset;
+               }
+               srcRowStride = _mesa_format_row_stride(texImage->TexFormat, width);
+               bytesPerRow = srcRowStride;
+               rows = (height + block_height - 1) / block_height;
+
+               copy_rows(img_start, dstRowStride, pixels, srcRowStride, rows, bytesPerRow);
+       }
+       else {
+               if (!_mesa_texstore(ctx, dims, texImage->_BaseFormat,
+                                       texImage->TexFormat, texImage->Data,
+                                       xoffset, yoffset, zoffset,
+                                       dstRowStride,
+                                       dstImageOffsets,
+                                       width, height, depth,
+                                       format, type, pixels, packing)) {
+                       _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage");
+               }
+       }
+
+       if (dims == 3) {
+               _mesa_free(dstImageOffsets);
+       }
+
+       radeon_teximage_unmap(image);
 }
 
 /**
@@ -530,13 +708,22 @@ static void radeon_teximage(
        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;
        GLuint face = radeon_face_for_target(target);
 
-       radeon_firevertices(rmesa);
+       {
+               struct radeon_bo *bo;
+               bo = !image->mt ? image->bo : image->mt->bo;
+               if (bo && radeon_bo_is_referenced_by_cs(bo, rmesa->cmdbuf.cs)) {
+                       radeon_firevertices(rmesa);
+               }
+       }
+
+       if (RADEON_DEBUG & RADEON_TEXTURE) {
+               fprintf(stderr, "radeon_teximage%dd: texObj %p, texImage %p, face %d, level %d\n",
+                               dims, texObj, texImage, face, level);
+       }
 
        t->validated = GL_FALSE;
 
@@ -545,62 +732,35 @@ static void radeon_teximage(
                                                  &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;
+       if (!_mesa_is_format_compressed(texImage->TexFormat)) {
+               GLuint texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
                /* Minimum pitch of 32 bytes */
                if (postConvWidth * texelBytes < 32) {
-                 postConvWidth = 32 / texelBytes;
-                 texImage->RowStride = postConvWidth;
+                       postConvWidth = 32 / texelBytes;
+                       texImage->RowStride = postConvWidth;
                }
-               if (!image->mt) {      
+               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, image, 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;
+       /* Mesa core only clears texImage->Data but not image->mt */
+       radeonFreeTexImageData(ctx, texImage);
+
+       if (!t->bo) {
+               teximage_assign_miptree(rmesa, texObj, texImage, face, level);
+               if (!image->mt) {
+                       int size = _mesa_format_image_size(texImage->TexFormat,
+                                                               texImage->Width,
+                                                               texImage->Height,
+                                                               texImage->Depth);
+                       texImage->Data = _mesa_alloc_texmemory(size);
+                       if (RADEON_DEBUG & RADEON_TEXTURE) {
+                               fprintf(stderr, "radeon_teximage%dd: texObj %p, texImage %p, "
+                                       " no miptree assigned, using local memory %p\n",
+                                       dims, texObj, texImage, texImage->Data);
+                       }
                }
-               texImage->Data = _mesa_alloc_texmemory(size);
        }
 
        /* Upload texture image; note that the spec allows pixels to be NULL */
@@ -614,64 +774,16 @@ static void radeon_teximage(
        }
 
        if (pixels) {
-               radeon_teximage_map(image, GL_TRUE);
-               if (compressed) {
-                       if (image->mt) {
-                               uint32_t srcRowStride, bytesPerRow, rows;
-                               srcRowStride = _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat, width);
-                               bytesPerRow = srcRowStride;
-                               rows = (height + 3) / 4;
-                               copy_rows(texImage->Data, image->mt->levels[level].rowstride,
-                                         pixels, srcRowStride, rows, bytesPerRow);
-                       } else {
-                               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);
-               }
+               radeon_store_teximage(ctx, dims,
+                       0, 0, 0,
+                       width, height, depth,
+                       imageSize, format, type,
+                       pixels, packing,
+                       texObj, texImage,
+                       compressed);
        }
 
        _mesa_unmap_teximage_pbo(ctx, packing);
-
-       if (pixels)
-         radeon_teximage_unmap(image);
-
-
 }
 
 void radeonTexImage1D(GLcontext * ctx, GLenum target, GLint level,
@@ -724,7 +836,7 @@ void radeonTexImage3D(GLcontext * ctx, GLenum target, GLint level,
 }
 
 /**
- * Update a subregion of the given texture image.
+ * All glTexSubImage calls go through this function.
  */
 static void radeon_texsubimage(GLcontext* ctx, int dims, GLenum target, int level,
                GLint xoffset, GLint yoffset, GLint zoffset,
@@ -741,64 +853,39 @@ static void radeon_texsubimage(GLcontext* ctx, int dims, GLenum target, int leve
        radeonTexObj* t = radeon_tex_obj(texObj);
        radeon_texture_image* image = get_radeon_texture_image(texImage);
 
-       radeon_firevertices(rmesa);
+       {
+               struct radeon_bo *bo;
+               bo = !image->mt ? image->bo : image->mt->bo;
+               if (bo && radeon_bo_is_referenced_by_cs(bo, rmesa->cmdbuf.cs)) {
+                       radeon_firevertices(rmesa);
+               }
+       }
+
+       if (RADEON_DEBUG & RADEON_TEXTURE) {
+               fprintf(stderr, "radeon_texsubimage%dd: texObj %p, texImage %p, face %d, level %d\n",
+                               dims, texObj, texImage, radeon_face_for_target(target), level);
+       }
 
        t->validated = GL_FALSE;
        if (compressed) {
                pixels = _mesa_validate_pbo_compressed_teximage(
-                       ctx, imageSize, pixels, packing, "glCompressedTexImage");
+                       ctx, imageSize, pixels, packing, "glCompressedTexSubImage");
        } else {
                pixels = _mesa_validate_pbo_teximage(ctx, dims,
-                       width, height, depth, format, type, pixels, packing, "glTexSubImage1D");
+                       width, height, depth, format, type, pixels, packing, "glTexSubImage");
        }
 
        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;
-                       GLubyte *img_start;
-                       if (!image->mt) {
-                               dstRowStride = _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat, texImage->Width);
-                               img_start = _mesa_compressed_image_address(xoffset, yoffset, 0,
-                                                                          texImage->TexFormat->MesaFormat,
-                                                                          texImage->Width, texImage->Data);
-                       }
-                       else {
-                               uint32_t blocks_x = dstRowStride / (image->mt->bpp * 4);
-                               img_start = texImage->Data + image->mt->bpp * 4 * (blocks_x * (yoffset / 4) + xoffset / 4);
-                       }
-                       srcRowStride = _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat, width);
-                       bytesPerRow = srcRowStride;
-                       rows = (height + 3) / 4;
-
-                       copy_rows(img_start, dstRowStride,  pixels, 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");
-               }
+               radeon_store_teximage(ctx, dims,
+                       xoffset, yoffset, zoffset,
+                       width, height, depth,
+                       imageSize, format, type,
+                       pixels, packing,
+                       texObj, texImage,
+                       compressed);
        }
 
-       radeon_teximage_unmap(image);
-
        _mesa_unmap_teximage_pbo(ctx, packing);
-
-
 }
 
 void radeonTexSubImage1D(GLcontext * ctx, GLenum target, GLint level,
@@ -854,143 +941,6 @@ void radeonTexSubImage3D(GLcontext * ctx, GLenum target, GLint level,
                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 + 3) / 4;
-                       srcrowstride = _mesa_compressed_row_stride(image->base.TexFormat->MesaFormat, image->base.Width);
-               } 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 & RADEON_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 & RADEON_TEXTURE)
-                       fprintf(stderr, " Allocate new miptree\n");
-               radeon_try_alloc_miptree(rmesa, t, baseimage, 0, texObj->BaseLevel);
-               if (!t->mt) {
-                       _mesa_problem(ctx, "radeon_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 & RADEON_TEXTURE)
-                               fprintf(stderr, " face %i, level %i... %p vs %p ", face, level, t->mt, image->mt);
-                       if (t->mt == image->mt || (!image->mt && !image->base.Data)) {
-                               if (RADEON_DEBUG & RADEON_TEXTURE)
-                                       fprintf(stderr, "OK\n");
-
-                               continue;
-                       }
-
-                       if (RADEON_DEBUG & RADEON_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.
index 888a55ba911309cbdba4c8386574c13a551f277f..906daf12d0a62de963464d9307bf2dff15f9a9b1 100644 (file)
 
 #ifndef RADEON_TEXTURE_H
 #define RADEON_TEXTURE_H
+
+#include "main/formats.h"
+
+void copy_rows(void* dst, GLuint dststride, const void* src, GLuint srcstride,
+       GLuint numrows, GLuint rowsize);
 struct gl_texture_image *radeonNewTextureImage(GLcontext *ctx);
 void radeonFreeTexImageData(GLcontext *ctx, struct gl_texture_image *timage);
 
@@ -40,14 +45,16 @@ 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);
+
+gl_format radeonChooseTextureFormat_mesa(GLcontext * ctx,
+                                         GLint internalFormat,
+                                         GLenum format,
+                                         GLenum type);
+
+gl_format radeonChooseTextureFormat(GLcontext * ctx,
+                                    GLint internalFormat,
+                                    GLenum format,
+                                    GLenum type, GLboolean fbo);
 
 void radeonTexImage1D(GLcontext * ctx, GLenum target, GLint level,
                      GLint internalFormat,
diff --git a/src/mesa/drivers/dri/s3v/Makefile b/src/mesa/drivers/dri/s3v/Makefile
deleted file mode 100644 (file)
index 9bd7973..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-# src/mesa/drivers/dri/s3v/Makefile
-
-TOP = ../../../../..
-include $(TOP)/configs/current
-
-LIBNAME = s3v_dri.so
-
-# Doesn't exist yet.
-#MINIGLX_SOURCES = server/savage_dri.c 
-
-DRIVER_SOURCES = \
-       s3v_context.c \
-        s3v_dd.c \
-        s3v_inithw.c \
-        s3v_lock.c \
-        s3v_render.c \
-        s3v_screen.c \
-        s3v_span.c \
-        s3v_state.c \
-        s3v_tex.c \
-        s3v_texmem.c \
-        s3v_texstate.c \
-        s3v_tris.c \
-        s3v_vb.c \
-        s3v_xmesa.c
-
-C_SOURCES = \
-       $(COMMON_SOURCES) \
-       $(DRIVER_SOURCES) 
-
-ASM_SOURCES = 
-
-
-include ../Makefile.template
-
-symlinks:
diff --git a/src/mesa/drivers/dri/s3v/s3v_common.h b/src/mesa/drivers/dri/s3v/s3v_common.h
deleted file mode 100644 (file)
index b66cdf1..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-/* WARNING: If you change any of these defines, make sure to change
- * the kernel include file as well (s3v_drm.h)
- */
-
-#ifndef _XF86DRI_S3V_H_
-#define _XF86DRI_S3V_H_
-
-#ifndef _S3V_DEFINES_
-#define _S3V_DEFINES_
-#define S3V_USE_BATCH 1
-
-/* #define S3V_BUF_4K 1 */
-
-#ifdef S3V_BUF_4K
-#define S3V_DMA_BUF_ORDER 12
-#define S3V_DMA_BUF_NR    256
-#else
-#define S3V_DMA_BUF_ORDER 16 /* -much- better */
-#define S3V_DMA_BUF_NR    16
-#endif
-/* on s3virge you can only choose between *
- * 4k (2^12) and 64k (2^16) dma bufs      */
-#define S3V_DMA_BUF_SZ        (1<<S3V_DMA_BUF_ORDER)
-
-#define S3V_NR_SAREA_CLIPRECTS 8
-
-/* Each region is a minimum of 16k (64*64@4bpp)
- * and there are at most 40 of them.
- */
-#define S3V_NR_TEX_REGIONS 64 /* was 40 */
-#define S3V_LOG_TEX_GRANULARITY 16 /* was 4 */
-/* 40 * (2 ^ 4) = 640k, that's all we have for tex on 4mb gfx card */
-/* FIXME: will it work with card with less than 4mb? */
-/* FIXME: we should set this at run time */
-
-#endif  /* _S3V_DEFINES */
-
-/*
- * WARNING: If you change any of these defines, make sure to change
- * the kernel include file as well (gamma_drm.h)
- */
-
-/* Driver specific DRM command indices
- * NOTE: these are not OS specific, but they are driver specific
- */
-#define DRM_S3V_INIT_DMA              0x00
-#define DRM_S3V_CLEANUP_DMA           0x01
-
-typedef struct _drmS3VInit {
-    enum {
-        S3V_INIT_DMA = 0x01,
-        S3V_CLEANUP_DMA = 0x02
-    } func;
-
-    unsigned int pcimode;   /* bool: 1=pci 0=agp */
-
-    unsigned int mmio_offset;
-    unsigned int buffers_offset;
-    unsigned int sarea_priv_offset;
-
-    unsigned int front_offset;
-    unsigned int front_width;
-    unsigned int front_height;
-    unsigned int front_pitch;
-
-    unsigned int back_offset;
-    unsigned int back_width;
-    unsigned int back_height;
-    unsigned int back_pitch;
-
-    unsigned int depth_offset;
-    unsigned int depth_width;
-    unsigned int depth_height;
-    unsigned int depth_pitch;
-
-    unsigned int texture_offset;
-} drmS3VInit;
-
-#endif
diff --git a/src/mesa/drivers/dri/s3v/s3v_context.c b/src/mesa/drivers/dri/s3v/s3v_context.c
deleted file mode 100644 (file)
index 0a3bf72..0000000
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#include "s3v_context.h"
-
-#include "swrast/swrast.h"
-#include "swrast_setup/swrast_setup.h"
-#include "vbo/vbo.h"
-
-#include "tnl/tnl.h"
-#include "tnl/t_pipeline.h"
-
-#include "main/context.h"
-#include "main/simple_list.h"
-#include "main/matrix.h"
-#include "main/extensions.h"
-#if defined(USE_X86_ASM)
-#include "x86/common_x86_asm.h"
-#endif
-#include "main/simple_list.h"
-#include "main/mm.h"
-
-#include "drivers/common/driverfuncs.h"
-#include "s3v_vb.h"
-#include "s3v_tris.h"
-
-#if 0
-extern const struct tnl_pipeline_stage _s3v_render_stage;
-
-static const struct tnl_pipeline_stage *s3v_pipeline[] = {
-   &_tnl_vertex_transform_stage,
-   &_tnl_normal_transform_stage,
-   &_tnl_lighting_stage,
-   &_tnl_fog_coordinate_stage,
-   &_tnl_texgen_stage,
-   &_tnl_texture_transform_stage,
-                               /* REMOVE: point attenuation stage */
-#if 1
-   &_s3v_render_stage, /* ADD: unclipped rastersetup-to-dma */
-#endif
-   &_tnl_render_stage,
-   0,
-};
-#endif
-
-GLboolean s3vCreateContext(const __GLcontextModes *glVisual,
-                          __DRIcontextPrivate *driContextPriv,
-                          void *sharedContextPrivate)
-{
-       GLcontext *ctx, *shareCtx;
-       __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
-       s3vContextPtr vmesa;
-       s3vScreenPtr s3vScrn;
-       S3VSAREAPtr saPriv=(S3VSAREAPtr)(((char*)sPriv->pSAREA) + 
-                            sizeof(drm_sarea_t));
-        struct dd_function_table functions;
-
-       DEBUG_WHERE(("*** s3vCreateContext ***\n"));
-
-       vmesa = (s3vContextPtr) CALLOC( sizeof(*vmesa) );
-       if ( !vmesa ) return GL_FALSE;
-
-       /* Allocate the Mesa context */
-       if (sharedContextPrivate)
-               shareCtx = ((s3vContextPtr) sharedContextPrivate)->glCtx;
-       else
-               shareCtx = NULL;
-
-        _mesa_init_driver_functions(&functions);
-
-       vmesa->glCtx = _mesa_create_context(glVisual, shareCtx, &functions,
-                                            (void *)vmesa);
-       if (!vmesa->glCtx) {
-               FREE(vmesa);
-               return GL_FALSE;
-       }
-
-       vmesa->driContext = driContextPriv;
-       vmesa->driScreen = sPriv;
-       vmesa->driDrawable = NULL; /* Set by XMesaMakeCurrent */
-
-       vmesa->hHWContext = driContextPriv->hHWContext;
-       vmesa->driHwLock = (drmLock *)&sPriv->pSAREA->lock;
-       vmesa->driFd = sPriv->fd;
-       vmesa->sarea = saPriv;
-
-       s3vScrn = vmesa->s3vScreen = (s3vScreenPtr)(sPriv->private);
-
-       ctx = vmesa->glCtx;
-
-       ctx->Const.MaxTextureLevels = 11;  /* it is (11-1) -> 1024 * 1024 FIXME */
-
-       ctx->Const.MaxTextureUnits = 1; /* FIXME: or 2 ? */
-
-       /* No wide points.
-        */
-       ctx->Const.MinPointSize = 1.0;
-       ctx->Const.MinPointSizeAA = 1.0;
-       ctx->Const.MaxPointSize = 1.0;
-       ctx->Const.MaxPointSizeAA = 1.0;
-
-       /* No wide lines.
-        */
-       ctx->Const.MinLineWidth = 1.0;
-       ctx->Const.MinLineWidthAA = 1.0;
-       ctx->Const.MaxLineWidth = 1.0;
-       ctx->Const.MaxLineWidthAA = 1.0;
-       ctx->Const.LineWidthGranularity = 1.0;
-
-       ctx->Const.MaxDrawBuffers = 1;
-
-       vmesa->texHeap = mmInit( 0, vmesa->s3vScreen->textureSize );
-       DEBUG(("vmesa->s3vScreen->textureSize = 0x%x\n",
-               vmesa->s3vScreen->textureSize));
-       
-       /* NOTE */
-       /* mmInit(offset, size); */
-
-       /* allocates a structure like this:
-
-       struct mem_block_t {
-               struct mem_block_t *next;
-               struct mem_block_t *heap;
-               int ofs,size;
-               int align;
-               int free:1;
-               int reserved:1;
-       };
-
-       */
-
-       make_empty_list(&vmesa->TexObjList);
-       make_empty_list(&vmesa->SwappedOut);
-
-       vmesa->CurrentTexObj[0] = 0;
-       vmesa->CurrentTexObj[1] = 0; /* FIXME */
-
-       vmesa->RenderIndex = ~0;
-
-       /* Initialize the software rasterizer and helper modules.
-        */
-       _swrast_CreateContext( ctx );
-       _vbo_CreateContext( ctx );
-       _tnl_CreateContext( ctx );
-       _swsetup_CreateContext( ctx );
-
-       /* Install the customized pipeline:
-        */
-#if 0
-       _tnl_destroy_pipeline( ctx );
-       _tnl_install_pipeline( ctx, s3v_pipeline );
-#endif
-       /* Configure swrast to match hardware characteristics:
-        */
-#if 0
-       _swrast_allow_pixel_fog( ctx, GL_FALSE );
-       _swrast_allow_vertex_fog( ctx, GL_TRUE );
-#endif
-       vmesa->_3d_mode = 0;
-
-       /* 3D lines / gouraud tris */
-       vmesa->CMD = ( AUTO_EXEC_ON | HW_CLIP_ON | DEST_COL_1555
-                       | FOG_OFF | ALPHA_OFF | Z_OFF | Z_UPDATE_OFF
-                       | Z_LESS | TEX_WRAP_ON | TEX_MODULATE | LINEAR
-                       | TEX_COL_ARGB1555 | CMD_3D );
-
-       vmesa->_alpha[0] = vmesa->_alpha[1] = ALPHA_OFF;
-       vmesa->alpha_cmd = vmesa->_alpha[0];
-       vmesa->_tri[0] = DO_GOURAUD_TRI;
-       vmesa->_tri[1] = DO_TEX_LIT_TRI;
-       vmesa->prim_cmd = vmesa->_tri[0];
-
-       /* printf("first vmesa->CMD = 0x%x\n", vmesa->CMD); */
-
-       vmesa->TexOffset = vmesa->s3vScreen->texOffset;
-
-       s3vInitVB( ctx );
-       s3vInitExtensions( ctx );
-       s3vInitDriverFuncs( ctx );
-       s3vInitStateFuncs( ctx );
-       s3vInitSpanFuncs( ctx );
-       s3vInitTextureFuncs( ctx );
-       s3vInitTriFuncs( ctx );
-       s3vInitState( vmesa );
-
-       driContextPriv->driverPrivate = (void *)vmesa;
-
-       /* HACK */
-       vmesa->bufSize = S3V_DMA_BUF_SZ;
-
-       DEBUG(("vmesa->bufSize = %i\n", vmesa->bufSize));
-       DEBUG(("vmesa->bufCount = %i\n", vmesa->bufCount));
-
-
-       /* dma init */
-       DEBUG_BUFS(("GET_FIRST_DMA\n"));
-       
-       vmesa->_bufNum = 0;
-
-       GET_FIRST_DMA(vmesa->driFd, vmesa->hHWContext,
-       1, &(vmesa->bufIndex[0]), &(vmesa->bufSize),
-       &vmesa->_buf[0], &vmesa->bufCount, s3vScrn);
-
-       GET_FIRST_DMA(vmesa->driFd, vmesa->hHWContext,
-    1, &(vmesa->bufIndex[1]), &(vmesa->bufSize),
-    &vmesa->_buf[1], &vmesa->bufCount, s3vScrn);
-
-       vmesa->buf = vmesa->_buf[vmesa->_bufNum];
-       
-/*
-       vmesa->CMD = (AUTO_EXEC_ON | HW_CLIP_ON | DEST_COL_1555
-       | FOG_OFF | ALPHA_OFF | Z_OFF | Z_UPDATE_OFF
-       | DO_GOURAUD_TRI | CMD_3D);
-
-       vmesa->TexOffset = vmesa->s3vScreen->texOffset;
-*/
-
-/* ... but we should support only 15 bit in virge (out of 8/15/24)... */
-
-       DEBUG(("glVisual->depthBits = %i\n", glVisual->depthBits));
-
-       switch (glVisual->depthBits) {
-       case 8:
-               break;
-       
-       case 15:
-       case 16:
-               vmesa->depth_scale = 1.0f / 0xffff; 
-               break;
-       case 24:
-               vmesa->depth_scale = 1.0f / 0xffffff;
-               break;
-       default:
-               break;
-       }
-
-       vmesa->cull_zero = 0.0f;
-
-       vmesa->DepthSize = glVisual->depthBits;
-       vmesa->Flags  = S3V_FRONT_BUFFER;
-       vmesa->Flags |= (glVisual->doubleBufferMode ? S3V_BACK_BUFFER : 0);
-       vmesa->Flags |= (vmesa->DepthSize > 0 ? S3V_DEPTH_BUFFER : 0);
-
-       vmesa->EnabledFlags = S3V_FRONT_BUFFER;
-       vmesa->EnabledFlags |= (glVisual->doubleBufferMode ? S3V_BACK_BUFFER : 0);
-
-
-       if (vmesa->Flags & S3V_BACK_BUFFER) {
-               vmesa->readOffset = vmesa->drawOffset = vmesa->s3vScreen->backOffset;
-       } else {
-               vmesa->readOffset = vmesa->drawOffset = 0;
-       }
-
-       s3vInitHW( vmesa );
-
-       driContextPriv->driverPrivate = (void *)vmesa;
-
-       return GL_TRUE;
-}
diff --git a/src/mesa/drivers/dri/s3v/s3v_context.h b/src/mesa/drivers/dri/s3v/s3v_context.h
deleted file mode 100644 (file)
index 671ba90..0000000
+++ /dev/null
@@ -1,443 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#ifndef _S3V_CONTEXT_H_
-#define _S3V_CONTEXT_H_
-
-#include "dri_util.h"
-
-#include "s3v_dri.h"
-#include "s3v_regs.h"
-#include "s3v_macros.h"
-#include "s3v_screen.h"
-#include "main/colormac.h"
-#include "main/macros.h"
-#include "main/mtypes.h"
-#include "drm.h"
-#include "main/mm.h"
-#include "drirenderbuffer.h"
-
-/* Flags for context */
-#define S3V_FRONT_BUFFER    0x00000001
-#define S3V_BACK_BUFFER     0x00000002
-#define S3V_DEPTH_BUFFER    0x00000004
-
-       /* FIXME: check */
-#define S3V_MAX_TEXTURE_SIZE    2048
-
-/* These are the minimum requirements and should probably be increased */
-#define MAX_MODELVIEW_STACK    16
-#define MAX_PROJECTION_STACK    2
-#define MAX_TEXTURE_STACK       2
-
-extern void            s3vDDUpdateHWState(GLcontext *ctx);
-extern s3vScreenPtr    s3vCreateScreen(__DRIscreenPrivate *sPriv);
-extern void            s3vDestroyScreen(__DRIscreenPrivate *sPriv);
-extern GLboolean       s3vCreateContext(const __GLcontextModes *glVisual,
-                                     __DRIcontextPrivate *driContextPriv,
-                                     void *sharedContextPrivate);
-
-#define S3V_UPLOAD_ALL                 0xffffffff
-/* #define S3V_UPLOAD_CLIPRECTS                0x00000002 */
-#define S3V_UPLOAD_ALPHA               0x00000004
-#define S3V_UPLOAD_BLEND               0x00000008
-#define S3V_UPLOAD_DEPTH               0x00000010
-#define S3V_UPLOAD_VIEWPORT            0x00000020
-#define S3V_UPLOAD_SHADE               0x00000040
-#define S3V_UPLOAD_CLIP                        0x00000080
-#define S3V_UPLOAD_MASKS               0x00000100
-#define S3V_UPLOAD_WINDOW              0x00000200 /* defunct */
-#define S3V_UPLOAD_GEOMETRY            0x00000400
-#define S3V_UPLOAD_POLYGON             0x00000800
-#define S3V_UPLOAD_DITHER              0x00001000
-#define S3V_UPLOAD_LOGICOP             0x00002000
-#define S3V_UPLOAD_FOG                 0x00004000
-#define S3V_UPLOAD_LIGHT               0x00008000
-#define S3V_UPLOAD_CONTEXT             0x00010000
-#define S3V_UPLOAD_TEX0                        0x00020000
-#define S3V_UPLOAD_STIPPLE             0x00040000
-#define S3V_UPLOAD_TRANSFORM           0x00080000
-#define S3V_UPLOAD_LINEMODE            0x00100000
-#define S3V_UPLOAD_POINTMODE           0x00200000
-#define S3V_UPLOAD_TRIMODE             0x00400000
-
-#define S3V_NEW_CLIP                   0x00000001
-#define S3V_NEW_WINDOW                 0x00000002
-#define S3V_NEW_CONTEXT                        0x00000004
-#define S3V_NEW_TEXTURE                        0x00000008 /* defunct */
-#define S3V_NEW_ALPHA                  0x00000010
-#define S3V_NEW_DEPTH                  0x00000020
-#define S3V_NEW_MASKS                  0x00000040
-#define S3V_NEW_POLYGON                        0x00000080
-#define S3V_NEW_CULL                   0x00000100
-#define S3V_NEW_LOGICOP                        0x00000200
-#define S3V_NEW_FOG                    0x00000400
-#define S3V_NEW_LIGHT                  0x00000800
-#define S3V_NEW_STIPPLE                        0x00001000
-#define S3V_NEW_ALL                    0xffffffff
-
-#define S3V_FALLBACK_TRI               0x00000001
-#define S3V_FALLBACK_TEXTURE           0x00000002
-
-struct s3v_context;
-typedef struct s3v_context s3vContextRec;
-typedef struct s3v_context *s3vContextPtr;
-typedef struct s3v_texture_object_t *s3vTextureObjectPtr;
-
-#define VALID_S3V_TEXTURE_OBJECT(tobj)  (tobj) 
-
-#define S3V_TEX_MAXLEVELS 12
-
-/* For shared texture space managment, these texture objects may also
- * be used as proxies for regions of texture memory containing other
- * client's textures.  Such proxy textures (not to be confused with GL
- * proxy textures) are subject to the same LRU aging we use for our
- * own private textures, and thus we have a mechanism where we can
- * fairly decide between kicking out our own textures and those of
- * other clients.
- *
- * Non-local texture objects have a valid MemBlock to describe the
- * region managed by the other client, and can be identified by
- * 't->globj == 0' 
- */
-struct s3v_texture_object_t {
-       struct s3v_texture_object_t *next, *prev;
-
-       GLuint age;   
-       struct gl_texture_object *globj;
-     
-       int Pitch;
-       int Height;
-       int WidthLog2;
-       int texelBytes;
-       int totalSize;
-       int bound;
-
-       struct mem_block *MemBlock;   
-       GLuint BufAddr;
-   
-       GLuint min_level;
-       GLuint max_level;
-       GLuint dirty_images;
-
-       GLint firstLevel, lastLevel;  /* upload tObj->Image[first .. lastLevel] */
-
-       struct { 
-               const struct gl_texture_image *image;
-               int offset;             /* into BufAddr */
-               int height;
-               int internalFormat;
-       } image[S3V_TEX_MAXLEVELS];
-
-       GLuint TextureCMD;
-
-       GLuint TextureColorMode;
-       GLuint TextureFilterMode;
-       GLuint TextureBorderColor;
-       GLuint TextureWrap;
-       GLuint TextureMipSize;
-
-       GLuint TextureBaseAddr[S3V_TEX_MAXLEVELS];
-       GLuint TextureFormat;
-       GLuint TextureReadMode;
-};             
-
-#define S3V_NO_PALETTE        0x0
-#define S3V_USE_PALETTE       0x1
-#define S3V_UPDATE_PALETTE    0x2
-#define S3V_FALLBACK_PALETTE  0x4
-
-void s3vUpdateTextureState( GLcontext *ctx );
-
-void s3vDestroyTexObj( s3vContextPtr vmesa, s3vTextureObjectPtr t);
-void s3vUploadTexImages( s3vContextPtr vmesa, s3vTextureObjectPtr t );
-
-void s3vResetGlobalLRU( s3vContextPtr vmesa );
-void s3vTexturesGone( s3vContextPtr vmesa, 
-                      GLuint start, GLuint end, 
-                      GLuint in_use ); 
-
-void s3vEmitHwState( s3vContextPtr vmesa );
-void s3vGetLock( s3vContextPtr vmesa, GLuint flags );
-void s3vInitExtensions( GLcontext *ctx );
-void s3vInitDriverFuncs( GLcontext *ctx );
-void s3vSetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
-void s3vInitState( s3vContextPtr vmesa );
-void s3vInitHW( s3vContextPtr vmesa );
-void s3vInitStateFuncs( GLcontext *ctx );
-void s3vInitTextureFuncs( GLcontext *ctx );
-void s3vInitTriFuncs( GLcontext *ctx );
-
-void s3vUpdateWindow( GLcontext *ctx );
-void s3vUpdateViewportOffset( GLcontext *ctx );
-
-void s3vPrintLocalLRU( s3vContextPtr vmesa );
-void s3vPrintGlobalLRU( s3vContextPtr vmesa );
-
-extern void s3vFallback( s3vContextPtr vmesa, GLuint bit, GLboolean mode );
-#define FALLBACK( imesa, bit, mode ) s3vFallback( imesa, bit, mode )
-
-/* Use the templated vertex formats.  Only one of these is used in s3v.
- */
-#define TAG(x) s3v##x
-#include "tnl_dd/t_dd_vertex.h"
-#undef TAG
-
-typedef void (*s3v_quad_func)( s3vContextPtr, 
-                               const s3vVertex *, 
-                               const s3vVertex *,
-                               const s3vVertex *,
-                               const s3vVertex * );
-typedef void (*s3v_tri_func)( s3vContextPtr, 
-                               const s3vVertex *, 
-                               const s3vVertex *,
-                               const s3vVertex * );
-typedef void (*s3v_line_func)( s3vContextPtr, 
-                               const s3vVertex *, 
-                               const s3vVertex * );
-typedef void (*s3v_point_func)( s3vContextPtr, 
-                                const s3vVertex * );
-
-
-/* static void s3v_lines_emit(GLcontext *ctx, GLuint start, GLuint end); */
-typedef void (*emit_func)( GLcontext *, GLuint, GLuint);
-
-struct s3v_context {
-       GLcontext               *glCtx;         /* Mesa context */
-
-       __DRIcontextPrivate     *driContext;
-       __DRIscreenPrivate      *driScreen;
-       __DRIdrawablePrivate    *driDrawable;
-
-       GLuint new_gl_state;
-       GLuint new_state;
-       GLuint dirty;
-
-       S3VSAREAPtr     sarea; 
-
-       /* Temporaries for translating away float colors
-        */
-       struct gl_client_array UbyteColor;
-       struct gl_client_array UbyteSecondaryColor;
-
-       /* Mirrors of some DRI state
-        */
-
-       drm_context_t hHWContext;
-       drmLock *driHwLock;
-       int driFd;
-
-       GLuint numClipRects;            /* Cliprects for the draw buffer */
-       drm_clip_rect_t *pClipRects;
-
-       GLuint* buf;                    /* FIXME */
-       GLuint* _buf[2];
-       int             _bufNum;
-       int             bufIndex[2];
-       int             bufSize;
-       int             bufCount;
-
-       s3vScreenPtr    s3vScreen;              /* Screen private DRI data */
-
-       int             drawOffset;
-       int             readOffset;
-
-       s3v_point_func  draw_point;
-       s3v_line_func   draw_line;
-       s3v_tri_func    draw_tri;
-       s3v_quad_func   draw_quad;
-
-       GLuint Fallback;
-       GLuint RenderIndex;
-       GLuint SetupNewInputs;
-       GLuint SetupIndex;
-
-       GLuint vertex_format;
-       GLuint vertex_size;
-       GLuint vertex_stride_shift;
-       char *verts;
-
-       GLfloat hw_viewport[16];
-       GLuint hw_primitive;
-       GLenum render_primitive;
-
-       GLfloat depth_scale;
-
-       s3vTextureObjectPtr CurrentTexObj[2];
-       struct s3v_texture_object_t TexObjList;
-       struct s3v_texture_object_t SwappedOut; 
-       GLenum TexEnvImageFmt[2];
-
-       struct mem_block *texHeap;
-
-       int lastSwap;
-       int texAge;
-       int ctxAge;
-       int dirtyAge;
-       int lastStamp;
-
-       /* max was here: don't touch */
-   
-       unsigned int S3V_REG[S3V_REGS_NUM];
-
-       GLuint texMode;
-       GLuint alphaMode;
-       GLuint lightMode;
-
-       GLuint SrcBase;
-       GLuint DestBase;
-       GLuint DestBlit;
-       GLuint ScissorLR;
-       GLuint ScissorTB;
-       GLuint ScissorWH; /* SubScissorWH */ /* RectWH */
-       GLuint FrontStride;
-       GLuint BackStride;
-       GLuint SrcStride;
-       GLuint DestStride;
-       GLuint SrcXY;
-       GLuint DestXY;
-
-       GLuint ClearColor;
-       GLuint Color;
-       GLuint DitherMode;
-       GLuint ClearDepth;
-
-       GLuint TextureBorderColor;
-       GLuint TexOffset;
-       GLuint TexStride;
-
-       GLuint CMD;
-       GLuint prim_cmd;
-       GLuint _tri[2]; /* 0 = gouraud; 1 = tex (lit or unlit) */
-       GLuint alpha_cmd; /* actual alpha cmd */
-       GLuint _alpha[2];
-       GLuint _alpha_tex; /* tex alpha type */
-       /* (3d_mode) 0 = 3d line/gourad tri; 1 = 3d tex tri */
-       GLuint _3d_mode;
-       
-       GLfloat backface_sign;
-       GLfloat cull_zero;
-
-       int restore_primitive;
-
-/* *** 2check *** */
-
-       GLuint          FogMode;
-       GLuint          AreaStippleMode;
-       GLuint          LBReadFormat;
-       GLuint          LBWriteFormat;
-       GLuint          LineMode;
-       GLuint          PointMode;
-       GLuint          TriangleMode;
-       GLuint          AntialiasMode;
-       GLfloat         ViewportScaleX;
-       GLfloat         ViewportScaleY;
-       GLfloat         ViewportScaleZ;
-       GLfloat         ViewportOffsetX;
-       GLfloat         ViewportOffsetY;
-       GLfloat         ViewportOffsetZ;
-       int             MatrixMode;
-       int             DepthMode;
-       int             TransformMode;
-       int             LBReadMode;
-       int             FBReadMode;
-       int             FBWindowBase;
-       int             LBWindowBase;
-       int             ColorDDAMode;
-       int             GeometryMode;
-       int             AlphaTestMode;
-       int             AlphaBlendMode;
-       int             AB_FBReadMode;
-       int             AB_FBReadMode_Save;
-       int             DeltaMode;
-       int             ColorMaterialMode;
-       int             FBHardwareWriteMask;
-       int             MaterialMode;
-       int             NormalizeMode;
-       int             LightingMode;
-       int             Light0Mode;
-       int             Light1Mode;
-       int             Light2Mode;
-       int             Light3Mode;
-       int             Light4Mode;
-       int             Light5Mode;
-       int             Light6Mode;
-       int             Light7Mode;
-       int             Light8Mode;
-       int             Light9Mode;
-       int             Light10Mode;
-       int             Light11Mode;
-       int             Light12Mode;
-       int             Light13Mode;
-       int             Light14Mode;
-       int             Light15Mode;
-       int             LogicalOpMode;
-       int             ScissorMode;
-       int             ScissorMaxXY;
-       int             ScissorMinXY;
-       int             Window; /* GID part probably should be in draw priv */
-       int             WindowOrigin;
-       int             x, y, w, h; /* Probably should be in drawable priv */
-       int             FrameCount; /* Probably should be in drawable priv */
-       int             NotClipped; /* Probably should be in drawable priv */
-       int             WindowChanged; /* Probably should be in drawabl... */
-       int             Flags;
-       int             EnabledFlags;
-       int             DepthSize;
-       int             Begin;
-       GLenum          ErrorValue;
-       int             Texture1DEnabled;
-       int             Texture2DEnabled;
-
-       float           ModelView[16];
-       float           Proj[16];
-       float           ModelViewProj[16];
-       float           Texture[16];
-
-       float           ModelViewStack[(MAX_MODELVIEW_STACK-1)*16];
-       int             ModelViewCount;
-       float           ProjStack[(MAX_PROJECTION_STACK-1)*16];
-       int             ProjCount;
-       float           TextureStack[(MAX_TEXTURE_STACK-1)*16];
-       int             TextureCount;
-};
-
-#define S3VIRGEPACKCOLOR555( r, g, b, a ) \
-    ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \
-     ((a) ? 0x8000 : 0))
-
-#define S3VIRGEPACKCOLOR565( r, g, b ) \
-    ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
-
-#define S3VIRGEPACKCOLOR888( r, g, b ) \
-    (((r) << 16) | ((g) << 8) | (b))
-
-#define S3VIRGEPACKCOLOR8888( r, g, b, a ) \
-    (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
-
-#define S3VIRGEPACKCOLOR4444( r, g, b, a ) \
-    ((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4))
-
-static INLINE GLuint s3vPackColor( GLuint cpp,
-                                   GLubyte r, GLubyte g,
-                                   GLubyte b, GLubyte a )
-{
-       unsigned int ret;
-       DEBUG(("cpp = %i, r=0x%x, g=0x%x, b=0x%x, a=0x%x\n", cpp, r, g, b, a));
-
-       switch ( cpp ) {
-       case 2:
-               ret = S3VIRGEPACKCOLOR555( r, g, b, a );
-               DEBUG(("ret = 0x%x\n", ret));
-               return ret;
-       case 4:
-               return PACK_COLOR_8888( a, r, g, b );
-       default:
-       return 0;
-       }
-}
-
-#define S3V_CONTEXT(ctx)       ((s3vContextPtr)(ctx->DriverCtx))
-
-#endif /* _S3V_CONTEXT_H_ */
diff --git a/src/mesa/drivers/dri/s3v/s3v_dd.c b/src/mesa/drivers/dri/s3v/s3v_dd.c
deleted file mode 100644 (file)
index e340116..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#include "s3v_context.h"
-#include "s3v_vb.h"
-#include "s3v_lock.h"
-#if defined(USE_X86_ASM)
-#include "x86/common_x86_asm.h"
-#endif
-
-#include "main/context.h"
-#include "main/framebuffer.h"
-#include "swrast/swrast.h"
-
-#define S3V_DATE "20020207"
-
-
-/* Return the width and height of the current color buffer.
- */
-static void s3vDDGetBufferSize( GLframebuffer *buffer,
-                                GLuint *width, GLuint *height )
-{
-   GET_CURRENT_CONTEXT(ctx);
-   s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-
-/* S3VHW_LOCK( vmesa ); */
-   *width  = vmesa->driDrawable->w;
-   *height = vmesa->driDrawable->h;
-/* S3VHW_UNLOCK( vmesa ); */
-}
-
-
-/* Return various strings for glGetString().
- */
-static const GLubyte *s3vDDGetString( GLcontext *ctx, GLenum name )
-{
-   static char buffer[128];
-
-   switch ( name ) {
-   case GL_VENDOR:
-      return (GLubyte *)"Max Lingua (ladybug)";
-
-   case GL_RENDERER:
-      sprintf( buffer, "Mesa DRI S3 Virge " S3V_DATE );
-
-      /* Append any CPU-specific information.
-       */
-#ifdef USE_X86_ASM
-      if ( _mesa_x86_cpu_features ) {
-        strncat( buffer, " x86", 4 );
-      
-}
-#ifdef USE_MMX_ASM
-      if ( cpu_has_mmx ) {
-        strncat( buffer, "/MMX", 4 );
-      }
-#endif
-#ifdef USE_3DNOW_ASM
-      if ( cpu_has_3dnow ) {
-        strncat( buffer, "/3DNow!", 7 );
-      }
-#endif
-#ifdef USE_SSE_ASM
-      if ( cpu_has_xmm ) {
-        strncat( buffer, "/SSE", 4 );
-      }
-#endif
-#endif
-      return (GLubyte *)buffer;
-
-   default:
-      return NULL;
-   }
-}
-
-/* Enable the extensions supported by this driver.
- */
-void s3vInitExtensions( GLcontext *ctx )
-{
-   /* None... */
-}
-
-/* Initialize the driver's misc functions.
- */
-void s3vInitDriverFuncs( GLcontext *ctx )
-{
-   ctx->Driver.GetBufferSize = s3vDDGetBufferSize;
-   ctx->Driver.GetString = s3vDDGetString;
-}
diff --git a/src/mesa/drivers/dri/s3v/s3v_dri.h b/src/mesa/drivers/dri/s3v/s3v_dri.h
deleted file mode 100644 (file)
index 339c579..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#ifndef _S3V_DRI
-#define _S3V_DRI
-
-#include "s3v_common.h"
-
-#define S3V_MAX_DRAWABLES (S3V_DMA_BUF_NR/2) /* 32 */ /* 256 */ /* FIXME */
-
-typedef struct
-{
-   int deviceID;
-   int width;
-   int height;
-   int mem;
-   int cpp;
-   int bitsPerPixel;
-
-   int fbOffset;
-   int fbStride;
-
-   int logTextureGranularity;
-   int textureOffset; 
-
-   drm_handle_t regs;
-   drmSize regsSize;
-
-   unsigned int sarea_priv_offset;
-/*
-   drmAddress regsMap;
-
-   drmSize textureSize;
-   drm_handle_t textures;
-*/
-
-#if 0
-   drm_handle_t agp_buffers;
-   drmSize agp_buf_size;
-#endif
-
-/*
-   drmBufMapPtr drmBufs;
-   int irq;
-   unsigned int sarea_priv_offset;
-*/
-
-/* FIXME: cleanup ! */
-
-   drmSize            registerSize; /* == S3V_MMIO_REGSIZE */
-   drm_handle_t       registerHandle;
-
-   drmSize            pciSize;
-   drm_handle_t       pciMemHandle;
-
-   drmSize            frontSize;    /* == videoRambytes */
-/* drm_handle_t       frontHandle; */
-   unsigned long      frontOffset;  /* == fbOffset */
-   int                frontPitch;
-/* unsigned char      *front; */
-
-   unsigned int       bufferSize; /* size of depth/back buffer */
-
-   drmSize            backSize;
-/* drm_handle_t       backHandle; */
-   unsigned long      backOffset;
-   int                backPitch;
-/* unsigned char      *back; */
-
-   drmSize            depthSize;
-/* drm_handle_t       depthHandle; */
-   unsigned long      depthOffset;
-   int                depthPitch;
-/* unsigned char      *depth; */
-
-   drmSize            texSize;
-/* drm_handle_t       texHandle; */
-   unsigned long      texOffset;
-   int                texPitch;
-/* unsigned char      *tex; */
-
-   drmSize            dmaBufSize;       /* Size of buffers (in bytes) */
-   drm_handle_t       dmaBufHandle;     /* Handle from drmAddMap */
-   unsigned long      dmaBufOffset;     /* Offset/Start */
-   int                dmaBufPitch;      /* Pitch */
-   unsigned char      *dmaBuf;          /* Map */
-   int                bufNumBufs;       /* Number of buffers */
-   drmBufMapPtr       buffers;          /* Buffer map */
-
-} S3VDRIRec, *S3VDRIPtr;
-
-/* WARNING: Do not change the SAREA structure without changing the kernel
- * as well */
-
-typedef struct {
-   unsigned char next, prev; /* indices to form a circular LRU  */
-   unsigned char in_use;   /* owned by a client, or free? */
-   int age;                /* tracked by clients to update local LRU's */
-} S3VTexRegionRec, *S3VTexRegionPtr;
-
-typedef struct {
-   unsigned int nbox;
-   drm_clip_rect_t boxes[S3V_NR_SAREA_CLIPRECTS];
-   
-   /* Maintain an LRU of contiguous regions of texture space.  If
-    * you think you own a region of texture memory, and it has an
-    * age different to the one you set, then you are mistaken and
-    * it has been stolen by another client.  If global texAge
-    * hasn't changed, there is no need to walk the list.
-    *
-    * These regions can be used as a proxy for the fine-grained
-    * texture information of other clients - by maintaining them
-    * in the same lru which is used to age their own textures,
-    * clients have an approximate lru for the whole of global
-    * texture space, and can make informed decisions as to which
-    * areas to kick out.  There is no need to choose whether to
-    * kick out your own texture or someone else's - simply eject
-    * them all in LRU order.  
-    */
-   S3VTexRegionRec texList[S3V_NR_TEX_REGIONS+1]; /* Last elt is sentinal */
-   
-   int texAge;             /* last time texture was uploaded */
-   
-   int last_enqueue;       /* last time a buffer was enqueued */
-   int last_dispatch;      /* age of the most recently dispatched buffer */
-   int last_quiescent;     /*  */
-   
-   int ctxOwner;           /* last context to upload state */
-} S3VSAREARec, *S3VSAREAPtr;
-
-typedef struct {
-  /* Nothing here yet */
-  int dummy;
-} S3VConfigPrivRec, *S3VConfigPrivPtr;
-
-typedef struct {
-  /* Nothing here yet */
-  int dummy;
-} S3VDRIContextRec, *S3VDRIContextPtr;
-
-
-#endif
diff --git a/src/mesa/drivers/dri/s3v/s3v_inithw.c b/src/mesa/drivers/dri/s3v/s3v_inithw.c
deleted file mode 100644 (file)
index bdc9eff..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#include <sys/ioctl.h>
-
-#include "s3v_context.h"
-
-void s3vInitHW( s3vContextPtr vmesa )
-{
-       int i;
-       static short _reset = 1;
-
-       DEBUG(("vmesa->driDrawable = %p\n", vmesa->driDrawable));
-       DEBUG(("stride = %i\n",
-               vmesa->driScreen->fbWidth*vmesa->s3vScreen->cpp));
-       DEBUG(("frontOffset = 0x%x\n", vmesa->s3vScreen->frontOffset));
-       DEBUG(("backOffset = 0x%x\n", vmesa->s3vScreen->backOffset));
-       DEBUG(("depthOffset = 0x%x\n", vmesa->s3vScreen->depthOffset));
-       DEBUG(("textureOffset = 0x%x\n", vmesa->s3vScreen->texOffset));
-
-/*     if (_reset) { */
-/*     ioctl(vmesa->driFd, 0x4a); */
-               ioctl(vmesa->driFd, 0x41); /* reset */
-               _reset = 0;
-/*     ioctl(vmesa->driFd, 0x4c); */
-/*     } */
-
-       /* FIXME */
-       switch (vmesa->s3vScreen->cpp) {
-               case 2:
-                       break;
-               case 4:
-                       break;
-       }
-
-       /* FIXME for stencil, gid, etc */
-       switch (vmesa->DepthSize) {
-               case 15:
-               case 16:
-                       break;
-               case 24:
-                       break;
-               case 32:
-                       break;
-       }
-
-       vmesa->FogMode = 1;
-       vmesa->ClearDepth = 0xffff;
-       vmesa->x = 0;
-       vmesa->y = 0;
-       vmesa->w = 0;
-       vmesa->h = 0;
-       vmesa->FrameCount = 0;
-       vmesa->MatrixMode = GL_MODELVIEW;
-       vmesa->ModelViewCount = 0;
-       vmesa->ProjCount = 0;
-       vmesa->TextureCount = 0;
-
-
-       /* FIXME: do we need the following? */
-
-       for (i = 0; i < 16; i++)
-               if (i % 5 == 0)
-                       vmesa->ModelView[i] =
-                       vmesa->Proj[i] =
-                       vmesa->ModelViewProj[i] =
-                       vmesa->Texture[i] = 1.0;
-               else
-                       vmesa->ModelView[i] =
-                       vmesa->Proj[i] =
-                       vmesa->ModelViewProj[i] =
-                       vmesa->Texture[i] = 0.0;
-
-       vmesa->LBWindowBase = vmesa->driScreen->fbWidth *
-                               (vmesa->driScreen->fbHeight - 1);
-       vmesa->FBWindowBase = vmesa->driScreen->fbWidth * 
-                               (vmesa->driScreen->fbHeight - 1);
-}
diff --git a/src/mesa/drivers/dri/s3v/s3v_lock.c b/src/mesa/drivers/dri/s3v/s3v_lock.c
deleted file mode 100644 (file)
index 52bb87e..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#include "s3v_context.h"
-
-#if DEBUG_LOCKING
-char *prevLockFile = NULL;
-int prevLockLine = 0;
-#endif
-
-
-/* Update the hardware state.  This is called if another context has
- * grabbed the hardware lock, which includes the X server.  This
- * function also updates the driver's window state after the X server
- * moves, resizes or restacks a window -- the change will be reflected
- * in the drawable position and clip rects.  Since the X server grabs
- * the hardware lock when it changes the window state, this routine will
- * automatically be called after such a change.
- */
-void s3vGetLock( s3vContextPtr vmesa, GLuint flags )
-{
-   __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
-/*   __DRIscreenPrivate *sPriv = vmesa->driScreen; */
-
-   printf("s3vGetLock <- ***\n");
-
-   drmGetLock( vmesa->driFd, vmesa->hHWContext, flags );
-
-   /* The window might have moved, so we might need to get new clip
-    * rects.
-    *
-    * NOTE: This releases and regrabs the hw lock to allow the X server
-    * to respond to the DRI protocol request for new drawable info.
-    * Since the hardware state depends on having the latest drawable
-    * clip rects, all state checking must be done _after_ this call.
-    */
-   /* DRI_VALIDATE_DRAWABLE_INFO( vmesa->display, sPriv, dPriv ); */
-
-   if ( vmesa->lastStamp != dPriv->lastStamp ) {
-      vmesa->lastStamp = dPriv->lastStamp;
-      vmesa->new_state |= S3V_NEW_WINDOW | S3V_NEW_CLIP;
-   }
-
-   vmesa->numClipRects = dPriv->numClipRects;
-   vmesa->pClipRects = dPriv->pClipRects;
-
-#if 0
-   vmesa->dirty = ~0;
-
-   if ( sarea->ctxOwner != vmesa->hHWContext ) {
-      sarea->ctxOwner = vmesa->hHWContext;
-      vmesa->dirty = S3V_UPLOAD_ALL;
-   }
-
-   for ( i = 0 ; i < vmesa->lastTexHeap ; i++ ) {
-      if ( sarea->texAge[i] != vmesa->lastTexAge[i] ) {
-        s3vAgeTextures( vmesa, i );
-      }
-   }
-#endif
-}
diff --git a/src/mesa/drivers/dri/s3v/s3v_lock.h b/src/mesa/drivers/dri/s3v/s3v_lock.h
deleted file mode 100644 (file)
index c39d24a..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#ifndef __S3V_LOCK_H__
-#define __S3V_LOCK_H__
-
-#include <sys/ioctl.h>
-
-extern void s3vGetLock( s3vContextPtr vmesa, GLuint flags );
-
-/* Turn DEBUG_LOCKING on to find locking conflicts.
- */
-#define DEBUG_LOCKING  0
-
-#if DEBUG_LOCKING
-extern char *prevLockFile;
-extern int prevLockLine;
-
-#define DEBUG_LOCK() \
-   do {        \
-      prevLockFile = (__FILE__); \
-      prevLockLine = (__LINE__); \
-   } while (0)
-
-#define DEBUG_RESET() \
-   do {        \
-      prevLockFile = 0;        \
-      prevLockLine = 0;        \
-   } while (0)
-
-#define DEBUG_CHECK_LOCK() \
-   do {        \
-      if ( prevLockFile ) { \
-        fprintf( stderr, \
-                 "LOCK SET!\n\tPrevious %s:%d\n\tCurrent: %s:%d\n", \
-                 prevLockFile, prevLockLine, __FILE__, __LINE__ );     \
-        exit(1); \
-      }        \
-   } while (0)
-
-#else
-
-#define DEBUG_LOCK()
-#define DEBUG_RESET()
-#define DEBUG_CHECK_LOCK()
-
-#endif
-
-/*
- * !!! We may want to separate locks from locks with validation.  This
- * could be used to improve performance for those things commands that
- * do not do any drawing !!!
- */
-
-/* Lock the hardware and validate our state.
- */
-#define LOCK_HARDWARE( vmesa ) \
-   do {        \
-      char __ret = 0; \
-      DEBUG_CHECK_LOCK(); \
-      DRM_CAS( vmesa->driHwLock, vmesa->hHWContext, \
-              (DRM_LOCK_HELD | vmesa->hHWContext), __ret ); \
-      if ( __ret ) \
-         s3vGetLock( vmesa, 0 ); \
-      DEBUG_LOCK(); \
-   } while (0)
-
-/* Unlock the hardware.
- */
-#define UNLOCK_HARDWARE( vmesa ) \
-   do { \
-      DRM_UNLOCK( vmesa->driFd, \
-                 vmesa->driHwLock, \
-                 vmesa->hHWContext ); \
-      DEBUG_RESET(); \
-   } while (0)
-
-#define S3VHW_LOCK( vmesa )    \
-   DRM_UNLOCK(vmesa->driFd, vmesa->driHwLock, vmesa->hHWContext); \
-   DRM_SPINLOCK(&vmesa->driScreen->pSAREA->drawable_lock, \
-                vmesa->driScreen->drawLockID); \
-   /* VALIDATE_DRAWABLE_INFO_NO_LOCK(vmesa); */
-
-#define S3VHW_UNLOCK( vmesa ) \
-    DRM_SPINUNLOCK(&vmesa->driScreen->pSAREA->drawable_lock, \
-                  vmesa->driScreen->drawLockID); \
-    /* VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(vmesa); */
-
-#define S3V_SIMPLE_LOCK( vmesa ) \
-       ioctl(vmesa->driFd, 0x4a) 
-
-#define S3V_SIMPLE_FLUSH_LOCK( vmesa ) \
-       ioctl(vmesa->driFd, 0x4b) 
-
-#define S3V_SIMPLE_UNLOCK( vmesa ) \
-       ioctl(vmesa->driFd, 0x4c) 
-
-#endif /* __S3V_LOCK_H__ */
diff --git a/src/mesa/drivers/dri/s3v/s3v_macros.h b/src/mesa/drivers/dri/s3v/s3v_macros.h
deleted file mode 100644 (file)
index 7e9b452..0000000
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#ifndef _S3V_MACROS_H_
-#define _S3V_MACROS_H_
-
-/**************/
-/* DRI macros */
-/**************/
-
-#define GENERIC_DEBUG 0
-#define FLOW_DEBUG    0
-#define DMABUFS_DEBUG 0
-
-/* Note: The argument to DEBUG*() _must_ be enclosed in parenthesis */
-
-#if (GENERIC_DEBUG || FLOW_DEBUG || DMABUFS_DEBUG)
-#include <stdio.h>
-#endif
-
-#undef DEBUG
-#if GENERIC_DEBUG
-#define DEBUG(str) printf str
-#else
-#define DEBUG(str)
-#endif
-
-#if FLOW_DEBUG
-#define DEBUG_WHERE(str) printf str
-#else
-#define DEBUG_WHERE(str)
-#endif
-
-#if DMABUFS_DEBUG
-#define DEBUG_BUFS(str) printf str
-#else
-#define DEBUG_BUFS(str)
-#endif
-
-
-#if 0
-#define S3V_DMA_SEND_FLAGS    DRM_DMA_PRIORITY
-#define S3V_DMA_SEND_FLAGS    DRM_DMA_BLOCK
-#else
-#define S3V_DMA_SEND_FLAGS    0
-#endif
-
-#if 0
-#define S3V_DMA_GET_FLAGS     \
-    (DRM_DMA_SMALLER_OK | DRM_DMA_LARGER_OK | DRM_DMA_WAIT)
-#else
-#define S3V_DMA_GET_FLAGS     DRM_DMA_WAIT
-#endif
-
-
-#define DMAOUT_CHECK(reg,len) \
-do { \
-       DEBUG(("DMAOUT_CHECK: reg = 0x%x\n", S3V_##reg##_REG)); \
-       DEBUG_BUFS(("DMAOUT_CHECK (was): ")); \
-       DEBUG_BUFS(("vmesa->bufCount=%i of vmesa->bufSize=%i\n", \
-               vmesa->bufCount, vmesa->bufSize)); \
-       /* FIXME: > or >= */ \
-       if (vmesa->bufCount+(len+1) >= vmesa->bufSize) \
-               DMAFLUSH(); \
-\
-       vmesa->bufCount += (len+1); \
-       DEBUG_BUFS(("DMAOUT_CHECK (is): vmesa->bufCount=%i len=%i, reg=%x\n", \
-               vmesa->bufCount, len, S3V_##reg##_REG)); \
-       DMAOUT( ((len & 0xffff) | ((S3V_##reg##_REG & 0xfffc) << 14)) );  \
-} while (0)
-
-#define DMAOUT(val) \
-do { \
-       *(vmesa->buf++)=val; \
-       DEBUG_BUFS(("DMAOUT: val=0x%x\n", (unsigned int)val)); \
-} while(0)
-
-#define DMAFINISH()    \
-do { \
-       /* NOTE: it does nothing - it just prints some summary infos */ \
-       DEBUG(("DMAFINISH: vmesa->bufCount=%i\n", vmesa->bufCount)); \
-       DEBUG(("buf: index=%i; addr=%p\n", vmesa->bufIndex[vmesa->_bufNum], \
-       vmesa->s3vScreen->bufs->list[vmesa->bufIndex[vmesa->_bufNum]].address)); \
-} while(0)
-
-#define DMAFLUSH() \
-do { \
-       if (vmesa->bufCount) { \
-               SEND_DMA(vmesa->driFd, vmesa->hHWContext, 1, \
-                       &vmesa->bufIndex[vmesa->_bufNum], &vmesa->bufCount); \
-/*
-               GET_DMA(vmesa->driFd, vmesa->hHWContext, 1, \
-                       &vmesa->bufIndex, &vmesa->bufSize); \
-*/ \
-               vmesa->_bufNum = !(vmesa->_bufNum); \
-               vmesa->buf = vmesa->_buf[vmesa->_bufNum]; \
-/* 
-               vmesa->buf = \
-                       vmesa->s3vScreen->bufs->list[vmesa->bufIndex].address; \
-*/ \
-               vmesa->bufCount = 0; \
-       } \
-} while (0)
-
-#define CMDCHANGE() \
-do { \
-       DMAOUT_CHECK(3DTRI_CMDSET, 1); /* FIXME: TRI/LINE */ \
-               DMAOUT(vmesa->CMD); \
-       DMAFINISH(); \
-} while (0)
-
-#ifdef DONT_SEND_DMA
-#define GET_DMA(fd, hHWCtx, n, idx, size)
-#define SEND_DMA(fd, hHWCtx,n, idx, cnt)
-#else
-#define GET_DMA(fd, hHWCtx, n, idx, size) \
-do { \
-       drmDMAReq dma; \
-       int retcode, i; \
-\
-       DEBUG(("GET_DMA: ")); \
-       DEBUG(("req_count=%i; req_list[#0]=%i; req_size[#0]=%i\n", \
-               n, (idx)[n-1], (size)[n-1])); \
-\
-       dma.context       = (hHWCtx); \
-       dma.send_count    = 0; \
-       dma.send_list     = NULL; \
-       dma.send_sizes    = NULL; \
-       dma.flags         = S3V_DMA_GET_FLAGS; \
-       dma.request_count = (n); \
-       dma.request_size  = S3V_DMA_BUF_SZ; \
-       dma.request_list  = (idx); \
-       dma.request_sizes = (size); \
-\
-       do { \
-               if ((retcode = drmDMA((fd), &dma))) { \
-               DEBUG_BUFS(("drmDMA (get) returned %d\n", retcode)); \
-       } \
-} while (!(dma).granted_count); \
-\
-       for (i = 0; i < (n); i++) { \
-               DEBUG(("Got buffer %i (index #%i)\n", (idx)[i], i)); \
-               DEBUG(("of %i bytes (%i words) size\n", \
-                       (size)[i], (size)[i] >>2)); \
-               /* Convert from bytes to words */ \
-               (size)[i] >>= 2; \
-       } \
-} while (0)
-
-#define SEND_DMA(fd, hHWCtx, n, idx, cnt) \
-do { \
-       drmDMAReq dma; \
-       int retcode, i; \
-\
-       DEBUG(("SEND_DMA: ")); \
-       DEBUG(("send_count=%i; send_list[#0]=%i; send_sizes[#0]=%i\n", \
-               n, (idx)[n-1], (cnt)[n-1])); \
-\
-       for (i = 0; i < (n); i++) { \
-               /* Convert from words to bytes */ \
-               (cnt)[i] <<= 2; \
-       } \
-\
-       dma.context       = (hHWCtx); \
-       dma.send_count    = (n); \
-       dma.send_list     = (idx); \
-       dma.send_sizes    = (cnt); \
-       dma.flags         = S3V_DMA_SEND_FLAGS; \
-       dma.request_count = 0; \
-       dma.request_size  = 0; \
-       dma.request_list  = NULL; \
-       dma.request_sizes = NULL; \
-\
-       if ((retcode = drmDMA((fd), &dma))) { \
-               DEBUG_BUFS(("drmDMA (send) returned %d\n", retcode)); \
-       } \
-\
-       for (i = 0; i < (n); i++) { \
-               DEBUG(("Sent buffer %i (index #%i)\n", (idx)[i], i)); \
-               DEBUG(("of %i bytes (%i words) size\n", \
-                       (cnt)[i], (cnt)[i] >>2)); \
-               (cnt)[i] = 0; \
-       } \
-} while (0)
-#endif /* DONT_SEND_DMA */
-
-#define GET_FIRST_DMA(fd, hHWCtx, n, idx, size, buf, cnt, vPriv) \
-do { \
-       int i; \
-       DEBUG_BUFS(("GET_FIRST_DMA\n")); \
-       DEBUG_BUFS(("n=%i idx=%i size=%i\n", n, *idx, *size)); \
-       DEBUG_BUFS(("going to GET_DMA\n")); \
-       GET_DMA(fd, hHWCtx, n, idx, size); \
-       DEBUG_BUFS(("coming from GET_DMA\n")); \
-       DEBUG_BUFS(("n=%i idx=%i size=%i\n", n, (idx)[0], (size)[0])); \
-       for (i = 0; i < (n); i++) { \
-               DEBUG_BUFS(("buf #%i @%p\n", \
-                       i, (vPriv)->bufs->list[(idx)[i]].address)); \
-               (buf)[i] = (vPriv)->bufs->list[(idx)[i]].address; \
-               (cnt)[i] = 0; \
-       } \
-       DEBUG(("GOING HOME\n")); \
-} while (0)
-
-/**************************/
-/* generic, global macros */
-/**************************/
-
-#define CALC_LOG2(l2,s) \
-do { \
-       int __s = s; \
-       l2 = 0; \
-       while (__s > 1) { ++l2; __s >>= 1; } \
-} while (0)
-
-#define PrimType_Null               0x00000000
-#define PrimType_Points             0x10000000
-#define PrimType_Lines              0x20000000
-#define PrimType_LineLoop           0x30000000
-#define PrimType_LineStrip          0x40000000
-#define PrimType_Triangles          0x50000000
-#define PrimType_TriangleStrip      0x60000000
-#define PrimType_TriangleFan        0x70000000
-#define PrimType_Quads              0x80000000
-#define PrimType_QuadStrip          0x90000000
-#define PrimType_Polygon            0xa0000000
-#define PrimType_Mask               0xf0000000
-
-#endif /* _S3V_MACROS_H_ */
diff --git a/src/mesa/drivers/dri/s3v/s3v_regs.h b/src/mesa/drivers/dri/s3v/s3v_regs.h
deleted file mode 100644 (file)
index 26a7c54..0000000
+++ /dev/null
@@ -1,367 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#ifndef _S3V_REG_H
-#define _S3V_REG_H
-
-#define S3V_REGS_NUM 256
-
-/************
- * DMA REGS *
- ************/
-
-#define S3V_DMA_ID                             0
-#define S3V_DMA_REG                            0x8590
-#define S3V_DMA_WRITEP_ID                      1
-#define S3V_DMA_WRITEP_REG                     0x8594
-#define S3V_DMA_READP_ID                       2
-#define S3V_DMA_READP_REG                      0x8598
-#define S3V_DMA_ENABLE_ID                      3
-#define S3V_DMA_ENABLE_REG                     0x859C
-#define S3V_DMA_UPDATE_ID                      4
-#define S3V_DMA_UPDATE_REG                     0x10000
-
-/***************
- * STATUS REGS *
- ***************/
-
-#define S3V_STAT_ID                            10
-#define S3V_STAT_REG                           0x8504
-#define S3V_STAT_VSYNC_ID                      11
-#define S3V_STAT_VSYNC_REG                     0x8505
-#define S3V_STAT_3D_DONE_ID                    12
-#define S3V_STAT_3D_DONE_REG                   0x8506
-#define S3V_STAT_FIFO_OVER_ID                  13
-#define S3V_STAT_FIFO_OVER_REG                 0x8508
-#define S3V_STAT_FIFO_EMPTY_ID                 14
-#define S3V_STAT_FIFO_EMPTY_REG                        0x850C
-#define S3V_STAT_HDMA_DONE_ID                  15
-#define S3V_STAT_HDMA_DONE_REG                 0x8514
-#define S3V_STAT_CDMA_DONE_ID                  16
-#define S3V_STAT_CDMA_DONE_REG                 0x8524
-#define S3V_STAT_3D_FIFO_EMPTY_ID              17
-#define S3V_STAT_3D_FIFO_EMPTY_REG             0x8544
-#define S3V_STAT_LPB_ID                                18
-#define S3V_STAT_LPB_REG                       0x8584
-#define S3V_STAT_3D_BUSY_ID                    19
-#define S3V_STAT_3D_BUSY_REG                   0x8704
-
-/***********
- * 2D REGS *
- ***********/
-
-#define S3V_BITBLT_ID                          30
-#define S3V_BITBLT_REG                         0xA400
-#define S3V_BITBLT_SRC_BASE_ID                 31
-#define S3V_BITBLT_SRC_BASE_REG                        0xA4D4
-#define S3V_BITBLT_DEST_BASE_ID                        32
-#define S3V_BITBLT_DEST_BASE_REG               0xA4D8
-#define S3V_BITBLT_CLIP_L_R_ID                 33
-#define S3V_BITBLT_CLIP_L_R_REG                        0xA4DC
-#define S3V_BITBLT_CLIP_T_B_ID                 34
-#define S3V_BITBLT_CLIP_T_B_REG                        0xA4E0
-#define S3V_BITBLT_DEST_SRC_STRIDE_ID          35
-#define S3V_BITBLT_DEST_SRC_STRIDE_REG         0xA4E4
-#define S3V_BITBLT_MONO_PAT0_ID                        36
-#define S3V_BITBLT_MONO_PAT0_REG               0xA4E8
-#define S3V_BITBLT_MONO_PAT1_ID                        37
-#define S3V_BITBLT_MONO_PAT1_REG               0xA4EC
-#define S3V_BITBLT_PAT_BG_COLOR_ID             38
-#define S3V_BITBLT_PAT_BG_COLOR_REG            0xA4F0
-#define S3V_BITBLT_PAT_FG_COLOR_ID             39
-#define S3V_BITBLT_PAT_FG_COLOR_REG            0xA4F4
-#define S3V_BITBLT_CMDSET_ID                   40
-#define S3V_BITBLT_CMDSET_REG                  0xA500
-#define S3V_BITBLT_WIDTH_HEIGHT_ID             41
-#define S3V_BITBLT_WIDTH_HEIGHT_REG            0xA504
-#define S3V_BITBLT_SRC_X_Y_ID                  42
-#define S3V_BITBLT_SRC_X_Y_REG                 0xA508
-#define S3V_BITBLT_DEST_X_Y_ID                 43
-#define S3V_BITBLT_DEST_X_Y_REG                        0xA50C
-#define S3V_2DLINE_ID                          44
-#define S3V_2DLINE_REG                         0xA800
-#define S3V_2DPOLY_ID                          45
-#define S3V_2DPOLY_REG                         0xAC00
-
-/***************
- * 3DLINE REGS *
- ***************/
-/* base regs */
-#define S3V_3DLINE_ID                                  50
-#define S3V_3DLINE_REG                         0xB000
-#define S3V_3DLINE_Z_BASE_ID                           51
-#define S3V_3DLINE_Z_BASE_REG                  0xB0D4
-#define S3V_3DLINE_SRC_BASE_ID                         52   /* it is the same reg */
-#define S3V_3DLINE_SRC_BASE_REG                        0xB0D4
-#define S3V_3DLINE_DEST_BASE_ID                        53
-#define S3V_3DLINE_DEST_BASE_REG               0xB0D8
-#define S3V_3DLINE_CLIP_L_R_ID                         54
-#define S3V_3DLINE_CLIP_L_R_REG                        0xB0DC
-#define S3V_3DLINE_CLIP_T_B_ID                 55
-#define S3V_3DLINE_CLIP_T_B_REG                0xB0E0
-#define S3V_3DLINE_DEST_SRC_STRIDE_ID          56
-#define S3V_3DLINE_DEST_SRC_STRIDE_REG         0xB0E4
-#define S3V_3DLINE_Z_STRIDE_ID                 57
-#define S3V_3DLINE_Z_STRIDE_REG                0xB0E8
-#define S3V_3DLINE_TEX_BASE_ID                 58
-#define S3V_3DLINE_TEX_BASE_REG                0xB0EC
-#define S3V_3DLINE_TEX_B_COLOR_ID              59
-#define S3V_3DLINE_TEX_B_COLOR_REG             0xB0F0
-#define S3V_3DLINE_FOG_COLOR_ID                60
-#define S3V_3DLINE_FOG_COLOR_REG               0xB0F4
-#define S3V_3DLINE_COLOR0_ID                           61
-#define S3V_3DLINE_COLOR0_REG                  0xB0F8
-#define S3V_3DLINE_COLOR1_ID                   62
-#define S3V_3DLINE_COLOR1_REG                  0xB0FC
-#define S3V_3DLINE_CMDSET_ID                   63
-#define S3V_3DLINE_CMDSET_REG                  0xB100 /* special */
-/* tex regs */
-/* FIXME: shouldn't it be a 1D tex for lines? */
-#define S3V_3DLINE_BASEV_ID                    64
-#define S3V_3DLINE_BASEV_REG                   0xB104 
-#define S3V_3DLINE_BASEU_ID                    65
-#define S3V_3DLINE_BASEU_REG                   0xB108
-#define S3V_3DLINE_WXD_ID                      66
-#define S3V_3DLINE_WXD_REG                             0xB10C
-#define S3V_3DLINE_WYD_ID                      67
-#define S3V_3DLINE_WYD_REG                     0xB110
-#define S3V_3DLINE_WSTART_ID                   68
-#define S3V_3DLINE_WSTART_REG                          0xB114
-#define S3V_3DLINE_DXD_ID                      69
-#define S3V_3DLINE_DXD_REG                     0xB118
-#define S3V_3DLINE_VXD_ID                      70
-#define S3V_3DLINE_VXD_REG                     0xB11C
-#define S3V_3DLINE_UXD_ID                      71
-#define S3V_3DLINE_UXD_REG                     0xB120
-#define S3V_3DLINE_DYD_ID                      72
-#define S3V_3DLINE_DYD_REG                     0xB124
-#define S3V_3DLINE_VYD_ID                      73
-#define S3V_3DLINE_VYD_REG                     0xB128
-#define S3V_3DLINE_UYD_ID                      74
-#define S3V_3DLINE_UYD_REG                     0xB12C
-#define S3V_3DLINE_DSTART_ID                   75
-#define S3V_3DLINE_DSTART_REG                  0xB130
-#define S3V_3DLINE_VSTART_ID                   76
-#define S3V_3DLINE_VSTART_REG                  0xB134
-#define S3V_3DLINE_USTART_ID                   77
-#define S3V_3DLINE_USTART_REG                  0xB138
-/* gourad regs */
-#define S3V_3DLINE_GBD_ID                      78
-#define S3V_3DLINE_GBD_REG                     0xB144
-#define S3V_3DLINE_ARD_ID                      79
-#define S3V_3DLINE_ARD_REG                             0xB148
-#define S3V_3DLINE_GS_BS_ID                    80
-#define S3V_3DLINE_GS_BS_REG                   0xB14C
-#define S3V_3DLINE_AS_RS_ID                    81
-#define S3V_3DLINE_AS_RS_REG                   0xB150
-/* vertex regs */
-#define S3V_3DLINE_DZ_ID                       82
-#define S3V_3DLINE_DZ_REG                      0xB158
-#define S3V_3DLINE_ZSTART_ID                   83
-#define S3V_3DLINE_ZSTART_REG                  0xB15C
-#define S3V_3DLINE_XEND0_END1_ID               84
-#define S3V_3DLINE_XEND0_END1_REG              0xB16C
-#define S3V_3DLINE_DX_ID                       85
-#define S3V_3DLINE_DX_REG                      0xB170
-#define S3V_3DLINE_XSTART_ID                   86
-#define S3V_3DLINE_XSTART_REG                  0xB174
-#define S3V_3DLINE_YSTART_ID                   87
-#define S3V_3DLINE_YSTART_REG                          0xB178
-#define S3V_3DLINE_YCNT_ID                     88
-#define S3V_3DLINE_YCNT_REG                    0xB17C
-
-/**************
- * 3DTRI REGS *
- **************/
-/* base regs */
-#define S3V_3DTRI_ID                                   100
-#define S3V_3DTRI_REG                          0xB400
-#define S3V_3DTRI_Z_BASE_ID                    101
-#define S3V_3DTRI_Z_BASE_REG                   0xB4D4
-#define S3V_3DTRI_SRC_BASE_ID                          102 /* it is the same reg */
-#define S3V_3DTRI_SRC_BASE_REG                 0xB4D4
-#define S3V_3DTRI_DEST_BASE_ID                         103
-#define S3V_3DTRI_DEST_BASE_REG                        0xB4D8
-#define S3V_3DTRI_CLIP_L_R_ID                          104
-#define S3V_3DTRI_CLIP_L_R_REG                         0xB4DC
-#define S3V_3DTRI_CLIP_T_B_ID                          105
-#define S3V_3DTRI_CLIP_T_B_REG                 0xB4E0
-#define S3V_3DTRI_DEST_SRC_STRIDE_ID                   106
-#define S3V_3DTRI_DEST_SRC_STRIDE_REG          0xB4E4
-#define S3V_3DTRI_Z_STRIDE_ID                          107
-#define S3V_3DTRI_Z_STRIDE_REG                 0xB4E8
-#define S3V_3DTRI_TEX_BASE_ID                          108
-#define S3V_3DTRI_TEX_BASE_REG                 0xB4EC
-#define S3V_3DTRI_TEX_B_COLOR_ID                       109
-#define S3V_3DTRI_TEX_B_COLOR_REG              0xB4F0
-#define S3V_3DTRI_FOG_COLOR_ID                         110
-#define S3V_3DTRI_FOG_COLOR_REG                        0xB4F4
-#define S3V_3DTRI_COLOR0_ID                            111
-#define S3V_3DTRI_COLOR0_REG                   0xB4F8
-#define S3V_3DTRI_COLOR1_ID                            112
-#define S3V_3DTRI_COLOR1_REG                   0xB4FC
-#define S3V_3DTRI_CMDSET_ID                            113  /* special */
-#define S3V_3DTRI_CMDSET_REG                   0xB500
-/* tex regs */
-#define S3V_3DTRI_BASEV_ID                             114
-#define S3V_3DTRI_BASEV_REG                    0xB504
-#define S3V_3DTRI_BASEU_ID                             115
-#define S3V_3DTRI_BASEU_REG                    0xB508
-#define S3V_3DTRI_WXD_ID                               116
-#define S3V_3DTRI_WXD_REG                      0xB50C
-#define S3V_3DTRI_WYD_ID                               117
-#define S3V_3DTRI_WYD_REG                      0xB510
-#define S3V_3DTRI_WSTART_ID                            118
-#define S3V_3DTRI_WSTART_REG                   0xB514
-#define S3V_3DTRI_DXD_ID                               119
-#define S3V_3DTRI_DXD_REG                      0xB518
-#define S3V_3DTRI_VXD_ID                               120
-#define S3V_3DTRI_VXD_REG                      0xB51C
-#define S3V_3DTRI_UXD_ID                       121
-#define S3V_3DTRI_UXD_REG                      0xB520
-#define S3V_3DTRI_DYD_ID                       122
-#define S3V_3DTRI_DYD_REG                      0xB524
-#define S3V_3DTRI_VYD_ID                       123
-#define S3V_3DTRI_VYD_REG                      0xB528
-#define S3V_3DTRI_UYD_ID                       124
-#define S3V_3DTRI_UYD_REG                      0xB52C
-#define S3V_3DTRI_DSTART_ID                    125
-#define S3V_3DTRI_DSTART_REG                   0xB530
-#define S3V_3DTRI_VSTART_ID                    126
-#define S3V_3DTRI_VSTART_REG                   0xB534
-#define S3V_3DTRI_USTART_ID                    127
-#define S3V_3DTRI_USTART_REG                   0xB538
-/* gourad regs */
-#define S3V_3DTRI_GBX_ID                               128
-#define S3V_3DTRI_GBX_REG                      0xB53C
-#define S3V_3DTRI_ARX_ID                               129
-#define S3V_3DTRI_ARX_REG                      0xB540
-#define S3V_3DTRI_GBY_ID                       130
-#define S3V_3DTRI_GBY_REG                      0xB544
-#define S3V_3DTRI_ARY_ID                       131
-#define S3V_3DTRI_ARY_REG                      0xB548
-#define S3V_3DTRI_GS_BS_ID                     132
-#define S3V_3DTRI_GS_BS_REG                    0xB54C
-#define S3V_3DTRI_AS_RS_ID                     133
-#define S3V_3DTRI_AS_RS_REG                    0xB550
-/* vertex regs */
-#define S3V_3DTRI_ZXD_ID                               134
-#define S3V_3DTRI_ZXD_REG                      0xB554
-#define S3V_3DTRI_ZYD_ID                               135
-#define S3V_3DTRI_ZYD_REG                      0xB558
-#define S3V_3DTRI_ZSTART_ID                            136
-#define S3V_3DTRI_ZSTART_REG                   0xB55C
-#define S3V_3DTRI_TXDELTA12_ID                         137
-#define S3V_3DTRI_TXDELTA12_REG                        0xB560
-#define S3V_3DTRI_TXEND12_ID                           138
-#define S3V_3DTRI_TXEND12_REG                  0xB564
-#define S3V_3DTRI_TXDELTA01_ID                         139
-#define S3V_3DTRI_TXDELTA01_REG                        0xB568
-#define S3V_3DTRI_TXEND01_ID                           140
-#define S3V_3DTRI_TXEND01_REG                  0xB56C
-#define S3V_3DTRI_TXDELTA02_ID                         141
-#define S3V_3DTRI_TXDELTA02_REG                        0xB570
-#define S3V_3DTRI_TXSTART02_ID                         142
-#define S3V_3DTRI_TXSTART02_REG                        0xB574
-#define S3V_3DTRI_TYS_ID                               143
-#define S3V_3DTRI_TYS_REG                      0xB578
-#define S3V_3DTRI_TY01_Y12_ID                          144
-#define S3V_3DTRI_TY01_Y12_REG                 0xB57C
-
-/* COMMANDS (to 0xB100 [lines] or 0xB500 [tris]) */
-
-/* Auto execute */
-#define AUTO_EXEC_MASK         0x00000001
-#define AUTO_EXEC_OFF          (0x0)
-#define AUTO_EXEC_ON           (0x1)
-/* HW clipping */
-#define HW_CLIP_MASK           0x00000002
-#define HW_CLIP_OFF            (0x0 << 1)
-#define HW_CLIP_ON             (0x1 << 1)
-/* Destination color */
-#define DEST_COL_MASK          0x0000001c
-#define DEST_COL_PAL           (0x0 << 2)      /* 8 bpp - palettized */
-#define DEST_COL_1555          (0x1 << 2)      /* 16 bpp - ZRGB */
-#define DEST_COL_888           (0x2 << 2)      /* 24 bpp - RGB */
-/* Texture color */
-#define TEX_COL_MASK           0x000000e0
-#define TEX_COL_ARGB8888       (0x0 << 5)      /* 32 bpp - ARGB */
-#define TEX_COL_ARGB4444       (0x1 << 5)      /* 16 bpp - ARGB */
-#define TEX_COL_ARGB1555       (0x2 << 5)      /* 16 bpp - ARGB */
-#define TEX_COL_ALPHA4         (0x3 << 5)      /* 8 bpp - ALPHA4 */
-#define TEX_COL_BLEND4_LOW     (0x4 << 5)      /* 4 bpp - BLEND4 low nibble */
-#define TEX_COL_BLEND4_HIGH    (0x5 << 5)      /* 4 bpp - BLEND4 high nibble */
-#define TEX_COL_PAL            (0x6 << 5)      /* 8 bpp - palettized */
-#define TEX_COL_YUV            (0x7 << 5)      /* 16 bpp - YUV */
-/* Mipmap level */
-#define MIP_MASK               0x00000f00
-#define MIPMAP_LEVEL(s)                (s << 8)        /* 8 -> 11 bits */
-/* Texture filtering */
-#define TEX_FILTER_MASK                0x00007000
-#define MIP_NEAREST            (0x0 << 12)
-#define LINEAR_MIP_NEAREST     (0x1 << 12)
-#define MIP_LINEAR             (0x2 << 12)
-#define LINEAR_MIP_LINEAR      (0x3 << 12)
-#define NEAREST                        (0x4 << 12)
-#define FAST_BILINEAR          (0x5 << 12)
-#define LINEAR                 (0x6 << 12)
-/* Texture blending */
-#define TEX_BLEND_MAKS         0x00018000
-#define TEX_REFLECT            (0x0 << 15)
-#define TEX_MODULATE           (0x1 << 15)
-#define TEX_DECAL              (0x2 << 15)
-/* Fog */
-#define FOG_MASK               0x00020000
-#define FOG_OFF                        (0x0 << 17)
-#define FOG_ON                 (0x1 << 17)
-/* Alpha blending */
-#define ALPHA_BLEND_MASK       0x000c0000
-#define ALPHA_OFF              (0x0 << 18) | (0x0 << 19)
-#define ALPHA_TEX              (0x2 << 18)
-#define ALPHA_SRC              (0x3 << 18)
-/* Depth compare mode */
-#define Z_MODE_MASK            0x00700000
-#define Z_NEVER                (0x0 << 20)
-#define Z_GREATER              (0x1 << 20)
-#define Z_EQUAL                (0x2 << 20)
-#define Z_GEQUAL               (0x3 << 20)
-#define Z_LESS                 (0x4 << 20)
-#define Z_NOTEQUAL             (0x5 << 20)
-#define Z_LEQUAL               (0x6 << 20) 
-#define Z_ALWAYS               (0x7 << 20)
-/* Depth update */
-#define Z_UPDATE_MASK          0x00800000
-#define Z_UPDATE_OFF           (0x0 << 23)     /* disable z update */
-#define Z_UPDATE_ON            (0x1 << 23)
-/* Depth buffering mode */
-#define Z_BUFFER_MASK          0x03000000
-#define Z_BUFFER               (0x0 << 24) | (0x0 << 25)
-#define Z_MUX_BUF              (0x1 << 24) | (0x0 << 25)
-#define Z_MUX_DRAW             (0x2 << 24)
-#define Z_OFF                  (0x3 << 24) /* no z buffering */
-/* Texture wrapping */
-#define TEX_WRAP_MASK          0x04000000
-#define TEX_WRAP_OFF           (0x0 << 26)
-#define TEX_WRAP_ON            (0x1 << 26)
-/* 3d command */
-#define DO_MASK                        0x78000000
-#define DO_GOURAUD_TRI         (0x0 << 27)
-#define DO_TEX_LIT_TRI_OLD     (0x1 << 27) 
-#define DO_TEX_UNLIT_TRI_OLD   (0x2 << 27)
-#define DO_TEX_LIT_TRI         (0x5 << 27)
-#define DO_TEX_UNLIT_TRI       (0x6 << 27)
-#define DO_3D_LINE             (0x8 << 27)
-#define        DO_NOP                  (0xf << 27) /* turn on autoexec */
-/* status */
-#define CMD_MASK               0x80000000
-#define CMD_2D                 (0x0 << 31) /* execute a 2d cmd */
-#define CMD_3D                 (0x1 << 31) /* execute a 3d cmd */
-
-/* global masks */
-#define TEX_MASK               ( TEX_COL_MASK | TEX_WRAP_MASK | MIP_MASK \
-                               | TEX_FILTER_MASK | TEX_BLEND_MAKS \
-                               | TEX_WRAP_MASK )
-#define Z_MASK                 ( Z_MODE_MASK | Z_UPDATE_MASK | Z_BUFFER_MASK )
-
-#endif /* _S3V_REG_H */
diff --git a/src/mesa/drivers/dri/s3v/s3v_render.c b/src/mesa/drivers/dri/s3v/s3v_render.c
deleted file mode 100644 (file)
index 5023f3c..0000000
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#include "main/glheader.h"
-#include "main/context.h"
-#include "main/macros.h"
-#include "main/mtypes.h"
-
-#include "tnl/t_context.h"
-
-#include "s3v_context.h"
-#include "s3v_tris.h"
-#include "s3v_vb.h"
-
-
-#define HAVE_POINTS      0
-#define HAVE_LINES       0
-#define HAVE_LINE_STRIPS 0
-#define HAVE_TRIANGLES   0
-#define HAVE_TRI_STRIPS  0
-#define HAVE_TRI_STRIP_1 0
-#define HAVE_TRI_FANS    0
-#define HAVE_QUADS       0
-#define HAVE_QUAD_STRIPS 0
-#define HAVE_POLYGONS    0
-
-#define HAVE_ELTS        0
-
-#if 0
-static void VERT_FALLBACK( GLcontext *ctx,
-                          GLuint start,
-                          GLuint count,
-                          GLuint flags )
-{
-       TNLcontext *tnl = TNL_CONTEXT(ctx);
-/*     s3vContextPtr vmesa = S3V_CONTEXT(ctx); */
-       int _flags;
-   
-       DEBUG(("VERT_FALLBACK: flags & PRIM_MODE_MASK = %i\n",
-               flags & PRIM_MODE_MASK));
-       DEBUG(("VERT_FALLBACK: flags=%i PRIM_MODE_MASK=%i\n",
-               flags, PRIM_MODE_MASK));
-#if 0
-       tnl->Driver.Render.PrimitiveNotify( ctx, flags & PRIM_MODE_MASK );
-#endif
-       tnl->Driver.Render.BuildVertices( ctx, start, count, ~0 );
-
-       _flags = flags & PRIM_MODE_MASK;
-
-       tnl->Driver.Render.PrimTabVerts[_flags]( ctx, start, count, flags );
-       S3V_CONTEXT(ctx)->SetupNewInputs = VERT_BIT_POS;
-}
-#endif
-
-static const GLuint hw_prim[GL_POLYGON+1] = {
-       PrimType_Points,
-       PrimType_Lines,
-       PrimType_LineLoop,
-       PrimType_LineStrip,
-       PrimType_Triangles,
-       PrimType_TriangleStrip,
-       PrimType_TriangleFan,
-       PrimType_Quads,
-       PrimType_QuadStrip,
-       PrimType_Polygon
-};
-
-static INLINE void s3vStartPrimitive( s3vContextPtr vmesa, GLenum prim )
-{
-       __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
-
-       int _hw_prim = hw_prim[prim];
-
-       DEBUG(("s3vStartPrimitive (new #%i) ", prim));
-
-       if (_hw_prim != vmesa->restore_primitive) {
-
-               if (prim == 4) { /* TRI */
-                       DEBUG(("switching to tri\n"));
-                       vmesa->prim_cmd = vmesa->_tri[vmesa->_3d_mode];
-                       vmesa->alpha_cmd = vmesa->_alpha[vmesa->_3d_mode];
-                       DMAOUT_CHECK(3DTRI_Z_BASE, 12);
-               } else if (prim == 1) { /* LINE */
-                       DEBUG(("switching to line\n"));
-                       vmesa->prim_cmd = DO_3D_LINE;
-                       vmesa->alpha_cmd = vmesa->_alpha[0];
-                       DMAOUT_CHECK(3DLINE_Z_BASE, 12);
-               } else {
-                       DEBUG(("Never mind the bollocks!\n"));
-               }
-
-               DMAOUT(vmesa->s3vScreen->depthOffset & 0x003FFFF8);
-               DMAOUT(vmesa->DestBase);
-               /* DMAOUT(vmesa->ScissorLR); */
-               /* DMAOUT(vmesa->ScissorTB); */
-               DMAOUT( (0 << 16) | (dPriv->w-1) );
-               DMAOUT( (0 << 16) | (dPriv->h-1) );
-               DMAOUT( (vmesa->SrcStride << 16) | vmesa->TexStride );
-               DMAOUT(vmesa->SrcStride);
-               DMAOUT(vmesa->TexOffset);
-               DMAOUT(vmesa->TextureBorderColor);
-               DMAOUT(0); /* FOG */
-               DMAOUT(0);
-               DMAOUT(0);
-               DMAOUT(vmesa->CMD | vmesa->prim_cmd | vmesa->alpha_cmd);
-               DMAFINISH();
-       }
-
-       vmesa->restore_primitive = _hw_prim;
-}
-
-static INLINE void s3vEndPrimitive( s3vContextPtr vmesa )
-{
-/*     GLcontext *ctx = vmesa->glCtx; */
-       DEBUG(("s3vEndPrimitive\n"));
-}
-
-#define LOCAL_VARS s3vContextPtr vmesa = S3V_CONTEXT(ctx)
-#define INIT( prim ) s3vStartPrimitive( vmesa, prim )
-#define FINISH s3vEndPrimitive( vmesa )
-#define NEW_PRIMITIVE() (void) vmesa
-#define NEW_BUFFER() (void) vmesa
-#define FIRE_VERTICES() (void) vmesa
-#define GET_CURRENT_VB_MAX_VERTS() \
-       (vmesa->bufSize - vmesa->bufCount) / 2
-#define GET_SUBSEQUENT_VB_MAX_VERTS() \
-       S3V_DMA_BUF_SZ / 2
-/* XXX */
-#define ALLOC_VERTS(nr) NULL
-#define EMIT_VERTS(ctx, start, count, buf) NULL
-#define FLUSH() s3vEndPrimitive( vmesa )
-
-#define TAG(x) s3v_##x
-
-#include "tnl_dd/t_dd_dmatmp.h"
-
-/**********************************************************************/
-/*                          Render pipeline stage                     */
-/**********************************************************************/
-
-
-static GLboolean s3v_run_render( GLcontext *ctx,
-                                 struct tnl_pipeline_stage *stage )
-{
-       s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-       TNLcontext *tnl = TNL_CONTEXT(ctx);
-       struct vertex_buffer *VB = &tnl->vb;
-       GLuint i;
-       tnl_render_func *tab;
-
-       DEBUG(("s3v_run_render\n"));
-       
-       /* FIXME: hw clip */
-       if (VB->ClipOrMask || vmesa->RenderIndex != 0) {
-               DEBUG(("*** CLIPPED in render ***\n"));
-#if 1
-               return GL_TRUE; /* don't handle clipping here */
-#endif
-       }
-
-
-       /* We don't do elts */
-       if (VB->Elts)
-               return GL_TRUE;
-
-       tab = TAG(render_tab_verts);
-
-       tnl->Driver.Render.Start( ctx );
-
-       for (i = 0 ; i < VB->PrimitiveCount ; i++ )
-       {
-               GLuint prim = _tnl_translate_prim(&VB->Primitive[i]);
-               GLuint start = VB->Primitive[i].start;
-               GLuint length = VB->Primitive[i].count;
-
-               DEBUG(("s3v_run_render (loop=%i) (lenght=%i)\n", i, length));
-
-               if (length) {
-                       tnl->Driver.Render.BuildVertices( ctx, start,
-                                start+length, ~0 /*stage->inputs*/); /* XXX */
-                       tnl->Driver.Render.PrimTabVerts[prim & PRIM_MODE_MASK]
-                               ( ctx, start, start + length, prim );
-                       vmesa->SetupNewInputs = VERT_BIT_POS;
-               }
-       }
-       
-       tnl->Driver.Render.Finish( ctx );
-
-       return GL_FALSE; /* finished the pipe */
-}
-
-
-
-const struct tnl_pipeline_stage _s3v_render_stage =
-{
-       "s3v render",
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-        s3v_run_render         /* run */
-};
diff --git a/src/mesa/drivers/dri/s3v/s3v_screen.c b/src/mesa/drivers/dri/s3v/s3v_screen.c
deleted file mode 100644 (file)
index f181059..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#include "s3v_context.h"
-#include "s3v_vb.h"
-#include "s3v_dri.h" 
-
-s3vScreenPtr s3vCreateScreen( __DRIscreenPrivate *sPriv )
-{
-   s3vScreenPtr s3vScreen;
-   S3VDRIPtr vDRIPriv = (S3VDRIPtr)sPriv->pDevPriv;
-
-/*   int i; */
-
-   DEBUG(("s3vCreateScreen\n"));
-   DEBUG(("sPriv->pDevPriv at %p\n", sPriv->pDevPriv));
-   DEBUG(("size = %i\n", sizeof(*vDRIPriv)));
-
-   if (sPriv->devPrivSize != sizeof(S3VDRIRec)) {
-      fprintf(stderr,"\nERROR!  sizeof(S3VDRIRec) does not match passed size from device driver\n");
-      return GL_FALSE;
-   }
-
-   /* Allocate the private area */
-   s3vScreen = (s3vScreenPtr) CALLOC( sizeof(*s3vScreen) );
-   if ( !s3vScreen ) return NULL;
-
-   s3vScreen->regionCount  = 4;        /* Magic number.  Can we fix this? */
-    
-   s3vScreen->regions = _mesa_malloc(s3vScreen->regionCount * 
-                                                       sizeof(s3vRegion));
-   DEBUG(("sPriv->fd = %i\nvDRIPriv->dmaBufHandle = %x\n",
-      sPriv->fd, vDRIPriv->dmaBufHandle));
-
-   DEBUG(("vDRIPriv->dmaBufSize=%i\nvDRIPriv->dmaBuf=%p\n",
-      vDRIPriv->dmaBufSize, vDRIPriv->dmaBuf));
-
-
-   /* Get the list of dma buffers */
-   s3vScreen->bufs = drmMapBufs(sPriv->fd);
-
-   if (!s3vScreen->bufs) {
-      DEBUG(("Helter/skelter with drmMapBufs\n"));
-      return GL_FALSE; 
-   }
-
-   s3vScreen->textureSize                  = vDRIPriv->texSize;
-   s3vScreen->logTextureGranularity = vDRIPriv->logTextureGranularity;
-   s3vScreen->cpp                                      = vDRIPriv->cpp;
-   s3vScreen->frontOffset                      = vDRIPriv->frontOffset;
-   s3vScreen->frontPitch                       = vDRIPriv->frontPitch;
-   s3vScreen->backOffset                       = vDRIPriv->backOffset;
-   s3vScreen->backPitch                                = vDRIPriv->frontPitch; /* FIXME: check */
-   s3vScreen->depthOffset                      = vDRIPriv->depthOffset;
-   s3vScreen->depthPitch                       = vDRIPriv->frontPitch;
-   s3vScreen->texOffset                                = vDRIPriv->texOffset;
-
-   s3vScreen->driScreen = sPriv;
-
-   DEBUG(("vDRIPriv->width =%i; vDRIPriv->deviceID =%x\n", vDRIPriv->width,
-                 vDRIPriv->deviceID));
-   DEBUG(("vDRIPriv->mem =%i\n", vDRIPriv->mem));
-   DEBUG(("vDRIPriv->fbOffset =%i\n", vDRIPriv->fbOffset));
-   DEBUG((" ps3vDRI->fbStride =%i\n", vDRIPriv->fbStride));
-   DEBUG(("s3vScreen->cpp = %i\n", s3vScreen->cpp));
-   DEBUG(("s3vScreen->backOffset = %x\n", s3vScreen->backOffset));
-   DEBUG(("s3vScreen->depthOffset = %x\n", s3vScreen->depthOffset));
-   DEBUG(("s3vScreen->texOffset = %x\n", s3vScreen->texOffset));
-   DEBUG(("I will return from s3vCreateScreen now\n"));
-   
-   DEBUG(("s3vScreen->bufs = 0x%x\n", s3vScreen->bufs));
-   return s3vScreen;
-}
-
-/* Destroy the device specific screen private data struct.
- */
-void s3vDestroyScreen( __DRIscreenPrivate *sPriv )
-{
-    s3vScreenPtr s3vScreen = (s3vScreenPtr)sPriv->private;
-
-    DEBUG(("s3vDestroyScreen\n"));
-
-    /* First, unmap the dma buffers */
-/*
-    drmUnmapBufs( s3vScreen->bufs );
-*/
-    /* Next, unmap all the regions */
-/*    while (s3vScreen->regionCount > 0) { 
-
-       (void)drmUnmap(s3vScreen->regions[s3vScreen->regionCount].map,
-                      s3vScreen->regions[s3vScreen->regionCount].size);
-       s3vScreen->regionCount--;
-
-    }
-    FREE(s3vScreen->regions); */
-       if (s3vScreen)
-           FREE(s3vScreen);
-}
diff --git a/src/mesa/drivers/dri/s3v/s3v_screen.h b/src/mesa/drivers/dri/s3v/s3v_screen.h
deleted file mode 100644 (file)
index c49bc85..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#include "main/mtypes.h"
-
-typedef struct _s3vRegion {
-    drm_handle_t  handle;
-    drmSize    size;
-    drmAddress map;
-} s3vRegion, *s3vRegionPtr;
-
-typedef struct {
-
-    int          regionCount;             /* Count of register regions */
-    s3vRegion           *regions;         /* Vector of mapped region info */
-
-    drmBufMapPtr bufs;             /* Map of DMA buffers */
-
-    __DRIscreenPrivate *driScreen; /* Back pointer to DRI screen */
-
-    int                cpp;
-    int                frontPitch;
-    int                frontOffset;
-
-    int                backPitch;
-    int                backOffset;
-    int                backX;
-    int                backY;
-
-    int                depthOffset;
-    int                depthPitch;
-
-    int                texOffset;
-    int                textureOffset;
-    int                textureSize;
-    int                logTextureGranularity;
-} s3vScreenRec, *s3vScreenPtr;
-
diff --git a/src/mesa/drivers/dri/s3v/s3v_span.c b/src/mesa/drivers/dri/s3v/s3v_span.c
deleted file mode 100644 (file)
index f9f7c0d..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#include "s3v_context.h"
-#include "s3v_lock.h"
-
-#include "swrast/swrast.h"
-
-#define _SPANLOCK 1
-#define DBG 0
-
-#define LOCAL_VARS \
-       s3vContextPtr vmesa = S3V_CONTEXT(ctx);                         \
-       __DRIscreenPrivate *sPriv = vmesa->driScreen;                   \
-       __DRIdrawablePrivate *dPriv = vmesa->driDrawable;               \
-       driRenderbuffer *drb = (driRenderbuffer *) rb;                  \
-       GLuint cpp = drb->cpp;                                          \
-       GLuint pitch = ( (drb->backBuffer) ?                            \
-                       ((dPriv->w+31)&~31) * cpp                       \
-                       : sPriv->fbWidth * cpp);                        \
-       GLuint height = dPriv->h;                                       \
-       char *buf = (char *)(sPriv->pFB + drb->offset                   \
-          + (drb->backBuffer ? 0 : dPriv->x * cpp + dPriv->y * pitch));\
-       GLuint p; \
-       (void) p
-
-/* FIXME! Depth/Stencil read/writes don't work ! */
-#define LOCAL_DEPTH_VARS                                       \
-       __DRIdrawablePrivate *dPriv = vmesa->driDrawable;       \
-       __DRIscreenPrivate *sPriv = vmesa->driScreen;           \
-       driRenderbuffer *drb = (driRenderbuffer *) rb;          \
-       GLuint pitch = drb->pitch;                              \
-       GLuint height = dPriv->h;                               \
-       char *buf = (char *)(sPriv->pFB + drb->offset);         \
-       (void) pitch
-
-#define LOCAL_STENCIL_VARS     LOCAL_DEPTH_VARS
-
-#define Y_FLIP( _y )   (height - _y - 1)
-
-#if _SPANLOCK  /* OK, we lock */
-
-#define HW_LOCK() \
-       s3vContextPtr vmesa = S3V_CONTEXT(ctx); \
-       (void) vmesa; \
-       DMAFLUSH(); \
-       S3V_SIMPLE_FLUSH_LOCK(vmesa);
-#define HW_UNLOCK() S3V_SIMPLE_UNLOCK(vmesa);
-
-#else                  /* plz, don't lock */
-
-#define HW_LOCK() \
-       s3vContextPtr vmesa = S3V_CONTEXT(ctx); \
-    (void) vmesa; \
-       DMAFLUSH(); 
-#define HW_UNLOCK()
-
-#endif
-
-
-/* ================================================================
- * Color buffer
- */
-
-/* 16 bit, RGB565 color spanline and pixel functions
- */
-#define INIT_MONO_PIXEL(p, color) \
-  p = S3VIRGEPACKCOLOR555( color[0], color[1], color[2], color[3] )
-
-#define WRITE_RGBA( _x, _y, r, g, b, a ) \
-do { \
-   *(GLushort *)(buf + _x*2 + _y*pitch) = ((((int)r & 0xf8) << 7) | \
-                                          (((int)g & 0xf8) << 2) | \
-                                          (((int)b & 0xf8) >> 3)); \
-   DEBUG(("buf=0x%x drawOffset=0x%x dPriv->x=%i drb->cpp=%i dPriv->y=%i pitch=%i\n", \
-       sPriv->pFB, vmesa->drawOffset, dPriv->x, drb->cpp, dPriv->y, pitch)); \
-   DEBUG(("dPriv->w = %i\n", dPriv->w)); \
-} while(0)
-
-#define WRITE_PIXEL( _x, _y, p ) \
-   *(GLushort *)(buf + _x*2 + _y*pitch) = p
-
-#define READ_RGBA( rgba, _x, _y ) \
-   do { \
-      GLushort p = *(GLushort *)(buf + _x*2 + _y*pitch); \
-      rgba[0] = (p >> 7) & 0xf8; \
-      rgba[1] = (p >> 2) & 0xf8; \
-      rgba[2] = (p << 3) & 0xf8; \
-      rgba[3] = 0xff; /*
-      if ( rgba[0] & 0x08 ) rgba[0] |= 0x07; \ 
-      if ( rgba[1] & 0x04 ) rgba[1] |= 0x03; \
-      if ( rgba[2] & 0x08 ) rgba[2] |= 0x07; */ \
-   } while (0)
-
-#define TAG(x) s3v##x##_RGB555
-#include "spantmp.h"
-
-
-/* 32 bit, ARGB8888 color spanline and pixel functions
- */
-
-#undef INIT_MONO_PIXEL
-#define INIT_MONO_PIXEL(p, color) \
-  p = PACK_COLOR_8888( color[3], color[0], color[1], color[2] )
-
-#define WRITE_RGBA( _x, _y, r, g, b, a ) \
-   *(GLuint *)(buf + _x*4 + _y*pitch) = ((b <<  0) | \
-                                        (g <<  8) | \
-                                        (r << 16) | \
-                                        (a << 24) )
-
-#define WRITE_PIXEL( _x, _y, p ) \
-   *(GLuint *)(buf + _x*4 + _y*pitch) = p
-
-#define READ_RGBA( rgba, _x, _y ) \
-do { \
-   GLuint p = *(GLuint *)(buf + _x*4 + _y*pitch); \
-   rgba[0] = (p >> 16) & 0xff; \
-   rgba[1] = (p >>  8) & 0xff; \
-   rgba[2] = (p >>  0) & 0xff; \
-   rgba[3] = (p >> 24) & 0xff; \
-} while (0)
-
-#define TAG(x) s3v##x##_ARGB8888
-#include "spantmp.h"
-
-
-/* 16 bit depthbuffer functions.
- */
-#define VALUE_TYPE GLushort
-
-#define WRITE_DEPTH( _x, _y, d ) \
-   *(GLushort *)(buf + _x*2 + _y*dPriv->w*2) = d
-
-#define READ_DEPTH( d, _x, _y ) \
-   d = *(GLushort *)(buf + _x*2 + _y*dPriv->w*2);
-
-#define TAG(x) s3v##x##_z16
-#include "depthtmp.h"
-
-
-
-
-/* 32 bit depthbuffer functions.
- */
-#if 0
-#define VALUE_TYPE GLuint
-
-#define WRITE_DEPTH( _x, _y, d )       \
-   *(GLuint *)(buf + _x*4 + _y*pitch) = d;
-
-#define READ_DEPTH( d, _x, _y )                \
-   d = *(GLuint *)(buf + _x*4 + _y*pitch);     
-
-#define TAG(x) s3v##x##_32
-#include "depthtmp.h"
-#endif
-
-
-/* 24/8 bit interleaved depth/stencil functions
- */
-#if 0
-#define VALUE_TYPE GLuint
-
-#define WRITE_DEPTH( _x, _y, d ) { \
-   GLuint tmp = *(GLuint *)(buf + _x*4 + _y*pitch);    \
-   tmp &= 0xff; \
-   tmp |= (d) & 0xffffff00; \
-   *(GLuint *)(buf + _x*4 + _y*pitch) = tmp; \
-}
-
-#define READ_DEPTH( d, _x, _y ) \
-   d = *(GLuint *)(buf + _x*4 + _y*pitch) & ~0xff      
-
-
-#define TAG(x) s3v##x##_24_8
-#include "depthtmp.h"
-
-#define WRITE_STENCIL( _x, _y, d ) { \
-   GLuint tmp = *(GLuint *)(buf + _x*4 + _y*pitch);    \
-   tmp &= 0xffffff00; \
-   tmp |= d & 0xff; \
-   *(GLuint *)(buf + _x*4 + _y*pitch) = tmp; \
-}
-
-#define READ_STENCIL( d, _x, _y ) \
-   d = *(GLuint *)(buf + _x*4 + _y*pitch) & 0xff       
-
-#define TAG(x) s3v##x##_24_8
-#include "stenciltmp.h"
-
-#endif
-
-
-/**
- * Plug in the Get/Put routines for the given driRenderbuffer.
- */
-void
-s3vSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
-{
-   if (drb->Base.InternalFormat == GL_RGBA) {
-      if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
-         s3vInitPointers_RGB555(&drb->Base);
-      }
-      else {
-         s3vInitPointers_ARGB8888(&drb->Base);
-      }
-   }
-   else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
-      s3vInitDepthPointers_z16(&drb->Base);
-   }
-   else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
-      /* not done yet */
-   }
-   else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
-      /* not done yet */
-   }
-}
diff --git a/src/mesa/drivers/dri/s3v/s3v_state.c b/src/mesa/drivers/dri/s3v/s3v_state.c
deleted file mode 100644 (file)
index 561f42c..0000000
+++ /dev/null
@@ -1,888 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#include "s3v_context.h"
-#include "s3v_macros.h"
-#include "s3v_dri.h"
-#include "main/macros.h"
-#include "main/colormac.h"
-#include "swrast/swrast.h"
-#include "swrast_setup/swrast_setup.h"
-#include "vbo/vbo.h"
-#include "tnl/tnl.h"
-
-/* #define DEBUG(str) printf str */
-#define ENABLELIGHTING 0
-
-
-/* =============================================================
- * Alpha blending
- */
-
-static void s3vUpdateAlphaMode( GLcontext *ctx )
-{
-       s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-       uint32_t cmd = vmesa->CMD;
-       cmd &= ~ALPHA_BLEND_MASK;
-
-       if ( ctx->Color.BlendEnabled ) {
-               DEBUG(("ctx->Color.AlphaEnabled = 1"));
-               vmesa->_alpha[0] = ALPHA_SRC;
-               vmesa->_alpha[1] = vmesa->_alpha_tex; /* FIXME: not all tex modes
-                                                        support alpha */
-       } else {
-               DEBUG(("ctx->Color.AlphaEnabled = 0"));
-               vmesa->_alpha[0] = vmesa->_alpha[1] = ALPHA_OFF;
-       }
-#if 1
-       if ((cmd & DO_MASK) & DO_3D_LINE) {     /* we are drawing 3d lines */
-                                               /* which don't support tex */
-               cmd |= vmesa->_alpha[0];
-       } else {
-               cmd |= vmesa->_alpha[vmesa->_3d_mode];
-       }
-
-       vmesa->CMD = cmd; /* FIXME: enough? */
-#else
-       vmesa->restore_primitive = -1;
-#endif
-       
-}
-
-static void s3vDDAlphaFunc( GLcontext *ctx, GLenum func, GLfloat ref )
-{
-   s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-
-   DEBUG(("s3vDDAlphaFunc\n"));
-
-   vmesa->new_state |= S3V_NEW_ALPHA;
-}
-
-static void s3vDDBlendFunc( GLcontext *ctx, GLenum sfactor, GLenum dfactor )
-{
-   s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-
-   DEBUG(("s3vDDBlendFunc\n"));
-
-   vmesa->new_state |= S3V_NEW_ALPHA;
-}
-
-/* ================================================================
- * Buffer clear
- */
-
-static void s3vDDClear( GLcontext *ctx, GLbitfield mask )
-{
-       s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-       unsigned int _stride;
-        GLint cx = ctx->DrawBuffer->_Xmin;
-        GLint cy = ctx->DrawBuffer->_Ymin;
-        GLint cw = ctx->DrawBuffer->_Xmax - cx;
-        GLint ch = ctx->DrawBuffer->_Ymax - cy;
-
-        /* XXX FIX ME: the cx,cy,cw,ch vars are currently ignored! */
-
-       vmesa->restore_primitive = -1;
-
-       /* Update and emit any new state.  We need to do this here to catch
-        * changes to the masks.
-        * FIXME: Just update the masks?
-        */
-
-       if ( vmesa->new_state )
-               s3vDDUpdateHWState( ctx );
-
-/*     s3vUpdateMasks( ctx ); */
-/*     s3vUpdateClipping( ctx ); */
-/*     s3vEmitHwState( vmesa ); */
-       
-
-#if 1 /* soft (0)/hw (1)*/
-
-       DEBUG(("*** s3vDDClear ***\n"));
-
-       DMAOUT_CHECK(BITBLT_SRC_BASE, 15);
-               DMAOUT(vmesa->SrcBase);
-               DMAOUT(vmesa->DestBlit);
-               DMAOUT( vmesa->ScissorLR );
-               DMAOUT( vmesa->ScissorTB );
-               DMAOUT( (vmesa->SrcStride << 16) | vmesa->SrcStride );  /* FIXME: unify */
-               DMAOUT( (~(0)) ); /* masks */
-               DMAOUT( (~(0)) );
-               DMAOUT(0);
-               DMAOUT(vmesa->ClearColor);
-               DMAOUT(0);
-               DMAOUT(0);
-               /* FIXME */
-               DMAOUT(0x16000122 | 0x5 | (0xF0 << 17));    /* black magic to me */
-               DMAOUT(vmesa->ScissorWH);
-               DMAOUT(vmesa->SrcXY);
-               DMAOUT(vmesa->DestXY);
-       DMAFINISH();
-
-       if (mask & BUFFER_BIT_DEPTH) { /* depth */
-               DEBUG(("BUFFER_BIT_DEPTH\n"));
-               
-               _stride = ((cw+31)&~31) * 2; /* XXX cw or Buffer->Width??? */
-
-               DMAOUT_CHECK(BITBLT_SRC_BASE, 15);
-                       DMAOUT(0);
-                       DMAOUT(vmesa->s3vScreen->depthOffset);
-                       DMAOUT( (0 << 16) | cw );
-                       DMAOUT( (0 << 16) | ch );
-                       DMAOUT( (vmesa->SrcStride << 16) | vmesa->DestStride );
-                       DMAOUT( (~(0)) ); /* masks */
-                       DMAOUT( (~(0)) );
-                       DMAOUT(0);
-                       DMAOUT(vmesa->ClearDepth); /* 0x7FFF */
-                       /* FIXME */
-                       DMAOUT(0);
-                       DMAOUT(0);
-                       DMAOUT(0x16000122 | 0x5 | (0xF0 << 17));
-                       DMAOUT( ((cw-1) << 16) | (ch-1) );
-                       DMAOUT(0);
-                       DMAOUT( (0 << 16) | 0 );
-               DMAFINISH();            
-
-               DEBUG(("vmesa->ClearDepth = 0x%x\n", vmesa->ClearDepth));
-               mask &= ~BUFFER_BIT_DEPTH;
-       }
-
-       if (!vmesa->NotClipped) {
-               DEBUG(("vmesa->NotClipped\n")); /* yes */
-       }
-
-       if (!(vmesa->EnabledFlags & S3V_BACK_BUFFER)) {
-               DEBUG(("!S3V_BACK_BUFFER -> flush\n"));
-               DMAFLUSH();
-       }
-/*
-       if ( mask )
-               DEBUG(("still masked ;3(\n")); */ /* yes */
-#else
-      _swrast_Clear( ctx, mask );
-#endif
-}
-
-/* =============================================================
- * Depth testing
- */
-
-static void s3vUpdateZMode( GLcontext *ctx )
-{
-       s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-       uint32_t cmd = vmesa->CMD;
-
-       DEBUG(("Depth.Test = %i\n", ctx->Depth.Test));
-       DEBUG(("CMD was = 0x%x ", cmd));
-
-/*     printf("depth --- CMD was = 0x%x \n", cmd); */
-
-       cmd &= ~Z_MASK; /*  0xfc0fffff; */
-       /* Z_BUFFER */ /* 000 mode */ /* Z_UPDATE_OFF */
-
-       if (!ctx->Depth.Test)
-               cmd |= Z_OFF;
-
-       if ( ctx->Depth.Mask )
-               cmd |= Z_UPDATE_ON;
-                       
-       switch ( ctx->Depth.Func ) {
-               case GL_NEVER:
-                       cmd |= Z_NEVER;
-                       break;
-               case GL_ALWAYS:
-                       cmd |= Z_ALWAYS;
-                       break;
-               case GL_LESS:
-                       cmd |= Z_LESS;
-                       break;
-               case GL_LEQUAL:
-                       cmd |= Z_LEQUAL;
-                       break;
-               case GL_EQUAL:
-                       cmd |= Z_EQUAL;
-                       break;
-               case GL_GEQUAL:
-                       cmd |= Z_GEQUAL;
-                       break;
-               case GL_GREATER:
-                       cmd |= Z_GREATER;
-                       break;
-               case GL_NOTEQUAL:
-                       cmd |= Z_NOTEQUAL;
-                       break;
-       }
-
-       DEBUG(("CMD is 0x%x\n", cmd));
-
-       vmesa->dirty |= S3V_UPLOAD_DEPTH;
-       vmesa->CMD = cmd;
-}
-
-static void s3vDDDepthFunc( GLcontext *ctx, GLenum func )
-{
-       s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-
-/*     FLUSH_BATCH( vmesa ); */
-       DEBUG(("s3vDDDepthFunc\n"));
-       vmesa->new_state |= S3V_NEW_DEPTH;
-}
-
-static void s3vDDDepthMask( GLcontext *ctx, GLboolean flag )
-{
-       s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-
-       /* FLUSH_BATCH( vmesa ); */
-       DEBUG(("s3vDDDepthMask\n"));
-       vmesa->new_state |= S3V_NEW_DEPTH;
-}
-
-static void s3vDDClearDepth( GLcontext *ctx, GLclampd d )
-{
-       s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-
-       switch ( vmesa->DepthSize ) {
-       case 15:
-       case 16:
-               vmesa->ClearDepth = d * 0x0000ffff;     /* 65536 */
-               DEBUG(("GLclampd d = %f\n", d));
-               DEBUG(("ctx->Depth.Clear = %f\n", ctx->Depth.Clear));
-               DEBUG(("(They should be the same)\n"));
-               break;
-       case 24:
-               vmesa->ClearDepth = d * 0x00ffffff;
-               break;
-       case 32:
-               vmesa->ClearDepth = d * 0xffffffff;
-               break;
-   }
-}
-
-static void s3vDDFinish( GLcontext *ctx )
-{
-       s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-       DMAFLUSH(); 
-}
-
-static void s3vDDFlush( GLcontext *ctx )
-{
-       s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-       DMAFLUSH();
-}
-
-/* =============================================================
- * Fog
- */
-
-static void s3vUpdateFogAttrib( GLcontext *ctx )
-{
-/*     s3vContextPtr vmesa = S3V_CONTEXT(ctx); */
-
-       if (ctx->Fog.Enabled) {
-       } else {
-       }
-
-       switch (ctx->Fog.Mode) {
-               case GL_LINEAR:
-                       break;
-               case GL_EXP:
-                       break;
-               case GL_EXP2:
-                       break;
-       }
-}
-
-static void s3vDDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *param )
-{
-   s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-   vmesa->new_state |= S3V_NEW_FOG;
-}
-
-/* =============================================================
- * Lines
- */
-static void s3vDDLineWidth( GLcontext *ctx, GLfloat width )
-{
-       /* FIXME: on virge you only have one size of 3d lines    *
-        * if we wanted more, we should start using tris instead *
-        * but virge has problem with some tris when all of the  *
-        * vertices stay on a line */
-}
-
-/* =============================================================
- * Points
- */
-static void s3vDDPointSize( GLcontext *ctx, GLfloat size )
-{
-       /* FIXME: we use 3d line to fake points. So same limitations
-        * as above apply */
-}
-
-/* =============================================================
- * Polygon 
- */
-
-static void s3vUpdatePolygon( GLcontext *ctx )
-{
-       /* FIXME: I don't think we could do much here */
-
-       s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-       vmesa->dirty |= S3V_UPLOAD_POLYGON;
-}
-
-/* =============================================================
- * Clipping
- */
-
-static void s3vUpdateClipping( GLcontext *ctx )
-{
-       s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-       __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
-
-       int x0,y0,x1,y1;
-
-       DEBUG((">>> s3vUpdateClipping <<<\n"));
-/*
-       if ( vmesa->driDrawable ) {
-               DEBUG(("s3vUpdateClipping\n"));
-*/
-       if (vmesa->EnabledFlags & S3V_BACK_BUFFER) {
-               DEBUG(("S3V_BACK_BUFFER\n"));
-
-               x0 = 0;
-               y0 = 0;
-               x1 = dPriv->w - 1;
-               y1 = dPriv->h - 1;
-
-               vmesa->SrcBase = 0;
-               vmesa->DestBase =  vmesa->s3vScreen->backOffset;
-               vmesa->DestBlit = vmesa->DestBase;
-               vmesa->ScissorLR = ( (0 << 16) | (dPriv->w-1) );
-               vmesa->ScissorTB = ( (0 << 16) | (dPriv->h-1) );
-/*
-               vmesa->ScissorLR = ( (x0 << 16) | x1 );
-               vmesa->ScissorTB = ( (y0 << 16) | y1 );
-*/
-               vmesa->SrcStride = ( ((dPriv->w+31)&~31) * vmesa->s3vScreen->cpp );
-               vmesa->DestStride = vmesa->driScreen->fbWidth*vmesa->s3vScreen->cpp;
-               vmesa->ScissorWH = ( (dPriv->w << 16) | dPriv->h );
-               vmesa->SrcXY = 0;
-/*             vmesa->DestXY = ( (dPriv->x << 16) | dPriv->y );  */
-               vmesa->DestXY = ( (0 << 16) | 0 );
-       } else {
-               DEBUG(("S3V_FRONT_BUFFER\n"));
-
-               x0 = dPriv->x;
-               y0 = dPriv->y;
-               x1 = x0 + dPriv->w - 1;
-               y1 = y0 + dPriv->h - 1;
-
-               vmesa->SrcBase = 0;
-               vmesa->DestBase = 0;
-               vmesa->ScissorLR = ( (x0 << 16) | x1 );
-               vmesa->ScissorTB = ( (y0 << 16) | y1 );
-               vmesa->DestStride = vmesa->driScreen->fbWidth*vmesa->s3vScreen->cpp;
-               vmesa->SrcStride = vmesa->DestStride;
-               vmesa->DestBase = (y0 * vmesa->DestStride)
-                               + x0*vmesa->s3vScreen->cpp;
-               vmesa->DestBlit = 0;
-               vmesa->ScissorWH = ( (x1 << 16) | y1 );
-               vmesa->SrcXY = 0;
-               vmesa->DestXY = ( (0 << 16) | 0 );
-/*             vmesa->DestXY = ( (dPriv->x << 16) | dPriv->y ); */
-       }
-
-       DEBUG(("x0=%i y0=%i x1=%i y1=%i\n", x0, y0, x1, y1));
-       DEBUG(("stride=%i rectWH=0x%x\n\n", vmesa->DestStride, vmesa->ScissorWH));
-
-       /* FIXME: how could we use the following info? */
-       /* if (ctx->Scissor.Enabled) {} */
-
-       vmesa->dirty |= S3V_UPLOAD_CLIP; 
-/*     }  */
-}
-
-static void s3vDDScissor( GLcontext *ctx,
-                          GLint x, GLint y, GLsizei w, GLsizei h )
-{
-       s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-
-       DEBUG((">>> s3vDDScissor <<<"));
-       /* FLUSH_BATCH( vmesa ); */
-       vmesa->new_state |= S3V_NEW_CLIP;
-}
-
-/* =============================================================
- * Culling
- */
-
-static void s3vUpdateCull( GLcontext *ctx )
-{
-       s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-       GLfloat backface_sign = 1;
-
-       DEBUG(("s3vUpdateCull\n"));
-       /* FIXME: GL_FRONT_AND_BACK */
-
-       switch ( ctx->Polygon.CullFaceMode ) {
-       case GL_BACK:
-               if (ctx->Polygon.FrontFace == GL_CCW)
-                       backface_sign = -1;
-               break;
-
-       case GL_FRONT:
-               if (ctx->Polygon.FrontFace != GL_CCW)
-                       backface_sign = -1;
-               break;
-
-       default:
-               break;
-       }
-
-       vmesa->backface_sign = backface_sign;
-       vmesa->dirty |= S3V_UPLOAD_GEOMETRY;
-}
-
-
-static void s3vDDCullFace( GLcontext *ctx, GLenum mode )
-{
-       s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-       /* FLUSH_BATCH( vmesa ); */
-       vmesa->new_state |= S3V_NEW_CULL;
-}
-
-static void s3vDDFrontFace( GLcontext *ctx, GLenum mode )
-{
-       s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-       /* FLUSH_BATCH( vmesa ); */
-       vmesa->new_state |= S3V_NEW_CULL;
-}
-
-/* =============================================================
- * Masks
- */
-
-static void s3vUpdateMasks( GLcontext *ctx )
-{
-       s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-
-       GLuint mask = s3vPackColor( vmesa->s3vScreen->cpp,
-                               ctx->Color.ColorMask[RCOMP],
-                               ctx->Color.ColorMask[GCOMP],
-                               ctx->Color.ColorMask[BCOMP],
-                               ctx->Color.ColorMask[ACOMP] );
-
-       if (vmesa->s3vScreen->cpp == 2) mask |= mask << 16;
-
-       /* FIXME: can we do something in virge? */
-}
-/*
-static void s3vDDColorMask( GLcontext *ctx, GLboolean r, GLboolean g,
-                             GLboolean b, GLboolean a)
-{
-   s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-
-   FLUSH_BATCH( vmesa );
-   vmesa->new_state |= S3V_NEW_MASKS;
-}
-*/
-/* =============================================================
- * Rendering attributes
- */
-
-/* =============================================================
- * Miscellaneous
- */
-
-static void s3vDDClearColor( GLcontext *ctx, const GLfloat color[4])
-{
-   s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-
-   DEBUG(("*** s3vDDClearColor\n"));
-
-   vmesa->ClearColor = s3vPackColor( 2, /* vmesa->s3vScreen->cpp, */
-                                     color[0], color[1], color[2], color[3] );
-
-#if 0
-   if (vmesa->s3vScreen->cpp == 2) vmesa->ClearColor |= vmesa->ClearColor<<16;
-#endif
-}
-
-static void s3vDDSetDrawBuffer( GLcontext *ctx, GLenum mode )
-{
-       s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-       int found = GL_TRUE;
-
-       DEBUG(("*** s3vDDSetDrawBuffer ***\n"));
-
-       /* FLUSH_BATCH( vmesa ); */
-
-       switch ( mode ) {
-               case GL_FRONT_LEFT:
-                       vmesa->drawOffset = vmesa->s3vScreen->frontOffset;
-                       break;
-               case GL_BACK_LEFT:
-                       vmesa->drawOffset = vmesa->s3vScreen->backOffset;
-                       /* vmesa->driScreen->fbHeight *
-                        * vmesa->driScreen->fbWidth *
-                        * vmesa->s3vScreen->cpp; */
-                       break;
-               default:
-                       found = GL_FALSE;
-                       break;
-       }
-
-       DEBUG(("vmesa->drawOffset = 0x%x\n", vmesa->drawOffset));
-/*     return GL_TRUE; */
-}
-
-/* =============================================================
- * Window position and viewport transformation
- */
-
-void s3vUpdateWindow( GLcontext *ctx )
-{
-       s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-       __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
-       GLfloat xoffset = (GLfloat)dPriv->x;
-       GLfloat yoffset =
-               vmesa->driScreen->fbHeight - (GLfloat)dPriv->y - dPriv->h;
-       const GLfloat *v = ctx->Viewport._WindowMap.m;
-
-       GLfloat sx = v[MAT_SX];
-       GLfloat tx = v[MAT_TX] + xoffset;
-       GLfloat sy = v[MAT_SY];
-       GLfloat ty = v[MAT_TY] + yoffset;
-       GLfloat sz = v[MAT_SZ] * vmesa->depth_scale;
-       GLfloat tz = v[MAT_TZ] * vmesa->depth_scale;
-
-       vmesa->dirty |= S3V_UPLOAD_VIEWPORT;
-
-       vmesa->ViewportScaleX = sx;
-       vmesa->ViewportScaleY = sy;
-       vmesa->ViewportScaleZ = sz;
-       vmesa->ViewportOffsetX = tx;
-       vmesa->ViewportOffsetY = ty;
-       vmesa->ViewportOffsetZ = tz;
-}
-
-
-/*
-static void s3vDDViewport( GLcontext *ctx, GLint x, GLint y,
-                           GLsizei width, GLsizei height )
-{
-       s3vUpdateWindow( ctx );
-}
-
-static void s3vDDDepthRange( GLcontext *ctx, GLclampd nearval,
-                             GLclampd farval )
-{
-       s3vUpdateWindow( ctx );
-}
-*/
-void s3vUpdateViewportOffset( GLcontext *ctx )
-{
-       s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-       __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
-       GLfloat xoffset = (GLfloat)dPriv->x;
-       GLfloat yoffset =
-               vmesa->driScreen->fbHeight - (GLfloat)dPriv->y - dPriv->h;
-       const GLfloat *v = ctx->Viewport._WindowMap.m;
-
-       GLfloat tx = v[MAT_TX] + xoffset;
-       GLfloat ty = v[MAT_TY] + yoffset;
-
-       DEBUG(("*** s3vUpdateViewportOffset ***\n"));
-
-       if ( vmesa->ViewportOffsetX != tx ||
-               vmesa->ViewportOffsetY != ty )
-       {
-               vmesa->ViewportOffsetX = tx;
-               vmesa->ViewportOffsetY = ty;
-
-               vmesa->new_state |= S3V_NEW_WINDOW;
-       }
-
-/*     vmesa->new_state |= S3V_NEW_CLIP; */
-}
-
-/* =============================================================
- * State enable/disable
- */
-
-static void s3vDDEnable( GLcontext *ctx, GLenum cap, GLboolean state )
-{
-       s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-
-       switch ( cap ) {
-       case GL_ALPHA_TEST:
-       case GL_BLEND:
-               vmesa->new_state |= S3V_NEW_ALPHA;
-               DEBUG(("s3vDDEnable: GL_BLEND\n"));
-       break;
-
-       case GL_CULL_FACE:
-               vmesa->new_state |= S3V_NEW_CULL;
-               DEBUG(("s3vDDEnable: GL_CULL_FACE\n"));
-       break;
-
-       case GL_DEPTH_TEST:
-               vmesa->new_state |= S3V_NEW_DEPTH;
-               DEBUG(("s3vDDEnable: GL_DEPTH\n"));
-       break;
-#if 0
-       case GL_FOG:
-               vmesa->new_state |= S3V_NEW_FOG;
-       break;
-#endif
-
-       case GL_SCISSOR_TEST:
-               vmesa->new_state |= S3V_NEW_CLIP;
-       break;
-
-       case GL_TEXTURE_2D:
-               DEBUG(("*** GL_TEXTURE_2D: %i\n", state));
-               vmesa->_3d_mode = state;
-               vmesa->restore_primitive = -1;
-       break;
-       
-       default:
-               return;
-       }
-}
-
-/* =============================================================
- * State initialization, management
- */
-
-
-/*
- * Load the current context's state into the hardware.
- *
- * NOTE: Be VERY careful about ensuring the context state is marked for
- * upload, the only place it shouldn't be uploaded is when the setup
- * state has changed in ReducedPrimitiveChange as this comes right after
- * a state update.
- *
- * Blits of any type should always upload the context and masks after
- * they are done.
- */
-void s3vEmitHwState( s3vContextPtr vmesa )
-{
-    if (!vmesa->driDrawable) return;
-    if (!vmesa->dirty) return; 
-
-       DEBUG(("**********************\n"));
-       DEBUG(("*** s3vEmitHwState ***\n"));
-       DEBUG(("**********************\n"));
-
-    if (vmesa->dirty & S3V_UPLOAD_VIEWPORT) {
-       vmesa->dirty &= ~S3V_UPLOAD_VIEWPORT;
-       DEBUG(("S3V_UPLOAD_VIEWPORT\n"));
-    }
-   
-    if ( (vmesa->dirty & S3V_UPLOAD_POINTMODE) ||
-        (vmesa->dirty & S3V_UPLOAD_LINEMODE) ||
-        (vmesa->dirty & S3V_UPLOAD_TRIMODE) ) {
-
-    }
-    
-    if (vmesa->dirty & S3V_UPLOAD_POINTMODE) {
-       vmesa->dirty &= ~S3V_UPLOAD_POINTMODE;
-    }
-
-    if (vmesa->dirty & S3V_UPLOAD_LINEMODE) {
-       vmesa->dirty &= ~S3V_UPLOAD_LINEMODE;
-    }
-    
-    if (vmesa->dirty & S3V_UPLOAD_TRIMODE) {
-       vmesa->dirty &= ~S3V_UPLOAD_TRIMODE;
-    }
-
-    if (vmesa->dirty & S3V_UPLOAD_FOG) {
-       GLchan c[3], col;
-       UNCLAMPED_FLOAT_TO_RGB_CHAN( c, vmesa->glCtx->Fog.Color );
-       DEBUG(("uploading ** FOG **\n"));
-       col = s3vPackColor(2, c[0], c[1], c[2], 0);
-       vmesa->dirty &= ~S3V_UPLOAD_FOG;
-    }
-    
-    if (vmesa->dirty & S3V_UPLOAD_DITHER) {
-       vmesa->dirty &= ~S3V_UPLOAD_DITHER;
-    }
-    
-    if (vmesa->dirty & S3V_UPLOAD_LOGICOP) {
-       vmesa->dirty &= ~S3V_UPLOAD_LOGICOP;
-    }
-    
-    if (vmesa->dirty & S3V_UPLOAD_CLIP) {
-       vmesa->dirty &= ~S3V_UPLOAD_CLIP;
-       DEBUG(("S3V_UPLOAD_CLIP\n"));
-       DEBUG(("vmesa->ScissorLR: %i\n",  vmesa->ScissorLR));
-       DEBUG(("vmesa->ScissorTB: %i\n",  vmesa->ScissorTB));
-    }
-
-    if (vmesa->dirty & S3V_UPLOAD_MASKS) {
-       vmesa->dirty &= ~S3V_UPLOAD_MASKS;
-       DEBUG(("S3V_UPLOAD_BLEND\n"));
-    }
-    
-    if (vmesa->dirty & S3V_UPLOAD_ALPHA) {
-       vmesa->dirty &= ~S3V_UPLOAD_ALPHA;
-       DEBUG(("S3V_UPLOAD_ALPHA\n"));
-    }
-    
-    if (vmesa->dirty & S3V_UPLOAD_SHADE) {
-       vmesa->dirty &= ~S3V_UPLOAD_SHADE;
-    }
-    
-    if (vmesa->dirty & S3V_UPLOAD_POLYGON) {
-       vmesa->dirty &= ~S3V_UPLOAD_POLYGON;
-    }
-    
-    if (vmesa->dirty & S3V_UPLOAD_DEPTH) {
-       vmesa->dirty &= ~S3V_UPLOAD_DEPTH;
-       DEBUG(("S3V_UPLOAD_DEPTH: DepthMode = 0x%x08\n", vmesa->DepthMode));
-    }
-    
-    if (vmesa->dirty & S3V_UPLOAD_GEOMETRY) {
-       vmesa->dirty &= ~S3V_UPLOAD_GEOMETRY;
-    }
-
-    if (vmesa->dirty & S3V_UPLOAD_TRANSFORM) {
-       vmesa->dirty &= ~S3V_UPLOAD_TRANSFORM;
-    }
-    
-    if (vmesa->dirty & S3V_UPLOAD_TEX0) {
-       s3vTextureObjectPtr curTex = vmesa->CurrentTexObj[0];
-       vmesa->dirty &= ~S3V_UPLOAD_TEX0;
-       DEBUG(("S3V_UPLOAD_TEX0\n"));
-       if (curTex) {
-               DEBUG(("S3V_UPLOAD_TEX0: curTex\n"));
-       } else {
-               DEBUG(("S3V_UPLOAD_TEX0: !curTex\n"));
-       }
-    }
-}
-
-void s3vDDUpdateHWState( GLcontext *ctx )
-{
-       s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-
-       int new_state = vmesa->new_state;
-
-       /* s3vUpdateClipping( ctx ); */
-
-       if ( new_state )
-       {
-
-               vmesa->new_state = 0;
-
-               /* Update the various parts of the context's state.
-                */
-               if ( new_state & S3V_NEW_ALPHA )
-                       s3vUpdateAlphaMode( ctx );
-
-               if ( new_state & S3V_NEW_DEPTH )
-                       s3vUpdateZMode( ctx );
-
-               if ( new_state & S3V_NEW_FOG )
-                       s3vUpdateFogAttrib( ctx );
-
-               if ( new_state & S3V_NEW_CLIP )
-               {
-                       DEBUG(("---> going to s3vUpdateClipping\n"));
-                       s3vUpdateClipping( ctx );
-               }
-
-               if ( new_state & S3V_NEW_POLYGON )
-                       s3vUpdatePolygon( ctx );
-
-               if ( new_state & S3V_NEW_CULL )
-                       s3vUpdateCull( ctx );
-
-               if ( new_state & S3V_NEW_MASKS )
-                       s3vUpdateMasks( ctx );
-
-               if ( new_state & S3V_NEW_WINDOW )
-                       s3vUpdateWindow( ctx );
-/*
-               if ( new_state & S3_NEW_TEXTURE )
-                       s3vUpdateTextureState( ctx );           
-*/
-               CMDCHANGE();
-       }
-
-       /* HACK ! */
-       s3vEmitHwState( vmesa );
-}
-
-
-static void s3vDDUpdateState( GLcontext *ctx, GLuint new_state )
-{
-       _swrast_InvalidateState( ctx, new_state );
-       _swsetup_InvalidateState( ctx, new_state );
-       _vbo_InvalidateState( ctx, new_state );
-       _tnl_InvalidateState( ctx, new_state );
-       S3V_CONTEXT(ctx)->new_gl_state |= new_state;
-}
-
-
-/* Initialize the context's hardware state.
- */
-void s3vInitState( s3vContextPtr vmesa )
-{
-       vmesa->new_state = 0;
-}
-
-/* Initialize the driver's state functions.
- */
-void s3vInitStateFuncs( GLcontext *ctx )
-{
-   ctx->Driver.UpdateState             = s3vDDUpdateState;
-
-   ctx->Driver.Clear                   = s3vDDClear;
-   ctx->Driver.ClearIndex              = NULL;
-   ctx->Driver.ClearColor              = s3vDDClearColor;
-   ctx->Driver.DrawBuffer              = s3vDDSetDrawBuffer; 
-   ctx->Driver.ReadBuffer               = NULL; /* XXX */
-
-   ctx->Driver.IndexMask               = NULL;
-   ctx->Driver.ColorMask               = NULL; /* s3vDDColorMask; */ /* FIXME */
-
-   ctx->Driver.AlphaFunc               = s3vDDAlphaFunc; /* FIXME */
-#if 0
-   ctx->Driver.BlendEquation           = NULL; /* s3vDDBlendEquation; */
-   ctx->Driver.BlendFunc               = s3vDDBlendFunc; /* FIXME */
-#endif
-   ctx->Driver.BlendFuncSeparate       = NULL; /* s3vDDBlendFuncSeparate; */
-   ctx->Driver.ClearDepth              = s3vDDClearDepth;
-   ctx->Driver.CullFace                        = s3vDDCullFace; 
-   ctx->Driver.FrontFace               = s3vDDFrontFace;
-   ctx->Driver.DepthFunc               = s3vDDDepthFunc;       /* FIXME */
-   ctx->Driver.DepthMask               = s3vDDDepthMask;       /* FIXME */
-   ctx->Driver.DepthRange              = NULL; /* s3vDDDepthRange; */
-   ctx->Driver.Enable                  = s3vDDEnable;          /* FIXME */
-   ctx->Driver.Finish                  = s3vDDFinish;
-   ctx->Driver.Flush                   = s3vDDFlush;
-#if 1
-   ctx->Driver.Fogfv                   = NULL; /* s3vDDFogfv; */
-#endif
-   ctx->Driver.Hint                    = NULL;
-   ctx->Driver.LineWidth               = NULL; /* s3vDDLineWidth; */
-   ctx->Driver.LineStipple             = NULL; /* s3vDDLineStipple; */
-#if ENABLELIGHTING
-   ctx->Driver.Lightfv                 = NULL; /* s3vDDLightfv; */
-
-   ctx->Driver.LightModelfv            = NULL; /* s3vDDLightModelfv; */
-#endif
-   ctx->Driver.LogicOpcode             = NULL; /* s3vDDLogicalOpcode; */
-   ctx->Driver.PointSize               = NULL; /* s3vDDPointSize; */
-   ctx->Driver.PolygonMode             = NULL; /* s3vDDPolygonMode; */
-   ctx->Driver.PolygonStipple          = NULL; /* s3vDDPolygonStipple; */
-   ctx->Driver.Scissor                 = s3vDDScissor; /* ScissorLR / ScissorTB */
-   ctx->Driver.ShadeModel              = NULL; /* s3vDDShadeModel; */
-   ctx->Driver.Viewport                        = NULL; /* s3vDDViewport; */
-}
diff --git a/src/mesa/drivers/dri/s3v/s3v_tex.c b/src/mesa/drivers/dri/s3v/s3v_tex.c
deleted file mode 100644 (file)
index ec1182f..0000000
+++ /dev/null
@@ -1,548 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "main/glheader.h"
-#include "main/mtypes.h"
-#include "main/simple_list.h"
-#include "main/enums.h"
-#include "main/mm.h"
-#include "main/texstore.h"
-#include "main/texformat.h"
-#include "main/teximage.h"
-#include "swrast/swrast.h"
-
-#include "s3v_context.h"
-#include "s3v_tex.h"
-
-
-extern void s3vSwapOutTexObj(s3vContextPtr vmesa, s3vTextureObjectPtr t);
-extern void s3vDestroyTexObj(s3vContextPtr vmesa, s3vTextureObjectPtr t);
-
-/*
-static GLuint s3vComputeLodBias(GLfloat bias)
-{
-#if TEX_DEBUG_ON
-       DEBUG_TEX(("*** s3vComputeLodBias ***\n"));
-#endif
-       return bias;
-}
-*/
-
-static void s3vSetTexWrapping(s3vContextPtr vmesa,
-                               s3vTextureObjectPtr t, 
-                              GLenum wraps, GLenum wrapt)
-{
-       GLuint t0 = t->TextureCMD;
-       GLuint cmd = vmesa->CMD;
-#if TEX_DEBUG_ON
-       static unsigned int times=0;
-       DEBUG_TEX(("*** s3vSetTexWrapping: #%i ***\n", ++times));
-#endif
-
-
-       t0 &= ~TEX_WRAP_MASK;
-       cmd &= ~TEX_WRAP_MASK;
-
-       if ((wraps != GL_CLAMP) || (wrapt != GL_CLAMP)) {
-               DEBUG(("TEX_WRAP_ON\n"));
-               t0 |= TEX_WRAP_ON;
-               cmd |= TEX_WRAP_ON; 
-       }
-
-       cmd |= TEX_WRAP_ON; /* FIXME: broken if off */
-       t->TextureCMD = t0;
-       vmesa->CMD = cmd;
-}
-
-
-static void s3vSetTexFilter(s3vContextPtr vmesa, 
-                            s3vTextureObjectPtr t, 
-                            GLenum minf, GLenum magf)
-{
-       GLuint t0 = t->TextureCMD;
-       GLuint cmd = vmesa->CMD;
-#if TEX_DEBUG_ON
-       static unsigned int times=0;
-       DEBUG_TEX(("*** s3vSetTexFilter: #%i ***\n", ++times));
-#endif
-
-       t0 &= ~TEX_FILTER_MASK;
-       cmd &= ~TEX_FILTER_MASK;
-
-       switch (minf) {
-               case GL_NEAREST:
-                       DEBUG(("GL_NEAREST\n"));
-                       t0 |= NEAREST;
-                       cmd |= NEAREST;
-                       break;
-               case GL_LINEAR:
-                       DEBUG(("GL_LINEAR\n"));
-                       t0 |= LINEAR;
-                       cmd |= LINEAR;
-                       break;
-               case GL_NEAREST_MIPMAP_NEAREST:
-                       DEBUG(("GL_MIPMAP_NEAREST\n"));
-                       t0 |= MIP_NEAREST;
-                       cmd |= MIP_NEAREST;
-                       break;
-               case GL_LINEAR_MIPMAP_NEAREST:
-                       DEBUG(("GL_LINEAR_MIPMAP_NEAREST\n"));
-                       t0 |= LINEAR_MIP_NEAREST;
-                       cmd |= LINEAR_MIP_NEAREST;
-                       break;
-               case GL_NEAREST_MIPMAP_LINEAR:
-                       DEBUG(("GL_NEAREST_MIPMAP_LINEAR\n"));
-                       t0 |= MIP_LINEAR;
-                       cmd |= MIP_LINEAR;
-                       break;
-               case GL_LINEAR_MIPMAP_LINEAR:
-                       DEBUG(("GL_LINEAR_MIPMAP_LINEAR\n"));
-                       t0 |= LINEAR_MIP_LINEAR;
-                       cmd |= LINEAR_MIP_LINEAR;
-                       break;
-               default:
-                       break;
-       }
-       /* FIXME: bilinear? */
-
-#if 0
-       switch (magf) {
-               case GL_NEAREST:
-                       break;
-               case GL_LINEAR:
-                       break;
-               default:
-                       break;
-       }  
-#endif
-
-       t->TextureCMD = t0;
-
-       DEBUG(("CMD was = 0x%x\n", vmesa->CMD));
-       DEBUG(("CMD is = 0x%x\n", cmd));
-
-       vmesa->CMD = cmd; 
-       /* CMDCHANGE(); */
-}
-
-
-static void s3vSetTexBorderColor(s3vContextPtr vmesa,
-                                 s3vTextureObjectPtr t, 
-                                 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]);
-
-#if TEX_DEBUG_ON
-       static unsigned int times=0;
-       DEBUG_TEX(("*** s3vSetTexBorderColor: #%i ***\n", ++times));
-#endif
-
-       /*FIXME: it should depend on tex col format */
-       /* switch(t0 ... t->TextureColorMode) */
-
-       /* case TEX_COL_ARGB1555: */
-       t->TextureBorderColor = S3VIRGEPACKCOLOR555(c[0], c[1], c[2], c[3]);
-
-       DEBUG(("TextureBorderColor = 0x%x\n", t->TextureBorderColor));
-
-       vmesa->TextureBorderColor = t->TextureBorderColor;
-}
-
-static void s3vTexParameter( GLcontext *ctx, GLenum target,
-                             struct gl_texture_object *tObj,
-                             GLenum pname, const GLfloat *params )
-{
-       s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-       s3vTextureObjectPtr t = (s3vTextureObjectPtr) tObj->DriverData;
-#if TEX_DEBUG_ON
-       static unsigned int times=0;
-       DEBUG_TEX(("*** s3vTexParameter: #%i ***\n", ++times));
-#endif
-   
-       if (!t) return;
-
-       /* Can't do the update now as we don't know whether to flush
-        * vertices or not.  Setting vmesa->new_state means that
-        * s3vUpdateTextureState() will be called before any triangles are
-        * rendered.  If a statechange has occurred, it will be detected at
-        * that point, and buffered vertices flushed.  
-       */
-       switch (pname) {
-       case GL_TEXTURE_MIN_FILTER:
-       case GL_TEXTURE_MAG_FILTER:
-               s3vSetTexFilter( vmesa, t, tObj->MinFilter, tObj->MagFilter );
-               break;
-
-       case GL_TEXTURE_WRAP_S:
-       case GL_TEXTURE_WRAP_T:
-               s3vSetTexWrapping( vmesa, t, tObj->WrapS, tObj->WrapT );
-               break;
-  
-       case GL_TEXTURE_BORDER_COLOR:
-               s3vSetTexBorderColor( vmesa, t, tObj->BorderColor );
-               break;
-
-       case GL_TEXTURE_BASE_LEVEL:
-       case GL_TEXTURE_MAX_LEVEL:
-       case GL_TEXTURE_MIN_LOD:
-       case GL_TEXTURE_MAX_LOD:
-       /* This isn't the most efficient solution but there doesn't appear to
-        * be a nice alternative for Virge.  Since there's no LOD clamping,
-        * we just have to rely on loading the right subset of mipmap levels
-        * to simulate a clamped LOD.
-        */
-               s3vSwapOutTexObj( vmesa, t ); 
-               break;
-
-       default:
-               return;
-       }
-
-       if (t == vmesa->CurrentTexObj[0])
-               vmesa->dirty |= S3V_UPLOAD_TEX0;
-
-#if 0
-       if (t == vmesa->CurrentTexObj[1]) {
-               vmesa->dirty |= S3V_UPLOAD_TEX1;
-       }
-#endif
-}
-
-
-static void s3vTexEnv( GLcontext *ctx, GLenum target, 
-                       GLenum pname, const GLfloat *param )
-{
-       s3vContextPtr vmesa = S3V_CONTEXT( ctx );
-       GLuint unit = ctx->Texture.CurrentUnit;
-#if TEX_DEBUG_ON
-       static unsigned int times=0;
-       DEBUG_TEX(("*** s3vTexEnv: #%i ***\n", ++times));
-#endif
-
-       /* Only one env color.  Need a fallback if env colors are different
-        * and texture setup references env color in both units.  
-        */
-       switch (pname) {
-       case GL_TEXTURE_ENV_COLOR: {
-               struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
-               GLfloat *fc = texUnit->EnvColor;
-               GLuint r, g, b, a, col;
-               CLAMPED_FLOAT_TO_UBYTE(r, fc[0]);
-               CLAMPED_FLOAT_TO_UBYTE(g, fc[1]);
-               CLAMPED_FLOAT_TO_UBYTE(b, fc[2]);
-               CLAMPED_FLOAT_TO_UBYTE(a, fc[3]);
-
-               col =  ((a << 24) | 
-                       (r << 16) | 
-                       (g <<  8) | 
-                       (b <<  0));
-
-               break;
-       }
-       case GL_TEXTURE_ENV_MODE:
-               vmesa->TexEnvImageFmt[unit] = 0; /* force recalc of env state */
-               break;
-       case GL_TEXTURE_LOD_BIAS_EXT: {
-/*
-               struct gl_texture_object *tObj =
-                       ctx->Texture.Unit[unit]._Current;
-
-               s3vTextureObjectPtr t = (s3vTextureObjectPtr) tObj->DriverData;
-*/
-               break;
-       }
-       default:
-               break;
-       }
-} 
-
-static void s3vTexImage1D( GLcontext *ctx, GLenum target, GLint level,
-                           GLint internalFormat,
-                           GLint width, GLint border,
-                           GLenum format, GLenum type, 
-                           const GLvoid *pixels,
-                           const struct gl_pixelstore_attrib *pack,
-                           struct gl_texture_object *texObj,
-                           struct gl_texture_image *texImage )
-{
-       s3vContextPtr vmesa = S3V_CONTEXT( ctx );
-       s3vTextureObjectPtr t = (s3vTextureObjectPtr) texObj->DriverData;
-#if TEX_DEBUG_ON
-       static unsigned int times=0;
-       DEBUG_TEX(("*** s3vTexImage1D: #%i ***\n", ++times));
-#endif
-
-#if 1 
-       if (t) {
-#if _TEXFLUSH
-               DMAFLUSH();
-#endif
-               s3vSwapOutTexObj( vmesa, t );
-/*
-               s3vDestroyTexObj( vmesa, t );
-               texObj->DriverData = 0;
-*/
-       }
-#endif
-       _mesa_store_teximage1d( ctx, target, level, internalFormat,
-                               width, border, format, type,
-                               pixels, pack, texObj, texImage );
-}
-
-static void s3vTexSubImage1D( GLcontext *ctx, 
-                              GLenum target,
-                              GLint level,     
-                              GLint xoffset,
-                              GLsizei width,
-                              GLenum format, GLenum type,
-                              const GLvoid *pixels,
-                              const struct gl_pixelstore_attrib *pack,
-                              struct gl_texture_object *texObj,
-                              struct gl_texture_image *texImage )
-{
-       s3vContextPtr vmesa = S3V_CONTEXT( ctx );
-       s3vTextureObjectPtr t = (s3vTextureObjectPtr) texObj->DriverData;
-#if TEX_DEBUG_ON
-       static unsigned int times=0;
-       DEBUG_TEX(("*** s3vTexSubImage1D: #%i ***\n", ++times));
-#endif
-
-#if 1
-       if (t) {
-#if _TEXFLUSH
-               DMAFLUSH();
-#endif
-               s3vSwapOutTexObj( vmesa, t );
-/*
-               s3vDestroyTexObj( vmesa, t );
-               texObj->DriverData = 0;
-*/
-       }
-#endif
-       _mesa_store_texsubimage1d(ctx, target, level, xoffset, width, 
-                               format, type, pixels, pack, texObj,
-                               texImage);
-}
-
-static void s3vTexImage2D( GLcontext *ctx, GLenum target, GLint level,
-                           GLint internalFormat,
-                           GLint width, GLint height, GLint border,
-                           GLenum format, GLenum type, const GLvoid *pixels,
-                           const struct gl_pixelstore_attrib *packing,
-                           struct gl_texture_object *texObj,
-                           struct gl_texture_image *texImage )
-{
-       s3vContextPtr vmesa = S3V_CONTEXT( ctx );
-       s3vTextureObjectPtr t = (s3vTextureObjectPtr) texObj->DriverData;
-
-#if TEX_DEBUG_ON
-       static unsigned int times=0;
-       DEBUG_TEX(("*** s3vTexImage2D: #%i ***\n", ++times));
-#endif
-
-#if 1 
-       if (t) {
-#if _TEXFLUSH
-               DMAFLUSH();
-#endif
-               s3vSwapOutTexObj( vmesa, t ); 
-/*
-               s3vDestroyTexObj( vmesa, t );
-               texObj->DriverData = 0;
-*/
-       }
-#endif
-       _mesa_store_teximage2d( ctx, target, level, internalFormat,
-                               width, height, border, format, type,
-                               pixels, packing, texObj, texImage );
-}
-
-static void s3vTexSubImage2D( GLcontext *ctx, 
-                              GLenum target,
-                              GLint level,     
-                              GLint xoffset, GLint yoffset,
-                              GLsizei width, GLsizei height,
-                              GLenum format, GLenum type,
-                              const GLvoid *pixels,
-                              const struct gl_pixelstore_attrib *packing,
-                              struct gl_texture_object *texObj,
-                              struct gl_texture_image *texImage )
-{
-       s3vContextPtr vmesa = S3V_CONTEXT( ctx );
-       s3vTextureObjectPtr t = (s3vTextureObjectPtr) texObj->DriverData;
-#if TEX_DEBUG_ON
-       static unsigned int times=0;
-       DEBUG_TEX(("*** s3vTexSubImage2D: #%i ***\n", ++times));
-#endif
-
-#if 1
-       if (t) {
-#if _TEXFLUSH
-               DMAFLUSH();
-#endif
-               s3vSwapOutTexObj( vmesa, t );
-/* 
-               s3vDestroyTexObj( vmesa, t );
-               texObj->DriverData = 0;
-*/
-       }
-#endif
-       _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width, 
-                               height, format, type, pixels, packing, texObj,
-                               texImage);
-}
-
-
-static void s3vBindTexture( GLcontext *ctx, GLenum target,
-                            struct gl_texture_object *tObj )
-{
-       s3vContextPtr vmesa = S3V_CONTEXT( ctx );
-       s3vTextureObjectPtr t = (s3vTextureObjectPtr) tObj->DriverData;
-       GLuint cmd = vmesa->CMD;
-#if TEX_DEBUG_ON
-       static unsigned int times=0;
-       DEBUG_TEX(("*** s3vBindTexture: #%i ***\n", ++times));
-#endif
-
-       if (!t) {
-/*
-               GLfloat bias = ctx->Texture.Unit[ctx->Texture.CurrentUnit].LodBias;
-*/
-               t = CALLOC_STRUCT(s3v_texture_object_t);
-
-               /* Initialize non-image-dependent parts of the state:
-                */
-               t->globj = tObj;
-#if 0
-               if (target == GL_TEXTURE_2D) {
-               } else
-               if (target == GL_TEXTURE_1D) {
-               }
-
-#if X_BYTE_ORDER == X_LITTLE_ENDIAN
-               t->TextureFormat = (TF_LittleEndian |
-#else
-               t->TextureFormat = (TF_BigEndian |
-#endif
-#endif
-               t->dirty_images = ~0;
-
-               tObj->DriverData = t;
-               make_empty_list( t );
-#if 0
-               s3vSetTexWrapping( vmesa, t, tObj->WrapS, tObj->WrapT );
-               s3vSetTexFilter( vmesa, t, tObj->MinFilter, tObj->MagFilter );
-               s3vSetTexBorderColor( vmesa, t, tObj->BorderColor );
-#endif
-       }
-
-       cmd = vmesa->CMD & ~MIP_MASK;
-    vmesa->dirty |= S3V_UPLOAD_TEX0;
-    vmesa->TexOffset = t->TextureBaseAddr[tObj->BaseLevel];
-    vmesa->TexStride = t->Pitch;
-    cmd |= MIPMAP_LEVEL(t->WidthLog2);
-       vmesa->CMD = cmd;
-       vmesa->restore_primitive = -1;
-#if 0
-       printf("t->TextureBaseAddr[0] = 0x%x\n", t->TextureBaseAddr[0]);
-       printf("t->TextureBaseAddr[1] = 0x%x\n", t->TextureBaseAddr[1]);
-       printf("t->TextureBaseAddr[2] = 0x%x\n", t->TextureBaseAddr[2]);
-#endif
-}
-
-
-static void s3vDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
-{
-       s3vTextureObjectPtr t = (s3vTextureObjectPtr)tObj->DriverData;
-#if TEX_DEBUG_ON
-       static unsigned int times=0;
-       DEBUG_TEX(("*** s3vDeleteTexture: #%i ***\n", ++times));
-#endif
-
-       if (t) {
-               s3vContextPtr vmesa = S3V_CONTEXT( ctx );
-
-#if _TEXFLUSH
-               if (vmesa) {
-                       DMAFLUSH();
-               }
-#endif
-
-               s3vDestroyTexObj( vmesa, t );
-               tObj->DriverData = 0;
-
-       }
-}
-
-static GLboolean s3vIsTextureResident( GLcontext *ctx, 
-                                       struct gl_texture_object *tObj )
-{
-       s3vTextureObjectPtr t = (s3vTextureObjectPtr)tObj->DriverData;
-#if TEX_DEBUG_ON
-       static unsigned int times=0;
-       DEBUG_TEX(("*** s3vIsTextureResident: #%i ***\n", ++times));
-#endif
-   
-       return (t && t->MemBlock);
-}
-
-static void s3vInitTextureObjects( GLcontext *ctx )
-{
-       /* s3vContextPtr vmesa = S3V_CONTEXT(ctx); */
-       struct gl_texture_object *texObj;
-       GLuint tmp = ctx->Texture.CurrentUnit;
-#if TEX_DEBUG_ON
-       static unsigned int times=0;
-       DEBUG_TEX(("*** s3vInitTextureObjects: #%i ***\n", ++times));
-#endif
-
-#if 1
-       ctx->Texture.CurrentUnit = 0;
-
-       texObj = ctx->Texture.Unit[0].CurrentTex[TEXTURE_1D_INDEX];
-       s3vBindTexture( ctx, GL_TEXTURE_1D, texObj );
-
-       texObj = ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX];
-       s3vBindTexture( ctx, GL_TEXTURE_2D, texObj );
-#endif
-
-#if 0
-       ctx->Texture.CurrentUnit = 1;
-
-       texObj = ctx->Texture.Unit[1].CurrentTex[TEXTURE_1D_INDEX];
-       s3vBindTexture( ctx, GL_TEXTURE_1D, texObj );
-
-       texObj = ctx->Texture.Unit[1].CurrentTex[TEXTURE_2D_INDEX];
-       s3vBindTexture( ctx, GL_TEXTURE_2D, texObj );
-#endif
-
-       ctx->Texture.CurrentUnit = tmp;
-}
-
-
-void s3vInitTextureFuncs( GLcontext *ctx )
-{
-#if TEX_DEBUG_ON
-       static unsigned int times=0;
-       DEBUG_TEX(("*** s3vInitTextureFuncs: #%i ***\n", ++times));
-#endif
-
-       ctx->Driver.TexEnv = s3vTexEnv;
-       ctx->Driver.TexImage2D = s3vTexImage2D;
-       ctx->Driver.TexSubImage2D = s3vTexSubImage2D;
-       ctx->Driver.BindTexture = s3vBindTexture;
-       ctx->Driver.DeleteTexture = s3vDeleteTexture;
-       ctx->Driver.TexParameter = s3vTexParameter;
-       ctx->Driver.UpdateTexturePalette = 0;
-       ctx->Driver.IsTextureResident = s3vIsTextureResident;
-
-       s3vInitTextureObjects( ctx );
-}
diff --git a/src/mesa/drivers/dri/s3v/s3v_tex.h b/src/mesa/drivers/dri/s3v/s3v_tex.h
deleted file mode 100644 (file)
index a823fe2..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#ifndef _S3V_TEX_H
-#define _S3V_TEX_H
-
-#define TEX_DEBUG_ON 0
-
-extern void s3vUpdateTexLRU( s3vContextPtr vmesa, s3vTextureObjectPtr t );
-
-#if TEX_DEBUG_ON
-#define DEBUG_TEX(str) printf str
-#else
-#define DEBUG_TEX(str) /* str */
-#endif
-
-#define _TEXFLUSH 1 /* flush before uploading */
-#define _TEXLOCK  1 /* lock before writing new texures to card mem */
-                                       /*      if you turn it on you will gain stability and image
-                                               quality, but you will loose performance (~10%) */
-#define _TEXFALLBACK 0 /* fallback to software for -big- textures (slow) */
-                                       /* turning this off, you will lose some tex (e.g. mountains
-                                          on tuxracer) but you will increase average playability */
-
-#define _TEXALIGN 0x00000007
-
-#endif
diff --git a/src/mesa/drivers/dri/s3v/s3v_texmem.c b/src/mesa/drivers/dri/s3v/s3v_texmem.c
deleted file mode 100644 (file)
index 705d105..0000000
+++ /dev/null
@@ -1,582 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "main/glheader.h"
-#include "main/macros.h"
-#include "main/mtypes.h"
-#include "main/simple_list.h"
-#include "main/enums.h"
-
-#include "main/mm.h"
-#include "s3v_context.h"
-#include "s3v_lock.h"
-#include "s3v_tex.h"
-
-void s3vSwapOutTexObj(s3vContextPtr vmesa, s3vTextureObjectPtr t);
-void s3vUpdateTexLRU( s3vContextPtr vmesa, s3vTextureObjectPtr t );
-
-
-void s3vDestroyTexObj(s3vContextPtr vmesa, s3vTextureObjectPtr t)
-{
-#if TEX_DEBUG_ON
-   static unsigned int times=0;
-   DEBUG_TEX(("*** s3vDestroyTexObj: #%i ***\n", ++times));
-#endif
-
-   if (!t) return;
-
-/* FIXME: useful? */
-#if _TEXFLUSH
-       if (vmesa)
-               DMAFLUSH();
-#endif
-
-   /* This is sad - need to sync *in case* we upload a texture
-    * to this newly free memory...
-    */
-   if (t->MemBlock) {
-      mmFreeMem(t->MemBlock);
-      t->MemBlock = 0;
-
-      if (vmesa && t->age > vmesa->dirtyAge)
-            vmesa->dirtyAge = t->age;
-   }
-
-   if (t->globj)
-      t->globj->DriverData = NULL;
-
-   if (vmesa) {
-      if (vmesa->CurrentTexObj[0] == t) {
-               vmesa->CurrentTexObj[0] = 0;
-               vmesa->dirty &= ~S3V_UPLOAD_TEX0;
-      }
-
-#if 0
-      if (vmesa->CurrentTexObj[1] == t) {
-         vmesa->CurrentTexObj[1] = 0;
-         vmesa->dirty &= ~S3V_UPLOAD_TEX1;
-      }
-#endif
-   }
-
-   remove_from_list(t);
-   FREE(t);
-}
-
-
-void s3vSwapOutTexObj(s3vContextPtr vmesa, s3vTextureObjectPtr t)
-{
-/*   int i; */
-#if TEX_DEBUG_ON
-   static unsigned int times=0;
-   DEBUG_TEX(("*** s3vSwapOutTexObj: #%i ***\n", ++times));
-#endif
-
-   if (t->MemBlock) {
-
-      mmFreeMem(t->MemBlock);
-      t->MemBlock = 0;
-
-      if (t->age > vmesa->dirtyAge)
-         vmesa->dirtyAge = t->age;
-   
-      t->dirty_images = ~0; 
-      move_to_tail(&(vmesa->SwappedOut), t);
-   }
-}
-
-
-/* Upload an image from mesa's internal copy.
- */
-
-static void s3vUploadTexLevel( s3vContextPtr vmesa, s3vTextureObjectPtr t,
-                               int level )
-{
-       __DRIscreenPrivate *sPriv = vmesa->driScreen;
-       const struct gl_texture_image *image = t->image[level].image;
-       int i,j;
-       int l2d;
-       /* int offset = 0; */
-       int words;
-       GLuint* dest;
-#if TEX_DEBUG_ON
-       static unsigned int times=0;
-#endif
-       if ( !image ) return;
-       if (image->Data == 0) return;
-
-       DEBUG_TEX(("*** s3vUploadTexLevel: #%i ***\n", ++times));
-       DEBUG_TEX(("level = %i\n", level));
-
-       l2d = 5; /* 32bits per texel == 1<<5 */
-/*
-       if (level == 0) 
-               ;
-*/
-       DEBUG_TEX(("t->image[%i].offset = 0x%x\n",
-               level, t->image[level].offset));
-               
-       t->TextureBaseAddr[level] = (GLuint)(t->BufAddr + t->image[level].offset
-               + _TEXALIGN) & (GLuint)(~_TEXALIGN);
-       dest = (GLuint*)(sPriv->pFB + t->TextureBaseAddr[level]); 
-
-       DEBUG_TEX(("sPriv->pFB = 0x%x\n", sPriv->pFB));
-       DEBUG_TEX(("dest = 0x%x\n", dest));
-       DEBUG_TEX(("dest - sPriv->pFB = 0x%x\n", ((int)dest - (int)sPriv->pFB)));
-
-       /* NOTE: we implicitly suppose t->texelBytes == 2 */
-
-       words = (image->Width * image->Height) >> 1;
-
-       DEBUG_TEX(("\n\n"));
-
-       switch (t->image[level].internalFormat) {
-       case GL_RGB:
-       case 3:
-       {
-               GLubyte *src = (GLubyte *)image->Data;
-
-               DEBUG_TEX(("GL_RGB:\n"));
-/*
-               if (level == 0)
-                       ;
-*/
-               /* The UGLY way, and SLOW : use DMA FIXME ! */
-
-               for (i = 0; i < words; i++) {
-               unsigned int data;
-               /* data = PACK_COLOR_565(src[0],src[1],src[2]); */
-               data = S3VIRGEPACKCOLOR555(src[0],src[1],src[2],255)
-                       |(S3VIRGEPACKCOLOR555(src[3],src[4],src[5],255)<<16);
-
-               *dest++ = data;
-               /* src += 3; */
-               src +=6;
-       }
-       }
-       break;
-
-       case GL_RGBA:
-       case 4:
-       {
-               GLubyte *src = (GLubyte *)image->Data;
-
-               DEBUG_TEX(("GL_RGBA:\n"));
-/*
-               if (level == 0)
-                       ;
-*/
-               for (i = 0; i < words; i++) {           
-               unsigned int data;
-               
-               /* data = PACK_COLOR_8888(src[0],src[1],src[2],src[3]); */
-               data = S3VIRGEPACKCOLOR4444(src[0], src[1],src[2], src[3])
-               | (S3VIRGEPACKCOLOR4444(src[4], src[5], src[6], src[7]) << 16);
-               
-               *dest++ = data;
-               /* src += 4; */
-               src += 8;
-               }
-       }
-       break;
-
-       case GL_LUMINANCE:
-       {
-               GLubyte *src = (GLubyte *)image->Data;
-
-               DEBUG_TEX(("GL_LUMINANCE:\n"));
-/*
-               if (level == 0)
-                       ;
-*/
-               for (i = 0; i < words; i++) {
-               unsigned int data;
-               
-               /* data = PACK_COLOR_888(src[0],src[0],src[0]); */
-               data = S3VIRGEPACKCOLOR4444(src[0],src[0],src[0],src[0])
-               | (S3VIRGEPACKCOLOR4444(src[1],src[1],src[1],src[1]) << 16);
-                
-               *dest++ = data;
-               /* src ++; */
-               src +=2;
-               }
-       }
-       break;
-
-       case GL_INTENSITY:
-       {
-               GLubyte *src = (GLubyte *)image->Data;
-
-               DEBUG_TEX(("GL_INTENSITY:\n"));
-/*     
-               if (level == 0)
-                       ;
-*/
-               for (i = 0; i < words; i++) {
-               unsigned int data;
-               
-               /* data = PACK_COLOR_8888(src[0],src[0],src[0],src[0]); */
-               data = S3VIRGEPACKCOLOR4444(src[0],src[0],src[0],src[0])
-               | (S3VIRGEPACKCOLOR4444(src[1],src[1],src[1],src[1]) << 16);
-
-               *dest++ = data; 
-               /* src ++; */
-               src += 2;
-               }
-       }
-       break;
-
-       case GL_LUMINANCE_ALPHA:
-       {
-               GLubyte *src = (GLubyte *)image->Data;
-
-               DEBUG_TEX(("GL_LUMINANCE_ALPHA:\n"));
-/*
-               if (level == 0)
-                       ;
-*/
-               for (i = 0; i < words; i++) {
-               unsigned int data;
-               
-               /* data = PACK_COLOR_8888(src[0],src[0],src[0],src[1]); */
-               data = S3VIRGEPACKCOLOR4444(src[0],src[0],src[0],src[1])
-               | (S3VIRGEPACKCOLOR4444(src[2],src[2],src[2],src[3]) << 16);
-               
-               *dest++ = data;
-               /* src += 2; */
-               src += 4;
-               }
-       }
-       break;
-
-       case GL_ALPHA:
-       {
-               GLubyte *src = (GLubyte *)image->Data;
-
-               DEBUG_TEX(("GL_ALPHA:\n"));
-/*
-               if (level == 0)
-                       ;
-*/
-               for (i = 0; i < words; i++) {
-               unsigned int data;
-               
-               /* data = PACK_COLOR_8888(255,255,255,src[0]); */
-               data = S3VIRGEPACKCOLOR4444(255,255,255,src[0])
-               | (S3VIRGEPACKCOLOR4444(255,255,255,src[1]) << 16);
-               
-               *dest++ = data;
-               /* src += 1; */
-               src += 2;
-               }
-       }
-       break;
-
-       /* TODO: Translate color indices *now*:
-        */
-       case GL_COLOR_INDEX:
-       {
-       
-               GLubyte *dst = (GLubyte *)(t->BufAddr + t->image[level].offset);
-               GLubyte *src = (GLubyte *)image->Data;
-
-               DEBUG_TEX(("GL_COLOR_INDEX:\n"));
-
-               for (j = 0 ; j < image->Height ; j++, dst += t->Pitch) {
-                       for (i = 0 ; i < image->Width ; i++) {
-                               dst[i] = src[0];
-                               src += 1;
-                       }
-               }
-       }
-       break;
-
-       default:
-               fprintf(stderr, "Not supported texture format %s\n",
-                       _mesa_lookup_enum_by_nr(image->_BaseFormat));
-       }
-
-       DEBUG_TEX(("words = %i\n\n", words));
-}
-
-void s3vPrintLocalLRU( s3vContextPtr vmesa )
-{
-   s3vTextureObjectPtr t;
-   int sz = 1 << (vmesa->s3vScreen->logTextureGranularity);
-
-#if TEX_DEBUG_ON
-   static unsigned int times=0;
-   DEBUG_TEX(("*** s3vPrintLocalLRU: #%i ***\n", ++times));
-#endif
-
-   foreach( t, &vmesa->TexObjList ) {
-      if (!t->globj)
-         fprintf(stderr, "Placeholder %d at %x sz %x\n",
-                   t->MemBlock->ofs / sz,
-                   t->MemBlock->ofs,
-                   t->MemBlock->size);
-      else
-         fprintf(stderr, "Texture at %x sz %x\n",
-                   t->MemBlock->ofs,
-                   t->MemBlock->size);
-
-   }
-}
-
-void s3vPrintGlobalLRU( s3vContextPtr vmesa )
-{
-   int i, j;
-   S3VTexRegionPtr list = vmesa->sarea->texList;
-#if TEX_DEBUG_ON
-   static unsigned int times=0;
-   DEBUG_TEX(("*** s3vPrintGlobalLRU: #%i ***\n", ++times));
-#endif
-
-   for (i = 0, j = S3V_NR_TEX_REGIONS ; i < S3V_NR_TEX_REGIONS ; i++) {
-      fprintf(stderr, "list[%d] age %d next %d prev %d\n",
-             j, list[j].age, list[j].next, list[j].prev);
-      j = list[j].next;
-      if (j == S3V_NR_TEX_REGIONS) break;
-   }
-
-   if (j != S3V_NR_TEX_REGIONS)
-      fprintf(stderr, "Loop detected in global LRU\n");
-}
-
-
-void s3vResetGlobalLRU( s3vContextPtr vmesa )
-{
-   S3VTexRegionPtr list = vmesa->sarea->texList;
-   int sz = 1 << vmesa->s3vScreen->logTextureGranularity;
-   int i;
-
-#if TEX_DEBUG_ON
-   static unsigned int times=0;
-   DEBUG_TEX(("*** s3vResetGlobalLRU: #%i ***\n", ++times));
-#endif
-
-   /* (Re)initialize the global circular LRU list.  The last element
-    * in the array (S3V_NR_TEX_REGIONS) is the sentinal.  Keeping it
-    * at the end of the array allows it to be addressed rationally
-    * when looking up objects at a particular location in texture
-    * memory.
-    */
-   for (i = 0 ; (i+1) * sz <= vmesa->s3vScreen->textureSize ; i++) {
-      list[i].prev = i-1;
-      list[i].next = i+1;
-      list[i].age = 0;
-   }
-
-   i--;
-   list[0].prev = S3V_NR_TEX_REGIONS;
-   list[i].prev = i-1;
-   list[i].next = S3V_NR_TEX_REGIONS;
-   list[S3V_NR_TEX_REGIONS].prev = i;
-   list[S3V_NR_TEX_REGIONS].next = 0;
-   vmesa->sarea->texAge = 0;
-}
-
-
-void s3vUpdateTexLRU( s3vContextPtr vmesa, s3vTextureObjectPtr t )
-{
-/*
-   int i;
-   int logsz = vmesa->s3vScreen->logTextureGranularity;
-   int start = t->MemBlock->ofs >> logsz;
-   int end = (t->MemBlock->ofs + t->MemBlock->size - 1) >> logsz;
-   S3VTexRegionPtr list = vmesa->sarea->texList;
-*/
-
-#if TEX_DEBUG_ON
-   static unsigned int times=0;
-   DEBUG_TEX(("*** s3vUpdateTexLRU: #%i ***\n", ++times));
-#endif
-
-   vmesa->texAge = ++vmesa->sarea->texAge;
-
-   /* Update our local LRU
-    */
-   move_to_head( &(vmesa->TexObjList), t );
-
-   /* Update the global LRU
-    */
-#if 0
-   for (i = start ; i <= end ; i++) {
-
-      list[i].in_use = 1;
-      list[i].age = vmesa->texAge;
-
-      /* remove_from_list(i)
-       */
-      list[(unsigned)list[i].next].prev = list[i].prev;
-      list[(unsigned)list[i].prev].next = list[i].next;
-
-      /* insert_at_head(list, i)
-       */
-      list[i].prev = S3V_NR_TEX_REGIONS;
-      list[i].next = list[S3V_NR_TEX_REGIONS].next;
-      list[(unsigned)list[S3V_NR_TEX_REGIONS].next].prev = i;
-      list[S3V_NR_TEX_REGIONS].next = i;
-   }
-#endif
-}
-
-
-/* Called for every shared texture region which has increased in age
- * since we last held the lock.
- *
- * Figures out which of our textures have been ejected by other clients,
- * and pushes a placeholder texture onto the LRU list to represent
- * the other client's textures.
- */
-void s3vTexturesGone( s3vContextPtr vmesa,
-                      GLuint offset,
-                      GLuint size,
-                      GLuint in_use )
-{
-   s3vTextureObjectPtr t, tmp;
-#if TEX_DEBUG_ON
-   static unsigned int times=0;
-   DEBUG_TEX(("*** s3vTexturesGone: #%i ***\n", ++times));
-#endif
-
-   foreach_s ( t, tmp, &vmesa->TexObjList ) {
-
-      if (t->MemBlock->ofs >= offset + size ||
-         t->MemBlock->ofs + t->MemBlock->size <= offset)
-         continue;
-
-      /* It overlaps - kick it off.  Need to hold onto the currently bound
-       * objects, however.
-       */
-         s3vSwapOutTexObj( vmesa, t );
-   }
-
-   if (in_use) {
-                  t = (s3vTextureObjectPtr) calloc(1,sizeof(*t));
-                  if (!t) return;
-
-                  t->MemBlock = mmAllocMem( vmesa->texHeap, size, 0, offset);
-                  insert_at_head( &vmesa->TexObjList, t );
-   }
-
-   /* Reload any lost textures referenced by current vertex buffer.
-       */
-#if 0
-   if (vmesa->vertex_buffer) {
-                  int i, j;
-
-                  fprintf(stderr, "\n\nreload tex\n");
-
-                  for (i = 0 ; i < vmesa->statenr ; i++) {
-                                  for (j = 0 ; j < 2 ; j++) {
-                                                  s3vTextureObjectPtr t = vmesa->state_tex[j][i];
-                                                  if (t) {
-                                                                  if (t->MemBlock == 0)
-                                                                                  s3vUploadTexImages( vmesa, t );
-                                                  }
-                                  }
-                  }
-
-                  /* Hard to do this with the lock held:
-                       */
-                  /*        S3V_FIREVERTICES( vmesa ); */
-   }
-#endif
-}
-
-
-/* This is called with the lock held.  May have to eject our own and/or
- * other client's texture objects to make room for the upload.
- */
-void s3vUploadTexImages( s3vContextPtr vmesa, s3vTextureObjectPtr t )
-{
-       int i;
-       int ofs;
-       int numLevels;
-#if TEX_DEBUG_ON
-       static unsigned int times=0;
-       static unsigned int try=0;
-
-       DEBUG_TEX(("*** s3vUploadTexImages: #%i ***\n", ++times));
-       DEBUG_TEX(("vmesa->texHeap = 0x%x; t->totalSize = %i\n",
-               (unsigned int)vmesa->texHeap, t->totalSize));
-#endif
-
-       /* Do we need to eject LRU texture objects?
-        */
-       if (!t->MemBlock) {
-
-               while (1)
-               {
-                       /* int try = 0; */
-                       DEBUG_TEX(("trying to alloc mem for tex (try %i)\n", ++try));
-
-                       t->MemBlock = mmAllocMem( vmesa->texHeap, t->totalSize, 12, 0 );
-
-                       if (t->MemBlock)
-                               break;
-
-                       if (vmesa->TexObjList.prev == vmesa->CurrentTexObj[0]) {
-/*                         || vmesa->TexObjList.prev == vmesa->CurrentTexObj[1]) {
-                               fprintf(stderr, "Hit bound texture in upload\n");
-                               s3vPrintLocalLRU( vmesa ); */
-                               return;
-                       }
-
-                       if (vmesa->TexObjList.prev == &(vmesa->TexObjList)) {
-/*                             fprintf(stderr, "Failed to upload texture, sz %d\n",
-                                       t->totalSize);
-                               mmDumpMemInfo( vmesa->texHeap ); */
-                               return;
-                       }
-
-                       DEBUG_TEX(("swapping out: %p\n", vmesa->TexObjList.prev));
-                       s3vSwapOutTexObj( vmesa, vmesa->TexObjList.prev );
-               }
-
-       ofs = t->MemBlock->ofs;
-
-       t->BufAddr = vmesa->s3vScreen->texOffset + ofs;
-
-       DEBUG_TEX(("ofs = 0x%x\n", ofs));
-       DEBUG_TEX(("t->BufAddr = 0x%x\n", t->BufAddr));
-
-/* FIXME: check if we need it */
-#if 0
-       if (t == vmesa->CurrentTexObj[0]) {
-               vmesa->dirty |= S3V_UPLOAD_TEX0; 
-               vmesa->restore_primitive = -1; 
-       }
-#endif
-
-#if 0
-       if (t == vmesa->CurrentTexObj[1])
-               vmesa->dirty |= S3V_UPLOAD_TEX1;
-#endif
-
-       s3vUpdateTexLRU( vmesa, t );
-       }
-
-#if 0
-       if (vmesa->dirtyAge >= GET_DISPATCH_AGE(vmesa))
-               s3vWaitAgeLocked( vmesa, vmesa->dirtyAge );
-#endif
-
-#if _TEXLOCK
-       S3V_SIMPLE_FLUSH_LOCK(vmesa);
-#endif
-       numLevels = t->lastLevel - t->firstLevel + 1;
-       for (i = 0 ; i < numLevels ; i++)
-               if (t->dirty_images & (1<<i))
-                       s3vUploadTexLevel( vmesa, t, i );
-
-       t->dirty_images = 0;
-#if _TEXLOCK
-       S3V_SIMPLE_UNLOCK(vmesa);
-#endif
-}
diff --git a/src/mesa/drivers/dri/s3v/s3v_texstate.c b/src/mesa/drivers/dri/s3v/s3v_texstate.c
deleted file mode 100644 (file)
index 455bae6..0000000
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "main/glheader.h"
-#include "main/macros.h"
-#include "main/mtypes.h"
-#include "main/simple_list.h"
-#include "main/enums.h"
-
-#include "main/mm.h"
-#include "s3v_context.h"
-#include "s3v_tex.h"
-
-
-static void s3vSetTexImages( s3vContextPtr vmesa, 
-                             struct gl_texture_object *tObj )
-{
-   GLuint height, width, pitch, i, /*textureFormat,*/ log_pitch;
-   s3vTextureObjectPtr t = (s3vTextureObjectPtr) tObj->DriverData;
-   const struct gl_texture_image *baseImage = tObj->Image[0][tObj->BaseLevel];
-   GLint firstLevel, lastLevel, numLevels;
-   GLint log2Width, log2Height;
-#if TEX_DEBUG_ON
-   static unsigned int times=0;
-   DEBUG_TEX(("*** s3vSetTexImages: #%i ***\n", ++times));
-#endif
-
-   t->texelBytes = 2; /* FIXME: always 2 ? */
-
-   /* Compute which mipmap levels we really want to send to the hardware.
-    * This depends on the base image size, GL_TEXTURE_MIN_LOD,
-    * GL_TEXTURE_MAX_LOD, GL_TEXTURE_BASE_LEVEL, and GL_TEXTURE_MAX_LEVEL.
-    * Yes, this looks overly complicated, but it's all needed.
-    */
-   if (tObj->MinFilter == GL_LINEAR || tObj->MinFilter == GL_NEAREST) {
-      firstLevel = lastLevel = tObj->BaseLevel;
-   }
-   else {
-      firstLevel = tObj->BaseLevel + (GLint) (tObj->MinLod + 0.5);
-      firstLevel = MAX2(firstLevel, tObj->BaseLevel);
-      lastLevel = tObj->BaseLevel + (GLint) (tObj->MaxLod + 0.5);
-         lastLevel = MAX2(lastLevel, tObj->BaseLevel);
-      lastLevel = MIN2(lastLevel, tObj->BaseLevel + baseImage->MaxLog2);
-      lastLevel = MIN2(lastLevel, tObj->MaxLevel);
-      lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */
-   }
-
-   /* save these values */
-   t->firstLevel = firstLevel;
-   t->lastLevel = lastLevel;
-
-   numLevels = lastLevel - firstLevel + 1;
-
-   log2Width = tObj->Image[0][firstLevel]->WidthLog2;
-   log2Height = tObj->Image[0][firstLevel]->HeightLog2;
-
-
-   /* Figure out the amount of memory required to hold all the mipmap
-    * levels.  Choose the smallest pitch to accomodate the largest
-    * mipmap:
-    */
-   width = tObj->Image[0][firstLevel]->Width * t->texelBytes;
-   for (pitch = 32, log_pitch=2 ; pitch < width ; pitch *= 2 )
-      log_pitch++;
-   
-   /* All images must be loaded at this pitch.  Count the number of
-    * lines required:
-    */
-   for ( height = i = 0 ; i < numLevels ; i++ ) {
-      t->image[i].image = tObj->Image[0][firstLevel + i];
-      t->image[i].offset = height * pitch;
-      t->image[i].internalFormat = baseImage->_BaseFormat;
-      height += t->image[i].image->Height;
-      t->TextureBaseAddr[i] = (t->BufAddr + t->image[i].offset +
-         _TEXALIGN) & (GLuint)(~_TEXALIGN);
-   }
-
-   t->Pitch = pitch;
-   t->WidthLog2 = log2Width;
-   t->totalSize = height*pitch;
-   t->max_level = i-1;
-   vmesa->dirty |= S3V_UPLOAD_TEX0 /* | S3V_UPLOAD_TEX1*/;   
-   vmesa->restore_primitive = -1;
-   DEBUG(("<><>pitch = TexStride = %i\n", pitch));
-   DEBUG(("log2Width = %i\n", log2Width));
-
-   s3vUploadTexImages( vmesa, t );
-}
-
-static void s3vUpdateTexEnv( GLcontext *ctx, GLuint unit )
-{
-   s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-   const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
-   const struct gl_texture_object *tObj = texUnit->_Current;
-   const GLuint format = tObj->Image[0][tObj->BaseLevel]->_BaseFormat;
-/*
-   s3vTextureObjectPtr t = (s3vTextureObjectPtr)tObj->DriverData;
-   GLuint tc;
-*/
-   GLuint alpha = 0;
-   GLuint cmd = vmesa->CMD;
-#if TEX_DEBUG_ON
-   static unsigned int times=0;
-   DEBUG_TEX(("*** s3vUpdateTexEnv: %i ***\n", ++times));
-#endif
-
-   cmd &= ~TEX_COL_MASK;
-   cmd &= ~TEX_BLEND_MAKS;
-/*   cmd &= ~ALPHA_BLEND_MASK; */
-
-   DEBUG(("format = "));
-
-   switch (format) {
-   case GL_RGB:
-      DEBUG_TEX(("GL_RGB\n"));
-      cmd |= TEX_COL_ARGB1555;
-      break;
-   case GL_LUMINANCE:
-      DEBUG_TEX(("GL_LUMINANCE\n"));
-      cmd |= TEX_COL_ARGB4444;
-      alpha = 1; /* FIXME: check */
-      break;
-   case GL_ALPHA:
-      DEBUG_TEX(("GL_ALPHA\n"));
-      cmd |= TEX_COL_ARGB4444;
-      alpha = 1;
-      break;
-   case GL_LUMINANCE_ALPHA:
-      DEBUG_TEX(("GL_LUMINANCE_ALPHA\n"));
-      cmd |= TEX_COL_ARGB4444;
-      alpha = 1;
-      break;
-   case GL_INTENSITY:
-      DEBUG_TEX(("GL_INTENSITY\n"));
-      cmd |= TEX_COL_ARGB4444;
-      alpha = 1;
-      break;
-   case GL_RGBA:
-      DEBUG_TEX(("GL_RGBA\n"));
-      cmd |= TEX_COL_ARGB4444;
-      alpha = 1;
-      break;
-   case GL_COLOR_INDEX:
-      DEBUG_TEX(("GL_COLOR_INDEX\n"));
-      cmd |= TEX_COL_PAL;
-      break;
-   }
-
-   DEBUG_TEX(("EnvMode = "));
-
-   switch (texUnit->EnvMode) {
-   case GL_REPLACE:
-      DEBUG_TEX(("GL_REPLACE\n"));
-      cmd |= TEX_REFLECT; /* FIXME */
-      vmesa->_tri[1] = DO_TEX_UNLIT_TRI; /* FIXME: white tri hack */
-      vmesa->_alpha_tex = ALPHA_TEX /* * alpha */;
-      break;
-   case GL_MODULATE:
-      DEBUG_TEX(("GL_MODULATE\n"));
-      cmd |= TEX_MODULATE;
-      vmesa->_tri[1] = DO_TEX_LIT_TRI;
-#if 0
-       if (alpha)
-               vmesa->_alpha_tex = ALPHA_TEX /* * alpha */;
-       else
-               vmesa->_alpha_tex = ALPHA_SRC /* * alpha */;
-#else
-       vmesa->_alpha_tex = ALPHA_TEX ;
-#endif
-      break;
-   case GL_ADD:
-      DEBUG_TEX(("DEBUG_TEX\n"));
-      /* do nothing ???*/
-      break;
-   case GL_DECAL:
-      DEBUG_TEX(("GL_DECAL\n"));
-      cmd |= TEX_DECAL;
-      vmesa->_tri[1] = DO_TEX_LIT_TRI;
-      vmesa->_alpha_tex = ALPHA_OFF;
-      break;
-   case GL_BLEND:
-      DEBUG_TEX(("GL_BLEND\n"));
-      cmd |= TEX_DECAL;
-      vmesa->_tri[1] = DO_TEX_LIT_TRI;
-      vmesa->_alpha_tex = ALPHA_OFF; /* FIXME: sure? */
-      break;
-   default:
-      fprintf(stderr, "unknown tex env mode");
-      return;
-   }
-  
-   DEBUG_TEX(("\n\n    vmesa->CMD was 0x%x\n", vmesa->CMD));   
-   DEBUG_TEX((   "    vmesa->CMD is 0x%x\n\n", cmd ));
-
-   vmesa->_alpha[1] = vmesa->_alpha_tex;
-   vmesa->CMD = cmd; /* | MIPMAP_LEVEL(8); */
-   vmesa->restore_primitive = -1; 
-}
-
-static void s3vUpdateTexUnit( GLcontext *ctx, GLuint unit )
-{
-   s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
-   GLuint cmd = vmesa->CMD;
-#if TEX_DEBUG_ON
-   static unsigned int times=0;
-   DEBUG_TEX(("*** s3vUpdateTexUnit: %i ***\n", ++times));
-   DEBUG_TEX(("and vmesa->CMD was 0x%x\n", vmesa->CMD));
-#endif
-
-   if (texUnit->_ReallyEnabled == TEXTURE_2D_BIT) 
-   {
-      struct gl_texture_object *tObj = texUnit->_Current;
-      s3vTextureObjectPtr t = (s3vTextureObjectPtr)tObj->DriverData;
-
-      /* Upload teximages (not pipelined)
-       */
-      if (t->dirty_images) {
-#if _TEXFLUSH
-         DMAFLUSH();
-#endif
-         s3vSetTexImages( vmesa, tObj ); 
-         if (!t->MemBlock) {
-#if _TEXFALLBACK
-            FALLBACK( vmesa, S3V_FALLBACK_TEXTURE, GL_TRUE );
-#endif
-            return;
-         }
-      }
-
-      /* Update state if this is a different texture object to last
-       * time.
-       */
-#if 1
-      if (vmesa->CurrentTexObj[unit] != t) {
-         vmesa->dirty |= S3V_UPLOAD_TEX0 /* << unit */;
-         vmesa->CurrentTexObj[unit] = t;
-         s3vUpdateTexLRU( vmesa, t ); /* done too often */
-      }
-#endif
-      
-      /* Update texture environment if texture object image format or 
-       * texture environment state has changed.
-       */
-      if (tObj->Image[0][tObj->BaseLevel]->_BaseFormat !=
-          vmesa->TexEnvImageFmt[unit]) {
-         vmesa->TexEnvImageFmt[unit] = tObj->Image[0][tObj->BaseLevel]->_BaseFormat;
-         s3vUpdateTexEnv( ctx, unit );
-      }
-#if 1
-      cmd = vmesa->CMD & ~MIP_MASK;
-      vmesa->dirty |= S3V_UPLOAD_TEX0 /* << unit */;
-      vmesa->CurrentTexObj[unit] = t;
-      vmesa->TexOffset = t->TextureBaseAddr[tObj->BaseLevel];
-      vmesa->TexStride = t->Pitch;
-      cmd |= MIPMAP_LEVEL(t->WidthLog2);
-       
-      DEBUG_TEX(("\n\n>>  vmesa->CMD was 0x%x\n", vmesa->CMD));
-      DEBUG_TEX((    ">>  vmesa->CMD is 0x%x\n\n", cmd ));
-      DEBUG_TEX(("t->WidthLog2 = %i\n", t->WidthLog2));
-      DEBUG_TEX(("MIPMAP_LEVEL(t->WidthLog2) = 0x%x\n", MIPMAP_LEVEL(t->WidthLog2)));
-
-      vmesa->CMD = cmd;
-      vmesa->restore_primitive = -1;
-#endif
-   }
-   else if (texUnit->_ReallyEnabled) { /* _ReallyEnabled but != TEXTURE0_2D */
-#if _TEXFALLBACK
-      FALLBACK( vmesa, S3V_FALLBACK_TEXTURE, GL_TRUE );
-#endif
-   }
-   else /*if (vmesa->CurrentTexObj[unit])*/ { /* !_ReallyEnabled */
-      vmesa->CurrentTexObj[unit] = 0;
-      vmesa->TexEnvImageFmt[unit] = 0; 
-      vmesa->dirty &= ~(S3V_UPLOAD_TEX0<<unit); 
-   }
-}
-
-
-void s3vUpdateTextureState( GLcontext *ctx )
-{
-   s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-   (void) vmesa;
-#if TEX_DEBUG_ON
-   static unsigned int times=0;
-   DEBUG_TEX(("*** s3vUpdateTextureState: #%i ***\n", ++times));
-#endif
-
-#if _TEXFALLBACK   
-   FALLBACK( vmesa, S3V_FALLBACK_TEXTURE, GL_FALSE );
-#endif
-   s3vUpdateTexUnit( ctx, 0 );
-#if 0
-   s3vUpdateTexUnit( ctx, 1 );
-#endif
-}
diff --git a/src/mesa/drivers/dri/s3v/s3v_tris.c b/src/mesa/drivers/dri/s3v/s3v_tris.c
deleted file mode 100644 (file)
index fafd384..0000000
+++ /dev/null
@@ -1,850 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <sys/ioctl.h>
-
-#include "s3v_context.h"
-#include "s3v_vb.h"
-#include "s3v_tris.h"
-
-#include "main/glheader.h"
-#include "main/mtypes.h"
-#include "main/macros.h"
-#include "main/colormac.h"
-
-#include "swrast/swrast.h"
-#include "swrast_setup/swrast_setup.h"
-#include "tnl/tnl.h"
-#include "tnl/t_context.h"
-#include "tnl/t_pipeline.h"
-
-
-/***********************************************************************
- *                   Build hardware rasterization functions            *
- ***********************************************************************/
-
-#define DO_TRI                 1
-#define HAVE_RGBA              1
-#define HAVE_SPEC              0
-#define HAVE_BACK_COLORS       0
-#define HAVE_HW_FLATSHADE      1
-#define VERTEX                 s3vVertex
-#define TAB                    rast_tab
-
-#define VERT_SET_RGBA( v, c ) \
-do { \
-       UNCLAMPED_FLOAT_TO_RGBA_CHAN( v->ub4[4], c); \
-/*     *(v->ub4[4]) = c; \ */ \
-} while (0)
-#define VERT_COPY_RGBA( v0, v1 ) v0->ui[4] = v1->ui[4]
-/*
-#define VERT_COPY_RGBA1( v0, v1 ) v0->ui[4] = v1->ui[4]
-*/
-#define VERT_SAVE_RGBA( idx )    color[idx] = v[idx]->ui[4]
-#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[4] = color[idx]
-
-#define S3V_OFFSET_BIT         0x01
-#define S3V_TWOSIDE_BIT        0x02
-#define S3V_UNFILLED_BIT        0x04
-#define S3V_FALLBACK_BIT        0x08
-#define S3V_MAX_TRIFUNC        0x10
-
-
-static struct {
-       tnl_points_func         points;
-       tnl_line_func           line;
-       tnl_triangle_func       triangle;
-       tnl_quad_func           quad;
-} rast_tab[S3V_MAX_TRIFUNC];
-
-#define S3V_RAST_CULL_BIT      0x01
-#define S3V_RAST_FLAT_BIT      0x02
-#define S3V_RAST_TEX_BIT       0x04
-
-static s3v_point_func s3v_point_tab[0x8];
-static s3v_line_func s3v_line_tab[0x8];
-static s3v_tri_func s3v_tri_tab[0x8];
-static s3v_quad_func s3v_quad_tab[0x8];
-
-#define IND (0)
-#define TAG(x) x
-#include "s3v_tritmp.h"
-
-#define IND (S3V_RAST_CULL_BIT)
-#define TAG(x) x##_cull
-#include "s3v_tritmp.h"
-
-#define IND (S3V_RAST_FLAT_BIT)
-#define TAG(x) x##_flat
-#include "s3v_tritmp.h"
-
-#define IND (S3V_RAST_CULL_BIT|S3V_RAST_FLAT_BIT)
-#define TAG(x) x##_cull_flat
-#include "s3v_tritmp.h"
-
-#define IND (S3V_RAST_TEX_BIT)
-#define TAG(x) x##_tex
-#include "s3v_tritmp.h"
-
-#define IND (S3V_RAST_CULL_BIT|S3V_RAST_TEX_BIT)
-#define TAG(x) x##_cull_tex
-#include "s3v_tritmp.h"
-
-#define IND (S3V_RAST_FLAT_BIT|S3V_RAST_TEX_BIT)
-#define TAG(x) x##_flat_tex
-#include "s3v_tritmp.h"
-
-#define IND (S3V_RAST_CULL_BIT|S3V_RAST_FLAT_BIT|S3V_RAST_TEX_BIT)
-#define TAG(x) x##_cull_flat_tex
-#include "s3v_tritmp.h"
-
-static void init_rast_tab( void )
-{
-       DEBUG(("*** init_rast_tab ***\n"));
-
-       s3v_init();
-       s3v_init_cull();
-       s3v_init_flat();
-       s3v_init_cull_flat();
-       s3v_init_tex();
-       s3v_init_cull_tex();
-       s3v_init_flat_tex();
-       s3v_init_cull_flat_tex();
-}
-
-/***********************************************************************
- *                    Rasterization fallback helpers                   *
- ***********************************************************************/
-
-
-/* This code is hit only when a mix of accelerated and unaccelerated
- * primitives are being drawn, and only for the unaccelerated
- * primitives.  
- */
-
-#if 0
-static void 
-s3v_fallback_quad( s3vContextPtr vmesa, 
-                   const s3vVertex *v0, 
-                   const s3vVertex *v1, 
-                   const s3vVertex *v2, 
-                   const s3vVertex *v3 )
-{
-   GLcontext *ctx = vmesa->glCtx;
-   SWvertex v[4];
-   s3v_translate_vertex( ctx, v0, &v[0] );
-   s3v_translate_vertex( ctx, v1, &v[1] );
-   s3v_translate_vertex( ctx, v2, &v[2] );
-   s3v_translate_vertex( ctx, v3, &v[3] );
-   DEBUG(("s3v_fallback_quad\n"));
-/*   _swrast_Quad( ctx, &v[0], &v[1], &v[2], &v[3] ); */
-}
-
-static void 
-s3v_fallback_tri( s3vContextPtr vmesa, 
-                   const s3vVertex *v0, 
-                   const s3vVertex *v1, 
-                   const s3vVertex *v2 )
-{
-   GLcontext *ctx = vmesa->glCtx;
-   SWvertex v[3];
-   s3v_translate_vertex( ctx, v0, &v[0] );
-   s3v_translate_vertex( ctx, v1, &v[1] );
-   s3v_translate_vertex( ctx, v2, &v[2] );
-   DEBUG(("s3v_fallback_tri\n"));
-/*   _swrast_Triangle( ctx, &v[0], &v[1], &v[2] ); */
-}
-
-static void
-s3v_fallback_line( s3vContextPtr vmesa,
-                    const s3vVertex *v0,
-                    const s3vVertex *v1 )
-{
-   GLcontext *ctx = vmesa->glCtx;
-   SWvertex v[2];
-   s3v_translate_vertex( ctx, v0, &v[0] );
-   s3v_translate_vertex( ctx, v1, &v[1] );
-   DEBUG(("s3v_fallback_line\n"));
-   _swrast_Line( ctx, &v[0], &v[1] );
-}
-
-/*
-static void 
-s3v_fallback_point( s3vContextPtr vmesa, 
-                     const s3vVertex *v0 )
-{
-   GLcontext *ctx = vmesa->glCtx;
-   SWvertex v[1];
-   s3v_translate_vertex( ctx, v0, &v[0] );
-   _swrast_Point( ctx, &v[0] );
-}
-*/
-#endif
-
-/***********************************************************************
- *                    Choose rasterization functions                   *
- ***********************************************************************/
-
-#define _S3V_NEW_RASTER_STATE  (_NEW_FOG | \
-                                _NEW_TEXTURE | \
-                                _DD_NEW_TRI_SMOOTH | \
-                                _DD_NEW_LINE_SMOOTH | \
-                                _DD_NEW_POINT_SMOOTH | \
-                                _DD_NEW_TRI_STIPPLE | \
-                                _DD_NEW_LINE_STIPPLE)
-
-#define LINE_FALLBACK (0)
-#define TRI_FALLBACK (0)
-
-static void s3v_nodraw_triangle(GLcontext *ctx, s3vVertex *v0,
-                                s3vVertex *v1, s3vVertex *v2)
-{
-       (void) (ctx && v0 && v1 && v2);
-}
-
-static void s3v_nodraw_quad(GLcontext *ctx,
-                            s3vVertex *v0, s3vVertex *v1,
-                            s3vVertex *v2, s3vVertex *v3)
-{
-       (void) (ctx && v0 && v1 && v2 && v3);
-}
-
-void s3vChooseRasterState(GLcontext *ctx);
-
-void s3vChooseRasterState(GLcontext *ctx)
-{
-       s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-       GLuint flags = ctx->_TriangleCaps;
-       GLuint ind = 0;
-
-       DEBUG(("*** s3vChooseRasterState ***\n"));
-
-       if (ctx->Polygon.CullFlag) {
-               if (ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) {
-                       vmesa->draw_tri = (s3v_tri_func)s3v_nodraw_triangle;
-                       vmesa->draw_quad = (s3v_quad_func)s3v_nodraw_quad;
-                       return;
-               }
-               ind |= S3V_RAST_CULL_BIT;
-               /* s3v_update_cullsign(ctx); */
-       } /* else vmesa->backface_sign = 0; */
-
-       if ( flags & DD_FLATSHADE )
-               ind |= S3V_RAST_FLAT_BIT;
-
-       if ( ctx->Texture.Unit[0]._ReallyEnabled ) {
-               ind |= S3V_RAST_TEX_BIT;
-       }
-
-       DEBUG(("ind = %i\n", ind));
-
-       vmesa->draw_line = s3v_line_tab[ind];
-       vmesa->draw_tri = s3v_tri_tab[ind];
-       vmesa->draw_quad = s3v_quad_tab[ind];
-       vmesa->draw_point = s3v_point_tab[ind];
-
-#if 0
-       /* Hook in fallbacks for specific primitives.  CURRENTLY DISABLED
-        */
-       
-       if (flags & LINE_FALLBACK) 
-               vmesa->draw_line = s3v_fallback_line;
-        
-       if (flags & TRI_FALLBACK) {
-               DEBUG(("TRI_FALLBACK\n"));
-               vmesa->draw_tri = s3v_fallback_tri;
-               vmesa->draw_quad = s3v_fallback_quad;
-       }
-#endif
-}
-
-
-
-
-/***********************************************************************
- *          Macros for t_dd_tritmp.h to draw basic primitives          *
- ***********************************************************************/
-
-#define TRI( v0, v1, v2 ) \
-do { \
-       /*
-       if (DO_FALLBACK) \
-               vmesa->draw_tri( vmesa, v0, v1, v2 ); \
-       else */ \
-       DEBUG(("TRI: max was here\n")); /* \
-       s3v_draw_tex_triangle( vmesa, v0, v1, v2 ); */ \
-       vmesa->draw_tri( vmesa, v0, v1, v2 ); \
-} while (0)
-
-#define QUAD( v0, v1, v2, v3 ) \
-do { \
-       DEBUG(("QUAD: max was here\n")); \
-       vmesa->draw_quad( vmesa, v0, v1, v2, v3 ); \
-} while (0)
-
-#define LINE( v0, v1 ) \
-do { \
-       DEBUG(("LINE: max was here\n")); \
-       vmesa->draw_line( vmesa, v0, v1 ); \
-} while (0)
-
-#define POINT( v0 ) \
-do { \
-       vmesa->draw_point( vmesa, v0 ); \
-} while (0)
-
-
-/***********************************************************************
- *              Build render functions from dd templates               *
- ***********************************************************************/
-
-/*
-#define S3V_OFFSET_BIT         0x01
-#define S3V_TWOSIDE_BIT        0x02
-#define S3V_UNFILLED_BIT       0x04
-#define S3V_FALLBACK_BIT       0x08
-#define S3V_MAX_TRIFUNC        0x10
-
-
-static struct {
-   points_func         points;
-   line_func           line;
-   triangle_func       triangle;
-   quad_func           quad;
-} rast_tab[S3V_MAX_TRIFUNC];
-*/
-
-#define DO_FALLBACK  (IND & S3V_FALLBACK_BIT)
-#define DO_OFFSET    (IND & S3V_OFFSET_BIT)
-#define DO_UNFILLED  (IND & S3V_UNFILLED_BIT)
-#define DO_TWOSIDE   (IND & S3V_TWOSIDE_BIT)
-#define DO_FLAT      0
-#define DO_TRI       1
-#define DO_QUAD      1
-#define DO_LINE      1
-#define DO_POINTS    1
-#define DO_FULL_QUAD 1
-
-#define HAVE_RGBA         1
-#define HAVE_SPEC         0
-#define HAVE_BACK_COLORS  0
-#define HAVE_HW_FLATSHADE 1
-#define VERTEX            s3vVertex
-#define TAB               rast_tab
-
-#define DEPTH_SCALE 1.0
-#define UNFILLED_TRI unfilled_tri
-#define UNFILLED_QUAD unfilled_quad
-#define VERT_X(_v) _v->v.x
-#define VERT_Y(_v) _v->v.y
-#define VERT_Z(_v) _v->v.z
-#define AREA_IS_CCW( a ) (a > 0)
-#define GET_VERTEX(e) (vmesa->verts + (e<<vmesa->vertex_stride_shift))
-
-#if 0
-#define VERT_SET_RGBA( v, c ) \
-do { \
-/*    UNCLAMPED_FLOAT_TO_RGBA_CHAN( v->ub4[4], c) */ \
-} while (0)
-
-#define VERT_COPY_RGBA( v0, v1 ) v0->ui[4] = v1->ui[4]
-/*
-#define VERT_COPY_RGBA1( v0, v1 ) v0->ui[4] = v1->ui[4]
-*/
-#define VERT_SAVE_RGBA( idx )    color[idx] = v[idx]->ui[4]
-#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[4] = color[idx]   
-#endif
-
-#define LOCAL_VARS(n) \
-       s3vContextPtr vmesa = S3V_CONTEXT(ctx); \
-       GLuint color[n]; \
-       (void) color;
-
-
-/***********************************************************************
- *                Helpers for rendering unfilled primitives            *
- ***********************************************************************/
-
-static const GLuint hw_prim[GL_POLYGON+1] = {
-       PrimType_Points,
-       PrimType_Lines,
-       PrimType_Lines,
-       PrimType_Lines,
-       PrimType_Triangles,
-       PrimType_Triangles,
-       PrimType_Triangles,
-       PrimType_Triangles,
-       PrimType_Triangles,
-       PrimType_Triangles
-};
-
-static void s3vResetLineStipple( GLcontext *ctx );
-static void s3vRasterPrimitive( GLcontext *ctx, GLuint hwprim );
-static void s3vRenderPrimitive( GLcontext *ctx, GLenum prim );
-/*
-extern static void s3v_lines_emit(GLcontext *ctx, GLuint start, GLuint end);
-extern static void s3v_tris_emit(GLcontext *ctx, GLuint start, GLuint end);
-*/
-#define RASTERIZE(x) if (vmesa->hw_primitive != hw_prim[x]) \
-                        s3vRasterPrimitive( ctx, hw_prim[x] )
-#define RENDER_PRIMITIVE vmesa->render_primitive
-#define TAG(x) x
-#define IND S3V_FALLBACK_BIT
-#include "tnl_dd/t_dd_unfilled.h"
-#undef IND
-
-/***********************************************************************
- *                      Generate GL render functions                   *
- ***********************************************************************/
-
-#define IND (0)
-#define TAG(x) x
-#include "tnl_dd/t_dd_tritmp.h"
-
-#define IND (S3V_OFFSET_BIT)
-#define TAG(x) x##_offset
-#include "tnl_dd/t_dd_tritmp.h"
-
-#define IND (S3V_TWOSIDE_BIT)
-#define TAG(x) x##_twoside
-#include "tnl_dd/t_dd_tritmp.h"
-
-#define IND (S3V_TWOSIDE_BIT|S3V_OFFSET_BIT)
-#define TAG(x) x##_twoside_offset
-#include "tnl_dd/t_dd_tritmp.h"
-
-#define IND (S3V_UNFILLED_BIT)
-#define TAG(x) x##_unfilled
-#include "tnl_dd/t_dd_tritmp.h"
-
-#define IND (S3V_OFFSET_BIT|S3V_UNFILLED_BIT)
-#define TAG(x) x##_offset_unfilled
-#include "tnl_dd/t_dd_tritmp.h"
-
-#define IND (S3V_TWOSIDE_BIT|S3V_UNFILLED_BIT)
-#define TAG(x) x##_twoside_unfilled
-#include "tnl_dd/t_dd_tritmp.h"
-
-#define IND (S3V_TWOSIDE_BIT|S3V_OFFSET_BIT|S3V_UNFILLED_BIT)
-#define TAG(x) x##_twoside_offset_unfilled
-#include "tnl_dd/t_dd_tritmp.h"
-
-
-static void init_render_tab( void )
-{
-       DEBUG(("*** init_render_tab ***\n"));
-
-       init();
-       init_offset();
-       init_twoside();
-       init_twoside_offset();
-       init_unfilled();
-       init_offset_unfilled();
-       init_twoside_unfilled();
-       init_twoside_offset_unfilled();
-}
-
-
-/**********************************************************************/
-/*               Render unclipped begin/end objects                   */
-/**********************************************************************/
-
-#define VERT(x) (s3vVertex *)(s3vverts + (x << shift))
-
-#define RENDER_POINTS( start, count ) \
-       DEBUG(("RENDER_POINTS...(ok)\n")); \
-       for ( ; start < count ; start++) \
-               vmesa->draw_line( vmesa, VERT(start), VERT(start) )
-       /*      vmesa->draw_point( vmesa, VERT(start) ) */
-
-#define RENDER_LINE( v0, v1 ) \
-       /* DEBUG(("RENDER_LINE...(ok)\n")); \ */ \
-       vmesa->draw_line( vmesa, VERT(v0), VERT(v1) ); \
-       DEBUG(("RENDER_LINE...(ok)\n"))
-
-#define RENDER_TRI( v0, v1, v2 )  \
-       DEBUG(("RENDER_TRI...(ok)\n")); \
-       vmesa->draw_tri( vmesa, VERT(v0), VERT(v1), VERT(v2) )
-
-#define RENDER_QUAD( v0, v1, v2, v3 ) \
-       DEBUG(("RENDER_QUAD...(ok)\n")); \
-       /* s3v_draw_quad( vmesa, VERT(v0), VERT(v1), VERT(v2),VERT(v3) ) */\
-       /* s3v_draw_triangle( vmesa, VERT(v0), VERT(v1), VERT(v2) ); \
-       s3v_draw_triangle( vmesa, VERT(v0), VERT(v2), VERT(v3) ) */ \
-       vmesa->draw_quad( vmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) ) 
-       
-#define INIT(x) s3vRenderPrimitive( ctx, x );
-#undef LOCAL_VARS
-#define LOCAL_VARS                                             \
-   s3vContextPtr vmesa = S3V_CONTEXT(ctx);             \
-   const GLuint shift = vmesa->vertex_stride_shift;            \
-   const char *s3vverts = (char *)vmesa->verts;                \
-   const GLboolean stipple = ctx->Line.StippleFlag;            \
-   (void) stipple;
-#define RESET_STIPPLE  if ( stipple ) s3vResetLineStipple( ctx );
-#define RESET_OCCLUSION
-#define PRESERVE_VB_DEFS
-#define ELT(x) (x)
-#define TAG(x) s3v_##x##_verts
-#include "tnl_dd/t_dd_rendertmp.h"
-
-
-/**********************************************************************/
-/*                   Render clipped primitives                        */
-/**********************************************************************/
-
-static void s3vRenderClippedPoly( GLcontext *ctx, const GLuint *elts, 
-                                  GLuint n )
-{
-       s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-       struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
-       TNLcontext *tnl = TNL_CONTEXT(ctx);
-       GLuint prim = vmesa->render_primitive;
-
-       DEBUG(("I AM in: s3vRenderClippedPoly\n"));
-
-       /* Render the new vertices as an unclipped polygon. 
-        */
-       if (1)
-       {
-       GLuint *tmp = VB->Elts;
-       VB->Elts = (GLuint *)elts;
-       tnl->Driver.Render.PrimTabElts[GL_POLYGON]
-               ( ctx, 0, n, PRIM_BEGIN|PRIM_END );
-
-       VB->Elts = tmp;
-       }
-
-       /* Restore the render primitive
-        */
-#if 1
-       if (prim != GL_POLYGON) {
-               DEBUG(("and prim != GL_POLYGON\n"));
-               tnl->Driver.Render.PrimitiveNotify( ctx, prim );
-       }
-       
-#endif
-}
-
-static void s3vRenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj )
-{
-   TNLcontext *tnl = TNL_CONTEXT(ctx);
-   /*tnl->Driver.LineFunc = s3v_line_tab[2];*/ /* _swsetup_Line; */
-
-   DEBUG(("I AM in: s3vRenderClippedLine\n"));
-   tnl->Driver.Render.Line( ctx, ii, jj );
-}
-
-
-/**********************************************************************/
-/*                    Choose render functions                         */
-/**********************************************************************/
-
-
-
-#define _S3V_NEW_RENDERSTATE (_DD_NEW_TRI_UNFILLED |           \
-                              _DD_NEW_TRI_LIGHT_TWOSIDE |      \
-                              _DD_NEW_TRI_OFFSET)
-
-#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED)
-
-static void s3vChooseRenderState(GLcontext *ctx)
-{
-   s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-   TNLcontext *tnl = TNL_CONTEXT(ctx);
-   GLuint flags = ctx->_TriangleCaps;
-   GLuint index = 0;
-
-   DEBUG(("s3vChooseRenderState\n"));
-
-   if (flags & ANY_RASTER_FLAGS) {
-      if (flags & DD_TRI_LIGHT_TWOSIDE)       index |= S3V_TWOSIDE_BIT;
-      if (flags & DD_TRI_OFFSET)             index |= S3V_OFFSET_BIT;
-      if (flags & DD_TRI_UNFILLED)           index |= S3V_UNFILLED_BIT;
-   }
-
-   DEBUG(("vmesa->RenderIndex = %i\n", vmesa->RenderIndex));
-   DEBUG(("index = %i\n", index));
-
-   if (vmesa->RenderIndex != index) {
-      vmesa->RenderIndex = index;
-
-      tnl->Driver.Render.Points = rast_tab[index].points;
-      tnl->Driver.Render.Line = rast_tab[index].line;
-      tnl->Driver.Render.Triangle = rast_tab[index].triangle;
-      tnl->Driver.Render.Quad = rast_tab[index].quad;
-
-      if (vmesa->RenderIndex == 0)
-         tnl->Driver.Render.PrimTabVerts = s3v_render_tab_verts;
-      else
-         tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
-      tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
-      tnl->Driver.Render.ClippedLine = s3vRenderClippedLine;
-      tnl->Driver.Render.ClippedPolygon = s3vRenderClippedPoly;
-   }
-}
-
-
-/**********************************************************************/
-/*                 High level hooks for t_vb_render.c                 */
-/**********************************************************************/
-
-
-
-/* Determine the rasterized primitive when not drawing unfilled 
- * polygons.
- *
- * Used only for the default render stage which always decomposes
- * primitives to trianges/lines/points.  For the accelerated stage,
- * which renders strips as strips, the equivalent calculations are
- * performed in s3v_render.c.
- */
-
-static void s3vRasterPrimitive( GLcontext *ctx, GLuint hwprim )
-{
-       s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-/*     __DRIdrawablePrivate *dPriv = vmesa->driDrawable; */
-       GLuint cmd = vmesa->CMD;
-       
-       unsigned int _hw_prim = hwprim;
-
-       DEBUG(("s3vRasterPrimitive: hwprim = 0x%x ", _hw_prim));
-
-/*     printf("* vmesa->CMD = 0x%x\n", vmesa->CMD); */
-
-       if (vmesa->hw_primitive != _hw_prim)
-       {
-               DEBUG(("(new one) ***\n"));
-               cmd &= ~DO_MASK;
-               cmd &= ~ALPHA_BLEND_MASK;
-               vmesa->hw_primitive = _hw_prim;
-
-               if (_hw_prim == PrimType_Triangles) {
-               /* TRI */
-                       DEBUG(("->switching to tri\n"));
-                       cmd |= (vmesa->_tri[vmesa->_3d_mode] | vmesa->_alpha[vmesa->_3d_mode]);
-               } else if (_hw_prim == PrimType_Lines
-                       || _hw_prim == PrimType_Points) {
-               /* LINE */
-                       DEBUG(("->switching to line\n"));
-                       cmd |= (DO_3D_LINE | vmesa->_alpha[0]);
-               } else  {
-               /* ugh? */
-                       DEBUG(("->switching to your sis'ass\n"));
-               }
-        
-               DEBUG(("\n"));
-
-               vmesa->restore_primitive = _hw_prim;
-               /* 0xacc16827: good value -> lightened newave!!! */
-               vmesa->CMD = cmd;
-               CMDCHANGE();
-       }
-}
-
-static void s3vRenderPrimitive( GLcontext *ctx, GLenum prim )
-{
-       s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-       __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
-       GLuint cmd = vmesa->CMD;
-
-       unsigned int _hw_prim = hw_prim[prim];
-
-       vmesa->render_primitive = prim;
-       vmesa->hw_primitive = _hw_prim;
-   
-       DEBUG(("s3vRenderPrimitive #%i ", prim));
-       DEBUG(("_hw_prim = 0x%x\n", _hw_prim));
-
-/*     printf(" vmesa->CMD = 0x%x\n", vmesa->CMD); */
-
-       if (_hw_prim != vmesa->restore_primitive) {
-               DEBUG(("_hw_prim != vmesa->restore_primitive (was 0x%x)\n",
-                       vmesa->restore_primitive));
-#if 1
-               cmd &= ~DO_MASK;
-               cmd &= ~ALPHA_BLEND_MASK;
-/*             
-               printf(" cmd = 0x%x\n", cmd);
-               printf(" vmesa->_3d_mode=%i; vmesa->_tri[vmesa->_3d_mode]=0x%x\n",
-                       vmesa->_3d_mode, vmesa->_tri[vmesa->_3d_mode]);
-               printf("vmesa->alpha[0] = 0x%x; vmesa->alpha[1] = 0x%x\n",
-                       vmesa->_alpha[0], vmesa->_alpha[1]);
-*/             
-               if (_hw_prim == PrimType_Triangles) { /* TRI */
-                       DEBUG(("->switching to tri\n"));
-                       cmd |= (vmesa->_tri[vmesa->_3d_mode] | vmesa->_alpha[vmesa->_3d_mode]);
-                       DEBUG(("vmesa->TexStride = %i\n", vmesa->TexStride));
-                       DEBUG(("vmesa->TexOffset = %i\n", vmesa->TexOffset));
-                       DMAOUT_CHECK(3DTRI_Z_BASE, 12);
-               } else { /* LINE */
-                       DEBUG(("->switching to line\n"));
-                       cmd |= (DO_3D_LINE | vmesa->_alpha[0]);
-                       DMAOUT_CHECK(3DLINE_Z_BASE, 12);
-               }
-
-               DMAOUT(vmesa->s3vScreen->depthOffset & 0x003FFFF8);
-               DMAOUT(vmesa->DestBase);
-               /* DMAOUT(vmesa->ScissorLR); */
-               /* DMAOUT(vmesa->ScissorTB); */
-
-               /* NOTE: we need to restore all these values since we
-                * are coming back from a vmesa->restore_primitive */
-               DMAOUT( (0 << 16) | (dPriv->w-1) );
-               DMAOUT( (0 << 16) | (dPriv->h-1) );
-               DMAOUT( (vmesa->SrcStride << 16) | vmesa->TexStride );
-               DMAOUT(vmesa->SrcStride);
-               DMAOUT(vmesa->TexOffset);
-               DMAOUT(vmesa->TextureBorderColor);
-               DMAOUT(0); /* FOG */
-               DMAOUT(0);
-               DMAOUT(0);
-               DMAOUT(cmd);
-               /* 0xacc16827: good value -> lightened newave!!! */
-        DMAFINISH();
-
-       vmesa->CMD = cmd;
-#endif
-       }
-
-       DEBUG(("\n"));
-
-       vmesa->restore_primitive = _hw_prim;
-}
-
-static void s3vRunPipeline( GLcontext *ctx )
-{
-       s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-
-       DEBUG(("*** s3vRunPipeline ***\n"));
-
-       if ( vmesa->new_state )
-               s3vDDUpdateHWState( ctx );
-
-       if (vmesa->new_gl_state) {
-
-               if (vmesa->new_gl_state & _NEW_TEXTURE) {
-                       s3vUpdateTextureState( ctx );
-               }
-
-               if (!vmesa->Fallback) {
-                       if (vmesa->new_gl_state & _S3V_NEW_VERTEX)
-                               s3vChooseVertexState( ctx );
-      
-                       if (vmesa->new_gl_state & _S3V_NEW_RASTER_STATE)
-                               s3vChooseRasterState( ctx );
-      
-                       if (vmesa->new_gl_state & _S3V_NEW_RENDERSTATE)
-                               s3vChooseRenderState( ctx );
-               }
-
-       vmesa->new_gl_state = 0;
-       
-       }
-
-       _tnl_run_pipeline( ctx );
-}
-
-static void s3vRenderStart( GLcontext *ctx )
-{
-       /* Check for projective texturing.  Make sure all texcoord
-        * pointers point to something.  (fix in mesa?)  
-        */
-
-       DEBUG(("s3vRenderStart\n"));
-       /* s3vCheckTexSizes( ctx ); */
-}
-
-static void s3vRenderFinish( GLcontext *ctx )
-{
-   if (0)
-      _swrast_flush( ctx );    /* never needed */
-}
-
-static void s3vResetLineStipple( GLcontext *ctx )
-{
-/*   s3vContextPtr vmesa = S3V_CONTEXT(ctx); */
-
-   /* Reset the hardware stipple counter.
-    */
-/*
-   CHECK_DMA_BUFFER(vmesa, 1);
-   WRITE(vmesa->buf, UpdateLineStippleCounters, 0);
-*/
-}
-
-
-/**********************************************************************/
-/*           Transition to/from hardware rasterization.               */
-/**********************************************************************/
-
-
-void s3vFallback( s3vContextPtr vmesa, GLuint bit, GLboolean mode )
-{
-   GLcontext *ctx = vmesa->glCtx;
-   TNLcontext *tnl = TNL_CONTEXT(ctx);
-   GLuint oldfallback = vmesa->Fallback;
-
-   DEBUG(("*** s3vFallback: "));
-
-   if (mode) {
-      vmesa->Fallback |= bit;
-      if (oldfallback == 0) {
-                DEBUG(("oldfallback == 0 ***\n"));
-                _swsetup_Wakeup( ctx );
-                _tnl_need_projected_coords( ctx, GL_TRUE );
-                vmesa->RenderIndex = ~0;
-      }
-   }
-   else {
-      DEBUG(("***\n"));
-      vmesa->Fallback &= ~bit;
-      if (oldfallback == bit) {
-               _swrast_flush( ctx );
-               tnl->Driver.Render.Start = s3vRenderStart;
-               tnl->Driver.Render.PrimitiveNotify = s3vRenderPrimitive;
-               tnl->Driver.Render.Finish = s3vRenderFinish;
-               tnl->Driver.Render.BuildVertices = s3vBuildVertices;
-               tnl->Driver.Render.ResetLineStipple = s3vResetLineStipple;
-               vmesa->new_gl_state |= (_S3V_NEW_RENDERSTATE|
-                                       _S3V_NEW_RASTER_STATE|
-                                       _S3V_NEW_VERTEX);
-      }
-   }
-}
-
-
-/**********************************************************************/
-/*                            Initialization.                         */
-/**********************************************************************/
-
-
-void s3vInitTriFuncs( GLcontext *ctx )
-{
-   s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-   TNLcontext *tnl = TNL_CONTEXT(ctx);
-   static int firsttime = 1;
-
-   if (firsttime) {
-      init_rast_tab();
-      init_render_tab();
-      firsttime = 0;
-   }
-   
-   vmesa->RenderIndex = ~0;
-
-   tnl->Driver.RunPipeline = s3vRunPipeline;
-   tnl->Driver.Render.Start = s3vRenderStart;
-   tnl->Driver.Render.Finish = s3vRenderFinish; 
-   tnl->Driver.Render.PrimitiveNotify = s3vRenderPrimitive;
-   tnl->Driver.Render.ResetLineStipple = s3vResetLineStipple;
-/*
-   tnl->Driver.RenderInterp = _swsetup_RenderInterp;
-   tnl->Driver.RenderCopyPV = _swsetup_RenderCopyPV;
-*/
-   tnl->Driver.Render.BuildVertices = s3vBuildVertices;
-}
diff --git a/src/mesa/drivers/dri/s3v/s3v_tris.h b/src/mesa/drivers/dri/s3v/s3v_tris.h
deleted file mode 100644 (file)
index 0010a7f..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#ifndef _S3V_TRIS_H
-#define _S3V_TRIS_H
-
-extern void s3vDDTrifuncInit(void);
-extern void s3vDDChooseTriRenderState(GLcontext *);
-
-#endif /* !(_S3V_TRIS_H) */
diff --git a/src/mesa/drivers/dri/s3v/s3v_tritmp.h b/src/mesa/drivers/dri/s3v/s3v_tritmp.h
deleted file mode 100644 (file)
index 2321bd4..0000000
+++ /dev/null
@@ -1,958 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-/**** MACROS start ****/
-
-/* point/line macros */
-
-#define LINE_VERT_VARS \
-        SWvertex v[3]; \
-       s3vVertex* vvv[2]; \
-        int x[3], y[3], z[3]; \
-        int idx[3]; \
-        int dx01, dy01; \
-        int delt02; \
-        int deltzy, zstart; \
-        int start02, end01; \
-        int ystart, y01y12; \
-        int i, tmp, tmp2, tmp3; \
-        GLfloat ydiff, fy[3]
-#define LINE_VERT_VARS_VOIDS \
-        (void) v; (void) vvv; (void) x; (void) y; (void) z; (void) idx; \
-        (void) dx01; (void) dy01; (void) delt02; (void) deltzy; \
-        (void) zstart; (void) start02; (void) ystart; (void) y01y12; \
-        (void) i; (void) tmp; (void) tmp2; (void) tmp3; (void) ydiff; (void) fy
-
-#define LINE_FLAT_VARS \
-        int arstart, gbstart; \
-        int deltarx, deltgbx, deltary, deltgby; \
-        GLubyte *(col)[3]
-#define LINE_FLAT_VARS_VOIDS \
-        (void) arstart; (void) gbstart; (void) deltarx; (void) deltgbx; \
-        (void) deltary; (void) deltgby; (void) col
-
-#define LINE_GOURAUD_VARS \
-        int arstart, gbstart; \
-        int deltary, deltgby; \
-        int ctmp, ctmp2, ctmp3, ctmp4; \
-        GLubyte *(col)[3]
-#define LINE_GOURAUD_VARS_VOIDS \
-        (void) arstart; (void) gbstart; (void) deltary; (void) deltgby; \
-        (void) ctmp; (void) ctmp2; (void) ctmp3; (void) ctmp4; (void) col
-
-#define SORT_LINE_VERT() \
-do { \
-       if(v[0].attrib[FRAG_ATTRIB_WPOS][1] <= v[1].attrib[FRAG_ATTRIB_WPOS][1]) { \
-\
-                idx[0] = 0; \
-                idx[1] = 1; \
-\
-        } else if (v[0].attrib[FRAG_ATTRIB_WPOS][1] > v[1].attrib[FRAG_ATTRIB_WPOS][1]) { \
-\
-                idx[0] = 1; \
-                idx[1] = 0; \
-\
-        } \
-} while(0)
-
-#define SET_LINE_VERT() \
-do { \
-        x[0] = (v[idx[0]].attrib[FRAG_ATTRIB_WPOS][0] * 1024.0f * 1024.0f); /* 0x100000 */ \
-        y[0] = fy[0] = dPriv->h - v[idx[0]].attrib[FRAG_ATTRIB_WPOS][1]; \
-        z[0] = (v[idx[0]].attrib[FRAG_ATTRIB_WPOS][2]) * 1024.0f * 32.0f; /* 0x8000; */ \
-\
-        x[1] = (v[idx[1]].attrib[FRAG_ATTRIB_WPOS][0] * 1024.0f * 1024.0f); /* 0x100000 */ \
-        y[1] = dPriv->h - v[idx[1]].attrib[FRAG_ATTRIB_WPOS][1]; \
-        z[1] = (v[idx[1]].attrib[FRAG_ATTRIB_WPOS][2]) * 1024.0f * 32.0f; /* 0x8000 */ \
-} while(0)
-
-#define SET_LINE_XY() \
-do { \
-       tmp = v[idx[0]].attrib[FRAG_ATTRIB_WPOS][0]; \
-        tmp2 = v[idx[1]].attrib[FRAG_ATTRIB_WPOS][0]; \
-\
-       dx01 = x[0] - x[1]; \
-        dy01 = y[0] - y[1]; \
-\
-        ydiff = fy[0] - (float)y[0]; \
-        ystart = y[0]; \
-        y01y12 = dy01 + 1; \
-} while (0)
-
-#define SET_LINE_DIR() \
-do { \
-        if (tmp2 > tmp) { \
-                y01y12 |= 0x80000000; \
-                tmp3 = tmp2-tmp; \
-        } else { \
-                tmp3 = tmp-tmp2; \
-        } \
-\
-        end01 = ((tmp << 16) | tmp2); \
-\
-       if (dy01) \
-                delt02 = -(dx01/dy01); \
-        else \
-               delt02 = 0; \
-\
-        if (dy01 > tmp3) { /* Y MAJ */ \
-       /* NOTE: tmp3 always >=0 */ \
-                start02 = x[0]; \
-        } else if (delt02 >= 0){ /* X MAJ - positive delta */ \
-                start02 = x[0] + delt02/2; \
-                dy01 = tmp3; /* could be 0 */ \
-        } else { /* X MAJ - negative delta */ \
-                start02 = x[0] + delt02/2 + ((1 << 20) - 1); \
-                dy01 = tmp3; /* could be 0 */ \
-        } \
-} while(0)
-
-#define SET_LINE_Z() \
-do { \
-       zstart = z[0]; \
-\
-       if (dy01) { \
-                deltzy = (z[1] - z[0])/dy01; \
-        } else { \
-                deltzy = 0; /* dy01 = tmp3 = 0 (it's a point)*/ \
-        } \
-} while (0)
-
-#define SET_LINE_FLAT_COL() \
-do { \
-        col[0] = &(v[idx[0]].color[0]); \
-        deltarx = deltary = deltgbx = deltgby = 0; \
-        gbstart = (((col[0][1]) << 23) | ((col[0][2]) << 7)); \
-        arstart = (((col[0][3]) << 23) | ((col[0][0]) << 7)); \
-} while(0)
-
-#define SET_LINE_GOURAUD_COL() \
-do { \
-        col[0] = &(v[idx[0]].color[0]); \
-        col[1] = &(v[idx[1]].color[0]); \
-\
-        vvv[0] = _v0; \
-        vvv[1] = _v1; \
-\
-        for (i=0; i<2; i++) { \
-       /* FIXME: swapped ! */ \
-                col[i][0] = vvv[!idx[i]]->v.color.red; \
-                col[i][1] = vvv[!idx[i]]->v.color.green; \
-                col[i][2] = vvv[!idx[i]]->v.color.blue; \
-                col[i][3] = vvv[!idx[i]]->v.color.alpha; \
-        } \
-\
-       if (dy01) { \
-\
-        ctmp = ((col[0][1] - col[1][1]) << 7) / dy01; \
-        ctmp2 = ((col[0][2] - col[1][2]) << 7) / dy01; \
-        deltgby = ((ctmp << 16) & 0xFFFF0000) | (ctmp2 & 0xFFFF); \
-\
-        ctmp3 = ((col[0][3] - col[1][3]) << 7) / dy01; \
-        ctmp4 = ((col[0][0] - col[1][0]) << 7) / dy01; \
-        deltary = ((ctmp3 << 16) & 0xFFFF0000) | (ctmp4 & 0xFFFF); \
-        } else { \
-        ctmp = ((col[1][1] - col[0][1]) << 7); \
-        ctmp2 = ((col[1][2] - col[0][2]) << 7); \
-        deltgby = ((ctmp << 16) & 0xFFFF0000) | (ctmp2 & 0xFFFF); \
-\
-        ctmp3 = ((col[1][3] - col[0][3]) << 7); \
-        ctmp4 = ((col[1][0] - col[0][0]) << 7); \
-        deltary = ((ctmp3 << 16) & 0xFFFF0000) | (ctmp4 & 0xFFFF); \
-        deltgby = deltary = 0; \
-        } \
-\
-       idx[0] = 1; /* FIXME: swapped */ \
-\
-        gbstart = \
-       (((int)((ydiff * ctmp) + (col[idx[0]][1] << 7)) << 16) & 0x7FFF0000) \
-       | ((int)((ydiff * ctmp2) + (col[idx[0]][2] << 7)) & 0x7FFF); \
-        arstart = \
-       (((int)((ydiff * ctmp3) + (col[idx[0]][3] << 7)) << 16) & 0x7FFF0000) \
-       | ((int)((ydiff * ctmp4) + (col[idx[0]][0] << 7)) & 0x7FFF); \
-} while(0)
-
-#define SEND_LINE_COL() \
-do { \
-       DMAOUT(deltgby); \
-       DMAOUT(deltary); \
-       DMAOUT(gbstart); \
-       DMAOUT(arstart); \
-} while (0)
-
-#define SEND_LINE_VERT() \
-do { \
-       DMAOUT(deltzy); \
-       DMAOUT(zstart); \
-       DMAOUT(0); \
-       DMAOUT(0); \
-       DMAOUT(0); \
-       DMAOUT(end01); \
-       DMAOUT(delt02); \
-       DMAOUT(start02); \
-       DMAOUT(ystart); \
-       DMAOUT(y01y12); \
-} while (0)
-
-
-/* tri macros (mostly stolen from utah-glx...) */
-
-#define VERT_VARS \
-        SWvertex v[3]; \
-        int x[3], y[3], z[3]; \
-        int idx[3]; \
-        int dx01, dy01; \
-        int dx02, dy02; \
-        int dx12, dy12; \
-        int delt01, delt02, delt12; \
-        int deltzx, deltzy, zstart; \
-        int start02, end01, end12; \
-        int ystart, y01y12; \
-        int i, tmp, lr; \
-        GLfloat ydiff, fy[3]
-#define VERT_VARS_VOIDS \
-        (void) v; (void) x; (void) y; (void) z; (void) idx; (void) dx01; \
-        (void) dy01; (void) dx02; (void) dy02; (void) dx12; (void) dy12; \
-        (void) delt01; (void) delt02; (void) delt12; (void) deltzx; \
-        (void) deltzy; (void) zstart; (void) start02; (void) end01; \
-        (void) end12; (void) ystart; (void) y01y12; (void) i; (void) tmp; \
-        (void) lr; (void) ydiff; (void) fy
-
-#define GOURAUD_VARS \
-        int arstart, gbstart; \
-        int deltarx, deltgbx, deltary, deltgby; \
-        int ctmp, ctmp2, ctmp3, ctmp4; \
-        GLubyte *(col)[3]
-#define GOURAUD_VARS_VOIDS \
-        (void) arstart; (void) gbstart; (void) deltarx; (void) deltgbx; \
-        (void) deltary; (void) deltgby; (void) ctmp; (void) ctmp2; \
-        (void) ctmp3; (void) ctmp4; (void) col
-
-#define FLAT_VARS \
-        int arstart, gbstart; \
-        int deltarx, deltgbx, deltary, deltgby; \
-        GLubyte *(col)[3]
-#define FLAT_VARS_VOIDS \
-        (void) arstart; (void) gbstart; (void) deltarx; (void) deltgbx; \
-        (void) deltary; (void) deltgby; (void) col
-
-#define TEX_VARS \
-        int u0, u1, u2; \
-        GLfloat ru0, ru1, ru2; \
-        int v0, v1, v2; \
-        GLfloat rv0, rv1, rv2; \
-        GLfloat w0, w1, w2; \
-        GLfloat rw0, rw1, rw2; \
-        int baseu, basev; \
-        int d0, d1, d2; \
-        int deltdx, deltvx, deltux, deltdy, deltvy, deltuy; \
-        int deltwx, deltwy; \
-        int rbaseu, rbasev; \
-        int dstart, ustart, wstart, vstart; \
-        static int stmp = 0; \
-        s3vTextureObjectPtr t
-#define TEX_VARS_VOIDS \
-        (void) u0; (void) u1; (void) u2; (void) ru0; (void) ru1; (void) ru2; \
-        (void) v0; (void) v1; (void) v2; (void) rv0; (void) rv1; (void) rv2; \
-        (void) w0; (void) w1; (void) w2; (void) rw0; (void) rw1; (void) rw2; \
-        (void) baseu; (void) basev; (void) d0; (void) d1; (void) d2; \
-        (void) deltdx; (void) deltvx; (void) deltux; (void) deltdy; \
-        (void) deltuy; (void) deltwx; (void) deltwy; (void) rbaseu; \
-        (void) rbasev; (void) dstart; (void) ustart; (void) wstart; \
-        (void) vstart; (void) stmp; (void) t
-
-#define SORT_VERT() \
-do { \
-       for (i=0; i<3; i++) \
-               fy[i] = v[i].attrib[FRAG_ATTRIB_WPOS][1]; \
-\
-               if (fy[1] > fy[0]) {  /* (fy[1] > fy[0]) */ \
-\
-                       if (fy[2] > fy[0]) { \
-                               idx[0] = 0; \
-                               if (fy[1] > fy[2]) { \
-                                       idx[1] = 2; \
-                                       idx[2] = 1; \
-                               } else { \
-                                       idx[1] = 1; \
-                                       idx[2] = 2; \
-                               } \
-                       } else { \
-                               idx[0] = 2; \
-                               idx[1] = 0; \
-                               idx[2] = 1; \
-                       } \
-               } else { /* (fy[1] < y[0]) */ \
-                       if (fy[2] > fy[0]) { \
-                               idx[0] = 1; \
-                               idx[1] = 0; \
-                               idx[2] = 2; \
-               } else { \
-                       idx[2] = 0; \
-                       if (fy[2] > fy[1]) { \
-                               idx[0] = 1; \
-                               idx[1] = 2; \
-                       } else { \
-                               idx[0] = 2; \
-                               idx[1] = 1; \
-                       } \
-               } \
-       } \
-} while(0)
-
-#define SET_VERT() \
-do { \
-       for (i=0; i<3; i++) \
-       { \
-               x[i] = ((v[idx[i]].attrib[FRAG_ATTRIB_WPOS][0]) * /* 0x100000*/  1024.0 * 1024.0); \
-               y[i] = fy[i] = (dPriv->h - v[idx[i]].attrib[FRAG_ATTRIB_WPOS][1]); \
-               z[i] = ((v[idx[i]].attrib[FRAG_ATTRIB_WPOS][2]) * /* 0x8000 */ 1024.0 * 32.0); \
-       } \
-\
-       ydiff = fy[0] - (float)y[0]; \
-\
-       ystart = y[0]; \
-\
-       dx12 = x[2] - x[1]; \
-       dy12 = y[1] - y[2]; \
-       dx01 = x[1] - x[0]; \
-       dy01 = y[0] - y[1]; \
-       dx02 = x[2] - x[0]; \
-       dy02 = y[0] - y[2]; \
-\
-       delt01 = delt02 = delt12 = 0; \
-} while (0)
-
-
-#define SET_XY() \
-do { \
-       if (dy01) delt01 = dx01 / dy01; \
-       if (dy12) delt12 = dx12 / dy12; \
-       delt02 = dx02 / dy02; \
-\
-       start02 = x[0] + (ydiff * delt02); \
-       end01 = x[0] + (ydiff * delt01); \
-       end12 = x[1] + ((fy[1] - (GLfloat)y[1]) * delt12); \
-} while (0)
-
-#define SET_DIR() \
-do { \
-       tmp = x[1] - (dy01 * delt02 + x[0]); \
-       if (tmp > 0) { \
-               lr = 0x80000000; \
-       } else { \
-               tmp *= -1; \
-               lr = 0; \
-       } \
-       tmp >>= 20; \
-\
-        y01y12 = ((((y[0] - y[1]) & 0x7FF) << 16) \
-                 | ((y[1] - y[2]) & 0x7FF) | lr); \
-} while (0)
-
-#define SET_Z() \
-do { \
-       deltzy = (z[2] - z[0]) / dy02; \
-       if (tmp) { \
-               deltzx = (z[1] - (dy01 * deltzy + z[0])) / tmp; \
-       } else { \
-               deltzx = 0; \
-       } \
-       zstart = (deltzy * ydiff) + z[0]; \
-} while (0)
-
-#define SET_FLAT_COL() \
-do { \
-       col[0] = &(v[0].color[0]); \
-       deltarx = deltary = deltgbx = deltgby = 0; \
-       gbstart = (((col[0][1]) << 23) | ((col[0][2]) << 7)); \
-       arstart = (((col[0][3]) << 23) | ((col[0][0]) << 7)); \
-} while(0)
-
-#define SET_GOURAUD_COL() \
-do { \
-       col[0] = &(v[idx[0]].color[0]); \
-       col[1] = &(v[idx[1]].color[0]); \
-       col[2] = &(v[idx[2]].color[0]); \
-\
-       ctmp = ((col[2][3] - col[0][3]) << 7) / dy02; \
-       ctmp2 = ((col[2][0] - col[0][0]) << 7) / dy02; \
-       deltary = ((ctmp << 16) & 0xFFFF0000) | (ctmp2 & 0xFFFF); \
-       ctmp3 = ((col[2][1] - col[0][1]) << 7) / dy02; \
-       ctmp4 = ((col[2][2] - col[0][2]) << 7) / dy02; \
-       deltgby = ((ctmp3 << 16) & 0xFFFF0000) | (ctmp4 & 0xFFFF); \
-       gbstart = \
-       (((int)((ydiff * ctmp3) + (col[0][1] << 7)) << 16) & 0x7FFF0000) \
-       | ((int)((ydiff * ctmp4) + (col[0][2] << 7)) & 0x7FFF); \
-       arstart = \
-       (((int)((ydiff * ctmp) + (col[0][3] << 7)) << 16) & 0x7FFF0000) \
-       | ((int)((ydiff * ctmp2) + (col[0][0] << 7)) & 0x7FFF); \
-       if (tmp) { \
-       int ax, rx, gx, bx; \
-       ax = ((col[1][3] << 7) - (dy01 * ctmp + (col[0][3] << 7))) / tmp; \
-       rx = ((col[1][0] << 7) - (dy01 * ctmp2 + (col[0][0] << 7))) / tmp; \
-       gx = ((col[1][1] << 7) - (dy01 * ctmp3 + (col[0][1] << 7))) / tmp; \
-       bx = ((col[1][2] << 7) - (dy01 * ctmp4 + (col[0][2] << 7))) / tmp; \
-       deltarx = ((ax << 16) & 0xFFFF0000) | (rx & 0xFFFF); \
-       deltgbx = ((gx << 16) & 0xFFFF0000) | (bx & 0xFFFF); \
-       } else { \
-       deltgbx = deltarx = 0; \
-       } \
-} while (0)
-
-#define SET_TEX_VERT() \
-do { \
-        t = ((s3vTextureObjectPtr) \
-                ctx->Texture.Unit[0]._Current->DriverData); \
-        deltwx = deltwy = wstart = deltdx = deltdy = dstart = 0; \
-\
-        u0 = (v[idx[0]].attrib[FRAG_ATTRIB_TEX0][0] \
-                * (GLfloat)(t->image[0].image->Width) * 256.0); \
-        u1 = (v[idx[1]].attrib[FRAG_ATTRIB_TEX0][0] \
-                * (GLfloat)(t->globj->Image[0][0]->Width) * 256.0); \
-        u2 = (v[idx[2]].attrib[FRAG_ATTRIB_TEX0][0] \
-                * (GLfloat)(t->globj->Image[0][0]->Width) * 256.0); \
-        v0 = (v[idx[0]].attrib[FRAG_ATTRIB_TEX0][1] \
-                * (GLfloat)(t->globj->Image[0][0]->Height) * 256.0); \
-        v1 = (v[idx[1]].attrib[FRAG_ATTRIB_TEX0][1] \
-                * (GLfloat)(t->globj->Image[0][0]->Height) * 256.0); \
-        v2 = (v[idx[2]].attrib[FRAG_ATTRIB_TEX0][1] \
-                * (GLfloat)(t->globj->Image[0][0]->Height) * 256.0); \
-\
-        w0 = (v[idx[0]].attrib[FRAG_ATTRIB_WPOS][3]); \
-        w1 = (v[idx[1]].attrib[FRAG_ATTRIB_WPOS][3]); \
-        w2 = (v[idx[2]].attrib[FRAG_ATTRIB_WPOS][3]); \
-} while (0)
-
-#define SET_BASEUV() \
-do { \
-        if (u0 < u1) { \
-                if (u0 < u2) { \
-                        baseu = u0; \
-                } else { \
-                        baseu = u2; \
-                } \
-        } else { \
-                if (u1 < u2) { \
-                        baseu = u1; \
-                } else { \
-                        baseu = u2; \
-                } \
-        } \
-\
-        if (v0 < v1) { \
-                if (v0 < v2) { \
-                        basev = v0; \
-                } else { \
-                        basev = v2; \
-                } \
-        } else { \
-                if (v1 < v2) { \
-                        basev = v1; \
-                } else { \
-                        basev = v2; \
-                } \
-        } \
-} while (0)
-
-
-#define SET_RW() \
-do { \
-        /* GLfloat minW; \
-\
-        if (w0 < w1) { \
-                if (w0 < w2) { \
-                        minW = w0; \
-                } else { \
-                        minW = w2; \
-                } \
-        } else { \
-                if (w1 < w2) { \
-                        minW = w1; \
-                } else { \
-                        minW = w2; \
-                } \
-        } */ \
-\
-        rw0 = (512.0 * w0); \
-        rw1 = (512.0 * w1); \
-        rw2 = (512.0 * w2); \
-} while (0)
-
-#define SET_D() \
-do { \
-        GLfloat sxy, suv; \
-        int lev; \
-\
-        suv = (v[idx[0]].attrib[FRAG_ATTRIB_TEX0][0] - \
-                v[idx[2]].attrib[FRAG_ATTRIB_TEX0][0]) * \
-                (v[idx[1]].attrib[FRAG_ATTRIB_TEX0][1] - \
-                v[idx[2]].attrib[FRAG_ATTRIB_TEX0][1]) - \
-                (v[idx[1]].attrib[FRAG_ATTRIB_TEX0][0] - \
-                v[idx[2]].attrib[FRAG_ATTRIB_TEX0][0]) * \
-                (v[idx[0]].attrib[FRAG_ATTRIB_TEX0][1] - \
-                v[idx[2]].attrib[FRAG_ATTRIB_TEX0][2]); \
-\
-        sxy = (v[idx[0]].attrib[FRAG_ATTRIB_TEX0][0] - \
-                v[idx[2]].attrib[FRAG_ATTRIB_TEX0][0]) * \
-                (v[idx[1]].attrib[FRAG_ATTRIB_TEX0][1] - \
-                v[idx[2]].attrib[FRAG_ATTRIB_TEX0][1]) - \
-                (v[idx[1]].attrib[FRAG_ATTRIB_TEX0][0] - \
-                v[idx[2]].attrib[FRAG_ATTRIB_TEX0][0]) * \
-                (v[idx[0]].attrib[FRAG_ATTRIB_TEX0][1] - \
-                v[idx[2]].attrib[FRAG_ATTRIB_TEX0][2]); \
-\
-       if (sxy < 0) sxy *= -1.0; \
-       if (suv < 0) suv *= -1.0; \
-\
-       lev = *(int*)&suv - *(int *)&sxy; \
-       if (lev < 0) \
-               lev = 0; \
-       else \
-               lev >>=23; \
-       dstart = (lev << 27); \
-} while (0)
-
-#define SET_UVWD() \
-do { \
-        SET_BASEUV(); \
-        SET_RW(); \
-        SET_D(); \
-        ru0 = (((u0 - baseu) * rw0)); \
-        ru1 = (((u1 - baseu) * rw1)); \
-        ru2 = (((u2 - baseu) * rw2)); \
-        rv0 = (((v0 - basev) * rw0)); \
-        rv1 = (((v1 - basev) * rw1)); \
-        rv2 = (((v2 - basev) * rw2)); \
-\
-        while (baseu < 0) { baseu += (t->globj->Image[0][0]->Width << 8); } \
-        while (basev < 0) { basev += (t->globj->Image[0][0]->Height << 8); } \
-\
-        if (!(baseu & 0xFF)) \
-                { baseu = (baseu >> 8); } \
-        else \
-                { baseu = (baseu >> 8) + 1; } \
-\
-        if ((basev & 0x80) || !(basev & 0xFF)) \
-                { basev = (basev >> 8); } \
-        else \
-                { basev = (basev >> 8) - 1; } \
-\
-        rbaseu = (baseu) << (16 - t->globj->Image[0][0]->WidthLog2); \
-        rbasev = (basev) << (16 - t->globj->Image[0][0]->WidthLog2); \
-        deltuy = (((ru2 - ru0) / dy02)); \
-        deltvy = (((rv2 - rv0) / dy02)); \
-        rw0 *= (1024.0 * 512.0); \
-        rw1 *= (1024.0 * 512.0); \
-        rw2 *= (1024.0 * 512.0); \
-        deltwy = ((rw2 - rw0) / dy02); \
-        if (tmp) { \
-                deltux = ((ru1 - (dy01 * deltuy + ru0)) / tmp); \
-                deltvx = ((rv1 - (dy01 * deltvy + rv0)) / tmp); \
-                deltwx = ((rw1 - (dy01 * deltwy + rw0)) / tmp); \
-        } else { deltux = deltvx = deltwx = 0; } \
-                ustart = (deltuy * ydiff) + (ru0); \
-                vstart = (deltvy * ydiff) + (rv0); \
-                wstart = (deltwy * ydiff) + (rw0); \
-} while (0)
-
-#define SEND_UVWD() \
-do { \
-        DMAOUT((rbasev & 0xFFFF)); \
-        DMAOUT((0xa0000000 | (rbaseu & 0xFFFF))); \
-        DMAOUT(deltwx); \
-        DMAOUT(deltwy); \
-        DMAOUT(wstart); \
-        DMAOUT(deltdx); \
-        DMAOUT(deltvx); \
-        DMAOUT(deltux); \
-        DMAOUT(deltdy); \
-        DMAOUT(deltvy); \
-        DMAOUT(deltuy); \
-        DMAOUT(dstart); \
-        DMAOUT(vstart); \
-        DMAOUT(ustart); \
-} while (0)
-
-#define SEND_VERT() \
-do { \
-       DMAOUT(deltzx); \
-       DMAOUT(deltzy); \
-       DMAOUT(zstart); \
-       DMAOUT(delt12); \
-       DMAOUT(end12); \
-       DMAOUT(delt01); \
-       DMAOUT(end01); \
-       DMAOUT(delt02); \
-       DMAOUT(start02); \
-       DMAOUT(ystart); \
-       DMAOUT(y01y12); \
-} while (0)
-
-#define SEND_COL() \
-do { \
-       DMAOUT(deltgbx); \
-       DMAOUT(deltarx); \
-       DMAOUT(deltgby); \
-       DMAOUT(deltary); \
-       DMAOUT(gbstart); \
-       DMAOUT(arstart); \
-} while (0)
-
-/**** MACROS end ****/
-
-
-
-
-static void TAG(s3v_point)( s3vContextPtr vmesa, 
-                            const s3vVertex *_v0 )
-{
-}
-
-static void TAG(s3v_line)( s3vContextPtr vmesa, 
-                            const s3vVertex *_v0,
-                            const s3vVertex *_v1 )
-{
-       GLcontext *ctx = vmesa->glCtx;
-       __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
-
-       LINE_VERT_VARS;
-#if (IND & S3V_RAST_FLAT_BIT)
-       LINE_FLAT_VARS;
-#else
-       LINE_GOURAUD_VARS;
-#endif
-#if (IND & S3V_RAST_CULL_BIT)
-       GLfloat cull;
-        (void) cull;
-#endif
-       LINE_VERT_VARS_VOIDS;
-#if (IND & S3V_RAST_FLAT_BIT)
-       LINE_FLAT_VARS_VOIDS;
-#else
-       LINE_GOURAUD_VARS_VOIDS;
-#endif
-
-       DEBUG(("*** s3v_line: "));
-#if (IND & S3V_RAST_CULL_BIT)
-       DEBUG(("cull "));
-#endif
-#if (IND & S3V_RAST_FLAT_BIT)
-        DEBUG(("flat "));
-#endif
-
-       DEBUG(("***\n"));
-
-#if 0
-       s3v_print_vertex(ctx, _v0);
-       s3v_print_vertex(ctx, _v1);
-#endif
-
-       s3v_translate_vertex( ctx, _v0, &v[0] );
-       s3v_translate_vertex( ctx, _v1, &v[1] );
-
-#if (IND & S3V_RAST_CULL_BIT)
-       /* FIXME: should we cull lines too? */
-#endif
-       (void)v; /* v[0]; v[1]; */
-
-       SORT_LINE_VERT();
-       SET_LINE_VERT();
-
-       SET_LINE_XY();
-       SET_LINE_DIR();
-       SET_LINE_Z();
-
-#if (IND & S3V_RAST_FLAT_BIT)
-       SET_LINE_FLAT_COL();
-#else
-       SET_LINE_GOURAUD_COL();
-#endif
-
-       DMAOUT_CHECK(3DLINE_GBD, 15);
-               SEND_LINE_COL();
-               DMAOUT(0);
-               SEND_LINE_VERT();
-       DMAFINISH();
-}
-
-static void TAG(s3v_triangle)( s3vContextPtr vmesa,
-                                const s3vVertex *_v0,
-                                const s3vVertex *_v1, 
-                                const s3vVertex *_v2 )
-{
-       GLcontext *ctx = vmesa->glCtx;
-       __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
-
-       VERT_VARS;
-#if (IND & S3v_RAST_FLAT_BIT)
-       FLAT_VARS;
-#else
-       GOURAUD_VARS;
-#endif
-#if (IND & S3V_RAST_TEX_BIT)
-       TEX_VARS;
-#endif
-#if (IND & S3V_RAST_CULL_BIT)
-       GLfloat cull;
-#endif
-       VERT_VARS_VOIDS;
-#if (IND & S3v_RAST_FLAT_BIT)
-       FLAT_VARS_VOIDS;
-#else
-       GOURAUD_VARS_VOIDS;
-#endif
-#if (IND & S3V_RAST_TEX_BIT)
-       TEX_VARS_VOIDS;
-#endif
-
-       DEBUG(("*** s3v_triangle: "));
-#if (IND & S3V_RAST_CULL_BIT)
-       DEBUG(("cull "));
-#endif
-#if (IND & S3V_RAST_FLAT_BIT)
-        DEBUG(("flat "));
-#endif
-#if (IND & S3V_RAST_TEX_BIT)
-        DEBUG(("tex "));
-#endif
-
-DEBUG(("***\n"));
-
-#if 0
-       s3v_print_vertex(ctx, _v0);
-       s3v_print_vertex(ctx, _v1);
-       s3v_print_vertex(ctx, _v2);
-#endif
-
-       s3v_translate_vertex( ctx, _v0, &v[0] );
-       s3v_translate_vertex( ctx, _v1, &v[1] );
-       s3v_translate_vertex( ctx, _v2, &v[2] );
-
-#if (IND & S3V_RAST_CULL_BIT)
-       cull = vmesa->backface_sign *
-               ((v[1].attrib[FRAG_ATTRIB_WPOS][0] - v[0].attrib[FRAG_ATTRIB_WPOS][0]) * (v[0].attrib[FRAG_ATTRIB_WPOS][1] - v[2].attrib[FRAG_ATTRIB_WPOS][1]) +
-                (v[1].attrib[FRAG_ATTRIB_WPOS][1] - v[0].attrib[FRAG_ATTRIB_WPOS][1]) * (v[2].attrib[FRAG_ATTRIB_WPOS][0] - v[0].attrib[FRAG_ATTRIB_WPOS][0]));
-
-       if (cull < vmesa->cull_zero /* -0.02f */) return;
-#endif
-
-       (void)v; /* v[0]; v[1]; v[2]; */
-
-       SORT_VERT();
-       SET_VERT();
-
-       if (dy02 == 0) return;
-
-       SET_XY();
-       SET_DIR();
-       SET_Z();
-       
-#if (IND & S3V_RAST_TEX_BIT)
-       SET_TEX_VERT();
-       SET_UVWD();
-#endif
-
-#if (IND & S3V_RAST_FLAT_BIT)
-       SET_FLAT_COL();
-#else
-       SET_GOURAUD_COL();
-#endif
-
-#if (IND & S3V_RAST_TEX_BIT)
-        DMAOUT_CHECK(3DTRI_BASEV, 31);
-               SEND_UVWD();
-               SEND_COL();
-               SEND_VERT();
-       DMAFINISH();
-#else
-       DMAOUT_CHECK(3DTRI_GBX, 17);
-               SEND_COL();
-               SEND_VERT();
-       DMAFINISH();
-#endif
-}
-
-static void TAG(s3v_quad)( s3vContextPtr vmesa,
-                           const s3vVertex *_v0,
-                           const s3vVertex *_v1,
-                           const s3vVertex *_v2,
-                           const s3vVertex *_v3 )
-{
-       GLcontext *ctx = vmesa->glCtx;
-        __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
-
-       SWvertex temp_v[4];
-        VERT_VARS;
-#if (IND & S3v_RAST_FLAT_BIT)
-        FLAT_VARS;
-#else
-        GOURAUD_VARS;
-#endif
-#if (IND & S3V_RAST_TEX_BIT)
-        TEX_VARS;
-#endif
-#if (IND & S3V_RAST_CULL_BIT)
-        GLfloat cull;
-#endif
-        VERT_VARS_VOIDS;
-#if (IND & S3v_RAST_FLAT_BIT)
-        FLAT_VARS_VOIDS;
-#else
-        GOURAUD_VARS_VOIDS;
-#endif
-#if (IND & S3V_RAST_TEX_BIT)
-        TEX_VARS_VOIDS;
-#endif
-
-       DEBUG(("*** s3v_quad: "));
-#if (IND & S3V_RAST_CULL_BIT)
-        DEBUG(("cull "));
-               /* printf(""); */ /* speed trick */
-#endif
-#if (IND & S3V_RAST_FLAT_BIT)
-        DEBUG(("flat "));
-#endif
-#if (IND & S3V_RAST_TEX_BIT)
-        DEBUG(("tex "));
-#endif
-
-       DEBUG(("***\n"));
-
-#if 0
-       s3v_print_vertex(ctx, _v0);
-       s3v_print_vertex(ctx, _v1);
-       s3v_print_vertex(ctx, _v2);
-       s3v_print_vertex(ctx, _v3);
-#endif
-       s3v_translate_vertex( ctx, _v0, &temp_v[0] );
-       s3v_translate_vertex( ctx, _v1, &temp_v[1] );
-       s3v_translate_vertex( ctx, _v2, &temp_v[2] );
-       s3v_translate_vertex( ctx, _v3, &temp_v[3] );
-
-       /* FIRST TRI (0,1,2) */
-
-       /* ROMEO */
-       /* printf(""); */ /* speed trick (a) [turn on if (a) is return]*/
-
-       v[0] = temp_v[0];
-       v[1] = temp_v[1];
-       v[2] = temp_v[2];
-
-#if (IND & S3V_RAST_CULL_BIT)
-       cull = vmesa->backface_sign *
-               ((v[1].attrib[FRAG_ATTRIB_WPOS][0] - v[0].attrib[FRAG_ATTRIB_WPOS][0]) * (v[0].attrib[FRAG_ATTRIB_WPOS][1] - v[2].attrib[FRAG_ATTRIB_WPOS][1]) +
-                (v[1].attrib[FRAG_ATTRIB_WPOS][1] - v[0].attrib[FRAG_ATTRIB_WPOS][1]) * (v[2].attrib[FRAG_ATTRIB_WPOS][0] - v[0].attrib[FRAG_ATTRIB_WPOS][0]));
-
-       if (cull < vmesa->cull_zero /* -0.02f */) goto second; /* return; */ /* (a) */
-#endif
-       
-#if 0
-        v[0] = temp_v[0];
-       v[1] = temp_v[1];
-       v[2] = temp_v[2];
-#else
-        (void) v;
-#endif
-       SORT_VERT();
-       SET_VERT();
-
-       if (dy02 == 0) goto second;
-
-        SET_XY();
-        SET_DIR();
-        SET_Z();
-
-#if (IND & S3V_RAST_TEX_BIT)
-       SET_TEX_VERT();
-       SET_UVWD();
-#endif
-
-#if (IND & S3V_RAST_FLAT_BIT)
-       SET_FLAT_COL();
-#else
-       SET_GOURAUD_COL();
-#endif
-
-#if (IND & S3V_RAST_TEX_BIT)
-       DMAOUT_CHECK(3DTRI_BASEV, 31);
-               SEND_UVWD();
-               SEND_COL();
-               SEND_VERT();
-       DMAFINISH();
-#else
-       DMAOUT_CHECK(3DTRI_GBX, 17);
-               SEND_COL();
-               SEND_VERT();
-       DMAFINISH();
-#endif
-
-       /* SECOND TRI (0,2,3) */
-
-second:
-       v[0] = temp_v[0];
-       v[1] = temp_v[2];
-       v[2] = temp_v[3];
-
-#if (IND & S3V_RAST_CULL_BIT)
-       cull = vmesa->backface_sign *
-               ((v[1].attrib[FRAG_ATTRIB_WPOS][0] - v[0].attrib[FRAG_ATTRIB_WPOS][0]) * (v[0].attrib[FRAG_ATTRIB_WPOS][1] - v[2].attrib[FRAG_ATTRIB_WPOS][1]) +
-                (v[1].attrib[FRAG_ATTRIB_WPOS][1] - v[0].attrib[FRAG_ATTRIB_WPOS][1]) * (v[2].attrib[FRAG_ATTRIB_WPOS][0] - v[0].attrib[FRAG_ATTRIB_WPOS][0]));
-                
-       if (cull < /* -0.02f */ vmesa->cull_zero) return;
-#endif
-
-/* second: */
-
-       /* ROMEO */
-       /* printf(""); */ /* speed trick */
-
-       v[0] = temp_v[0];
-       v[1] = temp_v[2];
-       v[2] = temp_v[3];
-
-       SORT_VERT();
-       SET_VERT();
-
-       if (dy02 == 0) return;
-
-       SET_XY();
-       SET_DIR();
-       SET_Z();
-
-#if (IND & S3V_RAST_TEX_BIT)
-       SET_TEX_VERT();
-       SET_UVWD();
-#endif
-
-#if (IND & S3V_RAST_FLAT_BIT)
-       SET_FLAT_COL();
-#else
-       SET_GOURAUD_COL();
-#endif
-
-#if (IND & S3V_RAST_TEX_BIT)
-       DMAOUT_CHECK(3DTRI_BASEV, 31);
-               SEND_UVWD();
-               SEND_COL();
-               SEND_VERT();
-       DMAFINISH();
-#else
-       DMAOUT_CHECK(3DTRI_GBX, 17);
-               SEND_COL();
-               SEND_VERT();
-       DMAFINISH();
-#endif
-}
-
-static void TAG(s3v_init)(void)
-{
-       s3v_point_tab[IND]      = TAG(s3v_point);
-       s3v_line_tab[IND]       = TAG(s3v_line);
-       s3v_tri_tab[IND]        = TAG(s3v_triangle);
-       s3v_quad_tab[IND]       = TAG(s3v_quad);
-}
-
-#undef IND
-#undef TAG
diff --git a/src/mesa/drivers/dri/s3v/s3v_vb.c b/src/mesa/drivers/dri/s3v/s3v_vb.c
deleted file mode 100644 (file)
index 00e375c..0000000
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#include "main/glheader.h"
-#include "main/mtypes.h"
-#include "main/macros.h"
-#include "main/colormac.h"
-
-#include "swrast_setup/swrast_setup.h"
-#include "tnl/t_context.h"
-#include "tnl/tnl.h"
-
-#include "s3v_context.h"
-#include "s3v_vb.h"
-#include "s3v_tris.h"
-
-#define S3V_XYZW_BIT       0x1
-#define S3V_RGBA_BIT       0x2
-#define S3V_TEX0_BIT       0x4
-#define S3V_PTEX_BIT       0x8
-#define S3V_FOG_BIT        0x10
-#define S3V_MAX_SETUP      0x20
-
-static struct {
-   void                (*emit)( GLcontext *, GLuint, GLuint, void *, GLuint );
-   tnl_interp_func     interp;
-   tnl_copy_pv_func    copy_pv;
-   GLboolean           (*check_tex_sizes)( GLcontext *ctx );
-   GLuint               vertex_size;
-   GLuint               vertex_stride_shift;
-   GLuint               vertex_format;
-} setup_tab[S3V_MAX_SETUP];
-
-
-/* Only one vertex format, atm, so no need to give them names:
- */
-#define TINY_VERTEX_FORMAT      1
-#define NOTEX_VERTEX_FORMAT     0
-#define TEX0_VERTEX_FORMAT      0
-#define TEX1_VERTEX_FORMAT      0
-#define PROJ_TEX1_VERTEX_FORMAT 0
-#define TEX2_VERTEX_FORMAT      0
-#define TEX3_VERTEX_FORMAT      0
-#define PROJ_TEX3_VERTEX_FORMAT 0
-
-#define DO_XYZW (IND & S3V_XYZW_BIT)
-#define DO_RGBA (IND & S3V_RGBA_BIT)
-#define DO_SPEC 0
-#define DO_FOG  (IND & S3V_FOG_BIT)
-#define DO_TEX0 (IND & S3V_TEX0_BIT)
-#define DO_TEX1 0
-#define DO_TEX2 0
-#define DO_TEX3 0
-#define DO_PTEX (IND & S3V_PTEX_BIT)
-                              
-#define VERTEX s3vVertex
-#define LOCALVARS /* s3vContextPtr vmesa = S3V_CONTEXT(ctx); */
-#define GET_VIEWPORT_MAT() 0 /* vmesa->hw_viewport */
-#define GET_TEXSOURCE(n)  n
-#define GET_VERTEX_FORMAT() 0
-#define GET_VERTEX_SIZE() S3V_CONTEXT(ctx)->vertex_size * sizeof(GLuint)
-#define GET_VERTEX_STORE() S3V_CONTEXT(ctx)->verts
-#define GET_VERTEX_STRIDE_SHIFT() S3V_CONTEXT(ctx)->vertex_stride_shift
-#define INVALIDATE_STORED_VERTICES()
-#define GET_UBYTE_COLOR_STORE() &S3V_CONTEXT(ctx)->UbyteColor
-#define GET_UBYTE_SPEC_COLOR_STORE() &S3V_CONTEXT(ctx)->UbyteSecondaryColor
-
-#define HAVE_HW_VIEWPORT    1  /* FIXME */
-#define HAVE_HW_DIVIDE      1
-#define HAVE_RGBA_COLOR     0  /* we're BGRA */
-#define HAVE_TINY_VERTICES  1
-#define HAVE_NOTEX_VERTICES 0
-#define HAVE_TEX0_VERTICES  0
-#define HAVE_TEX1_VERTICES  0
-#define HAVE_TEX2_VERTICES  0
-#define HAVE_TEX3_VERTICES  0
-#define HAVE_PTEX_VERTICES  1
-
-/*
-#define SUBPIXEL_X -.5
-#define SUBPIXEL_Y -.5
-#define UNVIEWPORT_VARS  GLfloat h = S3V_CONTEXT(ctx)->driDrawable->h
-#define UNVIEWPORT_X(x)  x - SUBPIXEL_X
-#define UNVIEWPORT_Y(y)  - y + h + SUBPIXEL_Y
-#define UNVIEWPORT_Z(z)  z / vmesa->depth_scale
-*/
-
-#define PTEX_FALLBACK()                /* never needed */
-
-#define IMPORT_QUALIFIER
-#define IMPORT_FLOAT_COLORS s3v_import_float_colors
-#define IMPORT_FLOAT_SPEC_COLORS s3v_import_float_spec_colors
-
-#define INTERP_VERTEX setup_tab[S3V_CONTEXT(ctx)->SetupIndex].interp
-#define COPY_PV_VERTEX setup_tab[S3V_CONTEXT(ctx)->SetupIndex].copy_pv
-
-
-
-/***********************************************************************
- *         Generate  pv-copying and translation functions              *
- ***********************************************************************/
-
-#define TAG(x) s3v_##x
-#include "tnl_dd/t_dd_vb.c"
-
-/***********************************************************************
- *             Generate vertex emit and interp functions               *
- ***********************************************************************/
-
-
-#define IND (S3V_XYZW_BIT|S3V_RGBA_BIT)
-#define TAG(x) x##_wg
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (S3V_XYZW_BIT|S3V_RGBA_BIT|S3V_TEX0_BIT)
-#define TAG(x) x##_wgt0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (S3V_XYZW_BIT|S3V_RGBA_BIT|S3V_TEX0_BIT|S3V_PTEX_BIT)
-#define TAG(x) x##_wgpt0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (S3V_TEX0_BIT)
-#define TAG(x) x##_t0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (S3V_RGBA_BIT)
-#define TAG(x) x##_g
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (S3V_RGBA_BIT|S3V_TEX0_BIT)
-#define TAG(x) x##_gt0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (S3V_XYZW_BIT|S3V_RGBA_BIT|S3V_FOG_BIT)
-#define TAG(x) x##_wgf
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (S3V_XYZW_BIT|S3V_RGBA_BIT|S3V_FOG_BIT|S3V_TEX0_BIT)
-#define TAG(x) x##_wgft0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (S3V_XYZW_BIT|S3V_RGBA_BIT|S3V_FOG_BIT|S3V_TEX0_BIT|S3V_PTEX_BIT)
-#define TAG(x) x##_wgfpt0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (S3V_FOG_BIT)
-#define TAG(x) x##_f
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (S3V_RGBA_BIT | S3V_FOG_BIT)
-#define TAG(x) x##_gf
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (S3V_RGBA_BIT | S3V_FOG_BIT | S3V_TEX0_BIT)
-#define TAG(x) x##_gft0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-static void init_setup_tab( void )
-{
-   init_wg();          /* pos + col */
-   init_wgt0();                /* pos + col + tex0 */
-   init_wgpt0();       /* pos + col + p-tex0 (?) */
-   init_t0();          /* tex0 */
-   init_g();           /* col */
-   init_gt0();         /* col + tex */
-   init_wgf();
-   init_wgft0();
-   init_wgfpt0();
-   init_f();
-   init_gf();
-   init_gft0();
-}
-
-
-#if 0
-void s3vPrintSetupFlags(char *msg, GLuint flags )
-{
-   fprintf(stderr, "%s(%x): %s%s%s%s%s%s\n",
-          msg,
-          (int)flags,
-          (flags & S3V_XYZW_BIT)      ? " xyzw," : "", 
-          (flags & S3V_RGBA_BIT)     ? " rgba," : "",
-          (flags & S3V_SPEC_BIT)     ? " spec," : "",
-          (flags & S3V_FOG_BIT)      ? " fog," : "",
-          (flags & S3V_TEX0_BIT)     ? " tex-0," : "",
-          (flags & S3V_TEX1_BIT)     ? " tex-1," : "");
-}
-#endif
-
-
-void s3vCheckTexSizes( GLcontext *ctx )
-{
-   TNLcontext *tnl = TNL_CONTEXT(ctx);
-   s3vContextPtr vmesa = S3V_CONTEXT( ctx );
-
-   if (!setup_tab[vmesa->SetupIndex].check_tex_sizes(ctx)) {
-
-      vmesa->SetupIndex |= (S3V_PTEX_BIT|S3V_RGBA_BIT);
-
-      if (1 || !(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
-         tnl->Driver.Render.Interp = setup_tab[vmesa->SetupIndex].interp;
-         tnl->Driver.Render.CopyPV = setup_tab[vmesa->SetupIndex].copy_pv;
-      }
-   }
-}
-
-void s3vBuildVertices( GLcontext *ctx, 
-                        GLuint start, 
-                        GLuint count,
-                        GLuint newinputs )
-{
-       s3vContextPtr vmesa = S3V_CONTEXT( ctx );
-       GLubyte *v = ((GLubyte *)vmesa->verts +
-               (start<<vmesa->vertex_stride_shift));
-       GLuint stride = 1<<vmesa->vertex_stride_shift;
-
-       DEBUG(("*** s3vBuildVertices ***\n"));
-       DEBUG(("vmesa->SetupNewInputs = 0x%x\n", vmesa->SetupNewInputs));
-       DEBUG(("vmesa->SetupIndex = 0x%x\n", vmesa->SetupIndex));
-
-#if 1
-       setup_tab[vmesa->SetupIndex].emit( ctx, start, count, v, stride );
-#else
-       newinputs |= vmesa->SetupNewInputs;
-       vmesa->SetupNewInputs = 0;
-
-       DEBUG(("newinputs is 0x%x\n", newinputs));
-
-       if (!newinputs) {
-               DEBUG(("!newinputs\n"));
-               return;
-       }
-
-       if (newinputs & VERT_CLIP) {
-       setup_tab[vmesa->SetupIndex].emit( ctx, start, count, v, stride );
-       DEBUG(("newinputs & VERT_CLIP\n"));
-       return;
-       } /* else { */
-/*      GLuint ind = 0; */
-
-       if (newinputs & VERT_RGBA) {
-               DEBUG(("newinputs & VERT_RGBA\n"));
-               ind |= S3V_RGBA_BIT;
-       }
-       if (newinputs & VERT_TEX0) {
-               DEBUG(("newinputs & VERT_TEX0\n"));
-               ind |= S3V_TEX0_BIT;
-       }
-
-    if (newinputs & VERT_FOG_COORD)
-        ind |= S3V_FOG_BIT;
-
-       if (vmesa->SetupIndex & S3V_PTEX_BIT)
-               ind = ~0;
-
-    ind &= vmesa->SetupIndex;
-
-       DEBUG(("vmesa->SetupIndex = 0x%x\n", vmesa->SetupIndex));
-       DEBUG(("ind = 0x%x\n", ind));
-       DEBUG(("ind & vmesa->SetupIndex = 0x%x\n", (ind & vmesa->SetupIndex)));
-
-       if (ind) {
-               setup_tab[ind].emit( ctx, start, count, v, stride );   
-       }
-#endif
-}
-
-void s3vChooseVertexState( GLcontext *ctx )
-{
-   s3vContextPtr vmesa = S3V_CONTEXT( ctx );
-   TNLcontext *tnl = TNL_CONTEXT(ctx);
-
-   GLuint ind = S3V_XYZW_BIT | S3V_RGBA_BIT;
-
-   /* FIXME: will segv in tnl_dd/t_dd_vbtmp.h (line 196) on some demos */
-/*
-   if (ctx->Fog.Enabled)
-      ind |= S3V_FOG_BIT;
-*/
-
-
-   if (ctx->Texture.Unit[0]._ReallyEnabled) {
-      _tnl_need_projected_coords( ctx, GL_FALSE );
-      ind |= S3V_TEX0_BIT;
-   } else {
-      _tnl_need_projected_coords( ctx, GL_TRUE );
-   }
-
-   vmesa->SetupIndex = ind;
-
-   if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
-      tnl->Driver.Render.Interp = s3v_interp_extras;
-      tnl->Driver.Render.CopyPV = s3v_copy_pv_extras;
-   } else {
-      tnl->Driver.Render.Interp = setup_tab[ind].interp;
-      tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv;
-   }
-}
-
-
-void s3vInitVB( GLcontext *ctx )
-{
-   s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-   GLuint size = TNL_CONTEXT(ctx)->vb.Size;
-
-   vmesa->verts = (char *)ALIGN_MALLOC(size * 4 * 16, 32);
-
-   {
-      static int firsttime = 1;
-      if (firsttime) {
-        init_setup_tab();
-        firsttime = 0;
-        vmesa->vertex_stride_shift = 6 /* 4 */; /* FIXME - only one vertex setup */
-      }
-   }
-}
-
-
-void s3vFreeVB( GLcontext *ctx )
-{
-   s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-   if (vmesa->verts) {
-      ALIGN_FREE(vmesa->verts);
-      vmesa->verts = 0;
-   }
-
-   if (vmesa->UbyteSecondaryColor.Ptr) {
-      ALIGN_FREE((void *)vmesa->UbyteSecondaryColor.Ptr);
-      vmesa->UbyteSecondaryColor.Ptr = 0;
-   }
-
-   if (vmesa->UbyteColor.Ptr) {
-      ALIGN_FREE((void *)vmesa->UbyteColor.Ptr);
-      vmesa->UbyteColor.Ptr = 0;
-   }
-}
diff --git a/src/mesa/drivers/dri/s3v/s3v_vb.h b/src/mesa/drivers/dri/s3v/s3v_vb.h
deleted file mode 100644 (file)
index 0fd5437..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#ifndef S3VVB_INC
-#define S3VVB_INC
-
-#include "main/mtypes.h"
-#include "swrast/swrast.h"
-
-#define _S3V_NEW_VERTEX (_NEW_TEXTURE |                \
-                          _DD_NEW_TRI_UNFILLED |       \
-                          _DD_NEW_TRI_LIGHT_TWOSIDE)
-
-
-extern void s3vChooseVertexState( GLcontext *ctx );
-extern void s3vCheckTexSizes( GLcontext *ctx );
-extern void s3vBuildVertices( GLcontext *ctx, 
-                               GLuint start, 
-                               GLuint count,
-                               GLuint newinputs );
-
-
-extern void s3v_import_float_colors( GLcontext *ctx );
-extern void s3v_import_float_spec_colors( GLcontext *ctx );
-
-extern void s3v_translate_vertex( GLcontext *ctx, 
-                                   const s3vVertex *src, 
-                                   SWvertex *dst );
-
-extern void s3vInitVB( GLcontext *ctx );
-extern void s3vFreeVB( GLcontext *ctx );
-
-extern void s3v_print_vertex( GLcontext *ctx, const s3vVertex *v );
-#if 0
-extern void s3vPrintSetupFlags(char *msg, GLuint flags );
-#endif
-
-#endif
diff --git a/src/mesa/drivers/dri/s3v/s3v_xmesa.c b/src/mesa/drivers/dri/s3v/s3v_xmesa.c
deleted file mode 100644 (file)
index 85f1481..0000000
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#include "s3v_context.h"
-#include "s3v_vb.h"
-#include "s3v_dri.h"
-#include "main/context.h"
-#include "main/matrix.h"
-#include "main/framebuffer.h"
-#include "main/renderbuffer.h"
-#include "main/viewport.h"
-
-#include "swrast/swrast.h"
-#include "swrast_setup/swrast_setup.h"
-#include "tnl/tnl.h"
-#include "vbo/vbo.h"
-
-/* #define DEBUG(str) printf str */
-
-static const __DRIconfig **
-s3vInitScreen(__DRIscreen *sPriv)
-{
-    sPriv->private = (void *) s3vCreateScreen( sPriv );
-
-    if (!sPriv->private) {
-       s3vDestroyScreen( sPriv );
-       return GL_FALSE;
-    }
-
-   return NULL;
-}
-
-static void 
-s3vDestroyContext(__DRIcontextPrivate *driContextPriv)
-{
-    s3vContextPtr vmesa = (s3vContextPtr)driContextPriv->driverPrivate;
-
-    if (vmesa) {
-      _swsetup_DestroyContext( vmesa->glCtx );
-      _tnl_DestroyContext( vmesa->glCtx );
-      _vbo_DestroyContext( vmesa->glCtx );
-      _swrast_DestroyContext( vmesa->glCtx );
-
-      s3vFreeVB( vmesa->glCtx );
-
-      /* free the Mesa context */
-      vmesa->glCtx->DriverCtx = NULL;
-      _mesa_destroy_context(vmesa->glCtx);
-
-      _mesa_free(vmesa);
-      driContextPriv->driverPrivate = NULL;
-    }
-}
-
-
-static GLboolean
-s3vCreateBuffer( __DRIscreenPrivate *driScrnPriv,
-                   __DRIdrawablePrivate *driDrawPriv,
-                   const __GLcontextModes *mesaVis,
-                   GLboolean isPixmap )
-{
-   s3vScreenPtr screen = (s3vScreenPtr) driScrnPriv->private;
-
-   if (isPixmap) {
-      return GL_FALSE; /* not implemented */
-   }
-   else {
-      struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
-
-      {
-         driRenderbuffer *frontRb
-            = driNewRenderbuffer(GL_RGBA, NULL, screen->cpp,
-                                 screen->frontOffset, screen->frontPitch,
-                                 driDrawPriv);
-         s3vSetSpanFunctions(frontRb, mesaVis);
-         _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
-      }
-
-      if (mesaVis->doubleBufferMode) {
-         driRenderbuffer *backRb
-            = driNewRenderbuffer(GL_RGBA, NULL, screen->cpp,
-                                 screen->backOffset, screen->backPitch,
-                                 driDrawPriv);
-         s3vSetSpanFunctions(backRb, mesaVis);
-         _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
-         backRb->backBuffer = GL_TRUE;
-      }
-
-      if (mesaVis->depthBits == 16) {
-         driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT16, NULL, screen->cpp,
-                                 screen->depthOffset, screen->depthPitch,
-                                 driDrawPriv);
-         s3vSetSpanFunctions(depthRb, mesaVis);
-         _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
-      }
-      else if (mesaVis->depthBits == 24) {
-         driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT24, NULL, screen->cpp,
-                                 screen->depthOffset, screen->depthPitch,
-                                 driDrawPriv);
-         s3vSetSpanFunctions(depthRb, mesaVis);
-         _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
-      }
-
-      /* no h/w stencil yet?
-      if (mesaVis->stencilBits > 0) {
-         driRenderbuffer *stencilRb
-            = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, NULL,
-                                 screen->cpp, screen->depthOffset,
-                                 screen->depthPitch, driDrawPriv);
-         s3vSetSpanFunctions(stencilRb, mesaVis);
-         _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
-      }
-      */
-
-      _mesa_add_soft_renderbuffers(fb,
-                                   GL_FALSE, /* color */
-                                   GL_FALSE, /* depth */
-                                   mesaVis->stencilBits > 0,
-                                   mesaVis->accumRedBits > 0,
-                                   GL_FALSE, /* alpha */
-                                   GL_FALSE /* aux */);
-      driDrawPriv->driverPrivate = (void *) fb;
-
-      return (driDrawPriv->driverPrivate != NULL);
-   }
-}
-
-
-static void
-s3vDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
-{
-   _mesa_reference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)), NULL);
-}
-
-static void
-s3vSwapBuffers(__DRIdrawablePrivate *drawablePrivate)
-{
-   __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate;
-   __DRIscreenPrivate *sPriv;
-   GLcontext *ctx;
-   s3vContextPtr vmesa;
-   s3vScreenPtr s3vscrn;
-   
-   vmesa = (s3vContextPtr) dPriv->driContextPriv->driverPrivate;
-   sPriv = vmesa->driScreen;
-   s3vscrn = vmesa->s3vScreen;
-   ctx = vmesa->glCtx;
-
-   DEBUG(("*** s3vSwapBuffers ***\n"));
-
-/* DMAFLUSH(); */
-
-   _mesa_notifySwapBuffers( ctx );
-
-   vmesa = (s3vContextPtr) dPriv->driContextPriv->driverPrivate;
-/*    driScrnPriv = vmesa->driScreen; */
-
-/*    if (vmesa->EnabledFlags & S3V_BACK_BUFFER) */
-
-/*     _mesa_notifySwapBuffers( ctx );  */
-#if 1
-{      
-       int x0, y0, x1, y1;
-/*     
-       int nRect = dPriv->numClipRects;
-       XF86DRIClipRectPtr pRect = dPriv->pClipRects;
-
-       __DRIscreenPrivate *driScrnPriv = vmesa->driScreen;
-*/
-
-/*     
-       DEBUG(("s3vSwapBuffers: S3V_BACK_BUFFER = 1 - nClip = %i\n", nRect));
-*/
-/*     vmesa->drawOffset=vmesa->s3vScreen->backOffset; */
-
-       x0 = dPriv->x;
-       y0 = dPriv->y;
-
-       x1 = x0 + dPriv->w - 1;
-       y1 = y0 + dPriv->h - 1;
-
-       DMAOUT_CHECK(BITBLT_SRC_BASE, 15);
-               DMAOUT(vmesa->s3vScreen->backOffset);
-               DMAOUT(0); /* 0xc0000000 */
-               DMAOUT( ((x0 << 16) | x1) );
-               DMAOUT( ((y0 << 16) | y1) );
-               DMAOUT( (vmesa->DestStride << 16) | vmesa->SrcStride );
-               DMAOUT( (~(0)) );
-               DMAOUT( (~(0)) );
-               DMAOUT(0);
-               DMAOUT(0);
-       /* FIXME */
-               DMAOUT(0);
-               DMAOUT(0);
-               DMAOUT( (0x01 | /* Autoexecute */
-                        0x02 | /* clip */
-                        0x04 | /* 16 bit */
-                        0x20 | /* draw */
-                       0x400 | /* word alignment (bit 10=1) */
-                       (0x2 << 11) | /*  offset = 1 byte */
-                       (0xCC << 17) |  /* rop #204 */
-                       (0x3 << 25)) ); /* l-r, t-b */
-               DMAOUT(vmesa->ScissorWH);
-               DMAOUT( /* 0 */ vmesa->SrcXY );
-               DMAOUT( (dPriv->x << 16) | dPriv->y );
-       DMAFINISH();
-
-       DMAFLUSH();
-
-       vmesa->restore_primitive = -1;
-
-}
-#endif
-}
-
-static GLboolean 
-s3vMakeCurrent(__DRIcontextPrivate *driContextPriv,
-                __DRIdrawablePrivate *driDrawPriv,
-                __DRIdrawablePrivate *driReadPriv)
-{
-       int x1,x2,y1,y2;
-       int cx, cy, cw, ch;
-       unsigned int src_stride, dest_stride;
-       int cl;
-
-       s3vContextPtr vmesa;
-       __DRIdrawablePrivate *dPriv = driDrawPriv;
-       vmesa = (s3vContextPtr) dPriv->driContextPriv->driverPrivate;
-       
-       DEBUG(("s3vMakeCurrent\n"));
-
-       DEBUG(("dPriv->x=%i y=%i w=%i h=%i\n", dPriv->x, dPriv->y,
-               dPriv->w, dPriv->h));
-
-       if (driContextPriv) {
-       GET_CURRENT_CONTEXT(ctx);
-       s3vContextPtr oldVirgeCtx = ctx ? S3V_CONTEXT(ctx) : NULL;
-       s3vContextPtr newVirgeCtx = (s3vContextPtr) driContextPriv->driverPrivate;
-
-       if ( newVirgeCtx != oldVirgeCtx ) {
-
-               newVirgeCtx->dirty = ~0;
-               cl = 1;
-               DEBUG(("newVirgeCtx != oldVirgeCtx\n"));
-/*             s3vUpdateClipping(newVirgeCtx->glCtx ); */
-       }
-
-       if (newVirgeCtx->driDrawable != driDrawPriv) {
-           newVirgeCtx->driDrawable = driDrawPriv;
-               DEBUG(("driDrawable != driDrawPriv\n"));
-               s3vUpdateWindow ( newVirgeCtx->glCtx );
-               s3vUpdateViewportOffset( newVirgeCtx->glCtx );
-/*             s3vUpdateClipping(newVirgeCtx->glCtx ); */
-       }
-/*
-       s3vUpdateWindow ( newVirgeCtx->glCtx );
-       s3vUpdateViewportOffset( newVirgeCtx->glCtx );
-*/
-
-/*
-       _mesa_make_current( newVirgeCtx->glCtx,
-                          (GLframebuffer *) driDrawPriv->driverPrivate,
-                          (GLframebuffer *) driReadPriv->driverPrivate );
-
-       _mesa_set_viewport(newVirgeCtx->glCtx, 0, 0,
-                         newVirgeCtx->driDrawable->w,
-                         newVirgeCtx->driDrawable->h);
-*/
-
-#if 0
-       newVirgeCtx->Window &= ~W_GIDMask;
-       newVirgeCtx->Window |= (driDrawPriv->index << 5);
-       CHECK_DMA_BUFFER(newVirgeCtx,1);
-       WRITE(newVirgeCtx->buf, S3VWindow, newVirgeCtx->Window);
-#endif
-
-       newVirgeCtx->new_state |= S3V_NEW_WINDOW; /* FIXME */
-
-       _mesa_make_current( newVirgeCtx->glCtx, 
-                            (GLframebuffer *) driDrawPriv->driverPrivate,
-                            (GLframebuffer *) driReadPriv->driverPrivate );
-
-       if (!newVirgeCtx->glCtx->Viewport.Width) {
-           _mesa_set_viewport(newVirgeCtx->glCtx, 0, 0, 
-                                       driDrawPriv->w, driDrawPriv->h);
-
-/*             s3vUpdateClipping(newVirgeCtx->glCtx ); */
-       }
-
-/*
-       if (cl) {
-               s3vUpdateClipping(newVirgeCtx->glCtx );
-               cl =0;
-       }
-*/
-
-       newVirgeCtx->new_state |= S3V_NEW_CLIP;
-
-        if (1) {
-           cx = dPriv->x;
-           cw = dPriv->w;
-           cy = dPriv->y;
-           ch = dPriv->h;
-        }
-        
-        x1 = y1 = 0;
-        x2 = cw-1;
-        y2 = ch-1;
-
-        /*  src_stride = vmesa->s3vScreen->w * vmesa->s3vScreen->cpp; 
-            dest_stride = ((x2+31)&~31) * vmesa->s3vScreen->cpp; */
-        src_stride = vmesa->driScreen->fbWidth * 2;
-        dest_stride = ((x2+31)&~31) * 2;
-    } else {
-       _mesa_make_current( NULL, NULL, NULL );
-    }
-
-    return GL_TRUE;
-}
-
-
-static GLboolean 
-s3vUnbindContext( __DRIcontextPrivate *driContextPriv )
-{
-   return GL_TRUE;
-}
-
-const struct __DriverAPIRec driDriverAPI = {
-   .InitScreen    = s3vInitScreen,
-   .DestroyScreen  = s3vDestroyScreen,
-   .CreateContext  = s3vCreateContext,
-   .DestroyContext = s3vDestroyContext,
-   .CreateBuffer   = s3vCreateBuffer,
-   .DestroyBuffer  = s3vDestroyBuffer,
-   .SwapBuffers           = s3vSwapBuffers,
-   .MakeCurrent           = s3vMakeCurrent,
-   .UnbindContext  = s3vUnbindContext,
-};
diff --git a/src/mesa/drivers/dri/s3v/s3virgetri.h b/src/mesa/drivers/dri/s3v/s3virgetri.h
deleted file mode 100644 (file)
index 5519cfd..0000000
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#define LOCAL_VARS \
-       int vert0, vert1, vert2; \
-       GLfloat y0, y1, y2, ydiff; \
-       int iy0, iy1, iy2; \
-       int x0, x1, x2, z0, z1, z2; \
-       int dy01, dy02, dy12, dx01, dx02, dx12; \
-       int delt02, delt01, delt12, end01, end12, start02; \
-       int zstart, arstart, gbstart; \
-       int deltzy, deltzx, deltarx, deltgbx, deltary, deltgby; \
-       GLubyte (*colours)[4]; \
-       GLubyte (*scolours)[4]; \
-       static int tp = 0; \
-       int tmp, lr
-
-#define LOCAL_TEX_VARS \
-       int u0, u1, u2; \
-       GLfloat ru0, ru1, ru2; \
-       int v0, v1, v2; \
-       GLfloat rv0, rv1, rv2; \
-       GLfloat w0, w1, w2; \
-       GLfloat rw0, rw1, rw2; \
-       int baseu, basev; \
-       int d0, d1, d2; \
-       int deltdx, deltvx, deltux, deltdy, deltvy, deltuy; \
-       int deltwx, deltwy; \
-       int rbaseu, rbasev; \
-       int dstart, ustart, wstart, vstart; \
-       static int stmp = 0; \
-       s3virgeTextureObject_t *t
-
-#define CULL_BACKFACE() \
-       do { \
-               GLfloat *w0 = VB->Win.data[e0]; \
-               GLfloat *w1 = VB->Win.data[e1]; \
-               GLfloat *w2 = VB->Win.data[e2]; \
-               float cull; \
-               cull = ctx->backface_sign * ((w1[0] - w0[0]) * (w0[1] - w2[1]) + \
-                       (w1[1] - w0[1]) * (w2[0] - w0[0])); \
-               if (cull < 0) \
-                       return; \
-       } while (0)
-       
-#define SORT_VERTICES() \
-       do { \
-               y0 = VB->Win.data[e0][1]; \
-               y1 = VB->Win.data[e1][1]; \
-               y2 = VB->Win.data[e2][1]; \
-               if (y1 > y0) { \
-                       if (y2 > y0) {  \
-                               vert0 = e0; \
-                               if (y1 > y2) { vert2 = e1; vert1 = e2; } else { vert2 = e2; vert1 = e1; } \
-                       } else { vert0 = e2; vert1 = e0; vert2 = e1; } \
-               } else { \
-                       if (y2 > y0) { vert0 = e1; vert1 = e0; vert2 = e2; } else { \
-                               vert2 = e0; \
-                               if (y2 > y1) { vert0 = e1; vert1 = e2; } else { vert0 = e2; vert1 = e1; } \
-                       } \
-               } \
-       } while (0)
-
-#define SET_VARIABLES() \
-       do { \
-               iy0 = y0 = ((s3virgeDB->height - (VB->Win.data[vert0][1]))); \
-               iy1 = y1 = ((s3virgeDB->height - (VB->Win.data[vert1][1]))); \
-               iy2 = y2 = ((s3virgeDB->height - (VB->Win.data[vert2][1]))); \
-               if (iy0 == iy2) { return; } \
-               ydiff = y0 - (float)iy0; \
-               x0 = ((VB->Win.data[vert0][0]) * 1024.0 * 1024.0); \
-               x1 = ((VB->Win.data[vert1][0]) * 1024.0 * 1024.0); \
-               x2 = ((VB->Win.data[vert2][0]) * 1024.0 * 1024.0); \
-               z0 = (VB->Win.data[vert0][2] * 1024.0 * 32.0); \
-               z1 = (VB->Win.data[vert1][2] * 1024.0 * 32.0); \
-               z2 = (VB->Win.data[vert2][2] * 1024.0 * 32.0); \
-               dx12 = x2 - x1; \
-               dy12 = iy1 - iy2; \
-               dx01 = x1 - x0; \
-               dy01 = iy0 - iy1; \
-               dx02 = x2 - x0; \
-               dy02 = iy0 - iy2; \
-               delt12 = delt02 = delt01 = 0; \
-       } while (0)
-       
-#define SET_TEX_VARIABLES() \
-       do { \
-               t = ((s3virgeTextureObject_t *)ctx->Texture.Unit[0].Current->DriverData); \
-               deltwx = deltwy = wstart = deltdx = deltdy = dstart = 0; \
-               u0 = (VB->TexCoordPtr[0]->data[vert0][0] * (GLfloat)(t->tObj->Image[0]->Width) * 256.0); \
-               u1 = (VB->TexCoordPtr[0]->data[vert1][0] * (GLfloat)(t->tObj->Image[0]->Width) * 256.0); \
-               u2 = (VB->TexCoordPtr[0]->data[vert2][0] * (GLfloat)(t->tObj->Image[0]->Width) * 256.0); \
-               v0 = (VB->TexCoordPtr[0]->data[vert0][1] * (GLfloat)(t->tObj->Image[0]->Height) * 256.0); \
-               v1 = (VB->TexCoordPtr[0]->data[vert1][1] * (GLfloat)(t->tObj->Image[0]->Height) * 256.0); \
-               v2 = (VB->TexCoordPtr[0]->data[vert2][1] * (GLfloat)(t->tObj->Image[0]->Height) * 256.0); \
-               w0 = (VB->Win.data[vert0][3]); \
-               w1 = (VB->Win.data[vert1][3]); \
-               w2 = (VB->Win.data[vert2][3]); \
-       } while (0)
-
-#define FLATSHADE_COLORS() \
-       do { \
-               GLubyte *col = &(colours[pv][0]); \
-               deltarx = deltary = deltgbx = deltgby = 0; \
-               gbstart = (((col[1]) << 23) | ((col[2]) << 7)); \
-               arstart = (((col[3]) << 23) | ((col[0]) << 7)); \
-       } while (0)
-
-#define GOURAUD_COLORS() \
-       do { \
-               int ctmp, ctmp2, ctmp3, ctmp4; \
-               GLubyte *col0, *col1, *col2; \
-               col0 = &(colours[vert0][0]); \
-               col1 = &(colours[vert1][0]); \
-               col2 = &(colours[vert2][0]); \
-               ctmp = ((col2[3] - col0[3]) << 7) / dy02; \
-               ctmp2 = ((col2[0] - col0[0]) << 7) / dy02; \
-               deltary = ((ctmp << 16) & 0xFFFF0000) | (ctmp2 & 0xFFFF); \
-               ctmp3 = ((col2[1] - col0[1]) << 7) / dy02; \
-               ctmp4 = ((col2[2] - col0[2]) << 7) / dy02; \
-               deltgby = ((ctmp3 << 16) & 0xFFFF0000) | (ctmp4 & 0xFFFF); \
-               gbstart = (((int)((ydiff * ctmp3) + (col0[1] << 7)) << 16) & 0x7FFF0000) | \
-                         ((int)((ydiff * ctmp4) + (col0[2] << 7)) & 0x7FFF); \
-               arstart = (((int)((ydiff * ctmp) + (col0[3] << 7)) << 16) & 0x7FFF0000) | \
-                         ((int)((ydiff * ctmp2) + (col0[0] << 7)) & 0x7FFF); \
-               if (tmp) { \
-                       int ax, rx, gx, bx; \
-                       ax = ((col1[3] << 7) - (dy01 * ctmp + (col0[3] << 7))) / tmp; \
-                       rx = ((col1[0] << 7) - (dy01 * ctmp2 + (col0[0] << 7))) / tmp; \
-                       gx = ((col1[1] << 7) - (dy01 * ctmp3 + (col0[1] << 7))) / tmp; \
-                       bx = ((col1[2] << 7) - (dy01 * ctmp4 + (col0[2] << 7))) / tmp; \
-                       deltarx = ((ax << 16) & 0xFFFF0000) | (rx & 0xFFFF); \
-                       deltgbx = ((gx << 16) & 0xFFFF0000) | (bx & 0xFFFF); \
-               } else { \
-                       deltgbx = deltarx = 0; \
-               } \
-       } while (0)
-
-#define SET_XY() \
-       do { \
-               delt02 = dx02 / dy02; \
-               if (dy12) delt12 = dx12 / dy12; \
-               if (dy01) delt01 = dx01 / dy01; \
-               start02 = (ydiff * delt02) + x0; \
-               end01 = (ydiff * delt01) + x0; \
-               end12 = ((y1 - (GLfloat)iy1) * delt12) + x1; \
-       } while (0)
-
-#define SET_DIR() \
-       do { \
-               tmp = x1 - (dy01 * delt02 + x0); \
-               if (tmp > 0) { \
-                       lr = 0x80000000; \
-               } else { \
-                       tmp *= -1; \
-                       lr = 0; \
-               } \
-               tmp >>= 20; \
-       } while (0)
-
-#define SET_Z() \
-       do { \
-               deltzy = (z2 - z0) / dy02; \
-               if (tmp) { \
-                       deltzx = (z1 - (dy01 * deltzy + z0)) / tmp; \
-               } else { deltzx = 0; } \
-               zstart = (deltzy * ydiff) + z0; \
-       } while (0)
-
-#define SET_BASEUV() \
-       do { \
-               if (u0 < u1) { \
-                       if (u0 < u2) { \
-                               baseu = u0; \
-                       } else { \
-                               baseu = u2; \
-                       } \
-               } else { \
-                       if (u1 < u2) { \
-                               baseu = u1; \
-                       } else { \
-                               baseu = u2; \
-                       } \
-               } \
-               if (v0 < v1) { \
-                       if (v0 < v2) { \
-                               basev = v0; \
-                       } else { \
-                               basev = v2; \
-                       } \
-               } else { \
-                       if (v1 < v2) { \
-                               basev = v1; \
-                       } else { \
-                               basev = v2; \
-                       } \
-               } \
-       } while (0)
-
-#define SET_RW() \
-       do { \
-               /* GLfloat minW; \
-               if (w0 < w1) { \
-                       if (w0 < w2) { \
-                               minW = w0; \
-                       } else { \
-                               minW = w2; \
-                       } \
-               } else { \
-                       if (w1 < w2) { \
-                               minW = w1; \
-                       } else { \
-                               minW = w2; \
-                       } \
-               } */ \
-               rw0 = (512.0 * w0); \
-               rw1 = (512.0 * w1); \
-               rw2 = (512.0 * w2); \
-       } while (0)
-
-
-#define SET_D() \
-       do { \
-               GLfloat sxy, suv; \
-               int lev; \
-               suv = (VB->TexCoordPtr[0]->data[vert0][0] - \
-                      VB->TexCoordPtr[0]->data[vert2][0]) * \
-                     (VB->TexCoordPtr[0]->data[vert1][1] - \
-                      VB->TexCoordPtr[0]->data[vert2][1]) - \
-                     (VB->TexCoordPtr[0]->data[vert1][0] - \
-                      VB->TexCoordPtr[0]->data[vert2][0]) * \
-                     (VB->TexCoordPtr[0]->data[vert0][1] - \
-                      VB->TexCoordPtr[0]->data[vert2][2]); \
-               sxy = (VB->Win.data[vert0][0] - \
-                      VB->Win.data[vert2][0]) * \
-                     (VB->Win.data[vert1][1] - \
-                      VB->Win.data[vert2][1]) - \
-                     (VB->Win.data[vert1][0] - \
-                      VB->Win.data[vert2][0]) * \
-                     (VB->Win.data[vert0][1] - \
-                      VB->Win.data[vert2][2]); \
-               if (sxy < 0) sxy *= -1.0; \
-               if (suv < 0) suv *= -1.0; \
-               lev = *(int*)&suv - *(int *)&sxy; \
-               if (lev < 0) \
-                       lev = 0; \
-               else \
-                       lev >>=23; \
-               dstart = (lev << 27); \
-       } while (0)
-               
-
-
-#define SET_UVWD() \
-       do { \
-               SET_BASEUV(); \
-               SET_RW(); \
-               SET_D(); \
-               ru0 = (((u0 - baseu) * rw0)); \
-               ru1 = (((u1 - baseu) * rw1)); \
-               ru2 = (((u2 - baseu) * rw2)); \
-               rv0 = (((v0 - basev) * rw0)); \
-               rv1 = (((v1 - basev) * rw1)); \
-               rv2 = (((v2 - basev) * rw2)); \
-               while (baseu < 0) { baseu += (t->tObj->Image[0]->Width << 8); } \
-               while (basev < 0) { basev += (t->tObj->Image[0]->Height << 8); } \
-               if (!(baseu & 0xFF)) { baseu = (baseu >> 8); } else { baseu = (baseu >> 8) + 1; } \
-               if ((basev & 0x80) || !(basev & 0xFF)) { basev = (basev >> 8); } else { basev = (basev >> 8) - 1; } \
-               rbaseu = (baseu) << (16 - t->widthLog2); \
-               rbasev = (basev) << (16 - t->widthLog2); \
-               deltuy = (((ru2 - ru0) / dy02)); \
-               deltvy = (((rv2 - rv0) / dy02)); \
-               rw0 *= (1024.0 * 512.0); \
-               rw1 *= (1024.0 * 512.0); \
-               rw2 *= (1024.0 * 512.0); \
-               deltwy = ((rw2 - rw0) / dy02); \
-               if (tmp) { \
-                       deltux = ((ru1 - (dy01 * deltuy + ru0)) / tmp); \
-                       deltvx = ((rv1 - (dy01 * deltvy + rv0)) / tmp); \
-                       deltwx = ((rw1 - (dy01 * deltwy + rw0)) / tmp); \
-               } else { deltux = deltvx = deltwx = 0; } \
-               ustart = (deltuy * ydiff) + (ru0); \
-               vstart = (deltvy * ydiff) + (rv0); \
-               wstart = (deltwy * ydiff) + (rw0); \
-       } while (0)
-
-
-#define SEND_COLORS() \
-       do { \
-               WAITFIFOEMPTY(6); \
-               OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_GBX), deltgbx); \
-               OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_ARX), deltarx); \
-               OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_GBY), deltgby); \
-               OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_ARY), deltary); \
-               OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_GS_BS), gbstart); \
-               OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_AS_RS), arstart); \
-       } while (0)
-
-#define SEND_VERTICES() \
-       do { \
-               WAITFIFOEMPTY(6); \
-               OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_ZSTART), zstart); \
-               OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_ZXD), deltzx); \
-               OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_ZYD), deltzy); \
-               OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_TXDELTA12), delt12); \
-               OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_TXEND12), end12); \
-               OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_TXDELTA01), delt01); \
-               WAITFIFOEMPTY(5); \
-               OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_TXEND01), end01); \
-               OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_TXDELTA02), delt02); \
-               OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_TXSTART02), start02); \
-               OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_TYS), iy0); \
-               OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_TY01_Y12), \
-                               ((((iy0 - iy1) & 0x7FF) << 16) | \
-                               ((iy1 - iy2) & 0x7FF) | lr)); \
-       } while (0)
-
-#define SEND_UVWD() \
-       do { \
-               WAITFIFOEMPTY(7); \
-               OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_BASEV), (rbasev & 0xFFFF)); \
-               OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_BASEU), (0xa0000000 | (rbaseu & 0xFFFF))); \
-               OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_WXD), deltwx); \
-               OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_WYD), deltwy); \
-               OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_WSTART), wstart); \
-               OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_DXD), deltdx); \
-               OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_VXD), deltvx); \
-               WAITFIFOEMPTY(7); \
-               OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_UXD), deltux); \
-               OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_DYD), deltdy); \
-               OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_VYD), deltvy); \
-               OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_UYD), deltuy); \
-               OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_DSTART), dstart); \
-               OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_VSTART), vstart); \
-               OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_USTART), ustart); \
-       } while (0)
-
-#define DMA_SEND_UVWD() \
-       do { \
-               DMAOUT((rbasev & 0xFFFF)); \
-               DMAOUT((0xa0000000 | (rbaseu & 0xFFFF))); \
-               DMAOUT(deltwx); \
-               DMAOUT(deltwy); \
-               DMAOUT(wstart); \
-               DMAOUT(deltdx); \
-               DMAOUT(deltvx); \
-               DMAOUT(deltux); \
-               DMAOUT(deltdy); \
-               DMAOUT(deltvy); \
-               DMAOUT(deltuy); \
-               DMAOUT(dstart); \
-               DMAOUT(vstart); \
-               DMAOUT(ustart); \
-       } while (0)
-
-
-#define DMA_SEND_COLORS() \
-       do { \
-               DMAOUT(deltgbx); \
-               DMAOUT(deltarx); \
-               DMAOUT(deltgby); \
-               DMAOUT(deltary); \
-               DMAOUT(gbstart); \
-               DMAOUT(arstart); \
-       } while (0)
-
-#define DMA_SEND_VERTICES() \
-       do { \
-               DMAOUT(deltzx); \
-               DMAOUT(deltzy); \
-               DMAOUT(zstart); \
-               DMAOUT(delt12); \
-               DMAOUT(end12); \
-               DMAOUT(delt01); \
-               DMAOUT(end01); \
-               DMAOUT(delt02); \
-               DMAOUT(start02); \
-               DMAOUT(iy0); \
-               DMAOUT(((((iy0 - iy1) & 0x7FF) << 16) | \
-                       ((iy1 - iy2) & 0x7FF) | lr)); \
-       } while (0)
-
index 018482f66beb35969a311da7829600de67296408..2e5c40802c150329952b24a7443872b7b67b26d7 100644 (file)
@@ -27,4 +27,3 @@ ASM_SOURCES =
 
 include ../Makefile.template
 
-symlinks:
index abb8440fc4cce3425865ec19108953d9dd842598..bfd3077d70cb8723255d268f50d3aa7688357ab2 100644 (file)
@@ -66,7 +66,7 @@ typedef struct {
    unsigned int logTextureGranularity[SAVAGE_NR_TEX_HEAPS];
    drmAddress texVirtual[SAVAGE_NR_TEX_HEAPS];
   
-   __DRIscreenPrivate *driScrnPriv;
+   __DRIscreen *driScrnPriv;
 
    savageRegion aperture;
    savageRegion agpTextures;
index 931ceff0a81c65f002eec8a2d9bc8fd2b1bb0f4f..8e879ca41c0c263ac1c2b37d49dc4d6127bcc3f6 100644 (file)
@@ -59,7 +59,7 @@
 #include "texmem.h"
 
 #define need_GL_EXT_secondary_color
-#include "extension_helper.h"
+#include "main/remap_helper.h"
 
 #include "xmlpool.h"
 
@@ -168,7 +168,7 @@ PUBLIC const __DRIextension *savageScreenExtensions[] = {
 };
 
 static GLboolean
-savageInitDriver(__DRIscreenPrivate *sPriv)
+savageInitDriver(__DRIscreen *sPriv)
 {
   savageScreenPrivate *savageScreen;
   SAVAGEDRIPtr         gDRIPriv = (SAVAGEDRIPtr)sPriv->pDevPriv;
@@ -272,7 +272,7 @@ savageInitDriver(__DRIscreenPrivate *sPriv)
 /* Accessed by dlsym from dri_mesa_init.c
  */
 static void
-savageDestroyScreen(__DRIscreenPrivate *sPriv)
+savageDestroyScreen(__DRIscreen *sPriv)
 {
    savageScreenPrivate *savageScreen = (savageScreenPrivate *)sPriv->private;
 
@@ -288,12 +288,12 @@ savageDestroyScreen(__DRIscreenPrivate *sPriv)
 
 static GLboolean
 savageCreateContext( const __GLcontextModes *mesaVis,
-                    __DRIcontextPrivate *driContextPriv,
+                    __DRIcontext *driContextPriv,
                     void *sharedContextPrivate )
 {
    GLcontext *ctx, *shareCtx;
    savageContextPtr imesa;
-   __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+   __DRIscreen *sPriv = driContextPriv->driScreenPriv;
    struct dd_function_table functions;
    savageScreenPrivate *savageScreen = (savageScreenPrivate *)sPriv->private;
    drm_savage_sarea_t *saPriv=(drm_savage_sarea_t *)(((char*)sPriv->pSAREA)+
@@ -436,7 +436,7 @@ savageCreateContext( const __GLcontextModes *mesaVis,
    if (ctx->Const.MaxTextureLevels <= 6) { /*spec requires at least 64x64*/
        __driUtilMessage("Not enough texture memory. "
                        "Falling back to indirect rendering.");
-       Xfree(imesa);
+       _mesa_free(imesa);
        return GL_FALSE;
    }
 
@@ -546,7 +546,7 @@ savageCreateContext( const __GLcontextModes *mesaVis,
 }
 
 static void
-savageDestroyContext(__DRIcontextPrivate *driContextPriv)
+savageDestroyContext(__DRIcontext *driContextPriv)
 {
    savageContextPtr imesa = (savageContextPtr) driContextPriv->driverPrivate;
    GLuint i;
@@ -574,14 +574,14 @@ savageDestroyContext(__DRIcontextPrivate *driContextPriv)
       _mesa_destroy_context(imesa->glCtx);
 
       /* no longer use vertex_dma_buf*/
-      Xfree(imesa);
+      _mesa_free(imesa);
    }
 }
 
 
 static GLboolean
-savageCreateBuffer( __DRIscreenPrivate *driScrnPriv,
-                   __DRIdrawablePrivate *driDrawPriv,
+savageCreateBuffer( __DRIscreen *driScrnPriv,
+                   __DRIdrawable *driDrawPriv,
                    const __GLcontextModes *mesaVis,
                    GLboolean isPixmap)
 {
@@ -602,7 +602,7 @@ savageCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       {
          driRenderbuffer *frontRb
-            = driNewRenderbuffer(GL_RGBA,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888,
                                  (GLubyte *) screen->aperture.map
                                  + 0x01000000 * TARGET_FRONT,
                                  screen->cpp,
@@ -615,7 +615,7 @@ savageCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->doubleBufferMode) {
          driRenderbuffer *backRb
-            = driNewRenderbuffer(GL_RGBA,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888,
                                  (GLubyte *) screen->aperture.map
                                  + 0x01000000 * TARGET_BACK,
                                  screen->cpp,
@@ -628,7 +628,7 @@ savageCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->depthBits == 16) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT16,
+            = driNewRenderbuffer(MESA_FORMAT_Z16,
                                  (GLubyte *) screen->aperture.map
                                  + 0x01000000 * TARGET_DEPTH,
                                  screen->zpp,
@@ -639,7 +639,7 @@ savageCreateBuffer( __DRIscreenPrivate *driScrnPriv,
       }
       else if (mesaVis->depthBits == 24) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT24,
+            = driNewRenderbuffer(MESA_FORMAT_S8_Z24,
                                  (GLubyte *) screen->aperture.map
                                  + 0x01000000 * TARGET_DEPTH,
                                  screen->zpp,
@@ -651,7 +651,7 @@ savageCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->stencilBits > 0 && !swStencil) {
          driRenderbuffer *stencilRb
-            = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT,
+            = driNewRenderbuffer(MESA_FORMAT_S8,
                                  (GLubyte *) screen->aperture.map
                                  + 0x01000000 * TARGET_DEPTH,
                                  screen->zpp,
@@ -675,13 +675,13 @@ savageCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 }
 
 static void
-savageDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+savageDestroyBuffer(__DRIdrawable *driDrawPriv)
 {
    _mesa_reference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)), NULL);
 }
 
 #if 0
-void XMesaSwapBuffers(__DRIdrawablePrivate *driDrawPriv)
+void XMesaSwapBuffers(__DRIdrawable *driDrawPriv)
 {
    /* XXX should do swap according to the buffer, not the context! */
    savageContextPtr imesa = savageCtx; 
@@ -694,7 +694,7 @@ void XMesaSwapBuffers(__DRIdrawablePrivate *driDrawPriv)
 
 void savageXMesaSetClipRects(savageContextPtr imesa)
 {
-   __DRIdrawablePrivate *dPriv = imesa->driDrawable;
+   __DRIdrawable *dPriv = imesa->driDrawable;
 
    if ((dPriv->numBackClipRects == 0)
        || (imesa->glCtx->DrawBuffer->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT)) {
@@ -715,8 +715,8 @@ void savageXMesaSetClipRects(savageContextPtr imesa)
 
 static void savageXMesaWindowMoved( savageContextPtr imesa ) 
 {
-   __DRIdrawablePrivate *const drawable = imesa->driDrawable;
-   __DRIdrawablePrivate *const readable = imesa->driReadable;
+   __DRIdrawable *const drawable = imesa->driDrawable;
+   __DRIdrawable *const readable = imesa->driReadable;
 
    if (0)
       fprintf(stderr, "savageXMesaWindowMoved\n\n");
@@ -731,7 +731,7 @@ static void savageXMesaWindowMoved( savageContextPtr imesa )
 
 
 static GLboolean
-savageUnbindContext(__DRIcontextPrivate *driContextPriv)
+savageUnbindContext(__DRIcontext *driContextPriv)
 {
    savageContextPtr savage = (savageContextPtr) driContextPriv->driverPrivate;
    if (savage)
@@ -742,7 +742,7 @@ savageUnbindContext(__DRIcontextPrivate *driContextPriv)
 
 #if 0
 static GLboolean
-savageOpenFullScreen(__DRIcontextPrivate *driContextPriv)
+savageOpenFullScreen(__DRIcontext *driContextPriv)
 {
     
   
@@ -761,7 +761,7 @@ savageOpenFullScreen(__DRIcontextPrivate *driContextPriv)
 }
 
 static GLboolean
-savageCloseFullScreen(__DRIcontextPrivate *driContextPriv)
+savageCloseFullScreen(__DRIcontext *driContextPriv)
 {
     
     if (driContextPriv) {
@@ -777,9 +777,9 @@ savageCloseFullScreen(__DRIcontextPrivate *driContextPriv)
 #endif
 
 static GLboolean
-savageMakeCurrent(__DRIcontextPrivate *driContextPriv,
-                 __DRIdrawablePrivate *driDrawPriv,
-                 __DRIdrawablePrivate *driReadPriv)
+savageMakeCurrent(__DRIcontext *driContextPriv,
+                 __DRIdrawable *driDrawPriv,
+                 __DRIdrawable *driReadPriv)
 {
    if (driContextPriv) {
       savageContextPtr imesa
@@ -816,9 +816,9 @@ savageMakeCurrent(__DRIcontextPrivate *driContextPriv,
 
 void savageGetLock( savageContextPtr imesa, GLuint flags ) 
 {
-   __DRIdrawablePrivate *const drawable = imesa->driDrawable;
-   __DRIdrawablePrivate *const readable = imesa->driReadable;
-   __DRIscreenPrivate *sPriv = imesa->driScreen;
+   __DRIdrawable *const drawable = imesa->driDrawable;
+   __DRIdrawable *const readable = imesa->driReadable;
+   __DRIscreen *sPriv = imesa->driScreen;
    drm_savage_sarea_t *sarea = imesa->sarea;
    int me = imesa->hHWContext;
    int stamp = drawable->lastStamp; 
@@ -883,7 +883,7 @@ void savageGetLock( savageContextPtr imesa, GLuint flags )
 }
 
 static const  __DRIconfig **
-savageFillInModes( __DRIscreenPrivate *psp,
+savageFillInModes( __DRIscreen *psp,
                   unsigned pixel_bits, unsigned depth_bits,
                   unsigned stencil_bits, GLboolean have_back_buffer )
 {
@@ -967,7 +967,7 @@ savageFillInModes( __DRIscreenPrivate *psp,
  * \return the __GLcontextModes supported by this driver
  */
 static const __DRIconfig **
-savageInitScreen(__DRIscreenPrivate *psp)
+savageInitScreen(__DRIscreen *psp)
 {
    static const __DRIversion ddx_expected = { 2, 0, 0 };
    static const __DRIversion dri_expected = { 4, 0, 0 };
@@ -980,18 +980,6 @@ savageInitScreen(__DRIscreenPrivate *psp)
                                      &psp->drm_version, & drm_expected ) )
       return NULL;
 
-   /* Calling driInitExtensions here, with a NULL context pointer,
-    * does not actually enable the extensions.  It just makes sure
-    * that all the dispatch offsets for all the extensions that
-    * *might* be enables are known.  This is needed because the
-    * dispatch offsets need to be known when _mesa_context_create is
-    * called, but we can't enable the extensions until we have a
-    * context pointer.
-    *
-    * Hello chicken.  Hello egg.  How are you two today?
-    */
-   driInitExtensions( NULL, card_extensions, GL_FALSE );
-
    if (!savageInitDriver(psp))
        return NULL;
 
@@ -1013,3 +1001,10 @@ const struct __DriverAPIRec driDriverAPI = {
    savageMakeCurrent,
    savageUnbindContext
 };
+
+/* This is the table of extensions that the loader will dlsym() for. */
+PUBLIC const __DRIextension *__driDriverExtensions[] = {
+    &driCoreExtension.base,
+    &driLegacyExtension.base,
+    NULL
+};
index 53a37db1cbcc2e9f514da736fd0f2fbdda3b2489..ba1e6e1e1addde7eac8daecfdd58e67e5789b949 100644 (file)
@@ -271,10 +271,10 @@ struct savage_context_t {
     drm_hw_lock_t *driHwLock;
     GLuint driFd;
 
-    __DRIdrawablePrivate *driDrawable;
-    __DRIdrawablePrivate *driReadable;
+    __DRIdrawable *driDrawable;
+    __DRIdrawable *driReadable;
 
-    __DRIscreenPrivate *driScreen;
+    __DRIscreen *driScreen;
     savageScreenPrivate *savageScreen; 
     drm_savage_sarea_t *sarea;
 
index 948ed18419e457ed6a38877174de210001bf124a..d0b64e801a973795ce3f989418f482b856b81234 100644 (file)
@@ -337,6 +337,8 @@ static void savageDDClear( GLcontext *ctx, GLbitfield mask )
    GLint ch = ctx->DrawBuffer->_Ymax - cy;
 
    /* XXX FIX ME: the cx,cy,cw,ch vars are currently ignored! */
+   (void) ch;
+   (void) cw;
 
    if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG)
        fprintf (stderr, "%s\n", __FUNCTION__);
@@ -358,15 +360,15 @@ static void savageDDClear( GLcontext *ctx, GLbitfield mask )
    depthMask = 0;
    switch (imesa->savageScreen->cpp) {
    case 2:
-       colorMask = PACK_COLOR_565(ctx->Color.ColorMask[0],
-                                 ctx->Color.ColorMask[1],
-                                 ctx->Color.ColorMask[2]);
+       colorMask = PACK_COLOR_565(ctx->Color.ColorMask[0][0],
+                                 ctx->Color.ColorMask[0][1],
+                                 ctx->Color.ColorMask[0][2]);
        break;
    case 4:
-       colorMask = PACK_COLOR_8888(ctx->Color.ColorMask[3],
-                                  ctx->Color.ColorMask[2],
-                                  ctx->Color.ColorMask[1],
-                                  ctx->Color.ColorMask[0]);
+       colorMask = PACK_COLOR_8888(ctx->Color.ColorMask[0][3],
+                                  ctx->Color.ColorMask[0][2],
+                                  ctx->Color.ColorMask[0][1],
+                                  ctx->Color.ColorMask[0][0]);
        break;
    }
 
@@ -431,7 +433,7 @@ static void savageDDClear( GLcontext *ctx, GLbitfield mask )
 /*
  * Copy the back buffer to the front buffer. 
  */
-void savageSwapBuffers( __DRIdrawablePrivate *dPriv )
+void savageSwapBuffers( __DRIdrawable *dPriv )
 {
    savageContextPtr imesa;
 
@@ -535,7 +537,7 @@ void savageFlushVertices( savageContextPtr imesa )
 
 void savageFlushCmdBufLocked( savageContextPtr imesa, GLboolean discard )
 {
-    __DRIdrawablePrivate *dPriv = imesa->driDrawable;
+    __DRIdrawable *dPriv = imesa->driDrawable;
 
     if (!imesa->dmaVtxBuf.total)
        discard = GL_FALSE;
index 639605cc5177ee7dc309257fd47161f7617dde67..e7e80816c10e8c3d499f19c04686f5f19f196b7c 100644 (file)
@@ -39,7 +39,7 @@ void savageFlushCmdBuf( savageContextPtr imesa, GLboolean discard );
 
 void savageDDInitIoctlFuncs( GLcontext *ctx );
 
-void savageSwapBuffers( __DRIdrawablePrivate *dPriv );
+void savageSwapBuffers( __DRIdrawable *dPriv );
 
 #define WAIT_IDLE_EMPTY(imesa) do { \
     if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG) \
index 32c74f9467e6d0994fcbf5483ad483b376dfbcbc..8221edf38727228bd1e7d95adf0405b2debf8b92 100644 (file)
@@ -252,13 +252,13 @@ static GLboolean run_texnorm_stage( GLcontext *ctx,
          const GLboolean normalizeS = (texObj->WrapS == GL_REPEAT);
          const GLboolean normalizeT = (reallyEnabled & TEXTURE_2D_BIT) &&
             (texObj->WrapT == GL_REPEAT);
-         const GLfloat *in = (GLfloat *)VB->TexCoordPtr[i]->data;
-         const GLint instride = VB->TexCoordPtr[i]->stride;
+         const GLfloat *in = (GLfloat *)VB->AttribPtr[_TNL_ATTRIB_TEX0 + i]->data;
+         const GLint instride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + i]->stride;
          GLfloat (*out)[4] = store->texcoord[i].data;
          GLint j;
 
          if (!ctx->Texture.Unit[i]._ReallyEnabled ||
-             VB->TexCoordPtr[i]->size == 4)
+             VB->AttribPtr[_TNL_ATTRIB_TEX0 + i]->size == 4)
             /* Never try to normalize homogenous tex coords! */
             continue;
 
@@ -297,7 +297,7 @@ static GLboolean run_texnorm_stage( GLcontext *ctx,
          }
 
          if (normalizeS || normalizeT)
-            VB->AttribPtr[VERT_ATTRIB_TEX0+i] = VB->TexCoordPtr[i] = &store->texcoord[i];
+            VB->AttribPtr[_TNL_ATTRIB_TEX0 + i] = &store->texcoord[i];
       }
    }
 
index 9615e34013ce8ac6553832ffd7dd09efead26f11..792e166d9c73b7794d0847a522358eca5dd813cb 100644 (file)
@@ -34,7 +34,7 @@
 
 #define LOCAL_VARS                                             \
    driRenderbuffer *drb = (driRenderbuffer *) rb;              \
-   __DRIdrawablePrivate *const dPriv = drb->dPriv;             \
+   __DRIdrawable *const dPriv = drb->dPriv;            \
    GLuint cpp   = drb->cpp;                                    \
    GLuint pitch = drb->pitch;                                  \
    GLuint height = dPriv->h;                                   \
@@ -44,7 +44,7 @@
 
 #define LOCAL_DEPTH_VARS                                       \
    driRenderbuffer *drb = (driRenderbuffer *) rb;              \
-   __DRIdrawablePrivate *const dPriv = drb->dPriv;             \
+   __DRIdrawable *const dPriv = drb->dPriv;            \
    GLuint zpp   = drb->cpp;                                    \
    GLuint pitch = drb->pitch;                                  \
    GLuint height = dPriv->h;                                   \
@@ -255,15 +255,13 @@ void
 savageSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis,
                        GLboolean float_depth)
 {
-   if (drb->Base.InternalFormat == GL_RGBA) {
-      if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
-         savageInitPointers_565(&drb->Base);
-      }
-      else {
-         savageInitPointers_8888(&drb->Base);
-      }
+   if (drb->Base.Format == MESA_FORMAT_RGB565) {
+      savageInitPointers_565(&drb->Base);
+   }
+   else if (drb->Base.Format == MESA_FORMAT_ARGB8888) {
+      savageInitPointers_8888(&drb->Base);
    }
-   else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+   else if (drb->Base.Format == MESA_FORMAT_Z16) {
       if (float_depth) {
          savageInitDepthPointers_z16f(&drb->Base);
       }
@@ -271,7 +269,7 @@ savageSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis,
          savageInitDepthPointers_z16(&drb->Base);
       }
    }
-   else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+   else if (drb->Base.Format == MESA_FORMAT_S8_Z24) {
       if (float_depth) {
          savageInitDepthPointers_s8_z24f(&drb->Base);
       }
@@ -279,7 +277,7 @@ savageSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis,
          savageInitDepthPointers_s8_z24(&drb->Base);
       }
    }
-   else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+   else if (drb->Base.Format == MESA_FORMAT_S8) {
       savageInitStencilPointers_s8_z24(&drb->Base);
    }
 }
index fe239e1b05fa0c48c072ce4b8b814a7dd3a54028..97598f599e56f79c478928aa76c2e804bd22c3ea 100644 (file)
  */
 
 
-#include <stdlib.h>
-#include <stdio.h>
-
-#include <GL/gl.h>
-
+#include "main/context.h"
 #include "main/mm.h"
-#include "savagecontext.h"
-#include "savagetex.h"
-#include "savagetris.h"
-#include "savageioctl.h"
-#include "main/simple_list.h"
-#include "main/enums.h"
-#include "savage_bci.h"
-
 #include "main/macros.h"
-#include "main/texformat.h"
 #include "main/texstore.h"
 #include "main/texobj.h"
 #include "main/convolve.h"
 #include "main/colormac.h"
+#include "main/simple_list.h"
+#include "main/enums.h"
 
 #include "swrast/swrast.h"
 
+#include "savagecontext.h"
+#include "savagetex.h"
+#include "savagetris.h"
+#include "savageioctl.h"
+#include "savage_bci.h"
+
 #include "xmlpool.h"
 
 #define TILE_INDEX_DXT1 0
@@ -512,7 +507,7 @@ savageAllocTexObj( struct gl_texture_object *texObj )
 
       savageSetTexWrapping(t,texObj->WrapS,texObj->WrapT);
       savageSetTexFilter(t,texObj->MinFilter,texObj->MagFilter);
-      savageSetTexBorderColor(t,texObj->BorderColor);
+      savageSetTexBorderColor(t,texObj->BorderColor.f);
    }
 
    return t;
@@ -527,6 +522,11 @@ savageAllocTexObj( struct gl_texture_object *texObj )
  * components to white. This way we get the correct result.
  */
 
+#if 0
+/* Using MESA_FORMAT_RGBA8888 to store alpha-only textures should
+ * work but is space inefficient.
+ */
+
 static GLboolean
 _savage_texstore_a1114444(TEXSTORE_PARAMS);
 
@@ -590,10 +590,11 @@ _savage_texstore_a1114444(TEXSTORE_PARAMS)
        return GL_FALSE;
     _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
     for (img = 0; img < srcDepth; img++) {
+        GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
         GLubyte *dstRow = (GLubyte *) dstAddr
-           + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+           + dstImageOffsets[dstZoffset + img] * texelBytes
            + dstYoffset * dstRowStride
-           + dstXoffset * dstFormat->TexelBytes;
+           + dstXoffset * texelBytes;
        for (row = 0; row < srcHeight; row++) {
             GLushort *dstUI = (GLushort *) dstRow;
            for (col = 0; col < srcWidth; col++) {
@@ -629,10 +630,11 @@ _savage_texstore_a1118888(TEXSTORE_PARAMS)
        return GL_FALSE;
     _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
     for (img = 0; img < srcDepth; img++) {
+        GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
         GLubyte *dstRow = (GLubyte *) dstAddr
-           + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+           + dstImageOffsets[dstZoffset + img] * texelBytes
            + dstYoffset * dstRowStride
-           + dstXoffset * dstFormat->TexelBytes;
+           + dstXoffset * texelBytes;
        for (row = 0; row < srcHeight; row++) {
             GLuint *dstUI = (GLuint *) dstRow;
            for (col = 0; col < srcWidth; col++) {
@@ -647,10 +649,11 @@ _savage_texstore_a1118888(TEXSTORE_PARAMS)
 
     return GL_TRUE;
 }
+#endif
 
 
 /* Called by the _mesa_store_teximage[123]d() functions. */
-static const struct gl_texture_format *
+static gl_format
 savageChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
                           GLenum format, GLenum type )
 {
@@ -669,15 +672,15 @@ savageChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
       switch ( type ) {
       case GL_UNSIGNED_INT_10_10_10_2:
       case GL_UNSIGNED_INT_2_10_10_10_REV:
-        return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb1555;
+        return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB1555;
       case GL_UNSIGNED_SHORT_4_4_4_4:
       case GL_UNSIGNED_SHORT_4_4_4_4_REV:
-        return &_mesa_texformat_argb4444;
+        return MESA_FORMAT_ARGB4444;
       case GL_UNSIGNED_SHORT_5_5_5_1:
       case GL_UNSIGNED_SHORT_1_5_5_5_REV:
-        return &_mesa_texformat_argb1555;
+        return MESA_FORMAT_ARGB1555;
       default:
-         return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+         return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444;
       }
 
    case 3:
@@ -686,129 +689,152 @@ savageChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
       switch ( type ) {
       case GL_UNSIGNED_SHORT_4_4_4_4:
       case GL_UNSIGNED_SHORT_4_4_4_4_REV:
-        return &_mesa_texformat_argb4444;
+        return MESA_FORMAT_ARGB4444;
       case GL_UNSIGNED_SHORT_5_5_5_1:
       case GL_UNSIGNED_SHORT_1_5_5_5_REV:
-        return &_mesa_texformat_argb1555;
+        return MESA_FORMAT_ARGB1555;
       case GL_UNSIGNED_SHORT_5_6_5:
       case GL_UNSIGNED_SHORT_5_6_5_REV:
-        return &_mesa_texformat_rgb565;
+        return MESA_FORMAT_RGB565;
       default:
-         return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
+         return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_RGB565;
       }
 
    case GL_RGBA8:
    case GL_RGBA12:
    case GL_RGBA16:
       return !force16bpt ?
-         &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+         MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444;
 
    case GL_RGB10_A2:
       return !force16bpt ?
-         &_mesa_texformat_argb8888 : &_mesa_texformat_argb1555;
+         MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB1555;
 
    case GL_RGBA4:
    case GL_RGBA2:
-      return &_mesa_texformat_argb4444;
+      return MESA_FORMAT_ARGB4444;
 
    case GL_RGB5_A1:
-      return &_mesa_texformat_argb1555;
+      return MESA_FORMAT_ARGB1555;
 
    case GL_RGB8:
    case GL_RGB10:
    case GL_RGB12:
    case GL_RGB16:
-      return !force16bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
+      return !force16bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_RGB565;
 
    case GL_RGB5:
    case GL_RGB4:
    case GL_R3_G3_B2:
-      return &_mesa_texformat_rgb565;
+      return MESA_FORMAT_RGB565;
 
    case GL_ALPHA:
    case GL_COMPRESSED_ALPHA:
-      return isSavage4 ? &_mesa_texformat_a8 : (
+#if 0
+      return isSavage4 ? MESA_FORMAT_a8 : (
         do32bpt ? &_savage_texformat_a1118888 : &_savage_texformat_a1114444);
+#else
+      if (isSavage4)
+         return MESA_FORMAT_A8;
+      else if (do32bpt)
+         return MESA_FORMAT_ARGB8888;
+      else
+         return MESA_FORMAT_ARGB4444;
+#endif
    case GL_ALPHA4:
-      return isSavage4 ? &_mesa_texformat_a8 : &_savage_texformat_a1114444;
+#if 0
+      return isSavage4 ? MESA_FORMAT_a8 : &_savage_texformat_a1114444;
+#else
+      if (isSavage4)
+         return MESA_FORMAT_A8;
+      else
+         return MESA_FORMAT_ARGB4444;
+#endif
    case GL_ALPHA8:
    case GL_ALPHA12:
    case GL_ALPHA16:
-      return isSavage4 ? &_mesa_texformat_a8 : (
+#if 0
+      return isSavage4 ? MESA_FORMAT_a8 : (
         !force16bpt ? &_savage_texformat_a1118888 : &_savage_texformat_a1114444);
-
+#else
+      if (isSavage4)
+         return MESA_FORMAT_A8;
+      else if (force16bpt)
+         return MESA_FORMAT_ARGB4444;
+      else
+         return MESA_FORMAT_ARGB8888;
+#endif
    case 1:
    case GL_LUMINANCE:
    case GL_COMPRESSED_LUMINANCE:
       /* no alpha, but use argb1555 in 16bit case to get pure grey values */
-      return isSavage4 ? &_mesa_texformat_l8 : (
-        do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb1555);
+      return isSavage4 ? MESA_FORMAT_L8 : (
+        do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB1555);
    case GL_LUMINANCE4:
-      return isSavage4 ? &_mesa_texformat_l8 : &_mesa_texformat_argb1555;
+      return isSavage4 ? MESA_FORMAT_L8 : MESA_FORMAT_ARGB1555;
    case GL_LUMINANCE8:
    case GL_LUMINANCE12:
    case GL_LUMINANCE16:
-      return isSavage4 ? &_mesa_texformat_l8 : (
-        !force16bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb1555);
+      return isSavage4 ? MESA_FORMAT_L8 : (
+        !force16bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB1555);
 
    case 2:
    case GL_LUMINANCE_ALPHA:
    case GL_COMPRESSED_LUMINANCE_ALPHA:
       /* Savage4 has a al44 texture format. But it's not supported by Mesa. */
-      return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+      return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444;
    case GL_LUMINANCE4_ALPHA4:
    case GL_LUMINANCE6_ALPHA2:
-      return &_mesa_texformat_argb4444;
+      return MESA_FORMAT_ARGB4444;
    case GL_LUMINANCE8_ALPHA8:
    case GL_LUMINANCE12_ALPHA4:
    case GL_LUMINANCE12_ALPHA12:
    case GL_LUMINANCE16_ALPHA16:
-      return !force16bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+      return !force16bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444;
 #if 0
    /* TFT_I8 produces garbage on ProSavageDDR and subsequent texture
     * disable keeps rendering garbage. Disabled for now. */
    case GL_INTENSITY:
    case GL_COMPRESSED_INTENSITY:
-      return isSavage4 ? &_mesa_texformat_i8 : (
-        do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444);
+      return isSavage4 ? MESA_FORMAT_i8 : (
+        do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444);
    case GL_INTENSITY4:
-      return isSavage4 ? &_mesa_texformat_i8 : &_mesa_texformat_argb4444;
+      return isSavage4 ? MESA_FORMAT_i8 : MESA_FORMAT_ARGB4444;
    case GL_INTENSITY8:
    case GL_INTENSITY12:
    case GL_INTENSITY16:
-      return isSavage4 ? &_mesa_texformat_i8 : (
-        !force16bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444);
+      return isSavage4 ? MESA_FORMAT_i8 : (
+        !force16bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444);
 #else
    case GL_INTENSITY:
    case GL_COMPRESSED_INTENSITY:
-      return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+      return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444;
    case GL_INTENSITY4:
-      return &_mesa_texformat_argb4444;
+      return MESA_FORMAT_ARGB4444;
    case GL_INTENSITY8:
    case GL_INTENSITY12:
    case GL_INTENSITY16:
-      return !force16bpt ? &_mesa_texformat_argb8888 :
-         &_mesa_texformat_argb4444;
+      return !force16bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444;
 #endif
 
    case GL_RGB_S3TC:
    case GL_RGB4_S3TC:
    case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
-      return &_mesa_texformat_rgb_dxt1;
+      return MESA_FORMAT_RGB_DXT1;
    case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
-      return &_mesa_texformat_rgba_dxt1;
+      return MESA_FORMAT_RGBA_DXT1;
 
    case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
-      return &_mesa_texformat_rgba_dxt3;
+      return MESA_FORMAT_RGBA_DXT3;
 
    case GL_RGBA_S3TC:
    case GL_RGBA4_S3TC:
       if (!isSavage4)
         /* Not the best choice but Savage3D/MX/IX don't support DXT3 or DXT5. */
-        return &_mesa_texformat_rgba_dxt1;
+        return MESA_FORMAT_RGBA_DXT1;
       /* fall through */
    case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
-      return &_mesa_texformat_rgba_dxt5;
+      return MESA_FORMAT_RGBA_DXT5;
 
 /*
    case GL_COLOR_INDEX:
@@ -822,7 +848,7 @@ savageChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
 */
    default:
       _mesa_problem(ctx, "unexpected texture format in %s", __FUNCTION__);
-      return NULL;
+      return MESA_FORMAT_NONE;
    }
 }
 
@@ -837,7 +863,7 @@ static void savageSetTexImages( savageContextPtr imesa,
    assert(t);
    assert(image);
 
-   switch (image->TexFormat->MesaFormat) {
+   switch (image->TexFormat) {
    case MESA_FORMAT_ARGB8888:
       textureFormat = TFT_ARGB8888;
       t->texelBytes = tileIndex = 4;
@@ -2018,7 +2044,7 @@ static void savageTexParameter( GLcontext *ctx, GLenum target,
       break;
   
    case GL_TEXTURE_BORDER_COLOR:
-      savageSetTexBorderColor(t,tObj->BorderColor);
+      savageSetTexBorderColor(t,tObj->BorderColor.f);
       break;
 
    default:
@@ -2083,6 +2109,7 @@ void savageDDInitTextureFuncs( struct dd_function_table *functions )
 
    /* Texel fetching with our custom texture formats works just like
     * the standard argb formats. */
+#if 0
    _savage_texformat_a1114444.FetchTexel1D = _mesa_texformat_argb4444.FetchTexel1D;
    _savage_texformat_a1114444.FetchTexel2D = _mesa_texformat_argb4444.FetchTexel2D;
    _savage_texformat_a1114444.FetchTexel3D = _mesa_texformat_argb4444.FetchTexel3D;
@@ -2096,4 +2123,5 @@ void savageDDInitTextureFuncs( struct dd_function_table *functions )
    _savage_texformat_a1118888.FetchTexel1Df= _mesa_texformat_argb8888.FetchTexel1Df;
    _savage_texformat_a1118888.FetchTexel2Df= _mesa_texformat_argb8888.FetchTexel2Df;
    _savage_texformat_a1118888.FetchTexel3Df= _mesa_texformat_argb8888.FetchTexel3Df;
+#endif
 }
index c04763b40e1c0383f3a54821b9c7367ab0ecc90f..9a92541ef7ed60a1180c248db5c87a09452d3022 100644 (file)
@@ -435,7 +435,8 @@ do {                                                                \
 
 #define LOCAL_VARS(n)                                          \
    savageContextPtr imesa = SAVAGE_CONTEXT(ctx);               \
-   GLuint color[n], spec[n];                                   \
+   GLuint color[n] = { 0 };                                    \
+   GLuint spec[n] = { 0 };                                     \
    GLuint coloroffset =                                                \
       ((imesa->skip & SAVAGE_SKIP_W) ? 3 : 4);                 \
    GLboolean specoffset =                                      \
@@ -879,13 +880,13 @@ static GLboolean savageCheckPTexHack( GLcontext *ctx )
 
    RENDERINPUTS_COPY( index_bitset, tnl->render_inputs_bitset );
 
-   if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX0 ) && VB->TexCoordPtr[0]->size == 4) {
+   if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX0 ) && VB->AttribPtr[_TNL_ATTRIB_TEX0]->size == 4) {
       if (!RENDERINPUTS_TEST_RANGE( index_bitset, _TNL_ATTRIB_TEX1, _TNL_LAST_TEX ))
         return GL_TRUE; /* apply ptex hack */
       else
         FALLBACK(ctx, SAVAGE_FALLBACK_PROJ_TEXTURE, GL_TRUE);
    }
-   if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX1 ) && VB->TexCoordPtr[1]->size == 4)
+   if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX1 ) && VB->AttribPtr[_TNL_ATTRIB_TEX1]->size == 4)
       FALLBACK(ctx, SAVAGE_FALLBACK_PROJ_TEXTURE, GL_TRUE);
 
    return GL_FALSE; /* don't apply ptex hack */
@@ -976,13 +977,13 @@ static INLINE GLuint savageChooseVertexFormat_s3d( GLcontext *ctx )
    if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX0 )) {
       if (imesa->ptexHack)
         EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_3F_XYW, SAVAGE_EMIT_STQ0, SAVAGE_SKIP_ST0);
-      else if (VB->TexCoordPtr[0]->size == 4)
+      else if (VB->AttribPtr[_TNL_ATTRIB_TEX0]->size == 4)
         assert (0); /* should be caught by savageCheckPTexHack */
-      else if (VB->TexCoordPtr[0]->size >= 2)
+      else if (VB->AttribPtr[_TNL_ATTRIB_TEX0]->size >= 2)
         /* The chromium menu emits some 3D tex coords even though no
          * 3D texture is enabled. Ignore the 3rd coordinate. */
         EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_2F, SAVAGE_EMIT_ST0, SAVAGE_SKIP_ST0 );
-      else if (VB->TexCoordPtr[0]->size == 1) {
+      else if (VB->AttribPtr[_TNL_ATTRIB_TEX0]->size == 1) {
         EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_1F, SAVAGE_EMIT_S0, SAVAGE_SKIP_S0 );
         EMIT_PAD( 4 );
       } else
@@ -1025,9 +1026,9 @@ static INLINE GLuint savageChooseVertexFormat_s4( GLcontext *ctx )
    if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX0 )) {
       if (imesa->ptexHack)
         NEED_ATTR( SAVAGE_EMIT_STQ0, SAVAGE_SKIP_ST0);
-      else if (VB->TexCoordPtr[0]->size == 4)
+      else if (VB->AttribPtr[_TNL_ATTRIB_TEX0]->size == 4)
         assert (0); /* should be caught by savageCheckPTexHack */
-      else if (VB->TexCoordPtr[0]->size >= 2)
+      else if (VB->AttribPtr[_TNL_ATTRIB_TEX0]->size >= 2)
         /* The chromium menu emits some 3D tex coords even though no
          * 3D texture is enabled. Ignore the 3rd coordinate. */
         NEED_ATTR( SAVAGE_EMIT_ST0, SAVAGE_SKIP_ST0 );
@@ -1035,10 +1036,10 @@ static INLINE GLuint savageChooseVertexFormat_s4( GLcontext *ctx )
         NEED_ATTR( SAVAGE_EMIT_S0, SAVAGE_SKIP_S0 );
    }
    if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX1 )) {
-      if (VB->TexCoordPtr[1]->size == 4)
+      if (VB->AttribPtr[_TNL_ATTRIB_TEX1]->size == 4)
         /* projective textures are not supported by the hardware */
         assert (0); /* should be caught by savageCheckPTexHack */
-      else if (VB->TexCoordPtr[1]->size >= 2)
+      else if (VB->AttribPtr[_TNL_ATTRIB_TEX1]->size >= 2)
         NEED_ATTR( SAVAGE_EMIT_ST1, SAVAGE_SKIP_ST1 );
       else
         NEED_ATTR( SAVAGE_EMIT_S1, SAVAGE_SKIP_S1 );
index d2354e6776441f40c803893050c6d65c51bcfbb9..ad009fc2398e3c11c3caa086fc258169f75e62d2 100644 (file)
@@ -34,4 +34,3 @@ ASM_SOURCES =
 
 include ../Makefile.template
 
-symlinks:
index 323383da62a9d011c7d15453ba4c15a1173c427c..d358ef62dc7ccb39bb3bc0f1fea9db9ed23995f1 100644 (file)
@@ -393,7 +393,6 @@ sis_clear_z_stencil_buffer( GLcontext * ctx, GLbitfield mask,
                            GLint x, GLint y, GLint width, GLint height )
 {
    sisContextPtr smesa = SIS_CONTEXT(ctx);
-   int cmd;
 
    mWait3DCmdQueue (8);
    MMIO(REG_SRC_PITCH, (smesa->zFormat == SiS_ZFORMAT_Z16) ?
index a070fe3d79f47016e0be64ba62d137979dec3277..0944f4d8b4e243f3cc5425b99b0c5539c53c8acb 100644 (file)
@@ -59,7 +59,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #define need_GL_EXT_fog_coord
 #define need_GL_EXT_secondary_color
-#include "extension_helper.h"
+#include "main/remap_helper.h"
 
 #ifndef SIS_DEBUG
 int SIS_DEBUG = 0;
@@ -69,7 +69,7 @@ int GlobalCurrentHwcx = -1;
 int GlobalHwcxCountBase = 1;
 int GlobalCmdQueueLen = 0;
 
-struct dri_extension card_extensions[] =
+static struct dri_extension card_extensions[] =
 {
     { "GL_ARB_multitexture",               NULL },
     { "GL_ARB_texture_border_clamp",       NULL },
@@ -83,13 +83,15 @@ struct dri_extension card_extensions[] =
     { NULL,                                NULL }
 };
 
-struct dri_extension card_extensions_6326[] =
+#if 0
+static struct dri_extension card_extensions_6326[] =
 {
     /*{ "GL_ARB_texture_border_clamp",       NULL },*/
     /*{ "GL_ARB_texture_mirrored_repeat",    NULL },*/
     /*{ "GL_MESA_ycbcr_texture",             NULL },*/
     { NULL,                                NULL }
 };
+#endif
 
 static const struct dri_debug_control debug_control[] =
 {
@@ -160,11 +162,11 @@ void sisReAllocateBuffers(GLcontext *ctx, GLframebuffer *drawbuffer,
 
 GLboolean
 sisCreateContext( const __GLcontextModes *glVisual,
-                 __DRIcontextPrivate *driContextPriv,
+                 __DRIcontext *driContextPriv,
                   void *sharedContextPrivate )
 {
    GLcontext *ctx, *shareCtx;
-   __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+   __DRIscreen *sPriv = driContextPriv->driScreenPriv;
    sisContextPtr smesa;
    sisScreenPtr sisScreen;
    int i;
@@ -337,7 +339,7 @@ sisCreateContext( const __GLcontextModes *glVisual,
 }
 
 void
-sisDestroyContext ( __DRIcontextPrivate *driContextPriv )
+sisDestroyContext ( __DRIcontext *driContextPriv )
 {
    sisContextPtr smesa = (sisContextPtr)driContextPriv->driverPrivate;
 
@@ -365,9 +367,9 @@ sisDestroyContext ( __DRIcontextPrivate *driContextPriv )
 }
 
 GLboolean
-sisMakeCurrent( __DRIcontextPrivate *driContextPriv,
-                __DRIdrawablePrivate *driDrawPriv,
-                __DRIdrawablePrivate *driReadPriv )
+sisMakeCurrent( __DRIcontext *driContextPriv,
+                __DRIdrawable *driDrawPriv,
+                __DRIdrawable *driReadPriv )
 {
    if ( driContextPriv ) {
       GET_CURRENT_CONTEXT(ctx);
@@ -396,7 +398,7 @@ sisMakeCurrent( __DRIcontextPrivate *driContextPriv,
 }
 
 GLboolean
-sisUnbindContext( __DRIcontextPrivate *driContextPriv )
+sisUnbindContext( __DRIcontext *driContextPriv )
 {
    return GL_TRUE;
 }
index bc53cb5efa169d6ed06c6af6121b6ae014094de8..4179ee081a7572d3ce79d783fc204c44c6bb98a6 100644 (file)
@@ -359,9 +359,9 @@ struct sis_context
 
   /* Mirrors of some DRI state
    */
-  __DRIcontextPrivate  *driContext;    /* DRI context */
-  __DRIscreenPrivate   *driScreen;     /* DRI screen */
-  __DRIdrawablePrivate *driDrawable;   /* DRI drawable bound to this ctx */
+  __DRIcontext *driContext;    /* DRI context */
+  __DRIscreen  *driScreen;     /* DRI screen */
+  __DRIdrawable        *driDrawable;   /* DRI drawable bound to this ctx */
 
   unsigned int lastStamp;              /* mirror driDrawable->lastStamp */
 
@@ -439,18 +439,18 @@ enum _sis_verbose {
 };
 
 extern GLboolean sisCreateContext( const __GLcontextModes *glVisual,
-                                  __DRIcontextPrivate *driContextPriv,
+                                  __DRIcontext *driContextPriv,
                                    void *sharedContextPrivate );
-extern void sisDestroyContext( __DRIcontextPrivate * );
+extern void sisDestroyContext( __DRIcontext * );
 
 void sisReAllocateBuffers(GLcontext *ctx, GLframebuffer *drawbuffer,
                           GLuint width, GLuint height);
 
-extern GLboolean sisMakeCurrent( __DRIcontextPrivate *driContextPriv,
-                                  __DRIdrawablePrivate *driDrawPriv,
-                                  __DRIdrawablePrivate *driReadPriv );
+extern GLboolean sisMakeCurrent( __DRIcontext *driContextPriv,
+                                  __DRIdrawable *driDrawPriv,
+                                  __DRIdrawable *driReadPriv );
 
-extern GLboolean sisUnbindContext( __DRIcontextPrivate *driContextPriv );
+extern GLboolean sisUnbindContext( __DRIcontext *driContextPriv );
 
 void WaitEngIdle (sisContextPtr smesa);
 void Wait2DEngIdle (sisContextPtr smesa);
index bddc4a9285ce829a0be8705738ec3a0dfc103806..217d77557f3e5530699d1b7deee60384a87ca6be 100644 (file)
@@ -41,6 +41,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "sis_tris.h"
 
 #include "swrast/swrast.h"
+#include "main/formats.h"
 #include "main/framebuffer.h"
 #include "main/renderbuffer.h"
 
@@ -142,25 +143,25 @@ sisInitRenderbuffer(struct gl_renderbuffer *rb, GLenum format)
 
    if (format == GL_RGBA) {
       /* Color */
-      rb->_BaseFormat = GL_RGBA;
+      rb->Format = MESA_FORMAT_ARGB8888;
       rb->DataType = GL_UNSIGNED_BYTE;
    }
    else if (format == GL_DEPTH_COMPONENT16) {
       /* Depth */
-      rb->_BaseFormat = GL_DEPTH_COMPONENT;
       /* we always Get/Put 32-bit Z values */
+      rb->Format = MESA_FORMAT_Z16;
       rb->DataType = GL_UNSIGNED_INT;
    }
    else if (format == GL_DEPTH_COMPONENT24) {
       /* Depth */
-      rb->_BaseFormat = GL_DEPTH_COMPONENT;
       /* we always Get/Put 32-bit Z values */
+      rb->Format = MESA_FORMAT_Z32;
       rb->DataType = GL_UNSIGNED_INT;
    }
    else {
       /* Stencil */
       ASSERT(format == GL_STENCIL_INDEX8_EXT);
-      rb->_BaseFormat = GL_STENCIL_INDEX;
+      rb->Format = MESA_FORMAT_S8;
       rb->DataType = GL_UNSIGNED_BYTE;
    }
 
index 806110cad4d2ff4bf6c385e601335ce634023e29..b8ff4e31e250fdf3b70f279ecae2a269715d9001 100644 (file)
@@ -46,8 +46,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 void
 sisGetLock( sisContextPtr smesa, GLuint flags )
 {
-   __DRIdrawablePrivate *dPriv = smesa->driDrawable;
-   __DRIscreenPrivate *sPriv = smesa->driScreen;
+   __DRIdrawable *dPriv = smesa->driDrawable;
+   __DRIscreen *sPriv = smesa->driScreen;
    SISSAREAPrivPtr sarea = smesa->sarea;
 
    drmGetLock( smesa->driFd, smesa->hHWContext, flags );
index b5f04ae28d09170776a46667ee2372f34ccf764c..d38b93ec9b8a7f217fb696f0e3eccf69ecf00623 100644 (file)
@@ -65,7 +65,7 @@ static const GLuint __driNConfigOptions = 3;
 extern const struct dri_extension card_extensions[];
 
 static const __DRIconfig **
-sisFillInModes(__DRIscreenPrivate *psp, int bpp)
+sisFillInModes(__DRIscreen *psp, int bpp)
 {
    __DRIconfig **configs;
    unsigned depth_buffer_factor;
@@ -117,7 +117,7 @@ sisFillInModes(__DRIscreenPrivate *psp, int bpp)
 /* Create the device specific screen private data struct.
  */
 static sisScreenPtr
-sisCreateScreen( __DRIscreenPrivate *sPriv )
+sisCreateScreen( __DRIscreen *sPriv )
 {
    sisScreenPtr sisScreen;
    SISDRIPtr sisDRIPriv = (SISDRIPtr)sPriv->pDevPriv;
@@ -172,7 +172,7 @@ sisCreateScreen( __DRIscreenPrivate *sPriv )
 /* Destroy the device specific screen private data struct.
  */
 static void
-sisDestroyScreen( __DRIscreenPrivate *sPriv )
+sisDestroyScreen( __DRIscreen *sPriv )
 {
    sisScreenPtr sisScreen = (sisScreenPtr)sPriv->private;
 
@@ -192,8 +192,8 @@ sisDestroyScreen( __DRIscreenPrivate *sPriv )
  * data.
  */
 static GLboolean
-sisCreateBuffer( __DRIscreenPrivate *driScrnPriv,
-                 __DRIdrawablePrivate *driDrawPriv,
+sisCreateBuffer( __DRIscreen *driScrnPriv,
+                 __DRIdrawable *driDrawPriv,
                  const __GLcontextModes *mesaVis,
                  GLboolean isPixmap )
 {
@@ -219,12 +219,12 @@ sisCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
 
 static void
-sisDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+sisDestroyBuffer(__DRIdrawable *driDrawPriv)
 {
    _mesa_reference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)), NULL);
 }
 
-static void sisCopyBuffer( __DRIdrawablePrivate *dPriv )
+static void sisCopyBuffer( __DRIdrawable *dPriv )
 {
    sisContextPtr smesa = (sisContextPtr)dPriv->driContextPriv->driverPrivate;
    int i;
@@ -259,7 +259,7 @@ static void sisCopyBuffer( __DRIdrawablePrivate *dPriv )
 
 /* Copy the back color buffer to the front color buffer */
 static void
-sisSwapBuffers(__DRIdrawablePrivate *dPriv)
+sisSwapBuffers(__DRIdrawable *dPriv)
 {
    if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
          sisContextPtr smesa = (sisContextPtr) dPriv->driContextPriv->driverPrivate;
@@ -284,7 +284,7 @@ sisSwapBuffers(__DRIdrawablePrivate *dPriv)
  * \return the __GLcontextModes supported by this driver
  */
 static const __DRIconfig **
-sisInitScreen(__DRIscreenPrivate *psp)
+sisInitScreen(__DRIscreen *psp)
 {
    static const __DRIversion ddx_expected = {0, 8, 0};
    static const __DRIversion dri_expected = {4, 0, 0};
@@ -298,18 +298,6 @@ sisInitScreen(__DRIscreenPrivate *psp)
                                   &psp->drm_version, &drm_expected))
       return NULL;
 
-   /* Calling driInitExtensions here, with a NULL context pointer,
-    * does not actually enable the extensions.  It just makes sure
-    * that all the dispatch offsets for all the extensions that
-    * *might* be enables are known.  This is needed because the
-    * dispatch offsets need to be known when _mesa_context_create is
-    * called, but we can't enable the extensions until we have a
-    * context pointer.
-    *
-    * Hello chicken.  Hello egg.  How are you two today?
-    */
-   driInitExtensions( NULL, card_extensions, GL_FALSE );
-
    psp->private = sisCreateScreen(psp);
 
    if (!psp->private) {
@@ -337,3 +325,10 @@ const struct __DriverAPIRec driDriverAPI = {
    .SwapBuffersMSC  = NULL
 
 };
+
+/* This is the table of extensions that the loader will dlsym() for. */
+PUBLIC const __DRIextension *__driDriverExtensions[] = {
+    &driCoreExtension.base,
+    &driLegacyExtension.base,
+    NULL
+};
index 07c29cfa09843f9946872d388bffdfe1cb48bd77..8009fecc31fcb7fface2f4dcd7f52f80599a7141 100644 (file)
@@ -50,7 +50,7 @@ typedef struct {
    int cpp;
    unsigned int screenX, screenY;
 
-   __DRIscreenPrivate *driScreen;
+   __DRIscreen *driScreen;
    unsigned int sarea_priv_offset;
 
    /* Configuration cache with default values for all contexts */
index 9e9a509755d8090577877ad26338fdeaa802fe5f..008b00160e8976b832d86cbaedca2ffc7a196090 100644 (file)
@@ -42,7 +42,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #define LOCAL_VARS                                                     \
    sisContextPtr smesa = SIS_CONTEXT(ctx);                             \
-   __DRIdrawablePrivate *dPriv = smesa->driDrawable;                   \
+   __DRIdrawable *dPriv = smesa->driDrawable;                  \
    struct sis_renderbuffer *srb = (struct sis_renderbuffer *) rb;      \
    GLuint pitch = srb->pitch;                                          \
    char *buf = srb->map;                                               \
@@ -52,7 +52,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #define LOCAL_DEPTH_VARS                                               \
    sisContextPtr smesa = SIS_CONTEXT(ctx);                             \
-   __DRIdrawablePrivate *dPriv = smesa->driDrawable;                   \
+   __DRIdrawable *dPriv = smesa->driDrawable;                  \
    struct sis_renderbuffer *srb = (struct sis_renderbuffer *) rb;      \
    char *buf = srb->map;
 
@@ -176,24 +176,22 @@ sisDDInitSpanFuncs( GLcontext *ctx )
 void
 sisSetSpanFunctions(struct sis_renderbuffer *srb, const GLvisual *vis)
 {
-   if (srb->Base.InternalFormat == GL_RGBA) {
-      if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
-         sisInitPointers_RGB565( &srb->Base );
-      }
-      else {
-         sisInitPointers_ARGB8888( &srb->Base );
-      }
+   if (srb->Base.Format == MESA_FORMAT_RGB565) {
+      sisInitPointers_RGB565( &srb->Base );
    }
-   else if (srb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+   else if (srb->Base.Format == MESA_FORMAT_ARGB8888) {
+      sisInitPointers_ARGB8888( &srb->Base );
+   }
+   else if (srb->Base.Format == MESA_FORMAT_Z16) {
       sisInitDepthPointers_z16(&srb->Base);
    }
-   else if (srb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+   else if (srb->Base.Format == MESA_FORMAT_S8_Z24) {
       sisInitDepthPointers_z24_s8(&srb->Base);
    }
-   else if (srb->Base.InternalFormat == GL_DEPTH_COMPONENT32) {
+   else if (srb->Base.Format == MESA_FORMAT_Z32) {
       sisInitDepthPointers_z32(&srb->Base);
    }
-   else if (srb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+   else if (srb->Base.Format == MESA_FORMAT_S8) {
       sisInitStencilPointers_z24_s8(&srb->Base);
    }
 }
index 28ced6cfd5f164343bc2ffb518292a6d9deb3c07..951c470dadfb174d15f81ac1803775ce2ed37429 100644 (file)
@@ -28,17 +28,15 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *    Eric Anholt <anholt@FreeBSD.org>
  */
 
-#include "sis_context.h"
-#include "sis_alloc.h"
-#include "sis_tex.h"
-
 #include "swrast/swrast.h"
 #include "main/imports.h"
-#include "main/texformat.h"
 #include "main/texstore.h"
 #include "main/teximage.h"
 #include "main/texobj.h"
 
+#include "sis_context.h"
+#include "sis_alloc.h"
+#include "sis_tex.h"
 #include "xmlpool.h"
 
 #define ALIGN(value, align) (GLubyte *)((long)(value + align - 1) & ~(align - 1))
@@ -65,7 +63,7 @@ sisAllocTexImage( sisContextPtr smesa, sisTexObjPtr t, int level,
 
    if (t->format == 0) {
       t->format = image->_BaseFormat;
-      switch (image->TexFormat->MesaFormat)
+      switch (image->TexFormat)
       {
       case MESA_FORMAT_ARGB8888:
          t->hwformat = TEXEL_ARGB_8888_32;
@@ -101,13 +99,12 @@ sisAllocTexImage( sisContextPtr smesa, sisTexObjPtr t, int level,
          t->hwformat = TEXEL_VUY422;
          break;
       default:
-         sis_fatal_error("Bad texture format 0x%x.\n",
-                        image->TexFormat->MesaFormat);
+         sis_fatal_error("Bad texture format 0x%x.\n", image->TexFormat);
       }
    }
    assert(t->format == image->_BaseFormat);
 
-   texel_size = image->TexFormat->TexelBytes;
+   texel_size = _mesa_get_format_bytes(image->TexFormat);
    size = image->Width * image->Height * texel_size + TEXTURE_HW_PLUS;
 
    addr = sisAllocFB( smesa, size, &t->image[level].handle );
@@ -230,7 +227,7 @@ static GLboolean sisIsTextureResident( GLcontext * ctx,
   return (texObj->DriverData != NULL);
 }
 
-static const struct gl_texture_format *
+static gl_format
 sisChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
                          GLenum format, GLenum type )
 {
@@ -248,15 +245,15 @@ sisChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
       switch ( type ) {
       case GL_UNSIGNED_INT_10_10_10_2:
       case GL_UNSIGNED_INT_2_10_10_10_REV:
-        return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb1555;
+        return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB1555;
       case GL_UNSIGNED_SHORT_4_4_4_4:
       case GL_UNSIGNED_SHORT_4_4_4_4_REV:
-        return &_mesa_texformat_argb4444;
+        return MESA_FORMAT_ARGB4444;
       case GL_UNSIGNED_SHORT_5_5_5_1:
       case GL_UNSIGNED_SHORT_1_5_5_5_REV:
-        return &_mesa_texformat_argb1555;
+        return MESA_FORMAT_ARGB1555;
       default:
-         return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+         return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444;
       }
 
    case 3:
@@ -265,46 +262,46 @@ sisChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
       switch ( type ) {
       case GL_UNSIGNED_SHORT_4_4_4_4:
       case GL_UNSIGNED_SHORT_4_4_4_4_REV:
-        return &_mesa_texformat_argb4444;
+        return MESA_FORMAT_ARGB4444;
       case GL_UNSIGNED_SHORT_5_5_5_1:
       case GL_UNSIGNED_SHORT_1_5_5_5_REV:
-        return &_mesa_texformat_argb1555;
+        return MESA_FORMAT_ARGB1555;
       case GL_UNSIGNED_SHORT_5_6_5:
       case GL_UNSIGNED_SHORT_5_6_5_REV:
-        return &_mesa_texformat_rgb565;
+        return MESA_FORMAT_RGB565;
       default:
-         return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
+         return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_RGB565;
       }
 
    case GL_RGBA8:
    case GL_RGBA12:
    case GL_RGBA16:
       return !force16bpt ?
-         &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+         MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444;
 
    case GL_RGB10_A2:
       return !force16bpt ?
-         &_mesa_texformat_argb8888 : &_mesa_texformat_argb1555;
+         MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB1555;
 
    case GL_RGBA4:
    case GL_RGBA2:
-      return &_mesa_texformat_argb4444;
+      return MESA_FORMAT_ARGB4444;
 
    case GL_RGB5_A1:
-      return &_mesa_texformat_argb1555;
+      return MESA_FORMAT_ARGB1555;
 
    case GL_RGB8:
    case GL_RGB10:
    case GL_RGB12:
    case GL_RGB16:
-      return !force16bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
+      return !force16bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_RGB565;
 
    case GL_RGB5:
    case GL_RGB4:
-      return &_mesa_texformat_rgb565;
+      return MESA_FORMAT_RGB565;
 
    case GL_R3_G3_B2:
-      return &_mesa_texformat_rgb332;
+      return MESA_FORMAT_RGB332;
 
    case GL_ALPHA:
    case GL_ALPHA4:             /* FIXME: This could use its own texstore */
@@ -312,7 +309,7 @@ sisChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_ALPHA12:
    case GL_ALPHA16:
    case GL_COMPRESSED_ALPHA:
-      return &_mesa_texformat_a8;
+      return MESA_FORMAT_A8;
 
    case 1:
    case GL_LUMINANCE:
@@ -321,7 +318,7 @@ sisChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_LUMINANCE12:
    case GL_LUMINANCE16:
    case GL_COMPRESSED_LUMINANCE:
-      return &_mesa_texformat_l8;
+      return MESA_FORMAT_L8;
 
    case 2:
    case GL_LUMINANCE_ALPHA:
@@ -332,7 +329,7 @@ sisChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_LUMINANCE12_ALPHA12:
    case GL_LUMINANCE16_ALPHA16:
    case GL_COMPRESSED_LUMINANCE_ALPHA:
-      return &_mesa_texformat_al88;
+      return MESA_FORMAT_AL88;
 
    case GL_INTENSITY:
    case GL_INTENSITY4:
@@ -340,19 +337,19 @@ sisChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_INTENSITY12:
    case GL_INTENSITY16:
    case GL_COMPRESSED_INTENSITY:
-      return &_mesa_texformat_i8;
+      return MESA_FORMAT_I8;
 
    case GL_YCBCR_MESA:
       if (type == GL_UNSIGNED_SHORT_8_8_APPLE ||
           type == GL_UNSIGNED_BYTE)
-         return &_mesa_texformat_ycbcr;
+         return MESA_FORMAT_YCBCR;
       else
-         return &_mesa_texformat_ycbcr_rev;
+         return MESA_FORMAT_YCBCR_REV;
 
    default:
       _mesa_problem(ctx, "unexpected format in sisDDChooseTextureFormat: %d",
          internalFormat);
-      return NULL;
+      return MESA_FORMAT_NONE;
    }
 }
 
@@ -425,7 +422,7 @@ static void sisTexSubImage1D( GLcontext *ctx,
 
    /* Upload the texture */
    WaitEngIdle(smesa);
-   texelBytes = texImage->TexFormat->TexelBytes;
+   texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
 
    copySize = width * texelBytes;
    src = (char *)texImage->Data + xoffset * texelBytes;
@@ -513,7 +510,7 @@ static void sisTexSubImage2D( GLcontext *ctx,
 
    /* Upload the texture */
    WaitEngIdle(smesa);
-   texelBytes = texImage->TexFormat->TexelBytes;
+   texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
 
    copySize = width * texelBytes;
    src = (char *)texImage->Data + (xoffset + yoffset * texImage->Width) *
index 46417ce414c374a350a700b3300d14f1fa0ff276..4c22a10cf7e361e9cdda9ef23d595675ad3949c4 100644 (file)
@@ -36,7 +36,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/colormac.h"
 #include "main/context.h"
 #include "main/macros.h"
-#include "main/texformat.h"
 
 #include "sis_context.h"
 #include "sis_state.h"
@@ -458,10 +457,10 @@ sis_set_texobj_parm( GLcontext *ctx, struct gl_texture_object *texObj,
 
    {
       GLubyte c[4];
-      CLAMPED_FLOAT_TO_UBYTE(c[0], texObj->BorderColor[0]);
-      CLAMPED_FLOAT_TO_UBYTE(c[1], texObj->BorderColor[1]);
-      CLAMPED_FLOAT_TO_UBYTE(c[2], texObj->BorderColor[2]);
-      CLAMPED_FLOAT_TO_UBYTE(c[3], texObj->BorderColor[3]);
+      CLAMPED_FLOAT_TO_UBYTE(c[0], texObj->BorderColor.f[0]);
+      CLAMPED_FLOAT_TO_UBYTE(c[1], texObj->BorderColor.f[1]);
+      CLAMPED_FLOAT_TO_UBYTE(c[2], texObj->BorderColor.f[2]);
+      CLAMPED_FLOAT_TO_UBYTE(c[3], texObj->BorderColor.f[3]);
 
       current->texture[hw_unit].hwTextureBorderColor = 
          PACK_COLOR_8888(c[3], c[0], c[1], c[2]);
index 76d12d07b3ca4e3aef5a665b8d0ad2646efa0088..4690274c3c05f8d7f43921ff6a012bdd4e7e5629 100644 (file)
@@ -430,7 +430,8 @@ do {                                                                \
 
 #define LOCAL_VARS(n)                                          \
    sisContextPtr smesa = SIS_CONTEXT(ctx);                     \
-   GLuint color[n], spec[n];                                   \
+   GLuint color[n] = { 0 };                                    \
+   GLuint spec[n] = { 0 };                                     \
    GLuint coloroffset = smesa->coloroffset;                    \
    GLuint specoffset = smesa->specoffset;                      \
    (void) color; (void) spec; (void) coloroffset; (void) specoffset;
@@ -903,14 +904,14 @@ static void sisRenderStart( GLcontext *ctx )
 
    /* projective textures are not supported by the hardware */
    if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX0 )) {
-      if (VB->TexCoordPtr[0]->size > 2)
+      if (VB->AttribPtr[_TNL_ATTRIB_TEX0]->size > 2)
         tex_fallback = GL_TRUE;
       EMIT_ATTR(_TNL_ATTRIB_TEX0, EMIT_2F);
       AGPParseSet |= SiS_PS_HAS_UV0;
    }
    /* Will only hit tex1 on SiS300 */
    if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX1 )) {
-      if (VB->TexCoordPtr[1]->size > 2)
+      if (VB->AttribPtr[_TNL_ATTRIB_TEX1]->size > 2)
         tex_fallback = GL_TRUE;
       EMIT_ATTR(_TNL_ATTRIB_TEX1, EMIT_2F);
       AGPParseSet |= SiS_PS_HAS_UV1;
index 5f3a4f2191ba93f0c78d9d8c99921aea1c2fbfb4..771169c1ff93007d4d86fe1510e4029f9858683d 100644 (file)
@@ -21,4 +21,3 @@ SWRAST_COMMON_SOURCES = \
 
 include ../Makefile.template
 
-symlinks:
index f4947daa063874f0df53b757cdb354106a803132..8340861aff8b5715259312f51639046e7b3fa086 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "main/context.h"
 #include "main/extensions.h"
+#include "main/formats.h"
 #include "main/framebuffer.h"
 #include "main/imports.h"
 #include "main/renderbuffer.h"
 #include "swrast_priv.h"
 
 
-#define need_GL_VERSION_1_3
-#define need_GL_VERSION_1_4
-#define need_GL_VERSION_1_5
-#define need_GL_VERSION_2_0
-#define need_GL_VERSION_2_1
-
-/* sw extensions for imaging */
-#define need_GL_EXT_blend_color
-#define need_GL_EXT_blend_minmax
-#define need_GL_EXT_convolution
-#define need_GL_EXT_histogram
-#define need_GL_SGI_color_table
-
-/* sw extensions not associated with some GL version */
-#define need_GL_ARB_draw_elements_base_vertex
-#define need_GL_ARB_shader_objects
-#define need_GL_ARB_vertex_array_object
-#define need_GL_ARB_vertex_program
-#define need_GL_ARB_sync
-#define need_GL_APPLE_vertex_array_object
-#define need_GL_ATI_fragment_shader
-#define need_GL_ATI_separate_stencil
-#define need_GL_EXT_depth_bounds_test
-#define need_GL_EXT_framebuffer_object
-#define need_GL_EXT_framebuffer_blit
-#define need_GL_EXT_gpu_program_parameters
-#define need_GL_EXT_paletted_texture
-#define need_GL_EXT_stencil_two_side
-#define need_GL_MESA_resize_buffers
-#define need_GL_NV_vertex_program
-#define need_GL_NV_fragment_program
-
-#include "extension_helper.h"
-
-const struct dri_extension card_extensions[] =
-{
-    { "GL_VERSION_1_3",                        GL_VERSION_1_3_functions },
-    { "GL_VERSION_1_4",                        GL_VERSION_1_4_functions },
-    { "GL_VERSION_1_5",                        GL_VERSION_1_5_functions },
-    { "GL_VERSION_2_0",                        GL_VERSION_2_0_functions },
-    { "GL_VERSION_2_1",                        GL_VERSION_2_1_functions },
-
-    { "GL_EXT_blend_color",            GL_EXT_blend_color_functions },
-    { "GL_EXT_blend_minmax",           GL_EXT_blend_minmax_functions },
-    { "GL_EXT_convolution",            GL_EXT_convolution_functions },
-    { "GL_EXT_histogram",              GL_EXT_histogram_functions },
-    { "GL_SGI_color_table",            GL_SGI_color_table_functions },
-
-    { "GL_ARB_depth_clamp",            NULL },
-    { "GL_ARB_draw_elements_base_vertex", GL_ARB_draw_elements_base_vertex_functions },
-    { "GL_ARB_shader_objects",         GL_ARB_shader_objects_functions },
-    { "GL_ARB_vertex_array_object",    GL_ARB_vertex_array_object_functions },
-    { "GL_ARB_vertex_program",         GL_ARB_vertex_program_functions },
-    { "GL_ARB_sync",                   GL_ARB_sync_functions },
-    { "GL_APPLE_vertex_array_object",  GL_APPLE_vertex_array_object_functions },
-    { "GL_ATI_fragment_shader",                GL_ATI_fragment_shader_functions },
-    { "GL_ATI_separate_stencil",       GL_ATI_separate_stencil_functions },
-    { "GL_EXT_depth_bounds_test",      GL_EXT_depth_bounds_test_functions },
-    { "GL_EXT_framebuffer_object",     GL_EXT_framebuffer_object_functions },
-    { "GL_EXT_framebuffer_blit",       GL_EXT_framebuffer_blit_functions },
-    { "GL_EXT_gpu_program_parameters", GL_EXT_gpu_program_parameters_functions },
-    { "GL_EXT_paletted_texture",       GL_EXT_paletted_texture_functions },
-    { "GL_EXT_stencil_two_side",       GL_EXT_stencil_two_side_functions },
-    { "GL_MESA_resize_buffers",                GL_MESA_resize_buffers_functions },
-    { "GL_NV_depth_clamp",             NULL },
-    { "GL_NV_vertex_program",          GL_NV_vertex_program_functions },
-    { "GL_NV_fragment_program",                GL_NV_fragment_program_functions },
-    { "GL_NV_fragment_program_option", NULL },
-    { NULL,                            NULL }
-};
-
-
 /**
  * Screen and config-related functions
  */
@@ -244,7 +173,7 @@ driCreateNewScreen(int scrn, const __DRIextension **extensions,
     *driver_configs = (const __DRIconfig **)
        driConcatConfigs(configs24, configs32);
 
-    driInitExtensions( NULL, card_extensions, GL_FALSE );
+    driInitExtensions( NULL, NULL, GL_FALSE );
 
     return psp;
 }
@@ -378,50 +307,38 @@ swrast_new_renderbuffer(const GLvisual *visual, GLboolean front)
 
     switch (pixel_format) {
     case PF_A8R8G8B8:
+       xrb->Base.Format = MESA_FORMAT_ARGB8888;
        xrb->Base.InternalFormat = GL_RGBA;
        xrb->Base._BaseFormat = GL_RGBA;
        xrb->Base.DataType = GL_UNSIGNED_BYTE;
-       xrb->Base.RedBits   = 8 * sizeof(GLubyte);
-       xrb->Base.GreenBits = 8 * sizeof(GLubyte);
-       xrb->Base.BlueBits  = 8 * sizeof(GLubyte);
-       xrb->Base.AlphaBits = 8 * sizeof(GLubyte);
        xrb->bpp = 32;
        break;
     case PF_X8R8G8B8:
+       xrb->Base.Format = MESA_FORMAT_ARGB8888; /* XXX */
        xrb->Base.InternalFormat = GL_RGB;
        xrb->Base._BaseFormat = GL_RGB;
        xrb->Base.DataType = GL_UNSIGNED_BYTE;
-       xrb->Base.RedBits   = 8 * sizeof(GLubyte);
-       xrb->Base.GreenBits = 8 * sizeof(GLubyte);
-       xrb->Base.BlueBits  = 8 * sizeof(GLubyte);
-       xrb->Base.AlphaBits = 0;
        xrb->bpp = 32;
        break;
     case PF_R5G6B5:
+       xrb->Base.Format = MESA_FORMAT_RGB565;
        xrb->Base.InternalFormat = GL_RGB;
        xrb->Base._BaseFormat = GL_RGB;
        xrb->Base.DataType = GL_UNSIGNED_BYTE;
-       xrb->Base.RedBits   = 5 * sizeof(GLubyte);
-       xrb->Base.GreenBits = 6 * sizeof(GLubyte);
-       xrb->Base.BlueBits  = 5 * sizeof(GLubyte);
-       xrb->Base.AlphaBits = 0;
        xrb->bpp = 16;
        break;
     case PF_R3G3B2:
+       xrb->Base.Format = MESA_FORMAT_RGB332;
        xrb->Base.InternalFormat = GL_RGB;
        xrb->Base._BaseFormat = GL_RGB;
        xrb->Base.DataType = GL_UNSIGNED_BYTE;
-       xrb->Base.RedBits   = 3 * sizeof(GLubyte);
-       xrb->Base.GreenBits = 3 * sizeof(GLubyte);
-       xrb->Base.BlueBits  = 2 * sizeof(GLubyte);
-       xrb->Base.AlphaBits = 0;
        xrb->bpp = 8;
        break;
     case PF_CI8:
+       xrb->Base.Format = MESA_FORMAT_CI8;
        xrb->Base.InternalFormat = GL_COLOR_INDEX8_EXT;
        xrb->Base._BaseFormat = GL_COLOR_INDEX;
        xrb->Base.DataType = GL_UNSIGNED_BYTE;
-       xrb->Base.IndexBits = 8 * sizeof(GLubyte);
        xrb->bpp = 8;
        break;
     default:
index 2d3c25dcbef44fdc7124ec8640b5806603cfba27..f8e503463fa17b2557553c64fd8c4d9644dab52f 100644 (file)
@@ -63,56 +63,42 @@ static const GLubyte kernel[16] = {
 
 /* 32-bit BGRA */
 #define STORE_PIXEL_A8R8G8B8(DST, X, Y, VALUE) \
-   DST[3] = VALUE[ACOMP]; \
-   DST[2] = VALUE[RCOMP]; \
-   DST[1] = VALUE[GCOMP]; \
-   DST[0] = VALUE[BCOMP]
+   *DST = VALUE[ACOMP] << 24 | VALUE[RCOMP] << 16 | VALUE[GCOMP] << 8 | VALUE[BCOMP]
 #define STORE_PIXEL_RGB_A8R8G8B8(DST, X, Y, VALUE) \
-   DST[3] = 0xff; \
-   DST[2] = VALUE[RCOMP]; \
-   DST[1] = VALUE[GCOMP]; \
-   DST[0] = VALUE[BCOMP]
+   *DST = 0xff << 24 | VALUE[RCOMP] << 16 | VALUE[GCOMP] << 8 | VALUE[BCOMP]
 #define FETCH_PIXEL_A8R8G8B8(DST, SRC) \
-   DST[ACOMP] = SRC[3]; \
-   DST[RCOMP] = SRC[2]; \
-   DST[GCOMP] = SRC[1]; \
-   DST[BCOMP] = SRC[0]
+   DST[ACOMP] = *SRC >> 24;            \
+   DST[RCOMP] = (*SRC >> 16) & 0xff;   \
+   DST[GCOMP] = (*SRC >> 8) & 0xff;    \
+   DST[BCOMP] = *SRC & 0xff
 
 
 /* 32-bit BGRX */
 #define STORE_PIXEL_X8R8G8B8(DST, X, Y, VALUE) \
-   DST[3] = 0xff; \
-   DST[2] = VALUE[RCOMP]; \
-   DST[1] = VALUE[GCOMP]; \
-   DST[0] = VALUE[BCOMP]
+   *DST = 0xff << 24 | VALUE[RCOMP] << 16 | VALUE[GCOMP] << 8 | VALUE[BCOMP]
 #define STORE_PIXEL_RGB_X8R8G8B8(DST, X, Y, VALUE) \
-   DST[3] = 0xff; \
-   DST[2] = VALUE[RCOMP]; \
-   DST[1] = VALUE[GCOMP]; \
-   DST[0] = VALUE[BCOMP]
+   *DST = 0xff << 24 | VALUE[RCOMP] << 16 | VALUE[GCOMP] << 8 | VALUE[BCOMP]
 #define FETCH_PIXEL_X8R8G8B8(DST, SRC) \
-   DST[ACOMP] = 0xff; \
-   DST[RCOMP] = SRC[2]; \
-   DST[GCOMP] = SRC[1]; \
-   DST[BCOMP] = SRC[0]
+   DST[ACOMP] = 0xff;                  \
+   DST[RCOMP] = (*SRC >> 16) & 0xff;   \
+   DST[GCOMP] = (*SRC >> 8) & 0xff;    \
+   DST[BCOMP] = *SRC & 0xff
 
 
 /* 16-bit BGR */
 #define STORE_PIXEL_R5G6B5(DST, X, Y, VALUE) \
    do { \
    int d = DITHER_COMP(X, Y) >> 6; \
-   GLushort *p = (GLushort *)DST; \
-   *p = ( ((DITHER_CLAMP((VALUE[RCOMP]) + d) & 0xf8) << 8) | \
-         ((DITHER_CLAMP((VALUE[GCOMP]) + d) & 0xfc) << 3) | \
-         ((DITHER_CLAMP((VALUE[BCOMP]) + d) & 0xf8) >> 3) ); \
+   *DST = ( ((DITHER_CLAMP((VALUE[RCOMP]) + d) & 0xf8) << 8) | \
+            ((DITHER_CLAMP((VALUE[GCOMP]) + d) & 0xfc) << 3) | \
+            ((DITHER_CLAMP((VALUE[BCOMP]) + d) & 0xf8) >> 3) ); \
    } while(0)
 #define FETCH_PIXEL_R5G6B5(DST, SRC) \
    do { \
-   GLushort p = *(GLushort *)SRC; \
    DST[ACOMP] = 0xff; \
-   DST[RCOMP] = ((p >> 8) & 0xf8) * 255 / 0xf8; \
-   DST[GCOMP] = ((p >> 3) & 0xfc) * 255 / 0xfc; \
-   DST[BCOMP] = ((p << 3) & 0xf8) * 255 / 0xf8; \
+   DST[RCOMP] = ((*SRC >> 8) & 0xf8) * 255 / 0xf8; \
+   DST[GCOMP] = ((*SRC >> 3) & 0xfc) * 255 / 0xfc; \
+   DST[BCOMP] = ((*SRC << 3) & 0xf8) * 255 / 0xf8; \
    } while(0)
 
 
@@ -145,8 +131,8 @@ static const GLubyte kernel[16] = {
 #define SPAN_VARS \
    struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
 #define INIT_PIXEL_PTR(P, X, Y) \
-   GLubyte *P = (GLubyte *)xrb->Base.Data + YFLIP(xrb, Y) * xrb->pitch + (X) * 4;
-#define INC_PIXEL_PTR(P) P += 4
+   GLuint *P = (GLuint *)xrb->Base.Data + YFLIP(xrb, Y) * xrb->pitch / 4 + (X)
+#define INC_PIXEL_PTR(P) P++
 #define STORE_PIXEL(DST, X, Y, VALUE) \
    STORE_PIXEL_A8R8G8B8(DST, X, Y, VALUE)
 #define STORE_PIXEL_RGB(DST, X, Y, VALUE) \
@@ -163,8 +149,8 @@ static const GLubyte kernel[16] = {
 #define SPAN_VARS \
    struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
 #define INIT_PIXEL_PTR(P, X, Y) \
-   GLubyte *P = (GLubyte *)xrb->Base.Data + YFLIP(xrb, Y) * xrb->pitch + (X) * 4;
-#define INC_PIXEL_PTR(P) P += 4
+   GLuint *P = (GLuint *)xrb->Base.Data + YFLIP(xrb, Y) * xrb->pitch / 4 + (X);
+#define INC_PIXEL_PTR(P) P++
 #define STORE_PIXEL(DST, X, Y, VALUE) \
    STORE_PIXEL_X8R8G8B8(DST, X, Y, VALUE)
 #define STORE_PIXEL_RGB(DST, X, Y, VALUE) \
@@ -181,8 +167,8 @@ static const GLubyte kernel[16] = {
 #define SPAN_VARS \
    struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
 #define INIT_PIXEL_PTR(P, X, Y) \
-   GLubyte *P = (GLubyte *)xrb->Base.Data + YFLIP(xrb, Y) * xrb->pitch + (X) * 2;
-#define INC_PIXEL_PTR(P) P += 2
+   GLushort *P = (GLushort *)xrb->Base.Data + YFLIP(xrb, Y) * xrb->pitch / 2 + (X);
+#define INC_PIXEL_PTR(P) P++
 #define STORE_PIXEL(DST, X, Y, VALUE) \
    STORE_PIXEL_R5G6B5(DST, X, Y, VALUE)
 #define FETCH_PIXEL(DST, SRC) \
@@ -234,8 +220,8 @@ static const GLubyte kernel[16] = {
 #define SPAN_VARS \
    struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
 #define INIT_PIXEL_PTR(P, X, Y) \
-   GLubyte *P = (GLubyte *)row;
-#define INC_PIXEL_PTR(P) P += 4
+   GLuint *P = (GLuint *)row;
+#define INC_PIXEL_PTR(P) P++
 #define STORE_PIXEL(DST, X, Y, VALUE) \
    STORE_PIXEL_A8R8G8B8(DST, X, Y, VALUE)
 #define STORE_PIXEL_RGB(DST, X, Y, VALUE) \
@@ -252,8 +238,8 @@ static const GLubyte kernel[16] = {
 #define SPAN_VARS \
    struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
 #define INIT_PIXEL_PTR(P, X, Y) \
-   GLubyte *P = (GLubyte *)row;
-#define INC_PIXEL_PTR(P) P += 4
+   GLuint *P = (GLuint *)row;
+#define INC_PIXEL_PTR(P) P++
 #define STORE_PIXEL(DST, X, Y, VALUE) \
    STORE_PIXEL_X8R8G8B8(DST, X, Y, VALUE)
 #define STORE_PIXEL_RGB(DST, X, Y, VALUE) \
@@ -270,7 +256,7 @@ static const GLubyte kernel[16] = {
 #define SPAN_VARS \
    struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
 #define INIT_PIXEL_PTR(P, X, Y) \
-   GLubyte *P = (GLubyte *)row;
+   GLushort *P = (GLushort *)row;
 #define INC_PIXEL_PTR(P) P += 2
 #define STORE_PIXEL(DST, X, Y, VALUE) \
    STORE_PIXEL_R5G6B5(DST, X, Y, VALUE)
index 092c580feac75f2a4faf3dd2d8a37abbb2a4eddf..b9f25db4fe8e30a56cfb16fb100ef839f5aa9018 100644 (file)
@@ -32,6 +32,4 @@ ASM_SOURCES =
 
 include ../Makefile.template
 
-symlinks:
-
 
index 68b5027561bd651def0939373df3619ba0fe079a..edb1875f767f9f5a5e6eb21eb60b91725f5c3d9d 100644 (file)
 #define need_GL_EXT_paletted_texture
 /* #define need_GL_EXT_secondary_color */
 /* #define need_GL_NV_vertex_program */
-#include "extension_helper.h"
+#include "main/remap_helper.h"
 
 
 /**
  * Common extension strings exported by all cards
  */
-const struct dri_extension card_extensions[] =
+static const struct dri_extension card_extensions[] =
 {
     { "GL_ARB_occlusion_query",            GL_ARB_occlusion_query_functions },
     { "GL_ARB_texture_mirrored_repeat",    NULL },
@@ -107,7 +107,7 @@ const struct dri_extension card_extensions[] =
 /**
  * Extension strings exported only by Naplam (e.g., Voodoo4 & Voodoo5) cards.
  */
-const struct dri_extension napalm_extensions[] =
+static const struct dri_extension napalm_extensions[] =
 {
     { "GL_ARB_texture_env_combine",        NULL },
     { "GL_EXT_blend_equation_separate",    GL_EXT_blend_equation_separate_functions },
@@ -165,12 +165,12 @@ static const struct dri_debug_control debug_control[] =
 };
 
 GLboolean tdfxCreateContext( const __GLcontextModes *mesaVis,
-                            __DRIcontextPrivate *driContextPriv,
+                            __DRIcontext *driContextPriv,
                              void *sharedContextPrivate )
 {
    tdfxContextPtr fxMesa;
    GLcontext *ctx, *shareCtx;
-   __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+   __DRIscreen *sPriv = driContextPriv->driScreenPriv;
    tdfxScreenPrivate *fxScreen = (tdfxScreenPrivate *) sPriv->private;
    TDFXSAREAPriv *saPriv = (TDFXSAREAPriv *) ((char *) sPriv->pSAREA +
                                              sizeof(drm_sarea_t));
@@ -441,7 +441,7 @@ static GLboolean tdfxInitVertexFormats( tdfxContextPtr fxMesa )
  * Initialize the state in an tdfxContextPtr struct.
  */
 static GLboolean
-tdfxInitContext( __DRIdrawablePrivate *driDrawPriv, tdfxContextPtr fxMesa )
+tdfxInitContext( __DRIdrawable *driDrawPriv, tdfxContextPtr fxMesa )
 {
    /* KW: Would be nice to make one of these a member of the other.
     */
@@ -563,7 +563,7 @@ tdfxInitContext( __DRIdrawablePrivate *driDrawPriv, tdfxContextPtr fxMesa )
 
 
 void
-tdfxDestroyContext( __DRIcontextPrivate *driContextPriv )
+tdfxDestroyContext( __DRIcontext *driContextPriv )
 {
    tdfxContextPtr fxMesa = (tdfxContextPtr) driContextPriv->driverPrivate;
 
@@ -607,7 +607,7 @@ tdfxDestroyContext( __DRIcontextPrivate *driContextPriv )
 
 
 GLboolean
-tdfxUnbindContext( __DRIcontextPrivate *driContextPriv )
+tdfxUnbindContext( __DRIcontext *driContextPriv )
 {
    GET_CURRENT_CONTEXT(ctx);
    tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
@@ -626,9 +626,9 @@ tdfxUnbindContext( __DRIcontextPrivate *driContextPriv )
 
 
 GLboolean
-tdfxMakeCurrent( __DRIcontextPrivate *driContextPriv,
-                 __DRIdrawablePrivate *driDrawPriv,
-                 __DRIdrawablePrivate *driReadPriv )
+tdfxMakeCurrent( __DRIcontext *driContextPriv,
+                 __DRIdrawable *driDrawPriv,
+                 __DRIdrawable *driReadPriv )
 {
    if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) {
       fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)driContextPriv );
index 3bcb5451193961f2735e063e084db59ae48a0256..6e25cac30159c419eec0a56ef7d3e0f8b2ef3720 100644 (file)
@@ -892,18 +892,18 @@ struct tdfx_context {
    char rendererString[100];
 
    /* stuff added for DRI */
-   __DRIscreenPrivate *driScreen;
-   __DRIcontextPrivate *driContext;
+   __DRIscreen *driScreen;
+   __DRIcontext *driContext;
 
    /**
     * DRI drawable bound to this context for drawing.
     */
-   __DRIdrawablePrivate        *driDrawable;
+   __DRIdrawable       *driDrawable;
 
    /**
     * DRI drawable bound to this context for reading.
     */
-   __DRIdrawablePrivate        *driReadable;
+   __DRIdrawable       *driReadable;
 
    drm_context_t hHWContext;
    drm_hw_lock_t *driHwLock;
@@ -938,19 +938,19 @@ struct tdfx_context {
 
 extern GLboolean
 tdfxCreateContext( const __GLcontextModes *mesaVis,
-                   __DRIcontextPrivate *driContextPriv,
+                   __DRIcontext *driContextPriv,
                    void *sharedContextPrivate );
 
 extern void
-tdfxDestroyContext( __DRIcontextPrivate *driContextPriv );
+tdfxDestroyContext( __DRIcontext *driContextPriv );
 
 extern GLboolean
-tdfxUnbindContext( __DRIcontextPrivate *driContextPriv );
+tdfxUnbindContext( __DRIcontext *driContextPriv );
 
 extern GLboolean
-tdfxMakeCurrent( __DRIcontextPrivate *driContextPriv,
-                 __DRIdrawablePrivate *driDrawPriv,
-                 __DRIdrawablePrivate *driReadPriv );
+tdfxMakeCurrent( __DRIcontext *driContextPriv,
+                 __DRIdrawable *driDrawPriv,
+                 __DRIdrawable *driReadPriv );
 
 extern GLboolean
 tdfxInitGlide( tdfxContextPtr tmesa );
index 17cdc51ee13be889e06fa60fa6f30ce596d30dc0..4f84240104ad67a7b96628a725401edaff1adb71 100644 (file)
 
 void tdfxGetLock( tdfxContextPtr fxMesa )
 {
-    __DRIcontextPrivate *cPriv = fxMesa->driContext;
-    __DRIdrawablePrivate *const drawable = cPriv->driDrawablePriv;
-    __DRIdrawablePrivate *const readable = cPriv->driReadablePriv;
-    __DRIscreenPrivate *sPriv = drawable->driScreenPriv;
+    __DRIcontext *cPriv = fxMesa->driContext;
+    __DRIdrawable *const drawable = cPriv->driDrawablePriv;
+    __DRIdrawable *const readable = cPriv->driReadablePriv;
+    __DRIscreen *sPriv = drawable->driScreenPriv;
     TDFXSAREAPriv *saPriv = (TDFXSAREAPriv *) (((char *) sPriv->pSAREA) +
                                        fxMesa->fxScreen->sarea_priv_offset);
     unsigned int stamp = drawable->lastStamp;
index 18729d5ae08c4adcaab342fb7ef35f3a4b4931d3..65f0464f8a5cbd6edf713259823e04d1c0e13ca0 100644 (file)
@@ -495,7 +495,7 @@ tdfx_readpixels_R5G6B5(GLcontext * ctx, GLint x, GLint y,
    {
       tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
       GrLfbInfo_t info;
-      __DRIdrawablePrivate *const readable = fxMesa->driReadable;
+      __DRIdrawable *const readable = fxMesa->driReadable;
       const GLint winX = readable->x;
       const GLint winY = readable->y + readable->h - 1;
       const GLint scrX = winX + x;
@@ -553,7 +553,7 @@ tdfx_readpixels_R8G8B8A8(GLcontext * ctx, GLint x, GLint y,
    {
       tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
       GrLfbInfo_t info;
-      __DRIdrawablePrivate *const readable = fxMesa->driReadable;
+      __DRIdrawable *const readable = fxMesa->driReadable;
       const GLint winX = readable->x;
       const GLint winY = readable->y + readable->h - 1;
       const GLint scrX = winX + x;
@@ -611,10 +611,10 @@ tdfx_drawpixels_R8G8B8A8(GLcontext * ctx, GLint x, GLint y,
        ctx->Fog.Enabled ||
        ctx->Scissor.Enabled ||
        ctx->Stencil._Enabled ||
-       !ctx->Color.ColorMask[0] ||
-       !ctx->Color.ColorMask[1] ||
-       !ctx->Color.ColorMask[2] ||
-       !ctx->Color.ColorMask[3] ||
+       !ctx->Color.ColorMask[0][0] ||
+       !ctx->Color.ColorMask[0][1] ||
+       !ctx->Color.ColorMask[0][2] ||
+       !ctx->Color.ColorMask[0][3] ||
        ctx->Color.ColorLogicOpEnabled ||
        ctx->Texture._EnabledUnits ||
        fxMesa->Fallback)       
index 2cd8e12d955cdb92cb39a6378c105d0bad3f357d..979bcd4514091c76a00de00d7242242bd10f11c5 100644 (file)
@@ -76,8 +76,8 @@ static void tdfxClear( GLcontext *ctx, GLbitfield mask )
 
    if (fxMesa->glCtx->Visual.redBits != 8) {
       /* can only do color masking if running in 24/32bpp on Napalm */
-      if (ctx->Color.ColorMask[RCOMP] != ctx->Color.ColorMask[GCOMP] ||
-          ctx->Color.ColorMask[GCOMP] != ctx->Color.ColorMask[BCOMP]) {
+      if (ctx->Color.ColorMask[0][RCOMP] != ctx->Color.ColorMask[0][GCOMP] ||
+          ctx->Color.ColorMask[0][GCOMP] != ctx->Color.ColorMask[0][BCOMP]) {
          softwareMask |= (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT));
          mask &= ~(BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT);
       }
@@ -556,7 +556,7 @@ static void uploadTextureImages( tdfxContextPtr fxMesa )
  */
 void tdfxUploadClipping( tdfxContextPtr fxMesa )
 {
-   __DRIdrawablePrivate *dPriv = fxMesa->driDrawable;
+   __DRIdrawable *dPriv = fxMesa->driDrawable;
 
    assert(dPriv);
 
@@ -721,7 +721,7 @@ void tdfxEmitHwStateLocked( tdfxContextPtr fxMesa )
         fxMesa->Glide.grColorMask( fxMesa->Color.ColorMask[RCOMP] ||
                                     fxMesa->Color.ColorMask[GCOMP] ||
                                     fxMesa->Color.ColorMask[BCOMP],
-                                    /*fxMesa->Color.ColorMask[ACOMP]*/GL_FALSE/*[dBorca] no-no*/ );
+                                    /*fxMesa->Color.ColorMask[0][ACOMP]*/GL_FALSE/*[dBorca] no-no*/ );
       }
       fxMesa->dirty &= ~TDFX_UPLOAD_COLOR_MASK;
    }
index 58bd48b294ce63e15cf776d4f7ef094be8114290..4422b5dec46b49a44f2384edf215c6a5fbeecfb7 100644 (file)
@@ -69,11 +69,8 @@ static const __DRIextension *tdfxExtensions[] = {
 
 static const GLuint __driNConfigOptions = 1;
 
-extern const struct dri_extension card_extensions[];
-extern const struct dri_extension napalm_extensions[];
-
 static GLboolean
-tdfxCreateScreen( __DRIscreenPrivate *sPriv )
+tdfxCreateScreen( __DRIscreen *sPriv )
 {
    tdfxScreenPrivate *fxScreen;
    TDFXDRIPtr fxDRIPriv = (TDFXDRIPtr) sPriv->pDevPriv;
@@ -124,7 +121,7 @@ tdfxCreateScreen( __DRIscreenPrivate *sPriv )
 
 
 static void
-tdfxDestroyScreen( __DRIscreenPrivate *sPriv )
+tdfxDestroyScreen( __DRIscreen *sPriv )
 {
    tdfxScreenPrivate *fxScreen = (tdfxScreenPrivate *) sPriv->private;
 
@@ -142,7 +139,7 @@ tdfxDestroyScreen( __DRIscreenPrivate *sPriv )
 
 
 static GLboolean
-tdfxInitDriver( __DRIscreenPrivate *sPriv )
+tdfxInitDriver( __DRIscreen *sPriv )
 {
    if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) {
       fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)sPriv );
@@ -158,8 +155,8 @@ tdfxInitDriver( __DRIscreenPrivate *sPriv )
 
 
 static GLboolean
-tdfxCreateBuffer( __DRIscreenPrivate *driScrnPriv,
-                  __DRIdrawablePrivate *driDrawPriv,
+tdfxCreateBuffer( __DRIscreen *driScrnPriv,
+                  __DRIdrawable *driDrawPriv,
                   const __GLcontextModes *mesaVis,
                   GLboolean isPixmap )
 {
@@ -173,7 +170,7 @@ tdfxCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       {
          driRenderbuffer *frontRb
-            = driNewRenderbuffer(GL_RGBA, NULL, screen->cpp,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888, NULL, screen->cpp,
                                  screen->fbOffset, screen->width, driDrawPriv);
          tdfxSetSpanFunctions(frontRb, mesaVis);
          _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
@@ -181,7 +178,7 @@ tdfxCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->doubleBufferMode) {
          driRenderbuffer *backRb
-            = driNewRenderbuffer(GL_RGBA, NULL, screen->cpp,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888, NULL, screen->cpp,
                                  screen->backOffset, screen->width,
                                  driDrawPriv);
          tdfxSetSpanFunctions(backRb, mesaVis);
@@ -191,7 +188,7 @@ tdfxCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->depthBits == 16) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT16, NULL, screen->cpp,
+            = driNewRenderbuffer(MESA_FORMAT_Z16, NULL, screen->cpp,
                                  screen->depthOffset, screen->width,
                                  driDrawPriv);
          tdfxSetSpanFunctions(depthRb, mesaVis);
@@ -199,7 +196,7 @@ tdfxCreateBuffer( __DRIscreenPrivate *driScrnPriv,
       }
       else if (mesaVis->depthBits == 24) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT24, NULL, screen->cpp,
+            = driNewRenderbuffer(MESA_FORMAT_Z24_S8, NULL, screen->cpp,
                                  screen->depthOffset, screen->width,
                                  driDrawPriv);
          tdfxSetSpanFunctions(depthRb, mesaVis);
@@ -208,7 +205,7 @@ tdfxCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->stencilBits > 0) {
          driRenderbuffer *stencilRb
-            = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, NULL, screen->cpp,
+            = driNewRenderbuffer(MESA_FORMAT_S8, NULL, screen->cpp,
                                  screen->depthOffset, screen->width,
                                  driDrawPriv);
          tdfxSetSpanFunctions(stencilRb, mesaVis);
@@ -230,14 +227,14 @@ tdfxCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
 
 static void
-tdfxDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+tdfxDestroyBuffer(__DRIdrawable *driDrawPriv)
 {
    _mesa_reference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)), NULL);
 }
 
 
 static void
-tdfxSwapBuffers( __DRIdrawablePrivate *driDrawPriv )
+tdfxSwapBuffers( __DRIdrawable *driDrawPriv )
 
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -256,7 +253,7 @@ tdfxSwapBuffers( __DRIdrawablePrivate *driDrawPriv )
     * we have to do a glFinish (per the GLX spec).
     */
    if ( ctx ) {
-      __DRIdrawablePrivate *curDrawPriv;
+      __DRIdrawable *curDrawPriv;
       fxMesa = TDFX_CONTEXT(ctx);
       curDrawPriv = fxMesa->driContext->driDrawablePriv;
 
@@ -344,7 +341,7 @@ tdfxSwapBuffers( __DRIdrawablePrivate *driDrawPriv )
 }
 
 static const __DRIconfig **
-tdfxFillInModes(__DRIscreenPrivate *psp,
+tdfxFillInModes(__DRIscreen *psp,
                unsigned pixel_bits,
                unsigned depth_bits,
                unsigned stencil_bits,
@@ -418,19 +415,6 @@ tdfxInitScreen(__DRIscreen *psp)
                                      &psp->drm_version, & drm_expected ) )
       return NULL;
 
-   /* Calling driInitExtensions here, with a NULL context pointer,
-    * does not actually enable the extensions.  It just makes sure
-    * that all the dispatch offsets for all the extensions that
-    * *might* be enables are known.  This is needed because the
-    * dispatch offsets need to be known when _mesa_context_create is
-    * called, but we can't enable the extensions until we have a
-    * context pointer.
-    *
-    * Hello chicken.  Hello egg.  How are you two today?
-    */
-   driInitExtensions( NULL, card_extensions, GL_FALSE );
-   driInitExtensions( NULL, napalm_extensions, GL_FALSE );
-
    if (!tdfxInitDriver(psp))
       return NULL;
       
@@ -456,3 +440,10 @@ const struct __DriverAPIRec driDriverAPI = {
    .WaitForSBC      = NULL,
    .SwapBuffersMSC  = NULL
 };
+
+/* This is the table of extensions that the loader will dlsym() for. */
+PUBLIC const __DRIextension *__driDriverExtensions[] = {
+    &driCoreExtension.base,
+    &driLegacyExtension.base,
+    NULL
+};
index 5a68898b369a1d6c913ec217c8180000a2bb09bd..6aa42e866740386981f7c3b6a31a59f558e559f7 100644 (file)
@@ -61,7 +61,7 @@ typedef struct {
    int textureOffset;
    int textureSize;
 
-   __DRIscreenPrivate *driScrnPriv;
+   __DRIscreen *driScrnPriv;
    unsigned int sarea_priv_offset;
 
    /* Configuration cache with default values for all contexts */
index 6b38fa5a017b0f610f2ac92b7ea5958d775cd8d1..a17bcd952a11cdf80c9d5899249c090478653fd6 100644 (file)
@@ -47,7 +47,7 @@
 
 #define LOCAL_VARS                                                     \
    driRenderbuffer *drb = (driRenderbuffer *) rb;                      \
-   __DRIdrawablePrivate *const dPriv = drb->dPriv;                     \
+   __DRIdrawable *const dPriv = drb->dPriv;                    \
    GLuint pitch = drb->backBuffer ? info.strideInBytes                 \
      : (drb->pitch * drb->cpp);                                                \
    const GLuint bottom = dPriv->h - 1;                                 \
 
 #define HW_READ_CLIPLOOP()                                             \
       do {                                                             \
-         const __DRIdrawablePrivate *dPriv = fxMesa->driDrawable;      \
+         const __DRIdrawable *dPriv = fxMesa->driDrawable;     \
          drm_clip_rect_t *rect = dPriv->pClipRects;                    \
          int _nc = dPriv->numClipRects;                                        \
          while (_nc--) {                                               \
index 591df8a905a9db7cb9677437f023be34a3e3b710..cdb61a0ce05bfb52e6f1d501222a53cd6f1936da 100644 (file)
@@ -40,7 +40,6 @@
 
 #include "main/mtypes.h"
 #include "main/colormac.h"
-#include "main/texformat.h"
 #include "main/texstore.h"
 #include "main/teximage.h"
 
@@ -622,7 +621,7 @@ static int intersect_rect( drm_clip_rect_t *out,
 void tdfxUpdateClipping( GLcontext *ctx )
 {
    tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
-   __DRIdrawablePrivate *dPriv = fxMesa->driDrawable;
+   __DRIdrawable *dPriv = fxMesa->driDrawable;
 
    if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) {
       fprintf( stderr, "%s()\n", __FUNCTION__ );
index f6a48b3ae12a7f2fdb448ed4041eb61d9446b182..e31ae97b0234a96aa7d96f6ad526f79a801157ce 100644 (file)
@@ -42,7 +42,6 @@
 #include "main/image.h"
 #include "main/mipmap.h"
 #include "main/texcompress.h"
-#include "main/texformat.h"
 #include "main/teximage.h"
 #include "main/texstore.h"
 #include "main/texobj.h"
@@ -72,13 +71,13 @@ _mesa_halve2x2_teximage2d ( GLcontext *ctx,
    GLubyte *_d = NULL;
    GLenum _t = 0;
 
-   if (texImage->TexFormat->MesaFormat == MESA_FORMAT_RGB565) {
+   if (texImage->TexFormat == MESA_FORMAT_RGB565) {
       _t = GL_UNSIGNED_SHORT_5_6_5_REV;
       bpt = bytesPerPixel;
-   } else if (texImage->TexFormat->MesaFormat == MESA_FORMAT_ARGB4444) {
+   } else if (texImage->TexFormat == MESA_FORMAT_ARGB4444) {
       _t = GL_UNSIGNED_SHORT_4_4_4_4_REV;
       bpt = bytesPerPixel;
-   } else if (texImage->TexFormat->MesaFormat == MESA_FORMAT_ARGB1555) {
+   } else if (texImage->TexFormat == MESA_FORMAT_ARGB1555) {
       _t = GL_UNSIGNED_SHORT_1_5_5_5_REV;
       bpt = bytesPerPixel;
    }
@@ -93,13 +92,13 @@ _mesa_halve2x2_teximage2d ( GLcontext *ctx,
       }
       _s = src = MALLOC(srcRowStride * srcHeight);
       _d = dst = MALLOC(dstWidth * bytesPerPixel * dstHeight);
-      _mesa_texstore_rgba8888(ctx, 2, GL_RGBA,
-                              &_mesa_texformat_rgba8888_rev, src,
-                              0, 0, 0, /* dstX/Y/Zoffset */
-                              srcRowStride, /* dstRowStride */
-                              &dstImageOffsets,
-                              srcWidth, srcHeight, 1,
-                              texImage->_BaseFormat, _t, srcImage, &ctx->DefaultPacking);
+      _mesa_texstore(ctx, 2, GL_RGBA,
+                     MESA_FORMAT_RGBA8888_REV, src,
+                     0, 0, 0, /* dstX/Y/Zoffset */
+                     srcRowStride, /* dstRowStride */
+                     &dstImageOffsets,
+                     srcWidth, srcHeight, 1,
+                     texImage->_BaseFormat, _t, srcImage, &ctx->DefaultPacking);
    }
 
    if (srcHeight == 1) {
@@ -140,13 +139,13 @@ _mesa_halve2x2_teximage2d ( GLcontext *ctx,
    if (bpt) {
       src = _s;
       dst = _d;
-      texImage->TexFormat->StoreImage(ctx, 2, texImage->_BaseFormat,
-                                      texImage->TexFormat, dstImage,
-                                      0, 0, 0, /* dstX/Y/Zoffset */
-                                      dstWidth * bpt,
-                                      &dstImageOffsets,
-                                      dstWidth, dstHeight, 1,
-                                      GL_BGRA, CHAN_TYPE, dst, &ctx->DefaultPacking);
+      _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+                     texImage->TexFormat, dstImage,
+                     0, 0, 0, /* dstX/Y/Zoffset */
+                     dstWidth * bpt,
+                     &dstImageOffsets,
+                     dstWidth, dstHeight, 1,
+                     GL_BGRA, CHAN_TYPE, dst, &ctx->DefaultPacking);
       FREE(dst);
       FREE(src);
    }
@@ -190,7 +189,7 @@ tdfxGenerateMipmap(GLcontext *ctx, GLenum target,
    const tdfxMipMapLevel *mml;
 
    texImage = _mesa_get_tex_image(ctx, texObj, target, level);
-   assert(!texImage->IsCompressed);
+   texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
 
    mml = TDFX_TEXIMAGE_DATA(texImage);
 
@@ -760,7 +759,7 @@ fxTexusError(const char *string, FxBool fatal)
 #endif
 
 
-static const struct gl_texture_format *
+static gl_format
 tdfxChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
                            GLenum srcFormat, GLenum srcType )
 {
@@ -774,7 +773,7 @@ tdfxChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_ALPHA12:
    case GL_ALPHA16:
    case GL_COMPRESSED_ALPHA:
-      return &_mesa_texformat_a8;
+      return MESA_FORMAT_A8;
    case 1:
    case GL_LUMINANCE:
    case GL_LUMINANCE4:
@@ -782,7 +781,7 @@ tdfxChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_LUMINANCE12:
    case GL_LUMINANCE16:
    case GL_COMPRESSED_LUMINANCE:
-      return &_mesa_texformat_l8;
+      return MESA_FORMAT_L8;
    case 2:
    case GL_LUMINANCE_ALPHA:
    case GL_LUMINANCE4_ALPHA4:
@@ -792,48 +791,47 @@ tdfxChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_LUMINANCE12_ALPHA12:
    case GL_LUMINANCE16_ALPHA16:
    case GL_COMPRESSED_LUMINANCE_ALPHA:
-      return &_mesa_texformat_al88;
+      return MESA_FORMAT_AL88;
    case GL_INTENSITY:
    case GL_INTENSITY4:
    case GL_INTENSITY8:
    case GL_INTENSITY12:
    case GL_INTENSITY16:
    case GL_COMPRESSED_INTENSITY:
-      return &_mesa_texformat_i8;
+      return MESA_FORMAT_I8;
    case GL_R3_G3_B2:
    case GL_RGB4:
    case GL_RGB5:
-      return &_mesa_texformat_rgb565;
+      return MESA_FORMAT_RGB565;
    case GL_COMPRESSED_RGB:
       /* intentional fall-through */
    case 3:
    case GL_RGB:
      if ( srcFormat == GL_RGB && srcType == GL_UNSIGNED_SHORT_5_6_5 ) {
-       return &_mesa_texformat_rgb565;
+       return MESA_FORMAT_RGB565;
      }
      /* intentional fall through */
    case GL_RGB8:
    case GL_RGB10:
    case GL_RGB12:
    case GL_RGB16:
-      return (allow32bpt) ? &_mesa_texformat_argb8888
-                          : &_mesa_texformat_rgb565;
+      return (allow32bpt) ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_RGB565;
    case GL_RGBA2:
    case GL_RGBA4:
-      return &_mesa_texformat_argb4444;
+      return MESA_FORMAT_ARGB4444;
    case GL_COMPRESSED_RGBA:
       /* intentional fall-through */
    case 4:
    case GL_RGBA:
      if ( srcFormat == GL_BGRA ) {
        if ( srcType == GL_UNSIGNED_INT_8_8_8_8_REV ) {
-         return &_mesa_texformat_argb8888;
+         return MESA_FORMAT_ARGB8888;
        }
        else if ( srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV ) {
-         return &_mesa_texformat_argb4444;
+         return MESA_FORMAT_ARGB4444;
        }
        else if ( srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV ) {
-         return &_mesa_texformat_argb1555;
+         return MESA_FORMAT_ARGB1555;
        }
      }
      /* intentional fall through */
@@ -841,10 +839,9 @@ tdfxChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_RGB10_A2:
    case GL_RGBA12:
    case GL_RGBA16:
-      return allow32bpt ? &_mesa_texformat_argb8888
-                        : &_mesa_texformat_argb4444;
+      return allow32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444;
    case GL_RGB5_A1:
-      return &_mesa_texformat_argb1555;
+      return MESA_FORMAT_ARGB1555;
    case GL_COLOR_INDEX:
    case GL_COLOR_INDEX1_EXT:
    case GL_COLOR_INDEX2_EXT:
@@ -852,29 +849,29 @@ tdfxChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_COLOR_INDEX8_EXT:
    case GL_COLOR_INDEX12_EXT:
    case GL_COLOR_INDEX16_EXT:
-      return &_mesa_texformat_ci8;
+      return MESA_FORMAT_CI8;
    /* GL_EXT_texture_compression_s3tc */
    /* GL_S3_s3tc */
    case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
    case GL_RGB_S3TC:
    case GL_RGB4_S3TC:
-      return &_mesa_texformat_rgb_dxt1;
+      return MESA_FORMAT_RGB_DXT1;
    case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
-      return &_mesa_texformat_rgba_dxt1;
+      return MESA_FORMAT_RGBA_DXT1;
    case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
    case GL_RGBA_S3TC:
    case GL_RGBA4_S3TC:
-      return &_mesa_texformat_rgba_dxt3;
+      return MESA_FORMAT_RGBA_DXT3;
    case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
-      return &_mesa_texformat_rgba_dxt5;
+      return MESA_FORMAT_RGBA_DXT5;
    /* GL_3DFX_texture_compression_FXT1 */
    case GL_COMPRESSED_RGB_FXT1_3DFX:
-      return &_mesa_texformat_rgb_fxt1;
+      return MESA_FORMAT_RGB_FXT1;
    case GL_COMPRESSED_RGBA_FXT1_3DFX:
-      return &_mesa_texformat_rgba_fxt1;
+      return MESA_FORMAT_RGBA_FXT1;
    default:
       _mesa_problem(ctx, "unexpected format in tdfxChooseTextureFormat");
-      return NULL;
+      return MESA_FORMAT_NONE;
    }
 }
 
@@ -1126,7 +1123,9 @@ fetch_rgb_dxt1(const struct gl_texture_image *texImage,
     i = i * mml->wScale;
     j = j * mml->hScale;
 
+    /* XXX Get fetch func from _mesa_get_texel_fetch_func()
     _mesa_texformat_rgb_dxt1.FetchTexel2D(texImage, i, j, k, rgba);
+    */
 }
 
 
@@ -1139,7 +1138,9 @@ fetch_rgba_dxt1(const struct gl_texture_image *texImage,
     i = i * mml->wScale;
     j = j * mml->hScale;
 
+    /* XXX Get fetch func from _mesa_get_texel_fetch_func()
     _mesa_texformat_rgba_dxt1.FetchTexel2D(texImage, i, j, k, rgba);
+    */
 }
 
 
@@ -1152,7 +1153,9 @@ fetch_rgba_dxt3(const struct gl_texture_image *texImage,
     i = i * mml->wScale;
     j = j * mml->hScale;
 
+    /* XXX Get fetch func from _mesa_get_texel_fetch_func()
     _mesa_texformat_rgba_dxt3.FetchTexel2D(texImage, i, j, k, rgba);
+    */
 }
 
 
@@ -1165,7 +1168,9 @@ fetch_rgba_dxt5(const struct gl_texture_image *texImage,
     i = i * mml->wScale;
     j = j * mml->hScale;
 
+    /* XXX Get fetch func from _mesa_get_texel_fetch_func()
     _mesa_texformat_rgba_dxt5.FetchTexel2D(texImage, i, j, k, rgba);
+    */
 }
 
 
@@ -1226,20 +1231,21 @@ adjust2DRatio (GLcontext *ctx,
    GLvoid *tempImage;
    GLuint dstImageOffsets = 0;
 
-   if (!texImage->IsCompressed) {
+   if (!_mesa_is_format_compressed(texImage->TexFormat)) {
       GLubyte *destAddr;
+
       tempImage = MALLOC(width * height * texelBytes);
       if (!tempImage) {
          return GL_FALSE;
       }
 
-      texImage->TexFormat->StoreImage(ctx, 2, texImage->_BaseFormat,
-                                      texImage->TexFormat, tempImage,
-                                      0, 0, 0, /* dstX/Y/Zoffset */
-                                      width * texelBytes, /* dstRowStride */
-                                      &dstImageOffsets,
-                                      width, height, 1,
-                                      format, type, pixels, packing);
+      _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+                     texImage->TexFormat, tempImage,
+                     0, 0, 0, /* dstX/Y/Zoffset */
+                     width * texelBytes, /* dstRowStride */
+                     &dstImageOffsets,
+                     width, height, 1,
+                     format, type, pixels, packing);
 
       /* now rescale */
       /* compute address of dest subimage within the overal tex image */
@@ -1256,6 +1262,7 @@ adjust2DRatio (GLcontext *ctx,
    } else {
       const GLint rawBytes = 4;
       GLvoid *rawImage = MALLOC(width * height * rawBytes);
+
       if (!rawImage) {
          return GL_FALSE;
       }
@@ -1265,26 +1272,26 @@ adjust2DRatio (GLcontext *ctx,
          return GL_FALSE;
       }
       /* unpack image, apply transfer ops and store in rawImage */
-      _mesa_texstore_rgba8888(ctx, 2, GL_RGBA,
-                              &_mesa_texformat_rgba8888_rev, rawImage,
-                              0, 0, 0, /* dstX/Y/Zoffset */
-                              width * rawBytes, /* dstRowStride */
-                              &dstImageOffsets,
-                              width, height, 1,
-                              format, type, pixels, packing);
+      _mesa_texstore(ctx, 2, GL_RGBA,
+                     MESA_FORMAT_RGBA8888_REV, rawImage,
+                     0, 0, 0, /* dstX/Y/Zoffset */
+                     width * rawBytes, /* dstRowStride */
+                     &dstImageOffsets,
+                     width, height, 1,
+                     format, type, pixels, packing);
       _mesa_rescale_teximage2d(rawBytes,
                                width,
                                newWidth * rawBytes, /* dst stride */
                                width, height, /* src */
                                newWidth, newHeight, /* dst */
                                rawImage /*src*/, tempImage /*dst*/ );
-      texImage->TexFormat->StoreImage(ctx, 2, texImage->_BaseFormat,
-                                      texImage->TexFormat, texImage->Data,
-                                      xoffset * mml->wScale, yoffset * mml->hScale, 0, /* dstX/Y/Zoffset */
-                                      dstRowStride,
-                                      &dstImageOffsets,
-                                      newWidth, newHeight, 1,
-                                      GL_RGBA, CHAN_TYPE, tempImage, &ctx->DefaultPacking);
+      _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+                     texImage->TexFormat, texImage->Data,
+                     xoffset * mml->wScale, yoffset * mml->hScale, 0, /* dstX/Y/Zoffset */
+                     dstRowStride,
+                     &dstImageOffsets,
+                     newWidth, newHeight, 1,
+                     GL_RGBA, CHAN_TYPE, tempImage, &ctx->DefaultPacking);
       FREE(rawImage);
    }
 
@@ -1357,7 +1364,7 @@ tdfxTexImage2D(GLcontext *ctx, GLenum target, GLint level,
      * be correct, since it would mess with "compressedSize".
      * Ditto for GL_RGBA[4]_S3TC, which is always mapped to DXT3.
      */
-    if (texImage->IsCompressed) {
+    if (_mesa_is_format_compressed(texImage->TexFormat)) {
       switch (internalFormat) {
       case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
       case GL_RGB_S3TC:
@@ -1384,30 +1391,22 @@ tdfxTexImage2D(GLcontext *ctx, GLenum target, GLint level,
        }
        if (texNapalm) {
           texImage->InternalFormat = internalFormat = texNapalm;
-          texImage->IsCompressed = GL_TRUE;
+          _mesa_is_format_compressed(texImage->TexFormat) = GL_TRUE;
        }
     }
 #endif
 
-    /* choose the texture format */
-    assert(ctx->Driver.ChooseTextureFormat);
-    texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
-                                     internalFormat, format, type);
-    assert(texImage->TexFormat);
-    mesaFormat = texImage->TexFormat->MesaFormat;
+    mesaFormat = texImage->TexFormat;
     mml->glideFormat = fxGlideFormat(mesaFormat);
     ti->info.format = mml->glideFormat;
     texImage->FetchTexelc = fxFetchFunction(mesaFormat);
-    texelBytes = texImage->TexFormat->TexelBytes;
-
-    if (texImage->IsCompressed) {
-       texImage->CompressedSize = _mesa_compressed_texture_size(ctx,
-                                                               mml->width,
-                                                               mml->height,
-                                                               1,
-                                                               mesaFormat);
-       dstRowStride = _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat, mml->width);
-       texImage->Data = _mesa_alloc_texmemory(texImage->CompressedSize);
+    texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
+
+    if (_mesa_is_format_compressed(texImage->TexFormat)) {
+       GLuint compressedSize = _mesa_format_image_size(mesaFormat, mml->width,
+                                                       mml->height, 1);
+       dstRowStride = _mesa_format_row_stride(texImage->TexFormat, mml->width);
+       texImage->Data = _mesa_alloc_texmemory(compressedSize);
     } else {
        dstRowStride = mml->width * texelBytes;
        texImage->Data = _mesa_alloc_texmemory(mml->width * mml->height * texelBytes);
@@ -1437,13 +1436,13 @@ tdfxTexImage2D(GLcontext *ctx, GLenum target, GLint level,
        else {
           /* no rescaling needed */
           /* unpack image, apply transfer ops and store in texImage->Data */
-          texImage->TexFormat->StoreImage(ctx, 2, texImage->_BaseFormat,
-                                          texImage->TexFormat, texImage->Data,
-                                          0, 0, 0, /* dstX/Y/Zoffset */
-                                          dstRowStride,
-                                          texImage->ImageOffsets,
-                                          width, height, 1,
-                                          format, type, pixels, packing);
+          _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+                         texImage->TexFormat, texImage->Data,
+                         0, 0, 0, /* dstX/Y/Zoffset */
+                         dstRowStride,
+                         texImage->ImageOffsets,
+                         width, height, 1,
+                         format, type, pixels, packing);
        }
     }
 
@@ -1482,9 +1481,9 @@ tdfxTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
     assert(texImage->Data);    /* must have an existing texture image! */
     assert(texImage->_BaseFormat);
 
-    texelBytes = texImage->TexFormat->TexelBytes;
-    if (texImage->IsCompressed) {
-       dstRowStride = _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat, mml->width);
+    texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
+    if (_mesa_is_format_compressed(texImage->TexFormat)) {
+       dstRowStride = _mesa_format_row_stride(texImage->TexFormat, mml->width);
     } else {
        dstRowStride = mml->width * texelBytes;
     }
@@ -1507,13 +1506,13 @@ tdfxTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
     }
     else {
         /* no rescaling needed */
-        texImage->TexFormat->StoreImage(ctx, 2, texImage->_BaseFormat,
-                                        texImage->TexFormat, texImage->Data,
-                                        xoffset, yoffset, 0,
-                                        dstRowStride,
-                                        texImage->ImageOffsets,
-                                        width, height, 1,
-                                        format, type, pixels, packing);
+       _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+                      texImage->TexFormat, texImage->Data,
+                      xoffset, yoffset, 0,
+                      dstRowStride,
+                      texImage->ImageOffsets,
+                      width, height, 1,
+                      format, type, pixels, packing);
     }
 
     ti->reloadImages = GL_TRUE; /* signal the image needs to be reloaded */
@@ -1572,7 +1571,8 @@ tdfxCompressedTexImage2D (GLcontext *ctx, GLenum target,
     tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
     tdfxTexInfo *ti;
     tdfxMipMapLevel *mml;
-    GLuint mesaFormat;
+    gl_format mesaFormat;
+    GLuint compressedSize = 0;
 
     if (TDFX_DEBUG & DEBUG_VERBOSE_DRI) {
         fprintf(stderr, "tdfxCompressedTexImage2D: id=%d int 0x%x  %dx%d\n",
@@ -1585,8 +1585,6 @@ tdfxCompressedTexImage2D (GLcontext *ctx, GLenum target,
        return;
     }
 
-    assert(texImage->IsCompressed);
-
     ti = TDFX_TEXTURE_DATA(texObj);
     if (!ti) {
         texObj->DriverData = fxAllocTexObjData(fxMesa);
@@ -1615,28 +1613,19 @@ tdfxCompressedTexImage2D (GLcontext *ctx, GLenum target,
     mml->height = height * mml->hScale;
 
 
-    /* choose the texture format */
-    assert(ctx->Driver.ChooseTextureFormat);
-    texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
-                                           internalFormat, -1/*format*/, -1/*type*/);
-    assert(texImage->TexFormat);
-
     /* Determine the appropriate Glide texel format,
      * given the user's internal texture format hint.
      */
-    mesaFormat = texImage->TexFormat->MesaFormat;
+    mesaFormat = texImage->TexFormat;
     mml->glideFormat = fxGlideFormat(mesaFormat);
     ti->info.format = mml->glideFormat;
     texImage->FetchTexelc = fxFetchFunction(mesaFormat);
 
     /* allocate new storage for texture image, if needed */
     if (!texImage->Data) {
-       texImage->CompressedSize = _mesa_compressed_texture_size(ctx,
-                                                                mml->width,
-                                                                mml->height,
-                                                                1,
-                                                                mesaFormat);
-       texImage->Data = _mesa_alloc_texmemory(texImage->CompressedSize);
+       compressedSize = _mesa_format_image_size(mesaFormat, mml->width,
+                                                mml->height, 1);
+       texImage->Data = _mesa_alloc_texmemory(compressedSize);
        if (!texImage->Data) {
           _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
           return;
@@ -1659,10 +1648,10 @@ tdfxCompressedTexImage2D (GLcontext *ctx, GLenum target,
         *    we replicate the data over the padded area.
         * For now, we take 2) + 3) but texelfetchers will be wrong!
         */
-       const GLuint mesaFormat = texImage->TexFormat->MesaFormat;
-       GLuint srcRowStride = _mesa_compressed_row_stride(mesaFormat, width);
+       const GLuint mesaFormat = texImage->TexFormat;
+       GLuint srcRowStride = _mesa_format_row_stride(mesaFormat, width);
  
-       GLuint destRowStride = _mesa_compressed_row_stride(mesaFormat,
+       GLuint destRowStride = _mesa_format_row_stride(mesaFormat,
                                                    mml->width);
  
        _mesa_upscale_teximage2d(srcRowStride, (height+3) / 4,
@@ -1671,7 +1660,7 @@ tdfxCompressedTexImage2D (GLcontext *ctx, GLenum target,
                                 texImage->Data);
        ti->padded = GL_TRUE;
     } else {
-       MEMCPY(texImage->Data, data, texImage->CompressedSize);
+       MEMCPY(texImage->Data, data, compressedSize);
     }
 
     RevalidateTexture(ctx, texObj);
@@ -1696,7 +1685,7 @@ tdfxCompressedTexSubImage2D( GLcontext *ctx, GLenum target,
     GLint destRowStride, srcRowStride;
     GLint i, rows;
     GLubyte *dest;
-    const GLuint mesaFormat = texImage->TexFormat->MesaFormat;
+    const GLuint mesaFormat = texImage->TexFormat;
 
     if (TDFX_DEBUG & DEBUG_VERBOSE_DRI) {
         fprintf(stderr, "tdfxCompressedTexSubImage2D: id=%d\n", texObj->Name);
@@ -1707,9 +1696,9 @@ tdfxCompressedTexSubImage2D( GLcontext *ctx, GLenum target,
     mml = TDFX_TEXIMAGE_DATA(texImage);
     assert(mml);
 
-    srcRowStride = _mesa_compressed_row_stride(mesaFormat, width);
+    srcRowStride = _mesa_format_row_stride(mesaFormat, width);
 
-    destRowStride = _mesa_compressed_row_stride(mesaFormat, mml->width);
+    destRowStride = _mesa_format_row_stride(mesaFormat, mml->width);
     dest = _mesa_compressed_image_address(xoffset, yoffset, 0,
                                           mesaFormat,
                                           mml->width,
@@ -1727,9 +1716,9 @@ tdfxCompressedTexSubImage2D( GLcontext *ctx, GLenum target,
      * see fxDDCompressedTexImage2D for caveats
      */
     if (mml->wScale != 1 || mml->hScale != 1) {
-       srcRowStride = _mesa_compressed_row_stride(mesaFormat, texImage->Width);
+       srcRowStride = _mesa_format_row_stride(mesaFormat, texImage->Width);
  
-       destRowStride = _mesa_compressed_row_stride(mesaFormat, mml->width);
+       destRowStride = _mesa_format_row_stride(mesaFormat, mml->width);
        _mesa_upscale_teximage2d(srcRowStride, texImage->Height / 4,
                                 destRowStride, mml->height / 4,
                                 1, texImage->Data, destRowStride,
index bbd2c8cfee94d1563f8290341b5156eda2619ea9..3f737878ed94c8adc30a1d2cc782bf2724fb2c19 100644 (file)
@@ -1314,7 +1314,7 @@ SetupDoubleTexEnvVoodoo3(GLcontext *ctx, int tmu0,
       fxMesa->TexCombine[0].InvertRGB = FXFALSE;
       fxMesa->TexCombine[0].InvertAlpha = FXFALSE;
 
-      if ((baseFormat0 == GL_RGB) && (baseFormat0 == GL_LUMINANCE)) {
+      if ((baseFormat0 == GL_RGB) || (baseFormat0 == GL_LUMINANCE)) {
          fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_LOCAL;
          fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_NONE;
          fxMesa->AlphaCombine.Local = locala;
index 492880223284224ea4a4b00ea860b0bb21feb446..c200ba3255a2a4fcf131f2e29bded178d19a6486 100644 (file)
@@ -69,11 +69,11 @@ static void interp_extras( GLcontext *ctx,
 
    /*fprintf(stderr, "%s\n", __FUNCTION__);*/
 
-   if (VB->ColorPtr[1]) {
+   if (VB->BackfaceColorPtr) {
       INTERP_4F( t,
-                   GET_COLOR(VB->ColorPtr[1], dst),
-                   GET_COLOR(VB->ColorPtr[1], out),
-                   GET_COLOR(VB->ColorPtr[1], in) );
+                GET_COLOR(VB->BackfaceColorPtr, dst),
+                GET_COLOR(VB->BackfaceColorPtr, out),
+                GET_COLOR(VB->BackfaceColorPtr, in) );
    }
 
    if (VB->EdgeFlag) {
@@ -88,9 +88,9 @@ static void copy_pv_extras( GLcontext *ctx, GLuint dst, GLuint src )
 {
    struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
 
-   if (VB->ColorPtr[1]) {
-        COPY_4FV( GET_COLOR(VB->ColorPtr[1], dst), 
-                    GET_COLOR(VB->ColorPtr[1], src) );
+   if (VB->BackfaceColorPtr) {
+      COPY_4FV( GET_COLOR(VB->BackfaceColorPtr, dst),
+               GET_COLOR(VB->BackfaceColorPtr, src) );
    }
 
    setup_tab[TDFX_CONTEXT(ctx)->SetupIndex].copy_pv(ctx, dst, src);
index 9b780761f42f13892a2fb9e610b544676a96ec7d..19baf7d0d25ca59c55cf5e7da3aa189be23e853b 100644 (file)
@@ -58,32 +58,32 @@ static void TAG(emit)( GLcontext *ctx,
 /*     fprintf(stderr, "%s\n", __FUNCTION__); */
 
    if (IND & TDFX_TEX0_BIT) {
-      tc0_stride = VB->TexCoordPtr[tmu0_source]->stride;
-      tc0 = VB->TexCoordPtr[tmu0_source]->data;
+      tc0_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu0_source]->stride;
+      tc0 = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu0_source]->data;
       u0scale = fxMesa->sScale0;
       v0scale = fxMesa->tScale0;
       if (IND & TDFX_PTEX_BIT)
-        tc0_size = VB->TexCoordPtr[tmu0_source]->size;
+        tc0_size = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu0_source]->size;
    }
 
    if (IND & TDFX_TEX1_BIT) {
-      tc1 = VB->TexCoordPtr[tmu1_source]->data;
-      tc1_stride = VB->TexCoordPtr[tmu1_source]->stride;
+      tc1 = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu1_source]->data;
+      tc1_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu1_source]->stride;
       u1scale = fxMesa->sScale1;
       v1scale = fxMesa->tScale1;
       if (IND & TDFX_PTEX_BIT)
-        tc1_size = VB->TexCoordPtr[tmu1_source]->size;
+        tc1_size = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu1_source]->size;
    }
    
    if (IND & TDFX_RGBA_BIT) {
-      col = VB->ColorPtr[0]->data;
-      col_stride = VB->ColorPtr[0]->stride;
-      col_size = VB->ColorPtr[0]->size;
+      col = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->data;
+      col_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->stride;
+      col_size = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->size;
    }
    
    if (IND & TDFX_FOGC_BIT) {
-      fog = VB->FogCoordPtr->data;
-      fog_stride = VB->FogCoordPtr->stride;
+      fog = VB->AttribPtr[_TNL_ATTRIB_FOG]->data;
+      fog_stride = VB->AttribPtr[_TNL_ATTRIB_FOG]->stride;
    }
 
    {
@@ -168,14 +168,14 @@ static GLboolean TAG(check_tex_sizes)( GLcontext *ctx )
       struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
 
       if (IND & TDFX_TEX1_BIT) {
-        if (VB->TexCoordPtr[0] == 0)
-           VB->TexCoordPtr[0] = VB->TexCoordPtr[1];
+        if (VB->AttribPtr[_TNL_ATTRIB_TEX0] == 0)
+           VB->AttribPtr[_TNL_ATTRIB_TEX0] = VB->AttribPtr[_TNL_ATTRIB_TEX1];
         
-        if (VB->TexCoordPtr[1]->size == 4)
+        if (VB->AttribPtr[_TNL_ATTRIB_TEX1]->size == 4)
            return GL_FALSE;
       }
 
-      if (VB->TexCoordPtr[0]->size == 4)
+      if (VB->AttribPtr[_TNL_ATTRIB_TEX0]->size == 4)
         return GL_FALSE;
    }
 
diff --git a/src/mesa/drivers/dri/trident/Makefile b/src/mesa/drivers/dri/trident/Makefile
deleted file mode 100644 (file)
index 9ee24c5..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-# src/mesa/drivers/dri/trident/Makefile
-
-TOP = ../../../../..
-include $(TOP)/configs/current
-
-LIBNAME = trident_dri.so
-
-# Not yet
-# MINIGLX_SOURCES = server/trident_dri.c 
-
-DRIVER_SOURCES = \
-       trident_context.c \
-       trident_state.c \
-       trident_vb.c \
-       trident_dd.c \
-       trident_tris.c
-
-C_SOURCES = \
-       $(COMMON_SOURCES) \
-       $(DRIVER_SOURCES)
-
-ASM_SOURCES = 
-
-include ../Makefile.template
-
-symlinks:
diff --git a/src/mesa/drivers/dri/trident/trident_context.c b/src/mesa/drivers/dri/trident/trident_context.c
deleted file mode 100644 (file)
index b5126b0..0000000
+++ /dev/null
@@ -1,465 +0,0 @@
-/*
- * Copyright 2002 by Alan Hourihane, Sychdyn, North Wales, UK.
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Alan Hourihane not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Alan Hourihane makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
- *
- * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * Authors:  Alan Hourihane, <alanh@fairlite.demon.co.uk>
- *
- * Trident CyberBladeXP driver.
- *
- */
-#include "trident_dri.h"
-#include "trident_context.h"
-#include "trident_lock.h"
-
-#include "swrast/swrast.h"
-#include "swrast_setup/swrast_setup.h"
-#include "vbo/vbo.h"
-
-#include "tnl/tnl.h"
-#include "tnl/t_pipeline.h"
-
-#include "main/context.h"
-#include "main/simple_list.h"
-#include "main/matrix.h"
-#include "main/extensions.h"
-#include "main/framebuffer.h"
-#include "main/renderbuffer.h"
-#include "main/viewport.h"
-#if defined(USE_X86_ASM)
-#include "x86/common_x86_asm.h"
-#endif
-#include "main/simple_list.h"
-#include "main/mm.h"
-#include "drirenderbuffer.h"
-
-#include "drivers/common/driverfuncs.h"
-#include "dri_util.h"
-#include "utils.h"
-
-static const struct tnl_pipeline_stage *trident_pipeline[] = {
-   &_tnl_vertex_transform_stage, 
-   &_tnl_normal_transform_stage, 
-   &_tnl_lighting_stage,
-   &_tnl_texgen_stage, 
-   &_tnl_texture_transform_stage, 
-   &_tnl_render_stage,         
-   0,
-};
-
-
-static GLboolean
-tridentCreateContext( const __GLcontextModes *glVisual,
-                      __DRIcontextPrivate *driContextPriv,
-                      void *sharedContextPrivate)
-{
-   GLcontext *ctx, *shareCtx;
-   __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
-   tridentContextPtr tmesa;
-   tridentScreenPtr tridentscrn;
-   struct dd_function_table functions;
-#if 0
-   drm_trident_sarea_t *saPriv=(drm_trident_sarea_t *)(((char*)sPriv->pSAREA)+
-                                                sizeof(XF86DRISAREARec));
-#endif
-
-   tmesa = (tridentContextPtr) CALLOC( sizeof(*tmesa) );
-   if ( !tmesa ) return GL_FALSE;
-
-   /* Allocate the Mesa context */
-   if (sharedContextPrivate)
-      shareCtx = ((tridentContextPtr) sharedContextPrivate)->glCtx;
-   else
-      shareCtx = NULL;
-
-   _mesa_init_driver_functions(&functions);
-
-   tmesa->glCtx =
-      _mesa_create_context(glVisual, shareCtx, &functions, (void *)tmesa);
-
-   if (!tmesa->glCtx) {
-      FREE(tmesa);
-      return GL_FALSE;
-   }
-
-   tmesa->driContext = driContextPriv;
-   tmesa->driScreen = sPriv;
-   tmesa->driDrawable = NULL; /* Set by XMesaMakeCurrent */
-
-   tmesa->hHWContext = driContextPriv->hHWContext;
-   tmesa->driHwLock = (drmLock *)&sPriv->pSAREA->lock;
-   tmesa->driFd = sPriv->fd;
-#if 0
-   tmesa->sarea = saPriv;
-#endif
-
-   tridentscrn = tmesa->tridentScreen = (tridentScreenPtr)(sPriv->private);
-
-   ctx = tmesa->glCtx;
-
-   ctx->Const.MaxTextureLevels = 13;  /* 4K by 4K?  Is that right? */
-   ctx->Const.MaxTextureUnits = 1; /* Permedia 3 */
-
-   ctx->Const.MinLineWidth = 0.0;
-   ctx->Const.MaxLineWidth = 255.0;
-
-   ctx->Const.MinLineWidthAA = 0.0;
-   ctx->Const.MaxLineWidthAA = 65536.0;
-
-   ctx->Const.MinPointSize = 0.0;
-   ctx->Const.MaxPointSize = 255.0;
-
-   ctx->Const.MinPointSizeAA = 0.5; /* 4x4 quality mode */
-   ctx->Const.MaxPointSizeAA = 16.0; 
-   ctx->Const.PointSizeGranularity = 0.25;
-
-   ctx->Const.MaxDrawBuffers = 1;
-
-#if 0
-   tmesa->texHeap = mmInit( 0, tmesa->tridentScreen->textureSize );
-
-   make_empty_list(&tmesa->TexObjList);
-   make_empty_list(&tmesa->SwappedOut);
-
-   tmesa->CurrentTexObj[0] = 0;
-   tmesa->CurrentTexObj[1] = 0; /* Permedia 3, second texture */
-
-   tmesa->RenderIndex = ~0;
-#endif
-
-   /* Initialize the software rasterizer and helper modules.
-    */
-   _swrast_CreateContext( ctx );
-   _vbo_CreateContext( ctx );
-   _tnl_CreateContext( ctx );
-   _swsetup_CreateContext( ctx );
-
-   /* Install the customized pipeline:
-    */
-   _tnl_destroy_pipeline( ctx );
-   _tnl_install_pipeline( ctx, trident_pipeline );
-
-   /* Configure swrast to match hardware characteristics:
-    */
-   _swrast_allow_pixel_fog( ctx, GL_FALSE );
-   _swrast_allow_vertex_fog( ctx, GL_TRUE );
-
-   tridentInitVB( ctx );
-   tridentDDInitExtensions( ctx );
-   tridentDDInitDriverFuncs( ctx );
-   tridentDDInitStateFuncs( ctx );
-#if 0
-   tridentDDInitSpanFuncs( ctx );
-   tridentDDInitTextureFuncs( ctx );
-#endif
-   tridentDDInitTriFuncs( ctx );
-   tridentDDInitState( tmesa );
-
-   driContextPriv->driverPrivate = (void *)tmesa;
-
-   UNLOCK_HARDWARE(tmesa);
-
-   return GL_TRUE;
-}
-
-static void 
-tridentDestroyContext(__DRIcontextPrivate *driContextPriv)
-{
-    tridentContextPtr tmesa = (tridentContextPtr)driContextPriv->driverPrivate;
-
-    if (tmesa) {
-      _swsetup_DestroyContext( tmesa->glCtx );
-      _tnl_DestroyContext( tmesa->glCtx );
-      _vbo_DestroyContext( tmesa->glCtx );
-      _swrast_DestroyContext( tmesa->glCtx );
-
-      /* free the Mesa context */
-      tmesa->glCtx->DriverCtx = NULL;
-      _mesa_destroy_context(tmesa->glCtx);
-
-      _mesa_free(tmesa);
-      driContextPriv->driverPrivate = NULL;
-    }
-}
-
-
-static GLboolean
-tridentCreateBuffer( __DRIscreenPrivate *driScrnPriv,
-                   __DRIdrawablePrivate *driDrawPriv,
-                   const __GLcontextModes *mesaVis,
-                   GLboolean isPixmap )
-{
-   tridentScreenPtr screen = (tridentScreenPtr) driScrnPriv->private;
-
-   if (isPixmap) {
-      return GL_FALSE; /* not implemented */
-   }
-   else {
-      struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
-
-      {
-         driRenderbuffer *frontRb
-            = driNewRenderbuffer(GL_RGBA, NULL, screen->cpp,
-                                 screen->frontOffset, screen->frontPitch,
-                                 driDrawPriv);
-         /*
-         tridentSetSpanFunctions(frontRb, mesaVis);
-         */
-         _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
-      }
-
-      if (mesaVis->doubleBufferMode) {
-         driRenderbuffer *backRb
-            = driNewRenderbuffer(GL_RGBA, NULL, screen->cpp,
-                                 screen->backOffset, screen->backPitch,
-                                 driDrawPriv);
-         /*
-         tridentSetSpanFunctions(backRb, mesaVis);
-         */
-         _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
-      }
-
-      if (mesaVis->depthBits == 16) {
-         driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT16, NULL, screen->cpp,
-                                 screen->depthOffset, screen->depthPitch,
-                                 driDrawPriv);
-         /*
-         tridentSetSpanFunctions(depthRb, mesaVis);
-         */
-         _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
-      }
-      else if (mesaVis->depthBits == 24) {
-         driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT24, NULL, screen->cpp,
-                                 screen->depthOffset, screen->depthPitch,
-                                 driDrawPriv);
-         /*
-         tridentSetSpanFunctions(depthRb, mesaVis);
-         */
-         _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
-      }
-
-      /* no h/w stencil?
-      if (mesaVis->stencilBits > 0 && !swStencil) {
-         driRenderbuffer *stencilRb
-            = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT);
-         tridentSetSpanFunctions(stencilRb, mesaVis);
-         _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
-      }
-      */
-
-      _mesa_add_soft_renderbuffers(fb,
-                                   GL_FALSE, /* color */
-                                   GL_FALSE, /* depth */
-                                   mesaVis->stencilBits > 0,
-                                   mesaVis->accumRedBits > 0,
-                                   GL_FALSE, /* alpha */
-                                   GL_FALSE /* aux */);
-      driDrawPriv->driverPrivate = (void *) fb;
-
-      return (driDrawPriv->driverPrivate != NULL);
-   }
-}
-
-
-static void
-tridentDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
-{
-   _mesa_reference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)), NULL);
-}
-
-static void
-tridentSwapBuffers(__DRIdrawablePrivate *drawablePrivate)
-{
-   __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate;
-
-   if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
-      tridentContextPtr tmesa;
-      GLcontext *ctx;
-      tmesa = (tridentContextPtr) dPriv->driContextPriv->driverPrivate;
-      ctx = tmesa->glCtx;
-      if (ctx->Visual.doubleBufferMode) {
-         _mesa_notifySwapBuffers( ctx );  /* flush pending rendering comands */
-         tridentCopyBuffer( dPriv );
-      }
-   }
-   else {
-      /* XXX this shouldn't be an error but we can't handle it for now */
-      _mesa_problem(NULL, "tridentSwapBuffers: drawable has no context!\n");
-   }
-}
-
-static GLboolean 
-tridentMakeCurrent(__DRIcontextPrivate *driContextPriv,
-                __DRIdrawablePrivate *driDrawPriv,
-                __DRIdrawablePrivate *driReadPriv)
-{
-    if (driContextPriv) {
-       GET_CURRENT_CONTEXT(ctx);
-       tridentContextPtr oldCtx = ctx ? TRIDENT_CONTEXT(ctx) : NULL;
-       tridentContextPtr newCtx = (tridentContextPtr) driContextPriv->driverPrivate;
-
-       if ( newCtx != oldCtx ) {
-           newCtx->dirty = ~0;
-       }
-
-       if (newCtx->driDrawable != driDrawPriv) {
-           newCtx->driDrawable = driDrawPriv;
-#if 0
-           tridentUpdateWindow ( newCtx->glCtx );
-           tridentUpdateViewportOffset( newCtx->glCtx );
-#endif
-       }
-
-   newCtx->drawOffset = newCtx->tridentScreen->backOffset;
-   newCtx->drawPitch = newCtx->tridentScreen->backPitch;
-
-       _mesa_make_current( newCtx->glCtx, 
-                            (GLframebuffer *) driDrawPriv->driverPrivate,
-                            (GLframebuffer *) driReadPriv->driverPrivate );
-
-       if (!newCtx->glCtx->Viewport.Width) {
-           _mesa_set_viewport(newCtx->glCtx, 0, 0, 
-                                       driDrawPriv->w, driDrawPriv->h);
-       }
-    } else {
-       _mesa_make_current( NULL, NULL, NULL );
-    }
-    return GL_TRUE;
-}
-
-
-static GLboolean 
-tridentUnbindContext( __DRIcontextPrivate *driContextPriv )
-{
-   return GL_TRUE;
-}
-
-
-static tridentScreenPtr
-tridentCreateScreen( __DRIscreenPrivate *sPriv )
-{
-   TRIDENTDRIPtr tDRIPriv = (TRIDENTDRIPtr)sPriv->pDevPriv;
-   tridentScreenPtr tridentScreen;
-
-   if (sPriv->devPrivSize != sizeof(TRIDENTDRIRec)) {
-      fprintf(stderr,"\nERROR!  sizeof(TRIDENTDRIRec) does not match passed size from device driver\n");
-      return GL_FALSE;
-   }
-
-    /* Allocate the private area */
-    tridentScreen = (tridentScreenPtr) CALLOC( sizeof(*tridentScreen) );
-    if ( !tridentScreen ) return NULL;
-
-   tridentScreen->driScreen = sPriv;
-
-   tridentScreen->frontOffset = tDRIPriv->frontOffset;
-   tridentScreen->backOffset = tDRIPriv->backOffset;
-   tridentScreen->depthOffset = tDRIPriv->depthOffset;
-   tridentScreen->frontPitch = tDRIPriv->frontPitch;
-   tridentScreen->backPitch = tDRIPriv->backPitch;
-   tridentScreen->depthPitch = tDRIPriv->depthPitch;
-   tridentScreen->width = tDRIPriv->width;
-   tridentScreen->height = tDRIPriv->height;
-
-printf("%d %d\n",tridentScreen->width,tridentScreen->height);
-printf("%d %d\n",tridentScreen->frontPitch,tridentScreen->backPitch);
-printf("offset 0x%x 0x%x\n",tridentScreen->backOffset,tridentScreen->depthOffset);
-
-   tridentScreen->mmio.handle = tDRIPriv->regs;
-   tridentScreen->mmio.size = 0x20000;
-    
-   if (drmMap(sPriv->fd,
-               tridentScreen->mmio.handle, tridentScreen->mmio.size,
-               (drmAddressPtr)&tridentScreen->mmio.map)) {
-           FREE(tridentScreen);
-           return GL_FALSE;
-    }
-printf("MAPPED at %p\n", tridentScreen->mmio.map);
-
-   return tridentScreen;
-}
-
-/* Destroy the device specific screen private data struct.
- */
-static void
-tridentDestroyScreen( __DRIscreenPrivate *sPriv )
-{
-    tridentScreenPtr tridentScreen = (tridentScreenPtr)sPriv->private;
-
-    FREE(tridentScreen);
-}
-
-static GLboolean 
-tridentInitDriver(__DRIscreenPrivate *sPriv)
-{
-    sPriv->private = (void *) tridentCreateScreen( sPriv );
-
-    if (!sPriv->private) {
-       tridentDestroyScreen( sPriv );
-       return GL_FALSE;
-    }
-
-    return GL_TRUE;
-}
-
-/**
- * This is the driver specific part of the createNewScreen entry point.
- * 
- * \todo maybe fold this into intelInitDriver
- *
- * \return the __GLcontextModes supported by this driver
- */
-const __DRIconfig **tridentInitScreen(__DRIscreenPrivate *psp)
-{
-   static const __DRIversion ddx_expected = { 4, 0, 0 };
-   static const __DRIversion dri_expected = { 3, 1, 0 };
-   static const __DRIversion drm_expected = { 1, 0, 0 };
-   
-   if ( ! driCheckDriDdxDrmVersions2( "Trident",
-                                     &psp->dri_version, & dri_expected,
-                                     &psp->ddx_version, & ddx_expected,
-                                     &psp->drm_version, & drm_expected ) )
-      return NULL;
-
-   if (!tridentInitDriver(psp))
-       return NULL;
-
-    /* Wait... what?  This driver doesn't report any modes... */
-#if 0
-   TRIDENTDRIPtr dri_priv = (TRIDENTDRIPtr) psp->pDevPriv;
-   *driver_modes = tridentFillInModes( dri_priv->bytesPerPixel * 8,
-                                      GL_TRUE );
-#endif
-
-   return NULL;
-}
-
-const struct __DriverAPIRec driDriverAPI = {
-   tridentInitScreen,
-   tridentDestroyScreen,
-   tridentCreateContext,
-   tridentDestroyContext,
-   tridentCreateBuffer,
-   tridentDestroyBuffer,
-   tridentSwapBuffers,
-   tridentMakeCurrent,
-   tridentUnbindContext,
-};
diff --git a/src/mesa/drivers/dri/trident/trident_context.h b/src/mesa/drivers/dri/trident/trident_context.h
deleted file mode 100644 (file)
index fbbb4a9..0000000
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Copyright 2002 by Alan Hourihane, Sychdyn, North Wales, UK.
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Alan Hourihane not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Alan Hourihane makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
- *
- * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * Authors:  Alan Hourihane, <alanh@fairlite.demon.co.uk>
- *
- * Trident CyberBladeXP driver.
- *
- */
-#ifndef _TRIDENT_CONTEXT_H_
-#define _TRIDENT_CONTEXT_H_
-
-#include "dri_util.h"
-#include "main/macros.h"
-#include "main/mtypes.h"
-#include "drm.h"
-#include "main/mm.h"
-
-#define SUBPIXEL_X (0.0F)
-#define SUBPIXEL_Y (0.125F)
-
-#define _TRIDENT_NEW_VERTEX (_NEW_TEXTURE |            \
-                          _DD_NEW_TRI_UNFILLED |       \
-                          _DD_NEW_TRI_LIGHT_TWOSIDE)
-
-#define TRIDENT_FALLBACK_TEXTURE       0x01
-#define TRIDENT_FALLBACK_DRAW_BUFFER   0x02
-
-#define TRIDENT_NEW_CLIP               0x01
-
-#define TRIDENT_UPLOAD_COMMAND_D       0x00000001
-#define TRIDENT_UPLOAD_CONTEXT         0x04000000
-#define TRIDENT_UPLOAD_CLIPRECTS       0x80000000
-
-#define TAG(x) trident##x
-#include "tnl_dd/t_dd_vertex.h"
-#undef TAG
-
-/* these require that base be dword-aligned */
-static INLINE void MMIO_OUT32(unsigned char *base, unsigned int offset,
-                              unsigned int val)
-{
-    unsigned int *addr = (unsigned int *)(base + offset);
-    *addr = val;
-}
-
-static INLINE unsigned int MMIO_IN32(unsigned char *base, unsigned int offset)
-{
-    unsigned int *addr = (unsigned int *)(base + offset);
-    return *addr;
-}
-
-#define MMIO_OUT8(base, offset, val) *((base) + (offset)) = (val)
-#define MMIO_IN8(base, offset) *((base) + (offset))
-
-struct trident_context;
-typedef struct trident_context tridentContextRec;
-typedef struct trident_context *tridentContextPtr;
-
-typedef void (*trident_quad_func)( tridentContextPtr, 
-                                const tridentVertex *, 
-                                const tridentVertex *,
-                                const tridentVertex *,
-                                const tridentVertex * );
-typedef void (*trident_tri_func)( tridentContextPtr, 
-                               const tridentVertex *, 
-                               const tridentVertex *,
-                               const tridentVertex * );
-typedef void (*trident_line_func)( tridentContextPtr, 
-                                const tridentVertex *, 
-                                const tridentVertex * );
-typedef void (*trident_point_func)( tridentContextPtr, 
-                                 const tridentVertex * );
-
-typedef struct {
-   drm_handle_t handle;                        /* Handle to the DRM region */
-   drmSize size;                       /* Size of the DRM region */
-   unsigned char *map;                 /* Mapping of the DRM region */
-} tridentRegionRec, *tridentRegionPtr;
-
-typedef struct {
-    __DRIscreenPrivate *driScreen; /* Back pointer to DRI screen */
-
-    drmBufMapPtr buffers;
-
-    unsigned int frontOffset;
-    unsigned int frontPitch;
-    unsigned int backOffset;
-    unsigned int backPitch;
-    unsigned int depthOffset;
-    unsigned int depthPitch;
-    unsigned int width;
-    unsigned int height;
-    unsigned int cpp;
-
-#if 0
-    unsigned int sarea_priv_offset;
-#endif
-
-    tridentRegionRec mmio;
-} tridentScreenRec, *tridentScreenPtr;
-
-/**
- * tridentRenderbuffer, derived from Mesa's gl_renderbuffer
- */
-typedef struct {
-   struct gl_renderbuffer Base;
-   /* XXX per-window info should go here */
-   int foo, bar;
-} tridentRenderbuffer;
-
-
-struct trident_context {
-       GLcontext               *glCtx;         /* Mesa context */
-
-       __DRIcontextPrivate     *driContext;
-       __DRIscreenPrivate      *driScreen;
-       __DRIdrawablePrivate    *driDrawable;
-
-       GLuint                  new_gl_state;
-       GLuint                  new_state;
-       GLuint                  dirty;
-
-#if 0
-       drm_trident_sarea_t     *sarea; 
-#endif
-
-        /* Temporaries for translating away float colors:
-        */
-        struct gl_client_array UbyteColor;
-        struct gl_client_array UbyteSecondaryColor;
-
-       /* Mirrors of some DRI state
-        */
-       int lastStamp;                  /* mirror driDrawable->lastStamp */
-
-       drm_context_t hHWContext;
-       drmLock *driHwLock;
-       int driFd;
-
-       tridentScreenPtr tridentScreen; /* Screen private DRI data */
-
-       /* Visual, drawable, cliprect and scissor information
-        */
-       GLenum DrawBuffer;
-       GLint drawOffset, drawPitch;
-       GLint drawX, drawY;             /* origin of drawable in draw buffer */
-       GLint readOffset, readPitch;
-
-       GLuint numClipRects;            /* Cliprects for the draw buffer */
-       drm_clip_rect_t *pClipRects;
-
-       GLint scissor;
-       drm_clip_rect_t ScissorRect;    /* Current software scissor */
-
-       GLuint Fallback;
-       GLuint RenderIndex;
-       GLuint SetupNewInputs;
-       GLuint SetupIndex;
-       GLfloat hw_viewport[16];
-       GLfloat depth_scale;
-       GLuint vertex_format;
-       GLuint vertex_size;
-       GLuint vertex_stride_shift;
-       GLubyte *verts;
-
-       GLint tmu_source[2];
-
-       GLuint hw_primitive;
-       GLenum render_primitive;
-
-       trident_point_func    draw_point;
-       trident_line_func     draw_line;
-       trident_tri_func      draw_tri;
-       trident_quad_func     draw_quad;
-
-#if 0
-       gammaTextureObjectPtr CurrentTexObj[2];
-       struct gamma_texture_object_t TexObjList;
-       struct gamma_texture_object_t SwappedOut; 
-       GLenum TexEnvImageFmt[2];
-
-       struct mem_block *texHeap;
-
-       int lastSwap;
-       int texAge;
-       int ctxAge;
-       int dirtyAge;
-        int lastStamp;
-#endif
-
-       /* Chip state */
-       
-       int     commandD;
-
-       /* Context State */
-       
-       int     ClearColor;
-};
-
-void tridentDDInitExtensions( GLcontext *ctx );
-void tridentDDInitDriverFuncs( GLcontext *ctx );
-void tridentDDInitSpanFuncs( GLcontext *ctx );
-void tridentDDInitState( tridentContextPtr tmesa );
-void tridentInitHW( tridentContextPtr tmesa );
-void tridentDDInitStateFuncs( GLcontext *ctx );
-void tridentDDInitTextureFuncs( GLcontext *ctx );
-void tridentDDInitTriFuncs( GLcontext *ctx );
-
-extern void tridentBuildVertices( GLcontext *ctx, 
-                               GLuint start, 
-                               GLuint count,
-                               GLuint newinputs );
-extern void tridentInitVB( GLcontext *ctx );
-extern void tridentCopyBuffer( const __DRIdrawablePrivate *dPriv );
-extern void tridentFallback( tridentContextPtr tmesa, GLuint bit,
-                             GLboolean mode );
-extern void tridentCheckTexSizes( GLcontext *ctx );
-extern void tridentChooseVertexState( GLcontext *ctx );
-extern void tridentDDUpdateHWState( GLcontext *ctx );
-extern void tridentUploadHwStateLocked( tridentContextPtr tmesa );
-
-#define TRIDENT_CONTEXT(ctx)           ((tridentContextPtr)(ctx->DriverCtx))
-
-#endif /* _TRIDENT_CONTEXT_H_ */
diff --git a/src/mesa/drivers/dri/trident/trident_dd.c b/src/mesa/drivers/dri/trident/trident_dd.c
deleted file mode 100644 (file)
index faa40c3..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright 2002 by Alan Hourihane, Sychdyn, North Wales, UK.
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Alan Hourihane not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Alan Hourihane makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
- *
- * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * Authors:  Alan Hourihane, <alanh@fairlite.demon.co.uk>
- *
- * Trident CyberBladeXP driver.
- *
- */
-#include "trident_context.h"
-#include "trident_lock.h"
-#if defined(USE_X86_ASM)
-#include "x86/common_x86_asm.h"
-#endif
-
-#include "swrast/swrast.h"
-#include "main/context.h"
-#include "main/framebuffer.h"
-
-#define TRIDENT_DATE   "20041223"
-
-/* Return the width and height of the current color buffer.
- */
-static void tridentDDGetBufferSize( GLframebuffer *framebuffer,
-                                GLuint *width, GLuint *height )
-{
-   GET_CURRENT_CONTEXT(ctx);
-   tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
-
-   LOCK_HARDWARE(tmesa);
-   *width  = tmesa->driDrawable->w;
-   *height = tmesa->driDrawable->h;
-   UNLOCK_HARDWARE(tmesa);
-}
-
-
-/* Return various strings for glGetString().
- */
-static const GLubyte *tridentDDGetString( GLcontext *ctx, GLenum name )
-{
-   static char buffer[128];
-
-   switch ( name ) {
-   case GL_VENDOR:
-      return (GLubyte *)"Alan Hourihane";
-
-   case GL_RENDERER:
-      sprintf( buffer, "Mesa DRI Trident " TRIDENT_DATE );
-
-      /* Append any CPU-specific information.
-       */
-#ifdef USE_X86_ASM
-      if ( _mesa_x86_cpu_features ) {
-        strncat( buffer, " x86", 4 );
-      }
-#ifdef USE_MMX_ASM
-      if ( cpu_has_mmx ) {
-        strncat( buffer, "/MMX", 4 );
-      }
-#endif
-#ifdef USE_3DNOW_ASM
-      if ( cpu_has_3dnow ) {
-        strncat( buffer, "/3DNow!", 7 );
-      }
-#endif
-#ifdef USE_SSE_ASM
-      if ( cpu_has_xmm ) {
-        strncat( buffer, "/SSE", 4 );
-      }
-#endif
-#endif
-      return (GLubyte *)buffer;
-
-   default:
-      return NULL;
-   }
-}
-
-/* Enable the extensions supported by this driver.
- */
-void tridentDDInitExtensions( GLcontext *ctx )
-{
-   /* None... */
-}
-
-/* Initialize the driver's misc functions.
- */
-void tridentDDInitDriverFuncs( GLcontext *ctx )
-{
-   ctx->Driver.GetBufferSize = tridentDDGetBufferSize;
-   ctx->Driver.GetString = tridentDDGetString;
-   ctx->Driver.Error = NULL;
-}
diff --git a/src/mesa/drivers/dri/trident/trident_dri.h b/src/mesa/drivers/dri/trident/trident_dri.h
deleted file mode 100644 (file)
index c1ce3c4..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef _TRIDENT_DRI_
-#define _TRIDENT_DRI_
-
-#include "xf86drm.h"
-
-typedef struct {
-  drm_handle_t regs;
-  drmSize regsSize;
-  drmAddress regsMap;
-  int deviceID;
-  int width;
-  int height;
-  int mem;
-  int frontOffset;
-  int frontPitch;
-  int backOffset;
-  int backPitch;
-  int depthOffset;
-  int depthPitch;
-  int cpp;
-#if 0
-  int textureOffset;
-  int textureSize;
-#endif
-  unsigned int sarea_priv_offset;
-} TRIDENTDRIRec, *TRIDENTDRIPtr;
-
-#endif
diff --git a/src/mesa/drivers/dri/trident/trident_lock.h b/src/mesa/drivers/dri/trident/trident_lock.h
deleted file mode 100644 (file)
index ee0819f..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-/* XXX tridentGetLock doesn't exist... */
-
-#define LOCK_HARDWARE(tmesa) \
-    do { \
-        char __ret = 0; \
-        DRM_CAS(tmesa->driHwLock, tmesa->hHWContext, \
-            DRM_LOCK_HELD | tmesa->hHWContext, __ret); \
-    } while (0)
-
-#define UNLOCK_HARDWARE(tmesa) \
-    DRM_UNLOCK(tmesa->driFd, tmesa->driHwLock, tmesa->hHWContext)
diff --git a/src/mesa/drivers/dri/trident/trident_state.c b/src/mesa/drivers/dri/trident/trident_state.c
deleted file mode 100644 (file)
index e68d3a7..0000000
+++ /dev/null
@@ -1,548 +0,0 @@
-/*
- * Copyright 2002 by Alan Hourihane, Sychdyn, North Wales, UK.
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Alan Hourihane not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Alan Hourihane makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
- *
- * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * Authors:  Alan Hourihane, <alanh@fairlite.demon.co.uk>
- *
- * Trident CyberBladeXP driver.
- *
- */
-#include "trident_context.h"
-#include "trident_lock.h"
-#include "vbo/vbo.h"
-#include "swrast/swrast.h"
-#include "swrast_setup/swrast_setup.h"
-#include "tnl/tnl.h"
-#include "main/framebuffer.h"
-
-#define TRIDENTPACKCOLOR332(r, g, b)                                   \
-   (((r) & 0xe0) | (((g) & 0xe0) >> 3) | (((b) & 0xc0) >> 6))
-
-#define TRIDENTPACKCOLOR1555(r, g, b, a)                                       \
-   ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) |  \
-    ((a) ? 0x8000 : 0))
-
-#define TRIDENTPACKCOLOR565(r, g, b)                                   \
-   ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
-
-#define TRIDENTPACKCOLOR888(r, g, b)                                   \
-   (((r) << 16) | ((g) << 8) | (b))
-
-#define TRIDENTPACKCOLOR8888(r, g, b, a)                                       \
-   (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
-
-#define TRIDENTPACKCOLOR4444(r, g, b, a)                                       \
-   ((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4))
-
-static INLINE GLuint tridentPackColor( GLuint cpp,
-                                       GLubyte r, GLubyte g,
-                                       GLubyte b, GLubyte a )
-{
-   switch ( cpp ) {
-   case 2:
-      return TRIDENTPACKCOLOR565( r, g, b );
-   case 4:
-      return TRIDENTPACKCOLOR8888( r, g, b, a );
-   default:
-      return 0;
-   }
-}
-
-void tridentUploadHwStateLocked( tridentContextPtr tmesa )
-{
-   unsigned char *MMIO = tmesa->tridentScreen->mmio.map;
-#if 0
-   ATISAREAPrivPtr sarea = tmesa->sarea;
-   trident_context_regs_t *regs = &(sarea->ContextState);
-#endif
-
-   if ( tmesa->dirty & TRIDENT_UPLOAD_COMMAND_D ) {
-      MMIO_OUT32(MMIO, 0x00281C, tmesa->commandD );
-      tmesa->dirty &= ~TRIDENT_UPLOAD_COMMAND_D;
-   }
-
-   if ( tmesa->dirty & TRIDENT_UPLOAD_CLIPRECTS ) {
-      /* XXX FIX ME ! */
-      MMIO_OUT32(MMIO, 0x002C80 , 0x20008000 | tmesa->tridentScreen->height );    
-      MMIO_OUT32(MMIO, 0x002C84 , 0x20000000 | tmesa->tridentScreen->width );    
-      tmesa->dirty &= ~TRIDENT_UPLOAD_CLIPRECTS;
-   }
-
-   tmesa->dirty = 0;
-}
-
-/* Copy the back color buffer to the front color buffer.
- */
-void tridentCopyBuffer( const __DRIdrawablePrivate *dPriv )
-{
-   unsigned char *MMIO;
-   tridentContextPtr tmesa;
-   GLint nbox, i;
-   int busy;
-   drm_clip_rect_t *pbox;
-
-   assert(dPriv);
-   assert(dPriv->driContextPriv);
-   assert(dPriv->driContextPriv->driverPrivate);
-
-   tmesa = (tridentContextPtr) dPriv->driContextPriv->driverPrivate;
-   MMIO = tmesa->tridentScreen->mmio.map;
-
-   LOCK_HARDWARE( tmesa );
-
-   /* use front buffer cliprects */
-   nbox = dPriv->numClipRects;
-   pbox = dPriv->pClipRects;
-
-   for ( i = 0 ; i < nbox ; i++ ) {
-#if 0
-      GLint nr = MIN2( i + MACH64_NR_SAREA_CLIPRECTS , nbox );
-      drm_clip_rect_t *b = tmesa->sarea->boxes;
-      GLint n = 0;
-
-      for ( ; i < nr ; i++ ) {
-        *b++ = pbox[i];
-        n++;
-      }
-      tmesa->sarea->nbox = n;
-#endif
-
-    MMIO_OUT32(MMIO, 0x2150, tmesa->tridentScreen->frontPitch << 20 | tmesa->tridentScreen->frontOffset>>4);
-    MMIO_OUT32(MMIO, 0x2154, tmesa->tridentScreen->backPitch << 20 | tmesa->tridentScreen->backOffset>>4);
-    MMIO_OUT8(MMIO, 0x2127, 0xCC); /* Copy Rop */
-    MMIO_OUT32(MMIO, 0x2128, 0x4); /* scr2scr */
-    MMIO_OUT32(MMIO, 0x2138, (pbox->x1 << 16) | pbox->y1);
-    MMIO_OUT32(MMIO, 0x213C, (pbox->x1 << 16) | pbox->y1);
-    MMIO_OUT32(MMIO, 0x2140, (pbox->x2 - pbox->x1) << 16 | (pbox->y2 - pbox->y1) );
-    MMIO_OUT8(MMIO, 0x2124, 0x01); /* BLT */
-#define GE_BUSY 0x80
-    for (;;) {
-       busy = MMIO_IN8(MMIO, 0x2120);
-       if ( !(busy & GE_BUSY) )
-               break;
-    }
-   }
-
-   UNLOCK_HARDWARE( tmesa );
-
-#if 0
-   tmesa->dirty |= (MACH64_UPLOAD_CONTEXT |
-                   MACH64_UPLOAD_MISC |
-                   MACH64_UPLOAD_CLIPRECTS);
-#endif
-}
-
-
-static void tridentDDClear( GLcontext *ctx, GLbitfield mask )
-{
-   tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
-   unsigned char *MMIO = tmesa->tridentScreen->mmio.map;
-   int busy;
-   GLuint flags = 0;
-   GLint i;
-   GLint cx, cy, cw, ch;
-
-#define DRM_TRIDENT_FRONT      0x01
-#define DRM_TRIDENT_BACK       0x02
-#define DRM_TRIDENT_DEPTH      0x04
-
-   if ( tmesa->new_state )
-      tridentDDUpdateHWState( ctx );
-
-   if ( mask & BUFFER_BIT_FRONT_LEFT ) {
-      flags |= DRM_TRIDENT_FRONT;
-      mask &= ~BUFFER_BIT_FRONT_LEFT;
-   }
-
-   if ( mask & BUFFER_BIT_BACK_LEFT ) {
-      flags |= DRM_TRIDENT_BACK;
-      mask &= ~BUFFER_BIT_BACK_LEFT;
-   }
-
-   if ( ( mask & BUFFER_BIT_DEPTH ) && ctx->Depth.Mask ) {
-      flags |= DRM_TRIDENT_DEPTH;
-      mask &= ~BUFFER_BIT_DEPTH;
-   }
-
-   LOCK_HARDWARE(tmesa);
-
-   /* get region after locking: */
-   cx = ctx->DrawBuffer->_Xmin;
-   cy = ctx->DrawBuffer->_Ymin;
-   cw = ctx->DrawBuffer->_Xmax - cx;
-   ch = ctx->DrawBuffer->_Ymax - cy;
-
-   if ( flags ) {
-   
-      cx += tmesa->drawX;
-      cy += tmesa->drawY;
-   
-      /* HACK!!!
-       */
-      if ( tmesa->dirty & ~TRIDENT_UPLOAD_CLIPRECTS ) {
-         tridentUploadHwStateLocked( tmesa );
-      }
-   
-      for ( i = 0 ; i < tmesa->numClipRects ; i++ ) {
-#if 0
-         int nr = MIN2( i + TRIDENT_NR_SAREA_CLIPRECTS, tmesa->numClipRects );
-         drm_clip_rect_t *box = tmesa->pClipRects;
-         drm_clip_rect_t *b = tmesa->sarea->boxes;
-         GLint n = 0;
-   
-         if ( !all ) {
-           for ( ; i < nr ; i++ ) {
-              GLint x = box[i].x1;
-              GLint y = box[i].y1;
-              GLint w = box[i].x2 - x;
-              GLint h = box[i].y2 - y;
-              
-              if ( x < cx ) w -= cx - x, x = cx;
-              if ( y < cy ) h -= cy - y, y = cy;
-              if ( x + w > cx + cw ) w = cx + cw - x;
-              if ( y + h > cy + ch ) h = cy + ch - y;
-              if ( w <= 0 ) continue;
-              if ( h <= 0 ) continue;
-              
-              b->x1 = x;
-              b->y1 = y;
-              b->x2 = x + w;
-              b->y2 = y + h;
-              b++;
-              n++;
-           }
-         } else {
-           for ( ; i < nr ; i++ ) {
-              *b++ = box[i];
-              n++;
-           }
-         }
-   
-         tmesa->sarea->nbox = n;
-#endif
-   
-if (flags & DRM_TRIDENT_BACK) {
-    MMIO_OUT32(MMIO, 0x2150, tmesa->tridentScreen->backPitch << 20 | tmesa->tridentScreen->backOffset>>4);
-         MMIO_OUT8(MMIO, 0x2127, 0xF0); /* Pat Rop */
-         MMIO_OUT32(MMIO, 0x2158, tmesa->ClearColor);
-         MMIO_OUT32(MMIO, 0x2128, 0x4000); /* solidfill */
-         MMIO_OUT32(MMIO, 0x2138, cx << 16 | cy);
-         MMIO_OUT32(MMIO, 0x2140, cw << 16 | ch);
-         MMIO_OUT8(MMIO, 0x2124, 0x01); /* BLT */
-#define GE_BUSY 0x80
-        for (;;) {
-               busy = MMIO_IN8(MMIO, 0x2120);
-               if ( !(busy & GE_BUSY) )
-                       break;
-        }
-}
-if (flags & DRM_TRIDENT_DEPTH) {
-    MMIO_OUT32(MMIO, 0x2150, tmesa->tridentScreen->depthPitch << 20 | tmesa->tridentScreen->depthOffset>>4);
-         MMIO_OUT8(MMIO, 0x2127, 0xF0); /* Pat Rop */
-         MMIO_OUT32(MMIO, 0x2158, tmesa->ClearColor);
-         MMIO_OUT32(MMIO, 0x2128, 0x4000); /* solidfill */
-         MMIO_OUT32(MMIO, 0x2138, cx << 16 | cy);
-         MMIO_OUT32(MMIO, 0x2140, cw << 16 | ch);
-         MMIO_OUT8(MMIO, 0x2124, 0x01); /* BLT */
-#define GE_BUSY 0x80
-        for (;;) {
-               busy = MMIO_IN8(MMIO, 0x2120);
-               if ( !(busy & GE_BUSY) )
-                       break;
-        }
-}
-    MMIO_OUT32(MMIO, 0x2150, tmesa->tridentScreen->frontPitch << 20 | tmesa->tridentScreen->frontOffset>>4);
-if (flags & DRM_TRIDENT_FRONT) {
-         MMIO_OUT8(MMIO, 0x2127, 0xF0); /* Pat Rop */
-         MMIO_OUT32(MMIO, 0x2158, tmesa->ClearColor);
-         MMIO_OUT32(MMIO, 0x2128, 0x4000); /* solidfill */
-         MMIO_OUT32(MMIO, 0x2138, cx << 16 | cy);
-         MMIO_OUT32(MMIO, 0x2140, cw << 16 | ch);
-         MMIO_OUT8(MMIO, 0x2124, 0x01); /* BLT */
-#define GE_BUSY 0x80
-        for (;;) {
-               busy = MMIO_IN8(MMIO, 0x2120);
-               if ( !(busy & GE_BUSY) )
-                       break;
-        }
-}
-   
-      }
-   
-#if 0
-      tmesa->dirty |= (TRIDENT_UPLOAD_CONTEXT |
-                      TRIDENT_UPLOAD_MISC |
-                      TRIDENT_UPLOAD_CLIPRECTS);
-#endif
-   }
-
-   UNLOCK_HARDWARE(tmesa);
-
-   if ( mask )
-      _swrast_Clear( ctx, mask );
-}
-
-static void tridentDDShadeModel( GLcontext *ctx, GLenum mode )
-{
-   tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
-   GLuint s = tmesa->commandD;
-
-#define TRIDENT_FLAT_SHADE                     0x000000E0
-#define TRIDENT_FLAT_SHADE_VERTEX_C            0x00000060
-#define TRIDENT_FLAT_SHADE_GOURAUD             0x00000080
-
-   s &= ~TRIDENT_FLAT_SHADE;
-
-   switch ( mode ) {
-   case GL_FLAT:
-      s |= TRIDENT_FLAT_SHADE_VERTEX_C;
-      break;
-   case GL_SMOOTH:
-      s |= TRIDENT_FLAT_SHADE_GOURAUD;
-      break;
-   default:
-      return;
-   }
-
-   if ( tmesa->commandD != s ) {
-      tmesa->commandD = s;
-
-      tmesa->dirty |= TRIDENT_UPLOAD_COMMAND_D;
-   }
-}
-
-static void
-tridentCalcViewport( GLcontext *ctx )
-{
-   tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
-   const GLfloat *v = ctx->Viewport._WindowMap.m;
-   GLfloat *m = tmesa->hw_viewport;
-
-   /* See also trident_translate_vertex.
-    */
-   m[MAT_SX] =   v[MAT_SX];
-   m[MAT_TX] =   v[MAT_TX] + tmesa->drawX + SUBPIXEL_X;
-   m[MAT_SY] = - v[MAT_SY];
-   m[MAT_TY] = - v[MAT_TY] + tmesa->driDrawable->h + tmesa->drawY + SUBPIXEL_Y;
-#if 0
-   m[MAT_SZ] =   v[MAT_SZ] * tmesa->depth_scale;
-   m[MAT_TZ] =   v[MAT_TZ] * tmesa->depth_scale;
-#else
-   m[MAT_SZ] =   v[MAT_SZ];
-   m[MAT_TZ] =   v[MAT_TZ];
-#endif
-
-   tmesa->SetupNewInputs = ~0;
-}
-
-static void tridentDDViewport( GLcontext *ctx,
-                         GLint x, GLint y,
-                         GLsizei width, GLsizei height )
-{
-   tridentCalcViewport( ctx );
-}
-
-static void tridentDDDepthRange( GLcontext *ctx,
-                           GLclampd nearval, GLclampd farval )
-{
-   tridentCalcViewport( ctx );
-}
-
-static void
-tridentSetCliprects( tridentContextPtr tmesa, GLenum mode )
-{
-   __DRIdrawablePrivate *dPriv = tmesa->driDrawable;
-
-   switch ( mode ) {
-   case GL_FRONT_LEFT:
-      if (dPriv->numClipRects == 0) {
-        static drm_clip_rect_t zeroareacliprect = {0,0,0,0};
-        tmesa->numClipRects = 1;
-        tmesa->pClipRects = &zeroareacliprect;
-      } else {
-        tmesa->numClipRects = dPriv->numClipRects;
-        tmesa->pClipRects = (drm_clip_rect_t *)dPriv->pClipRects;
-      }
-      tmesa->drawX = dPriv->x;
-      tmesa->drawY = dPriv->y;
-      break;
-   case GL_BACK_LEFT:
-      if ( dPriv->numBackClipRects == 0 ) {
-         if (dPriv->numClipRects == 0) {
-            static drm_clip_rect_t zeroareacliprect = {0,0,0,0};
-            tmesa->numClipRects = 1;
-            tmesa->pClipRects = &zeroareacliprect;
-         } else {
-            tmesa->numClipRects = dPriv->numClipRects;
-            tmesa->pClipRects = (drm_clip_rect_t *)dPriv->pClipRects;
-            tmesa->drawX = dPriv->x;
-            tmesa->drawY = dPriv->y;
-         }
-      }
-      else {
-        tmesa->numClipRects = dPriv->numBackClipRects;
-        tmesa->pClipRects = (drm_clip_rect_t *)dPriv->pBackClipRects;
-        tmesa->drawX = dPriv->backX;
-        tmesa->drawY = dPriv->backY;
-      }
-      break;
-   default:
-      return;
-   }
-
-#if 0
-   tmesa->dirty |= TRIDENT_UPLOAD_CLIPRECTS;
-#endif
-}
-
-#if 0
-static GLboolean tridentDDSetDrawBuffer( GLcontext *ctx, GLenum mode )
-{
-   tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
-   int found = GL_TRUE;
-
-   if ( tmesa->DrawBuffer != mode ) {
-      tmesa->DrawBuffer = mode;
-      
-      switch ( mode ) {
-      case GL_FRONT_LEFT:
-        tridentFallback( tmesa, TRIDENT_FALLBACK_DRAW_BUFFER, GL_FALSE );
-        tmesa->drawOffset = tmesa->tridentScreen->frontOffset;
-        tmesa->drawPitch  = tmesa->tridentScreen->frontPitch;
-        tridentSetCliprects( tmesa, GL_FRONT_LEFT );
-        break;
-      case GL_BACK_LEFT:
-        tridentFallback( tmesa, TRIDENT_FALLBACK_DRAW_BUFFER, GL_FALSE );
-        tmesa->drawOffset = tmesa->tridentScreen->backOffset;
-        tmesa->drawPitch  = tmesa->tridentScreen->backPitch;
-        tridentSetCliprects( tmesa, GL_BACK_LEFT );
-        break;
-      default:
-        tridentFallback( tmesa, TRIDENT_FALLBACK_DRAW_BUFFER, GL_TRUE );
-        found = GL_FALSE;
-        break;
-      }
-
-#if 0
-      tmesa->setup.dst_off_pitch = (((tmesa->drawPitch/8) << 22) |
-                                   (tmesa->drawOffset >> 3));
-
-      tmesa->dirty |= MACH64_UPLOAD_DST_OFF_PITCH | MACH64_UPLOAD_CONTEXT;
-#endif
-      
-   }
-
-   return found;
-}
-
-static void tridentDDClearColor( GLcontext *ctx,
-                               const GLchan color[4] )
-{
-   tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
-
-   tmesa->ClearColor = tridentPackColor( tmesa->tridentScreen->cpp,
-                                       color[0], color[1], 
-                                       color[2], color[3] );
-}
-#endif
-
-static void
-tridentDDUpdateState( GLcontext *ctx, GLuint new_state )
-{
-   _swrast_InvalidateState( ctx, new_state );
-   _swsetup_InvalidateState( ctx, new_state );
-   _vbo_InvalidateState( ctx, new_state );
-   _tnl_InvalidateState( ctx, new_state );
-   TRIDENT_CONTEXT(ctx)->new_gl_state |= new_state;
-}
-
-
-/* Initialize the context's hardware state.
- */
-void tridentDDInitState( tridentContextPtr tmesa )
-{
-   tmesa->new_state = 0;
-
-   switch ( tmesa->glCtx->Visual.depthBits ) {
-   case 16:
-      tmesa->depth_scale = 1.0 / (GLfloat)0xffff;
-      break;
-   case 24:
-      tmesa->depth_scale = 1.0 / (GLfloat)0xffffff;
-      break;
-   }
-}
-
-void tridentDDUpdateHWState( GLcontext *ctx )
-{
-   tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
-   int new_state = tmesa->new_state;
-
-   if ( new_state )
-   {
-      tmesa->new_state = 0;
-
-#if 0
-      /* Update the various parts of the context's state.
-       */
-      if ( new_state & GAMMA_NEW_ALPHA )
-        tridentUpdateAlphaMode( ctx );
-
-      if ( new_state & GAMMA_NEW_DEPTH )
-        tridentUpdateZMode( ctx );
-
-      if ( new_state & GAMMA_NEW_FOG )
-        gammaUpdateFogAttrib( ctx );
-
-      if ( new_state & GAMMA_NEW_CLIP )
-        gammaUpdateClipping( ctx );
-
-      if ( new_state & GAMMA_NEW_POLYGON )
-        gammaUpdatePolygon( ctx );
-
-      if ( new_state & GAMMA_NEW_CULL )
-        gammaUpdateCull( ctx );
-
-      if ( new_state & GAMMA_NEW_MASKS )
-        gammaUpdateMasks( ctx );
-
-      if ( new_state & GAMMA_NEW_STIPPLE )
-        gammaUpdateStipple( ctx );
-#endif
-   }
-
-   /* HACK ! */
-
-#if 0
-   gammaEmitHwState( tmesa );
-#endif
-}
-
-/* Initialize the driver's state functions.
- */
-void tridentDDInitStateFuncs( GLcontext *ctx )
-{
-   ctx->Driver.UpdateState             = tridentDDUpdateState;
-
-   ctx->Driver.Clear                   = tridentDDClear;
-   ctx->Driver.DepthRange              = tridentDDDepthRange;
-   ctx->Driver.ShadeModel              = tridentDDShadeModel;
-   ctx->Driver.Viewport                        = tridentDDViewport;
-}
diff --git a/src/mesa/drivers/dri/trident/trident_tris.c b/src/mesa/drivers/dri/trident/trident_tris.c
deleted file mode 100644 (file)
index ee85ab4..0000000
+++ /dev/null
@@ -1,1125 +0,0 @@
-/*
- * Copyright 2002 by Alan Hourihane, Sychdyn, North Wales, UK.
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Alan Hourihane not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Alan Hourihane makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
- *
- * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * Authors:  Alan Hourihane, <alanh@fairlite.demon.co.uk>
- *
- * Trident CyberBladeXP driver.
- *
- */
-
-#include "trident_context.h"
-#include "trident_lock.h"
-#include "tnl/tnl.h"
-#include "tnl/t_context.h"
-#include "tnl/t_pipeline.h"
-#include "swrast/swrast.h"
-#include "swrast_setup/swrast_setup.h"
-
-static int first = 1;
-
-typedef struct reg {
-       int addr;
-       int data;
-} RegData;
-
-RegData initRegData[]={
-    {0x2804,  0x19980824},
-    {0x2F70,  0x46455858},
-    {0x2F74,    0x41584998},
-    {0x2F00,    0x00000000},
-    {0x2F04,    0x80000800},
-    {0x2F08,    0x00550200},
-    {0x2F40,    0x00000001},
-    {0x2F40,    0x00000001},
-    {0x2F44,    0x00830097},
-    {0x2F48,    0x0087009F},
-    {0x2F4C,    0x00BF0003},
-    {0x2F50,    0xF00B6C1B},
-    {0x2C04,    0x00000000},
-    {0x2D00,    0x00000080},
-    {0x2D00,    0x00000000},
-    {0x2DD4,    0x00100000},
-    {0x2DD4,    0x00100010},
-    {0x2DD8,    0x00100000},
-    {0x2DD8,    0x00100010},
-    {0x2C88,    0xFFFFFFFF},
-    {0x2C94 ,   0xFFFFFFFF},
-    {0x281C,    0x00008000},
-    {0x2C80,    0x00000000},
-    {0x2C80,    0x00000000},
-    {0x2C80 ,   0x00008000},
-    {0x2C00  ,  0x00000000},
-    {0x2C04  ,  0x00000000},
-    {0x2C08  ,  0x00000000},
-    {0x2C0C  ,  0x00000000},
-    {0x2C10  ,  0x00000000},
-    {0x2C14  ,  0x00000000},
-    {0x2C18  ,  0x00000000},
-    {0x2C1C  ,  0x00000000},
-    {0x2C20  ,  0x00000000},
-    {0x2C24  ,  0x00000000},
-    {0x2C2C  ,  0x00000000},
-    {0x2C30  ,  0x00000000},
-    {0x2C34  ,  0x00000000},
-    {0x2C38  ,  0x00000000},
-    {0x2C3C  ,  0x00000000},
-    {0x2C40  ,  0x00000000},
-    {0x2C44  ,  0x00000000},
-    {0x2C48  ,  0x00000000},
-    {0x2C4C  ,  0x00000000},
-    {0x2C50  ,  0x00000000},
-    {0x2C54  ,  0x00000000},
-    {0x2C58  ,  0x00000000},
-    {0x2C5C  ,  0x00000000},
-    {0x2C60  ,  0x00000000},
-    {0x2C64  ,  0x00000000},
-    {0x2C68  ,  0x00000000},
-    {0x2C6C  ,  0x00000000},
-    {0x2C70  ,  0x00000000},
-    {0x2C74  ,  0x00000000},
-    {0x2C78  ,  0x00000000},
-    {0x2C7C  ,  0x00000000},
-    {0x2C80  ,  0x00008000},
-    {0x2C84  ,  0x00000000},
-    {0x2C88  ,  0xFFFFFFFF},
-    {0x2C8C  ,  0x00000000},
-    {0x2C90  ,  0x00000000},
-    {0x2C94  ,  0xFFFFFFFF},
-    {0x2C98  ,  0x00000000},
-    {0x2C9C  ,  0x00000000},
-    {0x2CA0  ,  0x00000000},
-    {0x2CA4   , 0x00000000},
-    {0x2CA8   , 0x00000000},
-    {0x2CAC  ,  0x00000000},
-    {0x2CB0  ,  0x00000000},
-    {0x2CB4  ,  0x00000000},
-    {0x2CB8  ,  0x00000000},
-    {0x2CBC  ,  0x00000000},
-    {0x2CC0  ,  0x00000000},
-    {0x2CC4  ,  0x00000000},
-    {0x2CC8  ,  0x00000000},
-    {0x2CCC  ,  0x00000000},
-    {0x2CD0  ,  0x00000000},
-    {0x2CD4  ,  0x00000000},
-    {0x2CD8  ,  0x00000000},
-    {0x2CDC  ,  0x00000000},
-    {0x2CE0  ,  0x00000000},
-    {0x2CE4  ,  0x00000000},
-    {0x2CE8  ,  0x00000000},
-    {0x2CEC  ,  0x00000000},
-    {0x2CF0  ,  0x00000000},
-    {0x2CF4  ,  0x00000000},
-    {0x2CF8  ,  0x00000000},
-    {0x2CFC  ,  0x00000000},
-    {0x2D00  ,  0x00000000},
-    {0x2D04  ,  0x00000000},
-    {0x2D08  ,  0x00000000},
-    {0x2D0C  ,  0x00000000},
-    {0x2D10  ,  0x00000000},
-    {0x2D14  ,  0x00000000},
-    {0x2D18  ,  0x00000000},
-    {0x2D1C  ,  0x00000000},
-    {0x2D20  ,  0x00000000},
-    {0x2D24  ,  0x00000000},
-    {0x2D28  ,  0x00000000},
-    {0x2D2C  ,  0x00000000},
-    {0x2D30  ,  0x00000000},
-    {0x2D34  ,  0x00000000},
-    {0x2D38   , 0x00000000},
-    {0x2D3C   , 0x00000000},
-    {0x2D40   , 0x00000000},
-    {0x2D44   , 0x00000000},
-    {0x2D48   , 0x00000000},
-    {0x2D4C   , 0x00000000},
-    {0x2D50   , 0x00000000},
-    {0x2D54  ,  0x00000000},
-    {0x2D58  ,  0x00000000},
-    {0x2D5C  ,  0x00000000},
-    {0x2D60  ,  0x00000000},
-    {0x2D64  ,  0x00000000},
-    {0x2D68  ,  0x00000000},
-    {0x2D6C  ,  0x00000000},
-    {0x2D70   , 0x00000000},
-    {0x2D74   , 0x00000000},
-    {0x2D78   , 0x00000000},
-    {0x2D7C   , 0x00000000},
-    {0x2D80   , 0x00000000},
-    {0x2D84   , 0x00000000},
-    {0x2D88   , 0x00000000},
-    {0x2D8C   , 0x00000000},
-    {0x2D90   , 0x00000000},
-    {0x2D94   , 0x00000000},
-    {0x2D98   , 0x00000000},
-    {0x2D9C   , 0x00000000},
-    {0x2DA0   , 0x00000000},
-    {0x2DA4   , 0x00000000},
-    {0x2DA8   , 0x00000000},
-    {0x2DAC   , 0x00000000},
-    {0x2DB0   , 0x00000000},
-    {0x2DB4   , 0x00000000},
-    {0x2DB8   , 0x00000000},
-    {0x2DBC   , 0x00000000},
-    {0x2DC0   , 0x00000000},
-    {0x2DC4   , 0x00000000},
-    {0x2DC8   , 0x00000000},
-    {0x2DCC   , 0x00000000},
-    {0x2DD0   , 0x00000000},
-    {0x2DD4   , 0x00100010},
-    {0x2DD8   , 0x00100010},
-    {0x2DDC   , 0x00000000},
-    {0x2DE0   , 0x00000000},
-    {0x2DE4   , 0x00000000},
-    {0x2DE8   , 0x00000000},
-    {0x2DEC   , 0x00000000},
-    {0x2DF0   , 0x00000000},
-    {0x2DF4   , 0x00000000},
-    {0x2DF8   , 0x00000000},
-    {0x2DFC   , 0x00000000},
-    {0x2E00   , 0x00000000},
-    {0x2E04   , 0x00000000},
-    {0x2E08   , 0x00000000},
-    {0x2E0C   , 0x00000000},
-    {0x2E10   , 0x00000000},
-    {0x2E14   , 0x00000000},
-    {0x2E18   , 0x00000000},
-    {0x2E1C   , 0x00000000},
-    {0x2E20   , 0x00000000},
-    {0x2E24   , 0x00000000},
-    {0x2E28   , 0x00000000},
-    {0x2E2C   , 0x00000000},
-    {0x2E30   , 0x00000000},
-    {0x2E34   , 0x00000000},
-    {0x2E38   , 0x00000000},
-    {0x2E3C   , 0x00000000},
-    {0x2E40   , 0x00000000},
-    {0x2E44   , 0x00000000},
-    {0x2E48   , 0x00000000},
-    {0x2E4C   , 0x00000000},
-    {0x2E50   , 0x00000000},
-    {0x2E54   , 0x00000000},
-    {0x2E58   , 0x00000000},
-    {0x2E5C   , 0x00000000},
-    {0x2E60   , 0x00000000},
-    {0x2E64   , 0x00000000},
-    {0x2E68   , 0x00000000},
-    {0x2E6C   , 0x00000000},
-    {0x2E70   , 0x00000000},
-    {0x2E74   , 0x00000000},
-    {0x2E78   , 0x00000000},
-    {0x2E7C   , 0x00000000},
-    {0x2E80   , 0x00000000},
-    {0x2E84   , 0x00000000},
-    {0x2E88   , 0x00000000},
-    {0x2E8C   , 0x00000000},
-    {0x2E90   , 0x00000000},
-    {0x2E94   , 0x00000000},
-    {0x2E98   , 0x00000000},
-    {0x2E9C   , 0x00000000},
-    {0x2EA0   , 0x00000000},
-    {0x2EA4   , 0x00000000},
-    {0x2EA8   , 0x00000000},
-    {0x2EAC   , 0x00000000},
-    {0x2EB0   , 0x00000000},
-    {0x2EB4   , 0x00000000},
-    {0x2EB8   , 0x00000000},
-    {0x2EBC   , 0x00000000},
-    {0x2EC0   , 0x00000000},
-    {0x2EC4   , 0x00000000},
-    {0x2EC8   , 0x00000000},
-    {0x2ECC   , 0x00000000},
-    {0x2ED0   , 0x00000000},
-    {0x2ED4   , 0x00000000},
-    {0x2ED8   , 0x00000000},
-    {0x2EDC   , 0x00000000},
-    {0x2EE0   , 0x00000000},
-    {0x2EE4    ,0x00000000},
-    {0x2EE8    ,0x00000000},
-    {0x2EEC   , 0x00000000},
-    {0x2EF0   , 0x00000000},
-    {0x2EF4   , 0x00000000},
-    {0x2EF8   , 0x00000000},
-    {0x2EFC   , 0x00000000},
-    /*{0x2F60   , 0x00000000},*/
-};
-
-int initRegDataNum=sizeof(initRegData)/sizeof(RegData);
-
-typedef union {
-    unsigned int i;
-    float        f;
-} dmaBufRec, *dmaBuf;
-
-void Init3D( tridentContextPtr tmesa )
-{
-   unsigned char *MMIO = tmesa->tridentScreen->mmio.map;
-    int i;
-
-    for(i=0;i<initRegDataNum;++i)
-       MMIO_OUT32(MMIO, initRegData[i].addr, initRegData[i].data);
-}
-
-int DrawTriangle( tridentContextPtr tmesa)
-{
-   unsigned char *MMIO = tmesa->tridentScreen->mmio.map;
-   dmaBufRec clr;
-
-printf("DRAW TRI\n");
-       Init3D(tmesa);
-
-printf("ENGINE STATUS 0x%x\n",MMIO_IN32(MMIO, 0x2800));
-    MMIO_OUT32(MMIO,  0x002800, 0x00000000 );
-#if 0
-    MMIO_OUT32(MMIO,  0x002368 , MMIO_IN32(MMIO,0x002368)|1 );
-#endif
-
-    MMIO_OUT32(MMIO, 0x002C00 , 0x00000014 );
-#if 0
-    MMIO_OUT32(MMIO, 0x002C04 , 0x0A8004C0 );
-#else
-    MMIO_OUT32(MMIO, 0x002C04 , 0x0A8000C0 );
-#endif
-
-#if 0
-    MMIO_OUT32(MMIO, 0x002C08 , 0x00000000 );
-    MMIO_OUT32(MMIO, 0x002C0C , 0xFFCCCCCC );
-    MMIO_OUT32(MMIO, 0x002C10 , 0x3F800000 );
-    MMIO_OUT32(MMIO, 0x002C14 , 0x3D0D3DCB );
-    MMIO_OUT32(MMIO, 0x002C2C , 0x70000000 );
-    MMIO_OUT32(MMIO, 0x002C24 , 0x00202C00 );
-    MMIO_OUT32(MMIO, 0x002C28 , 0xE0002500 );
-    MMIO_OUT32(MMIO, 0x002C30 , 0x00000000 );
-    MMIO_OUT32(MMIO, 0x002C34 , 0xE0000000 );
-    MMIO_OUT32(MMIO, 0x002C38 , 0x00000000 );
-#endif
-
-    MMIO_OUT32(MMIO, 0x002C50 , 0x00000000 );
-    MMIO_OUT32(MMIO, 0x002C54 , 0x0C320C80 );    
-    MMIO_OUT32(MMIO, 0x002C50 , 0x00000000 );
-    MMIO_OUT32(MMIO, 0x002C54 , 0x0C320C80 );    
-    MMIO_OUT32(MMIO, 0x002C80 , 0x20008258 );    
-    MMIO_OUT32(MMIO, 0x002C84 , 0x20000320 );    
-    MMIO_OUT32(MMIO, 0x002C94 , 0xFFFFFFFF );
-
-#if 0
-    MMIO_OUT32(MMIO, 0x002D00 , 0x00009009 );    
-    MMIO_OUT32(MMIO, 0x002D38 , 0x00000000 );
-    MMIO_OUT32(MMIO, 0x002D94 , 0x20002000 );
-    MMIO_OUT32(MMIO, 0x002D50 , 0xf0000000 );
-    MMIO_OUT32(MMIO, 0x002D80 , 0x24002000 );        
-    MMIO_OUT32(MMIO, 0x002D98 , 0x81000000 );        
-    MMIO_OUT32(MMIO, 0x002DB0 , 0x81000000 );        
-    MMIO_OUT32(MMIO, 0x002DC8 , 0x808000FF );
-    MMIO_OUT32(MMIO, 0x002DD4 , 0x02000200 );
-    MMIO_OUT32(MMIO, 0x002DD8 , 0x02000200 );
-    MMIO_OUT32(MMIO, 0x002D30 , 0x02092400 );    
-    MMIO_OUT32(MMIO, 0x002D04 , 0x00102120 );    
-    MMIO_OUT32(MMIO, 0x002D08 , 0xFFFFFFFF );
-    MMIO_OUT32(MMIO, 0x002D0C , 0xF00010D0 );    
-    MMIO_OUT32(MMIO, 0x002D10 , 0xC0000400 );
-#endif
-
-    MMIO_OUT32(MMIO, 0x002814,  0x00000000 );
-#if 0
-    MMIO_OUT32(MMIO, 0x002818 , 0x00036C20 );        
-#else
-    MMIO_OUT32(MMIO, 0x002818 , 0x00036020 );        
-#endif
-    MMIO_OUT32(MMIO, 0x00281C , 0x00098081 );  
-
-printf("first TRI\n");
-    clr.f = 5.0;
-    MMIO_OUT32(MMIO, 0x002820 , clr.i );               
-    clr.f = 595.0;
-    MMIO_OUT32(MMIO, 0x002824 , clr.i );               
-    clr.f = 1.0;
-    MMIO_OUT32(MMIO, 0x002828 , clr.i );
-    MMIO_OUT32(MMIO, 0x00282C , 0x00FF00 );        
-#if 0
-    clr.f = 0.0;
-    MMIO_OUT32(MMIO, 0x002830 , clr.i );
-    clr.f = 1.0;
-    MMIO_OUT32(MMIO, 0x002834 , clr.i );
-#endif
-
-    clr.f = 5.0;
-    MMIO_OUT32(MMIO, 0x002820 , clr.i );               
-    clr.f = 5.0;
-    MMIO_OUT32(MMIO, 0x002824 , clr.i );               
-    clr.f = 1.0;
-    MMIO_OUT32(MMIO, 0x002828 , clr.i );
-    MMIO_OUT32(MMIO, 0x00282C , 0xFF0000 );        
-#if 0
-    clr.f = 0.0;
-    MMIO_OUT32(MMIO, 0x002830 , clr.i );
-    clr.f = 0.0;
-    MMIO_OUT32(MMIO, 0x002834 , clr.i );
-#endif
-
-    clr.f = 395.0;
-printf("0x%x\n",clr.i);
-    MMIO_OUT32(MMIO, 0x002820 , clr.i );               
-    clr.f = 5.0;
-    MMIO_OUT32(MMIO, 0x002824 , clr.i );               
-    clr.f = 1.0;
-    MMIO_OUT32(MMIO, 0x002828 , clr.i );
-    MMIO_OUT32(MMIO, 0x00282C , 0xFF );        
-#if 0
-    clr.f = 1.0;
-    MMIO_OUT32(MMIO, 0x002830 , clr.i );
-    clr.f = 0.0;
-    MMIO_OUT32(MMIO, 0x002834 , clr.i );
-#endif
-
-printf("sec TRI\n");
-    MMIO_OUT32(MMIO, 0x00281C , 0x00093980 );    
-    clr.f = 395.0;
-    MMIO_OUT32(MMIO, 0x002820 , clr.i );               
-    clr.f = 595.0;
-    MMIO_OUT32(MMIO, 0x002824 , clr.i );               
-    clr.f = 1.0;
-    MMIO_OUT32(MMIO, 0x002828 , clr.i );               
-    MMIO_OUT32(MMIO, 0x00282C , 0x00FF00 );        
-#if 0
-    clr.f = 1.0;
-    MMIO_OUT32(MMIO, 0x002830 , clr.i );
-    clr.f = 1.0;
-    MMIO_OUT32(MMIO, 0x002834 , clr.i );
-#endif
-
-#if 0
-    MMIO_OUT32(MMIO,  0x002368 , MMIO_IN32(MMIO,0x002368)&0xfffffffe );
-#endif
-
-printf("fin TRI\n");
-
-    return 0;  
-}
-
-static INLINE void trident_draw_point(tridentContextPtr tmesa, 
-                            const tridentVertex *v0 )
-{
-   unsigned char *MMIO = tmesa->tridentScreen->mmio.map;
-   (void) MMIO;
-}
-
-static INLINE void trident_draw_line( tridentContextPtr tmesa, 
-                            const tridentVertex *v0,
-                            const tridentVertex *v1 )
-{
-   unsigned char *MMIO = tmesa->tridentScreen->mmio.map;
-   (void) MMIO;
-}
-
-static INLINE void trident_draw_triangle( tridentContextPtr tmesa,
-                                const tridentVertex *v0,
-                                const tridentVertex *v1, 
-                                const tridentVertex *v2 )
-{
-}
-
-static INLINE void trident_draw_quad( tridentContextPtr tmesa,
-                           const tridentVertex *v0,
-                           const tridentVertex *v1,
-                           const tridentVertex *v2,
-                           const tridentVertex *v3 )
-{
-   GLuint vertsize = tmesa->vertex_size;
-   GLint coloridx = (vertsize > 4) ? 4 : 3;
-   unsigned char *MMIO = tmesa->tridentScreen->mmio.map;
-   int clr;
-   float *ftmp = (float *)(&clr);
-
-   if (tmesa->dirty)
-       tridentUploadHwStateLocked( tmesa );
-#if 0
-       DrawTriangle(tmesa);
-       exit(0);
-#else
-#if 1
-       if (first) {
-       Init3D(tmesa);
-#if 0
-       DrawTriangle(tmesa);
-#endif
-       first = 0;
-       }
-#endif
-    
-    LOCK_HARDWARE( tmesa );
-
-    MMIO_OUT32(MMIO, 0x002C00 , 0x00000010 );
-    MMIO_OUT32(MMIO, 0x002C04 , 0x029C00C0 );
-
-    /* Z buffer */
-    MMIO_OUT32(MMIO, 0x002C24 , 0x00100000 /*| (tmesa->tridentScreen->depthOffset)*/ );
-    MMIO_OUT32(MMIO, 0x002C28 , 0xE0000000 | (tmesa->tridentScreen->depthPitch * 4) );
-
-    /* front buffer */
-    MMIO_OUT32(MMIO, 0x002C50 , 0x00000000 | (tmesa->drawOffset) );
-    MMIO_OUT32(MMIO, 0x002C54 , 0x0C320000 | (tmesa->drawPitch * 4) );    
-
-    /* clipper */
-    MMIO_OUT32(MMIO, 0x002C80 , 0x20008000 | tmesa->tridentScreen->height );    
-    MMIO_OUT32(MMIO, 0x002C84 , 0x20000000 | tmesa->tridentScreen->width );    
-
-    /* writemask */
-    MMIO_OUT32(MMIO, 0x002C94 , 0xFFFFFFFF );
-
-if (vertsize == 4) {
-    MMIO_OUT32(MMIO, 0x002818 , 0x0003A020 );        
-    MMIO_OUT32(MMIO, 0x00281C , 0x00098021 );  
-
-    *ftmp = v0->v.x;
-    MMIO_OUT32(MMIO, 0x002820 , clr );               
-    *ftmp = v0->v.y;
-    MMIO_OUT32(MMIO, 0x002824 , clr );               
-    *ftmp = v0->v.z;
-    MMIO_OUT32(MMIO, 0x002828 , clr );
-#if 0
-    *ftmp = v0->v.w;
-    MMIO_OUT32(MMIO, 0x00282C , clr );
-#endif
-    MMIO_OUT32(MMIO, 0x00282C , v0->ui[coloridx] );        
-
-    *ftmp = v1->v.x;
-    MMIO_OUT32(MMIO, 0x002820 , clr );               
-    *ftmp = v1->v.y;
-    MMIO_OUT32(MMIO, 0x002824 , clr );               
-    *ftmp = v1->v.z;
-    MMIO_OUT32(MMIO, 0x002828 , clr );
-#if 0
-    *ftmp = v1->v.w;
-    MMIO_OUT32(MMIO, 0x00282C , clr );
-#endif
-    MMIO_OUT32(MMIO, 0x00282C , v1->ui[coloridx] );        
-
-    *ftmp = v2->v.x;
-    MMIO_OUT32(MMIO, 0x002820 , clr );               
-    *ftmp = v2->v.y;
-    MMIO_OUT32(MMIO, 0x002824 , clr );               
-    *ftmp = v2->v.z;
-    MMIO_OUT32(MMIO, 0x002828 , clr );
-#if 0
-    *ftmp = v2->v.w;
-    MMIO_OUT32(MMIO, 0x00282C , clr );
-#endif
-    MMIO_OUT32(MMIO, 0x00282C , v2->ui[coloridx] );        
-
-    MMIO_OUT32(MMIO, 0x00281C , 0x00093020 );    
-    *ftmp = v3->v.x;
-    MMIO_OUT32(MMIO, 0x002820 , clr );               
-    *ftmp = v3->v.y;
-    MMIO_OUT32(MMIO, 0x002824 , clr );               
-    *ftmp = v3->v.z;
-    MMIO_OUT32(MMIO, 0x002828 , clr );
-#if 0
-    *ftmp = v3->v.w;
-    MMIO_OUT32(MMIO, 0x00282C , clr );
-#endif
-    MMIO_OUT32(MMIO, 0x00282C , v3->ui[coloridx] );        
-
-}
-#endif
-
-    UNLOCK_HARDWARE( tmesa );
-}
-/***********************************************************************
- *                    Rasterization fallback helpers                   *
- ***********************************************************************/
-
-
-/* This code is hit only when a mix of accelerated and unaccelerated
- * primitives are being drawn, and only for the unaccelerated
- * primitives.  
- */
-#if 0
-static void 
-trident_fallback_quad( tridentContextPtr tmesa, 
-                   const tridentVertex *v0, 
-                   const tridentVertex *v1, 
-                   const tridentVertex *v2, 
-                   const tridentVertex *v3 )
-{
-   GLcontext *ctx = tmesa->glCtx;
-   SWvertex v[4];
-   trident_translate_vertex( ctx, v0, &v[0] );
-   trident_translate_vertex( ctx, v1, &v[1] );
-   trident_translate_vertex( ctx, v2, &v[2] );
-   trident_translate_vertex( ctx, v3, &v[3] );
-   _swrast_Quad( ctx, &v[0], &v[1], &v[2], &v[3] );
-}
-#endif
-
-/* XXX hack to get the prototype defined in time... */
-void trident_translate_vertex(GLcontext *ctx, const tridentVertex *src,
-                              SWvertex *dst);
-
-static void 
-trident_fallback_tri( tridentContextPtr tmesa, 
-                   const tridentVertex *v0, 
-                   const tridentVertex *v1, 
-                   const tridentVertex *v2 )
-{
-   GLcontext *ctx = tmesa->glCtx;
-   SWvertex v[3];
-   trident_translate_vertex( ctx, v0, &v[0] );
-   trident_translate_vertex( ctx, v1, &v[1] );
-   trident_translate_vertex( ctx, v2, &v[2] );
-   _swrast_Triangle( ctx, &v[0], &v[1], &v[2] );
-}
-
-static void 
-trident_fallback_line( tridentContextPtr tmesa,
-                    const tridentVertex *v0,
-                    const tridentVertex *v1 )
-{
-   GLcontext *ctx = tmesa->glCtx;
-   SWvertex v[2];
-   trident_translate_vertex( ctx, v0, &v[0] );
-   trident_translate_vertex( ctx, v1, &v[1] );
-   _swrast_Line( ctx, &v[0], &v[1] );
-}
-
-
-static void 
-trident_fallback_point( tridentContextPtr tmesa, 
-                     const tridentVertex *v0 )
-{
-   GLcontext *ctx = tmesa->glCtx;
-   SWvertex v[1];
-   trident_translate_vertex( ctx, v0, &v[0] );
-   _swrast_Point( ctx, &v[0] );
-}
-
-/***********************************************************************
- *          Macros for t_dd_tritmp.h to draw basic primitives          *
- ***********************************************************************/
-
-#define TRI( a, b, c )                         \
-do {                                           \
-   if (DO_FALLBACK)                            \
-      tmesa->draw_tri( tmesa, a, b, c );       \
-   else                                                \
-      trident_draw_triangle( tmesa, a, b, c ); \
-} while (0)
-
-#define QUAD( a, b, c, d )                     \
-do {                                           \
-   if (DO_FALLBACK) {                          \
-      tmesa->draw_tri( tmesa, a, b, d );       \
-      tmesa->draw_tri( tmesa, b, c, d );       \
-   } else                                      \
-      trident_draw_quad( tmesa, a, b, c, d );  \
-} while (0)
-
-#define LINE( v0, v1 )                         \
-do {                                           \
-   if (DO_FALLBACK)                            \
-      tmesa->draw_line( tmesa, v0, v1 );       \
-   else                                        \
-      trident_draw_line( tmesa, v0, v1 );      \
-} while (0)
-
-#define POINT( v0 )                            \
-do {                                           \
-   if (DO_FALLBACK)                            \
-      tmesa->draw_point( tmesa, v0 );          \
-   else                                        \
-      trident_draw_point( tmesa, v0 );         \
-} while (0)
-
-/***********************************************************************
- *              Build render functions from dd templates               *
- ***********************************************************************/
-
-#define TRIDENT_OFFSET_BIT     0x01
-#define TRIDENT_TWOSIDE_BIT    0x02
-#define TRIDENT_UNFILLED_BIT   0x04
-#define TRIDENT_FALLBACK_BIT   0x08
-#define TRIDENT_MAX_TRIFUNC    0x10
-
-
-static struct {
-   tnl_points_func     points;
-   tnl_line_func       line;
-   tnl_triangle_func   triangle;
-   tnl_quad_func       quad;
-} rast_tab[TRIDENT_MAX_TRIFUNC];
-
-
-#define DO_FALLBACK (IND & TRIDENT_FALLBACK_BIT)
-#define DO_OFFSET   (IND & TRIDENT_OFFSET_BIT)
-#define DO_UNFILLED (IND & TRIDENT_UNFILLED_BIT)
-#define DO_TWOSIDE  (IND & TRIDENT_TWOSIDE_BIT)
-#define DO_FLAT      0
-#define DO_TRI       1
-#define DO_QUAD      1
-#define DO_LINE      1
-#define DO_POINTS    1
-#define DO_FULL_QUAD 1
-
-#define HAVE_RGBA         1
-#define HAVE_SPEC         1
-#define HAVE_BACK_COLORS  0
-#define HAVE_HW_FLATSHADE 1
-#define VERTEX            tridentVertex
-#define TAB               rast_tab
-
-#define DEPTH_SCALE 1.0
-#define UNFILLED_TRI unfilled_tri
-#define UNFILLED_QUAD unfilled_quad
-#define VERT_X(_v) _v->v.x
-#define VERT_Y(_v) _v->v.y
-#define VERT_Z(_v) _v->v.z
-#define AREA_IS_CCW( a ) (a > 0)
-#define GET_VERTEX(e) (tmesa->verts + (e<<tmesa->vertex_stride_shift))
-
-#define TRIDENT_COLOR( dst, src )                \
-do {                                           \
-   dst[0] = src[2];                            \
-   dst[1] = src[1];                            \
-   dst[2] = src[0];                            \
-   dst[3] = src[3];                            \
-} while (0)
-
-#define TRIDENT_SPEC( dst, src )                       \
-do {                                           \
-   dst[0] = src[2];                            \
-   dst[1] = src[1];                            \
-   dst[2] = src[0];                            \
-} while (0)
-
-#define VERT_SET_RGBA( v, c )    TRIDENT_COLOR( v->ub4[coloroffset], c )
-#define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset]
-#define VERT_SAVE_RGBA( idx )    color[idx] = v[idx]->ui[coloroffset]
-#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx]
-
-#define VERT_SET_SPEC( v, c )    if (havespec) TRIDENT_SPEC( v->ub4[5], c )
-#define VERT_COPY_SPEC( v0, v1 ) if (havespec) COPY_3V(v0->ub4[5], v1->ub4[5])
-#define VERT_SAVE_SPEC( idx )    if (havespec) spec[idx] = v[idx]->ui[5]
-#define VERT_RESTORE_SPEC( idx ) if (havespec) v[idx]->ui[5] = spec[idx]
-
-#define LOCAL_VARS(n)                                          \
-   tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);             \
-   GLuint color[n], spec[n];                                   \
-   GLuint coloroffset = (tmesa->vertex_size == 4 ? 3 : 4);     \
-   GLboolean havespec = (tmesa->vertex_size == 4 ? 0 : 1);     \
-   (void) color; (void) spec; (void) coloroffset; (void) havespec;
-/***********************************************************************
- *                Helpers for rendering unfilled primitives            *
- ***********************************************************************/
-#if 0
-static const GLuint hw_prim[GL_POLYGON+1] = {
-   B_PrimType_Points,
-   B_PrimType_Lines,
-   B_PrimType_Lines,
-   B_PrimType_Lines,
-   B_PrimType_Triangles,
-   B_PrimType_Triangles,
-   B_PrimType_Triangles,
-   B_PrimType_Triangles,
-   B_PrimType_Triangles,
-   B_PrimType_Triangles
-};
-#endif
-
-static void tridentResetLineStipple( GLcontext *ctx );
-#if 0
-static void tridentRasterPrimitive( GLcontext *ctx, GLuint hwprim );
-#endif
-static void tridentRenderPrimitive( GLcontext *ctx, GLenum prim );
-
-#define RASTERIZE(x) /*if (tmesa->hw_primitive != hw_prim[x]) \
-                        tridentRasterPrimitive( ctx, hw_prim[x] ) */
-#define RENDER_PRIMITIVE tmesa->render_primitive
-#define TAG(x) x
-#define IND TRIDENT_FALLBACK_BIT
-#include "tnl_dd/t_dd_unfilled.h"
-#undef IND
-
-/***********************************************************************
- *                      Generate GL render functions                   *
- ***********************************************************************/
-
-#define IND (0)
-#define TAG(x) x
-#include "tnl_dd/t_dd_tritmp.h"
-
-#define IND (TRIDENT_OFFSET_BIT)
-#define TAG(x) x##_offset
-#include "tnl_dd/t_dd_tritmp.h"
-
-#define IND (TRIDENT_TWOSIDE_BIT)
-#define TAG(x) x##_twoside
-#include "tnl_dd/t_dd_tritmp.h"
-
-#define IND (TRIDENT_TWOSIDE_BIT|TRIDENT_OFFSET_BIT)
-#define TAG(x) x##_twoside_offset
-#include "tnl_dd/t_dd_tritmp.h"
-
-#define IND (TRIDENT_UNFILLED_BIT)
-#define TAG(x) x##_unfilled
-#include "tnl_dd/t_dd_tritmp.h"
-
-#define IND (TRIDENT_OFFSET_BIT|TRIDENT_UNFILLED_BIT)
-#define TAG(x) x##_offset_unfilled
-#include "tnl_dd/t_dd_tritmp.h"
-
-#define IND (TRIDENT_TWOSIDE_BIT|TRIDENT_UNFILLED_BIT)
-#define TAG(x) x##_twoside_unfilled
-#include "tnl_dd/t_dd_tritmp.h"
-
-#define IND (TRIDENT_TWOSIDE_BIT|TRIDENT_OFFSET_BIT|TRIDENT_UNFILLED_BIT)
-#define TAG(x) x##_twoside_offset_unfilled
-#include "tnl_dd/t_dd_tritmp.h"
-
-#define IND (TRIDENT_FALLBACK_BIT)
-#define TAG(x) x##_fallback
-#include "tnl_dd/t_dd_tritmp.h"
-
-#define IND (TRIDENT_OFFSET_BIT|TRIDENT_FALLBACK_BIT)
-#define TAG(x) x##_offset_fallback
-#include "tnl_dd/t_dd_tritmp.h"
-
-#define IND (TRIDENT_TWOSIDE_BIT|TRIDENT_FALLBACK_BIT)
-#define TAG(x) x##_twoside_fallback
-#include "tnl_dd/t_dd_tritmp.h"
-
-#define IND (TRIDENT_TWOSIDE_BIT|TRIDENT_OFFSET_BIT|TRIDENT_FALLBACK_BIT)
-#define TAG(x) x##_twoside_offset_fallback
-#include "tnl_dd/t_dd_tritmp.h"
-
-#define IND (TRIDENT_UNFILLED_BIT|TRIDENT_FALLBACK_BIT)
-#define TAG(x) x##_unfilled_fallback
-#include "tnl_dd/t_dd_tritmp.h"
-
-#define IND (TRIDENT_OFFSET_BIT|TRIDENT_UNFILLED_BIT|TRIDENT_FALLBACK_BIT)
-#define TAG(x) x##_offset_unfilled_fallback
-#include "tnl_dd/t_dd_tritmp.h"
-
-#define IND (TRIDENT_TWOSIDE_BIT|TRIDENT_UNFILLED_BIT|TRIDENT_FALLBACK_BIT)
-#define TAG(x) x##_twoside_unfilled_fallback
-#include "tnl_dd/t_dd_tritmp.h"
-
-#define IND (TRIDENT_TWOSIDE_BIT|TRIDENT_OFFSET_BIT|TRIDENT_UNFILLED_BIT|TRIDENT_FALLBACK_BIT)
-#define TAG(x) x##_twoside_offset_unfilled_fallback
-#include "tnl_dd/t_dd_tritmp.h"
-
-static void init_rast_tab( void )
-{
-   init();
-   init_offset();
-   init_twoside();
-   init_twoside_offset();
-   init_unfilled();
-   init_offset_unfilled();
-   init_twoside_unfilled();
-   init_twoside_offset_unfilled();
-   init_fallback();
-   init_offset_fallback();
-   init_twoside_fallback();
-   init_twoside_offset_fallback();
-   init_unfilled_fallback();
-   init_offset_unfilled_fallback();
-   init_twoside_unfilled_fallback();
-   init_twoside_offset_unfilled_fallback();
-}
-
-
-/**********************************************************************/
-/*               Render unclipped begin/end objects                   */
-/**********************************************************************/
-
-#define VERT(x) (tridentVertex *)(tridentverts + (x << shift))
-#define RENDER_POINTS( start, count )          \
-   for ( ; start < count ; start++)            \
-      trident_draw_point( tmesa, VERT(start) )
-#define RENDER_LINE( v0, v1 ) \
-   trident_draw_line( tmesa, VERT(v0), VERT(v1) )
-#define RENDER_TRI( v0, v1, v2 )  \
-   trident_draw_triangle( tmesa, VERT(v0), VERT(v1), VERT(v2) )
-#define RENDER_QUAD( v0, v1, v2, v3 ) \
-   trident_draw_quad( tmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) )
-#define INIT(x) tridentRenderPrimitive( ctx, x );
-#undef LOCAL_VARS
-#define LOCAL_VARS                                             \
-   tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);             \
-   const GLuint shift = tmesa->vertex_stride_shift;            \
-   const char *tridentverts = (char *)tmesa->verts;            \
-   const GLboolean stipple = ctx->Line.StippleFlag;            \
-   const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts;       \
-   (void) elt;
-#define RESET_STIPPLE  if ( stipple ) tridentResetLineStipple( ctx );
-#define RESET_OCCLUSION
-#define PRESERVE_VB_DEFS
-#define ELT(x) (x)
-#define TAG(x) trident_##x##_verts
-#include "tnl/t_vb_rendertmp.h"
-#undef ELT
-#undef TAG
-#define TAG(x) trident_##x##_elts
-#define ELT(x) elt[x]
-#include "tnl/t_vb_rendertmp.h"
-
-/**********************************************************************/
-/*                   Render clipped primitives                        */
-/**********************************************************************/
-
-static void tridentRenderClippedPoly( GLcontext *ctx, const GLuint *elts, 
-                                  GLuint n )
-{
-   tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
-   struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
-   TNLcontext *tnl = TNL_CONTEXT(ctx);
-   GLuint prim = tmesa->render_primitive;
-
-   /* Render the new vertices as an unclipped polygon. 
-    */
-   {
-      GLuint *tmp = VB->Elts;
-      VB->Elts = (GLuint *)elts;
-      tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n, PRIM_BEGIN|PRIM_END );
-      VB->Elts = tmp;
-   }
-
-   /* Restore the render primitive
-    */
-   if (prim != GL_POLYGON)
-      tnl->Driver.Render.PrimitiveNotify( ctx, prim );
-}
-
-static void tridentRenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj )
-{
-   TNLcontext *tnl = TNL_CONTEXT(ctx);
-   tnl->Driver.Render.Line( ctx, ii, jj );
-}
-
-
-/**********************************************************************/
-/*                    Choose render functions                         */
-/**********************************************************************/
-
-#define _TRIDENT_NEW_RENDER_STATE (_DD_NEW_LINE_STIPPLE |      \
-                                 _DD_NEW_LINE_SMOOTH |         \
-                                 _DD_NEW_POINT_SMOOTH |        \
-                                 _DD_NEW_TRI_SMOOTH |          \
-                                 _DD_NEW_TRI_UNFILLED |        \
-                                 _DD_NEW_TRI_LIGHT_TWOSIDE |   \
-                                 _DD_NEW_TRI_OFFSET)           \
-
-
-#define POINT_FALLBACK (DD_POINT_SMOOTH)
-#define LINE_FALLBACK (DD_LINE_STIPPLE|DD_LINE_SMOOTH)
-#define TRI_FALLBACK (DD_TRI_SMOOTH)
-#define ANY_FALLBACK_FLAGS (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK)
-#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED)
-
-
-static void tridentChooseRenderState(GLcontext *ctx)
-{
-   tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
-   TNLcontext *tnl = TNL_CONTEXT(ctx);
-   GLuint flags = ctx->_TriangleCaps;
-   GLuint index = 0;
-
-   if (flags & (ANY_RASTER_FLAGS|ANY_FALLBACK_FLAGS)) {
-      tmesa->draw_point = trident_draw_point;
-      tmesa->draw_line = trident_draw_line;
-      tmesa->draw_tri = trident_draw_triangle;
-
-      if (flags & ANY_RASTER_FLAGS) {
-        if (flags & DD_TRI_LIGHT_TWOSIDE) index |= TRIDENT_TWOSIDE_BIT;
-        if (flags & DD_TRI_OFFSET)        index |= TRIDENT_OFFSET_BIT;
-        if (flags & DD_TRI_UNFILLED)      index |= TRIDENT_UNFILLED_BIT;
-      }
-
-      /* Hook in fallbacks for specific primitives.
-       */
-      if (flags & (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK)) {
-        if (flags & POINT_FALLBACK) tmesa->draw_point = trident_fallback_point;
-        if (flags & LINE_FALLBACK)  tmesa->draw_line = trident_fallback_line;
-        if (flags & TRI_FALLBACK)   tmesa->draw_tri = trident_fallback_tri;
-        index |= TRIDENT_FALLBACK_BIT;
-      }
-   }
-
-   if (tmesa->RenderIndex != index) {
-      tmesa->RenderIndex = index;
-
-      tnl->Driver.Render.Points = rast_tab[index].points;
-      tnl->Driver.Render.Line = rast_tab[index].line;
-      tnl->Driver.Render.Triangle = rast_tab[index].triangle;
-      tnl->Driver.Render.Quad = rast_tab[index].quad;
-         
-      if (tmesa->RenderIndex == 0) {
-         tnl->Driver.Render.PrimTabVerts = trident_render_tab_verts;
-         tnl->Driver.Render.PrimTabElts = trident_render_tab_elts;
-      } else {
-         tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
-         tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
-      }
-      tnl->Driver.Render.ClippedLine = tridentRenderClippedLine;
-      tnl->Driver.Render.ClippedPolygon = tridentRenderClippedPoly;
-   }
-}
-
-
-/**********************************************************************/
-/*                 High level hooks for t_vb_render.c                 */
-/**********************************************************************/
-
-
-
-/* Determine the rasterized primitive when not drawing unfilled 
- * polygons.
- *
- * Used only for the default render stage which always decomposes
- * primitives to trianges/lines/points.  For the accelerated stage,
- * which renders strips as strips, the equivalent calculations are
- * performed in tridentrender.c.
- */
-#if 0
-static void tridentRasterPrimitive( GLcontext *ctx, GLuint hwprim )
-{
-   tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
-   if (tmesa->hw_primitive != hwprim)
-      tmesa->hw_primitive = hwprim;
-}
-#endif
-
-static void tridentRenderPrimitive( GLcontext *ctx, GLenum prim )
-{
-   tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
-   tmesa->render_primitive = prim;
-}
-
-static void tridentRunPipeline( GLcontext *ctx )
-{
-   tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
-
-   if ( tmesa->new_state )
-      tridentDDUpdateHWState( ctx );
-
-   if (tmesa->new_gl_state) {
-#if 0
-      if (tmesa->new_gl_state & _NEW_TEXTURE)
-        tridentUpdateTextureState( ctx );
-#endif
-
-   if (!tmesa->Fallback) {
-      if (tmesa->new_gl_state & _TRIDENT_NEW_VERTEX)
-        tridentChooseVertexState( ctx );
-      
-      if (tmesa->new_gl_state & _TRIDENT_NEW_RENDER_STATE)
-        tridentChooseRenderState( ctx );
-   }
-      
-      tmesa->new_gl_state = 0;
-   }
-
-   _tnl_run_pipeline( ctx );
-}
-
-static void tridentRenderStart( GLcontext *ctx )
-{
-   /* Check for projective texturing.  Make sure all texcoord
-    * pointers point to something.  (fix in mesa?)  
-    */
-   tridentCheckTexSizes( ctx );
-}
-
-static void tridentRenderFinish( GLcontext *ctx )
-{
-   if (0)
-      _swrast_flush( ctx );    /* never needed */
-}
-
-static void tridentResetLineStipple( GLcontext *ctx )
-{
-   tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
-   (void) tmesa;
-
-   /* Reset the hardware stipple counter.
-    */
-}
-
-
-/**********************************************************************/
-/*           Transition to/from hardware rasterization.               */
-/**********************************************************************/
-
-
-void tridentFallback( tridentContextPtr tmesa, GLuint bit, GLboolean mode )
-{
-   GLcontext *ctx = tmesa->glCtx;
-   TNLcontext *tnl = TNL_CONTEXT(ctx);
-   GLuint oldfallback = tmesa->Fallback;
-
-      _tnl_need_projected_coords( ctx, GL_FALSE );
-
-   if (mode) {
-      tmesa->Fallback |= bit;
-      if (oldfallback == 0) {
-        _swsetup_Wakeup( ctx );
-        tmesa->RenderIndex = ~0;
-      }
-   }
-   else {
-      tmesa->Fallback &= ~bit;
-      if (oldfallback == bit) {
-        _swrast_flush( ctx );
-        tnl->Driver.Render.Start = tridentRenderStart;
-        tnl->Driver.Render.PrimitiveNotify = tridentRenderPrimitive;
-        tnl->Driver.Render.Finish = tridentRenderFinish;
-        tnl->Driver.Render.BuildVertices = tridentBuildVertices;
-         tnl->Driver.Render.ResetLineStipple = tridentResetLineStipple;
-        tmesa->new_gl_state |= (_TRIDENT_NEW_RENDER_STATE|
-                                _TRIDENT_NEW_VERTEX);
-      }
-   }
-}
-
-
-/**********************************************************************/
-/*                            Initialization.                         */
-/**********************************************************************/
-
-
-void tridentDDInitTriFuncs( GLcontext *ctx )
-{
-   tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
-   TNLcontext *tnl = TNL_CONTEXT(ctx);
-   static int firsttime = 1;
-
-   if (firsttime) {
-      init_rast_tab();
-      firsttime = 0;
-   }
-   
-   tmesa->RenderIndex = ~0;
-
-   tnl->Driver.RunPipeline = tridentRunPipeline;
-   tnl->Driver.Render.Start = tridentRenderStart;
-   tnl->Driver.Render.Finish = tridentRenderFinish; 
-   tnl->Driver.Render.PrimitiveNotify = tridentRenderPrimitive;
-   tnl->Driver.Render.ResetLineStipple = tridentResetLineStipple;
-   tnl->Driver.Render.BuildVertices = tridentBuildVertices;
-}
diff --git a/src/mesa/drivers/dri/trident/trident_vb.c b/src/mesa/drivers/dri/trident/trident_vb.c
deleted file mode 100644 (file)
index 055a914..0000000
+++ /dev/null
@@ -1,434 +0,0 @@
-/*
- * Copyright 2002 by Alan Hourihane, Sychdyn, North Wales, UK.
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Alan Hourihane not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Alan Hourihane makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
- *
- * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * Authors:  Alan Hourihane, <alanh@fairlite.demon.co.uk>
- *
- * Trident CyberBladeXP driver.
- *
- */
-#include "main/glheader.h"
-#include "main/mtypes.h"
-#include "main/macros.h"
-#include "main/colormac.h"
-
-#include "swrast_setup/swrast_setup.h"
-#include "swrast/swrast.h"
-#include "tnl/t_context.h"
-#include "tnl/tnl.h"
-
-#include "trident_context.h"
-
-#define TRIDENT_TEX1_BIT       0x1
-#define TRIDENT_TEX0_BIT       0x2
-#define TRIDENT_RGBA_BIT       0x4
-#define TRIDENT_SPEC_BIT       0x8
-#define TRIDENT_FOG_BIT        0x10
-#define TRIDENT_XYZW_BIT       0x20
-#define TRIDENT_PTEX_BIT       0x40
-#define TRIDENT_MAX_SETUP      0x80
-
-static struct {
-   void                (*emit)( GLcontext *, GLuint, GLuint, void *, GLuint );
-   tnl_interp_func     interp;
-   tnl_copy_pv_func     copy_pv;
-   GLboolean           (*check_tex_sizes)( GLcontext *ctx );
-   GLuint               vertex_size;
-   GLuint               vertex_stride_shift;
-   GLuint               vertex_format;
-} setup_tab[TRIDENT_MAX_SETUP];
-
-#define TINY_VERTEX_FORMAT      1
-#define NOTEX_VERTEX_FORMAT     2
-#define TEX0_VERTEX_FORMAT      3
-#define TEX1_VERTEX_FORMAT      4
-#define PROJ_TEX1_VERTEX_FORMAT 5
-#define TEX2_VERTEX_FORMAT      6
-#define TEX3_VERTEX_FORMAT      7
-#define PROJ_TEX3_VERTEX_FORMAT 8
-
-#define DO_XYZW (IND & TRIDENT_XYZW_BIT)
-#define DO_RGBA (IND & TRIDENT_RGBA_BIT)
-#define DO_SPEC (IND & TRIDENT_SPEC_BIT)
-#define DO_FOG  (IND & TRIDENT_FOG_BIT)
-#define DO_TEX0 (IND & TRIDENT_TEX0_BIT)
-#define DO_TEX1 (IND & TRIDENT_TEX1_BIT)
-#define DO_TEX2 0
-#define DO_TEX3 0
-#define DO_PTEX (IND & TRIDENT_PTEX_BIT)
-
-#define VERTEX tridentVertex
-#define VERTEX_COLOR trident_color_t
-#define LOCALVARS tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
-#define GET_VIEWPORT_MAT()             tmesa->hw_viewport
-#define GET_TEXSOURCE(n)               tmesa->tmu_source[n]
-#define GET_VERTEX_FORMAT()            tmesa->vertex_format
-#define GET_VERTEX_SIZE()               tmesa->vertex_size
-#define GET_VERTEX_STORE()             tmesa->verts
-#define GET_VERTEX_STRIDE_SHIFT()      tmesa->vertex_stride_shift
-#define GET_UBYTE_COLOR_STORE()        &tmesa->UbyteColor
-#define GET_UBYTE_SPEC_COLOR_STORE()   &tmesa->UbyteSecondaryColor
-                              
-#define HAVE_HW_VIEWPORT    0
-#define HAVE_HW_DIVIDE      0
-#define HAVE_RGBA_COLOR     0 
-#define HAVE_TINY_VERTICES  1
-#define HAVE_NOTEX_VERTICES 1
-#define HAVE_TEX0_VERTICES  1
-#define HAVE_TEX1_VERTICES  1
-#define HAVE_TEX2_VERTICES  0
-#define HAVE_TEX3_VERTICES  0
-#define HAVE_PTEX_VERTICES  0
-
-#define UNVIEWPORT_VARS                                 \
-   const GLfloat dx = - tmesa->drawX - SUBPIXEL_X;     \
-   const GLfloat dy = (tmesa->driDrawable->h +                 \
-                      tmesa->drawY + SUBPIXEL_Y);      \
-   const GLfloat sz = 1.0 / tmesa->depth_scale
-
-#define UNVIEWPORT_X(x)    x  +  dx;
-#define UNVIEWPORT_Y(y)  - y  +  dy;
-#define UNVIEWPORT_Z(z)    z  *  sz;
-
-#define PTEX_FALLBACK()         tridentFallback(TRIDENT_CONTEXT(ctx), TRIDENT_FALLBACK_TEXTURE, 1)
-
-#define IMPORT_FLOAT_COLORS trident_import_float_colors
-#define IMPORT_FLOAT_SPEC_COLORS trident_import_float_spec_colors
-
-#define INTERP_VERTEX setup_tab[tmesa->SetupIndex].interp
-#define COPY_PV_VERTEX setup_tab[tmesa->SetupIndex].copy_pv
-
-/***********************************************************************
- *         Generate  pv-copying and translation functions              *
- ***********************************************************************/
-
-#define TAG(x) trident_##x
-#include "tnl_dd/t_dd_vb.c"
-
-/***********************************************************************
- *             Generate vertex emit and interp functions               *
- ***********************************************************************/
-
-#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT)
-#define TAG(x) x##_wg
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_SPEC_BIT)
-#define TAG(x) x##_wgs
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_TEX0_BIT)
-#define TAG(x) x##_wgt0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT)
-#define TAG(x) x##_wgt0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_TEX0_BIT|TRIDENT_PTEX_BIT)
-#define TAG(x) x##_wgpt0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT)
-#define TAG(x) x##_wgst0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT)
-#define TAG(x) x##_wgst0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT|TRIDENT_PTEX_BIT)
-#define TAG(x) x##_wgspt0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT)
-#define TAG(x) x##_wgf
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_SPEC_BIT)
-#define TAG(x) x##_wgfs
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_TEX0_BIT)
-#define TAG(x) x##_wgft0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT)
-#define TAG(x) x##_wgft0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_TEX0_BIT|TRIDENT_PTEX_BIT)
-#define TAG(x) x##_wgfpt0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT)
-#define TAG(x) x##_wgfst0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT)
-#define TAG(x) x##_wgfst0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT|TRIDENT_PTEX_BIT)
-#define TAG(x) x##_wgfspt0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (TRIDENT_TEX0_BIT)
-#define TAG(x) x##_t0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT)
-#define TAG(x) x##_t0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (TRIDENT_FOG_BIT)
-#define TAG(x) x##_f
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (TRIDENT_FOG_BIT|TRIDENT_TEX0_BIT)
-#define TAG(x) x##_ft0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (TRIDENT_FOG_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT)
-#define TAG(x) x##_ft0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (TRIDENT_RGBA_BIT)
-#define TAG(x) x##_g
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (TRIDENT_RGBA_BIT|TRIDENT_SPEC_BIT)
-#define TAG(x) x##_gs
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (TRIDENT_RGBA_BIT|TRIDENT_TEX0_BIT)
-#define TAG(x) x##_gt0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (TRIDENT_RGBA_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT)
-#define TAG(x) x##_gt0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (TRIDENT_RGBA_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT)
-#define TAG(x) x##_gst0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (TRIDENT_RGBA_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT)
-#define TAG(x) x##_gst0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT)
-#define TAG(x) x##_gf
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_SPEC_BIT)
-#define TAG(x) x##_gfs
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_TEX0_BIT)
-#define TAG(x) x##_gft0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT)
-#define TAG(x) x##_gft0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT)
-#define TAG(x) x##_gfst0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT)
-#define TAG(x) x##_gfst0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-static void init_setup_tab( void )
-{
-   init_wg();
-   init_wgs();
-   init_wgt0();
-   init_wgt0t1();
-   init_wgpt0();
-   init_wgst0();
-   init_wgst0t1();
-   init_wgspt0();
-   init_wgf();
-   init_wgfs();
-   init_wgft0();
-   init_wgft0t1();
-   init_wgfpt0();
-   init_wgfst0();
-   init_wgfst0t1();
-   init_wgfspt0();
-   init_t0();
-   init_t0t1();
-   init_f();
-   init_ft0();
-   init_ft0t1();
-   init_g();
-   init_gs();
-   init_gt0();
-   init_gt0t1();
-   init_gst0();
-   init_gst0t1();
-   init_gf();
-   init_gfs();
-   init_gft0();
-   init_gft0t1();
-   init_gfst0();
-   init_gfst0t1();
-}
-
-void tridentBuildVertices( GLcontext *ctx, 
-                        GLuint start, 
-                        GLuint count,
-                        GLuint newinputs )
-{
-   tridentContextPtr tmesa = TRIDENT_CONTEXT( ctx );
-   GLubyte *v = ((GLubyte *)tmesa->verts + (start<<tmesa->vertex_stride_shift));
-   GLuint stride = 1<<tmesa->vertex_stride_shift;
-
-   newinputs |= tmesa->SetupNewInputs;
-   tmesa->SetupNewInputs = 0;
-
-   if (!newinputs)
-      return;
-
-   if (newinputs & VERT_BIT_POS) {
-      setup_tab[tmesa->SetupIndex].emit( ctx, start, count, v, stride );   
-   } else {
-      GLuint ind = 0;
-
-      if (newinputs & VERT_BIT_COLOR0)
-        ind |= TRIDENT_RGBA_BIT;
-
-      if (newinputs & VERT_BIT_COLOR1)
-        ind |= TRIDENT_SPEC_BIT;
-
-      if (newinputs & VERT_BIT_TEX0)
-        ind |= TRIDENT_TEX0_BIT;
-
-      if (newinputs & VERT_BIT_TEX1)
-        ind |= TRIDENT_TEX1_BIT;
-
-      if (newinputs & VERT_BIT_FOG)
-        ind |= TRIDENT_FOG_BIT;
-
-      if (tmesa->SetupIndex & TRIDENT_PTEX_BIT)
-        ind = ~0;
-
-      ind &= tmesa->SetupIndex;
-
-      if (ind) {
-        setup_tab[ind].emit( ctx, start, count, v, stride );   
-      }
-   }
-}
-
-void tridentCheckTexSizes( GLcontext *ctx )
-{
-   tridentContextPtr tmesa = TRIDENT_CONTEXT( ctx );
-
-   if (!setup_tab[tmesa->SetupIndex].check_tex_sizes(ctx)) {
-      TNLcontext *tnl = TNL_CONTEXT(ctx);
-
-      /* Invalidate stored verts
-       */
-      tmesa->SetupNewInputs = ~0;
-      tmesa->SetupIndex |= TRIDENT_PTEX_BIT;
-
-      if (!tmesa->Fallback &&
-         !(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
-        tnl->Driver.Render.Interp = setup_tab[tmesa->SetupIndex].interp;
-        tnl->Driver.Render.CopyPV = setup_tab[tmesa->SetupIndex].copy_pv;
-      }
-   }
-}
-
-void tridentChooseVertexState( GLcontext *ctx )
-{
-   tridentContextPtr tmesa = TRIDENT_CONTEXT( ctx );
-   TNLcontext *tnl = TNL_CONTEXT(ctx);
-   GLuint ind = TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT;
-
-   if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
-      ind |= TRIDENT_SPEC_BIT;
-
-   if (ctx->Fog.Enabled)
-      ind |= TRIDENT_FOG_BIT;
-
-   if (ctx->Texture.Unit[0]._ReallyEnabled) {
-      ind |= TRIDENT_TEX0_BIT;
-      if (ctx->Texture.Unit[1]._ReallyEnabled) {
-        ind |= TRIDENT_TEX1_BIT;
-      }
-   }
-
-   tmesa->SetupIndex = ind;
-
-   if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
-      tnl->Driver.Render.Interp = trident_interp_extras;
-      tnl->Driver.Render.CopyPV = trident_copy_pv_extras;
-   } else {
-      tnl->Driver.Render.Interp = setup_tab[ind].interp;
-      tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv;
-   }
-
-   if (setup_tab[ind].vertex_format != tmesa->vertex_format) {
-      tmesa->vertex_format = setup_tab[ind].vertex_format;
-      tmesa->vertex_size = setup_tab[ind].vertex_size;
-      tmesa->vertex_stride_shift = setup_tab[ind].vertex_stride_shift;
-   }
-}
-
-void tridentInitVB( GLcontext *ctx )
-{
-   tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
-   GLuint size = TNL_CONTEXT(ctx)->vb.Size;
-
-   tmesa->verts = (GLubyte *)ALIGN_MALLOC( size * 16 * 4, 32 );
-
-   {
-      static int firsttime = 1;
-      if (firsttime) {
-        init_setup_tab();
-        firsttime = 0;
-      }
-   }
-}
-
-void tridentFreeVB( GLcontext *ctx )
-{
-   tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
-
-   if (tmesa->verts) {
-      ALIGN_FREE(tmesa->verts);
-      tmesa->verts = 0;
-   }
-
-   if (tmesa->UbyteSecondaryColor.Ptr) {
-      ALIGN_FREE((void *)tmesa->UbyteSecondaryColor.Ptr);
-      tmesa->UbyteSecondaryColor.Ptr = 0;
-   }
-
-   if (tmesa->UbyteColor.Ptr) {
-      ALIGN_FREE((void *)tmesa->UbyteColor.Ptr);
-      tmesa->UbyteColor.Ptr = 0;
-   }
-}
index 5fe00c1bd1fa479c4e6c218905bafd4417d6bc09..344d34fce365d445b35f4e746cb29b3673ae2d89 100644 (file)
@@ -29,4 +29,3 @@ ASM_SOURCES =
 
 include ../Makefile.template
 
-symlinks:
index 6eb19ac079020d6befacc6c9d968a0b82606d453..d17a160271dbbf24ed6cf6888660f3d6e76b1753 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "main/glheader.h"
 #include "main/context.h"
+#include "main/formats.h"
 #include "main/matrix.h"
 #include "main/state.h"
 #include "main/simple_list.h"
@@ -65,7 +66,7 @@
 #define need_GL_ARB_point_parameters
 #define need_GL_EXT_fog_coord
 #define need_GL_EXT_secondary_color
-#include "extension_helper.h"
+#include "main/remap_helper.h"
 
 #define DRIVER_DATE    "20060710"
 
@@ -147,7 +148,7 @@ viaRenderbufferStorage(GLcontext *ctx, struct gl_renderbuffer *rb,
 
 static void
 viaInitRenderbuffer(struct via_renderbuffer *vrb, GLenum format,
-                   __DRIdrawablePrivate *dPriv)
+                   __DRIdrawable *dPriv)
 {
    const GLuint name = 0;
    struct gl_renderbuffer *rb = & vrb->Base;
@@ -163,24 +164,28 @@ viaInitRenderbuffer(struct via_renderbuffer *vrb, GLenum format,
    if (format == GL_RGBA) {
       /* Color */
       rb->_BaseFormat = GL_RGBA;
+      rb->Format = MESA_FORMAT_ARGB8888;
       rb->DataType = GL_UNSIGNED_BYTE;
    }
    else if (format == GL_DEPTH_COMPONENT16) {
       /* Depth */
       rb->_BaseFormat = GL_DEPTH_COMPONENT;
       /* we always Get/Put 32-bit Z values */
+      rb->Format = MESA_FORMAT_Z16;
       rb->DataType = GL_UNSIGNED_INT;
    }
    else if (format == GL_DEPTH_COMPONENT24) {
       /* Depth */
       rb->_BaseFormat = GL_DEPTH_COMPONENT;
       /* we always Get/Put 32-bit Z values */
+      rb->Format = MESA_FORMAT_Z32;
       rb->DataType = GL_UNSIGNED_INT;
    }
    else {
       /* Stencil */
       ASSERT(format == GL_STENCIL_INDEX8_EXT);
       rb->_BaseFormat = GL_STENCIL_INDEX;
+      rb->Format = MESA_FORMAT_S8;
       rb->DataType = GL_UNSIGNED_BYTE;
    }
 
@@ -202,7 +207,7 @@ viaInitRenderbuffer(struct via_renderbuffer *vrb, GLenum format,
 static GLboolean
 calculate_buffer_parameters(struct via_context *vmesa,
                            struct gl_framebuffer *fb,
-                           __DRIdrawablePrivate *dPriv)
+                           __DRIdrawable *dPriv)
 {
    const unsigned shift = vmesa->viaScreen->bitsPerPixel / 16;
    const unsigned extra = 32;
@@ -362,7 +367,7 @@ void viaReAllocateBuffers(GLcontext *ctx, GLframebuffer *drawbuffer,
 
 /* Extension strings exported by the Unichrome driver.
  */
-const struct dri_extension card_extensions[] =
+static const struct dri_extension card_extensions[] =
 {
     { "GL_ARB_multitexture",               NULL },
     { "GL_ARB_point_parameters",           GL_ARB_point_parameters_functions },
@@ -455,12 +460,12 @@ FreeBuffer(struct via_context *vmesa)
 
 GLboolean
 viaCreateContext(const __GLcontextModes *visual,
-                 __DRIcontextPrivate *driContextPriv,
+                 __DRIcontext *driContextPriv,
                  void *sharedContextPrivate)
 {
     GLcontext *ctx, *shareCtx;
     struct via_context *vmesa;
-    __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+    __DRIscreen *sPriv = driContextPriv->driScreenPriv;
     viaScreenPrivate *viaScreen = (viaScreenPrivate *)sPriv->private;
     drm_via_sarea_t *saPriv = (drm_via_sarea_t *)
         (((GLubyte *)sPriv->pSAREA) + viaScreen->sareaPrivOffset);
@@ -674,7 +679,7 @@ viaCreateContext(const __GLcontextModes *visual,
 }
 
 void
-viaDestroyContext(__DRIcontextPrivate *driContextPriv)
+viaDestroyContext(__DRIcontext *driContextPriv)
 {
     GET_CURRENT_CONTEXT(ctx);
     struct via_context *vmesa =
@@ -724,8 +729,8 @@ viaDestroyContext(__DRIcontextPrivate *driContextPriv)
 
 void viaXMesaWindowMoved(struct via_context *vmesa)
 {
-   __DRIdrawablePrivate *const drawable = vmesa->driDrawable;
-   __DRIdrawablePrivate *const readable = vmesa->driReadable;
+   __DRIdrawable *const drawable = vmesa->driDrawable;
+   __DRIdrawable *const readable = vmesa->driReadable;
    struct via_renderbuffer * draw_buffer;
    struct via_renderbuffer * read_buffer;
    GLuint bytePerPixel = vmesa->viaScreen->bitsPerPixel >> 3;
@@ -808,15 +813,15 @@ void viaXMesaWindowMoved(struct via_context *vmesa)
 }
 
 GLboolean
-viaUnbindContext(__DRIcontextPrivate *driContextPriv)
+viaUnbindContext(__DRIcontext *driContextPriv)
 {
     return GL_TRUE;
 }
 
 GLboolean
-viaMakeCurrent(__DRIcontextPrivate *driContextPriv,
-               __DRIdrawablePrivate *driDrawPriv,
-               __DRIdrawablePrivate *driReadPriv)
+viaMakeCurrent(__DRIcontext *driContextPriv,
+               __DRIdrawable *driDrawPriv,
+               __DRIdrawable *driReadPriv)
 {
     if (VIA_DEBUG & DEBUG_DRI) {
        fprintf(stderr, "driContextPriv = %016lx\n", (unsigned long)driContextPriv);
@@ -892,8 +897,8 @@ viaMakeCurrent(__DRIcontextPrivate *driContextPriv,
 
 void viaGetLock(struct via_context *vmesa, GLuint flags)
 {
-    __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
-    __DRIscreenPrivate *sPriv = vmesa->driScreen;
+    __DRIdrawable *dPriv = vmesa->driDrawable;
+    __DRIscreen *sPriv = vmesa->driScreen;
 
     drmGetLock(vmesa->driFd, vmesa->hHWContext, flags);
 
@@ -923,9 +928,9 @@ void viaGetLock(struct via_context *vmesa, GLuint flags)
 
 
 void
-viaSwapBuffers(__DRIdrawablePrivate *drawablePrivate)
+viaSwapBuffers(__DRIdrawable *drawablePrivate)
 {
-    __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *)drawablePrivate;
+    __DRIdrawable *dPriv = (__DRIdrawable *)drawablePrivate;
 
     if (dPriv && 
        dPriv->driContextPriv && 
index 4cc9e475c215596f3924be186822d4447765622f..4e1ab3a6ca73559c61935cee874ee503f2e79b9f 100644 (file)
@@ -105,7 +105,7 @@ struct via_renderbuffer {
    int drawW;                  
    int drawH;    
 
-   __DRIdrawablePrivate *dPriv;
+   __DRIdrawable *dPriv;
 };
 
 
@@ -294,14 +294,14 @@ struct via_context {
    /**
     * DRI drawable bound to this context for drawing.
     */
-   __DRIdrawablePrivate        *driDrawable;
+   __DRIdrawable       *driDrawable;
 
    /**
     * DRI drawable bound to this context for reading.
     */
-   __DRIdrawablePrivate        *driReadable;
+   __DRIdrawable       *driReadable;
 
-   __DRIscreenPrivate *driScreen;
+   __DRIscreen *driScreen;
    viaScreenPrivate *viaScreen;
    drm_via_sarea_t *sarea;
    volatile GLuint* regMMIOBase;
index 6746f552ae6d3335792d2813be12076ba2f56f71..8d4edfa30587c378c67800e18b86e7065e5045ef 100644 (file)
@@ -205,7 +205,7 @@ static void viaFillBuffer(struct via_context *vmesa,
 static void viaClear(GLcontext *ctx, GLbitfield mask)
 {
    struct via_context *vmesa = VIA_CONTEXT(ctx);
-   __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
+   __DRIdrawable *dPriv = vmesa->driDrawable;
    struct via_renderbuffer *const vrb = 
      (struct via_renderbuffer *) dPriv->driverPrivate;
    int flag = 0;
@@ -507,12 +507,12 @@ void viaWaitIdleLocked( struct via_context *vmesa, GLboolean light )
  * except that WAIT_IDLE() will spin the CPU polling, while this is
  * IRQ driven.
  */
-static void viaWaitIdleVBlank(  __DRIdrawablePrivate *dPriv, 
+static void viaWaitIdleVBlank(  __DRIdrawable *dPriv, 
                               struct via_context *vmesa,
                               GLuint value )
 {
    GLboolean missed_target;
-   __DRIscreenPrivate *psp = dPriv->driScreenPriv;
+   __DRIscreen *psp = dPriv->driScreenPriv;
 
    VIA_FLUSH_DMA(vmesa); 
 
@@ -591,11 +591,11 @@ void viaResetPageFlippingLocked(struct via_context *vmesa)
 /*
  * Copy the back buffer to the front buffer. 
  */
-void viaCopyBuffer(__DRIdrawablePrivate *dPriv)
+void viaCopyBuffer(__DRIdrawable *dPriv)
 {
    struct via_context *vmesa = 
       (struct via_context *)dPriv->driContextPriv->driverPrivate;
-   __DRIscreenPrivate *psp = dPriv->driScreenPriv;
+   __DRIscreen *psp = dPriv->driScreenPriv;
 
    if (VIA_DEBUG & DEBUG_IOCTL)
       fprintf(stderr, 
@@ -635,12 +635,12 @@ void viaCopyBuffer(__DRIdrawablePrivate *dPriv)
 }
 
 
-void viaPageFlip(__DRIdrawablePrivate *dPriv)
+void viaPageFlip(__DRIdrawable *dPriv)
 {
     struct via_context *vmesa = 
        (struct via_context *)dPriv->driContextPriv->driverPrivate;
     struct via_renderbuffer buffer_tmp;
-    __DRIscreenPrivate *psp = dPriv->driScreenPriv;
+    __DRIscreen *psp = dPriv->driScreenPriv;
 
     VIA_FLUSH_DMA(vmesa);
    if (dPriv->vblFlags == VBLANK_FLAG_SYNC &&
@@ -885,9 +885,6 @@ void viaFlushDmaLocked(struct via_context *vmesa, GLuint flags)
    }
    else if (vmesa->numClipRects) {
       drm_clip_rect_t *pbox = vmesa->pClipRects;
-      __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
-      struct via_renderbuffer *const vrb = 
-       (struct via_renderbuffer *) dPriv->driverPrivate;
 
       for (i = 0; i < vmesa->numClipRects; i++) {
         drm_clip_rect_t b;
index 14a833a97d001eee270f88ab99e7b375e2830050..c6b32cf08537869c3e48cb7150b54dc1421245a8 100644 (file)
@@ -33,8 +33,8 @@ void viaFlushDma(struct via_context *vmesa);
 void viaFlushDmaLocked(struct via_context *vmesa, GLuint flags);
 
 void viaInitIoctlFuncs(GLcontext *ctx);
-void viaCopyBuffer(__DRIdrawablePrivate *dpriv);
-void viaPageFlip(__DRIdrawablePrivate *dpriv);
+void viaCopyBuffer(__DRIdrawable *dpriv);
+void viaPageFlip(__DRIdrawable *dpriv);
 void viaCheckDma(struct via_context *vmesa, GLuint bytes);
 void viaResetPageFlippingLocked(struct via_context *vmesa);
 void viaWaitIdle(struct via_context *vmesa, GLboolean light);
index 3dbb5705710382e7e723df17c506e2744b663117..2cfb98317da1ee576466830cb0261c0af1b4ccf8 100644 (file)
@@ -62,8 +62,6 @@ DRI_CONF_BEGIN
 DRI_CONF_END;
 static const GLuint __driNConfigOptions = 3;
 
-extern const struct dri_extension card_extensions[];
-
 static drmBufMapPtr via_create_empty_buffers(void)
 {
     drmBufMapPtr retval;
@@ -92,7 +90,7 @@ static void via_free_empty_buffers( drmBufMapPtr bufs )
 
 
 static GLboolean
-viaInitDriver(__DRIscreenPrivate *sPriv)
+viaInitDriver(__DRIscreen *sPriv)
 {
     viaScreenPrivate *viaScreen;
     VIADRIPtr gDRIPriv = (VIADRIPtr)sPriv->pDevPriv;
@@ -186,7 +184,7 @@ viaInitDriver(__DRIscreenPrivate *sPriv)
 }
 
 static void
-viaDestroyScreen(__DRIscreenPrivate *sPriv)
+viaDestroyScreen(__DRIscreen *sPriv)
 {
     viaScreenPrivate *viaScreen = (viaScreenPrivate *)sPriv->private;
     VIADRIPtr gDRIPriv = (VIADRIPtr)sPriv->pDevPriv;
@@ -205,12 +203,14 @@ viaDestroyScreen(__DRIscreenPrivate *sPriv)
 
 
 static GLboolean
-viaCreateBuffer(__DRIscreenPrivate *driScrnPriv,
-                __DRIdrawablePrivate *driDrawPriv,
+viaCreateBuffer(__DRIscreen *driScrnPriv,
+                __DRIdrawable *driDrawPriv,
                 const __GLcontextModes *mesaVis,
                 GLboolean isPixmap)
 {
+#if 0
     viaScreenPrivate *screen = (viaScreenPrivate *) driScrnPriv->private;
+#endif
 
     GLboolean swStencil = (mesaVis->stencilBits > 0 && 
                           mesaVis->depthBits != 24);
@@ -248,7 +248,7 @@ viaCreateBuffer(__DRIscreenPrivate *driScrnPriv,
       /* XXX check/fix the offset/pitch parameters! */
       {
          driRenderbuffer *frontRb
-            = driNewRenderbuffer(GL_RGBA, NULL,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888, NULL,
                                  screen->bytesPerPixel,
                                  0, screen->width, driDrawPriv);
          viaSetSpanFunctions(frontRb, mesaVis);
@@ -257,7 +257,7 @@ viaCreateBuffer(__DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->doubleBufferMode) {
          driRenderbuffer *backRb
-            = driNewRenderbuffer(GL_RGBA, NULL,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888, NULL,
                                  screen->bytesPerPixel,
                                  0, screen->width, driDrawPriv);
          viaSetSpanFunctions(backRb, mesaVis);
@@ -266,7 +266,7 @@ viaCreateBuffer(__DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->depthBits == 16) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT16, NULL,
+            = driNewRenderbuffer(MESA_FORMAT_Z16, NULL,
                                  screen->bytesPerPixel,
                                  0, screen->width, driDrawPriv);
          viaSetSpanFunctions(depthRb, mesaVis);
@@ -274,7 +274,7 @@ viaCreateBuffer(__DRIscreenPrivate *driScrnPriv,
       }
       else if (mesaVis->depthBits == 24) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT24, NULL,
+            = driNewRenderbuffer(MESA_FORMAT_Z24_S8, NULL,
                                  screen->bytesPerPixel,
                                  0, screen->width, driDrawPriv);
          viaSetSpanFunctions(depthRb, mesaVis);
@@ -282,7 +282,7 @@ viaCreateBuffer(__DRIscreenPrivate *driScrnPriv,
       }
       else if (mesaVis->depthBits == 32) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT32, NULL,
+            = driNewRenderbuffer(MESA_FORMAT_Z32, NULL,
                                  screen->bytesPerPixel,
                                  0, screen->width, driDrawPriv);
          viaSetSpanFunctions(depthRb, mesaVis);
@@ -291,7 +291,7 @@ viaCreateBuffer(__DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->stencilBits > 0 && !swStencil) {
          driRenderbuffer *stencilRb
-            = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, NULL,
+            = driNewRenderbuffer(MESA_FORMAT_S8, NULL,
                                  screen->bytesPerPixel,
                                  0, screen->width, driDrawPriv);
          viaSetSpanFunctions(stencilRb, mesaVis);
@@ -314,13 +314,13 @@ viaCreateBuffer(__DRIscreenPrivate *driScrnPriv,
 
 
 static void
-viaDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+viaDestroyBuffer(__DRIdrawable *driDrawPriv)
 {
    _mesa_reference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)), NULL);
 }
 
 static const __DRIconfig **
-viaFillInModes( __DRIscreenPrivate *psp,
+viaFillInModes( __DRIscreen *psp,
                unsigned pixel_bits, GLboolean have_back_buffer )
 {
     __DRIconfig **configs;
@@ -377,7 +377,7 @@ viaFillInModes( __DRIscreenPrivate *psp,
  * \return the __GLcontextModes supported by this driver
  */
 static const __DRIconfig **
-viaInitScreen(__DRIscreenPrivate *psp)
+viaInitScreen(__DRIscreen *psp)
 {
    static const __DRIversion ddx_expected = { VIA_DRIDDX_VERSION_MAJOR,
                                               VIA_DRIDDX_VERSION_MINOR,
@@ -393,18 +393,6 @@ viaInitScreen(__DRIscreenPrivate *psp)
                                      &psp->drm_version, & drm_expected) )
       return NULL;
 
-   /* Calling driInitExtensions here, with a NULL context pointer,
-    * does not actually enable the extensions.  It just makes sure
-    * that all the dispatch offsets for all the extensions that
-    * *might* be enables are known.  This is needed because the
-    * dispatch offsets need to be known when _mesa_context_create is
-    * called, but we can't enable the extensions until we have a
-    * context pointer.
-    *
-    * Hello chicken.  Hello egg.  How are you two today?
-    */
-   driInitExtensions( NULL, card_extensions, GL_FALSE );
-
    if (!viaInitDriver(psp))
        return NULL;
 
@@ -417,7 +405,7 @@ viaInitScreen(__DRIscreenPrivate *psp)
  * Get information about previous buffer swaps.
  */
 static int
-getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo )
+getSwapInfo( __DRIdrawable *dPriv, __DRIswapInfo * sInfo )
 {
    struct via_context *vmesa;
 
@@ -455,3 +443,10 @@ const struct __DriverAPIRec driDriverAPI = {
    .WaitForSBC      = NULL,
    .SwapBuffersMSC  = NULL
 };
+
+/* This is the table of extensions that the loader will dlsym() for. */
+PUBLIC const __DRIextension *__driDriverExtensions[] = {
+    &driCoreExtension.base,
+    &driLegacyExtension.base,
+    NULL
+};
index c3ef722ff0720fe780e1644630d8f26a8be6c932..aa662e01c04512fb43ef8ddab38b39f302017d78 100644 (file)
@@ -61,7 +61,7 @@ typedef struct {
     drmAddress agpLinearStart;
     GLuint agpBase;
 
-    __DRIscreenPrivate *driScrnPriv;
+    __DRIscreen *driScrnPriv;
     drmBufMapPtr bufs;
     unsigned int sareaPrivOffset;
     /*=* John Sheng [2003.12.9] Tuxracer & VQ *=*/
@@ -77,21 +77,21 @@ typedef struct {
 
 extern GLboolean
 viaCreateContext(const __GLcontextModes *mesaVis,
-                 __DRIcontextPrivate *driContextPriv,
+                 __DRIcontext *driContextPriv,
                  void *sharedContextPrivate);
 
 extern void
-viaDestroyContext(__DRIcontextPrivate *driContextPriv);
+viaDestroyContext(__DRIcontext *driContextPriv);
 
 extern GLboolean
-viaUnbindContext(__DRIcontextPrivate *driContextPriv);
+viaUnbindContext(__DRIcontext *driContextPriv);
 
 extern GLboolean
-viaMakeCurrent(__DRIcontextPrivate *driContextPriv,
-               __DRIdrawablePrivate *driDrawPriv,
-               __DRIdrawablePrivate *driReadPriv);
+viaMakeCurrent(__DRIcontext *driContextPriv,
+               __DRIdrawable *driDrawPriv,
+               __DRIdrawable *driReadPriv);
 
 extern void
-viaSwapBuffers(__DRIdrawablePrivate *drawablePrivate);
+viaSwapBuffers(__DRIdrawable *drawablePrivate);
 
 #endif
index b908f0fb23a93a774c8d491d4be74471cb6750c2..fa3cbf7a79e30c0e172eca72c6b149db386d5b86 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include "main/glheader.h"
+#include "main/formats.h"
 #include "main/macros.h"
 #include "main/mtypes.h"
 #include "main/colormac.h"
@@ -42,7 +43,7 @@
 #undef LOCAL_VARS
 #define LOCAL_VARS                                                     \
     struct via_renderbuffer *vrb = (struct via_renderbuffer *) rb;     \
-    __DRIdrawablePrivate *dPriv = vrb->dPriv;                           \
+    __DRIdrawable *dPriv = vrb->dPriv;                           \
     GLuint pitch = vrb->pitch;                                          \
     GLuint height = dPriv->h;                                          \
     GLint p = 0;                                                       \
@@ -79,7 +80,7 @@
  */
 #define LOCAL_DEPTH_VARS                                            \
     struct via_renderbuffer *vrb = (struct via_renderbuffer *) rb;  \
-    __DRIdrawablePrivate *dPriv = vrb->dPriv;                       \
+    __DRIdrawable *dPriv = vrb->dPriv;                       \
     GLuint depth_pitch = vrb->pitch;                                \
     GLuint height = dPriv->h;                                       \
     char *buf = (char *)(vrb->map)
@@ -177,24 +178,22 @@ void viaInitSpanFuncs(GLcontext *ctx)
 void
 viaSetSpanFunctions(struct via_renderbuffer *vrb, const GLvisual *vis)
 {
-   if (vrb->Base.InternalFormat == GL_RGBA) {
-      if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
-         viaInitPointers_565(&vrb->Base);
-      }
-      else {
-         viaInitPointers_8888(&vrb->Base);
-      }
+   if (vrb->Base.Format == MESA_FORMAT_RGB565) {
+      viaInitPointers_565(&vrb->Base);
    }
-   else if (vrb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+   else if (vrb->Base.Format == MESA_FORMAT_ARGB8888) {
+      viaInitPointers_8888(&vrb->Base);
+   }
+   else if (vrb->Base.Format == MESA_FORMAT_Z16) {
       viaInitDepthPointers_z16(&vrb->Base);
    }
-   else if (vrb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+   else if (vrb->Base.Format == MESA_FORMAT_Z24_S8) {
       viaInitDepthPointers_z24_s8(&vrb->Base);
    }
-   else if (vrb->Base.InternalFormat == GL_DEPTH_COMPONENT32) {
+   else if (vrb->Base.Format == MESA_FORMAT_Z32) {
       viaInitDepthPointers_z32(&vrb->Base);
    }
-   else if (vrb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+   else if (vrb->Base.Format == MESA_FORMAT_S8) {
       viaInitStencilPointers_z24_s8(&vrb->Base);
    }
 }
index 840e4e42da95d887e462da971b8bd155fff62ccf..e6e5526d344f4218342b18286bd4c948939ad9bc 100644 (file)
@@ -476,7 +476,7 @@ void viaEmitState(struct via_context *vmesa)
     */
    if (ctx->Polygon.StippleFlag) {
       GLuint *stipple = &ctx->PolygonStipple[0];
-      __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
+      __DRIdrawable *dPriv = vmesa->driDrawable;
       struct via_renderbuffer *const vrb = 
        (struct via_renderbuffer *) dPriv->driverPrivate;
       GLint i;
@@ -722,7 +722,7 @@ static void viaColorMask(GLcontext *ctx,
 void viaCalcViewport(GLcontext *ctx)
 {
     struct via_context *vmesa = VIA_CONTEXT(ctx);
-    __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
+    __DRIdrawable *dPriv = vmesa->driDrawable;
     struct via_renderbuffer *const vrb = 
       (struct via_renderbuffer *) dPriv->driverPrivate;
     const GLfloat *v = ctx->Viewport._WindowMap.m;
@@ -891,10 +891,10 @@ static GLboolean viaChooseTextureState(GLcontext *ctx)
             if (texObj->Image[0][texObj->BaseLevel]->Border > 0) {
               vmesa->regHTXnTB[0] |= (HC_HTXnTB_TBC_S | HC_HTXnTB_TBC_T);
               vmesa->regHTXnTBC[0] = 
-                 PACK_COLOR_888(FLOAT_TO_UBYTE(texObj->BorderColor[0]),
-                                FLOAT_TO_UBYTE(texObj->BorderColor[1]),
-                                FLOAT_TO_UBYTE(texObj->BorderColor[2]));
-              vmesa->regHTXnTRAH[0] = FLOAT_TO_UBYTE(texObj->BorderColor[3]);
+                 PACK_COLOR_888(FLOAT_TO_UBYTE(texObj->BorderColor.f[0]),
+                                FLOAT_TO_UBYTE(texObj->BorderColor.f[1]),
+                                FLOAT_TO_UBYTE(texObj->BorderColor.f[2]));
+              vmesa->regHTXnTRAH[0] = FLOAT_TO_UBYTE(texObj->BorderColor.f[3]);
             }
 
            if (texUnit0->LodBias != 0.0f) {
@@ -924,10 +924,10 @@ static GLboolean viaChooseTextureState(GLcontext *ctx)
             if (texObj->Image[0][texObj->BaseLevel]->Border > 0) {
               vmesa->regHTXnTB[1] |= (HC_HTXnTB_TBC_S | HC_HTXnTB_TBC_T);
               vmesa->regHTXnTBC[1] = 
-                 PACK_COLOR_888(FLOAT_TO_UBYTE(texObj->BorderColor[0]),
-                                FLOAT_TO_UBYTE(texObj->BorderColor[1]),
-                                FLOAT_TO_UBYTE(texObj->BorderColor[2]));
-              vmesa->regHTXnTRAH[1] = FLOAT_TO_UBYTE(texObj->BorderColor[3]);
+                 PACK_COLOR_888(FLOAT_TO_UBYTE(texObj->BorderColor.f[0]),
+                                FLOAT_TO_UBYTE(texObj->BorderColor.f[1]),
+                                FLOAT_TO_UBYTE(texObj->BorderColor.f[2]));
+              vmesa->regHTXnTRAH[1] = FLOAT_TO_UBYTE(texObj->BorderColor.f[3]);
             }
 
 
@@ -1238,12 +1238,12 @@ static void viaChooseColorState(GLcontext *ctx)
     else
         vmesa->regHROP = HC_HROP_P;
 
-    vmesa->regHFBBMSKL = PACK_COLOR_888(ctx->Color.ColorMask[0],
-                                       ctx->Color.ColorMask[1],
-                                       ctx->Color.ColorMask[2]);
-    vmesa->regHROP |= ctx->Color.ColorMask[3];
+    vmesa->regHFBBMSKL = PACK_COLOR_888(ctx->Color.ColorMask[0][0],
+                                       ctx->Color.ColorMask[0][1],
+                                       ctx->Color.ColorMask[0][2]);
+    vmesa->regHROP |= ctx->Color.ColorMask[0][3];
 
-    if (ctx->Color.ColorMask[3])
+    if (ctx->Color.ColorMask[0][3])
         vmesa->regEnable |= HC_HenAW_MASK;
     else
         vmesa->regEnable &= ~HC_HenAW_MASK;
index 54073e76918d0b97899ee70d40775fa99a79c8aa..24924d261382f2652627fbe50be739c20dde71c8 100644 (file)
 #include "main/macros.h"
 #include "main/mtypes.h"
 #include "main/enums.h"
+#include "main/formats.h"
 #include "main/colortab.h"
 #include "main/convolve.h"
 #include "main/context.h"
 #include "main/mipmap.h"
+#include "main/mm.h"
 #include "main/simple_list.h"
 #include "main/texcompress.h"
-#include "main/texformat.h"
 #include "main/texobj.h"
 #include "main/texstore.h"
 
-#include "main/mm.h"
 #include "via_context.h"
 #include "via_fb.h"
 #include "via_tex.h"
@@ -48,7 +48,7 @@
 #include "via_ioctl.h"
 #include "via_3d_reg.h"
 
-static const struct gl_texture_format *
+static gl_format
 viaChooseTexFormat( GLcontext *ctx, GLint internalFormat,
                    GLenum format, GLenum type )
 {
@@ -65,56 +65,56 @@ viaChooseTexFormat( GLcontext *ctx, GLint internalFormat,
       if ( format == GL_BGRA ) {
         if ( type == GL_UNSIGNED_INT_8_8_8_8_REV ||
              type == GL_UNSIGNED_BYTE ) {
-           return &_mesa_texformat_argb8888;
+           return MESA_FORMAT_ARGB8888;
         }
          else if ( type == GL_UNSIGNED_SHORT_4_4_4_4_REV ) {
-            return &_mesa_texformat_argb4444;
+            return MESA_FORMAT_ARGB4444;
         }
          else if ( type == GL_UNSIGNED_SHORT_1_5_5_5_REV ) {
-           return &_mesa_texformat_argb1555;
+           return MESA_FORMAT_ARGB1555;
         }
       }
       else if ( type == GL_UNSIGNED_BYTE ||
                type == GL_UNSIGNED_INT_8_8_8_8_REV ||
                type == GL_UNSIGNED_INT_8_8_8_8 ) {
-        return &_mesa_texformat_argb8888;
+        return MESA_FORMAT_ARGB8888;
       }
-      return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+      return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444;
 
    case 3:
    case GL_RGB:
    case GL_COMPRESSED_RGB:
       if ( format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5 ) {
-        return &_mesa_texformat_rgb565;
+        return MESA_FORMAT_RGB565;
       }
       else if ( type == GL_UNSIGNED_BYTE ) {
-        return &_mesa_texformat_argb8888;
+        return MESA_FORMAT_ARGB8888;
       }
-      return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
+      return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_RGB565;
 
    case GL_RGBA8:
    case GL_RGB10_A2:
    case GL_RGBA12:
    case GL_RGBA16:
-      return &_mesa_texformat_argb8888;
+      return MESA_FORMAT_ARGB8888;
 
    case GL_RGBA4:
    case GL_RGBA2:
-      return &_mesa_texformat_argb4444;
+      return MESA_FORMAT_ARGB4444;
 
    case GL_RGB5_A1:
-      return &_mesa_texformat_argb1555;
+      return MESA_FORMAT_ARGB1555;
 
    case GL_RGB8:
    case GL_RGB10:
    case GL_RGB12:
    case GL_RGB16:
-      return &_mesa_texformat_argb8888;
+      return MESA_FORMAT_ARGB8888;
 
    case GL_RGB5:
    case GL_RGB4:
    case GL_R3_G3_B2:
-      return &_mesa_texformat_rgb565;
+      return MESA_FORMAT_RGB565;
 
    case GL_ALPHA:
    case GL_ALPHA4:
@@ -122,7 +122,7 @@ viaChooseTexFormat( GLcontext *ctx, GLint internalFormat,
    case GL_ALPHA12:
    case GL_ALPHA16:
    case GL_COMPRESSED_ALPHA:
-      return &_mesa_texformat_a8;
+      return MESA_FORMAT_A8;
 
    case 1:
    case GL_LUMINANCE:
@@ -131,7 +131,7 @@ viaChooseTexFormat( GLcontext *ctx, GLint internalFormat,
    case GL_LUMINANCE12:
    case GL_LUMINANCE16:
    case GL_COMPRESSED_LUMINANCE:
-      return &_mesa_texformat_l8;
+      return MESA_FORMAT_L8;
 
    case 2:
    case GL_LUMINANCE_ALPHA:
@@ -142,7 +142,7 @@ viaChooseTexFormat( GLcontext *ctx, GLint internalFormat,
    case GL_LUMINANCE12_ALPHA12:
    case GL_LUMINANCE16_ALPHA16:
    case GL_COMPRESSED_LUMINANCE_ALPHA:
-      return &_mesa_texformat_al88;
+      return MESA_FORMAT_AL88;
 
    case GL_INTENSITY:
    case GL_INTENSITY4:
@@ -150,35 +150,35 @@ viaChooseTexFormat( GLcontext *ctx, GLint internalFormat,
    case GL_INTENSITY12:
    case GL_INTENSITY16:
    case GL_COMPRESSED_INTENSITY:
-      return &_mesa_texformat_i8;
+      return MESA_FORMAT_I8;
 
    case GL_YCBCR_MESA:
       if (type == GL_UNSIGNED_SHORT_8_8_MESA ||
          type == GL_UNSIGNED_BYTE)
-         return &_mesa_texformat_ycbcr;
+         return MESA_FORMAT_YCBCR;
       else
-         return &_mesa_texformat_ycbcr_rev;
+         return MESA_FORMAT_YCBCR_REV;
 
    case GL_COMPRESSED_RGB_FXT1_3DFX:
-      return &_mesa_texformat_rgb_fxt1;
+      return MESA_FORMAT_RGB_FXT1;
    case GL_COMPRESSED_RGBA_FXT1_3DFX:
-      return &_mesa_texformat_rgba_fxt1;
+      return MESA_FORMAT_RGBA_FXT1;
 
    case GL_RGB_S3TC:
    case GL_RGB4_S3TC:
    case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
-      return &_mesa_texformat_rgb_dxt1;
+      return MESA_FORMAT_RGB_DXT1;
 
    case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
-      return &_mesa_texformat_rgba_dxt1;
+      return MESA_FORMAT_RGBA_DXT1;
 
    case GL_RGBA_S3TC:
    case GL_RGBA4_S3TC:
    case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
-      return &_mesa_texformat_rgba_dxt3;
+      return MESA_FORMAT_RGBA_DXT3;
 
    case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
-      return &_mesa_texformat_rgba_dxt5;
+      return MESA_FORMAT_RGBA_DXT5;
 
    case GL_COLOR_INDEX:        
    case GL_COLOR_INDEX1_EXT:   
@@ -187,16 +187,16 @@ viaChooseTexFormat( GLcontext *ctx, GLint internalFormat,
    case GL_COLOR_INDEX8_EXT:   
    case GL_COLOR_INDEX12_EXT:      
    case GL_COLOR_INDEX16_EXT:
-      return &_mesa_texformat_ci8;    
+      return MESA_FORMAT_CI8;
 
    default:
       fprintf(stderr, "unexpected texture format %s in %s\n", 
              _mesa_lookup_enum_by_nr(internalFormat),
              __FUNCTION__);
-      return NULL;
+      return MESA_FORMAT_NONE;
    }
 
-   return NULL; /* never get here */
+   return MESA_FORMAT_NONE; /* never get here */
 }
 
 static int logbase2(int n)
@@ -457,7 +457,7 @@ static GLboolean viaSetTexImages(GLcontext *ctx,
    GLuint widthExp = 0;
    GLuint heightExp = 0;    
 
-   switch (baseImage->image.TexFormat->MesaFormat) {
+   switch (baseImage->image.TexFormat) {
    case MESA_FORMAT_ARGB8888:
       texFormat = HC_HTXnFM_ARGB8888;
       break;
@@ -689,24 +689,7 @@ static void viaTexImage(GLcontext *ctx,
 
    assert(texImage->TexFormat);
 
-   if (dims == 1) {
-      texImage->FetchTexelc = texImage->TexFormat->FetchTexel1D;
-      texImage->FetchTexelf = texImage->TexFormat->FetchTexel1Df;
-   }
-   else {
-      texImage->FetchTexelc = texImage->TexFormat->FetchTexel2D;
-      texImage->FetchTexelf = texImage->TexFormat->FetchTexel2Df;
-   }
-   texelBytes = texImage->TexFormat->TexelBytes;
-
-   if (texelBytes == 0) {
-      /* compressed format */
-      texImage->IsCompressed = GL_TRUE;
-      texImage->CompressedSize =
-         ctx->Driver.CompressedTextureSize(ctx, texImage->Width,
-                                           texImage->Height, texImage->Depth,
-                                           texImage->TexFormat->MesaFormat);
-   }
+   texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
 
    /* Minimum pitch of 32 bytes */
    if (postConvWidth * texelBytes < 32) {
@@ -718,8 +701,11 @@ static void viaTexImage(GLcontext *ctx,
    viaImage->pitchLog2 = logbase2(postConvWidth * texelBytes);
 
    /* allocate memory */
-   if (texImage->IsCompressed)
-      sizeInBytes = texImage->CompressedSize;
+   if (_mesa_is_format_compressed(texImage->TexFormat))
+      sizeInBytes = _mesa_format_image_size(texImage->TexFormat,
+                                            texImage->Width,
+                                            texImage->Height,
+                                            texImage->Depth);
    else
       sizeInBytes = postConvWidth * postConvHeight * texelBytes;
 
@@ -797,22 +783,22 @@ static void viaTexImage(GLcontext *ctx,
    else {
       GLint dstRowStride;
       GLboolean success;
-      if (texImage->IsCompressed) {
-         dstRowStride = _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat, width);
+
+      if (_mesa_is_format_compressed(texImage->TexFormat)) {
+         dstRowStride = _mesa_format_row_stride(texImage->TexFormat, width);
       }
       else {
-         dstRowStride = postConvWidth * texImage->TexFormat->TexelBytes;
+         dstRowStride = postConvWidth * _mesa_get_format_bytes(texImage->TexFormat);
       }
-      ASSERT(texImage->TexFormat->StoreImage);
-      success = texImage->TexFormat->StoreImage(ctx, dims,
-                                                texImage->_BaseFormat,
-                                                texImage->TexFormat,
-                                                texImage->Data,
-                                                0, 0, 0,  /* dstX/Y/Zoffset */
-                                                dstRowStride,
-                                                texImage->ImageOffsets,
-                                                width, height, 1,
-                                                format, type, pixels, packing);
+      success = _mesa_texstore(ctx, dims,
+                               texImage->_BaseFormat,
+                               texImage->TexFormat,
+                               texImage->Data,
+                               0, 0, 0,  /* dstX/Y/Zoffset */
+                               dstRowStride,
+                               texImage->ImageOffsets,
+                               width, height, 1,
+                               format, type, pixels, packing);
       if (!success) {
          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
       }
index 79e67620c9edc784558fc5e11607a4d0d6a3edde..01359d51ea641c4dbcbc78c155138f783824693b 100644 (file)
@@ -330,7 +330,8 @@ do {                                                        \
 
 #define LOCAL_VARS(n)                                                   \
     struct via_context *vmesa = VIA_CONTEXT(ctx);                             \
-    GLuint color[n], spec[n];                                           \
+    GLuint color[n] = { 0 };                                          \
+    GLuint spec[n] = { 0 };                                           \
     GLuint coloroffset = vmesa->coloroffset;              \
     GLuint specoffset = vmesa->specoffset;                       \
     (void)color; (void)spec; (void)coloroffset; (void)specoffset;
@@ -832,13 +833,13 @@ static GLboolean viaCheckPTexHack( GLcontext *ctx )
 
    RENDERINPUTS_COPY( index_bitset, tnl->render_inputs_bitset );
 
-   if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX0 ) && VB->TexCoordPtr[0]->size == 4) {
+   if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX0 ) && VB->AttribPtr[_TNL_ATTRIB_TEX0]->size == 4) {
       if (!RENDERINPUTS_TEST_RANGE( index_bitset, _TNL_ATTRIB_TEX1, _TNL_LAST_TEX ))
         ptexHack = GL_TRUE; 
       else
         fallback = GL_TRUE;
    }
-   if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX1 ) && VB->TexCoordPtr[1]->size == 4)
+   if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX1 ) && VB->AttribPtr[_TNL_ATTRIB_TEX1]->size == 4)
       fallback = GL_TRUE;
 
    FALLBACK(VIA_CONTEXT(ctx), VIA_FALLBACK_PROJ_TEXTURE, fallback);
index f3cd9081810e1ae6dda690578412bf863ea6494e..9dd4f1e9c37223fc69d7dff214abbdf860e26694 100644 (file)
 
 #include "fxdrv.h"
 #include "main/enums.h"
+#include "main/formats.h"
 #include "main/image.h"
 #include "main/teximage.h"
+#include "main/texstore.h"
 #include "main/texformat.h"
 #include "main/texcompress.h"
 #include "main/texobj.h"
@@ -89,14 +91,14 @@ _mesa_halve2x2_teximage2d ( GLcontext *ctx,
       }
       _s = src = MALLOC(srcRowStride * srcHeight);
       _d = dst = MALLOC(dstWidth * bytesPerPixel * dstHeight);
-      _mesa_texstore_rgba8888(ctx, 2, GL_RGBA,
-                              &_mesa_texformat_rgba8888_rev, src,
-                              0, 0, 0, /* dstX/Y/Zoffset */
-                              srcRowStride, /* dstRowStride */
-                              0, /* dstImageStride */
-                              srcWidth, srcHeight, 1,
-                              texImage->_BaseFormat, _t,
-                              srcImage, &ctx->DefaultPacking);
+      _mesa_texstore(ctx, 2, GL_RGBA,
+                     &_mesa_texformat_rgba8888_rev, src,
+                     0, 0, 0, /* dstX/Y/Zoffset */
+                     srcRowStride, /* dstRowStride */
+                     0, /* dstImageStride */
+                     srcWidth, srcHeight, 1,
+                     texImage->_BaseFormat, _t,
+                     srcImage, &ctx->DefaultPacking);
    }
 
    if (srcHeight == 1) {
@@ -137,13 +139,13 @@ _mesa_halve2x2_teximage2d ( GLcontext *ctx,
    if (bpt) {
       src = _s;
       dst = _d;
-      texImage->TexFormat->StoreImage(ctx, 2, texImage->_BaseFormat,
-                                      texImage->TexFormat, dstImage,
-                                      0, 0, 0, /* dstX/Y/Zoffset */
-                                      dstWidth * bpt,
-                                      0, /* dstImageStride */
-                                      dstWidth, dstHeight, 1,
-                                      GL_BGRA, CHAN_TYPE, dst, &ctx->DefaultPacking);
+      _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+                     texImage->TexFormat, dstImage,
+                     0, 0, 0, /* dstX/Y/Zoffset */
+                     dstWidth * bpt,
+                     0, /* dstImageStride */
+                     dstWidth, dstHeight, 1,
+                     GL_BGRA, CHAN_TYPE, dst, &ctx->DefaultPacking);
       FREE(dst);
       FREE(src);
    }
@@ -273,8 +275,9 @@ fxDDTexEnv(GLcontext * ctx, GLenum target, GLenum pname,
    /* apply any lod biasing right now */
    if (pname == GL_TEXTURE_LOD_BIAS_EXT) {
       GLfloat bias = *param;
-      CLAMP_SELF(bias, -ctx->Const.MaxTextureLodBias,
-                        ctx->Const.MaxTextureLodBias - 0.25);
+      bias = CLAMP(bias,
+                  -ctx->Const.MaxTextureLodBias,
+                  ctx->Const.MaxTextureLodBias - 0.25);
 
       grTexLodBiasValue(GR_TMU0, bias);
 
@@ -1014,7 +1017,7 @@ PrintTexture(int w, int h, int c, const GLubyte * data)
 #endif
 
 
-const struct gl_texture_format *
+gl_format
 fxDDChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
                          GLenum srcFormat, GLenum srcType )
 {
@@ -1031,31 +1034,31 @@ fxDDChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case 3:
    case GL_RGB:
      if ( srcFormat == GL_RGB && srcType == GL_UNSIGNED_SHORT_5_6_5 ) {
-       return &_mesa_texformat_rgb565;
+       return MESA_FORMAT_RGB565;
      }
      /* intentional fall through */
    case GL_RGB8:
    case GL_RGB10:
    case GL_RGB12:
    case GL_RGB16:
-      return (allow32bpt) ? &_mesa_texformat_argb8888
-                          : &_mesa_texformat_rgb565;
+      return (allow32bpt) ? MESA_FORMAT_ARGB8888
+                          : MESA_FORMAT_RGB565;
    case GL_RGBA2:
    case GL_RGBA4:
-      return &_mesa_texformat_argb4444;
+      return MESA_FORMAT_ARGB4444;
    case GL_COMPRESSED_RGBA:
      /* intentional fall through */
    case 4:
    case GL_RGBA:
      if ( srcFormat == GL_BGRA ) {
        if ( srcType == GL_UNSIGNED_INT_8_8_8_8_REV ) {
-         return &_mesa_texformat_argb8888;
+         return MESA_FORMAT_ARGB8888;
        }
        else if ( srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV ) {
-         return &_mesa_texformat_argb4444;
+         return MESA_FORMAT_ARGB4444;
        }
        else if ( srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV ) {
-         return &_mesa_texformat_argb1555;
+         return MESA_FORMAT_ARGB1555;
        }
      }
      /* intentional fall through */
@@ -1063,15 +1066,15 @@ fxDDChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_RGB10_A2:
    case GL_RGBA12:
    case GL_RGBA16:
-      return (allow32bpt) ? &_mesa_texformat_argb8888
-                          : &_mesa_texformat_argb4444;
+      return (allow32bpt) ? MESA_FORMAT_ARGB8888
+                          : MESA_FORMAT_ARGB4444;
    case GL_INTENSITY:
    case GL_INTENSITY4:
    case GL_INTENSITY8:
    case GL_INTENSITY12:
    case GL_INTENSITY16:
    case GL_COMPRESSED_INTENSITY:
-      return &_mesa_texformat_i8;
+      return MESA_FORMAT_I8;
    case 1:
    case GL_LUMINANCE:
    case GL_LUMINANCE4:
@@ -1079,14 +1082,14 @@ fxDDChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_LUMINANCE12:
    case GL_LUMINANCE16:
    case GL_COMPRESSED_LUMINANCE:
-      return &_mesa_texformat_l8;
+      return MESA_FORMAT_L8;
    case GL_ALPHA:
    case GL_ALPHA4:
    case GL_ALPHA8:
    case GL_ALPHA12:
    case GL_ALPHA16:
    case GL_COMPRESSED_ALPHA:
-      return &_mesa_texformat_a8;
+      return MESA_FORMAT_A8;
    case GL_COLOR_INDEX:
    case GL_COLOR_INDEX1_EXT:
    case GL_COLOR_INDEX2_EXT:
@@ -1094,7 +1097,7 @@ fxDDChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_COLOR_INDEX8_EXT:
    case GL_COLOR_INDEX12_EXT:
    case GL_COLOR_INDEX16_EXT:
-      return &_mesa_texformat_ci8;
+      return MESA_FORMAT_CI8;
    case 2:
    case GL_LUMINANCE_ALPHA:
    case GL_LUMINANCE4_ALPHA4:
@@ -1104,35 +1107,35 @@ fxDDChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_LUMINANCE12_ALPHA12:
    case GL_LUMINANCE16_ALPHA16:
    case GL_COMPRESSED_LUMINANCE_ALPHA:
-      return &_mesa_texformat_al88;
+      return MESA_FORMAT_AL88;
    case GL_R3_G3_B2:
    case GL_RGB4:
    case GL_RGB5:
-      return &_mesa_texformat_rgb565;
+      return MESA_FORMAT_RGB565;
    case GL_RGB5_A1:
-      return &_mesa_texformat_argb1555;
+      return MESA_FORMAT_ARGB1555;
    /* GL_EXT_texture_compression_s3tc */
    /* GL_S3_s3tc */
    case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
    case GL_RGB_S3TC:
    case GL_RGB4_S3TC:
-      return &_mesa_texformat_rgb_dxt1;
+      return MESA_FORMAT_RGB_DXT1;
    case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
-      return &_mesa_texformat_rgba_dxt1;
+      return MESA_FORMAT_RGBA_DXT1;
    case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
    case GL_RGBA_S3TC:
    case GL_RGBA4_S3TC:
-      return &_mesa_texformat_rgba_dxt3;
+      return MESA_FORMAT_RGBA_DXT3;
    case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
-      return &_mesa_texformat_rgba_dxt5;
+      return MESA_FORMAT_RGBA_DXT5;
    /* GL_3DFX_texture_compression_FXT1 */
    case GL_COMPRESSED_RGB_FXT1_3DFX:
-      return &_mesa_texformat_rgb_fxt1;
+      return MESA_FORMAT_RGB_FXT1;
    case GL_COMPRESSED_RGBA_FXT1_3DFX:
-      return &_mesa_texformat_rgba_fxt1;
+      return MESA_FORMAT_RGBA_FXT1;
    default:
       _mesa_problem(NULL, "unexpected format in fxDDChooseTextureFormat");
-      return NULL;
+      return MESA_FORMAT_NONE;
    }
 }
 
@@ -1232,20 +1235,21 @@ adjust2DRatio (GLcontext *ctx,
    const GLint newHeight = height * mml->hScale;
    GLvoid *tempImage;
 
-   if (!texImage->IsCompressed) {
+   if (!_mesa_is_format_compressed(texImage->TexFormat)) {
       GLubyte *destAddr;
+
       tempImage = MALLOC(width * height * texelBytes);
       if (!tempImage) {
          return GL_FALSE;
       }
 
-      texImage->TexFormat->StoreImage(ctx, 2, texImage->_BaseFormat,
-                                      texImage->TexFormat, tempImage,
-                                      0, 0, 0, /* dstX/Y/Zoffset */
-                                      width * texelBytes, /* dstRowStride */
-                                      0, /* dstImageStride */
-                                      width, height, 1,
-                                      format, type, pixels, packing);
+      _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+                     texImage->TexFormat, tempImage,
+                     0, 0, 0, /* dstX/Y/Zoffset */
+                     width * texelBytes, /* dstRowStride */
+                     0, /* dstImageStride */
+                     width, height, 1,
+                     format, type, pixels, packing);
 
       /* now rescale */
       /* compute address of dest subimage within the overal tex image */
@@ -1262,6 +1266,7 @@ adjust2DRatio (GLcontext *ctx,
    } else {
       const GLint rawBytes = 4;
       GLvoid *rawImage = MALLOC(width * height * rawBytes);
+
       if (!rawImage) {
          return GL_FALSE;
       }
@@ -1270,26 +1275,26 @@ adjust2DRatio (GLcontext *ctx,
          return GL_FALSE;
       }
       /* unpack image, apply transfer ops and store in rawImage */
-      _mesa_texstore_rgba8888(ctx, 2, GL_RGBA,
-                              &_mesa_texformat_rgba8888_rev, rawImage,
-                              0, 0, 0, /* dstX/Y/Zoffset */
-                              width * rawBytes, /* dstRowStride */
-                              0, /* dstImageStride */
-                              width, height, 1,
-                              format, type, pixels, packing);
+      _mesa_texstore(ctx, 2, GL_RGBA,
+                     &_mesa_texformat_rgba8888_rev, rawImage,
+                     0, 0, 0, /* dstX/Y/Zoffset */
+                     width * rawBytes, /* dstRowStride */
+                     0, /* dstImageStride */
+                     width, height, 1,
+                     format, type, pixels, packing);
       _mesa_rescale_teximage2d(rawBytes,
                                width,
                                newWidth * rawBytes, /* dst stride */
                                width, height, /* src */
                                newWidth, newHeight, /* dst */
                                rawImage /*src*/, tempImage /*dst*/ );
-      texImage->TexFormat->StoreImage(ctx, 2, texImage->_BaseFormat,
-                                      texImage->TexFormat, texImage->Data,
-                                      xoffset * mml->wScale, yoffset * mml->hScale, 0, /* dstX/Y/Zoffset */
-                                      dstRowStride,
-                                      0, /* dstImageStride */
-                                      newWidth, newHeight, 1,
-                                      GL_RGBA, CHAN_TYPE, tempImage, &ctx->DefaultPacking);
+      _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+                     texImage->TexFormat, texImage->Data,
+                     xoffset * mml->wScale, yoffset * mml->hScale, 0, /* dstX/Y/Zoffset */
+                     dstRowStride,
+                     0, /* dstImageStride */
+                     newWidth, newHeight, 1,
+                     GL_RGBA, CHAN_TYPE, tempImage, &ctx->DefaultPacking);
       FREE(rawImage);
    }
 
@@ -1349,7 +1354,7 @@ fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
 
 #if FX_COMPRESS_S3TC_AS_FXT1_HACK
    /* [koolsmoky] substitute FXT1 for DXTn and Legacy S3TC */
-   if (!ctx->Mesa_DXTn && texImage->IsCompressed) {
+   if (!ctx->Mesa_DXTn && _mesa_is_format_compressed(texImage->TexFormat)) {
      switch (internalFormat) {
      case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
      case GL_RGB_S3TC:
@@ -1376,30 +1381,22 @@ fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
       }
       if (texNapalm) {
          texImage->InternalFormat = internalFormat = texNapalm;
-         texImage->IsCompressed = GL_TRUE;
       }
    }
 #endif
 
-   /* choose the texture format */
-   assert(ctx->Driver.ChooseTextureFormat);
-   texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
-                                          internalFormat, format, type);
-   assert(texImage->TexFormat);
-   texelBytes = texImage->TexFormat->TexelBytes;
+   texelBytes = _mesa_get_format_bytes(texImage->TexFormat->MesaFormat);
    /*if (!fxMesa->HaveTexFmt) assert(texelBytes == 1 || texelBytes == 2);*/
 
    mml->glideFormat = fxGlideFormat(texImage->TexFormat->MesaFormat);
 
    /* allocate mipmap buffer */
    assert(!texImage->Data);
-   if (texImage->IsCompressed) {
-      texImage->CompressedSize = _mesa_compressed_texture_size(ctx,
-                                                               mml->width,
-                                                               mml->height,
-                                                               1,
-                                                               internalFormat);
-      dstRowStride = _mesa_compressed_row_stride(internalFormat, mml->width);
+   if (_mesa_is_format_compressed(texImage->TexFormat)) {
+      texImage->CompressedSize = _mesa_format_image_size(texImage->TexFormat,
+                                                         mml->width,
+                                                         mml->height, 1);
+      dstRowStride = _mesa_format_row_stride(texImage->TexFormat, mml->width);
       texImage->Data = _mesa_malloc(texImage->CompressedSize);
    } else {
       dstRowStride = mml->width * texelBytes;
@@ -1430,13 +1427,13 @@ fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
       else {
          /* no rescaling needed */
          /* unpack image, apply transfer ops and store in texImage->Data */
-         texImage->TexFormat->StoreImage(ctx, 2, texImage->_BaseFormat,
-                                         texImage->TexFormat, texImage->Data,
-                                         0, 0, 0, /* dstX/Y/Zoffset */
-                                         dstRowStride,
-                                         0, /* dstImageStride */
-                                         width, height, 1,
-                                         format, type, pixels, packing);
+         _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+                        texImage->TexFormat, texImage->Data,
+                        0, 0, 0, /* dstX/Y/Zoffset */
+                        dstRowStride,
+                        0, /* dstImageStride */
+                        width, height, 1,
+                        format, type, pixels, packing);
       }
 
       /* GL_SGIS_generate_mipmap */
@@ -1447,7 +1444,7 @@ fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
          const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
          const GLint maxLevels = _mesa_max_texture_levels(ctx, texObj->Target);
 
-         assert(!texImage->IsCompressed);
+         assert(!_mesa_is_format_compressed(texImage->TexFormat));
 
          while (level < texObj->MaxLevel && level < maxLevels - 1) {
             mipWidth = width / 2;
@@ -1518,9 +1515,9 @@ fxDDTexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
    assert(texImage->Data);     /* must have an existing texture image! */
    assert(texImage->_BaseFormat);
 
-   texelBytes = texImage->TexFormat->TexelBytes;
-   if (texImage->IsCompressed) {
-      dstRowStride = _mesa_compressed_row_stride(texImage->InternalFormat, mml->width);
+   texelBytes = _mesa_get_format_bytes(texImage->TexFormat->MesaFormat);
+   if (_mesa_is_format_compressed(texImage->TexFormat)) {
+      dstRowStride = _mesa_format_row_stride(texImage->TexFormat, mml->width);
    } else {
       dstRowStride = mml->width * texelBytes;
    }
@@ -1543,13 +1540,13 @@ fxDDTexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
    }
    else {
       /* no rescaling needed */
-      texImage->TexFormat->StoreImage(ctx, 2, texImage->_BaseFormat,
-                                      texImage->TexFormat, (GLubyte *) texImage->Data,
-                                      xoffset, yoffset, 0, /* dstX/Y/Zoffset */
-                                      dstRowStride,
-                                      0, /* dstImageStride */
-                                      width, height, 1,
-                                      format, type, pixels, packing);
+      _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+                     texImage->TexFormat, (GLubyte *) texImage->Data,
+                     xoffset, yoffset, 0, /* dstX/Y/Zoffset */
+                     dstRowStride,
+                     0, /* dstImageStride */
+                     width, height, 1,
+                     format, type, pixels, packing);
    }
 
    /* GL_SGIS_generate_mipmap */
@@ -1560,7 +1557,7 @@ fxDDTexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
       const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
       const GLint maxLevels = _mesa_max_texture_levels(ctx, texObj->Target);
 
-      assert(!texImage->IsCompressed);
+      assert(!_mesa_is_format_compressed(texImage->TexFormat));
 
       width = texImage->Width;
       height = texImage->Height;
@@ -1616,7 +1613,7 @@ fxDDCompressedTexImage2D (GLcontext *ctx, GLenum target,
                        width, height);
    }
 
-   assert(texImage->IsCompressed);
+   assert(_mesa_is_format_compressed(texImage->TexFormat));
 
    if (!fxIsTexSupported(target, internalFormat, texImage)) {
       _mesa_problem(NULL, "fx Driver: unsupported texture in fxDDCompressedTexImg()\n");
@@ -1647,13 +1644,6 @@ fxDDCompressedTexImage2D (GLcontext *ctx, GLenum target,
    mml->width = width * mml->wScale;
    mml->height = height * mml->hScale;
 
-
-   /* choose the texture format */
-   assert(ctx->Driver.ChooseTextureFormat);
-   texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
-                                          internalFormat, -1/*format*/, -1/*type*/);
-   assert(texImage->TexFormat);
-
    /* Determine the appropriate Glide texel format,
     * given the user's internal texture format hint.
     */
@@ -1661,11 +1651,9 @@ fxDDCompressedTexImage2D (GLcontext *ctx, GLenum target,
 
    /* allocate new storage for texture image, if needed */
    if (!texImage->Data) {
-      texImage->CompressedSize = _mesa_compressed_texture_size(ctx,
-                                                               mml->width,
-                                                               mml->height,
-                                                               1,
-                                                               internalFormat);
+      texImage->CompressedSize = _mesa_format_image_size(texImage->TexFormat,
+                                                         mml->width,
+                                                         mml->height, 1);
       texImage->Data = _mesa_malloc(texImage->CompressedSize);
       if (!texImage->Data) {
          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
@@ -1689,10 +1677,10 @@ fxDDCompressedTexImage2D (GLcontext *ctx, GLenum target,
        *    we replicate the data over the padded area.
        * For now, we take 2) + 3) but texelfetchers will be wrong!
        */
-      GLuint srcRowStride = _mesa_compressed_row_stride(internalFormat, width);
+      GLuint srcRowStride = _mesa_format_row_stride(texImage->TexFormat, width);
 
-      GLuint destRowStride = _mesa_compressed_row_stride(internalFormat,
-                                                  mml->width);
+      GLuint destRowStride = _mesa_format_row_stride(texImage->TexFormat,
+                                                     mml->width);
 
       _mesa_upscale_teximage2d(srcRowStride, (height+3) / 4,
                                destRowStride, (mml->height+3) / 4,
@@ -1708,7 +1696,7 @@ fxDDCompressedTexImage2D (GLcontext *ctx, GLenum target,
 
    /* GL_SGIS_generate_mipmap */
    if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
-      assert(!texImage->IsCompressed);
+      assert(!_mesa_is_format_compressed(texImage->TexFormat));
    }
 
    fxTexInvalidate(ctx, texObj);
@@ -1740,10 +1728,9 @@ fxDDCompressedTexSubImage2D( GLcontext *ctx, GLenum target,
    mml = FX_MIPMAP_DATA(texImage);
    assert(mml);
 
-   srcRowStride = _mesa_compressed_row_stride(texImage->InternalFormat, width);
+   srcRowStride = _mesa_format_row_stride(texImage->TexFormat, width);
 
-   destRowStride = _mesa_compressed_row_stride(texImage->InternalFormat,
-                                               mml->width);
+   destRowStride = _mesa_format_row_stride(texImage->TexFormat, mml->width);
    dest = _mesa_compressed_image_address(xoffset, yoffset, 0,
                                          texImage->InternalFormat,
                                          mml->width,
@@ -1761,10 +1748,9 @@ fxDDCompressedTexSubImage2D( GLcontext *ctx, GLenum target,
     * see fxDDCompressedTexImage2D for caveats
     */
    if (mml->wScale != 1 || mml->hScale != 1) {
-      srcRowStride = _mesa_compressed_row_stride(texImage->InternalFormat, texImage->Width);
+      srcRowStride = _mesa_format_row_stride(texImage->TexFormat, texImage->Width);
 
-      destRowStride = _mesa_compressed_row_stride(texImage->InternalFormat,
-                                               mml->width);
+      destRowStride = _mesa_format_row_stride(texImage->TexFormat, mml->width);
       _mesa_upscale_teximage2d(srcRowStride, texImage->Height / 4,
                                destRowStride, mml->height / 4,
                                1, texImage->Data, destRowStride,
@@ -1773,7 +1759,7 @@ fxDDCompressedTexSubImage2D( GLcontext *ctx, GLenum target,
 
    /* GL_SGIS_generate_mipmap */
    if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
-      assert(!texImage->IsCompressed);
+      assert(!_mesa_is_format_compressed(texImage->TexFormat));
    }
 
    if (ti->validated && ti->isInTM)
index d48726a62ae518cd7d883ad766035d2a3ce9c787..9bf37967cd7b866185119a959c8b4335f6a8c3ec 100644 (file)
@@ -42,6 +42,7 @@
 
 #include "fxdrv.h"
 #include "main/enums.h"
+#include "main/formats.h"
 #include "main/texstore.h"
 #include "tnl/tnl.h"
 #include "tnl/t_context.h"
@@ -91,7 +92,7 @@ fxTexValidate(GLcontext * ctx, struct gl_texture_object *tObj)
       GLint _w, _h, maxSize = 1 << fxMesa->textureMaxLod;
       if ((mml->width > maxSize) || (mml->height > maxSize)) {
          /* need to rescale */
-         GLint texelBytes = texImage->TexFormat->TexelBytes;
+         GLint texelBytes = _mesa_get_format_bytes(texImage->TexFormat->MesaFormat);
          GLvoid *texImage_Data = texImage->Data;
          _w = MIN2(texImage->Width, maxSize);
          _h = MIN2(texImage->Height, maxSize);
index 1dc5f9891a1613c876e13bbf7a13fa96b9cd8ae4..cc9ad0e8b8349d5ff3537068bd09f4db6bf40146 100644 (file)
@@ -104,24 +104,24 @@ static void interp_extras( GLcontext *ctx,
 {
    struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
 
-   if (VB->ColorPtr[1]) {
-      /* If stride is zero, ColorPtr[1] is constant across the VB, so
+   if (VB->BackfaceColorPtr) {
+      /* If stride is zero, BackfaceColorPtr is constant across the VB, so
        * there is no point interpolating between two values as they will
        * be identical.  This case is handled in t_dd_tritmp.h
        */
-      if (VB->ColorPtr[1]->stride) {
-        assert(VB->ColorPtr[1]->stride == 4 * sizeof(GLfloat));
+      if (VB->BackfaceColorPtr->stride) {
+        assert(VB->BackfaceColorPtr->stride == 4 * sizeof(GLfloat));
         INTERP_4F( t,
-                   GET_COLOR(VB->ColorPtr[1], dst),
-                   GET_COLOR(VB->ColorPtr[1], out),
-                   GET_COLOR(VB->ColorPtr[1], in) );
+                   GET_COLOR(VB->BackfaceColorPtr, dst),
+                   GET_COLOR(VB->BackfaceColorPtr, out),
+                   GET_COLOR(VB->BackfaceColorPtr, in) );
       }
 
-      if (VB->SecondaryColorPtr[1]) {
+      if (VB->BackfaceSecondaryColorPtr) {
         INTERP_3F( t,
-                   GET_COLOR(VB->SecondaryColorPtr[1], dst),
-                   GET_COLOR(VB->SecondaryColorPtr[1], out),
-                   GET_COLOR(VB->SecondaryColorPtr[1], in) );
+                   GET_COLOR(VB->BackfaceSecondaryColorPtr, dst),
+                   GET_COLOR(VB->BackfaceSecondaryColorPtr, out),
+                   GET_COLOR(VB->BackfaceSecondaryColorPtr, in) );
       }
    }
 
@@ -137,13 +137,13 @@ static void copy_pv_extras( GLcontext *ctx, GLuint dst, GLuint src )
 {
    struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
 
-   if (VB->ColorPtr[1]) {
-        COPY_4FV( GET_COLOR(VB->ColorPtr[1], dst),
-                  GET_COLOR(VB->ColorPtr[1], src) );
+   if (VB->BackfaceColorPtr) {
+        COPY_4FV( GET_COLOR(VB->BackfaceColorPtr, dst),
+                  GET_COLOR(VB->BackfaceColorPtr, src) );
 
-        if (VB->SecondaryColorPtr[1]) {
-           COPY_3FV( GET_COLOR(VB->SecondaryColorPtr[1], dst),
-                     GET_COLOR(VB->SecondaryColorPtr[1], src) );
+        if (VB->BackfaceSecondaryColorPtr) {
+           COPY_3FV( GET_COLOR(VB->BackfaceSecondaryColorPtr, dst),
+                     GET_COLOR(VB->BackfaceSecondaryColorPtr, src) );
         }
    }
 
index f7970c78e290872e7527731ccc2bbaab132fb74d..f7893c1573fb2943292834cbdce36e9516d2a642 100644 (file)
@@ -62,37 +62,37 @@ static void TAG(emit)( GLcontext *ctx,
    }
 
    if (IND & SETUP_TMU0) {
-      tc0 = VB->TexCoordPtr[tmu0_source]->data;
-      tc0_stride = VB->TexCoordPtr[tmu0_source]->stride;
+      tc0 = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu0_source]->data;
+      tc0_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu0_source]->stride;
       u0scale = fxMesa->s0scale;
       v0scale = fxMesa->t0scale;
       if (IND & SETUP_PTEX)
-        tc0_size = VB->TexCoordPtr[tmu0_source]->size;
+        tc0_size = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu0_source]->size;
    }
 
    if (IND & SETUP_TMU1) {
-      tc1 = VB->TexCoordPtr[tmu1_source]->data;
-      tc1_stride = VB->TexCoordPtr[tmu1_source]->stride;
+      tc1 = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu1_source]->data;
+      tc1_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu1_source]->stride;
       u1scale = fxMesa->s1scale; /* wrong if tmu1_source == 0, possible? */
       v1scale = fxMesa->t1scale;
       if (IND & SETUP_PTEX)
-        tc1_size = VB->TexCoordPtr[tmu1_source]->size;
+        tc1_size = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu1_source]->size;
    }
    
    if (IND & SETUP_RGBA) {
-      col = VB->ColorPtr[0]->data;
-      col_stride = VB->ColorPtr[0]->stride;
-      col_size = VB->ColorPtr[0]->size;
+      col = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->data;
+      col_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->stride;
+      col_size = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->size;
    }
 
    if (IND & SETUP_SPEC) {
-      spec = VB->SecondaryColorPtr[0]->data;
-      spec_stride = VB->SecondaryColorPtr[0]->stride;
+      spec = VB->AttribPtr[_TNL_ATTRIB_COLOR1]->data;
+      spec_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR1]->stride;
    }
 
    if (IND & SETUP_FOGC) {
-      fog = VB->FogCoordPtr->data;
-      fog_stride = VB->FogCoordPtr->stride;
+      fog = VB->AttribPtr[_TNL_ATTRIB_FOG]->data;
+      fog_stride = VB->AttribPtr[_TNL_ATTRIB_FOG]->stride;
    }
 
    if (start) {
@@ -220,14 +220,15 @@ static GLboolean TAG(check_tex_sizes)( GLcontext *ctx )
       struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
 
       if (IND & SETUP_TMU1) {
-        if (VB->TexCoordPtr[0] == 0)
-           VB->TexCoordPtr[0] = VB->TexCoordPtr[1];
+        if (VB->AttribPtr[_TNL_ATTRIB_TEX0] == 0)
+           VB->AttribPtr[_TNL_ATTRIB_TEX0] = VB->AttribPtr[_TNL_ATTRIB_TEX1];
         
-        if (VB->TexCoordPtr[1]->size == 4)
+        if (VB->AttribPtr[_TNL_ATTRIB_TEX1]->size == 4)
            return GL_FALSE;
       }
 
-      if (VB->TexCoordPtr[0] && VB->TexCoordPtr[0]->size == 4)
+      if (VB->AttribPtr[_TNL_ATTRIB_TEX0] &&
+         VB->AttribPtr[_TNL_ATTRIB_TEX0]->size == 4)
         return GL_FALSE;
    }
 
index ffe4e0a23434e573979f950fe6ea31a87051b1af..fa8293d039a404b79011da97921658fc72f1b0f3 100644 (file)
@@ -37,7 +37,7 @@ glslcompiler: $(OBJECTS)
 
 
 glslcompiler.o: glslcompiler.c
-       $(CC) -c $(CFLAGS) $(INCLUDES) glslcompiler.c -o $@
+       $(CC) -c $(INCLUDES) $(CFLAGS) glslcompiler.c -o $@
 
 
 clean:
index 92d4149466525d1fd590e14851287aa06207b042..9010bbd130a5ed10bf67e5f3b1b3c02d4c4860a7 100644 (file)
@@ -21,7 +21,11 @@ INCLUDE_DIRS = \
 
 # Standalone osmesa needs to be linked with core Mesa APIs
 ifeq ($(DRIVER_DIRS), osmesa)
-CORE_MESA = $(TOP)/src/mesa/libmesa.a $(TOP)/src/mesa/libglapi.a
+CORE_MESA = \
+       $(TOP)/src/mesa/libmesa.a \
+       $(TOP)/src/mesa/libglapi.a \
+       $(TOP)/src/glsl/cl/libglslcl.a \
+       $(TOP)/src/glsl/pp/libglslpp.a
 else
 CORE_MESA =
 endif
index 692657a5dfd626796240b73098899e159766104c..bac8a9ef1427ffdcf09897718d9d4bcbf95ef468 100644 (file)
@@ -37,6 +37,7 @@
 #include "GL/osmesa.h"
 #include "main/context.h"
 #include "main/extensions.h"
+#include "main/formats.h"
 #include "main/framebuffer.h"
 #include "main/imports.h"
 #include "main/mtypes.h"
@@ -840,11 +841,6 @@ osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
    else
       bpc = 32;
 
-   rb->RedBits =
-   rb->GreenBits =
-   rb->BlueBits =
-   rb->AlphaBits = bpc;
-
    /* Note: we can ignoring internalFormat for "window-system" renderbuffers */
    (void) internalFormat;
 
@@ -876,7 +872,6 @@ osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
          rb->PutValues = put_values_RGBA32;
          rb->PutMonoValues = put_mono_values_RGBA32;
       }
-      rb->RedBits = rb->GreenBits = rb->BlueBits = rb->AlphaBits = bpc;
    }
    else if (osmesa->format == OSMESA_BGRA) {
       if (rb->DataType == GL_UNSIGNED_BYTE) {
@@ -906,7 +901,6 @@ osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
          rb->PutValues = put_values_BGRA32;
          rb->PutMonoValues = put_mono_values_BGRA32;
       }
-      rb->RedBits = rb->GreenBits = rb->BlueBits = rb->AlphaBits = bpc;
    }
    else if (osmesa->format == OSMESA_ARGB) {
       if (rb->DataType == GL_UNSIGNED_BYTE) {
@@ -936,7 +930,6 @@ osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
          rb->PutValues = put_values_ARGB32;
          rb->PutMonoValues = put_mono_values_ARGB32;
       }
-      rb->RedBits = rb->GreenBits = rb->BlueBits = rb->AlphaBits = bpc;
    }
    else if (osmesa->format == OSMESA_RGB) {
       if (rb->DataType == GL_UNSIGNED_BYTE) {
@@ -966,7 +959,6 @@ osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
          rb->PutValues = put_values_RGB32;
          rb->PutMonoValues = put_mono_values_RGB32;
       }
-      rb->RedBits = rb->GreenBits = rb->BlueBits = bpc;
    }
    else if (osmesa->format == OSMESA_BGR) {
       if (rb->DataType == GL_UNSIGNED_BYTE) {
@@ -996,7 +988,6 @@ osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
          rb->PutValues = put_values_BGR32;
          rb->PutMonoValues = put_mono_values_BGR32;
       }
-      rb->RedBits = rb->GreenBits = rb->BlueBits = bpc;
    }
    else if (osmesa->format == OSMESA_RGB_565) {
       ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
@@ -1007,9 +998,6 @@ osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
       rb->PutMonoRow = put_mono_row_RGB_565;
       rb->PutValues = put_values_RGB_565;
       rb->PutMonoValues = put_mono_values_RGB_565;
-      rb->RedBits = 5;
-      rb->GreenBits = 6;
-      rb->BlueBits = 5;
    }
    else if (osmesa->format == OSMESA_COLOR_INDEX) {
       rb->GetRow = get_row_CI;
@@ -1018,7 +1006,6 @@ osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
       rb->PutMonoRow = put_mono_row_CI;
       rb->PutValues = put_values_CI;
       rb->PutMonoValues = put_mono_values_CI;
-      rb->IndexBits = 8;
    }
    else {
       _mesa_problem(ctx, "bad pixel format in osmesa renderbuffer_storage");
@@ -1048,13 +1035,13 @@ new_osmesa_renderbuffer(GLcontext *ctx, GLenum format, GLenum type)
 
       if (format == OSMESA_COLOR_INDEX) {
          rb->InternalFormat = GL_COLOR_INDEX;
-         rb->_ActualFormat = GL_COLOR_INDEX8_EXT;
+         rb->Format = MESA_FORMAT_CI8;
          rb->_BaseFormat = GL_COLOR_INDEX;
          rb->DataType = GL_UNSIGNED_BYTE;
       }
       else {
          rb->InternalFormat = GL_RGBA;
-         rb->_ActualFormat = GL_RGBA;
+         rb->Format = MESA_FORMAT_RGBA8888;
          rb->_BaseFormat = GL_RGBA;
          rb->DataType = type;
       }
index 5abcd1d927e368e628f26724ea794fbff7c95fe4..62f75d9541ff429a68554e57267ca87bb695d178 100644 (file)
@@ -867,12 +867,6 @@ EXPORTS
        _glapi_get_proc_address
        _mesa_add_soft_renderbuffers
        _mesa_add_renderbuffer
-       _mesa_begin_query
-       _mesa_buffer_data
-       _mesa_buffer_get_subdata
-       _mesa_buffer_map
-       _mesa_buffer_subdata
-       _mesa_buffer_unmap
        _mesa_bzero
        _mesa_calloc
        _mesa_choose_tex_format
@@ -880,9 +874,7 @@ EXPORTS
        _mesa_create_framebuffer
        _mesa_create_visual
        _mesa_delete_array_object
-       _mesa_delete_buffer_object
        _mesa_delete_program
-       _mesa_delete_query
        _mesa_delete_texture_object
        _mesa_destroy_framebuffer
        _mesa_destroy_visual
@@ -892,7 +884,6 @@ EXPORTS
        _mesa_enable_2_0_extensions
        _mesa_enable_2_1_extensions
        _mesa_enable_sw_extensions
-       _mesa_end_query
        _mesa_error
        _mesa_finish_render_texture
        _mesa_framebuffer_renderbuffer
@@ -911,10 +902,8 @@ EXPORTS
        _mesa_memcpy
        _mesa_memset
        _mesa_new_array_object
-       _mesa_new_buffer_object
        _mesa_new_framebuffer
        _mesa_new_program
-       _mesa_new_query_object
        _mesa_new_renderbuffer
        _mesa_new_soft_renderbuffer
        _mesa_new_texture_image
index 8929b22af169580e41c612cccaf1ba83fe1f3dce..76c825a0904da13c83f3866166df86c076ac2ece 100644 (file)
@@ -301,10 +301,10 @@ static void clear(GLcontext *ctx, GLbitfield mask)
 
     /* Let swrast do all the work if the masks are not set to
      * clear all channels. */
-    if (ctx->Color.ColorMask[0] != 0xff ||
-       ctx->Color.ColorMask[1] != 0xff ||
-       ctx->Color.ColorMask[2] != 0xff ||
-       ctx->Color.ColorMask[3] != 0xff) {
+    if (!ctx->Color.ColorMask[0][0] ||
+       !ctx->Color.ColorMask[0][1] ||
+       !ctx->Color.ColorMask[0][2] ||
+       !ctx->Color.ColorMask[0][3]) {
        _swrast_Clear(ctx, mask);
        return;
     }
index d5fa64280069448df813dd9c294979540053fe93..7b202dfda709707e69cbc3dcee6733215b982d6f 100644 (file)
@@ -269,7 +269,7 @@ void gld_Clear_DX7(
        D3DRECT         d3dClearRect;
 
        // TODO: Colourmask
-       const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask;
+       const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask[0];
 
        if (!gld->pDev)
                return;
@@ -427,10 +427,10 @@ void gld_NEW_COLOR(
 
 /*
        // Color mask - unsupported by DX7
-       if (ctx->Color.ColorMask[0]) dwFlags |= D3DCOLORWRITEENABLE_RED;
-       if (ctx->Color.ColorMask[1]) dwFlags |= D3DCOLORWRITEENABLE_GREEN;
-       if (ctx->Color.ColorMask[2]) dwFlags |= D3DCOLORWRITEENABLE_BLUE;
-       if (ctx->Color.ColorMask[3]) dwFlags |= D3DCOLORWRITEENABLE_ALPHA;
+       if (ctx->Color.ColorMask[0][0]) dwFlags |= D3DCOLORWRITEENABLE_RED;
+       if (ctx->Color.ColorMask[0][1]) dwFlags |= D3DCOLORWRITEENABLE_GREEN;
+       if (ctx->Color.ColorMask[0][2]) dwFlags |= D3DCOLORWRITEENABLE_BLUE;
+       if (ctx->Color.ColorMask[0][3]) dwFlags |= D3DCOLORWRITEENABLE_ALPHA;
        _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_COLORWRITEENABLE, dwFlags));
 */
 }
index c99ba0bba551edbdae2af5618b9bb947a450deaa..0b373814feeacd63510273cde20b8ad233d83b23 100644 (file)
                GLfloat         ex,ey,fx,fy,cc;                                                 \
                /* Get vars for later */                                                        \
                VB              = &TNL_CONTEXT(ctx)->vb;                                        \
-               vbcolor = (GLchan (*)[4])VB->ColorPtr[1]->data;         \
-               if (VB->SecondaryColorPtr[1]) {                                         \
-                       vbspec = (GLchan (*)[4])VB->SecondaryColorPtr[1]->data; \
+               vbcolor = (GLchan (*)[4])VB->BackfaceColorPtr->data;    \
+               if (VB->BackfaceSecondaryColorPtr) {                    \
+                       vbspec = (GLchan (*)[4])VB->BackfaceSecondaryColorPtr->data;    \
                } else {                                                                                                        \
                        vbspec = NULL;                                                                                  \
                }                                                                                                                       \
        DWORD                                   dwColor;
 
 #define GLD_SETUP_3D_VERTEX(v)                                 \
-       p4f                             = VB->ObjPtr->data;                     \
+       p4f = VB->AttribPtr[_TNL_ATTRIB_POS]->data;             \
        pV->Position.x  = p4f[##v][0];                          \
        pV->Position.y  = p4f[##v][1];                          \
        pV->Position.z  = p4f[##v][2];
 
 #define GLD_SETUP_SMOOTH_COLOUR_3D(v)                                                                                                                  \
-       p4f                     = (GLfloat (*)[4])VB->ColorPtr[0]->data;                                                                                \
+       p4f = (GLfloat (*)[4])VB->AttribPtr[_TNL_ATTRIB_COLOR0]->data;                                                                          \
        pV->Diffuse     = D3DCOLOR_COLORVALUE(p4f[##v][0], p4f[##v][1], p4f[##v][2], p4f[##v][3]);
 
 
 #define GLD_SETUP_GET_FLAT_COLOUR_3D(v)                                                                                                        \
-       p4f             = (GLfloat (*)[4])VB->ColorPtr[0]->data;                                                                                \
+       p4f = (GLfloat (*)[4])VB->AttribPtr[_TNL_ATTRIB_COLOR0]->data;  \
        dwColor = D3DCOLOR_COLORVALUE(p4f[##v][0], p4f[##v][1], p4f[##v][2], p4f[##v][3]);
 
 #define GLD_SETUP_USE_FLAT_COLOUR_3D                   \
        pV->Diffuse = dwColor;
 
 #define GLD_SETUP_TEX0_3D(v)                                           \
-       if (VB->TexCoordPtr[0]) {                                               \
-               tc                              = VB->TexCoordPtr[0]->data;     \
+       if (VB->AttribPtr[_TNL_ATTRIB_TEX0]) {                          \
+               tc = VB->AttribPtr[_TNL_ATTRIB_TEX0]->data;             \
                pV->TexUnit0.x  = tc[##v][0];                           \
                pV->TexUnit0.y  = tc[##v][1];                           \
        }
 
 #define GLD_SETUP_TEX1_3D(v)                                           \
-       if (VB->TexCoordPtr[1]) {                                               \
-               tc                              = VB->TexCoordPtr[1]->data;     \
+       if (VB->AttribPtr[_TNL_ATTRIB_TEX1]) {                          \
+               tc = VB->AttribPtr[_TNL_ATTRIB_TEX1]->data;             \
                pV->TexUnit1.x  = tc[##v][0];                           \
                pV->TexUnit1.y  = tc[##v][1];                           \
        }
index a85620dde8d2452a94d6467f2f443c49c385257e..c39775cad32897879ee8aba99ad4c8e9ebdcc29d 100644 (file)
@@ -151,7 +151,7 @@ static GLboolean gld_d3d_render_stage_run(
 #if 0
    // For debugging: Useful to see if an app passes colour data in
    // an unusual format.
-   switch (VB->ColorPtr[0]->Type) {
+   switch (VB->AttribPtr[_TNL_ATTRIB_COLOR0]->Type) {
    case GL_FLOAT:
           ddlogMessage(GLDLOG_SYSTEM, "ColorPtr: GL_FLOAT\n");
           break;
index 7afa9190cdfb1a69f1f674cb18864b0c29793c04..7eeb9db2d15fd2f0f24c051564e144d8088e7130 100644 (file)
@@ -269,7 +269,7 @@ void gld_Clear_DX8(
        D3DRECT         d3dClearRect;
 
        // TODO: Colourmask
-       const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask;
+       const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask[0];
 
        if (!gld->pDev)
                return;
@@ -426,10 +426,10 @@ void gld_NEW_COLOR(
        _GLD_DX8_DEV(SetRenderState(gld->pDev, D3DRS_DESTBLEND, dest));
 
        // Color mask
-       if (ctx->Color.ColorMask[0]) dwFlags |= D3DCOLORWRITEENABLE_RED;
-       if (ctx->Color.ColorMask[1]) dwFlags |= D3DCOLORWRITEENABLE_GREEN;
-       if (ctx->Color.ColorMask[2]) dwFlags |= D3DCOLORWRITEENABLE_BLUE;
-       if (ctx->Color.ColorMask[3]) dwFlags |= D3DCOLORWRITEENABLE_ALPHA;
+       if (ctx->Color.ColorMask[0][0]) dwFlags |= D3DCOLORWRITEENABLE_RED;
+       if (ctx->Color.ColorMask[0][1]) dwFlags |= D3DCOLORWRITEENABLE_GREEN;
+       if (ctx->Color.ColorMask[0][2]) dwFlags |= D3DCOLORWRITEENABLE_BLUE;
+       if (ctx->Color.ColorMask[0][3]) dwFlags |= D3DCOLORWRITEENABLE_ALPHA;
        _GLD_DX8_DEV(SetRenderState(gld->pDev, D3DRS_COLORWRITEENABLE, dwFlags));
 }
 
index a5b5462f039c0208a70424df8eade38fbebf3cc9..990922580aaf14726633ca28dcfd8a9f62e1578f 100644 (file)
                GLfloat         ex,ey,fx,fy,cc;                                                 \
                /* Get vars for later */                                                        \
                VB              = &TNL_CONTEXT(ctx)->vb;                                        \
-               vbcolor = (GLchan (*)[4])VB->ColorPtr[1]->data;         \
-               if (VB->SecondaryColorPtr[1]) {                                         \
-                       vbspec = (GLchan (*)[4])VB->SecondaryColorPtr[1]->data; \
+               vbcolor = (GLchan (*)[4])VB->BackfaceColorPtr->data;    \
+               if (VB->BackfaceSecondaryColorPtr) {                    \
+                       vbspec = (GLchan (*)[4])VB->BackfaceSecondaryColorPtr->data;    \
                } else {                                                                                                        \
                        vbspec = NULL;                                                                                  \
                }                                                                                                                       \
        DWORD                                   dwColor;
 
 #define GLD_SETUP_3D_VERTEX(v)                                 \
-       p4f                             = VB->ObjPtr->data;                     \
+       p4f = VB->AttribPtr[_TNL_ATTRIB_POS]->data;             \
        pV->Position.x  = p4f[##v][0];                          \
        pV->Position.y  = p4f[##v][1];                          \
        pV->Position.z  = p4f[##v][2];
 
 #define GLD_SETUP_SMOOTH_COLOUR_3D(v)                                                                                                                  \
-       p4f                     = (GLfloat (*)[4])VB->ColorPtr[0]->data;                                                                                \
+       p4f = (GLfloat (*)[4])VB->AttribPtr[_TNL_ATTRIB_COLOR0]->data;  \
        pV->Diffuse     = D3DCOLOR_COLORVALUE(p4f[##v][0], p4f[##v][1], p4f[##v][2], p4f[##v][3]);
 
 
 #define GLD_SETUP_GET_FLAT_COLOUR_3D(v)                                                                                                        \
-       p4f             = (GLfloat (*)[4])VB->ColorPtr[0]->data;                                                                                \
+       p4f = (GLfloat (*)[4])VB->AttribPtr[_TNL_ATTRIB_COLOR0]->data;  \
        dwColor = D3DCOLOR_COLORVALUE(p4f[##v][0], p4f[##v][1], p4f[##v][2], p4f[##v][3]);
 
 #define GLD_SETUP_USE_FLAT_COLOUR_3D                   \
        pV->Diffuse = dwColor;
 
 #define GLD_SETUP_TEX0_3D(v)                                           \
-       if (VB->TexCoordPtr[0]) {                                               \
-               tc                              = VB->TexCoordPtr[0]->data;     \
+       if (VB->AttribPtr[_TNL_ATTRIB_TEX0]) {                          \
+               tc = VB->TnlAttribPtr[_TNL_ATTRIB_TEX0]->data;          \
                pV->TexUnit0.x  = tc[##v][0];                           \
                pV->TexUnit0.y  = tc[##v][1];                           \
        }
 
 #define GLD_SETUP_TEX1_3D(v)                                           \
-       if (VB->TexCoordPtr[1]) {                                               \
-               tc                              = VB->TexCoordPtr[1]->data;     \
+       if (VB->TnlAttribPtr[_TNL_ATTRIB_TEX1]) {                       \
+               tc = VB->TnlAttribPtr[_TNL_ATTRIB_TEX1]->data;          \
                pV->TexUnit1.x  = tc[##v][0];                           \
                pV->TexUnit1.y  = tc[##v][1];                           \
        }
index cafbf4f5c50a089bc8dfcaf5f2679484d4b347e5..265c81fb4a48a0d6de07ee7e9d3c4bc9a49a3c1b 100644 (file)
@@ -149,7 +149,7 @@ static GLboolean gld_d3d_render_stage_run(
 #if 0
    // For debugging: Useful to see if an app passes colour data in
    // an unusual format.
-   switch (VB->ColorPtr[0]->Type) {
+   switch (VB->AttribPtr[_TNL_ATTRIB_COLOR0]->Type) {
    case GL_FLOAT:
           ddlogMessage(GLDLOG_SYSTEM, "ColorPtr: GL_FLOAT\n");
           break;
index c191564d6eba568ecaf1226203fc2916e4095fb0..0558462dea03f743a17eacff243109212b26a0e7 100644 (file)
@@ -269,7 +269,7 @@ void gld_Clear_DX9(
        D3DRECT         d3dClearRect;
 
        // TODO: Colourmask
-       const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask;
+       const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask[0];
 
        if (!gld->pDev)
                return;
@@ -424,10 +424,10 @@ void gld_NEW_COLOR(
        _GLD_DX9_DEV(SetRenderState(gld->pDev, D3DRS_DESTBLEND, dest));
 
        // Color mask
-       if (ctx->Color.ColorMask[0]) dwFlags |= D3DCOLORWRITEENABLE_RED;
-       if (ctx->Color.ColorMask[1]) dwFlags |= D3DCOLORWRITEENABLE_GREEN;
-       if (ctx->Color.ColorMask[2]) dwFlags |= D3DCOLORWRITEENABLE_BLUE;
-       if (ctx->Color.ColorMask[3]) dwFlags |= D3DCOLORWRITEENABLE_ALPHA;
+       if (ctx->Color.ColorMask[0][0]) dwFlags |= D3DCOLORWRITEENABLE_RED;
+       if (ctx->Color.ColorMask[0][1]) dwFlags |= D3DCOLORWRITEENABLE_GREEN;
+       if (ctx->Color.ColorMask[0][2]) dwFlags |= D3DCOLORWRITEENABLE_BLUE;
+       if (ctx->Color.ColorMask[0][3]) dwFlags |= D3DCOLORWRITEENABLE_ALPHA;
        _GLD_DX9_DEV(SetRenderState(gld->pDev, D3DRS_COLORWRITEENABLE, dwFlags));
 }
 
index 403a9d5f86e3ab124b648279be84695b67f079a4..fd4dd4ed75104f91962aeeb909605a1ffdf777d6 100644 (file)
                GLfloat         ex,ey,fx,fy,cc;                                                 \
                /* Get vars for later */                                                        \
                VB              = &TNL_CONTEXT(ctx)->vb;                                        \
-               vbcolor = (GLchan (*)[4])VB->ColorPtr[1]->data;         \
-               if (VB->SecondaryColorPtr[1]) {                                         \
-                       vbspec = (GLchan (*)[4])VB->SecondaryColorPtr[1]->data; \
+               vbcolor = (GLchan (*)[4])VB->BackfaceColorPtr->data;    \
+               if (VB->BackfaceSecondaryColorPtr) {                    \
+                       vbspec = (GLchan (*)[4])VB->BackfaceSecondaryColorPtr->data;    \
                } else {                                                                                                        \
                        vbspec = NULL;                                                                                  \
                }                                                                                                                       \
        DWORD                                   dwColor;
 
 #define GLD_SETUP_3D_VERTEX(v)                                 \
-       p4f                             = VB->ObjPtr->data;                     \
+       p4f = VB->AttribPtr[_TNL_ATTRIB_POS]->data;             \
        pV->Position.x  = p4f[##v][0];                          \
        pV->Position.y  = p4f[##v][1];                          \
        pV->Position.z  = p4f[##v][2];
 
 #define GLD_SETUP_SMOOTH_COLOUR_3D(v)                                                                                                                  \
-       p4f                     = (GLfloat (*)[4])VB->ColorPtr[0]->data;                                                                                \
+       p4f = (GLfloat (*)[4])VB->AttribPtr[_TNL_ATTRIB_COLOR0]->data;                                                                          \
        pV->Diffuse     = D3DCOLOR_COLORVALUE(p4f[##v][0], p4f[##v][1], p4f[##v][2], p4f[##v][3]);
 
 
 #define GLD_SETUP_GET_FLAT_COLOUR_3D(v)                                                                                                        \
-       p4f             = (GLfloat (*)[4])VB->ColorPtr[0]->data;                                                                                \
+       p4f = (GLfloat (*)[4])VB->AttribPtr[_TNL_ATTRIB_COLOR00]->data; \
        dwColor = D3DCOLOR_COLORVALUE(p4f[##v][0], p4f[##v][1], p4f[##v][2], p4f[##v][3]);
 
 #define GLD_SETUP_USE_FLAT_COLOUR_3D                   \
        pV->Diffuse = dwColor;
 
 #define GLD_SETUP_TEX0_3D(v)                                           \
-       if (VB->TexCoordPtr[0]) {                                               \
-               tc                              = VB->TexCoordPtr[0]->data;     \
+       if (VB->AttribPtr[_TNL_ATTRIB_TEX0]) {                          \
+               tc = VB->AttribPtr[_TNL_ATTRIB_TEX0]->data;             \
                pV->TexUnit0.x  = tc[##v][0];                           \
                pV->TexUnit0.y  = tc[##v][1];                           \
        }
 
 #define GLD_SETUP_TEX1_3D(v)                                           \
-       if (VB->TexCoordPtr[1]) {                                               \
-               tc                              = VB->TexCoordPtr[1]->data;     \
+       if (VB->AttribPtr[_TNL_ATTRIB_TEX1]) {                          \
+               tc = VB->AttribPtr[_TNL_ATTRIB_TEX1]->data;             \
                pV->TexUnit1.x  = tc[##v][0];                           \
                pV->TexUnit1.y  = tc[##v][1];                           \
        }
index 4fa6bcaf1abd1f9598ff271d969ffc78a750f5d4..91a68b3f2d9ce93ef71c231fec0303c8799ed65f 100644 (file)
@@ -149,7 +149,7 @@ static GLboolean gld_d3d_render_stage_run(
 #if 0
    // For debugging: Useful to see if an app passes colour data in
    // an unusual format.
-   switch (VB->ColorPtr[0]->Type) {
+   switch (VB->AttribPtr[_TNL_ATTRIB_COLOR0]->Type) {
    case GL_FLOAT:
           ddlogMessage(GLDLOG_SYSTEM, "ColorPtr: GL_FLOAT\n");
           break;
index 525db3b7cb79e0b63fef16091d1c9a21caa42119..5c0084f37aae4ac0afb24930101538829f4692f5 100644 (file)
@@ -1639,13 +1639,15 @@ Fake_glXCopyContext( Display *dpy, GLXContext src, GLXContext dst,
 static Bool
 Fake_glXQueryExtension( Display *dpy, int *errorBase, int *eventBase )
 {
+   int op, ev, err;
    /* Mesa's GLX isn't really an X extension but we try to act like one. */
-   (void) dpy;
+   if (!XQueryExtension(dpy, GLX_EXTENSION_NAME, &op, &ev, &err))
+      ev = err = 0;
    if (errorBase)
-      *errorBase = 0;
+      *errorBase = err;
    if (eventBase)
-      *eventBase = 0;
-   return True;
+      *eventBase = ev;
+   return True; /* we're faking GLX so always return success */
 }
 
 
index 79b058634cffd62b7eefbb2f945ee0ecf94defaf..bf767bceddf28e387de4290a8e65877729cf23ae 100644 (file)
@@ -1303,71 +1303,6 @@ xmesa_convert_from_x_visual_type( int visualType )
 /**********************************************************************/
 
 
-#ifdef IN_DRI_DRIVER
-#define need_GL_VERSION_1_3
-#define need_GL_VERSION_1_4
-#define need_GL_VERSION_1_5
-#define need_GL_VERSION_2_0
-
-/* sw extensions for imaging */
-#define need_GL_EXT_blend_color
-#define need_GL_EXT_blend_minmax
-#define need_GL_EXT_convolution
-#define need_GL_EXT_histogram
-#define need_GL_SGI_color_table
-
-/* sw extensions not associated with some GL version */
-#define need_GL_ARB_draw_elements_base_vertex
-#define need_GL_ARB_shader_objects
-#define need_GL_ARB_sync
-#define need_GL_ARB_vertex_program
-#define need_GL_APPLE_vertex_array_object
-#define need_GL_ATI_fragment_shader
-#define need_GL_EXT_depth_bounds_test
-#define need_GL_EXT_framebuffer_object
-#define need_GL_EXT_framebuffer_blit
-#define need_GL_EXT_gpu_program_parameters
-#define need_GL_EXT_paletted_texture
-#define need_GL_MESA_resize_buffers
-#define need_GL_NV_vertex_program
-#define need_GL_NV_fragment_program
-
-#include "extension_helper.h"
-#include "utils.h"
-
-const struct dri_extension card_extensions[] =
-{
-   { "GL_VERSION_1_3",                 GL_VERSION_1_3_functions },
-   { "GL_VERSION_1_4",                 GL_VERSION_1_4_functions },
-   { "GL_VERSION_1_5",                 GL_VERSION_1_5_functions },
-   { "GL_VERSION_2_0",                 GL_VERSION_2_0_functions },
-
-   { "GL_EXT_blend_color",             GL_EXT_blend_color_functions },
-   { "GL_EXT_blend_minmax",            GL_EXT_blend_minmax_functions },
-   { "GL_EXT_convolution",             GL_EXT_convolution_functions },
-   { "GL_EXT_histogram",               GL_EXT_histogram_functions },
-   { "GL_SGI_color_table",             GL_SGI_color_table_functions },
-
-   { "GL_ARB_depth_clamp",             NULL },
-   { "GL_ARB_draw_elements_base_vertex", GL_ARB_draw_elements_base_vertex_functions },
-   { "GL_ARB_shader_objects",          GL_ARB_shader_objects_functions },
-   { "GL_ARB_sync",                    GL_ARB_sync_functions },
-   { "GL_ARB_vertex_program",          GL_ARB_vertex_program_functions },
-   { "GL_APPLE_vertex_array_object",   GL_APPLE_vertex_array_object_functions },
-   { "GL_ATI_fragment_shader",         GL_ATI_fragment_shader_functions },
-   { "GL_EXT_depth_bounds_test",       GL_EXT_depth_bounds_test_functions },
-   { "GL_EXT_framebuffer_object",      GL_EXT_framebuffer_object_functions },
-   { "GL_EXT_framebuffer_blit",                GL_EXT_framebuffer_blit_functions },
-   { "GL_EXT_gpu_program_parameters",  GL_EXT_gpu_program_parameters_functions },
-   { "GL_EXT_paletted_texture",                GL_EXT_paletted_texture_functions },
-   { "GL_MESA_resize_buffers",         GL_MESA_resize_buffers_functions },
-   { "GL_NV_depth_clamp",              NULL },
-   { "GL_NV_vertex_program",           GL_NV_vertex_program_functions },
-   { "GL_NV_fragment_program",         GL_NV_fragment_program_functions },
-   { NULL,                             NULL }
-};
-#endif
-
 /*
  * Create a new X/Mesa visual.
  * Input:  display - X11 display
@@ -1413,14 +1348,6 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
    XMesaVisual v;
    GLint red_bits, green_bits, blue_bits, alpha_bits;
 
-#ifdef IN_DRI_DRIVER
-   /* driInitExtensions() should be called once per screen to setup extension
-    * indices.  There is no need to call it when the context is created since
-    * XMesa enables mesa sw extensions on its own.
-    */
-   driInitExtensions( NULL, card_extensions, GL_FALSE );
-#endif
-
 #ifndef XFree86Server
    /* For debugging only */
    if (_mesa_getenv("MESA_XSYNC")) {
index 821e2a8e082e42198d0655836f2e080192865708..bf386292895ceb09a6e6beeab2eea4b9f96d3310 100644 (file)
@@ -32,6 +32,7 @@
 #include "glxheader.h"
 #include "xmesaP.h"
 #include "main/imports.h"
+#include "main/formats.h"
 #include "main/framebuffer.h"
 #include "main/renderbuffer.h"
 
@@ -338,18 +339,15 @@ xmesa_new_renderbuffer(GLcontext *ctx, GLuint name, const GLvisual *visual,
 
       if (visual->rgbMode) {
          xrb->Base.InternalFormat = GL_RGBA;
+         xrb->Base.Format = MESA_FORMAT_RGBA8888;
          xrb->Base._BaseFormat = GL_RGBA;
          xrb->Base.DataType = GL_UNSIGNED_BYTE;
-         xrb->Base.RedBits = visual->redBits;
-         xrb->Base.GreenBits = visual->greenBits;
-         xrb->Base.BlueBits = visual->blueBits;
-         xrb->Base.AlphaBits = visual->alphaBits;
       }
       else {
          xrb->Base.InternalFormat = GL_COLOR_INDEX;
+         xrb->Base.Format = MESA_FORMAT_CI8;
          xrb->Base._BaseFormat = GL_COLOR_INDEX;
          xrb->Base.DataType = GL_UNSIGNED_INT;
-         xrb->Base.IndexBits = visual->indexBits;
       }
       /* only need to set Red/Green/EtcBits fields for user-created RBs */
    }
index e2d4aa9b2d1ddf40bbaf53afe2c2ce186d91b83c..df04e3a1011841a31f35f749fe893cefd98db4a2 100644 (file)
@@ -381,7 +381,7 @@ clear_buffers(GLcontext *ctx, GLbitfield buffers)
 {
    if (ctx->DrawBuffer->Name == 0) {
       /* this is a window system framebuffer */
-      const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask;
+      const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask[0];
       XMesaBuffer b = XMESA_BUFFER(ctx->DrawBuffer);
       const GLint x = ctx->DrawBuffer->_Xmin;
       const GLint y = ctx->DrawBuffer->_Ymin;
@@ -448,7 +448,7 @@ can_do_DrawPixels_8R8G8B(GLcontext *ctx, GLenum format, GLenum type)
             struct xmesa_renderbuffer *xrb = xmesa_renderbuffer(rb->Wrapped);
             if (xrb &&
                 xrb->pixmap && /* drawing to pixmap or window */
-                xrb->Base.AlphaBits == 0) {
+                _mesa_get_format_bits(xrb->Base.Format, GL_ALPHA_BITS) == 0) {
                return GL_TRUE;
             }
          }
@@ -582,7 +582,7 @@ can_do_DrawPixels_5R6G5B(GLcontext *ctx, GLenum format, GLenum type)
             struct xmesa_renderbuffer *xrb = xmesa_renderbuffer(rb->Wrapped);
             if (xrb &&
                 xrb->pixmap && /* drawing to pixmap or window */
-                xrb->Base.AlphaBits == 0) {
+                _mesa_get_format_bits(xrb->Base.Format, GL_ALPHA_BITS) == 0) {
                return GL_TRUE;
             }
          }
@@ -1019,15 +1019,15 @@ test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level,
 /**
  * In SW, we don't really compress GL_COMPRESSED_RGB[A] textures!
  */
-static const struct gl_texture_format *
+static gl_format
 choose_tex_format( GLcontext *ctx, GLint internalFormat,
                    GLenum format, GLenum type )
 {
    switch (internalFormat) {
       case GL_COMPRESSED_RGB_ARB:
-         return &_mesa_texformat_rgb;
+         return MESA_FORMAT_RGB888;
       case GL_COMPRESSED_RGBA_ARB:
-         return &_mesa_texformat_rgba;
+         return MESA_FORMAT_RGBA8888;
       default:
          return _mesa_choose_tex_format(ctx, internalFormat, format, type);
    }
index 309cefcb8e8152dc7b6afdafa4afa0a93c866bfd..c39d87c4516aa1a3c2add6312264bff76ff62967 100644 (file)
@@ -3773,7 +3773,7 @@ static void put_values_ci_ximage( PUT_VALUES_ARGS )
  *          else return number of pixels to skip in the destination array.
  */
 static int
-clip_for_xgetimage(GLcontext *ctx, GLuint *n, GLint *x, GLint *y)
+clip_for_xgetimage(GLcontext *ctx, XMesaPixmap pixmap, GLuint *n, GLint *x, GLint *y)
 {
    XMesaContext xmesa = XMESA_CONTEXT(ctx);
    XMesaBuffer source = XMESA_BUFFER(ctx->DrawBuffer);
@@ -3783,7 +3783,7 @@ clip_for_xgetimage(GLcontext *ctx, GLuint *n, GLint *x, GLint *y)
    GLint dx, dy;
    if (source->type == PBUFFER || source->type == PIXMAP)
       return 0;
-   XTranslateCoordinates(xmesa->display, source->frontxrb->pixmap, rootWin,
+   XTranslateCoordinates(xmesa->display, pixmap, rootWin,
                          *x, *y, &dx, &dy, &child);
    if (dx >= screenWidth) {
       /* totally clipped on right */
@@ -3827,7 +3827,7 @@ get_row_ci(GLcontext *ctx, struct gl_renderbuffer *rb,
 #ifndef XFree86Server
       XMesaImage *span = NULL;
       int error;
-      int k = clip_for_xgetimage(ctx, &n, &x, &y);
+      int k = clip_for_xgetimage(ctx, xrb->pixmap, &n, &x, &y);
       if (k < 0)
          return;
       index += k;
@@ -3892,7 +3892,7 @@ get_row_rgba(GLcontext *ctx, struct gl_renderbuffer *rb,
 #else
       int k;
       y = YFLIP(xrb, y);
-      k = clip_for_xgetimage(ctx, &n, &x, &y);
+      k = clip_for_xgetimage(ctx, xrb->pixmap, &n, &x, &y);
       if (k < 0)
          return;
       rgba += k;
index b700e7e77d840036cee1b4baf389d97eee970df8..e6bdcd6e509cb0078eeec8cda32cec6bdaef451c 100644 (file)
 
     <enum name="RENDERBUFFER"                             value="0x8D41"/>
 
-    <enum name="STENCIL_INDEX1_EXT"                       value="0x8D46"/>
-    <enum name="STENCIL_INDEX4_EXT"                       value="0x8D47"/>
-    <enum name="STENCIL_INDEX8_EXT"                       value="0x8D48"/>
-    <enum name="STENCIL_INDEX16_EXT"                      value="0x8D49"/>
+    <enum name="STENCIL_INDEX1"                           value="0x8D46"/>
+    <enum name="STENCIL_INDEX4"                           value="0x8D47"/>
+    <enum name="STENCIL_INDEX8"                           value="0x8D48"/>
+    <enum name="STENCIL_INDEX16"                          value="0x8D49"/>
 
     <enum name="RENDERBUFFER_WIDTH"              value="0x8D42"/>
     <enum name="RENDERBUFFER_HEIGHT"             value="0x8D43"/>
     <enum name="STENCIL_ATTACHMENT"                        value="0x8D20"/>
     <enum name="DEPTH_STENCIL_ATTACHMENT"                  value="0x821A"/>
 
-    <enum name="MAX_SAMPLES"                               value="0x8D57"/>
+    <enum name="MAX_SAMPLES"                     count="1" value="0x8D57">
+        <size name="Get" mode="get"/>
+    </enum>
 
     <enum name="FRAMEBUFFER_COMPLETE"                      value="0x8CD5"/>
     <enum name="FRAMEBUFFER_INCOMPLETE_ATTACHMENT"         value="0x8CD6"/>
     <enum name="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT" value="0x8CD7"/>
-    <enum name="FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT"    value="0x8CDB"/>
-    <enum name="FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT"    value="0x8CDC"/>
+    <enum name="FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER"        value="0x8CDB"/>
+    <enum name="FRAMEBUFFER_INCOMPLETE_READ_BUFFER"        value="0x8CDC"/>
     <enum name="FRAMEBUFFER_UNSUPPORTED"                   value="0x8CDD"/>
     <enum name="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE"        value="0x8D56"/>
     <enum name="FRAMEBUFFER_UNDEFINED"                     value="0x8219"/>
 
-    <enum name="FRAMEBUFFER_BINDING_EXT"         count="1" value="0x8CA6">
+    <enum name="FRAMEBUFFER_BINDING"             count="1" value="0x8CA6">
         <size name="Get" mode="get"/>
     </enum>
-    <enum name="DRAW_FRAMEBUFFER_BINDING_EXT"    count="1" value="0x8CA6">
+    <enum name="DRAW_FRAMEBUFFER_BINDING"        count="1" value="0x8CA6">
         <size name="Get" mode="get"/>
     </enum>
-    <enum name="READ_FRAMEBUFFER_BINDING_EXT"    count="1" value="0x8CAA">
+    <enum name="READ_FRAMEBUFFER_BINDING"        count="1" value="0x8CAA">
         <size name="Get" mode="get"/>
     </enum>
-    <enum name="RENDERBUFFER_BINDING_EXT"        count="1" value="0x8CA7">
+    <enum name="RENDERBUFFER_BINDING"            count="1" value="0x8CA7">
         <size name="Get" mode="get"/>
     </enum>
-    <enum name="MAX_COLOR_ATTACHMENTS_EXT"       count="1" value="0x8CDF">
+    <enum name="MAX_COLOR_ATTACHMENTS"           count="1" value="0x8CDF">
         <size name="Get" mode="get"/>
     </enum>
-    <enum name="MAX_RENDERBUFFER_SIZE_EXT"       count="1" value="0x84E8">
+    <enum name="MAX_RENDERBUFFER_SIZE"           count="1" value="0x84E8">
         <size name="Get" mode="get"/>
     </enum>
 
 
     <enum name="DEPTH24_STENCIL8"                         value="0x88F0"/>
 
-    <enum name="TEXTURE_STENCIL_SIZE"                     value="0x88F1"/>
+    <enum name="TEXTURE_STENCIL_SIZE"          count="1"  value="0x88F1">
+        <size name="GetTexLevelParameterfv" mode="get"/>
+        <size name="GetTexLevelParameteriv" mode="get"/>
+    </enum>
 
 
 
         <param name="internalformat" type="GLenum"/>
         <param name="width" type="GLsizei"/>
         <param name="height" type="GLsizei"/>
+        <glx rop="4331"/>
     </function>
 
     <function name="GetRenderbufferParameteriv" alias="GetRenderbufferParameterivEXT">
index 37f474980cf9b4a79a960bfbafa2e19e25838cd5..4e4eebac32adea9874a21bd5215907d0195f3f62 100644 (file)
     <enum name="WAIT_FAILED"                              value="0x911D"/>
 
     <enum name="SYNC_FLUSH_COMMANDS_BIT"                  value="0x00000001"/>
-    <enum name="TIMEOUT_IGNORED"                  value="0xFFFFFFFFFFFFFFFF"/>
 
+    <!-- Not really an enum:
+    <enum name="TIMEOUT_IGNORED"                  value="0xFFFFFFFFFFFFFFFF"/>
+    -->
 
 
     <function name="FenceSync" offset="assign">
diff --git a/src/mesa/glapi/EXT_draw_buffers2.xml b/src/mesa/glapi/EXT_draw_buffers2.xml
new file mode 100644 (file)
index 0000000..efbe61f
--- /dev/null
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<!DOCTYPE OpenGLAPI SYSTEM "gl_API.dtd">
+
+<!-- Note: no GLX protocol info yet. -->
+
+
+<OpenGLAPI>
+
+<category name="GL_EXT_draw_buffers2" number="340">
+
+    <function name="ColorMaskIndexedEXT" offset="assign">
+       <param name="buf" type="GLuint"/>
+       <param name="r" type="GLboolean"/>
+       <param name="g" type="GLboolean"/>
+       <param name="b" type="GLboolean"/>
+       <param name="a" type="GLboolean"/>
+    </function>
+
+    <function name="GetBooleanIndexedvEXT" offset="assign">
+        <param name="value" type="GLenum"/>
+       <param name="index" type="GLuint"/>
+       <param name="data" type="GLboolean *"/>
+    </function>
+
+    <function name="GetIntegerIndexedvEXT" offset="assign">
+        <param name="value" type="GLenum"/>
+       <param name="index" type="GLuint"/>
+       <param name="data" type="GLint *"/>
+    </function>
+
+    <function name="EnableIndexedEXT" offset="assign">
+        <param name="target" type="GLenum"/>
+       <param name="index" type="GLuint"/>
+    </function>
+
+    <function name="DisableIndexedEXT" offset="assign">
+        <param name="target" type="GLenum"/>
+       <param name="index" type="GLuint"/>
+    </function>
+
+    <function name ="IsEnabledIndexedEXT" offset="assign">
+        <param name="target" type="GLenum"/>
+       <param name="index" type="GLuint"/>
+       <return type="GLboolean"/>
+    </function>
+
+</category>
+
+</OpenGLAPI>
index 5559b48b11a8d8ffd6aff00e84eb43c49453f18f..4f418f7b64cdc266c36b7d18d0fd04328092effc 100644 (file)
     </function>
 </category>
 
+<category name="GL_EXT_framebuffer_blit" number="316">
+    <enum name="READ_FRAMEBUFFER_EXT" value="0x8CA8"/>
+    <enum name="DRAW_FRAMEBUFFER_EXT" value="0x8CA9"/>
+    <enum name="DRAW_FRAMEBUFFER_BINDING_EXT" count="1" value="0x8CA6">
+        <size name="Get" mode="get"/>
+    </enum>
+    <enum name="READ_FRAMEBUFFER_BINDING_EXT" count="1" value="0x8CAA">
+        <size name="Get" mode="get"/>
+    </enum>
+    <function name="BlitFramebufferEXT" offset="assign" static_dispatch="false">
+        <param name="srcX0" type="GLint"/>
+        <param name="srcY0" type="GLint"/>
+        <param name="srcX1" type="GLint"/>
+        <param name="srcY1" type="GLint"/>
+        <param name="dstX0" type="GLint"/>
+        <param name="dstY0" type="GLint"/>
+        <param name="dstX1" type="GLint"/>
+        <param name="dstY1" type="GLint"/>
+        <param name="mask" type="GLbitfield"/>
+        <param name="filter" type="GLenum"/>
+        <glx rop="4330"/>
+    </function>
+</category>
+
+<category name="GL_EXT_framebuffer_multisample" number="317">
+    <enum name="RENDERBUFFER_SAMPLES_EXT"                  value="0x8CAB"/>
+    <enum name="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT"    value="0x8D56"/>
+    <enum name="MAX_SAMPLES_EXT"                 count="1" value="0x8D57">
+        <size name="Get" mode="get"/>
+    </enum>
+
+    <function name="RenderbufferStorageMultisampleEXT" alias="RenderbufferStorageMultisample">
+        <param name="target" type="GLenum"/>
+        <param name="samples" type="GLsizei"/>
+        <param name="internalformat" type="GLenum"/>
+        <param name="width" type="GLsizei"/>
+        <param name="height" type="GLsizei"/>
+    </function>
+</category>
+
 </OpenGLAPI>
diff --git a/src/mesa/glapi/EXT_packed_depth_stencil.xml b/src/mesa/glapi/EXT_packed_depth_stencil.xml
new file mode 100644 (file)
index 0000000..5be8103
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<!DOCTYPE OpenGLAPI SYSTEM "gl_API.dtd">
+
+<OpenGLAPI>
+<category name="GL_EXT_packed_depth_stencil" number="312">
+    <!-- These enums are shared with GL_NV_packed_depth_stencil. -->
+    <enum name="DEPTH_STENCIL_EXT"                        value="0x84F9"/>
+    <enum name="UNSIGNED_INT_24_8_EXT"                    value="0x84FA"/>
+
+    <enum name="DEPTH24_STENCIL8_EXT"                     value="0x88F0"/>
+
+    <enum name="TEXTURE_STENCIL_SIZE_EXT"      count="1"  value="0x88F1">
+        <size name="GetTexLevelParameterfv" mode="get"/>
+        <size name="GetTexLevelParameteriv" mode="get"/>
+    </enum>
+</category>
+
+</OpenGLAPI>
index e5bd9f3c6970b8e2f01b51d58ea442cce7e27c2d..b5b8bd406f7ca850627e77ca2c40ec0f134c8390 100644 (file)
@@ -35,6 +35,7 @@
         <param name="texture" type="GLuint"/>
         <param name="level" type="GLint"/>
         <param name="layer" type="GLint"/>
+       <glx rop="237"/>
     </function>
 </category>
 
index 22f65b74c29f1632754048f35de70f04ba481c9e..4db0ff1425e9079c86eceacb808fb223246787a7 100644 (file)
@@ -7,12 +7,12 @@
 TOP = ../../..
 include $(TOP)/configs/current
 
-OUTPUTS = glprocs.h glapitemp.h glapioffsets.h glapitable.h dispatch.h \
+OUTPUTS = glprocs.h glapitemp.h glapioffsets.h glapitable.h glapidispatch.h \
        ../main/enums.c \
+       ../main/remap_helper.h \
        ../x86/glapi_x86.S \
        ../x86-64/glapi_x86-64.S \
        ../sparc/glapi_sparc.S \
-       ../drivers/dri/common/extension_helper.h \
        ../../glx/x11/indirect.c \
        ../../glx/x11/indirect.h \
        ../../glx/x11/indirect_init.c \
@@ -41,21 +41,27 @@ SERVER_OUTPUTS = \
        $(GLX_DIR)/glapitemp.h \
        $(GLX_DIR)/glapitable.h \
        $(GLX_DIR)/glapioffsets.h \
+       $(GLX_DIR)/glapidispatch.h \
        $(GLX_DIR)/glprocs.h \
        $(GLX_DIR)/dispatch.h \
        $(SERVER_GLAPI_FILES)
 
 API_XML = gl_API.xml \
-       EXT_framebuffer_object.xml \
        ARB_copy_buffer.xml \
        ARB_depth_clamp.xml \
+       ARB_draw_elements_base_vertex.xml \
        ARB_framebuffer_object.xml \
        ARB_map_buffer_range.xml \
        ARB_seamless_cube_map.xml \
        ARB_sync.xml \
        ARB_vertex_array_object.xml \
        APPLE_vertex_array_object.xml \
-       EXT_provoking_vertex.xml
+       EXT_draw_buffers2.xml \
+       EXT_framebuffer_object.xml \
+       EXT_packed_depth_stencil.xml \
+       EXT_provoking_vertex.xml \
+       EXT_texture_array.xml \
+       NV_conditional_render.xml
 
 COMMON = gl_XML.py glX_XML.py license.py $(API_XML) typeexpr.py
 COMMON_GLX = $(COMMON) glX_API.xml glX_XML.py glX_proto_common.py
@@ -86,12 +92,15 @@ glapioffsets.h $(GLX_DIR)/glapioffsets.h: gl_offsets.py $(COMMON)
 glapitable.h $(GLX_DIR)/glapitable.h: gl_table.py $(COMMON)
        $(PYTHON2) $(PYTHON_FLAGS) $< > $@
 
-dispatch.h $(GLX_DIR)/dispatch.h: gl_table.py $(COMMON)
+glapidispatch.h $(GLX_DIR)/glapidispatch.h: gl_table.py $(COMMON)
        $(PYTHON2) $(PYTHON_FLAGS) $< -m remap_table > $@
 
 ../main/enums.c: gl_enums.py $(COMMON)
        $(PYTHON2) $(PYTHON_FLAGS) $< > $@
 
+../main/remap_helper.h: remap_helper.py $(COMMON)
+       $(PYTHON2) $(PYTHON_FLAGS) $< > $@
+
 ../x86/glapi_x86.S: gl_x86_asm.py $(COMMON)
        $(PYTHON2) $(PYTHON_FLAGS) $< > $@
 
@@ -101,10 +110,6 @@ dispatch.h $(GLX_DIR)/dispatch.h: gl_table.py $(COMMON)
 ../sparc/glapi_sparc.S: gl_SPARC_asm.py $(COMMON)
        $(PYTHON2) $(PYTHON_FLAGS) $< > $@
 
-
-../drivers/dri/common/extension_helper.h: extension_helper.py $(COMMON)
-       $(PYTHON2) $(PYTHON_FLAGS) $< > $@
-
 ../../glx/x11/indirect.c: glX_proto_send.py $(COMMON_GLX)
        $(PYTHON2) $(PYTHON_FLAGS) $< -m proto | $(INDENT) $(INDENT_FLAGS) > $@
 
diff --git a/src/mesa/glapi/NV_conditional_render.xml b/src/mesa/glapi/NV_conditional_render.xml
new file mode 100644 (file)
index 0000000..8bb31dd
--- /dev/null
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<!DOCTYPE OpenGLAPI SYSTEM "gl_API.dtd">
+
+<!-- Note: no GLX protocol info yet. -->
+
+
+<OpenGLAPI>
+
+<category name="GL_NV_condtitional_render" number="346">
+
+    <enum name="QUERY_WAIT_NV"               value="0x8E13"/>
+    <enum name="QUERY_NO_WAIT_NV"            value="0x8E14"/>
+    <enum name="QUERY_BY_REGION_WAIT_NV"     value="0x8E15"/>
+    <enum name="QUERY_BY_REGION_NO_WAIT_NV"  value="0x8E16"/>
+
+    <function name="BeginConditionalRenderNV" offset="assign">
+       <param name="query" type="GLuint"/>
+       <param name="mode" type="GLenum"/>
+    </function>
+
+    <function name="EndConditionalRenderNV" offset="assign">
+    </function>
+
+</category>
+
+</OpenGLAPI>
index efbd56fa712a0cf59597c392a7da80e6cbe985d3..6623d52469277eb5a22a1c7c38e07f6addc03757 100644 (file)
@@ -1,5 +1,3 @@
-/* DO NOT EDIT - This file generated automatically by gl_table.py (from Mesa) script */
-
 /*
  * (C) Copyright IBM Corporation 2005
  * All Rights Reserved.
  * SOFTWARE.
  */
 
-#if !defined( _DISPATCH_H_ )
-#  define _DISPATCH_H_
+#ifndef _DISPATCH_H
+#define _DISPATCH_H
 
+#ifdef IN_DRI_DRIVER
+#define _GLAPI_USE_REMAP_TABLE
+#endif
 
 #include "glapitable.h"
-/**
- * \file dispatch.h
- * Macros for handling GL dispatch tables.
- *
- * For each known GL function, there are 3 macros in this file.  The first
- * macro is named CALL_FuncName and is used to call that GL function using
- * the specified dispatch table.  The other 2 macros, called GET_FuncName
- * can SET_FuncName, are used to get and set the dispatch pointer for the
- * named function in the specified dispatch table.
- */
-
-#define CALL_by_offset(disp, cast, offset, parameters) \
-    (*(cast (GET_by_offset(disp, offset)))) parameters
-#define GET_by_offset(disp, offset) \
-    (offset >= 0) ? (((_glapi_proc *)(disp))[offset]) : NULL
-#define SET_by_offset(disp, offset, fn) \
-    do { \
-        if ( (offset) < 0 ) { \
-            /* fprintf( stderr, "[%s:%u] SET_by_offset(%p, %d, %s)!\n", */ \
-            /*         __func__, __LINE__, disp, offset, # fn); */ \
-            /* abort(); */ \
-        } \
-        else { \
-            ( (_glapi_proc *) (disp) )[offset] = (_glapi_proc) fn; \
-        } \
-    } while(0)
-
-#define CALL_NewList(disp, parameters) (*((disp)->NewList)) parameters
-#define GET_NewList(disp) ((disp)->NewList)
-#define SET_NewList(disp, fn) ((disp)->NewList = fn)
-#define CALL_EndList(disp, parameters) (*((disp)->EndList)) parameters
-#define GET_EndList(disp) ((disp)->EndList)
-#define SET_EndList(disp, fn) ((disp)->EndList = fn)
-#define CALL_CallList(disp, parameters) (*((disp)->CallList)) parameters
-#define GET_CallList(disp) ((disp)->CallList)
-#define SET_CallList(disp, fn) ((disp)->CallList = fn)
-#define CALL_CallLists(disp, parameters) (*((disp)->CallLists)) parameters
-#define GET_CallLists(disp) ((disp)->CallLists)
-#define SET_CallLists(disp, fn) ((disp)->CallLists = fn)
-#define CALL_DeleteLists(disp, parameters) (*((disp)->DeleteLists)) parameters
-#define GET_DeleteLists(disp) ((disp)->DeleteLists)
-#define SET_DeleteLists(disp, fn) ((disp)->DeleteLists = fn)
-#define CALL_GenLists(disp, parameters) (*((disp)->GenLists)) parameters
-#define GET_GenLists(disp) ((disp)->GenLists)
-#define SET_GenLists(disp, fn) ((disp)->GenLists = fn)
-#define CALL_ListBase(disp, parameters) (*((disp)->ListBase)) parameters
-#define GET_ListBase(disp) ((disp)->ListBase)
-#define SET_ListBase(disp, fn) ((disp)->ListBase = fn)
-#define CALL_Begin(disp, parameters) (*((disp)->Begin)) parameters
-#define GET_Begin(disp) ((disp)->Begin)
-#define SET_Begin(disp, fn) ((disp)->Begin = fn)
-#define CALL_Bitmap(disp, parameters) (*((disp)->Bitmap)) parameters
-#define GET_Bitmap(disp) ((disp)->Bitmap)
-#define SET_Bitmap(disp, fn) ((disp)->Bitmap = fn)
-#define CALL_Color3b(disp, parameters) (*((disp)->Color3b)) parameters
-#define GET_Color3b(disp) ((disp)->Color3b)
-#define SET_Color3b(disp, fn) ((disp)->Color3b = fn)
-#define CALL_Color3bv(disp, parameters) (*((disp)->Color3bv)) parameters
-#define GET_Color3bv(disp) ((disp)->Color3bv)
-#define SET_Color3bv(disp, fn) ((disp)->Color3bv = fn)
-#define CALL_Color3d(disp, parameters) (*((disp)->Color3d)) parameters
-#define GET_Color3d(disp) ((disp)->Color3d)
-#define SET_Color3d(disp, fn) ((disp)->Color3d = fn)
-#define CALL_Color3dv(disp, parameters) (*((disp)->Color3dv)) parameters
-#define GET_Color3dv(disp) ((disp)->Color3dv)
-#define SET_Color3dv(disp, fn) ((disp)->Color3dv = fn)
-#define CALL_Color3f(disp, parameters) (*((disp)->Color3f)) parameters
-#define GET_Color3f(disp) ((disp)->Color3f)
-#define SET_Color3f(disp, fn) ((disp)->Color3f = fn)
-#define CALL_Color3fv(disp, parameters) (*((disp)->Color3fv)) parameters
-#define GET_Color3fv(disp) ((disp)->Color3fv)
-#define SET_Color3fv(disp, fn) ((disp)->Color3fv = fn)
-#define CALL_Color3i(disp, parameters) (*((disp)->Color3i)) parameters
-#define GET_Color3i(disp) ((disp)->Color3i)
-#define SET_Color3i(disp, fn) ((disp)->Color3i = fn)
-#define CALL_Color3iv(disp, parameters) (*((disp)->Color3iv)) parameters
-#define GET_Color3iv(disp) ((disp)->Color3iv)
-#define SET_Color3iv(disp, fn) ((disp)->Color3iv = fn)
-#define CALL_Color3s(disp, parameters) (*((disp)->Color3s)) parameters
-#define GET_Color3s(disp) ((disp)->Color3s)
-#define SET_Color3s(disp, fn) ((disp)->Color3s = fn)
-#define CALL_Color3sv(disp, parameters) (*((disp)->Color3sv)) parameters
-#define GET_Color3sv(disp) ((disp)->Color3sv)
-#define SET_Color3sv(disp, fn) ((disp)->Color3sv = fn)
-#define CALL_Color3ub(disp, parameters) (*((disp)->Color3ub)) parameters
-#define GET_Color3ub(disp) ((disp)->Color3ub)
-#define SET_Color3ub(disp, fn) ((disp)->Color3ub = fn)
-#define CALL_Color3ubv(disp, parameters) (*((disp)->Color3ubv)) parameters
-#define GET_Color3ubv(disp) ((disp)->Color3ubv)
-#define SET_Color3ubv(disp, fn) ((disp)->Color3ubv = fn)
-#define CALL_Color3ui(disp, parameters) (*((disp)->Color3ui)) parameters
-#define GET_Color3ui(disp) ((disp)->Color3ui)
-#define SET_Color3ui(disp, fn) ((disp)->Color3ui = fn)
-#define CALL_Color3uiv(disp, parameters) (*((disp)->Color3uiv)) parameters
-#define GET_Color3uiv(disp) ((disp)->Color3uiv)
-#define SET_Color3uiv(disp, fn) ((disp)->Color3uiv = fn)
-#define CALL_Color3us(disp, parameters) (*((disp)->Color3us)) parameters
-#define GET_Color3us(disp) ((disp)->Color3us)
-#define SET_Color3us(disp, fn) ((disp)->Color3us = fn)
-#define CALL_Color3usv(disp, parameters) (*((disp)->Color3usv)) parameters
-#define GET_Color3usv(disp) ((disp)->Color3usv)
-#define SET_Color3usv(disp, fn) ((disp)->Color3usv = fn)
-#define CALL_Color4b(disp, parameters) (*((disp)->Color4b)) parameters
-#define GET_Color4b(disp) ((disp)->Color4b)
-#define SET_Color4b(disp, fn) ((disp)->Color4b = fn)
-#define CALL_Color4bv(disp, parameters) (*((disp)->Color4bv)) parameters
-#define GET_Color4bv(disp) ((disp)->Color4bv)
-#define SET_Color4bv(disp, fn) ((disp)->Color4bv = fn)
-#define CALL_Color4d(disp, parameters) (*((disp)->Color4d)) parameters
-#define GET_Color4d(disp) ((disp)->Color4d)
-#define SET_Color4d(disp, fn) ((disp)->Color4d = fn)
-#define CALL_Color4dv(disp, parameters) (*((disp)->Color4dv)) parameters
-#define GET_Color4dv(disp) ((disp)->Color4dv)
-#define SET_Color4dv(disp, fn) ((disp)->Color4dv = fn)
-#define CALL_Color4f(disp, parameters) (*((disp)->Color4f)) parameters
-#define GET_Color4f(disp) ((disp)->Color4f)
-#define SET_Color4f(disp, fn) ((disp)->Color4f = fn)
-#define CALL_Color4fv(disp, parameters) (*((disp)->Color4fv)) parameters
-#define GET_Color4fv(disp) ((disp)->Color4fv)
-#define SET_Color4fv(disp, fn) ((disp)->Color4fv = fn)
-#define CALL_Color4i(disp, parameters) (*((disp)->Color4i)) parameters
-#define GET_Color4i(disp) ((disp)->Color4i)
-#define SET_Color4i(disp, fn) ((disp)->Color4i = fn)
-#define CALL_Color4iv(disp, parameters) (*((disp)->Color4iv)) parameters
-#define GET_Color4iv(disp) ((disp)->Color4iv)
-#define SET_Color4iv(disp, fn) ((disp)->Color4iv = fn)
-#define CALL_Color4s(disp, parameters) (*((disp)->Color4s)) parameters
-#define GET_Color4s(disp) ((disp)->Color4s)
-#define SET_Color4s(disp, fn) ((disp)->Color4s = fn)
-#define CALL_Color4sv(disp, parameters) (*((disp)->Color4sv)) parameters
-#define GET_Color4sv(disp) ((disp)->Color4sv)
-#define SET_Color4sv(disp, fn) ((disp)->Color4sv = fn)
-#define CALL_Color4ub(disp, parameters) (*((disp)->Color4ub)) parameters
-#define GET_Color4ub(disp) ((disp)->Color4ub)
-#define SET_Color4ub(disp, fn) ((disp)->Color4ub = fn)
-#define CALL_Color4ubv(disp, parameters) (*((disp)->Color4ubv)) parameters
-#define GET_Color4ubv(disp) ((disp)->Color4ubv)
-#define SET_Color4ubv(disp, fn) ((disp)->Color4ubv = fn)
-#define CALL_Color4ui(disp, parameters) (*((disp)->Color4ui)) parameters
-#define GET_Color4ui(disp) ((disp)->Color4ui)
-#define SET_Color4ui(disp, fn) ((disp)->Color4ui = fn)
-#define CALL_Color4uiv(disp, parameters) (*((disp)->Color4uiv)) parameters
-#define GET_Color4uiv(disp) ((disp)->Color4uiv)
-#define SET_Color4uiv(disp, fn) ((disp)->Color4uiv = fn)
-#define CALL_Color4us(disp, parameters) (*((disp)->Color4us)) parameters
-#define GET_Color4us(disp) ((disp)->Color4us)
-#define SET_Color4us(disp, fn) ((disp)->Color4us = fn)
-#define CALL_Color4usv(disp, parameters) (*((disp)->Color4usv)) parameters
-#define GET_Color4usv(disp) ((disp)->Color4usv)
-#define SET_Color4usv(disp, fn) ((disp)->Color4usv = fn)
-#define CALL_EdgeFlag(disp, parameters) (*((disp)->EdgeFlag)) parameters
-#define GET_EdgeFlag(disp) ((disp)->EdgeFlag)
-#define SET_EdgeFlag(disp, fn) ((disp)->EdgeFlag = fn)
-#define CALL_EdgeFlagv(disp, parameters) (*((disp)->EdgeFlagv)) parameters
-#define GET_EdgeFlagv(disp) ((disp)->EdgeFlagv)
-#define SET_EdgeFlagv(disp, fn) ((disp)->EdgeFlagv = fn)
-#define CALL_End(disp, parameters) (*((disp)->End)) parameters
-#define GET_End(disp) ((disp)->End)
-#define SET_End(disp, fn) ((disp)->End = fn)
-#define CALL_Indexd(disp, parameters) (*((disp)->Indexd)) parameters
-#define GET_Indexd(disp) ((disp)->Indexd)
-#define SET_Indexd(disp, fn) ((disp)->Indexd = fn)
-#define CALL_Indexdv(disp, parameters) (*((disp)->Indexdv)) parameters
-#define GET_Indexdv(disp) ((disp)->Indexdv)
-#define SET_Indexdv(disp, fn) ((disp)->Indexdv = fn)
-#define CALL_Indexf(disp, parameters) (*((disp)->Indexf)) parameters
-#define GET_Indexf(disp) ((disp)->Indexf)
-#define SET_Indexf(disp, fn) ((disp)->Indexf = fn)
-#define CALL_Indexfv(disp, parameters) (*((disp)->Indexfv)) parameters
-#define GET_Indexfv(disp) ((disp)->Indexfv)
-#define SET_Indexfv(disp, fn) ((disp)->Indexfv = fn)
-#define CALL_Indexi(disp, parameters) (*((disp)->Indexi)) parameters
-#define GET_Indexi(disp) ((disp)->Indexi)
-#define SET_Indexi(disp, fn) ((disp)->Indexi = fn)
-#define CALL_Indexiv(disp, parameters) (*((disp)->Indexiv)) parameters
-#define GET_Indexiv(disp) ((disp)->Indexiv)
-#define SET_Indexiv(disp, fn) ((disp)->Indexiv = fn)
-#define CALL_Indexs(disp, parameters) (*((disp)->Indexs)) parameters
-#define GET_Indexs(disp) ((disp)->Indexs)
-#define SET_Indexs(disp, fn) ((disp)->Indexs = fn)
-#define CALL_Indexsv(disp, parameters) (*((disp)->Indexsv)) parameters
-#define GET_Indexsv(disp) ((disp)->Indexsv)
-#define SET_Indexsv(disp, fn) ((disp)->Indexsv = fn)
-#define CALL_Normal3b(disp, parameters) (*((disp)->Normal3b)) parameters
-#define GET_Normal3b(disp) ((disp)->Normal3b)
-#define SET_Normal3b(disp, fn) ((disp)->Normal3b = fn)
-#define CALL_Normal3bv(disp, parameters) (*((disp)->Normal3bv)) parameters
-#define GET_Normal3bv(disp) ((disp)->Normal3bv)
-#define SET_Normal3bv(disp, fn) ((disp)->Normal3bv = fn)
-#define CALL_Normal3d(disp, parameters) (*((disp)->Normal3d)) parameters
-#define GET_Normal3d(disp) ((disp)->Normal3d)
-#define SET_Normal3d(disp, fn) ((disp)->Normal3d = fn)
-#define CALL_Normal3dv(disp, parameters) (*((disp)->Normal3dv)) parameters
-#define GET_Normal3dv(disp) ((disp)->Normal3dv)
-#define SET_Normal3dv(disp, fn) ((disp)->Normal3dv = fn)
-#define CALL_Normal3f(disp, parameters) (*((disp)->Normal3f)) parameters
-#define GET_Normal3f(disp) ((disp)->Normal3f)
-#define SET_Normal3f(disp, fn) ((disp)->Normal3f = fn)
-#define CALL_Normal3fv(disp, parameters) (*((disp)->Normal3fv)) parameters
-#define GET_Normal3fv(disp) ((disp)->Normal3fv)
-#define SET_Normal3fv(disp, fn) ((disp)->Normal3fv = fn)
-#define CALL_Normal3i(disp, parameters) (*((disp)->Normal3i)) parameters
-#define GET_Normal3i(disp) ((disp)->Normal3i)
-#define SET_Normal3i(disp, fn) ((disp)->Normal3i = fn)
-#define CALL_Normal3iv(disp, parameters) (*((disp)->Normal3iv)) parameters
-#define GET_Normal3iv(disp) ((disp)->Normal3iv)
-#define SET_Normal3iv(disp, fn) ((disp)->Normal3iv = fn)
-#define CALL_Normal3s(disp, parameters) (*((disp)->Normal3s)) parameters
-#define GET_Normal3s(disp) ((disp)->Normal3s)
-#define SET_Normal3s(disp, fn) ((disp)->Normal3s = fn)
-#define CALL_Normal3sv(disp, parameters) (*((disp)->Normal3sv)) parameters
-#define GET_Normal3sv(disp) ((disp)->Normal3sv)
-#define SET_Normal3sv(disp, fn) ((disp)->Normal3sv = fn)
-#define CALL_RasterPos2d(disp, parameters) (*((disp)->RasterPos2d)) parameters
-#define GET_RasterPos2d(disp) ((disp)->RasterPos2d)
-#define SET_RasterPos2d(disp, fn) ((disp)->RasterPos2d = fn)
-#define CALL_RasterPos2dv(disp, parameters) (*((disp)->RasterPos2dv)) parameters
-#define GET_RasterPos2dv(disp) ((disp)->RasterPos2dv)
-#define SET_RasterPos2dv(disp, fn) ((disp)->RasterPos2dv = fn)
-#define CALL_RasterPos2f(disp, parameters) (*((disp)->RasterPos2f)) parameters
-#define GET_RasterPos2f(disp) ((disp)->RasterPos2f)
-#define SET_RasterPos2f(disp, fn) ((disp)->RasterPos2f = fn)
-#define CALL_RasterPos2fv(disp, parameters) (*((disp)->RasterPos2fv)) parameters
-#define GET_RasterPos2fv(disp) ((disp)->RasterPos2fv)
-#define SET_RasterPos2fv(disp, fn) ((disp)->RasterPos2fv = fn)
-#define CALL_RasterPos2i(disp, parameters) (*((disp)->RasterPos2i)) parameters
-#define GET_RasterPos2i(disp) ((disp)->RasterPos2i)
-#define SET_RasterPos2i(disp, fn) ((disp)->RasterPos2i = fn)
-#define CALL_RasterPos2iv(disp, parameters) (*((disp)->RasterPos2iv)) parameters
-#define GET_RasterPos2iv(disp) ((disp)->RasterPos2iv)
-#define SET_RasterPos2iv(disp, fn) ((disp)->RasterPos2iv = fn)
-#define CALL_RasterPos2s(disp, parameters) (*((disp)->RasterPos2s)) parameters
-#define GET_RasterPos2s(disp) ((disp)->RasterPos2s)
-#define SET_RasterPos2s(disp, fn) ((disp)->RasterPos2s = fn)
-#define CALL_RasterPos2sv(disp, parameters) (*((disp)->RasterPos2sv)) parameters
-#define GET_RasterPos2sv(disp) ((disp)->RasterPos2sv)
-#define SET_RasterPos2sv(disp, fn) ((disp)->RasterPos2sv = fn)
-#define CALL_RasterPos3d(disp, parameters) (*((disp)->RasterPos3d)) parameters
-#define GET_RasterPos3d(disp) ((disp)->RasterPos3d)
-#define SET_RasterPos3d(disp, fn) ((disp)->RasterPos3d = fn)
-#define CALL_RasterPos3dv(disp, parameters) (*((disp)->RasterPos3dv)) parameters
-#define GET_RasterPos3dv(disp) ((disp)->RasterPos3dv)
-#define SET_RasterPos3dv(disp, fn) ((disp)->RasterPos3dv = fn)
-#define CALL_RasterPos3f(disp, parameters) (*((disp)->RasterPos3f)) parameters
-#define GET_RasterPos3f(disp) ((disp)->RasterPos3f)
-#define SET_RasterPos3f(disp, fn) ((disp)->RasterPos3f = fn)
-#define CALL_RasterPos3fv(disp, parameters) (*((disp)->RasterPos3fv)) parameters
-#define GET_RasterPos3fv(disp) ((disp)->RasterPos3fv)
-#define SET_RasterPos3fv(disp, fn) ((disp)->RasterPos3fv = fn)
-#define CALL_RasterPos3i(disp, parameters) (*((disp)->RasterPos3i)) parameters
-#define GET_RasterPos3i(disp) ((disp)->RasterPos3i)
-#define SET_RasterPos3i(disp, fn) ((disp)->RasterPos3i = fn)
-#define CALL_RasterPos3iv(disp, parameters) (*((disp)->RasterPos3iv)) parameters
-#define GET_RasterPos3iv(disp) ((disp)->RasterPos3iv)
-#define SET_RasterPos3iv(disp, fn) ((disp)->RasterPos3iv = fn)
-#define CALL_RasterPos3s(disp, parameters) (*((disp)->RasterPos3s)) parameters
-#define GET_RasterPos3s(disp) ((disp)->RasterPos3s)
-#define SET_RasterPos3s(disp, fn) ((disp)->RasterPos3s = fn)
-#define CALL_RasterPos3sv(disp, parameters) (*((disp)->RasterPos3sv)) parameters
-#define GET_RasterPos3sv(disp) ((disp)->RasterPos3sv)
-#define SET_RasterPos3sv(disp, fn) ((disp)->RasterPos3sv = fn)
-#define CALL_RasterPos4d(disp, parameters) (*((disp)->RasterPos4d)) parameters
-#define GET_RasterPos4d(disp) ((disp)->RasterPos4d)
-#define SET_RasterPos4d(disp, fn) ((disp)->RasterPos4d = fn)
-#define CALL_RasterPos4dv(disp, parameters) (*((disp)->RasterPos4dv)) parameters
-#define GET_RasterPos4dv(disp) ((disp)->RasterPos4dv)
-#define SET_RasterPos4dv(disp, fn) ((disp)->RasterPos4dv = fn)
-#define CALL_RasterPos4f(disp, parameters) (*((disp)->RasterPos4f)) parameters
-#define GET_RasterPos4f(disp) ((disp)->RasterPos4f)
-#define SET_RasterPos4f(disp, fn) ((disp)->RasterPos4f = fn)
-#define CALL_RasterPos4fv(disp, parameters) (*((disp)->RasterPos4fv)) parameters
-#define GET_RasterPos4fv(disp) ((disp)->RasterPos4fv)
-#define SET_RasterPos4fv(disp, fn) ((disp)->RasterPos4fv = fn)
-#define CALL_RasterPos4i(disp, parameters) (*((disp)->RasterPos4i)) parameters
-#define GET_RasterPos4i(disp) ((disp)->RasterPos4i)
-#define SET_RasterPos4i(disp, fn) ((disp)->RasterPos4i = fn)
-#define CALL_RasterPos4iv(disp, parameters) (*((disp)->RasterPos4iv)) parameters
-#define GET_RasterPos4iv(disp) ((disp)->RasterPos4iv)
-#define SET_RasterPos4iv(disp, fn) ((disp)->RasterPos4iv = fn)
-#define CALL_RasterPos4s(disp, parameters) (*((disp)->RasterPos4s)) parameters
-#define GET_RasterPos4s(disp) ((disp)->RasterPos4s)
-#define SET_RasterPos4s(disp, fn) ((disp)->RasterPos4s = fn)
-#define CALL_RasterPos4sv(disp, parameters) (*((disp)->RasterPos4sv)) parameters
-#define GET_RasterPos4sv(disp) ((disp)->RasterPos4sv)
-#define SET_RasterPos4sv(disp, fn) ((disp)->RasterPos4sv = fn)
-#define CALL_Rectd(disp, parameters) (*((disp)->Rectd)) parameters
-#define GET_Rectd(disp) ((disp)->Rectd)
-#define SET_Rectd(disp, fn) ((disp)->Rectd = fn)
-#define CALL_Rectdv(disp, parameters) (*((disp)->Rectdv)) parameters
-#define GET_Rectdv(disp) ((disp)->Rectdv)
-#define SET_Rectdv(disp, fn) ((disp)->Rectdv = fn)
-#define CALL_Rectf(disp, parameters) (*((disp)->Rectf)) parameters
-#define GET_Rectf(disp) ((disp)->Rectf)
-#define SET_Rectf(disp, fn) ((disp)->Rectf = fn)
-#define CALL_Rectfv(disp, parameters) (*((disp)->Rectfv)) parameters
-#define GET_Rectfv(disp) ((disp)->Rectfv)
-#define SET_Rectfv(disp, fn) ((disp)->Rectfv = fn)
-#define CALL_Recti(disp, parameters) (*((disp)->Recti)) parameters
-#define GET_Recti(disp) ((disp)->Recti)
-#define SET_Recti(disp, fn) ((disp)->Recti = fn)
-#define CALL_Rectiv(disp, parameters) (*((disp)->Rectiv)) parameters
-#define GET_Rectiv(disp) ((disp)->Rectiv)
-#define SET_Rectiv(disp, fn) ((disp)->Rectiv = fn)
-#define CALL_Rects(disp, parameters) (*((disp)->Rects)) parameters
-#define GET_Rects(disp) ((disp)->Rects)
-#define SET_Rects(disp, fn) ((disp)->Rects = fn)
-#define CALL_Rectsv(disp, parameters) (*((disp)->Rectsv)) parameters
-#define GET_Rectsv(disp) ((disp)->Rectsv)
-#define SET_Rectsv(disp, fn) ((disp)->Rectsv = fn)
-#define CALL_TexCoord1d(disp, parameters) (*((disp)->TexCoord1d)) parameters
-#define GET_TexCoord1d(disp) ((disp)->TexCoord1d)
-#define SET_TexCoord1d(disp, fn) ((disp)->TexCoord1d = fn)
-#define CALL_TexCoord1dv(disp, parameters) (*((disp)->TexCoord1dv)) parameters
-#define GET_TexCoord1dv(disp) ((disp)->TexCoord1dv)
-#define SET_TexCoord1dv(disp, fn) ((disp)->TexCoord1dv = fn)
-#define CALL_TexCoord1f(disp, parameters) (*((disp)->TexCoord1f)) parameters
-#define GET_TexCoord1f(disp) ((disp)->TexCoord1f)
-#define SET_TexCoord1f(disp, fn) ((disp)->TexCoord1f = fn)
-#define CALL_TexCoord1fv(disp, parameters) (*((disp)->TexCoord1fv)) parameters
-#define GET_TexCoord1fv(disp) ((disp)->TexCoord1fv)
-#define SET_TexCoord1fv(disp, fn) ((disp)->TexCoord1fv = fn)
-#define CALL_TexCoord1i(disp, parameters) (*((disp)->TexCoord1i)) parameters
-#define GET_TexCoord1i(disp) ((disp)->TexCoord1i)
-#define SET_TexCoord1i(disp, fn) ((disp)->TexCoord1i = fn)
-#define CALL_TexCoord1iv(disp, parameters) (*((disp)->TexCoord1iv)) parameters
-#define GET_TexCoord1iv(disp) ((disp)->TexCoord1iv)
-#define SET_TexCoord1iv(disp, fn) ((disp)->TexCoord1iv = fn)
-#define CALL_TexCoord1s(disp, parameters) (*((disp)->TexCoord1s)) parameters
-#define GET_TexCoord1s(disp) ((disp)->TexCoord1s)
-#define SET_TexCoord1s(disp, fn) ((disp)->TexCoord1s = fn)
-#define CALL_TexCoord1sv(disp, parameters) (*((disp)->TexCoord1sv)) parameters
-#define GET_TexCoord1sv(disp) ((disp)->TexCoord1sv)
-#define SET_TexCoord1sv(disp, fn) ((disp)->TexCoord1sv = fn)
-#define CALL_TexCoord2d(disp, parameters) (*((disp)->TexCoord2d)) parameters
-#define GET_TexCoord2d(disp) ((disp)->TexCoord2d)
-#define SET_TexCoord2d(disp, fn) ((disp)->TexCoord2d = fn)
-#define CALL_TexCoord2dv(disp, parameters) (*((disp)->TexCoord2dv)) parameters
-#define GET_TexCoord2dv(disp) ((disp)->TexCoord2dv)
-#define SET_TexCoord2dv(disp, fn) ((disp)->TexCoord2dv = fn)
-#define CALL_TexCoord2f(disp, parameters) (*((disp)->TexCoord2f)) parameters
-#define GET_TexCoord2f(disp) ((disp)->TexCoord2f)
-#define SET_TexCoord2f(disp, fn) ((disp)->TexCoord2f = fn)
-#define CALL_TexCoord2fv(disp, parameters) (*((disp)->TexCoord2fv)) parameters
-#define GET_TexCoord2fv(disp) ((disp)->TexCoord2fv)
-#define SET_TexCoord2fv(disp, fn) ((disp)->TexCoord2fv = fn)
-#define CALL_TexCoord2i(disp, parameters) (*((disp)->TexCoord2i)) parameters
-#define GET_TexCoord2i(disp) ((disp)->TexCoord2i)
-#define SET_TexCoord2i(disp, fn) ((disp)->TexCoord2i = fn)
-#define CALL_TexCoord2iv(disp, parameters) (*((disp)->TexCoord2iv)) parameters
-#define GET_TexCoord2iv(disp) ((disp)->TexCoord2iv)
-#define SET_TexCoord2iv(disp, fn) ((disp)->TexCoord2iv = fn)
-#define CALL_TexCoord2s(disp, parameters) (*((disp)->TexCoord2s)) parameters
-#define GET_TexCoord2s(disp) ((disp)->TexCoord2s)
-#define SET_TexCoord2s(disp, fn) ((disp)->TexCoord2s = fn)
-#define CALL_TexCoord2sv(disp, parameters) (*((disp)->TexCoord2sv)) parameters
-#define GET_TexCoord2sv(disp) ((disp)->TexCoord2sv)
-#define SET_TexCoord2sv(disp, fn) ((disp)->TexCoord2sv = fn)
-#define CALL_TexCoord3d(disp, parameters) (*((disp)->TexCoord3d)) parameters
-#define GET_TexCoord3d(disp) ((disp)->TexCoord3d)
-#define SET_TexCoord3d(disp, fn) ((disp)->TexCoord3d = fn)
-#define CALL_TexCoord3dv(disp, parameters) (*((disp)->TexCoord3dv)) parameters
-#define GET_TexCoord3dv(disp) ((disp)->TexCoord3dv)
-#define SET_TexCoord3dv(disp, fn) ((disp)->TexCoord3dv = fn)
-#define CALL_TexCoord3f(disp, parameters) (*((disp)->TexCoord3f)) parameters
-#define GET_TexCoord3f(disp) ((disp)->TexCoord3f)
-#define SET_TexCoord3f(disp, fn) ((disp)->TexCoord3f = fn)
-#define CALL_TexCoord3fv(disp, parameters) (*((disp)->TexCoord3fv)) parameters
-#define GET_TexCoord3fv(disp) ((disp)->TexCoord3fv)
-#define SET_TexCoord3fv(disp, fn) ((disp)->TexCoord3fv = fn)
-#define CALL_TexCoord3i(disp, parameters) (*((disp)->TexCoord3i)) parameters
-#define GET_TexCoord3i(disp) ((disp)->TexCoord3i)
-#define SET_TexCoord3i(disp, fn) ((disp)->TexCoord3i = fn)
-#define CALL_TexCoord3iv(disp, parameters) (*((disp)->TexCoord3iv)) parameters
-#define GET_TexCoord3iv(disp) ((disp)->TexCoord3iv)
-#define SET_TexCoord3iv(disp, fn) ((disp)->TexCoord3iv = fn)
-#define CALL_TexCoord3s(disp, parameters) (*((disp)->TexCoord3s)) parameters
-#define GET_TexCoord3s(disp) ((disp)->TexCoord3s)
-#define SET_TexCoord3s(disp, fn) ((disp)->TexCoord3s = fn)
-#define CALL_TexCoord3sv(disp, parameters) (*((disp)->TexCoord3sv)) parameters
-#define GET_TexCoord3sv(disp) ((disp)->TexCoord3sv)
-#define SET_TexCoord3sv(disp, fn) ((disp)->TexCoord3sv = fn)
-#define CALL_TexCoord4d(disp, parameters) (*((disp)->TexCoord4d)) parameters
-#define GET_TexCoord4d(disp) ((disp)->TexCoord4d)
-#define SET_TexCoord4d(disp, fn) ((disp)->TexCoord4d = fn)
-#define CALL_TexCoord4dv(disp, parameters) (*((disp)->TexCoord4dv)) parameters
-#define GET_TexCoord4dv(disp) ((disp)->TexCoord4dv)
-#define SET_TexCoord4dv(disp, fn) ((disp)->TexCoord4dv = fn)
-#define CALL_TexCoord4f(disp, parameters) (*((disp)->TexCoord4f)) parameters
-#define GET_TexCoord4f(disp) ((disp)->TexCoord4f)
-#define SET_TexCoord4f(disp, fn) ((disp)->TexCoord4f = fn)
-#define CALL_TexCoord4fv(disp, parameters) (*((disp)->TexCoord4fv)) parameters
-#define GET_TexCoord4fv(disp) ((disp)->TexCoord4fv)
-#define SET_TexCoord4fv(disp, fn) ((disp)->TexCoord4fv = fn)
-#define CALL_TexCoord4i(disp, parameters) (*((disp)->TexCoord4i)) parameters
-#define GET_TexCoord4i(disp) ((disp)->TexCoord4i)
-#define SET_TexCoord4i(disp, fn) ((disp)->TexCoord4i = fn)
-#define CALL_TexCoord4iv(disp, parameters) (*((disp)->TexCoord4iv)) parameters
-#define GET_TexCoord4iv(disp) ((disp)->TexCoord4iv)
-#define SET_TexCoord4iv(disp, fn) ((disp)->TexCoord4iv = fn)
-#define CALL_TexCoord4s(disp, parameters) (*((disp)->TexCoord4s)) parameters
-#define GET_TexCoord4s(disp) ((disp)->TexCoord4s)
-#define SET_TexCoord4s(disp, fn) ((disp)->TexCoord4s = fn)
-#define CALL_TexCoord4sv(disp, parameters) (*((disp)->TexCoord4sv)) parameters
-#define GET_TexCoord4sv(disp) ((disp)->TexCoord4sv)
-#define SET_TexCoord4sv(disp, fn) ((disp)->TexCoord4sv = fn)
-#define CALL_Vertex2d(disp, parameters) (*((disp)->Vertex2d)) parameters
-#define GET_Vertex2d(disp) ((disp)->Vertex2d)
-#define SET_Vertex2d(disp, fn) ((disp)->Vertex2d = fn)
-#define CALL_Vertex2dv(disp, parameters) (*((disp)->Vertex2dv)) parameters
-#define GET_Vertex2dv(disp) ((disp)->Vertex2dv)
-#define SET_Vertex2dv(disp, fn) ((disp)->Vertex2dv = fn)
-#define CALL_Vertex2f(disp, parameters) (*((disp)->Vertex2f)) parameters
-#define GET_Vertex2f(disp) ((disp)->Vertex2f)
-#define SET_Vertex2f(disp, fn) ((disp)->Vertex2f = fn)
-#define CALL_Vertex2fv(disp, parameters) (*((disp)->Vertex2fv)) parameters
-#define GET_Vertex2fv(disp) ((disp)->Vertex2fv)
-#define SET_Vertex2fv(disp, fn) ((disp)->Vertex2fv = fn)
-#define CALL_Vertex2i(disp, parameters) (*((disp)->Vertex2i)) parameters
-#define GET_Vertex2i(disp) ((disp)->Vertex2i)
-#define SET_Vertex2i(disp, fn) ((disp)->Vertex2i = fn)
-#define CALL_Vertex2iv(disp, parameters) (*((disp)->Vertex2iv)) parameters
-#define GET_Vertex2iv(disp) ((disp)->Vertex2iv)
-#define SET_Vertex2iv(disp, fn) ((disp)->Vertex2iv = fn)
-#define CALL_Vertex2s(disp, parameters) (*((disp)->Vertex2s)) parameters
-#define GET_Vertex2s(disp) ((disp)->Vertex2s)
-#define SET_Vertex2s(disp, fn) ((disp)->Vertex2s = fn)
-#define CALL_Vertex2sv(disp, parameters) (*((disp)->Vertex2sv)) parameters
-#define GET_Vertex2sv(disp) ((disp)->Vertex2sv)
-#define SET_Vertex2sv(disp, fn) ((disp)->Vertex2sv = fn)
-#define CALL_Vertex3d(disp, parameters) (*((disp)->Vertex3d)) parameters
-#define GET_Vertex3d(disp) ((disp)->Vertex3d)
-#define SET_Vertex3d(disp, fn) ((disp)->Vertex3d = fn)
-#define CALL_Vertex3dv(disp, parameters) (*((disp)->Vertex3dv)) parameters
-#define GET_Vertex3dv(disp) ((disp)->Vertex3dv)
-#define SET_Vertex3dv(disp, fn) ((disp)->Vertex3dv = fn)
-#define CALL_Vertex3f(disp, parameters) (*((disp)->Vertex3f)) parameters
-#define GET_Vertex3f(disp) ((disp)->Vertex3f)
-#define SET_Vertex3f(disp, fn) ((disp)->Vertex3f = fn)
-#define CALL_Vertex3fv(disp, parameters) (*((disp)->Vertex3fv)) parameters
-#define GET_Vertex3fv(disp) ((disp)->Vertex3fv)
-#define SET_Vertex3fv(disp, fn) ((disp)->Vertex3fv = fn)
-#define CALL_Vertex3i(disp, parameters) (*((disp)->Vertex3i)) parameters
-#define GET_Vertex3i(disp) ((disp)->Vertex3i)
-#define SET_Vertex3i(disp, fn) ((disp)->Vertex3i = fn)
-#define CALL_Vertex3iv(disp, parameters) (*((disp)->Vertex3iv)) parameters
-#define GET_Vertex3iv(disp) ((disp)->Vertex3iv)
-#define SET_Vertex3iv(disp, fn) ((disp)->Vertex3iv = fn)
-#define CALL_Vertex3s(disp, parameters) (*((disp)->Vertex3s)) parameters
-#define GET_Vertex3s(disp) ((disp)->Vertex3s)
-#define SET_Vertex3s(disp, fn) ((disp)->Vertex3s = fn)
-#define CALL_Vertex3sv(disp, parameters) (*((disp)->Vertex3sv)) parameters
-#define GET_Vertex3sv(disp) ((disp)->Vertex3sv)
-#define SET_Vertex3sv(disp, fn) ((disp)->Vertex3sv = fn)
-#define CALL_Vertex4d(disp, parameters) (*((disp)->Vertex4d)) parameters
-#define GET_Vertex4d(disp) ((disp)->Vertex4d)
-#define SET_Vertex4d(disp, fn) ((disp)->Vertex4d = fn)
-#define CALL_Vertex4dv(disp, parameters) (*((disp)->Vertex4dv)) parameters
-#define GET_Vertex4dv(disp) ((disp)->Vertex4dv)
-#define SET_Vertex4dv(disp, fn) ((disp)->Vertex4dv = fn)
-#define CALL_Vertex4f(disp, parameters) (*((disp)->Vertex4f)) parameters
-#define GET_Vertex4f(disp) ((disp)->Vertex4f)
-#define SET_Vertex4f(disp, fn) ((disp)->Vertex4f = fn)
-#define CALL_Vertex4fv(disp, parameters) (*((disp)->Vertex4fv)) parameters
-#define GET_Vertex4fv(disp) ((disp)->Vertex4fv)
-#define SET_Vertex4fv(disp, fn) ((disp)->Vertex4fv = fn)
-#define CALL_Vertex4i(disp, parameters) (*((disp)->Vertex4i)) parameters
-#define GET_Vertex4i(disp) ((disp)->Vertex4i)
-#define SET_Vertex4i(disp, fn) ((disp)->Vertex4i = fn)
-#define CALL_Vertex4iv(disp, parameters) (*((disp)->Vertex4iv)) parameters
-#define GET_Vertex4iv(disp) ((disp)->Vertex4iv)
-#define SET_Vertex4iv(disp, fn) ((disp)->Vertex4iv = fn)
-#define CALL_Vertex4s(disp, parameters) (*((disp)->Vertex4s)) parameters
-#define GET_Vertex4s(disp) ((disp)->Vertex4s)
-#define SET_Vertex4s(disp, fn) ((disp)->Vertex4s = fn)
-#define CALL_Vertex4sv(disp, parameters) (*((disp)->Vertex4sv)) parameters
-#define GET_Vertex4sv(disp) ((disp)->Vertex4sv)
-#define SET_Vertex4sv(disp, fn) ((disp)->Vertex4sv = fn)
-#define CALL_ClipPlane(disp, parameters) (*((disp)->ClipPlane)) parameters
-#define GET_ClipPlane(disp) ((disp)->ClipPlane)
-#define SET_ClipPlane(disp, fn) ((disp)->ClipPlane = fn)
-#define CALL_ColorMaterial(disp, parameters) (*((disp)->ColorMaterial)) parameters
-#define GET_ColorMaterial(disp) ((disp)->ColorMaterial)
-#define SET_ColorMaterial(disp, fn) ((disp)->ColorMaterial = fn)
-#define CALL_CullFace(disp, parameters) (*((disp)->CullFace)) parameters
-#define GET_CullFace(disp) ((disp)->CullFace)
-#define SET_CullFace(disp, fn) ((disp)->CullFace = fn)
-#define CALL_Fogf(disp, parameters) (*((disp)->Fogf)) parameters
-#define GET_Fogf(disp) ((disp)->Fogf)
-#define SET_Fogf(disp, fn) ((disp)->Fogf = fn)
-#define CALL_Fogfv(disp, parameters) (*((disp)->Fogfv)) parameters
-#define GET_Fogfv(disp) ((disp)->Fogfv)
-#define SET_Fogfv(disp, fn) ((disp)->Fogfv = fn)
-#define CALL_Fogi(disp, parameters) (*((disp)->Fogi)) parameters
-#define GET_Fogi(disp) ((disp)->Fogi)
-#define SET_Fogi(disp, fn) ((disp)->Fogi = fn)
-#define CALL_Fogiv(disp, parameters) (*((disp)->Fogiv)) parameters
-#define GET_Fogiv(disp) ((disp)->Fogiv)
-#define SET_Fogiv(disp, fn) ((disp)->Fogiv = fn)
-#define CALL_FrontFace(disp, parameters) (*((disp)->FrontFace)) parameters
-#define GET_FrontFace(disp) ((disp)->FrontFace)
-#define SET_FrontFace(disp, fn) ((disp)->FrontFace = fn)
-#define CALL_Hint(disp, parameters) (*((disp)->Hint)) parameters
-#define GET_Hint(disp) ((disp)->Hint)
-#define SET_Hint(disp, fn) ((disp)->Hint = fn)
-#define CALL_Lightf(disp, parameters) (*((disp)->Lightf)) parameters
-#define GET_Lightf(disp) ((disp)->Lightf)
-#define SET_Lightf(disp, fn) ((disp)->Lightf = fn)
-#define CALL_Lightfv(disp, parameters) (*((disp)->Lightfv)) parameters
-#define GET_Lightfv(disp) ((disp)->Lightfv)
-#define SET_Lightfv(disp, fn) ((disp)->Lightfv = fn)
-#define CALL_Lighti(disp, parameters) (*((disp)->Lighti)) parameters
-#define GET_Lighti(disp) ((disp)->Lighti)
-#define SET_Lighti(disp, fn) ((disp)->Lighti = fn)
-#define CALL_Lightiv(disp, parameters) (*((disp)->Lightiv)) parameters
-#define GET_Lightiv(disp) ((disp)->Lightiv)
-#define SET_Lightiv(disp, fn) ((disp)->Lightiv = fn)
-#define CALL_LightModelf(disp, parameters) (*((disp)->LightModelf)) parameters
-#define GET_LightModelf(disp) ((disp)->LightModelf)
-#define SET_LightModelf(disp, fn) ((disp)->LightModelf = fn)
-#define CALL_LightModelfv(disp, parameters) (*((disp)->LightModelfv)) parameters
-#define GET_LightModelfv(disp) ((disp)->LightModelfv)
-#define SET_LightModelfv(disp, fn) ((disp)->LightModelfv = fn)
-#define CALL_LightModeli(disp, parameters) (*((disp)->LightModeli)) parameters
-#define GET_LightModeli(disp) ((disp)->LightModeli)
-#define SET_LightModeli(disp, fn) ((disp)->LightModeli = fn)
-#define CALL_LightModeliv(disp, parameters) (*((disp)->LightModeliv)) parameters
-#define GET_LightModeliv(disp) ((disp)->LightModeliv)
-#define SET_LightModeliv(disp, fn) ((disp)->LightModeliv = fn)
-#define CALL_LineStipple(disp, parameters) (*((disp)->LineStipple)) parameters
-#define GET_LineStipple(disp) ((disp)->LineStipple)
-#define SET_LineStipple(disp, fn) ((disp)->LineStipple = fn)
-#define CALL_LineWidth(disp, parameters) (*((disp)->LineWidth)) parameters
-#define GET_LineWidth(disp) ((disp)->LineWidth)
-#define SET_LineWidth(disp, fn) ((disp)->LineWidth = fn)
-#define CALL_Materialf(disp, parameters) (*((disp)->Materialf)) parameters
-#define GET_Materialf(disp) ((disp)->Materialf)
-#define SET_Materialf(disp, fn) ((disp)->Materialf = fn)
-#define CALL_Materialfv(disp, parameters) (*((disp)->Materialfv)) parameters
-#define GET_Materialfv(disp) ((disp)->Materialfv)
-#define SET_Materialfv(disp, fn) ((disp)->Materialfv = fn)
-#define CALL_Materiali(disp, parameters) (*((disp)->Materiali)) parameters
-#define GET_Materiali(disp) ((disp)->Materiali)
-#define SET_Materiali(disp, fn) ((disp)->Materiali = fn)
-#define CALL_Materialiv(disp, parameters) (*((disp)->Materialiv)) parameters
-#define GET_Materialiv(disp) ((disp)->Materialiv)
-#define SET_Materialiv(disp, fn) ((disp)->Materialiv = fn)
-#define CALL_PointSize(disp, parameters) (*((disp)->PointSize)) parameters
-#define GET_PointSize(disp) ((disp)->PointSize)
-#define SET_PointSize(disp, fn) ((disp)->PointSize = fn)
-#define CALL_PolygonMode(disp, parameters) (*((disp)->PolygonMode)) parameters
-#define GET_PolygonMode(disp) ((disp)->PolygonMode)
-#define SET_PolygonMode(disp, fn) ((disp)->PolygonMode = fn)
-#define CALL_PolygonStipple(disp, parameters) (*((disp)->PolygonStipple)) parameters
-#define GET_PolygonStipple(disp) ((disp)->PolygonStipple)
-#define SET_PolygonStipple(disp, fn) ((disp)->PolygonStipple = fn)
-#define CALL_Scissor(disp, parameters) (*((disp)->Scissor)) parameters
-#define GET_Scissor(disp) ((disp)->Scissor)
-#define SET_Scissor(disp, fn) ((disp)->Scissor = fn)
-#define CALL_ShadeModel(disp, parameters) (*((disp)->ShadeModel)) parameters
-#define GET_ShadeModel(disp) ((disp)->ShadeModel)
-#define SET_ShadeModel(disp, fn) ((disp)->ShadeModel = fn)
-#define CALL_TexParameterf(disp, parameters) (*((disp)->TexParameterf)) parameters
-#define GET_TexParameterf(disp) ((disp)->TexParameterf)
-#define SET_TexParameterf(disp, fn) ((disp)->TexParameterf = fn)
-#define CALL_TexParameterfv(disp, parameters) (*((disp)->TexParameterfv)) parameters
-#define GET_TexParameterfv(disp) ((disp)->TexParameterfv)
-#define SET_TexParameterfv(disp, fn) ((disp)->TexParameterfv = fn)
-#define CALL_TexParameteri(disp, parameters) (*((disp)->TexParameteri)) parameters
-#define GET_TexParameteri(disp) ((disp)->TexParameteri)
-#define SET_TexParameteri(disp, fn) ((disp)->TexParameteri = fn)
-#define CALL_TexParameteriv(disp, parameters) (*((disp)->TexParameteriv)) parameters
-#define GET_TexParameteriv(disp) ((disp)->TexParameteriv)
-#define SET_TexParameteriv(disp, fn) ((disp)->TexParameteriv = fn)
-#define CALL_TexImage1D(disp, parameters) (*((disp)->TexImage1D)) parameters
-#define GET_TexImage1D(disp) ((disp)->TexImage1D)
-#define SET_TexImage1D(disp, fn) ((disp)->TexImage1D = fn)
-#define CALL_TexImage2D(disp, parameters) (*((disp)->TexImage2D)) parameters
-#define GET_TexImage2D(disp) ((disp)->TexImage2D)
-#define SET_TexImage2D(disp, fn) ((disp)->TexImage2D = fn)
-#define CALL_TexEnvf(disp, parameters) (*((disp)->TexEnvf)) parameters
-#define GET_TexEnvf(disp) ((disp)->TexEnvf)
-#define SET_TexEnvf(disp, fn) ((disp)->TexEnvf = fn)
-#define CALL_TexEnvfv(disp, parameters) (*((disp)->TexEnvfv)) parameters
-#define GET_TexEnvfv(disp) ((disp)->TexEnvfv)
-#define SET_TexEnvfv(disp, fn) ((disp)->TexEnvfv = fn)
-#define CALL_TexEnvi(disp, parameters) (*((disp)->TexEnvi)) parameters
-#define GET_TexEnvi(disp) ((disp)->TexEnvi)
-#define SET_TexEnvi(disp, fn) ((disp)->TexEnvi = fn)
-#define CALL_TexEnviv(disp, parameters) (*((disp)->TexEnviv)) parameters
-#define GET_TexEnviv(disp) ((disp)->TexEnviv)
-#define SET_TexEnviv(disp, fn) ((disp)->TexEnviv = fn)
-#define CALL_TexGend(disp, parameters) (*((disp)->TexGend)) parameters
-#define GET_TexGend(disp) ((disp)->TexGend)
-#define SET_TexGend(disp, fn) ((disp)->TexGend = fn)
-#define CALL_TexGendv(disp, parameters) (*((disp)->TexGendv)) parameters
-#define GET_TexGendv(disp) ((disp)->TexGendv)
-#define SET_TexGendv(disp, fn) ((disp)->TexGendv = fn)
-#define CALL_TexGenf(disp, parameters) (*((disp)->TexGenf)) parameters
-#define GET_TexGenf(disp) ((disp)->TexGenf)
-#define SET_TexGenf(disp, fn) ((disp)->TexGenf = fn)
-#define CALL_TexGenfv(disp, parameters) (*((disp)->TexGenfv)) parameters
-#define GET_TexGenfv(disp) ((disp)->TexGenfv)
-#define SET_TexGenfv(disp, fn) ((disp)->TexGenfv = fn)
-#define CALL_TexGeni(disp, parameters) (*((disp)->TexGeni)) parameters
-#define GET_TexGeni(disp) ((disp)->TexGeni)
-#define SET_TexGeni(disp, fn) ((disp)->TexGeni = fn)
-#define CALL_TexGeniv(disp, parameters) (*((disp)->TexGeniv)) parameters
-#define GET_TexGeniv(disp) ((disp)->TexGeniv)
-#define SET_TexGeniv(disp, fn) ((disp)->TexGeniv = fn)
-#define CALL_FeedbackBuffer(disp, parameters) (*((disp)->FeedbackBuffer)) parameters
-#define GET_FeedbackBuffer(disp) ((disp)->FeedbackBuffer)
-#define SET_FeedbackBuffer(disp, fn) ((disp)->FeedbackBuffer = fn)
-#define CALL_SelectBuffer(disp, parameters) (*((disp)->SelectBuffer)) parameters
-#define GET_SelectBuffer(disp) ((disp)->SelectBuffer)
-#define SET_SelectBuffer(disp, fn) ((disp)->SelectBuffer = fn)
-#define CALL_RenderMode(disp, parameters) (*((disp)->RenderMode)) parameters
-#define GET_RenderMode(disp) ((disp)->RenderMode)
-#define SET_RenderMode(disp, fn) ((disp)->RenderMode = fn)
-#define CALL_InitNames(disp, parameters) (*((disp)->InitNames)) parameters
-#define GET_InitNames(disp) ((disp)->InitNames)
-#define SET_InitNames(disp, fn) ((disp)->InitNames = fn)
-#define CALL_LoadName(disp, parameters) (*((disp)->LoadName)) parameters
-#define GET_LoadName(disp) ((disp)->LoadName)
-#define SET_LoadName(disp, fn) ((disp)->LoadName = fn)
-#define CALL_PassThrough(disp, parameters) (*((disp)->PassThrough)) parameters
-#define GET_PassThrough(disp) ((disp)->PassThrough)
-#define SET_PassThrough(disp, fn) ((disp)->PassThrough = fn)
-#define CALL_PopName(disp, parameters) (*((disp)->PopName)) parameters
-#define GET_PopName(disp) ((disp)->PopName)
-#define SET_PopName(disp, fn) ((disp)->PopName = fn)
-#define CALL_PushName(disp, parameters) (*((disp)->PushName)) parameters
-#define GET_PushName(disp) ((disp)->PushName)
-#define SET_PushName(disp, fn) ((disp)->PushName = fn)
-#define CALL_DrawBuffer(disp, parameters) (*((disp)->DrawBuffer)) parameters
-#define GET_DrawBuffer(disp) ((disp)->DrawBuffer)
-#define SET_DrawBuffer(disp, fn) ((disp)->DrawBuffer = fn)
-#define CALL_Clear(disp, parameters) (*((disp)->Clear)) parameters
-#define GET_Clear(disp) ((disp)->Clear)
-#define SET_Clear(disp, fn) ((disp)->Clear = fn)
-#define CALL_ClearAccum(disp, parameters) (*((disp)->ClearAccum)) parameters
-#define GET_ClearAccum(disp) ((disp)->ClearAccum)
-#define SET_ClearAccum(disp, fn) ((disp)->ClearAccum = fn)
-#define CALL_ClearIndex(disp, parameters) (*((disp)->ClearIndex)) parameters
-#define GET_ClearIndex(disp) ((disp)->ClearIndex)
-#define SET_ClearIndex(disp, fn) ((disp)->ClearIndex = fn)
-#define CALL_ClearColor(disp, parameters) (*((disp)->ClearColor)) parameters
-#define GET_ClearColor(disp) ((disp)->ClearColor)
-#define SET_ClearColor(disp, fn) ((disp)->ClearColor = fn)
-#define CALL_ClearStencil(disp, parameters) (*((disp)->ClearStencil)) parameters
-#define GET_ClearStencil(disp) ((disp)->ClearStencil)
-#define SET_ClearStencil(disp, fn) ((disp)->ClearStencil = fn)
-#define CALL_ClearDepth(disp, parameters) (*((disp)->ClearDepth)) parameters
-#define GET_ClearDepth(disp) ((disp)->ClearDepth)
-#define SET_ClearDepth(disp, fn) ((disp)->ClearDepth = fn)
-#define CALL_StencilMask(disp, parameters) (*((disp)->StencilMask)) parameters
-#define GET_StencilMask(disp) ((disp)->StencilMask)
-#define SET_StencilMask(disp, fn) ((disp)->StencilMask = fn)
-#define CALL_ColorMask(disp, parameters) (*((disp)->ColorMask)) parameters
-#define GET_ColorMask(disp) ((disp)->ColorMask)
-#define SET_ColorMask(disp, fn) ((disp)->ColorMask = fn)
-#define CALL_DepthMask(disp, parameters) (*((disp)->DepthMask)) parameters
-#define GET_DepthMask(disp) ((disp)->DepthMask)
-#define SET_DepthMask(disp, fn) ((disp)->DepthMask = fn)
-#define CALL_IndexMask(disp, parameters) (*((disp)->IndexMask)) parameters
-#define GET_IndexMask(disp) ((disp)->IndexMask)
-#define SET_IndexMask(disp, fn) ((disp)->IndexMask = fn)
-#define CALL_Accum(disp, parameters) (*((disp)->Accum)) parameters
-#define GET_Accum(disp) ((disp)->Accum)
-#define SET_Accum(disp, fn) ((disp)->Accum = fn)
-#define CALL_Disable(disp, parameters) (*((disp)->Disable)) parameters
-#define GET_Disable(disp) ((disp)->Disable)
-#define SET_Disable(disp, fn) ((disp)->Disable = fn)
-#define CALL_Enable(disp, parameters) (*((disp)->Enable)) parameters
-#define GET_Enable(disp) ((disp)->Enable)
-#define SET_Enable(disp, fn) ((disp)->Enable = fn)
-#define CALL_Finish(disp, parameters) (*((disp)->Finish)) parameters
-#define GET_Finish(disp) ((disp)->Finish)
-#define SET_Finish(disp, fn) ((disp)->Finish = fn)
-#define CALL_Flush(disp, parameters) (*((disp)->Flush)) parameters
-#define GET_Flush(disp) ((disp)->Flush)
-#define SET_Flush(disp, fn) ((disp)->Flush = fn)
-#define CALL_PopAttrib(disp, parameters) (*((disp)->PopAttrib)) parameters
-#define GET_PopAttrib(disp) ((disp)->PopAttrib)
-#define SET_PopAttrib(disp, fn) ((disp)->PopAttrib = fn)
-#define CALL_PushAttrib(disp, parameters) (*((disp)->PushAttrib)) parameters
-#define GET_PushAttrib(disp) ((disp)->PushAttrib)
-#define SET_PushAttrib(disp, fn) ((disp)->PushAttrib = fn)
-#define CALL_Map1d(disp, parameters) (*((disp)->Map1d)) parameters
-#define GET_Map1d(disp) ((disp)->Map1d)
-#define SET_Map1d(disp, fn) ((disp)->Map1d = fn)
-#define CALL_Map1f(disp, parameters) (*((disp)->Map1f)) parameters
-#define GET_Map1f(disp) ((disp)->Map1f)
-#define SET_Map1f(disp, fn) ((disp)->Map1f = fn)
-#define CALL_Map2d(disp, parameters) (*((disp)->Map2d)) parameters
-#define GET_Map2d(disp) ((disp)->Map2d)
-#define SET_Map2d(disp, fn) ((disp)->Map2d = fn)
-#define CALL_Map2f(disp, parameters) (*((disp)->Map2f)) parameters
-#define GET_Map2f(disp) ((disp)->Map2f)
-#define SET_Map2f(disp, fn) ((disp)->Map2f = fn)
-#define CALL_MapGrid1d(disp, parameters) (*((disp)->MapGrid1d)) parameters
-#define GET_MapGrid1d(disp) ((disp)->MapGrid1d)
-#define SET_MapGrid1d(disp, fn) ((disp)->MapGrid1d = fn)
-#define CALL_MapGrid1f(disp, parameters) (*((disp)->MapGrid1f)) parameters
-#define GET_MapGrid1f(disp) ((disp)->MapGrid1f)
-#define SET_MapGrid1f(disp, fn) ((disp)->MapGrid1f = fn)
-#define CALL_MapGrid2d(disp, parameters) (*((disp)->MapGrid2d)) parameters
-#define GET_MapGrid2d(disp) ((disp)->MapGrid2d)
-#define SET_MapGrid2d(disp, fn) ((disp)->MapGrid2d = fn)
-#define CALL_MapGrid2f(disp, parameters) (*((disp)->MapGrid2f)) parameters
-#define GET_MapGrid2f(disp) ((disp)->MapGrid2f)
-#define SET_MapGrid2f(disp, fn) ((disp)->MapGrid2f = fn)
-#define CALL_EvalCoord1d(disp, parameters) (*((disp)->EvalCoord1d)) parameters
-#define GET_EvalCoord1d(disp) ((disp)->EvalCoord1d)
-#define SET_EvalCoord1d(disp, fn) ((disp)->EvalCoord1d = fn)
-#define CALL_EvalCoord1dv(disp, parameters) (*((disp)->EvalCoord1dv)) parameters
-#define GET_EvalCoord1dv(disp) ((disp)->EvalCoord1dv)
-#define SET_EvalCoord1dv(disp, fn) ((disp)->EvalCoord1dv = fn)
-#define CALL_EvalCoord1f(disp, parameters) (*((disp)->EvalCoord1f)) parameters
-#define GET_EvalCoord1f(disp) ((disp)->EvalCoord1f)
-#define SET_EvalCoord1f(disp, fn) ((disp)->EvalCoord1f = fn)
-#define CALL_EvalCoord1fv(disp, parameters) (*((disp)->EvalCoord1fv)) parameters
-#define GET_EvalCoord1fv(disp) ((disp)->EvalCoord1fv)
-#define SET_EvalCoord1fv(disp, fn) ((disp)->EvalCoord1fv = fn)
-#define CALL_EvalCoord2d(disp, parameters) (*((disp)->EvalCoord2d)) parameters
-#define GET_EvalCoord2d(disp) ((disp)->EvalCoord2d)
-#define SET_EvalCoord2d(disp, fn) ((disp)->EvalCoord2d = fn)
-#define CALL_EvalCoord2dv(disp, parameters) (*((disp)->EvalCoord2dv)) parameters
-#define GET_EvalCoord2dv(disp) ((disp)->EvalCoord2dv)
-#define SET_EvalCoord2dv(disp, fn) ((disp)->EvalCoord2dv = fn)
-#define CALL_EvalCoord2f(disp, parameters) (*((disp)->EvalCoord2f)) parameters
-#define GET_EvalCoord2f(disp) ((disp)->EvalCoord2f)
-#define SET_EvalCoord2f(disp, fn) ((disp)->EvalCoord2f = fn)
-#define CALL_EvalCoord2fv(disp, parameters) (*((disp)->EvalCoord2fv)) parameters
-#define GET_EvalCoord2fv(disp) ((disp)->EvalCoord2fv)
-#define SET_EvalCoord2fv(disp, fn) ((disp)->EvalCoord2fv = fn)
-#define CALL_EvalMesh1(disp, parameters) (*((disp)->EvalMesh1)) parameters
-#define GET_EvalMesh1(disp) ((disp)->EvalMesh1)
-#define SET_EvalMesh1(disp, fn) ((disp)->EvalMesh1 = fn)
-#define CALL_EvalPoint1(disp, parameters) (*((disp)->EvalPoint1)) parameters
-#define GET_EvalPoint1(disp) ((disp)->EvalPoint1)
-#define SET_EvalPoint1(disp, fn) ((disp)->EvalPoint1 = fn)
-#define CALL_EvalMesh2(disp, parameters) (*((disp)->EvalMesh2)) parameters
-#define GET_EvalMesh2(disp) ((disp)->EvalMesh2)
-#define SET_EvalMesh2(disp, fn) ((disp)->EvalMesh2 = fn)
-#define CALL_EvalPoint2(disp, parameters) (*((disp)->EvalPoint2)) parameters
-#define GET_EvalPoint2(disp) ((disp)->EvalPoint2)
-#define SET_EvalPoint2(disp, fn) ((disp)->EvalPoint2 = fn)
-#define CALL_AlphaFunc(disp, parameters) (*((disp)->AlphaFunc)) parameters
-#define GET_AlphaFunc(disp) ((disp)->AlphaFunc)
-#define SET_AlphaFunc(disp, fn) ((disp)->AlphaFunc = fn)
-#define CALL_BlendFunc(disp, parameters) (*((disp)->BlendFunc)) parameters
-#define GET_BlendFunc(disp) ((disp)->BlendFunc)
-#define SET_BlendFunc(disp, fn) ((disp)->BlendFunc = fn)
-#define CALL_LogicOp(disp, parameters) (*((disp)->LogicOp)) parameters
-#define GET_LogicOp(disp) ((disp)->LogicOp)
-#define SET_LogicOp(disp, fn) ((disp)->LogicOp = fn)
-#define CALL_StencilFunc(disp, parameters) (*((disp)->StencilFunc)) parameters
-#define GET_StencilFunc(disp) ((disp)->StencilFunc)
-#define SET_StencilFunc(disp, fn) ((disp)->StencilFunc = fn)
-#define CALL_StencilOp(disp, parameters) (*((disp)->StencilOp)) parameters
-#define GET_StencilOp(disp) ((disp)->StencilOp)
-#define SET_StencilOp(disp, fn) ((disp)->StencilOp = fn)
-#define CALL_DepthFunc(disp, parameters) (*((disp)->DepthFunc)) parameters
-#define GET_DepthFunc(disp) ((disp)->DepthFunc)
-#define SET_DepthFunc(disp, fn) ((disp)->DepthFunc = fn)
-#define CALL_PixelZoom(disp, parameters) (*((disp)->PixelZoom)) parameters
-#define GET_PixelZoom(disp) ((disp)->PixelZoom)
-#define SET_PixelZoom(disp, fn) ((disp)->PixelZoom = fn)
-#define CALL_PixelTransferf(disp, parameters) (*((disp)->PixelTransferf)) parameters
-#define GET_PixelTransferf(disp) ((disp)->PixelTransferf)
-#define SET_PixelTransferf(disp, fn) ((disp)->PixelTransferf = fn)
-#define CALL_PixelTransferi(disp, parameters) (*((disp)->PixelTransferi)) parameters
-#define GET_PixelTransferi(disp) ((disp)->PixelTransferi)
-#define SET_PixelTransferi(disp, fn) ((disp)->PixelTransferi = fn)
-#define CALL_PixelStoref(disp, parameters) (*((disp)->PixelStoref)) parameters
-#define GET_PixelStoref(disp) ((disp)->PixelStoref)
-#define SET_PixelStoref(disp, fn) ((disp)->PixelStoref = fn)
-#define CALL_PixelStorei(disp, parameters) (*((disp)->PixelStorei)) parameters
-#define GET_PixelStorei(disp) ((disp)->PixelStorei)
-#define SET_PixelStorei(disp, fn) ((disp)->PixelStorei = fn)
-#define CALL_PixelMapfv(disp, parameters) (*((disp)->PixelMapfv)) parameters
-#define GET_PixelMapfv(disp) ((disp)->PixelMapfv)
-#define SET_PixelMapfv(disp, fn) ((disp)->PixelMapfv = fn)
-#define CALL_PixelMapuiv(disp, parameters) (*((disp)->PixelMapuiv)) parameters
-#define GET_PixelMapuiv(disp) ((disp)->PixelMapuiv)
-#define SET_PixelMapuiv(disp, fn) ((disp)->PixelMapuiv = fn)
-#define CALL_PixelMapusv(disp, parameters) (*((disp)->PixelMapusv)) parameters
-#define GET_PixelMapusv(disp) ((disp)->PixelMapusv)
-#define SET_PixelMapusv(disp, fn) ((disp)->PixelMapusv = fn)
-#define CALL_ReadBuffer(disp, parameters) (*((disp)->ReadBuffer)) parameters
-#define GET_ReadBuffer(disp) ((disp)->ReadBuffer)
-#define SET_ReadBuffer(disp, fn) ((disp)->ReadBuffer = fn)
-#define CALL_CopyPixels(disp, parameters) (*((disp)->CopyPixels)) parameters
-#define GET_CopyPixels(disp) ((disp)->CopyPixels)
-#define SET_CopyPixels(disp, fn) ((disp)->CopyPixels = fn)
-#define CALL_ReadPixels(disp, parameters) (*((disp)->ReadPixels)) parameters
-#define GET_ReadPixels(disp) ((disp)->ReadPixels)
-#define SET_ReadPixels(disp, fn) ((disp)->ReadPixels = fn)
-#define CALL_DrawPixels(disp, parameters) (*((disp)->DrawPixels)) parameters
-#define GET_DrawPixels(disp) ((disp)->DrawPixels)
-#define SET_DrawPixels(disp, fn) ((disp)->DrawPixels = fn)
-#define CALL_GetBooleanv(disp, parameters) (*((disp)->GetBooleanv)) parameters
-#define GET_GetBooleanv(disp) ((disp)->GetBooleanv)
-#define SET_GetBooleanv(disp, fn) ((disp)->GetBooleanv = fn)
-#define CALL_GetClipPlane(disp, parameters) (*((disp)->GetClipPlane)) parameters
-#define GET_GetClipPlane(disp) ((disp)->GetClipPlane)
-#define SET_GetClipPlane(disp, fn) ((disp)->GetClipPlane = fn)
-#define CALL_GetDoublev(disp, parameters) (*((disp)->GetDoublev)) parameters
-#define GET_GetDoublev(disp) ((disp)->GetDoublev)
-#define SET_GetDoublev(disp, fn) ((disp)->GetDoublev = fn)
-#define CALL_GetError(disp, parameters) (*((disp)->GetError)) parameters
-#define GET_GetError(disp) ((disp)->GetError)
-#define SET_GetError(disp, fn) ((disp)->GetError = fn)
-#define CALL_GetFloatv(disp, parameters) (*((disp)->GetFloatv)) parameters
-#define GET_GetFloatv(disp) ((disp)->GetFloatv)
-#define SET_GetFloatv(disp, fn) ((disp)->GetFloatv = fn)
-#define CALL_GetIntegerv(disp, parameters) (*((disp)->GetIntegerv)) parameters
-#define GET_GetIntegerv(disp) ((disp)->GetIntegerv)
-#define SET_GetIntegerv(disp, fn) ((disp)->GetIntegerv = fn)
-#define CALL_GetLightfv(disp, parameters) (*((disp)->GetLightfv)) parameters
-#define GET_GetLightfv(disp) ((disp)->GetLightfv)
-#define SET_GetLightfv(disp, fn) ((disp)->GetLightfv = fn)
-#define CALL_GetLightiv(disp, parameters) (*((disp)->GetLightiv)) parameters
-#define GET_GetLightiv(disp) ((disp)->GetLightiv)
-#define SET_GetLightiv(disp, fn) ((disp)->GetLightiv = fn)
-#define CALL_GetMapdv(disp, parameters) (*((disp)->GetMapdv)) parameters
-#define GET_GetMapdv(disp) ((disp)->GetMapdv)
-#define SET_GetMapdv(disp, fn) ((disp)->GetMapdv = fn)
-#define CALL_GetMapfv(disp, parameters) (*((disp)->GetMapfv)) parameters
-#define GET_GetMapfv(disp) ((disp)->GetMapfv)
-#define SET_GetMapfv(disp, fn) ((disp)->GetMapfv = fn)
-#define CALL_GetMapiv(disp, parameters) (*((disp)->GetMapiv)) parameters
-#define GET_GetMapiv(disp) ((disp)->GetMapiv)
-#define SET_GetMapiv(disp, fn) ((disp)->GetMapiv = fn)
-#define CALL_GetMaterialfv(disp, parameters) (*((disp)->GetMaterialfv)) parameters
-#define GET_GetMaterialfv(disp) ((disp)->GetMaterialfv)
-#define SET_GetMaterialfv(disp, fn) ((disp)->GetMaterialfv = fn)
-#define CALL_GetMaterialiv(disp, parameters) (*((disp)->GetMaterialiv)) parameters
-#define GET_GetMaterialiv(disp) ((disp)->GetMaterialiv)
-#define SET_GetMaterialiv(disp, fn) ((disp)->GetMaterialiv = fn)
-#define CALL_GetPixelMapfv(disp, parameters) (*((disp)->GetPixelMapfv)) parameters
-#define GET_GetPixelMapfv(disp) ((disp)->GetPixelMapfv)
-#define SET_GetPixelMapfv(disp, fn) ((disp)->GetPixelMapfv = fn)
-#define CALL_GetPixelMapuiv(disp, parameters) (*((disp)->GetPixelMapuiv)) parameters
-#define GET_GetPixelMapuiv(disp) ((disp)->GetPixelMapuiv)
-#define SET_GetPixelMapuiv(disp, fn) ((disp)->GetPixelMapuiv = fn)
-#define CALL_GetPixelMapusv(disp, parameters) (*((disp)->GetPixelMapusv)) parameters
-#define GET_GetPixelMapusv(disp) ((disp)->GetPixelMapusv)
-#define SET_GetPixelMapusv(disp, fn) ((disp)->GetPixelMapusv = fn)
-#define CALL_GetPolygonStipple(disp, parameters) (*((disp)->GetPolygonStipple)) parameters
-#define GET_GetPolygonStipple(disp) ((disp)->GetPolygonStipple)
-#define SET_GetPolygonStipple(disp, fn) ((disp)->GetPolygonStipple = fn)
-#define CALL_GetString(disp, parameters) (*((disp)->GetString)) parameters
-#define GET_GetString(disp) ((disp)->GetString)
-#define SET_GetString(disp, fn) ((disp)->GetString = fn)
-#define CALL_GetTexEnvfv(disp, parameters) (*((disp)->GetTexEnvfv)) parameters
-#define GET_GetTexEnvfv(disp) ((disp)->GetTexEnvfv)
-#define SET_GetTexEnvfv(disp, fn) ((disp)->GetTexEnvfv = fn)
-#define CALL_GetTexEnviv(disp, parameters) (*((disp)->GetTexEnviv)) parameters
-#define GET_GetTexEnviv(disp) ((disp)->GetTexEnviv)
-#define SET_GetTexEnviv(disp, fn) ((disp)->GetTexEnviv = fn)
-#define CALL_GetTexGendv(disp, parameters) (*((disp)->GetTexGendv)) parameters
-#define GET_GetTexGendv(disp) ((disp)->GetTexGendv)
-#define SET_GetTexGendv(disp, fn) ((disp)->GetTexGendv = fn)
-#define CALL_GetTexGenfv(disp, parameters) (*((disp)->GetTexGenfv)) parameters
-#define GET_GetTexGenfv(disp) ((disp)->GetTexGenfv)
-#define SET_GetTexGenfv(disp, fn) ((disp)->GetTexGenfv = fn)
-#define CALL_GetTexGeniv(disp, parameters) (*((disp)->GetTexGeniv)) parameters
-#define GET_GetTexGeniv(disp) ((disp)->GetTexGeniv)
-#define SET_GetTexGeniv(disp, fn) ((disp)->GetTexGeniv = fn)
-#define CALL_GetTexImage(disp, parameters) (*((disp)->GetTexImage)) parameters
-#define GET_GetTexImage(disp) ((disp)->GetTexImage)
-#define SET_GetTexImage(disp, fn) ((disp)->GetTexImage = fn)
-#define CALL_GetTexParameterfv(disp, parameters) (*((disp)->GetTexParameterfv)) parameters
-#define GET_GetTexParameterfv(disp) ((disp)->GetTexParameterfv)
-#define SET_GetTexParameterfv(disp, fn) ((disp)->GetTexParameterfv = fn)
-#define CALL_GetTexParameteriv(disp, parameters) (*((disp)->GetTexParameteriv)) parameters
-#define GET_GetTexParameteriv(disp) ((disp)->GetTexParameteriv)
-#define SET_GetTexParameteriv(disp, fn) ((disp)->GetTexParameteriv = fn)
-#define CALL_GetTexLevelParameterfv(disp, parameters) (*((disp)->GetTexLevelParameterfv)) parameters
-#define GET_GetTexLevelParameterfv(disp) ((disp)->GetTexLevelParameterfv)
-#define SET_GetTexLevelParameterfv(disp, fn) ((disp)->GetTexLevelParameterfv = fn)
-#define CALL_GetTexLevelParameteriv(disp, parameters) (*((disp)->GetTexLevelParameteriv)) parameters
-#define GET_GetTexLevelParameteriv(disp) ((disp)->GetTexLevelParameteriv)
-#define SET_GetTexLevelParameteriv(disp, fn) ((disp)->GetTexLevelParameteriv = fn)
-#define CALL_IsEnabled(disp, parameters) (*((disp)->IsEnabled)) parameters
-#define GET_IsEnabled(disp) ((disp)->IsEnabled)
-#define SET_IsEnabled(disp, fn) ((disp)->IsEnabled = fn)
-#define CALL_IsList(disp, parameters) (*((disp)->IsList)) parameters
-#define GET_IsList(disp) ((disp)->IsList)
-#define SET_IsList(disp, fn) ((disp)->IsList = fn)
-#define CALL_DepthRange(disp, parameters) (*((disp)->DepthRange)) parameters
-#define GET_DepthRange(disp) ((disp)->DepthRange)
-#define SET_DepthRange(disp, fn) ((disp)->DepthRange = fn)
-#define CALL_Frustum(disp, parameters) (*((disp)->Frustum)) parameters
-#define GET_Frustum(disp) ((disp)->Frustum)
-#define SET_Frustum(disp, fn) ((disp)->Frustum = fn)
-#define CALL_LoadIdentity(disp, parameters) (*((disp)->LoadIdentity)) parameters
-#define GET_LoadIdentity(disp) ((disp)->LoadIdentity)
-#define SET_LoadIdentity(disp, fn) ((disp)->LoadIdentity = fn)
-#define CALL_LoadMatrixf(disp, parameters) (*((disp)->LoadMatrixf)) parameters
-#define GET_LoadMatrixf(disp) ((disp)->LoadMatrixf)
-#define SET_LoadMatrixf(disp, fn) ((disp)->LoadMatrixf = fn)
-#define CALL_LoadMatrixd(disp, parameters) (*((disp)->LoadMatrixd)) parameters
-#define GET_LoadMatrixd(disp) ((disp)->LoadMatrixd)
-#define SET_LoadMatrixd(disp, fn) ((disp)->LoadMatrixd = fn)
-#define CALL_MatrixMode(disp, parameters) (*((disp)->MatrixMode)) parameters
-#define GET_MatrixMode(disp) ((disp)->MatrixMode)
-#define SET_MatrixMode(disp, fn) ((disp)->MatrixMode = fn)
-#define CALL_MultMatrixf(disp, parameters) (*((disp)->MultMatrixf)) parameters
-#define GET_MultMatrixf(disp) ((disp)->MultMatrixf)
-#define SET_MultMatrixf(disp, fn) ((disp)->MultMatrixf = fn)
-#define CALL_MultMatrixd(disp, parameters) (*((disp)->MultMatrixd)) parameters
-#define GET_MultMatrixd(disp) ((disp)->MultMatrixd)
-#define SET_MultMatrixd(disp, fn) ((disp)->MultMatrixd = fn)
-#define CALL_Ortho(disp, parameters) (*((disp)->Ortho)) parameters
-#define GET_Ortho(disp) ((disp)->Ortho)
-#define SET_Ortho(disp, fn) ((disp)->Ortho = fn)
-#define CALL_PopMatrix(disp, parameters) (*((disp)->PopMatrix)) parameters
-#define GET_PopMatrix(disp) ((disp)->PopMatrix)
-#define SET_PopMatrix(disp, fn) ((disp)->PopMatrix = fn)
-#define CALL_PushMatrix(disp, parameters) (*((disp)->PushMatrix)) parameters
-#define GET_PushMatrix(disp) ((disp)->PushMatrix)
-#define SET_PushMatrix(disp, fn) ((disp)->PushMatrix = fn)
-#define CALL_Rotated(disp, parameters) (*((disp)->Rotated)) parameters
-#define GET_Rotated(disp) ((disp)->Rotated)
-#define SET_Rotated(disp, fn) ((disp)->Rotated = fn)
-#define CALL_Rotatef(disp, parameters) (*((disp)->Rotatef)) parameters
-#define GET_Rotatef(disp) ((disp)->Rotatef)
-#define SET_Rotatef(disp, fn) ((disp)->Rotatef = fn)
-#define CALL_Scaled(disp, parameters) (*((disp)->Scaled)) parameters
-#define GET_Scaled(disp) ((disp)->Scaled)
-#define SET_Scaled(disp, fn) ((disp)->Scaled = fn)
-#define CALL_Scalef(disp, parameters) (*((disp)->Scalef)) parameters
-#define GET_Scalef(disp) ((disp)->Scalef)
-#define SET_Scalef(disp, fn) ((disp)->Scalef = fn)
-#define CALL_Translated(disp, parameters) (*((disp)->Translated)) parameters
-#define GET_Translated(disp) ((disp)->Translated)
-#define SET_Translated(disp, fn) ((disp)->Translated = fn)
-#define CALL_Translatef(disp, parameters) (*((disp)->Translatef)) parameters
-#define GET_Translatef(disp) ((disp)->Translatef)
-#define SET_Translatef(disp, fn) ((disp)->Translatef = fn)
-#define CALL_Viewport(disp, parameters) (*((disp)->Viewport)) parameters
-#define GET_Viewport(disp) ((disp)->Viewport)
-#define SET_Viewport(disp, fn) ((disp)->Viewport = fn)
-#define CALL_ArrayElement(disp, parameters) (*((disp)->ArrayElement)) parameters
-#define GET_ArrayElement(disp) ((disp)->ArrayElement)
-#define SET_ArrayElement(disp, fn) ((disp)->ArrayElement = fn)
-#define CALL_BindTexture(disp, parameters) (*((disp)->BindTexture)) parameters
-#define GET_BindTexture(disp) ((disp)->BindTexture)
-#define SET_BindTexture(disp, fn) ((disp)->BindTexture = fn)
-#define CALL_ColorPointer(disp, parameters) (*((disp)->ColorPointer)) parameters
-#define GET_ColorPointer(disp) ((disp)->ColorPointer)
-#define SET_ColorPointer(disp, fn) ((disp)->ColorPointer = fn)
-#define CALL_DisableClientState(disp, parameters) (*((disp)->DisableClientState)) parameters
-#define GET_DisableClientState(disp) ((disp)->DisableClientState)
-#define SET_DisableClientState(disp, fn) ((disp)->DisableClientState = fn)
-#define CALL_DrawArrays(disp, parameters) (*((disp)->DrawArrays)) parameters
-#define GET_DrawArrays(disp) ((disp)->DrawArrays)
-#define SET_DrawArrays(disp, fn) ((disp)->DrawArrays = fn)
-#define CALL_DrawElements(disp, parameters) (*((disp)->DrawElements)) parameters
-#define GET_DrawElements(disp) ((disp)->DrawElements)
-#define SET_DrawElements(disp, fn) ((disp)->DrawElements = fn)
-#define CALL_EdgeFlagPointer(disp, parameters) (*((disp)->EdgeFlagPointer)) parameters
-#define GET_EdgeFlagPointer(disp) ((disp)->EdgeFlagPointer)
-#define SET_EdgeFlagPointer(disp, fn) ((disp)->EdgeFlagPointer = fn)
-#define CALL_EnableClientState(disp, parameters) (*((disp)->EnableClientState)) parameters
-#define GET_EnableClientState(disp) ((disp)->EnableClientState)
-#define SET_EnableClientState(disp, fn) ((disp)->EnableClientState = fn)
-#define CALL_IndexPointer(disp, parameters) (*((disp)->IndexPointer)) parameters
-#define GET_IndexPointer(disp) ((disp)->IndexPointer)
-#define SET_IndexPointer(disp, fn) ((disp)->IndexPointer = fn)
-#define CALL_Indexub(disp, parameters) (*((disp)->Indexub)) parameters
-#define GET_Indexub(disp) ((disp)->Indexub)
-#define SET_Indexub(disp, fn) ((disp)->Indexub = fn)
-#define CALL_Indexubv(disp, parameters) (*((disp)->Indexubv)) parameters
-#define GET_Indexubv(disp) ((disp)->Indexubv)
-#define SET_Indexubv(disp, fn) ((disp)->Indexubv = fn)
-#define CALL_InterleavedArrays(disp, parameters) (*((disp)->InterleavedArrays)) parameters
-#define GET_InterleavedArrays(disp) ((disp)->InterleavedArrays)
-#define SET_InterleavedArrays(disp, fn) ((disp)->InterleavedArrays = fn)
-#define CALL_NormalPointer(disp, parameters) (*((disp)->NormalPointer)) parameters
-#define GET_NormalPointer(disp) ((disp)->NormalPointer)
-#define SET_NormalPointer(disp, fn) ((disp)->NormalPointer = fn)
-#define CALL_PolygonOffset(disp, parameters) (*((disp)->PolygonOffset)) parameters
-#define GET_PolygonOffset(disp) ((disp)->PolygonOffset)
-#define SET_PolygonOffset(disp, fn) ((disp)->PolygonOffset = fn)
-#define CALL_TexCoordPointer(disp, parameters) (*((disp)->TexCoordPointer)) parameters
-#define GET_TexCoordPointer(disp) ((disp)->TexCoordPointer)
-#define SET_TexCoordPointer(disp, fn) ((disp)->TexCoordPointer = fn)
-#define CALL_VertexPointer(disp, parameters) (*((disp)->VertexPointer)) parameters
-#define GET_VertexPointer(disp) ((disp)->VertexPointer)
-#define SET_VertexPointer(disp, fn) ((disp)->VertexPointer = fn)
-#define CALL_AreTexturesResident(disp, parameters) (*((disp)->AreTexturesResident)) parameters
-#define GET_AreTexturesResident(disp) ((disp)->AreTexturesResident)
-#define SET_AreTexturesResident(disp, fn) ((disp)->AreTexturesResident = fn)
-#define CALL_CopyTexImage1D(disp, parameters) (*((disp)->CopyTexImage1D)) parameters
-#define GET_CopyTexImage1D(disp) ((disp)->CopyTexImage1D)
-#define SET_CopyTexImage1D(disp, fn) ((disp)->CopyTexImage1D = fn)
-#define CALL_CopyTexImage2D(disp, parameters) (*((disp)->CopyTexImage2D)) parameters
-#define GET_CopyTexImage2D(disp) ((disp)->CopyTexImage2D)
-#define SET_CopyTexImage2D(disp, fn) ((disp)->CopyTexImage2D = fn)
-#define CALL_CopyTexSubImage1D(disp, parameters) (*((disp)->CopyTexSubImage1D)) parameters
-#define GET_CopyTexSubImage1D(disp) ((disp)->CopyTexSubImage1D)
-#define SET_CopyTexSubImage1D(disp, fn) ((disp)->CopyTexSubImage1D = fn)
-#define CALL_CopyTexSubImage2D(disp, parameters) (*((disp)->CopyTexSubImage2D)) parameters
-#define GET_CopyTexSubImage2D(disp) ((disp)->CopyTexSubImage2D)
-#define SET_CopyTexSubImage2D(disp, fn) ((disp)->CopyTexSubImage2D = fn)
-#define CALL_DeleteTextures(disp, parameters) (*((disp)->DeleteTextures)) parameters
-#define GET_DeleteTextures(disp) ((disp)->DeleteTextures)
-#define SET_DeleteTextures(disp, fn) ((disp)->DeleteTextures = fn)
-#define CALL_GenTextures(disp, parameters) (*((disp)->GenTextures)) parameters
-#define GET_GenTextures(disp) ((disp)->GenTextures)
-#define SET_GenTextures(disp, fn) ((disp)->GenTextures = fn)
-#define CALL_GetPointerv(disp, parameters) (*((disp)->GetPointerv)) parameters
-#define GET_GetPointerv(disp) ((disp)->GetPointerv)
-#define SET_GetPointerv(disp, fn) ((disp)->GetPointerv = fn)
-#define CALL_IsTexture(disp, parameters) (*((disp)->IsTexture)) parameters
-#define GET_IsTexture(disp) ((disp)->IsTexture)
-#define SET_IsTexture(disp, fn) ((disp)->IsTexture = fn)
-#define CALL_PrioritizeTextures(disp, parameters) (*((disp)->PrioritizeTextures)) parameters
-#define GET_PrioritizeTextures(disp) ((disp)->PrioritizeTextures)
-#define SET_PrioritizeTextures(disp, fn) ((disp)->PrioritizeTextures = fn)
-#define CALL_TexSubImage1D(disp, parameters) (*((disp)->TexSubImage1D)) parameters
-#define GET_TexSubImage1D(disp) ((disp)->TexSubImage1D)
-#define SET_TexSubImage1D(disp, fn) ((disp)->TexSubImage1D = fn)
-#define CALL_TexSubImage2D(disp, parameters) (*((disp)->TexSubImage2D)) parameters
-#define GET_TexSubImage2D(disp) ((disp)->TexSubImage2D)
-#define SET_TexSubImage2D(disp, fn) ((disp)->TexSubImage2D = fn)
-#define CALL_PopClientAttrib(disp, parameters) (*((disp)->PopClientAttrib)) parameters
-#define GET_PopClientAttrib(disp) ((disp)->PopClientAttrib)
-#define SET_PopClientAttrib(disp, fn) ((disp)->PopClientAttrib = fn)
-#define CALL_PushClientAttrib(disp, parameters) (*((disp)->PushClientAttrib)) parameters
-#define GET_PushClientAttrib(disp) ((disp)->PushClientAttrib)
-#define SET_PushClientAttrib(disp, fn) ((disp)->PushClientAttrib = fn)
-#define CALL_BlendColor(disp, parameters) (*((disp)->BlendColor)) parameters
-#define GET_BlendColor(disp) ((disp)->BlendColor)
-#define SET_BlendColor(disp, fn) ((disp)->BlendColor = fn)
-#define CALL_BlendEquation(disp, parameters) (*((disp)->BlendEquation)) parameters
-#define GET_BlendEquation(disp) ((disp)->BlendEquation)
-#define SET_BlendEquation(disp, fn) ((disp)->BlendEquation = fn)
-#define CALL_DrawRangeElements(disp, parameters) (*((disp)->DrawRangeElements)) parameters
-#define GET_DrawRangeElements(disp) ((disp)->DrawRangeElements)
-#define SET_DrawRangeElements(disp, fn) ((disp)->DrawRangeElements = fn)
-#define CALL_ColorTable(disp, parameters) (*((disp)->ColorTable)) parameters
-#define GET_ColorTable(disp) ((disp)->ColorTable)
-#define SET_ColorTable(disp, fn) ((disp)->ColorTable = fn)
-#define CALL_ColorTableParameterfv(disp, parameters) (*((disp)->ColorTableParameterfv)) parameters
-#define GET_ColorTableParameterfv(disp) ((disp)->ColorTableParameterfv)
-#define SET_ColorTableParameterfv(disp, fn) ((disp)->ColorTableParameterfv = fn)
-#define CALL_ColorTableParameteriv(disp, parameters) (*((disp)->ColorTableParameteriv)) parameters
-#define GET_ColorTableParameteriv(disp) ((disp)->ColorTableParameteriv)
-#define SET_ColorTableParameteriv(disp, fn) ((disp)->ColorTableParameteriv = fn)
-#define CALL_CopyColorTable(disp, parameters) (*((disp)->CopyColorTable)) parameters
-#define GET_CopyColorTable(disp) ((disp)->CopyColorTable)
-#define SET_CopyColorTable(disp, fn) ((disp)->CopyColorTable = fn)
-#define CALL_GetColorTable(disp, parameters) (*((disp)->GetColorTable)) parameters
-#define GET_GetColorTable(disp) ((disp)->GetColorTable)
-#define SET_GetColorTable(disp, fn) ((disp)->GetColorTable = fn)
-#define CALL_GetColorTableParameterfv(disp, parameters) (*((disp)->GetColorTableParameterfv)) parameters
-#define GET_GetColorTableParameterfv(disp) ((disp)->GetColorTableParameterfv)
-#define SET_GetColorTableParameterfv(disp, fn) ((disp)->GetColorTableParameterfv = fn)
-#define CALL_GetColorTableParameteriv(disp, parameters) (*((disp)->GetColorTableParameteriv)) parameters
-#define GET_GetColorTableParameteriv(disp) ((disp)->GetColorTableParameteriv)
-#define SET_GetColorTableParameteriv(disp, fn) ((disp)->GetColorTableParameteriv = fn)
-#define CALL_ColorSubTable(disp, parameters) (*((disp)->ColorSubTable)) parameters
-#define GET_ColorSubTable(disp) ((disp)->ColorSubTable)
-#define SET_ColorSubTable(disp, fn) ((disp)->ColorSubTable = fn)
-#define CALL_CopyColorSubTable(disp, parameters) (*((disp)->CopyColorSubTable)) parameters
-#define GET_CopyColorSubTable(disp) ((disp)->CopyColorSubTable)
-#define SET_CopyColorSubTable(disp, fn) ((disp)->CopyColorSubTable = fn)
-#define CALL_ConvolutionFilter1D(disp, parameters) (*((disp)->ConvolutionFilter1D)) parameters
-#define GET_ConvolutionFilter1D(disp) ((disp)->ConvolutionFilter1D)
-#define SET_ConvolutionFilter1D(disp, fn) ((disp)->ConvolutionFilter1D = fn)
-#define CALL_ConvolutionFilter2D(disp, parameters) (*((disp)->ConvolutionFilter2D)) parameters
-#define GET_ConvolutionFilter2D(disp) ((disp)->ConvolutionFilter2D)
-#define SET_ConvolutionFilter2D(disp, fn) ((disp)->ConvolutionFilter2D = fn)
-#define CALL_ConvolutionParameterf(disp, parameters) (*((disp)->ConvolutionParameterf)) parameters
-#define GET_ConvolutionParameterf(disp) ((disp)->ConvolutionParameterf)
-#define SET_ConvolutionParameterf(disp, fn) ((disp)->ConvolutionParameterf = fn)
-#define CALL_ConvolutionParameterfv(disp, parameters) (*((disp)->ConvolutionParameterfv)) parameters
-#define GET_ConvolutionParameterfv(disp) ((disp)->ConvolutionParameterfv)
-#define SET_ConvolutionParameterfv(disp, fn) ((disp)->ConvolutionParameterfv = fn)
-#define CALL_ConvolutionParameteri(disp, parameters) (*((disp)->ConvolutionParameteri)) parameters
-#define GET_ConvolutionParameteri(disp) ((disp)->ConvolutionParameteri)
-#define SET_ConvolutionParameteri(disp, fn) ((disp)->ConvolutionParameteri = fn)
-#define CALL_ConvolutionParameteriv(disp, parameters) (*((disp)->ConvolutionParameteriv)) parameters
-#define GET_ConvolutionParameteriv(disp) ((disp)->ConvolutionParameteriv)
-#define SET_ConvolutionParameteriv(disp, fn) ((disp)->ConvolutionParameteriv = fn)
-#define CALL_CopyConvolutionFilter1D(disp, parameters) (*((disp)->CopyConvolutionFilter1D)) parameters
-#define GET_CopyConvolutionFilter1D(disp) ((disp)->CopyConvolutionFilter1D)
-#define SET_CopyConvolutionFilter1D(disp, fn) ((disp)->CopyConvolutionFilter1D = fn)
-#define CALL_CopyConvolutionFilter2D(disp, parameters) (*((disp)->CopyConvolutionFilter2D)) parameters
-#define GET_CopyConvolutionFilter2D(disp) ((disp)->CopyConvolutionFilter2D)
-#define SET_CopyConvolutionFilter2D(disp, fn) ((disp)->CopyConvolutionFilter2D = fn)
-#define CALL_GetConvolutionFilter(disp, parameters) (*((disp)->GetConvolutionFilter)) parameters
-#define GET_GetConvolutionFilter(disp) ((disp)->GetConvolutionFilter)
-#define SET_GetConvolutionFilter(disp, fn) ((disp)->GetConvolutionFilter = fn)
-#define CALL_GetConvolutionParameterfv(disp, parameters) (*((disp)->GetConvolutionParameterfv)) parameters
-#define GET_GetConvolutionParameterfv(disp) ((disp)->GetConvolutionParameterfv)
-#define SET_GetConvolutionParameterfv(disp, fn) ((disp)->GetConvolutionParameterfv = fn)
-#define CALL_GetConvolutionParameteriv(disp, parameters) (*((disp)->GetConvolutionParameteriv)) parameters
-#define GET_GetConvolutionParameteriv(disp) ((disp)->GetConvolutionParameteriv)
-#define SET_GetConvolutionParameteriv(disp, fn) ((disp)->GetConvolutionParameteriv = fn)
-#define CALL_GetSeparableFilter(disp, parameters) (*((disp)->GetSeparableFilter)) parameters
-#define GET_GetSeparableFilter(disp) ((disp)->GetSeparableFilter)
-#define SET_GetSeparableFilter(disp, fn) ((disp)->GetSeparableFilter = fn)
-#define CALL_SeparableFilter2D(disp, parameters) (*((disp)->SeparableFilter2D)) parameters
-#define GET_SeparableFilter2D(disp) ((disp)->SeparableFilter2D)
-#define SET_SeparableFilter2D(disp, fn) ((disp)->SeparableFilter2D = fn)
-#define CALL_GetHistogram(disp, parameters) (*((disp)->GetHistogram)) parameters
-#define GET_GetHistogram(disp) ((disp)->GetHistogram)
-#define SET_GetHistogram(disp, fn) ((disp)->GetHistogram = fn)
-#define CALL_GetHistogramParameterfv(disp, parameters) (*((disp)->GetHistogramParameterfv)) parameters
-#define GET_GetHistogramParameterfv(disp) ((disp)->GetHistogramParameterfv)
-#define SET_GetHistogramParameterfv(disp, fn) ((disp)->GetHistogramParameterfv = fn)
-#define CALL_GetHistogramParameteriv(disp, parameters) (*((disp)->GetHistogramParameteriv)) parameters
-#define GET_GetHistogramParameteriv(disp) ((disp)->GetHistogramParameteriv)
-#define SET_GetHistogramParameteriv(disp, fn) ((disp)->GetHistogramParameteriv = fn)
-#define CALL_GetMinmax(disp, parameters) (*((disp)->GetMinmax)) parameters
-#define GET_GetMinmax(disp) ((disp)->GetMinmax)
-#define SET_GetMinmax(disp, fn) ((disp)->GetMinmax = fn)
-#define CALL_GetMinmaxParameterfv(disp, parameters) (*((disp)->GetMinmaxParameterfv)) parameters
-#define GET_GetMinmaxParameterfv(disp) ((disp)->GetMinmaxParameterfv)
-#define SET_GetMinmaxParameterfv(disp, fn) ((disp)->GetMinmaxParameterfv = fn)
-#define CALL_GetMinmaxParameteriv(disp, parameters) (*((disp)->GetMinmaxParameteriv)) parameters
-#define GET_GetMinmaxParameteriv(disp) ((disp)->GetMinmaxParameteriv)
-#define SET_GetMinmaxParameteriv(disp, fn) ((disp)->GetMinmaxParameteriv = fn)
-#define CALL_Histogram(disp, parameters) (*((disp)->Histogram)) parameters
-#define GET_Histogram(disp) ((disp)->Histogram)
-#define SET_Histogram(disp, fn) ((disp)->Histogram = fn)
-#define CALL_Minmax(disp, parameters) (*((disp)->Minmax)) parameters
-#define GET_Minmax(disp) ((disp)->Minmax)
-#define SET_Minmax(disp, fn) ((disp)->Minmax = fn)
-#define CALL_ResetHistogram(disp, parameters) (*((disp)->ResetHistogram)) parameters
-#define GET_ResetHistogram(disp) ((disp)->ResetHistogram)
-#define SET_ResetHistogram(disp, fn) ((disp)->ResetHistogram = fn)
-#define CALL_ResetMinmax(disp, parameters) (*((disp)->ResetMinmax)) parameters
-#define GET_ResetMinmax(disp) ((disp)->ResetMinmax)
-#define SET_ResetMinmax(disp, fn) ((disp)->ResetMinmax = fn)
-#define CALL_TexImage3D(disp, parameters) (*((disp)->TexImage3D)) parameters
-#define GET_TexImage3D(disp) ((disp)->TexImage3D)
-#define SET_TexImage3D(disp, fn) ((disp)->TexImage3D = fn)
-#define CALL_TexSubImage3D(disp, parameters) (*((disp)->TexSubImage3D)) parameters
-#define GET_TexSubImage3D(disp) ((disp)->TexSubImage3D)
-#define SET_TexSubImage3D(disp, fn) ((disp)->TexSubImage3D = fn)
-#define CALL_CopyTexSubImage3D(disp, parameters) (*((disp)->CopyTexSubImage3D)) parameters
-#define GET_CopyTexSubImage3D(disp) ((disp)->CopyTexSubImage3D)
-#define SET_CopyTexSubImage3D(disp, fn) ((disp)->CopyTexSubImage3D = fn)
-#define CALL_ActiveTextureARB(disp, parameters) (*((disp)->ActiveTextureARB)) parameters
-#define GET_ActiveTextureARB(disp) ((disp)->ActiveTextureARB)
-#define SET_ActiveTextureARB(disp, fn) ((disp)->ActiveTextureARB = fn)
-#define CALL_ClientActiveTextureARB(disp, parameters) (*((disp)->ClientActiveTextureARB)) parameters
-#define GET_ClientActiveTextureARB(disp) ((disp)->ClientActiveTextureARB)
-#define SET_ClientActiveTextureARB(disp, fn) ((disp)->ClientActiveTextureARB = fn)
-#define CALL_MultiTexCoord1dARB(disp, parameters) (*((disp)->MultiTexCoord1dARB)) parameters
-#define GET_MultiTexCoord1dARB(disp) ((disp)->MultiTexCoord1dARB)
-#define SET_MultiTexCoord1dARB(disp, fn) ((disp)->MultiTexCoord1dARB = fn)
-#define CALL_MultiTexCoord1dvARB(disp, parameters) (*((disp)->MultiTexCoord1dvARB)) parameters
-#define GET_MultiTexCoord1dvARB(disp) ((disp)->MultiTexCoord1dvARB)
-#define SET_MultiTexCoord1dvARB(disp, fn) ((disp)->MultiTexCoord1dvARB = fn)
-#define CALL_MultiTexCoord1fARB(disp, parameters) (*((disp)->MultiTexCoord1fARB)) parameters
-#define GET_MultiTexCoord1fARB(disp) ((disp)->MultiTexCoord1fARB)
-#define SET_MultiTexCoord1fARB(disp, fn) ((disp)->MultiTexCoord1fARB = fn)
-#define CALL_MultiTexCoord1fvARB(disp, parameters) (*((disp)->MultiTexCoord1fvARB)) parameters
-#define GET_MultiTexCoord1fvARB(disp) ((disp)->MultiTexCoord1fvARB)
-#define SET_MultiTexCoord1fvARB(disp, fn) ((disp)->MultiTexCoord1fvARB = fn)
-#define CALL_MultiTexCoord1iARB(disp, parameters) (*((disp)->MultiTexCoord1iARB)) parameters
-#define GET_MultiTexCoord1iARB(disp) ((disp)->MultiTexCoord1iARB)
-#define SET_MultiTexCoord1iARB(disp, fn) ((disp)->MultiTexCoord1iARB = fn)
-#define CALL_MultiTexCoord1ivARB(disp, parameters) (*((disp)->MultiTexCoord1ivARB)) parameters
-#define GET_MultiTexCoord1ivARB(disp) ((disp)->MultiTexCoord1ivARB)
-#define SET_MultiTexCoord1ivARB(disp, fn) ((disp)->MultiTexCoord1ivARB = fn)
-#define CALL_MultiTexCoord1sARB(disp, parameters) (*((disp)->MultiTexCoord1sARB)) parameters
-#define GET_MultiTexCoord1sARB(disp) ((disp)->MultiTexCoord1sARB)
-#define SET_MultiTexCoord1sARB(disp, fn) ((disp)->MultiTexCoord1sARB = fn)
-#define CALL_MultiTexCoord1svARB(disp, parameters) (*((disp)->MultiTexCoord1svARB)) parameters
-#define GET_MultiTexCoord1svARB(disp) ((disp)->MultiTexCoord1svARB)
-#define SET_MultiTexCoord1svARB(disp, fn) ((disp)->MultiTexCoord1svARB = fn)
-#define CALL_MultiTexCoord2dARB(disp, parameters) (*((disp)->MultiTexCoord2dARB)) parameters
-#define GET_MultiTexCoord2dARB(disp) ((disp)->MultiTexCoord2dARB)
-#define SET_MultiTexCoord2dARB(disp, fn) ((disp)->MultiTexCoord2dARB = fn)
-#define CALL_MultiTexCoord2dvARB(disp, parameters) (*((disp)->MultiTexCoord2dvARB)) parameters
-#define GET_MultiTexCoord2dvARB(disp) ((disp)->MultiTexCoord2dvARB)
-#define SET_MultiTexCoord2dvARB(disp, fn) ((disp)->MultiTexCoord2dvARB = fn)
-#define CALL_MultiTexCoord2fARB(disp, parameters) (*((disp)->MultiTexCoord2fARB)) parameters
-#define GET_MultiTexCoord2fARB(disp) ((disp)->MultiTexCoord2fARB)
-#define SET_MultiTexCoord2fARB(disp, fn) ((disp)->MultiTexCoord2fARB = fn)
-#define CALL_MultiTexCoord2fvARB(disp, parameters) (*((disp)->MultiTexCoord2fvARB)) parameters
-#define GET_MultiTexCoord2fvARB(disp) ((disp)->MultiTexCoord2fvARB)
-#define SET_MultiTexCoord2fvARB(disp, fn) ((disp)->MultiTexCoord2fvARB = fn)
-#define CALL_MultiTexCoord2iARB(disp, parameters) (*((disp)->MultiTexCoord2iARB)) parameters
-#define GET_MultiTexCoord2iARB(disp) ((disp)->MultiTexCoord2iARB)
-#define SET_MultiTexCoord2iARB(disp, fn) ((disp)->MultiTexCoord2iARB = fn)
-#define CALL_MultiTexCoord2ivARB(disp, parameters) (*((disp)->MultiTexCoord2ivARB)) parameters
-#define GET_MultiTexCoord2ivARB(disp) ((disp)->MultiTexCoord2ivARB)
-#define SET_MultiTexCoord2ivARB(disp, fn) ((disp)->MultiTexCoord2ivARB = fn)
-#define CALL_MultiTexCoord2sARB(disp, parameters) (*((disp)->MultiTexCoord2sARB)) parameters
-#define GET_MultiTexCoord2sARB(disp) ((disp)->MultiTexCoord2sARB)
-#define SET_MultiTexCoord2sARB(disp, fn) ((disp)->MultiTexCoord2sARB = fn)
-#define CALL_MultiTexCoord2svARB(disp, parameters) (*((disp)->MultiTexCoord2svARB)) parameters
-#define GET_MultiTexCoord2svARB(disp) ((disp)->MultiTexCoord2svARB)
-#define SET_MultiTexCoord2svARB(disp, fn) ((disp)->MultiTexCoord2svARB = fn)
-#define CALL_MultiTexCoord3dARB(disp, parameters) (*((disp)->MultiTexCoord3dARB)) parameters
-#define GET_MultiTexCoord3dARB(disp) ((disp)->MultiTexCoord3dARB)
-#define SET_MultiTexCoord3dARB(disp, fn) ((disp)->MultiTexCoord3dARB = fn)
-#define CALL_MultiTexCoord3dvARB(disp, parameters) (*((disp)->MultiTexCoord3dvARB)) parameters
-#define GET_MultiTexCoord3dvARB(disp) ((disp)->MultiTexCoord3dvARB)
-#define SET_MultiTexCoord3dvARB(disp, fn) ((disp)->MultiTexCoord3dvARB = fn)
-#define CALL_MultiTexCoord3fARB(disp, parameters) (*((disp)->MultiTexCoord3fARB)) parameters
-#define GET_MultiTexCoord3fARB(disp) ((disp)->MultiTexCoord3fARB)
-#define SET_MultiTexCoord3fARB(disp, fn) ((disp)->MultiTexCoord3fARB = fn)
-#define CALL_MultiTexCoord3fvARB(disp, parameters) (*((disp)->MultiTexCoord3fvARB)) parameters
-#define GET_MultiTexCoord3fvARB(disp) ((disp)->MultiTexCoord3fvARB)
-#define SET_MultiTexCoord3fvARB(disp, fn) ((disp)->MultiTexCoord3fvARB = fn)
-#define CALL_MultiTexCoord3iARB(disp, parameters) (*((disp)->MultiTexCoord3iARB)) parameters
-#define GET_MultiTexCoord3iARB(disp) ((disp)->MultiTexCoord3iARB)
-#define SET_MultiTexCoord3iARB(disp, fn) ((disp)->MultiTexCoord3iARB = fn)
-#define CALL_MultiTexCoord3ivARB(disp, parameters) (*((disp)->MultiTexCoord3ivARB)) parameters
-#define GET_MultiTexCoord3ivARB(disp) ((disp)->MultiTexCoord3ivARB)
-#define SET_MultiTexCoord3ivARB(disp, fn) ((disp)->MultiTexCoord3ivARB = fn)
-#define CALL_MultiTexCoord3sARB(disp, parameters) (*((disp)->MultiTexCoord3sARB)) parameters
-#define GET_MultiTexCoord3sARB(disp) ((disp)->MultiTexCoord3sARB)
-#define SET_MultiTexCoord3sARB(disp, fn) ((disp)->MultiTexCoord3sARB = fn)
-#define CALL_MultiTexCoord3svARB(disp, parameters) (*((disp)->MultiTexCoord3svARB)) parameters
-#define GET_MultiTexCoord3svARB(disp) ((disp)->MultiTexCoord3svARB)
-#define SET_MultiTexCoord3svARB(disp, fn) ((disp)->MultiTexCoord3svARB = fn)
-#define CALL_MultiTexCoord4dARB(disp, parameters) (*((disp)->MultiTexCoord4dARB)) parameters
-#define GET_MultiTexCoord4dARB(disp) ((disp)->MultiTexCoord4dARB)
-#define SET_MultiTexCoord4dARB(disp, fn) ((disp)->MultiTexCoord4dARB = fn)
-#define CALL_MultiTexCoord4dvARB(disp, parameters) (*((disp)->MultiTexCoord4dvARB)) parameters
-#define GET_MultiTexCoord4dvARB(disp) ((disp)->MultiTexCoord4dvARB)
-#define SET_MultiTexCoord4dvARB(disp, fn) ((disp)->MultiTexCoord4dvARB = fn)
-#define CALL_MultiTexCoord4fARB(disp, parameters) (*((disp)->MultiTexCoord4fARB)) parameters
-#define GET_MultiTexCoord4fARB(disp) ((disp)->MultiTexCoord4fARB)
-#define SET_MultiTexCoord4fARB(disp, fn) ((disp)->MultiTexCoord4fARB = fn)
-#define CALL_MultiTexCoord4fvARB(disp, parameters) (*((disp)->MultiTexCoord4fvARB)) parameters
-#define GET_MultiTexCoord4fvARB(disp) ((disp)->MultiTexCoord4fvARB)
-#define SET_MultiTexCoord4fvARB(disp, fn) ((disp)->MultiTexCoord4fvARB = fn)
-#define CALL_MultiTexCoord4iARB(disp, parameters) (*((disp)->MultiTexCoord4iARB)) parameters
-#define GET_MultiTexCoord4iARB(disp) ((disp)->MultiTexCoord4iARB)
-#define SET_MultiTexCoord4iARB(disp, fn) ((disp)->MultiTexCoord4iARB = fn)
-#define CALL_MultiTexCoord4ivARB(disp, parameters) (*((disp)->MultiTexCoord4ivARB)) parameters
-#define GET_MultiTexCoord4ivARB(disp) ((disp)->MultiTexCoord4ivARB)
-#define SET_MultiTexCoord4ivARB(disp, fn) ((disp)->MultiTexCoord4ivARB = fn)
-#define CALL_MultiTexCoord4sARB(disp, parameters) (*((disp)->MultiTexCoord4sARB)) parameters
-#define GET_MultiTexCoord4sARB(disp) ((disp)->MultiTexCoord4sARB)
-#define SET_MultiTexCoord4sARB(disp, fn) ((disp)->MultiTexCoord4sARB = fn)
-#define CALL_MultiTexCoord4svARB(disp, parameters) (*((disp)->MultiTexCoord4svARB)) parameters
-#define GET_MultiTexCoord4svARB(disp) ((disp)->MultiTexCoord4svARB)
-#define SET_MultiTexCoord4svARB(disp, fn) ((disp)->MultiTexCoord4svARB = fn)
-
-#if !defined(IN_DRI_DRIVER)
-
-#define CALL_AttachShader(disp, parameters) (*((disp)->AttachShader)) parameters
-#define GET_AttachShader(disp) ((disp)->AttachShader)
-#define SET_AttachShader(disp, fn) ((disp)->AttachShader = fn)
-#define CALL_CreateProgram(disp, parameters) (*((disp)->CreateProgram)) parameters
-#define GET_CreateProgram(disp) ((disp)->CreateProgram)
-#define SET_CreateProgram(disp, fn) ((disp)->CreateProgram = fn)
-#define CALL_CreateShader(disp, parameters) (*((disp)->CreateShader)) parameters
-#define GET_CreateShader(disp) ((disp)->CreateShader)
-#define SET_CreateShader(disp, fn) ((disp)->CreateShader = fn)
-#define CALL_DeleteProgram(disp, parameters) (*((disp)->DeleteProgram)) parameters
-#define GET_DeleteProgram(disp) ((disp)->DeleteProgram)
-#define SET_DeleteProgram(disp, fn) ((disp)->DeleteProgram = fn)
-#define CALL_DeleteShader(disp, parameters) (*((disp)->DeleteShader)) parameters
-#define GET_DeleteShader(disp) ((disp)->DeleteShader)
-#define SET_DeleteShader(disp, fn) ((disp)->DeleteShader = fn)
-#define CALL_DetachShader(disp, parameters) (*((disp)->DetachShader)) parameters
-#define GET_DetachShader(disp) ((disp)->DetachShader)
-#define SET_DetachShader(disp, fn) ((disp)->DetachShader = fn)
-#define CALL_GetAttachedShaders(disp, parameters) (*((disp)->GetAttachedShaders)) parameters
-#define GET_GetAttachedShaders(disp) ((disp)->GetAttachedShaders)
-#define SET_GetAttachedShaders(disp, fn) ((disp)->GetAttachedShaders = fn)
-#define CALL_GetProgramInfoLog(disp, parameters) (*((disp)->GetProgramInfoLog)) parameters
-#define GET_GetProgramInfoLog(disp) ((disp)->GetProgramInfoLog)
-#define SET_GetProgramInfoLog(disp, fn) ((disp)->GetProgramInfoLog = fn)
-#define CALL_GetProgramiv(disp, parameters) (*((disp)->GetProgramiv)) parameters
-#define GET_GetProgramiv(disp) ((disp)->GetProgramiv)
-#define SET_GetProgramiv(disp, fn) ((disp)->GetProgramiv = fn)
-#define CALL_GetShaderInfoLog(disp, parameters) (*((disp)->GetShaderInfoLog)) parameters
-#define GET_GetShaderInfoLog(disp) ((disp)->GetShaderInfoLog)
-#define SET_GetShaderInfoLog(disp, fn) ((disp)->GetShaderInfoLog = fn)
-#define CALL_GetShaderiv(disp, parameters) (*((disp)->GetShaderiv)) parameters
-#define GET_GetShaderiv(disp) ((disp)->GetShaderiv)
-#define SET_GetShaderiv(disp, fn) ((disp)->GetShaderiv = fn)
-#define CALL_IsProgram(disp, parameters) (*((disp)->IsProgram)) parameters
-#define GET_IsProgram(disp) ((disp)->IsProgram)
-#define SET_IsProgram(disp, fn) ((disp)->IsProgram = fn)
-#define CALL_IsShader(disp, parameters) (*((disp)->IsShader)) parameters
-#define GET_IsShader(disp) ((disp)->IsShader)
-#define SET_IsShader(disp, fn) ((disp)->IsShader = fn)
-#define CALL_StencilFuncSeparate(disp, parameters) (*((disp)->StencilFuncSeparate)) parameters
-#define GET_StencilFuncSeparate(disp) ((disp)->StencilFuncSeparate)
-#define SET_StencilFuncSeparate(disp, fn) ((disp)->StencilFuncSeparate = fn)
-#define CALL_StencilMaskSeparate(disp, parameters) (*((disp)->StencilMaskSeparate)) parameters
-#define GET_StencilMaskSeparate(disp) ((disp)->StencilMaskSeparate)
-#define SET_StencilMaskSeparate(disp, fn) ((disp)->StencilMaskSeparate = fn)
-#define CALL_StencilOpSeparate(disp, parameters) (*((disp)->StencilOpSeparate)) parameters
-#define GET_StencilOpSeparate(disp) ((disp)->StencilOpSeparate)
-#define SET_StencilOpSeparate(disp, fn) ((disp)->StencilOpSeparate = fn)
-#define CALL_UniformMatrix2x3fv(disp, parameters) (*((disp)->UniformMatrix2x3fv)) parameters
-#define GET_UniformMatrix2x3fv(disp) ((disp)->UniformMatrix2x3fv)
-#define SET_UniformMatrix2x3fv(disp, fn) ((disp)->UniformMatrix2x3fv = fn)
-#define CALL_UniformMatrix2x4fv(disp, parameters) (*((disp)->UniformMatrix2x4fv)) parameters
-#define GET_UniformMatrix2x4fv(disp) ((disp)->UniformMatrix2x4fv)
-#define SET_UniformMatrix2x4fv(disp, fn) ((disp)->UniformMatrix2x4fv = fn)
-#define CALL_UniformMatrix3x2fv(disp, parameters) (*((disp)->UniformMatrix3x2fv)) parameters
-#define GET_UniformMatrix3x2fv(disp) ((disp)->UniformMatrix3x2fv)
-#define SET_UniformMatrix3x2fv(disp, fn) ((disp)->UniformMatrix3x2fv = fn)
-#define CALL_UniformMatrix3x4fv(disp, parameters) (*((disp)->UniformMatrix3x4fv)) parameters
-#define GET_UniformMatrix3x4fv(disp) ((disp)->UniformMatrix3x4fv)
-#define SET_UniformMatrix3x4fv(disp, fn) ((disp)->UniformMatrix3x4fv = fn)
-#define CALL_UniformMatrix4x2fv(disp, parameters) (*((disp)->UniformMatrix4x2fv)) parameters
-#define GET_UniformMatrix4x2fv(disp) ((disp)->UniformMatrix4x2fv)
-#define SET_UniformMatrix4x2fv(disp, fn) ((disp)->UniformMatrix4x2fv = fn)
-#define CALL_UniformMatrix4x3fv(disp, parameters) (*((disp)->UniformMatrix4x3fv)) parameters
-#define GET_UniformMatrix4x3fv(disp) ((disp)->UniformMatrix4x3fv)
-#define SET_UniformMatrix4x3fv(disp, fn) ((disp)->UniformMatrix4x3fv = fn)
-#define CALL_LoadTransposeMatrixdARB(disp, parameters) (*((disp)->LoadTransposeMatrixdARB)) parameters
-#define GET_LoadTransposeMatrixdARB(disp) ((disp)->LoadTransposeMatrixdARB)
-#define SET_LoadTransposeMatrixdARB(disp, fn) ((disp)->LoadTransposeMatrixdARB = fn)
-#define CALL_LoadTransposeMatrixfARB(disp, parameters) (*((disp)->LoadTransposeMatrixfARB)) parameters
-#define GET_LoadTransposeMatrixfARB(disp) ((disp)->LoadTransposeMatrixfARB)
-#define SET_LoadTransposeMatrixfARB(disp, fn) ((disp)->LoadTransposeMatrixfARB = fn)
-#define CALL_MultTransposeMatrixdARB(disp, parameters) (*((disp)->MultTransposeMatrixdARB)) parameters
-#define GET_MultTransposeMatrixdARB(disp) ((disp)->MultTransposeMatrixdARB)
-#define SET_MultTransposeMatrixdARB(disp, fn) ((disp)->MultTransposeMatrixdARB = fn)
-#define CALL_MultTransposeMatrixfARB(disp, parameters) (*((disp)->MultTransposeMatrixfARB)) parameters
-#define GET_MultTransposeMatrixfARB(disp) ((disp)->MultTransposeMatrixfARB)
-#define SET_MultTransposeMatrixfARB(disp, fn) ((disp)->MultTransposeMatrixfARB = fn)
-#define CALL_SampleCoverageARB(disp, parameters) (*((disp)->SampleCoverageARB)) parameters
-#define GET_SampleCoverageARB(disp) ((disp)->SampleCoverageARB)
-#define SET_SampleCoverageARB(disp, fn) ((disp)->SampleCoverageARB = fn)
-#define CALL_CompressedTexImage1DARB(disp, parameters) (*((disp)->CompressedTexImage1DARB)) parameters
-#define GET_CompressedTexImage1DARB(disp) ((disp)->CompressedTexImage1DARB)
-#define SET_CompressedTexImage1DARB(disp, fn) ((disp)->CompressedTexImage1DARB = fn)
-#define CALL_CompressedTexImage2DARB(disp, parameters) (*((disp)->CompressedTexImage2DARB)) parameters
-#define GET_CompressedTexImage2DARB(disp) ((disp)->CompressedTexImage2DARB)
-#define SET_CompressedTexImage2DARB(disp, fn) ((disp)->CompressedTexImage2DARB = fn)
-#define CALL_CompressedTexImage3DARB(disp, parameters) (*((disp)->CompressedTexImage3DARB)) parameters
-#define GET_CompressedTexImage3DARB(disp) ((disp)->CompressedTexImage3DARB)
-#define SET_CompressedTexImage3DARB(disp, fn) ((disp)->CompressedTexImage3DARB = fn)
-#define CALL_CompressedTexSubImage1DARB(disp, parameters) (*((disp)->CompressedTexSubImage1DARB)) parameters
-#define GET_CompressedTexSubImage1DARB(disp) ((disp)->CompressedTexSubImage1DARB)
-#define SET_CompressedTexSubImage1DARB(disp, fn) ((disp)->CompressedTexSubImage1DARB = fn)
-#define CALL_CompressedTexSubImage2DARB(disp, parameters) (*((disp)->CompressedTexSubImage2DARB)) parameters
-#define GET_CompressedTexSubImage2DARB(disp) ((disp)->CompressedTexSubImage2DARB)
-#define SET_CompressedTexSubImage2DARB(disp, fn) ((disp)->CompressedTexSubImage2DARB = fn)
-#define CALL_CompressedTexSubImage3DARB(disp, parameters) (*((disp)->CompressedTexSubImage3DARB)) parameters
-#define GET_CompressedTexSubImage3DARB(disp) ((disp)->CompressedTexSubImage3DARB)
-#define SET_CompressedTexSubImage3DARB(disp, fn) ((disp)->CompressedTexSubImage3DARB = fn)
-#define CALL_GetCompressedTexImageARB(disp, parameters) (*((disp)->GetCompressedTexImageARB)) parameters
-#define GET_GetCompressedTexImageARB(disp) ((disp)->GetCompressedTexImageARB)
-#define SET_GetCompressedTexImageARB(disp, fn) ((disp)->GetCompressedTexImageARB = fn)
-#define CALL_DisableVertexAttribArrayARB(disp, parameters) (*((disp)->DisableVertexAttribArrayARB)) parameters
-#define GET_DisableVertexAttribArrayARB(disp) ((disp)->DisableVertexAttribArrayARB)
-#define SET_DisableVertexAttribArrayARB(disp, fn) ((disp)->DisableVertexAttribArrayARB = fn)
-#define CALL_EnableVertexAttribArrayARB(disp, parameters) (*((disp)->EnableVertexAttribArrayARB)) parameters
-#define GET_EnableVertexAttribArrayARB(disp) ((disp)->EnableVertexAttribArrayARB)
-#define SET_EnableVertexAttribArrayARB(disp, fn) ((disp)->EnableVertexAttribArrayARB = fn)
-#define CALL_GetProgramEnvParameterdvARB(disp, parameters) (*((disp)->GetProgramEnvParameterdvARB)) parameters
-#define GET_GetProgramEnvParameterdvARB(disp) ((disp)->GetProgramEnvParameterdvARB)
-#define SET_GetProgramEnvParameterdvARB(disp, fn) ((disp)->GetProgramEnvParameterdvARB = fn)
-#define CALL_GetProgramEnvParameterfvARB(disp, parameters) (*((disp)->GetProgramEnvParameterfvARB)) parameters
-#define GET_GetProgramEnvParameterfvARB(disp) ((disp)->GetProgramEnvParameterfvARB)
-#define SET_GetProgramEnvParameterfvARB(disp, fn) ((disp)->GetProgramEnvParameterfvARB = fn)
-#define CALL_GetProgramLocalParameterdvARB(disp, parameters) (*((disp)->GetProgramLocalParameterdvARB)) parameters
-#define GET_GetProgramLocalParameterdvARB(disp) ((disp)->GetProgramLocalParameterdvARB)
-#define SET_GetProgramLocalParameterdvARB(disp, fn) ((disp)->GetProgramLocalParameterdvARB = fn)
-#define CALL_GetProgramLocalParameterfvARB(disp, parameters) (*((disp)->GetProgramLocalParameterfvARB)) parameters
-#define GET_GetProgramLocalParameterfvARB(disp) ((disp)->GetProgramLocalParameterfvARB)
-#define SET_GetProgramLocalParameterfvARB(disp, fn) ((disp)->GetProgramLocalParameterfvARB = fn)
-#define CALL_GetProgramStringARB(disp, parameters) (*((disp)->GetProgramStringARB)) parameters
-#define GET_GetProgramStringARB(disp) ((disp)->GetProgramStringARB)
-#define SET_GetProgramStringARB(disp, fn) ((disp)->GetProgramStringARB = fn)
-#define CALL_GetProgramivARB(disp, parameters) (*((disp)->GetProgramivARB)) parameters
-#define GET_GetProgramivARB(disp) ((disp)->GetProgramivARB)
-#define SET_GetProgramivARB(disp, fn) ((disp)->GetProgramivARB = fn)
-#define CALL_GetVertexAttribdvARB(disp, parameters) (*((disp)->GetVertexAttribdvARB)) parameters
-#define GET_GetVertexAttribdvARB(disp) ((disp)->GetVertexAttribdvARB)
-#define SET_GetVertexAttribdvARB(disp, fn) ((disp)->GetVertexAttribdvARB = fn)
-#define CALL_GetVertexAttribfvARB(disp, parameters) (*((disp)->GetVertexAttribfvARB)) parameters
-#define GET_GetVertexAttribfvARB(disp) ((disp)->GetVertexAttribfvARB)
-#define SET_GetVertexAttribfvARB(disp, fn) ((disp)->GetVertexAttribfvARB = fn)
-#define CALL_GetVertexAttribivARB(disp, parameters) (*((disp)->GetVertexAttribivARB)) parameters
-#define GET_GetVertexAttribivARB(disp) ((disp)->GetVertexAttribivARB)
-#define SET_GetVertexAttribivARB(disp, fn) ((disp)->GetVertexAttribivARB = fn)
-#define CALL_ProgramEnvParameter4dARB(disp, parameters) (*((disp)->ProgramEnvParameter4dARB)) parameters
-#define GET_ProgramEnvParameter4dARB(disp) ((disp)->ProgramEnvParameter4dARB)
-#define SET_ProgramEnvParameter4dARB(disp, fn) ((disp)->ProgramEnvParameter4dARB = fn)
-#define CALL_ProgramEnvParameter4dvARB(disp, parameters) (*((disp)->ProgramEnvParameter4dvARB)) parameters
-#define GET_ProgramEnvParameter4dvARB(disp) ((disp)->ProgramEnvParameter4dvARB)
-#define SET_ProgramEnvParameter4dvARB(disp, fn) ((disp)->ProgramEnvParameter4dvARB = fn)
-#define CALL_ProgramEnvParameter4fARB(disp, parameters) (*((disp)->ProgramEnvParameter4fARB)) parameters
-#define GET_ProgramEnvParameter4fARB(disp) ((disp)->ProgramEnvParameter4fARB)
-#define SET_ProgramEnvParameter4fARB(disp, fn) ((disp)->ProgramEnvParameter4fARB = fn)
-#define CALL_ProgramEnvParameter4fvARB(disp, parameters) (*((disp)->ProgramEnvParameter4fvARB)) parameters
-#define GET_ProgramEnvParameter4fvARB(disp) ((disp)->ProgramEnvParameter4fvARB)
-#define SET_ProgramEnvParameter4fvARB(disp, fn) ((disp)->ProgramEnvParameter4fvARB = fn)
-#define CALL_ProgramLocalParameter4dARB(disp, parameters) (*((disp)->ProgramLocalParameter4dARB)) parameters
-#define GET_ProgramLocalParameter4dARB(disp) ((disp)->ProgramLocalParameter4dARB)
-#define SET_ProgramLocalParameter4dARB(disp, fn) ((disp)->ProgramLocalParameter4dARB = fn)
-#define CALL_ProgramLocalParameter4dvARB(disp, parameters) (*((disp)->ProgramLocalParameter4dvARB)) parameters
-#define GET_ProgramLocalParameter4dvARB(disp) ((disp)->ProgramLocalParameter4dvARB)
-#define SET_ProgramLocalParameter4dvARB(disp, fn) ((disp)->ProgramLocalParameter4dvARB = fn)
-#define CALL_ProgramLocalParameter4fARB(disp, parameters) (*((disp)->ProgramLocalParameter4fARB)) parameters
-#define GET_ProgramLocalParameter4fARB(disp) ((disp)->ProgramLocalParameter4fARB)
-#define SET_ProgramLocalParameter4fARB(disp, fn) ((disp)->ProgramLocalParameter4fARB = fn)
-#define CALL_ProgramLocalParameter4fvARB(disp, parameters) (*((disp)->ProgramLocalParameter4fvARB)) parameters
-#define GET_ProgramLocalParameter4fvARB(disp) ((disp)->ProgramLocalParameter4fvARB)
-#define SET_ProgramLocalParameter4fvARB(disp, fn) ((disp)->ProgramLocalParameter4fvARB = fn)
-#define CALL_ProgramStringARB(disp, parameters) (*((disp)->ProgramStringARB)) parameters
-#define GET_ProgramStringARB(disp) ((disp)->ProgramStringARB)
-#define SET_ProgramStringARB(disp, fn) ((disp)->ProgramStringARB = fn)
-#define CALL_VertexAttrib1dARB(disp, parameters) (*((disp)->VertexAttrib1dARB)) parameters
-#define GET_VertexAttrib1dARB(disp) ((disp)->VertexAttrib1dARB)
-#define SET_VertexAttrib1dARB(disp, fn) ((disp)->VertexAttrib1dARB = fn)
-#define CALL_VertexAttrib1dvARB(disp, parameters) (*((disp)->VertexAttrib1dvARB)) parameters
-#define GET_VertexAttrib1dvARB(disp) ((disp)->VertexAttrib1dvARB)
-#define SET_VertexAttrib1dvARB(disp, fn) ((disp)->VertexAttrib1dvARB = fn)
-#define CALL_VertexAttrib1fARB(disp, parameters) (*((disp)->VertexAttrib1fARB)) parameters
-#define GET_VertexAttrib1fARB(disp) ((disp)->VertexAttrib1fARB)
-#define SET_VertexAttrib1fARB(disp, fn) ((disp)->VertexAttrib1fARB = fn)
-#define CALL_VertexAttrib1fvARB(disp, parameters) (*((disp)->VertexAttrib1fvARB)) parameters
-#define GET_VertexAttrib1fvARB(disp) ((disp)->VertexAttrib1fvARB)
-#define SET_VertexAttrib1fvARB(disp, fn) ((disp)->VertexAttrib1fvARB = fn)
-#define CALL_VertexAttrib1sARB(disp, parameters) (*((disp)->VertexAttrib1sARB)) parameters
-#define GET_VertexAttrib1sARB(disp) ((disp)->VertexAttrib1sARB)
-#define SET_VertexAttrib1sARB(disp, fn) ((disp)->VertexAttrib1sARB = fn)
-#define CALL_VertexAttrib1svARB(disp, parameters) (*((disp)->VertexAttrib1svARB)) parameters
-#define GET_VertexAttrib1svARB(disp) ((disp)->VertexAttrib1svARB)
-#define SET_VertexAttrib1svARB(disp, fn) ((disp)->VertexAttrib1svARB = fn)
-#define CALL_VertexAttrib2dARB(disp, parameters) (*((disp)->VertexAttrib2dARB)) parameters
-#define GET_VertexAttrib2dARB(disp) ((disp)->VertexAttrib2dARB)
-#define SET_VertexAttrib2dARB(disp, fn) ((disp)->VertexAttrib2dARB = fn)
-#define CALL_VertexAttrib2dvARB(disp, parameters) (*((disp)->VertexAttrib2dvARB)) parameters
-#define GET_VertexAttrib2dvARB(disp) ((disp)->VertexAttrib2dvARB)
-#define SET_VertexAttrib2dvARB(disp, fn) ((disp)->VertexAttrib2dvARB = fn)
-#define CALL_VertexAttrib2fARB(disp, parameters) (*((disp)->VertexAttrib2fARB)) parameters
-#define GET_VertexAttrib2fARB(disp) ((disp)->VertexAttrib2fARB)
-#define SET_VertexAttrib2fARB(disp, fn) ((disp)->VertexAttrib2fARB = fn)
-#define CALL_VertexAttrib2fvARB(disp, parameters) (*((disp)->VertexAttrib2fvARB)) parameters
-#define GET_VertexAttrib2fvARB(disp) ((disp)->VertexAttrib2fvARB)
-#define SET_VertexAttrib2fvARB(disp, fn) ((disp)->VertexAttrib2fvARB = fn)
-#define CALL_VertexAttrib2sARB(disp, parameters) (*((disp)->VertexAttrib2sARB)) parameters
-#define GET_VertexAttrib2sARB(disp) ((disp)->VertexAttrib2sARB)
-#define SET_VertexAttrib2sARB(disp, fn) ((disp)->VertexAttrib2sARB = fn)
-#define CALL_VertexAttrib2svARB(disp, parameters) (*((disp)->VertexAttrib2svARB)) parameters
-#define GET_VertexAttrib2svARB(disp) ((disp)->VertexAttrib2svARB)
-#define SET_VertexAttrib2svARB(disp, fn) ((disp)->VertexAttrib2svARB = fn)
-#define CALL_VertexAttrib3dARB(disp, parameters) (*((disp)->VertexAttrib3dARB)) parameters
-#define GET_VertexAttrib3dARB(disp) ((disp)->VertexAttrib3dARB)
-#define SET_VertexAttrib3dARB(disp, fn) ((disp)->VertexAttrib3dARB = fn)
-#define CALL_VertexAttrib3dvARB(disp, parameters) (*((disp)->VertexAttrib3dvARB)) parameters
-#define GET_VertexAttrib3dvARB(disp) ((disp)->VertexAttrib3dvARB)
-#define SET_VertexAttrib3dvARB(disp, fn) ((disp)->VertexAttrib3dvARB = fn)
-#define CALL_VertexAttrib3fARB(disp, parameters) (*((disp)->VertexAttrib3fARB)) parameters
-#define GET_VertexAttrib3fARB(disp) ((disp)->VertexAttrib3fARB)
-#define SET_VertexAttrib3fARB(disp, fn) ((disp)->VertexAttrib3fARB = fn)
-#define CALL_VertexAttrib3fvARB(disp, parameters) (*((disp)->VertexAttrib3fvARB)) parameters
-#define GET_VertexAttrib3fvARB(disp) ((disp)->VertexAttrib3fvARB)
-#define SET_VertexAttrib3fvARB(disp, fn) ((disp)->VertexAttrib3fvARB = fn)
-#define CALL_VertexAttrib3sARB(disp, parameters) (*((disp)->VertexAttrib3sARB)) parameters
-#define GET_VertexAttrib3sARB(disp) ((disp)->VertexAttrib3sARB)
-#define SET_VertexAttrib3sARB(disp, fn) ((disp)->VertexAttrib3sARB = fn)
-#define CALL_VertexAttrib3svARB(disp, parameters) (*((disp)->VertexAttrib3svARB)) parameters
-#define GET_VertexAttrib3svARB(disp) ((disp)->VertexAttrib3svARB)
-#define SET_VertexAttrib3svARB(disp, fn) ((disp)->VertexAttrib3svARB = fn)
-#define CALL_VertexAttrib4NbvARB(disp, parameters) (*((disp)->VertexAttrib4NbvARB)) parameters
-#define GET_VertexAttrib4NbvARB(disp) ((disp)->VertexAttrib4NbvARB)
-#define SET_VertexAttrib4NbvARB(disp, fn) ((disp)->VertexAttrib4NbvARB = fn)
-#define CALL_VertexAttrib4NivARB(disp, parameters) (*((disp)->VertexAttrib4NivARB)) parameters
-#define GET_VertexAttrib4NivARB(disp) ((disp)->VertexAttrib4NivARB)
-#define SET_VertexAttrib4NivARB(disp, fn) ((disp)->VertexAttrib4NivARB = fn)
-#define CALL_VertexAttrib4NsvARB(disp, parameters) (*((disp)->VertexAttrib4NsvARB)) parameters
-#define GET_VertexAttrib4NsvARB(disp) ((disp)->VertexAttrib4NsvARB)
-#define SET_VertexAttrib4NsvARB(disp, fn) ((disp)->VertexAttrib4NsvARB = fn)
-#define CALL_VertexAttrib4NubARB(disp, parameters) (*((disp)->VertexAttrib4NubARB)) parameters
-#define GET_VertexAttrib4NubARB(disp) ((disp)->VertexAttrib4NubARB)
-#define SET_VertexAttrib4NubARB(disp, fn) ((disp)->VertexAttrib4NubARB = fn)
-#define CALL_VertexAttrib4NubvARB(disp, parameters) (*((disp)->VertexAttrib4NubvARB)) parameters
-#define GET_VertexAttrib4NubvARB(disp) ((disp)->VertexAttrib4NubvARB)
-#define SET_VertexAttrib4NubvARB(disp, fn) ((disp)->VertexAttrib4NubvARB = fn)
-#define CALL_VertexAttrib4NuivARB(disp, parameters) (*((disp)->VertexAttrib4NuivARB)) parameters
-#define GET_VertexAttrib4NuivARB(disp) ((disp)->VertexAttrib4NuivARB)
-#define SET_VertexAttrib4NuivARB(disp, fn) ((disp)->VertexAttrib4NuivARB = fn)
-#define CALL_VertexAttrib4NusvARB(disp, parameters) (*((disp)->VertexAttrib4NusvARB)) parameters
-#define GET_VertexAttrib4NusvARB(disp) ((disp)->VertexAttrib4NusvARB)
-#define SET_VertexAttrib4NusvARB(disp, fn) ((disp)->VertexAttrib4NusvARB = fn)
-#define CALL_VertexAttrib4bvARB(disp, parameters) (*((disp)->VertexAttrib4bvARB)) parameters
-#define GET_VertexAttrib4bvARB(disp) ((disp)->VertexAttrib4bvARB)
-#define SET_VertexAttrib4bvARB(disp, fn) ((disp)->VertexAttrib4bvARB = fn)
-#define CALL_VertexAttrib4dARB(disp, parameters) (*((disp)->VertexAttrib4dARB)) parameters
-#define GET_VertexAttrib4dARB(disp) ((disp)->VertexAttrib4dARB)
-#define SET_VertexAttrib4dARB(disp, fn) ((disp)->VertexAttrib4dARB = fn)
-#define CALL_VertexAttrib4dvARB(disp, parameters) (*((disp)->VertexAttrib4dvARB)) parameters
-#define GET_VertexAttrib4dvARB(disp) ((disp)->VertexAttrib4dvARB)
-#define SET_VertexAttrib4dvARB(disp, fn) ((disp)->VertexAttrib4dvARB = fn)
-#define CALL_VertexAttrib4fARB(disp, parameters) (*((disp)->VertexAttrib4fARB)) parameters
-#define GET_VertexAttrib4fARB(disp) ((disp)->VertexAttrib4fARB)
-#define SET_VertexAttrib4fARB(disp, fn) ((disp)->VertexAttrib4fARB = fn)
-#define CALL_VertexAttrib4fvARB(disp, parameters) (*((disp)->VertexAttrib4fvARB)) parameters
-#define GET_VertexAttrib4fvARB(disp) ((disp)->VertexAttrib4fvARB)
-#define SET_VertexAttrib4fvARB(disp, fn) ((disp)->VertexAttrib4fvARB = fn)
-#define CALL_VertexAttrib4ivARB(disp, parameters) (*((disp)->VertexAttrib4ivARB)) parameters
-#define GET_VertexAttrib4ivARB(disp) ((disp)->VertexAttrib4ivARB)
-#define SET_VertexAttrib4ivARB(disp, fn) ((disp)->VertexAttrib4ivARB = fn)
-#define CALL_VertexAttrib4sARB(disp, parameters) (*((disp)->VertexAttrib4sARB)) parameters
-#define GET_VertexAttrib4sARB(disp) ((disp)->VertexAttrib4sARB)
-#define SET_VertexAttrib4sARB(disp, fn) ((disp)->VertexAttrib4sARB = fn)
-#define CALL_VertexAttrib4svARB(disp, parameters) (*((disp)->VertexAttrib4svARB)) parameters
-#define GET_VertexAttrib4svARB(disp) ((disp)->VertexAttrib4svARB)
-#define SET_VertexAttrib4svARB(disp, fn) ((disp)->VertexAttrib4svARB = fn)
-#define CALL_VertexAttrib4ubvARB(disp, parameters) (*((disp)->VertexAttrib4ubvARB)) parameters
-#define GET_VertexAttrib4ubvARB(disp) ((disp)->VertexAttrib4ubvARB)
-#define SET_VertexAttrib4ubvARB(disp, fn) ((disp)->VertexAttrib4ubvARB = fn)
-#define CALL_VertexAttrib4uivARB(disp, parameters) (*((disp)->VertexAttrib4uivARB)) parameters
-#define GET_VertexAttrib4uivARB(disp) ((disp)->VertexAttrib4uivARB)
-#define SET_VertexAttrib4uivARB(disp, fn) ((disp)->VertexAttrib4uivARB = fn)
-#define CALL_VertexAttrib4usvARB(disp, parameters) (*((disp)->VertexAttrib4usvARB)) parameters
-#define GET_VertexAttrib4usvARB(disp) ((disp)->VertexAttrib4usvARB)
-#define SET_VertexAttrib4usvARB(disp, fn) ((disp)->VertexAttrib4usvARB = fn)
-#define CALL_VertexAttribPointerARB(disp, parameters) (*((disp)->VertexAttribPointerARB)) parameters
-#define GET_VertexAttribPointerARB(disp) ((disp)->VertexAttribPointerARB)
-#define SET_VertexAttribPointerARB(disp, fn) ((disp)->VertexAttribPointerARB = fn)
-#define CALL_BindBufferARB(disp, parameters) (*((disp)->BindBufferARB)) parameters
-#define GET_BindBufferARB(disp) ((disp)->BindBufferARB)
-#define SET_BindBufferARB(disp, fn) ((disp)->BindBufferARB = fn)
-#define CALL_BufferDataARB(disp, parameters) (*((disp)->BufferDataARB)) parameters
-#define GET_BufferDataARB(disp) ((disp)->BufferDataARB)
-#define SET_BufferDataARB(disp, fn) ((disp)->BufferDataARB = fn)
-#define CALL_BufferSubDataARB(disp, parameters) (*((disp)->BufferSubDataARB)) parameters
-#define GET_BufferSubDataARB(disp) ((disp)->BufferSubDataARB)
-#define SET_BufferSubDataARB(disp, fn) ((disp)->BufferSubDataARB = fn)
-#define CALL_DeleteBuffersARB(disp, parameters) (*((disp)->DeleteBuffersARB)) parameters
-#define GET_DeleteBuffersARB(disp) ((disp)->DeleteBuffersARB)
-#define SET_DeleteBuffersARB(disp, fn) ((disp)->DeleteBuffersARB = fn)
-#define CALL_GenBuffersARB(disp, parameters) (*((disp)->GenBuffersARB)) parameters
-#define GET_GenBuffersARB(disp) ((disp)->GenBuffersARB)
-#define SET_GenBuffersARB(disp, fn) ((disp)->GenBuffersARB = fn)
-#define CALL_GetBufferParameterivARB(disp, parameters) (*((disp)->GetBufferParameterivARB)) parameters
-#define GET_GetBufferParameterivARB(disp) ((disp)->GetBufferParameterivARB)
-#define SET_GetBufferParameterivARB(disp, fn) ((disp)->GetBufferParameterivARB = fn)
-#define CALL_GetBufferPointervARB(disp, parameters) (*((disp)->GetBufferPointervARB)) parameters
-#define GET_GetBufferPointervARB(disp) ((disp)->GetBufferPointervARB)
-#define SET_GetBufferPointervARB(disp, fn) ((disp)->GetBufferPointervARB = fn)
-#define CALL_GetBufferSubDataARB(disp, parameters) (*((disp)->GetBufferSubDataARB)) parameters
-#define GET_GetBufferSubDataARB(disp) ((disp)->GetBufferSubDataARB)
-#define SET_GetBufferSubDataARB(disp, fn) ((disp)->GetBufferSubDataARB = fn)
-#define CALL_IsBufferARB(disp, parameters) (*((disp)->IsBufferARB)) parameters
-#define GET_IsBufferARB(disp) ((disp)->IsBufferARB)
-#define SET_IsBufferARB(disp, fn) ((disp)->IsBufferARB = fn)
-#define CALL_MapBufferARB(disp, parameters) (*((disp)->MapBufferARB)) parameters
-#define GET_MapBufferARB(disp) ((disp)->MapBufferARB)
-#define SET_MapBufferARB(disp, fn) ((disp)->MapBufferARB = fn)
-#define CALL_UnmapBufferARB(disp, parameters) (*((disp)->UnmapBufferARB)) parameters
-#define GET_UnmapBufferARB(disp) ((disp)->UnmapBufferARB)
-#define SET_UnmapBufferARB(disp, fn) ((disp)->UnmapBufferARB = fn)
-#define CALL_BeginQueryARB(disp, parameters) (*((disp)->BeginQueryARB)) parameters
-#define GET_BeginQueryARB(disp) ((disp)->BeginQueryARB)
-#define SET_BeginQueryARB(disp, fn) ((disp)->BeginQueryARB = fn)
-#define CALL_DeleteQueriesARB(disp, parameters) (*((disp)->DeleteQueriesARB)) parameters
-#define GET_DeleteQueriesARB(disp) ((disp)->DeleteQueriesARB)
-#define SET_DeleteQueriesARB(disp, fn) ((disp)->DeleteQueriesARB = fn)
-#define CALL_EndQueryARB(disp, parameters) (*((disp)->EndQueryARB)) parameters
-#define GET_EndQueryARB(disp) ((disp)->EndQueryARB)
-#define SET_EndQueryARB(disp, fn) ((disp)->EndQueryARB = fn)
-#define CALL_GenQueriesARB(disp, parameters) (*((disp)->GenQueriesARB)) parameters
-#define GET_GenQueriesARB(disp) ((disp)->GenQueriesARB)
-#define SET_GenQueriesARB(disp, fn) ((disp)->GenQueriesARB = fn)
-#define CALL_GetQueryObjectivARB(disp, parameters) (*((disp)->GetQueryObjectivARB)) parameters
-#define GET_GetQueryObjectivARB(disp) ((disp)->GetQueryObjectivARB)
-#define SET_GetQueryObjectivARB(disp, fn) ((disp)->GetQueryObjectivARB = fn)
-#define CALL_GetQueryObjectuivARB(disp, parameters) (*((disp)->GetQueryObjectuivARB)) parameters
-#define GET_GetQueryObjectuivARB(disp) ((disp)->GetQueryObjectuivARB)
-#define SET_GetQueryObjectuivARB(disp, fn) ((disp)->GetQueryObjectuivARB = fn)
-#define CALL_GetQueryivARB(disp, parameters) (*((disp)->GetQueryivARB)) parameters
-#define GET_GetQueryivARB(disp) ((disp)->GetQueryivARB)
-#define SET_GetQueryivARB(disp, fn) ((disp)->GetQueryivARB = fn)
-#define CALL_IsQueryARB(disp, parameters) (*((disp)->IsQueryARB)) parameters
-#define GET_IsQueryARB(disp) ((disp)->IsQueryARB)
-#define SET_IsQueryARB(disp, fn) ((disp)->IsQueryARB = fn)
-#define CALL_AttachObjectARB(disp, parameters) (*((disp)->AttachObjectARB)) parameters
-#define GET_AttachObjectARB(disp) ((disp)->AttachObjectARB)
-#define SET_AttachObjectARB(disp, fn) ((disp)->AttachObjectARB = fn)
-#define CALL_CompileShaderARB(disp, parameters) (*((disp)->CompileShaderARB)) parameters
-#define GET_CompileShaderARB(disp) ((disp)->CompileShaderARB)
-#define SET_CompileShaderARB(disp, fn) ((disp)->CompileShaderARB = fn)
-#define CALL_CreateProgramObjectARB(disp, parameters) (*((disp)->CreateProgramObjectARB)) parameters
-#define GET_CreateProgramObjectARB(disp) ((disp)->CreateProgramObjectARB)
-#define SET_CreateProgramObjectARB(disp, fn) ((disp)->CreateProgramObjectARB = fn)
-#define CALL_CreateShaderObjectARB(disp, parameters) (*((disp)->CreateShaderObjectARB)) parameters
-#define GET_CreateShaderObjectARB(disp) ((disp)->CreateShaderObjectARB)
-#define SET_CreateShaderObjectARB(disp, fn) ((disp)->CreateShaderObjectARB = fn)
-#define CALL_DeleteObjectARB(disp, parameters) (*((disp)->DeleteObjectARB)) parameters
-#define GET_DeleteObjectARB(disp) ((disp)->DeleteObjectARB)
-#define SET_DeleteObjectARB(disp, fn) ((disp)->DeleteObjectARB = fn)
-#define CALL_DetachObjectARB(disp, parameters) (*((disp)->DetachObjectARB)) parameters
-#define GET_DetachObjectARB(disp) ((disp)->DetachObjectARB)
-#define SET_DetachObjectARB(disp, fn) ((disp)->DetachObjectARB = fn)
-#define CALL_GetActiveUniformARB(disp, parameters) (*((disp)->GetActiveUniformARB)) parameters
-#define GET_GetActiveUniformARB(disp) ((disp)->GetActiveUniformARB)
-#define SET_GetActiveUniformARB(disp, fn) ((disp)->GetActiveUniformARB = fn)
-#define CALL_GetAttachedObjectsARB(disp, parameters) (*((disp)->GetAttachedObjectsARB)) parameters
-#define GET_GetAttachedObjectsARB(disp) ((disp)->GetAttachedObjectsARB)
-#define SET_GetAttachedObjectsARB(disp, fn) ((disp)->GetAttachedObjectsARB = fn)
-#define CALL_GetHandleARB(disp, parameters) (*((disp)->GetHandleARB)) parameters
-#define GET_GetHandleARB(disp) ((disp)->GetHandleARB)
-#define SET_GetHandleARB(disp, fn) ((disp)->GetHandleARB = fn)
-#define CALL_GetInfoLogARB(disp, parameters) (*((disp)->GetInfoLogARB)) parameters
-#define GET_GetInfoLogARB(disp) ((disp)->GetInfoLogARB)
-#define SET_GetInfoLogARB(disp, fn) ((disp)->GetInfoLogARB = fn)
-#define CALL_GetObjectParameterfvARB(disp, parameters) (*((disp)->GetObjectParameterfvARB)) parameters
-#define GET_GetObjectParameterfvARB(disp) ((disp)->GetObjectParameterfvARB)
-#define SET_GetObjectParameterfvARB(disp, fn) ((disp)->GetObjectParameterfvARB = fn)
-#define CALL_GetObjectParameterivARB(disp, parameters) (*((disp)->GetObjectParameterivARB)) parameters
-#define GET_GetObjectParameterivARB(disp) ((disp)->GetObjectParameterivARB)
-#define SET_GetObjectParameterivARB(disp, fn) ((disp)->GetObjectParameterivARB = fn)
-#define CALL_GetShaderSourceARB(disp, parameters) (*((disp)->GetShaderSourceARB)) parameters
-#define GET_GetShaderSourceARB(disp) ((disp)->GetShaderSourceARB)
-#define SET_GetShaderSourceARB(disp, fn) ((disp)->GetShaderSourceARB = fn)
-#define CALL_GetUniformLocationARB(disp, parameters) (*((disp)->GetUniformLocationARB)) parameters
-#define GET_GetUniformLocationARB(disp) ((disp)->GetUniformLocationARB)
-#define SET_GetUniformLocationARB(disp, fn) ((disp)->GetUniformLocationARB = fn)
-#define CALL_GetUniformfvARB(disp, parameters) (*((disp)->GetUniformfvARB)) parameters
-#define GET_GetUniformfvARB(disp) ((disp)->GetUniformfvARB)
-#define SET_GetUniformfvARB(disp, fn) ((disp)->GetUniformfvARB = fn)
-#define CALL_GetUniformivARB(disp, parameters) (*((disp)->GetUniformivARB)) parameters
-#define GET_GetUniformivARB(disp) ((disp)->GetUniformivARB)
-#define SET_GetUniformivARB(disp, fn) ((disp)->GetUniformivARB = fn)
-#define CALL_LinkProgramARB(disp, parameters) (*((disp)->LinkProgramARB)) parameters
-#define GET_LinkProgramARB(disp) ((disp)->LinkProgramARB)
-#define SET_LinkProgramARB(disp, fn) ((disp)->LinkProgramARB = fn)
-#define CALL_ShaderSourceARB(disp, parameters) (*((disp)->ShaderSourceARB)) parameters
-#define GET_ShaderSourceARB(disp) ((disp)->ShaderSourceARB)
-#define SET_ShaderSourceARB(disp, fn) ((disp)->ShaderSourceARB = fn)
-#define CALL_Uniform1fARB(disp, parameters) (*((disp)->Uniform1fARB)) parameters
-#define GET_Uniform1fARB(disp) ((disp)->Uniform1fARB)
-#define SET_Uniform1fARB(disp, fn) ((disp)->Uniform1fARB = fn)
-#define CALL_Uniform1fvARB(disp, parameters) (*((disp)->Uniform1fvARB)) parameters
-#define GET_Uniform1fvARB(disp) ((disp)->Uniform1fvARB)
-#define SET_Uniform1fvARB(disp, fn) ((disp)->Uniform1fvARB = fn)
-#define CALL_Uniform1iARB(disp, parameters) (*((disp)->Uniform1iARB)) parameters
-#define GET_Uniform1iARB(disp) ((disp)->Uniform1iARB)
-#define SET_Uniform1iARB(disp, fn) ((disp)->Uniform1iARB = fn)
-#define CALL_Uniform1ivARB(disp, parameters) (*((disp)->Uniform1ivARB)) parameters
-#define GET_Uniform1ivARB(disp) ((disp)->Uniform1ivARB)
-#define SET_Uniform1ivARB(disp, fn) ((disp)->Uniform1ivARB = fn)
-#define CALL_Uniform2fARB(disp, parameters) (*((disp)->Uniform2fARB)) parameters
-#define GET_Uniform2fARB(disp) ((disp)->Uniform2fARB)
-#define SET_Uniform2fARB(disp, fn) ((disp)->Uniform2fARB = fn)
-#define CALL_Uniform2fvARB(disp, parameters) (*((disp)->Uniform2fvARB)) parameters
-#define GET_Uniform2fvARB(disp) ((disp)->Uniform2fvARB)
-#define SET_Uniform2fvARB(disp, fn) ((disp)->Uniform2fvARB = fn)
-#define CALL_Uniform2iARB(disp, parameters) (*((disp)->Uniform2iARB)) parameters
-#define GET_Uniform2iARB(disp) ((disp)->Uniform2iARB)
-#define SET_Uniform2iARB(disp, fn) ((disp)->Uniform2iARB = fn)
-#define CALL_Uniform2ivARB(disp, parameters) (*((disp)->Uniform2ivARB)) parameters
-#define GET_Uniform2ivARB(disp) ((disp)->Uniform2ivARB)
-#define SET_Uniform2ivARB(disp, fn) ((disp)->Uniform2ivARB = fn)
-#define CALL_Uniform3fARB(disp, parameters) (*((disp)->Uniform3fARB)) parameters
-#define GET_Uniform3fARB(disp) ((disp)->Uniform3fARB)
-#define SET_Uniform3fARB(disp, fn) ((disp)->Uniform3fARB = fn)
-#define CALL_Uniform3fvARB(disp, parameters) (*((disp)->Uniform3fvARB)) parameters
-#define GET_Uniform3fvARB(disp) ((disp)->Uniform3fvARB)
-#define SET_Uniform3fvARB(disp, fn) ((disp)->Uniform3fvARB = fn)
-#define CALL_Uniform3iARB(disp, parameters) (*((disp)->Uniform3iARB)) parameters
-#define GET_Uniform3iARB(disp) ((disp)->Uniform3iARB)
-#define SET_Uniform3iARB(disp, fn) ((disp)->Uniform3iARB = fn)
-#define CALL_Uniform3ivARB(disp, parameters) (*((disp)->Uniform3ivARB)) parameters
-#define GET_Uniform3ivARB(disp) ((disp)->Uniform3ivARB)
-#define SET_Uniform3ivARB(disp, fn) ((disp)->Uniform3ivARB = fn)
-#define CALL_Uniform4fARB(disp, parameters) (*((disp)->Uniform4fARB)) parameters
-#define GET_Uniform4fARB(disp) ((disp)->Uniform4fARB)
-#define SET_Uniform4fARB(disp, fn) ((disp)->Uniform4fARB = fn)
-#define CALL_Uniform4fvARB(disp, parameters) (*((disp)->Uniform4fvARB)) parameters
-#define GET_Uniform4fvARB(disp) ((disp)->Uniform4fvARB)
-#define SET_Uniform4fvARB(disp, fn) ((disp)->Uniform4fvARB = fn)
-#define CALL_Uniform4iARB(disp, parameters) (*((disp)->Uniform4iARB)) parameters
-#define GET_Uniform4iARB(disp) ((disp)->Uniform4iARB)
-#define SET_Uniform4iARB(disp, fn) ((disp)->Uniform4iARB = fn)
-#define CALL_Uniform4ivARB(disp, parameters) (*((disp)->Uniform4ivARB)) parameters
-#define GET_Uniform4ivARB(disp) ((disp)->Uniform4ivARB)
-#define SET_Uniform4ivARB(disp, fn) ((disp)->Uniform4ivARB = fn)
-#define CALL_UniformMatrix2fvARB(disp, parameters) (*((disp)->UniformMatrix2fvARB)) parameters
-#define GET_UniformMatrix2fvARB(disp) ((disp)->UniformMatrix2fvARB)
-#define SET_UniformMatrix2fvARB(disp, fn) ((disp)->UniformMatrix2fvARB = fn)
-#define CALL_UniformMatrix3fvARB(disp, parameters) (*((disp)->UniformMatrix3fvARB)) parameters
-#define GET_UniformMatrix3fvARB(disp) ((disp)->UniformMatrix3fvARB)
-#define SET_UniformMatrix3fvARB(disp, fn) ((disp)->UniformMatrix3fvARB = fn)
-#define CALL_UniformMatrix4fvARB(disp, parameters) (*((disp)->UniformMatrix4fvARB)) parameters
-#define GET_UniformMatrix4fvARB(disp) ((disp)->UniformMatrix4fvARB)
-#define SET_UniformMatrix4fvARB(disp, fn) ((disp)->UniformMatrix4fvARB = fn)
-#define CALL_UseProgramObjectARB(disp, parameters) (*((disp)->UseProgramObjectARB)) parameters
-#define GET_UseProgramObjectARB(disp) ((disp)->UseProgramObjectARB)
-#define SET_UseProgramObjectARB(disp, fn) ((disp)->UseProgramObjectARB = fn)
-#define CALL_ValidateProgramARB(disp, parameters) (*((disp)->ValidateProgramARB)) parameters
-#define GET_ValidateProgramARB(disp) ((disp)->ValidateProgramARB)
-#define SET_ValidateProgramARB(disp, fn) ((disp)->ValidateProgramARB = fn)
-#define CALL_BindAttribLocationARB(disp, parameters) (*((disp)->BindAttribLocationARB)) parameters
-#define GET_BindAttribLocationARB(disp) ((disp)->BindAttribLocationARB)
-#define SET_BindAttribLocationARB(disp, fn) ((disp)->BindAttribLocationARB = fn)
-#define CALL_GetActiveAttribARB(disp, parameters) (*((disp)->GetActiveAttribARB)) parameters
-#define GET_GetActiveAttribARB(disp) ((disp)->GetActiveAttribARB)
-#define SET_GetActiveAttribARB(disp, fn) ((disp)->GetActiveAttribARB = fn)
-#define CALL_GetAttribLocationARB(disp, parameters) (*((disp)->GetAttribLocationARB)) parameters
-#define GET_GetAttribLocationARB(disp) ((disp)->GetAttribLocationARB)
-#define SET_GetAttribLocationARB(disp, fn) ((disp)->GetAttribLocationARB = fn)
-#define CALL_DrawBuffersARB(disp, parameters) (*((disp)->DrawBuffersARB)) parameters
-#define GET_DrawBuffersARB(disp) ((disp)->DrawBuffersARB)
-#define SET_DrawBuffersARB(disp, fn) ((disp)->DrawBuffersARB = fn)
-#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_BindVertexArray(disp, parameters) (*((disp)->BindVertexArray)) parameters
-#define GET_BindVertexArray(disp) ((disp)->BindVertexArray)
-#define SET_BindVertexArray(disp, fn) ((disp)->BindVertexArray = fn)
-#define CALL_GenVertexArrays(disp, parameters) (*((disp)->GenVertexArrays)) parameters
-#define GET_GenVertexArrays(disp) ((disp)->GenVertexArrays)
-#define SET_GenVertexArrays(disp, fn) ((disp)->GenVertexArrays = 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_ClientWaitSync(disp, parameters) (*((disp)->ClientWaitSync)) parameters
-#define GET_ClientWaitSync(disp) ((disp)->ClientWaitSync)
-#define SET_ClientWaitSync(disp, fn) ((disp)->ClientWaitSync = fn)
-#define CALL_DeleteSync(disp, parameters) (*((disp)->DeleteSync)) parameters
-#define GET_DeleteSync(disp) ((disp)->DeleteSync)
-#define SET_DeleteSync(disp, fn) ((disp)->DeleteSync = fn)
-#define CALL_FenceSync(disp, parameters) (*((disp)->FenceSync)) parameters
-#define GET_FenceSync(disp) ((disp)->FenceSync)
-#define SET_FenceSync(disp, fn) ((disp)->FenceSync = fn)
-#define CALL_GetInteger64v(disp, parameters) (*((disp)->GetInteger64v)) parameters
-#define GET_GetInteger64v(disp) ((disp)->GetInteger64v)
-#define SET_GetInteger64v(disp, fn) ((disp)->GetInteger64v = fn)
-#define CALL_GetSynciv(disp, parameters) (*((disp)->GetSynciv)) parameters
-#define GET_GetSynciv(disp) ((disp)->GetSynciv)
-#define SET_GetSynciv(disp, fn) ((disp)->GetSynciv = fn)
-#define CALL_IsSync(disp, parameters) (*((disp)->IsSync)) parameters
-#define GET_IsSync(disp) ((disp)->IsSync)
-#define SET_IsSync(disp, fn) ((disp)->IsSync = fn)
-#define CALL_WaitSync(disp, parameters) (*((disp)->WaitSync)) parameters
-#define GET_WaitSync(disp) ((disp)->WaitSync)
-#define SET_WaitSync(disp, fn) ((disp)->WaitSync = fn)
-#define CALL_DrawElementsBaseVertex(disp, parameters) (*((disp)->DrawElementsBaseVertex)) parameters
-#define GET_DrawElementsBaseVertex(disp) ((disp)->DrawElementsBaseVertex)
-#define SET_DrawElementsBaseVertex(disp, fn) ((disp)->DrawElementsBaseVertex = fn)
-#define CALL_DrawRangeElementsBaseVertex(disp, parameters) (*((disp)->DrawRangeElementsBaseVertex)) parameters
-#define GET_DrawRangeElementsBaseVertex(disp) ((disp)->DrawRangeElementsBaseVertex)
-#define SET_DrawRangeElementsBaseVertex(disp, fn) ((disp)->DrawRangeElementsBaseVertex = fn)
-#define CALL_MultiDrawElementsBaseVertex(disp, parameters) (*((disp)->MultiDrawElementsBaseVertex)) parameters
-#define GET_MultiDrawElementsBaseVertex(disp) ((disp)->MultiDrawElementsBaseVertex)
-#define SET_MultiDrawElementsBaseVertex(disp, fn) ((disp)->MultiDrawElementsBaseVertex = fn)
-#define CALL_PolygonOffsetEXT(disp, parameters) (*((disp)->PolygonOffsetEXT)) parameters
-#define GET_PolygonOffsetEXT(disp) ((disp)->PolygonOffsetEXT)
-#define SET_PolygonOffsetEXT(disp, fn) ((disp)->PolygonOffsetEXT = fn)
-#define CALL_GetPixelTexGenParameterfvSGIS(disp, parameters) (*((disp)->GetPixelTexGenParameterfvSGIS)) parameters
-#define GET_GetPixelTexGenParameterfvSGIS(disp) ((disp)->GetPixelTexGenParameterfvSGIS)
-#define SET_GetPixelTexGenParameterfvSGIS(disp, fn) ((disp)->GetPixelTexGenParameterfvSGIS = fn)
-#define CALL_GetPixelTexGenParameterivSGIS(disp, parameters) (*((disp)->GetPixelTexGenParameterivSGIS)) parameters
-#define GET_GetPixelTexGenParameterivSGIS(disp) ((disp)->GetPixelTexGenParameterivSGIS)
-#define SET_GetPixelTexGenParameterivSGIS(disp, fn) ((disp)->GetPixelTexGenParameterivSGIS = fn)
-#define CALL_PixelTexGenParameterfSGIS(disp, parameters) (*((disp)->PixelTexGenParameterfSGIS)) parameters
-#define GET_PixelTexGenParameterfSGIS(disp) ((disp)->PixelTexGenParameterfSGIS)
-#define SET_PixelTexGenParameterfSGIS(disp, fn) ((disp)->PixelTexGenParameterfSGIS = fn)
-#define CALL_PixelTexGenParameterfvSGIS(disp, parameters) (*((disp)->PixelTexGenParameterfvSGIS)) parameters
-#define GET_PixelTexGenParameterfvSGIS(disp) ((disp)->PixelTexGenParameterfvSGIS)
-#define SET_PixelTexGenParameterfvSGIS(disp, fn) ((disp)->PixelTexGenParameterfvSGIS = fn)
-#define CALL_PixelTexGenParameteriSGIS(disp, parameters) (*((disp)->PixelTexGenParameteriSGIS)) parameters
-#define GET_PixelTexGenParameteriSGIS(disp) ((disp)->PixelTexGenParameteriSGIS)
-#define SET_PixelTexGenParameteriSGIS(disp, fn) ((disp)->PixelTexGenParameteriSGIS = fn)
-#define CALL_PixelTexGenParameterivSGIS(disp, parameters) (*((disp)->PixelTexGenParameterivSGIS)) parameters
-#define GET_PixelTexGenParameterivSGIS(disp) ((disp)->PixelTexGenParameterivSGIS)
-#define SET_PixelTexGenParameterivSGIS(disp, fn) ((disp)->PixelTexGenParameterivSGIS = fn)
-#define CALL_SampleMaskSGIS(disp, parameters) (*((disp)->SampleMaskSGIS)) parameters
-#define GET_SampleMaskSGIS(disp) ((disp)->SampleMaskSGIS)
-#define SET_SampleMaskSGIS(disp, fn) ((disp)->SampleMaskSGIS = fn)
-#define CALL_SamplePatternSGIS(disp, parameters) (*((disp)->SamplePatternSGIS)) parameters
-#define GET_SamplePatternSGIS(disp) ((disp)->SamplePatternSGIS)
-#define SET_SamplePatternSGIS(disp, fn) ((disp)->SamplePatternSGIS = fn)
-#define CALL_ColorPointerEXT(disp, parameters) (*((disp)->ColorPointerEXT)) parameters
-#define GET_ColorPointerEXT(disp) ((disp)->ColorPointerEXT)
-#define SET_ColorPointerEXT(disp, fn) ((disp)->ColorPointerEXT = fn)
-#define CALL_EdgeFlagPointerEXT(disp, parameters) (*((disp)->EdgeFlagPointerEXT)) parameters
-#define GET_EdgeFlagPointerEXT(disp) ((disp)->EdgeFlagPointerEXT)
-#define SET_EdgeFlagPointerEXT(disp, fn) ((disp)->EdgeFlagPointerEXT = fn)
-#define CALL_IndexPointerEXT(disp, parameters) (*((disp)->IndexPointerEXT)) parameters
-#define GET_IndexPointerEXT(disp) ((disp)->IndexPointerEXT)
-#define SET_IndexPointerEXT(disp, fn) ((disp)->IndexPointerEXT = fn)
-#define CALL_NormalPointerEXT(disp, parameters) (*((disp)->NormalPointerEXT)) parameters
-#define GET_NormalPointerEXT(disp) ((disp)->NormalPointerEXT)
-#define SET_NormalPointerEXT(disp, fn) ((disp)->NormalPointerEXT = fn)
-#define CALL_TexCoordPointerEXT(disp, parameters) (*((disp)->TexCoordPointerEXT)) parameters
-#define GET_TexCoordPointerEXT(disp) ((disp)->TexCoordPointerEXT)
-#define SET_TexCoordPointerEXT(disp, fn) ((disp)->TexCoordPointerEXT = fn)
-#define CALL_VertexPointerEXT(disp, parameters) (*((disp)->VertexPointerEXT)) parameters
-#define GET_VertexPointerEXT(disp) ((disp)->VertexPointerEXT)
-#define SET_VertexPointerEXT(disp, fn) ((disp)->VertexPointerEXT = fn)
-#define CALL_PointParameterfEXT(disp, parameters) (*((disp)->PointParameterfEXT)) parameters
-#define GET_PointParameterfEXT(disp) ((disp)->PointParameterfEXT)
-#define SET_PointParameterfEXT(disp, fn) ((disp)->PointParameterfEXT = fn)
-#define CALL_PointParameterfvEXT(disp, parameters) (*((disp)->PointParameterfvEXT)) parameters
-#define GET_PointParameterfvEXT(disp) ((disp)->PointParameterfvEXT)
-#define SET_PointParameterfvEXT(disp, fn) ((disp)->PointParameterfvEXT = fn)
-#define CALL_LockArraysEXT(disp, parameters) (*((disp)->LockArraysEXT)) parameters
-#define GET_LockArraysEXT(disp) ((disp)->LockArraysEXT)
-#define SET_LockArraysEXT(disp, fn) ((disp)->LockArraysEXT = fn)
-#define CALL_UnlockArraysEXT(disp, parameters) (*((disp)->UnlockArraysEXT)) parameters
-#define GET_UnlockArraysEXT(disp) ((disp)->UnlockArraysEXT)
-#define SET_UnlockArraysEXT(disp, fn) ((disp)->UnlockArraysEXT = fn)
-#define CALL_CullParameterdvEXT(disp, parameters) (*((disp)->CullParameterdvEXT)) parameters
-#define GET_CullParameterdvEXT(disp) ((disp)->CullParameterdvEXT)
-#define SET_CullParameterdvEXT(disp, fn) ((disp)->CullParameterdvEXT = fn)
-#define CALL_CullParameterfvEXT(disp, parameters) (*((disp)->CullParameterfvEXT)) parameters
-#define GET_CullParameterfvEXT(disp) ((disp)->CullParameterfvEXT)
-#define SET_CullParameterfvEXT(disp, fn) ((disp)->CullParameterfvEXT = fn)
-#define CALL_SecondaryColor3bEXT(disp, parameters) (*((disp)->SecondaryColor3bEXT)) parameters
-#define GET_SecondaryColor3bEXT(disp) ((disp)->SecondaryColor3bEXT)
-#define SET_SecondaryColor3bEXT(disp, fn) ((disp)->SecondaryColor3bEXT = fn)
-#define CALL_SecondaryColor3bvEXT(disp, parameters) (*((disp)->SecondaryColor3bvEXT)) parameters
-#define GET_SecondaryColor3bvEXT(disp) ((disp)->SecondaryColor3bvEXT)
-#define SET_SecondaryColor3bvEXT(disp, fn) ((disp)->SecondaryColor3bvEXT = fn)
-#define CALL_SecondaryColor3dEXT(disp, parameters) (*((disp)->SecondaryColor3dEXT)) parameters
-#define GET_SecondaryColor3dEXT(disp) ((disp)->SecondaryColor3dEXT)
-#define SET_SecondaryColor3dEXT(disp, fn) ((disp)->SecondaryColor3dEXT = fn)
-#define CALL_SecondaryColor3dvEXT(disp, parameters) (*((disp)->SecondaryColor3dvEXT)) parameters
-#define GET_SecondaryColor3dvEXT(disp) ((disp)->SecondaryColor3dvEXT)
-#define SET_SecondaryColor3dvEXT(disp, fn) ((disp)->SecondaryColor3dvEXT = fn)
-#define CALL_SecondaryColor3fEXT(disp, parameters) (*((disp)->SecondaryColor3fEXT)) parameters
-#define GET_SecondaryColor3fEXT(disp) ((disp)->SecondaryColor3fEXT)
-#define SET_SecondaryColor3fEXT(disp, fn) ((disp)->SecondaryColor3fEXT = fn)
-#define CALL_SecondaryColor3fvEXT(disp, parameters) (*((disp)->SecondaryColor3fvEXT)) parameters
-#define GET_SecondaryColor3fvEXT(disp) ((disp)->SecondaryColor3fvEXT)
-#define SET_SecondaryColor3fvEXT(disp, fn) ((disp)->SecondaryColor3fvEXT = fn)
-#define CALL_SecondaryColor3iEXT(disp, parameters) (*((disp)->SecondaryColor3iEXT)) parameters
-#define GET_SecondaryColor3iEXT(disp) ((disp)->SecondaryColor3iEXT)
-#define SET_SecondaryColor3iEXT(disp, fn) ((disp)->SecondaryColor3iEXT = fn)
-#define CALL_SecondaryColor3ivEXT(disp, parameters) (*((disp)->SecondaryColor3ivEXT)) parameters
-#define GET_SecondaryColor3ivEXT(disp) ((disp)->SecondaryColor3ivEXT)
-#define SET_SecondaryColor3ivEXT(disp, fn) ((disp)->SecondaryColor3ivEXT = fn)
-#define CALL_SecondaryColor3sEXT(disp, parameters) (*((disp)->SecondaryColor3sEXT)) parameters
-#define GET_SecondaryColor3sEXT(disp) ((disp)->SecondaryColor3sEXT)
-#define SET_SecondaryColor3sEXT(disp, fn) ((disp)->SecondaryColor3sEXT = fn)
-#define CALL_SecondaryColor3svEXT(disp, parameters) (*((disp)->SecondaryColor3svEXT)) parameters
-#define GET_SecondaryColor3svEXT(disp) ((disp)->SecondaryColor3svEXT)
-#define SET_SecondaryColor3svEXT(disp, fn) ((disp)->SecondaryColor3svEXT = fn)
-#define CALL_SecondaryColor3ubEXT(disp, parameters) (*((disp)->SecondaryColor3ubEXT)) parameters
-#define GET_SecondaryColor3ubEXT(disp) ((disp)->SecondaryColor3ubEXT)
-#define SET_SecondaryColor3ubEXT(disp, fn) ((disp)->SecondaryColor3ubEXT = fn)
-#define CALL_SecondaryColor3ubvEXT(disp, parameters) (*((disp)->SecondaryColor3ubvEXT)) parameters
-#define GET_SecondaryColor3ubvEXT(disp) ((disp)->SecondaryColor3ubvEXT)
-#define SET_SecondaryColor3ubvEXT(disp, fn) ((disp)->SecondaryColor3ubvEXT = fn)
-#define CALL_SecondaryColor3uiEXT(disp, parameters) (*((disp)->SecondaryColor3uiEXT)) parameters
-#define GET_SecondaryColor3uiEXT(disp) ((disp)->SecondaryColor3uiEXT)
-#define SET_SecondaryColor3uiEXT(disp, fn) ((disp)->SecondaryColor3uiEXT = fn)
-#define CALL_SecondaryColor3uivEXT(disp, parameters) (*((disp)->SecondaryColor3uivEXT)) parameters
-#define GET_SecondaryColor3uivEXT(disp) ((disp)->SecondaryColor3uivEXT)
-#define SET_SecondaryColor3uivEXT(disp, fn) ((disp)->SecondaryColor3uivEXT = fn)
-#define CALL_SecondaryColor3usEXT(disp, parameters) (*((disp)->SecondaryColor3usEXT)) parameters
-#define GET_SecondaryColor3usEXT(disp) ((disp)->SecondaryColor3usEXT)
-#define SET_SecondaryColor3usEXT(disp, fn) ((disp)->SecondaryColor3usEXT = fn)
-#define CALL_SecondaryColor3usvEXT(disp, parameters) (*((disp)->SecondaryColor3usvEXT)) parameters
-#define GET_SecondaryColor3usvEXT(disp) ((disp)->SecondaryColor3usvEXT)
-#define SET_SecondaryColor3usvEXT(disp, fn) ((disp)->SecondaryColor3usvEXT = fn)
-#define CALL_SecondaryColorPointerEXT(disp, parameters) (*((disp)->SecondaryColorPointerEXT)) parameters
-#define GET_SecondaryColorPointerEXT(disp) ((disp)->SecondaryColorPointerEXT)
-#define SET_SecondaryColorPointerEXT(disp, fn) ((disp)->SecondaryColorPointerEXT = fn)
-#define CALL_MultiDrawArraysEXT(disp, parameters) (*((disp)->MultiDrawArraysEXT)) parameters
-#define GET_MultiDrawArraysEXT(disp) ((disp)->MultiDrawArraysEXT)
-#define SET_MultiDrawArraysEXT(disp, fn) ((disp)->MultiDrawArraysEXT = fn)
-#define CALL_MultiDrawElementsEXT(disp, parameters) (*((disp)->MultiDrawElementsEXT)) parameters
-#define GET_MultiDrawElementsEXT(disp) ((disp)->MultiDrawElementsEXT)
-#define SET_MultiDrawElementsEXT(disp, fn) ((disp)->MultiDrawElementsEXT = fn)
-#define CALL_FogCoordPointerEXT(disp, parameters) (*((disp)->FogCoordPointerEXT)) parameters
-#define GET_FogCoordPointerEXT(disp) ((disp)->FogCoordPointerEXT)
-#define SET_FogCoordPointerEXT(disp, fn) ((disp)->FogCoordPointerEXT = fn)
-#define CALL_FogCoorddEXT(disp, parameters) (*((disp)->FogCoorddEXT)) parameters
-#define GET_FogCoorddEXT(disp) ((disp)->FogCoorddEXT)
-#define SET_FogCoorddEXT(disp, fn) ((disp)->FogCoorddEXT = fn)
-#define CALL_FogCoorddvEXT(disp, parameters) (*((disp)->FogCoorddvEXT)) parameters
-#define GET_FogCoorddvEXT(disp) ((disp)->FogCoorddvEXT)
-#define SET_FogCoorddvEXT(disp, fn) ((disp)->FogCoorddvEXT = fn)
-#define CALL_FogCoordfEXT(disp, parameters) (*((disp)->FogCoordfEXT)) parameters
-#define GET_FogCoordfEXT(disp) ((disp)->FogCoordfEXT)
-#define SET_FogCoordfEXT(disp, fn) ((disp)->FogCoordfEXT = fn)
-#define CALL_FogCoordfvEXT(disp, parameters) (*((disp)->FogCoordfvEXT)) parameters
-#define GET_FogCoordfvEXT(disp) ((disp)->FogCoordfvEXT)
-#define SET_FogCoordfvEXT(disp, fn) ((disp)->FogCoordfvEXT = fn)
-#define CALL_PixelTexGenSGIX(disp, parameters) (*((disp)->PixelTexGenSGIX)) parameters
-#define GET_PixelTexGenSGIX(disp) ((disp)->PixelTexGenSGIX)
-#define SET_PixelTexGenSGIX(disp, fn) ((disp)->PixelTexGenSGIX = fn)
-#define CALL_BlendFuncSeparateEXT(disp, parameters) (*((disp)->BlendFuncSeparateEXT)) parameters
-#define GET_BlendFuncSeparateEXT(disp) ((disp)->BlendFuncSeparateEXT)
-#define SET_BlendFuncSeparateEXT(disp, fn) ((disp)->BlendFuncSeparateEXT = fn)
-#define CALL_FlushVertexArrayRangeNV(disp, parameters) (*((disp)->FlushVertexArrayRangeNV)) parameters
-#define GET_FlushVertexArrayRangeNV(disp) ((disp)->FlushVertexArrayRangeNV)
-#define SET_FlushVertexArrayRangeNV(disp, fn) ((disp)->FlushVertexArrayRangeNV = fn)
-#define CALL_VertexArrayRangeNV(disp, parameters) (*((disp)->VertexArrayRangeNV)) parameters
-#define GET_VertexArrayRangeNV(disp) ((disp)->VertexArrayRangeNV)
-#define SET_VertexArrayRangeNV(disp, fn) ((disp)->VertexArrayRangeNV = fn)
-#define CALL_CombinerInputNV(disp, parameters) (*((disp)->CombinerInputNV)) parameters
-#define GET_CombinerInputNV(disp) ((disp)->CombinerInputNV)
-#define SET_CombinerInputNV(disp, fn) ((disp)->CombinerInputNV = fn)
-#define CALL_CombinerOutputNV(disp, parameters) (*((disp)->CombinerOutputNV)) parameters
-#define GET_CombinerOutputNV(disp) ((disp)->CombinerOutputNV)
-#define SET_CombinerOutputNV(disp, fn) ((disp)->CombinerOutputNV = fn)
-#define CALL_CombinerParameterfNV(disp, parameters) (*((disp)->CombinerParameterfNV)) parameters
-#define GET_CombinerParameterfNV(disp) ((disp)->CombinerParameterfNV)
-#define SET_CombinerParameterfNV(disp, fn) ((disp)->CombinerParameterfNV = fn)
-#define CALL_CombinerParameterfvNV(disp, parameters) (*((disp)->CombinerParameterfvNV)) parameters
-#define GET_CombinerParameterfvNV(disp) ((disp)->CombinerParameterfvNV)
-#define SET_CombinerParameterfvNV(disp, fn) ((disp)->CombinerParameterfvNV = fn)
-#define CALL_CombinerParameteriNV(disp, parameters) (*((disp)->CombinerParameteriNV)) parameters
-#define GET_CombinerParameteriNV(disp) ((disp)->CombinerParameteriNV)
-#define SET_CombinerParameteriNV(disp, fn) ((disp)->CombinerParameteriNV = fn)
-#define CALL_CombinerParameterivNV(disp, parameters) (*((disp)->CombinerParameterivNV)) parameters
-#define GET_CombinerParameterivNV(disp) ((disp)->CombinerParameterivNV)
-#define SET_CombinerParameterivNV(disp, fn) ((disp)->CombinerParameterivNV = fn)
-#define CALL_FinalCombinerInputNV(disp, parameters) (*((disp)->FinalCombinerInputNV)) parameters
-#define GET_FinalCombinerInputNV(disp) ((disp)->FinalCombinerInputNV)
-#define SET_FinalCombinerInputNV(disp, fn) ((disp)->FinalCombinerInputNV = fn)
-#define CALL_GetCombinerInputParameterfvNV(disp, parameters) (*((disp)->GetCombinerInputParameterfvNV)) parameters
-#define GET_GetCombinerInputParameterfvNV(disp) ((disp)->GetCombinerInputParameterfvNV)
-#define SET_GetCombinerInputParameterfvNV(disp, fn) ((disp)->GetCombinerInputParameterfvNV = fn)
-#define CALL_GetCombinerInputParameterivNV(disp, parameters) (*((disp)->GetCombinerInputParameterivNV)) parameters
-#define GET_GetCombinerInputParameterivNV(disp) ((disp)->GetCombinerInputParameterivNV)
-#define SET_GetCombinerInputParameterivNV(disp, fn) ((disp)->GetCombinerInputParameterivNV = fn)
-#define CALL_GetCombinerOutputParameterfvNV(disp, parameters) (*((disp)->GetCombinerOutputParameterfvNV)) parameters
-#define GET_GetCombinerOutputParameterfvNV(disp) ((disp)->GetCombinerOutputParameterfvNV)
-#define SET_GetCombinerOutputParameterfvNV(disp, fn) ((disp)->GetCombinerOutputParameterfvNV = fn)
-#define CALL_GetCombinerOutputParameterivNV(disp, parameters) (*((disp)->GetCombinerOutputParameterivNV)) parameters
-#define GET_GetCombinerOutputParameterivNV(disp) ((disp)->GetCombinerOutputParameterivNV)
-#define SET_GetCombinerOutputParameterivNV(disp, fn) ((disp)->GetCombinerOutputParameterivNV = fn)
-#define CALL_GetFinalCombinerInputParameterfvNV(disp, parameters) (*((disp)->GetFinalCombinerInputParameterfvNV)) parameters
-#define GET_GetFinalCombinerInputParameterfvNV(disp) ((disp)->GetFinalCombinerInputParameterfvNV)
-#define SET_GetFinalCombinerInputParameterfvNV(disp, fn) ((disp)->GetFinalCombinerInputParameterfvNV = fn)
-#define CALL_GetFinalCombinerInputParameterivNV(disp, parameters) (*((disp)->GetFinalCombinerInputParameterivNV)) parameters
-#define GET_GetFinalCombinerInputParameterivNV(disp) ((disp)->GetFinalCombinerInputParameterivNV)
-#define SET_GetFinalCombinerInputParameterivNV(disp, fn) ((disp)->GetFinalCombinerInputParameterivNV = fn)
-#define CALL_ResizeBuffersMESA(disp, parameters) (*((disp)->ResizeBuffersMESA)) parameters
-#define GET_ResizeBuffersMESA(disp) ((disp)->ResizeBuffersMESA)
-#define SET_ResizeBuffersMESA(disp, fn) ((disp)->ResizeBuffersMESA = fn)
-#define CALL_WindowPos2dMESA(disp, parameters) (*((disp)->WindowPos2dMESA)) parameters
-#define GET_WindowPos2dMESA(disp) ((disp)->WindowPos2dMESA)
-#define SET_WindowPos2dMESA(disp, fn) ((disp)->WindowPos2dMESA = fn)
-#define CALL_WindowPos2dvMESA(disp, parameters) (*((disp)->WindowPos2dvMESA)) parameters
-#define GET_WindowPos2dvMESA(disp) ((disp)->WindowPos2dvMESA)
-#define SET_WindowPos2dvMESA(disp, fn) ((disp)->WindowPos2dvMESA = fn)
-#define CALL_WindowPos2fMESA(disp, parameters) (*((disp)->WindowPos2fMESA)) parameters
-#define GET_WindowPos2fMESA(disp) ((disp)->WindowPos2fMESA)
-#define SET_WindowPos2fMESA(disp, fn) ((disp)->WindowPos2fMESA = fn)
-#define CALL_WindowPos2fvMESA(disp, parameters) (*((disp)->WindowPos2fvMESA)) parameters
-#define GET_WindowPos2fvMESA(disp) ((disp)->WindowPos2fvMESA)
-#define SET_WindowPos2fvMESA(disp, fn) ((disp)->WindowPos2fvMESA = fn)
-#define CALL_WindowPos2iMESA(disp, parameters) (*((disp)->WindowPos2iMESA)) parameters
-#define GET_WindowPos2iMESA(disp) ((disp)->WindowPos2iMESA)
-#define SET_WindowPos2iMESA(disp, fn) ((disp)->WindowPos2iMESA = fn)
-#define CALL_WindowPos2ivMESA(disp, parameters) (*((disp)->WindowPos2ivMESA)) parameters
-#define GET_WindowPos2ivMESA(disp) ((disp)->WindowPos2ivMESA)
-#define SET_WindowPos2ivMESA(disp, fn) ((disp)->WindowPos2ivMESA = fn)
-#define CALL_WindowPos2sMESA(disp, parameters) (*((disp)->WindowPos2sMESA)) parameters
-#define GET_WindowPos2sMESA(disp) ((disp)->WindowPos2sMESA)
-#define SET_WindowPos2sMESA(disp, fn) ((disp)->WindowPos2sMESA = fn)
-#define CALL_WindowPos2svMESA(disp, parameters) (*((disp)->WindowPos2svMESA)) parameters
-#define GET_WindowPos2svMESA(disp) ((disp)->WindowPos2svMESA)
-#define SET_WindowPos2svMESA(disp, fn) ((disp)->WindowPos2svMESA = fn)
-#define CALL_WindowPos3dMESA(disp, parameters) (*((disp)->WindowPos3dMESA)) parameters
-#define GET_WindowPos3dMESA(disp) ((disp)->WindowPos3dMESA)
-#define SET_WindowPos3dMESA(disp, fn) ((disp)->WindowPos3dMESA = fn)
-#define CALL_WindowPos3dvMESA(disp, parameters) (*((disp)->WindowPos3dvMESA)) parameters
-#define GET_WindowPos3dvMESA(disp) ((disp)->WindowPos3dvMESA)
-#define SET_WindowPos3dvMESA(disp, fn) ((disp)->WindowPos3dvMESA = fn)
-#define CALL_WindowPos3fMESA(disp, parameters) (*((disp)->WindowPos3fMESA)) parameters
-#define GET_WindowPos3fMESA(disp) ((disp)->WindowPos3fMESA)
-#define SET_WindowPos3fMESA(disp, fn) ((disp)->WindowPos3fMESA = fn)
-#define CALL_WindowPos3fvMESA(disp, parameters) (*((disp)->WindowPos3fvMESA)) parameters
-#define GET_WindowPos3fvMESA(disp) ((disp)->WindowPos3fvMESA)
-#define SET_WindowPos3fvMESA(disp, fn) ((disp)->WindowPos3fvMESA = fn)
-#define CALL_WindowPos3iMESA(disp, parameters) (*((disp)->WindowPos3iMESA)) parameters
-#define GET_WindowPos3iMESA(disp) ((disp)->WindowPos3iMESA)
-#define SET_WindowPos3iMESA(disp, fn) ((disp)->WindowPos3iMESA = fn)
-#define CALL_WindowPos3ivMESA(disp, parameters) (*((disp)->WindowPos3ivMESA)) parameters
-#define GET_WindowPos3ivMESA(disp) ((disp)->WindowPos3ivMESA)
-#define SET_WindowPos3ivMESA(disp, fn) ((disp)->WindowPos3ivMESA = fn)
-#define CALL_WindowPos3sMESA(disp, parameters) (*((disp)->WindowPos3sMESA)) parameters
-#define GET_WindowPos3sMESA(disp) ((disp)->WindowPos3sMESA)
-#define SET_WindowPos3sMESA(disp, fn) ((disp)->WindowPos3sMESA = fn)
-#define CALL_WindowPos3svMESA(disp, parameters) (*((disp)->WindowPos3svMESA)) parameters
-#define GET_WindowPos3svMESA(disp) ((disp)->WindowPos3svMESA)
-#define SET_WindowPos3svMESA(disp, fn) ((disp)->WindowPos3svMESA = fn)
-#define CALL_WindowPos4dMESA(disp, parameters) (*((disp)->WindowPos4dMESA)) parameters
-#define GET_WindowPos4dMESA(disp) ((disp)->WindowPos4dMESA)
-#define SET_WindowPos4dMESA(disp, fn) ((disp)->WindowPos4dMESA = fn)
-#define CALL_WindowPos4dvMESA(disp, parameters) (*((disp)->WindowPos4dvMESA)) parameters
-#define GET_WindowPos4dvMESA(disp) ((disp)->WindowPos4dvMESA)
-#define SET_WindowPos4dvMESA(disp, fn) ((disp)->WindowPos4dvMESA = fn)
-#define CALL_WindowPos4fMESA(disp, parameters) (*((disp)->WindowPos4fMESA)) parameters
-#define GET_WindowPos4fMESA(disp) ((disp)->WindowPos4fMESA)
-#define SET_WindowPos4fMESA(disp, fn) ((disp)->WindowPos4fMESA = fn)
-#define CALL_WindowPos4fvMESA(disp, parameters) (*((disp)->WindowPos4fvMESA)) parameters
-#define GET_WindowPos4fvMESA(disp) ((disp)->WindowPos4fvMESA)
-#define SET_WindowPos4fvMESA(disp, fn) ((disp)->WindowPos4fvMESA = fn)
-#define CALL_WindowPos4iMESA(disp, parameters) (*((disp)->WindowPos4iMESA)) parameters
-#define GET_WindowPos4iMESA(disp) ((disp)->WindowPos4iMESA)
-#define SET_WindowPos4iMESA(disp, fn) ((disp)->WindowPos4iMESA = fn)
-#define CALL_WindowPos4ivMESA(disp, parameters) (*((disp)->WindowPos4ivMESA)) parameters
-#define GET_WindowPos4ivMESA(disp) ((disp)->WindowPos4ivMESA)
-#define SET_WindowPos4ivMESA(disp, fn) ((disp)->WindowPos4ivMESA = fn)
-#define CALL_WindowPos4sMESA(disp, parameters) (*((disp)->WindowPos4sMESA)) parameters
-#define GET_WindowPos4sMESA(disp) ((disp)->WindowPos4sMESA)
-#define SET_WindowPos4sMESA(disp, fn) ((disp)->WindowPos4sMESA = fn)
-#define CALL_WindowPos4svMESA(disp, parameters) (*((disp)->WindowPos4svMESA)) parameters
-#define GET_WindowPos4svMESA(disp) ((disp)->WindowPos4svMESA)
-#define SET_WindowPos4svMESA(disp, fn) ((disp)->WindowPos4svMESA = fn)
-#define CALL_MultiModeDrawArraysIBM(disp, parameters) (*((disp)->MultiModeDrawArraysIBM)) parameters
-#define GET_MultiModeDrawArraysIBM(disp) ((disp)->MultiModeDrawArraysIBM)
-#define SET_MultiModeDrawArraysIBM(disp, fn) ((disp)->MultiModeDrawArraysIBM = fn)
-#define CALL_MultiModeDrawElementsIBM(disp, parameters) (*((disp)->MultiModeDrawElementsIBM)) parameters
-#define GET_MultiModeDrawElementsIBM(disp) ((disp)->MultiModeDrawElementsIBM)
-#define SET_MultiModeDrawElementsIBM(disp, fn) ((disp)->MultiModeDrawElementsIBM = fn)
-#define CALL_DeleteFencesNV(disp, parameters) (*((disp)->DeleteFencesNV)) parameters
-#define GET_DeleteFencesNV(disp) ((disp)->DeleteFencesNV)
-#define SET_DeleteFencesNV(disp, fn) ((disp)->DeleteFencesNV = fn)
-#define CALL_FinishFenceNV(disp, parameters) (*((disp)->FinishFenceNV)) parameters
-#define GET_FinishFenceNV(disp) ((disp)->FinishFenceNV)
-#define SET_FinishFenceNV(disp, fn) ((disp)->FinishFenceNV = fn)
-#define CALL_GenFencesNV(disp, parameters) (*((disp)->GenFencesNV)) parameters
-#define GET_GenFencesNV(disp) ((disp)->GenFencesNV)
-#define SET_GenFencesNV(disp, fn) ((disp)->GenFencesNV = fn)
-#define CALL_GetFenceivNV(disp, parameters) (*((disp)->GetFenceivNV)) parameters
-#define GET_GetFenceivNV(disp) ((disp)->GetFenceivNV)
-#define SET_GetFenceivNV(disp, fn) ((disp)->GetFenceivNV = fn)
-#define CALL_IsFenceNV(disp, parameters) (*((disp)->IsFenceNV)) parameters
-#define GET_IsFenceNV(disp) ((disp)->IsFenceNV)
-#define SET_IsFenceNV(disp, fn) ((disp)->IsFenceNV = fn)
-#define CALL_SetFenceNV(disp, parameters) (*((disp)->SetFenceNV)) parameters
-#define GET_SetFenceNV(disp) ((disp)->SetFenceNV)
-#define SET_SetFenceNV(disp, fn) ((disp)->SetFenceNV = fn)
-#define CALL_TestFenceNV(disp, parameters) (*((disp)->TestFenceNV)) parameters
-#define GET_TestFenceNV(disp) ((disp)->TestFenceNV)
-#define SET_TestFenceNV(disp, fn) ((disp)->TestFenceNV = fn)
-#define CALL_AreProgramsResidentNV(disp, parameters) (*((disp)->AreProgramsResidentNV)) parameters
-#define GET_AreProgramsResidentNV(disp) ((disp)->AreProgramsResidentNV)
-#define SET_AreProgramsResidentNV(disp, fn) ((disp)->AreProgramsResidentNV = fn)
-#define CALL_BindProgramNV(disp, parameters) (*((disp)->BindProgramNV)) parameters
-#define GET_BindProgramNV(disp) ((disp)->BindProgramNV)
-#define SET_BindProgramNV(disp, fn) ((disp)->BindProgramNV = fn)
-#define CALL_DeleteProgramsNV(disp, parameters) (*((disp)->DeleteProgramsNV)) parameters
-#define GET_DeleteProgramsNV(disp) ((disp)->DeleteProgramsNV)
-#define SET_DeleteProgramsNV(disp, fn) ((disp)->DeleteProgramsNV = fn)
-#define CALL_ExecuteProgramNV(disp, parameters) (*((disp)->ExecuteProgramNV)) parameters
-#define GET_ExecuteProgramNV(disp) ((disp)->ExecuteProgramNV)
-#define SET_ExecuteProgramNV(disp, fn) ((disp)->ExecuteProgramNV = fn)
-#define CALL_GenProgramsNV(disp, parameters) (*((disp)->GenProgramsNV)) parameters
-#define GET_GenProgramsNV(disp) ((disp)->GenProgramsNV)
-#define SET_GenProgramsNV(disp, fn) ((disp)->GenProgramsNV = fn)
-#define CALL_GetProgramParameterdvNV(disp, parameters) (*((disp)->GetProgramParameterdvNV)) parameters
-#define GET_GetProgramParameterdvNV(disp) ((disp)->GetProgramParameterdvNV)
-#define SET_GetProgramParameterdvNV(disp, fn) ((disp)->GetProgramParameterdvNV = fn)
-#define CALL_GetProgramParameterfvNV(disp, parameters) (*((disp)->GetProgramParameterfvNV)) parameters
-#define GET_GetProgramParameterfvNV(disp) ((disp)->GetProgramParameterfvNV)
-#define SET_GetProgramParameterfvNV(disp, fn) ((disp)->GetProgramParameterfvNV = fn)
-#define CALL_GetProgramStringNV(disp, parameters) (*((disp)->GetProgramStringNV)) parameters
-#define GET_GetProgramStringNV(disp) ((disp)->GetProgramStringNV)
-#define SET_GetProgramStringNV(disp, fn) ((disp)->GetProgramStringNV = fn)
-#define CALL_GetProgramivNV(disp, parameters) (*((disp)->GetProgramivNV)) parameters
-#define GET_GetProgramivNV(disp) ((disp)->GetProgramivNV)
-#define SET_GetProgramivNV(disp, fn) ((disp)->GetProgramivNV = fn)
-#define CALL_GetTrackMatrixivNV(disp, parameters) (*((disp)->GetTrackMatrixivNV)) parameters
-#define GET_GetTrackMatrixivNV(disp) ((disp)->GetTrackMatrixivNV)
-#define SET_GetTrackMatrixivNV(disp, fn) ((disp)->GetTrackMatrixivNV = fn)
-#define CALL_GetVertexAttribPointervNV(disp, parameters) (*((disp)->GetVertexAttribPointervNV)) parameters
-#define GET_GetVertexAttribPointervNV(disp) ((disp)->GetVertexAttribPointervNV)
-#define SET_GetVertexAttribPointervNV(disp, fn) ((disp)->GetVertexAttribPointervNV = fn)
-#define CALL_GetVertexAttribdvNV(disp, parameters) (*((disp)->GetVertexAttribdvNV)) parameters
-#define GET_GetVertexAttribdvNV(disp) ((disp)->GetVertexAttribdvNV)
-#define SET_GetVertexAttribdvNV(disp, fn) ((disp)->GetVertexAttribdvNV = fn)
-#define CALL_GetVertexAttribfvNV(disp, parameters) (*((disp)->GetVertexAttribfvNV)) parameters
-#define GET_GetVertexAttribfvNV(disp) ((disp)->GetVertexAttribfvNV)
-#define SET_GetVertexAttribfvNV(disp, fn) ((disp)->GetVertexAttribfvNV = fn)
-#define CALL_GetVertexAttribivNV(disp, parameters) (*((disp)->GetVertexAttribivNV)) parameters
-#define GET_GetVertexAttribivNV(disp) ((disp)->GetVertexAttribivNV)
-#define SET_GetVertexAttribivNV(disp, fn) ((disp)->GetVertexAttribivNV = fn)
-#define CALL_IsProgramNV(disp, parameters) (*((disp)->IsProgramNV)) parameters
-#define GET_IsProgramNV(disp) ((disp)->IsProgramNV)
-#define SET_IsProgramNV(disp, fn) ((disp)->IsProgramNV = fn)
-#define CALL_LoadProgramNV(disp, parameters) (*((disp)->LoadProgramNV)) parameters
-#define GET_LoadProgramNV(disp) ((disp)->LoadProgramNV)
-#define SET_LoadProgramNV(disp, fn) ((disp)->LoadProgramNV = fn)
-#define CALL_ProgramParameters4dvNV(disp, parameters) (*((disp)->ProgramParameters4dvNV)) parameters
-#define GET_ProgramParameters4dvNV(disp) ((disp)->ProgramParameters4dvNV)
-#define SET_ProgramParameters4dvNV(disp, fn) ((disp)->ProgramParameters4dvNV = fn)
-#define CALL_ProgramParameters4fvNV(disp, parameters) (*((disp)->ProgramParameters4fvNV)) parameters
-#define GET_ProgramParameters4fvNV(disp) ((disp)->ProgramParameters4fvNV)
-#define SET_ProgramParameters4fvNV(disp, fn) ((disp)->ProgramParameters4fvNV = fn)
-#define CALL_RequestResidentProgramsNV(disp, parameters) (*((disp)->RequestResidentProgramsNV)) parameters
-#define GET_RequestResidentProgramsNV(disp) ((disp)->RequestResidentProgramsNV)
-#define SET_RequestResidentProgramsNV(disp, fn) ((disp)->RequestResidentProgramsNV = fn)
-#define CALL_TrackMatrixNV(disp, parameters) (*((disp)->TrackMatrixNV)) parameters
-#define GET_TrackMatrixNV(disp) ((disp)->TrackMatrixNV)
-#define SET_TrackMatrixNV(disp, fn) ((disp)->TrackMatrixNV = fn)
-#define CALL_VertexAttrib1dNV(disp, parameters) (*((disp)->VertexAttrib1dNV)) parameters
-#define GET_VertexAttrib1dNV(disp) ((disp)->VertexAttrib1dNV)
-#define SET_VertexAttrib1dNV(disp, fn) ((disp)->VertexAttrib1dNV = fn)
-#define CALL_VertexAttrib1dvNV(disp, parameters) (*((disp)->VertexAttrib1dvNV)) parameters
-#define GET_VertexAttrib1dvNV(disp) ((disp)->VertexAttrib1dvNV)
-#define SET_VertexAttrib1dvNV(disp, fn) ((disp)->VertexAttrib1dvNV = fn)
-#define CALL_VertexAttrib1fNV(disp, parameters) (*((disp)->VertexAttrib1fNV)) parameters
-#define GET_VertexAttrib1fNV(disp) ((disp)->VertexAttrib1fNV)
-#define SET_VertexAttrib1fNV(disp, fn) ((disp)->VertexAttrib1fNV = fn)
-#define CALL_VertexAttrib1fvNV(disp, parameters) (*((disp)->VertexAttrib1fvNV)) parameters
-#define GET_VertexAttrib1fvNV(disp) ((disp)->VertexAttrib1fvNV)
-#define SET_VertexAttrib1fvNV(disp, fn) ((disp)->VertexAttrib1fvNV = fn)
-#define CALL_VertexAttrib1sNV(disp, parameters) (*((disp)->VertexAttrib1sNV)) parameters
-#define GET_VertexAttrib1sNV(disp) ((disp)->VertexAttrib1sNV)
-#define SET_VertexAttrib1sNV(disp, fn) ((disp)->VertexAttrib1sNV = fn)
-#define CALL_VertexAttrib1svNV(disp, parameters) (*((disp)->VertexAttrib1svNV)) parameters
-#define GET_VertexAttrib1svNV(disp) ((disp)->VertexAttrib1svNV)
-#define SET_VertexAttrib1svNV(disp, fn) ((disp)->VertexAttrib1svNV = fn)
-#define CALL_VertexAttrib2dNV(disp, parameters) (*((disp)->VertexAttrib2dNV)) parameters
-#define GET_VertexAttrib2dNV(disp) ((disp)->VertexAttrib2dNV)
-#define SET_VertexAttrib2dNV(disp, fn) ((disp)->VertexAttrib2dNV = fn)
-#define CALL_VertexAttrib2dvNV(disp, parameters) (*((disp)->VertexAttrib2dvNV)) parameters
-#define GET_VertexAttrib2dvNV(disp) ((disp)->VertexAttrib2dvNV)
-#define SET_VertexAttrib2dvNV(disp, fn) ((disp)->VertexAttrib2dvNV = fn)
-#define CALL_VertexAttrib2fNV(disp, parameters) (*((disp)->VertexAttrib2fNV)) parameters
-#define GET_VertexAttrib2fNV(disp) ((disp)->VertexAttrib2fNV)
-#define SET_VertexAttrib2fNV(disp, fn) ((disp)->VertexAttrib2fNV = fn)
-#define CALL_VertexAttrib2fvNV(disp, parameters) (*((disp)->VertexAttrib2fvNV)) parameters
-#define GET_VertexAttrib2fvNV(disp) ((disp)->VertexAttrib2fvNV)
-#define SET_VertexAttrib2fvNV(disp, fn) ((disp)->VertexAttrib2fvNV = fn)
-#define CALL_VertexAttrib2sNV(disp, parameters) (*((disp)->VertexAttrib2sNV)) parameters
-#define GET_VertexAttrib2sNV(disp) ((disp)->VertexAttrib2sNV)
-#define SET_VertexAttrib2sNV(disp, fn) ((disp)->VertexAttrib2sNV = fn)
-#define CALL_VertexAttrib2svNV(disp, parameters) (*((disp)->VertexAttrib2svNV)) parameters
-#define GET_VertexAttrib2svNV(disp) ((disp)->VertexAttrib2svNV)
-#define SET_VertexAttrib2svNV(disp, fn) ((disp)->VertexAttrib2svNV = fn)
-#define CALL_VertexAttrib3dNV(disp, parameters) (*((disp)->VertexAttrib3dNV)) parameters
-#define GET_VertexAttrib3dNV(disp) ((disp)->VertexAttrib3dNV)
-#define SET_VertexAttrib3dNV(disp, fn) ((disp)->VertexAttrib3dNV = fn)
-#define CALL_VertexAttrib3dvNV(disp, parameters) (*((disp)->VertexAttrib3dvNV)) parameters
-#define GET_VertexAttrib3dvNV(disp) ((disp)->VertexAttrib3dvNV)
-#define SET_VertexAttrib3dvNV(disp, fn) ((disp)->VertexAttrib3dvNV = fn)
-#define CALL_VertexAttrib3fNV(disp, parameters) (*((disp)->VertexAttrib3fNV)) parameters
-#define GET_VertexAttrib3fNV(disp) ((disp)->VertexAttrib3fNV)
-#define SET_VertexAttrib3fNV(disp, fn) ((disp)->VertexAttrib3fNV = fn)
-#define CALL_VertexAttrib3fvNV(disp, parameters) (*((disp)->VertexAttrib3fvNV)) parameters
-#define GET_VertexAttrib3fvNV(disp) ((disp)->VertexAttrib3fvNV)
-#define SET_VertexAttrib3fvNV(disp, fn) ((disp)->VertexAttrib3fvNV = fn)
-#define CALL_VertexAttrib3sNV(disp, parameters) (*((disp)->VertexAttrib3sNV)) parameters
-#define GET_VertexAttrib3sNV(disp) ((disp)->VertexAttrib3sNV)
-#define SET_VertexAttrib3sNV(disp, fn) ((disp)->VertexAttrib3sNV = fn)
-#define CALL_VertexAttrib3svNV(disp, parameters) (*((disp)->VertexAttrib3svNV)) parameters
-#define GET_VertexAttrib3svNV(disp) ((disp)->VertexAttrib3svNV)
-#define SET_VertexAttrib3svNV(disp, fn) ((disp)->VertexAttrib3svNV = fn)
-#define CALL_VertexAttrib4dNV(disp, parameters) (*((disp)->VertexAttrib4dNV)) parameters
-#define GET_VertexAttrib4dNV(disp) ((disp)->VertexAttrib4dNV)
-#define SET_VertexAttrib4dNV(disp, fn) ((disp)->VertexAttrib4dNV = fn)
-#define CALL_VertexAttrib4dvNV(disp, parameters) (*((disp)->VertexAttrib4dvNV)) parameters
-#define GET_VertexAttrib4dvNV(disp) ((disp)->VertexAttrib4dvNV)
-#define SET_VertexAttrib4dvNV(disp, fn) ((disp)->VertexAttrib4dvNV = fn)
-#define CALL_VertexAttrib4fNV(disp, parameters) (*((disp)->VertexAttrib4fNV)) parameters
-#define GET_VertexAttrib4fNV(disp) ((disp)->VertexAttrib4fNV)
-#define SET_VertexAttrib4fNV(disp, fn) ((disp)->VertexAttrib4fNV = fn)
-#define CALL_VertexAttrib4fvNV(disp, parameters) (*((disp)->VertexAttrib4fvNV)) parameters
-#define GET_VertexAttrib4fvNV(disp) ((disp)->VertexAttrib4fvNV)
-#define SET_VertexAttrib4fvNV(disp, fn) ((disp)->VertexAttrib4fvNV = fn)
-#define CALL_VertexAttrib4sNV(disp, parameters) (*((disp)->VertexAttrib4sNV)) parameters
-#define GET_VertexAttrib4sNV(disp) ((disp)->VertexAttrib4sNV)
-#define SET_VertexAttrib4sNV(disp, fn) ((disp)->VertexAttrib4sNV = fn)
-#define CALL_VertexAttrib4svNV(disp, parameters) (*((disp)->VertexAttrib4svNV)) parameters
-#define GET_VertexAttrib4svNV(disp) ((disp)->VertexAttrib4svNV)
-#define SET_VertexAttrib4svNV(disp, fn) ((disp)->VertexAttrib4svNV = fn)
-#define CALL_VertexAttrib4ubNV(disp, parameters) (*((disp)->VertexAttrib4ubNV)) parameters
-#define GET_VertexAttrib4ubNV(disp) ((disp)->VertexAttrib4ubNV)
-#define SET_VertexAttrib4ubNV(disp, fn) ((disp)->VertexAttrib4ubNV = fn)
-#define CALL_VertexAttrib4ubvNV(disp, parameters) (*((disp)->VertexAttrib4ubvNV)) parameters
-#define GET_VertexAttrib4ubvNV(disp) ((disp)->VertexAttrib4ubvNV)
-#define SET_VertexAttrib4ubvNV(disp, fn) ((disp)->VertexAttrib4ubvNV = fn)
-#define CALL_VertexAttribPointerNV(disp, parameters) (*((disp)->VertexAttribPointerNV)) parameters
-#define GET_VertexAttribPointerNV(disp) ((disp)->VertexAttribPointerNV)
-#define SET_VertexAttribPointerNV(disp, fn) ((disp)->VertexAttribPointerNV = fn)
-#define CALL_VertexAttribs1dvNV(disp, parameters) (*((disp)->VertexAttribs1dvNV)) parameters
-#define GET_VertexAttribs1dvNV(disp) ((disp)->VertexAttribs1dvNV)
-#define SET_VertexAttribs1dvNV(disp, fn) ((disp)->VertexAttribs1dvNV = fn)
-#define CALL_VertexAttribs1fvNV(disp, parameters) (*((disp)->VertexAttribs1fvNV)) parameters
-#define GET_VertexAttribs1fvNV(disp) ((disp)->VertexAttribs1fvNV)
-#define SET_VertexAttribs1fvNV(disp, fn) ((disp)->VertexAttribs1fvNV = fn)
-#define CALL_VertexAttribs1svNV(disp, parameters) (*((disp)->VertexAttribs1svNV)) parameters
-#define GET_VertexAttribs1svNV(disp) ((disp)->VertexAttribs1svNV)
-#define SET_VertexAttribs1svNV(disp, fn) ((disp)->VertexAttribs1svNV = fn)
-#define CALL_VertexAttribs2dvNV(disp, parameters) (*((disp)->VertexAttribs2dvNV)) parameters
-#define GET_VertexAttribs2dvNV(disp) ((disp)->VertexAttribs2dvNV)
-#define SET_VertexAttribs2dvNV(disp, fn) ((disp)->VertexAttribs2dvNV = fn)
-#define CALL_VertexAttribs2fvNV(disp, parameters) (*((disp)->VertexAttribs2fvNV)) parameters
-#define GET_VertexAttribs2fvNV(disp) ((disp)->VertexAttribs2fvNV)
-#define SET_VertexAttribs2fvNV(disp, fn) ((disp)->VertexAttribs2fvNV = fn)
-#define CALL_VertexAttribs2svNV(disp, parameters) (*((disp)->VertexAttribs2svNV)) parameters
-#define GET_VertexAttribs2svNV(disp) ((disp)->VertexAttribs2svNV)
-#define SET_VertexAttribs2svNV(disp, fn) ((disp)->VertexAttribs2svNV = fn)
-#define CALL_VertexAttribs3dvNV(disp, parameters) (*((disp)->VertexAttribs3dvNV)) parameters
-#define GET_VertexAttribs3dvNV(disp) ((disp)->VertexAttribs3dvNV)
-#define SET_VertexAttribs3dvNV(disp, fn) ((disp)->VertexAttribs3dvNV = fn)
-#define CALL_VertexAttribs3fvNV(disp, parameters) (*((disp)->VertexAttribs3fvNV)) parameters
-#define GET_VertexAttribs3fvNV(disp) ((disp)->VertexAttribs3fvNV)
-#define SET_VertexAttribs3fvNV(disp, fn) ((disp)->VertexAttribs3fvNV = fn)
-#define CALL_VertexAttribs3svNV(disp, parameters) (*((disp)->VertexAttribs3svNV)) parameters
-#define GET_VertexAttribs3svNV(disp) ((disp)->VertexAttribs3svNV)
-#define SET_VertexAttribs3svNV(disp, fn) ((disp)->VertexAttribs3svNV = fn)
-#define CALL_VertexAttribs4dvNV(disp, parameters) (*((disp)->VertexAttribs4dvNV)) parameters
-#define GET_VertexAttribs4dvNV(disp) ((disp)->VertexAttribs4dvNV)
-#define SET_VertexAttribs4dvNV(disp, fn) ((disp)->VertexAttribs4dvNV = fn)
-#define CALL_VertexAttribs4fvNV(disp, parameters) (*((disp)->VertexAttribs4fvNV)) parameters
-#define GET_VertexAttribs4fvNV(disp) ((disp)->VertexAttribs4fvNV)
-#define SET_VertexAttribs4fvNV(disp, fn) ((disp)->VertexAttribs4fvNV = fn)
-#define CALL_VertexAttribs4svNV(disp, parameters) (*((disp)->VertexAttribs4svNV)) parameters
-#define GET_VertexAttribs4svNV(disp) ((disp)->VertexAttribs4svNV)
-#define SET_VertexAttribs4svNV(disp, fn) ((disp)->VertexAttribs4svNV = fn)
-#define CALL_VertexAttribs4ubvNV(disp, parameters) (*((disp)->VertexAttribs4ubvNV)) parameters
-#define GET_VertexAttribs4ubvNV(disp) ((disp)->VertexAttribs4ubvNV)
-#define SET_VertexAttribs4ubvNV(disp, fn) ((disp)->VertexAttribs4ubvNV = fn)
-#define CALL_GetTexBumpParameterfvATI(disp, parameters) (*((disp)->GetTexBumpParameterfvATI)) parameters
-#define GET_GetTexBumpParameterfvATI(disp) ((disp)->GetTexBumpParameterfvATI)
-#define SET_GetTexBumpParameterfvATI(disp, fn) ((disp)->GetTexBumpParameterfvATI = fn)
-#define CALL_GetTexBumpParameterivATI(disp, parameters) (*((disp)->GetTexBumpParameterivATI)) parameters
-#define GET_GetTexBumpParameterivATI(disp) ((disp)->GetTexBumpParameterivATI)
-#define SET_GetTexBumpParameterivATI(disp, fn) ((disp)->GetTexBumpParameterivATI = fn)
-#define CALL_TexBumpParameterfvATI(disp, parameters) (*((disp)->TexBumpParameterfvATI)) parameters
-#define GET_TexBumpParameterfvATI(disp) ((disp)->TexBumpParameterfvATI)
-#define SET_TexBumpParameterfvATI(disp, fn) ((disp)->TexBumpParameterfvATI = fn)
-#define CALL_TexBumpParameterivATI(disp, parameters) (*((disp)->TexBumpParameterivATI)) parameters
-#define GET_TexBumpParameterivATI(disp) ((disp)->TexBumpParameterivATI)
-#define SET_TexBumpParameterivATI(disp, fn) ((disp)->TexBumpParameterivATI = fn)
-#define CALL_AlphaFragmentOp1ATI(disp, parameters) (*((disp)->AlphaFragmentOp1ATI)) parameters
-#define GET_AlphaFragmentOp1ATI(disp) ((disp)->AlphaFragmentOp1ATI)
-#define SET_AlphaFragmentOp1ATI(disp, fn) ((disp)->AlphaFragmentOp1ATI = fn)
-#define CALL_AlphaFragmentOp2ATI(disp, parameters) (*((disp)->AlphaFragmentOp2ATI)) parameters
-#define GET_AlphaFragmentOp2ATI(disp) ((disp)->AlphaFragmentOp2ATI)
-#define SET_AlphaFragmentOp2ATI(disp, fn) ((disp)->AlphaFragmentOp2ATI = fn)
-#define CALL_AlphaFragmentOp3ATI(disp, parameters) (*((disp)->AlphaFragmentOp3ATI)) parameters
-#define GET_AlphaFragmentOp3ATI(disp) ((disp)->AlphaFragmentOp3ATI)
-#define SET_AlphaFragmentOp3ATI(disp, fn) ((disp)->AlphaFragmentOp3ATI = fn)
-#define CALL_BeginFragmentShaderATI(disp, parameters) (*((disp)->BeginFragmentShaderATI)) parameters
-#define GET_BeginFragmentShaderATI(disp) ((disp)->BeginFragmentShaderATI)
-#define SET_BeginFragmentShaderATI(disp, fn) ((disp)->BeginFragmentShaderATI = fn)
-#define CALL_BindFragmentShaderATI(disp, parameters) (*((disp)->BindFragmentShaderATI)) parameters
-#define GET_BindFragmentShaderATI(disp) ((disp)->BindFragmentShaderATI)
-#define SET_BindFragmentShaderATI(disp, fn) ((disp)->BindFragmentShaderATI = fn)
-#define CALL_ColorFragmentOp1ATI(disp, parameters) (*((disp)->ColorFragmentOp1ATI)) parameters
-#define GET_ColorFragmentOp1ATI(disp) ((disp)->ColorFragmentOp1ATI)
-#define SET_ColorFragmentOp1ATI(disp, fn) ((disp)->ColorFragmentOp1ATI = fn)
-#define CALL_ColorFragmentOp2ATI(disp, parameters) (*((disp)->ColorFragmentOp2ATI)) parameters
-#define GET_ColorFragmentOp2ATI(disp) ((disp)->ColorFragmentOp2ATI)
-#define SET_ColorFragmentOp2ATI(disp, fn) ((disp)->ColorFragmentOp2ATI = fn)
-#define CALL_ColorFragmentOp3ATI(disp, parameters) (*((disp)->ColorFragmentOp3ATI)) parameters
-#define GET_ColorFragmentOp3ATI(disp) ((disp)->ColorFragmentOp3ATI)
-#define SET_ColorFragmentOp3ATI(disp, fn) ((disp)->ColorFragmentOp3ATI = fn)
-#define CALL_DeleteFragmentShaderATI(disp, parameters) (*((disp)->DeleteFragmentShaderATI)) parameters
-#define GET_DeleteFragmentShaderATI(disp) ((disp)->DeleteFragmentShaderATI)
-#define SET_DeleteFragmentShaderATI(disp, fn) ((disp)->DeleteFragmentShaderATI = fn)
-#define CALL_EndFragmentShaderATI(disp, parameters) (*((disp)->EndFragmentShaderATI)) parameters
-#define GET_EndFragmentShaderATI(disp) ((disp)->EndFragmentShaderATI)
-#define SET_EndFragmentShaderATI(disp, fn) ((disp)->EndFragmentShaderATI = fn)
-#define CALL_GenFragmentShadersATI(disp, parameters) (*((disp)->GenFragmentShadersATI)) parameters
-#define GET_GenFragmentShadersATI(disp) ((disp)->GenFragmentShadersATI)
-#define SET_GenFragmentShadersATI(disp, fn) ((disp)->GenFragmentShadersATI = fn)
-#define CALL_PassTexCoordATI(disp, parameters) (*((disp)->PassTexCoordATI)) parameters
-#define GET_PassTexCoordATI(disp) ((disp)->PassTexCoordATI)
-#define SET_PassTexCoordATI(disp, fn) ((disp)->PassTexCoordATI = fn)
-#define CALL_SampleMapATI(disp, parameters) (*((disp)->SampleMapATI)) parameters
-#define GET_SampleMapATI(disp) ((disp)->SampleMapATI)
-#define SET_SampleMapATI(disp, fn) ((disp)->SampleMapATI = fn)
-#define CALL_SetFragmentShaderConstantATI(disp, parameters) (*((disp)->SetFragmentShaderConstantATI)) parameters
-#define GET_SetFragmentShaderConstantATI(disp) ((disp)->SetFragmentShaderConstantATI)
-#define SET_SetFragmentShaderConstantATI(disp, fn) ((disp)->SetFragmentShaderConstantATI = fn)
-#define CALL_PointParameteriNV(disp, parameters) (*((disp)->PointParameteriNV)) parameters
-#define GET_PointParameteriNV(disp) ((disp)->PointParameteriNV)
-#define SET_PointParameteriNV(disp, fn) ((disp)->PointParameteriNV = fn)
-#define CALL_PointParameterivNV(disp, parameters) (*((disp)->PointParameterivNV)) parameters
-#define GET_PointParameterivNV(disp) ((disp)->PointParameterivNV)
-#define SET_PointParameterivNV(disp, fn) ((disp)->PointParameterivNV = fn)
-#define CALL_ActiveStencilFaceEXT(disp, parameters) (*((disp)->ActiveStencilFaceEXT)) parameters
-#define GET_ActiveStencilFaceEXT(disp) ((disp)->ActiveStencilFaceEXT)
-#define SET_ActiveStencilFaceEXT(disp, fn) ((disp)->ActiveStencilFaceEXT = fn)
-#define CALL_BindVertexArrayAPPLE(disp, parameters) (*((disp)->BindVertexArrayAPPLE)) parameters
-#define GET_BindVertexArrayAPPLE(disp) ((disp)->BindVertexArrayAPPLE)
-#define SET_BindVertexArrayAPPLE(disp, fn) ((disp)->BindVertexArrayAPPLE = fn)
-#define CALL_DeleteVertexArraysAPPLE(disp, parameters) (*((disp)->DeleteVertexArraysAPPLE)) parameters
-#define GET_DeleteVertexArraysAPPLE(disp) ((disp)->DeleteVertexArraysAPPLE)
-#define SET_DeleteVertexArraysAPPLE(disp, fn) ((disp)->DeleteVertexArraysAPPLE = fn)
-#define CALL_GenVertexArraysAPPLE(disp, parameters) (*((disp)->GenVertexArraysAPPLE)) parameters
-#define GET_GenVertexArraysAPPLE(disp) ((disp)->GenVertexArraysAPPLE)
-#define SET_GenVertexArraysAPPLE(disp, fn) ((disp)->GenVertexArraysAPPLE = fn)
-#define CALL_IsVertexArrayAPPLE(disp, parameters) (*((disp)->IsVertexArrayAPPLE)) parameters
-#define GET_IsVertexArrayAPPLE(disp) ((disp)->IsVertexArrayAPPLE)
-#define SET_IsVertexArrayAPPLE(disp, fn) ((disp)->IsVertexArrayAPPLE = fn)
-#define CALL_GetProgramNamedParameterdvNV(disp, parameters) (*((disp)->GetProgramNamedParameterdvNV)) parameters
-#define GET_GetProgramNamedParameterdvNV(disp) ((disp)->GetProgramNamedParameterdvNV)
-#define SET_GetProgramNamedParameterdvNV(disp, fn) ((disp)->GetProgramNamedParameterdvNV = fn)
-#define CALL_GetProgramNamedParameterfvNV(disp, parameters) (*((disp)->GetProgramNamedParameterfvNV)) parameters
-#define GET_GetProgramNamedParameterfvNV(disp) ((disp)->GetProgramNamedParameterfvNV)
-#define SET_GetProgramNamedParameterfvNV(disp, fn) ((disp)->GetProgramNamedParameterfvNV = fn)
-#define CALL_ProgramNamedParameter4dNV(disp, parameters) (*((disp)->ProgramNamedParameter4dNV)) parameters
-#define GET_ProgramNamedParameter4dNV(disp) ((disp)->ProgramNamedParameter4dNV)
-#define SET_ProgramNamedParameter4dNV(disp, fn) ((disp)->ProgramNamedParameter4dNV = fn)
-#define CALL_ProgramNamedParameter4dvNV(disp, parameters) (*((disp)->ProgramNamedParameter4dvNV)) parameters
-#define GET_ProgramNamedParameter4dvNV(disp) ((disp)->ProgramNamedParameter4dvNV)
-#define SET_ProgramNamedParameter4dvNV(disp, fn) ((disp)->ProgramNamedParameter4dvNV = fn)
-#define CALL_ProgramNamedParameter4fNV(disp, parameters) (*((disp)->ProgramNamedParameter4fNV)) parameters
-#define GET_ProgramNamedParameter4fNV(disp) ((disp)->ProgramNamedParameter4fNV)
-#define SET_ProgramNamedParameter4fNV(disp, fn) ((disp)->ProgramNamedParameter4fNV = fn)
-#define CALL_ProgramNamedParameter4fvNV(disp, parameters) (*((disp)->ProgramNamedParameter4fvNV)) parameters
-#define GET_ProgramNamedParameter4fvNV(disp) ((disp)->ProgramNamedParameter4fvNV)
-#define SET_ProgramNamedParameter4fvNV(disp, fn) ((disp)->ProgramNamedParameter4fvNV = fn)
-#define CALL_DepthBoundsEXT(disp, parameters) (*((disp)->DepthBoundsEXT)) parameters
-#define GET_DepthBoundsEXT(disp) ((disp)->DepthBoundsEXT)
-#define SET_DepthBoundsEXT(disp, fn) ((disp)->DepthBoundsEXT = fn)
-#define CALL_BlendEquationSeparateEXT(disp, parameters) (*((disp)->BlendEquationSeparateEXT)) parameters
-#define GET_BlendEquationSeparateEXT(disp) ((disp)->BlendEquationSeparateEXT)
-#define SET_BlendEquationSeparateEXT(disp, fn) ((disp)->BlendEquationSeparateEXT = fn)
-#define CALL_BindFramebufferEXT(disp, parameters) (*((disp)->BindFramebufferEXT)) parameters
-#define GET_BindFramebufferEXT(disp) ((disp)->BindFramebufferEXT)
-#define SET_BindFramebufferEXT(disp, fn) ((disp)->BindFramebufferEXT = fn)
-#define CALL_BindRenderbufferEXT(disp, parameters) (*((disp)->BindRenderbufferEXT)) parameters
-#define GET_BindRenderbufferEXT(disp) ((disp)->BindRenderbufferEXT)
-#define SET_BindRenderbufferEXT(disp, fn) ((disp)->BindRenderbufferEXT = fn)
-#define CALL_CheckFramebufferStatusEXT(disp, parameters) (*((disp)->CheckFramebufferStatusEXT)) parameters
-#define GET_CheckFramebufferStatusEXT(disp) ((disp)->CheckFramebufferStatusEXT)
-#define SET_CheckFramebufferStatusEXT(disp, fn) ((disp)->CheckFramebufferStatusEXT = fn)
-#define CALL_DeleteFramebuffersEXT(disp, parameters) (*((disp)->DeleteFramebuffersEXT)) parameters
-#define GET_DeleteFramebuffersEXT(disp) ((disp)->DeleteFramebuffersEXT)
-#define SET_DeleteFramebuffersEXT(disp, fn) ((disp)->DeleteFramebuffersEXT = fn)
-#define CALL_DeleteRenderbuffersEXT(disp, parameters) (*((disp)->DeleteRenderbuffersEXT)) parameters
-#define GET_DeleteRenderbuffersEXT(disp) ((disp)->DeleteRenderbuffersEXT)
-#define SET_DeleteRenderbuffersEXT(disp, fn) ((disp)->DeleteRenderbuffersEXT = fn)
-#define CALL_FramebufferRenderbufferEXT(disp, parameters) (*((disp)->FramebufferRenderbufferEXT)) parameters
-#define GET_FramebufferRenderbufferEXT(disp) ((disp)->FramebufferRenderbufferEXT)
-#define SET_FramebufferRenderbufferEXT(disp, fn) ((disp)->FramebufferRenderbufferEXT = fn)
-#define CALL_FramebufferTexture1DEXT(disp, parameters) (*((disp)->FramebufferTexture1DEXT)) parameters
-#define GET_FramebufferTexture1DEXT(disp) ((disp)->FramebufferTexture1DEXT)
-#define SET_FramebufferTexture1DEXT(disp, fn) ((disp)->FramebufferTexture1DEXT = fn)
-#define CALL_FramebufferTexture2DEXT(disp, parameters) (*((disp)->FramebufferTexture2DEXT)) parameters
-#define GET_FramebufferTexture2DEXT(disp) ((disp)->FramebufferTexture2DEXT)
-#define SET_FramebufferTexture2DEXT(disp, fn) ((disp)->FramebufferTexture2DEXT = fn)
-#define CALL_FramebufferTexture3DEXT(disp, parameters) (*((disp)->FramebufferTexture3DEXT)) parameters
-#define GET_FramebufferTexture3DEXT(disp) ((disp)->FramebufferTexture3DEXT)
-#define SET_FramebufferTexture3DEXT(disp, fn) ((disp)->FramebufferTexture3DEXT = fn)
-#define CALL_GenFramebuffersEXT(disp, parameters) (*((disp)->GenFramebuffersEXT)) parameters
-#define GET_GenFramebuffersEXT(disp) ((disp)->GenFramebuffersEXT)
-#define SET_GenFramebuffersEXT(disp, fn) ((disp)->GenFramebuffersEXT = fn)
-#define CALL_GenRenderbuffersEXT(disp, parameters) (*((disp)->GenRenderbuffersEXT)) parameters
-#define GET_GenRenderbuffersEXT(disp) ((disp)->GenRenderbuffersEXT)
-#define SET_GenRenderbuffersEXT(disp, fn) ((disp)->GenRenderbuffersEXT = fn)
-#define CALL_GenerateMipmapEXT(disp, parameters) (*((disp)->GenerateMipmapEXT)) parameters
-#define GET_GenerateMipmapEXT(disp) ((disp)->GenerateMipmapEXT)
-#define SET_GenerateMipmapEXT(disp, fn) ((disp)->GenerateMipmapEXT = fn)
-#define CALL_GetFramebufferAttachmentParameterivEXT(disp, parameters) (*((disp)->GetFramebufferAttachmentParameterivEXT)) parameters
-#define GET_GetFramebufferAttachmentParameterivEXT(disp) ((disp)->GetFramebufferAttachmentParameterivEXT)
-#define SET_GetFramebufferAttachmentParameterivEXT(disp, fn) ((disp)->GetFramebufferAttachmentParameterivEXT = fn)
-#define CALL_GetRenderbufferParameterivEXT(disp, parameters) (*((disp)->GetRenderbufferParameterivEXT)) parameters
-#define GET_GetRenderbufferParameterivEXT(disp) ((disp)->GetRenderbufferParameterivEXT)
-#define SET_GetRenderbufferParameterivEXT(disp, fn) ((disp)->GetRenderbufferParameterivEXT = fn)
-#define CALL_IsFramebufferEXT(disp, parameters) (*((disp)->IsFramebufferEXT)) parameters
-#define GET_IsFramebufferEXT(disp) ((disp)->IsFramebufferEXT)
-#define SET_IsFramebufferEXT(disp, fn) ((disp)->IsFramebufferEXT = fn)
-#define CALL_IsRenderbufferEXT(disp, parameters) (*((disp)->IsRenderbufferEXT)) parameters
-#define GET_IsRenderbufferEXT(disp) ((disp)->IsRenderbufferEXT)
-#define SET_IsRenderbufferEXT(disp, fn) ((disp)->IsRenderbufferEXT = fn)
-#define CALL_RenderbufferStorageEXT(disp, parameters) (*((disp)->RenderbufferStorageEXT)) parameters
-#define GET_RenderbufferStorageEXT(disp) ((disp)->RenderbufferStorageEXT)
-#define SET_RenderbufferStorageEXT(disp, fn) ((disp)->RenderbufferStorageEXT = fn)
-#define CALL_BlitFramebufferEXT(disp, parameters) (*((disp)->BlitFramebufferEXT)) parameters
-#define GET_BlitFramebufferEXT(disp) ((disp)->BlitFramebufferEXT)
-#define SET_BlitFramebufferEXT(disp, fn) ((disp)->BlitFramebufferEXT = fn)
-#define CALL_BufferParameteriAPPLE(disp, parameters) (*((disp)->BufferParameteriAPPLE)) parameters
-#define GET_BufferParameteriAPPLE(disp) ((disp)->BufferParameteriAPPLE)
-#define SET_BufferParameteriAPPLE(disp, fn) ((disp)->BufferParameteriAPPLE = fn)
-#define CALL_FlushMappedBufferRangeAPPLE(disp, parameters) (*((disp)->FlushMappedBufferRangeAPPLE)) parameters
-#define GET_FlushMappedBufferRangeAPPLE(disp) ((disp)->FlushMappedBufferRangeAPPLE)
-#define SET_FlushMappedBufferRangeAPPLE(disp, fn) ((disp)->FlushMappedBufferRangeAPPLE = fn)
-#define CALL_FramebufferTextureLayerEXT(disp, parameters) (*((disp)->FramebufferTextureLayerEXT)) parameters
-#define GET_FramebufferTextureLayerEXT(disp) ((disp)->FramebufferTextureLayerEXT)
-#define SET_FramebufferTextureLayerEXT(disp, fn) ((disp)->FramebufferTextureLayerEXT = fn)
-#define CALL_ProvokingVertexEXT(disp, parameters) (*((disp)->ProvokingVertexEXT)) parameters
-#define GET_ProvokingVertexEXT(disp) ((disp)->ProvokingVertexEXT)
-#define SET_ProvokingVertexEXT(disp, fn) ((disp)->ProvokingVertexEXT = fn)
-#define CALL_GetTexParameterPointervAPPLE(disp, parameters) (*((disp)->GetTexParameterPointervAPPLE)) parameters
-#define GET_GetTexParameterPointervAPPLE(disp) ((disp)->GetTexParameterPointervAPPLE)
-#define SET_GetTexParameterPointervAPPLE(disp, fn) ((disp)->GetTexParameterPointervAPPLE = fn)
-#define CALL_TextureRangeAPPLE(disp, parameters) (*((disp)->TextureRangeAPPLE)) parameters
-#define GET_TextureRangeAPPLE(disp) ((disp)->TextureRangeAPPLE)
-#define SET_TextureRangeAPPLE(disp, fn) ((disp)->TextureRangeAPPLE = fn)
-#define CALL_StencilFuncSeparateATI(disp, parameters) (*((disp)->StencilFuncSeparateATI)) parameters
-#define GET_StencilFuncSeparateATI(disp) ((disp)->StencilFuncSeparateATI)
-#define SET_StencilFuncSeparateATI(disp, fn) ((disp)->StencilFuncSeparateATI = fn)
-#define CALL_ProgramEnvParameters4fvEXT(disp, parameters) (*((disp)->ProgramEnvParameters4fvEXT)) parameters
-#define GET_ProgramEnvParameters4fvEXT(disp) ((disp)->ProgramEnvParameters4fvEXT)
-#define SET_ProgramEnvParameters4fvEXT(disp, fn) ((disp)->ProgramEnvParameters4fvEXT = fn)
-#define CALL_ProgramLocalParameters4fvEXT(disp, parameters) (*((disp)->ProgramLocalParameters4fvEXT)) parameters
-#define GET_ProgramLocalParameters4fvEXT(disp) ((disp)->ProgramLocalParameters4fvEXT)
-#define SET_ProgramLocalParameters4fvEXT(disp, fn) ((disp)->ProgramLocalParameters4fvEXT = fn)
-#define CALL_GetQueryObjecti64vEXT(disp, parameters) (*((disp)->GetQueryObjecti64vEXT)) parameters
-#define GET_GetQueryObjecti64vEXT(disp) ((disp)->GetQueryObjecti64vEXT)
-#define SET_GetQueryObjecti64vEXT(disp, fn) ((disp)->GetQueryObjecti64vEXT = fn)
-#define CALL_GetQueryObjectui64vEXT(disp, parameters) (*((disp)->GetQueryObjectui64vEXT)) parameters
-#define GET_GetQueryObjectui64vEXT(disp) ((disp)->GetQueryObjectui64vEXT)
-#define SET_GetQueryObjectui64vEXT(disp, fn) ((disp)->GetQueryObjectui64vEXT = fn)
-
-#else
-
-#define driDispatchRemapTable_size 387
-extern int driDispatchRemapTable[ driDispatchRemapTable_size ];
-
-#define AttachShader_remap_index 0
-#define CreateProgram_remap_index 1
-#define CreateShader_remap_index 2
-#define DeleteProgram_remap_index 3
-#define DeleteShader_remap_index 4
-#define DetachShader_remap_index 5
-#define GetAttachedShaders_remap_index 6
-#define GetProgramInfoLog_remap_index 7
-#define GetProgramiv_remap_index 8
-#define GetShaderInfoLog_remap_index 9
-#define GetShaderiv_remap_index 10
-#define IsProgram_remap_index 11
-#define IsShader_remap_index 12
-#define StencilFuncSeparate_remap_index 13
-#define StencilMaskSeparate_remap_index 14
-#define StencilOpSeparate_remap_index 15
-#define UniformMatrix2x3fv_remap_index 16
-#define UniformMatrix2x4fv_remap_index 17
-#define UniformMatrix3x2fv_remap_index 18
-#define UniformMatrix3x4fv_remap_index 19
-#define UniformMatrix4x2fv_remap_index 20
-#define UniformMatrix4x3fv_remap_index 21
-#define LoadTransposeMatrixdARB_remap_index 22
-#define LoadTransposeMatrixfARB_remap_index 23
-#define MultTransposeMatrixdARB_remap_index 24
-#define MultTransposeMatrixfARB_remap_index 25
-#define SampleCoverageARB_remap_index 26
-#define CompressedTexImage1DARB_remap_index 27
-#define CompressedTexImage2DARB_remap_index 28
-#define CompressedTexImage3DARB_remap_index 29
-#define CompressedTexSubImage1DARB_remap_index 30
-#define CompressedTexSubImage2DARB_remap_index 31
-#define CompressedTexSubImage3DARB_remap_index 32
-#define GetCompressedTexImageARB_remap_index 33
-#define DisableVertexAttribArrayARB_remap_index 34
-#define EnableVertexAttribArrayARB_remap_index 35
-#define GetProgramEnvParameterdvARB_remap_index 36
-#define GetProgramEnvParameterfvARB_remap_index 37
-#define GetProgramLocalParameterdvARB_remap_index 38
-#define GetProgramLocalParameterfvARB_remap_index 39
-#define GetProgramStringARB_remap_index 40
-#define GetProgramivARB_remap_index 41
-#define GetVertexAttribdvARB_remap_index 42
-#define GetVertexAttribfvARB_remap_index 43
-#define GetVertexAttribivARB_remap_index 44
-#define ProgramEnvParameter4dARB_remap_index 45
-#define ProgramEnvParameter4dvARB_remap_index 46
-#define ProgramEnvParameter4fARB_remap_index 47
-#define ProgramEnvParameter4fvARB_remap_index 48
-#define ProgramLocalParameter4dARB_remap_index 49
-#define ProgramLocalParameter4dvARB_remap_index 50
-#define ProgramLocalParameter4fARB_remap_index 51
-#define ProgramLocalParameter4fvARB_remap_index 52
-#define ProgramStringARB_remap_index 53
-#define VertexAttrib1dARB_remap_index 54
-#define VertexAttrib1dvARB_remap_index 55
-#define VertexAttrib1fARB_remap_index 56
-#define VertexAttrib1fvARB_remap_index 57
-#define VertexAttrib1sARB_remap_index 58
-#define VertexAttrib1svARB_remap_index 59
-#define VertexAttrib2dARB_remap_index 60
-#define VertexAttrib2dvARB_remap_index 61
-#define VertexAttrib2fARB_remap_index 62
-#define VertexAttrib2fvARB_remap_index 63
-#define VertexAttrib2sARB_remap_index 64
-#define VertexAttrib2svARB_remap_index 65
-#define VertexAttrib3dARB_remap_index 66
-#define VertexAttrib3dvARB_remap_index 67
-#define VertexAttrib3fARB_remap_index 68
-#define VertexAttrib3fvARB_remap_index 69
-#define VertexAttrib3sARB_remap_index 70
-#define VertexAttrib3svARB_remap_index 71
-#define VertexAttrib4NbvARB_remap_index 72
-#define VertexAttrib4NivARB_remap_index 73
-#define VertexAttrib4NsvARB_remap_index 74
-#define VertexAttrib4NubARB_remap_index 75
-#define VertexAttrib4NubvARB_remap_index 76
-#define VertexAttrib4NuivARB_remap_index 77
-#define VertexAttrib4NusvARB_remap_index 78
-#define VertexAttrib4bvARB_remap_index 79
-#define VertexAttrib4dARB_remap_index 80
-#define VertexAttrib4dvARB_remap_index 81
-#define VertexAttrib4fARB_remap_index 82
-#define VertexAttrib4fvARB_remap_index 83
-#define VertexAttrib4ivARB_remap_index 84
-#define VertexAttrib4sARB_remap_index 85
-#define VertexAttrib4svARB_remap_index 86
-#define VertexAttrib4ubvARB_remap_index 87
-#define VertexAttrib4uivARB_remap_index 88
-#define VertexAttrib4usvARB_remap_index 89
-#define VertexAttribPointerARB_remap_index 90
-#define BindBufferARB_remap_index 91
-#define BufferDataARB_remap_index 92
-#define BufferSubDataARB_remap_index 93
-#define DeleteBuffersARB_remap_index 94
-#define GenBuffersARB_remap_index 95
-#define GetBufferParameterivARB_remap_index 96
-#define GetBufferPointervARB_remap_index 97
-#define GetBufferSubDataARB_remap_index 98
-#define IsBufferARB_remap_index 99
-#define MapBufferARB_remap_index 100
-#define UnmapBufferARB_remap_index 101
-#define BeginQueryARB_remap_index 102
-#define DeleteQueriesARB_remap_index 103
-#define EndQueryARB_remap_index 104
-#define GenQueriesARB_remap_index 105
-#define GetQueryObjectivARB_remap_index 106
-#define GetQueryObjectuivARB_remap_index 107
-#define GetQueryivARB_remap_index 108
-#define IsQueryARB_remap_index 109
-#define AttachObjectARB_remap_index 110
-#define CompileShaderARB_remap_index 111
-#define CreateProgramObjectARB_remap_index 112
-#define CreateShaderObjectARB_remap_index 113
-#define DeleteObjectARB_remap_index 114
-#define DetachObjectARB_remap_index 115
-#define GetActiveUniformARB_remap_index 116
-#define GetAttachedObjectsARB_remap_index 117
-#define GetHandleARB_remap_index 118
-#define GetInfoLogARB_remap_index 119
-#define GetObjectParameterfvARB_remap_index 120
-#define GetObjectParameterivARB_remap_index 121
-#define GetShaderSourceARB_remap_index 122
-#define GetUniformLocationARB_remap_index 123
-#define GetUniformfvARB_remap_index 124
-#define GetUniformivARB_remap_index 125
-#define LinkProgramARB_remap_index 126
-#define ShaderSourceARB_remap_index 127
-#define Uniform1fARB_remap_index 128
-#define Uniform1fvARB_remap_index 129
-#define Uniform1iARB_remap_index 130
-#define Uniform1ivARB_remap_index 131
-#define Uniform2fARB_remap_index 132
-#define Uniform2fvARB_remap_index 133
-#define Uniform2iARB_remap_index 134
-#define Uniform2ivARB_remap_index 135
-#define Uniform3fARB_remap_index 136
-#define Uniform3fvARB_remap_index 137
-#define Uniform3iARB_remap_index 138
-#define Uniform3ivARB_remap_index 139
-#define Uniform4fARB_remap_index 140
-#define Uniform4fvARB_remap_index 141
-#define Uniform4iARB_remap_index 142
-#define Uniform4ivARB_remap_index 143
-#define UniformMatrix2fvARB_remap_index 144
-#define UniformMatrix3fvARB_remap_index 145
-#define UniformMatrix4fvARB_remap_index 146
-#define UseProgramObjectARB_remap_index 147
-#define ValidateProgramARB_remap_index 148
-#define BindAttribLocationARB_remap_index 149
-#define GetActiveAttribARB_remap_index 150
-#define GetAttribLocationARB_remap_index 151
-#define DrawBuffersARB_remap_index 152
-#define RenderbufferStorageMultisample_remap_index 153
-#define FlushMappedBufferRange_remap_index 154
-#define MapBufferRange_remap_index 155
-#define BindVertexArray_remap_index 156
-#define GenVertexArrays_remap_index 157
-#define CopyBufferSubData_remap_index 158
-#define ClientWaitSync_remap_index 159
-#define DeleteSync_remap_index 160
-#define FenceSync_remap_index 161
-#define GetInteger64v_remap_index 162
-#define GetSynciv_remap_index 163
-#define IsSync_remap_index 164
-#define WaitSync_remap_index 165
-#define DrawElementsBaseVertex_remap_index 166
-#define DrawRangeElementsBaseVertex_remap_index 167
-#define MultiDrawElementsBaseVertex_remap_index 168
-#define PolygonOffsetEXT_remap_index 169
-#define GetPixelTexGenParameterfvSGIS_remap_index 170
-#define GetPixelTexGenParameterivSGIS_remap_index 171
-#define PixelTexGenParameterfSGIS_remap_index 172
-#define PixelTexGenParameterfvSGIS_remap_index 173
-#define PixelTexGenParameteriSGIS_remap_index 174
-#define PixelTexGenParameterivSGIS_remap_index 175
-#define SampleMaskSGIS_remap_index 176
-#define SamplePatternSGIS_remap_index 177
-#define ColorPointerEXT_remap_index 178
-#define EdgeFlagPointerEXT_remap_index 179
-#define IndexPointerEXT_remap_index 180
-#define NormalPointerEXT_remap_index 181
-#define TexCoordPointerEXT_remap_index 182
-#define VertexPointerEXT_remap_index 183
-#define PointParameterfEXT_remap_index 184
-#define PointParameterfvEXT_remap_index 185
-#define LockArraysEXT_remap_index 186
-#define UnlockArraysEXT_remap_index 187
-#define CullParameterdvEXT_remap_index 188
-#define CullParameterfvEXT_remap_index 189
-#define SecondaryColor3bEXT_remap_index 190
-#define SecondaryColor3bvEXT_remap_index 191
-#define SecondaryColor3dEXT_remap_index 192
-#define SecondaryColor3dvEXT_remap_index 193
-#define SecondaryColor3fEXT_remap_index 194
-#define SecondaryColor3fvEXT_remap_index 195
-#define SecondaryColor3iEXT_remap_index 196
-#define SecondaryColor3ivEXT_remap_index 197
-#define SecondaryColor3sEXT_remap_index 198
-#define SecondaryColor3svEXT_remap_index 199
-#define SecondaryColor3ubEXT_remap_index 200
-#define SecondaryColor3ubvEXT_remap_index 201
-#define SecondaryColor3uiEXT_remap_index 202
-#define SecondaryColor3uivEXT_remap_index 203
-#define SecondaryColor3usEXT_remap_index 204
-#define SecondaryColor3usvEXT_remap_index 205
-#define SecondaryColorPointerEXT_remap_index 206
-#define MultiDrawArraysEXT_remap_index 207
-#define MultiDrawElementsEXT_remap_index 208
-#define FogCoordPointerEXT_remap_index 209
-#define FogCoorddEXT_remap_index 210
-#define FogCoorddvEXT_remap_index 211
-#define FogCoordfEXT_remap_index 212
-#define FogCoordfvEXT_remap_index 213
-#define PixelTexGenSGIX_remap_index 214
-#define BlendFuncSeparateEXT_remap_index 215
-#define FlushVertexArrayRangeNV_remap_index 216
-#define VertexArrayRangeNV_remap_index 217
-#define CombinerInputNV_remap_index 218
-#define CombinerOutputNV_remap_index 219
-#define CombinerParameterfNV_remap_index 220
-#define CombinerParameterfvNV_remap_index 221
-#define CombinerParameteriNV_remap_index 222
-#define CombinerParameterivNV_remap_index 223
-#define FinalCombinerInputNV_remap_index 224
-#define GetCombinerInputParameterfvNV_remap_index 225
-#define GetCombinerInputParameterivNV_remap_index 226
-#define GetCombinerOutputParameterfvNV_remap_index 227
-#define GetCombinerOutputParameterivNV_remap_index 228
-#define GetFinalCombinerInputParameterfvNV_remap_index 229
-#define GetFinalCombinerInputParameterivNV_remap_index 230
-#define ResizeBuffersMESA_remap_index 231
-#define WindowPos2dMESA_remap_index 232
-#define WindowPos2dvMESA_remap_index 233
-#define WindowPos2fMESA_remap_index 234
-#define WindowPos2fvMESA_remap_index 235
-#define WindowPos2iMESA_remap_index 236
-#define WindowPos2ivMESA_remap_index 237
-#define WindowPos2sMESA_remap_index 238
-#define WindowPos2svMESA_remap_index 239
-#define WindowPos3dMESA_remap_index 240
-#define WindowPos3dvMESA_remap_index 241
-#define WindowPos3fMESA_remap_index 242
-#define WindowPos3fvMESA_remap_index 243
-#define WindowPos3iMESA_remap_index 244
-#define WindowPos3ivMESA_remap_index 245
-#define WindowPos3sMESA_remap_index 246
-#define WindowPos3svMESA_remap_index 247
-#define WindowPos4dMESA_remap_index 248
-#define WindowPos4dvMESA_remap_index 249
-#define WindowPos4fMESA_remap_index 250
-#define WindowPos4fvMESA_remap_index 251
-#define WindowPos4iMESA_remap_index 252
-#define WindowPos4ivMESA_remap_index 253
-#define WindowPos4sMESA_remap_index 254
-#define WindowPos4svMESA_remap_index 255
-#define MultiModeDrawArraysIBM_remap_index 256
-#define MultiModeDrawElementsIBM_remap_index 257
-#define DeleteFencesNV_remap_index 258
-#define FinishFenceNV_remap_index 259
-#define GenFencesNV_remap_index 260
-#define GetFenceivNV_remap_index 261
-#define IsFenceNV_remap_index 262
-#define SetFenceNV_remap_index 263
-#define TestFenceNV_remap_index 264
-#define AreProgramsResidentNV_remap_index 265
-#define BindProgramNV_remap_index 266
-#define DeleteProgramsNV_remap_index 267
-#define ExecuteProgramNV_remap_index 268
-#define GenProgramsNV_remap_index 269
-#define GetProgramParameterdvNV_remap_index 270
-#define GetProgramParameterfvNV_remap_index 271
-#define GetProgramStringNV_remap_index 272
-#define GetProgramivNV_remap_index 273
-#define GetTrackMatrixivNV_remap_index 274
-#define GetVertexAttribPointervNV_remap_index 275
-#define GetVertexAttribdvNV_remap_index 276
-#define GetVertexAttribfvNV_remap_index 277
-#define GetVertexAttribivNV_remap_index 278
-#define IsProgramNV_remap_index 279
-#define LoadProgramNV_remap_index 280
-#define ProgramParameters4dvNV_remap_index 281
-#define ProgramParameters4fvNV_remap_index 282
-#define RequestResidentProgramsNV_remap_index 283
-#define TrackMatrixNV_remap_index 284
-#define VertexAttrib1dNV_remap_index 285
-#define VertexAttrib1dvNV_remap_index 286
-#define VertexAttrib1fNV_remap_index 287
-#define VertexAttrib1fvNV_remap_index 288
-#define VertexAttrib1sNV_remap_index 289
-#define VertexAttrib1svNV_remap_index 290
-#define VertexAttrib2dNV_remap_index 291
-#define VertexAttrib2dvNV_remap_index 292
-#define VertexAttrib2fNV_remap_index 293
-#define VertexAttrib2fvNV_remap_index 294
-#define VertexAttrib2sNV_remap_index 295
-#define VertexAttrib2svNV_remap_index 296
-#define VertexAttrib3dNV_remap_index 297
-#define VertexAttrib3dvNV_remap_index 298
-#define VertexAttrib3fNV_remap_index 299
-#define VertexAttrib3fvNV_remap_index 300
-#define VertexAttrib3sNV_remap_index 301
-#define VertexAttrib3svNV_remap_index 302
-#define VertexAttrib4dNV_remap_index 303
-#define VertexAttrib4dvNV_remap_index 304
-#define VertexAttrib4fNV_remap_index 305
-#define VertexAttrib4fvNV_remap_index 306
-#define VertexAttrib4sNV_remap_index 307
-#define VertexAttrib4svNV_remap_index 308
-#define VertexAttrib4ubNV_remap_index 309
-#define VertexAttrib4ubvNV_remap_index 310
-#define VertexAttribPointerNV_remap_index 311
-#define VertexAttribs1dvNV_remap_index 312
-#define VertexAttribs1fvNV_remap_index 313
-#define VertexAttribs1svNV_remap_index 314
-#define VertexAttribs2dvNV_remap_index 315
-#define VertexAttribs2fvNV_remap_index 316
-#define VertexAttribs2svNV_remap_index 317
-#define VertexAttribs3dvNV_remap_index 318
-#define VertexAttribs3fvNV_remap_index 319
-#define VertexAttribs3svNV_remap_index 320
-#define VertexAttribs4dvNV_remap_index 321
-#define VertexAttribs4fvNV_remap_index 322
-#define VertexAttribs4svNV_remap_index 323
-#define VertexAttribs4ubvNV_remap_index 324
-#define GetTexBumpParameterfvATI_remap_index 325
-#define GetTexBumpParameterivATI_remap_index 326
-#define TexBumpParameterfvATI_remap_index 327
-#define TexBumpParameterivATI_remap_index 328
-#define AlphaFragmentOp1ATI_remap_index 329
-#define AlphaFragmentOp2ATI_remap_index 330
-#define AlphaFragmentOp3ATI_remap_index 331
-#define BeginFragmentShaderATI_remap_index 332
-#define BindFragmentShaderATI_remap_index 333
-#define ColorFragmentOp1ATI_remap_index 334
-#define ColorFragmentOp2ATI_remap_index 335
-#define ColorFragmentOp3ATI_remap_index 336
-#define DeleteFragmentShaderATI_remap_index 337
-#define EndFragmentShaderATI_remap_index 338
-#define GenFragmentShadersATI_remap_index 339
-#define PassTexCoordATI_remap_index 340
-#define SampleMapATI_remap_index 341
-#define SetFragmentShaderConstantATI_remap_index 342
-#define PointParameteriNV_remap_index 343
-#define PointParameterivNV_remap_index 344
-#define ActiveStencilFaceEXT_remap_index 345
-#define BindVertexArrayAPPLE_remap_index 346
-#define DeleteVertexArraysAPPLE_remap_index 347
-#define GenVertexArraysAPPLE_remap_index 348
-#define IsVertexArrayAPPLE_remap_index 349
-#define GetProgramNamedParameterdvNV_remap_index 350
-#define GetProgramNamedParameterfvNV_remap_index 351
-#define ProgramNamedParameter4dNV_remap_index 352
-#define ProgramNamedParameter4dvNV_remap_index 353
-#define ProgramNamedParameter4fNV_remap_index 354
-#define ProgramNamedParameter4fvNV_remap_index 355
-#define DepthBoundsEXT_remap_index 356
-#define BlendEquationSeparateEXT_remap_index 357
-#define BindFramebufferEXT_remap_index 358
-#define BindRenderbufferEXT_remap_index 359
-#define CheckFramebufferStatusEXT_remap_index 360
-#define DeleteFramebuffersEXT_remap_index 361
-#define DeleteRenderbuffersEXT_remap_index 362
-#define FramebufferRenderbufferEXT_remap_index 363
-#define FramebufferTexture1DEXT_remap_index 364
-#define FramebufferTexture2DEXT_remap_index 365
-#define FramebufferTexture3DEXT_remap_index 366
-#define GenFramebuffersEXT_remap_index 367
-#define GenRenderbuffersEXT_remap_index 368
-#define GenerateMipmapEXT_remap_index 369
-#define GetFramebufferAttachmentParameterivEXT_remap_index 370
-#define GetRenderbufferParameterivEXT_remap_index 371
-#define IsFramebufferEXT_remap_index 372
-#define IsRenderbufferEXT_remap_index 373
-#define RenderbufferStorageEXT_remap_index 374
-#define BlitFramebufferEXT_remap_index 375
-#define BufferParameteriAPPLE_remap_index 376
-#define FlushMappedBufferRangeAPPLE_remap_index 377
-#define FramebufferTextureLayerEXT_remap_index 378
-#define ProvokingVertexEXT_remap_index 379
-#define GetTexParameterPointervAPPLE_remap_index 380
-#define TextureRangeAPPLE_remap_index 381
-#define StencilFuncSeparateATI_remap_index 382
-#define ProgramEnvParameters4fvEXT_remap_index 383
-#define ProgramLocalParameters4fvEXT_remap_index 384
-#define GetQueryObjecti64vEXT_remap_index 385
-#define GetQueryObjectui64vEXT_remap_index 386
-
-#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])
-#define SET_AttachShader(disp, fn) SET_by_offset(disp, driDispatchRemapTable[AttachShader_remap_index], fn)
-#define CALL_CreateProgram(disp, parameters) CALL_by_offset(disp, (GLuint (GLAPIENTRYP)(void)), driDispatchRemapTable[CreateProgram_remap_index], parameters)
-#define GET_CreateProgram(disp) GET_by_offset(disp, driDispatchRemapTable[CreateProgram_remap_index])
-#define SET_CreateProgram(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CreateProgram_remap_index], fn)
-#define CALL_CreateShader(disp, parameters) CALL_by_offset(disp, (GLuint (GLAPIENTRYP)(GLenum)), driDispatchRemapTable[CreateShader_remap_index], parameters)
-#define GET_CreateShader(disp) GET_by_offset(disp, driDispatchRemapTable[CreateShader_remap_index])
-#define SET_CreateShader(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CreateShader_remap_index], fn)
-#define CALL_DeleteProgram(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[DeleteProgram_remap_index], parameters)
-#define GET_DeleteProgram(disp) GET_by_offset(disp, driDispatchRemapTable[DeleteProgram_remap_index])
-#define SET_DeleteProgram(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DeleteProgram_remap_index], fn)
-#define CALL_DeleteShader(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[DeleteShader_remap_index], parameters)
-#define GET_DeleteShader(disp) GET_by_offset(disp, driDispatchRemapTable[DeleteShader_remap_index])
-#define SET_DeleteShader(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DeleteShader_remap_index], fn)
-#define CALL_DetachShader(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLuint)), driDispatchRemapTable[DetachShader_remap_index], parameters)
-#define GET_DetachShader(disp) GET_by_offset(disp, driDispatchRemapTable[DetachShader_remap_index])
-#define SET_DetachShader(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DetachShader_remap_index], fn)
-#define CALL_GetAttachedShaders(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, GLsizei *, GLuint *)), driDispatchRemapTable[GetAttachedShaders_remap_index], parameters)
-#define GET_GetAttachedShaders(disp) GET_by_offset(disp, driDispatchRemapTable[GetAttachedShaders_remap_index])
-#define SET_GetAttachedShaders(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetAttachedShaders_remap_index], fn)
-#define CALL_GetProgramInfoLog(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, GLsizei *, GLchar *)), driDispatchRemapTable[GetProgramInfoLog_remap_index], parameters)
-#define GET_GetProgramInfoLog(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramInfoLog_remap_index])
-#define SET_GetProgramInfoLog(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramInfoLog_remap_index], fn)
-#define CALL_GetProgramiv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint *)), driDispatchRemapTable[GetProgramiv_remap_index], parameters)
-#define GET_GetProgramiv(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramiv_remap_index])
-#define SET_GetProgramiv(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramiv_remap_index], fn)
-#define CALL_GetShaderInfoLog(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, GLsizei *, GLchar *)), driDispatchRemapTable[GetShaderInfoLog_remap_index], parameters)
-#define GET_GetShaderInfoLog(disp) GET_by_offset(disp, driDispatchRemapTable[GetShaderInfoLog_remap_index])
-#define SET_GetShaderInfoLog(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetShaderInfoLog_remap_index], fn)
-#define CALL_GetShaderiv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint *)), driDispatchRemapTable[GetShaderiv_remap_index], parameters)
-#define GET_GetShaderiv(disp) GET_by_offset(disp, driDispatchRemapTable[GetShaderiv_remap_index])
-#define SET_GetShaderiv(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetShaderiv_remap_index], fn)
-#define CALL_IsProgram(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[IsProgram_remap_index], parameters)
-#define GET_IsProgram(disp) GET_by_offset(disp, driDispatchRemapTable[IsProgram_remap_index])
-#define SET_IsProgram(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IsProgram_remap_index], fn)
-#define CALL_IsShader(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[IsShader_remap_index], parameters)
-#define GET_IsShader(disp) GET_by_offset(disp, driDispatchRemapTable[IsShader_remap_index])
-#define SET_IsShader(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IsShader_remap_index], fn)
-#define CALL_StencilFuncSeparate(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint, GLuint)), driDispatchRemapTable[StencilFuncSeparate_remap_index], parameters)
-#define GET_StencilFuncSeparate(disp) GET_by_offset(disp, driDispatchRemapTable[StencilFuncSeparate_remap_index])
-#define SET_StencilFuncSeparate(disp, fn) SET_by_offset(disp, driDispatchRemapTable[StencilFuncSeparate_remap_index], fn)
-#define CALL_StencilMaskSeparate(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint)), driDispatchRemapTable[StencilMaskSeparate_remap_index], parameters)
-#define GET_StencilMaskSeparate(disp) GET_by_offset(disp, driDispatchRemapTable[StencilMaskSeparate_remap_index])
-#define SET_StencilMaskSeparate(disp, fn) SET_by_offset(disp, driDispatchRemapTable[StencilMaskSeparate_remap_index], fn)
-#define CALL_StencilOpSeparate(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLenum)), driDispatchRemapTable[StencilOpSeparate_remap_index], parameters)
-#define GET_StencilOpSeparate(disp) GET_by_offset(disp, driDispatchRemapTable[StencilOpSeparate_remap_index])
-#define SET_StencilOpSeparate(disp, fn) SET_by_offset(disp, driDispatchRemapTable[StencilOpSeparate_remap_index], fn)
-#define CALL_UniformMatrix2x3fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, GLboolean, const GLfloat *)), driDispatchRemapTable[UniformMatrix2x3fv_remap_index], parameters)
-#define GET_UniformMatrix2x3fv(disp) GET_by_offset(disp, driDispatchRemapTable[UniformMatrix2x3fv_remap_index])
-#define SET_UniformMatrix2x3fv(disp, fn) SET_by_offset(disp, driDispatchRemapTable[UniformMatrix2x3fv_remap_index], fn)
-#define CALL_UniformMatrix2x4fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, GLboolean, const GLfloat *)), driDispatchRemapTable[UniformMatrix2x4fv_remap_index], parameters)
-#define GET_UniformMatrix2x4fv(disp) GET_by_offset(disp, driDispatchRemapTable[UniformMatrix2x4fv_remap_index])
-#define SET_UniformMatrix2x4fv(disp, fn) SET_by_offset(disp, driDispatchRemapTable[UniformMatrix2x4fv_remap_index], fn)
-#define CALL_UniformMatrix3x2fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, GLboolean, const GLfloat *)), driDispatchRemapTable[UniformMatrix3x2fv_remap_index], parameters)
-#define GET_UniformMatrix3x2fv(disp) GET_by_offset(disp, driDispatchRemapTable[UniformMatrix3x2fv_remap_index])
-#define SET_UniformMatrix3x2fv(disp, fn) SET_by_offset(disp, driDispatchRemapTable[UniformMatrix3x2fv_remap_index], fn)
-#define CALL_UniformMatrix3x4fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, GLboolean, const GLfloat *)), driDispatchRemapTable[UniformMatrix3x4fv_remap_index], parameters)
-#define GET_UniformMatrix3x4fv(disp) GET_by_offset(disp, driDispatchRemapTable[UniformMatrix3x4fv_remap_index])
-#define SET_UniformMatrix3x4fv(disp, fn) SET_by_offset(disp, driDispatchRemapTable[UniformMatrix3x4fv_remap_index], fn)
-#define CALL_UniformMatrix4x2fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, GLboolean, const GLfloat *)), driDispatchRemapTable[UniformMatrix4x2fv_remap_index], parameters)
-#define GET_UniformMatrix4x2fv(disp) GET_by_offset(disp, driDispatchRemapTable[UniformMatrix4x2fv_remap_index])
-#define SET_UniformMatrix4x2fv(disp, fn) SET_by_offset(disp, driDispatchRemapTable[UniformMatrix4x2fv_remap_index], fn)
-#define CALL_UniformMatrix4x3fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, GLboolean, const GLfloat *)), driDispatchRemapTable[UniformMatrix4x3fv_remap_index], parameters)
-#define GET_UniformMatrix4x3fv(disp) GET_by_offset(disp, driDispatchRemapTable[UniformMatrix4x3fv_remap_index])
-#define SET_UniformMatrix4x3fv(disp, fn) SET_by_offset(disp, driDispatchRemapTable[UniformMatrix4x3fv_remap_index], fn)
-#define CALL_LoadTransposeMatrixdARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), driDispatchRemapTable[LoadTransposeMatrixdARB_remap_index], parameters)
-#define GET_LoadTransposeMatrixdARB(disp) GET_by_offset(disp, driDispatchRemapTable[LoadTransposeMatrixdARB_remap_index])
-#define SET_LoadTransposeMatrixdARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[LoadTransposeMatrixdARB_remap_index], fn)
-#define CALL_LoadTransposeMatrixfARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), driDispatchRemapTable[LoadTransposeMatrixfARB_remap_index], parameters)
-#define GET_LoadTransposeMatrixfARB(disp) GET_by_offset(disp, driDispatchRemapTable[LoadTransposeMatrixfARB_remap_index])
-#define SET_LoadTransposeMatrixfARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[LoadTransposeMatrixfARB_remap_index], fn)
-#define CALL_MultTransposeMatrixdARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), driDispatchRemapTable[MultTransposeMatrixdARB_remap_index], parameters)
-#define GET_MultTransposeMatrixdARB(disp) GET_by_offset(disp, driDispatchRemapTable[MultTransposeMatrixdARB_remap_index])
-#define SET_MultTransposeMatrixdARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[MultTransposeMatrixdARB_remap_index], fn)
-#define CALL_MultTransposeMatrixfARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), driDispatchRemapTable[MultTransposeMatrixfARB_remap_index], parameters)
-#define GET_MultTransposeMatrixfARB(disp) GET_by_offset(disp, driDispatchRemapTable[MultTransposeMatrixfARB_remap_index])
-#define SET_MultTransposeMatrixfARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[MultTransposeMatrixfARB_remap_index], fn)
-#define CALL_SampleCoverageARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLclampf, GLboolean)), driDispatchRemapTable[SampleCoverageARB_remap_index], parameters)
-#define GET_SampleCoverageARB(disp) GET_by_offset(disp, driDispatchRemapTable[SampleCoverageARB_remap_index])
-#define SET_SampleCoverageARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SampleCoverageARB_remap_index], fn)
-#define CALL_CompressedTexImage1DARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *)), driDispatchRemapTable[CompressedTexImage1DARB_remap_index], parameters)
-#define GET_CompressedTexImage1DARB(disp) GET_by_offset(disp, driDispatchRemapTable[CompressedTexImage1DARB_remap_index])
-#define SET_CompressedTexImage1DARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CompressedTexImage1DARB_remap_index], fn)
-#define CALL_CompressedTexImage2DARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *)), driDispatchRemapTable[CompressedTexImage2DARB_remap_index], parameters)
-#define GET_CompressedTexImage2DARB(disp) GET_by_offset(disp, driDispatchRemapTable[CompressedTexImage2DARB_remap_index])
-#define SET_CompressedTexImage2DARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CompressedTexImage2DARB_remap_index], fn)
-#define CALL_CompressedTexImage3DARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *)), driDispatchRemapTable[CompressedTexImage3DARB_remap_index], parameters)
-#define GET_CompressedTexImage3DARB(disp) GET_by_offset(disp, driDispatchRemapTable[CompressedTexImage3DARB_remap_index])
-#define SET_CompressedTexImage3DARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CompressedTexImage3DARB_remap_index], fn)
-#define CALL_CompressedTexSubImage1DARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *)), driDispatchRemapTable[CompressedTexSubImage1DARB_remap_index], parameters)
-#define GET_CompressedTexSubImage1DARB(disp) GET_by_offset(disp, driDispatchRemapTable[CompressedTexSubImage1DARB_remap_index])
-#define SET_CompressedTexSubImage1DARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CompressedTexSubImage1DARB_remap_index], fn)
-#define CALL_CompressedTexSubImage2DARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *)), driDispatchRemapTable[CompressedTexSubImage2DARB_remap_index], parameters)
-#define GET_CompressedTexSubImage2DARB(disp) GET_by_offset(disp, driDispatchRemapTable[CompressedTexSubImage2DARB_remap_index])
-#define SET_CompressedTexSubImage2DARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CompressedTexSubImage2DARB_remap_index], fn)
-#define CALL_CompressedTexSubImage3DARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *)), driDispatchRemapTable[CompressedTexSubImage3DARB_remap_index], parameters)
-#define GET_CompressedTexSubImage3DARB(disp) GET_by_offset(disp, driDispatchRemapTable[CompressedTexSubImage3DARB_remap_index])
-#define SET_CompressedTexSubImage3DARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CompressedTexSubImage3DARB_remap_index], fn)
-#define CALL_GetCompressedTexImageARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLvoid *)), driDispatchRemapTable[GetCompressedTexImageARB_remap_index], parameters)
-#define GET_GetCompressedTexImageARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetCompressedTexImageARB_remap_index])
-#define SET_GetCompressedTexImageARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetCompressedTexImageARB_remap_index], fn)
-#define CALL_DisableVertexAttribArrayARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[DisableVertexAttribArrayARB_remap_index], parameters)
-#define GET_DisableVertexAttribArrayARB(disp) GET_by_offset(disp, driDispatchRemapTable[DisableVertexAttribArrayARB_remap_index])
-#define SET_DisableVertexAttribArrayARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DisableVertexAttribArrayARB_remap_index], fn)
-#define CALL_EnableVertexAttribArrayARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[EnableVertexAttribArrayARB_remap_index], parameters)
-#define GET_EnableVertexAttribArrayARB(disp) GET_by_offset(disp, driDispatchRemapTable[EnableVertexAttribArrayARB_remap_index])
-#define SET_EnableVertexAttribArrayARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[EnableVertexAttribArrayARB_remap_index], fn)
-#define CALL_GetProgramEnvParameterdvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLdouble *)), driDispatchRemapTable[GetProgramEnvParameterdvARB_remap_index], parameters)
-#define GET_GetProgramEnvParameterdvARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramEnvParameterdvARB_remap_index])
-#define SET_GetProgramEnvParameterdvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramEnvParameterdvARB_remap_index], fn)
-#define CALL_GetProgramEnvParameterfvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLfloat *)), driDispatchRemapTable[GetProgramEnvParameterfvARB_remap_index], parameters)
-#define GET_GetProgramEnvParameterfvARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramEnvParameterfvARB_remap_index])
-#define SET_GetProgramEnvParameterfvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramEnvParameterfvARB_remap_index], fn)
-#define CALL_GetProgramLocalParameterdvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLdouble *)), driDispatchRemapTable[GetProgramLocalParameterdvARB_remap_index], parameters)
-#define GET_GetProgramLocalParameterdvARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramLocalParameterdvARB_remap_index])
-#define SET_GetProgramLocalParameterdvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramLocalParameterdvARB_remap_index], fn)
-#define CALL_GetProgramLocalParameterfvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLfloat *)), driDispatchRemapTable[GetProgramLocalParameterfvARB_remap_index], parameters)
-#define GET_GetProgramLocalParameterfvARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramLocalParameterfvARB_remap_index])
-#define SET_GetProgramLocalParameterfvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramLocalParameterfvARB_remap_index], fn)
-#define CALL_GetProgramStringARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLvoid *)), driDispatchRemapTable[GetProgramStringARB_remap_index], parameters)
-#define GET_GetProgramStringARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramStringARB_remap_index])
-#define SET_GetProgramStringARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramStringARB_remap_index], fn)
-#define CALL_GetProgramivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), driDispatchRemapTable[GetProgramivARB_remap_index], parameters)
-#define GET_GetProgramivARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramivARB_remap_index])
-#define SET_GetProgramivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramivARB_remap_index], fn)
-#define CALL_GetVertexAttribdvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLdouble *)), driDispatchRemapTable[GetVertexAttribdvARB_remap_index], parameters)
-#define GET_GetVertexAttribdvARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetVertexAttribdvARB_remap_index])
-#define SET_GetVertexAttribdvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetVertexAttribdvARB_remap_index], fn)
-#define CALL_GetVertexAttribfvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLfloat *)), driDispatchRemapTable[GetVertexAttribfvARB_remap_index], parameters)
-#define GET_GetVertexAttribfvARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetVertexAttribfvARB_remap_index])
-#define SET_GetVertexAttribfvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetVertexAttribfvARB_remap_index], fn)
-#define CALL_GetVertexAttribivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint *)), driDispatchRemapTable[GetVertexAttribivARB_remap_index], parameters)
-#define GET_GetVertexAttribivARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetVertexAttribivARB_remap_index])
-#define SET_GetVertexAttribivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetVertexAttribivARB_remap_index], fn)
-#define CALL_ProgramEnvParameter4dARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble)), driDispatchRemapTable[ProgramEnvParameter4dARB_remap_index], parameters)
-#define GET_ProgramEnvParameter4dARB(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramEnvParameter4dARB_remap_index])
-#define SET_ProgramEnvParameter4dARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramEnvParameter4dARB_remap_index], fn)
-#define CALL_ProgramEnvParameter4dvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, const GLdouble *)), driDispatchRemapTable[ProgramEnvParameter4dvARB_remap_index], parameters)
-#define GET_ProgramEnvParameter4dvARB(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramEnvParameter4dvARB_remap_index])
-#define SET_ProgramEnvParameter4dvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramEnvParameter4dvARB_remap_index], fn)
-#define CALL_ProgramEnvParameter4fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[ProgramEnvParameter4fARB_remap_index], parameters)
-#define GET_ProgramEnvParameter4fARB(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramEnvParameter4fARB_remap_index])
-#define SET_ProgramEnvParameter4fARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramEnvParameter4fARB_remap_index], fn)
-#define CALL_ProgramEnvParameter4fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, const GLfloat *)), driDispatchRemapTable[ProgramEnvParameter4fvARB_remap_index], parameters)
-#define GET_ProgramEnvParameter4fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramEnvParameter4fvARB_remap_index])
-#define SET_ProgramEnvParameter4fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramEnvParameter4fvARB_remap_index], fn)
-#define CALL_ProgramLocalParameter4dARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble)), driDispatchRemapTable[ProgramLocalParameter4dARB_remap_index], parameters)
-#define GET_ProgramLocalParameter4dARB(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramLocalParameter4dARB_remap_index])
-#define SET_ProgramLocalParameter4dARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramLocalParameter4dARB_remap_index], fn)
-#define CALL_ProgramLocalParameter4dvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, const GLdouble *)), driDispatchRemapTable[ProgramLocalParameter4dvARB_remap_index], parameters)
-#define GET_ProgramLocalParameter4dvARB(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramLocalParameter4dvARB_remap_index])
-#define SET_ProgramLocalParameter4dvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramLocalParameter4dvARB_remap_index], fn)
-#define CALL_ProgramLocalParameter4fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[ProgramLocalParameter4fARB_remap_index], parameters)
-#define GET_ProgramLocalParameter4fARB(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramLocalParameter4fARB_remap_index])
-#define SET_ProgramLocalParameter4fARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramLocalParameter4fARB_remap_index], fn)
-#define CALL_ProgramLocalParameter4fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, const GLfloat *)), driDispatchRemapTable[ProgramLocalParameter4fvARB_remap_index], parameters)
-#define GET_ProgramLocalParameter4fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramLocalParameter4fvARB_remap_index])
-#define SET_ProgramLocalParameter4fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramLocalParameter4fvARB_remap_index], fn)
-#define CALL_ProgramStringARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLsizei, const GLvoid *)), driDispatchRemapTable[ProgramStringARB_remap_index], parameters)
-#define GET_ProgramStringARB(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramStringARB_remap_index])
-#define SET_ProgramStringARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramStringARB_remap_index], fn)
-#define CALL_VertexAttrib1dARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLdouble)), driDispatchRemapTable[VertexAttrib1dARB_remap_index], parameters)
-#define GET_VertexAttrib1dARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1dARB_remap_index])
-#define SET_VertexAttrib1dARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1dARB_remap_index], fn)
-#define CALL_VertexAttrib1dvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLdouble *)), driDispatchRemapTable[VertexAttrib1dvARB_remap_index], parameters)
-#define GET_VertexAttrib1dvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1dvARB_remap_index])
-#define SET_VertexAttrib1dvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1dvARB_remap_index], fn)
-#define CALL_VertexAttrib1fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLfloat)), driDispatchRemapTable[VertexAttrib1fARB_remap_index], parameters)
-#define GET_VertexAttrib1fARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1fARB_remap_index])
-#define SET_VertexAttrib1fARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1fARB_remap_index], fn)
-#define CALL_VertexAttrib1fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), driDispatchRemapTable[VertexAttrib1fvARB_remap_index], parameters)
-#define GET_VertexAttrib1fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1fvARB_remap_index])
-#define SET_VertexAttrib1fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1fvARB_remap_index], fn)
-#define CALL_VertexAttrib1sARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLshort)), driDispatchRemapTable[VertexAttrib1sARB_remap_index], parameters)
-#define GET_VertexAttrib1sARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1sARB_remap_index])
-#define SET_VertexAttrib1sARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1sARB_remap_index], fn)
-#define CALL_VertexAttrib1svARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), driDispatchRemapTable[VertexAttrib1svARB_remap_index], parameters)
-#define GET_VertexAttrib1svARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1svARB_remap_index])
-#define SET_VertexAttrib1svARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1svARB_remap_index], fn)
-#define CALL_VertexAttrib2dARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLdouble, GLdouble)), driDispatchRemapTable[VertexAttrib2dARB_remap_index], parameters)
-#define GET_VertexAttrib2dARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2dARB_remap_index])
-#define SET_VertexAttrib2dARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2dARB_remap_index], fn)
-#define CALL_VertexAttrib2dvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLdouble *)), driDispatchRemapTable[VertexAttrib2dvARB_remap_index], parameters)
-#define GET_VertexAttrib2dvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2dvARB_remap_index])
-#define SET_VertexAttrib2dvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2dvARB_remap_index], fn)
-#define CALL_VertexAttrib2fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLfloat, GLfloat)), driDispatchRemapTable[VertexAttrib2fARB_remap_index], parameters)
-#define GET_VertexAttrib2fARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2fARB_remap_index])
-#define SET_VertexAttrib2fARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2fARB_remap_index], fn)
-#define CALL_VertexAttrib2fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), driDispatchRemapTable[VertexAttrib2fvARB_remap_index], parameters)
-#define GET_VertexAttrib2fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2fvARB_remap_index])
-#define SET_VertexAttrib2fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2fvARB_remap_index], fn)
-#define CALL_VertexAttrib2sARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLshort, GLshort)), driDispatchRemapTable[VertexAttrib2sARB_remap_index], parameters)
-#define GET_VertexAttrib2sARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2sARB_remap_index])
-#define SET_VertexAttrib2sARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2sARB_remap_index], fn)
-#define CALL_VertexAttrib2svARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), driDispatchRemapTable[VertexAttrib2svARB_remap_index], parameters)
-#define GET_VertexAttrib2svARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2svARB_remap_index])
-#define SET_VertexAttrib2svARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2svARB_remap_index], fn)
-#define CALL_VertexAttrib3dARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLdouble, GLdouble, GLdouble)), driDispatchRemapTable[VertexAttrib3dARB_remap_index], parameters)
-#define GET_VertexAttrib3dARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3dARB_remap_index])
-#define SET_VertexAttrib3dARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3dARB_remap_index], fn)
-#define CALL_VertexAttrib3dvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLdouble *)), driDispatchRemapTable[VertexAttrib3dvARB_remap_index], parameters)
-#define GET_VertexAttrib3dvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3dvARB_remap_index])
-#define SET_VertexAttrib3dvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3dvARB_remap_index], fn)
-#define CALL_VertexAttrib3fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[VertexAttrib3fARB_remap_index], parameters)
-#define GET_VertexAttrib3fARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3fARB_remap_index])
-#define SET_VertexAttrib3fARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3fARB_remap_index], fn)
-#define CALL_VertexAttrib3fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), driDispatchRemapTable[VertexAttrib3fvARB_remap_index], parameters)
-#define GET_VertexAttrib3fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3fvARB_remap_index])
-#define SET_VertexAttrib3fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3fvARB_remap_index], fn)
-#define CALL_VertexAttrib3sARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLshort, GLshort, GLshort)), driDispatchRemapTable[VertexAttrib3sARB_remap_index], parameters)
-#define GET_VertexAttrib3sARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3sARB_remap_index])
-#define SET_VertexAttrib3sARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3sARB_remap_index], fn)
-#define CALL_VertexAttrib3svARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), driDispatchRemapTable[VertexAttrib3svARB_remap_index], parameters)
-#define GET_VertexAttrib3svARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3svARB_remap_index])
-#define SET_VertexAttrib3svARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3svARB_remap_index], fn)
-#define CALL_VertexAttrib4NbvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLbyte *)), driDispatchRemapTable[VertexAttrib4NbvARB_remap_index], parameters)
-#define GET_VertexAttrib4NbvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NbvARB_remap_index])
-#define SET_VertexAttrib4NbvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NbvARB_remap_index], fn)
-#define CALL_VertexAttrib4NivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLint *)), driDispatchRemapTable[VertexAttrib4NivARB_remap_index], parameters)
-#define GET_VertexAttrib4NivARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NivARB_remap_index])
-#define SET_VertexAttrib4NivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NivARB_remap_index], fn)
-#define CALL_VertexAttrib4NsvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), driDispatchRemapTable[VertexAttrib4NsvARB_remap_index], parameters)
-#define GET_VertexAttrib4NsvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NsvARB_remap_index])
-#define SET_VertexAttrib4NsvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NsvARB_remap_index], fn)
-#define CALL_VertexAttrib4NubARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte)), driDispatchRemapTable[VertexAttrib4NubARB_remap_index], parameters)
-#define GET_VertexAttrib4NubARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NubARB_remap_index])
-#define SET_VertexAttrib4NubARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NubARB_remap_index], fn)
-#define CALL_VertexAttrib4NubvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLubyte *)), driDispatchRemapTable[VertexAttrib4NubvARB_remap_index], parameters)
-#define GET_VertexAttrib4NubvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NubvARB_remap_index])
-#define SET_VertexAttrib4NubvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NubvARB_remap_index], fn)
-#define CALL_VertexAttrib4NuivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLuint *)), driDispatchRemapTable[VertexAttrib4NuivARB_remap_index], parameters)
-#define GET_VertexAttrib4NuivARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NuivARB_remap_index])
-#define SET_VertexAttrib4NuivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NuivARB_remap_index], fn)
-#define CALL_VertexAttrib4NusvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLushort *)), driDispatchRemapTable[VertexAttrib4NusvARB_remap_index], parameters)
-#define GET_VertexAttrib4NusvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NusvARB_remap_index])
-#define SET_VertexAttrib4NusvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NusvARB_remap_index], fn)
-#define CALL_VertexAttrib4bvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLbyte *)), driDispatchRemapTable[VertexAttrib4bvARB_remap_index], parameters)
-#define GET_VertexAttrib4bvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4bvARB_remap_index])
-#define SET_VertexAttrib4bvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4bvARB_remap_index], fn)
-#define CALL_VertexAttrib4dARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble)), driDispatchRemapTable[VertexAttrib4dARB_remap_index], parameters)
-#define GET_VertexAttrib4dARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4dARB_remap_index])
-#define SET_VertexAttrib4dARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4dARB_remap_index], fn)
-#define CALL_VertexAttrib4dvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLdouble *)), driDispatchRemapTable[VertexAttrib4dvARB_remap_index], parameters)
-#define GET_VertexAttrib4dvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4dvARB_remap_index])
-#define SET_VertexAttrib4dvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4dvARB_remap_index], fn)
-#define CALL_VertexAttrib4fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[VertexAttrib4fARB_remap_index], parameters)
-#define GET_VertexAttrib4fARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4fARB_remap_index])
-#define SET_VertexAttrib4fARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4fARB_remap_index], fn)
-#define CALL_VertexAttrib4fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), driDispatchRemapTable[VertexAttrib4fvARB_remap_index], parameters)
-#define GET_VertexAttrib4fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4fvARB_remap_index])
-#define SET_VertexAttrib4fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4fvARB_remap_index], fn)
-#define CALL_VertexAttrib4ivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLint *)), driDispatchRemapTable[VertexAttrib4ivARB_remap_index], parameters)
-#define GET_VertexAttrib4ivARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4ivARB_remap_index])
-#define SET_VertexAttrib4ivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4ivARB_remap_index], fn)
-#define CALL_VertexAttrib4sARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLshort, GLshort, GLshort, GLshort)), driDispatchRemapTable[VertexAttrib4sARB_remap_index], parameters)
-#define GET_VertexAttrib4sARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4sARB_remap_index])
-#define SET_VertexAttrib4sARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4sARB_remap_index], fn)
-#define CALL_VertexAttrib4svARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), driDispatchRemapTable[VertexAttrib4svARB_remap_index], parameters)
-#define GET_VertexAttrib4svARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4svARB_remap_index])
-#define SET_VertexAttrib4svARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4svARB_remap_index], fn)
-#define CALL_VertexAttrib4ubvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLubyte *)), driDispatchRemapTable[VertexAttrib4ubvARB_remap_index], parameters)
-#define GET_VertexAttrib4ubvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4ubvARB_remap_index])
-#define SET_VertexAttrib4ubvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4ubvARB_remap_index], fn)
-#define CALL_VertexAttrib4uivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLuint *)), driDispatchRemapTable[VertexAttrib4uivARB_remap_index], parameters)
-#define GET_VertexAttrib4uivARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4uivARB_remap_index])
-#define SET_VertexAttrib4uivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4uivARB_remap_index], fn)
-#define CALL_VertexAttrib4usvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLushort *)), driDispatchRemapTable[VertexAttrib4usvARB_remap_index], parameters)
-#define GET_VertexAttrib4usvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4usvARB_remap_index])
-#define SET_VertexAttrib4usvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4usvARB_remap_index], fn)
-#define CALL_VertexAttribPointerARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *)), driDispatchRemapTable[VertexAttribPointerARB_remap_index], parameters)
-#define GET_VertexAttribPointerARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribPointerARB_remap_index])
-#define SET_VertexAttribPointerARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribPointerARB_remap_index], fn)
-#define CALL_BindBufferARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint)), driDispatchRemapTable[BindBufferARB_remap_index], parameters)
-#define GET_BindBufferARB(disp) GET_by_offset(disp, driDispatchRemapTable[BindBufferARB_remap_index])
-#define SET_BindBufferARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BindBufferARB_remap_index], fn)
-#define CALL_BufferDataARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizeiptrARB, const GLvoid *, GLenum)), driDispatchRemapTable[BufferDataARB_remap_index], parameters)
-#define GET_BufferDataARB(disp) GET_by_offset(disp, driDispatchRemapTable[BufferDataARB_remap_index])
-#define SET_BufferDataARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BufferDataARB_remap_index], fn)
-#define CALL_BufferSubDataARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLintptrARB, GLsizeiptrARB, const GLvoid *)), driDispatchRemapTable[BufferSubDataARB_remap_index], parameters)
-#define GET_BufferSubDataARB(disp) GET_by_offset(disp, driDispatchRemapTable[BufferSubDataARB_remap_index])
-#define SET_BufferSubDataARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BufferSubDataARB_remap_index], fn)
-#define CALL_DeleteBuffersARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), driDispatchRemapTable[DeleteBuffersARB_remap_index], parameters)
-#define GET_DeleteBuffersARB(disp) GET_by_offset(disp, driDispatchRemapTable[DeleteBuffersARB_remap_index])
-#define SET_DeleteBuffersARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DeleteBuffersARB_remap_index], fn)
-#define CALL_GenBuffersARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), driDispatchRemapTable[GenBuffersARB_remap_index], parameters)
-#define GET_GenBuffersARB(disp) GET_by_offset(disp, driDispatchRemapTable[GenBuffersARB_remap_index])
-#define SET_GenBuffersARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GenBuffersARB_remap_index], fn)
-#define CALL_GetBufferParameterivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), driDispatchRemapTable[GetBufferParameterivARB_remap_index], parameters)
-#define GET_GetBufferParameterivARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetBufferParameterivARB_remap_index])
-#define SET_GetBufferParameterivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetBufferParameterivARB_remap_index], fn)
-#define CALL_GetBufferPointervARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLvoid **)), driDispatchRemapTable[GetBufferPointervARB_remap_index], parameters)
-#define GET_GetBufferPointervARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetBufferPointervARB_remap_index])
-#define SET_GetBufferPointervARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetBufferPointervARB_remap_index], fn)
-#define CALL_GetBufferSubDataARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLintptrARB, GLsizeiptrARB, GLvoid *)), driDispatchRemapTable[GetBufferSubDataARB_remap_index], parameters)
-#define GET_GetBufferSubDataARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetBufferSubDataARB_remap_index])
-#define SET_GetBufferSubDataARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetBufferSubDataARB_remap_index], fn)
-#define CALL_IsBufferARB(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[IsBufferARB_remap_index], parameters)
-#define GET_IsBufferARB(disp) GET_by_offset(disp, driDispatchRemapTable[IsBufferARB_remap_index])
-#define SET_IsBufferARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IsBufferARB_remap_index], fn)
-#define CALL_MapBufferARB(disp, parameters) CALL_by_offset(disp, (GLvoid * (GLAPIENTRYP)(GLenum, GLenum)), driDispatchRemapTable[MapBufferARB_remap_index], parameters)
-#define GET_MapBufferARB(disp) GET_by_offset(disp, driDispatchRemapTable[MapBufferARB_remap_index])
-#define SET_MapBufferARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[MapBufferARB_remap_index], fn)
-#define CALL_UnmapBufferARB(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLenum)), driDispatchRemapTable[UnmapBufferARB_remap_index], parameters)
-#define GET_UnmapBufferARB(disp) GET_by_offset(disp, driDispatchRemapTable[UnmapBufferARB_remap_index])
-#define SET_UnmapBufferARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[UnmapBufferARB_remap_index], fn)
-#define CALL_BeginQueryARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint)), driDispatchRemapTable[BeginQueryARB_remap_index], parameters)
-#define GET_BeginQueryARB(disp) GET_by_offset(disp, driDispatchRemapTable[BeginQueryARB_remap_index])
-#define SET_BeginQueryARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BeginQueryARB_remap_index], fn)
-#define CALL_DeleteQueriesARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), driDispatchRemapTable[DeleteQueriesARB_remap_index], parameters)
-#define GET_DeleteQueriesARB(disp) GET_by_offset(disp, driDispatchRemapTable[DeleteQueriesARB_remap_index])
-#define SET_DeleteQueriesARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DeleteQueriesARB_remap_index], fn)
-#define CALL_EndQueryARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), driDispatchRemapTable[EndQueryARB_remap_index], parameters)
-#define GET_EndQueryARB(disp) GET_by_offset(disp, driDispatchRemapTable[EndQueryARB_remap_index])
-#define SET_EndQueryARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[EndQueryARB_remap_index], fn)
-#define CALL_GenQueriesARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), driDispatchRemapTable[GenQueriesARB_remap_index], parameters)
-#define GET_GenQueriesARB(disp) GET_by_offset(disp, driDispatchRemapTable[GenQueriesARB_remap_index])
-#define SET_GenQueriesARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GenQueriesARB_remap_index], fn)
-#define CALL_GetQueryObjectivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint *)), driDispatchRemapTable[GetQueryObjectivARB_remap_index], parameters)
-#define GET_GetQueryObjectivARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetQueryObjectivARB_remap_index])
-#define SET_GetQueryObjectivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetQueryObjectivARB_remap_index], fn)
-#define CALL_GetQueryObjectuivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLuint *)), driDispatchRemapTable[GetQueryObjectuivARB_remap_index], parameters)
-#define GET_GetQueryObjectuivARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetQueryObjectuivARB_remap_index])
-#define SET_GetQueryObjectuivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetQueryObjectuivARB_remap_index], fn)
-#define CALL_GetQueryivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), driDispatchRemapTable[GetQueryivARB_remap_index], parameters)
-#define GET_GetQueryivARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetQueryivARB_remap_index])
-#define SET_GetQueryivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetQueryivARB_remap_index], fn)
-#define CALL_IsQueryARB(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[IsQueryARB_remap_index], parameters)
-#define GET_IsQueryARB(disp) GET_by_offset(disp, driDispatchRemapTable[IsQueryARB_remap_index])
-#define SET_IsQueryARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IsQueryARB_remap_index], fn)
-#define CALL_AttachObjectARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLhandleARB)), driDispatchRemapTable[AttachObjectARB_remap_index], parameters)
-#define GET_AttachObjectARB(disp) GET_by_offset(disp, driDispatchRemapTable[AttachObjectARB_remap_index])
-#define SET_AttachObjectARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[AttachObjectARB_remap_index], fn)
-#define CALL_CompileShaderARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB)), driDispatchRemapTable[CompileShaderARB_remap_index], parameters)
-#define GET_CompileShaderARB(disp) GET_by_offset(disp, driDispatchRemapTable[CompileShaderARB_remap_index])
-#define SET_CompileShaderARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CompileShaderARB_remap_index], fn)
-#define CALL_CreateProgramObjectARB(disp, parameters) CALL_by_offset(disp, (GLhandleARB (GLAPIENTRYP)(void)), driDispatchRemapTable[CreateProgramObjectARB_remap_index], parameters)
-#define GET_CreateProgramObjectARB(disp) GET_by_offset(disp, driDispatchRemapTable[CreateProgramObjectARB_remap_index])
-#define SET_CreateProgramObjectARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CreateProgramObjectARB_remap_index], fn)
-#define CALL_CreateShaderObjectARB(disp, parameters) CALL_by_offset(disp, (GLhandleARB (GLAPIENTRYP)(GLenum)), driDispatchRemapTable[CreateShaderObjectARB_remap_index], parameters)
-#define GET_CreateShaderObjectARB(disp) GET_by_offset(disp, driDispatchRemapTable[CreateShaderObjectARB_remap_index])
-#define SET_CreateShaderObjectARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CreateShaderObjectARB_remap_index], fn)
-#define CALL_DeleteObjectARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB)), driDispatchRemapTable[DeleteObjectARB_remap_index], parameters)
-#define GET_DeleteObjectARB(disp) GET_by_offset(disp, driDispatchRemapTable[DeleteObjectARB_remap_index])
-#define SET_DeleteObjectARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DeleteObjectARB_remap_index], fn)
-#define CALL_DetachObjectARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLhandleARB)), driDispatchRemapTable[DetachObjectARB_remap_index], parameters)
-#define GET_DetachObjectARB(disp) GET_by_offset(disp, driDispatchRemapTable[DetachObjectARB_remap_index])
-#define SET_DetachObjectARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DetachObjectARB_remap_index], fn)
-#define CALL_GetActiveUniformARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *)), driDispatchRemapTable[GetActiveUniformARB_remap_index], parameters)
-#define GET_GetActiveUniformARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetActiveUniformARB_remap_index])
-#define SET_GetActiveUniformARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetActiveUniformARB_remap_index], fn)
-#define CALL_GetAttachedObjectsARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLsizei, GLsizei *, GLhandleARB *)), driDispatchRemapTable[GetAttachedObjectsARB_remap_index], parameters)
-#define GET_GetAttachedObjectsARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetAttachedObjectsARB_remap_index])
-#define SET_GetAttachedObjectsARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetAttachedObjectsARB_remap_index], fn)
-#define CALL_GetHandleARB(disp, parameters) CALL_by_offset(disp, (GLhandleARB (GLAPIENTRYP)(GLenum)), driDispatchRemapTable[GetHandleARB_remap_index], parameters)
-#define GET_GetHandleARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetHandleARB_remap_index])
-#define SET_GetHandleARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetHandleARB_remap_index], fn)
-#define CALL_GetInfoLogARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLsizei, GLsizei *, GLcharARB *)), driDispatchRemapTable[GetInfoLogARB_remap_index], parameters)
-#define GET_GetInfoLogARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetInfoLogARB_remap_index])
-#define SET_GetInfoLogARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetInfoLogARB_remap_index], fn)
-#define CALL_GetObjectParameterfvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLenum, GLfloat *)), driDispatchRemapTable[GetObjectParameterfvARB_remap_index], parameters)
-#define GET_GetObjectParameterfvARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetObjectParameterfvARB_remap_index])
-#define SET_GetObjectParameterfvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetObjectParameterfvARB_remap_index], fn)
-#define CALL_GetObjectParameterivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLenum, GLint *)), driDispatchRemapTable[GetObjectParameterivARB_remap_index], parameters)
-#define GET_GetObjectParameterivARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetObjectParameterivARB_remap_index])
-#define SET_GetObjectParameterivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetObjectParameterivARB_remap_index], fn)
-#define CALL_GetShaderSourceARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLsizei, GLsizei *, GLcharARB *)), driDispatchRemapTable[GetShaderSourceARB_remap_index], parameters)
-#define GET_GetShaderSourceARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetShaderSourceARB_remap_index])
-#define SET_GetShaderSourceARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetShaderSourceARB_remap_index], fn)
-#define CALL_GetUniformLocationARB(disp, parameters) CALL_by_offset(disp, (GLint (GLAPIENTRYP)(GLhandleARB, const GLcharARB *)), driDispatchRemapTable[GetUniformLocationARB_remap_index], parameters)
-#define GET_GetUniformLocationARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetUniformLocationARB_remap_index])
-#define SET_GetUniformLocationARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetUniformLocationARB_remap_index], fn)
-#define CALL_GetUniformfvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLint, GLfloat *)), driDispatchRemapTable[GetUniformfvARB_remap_index], parameters)
-#define GET_GetUniformfvARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetUniformfvARB_remap_index])
-#define SET_GetUniformfvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetUniformfvARB_remap_index], fn)
-#define CALL_GetUniformivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLint, GLint *)), driDispatchRemapTable[GetUniformivARB_remap_index], parameters)
-#define GET_GetUniformivARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetUniformivARB_remap_index])
-#define SET_GetUniformivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetUniformivARB_remap_index], fn)
-#define CALL_LinkProgramARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB)), driDispatchRemapTable[LinkProgramARB_remap_index], parameters)
-#define GET_LinkProgramARB(disp) GET_by_offset(disp, driDispatchRemapTable[LinkProgramARB_remap_index])
-#define SET_LinkProgramARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[LinkProgramARB_remap_index], fn)
-#define CALL_ShaderSourceARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLsizei, const GLcharARB **, const GLint *)), driDispatchRemapTable[ShaderSourceARB_remap_index], parameters)
-#define GET_ShaderSourceARB(disp) GET_by_offset(disp, driDispatchRemapTable[ShaderSourceARB_remap_index])
-#define SET_ShaderSourceARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ShaderSourceARB_remap_index], fn)
-#define CALL_Uniform1fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLfloat)), driDispatchRemapTable[Uniform1fARB_remap_index], parameters)
-#define GET_Uniform1fARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform1fARB_remap_index])
-#define SET_Uniform1fARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform1fARB_remap_index], fn)
-#define CALL_Uniform1fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLfloat *)), driDispatchRemapTable[Uniform1fvARB_remap_index], parameters)
-#define GET_Uniform1fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform1fvARB_remap_index])
-#define SET_Uniform1fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform1fvARB_remap_index], fn)
-#define CALL_Uniform1iARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint)), driDispatchRemapTable[Uniform1iARB_remap_index], parameters)
-#define GET_Uniform1iARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform1iARB_remap_index])
-#define SET_Uniform1iARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform1iARB_remap_index], fn)
-#define CALL_Uniform1ivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLint *)), driDispatchRemapTable[Uniform1ivARB_remap_index], parameters)
-#define GET_Uniform1ivARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform1ivARB_remap_index])
-#define SET_Uniform1ivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform1ivARB_remap_index], fn)
-#define CALL_Uniform2fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLfloat, GLfloat)), driDispatchRemapTable[Uniform2fARB_remap_index], parameters)
-#define GET_Uniform2fARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform2fARB_remap_index])
-#define SET_Uniform2fARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform2fARB_remap_index], fn)
-#define CALL_Uniform2fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLfloat *)), driDispatchRemapTable[Uniform2fvARB_remap_index], parameters)
-#define GET_Uniform2fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform2fvARB_remap_index])
-#define SET_Uniform2fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform2fvARB_remap_index], fn)
-#define CALL_Uniform2iARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint)), driDispatchRemapTable[Uniform2iARB_remap_index], parameters)
-#define GET_Uniform2iARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform2iARB_remap_index])
-#define SET_Uniform2iARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform2iARB_remap_index], fn)
-#define CALL_Uniform2ivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLint *)), driDispatchRemapTable[Uniform2ivARB_remap_index], parameters)
-#define GET_Uniform2ivARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform2ivARB_remap_index])
-#define SET_Uniform2ivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform2ivARB_remap_index], fn)
-#define CALL_Uniform3fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[Uniform3fARB_remap_index], parameters)
-#define GET_Uniform3fARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform3fARB_remap_index])
-#define SET_Uniform3fARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform3fARB_remap_index], fn)
-#define CALL_Uniform3fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLfloat *)), driDispatchRemapTable[Uniform3fvARB_remap_index], parameters)
-#define GET_Uniform3fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform3fvARB_remap_index])
-#define SET_Uniform3fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform3fvARB_remap_index], fn)
-#define CALL_Uniform3iARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint, GLint)), driDispatchRemapTable[Uniform3iARB_remap_index], parameters)
-#define GET_Uniform3iARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform3iARB_remap_index])
-#define SET_Uniform3iARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform3iARB_remap_index], fn)
-#define CALL_Uniform3ivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLint *)), driDispatchRemapTable[Uniform3ivARB_remap_index], parameters)
-#define GET_Uniform3ivARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform3ivARB_remap_index])
-#define SET_Uniform3ivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform3ivARB_remap_index], fn)
-#define CALL_Uniform4fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLfloat, GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[Uniform4fARB_remap_index], parameters)
-#define GET_Uniform4fARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform4fARB_remap_index])
-#define SET_Uniform4fARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform4fARB_remap_index], fn)
-#define CALL_Uniform4fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLfloat *)), driDispatchRemapTable[Uniform4fvARB_remap_index], parameters)
-#define GET_Uniform4fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform4fvARB_remap_index])
-#define SET_Uniform4fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform4fvARB_remap_index], fn)
-#define CALL_Uniform4iARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint, GLint, GLint)), driDispatchRemapTable[Uniform4iARB_remap_index], parameters)
-#define GET_Uniform4iARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform4iARB_remap_index])
-#define SET_Uniform4iARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform4iARB_remap_index], fn)
-#define CALL_Uniform4ivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLint *)), driDispatchRemapTable[Uniform4ivARB_remap_index], parameters)
-#define GET_Uniform4ivARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform4ivARB_remap_index])
-#define SET_Uniform4ivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform4ivARB_remap_index], fn)
-#define CALL_UniformMatrix2fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, GLboolean, const GLfloat *)), driDispatchRemapTable[UniformMatrix2fvARB_remap_index], parameters)
-#define GET_UniformMatrix2fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[UniformMatrix2fvARB_remap_index])
-#define SET_UniformMatrix2fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[UniformMatrix2fvARB_remap_index], fn)
-#define CALL_UniformMatrix3fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, GLboolean, const GLfloat *)), driDispatchRemapTable[UniformMatrix3fvARB_remap_index], parameters)
-#define GET_UniformMatrix3fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[UniformMatrix3fvARB_remap_index])
-#define SET_UniformMatrix3fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[UniformMatrix3fvARB_remap_index], fn)
-#define CALL_UniformMatrix4fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, GLboolean, const GLfloat *)), driDispatchRemapTable[UniformMatrix4fvARB_remap_index], parameters)
-#define GET_UniformMatrix4fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[UniformMatrix4fvARB_remap_index])
-#define SET_UniformMatrix4fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[UniformMatrix4fvARB_remap_index], fn)
-#define CALL_UseProgramObjectARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB)), driDispatchRemapTable[UseProgramObjectARB_remap_index], parameters)
-#define GET_UseProgramObjectARB(disp) GET_by_offset(disp, driDispatchRemapTable[UseProgramObjectARB_remap_index])
-#define SET_UseProgramObjectARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[UseProgramObjectARB_remap_index], fn)
-#define CALL_ValidateProgramARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB)), driDispatchRemapTable[ValidateProgramARB_remap_index], parameters)
-#define GET_ValidateProgramARB(disp) GET_by_offset(disp, driDispatchRemapTable[ValidateProgramARB_remap_index])
-#define SET_ValidateProgramARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ValidateProgramARB_remap_index], fn)
-#define CALL_BindAttribLocationARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLuint, const GLcharARB *)), driDispatchRemapTable[BindAttribLocationARB_remap_index], parameters)
-#define GET_BindAttribLocationARB(disp) GET_by_offset(disp, driDispatchRemapTable[BindAttribLocationARB_remap_index])
-#define SET_BindAttribLocationARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BindAttribLocationARB_remap_index], fn)
-#define CALL_GetActiveAttribARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *)), driDispatchRemapTable[GetActiveAttribARB_remap_index], parameters)
-#define GET_GetActiveAttribARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetActiveAttribARB_remap_index])
-#define SET_GetActiveAttribARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetActiveAttribARB_remap_index], fn)
-#define CALL_GetAttribLocationARB(disp, parameters) CALL_by_offset(disp, (GLint (GLAPIENTRYP)(GLhandleARB, const GLcharARB *)), driDispatchRemapTable[GetAttribLocationARB_remap_index], parameters)
-#define GET_GetAttribLocationARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetAttribLocationARB_remap_index])
-#define SET_GetAttribLocationARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetAttribLocationARB_remap_index], fn)
-#define CALL_DrawBuffersARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLenum *)), driDispatchRemapTable[DrawBuffersARB_remap_index], parameters)
-#define GET_DrawBuffersARB(disp) GET_by_offset(disp, driDispatchRemapTable[DrawBuffersARB_remap_index])
-#define SET_DrawBuffersARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DrawBuffersARB_remap_index], fn)
-#define CALL_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_BindVertexArray(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[BindVertexArray_remap_index], parameters)
-#define GET_BindVertexArray(disp) GET_by_offset(disp, driDispatchRemapTable[BindVertexArray_remap_index])
-#define SET_BindVertexArray(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BindVertexArray_remap_index], fn)
-#define CALL_GenVertexArrays(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), driDispatchRemapTable[GenVertexArrays_remap_index], parameters)
-#define GET_GenVertexArrays(disp) GET_by_offset(disp, driDispatchRemapTable[GenVertexArrays_remap_index])
-#define SET_GenVertexArrays(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GenVertexArrays_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_ClientWaitSync(disp, parameters) CALL_by_offset(disp, (GLenum (GLAPIENTRYP)(GLsync, GLbitfield, GLuint64)), driDispatchRemapTable[ClientWaitSync_remap_index], parameters)
-#define GET_ClientWaitSync(disp) GET_by_offset(disp, driDispatchRemapTable[ClientWaitSync_remap_index])
-#define SET_ClientWaitSync(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ClientWaitSync_remap_index], fn)
-#define CALL_DeleteSync(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsync)), driDispatchRemapTable[DeleteSync_remap_index], parameters)
-#define GET_DeleteSync(disp) GET_by_offset(disp, driDispatchRemapTable[DeleteSync_remap_index])
-#define SET_DeleteSync(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DeleteSync_remap_index], fn)
-#define CALL_FenceSync(disp, parameters) CALL_by_offset(disp, (GLsync (GLAPIENTRYP)(GLenum, GLbitfield)), driDispatchRemapTable[FenceSync_remap_index], parameters)
-#define GET_FenceSync(disp) GET_by_offset(disp, driDispatchRemapTable[FenceSync_remap_index])
-#define SET_FenceSync(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FenceSync_remap_index], fn)
-#define CALL_GetInteger64v(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint64 *)), driDispatchRemapTable[GetInteger64v_remap_index], parameters)
-#define GET_GetInteger64v(disp) GET_by_offset(disp, driDispatchRemapTable[GetInteger64v_remap_index])
-#define SET_GetInteger64v(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetInteger64v_remap_index], fn)
-#define CALL_GetSynciv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsync, GLenum, GLsizei, GLsizei *, GLint *)), driDispatchRemapTable[GetSynciv_remap_index], parameters)
-#define GET_GetSynciv(disp) GET_by_offset(disp, driDispatchRemapTable[GetSynciv_remap_index])
-#define SET_GetSynciv(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetSynciv_remap_index], fn)
-#define CALL_IsSync(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLsync)), driDispatchRemapTable[IsSync_remap_index], parameters)
-#define GET_IsSync(disp) GET_by_offset(disp, driDispatchRemapTable[IsSync_remap_index])
-#define SET_IsSync(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IsSync_remap_index], fn)
-#define CALL_WaitSync(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsync, GLbitfield, GLuint64)), driDispatchRemapTable[WaitSync_remap_index], parameters)
-#define GET_WaitSync(disp) GET_by_offset(disp, driDispatchRemapTable[WaitSync_remap_index])
-#define SET_WaitSync(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WaitSync_remap_index], fn)
-#define CALL_DrawElementsBaseVertex(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, GLenum, const GLvoid *, GLint)), driDispatchRemapTable[DrawElementsBaseVertex_remap_index], parameters)
-#define GET_DrawElementsBaseVertex(disp) GET_by_offset(disp, driDispatchRemapTable[DrawElementsBaseVertex_remap_index])
-#define SET_DrawElementsBaseVertex(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DrawElementsBaseVertex_remap_index], fn)
-#define CALL_DrawRangeElementsBaseVertex(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *, GLint)), driDispatchRemapTable[DrawRangeElementsBaseVertex_remap_index], parameters)
-#define GET_DrawRangeElementsBaseVertex(disp) GET_by_offset(disp, driDispatchRemapTable[DrawRangeElementsBaseVertex_remap_index])
-#define SET_DrawRangeElementsBaseVertex(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DrawRangeElementsBaseVertex_remap_index], fn)
-#define CALL_MultiDrawElementsBaseVertex(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLsizei *, GLenum, const GLvoid **, GLsizei, const GLint *)), driDispatchRemapTable[MultiDrawElementsBaseVertex_remap_index], parameters)
-#define GET_MultiDrawElementsBaseVertex(disp) GET_by_offset(disp, driDispatchRemapTable[MultiDrawElementsBaseVertex_remap_index])
-#define SET_MultiDrawElementsBaseVertex(disp, fn) SET_by_offset(disp, driDispatchRemapTable[MultiDrawElementsBaseVertex_remap_index], fn)
-#define CALL_PolygonOffsetEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat)), driDispatchRemapTable[PolygonOffsetEXT_remap_index], parameters)
-#define GET_PolygonOffsetEXT(disp) GET_by_offset(disp, driDispatchRemapTable[PolygonOffsetEXT_remap_index])
-#define SET_PolygonOffsetEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PolygonOffsetEXT_remap_index], fn)
-#define CALL_GetPixelTexGenParameterfvSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat *)), driDispatchRemapTable[GetPixelTexGenParameterfvSGIS_remap_index], parameters)
-#define GET_GetPixelTexGenParameterfvSGIS(disp) GET_by_offset(disp, driDispatchRemapTable[GetPixelTexGenParameterfvSGIS_remap_index])
-#define SET_GetPixelTexGenParameterfvSGIS(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetPixelTexGenParameterfvSGIS_remap_index], fn)
-#define CALL_GetPixelTexGenParameterivSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint *)), driDispatchRemapTable[GetPixelTexGenParameterivSGIS_remap_index], parameters)
-#define GET_GetPixelTexGenParameterivSGIS(disp) GET_by_offset(disp, driDispatchRemapTable[GetPixelTexGenParameterivSGIS_remap_index])
-#define SET_GetPixelTexGenParameterivSGIS(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetPixelTexGenParameterivSGIS_remap_index], fn)
-#define CALL_PixelTexGenParameterfSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat)), driDispatchRemapTable[PixelTexGenParameterfSGIS_remap_index], parameters)
-#define GET_PixelTexGenParameterfSGIS(disp) GET_by_offset(disp, driDispatchRemapTable[PixelTexGenParameterfSGIS_remap_index])
-#define SET_PixelTexGenParameterfSGIS(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PixelTexGenParameterfSGIS_remap_index], fn)
-#define CALL_PixelTexGenParameterfvSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLfloat *)), driDispatchRemapTable[PixelTexGenParameterfvSGIS_remap_index], parameters)
-#define GET_PixelTexGenParameterfvSGIS(disp) GET_by_offset(disp, driDispatchRemapTable[PixelTexGenParameterfvSGIS_remap_index])
-#define SET_PixelTexGenParameterfvSGIS(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PixelTexGenParameterfvSGIS_remap_index], fn)
-#define CALL_PixelTexGenParameteriSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint)), driDispatchRemapTable[PixelTexGenParameteriSGIS_remap_index], parameters)
-#define GET_PixelTexGenParameteriSGIS(disp) GET_by_offset(disp, driDispatchRemapTable[PixelTexGenParameteriSGIS_remap_index])
-#define SET_PixelTexGenParameteriSGIS(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PixelTexGenParameteriSGIS_remap_index], fn)
-#define CALL_PixelTexGenParameterivSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLint *)), driDispatchRemapTable[PixelTexGenParameterivSGIS_remap_index], parameters)
-#define GET_PixelTexGenParameterivSGIS(disp) GET_by_offset(disp, driDispatchRemapTable[PixelTexGenParameterivSGIS_remap_index])
-#define SET_PixelTexGenParameterivSGIS(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PixelTexGenParameterivSGIS_remap_index], fn)
-#define CALL_SampleMaskSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLclampf, GLboolean)), driDispatchRemapTable[SampleMaskSGIS_remap_index], parameters)
-#define GET_SampleMaskSGIS(disp) GET_by_offset(disp, driDispatchRemapTable[SampleMaskSGIS_remap_index])
-#define SET_SampleMaskSGIS(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SampleMaskSGIS_remap_index], fn)
-#define CALL_SamplePatternSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), driDispatchRemapTable[SamplePatternSGIS_remap_index], parameters)
-#define GET_SamplePatternSGIS(disp) GET_by_offset(disp, driDispatchRemapTable[SamplePatternSGIS_remap_index])
-#define SET_SamplePatternSGIS(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SamplePatternSGIS_remap_index], fn)
-#define CALL_ColorPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLenum, GLsizei, GLsizei, const GLvoid *)), driDispatchRemapTable[ColorPointerEXT_remap_index], parameters)
-#define GET_ColorPointerEXT(disp) GET_by_offset(disp, driDispatchRemapTable[ColorPointerEXT_remap_index])
-#define SET_ColorPointerEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ColorPointerEXT_remap_index], fn)
-#define CALL_EdgeFlagPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLsizei, const GLboolean *)), driDispatchRemapTable[EdgeFlagPointerEXT_remap_index], parameters)
-#define GET_EdgeFlagPointerEXT(disp) GET_by_offset(disp, driDispatchRemapTable[EdgeFlagPointerEXT_remap_index])
-#define SET_EdgeFlagPointerEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[EdgeFlagPointerEXT_remap_index], fn)
-#define CALL_IndexPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, GLsizei, const GLvoid *)), driDispatchRemapTable[IndexPointerEXT_remap_index], parameters)
-#define GET_IndexPointerEXT(disp) GET_by_offset(disp, driDispatchRemapTable[IndexPointerEXT_remap_index])
-#define SET_IndexPointerEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IndexPointerEXT_remap_index], fn)
-#define CALL_NormalPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, GLsizei, const GLvoid *)), driDispatchRemapTable[NormalPointerEXT_remap_index], parameters)
-#define GET_NormalPointerEXT(disp) GET_by_offset(disp, driDispatchRemapTable[NormalPointerEXT_remap_index])
-#define SET_NormalPointerEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[NormalPointerEXT_remap_index], fn)
-#define CALL_TexCoordPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLenum, GLsizei, GLsizei, const GLvoid *)), driDispatchRemapTable[TexCoordPointerEXT_remap_index], parameters)
-#define GET_TexCoordPointerEXT(disp) GET_by_offset(disp, driDispatchRemapTable[TexCoordPointerEXT_remap_index])
-#define SET_TexCoordPointerEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[TexCoordPointerEXT_remap_index], fn)
-#define CALL_VertexPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLenum, GLsizei, GLsizei, const GLvoid *)), driDispatchRemapTable[VertexPointerEXT_remap_index], parameters)
-#define GET_VertexPointerEXT(disp) GET_by_offset(disp, driDispatchRemapTable[VertexPointerEXT_remap_index])
-#define SET_VertexPointerEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexPointerEXT_remap_index], fn)
-#define CALL_PointParameterfEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat)), driDispatchRemapTable[PointParameterfEXT_remap_index], parameters)
-#define GET_PointParameterfEXT(disp) GET_by_offset(disp, driDispatchRemapTable[PointParameterfEXT_remap_index])
-#define SET_PointParameterfEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PointParameterfEXT_remap_index], fn)
-#define CALL_PointParameterfvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLfloat *)), driDispatchRemapTable[PointParameterfvEXT_remap_index], parameters)
-#define GET_PointParameterfvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[PointParameterfvEXT_remap_index])
-#define SET_PointParameterfvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PointParameterfvEXT_remap_index], fn)
-#define CALL_LockArraysEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei)), driDispatchRemapTable[LockArraysEXT_remap_index], parameters)
-#define GET_LockArraysEXT(disp) GET_by_offset(disp, driDispatchRemapTable[LockArraysEXT_remap_index])
-#define SET_LockArraysEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[LockArraysEXT_remap_index], fn)
-#define CALL_UnlockArraysEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), driDispatchRemapTable[UnlockArraysEXT_remap_index], parameters)
-#define GET_UnlockArraysEXT(disp) GET_by_offset(disp, driDispatchRemapTable[UnlockArraysEXT_remap_index])
-#define SET_UnlockArraysEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[UnlockArraysEXT_remap_index], fn)
-#define CALL_CullParameterdvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLdouble *)), driDispatchRemapTable[CullParameterdvEXT_remap_index], parameters)
-#define GET_CullParameterdvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[CullParameterdvEXT_remap_index])
-#define SET_CullParameterdvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CullParameterdvEXT_remap_index], fn)
-#define CALL_CullParameterfvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat *)), driDispatchRemapTable[CullParameterfvEXT_remap_index], parameters)
-#define GET_CullParameterfvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[CullParameterfvEXT_remap_index])
-#define SET_CullParameterfvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CullParameterfvEXT_remap_index], fn)
-#define CALL_SecondaryColor3bEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLbyte, GLbyte, GLbyte)), driDispatchRemapTable[SecondaryColor3bEXT_remap_index], parameters)
-#define GET_SecondaryColor3bEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3bEXT_remap_index])
-#define SET_SecondaryColor3bEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3bEXT_remap_index], fn)
-#define CALL_SecondaryColor3bvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLbyte *)), driDispatchRemapTable[SecondaryColor3bvEXT_remap_index], parameters)
-#define GET_SecondaryColor3bvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3bvEXT_remap_index])
-#define SET_SecondaryColor3bvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3bvEXT_remap_index], fn)
-#define CALL_SecondaryColor3dEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble, GLdouble)), driDispatchRemapTable[SecondaryColor3dEXT_remap_index], parameters)
-#define GET_SecondaryColor3dEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3dEXT_remap_index])
-#define SET_SecondaryColor3dEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3dEXT_remap_index], fn)
-#define CALL_SecondaryColor3dvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), driDispatchRemapTable[SecondaryColor3dvEXT_remap_index], parameters)
-#define GET_SecondaryColor3dvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3dvEXT_remap_index])
-#define SET_SecondaryColor3dvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3dvEXT_remap_index], fn)
-#define CALL_SecondaryColor3fEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[SecondaryColor3fEXT_remap_index], parameters)
-#define GET_SecondaryColor3fEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3fEXT_remap_index])
-#define SET_SecondaryColor3fEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3fEXT_remap_index], fn)
-#define CALL_SecondaryColor3fvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), driDispatchRemapTable[SecondaryColor3fvEXT_remap_index], parameters)
-#define GET_SecondaryColor3fvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3fvEXT_remap_index])
-#define SET_SecondaryColor3fvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3fvEXT_remap_index], fn)
-#define CALL_SecondaryColor3iEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint)), driDispatchRemapTable[SecondaryColor3iEXT_remap_index], parameters)
-#define GET_SecondaryColor3iEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3iEXT_remap_index])
-#define SET_SecondaryColor3iEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3iEXT_remap_index], fn)
-#define CALL_SecondaryColor3ivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLint *)), driDispatchRemapTable[SecondaryColor3ivEXT_remap_index], parameters)
-#define GET_SecondaryColor3ivEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3ivEXT_remap_index])
-#define SET_SecondaryColor3ivEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3ivEXT_remap_index], fn)
-#define CALL_SecondaryColor3sEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLshort, GLshort, GLshort)), driDispatchRemapTable[SecondaryColor3sEXT_remap_index], parameters)
-#define GET_SecondaryColor3sEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3sEXT_remap_index])
-#define SET_SecondaryColor3sEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3sEXT_remap_index], fn)
-#define CALL_SecondaryColor3svEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLshort *)), driDispatchRemapTable[SecondaryColor3svEXT_remap_index], parameters)
-#define GET_SecondaryColor3svEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3svEXT_remap_index])
-#define SET_SecondaryColor3svEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3svEXT_remap_index], fn)
-#define CALL_SecondaryColor3ubEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLubyte, GLubyte, GLubyte)), driDispatchRemapTable[SecondaryColor3ubEXT_remap_index], parameters)
-#define GET_SecondaryColor3ubEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3ubEXT_remap_index])
-#define SET_SecondaryColor3ubEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3ubEXT_remap_index], fn)
-#define CALL_SecondaryColor3ubvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLubyte *)), driDispatchRemapTable[SecondaryColor3ubvEXT_remap_index], parameters)
-#define GET_SecondaryColor3ubvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3ubvEXT_remap_index])
-#define SET_SecondaryColor3ubvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3ubvEXT_remap_index], fn)
-#define CALL_SecondaryColor3uiEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLuint, GLuint)), driDispatchRemapTable[SecondaryColor3uiEXT_remap_index], parameters)
-#define GET_SecondaryColor3uiEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3uiEXT_remap_index])
-#define SET_SecondaryColor3uiEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3uiEXT_remap_index], fn)
-#define CALL_SecondaryColor3uivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLuint *)), driDispatchRemapTable[SecondaryColor3uivEXT_remap_index], parameters)
-#define GET_SecondaryColor3uivEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3uivEXT_remap_index])
-#define SET_SecondaryColor3uivEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3uivEXT_remap_index], fn)
-#define CALL_SecondaryColor3usEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLushort, GLushort, GLushort)), driDispatchRemapTable[SecondaryColor3usEXT_remap_index], parameters)
-#define GET_SecondaryColor3usEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3usEXT_remap_index])
-#define SET_SecondaryColor3usEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3usEXT_remap_index], fn)
-#define CALL_SecondaryColor3usvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLushort *)), driDispatchRemapTable[SecondaryColor3usvEXT_remap_index], parameters)
-#define GET_SecondaryColor3usvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3usvEXT_remap_index])
-#define SET_SecondaryColor3usvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3usvEXT_remap_index], fn)
-#define CALL_SecondaryColorPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLenum, GLsizei, const GLvoid *)), driDispatchRemapTable[SecondaryColorPointerEXT_remap_index], parameters)
-#define GET_SecondaryColorPointerEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColorPointerEXT_remap_index])
-#define SET_SecondaryColorPointerEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColorPointerEXT_remap_index], fn)
-#define CALL_MultiDrawArraysEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint *, GLsizei *, GLsizei)), driDispatchRemapTable[MultiDrawArraysEXT_remap_index], parameters)
-#define GET_MultiDrawArraysEXT(disp) GET_by_offset(disp, driDispatchRemapTable[MultiDrawArraysEXT_remap_index])
-#define SET_MultiDrawArraysEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[MultiDrawArraysEXT_remap_index], fn)
-#define CALL_MultiDrawElementsEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLsizei *, GLenum, const GLvoid **, GLsizei)), driDispatchRemapTable[MultiDrawElementsEXT_remap_index], parameters)
-#define GET_MultiDrawElementsEXT(disp) GET_by_offset(disp, driDispatchRemapTable[MultiDrawElementsEXT_remap_index])
-#define SET_MultiDrawElementsEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[MultiDrawElementsEXT_remap_index], fn)
-#define CALL_FogCoordPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, const GLvoid *)), driDispatchRemapTable[FogCoordPointerEXT_remap_index], parameters)
-#define GET_FogCoordPointerEXT(disp) GET_by_offset(disp, driDispatchRemapTable[FogCoordPointerEXT_remap_index])
-#define SET_FogCoordPointerEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FogCoordPointerEXT_remap_index], fn)
-#define CALL_FogCoorddEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble)), driDispatchRemapTable[FogCoorddEXT_remap_index], parameters)
-#define GET_FogCoorddEXT(disp) GET_by_offset(disp, driDispatchRemapTable[FogCoorddEXT_remap_index])
-#define SET_FogCoorddEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FogCoorddEXT_remap_index], fn)
-#define CALL_FogCoorddvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), driDispatchRemapTable[FogCoorddvEXT_remap_index], parameters)
-#define GET_FogCoorddvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[FogCoorddvEXT_remap_index])
-#define SET_FogCoorddvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FogCoorddvEXT_remap_index], fn)
-#define CALL_FogCoordfEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat)), driDispatchRemapTable[FogCoordfEXT_remap_index], parameters)
-#define GET_FogCoordfEXT(disp) GET_by_offset(disp, driDispatchRemapTable[FogCoordfEXT_remap_index])
-#define SET_FogCoordfEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FogCoordfEXT_remap_index], fn)
-#define CALL_FogCoordfvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), driDispatchRemapTable[FogCoordfvEXT_remap_index], parameters)
-#define GET_FogCoordfvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[FogCoordfvEXT_remap_index])
-#define SET_FogCoordfvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FogCoordfvEXT_remap_index], fn)
-#define CALL_PixelTexGenSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), driDispatchRemapTable[PixelTexGenSGIX_remap_index], parameters)
-#define GET_PixelTexGenSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[PixelTexGenSGIX_remap_index])
-#define SET_PixelTexGenSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PixelTexGenSGIX_remap_index], fn)
-#define CALL_BlendFuncSeparateEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLenum)), driDispatchRemapTable[BlendFuncSeparateEXT_remap_index], parameters)
-#define GET_BlendFuncSeparateEXT(disp) GET_by_offset(disp, driDispatchRemapTable[BlendFuncSeparateEXT_remap_index])
-#define SET_BlendFuncSeparateEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BlendFuncSeparateEXT_remap_index], fn)
-#define CALL_FlushVertexArrayRangeNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), driDispatchRemapTable[FlushVertexArrayRangeNV_remap_index], parameters)
-#define GET_FlushVertexArrayRangeNV(disp) GET_by_offset(disp, driDispatchRemapTable[FlushVertexArrayRangeNV_remap_index])
-#define SET_FlushVertexArrayRangeNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FlushVertexArrayRangeNV_remap_index], fn)
-#define CALL_VertexArrayRangeNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLvoid *)), driDispatchRemapTable[VertexArrayRangeNV_remap_index], parameters)
-#define GET_VertexArrayRangeNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexArrayRangeNV_remap_index])
-#define SET_VertexArrayRangeNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexArrayRangeNV_remap_index], fn)
-#define CALL_CombinerInputNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLenum, GLenum, GLenum)), driDispatchRemapTable[CombinerInputNV_remap_index], parameters)
-#define GET_CombinerInputNV(disp) GET_by_offset(disp, driDispatchRemapTable[CombinerInputNV_remap_index])
-#define SET_CombinerInputNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CombinerInputNV_remap_index], fn)
-#define CALL_CombinerOutputNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean)), driDispatchRemapTable[CombinerOutputNV_remap_index], parameters)
-#define GET_CombinerOutputNV(disp) GET_by_offset(disp, driDispatchRemapTable[CombinerOutputNV_remap_index])
-#define SET_CombinerOutputNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CombinerOutputNV_remap_index], fn)
-#define CALL_CombinerParameterfNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat)), driDispatchRemapTable[CombinerParameterfNV_remap_index], parameters)
-#define GET_CombinerParameterfNV(disp) GET_by_offset(disp, driDispatchRemapTable[CombinerParameterfNV_remap_index])
-#define SET_CombinerParameterfNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CombinerParameterfNV_remap_index], fn)
-#define CALL_CombinerParameterfvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLfloat *)), driDispatchRemapTable[CombinerParameterfvNV_remap_index], parameters)
-#define GET_CombinerParameterfvNV(disp) GET_by_offset(disp, driDispatchRemapTable[CombinerParameterfvNV_remap_index])
-#define SET_CombinerParameterfvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CombinerParameterfvNV_remap_index], fn)
-#define CALL_CombinerParameteriNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint)), driDispatchRemapTable[CombinerParameteriNV_remap_index], parameters)
-#define GET_CombinerParameteriNV(disp) GET_by_offset(disp, driDispatchRemapTable[CombinerParameteriNV_remap_index])
-#define SET_CombinerParameteriNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CombinerParameteriNV_remap_index], fn)
-#define CALL_CombinerParameterivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLint *)), driDispatchRemapTable[CombinerParameterivNV_remap_index], parameters)
-#define GET_CombinerParameterivNV(disp) GET_by_offset(disp, driDispatchRemapTable[CombinerParameterivNV_remap_index])
-#define SET_CombinerParameterivNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CombinerParameterivNV_remap_index], fn)
-#define CALL_FinalCombinerInputNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLenum)), driDispatchRemapTable[FinalCombinerInputNV_remap_index], parameters)
-#define GET_FinalCombinerInputNV(disp) GET_by_offset(disp, driDispatchRemapTable[FinalCombinerInputNV_remap_index])
-#define SET_FinalCombinerInputNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FinalCombinerInputNV_remap_index], fn)
-#define CALL_GetCombinerInputParameterfvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLenum, GLfloat *)), driDispatchRemapTable[GetCombinerInputParameterfvNV_remap_index], parameters)
-#define GET_GetCombinerInputParameterfvNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetCombinerInputParameterfvNV_remap_index])
-#define SET_GetCombinerInputParameterfvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetCombinerInputParameterfvNV_remap_index], fn)
-#define CALL_GetCombinerInputParameterivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLenum, GLint *)), driDispatchRemapTable[GetCombinerInputParameterivNV_remap_index], parameters)
-#define GET_GetCombinerInputParameterivNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetCombinerInputParameterivNV_remap_index])
-#define SET_GetCombinerInputParameterivNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetCombinerInputParameterivNV_remap_index], fn)
-#define CALL_GetCombinerOutputParameterfvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLfloat *)), driDispatchRemapTable[GetCombinerOutputParameterfvNV_remap_index], parameters)
-#define GET_GetCombinerOutputParameterfvNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetCombinerOutputParameterfvNV_remap_index])
-#define SET_GetCombinerOutputParameterfvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetCombinerOutputParameterfvNV_remap_index], fn)
-#define CALL_GetCombinerOutputParameterivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLint *)), driDispatchRemapTable[GetCombinerOutputParameterivNV_remap_index], parameters)
-#define GET_GetCombinerOutputParameterivNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetCombinerOutputParameterivNV_remap_index])
-#define SET_GetCombinerOutputParameterivNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetCombinerOutputParameterivNV_remap_index], fn)
-#define CALL_GetFinalCombinerInputParameterfvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLfloat *)), driDispatchRemapTable[GetFinalCombinerInputParameterfvNV_remap_index], parameters)
-#define GET_GetFinalCombinerInputParameterfvNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetFinalCombinerInputParameterfvNV_remap_index])
-#define SET_GetFinalCombinerInputParameterfvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetFinalCombinerInputParameterfvNV_remap_index], fn)
-#define CALL_GetFinalCombinerInputParameterivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), driDispatchRemapTable[GetFinalCombinerInputParameterivNV_remap_index], parameters)
-#define GET_GetFinalCombinerInputParameterivNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetFinalCombinerInputParameterivNV_remap_index])
-#define SET_GetFinalCombinerInputParameterivNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetFinalCombinerInputParameterivNV_remap_index], fn)
-#define CALL_ResizeBuffersMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), driDispatchRemapTable[ResizeBuffersMESA_remap_index], parameters)
-#define GET_ResizeBuffersMESA(disp) GET_by_offset(disp, driDispatchRemapTable[ResizeBuffersMESA_remap_index])
-#define SET_ResizeBuffersMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ResizeBuffersMESA_remap_index], fn)
-#define CALL_WindowPos2dMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble)), driDispatchRemapTable[WindowPos2dMESA_remap_index], parameters)
-#define GET_WindowPos2dMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos2dMESA_remap_index])
-#define SET_WindowPos2dMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos2dMESA_remap_index], fn)
-#define CALL_WindowPos2dvMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), driDispatchRemapTable[WindowPos2dvMESA_remap_index], parameters)
-#define GET_WindowPos2dvMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos2dvMESA_remap_index])
-#define SET_WindowPos2dvMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos2dvMESA_remap_index], fn)
-#define CALL_WindowPos2fMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat)), driDispatchRemapTable[WindowPos2fMESA_remap_index], parameters)
-#define GET_WindowPos2fMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos2fMESA_remap_index])
-#define SET_WindowPos2fMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos2fMESA_remap_index], fn)
-#define CALL_WindowPos2fvMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), driDispatchRemapTable[WindowPos2fvMESA_remap_index], parameters)
-#define GET_WindowPos2fvMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos2fvMESA_remap_index])
-#define SET_WindowPos2fvMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos2fvMESA_remap_index], fn)
-#define CALL_WindowPos2iMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint)), driDispatchRemapTable[WindowPos2iMESA_remap_index], parameters)
-#define GET_WindowPos2iMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos2iMESA_remap_index])
-#define SET_WindowPos2iMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos2iMESA_remap_index], fn)
-#define CALL_WindowPos2ivMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLint *)), driDispatchRemapTable[WindowPos2ivMESA_remap_index], parameters)
-#define GET_WindowPos2ivMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos2ivMESA_remap_index])
-#define SET_WindowPos2ivMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos2ivMESA_remap_index], fn)
-#define CALL_WindowPos2sMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLshort, GLshort)), driDispatchRemapTable[WindowPos2sMESA_remap_index], parameters)
-#define GET_WindowPos2sMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos2sMESA_remap_index])
-#define SET_WindowPos2sMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos2sMESA_remap_index], fn)
-#define CALL_WindowPos2svMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLshort *)), driDispatchRemapTable[WindowPos2svMESA_remap_index], parameters)
-#define GET_WindowPos2svMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos2svMESA_remap_index])
-#define SET_WindowPos2svMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos2svMESA_remap_index], fn)
-#define CALL_WindowPos3dMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble, GLdouble)), driDispatchRemapTable[WindowPos3dMESA_remap_index], parameters)
-#define GET_WindowPos3dMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos3dMESA_remap_index])
-#define SET_WindowPos3dMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos3dMESA_remap_index], fn)
-#define CALL_WindowPos3dvMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), driDispatchRemapTable[WindowPos3dvMESA_remap_index], parameters)
-#define GET_WindowPos3dvMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos3dvMESA_remap_index])
-#define SET_WindowPos3dvMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos3dvMESA_remap_index], fn)
-#define CALL_WindowPos3fMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[WindowPos3fMESA_remap_index], parameters)
-#define GET_WindowPos3fMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos3fMESA_remap_index])
-#define SET_WindowPos3fMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos3fMESA_remap_index], fn)
-#define CALL_WindowPos3fvMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), driDispatchRemapTable[WindowPos3fvMESA_remap_index], parameters)
-#define GET_WindowPos3fvMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos3fvMESA_remap_index])
-#define SET_WindowPos3fvMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos3fvMESA_remap_index], fn)
-#define CALL_WindowPos3iMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint)), driDispatchRemapTable[WindowPos3iMESA_remap_index], parameters)
-#define GET_WindowPos3iMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos3iMESA_remap_index])
-#define SET_WindowPos3iMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos3iMESA_remap_index], fn)
-#define CALL_WindowPos3ivMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLint *)), driDispatchRemapTable[WindowPos3ivMESA_remap_index], parameters)
-#define GET_WindowPos3ivMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos3ivMESA_remap_index])
-#define SET_WindowPos3ivMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos3ivMESA_remap_index], fn)
-#define CALL_WindowPos3sMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLshort, GLshort, GLshort)), driDispatchRemapTable[WindowPos3sMESA_remap_index], parameters)
-#define GET_WindowPos3sMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos3sMESA_remap_index])
-#define SET_WindowPos3sMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos3sMESA_remap_index], fn)
-#define CALL_WindowPos3svMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLshort *)), driDispatchRemapTable[WindowPos3svMESA_remap_index], parameters)
-#define GET_WindowPos3svMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos3svMESA_remap_index])
-#define SET_WindowPos3svMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos3svMESA_remap_index], fn)
-#define CALL_WindowPos4dMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble, GLdouble, GLdouble)), driDispatchRemapTable[WindowPos4dMESA_remap_index], parameters)
-#define GET_WindowPos4dMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos4dMESA_remap_index])
-#define SET_WindowPos4dMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos4dMESA_remap_index], fn)
-#define CALL_WindowPos4dvMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), driDispatchRemapTable[WindowPos4dvMESA_remap_index], parameters)
-#define GET_WindowPos4dvMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos4dvMESA_remap_index])
-#define SET_WindowPos4dvMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos4dvMESA_remap_index], fn)
-#define CALL_WindowPos4fMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[WindowPos4fMESA_remap_index], parameters)
-#define GET_WindowPos4fMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos4fMESA_remap_index])
-#define SET_WindowPos4fMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos4fMESA_remap_index], fn)
-#define CALL_WindowPos4fvMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), driDispatchRemapTable[WindowPos4fvMESA_remap_index], parameters)
-#define GET_WindowPos4fvMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos4fvMESA_remap_index])
-#define SET_WindowPos4fvMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos4fvMESA_remap_index], fn)
-#define CALL_WindowPos4iMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint, GLint)), driDispatchRemapTable[WindowPos4iMESA_remap_index], parameters)
-#define GET_WindowPos4iMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos4iMESA_remap_index])
-#define SET_WindowPos4iMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos4iMESA_remap_index], fn)
-#define CALL_WindowPos4ivMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLint *)), driDispatchRemapTable[WindowPos4ivMESA_remap_index], parameters)
-#define GET_WindowPos4ivMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos4ivMESA_remap_index])
-#define SET_WindowPos4ivMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos4ivMESA_remap_index], fn)
-#define CALL_WindowPos4sMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLshort, GLshort, GLshort, GLshort)), driDispatchRemapTable[WindowPos4sMESA_remap_index], parameters)
-#define GET_WindowPos4sMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos4sMESA_remap_index])
-#define SET_WindowPos4sMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos4sMESA_remap_index], fn)
-#define CALL_WindowPos4svMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLshort *)), driDispatchRemapTable[WindowPos4svMESA_remap_index], parameters)
-#define GET_WindowPos4svMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos4svMESA_remap_index])
-#define SET_WindowPos4svMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos4svMESA_remap_index], fn)
-#define CALL_MultiModeDrawArraysIBM(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLenum *, const GLint *, const GLsizei *, GLsizei, GLint)), driDispatchRemapTable[MultiModeDrawArraysIBM_remap_index], parameters)
-#define GET_MultiModeDrawArraysIBM(disp) GET_by_offset(disp, driDispatchRemapTable[MultiModeDrawArraysIBM_remap_index])
-#define SET_MultiModeDrawArraysIBM(disp, fn) SET_by_offset(disp, driDispatchRemapTable[MultiModeDrawArraysIBM_remap_index], fn)
-#define CALL_MultiModeDrawElementsIBM(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLenum *, const GLsizei *, GLenum, const GLvoid * const *, GLsizei, GLint)), driDispatchRemapTable[MultiModeDrawElementsIBM_remap_index], parameters)
-#define GET_MultiModeDrawElementsIBM(disp) GET_by_offset(disp, driDispatchRemapTable[MultiModeDrawElementsIBM_remap_index])
-#define SET_MultiModeDrawElementsIBM(disp, fn) SET_by_offset(disp, driDispatchRemapTable[MultiModeDrawElementsIBM_remap_index], fn)
-#define CALL_DeleteFencesNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), driDispatchRemapTable[DeleteFencesNV_remap_index], parameters)
-#define GET_DeleteFencesNV(disp) GET_by_offset(disp, driDispatchRemapTable[DeleteFencesNV_remap_index])
-#define SET_DeleteFencesNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DeleteFencesNV_remap_index], fn)
-#define CALL_FinishFenceNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[FinishFenceNV_remap_index], parameters)
-#define GET_FinishFenceNV(disp) GET_by_offset(disp, driDispatchRemapTable[FinishFenceNV_remap_index])
-#define SET_FinishFenceNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FinishFenceNV_remap_index], fn)
-#define CALL_GenFencesNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), driDispatchRemapTable[GenFencesNV_remap_index], parameters)
-#define GET_GenFencesNV(disp) GET_by_offset(disp, driDispatchRemapTable[GenFencesNV_remap_index])
-#define SET_GenFencesNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GenFencesNV_remap_index], fn)
-#define CALL_GetFenceivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint *)), driDispatchRemapTable[GetFenceivNV_remap_index], parameters)
-#define GET_GetFenceivNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetFenceivNV_remap_index])
-#define SET_GetFenceivNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetFenceivNV_remap_index], fn)
-#define CALL_IsFenceNV(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[IsFenceNV_remap_index], parameters)
-#define GET_IsFenceNV(disp) GET_by_offset(disp, driDispatchRemapTable[IsFenceNV_remap_index])
-#define SET_IsFenceNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IsFenceNV_remap_index], fn)
-#define CALL_SetFenceNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum)), driDispatchRemapTable[SetFenceNV_remap_index], parameters)
-#define GET_SetFenceNV(disp) GET_by_offset(disp, driDispatchRemapTable[SetFenceNV_remap_index])
-#define SET_SetFenceNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SetFenceNV_remap_index], fn)
-#define CALL_TestFenceNV(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[TestFenceNV_remap_index], parameters)
-#define GET_TestFenceNV(disp) GET_by_offset(disp, driDispatchRemapTable[TestFenceNV_remap_index])
-#define SET_TestFenceNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[TestFenceNV_remap_index], fn)
-#define CALL_AreProgramsResidentNV(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLsizei, const GLuint *, GLboolean *)), driDispatchRemapTable[AreProgramsResidentNV_remap_index], parameters)
-#define GET_AreProgramsResidentNV(disp) GET_by_offset(disp, driDispatchRemapTable[AreProgramsResidentNV_remap_index])
-#define SET_AreProgramsResidentNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[AreProgramsResidentNV_remap_index], fn)
-#define CALL_BindProgramNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint)), driDispatchRemapTable[BindProgramNV_remap_index], parameters)
-#define GET_BindProgramNV(disp) GET_by_offset(disp, driDispatchRemapTable[BindProgramNV_remap_index])
-#define SET_BindProgramNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BindProgramNV_remap_index], fn)
-#define CALL_DeleteProgramsNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), driDispatchRemapTable[DeleteProgramsNV_remap_index], parameters)
-#define GET_DeleteProgramsNV(disp) GET_by_offset(disp, driDispatchRemapTable[DeleteProgramsNV_remap_index])
-#define SET_DeleteProgramsNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DeleteProgramsNV_remap_index], fn)
-#define CALL_ExecuteProgramNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, const GLfloat *)), driDispatchRemapTable[ExecuteProgramNV_remap_index], parameters)
-#define GET_ExecuteProgramNV(disp) GET_by_offset(disp, driDispatchRemapTable[ExecuteProgramNV_remap_index])
-#define SET_ExecuteProgramNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ExecuteProgramNV_remap_index], fn)
-#define CALL_GenProgramsNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), driDispatchRemapTable[GenProgramsNV_remap_index], parameters)
-#define GET_GenProgramsNV(disp) GET_by_offset(disp, driDispatchRemapTable[GenProgramsNV_remap_index])
-#define SET_GenProgramsNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GenProgramsNV_remap_index], fn)
-#define CALL_GetProgramParameterdvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLenum, GLdouble *)), driDispatchRemapTable[GetProgramParameterdvNV_remap_index], parameters)
-#define GET_GetProgramParameterdvNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramParameterdvNV_remap_index])
-#define SET_GetProgramParameterdvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramParameterdvNV_remap_index], fn)
-#define CALL_GetProgramParameterfvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLenum, GLfloat *)), driDispatchRemapTable[GetProgramParameterfvNV_remap_index], parameters)
-#define GET_GetProgramParameterfvNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramParameterfvNV_remap_index])
-#define SET_GetProgramParameterfvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramParameterfvNV_remap_index], fn)
-#define CALL_GetProgramStringNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLubyte *)), driDispatchRemapTable[GetProgramStringNV_remap_index], parameters)
-#define GET_GetProgramStringNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramStringNV_remap_index])
-#define SET_GetProgramStringNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramStringNV_remap_index], fn)
-#define CALL_GetProgramivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint *)), driDispatchRemapTable[GetProgramivNV_remap_index], parameters)
-#define GET_GetProgramivNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramivNV_remap_index])
-#define SET_GetProgramivNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramivNV_remap_index], fn)
-#define CALL_GetTrackMatrixivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLenum, GLint *)), driDispatchRemapTable[GetTrackMatrixivNV_remap_index], parameters)
-#define GET_GetTrackMatrixivNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetTrackMatrixivNV_remap_index])
-#define SET_GetTrackMatrixivNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetTrackMatrixivNV_remap_index], fn)
-#define CALL_GetVertexAttribPointervNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLvoid **)), driDispatchRemapTable[GetVertexAttribPointervNV_remap_index], parameters)
-#define GET_GetVertexAttribPointervNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetVertexAttribPointervNV_remap_index])
-#define SET_GetVertexAttribPointervNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetVertexAttribPointervNV_remap_index], fn)
-#define CALL_GetVertexAttribdvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLdouble *)), driDispatchRemapTable[GetVertexAttribdvNV_remap_index], parameters)
-#define GET_GetVertexAttribdvNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetVertexAttribdvNV_remap_index])
-#define SET_GetVertexAttribdvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetVertexAttribdvNV_remap_index], fn)
-#define CALL_GetVertexAttribfvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLfloat *)), driDispatchRemapTable[GetVertexAttribfvNV_remap_index], parameters)
-#define GET_GetVertexAttribfvNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetVertexAttribfvNV_remap_index])
-#define SET_GetVertexAttribfvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetVertexAttribfvNV_remap_index], fn)
-#define CALL_GetVertexAttribivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint *)), driDispatchRemapTable[GetVertexAttribivNV_remap_index], parameters)
-#define GET_GetVertexAttribivNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetVertexAttribivNV_remap_index])
-#define SET_GetVertexAttribivNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetVertexAttribivNV_remap_index], fn)
-#define CALL_IsProgramNV(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[IsProgramNV_remap_index], parameters)
-#define GET_IsProgramNV(disp) GET_by_offset(disp, driDispatchRemapTable[IsProgramNV_remap_index])
-#define SET_IsProgramNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IsProgramNV_remap_index], fn)
-#define CALL_LoadProgramNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLsizei, const GLubyte *)), driDispatchRemapTable[LoadProgramNV_remap_index], parameters)
-#define GET_LoadProgramNV(disp) GET_by_offset(disp, driDispatchRemapTable[LoadProgramNV_remap_index])
-#define SET_LoadProgramNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[LoadProgramNV_remap_index], fn)
-#define CALL_ProgramParameters4dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, const GLdouble *)), driDispatchRemapTable[ProgramParameters4dvNV_remap_index], parameters)
-#define GET_ProgramParameters4dvNV(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramParameters4dvNV_remap_index])
-#define SET_ProgramParameters4dvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramParameters4dvNV_remap_index], fn)
-#define CALL_ProgramParameters4fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, const GLfloat *)), driDispatchRemapTable[ProgramParameters4fvNV_remap_index], parameters)
-#define GET_ProgramParameters4fvNV(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramParameters4fvNV_remap_index])
-#define SET_ProgramParameters4fvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramParameters4fvNV_remap_index], fn)
-#define CALL_RequestResidentProgramsNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), driDispatchRemapTable[RequestResidentProgramsNV_remap_index], parameters)
-#define GET_RequestResidentProgramsNV(disp) GET_by_offset(disp, driDispatchRemapTable[RequestResidentProgramsNV_remap_index])
-#define SET_RequestResidentProgramsNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[RequestResidentProgramsNV_remap_index], fn)
-#define CALL_TrackMatrixNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLenum, GLenum)), driDispatchRemapTable[TrackMatrixNV_remap_index], parameters)
-#define GET_TrackMatrixNV(disp) GET_by_offset(disp, driDispatchRemapTable[TrackMatrixNV_remap_index])
-#define SET_TrackMatrixNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[TrackMatrixNV_remap_index], fn)
-#define CALL_VertexAttrib1dNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLdouble)), driDispatchRemapTable[VertexAttrib1dNV_remap_index], parameters)
-#define GET_VertexAttrib1dNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1dNV_remap_index])
-#define SET_VertexAttrib1dNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1dNV_remap_index], fn)
-#define CALL_VertexAttrib1dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLdouble *)), driDispatchRemapTable[VertexAttrib1dvNV_remap_index], parameters)
-#define GET_VertexAttrib1dvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1dvNV_remap_index])
-#define SET_VertexAttrib1dvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1dvNV_remap_index], fn)
-#define CALL_VertexAttrib1fNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLfloat)), driDispatchRemapTable[VertexAttrib1fNV_remap_index], parameters)
-#define GET_VertexAttrib1fNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1fNV_remap_index])
-#define SET_VertexAttrib1fNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1fNV_remap_index], fn)
-#define CALL_VertexAttrib1fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), driDispatchRemapTable[VertexAttrib1fvNV_remap_index], parameters)
-#define GET_VertexAttrib1fvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1fvNV_remap_index])
-#define SET_VertexAttrib1fvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1fvNV_remap_index], fn)
-#define CALL_VertexAttrib1sNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLshort)), driDispatchRemapTable[VertexAttrib1sNV_remap_index], parameters)
-#define GET_VertexAttrib1sNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1sNV_remap_index])
-#define SET_VertexAttrib1sNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1sNV_remap_index], fn)
-#define CALL_VertexAttrib1svNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), driDispatchRemapTable[VertexAttrib1svNV_remap_index], parameters)
-#define GET_VertexAttrib1svNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1svNV_remap_index])
-#define SET_VertexAttrib1svNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1svNV_remap_index], fn)
-#define CALL_VertexAttrib2dNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLdouble, GLdouble)), driDispatchRemapTable[VertexAttrib2dNV_remap_index], parameters)
-#define GET_VertexAttrib2dNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2dNV_remap_index])
-#define SET_VertexAttrib2dNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2dNV_remap_index], fn)
-#define CALL_VertexAttrib2dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLdouble *)), driDispatchRemapTable[VertexAttrib2dvNV_remap_index], parameters)
-#define GET_VertexAttrib2dvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2dvNV_remap_index])
-#define SET_VertexAttrib2dvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2dvNV_remap_index], fn)
-#define CALL_VertexAttrib2fNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLfloat, GLfloat)), driDispatchRemapTable[VertexAttrib2fNV_remap_index], parameters)
-#define GET_VertexAttrib2fNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2fNV_remap_index])
-#define SET_VertexAttrib2fNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2fNV_remap_index], fn)
-#define CALL_VertexAttrib2fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), driDispatchRemapTable[VertexAttrib2fvNV_remap_index], parameters)
-#define GET_VertexAttrib2fvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2fvNV_remap_index])
-#define SET_VertexAttrib2fvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2fvNV_remap_index], fn)
-#define CALL_VertexAttrib2sNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLshort, GLshort)), driDispatchRemapTable[VertexAttrib2sNV_remap_index], parameters)
-#define GET_VertexAttrib2sNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2sNV_remap_index])
-#define SET_VertexAttrib2sNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2sNV_remap_index], fn)
-#define CALL_VertexAttrib2svNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), driDispatchRemapTable[VertexAttrib2svNV_remap_index], parameters)
-#define GET_VertexAttrib2svNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2svNV_remap_index])
-#define SET_VertexAttrib2svNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2svNV_remap_index], fn)
-#define CALL_VertexAttrib3dNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLdouble, GLdouble, GLdouble)), driDispatchRemapTable[VertexAttrib3dNV_remap_index], parameters)
-#define GET_VertexAttrib3dNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3dNV_remap_index])
-#define SET_VertexAttrib3dNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3dNV_remap_index], fn)
-#define CALL_VertexAttrib3dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLdouble *)), driDispatchRemapTable[VertexAttrib3dvNV_remap_index], parameters)
-#define GET_VertexAttrib3dvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3dvNV_remap_index])
-#define SET_VertexAttrib3dvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3dvNV_remap_index], fn)
-#define CALL_VertexAttrib3fNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[VertexAttrib3fNV_remap_index], parameters)
-#define GET_VertexAttrib3fNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3fNV_remap_index])
-#define SET_VertexAttrib3fNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3fNV_remap_index], fn)
-#define CALL_VertexAttrib3fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), driDispatchRemapTable[VertexAttrib3fvNV_remap_index], parameters)
-#define GET_VertexAttrib3fvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3fvNV_remap_index])
-#define SET_VertexAttrib3fvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3fvNV_remap_index], fn)
-#define CALL_VertexAttrib3sNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLshort, GLshort, GLshort)), driDispatchRemapTable[VertexAttrib3sNV_remap_index], parameters)
-#define GET_VertexAttrib3sNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3sNV_remap_index])
-#define SET_VertexAttrib3sNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3sNV_remap_index], fn)
-#define CALL_VertexAttrib3svNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), driDispatchRemapTable[VertexAttrib3svNV_remap_index], parameters)
-#define GET_VertexAttrib3svNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3svNV_remap_index])
-#define SET_VertexAttrib3svNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3svNV_remap_index], fn)
-#define CALL_VertexAttrib4dNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble)), driDispatchRemapTable[VertexAttrib4dNV_remap_index], parameters)
-#define GET_VertexAttrib4dNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4dNV_remap_index])
-#define SET_VertexAttrib4dNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4dNV_remap_index], fn)
-#define CALL_VertexAttrib4dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLdouble *)), driDispatchRemapTable[VertexAttrib4dvNV_remap_index], parameters)
-#define GET_VertexAttrib4dvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4dvNV_remap_index])
-#define SET_VertexAttrib4dvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4dvNV_remap_index], fn)
-#define CALL_VertexAttrib4fNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[VertexAttrib4fNV_remap_index], parameters)
-#define GET_VertexAttrib4fNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4fNV_remap_index])
-#define SET_VertexAttrib4fNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4fNV_remap_index], fn)
-#define CALL_VertexAttrib4fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), driDispatchRemapTable[VertexAttrib4fvNV_remap_index], parameters)
-#define GET_VertexAttrib4fvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4fvNV_remap_index])
-#define SET_VertexAttrib4fvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4fvNV_remap_index], fn)
-#define CALL_VertexAttrib4sNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLshort, GLshort, GLshort, GLshort)), driDispatchRemapTable[VertexAttrib4sNV_remap_index], parameters)
-#define GET_VertexAttrib4sNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4sNV_remap_index])
-#define SET_VertexAttrib4sNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4sNV_remap_index], fn)
-#define CALL_VertexAttrib4svNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), driDispatchRemapTable[VertexAttrib4svNV_remap_index], parameters)
-#define GET_VertexAttrib4svNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4svNV_remap_index])
-#define SET_VertexAttrib4svNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4svNV_remap_index], fn)
-#define CALL_VertexAttrib4ubNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte)), driDispatchRemapTable[VertexAttrib4ubNV_remap_index], parameters)
-#define GET_VertexAttrib4ubNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4ubNV_remap_index])
-#define SET_VertexAttrib4ubNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4ubNV_remap_index], fn)
-#define CALL_VertexAttrib4ubvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLubyte *)), driDispatchRemapTable[VertexAttrib4ubvNV_remap_index], parameters)
-#define GET_VertexAttrib4ubvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4ubvNV_remap_index])
-#define SET_VertexAttrib4ubvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4ubvNV_remap_index], fn)
-#define CALL_VertexAttribPointerNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLint, GLenum, GLsizei, const GLvoid *)), driDispatchRemapTable[VertexAttribPointerNV_remap_index], parameters)
-#define GET_VertexAttribPointerNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribPointerNV_remap_index])
-#define SET_VertexAttribPointerNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribPointerNV_remap_index], fn)
-#define CALL_VertexAttribs1dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLdouble *)), driDispatchRemapTable[VertexAttribs1dvNV_remap_index], parameters)
-#define GET_VertexAttribs1dvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs1dvNV_remap_index])
-#define SET_VertexAttribs1dvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs1dvNV_remap_index], fn)
-#define CALL_VertexAttribs1fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLfloat *)), driDispatchRemapTable[VertexAttribs1fvNV_remap_index], parameters)
-#define GET_VertexAttribs1fvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs1fvNV_remap_index])
-#define SET_VertexAttribs1fvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs1fvNV_remap_index], fn)
-#define CALL_VertexAttribs1svNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLshort *)), driDispatchRemapTable[VertexAttribs1svNV_remap_index], parameters)
-#define GET_VertexAttribs1svNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs1svNV_remap_index])
-#define SET_VertexAttribs1svNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs1svNV_remap_index], fn)
-#define CALL_VertexAttribs2dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLdouble *)), driDispatchRemapTable[VertexAttribs2dvNV_remap_index], parameters)
-#define GET_VertexAttribs2dvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs2dvNV_remap_index])
-#define SET_VertexAttribs2dvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs2dvNV_remap_index], fn)
-#define CALL_VertexAttribs2fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLfloat *)), driDispatchRemapTable[VertexAttribs2fvNV_remap_index], parameters)
-#define GET_VertexAttribs2fvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs2fvNV_remap_index])
-#define SET_VertexAttribs2fvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs2fvNV_remap_index], fn)
-#define CALL_VertexAttribs2svNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLshort *)), driDispatchRemapTable[VertexAttribs2svNV_remap_index], parameters)
-#define GET_VertexAttribs2svNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs2svNV_remap_index])
-#define SET_VertexAttribs2svNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs2svNV_remap_index], fn)
-#define CALL_VertexAttribs3dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLdouble *)), driDispatchRemapTable[VertexAttribs3dvNV_remap_index], parameters)
-#define GET_VertexAttribs3dvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs3dvNV_remap_index])
-#define SET_VertexAttribs3dvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs3dvNV_remap_index], fn)
-#define CALL_VertexAttribs3fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLfloat *)), driDispatchRemapTable[VertexAttribs3fvNV_remap_index], parameters)
-#define GET_VertexAttribs3fvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs3fvNV_remap_index])
-#define SET_VertexAttribs3fvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs3fvNV_remap_index], fn)
-#define CALL_VertexAttribs3svNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLshort *)), driDispatchRemapTable[VertexAttribs3svNV_remap_index], parameters)
-#define GET_VertexAttribs3svNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs3svNV_remap_index])
-#define SET_VertexAttribs3svNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs3svNV_remap_index], fn)
-#define CALL_VertexAttribs4dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLdouble *)), driDispatchRemapTable[VertexAttribs4dvNV_remap_index], parameters)
-#define GET_VertexAttribs4dvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs4dvNV_remap_index])
-#define SET_VertexAttribs4dvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs4dvNV_remap_index], fn)
-#define CALL_VertexAttribs4fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLfloat *)), driDispatchRemapTable[VertexAttribs4fvNV_remap_index], parameters)
-#define GET_VertexAttribs4fvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs4fvNV_remap_index])
-#define SET_VertexAttribs4fvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs4fvNV_remap_index], fn)
-#define CALL_VertexAttribs4svNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLshort *)), driDispatchRemapTable[VertexAttribs4svNV_remap_index], parameters)
-#define GET_VertexAttribs4svNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs4svNV_remap_index])
-#define SET_VertexAttribs4svNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs4svNV_remap_index], fn)
-#define CALL_VertexAttribs4ubvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLubyte *)), driDispatchRemapTable[VertexAttribs4ubvNV_remap_index], parameters)
-#define GET_VertexAttribs4ubvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs4ubvNV_remap_index])
-#define SET_VertexAttribs4ubvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs4ubvNV_remap_index], fn)
-#define CALL_GetTexBumpParameterfvATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat *)), driDispatchRemapTable[GetTexBumpParameterfvATI_remap_index], parameters)
-#define GET_GetTexBumpParameterfvATI(disp) GET_by_offset(disp, driDispatchRemapTable[GetTexBumpParameterfvATI_remap_index])
-#define SET_GetTexBumpParameterfvATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetTexBumpParameterfvATI_remap_index], fn)
-#define CALL_GetTexBumpParameterivATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint *)), driDispatchRemapTable[GetTexBumpParameterivATI_remap_index], parameters)
-#define GET_GetTexBumpParameterivATI(disp) GET_by_offset(disp, driDispatchRemapTable[GetTexBumpParameterivATI_remap_index])
-#define SET_GetTexBumpParameterivATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetTexBumpParameterivATI_remap_index], fn)
-#define CALL_TexBumpParameterfvATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLfloat *)), driDispatchRemapTable[TexBumpParameterfvATI_remap_index], parameters)
-#define GET_TexBumpParameterfvATI(disp) GET_by_offset(disp, driDispatchRemapTable[TexBumpParameterfvATI_remap_index])
-#define SET_TexBumpParameterfvATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[TexBumpParameterfvATI_remap_index], fn)
-#define CALL_TexBumpParameterivATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLint *)), driDispatchRemapTable[TexBumpParameterivATI_remap_index], parameters)
-#define GET_TexBumpParameterivATI(disp) GET_by_offset(disp, driDispatchRemapTable[TexBumpParameterivATI_remap_index])
-#define SET_TexBumpParameterivATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[TexBumpParameterivATI_remap_index], fn)
-#define CALL_AlphaFragmentOp1ATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, GLuint, GLuint, GLuint)), driDispatchRemapTable[AlphaFragmentOp1ATI_remap_index], parameters)
-#define GET_AlphaFragmentOp1ATI(disp) GET_by_offset(disp, driDispatchRemapTable[AlphaFragmentOp1ATI_remap_index])
-#define SET_AlphaFragmentOp1ATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[AlphaFragmentOp1ATI_remap_index], fn)
-#define CALL_AlphaFragmentOp2ATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint)), driDispatchRemapTable[AlphaFragmentOp2ATI_remap_index], parameters)
-#define GET_AlphaFragmentOp2ATI(disp) GET_by_offset(disp, driDispatchRemapTable[AlphaFragmentOp2ATI_remap_index])
-#define SET_AlphaFragmentOp2ATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[AlphaFragmentOp2ATI_remap_index], fn)
-#define CALL_AlphaFragmentOp3ATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint)), driDispatchRemapTable[AlphaFragmentOp3ATI_remap_index], parameters)
-#define GET_AlphaFragmentOp3ATI(disp) GET_by_offset(disp, driDispatchRemapTable[AlphaFragmentOp3ATI_remap_index])
-#define SET_AlphaFragmentOp3ATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[AlphaFragmentOp3ATI_remap_index], fn)
-#define CALL_BeginFragmentShaderATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), driDispatchRemapTable[BeginFragmentShaderATI_remap_index], parameters)
-#define GET_BeginFragmentShaderATI(disp) GET_by_offset(disp, driDispatchRemapTable[BeginFragmentShaderATI_remap_index])
-#define SET_BeginFragmentShaderATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BeginFragmentShaderATI_remap_index], fn)
-#define CALL_BindFragmentShaderATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[BindFragmentShaderATI_remap_index], parameters)
-#define GET_BindFragmentShaderATI(disp) GET_by_offset(disp, driDispatchRemapTable[BindFragmentShaderATI_remap_index])
-#define SET_BindFragmentShaderATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BindFragmentShaderATI_remap_index], fn)
-#define CALL_ColorFragmentOp1ATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint)), driDispatchRemapTable[ColorFragmentOp1ATI_remap_index], parameters)
-#define GET_ColorFragmentOp1ATI(disp) GET_by_offset(disp, driDispatchRemapTable[ColorFragmentOp1ATI_remap_index])
-#define SET_ColorFragmentOp1ATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ColorFragmentOp1ATI_remap_index], fn)
-#define CALL_ColorFragmentOp2ATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint)), driDispatchRemapTable[ColorFragmentOp2ATI_remap_index], parameters)
-#define GET_ColorFragmentOp2ATI(disp) GET_by_offset(disp, driDispatchRemapTable[ColorFragmentOp2ATI_remap_index])
-#define SET_ColorFragmentOp2ATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ColorFragmentOp2ATI_remap_index], fn)
-#define CALL_ColorFragmentOp3ATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint)), driDispatchRemapTable[ColorFragmentOp3ATI_remap_index], parameters)
-#define GET_ColorFragmentOp3ATI(disp) GET_by_offset(disp, driDispatchRemapTable[ColorFragmentOp3ATI_remap_index])
-#define SET_ColorFragmentOp3ATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ColorFragmentOp3ATI_remap_index], fn)
-#define CALL_DeleteFragmentShaderATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[DeleteFragmentShaderATI_remap_index], parameters)
-#define GET_DeleteFragmentShaderATI(disp) GET_by_offset(disp, driDispatchRemapTable[DeleteFragmentShaderATI_remap_index])
-#define SET_DeleteFragmentShaderATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DeleteFragmentShaderATI_remap_index], fn)
-#define CALL_EndFragmentShaderATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), driDispatchRemapTable[EndFragmentShaderATI_remap_index], parameters)
-#define GET_EndFragmentShaderATI(disp) GET_by_offset(disp, driDispatchRemapTable[EndFragmentShaderATI_remap_index])
-#define SET_EndFragmentShaderATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[EndFragmentShaderATI_remap_index], fn)
-#define CALL_GenFragmentShadersATI(disp, parameters) CALL_by_offset(disp, (GLuint (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[GenFragmentShadersATI_remap_index], parameters)
-#define GET_GenFragmentShadersATI(disp) GET_by_offset(disp, driDispatchRemapTable[GenFragmentShadersATI_remap_index])
-#define SET_GenFragmentShadersATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GenFragmentShadersATI_remap_index], fn)
-#define CALL_PassTexCoordATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLuint, GLenum)), driDispatchRemapTable[PassTexCoordATI_remap_index], parameters)
-#define GET_PassTexCoordATI(disp) GET_by_offset(disp, driDispatchRemapTable[PassTexCoordATI_remap_index])
-#define SET_PassTexCoordATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PassTexCoordATI_remap_index], fn)
-#define CALL_SampleMapATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLuint, GLenum)), driDispatchRemapTable[SampleMapATI_remap_index], parameters)
-#define GET_SampleMapATI(disp) GET_by_offset(disp, driDispatchRemapTable[SampleMapATI_remap_index])
-#define SET_SampleMapATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SampleMapATI_remap_index], fn)
-#define CALL_SetFragmentShaderConstantATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), driDispatchRemapTable[SetFragmentShaderConstantATI_remap_index], parameters)
-#define GET_SetFragmentShaderConstantATI(disp) GET_by_offset(disp, driDispatchRemapTable[SetFragmentShaderConstantATI_remap_index])
-#define SET_SetFragmentShaderConstantATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SetFragmentShaderConstantATI_remap_index], fn)
-#define CALL_PointParameteriNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint)), driDispatchRemapTable[PointParameteriNV_remap_index], parameters)
-#define GET_PointParameteriNV(disp) GET_by_offset(disp, driDispatchRemapTable[PointParameteriNV_remap_index])
-#define SET_PointParameteriNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PointParameteriNV_remap_index], fn)
-#define CALL_PointParameterivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLint *)), driDispatchRemapTable[PointParameterivNV_remap_index], parameters)
-#define GET_PointParameterivNV(disp) GET_by_offset(disp, driDispatchRemapTable[PointParameterivNV_remap_index])
-#define SET_PointParameterivNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PointParameterivNV_remap_index], fn)
-#define CALL_ActiveStencilFaceEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), driDispatchRemapTable[ActiveStencilFaceEXT_remap_index], parameters)
-#define GET_ActiveStencilFaceEXT(disp) GET_by_offset(disp, driDispatchRemapTable[ActiveStencilFaceEXT_remap_index])
-#define SET_ActiveStencilFaceEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ActiveStencilFaceEXT_remap_index], fn)
-#define CALL_BindVertexArrayAPPLE(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[BindVertexArrayAPPLE_remap_index], parameters)
-#define GET_BindVertexArrayAPPLE(disp) GET_by_offset(disp, driDispatchRemapTable[BindVertexArrayAPPLE_remap_index])
-#define SET_BindVertexArrayAPPLE(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BindVertexArrayAPPLE_remap_index], fn)
-#define CALL_DeleteVertexArraysAPPLE(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), driDispatchRemapTable[DeleteVertexArraysAPPLE_remap_index], parameters)
-#define GET_DeleteVertexArraysAPPLE(disp) GET_by_offset(disp, driDispatchRemapTable[DeleteVertexArraysAPPLE_remap_index])
-#define SET_DeleteVertexArraysAPPLE(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DeleteVertexArraysAPPLE_remap_index], fn)
-#define CALL_GenVertexArraysAPPLE(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), driDispatchRemapTable[GenVertexArraysAPPLE_remap_index], parameters)
-#define GET_GenVertexArraysAPPLE(disp) GET_by_offset(disp, driDispatchRemapTable[GenVertexArraysAPPLE_remap_index])
-#define SET_GenVertexArraysAPPLE(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GenVertexArraysAPPLE_remap_index], fn)
-#define CALL_IsVertexArrayAPPLE(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[IsVertexArrayAPPLE_remap_index], parameters)
-#define GET_IsVertexArrayAPPLE(disp) GET_by_offset(disp, driDispatchRemapTable[IsVertexArrayAPPLE_remap_index])
-#define SET_IsVertexArrayAPPLE(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IsVertexArrayAPPLE_remap_index], fn)
-#define CALL_GetProgramNamedParameterdvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLubyte *, GLdouble *)), driDispatchRemapTable[GetProgramNamedParameterdvNV_remap_index], parameters)
-#define GET_GetProgramNamedParameterdvNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramNamedParameterdvNV_remap_index])
-#define SET_GetProgramNamedParameterdvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramNamedParameterdvNV_remap_index], fn)
-#define CALL_GetProgramNamedParameterfvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLubyte *, GLfloat *)), driDispatchRemapTable[GetProgramNamedParameterfvNV_remap_index], parameters)
-#define GET_GetProgramNamedParameterfvNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramNamedParameterfvNV_remap_index])
-#define SET_GetProgramNamedParameterfvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramNamedParameterfvNV_remap_index], fn)
-#define CALL_ProgramNamedParameter4dNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLubyte *, GLdouble, GLdouble, GLdouble, GLdouble)), driDispatchRemapTable[ProgramNamedParameter4dNV_remap_index], parameters)
-#define GET_ProgramNamedParameter4dNV(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramNamedParameter4dNV_remap_index])
-#define SET_ProgramNamedParameter4dNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramNamedParameter4dNV_remap_index], fn)
-#define CALL_ProgramNamedParameter4dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLubyte *, const GLdouble *)), driDispatchRemapTable[ProgramNamedParameter4dvNV_remap_index], parameters)
-#define GET_ProgramNamedParameter4dvNV(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramNamedParameter4dvNV_remap_index])
-#define SET_ProgramNamedParameter4dvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramNamedParameter4dvNV_remap_index], fn)
-#define CALL_ProgramNamedParameter4fNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLubyte *, GLfloat, GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[ProgramNamedParameter4fNV_remap_index], parameters)
-#define GET_ProgramNamedParameter4fNV(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramNamedParameter4fNV_remap_index])
-#define SET_ProgramNamedParameter4fNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramNamedParameter4fNV_remap_index], fn)
-#define CALL_ProgramNamedParameter4fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLubyte *, const GLfloat *)), driDispatchRemapTable[ProgramNamedParameter4fvNV_remap_index], parameters)
-#define GET_ProgramNamedParameter4fvNV(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramNamedParameter4fvNV_remap_index])
-#define SET_ProgramNamedParameter4fvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramNamedParameter4fvNV_remap_index], fn)
-#define CALL_DepthBoundsEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLclampd, GLclampd)), driDispatchRemapTable[DepthBoundsEXT_remap_index], parameters)
-#define GET_DepthBoundsEXT(disp) GET_by_offset(disp, driDispatchRemapTable[DepthBoundsEXT_remap_index])
-#define SET_DepthBoundsEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DepthBoundsEXT_remap_index], fn)
-#define CALL_BlendEquationSeparateEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum)), driDispatchRemapTable[BlendEquationSeparateEXT_remap_index], parameters)
-#define GET_BlendEquationSeparateEXT(disp) GET_by_offset(disp, driDispatchRemapTable[BlendEquationSeparateEXT_remap_index])
-#define SET_BlendEquationSeparateEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BlendEquationSeparateEXT_remap_index], fn)
-#define CALL_BindFramebufferEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint)), driDispatchRemapTable[BindFramebufferEXT_remap_index], parameters)
-#define GET_BindFramebufferEXT(disp) GET_by_offset(disp, driDispatchRemapTable[BindFramebufferEXT_remap_index])
-#define SET_BindFramebufferEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BindFramebufferEXT_remap_index], fn)
-#define CALL_BindRenderbufferEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint)), driDispatchRemapTable[BindRenderbufferEXT_remap_index], parameters)
-#define GET_BindRenderbufferEXT(disp) GET_by_offset(disp, driDispatchRemapTable[BindRenderbufferEXT_remap_index])
-#define SET_BindRenderbufferEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BindRenderbufferEXT_remap_index], fn)
-#define CALL_CheckFramebufferStatusEXT(disp, parameters) CALL_by_offset(disp, (GLenum (GLAPIENTRYP)(GLenum)), driDispatchRemapTable[CheckFramebufferStatusEXT_remap_index], parameters)
-#define GET_CheckFramebufferStatusEXT(disp) GET_by_offset(disp, driDispatchRemapTable[CheckFramebufferStatusEXT_remap_index])
-#define SET_CheckFramebufferStatusEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CheckFramebufferStatusEXT_remap_index], fn)
-#define CALL_DeleteFramebuffersEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), driDispatchRemapTable[DeleteFramebuffersEXT_remap_index], parameters)
-#define GET_DeleteFramebuffersEXT(disp) GET_by_offset(disp, driDispatchRemapTable[DeleteFramebuffersEXT_remap_index])
-#define SET_DeleteFramebuffersEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DeleteFramebuffersEXT_remap_index], fn)
-#define CALL_DeleteRenderbuffersEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), driDispatchRemapTable[DeleteRenderbuffersEXT_remap_index], parameters)
-#define GET_DeleteRenderbuffersEXT(disp) GET_by_offset(disp, driDispatchRemapTable[DeleteRenderbuffersEXT_remap_index])
-#define SET_DeleteRenderbuffersEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DeleteRenderbuffersEXT_remap_index], fn)
-#define CALL_FramebufferRenderbufferEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLuint)), driDispatchRemapTable[FramebufferRenderbufferEXT_remap_index], parameters)
-#define GET_FramebufferRenderbufferEXT(disp) GET_by_offset(disp, driDispatchRemapTable[FramebufferRenderbufferEXT_remap_index])
-#define SET_FramebufferRenderbufferEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FramebufferRenderbufferEXT_remap_index], fn)
-#define CALL_FramebufferTexture1DEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLuint, GLint)), driDispatchRemapTable[FramebufferTexture1DEXT_remap_index], parameters)
-#define GET_FramebufferTexture1DEXT(disp) GET_by_offset(disp, driDispatchRemapTable[FramebufferTexture1DEXT_remap_index])
-#define SET_FramebufferTexture1DEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FramebufferTexture1DEXT_remap_index], fn)
-#define CALL_FramebufferTexture2DEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLuint, GLint)), driDispatchRemapTable[FramebufferTexture2DEXT_remap_index], parameters)
-#define GET_FramebufferTexture2DEXT(disp) GET_by_offset(disp, driDispatchRemapTable[FramebufferTexture2DEXT_remap_index])
-#define SET_FramebufferTexture2DEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FramebufferTexture2DEXT_remap_index], fn)
-#define CALL_FramebufferTexture3DEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLuint, GLint, GLint)), driDispatchRemapTable[FramebufferTexture3DEXT_remap_index], parameters)
-#define GET_FramebufferTexture3DEXT(disp) GET_by_offset(disp, driDispatchRemapTable[FramebufferTexture3DEXT_remap_index])
-#define SET_FramebufferTexture3DEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FramebufferTexture3DEXT_remap_index], fn)
-#define CALL_GenFramebuffersEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), driDispatchRemapTable[GenFramebuffersEXT_remap_index], parameters)
-#define GET_GenFramebuffersEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GenFramebuffersEXT_remap_index])
-#define SET_GenFramebuffersEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GenFramebuffersEXT_remap_index], fn)
-#define CALL_GenRenderbuffersEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), driDispatchRemapTable[GenRenderbuffersEXT_remap_index], parameters)
-#define GET_GenRenderbuffersEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GenRenderbuffersEXT_remap_index])
-#define SET_GenRenderbuffersEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GenRenderbuffersEXT_remap_index], fn)
-#define CALL_GenerateMipmapEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), driDispatchRemapTable[GenerateMipmapEXT_remap_index], parameters)
-#define GET_GenerateMipmapEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GenerateMipmapEXT_remap_index])
-#define SET_GenerateMipmapEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GenerateMipmapEXT_remap_index], fn)
-#define CALL_GetFramebufferAttachmentParameterivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLint *)), driDispatchRemapTable[GetFramebufferAttachmentParameterivEXT_remap_index], parameters)
-#define GET_GetFramebufferAttachmentParameterivEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GetFramebufferAttachmentParameterivEXT_remap_index])
-#define SET_GetFramebufferAttachmentParameterivEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetFramebufferAttachmentParameterivEXT_remap_index], fn)
-#define CALL_GetRenderbufferParameterivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), driDispatchRemapTable[GetRenderbufferParameterivEXT_remap_index], parameters)
-#define GET_GetRenderbufferParameterivEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GetRenderbufferParameterivEXT_remap_index])
-#define SET_GetRenderbufferParameterivEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetRenderbufferParameterivEXT_remap_index], fn)
-#define CALL_IsFramebufferEXT(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[IsFramebufferEXT_remap_index], parameters)
-#define GET_IsFramebufferEXT(disp) GET_by_offset(disp, driDispatchRemapTable[IsFramebufferEXT_remap_index])
-#define SET_IsFramebufferEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IsFramebufferEXT_remap_index], fn)
-#define CALL_IsRenderbufferEXT(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[IsRenderbufferEXT_remap_index], parameters)
-#define GET_IsRenderbufferEXT(disp) GET_by_offset(disp, driDispatchRemapTable[IsRenderbufferEXT_remap_index])
-#define SET_IsRenderbufferEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IsRenderbufferEXT_remap_index], fn)
-#define CALL_RenderbufferStorageEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLsizei, GLsizei)), driDispatchRemapTable[RenderbufferStorageEXT_remap_index], parameters)
-#define GET_RenderbufferStorageEXT(disp) GET_by_offset(disp, driDispatchRemapTable[RenderbufferStorageEXT_remap_index])
-#define SET_RenderbufferStorageEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[RenderbufferStorageEXT_remap_index], fn)
-#define CALL_BlitFramebufferEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum)), driDispatchRemapTable[BlitFramebufferEXT_remap_index], parameters)
-#define GET_BlitFramebufferEXT(disp) GET_by_offset(disp, driDispatchRemapTable[BlitFramebufferEXT_remap_index])
-#define SET_BlitFramebufferEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BlitFramebufferEXT_remap_index], fn)
-#define CALL_BufferParameteriAPPLE(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint)), driDispatchRemapTable[BufferParameteriAPPLE_remap_index], parameters)
-#define GET_BufferParameteriAPPLE(disp) GET_by_offset(disp, driDispatchRemapTable[BufferParameteriAPPLE_remap_index])
-#define SET_BufferParameteriAPPLE(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BufferParameteriAPPLE_remap_index], fn)
-#define CALL_FlushMappedBufferRangeAPPLE(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLintptr, GLsizeiptr)), driDispatchRemapTable[FlushMappedBufferRangeAPPLE_remap_index], parameters)
-#define GET_FlushMappedBufferRangeAPPLE(disp) GET_by_offset(disp, driDispatchRemapTable[FlushMappedBufferRangeAPPLE_remap_index])
-#define SET_FlushMappedBufferRangeAPPLE(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FlushMappedBufferRangeAPPLE_remap_index], fn)
-#define CALL_FramebufferTextureLayerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLuint, GLint, GLint)), driDispatchRemapTable[FramebufferTextureLayerEXT_remap_index], parameters)
-#define GET_FramebufferTextureLayerEXT(disp) GET_by_offset(disp, driDispatchRemapTable[FramebufferTextureLayerEXT_remap_index])
-#define SET_FramebufferTextureLayerEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FramebufferTextureLayerEXT_remap_index], fn)
-#define CALL_ProvokingVertexEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), driDispatchRemapTable[ProvokingVertexEXT_remap_index], parameters)
-#define GET_ProvokingVertexEXT(disp) GET_by_offset(disp, driDispatchRemapTable[ProvokingVertexEXT_remap_index])
-#define SET_ProvokingVertexEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProvokingVertexEXT_remap_index], fn)
-#define CALL_GetTexParameterPointervAPPLE(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLvoid **)), driDispatchRemapTable[GetTexParameterPointervAPPLE_remap_index], parameters)
-#define GET_GetTexParameterPointervAPPLE(disp) GET_by_offset(disp, driDispatchRemapTable[GetTexParameterPointervAPPLE_remap_index])
-#define SET_GetTexParameterPointervAPPLE(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetTexParameterPointervAPPLE_remap_index], fn)
-#define CALL_TextureRangeAPPLE(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, GLvoid *)), driDispatchRemapTable[TextureRangeAPPLE_remap_index], parameters)
-#define GET_TextureRangeAPPLE(disp) GET_by_offset(disp, driDispatchRemapTable[TextureRangeAPPLE_remap_index])
-#define SET_TextureRangeAPPLE(disp, fn) SET_by_offset(disp, driDispatchRemapTable[TextureRangeAPPLE_remap_index], fn)
-#define CALL_StencilFuncSeparateATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint, GLuint)), driDispatchRemapTable[StencilFuncSeparateATI_remap_index], parameters)
-#define GET_StencilFuncSeparateATI(disp) GET_by_offset(disp, driDispatchRemapTable[StencilFuncSeparateATI_remap_index])
-#define SET_StencilFuncSeparateATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[StencilFuncSeparateATI_remap_index], fn)
-#define CALL_ProgramEnvParameters4fvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLsizei, const GLfloat *)), driDispatchRemapTable[ProgramEnvParameters4fvEXT_remap_index], parameters)
-#define GET_ProgramEnvParameters4fvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramEnvParameters4fvEXT_remap_index])
-#define SET_ProgramEnvParameters4fvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramEnvParameters4fvEXT_remap_index], fn)
-#define CALL_ProgramLocalParameters4fvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLsizei, const GLfloat *)), driDispatchRemapTable[ProgramLocalParameters4fvEXT_remap_index], parameters)
-#define GET_ProgramLocalParameters4fvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramLocalParameters4fvEXT_remap_index])
-#define SET_ProgramLocalParameters4fvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramLocalParameters4fvEXT_remap_index], fn)
-#define CALL_GetQueryObjecti64vEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint64EXT *)), driDispatchRemapTable[GetQueryObjecti64vEXT_remap_index], parameters)
-#define GET_GetQueryObjecti64vEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GetQueryObjecti64vEXT_remap_index])
-#define SET_GetQueryObjecti64vEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetQueryObjecti64vEXT_remap_index], fn)
-#define CALL_GetQueryObjectui64vEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLuint64EXT *)), driDispatchRemapTable[GetQueryObjectui64vEXT_remap_index], parameters)
-#define GET_GetQueryObjectui64vEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GetQueryObjectui64vEXT_remap_index])
-#define SET_GetQueryObjectui64vEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetQueryObjectui64vEXT_remap_index], fn)
-
-#endif /* !defined(IN_DRI_DRIVER) */
+#include "glapioffsets.h"
+#include "glapidispatch.h"
 
-#endif /* !defined( _DISPATCH_H_ ) */
+#endif /* _DISPATCH_H */
index da4be14707efdd21ba9f3da3ed1eb394c7a52326..75d2f3c4383bc8df3ab6402100ece654561c55dd 100644 (file)
 
 <xi:include href="ARB_draw_elements_base_vertex.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
 
+<xi:include href="NV_conditional_render.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
+
 
 <!-- Non-ARB extensions sorted by extension number. -->
 
 
 <xi:include href="EXT_framebuffer_object.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
 
+<xi:include href="EXT_packed_depth_stencil.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
+
 <xi:include href="EXT_provoking_vertex.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
 
-<category name="GL_EXT_framebuffer_blit" number="316">
-    <enum name="READ_FRAMEBUFFER_EXT" value="0x8CA8"/>
-    <enum name="DRAW_FRAMEBUFFER_EXT" value="0x8CA9"/>
-    <enum name="DRAW_FRAMEBUFFER_BINDING_EXT" count="1" value="0x8CA6">
-        <size name="Get" mode="get"/>
-    </enum>
-    <enum name="READ_FRAMEBUFFER_BINDING_EXT" count="1" value="0x8CAA">
-        <size name="Get" mode="get"/>
-    </enum>
-    <function name="BlitFramebufferEXT" offset="assign" static_dispatch="false">
-        <param name="srcX0" type="GLint"/>
-        <param name="srcY0" type="GLint"/>
-        <param name="srcX1" type="GLint"/>
-        <param name="srcY1" type="GLint"/>
-        <param name="dstX0" type="GLint"/>
-        <param name="dstY0" type="GLint"/>
-        <param name="dstX1" type="GLint"/>
-        <param name="dstY1" type="GLint"/>
-        <param name="mask" type="GLbitfield"/>
-        <param name="filter" type="GLenum"/>
-    </function>
-</category>
+<xi:include href="EXT_draw_buffers2.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
+
 
 <category name="GL_APPLE_flush_buffer_range" number="321">
     <enum name="BUFFER_SERIALIZED_MODIFY_APPLE" count="1" value="0x8A12">
index 59f8d372b0e2a7f55a1a046d40825e82d48ec7cd..ca6c90ffd8e93d96acfcd60a911ddd4661b59418 100644 (file)
@@ -43,6 +43,9 @@ class PrintGlOffsets(gl_XML.gl_print_base):
        def printBody(self, api):
                abi = [ "1.0", "1.1", "1.2", "GL_ARB_multitexture" ]
 
+               print '/* this file should not be included directly in mesa */'
+               print ''
+
                functions = []
                abi_functions = []
                count = 0
@@ -60,7 +63,7 @@ class PrintGlOffsets(gl_XML.gl_print_base):
                        last_static = f.offset
 
                print ''
-               print '#if !defined(IN_DRI_DRIVER)'
+               print '#if !defined(_GLAPI_USE_REMAP_TABLE)'
                print ''
 
                for [f, index] in functions:
@@ -76,7 +79,7 @@ class PrintGlOffsets(gl_XML.gl_print_base):
                        print '#define _gloffset_%s driDispatchRemapTable[%s_remap_index]' % (f.name, f.name)
 
                print ''
-               print '#endif /* !defined(IN_DRI_DRIVER) */'
+               print '#endif /* !defined(_GLAPI_USE_REMAP_TABLE) */'
 
                return
 
index 55a33748aed344203cd023813a660710c4975b25..0e05b3431a17b76cb4d5061d668d821ceef95966 100644 (file)
@@ -71,7 +71,7 @@ class PrintRemapTable(gl_XML.gl_print_base):
        def __init__(self):
                gl_XML.gl_print_base.__init__(self)
 
-               self.header_tag = '_DISPATCH_H_'
+               self.header_tag = '_GLAPI_DISPATCH_H_'
                self.name = "gl_table.py (from Mesa)"
                self.license = license.bsd_license_template % ("(C) Copyright IBM Corporation 2005", "IBM")
                return
@@ -79,9 +79,10 @@ class PrintRemapTable(gl_XML.gl_print_base):
 
        def printRealHeader(self):
                print """
-#include "glapitable.h"
+/* this file should not be included directly in mesa */
+
 /**
- * \\file dispatch.h
+ * \\file glapidispatch.h
  * Macros for handling GL dispatch tables.
  *
  * For each known GL function, there are 3 macros in this file.  The first
@@ -133,7 +134,7 @@ class PrintRemapTable(gl_XML.gl_print_base):
 
 
                print ''
-               print '#if !defined(IN_DRI_DRIVER)'
+               print '#if !defined(_GLAPI_USE_REMAP_TABLE)'
                print ''
 
                for [f, index] in functions:
@@ -163,7 +164,7 @@ class PrintRemapTable(gl_XML.gl_print_base):
 
 
                print ''
-               print '#endif /* !defined(IN_DRI_DRIVER) */'
+               print '#endif /* !defined(_GLAPI_USE_REMAP_TABLE) */'
                return
 
 
index e36fccb354cfa840115ebb6141aef62754d69d6e..84e5a8270a0d240325bd047a3f6fe8502bb850fc 100644 (file)
@@ -73,7 +73,6 @@
 #include "glapioffsets.h"
 #include "glapitable.h"
 
-
 /***** BEGIN NO-OP DISPATCH *****/
 
 static GLboolean WarnFlag = GL_FALSE;
@@ -97,22 +96,19 @@ _glapi_set_warning_func( _glapi_warning_func func )
    warning_func = func;
 }
 
-static GLboolean
-warn(void)
+static int
+warn(const char *func)
 {
 #if !defined(_WIN32_WCE)
    if ((WarnFlag || getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG"))
        && warning_func) {
-      return GL_TRUE;
-   }
-   else {
-      return GL_FALSE;
+      warning_func(NULL, "GL User Error: called without context: %s", func);
    }
-#else
-   return GL_FALSE;
 #endif
+   return 0;
 }
 
+#ifdef DEBUG
 
 #define KEYWORD1 static
 #define KEYWORD1_ALT static
@@ -122,27 +118,34 @@ warn(void)
 #define F NULL
 
 #define DISPATCH(func, args, msg)                                            \
-   if (warn()) {                                                             \
-      warning_func(NULL, "GL User Error: called without context: %s", #func); \
-   }
+   warn(#func);
 
 #define RETURN_DISPATCH(func, args, msg)                                     \
-   if (warn()) {                                                             \
-      warning_func(NULL, "GL User Error: called without context: %s", #func); \
-   }                                                                         \
-   return 0
+   return warn(#func);
+
+#define TABLE_ENTRY(name) (_glapi_proc) NoOp##name
+
+#else
+
+static void
+NoOpGeneric(void)
+{
+   if ((WarnFlag || getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG"))
+       && warning_func) {
+      warning_func(NULL, "GL User Error: calling GL function");
+   }
+}
+
+#define TABLE_ENTRY(name) (_glapi_proc) NoOpGeneric
+
+#endif
 
 #define DISPATCH_TABLE_NAME __glapi_noop_table
 #define UNUSED_TABLE_NAME __unused_noop_functions
 
-#define TABLE_ENTRY(name) (_glapi_proc) NoOp##name
-
 static GLint NoOpUnused(void)
 {
-   if (warn()) {
-      warning_func(NULL, "GL User Error: calling extension function without a current context\n");
-   }
-   return 0;
+   return warn("extension function");
 }
 
 #include "glapitemp.h"
@@ -237,7 +240,7 @@ PUBLIC void *_glapi_Context = NULL;
  * We should call this periodically from a function such as glXMakeCurrent
  * in order to test if multiple threads are being used.
  */
-void
+PUBLIC void
 _glapi_check_multithread(void)
 {
 #if defined(THREADS) && !defined(GLX_USE_TLS)
index ed443c12c89f2e1f327f1973f09ff4a974f4ffac..1401c1cb586ce5154b4c91ffe992da83a3f54323 100644 (file)
@@ -530,7 +530,7 @@ _glapi_get_proc_offset(const char *funcName)
  * in the name of static functions, try generating a new API entrypoint on
  * the fly with assembly language.
  */
-_glapi_proc
+PUBLIC _glapi_proc
 _glapi_get_proc_address(const char *funcName)
 {
    struct _glapi_function * entry;
diff --git a/src/mesa/glapi/glapidispatch.h b/src/mesa/glapi/glapidispatch.h
new file mode 100644 (file)
index 0000000..51ae7fe
--- /dev/null
@@ -0,0 +1,4063 @@
+/* DO NOT EDIT - This file generated automatically by gl_table.py (from Mesa) script */
+
+/*
+ * (C) Copyright IBM Corporation 2005
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * IBM,
+ * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#if !defined( _GLAPI_DISPATCH_H_ )
+#  define _GLAPI_DISPATCH_H_
+
+
+/* this file should not be included directly in mesa */
+
+/**
+ * \file glapidispatch.h
+ * Macros for handling GL dispatch tables.
+ *
+ * For each known GL function, there are 3 macros in this file.  The first
+ * macro is named CALL_FuncName and is used to call that GL function using
+ * the specified dispatch table.  The other 2 macros, called GET_FuncName
+ * can SET_FuncName, are used to get and set the dispatch pointer for the
+ * named function in the specified dispatch table.
+ */
+
+#define CALL_by_offset(disp, cast, offset, parameters) \
+    (*(cast (GET_by_offset(disp, offset)))) parameters
+#define GET_by_offset(disp, offset) \
+    (offset >= 0) ? (((_glapi_proc *)(disp))[offset]) : NULL
+#define SET_by_offset(disp, offset, fn) \
+    do { \
+        if ( (offset) < 0 ) { \
+            /* fprintf( stderr, "[%s:%u] SET_by_offset(%p, %d, %s)!\n", */ \
+            /*         __func__, __LINE__, disp, offset, # fn); */ \
+            /* abort(); */ \
+        } \
+        else { \
+            ( (_glapi_proc *) (disp) )[offset] = (_glapi_proc) fn; \
+        } \
+    } while(0)
+
+#define CALL_NewList(disp, parameters) (*((disp)->NewList)) parameters
+#define GET_NewList(disp) ((disp)->NewList)
+#define SET_NewList(disp, fn) ((disp)->NewList = fn)
+#define CALL_EndList(disp, parameters) (*((disp)->EndList)) parameters
+#define GET_EndList(disp) ((disp)->EndList)
+#define SET_EndList(disp, fn) ((disp)->EndList = fn)
+#define CALL_CallList(disp, parameters) (*((disp)->CallList)) parameters
+#define GET_CallList(disp) ((disp)->CallList)
+#define SET_CallList(disp, fn) ((disp)->CallList = fn)
+#define CALL_CallLists(disp, parameters) (*((disp)->CallLists)) parameters
+#define GET_CallLists(disp) ((disp)->CallLists)
+#define SET_CallLists(disp, fn) ((disp)->CallLists = fn)
+#define CALL_DeleteLists(disp, parameters) (*((disp)->DeleteLists)) parameters
+#define GET_DeleteLists(disp) ((disp)->DeleteLists)
+#define SET_DeleteLists(disp, fn) ((disp)->DeleteLists = fn)
+#define CALL_GenLists(disp, parameters) (*((disp)->GenLists)) parameters
+#define GET_GenLists(disp) ((disp)->GenLists)
+#define SET_GenLists(disp, fn) ((disp)->GenLists = fn)
+#define CALL_ListBase(disp, parameters) (*((disp)->ListBase)) parameters
+#define GET_ListBase(disp) ((disp)->ListBase)
+#define SET_ListBase(disp, fn) ((disp)->ListBase = fn)
+#define CALL_Begin(disp, parameters) (*((disp)->Begin)) parameters
+#define GET_Begin(disp) ((disp)->Begin)
+#define SET_Begin(disp, fn) ((disp)->Begin = fn)
+#define CALL_Bitmap(disp, parameters) (*((disp)->Bitmap)) parameters
+#define GET_Bitmap(disp) ((disp)->Bitmap)
+#define SET_Bitmap(disp, fn) ((disp)->Bitmap = fn)
+#define CALL_Color3b(disp, parameters) (*((disp)->Color3b)) parameters
+#define GET_Color3b(disp) ((disp)->Color3b)
+#define SET_Color3b(disp, fn) ((disp)->Color3b = fn)
+#define CALL_Color3bv(disp, parameters) (*((disp)->Color3bv)) parameters
+#define GET_Color3bv(disp) ((disp)->Color3bv)
+#define SET_Color3bv(disp, fn) ((disp)->Color3bv = fn)
+#define CALL_Color3d(disp, parameters) (*((disp)->Color3d)) parameters
+#define GET_Color3d(disp) ((disp)->Color3d)
+#define SET_Color3d(disp, fn) ((disp)->Color3d = fn)
+#define CALL_Color3dv(disp, parameters) (*((disp)->Color3dv)) parameters
+#define GET_Color3dv(disp) ((disp)->Color3dv)
+#define SET_Color3dv(disp, fn) ((disp)->Color3dv = fn)
+#define CALL_Color3f(disp, parameters) (*((disp)->Color3f)) parameters
+#define GET_Color3f(disp) ((disp)->Color3f)
+#define SET_Color3f(disp, fn) ((disp)->Color3f = fn)
+#define CALL_Color3fv(disp, parameters) (*((disp)->Color3fv)) parameters
+#define GET_Color3fv(disp) ((disp)->Color3fv)
+#define SET_Color3fv(disp, fn) ((disp)->Color3fv = fn)
+#define CALL_Color3i(disp, parameters) (*((disp)->Color3i)) parameters
+#define GET_Color3i(disp) ((disp)->Color3i)
+#define SET_Color3i(disp, fn) ((disp)->Color3i = fn)
+#define CALL_Color3iv(disp, parameters) (*((disp)->Color3iv)) parameters
+#define GET_Color3iv(disp) ((disp)->Color3iv)
+#define SET_Color3iv(disp, fn) ((disp)->Color3iv = fn)
+#define CALL_Color3s(disp, parameters) (*((disp)->Color3s)) parameters
+#define GET_Color3s(disp) ((disp)->Color3s)
+#define SET_Color3s(disp, fn) ((disp)->Color3s = fn)
+#define CALL_Color3sv(disp, parameters) (*((disp)->Color3sv)) parameters
+#define GET_Color3sv(disp) ((disp)->Color3sv)
+#define SET_Color3sv(disp, fn) ((disp)->Color3sv = fn)
+#define CALL_Color3ub(disp, parameters) (*((disp)->Color3ub)) parameters
+#define GET_Color3ub(disp) ((disp)->Color3ub)
+#define SET_Color3ub(disp, fn) ((disp)->Color3ub = fn)
+#define CALL_Color3ubv(disp, parameters) (*((disp)->Color3ubv)) parameters
+#define GET_Color3ubv(disp) ((disp)->Color3ubv)
+#define SET_Color3ubv(disp, fn) ((disp)->Color3ubv = fn)
+#define CALL_Color3ui(disp, parameters) (*((disp)->Color3ui)) parameters
+#define GET_Color3ui(disp) ((disp)->Color3ui)
+#define SET_Color3ui(disp, fn) ((disp)->Color3ui = fn)
+#define CALL_Color3uiv(disp, parameters) (*((disp)->Color3uiv)) parameters
+#define GET_Color3uiv(disp) ((disp)->Color3uiv)
+#define SET_Color3uiv(disp, fn) ((disp)->Color3uiv = fn)
+#define CALL_Color3us(disp, parameters) (*((disp)->Color3us)) parameters
+#define GET_Color3us(disp) ((disp)->Color3us)
+#define SET_Color3us(disp, fn) ((disp)->Color3us = fn)
+#define CALL_Color3usv(disp, parameters) (*((disp)->Color3usv)) parameters
+#define GET_Color3usv(disp) ((disp)->Color3usv)
+#define SET_Color3usv(disp, fn) ((disp)->Color3usv = fn)
+#define CALL_Color4b(disp, parameters) (*((disp)->Color4b)) parameters
+#define GET_Color4b(disp) ((disp)->Color4b)
+#define SET_Color4b(disp, fn) ((disp)->Color4b = fn)
+#define CALL_Color4bv(disp, parameters) (*((disp)->Color4bv)) parameters
+#define GET_Color4bv(disp) ((disp)->Color4bv)
+#define SET_Color4bv(disp, fn) ((disp)->Color4bv = fn)
+#define CALL_Color4d(disp, parameters) (*((disp)->Color4d)) parameters
+#define GET_Color4d(disp) ((disp)->Color4d)
+#define SET_Color4d(disp, fn) ((disp)->Color4d = fn)
+#define CALL_Color4dv(disp, parameters) (*((disp)->Color4dv)) parameters
+#define GET_Color4dv(disp) ((disp)->Color4dv)
+#define SET_Color4dv(disp, fn) ((disp)->Color4dv = fn)
+#define CALL_Color4f(disp, parameters) (*((disp)->Color4f)) parameters
+#define GET_Color4f(disp) ((disp)->Color4f)
+#define SET_Color4f(disp, fn) ((disp)->Color4f = fn)
+#define CALL_Color4fv(disp, parameters) (*((disp)->Color4fv)) parameters
+#define GET_Color4fv(disp) ((disp)->Color4fv)
+#define SET_Color4fv(disp, fn) ((disp)->Color4fv = fn)
+#define CALL_Color4i(disp, parameters) (*((disp)->Color4i)) parameters
+#define GET_Color4i(disp) ((disp)->Color4i)
+#define SET_Color4i(disp, fn) ((disp)->Color4i = fn)
+#define CALL_Color4iv(disp, parameters) (*((disp)->Color4iv)) parameters
+#define GET_Color4iv(disp) ((disp)->Color4iv)
+#define SET_Color4iv(disp, fn) ((disp)->Color4iv = fn)
+#define CALL_Color4s(disp, parameters) (*((disp)->Color4s)) parameters
+#define GET_Color4s(disp) ((disp)->Color4s)
+#define SET_Color4s(disp, fn) ((disp)->Color4s = fn)
+#define CALL_Color4sv(disp, parameters) (*((disp)->Color4sv)) parameters
+#define GET_Color4sv(disp) ((disp)->Color4sv)
+#define SET_Color4sv(disp, fn) ((disp)->Color4sv = fn)
+#define CALL_Color4ub(disp, parameters) (*((disp)->Color4ub)) parameters
+#define GET_Color4ub(disp) ((disp)->Color4ub)
+#define SET_Color4ub(disp, fn) ((disp)->Color4ub = fn)
+#define CALL_Color4ubv(disp, parameters) (*((disp)->Color4ubv)) parameters
+#define GET_Color4ubv(disp) ((disp)->Color4ubv)
+#define SET_Color4ubv(disp, fn) ((disp)->Color4ubv = fn)
+#define CALL_Color4ui(disp, parameters) (*((disp)->Color4ui)) parameters
+#define GET_Color4ui(disp) ((disp)->Color4ui)
+#define SET_Color4ui(disp, fn) ((disp)->Color4ui = fn)
+#define CALL_Color4uiv(disp, parameters) (*((disp)->Color4uiv)) parameters
+#define GET_Color4uiv(disp) ((disp)->Color4uiv)
+#define SET_Color4uiv(disp, fn) ((disp)->Color4uiv = fn)
+#define CALL_Color4us(disp, parameters) (*((disp)->Color4us)) parameters
+#define GET_Color4us(disp) ((disp)->Color4us)
+#define SET_Color4us(disp, fn) ((disp)->Color4us = fn)
+#define CALL_Color4usv(disp, parameters) (*((disp)->Color4usv)) parameters
+#define GET_Color4usv(disp) ((disp)->Color4usv)
+#define SET_Color4usv(disp, fn) ((disp)->Color4usv = fn)
+#define CALL_EdgeFlag(disp, parameters) (*((disp)->EdgeFlag)) parameters
+#define GET_EdgeFlag(disp) ((disp)->EdgeFlag)
+#define SET_EdgeFlag(disp, fn) ((disp)->EdgeFlag = fn)
+#define CALL_EdgeFlagv(disp, parameters) (*((disp)->EdgeFlagv)) parameters
+#define GET_EdgeFlagv(disp) ((disp)->EdgeFlagv)
+#define SET_EdgeFlagv(disp, fn) ((disp)->EdgeFlagv = fn)
+#define CALL_End(disp, parameters) (*((disp)->End)) parameters
+#define GET_End(disp) ((disp)->End)
+#define SET_End(disp, fn) ((disp)->End = fn)
+#define CALL_Indexd(disp, parameters) (*((disp)->Indexd)) parameters
+#define GET_Indexd(disp) ((disp)->Indexd)
+#define SET_Indexd(disp, fn) ((disp)->Indexd = fn)
+#define CALL_Indexdv(disp, parameters) (*((disp)->Indexdv)) parameters
+#define GET_Indexdv(disp) ((disp)->Indexdv)
+#define SET_Indexdv(disp, fn) ((disp)->Indexdv = fn)
+#define CALL_Indexf(disp, parameters) (*((disp)->Indexf)) parameters
+#define GET_Indexf(disp) ((disp)->Indexf)
+#define SET_Indexf(disp, fn) ((disp)->Indexf = fn)
+#define CALL_Indexfv(disp, parameters) (*((disp)->Indexfv)) parameters
+#define GET_Indexfv(disp) ((disp)->Indexfv)
+#define SET_Indexfv(disp, fn) ((disp)->Indexfv = fn)
+#define CALL_Indexi(disp, parameters) (*((disp)->Indexi)) parameters
+#define GET_Indexi(disp) ((disp)->Indexi)
+#define SET_Indexi(disp, fn) ((disp)->Indexi = fn)
+#define CALL_Indexiv(disp, parameters) (*((disp)->Indexiv)) parameters
+#define GET_Indexiv(disp) ((disp)->Indexiv)
+#define SET_Indexiv(disp, fn) ((disp)->Indexiv = fn)
+#define CALL_Indexs(disp, parameters) (*((disp)->Indexs)) parameters
+#define GET_Indexs(disp) ((disp)->Indexs)
+#define SET_Indexs(disp, fn) ((disp)->Indexs = fn)
+#define CALL_Indexsv(disp, parameters) (*((disp)->Indexsv)) parameters
+#define GET_Indexsv(disp) ((disp)->Indexsv)
+#define SET_Indexsv(disp, fn) ((disp)->Indexsv = fn)
+#define CALL_Normal3b(disp, parameters) (*((disp)->Normal3b)) parameters
+#define GET_Normal3b(disp) ((disp)->Normal3b)
+#define SET_Normal3b(disp, fn) ((disp)->Normal3b = fn)
+#define CALL_Normal3bv(disp, parameters) (*((disp)->Normal3bv)) parameters
+#define GET_Normal3bv(disp) ((disp)->Normal3bv)
+#define SET_Normal3bv(disp, fn) ((disp)->Normal3bv = fn)
+#define CALL_Normal3d(disp, parameters) (*((disp)->Normal3d)) parameters
+#define GET_Normal3d(disp) ((disp)->Normal3d)
+#define SET_Normal3d(disp, fn) ((disp)->Normal3d = fn)
+#define CALL_Normal3dv(disp, parameters) (*((disp)->Normal3dv)) parameters
+#define GET_Normal3dv(disp) ((disp)->Normal3dv)
+#define SET_Normal3dv(disp, fn) ((disp)->Normal3dv = fn)
+#define CALL_Normal3f(disp, parameters) (*((disp)->Normal3f)) parameters
+#define GET_Normal3f(disp) ((disp)->Normal3f)
+#define SET_Normal3f(disp, fn) ((disp)->Normal3f = fn)
+#define CALL_Normal3fv(disp, parameters) (*((disp)->Normal3fv)) parameters
+#define GET_Normal3fv(disp) ((disp)->Normal3fv)
+#define SET_Normal3fv(disp, fn) ((disp)->Normal3fv = fn)
+#define CALL_Normal3i(disp, parameters) (*((disp)->Normal3i)) parameters
+#define GET_Normal3i(disp) ((disp)->Normal3i)
+#define SET_Normal3i(disp, fn) ((disp)->Normal3i = fn)
+#define CALL_Normal3iv(disp, parameters) (*((disp)->Normal3iv)) parameters
+#define GET_Normal3iv(disp) ((disp)->Normal3iv)
+#define SET_Normal3iv(disp, fn) ((disp)->Normal3iv = fn)
+#define CALL_Normal3s(disp, parameters) (*((disp)->Normal3s)) parameters
+#define GET_Normal3s(disp) ((disp)->Normal3s)
+#define SET_Normal3s(disp, fn) ((disp)->Normal3s = fn)
+#define CALL_Normal3sv(disp, parameters) (*((disp)->Normal3sv)) parameters
+#define GET_Normal3sv(disp) ((disp)->Normal3sv)
+#define SET_Normal3sv(disp, fn) ((disp)->Normal3sv = fn)
+#define CALL_RasterPos2d(disp, parameters) (*((disp)->RasterPos2d)) parameters
+#define GET_RasterPos2d(disp) ((disp)->RasterPos2d)
+#define SET_RasterPos2d(disp, fn) ((disp)->RasterPos2d = fn)
+#define CALL_RasterPos2dv(disp, parameters) (*((disp)->RasterPos2dv)) parameters
+#define GET_RasterPos2dv(disp) ((disp)->RasterPos2dv)
+#define SET_RasterPos2dv(disp, fn) ((disp)->RasterPos2dv = fn)
+#define CALL_RasterPos2f(disp, parameters) (*((disp)->RasterPos2f)) parameters
+#define GET_RasterPos2f(disp) ((disp)->RasterPos2f)
+#define SET_RasterPos2f(disp, fn) ((disp)->RasterPos2f = fn)
+#define CALL_RasterPos2fv(disp, parameters) (*((disp)->RasterPos2fv)) parameters
+#define GET_RasterPos2fv(disp) ((disp)->RasterPos2fv)
+#define SET_RasterPos2fv(disp, fn) ((disp)->RasterPos2fv = fn)
+#define CALL_RasterPos2i(disp, parameters) (*((disp)->RasterPos2i)) parameters
+#define GET_RasterPos2i(disp) ((disp)->RasterPos2i)
+#define SET_RasterPos2i(disp, fn) ((disp)->RasterPos2i = fn)
+#define CALL_RasterPos2iv(disp, parameters) (*((disp)->RasterPos2iv)) parameters
+#define GET_RasterPos2iv(disp) ((disp)->RasterPos2iv)
+#define SET_RasterPos2iv(disp, fn) ((disp)->RasterPos2iv = fn)
+#define CALL_RasterPos2s(disp, parameters) (*((disp)->RasterPos2s)) parameters
+#define GET_RasterPos2s(disp) ((disp)->RasterPos2s)
+#define SET_RasterPos2s(disp, fn) ((disp)->RasterPos2s = fn)
+#define CALL_RasterPos2sv(disp, parameters) (*((disp)->RasterPos2sv)) parameters
+#define GET_RasterPos2sv(disp) ((disp)->RasterPos2sv)
+#define SET_RasterPos2sv(disp, fn) ((disp)->RasterPos2sv = fn)
+#define CALL_RasterPos3d(disp, parameters) (*((disp)->RasterPos3d)) parameters
+#define GET_RasterPos3d(disp) ((disp)->RasterPos3d)
+#define SET_RasterPos3d(disp, fn) ((disp)->RasterPos3d = fn)
+#define CALL_RasterPos3dv(disp, parameters) (*((disp)->RasterPos3dv)) parameters
+#define GET_RasterPos3dv(disp) ((disp)->RasterPos3dv)
+#define SET_RasterPos3dv(disp, fn) ((disp)->RasterPos3dv = fn)
+#define CALL_RasterPos3f(disp, parameters) (*((disp)->RasterPos3f)) parameters
+#define GET_RasterPos3f(disp) ((disp)->RasterPos3f)
+#define SET_RasterPos3f(disp, fn) ((disp)->RasterPos3f = fn)
+#define CALL_RasterPos3fv(disp, parameters) (*((disp)->RasterPos3fv)) parameters
+#define GET_RasterPos3fv(disp) ((disp)->RasterPos3fv)
+#define SET_RasterPos3fv(disp, fn) ((disp)->RasterPos3fv = fn)
+#define CALL_RasterPos3i(disp, parameters) (*((disp)->RasterPos3i)) parameters
+#define GET_RasterPos3i(disp) ((disp)->RasterPos3i)
+#define SET_RasterPos3i(disp, fn) ((disp)->RasterPos3i = fn)
+#define CALL_RasterPos3iv(disp, parameters) (*((disp)->RasterPos3iv)) parameters
+#define GET_RasterPos3iv(disp) ((disp)->RasterPos3iv)
+#define SET_RasterPos3iv(disp, fn) ((disp)->RasterPos3iv = fn)
+#define CALL_RasterPos3s(disp, parameters) (*((disp)->RasterPos3s)) parameters
+#define GET_RasterPos3s(disp) ((disp)->RasterPos3s)
+#define SET_RasterPos3s(disp, fn) ((disp)->RasterPos3s = fn)
+#define CALL_RasterPos3sv(disp, parameters) (*((disp)->RasterPos3sv)) parameters
+#define GET_RasterPos3sv(disp) ((disp)->RasterPos3sv)
+#define SET_RasterPos3sv(disp, fn) ((disp)->RasterPos3sv = fn)
+#define CALL_RasterPos4d(disp, parameters) (*((disp)->RasterPos4d)) parameters
+#define GET_RasterPos4d(disp) ((disp)->RasterPos4d)
+#define SET_RasterPos4d(disp, fn) ((disp)->RasterPos4d = fn)
+#define CALL_RasterPos4dv(disp, parameters) (*((disp)->RasterPos4dv)) parameters
+#define GET_RasterPos4dv(disp) ((disp)->RasterPos4dv)
+#define SET_RasterPos4dv(disp, fn) ((disp)->RasterPos4dv = fn)
+#define CALL_RasterPos4f(disp, parameters) (*((disp)->RasterPos4f)) parameters
+#define GET_RasterPos4f(disp) ((disp)->RasterPos4f)
+#define SET_RasterPos4f(disp, fn) ((disp)->RasterPos4f = fn)
+#define CALL_RasterPos4fv(disp, parameters) (*((disp)->RasterPos4fv)) parameters
+#define GET_RasterPos4fv(disp) ((disp)->RasterPos4fv)
+#define SET_RasterPos4fv(disp, fn) ((disp)->RasterPos4fv = fn)
+#define CALL_RasterPos4i(disp, parameters) (*((disp)->RasterPos4i)) parameters
+#define GET_RasterPos4i(disp) ((disp)->RasterPos4i)
+#define SET_RasterPos4i(disp, fn) ((disp)->RasterPos4i = fn)
+#define CALL_RasterPos4iv(disp, parameters) (*((disp)->RasterPos4iv)) parameters
+#define GET_RasterPos4iv(disp) ((disp)->RasterPos4iv)
+#define SET_RasterPos4iv(disp, fn) ((disp)->RasterPos4iv = fn)
+#define CALL_RasterPos4s(disp, parameters) (*((disp)->RasterPos4s)) parameters
+#define GET_RasterPos4s(disp) ((disp)->RasterPos4s)
+#define SET_RasterPos4s(disp, fn) ((disp)->RasterPos4s = fn)
+#define CALL_RasterPos4sv(disp, parameters) (*((disp)->RasterPos4sv)) parameters
+#define GET_RasterPos4sv(disp) ((disp)->RasterPos4sv)
+#define SET_RasterPos4sv(disp, fn) ((disp)->RasterPos4sv = fn)
+#define CALL_Rectd(disp, parameters) (*((disp)->Rectd)) parameters
+#define GET_Rectd(disp) ((disp)->Rectd)
+#define SET_Rectd(disp, fn) ((disp)->Rectd = fn)
+#define CALL_Rectdv(disp, parameters) (*((disp)->Rectdv)) parameters
+#define GET_Rectdv(disp) ((disp)->Rectdv)
+#define SET_Rectdv(disp, fn) ((disp)->Rectdv = fn)
+#define CALL_Rectf(disp, parameters) (*((disp)->Rectf)) parameters
+#define GET_Rectf(disp) ((disp)->Rectf)
+#define SET_Rectf(disp, fn) ((disp)->Rectf = fn)
+#define CALL_Rectfv(disp, parameters) (*((disp)->Rectfv)) parameters
+#define GET_Rectfv(disp) ((disp)->Rectfv)
+#define SET_Rectfv(disp, fn) ((disp)->Rectfv = fn)
+#define CALL_Recti(disp, parameters) (*((disp)->Recti)) parameters
+#define GET_Recti(disp) ((disp)->Recti)
+#define SET_Recti(disp, fn) ((disp)->Recti = fn)
+#define CALL_Rectiv(disp, parameters) (*((disp)->Rectiv)) parameters
+#define GET_Rectiv(disp) ((disp)->Rectiv)
+#define SET_Rectiv(disp, fn) ((disp)->Rectiv = fn)
+#define CALL_Rects(disp, parameters) (*((disp)->Rects)) parameters
+#define GET_Rects(disp) ((disp)->Rects)
+#define SET_Rects(disp, fn) ((disp)->Rects = fn)
+#define CALL_Rectsv(disp, parameters) (*((disp)->Rectsv)) parameters
+#define GET_Rectsv(disp) ((disp)->Rectsv)
+#define SET_Rectsv(disp, fn) ((disp)->Rectsv = fn)
+#define CALL_TexCoord1d(disp, parameters) (*((disp)->TexCoord1d)) parameters
+#define GET_TexCoord1d(disp) ((disp)->TexCoord1d)
+#define SET_TexCoord1d(disp, fn) ((disp)->TexCoord1d = fn)
+#define CALL_TexCoord1dv(disp, parameters) (*((disp)->TexCoord1dv)) parameters
+#define GET_TexCoord1dv(disp) ((disp)->TexCoord1dv)
+#define SET_TexCoord1dv(disp, fn) ((disp)->TexCoord1dv = fn)
+#define CALL_TexCoord1f(disp, parameters) (*((disp)->TexCoord1f)) parameters
+#define GET_TexCoord1f(disp) ((disp)->TexCoord1f)
+#define SET_TexCoord1f(disp, fn) ((disp)->TexCoord1f = fn)
+#define CALL_TexCoord1fv(disp, parameters) (*((disp)->TexCoord1fv)) parameters
+#define GET_TexCoord1fv(disp) ((disp)->TexCoord1fv)
+#define SET_TexCoord1fv(disp, fn) ((disp)->TexCoord1fv = fn)
+#define CALL_TexCoord1i(disp, parameters) (*((disp)->TexCoord1i)) parameters
+#define GET_TexCoord1i(disp) ((disp)->TexCoord1i)
+#define SET_TexCoord1i(disp, fn) ((disp)->TexCoord1i = fn)
+#define CALL_TexCoord1iv(disp, parameters) (*((disp)->TexCoord1iv)) parameters
+#define GET_TexCoord1iv(disp) ((disp)->TexCoord1iv)
+#define SET_TexCoord1iv(disp, fn) ((disp)->TexCoord1iv = fn)
+#define CALL_TexCoord1s(disp, parameters) (*((disp)->TexCoord1s)) parameters
+#define GET_TexCoord1s(disp) ((disp)->TexCoord1s)
+#define SET_TexCoord1s(disp, fn) ((disp)->TexCoord1s = fn)
+#define CALL_TexCoord1sv(disp, parameters) (*((disp)->TexCoord1sv)) parameters
+#define GET_TexCoord1sv(disp) ((disp)->TexCoord1sv)
+#define SET_TexCoord1sv(disp, fn) ((disp)->TexCoord1sv = fn)
+#define CALL_TexCoord2d(disp, parameters) (*((disp)->TexCoord2d)) parameters
+#define GET_TexCoord2d(disp) ((disp)->TexCoord2d)
+#define SET_TexCoord2d(disp, fn) ((disp)->TexCoord2d = fn)
+#define CALL_TexCoord2dv(disp, parameters) (*((disp)->TexCoord2dv)) parameters
+#define GET_TexCoord2dv(disp) ((disp)->TexCoord2dv)
+#define SET_TexCoord2dv(disp, fn) ((disp)->TexCoord2dv = fn)
+#define CALL_TexCoord2f(disp, parameters) (*((disp)->TexCoord2f)) parameters
+#define GET_TexCoord2f(disp) ((disp)->TexCoord2f)
+#define SET_TexCoord2f(disp, fn) ((disp)->TexCoord2f = fn)
+#define CALL_TexCoord2fv(disp, parameters) (*((disp)->TexCoord2fv)) parameters
+#define GET_TexCoord2fv(disp) ((disp)->TexCoord2fv)
+#define SET_TexCoord2fv(disp, fn) ((disp)->TexCoord2fv = fn)
+#define CALL_TexCoord2i(disp, parameters) (*((disp)->TexCoord2i)) parameters
+#define GET_TexCoord2i(disp) ((disp)->TexCoord2i)
+#define SET_TexCoord2i(disp, fn) ((disp)->TexCoord2i = fn)
+#define CALL_TexCoord2iv(disp, parameters) (*((disp)->TexCoord2iv)) parameters
+#define GET_TexCoord2iv(disp) ((disp)->TexCoord2iv)
+#define SET_TexCoord2iv(disp, fn) ((disp)->TexCoord2iv = fn)
+#define CALL_TexCoord2s(disp, parameters) (*((disp)->TexCoord2s)) parameters
+#define GET_TexCoord2s(disp) ((disp)->TexCoord2s)
+#define SET_TexCoord2s(disp, fn) ((disp)->TexCoord2s = fn)
+#define CALL_TexCoord2sv(disp, parameters) (*((disp)->TexCoord2sv)) parameters
+#define GET_TexCoord2sv(disp) ((disp)->TexCoord2sv)
+#define SET_TexCoord2sv(disp, fn) ((disp)->TexCoord2sv = fn)
+#define CALL_TexCoord3d(disp, parameters) (*((disp)->TexCoord3d)) parameters
+#define GET_TexCoord3d(disp) ((disp)->TexCoord3d)
+#define SET_TexCoord3d(disp, fn) ((disp)->TexCoord3d = fn)
+#define CALL_TexCoord3dv(disp, parameters) (*((disp)->TexCoord3dv)) parameters
+#define GET_TexCoord3dv(disp) ((disp)->TexCoord3dv)
+#define SET_TexCoord3dv(disp, fn) ((disp)->TexCoord3dv = fn)
+#define CALL_TexCoord3f(disp, parameters) (*((disp)->TexCoord3f)) parameters
+#define GET_TexCoord3f(disp) ((disp)->TexCoord3f)
+#define SET_TexCoord3f(disp, fn) ((disp)->TexCoord3f = fn)
+#define CALL_TexCoord3fv(disp, parameters) (*((disp)->TexCoord3fv)) parameters
+#define GET_TexCoord3fv(disp) ((disp)->TexCoord3fv)
+#define SET_TexCoord3fv(disp, fn) ((disp)->TexCoord3fv = fn)
+#define CALL_TexCoord3i(disp, parameters) (*((disp)->TexCoord3i)) parameters
+#define GET_TexCoord3i(disp) ((disp)->TexCoord3i)
+#define SET_TexCoord3i(disp, fn) ((disp)->TexCoord3i = fn)
+#define CALL_TexCoord3iv(disp, parameters) (*((disp)->TexCoord3iv)) parameters
+#define GET_TexCoord3iv(disp) ((disp)->TexCoord3iv)
+#define SET_TexCoord3iv(disp, fn) ((disp)->TexCoord3iv = fn)
+#define CALL_TexCoord3s(disp, parameters) (*((disp)->TexCoord3s)) parameters
+#define GET_TexCoord3s(disp) ((disp)->TexCoord3s)
+#define SET_TexCoord3s(disp, fn) ((disp)->TexCoord3s = fn)
+#define CALL_TexCoord3sv(disp, parameters) (*((disp)->TexCoord3sv)) parameters
+#define GET_TexCoord3sv(disp) ((disp)->TexCoord3sv)
+#define SET_TexCoord3sv(disp, fn) ((disp)->TexCoord3sv = fn)
+#define CALL_TexCoord4d(disp, parameters) (*((disp)->TexCoord4d)) parameters
+#define GET_TexCoord4d(disp) ((disp)->TexCoord4d)
+#define SET_TexCoord4d(disp, fn) ((disp)->TexCoord4d = fn)
+#define CALL_TexCoord4dv(disp, parameters) (*((disp)->TexCoord4dv)) parameters
+#define GET_TexCoord4dv(disp) ((disp)->TexCoord4dv)
+#define SET_TexCoord4dv(disp, fn) ((disp)->TexCoord4dv = fn)
+#define CALL_TexCoord4f(disp, parameters) (*((disp)->TexCoord4f)) parameters
+#define GET_TexCoord4f(disp) ((disp)->TexCoord4f)
+#define SET_TexCoord4f(disp, fn) ((disp)->TexCoord4f = fn)
+#define CALL_TexCoord4fv(disp, parameters) (*((disp)->TexCoord4fv)) parameters
+#define GET_TexCoord4fv(disp) ((disp)->TexCoord4fv)
+#define SET_TexCoord4fv(disp, fn) ((disp)->TexCoord4fv = fn)
+#define CALL_TexCoord4i(disp, parameters) (*((disp)->TexCoord4i)) parameters
+#define GET_TexCoord4i(disp) ((disp)->TexCoord4i)
+#define SET_TexCoord4i(disp, fn) ((disp)->TexCoord4i = fn)
+#define CALL_TexCoord4iv(disp, parameters) (*((disp)->TexCoord4iv)) parameters
+#define GET_TexCoord4iv(disp) ((disp)->TexCoord4iv)
+#define SET_TexCoord4iv(disp, fn) ((disp)->TexCoord4iv = fn)
+#define CALL_TexCoord4s(disp, parameters) (*((disp)->TexCoord4s)) parameters
+#define GET_TexCoord4s(disp) ((disp)->TexCoord4s)
+#define SET_TexCoord4s(disp, fn) ((disp)->TexCoord4s = fn)
+#define CALL_TexCoord4sv(disp, parameters) (*((disp)->TexCoord4sv)) parameters
+#define GET_TexCoord4sv(disp) ((disp)->TexCoord4sv)
+#define SET_TexCoord4sv(disp, fn) ((disp)->TexCoord4sv = fn)
+#define CALL_Vertex2d(disp, parameters) (*((disp)->Vertex2d)) parameters
+#define GET_Vertex2d(disp) ((disp)->Vertex2d)
+#define SET_Vertex2d(disp, fn) ((disp)->Vertex2d = fn)
+#define CALL_Vertex2dv(disp, parameters) (*((disp)->Vertex2dv)) parameters
+#define GET_Vertex2dv(disp) ((disp)->Vertex2dv)
+#define SET_Vertex2dv(disp, fn) ((disp)->Vertex2dv = fn)
+#define CALL_Vertex2f(disp, parameters) (*((disp)->Vertex2f)) parameters
+#define GET_Vertex2f(disp) ((disp)->Vertex2f)
+#define SET_Vertex2f(disp, fn) ((disp)->Vertex2f = fn)
+#define CALL_Vertex2fv(disp, parameters) (*((disp)->Vertex2fv)) parameters
+#define GET_Vertex2fv(disp) ((disp)->Vertex2fv)
+#define SET_Vertex2fv(disp, fn) ((disp)->Vertex2fv = fn)
+#define CALL_Vertex2i(disp, parameters) (*((disp)->Vertex2i)) parameters
+#define GET_Vertex2i(disp) ((disp)->Vertex2i)
+#define SET_Vertex2i(disp, fn) ((disp)->Vertex2i = fn)
+#define CALL_Vertex2iv(disp, parameters) (*((disp)->Vertex2iv)) parameters
+#define GET_Vertex2iv(disp) ((disp)->Vertex2iv)
+#define SET_Vertex2iv(disp, fn) ((disp)->Vertex2iv = fn)
+#define CALL_Vertex2s(disp, parameters) (*((disp)->Vertex2s)) parameters
+#define GET_Vertex2s(disp) ((disp)->Vertex2s)
+#define SET_Vertex2s(disp, fn) ((disp)->Vertex2s = fn)
+#define CALL_Vertex2sv(disp, parameters) (*((disp)->Vertex2sv)) parameters
+#define GET_Vertex2sv(disp) ((disp)->Vertex2sv)
+#define SET_Vertex2sv(disp, fn) ((disp)->Vertex2sv = fn)
+#define CALL_Vertex3d(disp, parameters) (*((disp)->Vertex3d)) parameters
+#define GET_Vertex3d(disp) ((disp)->Vertex3d)
+#define SET_Vertex3d(disp, fn) ((disp)->Vertex3d = fn)
+#define CALL_Vertex3dv(disp, parameters) (*((disp)->Vertex3dv)) parameters
+#define GET_Vertex3dv(disp) ((disp)->Vertex3dv)
+#define SET_Vertex3dv(disp, fn) ((disp)->Vertex3dv = fn)
+#define CALL_Vertex3f(disp, parameters) (*((disp)->Vertex3f)) parameters
+#define GET_Vertex3f(disp) ((disp)->Vertex3f)
+#define SET_Vertex3f(disp, fn) ((disp)->Vertex3f = fn)
+#define CALL_Vertex3fv(disp, parameters) (*((disp)->Vertex3fv)) parameters
+#define GET_Vertex3fv(disp) ((disp)->Vertex3fv)
+#define SET_Vertex3fv(disp, fn) ((disp)->Vertex3fv = fn)
+#define CALL_Vertex3i(disp, parameters) (*((disp)->Vertex3i)) parameters
+#define GET_Vertex3i(disp) ((disp)->Vertex3i)
+#define SET_Vertex3i(disp, fn) ((disp)->Vertex3i = fn)
+#define CALL_Vertex3iv(disp, parameters) (*((disp)->Vertex3iv)) parameters
+#define GET_Vertex3iv(disp) ((disp)->Vertex3iv)
+#define SET_Vertex3iv(disp, fn) ((disp)->Vertex3iv = fn)
+#define CALL_Vertex3s(disp, parameters) (*((disp)->Vertex3s)) parameters
+#define GET_Vertex3s(disp) ((disp)->Vertex3s)
+#define SET_Vertex3s(disp, fn) ((disp)->Vertex3s = fn)
+#define CALL_Vertex3sv(disp, parameters) (*((disp)->Vertex3sv)) parameters
+#define GET_Vertex3sv(disp) ((disp)->Vertex3sv)
+#define SET_Vertex3sv(disp, fn) ((disp)->Vertex3sv = fn)
+#define CALL_Vertex4d(disp, parameters) (*((disp)->Vertex4d)) parameters
+#define GET_Vertex4d(disp) ((disp)->Vertex4d)
+#define SET_Vertex4d(disp, fn) ((disp)->Vertex4d = fn)
+#define CALL_Vertex4dv(disp, parameters) (*((disp)->Vertex4dv)) parameters
+#define GET_Vertex4dv(disp) ((disp)->Vertex4dv)
+#define SET_Vertex4dv(disp, fn) ((disp)->Vertex4dv = fn)
+#define CALL_Vertex4f(disp, parameters) (*((disp)->Vertex4f)) parameters
+#define GET_Vertex4f(disp) ((disp)->Vertex4f)
+#define SET_Vertex4f(disp, fn) ((disp)->Vertex4f = fn)
+#define CALL_Vertex4fv(disp, parameters) (*((disp)->Vertex4fv)) parameters
+#define GET_Vertex4fv(disp) ((disp)->Vertex4fv)
+#define SET_Vertex4fv(disp, fn) ((disp)->Vertex4fv = fn)
+#define CALL_Vertex4i(disp, parameters) (*((disp)->Vertex4i)) parameters
+#define GET_Vertex4i(disp) ((disp)->Vertex4i)
+#define SET_Vertex4i(disp, fn) ((disp)->Vertex4i = fn)
+#define CALL_Vertex4iv(disp, parameters) (*((disp)->Vertex4iv)) parameters
+#define GET_Vertex4iv(disp) ((disp)->Vertex4iv)
+#define SET_Vertex4iv(disp, fn) ((disp)->Vertex4iv = fn)
+#define CALL_Vertex4s(disp, parameters) (*((disp)->Vertex4s)) parameters
+#define GET_Vertex4s(disp) ((disp)->Vertex4s)
+#define SET_Vertex4s(disp, fn) ((disp)->Vertex4s = fn)
+#define CALL_Vertex4sv(disp, parameters) (*((disp)->Vertex4sv)) parameters
+#define GET_Vertex4sv(disp) ((disp)->Vertex4sv)
+#define SET_Vertex4sv(disp, fn) ((disp)->Vertex4sv = fn)
+#define CALL_ClipPlane(disp, parameters) (*((disp)->ClipPlane)) parameters
+#define GET_ClipPlane(disp) ((disp)->ClipPlane)
+#define SET_ClipPlane(disp, fn) ((disp)->ClipPlane = fn)
+#define CALL_ColorMaterial(disp, parameters) (*((disp)->ColorMaterial)) parameters
+#define GET_ColorMaterial(disp) ((disp)->ColorMaterial)
+#define SET_ColorMaterial(disp, fn) ((disp)->ColorMaterial = fn)
+#define CALL_CullFace(disp, parameters) (*((disp)->CullFace)) parameters
+#define GET_CullFace(disp) ((disp)->CullFace)
+#define SET_CullFace(disp, fn) ((disp)->CullFace = fn)
+#define CALL_Fogf(disp, parameters) (*((disp)->Fogf)) parameters
+#define GET_Fogf(disp) ((disp)->Fogf)
+#define SET_Fogf(disp, fn) ((disp)->Fogf = fn)
+#define CALL_Fogfv(disp, parameters) (*((disp)->Fogfv)) parameters
+#define GET_Fogfv(disp) ((disp)->Fogfv)
+#define SET_Fogfv(disp, fn) ((disp)->Fogfv = fn)
+#define CALL_Fogi(disp, parameters) (*((disp)->Fogi)) parameters
+#define GET_Fogi(disp) ((disp)->Fogi)
+#define SET_Fogi(disp, fn) ((disp)->Fogi = fn)
+#define CALL_Fogiv(disp, parameters) (*((disp)->Fogiv)) parameters
+#define GET_Fogiv(disp) ((disp)->Fogiv)
+#define SET_Fogiv(disp, fn) ((disp)->Fogiv = fn)
+#define CALL_FrontFace(disp, parameters) (*((disp)->FrontFace)) parameters
+#define GET_FrontFace(disp) ((disp)->FrontFace)
+#define SET_FrontFace(disp, fn) ((disp)->FrontFace = fn)
+#define CALL_Hint(disp, parameters) (*((disp)->Hint)) parameters
+#define GET_Hint(disp) ((disp)->Hint)
+#define SET_Hint(disp, fn) ((disp)->Hint = fn)
+#define CALL_Lightf(disp, parameters) (*((disp)->Lightf)) parameters
+#define GET_Lightf(disp) ((disp)->Lightf)
+#define SET_Lightf(disp, fn) ((disp)->Lightf = fn)
+#define CALL_Lightfv(disp, parameters) (*((disp)->Lightfv)) parameters
+#define GET_Lightfv(disp) ((disp)->Lightfv)
+#define SET_Lightfv(disp, fn) ((disp)->Lightfv = fn)
+#define CALL_Lighti(disp, parameters) (*((disp)->Lighti)) parameters
+#define GET_Lighti(disp) ((disp)->Lighti)
+#define SET_Lighti(disp, fn) ((disp)->Lighti = fn)
+#define CALL_Lightiv(disp, parameters) (*((disp)->Lightiv)) parameters
+#define GET_Lightiv(disp) ((disp)->Lightiv)
+#define SET_Lightiv(disp, fn) ((disp)->Lightiv = fn)
+#define CALL_LightModelf(disp, parameters) (*((disp)->LightModelf)) parameters
+#define GET_LightModelf(disp) ((disp)->LightModelf)
+#define SET_LightModelf(disp, fn) ((disp)->LightModelf = fn)
+#define CALL_LightModelfv(disp, parameters) (*((disp)->LightModelfv)) parameters
+#define GET_LightModelfv(disp) ((disp)->LightModelfv)
+#define SET_LightModelfv(disp, fn) ((disp)->LightModelfv = fn)
+#define CALL_LightModeli(disp, parameters) (*((disp)->LightModeli)) parameters
+#define GET_LightModeli(disp) ((disp)->LightModeli)
+#define SET_LightModeli(disp, fn) ((disp)->LightModeli = fn)
+#define CALL_LightModeliv(disp, parameters) (*((disp)->LightModeliv)) parameters
+#define GET_LightModeliv(disp) ((disp)->LightModeliv)
+#define SET_LightModeliv(disp, fn) ((disp)->LightModeliv = fn)
+#define CALL_LineStipple(disp, parameters) (*((disp)->LineStipple)) parameters
+#define GET_LineStipple(disp) ((disp)->LineStipple)
+#define SET_LineStipple(disp, fn) ((disp)->LineStipple = fn)
+#define CALL_LineWidth(disp, parameters) (*((disp)->LineWidth)) parameters
+#define GET_LineWidth(disp) ((disp)->LineWidth)
+#define SET_LineWidth(disp, fn) ((disp)->LineWidth = fn)
+#define CALL_Materialf(disp, parameters) (*((disp)->Materialf)) parameters
+#define GET_Materialf(disp) ((disp)->Materialf)
+#define SET_Materialf(disp, fn) ((disp)->Materialf = fn)
+#define CALL_Materialfv(disp, parameters) (*((disp)->Materialfv)) parameters
+#define GET_Materialfv(disp) ((disp)->Materialfv)
+#define SET_Materialfv(disp, fn) ((disp)->Materialfv = fn)
+#define CALL_Materiali(disp, parameters) (*((disp)->Materiali)) parameters
+#define GET_Materiali(disp) ((disp)->Materiali)
+#define SET_Materiali(disp, fn) ((disp)->Materiali = fn)
+#define CALL_Materialiv(disp, parameters) (*((disp)->Materialiv)) parameters
+#define GET_Materialiv(disp) ((disp)->Materialiv)
+#define SET_Materialiv(disp, fn) ((disp)->Materialiv = fn)
+#define CALL_PointSize(disp, parameters) (*((disp)->PointSize)) parameters
+#define GET_PointSize(disp) ((disp)->PointSize)
+#define SET_PointSize(disp, fn) ((disp)->PointSize = fn)
+#define CALL_PolygonMode(disp, parameters) (*((disp)->PolygonMode)) parameters
+#define GET_PolygonMode(disp) ((disp)->PolygonMode)
+#define SET_PolygonMode(disp, fn) ((disp)->PolygonMode = fn)
+#define CALL_PolygonStipple(disp, parameters) (*((disp)->PolygonStipple)) parameters
+#define GET_PolygonStipple(disp) ((disp)->PolygonStipple)
+#define SET_PolygonStipple(disp, fn) ((disp)->PolygonStipple = fn)
+#define CALL_Scissor(disp, parameters) (*((disp)->Scissor)) parameters
+#define GET_Scissor(disp) ((disp)->Scissor)
+#define SET_Scissor(disp, fn) ((disp)->Scissor = fn)
+#define CALL_ShadeModel(disp, parameters) (*((disp)->ShadeModel)) parameters
+#define GET_ShadeModel(disp) ((disp)->ShadeModel)
+#define SET_ShadeModel(disp, fn) ((disp)->ShadeModel = fn)
+#define CALL_TexParameterf(disp, parameters) (*((disp)->TexParameterf)) parameters
+#define GET_TexParameterf(disp) ((disp)->TexParameterf)
+#define SET_TexParameterf(disp, fn) ((disp)->TexParameterf = fn)
+#define CALL_TexParameterfv(disp, parameters) (*((disp)->TexParameterfv)) parameters
+#define GET_TexParameterfv(disp) ((disp)->TexParameterfv)
+#define SET_TexParameterfv(disp, fn) ((disp)->TexParameterfv = fn)
+#define CALL_TexParameteri(disp, parameters) (*((disp)->TexParameteri)) parameters
+#define GET_TexParameteri(disp) ((disp)->TexParameteri)
+#define SET_TexParameteri(disp, fn) ((disp)->TexParameteri = fn)
+#define CALL_TexParameteriv(disp, parameters) (*((disp)->TexParameteriv)) parameters
+#define GET_TexParameteriv(disp) ((disp)->TexParameteriv)
+#define SET_TexParameteriv(disp, fn) ((disp)->TexParameteriv = fn)
+#define CALL_TexImage1D(disp, parameters) (*((disp)->TexImage1D)) parameters
+#define GET_TexImage1D(disp) ((disp)->TexImage1D)
+#define SET_TexImage1D(disp, fn) ((disp)->TexImage1D = fn)
+#define CALL_TexImage2D(disp, parameters) (*((disp)->TexImage2D)) parameters
+#define GET_TexImage2D(disp) ((disp)->TexImage2D)
+#define SET_TexImage2D(disp, fn) ((disp)->TexImage2D = fn)
+#define CALL_TexEnvf(disp, parameters) (*((disp)->TexEnvf)) parameters
+#define GET_TexEnvf(disp) ((disp)->TexEnvf)
+#define SET_TexEnvf(disp, fn) ((disp)->TexEnvf = fn)
+#define CALL_TexEnvfv(disp, parameters) (*((disp)->TexEnvfv)) parameters
+#define GET_TexEnvfv(disp) ((disp)->TexEnvfv)
+#define SET_TexEnvfv(disp, fn) ((disp)->TexEnvfv = fn)
+#define CALL_TexEnvi(disp, parameters) (*((disp)->TexEnvi)) parameters
+#define GET_TexEnvi(disp) ((disp)->TexEnvi)
+#define SET_TexEnvi(disp, fn) ((disp)->TexEnvi = fn)
+#define CALL_TexEnviv(disp, parameters) (*((disp)->TexEnviv)) parameters
+#define GET_TexEnviv(disp) ((disp)->TexEnviv)
+#define SET_TexEnviv(disp, fn) ((disp)->TexEnviv = fn)
+#define CALL_TexGend(disp, parameters) (*((disp)->TexGend)) parameters
+#define GET_TexGend(disp) ((disp)->TexGend)
+#define SET_TexGend(disp, fn) ((disp)->TexGend = fn)
+#define CALL_TexGendv(disp, parameters) (*((disp)->TexGendv)) parameters
+#define GET_TexGendv(disp) ((disp)->TexGendv)
+#define SET_TexGendv(disp, fn) ((disp)->TexGendv = fn)
+#define CALL_TexGenf(disp, parameters) (*((disp)->TexGenf)) parameters
+#define GET_TexGenf(disp) ((disp)->TexGenf)
+#define SET_TexGenf(disp, fn) ((disp)->TexGenf = fn)
+#define CALL_TexGenfv(disp, parameters) (*((disp)->TexGenfv)) parameters
+#define GET_TexGenfv(disp) ((disp)->TexGenfv)
+#define SET_TexGenfv(disp, fn) ((disp)->TexGenfv = fn)
+#define CALL_TexGeni(disp, parameters) (*((disp)->TexGeni)) parameters
+#define GET_TexGeni(disp) ((disp)->TexGeni)
+#define SET_TexGeni(disp, fn) ((disp)->TexGeni = fn)
+#define CALL_TexGeniv(disp, parameters) (*((disp)->TexGeniv)) parameters
+#define GET_TexGeniv(disp) ((disp)->TexGeniv)
+#define SET_TexGeniv(disp, fn) ((disp)->TexGeniv = fn)
+#define CALL_FeedbackBuffer(disp, parameters) (*((disp)->FeedbackBuffer)) parameters
+#define GET_FeedbackBuffer(disp) ((disp)->FeedbackBuffer)
+#define SET_FeedbackBuffer(disp, fn) ((disp)->FeedbackBuffer = fn)
+#define CALL_SelectBuffer(disp, parameters) (*((disp)->SelectBuffer)) parameters
+#define GET_SelectBuffer(disp) ((disp)->SelectBuffer)
+#define SET_SelectBuffer(disp, fn) ((disp)->SelectBuffer = fn)
+#define CALL_RenderMode(disp, parameters) (*((disp)->RenderMode)) parameters
+#define GET_RenderMode(disp) ((disp)->RenderMode)
+#define SET_RenderMode(disp, fn) ((disp)->RenderMode = fn)
+#define CALL_InitNames(disp, parameters) (*((disp)->InitNames)) parameters
+#define GET_InitNames(disp) ((disp)->InitNames)
+#define SET_InitNames(disp, fn) ((disp)->InitNames = fn)
+#define CALL_LoadName(disp, parameters) (*((disp)->LoadName)) parameters
+#define GET_LoadName(disp) ((disp)->LoadName)
+#define SET_LoadName(disp, fn) ((disp)->LoadName = fn)
+#define CALL_PassThrough(disp, parameters) (*((disp)->PassThrough)) parameters
+#define GET_PassThrough(disp) ((disp)->PassThrough)
+#define SET_PassThrough(disp, fn) ((disp)->PassThrough = fn)
+#define CALL_PopName(disp, parameters) (*((disp)->PopName)) parameters
+#define GET_PopName(disp) ((disp)->PopName)
+#define SET_PopName(disp, fn) ((disp)->PopName = fn)
+#define CALL_PushName(disp, parameters) (*((disp)->PushName)) parameters
+#define GET_PushName(disp) ((disp)->PushName)
+#define SET_PushName(disp, fn) ((disp)->PushName = fn)
+#define CALL_DrawBuffer(disp, parameters) (*((disp)->DrawBuffer)) parameters
+#define GET_DrawBuffer(disp) ((disp)->DrawBuffer)
+#define SET_DrawBuffer(disp, fn) ((disp)->DrawBuffer = fn)
+#define CALL_Clear(disp, parameters) (*((disp)->Clear)) parameters
+#define GET_Clear(disp) ((disp)->Clear)
+#define SET_Clear(disp, fn) ((disp)->Clear = fn)
+#define CALL_ClearAccum(disp, parameters) (*((disp)->ClearAccum)) parameters
+#define GET_ClearAccum(disp) ((disp)->ClearAccum)
+#define SET_ClearAccum(disp, fn) ((disp)->ClearAccum = fn)
+#define CALL_ClearIndex(disp, parameters) (*((disp)->ClearIndex)) parameters
+#define GET_ClearIndex(disp) ((disp)->ClearIndex)
+#define SET_ClearIndex(disp, fn) ((disp)->ClearIndex = fn)
+#define CALL_ClearColor(disp, parameters) (*((disp)->ClearColor)) parameters
+#define GET_ClearColor(disp) ((disp)->ClearColor)
+#define SET_ClearColor(disp, fn) ((disp)->ClearColor = fn)
+#define CALL_ClearStencil(disp, parameters) (*((disp)->ClearStencil)) parameters
+#define GET_ClearStencil(disp) ((disp)->ClearStencil)
+#define SET_ClearStencil(disp, fn) ((disp)->ClearStencil = fn)
+#define CALL_ClearDepth(disp, parameters) (*((disp)->ClearDepth)) parameters
+#define GET_ClearDepth(disp) ((disp)->ClearDepth)
+#define SET_ClearDepth(disp, fn) ((disp)->ClearDepth = fn)
+#define CALL_StencilMask(disp, parameters) (*((disp)->StencilMask)) parameters
+#define GET_StencilMask(disp) ((disp)->StencilMask)
+#define SET_StencilMask(disp, fn) ((disp)->StencilMask = fn)
+#define CALL_ColorMask(disp, parameters) (*((disp)->ColorMask)) parameters
+#define GET_ColorMask(disp) ((disp)->ColorMask)
+#define SET_ColorMask(disp, fn) ((disp)->ColorMask = fn)
+#define CALL_DepthMask(disp, parameters) (*((disp)->DepthMask)) parameters
+#define GET_DepthMask(disp) ((disp)->DepthMask)
+#define SET_DepthMask(disp, fn) ((disp)->DepthMask = fn)
+#define CALL_IndexMask(disp, parameters) (*((disp)->IndexMask)) parameters
+#define GET_IndexMask(disp) ((disp)->IndexMask)
+#define SET_IndexMask(disp, fn) ((disp)->IndexMask = fn)
+#define CALL_Accum(disp, parameters) (*((disp)->Accum)) parameters
+#define GET_Accum(disp) ((disp)->Accum)
+#define SET_Accum(disp, fn) ((disp)->Accum = fn)
+#define CALL_Disable(disp, parameters) (*((disp)->Disable)) parameters
+#define GET_Disable(disp) ((disp)->Disable)
+#define SET_Disable(disp, fn) ((disp)->Disable = fn)
+#define CALL_Enable(disp, parameters) (*((disp)->Enable)) parameters
+#define GET_Enable(disp) ((disp)->Enable)
+#define SET_Enable(disp, fn) ((disp)->Enable = fn)
+#define CALL_Finish(disp, parameters) (*((disp)->Finish)) parameters
+#define GET_Finish(disp) ((disp)->Finish)
+#define SET_Finish(disp, fn) ((disp)->Finish = fn)
+#define CALL_Flush(disp, parameters) (*((disp)->Flush)) parameters
+#define GET_Flush(disp) ((disp)->Flush)
+#define SET_Flush(disp, fn) ((disp)->Flush = fn)
+#define CALL_PopAttrib(disp, parameters) (*((disp)->PopAttrib)) parameters
+#define GET_PopAttrib(disp) ((disp)->PopAttrib)
+#define SET_PopAttrib(disp, fn) ((disp)->PopAttrib = fn)
+#define CALL_PushAttrib(disp, parameters) (*((disp)->PushAttrib)) parameters
+#define GET_PushAttrib(disp) ((disp)->PushAttrib)
+#define SET_PushAttrib(disp, fn) ((disp)->PushAttrib = fn)
+#define CALL_Map1d(disp, parameters) (*((disp)->Map1d)) parameters
+#define GET_Map1d(disp) ((disp)->Map1d)
+#define SET_Map1d(disp, fn) ((disp)->Map1d = fn)
+#define CALL_Map1f(disp, parameters) (*((disp)->Map1f)) parameters
+#define GET_Map1f(disp) ((disp)->Map1f)
+#define SET_Map1f(disp, fn) ((disp)->Map1f = fn)
+#define CALL_Map2d(disp, parameters) (*((disp)->Map2d)) parameters
+#define GET_Map2d(disp) ((disp)->Map2d)
+#define SET_Map2d(disp, fn) ((disp)->Map2d = fn)
+#define CALL_Map2f(disp, parameters) (*((disp)->Map2f)) parameters
+#define GET_Map2f(disp) ((disp)->Map2f)
+#define SET_Map2f(disp, fn) ((disp)->Map2f = fn)
+#define CALL_MapGrid1d(disp, parameters) (*((disp)->MapGrid1d)) parameters
+#define GET_MapGrid1d(disp) ((disp)->MapGrid1d)
+#define SET_MapGrid1d(disp, fn) ((disp)->MapGrid1d = fn)
+#define CALL_MapGrid1f(disp, parameters) (*((disp)->MapGrid1f)) parameters
+#define GET_MapGrid1f(disp) ((disp)->MapGrid1f)
+#define SET_MapGrid1f(disp, fn) ((disp)->MapGrid1f = fn)
+#define CALL_MapGrid2d(disp, parameters) (*((disp)->MapGrid2d)) parameters
+#define GET_MapGrid2d(disp) ((disp)->MapGrid2d)
+#define SET_MapGrid2d(disp, fn) ((disp)->MapGrid2d = fn)
+#define CALL_MapGrid2f(disp, parameters) (*((disp)->MapGrid2f)) parameters
+#define GET_MapGrid2f(disp) ((disp)->MapGrid2f)
+#define SET_MapGrid2f(disp, fn) ((disp)->MapGrid2f = fn)
+#define CALL_EvalCoord1d(disp, parameters) (*((disp)->EvalCoord1d)) parameters
+#define GET_EvalCoord1d(disp) ((disp)->EvalCoord1d)
+#define SET_EvalCoord1d(disp, fn) ((disp)->EvalCoord1d = fn)
+#define CALL_EvalCoord1dv(disp, parameters) (*((disp)->EvalCoord1dv)) parameters
+#define GET_EvalCoord1dv(disp) ((disp)->EvalCoord1dv)
+#define SET_EvalCoord1dv(disp, fn) ((disp)->EvalCoord1dv = fn)
+#define CALL_EvalCoord1f(disp, parameters) (*((disp)->EvalCoord1f)) parameters
+#define GET_EvalCoord1f(disp) ((disp)->EvalCoord1f)
+#define SET_EvalCoord1f(disp, fn) ((disp)->EvalCoord1f = fn)
+#define CALL_EvalCoord1fv(disp, parameters) (*((disp)->EvalCoord1fv)) parameters
+#define GET_EvalCoord1fv(disp) ((disp)->EvalCoord1fv)
+#define SET_EvalCoord1fv(disp, fn) ((disp)->EvalCoord1fv = fn)
+#define CALL_EvalCoord2d(disp, parameters) (*((disp)->EvalCoord2d)) parameters
+#define GET_EvalCoord2d(disp) ((disp)->EvalCoord2d)
+#define SET_EvalCoord2d(disp, fn) ((disp)->EvalCoord2d = fn)
+#define CALL_EvalCoord2dv(disp, parameters) (*((disp)->EvalCoord2dv)) parameters
+#define GET_EvalCoord2dv(disp) ((disp)->EvalCoord2dv)
+#define SET_EvalCoord2dv(disp, fn) ((disp)->EvalCoord2dv = fn)
+#define CALL_EvalCoord2f(disp, parameters) (*((disp)->EvalCoord2f)) parameters
+#define GET_EvalCoord2f(disp) ((disp)->EvalCoord2f)
+#define SET_EvalCoord2f(disp, fn) ((disp)->EvalCoord2f = fn)
+#define CALL_EvalCoord2fv(disp, parameters) (*((disp)->EvalCoord2fv)) parameters
+#define GET_EvalCoord2fv(disp) ((disp)->EvalCoord2fv)
+#define SET_EvalCoord2fv(disp, fn) ((disp)->EvalCoord2fv = fn)
+#define CALL_EvalMesh1(disp, parameters) (*((disp)->EvalMesh1)) parameters
+#define GET_EvalMesh1(disp) ((disp)->EvalMesh1)
+#define SET_EvalMesh1(disp, fn) ((disp)->EvalMesh1 = fn)
+#define CALL_EvalPoint1(disp, parameters) (*((disp)->EvalPoint1)) parameters
+#define GET_EvalPoint1(disp) ((disp)->EvalPoint1)
+#define SET_EvalPoint1(disp, fn) ((disp)->EvalPoint1 = fn)
+#define CALL_EvalMesh2(disp, parameters) (*((disp)->EvalMesh2)) parameters
+#define GET_EvalMesh2(disp) ((disp)->EvalMesh2)
+#define SET_EvalMesh2(disp, fn) ((disp)->EvalMesh2 = fn)
+#define CALL_EvalPoint2(disp, parameters) (*((disp)->EvalPoint2)) parameters
+#define GET_EvalPoint2(disp) ((disp)->EvalPoint2)
+#define SET_EvalPoint2(disp, fn) ((disp)->EvalPoint2 = fn)
+#define CALL_AlphaFunc(disp, parameters) (*((disp)->AlphaFunc)) parameters
+#define GET_AlphaFunc(disp) ((disp)->AlphaFunc)
+#define SET_AlphaFunc(disp, fn) ((disp)->AlphaFunc = fn)
+#define CALL_BlendFunc(disp, parameters) (*((disp)->BlendFunc)) parameters
+#define GET_BlendFunc(disp) ((disp)->BlendFunc)
+#define SET_BlendFunc(disp, fn) ((disp)->BlendFunc = fn)
+#define CALL_LogicOp(disp, parameters) (*((disp)->LogicOp)) parameters
+#define GET_LogicOp(disp) ((disp)->LogicOp)
+#define SET_LogicOp(disp, fn) ((disp)->LogicOp = fn)
+#define CALL_StencilFunc(disp, parameters) (*((disp)->StencilFunc)) parameters
+#define GET_StencilFunc(disp) ((disp)->StencilFunc)
+#define SET_StencilFunc(disp, fn) ((disp)->StencilFunc = fn)
+#define CALL_StencilOp(disp, parameters) (*((disp)->StencilOp)) parameters
+#define GET_StencilOp(disp) ((disp)->StencilOp)
+#define SET_StencilOp(disp, fn) ((disp)->StencilOp = fn)
+#define CALL_DepthFunc(disp, parameters) (*((disp)->DepthFunc)) parameters
+#define GET_DepthFunc(disp) ((disp)->DepthFunc)
+#define SET_DepthFunc(disp, fn) ((disp)->DepthFunc = fn)
+#define CALL_PixelZoom(disp, parameters) (*((disp)->PixelZoom)) parameters
+#define GET_PixelZoom(disp) ((disp)->PixelZoom)
+#define SET_PixelZoom(disp, fn) ((disp)->PixelZoom = fn)
+#define CALL_PixelTransferf(disp, parameters) (*((disp)->PixelTransferf)) parameters
+#define GET_PixelTransferf(disp) ((disp)->PixelTransferf)
+#define SET_PixelTransferf(disp, fn) ((disp)->PixelTransferf = fn)
+#define CALL_PixelTransferi(disp, parameters) (*((disp)->PixelTransferi)) parameters
+#define GET_PixelTransferi(disp) ((disp)->PixelTransferi)
+#define SET_PixelTransferi(disp, fn) ((disp)->PixelTransferi = fn)
+#define CALL_PixelStoref(disp, parameters) (*((disp)->PixelStoref)) parameters
+#define GET_PixelStoref(disp) ((disp)->PixelStoref)
+#define SET_PixelStoref(disp, fn) ((disp)->PixelStoref = fn)
+#define CALL_PixelStorei(disp, parameters) (*((disp)->PixelStorei)) parameters
+#define GET_PixelStorei(disp) ((disp)->PixelStorei)
+#define SET_PixelStorei(disp, fn) ((disp)->PixelStorei = fn)
+#define CALL_PixelMapfv(disp, parameters) (*((disp)->PixelMapfv)) parameters
+#define GET_PixelMapfv(disp) ((disp)->PixelMapfv)
+#define SET_PixelMapfv(disp, fn) ((disp)->PixelMapfv = fn)
+#define CALL_PixelMapuiv(disp, parameters) (*((disp)->PixelMapuiv)) parameters
+#define GET_PixelMapuiv(disp) ((disp)->PixelMapuiv)
+#define SET_PixelMapuiv(disp, fn) ((disp)->PixelMapuiv = fn)
+#define CALL_PixelMapusv(disp, parameters) (*((disp)->PixelMapusv)) parameters
+#define GET_PixelMapusv(disp) ((disp)->PixelMapusv)
+#define SET_PixelMapusv(disp, fn) ((disp)->PixelMapusv = fn)
+#define CALL_ReadBuffer(disp, parameters) (*((disp)->ReadBuffer)) parameters
+#define GET_ReadBuffer(disp) ((disp)->ReadBuffer)
+#define SET_ReadBuffer(disp, fn) ((disp)->ReadBuffer = fn)
+#define CALL_CopyPixels(disp, parameters) (*((disp)->CopyPixels)) parameters
+#define GET_CopyPixels(disp) ((disp)->CopyPixels)
+#define SET_CopyPixels(disp, fn) ((disp)->CopyPixels = fn)
+#define CALL_ReadPixels(disp, parameters) (*((disp)->ReadPixels)) parameters
+#define GET_ReadPixels(disp) ((disp)->ReadPixels)
+#define SET_ReadPixels(disp, fn) ((disp)->ReadPixels = fn)
+#define CALL_DrawPixels(disp, parameters) (*((disp)->DrawPixels)) parameters
+#define GET_DrawPixels(disp) ((disp)->DrawPixels)
+#define SET_DrawPixels(disp, fn) ((disp)->DrawPixels = fn)
+#define CALL_GetBooleanv(disp, parameters) (*((disp)->GetBooleanv)) parameters
+#define GET_GetBooleanv(disp) ((disp)->GetBooleanv)
+#define SET_GetBooleanv(disp, fn) ((disp)->GetBooleanv = fn)
+#define CALL_GetClipPlane(disp, parameters) (*((disp)->GetClipPlane)) parameters
+#define GET_GetClipPlane(disp) ((disp)->GetClipPlane)
+#define SET_GetClipPlane(disp, fn) ((disp)->GetClipPlane = fn)
+#define CALL_GetDoublev(disp, parameters) (*((disp)->GetDoublev)) parameters
+#define GET_GetDoublev(disp) ((disp)->GetDoublev)
+#define SET_GetDoublev(disp, fn) ((disp)->GetDoublev = fn)
+#define CALL_GetError(disp, parameters) (*((disp)->GetError)) parameters
+#define GET_GetError(disp) ((disp)->GetError)
+#define SET_GetError(disp, fn) ((disp)->GetError = fn)
+#define CALL_GetFloatv(disp, parameters) (*((disp)->GetFloatv)) parameters
+#define GET_GetFloatv(disp) ((disp)->GetFloatv)
+#define SET_GetFloatv(disp, fn) ((disp)->GetFloatv = fn)
+#define CALL_GetIntegerv(disp, parameters) (*((disp)->GetIntegerv)) parameters
+#define GET_GetIntegerv(disp) ((disp)->GetIntegerv)
+#define SET_GetIntegerv(disp, fn) ((disp)->GetIntegerv = fn)
+#define CALL_GetLightfv(disp, parameters) (*((disp)->GetLightfv)) parameters
+#define GET_GetLightfv(disp) ((disp)->GetLightfv)
+#define SET_GetLightfv(disp, fn) ((disp)->GetLightfv = fn)
+#define CALL_GetLightiv(disp, parameters) (*((disp)->GetLightiv)) parameters
+#define GET_GetLightiv(disp) ((disp)->GetLightiv)
+#define SET_GetLightiv(disp, fn) ((disp)->GetLightiv = fn)
+#define CALL_GetMapdv(disp, parameters) (*((disp)->GetMapdv)) parameters
+#define GET_GetMapdv(disp) ((disp)->GetMapdv)
+#define SET_GetMapdv(disp, fn) ((disp)->GetMapdv = fn)
+#define CALL_GetMapfv(disp, parameters) (*((disp)->GetMapfv)) parameters
+#define GET_GetMapfv(disp) ((disp)->GetMapfv)
+#define SET_GetMapfv(disp, fn) ((disp)->GetMapfv = fn)
+#define CALL_GetMapiv(disp, parameters) (*((disp)->GetMapiv)) parameters
+#define GET_GetMapiv(disp) ((disp)->GetMapiv)
+#define SET_GetMapiv(disp, fn) ((disp)->GetMapiv = fn)
+#define CALL_GetMaterialfv(disp, parameters) (*((disp)->GetMaterialfv)) parameters
+#define GET_GetMaterialfv(disp) ((disp)->GetMaterialfv)
+#define SET_GetMaterialfv(disp, fn) ((disp)->GetMaterialfv = fn)
+#define CALL_GetMaterialiv(disp, parameters) (*((disp)->GetMaterialiv)) parameters
+#define GET_GetMaterialiv(disp) ((disp)->GetMaterialiv)
+#define SET_GetMaterialiv(disp, fn) ((disp)->GetMaterialiv = fn)
+#define CALL_GetPixelMapfv(disp, parameters) (*((disp)->GetPixelMapfv)) parameters
+#define GET_GetPixelMapfv(disp) ((disp)->GetPixelMapfv)
+#define SET_GetPixelMapfv(disp, fn) ((disp)->GetPixelMapfv = fn)
+#define CALL_GetPixelMapuiv(disp, parameters) (*((disp)->GetPixelMapuiv)) parameters
+#define GET_GetPixelMapuiv(disp) ((disp)->GetPixelMapuiv)
+#define SET_GetPixelMapuiv(disp, fn) ((disp)->GetPixelMapuiv = fn)
+#define CALL_GetPixelMapusv(disp, parameters) (*((disp)->GetPixelMapusv)) parameters
+#define GET_GetPixelMapusv(disp) ((disp)->GetPixelMapusv)
+#define SET_GetPixelMapusv(disp, fn) ((disp)->GetPixelMapusv = fn)
+#define CALL_GetPolygonStipple(disp, parameters) (*((disp)->GetPolygonStipple)) parameters
+#define GET_GetPolygonStipple(disp) ((disp)->GetPolygonStipple)
+#define SET_GetPolygonStipple(disp, fn) ((disp)->GetPolygonStipple = fn)
+#define CALL_GetString(disp, parameters) (*((disp)->GetString)) parameters
+#define GET_GetString(disp) ((disp)->GetString)
+#define SET_GetString(disp, fn) ((disp)->GetString = fn)
+#define CALL_GetTexEnvfv(disp, parameters) (*((disp)->GetTexEnvfv)) parameters
+#define GET_GetTexEnvfv(disp) ((disp)->GetTexEnvfv)
+#define SET_GetTexEnvfv(disp, fn) ((disp)->GetTexEnvfv = fn)
+#define CALL_GetTexEnviv(disp, parameters) (*((disp)->GetTexEnviv)) parameters
+#define GET_GetTexEnviv(disp) ((disp)->GetTexEnviv)
+#define SET_GetTexEnviv(disp, fn) ((disp)->GetTexEnviv = fn)
+#define CALL_GetTexGendv(disp, parameters) (*((disp)->GetTexGendv)) parameters
+#define GET_GetTexGendv(disp) ((disp)->GetTexGendv)
+#define SET_GetTexGendv(disp, fn) ((disp)->GetTexGendv = fn)
+#define CALL_GetTexGenfv(disp, parameters) (*((disp)->GetTexGenfv)) parameters
+#define GET_GetTexGenfv(disp) ((disp)->GetTexGenfv)
+#define SET_GetTexGenfv(disp, fn) ((disp)->GetTexGenfv = fn)
+#define CALL_GetTexGeniv(disp, parameters) (*((disp)->GetTexGeniv)) parameters
+#define GET_GetTexGeniv(disp) ((disp)->GetTexGeniv)
+#define SET_GetTexGeniv(disp, fn) ((disp)->GetTexGeniv = fn)
+#define CALL_GetTexImage(disp, parameters) (*((disp)->GetTexImage)) parameters
+#define GET_GetTexImage(disp) ((disp)->GetTexImage)
+#define SET_GetTexImage(disp, fn) ((disp)->GetTexImage = fn)
+#define CALL_GetTexParameterfv(disp, parameters) (*((disp)->GetTexParameterfv)) parameters
+#define GET_GetTexParameterfv(disp) ((disp)->GetTexParameterfv)
+#define SET_GetTexParameterfv(disp, fn) ((disp)->GetTexParameterfv = fn)
+#define CALL_GetTexParameteriv(disp, parameters) (*((disp)->GetTexParameteriv)) parameters
+#define GET_GetTexParameteriv(disp) ((disp)->GetTexParameteriv)
+#define SET_GetTexParameteriv(disp, fn) ((disp)->GetTexParameteriv = fn)
+#define CALL_GetTexLevelParameterfv(disp, parameters) (*((disp)->GetTexLevelParameterfv)) parameters
+#define GET_GetTexLevelParameterfv(disp) ((disp)->GetTexLevelParameterfv)
+#define SET_GetTexLevelParameterfv(disp, fn) ((disp)->GetTexLevelParameterfv = fn)
+#define CALL_GetTexLevelParameteriv(disp, parameters) (*((disp)->GetTexLevelParameteriv)) parameters
+#define GET_GetTexLevelParameteriv(disp) ((disp)->GetTexLevelParameteriv)
+#define SET_GetTexLevelParameteriv(disp, fn) ((disp)->GetTexLevelParameteriv = fn)
+#define CALL_IsEnabled(disp, parameters) (*((disp)->IsEnabled)) parameters
+#define GET_IsEnabled(disp) ((disp)->IsEnabled)
+#define SET_IsEnabled(disp, fn) ((disp)->IsEnabled = fn)
+#define CALL_IsList(disp, parameters) (*((disp)->IsList)) parameters
+#define GET_IsList(disp) ((disp)->IsList)
+#define SET_IsList(disp, fn) ((disp)->IsList = fn)
+#define CALL_DepthRange(disp, parameters) (*((disp)->DepthRange)) parameters
+#define GET_DepthRange(disp) ((disp)->DepthRange)
+#define SET_DepthRange(disp, fn) ((disp)->DepthRange = fn)
+#define CALL_Frustum(disp, parameters) (*((disp)->Frustum)) parameters
+#define GET_Frustum(disp) ((disp)->Frustum)
+#define SET_Frustum(disp, fn) ((disp)->Frustum = fn)
+#define CALL_LoadIdentity(disp, parameters) (*((disp)->LoadIdentity)) parameters
+#define GET_LoadIdentity(disp) ((disp)->LoadIdentity)
+#define SET_LoadIdentity(disp, fn) ((disp)->LoadIdentity = fn)
+#define CALL_LoadMatrixf(disp, parameters) (*((disp)->LoadMatrixf)) parameters
+#define GET_LoadMatrixf(disp) ((disp)->LoadMatrixf)
+#define SET_LoadMatrixf(disp, fn) ((disp)->LoadMatrixf = fn)
+#define CALL_LoadMatrixd(disp, parameters) (*((disp)->LoadMatrixd)) parameters
+#define GET_LoadMatrixd(disp) ((disp)->LoadMatrixd)
+#define SET_LoadMatrixd(disp, fn) ((disp)->LoadMatrixd = fn)
+#define CALL_MatrixMode(disp, parameters) (*((disp)->MatrixMode)) parameters
+#define GET_MatrixMode(disp) ((disp)->MatrixMode)
+#define SET_MatrixMode(disp, fn) ((disp)->MatrixMode = fn)
+#define CALL_MultMatrixf(disp, parameters) (*((disp)->MultMatrixf)) parameters
+#define GET_MultMatrixf(disp) ((disp)->MultMatrixf)
+#define SET_MultMatrixf(disp, fn) ((disp)->MultMatrixf = fn)
+#define CALL_MultMatrixd(disp, parameters) (*((disp)->MultMatrixd)) parameters
+#define GET_MultMatrixd(disp) ((disp)->MultMatrixd)
+#define SET_MultMatrixd(disp, fn) ((disp)->MultMatrixd = fn)
+#define CALL_Ortho(disp, parameters) (*((disp)->Ortho)) parameters
+#define GET_Ortho(disp) ((disp)->Ortho)
+#define SET_Ortho(disp, fn) ((disp)->Ortho = fn)
+#define CALL_PopMatrix(disp, parameters) (*((disp)->PopMatrix)) parameters
+#define GET_PopMatrix(disp) ((disp)->PopMatrix)
+#define SET_PopMatrix(disp, fn) ((disp)->PopMatrix = fn)
+#define CALL_PushMatrix(disp, parameters) (*((disp)->PushMatrix)) parameters
+#define GET_PushMatrix(disp) ((disp)->PushMatrix)
+#define SET_PushMatrix(disp, fn) ((disp)->PushMatrix = fn)
+#define CALL_Rotated(disp, parameters) (*((disp)->Rotated)) parameters
+#define GET_Rotated(disp) ((disp)->Rotated)
+#define SET_Rotated(disp, fn) ((disp)->Rotated = fn)
+#define CALL_Rotatef(disp, parameters) (*((disp)->Rotatef)) parameters
+#define GET_Rotatef(disp) ((disp)->Rotatef)
+#define SET_Rotatef(disp, fn) ((disp)->Rotatef = fn)
+#define CALL_Scaled(disp, parameters) (*((disp)->Scaled)) parameters
+#define GET_Scaled(disp) ((disp)->Scaled)
+#define SET_Scaled(disp, fn) ((disp)->Scaled = fn)
+#define CALL_Scalef(disp, parameters) (*((disp)->Scalef)) parameters
+#define GET_Scalef(disp) ((disp)->Scalef)
+#define SET_Scalef(disp, fn) ((disp)->Scalef = fn)
+#define CALL_Translated(disp, parameters) (*((disp)->Translated)) parameters
+#define GET_Translated(disp) ((disp)->Translated)
+#define SET_Translated(disp, fn) ((disp)->Translated = fn)
+#define CALL_Translatef(disp, parameters) (*((disp)->Translatef)) parameters
+#define GET_Translatef(disp) ((disp)->Translatef)
+#define SET_Translatef(disp, fn) ((disp)->Translatef = fn)
+#define CALL_Viewport(disp, parameters) (*((disp)->Viewport)) parameters
+#define GET_Viewport(disp) ((disp)->Viewport)
+#define SET_Viewport(disp, fn) ((disp)->Viewport = fn)
+#define CALL_ArrayElement(disp, parameters) (*((disp)->ArrayElement)) parameters
+#define GET_ArrayElement(disp) ((disp)->ArrayElement)
+#define SET_ArrayElement(disp, fn) ((disp)->ArrayElement = fn)
+#define CALL_BindTexture(disp, parameters) (*((disp)->BindTexture)) parameters
+#define GET_BindTexture(disp) ((disp)->BindTexture)
+#define SET_BindTexture(disp, fn) ((disp)->BindTexture = fn)
+#define CALL_ColorPointer(disp, parameters) (*((disp)->ColorPointer)) parameters
+#define GET_ColorPointer(disp) ((disp)->ColorPointer)
+#define SET_ColorPointer(disp, fn) ((disp)->ColorPointer = fn)
+#define CALL_DisableClientState(disp, parameters) (*((disp)->DisableClientState)) parameters
+#define GET_DisableClientState(disp) ((disp)->DisableClientState)
+#define SET_DisableClientState(disp, fn) ((disp)->DisableClientState = fn)
+#define CALL_DrawArrays(disp, parameters) (*((disp)->DrawArrays)) parameters
+#define GET_DrawArrays(disp) ((disp)->DrawArrays)
+#define SET_DrawArrays(disp, fn) ((disp)->DrawArrays = fn)
+#define CALL_DrawElements(disp, parameters) (*((disp)->DrawElements)) parameters
+#define GET_DrawElements(disp) ((disp)->DrawElements)
+#define SET_DrawElements(disp, fn) ((disp)->DrawElements = fn)
+#define CALL_EdgeFlagPointer(disp, parameters) (*((disp)->EdgeFlagPointer)) parameters
+#define GET_EdgeFlagPointer(disp) ((disp)->EdgeFlagPointer)
+#define SET_EdgeFlagPointer(disp, fn) ((disp)->EdgeFlagPointer = fn)
+#define CALL_EnableClientState(disp, parameters) (*((disp)->EnableClientState)) parameters
+#define GET_EnableClientState(disp) ((disp)->EnableClientState)
+#define SET_EnableClientState(disp, fn) ((disp)->EnableClientState = fn)
+#define CALL_IndexPointer(disp, parameters) (*((disp)->IndexPointer)) parameters
+#define GET_IndexPointer(disp) ((disp)->IndexPointer)
+#define SET_IndexPointer(disp, fn) ((disp)->IndexPointer = fn)
+#define CALL_Indexub(disp, parameters) (*((disp)->Indexub)) parameters
+#define GET_Indexub(disp) ((disp)->Indexub)
+#define SET_Indexub(disp, fn) ((disp)->Indexub = fn)
+#define CALL_Indexubv(disp, parameters) (*((disp)->Indexubv)) parameters
+#define GET_Indexubv(disp) ((disp)->Indexubv)
+#define SET_Indexubv(disp, fn) ((disp)->Indexubv = fn)
+#define CALL_InterleavedArrays(disp, parameters) (*((disp)->InterleavedArrays)) parameters
+#define GET_InterleavedArrays(disp) ((disp)->InterleavedArrays)
+#define SET_InterleavedArrays(disp, fn) ((disp)->InterleavedArrays = fn)
+#define CALL_NormalPointer(disp, parameters) (*((disp)->NormalPointer)) parameters
+#define GET_NormalPointer(disp) ((disp)->NormalPointer)
+#define SET_NormalPointer(disp, fn) ((disp)->NormalPointer = fn)
+#define CALL_PolygonOffset(disp, parameters) (*((disp)->PolygonOffset)) parameters
+#define GET_PolygonOffset(disp) ((disp)->PolygonOffset)
+#define SET_PolygonOffset(disp, fn) ((disp)->PolygonOffset = fn)
+#define CALL_TexCoordPointer(disp, parameters) (*((disp)->TexCoordPointer)) parameters
+#define GET_TexCoordPointer(disp) ((disp)->TexCoordPointer)
+#define SET_TexCoordPointer(disp, fn) ((disp)->TexCoordPointer = fn)
+#define CALL_VertexPointer(disp, parameters) (*((disp)->VertexPointer)) parameters
+#define GET_VertexPointer(disp) ((disp)->VertexPointer)
+#define SET_VertexPointer(disp, fn) ((disp)->VertexPointer = fn)
+#define CALL_AreTexturesResident(disp, parameters) (*((disp)->AreTexturesResident)) parameters
+#define GET_AreTexturesResident(disp) ((disp)->AreTexturesResident)
+#define SET_AreTexturesResident(disp, fn) ((disp)->AreTexturesResident = fn)
+#define CALL_CopyTexImage1D(disp, parameters) (*((disp)->CopyTexImage1D)) parameters
+#define GET_CopyTexImage1D(disp) ((disp)->CopyTexImage1D)
+#define SET_CopyTexImage1D(disp, fn) ((disp)->CopyTexImage1D = fn)
+#define CALL_CopyTexImage2D(disp, parameters) (*((disp)->CopyTexImage2D)) parameters
+#define GET_CopyTexImage2D(disp) ((disp)->CopyTexImage2D)
+#define SET_CopyTexImage2D(disp, fn) ((disp)->CopyTexImage2D = fn)
+#define CALL_CopyTexSubImage1D(disp, parameters) (*((disp)->CopyTexSubImage1D)) parameters
+#define GET_CopyTexSubImage1D(disp) ((disp)->CopyTexSubImage1D)
+#define SET_CopyTexSubImage1D(disp, fn) ((disp)->CopyTexSubImage1D = fn)
+#define CALL_CopyTexSubImage2D(disp, parameters) (*((disp)->CopyTexSubImage2D)) parameters
+#define GET_CopyTexSubImage2D(disp) ((disp)->CopyTexSubImage2D)
+#define SET_CopyTexSubImage2D(disp, fn) ((disp)->CopyTexSubImage2D = fn)
+#define CALL_DeleteTextures(disp, parameters) (*((disp)->DeleteTextures)) parameters
+#define GET_DeleteTextures(disp) ((disp)->DeleteTextures)
+#define SET_DeleteTextures(disp, fn) ((disp)->DeleteTextures = fn)
+#define CALL_GenTextures(disp, parameters) (*((disp)->GenTextures)) parameters
+#define GET_GenTextures(disp) ((disp)->GenTextures)
+#define SET_GenTextures(disp, fn) ((disp)->GenTextures = fn)
+#define CALL_GetPointerv(disp, parameters) (*((disp)->GetPointerv)) parameters
+#define GET_GetPointerv(disp) ((disp)->GetPointerv)
+#define SET_GetPointerv(disp, fn) ((disp)->GetPointerv = fn)
+#define CALL_IsTexture(disp, parameters) (*((disp)->IsTexture)) parameters
+#define GET_IsTexture(disp) ((disp)->IsTexture)
+#define SET_IsTexture(disp, fn) ((disp)->IsTexture = fn)
+#define CALL_PrioritizeTextures(disp, parameters) (*((disp)->PrioritizeTextures)) parameters
+#define GET_PrioritizeTextures(disp) ((disp)->PrioritizeTextures)
+#define SET_PrioritizeTextures(disp, fn) ((disp)->PrioritizeTextures = fn)
+#define CALL_TexSubImage1D(disp, parameters) (*((disp)->TexSubImage1D)) parameters
+#define GET_TexSubImage1D(disp) ((disp)->TexSubImage1D)
+#define SET_TexSubImage1D(disp, fn) ((disp)->TexSubImage1D = fn)
+#define CALL_TexSubImage2D(disp, parameters) (*((disp)->TexSubImage2D)) parameters
+#define GET_TexSubImage2D(disp) ((disp)->TexSubImage2D)
+#define SET_TexSubImage2D(disp, fn) ((disp)->TexSubImage2D = fn)
+#define CALL_PopClientAttrib(disp, parameters) (*((disp)->PopClientAttrib)) parameters
+#define GET_PopClientAttrib(disp) ((disp)->PopClientAttrib)
+#define SET_PopClientAttrib(disp, fn) ((disp)->PopClientAttrib = fn)
+#define CALL_PushClientAttrib(disp, parameters) (*((disp)->PushClientAttrib)) parameters
+#define GET_PushClientAttrib(disp) ((disp)->PushClientAttrib)
+#define SET_PushClientAttrib(disp, fn) ((disp)->PushClientAttrib = fn)
+#define CALL_BlendColor(disp, parameters) (*((disp)->BlendColor)) parameters
+#define GET_BlendColor(disp) ((disp)->BlendColor)
+#define SET_BlendColor(disp, fn) ((disp)->BlendColor = fn)
+#define CALL_BlendEquation(disp, parameters) (*((disp)->BlendEquation)) parameters
+#define GET_BlendEquation(disp) ((disp)->BlendEquation)
+#define SET_BlendEquation(disp, fn) ((disp)->BlendEquation = fn)
+#define CALL_DrawRangeElements(disp, parameters) (*((disp)->DrawRangeElements)) parameters
+#define GET_DrawRangeElements(disp) ((disp)->DrawRangeElements)
+#define SET_DrawRangeElements(disp, fn) ((disp)->DrawRangeElements = fn)
+#define CALL_ColorTable(disp, parameters) (*((disp)->ColorTable)) parameters
+#define GET_ColorTable(disp) ((disp)->ColorTable)
+#define SET_ColorTable(disp, fn) ((disp)->ColorTable = fn)
+#define CALL_ColorTableParameterfv(disp, parameters) (*((disp)->ColorTableParameterfv)) parameters
+#define GET_ColorTableParameterfv(disp) ((disp)->ColorTableParameterfv)
+#define SET_ColorTableParameterfv(disp, fn) ((disp)->ColorTableParameterfv = fn)
+#define CALL_ColorTableParameteriv(disp, parameters) (*((disp)->ColorTableParameteriv)) parameters
+#define GET_ColorTableParameteriv(disp) ((disp)->ColorTableParameteriv)
+#define SET_ColorTableParameteriv(disp, fn) ((disp)->ColorTableParameteriv = fn)
+#define CALL_CopyColorTable(disp, parameters) (*((disp)->CopyColorTable)) parameters
+#define GET_CopyColorTable(disp) ((disp)->CopyColorTable)
+#define SET_CopyColorTable(disp, fn) ((disp)->CopyColorTable = fn)
+#define CALL_GetColorTable(disp, parameters) (*((disp)->GetColorTable)) parameters
+#define GET_GetColorTable(disp) ((disp)->GetColorTable)
+#define SET_GetColorTable(disp, fn) ((disp)->GetColorTable = fn)
+#define CALL_GetColorTableParameterfv(disp, parameters) (*((disp)->GetColorTableParameterfv)) parameters
+#define GET_GetColorTableParameterfv(disp) ((disp)->GetColorTableParameterfv)
+#define SET_GetColorTableParameterfv(disp, fn) ((disp)->GetColorTableParameterfv = fn)
+#define CALL_GetColorTableParameteriv(disp, parameters) (*((disp)->GetColorTableParameteriv)) parameters
+#define GET_GetColorTableParameteriv(disp) ((disp)->GetColorTableParameteriv)
+#define SET_GetColorTableParameteriv(disp, fn) ((disp)->GetColorTableParameteriv = fn)
+#define CALL_ColorSubTable(disp, parameters) (*((disp)->ColorSubTable)) parameters
+#define GET_ColorSubTable(disp) ((disp)->ColorSubTable)
+#define SET_ColorSubTable(disp, fn) ((disp)->ColorSubTable = fn)
+#define CALL_CopyColorSubTable(disp, parameters) (*((disp)->CopyColorSubTable)) parameters
+#define GET_CopyColorSubTable(disp) ((disp)->CopyColorSubTable)
+#define SET_CopyColorSubTable(disp, fn) ((disp)->CopyColorSubTable = fn)
+#define CALL_ConvolutionFilter1D(disp, parameters) (*((disp)->ConvolutionFilter1D)) parameters
+#define GET_ConvolutionFilter1D(disp) ((disp)->ConvolutionFilter1D)
+#define SET_ConvolutionFilter1D(disp, fn) ((disp)->ConvolutionFilter1D = fn)
+#define CALL_ConvolutionFilter2D(disp, parameters) (*((disp)->ConvolutionFilter2D)) parameters
+#define GET_ConvolutionFilter2D(disp) ((disp)->ConvolutionFilter2D)
+#define SET_ConvolutionFilter2D(disp, fn) ((disp)->ConvolutionFilter2D = fn)
+#define CALL_ConvolutionParameterf(disp, parameters) (*((disp)->ConvolutionParameterf)) parameters
+#define GET_ConvolutionParameterf(disp) ((disp)->ConvolutionParameterf)
+#define SET_ConvolutionParameterf(disp, fn) ((disp)->ConvolutionParameterf = fn)
+#define CALL_ConvolutionParameterfv(disp, parameters) (*((disp)->ConvolutionParameterfv)) parameters
+#define GET_ConvolutionParameterfv(disp) ((disp)->ConvolutionParameterfv)
+#define SET_ConvolutionParameterfv(disp, fn) ((disp)->ConvolutionParameterfv = fn)
+#define CALL_ConvolutionParameteri(disp, parameters) (*((disp)->ConvolutionParameteri)) parameters
+#define GET_ConvolutionParameteri(disp) ((disp)->ConvolutionParameteri)
+#define SET_ConvolutionParameteri(disp, fn) ((disp)->ConvolutionParameteri = fn)
+#define CALL_ConvolutionParameteriv(disp, parameters) (*((disp)->ConvolutionParameteriv)) parameters
+#define GET_ConvolutionParameteriv(disp) ((disp)->ConvolutionParameteriv)
+#define SET_ConvolutionParameteriv(disp, fn) ((disp)->ConvolutionParameteriv = fn)
+#define CALL_CopyConvolutionFilter1D(disp, parameters) (*((disp)->CopyConvolutionFilter1D)) parameters
+#define GET_CopyConvolutionFilter1D(disp) ((disp)->CopyConvolutionFilter1D)
+#define SET_CopyConvolutionFilter1D(disp, fn) ((disp)->CopyConvolutionFilter1D = fn)
+#define CALL_CopyConvolutionFilter2D(disp, parameters) (*((disp)->CopyConvolutionFilter2D)) parameters
+#define GET_CopyConvolutionFilter2D(disp) ((disp)->CopyConvolutionFilter2D)
+#define SET_CopyConvolutionFilter2D(disp, fn) ((disp)->CopyConvolutionFilter2D = fn)
+#define CALL_GetConvolutionFilter(disp, parameters) (*((disp)->GetConvolutionFilter)) parameters
+#define GET_GetConvolutionFilter(disp) ((disp)->GetConvolutionFilter)
+#define SET_GetConvolutionFilter(disp, fn) ((disp)->GetConvolutionFilter = fn)
+#define CALL_GetConvolutionParameterfv(disp, parameters) (*((disp)->GetConvolutionParameterfv)) parameters
+#define GET_GetConvolutionParameterfv(disp) ((disp)->GetConvolutionParameterfv)
+#define SET_GetConvolutionParameterfv(disp, fn) ((disp)->GetConvolutionParameterfv = fn)
+#define CALL_GetConvolutionParameteriv(disp, parameters) (*((disp)->GetConvolutionParameteriv)) parameters
+#define GET_GetConvolutionParameteriv(disp) ((disp)->GetConvolutionParameteriv)
+#define SET_GetConvolutionParameteriv(disp, fn) ((disp)->GetConvolutionParameteriv = fn)
+#define CALL_GetSeparableFilter(disp, parameters) (*((disp)->GetSeparableFilter)) parameters
+#define GET_GetSeparableFilter(disp) ((disp)->GetSeparableFilter)
+#define SET_GetSeparableFilter(disp, fn) ((disp)->GetSeparableFilter = fn)
+#define CALL_SeparableFilter2D(disp, parameters) (*((disp)->SeparableFilter2D)) parameters
+#define GET_SeparableFilter2D(disp) ((disp)->SeparableFilter2D)
+#define SET_SeparableFilter2D(disp, fn) ((disp)->SeparableFilter2D = fn)
+#define CALL_GetHistogram(disp, parameters) (*((disp)->GetHistogram)) parameters
+#define GET_GetHistogram(disp) ((disp)->GetHistogram)
+#define SET_GetHistogram(disp, fn) ((disp)->GetHistogram = fn)
+#define CALL_GetHistogramParameterfv(disp, parameters) (*((disp)->GetHistogramParameterfv)) parameters
+#define GET_GetHistogramParameterfv(disp) ((disp)->GetHistogramParameterfv)
+#define SET_GetHistogramParameterfv(disp, fn) ((disp)->GetHistogramParameterfv = fn)
+#define CALL_GetHistogramParameteriv(disp, parameters) (*((disp)->GetHistogramParameteriv)) parameters
+#define GET_GetHistogramParameteriv(disp) ((disp)->GetHistogramParameteriv)
+#define SET_GetHistogramParameteriv(disp, fn) ((disp)->GetHistogramParameteriv = fn)
+#define CALL_GetMinmax(disp, parameters) (*((disp)->GetMinmax)) parameters
+#define GET_GetMinmax(disp) ((disp)->GetMinmax)
+#define SET_GetMinmax(disp, fn) ((disp)->GetMinmax = fn)
+#define CALL_GetMinmaxParameterfv(disp, parameters) (*((disp)->GetMinmaxParameterfv)) parameters
+#define GET_GetMinmaxParameterfv(disp) ((disp)->GetMinmaxParameterfv)
+#define SET_GetMinmaxParameterfv(disp, fn) ((disp)->GetMinmaxParameterfv = fn)
+#define CALL_GetMinmaxParameteriv(disp, parameters) (*((disp)->GetMinmaxParameteriv)) parameters
+#define GET_GetMinmaxParameteriv(disp) ((disp)->GetMinmaxParameteriv)
+#define SET_GetMinmaxParameteriv(disp, fn) ((disp)->GetMinmaxParameteriv = fn)
+#define CALL_Histogram(disp, parameters) (*((disp)->Histogram)) parameters
+#define GET_Histogram(disp) ((disp)->Histogram)
+#define SET_Histogram(disp, fn) ((disp)->Histogram = fn)
+#define CALL_Minmax(disp, parameters) (*((disp)->Minmax)) parameters
+#define GET_Minmax(disp) ((disp)->Minmax)
+#define SET_Minmax(disp, fn) ((disp)->Minmax = fn)
+#define CALL_ResetHistogram(disp, parameters) (*((disp)->ResetHistogram)) parameters
+#define GET_ResetHistogram(disp) ((disp)->ResetHistogram)
+#define SET_ResetHistogram(disp, fn) ((disp)->ResetHistogram = fn)
+#define CALL_ResetMinmax(disp, parameters) (*((disp)->ResetMinmax)) parameters
+#define GET_ResetMinmax(disp) ((disp)->ResetMinmax)
+#define SET_ResetMinmax(disp, fn) ((disp)->ResetMinmax = fn)
+#define CALL_TexImage3D(disp, parameters) (*((disp)->TexImage3D)) parameters
+#define GET_TexImage3D(disp) ((disp)->TexImage3D)
+#define SET_TexImage3D(disp, fn) ((disp)->TexImage3D = fn)
+#define CALL_TexSubImage3D(disp, parameters) (*((disp)->TexSubImage3D)) parameters
+#define GET_TexSubImage3D(disp) ((disp)->TexSubImage3D)
+#define SET_TexSubImage3D(disp, fn) ((disp)->TexSubImage3D = fn)
+#define CALL_CopyTexSubImage3D(disp, parameters) (*((disp)->CopyTexSubImage3D)) parameters
+#define GET_CopyTexSubImage3D(disp) ((disp)->CopyTexSubImage3D)
+#define SET_CopyTexSubImage3D(disp, fn) ((disp)->CopyTexSubImage3D = fn)
+#define CALL_ActiveTextureARB(disp, parameters) (*((disp)->ActiveTextureARB)) parameters
+#define GET_ActiveTextureARB(disp) ((disp)->ActiveTextureARB)
+#define SET_ActiveTextureARB(disp, fn) ((disp)->ActiveTextureARB = fn)
+#define CALL_ClientActiveTextureARB(disp, parameters) (*((disp)->ClientActiveTextureARB)) parameters
+#define GET_ClientActiveTextureARB(disp) ((disp)->ClientActiveTextureARB)
+#define SET_ClientActiveTextureARB(disp, fn) ((disp)->ClientActiveTextureARB = fn)
+#define CALL_MultiTexCoord1dARB(disp, parameters) (*((disp)->MultiTexCoord1dARB)) parameters
+#define GET_MultiTexCoord1dARB(disp) ((disp)->MultiTexCoord1dARB)
+#define SET_MultiTexCoord1dARB(disp, fn) ((disp)->MultiTexCoord1dARB = fn)
+#define CALL_MultiTexCoord1dvARB(disp, parameters) (*((disp)->MultiTexCoord1dvARB)) parameters
+#define GET_MultiTexCoord1dvARB(disp) ((disp)->MultiTexCoord1dvARB)
+#define SET_MultiTexCoord1dvARB(disp, fn) ((disp)->MultiTexCoord1dvARB = fn)
+#define CALL_MultiTexCoord1fARB(disp, parameters) (*((disp)->MultiTexCoord1fARB)) parameters
+#define GET_MultiTexCoord1fARB(disp) ((disp)->MultiTexCoord1fARB)
+#define SET_MultiTexCoord1fARB(disp, fn) ((disp)->MultiTexCoord1fARB = fn)
+#define CALL_MultiTexCoord1fvARB(disp, parameters) (*((disp)->MultiTexCoord1fvARB)) parameters
+#define GET_MultiTexCoord1fvARB(disp) ((disp)->MultiTexCoord1fvARB)
+#define SET_MultiTexCoord1fvARB(disp, fn) ((disp)->MultiTexCoord1fvARB = fn)
+#define CALL_MultiTexCoord1iARB(disp, parameters) (*((disp)->MultiTexCoord1iARB)) parameters
+#define GET_MultiTexCoord1iARB(disp) ((disp)->MultiTexCoord1iARB)
+#define SET_MultiTexCoord1iARB(disp, fn) ((disp)->MultiTexCoord1iARB = fn)
+#define CALL_MultiTexCoord1ivARB(disp, parameters) (*((disp)->MultiTexCoord1ivARB)) parameters
+#define GET_MultiTexCoord1ivARB(disp) ((disp)->MultiTexCoord1ivARB)
+#define SET_MultiTexCoord1ivARB(disp, fn) ((disp)->MultiTexCoord1ivARB = fn)
+#define CALL_MultiTexCoord1sARB(disp, parameters) (*((disp)->MultiTexCoord1sARB)) parameters
+#define GET_MultiTexCoord1sARB(disp) ((disp)->MultiTexCoord1sARB)
+#define SET_MultiTexCoord1sARB(disp, fn) ((disp)->MultiTexCoord1sARB = fn)
+#define CALL_MultiTexCoord1svARB(disp, parameters) (*((disp)->MultiTexCoord1svARB)) parameters
+#define GET_MultiTexCoord1svARB(disp) ((disp)->MultiTexCoord1svARB)
+#define SET_MultiTexCoord1svARB(disp, fn) ((disp)->MultiTexCoord1svARB = fn)
+#define CALL_MultiTexCoord2dARB(disp, parameters) (*((disp)->MultiTexCoord2dARB)) parameters
+#define GET_MultiTexCoord2dARB(disp) ((disp)->MultiTexCoord2dARB)
+#define SET_MultiTexCoord2dARB(disp, fn) ((disp)->MultiTexCoord2dARB = fn)
+#define CALL_MultiTexCoord2dvARB(disp, parameters) (*((disp)->MultiTexCoord2dvARB)) parameters
+#define GET_MultiTexCoord2dvARB(disp) ((disp)->MultiTexCoord2dvARB)
+#define SET_MultiTexCoord2dvARB(disp, fn) ((disp)->MultiTexCoord2dvARB = fn)
+#define CALL_MultiTexCoord2fARB(disp, parameters) (*((disp)->MultiTexCoord2fARB)) parameters
+#define GET_MultiTexCoord2fARB(disp) ((disp)->MultiTexCoord2fARB)
+#define SET_MultiTexCoord2fARB(disp, fn) ((disp)->MultiTexCoord2fARB = fn)
+#define CALL_MultiTexCoord2fvARB(disp, parameters) (*((disp)->MultiTexCoord2fvARB)) parameters
+#define GET_MultiTexCoord2fvARB(disp) ((disp)->MultiTexCoord2fvARB)
+#define SET_MultiTexCoord2fvARB(disp, fn) ((disp)->MultiTexCoord2fvARB = fn)
+#define CALL_MultiTexCoord2iARB(disp, parameters) (*((disp)->MultiTexCoord2iARB)) parameters
+#define GET_MultiTexCoord2iARB(disp) ((disp)->MultiTexCoord2iARB)
+#define SET_MultiTexCoord2iARB(disp, fn) ((disp)->MultiTexCoord2iARB = fn)
+#define CALL_MultiTexCoord2ivARB(disp, parameters) (*((disp)->MultiTexCoord2ivARB)) parameters
+#define GET_MultiTexCoord2ivARB(disp) ((disp)->MultiTexCoord2ivARB)
+#define SET_MultiTexCoord2ivARB(disp, fn) ((disp)->MultiTexCoord2ivARB = fn)
+#define CALL_MultiTexCoord2sARB(disp, parameters) (*((disp)->MultiTexCoord2sARB)) parameters
+#define GET_MultiTexCoord2sARB(disp) ((disp)->MultiTexCoord2sARB)
+#define SET_MultiTexCoord2sARB(disp, fn) ((disp)->MultiTexCoord2sARB = fn)
+#define CALL_MultiTexCoord2svARB(disp, parameters) (*((disp)->MultiTexCoord2svARB)) parameters
+#define GET_MultiTexCoord2svARB(disp) ((disp)->MultiTexCoord2svARB)
+#define SET_MultiTexCoord2svARB(disp, fn) ((disp)->MultiTexCoord2svARB = fn)
+#define CALL_MultiTexCoord3dARB(disp, parameters) (*((disp)->MultiTexCoord3dARB)) parameters
+#define GET_MultiTexCoord3dARB(disp) ((disp)->MultiTexCoord3dARB)
+#define SET_MultiTexCoord3dARB(disp, fn) ((disp)->MultiTexCoord3dARB = fn)
+#define CALL_MultiTexCoord3dvARB(disp, parameters) (*((disp)->MultiTexCoord3dvARB)) parameters
+#define GET_MultiTexCoord3dvARB(disp) ((disp)->MultiTexCoord3dvARB)
+#define SET_MultiTexCoord3dvARB(disp, fn) ((disp)->MultiTexCoord3dvARB = fn)
+#define CALL_MultiTexCoord3fARB(disp, parameters) (*((disp)->MultiTexCoord3fARB)) parameters
+#define GET_MultiTexCoord3fARB(disp) ((disp)->MultiTexCoord3fARB)
+#define SET_MultiTexCoord3fARB(disp, fn) ((disp)->MultiTexCoord3fARB = fn)
+#define CALL_MultiTexCoord3fvARB(disp, parameters) (*((disp)->MultiTexCoord3fvARB)) parameters
+#define GET_MultiTexCoord3fvARB(disp) ((disp)->MultiTexCoord3fvARB)
+#define SET_MultiTexCoord3fvARB(disp, fn) ((disp)->MultiTexCoord3fvARB = fn)
+#define CALL_MultiTexCoord3iARB(disp, parameters) (*((disp)->MultiTexCoord3iARB)) parameters
+#define GET_MultiTexCoord3iARB(disp) ((disp)->MultiTexCoord3iARB)
+#define SET_MultiTexCoord3iARB(disp, fn) ((disp)->MultiTexCoord3iARB = fn)
+#define CALL_MultiTexCoord3ivARB(disp, parameters) (*((disp)->MultiTexCoord3ivARB)) parameters
+#define GET_MultiTexCoord3ivARB(disp) ((disp)->MultiTexCoord3ivARB)
+#define SET_MultiTexCoord3ivARB(disp, fn) ((disp)->MultiTexCoord3ivARB = fn)
+#define CALL_MultiTexCoord3sARB(disp, parameters) (*((disp)->MultiTexCoord3sARB)) parameters
+#define GET_MultiTexCoord3sARB(disp) ((disp)->MultiTexCoord3sARB)
+#define SET_MultiTexCoord3sARB(disp, fn) ((disp)->MultiTexCoord3sARB = fn)
+#define CALL_MultiTexCoord3svARB(disp, parameters) (*((disp)->MultiTexCoord3svARB)) parameters
+#define GET_MultiTexCoord3svARB(disp) ((disp)->MultiTexCoord3svARB)
+#define SET_MultiTexCoord3svARB(disp, fn) ((disp)->MultiTexCoord3svARB = fn)
+#define CALL_MultiTexCoord4dARB(disp, parameters) (*((disp)->MultiTexCoord4dARB)) parameters
+#define GET_MultiTexCoord4dARB(disp) ((disp)->MultiTexCoord4dARB)
+#define SET_MultiTexCoord4dARB(disp, fn) ((disp)->MultiTexCoord4dARB = fn)
+#define CALL_MultiTexCoord4dvARB(disp, parameters) (*((disp)->MultiTexCoord4dvARB)) parameters
+#define GET_MultiTexCoord4dvARB(disp) ((disp)->MultiTexCoord4dvARB)
+#define SET_MultiTexCoord4dvARB(disp, fn) ((disp)->MultiTexCoord4dvARB = fn)
+#define CALL_MultiTexCoord4fARB(disp, parameters) (*((disp)->MultiTexCoord4fARB)) parameters
+#define GET_MultiTexCoord4fARB(disp) ((disp)->MultiTexCoord4fARB)
+#define SET_MultiTexCoord4fARB(disp, fn) ((disp)->MultiTexCoord4fARB = fn)
+#define CALL_MultiTexCoord4fvARB(disp, parameters) (*((disp)->MultiTexCoord4fvARB)) parameters
+#define GET_MultiTexCoord4fvARB(disp) ((disp)->MultiTexCoord4fvARB)
+#define SET_MultiTexCoord4fvARB(disp, fn) ((disp)->MultiTexCoord4fvARB = fn)
+#define CALL_MultiTexCoord4iARB(disp, parameters) (*((disp)->MultiTexCoord4iARB)) parameters
+#define GET_MultiTexCoord4iARB(disp) ((disp)->MultiTexCoord4iARB)
+#define SET_MultiTexCoord4iARB(disp, fn) ((disp)->MultiTexCoord4iARB = fn)
+#define CALL_MultiTexCoord4ivARB(disp, parameters) (*((disp)->MultiTexCoord4ivARB)) parameters
+#define GET_MultiTexCoord4ivARB(disp) ((disp)->MultiTexCoord4ivARB)
+#define SET_MultiTexCoord4ivARB(disp, fn) ((disp)->MultiTexCoord4ivARB = fn)
+#define CALL_MultiTexCoord4sARB(disp, parameters) (*((disp)->MultiTexCoord4sARB)) parameters
+#define GET_MultiTexCoord4sARB(disp) ((disp)->MultiTexCoord4sARB)
+#define SET_MultiTexCoord4sARB(disp, fn) ((disp)->MultiTexCoord4sARB = fn)
+#define CALL_MultiTexCoord4svARB(disp, parameters) (*((disp)->MultiTexCoord4svARB)) parameters
+#define GET_MultiTexCoord4svARB(disp) ((disp)->MultiTexCoord4svARB)
+#define SET_MultiTexCoord4svARB(disp, fn) ((disp)->MultiTexCoord4svARB = fn)
+
+#if !defined(_GLAPI_USE_REMAP_TABLE)
+
+#define CALL_AttachShader(disp, parameters) (*((disp)->AttachShader)) parameters
+#define GET_AttachShader(disp) ((disp)->AttachShader)
+#define SET_AttachShader(disp, fn) ((disp)->AttachShader = fn)
+#define CALL_CreateProgram(disp, parameters) (*((disp)->CreateProgram)) parameters
+#define GET_CreateProgram(disp) ((disp)->CreateProgram)
+#define SET_CreateProgram(disp, fn) ((disp)->CreateProgram = fn)
+#define CALL_CreateShader(disp, parameters) (*((disp)->CreateShader)) parameters
+#define GET_CreateShader(disp) ((disp)->CreateShader)
+#define SET_CreateShader(disp, fn) ((disp)->CreateShader = fn)
+#define CALL_DeleteProgram(disp, parameters) (*((disp)->DeleteProgram)) parameters
+#define GET_DeleteProgram(disp) ((disp)->DeleteProgram)
+#define SET_DeleteProgram(disp, fn) ((disp)->DeleteProgram = fn)
+#define CALL_DeleteShader(disp, parameters) (*((disp)->DeleteShader)) parameters
+#define GET_DeleteShader(disp) ((disp)->DeleteShader)
+#define SET_DeleteShader(disp, fn) ((disp)->DeleteShader = fn)
+#define CALL_DetachShader(disp, parameters) (*((disp)->DetachShader)) parameters
+#define GET_DetachShader(disp) ((disp)->DetachShader)
+#define SET_DetachShader(disp, fn) ((disp)->DetachShader = fn)
+#define CALL_GetAttachedShaders(disp, parameters) (*((disp)->GetAttachedShaders)) parameters
+#define GET_GetAttachedShaders(disp) ((disp)->GetAttachedShaders)
+#define SET_GetAttachedShaders(disp, fn) ((disp)->GetAttachedShaders = fn)
+#define CALL_GetProgramInfoLog(disp, parameters) (*((disp)->GetProgramInfoLog)) parameters
+#define GET_GetProgramInfoLog(disp) ((disp)->GetProgramInfoLog)
+#define SET_GetProgramInfoLog(disp, fn) ((disp)->GetProgramInfoLog = fn)
+#define CALL_GetProgramiv(disp, parameters) (*((disp)->GetProgramiv)) parameters
+#define GET_GetProgramiv(disp) ((disp)->GetProgramiv)
+#define SET_GetProgramiv(disp, fn) ((disp)->GetProgramiv = fn)
+#define CALL_GetShaderInfoLog(disp, parameters) (*((disp)->GetShaderInfoLog)) parameters
+#define GET_GetShaderInfoLog(disp) ((disp)->GetShaderInfoLog)
+#define SET_GetShaderInfoLog(disp, fn) ((disp)->GetShaderInfoLog = fn)
+#define CALL_GetShaderiv(disp, parameters) (*((disp)->GetShaderiv)) parameters
+#define GET_GetShaderiv(disp) ((disp)->GetShaderiv)
+#define SET_GetShaderiv(disp, fn) ((disp)->GetShaderiv = fn)
+#define CALL_IsProgram(disp, parameters) (*((disp)->IsProgram)) parameters
+#define GET_IsProgram(disp) ((disp)->IsProgram)
+#define SET_IsProgram(disp, fn) ((disp)->IsProgram = fn)
+#define CALL_IsShader(disp, parameters) (*((disp)->IsShader)) parameters
+#define GET_IsShader(disp) ((disp)->IsShader)
+#define SET_IsShader(disp, fn) ((disp)->IsShader = fn)
+#define CALL_StencilFuncSeparate(disp, parameters) (*((disp)->StencilFuncSeparate)) parameters
+#define GET_StencilFuncSeparate(disp) ((disp)->StencilFuncSeparate)
+#define SET_StencilFuncSeparate(disp, fn) ((disp)->StencilFuncSeparate = fn)
+#define CALL_StencilMaskSeparate(disp, parameters) (*((disp)->StencilMaskSeparate)) parameters
+#define GET_StencilMaskSeparate(disp) ((disp)->StencilMaskSeparate)
+#define SET_StencilMaskSeparate(disp, fn) ((disp)->StencilMaskSeparate = fn)
+#define CALL_StencilOpSeparate(disp, parameters) (*((disp)->StencilOpSeparate)) parameters
+#define GET_StencilOpSeparate(disp) ((disp)->StencilOpSeparate)
+#define SET_StencilOpSeparate(disp, fn) ((disp)->StencilOpSeparate = fn)
+#define CALL_UniformMatrix2x3fv(disp, parameters) (*((disp)->UniformMatrix2x3fv)) parameters
+#define GET_UniformMatrix2x3fv(disp) ((disp)->UniformMatrix2x3fv)
+#define SET_UniformMatrix2x3fv(disp, fn) ((disp)->UniformMatrix2x3fv = fn)
+#define CALL_UniformMatrix2x4fv(disp, parameters) (*((disp)->UniformMatrix2x4fv)) parameters
+#define GET_UniformMatrix2x4fv(disp) ((disp)->UniformMatrix2x4fv)
+#define SET_UniformMatrix2x4fv(disp, fn) ((disp)->UniformMatrix2x4fv = fn)
+#define CALL_UniformMatrix3x2fv(disp, parameters) (*((disp)->UniformMatrix3x2fv)) parameters
+#define GET_UniformMatrix3x2fv(disp) ((disp)->UniformMatrix3x2fv)
+#define SET_UniformMatrix3x2fv(disp, fn) ((disp)->UniformMatrix3x2fv = fn)
+#define CALL_UniformMatrix3x4fv(disp, parameters) (*((disp)->UniformMatrix3x4fv)) parameters
+#define GET_UniformMatrix3x4fv(disp) ((disp)->UniformMatrix3x4fv)
+#define SET_UniformMatrix3x4fv(disp, fn) ((disp)->UniformMatrix3x4fv = fn)
+#define CALL_UniformMatrix4x2fv(disp, parameters) (*((disp)->UniformMatrix4x2fv)) parameters
+#define GET_UniformMatrix4x2fv(disp) ((disp)->UniformMatrix4x2fv)
+#define SET_UniformMatrix4x2fv(disp, fn) ((disp)->UniformMatrix4x2fv = fn)
+#define CALL_UniformMatrix4x3fv(disp, parameters) (*((disp)->UniformMatrix4x3fv)) parameters
+#define GET_UniformMatrix4x3fv(disp) ((disp)->UniformMatrix4x3fv)
+#define SET_UniformMatrix4x3fv(disp, fn) ((disp)->UniformMatrix4x3fv = fn)
+#define CALL_LoadTransposeMatrixdARB(disp, parameters) (*((disp)->LoadTransposeMatrixdARB)) parameters
+#define GET_LoadTransposeMatrixdARB(disp) ((disp)->LoadTransposeMatrixdARB)
+#define SET_LoadTransposeMatrixdARB(disp, fn) ((disp)->LoadTransposeMatrixdARB = fn)
+#define CALL_LoadTransposeMatrixfARB(disp, parameters) (*((disp)->LoadTransposeMatrixfARB)) parameters
+#define GET_LoadTransposeMatrixfARB(disp) ((disp)->LoadTransposeMatrixfARB)
+#define SET_LoadTransposeMatrixfARB(disp, fn) ((disp)->LoadTransposeMatrixfARB = fn)
+#define CALL_MultTransposeMatrixdARB(disp, parameters) (*((disp)->MultTransposeMatrixdARB)) parameters
+#define GET_MultTransposeMatrixdARB(disp) ((disp)->MultTransposeMatrixdARB)
+#define SET_MultTransposeMatrixdARB(disp, fn) ((disp)->MultTransposeMatrixdARB = fn)
+#define CALL_MultTransposeMatrixfARB(disp, parameters) (*((disp)->MultTransposeMatrixfARB)) parameters
+#define GET_MultTransposeMatrixfARB(disp) ((disp)->MultTransposeMatrixfARB)
+#define SET_MultTransposeMatrixfARB(disp, fn) ((disp)->MultTransposeMatrixfARB = fn)
+#define CALL_SampleCoverageARB(disp, parameters) (*((disp)->SampleCoverageARB)) parameters
+#define GET_SampleCoverageARB(disp) ((disp)->SampleCoverageARB)
+#define SET_SampleCoverageARB(disp, fn) ((disp)->SampleCoverageARB = fn)
+#define CALL_CompressedTexImage1DARB(disp, parameters) (*((disp)->CompressedTexImage1DARB)) parameters
+#define GET_CompressedTexImage1DARB(disp) ((disp)->CompressedTexImage1DARB)
+#define SET_CompressedTexImage1DARB(disp, fn) ((disp)->CompressedTexImage1DARB = fn)
+#define CALL_CompressedTexImage2DARB(disp, parameters) (*((disp)->CompressedTexImage2DARB)) parameters
+#define GET_CompressedTexImage2DARB(disp) ((disp)->CompressedTexImage2DARB)
+#define SET_CompressedTexImage2DARB(disp, fn) ((disp)->CompressedTexImage2DARB = fn)
+#define CALL_CompressedTexImage3DARB(disp, parameters) (*((disp)->CompressedTexImage3DARB)) parameters
+#define GET_CompressedTexImage3DARB(disp) ((disp)->CompressedTexImage3DARB)
+#define SET_CompressedTexImage3DARB(disp, fn) ((disp)->CompressedTexImage3DARB = fn)
+#define CALL_CompressedTexSubImage1DARB(disp, parameters) (*((disp)->CompressedTexSubImage1DARB)) parameters
+#define GET_CompressedTexSubImage1DARB(disp) ((disp)->CompressedTexSubImage1DARB)
+#define SET_CompressedTexSubImage1DARB(disp, fn) ((disp)->CompressedTexSubImage1DARB = fn)
+#define CALL_CompressedTexSubImage2DARB(disp, parameters) (*((disp)->CompressedTexSubImage2DARB)) parameters
+#define GET_CompressedTexSubImage2DARB(disp) ((disp)->CompressedTexSubImage2DARB)
+#define SET_CompressedTexSubImage2DARB(disp, fn) ((disp)->CompressedTexSubImage2DARB = fn)
+#define CALL_CompressedTexSubImage3DARB(disp, parameters) (*((disp)->CompressedTexSubImage3DARB)) parameters
+#define GET_CompressedTexSubImage3DARB(disp) ((disp)->CompressedTexSubImage3DARB)
+#define SET_CompressedTexSubImage3DARB(disp, fn) ((disp)->CompressedTexSubImage3DARB = fn)
+#define CALL_GetCompressedTexImageARB(disp, parameters) (*((disp)->GetCompressedTexImageARB)) parameters
+#define GET_GetCompressedTexImageARB(disp) ((disp)->GetCompressedTexImageARB)
+#define SET_GetCompressedTexImageARB(disp, fn) ((disp)->GetCompressedTexImageARB = fn)
+#define CALL_DisableVertexAttribArrayARB(disp, parameters) (*((disp)->DisableVertexAttribArrayARB)) parameters
+#define GET_DisableVertexAttribArrayARB(disp) ((disp)->DisableVertexAttribArrayARB)
+#define SET_DisableVertexAttribArrayARB(disp, fn) ((disp)->DisableVertexAttribArrayARB = fn)
+#define CALL_EnableVertexAttribArrayARB(disp, parameters) (*((disp)->EnableVertexAttribArrayARB)) parameters
+#define GET_EnableVertexAttribArrayARB(disp) ((disp)->EnableVertexAttribArrayARB)
+#define SET_EnableVertexAttribArrayARB(disp, fn) ((disp)->EnableVertexAttribArrayARB = fn)
+#define CALL_GetProgramEnvParameterdvARB(disp, parameters) (*((disp)->GetProgramEnvParameterdvARB)) parameters
+#define GET_GetProgramEnvParameterdvARB(disp) ((disp)->GetProgramEnvParameterdvARB)
+#define SET_GetProgramEnvParameterdvARB(disp, fn) ((disp)->GetProgramEnvParameterdvARB = fn)
+#define CALL_GetProgramEnvParameterfvARB(disp, parameters) (*((disp)->GetProgramEnvParameterfvARB)) parameters
+#define GET_GetProgramEnvParameterfvARB(disp) ((disp)->GetProgramEnvParameterfvARB)
+#define SET_GetProgramEnvParameterfvARB(disp, fn) ((disp)->GetProgramEnvParameterfvARB = fn)
+#define CALL_GetProgramLocalParameterdvARB(disp, parameters) (*((disp)->GetProgramLocalParameterdvARB)) parameters
+#define GET_GetProgramLocalParameterdvARB(disp) ((disp)->GetProgramLocalParameterdvARB)
+#define SET_GetProgramLocalParameterdvARB(disp, fn) ((disp)->GetProgramLocalParameterdvARB = fn)
+#define CALL_GetProgramLocalParameterfvARB(disp, parameters) (*((disp)->GetProgramLocalParameterfvARB)) parameters
+#define GET_GetProgramLocalParameterfvARB(disp) ((disp)->GetProgramLocalParameterfvARB)
+#define SET_GetProgramLocalParameterfvARB(disp, fn) ((disp)->GetProgramLocalParameterfvARB = fn)
+#define CALL_GetProgramStringARB(disp, parameters) (*((disp)->GetProgramStringARB)) parameters
+#define GET_GetProgramStringARB(disp) ((disp)->GetProgramStringARB)
+#define SET_GetProgramStringARB(disp, fn) ((disp)->GetProgramStringARB = fn)
+#define CALL_GetProgramivARB(disp, parameters) (*((disp)->GetProgramivARB)) parameters
+#define GET_GetProgramivARB(disp) ((disp)->GetProgramivARB)
+#define SET_GetProgramivARB(disp, fn) ((disp)->GetProgramivARB = fn)
+#define CALL_GetVertexAttribdvARB(disp, parameters) (*((disp)->GetVertexAttribdvARB)) parameters
+#define GET_GetVertexAttribdvARB(disp) ((disp)->GetVertexAttribdvARB)
+#define SET_GetVertexAttribdvARB(disp, fn) ((disp)->GetVertexAttribdvARB = fn)
+#define CALL_GetVertexAttribfvARB(disp, parameters) (*((disp)->GetVertexAttribfvARB)) parameters
+#define GET_GetVertexAttribfvARB(disp) ((disp)->GetVertexAttribfvARB)
+#define SET_GetVertexAttribfvARB(disp, fn) ((disp)->GetVertexAttribfvARB = fn)
+#define CALL_GetVertexAttribivARB(disp, parameters) (*((disp)->GetVertexAttribivARB)) parameters
+#define GET_GetVertexAttribivARB(disp) ((disp)->GetVertexAttribivARB)
+#define SET_GetVertexAttribivARB(disp, fn) ((disp)->GetVertexAttribivARB = fn)
+#define CALL_ProgramEnvParameter4dARB(disp, parameters) (*((disp)->ProgramEnvParameter4dARB)) parameters
+#define GET_ProgramEnvParameter4dARB(disp) ((disp)->ProgramEnvParameter4dARB)
+#define SET_ProgramEnvParameter4dARB(disp, fn) ((disp)->ProgramEnvParameter4dARB = fn)
+#define CALL_ProgramEnvParameter4dvARB(disp, parameters) (*((disp)->ProgramEnvParameter4dvARB)) parameters
+#define GET_ProgramEnvParameter4dvARB(disp) ((disp)->ProgramEnvParameter4dvARB)
+#define SET_ProgramEnvParameter4dvARB(disp, fn) ((disp)->ProgramEnvParameter4dvARB = fn)
+#define CALL_ProgramEnvParameter4fARB(disp, parameters) (*((disp)->ProgramEnvParameter4fARB)) parameters
+#define GET_ProgramEnvParameter4fARB(disp) ((disp)->ProgramEnvParameter4fARB)
+#define SET_ProgramEnvParameter4fARB(disp, fn) ((disp)->ProgramEnvParameter4fARB = fn)
+#define CALL_ProgramEnvParameter4fvARB(disp, parameters) (*((disp)->ProgramEnvParameter4fvARB)) parameters
+#define GET_ProgramEnvParameter4fvARB(disp) ((disp)->ProgramEnvParameter4fvARB)
+#define SET_ProgramEnvParameter4fvARB(disp, fn) ((disp)->ProgramEnvParameter4fvARB = fn)
+#define CALL_ProgramLocalParameter4dARB(disp, parameters) (*((disp)->ProgramLocalParameter4dARB)) parameters
+#define GET_ProgramLocalParameter4dARB(disp) ((disp)->ProgramLocalParameter4dARB)
+#define SET_ProgramLocalParameter4dARB(disp, fn) ((disp)->ProgramLocalParameter4dARB = fn)
+#define CALL_ProgramLocalParameter4dvARB(disp, parameters) (*((disp)->ProgramLocalParameter4dvARB)) parameters
+#define GET_ProgramLocalParameter4dvARB(disp) ((disp)->ProgramLocalParameter4dvARB)
+#define SET_ProgramLocalParameter4dvARB(disp, fn) ((disp)->ProgramLocalParameter4dvARB = fn)
+#define CALL_ProgramLocalParameter4fARB(disp, parameters) (*((disp)->ProgramLocalParameter4fARB)) parameters
+#define GET_ProgramLocalParameter4fARB(disp) ((disp)->ProgramLocalParameter4fARB)
+#define SET_ProgramLocalParameter4fARB(disp, fn) ((disp)->ProgramLocalParameter4fARB = fn)
+#define CALL_ProgramLocalParameter4fvARB(disp, parameters) (*((disp)->ProgramLocalParameter4fvARB)) parameters
+#define GET_ProgramLocalParameter4fvARB(disp) ((disp)->ProgramLocalParameter4fvARB)
+#define SET_ProgramLocalParameter4fvARB(disp, fn) ((disp)->ProgramLocalParameter4fvARB = fn)
+#define CALL_ProgramStringARB(disp, parameters) (*((disp)->ProgramStringARB)) parameters
+#define GET_ProgramStringARB(disp) ((disp)->ProgramStringARB)
+#define SET_ProgramStringARB(disp, fn) ((disp)->ProgramStringARB = fn)
+#define CALL_VertexAttrib1dARB(disp, parameters) (*((disp)->VertexAttrib1dARB)) parameters
+#define GET_VertexAttrib1dARB(disp) ((disp)->VertexAttrib1dARB)
+#define SET_VertexAttrib1dARB(disp, fn) ((disp)->VertexAttrib1dARB = fn)
+#define CALL_VertexAttrib1dvARB(disp, parameters) (*((disp)->VertexAttrib1dvARB)) parameters
+#define GET_VertexAttrib1dvARB(disp) ((disp)->VertexAttrib1dvARB)
+#define SET_VertexAttrib1dvARB(disp, fn) ((disp)->VertexAttrib1dvARB = fn)
+#define CALL_VertexAttrib1fARB(disp, parameters) (*((disp)->VertexAttrib1fARB)) parameters
+#define GET_VertexAttrib1fARB(disp) ((disp)->VertexAttrib1fARB)
+#define SET_VertexAttrib1fARB(disp, fn) ((disp)->VertexAttrib1fARB = fn)
+#define CALL_VertexAttrib1fvARB(disp, parameters) (*((disp)->VertexAttrib1fvARB)) parameters
+#define GET_VertexAttrib1fvARB(disp) ((disp)->VertexAttrib1fvARB)
+#define SET_VertexAttrib1fvARB(disp, fn) ((disp)->VertexAttrib1fvARB = fn)
+#define CALL_VertexAttrib1sARB(disp, parameters) (*((disp)->VertexAttrib1sARB)) parameters
+#define GET_VertexAttrib1sARB(disp) ((disp)->VertexAttrib1sARB)
+#define SET_VertexAttrib1sARB(disp, fn) ((disp)->VertexAttrib1sARB = fn)
+#define CALL_VertexAttrib1svARB(disp, parameters) (*((disp)->VertexAttrib1svARB)) parameters
+#define GET_VertexAttrib1svARB(disp) ((disp)->VertexAttrib1svARB)
+#define SET_VertexAttrib1svARB(disp, fn) ((disp)->VertexAttrib1svARB = fn)
+#define CALL_VertexAttrib2dARB(disp, parameters) (*((disp)->VertexAttrib2dARB)) parameters
+#define GET_VertexAttrib2dARB(disp) ((disp)->VertexAttrib2dARB)
+#define SET_VertexAttrib2dARB(disp, fn) ((disp)->VertexAttrib2dARB = fn)
+#define CALL_VertexAttrib2dvARB(disp, parameters) (*((disp)->VertexAttrib2dvARB)) parameters
+#define GET_VertexAttrib2dvARB(disp) ((disp)->VertexAttrib2dvARB)
+#define SET_VertexAttrib2dvARB(disp, fn) ((disp)->VertexAttrib2dvARB = fn)
+#define CALL_VertexAttrib2fARB(disp, parameters) (*((disp)->VertexAttrib2fARB)) parameters
+#define GET_VertexAttrib2fARB(disp) ((disp)->VertexAttrib2fARB)
+#define SET_VertexAttrib2fARB(disp, fn) ((disp)->VertexAttrib2fARB = fn)
+#define CALL_VertexAttrib2fvARB(disp, parameters) (*((disp)->VertexAttrib2fvARB)) parameters
+#define GET_VertexAttrib2fvARB(disp) ((disp)->VertexAttrib2fvARB)
+#define SET_VertexAttrib2fvARB(disp, fn) ((disp)->VertexAttrib2fvARB = fn)
+#define CALL_VertexAttrib2sARB(disp, parameters) (*((disp)->VertexAttrib2sARB)) parameters
+#define GET_VertexAttrib2sARB(disp) ((disp)->VertexAttrib2sARB)
+#define SET_VertexAttrib2sARB(disp, fn) ((disp)->VertexAttrib2sARB = fn)
+#define CALL_VertexAttrib2svARB(disp, parameters) (*((disp)->VertexAttrib2svARB)) parameters
+#define GET_VertexAttrib2svARB(disp) ((disp)->VertexAttrib2svARB)
+#define SET_VertexAttrib2svARB(disp, fn) ((disp)->VertexAttrib2svARB = fn)
+#define CALL_VertexAttrib3dARB(disp, parameters) (*((disp)->VertexAttrib3dARB)) parameters
+#define GET_VertexAttrib3dARB(disp) ((disp)->VertexAttrib3dARB)
+#define SET_VertexAttrib3dARB(disp, fn) ((disp)->VertexAttrib3dARB = fn)
+#define CALL_VertexAttrib3dvARB(disp, parameters) (*((disp)->VertexAttrib3dvARB)) parameters
+#define GET_VertexAttrib3dvARB(disp) ((disp)->VertexAttrib3dvARB)
+#define SET_VertexAttrib3dvARB(disp, fn) ((disp)->VertexAttrib3dvARB = fn)
+#define CALL_VertexAttrib3fARB(disp, parameters) (*((disp)->VertexAttrib3fARB)) parameters
+#define GET_VertexAttrib3fARB(disp) ((disp)->VertexAttrib3fARB)
+#define SET_VertexAttrib3fARB(disp, fn) ((disp)->VertexAttrib3fARB = fn)
+#define CALL_VertexAttrib3fvARB(disp, parameters) (*((disp)->VertexAttrib3fvARB)) parameters
+#define GET_VertexAttrib3fvARB(disp) ((disp)->VertexAttrib3fvARB)
+#define SET_VertexAttrib3fvARB(disp, fn) ((disp)->VertexAttrib3fvARB = fn)
+#define CALL_VertexAttrib3sARB(disp, parameters) (*((disp)->VertexAttrib3sARB)) parameters
+#define GET_VertexAttrib3sARB(disp) ((disp)->VertexAttrib3sARB)
+#define SET_VertexAttrib3sARB(disp, fn) ((disp)->VertexAttrib3sARB = fn)
+#define CALL_VertexAttrib3svARB(disp, parameters) (*((disp)->VertexAttrib3svARB)) parameters
+#define GET_VertexAttrib3svARB(disp) ((disp)->VertexAttrib3svARB)
+#define SET_VertexAttrib3svARB(disp, fn) ((disp)->VertexAttrib3svARB = fn)
+#define CALL_VertexAttrib4NbvARB(disp, parameters) (*((disp)->VertexAttrib4NbvARB)) parameters
+#define GET_VertexAttrib4NbvARB(disp) ((disp)->VertexAttrib4NbvARB)
+#define SET_VertexAttrib4NbvARB(disp, fn) ((disp)->VertexAttrib4NbvARB = fn)
+#define CALL_VertexAttrib4NivARB(disp, parameters) (*((disp)->VertexAttrib4NivARB)) parameters
+#define GET_VertexAttrib4NivARB(disp) ((disp)->VertexAttrib4NivARB)
+#define SET_VertexAttrib4NivARB(disp, fn) ((disp)->VertexAttrib4NivARB = fn)
+#define CALL_VertexAttrib4NsvARB(disp, parameters) (*((disp)->VertexAttrib4NsvARB)) parameters
+#define GET_VertexAttrib4NsvARB(disp) ((disp)->VertexAttrib4NsvARB)
+#define SET_VertexAttrib4NsvARB(disp, fn) ((disp)->VertexAttrib4NsvARB = fn)
+#define CALL_VertexAttrib4NubARB(disp, parameters) (*((disp)->VertexAttrib4NubARB)) parameters
+#define GET_VertexAttrib4NubARB(disp) ((disp)->VertexAttrib4NubARB)
+#define SET_VertexAttrib4NubARB(disp, fn) ((disp)->VertexAttrib4NubARB = fn)
+#define CALL_VertexAttrib4NubvARB(disp, parameters) (*((disp)->VertexAttrib4NubvARB)) parameters
+#define GET_VertexAttrib4NubvARB(disp) ((disp)->VertexAttrib4NubvARB)
+#define SET_VertexAttrib4NubvARB(disp, fn) ((disp)->VertexAttrib4NubvARB = fn)
+#define CALL_VertexAttrib4NuivARB(disp, parameters) (*((disp)->VertexAttrib4NuivARB)) parameters
+#define GET_VertexAttrib4NuivARB(disp) ((disp)->VertexAttrib4NuivARB)
+#define SET_VertexAttrib4NuivARB(disp, fn) ((disp)->VertexAttrib4NuivARB = fn)
+#define CALL_VertexAttrib4NusvARB(disp, parameters) (*((disp)->VertexAttrib4NusvARB)) parameters
+#define GET_VertexAttrib4NusvARB(disp) ((disp)->VertexAttrib4NusvARB)
+#define SET_VertexAttrib4NusvARB(disp, fn) ((disp)->VertexAttrib4NusvARB = fn)
+#define CALL_VertexAttrib4bvARB(disp, parameters) (*((disp)->VertexAttrib4bvARB)) parameters
+#define GET_VertexAttrib4bvARB(disp) ((disp)->VertexAttrib4bvARB)
+#define SET_VertexAttrib4bvARB(disp, fn) ((disp)->VertexAttrib4bvARB = fn)
+#define CALL_VertexAttrib4dARB(disp, parameters) (*((disp)->VertexAttrib4dARB)) parameters
+#define GET_VertexAttrib4dARB(disp) ((disp)->VertexAttrib4dARB)
+#define SET_VertexAttrib4dARB(disp, fn) ((disp)->VertexAttrib4dARB = fn)
+#define CALL_VertexAttrib4dvARB(disp, parameters) (*((disp)->VertexAttrib4dvARB)) parameters
+#define GET_VertexAttrib4dvARB(disp) ((disp)->VertexAttrib4dvARB)
+#define SET_VertexAttrib4dvARB(disp, fn) ((disp)->VertexAttrib4dvARB = fn)
+#define CALL_VertexAttrib4fARB(disp, parameters) (*((disp)->VertexAttrib4fARB)) parameters
+#define GET_VertexAttrib4fARB(disp) ((disp)->VertexAttrib4fARB)
+#define SET_VertexAttrib4fARB(disp, fn) ((disp)->VertexAttrib4fARB = fn)
+#define CALL_VertexAttrib4fvARB(disp, parameters) (*((disp)->VertexAttrib4fvARB)) parameters
+#define GET_VertexAttrib4fvARB(disp) ((disp)->VertexAttrib4fvARB)
+#define SET_VertexAttrib4fvARB(disp, fn) ((disp)->VertexAttrib4fvARB = fn)
+#define CALL_VertexAttrib4ivARB(disp, parameters) (*((disp)->VertexAttrib4ivARB)) parameters
+#define GET_VertexAttrib4ivARB(disp) ((disp)->VertexAttrib4ivARB)
+#define SET_VertexAttrib4ivARB(disp, fn) ((disp)->VertexAttrib4ivARB = fn)
+#define CALL_VertexAttrib4sARB(disp, parameters) (*((disp)->VertexAttrib4sARB)) parameters
+#define GET_VertexAttrib4sARB(disp) ((disp)->VertexAttrib4sARB)
+#define SET_VertexAttrib4sARB(disp, fn) ((disp)->VertexAttrib4sARB = fn)
+#define CALL_VertexAttrib4svARB(disp, parameters) (*((disp)->VertexAttrib4svARB)) parameters
+#define GET_VertexAttrib4svARB(disp) ((disp)->VertexAttrib4svARB)
+#define SET_VertexAttrib4svARB(disp, fn) ((disp)->VertexAttrib4svARB = fn)
+#define CALL_VertexAttrib4ubvARB(disp, parameters) (*((disp)->VertexAttrib4ubvARB)) parameters
+#define GET_VertexAttrib4ubvARB(disp) ((disp)->VertexAttrib4ubvARB)
+#define SET_VertexAttrib4ubvARB(disp, fn) ((disp)->VertexAttrib4ubvARB = fn)
+#define CALL_VertexAttrib4uivARB(disp, parameters) (*((disp)->VertexAttrib4uivARB)) parameters
+#define GET_VertexAttrib4uivARB(disp) ((disp)->VertexAttrib4uivARB)
+#define SET_VertexAttrib4uivARB(disp, fn) ((disp)->VertexAttrib4uivARB = fn)
+#define CALL_VertexAttrib4usvARB(disp, parameters) (*((disp)->VertexAttrib4usvARB)) parameters
+#define GET_VertexAttrib4usvARB(disp) ((disp)->VertexAttrib4usvARB)
+#define SET_VertexAttrib4usvARB(disp, fn) ((disp)->VertexAttrib4usvARB = fn)
+#define CALL_VertexAttribPointerARB(disp, parameters) (*((disp)->VertexAttribPointerARB)) parameters
+#define GET_VertexAttribPointerARB(disp) ((disp)->VertexAttribPointerARB)
+#define SET_VertexAttribPointerARB(disp, fn) ((disp)->VertexAttribPointerARB = fn)
+#define CALL_BindBufferARB(disp, parameters) (*((disp)->BindBufferARB)) parameters
+#define GET_BindBufferARB(disp) ((disp)->BindBufferARB)
+#define SET_BindBufferARB(disp, fn) ((disp)->BindBufferARB = fn)
+#define CALL_BufferDataARB(disp, parameters) (*((disp)->BufferDataARB)) parameters
+#define GET_BufferDataARB(disp) ((disp)->BufferDataARB)
+#define SET_BufferDataARB(disp, fn) ((disp)->BufferDataARB = fn)
+#define CALL_BufferSubDataARB(disp, parameters) (*((disp)->BufferSubDataARB)) parameters
+#define GET_BufferSubDataARB(disp) ((disp)->BufferSubDataARB)
+#define SET_BufferSubDataARB(disp, fn) ((disp)->BufferSubDataARB = fn)
+#define CALL_DeleteBuffersARB(disp, parameters) (*((disp)->DeleteBuffersARB)) parameters
+#define GET_DeleteBuffersARB(disp) ((disp)->DeleteBuffersARB)
+#define SET_DeleteBuffersARB(disp, fn) ((disp)->DeleteBuffersARB = fn)
+#define CALL_GenBuffersARB(disp, parameters) (*((disp)->GenBuffersARB)) parameters
+#define GET_GenBuffersARB(disp) ((disp)->GenBuffersARB)
+#define SET_GenBuffersARB(disp, fn) ((disp)->GenBuffersARB = fn)
+#define CALL_GetBufferParameterivARB(disp, parameters) (*((disp)->GetBufferParameterivARB)) parameters
+#define GET_GetBufferParameterivARB(disp) ((disp)->GetBufferParameterivARB)
+#define SET_GetBufferParameterivARB(disp, fn) ((disp)->GetBufferParameterivARB = fn)
+#define CALL_GetBufferPointervARB(disp, parameters) (*((disp)->GetBufferPointervARB)) parameters
+#define GET_GetBufferPointervARB(disp) ((disp)->GetBufferPointervARB)
+#define SET_GetBufferPointervARB(disp, fn) ((disp)->GetBufferPointervARB = fn)
+#define CALL_GetBufferSubDataARB(disp, parameters) (*((disp)->GetBufferSubDataARB)) parameters
+#define GET_GetBufferSubDataARB(disp) ((disp)->GetBufferSubDataARB)
+#define SET_GetBufferSubDataARB(disp, fn) ((disp)->GetBufferSubDataARB = fn)
+#define CALL_IsBufferARB(disp, parameters) (*((disp)->IsBufferARB)) parameters
+#define GET_IsBufferARB(disp) ((disp)->IsBufferARB)
+#define SET_IsBufferARB(disp, fn) ((disp)->IsBufferARB = fn)
+#define CALL_MapBufferARB(disp, parameters) (*((disp)->MapBufferARB)) parameters
+#define GET_MapBufferARB(disp) ((disp)->MapBufferARB)
+#define SET_MapBufferARB(disp, fn) ((disp)->MapBufferARB = fn)
+#define CALL_UnmapBufferARB(disp, parameters) (*((disp)->UnmapBufferARB)) parameters
+#define GET_UnmapBufferARB(disp) ((disp)->UnmapBufferARB)
+#define SET_UnmapBufferARB(disp, fn) ((disp)->UnmapBufferARB = fn)
+#define CALL_BeginQueryARB(disp, parameters) (*((disp)->BeginQueryARB)) parameters
+#define GET_BeginQueryARB(disp) ((disp)->BeginQueryARB)
+#define SET_BeginQueryARB(disp, fn) ((disp)->BeginQueryARB = fn)
+#define CALL_DeleteQueriesARB(disp, parameters) (*((disp)->DeleteQueriesARB)) parameters
+#define GET_DeleteQueriesARB(disp) ((disp)->DeleteQueriesARB)
+#define SET_DeleteQueriesARB(disp, fn) ((disp)->DeleteQueriesARB = fn)
+#define CALL_EndQueryARB(disp, parameters) (*((disp)->EndQueryARB)) parameters
+#define GET_EndQueryARB(disp) ((disp)->EndQueryARB)
+#define SET_EndQueryARB(disp, fn) ((disp)->EndQueryARB = fn)
+#define CALL_GenQueriesARB(disp, parameters) (*((disp)->GenQueriesARB)) parameters
+#define GET_GenQueriesARB(disp) ((disp)->GenQueriesARB)
+#define SET_GenQueriesARB(disp, fn) ((disp)->GenQueriesARB = fn)
+#define CALL_GetQueryObjectivARB(disp, parameters) (*((disp)->GetQueryObjectivARB)) parameters
+#define GET_GetQueryObjectivARB(disp) ((disp)->GetQueryObjectivARB)
+#define SET_GetQueryObjectivARB(disp, fn) ((disp)->GetQueryObjectivARB = fn)
+#define CALL_GetQueryObjectuivARB(disp, parameters) (*((disp)->GetQueryObjectuivARB)) parameters
+#define GET_GetQueryObjectuivARB(disp) ((disp)->GetQueryObjectuivARB)
+#define SET_GetQueryObjectuivARB(disp, fn) ((disp)->GetQueryObjectuivARB = fn)
+#define CALL_GetQueryivARB(disp, parameters) (*((disp)->GetQueryivARB)) parameters
+#define GET_GetQueryivARB(disp) ((disp)->GetQueryivARB)
+#define SET_GetQueryivARB(disp, fn) ((disp)->GetQueryivARB = fn)
+#define CALL_IsQueryARB(disp, parameters) (*((disp)->IsQueryARB)) parameters
+#define GET_IsQueryARB(disp) ((disp)->IsQueryARB)
+#define SET_IsQueryARB(disp, fn) ((disp)->IsQueryARB = fn)
+#define CALL_AttachObjectARB(disp, parameters) (*((disp)->AttachObjectARB)) parameters
+#define GET_AttachObjectARB(disp) ((disp)->AttachObjectARB)
+#define SET_AttachObjectARB(disp, fn) ((disp)->AttachObjectARB = fn)
+#define CALL_CompileShaderARB(disp, parameters) (*((disp)->CompileShaderARB)) parameters
+#define GET_CompileShaderARB(disp) ((disp)->CompileShaderARB)
+#define SET_CompileShaderARB(disp, fn) ((disp)->CompileShaderARB = fn)
+#define CALL_CreateProgramObjectARB(disp, parameters) (*((disp)->CreateProgramObjectARB)) parameters
+#define GET_CreateProgramObjectARB(disp) ((disp)->CreateProgramObjectARB)
+#define SET_CreateProgramObjectARB(disp, fn) ((disp)->CreateProgramObjectARB = fn)
+#define CALL_CreateShaderObjectARB(disp, parameters) (*((disp)->CreateShaderObjectARB)) parameters
+#define GET_CreateShaderObjectARB(disp) ((disp)->CreateShaderObjectARB)
+#define SET_CreateShaderObjectARB(disp, fn) ((disp)->CreateShaderObjectARB = fn)
+#define CALL_DeleteObjectARB(disp, parameters) (*((disp)->DeleteObjectARB)) parameters
+#define GET_DeleteObjectARB(disp) ((disp)->DeleteObjectARB)
+#define SET_DeleteObjectARB(disp, fn) ((disp)->DeleteObjectARB = fn)
+#define CALL_DetachObjectARB(disp, parameters) (*((disp)->DetachObjectARB)) parameters
+#define GET_DetachObjectARB(disp) ((disp)->DetachObjectARB)
+#define SET_DetachObjectARB(disp, fn) ((disp)->DetachObjectARB = fn)
+#define CALL_GetActiveUniformARB(disp, parameters) (*((disp)->GetActiveUniformARB)) parameters
+#define GET_GetActiveUniformARB(disp) ((disp)->GetActiveUniformARB)
+#define SET_GetActiveUniformARB(disp, fn) ((disp)->GetActiveUniformARB = fn)
+#define CALL_GetAttachedObjectsARB(disp, parameters) (*((disp)->GetAttachedObjectsARB)) parameters
+#define GET_GetAttachedObjectsARB(disp) ((disp)->GetAttachedObjectsARB)
+#define SET_GetAttachedObjectsARB(disp, fn) ((disp)->GetAttachedObjectsARB = fn)
+#define CALL_GetHandleARB(disp, parameters) (*((disp)->GetHandleARB)) parameters
+#define GET_GetHandleARB(disp) ((disp)->GetHandleARB)
+#define SET_GetHandleARB(disp, fn) ((disp)->GetHandleARB = fn)
+#define CALL_GetInfoLogARB(disp, parameters) (*((disp)->GetInfoLogARB)) parameters
+#define GET_GetInfoLogARB(disp) ((disp)->GetInfoLogARB)
+#define SET_GetInfoLogARB(disp, fn) ((disp)->GetInfoLogARB = fn)
+#define CALL_GetObjectParameterfvARB(disp, parameters) (*((disp)->GetObjectParameterfvARB)) parameters
+#define GET_GetObjectParameterfvARB(disp) ((disp)->GetObjectParameterfvARB)
+#define SET_GetObjectParameterfvARB(disp, fn) ((disp)->GetObjectParameterfvARB = fn)
+#define CALL_GetObjectParameterivARB(disp, parameters) (*((disp)->GetObjectParameterivARB)) parameters
+#define GET_GetObjectParameterivARB(disp) ((disp)->GetObjectParameterivARB)
+#define SET_GetObjectParameterivARB(disp, fn) ((disp)->GetObjectParameterivARB = fn)
+#define CALL_GetShaderSourceARB(disp, parameters) (*((disp)->GetShaderSourceARB)) parameters
+#define GET_GetShaderSourceARB(disp) ((disp)->GetShaderSourceARB)
+#define SET_GetShaderSourceARB(disp, fn) ((disp)->GetShaderSourceARB = fn)
+#define CALL_GetUniformLocationARB(disp, parameters) (*((disp)->GetUniformLocationARB)) parameters
+#define GET_GetUniformLocationARB(disp) ((disp)->GetUniformLocationARB)
+#define SET_GetUniformLocationARB(disp, fn) ((disp)->GetUniformLocationARB = fn)
+#define CALL_GetUniformfvARB(disp, parameters) (*((disp)->GetUniformfvARB)) parameters
+#define GET_GetUniformfvARB(disp) ((disp)->GetUniformfvARB)
+#define SET_GetUniformfvARB(disp, fn) ((disp)->GetUniformfvARB = fn)
+#define CALL_GetUniformivARB(disp, parameters) (*((disp)->GetUniformivARB)) parameters
+#define GET_GetUniformivARB(disp) ((disp)->GetUniformivARB)
+#define SET_GetUniformivARB(disp, fn) ((disp)->GetUniformivARB = fn)
+#define CALL_LinkProgramARB(disp, parameters) (*((disp)->LinkProgramARB)) parameters
+#define GET_LinkProgramARB(disp) ((disp)->LinkProgramARB)
+#define SET_LinkProgramARB(disp, fn) ((disp)->LinkProgramARB = fn)
+#define CALL_ShaderSourceARB(disp, parameters) (*((disp)->ShaderSourceARB)) parameters
+#define GET_ShaderSourceARB(disp) ((disp)->ShaderSourceARB)
+#define SET_ShaderSourceARB(disp, fn) ((disp)->ShaderSourceARB = fn)
+#define CALL_Uniform1fARB(disp, parameters) (*((disp)->Uniform1fARB)) parameters
+#define GET_Uniform1fARB(disp) ((disp)->Uniform1fARB)
+#define SET_Uniform1fARB(disp, fn) ((disp)->Uniform1fARB = fn)
+#define CALL_Uniform1fvARB(disp, parameters) (*((disp)->Uniform1fvARB)) parameters
+#define GET_Uniform1fvARB(disp) ((disp)->Uniform1fvARB)
+#define SET_Uniform1fvARB(disp, fn) ((disp)->Uniform1fvARB = fn)
+#define CALL_Uniform1iARB(disp, parameters) (*((disp)->Uniform1iARB)) parameters
+#define GET_Uniform1iARB(disp) ((disp)->Uniform1iARB)
+#define SET_Uniform1iARB(disp, fn) ((disp)->Uniform1iARB = fn)
+#define CALL_Uniform1ivARB(disp, parameters) (*((disp)->Uniform1ivARB)) parameters
+#define GET_Uniform1ivARB(disp) ((disp)->Uniform1ivARB)
+#define SET_Uniform1ivARB(disp, fn) ((disp)->Uniform1ivARB = fn)
+#define CALL_Uniform2fARB(disp, parameters) (*((disp)->Uniform2fARB)) parameters
+#define GET_Uniform2fARB(disp) ((disp)->Uniform2fARB)
+#define SET_Uniform2fARB(disp, fn) ((disp)->Uniform2fARB = fn)
+#define CALL_Uniform2fvARB(disp, parameters) (*((disp)->Uniform2fvARB)) parameters
+#define GET_Uniform2fvARB(disp) ((disp)->Uniform2fvARB)
+#define SET_Uniform2fvARB(disp, fn) ((disp)->Uniform2fvARB = fn)
+#define CALL_Uniform2iARB(disp, parameters) (*((disp)->Uniform2iARB)) parameters
+#define GET_Uniform2iARB(disp) ((disp)->Uniform2iARB)
+#define SET_Uniform2iARB(disp, fn) ((disp)->Uniform2iARB = fn)
+#define CALL_Uniform2ivARB(disp, parameters) (*((disp)->Uniform2ivARB)) parameters
+#define GET_Uniform2ivARB(disp) ((disp)->Uniform2ivARB)
+#define SET_Uniform2ivARB(disp, fn) ((disp)->Uniform2ivARB = fn)
+#define CALL_Uniform3fARB(disp, parameters) (*((disp)->Uniform3fARB)) parameters
+#define GET_Uniform3fARB(disp) ((disp)->Uniform3fARB)
+#define SET_Uniform3fARB(disp, fn) ((disp)->Uniform3fARB = fn)
+#define CALL_Uniform3fvARB(disp, parameters) (*((disp)->Uniform3fvARB)) parameters
+#define GET_Uniform3fvARB(disp) ((disp)->Uniform3fvARB)
+#define SET_Uniform3fvARB(disp, fn) ((disp)->Uniform3fvARB = fn)
+#define CALL_Uniform3iARB(disp, parameters) (*((disp)->Uniform3iARB)) parameters
+#define GET_Uniform3iARB(disp) ((disp)->Uniform3iARB)
+#define SET_Uniform3iARB(disp, fn) ((disp)->Uniform3iARB = fn)
+#define CALL_Uniform3ivARB(disp, parameters) (*((disp)->Uniform3ivARB)) parameters
+#define GET_Uniform3ivARB(disp) ((disp)->Uniform3ivARB)
+#define SET_Uniform3ivARB(disp, fn) ((disp)->Uniform3ivARB = fn)
+#define CALL_Uniform4fARB(disp, parameters) (*((disp)->Uniform4fARB)) parameters
+#define GET_Uniform4fARB(disp) ((disp)->Uniform4fARB)
+#define SET_Uniform4fARB(disp, fn) ((disp)->Uniform4fARB = fn)
+#define CALL_Uniform4fvARB(disp, parameters) (*((disp)->Uniform4fvARB)) parameters
+#define GET_Uniform4fvARB(disp) ((disp)->Uniform4fvARB)
+#define SET_Uniform4fvARB(disp, fn) ((disp)->Uniform4fvARB = fn)
+#define CALL_Uniform4iARB(disp, parameters) (*((disp)->Uniform4iARB)) parameters
+#define GET_Uniform4iARB(disp) ((disp)->Uniform4iARB)
+#define SET_Uniform4iARB(disp, fn) ((disp)->Uniform4iARB = fn)
+#define CALL_Uniform4ivARB(disp, parameters) (*((disp)->Uniform4ivARB)) parameters
+#define GET_Uniform4ivARB(disp) ((disp)->Uniform4ivARB)
+#define SET_Uniform4ivARB(disp, fn) ((disp)->Uniform4ivARB = fn)
+#define CALL_UniformMatrix2fvARB(disp, parameters) (*((disp)->UniformMatrix2fvARB)) parameters
+#define GET_UniformMatrix2fvARB(disp) ((disp)->UniformMatrix2fvARB)
+#define SET_UniformMatrix2fvARB(disp, fn) ((disp)->UniformMatrix2fvARB = fn)
+#define CALL_UniformMatrix3fvARB(disp, parameters) (*((disp)->UniformMatrix3fvARB)) parameters
+#define GET_UniformMatrix3fvARB(disp) ((disp)->UniformMatrix3fvARB)
+#define SET_UniformMatrix3fvARB(disp, fn) ((disp)->UniformMatrix3fvARB = fn)
+#define CALL_UniformMatrix4fvARB(disp, parameters) (*((disp)->UniformMatrix4fvARB)) parameters
+#define GET_UniformMatrix4fvARB(disp) ((disp)->UniformMatrix4fvARB)
+#define SET_UniformMatrix4fvARB(disp, fn) ((disp)->UniformMatrix4fvARB = fn)
+#define CALL_UseProgramObjectARB(disp, parameters) (*((disp)->UseProgramObjectARB)) parameters
+#define GET_UseProgramObjectARB(disp) ((disp)->UseProgramObjectARB)
+#define SET_UseProgramObjectARB(disp, fn) ((disp)->UseProgramObjectARB = fn)
+#define CALL_ValidateProgramARB(disp, parameters) (*((disp)->ValidateProgramARB)) parameters
+#define GET_ValidateProgramARB(disp) ((disp)->ValidateProgramARB)
+#define SET_ValidateProgramARB(disp, fn) ((disp)->ValidateProgramARB = fn)
+#define CALL_BindAttribLocationARB(disp, parameters) (*((disp)->BindAttribLocationARB)) parameters
+#define GET_BindAttribLocationARB(disp) ((disp)->BindAttribLocationARB)
+#define SET_BindAttribLocationARB(disp, fn) ((disp)->BindAttribLocationARB = fn)
+#define CALL_GetActiveAttribARB(disp, parameters) (*((disp)->GetActiveAttribARB)) parameters
+#define GET_GetActiveAttribARB(disp) ((disp)->GetActiveAttribARB)
+#define SET_GetActiveAttribARB(disp, fn) ((disp)->GetActiveAttribARB = fn)
+#define CALL_GetAttribLocationARB(disp, parameters) (*((disp)->GetAttribLocationARB)) parameters
+#define GET_GetAttribLocationARB(disp) ((disp)->GetAttribLocationARB)
+#define SET_GetAttribLocationARB(disp, fn) ((disp)->GetAttribLocationARB = fn)
+#define CALL_DrawBuffersARB(disp, parameters) (*((disp)->DrawBuffersARB)) parameters
+#define GET_DrawBuffersARB(disp) ((disp)->DrawBuffersARB)
+#define SET_DrawBuffersARB(disp, fn) ((disp)->DrawBuffersARB = fn)
+#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_BindVertexArray(disp, parameters) (*((disp)->BindVertexArray)) parameters
+#define GET_BindVertexArray(disp) ((disp)->BindVertexArray)
+#define SET_BindVertexArray(disp, fn) ((disp)->BindVertexArray = fn)
+#define CALL_GenVertexArrays(disp, parameters) (*((disp)->GenVertexArrays)) parameters
+#define GET_GenVertexArrays(disp) ((disp)->GenVertexArrays)
+#define SET_GenVertexArrays(disp, fn) ((disp)->GenVertexArrays = 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_ClientWaitSync(disp, parameters) (*((disp)->ClientWaitSync)) parameters
+#define GET_ClientWaitSync(disp) ((disp)->ClientWaitSync)
+#define SET_ClientWaitSync(disp, fn) ((disp)->ClientWaitSync = fn)
+#define CALL_DeleteSync(disp, parameters) (*((disp)->DeleteSync)) parameters
+#define GET_DeleteSync(disp) ((disp)->DeleteSync)
+#define SET_DeleteSync(disp, fn) ((disp)->DeleteSync = fn)
+#define CALL_FenceSync(disp, parameters) (*((disp)->FenceSync)) parameters
+#define GET_FenceSync(disp) ((disp)->FenceSync)
+#define SET_FenceSync(disp, fn) ((disp)->FenceSync = fn)
+#define CALL_GetInteger64v(disp, parameters) (*((disp)->GetInteger64v)) parameters
+#define GET_GetInteger64v(disp) ((disp)->GetInteger64v)
+#define SET_GetInteger64v(disp, fn) ((disp)->GetInteger64v = fn)
+#define CALL_GetSynciv(disp, parameters) (*((disp)->GetSynciv)) parameters
+#define GET_GetSynciv(disp) ((disp)->GetSynciv)
+#define SET_GetSynciv(disp, fn) ((disp)->GetSynciv = fn)
+#define CALL_IsSync(disp, parameters) (*((disp)->IsSync)) parameters
+#define GET_IsSync(disp) ((disp)->IsSync)
+#define SET_IsSync(disp, fn) ((disp)->IsSync = fn)
+#define CALL_WaitSync(disp, parameters) (*((disp)->WaitSync)) parameters
+#define GET_WaitSync(disp) ((disp)->WaitSync)
+#define SET_WaitSync(disp, fn) ((disp)->WaitSync = fn)
+#define CALL_DrawElementsBaseVertex(disp, parameters) (*((disp)->DrawElementsBaseVertex)) parameters
+#define GET_DrawElementsBaseVertex(disp) ((disp)->DrawElementsBaseVertex)
+#define SET_DrawElementsBaseVertex(disp, fn) ((disp)->DrawElementsBaseVertex = fn)
+#define CALL_DrawRangeElementsBaseVertex(disp, parameters) (*((disp)->DrawRangeElementsBaseVertex)) parameters
+#define GET_DrawRangeElementsBaseVertex(disp) ((disp)->DrawRangeElementsBaseVertex)
+#define SET_DrawRangeElementsBaseVertex(disp, fn) ((disp)->DrawRangeElementsBaseVertex = fn)
+#define CALL_MultiDrawElementsBaseVertex(disp, parameters) (*((disp)->MultiDrawElementsBaseVertex)) parameters
+#define GET_MultiDrawElementsBaseVertex(disp) ((disp)->MultiDrawElementsBaseVertex)
+#define SET_MultiDrawElementsBaseVertex(disp, fn) ((disp)->MultiDrawElementsBaseVertex = fn)
+#define CALL_PolygonOffsetEXT(disp, parameters) (*((disp)->PolygonOffsetEXT)) parameters
+#define GET_PolygonOffsetEXT(disp) ((disp)->PolygonOffsetEXT)
+#define SET_PolygonOffsetEXT(disp, fn) ((disp)->PolygonOffsetEXT = fn)
+#define CALL_GetPixelTexGenParameterfvSGIS(disp, parameters) (*((disp)->GetPixelTexGenParameterfvSGIS)) parameters
+#define GET_GetPixelTexGenParameterfvSGIS(disp) ((disp)->GetPixelTexGenParameterfvSGIS)
+#define SET_GetPixelTexGenParameterfvSGIS(disp, fn) ((disp)->GetPixelTexGenParameterfvSGIS = fn)
+#define CALL_GetPixelTexGenParameterivSGIS(disp, parameters) (*((disp)->GetPixelTexGenParameterivSGIS)) parameters
+#define GET_GetPixelTexGenParameterivSGIS(disp) ((disp)->GetPixelTexGenParameterivSGIS)
+#define SET_GetPixelTexGenParameterivSGIS(disp, fn) ((disp)->GetPixelTexGenParameterivSGIS = fn)
+#define CALL_PixelTexGenParameterfSGIS(disp, parameters) (*((disp)->PixelTexGenParameterfSGIS)) parameters
+#define GET_PixelTexGenParameterfSGIS(disp) ((disp)->PixelTexGenParameterfSGIS)
+#define SET_PixelTexGenParameterfSGIS(disp, fn) ((disp)->PixelTexGenParameterfSGIS = fn)
+#define CALL_PixelTexGenParameterfvSGIS(disp, parameters) (*((disp)->PixelTexGenParameterfvSGIS)) parameters
+#define GET_PixelTexGenParameterfvSGIS(disp) ((disp)->PixelTexGenParameterfvSGIS)
+#define SET_PixelTexGenParameterfvSGIS(disp, fn) ((disp)->PixelTexGenParameterfvSGIS = fn)
+#define CALL_PixelTexGenParameteriSGIS(disp, parameters) (*((disp)->PixelTexGenParameteriSGIS)) parameters
+#define GET_PixelTexGenParameteriSGIS(disp) ((disp)->PixelTexGenParameteriSGIS)
+#define SET_PixelTexGenParameteriSGIS(disp, fn) ((disp)->PixelTexGenParameteriSGIS = fn)
+#define CALL_PixelTexGenParameterivSGIS(disp, parameters) (*((disp)->PixelTexGenParameterivSGIS)) parameters
+#define GET_PixelTexGenParameterivSGIS(disp) ((disp)->PixelTexGenParameterivSGIS)
+#define SET_PixelTexGenParameterivSGIS(disp, fn) ((disp)->PixelTexGenParameterivSGIS = fn)
+#define CALL_SampleMaskSGIS(disp, parameters) (*((disp)->SampleMaskSGIS)) parameters
+#define GET_SampleMaskSGIS(disp) ((disp)->SampleMaskSGIS)
+#define SET_SampleMaskSGIS(disp, fn) ((disp)->SampleMaskSGIS = fn)
+#define CALL_SamplePatternSGIS(disp, parameters) (*((disp)->SamplePatternSGIS)) parameters
+#define GET_SamplePatternSGIS(disp) ((disp)->SamplePatternSGIS)
+#define SET_SamplePatternSGIS(disp, fn) ((disp)->SamplePatternSGIS = fn)
+#define CALL_ColorPointerEXT(disp, parameters) (*((disp)->ColorPointerEXT)) parameters
+#define GET_ColorPointerEXT(disp) ((disp)->ColorPointerEXT)
+#define SET_ColorPointerEXT(disp, fn) ((disp)->ColorPointerEXT = fn)
+#define CALL_EdgeFlagPointerEXT(disp, parameters) (*((disp)->EdgeFlagPointerEXT)) parameters
+#define GET_EdgeFlagPointerEXT(disp) ((disp)->EdgeFlagPointerEXT)
+#define SET_EdgeFlagPointerEXT(disp, fn) ((disp)->EdgeFlagPointerEXT = fn)
+#define CALL_IndexPointerEXT(disp, parameters) (*((disp)->IndexPointerEXT)) parameters
+#define GET_IndexPointerEXT(disp) ((disp)->IndexPointerEXT)
+#define SET_IndexPointerEXT(disp, fn) ((disp)->IndexPointerEXT = fn)
+#define CALL_NormalPointerEXT(disp, parameters) (*((disp)->NormalPointerEXT)) parameters
+#define GET_NormalPointerEXT(disp) ((disp)->NormalPointerEXT)
+#define SET_NormalPointerEXT(disp, fn) ((disp)->NormalPointerEXT = fn)
+#define CALL_TexCoordPointerEXT(disp, parameters) (*((disp)->TexCoordPointerEXT)) parameters
+#define GET_TexCoordPointerEXT(disp) ((disp)->TexCoordPointerEXT)
+#define SET_TexCoordPointerEXT(disp, fn) ((disp)->TexCoordPointerEXT = fn)
+#define CALL_VertexPointerEXT(disp, parameters) (*((disp)->VertexPointerEXT)) parameters
+#define GET_VertexPointerEXT(disp) ((disp)->VertexPointerEXT)
+#define SET_VertexPointerEXT(disp, fn) ((disp)->VertexPointerEXT = fn)
+#define CALL_PointParameterfEXT(disp, parameters) (*((disp)->PointParameterfEXT)) parameters
+#define GET_PointParameterfEXT(disp) ((disp)->PointParameterfEXT)
+#define SET_PointParameterfEXT(disp, fn) ((disp)->PointParameterfEXT = fn)
+#define CALL_PointParameterfvEXT(disp, parameters) (*((disp)->PointParameterfvEXT)) parameters
+#define GET_PointParameterfvEXT(disp) ((disp)->PointParameterfvEXT)
+#define SET_PointParameterfvEXT(disp, fn) ((disp)->PointParameterfvEXT = fn)
+#define CALL_LockArraysEXT(disp, parameters) (*((disp)->LockArraysEXT)) parameters
+#define GET_LockArraysEXT(disp) ((disp)->LockArraysEXT)
+#define SET_LockArraysEXT(disp, fn) ((disp)->LockArraysEXT = fn)
+#define CALL_UnlockArraysEXT(disp, parameters) (*((disp)->UnlockArraysEXT)) parameters
+#define GET_UnlockArraysEXT(disp) ((disp)->UnlockArraysEXT)
+#define SET_UnlockArraysEXT(disp, fn) ((disp)->UnlockArraysEXT = fn)
+#define CALL_CullParameterdvEXT(disp, parameters) (*((disp)->CullParameterdvEXT)) parameters
+#define GET_CullParameterdvEXT(disp) ((disp)->CullParameterdvEXT)
+#define SET_CullParameterdvEXT(disp, fn) ((disp)->CullParameterdvEXT = fn)
+#define CALL_CullParameterfvEXT(disp, parameters) (*((disp)->CullParameterfvEXT)) parameters
+#define GET_CullParameterfvEXT(disp) ((disp)->CullParameterfvEXT)
+#define SET_CullParameterfvEXT(disp, fn) ((disp)->CullParameterfvEXT = fn)
+#define CALL_SecondaryColor3bEXT(disp, parameters) (*((disp)->SecondaryColor3bEXT)) parameters
+#define GET_SecondaryColor3bEXT(disp) ((disp)->SecondaryColor3bEXT)
+#define SET_SecondaryColor3bEXT(disp, fn) ((disp)->SecondaryColor3bEXT = fn)
+#define CALL_SecondaryColor3bvEXT(disp, parameters) (*((disp)->SecondaryColor3bvEXT)) parameters
+#define GET_SecondaryColor3bvEXT(disp) ((disp)->SecondaryColor3bvEXT)
+#define SET_SecondaryColor3bvEXT(disp, fn) ((disp)->SecondaryColor3bvEXT = fn)
+#define CALL_SecondaryColor3dEXT(disp, parameters) (*((disp)->SecondaryColor3dEXT)) parameters
+#define GET_SecondaryColor3dEXT(disp) ((disp)->SecondaryColor3dEXT)
+#define SET_SecondaryColor3dEXT(disp, fn) ((disp)->SecondaryColor3dEXT = fn)
+#define CALL_SecondaryColor3dvEXT(disp, parameters) (*((disp)->SecondaryColor3dvEXT)) parameters
+#define GET_SecondaryColor3dvEXT(disp) ((disp)->SecondaryColor3dvEXT)
+#define SET_SecondaryColor3dvEXT(disp, fn) ((disp)->SecondaryColor3dvEXT = fn)
+#define CALL_SecondaryColor3fEXT(disp, parameters) (*((disp)->SecondaryColor3fEXT)) parameters
+#define GET_SecondaryColor3fEXT(disp) ((disp)->SecondaryColor3fEXT)
+#define SET_SecondaryColor3fEXT(disp, fn) ((disp)->SecondaryColor3fEXT = fn)
+#define CALL_SecondaryColor3fvEXT(disp, parameters) (*((disp)->SecondaryColor3fvEXT)) parameters
+#define GET_SecondaryColor3fvEXT(disp) ((disp)->SecondaryColor3fvEXT)
+#define SET_SecondaryColor3fvEXT(disp, fn) ((disp)->SecondaryColor3fvEXT = fn)
+#define CALL_SecondaryColor3iEXT(disp, parameters) (*((disp)->SecondaryColor3iEXT)) parameters
+#define GET_SecondaryColor3iEXT(disp) ((disp)->SecondaryColor3iEXT)
+#define SET_SecondaryColor3iEXT(disp, fn) ((disp)->SecondaryColor3iEXT = fn)
+#define CALL_SecondaryColor3ivEXT(disp, parameters) (*((disp)->SecondaryColor3ivEXT)) parameters
+#define GET_SecondaryColor3ivEXT(disp) ((disp)->SecondaryColor3ivEXT)
+#define SET_SecondaryColor3ivEXT(disp, fn) ((disp)->SecondaryColor3ivEXT = fn)
+#define CALL_SecondaryColor3sEXT(disp, parameters) (*((disp)->SecondaryColor3sEXT)) parameters
+#define GET_SecondaryColor3sEXT(disp) ((disp)->SecondaryColor3sEXT)
+#define SET_SecondaryColor3sEXT(disp, fn) ((disp)->SecondaryColor3sEXT = fn)
+#define CALL_SecondaryColor3svEXT(disp, parameters) (*((disp)->SecondaryColor3svEXT)) parameters
+#define GET_SecondaryColor3svEXT(disp) ((disp)->SecondaryColor3svEXT)
+#define SET_SecondaryColor3svEXT(disp, fn) ((disp)->SecondaryColor3svEXT = fn)
+#define CALL_SecondaryColor3ubEXT(disp, parameters) (*((disp)->SecondaryColor3ubEXT)) parameters
+#define GET_SecondaryColor3ubEXT(disp) ((disp)->SecondaryColor3ubEXT)
+#define SET_SecondaryColor3ubEXT(disp, fn) ((disp)->SecondaryColor3ubEXT = fn)
+#define CALL_SecondaryColor3ubvEXT(disp, parameters) (*((disp)->SecondaryColor3ubvEXT)) parameters
+#define GET_SecondaryColor3ubvEXT(disp) ((disp)->SecondaryColor3ubvEXT)
+#define SET_SecondaryColor3ubvEXT(disp, fn) ((disp)->SecondaryColor3ubvEXT = fn)
+#define CALL_SecondaryColor3uiEXT(disp, parameters) (*((disp)->SecondaryColor3uiEXT)) parameters
+#define GET_SecondaryColor3uiEXT(disp) ((disp)->SecondaryColor3uiEXT)
+#define SET_SecondaryColor3uiEXT(disp, fn) ((disp)->SecondaryColor3uiEXT = fn)
+#define CALL_SecondaryColor3uivEXT(disp, parameters) (*((disp)->SecondaryColor3uivEXT)) parameters
+#define GET_SecondaryColor3uivEXT(disp) ((disp)->SecondaryColor3uivEXT)
+#define SET_SecondaryColor3uivEXT(disp, fn) ((disp)->SecondaryColor3uivEXT = fn)
+#define CALL_SecondaryColor3usEXT(disp, parameters) (*((disp)->SecondaryColor3usEXT)) parameters
+#define GET_SecondaryColor3usEXT(disp) ((disp)->SecondaryColor3usEXT)
+#define SET_SecondaryColor3usEXT(disp, fn) ((disp)->SecondaryColor3usEXT = fn)
+#define CALL_SecondaryColor3usvEXT(disp, parameters) (*((disp)->SecondaryColor3usvEXT)) parameters
+#define GET_SecondaryColor3usvEXT(disp) ((disp)->SecondaryColor3usvEXT)
+#define SET_SecondaryColor3usvEXT(disp, fn) ((disp)->SecondaryColor3usvEXT = fn)
+#define CALL_SecondaryColorPointerEXT(disp, parameters) (*((disp)->SecondaryColorPointerEXT)) parameters
+#define GET_SecondaryColorPointerEXT(disp) ((disp)->SecondaryColorPointerEXT)
+#define SET_SecondaryColorPointerEXT(disp, fn) ((disp)->SecondaryColorPointerEXT = fn)
+#define CALL_MultiDrawArraysEXT(disp, parameters) (*((disp)->MultiDrawArraysEXT)) parameters
+#define GET_MultiDrawArraysEXT(disp) ((disp)->MultiDrawArraysEXT)
+#define SET_MultiDrawArraysEXT(disp, fn) ((disp)->MultiDrawArraysEXT = fn)
+#define CALL_MultiDrawElementsEXT(disp, parameters) (*((disp)->MultiDrawElementsEXT)) parameters
+#define GET_MultiDrawElementsEXT(disp) ((disp)->MultiDrawElementsEXT)
+#define SET_MultiDrawElementsEXT(disp, fn) ((disp)->MultiDrawElementsEXT = fn)
+#define CALL_FogCoordPointerEXT(disp, parameters) (*((disp)->FogCoordPointerEXT)) parameters
+#define GET_FogCoordPointerEXT(disp) ((disp)->FogCoordPointerEXT)
+#define SET_FogCoordPointerEXT(disp, fn) ((disp)->FogCoordPointerEXT = fn)
+#define CALL_FogCoorddEXT(disp, parameters) (*((disp)->FogCoorddEXT)) parameters
+#define GET_FogCoorddEXT(disp) ((disp)->FogCoorddEXT)
+#define SET_FogCoorddEXT(disp, fn) ((disp)->FogCoorddEXT = fn)
+#define CALL_FogCoorddvEXT(disp, parameters) (*((disp)->FogCoorddvEXT)) parameters
+#define GET_FogCoorddvEXT(disp) ((disp)->FogCoorddvEXT)
+#define SET_FogCoorddvEXT(disp, fn) ((disp)->FogCoorddvEXT = fn)
+#define CALL_FogCoordfEXT(disp, parameters) (*((disp)->FogCoordfEXT)) parameters
+#define GET_FogCoordfEXT(disp) ((disp)->FogCoordfEXT)
+#define SET_FogCoordfEXT(disp, fn) ((disp)->FogCoordfEXT = fn)
+#define CALL_FogCoordfvEXT(disp, parameters) (*((disp)->FogCoordfvEXT)) parameters
+#define GET_FogCoordfvEXT(disp) ((disp)->FogCoordfvEXT)
+#define SET_FogCoordfvEXT(disp, fn) ((disp)->FogCoordfvEXT = fn)
+#define CALL_PixelTexGenSGIX(disp, parameters) (*((disp)->PixelTexGenSGIX)) parameters
+#define GET_PixelTexGenSGIX(disp) ((disp)->PixelTexGenSGIX)
+#define SET_PixelTexGenSGIX(disp, fn) ((disp)->PixelTexGenSGIX = fn)
+#define CALL_BlendFuncSeparateEXT(disp, parameters) (*((disp)->BlendFuncSeparateEXT)) parameters
+#define GET_BlendFuncSeparateEXT(disp) ((disp)->BlendFuncSeparateEXT)
+#define SET_BlendFuncSeparateEXT(disp, fn) ((disp)->BlendFuncSeparateEXT = fn)
+#define CALL_FlushVertexArrayRangeNV(disp, parameters) (*((disp)->FlushVertexArrayRangeNV)) parameters
+#define GET_FlushVertexArrayRangeNV(disp) ((disp)->FlushVertexArrayRangeNV)
+#define SET_FlushVertexArrayRangeNV(disp, fn) ((disp)->FlushVertexArrayRangeNV = fn)
+#define CALL_VertexArrayRangeNV(disp, parameters) (*((disp)->VertexArrayRangeNV)) parameters
+#define GET_VertexArrayRangeNV(disp) ((disp)->VertexArrayRangeNV)
+#define SET_VertexArrayRangeNV(disp, fn) ((disp)->VertexArrayRangeNV = fn)
+#define CALL_CombinerInputNV(disp, parameters) (*((disp)->CombinerInputNV)) parameters
+#define GET_CombinerInputNV(disp) ((disp)->CombinerInputNV)
+#define SET_CombinerInputNV(disp, fn) ((disp)->CombinerInputNV = fn)
+#define CALL_CombinerOutputNV(disp, parameters) (*((disp)->CombinerOutputNV)) parameters
+#define GET_CombinerOutputNV(disp) ((disp)->CombinerOutputNV)
+#define SET_CombinerOutputNV(disp, fn) ((disp)->CombinerOutputNV = fn)
+#define CALL_CombinerParameterfNV(disp, parameters) (*((disp)->CombinerParameterfNV)) parameters
+#define GET_CombinerParameterfNV(disp) ((disp)->CombinerParameterfNV)
+#define SET_CombinerParameterfNV(disp, fn) ((disp)->CombinerParameterfNV = fn)
+#define CALL_CombinerParameterfvNV(disp, parameters) (*((disp)->CombinerParameterfvNV)) parameters
+#define GET_CombinerParameterfvNV(disp) ((disp)->CombinerParameterfvNV)
+#define SET_CombinerParameterfvNV(disp, fn) ((disp)->CombinerParameterfvNV = fn)
+#define CALL_CombinerParameteriNV(disp, parameters) (*((disp)->CombinerParameteriNV)) parameters
+#define GET_CombinerParameteriNV(disp) ((disp)->CombinerParameteriNV)
+#define SET_CombinerParameteriNV(disp, fn) ((disp)->CombinerParameteriNV = fn)
+#define CALL_CombinerParameterivNV(disp, parameters) (*((disp)->CombinerParameterivNV)) parameters
+#define GET_CombinerParameterivNV(disp) ((disp)->CombinerParameterivNV)
+#define SET_CombinerParameterivNV(disp, fn) ((disp)->CombinerParameterivNV = fn)
+#define CALL_FinalCombinerInputNV(disp, parameters) (*((disp)->FinalCombinerInputNV)) parameters
+#define GET_FinalCombinerInputNV(disp) ((disp)->FinalCombinerInputNV)
+#define SET_FinalCombinerInputNV(disp, fn) ((disp)->FinalCombinerInputNV = fn)
+#define CALL_GetCombinerInputParameterfvNV(disp, parameters) (*((disp)->GetCombinerInputParameterfvNV)) parameters
+#define GET_GetCombinerInputParameterfvNV(disp) ((disp)->GetCombinerInputParameterfvNV)
+#define SET_GetCombinerInputParameterfvNV(disp, fn) ((disp)->GetCombinerInputParameterfvNV = fn)
+#define CALL_GetCombinerInputParameterivNV(disp, parameters) (*((disp)->GetCombinerInputParameterivNV)) parameters
+#define GET_GetCombinerInputParameterivNV(disp) ((disp)->GetCombinerInputParameterivNV)
+#define SET_GetCombinerInputParameterivNV(disp, fn) ((disp)->GetCombinerInputParameterivNV = fn)
+#define CALL_GetCombinerOutputParameterfvNV(disp, parameters) (*((disp)->GetCombinerOutputParameterfvNV)) parameters
+#define GET_GetCombinerOutputParameterfvNV(disp) ((disp)->GetCombinerOutputParameterfvNV)
+#define SET_GetCombinerOutputParameterfvNV(disp, fn) ((disp)->GetCombinerOutputParameterfvNV = fn)
+#define CALL_GetCombinerOutputParameterivNV(disp, parameters) (*((disp)->GetCombinerOutputParameterivNV)) parameters
+#define GET_GetCombinerOutputParameterivNV(disp) ((disp)->GetCombinerOutputParameterivNV)
+#define SET_GetCombinerOutputParameterivNV(disp, fn) ((disp)->GetCombinerOutputParameterivNV = fn)
+#define CALL_GetFinalCombinerInputParameterfvNV(disp, parameters) (*((disp)->GetFinalCombinerInputParameterfvNV)) parameters
+#define GET_GetFinalCombinerInputParameterfvNV(disp) ((disp)->GetFinalCombinerInputParameterfvNV)
+#define SET_GetFinalCombinerInputParameterfvNV(disp, fn) ((disp)->GetFinalCombinerInputParameterfvNV = fn)
+#define CALL_GetFinalCombinerInputParameterivNV(disp, parameters) (*((disp)->GetFinalCombinerInputParameterivNV)) parameters
+#define GET_GetFinalCombinerInputParameterivNV(disp) ((disp)->GetFinalCombinerInputParameterivNV)
+#define SET_GetFinalCombinerInputParameterivNV(disp, fn) ((disp)->GetFinalCombinerInputParameterivNV = fn)
+#define CALL_ResizeBuffersMESA(disp, parameters) (*((disp)->ResizeBuffersMESA)) parameters
+#define GET_ResizeBuffersMESA(disp) ((disp)->ResizeBuffersMESA)
+#define SET_ResizeBuffersMESA(disp, fn) ((disp)->ResizeBuffersMESA = fn)
+#define CALL_WindowPos2dMESA(disp, parameters) (*((disp)->WindowPos2dMESA)) parameters
+#define GET_WindowPos2dMESA(disp) ((disp)->WindowPos2dMESA)
+#define SET_WindowPos2dMESA(disp, fn) ((disp)->WindowPos2dMESA = fn)
+#define CALL_WindowPos2dvMESA(disp, parameters) (*((disp)->WindowPos2dvMESA)) parameters
+#define GET_WindowPos2dvMESA(disp) ((disp)->WindowPos2dvMESA)
+#define SET_WindowPos2dvMESA(disp, fn) ((disp)->WindowPos2dvMESA = fn)
+#define CALL_WindowPos2fMESA(disp, parameters) (*((disp)->WindowPos2fMESA)) parameters
+#define GET_WindowPos2fMESA(disp) ((disp)->WindowPos2fMESA)
+#define SET_WindowPos2fMESA(disp, fn) ((disp)->WindowPos2fMESA = fn)
+#define CALL_WindowPos2fvMESA(disp, parameters) (*((disp)->WindowPos2fvMESA)) parameters
+#define GET_WindowPos2fvMESA(disp) ((disp)->WindowPos2fvMESA)
+#define SET_WindowPos2fvMESA(disp, fn) ((disp)->WindowPos2fvMESA = fn)
+#define CALL_WindowPos2iMESA(disp, parameters) (*((disp)->WindowPos2iMESA)) parameters
+#define GET_WindowPos2iMESA(disp) ((disp)->WindowPos2iMESA)
+#define SET_WindowPos2iMESA(disp, fn) ((disp)->WindowPos2iMESA = fn)
+#define CALL_WindowPos2ivMESA(disp, parameters) (*((disp)->WindowPos2ivMESA)) parameters
+#define GET_WindowPos2ivMESA(disp) ((disp)->WindowPos2ivMESA)
+#define SET_WindowPos2ivMESA(disp, fn) ((disp)->WindowPos2ivMESA = fn)
+#define CALL_WindowPos2sMESA(disp, parameters) (*((disp)->WindowPos2sMESA)) parameters
+#define GET_WindowPos2sMESA(disp) ((disp)->WindowPos2sMESA)
+#define SET_WindowPos2sMESA(disp, fn) ((disp)->WindowPos2sMESA = fn)
+#define CALL_WindowPos2svMESA(disp, parameters) (*((disp)->WindowPos2svMESA)) parameters
+#define GET_WindowPos2svMESA(disp) ((disp)->WindowPos2svMESA)
+#define SET_WindowPos2svMESA(disp, fn) ((disp)->WindowPos2svMESA = fn)
+#define CALL_WindowPos3dMESA(disp, parameters) (*((disp)->WindowPos3dMESA)) parameters
+#define GET_WindowPos3dMESA(disp) ((disp)->WindowPos3dMESA)
+#define SET_WindowPos3dMESA(disp, fn) ((disp)->WindowPos3dMESA = fn)
+#define CALL_WindowPos3dvMESA(disp, parameters) (*((disp)->WindowPos3dvMESA)) parameters
+#define GET_WindowPos3dvMESA(disp) ((disp)->WindowPos3dvMESA)
+#define SET_WindowPos3dvMESA(disp, fn) ((disp)->WindowPos3dvMESA = fn)
+#define CALL_WindowPos3fMESA(disp, parameters) (*((disp)->WindowPos3fMESA)) parameters
+#define GET_WindowPos3fMESA(disp) ((disp)->WindowPos3fMESA)
+#define SET_WindowPos3fMESA(disp, fn) ((disp)->WindowPos3fMESA = fn)
+#define CALL_WindowPos3fvMESA(disp, parameters) (*((disp)->WindowPos3fvMESA)) parameters
+#define GET_WindowPos3fvMESA(disp) ((disp)->WindowPos3fvMESA)
+#define SET_WindowPos3fvMESA(disp, fn) ((disp)->WindowPos3fvMESA = fn)
+#define CALL_WindowPos3iMESA(disp, parameters) (*((disp)->WindowPos3iMESA)) parameters
+#define GET_WindowPos3iMESA(disp) ((disp)->WindowPos3iMESA)
+#define SET_WindowPos3iMESA(disp, fn) ((disp)->WindowPos3iMESA = fn)
+#define CALL_WindowPos3ivMESA(disp, parameters) (*((disp)->WindowPos3ivMESA)) parameters
+#define GET_WindowPos3ivMESA(disp) ((disp)->WindowPos3ivMESA)
+#define SET_WindowPos3ivMESA(disp, fn) ((disp)->WindowPos3ivMESA = fn)
+#define CALL_WindowPos3sMESA(disp, parameters) (*((disp)->WindowPos3sMESA)) parameters
+#define GET_WindowPos3sMESA(disp) ((disp)->WindowPos3sMESA)
+#define SET_WindowPos3sMESA(disp, fn) ((disp)->WindowPos3sMESA = fn)
+#define CALL_WindowPos3svMESA(disp, parameters) (*((disp)->WindowPos3svMESA)) parameters
+#define GET_WindowPos3svMESA(disp) ((disp)->WindowPos3svMESA)
+#define SET_WindowPos3svMESA(disp, fn) ((disp)->WindowPos3svMESA = fn)
+#define CALL_WindowPos4dMESA(disp, parameters) (*((disp)->WindowPos4dMESA)) parameters
+#define GET_WindowPos4dMESA(disp) ((disp)->WindowPos4dMESA)
+#define SET_WindowPos4dMESA(disp, fn) ((disp)->WindowPos4dMESA = fn)
+#define CALL_WindowPos4dvMESA(disp, parameters) (*((disp)->WindowPos4dvMESA)) parameters
+#define GET_WindowPos4dvMESA(disp) ((disp)->WindowPos4dvMESA)
+#define SET_WindowPos4dvMESA(disp, fn) ((disp)->WindowPos4dvMESA = fn)
+#define CALL_WindowPos4fMESA(disp, parameters) (*((disp)->WindowPos4fMESA)) parameters
+#define GET_WindowPos4fMESA(disp) ((disp)->WindowPos4fMESA)
+#define SET_WindowPos4fMESA(disp, fn) ((disp)->WindowPos4fMESA = fn)
+#define CALL_WindowPos4fvMESA(disp, parameters) (*((disp)->WindowPos4fvMESA)) parameters
+#define GET_WindowPos4fvMESA(disp) ((disp)->WindowPos4fvMESA)
+#define SET_WindowPos4fvMESA(disp, fn) ((disp)->WindowPos4fvMESA = fn)
+#define CALL_WindowPos4iMESA(disp, parameters) (*((disp)->WindowPos4iMESA)) parameters
+#define GET_WindowPos4iMESA(disp) ((disp)->WindowPos4iMESA)
+#define SET_WindowPos4iMESA(disp, fn) ((disp)->WindowPos4iMESA = fn)
+#define CALL_WindowPos4ivMESA(disp, parameters) (*((disp)->WindowPos4ivMESA)) parameters
+#define GET_WindowPos4ivMESA(disp) ((disp)->WindowPos4ivMESA)
+#define SET_WindowPos4ivMESA(disp, fn) ((disp)->WindowPos4ivMESA = fn)
+#define CALL_WindowPos4sMESA(disp, parameters) (*((disp)->WindowPos4sMESA)) parameters
+#define GET_WindowPos4sMESA(disp) ((disp)->WindowPos4sMESA)
+#define SET_WindowPos4sMESA(disp, fn) ((disp)->WindowPos4sMESA = fn)
+#define CALL_WindowPos4svMESA(disp, parameters) (*((disp)->WindowPos4svMESA)) parameters
+#define GET_WindowPos4svMESA(disp) ((disp)->WindowPos4svMESA)
+#define SET_WindowPos4svMESA(disp, fn) ((disp)->WindowPos4svMESA = fn)
+#define CALL_MultiModeDrawArraysIBM(disp, parameters) (*((disp)->MultiModeDrawArraysIBM)) parameters
+#define GET_MultiModeDrawArraysIBM(disp) ((disp)->MultiModeDrawArraysIBM)
+#define SET_MultiModeDrawArraysIBM(disp, fn) ((disp)->MultiModeDrawArraysIBM = fn)
+#define CALL_MultiModeDrawElementsIBM(disp, parameters) (*((disp)->MultiModeDrawElementsIBM)) parameters
+#define GET_MultiModeDrawElementsIBM(disp) ((disp)->MultiModeDrawElementsIBM)
+#define SET_MultiModeDrawElementsIBM(disp, fn) ((disp)->MultiModeDrawElementsIBM = fn)
+#define CALL_DeleteFencesNV(disp, parameters) (*((disp)->DeleteFencesNV)) parameters
+#define GET_DeleteFencesNV(disp) ((disp)->DeleteFencesNV)
+#define SET_DeleteFencesNV(disp, fn) ((disp)->DeleteFencesNV = fn)
+#define CALL_FinishFenceNV(disp, parameters) (*((disp)->FinishFenceNV)) parameters
+#define GET_FinishFenceNV(disp) ((disp)->FinishFenceNV)
+#define SET_FinishFenceNV(disp, fn) ((disp)->FinishFenceNV = fn)
+#define CALL_GenFencesNV(disp, parameters) (*((disp)->GenFencesNV)) parameters
+#define GET_GenFencesNV(disp) ((disp)->GenFencesNV)
+#define SET_GenFencesNV(disp, fn) ((disp)->GenFencesNV = fn)
+#define CALL_GetFenceivNV(disp, parameters) (*((disp)->GetFenceivNV)) parameters
+#define GET_GetFenceivNV(disp) ((disp)->GetFenceivNV)
+#define SET_GetFenceivNV(disp, fn) ((disp)->GetFenceivNV = fn)
+#define CALL_IsFenceNV(disp, parameters) (*((disp)->IsFenceNV)) parameters
+#define GET_IsFenceNV(disp) ((disp)->IsFenceNV)
+#define SET_IsFenceNV(disp, fn) ((disp)->IsFenceNV = fn)
+#define CALL_SetFenceNV(disp, parameters) (*((disp)->SetFenceNV)) parameters
+#define GET_SetFenceNV(disp) ((disp)->SetFenceNV)
+#define SET_SetFenceNV(disp, fn) ((disp)->SetFenceNV = fn)
+#define CALL_TestFenceNV(disp, parameters) (*((disp)->TestFenceNV)) parameters
+#define GET_TestFenceNV(disp) ((disp)->TestFenceNV)
+#define SET_TestFenceNV(disp, fn) ((disp)->TestFenceNV = fn)
+#define CALL_AreProgramsResidentNV(disp, parameters) (*((disp)->AreProgramsResidentNV)) parameters
+#define GET_AreProgramsResidentNV(disp) ((disp)->AreProgramsResidentNV)
+#define SET_AreProgramsResidentNV(disp, fn) ((disp)->AreProgramsResidentNV = fn)
+#define CALL_BindProgramNV(disp, parameters) (*((disp)->BindProgramNV)) parameters
+#define GET_BindProgramNV(disp) ((disp)->BindProgramNV)
+#define SET_BindProgramNV(disp, fn) ((disp)->BindProgramNV = fn)
+#define CALL_DeleteProgramsNV(disp, parameters) (*((disp)->DeleteProgramsNV)) parameters
+#define GET_DeleteProgramsNV(disp) ((disp)->DeleteProgramsNV)
+#define SET_DeleteProgramsNV(disp, fn) ((disp)->DeleteProgramsNV = fn)
+#define CALL_ExecuteProgramNV(disp, parameters) (*((disp)->ExecuteProgramNV)) parameters
+#define GET_ExecuteProgramNV(disp) ((disp)->ExecuteProgramNV)
+#define SET_ExecuteProgramNV(disp, fn) ((disp)->ExecuteProgramNV = fn)
+#define CALL_GenProgramsNV(disp, parameters) (*((disp)->GenProgramsNV)) parameters
+#define GET_GenProgramsNV(disp) ((disp)->GenProgramsNV)
+#define SET_GenProgramsNV(disp, fn) ((disp)->GenProgramsNV = fn)
+#define CALL_GetProgramParameterdvNV(disp, parameters) (*((disp)->GetProgramParameterdvNV)) parameters
+#define GET_GetProgramParameterdvNV(disp) ((disp)->GetProgramParameterdvNV)
+#define SET_GetProgramParameterdvNV(disp, fn) ((disp)->GetProgramParameterdvNV = fn)
+#define CALL_GetProgramParameterfvNV(disp, parameters) (*((disp)->GetProgramParameterfvNV)) parameters
+#define GET_GetProgramParameterfvNV(disp) ((disp)->GetProgramParameterfvNV)
+#define SET_GetProgramParameterfvNV(disp, fn) ((disp)->GetProgramParameterfvNV = fn)
+#define CALL_GetProgramStringNV(disp, parameters) (*((disp)->GetProgramStringNV)) parameters
+#define GET_GetProgramStringNV(disp) ((disp)->GetProgramStringNV)
+#define SET_GetProgramStringNV(disp, fn) ((disp)->GetProgramStringNV = fn)
+#define CALL_GetProgramivNV(disp, parameters) (*((disp)->GetProgramivNV)) parameters
+#define GET_GetProgramivNV(disp) ((disp)->GetProgramivNV)
+#define SET_GetProgramivNV(disp, fn) ((disp)->GetProgramivNV = fn)
+#define CALL_GetTrackMatrixivNV(disp, parameters) (*((disp)->GetTrackMatrixivNV)) parameters
+#define GET_GetTrackMatrixivNV(disp) ((disp)->GetTrackMatrixivNV)
+#define SET_GetTrackMatrixivNV(disp, fn) ((disp)->GetTrackMatrixivNV = fn)
+#define CALL_GetVertexAttribPointervNV(disp, parameters) (*((disp)->GetVertexAttribPointervNV)) parameters
+#define GET_GetVertexAttribPointervNV(disp) ((disp)->GetVertexAttribPointervNV)
+#define SET_GetVertexAttribPointervNV(disp, fn) ((disp)->GetVertexAttribPointervNV = fn)
+#define CALL_GetVertexAttribdvNV(disp, parameters) (*((disp)->GetVertexAttribdvNV)) parameters
+#define GET_GetVertexAttribdvNV(disp) ((disp)->GetVertexAttribdvNV)
+#define SET_GetVertexAttribdvNV(disp, fn) ((disp)->GetVertexAttribdvNV = fn)
+#define CALL_GetVertexAttribfvNV(disp, parameters) (*((disp)->GetVertexAttribfvNV)) parameters
+#define GET_GetVertexAttribfvNV(disp) ((disp)->GetVertexAttribfvNV)
+#define SET_GetVertexAttribfvNV(disp, fn) ((disp)->GetVertexAttribfvNV = fn)
+#define CALL_GetVertexAttribivNV(disp, parameters) (*((disp)->GetVertexAttribivNV)) parameters
+#define GET_GetVertexAttribivNV(disp) ((disp)->GetVertexAttribivNV)
+#define SET_GetVertexAttribivNV(disp, fn) ((disp)->GetVertexAttribivNV = fn)
+#define CALL_IsProgramNV(disp, parameters) (*((disp)->IsProgramNV)) parameters
+#define GET_IsProgramNV(disp) ((disp)->IsProgramNV)
+#define SET_IsProgramNV(disp, fn) ((disp)->IsProgramNV = fn)
+#define CALL_LoadProgramNV(disp, parameters) (*((disp)->LoadProgramNV)) parameters
+#define GET_LoadProgramNV(disp) ((disp)->LoadProgramNV)
+#define SET_LoadProgramNV(disp, fn) ((disp)->LoadProgramNV = fn)
+#define CALL_ProgramParameters4dvNV(disp, parameters) (*((disp)->ProgramParameters4dvNV)) parameters
+#define GET_ProgramParameters4dvNV(disp) ((disp)->ProgramParameters4dvNV)
+#define SET_ProgramParameters4dvNV(disp, fn) ((disp)->ProgramParameters4dvNV = fn)
+#define CALL_ProgramParameters4fvNV(disp, parameters) (*((disp)->ProgramParameters4fvNV)) parameters
+#define GET_ProgramParameters4fvNV(disp) ((disp)->ProgramParameters4fvNV)
+#define SET_ProgramParameters4fvNV(disp, fn) ((disp)->ProgramParameters4fvNV = fn)
+#define CALL_RequestResidentProgramsNV(disp, parameters) (*((disp)->RequestResidentProgramsNV)) parameters
+#define GET_RequestResidentProgramsNV(disp) ((disp)->RequestResidentProgramsNV)
+#define SET_RequestResidentProgramsNV(disp, fn) ((disp)->RequestResidentProgramsNV = fn)
+#define CALL_TrackMatrixNV(disp, parameters) (*((disp)->TrackMatrixNV)) parameters
+#define GET_TrackMatrixNV(disp) ((disp)->TrackMatrixNV)
+#define SET_TrackMatrixNV(disp, fn) ((disp)->TrackMatrixNV = fn)
+#define CALL_VertexAttrib1dNV(disp, parameters) (*((disp)->VertexAttrib1dNV)) parameters
+#define GET_VertexAttrib1dNV(disp) ((disp)->VertexAttrib1dNV)
+#define SET_VertexAttrib1dNV(disp, fn) ((disp)->VertexAttrib1dNV = fn)
+#define CALL_VertexAttrib1dvNV(disp, parameters) (*((disp)->VertexAttrib1dvNV)) parameters
+#define GET_VertexAttrib1dvNV(disp) ((disp)->VertexAttrib1dvNV)
+#define SET_VertexAttrib1dvNV(disp, fn) ((disp)->VertexAttrib1dvNV = fn)
+#define CALL_VertexAttrib1fNV(disp, parameters) (*((disp)->VertexAttrib1fNV)) parameters
+#define GET_VertexAttrib1fNV(disp) ((disp)->VertexAttrib1fNV)
+#define SET_VertexAttrib1fNV(disp, fn) ((disp)->VertexAttrib1fNV = fn)
+#define CALL_VertexAttrib1fvNV(disp, parameters) (*((disp)->VertexAttrib1fvNV)) parameters
+#define GET_VertexAttrib1fvNV(disp) ((disp)->VertexAttrib1fvNV)
+#define SET_VertexAttrib1fvNV(disp, fn) ((disp)->VertexAttrib1fvNV = fn)
+#define CALL_VertexAttrib1sNV(disp, parameters) (*((disp)->VertexAttrib1sNV)) parameters
+#define GET_VertexAttrib1sNV(disp) ((disp)->VertexAttrib1sNV)
+#define SET_VertexAttrib1sNV(disp, fn) ((disp)->VertexAttrib1sNV = fn)
+#define CALL_VertexAttrib1svNV(disp, parameters) (*((disp)->VertexAttrib1svNV)) parameters
+#define GET_VertexAttrib1svNV(disp) ((disp)->VertexAttrib1svNV)
+#define SET_VertexAttrib1svNV(disp, fn) ((disp)->VertexAttrib1svNV = fn)
+#define CALL_VertexAttrib2dNV(disp, parameters) (*((disp)->VertexAttrib2dNV)) parameters
+#define GET_VertexAttrib2dNV(disp) ((disp)->VertexAttrib2dNV)
+#define SET_VertexAttrib2dNV(disp, fn) ((disp)->VertexAttrib2dNV = fn)
+#define CALL_VertexAttrib2dvNV(disp, parameters) (*((disp)->VertexAttrib2dvNV)) parameters
+#define GET_VertexAttrib2dvNV(disp) ((disp)->VertexAttrib2dvNV)
+#define SET_VertexAttrib2dvNV(disp, fn) ((disp)->VertexAttrib2dvNV = fn)
+#define CALL_VertexAttrib2fNV(disp, parameters) (*((disp)->VertexAttrib2fNV)) parameters
+#define GET_VertexAttrib2fNV(disp) ((disp)->VertexAttrib2fNV)
+#define SET_VertexAttrib2fNV(disp, fn) ((disp)->VertexAttrib2fNV = fn)
+#define CALL_VertexAttrib2fvNV(disp, parameters) (*((disp)->VertexAttrib2fvNV)) parameters
+#define GET_VertexAttrib2fvNV(disp) ((disp)->VertexAttrib2fvNV)
+#define SET_VertexAttrib2fvNV(disp, fn) ((disp)->VertexAttrib2fvNV = fn)
+#define CALL_VertexAttrib2sNV(disp, parameters) (*((disp)->VertexAttrib2sNV)) parameters
+#define GET_VertexAttrib2sNV(disp) ((disp)->VertexAttrib2sNV)
+#define SET_VertexAttrib2sNV(disp, fn) ((disp)->VertexAttrib2sNV = fn)
+#define CALL_VertexAttrib2svNV(disp, parameters) (*((disp)->VertexAttrib2svNV)) parameters
+#define GET_VertexAttrib2svNV(disp) ((disp)->VertexAttrib2svNV)
+#define SET_VertexAttrib2svNV(disp, fn) ((disp)->VertexAttrib2svNV = fn)
+#define CALL_VertexAttrib3dNV(disp, parameters) (*((disp)->VertexAttrib3dNV)) parameters
+#define GET_VertexAttrib3dNV(disp) ((disp)->VertexAttrib3dNV)
+#define SET_VertexAttrib3dNV(disp, fn) ((disp)->VertexAttrib3dNV = fn)
+#define CALL_VertexAttrib3dvNV(disp, parameters) (*((disp)->VertexAttrib3dvNV)) parameters
+#define GET_VertexAttrib3dvNV(disp) ((disp)->VertexAttrib3dvNV)
+#define SET_VertexAttrib3dvNV(disp, fn) ((disp)->VertexAttrib3dvNV = fn)
+#define CALL_VertexAttrib3fNV(disp, parameters) (*((disp)->VertexAttrib3fNV)) parameters
+#define GET_VertexAttrib3fNV(disp) ((disp)->VertexAttrib3fNV)
+#define SET_VertexAttrib3fNV(disp, fn) ((disp)->VertexAttrib3fNV = fn)
+#define CALL_VertexAttrib3fvNV(disp, parameters) (*((disp)->VertexAttrib3fvNV)) parameters
+#define GET_VertexAttrib3fvNV(disp) ((disp)->VertexAttrib3fvNV)
+#define SET_VertexAttrib3fvNV(disp, fn) ((disp)->VertexAttrib3fvNV = fn)
+#define CALL_VertexAttrib3sNV(disp, parameters) (*((disp)->VertexAttrib3sNV)) parameters
+#define GET_VertexAttrib3sNV(disp) ((disp)->VertexAttrib3sNV)
+#define SET_VertexAttrib3sNV(disp, fn) ((disp)->VertexAttrib3sNV = fn)
+#define CALL_VertexAttrib3svNV(disp, parameters) (*((disp)->VertexAttrib3svNV)) parameters
+#define GET_VertexAttrib3svNV(disp) ((disp)->VertexAttrib3svNV)
+#define SET_VertexAttrib3svNV(disp, fn) ((disp)->VertexAttrib3svNV = fn)
+#define CALL_VertexAttrib4dNV(disp, parameters) (*((disp)->VertexAttrib4dNV)) parameters
+#define GET_VertexAttrib4dNV(disp) ((disp)->VertexAttrib4dNV)
+#define SET_VertexAttrib4dNV(disp, fn) ((disp)->VertexAttrib4dNV = fn)
+#define CALL_VertexAttrib4dvNV(disp, parameters) (*((disp)->VertexAttrib4dvNV)) parameters
+#define GET_VertexAttrib4dvNV(disp) ((disp)->VertexAttrib4dvNV)
+#define SET_VertexAttrib4dvNV(disp, fn) ((disp)->VertexAttrib4dvNV = fn)
+#define CALL_VertexAttrib4fNV(disp, parameters) (*((disp)->VertexAttrib4fNV)) parameters
+#define GET_VertexAttrib4fNV(disp) ((disp)->VertexAttrib4fNV)
+#define SET_VertexAttrib4fNV(disp, fn) ((disp)->VertexAttrib4fNV = fn)
+#define CALL_VertexAttrib4fvNV(disp, parameters) (*((disp)->VertexAttrib4fvNV)) parameters
+#define GET_VertexAttrib4fvNV(disp) ((disp)->VertexAttrib4fvNV)
+#define SET_VertexAttrib4fvNV(disp, fn) ((disp)->VertexAttrib4fvNV = fn)
+#define CALL_VertexAttrib4sNV(disp, parameters) (*((disp)->VertexAttrib4sNV)) parameters
+#define GET_VertexAttrib4sNV(disp) ((disp)->VertexAttrib4sNV)
+#define SET_VertexAttrib4sNV(disp, fn) ((disp)->VertexAttrib4sNV = fn)
+#define CALL_VertexAttrib4svNV(disp, parameters) (*((disp)->VertexAttrib4svNV)) parameters
+#define GET_VertexAttrib4svNV(disp) ((disp)->VertexAttrib4svNV)
+#define SET_VertexAttrib4svNV(disp, fn) ((disp)->VertexAttrib4svNV = fn)
+#define CALL_VertexAttrib4ubNV(disp, parameters) (*((disp)->VertexAttrib4ubNV)) parameters
+#define GET_VertexAttrib4ubNV(disp) ((disp)->VertexAttrib4ubNV)
+#define SET_VertexAttrib4ubNV(disp, fn) ((disp)->VertexAttrib4ubNV = fn)
+#define CALL_VertexAttrib4ubvNV(disp, parameters) (*((disp)->VertexAttrib4ubvNV)) parameters
+#define GET_VertexAttrib4ubvNV(disp) ((disp)->VertexAttrib4ubvNV)
+#define SET_VertexAttrib4ubvNV(disp, fn) ((disp)->VertexAttrib4ubvNV = fn)
+#define CALL_VertexAttribPointerNV(disp, parameters) (*((disp)->VertexAttribPointerNV)) parameters
+#define GET_VertexAttribPointerNV(disp) ((disp)->VertexAttribPointerNV)
+#define SET_VertexAttribPointerNV(disp, fn) ((disp)->VertexAttribPointerNV = fn)
+#define CALL_VertexAttribs1dvNV(disp, parameters) (*((disp)->VertexAttribs1dvNV)) parameters
+#define GET_VertexAttribs1dvNV(disp) ((disp)->VertexAttribs1dvNV)
+#define SET_VertexAttribs1dvNV(disp, fn) ((disp)->VertexAttribs1dvNV = fn)
+#define CALL_VertexAttribs1fvNV(disp, parameters) (*((disp)->VertexAttribs1fvNV)) parameters
+#define GET_VertexAttribs1fvNV(disp) ((disp)->VertexAttribs1fvNV)
+#define SET_VertexAttribs1fvNV(disp, fn) ((disp)->VertexAttribs1fvNV = fn)
+#define CALL_VertexAttribs1svNV(disp, parameters) (*((disp)->VertexAttribs1svNV)) parameters
+#define GET_VertexAttribs1svNV(disp) ((disp)->VertexAttribs1svNV)
+#define SET_VertexAttribs1svNV(disp, fn) ((disp)->VertexAttribs1svNV = fn)
+#define CALL_VertexAttribs2dvNV(disp, parameters) (*((disp)->VertexAttribs2dvNV)) parameters
+#define GET_VertexAttribs2dvNV(disp) ((disp)->VertexAttribs2dvNV)
+#define SET_VertexAttribs2dvNV(disp, fn) ((disp)->VertexAttribs2dvNV = fn)
+#define CALL_VertexAttribs2fvNV(disp, parameters) (*((disp)->VertexAttribs2fvNV)) parameters
+#define GET_VertexAttribs2fvNV(disp) ((disp)->VertexAttribs2fvNV)
+#define SET_VertexAttribs2fvNV(disp, fn) ((disp)->VertexAttribs2fvNV = fn)
+#define CALL_VertexAttribs2svNV(disp, parameters) (*((disp)->VertexAttribs2svNV)) parameters
+#define GET_VertexAttribs2svNV(disp) ((disp)->VertexAttribs2svNV)
+#define SET_VertexAttribs2svNV(disp, fn) ((disp)->VertexAttribs2svNV = fn)
+#define CALL_VertexAttribs3dvNV(disp, parameters) (*((disp)->VertexAttribs3dvNV)) parameters
+#define GET_VertexAttribs3dvNV(disp) ((disp)->VertexAttribs3dvNV)
+#define SET_VertexAttribs3dvNV(disp, fn) ((disp)->VertexAttribs3dvNV = fn)
+#define CALL_VertexAttribs3fvNV(disp, parameters) (*((disp)->VertexAttribs3fvNV)) parameters
+#define GET_VertexAttribs3fvNV(disp) ((disp)->VertexAttribs3fvNV)
+#define SET_VertexAttribs3fvNV(disp, fn) ((disp)->VertexAttribs3fvNV = fn)
+#define CALL_VertexAttribs3svNV(disp, parameters) (*((disp)->VertexAttribs3svNV)) parameters
+#define GET_VertexAttribs3svNV(disp) ((disp)->VertexAttribs3svNV)
+#define SET_VertexAttribs3svNV(disp, fn) ((disp)->VertexAttribs3svNV = fn)
+#define CALL_VertexAttribs4dvNV(disp, parameters) (*((disp)->VertexAttribs4dvNV)) parameters
+#define GET_VertexAttribs4dvNV(disp) ((disp)->VertexAttribs4dvNV)
+#define SET_VertexAttribs4dvNV(disp, fn) ((disp)->VertexAttribs4dvNV = fn)
+#define CALL_VertexAttribs4fvNV(disp, parameters) (*((disp)->VertexAttribs4fvNV)) parameters
+#define GET_VertexAttribs4fvNV(disp) ((disp)->VertexAttribs4fvNV)
+#define SET_VertexAttribs4fvNV(disp, fn) ((disp)->VertexAttribs4fvNV = fn)
+#define CALL_VertexAttribs4svNV(disp, parameters) (*((disp)->VertexAttribs4svNV)) parameters
+#define GET_VertexAttribs4svNV(disp) ((disp)->VertexAttribs4svNV)
+#define SET_VertexAttribs4svNV(disp, fn) ((disp)->VertexAttribs4svNV = fn)
+#define CALL_VertexAttribs4ubvNV(disp, parameters) (*((disp)->VertexAttribs4ubvNV)) parameters
+#define GET_VertexAttribs4ubvNV(disp) ((disp)->VertexAttribs4ubvNV)
+#define SET_VertexAttribs4ubvNV(disp, fn) ((disp)->VertexAttribs4ubvNV = fn)
+#define CALL_GetTexBumpParameterfvATI(disp, parameters) (*((disp)->GetTexBumpParameterfvATI)) parameters
+#define GET_GetTexBumpParameterfvATI(disp) ((disp)->GetTexBumpParameterfvATI)
+#define SET_GetTexBumpParameterfvATI(disp, fn) ((disp)->GetTexBumpParameterfvATI = fn)
+#define CALL_GetTexBumpParameterivATI(disp, parameters) (*((disp)->GetTexBumpParameterivATI)) parameters
+#define GET_GetTexBumpParameterivATI(disp) ((disp)->GetTexBumpParameterivATI)
+#define SET_GetTexBumpParameterivATI(disp, fn) ((disp)->GetTexBumpParameterivATI = fn)
+#define CALL_TexBumpParameterfvATI(disp, parameters) (*((disp)->TexBumpParameterfvATI)) parameters
+#define GET_TexBumpParameterfvATI(disp) ((disp)->TexBumpParameterfvATI)
+#define SET_TexBumpParameterfvATI(disp, fn) ((disp)->TexBumpParameterfvATI = fn)
+#define CALL_TexBumpParameterivATI(disp, parameters) (*((disp)->TexBumpParameterivATI)) parameters
+#define GET_TexBumpParameterivATI(disp) ((disp)->TexBumpParameterivATI)
+#define SET_TexBumpParameterivATI(disp, fn) ((disp)->TexBumpParameterivATI = fn)
+#define CALL_AlphaFragmentOp1ATI(disp, parameters) (*((disp)->AlphaFragmentOp1ATI)) parameters
+#define GET_AlphaFragmentOp1ATI(disp) ((disp)->AlphaFragmentOp1ATI)
+#define SET_AlphaFragmentOp1ATI(disp, fn) ((disp)->AlphaFragmentOp1ATI = fn)
+#define CALL_AlphaFragmentOp2ATI(disp, parameters) (*((disp)->AlphaFragmentOp2ATI)) parameters
+#define GET_AlphaFragmentOp2ATI(disp) ((disp)->AlphaFragmentOp2ATI)
+#define SET_AlphaFragmentOp2ATI(disp, fn) ((disp)->AlphaFragmentOp2ATI = fn)
+#define CALL_AlphaFragmentOp3ATI(disp, parameters) (*((disp)->AlphaFragmentOp3ATI)) parameters
+#define GET_AlphaFragmentOp3ATI(disp) ((disp)->AlphaFragmentOp3ATI)
+#define SET_AlphaFragmentOp3ATI(disp, fn) ((disp)->AlphaFragmentOp3ATI = fn)
+#define CALL_BeginFragmentShaderATI(disp, parameters) (*((disp)->BeginFragmentShaderATI)) parameters
+#define GET_BeginFragmentShaderATI(disp) ((disp)->BeginFragmentShaderATI)
+#define SET_BeginFragmentShaderATI(disp, fn) ((disp)->BeginFragmentShaderATI = fn)
+#define CALL_BindFragmentShaderATI(disp, parameters) (*((disp)->BindFragmentShaderATI)) parameters
+#define GET_BindFragmentShaderATI(disp) ((disp)->BindFragmentShaderATI)
+#define SET_BindFragmentShaderATI(disp, fn) ((disp)->BindFragmentShaderATI = fn)
+#define CALL_ColorFragmentOp1ATI(disp, parameters) (*((disp)->ColorFragmentOp1ATI)) parameters
+#define GET_ColorFragmentOp1ATI(disp) ((disp)->ColorFragmentOp1ATI)
+#define SET_ColorFragmentOp1ATI(disp, fn) ((disp)->ColorFragmentOp1ATI = fn)
+#define CALL_ColorFragmentOp2ATI(disp, parameters) (*((disp)->ColorFragmentOp2ATI)) parameters
+#define GET_ColorFragmentOp2ATI(disp) ((disp)->ColorFragmentOp2ATI)
+#define SET_ColorFragmentOp2ATI(disp, fn) ((disp)->ColorFragmentOp2ATI = fn)
+#define CALL_ColorFragmentOp3ATI(disp, parameters) (*((disp)->ColorFragmentOp3ATI)) parameters
+#define GET_ColorFragmentOp3ATI(disp) ((disp)->ColorFragmentOp3ATI)
+#define SET_ColorFragmentOp3ATI(disp, fn) ((disp)->ColorFragmentOp3ATI = fn)
+#define CALL_DeleteFragmentShaderATI(disp, parameters) (*((disp)->DeleteFragmentShaderATI)) parameters
+#define GET_DeleteFragmentShaderATI(disp) ((disp)->DeleteFragmentShaderATI)
+#define SET_DeleteFragmentShaderATI(disp, fn) ((disp)->DeleteFragmentShaderATI = fn)
+#define CALL_EndFragmentShaderATI(disp, parameters) (*((disp)->EndFragmentShaderATI)) parameters
+#define GET_EndFragmentShaderATI(disp) ((disp)->EndFragmentShaderATI)
+#define SET_EndFragmentShaderATI(disp, fn) ((disp)->EndFragmentShaderATI = fn)
+#define CALL_GenFragmentShadersATI(disp, parameters) (*((disp)->GenFragmentShadersATI)) parameters
+#define GET_GenFragmentShadersATI(disp) ((disp)->GenFragmentShadersATI)
+#define SET_GenFragmentShadersATI(disp, fn) ((disp)->GenFragmentShadersATI = fn)
+#define CALL_PassTexCoordATI(disp, parameters) (*((disp)->PassTexCoordATI)) parameters
+#define GET_PassTexCoordATI(disp) ((disp)->PassTexCoordATI)
+#define SET_PassTexCoordATI(disp, fn) ((disp)->PassTexCoordATI = fn)
+#define CALL_SampleMapATI(disp, parameters) (*((disp)->SampleMapATI)) parameters
+#define GET_SampleMapATI(disp) ((disp)->SampleMapATI)
+#define SET_SampleMapATI(disp, fn) ((disp)->SampleMapATI = fn)
+#define CALL_SetFragmentShaderConstantATI(disp, parameters) (*((disp)->SetFragmentShaderConstantATI)) parameters
+#define GET_SetFragmentShaderConstantATI(disp) ((disp)->SetFragmentShaderConstantATI)
+#define SET_SetFragmentShaderConstantATI(disp, fn) ((disp)->SetFragmentShaderConstantATI = fn)
+#define CALL_PointParameteriNV(disp, parameters) (*((disp)->PointParameteriNV)) parameters
+#define GET_PointParameteriNV(disp) ((disp)->PointParameteriNV)
+#define SET_PointParameteriNV(disp, fn) ((disp)->PointParameteriNV = fn)
+#define CALL_PointParameterivNV(disp, parameters) (*((disp)->PointParameterivNV)) parameters
+#define GET_PointParameterivNV(disp) ((disp)->PointParameterivNV)
+#define SET_PointParameterivNV(disp, fn) ((disp)->PointParameterivNV = fn)
+#define CALL_ActiveStencilFaceEXT(disp, parameters) (*((disp)->ActiveStencilFaceEXT)) parameters
+#define GET_ActiveStencilFaceEXT(disp) ((disp)->ActiveStencilFaceEXT)
+#define SET_ActiveStencilFaceEXT(disp, fn) ((disp)->ActiveStencilFaceEXT = fn)
+#define CALL_BindVertexArrayAPPLE(disp, parameters) (*((disp)->BindVertexArrayAPPLE)) parameters
+#define GET_BindVertexArrayAPPLE(disp) ((disp)->BindVertexArrayAPPLE)
+#define SET_BindVertexArrayAPPLE(disp, fn) ((disp)->BindVertexArrayAPPLE = fn)
+#define CALL_DeleteVertexArraysAPPLE(disp, parameters) (*((disp)->DeleteVertexArraysAPPLE)) parameters
+#define GET_DeleteVertexArraysAPPLE(disp) ((disp)->DeleteVertexArraysAPPLE)
+#define SET_DeleteVertexArraysAPPLE(disp, fn) ((disp)->DeleteVertexArraysAPPLE = fn)
+#define CALL_GenVertexArraysAPPLE(disp, parameters) (*((disp)->GenVertexArraysAPPLE)) parameters
+#define GET_GenVertexArraysAPPLE(disp) ((disp)->GenVertexArraysAPPLE)
+#define SET_GenVertexArraysAPPLE(disp, fn) ((disp)->GenVertexArraysAPPLE = fn)
+#define CALL_IsVertexArrayAPPLE(disp, parameters) (*((disp)->IsVertexArrayAPPLE)) parameters
+#define GET_IsVertexArrayAPPLE(disp) ((disp)->IsVertexArrayAPPLE)
+#define SET_IsVertexArrayAPPLE(disp, fn) ((disp)->IsVertexArrayAPPLE = fn)
+#define CALL_GetProgramNamedParameterdvNV(disp, parameters) (*((disp)->GetProgramNamedParameterdvNV)) parameters
+#define GET_GetProgramNamedParameterdvNV(disp) ((disp)->GetProgramNamedParameterdvNV)
+#define SET_GetProgramNamedParameterdvNV(disp, fn) ((disp)->GetProgramNamedParameterdvNV = fn)
+#define CALL_GetProgramNamedParameterfvNV(disp, parameters) (*((disp)->GetProgramNamedParameterfvNV)) parameters
+#define GET_GetProgramNamedParameterfvNV(disp) ((disp)->GetProgramNamedParameterfvNV)
+#define SET_GetProgramNamedParameterfvNV(disp, fn) ((disp)->GetProgramNamedParameterfvNV = fn)
+#define CALL_ProgramNamedParameter4dNV(disp, parameters) (*((disp)->ProgramNamedParameter4dNV)) parameters
+#define GET_ProgramNamedParameter4dNV(disp) ((disp)->ProgramNamedParameter4dNV)
+#define SET_ProgramNamedParameter4dNV(disp, fn) ((disp)->ProgramNamedParameter4dNV = fn)
+#define CALL_ProgramNamedParameter4dvNV(disp, parameters) (*((disp)->ProgramNamedParameter4dvNV)) parameters
+#define GET_ProgramNamedParameter4dvNV(disp) ((disp)->ProgramNamedParameter4dvNV)
+#define SET_ProgramNamedParameter4dvNV(disp, fn) ((disp)->ProgramNamedParameter4dvNV = fn)
+#define CALL_ProgramNamedParameter4fNV(disp, parameters) (*((disp)->ProgramNamedParameter4fNV)) parameters
+#define GET_ProgramNamedParameter4fNV(disp) ((disp)->ProgramNamedParameter4fNV)
+#define SET_ProgramNamedParameter4fNV(disp, fn) ((disp)->ProgramNamedParameter4fNV = fn)
+#define CALL_ProgramNamedParameter4fvNV(disp, parameters) (*((disp)->ProgramNamedParameter4fvNV)) parameters
+#define GET_ProgramNamedParameter4fvNV(disp) ((disp)->ProgramNamedParameter4fvNV)
+#define SET_ProgramNamedParameter4fvNV(disp, fn) ((disp)->ProgramNamedParameter4fvNV = fn)
+#define CALL_DepthBoundsEXT(disp, parameters) (*((disp)->DepthBoundsEXT)) parameters
+#define GET_DepthBoundsEXT(disp) ((disp)->DepthBoundsEXT)
+#define SET_DepthBoundsEXT(disp, fn) ((disp)->DepthBoundsEXT = fn)
+#define CALL_BlendEquationSeparateEXT(disp, parameters) (*((disp)->BlendEquationSeparateEXT)) parameters
+#define GET_BlendEquationSeparateEXT(disp) ((disp)->BlendEquationSeparateEXT)
+#define SET_BlendEquationSeparateEXT(disp, fn) ((disp)->BlendEquationSeparateEXT = fn)
+#define CALL_BindFramebufferEXT(disp, parameters) (*((disp)->BindFramebufferEXT)) parameters
+#define GET_BindFramebufferEXT(disp) ((disp)->BindFramebufferEXT)
+#define SET_BindFramebufferEXT(disp, fn) ((disp)->BindFramebufferEXT = fn)
+#define CALL_BindRenderbufferEXT(disp, parameters) (*((disp)->BindRenderbufferEXT)) parameters
+#define GET_BindRenderbufferEXT(disp) ((disp)->BindRenderbufferEXT)
+#define SET_BindRenderbufferEXT(disp, fn) ((disp)->BindRenderbufferEXT = fn)
+#define CALL_CheckFramebufferStatusEXT(disp, parameters) (*((disp)->CheckFramebufferStatusEXT)) parameters
+#define GET_CheckFramebufferStatusEXT(disp) ((disp)->CheckFramebufferStatusEXT)
+#define SET_CheckFramebufferStatusEXT(disp, fn) ((disp)->CheckFramebufferStatusEXT = fn)
+#define CALL_DeleteFramebuffersEXT(disp, parameters) (*((disp)->DeleteFramebuffersEXT)) parameters
+#define GET_DeleteFramebuffersEXT(disp) ((disp)->DeleteFramebuffersEXT)
+#define SET_DeleteFramebuffersEXT(disp, fn) ((disp)->DeleteFramebuffersEXT = fn)
+#define CALL_DeleteRenderbuffersEXT(disp, parameters) (*((disp)->DeleteRenderbuffersEXT)) parameters
+#define GET_DeleteRenderbuffersEXT(disp) ((disp)->DeleteRenderbuffersEXT)
+#define SET_DeleteRenderbuffersEXT(disp, fn) ((disp)->DeleteRenderbuffersEXT = fn)
+#define CALL_FramebufferRenderbufferEXT(disp, parameters) (*((disp)->FramebufferRenderbufferEXT)) parameters
+#define GET_FramebufferRenderbufferEXT(disp) ((disp)->FramebufferRenderbufferEXT)
+#define SET_FramebufferRenderbufferEXT(disp, fn) ((disp)->FramebufferRenderbufferEXT = fn)
+#define CALL_FramebufferTexture1DEXT(disp, parameters) (*((disp)->FramebufferTexture1DEXT)) parameters
+#define GET_FramebufferTexture1DEXT(disp) ((disp)->FramebufferTexture1DEXT)
+#define SET_FramebufferTexture1DEXT(disp, fn) ((disp)->FramebufferTexture1DEXT = fn)
+#define CALL_FramebufferTexture2DEXT(disp, parameters) (*((disp)->FramebufferTexture2DEXT)) parameters
+#define GET_FramebufferTexture2DEXT(disp) ((disp)->FramebufferTexture2DEXT)
+#define SET_FramebufferTexture2DEXT(disp, fn) ((disp)->FramebufferTexture2DEXT = fn)
+#define CALL_FramebufferTexture3DEXT(disp, parameters) (*((disp)->FramebufferTexture3DEXT)) parameters
+#define GET_FramebufferTexture3DEXT(disp) ((disp)->FramebufferTexture3DEXT)
+#define SET_FramebufferTexture3DEXT(disp, fn) ((disp)->FramebufferTexture3DEXT = fn)
+#define CALL_GenFramebuffersEXT(disp, parameters) (*((disp)->GenFramebuffersEXT)) parameters
+#define GET_GenFramebuffersEXT(disp) ((disp)->GenFramebuffersEXT)
+#define SET_GenFramebuffersEXT(disp, fn) ((disp)->GenFramebuffersEXT = fn)
+#define CALL_GenRenderbuffersEXT(disp, parameters) (*((disp)->GenRenderbuffersEXT)) parameters
+#define GET_GenRenderbuffersEXT(disp) ((disp)->GenRenderbuffersEXT)
+#define SET_GenRenderbuffersEXT(disp, fn) ((disp)->GenRenderbuffersEXT = fn)
+#define CALL_GenerateMipmapEXT(disp, parameters) (*((disp)->GenerateMipmapEXT)) parameters
+#define GET_GenerateMipmapEXT(disp) ((disp)->GenerateMipmapEXT)
+#define SET_GenerateMipmapEXT(disp, fn) ((disp)->GenerateMipmapEXT = fn)
+#define CALL_GetFramebufferAttachmentParameterivEXT(disp, parameters) (*((disp)->GetFramebufferAttachmentParameterivEXT)) parameters
+#define GET_GetFramebufferAttachmentParameterivEXT(disp) ((disp)->GetFramebufferAttachmentParameterivEXT)
+#define SET_GetFramebufferAttachmentParameterivEXT(disp, fn) ((disp)->GetFramebufferAttachmentParameterivEXT = fn)
+#define CALL_GetRenderbufferParameterivEXT(disp, parameters) (*((disp)->GetRenderbufferParameterivEXT)) parameters
+#define GET_GetRenderbufferParameterivEXT(disp) ((disp)->GetRenderbufferParameterivEXT)
+#define SET_GetRenderbufferParameterivEXT(disp, fn) ((disp)->GetRenderbufferParameterivEXT = fn)
+#define CALL_IsFramebufferEXT(disp, parameters) (*((disp)->IsFramebufferEXT)) parameters
+#define GET_IsFramebufferEXT(disp) ((disp)->IsFramebufferEXT)
+#define SET_IsFramebufferEXT(disp, fn) ((disp)->IsFramebufferEXT = fn)
+#define CALL_IsRenderbufferEXT(disp, parameters) (*((disp)->IsRenderbufferEXT)) parameters
+#define GET_IsRenderbufferEXT(disp) ((disp)->IsRenderbufferEXT)
+#define SET_IsRenderbufferEXT(disp, fn) ((disp)->IsRenderbufferEXT = fn)
+#define CALL_RenderbufferStorageEXT(disp, parameters) (*((disp)->RenderbufferStorageEXT)) parameters
+#define GET_RenderbufferStorageEXT(disp) ((disp)->RenderbufferStorageEXT)
+#define SET_RenderbufferStorageEXT(disp, fn) ((disp)->RenderbufferStorageEXT = fn)
+#define CALL_BlitFramebufferEXT(disp, parameters) (*((disp)->BlitFramebufferEXT)) parameters
+#define GET_BlitFramebufferEXT(disp) ((disp)->BlitFramebufferEXT)
+#define SET_BlitFramebufferEXT(disp, fn) ((disp)->BlitFramebufferEXT = fn)
+#define CALL_BufferParameteriAPPLE(disp, parameters) (*((disp)->BufferParameteriAPPLE)) parameters
+#define GET_BufferParameteriAPPLE(disp) ((disp)->BufferParameteriAPPLE)
+#define SET_BufferParameteriAPPLE(disp, fn) ((disp)->BufferParameteriAPPLE = fn)
+#define CALL_FlushMappedBufferRangeAPPLE(disp, parameters) (*((disp)->FlushMappedBufferRangeAPPLE)) parameters
+#define GET_FlushMappedBufferRangeAPPLE(disp) ((disp)->FlushMappedBufferRangeAPPLE)
+#define SET_FlushMappedBufferRangeAPPLE(disp, fn) ((disp)->FlushMappedBufferRangeAPPLE = fn)
+#define CALL_FramebufferTextureLayerEXT(disp, parameters) (*((disp)->FramebufferTextureLayerEXT)) parameters
+#define GET_FramebufferTextureLayerEXT(disp) ((disp)->FramebufferTextureLayerEXT)
+#define SET_FramebufferTextureLayerEXT(disp, fn) ((disp)->FramebufferTextureLayerEXT = fn)
+#define CALL_ColorMaskIndexedEXT(disp, parameters) (*((disp)->ColorMaskIndexedEXT)) parameters
+#define GET_ColorMaskIndexedEXT(disp) ((disp)->ColorMaskIndexedEXT)
+#define SET_ColorMaskIndexedEXT(disp, fn) ((disp)->ColorMaskIndexedEXT = fn)
+#define CALL_DisableIndexedEXT(disp, parameters) (*((disp)->DisableIndexedEXT)) parameters
+#define GET_DisableIndexedEXT(disp) ((disp)->DisableIndexedEXT)
+#define SET_DisableIndexedEXT(disp, fn) ((disp)->DisableIndexedEXT = fn)
+#define CALL_EnableIndexedEXT(disp, parameters) (*((disp)->EnableIndexedEXT)) parameters
+#define GET_EnableIndexedEXT(disp) ((disp)->EnableIndexedEXT)
+#define SET_EnableIndexedEXT(disp, fn) ((disp)->EnableIndexedEXT = fn)
+#define CALL_GetBooleanIndexedvEXT(disp, parameters) (*((disp)->GetBooleanIndexedvEXT)) parameters
+#define GET_GetBooleanIndexedvEXT(disp) ((disp)->GetBooleanIndexedvEXT)
+#define SET_GetBooleanIndexedvEXT(disp, fn) ((disp)->GetBooleanIndexedvEXT = fn)
+#define CALL_GetIntegerIndexedvEXT(disp, parameters) (*((disp)->GetIntegerIndexedvEXT)) parameters
+#define GET_GetIntegerIndexedvEXT(disp) ((disp)->GetIntegerIndexedvEXT)
+#define SET_GetIntegerIndexedvEXT(disp, fn) ((disp)->GetIntegerIndexedvEXT = fn)
+#define CALL_IsEnabledIndexedEXT(disp, parameters) (*((disp)->IsEnabledIndexedEXT)) parameters
+#define GET_IsEnabledIndexedEXT(disp) ((disp)->IsEnabledIndexedEXT)
+#define SET_IsEnabledIndexedEXT(disp, fn) ((disp)->IsEnabledIndexedEXT = fn)
+#define CALL_BeginConditionalRenderNV(disp, parameters) (*((disp)->BeginConditionalRenderNV)) parameters
+#define GET_BeginConditionalRenderNV(disp) ((disp)->BeginConditionalRenderNV)
+#define SET_BeginConditionalRenderNV(disp, fn) ((disp)->BeginConditionalRenderNV = fn)
+#define CALL_EndConditionalRenderNV(disp, parameters) (*((disp)->EndConditionalRenderNV)) parameters
+#define GET_EndConditionalRenderNV(disp) ((disp)->EndConditionalRenderNV)
+#define SET_EndConditionalRenderNV(disp, fn) ((disp)->EndConditionalRenderNV = fn)
+#define CALL_ProvokingVertexEXT(disp, parameters) (*((disp)->ProvokingVertexEXT)) parameters
+#define GET_ProvokingVertexEXT(disp) ((disp)->ProvokingVertexEXT)
+#define SET_ProvokingVertexEXT(disp, fn) ((disp)->ProvokingVertexEXT = fn)
+#define CALL_GetTexParameterPointervAPPLE(disp, parameters) (*((disp)->GetTexParameterPointervAPPLE)) parameters
+#define GET_GetTexParameterPointervAPPLE(disp) ((disp)->GetTexParameterPointervAPPLE)
+#define SET_GetTexParameterPointervAPPLE(disp, fn) ((disp)->GetTexParameterPointervAPPLE = fn)
+#define CALL_TextureRangeAPPLE(disp, parameters) (*((disp)->TextureRangeAPPLE)) parameters
+#define GET_TextureRangeAPPLE(disp) ((disp)->TextureRangeAPPLE)
+#define SET_TextureRangeAPPLE(disp, fn) ((disp)->TextureRangeAPPLE = fn)
+#define CALL_StencilFuncSeparateATI(disp, parameters) (*((disp)->StencilFuncSeparateATI)) parameters
+#define GET_StencilFuncSeparateATI(disp) ((disp)->StencilFuncSeparateATI)
+#define SET_StencilFuncSeparateATI(disp, fn) ((disp)->StencilFuncSeparateATI = fn)
+#define CALL_ProgramEnvParameters4fvEXT(disp, parameters) (*((disp)->ProgramEnvParameters4fvEXT)) parameters
+#define GET_ProgramEnvParameters4fvEXT(disp) ((disp)->ProgramEnvParameters4fvEXT)
+#define SET_ProgramEnvParameters4fvEXT(disp, fn) ((disp)->ProgramEnvParameters4fvEXT = fn)
+#define CALL_ProgramLocalParameters4fvEXT(disp, parameters) (*((disp)->ProgramLocalParameters4fvEXT)) parameters
+#define GET_ProgramLocalParameters4fvEXT(disp) ((disp)->ProgramLocalParameters4fvEXT)
+#define SET_ProgramLocalParameters4fvEXT(disp, fn) ((disp)->ProgramLocalParameters4fvEXT = fn)
+#define CALL_GetQueryObjecti64vEXT(disp, parameters) (*((disp)->GetQueryObjecti64vEXT)) parameters
+#define GET_GetQueryObjecti64vEXT(disp) ((disp)->GetQueryObjecti64vEXT)
+#define SET_GetQueryObjecti64vEXT(disp, fn) ((disp)->GetQueryObjecti64vEXT = fn)
+#define CALL_GetQueryObjectui64vEXT(disp, parameters) (*((disp)->GetQueryObjectui64vEXT)) parameters
+#define GET_GetQueryObjectui64vEXT(disp) ((disp)->GetQueryObjectui64vEXT)
+#define SET_GetQueryObjectui64vEXT(disp, fn) ((disp)->GetQueryObjectui64vEXT = fn)
+
+#else
+
+#define driDispatchRemapTable_size 395
+extern int driDispatchRemapTable[ driDispatchRemapTable_size ];
+
+#define AttachShader_remap_index 0
+#define CreateProgram_remap_index 1
+#define CreateShader_remap_index 2
+#define DeleteProgram_remap_index 3
+#define DeleteShader_remap_index 4
+#define DetachShader_remap_index 5
+#define GetAttachedShaders_remap_index 6
+#define GetProgramInfoLog_remap_index 7
+#define GetProgramiv_remap_index 8
+#define GetShaderInfoLog_remap_index 9
+#define GetShaderiv_remap_index 10
+#define IsProgram_remap_index 11
+#define IsShader_remap_index 12
+#define StencilFuncSeparate_remap_index 13
+#define StencilMaskSeparate_remap_index 14
+#define StencilOpSeparate_remap_index 15
+#define UniformMatrix2x3fv_remap_index 16
+#define UniformMatrix2x4fv_remap_index 17
+#define UniformMatrix3x2fv_remap_index 18
+#define UniformMatrix3x4fv_remap_index 19
+#define UniformMatrix4x2fv_remap_index 20
+#define UniformMatrix4x3fv_remap_index 21
+#define LoadTransposeMatrixdARB_remap_index 22
+#define LoadTransposeMatrixfARB_remap_index 23
+#define MultTransposeMatrixdARB_remap_index 24
+#define MultTransposeMatrixfARB_remap_index 25
+#define SampleCoverageARB_remap_index 26
+#define CompressedTexImage1DARB_remap_index 27
+#define CompressedTexImage2DARB_remap_index 28
+#define CompressedTexImage3DARB_remap_index 29
+#define CompressedTexSubImage1DARB_remap_index 30
+#define CompressedTexSubImage2DARB_remap_index 31
+#define CompressedTexSubImage3DARB_remap_index 32
+#define GetCompressedTexImageARB_remap_index 33
+#define DisableVertexAttribArrayARB_remap_index 34
+#define EnableVertexAttribArrayARB_remap_index 35
+#define GetProgramEnvParameterdvARB_remap_index 36
+#define GetProgramEnvParameterfvARB_remap_index 37
+#define GetProgramLocalParameterdvARB_remap_index 38
+#define GetProgramLocalParameterfvARB_remap_index 39
+#define GetProgramStringARB_remap_index 40
+#define GetProgramivARB_remap_index 41
+#define GetVertexAttribdvARB_remap_index 42
+#define GetVertexAttribfvARB_remap_index 43
+#define GetVertexAttribivARB_remap_index 44
+#define ProgramEnvParameter4dARB_remap_index 45
+#define ProgramEnvParameter4dvARB_remap_index 46
+#define ProgramEnvParameter4fARB_remap_index 47
+#define ProgramEnvParameter4fvARB_remap_index 48
+#define ProgramLocalParameter4dARB_remap_index 49
+#define ProgramLocalParameter4dvARB_remap_index 50
+#define ProgramLocalParameter4fARB_remap_index 51
+#define ProgramLocalParameter4fvARB_remap_index 52
+#define ProgramStringARB_remap_index 53
+#define VertexAttrib1dARB_remap_index 54
+#define VertexAttrib1dvARB_remap_index 55
+#define VertexAttrib1fARB_remap_index 56
+#define VertexAttrib1fvARB_remap_index 57
+#define VertexAttrib1sARB_remap_index 58
+#define VertexAttrib1svARB_remap_index 59
+#define VertexAttrib2dARB_remap_index 60
+#define VertexAttrib2dvARB_remap_index 61
+#define VertexAttrib2fARB_remap_index 62
+#define VertexAttrib2fvARB_remap_index 63
+#define VertexAttrib2sARB_remap_index 64
+#define VertexAttrib2svARB_remap_index 65
+#define VertexAttrib3dARB_remap_index 66
+#define VertexAttrib3dvARB_remap_index 67
+#define VertexAttrib3fARB_remap_index 68
+#define VertexAttrib3fvARB_remap_index 69
+#define VertexAttrib3sARB_remap_index 70
+#define VertexAttrib3svARB_remap_index 71
+#define VertexAttrib4NbvARB_remap_index 72
+#define VertexAttrib4NivARB_remap_index 73
+#define VertexAttrib4NsvARB_remap_index 74
+#define VertexAttrib4NubARB_remap_index 75
+#define VertexAttrib4NubvARB_remap_index 76
+#define VertexAttrib4NuivARB_remap_index 77
+#define VertexAttrib4NusvARB_remap_index 78
+#define VertexAttrib4bvARB_remap_index 79
+#define VertexAttrib4dARB_remap_index 80
+#define VertexAttrib4dvARB_remap_index 81
+#define VertexAttrib4fARB_remap_index 82
+#define VertexAttrib4fvARB_remap_index 83
+#define VertexAttrib4ivARB_remap_index 84
+#define VertexAttrib4sARB_remap_index 85
+#define VertexAttrib4svARB_remap_index 86
+#define VertexAttrib4ubvARB_remap_index 87
+#define VertexAttrib4uivARB_remap_index 88
+#define VertexAttrib4usvARB_remap_index 89
+#define VertexAttribPointerARB_remap_index 90
+#define BindBufferARB_remap_index 91
+#define BufferDataARB_remap_index 92
+#define BufferSubDataARB_remap_index 93
+#define DeleteBuffersARB_remap_index 94
+#define GenBuffersARB_remap_index 95
+#define GetBufferParameterivARB_remap_index 96
+#define GetBufferPointervARB_remap_index 97
+#define GetBufferSubDataARB_remap_index 98
+#define IsBufferARB_remap_index 99
+#define MapBufferARB_remap_index 100
+#define UnmapBufferARB_remap_index 101
+#define BeginQueryARB_remap_index 102
+#define DeleteQueriesARB_remap_index 103
+#define EndQueryARB_remap_index 104
+#define GenQueriesARB_remap_index 105
+#define GetQueryObjectivARB_remap_index 106
+#define GetQueryObjectuivARB_remap_index 107
+#define GetQueryivARB_remap_index 108
+#define IsQueryARB_remap_index 109
+#define AttachObjectARB_remap_index 110
+#define CompileShaderARB_remap_index 111
+#define CreateProgramObjectARB_remap_index 112
+#define CreateShaderObjectARB_remap_index 113
+#define DeleteObjectARB_remap_index 114
+#define DetachObjectARB_remap_index 115
+#define GetActiveUniformARB_remap_index 116
+#define GetAttachedObjectsARB_remap_index 117
+#define GetHandleARB_remap_index 118
+#define GetInfoLogARB_remap_index 119
+#define GetObjectParameterfvARB_remap_index 120
+#define GetObjectParameterivARB_remap_index 121
+#define GetShaderSourceARB_remap_index 122
+#define GetUniformLocationARB_remap_index 123
+#define GetUniformfvARB_remap_index 124
+#define GetUniformivARB_remap_index 125
+#define LinkProgramARB_remap_index 126
+#define ShaderSourceARB_remap_index 127
+#define Uniform1fARB_remap_index 128
+#define Uniform1fvARB_remap_index 129
+#define Uniform1iARB_remap_index 130
+#define Uniform1ivARB_remap_index 131
+#define Uniform2fARB_remap_index 132
+#define Uniform2fvARB_remap_index 133
+#define Uniform2iARB_remap_index 134
+#define Uniform2ivARB_remap_index 135
+#define Uniform3fARB_remap_index 136
+#define Uniform3fvARB_remap_index 137
+#define Uniform3iARB_remap_index 138
+#define Uniform3ivARB_remap_index 139
+#define Uniform4fARB_remap_index 140
+#define Uniform4fvARB_remap_index 141
+#define Uniform4iARB_remap_index 142
+#define Uniform4ivARB_remap_index 143
+#define UniformMatrix2fvARB_remap_index 144
+#define UniformMatrix3fvARB_remap_index 145
+#define UniformMatrix4fvARB_remap_index 146
+#define UseProgramObjectARB_remap_index 147
+#define ValidateProgramARB_remap_index 148
+#define BindAttribLocationARB_remap_index 149
+#define GetActiveAttribARB_remap_index 150
+#define GetAttribLocationARB_remap_index 151
+#define DrawBuffersARB_remap_index 152
+#define RenderbufferStorageMultisample_remap_index 153
+#define FlushMappedBufferRange_remap_index 154
+#define MapBufferRange_remap_index 155
+#define BindVertexArray_remap_index 156
+#define GenVertexArrays_remap_index 157
+#define CopyBufferSubData_remap_index 158
+#define ClientWaitSync_remap_index 159
+#define DeleteSync_remap_index 160
+#define FenceSync_remap_index 161
+#define GetInteger64v_remap_index 162
+#define GetSynciv_remap_index 163
+#define IsSync_remap_index 164
+#define WaitSync_remap_index 165
+#define DrawElementsBaseVertex_remap_index 166
+#define DrawRangeElementsBaseVertex_remap_index 167
+#define MultiDrawElementsBaseVertex_remap_index 168
+#define PolygonOffsetEXT_remap_index 169
+#define GetPixelTexGenParameterfvSGIS_remap_index 170
+#define GetPixelTexGenParameterivSGIS_remap_index 171
+#define PixelTexGenParameterfSGIS_remap_index 172
+#define PixelTexGenParameterfvSGIS_remap_index 173
+#define PixelTexGenParameteriSGIS_remap_index 174
+#define PixelTexGenParameterivSGIS_remap_index 175
+#define SampleMaskSGIS_remap_index 176
+#define SamplePatternSGIS_remap_index 177
+#define ColorPointerEXT_remap_index 178
+#define EdgeFlagPointerEXT_remap_index 179
+#define IndexPointerEXT_remap_index 180
+#define NormalPointerEXT_remap_index 181
+#define TexCoordPointerEXT_remap_index 182
+#define VertexPointerEXT_remap_index 183
+#define PointParameterfEXT_remap_index 184
+#define PointParameterfvEXT_remap_index 185
+#define LockArraysEXT_remap_index 186
+#define UnlockArraysEXT_remap_index 187
+#define CullParameterdvEXT_remap_index 188
+#define CullParameterfvEXT_remap_index 189
+#define SecondaryColor3bEXT_remap_index 190
+#define SecondaryColor3bvEXT_remap_index 191
+#define SecondaryColor3dEXT_remap_index 192
+#define SecondaryColor3dvEXT_remap_index 193
+#define SecondaryColor3fEXT_remap_index 194
+#define SecondaryColor3fvEXT_remap_index 195
+#define SecondaryColor3iEXT_remap_index 196
+#define SecondaryColor3ivEXT_remap_index 197
+#define SecondaryColor3sEXT_remap_index 198
+#define SecondaryColor3svEXT_remap_index 199
+#define SecondaryColor3ubEXT_remap_index 200
+#define SecondaryColor3ubvEXT_remap_index 201
+#define SecondaryColor3uiEXT_remap_index 202
+#define SecondaryColor3uivEXT_remap_index 203
+#define SecondaryColor3usEXT_remap_index 204
+#define SecondaryColor3usvEXT_remap_index 205
+#define SecondaryColorPointerEXT_remap_index 206
+#define MultiDrawArraysEXT_remap_index 207
+#define MultiDrawElementsEXT_remap_index 208
+#define FogCoordPointerEXT_remap_index 209
+#define FogCoorddEXT_remap_index 210
+#define FogCoorddvEXT_remap_index 211
+#define FogCoordfEXT_remap_index 212
+#define FogCoordfvEXT_remap_index 213
+#define PixelTexGenSGIX_remap_index 214
+#define BlendFuncSeparateEXT_remap_index 215
+#define FlushVertexArrayRangeNV_remap_index 216
+#define VertexArrayRangeNV_remap_index 217
+#define CombinerInputNV_remap_index 218
+#define CombinerOutputNV_remap_index 219
+#define CombinerParameterfNV_remap_index 220
+#define CombinerParameterfvNV_remap_index 221
+#define CombinerParameteriNV_remap_index 222
+#define CombinerParameterivNV_remap_index 223
+#define FinalCombinerInputNV_remap_index 224
+#define GetCombinerInputParameterfvNV_remap_index 225
+#define GetCombinerInputParameterivNV_remap_index 226
+#define GetCombinerOutputParameterfvNV_remap_index 227
+#define GetCombinerOutputParameterivNV_remap_index 228
+#define GetFinalCombinerInputParameterfvNV_remap_index 229
+#define GetFinalCombinerInputParameterivNV_remap_index 230
+#define ResizeBuffersMESA_remap_index 231
+#define WindowPos2dMESA_remap_index 232
+#define WindowPos2dvMESA_remap_index 233
+#define WindowPos2fMESA_remap_index 234
+#define WindowPos2fvMESA_remap_index 235
+#define WindowPos2iMESA_remap_index 236
+#define WindowPos2ivMESA_remap_index 237
+#define WindowPos2sMESA_remap_index 238
+#define WindowPos2svMESA_remap_index 239
+#define WindowPos3dMESA_remap_index 240
+#define WindowPos3dvMESA_remap_index 241
+#define WindowPos3fMESA_remap_index 242
+#define WindowPos3fvMESA_remap_index 243
+#define WindowPos3iMESA_remap_index 244
+#define WindowPos3ivMESA_remap_index 245
+#define WindowPos3sMESA_remap_index 246
+#define WindowPos3svMESA_remap_index 247
+#define WindowPos4dMESA_remap_index 248
+#define WindowPos4dvMESA_remap_index 249
+#define WindowPos4fMESA_remap_index 250
+#define WindowPos4fvMESA_remap_index 251
+#define WindowPos4iMESA_remap_index 252
+#define WindowPos4ivMESA_remap_index 253
+#define WindowPos4sMESA_remap_index 254
+#define WindowPos4svMESA_remap_index 255
+#define MultiModeDrawArraysIBM_remap_index 256
+#define MultiModeDrawElementsIBM_remap_index 257
+#define DeleteFencesNV_remap_index 258
+#define FinishFenceNV_remap_index 259
+#define GenFencesNV_remap_index 260
+#define GetFenceivNV_remap_index 261
+#define IsFenceNV_remap_index 262
+#define SetFenceNV_remap_index 263
+#define TestFenceNV_remap_index 264
+#define AreProgramsResidentNV_remap_index 265
+#define BindProgramNV_remap_index 266
+#define DeleteProgramsNV_remap_index 267
+#define ExecuteProgramNV_remap_index 268
+#define GenProgramsNV_remap_index 269
+#define GetProgramParameterdvNV_remap_index 270
+#define GetProgramParameterfvNV_remap_index 271
+#define GetProgramStringNV_remap_index 272
+#define GetProgramivNV_remap_index 273
+#define GetTrackMatrixivNV_remap_index 274
+#define GetVertexAttribPointervNV_remap_index 275
+#define GetVertexAttribdvNV_remap_index 276
+#define GetVertexAttribfvNV_remap_index 277
+#define GetVertexAttribivNV_remap_index 278
+#define IsProgramNV_remap_index 279
+#define LoadProgramNV_remap_index 280
+#define ProgramParameters4dvNV_remap_index 281
+#define ProgramParameters4fvNV_remap_index 282
+#define RequestResidentProgramsNV_remap_index 283
+#define TrackMatrixNV_remap_index 284
+#define VertexAttrib1dNV_remap_index 285
+#define VertexAttrib1dvNV_remap_index 286
+#define VertexAttrib1fNV_remap_index 287
+#define VertexAttrib1fvNV_remap_index 288
+#define VertexAttrib1sNV_remap_index 289
+#define VertexAttrib1svNV_remap_index 290
+#define VertexAttrib2dNV_remap_index 291
+#define VertexAttrib2dvNV_remap_index 292
+#define VertexAttrib2fNV_remap_index 293
+#define VertexAttrib2fvNV_remap_index 294
+#define VertexAttrib2sNV_remap_index 295
+#define VertexAttrib2svNV_remap_index 296
+#define VertexAttrib3dNV_remap_index 297
+#define VertexAttrib3dvNV_remap_index 298
+#define VertexAttrib3fNV_remap_index 299
+#define VertexAttrib3fvNV_remap_index 300
+#define VertexAttrib3sNV_remap_index 301
+#define VertexAttrib3svNV_remap_index 302
+#define VertexAttrib4dNV_remap_index 303
+#define VertexAttrib4dvNV_remap_index 304
+#define VertexAttrib4fNV_remap_index 305
+#define VertexAttrib4fvNV_remap_index 306
+#define VertexAttrib4sNV_remap_index 307
+#define VertexAttrib4svNV_remap_index 308
+#define VertexAttrib4ubNV_remap_index 309
+#define VertexAttrib4ubvNV_remap_index 310
+#define VertexAttribPointerNV_remap_index 311
+#define VertexAttribs1dvNV_remap_index 312
+#define VertexAttribs1fvNV_remap_index 313
+#define VertexAttribs1svNV_remap_index 314
+#define VertexAttribs2dvNV_remap_index 315
+#define VertexAttribs2fvNV_remap_index 316
+#define VertexAttribs2svNV_remap_index 317
+#define VertexAttribs3dvNV_remap_index 318
+#define VertexAttribs3fvNV_remap_index 319
+#define VertexAttribs3svNV_remap_index 320
+#define VertexAttribs4dvNV_remap_index 321
+#define VertexAttribs4fvNV_remap_index 322
+#define VertexAttribs4svNV_remap_index 323
+#define VertexAttribs4ubvNV_remap_index 324
+#define GetTexBumpParameterfvATI_remap_index 325
+#define GetTexBumpParameterivATI_remap_index 326
+#define TexBumpParameterfvATI_remap_index 327
+#define TexBumpParameterivATI_remap_index 328
+#define AlphaFragmentOp1ATI_remap_index 329
+#define AlphaFragmentOp2ATI_remap_index 330
+#define AlphaFragmentOp3ATI_remap_index 331
+#define BeginFragmentShaderATI_remap_index 332
+#define BindFragmentShaderATI_remap_index 333
+#define ColorFragmentOp1ATI_remap_index 334
+#define ColorFragmentOp2ATI_remap_index 335
+#define ColorFragmentOp3ATI_remap_index 336
+#define DeleteFragmentShaderATI_remap_index 337
+#define EndFragmentShaderATI_remap_index 338
+#define GenFragmentShadersATI_remap_index 339
+#define PassTexCoordATI_remap_index 340
+#define SampleMapATI_remap_index 341
+#define SetFragmentShaderConstantATI_remap_index 342
+#define PointParameteriNV_remap_index 343
+#define PointParameterivNV_remap_index 344
+#define ActiveStencilFaceEXT_remap_index 345
+#define BindVertexArrayAPPLE_remap_index 346
+#define DeleteVertexArraysAPPLE_remap_index 347
+#define GenVertexArraysAPPLE_remap_index 348
+#define IsVertexArrayAPPLE_remap_index 349
+#define GetProgramNamedParameterdvNV_remap_index 350
+#define GetProgramNamedParameterfvNV_remap_index 351
+#define ProgramNamedParameter4dNV_remap_index 352
+#define ProgramNamedParameter4dvNV_remap_index 353
+#define ProgramNamedParameter4fNV_remap_index 354
+#define ProgramNamedParameter4fvNV_remap_index 355
+#define DepthBoundsEXT_remap_index 356
+#define BlendEquationSeparateEXT_remap_index 357
+#define BindFramebufferEXT_remap_index 358
+#define BindRenderbufferEXT_remap_index 359
+#define CheckFramebufferStatusEXT_remap_index 360
+#define DeleteFramebuffersEXT_remap_index 361
+#define DeleteRenderbuffersEXT_remap_index 362
+#define FramebufferRenderbufferEXT_remap_index 363
+#define FramebufferTexture1DEXT_remap_index 364
+#define FramebufferTexture2DEXT_remap_index 365
+#define FramebufferTexture3DEXT_remap_index 366
+#define GenFramebuffersEXT_remap_index 367
+#define GenRenderbuffersEXT_remap_index 368
+#define GenerateMipmapEXT_remap_index 369
+#define GetFramebufferAttachmentParameterivEXT_remap_index 370
+#define GetRenderbufferParameterivEXT_remap_index 371
+#define IsFramebufferEXT_remap_index 372
+#define IsRenderbufferEXT_remap_index 373
+#define RenderbufferStorageEXT_remap_index 374
+#define BlitFramebufferEXT_remap_index 375
+#define BufferParameteriAPPLE_remap_index 376
+#define FlushMappedBufferRangeAPPLE_remap_index 377
+#define FramebufferTextureLayerEXT_remap_index 378
+#define ColorMaskIndexedEXT_remap_index 379
+#define DisableIndexedEXT_remap_index 380
+#define EnableIndexedEXT_remap_index 381
+#define GetBooleanIndexedvEXT_remap_index 382
+#define GetIntegerIndexedvEXT_remap_index 383
+#define IsEnabledIndexedEXT_remap_index 384
+#define BeginConditionalRenderNV_remap_index 385
+#define EndConditionalRenderNV_remap_index 386
+#define ProvokingVertexEXT_remap_index 387
+#define GetTexParameterPointervAPPLE_remap_index 388
+#define TextureRangeAPPLE_remap_index 389
+#define StencilFuncSeparateATI_remap_index 390
+#define ProgramEnvParameters4fvEXT_remap_index 391
+#define ProgramLocalParameters4fvEXT_remap_index 392
+#define GetQueryObjecti64vEXT_remap_index 393
+#define GetQueryObjectui64vEXT_remap_index 394
+
+#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])
+#define SET_AttachShader(disp, fn) SET_by_offset(disp, driDispatchRemapTable[AttachShader_remap_index], fn)
+#define CALL_CreateProgram(disp, parameters) CALL_by_offset(disp, (GLuint (GLAPIENTRYP)(void)), driDispatchRemapTable[CreateProgram_remap_index], parameters)
+#define GET_CreateProgram(disp) GET_by_offset(disp, driDispatchRemapTable[CreateProgram_remap_index])
+#define SET_CreateProgram(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CreateProgram_remap_index], fn)
+#define CALL_CreateShader(disp, parameters) CALL_by_offset(disp, (GLuint (GLAPIENTRYP)(GLenum)), driDispatchRemapTable[CreateShader_remap_index], parameters)
+#define GET_CreateShader(disp) GET_by_offset(disp, driDispatchRemapTable[CreateShader_remap_index])
+#define SET_CreateShader(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CreateShader_remap_index], fn)
+#define CALL_DeleteProgram(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[DeleteProgram_remap_index], parameters)
+#define GET_DeleteProgram(disp) GET_by_offset(disp, driDispatchRemapTable[DeleteProgram_remap_index])
+#define SET_DeleteProgram(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DeleteProgram_remap_index], fn)
+#define CALL_DeleteShader(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[DeleteShader_remap_index], parameters)
+#define GET_DeleteShader(disp) GET_by_offset(disp, driDispatchRemapTable[DeleteShader_remap_index])
+#define SET_DeleteShader(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DeleteShader_remap_index], fn)
+#define CALL_DetachShader(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLuint)), driDispatchRemapTable[DetachShader_remap_index], parameters)
+#define GET_DetachShader(disp) GET_by_offset(disp, driDispatchRemapTable[DetachShader_remap_index])
+#define SET_DetachShader(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DetachShader_remap_index], fn)
+#define CALL_GetAttachedShaders(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, GLsizei *, GLuint *)), driDispatchRemapTable[GetAttachedShaders_remap_index], parameters)
+#define GET_GetAttachedShaders(disp) GET_by_offset(disp, driDispatchRemapTable[GetAttachedShaders_remap_index])
+#define SET_GetAttachedShaders(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetAttachedShaders_remap_index], fn)
+#define CALL_GetProgramInfoLog(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, GLsizei *, GLchar *)), driDispatchRemapTable[GetProgramInfoLog_remap_index], parameters)
+#define GET_GetProgramInfoLog(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramInfoLog_remap_index])
+#define SET_GetProgramInfoLog(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramInfoLog_remap_index], fn)
+#define CALL_GetProgramiv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint *)), driDispatchRemapTable[GetProgramiv_remap_index], parameters)
+#define GET_GetProgramiv(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramiv_remap_index])
+#define SET_GetProgramiv(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramiv_remap_index], fn)
+#define CALL_GetShaderInfoLog(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, GLsizei *, GLchar *)), driDispatchRemapTable[GetShaderInfoLog_remap_index], parameters)
+#define GET_GetShaderInfoLog(disp) GET_by_offset(disp, driDispatchRemapTable[GetShaderInfoLog_remap_index])
+#define SET_GetShaderInfoLog(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetShaderInfoLog_remap_index], fn)
+#define CALL_GetShaderiv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint *)), driDispatchRemapTable[GetShaderiv_remap_index], parameters)
+#define GET_GetShaderiv(disp) GET_by_offset(disp, driDispatchRemapTable[GetShaderiv_remap_index])
+#define SET_GetShaderiv(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetShaderiv_remap_index], fn)
+#define CALL_IsProgram(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[IsProgram_remap_index], parameters)
+#define GET_IsProgram(disp) GET_by_offset(disp, driDispatchRemapTable[IsProgram_remap_index])
+#define SET_IsProgram(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IsProgram_remap_index], fn)
+#define CALL_IsShader(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[IsShader_remap_index], parameters)
+#define GET_IsShader(disp) GET_by_offset(disp, driDispatchRemapTable[IsShader_remap_index])
+#define SET_IsShader(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IsShader_remap_index], fn)
+#define CALL_StencilFuncSeparate(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint, GLuint)), driDispatchRemapTable[StencilFuncSeparate_remap_index], parameters)
+#define GET_StencilFuncSeparate(disp) GET_by_offset(disp, driDispatchRemapTable[StencilFuncSeparate_remap_index])
+#define SET_StencilFuncSeparate(disp, fn) SET_by_offset(disp, driDispatchRemapTable[StencilFuncSeparate_remap_index], fn)
+#define CALL_StencilMaskSeparate(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint)), driDispatchRemapTable[StencilMaskSeparate_remap_index], parameters)
+#define GET_StencilMaskSeparate(disp) GET_by_offset(disp, driDispatchRemapTable[StencilMaskSeparate_remap_index])
+#define SET_StencilMaskSeparate(disp, fn) SET_by_offset(disp, driDispatchRemapTable[StencilMaskSeparate_remap_index], fn)
+#define CALL_StencilOpSeparate(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLenum)), driDispatchRemapTable[StencilOpSeparate_remap_index], parameters)
+#define GET_StencilOpSeparate(disp) GET_by_offset(disp, driDispatchRemapTable[StencilOpSeparate_remap_index])
+#define SET_StencilOpSeparate(disp, fn) SET_by_offset(disp, driDispatchRemapTable[StencilOpSeparate_remap_index], fn)
+#define CALL_UniformMatrix2x3fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, GLboolean, const GLfloat *)), driDispatchRemapTable[UniformMatrix2x3fv_remap_index], parameters)
+#define GET_UniformMatrix2x3fv(disp) GET_by_offset(disp, driDispatchRemapTable[UniformMatrix2x3fv_remap_index])
+#define SET_UniformMatrix2x3fv(disp, fn) SET_by_offset(disp, driDispatchRemapTable[UniformMatrix2x3fv_remap_index], fn)
+#define CALL_UniformMatrix2x4fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, GLboolean, const GLfloat *)), driDispatchRemapTable[UniformMatrix2x4fv_remap_index], parameters)
+#define GET_UniformMatrix2x4fv(disp) GET_by_offset(disp, driDispatchRemapTable[UniformMatrix2x4fv_remap_index])
+#define SET_UniformMatrix2x4fv(disp, fn) SET_by_offset(disp, driDispatchRemapTable[UniformMatrix2x4fv_remap_index], fn)
+#define CALL_UniformMatrix3x2fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, GLboolean, const GLfloat *)), driDispatchRemapTable[UniformMatrix3x2fv_remap_index], parameters)
+#define GET_UniformMatrix3x2fv(disp) GET_by_offset(disp, driDispatchRemapTable[UniformMatrix3x2fv_remap_index])
+#define SET_UniformMatrix3x2fv(disp, fn) SET_by_offset(disp, driDispatchRemapTable[UniformMatrix3x2fv_remap_index], fn)
+#define CALL_UniformMatrix3x4fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, GLboolean, const GLfloat *)), driDispatchRemapTable[UniformMatrix3x4fv_remap_index], parameters)
+#define GET_UniformMatrix3x4fv(disp) GET_by_offset(disp, driDispatchRemapTable[UniformMatrix3x4fv_remap_index])
+#define SET_UniformMatrix3x4fv(disp, fn) SET_by_offset(disp, driDispatchRemapTable[UniformMatrix3x4fv_remap_index], fn)
+#define CALL_UniformMatrix4x2fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, GLboolean, const GLfloat *)), driDispatchRemapTable[UniformMatrix4x2fv_remap_index], parameters)
+#define GET_UniformMatrix4x2fv(disp) GET_by_offset(disp, driDispatchRemapTable[UniformMatrix4x2fv_remap_index])
+#define SET_UniformMatrix4x2fv(disp, fn) SET_by_offset(disp, driDispatchRemapTable[UniformMatrix4x2fv_remap_index], fn)
+#define CALL_UniformMatrix4x3fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, GLboolean, const GLfloat *)), driDispatchRemapTable[UniformMatrix4x3fv_remap_index], parameters)
+#define GET_UniformMatrix4x3fv(disp) GET_by_offset(disp, driDispatchRemapTable[UniformMatrix4x3fv_remap_index])
+#define SET_UniformMatrix4x3fv(disp, fn) SET_by_offset(disp, driDispatchRemapTable[UniformMatrix4x3fv_remap_index], fn)
+#define CALL_LoadTransposeMatrixdARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), driDispatchRemapTable[LoadTransposeMatrixdARB_remap_index], parameters)
+#define GET_LoadTransposeMatrixdARB(disp) GET_by_offset(disp, driDispatchRemapTable[LoadTransposeMatrixdARB_remap_index])
+#define SET_LoadTransposeMatrixdARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[LoadTransposeMatrixdARB_remap_index], fn)
+#define CALL_LoadTransposeMatrixfARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), driDispatchRemapTable[LoadTransposeMatrixfARB_remap_index], parameters)
+#define GET_LoadTransposeMatrixfARB(disp) GET_by_offset(disp, driDispatchRemapTable[LoadTransposeMatrixfARB_remap_index])
+#define SET_LoadTransposeMatrixfARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[LoadTransposeMatrixfARB_remap_index], fn)
+#define CALL_MultTransposeMatrixdARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), driDispatchRemapTable[MultTransposeMatrixdARB_remap_index], parameters)
+#define GET_MultTransposeMatrixdARB(disp) GET_by_offset(disp, driDispatchRemapTable[MultTransposeMatrixdARB_remap_index])
+#define SET_MultTransposeMatrixdARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[MultTransposeMatrixdARB_remap_index], fn)
+#define CALL_MultTransposeMatrixfARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), driDispatchRemapTable[MultTransposeMatrixfARB_remap_index], parameters)
+#define GET_MultTransposeMatrixfARB(disp) GET_by_offset(disp, driDispatchRemapTable[MultTransposeMatrixfARB_remap_index])
+#define SET_MultTransposeMatrixfARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[MultTransposeMatrixfARB_remap_index], fn)
+#define CALL_SampleCoverageARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLclampf, GLboolean)), driDispatchRemapTable[SampleCoverageARB_remap_index], parameters)
+#define GET_SampleCoverageARB(disp) GET_by_offset(disp, driDispatchRemapTable[SampleCoverageARB_remap_index])
+#define SET_SampleCoverageARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SampleCoverageARB_remap_index], fn)
+#define CALL_CompressedTexImage1DARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *)), driDispatchRemapTable[CompressedTexImage1DARB_remap_index], parameters)
+#define GET_CompressedTexImage1DARB(disp) GET_by_offset(disp, driDispatchRemapTable[CompressedTexImage1DARB_remap_index])
+#define SET_CompressedTexImage1DARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CompressedTexImage1DARB_remap_index], fn)
+#define CALL_CompressedTexImage2DARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *)), driDispatchRemapTable[CompressedTexImage2DARB_remap_index], parameters)
+#define GET_CompressedTexImage2DARB(disp) GET_by_offset(disp, driDispatchRemapTable[CompressedTexImage2DARB_remap_index])
+#define SET_CompressedTexImage2DARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CompressedTexImage2DARB_remap_index], fn)
+#define CALL_CompressedTexImage3DARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *)), driDispatchRemapTable[CompressedTexImage3DARB_remap_index], parameters)
+#define GET_CompressedTexImage3DARB(disp) GET_by_offset(disp, driDispatchRemapTable[CompressedTexImage3DARB_remap_index])
+#define SET_CompressedTexImage3DARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CompressedTexImage3DARB_remap_index], fn)
+#define CALL_CompressedTexSubImage1DARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *)), driDispatchRemapTable[CompressedTexSubImage1DARB_remap_index], parameters)
+#define GET_CompressedTexSubImage1DARB(disp) GET_by_offset(disp, driDispatchRemapTable[CompressedTexSubImage1DARB_remap_index])
+#define SET_CompressedTexSubImage1DARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CompressedTexSubImage1DARB_remap_index], fn)
+#define CALL_CompressedTexSubImage2DARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *)), driDispatchRemapTable[CompressedTexSubImage2DARB_remap_index], parameters)
+#define GET_CompressedTexSubImage2DARB(disp) GET_by_offset(disp, driDispatchRemapTable[CompressedTexSubImage2DARB_remap_index])
+#define SET_CompressedTexSubImage2DARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CompressedTexSubImage2DARB_remap_index], fn)
+#define CALL_CompressedTexSubImage3DARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *)), driDispatchRemapTable[CompressedTexSubImage3DARB_remap_index], parameters)
+#define GET_CompressedTexSubImage3DARB(disp) GET_by_offset(disp, driDispatchRemapTable[CompressedTexSubImage3DARB_remap_index])
+#define SET_CompressedTexSubImage3DARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CompressedTexSubImage3DARB_remap_index], fn)
+#define CALL_GetCompressedTexImageARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLvoid *)), driDispatchRemapTable[GetCompressedTexImageARB_remap_index], parameters)
+#define GET_GetCompressedTexImageARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetCompressedTexImageARB_remap_index])
+#define SET_GetCompressedTexImageARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetCompressedTexImageARB_remap_index], fn)
+#define CALL_DisableVertexAttribArrayARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[DisableVertexAttribArrayARB_remap_index], parameters)
+#define GET_DisableVertexAttribArrayARB(disp) GET_by_offset(disp, driDispatchRemapTable[DisableVertexAttribArrayARB_remap_index])
+#define SET_DisableVertexAttribArrayARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DisableVertexAttribArrayARB_remap_index], fn)
+#define CALL_EnableVertexAttribArrayARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[EnableVertexAttribArrayARB_remap_index], parameters)
+#define GET_EnableVertexAttribArrayARB(disp) GET_by_offset(disp, driDispatchRemapTable[EnableVertexAttribArrayARB_remap_index])
+#define SET_EnableVertexAttribArrayARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[EnableVertexAttribArrayARB_remap_index], fn)
+#define CALL_GetProgramEnvParameterdvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLdouble *)), driDispatchRemapTable[GetProgramEnvParameterdvARB_remap_index], parameters)
+#define GET_GetProgramEnvParameterdvARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramEnvParameterdvARB_remap_index])
+#define SET_GetProgramEnvParameterdvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramEnvParameterdvARB_remap_index], fn)
+#define CALL_GetProgramEnvParameterfvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLfloat *)), driDispatchRemapTable[GetProgramEnvParameterfvARB_remap_index], parameters)
+#define GET_GetProgramEnvParameterfvARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramEnvParameterfvARB_remap_index])
+#define SET_GetProgramEnvParameterfvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramEnvParameterfvARB_remap_index], fn)
+#define CALL_GetProgramLocalParameterdvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLdouble *)), driDispatchRemapTable[GetProgramLocalParameterdvARB_remap_index], parameters)
+#define GET_GetProgramLocalParameterdvARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramLocalParameterdvARB_remap_index])
+#define SET_GetProgramLocalParameterdvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramLocalParameterdvARB_remap_index], fn)
+#define CALL_GetProgramLocalParameterfvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLfloat *)), driDispatchRemapTable[GetProgramLocalParameterfvARB_remap_index], parameters)
+#define GET_GetProgramLocalParameterfvARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramLocalParameterfvARB_remap_index])
+#define SET_GetProgramLocalParameterfvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramLocalParameterfvARB_remap_index], fn)
+#define CALL_GetProgramStringARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLvoid *)), driDispatchRemapTable[GetProgramStringARB_remap_index], parameters)
+#define GET_GetProgramStringARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramStringARB_remap_index])
+#define SET_GetProgramStringARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramStringARB_remap_index], fn)
+#define CALL_GetProgramivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), driDispatchRemapTable[GetProgramivARB_remap_index], parameters)
+#define GET_GetProgramivARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramivARB_remap_index])
+#define SET_GetProgramivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramivARB_remap_index], fn)
+#define CALL_GetVertexAttribdvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLdouble *)), driDispatchRemapTable[GetVertexAttribdvARB_remap_index], parameters)
+#define GET_GetVertexAttribdvARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetVertexAttribdvARB_remap_index])
+#define SET_GetVertexAttribdvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetVertexAttribdvARB_remap_index], fn)
+#define CALL_GetVertexAttribfvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLfloat *)), driDispatchRemapTable[GetVertexAttribfvARB_remap_index], parameters)
+#define GET_GetVertexAttribfvARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetVertexAttribfvARB_remap_index])
+#define SET_GetVertexAttribfvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetVertexAttribfvARB_remap_index], fn)
+#define CALL_GetVertexAttribivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint *)), driDispatchRemapTable[GetVertexAttribivARB_remap_index], parameters)
+#define GET_GetVertexAttribivARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetVertexAttribivARB_remap_index])
+#define SET_GetVertexAttribivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetVertexAttribivARB_remap_index], fn)
+#define CALL_ProgramEnvParameter4dARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble)), driDispatchRemapTable[ProgramEnvParameter4dARB_remap_index], parameters)
+#define GET_ProgramEnvParameter4dARB(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramEnvParameter4dARB_remap_index])
+#define SET_ProgramEnvParameter4dARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramEnvParameter4dARB_remap_index], fn)
+#define CALL_ProgramEnvParameter4dvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, const GLdouble *)), driDispatchRemapTable[ProgramEnvParameter4dvARB_remap_index], parameters)
+#define GET_ProgramEnvParameter4dvARB(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramEnvParameter4dvARB_remap_index])
+#define SET_ProgramEnvParameter4dvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramEnvParameter4dvARB_remap_index], fn)
+#define CALL_ProgramEnvParameter4fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[ProgramEnvParameter4fARB_remap_index], parameters)
+#define GET_ProgramEnvParameter4fARB(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramEnvParameter4fARB_remap_index])
+#define SET_ProgramEnvParameter4fARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramEnvParameter4fARB_remap_index], fn)
+#define CALL_ProgramEnvParameter4fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, const GLfloat *)), driDispatchRemapTable[ProgramEnvParameter4fvARB_remap_index], parameters)
+#define GET_ProgramEnvParameter4fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramEnvParameter4fvARB_remap_index])
+#define SET_ProgramEnvParameter4fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramEnvParameter4fvARB_remap_index], fn)
+#define CALL_ProgramLocalParameter4dARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble)), driDispatchRemapTable[ProgramLocalParameter4dARB_remap_index], parameters)
+#define GET_ProgramLocalParameter4dARB(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramLocalParameter4dARB_remap_index])
+#define SET_ProgramLocalParameter4dARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramLocalParameter4dARB_remap_index], fn)
+#define CALL_ProgramLocalParameter4dvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, const GLdouble *)), driDispatchRemapTable[ProgramLocalParameter4dvARB_remap_index], parameters)
+#define GET_ProgramLocalParameter4dvARB(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramLocalParameter4dvARB_remap_index])
+#define SET_ProgramLocalParameter4dvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramLocalParameter4dvARB_remap_index], fn)
+#define CALL_ProgramLocalParameter4fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[ProgramLocalParameter4fARB_remap_index], parameters)
+#define GET_ProgramLocalParameter4fARB(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramLocalParameter4fARB_remap_index])
+#define SET_ProgramLocalParameter4fARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramLocalParameter4fARB_remap_index], fn)
+#define CALL_ProgramLocalParameter4fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, const GLfloat *)), driDispatchRemapTable[ProgramLocalParameter4fvARB_remap_index], parameters)
+#define GET_ProgramLocalParameter4fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramLocalParameter4fvARB_remap_index])
+#define SET_ProgramLocalParameter4fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramLocalParameter4fvARB_remap_index], fn)
+#define CALL_ProgramStringARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLsizei, const GLvoid *)), driDispatchRemapTable[ProgramStringARB_remap_index], parameters)
+#define GET_ProgramStringARB(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramStringARB_remap_index])
+#define SET_ProgramStringARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramStringARB_remap_index], fn)
+#define CALL_VertexAttrib1dARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLdouble)), driDispatchRemapTable[VertexAttrib1dARB_remap_index], parameters)
+#define GET_VertexAttrib1dARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1dARB_remap_index])
+#define SET_VertexAttrib1dARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1dARB_remap_index], fn)
+#define CALL_VertexAttrib1dvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLdouble *)), driDispatchRemapTable[VertexAttrib1dvARB_remap_index], parameters)
+#define GET_VertexAttrib1dvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1dvARB_remap_index])
+#define SET_VertexAttrib1dvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1dvARB_remap_index], fn)
+#define CALL_VertexAttrib1fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLfloat)), driDispatchRemapTable[VertexAttrib1fARB_remap_index], parameters)
+#define GET_VertexAttrib1fARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1fARB_remap_index])
+#define SET_VertexAttrib1fARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1fARB_remap_index], fn)
+#define CALL_VertexAttrib1fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), driDispatchRemapTable[VertexAttrib1fvARB_remap_index], parameters)
+#define GET_VertexAttrib1fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1fvARB_remap_index])
+#define SET_VertexAttrib1fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1fvARB_remap_index], fn)
+#define CALL_VertexAttrib1sARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLshort)), driDispatchRemapTable[VertexAttrib1sARB_remap_index], parameters)
+#define GET_VertexAttrib1sARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1sARB_remap_index])
+#define SET_VertexAttrib1sARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1sARB_remap_index], fn)
+#define CALL_VertexAttrib1svARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), driDispatchRemapTable[VertexAttrib1svARB_remap_index], parameters)
+#define GET_VertexAttrib1svARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1svARB_remap_index])
+#define SET_VertexAttrib1svARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1svARB_remap_index], fn)
+#define CALL_VertexAttrib2dARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLdouble, GLdouble)), driDispatchRemapTable[VertexAttrib2dARB_remap_index], parameters)
+#define GET_VertexAttrib2dARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2dARB_remap_index])
+#define SET_VertexAttrib2dARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2dARB_remap_index], fn)
+#define CALL_VertexAttrib2dvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLdouble *)), driDispatchRemapTable[VertexAttrib2dvARB_remap_index], parameters)
+#define GET_VertexAttrib2dvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2dvARB_remap_index])
+#define SET_VertexAttrib2dvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2dvARB_remap_index], fn)
+#define CALL_VertexAttrib2fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLfloat, GLfloat)), driDispatchRemapTable[VertexAttrib2fARB_remap_index], parameters)
+#define GET_VertexAttrib2fARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2fARB_remap_index])
+#define SET_VertexAttrib2fARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2fARB_remap_index], fn)
+#define CALL_VertexAttrib2fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), driDispatchRemapTable[VertexAttrib2fvARB_remap_index], parameters)
+#define GET_VertexAttrib2fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2fvARB_remap_index])
+#define SET_VertexAttrib2fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2fvARB_remap_index], fn)
+#define CALL_VertexAttrib2sARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLshort, GLshort)), driDispatchRemapTable[VertexAttrib2sARB_remap_index], parameters)
+#define GET_VertexAttrib2sARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2sARB_remap_index])
+#define SET_VertexAttrib2sARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2sARB_remap_index], fn)
+#define CALL_VertexAttrib2svARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), driDispatchRemapTable[VertexAttrib2svARB_remap_index], parameters)
+#define GET_VertexAttrib2svARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2svARB_remap_index])
+#define SET_VertexAttrib2svARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2svARB_remap_index], fn)
+#define CALL_VertexAttrib3dARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLdouble, GLdouble, GLdouble)), driDispatchRemapTable[VertexAttrib3dARB_remap_index], parameters)
+#define GET_VertexAttrib3dARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3dARB_remap_index])
+#define SET_VertexAttrib3dARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3dARB_remap_index], fn)
+#define CALL_VertexAttrib3dvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLdouble *)), driDispatchRemapTable[VertexAttrib3dvARB_remap_index], parameters)
+#define GET_VertexAttrib3dvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3dvARB_remap_index])
+#define SET_VertexAttrib3dvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3dvARB_remap_index], fn)
+#define CALL_VertexAttrib3fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[VertexAttrib3fARB_remap_index], parameters)
+#define GET_VertexAttrib3fARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3fARB_remap_index])
+#define SET_VertexAttrib3fARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3fARB_remap_index], fn)
+#define CALL_VertexAttrib3fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), driDispatchRemapTable[VertexAttrib3fvARB_remap_index], parameters)
+#define GET_VertexAttrib3fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3fvARB_remap_index])
+#define SET_VertexAttrib3fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3fvARB_remap_index], fn)
+#define CALL_VertexAttrib3sARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLshort, GLshort, GLshort)), driDispatchRemapTable[VertexAttrib3sARB_remap_index], parameters)
+#define GET_VertexAttrib3sARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3sARB_remap_index])
+#define SET_VertexAttrib3sARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3sARB_remap_index], fn)
+#define CALL_VertexAttrib3svARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), driDispatchRemapTable[VertexAttrib3svARB_remap_index], parameters)
+#define GET_VertexAttrib3svARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3svARB_remap_index])
+#define SET_VertexAttrib3svARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3svARB_remap_index], fn)
+#define CALL_VertexAttrib4NbvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLbyte *)), driDispatchRemapTable[VertexAttrib4NbvARB_remap_index], parameters)
+#define GET_VertexAttrib4NbvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NbvARB_remap_index])
+#define SET_VertexAttrib4NbvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NbvARB_remap_index], fn)
+#define CALL_VertexAttrib4NivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLint *)), driDispatchRemapTable[VertexAttrib4NivARB_remap_index], parameters)
+#define GET_VertexAttrib4NivARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NivARB_remap_index])
+#define SET_VertexAttrib4NivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NivARB_remap_index], fn)
+#define CALL_VertexAttrib4NsvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), driDispatchRemapTable[VertexAttrib4NsvARB_remap_index], parameters)
+#define GET_VertexAttrib4NsvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NsvARB_remap_index])
+#define SET_VertexAttrib4NsvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NsvARB_remap_index], fn)
+#define CALL_VertexAttrib4NubARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte)), driDispatchRemapTable[VertexAttrib4NubARB_remap_index], parameters)
+#define GET_VertexAttrib4NubARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NubARB_remap_index])
+#define SET_VertexAttrib4NubARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NubARB_remap_index], fn)
+#define CALL_VertexAttrib4NubvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLubyte *)), driDispatchRemapTable[VertexAttrib4NubvARB_remap_index], parameters)
+#define GET_VertexAttrib4NubvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NubvARB_remap_index])
+#define SET_VertexAttrib4NubvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NubvARB_remap_index], fn)
+#define CALL_VertexAttrib4NuivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLuint *)), driDispatchRemapTable[VertexAttrib4NuivARB_remap_index], parameters)
+#define GET_VertexAttrib4NuivARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NuivARB_remap_index])
+#define SET_VertexAttrib4NuivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NuivARB_remap_index], fn)
+#define CALL_VertexAttrib4NusvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLushort *)), driDispatchRemapTable[VertexAttrib4NusvARB_remap_index], parameters)
+#define GET_VertexAttrib4NusvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NusvARB_remap_index])
+#define SET_VertexAttrib4NusvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NusvARB_remap_index], fn)
+#define CALL_VertexAttrib4bvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLbyte *)), driDispatchRemapTable[VertexAttrib4bvARB_remap_index], parameters)
+#define GET_VertexAttrib4bvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4bvARB_remap_index])
+#define SET_VertexAttrib4bvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4bvARB_remap_index], fn)
+#define CALL_VertexAttrib4dARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble)), driDispatchRemapTable[VertexAttrib4dARB_remap_index], parameters)
+#define GET_VertexAttrib4dARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4dARB_remap_index])
+#define SET_VertexAttrib4dARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4dARB_remap_index], fn)
+#define CALL_VertexAttrib4dvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLdouble *)), driDispatchRemapTable[VertexAttrib4dvARB_remap_index], parameters)
+#define GET_VertexAttrib4dvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4dvARB_remap_index])
+#define SET_VertexAttrib4dvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4dvARB_remap_index], fn)
+#define CALL_VertexAttrib4fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[VertexAttrib4fARB_remap_index], parameters)
+#define GET_VertexAttrib4fARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4fARB_remap_index])
+#define SET_VertexAttrib4fARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4fARB_remap_index], fn)
+#define CALL_VertexAttrib4fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), driDispatchRemapTable[VertexAttrib4fvARB_remap_index], parameters)
+#define GET_VertexAttrib4fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4fvARB_remap_index])
+#define SET_VertexAttrib4fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4fvARB_remap_index], fn)
+#define CALL_VertexAttrib4ivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLint *)), driDispatchRemapTable[VertexAttrib4ivARB_remap_index], parameters)
+#define GET_VertexAttrib4ivARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4ivARB_remap_index])
+#define SET_VertexAttrib4ivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4ivARB_remap_index], fn)
+#define CALL_VertexAttrib4sARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLshort, GLshort, GLshort, GLshort)), driDispatchRemapTable[VertexAttrib4sARB_remap_index], parameters)
+#define GET_VertexAttrib4sARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4sARB_remap_index])
+#define SET_VertexAttrib4sARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4sARB_remap_index], fn)
+#define CALL_VertexAttrib4svARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), driDispatchRemapTable[VertexAttrib4svARB_remap_index], parameters)
+#define GET_VertexAttrib4svARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4svARB_remap_index])
+#define SET_VertexAttrib4svARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4svARB_remap_index], fn)
+#define CALL_VertexAttrib4ubvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLubyte *)), driDispatchRemapTable[VertexAttrib4ubvARB_remap_index], parameters)
+#define GET_VertexAttrib4ubvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4ubvARB_remap_index])
+#define SET_VertexAttrib4ubvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4ubvARB_remap_index], fn)
+#define CALL_VertexAttrib4uivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLuint *)), driDispatchRemapTable[VertexAttrib4uivARB_remap_index], parameters)
+#define GET_VertexAttrib4uivARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4uivARB_remap_index])
+#define SET_VertexAttrib4uivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4uivARB_remap_index], fn)
+#define CALL_VertexAttrib4usvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLushort *)), driDispatchRemapTable[VertexAttrib4usvARB_remap_index], parameters)
+#define GET_VertexAttrib4usvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4usvARB_remap_index])
+#define SET_VertexAttrib4usvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4usvARB_remap_index], fn)
+#define CALL_VertexAttribPointerARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *)), driDispatchRemapTable[VertexAttribPointerARB_remap_index], parameters)
+#define GET_VertexAttribPointerARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribPointerARB_remap_index])
+#define SET_VertexAttribPointerARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribPointerARB_remap_index], fn)
+#define CALL_BindBufferARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint)), driDispatchRemapTable[BindBufferARB_remap_index], parameters)
+#define GET_BindBufferARB(disp) GET_by_offset(disp, driDispatchRemapTable[BindBufferARB_remap_index])
+#define SET_BindBufferARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BindBufferARB_remap_index], fn)
+#define CALL_BufferDataARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizeiptrARB, const GLvoid *, GLenum)), driDispatchRemapTable[BufferDataARB_remap_index], parameters)
+#define GET_BufferDataARB(disp) GET_by_offset(disp, driDispatchRemapTable[BufferDataARB_remap_index])
+#define SET_BufferDataARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BufferDataARB_remap_index], fn)
+#define CALL_BufferSubDataARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLintptrARB, GLsizeiptrARB, const GLvoid *)), driDispatchRemapTable[BufferSubDataARB_remap_index], parameters)
+#define GET_BufferSubDataARB(disp) GET_by_offset(disp, driDispatchRemapTable[BufferSubDataARB_remap_index])
+#define SET_BufferSubDataARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BufferSubDataARB_remap_index], fn)
+#define CALL_DeleteBuffersARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), driDispatchRemapTable[DeleteBuffersARB_remap_index], parameters)
+#define GET_DeleteBuffersARB(disp) GET_by_offset(disp, driDispatchRemapTable[DeleteBuffersARB_remap_index])
+#define SET_DeleteBuffersARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DeleteBuffersARB_remap_index], fn)
+#define CALL_GenBuffersARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), driDispatchRemapTable[GenBuffersARB_remap_index], parameters)
+#define GET_GenBuffersARB(disp) GET_by_offset(disp, driDispatchRemapTable[GenBuffersARB_remap_index])
+#define SET_GenBuffersARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GenBuffersARB_remap_index], fn)
+#define CALL_GetBufferParameterivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), driDispatchRemapTable[GetBufferParameterivARB_remap_index], parameters)
+#define GET_GetBufferParameterivARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetBufferParameterivARB_remap_index])
+#define SET_GetBufferParameterivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetBufferParameterivARB_remap_index], fn)
+#define CALL_GetBufferPointervARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLvoid **)), driDispatchRemapTable[GetBufferPointervARB_remap_index], parameters)
+#define GET_GetBufferPointervARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetBufferPointervARB_remap_index])
+#define SET_GetBufferPointervARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetBufferPointervARB_remap_index], fn)
+#define CALL_GetBufferSubDataARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLintptrARB, GLsizeiptrARB, GLvoid *)), driDispatchRemapTable[GetBufferSubDataARB_remap_index], parameters)
+#define GET_GetBufferSubDataARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetBufferSubDataARB_remap_index])
+#define SET_GetBufferSubDataARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetBufferSubDataARB_remap_index], fn)
+#define CALL_IsBufferARB(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[IsBufferARB_remap_index], parameters)
+#define GET_IsBufferARB(disp) GET_by_offset(disp, driDispatchRemapTable[IsBufferARB_remap_index])
+#define SET_IsBufferARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IsBufferARB_remap_index], fn)
+#define CALL_MapBufferARB(disp, parameters) CALL_by_offset(disp, (GLvoid * (GLAPIENTRYP)(GLenum, GLenum)), driDispatchRemapTable[MapBufferARB_remap_index], parameters)
+#define GET_MapBufferARB(disp) GET_by_offset(disp, driDispatchRemapTable[MapBufferARB_remap_index])
+#define SET_MapBufferARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[MapBufferARB_remap_index], fn)
+#define CALL_UnmapBufferARB(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLenum)), driDispatchRemapTable[UnmapBufferARB_remap_index], parameters)
+#define GET_UnmapBufferARB(disp) GET_by_offset(disp, driDispatchRemapTable[UnmapBufferARB_remap_index])
+#define SET_UnmapBufferARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[UnmapBufferARB_remap_index], fn)
+#define CALL_BeginQueryARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint)), driDispatchRemapTable[BeginQueryARB_remap_index], parameters)
+#define GET_BeginQueryARB(disp) GET_by_offset(disp, driDispatchRemapTable[BeginQueryARB_remap_index])
+#define SET_BeginQueryARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BeginQueryARB_remap_index], fn)
+#define CALL_DeleteQueriesARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), driDispatchRemapTable[DeleteQueriesARB_remap_index], parameters)
+#define GET_DeleteQueriesARB(disp) GET_by_offset(disp, driDispatchRemapTable[DeleteQueriesARB_remap_index])
+#define SET_DeleteQueriesARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DeleteQueriesARB_remap_index], fn)
+#define CALL_EndQueryARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), driDispatchRemapTable[EndQueryARB_remap_index], parameters)
+#define GET_EndQueryARB(disp) GET_by_offset(disp, driDispatchRemapTable[EndQueryARB_remap_index])
+#define SET_EndQueryARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[EndQueryARB_remap_index], fn)
+#define CALL_GenQueriesARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), driDispatchRemapTable[GenQueriesARB_remap_index], parameters)
+#define GET_GenQueriesARB(disp) GET_by_offset(disp, driDispatchRemapTable[GenQueriesARB_remap_index])
+#define SET_GenQueriesARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GenQueriesARB_remap_index], fn)
+#define CALL_GetQueryObjectivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint *)), driDispatchRemapTable[GetQueryObjectivARB_remap_index], parameters)
+#define GET_GetQueryObjectivARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetQueryObjectivARB_remap_index])
+#define SET_GetQueryObjectivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetQueryObjectivARB_remap_index], fn)
+#define CALL_GetQueryObjectuivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLuint *)), driDispatchRemapTable[GetQueryObjectuivARB_remap_index], parameters)
+#define GET_GetQueryObjectuivARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetQueryObjectuivARB_remap_index])
+#define SET_GetQueryObjectuivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetQueryObjectuivARB_remap_index], fn)
+#define CALL_GetQueryivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), driDispatchRemapTable[GetQueryivARB_remap_index], parameters)
+#define GET_GetQueryivARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetQueryivARB_remap_index])
+#define SET_GetQueryivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetQueryivARB_remap_index], fn)
+#define CALL_IsQueryARB(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[IsQueryARB_remap_index], parameters)
+#define GET_IsQueryARB(disp) GET_by_offset(disp, driDispatchRemapTable[IsQueryARB_remap_index])
+#define SET_IsQueryARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IsQueryARB_remap_index], fn)
+#define CALL_AttachObjectARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLhandleARB)), driDispatchRemapTable[AttachObjectARB_remap_index], parameters)
+#define GET_AttachObjectARB(disp) GET_by_offset(disp, driDispatchRemapTable[AttachObjectARB_remap_index])
+#define SET_AttachObjectARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[AttachObjectARB_remap_index], fn)
+#define CALL_CompileShaderARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB)), driDispatchRemapTable[CompileShaderARB_remap_index], parameters)
+#define GET_CompileShaderARB(disp) GET_by_offset(disp, driDispatchRemapTable[CompileShaderARB_remap_index])
+#define SET_CompileShaderARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CompileShaderARB_remap_index], fn)
+#define CALL_CreateProgramObjectARB(disp, parameters) CALL_by_offset(disp, (GLhandleARB (GLAPIENTRYP)(void)), driDispatchRemapTable[CreateProgramObjectARB_remap_index], parameters)
+#define GET_CreateProgramObjectARB(disp) GET_by_offset(disp, driDispatchRemapTable[CreateProgramObjectARB_remap_index])
+#define SET_CreateProgramObjectARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CreateProgramObjectARB_remap_index], fn)
+#define CALL_CreateShaderObjectARB(disp, parameters) CALL_by_offset(disp, (GLhandleARB (GLAPIENTRYP)(GLenum)), driDispatchRemapTable[CreateShaderObjectARB_remap_index], parameters)
+#define GET_CreateShaderObjectARB(disp) GET_by_offset(disp, driDispatchRemapTable[CreateShaderObjectARB_remap_index])
+#define SET_CreateShaderObjectARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CreateShaderObjectARB_remap_index], fn)
+#define CALL_DeleteObjectARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB)), driDispatchRemapTable[DeleteObjectARB_remap_index], parameters)
+#define GET_DeleteObjectARB(disp) GET_by_offset(disp, driDispatchRemapTable[DeleteObjectARB_remap_index])
+#define SET_DeleteObjectARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DeleteObjectARB_remap_index], fn)
+#define CALL_DetachObjectARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLhandleARB)), driDispatchRemapTable[DetachObjectARB_remap_index], parameters)
+#define GET_DetachObjectARB(disp) GET_by_offset(disp, driDispatchRemapTable[DetachObjectARB_remap_index])
+#define SET_DetachObjectARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DetachObjectARB_remap_index], fn)
+#define CALL_GetActiveUniformARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *)), driDispatchRemapTable[GetActiveUniformARB_remap_index], parameters)
+#define GET_GetActiveUniformARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetActiveUniformARB_remap_index])
+#define SET_GetActiveUniformARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetActiveUniformARB_remap_index], fn)
+#define CALL_GetAttachedObjectsARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLsizei, GLsizei *, GLhandleARB *)), driDispatchRemapTable[GetAttachedObjectsARB_remap_index], parameters)
+#define GET_GetAttachedObjectsARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetAttachedObjectsARB_remap_index])
+#define SET_GetAttachedObjectsARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetAttachedObjectsARB_remap_index], fn)
+#define CALL_GetHandleARB(disp, parameters) CALL_by_offset(disp, (GLhandleARB (GLAPIENTRYP)(GLenum)), driDispatchRemapTable[GetHandleARB_remap_index], parameters)
+#define GET_GetHandleARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetHandleARB_remap_index])
+#define SET_GetHandleARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetHandleARB_remap_index], fn)
+#define CALL_GetInfoLogARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLsizei, GLsizei *, GLcharARB *)), driDispatchRemapTable[GetInfoLogARB_remap_index], parameters)
+#define GET_GetInfoLogARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetInfoLogARB_remap_index])
+#define SET_GetInfoLogARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetInfoLogARB_remap_index], fn)
+#define CALL_GetObjectParameterfvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLenum, GLfloat *)), driDispatchRemapTable[GetObjectParameterfvARB_remap_index], parameters)
+#define GET_GetObjectParameterfvARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetObjectParameterfvARB_remap_index])
+#define SET_GetObjectParameterfvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetObjectParameterfvARB_remap_index], fn)
+#define CALL_GetObjectParameterivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLenum, GLint *)), driDispatchRemapTable[GetObjectParameterivARB_remap_index], parameters)
+#define GET_GetObjectParameterivARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetObjectParameterivARB_remap_index])
+#define SET_GetObjectParameterivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetObjectParameterivARB_remap_index], fn)
+#define CALL_GetShaderSourceARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLsizei, GLsizei *, GLcharARB *)), driDispatchRemapTable[GetShaderSourceARB_remap_index], parameters)
+#define GET_GetShaderSourceARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetShaderSourceARB_remap_index])
+#define SET_GetShaderSourceARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetShaderSourceARB_remap_index], fn)
+#define CALL_GetUniformLocationARB(disp, parameters) CALL_by_offset(disp, (GLint (GLAPIENTRYP)(GLhandleARB, const GLcharARB *)), driDispatchRemapTable[GetUniformLocationARB_remap_index], parameters)
+#define GET_GetUniformLocationARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetUniformLocationARB_remap_index])
+#define SET_GetUniformLocationARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetUniformLocationARB_remap_index], fn)
+#define CALL_GetUniformfvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLint, GLfloat *)), driDispatchRemapTable[GetUniformfvARB_remap_index], parameters)
+#define GET_GetUniformfvARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetUniformfvARB_remap_index])
+#define SET_GetUniformfvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetUniformfvARB_remap_index], fn)
+#define CALL_GetUniformivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLint, GLint *)), driDispatchRemapTable[GetUniformivARB_remap_index], parameters)
+#define GET_GetUniformivARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetUniformivARB_remap_index])
+#define SET_GetUniformivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetUniformivARB_remap_index], fn)
+#define CALL_LinkProgramARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB)), driDispatchRemapTable[LinkProgramARB_remap_index], parameters)
+#define GET_LinkProgramARB(disp) GET_by_offset(disp, driDispatchRemapTable[LinkProgramARB_remap_index])
+#define SET_LinkProgramARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[LinkProgramARB_remap_index], fn)
+#define CALL_ShaderSourceARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLsizei, const GLcharARB **, const GLint *)), driDispatchRemapTable[ShaderSourceARB_remap_index], parameters)
+#define GET_ShaderSourceARB(disp) GET_by_offset(disp, driDispatchRemapTable[ShaderSourceARB_remap_index])
+#define SET_ShaderSourceARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ShaderSourceARB_remap_index], fn)
+#define CALL_Uniform1fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLfloat)), driDispatchRemapTable[Uniform1fARB_remap_index], parameters)
+#define GET_Uniform1fARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform1fARB_remap_index])
+#define SET_Uniform1fARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform1fARB_remap_index], fn)
+#define CALL_Uniform1fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLfloat *)), driDispatchRemapTable[Uniform1fvARB_remap_index], parameters)
+#define GET_Uniform1fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform1fvARB_remap_index])
+#define SET_Uniform1fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform1fvARB_remap_index], fn)
+#define CALL_Uniform1iARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint)), driDispatchRemapTable[Uniform1iARB_remap_index], parameters)
+#define GET_Uniform1iARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform1iARB_remap_index])
+#define SET_Uniform1iARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform1iARB_remap_index], fn)
+#define CALL_Uniform1ivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLint *)), driDispatchRemapTable[Uniform1ivARB_remap_index], parameters)
+#define GET_Uniform1ivARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform1ivARB_remap_index])
+#define SET_Uniform1ivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform1ivARB_remap_index], fn)
+#define CALL_Uniform2fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLfloat, GLfloat)), driDispatchRemapTable[Uniform2fARB_remap_index], parameters)
+#define GET_Uniform2fARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform2fARB_remap_index])
+#define SET_Uniform2fARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform2fARB_remap_index], fn)
+#define CALL_Uniform2fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLfloat *)), driDispatchRemapTable[Uniform2fvARB_remap_index], parameters)
+#define GET_Uniform2fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform2fvARB_remap_index])
+#define SET_Uniform2fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform2fvARB_remap_index], fn)
+#define CALL_Uniform2iARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint)), driDispatchRemapTable[Uniform2iARB_remap_index], parameters)
+#define GET_Uniform2iARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform2iARB_remap_index])
+#define SET_Uniform2iARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform2iARB_remap_index], fn)
+#define CALL_Uniform2ivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLint *)), driDispatchRemapTable[Uniform2ivARB_remap_index], parameters)
+#define GET_Uniform2ivARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform2ivARB_remap_index])
+#define SET_Uniform2ivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform2ivARB_remap_index], fn)
+#define CALL_Uniform3fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[Uniform3fARB_remap_index], parameters)
+#define GET_Uniform3fARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform3fARB_remap_index])
+#define SET_Uniform3fARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform3fARB_remap_index], fn)
+#define CALL_Uniform3fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLfloat *)), driDispatchRemapTable[Uniform3fvARB_remap_index], parameters)
+#define GET_Uniform3fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform3fvARB_remap_index])
+#define SET_Uniform3fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform3fvARB_remap_index], fn)
+#define CALL_Uniform3iARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint, GLint)), driDispatchRemapTable[Uniform3iARB_remap_index], parameters)
+#define GET_Uniform3iARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform3iARB_remap_index])
+#define SET_Uniform3iARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform3iARB_remap_index], fn)
+#define CALL_Uniform3ivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLint *)), driDispatchRemapTable[Uniform3ivARB_remap_index], parameters)
+#define GET_Uniform3ivARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform3ivARB_remap_index])
+#define SET_Uniform3ivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform3ivARB_remap_index], fn)
+#define CALL_Uniform4fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLfloat, GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[Uniform4fARB_remap_index], parameters)
+#define GET_Uniform4fARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform4fARB_remap_index])
+#define SET_Uniform4fARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform4fARB_remap_index], fn)
+#define CALL_Uniform4fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLfloat *)), driDispatchRemapTable[Uniform4fvARB_remap_index], parameters)
+#define GET_Uniform4fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform4fvARB_remap_index])
+#define SET_Uniform4fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform4fvARB_remap_index], fn)
+#define CALL_Uniform4iARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint, GLint, GLint)), driDispatchRemapTable[Uniform4iARB_remap_index], parameters)
+#define GET_Uniform4iARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform4iARB_remap_index])
+#define SET_Uniform4iARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform4iARB_remap_index], fn)
+#define CALL_Uniform4ivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLint *)), driDispatchRemapTable[Uniform4ivARB_remap_index], parameters)
+#define GET_Uniform4ivARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform4ivARB_remap_index])
+#define SET_Uniform4ivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform4ivARB_remap_index], fn)
+#define CALL_UniformMatrix2fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, GLboolean, const GLfloat *)), driDispatchRemapTable[UniformMatrix2fvARB_remap_index], parameters)
+#define GET_UniformMatrix2fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[UniformMatrix2fvARB_remap_index])
+#define SET_UniformMatrix2fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[UniformMatrix2fvARB_remap_index], fn)
+#define CALL_UniformMatrix3fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, GLboolean, const GLfloat *)), driDispatchRemapTable[UniformMatrix3fvARB_remap_index], parameters)
+#define GET_UniformMatrix3fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[UniformMatrix3fvARB_remap_index])
+#define SET_UniformMatrix3fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[UniformMatrix3fvARB_remap_index], fn)
+#define CALL_UniformMatrix4fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, GLboolean, const GLfloat *)), driDispatchRemapTable[UniformMatrix4fvARB_remap_index], parameters)
+#define GET_UniformMatrix4fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[UniformMatrix4fvARB_remap_index])
+#define SET_UniformMatrix4fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[UniformMatrix4fvARB_remap_index], fn)
+#define CALL_UseProgramObjectARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB)), driDispatchRemapTable[UseProgramObjectARB_remap_index], parameters)
+#define GET_UseProgramObjectARB(disp) GET_by_offset(disp, driDispatchRemapTable[UseProgramObjectARB_remap_index])
+#define SET_UseProgramObjectARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[UseProgramObjectARB_remap_index], fn)
+#define CALL_ValidateProgramARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB)), driDispatchRemapTable[ValidateProgramARB_remap_index], parameters)
+#define GET_ValidateProgramARB(disp) GET_by_offset(disp, driDispatchRemapTable[ValidateProgramARB_remap_index])
+#define SET_ValidateProgramARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ValidateProgramARB_remap_index], fn)
+#define CALL_BindAttribLocationARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLuint, const GLcharARB *)), driDispatchRemapTable[BindAttribLocationARB_remap_index], parameters)
+#define GET_BindAttribLocationARB(disp) GET_by_offset(disp, driDispatchRemapTable[BindAttribLocationARB_remap_index])
+#define SET_BindAttribLocationARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BindAttribLocationARB_remap_index], fn)
+#define CALL_GetActiveAttribARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *)), driDispatchRemapTable[GetActiveAttribARB_remap_index], parameters)
+#define GET_GetActiveAttribARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetActiveAttribARB_remap_index])
+#define SET_GetActiveAttribARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetActiveAttribARB_remap_index], fn)
+#define CALL_GetAttribLocationARB(disp, parameters) CALL_by_offset(disp, (GLint (GLAPIENTRYP)(GLhandleARB, const GLcharARB *)), driDispatchRemapTable[GetAttribLocationARB_remap_index], parameters)
+#define GET_GetAttribLocationARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetAttribLocationARB_remap_index])
+#define SET_GetAttribLocationARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetAttribLocationARB_remap_index], fn)
+#define CALL_DrawBuffersARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLenum *)), driDispatchRemapTable[DrawBuffersARB_remap_index], parameters)
+#define GET_DrawBuffersARB(disp) GET_by_offset(disp, driDispatchRemapTable[DrawBuffersARB_remap_index])
+#define SET_DrawBuffersARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DrawBuffersARB_remap_index], fn)
+#define CALL_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_BindVertexArray(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[BindVertexArray_remap_index], parameters)
+#define GET_BindVertexArray(disp) GET_by_offset(disp, driDispatchRemapTable[BindVertexArray_remap_index])
+#define SET_BindVertexArray(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BindVertexArray_remap_index], fn)
+#define CALL_GenVertexArrays(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), driDispatchRemapTable[GenVertexArrays_remap_index], parameters)
+#define GET_GenVertexArrays(disp) GET_by_offset(disp, driDispatchRemapTable[GenVertexArrays_remap_index])
+#define SET_GenVertexArrays(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GenVertexArrays_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_ClientWaitSync(disp, parameters) CALL_by_offset(disp, (GLenum (GLAPIENTRYP)(GLsync, GLbitfield, GLuint64)), driDispatchRemapTable[ClientWaitSync_remap_index], parameters)
+#define GET_ClientWaitSync(disp) GET_by_offset(disp, driDispatchRemapTable[ClientWaitSync_remap_index])
+#define SET_ClientWaitSync(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ClientWaitSync_remap_index], fn)
+#define CALL_DeleteSync(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsync)), driDispatchRemapTable[DeleteSync_remap_index], parameters)
+#define GET_DeleteSync(disp) GET_by_offset(disp, driDispatchRemapTable[DeleteSync_remap_index])
+#define SET_DeleteSync(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DeleteSync_remap_index], fn)
+#define CALL_FenceSync(disp, parameters) CALL_by_offset(disp, (GLsync (GLAPIENTRYP)(GLenum, GLbitfield)), driDispatchRemapTable[FenceSync_remap_index], parameters)
+#define GET_FenceSync(disp) GET_by_offset(disp, driDispatchRemapTable[FenceSync_remap_index])
+#define SET_FenceSync(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FenceSync_remap_index], fn)
+#define CALL_GetInteger64v(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint64 *)), driDispatchRemapTable[GetInteger64v_remap_index], parameters)
+#define GET_GetInteger64v(disp) GET_by_offset(disp, driDispatchRemapTable[GetInteger64v_remap_index])
+#define SET_GetInteger64v(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetInteger64v_remap_index], fn)
+#define CALL_GetSynciv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsync, GLenum, GLsizei, GLsizei *, GLint *)), driDispatchRemapTable[GetSynciv_remap_index], parameters)
+#define GET_GetSynciv(disp) GET_by_offset(disp, driDispatchRemapTable[GetSynciv_remap_index])
+#define SET_GetSynciv(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetSynciv_remap_index], fn)
+#define CALL_IsSync(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLsync)), driDispatchRemapTable[IsSync_remap_index], parameters)
+#define GET_IsSync(disp) GET_by_offset(disp, driDispatchRemapTable[IsSync_remap_index])
+#define SET_IsSync(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IsSync_remap_index], fn)
+#define CALL_WaitSync(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsync, GLbitfield, GLuint64)), driDispatchRemapTable[WaitSync_remap_index], parameters)
+#define GET_WaitSync(disp) GET_by_offset(disp, driDispatchRemapTable[WaitSync_remap_index])
+#define SET_WaitSync(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WaitSync_remap_index], fn)
+#define CALL_DrawElementsBaseVertex(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, GLenum, const GLvoid *, GLint)), driDispatchRemapTable[DrawElementsBaseVertex_remap_index], parameters)
+#define GET_DrawElementsBaseVertex(disp) GET_by_offset(disp, driDispatchRemapTable[DrawElementsBaseVertex_remap_index])
+#define SET_DrawElementsBaseVertex(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DrawElementsBaseVertex_remap_index], fn)
+#define CALL_DrawRangeElementsBaseVertex(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *, GLint)), driDispatchRemapTable[DrawRangeElementsBaseVertex_remap_index], parameters)
+#define GET_DrawRangeElementsBaseVertex(disp) GET_by_offset(disp, driDispatchRemapTable[DrawRangeElementsBaseVertex_remap_index])
+#define SET_DrawRangeElementsBaseVertex(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DrawRangeElementsBaseVertex_remap_index], fn)
+#define CALL_MultiDrawElementsBaseVertex(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLsizei *, GLenum, const GLvoid **, GLsizei, const GLint *)), driDispatchRemapTable[MultiDrawElementsBaseVertex_remap_index], parameters)
+#define GET_MultiDrawElementsBaseVertex(disp) GET_by_offset(disp, driDispatchRemapTable[MultiDrawElementsBaseVertex_remap_index])
+#define SET_MultiDrawElementsBaseVertex(disp, fn) SET_by_offset(disp, driDispatchRemapTable[MultiDrawElementsBaseVertex_remap_index], fn)
+#define CALL_PolygonOffsetEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat)), driDispatchRemapTable[PolygonOffsetEXT_remap_index], parameters)
+#define GET_PolygonOffsetEXT(disp) GET_by_offset(disp, driDispatchRemapTable[PolygonOffsetEXT_remap_index])
+#define SET_PolygonOffsetEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PolygonOffsetEXT_remap_index], fn)
+#define CALL_GetPixelTexGenParameterfvSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat *)), driDispatchRemapTable[GetPixelTexGenParameterfvSGIS_remap_index], parameters)
+#define GET_GetPixelTexGenParameterfvSGIS(disp) GET_by_offset(disp, driDispatchRemapTable[GetPixelTexGenParameterfvSGIS_remap_index])
+#define SET_GetPixelTexGenParameterfvSGIS(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetPixelTexGenParameterfvSGIS_remap_index], fn)
+#define CALL_GetPixelTexGenParameterivSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint *)), driDispatchRemapTable[GetPixelTexGenParameterivSGIS_remap_index], parameters)
+#define GET_GetPixelTexGenParameterivSGIS(disp) GET_by_offset(disp, driDispatchRemapTable[GetPixelTexGenParameterivSGIS_remap_index])
+#define SET_GetPixelTexGenParameterivSGIS(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetPixelTexGenParameterivSGIS_remap_index], fn)
+#define CALL_PixelTexGenParameterfSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat)), driDispatchRemapTable[PixelTexGenParameterfSGIS_remap_index], parameters)
+#define GET_PixelTexGenParameterfSGIS(disp) GET_by_offset(disp, driDispatchRemapTable[PixelTexGenParameterfSGIS_remap_index])
+#define SET_PixelTexGenParameterfSGIS(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PixelTexGenParameterfSGIS_remap_index], fn)
+#define CALL_PixelTexGenParameterfvSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLfloat *)), driDispatchRemapTable[PixelTexGenParameterfvSGIS_remap_index], parameters)
+#define GET_PixelTexGenParameterfvSGIS(disp) GET_by_offset(disp, driDispatchRemapTable[PixelTexGenParameterfvSGIS_remap_index])
+#define SET_PixelTexGenParameterfvSGIS(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PixelTexGenParameterfvSGIS_remap_index], fn)
+#define CALL_PixelTexGenParameteriSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint)), driDispatchRemapTable[PixelTexGenParameteriSGIS_remap_index], parameters)
+#define GET_PixelTexGenParameteriSGIS(disp) GET_by_offset(disp, driDispatchRemapTable[PixelTexGenParameteriSGIS_remap_index])
+#define SET_PixelTexGenParameteriSGIS(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PixelTexGenParameteriSGIS_remap_index], fn)
+#define CALL_PixelTexGenParameterivSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLint *)), driDispatchRemapTable[PixelTexGenParameterivSGIS_remap_index], parameters)
+#define GET_PixelTexGenParameterivSGIS(disp) GET_by_offset(disp, driDispatchRemapTable[PixelTexGenParameterivSGIS_remap_index])
+#define SET_PixelTexGenParameterivSGIS(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PixelTexGenParameterivSGIS_remap_index], fn)
+#define CALL_SampleMaskSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLclampf, GLboolean)), driDispatchRemapTable[SampleMaskSGIS_remap_index], parameters)
+#define GET_SampleMaskSGIS(disp) GET_by_offset(disp, driDispatchRemapTable[SampleMaskSGIS_remap_index])
+#define SET_SampleMaskSGIS(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SampleMaskSGIS_remap_index], fn)
+#define CALL_SamplePatternSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), driDispatchRemapTable[SamplePatternSGIS_remap_index], parameters)
+#define GET_SamplePatternSGIS(disp) GET_by_offset(disp, driDispatchRemapTable[SamplePatternSGIS_remap_index])
+#define SET_SamplePatternSGIS(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SamplePatternSGIS_remap_index], fn)
+#define CALL_ColorPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLenum, GLsizei, GLsizei, const GLvoid *)), driDispatchRemapTable[ColorPointerEXT_remap_index], parameters)
+#define GET_ColorPointerEXT(disp) GET_by_offset(disp, driDispatchRemapTable[ColorPointerEXT_remap_index])
+#define SET_ColorPointerEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ColorPointerEXT_remap_index], fn)
+#define CALL_EdgeFlagPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLsizei, const GLboolean *)), driDispatchRemapTable[EdgeFlagPointerEXT_remap_index], parameters)
+#define GET_EdgeFlagPointerEXT(disp) GET_by_offset(disp, driDispatchRemapTable[EdgeFlagPointerEXT_remap_index])
+#define SET_EdgeFlagPointerEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[EdgeFlagPointerEXT_remap_index], fn)
+#define CALL_IndexPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, GLsizei, const GLvoid *)), driDispatchRemapTable[IndexPointerEXT_remap_index], parameters)
+#define GET_IndexPointerEXT(disp) GET_by_offset(disp, driDispatchRemapTable[IndexPointerEXT_remap_index])
+#define SET_IndexPointerEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IndexPointerEXT_remap_index], fn)
+#define CALL_NormalPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, GLsizei, const GLvoid *)), driDispatchRemapTable[NormalPointerEXT_remap_index], parameters)
+#define GET_NormalPointerEXT(disp) GET_by_offset(disp, driDispatchRemapTable[NormalPointerEXT_remap_index])
+#define SET_NormalPointerEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[NormalPointerEXT_remap_index], fn)
+#define CALL_TexCoordPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLenum, GLsizei, GLsizei, const GLvoid *)), driDispatchRemapTable[TexCoordPointerEXT_remap_index], parameters)
+#define GET_TexCoordPointerEXT(disp) GET_by_offset(disp, driDispatchRemapTable[TexCoordPointerEXT_remap_index])
+#define SET_TexCoordPointerEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[TexCoordPointerEXT_remap_index], fn)
+#define CALL_VertexPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLenum, GLsizei, GLsizei, const GLvoid *)), driDispatchRemapTable[VertexPointerEXT_remap_index], parameters)
+#define GET_VertexPointerEXT(disp) GET_by_offset(disp, driDispatchRemapTable[VertexPointerEXT_remap_index])
+#define SET_VertexPointerEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexPointerEXT_remap_index], fn)
+#define CALL_PointParameterfEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat)), driDispatchRemapTable[PointParameterfEXT_remap_index], parameters)
+#define GET_PointParameterfEXT(disp) GET_by_offset(disp, driDispatchRemapTable[PointParameterfEXT_remap_index])
+#define SET_PointParameterfEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PointParameterfEXT_remap_index], fn)
+#define CALL_PointParameterfvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLfloat *)), driDispatchRemapTable[PointParameterfvEXT_remap_index], parameters)
+#define GET_PointParameterfvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[PointParameterfvEXT_remap_index])
+#define SET_PointParameterfvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PointParameterfvEXT_remap_index], fn)
+#define CALL_LockArraysEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei)), driDispatchRemapTable[LockArraysEXT_remap_index], parameters)
+#define GET_LockArraysEXT(disp) GET_by_offset(disp, driDispatchRemapTable[LockArraysEXT_remap_index])
+#define SET_LockArraysEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[LockArraysEXT_remap_index], fn)
+#define CALL_UnlockArraysEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), driDispatchRemapTable[UnlockArraysEXT_remap_index], parameters)
+#define GET_UnlockArraysEXT(disp) GET_by_offset(disp, driDispatchRemapTable[UnlockArraysEXT_remap_index])
+#define SET_UnlockArraysEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[UnlockArraysEXT_remap_index], fn)
+#define CALL_CullParameterdvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLdouble *)), driDispatchRemapTable[CullParameterdvEXT_remap_index], parameters)
+#define GET_CullParameterdvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[CullParameterdvEXT_remap_index])
+#define SET_CullParameterdvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CullParameterdvEXT_remap_index], fn)
+#define CALL_CullParameterfvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat *)), driDispatchRemapTable[CullParameterfvEXT_remap_index], parameters)
+#define GET_CullParameterfvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[CullParameterfvEXT_remap_index])
+#define SET_CullParameterfvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CullParameterfvEXT_remap_index], fn)
+#define CALL_SecondaryColor3bEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLbyte, GLbyte, GLbyte)), driDispatchRemapTable[SecondaryColor3bEXT_remap_index], parameters)
+#define GET_SecondaryColor3bEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3bEXT_remap_index])
+#define SET_SecondaryColor3bEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3bEXT_remap_index], fn)
+#define CALL_SecondaryColor3bvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLbyte *)), driDispatchRemapTable[SecondaryColor3bvEXT_remap_index], parameters)
+#define GET_SecondaryColor3bvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3bvEXT_remap_index])
+#define SET_SecondaryColor3bvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3bvEXT_remap_index], fn)
+#define CALL_SecondaryColor3dEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble, GLdouble)), driDispatchRemapTable[SecondaryColor3dEXT_remap_index], parameters)
+#define GET_SecondaryColor3dEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3dEXT_remap_index])
+#define SET_SecondaryColor3dEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3dEXT_remap_index], fn)
+#define CALL_SecondaryColor3dvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), driDispatchRemapTable[SecondaryColor3dvEXT_remap_index], parameters)
+#define GET_SecondaryColor3dvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3dvEXT_remap_index])
+#define SET_SecondaryColor3dvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3dvEXT_remap_index], fn)
+#define CALL_SecondaryColor3fEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[SecondaryColor3fEXT_remap_index], parameters)
+#define GET_SecondaryColor3fEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3fEXT_remap_index])
+#define SET_SecondaryColor3fEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3fEXT_remap_index], fn)
+#define CALL_SecondaryColor3fvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), driDispatchRemapTable[SecondaryColor3fvEXT_remap_index], parameters)
+#define GET_SecondaryColor3fvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3fvEXT_remap_index])
+#define SET_SecondaryColor3fvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3fvEXT_remap_index], fn)
+#define CALL_SecondaryColor3iEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint)), driDispatchRemapTable[SecondaryColor3iEXT_remap_index], parameters)
+#define GET_SecondaryColor3iEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3iEXT_remap_index])
+#define SET_SecondaryColor3iEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3iEXT_remap_index], fn)
+#define CALL_SecondaryColor3ivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLint *)), driDispatchRemapTable[SecondaryColor3ivEXT_remap_index], parameters)
+#define GET_SecondaryColor3ivEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3ivEXT_remap_index])
+#define SET_SecondaryColor3ivEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3ivEXT_remap_index], fn)
+#define CALL_SecondaryColor3sEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLshort, GLshort, GLshort)), driDispatchRemapTable[SecondaryColor3sEXT_remap_index], parameters)
+#define GET_SecondaryColor3sEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3sEXT_remap_index])
+#define SET_SecondaryColor3sEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3sEXT_remap_index], fn)
+#define CALL_SecondaryColor3svEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLshort *)), driDispatchRemapTable[SecondaryColor3svEXT_remap_index], parameters)
+#define GET_SecondaryColor3svEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3svEXT_remap_index])
+#define SET_SecondaryColor3svEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3svEXT_remap_index], fn)
+#define CALL_SecondaryColor3ubEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLubyte, GLubyte, GLubyte)), driDispatchRemapTable[SecondaryColor3ubEXT_remap_index], parameters)
+#define GET_SecondaryColor3ubEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3ubEXT_remap_index])
+#define SET_SecondaryColor3ubEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3ubEXT_remap_index], fn)
+#define CALL_SecondaryColor3ubvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLubyte *)), driDispatchRemapTable[SecondaryColor3ubvEXT_remap_index], parameters)
+#define GET_SecondaryColor3ubvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3ubvEXT_remap_index])
+#define SET_SecondaryColor3ubvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3ubvEXT_remap_index], fn)
+#define CALL_SecondaryColor3uiEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLuint, GLuint)), driDispatchRemapTable[SecondaryColor3uiEXT_remap_index], parameters)
+#define GET_SecondaryColor3uiEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3uiEXT_remap_index])
+#define SET_SecondaryColor3uiEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3uiEXT_remap_index], fn)
+#define CALL_SecondaryColor3uivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLuint *)), driDispatchRemapTable[SecondaryColor3uivEXT_remap_index], parameters)
+#define GET_SecondaryColor3uivEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3uivEXT_remap_index])
+#define SET_SecondaryColor3uivEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3uivEXT_remap_index], fn)
+#define CALL_SecondaryColor3usEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLushort, GLushort, GLushort)), driDispatchRemapTable[SecondaryColor3usEXT_remap_index], parameters)
+#define GET_SecondaryColor3usEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3usEXT_remap_index])
+#define SET_SecondaryColor3usEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3usEXT_remap_index], fn)
+#define CALL_SecondaryColor3usvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLushort *)), driDispatchRemapTable[SecondaryColor3usvEXT_remap_index], parameters)
+#define GET_SecondaryColor3usvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3usvEXT_remap_index])
+#define SET_SecondaryColor3usvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3usvEXT_remap_index], fn)
+#define CALL_SecondaryColorPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLenum, GLsizei, const GLvoid *)), driDispatchRemapTable[SecondaryColorPointerEXT_remap_index], parameters)
+#define GET_SecondaryColorPointerEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColorPointerEXT_remap_index])
+#define SET_SecondaryColorPointerEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColorPointerEXT_remap_index], fn)
+#define CALL_MultiDrawArraysEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint *, GLsizei *, GLsizei)), driDispatchRemapTable[MultiDrawArraysEXT_remap_index], parameters)
+#define GET_MultiDrawArraysEXT(disp) GET_by_offset(disp, driDispatchRemapTable[MultiDrawArraysEXT_remap_index])
+#define SET_MultiDrawArraysEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[MultiDrawArraysEXT_remap_index], fn)
+#define CALL_MultiDrawElementsEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLsizei *, GLenum, const GLvoid **, GLsizei)), driDispatchRemapTable[MultiDrawElementsEXT_remap_index], parameters)
+#define GET_MultiDrawElementsEXT(disp) GET_by_offset(disp, driDispatchRemapTable[MultiDrawElementsEXT_remap_index])
+#define SET_MultiDrawElementsEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[MultiDrawElementsEXT_remap_index], fn)
+#define CALL_FogCoordPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, const GLvoid *)), driDispatchRemapTable[FogCoordPointerEXT_remap_index], parameters)
+#define GET_FogCoordPointerEXT(disp) GET_by_offset(disp, driDispatchRemapTable[FogCoordPointerEXT_remap_index])
+#define SET_FogCoordPointerEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FogCoordPointerEXT_remap_index], fn)
+#define CALL_FogCoorddEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble)), driDispatchRemapTable[FogCoorddEXT_remap_index], parameters)
+#define GET_FogCoorddEXT(disp) GET_by_offset(disp, driDispatchRemapTable[FogCoorddEXT_remap_index])
+#define SET_FogCoorddEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FogCoorddEXT_remap_index], fn)
+#define CALL_FogCoorddvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), driDispatchRemapTable[FogCoorddvEXT_remap_index], parameters)
+#define GET_FogCoorddvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[FogCoorddvEXT_remap_index])
+#define SET_FogCoorddvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FogCoorddvEXT_remap_index], fn)
+#define CALL_FogCoordfEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat)), driDispatchRemapTable[FogCoordfEXT_remap_index], parameters)
+#define GET_FogCoordfEXT(disp) GET_by_offset(disp, driDispatchRemapTable[FogCoordfEXT_remap_index])
+#define SET_FogCoordfEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FogCoordfEXT_remap_index], fn)
+#define CALL_FogCoordfvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), driDispatchRemapTable[FogCoordfvEXT_remap_index], parameters)
+#define GET_FogCoordfvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[FogCoordfvEXT_remap_index])
+#define SET_FogCoordfvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FogCoordfvEXT_remap_index], fn)
+#define CALL_PixelTexGenSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), driDispatchRemapTable[PixelTexGenSGIX_remap_index], parameters)
+#define GET_PixelTexGenSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[PixelTexGenSGIX_remap_index])
+#define SET_PixelTexGenSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PixelTexGenSGIX_remap_index], fn)
+#define CALL_BlendFuncSeparateEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLenum)), driDispatchRemapTable[BlendFuncSeparateEXT_remap_index], parameters)
+#define GET_BlendFuncSeparateEXT(disp) GET_by_offset(disp, driDispatchRemapTable[BlendFuncSeparateEXT_remap_index])
+#define SET_BlendFuncSeparateEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BlendFuncSeparateEXT_remap_index], fn)
+#define CALL_FlushVertexArrayRangeNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), driDispatchRemapTable[FlushVertexArrayRangeNV_remap_index], parameters)
+#define GET_FlushVertexArrayRangeNV(disp) GET_by_offset(disp, driDispatchRemapTable[FlushVertexArrayRangeNV_remap_index])
+#define SET_FlushVertexArrayRangeNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FlushVertexArrayRangeNV_remap_index], fn)
+#define CALL_VertexArrayRangeNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLvoid *)), driDispatchRemapTable[VertexArrayRangeNV_remap_index], parameters)
+#define GET_VertexArrayRangeNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexArrayRangeNV_remap_index])
+#define SET_VertexArrayRangeNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexArrayRangeNV_remap_index], fn)
+#define CALL_CombinerInputNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLenum, GLenum, GLenum)), driDispatchRemapTable[CombinerInputNV_remap_index], parameters)
+#define GET_CombinerInputNV(disp) GET_by_offset(disp, driDispatchRemapTable[CombinerInputNV_remap_index])
+#define SET_CombinerInputNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CombinerInputNV_remap_index], fn)
+#define CALL_CombinerOutputNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean)), driDispatchRemapTable[CombinerOutputNV_remap_index], parameters)
+#define GET_CombinerOutputNV(disp) GET_by_offset(disp, driDispatchRemapTable[CombinerOutputNV_remap_index])
+#define SET_CombinerOutputNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CombinerOutputNV_remap_index], fn)
+#define CALL_CombinerParameterfNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat)), driDispatchRemapTable[CombinerParameterfNV_remap_index], parameters)
+#define GET_CombinerParameterfNV(disp) GET_by_offset(disp, driDispatchRemapTable[CombinerParameterfNV_remap_index])
+#define SET_CombinerParameterfNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CombinerParameterfNV_remap_index], fn)
+#define CALL_CombinerParameterfvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLfloat *)), driDispatchRemapTable[CombinerParameterfvNV_remap_index], parameters)
+#define GET_CombinerParameterfvNV(disp) GET_by_offset(disp, driDispatchRemapTable[CombinerParameterfvNV_remap_index])
+#define SET_CombinerParameterfvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CombinerParameterfvNV_remap_index], fn)
+#define CALL_CombinerParameteriNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint)), driDispatchRemapTable[CombinerParameteriNV_remap_index], parameters)
+#define GET_CombinerParameteriNV(disp) GET_by_offset(disp, driDispatchRemapTable[CombinerParameteriNV_remap_index])
+#define SET_CombinerParameteriNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CombinerParameteriNV_remap_index], fn)
+#define CALL_CombinerParameterivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLint *)), driDispatchRemapTable[CombinerParameterivNV_remap_index], parameters)
+#define GET_CombinerParameterivNV(disp) GET_by_offset(disp, driDispatchRemapTable[CombinerParameterivNV_remap_index])
+#define SET_CombinerParameterivNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CombinerParameterivNV_remap_index], fn)
+#define CALL_FinalCombinerInputNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLenum)), driDispatchRemapTable[FinalCombinerInputNV_remap_index], parameters)
+#define GET_FinalCombinerInputNV(disp) GET_by_offset(disp, driDispatchRemapTable[FinalCombinerInputNV_remap_index])
+#define SET_FinalCombinerInputNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FinalCombinerInputNV_remap_index], fn)
+#define CALL_GetCombinerInputParameterfvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLenum, GLfloat *)), driDispatchRemapTable[GetCombinerInputParameterfvNV_remap_index], parameters)
+#define GET_GetCombinerInputParameterfvNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetCombinerInputParameterfvNV_remap_index])
+#define SET_GetCombinerInputParameterfvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetCombinerInputParameterfvNV_remap_index], fn)
+#define CALL_GetCombinerInputParameterivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLenum, GLint *)), driDispatchRemapTable[GetCombinerInputParameterivNV_remap_index], parameters)
+#define GET_GetCombinerInputParameterivNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetCombinerInputParameterivNV_remap_index])
+#define SET_GetCombinerInputParameterivNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetCombinerInputParameterivNV_remap_index], fn)
+#define CALL_GetCombinerOutputParameterfvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLfloat *)), driDispatchRemapTable[GetCombinerOutputParameterfvNV_remap_index], parameters)
+#define GET_GetCombinerOutputParameterfvNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetCombinerOutputParameterfvNV_remap_index])
+#define SET_GetCombinerOutputParameterfvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetCombinerOutputParameterfvNV_remap_index], fn)
+#define CALL_GetCombinerOutputParameterivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLint *)), driDispatchRemapTable[GetCombinerOutputParameterivNV_remap_index], parameters)
+#define GET_GetCombinerOutputParameterivNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetCombinerOutputParameterivNV_remap_index])
+#define SET_GetCombinerOutputParameterivNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetCombinerOutputParameterivNV_remap_index], fn)
+#define CALL_GetFinalCombinerInputParameterfvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLfloat *)), driDispatchRemapTable[GetFinalCombinerInputParameterfvNV_remap_index], parameters)
+#define GET_GetFinalCombinerInputParameterfvNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetFinalCombinerInputParameterfvNV_remap_index])
+#define SET_GetFinalCombinerInputParameterfvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetFinalCombinerInputParameterfvNV_remap_index], fn)
+#define CALL_GetFinalCombinerInputParameterivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), driDispatchRemapTable[GetFinalCombinerInputParameterivNV_remap_index], parameters)
+#define GET_GetFinalCombinerInputParameterivNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetFinalCombinerInputParameterivNV_remap_index])
+#define SET_GetFinalCombinerInputParameterivNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetFinalCombinerInputParameterivNV_remap_index], fn)
+#define CALL_ResizeBuffersMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), driDispatchRemapTable[ResizeBuffersMESA_remap_index], parameters)
+#define GET_ResizeBuffersMESA(disp) GET_by_offset(disp, driDispatchRemapTable[ResizeBuffersMESA_remap_index])
+#define SET_ResizeBuffersMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ResizeBuffersMESA_remap_index], fn)
+#define CALL_WindowPos2dMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble)), driDispatchRemapTable[WindowPos2dMESA_remap_index], parameters)
+#define GET_WindowPos2dMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos2dMESA_remap_index])
+#define SET_WindowPos2dMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos2dMESA_remap_index], fn)
+#define CALL_WindowPos2dvMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), driDispatchRemapTable[WindowPos2dvMESA_remap_index], parameters)
+#define GET_WindowPos2dvMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos2dvMESA_remap_index])
+#define SET_WindowPos2dvMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos2dvMESA_remap_index], fn)
+#define CALL_WindowPos2fMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat)), driDispatchRemapTable[WindowPos2fMESA_remap_index], parameters)
+#define GET_WindowPos2fMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos2fMESA_remap_index])
+#define SET_WindowPos2fMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos2fMESA_remap_index], fn)
+#define CALL_WindowPos2fvMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), driDispatchRemapTable[WindowPos2fvMESA_remap_index], parameters)
+#define GET_WindowPos2fvMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos2fvMESA_remap_index])
+#define SET_WindowPos2fvMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos2fvMESA_remap_index], fn)
+#define CALL_WindowPos2iMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint)), driDispatchRemapTable[WindowPos2iMESA_remap_index], parameters)
+#define GET_WindowPos2iMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos2iMESA_remap_index])
+#define SET_WindowPos2iMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos2iMESA_remap_index], fn)
+#define CALL_WindowPos2ivMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLint *)), driDispatchRemapTable[WindowPos2ivMESA_remap_index], parameters)
+#define GET_WindowPos2ivMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos2ivMESA_remap_index])
+#define SET_WindowPos2ivMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos2ivMESA_remap_index], fn)
+#define CALL_WindowPos2sMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLshort, GLshort)), driDispatchRemapTable[WindowPos2sMESA_remap_index], parameters)
+#define GET_WindowPos2sMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos2sMESA_remap_index])
+#define SET_WindowPos2sMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos2sMESA_remap_index], fn)
+#define CALL_WindowPos2svMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLshort *)), driDispatchRemapTable[WindowPos2svMESA_remap_index], parameters)
+#define GET_WindowPos2svMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos2svMESA_remap_index])
+#define SET_WindowPos2svMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos2svMESA_remap_index], fn)
+#define CALL_WindowPos3dMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble, GLdouble)), driDispatchRemapTable[WindowPos3dMESA_remap_index], parameters)
+#define GET_WindowPos3dMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos3dMESA_remap_index])
+#define SET_WindowPos3dMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos3dMESA_remap_index], fn)
+#define CALL_WindowPos3dvMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), driDispatchRemapTable[WindowPos3dvMESA_remap_index], parameters)
+#define GET_WindowPos3dvMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos3dvMESA_remap_index])
+#define SET_WindowPos3dvMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos3dvMESA_remap_index], fn)
+#define CALL_WindowPos3fMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[WindowPos3fMESA_remap_index], parameters)
+#define GET_WindowPos3fMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos3fMESA_remap_index])
+#define SET_WindowPos3fMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos3fMESA_remap_index], fn)
+#define CALL_WindowPos3fvMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), driDispatchRemapTable[WindowPos3fvMESA_remap_index], parameters)
+#define GET_WindowPos3fvMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos3fvMESA_remap_index])
+#define SET_WindowPos3fvMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos3fvMESA_remap_index], fn)
+#define CALL_WindowPos3iMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint)), driDispatchRemapTable[WindowPos3iMESA_remap_index], parameters)
+#define GET_WindowPos3iMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos3iMESA_remap_index])
+#define SET_WindowPos3iMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos3iMESA_remap_index], fn)
+#define CALL_WindowPos3ivMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLint *)), driDispatchRemapTable[WindowPos3ivMESA_remap_index], parameters)
+#define GET_WindowPos3ivMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos3ivMESA_remap_index])
+#define SET_WindowPos3ivMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos3ivMESA_remap_index], fn)
+#define CALL_WindowPos3sMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLshort, GLshort, GLshort)), driDispatchRemapTable[WindowPos3sMESA_remap_index], parameters)
+#define GET_WindowPos3sMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos3sMESA_remap_index])
+#define SET_WindowPos3sMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos3sMESA_remap_index], fn)
+#define CALL_WindowPos3svMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLshort *)), driDispatchRemapTable[WindowPos3svMESA_remap_index], parameters)
+#define GET_WindowPos3svMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos3svMESA_remap_index])
+#define SET_WindowPos3svMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos3svMESA_remap_index], fn)
+#define CALL_WindowPos4dMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble, GLdouble, GLdouble)), driDispatchRemapTable[WindowPos4dMESA_remap_index], parameters)
+#define GET_WindowPos4dMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos4dMESA_remap_index])
+#define SET_WindowPos4dMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos4dMESA_remap_index], fn)
+#define CALL_WindowPos4dvMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), driDispatchRemapTable[WindowPos4dvMESA_remap_index], parameters)
+#define GET_WindowPos4dvMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos4dvMESA_remap_index])
+#define SET_WindowPos4dvMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos4dvMESA_remap_index], fn)
+#define CALL_WindowPos4fMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[WindowPos4fMESA_remap_index], parameters)
+#define GET_WindowPos4fMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos4fMESA_remap_index])
+#define SET_WindowPos4fMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos4fMESA_remap_index], fn)
+#define CALL_WindowPos4fvMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), driDispatchRemapTable[WindowPos4fvMESA_remap_index], parameters)
+#define GET_WindowPos4fvMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos4fvMESA_remap_index])
+#define SET_WindowPos4fvMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos4fvMESA_remap_index], fn)
+#define CALL_WindowPos4iMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint, GLint)), driDispatchRemapTable[WindowPos4iMESA_remap_index], parameters)
+#define GET_WindowPos4iMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos4iMESA_remap_index])
+#define SET_WindowPos4iMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos4iMESA_remap_index], fn)
+#define CALL_WindowPos4ivMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLint *)), driDispatchRemapTable[WindowPos4ivMESA_remap_index], parameters)
+#define GET_WindowPos4ivMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos4ivMESA_remap_index])
+#define SET_WindowPos4ivMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos4ivMESA_remap_index], fn)
+#define CALL_WindowPos4sMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLshort, GLshort, GLshort, GLshort)), driDispatchRemapTable[WindowPos4sMESA_remap_index], parameters)
+#define GET_WindowPos4sMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos4sMESA_remap_index])
+#define SET_WindowPos4sMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos4sMESA_remap_index], fn)
+#define CALL_WindowPos4svMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLshort *)), driDispatchRemapTable[WindowPos4svMESA_remap_index], parameters)
+#define GET_WindowPos4svMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos4svMESA_remap_index])
+#define SET_WindowPos4svMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos4svMESA_remap_index], fn)
+#define CALL_MultiModeDrawArraysIBM(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLenum *, const GLint *, const GLsizei *, GLsizei, GLint)), driDispatchRemapTable[MultiModeDrawArraysIBM_remap_index], parameters)
+#define GET_MultiModeDrawArraysIBM(disp) GET_by_offset(disp, driDispatchRemapTable[MultiModeDrawArraysIBM_remap_index])
+#define SET_MultiModeDrawArraysIBM(disp, fn) SET_by_offset(disp, driDispatchRemapTable[MultiModeDrawArraysIBM_remap_index], fn)
+#define CALL_MultiModeDrawElementsIBM(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLenum *, const GLsizei *, GLenum, const GLvoid * const *, GLsizei, GLint)), driDispatchRemapTable[MultiModeDrawElementsIBM_remap_index], parameters)
+#define GET_MultiModeDrawElementsIBM(disp) GET_by_offset(disp, driDispatchRemapTable[MultiModeDrawElementsIBM_remap_index])
+#define SET_MultiModeDrawElementsIBM(disp, fn) SET_by_offset(disp, driDispatchRemapTable[MultiModeDrawElementsIBM_remap_index], fn)
+#define CALL_DeleteFencesNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), driDispatchRemapTable[DeleteFencesNV_remap_index], parameters)
+#define GET_DeleteFencesNV(disp) GET_by_offset(disp, driDispatchRemapTable[DeleteFencesNV_remap_index])
+#define SET_DeleteFencesNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DeleteFencesNV_remap_index], fn)
+#define CALL_FinishFenceNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[FinishFenceNV_remap_index], parameters)
+#define GET_FinishFenceNV(disp) GET_by_offset(disp, driDispatchRemapTable[FinishFenceNV_remap_index])
+#define SET_FinishFenceNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FinishFenceNV_remap_index], fn)
+#define CALL_GenFencesNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), driDispatchRemapTable[GenFencesNV_remap_index], parameters)
+#define GET_GenFencesNV(disp) GET_by_offset(disp, driDispatchRemapTable[GenFencesNV_remap_index])
+#define SET_GenFencesNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GenFencesNV_remap_index], fn)
+#define CALL_GetFenceivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint *)), driDispatchRemapTable[GetFenceivNV_remap_index], parameters)
+#define GET_GetFenceivNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetFenceivNV_remap_index])
+#define SET_GetFenceivNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetFenceivNV_remap_index], fn)
+#define CALL_IsFenceNV(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[IsFenceNV_remap_index], parameters)
+#define GET_IsFenceNV(disp) GET_by_offset(disp, driDispatchRemapTable[IsFenceNV_remap_index])
+#define SET_IsFenceNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IsFenceNV_remap_index], fn)
+#define CALL_SetFenceNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum)), driDispatchRemapTable[SetFenceNV_remap_index], parameters)
+#define GET_SetFenceNV(disp) GET_by_offset(disp, driDispatchRemapTable[SetFenceNV_remap_index])
+#define SET_SetFenceNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SetFenceNV_remap_index], fn)
+#define CALL_TestFenceNV(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[TestFenceNV_remap_index], parameters)
+#define GET_TestFenceNV(disp) GET_by_offset(disp, driDispatchRemapTable[TestFenceNV_remap_index])
+#define SET_TestFenceNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[TestFenceNV_remap_index], fn)
+#define CALL_AreProgramsResidentNV(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLsizei, const GLuint *, GLboolean *)), driDispatchRemapTable[AreProgramsResidentNV_remap_index], parameters)
+#define GET_AreProgramsResidentNV(disp) GET_by_offset(disp, driDispatchRemapTable[AreProgramsResidentNV_remap_index])
+#define SET_AreProgramsResidentNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[AreProgramsResidentNV_remap_index], fn)
+#define CALL_BindProgramNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint)), driDispatchRemapTable[BindProgramNV_remap_index], parameters)
+#define GET_BindProgramNV(disp) GET_by_offset(disp, driDispatchRemapTable[BindProgramNV_remap_index])
+#define SET_BindProgramNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BindProgramNV_remap_index], fn)
+#define CALL_DeleteProgramsNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), driDispatchRemapTable[DeleteProgramsNV_remap_index], parameters)
+#define GET_DeleteProgramsNV(disp) GET_by_offset(disp, driDispatchRemapTable[DeleteProgramsNV_remap_index])
+#define SET_DeleteProgramsNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DeleteProgramsNV_remap_index], fn)
+#define CALL_ExecuteProgramNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, const GLfloat *)), driDispatchRemapTable[ExecuteProgramNV_remap_index], parameters)
+#define GET_ExecuteProgramNV(disp) GET_by_offset(disp, driDispatchRemapTable[ExecuteProgramNV_remap_index])
+#define SET_ExecuteProgramNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ExecuteProgramNV_remap_index], fn)
+#define CALL_GenProgramsNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), driDispatchRemapTable[GenProgramsNV_remap_index], parameters)
+#define GET_GenProgramsNV(disp) GET_by_offset(disp, driDispatchRemapTable[GenProgramsNV_remap_index])
+#define SET_GenProgramsNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GenProgramsNV_remap_index], fn)
+#define CALL_GetProgramParameterdvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLenum, GLdouble *)), driDispatchRemapTable[GetProgramParameterdvNV_remap_index], parameters)
+#define GET_GetProgramParameterdvNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramParameterdvNV_remap_index])
+#define SET_GetProgramParameterdvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramParameterdvNV_remap_index], fn)
+#define CALL_GetProgramParameterfvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLenum, GLfloat *)), driDispatchRemapTable[GetProgramParameterfvNV_remap_index], parameters)
+#define GET_GetProgramParameterfvNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramParameterfvNV_remap_index])
+#define SET_GetProgramParameterfvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramParameterfvNV_remap_index], fn)
+#define CALL_GetProgramStringNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLubyte *)), driDispatchRemapTable[GetProgramStringNV_remap_index], parameters)
+#define GET_GetProgramStringNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramStringNV_remap_index])
+#define SET_GetProgramStringNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramStringNV_remap_index], fn)
+#define CALL_GetProgramivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint *)), driDispatchRemapTable[GetProgramivNV_remap_index], parameters)
+#define GET_GetProgramivNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramivNV_remap_index])
+#define SET_GetProgramivNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramivNV_remap_index], fn)
+#define CALL_GetTrackMatrixivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLenum, GLint *)), driDispatchRemapTable[GetTrackMatrixivNV_remap_index], parameters)
+#define GET_GetTrackMatrixivNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetTrackMatrixivNV_remap_index])
+#define SET_GetTrackMatrixivNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetTrackMatrixivNV_remap_index], fn)
+#define CALL_GetVertexAttribPointervNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLvoid **)), driDispatchRemapTable[GetVertexAttribPointervNV_remap_index], parameters)
+#define GET_GetVertexAttribPointervNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetVertexAttribPointervNV_remap_index])
+#define SET_GetVertexAttribPointervNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetVertexAttribPointervNV_remap_index], fn)
+#define CALL_GetVertexAttribdvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLdouble *)), driDispatchRemapTable[GetVertexAttribdvNV_remap_index], parameters)
+#define GET_GetVertexAttribdvNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetVertexAttribdvNV_remap_index])
+#define SET_GetVertexAttribdvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetVertexAttribdvNV_remap_index], fn)
+#define CALL_GetVertexAttribfvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLfloat *)), driDispatchRemapTable[GetVertexAttribfvNV_remap_index], parameters)
+#define GET_GetVertexAttribfvNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetVertexAttribfvNV_remap_index])
+#define SET_GetVertexAttribfvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetVertexAttribfvNV_remap_index], fn)
+#define CALL_GetVertexAttribivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint *)), driDispatchRemapTable[GetVertexAttribivNV_remap_index], parameters)
+#define GET_GetVertexAttribivNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetVertexAttribivNV_remap_index])
+#define SET_GetVertexAttribivNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetVertexAttribivNV_remap_index], fn)
+#define CALL_IsProgramNV(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[IsProgramNV_remap_index], parameters)
+#define GET_IsProgramNV(disp) GET_by_offset(disp, driDispatchRemapTable[IsProgramNV_remap_index])
+#define SET_IsProgramNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IsProgramNV_remap_index], fn)
+#define CALL_LoadProgramNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLsizei, const GLubyte *)), driDispatchRemapTable[LoadProgramNV_remap_index], parameters)
+#define GET_LoadProgramNV(disp) GET_by_offset(disp, driDispatchRemapTable[LoadProgramNV_remap_index])
+#define SET_LoadProgramNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[LoadProgramNV_remap_index], fn)
+#define CALL_ProgramParameters4dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, const GLdouble *)), driDispatchRemapTable[ProgramParameters4dvNV_remap_index], parameters)
+#define GET_ProgramParameters4dvNV(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramParameters4dvNV_remap_index])
+#define SET_ProgramParameters4dvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramParameters4dvNV_remap_index], fn)
+#define CALL_ProgramParameters4fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, const GLfloat *)), driDispatchRemapTable[ProgramParameters4fvNV_remap_index], parameters)
+#define GET_ProgramParameters4fvNV(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramParameters4fvNV_remap_index])
+#define SET_ProgramParameters4fvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramParameters4fvNV_remap_index], fn)
+#define CALL_RequestResidentProgramsNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), driDispatchRemapTable[RequestResidentProgramsNV_remap_index], parameters)
+#define GET_RequestResidentProgramsNV(disp) GET_by_offset(disp, driDispatchRemapTable[RequestResidentProgramsNV_remap_index])
+#define SET_RequestResidentProgramsNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[RequestResidentProgramsNV_remap_index], fn)
+#define CALL_TrackMatrixNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLenum, GLenum)), driDispatchRemapTable[TrackMatrixNV_remap_index], parameters)
+#define GET_TrackMatrixNV(disp) GET_by_offset(disp, driDispatchRemapTable[TrackMatrixNV_remap_index])
+#define SET_TrackMatrixNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[TrackMatrixNV_remap_index], fn)
+#define CALL_VertexAttrib1dNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLdouble)), driDispatchRemapTable[VertexAttrib1dNV_remap_index], parameters)
+#define GET_VertexAttrib1dNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1dNV_remap_index])
+#define SET_VertexAttrib1dNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1dNV_remap_index], fn)
+#define CALL_VertexAttrib1dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLdouble *)), driDispatchRemapTable[VertexAttrib1dvNV_remap_index], parameters)
+#define GET_VertexAttrib1dvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1dvNV_remap_index])
+#define SET_VertexAttrib1dvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1dvNV_remap_index], fn)
+#define CALL_VertexAttrib1fNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLfloat)), driDispatchRemapTable[VertexAttrib1fNV_remap_index], parameters)
+#define GET_VertexAttrib1fNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1fNV_remap_index])
+#define SET_VertexAttrib1fNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1fNV_remap_index], fn)
+#define CALL_VertexAttrib1fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), driDispatchRemapTable[VertexAttrib1fvNV_remap_index], parameters)
+#define GET_VertexAttrib1fvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1fvNV_remap_index])
+#define SET_VertexAttrib1fvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1fvNV_remap_index], fn)
+#define CALL_VertexAttrib1sNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLshort)), driDispatchRemapTable[VertexAttrib1sNV_remap_index], parameters)
+#define GET_VertexAttrib1sNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1sNV_remap_index])
+#define SET_VertexAttrib1sNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1sNV_remap_index], fn)
+#define CALL_VertexAttrib1svNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), driDispatchRemapTable[VertexAttrib1svNV_remap_index], parameters)
+#define GET_VertexAttrib1svNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1svNV_remap_index])
+#define SET_VertexAttrib1svNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1svNV_remap_index], fn)
+#define CALL_VertexAttrib2dNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLdouble, GLdouble)), driDispatchRemapTable[VertexAttrib2dNV_remap_index], parameters)
+#define GET_VertexAttrib2dNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2dNV_remap_index])
+#define SET_VertexAttrib2dNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2dNV_remap_index], fn)
+#define CALL_VertexAttrib2dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLdouble *)), driDispatchRemapTable[VertexAttrib2dvNV_remap_index], parameters)
+#define GET_VertexAttrib2dvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2dvNV_remap_index])
+#define SET_VertexAttrib2dvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2dvNV_remap_index], fn)
+#define CALL_VertexAttrib2fNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLfloat, GLfloat)), driDispatchRemapTable[VertexAttrib2fNV_remap_index], parameters)
+#define GET_VertexAttrib2fNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2fNV_remap_index])
+#define SET_VertexAttrib2fNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2fNV_remap_index], fn)
+#define CALL_VertexAttrib2fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), driDispatchRemapTable[VertexAttrib2fvNV_remap_index], parameters)
+#define GET_VertexAttrib2fvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2fvNV_remap_index])
+#define SET_VertexAttrib2fvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2fvNV_remap_index], fn)
+#define CALL_VertexAttrib2sNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLshort, GLshort)), driDispatchRemapTable[VertexAttrib2sNV_remap_index], parameters)
+#define GET_VertexAttrib2sNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2sNV_remap_index])
+#define SET_VertexAttrib2sNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2sNV_remap_index], fn)
+#define CALL_VertexAttrib2svNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), driDispatchRemapTable[VertexAttrib2svNV_remap_index], parameters)
+#define GET_VertexAttrib2svNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2svNV_remap_index])
+#define SET_VertexAttrib2svNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2svNV_remap_index], fn)
+#define CALL_VertexAttrib3dNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLdouble, GLdouble, GLdouble)), driDispatchRemapTable[VertexAttrib3dNV_remap_index], parameters)
+#define GET_VertexAttrib3dNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3dNV_remap_index])
+#define SET_VertexAttrib3dNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3dNV_remap_index], fn)
+#define CALL_VertexAttrib3dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLdouble *)), driDispatchRemapTable[VertexAttrib3dvNV_remap_index], parameters)
+#define GET_VertexAttrib3dvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3dvNV_remap_index])
+#define SET_VertexAttrib3dvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3dvNV_remap_index], fn)
+#define CALL_VertexAttrib3fNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[VertexAttrib3fNV_remap_index], parameters)
+#define GET_VertexAttrib3fNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3fNV_remap_index])
+#define SET_VertexAttrib3fNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3fNV_remap_index], fn)
+#define CALL_VertexAttrib3fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), driDispatchRemapTable[VertexAttrib3fvNV_remap_index], parameters)
+#define GET_VertexAttrib3fvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3fvNV_remap_index])
+#define SET_VertexAttrib3fvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3fvNV_remap_index], fn)
+#define CALL_VertexAttrib3sNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLshort, GLshort, GLshort)), driDispatchRemapTable[VertexAttrib3sNV_remap_index], parameters)
+#define GET_VertexAttrib3sNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3sNV_remap_index])
+#define SET_VertexAttrib3sNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3sNV_remap_index], fn)
+#define CALL_VertexAttrib3svNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), driDispatchRemapTable[VertexAttrib3svNV_remap_index], parameters)
+#define GET_VertexAttrib3svNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3svNV_remap_index])
+#define SET_VertexAttrib3svNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3svNV_remap_index], fn)
+#define CALL_VertexAttrib4dNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble)), driDispatchRemapTable[VertexAttrib4dNV_remap_index], parameters)
+#define GET_VertexAttrib4dNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4dNV_remap_index])
+#define SET_VertexAttrib4dNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4dNV_remap_index], fn)
+#define CALL_VertexAttrib4dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLdouble *)), driDispatchRemapTable[VertexAttrib4dvNV_remap_index], parameters)
+#define GET_VertexAttrib4dvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4dvNV_remap_index])
+#define SET_VertexAttrib4dvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4dvNV_remap_index], fn)
+#define CALL_VertexAttrib4fNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[VertexAttrib4fNV_remap_index], parameters)
+#define GET_VertexAttrib4fNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4fNV_remap_index])
+#define SET_VertexAttrib4fNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4fNV_remap_index], fn)
+#define CALL_VertexAttrib4fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), driDispatchRemapTable[VertexAttrib4fvNV_remap_index], parameters)
+#define GET_VertexAttrib4fvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4fvNV_remap_index])
+#define SET_VertexAttrib4fvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4fvNV_remap_index], fn)
+#define CALL_VertexAttrib4sNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLshort, GLshort, GLshort, GLshort)), driDispatchRemapTable[VertexAttrib4sNV_remap_index], parameters)
+#define GET_VertexAttrib4sNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4sNV_remap_index])
+#define SET_VertexAttrib4sNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4sNV_remap_index], fn)
+#define CALL_VertexAttrib4svNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), driDispatchRemapTable[VertexAttrib4svNV_remap_index], parameters)
+#define GET_VertexAttrib4svNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4svNV_remap_index])
+#define SET_VertexAttrib4svNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4svNV_remap_index], fn)
+#define CALL_VertexAttrib4ubNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte)), driDispatchRemapTable[VertexAttrib4ubNV_remap_index], parameters)
+#define GET_VertexAttrib4ubNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4ubNV_remap_index])
+#define SET_VertexAttrib4ubNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4ubNV_remap_index], fn)
+#define CALL_VertexAttrib4ubvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLubyte *)), driDispatchRemapTable[VertexAttrib4ubvNV_remap_index], parameters)
+#define GET_VertexAttrib4ubvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4ubvNV_remap_index])
+#define SET_VertexAttrib4ubvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4ubvNV_remap_index], fn)
+#define CALL_VertexAttribPointerNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLint, GLenum, GLsizei, const GLvoid *)), driDispatchRemapTable[VertexAttribPointerNV_remap_index], parameters)
+#define GET_VertexAttribPointerNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribPointerNV_remap_index])
+#define SET_VertexAttribPointerNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribPointerNV_remap_index], fn)
+#define CALL_VertexAttribs1dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLdouble *)), driDispatchRemapTable[VertexAttribs1dvNV_remap_index], parameters)
+#define GET_VertexAttribs1dvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs1dvNV_remap_index])
+#define SET_VertexAttribs1dvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs1dvNV_remap_index], fn)
+#define CALL_VertexAttribs1fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLfloat *)), driDispatchRemapTable[VertexAttribs1fvNV_remap_index], parameters)
+#define GET_VertexAttribs1fvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs1fvNV_remap_index])
+#define SET_VertexAttribs1fvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs1fvNV_remap_index], fn)
+#define CALL_VertexAttribs1svNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLshort *)), driDispatchRemapTable[VertexAttribs1svNV_remap_index], parameters)
+#define GET_VertexAttribs1svNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs1svNV_remap_index])
+#define SET_VertexAttribs1svNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs1svNV_remap_index], fn)
+#define CALL_VertexAttribs2dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLdouble *)), driDispatchRemapTable[VertexAttribs2dvNV_remap_index], parameters)
+#define GET_VertexAttribs2dvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs2dvNV_remap_index])
+#define SET_VertexAttribs2dvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs2dvNV_remap_index], fn)
+#define CALL_VertexAttribs2fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLfloat *)), driDispatchRemapTable[VertexAttribs2fvNV_remap_index], parameters)
+#define GET_VertexAttribs2fvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs2fvNV_remap_index])
+#define SET_VertexAttribs2fvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs2fvNV_remap_index], fn)
+#define CALL_VertexAttribs2svNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLshort *)), driDispatchRemapTable[VertexAttribs2svNV_remap_index], parameters)
+#define GET_VertexAttribs2svNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs2svNV_remap_index])
+#define SET_VertexAttribs2svNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs2svNV_remap_index], fn)
+#define CALL_VertexAttribs3dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLdouble *)), driDispatchRemapTable[VertexAttribs3dvNV_remap_index], parameters)
+#define GET_VertexAttribs3dvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs3dvNV_remap_index])
+#define SET_VertexAttribs3dvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs3dvNV_remap_index], fn)
+#define CALL_VertexAttribs3fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLfloat *)), driDispatchRemapTable[VertexAttribs3fvNV_remap_index], parameters)
+#define GET_VertexAttribs3fvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs3fvNV_remap_index])
+#define SET_VertexAttribs3fvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs3fvNV_remap_index], fn)
+#define CALL_VertexAttribs3svNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLshort *)), driDispatchRemapTable[VertexAttribs3svNV_remap_index], parameters)
+#define GET_VertexAttribs3svNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs3svNV_remap_index])
+#define SET_VertexAttribs3svNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs3svNV_remap_index], fn)
+#define CALL_VertexAttribs4dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLdouble *)), driDispatchRemapTable[VertexAttribs4dvNV_remap_index], parameters)
+#define GET_VertexAttribs4dvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs4dvNV_remap_index])
+#define SET_VertexAttribs4dvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs4dvNV_remap_index], fn)
+#define CALL_VertexAttribs4fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLfloat *)), driDispatchRemapTable[VertexAttribs4fvNV_remap_index], parameters)
+#define GET_VertexAttribs4fvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs4fvNV_remap_index])
+#define SET_VertexAttribs4fvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs4fvNV_remap_index], fn)
+#define CALL_VertexAttribs4svNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLshort *)), driDispatchRemapTable[VertexAttribs4svNV_remap_index], parameters)
+#define GET_VertexAttribs4svNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs4svNV_remap_index])
+#define SET_VertexAttribs4svNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs4svNV_remap_index], fn)
+#define CALL_VertexAttribs4ubvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLubyte *)), driDispatchRemapTable[VertexAttribs4ubvNV_remap_index], parameters)
+#define GET_VertexAttribs4ubvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs4ubvNV_remap_index])
+#define SET_VertexAttribs4ubvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs4ubvNV_remap_index], fn)
+#define CALL_GetTexBumpParameterfvATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat *)), driDispatchRemapTable[GetTexBumpParameterfvATI_remap_index], parameters)
+#define GET_GetTexBumpParameterfvATI(disp) GET_by_offset(disp, driDispatchRemapTable[GetTexBumpParameterfvATI_remap_index])
+#define SET_GetTexBumpParameterfvATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetTexBumpParameterfvATI_remap_index], fn)
+#define CALL_GetTexBumpParameterivATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint *)), driDispatchRemapTable[GetTexBumpParameterivATI_remap_index], parameters)
+#define GET_GetTexBumpParameterivATI(disp) GET_by_offset(disp, driDispatchRemapTable[GetTexBumpParameterivATI_remap_index])
+#define SET_GetTexBumpParameterivATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetTexBumpParameterivATI_remap_index], fn)
+#define CALL_TexBumpParameterfvATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLfloat *)), driDispatchRemapTable[TexBumpParameterfvATI_remap_index], parameters)
+#define GET_TexBumpParameterfvATI(disp) GET_by_offset(disp, driDispatchRemapTable[TexBumpParameterfvATI_remap_index])
+#define SET_TexBumpParameterfvATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[TexBumpParameterfvATI_remap_index], fn)
+#define CALL_TexBumpParameterivATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLint *)), driDispatchRemapTable[TexBumpParameterivATI_remap_index], parameters)
+#define GET_TexBumpParameterivATI(disp) GET_by_offset(disp, driDispatchRemapTable[TexBumpParameterivATI_remap_index])
+#define SET_TexBumpParameterivATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[TexBumpParameterivATI_remap_index], fn)
+#define CALL_AlphaFragmentOp1ATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, GLuint, GLuint, GLuint)), driDispatchRemapTable[AlphaFragmentOp1ATI_remap_index], parameters)
+#define GET_AlphaFragmentOp1ATI(disp) GET_by_offset(disp, driDispatchRemapTable[AlphaFragmentOp1ATI_remap_index])
+#define SET_AlphaFragmentOp1ATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[AlphaFragmentOp1ATI_remap_index], fn)
+#define CALL_AlphaFragmentOp2ATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint)), driDispatchRemapTable[AlphaFragmentOp2ATI_remap_index], parameters)
+#define GET_AlphaFragmentOp2ATI(disp) GET_by_offset(disp, driDispatchRemapTable[AlphaFragmentOp2ATI_remap_index])
+#define SET_AlphaFragmentOp2ATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[AlphaFragmentOp2ATI_remap_index], fn)
+#define CALL_AlphaFragmentOp3ATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint)), driDispatchRemapTable[AlphaFragmentOp3ATI_remap_index], parameters)
+#define GET_AlphaFragmentOp3ATI(disp) GET_by_offset(disp, driDispatchRemapTable[AlphaFragmentOp3ATI_remap_index])
+#define SET_AlphaFragmentOp3ATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[AlphaFragmentOp3ATI_remap_index], fn)
+#define CALL_BeginFragmentShaderATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), driDispatchRemapTable[BeginFragmentShaderATI_remap_index], parameters)
+#define GET_BeginFragmentShaderATI(disp) GET_by_offset(disp, driDispatchRemapTable[BeginFragmentShaderATI_remap_index])
+#define SET_BeginFragmentShaderATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BeginFragmentShaderATI_remap_index], fn)
+#define CALL_BindFragmentShaderATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[BindFragmentShaderATI_remap_index], parameters)
+#define GET_BindFragmentShaderATI(disp) GET_by_offset(disp, driDispatchRemapTable[BindFragmentShaderATI_remap_index])
+#define SET_BindFragmentShaderATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BindFragmentShaderATI_remap_index], fn)
+#define CALL_ColorFragmentOp1ATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint)), driDispatchRemapTable[ColorFragmentOp1ATI_remap_index], parameters)
+#define GET_ColorFragmentOp1ATI(disp) GET_by_offset(disp, driDispatchRemapTable[ColorFragmentOp1ATI_remap_index])
+#define SET_ColorFragmentOp1ATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ColorFragmentOp1ATI_remap_index], fn)
+#define CALL_ColorFragmentOp2ATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint)), driDispatchRemapTable[ColorFragmentOp2ATI_remap_index], parameters)
+#define GET_ColorFragmentOp2ATI(disp) GET_by_offset(disp, driDispatchRemapTable[ColorFragmentOp2ATI_remap_index])
+#define SET_ColorFragmentOp2ATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ColorFragmentOp2ATI_remap_index], fn)
+#define CALL_ColorFragmentOp3ATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint)), driDispatchRemapTable[ColorFragmentOp3ATI_remap_index], parameters)
+#define GET_ColorFragmentOp3ATI(disp) GET_by_offset(disp, driDispatchRemapTable[ColorFragmentOp3ATI_remap_index])
+#define SET_ColorFragmentOp3ATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ColorFragmentOp3ATI_remap_index], fn)
+#define CALL_DeleteFragmentShaderATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[DeleteFragmentShaderATI_remap_index], parameters)
+#define GET_DeleteFragmentShaderATI(disp) GET_by_offset(disp, driDispatchRemapTable[DeleteFragmentShaderATI_remap_index])
+#define SET_DeleteFragmentShaderATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DeleteFragmentShaderATI_remap_index], fn)
+#define CALL_EndFragmentShaderATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), driDispatchRemapTable[EndFragmentShaderATI_remap_index], parameters)
+#define GET_EndFragmentShaderATI(disp) GET_by_offset(disp, driDispatchRemapTable[EndFragmentShaderATI_remap_index])
+#define SET_EndFragmentShaderATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[EndFragmentShaderATI_remap_index], fn)
+#define CALL_GenFragmentShadersATI(disp, parameters) CALL_by_offset(disp, (GLuint (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[GenFragmentShadersATI_remap_index], parameters)
+#define GET_GenFragmentShadersATI(disp) GET_by_offset(disp, driDispatchRemapTable[GenFragmentShadersATI_remap_index])
+#define SET_GenFragmentShadersATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GenFragmentShadersATI_remap_index], fn)
+#define CALL_PassTexCoordATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLuint, GLenum)), driDispatchRemapTable[PassTexCoordATI_remap_index], parameters)
+#define GET_PassTexCoordATI(disp) GET_by_offset(disp, driDispatchRemapTable[PassTexCoordATI_remap_index])
+#define SET_PassTexCoordATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PassTexCoordATI_remap_index], fn)
+#define CALL_SampleMapATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLuint, GLenum)), driDispatchRemapTable[SampleMapATI_remap_index], parameters)
+#define GET_SampleMapATI(disp) GET_by_offset(disp, driDispatchRemapTable[SampleMapATI_remap_index])
+#define SET_SampleMapATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SampleMapATI_remap_index], fn)
+#define CALL_SetFragmentShaderConstantATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), driDispatchRemapTable[SetFragmentShaderConstantATI_remap_index], parameters)
+#define GET_SetFragmentShaderConstantATI(disp) GET_by_offset(disp, driDispatchRemapTable[SetFragmentShaderConstantATI_remap_index])
+#define SET_SetFragmentShaderConstantATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SetFragmentShaderConstantATI_remap_index], fn)
+#define CALL_PointParameteriNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint)), driDispatchRemapTable[PointParameteriNV_remap_index], parameters)
+#define GET_PointParameteriNV(disp) GET_by_offset(disp, driDispatchRemapTable[PointParameteriNV_remap_index])
+#define SET_PointParameteriNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PointParameteriNV_remap_index], fn)
+#define CALL_PointParameterivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLint *)), driDispatchRemapTable[PointParameterivNV_remap_index], parameters)
+#define GET_PointParameterivNV(disp) GET_by_offset(disp, driDispatchRemapTable[PointParameterivNV_remap_index])
+#define SET_PointParameterivNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PointParameterivNV_remap_index], fn)
+#define CALL_ActiveStencilFaceEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), driDispatchRemapTable[ActiveStencilFaceEXT_remap_index], parameters)
+#define GET_ActiveStencilFaceEXT(disp) GET_by_offset(disp, driDispatchRemapTable[ActiveStencilFaceEXT_remap_index])
+#define SET_ActiveStencilFaceEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ActiveStencilFaceEXT_remap_index], fn)
+#define CALL_BindVertexArrayAPPLE(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[BindVertexArrayAPPLE_remap_index], parameters)
+#define GET_BindVertexArrayAPPLE(disp) GET_by_offset(disp, driDispatchRemapTable[BindVertexArrayAPPLE_remap_index])
+#define SET_BindVertexArrayAPPLE(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BindVertexArrayAPPLE_remap_index], fn)
+#define CALL_DeleteVertexArraysAPPLE(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), driDispatchRemapTable[DeleteVertexArraysAPPLE_remap_index], parameters)
+#define GET_DeleteVertexArraysAPPLE(disp) GET_by_offset(disp, driDispatchRemapTable[DeleteVertexArraysAPPLE_remap_index])
+#define SET_DeleteVertexArraysAPPLE(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DeleteVertexArraysAPPLE_remap_index], fn)
+#define CALL_GenVertexArraysAPPLE(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), driDispatchRemapTable[GenVertexArraysAPPLE_remap_index], parameters)
+#define GET_GenVertexArraysAPPLE(disp) GET_by_offset(disp, driDispatchRemapTable[GenVertexArraysAPPLE_remap_index])
+#define SET_GenVertexArraysAPPLE(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GenVertexArraysAPPLE_remap_index], fn)
+#define CALL_IsVertexArrayAPPLE(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[IsVertexArrayAPPLE_remap_index], parameters)
+#define GET_IsVertexArrayAPPLE(disp) GET_by_offset(disp, driDispatchRemapTable[IsVertexArrayAPPLE_remap_index])
+#define SET_IsVertexArrayAPPLE(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IsVertexArrayAPPLE_remap_index], fn)
+#define CALL_GetProgramNamedParameterdvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLubyte *, GLdouble *)), driDispatchRemapTable[GetProgramNamedParameterdvNV_remap_index], parameters)
+#define GET_GetProgramNamedParameterdvNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramNamedParameterdvNV_remap_index])
+#define SET_GetProgramNamedParameterdvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramNamedParameterdvNV_remap_index], fn)
+#define CALL_GetProgramNamedParameterfvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLubyte *, GLfloat *)), driDispatchRemapTable[GetProgramNamedParameterfvNV_remap_index], parameters)
+#define GET_GetProgramNamedParameterfvNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramNamedParameterfvNV_remap_index])
+#define SET_GetProgramNamedParameterfvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramNamedParameterfvNV_remap_index], fn)
+#define CALL_ProgramNamedParameter4dNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLubyte *, GLdouble, GLdouble, GLdouble, GLdouble)), driDispatchRemapTable[ProgramNamedParameter4dNV_remap_index], parameters)
+#define GET_ProgramNamedParameter4dNV(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramNamedParameter4dNV_remap_index])
+#define SET_ProgramNamedParameter4dNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramNamedParameter4dNV_remap_index], fn)
+#define CALL_ProgramNamedParameter4dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLubyte *, const GLdouble *)), driDispatchRemapTable[ProgramNamedParameter4dvNV_remap_index], parameters)
+#define GET_ProgramNamedParameter4dvNV(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramNamedParameter4dvNV_remap_index])
+#define SET_ProgramNamedParameter4dvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramNamedParameter4dvNV_remap_index], fn)
+#define CALL_ProgramNamedParameter4fNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLubyte *, GLfloat, GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[ProgramNamedParameter4fNV_remap_index], parameters)
+#define GET_ProgramNamedParameter4fNV(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramNamedParameter4fNV_remap_index])
+#define SET_ProgramNamedParameter4fNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramNamedParameter4fNV_remap_index], fn)
+#define CALL_ProgramNamedParameter4fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLubyte *, const GLfloat *)), driDispatchRemapTable[ProgramNamedParameter4fvNV_remap_index], parameters)
+#define GET_ProgramNamedParameter4fvNV(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramNamedParameter4fvNV_remap_index])
+#define SET_ProgramNamedParameter4fvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramNamedParameter4fvNV_remap_index], fn)
+#define CALL_DepthBoundsEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLclampd, GLclampd)), driDispatchRemapTable[DepthBoundsEXT_remap_index], parameters)
+#define GET_DepthBoundsEXT(disp) GET_by_offset(disp, driDispatchRemapTable[DepthBoundsEXT_remap_index])
+#define SET_DepthBoundsEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DepthBoundsEXT_remap_index], fn)
+#define CALL_BlendEquationSeparateEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum)), driDispatchRemapTable[BlendEquationSeparateEXT_remap_index], parameters)
+#define GET_BlendEquationSeparateEXT(disp) GET_by_offset(disp, driDispatchRemapTable[BlendEquationSeparateEXT_remap_index])
+#define SET_BlendEquationSeparateEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BlendEquationSeparateEXT_remap_index], fn)
+#define CALL_BindFramebufferEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint)), driDispatchRemapTable[BindFramebufferEXT_remap_index], parameters)
+#define GET_BindFramebufferEXT(disp) GET_by_offset(disp, driDispatchRemapTable[BindFramebufferEXT_remap_index])
+#define SET_BindFramebufferEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BindFramebufferEXT_remap_index], fn)
+#define CALL_BindRenderbufferEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint)), driDispatchRemapTable[BindRenderbufferEXT_remap_index], parameters)
+#define GET_BindRenderbufferEXT(disp) GET_by_offset(disp, driDispatchRemapTable[BindRenderbufferEXT_remap_index])
+#define SET_BindRenderbufferEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BindRenderbufferEXT_remap_index], fn)
+#define CALL_CheckFramebufferStatusEXT(disp, parameters) CALL_by_offset(disp, (GLenum (GLAPIENTRYP)(GLenum)), driDispatchRemapTable[CheckFramebufferStatusEXT_remap_index], parameters)
+#define GET_CheckFramebufferStatusEXT(disp) GET_by_offset(disp, driDispatchRemapTable[CheckFramebufferStatusEXT_remap_index])
+#define SET_CheckFramebufferStatusEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CheckFramebufferStatusEXT_remap_index], fn)
+#define CALL_DeleteFramebuffersEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), driDispatchRemapTable[DeleteFramebuffersEXT_remap_index], parameters)
+#define GET_DeleteFramebuffersEXT(disp) GET_by_offset(disp, driDispatchRemapTable[DeleteFramebuffersEXT_remap_index])
+#define SET_DeleteFramebuffersEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DeleteFramebuffersEXT_remap_index], fn)
+#define CALL_DeleteRenderbuffersEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), driDispatchRemapTable[DeleteRenderbuffersEXT_remap_index], parameters)
+#define GET_DeleteRenderbuffersEXT(disp) GET_by_offset(disp, driDispatchRemapTable[DeleteRenderbuffersEXT_remap_index])
+#define SET_DeleteRenderbuffersEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DeleteRenderbuffersEXT_remap_index], fn)
+#define CALL_FramebufferRenderbufferEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLuint)), driDispatchRemapTable[FramebufferRenderbufferEXT_remap_index], parameters)
+#define GET_FramebufferRenderbufferEXT(disp) GET_by_offset(disp, driDispatchRemapTable[FramebufferRenderbufferEXT_remap_index])
+#define SET_FramebufferRenderbufferEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FramebufferRenderbufferEXT_remap_index], fn)
+#define CALL_FramebufferTexture1DEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLuint, GLint)), driDispatchRemapTable[FramebufferTexture1DEXT_remap_index], parameters)
+#define GET_FramebufferTexture1DEXT(disp) GET_by_offset(disp, driDispatchRemapTable[FramebufferTexture1DEXT_remap_index])
+#define SET_FramebufferTexture1DEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FramebufferTexture1DEXT_remap_index], fn)
+#define CALL_FramebufferTexture2DEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLuint, GLint)), driDispatchRemapTable[FramebufferTexture2DEXT_remap_index], parameters)
+#define GET_FramebufferTexture2DEXT(disp) GET_by_offset(disp, driDispatchRemapTable[FramebufferTexture2DEXT_remap_index])
+#define SET_FramebufferTexture2DEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FramebufferTexture2DEXT_remap_index], fn)
+#define CALL_FramebufferTexture3DEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLuint, GLint, GLint)), driDispatchRemapTable[FramebufferTexture3DEXT_remap_index], parameters)
+#define GET_FramebufferTexture3DEXT(disp) GET_by_offset(disp, driDispatchRemapTable[FramebufferTexture3DEXT_remap_index])
+#define SET_FramebufferTexture3DEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FramebufferTexture3DEXT_remap_index], fn)
+#define CALL_GenFramebuffersEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), driDispatchRemapTable[GenFramebuffersEXT_remap_index], parameters)
+#define GET_GenFramebuffersEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GenFramebuffersEXT_remap_index])
+#define SET_GenFramebuffersEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GenFramebuffersEXT_remap_index], fn)
+#define CALL_GenRenderbuffersEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), driDispatchRemapTable[GenRenderbuffersEXT_remap_index], parameters)
+#define GET_GenRenderbuffersEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GenRenderbuffersEXT_remap_index])
+#define SET_GenRenderbuffersEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GenRenderbuffersEXT_remap_index], fn)
+#define CALL_GenerateMipmapEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), driDispatchRemapTable[GenerateMipmapEXT_remap_index], parameters)
+#define GET_GenerateMipmapEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GenerateMipmapEXT_remap_index])
+#define SET_GenerateMipmapEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GenerateMipmapEXT_remap_index], fn)
+#define CALL_GetFramebufferAttachmentParameterivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLint *)), driDispatchRemapTable[GetFramebufferAttachmentParameterivEXT_remap_index], parameters)
+#define GET_GetFramebufferAttachmentParameterivEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GetFramebufferAttachmentParameterivEXT_remap_index])
+#define SET_GetFramebufferAttachmentParameterivEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetFramebufferAttachmentParameterivEXT_remap_index], fn)
+#define CALL_GetRenderbufferParameterivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), driDispatchRemapTable[GetRenderbufferParameterivEXT_remap_index], parameters)
+#define GET_GetRenderbufferParameterivEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GetRenderbufferParameterivEXT_remap_index])
+#define SET_GetRenderbufferParameterivEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetRenderbufferParameterivEXT_remap_index], fn)
+#define CALL_IsFramebufferEXT(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[IsFramebufferEXT_remap_index], parameters)
+#define GET_IsFramebufferEXT(disp) GET_by_offset(disp, driDispatchRemapTable[IsFramebufferEXT_remap_index])
+#define SET_IsFramebufferEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IsFramebufferEXT_remap_index], fn)
+#define CALL_IsRenderbufferEXT(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[IsRenderbufferEXT_remap_index], parameters)
+#define GET_IsRenderbufferEXT(disp) GET_by_offset(disp, driDispatchRemapTable[IsRenderbufferEXT_remap_index])
+#define SET_IsRenderbufferEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IsRenderbufferEXT_remap_index], fn)
+#define CALL_RenderbufferStorageEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLsizei, GLsizei)), driDispatchRemapTable[RenderbufferStorageEXT_remap_index], parameters)
+#define GET_RenderbufferStorageEXT(disp) GET_by_offset(disp, driDispatchRemapTable[RenderbufferStorageEXT_remap_index])
+#define SET_RenderbufferStorageEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[RenderbufferStorageEXT_remap_index], fn)
+#define CALL_BlitFramebufferEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum)), driDispatchRemapTable[BlitFramebufferEXT_remap_index], parameters)
+#define GET_BlitFramebufferEXT(disp) GET_by_offset(disp, driDispatchRemapTable[BlitFramebufferEXT_remap_index])
+#define SET_BlitFramebufferEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BlitFramebufferEXT_remap_index], fn)
+#define CALL_BufferParameteriAPPLE(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint)), driDispatchRemapTable[BufferParameteriAPPLE_remap_index], parameters)
+#define GET_BufferParameteriAPPLE(disp) GET_by_offset(disp, driDispatchRemapTable[BufferParameteriAPPLE_remap_index])
+#define SET_BufferParameteriAPPLE(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BufferParameteriAPPLE_remap_index], fn)
+#define CALL_FlushMappedBufferRangeAPPLE(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLintptr, GLsizeiptr)), driDispatchRemapTable[FlushMappedBufferRangeAPPLE_remap_index], parameters)
+#define GET_FlushMappedBufferRangeAPPLE(disp) GET_by_offset(disp, driDispatchRemapTable[FlushMappedBufferRangeAPPLE_remap_index])
+#define SET_FlushMappedBufferRangeAPPLE(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FlushMappedBufferRangeAPPLE_remap_index], fn)
+#define CALL_FramebufferTextureLayerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLuint, GLint, GLint)), driDispatchRemapTable[FramebufferTextureLayerEXT_remap_index], parameters)
+#define GET_FramebufferTextureLayerEXT(disp) GET_by_offset(disp, driDispatchRemapTable[FramebufferTextureLayerEXT_remap_index])
+#define SET_FramebufferTextureLayerEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FramebufferTextureLayerEXT_remap_index], fn)
+#define CALL_ColorMaskIndexedEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLboolean, GLboolean, GLboolean, GLboolean)), driDispatchRemapTable[ColorMaskIndexedEXT_remap_index], parameters)
+#define GET_ColorMaskIndexedEXT(disp) GET_by_offset(disp, driDispatchRemapTable[ColorMaskIndexedEXT_remap_index])
+#define SET_ColorMaskIndexedEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ColorMaskIndexedEXT_remap_index], fn)
+#define CALL_DisableIndexedEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint)), driDispatchRemapTable[DisableIndexedEXT_remap_index], parameters)
+#define GET_DisableIndexedEXT(disp) GET_by_offset(disp, driDispatchRemapTable[DisableIndexedEXT_remap_index])
+#define SET_DisableIndexedEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DisableIndexedEXT_remap_index], fn)
+#define CALL_EnableIndexedEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint)), driDispatchRemapTable[EnableIndexedEXT_remap_index], parameters)
+#define GET_EnableIndexedEXT(disp) GET_by_offset(disp, driDispatchRemapTable[EnableIndexedEXT_remap_index])
+#define SET_EnableIndexedEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[EnableIndexedEXT_remap_index], fn)
+#define CALL_GetBooleanIndexedvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLboolean *)), driDispatchRemapTable[GetBooleanIndexedvEXT_remap_index], parameters)
+#define GET_GetBooleanIndexedvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GetBooleanIndexedvEXT_remap_index])
+#define SET_GetBooleanIndexedvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetBooleanIndexedvEXT_remap_index], fn)
+#define CALL_GetIntegerIndexedvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLint *)), driDispatchRemapTable[GetIntegerIndexedvEXT_remap_index], parameters)
+#define GET_GetIntegerIndexedvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GetIntegerIndexedvEXT_remap_index])
+#define SET_GetIntegerIndexedvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetIntegerIndexedvEXT_remap_index], fn)
+#define CALL_IsEnabledIndexedEXT(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLenum, GLuint)), driDispatchRemapTable[IsEnabledIndexedEXT_remap_index], parameters)
+#define GET_IsEnabledIndexedEXT(disp) GET_by_offset(disp, driDispatchRemapTable[IsEnabledIndexedEXT_remap_index])
+#define SET_IsEnabledIndexedEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IsEnabledIndexedEXT_remap_index], fn)
+#define CALL_BeginConditionalRenderNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum)), driDispatchRemapTable[BeginConditionalRenderNV_remap_index], parameters)
+#define GET_BeginConditionalRenderNV(disp) GET_by_offset(disp, driDispatchRemapTable[BeginConditionalRenderNV_remap_index])
+#define SET_BeginConditionalRenderNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BeginConditionalRenderNV_remap_index], fn)
+#define CALL_EndConditionalRenderNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), driDispatchRemapTable[EndConditionalRenderNV_remap_index], parameters)
+#define GET_EndConditionalRenderNV(disp) GET_by_offset(disp, driDispatchRemapTable[EndConditionalRenderNV_remap_index])
+#define SET_EndConditionalRenderNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[EndConditionalRenderNV_remap_index], fn)
+#define CALL_ProvokingVertexEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), driDispatchRemapTable[ProvokingVertexEXT_remap_index], parameters)
+#define GET_ProvokingVertexEXT(disp) GET_by_offset(disp, driDispatchRemapTable[ProvokingVertexEXT_remap_index])
+#define SET_ProvokingVertexEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProvokingVertexEXT_remap_index], fn)
+#define CALL_GetTexParameterPointervAPPLE(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLvoid **)), driDispatchRemapTable[GetTexParameterPointervAPPLE_remap_index], parameters)
+#define GET_GetTexParameterPointervAPPLE(disp) GET_by_offset(disp, driDispatchRemapTable[GetTexParameterPointervAPPLE_remap_index])
+#define SET_GetTexParameterPointervAPPLE(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetTexParameterPointervAPPLE_remap_index], fn)
+#define CALL_TextureRangeAPPLE(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, GLvoid *)), driDispatchRemapTable[TextureRangeAPPLE_remap_index], parameters)
+#define GET_TextureRangeAPPLE(disp) GET_by_offset(disp, driDispatchRemapTable[TextureRangeAPPLE_remap_index])
+#define SET_TextureRangeAPPLE(disp, fn) SET_by_offset(disp, driDispatchRemapTable[TextureRangeAPPLE_remap_index], fn)
+#define CALL_StencilFuncSeparateATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint, GLuint)), driDispatchRemapTable[StencilFuncSeparateATI_remap_index], parameters)
+#define GET_StencilFuncSeparateATI(disp) GET_by_offset(disp, driDispatchRemapTable[StencilFuncSeparateATI_remap_index])
+#define SET_StencilFuncSeparateATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[StencilFuncSeparateATI_remap_index], fn)
+#define CALL_ProgramEnvParameters4fvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLsizei, const GLfloat *)), driDispatchRemapTable[ProgramEnvParameters4fvEXT_remap_index], parameters)
+#define GET_ProgramEnvParameters4fvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramEnvParameters4fvEXT_remap_index])
+#define SET_ProgramEnvParameters4fvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramEnvParameters4fvEXT_remap_index], fn)
+#define CALL_ProgramLocalParameters4fvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLsizei, const GLfloat *)), driDispatchRemapTable[ProgramLocalParameters4fvEXT_remap_index], parameters)
+#define GET_ProgramLocalParameters4fvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramLocalParameters4fvEXT_remap_index])
+#define SET_ProgramLocalParameters4fvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramLocalParameters4fvEXT_remap_index], fn)
+#define CALL_GetQueryObjecti64vEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint64EXT *)), driDispatchRemapTable[GetQueryObjecti64vEXT_remap_index], parameters)
+#define GET_GetQueryObjecti64vEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GetQueryObjecti64vEXT_remap_index])
+#define SET_GetQueryObjecti64vEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetQueryObjecti64vEXT_remap_index], fn)
+#define CALL_GetQueryObjectui64vEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLuint64EXT *)), driDispatchRemapTable[GetQueryObjectui64vEXT_remap_index], parameters)
+#define GET_GetQueryObjectui64vEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GetQueryObjectui64vEXT_remap_index])
+#define SET_GetQueryObjectui64vEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetQueryObjectui64vEXT_remap_index], fn)
+
+#endif /* !defined(_GLAPI_USE_REMAP_TABLE) */
+
+#endif /* !defined( _GLAPI_DISPATCH_H_ ) */
index a3807744fff48285c08fe9487d547c47c7487a0a..c5d367f6f29b0b6553ab96265a04a75699e72b46 100644 (file)
@@ -29,6 +29,8 @@
 #if !defined( _GLAPI_OFFSETS_H_ )
 #  define _GLAPI_OFFSETS_H_
 
+/* this file should not be included directly in mesa */
+
 #define _gloffset_NewList 0
 #define _gloffset_EndList 1
 #define _gloffset_CallList 2
 #define _gloffset_MultiTexCoord4sARB 406
 #define _gloffset_MultiTexCoord4svARB 407
 
-#if !defined(IN_DRI_DRIVER)
+#if !defined(_GLAPI_USE_REMAP_TABLE)
 
 #define _gloffset_AttachShader 408
 #define _gloffset_CreateProgram 409
 #define _gloffset_BufferParameteriAPPLE 784
 #define _gloffset_FlushMappedBufferRangeAPPLE 785
 #define _gloffset_FramebufferTextureLayerEXT 786
-#define _gloffset_ProvokingVertexEXT 787
-#define _gloffset_GetTexParameterPointervAPPLE 788
-#define _gloffset_TextureRangeAPPLE 789
-#define _gloffset_StencilFuncSeparateATI 790
-#define _gloffset_ProgramEnvParameters4fvEXT 791
-#define _gloffset_ProgramLocalParameters4fvEXT 792
-#define _gloffset_GetQueryObjecti64vEXT 793
-#define _gloffset_GetQueryObjectui64vEXT 794
-#define _gloffset_FIRST_DYNAMIC 795
+#define _gloffset_ColorMaskIndexedEXT 787
+#define _gloffset_DisableIndexedEXT 788
+#define _gloffset_EnableIndexedEXT 789
+#define _gloffset_GetBooleanIndexedvEXT 790
+#define _gloffset_GetIntegerIndexedvEXT 791
+#define _gloffset_IsEnabledIndexedEXT 792
+#define _gloffset_BeginConditionalRenderNV 793
+#define _gloffset_EndConditionalRenderNV 794
+#define _gloffset_ProvokingVertexEXT 795
+#define _gloffset_GetTexParameterPointervAPPLE 796
+#define _gloffset_TextureRangeAPPLE 797
+#define _gloffset_StencilFuncSeparateATI 798
+#define _gloffset_ProgramEnvParameters4fvEXT 799
+#define _gloffset_ProgramLocalParameters4fvEXT 800
+#define _gloffset_GetQueryObjecti64vEXT 801
+#define _gloffset_GetQueryObjectui64vEXT 802
+#define _gloffset_FIRST_DYNAMIC 803
 
 #else
 
 #define _gloffset_BufferParameteriAPPLE driDispatchRemapTable[BufferParameteriAPPLE_remap_index]
 #define _gloffset_FlushMappedBufferRangeAPPLE driDispatchRemapTable[FlushMappedBufferRangeAPPLE_remap_index]
 #define _gloffset_FramebufferTextureLayerEXT driDispatchRemapTable[FramebufferTextureLayerEXT_remap_index]
+#define _gloffset_ColorMaskIndexedEXT driDispatchRemapTable[ColorMaskIndexedEXT_remap_index]
+#define _gloffset_DisableIndexedEXT driDispatchRemapTable[DisableIndexedEXT_remap_index]
+#define _gloffset_EnableIndexedEXT driDispatchRemapTable[EnableIndexedEXT_remap_index]
+#define _gloffset_GetBooleanIndexedvEXT driDispatchRemapTable[GetBooleanIndexedvEXT_remap_index]
+#define _gloffset_GetIntegerIndexedvEXT driDispatchRemapTable[GetIntegerIndexedvEXT_remap_index]
+#define _gloffset_IsEnabledIndexedEXT driDispatchRemapTable[IsEnabledIndexedEXT_remap_index]
+#define _gloffset_BeginConditionalRenderNV driDispatchRemapTable[BeginConditionalRenderNV_remap_index]
+#define _gloffset_EndConditionalRenderNV driDispatchRemapTable[EndConditionalRenderNV_remap_index]
 #define _gloffset_ProvokingVertexEXT driDispatchRemapTable[ProvokingVertexEXT_remap_index]
 #define _gloffset_GetTexParameterPointervAPPLE driDispatchRemapTable[GetTexParameterPointervAPPLE_remap_index]
 #define _gloffset_TextureRangeAPPLE driDispatchRemapTable[TextureRangeAPPLE_remap_index]
 #define _gloffset_GetQueryObjecti64vEXT driDispatchRemapTable[GetQueryObjecti64vEXT_remap_index]
 #define _gloffset_GetQueryObjectui64vEXT driDispatchRemapTable[GetQueryObjectui64vEXT_remap_index]
 
-#endif /* !defined(IN_DRI_DRIVER) */
+#endif /* !defined(_GLAPI_USE_REMAP_TABLE) */
 
 #endif /* !defined( _GLAPI_OFFSETS_H_ ) */
index 4f9e53b62d661eded7fece12bc98c687dbfb2ea7..0c5b46d04b4c30e3978f71235369725d846cdebc 100644 (file)
@@ -827,14 +827,22 @@ struct _glapi_table
    void (GLAPIENTRYP BufferParameteriAPPLE)(GLenum target, GLenum pname, GLint param); /* 784 */
    void (GLAPIENTRYP FlushMappedBufferRangeAPPLE)(GLenum target, GLintptr offset, GLsizeiptr size); /* 785 */
    void (GLAPIENTRYP FramebufferTextureLayerEXT)(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); /* 786 */
-   void (GLAPIENTRYP ProvokingVertexEXT)(GLenum mode); /* 787 */
-   void (GLAPIENTRYP GetTexParameterPointervAPPLE)(GLenum target, GLenum pname, GLvoid ** params); /* 788 */
-   void (GLAPIENTRYP TextureRangeAPPLE)(GLenum target, GLsizei length, GLvoid * pointer); /* 789 */
-   void (GLAPIENTRYP StencilFuncSeparateATI)(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); /* 790 */
-   void (GLAPIENTRYP ProgramEnvParameters4fvEXT)(GLenum target, GLuint index, GLsizei count, const GLfloat * params); /* 791 */
-   void (GLAPIENTRYP ProgramLocalParameters4fvEXT)(GLenum target, GLuint index, GLsizei count, const GLfloat * params); /* 792 */
-   void (GLAPIENTRYP GetQueryObjecti64vEXT)(GLuint id, GLenum pname, GLint64EXT * params); /* 793 */
-   void (GLAPIENTRYP GetQueryObjectui64vEXT)(GLuint id, GLenum pname, GLuint64EXT * params); /* 794 */
+   void (GLAPIENTRYP ColorMaskIndexedEXT)(GLuint buf, GLboolean r, GLboolean g, GLboolean b, GLboolean a); /* 787 */
+   void (GLAPIENTRYP DisableIndexedEXT)(GLenum target, GLuint index); /* 788 */
+   void (GLAPIENTRYP EnableIndexedEXT)(GLenum target, GLuint index); /* 789 */
+   void (GLAPIENTRYP GetBooleanIndexedvEXT)(GLenum value, GLuint index, GLboolean * data); /* 790 */
+   void (GLAPIENTRYP GetIntegerIndexedvEXT)(GLenum value, GLuint index, GLint * data); /* 791 */
+   GLboolean (GLAPIENTRYP IsEnabledIndexedEXT)(GLenum target, GLuint index); /* 792 */
+   void (GLAPIENTRYP BeginConditionalRenderNV)(GLuint query, GLenum mode); /* 793 */
+   void (GLAPIENTRYP EndConditionalRenderNV)(void); /* 794 */
+   void (GLAPIENTRYP ProvokingVertexEXT)(GLenum mode); /* 795 */
+   void (GLAPIENTRYP GetTexParameterPointervAPPLE)(GLenum target, GLenum pname, GLvoid ** params); /* 796 */
+   void (GLAPIENTRYP TextureRangeAPPLE)(GLenum target, GLsizei length, GLvoid * pointer); /* 797 */
+   void (GLAPIENTRYP StencilFuncSeparateATI)(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); /* 798 */
+   void (GLAPIENTRYP ProgramEnvParameters4fvEXT)(GLenum target, GLuint index, GLsizei count, const GLfloat * params); /* 799 */
+   void (GLAPIENTRYP ProgramLocalParameters4fvEXT)(GLenum target, GLuint index, GLsizei count, const GLfloat * params); /* 800 */
+   void (GLAPIENTRYP GetQueryObjecti64vEXT)(GLuint id, GLenum pname, GLint64EXT * params); /* 801 */
+   void (GLAPIENTRYP GetQueryObjectui64vEXT)(GLuint id, GLenum pname, GLuint64EXT * params); /* 802 */
 };
 
 #endif /* !defined( _GLAPI_TABLE_H_ ) */
index d9a3690f2add2dfc38efd294a2c72dcb7d0b0e3a..96b2ac726825b7f63116a9b03a557b9db38e2fa9 100644 (file)
@@ -4011,6 +4011,11 @@ 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(RenderbufferStorageMultisampleEXT)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
+{
+   DISPATCH(RenderbufferStorageMultisample, (target, samples, internalformat, width, height), (F, "glRenderbufferStorageMultisampleEXT(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));
@@ -5672,6 +5677,46 @@ 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 void KEYWORD2 NAME(ColorMaskIndexedEXT)(GLuint buf, GLboolean r, GLboolean g, GLboolean b, GLboolean a)
+{
+   DISPATCH(ColorMaskIndexedEXT, (buf, r, g, b, a), (F, "glColorMaskIndexedEXT(%d, %d, %d, %d, %d);\n", buf, r, g, b, a));
+}
+
+KEYWORD1 void KEYWORD2 NAME(DisableIndexedEXT)(GLenum target, GLuint index)
+{
+   DISPATCH(DisableIndexedEXT, (target, index), (F, "glDisableIndexedEXT(0x%x, %d);\n", target, index));
+}
+
+KEYWORD1 void KEYWORD2 NAME(EnableIndexedEXT)(GLenum target, GLuint index)
+{
+   DISPATCH(EnableIndexedEXT, (target, index), (F, "glEnableIndexedEXT(0x%x, %d);\n", target, index));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetBooleanIndexedvEXT)(GLenum value, GLuint index, GLboolean * data)
+{
+   DISPATCH(GetBooleanIndexedvEXT, (value, index, data), (F, "glGetBooleanIndexedvEXT(0x%x, %d, %p);\n", value, index, (const void *) data));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetIntegerIndexedvEXT)(GLenum value, GLuint index, GLint * data)
+{
+   DISPATCH(GetIntegerIndexedvEXT, (value, index, data), (F, "glGetIntegerIndexedvEXT(0x%x, %d, %p);\n", value, index, (const void *) data));
+}
+
+KEYWORD1 GLboolean KEYWORD2 NAME(IsEnabledIndexedEXT)(GLenum target, GLuint index)
+{
+   RETURN_DISPATCH(IsEnabledIndexedEXT, (target, index), (F, "glIsEnabledIndexedEXT(0x%x, %d);\n", target, index));
+}
+
+KEYWORD1 void KEYWORD2 NAME(BeginConditionalRenderNV)(GLuint query, GLenum mode)
+{
+   DISPATCH(BeginConditionalRenderNV, (query, mode), (F, "glBeginConditionalRenderNV(%d, 0x%x);\n", query, mode));
+}
+
+KEYWORD1 void KEYWORD2 NAME(EndConditionalRenderNV)(void)
+{
+   DISPATCH(EndConditionalRenderNV, (), (F, "glEndConditionalRenderNV();\n"));
+}
+
 KEYWORD1 void KEYWORD2 NAME(ProvokingVertexEXT)(GLenum mode)
 {
    DISPATCH(ProvokingVertexEXT, (mode), (F, "glProvokingVertexEXT(0x%x);\n", mode));
@@ -5682,51 +5727,51 @@ KEYWORD1 void KEYWORD2 NAME(ProvokingVertex)(GLenum mode)
    DISPATCH(ProvokingVertexEXT, (mode), (F, "glProvokingVertex(0x%x);\n", mode));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_788)(GLenum target, GLenum pname, GLvoid ** params);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_796)(GLenum target, GLenum pname, GLvoid ** params);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_788)(GLenum target, GLenum pname, GLvoid ** params)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_796)(GLenum target, GLenum pname, GLvoid ** params)
 {
    DISPATCH(GetTexParameterPointervAPPLE, (target, pname, params), (F, "glGetTexParameterPointervAPPLE(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_789)(GLenum target, GLsizei length, GLvoid * pointer);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_797)(GLenum target, GLsizei length, GLvoid * pointer);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_789)(GLenum target, GLsizei length, GLvoid * pointer)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_797)(GLenum target, GLsizei length, GLvoid * pointer)
 {
    DISPATCH(TextureRangeAPPLE, (target, length, pointer), (F, "glTextureRangeAPPLE(0x%x, %d, %p);\n", target, length, (const void *) pointer));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_790)(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_798)(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_790)(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_798)(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_791)(GLenum target, GLuint index, GLsizei count, const GLfloat * params);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_799)(GLenum target, GLuint index, GLsizei count, const GLfloat * params);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_791)(GLenum target, GLuint index, GLsizei count, const GLfloat * params)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_799)(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_792)(GLenum target, GLuint index, GLsizei count, const GLfloat * params);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_800)(GLenum target, GLuint index, GLsizei count, const GLfloat * params);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_792)(GLenum target, GLuint index, GLsizei count, const GLfloat * params)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_800)(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_793)(GLuint id, GLenum pname, GLint64EXT * params);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_801)(GLuint id, GLenum pname, GLint64EXT * params);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_793)(GLuint id, GLenum pname, GLint64EXT * params)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_801)(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_794)(GLuint id, GLenum pname, GLuint64EXT * params);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_802)(GLuint id, GLenum pname, GLuint64EXT * params);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_794)(GLuint id, GLenum pname, GLuint64EXT * params)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_802)(GLuint id, GLenum pname, GLuint64EXT * params)
 {
    DISPATCH(GetQueryObjectui64vEXT, (id, pname, params), (F, "glGetQueryObjectui64vEXT(%d, 0x%x, %p);\n", id, pname, (const void *) params));
 }
@@ -6532,14 +6577,22 @@ static _glapi_proc DISPATCH_TABLE_NAME[] = {
    TABLE_ENTRY(_dispatch_stub_784),
    TABLE_ENTRY(_dispatch_stub_785),
    TABLE_ENTRY(FramebufferTextureLayerEXT),
+   TABLE_ENTRY(ColorMaskIndexedEXT),
+   TABLE_ENTRY(DisableIndexedEXT),
+   TABLE_ENTRY(EnableIndexedEXT),
+   TABLE_ENTRY(GetBooleanIndexedvEXT),
+   TABLE_ENTRY(GetIntegerIndexedvEXT),
+   TABLE_ENTRY(IsEnabledIndexedEXT),
+   TABLE_ENTRY(BeginConditionalRenderNV),
+   TABLE_ENTRY(EndConditionalRenderNV),
    TABLE_ENTRY(ProvokingVertexEXT),
-   TABLE_ENTRY(_dispatch_stub_788),
-   TABLE_ENTRY(_dispatch_stub_789),
-   TABLE_ENTRY(_dispatch_stub_790),
-   TABLE_ENTRY(_dispatch_stub_791),
-   TABLE_ENTRY(_dispatch_stub_792),
-   TABLE_ENTRY(_dispatch_stub_793),
-   TABLE_ENTRY(_dispatch_stub_794),
+   TABLE_ENTRY(_dispatch_stub_796),
+   TABLE_ENTRY(_dispatch_stub_797),
+   TABLE_ENTRY(_dispatch_stub_798),
+   TABLE_ENTRY(_dispatch_stub_799),
+   TABLE_ENTRY(_dispatch_stub_800),
+   TABLE_ENTRY(_dispatch_stub_801),
+   TABLE_ENTRY(_dispatch_stub_802),
    /* 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.
@@ -6837,6 +6890,7 @@ static _glapi_proc UNUSED_TABLE_NAME[] = {
    TABLE_ENTRY(GetAttribLocation),
    TABLE_ENTRY(DrawBuffers),
    TABLE_ENTRY(DrawBuffersATI),
+   TABLE_ENTRY(RenderbufferStorageMultisampleEXT),
    TABLE_ENTRY(PointParameterf),
    TABLE_ENTRY(PointParameterfARB),
    TABLE_ENTRY(PointParameterfv),
index c29f8b57be96e97e7f4f5816e55f867d51adcb5b..b590a7c41d1b948859a8451471fa87761ed369ec 100644 (file)
@@ -839,6 +839,14 @@ static const char gl_string_table[] =
     "glBufferParameteriAPPLE\0"
     "glFlushMappedBufferRangeAPPLE\0"
     "glFramebufferTextureLayerEXT\0"
+    "glColorMaskIndexedEXT\0"
+    "glDisableIndexedEXT\0"
+    "glEnableIndexedEXT\0"
+    "glGetBooleanIndexedvEXT\0"
+    "glGetIntegerIndexedvEXT\0"
+    "glIsEnabledIndexedEXT\0"
+    "glBeginConditionalRenderNV\0"
+    "glEndConditionalRenderNV\0"
     "glProvokingVertexEXT\0"
     "glGetTexParameterPointervAPPLE\0"
     "glTextureRangeAPPLE\0"
@@ -1050,6 +1058,7 @@ static const char gl_string_table[] =
     "glGetAttribLocation\0"
     "glDrawBuffers\0"
     "glDrawBuffersATI\0"
+    "glRenderbufferStorageMultisampleEXT\0"
     "glSampleMaskEXT\0"
     "glSamplePatternEXT\0"
     "glPointParameterf\0"
@@ -1195,13 +1204,13 @@ static const char gl_string_table[] =
 #define gl_dispatch_stub_783 mgl_dispatch_stub_783
 #define gl_dispatch_stub_784 mgl_dispatch_stub_784
 #define gl_dispatch_stub_785 mgl_dispatch_stub_785
-#define gl_dispatch_stub_788 mgl_dispatch_stub_788
-#define gl_dispatch_stub_789 mgl_dispatch_stub_789
-#define gl_dispatch_stub_790 mgl_dispatch_stub_790
-#define gl_dispatch_stub_791 mgl_dispatch_stub_791
-#define gl_dispatch_stub_792 mgl_dispatch_stub_792
-#define gl_dispatch_stub_793 mgl_dispatch_stub_793
-#define gl_dispatch_stub_794 mgl_dispatch_stub_794
+#define gl_dispatch_stub_796 mgl_dispatch_stub_796
+#define gl_dispatch_stub_797 mgl_dispatch_stub_797
+#define gl_dispatch_stub_798 mgl_dispatch_stub_798
+#define gl_dispatch_stub_799 mgl_dispatch_stub_799
+#define gl_dispatch_stub_800 mgl_dispatch_stub_800
+#define gl_dispatch_stub_801 mgl_dispatch_stub_801
+#define gl_dispatch_stub_802 mgl_dispatch_stub_802
 #endif /* USE_MGL_NAMESPACE */
 
 
@@ -1249,13 +1258,13 @@ void GLAPIENTRY gl_dispatch_stub_765(GLenum modeRGB, GLenum modeA);
 void GLAPIENTRY gl_dispatch_stub_783(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_784(GLenum target, GLenum pname, GLint param);
 void GLAPIENTRY gl_dispatch_stub_785(GLenum target, GLintptr offset, GLsizeiptr size);
-void GLAPIENTRY gl_dispatch_stub_788(GLenum target, GLenum pname, GLvoid ** params);
-void GLAPIENTRY gl_dispatch_stub_789(GLenum target, GLsizei length, GLvoid * pointer);
-void GLAPIENTRY gl_dispatch_stub_790(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);
-void GLAPIENTRY gl_dispatch_stub_791(GLenum target, GLuint index, GLsizei count, const GLfloat * params);
-void GLAPIENTRY gl_dispatch_stub_792(GLenum target, GLuint index, GLsizei count, const GLfloat * params);
-void GLAPIENTRY gl_dispatch_stub_793(GLuint id, GLenum pname, GLint64EXT * params);
-void GLAPIENTRY gl_dispatch_stub_794(GLuint id, GLenum pname, GLuint64EXT * params);
+void GLAPIENTRY gl_dispatch_stub_796(GLenum target, GLenum pname, GLvoid ** params);
+void GLAPIENTRY gl_dispatch_stub_797(GLenum target, GLsizei length, GLvoid * pointer);
+void GLAPIENTRY gl_dispatch_stub_798(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);
+void GLAPIENTRY gl_dispatch_stub_799(GLenum target, GLuint index, GLsizei count, const GLfloat * params);
+void GLAPIENTRY gl_dispatch_stub_800(GLenum target, GLuint index, GLsizei count, const GLfloat * params);
+void GLAPIENTRY gl_dispatch_stub_801(GLuint id, GLenum pname, GLint64EXT * params);
+void GLAPIENTRY gl_dispatch_stub_802(GLuint id, GLenum pname, GLuint64EXT * params);
 #endif /* defined(NEED_FUNCTION_POINTER) || defined(GLX_INDIRECT_RENDERING) */
 
 static const glprocs_table_t static_functions[] = {
@@ -2046,315 +2055,324 @@ static const glprocs_table_t static_functions[] = {
     NAME_FUNC_OFFSET(13784, gl_dispatch_stub_784, gl_dispatch_stub_784, NULL, _gloffset_BufferParameteriAPPLE),
     NAME_FUNC_OFFSET(13808, gl_dispatch_stub_785, gl_dispatch_stub_785, NULL, _gloffset_FlushMappedBufferRangeAPPLE),
     NAME_FUNC_OFFSET(13838, glFramebufferTextureLayerEXT, glFramebufferTextureLayerEXT, NULL, _gloffset_FramebufferTextureLayerEXT),
-    NAME_FUNC_OFFSET(13867, glProvokingVertexEXT, glProvokingVertexEXT, NULL, _gloffset_ProvokingVertexEXT),
-    NAME_FUNC_OFFSET(13888, gl_dispatch_stub_788, gl_dispatch_stub_788, NULL, _gloffset_GetTexParameterPointervAPPLE),
-    NAME_FUNC_OFFSET(13919, gl_dispatch_stub_789, gl_dispatch_stub_789, NULL, _gloffset_TextureRangeAPPLE),
-    NAME_FUNC_OFFSET(13939, gl_dispatch_stub_790, gl_dispatch_stub_790, NULL, _gloffset_StencilFuncSeparateATI),
-    NAME_FUNC_OFFSET(13964, gl_dispatch_stub_791, gl_dispatch_stub_791, NULL, _gloffset_ProgramEnvParameters4fvEXT),
-    NAME_FUNC_OFFSET(13993, gl_dispatch_stub_792, gl_dispatch_stub_792, NULL, _gloffset_ProgramLocalParameters4fvEXT),
-    NAME_FUNC_OFFSET(14024, gl_dispatch_stub_793, gl_dispatch_stub_793, NULL, _gloffset_GetQueryObjecti64vEXT),
-    NAME_FUNC_OFFSET(14048, gl_dispatch_stub_794, gl_dispatch_stub_794, NULL, _gloffset_GetQueryObjectui64vEXT),
-    NAME_FUNC_OFFSET(14073, glArrayElement, glArrayElement, NULL, _gloffset_ArrayElement),
-    NAME_FUNC_OFFSET(14091, glBindTexture, glBindTexture, NULL, _gloffset_BindTexture),
-    NAME_FUNC_OFFSET(14108, glDrawArrays, glDrawArrays, NULL, _gloffset_DrawArrays),
-    NAME_FUNC_OFFSET(14124, glAreTexturesResident, glAreTexturesResidentEXT, glAreTexturesResidentEXT, _gloffset_AreTexturesResident),
-    NAME_FUNC_OFFSET(14149, glCopyTexImage1D, glCopyTexImage1D, NULL, _gloffset_CopyTexImage1D),
-    NAME_FUNC_OFFSET(14169, glCopyTexImage2D, glCopyTexImage2D, NULL, _gloffset_CopyTexImage2D),
-    NAME_FUNC_OFFSET(14189, glCopyTexSubImage1D, glCopyTexSubImage1D, NULL, _gloffset_CopyTexSubImage1D),
-    NAME_FUNC_OFFSET(14212, glCopyTexSubImage2D, glCopyTexSubImage2D, NULL, _gloffset_CopyTexSubImage2D),
-    NAME_FUNC_OFFSET(14235, glDeleteTextures, glDeleteTexturesEXT, glDeleteTexturesEXT, _gloffset_DeleteTextures),
-    NAME_FUNC_OFFSET(14255, glGenTextures, glGenTexturesEXT, glGenTexturesEXT, _gloffset_GenTextures),
-    NAME_FUNC_OFFSET(14272, glGetPointerv, glGetPointerv, NULL, _gloffset_GetPointerv),
-    NAME_FUNC_OFFSET(14289, glIsTexture, glIsTextureEXT, glIsTextureEXT, _gloffset_IsTexture),
-    NAME_FUNC_OFFSET(14304, glPrioritizeTextures, glPrioritizeTextures, NULL, _gloffset_PrioritizeTextures),
-    NAME_FUNC_OFFSET(14328, glTexSubImage1D, glTexSubImage1D, NULL, _gloffset_TexSubImage1D),
-    NAME_FUNC_OFFSET(14347, glTexSubImage2D, glTexSubImage2D, NULL, _gloffset_TexSubImage2D),
-    NAME_FUNC_OFFSET(14366, glBlendColor, glBlendColor, NULL, _gloffset_BlendColor),
-    NAME_FUNC_OFFSET(14382, glBlendEquation, glBlendEquation, NULL, _gloffset_BlendEquation),
-    NAME_FUNC_OFFSET(14401, glDrawRangeElements, glDrawRangeElements, NULL, _gloffset_DrawRangeElements),
-    NAME_FUNC_OFFSET(14424, glColorTable, glColorTable, NULL, _gloffset_ColorTable),
-    NAME_FUNC_OFFSET(14440, glColorTable, glColorTable, NULL, _gloffset_ColorTable),
-    NAME_FUNC_OFFSET(14456, glColorTableParameterfv, glColorTableParameterfv, NULL, _gloffset_ColorTableParameterfv),
-    NAME_FUNC_OFFSET(14483, glColorTableParameteriv, glColorTableParameteriv, NULL, _gloffset_ColorTableParameteriv),
-    NAME_FUNC_OFFSET(14510, glCopyColorTable, glCopyColorTable, NULL, _gloffset_CopyColorTable),
-    NAME_FUNC_OFFSET(14530, glGetColorTable, glGetColorTableEXT, glGetColorTableEXT, _gloffset_GetColorTable),
-    NAME_FUNC_OFFSET(14549, glGetColorTable, glGetColorTableEXT, glGetColorTableEXT, _gloffset_GetColorTable),
-    NAME_FUNC_OFFSET(14568, glGetColorTableParameterfv, glGetColorTableParameterfvEXT, glGetColorTableParameterfvEXT, _gloffset_GetColorTableParameterfv),
-    NAME_FUNC_OFFSET(14598, glGetColorTableParameterfv, glGetColorTableParameterfvEXT, glGetColorTableParameterfvEXT, _gloffset_GetColorTableParameterfv),
-    NAME_FUNC_OFFSET(14628, glGetColorTableParameteriv, glGetColorTableParameterivEXT, glGetColorTableParameterivEXT, _gloffset_GetColorTableParameteriv),
-    NAME_FUNC_OFFSET(14658, glGetColorTableParameteriv, glGetColorTableParameterivEXT, glGetColorTableParameterivEXT, _gloffset_GetColorTableParameteriv),
-    NAME_FUNC_OFFSET(14688, glColorSubTable, glColorSubTable, NULL, _gloffset_ColorSubTable),
-    NAME_FUNC_OFFSET(14707, glCopyColorSubTable, glCopyColorSubTable, NULL, _gloffset_CopyColorSubTable),
-    NAME_FUNC_OFFSET(14730, glConvolutionFilter1D, glConvolutionFilter1D, NULL, _gloffset_ConvolutionFilter1D),
-    NAME_FUNC_OFFSET(14755, glConvolutionFilter2D, glConvolutionFilter2D, NULL, _gloffset_ConvolutionFilter2D),
-    NAME_FUNC_OFFSET(14780, glConvolutionParameterf, glConvolutionParameterf, NULL, _gloffset_ConvolutionParameterf),
-    NAME_FUNC_OFFSET(14807, glConvolutionParameterfv, glConvolutionParameterfv, NULL, _gloffset_ConvolutionParameterfv),
-    NAME_FUNC_OFFSET(14835, glConvolutionParameteri, glConvolutionParameteri, NULL, _gloffset_ConvolutionParameteri),
-    NAME_FUNC_OFFSET(14862, glConvolutionParameteriv, glConvolutionParameteriv, NULL, _gloffset_ConvolutionParameteriv),
-    NAME_FUNC_OFFSET(14890, glCopyConvolutionFilter1D, glCopyConvolutionFilter1D, NULL, _gloffset_CopyConvolutionFilter1D),
-    NAME_FUNC_OFFSET(14919, glCopyConvolutionFilter2D, glCopyConvolutionFilter2D, NULL, _gloffset_CopyConvolutionFilter2D),
-    NAME_FUNC_OFFSET(14948, glGetConvolutionFilter, gl_dispatch_stub_356, gl_dispatch_stub_356, _gloffset_GetConvolutionFilter),
-    NAME_FUNC_OFFSET(14974, glGetConvolutionParameterfv, gl_dispatch_stub_357, gl_dispatch_stub_357, _gloffset_GetConvolutionParameterfv),
-    NAME_FUNC_OFFSET(15005, glGetConvolutionParameteriv, gl_dispatch_stub_358, gl_dispatch_stub_358, _gloffset_GetConvolutionParameteriv),
-    NAME_FUNC_OFFSET(15036, glGetSeparableFilter, gl_dispatch_stub_359, gl_dispatch_stub_359, _gloffset_GetSeparableFilter),
-    NAME_FUNC_OFFSET(15060, glSeparableFilter2D, glSeparableFilter2D, NULL, _gloffset_SeparableFilter2D),
-    NAME_FUNC_OFFSET(15083, glGetHistogram, gl_dispatch_stub_361, gl_dispatch_stub_361, _gloffset_GetHistogram),
-    NAME_FUNC_OFFSET(15101, glGetHistogramParameterfv, gl_dispatch_stub_362, gl_dispatch_stub_362, _gloffset_GetHistogramParameterfv),
-    NAME_FUNC_OFFSET(15130, glGetHistogramParameteriv, gl_dispatch_stub_363, gl_dispatch_stub_363, _gloffset_GetHistogramParameteriv),
-    NAME_FUNC_OFFSET(15159, glGetMinmax, gl_dispatch_stub_364, gl_dispatch_stub_364, _gloffset_GetMinmax),
-    NAME_FUNC_OFFSET(15174, glGetMinmaxParameterfv, gl_dispatch_stub_365, gl_dispatch_stub_365, _gloffset_GetMinmaxParameterfv),
-    NAME_FUNC_OFFSET(15200, glGetMinmaxParameteriv, gl_dispatch_stub_366, gl_dispatch_stub_366, _gloffset_GetMinmaxParameteriv),
-    NAME_FUNC_OFFSET(15226, glHistogram, glHistogram, NULL, _gloffset_Histogram),
-    NAME_FUNC_OFFSET(15241, glMinmax, glMinmax, NULL, _gloffset_Minmax),
-    NAME_FUNC_OFFSET(15253, glResetHistogram, glResetHistogram, NULL, _gloffset_ResetHistogram),
-    NAME_FUNC_OFFSET(15273, glResetMinmax, glResetMinmax, NULL, _gloffset_ResetMinmax),
-    NAME_FUNC_OFFSET(15290, glTexImage3D, glTexImage3D, NULL, _gloffset_TexImage3D),
-    NAME_FUNC_OFFSET(15306, glTexSubImage3D, glTexSubImage3D, NULL, _gloffset_TexSubImage3D),
-    NAME_FUNC_OFFSET(15325, glCopyTexSubImage3D, glCopyTexSubImage3D, NULL, _gloffset_CopyTexSubImage3D),
-    NAME_FUNC_OFFSET(15348, glActiveTextureARB, glActiveTextureARB, NULL, _gloffset_ActiveTextureARB),
-    NAME_FUNC_OFFSET(15364, glClientActiveTextureARB, glClientActiveTextureARB, NULL, _gloffset_ClientActiveTextureARB),
-    NAME_FUNC_OFFSET(15386, glMultiTexCoord1dARB, glMultiTexCoord1dARB, NULL, _gloffset_MultiTexCoord1dARB),
-    NAME_FUNC_OFFSET(15404, glMultiTexCoord1dvARB, glMultiTexCoord1dvARB, NULL, _gloffset_MultiTexCoord1dvARB),
-    NAME_FUNC_OFFSET(15423, glMultiTexCoord1fARB, glMultiTexCoord1fARB, NULL, _gloffset_MultiTexCoord1fARB),
-    NAME_FUNC_OFFSET(15441, glMultiTexCoord1fvARB, glMultiTexCoord1fvARB, NULL, _gloffset_MultiTexCoord1fvARB),
-    NAME_FUNC_OFFSET(15460, glMultiTexCoord1iARB, glMultiTexCoord1iARB, NULL, _gloffset_MultiTexCoord1iARB),
-    NAME_FUNC_OFFSET(15478, glMultiTexCoord1ivARB, glMultiTexCoord1ivARB, NULL, _gloffset_MultiTexCoord1ivARB),
-    NAME_FUNC_OFFSET(15497, glMultiTexCoord1sARB, glMultiTexCoord1sARB, NULL, _gloffset_MultiTexCoord1sARB),
-    NAME_FUNC_OFFSET(15515, glMultiTexCoord1svARB, glMultiTexCoord1svARB, NULL, _gloffset_MultiTexCoord1svARB),
-    NAME_FUNC_OFFSET(15534, glMultiTexCoord2dARB, glMultiTexCoord2dARB, NULL, _gloffset_MultiTexCoord2dARB),
-    NAME_FUNC_OFFSET(15552, glMultiTexCoord2dvARB, glMultiTexCoord2dvARB, NULL, _gloffset_MultiTexCoord2dvARB),
-    NAME_FUNC_OFFSET(15571, glMultiTexCoord2fARB, glMultiTexCoord2fARB, NULL, _gloffset_MultiTexCoord2fARB),
-    NAME_FUNC_OFFSET(15589, glMultiTexCoord2fvARB, glMultiTexCoord2fvARB, NULL, _gloffset_MultiTexCoord2fvARB),
-    NAME_FUNC_OFFSET(15608, glMultiTexCoord2iARB, glMultiTexCoord2iARB, NULL, _gloffset_MultiTexCoord2iARB),
-    NAME_FUNC_OFFSET(15626, glMultiTexCoord2ivARB, glMultiTexCoord2ivARB, NULL, _gloffset_MultiTexCoord2ivARB),
-    NAME_FUNC_OFFSET(15645, glMultiTexCoord2sARB, glMultiTexCoord2sARB, NULL, _gloffset_MultiTexCoord2sARB),
-    NAME_FUNC_OFFSET(15663, glMultiTexCoord2svARB, glMultiTexCoord2svARB, NULL, _gloffset_MultiTexCoord2svARB),
-    NAME_FUNC_OFFSET(15682, glMultiTexCoord3dARB, glMultiTexCoord3dARB, NULL, _gloffset_MultiTexCoord3dARB),
-    NAME_FUNC_OFFSET(15700, glMultiTexCoord3dvARB, glMultiTexCoord3dvARB, NULL, _gloffset_MultiTexCoord3dvARB),
-    NAME_FUNC_OFFSET(15719, glMultiTexCoord3fARB, glMultiTexCoord3fARB, NULL, _gloffset_MultiTexCoord3fARB),
-    NAME_FUNC_OFFSET(15737, glMultiTexCoord3fvARB, glMultiTexCoord3fvARB, NULL, _gloffset_MultiTexCoord3fvARB),
-    NAME_FUNC_OFFSET(15756, glMultiTexCoord3iARB, glMultiTexCoord3iARB, NULL, _gloffset_MultiTexCoord3iARB),
-    NAME_FUNC_OFFSET(15774, glMultiTexCoord3ivARB, glMultiTexCoord3ivARB, NULL, _gloffset_MultiTexCoord3ivARB),
-    NAME_FUNC_OFFSET(15793, glMultiTexCoord3sARB, glMultiTexCoord3sARB, NULL, _gloffset_MultiTexCoord3sARB),
-    NAME_FUNC_OFFSET(15811, glMultiTexCoord3svARB, glMultiTexCoord3svARB, NULL, _gloffset_MultiTexCoord3svARB),
-    NAME_FUNC_OFFSET(15830, glMultiTexCoord4dARB, glMultiTexCoord4dARB, NULL, _gloffset_MultiTexCoord4dARB),
-    NAME_FUNC_OFFSET(15848, glMultiTexCoord4dvARB, glMultiTexCoord4dvARB, NULL, _gloffset_MultiTexCoord4dvARB),
-    NAME_FUNC_OFFSET(15867, glMultiTexCoord4fARB, glMultiTexCoord4fARB, NULL, _gloffset_MultiTexCoord4fARB),
-    NAME_FUNC_OFFSET(15885, glMultiTexCoord4fvARB, glMultiTexCoord4fvARB, NULL, _gloffset_MultiTexCoord4fvARB),
-    NAME_FUNC_OFFSET(15904, glMultiTexCoord4iARB, glMultiTexCoord4iARB, NULL, _gloffset_MultiTexCoord4iARB),
-    NAME_FUNC_OFFSET(15922, glMultiTexCoord4ivARB, glMultiTexCoord4ivARB, NULL, _gloffset_MultiTexCoord4ivARB),
-    NAME_FUNC_OFFSET(15941, glMultiTexCoord4sARB, glMultiTexCoord4sARB, NULL, _gloffset_MultiTexCoord4sARB),
-    NAME_FUNC_OFFSET(15959, glMultiTexCoord4svARB, glMultiTexCoord4svARB, NULL, _gloffset_MultiTexCoord4svARB),
-    NAME_FUNC_OFFSET(15978, glStencilOpSeparate, glStencilOpSeparate, NULL, _gloffset_StencilOpSeparate),
-    NAME_FUNC_OFFSET(16001, glLoadTransposeMatrixdARB, glLoadTransposeMatrixdARB, NULL, _gloffset_LoadTransposeMatrixdARB),
-    NAME_FUNC_OFFSET(16024, glLoadTransposeMatrixfARB, glLoadTransposeMatrixfARB, NULL, _gloffset_LoadTransposeMatrixfARB),
-    NAME_FUNC_OFFSET(16047, glMultTransposeMatrixdARB, glMultTransposeMatrixdARB, NULL, _gloffset_MultTransposeMatrixdARB),
-    NAME_FUNC_OFFSET(16070, glMultTransposeMatrixfARB, glMultTransposeMatrixfARB, NULL, _gloffset_MultTransposeMatrixfARB),
-    NAME_FUNC_OFFSET(16093, glSampleCoverageARB, glSampleCoverageARB, NULL, _gloffset_SampleCoverageARB),
-    NAME_FUNC_OFFSET(16110, glCompressedTexImage1DARB, glCompressedTexImage1DARB, NULL, _gloffset_CompressedTexImage1DARB),
-    NAME_FUNC_OFFSET(16133, glCompressedTexImage2DARB, glCompressedTexImage2DARB, NULL, _gloffset_CompressedTexImage2DARB),
-    NAME_FUNC_OFFSET(16156, glCompressedTexImage3DARB, glCompressedTexImage3DARB, NULL, _gloffset_CompressedTexImage3DARB),
-    NAME_FUNC_OFFSET(16179, glCompressedTexSubImage1DARB, glCompressedTexSubImage1DARB, NULL, _gloffset_CompressedTexSubImage1DARB),
-    NAME_FUNC_OFFSET(16205, glCompressedTexSubImage2DARB, glCompressedTexSubImage2DARB, NULL, _gloffset_CompressedTexSubImage2DARB),
-    NAME_FUNC_OFFSET(16231, glCompressedTexSubImage3DARB, glCompressedTexSubImage3DARB, NULL, _gloffset_CompressedTexSubImage3DARB),
-    NAME_FUNC_OFFSET(16257, glGetCompressedTexImageARB, glGetCompressedTexImageARB, NULL, _gloffset_GetCompressedTexImageARB),
-    NAME_FUNC_OFFSET(16281, glDisableVertexAttribArrayARB, glDisableVertexAttribArrayARB, NULL, _gloffset_DisableVertexAttribArrayARB),
-    NAME_FUNC_OFFSET(16308, glEnableVertexAttribArrayARB, glEnableVertexAttribArrayARB, NULL, _gloffset_EnableVertexAttribArrayARB),
-    NAME_FUNC_OFFSET(16334, glGetVertexAttribdvARB, glGetVertexAttribdvARB, NULL, _gloffset_GetVertexAttribdvARB),
-    NAME_FUNC_OFFSET(16354, glGetVertexAttribfvARB, glGetVertexAttribfvARB, NULL, _gloffset_GetVertexAttribfvARB),
-    NAME_FUNC_OFFSET(16374, glGetVertexAttribivARB, glGetVertexAttribivARB, NULL, _gloffset_GetVertexAttribivARB),
-    NAME_FUNC_OFFSET(16394, glProgramEnvParameter4dARB, glProgramEnvParameter4dARB, NULL, _gloffset_ProgramEnvParameter4dARB),
-    NAME_FUNC_OFFSET(16417, glProgramEnvParameter4dvARB, glProgramEnvParameter4dvARB, NULL, _gloffset_ProgramEnvParameter4dvARB),
-    NAME_FUNC_OFFSET(16441, glProgramEnvParameter4fARB, glProgramEnvParameter4fARB, NULL, _gloffset_ProgramEnvParameter4fARB),
-    NAME_FUNC_OFFSET(16464, glProgramEnvParameter4fvARB, glProgramEnvParameter4fvARB, NULL, _gloffset_ProgramEnvParameter4fvARB),
-    NAME_FUNC_OFFSET(16488, glVertexAttrib1dARB, glVertexAttrib1dARB, NULL, _gloffset_VertexAttrib1dARB),
-    NAME_FUNC_OFFSET(16505, glVertexAttrib1dvARB, glVertexAttrib1dvARB, NULL, _gloffset_VertexAttrib1dvARB),
-    NAME_FUNC_OFFSET(16523, glVertexAttrib1fARB, glVertexAttrib1fARB, NULL, _gloffset_VertexAttrib1fARB),
-    NAME_FUNC_OFFSET(16540, glVertexAttrib1fvARB, glVertexAttrib1fvARB, NULL, _gloffset_VertexAttrib1fvARB),
-    NAME_FUNC_OFFSET(16558, glVertexAttrib1sARB, glVertexAttrib1sARB, NULL, _gloffset_VertexAttrib1sARB),
-    NAME_FUNC_OFFSET(16575, glVertexAttrib1svARB, glVertexAttrib1svARB, NULL, _gloffset_VertexAttrib1svARB),
-    NAME_FUNC_OFFSET(16593, glVertexAttrib2dARB, glVertexAttrib2dARB, NULL, _gloffset_VertexAttrib2dARB),
-    NAME_FUNC_OFFSET(16610, glVertexAttrib2dvARB, glVertexAttrib2dvARB, NULL, _gloffset_VertexAttrib2dvARB),
-    NAME_FUNC_OFFSET(16628, glVertexAttrib2fARB, glVertexAttrib2fARB, NULL, _gloffset_VertexAttrib2fARB),
-    NAME_FUNC_OFFSET(16645, glVertexAttrib2fvARB, glVertexAttrib2fvARB, NULL, _gloffset_VertexAttrib2fvARB),
-    NAME_FUNC_OFFSET(16663, glVertexAttrib2sARB, glVertexAttrib2sARB, NULL, _gloffset_VertexAttrib2sARB),
-    NAME_FUNC_OFFSET(16680, glVertexAttrib2svARB, glVertexAttrib2svARB, NULL, _gloffset_VertexAttrib2svARB),
-    NAME_FUNC_OFFSET(16698, glVertexAttrib3dARB, glVertexAttrib3dARB, NULL, _gloffset_VertexAttrib3dARB),
-    NAME_FUNC_OFFSET(16715, glVertexAttrib3dvARB, glVertexAttrib3dvARB, NULL, _gloffset_VertexAttrib3dvARB),
-    NAME_FUNC_OFFSET(16733, glVertexAttrib3fARB, glVertexAttrib3fARB, NULL, _gloffset_VertexAttrib3fARB),
-    NAME_FUNC_OFFSET(16750, glVertexAttrib3fvARB, glVertexAttrib3fvARB, NULL, _gloffset_VertexAttrib3fvARB),
-    NAME_FUNC_OFFSET(16768, glVertexAttrib3sARB, glVertexAttrib3sARB, NULL, _gloffset_VertexAttrib3sARB),
-    NAME_FUNC_OFFSET(16785, glVertexAttrib3svARB, glVertexAttrib3svARB, NULL, _gloffset_VertexAttrib3svARB),
-    NAME_FUNC_OFFSET(16803, glVertexAttrib4NbvARB, glVertexAttrib4NbvARB, NULL, _gloffset_VertexAttrib4NbvARB),
-    NAME_FUNC_OFFSET(16822, glVertexAttrib4NivARB, glVertexAttrib4NivARB, NULL, _gloffset_VertexAttrib4NivARB),
-    NAME_FUNC_OFFSET(16841, glVertexAttrib4NsvARB, glVertexAttrib4NsvARB, NULL, _gloffset_VertexAttrib4NsvARB),
-    NAME_FUNC_OFFSET(16860, glVertexAttrib4NubARB, glVertexAttrib4NubARB, NULL, _gloffset_VertexAttrib4NubARB),
-    NAME_FUNC_OFFSET(16879, glVertexAttrib4NubvARB, glVertexAttrib4NubvARB, NULL, _gloffset_VertexAttrib4NubvARB),
-    NAME_FUNC_OFFSET(16899, glVertexAttrib4NuivARB, glVertexAttrib4NuivARB, NULL, _gloffset_VertexAttrib4NuivARB),
-    NAME_FUNC_OFFSET(16919, glVertexAttrib4NusvARB, glVertexAttrib4NusvARB, NULL, _gloffset_VertexAttrib4NusvARB),
-    NAME_FUNC_OFFSET(16939, glVertexAttrib4bvARB, glVertexAttrib4bvARB, NULL, _gloffset_VertexAttrib4bvARB),
-    NAME_FUNC_OFFSET(16957, glVertexAttrib4dARB, glVertexAttrib4dARB, NULL, _gloffset_VertexAttrib4dARB),
-    NAME_FUNC_OFFSET(16974, glVertexAttrib4dvARB, glVertexAttrib4dvARB, NULL, _gloffset_VertexAttrib4dvARB),
-    NAME_FUNC_OFFSET(16992, glVertexAttrib4fARB, glVertexAttrib4fARB, NULL, _gloffset_VertexAttrib4fARB),
-    NAME_FUNC_OFFSET(17009, glVertexAttrib4fvARB, glVertexAttrib4fvARB, NULL, _gloffset_VertexAttrib4fvARB),
-    NAME_FUNC_OFFSET(17027, glVertexAttrib4ivARB, glVertexAttrib4ivARB, NULL, _gloffset_VertexAttrib4ivARB),
-    NAME_FUNC_OFFSET(17045, glVertexAttrib4sARB, glVertexAttrib4sARB, NULL, _gloffset_VertexAttrib4sARB),
-    NAME_FUNC_OFFSET(17062, glVertexAttrib4svARB, glVertexAttrib4svARB, NULL, _gloffset_VertexAttrib4svARB),
-    NAME_FUNC_OFFSET(17080, glVertexAttrib4ubvARB, glVertexAttrib4ubvARB, NULL, _gloffset_VertexAttrib4ubvARB),
-    NAME_FUNC_OFFSET(17099, glVertexAttrib4uivARB, glVertexAttrib4uivARB, NULL, _gloffset_VertexAttrib4uivARB),
-    NAME_FUNC_OFFSET(17118, glVertexAttrib4usvARB, glVertexAttrib4usvARB, NULL, _gloffset_VertexAttrib4usvARB),
-    NAME_FUNC_OFFSET(17137, glVertexAttribPointerARB, glVertexAttribPointerARB, NULL, _gloffset_VertexAttribPointerARB),
-    NAME_FUNC_OFFSET(17159, glBindBufferARB, glBindBufferARB, NULL, _gloffset_BindBufferARB),
-    NAME_FUNC_OFFSET(17172, glBufferDataARB, glBufferDataARB, NULL, _gloffset_BufferDataARB),
-    NAME_FUNC_OFFSET(17185, glBufferSubDataARB, glBufferSubDataARB, NULL, _gloffset_BufferSubDataARB),
-    NAME_FUNC_OFFSET(17201, glDeleteBuffersARB, glDeleteBuffersARB, NULL, _gloffset_DeleteBuffersARB),
-    NAME_FUNC_OFFSET(17217, glGenBuffersARB, glGenBuffersARB, NULL, _gloffset_GenBuffersARB),
-    NAME_FUNC_OFFSET(17230, glGetBufferParameterivARB, glGetBufferParameterivARB, NULL, _gloffset_GetBufferParameterivARB),
-    NAME_FUNC_OFFSET(17253, glGetBufferPointervARB, glGetBufferPointervARB, NULL, _gloffset_GetBufferPointervARB),
-    NAME_FUNC_OFFSET(17273, glGetBufferSubDataARB, glGetBufferSubDataARB, NULL, _gloffset_GetBufferSubDataARB),
-    NAME_FUNC_OFFSET(17292, glIsBufferARB, glIsBufferARB, NULL, _gloffset_IsBufferARB),
-    NAME_FUNC_OFFSET(17303, glMapBufferARB, glMapBufferARB, NULL, _gloffset_MapBufferARB),
-    NAME_FUNC_OFFSET(17315, glUnmapBufferARB, glUnmapBufferARB, NULL, _gloffset_UnmapBufferARB),
-    NAME_FUNC_OFFSET(17329, glBeginQueryARB, glBeginQueryARB, NULL, _gloffset_BeginQueryARB),
-    NAME_FUNC_OFFSET(17342, glDeleteQueriesARB, glDeleteQueriesARB, NULL, _gloffset_DeleteQueriesARB),
-    NAME_FUNC_OFFSET(17358, glEndQueryARB, glEndQueryARB, NULL, _gloffset_EndQueryARB),
-    NAME_FUNC_OFFSET(17369, glGenQueriesARB, glGenQueriesARB, NULL, _gloffset_GenQueriesARB),
-    NAME_FUNC_OFFSET(17382, glGetQueryObjectivARB, glGetQueryObjectivARB, NULL, _gloffset_GetQueryObjectivARB),
-    NAME_FUNC_OFFSET(17401, glGetQueryObjectuivARB, glGetQueryObjectuivARB, NULL, _gloffset_GetQueryObjectuivARB),
-    NAME_FUNC_OFFSET(17421, glGetQueryivARB, glGetQueryivARB, NULL, _gloffset_GetQueryivARB),
-    NAME_FUNC_OFFSET(17434, glIsQueryARB, glIsQueryARB, NULL, _gloffset_IsQueryARB),
-    NAME_FUNC_OFFSET(17444, glCompileShaderARB, glCompileShaderARB, NULL, _gloffset_CompileShaderARB),
-    NAME_FUNC_OFFSET(17460, glGetActiveUniformARB, glGetActiveUniformARB, NULL, _gloffset_GetActiveUniformARB),
-    NAME_FUNC_OFFSET(17479, glGetShaderSourceARB, glGetShaderSourceARB, NULL, _gloffset_GetShaderSourceARB),
-    NAME_FUNC_OFFSET(17497, glGetUniformLocationARB, glGetUniformLocationARB, NULL, _gloffset_GetUniformLocationARB),
-    NAME_FUNC_OFFSET(17518, glGetUniformfvARB, glGetUniformfvARB, NULL, _gloffset_GetUniformfvARB),
-    NAME_FUNC_OFFSET(17533, glGetUniformivARB, glGetUniformivARB, NULL, _gloffset_GetUniformivARB),
-    NAME_FUNC_OFFSET(17548, glLinkProgramARB, glLinkProgramARB, NULL, _gloffset_LinkProgramARB),
-    NAME_FUNC_OFFSET(17562, glShaderSourceARB, glShaderSourceARB, NULL, _gloffset_ShaderSourceARB),
-    NAME_FUNC_OFFSET(17577, glUniform1fARB, glUniform1fARB, NULL, _gloffset_Uniform1fARB),
-    NAME_FUNC_OFFSET(17589, glUniform1fvARB, glUniform1fvARB, NULL, _gloffset_Uniform1fvARB),
-    NAME_FUNC_OFFSET(17602, glUniform1iARB, glUniform1iARB, NULL, _gloffset_Uniform1iARB),
-    NAME_FUNC_OFFSET(17614, glUniform1ivARB, glUniform1ivARB, NULL, _gloffset_Uniform1ivARB),
-    NAME_FUNC_OFFSET(17627, glUniform2fARB, glUniform2fARB, NULL, _gloffset_Uniform2fARB),
-    NAME_FUNC_OFFSET(17639, glUniform2fvARB, glUniform2fvARB, NULL, _gloffset_Uniform2fvARB),
-    NAME_FUNC_OFFSET(17652, glUniform2iARB, glUniform2iARB, NULL, _gloffset_Uniform2iARB),
-    NAME_FUNC_OFFSET(17664, glUniform2ivARB, glUniform2ivARB, NULL, _gloffset_Uniform2ivARB),
-    NAME_FUNC_OFFSET(17677, glUniform3fARB, glUniform3fARB, NULL, _gloffset_Uniform3fARB),
-    NAME_FUNC_OFFSET(17689, glUniform3fvARB, glUniform3fvARB, NULL, _gloffset_Uniform3fvARB),
-    NAME_FUNC_OFFSET(17702, glUniform3iARB, glUniform3iARB, NULL, _gloffset_Uniform3iARB),
-    NAME_FUNC_OFFSET(17714, glUniform3ivARB, glUniform3ivARB, NULL, _gloffset_Uniform3ivARB),
-    NAME_FUNC_OFFSET(17727, glUniform4fARB, glUniform4fARB, NULL, _gloffset_Uniform4fARB),
-    NAME_FUNC_OFFSET(17739, glUniform4fvARB, glUniform4fvARB, NULL, _gloffset_Uniform4fvARB),
-    NAME_FUNC_OFFSET(17752, glUniform4iARB, glUniform4iARB, NULL, _gloffset_Uniform4iARB),
-    NAME_FUNC_OFFSET(17764, glUniform4ivARB, glUniform4ivARB, NULL, _gloffset_Uniform4ivARB),
-    NAME_FUNC_OFFSET(17777, glUniformMatrix2fvARB, glUniformMatrix2fvARB, NULL, _gloffset_UniformMatrix2fvARB),
-    NAME_FUNC_OFFSET(17796, glUniformMatrix3fvARB, glUniformMatrix3fvARB, NULL, _gloffset_UniformMatrix3fvARB),
-    NAME_FUNC_OFFSET(17815, glUniformMatrix4fvARB, glUniformMatrix4fvARB, NULL, _gloffset_UniformMatrix4fvARB),
-    NAME_FUNC_OFFSET(17834, glUseProgramObjectARB, glUseProgramObjectARB, NULL, _gloffset_UseProgramObjectARB),
-    NAME_FUNC_OFFSET(17847, glValidateProgramARB, glValidateProgramARB, NULL, _gloffset_ValidateProgramARB),
-    NAME_FUNC_OFFSET(17865, glBindAttribLocationARB, glBindAttribLocationARB, NULL, _gloffset_BindAttribLocationARB),
-    NAME_FUNC_OFFSET(17886, glGetActiveAttribARB, glGetActiveAttribARB, NULL, _gloffset_GetActiveAttribARB),
-    NAME_FUNC_OFFSET(17904, glGetAttribLocationARB, glGetAttribLocationARB, NULL, _gloffset_GetAttribLocationARB),
-    NAME_FUNC_OFFSET(17924, glDrawBuffersARB, glDrawBuffersARB, NULL, _gloffset_DrawBuffersARB),
-    NAME_FUNC_OFFSET(17938, glDrawBuffersARB, glDrawBuffersARB, NULL, _gloffset_DrawBuffersARB),
-    NAME_FUNC_OFFSET(17955, gl_dispatch_stub_584, gl_dispatch_stub_584, NULL, _gloffset_SampleMaskSGIS),
-    NAME_FUNC_OFFSET(17971, gl_dispatch_stub_585, gl_dispatch_stub_585, NULL, _gloffset_SamplePatternSGIS),
-    NAME_FUNC_OFFSET(17990, glPointParameterfEXT, glPointParameterfEXT, NULL, _gloffset_PointParameterfEXT),
-    NAME_FUNC_OFFSET(18008, glPointParameterfEXT, glPointParameterfEXT, NULL, _gloffset_PointParameterfEXT),
-    NAME_FUNC_OFFSET(18029, glPointParameterfEXT, glPointParameterfEXT, NULL, _gloffset_PointParameterfEXT),
-    NAME_FUNC_OFFSET(18051, glPointParameterfvEXT, glPointParameterfvEXT, NULL, _gloffset_PointParameterfvEXT),
-    NAME_FUNC_OFFSET(18070, glPointParameterfvEXT, glPointParameterfvEXT, NULL, _gloffset_PointParameterfvEXT),
-    NAME_FUNC_OFFSET(18092, glPointParameterfvEXT, glPointParameterfvEXT, NULL, _gloffset_PointParameterfvEXT),
-    NAME_FUNC_OFFSET(18115, glSecondaryColor3bEXT, glSecondaryColor3bEXT, NULL, _gloffset_SecondaryColor3bEXT),
-    NAME_FUNC_OFFSET(18134, glSecondaryColor3bvEXT, glSecondaryColor3bvEXT, NULL, _gloffset_SecondaryColor3bvEXT),
-    NAME_FUNC_OFFSET(18154, glSecondaryColor3dEXT, glSecondaryColor3dEXT, NULL, _gloffset_SecondaryColor3dEXT),
-    NAME_FUNC_OFFSET(18173, glSecondaryColor3dvEXT, glSecondaryColor3dvEXT, NULL, _gloffset_SecondaryColor3dvEXT),
-    NAME_FUNC_OFFSET(18193, glSecondaryColor3fEXT, glSecondaryColor3fEXT, NULL, _gloffset_SecondaryColor3fEXT),
-    NAME_FUNC_OFFSET(18212, glSecondaryColor3fvEXT, glSecondaryColor3fvEXT, NULL, _gloffset_SecondaryColor3fvEXT),
-    NAME_FUNC_OFFSET(18232, glSecondaryColor3iEXT, glSecondaryColor3iEXT, NULL, _gloffset_SecondaryColor3iEXT),
-    NAME_FUNC_OFFSET(18251, glSecondaryColor3ivEXT, glSecondaryColor3ivEXT, NULL, _gloffset_SecondaryColor3ivEXT),
-    NAME_FUNC_OFFSET(18271, glSecondaryColor3sEXT, glSecondaryColor3sEXT, NULL, _gloffset_SecondaryColor3sEXT),
-    NAME_FUNC_OFFSET(18290, glSecondaryColor3svEXT, glSecondaryColor3svEXT, NULL, _gloffset_SecondaryColor3svEXT),
-    NAME_FUNC_OFFSET(18310, glSecondaryColor3ubEXT, glSecondaryColor3ubEXT, NULL, _gloffset_SecondaryColor3ubEXT),
-    NAME_FUNC_OFFSET(18330, glSecondaryColor3ubvEXT, glSecondaryColor3ubvEXT, NULL, _gloffset_SecondaryColor3ubvEXT),
-    NAME_FUNC_OFFSET(18351, glSecondaryColor3uiEXT, glSecondaryColor3uiEXT, NULL, _gloffset_SecondaryColor3uiEXT),
-    NAME_FUNC_OFFSET(18371, glSecondaryColor3uivEXT, glSecondaryColor3uivEXT, NULL, _gloffset_SecondaryColor3uivEXT),
-    NAME_FUNC_OFFSET(18392, glSecondaryColor3usEXT, glSecondaryColor3usEXT, NULL, _gloffset_SecondaryColor3usEXT),
-    NAME_FUNC_OFFSET(18412, glSecondaryColor3usvEXT, glSecondaryColor3usvEXT, NULL, _gloffset_SecondaryColor3usvEXT),
-    NAME_FUNC_OFFSET(18433, glSecondaryColorPointerEXT, glSecondaryColorPointerEXT, NULL, _gloffset_SecondaryColorPointerEXT),
-    NAME_FUNC_OFFSET(18457, glMultiDrawArraysEXT, glMultiDrawArraysEXT, NULL, _gloffset_MultiDrawArraysEXT),
-    NAME_FUNC_OFFSET(18475, glMultiDrawElementsEXT, glMultiDrawElementsEXT, NULL, _gloffset_MultiDrawElementsEXT),
-    NAME_FUNC_OFFSET(18495, glFogCoordPointerEXT, glFogCoordPointerEXT, NULL, _gloffset_FogCoordPointerEXT),
-    NAME_FUNC_OFFSET(18513, glFogCoorddEXT, glFogCoorddEXT, NULL, _gloffset_FogCoorddEXT),
-    NAME_FUNC_OFFSET(18525, glFogCoorddvEXT, glFogCoorddvEXT, NULL, _gloffset_FogCoorddvEXT),
-    NAME_FUNC_OFFSET(18538, glFogCoordfEXT, glFogCoordfEXT, NULL, _gloffset_FogCoordfEXT),
-    NAME_FUNC_OFFSET(18550, glFogCoordfvEXT, glFogCoordfvEXT, NULL, _gloffset_FogCoordfvEXT),
-    NAME_FUNC_OFFSET(18563, glBlendFuncSeparateEXT, glBlendFuncSeparateEXT, NULL, _gloffset_BlendFuncSeparateEXT),
-    NAME_FUNC_OFFSET(18583, glBlendFuncSeparateEXT, glBlendFuncSeparateEXT, NULL, _gloffset_BlendFuncSeparateEXT),
-    NAME_FUNC_OFFSET(18607, glWindowPos2dMESA, glWindowPos2dMESA, NULL, _gloffset_WindowPos2dMESA),
-    NAME_FUNC_OFFSET(18621, glWindowPos2dMESA, glWindowPos2dMESA, NULL, _gloffset_WindowPos2dMESA),
-    NAME_FUNC_OFFSET(18638, glWindowPos2dvMESA, glWindowPos2dvMESA, NULL, _gloffset_WindowPos2dvMESA),
-    NAME_FUNC_OFFSET(18653, glWindowPos2dvMESA, glWindowPos2dvMESA, NULL, _gloffset_WindowPos2dvMESA),
-    NAME_FUNC_OFFSET(18671, glWindowPos2fMESA, glWindowPos2fMESA, NULL, _gloffset_WindowPos2fMESA),
-    NAME_FUNC_OFFSET(18685, glWindowPos2fMESA, glWindowPos2fMESA, NULL, _gloffset_WindowPos2fMESA),
-    NAME_FUNC_OFFSET(18702, glWindowPos2fvMESA, glWindowPos2fvMESA, NULL, _gloffset_WindowPos2fvMESA),
-    NAME_FUNC_OFFSET(18717, glWindowPos2fvMESA, glWindowPos2fvMESA, NULL, _gloffset_WindowPos2fvMESA),
-    NAME_FUNC_OFFSET(18735, glWindowPos2iMESA, glWindowPos2iMESA, NULL, _gloffset_WindowPos2iMESA),
-    NAME_FUNC_OFFSET(18749, glWindowPos2iMESA, glWindowPos2iMESA, NULL, _gloffset_WindowPos2iMESA),
-    NAME_FUNC_OFFSET(18766, glWindowPos2ivMESA, glWindowPos2ivMESA, NULL, _gloffset_WindowPos2ivMESA),
-    NAME_FUNC_OFFSET(18781, glWindowPos2ivMESA, glWindowPos2ivMESA, NULL, _gloffset_WindowPos2ivMESA),
-    NAME_FUNC_OFFSET(18799, glWindowPos2sMESA, glWindowPos2sMESA, NULL, _gloffset_WindowPos2sMESA),
-    NAME_FUNC_OFFSET(18813, glWindowPos2sMESA, glWindowPos2sMESA, NULL, _gloffset_WindowPos2sMESA),
-    NAME_FUNC_OFFSET(18830, glWindowPos2svMESA, glWindowPos2svMESA, NULL, _gloffset_WindowPos2svMESA),
-    NAME_FUNC_OFFSET(18845, glWindowPos2svMESA, glWindowPos2svMESA, NULL, _gloffset_WindowPos2svMESA),
-    NAME_FUNC_OFFSET(18863, glWindowPos3dMESA, glWindowPos3dMESA, NULL, _gloffset_WindowPos3dMESA),
-    NAME_FUNC_OFFSET(18877, glWindowPos3dMESA, glWindowPos3dMESA, NULL, _gloffset_WindowPos3dMESA),
-    NAME_FUNC_OFFSET(18894, glWindowPos3dvMESA, glWindowPos3dvMESA, NULL, _gloffset_WindowPos3dvMESA),
-    NAME_FUNC_OFFSET(18909, glWindowPos3dvMESA, glWindowPos3dvMESA, NULL, _gloffset_WindowPos3dvMESA),
-    NAME_FUNC_OFFSET(18927, glWindowPos3fMESA, glWindowPos3fMESA, NULL, _gloffset_WindowPos3fMESA),
-    NAME_FUNC_OFFSET(18941, glWindowPos3fMESA, glWindowPos3fMESA, NULL, _gloffset_WindowPos3fMESA),
-    NAME_FUNC_OFFSET(18958, glWindowPos3fvMESA, glWindowPos3fvMESA, NULL, _gloffset_WindowPos3fvMESA),
-    NAME_FUNC_OFFSET(18973, glWindowPos3fvMESA, glWindowPos3fvMESA, NULL, _gloffset_WindowPos3fvMESA),
-    NAME_FUNC_OFFSET(18991, glWindowPos3iMESA, glWindowPos3iMESA, NULL, _gloffset_WindowPos3iMESA),
-    NAME_FUNC_OFFSET(19005, glWindowPos3iMESA, glWindowPos3iMESA, NULL, _gloffset_WindowPos3iMESA),
-    NAME_FUNC_OFFSET(19022, glWindowPos3ivMESA, glWindowPos3ivMESA, NULL, _gloffset_WindowPos3ivMESA),
-    NAME_FUNC_OFFSET(19037, glWindowPos3ivMESA, glWindowPos3ivMESA, NULL, _gloffset_WindowPos3ivMESA),
-    NAME_FUNC_OFFSET(19055, glWindowPos3sMESA, glWindowPos3sMESA, NULL, _gloffset_WindowPos3sMESA),
-    NAME_FUNC_OFFSET(19069, glWindowPos3sMESA, glWindowPos3sMESA, NULL, _gloffset_WindowPos3sMESA),
-    NAME_FUNC_OFFSET(19086, glWindowPos3svMESA, glWindowPos3svMESA, NULL, _gloffset_WindowPos3svMESA),
-    NAME_FUNC_OFFSET(19101, glWindowPos3svMESA, glWindowPos3svMESA, NULL, _gloffset_WindowPos3svMESA),
-    NAME_FUNC_OFFSET(19119, glBindProgramNV, glBindProgramNV, NULL, _gloffset_BindProgramNV),
-    NAME_FUNC_OFFSET(19136, glDeleteProgramsNV, glDeleteProgramsNV, NULL, _gloffset_DeleteProgramsNV),
-    NAME_FUNC_OFFSET(19156, glGenProgramsNV, glGenProgramsNV, NULL, _gloffset_GenProgramsNV),
-    NAME_FUNC_OFFSET(19173, glGetVertexAttribPointervNV, glGetVertexAttribPointervNV, NULL, _gloffset_GetVertexAttribPointervNV),
-    NAME_FUNC_OFFSET(19199, glGetVertexAttribPointervNV, glGetVertexAttribPointervNV, NULL, _gloffset_GetVertexAttribPointervNV),
-    NAME_FUNC_OFFSET(19228, glIsProgramNV, glIsProgramNV, NULL, _gloffset_IsProgramNV),
-    NAME_FUNC_OFFSET(19243, glPointParameteriNV, glPointParameteriNV, NULL, _gloffset_PointParameteriNV),
-    NAME_FUNC_OFFSET(19261, glPointParameterivNV, glPointParameterivNV, NULL, _gloffset_PointParameterivNV),
-    NAME_FUNC_OFFSET(19280, gl_dispatch_stub_755, gl_dispatch_stub_755, NULL, _gloffset_DeleteVertexArraysAPPLE),
-    NAME_FUNC_OFFSET(19301, gl_dispatch_stub_757, gl_dispatch_stub_757, NULL, _gloffset_IsVertexArrayAPPLE),
-    NAME_FUNC_OFFSET(19317, gl_dispatch_stub_765, gl_dispatch_stub_765, NULL, _gloffset_BlendEquationSeparateEXT),
-    NAME_FUNC_OFFSET(19341, gl_dispatch_stub_765, gl_dispatch_stub_765, NULL, _gloffset_BlendEquationSeparateEXT),
-    NAME_FUNC_OFFSET(19368, glBindFramebufferEXT, glBindFramebufferEXT, NULL, _gloffset_BindFramebufferEXT),
-    NAME_FUNC_OFFSET(19386, glBindRenderbufferEXT, glBindRenderbufferEXT, NULL, _gloffset_BindRenderbufferEXT),
-    NAME_FUNC_OFFSET(19405, glCheckFramebufferStatusEXT, glCheckFramebufferStatusEXT, NULL, _gloffset_CheckFramebufferStatusEXT),
-    NAME_FUNC_OFFSET(19430, glDeleteFramebuffersEXT, glDeleteFramebuffersEXT, NULL, _gloffset_DeleteFramebuffersEXT),
-    NAME_FUNC_OFFSET(19451, glDeleteRenderbuffersEXT, glDeleteRenderbuffersEXT, NULL, _gloffset_DeleteRenderbuffersEXT),
-    NAME_FUNC_OFFSET(19473, glFramebufferRenderbufferEXT, glFramebufferRenderbufferEXT, NULL, _gloffset_FramebufferRenderbufferEXT),
-    NAME_FUNC_OFFSET(19499, glFramebufferTexture1DEXT, glFramebufferTexture1DEXT, NULL, _gloffset_FramebufferTexture1DEXT),
-    NAME_FUNC_OFFSET(19522, glFramebufferTexture2DEXT, glFramebufferTexture2DEXT, NULL, _gloffset_FramebufferTexture2DEXT),
-    NAME_FUNC_OFFSET(19545, glFramebufferTexture3DEXT, glFramebufferTexture3DEXT, NULL, _gloffset_FramebufferTexture3DEXT),
-    NAME_FUNC_OFFSET(19568, glGenFramebuffersEXT, glGenFramebuffersEXT, NULL, _gloffset_GenFramebuffersEXT),
-    NAME_FUNC_OFFSET(19586, glGenRenderbuffersEXT, glGenRenderbuffersEXT, NULL, _gloffset_GenRenderbuffersEXT),
-    NAME_FUNC_OFFSET(19605, glGenerateMipmapEXT, glGenerateMipmapEXT, NULL, _gloffset_GenerateMipmapEXT),
-    NAME_FUNC_OFFSET(19622, glGetFramebufferAttachmentParameterivEXT, glGetFramebufferAttachmentParameterivEXT, NULL, _gloffset_GetFramebufferAttachmentParameterivEXT),
-    NAME_FUNC_OFFSET(19660, glGetRenderbufferParameterivEXT, glGetRenderbufferParameterivEXT, NULL, _gloffset_GetRenderbufferParameterivEXT),
-    NAME_FUNC_OFFSET(19689, glIsFramebufferEXT, glIsFramebufferEXT, NULL, _gloffset_IsFramebufferEXT),
-    NAME_FUNC_OFFSET(19705, glIsRenderbufferEXT, glIsRenderbufferEXT, NULL, _gloffset_IsRenderbufferEXT),
-    NAME_FUNC_OFFSET(19722, glRenderbufferStorageEXT, glRenderbufferStorageEXT, NULL, _gloffset_RenderbufferStorageEXT),
-    NAME_FUNC_OFFSET(19744, gl_dispatch_stub_783, gl_dispatch_stub_783, NULL, _gloffset_BlitFramebufferEXT),
-    NAME_FUNC_OFFSET(19762, glFramebufferTextureLayerEXT, glFramebufferTextureLayerEXT, NULL, _gloffset_FramebufferTextureLayerEXT),
-    NAME_FUNC_OFFSET(19788, glProvokingVertexEXT, glProvokingVertexEXT, NULL, _gloffset_ProvokingVertexEXT),
+    NAME_FUNC_OFFSET(13867, glColorMaskIndexedEXT, glColorMaskIndexedEXT, NULL, _gloffset_ColorMaskIndexedEXT),
+    NAME_FUNC_OFFSET(13889, glDisableIndexedEXT, glDisableIndexedEXT, NULL, _gloffset_DisableIndexedEXT),
+    NAME_FUNC_OFFSET(13909, glEnableIndexedEXT, glEnableIndexedEXT, NULL, _gloffset_EnableIndexedEXT),
+    NAME_FUNC_OFFSET(13928, glGetBooleanIndexedvEXT, glGetBooleanIndexedvEXT, NULL, _gloffset_GetBooleanIndexedvEXT),
+    NAME_FUNC_OFFSET(13952, glGetIntegerIndexedvEXT, glGetIntegerIndexedvEXT, NULL, _gloffset_GetIntegerIndexedvEXT),
+    NAME_FUNC_OFFSET(13976, glIsEnabledIndexedEXT, glIsEnabledIndexedEXT, NULL, _gloffset_IsEnabledIndexedEXT),
+    NAME_FUNC_OFFSET(13998, glBeginConditionalRenderNV, glBeginConditionalRenderNV, NULL, _gloffset_BeginConditionalRenderNV),
+    NAME_FUNC_OFFSET(14025, glEndConditionalRenderNV, glEndConditionalRenderNV, NULL, _gloffset_EndConditionalRenderNV),
+    NAME_FUNC_OFFSET(14050, glProvokingVertexEXT, glProvokingVertexEXT, NULL, _gloffset_ProvokingVertexEXT),
+    NAME_FUNC_OFFSET(14071, gl_dispatch_stub_796, gl_dispatch_stub_796, NULL, _gloffset_GetTexParameterPointervAPPLE),
+    NAME_FUNC_OFFSET(14102, gl_dispatch_stub_797, gl_dispatch_stub_797, NULL, _gloffset_TextureRangeAPPLE),
+    NAME_FUNC_OFFSET(14122, gl_dispatch_stub_798, gl_dispatch_stub_798, NULL, _gloffset_StencilFuncSeparateATI),
+    NAME_FUNC_OFFSET(14147, gl_dispatch_stub_799, gl_dispatch_stub_799, NULL, _gloffset_ProgramEnvParameters4fvEXT),
+    NAME_FUNC_OFFSET(14176, gl_dispatch_stub_800, gl_dispatch_stub_800, NULL, _gloffset_ProgramLocalParameters4fvEXT),
+    NAME_FUNC_OFFSET(14207, gl_dispatch_stub_801, gl_dispatch_stub_801, NULL, _gloffset_GetQueryObjecti64vEXT),
+    NAME_FUNC_OFFSET(14231, gl_dispatch_stub_802, gl_dispatch_stub_802, NULL, _gloffset_GetQueryObjectui64vEXT),
+    NAME_FUNC_OFFSET(14256, glArrayElement, glArrayElement, NULL, _gloffset_ArrayElement),
+    NAME_FUNC_OFFSET(14274, glBindTexture, glBindTexture, NULL, _gloffset_BindTexture),
+    NAME_FUNC_OFFSET(14291, glDrawArrays, glDrawArrays, NULL, _gloffset_DrawArrays),
+    NAME_FUNC_OFFSET(14307, glAreTexturesResident, glAreTexturesResidentEXT, glAreTexturesResidentEXT, _gloffset_AreTexturesResident),
+    NAME_FUNC_OFFSET(14332, glCopyTexImage1D, glCopyTexImage1D, NULL, _gloffset_CopyTexImage1D),
+    NAME_FUNC_OFFSET(14352, glCopyTexImage2D, glCopyTexImage2D, NULL, _gloffset_CopyTexImage2D),
+    NAME_FUNC_OFFSET(14372, glCopyTexSubImage1D, glCopyTexSubImage1D, NULL, _gloffset_CopyTexSubImage1D),
+    NAME_FUNC_OFFSET(14395, glCopyTexSubImage2D, glCopyTexSubImage2D, NULL, _gloffset_CopyTexSubImage2D),
+    NAME_FUNC_OFFSET(14418, glDeleteTextures, glDeleteTexturesEXT, glDeleteTexturesEXT, _gloffset_DeleteTextures),
+    NAME_FUNC_OFFSET(14438, glGenTextures, glGenTexturesEXT, glGenTexturesEXT, _gloffset_GenTextures),
+    NAME_FUNC_OFFSET(14455, glGetPointerv, glGetPointerv, NULL, _gloffset_GetPointerv),
+    NAME_FUNC_OFFSET(14472, glIsTexture, glIsTextureEXT, glIsTextureEXT, _gloffset_IsTexture),
+    NAME_FUNC_OFFSET(14487, glPrioritizeTextures, glPrioritizeTextures, NULL, _gloffset_PrioritizeTextures),
+    NAME_FUNC_OFFSET(14511, glTexSubImage1D, glTexSubImage1D, NULL, _gloffset_TexSubImage1D),
+    NAME_FUNC_OFFSET(14530, glTexSubImage2D, glTexSubImage2D, NULL, _gloffset_TexSubImage2D),
+    NAME_FUNC_OFFSET(14549, glBlendColor, glBlendColor, NULL, _gloffset_BlendColor),
+    NAME_FUNC_OFFSET(14565, glBlendEquation, glBlendEquation, NULL, _gloffset_BlendEquation),
+    NAME_FUNC_OFFSET(14584, glDrawRangeElements, glDrawRangeElements, NULL, _gloffset_DrawRangeElements),
+    NAME_FUNC_OFFSET(14607, glColorTable, glColorTable, NULL, _gloffset_ColorTable),
+    NAME_FUNC_OFFSET(14623, glColorTable, glColorTable, NULL, _gloffset_ColorTable),
+    NAME_FUNC_OFFSET(14639, glColorTableParameterfv, glColorTableParameterfv, NULL, _gloffset_ColorTableParameterfv),
+    NAME_FUNC_OFFSET(14666, glColorTableParameteriv, glColorTableParameteriv, NULL, _gloffset_ColorTableParameteriv),
+    NAME_FUNC_OFFSET(14693, glCopyColorTable, glCopyColorTable, NULL, _gloffset_CopyColorTable),
+    NAME_FUNC_OFFSET(14713, glGetColorTable, glGetColorTableEXT, glGetColorTableEXT, _gloffset_GetColorTable),
+    NAME_FUNC_OFFSET(14732, glGetColorTable, glGetColorTableEXT, glGetColorTableEXT, _gloffset_GetColorTable),
+    NAME_FUNC_OFFSET(14751, glGetColorTableParameterfv, glGetColorTableParameterfvEXT, glGetColorTableParameterfvEXT, _gloffset_GetColorTableParameterfv),
+    NAME_FUNC_OFFSET(14781, glGetColorTableParameterfv, glGetColorTableParameterfvEXT, glGetColorTableParameterfvEXT, _gloffset_GetColorTableParameterfv),
+    NAME_FUNC_OFFSET(14811, glGetColorTableParameteriv, glGetColorTableParameterivEXT, glGetColorTableParameterivEXT, _gloffset_GetColorTableParameteriv),
+    NAME_FUNC_OFFSET(14841, glGetColorTableParameteriv, glGetColorTableParameterivEXT, glGetColorTableParameterivEXT, _gloffset_GetColorTableParameteriv),
+    NAME_FUNC_OFFSET(14871, glColorSubTable, glColorSubTable, NULL, _gloffset_ColorSubTable),
+    NAME_FUNC_OFFSET(14890, glCopyColorSubTable, glCopyColorSubTable, NULL, _gloffset_CopyColorSubTable),
+    NAME_FUNC_OFFSET(14913, glConvolutionFilter1D, glConvolutionFilter1D, NULL, _gloffset_ConvolutionFilter1D),
+    NAME_FUNC_OFFSET(14938, glConvolutionFilter2D, glConvolutionFilter2D, NULL, _gloffset_ConvolutionFilter2D),
+    NAME_FUNC_OFFSET(14963, glConvolutionParameterf, glConvolutionParameterf, NULL, _gloffset_ConvolutionParameterf),
+    NAME_FUNC_OFFSET(14990, glConvolutionParameterfv, glConvolutionParameterfv, NULL, _gloffset_ConvolutionParameterfv),
+    NAME_FUNC_OFFSET(15018, glConvolutionParameteri, glConvolutionParameteri, NULL, _gloffset_ConvolutionParameteri),
+    NAME_FUNC_OFFSET(15045, glConvolutionParameteriv, glConvolutionParameteriv, NULL, _gloffset_ConvolutionParameteriv),
+    NAME_FUNC_OFFSET(15073, glCopyConvolutionFilter1D, glCopyConvolutionFilter1D, NULL, _gloffset_CopyConvolutionFilter1D),
+    NAME_FUNC_OFFSET(15102, glCopyConvolutionFilter2D, glCopyConvolutionFilter2D, NULL, _gloffset_CopyConvolutionFilter2D),
+    NAME_FUNC_OFFSET(15131, glGetConvolutionFilter, gl_dispatch_stub_356, gl_dispatch_stub_356, _gloffset_GetConvolutionFilter),
+    NAME_FUNC_OFFSET(15157, glGetConvolutionParameterfv, gl_dispatch_stub_357, gl_dispatch_stub_357, _gloffset_GetConvolutionParameterfv),
+    NAME_FUNC_OFFSET(15188, glGetConvolutionParameteriv, gl_dispatch_stub_358, gl_dispatch_stub_358, _gloffset_GetConvolutionParameteriv),
+    NAME_FUNC_OFFSET(15219, glGetSeparableFilter, gl_dispatch_stub_359, gl_dispatch_stub_359, _gloffset_GetSeparableFilter),
+    NAME_FUNC_OFFSET(15243, glSeparableFilter2D, glSeparableFilter2D, NULL, _gloffset_SeparableFilter2D),
+    NAME_FUNC_OFFSET(15266, glGetHistogram, gl_dispatch_stub_361, gl_dispatch_stub_361, _gloffset_GetHistogram),
+    NAME_FUNC_OFFSET(15284, glGetHistogramParameterfv, gl_dispatch_stub_362, gl_dispatch_stub_362, _gloffset_GetHistogramParameterfv),
+    NAME_FUNC_OFFSET(15313, glGetHistogramParameteriv, gl_dispatch_stub_363, gl_dispatch_stub_363, _gloffset_GetHistogramParameteriv),
+    NAME_FUNC_OFFSET(15342, glGetMinmax, gl_dispatch_stub_364, gl_dispatch_stub_364, _gloffset_GetMinmax),
+    NAME_FUNC_OFFSET(15357, glGetMinmaxParameterfv, gl_dispatch_stub_365, gl_dispatch_stub_365, _gloffset_GetMinmaxParameterfv),
+    NAME_FUNC_OFFSET(15383, glGetMinmaxParameteriv, gl_dispatch_stub_366, gl_dispatch_stub_366, _gloffset_GetMinmaxParameteriv),
+    NAME_FUNC_OFFSET(15409, glHistogram, glHistogram, NULL, _gloffset_Histogram),
+    NAME_FUNC_OFFSET(15424, glMinmax, glMinmax, NULL, _gloffset_Minmax),
+    NAME_FUNC_OFFSET(15436, glResetHistogram, glResetHistogram, NULL, _gloffset_ResetHistogram),
+    NAME_FUNC_OFFSET(15456, glResetMinmax, glResetMinmax, NULL, _gloffset_ResetMinmax),
+    NAME_FUNC_OFFSET(15473, glTexImage3D, glTexImage3D, NULL, _gloffset_TexImage3D),
+    NAME_FUNC_OFFSET(15489, glTexSubImage3D, glTexSubImage3D, NULL, _gloffset_TexSubImage3D),
+    NAME_FUNC_OFFSET(15508, glCopyTexSubImage3D, glCopyTexSubImage3D, NULL, _gloffset_CopyTexSubImage3D),
+    NAME_FUNC_OFFSET(15531, glActiveTextureARB, glActiveTextureARB, NULL, _gloffset_ActiveTextureARB),
+    NAME_FUNC_OFFSET(15547, glClientActiveTextureARB, glClientActiveTextureARB, NULL, _gloffset_ClientActiveTextureARB),
+    NAME_FUNC_OFFSET(15569, glMultiTexCoord1dARB, glMultiTexCoord1dARB, NULL, _gloffset_MultiTexCoord1dARB),
+    NAME_FUNC_OFFSET(15587, glMultiTexCoord1dvARB, glMultiTexCoord1dvARB, NULL, _gloffset_MultiTexCoord1dvARB),
+    NAME_FUNC_OFFSET(15606, glMultiTexCoord1fARB, glMultiTexCoord1fARB, NULL, _gloffset_MultiTexCoord1fARB),
+    NAME_FUNC_OFFSET(15624, glMultiTexCoord1fvARB, glMultiTexCoord1fvARB, NULL, _gloffset_MultiTexCoord1fvARB),
+    NAME_FUNC_OFFSET(15643, glMultiTexCoord1iARB, glMultiTexCoord1iARB, NULL, _gloffset_MultiTexCoord1iARB),
+    NAME_FUNC_OFFSET(15661, glMultiTexCoord1ivARB, glMultiTexCoord1ivARB, NULL, _gloffset_MultiTexCoord1ivARB),
+    NAME_FUNC_OFFSET(15680, glMultiTexCoord1sARB, glMultiTexCoord1sARB, NULL, _gloffset_MultiTexCoord1sARB),
+    NAME_FUNC_OFFSET(15698, glMultiTexCoord1svARB, glMultiTexCoord1svARB, NULL, _gloffset_MultiTexCoord1svARB),
+    NAME_FUNC_OFFSET(15717, glMultiTexCoord2dARB, glMultiTexCoord2dARB, NULL, _gloffset_MultiTexCoord2dARB),
+    NAME_FUNC_OFFSET(15735, glMultiTexCoord2dvARB, glMultiTexCoord2dvARB, NULL, _gloffset_MultiTexCoord2dvARB),
+    NAME_FUNC_OFFSET(15754, glMultiTexCoord2fARB, glMultiTexCoord2fARB, NULL, _gloffset_MultiTexCoord2fARB),
+    NAME_FUNC_OFFSET(15772, glMultiTexCoord2fvARB, glMultiTexCoord2fvARB, NULL, _gloffset_MultiTexCoord2fvARB),
+    NAME_FUNC_OFFSET(15791, glMultiTexCoord2iARB, glMultiTexCoord2iARB, NULL, _gloffset_MultiTexCoord2iARB),
+    NAME_FUNC_OFFSET(15809, glMultiTexCoord2ivARB, glMultiTexCoord2ivARB, NULL, _gloffset_MultiTexCoord2ivARB),
+    NAME_FUNC_OFFSET(15828, glMultiTexCoord2sARB, glMultiTexCoord2sARB, NULL, _gloffset_MultiTexCoord2sARB),
+    NAME_FUNC_OFFSET(15846, glMultiTexCoord2svARB, glMultiTexCoord2svARB, NULL, _gloffset_MultiTexCoord2svARB),
+    NAME_FUNC_OFFSET(15865, glMultiTexCoord3dARB, glMultiTexCoord3dARB, NULL, _gloffset_MultiTexCoord3dARB),
+    NAME_FUNC_OFFSET(15883, glMultiTexCoord3dvARB, glMultiTexCoord3dvARB, NULL, _gloffset_MultiTexCoord3dvARB),
+    NAME_FUNC_OFFSET(15902, glMultiTexCoord3fARB, glMultiTexCoord3fARB, NULL, _gloffset_MultiTexCoord3fARB),
+    NAME_FUNC_OFFSET(15920, glMultiTexCoord3fvARB, glMultiTexCoord3fvARB, NULL, _gloffset_MultiTexCoord3fvARB),
+    NAME_FUNC_OFFSET(15939, glMultiTexCoord3iARB, glMultiTexCoord3iARB, NULL, _gloffset_MultiTexCoord3iARB),
+    NAME_FUNC_OFFSET(15957, glMultiTexCoord3ivARB, glMultiTexCoord3ivARB, NULL, _gloffset_MultiTexCoord3ivARB),
+    NAME_FUNC_OFFSET(15976, glMultiTexCoord3sARB, glMultiTexCoord3sARB, NULL, _gloffset_MultiTexCoord3sARB),
+    NAME_FUNC_OFFSET(15994, glMultiTexCoord3svARB, glMultiTexCoord3svARB, NULL, _gloffset_MultiTexCoord3svARB),
+    NAME_FUNC_OFFSET(16013, glMultiTexCoord4dARB, glMultiTexCoord4dARB, NULL, _gloffset_MultiTexCoord4dARB),
+    NAME_FUNC_OFFSET(16031, glMultiTexCoord4dvARB, glMultiTexCoord4dvARB, NULL, _gloffset_MultiTexCoord4dvARB),
+    NAME_FUNC_OFFSET(16050, glMultiTexCoord4fARB, glMultiTexCoord4fARB, NULL, _gloffset_MultiTexCoord4fARB),
+    NAME_FUNC_OFFSET(16068, glMultiTexCoord4fvARB, glMultiTexCoord4fvARB, NULL, _gloffset_MultiTexCoord4fvARB),
+    NAME_FUNC_OFFSET(16087, glMultiTexCoord4iARB, glMultiTexCoord4iARB, NULL, _gloffset_MultiTexCoord4iARB),
+    NAME_FUNC_OFFSET(16105, glMultiTexCoord4ivARB, glMultiTexCoord4ivARB, NULL, _gloffset_MultiTexCoord4ivARB),
+    NAME_FUNC_OFFSET(16124, glMultiTexCoord4sARB, glMultiTexCoord4sARB, NULL, _gloffset_MultiTexCoord4sARB),
+    NAME_FUNC_OFFSET(16142, glMultiTexCoord4svARB, glMultiTexCoord4svARB, NULL, _gloffset_MultiTexCoord4svARB),
+    NAME_FUNC_OFFSET(16161, glStencilOpSeparate, glStencilOpSeparate, NULL, _gloffset_StencilOpSeparate),
+    NAME_FUNC_OFFSET(16184, glLoadTransposeMatrixdARB, glLoadTransposeMatrixdARB, NULL, _gloffset_LoadTransposeMatrixdARB),
+    NAME_FUNC_OFFSET(16207, glLoadTransposeMatrixfARB, glLoadTransposeMatrixfARB, NULL, _gloffset_LoadTransposeMatrixfARB),
+    NAME_FUNC_OFFSET(16230, glMultTransposeMatrixdARB, glMultTransposeMatrixdARB, NULL, _gloffset_MultTransposeMatrixdARB),
+    NAME_FUNC_OFFSET(16253, glMultTransposeMatrixfARB, glMultTransposeMatrixfARB, NULL, _gloffset_MultTransposeMatrixfARB),
+    NAME_FUNC_OFFSET(16276, glSampleCoverageARB, glSampleCoverageARB, NULL, _gloffset_SampleCoverageARB),
+    NAME_FUNC_OFFSET(16293, glCompressedTexImage1DARB, glCompressedTexImage1DARB, NULL, _gloffset_CompressedTexImage1DARB),
+    NAME_FUNC_OFFSET(16316, glCompressedTexImage2DARB, glCompressedTexImage2DARB, NULL, _gloffset_CompressedTexImage2DARB),
+    NAME_FUNC_OFFSET(16339, glCompressedTexImage3DARB, glCompressedTexImage3DARB, NULL, _gloffset_CompressedTexImage3DARB),
+    NAME_FUNC_OFFSET(16362, glCompressedTexSubImage1DARB, glCompressedTexSubImage1DARB, NULL, _gloffset_CompressedTexSubImage1DARB),
+    NAME_FUNC_OFFSET(16388, glCompressedTexSubImage2DARB, glCompressedTexSubImage2DARB, NULL, _gloffset_CompressedTexSubImage2DARB),
+    NAME_FUNC_OFFSET(16414, glCompressedTexSubImage3DARB, glCompressedTexSubImage3DARB, NULL, _gloffset_CompressedTexSubImage3DARB),
+    NAME_FUNC_OFFSET(16440, glGetCompressedTexImageARB, glGetCompressedTexImageARB, NULL, _gloffset_GetCompressedTexImageARB),
+    NAME_FUNC_OFFSET(16464, glDisableVertexAttribArrayARB, glDisableVertexAttribArrayARB, NULL, _gloffset_DisableVertexAttribArrayARB),
+    NAME_FUNC_OFFSET(16491, glEnableVertexAttribArrayARB, glEnableVertexAttribArrayARB, NULL, _gloffset_EnableVertexAttribArrayARB),
+    NAME_FUNC_OFFSET(16517, glGetVertexAttribdvARB, glGetVertexAttribdvARB, NULL, _gloffset_GetVertexAttribdvARB),
+    NAME_FUNC_OFFSET(16537, glGetVertexAttribfvARB, glGetVertexAttribfvARB, NULL, _gloffset_GetVertexAttribfvARB),
+    NAME_FUNC_OFFSET(16557, glGetVertexAttribivARB, glGetVertexAttribivARB, NULL, _gloffset_GetVertexAttribivARB),
+    NAME_FUNC_OFFSET(16577, glProgramEnvParameter4dARB, glProgramEnvParameter4dARB, NULL, _gloffset_ProgramEnvParameter4dARB),
+    NAME_FUNC_OFFSET(16600, glProgramEnvParameter4dvARB, glProgramEnvParameter4dvARB, NULL, _gloffset_ProgramEnvParameter4dvARB),
+    NAME_FUNC_OFFSET(16624, glProgramEnvParameter4fARB, glProgramEnvParameter4fARB, NULL, _gloffset_ProgramEnvParameter4fARB),
+    NAME_FUNC_OFFSET(16647, glProgramEnvParameter4fvARB, glProgramEnvParameter4fvARB, NULL, _gloffset_ProgramEnvParameter4fvARB),
+    NAME_FUNC_OFFSET(16671, glVertexAttrib1dARB, glVertexAttrib1dARB, NULL, _gloffset_VertexAttrib1dARB),
+    NAME_FUNC_OFFSET(16688, glVertexAttrib1dvARB, glVertexAttrib1dvARB, NULL, _gloffset_VertexAttrib1dvARB),
+    NAME_FUNC_OFFSET(16706, glVertexAttrib1fARB, glVertexAttrib1fARB, NULL, _gloffset_VertexAttrib1fARB),
+    NAME_FUNC_OFFSET(16723, glVertexAttrib1fvARB, glVertexAttrib1fvARB, NULL, _gloffset_VertexAttrib1fvARB),
+    NAME_FUNC_OFFSET(16741, glVertexAttrib1sARB, glVertexAttrib1sARB, NULL, _gloffset_VertexAttrib1sARB),
+    NAME_FUNC_OFFSET(16758, glVertexAttrib1svARB, glVertexAttrib1svARB, NULL, _gloffset_VertexAttrib1svARB),
+    NAME_FUNC_OFFSET(16776, glVertexAttrib2dARB, glVertexAttrib2dARB, NULL, _gloffset_VertexAttrib2dARB),
+    NAME_FUNC_OFFSET(16793, glVertexAttrib2dvARB, glVertexAttrib2dvARB, NULL, _gloffset_VertexAttrib2dvARB),
+    NAME_FUNC_OFFSET(16811, glVertexAttrib2fARB, glVertexAttrib2fARB, NULL, _gloffset_VertexAttrib2fARB),
+    NAME_FUNC_OFFSET(16828, glVertexAttrib2fvARB, glVertexAttrib2fvARB, NULL, _gloffset_VertexAttrib2fvARB),
+    NAME_FUNC_OFFSET(16846, glVertexAttrib2sARB, glVertexAttrib2sARB, NULL, _gloffset_VertexAttrib2sARB),
+    NAME_FUNC_OFFSET(16863, glVertexAttrib2svARB, glVertexAttrib2svARB, NULL, _gloffset_VertexAttrib2svARB),
+    NAME_FUNC_OFFSET(16881, glVertexAttrib3dARB, glVertexAttrib3dARB, NULL, _gloffset_VertexAttrib3dARB),
+    NAME_FUNC_OFFSET(16898, glVertexAttrib3dvARB, glVertexAttrib3dvARB, NULL, _gloffset_VertexAttrib3dvARB),
+    NAME_FUNC_OFFSET(16916, glVertexAttrib3fARB, glVertexAttrib3fARB, NULL, _gloffset_VertexAttrib3fARB),
+    NAME_FUNC_OFFSET(16933, glVertexAttrib3fvARB, glVertexAttrib3fvARB, NULL, _gloffset_VertexAttrib3fvARB),
+    NAME_FUNC_OFFSET(16951, glVertexAttrib3sARB, glVertexAttrib3sARB, NULL, _gloffset_VertexAttrib3sARB),
+    NAME_FUNC_OFFSET(16968, glVertexAttrib3svARB, glVertexAttrib3svARB, NULL, _gloffset_VertexAttrib3svARB),
+    NAME_FUNC_OFFSET(16986, glVertexAttrib4NbvARB, glVertexAttrib4NbvARB, NULL, _gloffset_VertexAttrib4NbvARB),
+    NAME_FUNC_OFFSET(17005, glVertexAttrib4NivARB, glVertexAttrib4NivARB, NULL, _gloffset_VertexAttrib4NivARB),
+    NAME_FUNC_OFFSET(17024, glVertexAttrib4NsvARB, glVertexAttrib4NsvARB, NULL, _gloffset_VertexAttrib4NsvARB),
+    NAME_FUNC_OFFSET(17043, glVertexAttrib4NubARB, glVertexAttrib4NubARB, NULL, _gloffset_VertexAttrib4NubARB),
+    NAME_FUNC_OFFSET(17062, glVertexAttrib4NubvARB, glVertexAttrib4NubvARB, NULL, _gloffset_VertexAttrib4NubvARB),
+    NAME_FUNC_OFFSET(17082, glVertexAttrib4NuivARB, glVertexAttrib4NuivARB, NULL, _gloffset_VertexAttrib4NuivARB),
+    NAME_FUNC_OFFSET(17102, glVertexAttrib4NusvARB, glVertexAttrib4NusvARB, NULL, _gloffset_VertexAttrib4NusvARB),
+    NAME_FUNC_OFFSET(17122, glVertexAttrib4bvARB, glVertexAttrib4bvARB, NULL, _gloffset_VertexAttrib4bvARB),
+    NAME_FUNC_OFFSET(17140, glVertexAttrib4dARB, glVertexAttrib4dARB, NULL, _gloffset_VertexAttrib4dARB),
+    NAME_FUNC_OFFSET(17157, glVertexAttrib4dvARB, glVertexAttrib4dvARB, NULL, _gloffset_VertexAttrib4dvARB),
+    NAME_FUNC_OFFSET(17175, glVertexAttrib4fARB, glVertexAttrib4fARB, NULL, _gloffset_VertexAttrib4fARB),
+    NAME_FUNC_OFFSET(17192, glVertexAttrib4fvARB, glVertexAttrib4fvARB, NULL, _gloffset_VertexAttrib4fvARB),
+    NAME_FUNC_OFFSET(17210, glVertexAttrib4ivARB, glVertexAttrib4ivARB, NULL, _gloffset_VertexAttrib4ivARB),
+    NAME_FUNC_OFFSET(17228, glVertexAttrib4sARB, glVertexAttrib4sARB, NULL, _gloffset_VertexAttrib4sARB),
+    NAME_FUNC_OFFSET(17245, glVertexAttrib4svARB, glVertexAttrib4svARB, NULL, _gloffset_VertexAttrib4svARB),
+    NAME_FUNC_OFFSET(17263, glVertexAttrib4ubvARB, glVertexAttrib4ubvARB, NULL, _gloffset_VertexAttrib4ubvARB),
+    NAME_FUNC_OFFSET(17282, glVertexAttrib4uivARB, glVertexAttrib4uivARB, NULL, _gloffset_VertexAttrib4uivARB),
+    NAME_FUNC_OFFSET(17301, glVertexAttrib4usvARB, glVertexAttrib4usvARB, NULL, _gloffset_VertexAttrib4usvARB),
+    NAME_FUNC_OFFSET(17320, glVertexAttribPointerARB, glVertexAttribPointerARB, NULL, _gloffset_VertexAttribPointerARB),
+    NAME_FUNC_OFFSET(17342, glBindBufferARB, glBindBufferARB, NULL, _gloffset_BindBufferARB),
+    NAME_FUNC_OFFSET(17355, glBufferDataARB, glBufferDataARB, NULL, _gloffset_BufferDataARB),
+    NAME_FUNC_OFFSET(17368, glBufferSubDataARB, glBufferSubDataARB, NULL, _gloffset_BufferSubDataARB),
+    NAME_FUNC_OFFSET(17384, glDeleteBuffersARB, glDeleteBuffersARB, NULL, _gloffset_DeleteBuffersARB),
+    NAME_FUNC_OFFSET(17400, glGenBuffersARB, glGenBuffersARB, NULL, _gloffset_GenBuffersARB),
+    NAME_FUNC_OFFSET(17413, glGetBufferParameterivARB, glGetBufferParameterivARB, NULL, _gloffset_GetBufferParameterivARB),
+    NAME_FUNC_OFFSET(17436, glGetBufferPointervARB, glGetBufferPointervARB, NULL, _gloffset_GetBufferPointervARB),
+    NAME_FUNC_OFFSET(17456, glGetBufferSubDataARB, glGetBufferSubDataARB, NULL, _gloffset_GetBufferSubDataARB),
+    NAME_FUNC_OFFSET(17475, glIsBufferARB, glIsBufferARB, NULL, _gloffset_IsBufferARB),
+    NAME_FUNC_OFFSET(17486, glMapBufferARB, glMapBufferARB, NULL, _gloffset_MapBufferARB),
+    NAME_FUNC_OFFSET(17498, glUnmapBufferARB, glUnmapBufferARB, NULL, _gloffset_UnmapBufferARB),
+    NAME_FUNC_OFFSET(17512, glBeginQueryARB, glBeginQueryARB, NULL, _gloffset_BeginQueryARB),
+    NAME_FUNC_OFFSET(17525, glDeleteQueriesARB, glDeleteQueriesARB, NULL, _gloffset_DeleteQueriesARB),
+    NAME_FUNC_OFFSET(17541, glEndQueryARB, glEndQueryARB, NULL, _gloffset_EndQueryARB),
+    NAME_FUNC_OFFSET(17552, glGenQueriesARB, glGenQueriesARB, NULL, _gloffset_GenQueriesARB),
+    NAME_FUNC_OFFSET(17565, glGetQueryObjectivARB, glGetQueryObjectivARB, NULL, _gloffset_GetQueryObjectivARB),
+    NAME_FUNC_OFFSET(17584, glGetQueryObjectuivARB, glGetQueryObjectuivARB, NULL, _gloffset_GetQueryObjectuivARB),
+    NAME_FUNC_OFFSET(17604, glGetQueryivARB, glGetQueryivARB, NULL, _gloffset_GetQueryivARB),
+    NAME_FUNC_OFFSET(17617, glIsQueryARB, glIsQueryARB, NULL, _gloffset_IsQueryARB),
+    NAME_FUNC_OFFSET(17627, glCompileShaderARB, glCompileShaderARB, NULL, _gloffset_CompileShaderARB),
+    NAME_FUNC_OFFSET(17643, glGetActiveUniformARB, glGetActiveUniformARB, NULL, _gloffset_GetActiveUniformARB),
+    NAME_FUNC_OFFSET(17662, glGetShaderSourceARB, glGetShaderSourceARB, NULL, _gloffset_GetShaderSourceARB),
+    NAME_FUNC_OFFSET(17680, glGetUniformLocationARB, glGetUniformLocationARB, NULL, _gloffset_GetUniformLocationARB),
+    NAME_FUNC_OFFSET(17701, glGetUniformfvARB, glGetUniformfvARB, NULL, _gloffset_GetUniformfvARB),
+    NAME_FUNC_OFFSET(17716, glGetUniformivARB, glGetUniformivARB, NULL, _gloffset_GetUniformivARB),
+    NAME_FUNC_OFFSET(17731, glLinkProgramARB, glLinkProgramARB, NULL, _gloffset_LinkProgramARB),
+    NAME_FUNC_OFFSET(17745, glShaderSourceARB, glShaderSourceARB, NULL, _gloffset_ShaderSourceARB),
+    NAME_FUNC_OFFSET(17760, glUniform1fARB, glUniform1fARB, NULL, _gloffset_Uniform1fARB),
+    NAME_FUNC_OFFSET(17772, glUniform1fvARB, glUniform1fvARB, NULL, _gloffset_Uniform1fvARB),
+    NAME_FUNC_OFFSET(17785, glUniform1iARB, glUniform1iARB, NULL, _gloffset_Uniform1iARB),
+    NAME_FUNC_OFFSET(17797, glUniform1ivARB, glUniform1ivARB, NULL, _gloffset_Uniform1ivARB),
+    NAME_FUNC_OFFSET(17810, glUniform2fARB, glUniform2fARB, NULL, _gloffset_Uniform2fARB),
+    NAME_FUNC_OFFSET(17822, glUniform2fvARB, glUniform2fvARB, NULL, _gloffset_Uniform2fvARB),
+    NAME_FUNC_OFFSET(17835, glUniform2iARB, glUniform2iARB, NULL, _gloffset_Uniform2iARB),
+    NAME_FUNC_OFFSET(17847, glUniform2ivARB, glUniform2ivARB, NULL, _gloffset_Uniform2ivARB),
+    NAME_FUNC_OFFSET(17860, glUniform3fARB, glUniform3fARB, NULL, _gloffset_Uniform3fARB),
+    NAME_FUNC_OFFSET(17872, glUniform3fvARB, glUniform3fvARB, NULL, _gloffset_Uniform3fvARB),
+    NAME_FUNC_OFFSET(17885, glUniform3iARB, glUniform3iARB, NULL, _gloffset_Uniform3iARB),
+    NAME_FUNC_OFFSET(17897, glUniform3ivARB, glUniform3ivARB, NULL, _gloffset_Uniform3ivARB),
+    NAME_FUNC_OFFSET(17910, glUniform4fARB, glUniform4fARB, NULL, _gloffset_Uniform4fARB),
+    NAME_FUNC_OFFSET(17922, glUniform4fvARB, glUniform4fvARB, NULL, _gloffset_Uniform4fvARB),
+    NAME_FUNC_OFFSET(17935, glUniform4iARB, glUniform4iARB, NULL, _gloffset_Uniform4iARB),
+    NAME_FUNC_OFFSET(17947, glUniform4ivARB, glUniform4ivARB, NULL, _gloffset_Uniform4ivARB),
+    NAME_FUNC_OFFSET(17960, glUniformMatrix2fvARB, glUniformMatrix2fvARB, NULL, _gloffset_UniformMatrix2fvARB),
+    NAME_FUNC_OFFSET(17979, glUniformMatrix3fvARB, glUniformMatrix3fvARB, NULL, _gloffset_UniformMatrix3fvARB),
+    NAME_FUNC_OFFSET(17998, glUniformMatrix4fvARB, glUniformMatrix4fvARB, NULL, _gloffset_UniformMatrix4fvARB),
+    NAME_FUNC_OFFSET(18017, glUseProgramObjectARB, glUseProgramObjectARB, NULL, _gloffset_UseProgramObjectARB),
+    NAME_FUNC_OFFSET(18030, glValidateProgramARB, glValidateProgramARB, NULL, _gloffset_ValidateProgramARB),
+    NAME_FUNC_OFFSET(18048, glBindAttribLocationARB, glBindAttribLocationARB, NULL, _gloffset_BindAttribLocationARB),
+    NAME_FUNC_OFFSET(18069, glGetActiveAttribARB, glGetActiveAttribARB, NULL, _gloffset_GetActiveAttribARB),
+    NAME_FUNC_OFFSET(18087, glGetAttribLocationARB, glGetAttribLocationARB, NULL, _gloffset_GetAttribLocationARB),
+    NAME_FUNC_OFFSET(18107, glDrawBuffersARB, glDrawBuffersARB, NULL, _gloffset_DrawBuffersARB),
+    NAME_FUNC_OFFSET(18121, glDrawBuffersARB, glDrawBuffersARB, NULL, _gloffset_DrawBuffersARB),
+    NAME_FUNC_OFFSET(18138, glRenderbufferStorageMultisample, glRenderbufferStorageMultisample, NULL, _gloffset_RenderbufferStorageMultisample),
+    NAME_FUNC_OFFSET(18174, gl_dispatch_stub_584, gl_dispatch_stub_584, NULL, _gloffset_SampleMaskSGIS),
+    NAME_FUNC_OFFSET(18190, gl_dispatch_stub_585, gl_dispatch_stub_585, NULL, _gloffset_SamplePatternSGIS),
+    NAME_FUNC_OFFSET(18209, glPointParameterfEXT, glPointParameterfEXT, NULL, _gloffset_PointParameterfEXT),
+    NAME_FUNC_OFFSET(18227, glPointParameterfEXT, glPointParameterfEXT, NULL, _gloffset_PointParameterfEXT),
+    NAME_FUNC_OFFSET(18248, glPointParameterfEXT, glPointParameterfEXT, NULL, _gloffset_PointParameterfEXT),
+    NAME_FUNC_OFFSET(18270, glPointParameterfvEXT, glPointParameterfvEXT, NULL, _gloffset_PointParameterfvEXT),
+    NAME_FUNC_OFFSET(18289, glPointParameterfvEXT, glPointParameterfvEXT, NULL, _gloffset_PointParameterfvEXT),
+    NAME_FUNC_OFFSET(18311, glPointParameterfvEXT, glPointParameterfvEXT, NULL, _gloffset_PointParameterfvEXT),
+    NAME_FUNC_OFFSET(18334, glSecondaryColor3bEXT, glSecondaryColor3bEXT, NULL, _gloffset_SecondaryColor3bEXT),
+    NAME_FUNC_OFFSET(18353, glSecondaryColor3bvEXT, glSecondaryColor3bvEXT, NULL, _gloffset_SecondaryColor3bvEXT),
+    NAME_FUNC_OFFSET(18373, glSecondaryColor3dEXT, glSecondaryColor3dEXT, NULL, _gloffset_SecondaryColor3dEXT),
+    NAME_FUNC_OFFSET(18392, glSecondaryColor3dvEXT, glSecondaryColor3dvEXT, NULL, _gloffset_SecondaryColor3dvEXT),
+    NAME_FUNC_OFFSET(18412, glSecondaryColor3fEXT, glSecondaryColor3fEXT, NULL, _gloffset_SecondaryColor3fEXT),
+    NAME_FUNC_OFFSET(18431, glSecondaryColor3fvEXT, glSecondaryColor3fvEXT, NULL, _gloffset_SecondaryColor3fvEXT),
+    NAME_FUNC_OFFSET(18451, glSecondaryColor3iEXT, glSecondaryColor3iEXT, NULL, _gloffset_SecondaryColor3iEXT),
+    NAME_FUNC_OFFSET(18470, glSecondaryColor3ivEXT, glSecondaryColor3ivEXT, NULL, _gloffset_SecondaryColor3ivEXT),
+    NAME_FUNC_OFFSET(18490, glSecondaryColor3sEXT, glSecondaryColor3sEXT, NULL, _gloffset_SecondaryColor3sEXT),
+    NAME_FUNC_OFFSET(18509, glSecondaryColor3svEXT, glSecondaryColor3svEXT, NULL, _gloffset_SecondaryColor3svEXT),
+    NAME_FUNC_OFFSET(18529, glSecondaryColor3ubEXT, glSecondaryColor3ubEXT, NULL, _gloffset_SecondaryColor3ubEXT),
+    NAME_FUNC_OFFSET(18549, glSecondaryColor3ubvEXT, glSecondaryColor3ubvEXT, NULL, _gloffset_SecondaryColor3ubvEXT),
+    NAME_FUNC_OFFSET(18570, glSecondaryColor3uiEXT, glSecondaryColor3uiEXT, NULL, _gloffset_SecondaryColor3uiEXT),
+    NAME_FUNC_OFFSET(18590, glSecondaryColor3uivEXT, glSecondaryColor3uivEXT, NULL, _gloffset_SecondaryColor3uivEXT),
+    NAME_FUNC_OFFSET(18611, glSecondaryColor3usEXT, glSecondaryColor3usEXT, NULL, _gloffset_SecondaryColor3usEXT),
+    NAME_FUNC_OFFSET(18631, glSecondaryColor3usvEXT, glSecondaryColor3usvEXT, NULL, _gloffset_SecondaryColor3usvEXT),
+    NAME_FUNC_OFFSET(18652, glSecondaryColorPointerEXT, glSecondaryColorPointerEXT, NULL, _gloffset_SecondaryColorPointerEXT),
+    NAME_FUNC_OFFSET(18676, glMultiDrawArraysEXT, glMultiDrawArraysEXT, NULL, _gloffset_MultiDrawArraysEXT),
+    NAME_FUNC_OFFSET(18694, glMultiDrawElementsEXT, glMultiDrawElementsEXT, NULL, _gloffset_MultiDrawElementsEXT),
+    NAME_FUNC_OFFSET(18714, glFogCoordPointerEXT, glFogCoordPointerEXT, NULL, _gloffset_FogCoordPointerEXT),
+    NAME_FUNC_OFFSET(18732, glFogCoorddEXT, glFogCoorddEXT, NULL, _gloffset_FogCoorddEXT),
+    NAME_FUNC_OFFSET(18744, glFogCoorddvEXT, glFogCoorddvEXT, NULL, _gloffset_FogCoorddvEXT),
+    NAME_FUNC_OFFSET(18757, glFogCoordfEXT, glFogCoordfEXT, NULL, _gloffset_FogCoordfEXT),
+    NAME_FUNC_OFFSET(18769, glFogCoordfvEXT, glFogCoordfvEXT, NULL, _gloffset_FogCoordfvEXT),
+    NAME_FUNC_OFFSET(18782, glBlendFuncSeparateEXT, glBlendFuncSeparateEXT, NULL, _gloffset_BlendFuncSeparateEXT),
+    NAME_FUNC_OFFSET(18802, glBlendFuncSeparateEXT, glBlendFuncSeparateEXT, NULL, _gloffset_BlendFuncSeparateEXT),
+    NAME_FUNC_OFFSET(18826, glWindowPos2dMESA, glWindowPos2dMESA, NULL, _gloffset_WindowPos2dMESA),
+    NAME_FUNC_OFFSET(18840, glWindowPos2dMESA, glWindowPos2dMESA, NULL, _gloffset_WindowPos2dMESA),
+    NAME_FUNC_OFFSET(18857, glWindowPos2dvMESA, glWindowPos2dvMESA, NULL, _gloffset_WindowPos2dvMESA),
+    NAME_FUNC_OFFSET(18872, glWindowPos2dvMESA, glWindowPos2dvMESA, NULL, _gloffset_WindowPos2dvMESA),
+    NAME_FUNC_OFFSET(18890, glWindowPos2fMESA, glWindowPos2fMESA, NULL, _gloffset_WindowPos2fMESA),
+    NAME_FUNC_OFFSET(18904, glWindowPos2fMESA, glWindowPos2fMESA, NULL, _gloffset_WindowPos2fMESA),
+    NAME_FUNC_OFFSET(18921, glWindowPos2fvMESA, glWindowPos2fvMESA, NULL, _gloffset_WindowPos2fvMESA),
+    NAME_FUNC_OFFSET(18936, glWindowPos2fvMESA, glWindowPos2fvMESA, NULL, _gloffset_WindowPos2fvMESA),
+    NAME_FUNC_OFFSET(18954, glWindowPos2iMESA, glWindowPos2iMESA, NULL, _gloffset_WindowPos2iMESA),
+    NAME_FUNC_OFFSET(18968, glWindowPos2iMESA, glWindowPos2iMESA, NULL, _gloffset_WindowPos2iMESA),
+    NAME_FUNC_OFFSET(18985, glWindowPos2ivMESA, glWindowPos2ivMESA, NULL, _gloffset_WindowPos2ivMESA),
+    NAME_FUNC_OFFSET(19000, glWindowPos2ivMESA, glWindowPos2ivMESA, NULL, _gloffset_WindowPos2ivMESA),
+    NAME_FUNC_OFFSET(19018, glWindowPos2sMESA, glWindowPos2sMESA, NULL, _gloffset_WindowPos2sMESA),
+    NAME_FUNC_OFFSET(19032, glWindowPos2sMESA, glWindowPos2sMESA, NULL, _gloffset_WindowPos2sMESA),
+    NAME_FUNC_OFFSET(19049, glWindowPos2svMESA, glWindowPos2svMESA, NULL, _gloffset_WindowPos2svMESA),
+    NAME_FUNC_OFFSET(19064, glWindowPos2svMESA, glWindowPos2svMESA, NULL, _gloffset_WindowPos2svMESA),
+    NAME_FUNC_OFFSET(19082, glWindowPos3dMESA, glWindowPos3dMESA, NULL, _gloffset_WindowPos3dMESA),
+    NAME_FUNC_OFFSET(19096, glWindowPos3dMESA, glWindowPos3dMESA, NULL, _gloffset_WindowPos3dMESA),
+    NAME_FUNC_OFFSET(19113, glWindowPos3dvMESA, glWindowPos3dvMESA, NULL, _gloffset_WindowPos3dvMESA),
+    NAME_FUNC_OFFSET(19128, glWindowPos3dvMESA, glWindowPos3dvMESA, NULL, _gloffset_WindowPos3dvMESA),
+    NAME_FUNC_OFFSET(19146, glWindowPos3fMESA, glWindowPos3fMESA, NULL, _gloffset_WindowPos3fMESA),
+    NAME_FUNC_OFFSET(19160, glWindowPos3fMESA, glWindowPos3fMESA, NULL, _gloffset_WindowPos3fMESA),
+    NAME_FUNC_OFFSET(19177, glWindowPos3fvMESA, glWindowPos3fvMESA, NULL, _gloffset_WindowPos3fvMESA),
+    NAME_FUNC_OFFSET(19192, glWindowPos3fvMESA, glWindowPos3fvMESA, NULL, _gloffset_WindowPos3fvMESA),
+    NAME_FUNC_OFFSET(19210, glWindowPos3iMESA, glWindowPos3iMESA, NULL, _gloffset_WindowPos3iMESA),
+    NAME_FUNC_OFFSET(19224, glWindowPos3iMESA, glWindowPos3iMESA, NULL, _gloffset_WindowPos3iMESA),
+    NAME_FUNC_OFFSET(19241, glWindowPos3ivMESA, glWindowPos3ivMESA, NULL, _gloffset_WindowPos3ivMESA),
+    NAME_FUNC_OFFSET(19256, glWindowPos3ivMESA, glWindowPos3ivMESA, NULL, _gloffset_WindowPos3ivMESA),
+    NAME_FUNC_OFFSET(19274, glWindowPos3sMESA, glWindowPos3sMESA, NULL, _gloffset_WindowPos3sMESA),
+    NAME_FUNC_OFFSET(19288, glWindowPos3sMESA, glWindowPos3sMESA, NULL, _gloffset_WindowPos3sMESA),
+    NAME_FUNC_OFFSET(19305, glWindowPos3svMESA, glWindowPos3svMESA, NULL, _gloffset_WindowPos3svMESA),
+    NAME_FUNC_OFFSET(19320, glWindowPos3svMESA, glWindowPos3svMESA, NULL, _gloffset_WindowPos3svMESA),
+    NAME_FUNC_OFFSET(19338, glBindProgramNV, glBindProgramNV, NULL, _gloffset_BindProgramNV),
+    NAME_FUNC_OFFSET(19355, glDeleteProgramsNV, glDeleteProgramsNV, NULL, _gloffset_DeleteProgramsNV),
+    NAME_FUNC_OFFSET(19375, glGenProgramsNV, glGenProgramsNV, NULL, _gloffset_GenProgramsNV),
+    NAME_FUNC_OFFSET(19392, glGetVertexAttribPointervNV, glGetVertexAttribPointervNV, NULL, _gloffset_GetVertexAttribPointervNV),
+    NAME_FUNC_OFFSET(19418, glGetVertexAttribPointervNV, glGetVertexAttribPointervNV, NULL, _gloffset_GetVertexAttribPointervNV),
+    NAME_FUNC_OFFSET(19447, glIsProgramNV, glIsProgramNV, NULL, _gloffset_IsProgramNV),
+    NAME_FUNC_OFFSET(19462, glPointParameteriNV, glPointParameteriNV, NULL, _gloffset_PointParameteriNV),
+    NAME_FUNC_OFFSET(19480, glPointParameterivNV, glPointParameterivNV, NULL, _gloffset_PointParameterivNV),
+    NAME_FUNC_OFFSET(19499, gl_dispatch_stub_755, gl_dispatch_stub_755, NULL, _gloffset_DeleteVertexArraysAPPLE),
+    NAME_FUNC_OFFSET(19520, gl_dispatch_stub_757, gl_dispatch_stub_757, NULL, _gloffset_IsVertexArrayAPPLE),
+    NAME_FUNC_OFFSET(19536, gl_dispatch_stub_765, gl_dispatch_stub_765, NULL, _gloffset_BlendEquationSeparateEXT),
+    NAME_FUNC_OFFSET(19560, gl_dispatch_stub_765, gl_dispatch_stub_765, NULL, _gloffset_BlendEquationSeparateEXT),
+    NAME_FUNC_OFFSET(19587, glBindFramebufferEXT, glBindFramebufferEXT, NULL, _gloffset_BindFramebufferEXT),
+    NAME_FUNC_OFFSET(19605, glBindRenderbufferEXT, glBindRenderbufferEXT, NULL, _gloffset_BindRenderbufferEXT),
+    NAME_FUNC_OFFSET(19624, glCheckFramebufferStatusEXT, glCheckFramebufferStatusEXT, NULL, _gloffset_CheckFramebufferStatusEXT),
+    NAME_FUNC_OFFSET(19649, glDeleteFramebuffersEXT, glDeleteFramebuffersEXT, NULL, _gloffset_DeleteFramebuffersEXT),
+    NAME_FUNC_OFFSET(19670, glDeleteRenderbuffersEXT, glDeleteRenderbuffersEXT, NULL, _gloffset_DeleteRenderbuffersEXT),
+    NAME_FUNC_OFFSET(19692, glFramebufferRenderbufferEXT, glFramebufferRenderbufferEXT, NULL, _gloffset_FramebufferRenderbufferEXT),
+    NAME_FUNC_OFFSET(19718, glFramebufferTexture1DEXT, glFramebufferTexture1DEXT, NULL, _gloffset_FramebufferTexture1DEXT),
+    NAME_FUNC_OFFSET(19741, glFramebufferTexture2DEXT, glFramebufferTexture2DEXT, NULL, _gloffset_FramebufferTexture2DEXT),
+    NAME_FUNC_OFFSET(19764, glFramebufferTexture3DEXT, glFramebufferTexture3DEXT, NULL, _gloffset_FramebufferTexture3DEXT),
+    NAME_FUNC_OFFSET(19787, glGenFramebuffersEXT, glGenFramebuffersEXT, NULL, _gloffset_GenFramebuffersEXT),
+    NAME_FUNC_OFFSET(19805, glGenRenderbuffersEXT, glGenRenderbuffersEXT, NULL, _gloffset_GenRenderbuffersEXT),
+    NAME_FUNC_OFFSET(19824, glGenerateMipmapEXT, glGenerateMipmapEXT, NULL, _gloffset_GenerateMipmapEXT),
+    NAME_FUNC_OFFSET(19841, glGetFramebufferAttachmentParameterivEXT, glGetFramebufferAttachmentParameterivEXT, NULL, _gloffset_GetFramebufferAttachmentParameterivEXT),
+    NAME_FUNC_OFFSET(19879, glGetRenderbufferParameterivEXT, glGetRenderbufferParameterivEXT, NULL, _gloffset_GetRenderbufferParameterivEXT),
+    NAME_FUNC_OFFSET(19908, glIsFramebufferEXT, glIsFramebufferEXT, NULL, _gloffset_IsFramebufferEXT),
+    NAME_FUNC_OFFSET(19924, glIsRenderbufferEXT, glIsRenderbufferEXT, NULL, _gloffset_IsRenderbufferEXT),
+    NAME_FUNC_OFFSET(19941, glRenderbufferStorageEXT, glRenderbufferStorageEXT, NULL, _gloffset_RenderbufferStorageEXT),
+    NAME_FUNC_OFFSET(19963, gl_dispatch_stub_783, gl_dispatch_stub_783, NULL, _gloffset_BlitFramebufferEXT),
+    NAME_FUNC_OFFSET(19981, glFramebufferTextureLayerEXT, glFramebufferTextureLayerEXT, NULL, _gloffset_FramebufferTextureLayerEXT),
+    NAME_FUNC_OFFSET(20007, glProvokingVertexEXT, glProvokingVertexEXT, NULL, _gloffset_ProvokingVertexEXT),
     NAME_FUNC_OFFSET(-1, NULL, NULL, NULL, 0)
 };
 
index 737fd4d6a8489d8ceeccc5d8c9545399acf61ee0..f480edff4e8a868234aee552113a66a2181970c9 100644 (file)
@@ -69,7 +69,7 @@
  */
 #ifdef PTHREADS
 
-unsigned long
+PUBLIC unsigned long
 _glthread_GetID(void)
 {
    return (unsigned long) pthread_self();
@@ -123,7 +123,7 @@ _glthread_SetTSD(_glthread_TSD *tsd, void *ptr)
 #define USE_LOCK_FOR_KEY       /* undef this to try a version without
                                   lock for the global key... */
 
-unsigned long
+PUBLIC unsigned long
 _glthread_GetID(void)
 {
    abort();   /* XXX not implemented yet */
@@ -201,7 +201,7 @@ void InsteadOf_exit(int nCode)
    DWORD dwErr=GetLastError();
 }
 
-unsigned long
+PUBLIC unsigned long
 _glthread_GetID(void)
 {
    return GetCurrentThreadId();
@@ -251,7 +251,7 @@ _glthread_SetTSD(_glthread_TSD *tsd, void *ptr)
  */
 #ifdef BEOS_THREADS
 
-unsigned long
+PUBLIC unsigned long
 _glthread_GetID(void)
 {
    return (unsigned long) find_thread(NULL);
@@ -293,7 +293,7 @@ _glthread_SetTSD(_glthread_TSD *tsd, void *ptr)
  * no-op functions
  */
 
-unsigned long
+PUBLIC unsigned long
 _glthread_GetID(void)
 {
    return 0;
diff --git a/src/mesa/glapi/remap_helper.py b/src/mesa/glapi/remap_helper.py
new file mode 100644 (file)
index 0000000..e47583a
--- /dev/null
@@ -0,0 +1,218 @@
+#!/usr/bin/env python
+
+# Copyright (C) 2009 Chia-I Wu <olv@0xlab.org>
+# All Rights Reserved.
+#
+# This is based on extension_helper.py by Ian Romanick.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# on the rights to use, copy, modify, merge, publish, distribute, sub
+# license, and/or sell copies of the Software, and to permit persons to whom
+# the Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+# IBM AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+
+import gl_XML
+import license
+import sys, getopt, string
+
+def get_function_spec(func):
+       sig = ""
+       # derive parameter signature
+       for p in func.parameterIterator():
+               if p.is_padding:
+                       continue
+               # FIXME: This is a *really* ugly hack. :(
+               tn = p.type_expr.get_base_type_node()
+               if p.is_pointer():
+                       sig += 'p'
+               elif tn.integer:
+                       sig += 'i'
+               elif tn.size == 4:
+                       sig += 'f'
+               else:
+                       sig += 'd'
+
+       spec = [sig]
+       for ent in func.entry_points:
+               spec.append("gl" + ent)
+
+       # spec is terminated by an empty string
+       spec.append('')
+
+       return spec
+
+class PrintGlRemap(gl_XML.gl_print_base):
+       def __init__(self):
+               gl_XML.gl_print_base.__init__(self)
+
+               self.name = "remap_helper.py (from Mesa)"
+               self.license = license.bsd_license_template % ("Copyright (C) 2009 Chia-I Wu <olv@0xlab.org>", "Chia-I Wu")
+               return
+
+
+       def printRealHeader(self):
+               print '#include "glapi/dispatch.h"'
+               print ''
+               return
+
+
+       def printBody(self, api):
+               print 'struct gl_function_remap {'
+               print '   GLint func_index;'
+               print '   GLint dispatch_offset; /* for sanity check */'
+               print '};'
+               print ''
+
+               pool_indices = {}
+
+               print '/* this is internal to remap.c */'
+               print '#ifdef need_MESA_remap_table'
+               print ''
+               print 'static const char _mesa_function_pool[] ='
+
+               # output string pool
+               index = 0;
+               for f in api.functionIterateAll():
+                       pool_indices[f] = index
+
+                       spec = get_function_spec(f)
+
+                       # a function has either assigned offset, fixed offset,
+                       # or no offset
+                       if f.assign_offset:
+                               comments = "will be remapped"
+                       elif f.offset > 0:
+                               comments = "offset %d" % f.offset
+                       else:
+                               comments = "dynamic"
+
+                       print '   /* _mesa_function_pool[%d]: %s (%s) */' \
+                                       % (index, f.name, comments)
+                       for line in spec:
+                               print '   "%s\\0"' % line
+                               index += len(line) + 1
+               print '   ;'
+               print ''
+
+               print '/* these functions need to be remapped */'
+               print 'static const struct {'
+               print '   GLint pool_index;'
+               print '   GLint remap_index;'
+               print '} MESA_remap_table_functions[] = {'
+               # output all functions that need to be remapped
+               # iterate by offsets so that they are sorted by remap indices
+               for f in api.functionIterateByOffset():
+                       if not f.assign_offset:
+                               continue
+                       print '   { %5d, %s_remap_index },' \
+                                       % (pool_indices[f], f.name)
+               print '   {    -1, -1 }'
+               print '};'
+               print ''
+
+               abi = [ "1.0", "1.1", "1.2", "GL_ARB_multitexture" ]
+               extension_functions = {}
+
+               # collect non-ABI functions
+               for f in api.functionIterateAll():
+                       for n in f.entry_points:
+                               category, num = api.get_category_for_name(n)
+                               if category not in abi:
+                                       c = gl_XML.real_category_name(category)
+                                       if not extension_functions.has_key(c):
+                                               extension_functions[c] = []
+                                       extension_functions[c].append(f)
+               extensions = extension_functions.keys()
+               extensions.sort()
+
+               # output ABI functions that have alternative names (with ext suffix)
+               print '/* these functions are in the ABI, but have alternative names */'
+               print 'static const struct gl_function_remap MESA_alt_functions[] = {'
+               for ext in extensions:
+                       funcs = []
+                       for f in extension_functions[ext]:
+                               # test if the function is in the ABI
+                               if not f.assign_offset and f.offset >= 0:
+                                       funcs.append(f)
+                       if not funcs:
+                               continue
+                       print '   /* from %s */' % ext
+                       for f in funcs:
+                               print '   { %5d, _gloffset_%s },' \
+                                               % (pool_indices[f], f.name)
+               print '   {    -1, -1 }'
+               print '};'
+               print ''
+
+               print '#endif /* need_MESA_remap_table */'
+               print ''
+
+               # output remap helpers for DRI drivers
+
+               for ext in extensions:
+                       funcs = []
+                       remapped = []
+                       for f in extension_functions[ext]:
+                               if f.assign_offset:
+                                       # these are handled above
+                                       remapped.append(f)
+                               else:
+                                       # these functions are either in the
+                                        # abi, or have offset -1
+                                       funcs.append(f)
+
+                       print '#if defined(need_%s)' % (ext)
+                       if remapped:
+                               print '/* functions defined in MESA_remap_table_functions are excluded */'
+
+                       # output extension functions that need to be mapped
+                       print 'static const struct gl_function_remap %s_functions[] = {' % (ext)
+                       for f in funcs:
+                               if f.offset >= 0:
+                                       print '   { %5d, _gloffset_%s },' \
+                                                       % (pool_indices[f], f.name)
+                               else:
+                                       print '   { %5d, -1 }, /* %s */' % \
+                                                       (pool_indices[f], f.name)
+                       print '   {    -1, -1 }'
+                       print '};'
+
+                       print '#endif'
+                       print ''
+
+               return
+
+
+def show_usage():
+       print "Usage: %s [-f input_file_name]" % sys.argv[0]
+       sys.exit(1)
+
+if __name__ == '__main__':
+       file_name = "gl_API.xml"
+
+       try:
+               (args, trail) = getopt.getopt(sys.argv[1:], "f:")
+       except Exception,e:
+               show_usage()
+
+       for (arg,val) in args:
+               if arg == "-f":
+                       file_name = val
+
+       api = gl_XML.parse_GL_API( file_name )
+
+       printer = PrintGlRemap()
+       printer.Print( api )
index a058227110d2b243df4505d116ac649079f4cd6b..469b4529f91f5cc73674d622bb390e2f2dbeeea4 100644 (file)
@@ -32,7 +32,6 @@
 #include "context.h"
 #include "imports.h"
 #include "macros.h"
-#include "glapi/glapioffsets.h"
 #include "glapi/dispatch.h"
 
 typedef void (GLAPIENTRY *array_func)( const void * );
index 1559984f43a5eb543603366e7cd63bd688c50197..c2d8a7fb9729f847046c1d54446c5613d12c4e2a 100644 (file)
@@ -51,6 +51,7 @@
 #include "clear.h"
 #include "clip.h"
 #include "colortab.h"
+#include "condrender.h"
 #include "context.h"
 #include "convolve.h"
 #include "depth.h"
@@ -746,4 +747,16 @@ _mesa_init_exec_table(struct _glapi_table *exec)
    /* GL_ARB_vertex_array_object */
    SET_BindVertexArray(exec, _mesa_BindVertexArray);
    SET_GenVertexArrays(exec, _mesa_GenVertexArrays);
+
+   /* GL_EXT_draw_buffers2 */
+   SET_ColorMaskIndexedEXT(exec, _mesa_ColorMaskIndexed);
+   SET_GetBooleanIndexedvEXT(exec, _mesa_GetBooleanIndexedv);
+   SET_GetIntegerIndexedvEXT(exec, _mesa_GetIntegerIndexedv);
+   SET_EnableIndexedEXT(exec, _mesa_EnableIndexed);
+   SET_DisableIndexedEXT(exec, _mesa_DisableIndexed);
+   SET_IsEnabledIndexedEXT(exec, _mesa_IsEnabledIndexed);
+
+   /* GL_NV_conditional_render */
+   SET_BeginConditionalRenderNV(exec, _mesa_BeginConditionalRender);
+   SET_EndConditionalRenderNV(exec, _mesa_EndConditionalRender);
 }
index 246c5521b7d9c83b8278deaa25a06223058049a4..0641b98b3b78a88056751d406f962e4ff39d6b6a 100644 (file)
@@ -499,7 +499,17 @@ pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable)
        }
 
    TEST_AND_UPDATE(ctx->Color.AlphaEnabled, enable->AlphaTest, GL_ALPHA_TEST);
-   TEST_AND_UPDATE(ctx->Color.BlendEnabled, enable->Blend, GL_BLEND);
+   if (ctx->Color.BlendEnabled != enable->Blend) {
+      if (ctx->Extensions.EXT_draw_buffers2) {
+         GLuint i;
+         for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
+            _mesa_set_enablei(ctx, GL_BLEND, i, (enable->Blend >> i) & 1);
+         }
+      }
+      else {
+         _mesa_set_enable(ctx, GL_BLEND, (enable->Blend & 1));
+      }
+   }
 
    for (i=0;i<MAX_CLIP_PLANES;i++) {
       const GLuint mask = 1 << i;
@@ -825,7 +835,7 @@ pop_texture_group(GLcontext *ctx, struct texture_state *texstate)
 
          _mesa_BindTexture(target, obj->Name);
 
-         _mesa_TexParameterfv(target, GL_TEXTURE_BORDER_COLOR, obj->BorderColor);
+         _mesa_TexParameterfv(target, GL_TEXTURE_BORDER_COLOR, obj->BorderColor.f);
          _mesa_TexParameterf(target, GL_TEXTURE_PRIORITY, obj->Priority);
          _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, obj->WrapS);
          _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, obj->WrapT);
@@ -906,6 +916,7 @@ _mesa_PopAttrib(void)
          case GL_COLOR_BUFFER_BIT:
             {
                const struct gl_colorbuffer_attrib *color;
+
                color = (const struct gl_colorbuffer_attrib *) attr->data;
                _mesa_ClearIndex((GLfloat) color->ClearIndex);
                _mesa_ClearColor(color->ClearColor[0],
@@ -913,10 +924,22 @@ _mesa_PopAttrib(void)
                                 color->ClearColor[2],
                                 color->ClearColor[3]);
                _mesa_IndexMask(color->IndexMask);
-               _mesa_ColorMask((GLboolean) (color->ColorMask[0] != 0),
-                               (GLboolean) (color->ColorMask[1] != 0),
-                               (GLboolean) (color->ColorMask[2] != 0),
-                               (GLboolean) (color->ColorMask[3] != 0));
+               if (!ctx->Extensions.EXT_draw_buffers2) {
+                  _mesa_ColorMask((GLboolean) (color->ColorMask[0][0] != 0),
+                                  (GLboolean) (color->ColorMask[0][1] != 0),
+                                  (GLboolean) (color->ColorMask[0][2] != 0),
+                                  (GLboolean) (color->ColorMask[0][3] != 0));
+               }
+               else {
+                  GLuint i;
+                  for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
+                     _mesa_ColorMaskIndexed(i, 
+                                  (GLboolean) (color->ColorMask[i][0] != 0),
+                                  (GLboolean) (color->ColorMask[i][1] != 0),
+                                  (GLboolean) (color->ColorMask[i][2] != 0),
+                                  (GLboolean) (color->ColorMask[i][3] != 0));
+                  }
+               }
                {
                   /* Need to determine if more than one color output is
                    * specified.  If so, call glDrawBuffersARB, else call
@@ -948,7 +971,18 @@ _mesa_PopAttrib(void)
                }
                _mesa_set_enable(ctx, GL_ALPHA_TEST, color->AlphaEnabled);
                _mesa_AlphaFunc(color->AlphaFunc, color->AlphaRef);
-               _mesa_set_enable(ctx, GL_BLEND, color->BlendEnabled);
+               if (ctx->Color.BlendEnabled != color->BlendEnabled) {
+                  if (ctx->Extensions.EXT_draw_buffers2) {
+                     GLuint i;
+                     for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
+                        _mesa_set_enablei(ctx, GL_BLEND, i,
+                                          (color->BlendEnabled >> i) & 1);
+                     }
+                  }
+                  else {
+                     _mesa_set_enable(ctx, GL_BLEND, (color->BlendEnabled & 1));
+                  }
+               }
                _mesa_BlendFuncSeparateEXT(color->BlendSrcRGB,
                                           color->BlendDstRGB,
                                           color->BlendSrcA,
@@ -1043,22 +1077,39 @@ _mesa_PopAttrib(void)
                   _math_matrix_analyse( ctx->ModelviewMatrixStack.Top );
               
                for (i = 0; i < ctx->Const.MaxLights; i++) {
-                 const struct gl_light *l = &light->Light[i];
+                  const struct gl_light *l = &light->Light[i];
                   _mesa_set_enable(ctx, GL_LIGHT0 + i, l->Enabled);
-                 _mesa_light(ctx, i, GL_AMBIENT, l->Ambient);
-                 _mesa_light(ctx, i, GL_DIFFUSE, l->Diffuse);
-                 _mesa_light(ctx, i, GL_SPECULAR, l->Specular );
-                 _mesa_light(ctx, i, GL_POSITION, l->EyePosition);
-                 _mesa_light(ctx, i, GL_SPOT_DIRECTION, l->SpotDirection);
-                 _mesa_light(ctx, i, GL_SPOT_EXPONENT, &l->SpotExponent);
-                 _mesa_light(ctx, i, GL_SPOT_CUTOFF, &l->SpotCutoff);
-                 _mesa_light(ctx, i, GL_CONSTANT_ATTENUATION,
-                              &l->ConstantAttenuation);
-                 _mesa_light(ctx, i, GL_LINEAR_ATTENUATION,
-                              &l->LinearAttenuation);
-                 _mesa_light(ctx, i, GL_QUADRATIC_ATTENUATION,
-                              &l->QuadraticAttenuation);
-               }
+                  _mesa_light(ctx, i, GL_AMBIENT, l->Ambient);
+                  _mesa_light(ctx, i, GL_DIFFUSE, l->Diffuse);
+                  _mesa_light(ctx, i, GL_SPECULAR, l->Specular );
+                  _mesa_light(ctx, i, GL_POSITION, l->EyePosition);
+                  _mesa_light(ctx, i, GL_SPOT_DIRECTION, l->SpotDirection);
+                  {
+                     GLfloat p[4] = { 0 };
+                     p[0] = l->SpotExponent;
+                     _mesa_light(ctx, i, GL_SPOT_EXPONENT, p);
+                  }
+                  {
+                     GLfloat p[4] = { 0 };
+                     p[0] = l->SpotCutoff;
+                     _mesa_light(ctx, i, GL_SPOT_CUTOFF, p);
+                  }
+                  {
+                     GLfloat p[4] = { 0 };
+                     p[0] = l->ConstantAttenuation;
+                     _mesa_light(ctx, i, GL_CONSTANT_ATTENUATION, p);
+                  }
+                  {
+                     GLfloat p[4] = { 0 };
+                     p[0] = l->LinearAttenuation;
+                     _mesa_light(ctx, i, GL_LINEAR_ATTENUATION, p);
+                  }
+                  {
+                     GLfloat p[4] = { 0 };
+                     p[0] = l->QuadraticAttenuation;
+                     _mesa_light(ctx, i, GL_QUADRATIC_ATTENUATION, p);
+                  }
+                }
                /* light model */
                _mesa_LightModelfv(GL_LIGHT_MODEL_AMBIENT,
                                   light->Model.Ambient);
index 39cf6153e2850c3b6fc691f984317f26e7ff24af..b8170dd46860eaecfc7c4fba38c28527c366ce9d 100644 (file)
@@ -72,7 +72,7 @@ _mesa_BlendFuncSeparateEXT( GLenum sfactorRGB, GLenum dfactorRGB,
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
-   if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
+   if (MESA_VERBOSE & VERBOSE_API)
       _mesa_debug(ctx, "glBlendFuncSeparate %s %s %s %s\n",
                   _mesa_lookup_enum_by_nr(sfactorRGB),
                   _mesa_lookup_enum_by_nr(dfactorRGB),
@@ -250,7 +250,7 @@ _mesa_BlendEquation( GLenum mode )
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
-   if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
+   if (MESA_VERBOSE & VERBOSE_API)
       _mesa_debug(ctx, "glBlendEquation %s\n",
                   _mesa_lookup_enum_by_nr(mode));
 
@@ -278,7 +278,7 @@ _mesa_BlendEquationSeparateEXT( GLenum modeRGB, GLenum modeA )
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
-   if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
+   if (MESA_VERBOSE & VERBOSE_API)
       _mesa_debug(ctx, "glBlendEquationSeparateEXT %s %s\n",
                   _mesa_lookup_enum_by_nr(modeRGB),
                   _mesa_lookup_enum_by_nr(modeA));
@@ -484,6 +484,8 @@ _mesa_ColorMask( GLboolean red, GLboolean green,
 {
    GET_CURRENT_CONTEXT(ctx);
    GLubyte tmp[4];
+   GLuint i;
+   GLboolean flushed;
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    if (MESA_VERBOSE & VERBOSE_API)
@@ -497,14 +499,58 @@ _mesa_ColorMask( GLboolean red, GLboolean green,
    tmp[BCOMP] = blue   ? 0xff : 0x0;
    tmp[ACOMP] = alpha  ? 0xff : 0x0;
 
-   if (TEST_EQ_4UBV(tmp, ctx->Color.ColorMask))
+   flushed = GL_FALSE;
+   for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
+      if (!TEST_EQ_4V(tmp, ctx->Color.ColorMask[i])) {
+         if (!flushed) {
+            FLUSH_VERTICES(ctx, _NEW_COLOR);
+         }
+         flushed = GL_TRUE;
+         COPY_4UBV(ctx->Color.ColorMask[i], tmp);
+      }
+   }
+
+   if (ctx->Driver.ColorMask)
+      ctx->Driver.ColorMask( ctx, red, green, blue, alpha );
+}
+
+
+/**
+ * For GL_EXT_draw_buffers2 and GL3
+ */
+void GLAPIENTRY
+_mesa_ColorMaskIndexed( GLuint buf, GLboolean red, GLboolean green,
+                        GLboolean blue, GLboolean alpha )
+{
+   GLubyte tmp[4];
+   GET_CURRENT_CONTEXT(ctx);
+   ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+   if (MESA_VERBOSE & VERBOSE_API)
+      _mesa_debug(ctx, "glColorMaskIndexed %u %d %d %d %d\n",
+                  buf, red, green, blue, alpha);
+
+   if (buf >= ctx->Const.MaxDrawBuffers) {
+      _mesa_error(ctx, GL_INVALID_VALUE, "glColorMaskIndexed(buf=%u)", buf);
+      return;
+   }
+
+   /* Shouldn't have any information about channel depth in core mesa
+    * -- should probably store these as the native booleans:
+    */
+   tmp[RCOMP] = red    ? 0xff : 0x0;
+   tmp[GCOMP] = green  ? 0xff : 0x0;
+   tmp[BCOMP] = blue   ? 0xff : 0x0;
+   tmp[ACOMP] = alpha  ? 0xff : 0x0;
+
+   if (TEST_EQ_4V(tmp, ctx->Color.ColorMask[buf]))
       return;
 
    FLUSH_VERTICES(ctx, _NEW_COLOR);
-   COPY_4UBV(ctx->Color.ColorMask, tmp);
+   COPY_4UBV(ctx->Color.ColorMask[buf], tmp);
 
-   if (ctx->Driver.ColorMask)
-      ctx->Driver.ColorMask( ctx, red, green, blue, alpha );
+   if (ctx->Driver.ColorMaskIndexed)
+      ctx->Driver.ColorMaskIndexed(ctx, buf, red, green, blue, alpha);
 }
 
 
@@ -555,16 +601,13 @@ void _mesa_init_color( GLcontext * ctx )
 {
    /* Color buffer group */
    ctx->Color.IndexMask = ~0u;
-   ctx->Color.ColorMask[0] = 0xff;
-   ctx->Color.ColorMask[1] = 0xff;
-   ctx->Color.ColorMask[2] = 0xff;
-   ctx->Color.ColorMask[3] = 0xff;
+   memset(ctx->Color.ColorMask, 0xff, sizeof(ctx->Color.ColorMask));
    ctx->Color.ClearIndex = 0;
    ASSIGN_4V( ctx->Color.ClearColor, 0, 0, 0, 0 );
    ctx->Color.AlphaEnabled = GL_FALSE;
    ctx->Color.AlphaFunc = GL_ALWAYS;
    ctx->Color.AlphaRef = 0;
-   ctx->Color.BlendEnabled = GL_FALSE;
+   ctx->Color.BlendEnabled = 0x0;
    ctx->Color.BlendSrcRGB = GL_ONE;
    ctx->Color.BlendDstRGB = GL_ZERO;
    ctx->Color.BlendSrcA = GL_ONE;
index 5c0f2783a735f3794d7cef0d4d4d312ba367da81..b4fd7470ebe29a62027969cc7ca70b0040d76b9d 100644 (file)
@@ -72,6 +72,10 @@ extern void GLAPIENTRY
 _mesa_ColorMask( GLboolean red, GLboolean green,
                  GLboolean blue, GLboolean alpha );
 
+extern void GLAPIENTRY
+_mesa_ColorMaskIndexed( GLuint buf, GLboolean red, GLboolean green,
+                        GLboolean blue, GLboolean alpha );
+
 
 extern void GLAPIENTRY
 _mesa_ClampColorARB(GLenum target, GLenum clamp);
index 189b5e165585ef37bbd1d5c507319daac9adf72e..9e765b21d2f70d382d85fad978dce9836655e2cb 100644 (file)
 
 
 /**
- * Get the buffer object bound to the specified target in a GL context.
- *
- * \param ctx     GL context
- * \param target  Buffer object target to be retrieved.  Currently this must
- *                be either \c GL_ARRAY_BUFFER or \c GL_ELEMENT_ARRAY_BUFFER.
- * \return   A pointer to the buffer object bound to \c target in the
+ * Return pointer to address of a buffer object target.
+ * \param ctx  the GL context
+ * \param target  the buffer object target to be retrieved.
+ * \return   pointer to pointer to the buffer object bound to \c target in the
  *           specified context or \c NULL if \c target is invalid.
  */
-static INLINE struct gl_buffer_object *
-get_buffer(GLcontext *ctx, GLenum target)
+static INLINE struct gl_buffer_object **
+get_buffer_target(GLcontext *ctx, GLenum target)
 {
-   struct gl_buffer_object * bufObj = NULL;
-
    switch (target) {
-      case GL_ARRAY_BUFFER_ARB:
-         bufObj = ctx->Array.ArrayBufferObj;
-         break;
-      case GL_ELEMENT_ARRAY_BUFFER_ARB:
-         bufObj = ctx->Array.ElementArrayBufferObj;
-         break;
-      case GL_PIXEL_PACK_BUFFER_EXT:
-         bufObj = ctx->Pack.BufferObj;
-         break;
-      case GL_PIXEL_UNPACK_BUFFER_EXT:
-         bufObj = ctx->Unpack.BufferObj;
-         break;
-      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;
+   case GL_ARRAY_BUFFER_ARB:
+      return &ctx->Array.ArrayBufferObj;
+   case GL_ELEMENT_ARRAY_BUFFER_ARB:
+      return &ctx->Array.ElementArrayBufferObj;
+   case GL_PIXEL_PACK_BUFFER_EXT:
+      return &ctx->Pack.BufferObj;
+   case GL_PIXEL_UNPACK_BUFFER_EXT:
+      return &ctx->Unpack.BufferObj;
+   case GL_COPY_READ_BUFFER:
+      if (ctx->Extensions.ARB_copy_buffer) {
+         return &ctx->CopyReadBuffer;
+      }
+      break;
+   case GL_COPY_WRITE_BUFFER:
+      if (ctx->Extensions.ARB_copy_buffer) {
+         return &ctx->CopyWriteBuffer;
+      }
+      break;
+   default:
+      return NULL;
    }
+   return NULL;
+}
 
-   /* bufObj should point to NullBufferObj or a user-created buffer object */
-   ASSERT(bufObj);
 
-   return bufObj;
+/**
+ * Get the buffer object bound to the specified target in a GL context.
+ * \param ctx  the GL context
+ * \param target  the buffer object target to be retrieved.
+ * \return   pointer to the buffer object bound to \c target in the
+ *           specified context or \c NULL if \c target is invalid.
+ */
+static INLINE struct gl_buffer_object *
+get_buffer(GLcontext *ctx, GLenum target)
+{
+   struct gl_buffer_object **bufObj = get_buffer_target(ctx, target);
+   if (bufObj)
+      return *bufObj;
+   return NULL;
 }
 
 
@@ -552,6 +556,7 @@ _mesa_init_buffer_objects( GLcontext *ctx )
 
 /**
  * Bind the specified target to buffer for the specified context.
+ * Called by glBindBuffer() and other functions.
  */
 static void
 bind_buffer_object(GLcontext *ctx, GLenum target, GLuint buffer)
@@ -560,40 +565,14 @@ bind_buffer_object(GLcontext *ctx, GLenum target, GLuint buffer)
    struct gl_buffer_object *newBufObj = NULL;
    struct gl_buffer_object **bindTarget = NULL;
 
-   switch (target) {
-   case GL_ARRAY_BUFFER_ARB:
-      bindTarget = &ctx->Array.ArrayBufferObj;
-      break;
-   case GL_ELEMENT_ARRAY_BUFFER_ARB:
-      bindTarget = &ctx->Array.ElementArrayBufferObj;
-      break;
-   case GL_PIXEL_PACK_BUFFER_EXT:
-      bindTarget = &ctx->Pack.BufferObj;
-      break;
-   case GL_PIXEL_UNPACK_BUFFER_EXT:
-      bindTarget = &ctx->Unpack.BufferObj;
-      break;
-   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:
-      ; /* no-op / we'll hit the follow error test next */
-   }
-
+   bindTarget = get_buffer_target(ctx, target);
    if (!bindTarget) {
       _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferARB(target 0x%x)");
       return;
    }
 
    /* Get pointer to old buffer object (to be unbound) */
-   oldBufObj = get_buffer(ctx, target);
+   oldBufObj = *bindTarget;
    if (oldBufObj && oldBufObj->Name == buffer)
       return;   /* rebinding the same buffer object- no change */
 
@@ -1410,6 +1389,48 @@ _mesa_GetBufferParameterivARB(GLenum target, GLenum pname, GLint *params)
 }
 
 
+/**
+ * New in GL 3.2
+ * This is pretty much a duplicate of GetBufferParameteriv() but the
+ * GL_BUFFER_SIZE_ARB attribute will be 64-bits on a 64-bit system.
+ */
+void GLAPIENTRY
+_mesa_GetBufferParameteri64v(GLenum target, GLenum pname, GLint64 *params)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_buffer_object *bufObj;
+   ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+   bufObj = get_buffer(ctx, target);
+   if (!bufObj) {
+      _mesa_error(ctx, GL_INVALID_ENUM, "GetBufferParameteri64v(target)" );
+      return;
+   }
+   if (!_mesa_is_bufferobj(bufObj)) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "GetBufferParameteri64v" );
+      return;
+   }
+
+   switch (pname) {
+      case GL_BUFFER_SIZE_ARB:
+         *params = bufObj->Size;
+         break;
+      case GL_BUFFER_USAGE_ARB:
+         *params = bufObj->Usage;
+         break;
+      case GL_BUFFER_ACCESS_ARB:
+         *params = simplified_access_mode(bufObj->AccessFlags);
+         break;
+      case GL_BUFFER_MAPPED_ARB:
+         *params = _mesa_bufferobj_mapped(bufObj);
+         break;
+      default:
+         _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameteri64v(pname)");
+         return;
+   }
+}
+
+
 void GLAPIENTRY
 _mesa_GetBufferPointervARB(GLenum target, GLenum pname, GLvoid **params)
 {
index 9f732ec0c07cfb3b70b2af4bea9d6025a546f5a3..2931962ac08a3dfeb4cbaea5af94480cab0737ee 100644 (file)
@@ -154,6 +154,9 @@ _mesa_UnmapBufferARB(GLenum target);
 extern void GLAPIENTRY
 _mesa_GetBufferParameterivARB(GLenum target, GLenum pname, GLint *params);
 
+extern void GLAPIENTRY
+_mesa_GetBufferParameteri64v(GLenum target, GLenum pname, GLint64 *params);
+
 extern void GLAPIENTRY
 _mesa_GetBufferPointervARB(GLenum target, GLenum pname, GLvoid **params);
 
index d8b5f3b1f4aafe02bbd5f53e27b8644210901682..97f065975819e7710b6080adbfcba5b7a8aef2ba 100644 (file)
@@ -338,13 +338,13 @@ _mesa_DrawBuffersARB(GLsizei n, const GLenum *buffers)
    if (ctx->Driver.DrawBuffers)
       ctx->Driver.DrawBuffers(ctx, n, buffers);
    else if (ctx->Driver.DrawBuffer)
-      ctx->Driver.DrawBuffer(ctx, n>0? buffers[0]:GL_NONE);
+      ctx->Driver.DrawBuffer(ctx, n > 0 ? buffers[0] : GL_NONE);
 }
 
 
 /**
  * Helper function to set the GL_DRAW_BUFFER state in the context and
- * current FBO.
+ * current FBO.  Called via glDrawBuffer(), glDrawBuffersARB()
  *
  * All error checking will have been done prior to calling this function
  * so nothing should go wrong at this point.
@@ -362,6 +362,7 @@ _mesa_drawbuffers(GLcontext *ctx, GLuint n, const GLenum *buffers,
 {
    struct gl_framebuffer *fb = ctx->DrawBuffer;
    GLbitfield mask[MAX_DRAW_BUFFERS];
+   GLboolean newState = GL_FALSE;
 
    if (!destMask) {
       /* compute destMask values now */
@@ -375,34 +376,54 @@ _mesa_drawbuffers(GLcontext *ctx, GLuint n, const GLenum *buffers,
       destMask = mask;
    }
 
+   /*
+    * If n==1, destMask[0] may have up to four bits set.
+    * Otherwise, destMask[x] can only have one bit set.
+    */
    if (n == 1) {
-      GLuint buf, count = 0;
-      /* init to -1 to help catch errors */
-      fb->_ColorDrawBufferIndexes[0] = -1;
-      for (buf = 0; buf < BUFFER_COUNT; buf++) {
-         if (destMask[0] & (1 << buf)) {
-            fb->_ColorDrawBufferIndexes[count] = buf;
-            count++;
+      GLuint count = 0, destMask0 = destMask[0];
+      while (destMask0) {
+         GLint bufIndex = _mesa_ffs(destMask0) - 1;
+         if (fb->_ColorDrawBufferIndexes[count] != bufIndex) {
+            fb->_ColorDrawBufferIndexes[count] = bufIndex;
+            newState = GL_TRUE;
          }
+         count++;
+         destMask0 &= ~(1 << bufIndex);
       }
       fb->ColorDrawBuffer[0] = buffers[0];
-      fb->_NumColorDrawBuffers = count;
+      if (fb->_NumColorDrawBuffers != count) {
+         fb->_NumColorDrawBuffers = count;
+         newState = GL_TRUE;
+      }
    }
    else {
       GLuint buf, count = 0;
       for (buf = 0; buf < n; buf++ ) {
          if (destMask[buf]) {
-            fb->_ColorDrawBufferIndexes[buf] = _mesa_ffs(destMask[buf]) - 1;
+            GLint bufIndex = _mesa_ffs(destMask[buf]) - 1;
+            /* only one bit should be set in the destMask[buf] field */
+            ASSERT(_mesa_bitcount(destMask[buf]) == 1);
+            if (fb->_ColorDrawBufferIndexes[buf] != bufIndex) {
+               fb->_ColorDrawBufferIndexes[buf] = bufIndex;
+               newState = GL_TRUE;
+            }
             fb->ColorDrawBuffer[buf] = buffers[buf];
             count = buf + 1;
          }
          else {
-            fb->_ColorDrawBufferIndexes[buf] = -1;
+            if (fb->_ColorDrawBufferIndexes[buf] != -1) {
+               fb->_ColorDrawBufferIndexes[buf] = -1;
+               newState = GL_TRUE;
+            }
          }
       }
       /* set remaining outputs to -1 (GL_NONE) */
       while (buf < ctx->Const.MaxDrawBuffers) {
-         fb->_ColorDrawBufferIndexes[buf] = -1;
+         if (fb->_ColorDrawBufferIndexes[buf] != -1) {
+            fb->_ColorDrawBufferIndexes[buf] = -1;
+            newState = GL_TRUE;
+         }
          fb->ColorDrawBuffer[buf] = GL_NONE;
          buf++;
       }
@@ -413,11 +434,15 @@ _mesa_drawbuffers(GLcontext *ctx, GLuint n, const GLenum *buffers,
       /* also set context drawbuffer state */
       GLuint buf;
       for (buf = 0; buf < ctx->Const.MaxDrawBuffers; buf++) {
-         ctx->Color.DrawBuffer[buf] = fb->ColorDrawBuffer[buf];
+         if (ctx->Color.DrawBuffer[buf] != fb->ColorDrawBuffer[buf]) {
+            ctx->Color.DrawBuffer[buf] = fb->ColorDrawBuffer[buf];
+            newState = GL_TRUE;
+         }
       }
    }
 
-   ctx->NewState |= _NEW_BUFFERS;
+   if (newState)
+      FLUSH_VERTICES(ctx, _NEW_BUFFERS);
 }
 
 
index 63388f42ee46bdb19c6e0f8b9657b342df0694b6..4a3c11165863645262ca3c14999c34d986336c9e 100644 (file)
@@ -34,6 +34,7 @@
 #include "clear.h"
 #include "context.h"
 #include "colormac.h"
+#include "enums.h"
 #include "state.h"
 
 
@@ -182,3 +183,346 @@ _mesa_Clear( GLbitfield mask )
       ctx->Driver.Clear(ctx, bufferMask);
    }
 }
+
+
+/** Returned by make_color_buffer_mask() for errors */
+#define INVALID_MASK ~0x0
+
+
+/**
+ * Convert the glClearBuffer 'drawbuffer' parameter into a bitmask of
+ * BUFFER_BIT_x values.
+ * Return INVALID_MASK if the drawbuffer value is invalid.
+ */
+static GLbitfield
+make_color_buffer_mask(GLcontext *ctx, GLint drawbuffer)
+{
+   const struct gl_renderbuffer_attachment *att = ctx->DrawBuffer->Attachment;
+   GLbitfield mask = 0x0;
+
+   switch (drawbuffer) {
+   case GL_FRONT:
+      if (att[BUFFER_FRONT_LEFT].Renderbuffer)
+         mask |= BUFFER_BIT_FRONT_LEFT;
+      if (att[BUFFER_FRONT_RIGHT].Renderbuffer)
+         mask |= BUFFER_BIT_FRONT_RIGHT;
+      break;
+   case GL_BACK:
+      if (att[BUFFER_BACK_LEFT].Renderbuffer)
+         mask |= BUFFER_BIT_BACK_LEFT;
+      if (att[BUFFER_BACK_RIGHT].Renderbuffer)
+         mask |= BUFFER_BIT_BACK_RIGHT;
+      break;
+   case GL_LEFT:
+      if (att[BUFFER_FRONT_LEFT].Renderbuffer)
+         mask |= BUFFER_BIT_FRONT_LEFT;
+      if (att[BUFFER_BACK_LEFT].Renderbuffer)
+         mask |= BUFFER_BIT_BACK_LEFT;
+      break;
+   case GL_RIGHT:
+      if (att[BUFFER_FRONT_RIGHT].Renderbuffer)
+         mask |= BUFFER_BIT_FRONT_RIGHT;
+      if (att[BUFFER_BACK_RIGHT].Renderbuffer)
+         mask |= BUFFER_BIT_BACK_RIGHT;
+      break;
+   case GL_FRONT_AND_BACK:
+      if (att[BUFFER_FRONT_LEFT].Renderbuffer)
+         mask |= BUFFER_BIT_FRONT_LEFT;
+      if (att[BUFFER_BACK_LEFT].Renderbuffer)
+         mask |= BUFFER_BIT_BACK_LEFT;
+      if (att[BUFFER_FRONT_RIGHT].Renderbuffer)
+         mask |= BUFFER_BIT_FRONT_RIGHT;
+      if (att[BUFFER_BACK_RIGHT].Renderbuffer)
+         mask |= BUFFER_BIT_BACK_RIGHT;
+      break;
+   default:
+      if (drawbuffer < 0 || drawbuffer >= ctx->Const.MaxDrawBuffers) {
+         mask = INVALID_MASK;
+      }
+      else if (att[BUFFER_COLOR0 + drawbuffer].Renderbuffer) {
+         mask |= (BUFFER_BIT_COLOR0 << drawbuffer);
+      }
+   }
+
+   return mask;
+}
+
+
+
+/**
+ * New in GL 3.0
+ * Clear signed integer color buffer or stencil buffer (not depth).
+ */
+void GLAPIENTRY
+_mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+   FLUSH_CURRENT(ctx, 0);
+
+   if (!ctx->DrawBuffer->Visual.rgbMode) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glClearBufferiv()");
+      return;
+   }
+
+   if (ctx->NewState) {
+      _mesa_update_state( ctx );
+   }
+
+   switch (buffer) {
+   case GL_STENCIL:
+      if (drawbuffer != 0) {
+         _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferiv(drawbuffer=%d)",
+                     drawbuffer);
+         return;
+      }
+      else {
+         /* Save current stencil clear value, set to 'value', do the
+          * stencil clear and restore the clear value.
+          * XXX in the future we may have a new ctx->Driver.ClearBuffer()
+          * hook instead.
+          */
+         const GLuint clearSave = ctx->Stencil.Clear;
+         ctx->Stencil.Clear = *value;
+         if (ctx->Driver.ClearStencil)
+            ctx->Driver.ClearStencil(ctx, *value);
+         ctx->Driver.Clear(ctx, BUFFER_BIT_STENCIL);
+         ctx->Stencil.Clear = clearSave;
+         if (ctx->Driver.ClearStencil)
+            ctx->Driver.ClearStencil(ctx, clearSave);
+      }
+      break;
+   case GL_COLOR:
+      {
+         const GLbitfield mask = make_color_buffer_mask(ctx, drawbuffer);
+         if (mask == INVALID_MASK) {
+            _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferiv(drawbuffer=%d)",
+                        drawbuffer);
+            return;
+         }
+         else if (mask) {
+            /* XXX note: we're putting the integer clear values into the
+             * floating point state var.  This will not always work.  We'll
+             * need a new ctx->Driver.ClearBuffer() hook....
+             */
+            GLfloat clearSave[4];
+            /* save color */
+            COPY_4V(clearSave, ctx->Color.ClearColor);
+            /* set color */
+            COPY_4V(ctx->Color.ClearColor, value);
+            if (ctx->Driver.ClearColor)
+               ctx->Driver.ClearColor(ctx, ctx->Color.ClearColor);
+            /* clear buffer(s) */
+            ctx->Driver.Clear(ctx, mask);
+            /* restore color */
+            COPY_4V(ctx->Color.ClearColor, clearSave);
+            if (ctx->Driver.ClearColor)
+               ctx->Driver.ClearColor(ctx, clearSave);
+         }
+      }
+      break;
+   default:
+      _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferiv(buffer=%s)",
+                  _mesa_lookup_enum_by_nr(buffer));
+      return;
+   }
+}
+
+
+/**
+ * New in GL 3.0
+ * Clear unsigned integer color buffer (not depth, not stencil).
+ */
+void GLAPIENTRY
+_mesa_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+   FLUSH_CURRENT(ctx, 0);
+
+   if (!ctx->DrawBuffer->Visual.rgbMode) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glClearBufferuiv()");
+      return;
+   }
+
+   if (ctx->NewState) {
+      _mesa_update_state( ctx );
+   }
+
+   switch (buffer) {
+   case GL_COLOR:
+      {
+         const GLbitfield mask = make_color_buffer_mask(ctx, drawbuffer);
+         if (mask == INVALID_MASK) {
+            _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferiv(drawbuffer=%d)",
+                        drawbuffer);
+            return;
+         }
+         else if (mask) {
+            /* XXX note: we're putting the uint clear values into the
+             * floating point state var.  This will not always work.  We'll
+             * need a new ctx->Driver.ClearBuffer() hook....
+             */
+            GLfloat clearSave[4];
+            /* save color */
+            COPY_4V(clearSave, ctx->Color.ClearColor);
+            /* set color */
+            COPY_4V(ctx->Color.ClearColor, value);
+            if (ctx->Driver.ClearColor)
+               ctx->Driver.ClearColor(ctx, ctx->Color.ClearColor);
+            /* clear buffer(s) */
+            ctx->Driver.Clear(ctx, mask);
+            /* restore color */
+            COPY_4V(ctx->Color.ClearColor, clearSave);
+            if (ctx->Driver.ClearColor)
+               ctx->Driver.ClearColor(ctx, clearSave);
+         }
+      }
+      break;
+   default:
+      _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferuiv(buffer=%s)",
+                  _mesa_lookup_enum_by_nr(buffer));
+      return;
+   }
+}
+
+
+/**
+ * New in GL 3.0
+ * Clear fixed-pt or float color buffer or depth buffer (not stencil).
+ */
+void GLAPIENTRY
+_mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+   FLUSH_CURRENT(ctx, 0);
+
+   if (!ctx->DrawBuffer->Visual.rgbMode) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glClearBufferfv()");
+      return;
+   }
+
+   if (ctx->NewState) {
+      _mesa_update_state( ctx );
+   }
+
+   switch (buffer) {
+   case GL_DEPTH:
+      if (drawbuffer != 0) {
+         _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferfv(drawbuffer=%d)",
+                     drawbuffer);
+         return;
+      }
+      else {
+         /* Save current depth clear value, set to 'value', do the
+          * depth clear and restore the clear value.
+          * XXX in the future we may have a new ctx->Driver.ClearBuffer()
+          * hook instead.
+          */
+         const GLfloat clearSave = ctx->Depth.Clear;
+         ctx->Depth.Clear = *value;
+         if (ctx->Driver.ClearDepth)
+            ctx->Driver.ClearDepth(ctx, *value);
+         ctx->Driver.Clear(ctx, BUFFER_BIT_DEPTH);
+         ctx->Depth.Clear = clearSave;
+         if (ctx->Driver.ClearDepth)
+            ctx->Driver.ClearDepth(ctx, clearSave);
+      }
+      /* clear depth buffer to value */
+      break;
+   case GL_COLOR:
+      {
+         const GLbitfield mask = make_color_buffer_mask(ctx, drawbuffer);
+         if (mask == INVALID_MASK) {
+            _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferfv(drawbuffer=%d)",
+                        drawbuffer);
+            return;
+         }
+         else if (mask) {
+            GLfloat clearSave[4];
+            /* save color */
+            COPY_4V(clearSave, ctx->Color.ClearColor);
+            /* set color */
+            COPY_4V(ctx->Color.ClearColor, value);
+            if (ctx->Driver.ClearColor)
+               ctx->Driver.ClearColor(ctx, ctx->Color.ClearColor);
+            /* clear buffer(s) */
+            ctx->Driver.Clear(ctx, mask);
+            /* restore color */
+            COPY_4V(ctx->Color.ClearColor, clearSave);
+            if (ctx->Driver.ClearColor)
+               ctx->Driver.ClearColor(ctx, clearSave);
+         }
+      }
+      break;
+   default:
+      _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferfv(buffer=%s)",
+                  _mesa_lookup_enum_by_nr(buffer));
+      return;
+   }
+}
+
+
+/**
+ * New in GL 3.0
+ * Clear depth/stencil buffer only.
+ */
+void GLAPIENTRY
+_mesa_ClearBufferfi(GLenum buffer, GLint drawbuffer,
+                    GLfloat depth, GLint stencil)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+   FLUSH_CURRENT(ctx, 0);
+
+   if (!ctx->DrawBuffer->Visual.rgbMode) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glClearBufferfi()");
+      return;
+   }
+
+   if (buffer != GL_DEPTH_STENCIL) {
+      _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferfi(buffer=%s)",
+                  _mesa_lookup_enum_by_nr(buffer));
+      return;
+   }
+
+   if (drawbuffer != 0) {
+      _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferfi(drawbuffer=%d)",
+                  drawbuffer);
+      return;
+   }
+
+   if (ctx->NewState) {
+      _mesa_update_state( ctx );
+   }
+
+   {
+      /* save current clear values */
+      const GLfloat clearDepthSave = ctx->Depth.Clear;
+      const GLuint clearStencilSave = ctx->Stencil.Clear;
+
+      /* set new clear values */
+      ctx->Depth.Clear = depth;
+      ctx->Stencil.Clear = stencil;
+      if (ctx->Driver.ClearDepth)
+         ctx->Driver.ClearDepth(ctx, depth);
+      if (ctx->Driver.ClearStencil)
+         ctx->Driver.ClearStencil(ctx, stencil);
+
+      /* clear buffers */
+      ctx->Driver.Clear(ctx, BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL);
+
+      /* restore */
+      ctx->Depth.Clear = clearDepthSave;
+      ctx->Stencil.Clear = clearStencilSave;
+      if (ctx->Driver.ClearDepth)
+         ctx->Driver.ClearDepth(ctx, clearDepthSave);
+      if (ctx->Driver.ClearStencil)
+         ctx->Driver.ClearStencil(ctx, clearStencilSave);
+   }
+}
index 9a54ba14bccdb04d702fa75f7965cee0f21b928c..4c78eeda48823f8734a26ec0bf5242d3f7f56f49 100644 (file)
@@ -41,4 +41,17 @@ extern void GLAPIENTRY
 _mesa_Clear( GLbitfield mask );
 
 
+extern void GLAPIENTRY
+_mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value);
+
+extern void GLAPIENTRY
+_mesa_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value);
+
+extern void GLAPIENTRY
+_mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value);
+
+extern void GLAPIENTRY
+_mesa_ClearBufferfi(GLenum buffer, GLint drawbuffer,
+                    GLfloat depth, GLint stencil);
+
 #endif
index 815624ee5080c5f1101a702f724e2d2015db8a3a..905f4e2283733a5c7d416d2c0df9dcf27950ea3b 100644 (file)
  */
 #define UNCLAMPED_FLOAT_TO_RGB_CHAN(dst, f)    \
 do {                                           \
-   UNCLAMPED_FLOAT_TO_CHAN(dst[0], f[0]);      \
-   UNCLAMPED_FLOAT_TO_CHAN(dst[1], f[1]);      \
-   UNCLAMPED_FLOAT_TO_CHAN(dst[2], f[2]);      \
+   UNCLAMPED_FLOAT_TO_CHAN((dst)[0], (f)[0]);  \
+   UNCLAMPED_FLOAT_TO_CHAN((dst)[1], (f)[1]);  \
+   UNCLAMPED_FLOAT_TO_CHAN((dst)[2], (f)[2]);  \
 } while (0)
 
 
@@ -156,10 +156,10 @@ do {                                              \
  */
 #define UNCLAMPED_FLOAT_TO_RGBA_CHAN(dst, f)   \
 do {                                           \
-   UNCLAMPED_FLOAT_TO_CHAN(dst[0], f[0]);      \
-   UNCLAMPED_FLOAT_TO_CHAN(dst[1], f[1]);      \
-   UNCLAMPED_FLOAT_TO_CHAN(dst[2], f[2]);      \
-   UNCLAMPED_FLOAT_TO_CHAN(dst[3], f[3]);      \
+   UNCLAMPED_FLOAT_TO_CHAN((dst)[0], (f)[0]);  \
+   UNCLAMPED_FLOAT_TO_CHAN((dst)[1], (f)[1]);  \
+   UNCLAMPED_FLOAT_TO_CHAN((dst)[2], (f)[2]);  \
+   UNCLAMPED_FLOAT_TO_CHAN((dst)[3], (f)[3]);  \
 } while (0)
 
 
@@ -210,6 +210,12 @@ do {                                               \
 #define PACK_COLOR_88_REV( L, A )                                      \
    (((A) << 8) | (L))
 
+#define PACK_COLOR_1616( L, A )                                                \
+   (((L) << 16) | (A))
+
+#define PACK_COLOR_1616_REV( L, A )                                    \
+   (((A) << 16) | (L))
+
 #define PACK_COLOR_332( R, G, B )                                      \
    (((R) & 0xe0) | (((G) & 0xe0) >> 3) | (((B) & 0xc0) >> 6))
 
index 380663ec97107222afad35343515cf0c1ea4d053..4eb249b4af13df8b1a12b748e1bb17034844702c 100644 (file)
@@ -234,7 +234,12 @@ extern "C" {
 #elif defined(__APPLE__)
 #include <CoreFoundation/CFByteOrder.h>
 #define CPU_TO_LE32( x )       CFSwapInt32HostToLittle( x )
-#else /*__linux__ __APPLE__*/
+#elif (defined(_AIX) || defined(__blrts))
+#define CPU_TO_LE32( x )        x = ((x & 0x000000ff) << 24) | \
+                                    ((x & 0x0000ff00) <<  8) | \
+                                    ((x & 0x00ff0000) >>  8) | \
+                                    ((x & 0xff000000) >> 24);
+#else /*__linux__ */
 #include <sys/endian.h>
 #define CPU_TO_LE32( x )       bswap32( x )
 #endif /*__linux__*/
diff --git a/src/mesa/main/condrender.c b/src/mesa/main/condrender.c
new file mode 100644 (file)
index 0000000..8d9a91d
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+ * Mesa 3-D graphics library
+ * Version:  7.8
+ *
+ * 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"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ */
+
+/**
+ * \file condrender.c
+ * Conditional rendering functions
+ *
+ * \author Brian Paul
+ */
+
+#include "glheader.h"
+#include "condrender.h"
+#include "enums.h"
+#include "queryobj.h"
+
+
+void GLAPIENTRY
+_mesa_BeginConditionalRender(GLuint queryId, GLenum mode)
+{
+   struct gl_query_object *q;
+   GET_CURRENT_CONTEXT(ctx);
+
+   if (!ctx->Extensions.NV_conditional_render || ctx->Query.CondRenderQuery) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glBeginConditionalRender()");
+      return;
+   }
+
+   ASSERT(ctx->Query.CondRenderMode == GL_NONE);
+
+   switch (mode) {
+   case GL_QUERY_WAIT:
+   case GL_QUERY_NO_WAIT:
+   case GL_QUERY_BY_REGION_WAIT:
+   case GL_QUERY_BY_REGION_NO_WAIT:
+      /* OK */
+      break;
+   default:
+      _mesa_error(ctx, GL_INVALID_ENUM, "glBeginConditionalRender(mode=%s)",
+                  _mesa_lookup_enum_by_nr(mode));
+      return;
+   }
+
+   q = _mesa_lookup_query_object(ctx, queryId);
+   if (!q) {
+      _mesa_error(ctx, GL_INVALID_VALUE,
+                  "glBeginConditionalRender(bad queryId=%u)", queryId);
+      return;
+   }
+   ASSERT(q->Id == queryId);
+
+   if (q->Target != GL_SAMPLES_PASSED) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glBeginConditionalRender()");
+      return;
+   }
+
+   ctx->Query.CondRenderQuery = q;
+   ctx->Query.CondRenderMode = mode;
+
+   if (ctx->Driver.BeginConditionalRender)
+      ctx->Driver.BeginConditionalRender(ctx, q, mode);
+}
+
+
+void APIENTRY
+_mesa_EndConditionalRender(void)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   FLUSH_VERTICES(ctx, 0x0);
+
+   if (!ctx->Extensions.NV_conditional_render || !ctx->Query.CondRenderQuery) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glEndConditionalRender()");
+      return;
+   }
+
+   if (ctx->Driver.EndConditionalRender)
+      ctx->Driver.EndConditionalRender(ctx, ctx->Query.CondRenderQuery);
+
+   ctx->Query.CondRenderQuery = NULL;
+   ctx->Query.CondRenderMode = GL_NONE;
+}
+
+
+/**
+ * This function is called by software rendering commands (all point,
+ * line triangle drawing, glClear, glDrawPixels, glCopyPixels, and
+ * glBitmap, glBlitFramebuffer) to determine if subsequent drawing
+ * commands should be
+ * executed or discarded depending on the current conditional
+ * rendering state.  Ideally, this check would be implemented by the
+ * GPU when doing hardware rendering.  XXX should this function be
+ * called via a new driver hook?
+ *
+ * \return GL_TRUE if we should render, GL_FALSE if we should discard
+ */
+GLboolean
+_mesa_check_conditional_render(GLcontext *ctx)
+{
+   struct gl_query_object *q = ctx->Query.CondRenderQuery;
+
+   if (!q) {
+      /* no query in progress - draw normally */
+      return GL_TRUE;
+   }
+
+   switch (ctx->Query.CondRenderMode) {
+   case GL_QUERY_BY_REGION_WAIT:
+      /* fall-through */
+   case GL_QUERY_WAIT:
+      if (!q->Ready) {
+         ctx->Driver.WaitQuery(ctx, q);
+      }
+      return q->Result > 0;
+   case GL_QUERY_BY_REGION_NO_WAIT:
+      /* fall-through */
+   case GL_QUERY_NO_WAIT:
+      return q->Ready ? (q->Result > 0) : GL_TRUE;
+   default:
+      _mesa_problem(ctx, "Bad cond render mode %s in "
+                    " _mesa_check_conditional_render()",
+                    _mesa_lookup_enum_by_nr(ctx->Query.CondRenderMode));
+      return GL_TRUE;
+   }
+}
diff --git a/src/mesa/main/condrender.h b/src/mesa/main/condrender.h
new file mode 100644 (file)
index 0000000..d55e980
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Mesa 3-D graphics library
+ * Version:  7.8
+ *
+ * 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"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ */
+
+#ifndef CONDRENDER_H
+#define CONDRENDER_H
+
+
+#include "glheader.h"
+#include "context.h"
+
+
+extern void GLAPIENTRY
+_mesa_BeginConditionalRender(GLuint queryId, GLenum mode);
+
+extern void APIENTRY
+_mesa_EndConditionalRender(void);
+
+extern GLboolean
+_mesa_check_conditional_render(GLcontext *ctx);
+
+
+#endif /* CONDRENDER_H */
index 8a09efdb539ed5a69ec1ea59e44e72a67398b24c..2eac1cc2ed9bfcc3eeee501961011ca901cd6c80 100644 (file)
 #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
+#define MAX_PROGRAM_OUTPUTS            64
 /*@}*/
 
 /** For GL_ARB_vertex_program */
 /*@{*/
 #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
+#define MAX_COMBINED_TEXTURE_IMAGE_UNITS (MAX_VERTEX_TEXTURE_IMAGE_UNITS + \
+                                         MAX_TEXTURE_IMAGE_UNITS)
 /*@}*/
 
 
index ae91bf5f38516f5c5a92270f7aa675eec2cfa7ad..320c59068cc55562bb56490c87ebb57bc9df2c04 100644 (file)
 #include "syncobj.h"
 #endif
 #include "rastpos.h"
+#include "remap.h"
 #include "scissor.h"
 #include "shared.h"
 #include "simple_list.h"
 #include "state.h"
 #include "stencil.h"
-#include "texcompress.h"
+#include "texcompress_s3tc.h"
 #include "teximage.h"
 #include "texobj.h"
 #include "texstate.h"
 #include "viewport.h"
 #include "vtxfmt.h"
 #include "glapi/glthread.h"
-#include "glapi/glapioffsets.h"
 #include "glapi/glapitable.h"
 #include "shader/program.h"
 #include "shader/prog_print.h"
@@ -173,6 +173,8 @@ GLfloat _mesa_ubyte_to_float_color_tab[256];
 void
 _mesa_notifySwapBuffers(__GLcontext *ctx)
 {
+   if (MESA_VERBOSE & VERBOSE_SWAPBUFFERS)
+      _mesa_debug(ctx, "SwapBuffers\n");
    FLUSH_CURRENT( ctx, 0 );
    if (ctx->Driver.Flush) {
       ctx->Driver.Flush(ctx);
@@ -405,6 +407,8 @@ one_time_init( GLcontext *ctx )
 
       _mesa_get_cpu_features();
 
+      _mesa_init_remap_table();
+
       _mesa_init_sqrt_table();
 
       for (i = 0; i < 256; i++) {
@@ -560,10 +564,6 @@ _mesa_init_constants(GLcontext *ctx)
    /* GL_ARB_draw_buffers */
    ctx->Const.MaxDrawBuffers = MAX_DRAW_BUFFERS;
 
-   /* GL_OES_read_format */
-   ctx->Const.ColorReadFormat = GL_RGBA;
-   ctx->Const.ColorReadType = GL_UNSIGNED_BYTE;
-
 #if FEATURE_EXT_framebuffer_object
    ctx->Const.MaxColorAttachments = MAX_COLOR_ATTACHMENTS;
    ctx->Const.MaxRenderbufferSize = MAX_WIDTH;
@@ -571,6 +571,7 @@ _mesa_init_constants(GLcontext *ctx)
 
 #if FEATURE_ARB_vertex_shader
    ctx->Const.MaxVertexTextureImageUnits = MAX_VERTEX_TEXTURE_IMAGE_UNITS;
+   ctx->Const.MaxCombinedTextureImageUnits = MAX_COMBINED_TEXTURE_IMAGE_UNITS;
    ctx->Const.MaxVarying = MAX_VARYING;
 #endif
 
@@ -597,9 +598,11 @@ _mesa_init_constants(GLcontext *ctx)
    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);
+   /* check that we don't exceed the size of various bitfields */
+   ASSERT(VERT_RESULT_MAX <=
+         (8 * sizeof(ctx->VertexProgram._Current->Base.OutputsWritten)));
+   ASSERT(FRAG_ATTRIB_MAX <=
+         (8 * sizeof(ctx->FragmentProgram._Current->Base.InputsRead)));
 }
 
 
@@ -699,12 +702,7 @@ init_attrib_groups(GLcontext *ctx)
    if (!_mesa_init_texture( ctx ))
       return GL_FALSE;
 
-#if FEATURE_texture_s3tc
    _mesa_init_texture_s3tc( ctx );
-#endif
-#if FEATURE_texture_fxt1
-   _mesa_init_texture_fxt1( ctx );
-#endif
 
    /* Miscellaneous */
    ctx->NewState = _NEW_ALL;
@@ -1011,9 +1009,15 @@ _mesa_free_context_data( GLcontext *ctx )
       _mesa_free_shared_state( ctx, ctx->Shared );
    }
 
+   /* needs to be after freeing shared state */
+   _mesa_free_display_list_data(ctx);
+
    if (ctx->Extensions.String)
       _mesa_free((void *) ctx->Extensions.String);
 
+   if (ctx->VersionString)
+      _mesa_free(ctx->VersionString);
+
    /* unbind the context if it's currently bound */
    if (ctx == _mesa_get_current_context()) {
       _mesa_make_current(NULL, NULL, NULL);
@@ -1373,6 +1377,8 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer,
       }
 
       if (newCtx->FirstTimeCurrent) {
+         _mesa_compute_version(newCtx);
+
          check_context_limits(newCtx);
 
          /* We can use this to help debug user's problems.  Tell them to set
@@ -1499,6 +1505,33 @@ _mesa_record_error(GLcontext *ctx, GLenum error)
 }
 
 
+/**
+ * Flush commands and wait for completion.
+ */
+void
+_mesa_finish(GLcontext *ctx)
+{
+   FLUSH_CURRENT( ctx, 0 );
+   if (ctx->Driver.Finish) {
+      ctx->Driver.Finish(ctx);
+   }
+}
+
+
+/**
+ * Flush commands.
+ */
+void
+_mesa_flush(GLcontext *ctx)
+{
+   FLUSH_CURRENT( ctx, 0 );
+   if (ctx->Driver.Flush) {
+      ctx->Driver.Flush(ctx);
+   }
+}
+
+
+
 /**
  * Execute glFinish().
  *
@@ -1510,10 +1543,7 @@ _mesa_Finish(void)
 {
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
-   FLUSH_CURRENT( ctx, 0 );
-   if (ctx->Driver.Finish) {
-      ctx->Driver.Finish(ctx);
-   }
+   _mesa_finish(ctx);
 }
 
 
@@ -1528,10 +1558,7 @@ _mesa_Flush(void)
 {
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
-   FLUSH_CURRENT( ctx, 0 );
-   if (ctx->Driver.Flush) {
-      ctx->Driver.Flush(ctx);
-   }
+   _mesa_flush(ctx);
 }
 
 
index 5587695fa0b5e52c35a035170fd37befc8be4540..c3be1063f86ff16c599e8e55726f41a13f34a740 100644 (file)
@@ -170,6 +170,14 @@ _mesa_valid_to_render(GLcontext *ctx, const char *where);
 extern void
 _mesa_record_error( GLcontext *ctx, GLenum error );
 
+
+extern void
+_mesa_finish(GLcontext *ctx);
+
+extern void
+_mesa_flush(GLcontext *ctx);
+
+
 extern void GLAPIENTRY
 _mesa_Finish( void );
 
index ce5e158626616b0573671a76476775f22beec131..e99e87d9059ce6251b88e4335b376cc4aed43021 100644 (file)
@@ -182,10 +182,10 @@ struct dd_function_table {
     * 
     * This is called by the \c _mesa_store_tex[sub]image[123]d() fallback
     * functions.  The driver should examine \p internalFormat and return a
-    * pointer to an appropriate gl_texture_format.
+    * gl_format value.
     */
-   const struct gl_texture_format *(*ChooseTextureFormat)( GLcontext *ctx,
-                      GLint internalFormat, GLenum srcFormat, GLenum srcType );
+   GLuint (*ChooseTextureFormat)( GLcontext *ctx, GLint internalFormat,
+                                     GLenum srcFormat, GLenum srcType );
 
    /**
     * Called by glTexImage1D().
@@ -475,13 +475,6 @@ struct dd_function_table {
                                  struct gl_texture_object *texObj,
                                  struct gl_texture_image *texImage);
 
-   /**
-    * Called to query number of bytes of storage needed to store the
-    * specified compressed texture.
-    */
-   GLuint (*CompressedTextureSize)( GLcontext *ctx, GLsizei width,
-                                    GLsizei height, GLsizei depth,
-                                    GLenum format );
    /*@}*/
 
    /**
@@ -544,17 +537,6 @@ struct dd_function_table {
    GLboolean (*IsTextureResident)( GLcontext *ctx,
                                    struct gl_texture_object *t );
 
-   /**
-    * Called by glPrioritizeTextures().
-    */
-   void (*PrioritizeTexture)( GLcontext *ctx,  struct gl_texture_object *t,
-                              GLclampf priority );
-
-   /**
-    * Called by glActiveTextureARB() to set current texture unit.
-    */
-   void (*ActiveTexture)( GLcontext *ctx, GLuint texUnitNumber );
-
    /**
     * Called when the texture's color lookup table is changed.
     * 
@@ -643,6 +625,8 @@ struct dd_function_table {
    /** Enable and disable writing of frame buffer color components */
    void (*ColorMask)(GLcontext *ctx, GLboolean rmask, GLboolean gmask,
                      GLboolean bmask, GLboolean amask );
+   void (*ColorMaskIndexed)(GLcontext *ctx, GLuint buf, GLboolean rmask,
+                            GLboolean gmask, GLboolean bmask, GLboolean amask);
    /** Cause a material color to track the current color */
    void (*ColorMaterial)(GLcontext *ctx, GLenum face, GLenum mode);
    /** Specify whether front- or back-facing facets can be culled */
@@ -717,40 +701,11 @@ struct dd_function_table {
    void (*TexParameter)(GLcontext *ctx, GLenum target,
                         struct gl_texture_object *texObj,
                         GLenum pname, const GLfloat *params);
-   void (*TextureMatrix)(GLcontext *ctx, GLuint unit, const GLmatrix *mat);
    /** Set the viewport */
    void (*Viewport)(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
    /*@}*/
 
 
-   /**
-    * \name Vertex array functions
-    *
-    * Called by the corresponding OpenGL functions.
-    */
-   /*@{*/
-   void (*VertexPointer)(GLcontext *ctx, GLint size, GLenum type,
-                        GLsizei stride, const GLvoid *ptr);
-   void (*NormalPointer)(GLcontext *ctx, GLenum type,
-                        GLsizei stride, const GLvoid *ptr);
-   void (*ColorPointer)(GLcontext *ctx, GLint size, GLenum type,
-                       GLsizei stride, const GLvoid *ptr);
-   void (*FogCoordPointer)(GLcontext *ctx, GLenum type,
-                          GLsizei stride, const GLvoid *ptr);
-   void (*IndexPointer)(GLcontext *ctx, GLenum type,
-                       GLsizei stride, const GLvoid *ptr);
-   void (*SecondaryColorPointer)(GLcontext *ctx, GLint size, GLenum type,
-                                GLsizei stride, const GLvoid *ptr);
-   void (*TexCoordPointer)(GLcontext *ctx, GLint size, GLenum type,
-                          GLsizei stride, const GLvoid *ptr);
-   void (*EdgeFlagPointer)(GLcontext *ctx, GLsizei stride, const GLvoid *ptr);
-   void (*VertexAttribPointer)(GLcontext *ctx, GLuint index, GLint size,
-                               GLenum type, GLsizei stride, const GLvoid *ptr);
-   void (*LockArraysEXT)( GLcontext *ctx, GLint first, GLsizei count );
-   void (*UnlockArraysEXT)( GLcontext *ctx );
-   /*@}*/
-
-
    /** 
     * \name State-query functions
     *
@@ -808,13 +763,13 @@ struct dd_function_table {
 
    /* May return NULL if MESA_MAP_NOWAIT_BIT is set in access:
     */
-   void * (*MapBufferRange)( GLcontext *ctx, GLenum target,
-                             GLintptr offset, GLsizeiptr length, GLbitfield access,
+   void * (*MapBufferRange)( GLcontext *ctx, GLenum target, GLintptr offset,
+                             GLsizeiptr length, GLbitfield access,
                              struct gl_buffer_object *obj);
 
-   void (*FlushMappedBufferRange) (GLcontext *ctx, GLenum target, 
-                                   GLintptr offset, GLsizeiptr length,
-                                   struct gl_buffer_object *obj);
+   void (*FlushMappedBufferRange)(GLcontext *ctx, GLenum target, 
+                                  GLintptr offset, GLsizeiptr length,
+                                  struct gl_buffer_object *obj);
 
    GLboolean (*UnmapBuffer)( GLcontext *ctx, GLenum target,
                             struct gl_buffer_object *obj );
@@ -829,7 +784,8 @@ struct dd_function_table {
    struct gl_framebuffer * (*NewFramebuffer)(GLcontext *ctx, GLuint name);
    struct gl_renderbuffer * (*NewRenderbuffer)(GLcontext *ctx, GLuint name);
    void (*BindFramebuffer)(GLcontext *ctx, GLenum target,
-                           struct gl_framebuffer *fb, struct gl_framebuffer *fbread);
+                           struct gl_framebuffer *drawFb,
+                           struct gl_framebuffer *readFb);
    void (*FramebufferRenderbuffer)(GLcontext *ctx, 
                                    struct gl_framebuffer *fb,
                                    GLenum attachment,
@@ -1060,6 +1016,11 @@ struct dd_function_table {
                          GLbitfield, GLuint64);
    /*@}*/
 #endif
+
+   /** GL_NV_conditional_render */
+   void (*BeginConditionalRender)(GLcontext *ctx, struct gl_query_object *q,
+                                  GLenum mode);
+   void (*EndConditionalRender)(GLcontext *ctx, struct gl_query_object *q);
 };
 
 
index 8492c8561d422fec5d1c428b415737019559ec83..a42113edcacac962204ad3317705dfbccc1cd7cf 100644 (file)
@@ -27,6 +27,8 @@
 #include "attrib.h"
 #include "colormac.h"
 #include "context.h"
+#include "enums.h"
+#include "formats.h"
 #include "hash.h"
 #include "imports.h"
 #include "debug.h"
@@ -35,7 +37,6 @@
 #include "readpix.h"
 #include "texgetimage.h"
 #include "texobj.h"
-#include "texformat.h"
 
 
 /**
@@ -57,6 +58,31 @@ const char *_mesa_prim_name[GL_POLYGON+4] = {
    "unknown state"
 };
 
+
+static const char *
+tex_target_name(GLenum tgt)
+{
+   static const struct {
+      GLenum target;
+      const char *name;
+   } tex_targets[] = {
+      { GL_TEXTURE_1D, "GL_TEXTURE_1D" },
+      { GL_TEXTURE_2D, "GL_TEXTURE_2D" },
+      { GL_TEXTURE_3D, "GL_TEXTURE_3D" },
+      { GL_TEXTURE_CUBE_MAP, "GL_TEXTURE_CUBE_MAP" },
+      { GL_TEXTURE_RECTANGLE, "GL_TEXTURE_RECTANGLE" },
+      { GL_TEXTURE_1D_ARRAY_EXT, "GL_TEXTURE_1D_ARRAY" },
+      { GL_TEXTURE_2D_ARRAY_EXT, "GL_TEXTURE_2D_ARRAY" }
+   };
+   GLuint i;
+   for (i = 0; i < Elements(tex_targets); i++) {
+      if (tex_targets[i].target == tgt)
+         return tex_targets[i].name;
+   }
+   return "UNKNOWN TEX TARGET";
+}
+
+
 void
 _mesa_print_state( const char *msg, GLuint state )
 {
@@ -167,14 +193,16 @@ static void add_debug_flags( const char *debug )
    static const struct debug_option debug_opt[] = {
       { "varray",    VERBOSE_VARRAY },
       { "tex",       VERBOSE_TEXTURE },
-      { "imm",       VERBOSE_IMMEDIATE },
+      { "mat",       VERBOSE_MATERIAL },
       { "pipe",      VERBOSE_PIPELINE },
       { "driver",    VERBOSE_DRIVER },
       { "state",     VERBOSE_STATE },
       { "api",       VERBOSE_API },
       { "list",      VERBOSE_DISPLAY_LIST },
       { "lighting",  VERBOSE_LIGHTING },
-      { "disassem",  VERBOSE_DISASSEM }
+      { "disassem",  VERBOSE_DISASSEM },
+      { "draw",      VERBOSE_DRAW },
+      { "swap",      VERBOSE_SWAPBUFFERS }
    };
    GLuint i;
 
@@ -262,10 +290,13 @@ write_ppm(const char *filename, const GLubyte *buffer, int width, int height,
 
 
 /**
- * Write level[0] image to a ppm file.
+ * Write a texture image to a ppm file.
+ * \param face  cube face in [0,5]
+ * \param level  mipmap level
  */
 static void
-write_texture_image(struct gl_texture_object *texObj, GLuint face, GLuint level)
+write_texture_image(struct gl_texture_object *texObj,
+                    GLuint face, GLuint level)
 {
    struct gl_texture_image *img = texObj->Image[face][level];
    if (img) {
@@ -285,7 +316,7 @@ write_texture_image(struct gl_texture_object *texObj, GLuint face, GLuint level)
                               buffer, texObj, img);
 
       /* make filename */
-      _mesa_sprintf(s, "/tmp/teximage%u.ppm", texObj->Name);
+      _mesa_sprintf(s, "/tmp/tex%u.l%u.f%u.ppm", texObj->Name, level, face);
 
       _mesa_printf("  Writing image level %u to %s\n", level, s);
       write_ppm(s, buffer, img->Width, img->Height, 4, 0, 1, 2, GL_FALSE);
@@ -297,48 +328,153 @@ write_texture_image(struct gl_texture_object *texObj, GLuint face, GLuint level)
 }
 
 
-static GLboolean DumpImages;
+/**
+ * Write renderbuffer image to a ppm file.
+ */
+static void
+write_renderbuffer_image(const struct gl_renderbuffer *rb)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   GLubyte *buffer;
+   char s[100];
+   GLenum format, type;
+
+   if (rb->_BaseFormat == GL_RGB || 
+       rb->_BaseFormat == GL_RGBA) {
+      format = GL_RGBA;
+      type = GL_UNSIGNED_BYTE;
+   }
+   else if (rb->_BaseFormat == GL_DEPTH_STENCIL) {
+      format = GL_DEPTH_STENCIL;
+      type = GL_UNSIGNED_INT_24_8;
+   }
+   else {
+      return;
+   }
+
+   buffer = (GLubyte *) _mesa_malloc(rb->Width * rb->Height * 4);
+
+   ctx->Driver.ReadPixels(ctx, 0, 0, rb->Width, rb->Height,
+                          format, type, &ctx->DefaultPacking, buffer);
+
+   /* make filename */
+   _mesa_sprintf(s, "/tmp/renderbuffer%u.ppm", rb->Name);
+
+   _mesa_printf("  Writing renderbuffer image to %s\n", s);
+   write_ppm(s, buffer, rb->Width, rb->Height, 4, 0, 1, 2, GL_TRUE);
+
+   _mesa_free(buffer);
+}
+
+
+/** How many texture images (mipmap levels, faces) to write to files */
+#define WRITE_NONE 0
+#define WRITE_ONE  1
+#define WRITE_ALL  2
+
+static GLuint WriteImages;
 
 
 static void
-dump_texture_cb(GLuint id, void *data, void *userData)
+dump_texture(struct gl_texture_object *texObj, GLuint writeImages)
 {
-   struct gl_texture_object *texObj = (struct gl_texture_object *) data;
-   int i;
+   const GLuint numFaces = texObj->Target == GL_TEXTURE_CUBE_MAP ? 6 : 1;
    GLboolean written = GL_FALSE;
-   (void) userData;
+   GLuint i, j;
 
    _mesa_printf("Texture %u\n", texObj->Name);
-   _mesa_printf("  Target 0x%x\n", texObj->Target);
+   _mesa_printf("  Target %s\n", tex_target_name(texObj->Target));
    for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
-      struct gl_texture_image *texImg = texObj->Image[0][i];
-      if (texImg) {
-         _mesa_printf("  Image %u: %d x %d x %d, format %u at %p\n", i,
-                      texImg->Width, texImg->Height, texImg->Depth,
-                      texImg->TexFormat->MesaFormat, texImg->Data);
-         if (DumpImages && !written) {
-            GLuint face = 0;
-            write_texture_image(texObj, face, i);
-            written = GL_TRUE;
+      for (j = 0; j < numFaces; j++) {
+         struct gl_texture_image *texImg = texObj->Image[j][i];
+         if (texImg) {
+            _mesa_printf("  Face %u level %u: %d x %d x %d, format %s at %p\n",
+                         j, i,
+                         texImg->Width, texImg->Height, texImg->Depth,
+                         _mesa_get_format_name(texImg->TexFormat),
+                         texImg->Data);
+            if (writeImages == WRITE_ALL ||
+                (writeImages == WRITE_ONE && !written)) {
+               write_texture_image(texObj, j, i);
+               written = GL_TRUE;
+            }
          }
       }
    }
 }
 
 
+/**
+ * Dump a single texture.
+ */
+void
+_mesa_dump_texture(GLuint texture, GLuint writeImages)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_texture_object *texObj = _mesa_lookup_texture(ctx, texture);
+   if (texObj) {
+      dump_texture(texObj, writeImages);
+   }
+}
+
+
+static void
+dump_texture_cb(GLuint id, void *data, void *userData)
+{
+   struct gl_texture_object *texObj = (struct gl_texture_object *) data;
+   (void) userData;
+   dump_texture(texObj, WriteImages);
+}
+
+
 /**
  * Print basic info about all texture objext to stdout.
  * If dumpImages is true, write PPM of level[0] image to a file.
  */
 void
-_mesa_dump_textures(GLboolean dumpImages)
+_mesa_dump_textures(GLuint writeImages)
 {
    GET_CURRENT_CONTEXT(ctx);
-   DumpImages = dumpImages;
+   WriteImages = writeImages;
    _mesa_HashWalk(ctx->Shared->TexObjects, dump_texture_cb, ctx);
 }
 
 
+static void
+dump_renderbuffer(const struct gl_renderbuffer *rb, GLboolean writeImage)
+{
+   _mesa_printf("Renderbuffer %u: %u x %u  IntFormat = %s\n",
+                rb->Name, rb->Width, rb->Height,
+                _mesa_lookup_enum_by_nr(rb->InternalFormat));
+   if (writeImage) {
+      write_renderbuffer_image(rb);
+   }
+}
+
+
+static void
+dump_renderbuffer_cb(GLuint id, void *data, void *userData)
+{
+   const struct gl_renderbuffer *rb = (const struct gl_renderbuffer *) data;
+   (void) userData;
+   dump_renderbuffer(rb, WriteImages);
+}
+
+
+/**
+ * Print basic info about all renderbuffers to stdout.
+ * If dumpImages is true, write PPM of level[0] image to a file.
+ */
+void
+_mesa_dump_renderbuffers(GLboolean writeImages)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   WriteImages = writeImages;
+   _mesa_HashWalk(ctx->Shared->RenderBuffers, dump_renderbuffer_cb, ctx);
+}
+
+
+
 void
 _mesa_dump_color_buffer(const char *filename)
 {
@@ -438,3 +574,64 @@ _mesa_dump_stencil_buffer(const char *filename)
    _mesa_free(buf);
    _mesa_free(buf2);
 }
+
+
+/**
+ * Quick and dirty function to "print" a texture to stdout.
+ */
+void
+_mesa_print_texture(GLcontext *ctx, const struct gl_texture_image *img)
+{
+#if CHAN_TYPE != GL_UNSIGNED_BYTE
+   _mesa_problem(NULL, "PrintTexture not supported");
+#else
+   GLuint i, j, c;
+   const GLubyte *data = (const GLubyte *) img->Data;
+
+   if (!data) {
+      _mesa_printf("No texture data\n");
+      return;
+   }
+
+   /* XXX add more formats or make into a new format utility function */
+   switch (img->TexFormat) {
+      case MESA_FORMAT_A8:
+      case MESA_FORMAT_L8:
+      case MESA_FORMAT_I8:
+      case MESA_FORMAT_CI8:
+         c = 1;
+         break;
+      case MESA_FORMAT_AL88:
+      case MESA_FORMAT_AL88_REV:
+         c = 2;
+         break;
+      case MESA_FORMAT_RGB888:
+      case MESA_FORMAT_BGR888:
+         c = 3;
+         break;
+      case MESA_FORMAT_RGBA8888:
+      case MESA_FORMAT_ARGB8888:
+         c = 4;
+         break;
+      default:
+         _mesa_problem(NULL, "error in PrintTexture\n");
+         return;
+   }
+
+   for (i = 0; i < img->Height; i++) {
+      for (j = 0; j < img->Width; j++) {
+         if (c==1)
+            _mesa_printf("%02x  ", data[0]);
+         else if (c==2)
+            _mesa_printf("%02x%02x  ", data[0], data[1]);
+         else if (c==3)
+            _mesa_printf("%02x%02x%02x  ", data[0], data[1], data[2]);
+         else if (c==4)
+            _mesa_printf("%02x%02x%02x%02x  ", data[0], data[1], data[2], data[3]);
+         data += (img->RowStride - img->Width) * c;
+      }
+      /* XXX use img->ImageStride here */
+      _mesa_printf("\n");
+   }
+#endif
+}
index bb384c43242361dae7288b31bc285b99801737d9..0449cb1798a571a61fc3a803f927179804592f3e 100644 (file)
@@ -58,7 +58,13 @@ extern void _mesa_init_debug( GLcontext *ctx );
 #endif
 
 extern void
-_mesa_dump_textures(GLboolean dumpImages);
+_mesa_dump_texture(GLuint texture, GLuint writeImages);
+
+extern void
+_mesa_dump_textures(GLuint writeImages);
+
+extern void
+_mesa_dump_renderbuffers(GLboolean writeImages);
 
 extern void
 _mesa_dump_color_buffer(const char *filename);
@@ -69,4 +75,7 @@ _mesa_dump_depth_buffer(const char *filename);
 extern void
 _mesa_dump_stencil_buffer(const char *filename);
 
+extern void
+_mesa_print_texture(GLcontext *ctx, const struct gl_texture_image *img);
+
 #endif
index 91c036ef9686d5816da45481ccb0a1e5923f0b17..f187205b978356c823a2dcc7ab5ac80910d4afc8 100644 (file)
@@ -63,7 +63,7 @@ _mesa_DepthFunc( GLenum func )
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
-   if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
+   if (MESA_VERBOSE & VERBOSE_API)
       _mesa_debug(ctx, "glDepthFunc %s\n", _mesa_lookup_enum_by_nr(func));
 
    switch (func) {
@@ -99,7 +99,7 @@ _mesa_DepthMask( GLboolean flag )
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
-   if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
+   if (MESA_VERBOSE & VERBOSE_API)
       _mesa_debug(ctx, "glDepthMask %d\n", flag);
 
    /*
index 7be2aacaf2c0efbf1aaf0f61d2d67e390eb11177..193c7f8255fe9e4d246a7105b98b12ec8d8f26f4 100644 (file)
@@ -26,6 +26,7 @@
 #include "imports.h"
 #include "context.h"
 #include "fbobject.h"
+#include "formats.h"
 #include "mtypes.h"
 #include "depthstencil.h"
 #include "renderbuffer.h"
@@ -40,8 +41,8 @@
  * a combined Z+stencil buffer!  That implies we need three different sets
  * of Get/Put functions.
  *
- * We solve this by wrapping the Z24_S8 renderbuffer with depth and stencil
- * adaptors, each with the right kind of depth/stencil Get/Put functions.
+ * We solve this by wrapping the Z24_S8 or S8_Z24 renderbuffer with depth and
+ * stencil adaptors, each with the right kind of depth/stencil Get/Put functions.
  */
 
 
@@ -62,8 +63,8 @@ nop_get_pointer(GLcontext *ctx, struct gl_renderbuffer *rb, GLint x, GLint y)
 static void
 delete_wrapper(struct gl_renderbuffer *rb)
 {
-   ASSERT(rb->_ActualFormat == GL_DEPTH_COMPONENT24 ||
-          rb->_ActualFormat == GL_STENCIL_INDEX8_EXT);
+   ASSERT(rb->Format == MESA_FORMAT_Z24_S8 ||
+          rb->Format == MESA_FORMAT_S8_Z24);
    _mesa_reference_renderbuffer(&rb->Wrapped, NULL);
    _mesa_free(rb);
 }
@@ -82,7 +83,8 @@ alloc_wrapper_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
 
    (void) internalFormat;
 
-   ASSERT(dsrb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
+   ASSERT(dsrb->Format == MESA_FORMAT_Z24_S8 ||
+          dsrb->Format == MESA_FORMAT_S8_Z24);
 
    retVal = dsrb->AllocStorage(ctx, dsrb, dsrb->InternalFormat, width, height);
    if (retVal) {
@@ -108,14 +110,21 @@ get_row_z24(GLcontext *ctx, struct gl_renderbuffer *z24rb, GLuint count,
    GLuint *dst = (GLuint *) values;
    const GLuint *src = (const GLuint *) dsrb->GetPointer(ctx, dsrb, x, y);
    ASSERT(z24rb->DataType == GL_UNSIGNED_INT);
-   ASSERT(dsrb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
    ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
    if (!src) {
       dsrb->GetRow(ctx, dsrb, count, x, y, temp);
       src = temp;
    }
-   for (i = 0; i < count; i++) {
-      dst[i] = src[i] >> 8;
+   if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+      for (i = 0; i < count; i++) {
+         dst[i] = src[i] >> 8;
+      }
+   }
+   else {
+      assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+      for (i = 0; i < count; i++) {
+         dst[i] = src[i] & 0xffffff;
+      }
    }
 }
 
@@ -127,13 +136,20 @@ get_values_z24(GLcontext *ctx, struct gl_renderbuffer *z24rb, GLuint count,
    GLuint temp[MAX_WIDTH], i;
    GLuint *dst = (GLuint *) values;
    ASSERT(z24rb->DataType == GL_UNSIGNED_INT);
-   ASSERT(dsrb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
    ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
    ASSERT(count <= MAX_WIDTH);
    /* don't bother trying direct access */
    dsrb->GetValues(ctx, dsrb, count, x, y, temp);
-   for (i = 0; i < count; i++) {
-      dst[i] = temp[i] >> 8;
+   if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+      for (i = 0; i < count; i++) {
+         dst[i] = temp[i] >> 8;
+      }
+   }
+   else {
+      assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+      for (i = 0; i < count; i++) {
+         dst[i] = temp[i] & 0xffffff;
+      }
    }
 }
 
@@ -145,14 +161,23 @@ put_row_z24(GLcontext *ctx, struct gl_renderbuffer *z24rb, GLuint count,
    const GLuint *src = (const GLuint *) values;
    GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y);
    ASSERT(z24rb->DataType == GL_UNSIGNED_INT);
-   ASSERT(dsrb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
    ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
    if (dst) {
       /* direct access */
       GLuint i;
-      for (i = 0; i < count; i++) {
-         if (!mask || mask[i]) {
-            dst[i] = (src[i] << 8) | (dst[i] & 0xff);
+      if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+         for (i = 0; i < count; i++) {
+            if (!mask || mask[i]) {
+               dst[i] = (src[i] << 8) | (dst[i] & 0xff);
+            }
+         }
+      }
+      else {
+         assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+         for (i = 0; i < count; i++) {
+            if (!mask || mask[i]) {
+               dst[i] = (src[i] & 0xffffff) | (dst[i] & 0xff000000);
+            }
          }
       }
    }
@@ -160,9 +185,19 @@ put_row_z24(GLcontext *ctx, struct gl_renderbuffer *z24rb, GLuint count,
       /* get, modify, put */
       GLuint temp[MAX_WIDTH], i;
       dsrb->GetRow(ctx, dsrb, count, x, y, temp);
-      for (i = 0; i < count; i++) {
-         if (!mask || mask[i]) {
-            temp[i] = (src[i] << 8) | (temp[i] & 0xff);
+      if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+         for (i = 0; i < count; i++) {
+            if (!mask || mask[i]) {
+               temp[i] = (src[i] << 8) | (temp[i] & 0xff);
+            }
+         }
+      }
+      else {
+         assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+         for (i = 0; i < count; i++) {
+            if (!mask || mask[i]) {
+               temp[i] = (src[i] & 0xffffff) | (temp[i] & 0xff000000);
+            }
          }
       }
       dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask);
@@ -174,17 +209,27 @@ put_mono_row_z24(GLcontext *ctx, struct gl_renderbuffer *z24rb, GLuint count,
                  GLint x, GLint y, const void *value, const GLubyte *mask)
 {
    struct gl_renderbuffer *dsrb = z24rb->Wrapped;
-   const GLuint shiftedVal = *((GLuint *) value) << 8;
    GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y);
    ASSERT(z24rb->DataType == GL_UNSIGNED_INT);
-   ASSERT(dsrb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
    ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
    if (dst) {
       /* direct access */
       GLuint i;
-      for (i = 0; i < count; i++) {
-         if (!mask || mask[i]) {
-            dst[i] = shiftedVal | (dst[i] & 0xff);
+      if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+         const GLuint shiftedVal = *((GLuint *) value) << 8;
+         for (i = 0; i < count; i++) {
+            if (!mask || mask[i]) {
+               dst[i] = shiftedVal | (dst[i] & 0xff);
+            }
+         }
+      }
+      else {
+         const GLuint shiftedVal = *((GLuint *) value);
+         assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+         for (i = 0; i < count; i++) {
+            if (!mask || mask[i]) {
+               dst[i] = shiftedVal | (dst[i] & 0xff000000);
+            }
          }
       }
    }
@@ -192,9 +237,21 @@ put_mono_row_z24(GLcontext *ctx, struct gl_renderbuffer *z24rb, GLuint count,
       /* get, modify, put */
       GLuint temp[MAX_WIDTH], i;
       dsrb->GetRow(ctx, dsrb, count, x, y, temp);
-      for (i = 0; i < count; i++) {
-         if (!mask || mask[i]) {
-            temp[i] = shiftedVal | (temp[i] & 0xff);
+      if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+         const GLuint shiftedVal = *((GLuint *) value) << 8;
+         for (i = 0; i < count; i++) {
+            if (!mask || mask[i]) {
+               temp[i] = shiftedVal | (temp[i] & 0xff);
+            }
+         }
+      }
+      else {
+         const GLuint shiftedVal = *((GLuint *) value);
+         assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+         for (i = 0; i < count; i++) {
+            if (!mask || mask[i]) {
+               temp[i] = shiftedVal | (temp[i] & 0xff000000);
+            }
          }
       }
       dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask);
@@ -209,15 +266,25 @@ put_values_z24(GLcontext *ctx, struct gl_renderbuffer *z24rb, GLuint count,
    struct gl_renderbuffer *dsrb = z24rb->Wrapped;
    const GLuint *src = (const GLuint *) values;
    ASSERT(z24rb->DataType == GL_UNSIGNED_INT);
-   ASSERT(dsrb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
    ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
    if (dsrb->GetPointer(ctx, dsrb, 0, 0)) {
       /* direct access */
       GLuint i;
-      for (i = 0; i < count; i++) {
-         if (!mask || mask[i]) {
-            GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]);
-            *dst = (src[i] << 8) | (*dst & 0xff);
+      if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+         for (i = 0; i < count; i++) {
+            if (!mask || mask[i]) {
+               GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]);
+               *dst = (src[i] << 8) | (*dst & 0xff);
+            }
+         }
+      }
+      else {
+         assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+         for (i = 0; i < count; i++) {
+            if (!mask || mask[i]) {
+               GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]);
+               *dst = (src[i] & 0xffffff) | (*dst & 0xff000000);
+            }
          }
       }
    }
@@ -225,9 +292,19 @@ put_values_z24(GLcontext *ctx, struct gl_renderbuffer *z24rb, GLuint count,
       /* get, modify, put */
       GLuint temp[MAX_WIDTH], i;
       dsrb->GetValues(ctx, dsrb, count, x, y, temp);
-      for (i = 0; i < count; i++) {
-         if (!mask || mask[i]) {
-            temp[i] = (src[i] << 8) | (temp[i] & 0xff);
+      if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+         for (i = 0; i < count; i++) {
+            if (!mask || mask[i]) {
+               temp[i] = (src[i] << 8) | (temp[i] & 0xff);
+            }
+         }
+      }
+      else {
+         assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+         for (i = 0; i < count; i++) {
+            if (!mask || mask[i]) {
+               temp[i] = (src[i] & 0xffffff) | (temp[i] & 0xff000000);
+            }
          }
       }
       dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask);
@@ -241,12 +318,23 @@ put_mono_values_z24(GLcontext *ctx, struct gl_renderbuffer *z24rb,
 {
    struct gl_renderbuffer *dsrb = z24rb->Wrapped;
    GLuint temp[MAX_WIDTH], i;
-   const GLuint shiftedVal = *((GLuint *) value) << 8;
    /* get, modify, put */
    dsrb->GetValues(ctx, dsrb, count, x, y, temp);
-   for (i = 0; i < count; i++) {
-      if (!mask || mask[i]) {
-         temp[i] = shiftedVal | (temp[i] & 0xff);
+   if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+      const GLuint shiftedVal = *((GLuint *) value) << 8;
+      for (i = 0; i < count; i++) {
+         if (!mask || mask[i]) {
+            temp[i] = shiftedVal | (temp[i] & 0xff);
+         }
+      }
+   }
+   else {
+      const GLuint shiftedVal = *((GLuint *) value);
+      assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+      for (i = 0; i < count; i++) {
+         if (!mask || mask[i]) {
+            temp[i] = shiftedVal | (temp[i] & 0xff000000);
+         }
       }
    }
    dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask);
@@ -264,7 +352,8 @@ _mesa_new_z24_renderbuffer_wrapper(GLcontext *ctx,
 {
    struct gl_renderbuffer *z24rb;
 
-   ASSERT(dsrb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
+   ASSERT(dsrb->Format == MESA_FORMAT_Z24_S8 ||
+          dsrb->Format == MESA_FORMAT_S8_Z24);
    ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
 
    z24rb = _mesa_new_renderbuffer(ctx, 0);
@@ -277,10 +366,9 @@ _mesa_new_z24_renderbuffer_wrapper(GLcontext *ctx,
    z24rb->Width = dsrb->Width;
    z24rb->Height = dsrb->Height;
    z24rb->InternalFormat = GL_DEPTH_COMPONENT24;
-   z24rb->_ActualFormat = GL_DEPTH_COMPONENT24;
+   z24rb->Format = MESA_FORMAT_X8_Z24;
    z24rb->_BaseFormat = GL_DEPTH_COMPONENT;
    z24rb->DataType = GL_UNSIGNED_INT;
-   z24rb->DepthBits = 24;
    z24rb->Data = NULL;
    z24rb->Delete = delete_wrapper;
    z24rb->AllocStorage = alloc_wrapper_storage;
@@ -310,14 +398,21 @@ get_row_s8(GLcontext *ctx, struct gl_renderbuffer *s8rb, GLuint count,
    GLubyte *dst = (GLubyte *) values;
    const GLuint *src = (const GLuint *) dsrb->GetPointer(ctx, dsrb, x, y);
    ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE);
-   ASSERT(dsrb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
    ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
    if (!src) {
       dsrb->GetRow(ctx, dsrb, count, x, y, temp);
       src = temp;
    }
-   for (i = 0; i < count; i++) {
-      dst[i] = src[i] & 0xff;
+   if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+      for (i = 0; i < count; i++) {
+         dst[i] = src[i] & 0xff;
+      }
+   }
+   else {
+      assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+      for (i = 0; i < count; i++) {
+         dst[i] = src[i] >> 24;
+      }
    }
 }
 
@@ -329,13 +424,20 @@ get_values_s8(GLcontext *ctx, struct gl_renderbuffer *s8rb, GLuint count,
    GLuint temp[MAX_WIDTH], i;
    GLubyte *dst = (GLubyte *) values;
    ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE);
-   ASSERT(dsrb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
    ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
    ASSERT(count <= MAX_WIDTH);
    /* don't bother trying direct access */
    dsrb->GetValues(ctx, dsrb, count, x, y, temp);
-   for (i = 0; i < count; i++) {
-      dst[i] = temp[i] & 0xff;
+   if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+      for (i = 0; i < count; i++) {
+         dst[i] = temp[i] & 0xff;
+      }
+   }
+   else {
+      assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+      for (i = 0; i < count; i++) {
+         dst[i] = temp[i] >> 24;
+      }
    }
 }
 
@@ -347,14 +449,23 @@ put_row_s8(GLcontext *ctx, struct gl_renderbuffer *s8rb, GLuint count,
    const GLubyte *src = (const GLubyte *) values;
    GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y);
    ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE);
-   ASSERT(dsrb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
    ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
    if (dst) {
       /* direct access */
       GLuint i;
-      for (i = 0; i < count; i++) {
-         if (!mask || mask[i]) {
-            dst[i] = (dst[i] & 0xffffff00) | src[i];
+      if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+         for (i = 0; i < count; i++) {
+            if (!mask || mask[i]) {
+               dst[i] = (dst[i] & 0xffffff00) | src[i];
+            }
+         }
+      }
+      else {
+         assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+         for (i = 0; i < count; i++) {
+            if (!mask || mask[i]) {
+               dst[i] = (dst[i] & 0xffffff) | (src[i] << 24);
+            }
          }
       }
    }
@@ -362,9 +473,19 @@ put_row_s8(GLcontext *ctx, struct gl_renderbuffer *s8rb, GLuint count,
       /* get, modify, put */
       GLuint temp[MAX_WIDTH], i;
       dsrb->GetRow(ctx, dsrb, count, x, y, temp);
-      for (i = 0; i < count; i++) {
-         if (!mask || mask[i]) {
-            temp[i] = (temp[i] & 0xffffff00) | src[i];
+      if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+         for (i = 0; i < count; i++) {
+            if (!mask || mask[i]) {
+               temp[i] = (temp[i] & 0xffffff00) | src[i];
+            }
+         }
+      }
+      else {
+         assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+         for (i = 0; i < count; i++) {
+            if (!mask || mask[i]) {
+               temp[i] = (temp[i] & 0xffffff) | (src[i] << 24);
+            }
          }
       }
       dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask);
@@ -379,14 +500,23 @@ put_mono_row_s8(GLcontext *ctx, struct gl_renderbuffer *s8rb, GLuint count,
    const GLubyte val = *((GLubyte *) value);
    GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y);
    ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE);
-   ASSERT(dsrb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
    ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
    if (dst) {
       /* direct access */
       GLuint i;
-      for (i = 0; i < count; i++) {
-         if (!mask || mask[i]) {
-            dst[i] = (dst[i] & 0xffffff00) | val;
+      if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+         for (i = 0; i < count; i++) {
+            if (!mask || mask[i]) {
+               dst[i] = (dst[i] & 0xffffff00) | val;
+            }
+         }
+      }
+      else {
+         assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+         for (i = 0; i < count; i++) {
+            if (!mask || mask[i]) {
+               dst[i] = (dst[i] & 0xffffff) | (val << 24);
+            }
          }
       }
    }
@@ -394,9 +524,19 @@ put_mono_row_s8(GLcontext *ctx, struct gl_renderbuffer *s8rb, GLuint count,
       /* get, modify, put */
       GLuint temp[MAX_WIDTH], i;
       dsrb->GetRow(ctx, dsrb, count, x, y, temp);
-      for (i = 0; i < count; i++) {
-         if (!mask || mask[i]) {
-            temp[i] = (temp[i] & 0xffffff00) | val;
+      if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+         for (i = 0; i < count; i++) {
+            if (!mask || mask[i]) {
+               temp[i] = (temp[i] & 0xffffff00) | val;
+            }
+         }
+      }
+      else {
+         assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+         for (i = 0; i < count; i++) {
+            if (!mask || mask[i]) {
+               temp[i] = (temp[i] & 0xffffff) | (val << 24);
+            }
          }
       }
       dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask);
@@ -411,15 +551,25 @@ put_values_s8(GLcontext *ctx, struct gl_renderbuffer *s8rb, GLuint count,
    struct gl_renderbuffer *dsrb = s8rb->Wrapped;
    const GLubyte *src = (const GLubyte *) values;
    ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE);
-   ASSERT(dsrb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
    ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
    if (dsrb->GetPointer(ctx, dsrb, 0, 0)) {
       /* direct access */
       GLuint i;
-      for (i = 0; i < count; i++) {
-         if (!mask || mask[i]) {
-            GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]);
-            *dst = (*dst & 0xffffff00) | src[i];
+      if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+         for (i = 0; i < count; i++) {
+            if (!mask || mask[i]) {
+               GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]);
+               *dst = (*dst & 0xffffff00) | src[i];
+            }
+         }
+      }
+      else {
+         assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+         for (i = 0; i < count; i++) {
+            if (!mask || mask[i]) {
+               GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]);
+               *dst = (*dst & 0xffffff) | (src[i] << 24);
+            }
          }
       }
    }
@@ -427,9 +577,19 @@ put_values_s8(GLcontext *ctx, struct gl_renderbuffer *s8rb, GLuint count,
       /* get, modify, put */
       GLuint temp[MAX_WIDTH], i;
       dsrb->GetValues(ctx, dsrb, count, x, y, temp);
-      for (i = 0; i < count; i++) {
-         if (!mask || mask[i]) {
-            temp[i] = (temp[i] & 0xffffff00) | src[i];
+      if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+         for (i = 0; i < count; i++) {
+            if (!mask || mask[i]) {
+               temp[i] = (temp[i] & 0xffffff00) | src[i];
+            }
+         }
+      }
+      else {
+         assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+         for (i = 0; i < count; i++) {
+            if (!mask || mask[i]) {
+               temp[i] = (temp[i] & 0xffffff) | (src[i] << 24);
+            }
          }
       }
       dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask);
@@ -446,9 +606,19 @@ put_mono_values_s8(GLcontext *ctx, struct gl_renderbuffer *s8rb, GLuint count,
    const GLubyte val = *((GLubyte *) value);
    /* get, modify, put */
    dsrb->GetValues(ctx, dsrb, count, x, y, temp);
-   for (i = 0; i < count; i++) {
-      if (!mask || mask[i]) {
-         temp[i] = (temp[i] & 0xffffff) | val;
+   if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+      for (i = 0; i < count; i++) {
+         if (!mask || mask[i]) {
+            temp[i] = (temp[i] & 0xffffff00) | val;
+         }
+      }
+   }
+   else {
+      assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+      for (i = 0; i < count; i++) {
+         if (!mask || mask[i]) {
+            temp[i] = (temp[i] & 0xffffff) | (val << 24);
+         }
       }
    }
    dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask);
@@ -465,7 +635,8 @@ _mesa_new_s8_renderbuffer_wrapper(GLcontext *ctx, struct gl_renderbuffer *dsrb)
 {
    struct gl_renderbuffer *s8rb;
 
-   ASSERT(dsrb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
+   ASSERT(dsrb->Format == MESA_FORMAT_Z24_S8 ||
+          dsrb->Format == MESA_FORMAT_S8_Z24);
    ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
 
    s8rb = _mesa_new_renderbuffer(ctx, 0);
@@ -478,10 +649,9 @@ _mesa_new_s8_renderbuffer_wrapper(GLcontext *ctx, struct gl_renderbuffer *dsrb)
    s8rb->Width = dsrb->Width;
    s8rb->Height = dsrb->Height;
    s8rb->InternalFormat = GL_STENCIL_INDEX8_EXT;
-   s8rb->_ActualFormat = GL_STENCIL_INDEX8_EXT;
+   s8rb->Format = MESA_FORMAT_S8;
    s8rb->_BaseFormat = GL_STENCIL_INDEX;
    s8rb->DataType = GL_UNSIGNED_BYTE;
-   s8rb->StencilBits = 8;
    s8rb->Data = NULL;
    s8rb->Delete = delete_wrapper;
    s8rb->AllocStorage = alloc_wrapper_storage;
@@ -528,10 +698,10 @@ _mesa_extract_stencil(GLcontext *ctx,
    ASSERT(dsRb);
    ASSERT(stencilRb);
 
-   ASSERT(dsRb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
+   ASSERT(dsRb->Format == MESA_FORMAT_Z24_S8);
    ASSERT(dsRb->DataType == GL_UNSIGNED_INT_24_8_EXT);
-   ASSERT(stencilRb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT ||
-          stencilRb->_ActualFormat == GL_STENCIL_INDEX8_EXT);
+   ASSERT(stencilRb->Format == MESA_FORMAT_Z24_S8 ||
+          stencilRb->Format == MESA_FORMAT_S8);
    ASSERT(dsRb->Width == stencilRb->Width);
    ASSERT(dsRb->Height == stencilRb->Height);
 
@@ -541,7 +711,7 @@ _mesa_extract_stencil(GLcontext *ctx,
    for (row = 0; row < height; row++) {
       GLuint depthStencil[MAX_WIDTH];
       dsRb->GetRow(ctx, dsRb, width, 0, row, depthStencil);
-      if (stencilRb->_ActualFormat == GL_STENCIL_INDEX8_EXT) {
+      if (stencilRb->Format == MESA_FORMAT_S8) {
          /* 8bpp stencil */
          GLubyte stencil[MAX_WIDTH];
          GLuint i;
@@ -553,7 +723,7 @@ _mesa_extract_stencil(GLcontext *ctx,
       else {
          /* 32bpp stencil */
          /* the 24 depth bits will be ignored */
-         ASSERT(stencilRb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
+         ASSERT(stencilRb->Format == MESA_FORMAT_Z24_S8);
          ASSERT(stencilRb->DataType == GL_UNSIGNED_INT_24_8_EXT);
          stencilRb->PutRow(ctx, stencilRb, width, 0, row, depthStencil, NULL);
       }
@@ -577,10 +747,10 @@ _mesa_insert_stencil(GLcontext *ctx,
    ASSERT(dsRb);
    ASSERT(stencilRb);
 
-   ASSERT(dsRb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
+   ASSERT(dsRb->Format == MESA_FORMAT_Z24_S8);
    ASSERT(dsRb->DataType == GL_UNSIGNED_INT_24_8_EXT);
-   ASSERT(stencilRb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT ||
-          stencilRb->_ActualFormat == GL_STENCIL_INDEX8_EXT);
+   ASSERT(stencilRb->Format == MESA_FORMAT_Z24_S8 ||
+          stencilRb->Format == MESA_FORMAT_S8);
 
    ASSERT(dsRb->Width == stencilRb->Width);
    ASSERT(dsRb->Height == stencilRb->Height);
@@ -593,7 +763,7 @@ _mesa_insert_stencil(GLcontext *ctx,
 
       dsRb->GetRow(ctx, dsRb, width, 0, row, depthStencil);
 
-      if (stencilRb->_ActualFormat == GL_STENCIL_INDEX8_EXT) {
+      if (stencilRb->Format == MESA_FORMAT_S8) {
          /* 8bpp stencil */
          GLubyte stencil[MAX_WIDTH];
          GLuint i;
@@ -605,7 +775,7 @@ _mesa_insert_stencil(GLcontext *ctx,
       else {
          /* 32bpp stencil buffer */
          GLuint stencil[MAX_WIDTH], i;
-         ASSERT(stencilRb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
+         ASSERT(stencilRb->Format == MESA_FORMAT_Z24_S8);
          ASSERT(stencilRb->DataType == GL_UNSIGNED_INT_24_8_EXT);
          stencilRb->GetRow(ctx, stencilRb, width, 0, row, stencil);
          for (i = 0; i < width; i++) {
@@ -631,7 +801,7 @@ _mesa_promote_stencil(GLcontext *ctx, struct gl_renderbuffer *stencilRb)
    GLubyte *data;
    GLint i, j, k;
 
-   ASSERT(stencilRb->_ActualFormat == GL_STENCIL_INDEX8_EXT);
+   ASSERT(stencilRb->Format == MESA_FORMAT_S8);
    ASSERT(stencilRb->Data);
 
    data = (GLubyte *) stencilRb->Data;
@@ -650,6 +820,4 @@ _mesa_promote_stencil(GLcontext *ctx, struct gl_renderbuffer *stencilRb)
       stencilRb->PutRow(ctx, stencilRb, width, 0, i, depthStencil, NULL);
    }
    _mesa_free(data);
-
-   stencilRb->_BaseFormat = GL_DEPTH_STENCIL_EXT;
 }
index bf1a01378968cf6bc5379fee6923a7b4bdbfb2a0..eb0d1ff8a7b44fcaad6a9b156bb7db59f9a8f795 100644 (file)
  * \author Brian Paul <brian@precisioninsight.com>
  */
 
-#ifndef GLX_USE_APPLEGL
-
 #include "main/glheader.h"
 #include "main/compiler.h"
 #include "glapi/glapi.h"
 #include "glapi/glapitable.h"
+#include "glapi/glapidispatch.h"
 #include "glapi/glthread.h"
 
 
@@ -88,9 +87,6 @@
 #define GLAPIENTRY
 #endif
 
-#include "glapi/dispatch.h"
 #include "glapi/glapitemp.h"
 
 #endif /* USE_X86_ASM */
-
-#endif /* !GLX_USE_APPLEGL */
index 95c1b9015bd84aaaa1fb962737de58469470b41c..21a8216254bebc11e128fddaf6f934aa4c7aa3d1 100644 (file)
@@ -1,8 +1,9 @@
 /*
  * Mesa 3-D graphics library
- * Version:  7.1
+ * Version:  7.7
  *
- * 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 "glapi/dispatch.h"
 
 
+
+/**
+ * Other parts of Mesa (such as the VBO module) can plug into the display
+ * list system.  This structure describes new display list instructions.
+ */
+struct gl_list_instruction
+{
+   GLuint Size;
+   void (*Execute)( GLcontext *ctx, void *data );
+   void (*Destroy)( GLcontext *ctx, void *data );
+   void (*Print)( GLcontext *ctx, void *data );
+};
+
+
+#define MAX_DLIST_EXT_OPCODES 16
+
+/**
+ * Used by device drivers to hook new commands into display lists.
+ */
+struct gl_list_extensions
+{
+   struct gl_list_instruction Opcode[MAX_DLIST_EXT_OPCODES];
+   GLuint NumOpcodes;
+};
+
+
+
 /**
  * Flush vertices.
  *
@@ -190,8 +218,13 @@ typedef enum
    OPCODE_CLEAR_DEPTH,
    OPCODE_CLEAR_INDEX,
    OPCODE_CLEAR_STENCIL,
+   OPCODE_CLEAR_BUFFER_IV,
+   OPCODE_CLEAR_BUFFER_UIV,
+   OPCODE_CLEAR_BUFFER_FV,
+   OPCODE_CLEAR_BUFFER_FI,
    OPCODE_CLIP_PLANE,
    OPCODE_COLOR_MASK,
+   OPCODE_COLOR_MASK_INDEXED,
    OPCODE_COLOR_MATERIAL,
    OPCODE_COLOR_TABLE,
    OPCODE_COLOR_TABLE_PARAMETER_FV,
@@ -216,9 +249,11 @@ typedef enum
    OPCODE_DEPTH_MASK,
    OPCODE_DEPTH_RANGE,
    OPCODE_DISABLE,
+   OPCODE_DISABLE_INDEXED,
    OPCODE_DRAW_BUFFER,
    OPCODE_DRAW_PIXELS,
    OPCODE_ENABLE,
+   OPCODE_ENABLE_INDEXED,
    OPCODE_EVALMESH1,
    OPCODE_EVALMESH2,
    OPCODE_FOG,
@@ -477,6 +512,49 @@ lookup_list(GLcontext *ctx, GLuint list)
 }
 
 
+/** Is the given opcode an extension code? */
+static INLINE GLboolean
+is_ext_opcode(OpCode opcode)
+{
+   return (opcode >= OPCODE_EXT_0);
+}
+
+
+/** Destroy an extended opcode instruction */
+static GLint
+ext_opcode_destroy(GLcontext *ctx, Node *node)
+{
+   const GLint i = node[0].opcode - OPCODE_EXT_0;
+   GLint step;
+   ctx->ListExt->Opcode[i].Destroy(ctx, &node[1]);
+   step = ctx->ListExt->Opcode[i].Size;
+   return step;
+}
+
+
+/** Execute an extended opcode instruction */
+static GLint
+ext_opcode_execute(GLcontext *ctx, Node *node)
+{
+   const GLint i = node[0].opcode - OPCODE_EXT_0;
+   GLint step;
+   ctx->ListExt->Opcode[i].Execute(ctx, &node[1]);
+   step = ctx->ListExt->Opcode[i].Size;
+   return step;
+}
+
+
+/** Print an extended opcode instruction */
+static GLint
+ext_opcode_print(GLcontext *ctx, Node *node)
+{
+   const GLint i = node[0].opcode - OPCODE_EXT_0;
+   GLint step;
+   ctx->ListExt->Opcode[i].Print(ctx, &node[1]);
+   step = ctx->ListExt->Opcode[i].Size;
+   return step;
+}
+
 
 /**
  * Delete the named display list, but don't remove from hash table.
@@ -492,16 +570,14 @@ _mesa_delete_list(GLcontext *ctx, struct gl_display_list *dlist)
 
    done = block ? GL_FALSE : GL_TRUE;
    while (!done) {
+      const OpCode opcode = n[0].opcode;
 
       /* check for extension opcodes first */
-
-      GLint i = (GLint) n[0].opcode - (GLint) OPCODE_EXT_0;
-      if (i >= 0 && i < (GLint) ctx->ListExt.NumOpcodes) {
-         ctx->ListExt.Opcode[i].Destroy(ctx, &n[1]);
-         n += ctx->ListExt.Opcode[i].Size;
+      if (is_ext_opcode(opcode)) {
+         n += ext_opcode_destroy(ctx, n);
       }
       else {
-         switch (n[0].opcode) {
+         switch (opcode) {
             /* for some commands, we need to free malloc'd memory */
          case OPCODE_MAP1:
             _mesa_free(n[6].data);
@@ -789,14 +865,13 @@ unpack_image(GLcontext *ctx, GLuint dimensions,
 
 
 /**
- * Allocate space for a display list instruction.
+ * Allocate space for a display list instruction (opcode + payload space).
  * \param opcode  the instruction opcode (OPCODE_* value)
- * \param bytes   instruction size in bytes, not counting opcode.
- * \return pointer to the usable data area (not including the internal
- *         opcode).
+ * \param bytes   instruction payload size (not counting opcode)
+ * \return pointer to allocated memory (the opcode space)
  */
-void *
-_mesa_alloc_instruction(GLcontext *ctx, GLuint opcode, GLuint bytes)
+static Node *
+dlist_alloc(GLcontext *ctx, OpCode opcode, GLuint bytes)
 {
    const GLuint numNodes = 1 + (bytes + sizeof(Node) - 1) / sizeof(Node);
    Node *n;
@@ -830,9 +905,30 @@ _mesa_alloc_instruction(GLcontext *ctx, GLuint opcode, GLuint bytes)
    n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos;
    ctx->ListState.CurrentPos += numNodes;
 
-   n[0].opcode = (OpCode) opcode;
+   n[0].opcode = opcode;
 
-   return (void *) (n + 1);     /* return ptr to node following opcode */
+   return n;
+}
+
+
+
+/**
+ * Allocate space for a display list instruction.  Used by callers outside
+ * this file for things like VBO vertex data.
+ *
+ * \param opcode  the instruction opcode (OPCODE_* value)
+ * \param bytes   instruction size in bytes, not counting opcode.
+ * \return pointer to the usable data area (not including the internal
+ *         opcode).
+ */
+void *
+_mesa_dlist_alloc(GLcontext *ctx, GLuint opcode, GLuint bytes)
+{
+   Node *n = dlist_alloc(ctx, (OpCode) opcode, bytes);
+   if (n)
+      return n + 1;  /* return pointer to payload area, after opcode */
+   else
+      return NULL;
 }
 
 
@@ -847,35 +943,39 @@ _mesa_alloc_instruction(GLcontext *ctx, GLuint opcode, GLuint bytes)
  * \return  the new opcode number or -1 if error
  */
 GLint
-_mesa_alloc_opcode(GLcontext *ctx,
-                   GLuint size,
-                   void (*execute) (GLcontext *, void *),
-                   void (*destroy) (GLcontext *, void *),
-                   void (*print) (GLcontext *, void *))
-{
-   if (ctx->ListExt.NumOpcodes < MAX_DLIST_EXT_OPCODES) {
-      const GLuint i = ctx->ListExt.NumOpcodes++;
-      ctx->ListExt.Opcode[i].Size =
+_mesa_dlist_alloc_opcode(GLcontext *ctx,
+                         GLuint size,
+                         void (*execute) (GLcontext *, void *),
+                         void (*destroy) (GLcontext *, void *),
+                         void (*print) (GLcontext *, void *))
+{
+   if (ctx->ListExt->NumOpcodes < MAX_DLIST_EXT_OPCODES) {
+      const GLuint i = ctx->ListExt->NumOpcodes++;
+      ctx->ListExt->Opcode[i].Size =
          1 + (size + sizeof(Node) - 1) / sizeof(Node);
-      ctx->ListExt.Opcode[i].Execute = execute;
-      ctx->ListExt.Opcode[i].Destroy = destroy;
-      ctx->ListExt.Opcode[i].Print = print;
+      ctx->ListExt->Opcode[i].Execute = execute;
+      ctx->ListExt->Opcode[i].Destroy = destroy;
+      ctx->ListExt->Opcode[i].Print = print;
       return i + OPCODE_EXT_0;
    }
    return -1;
 }
 
 
-
 /**
- * Allocate display list instruction.  Returns Node ptr to where the opcode
- * is stored.
- *   - nParams is the number of function parameters
- *   - return value a pointer to sizeof(Node) before the actual
- *     usable data area.
+ * Allocate space for a display list instruction.  The space is basically
+ * an array of Nodes where node[0] holds the opcode, node[1] is the first
+ * function parameter, node[2] is the second parameter, etc.
+ *
+ * \param opcode  one of OPCODE_x
+ * \param nparams  number of function parameters
+ * \return  pointer to start of instruction space
  */
-#define ALLOC_INSTRUCTION(CTX, OPCODE, NPARAMS) \
-    ((Node *)_mesa_alloc_instruction(CTX, OPCODE, (NPARAMS)*sizeof(Node)) - 1)
+static INLINE Node *
+alloc_instruction(GLcontext *ctx, OpCode opcode, GLuint nparams)
+{
+   return dlist_alloc(ctx, opcode, nparams * sizeof(Node));
+}
 
 
 
@@ -888,7 +988,7 @@ save_Accum(GLenum op, GLfloat value)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_ACCUM, 2);
+   n = alloc_instruction(ctx, OPCODE_ACCUM, 2);
    if (n) {
       n[1].e = op;
       n[2].f = value;
@@ -905,7 +1005,7 @@ save_AlphaFunc(GLenum func, GLclampf ref)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_ALPHA_FUNC, 2);
+   n = alloc_instruction(ctx, OPCODE_ALPHA_FUNC, 2);
    if (n) {
       n[1].e = func;
       n[2].f = (GLfloat) ref;
@@ -922,7 +1022,7 @@ save_BindTexture(GLenum target, GLuint texture)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_BIND_TEXTURE, 2);
+   n = alloc_instruction(ctx, OPCODE_BIND_TEXTURE, 2);
    if (n) {
       n[1].e = target;
       n[2].ui = texture;
@@ -941,7 +1041,7 @@ save_Bitmap(GLsizei width, GLsizei height,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_BITMAP, 7);
+   n = alloc_instruction(ctx, OPCODE_BITMAP, 7);
    if (n) {
       n[1].i = (GLint) width;
       n[2].i = (GLint) height;
@@ -964,7 +1064,7 @@ save_BlendEquation(GLenum mode)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_BLEND_EQUATION, 1);
+   n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION, 1);
    if (n) {
       n[1].e = mode;
    }
@@ -980,7 +1080,7 @@ save_BlendEquationSeparateEXT(GLenum modeRGB, GLenum modeA)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_BLEND_EQUATION_SEPARATE, 2);
+   n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_SEPARATE, 2);
    if (n) {
       n[1].e = modeRGB;
       n[2].e = modeA;
@@ -998,7 +1098,7 @@ save_BlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_BLEND_FUNC_SEPARATE, 4);
+   n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_SEPARATE, 4);
    if (n) {
       n[1].e = sfactorRGB;
       n[2].e = dfactorRGB;
@@ -1025,7 +1125,7 @@ save_BlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_BLEND_COLOR, 4);
+   n = alloc_instruction(ctx, OPCODE_BLEND_COLOR, 4);
    if (n) {
       n[1].f = red;
       n[2].f = green;
@@ -1059,7 +1159,7 @@ save_CallList(GLuint list)
    Node *n;
    SAVE_FLUSH_VERTICES(ctx);
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_CALL_LIST, 1);
+   n = alloc_instruction(ctx, OPCODE_CALL_LIST, 1);
    if (n) {
       n[1].ui = list;
    }
@@ -1103,7 +1203,7 @@ save_CallLists(GLsizei num, GLenum type, const GLvoid * lists)
 
    for (i = 0; i < num; i++) {
       GLint list = translate_id(i, type, lists);
-      Node *n = ALLOC_INSTRUCTION(ctx, OPCODE_CALL_LIST_OFFSET, 2);
+      Node *n = alloc_instruction(ctx, OPCODE_CALL_LIST_OFFSET, 2);
       if (n) {
          n[1].i = list;
          n[2].b = typeErrorFlag;
@@ -1127,7 +1227,7 @@ save_Clear(GLbitfield mask)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_CLEAR, 1);
+   n = alloc_instruction(ctx, OPCODE_CLEAR, 1);
    if (n) {
       n[1].bf = mask;
    }
@@ -1137,13 +1237,117 @@ save_Clear(GLbitfield mask)
 }
 
 
+static void GLAPIENTRY
+save_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_IV, 6);
+   if (n) {
+      n[1].e = buffer;
+      n[2].i = drawbuffer;
+      n[3].i = value[0];
+      if (buffer == GL_COLOR) {
+         n[4].i = value[1];
+         n[5].i = value[2];
+         n[6].i = value[3];
+      }
+      else {
+         n[4].i = 0;
+         n[5].i = 0;
+         n[6].i = 0;
+      }
+   }
+   if (ctx->ExecuteFlag) {
+      /*CALL_ClearBufferiv(ctx->Exec, (buffer, drawbuffer, value));*/
+   }
+}
+
+
+static void GLAPIENTRY
+save_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_UIV, 6);
+   if (n) {
+      n[1].e = buffer;
+      n[2].i = drawbuffer;
+      n[3].ui = value[0];
+      if (buffer == GL_COLOR) {
+         n[4].ui = value[1];
+         n[5].ui = value[2];
+         n[6].ui = value[3];
+      }
+      else {
+         n[4].ui = 0;
+         n[5].ui = 0;
+         n[6].ui = 0;
+      }
+   }
+   if (ctx->ExecuteFlag) {
+      /*CALL_ClearBufferuiv(ctx->Exec, (buffer, drawbuffer, value));*/
+   }
+}
+
+
+static void GLAPIENTRY
+save_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_FV, 6);
+   if (n) {
+      n[1].e = buffer;
+      n[2].i = drawbuffer;
+      n[3].f = value[0];
+      if (buffer == GL_COLOR) {
+         n[4].f = value[1];
+         n[5].f = value[2];
+         n[6].f = value[3];
+      }
+      else {
+         n[4].f = 0.0F;
+         n[5].f = 0.0F;
+         n[6].f = 0.0F;
+      }
+   }
+   if (ctx->ExecuteFlag) {
+      /*CALL_ClearBufferuiv(ctx->Exec, (buffer, drawbuffer, value));*/
+   }
+}
+
+
+static void GLAPIENTRY
+save_ClearBufferfi(GLenum buffer, GLint drawbuffer,
+                   GLfloat depth, GLint stencil)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_FI, 4);
+   if (n) {
+      n[1].e = buffer;
+      n[2].i = drawbuffer;
+      n[3].f = depth;
+      n[4].i = stencil;
+   }
+   if (ctx->ExecuteFlag) {
+      /*CALL_ClearBufferfi(ctx->Exec, (buffer, drawbuffer, depth, stencil));*/
+   }
+}
+
+
 static void GLAPIENTRY
 save_ClearAccum(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_CLEAR_ACCUM, 4);
+   n = alloc_instruction(ctx, OPCODE_CLEAR_ACCUM, 4);
    if (n) {
       n[1].f = red;
       n[2].f = green;
@@ -1162,7 +1366,7 @@ save_ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_CLEAR_COLOR, 4);
+   n = alloc_instruction(ctx, OPCODE_CLEAR_COLOR, 4);
    if (n) {
       n[1].f = red;
       n[2].f = green;
@@ -1181,7 +1385,7 @@ save_ClearDepth(GLclampd depth)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_CLEAR_DEPTH, 1);
+   n = alloc_instruction(ctx, OPCODE_CLEAR_DEPTH, 1);
    if (n) {
       n[1].f = (GLfloat) depth;
    }
@@ -1197,7 +1401,7 @@ save_ClearIndex(GLfloat c)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_CLEAR_INDEX, 1);
+   n = alloc_instruction(ctx, OPCODE_CLEAR_INDEX, 1);
    if (n) {
       n[1].f = c;
    }
@@ -1213,7 +1417,7 @@ save_ClearStencil(GLint s)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_CLEAR_STENCIL, 1);
+   n = alloc_instruction(ctx, OPCODE_CLEAR_STENCIL, 1);
    if (n) {
       n[1].i = s;
    }
@@ -1229,7 +1433,7 @@ save_ClipPlane(GLenum plane, const GLdouble * equ)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_CLIP_PLANE, 5);
+   n = alloc_instruction(ctx, OPCODE_CLIP_PLANE, 5);
    if (n) {
       n[1].e = plane;
       n[2].f = (GLfloat) equ[0];
@@ -1251,7 +1455,7 @@ save_ColorMask(GLboolean red, GLboolean green,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_COLOR_MASK, 4);
+   n = alloc_instruction(ctx, OPCODE_COLOR_MASK, 4);
    if (n) {
       n[1].b = red;
       n[2].b = green;
@@ -1264,6 +1468,27 @@ save_ColorMask(GLboolean red, GLboolean green,
 }
 
 
+static void GLAPIENTRY
+save_ColorMaskIndexed(GLuint buf, GLboolean red, GLboolean green,
+                      GLboolean blue, GLboolean alpha)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = alloc_instruction(ctx, OPCODE_COLOR_MASK_INDEXED, 5);
+   if (n) {
+      n[1].ui = buf;
+      n[2].b = red;
+      n[3].b = green;
+      n[4].b = blue;
+      n[5].b = alpha;
+   }
+   if (ctx->ExecuteFlag) {
+      /*CALL_ColorMaskIndexedEXT(ctx->Exec, (buf, red, green, blue, alpha));*/
+   }
+}
+
+
 static void GLAPIENTRY
 save_ColorMaterial(GLenum face, GLenum mode)
 {
@@ -1271,7 +1496,7 @@ save_ColorMaterial(GLenum face, GLenum mode)
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_COLOR_MATERIAL, 2);
+   n = alloc_instruction(ctx, OPCODE_COLOR_MATERIAL, 2);
    if (n) {
       n[1].e = face;
       n[2].e = mode;
@@ -1296,7 +1521,7 @@ save_ColorTable(GLenum target, GLenum internalFormat,
    else {
       Node *n;
       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-      n = ALLOC_INSTRUCTION(ctx, OPCODE_COLOR_TABLE, 6);
+      n = alloc_instruction(ctx, OPCODE_COLOR_TABLE, 6);
       if (n) {
          n[1].e = target;
          n[2].e = internalFormat;
@@ -1324,7 +1549,7 @@ save_ColorTableParameterfv(GLenum target, GLenum pname,
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_COLOR_TABLE_PARAMETER_FV, 6);
+   n = alloc_instruction(ctx, OPCODE_COLOR_TABLE_PARAMETER_FV, 6);
    if (n) {
       n[1].e = target;
       n[2].e = pname;
@@ -1353,7 +1578,7 @@ save_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params)
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_COLOR_TABLE_PARAMETER_IV, 6);
+   n = alloc_instruction(ctx, OPCODE_COLOR_TABLE_PARAMETER_IV, 6);
    if (n) {
       n[1].e = target;
       n[2].e = pname;
@@ -1382,7 +1607,7 @@ save_ColorSubTable(GLenum target, GLsizei start, GLsizei count,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_COLOR_SUB_TABLE, 6);
+   n = alloc_instruction(ctx, OPCODE_COLOR_SUB_TABLE, 6);
    if (n) {
       n[1].e = target;
       n[2].i = start;
@@ -1407,7 +1632,7 @@ save_CopyColorSubTable(GLenum target, GLsizei start,
    Node *n;
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_COPY_COLOR_SUB_TABLE, 5);
+   n = alloc_instruction(ctx, OPCODE_COPY_COLOR_SUB_TABLE, 5);
    if (n) {
       n[1].e = target;
       n[2].i = start;
@@ -1429,7 +1654,7 @@ save_CopyColorTable(GLenum target, GLenum internalformat,
    Node *n;
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_COPY_COLOR_TABLE, 5);
+   n = alloc_instruction(ctx, OPCODE_COPY_COLOR_TABLE, 5);
    if (n) {
       n[1].e = target;
       n[2].e = internalformat;
@@ -1452,7 +1677,7 @@ save_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width,
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_CONVOLUTION_FILTER_1D, 6);
+   n = alloc_instruction(ctx, OPCODE_CONVOLUTION_FILTER_1D, 6);
    if (n) {
       n[1].e = target;
       n[2].e = internalFormat;
@@ -1479,7 +1704,7 @@ save_ConvolutionFilter2D(GLenum target, GLenum internalFormat,
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_CONVOLUTION_FILTER_2D, 7);
+   n = alloc_instruction(ctx, OPCODE_CONVOLUTION_FILTER_2D, 7);
    if (n) {
       n[1].e = target;
       n[2].e = internalFormat;
@@ -1504,7 +1729,7 @@ save_ConvolutionParameteri(GLenum target, GLenum pname, GLint param)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_CONVOLUTION_PARAMETER_I, 3);
+   n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_I, 3);
    if (n) {
       n[1].e = target;
       n[2].e = pname;
@@ -1522,7 +1747,7 @@ save_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_CONVOLUTION_PARAMETER_IV, 6);
+   n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_IV, 6);
    if (n) {
       n[1].e = target;
       n[2].e = pname;
@@ -1550,7 +1775,7 @@ save_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat param)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_CONVOLUTION_PARAMETER_F, 3);
+   n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_F, 3);
    if (n) {
       n[1].e = target;
       n[2].e = pname;
@@ -1569,7 +1794,7 @@ save_ConvolutionParameterfv(GLenum target, GLenum pname,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_CONVOLUTION_PARAMETER_FV, 6);
+   n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_FV, 6);
    if (n) {
       n[1].e = target;
       n[2].e = pname;
@@ -1597,7 +1822,7 @@ save_CopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_COPY_PIXELS, 5);
+   n = alloc_instruction(ctx, OPCODE_COPY_PIXELS, 5);
    if (n) {
       n[1].i = x;
       n[2].i = y;
@@ -1619,7 +1844,7 @@ save_CopyTexImage1D(GLenum target, GLint level, GLenum internalformat,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_COPY_TEX_IMAGE1D, 7);
+   n = alloc_instruction(ctx, OPCODE_COPY_TEX_IMAGE1D, 7);
    if (n) {
       n[1].e = target;
       n[2].i = level;
@@ -1645,7 +1870,7 @@ save_CopyTexImage2D(GLenum target, GLint level,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_COPY_TEX_IMAGE2D, 8);
+   n = alloc_instruction(ctx, OPCODE_COPY_TEX_IMAGE2D, 8);
    if (n) {
       n[1].e = target;
       n[2].i = level;
@@ -1671,7 +1896,7 @@ save_CopyTexSubImage1D(GLenum target, GLint level,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6);
+   n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6);
    if (n) {
       n[1].e = target;
       n[2].i = level;
@@ -1695,7 +1920,7 @@ save_CopyTexSubImage2D(GLenum target, GLint level,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8);
+   n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8);
    if (n) {
       n[1].e = target;
       n[2].i = level;
@@ -1721,7 +1946,7 @@ save_CopyTexSubImage3D(GLenum target, GLint level,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9);
+   n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9);
    if (n) {
       n[1].e = target;
       n[2].i = level;
@@ -1747,7 +1972,7 @@ save_CullFace(GLenum mode)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_CULL_FACE, 1);
+   n = alloc_instruction(ctx, OPCODE_CULL_FACE, 1);
    if (n) {
       n[1].e = mode;
    }
@@ -1763,7 +1988,7 @@ save_DepthFunc(GLenum func)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_DEPTH_FUNC, 1);
+   n = alloc_instruction(ctx, OPCODE_DEPTH_FUNC, 1);
    if (n) {
       n[1].e = func;
    }
@@ -1779,7 +2004,7 @@ save_DepthMask(GLboolean mask)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_DEPTH_MASK, 1);
+   n = alloc_instruction(ctx, OPCODE_DEPTH_MASK, 1);
    if (n) {
       n[1].b = mask;
    }
@@ -1795,7 +2020,7 @@ save_DepthRange(GLclampd nearval, GLclampd farval)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_DEPTH_RANGE, 2);
+   n = alloc_instruction(ctx, OPCODE_DEPTH_RANGE, 2);
    if (n) {
       n[1].f = (GLfloat) nearval;
       n[2].f = (GLfloat) farval;
@@ -1812,7 +2037,7 @@ save_Disable(GLenum cap)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_DISABLE, 1);
+   n = alloc_instruction(ctx, OPCODE_DISABLE, 1);
    if (n) {
       n[1].e = cap;
    }
@@ -1822,13 +2047,30 @@ save_Disable(GLenum cap)
 }
 
 
+static void GLAPIENTRY
+save_DisableIndexed(GLuint index, GLenum cap)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = alloc_instruction(ctx, OPCODE_DISABLE_INDEXED, 2);
+   if (n) {
+      n[1].ui = index;
+      n[2].e = cap;
+   }
+   if (ctx->ExecuteFlag) {
+      CALL_DisableIndexedEXT(ctx->Exec, (index, cap));
+   }
+}
+
+
 static void GLAPIENTRY
 save_DrawBuffer(GLenum mode)
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_DRAW_BUFFER, 1);
+   n = alloc_instruction(ctx, OPCODE_DRAW_BUFFER, 1);
    if (n) {
       n[1].e = mode;
    }
@@ -1847,7 +2089,7 @@ save_DrawPixels(GLsizei width, GLsizei height,
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_DRAW_PIXELS, 5);
+   n = alloc_instruction(ctx, OPCODE_DRAW_PIXELS, 5);
    if (n) {
       n[1].i = width;
       n[2].i = height;
@@ -1869,7 +2111,7 @@ save_Enable(GLenum cap)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_ENABLE, 1);
+   n = alloc_instruction(ctx, OPCODE_ENABLE, 1);
    if (n) {
       n[1].e = cap;
    }
@@ -1880,13 +2122,31 @@ save_Enable(GLenum cap)
 
 
 
+static void GLAPIENTRY
+save_EnableIndexed(GLuint index, GLenum cap)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = alloc_instruction(ctx, OPCODE_ENABLE_INDEXED, 2);
+   if (n) {
+      n[1].ui = index;
+      n[2].e = cap;
+   }
+   if (ctx->ExecuteFlag) {
+      CALL_EnableIndexedEXT(ctx->Exec, (index, cap));
+   }
+}
+
+
+
 static void GLAPIENTRY
 save_EvalMesh1(GLenum mode, GLint i1, GLint i2)
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_EVALMESH1, 3);
+   n = alloc_instruction(ctx, OPCODE_EVALMESH1, 3);
    if (n) {
       n[1].e = mode;
       n[2].i = i1;
@@ -1904,7 +2164,7 @@ save_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_EVALMESH2, 5);
+   n = alloc_instruction(ctx, OPCODE_EVALMESH2, 5);
    if (n) {
       n[1].e = mode;
       n[2].i = i1;
@@ -1926,7 +2186,7 @@ save_Fogfv(GLenum pname, const GLfloat *params)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_FOG, 5);
+   n = alloc_instruction(ctx, OPCODE_FOG, 5);
    if (n) {
       n[1].e = pname;
       n[2].f = params[0];
@@ -1995,7 +2255,7 @@ save_FrontFace(GLenum mode)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_FRONT_FACE, 1);
+   n = alloc_instruction(ctx, OPCODE_FRONT_FACE, 1);
    if (n) {
       n[1].e = mode;
    }
@@ -2012,7 +2272,7 @@ save_Frustum(GLdouble left, GLdouble right,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_FRUSTUM, 6);
+   n = alloc_instruction(ctx, OPCODE_FRUSTUM, 6);
    if (n) {
       n[1].f = (GLfloat) left;
       n[2].f = (GLfloat) right;
@@ -2033,7 +2293,7 @@ save_Hint(GLenum target, GLenum mode)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_HINT, 2);
+   n = alloc_instruction(ctx, OPCODE_HINT, 2);
    if (n) {
       n[1].e = target;
       n[2].e = mode;
@@ -2052,7 +2312,7 @@ save_Histogram(GLenum target, GLsizei width, GLenum internalFormat,
    Node *n;
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_HISTOGRAM, 4);
+   n = alloc_instruction(ctx, OPCODE_HISTOGRAM, 4);
    if (n) {
       n[1].e = target;
       n[2].i = width;
@@ -2071,7 +2331,7 @@ save_IndexMask(GLuint mask)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_INDEX_MASK, 1);
+   n = alloc_instruction(ctx, OPCODE_INDEX_MASK, 1);
    if (n) {
       n[1].ui = mask;
    }
@@ -2086,7 +2346,7 @@ save_InitNames(void)
 {
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   (void) ALLOC_INSTRUCTION(ctx, OPCODE_INIT_NAMES, 0);
+   (void) alloc_instruction(ctx, OPCODE_INIT_NAMES, 0);
    if (ctx->ExecuteFlag) {
       CALL_InitNames(ctx->Exec, ());
    }
@@ -2099,7 +2359,7 @@ save_Lightfv(GLenum light, GLenum pname, const GLfloat *params)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_LIGHT, 6);
+   n = alloc_instruction(ctx, OPCODE_LIGHT, 6);
    if (n) {
       GLint i, nParams;
       n[1].e = light;
@@ -2213,7 +2473,7 @@ save_LightModelfv(GLenum pname, const GLfloat *params)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_LIGHT_MODEL, 5);
+   n = alloc_instruction(ctx, OPCODE_LIGHT_MODEL, 5);
    if (n) {
       n[1].e = pname;
       n[2].f = params[0];
@@ -2280,7 +2540,7 @@ save_LineStipple(GLint factor, GLushort pattern)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_LINE_STIPPLE, 2);
+   n = alloc_instruction(ctx, OPCODE_LINE_STIPPLE, 2);
    if (n) {
       n[1].i = factor;
       n[2].us = pattern;
@@ -2297,7 +2557,7 @@ save_LineWidth(GLfloat width)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_LINE_WIDTH, 1);
+   n = alloc_instruction(ctx, OPCODE_LINE_WIDTH, 1);
    if (n) {
       n[1].f = width;
    }
@@ -2313,7 +2573,7 @@ save_ListBase(GLuint base)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_LIST_BASE, 1);
+   n = alloc_instruction(ctx, OPCODE_LIST_BASE, 1);
    if (n) {
       n[1].ui = base;
    }
@@ -2328,7 +2588,7 @@ save_LoadIdentity(void)
 {
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   (void) ALLOC_INSTRUCTION(ctx, OPCODE_LOAD_IDENTITY, 0);
+   (void) alloc_instruction(ctx, OPCODE_LOAD_IDENTITY, 0);
    if (ctx->ExecuteFlag) {
       CALL_LoadIdentity(ctx->Exec, ());
    }
@@ -2341,7 +2601,7 @@ save_LoadMatrixf(const GLfloat * m)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_LOAD_MATRIX, 16);
+   n = alloc_instruction(ctx, OPCODE_LOAD_MATRIX, 16);
    if (n) {
       GLuint i;
       for (i = 0; i < 16; i++) {
@@ -2372,7 +2632,7 @@ save_LoadName(GLuint name)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_LOAD_NAME, 1);
+   n = alloc_instruction(ctx, OPCODE_LOAD_NAME, 1);
    if (n) {
       n[1].ui = name;
    }
@@ -2388,7 +2648,7 @@ save_LogicOp(GLenum opcode)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_LOGIC_OP, 1);
+   n = alloc_instruction(ctx, OPCODE_LOGIC_OP, 1);
    if (n) {
       n[1].e = opcode;
    }
@@ -2405,7 +2665,7 @@ save_Map1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_MAP1, 6);
+   n = alloc_instruction(ctx, OPCODE_MAP1, 6);
    if (n) {
       GLfloat *pnts = _mesa_copy_map_points1d(target, stride, order, points);
       n[1].e = target;
@@ -2427,7 +2687,7 @@ save_Map1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_MAP1, 6);
+   n = alloc_instruction(ctx, OPCODE_MAP1, 6);
    if (n) {
       GLfloat *pnts = _mesa_copy_map_points1f(target, stride, order, points);
       n[1].e = target;
@@ -2452,7 +2712,7 @@ save_Map2d(GLenum target,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_MAP2, 10);
+   n = alloc_instruction(ctx, OPCODE_MAP2, 10);
    if (n) {
       GLfloat *pnts = _mesa_copy_map_points2d(target, ustride, uorder,
                                               vstride, vorder, points);
@@ -2485,7 +2745,7 @@ save_Map2f(GLenum target,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_MAP2, 10);
+   n = alloc_instruction(ctx, OPCODE_MAP2, 10);
    if (n) {
       GLfloat *pnts = _mesa_copy_map_points2f(target, ustride, uorder,
                                               vstride, vorder, points);
@@ -2514,7 +2774,7 @@ save_MapGrid1f(GLint un, GLfloat u1, GLfloat u2)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_MAPGRID1, 3);
+   n = alloc_instruction(ctx, OPCODE_MAPGRID1, 3);
    if (n) {
       n[1].i = un;
       n[2].f = u1;
@@ -2540,7 +2800,7 @@ save_MapGrid2f(GLint un, GLfloat u1, GLfloat u2,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_MAPGRID2, 6);
+   n = alloc_instruction(ctx, OPCODE_MAPGRID2, 6);
    if (n) {
       n[1].i = un;
       n[2].f = u1;
@@ -2571,7 +2831,7 @@ save_MatrixMode(GLenum mode)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_MATRIX_MODE, 1);
+   n = alloc_instruction(ctx, OPCODE_MATRIX_MODE, 1);
    if (n) {
       n[1].e = mode;
    }
@@ -2588,7 +2848,7 @@ save_Minmax(GLenum target, GLenum internalFormat, GLboolean sink)
    Node *n;
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_MIN_MAX, 3);
+   n = alloc_instruction(ctx, OPCODE_MIN_MAX, 3);
    if (n) {
       n[1].e = target;
       n[2].e = internalFormat;
@@ -2606,7 +2866,7 @@ save_MultMatrixf(const GLfloat * m)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_MULT_MATRIX, 16);
+   n = alloc_instruction(ctx, OPCODE_MULT_MATRIX, 16);
    if (n) {
       GLuint i;
       for (i = 0; i < 16; i++) {
@@ -2650,7 +2910,7 @@ save_Ortho(GLdouble left, GLdouble right,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_ORTHO, 6);
+   n = alloc_instruction(ctx, OPCODE_ORTHO, 6);
    if (n) {
       n[1].f = (GLfloat) left;
       n[2].f = (GLfloat) right;
@@ -2671,7 +2931,7 @@ save_PixelMapfv(GLenum map, GLint mapsize, const GLfloat *values)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_PIXEL_MAP, 3);
+   n = alloc_instruction(ctx, OPCODE_PIXEL_MAP, 3);
    if (n) {
       n[1].e = map;
       n[2].i = mapsize;
@@ -2728,7 +2988,7 @@ save_PixelTransferf(GLenum pname, GLfloat param)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_PIXEL_TRANSFER, 2);
+   n = alloc_instruction(ctx, OPCODE_PIXEL_TRANSFER, 2);
    if (n) {
       n[1].e = pname;
       n[2].f = param;
@@ -2752,7 +3012,7 @@ save_PixelZoom(GLfloat xfactor, GLfloat yfactor)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_PIXEL_ZOOM, 2);
+   n = alloc_instruction(ctx, OPCODE_PIXEL_ZOOM, 2);
    if (n) {
       n[1].f = xfactor;
       n[2].f = yfactor;
@@ -2769,7 +3029,7 @@ save_PointParameterfvEXT(GLenum pname, const GLfloat *params)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_POINT_PARAMETERS, 4);
+   n = alloc_instruction(ctx, OPCODE_POINT_PARAMETERS, 4);
    if (n) {
       n[1].e = pname;
       n[2].f = params[0];
@@ -2816,7 +3076,7 @@ save_PointSize(GLfloat size)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_POINT_SIZE, 1);
+   n = alloc_instruction(ctx, OPCODE_POINT_SIZE, 1);
    if (n) {
       n[1].f = size;
    }
@@ -2832,7 +3092,7 @@ save_PolygonMode(GLenum face, GLenum mode)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_POLYGON_MODE, 2);
+   n = alloc_instruction(ctx, OPCODE_POLYGON_MODE, 2);
    if (n) {
       n[1].e = face;
       n[2].e = mode;
@@ -2851,7 +3111,7 @@ save_PolygonStipple(const GLubyte * pattern)
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_POLYGON_STIPPLE, 1);
+   n = alloc_instruction(ctx, OPCODE_POLYGON_STIPPLE, 1);
    if (n) {
       n[1].data = unpack_image(ctx, 2, 32, 32, 1, GL_COLOR_INDEX, GL_BITMAP,
                                pattern, &ctx->Unpack);
@@ -2868,7 +3128,7 @@ save_PolygonOffset(GLfloat factor, GLfloat units)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_POLYGON_OFFSET, 2);
+   n = alloc_instruction(ctx, OPCODE_POLYGON_OFFSET, 2);
    if (n) {
       n[1].f = factor;
       n[2].f = units;
@@ -2893,7 +3153,7 @@ save_PopAttrib(void)
 {
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   (void) ALLOC_INSTRUCTION(ctx, OPCODE_POP_ATTRIB, 0);
+   (void) alloc_instruction(ctx, OPCODE_POP_ATTRIB, 0);
    if (ctx->ExecuteFlag) {
       CALL_PopAttrib(ctx->Exec, ());
    }
@@ -2905,7 +3165,7 @@ save_PopMatrix(void)
 {
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   (void) ALLOC_INSTRUCTION(ctx, OPCODE_POP_MATRIX, 0);
+   (void) alloc_instruction(ctx, OPCODE_POP_MATRIX, 0);
    if (ctx->ExecuteFlag) {
       CALL_PopMatrix(ctx->Exec, ());
    }
@@ -2917,7 +3177,7 @@ save_PopName(void)
 {
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   (void) ALLOC_INSTRUCTION(ctx, OPCODE_POP_NAME, 0);
+   (void) alloc_instruction(ctx, OPCODE_POP_NAME, 0);
    if (ctx->ExecuteFlag) {
       CALL_PopName(ctx->Exec, ());
    }
@@ -2934,7 +3194,7 @@ save_PrioritizeTextures(GLsizei num, const GLuint * textures,
 
    for (i = 0; i < num; i++) {
       Node *n;
-      n = ALLOC_INSTRUCTION(ctx, OPCODE_PRIORITIZE_TEXTURE, 2);
+      n = alloc_instruction(ctx, OPCODE_PRIORITIZE_TEXTURE, 2);
       if (n) {
          n[1].ui = textures[i];
          n[2].f = priorities[i];
@@ -2952,7 +3212,7 @@ save_PushAttrib(GLbitfield mask)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_PUSH_ATTRIB, 1);
+   n = alloc_instruction(ctx, OPCODE_PUSH_ATTRIB, 1);
    if (n) {
       n[1].bf = mask;
    }
@@ -2967,7 +3227,7 @@ save_PushMatrix(void)
 {
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   (void) ALLOC_INSTRUCTION(ctx, OPCODE_PUSH_MATRIX, 0);
+   (void) alloc_instruction(ctx, OPCODE_PUSH_MATRIX, 0);
    if (ctx->ExecuteFlag) {
       CALL_PushMatrix(ctx->Exec, ());
    }
@@ -2980,7 +3240,7 @@ save_PushName(GLuint name)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_PUSH_NAME, 1);
+   n = alloc_instruction(ctx, OPCODE_PUSH_NAME, 1);
    if (n) {
       n[1].ui = name;
    }
@@ -2996,7 +3256,7 @@ save_RasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_RASTER_POS, 4);
+   n = alloc_instruction(ctx, OPCODE_RASTER_POS, 4);
    if (n) {
       n[1].f = x;
       n[2].f = y;
@@ -3155,7 +3415,7 @@ save_PassThrough(GLfloat token)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_PASSTHROUGH, 1);
+   n = alloc_instruction(ctx, OPCODE_PASSTHROUGH, 1);
    if (n) {
       n[1].f = token;
    }
@@ -3171,7 +3431,7 @@ save_ReadBuffer(GLenum mode)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_READ_BUFFER, 1);
+   n = alloc_instruction(ctx, OPCODE_READ_BUFFER, 1);
    if (n) {
       n[1].e = mode;
    }
@@ -3187,7 +3447,7 @@ save_ResetHistogram(GLenum target)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_RESET_HISTOGRAM, 1);
+   n = alloc_instruction(ctx, OPCODE_RESET_HISTOGRAM, 1);
    if (n) {
       n[1].e = target;
    }
@@ -3203,7 +3463,7 @@ save_ResetMinmax(GLenum target)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_RESET_MIN_MAX, 1);
+   n = alloc_instruction(ctx, OPCODE_RESET_MIN_MAX, 1);
    if (n) {
       n[1].e = target;
    }
@@ -3219,7 +3479,7 @@ save_Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_ROTATE, 4);
+   n = alloc_instruction(ctx, OPCODE_ROTATE, 4);
    if (n) {
       n[1].f = angle;
       n[2].f = x;
@@ -3245,7 +3505,7 @@ save_Scalef(GLfloat x, GLfloat y, GLfloat z)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_SCALE, 3);
+   n = alloc_instruction(ctx, OPCODE_SCALE, 3);
    if (n) {
       n[1].f = x;
       n[2].f = y;
@@ -3270,7 +3530,7 @@ save_Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_SCISSOR, 4);
+   n = alloc_instruction(ctx, OPCODE_SCISSOR, 4);
    if (n) {
       n[1].i = x;
       n[2].i = y;
@@ -3304,7 +3564,7 @@ save_ShadeModel(GLenum mode)
    if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END)
       ctx->ListState.Current.ShadeModel = mode;
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_SHADE_MODEL, 1);
+   n = alloc_instruction(ctx, OPCODE_SHADE_MODEL, 1);
    if (n) {
       n[1].e = mode;
    }
@@ -3317,7 +3577,7 @@ save_StencilFunc(GLenum func, GLint ref, GLuint mask)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_FUNC, 3);
+   n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC, 3);
    if (n) {
       n[1].e = func;
       n[2].i = ref;
@@ -3335,7 +3595,7 @@ save_StencilMask(GLuint mask)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_MASK, 1);
+   n = alloc_instruction(ctx, OPCODE_STENCIL_MASK, 1);
    if (n) {
       n[1].ui = mask;
    }
@@ -3351,7 +3611,7 @@ save_StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_OP, 3);
+   n = alloc_instruction(ctx, OPCODE_STENCIL_OP, 3);
    if (n) {
       n[1].e = fail;
       n[2].e = zfail;
@@ -3369,7 +3629,7 @@ save_StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
+   n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
    if (n) {
       n[1].e = face;
       n[2].e = func;
@@ -3390,7 +3650,7 @@ save_StencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, GLint ref,
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
    /* GL_FRONT */
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
+   n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
    if (n) {
       n[1].e = GL_FRONT;
       n[2].e = frontfunc;
@@ -3398,7 +3658,7 @@ save_StencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, GLint ref,
       n[4].ui = mask;
    }
    /* GL_BACK */
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
+   n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
    if (n) {
       n[1].e = GL_BACK;
       n[2].e = backfunc;
@@ -3418,7 +3678,7 @@ save_StencilMaskSeparate(GLenum face, GLuint mask)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_MASK_SEPARATE, 2);
+   n = alloc_instruction(ctx, OPCODE_STENCIL_MASK_SEPARATE, 2);
    if (n) {
       n[1].e = face;
       n[2].ui = mask;
@@ -3435,7 +3695,7 @@ save_StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_OP_SEPARATE, 4);
+   n = alloc_instruction(ctx, OPCODE_STENCIL_OP_SEPARATE, 4);
    if (n) {
       n[1].e = face;
       n[2].e = fail;
@@ -3454,7 +3714,7 @@ save_TexEnvfv(GLenum target, GLenum pname, const GLfloat *params)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_TEXENV, 6);
+   n = alloc_instruction(ctx, OPCODE_TEXENV, 6);
    if (n) {
       n[1].e = target;
       n[2].e = pname;
@@ -3519,7 +3779,7 @@ save_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_TEXGEN, 6);
+   n = alloc_instruction(ctx, OPCODE_TEXGEN, 6);
    if (n) {
       n[1].e = coord;
       n[2].e = pname;
@@ -3594,7 +3854,7 @@ save_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_TEXPARAMETER, 6);
+   n = alloc_instruction(ctx, OPCODE_TEXPARAMETER, 6);
    if (n) {
       n[1].e = target;
       n[2].e = pname;
@@ -3654,7 +3914,7 @@ save_TexImage1D(GLenum target,
    else {
       Node *n;
       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-      n = ALLOC_INSTRUCTION(ctx, OPCODE_TEX_IMAGE1D, 8);
+      n = alloc_instruction(ctx, OPCODE_TEX_IMAGE1D, 8);
       if (n) {
          n[1].e = target;
          n[2].i = level;
@@ -3689,7 +3949,7 @@ save_TexImage2D(GLenum target,
    else {
       Node *n;
       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-      n = ALLOC_INSTRUCTION(ctx, OPCODE_TEX_IMAGE2D, 9);
+      n = alloc_instruction(ctx, OPCODE_TEX_IMAGE2D, 9);
       if (n) {
          n[1].e = target;
          n[2].i = level;
@@ -3727,7 +3987,7 @@ save_TexImage3D(GLenum target,
    else {
       Node *n;
       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-      n = ALLOC_INSTRUCTION(ctx, OPCODE_TEX_IMAGE3D, 10);
+      n = alloc_instruction(ctx, OPCODE_TEX_IMAGE3D, 10);
       if (n) {
          n[1].e = target;
          n[2].i = level;
@@ -3760,7 +4020,7 @@ save_TexSubImage1D(GLenum target, GLint level, GLint xoffset,
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_TEX_SUB_IMAGE1D, 7);
+   n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE1D, 7);
    if (n) {
       n[1].e = target;
       n[2].i = level;
@@ -3789,7 +4049,7 @@ save_TexSubImage2D(GLenum target, GLint level,
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_TEX_SUB_IMAGE2D, 9);
+   n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE2D, 9);
    if (n) {
       n[1].e = target;
       n[2].i = level;
@@ -3820,7 +4080,7 @@ save_TexSubImage3D(GLenum target, GLint level,
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_TEX_SUB_IMAGE3D, 11);
+   n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE3D, 11);
    if (n) {
       n[1].e = target;
       n[2].i = level;
@@ -3850,7 +4110,7 @@ save_Translatef(GLfloat x, GLfloat y, GLfloat z)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_TRANSLATE, 3);
+   n = alloc_instruction(ctx, OPCODE_TRANSLATE, 3);
    if (n) {
       n[1].f = x;
       n[2].f = y;
@@ -3876,7 +4136,7 @@ save_Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_VIEWPORT, 4);
+   n = alloc_instruction(ctx, OPCODE_VIEWPORT, 4);
    if (n) {
       n[1].i = x;
       n[2].i = y;
@@ -3895,7 +4155,7 @@ save_WindowPos4fMESA(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_WINDOW_POS, 4);
+   n = alloc_instruction(ctx, OPCODE_WINDOW_POS, 4);
    if (n) {
       n[1].f = x;
       n[2].f = y;
@@ -4056,7 +4316,7 @@ save_ActiveTextureARB(GLenum target)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_ACTIVE_TEXTURE, 1);
+   n = alloc_instruction(ctx, OPCODE_ACTIVE_TEXTURE, 1);
    if (n) {
       n[1].e = target;
    }
@@ -4129,7 +4389,7 @@ save_CompressedTexImage1DARB(GLenum target, GLint level,
          return;
       }
       MEMCPY(image, data, imageSize);
-      n = ALLOC_INSTRUCTION(ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D, 7);
+      n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D, 7);
       if (n) {
          n[1].e = target;
          n[2].i = level;
@@ -4175,7 +4435,7 @@ save_CompressedTexImage2DARB(GLenum target, GLint level,
          return;
       }
       MEMCPY(image, data, imageSize);
-      n = ALLOC_INSTRUCTION(ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D, 8);
+      n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D, 8);
       if (n) {
          n[1].e = target;
          n[2].i = level;
@@ -4222,7 +4482,7 @@ save_CompressedTexImage3DARB(GLenum target, GLint level,
          return;
       }
       MEMCPY(image, data, imageSize);
-      n = ALLOC_INSTRUCTION(ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D, 9);
+      n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D, 9);
       if (n) {
          n[1].e = target;
          n[2].i = level;
@@ -4265,7 +4525,7 @@ save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
       return;
    }
    MEMCPY(image, data, imageSize);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, 7);
+   n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, 7);
    if (n) {
       n[1].e = target;
       n[2].i = level;
@@ -4305,7 +4565,7 @@ save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
       return;
    }
    MEMCPY(image, data, imageSize);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, 9);
+   n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, 9);
    if (n) {
       n[1].e = target;
       n[2].i = level;
@@ -4347,7 +4607,7 @@ save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
       return;
    }
    MEMCPY(image, data, imageSize);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, 11);
+   n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, 11);
    if (n) {
       n[1].e = target;
       n[2].i = level;
@@ -4380,7 +4640,7 @@ save_SampleCoverageARB(GLclampf value, GLboolean invert)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_SAMPLE_COVERAGE, 2);
+   n = alloc_instruction(ctx, OPCODE_SAMPLE_COVERAGE, 2);
    if (n) {
       n[1].f = value;
       n[2].b = invert;
@@ -4401,7 +4661,7 @@ save_BindProgramNV(GLenum target, GLuint id)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_BIND_PROGRAM_NV, 2);
+   n = alloc_instruction(ctx, OPCODE_BIND_PROGRAM_NV, 2);
    if (n) {
       n[1].e = target;
       n[2].ui = id;
@@ -4418,7 +4678,7 @@ save_ProgramEnvParameter4fARB(GLenum target, GLuint index,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6);
+   n = alloc_instruction(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6);
    if (n) {
       n[1].e = target;
       n[2].ui = index;
@@ -4455,7 +4715,7 @@ save_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
       const GLfloat * p = params;
 
       for (i = 0 ; i < count ; i++) {
-        n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6);
+        n = alloc_instruction(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6);
         if (n) {
            n[1].e = target;
            n[2].ui = index;
@@ -4503,7 +4763,7 @@ save_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_EXECUTE_PROGRAM_NV, 6);
+   n = alloc_instruction(ctx, OPCODE_EXECUTE_PROGRAM_NV, 6);
    if (n) {
       n[1].e = target;
       n[2].ui = id;
@@ -4549,7 +4809,7 @@ save_LoadProgramNV(GLenum target, GLuint id, GLsizei len,
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_LOAD_PROGRAM_NV, 4);
+   n = alloc_instruction(ctx, OPCODE_LOAD_PROGRAM_NV, 4);
    if (n) {
       GLubyte *programCopy = (GLubyte *) _mesa_malloc(len);
       if (!programCopy) {
@@ -4576,7 +4836,7 @@ save_RequestResidentProgramsNV(GLsizei num, const GLuint * ids)
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_TRACK_MATRIX_NV, 2);
+   n = alloc_instruction(ctx, OPCODE_TRACK_MATRIX_NV, 2);
    if (n) {
       GLuint *idCopy = (GLuint *) _mesa_malloc(num * sizeof(GLuint));
       if (!idCopy) {
@@ -4600,7 +4860,7 @@ save_TrackMatrixNV(GLenum target, GLuint address,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_TRACK_MATRIX_NV, 4);
+   n = alloc_instruction(ctx, OPCODE_TRACK_MATRIX_NV, 4);
    if (n) {
       n[1].e = target;
       n[2].ui = address;
@@ -4625,7 +4885,7 @@ save_ProgramLocalParameter4fARB(GLenum target, GLuint index,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
+   n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
    if (n) {
       n[1].e = target;
       n[2].ui = index;
@@ -4647,7 +4907,7 @@ save_ProgramLocalParameter4fvARB(GLenum target, GLuint index,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
+   n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
    if (n) {
       n[1].e = target;
       n[2].ui = index;
@@ -4675,7 +4935,7 @@ save_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
       const GLfloat * p = params;
 
       for (i = 0 ; i < count ; i++) {
-        n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
+        n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
         if (n) {
            n[1].e = target;
            n[2].ui = index;
@@ -4702,7 +4962,7 @@ save_ProgramLocalParameter4dARB(GLenum target, GLuint index,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
+   n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
    if (n) {
       n[1].e = target;
       n[2].ui = index;
@@ -4724,7 +4984,7 @@ save_ProgramLocalParameter4dvARB(GLenum target, GLuint index,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
+   n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
    if (n) {
       n[1].e = target;
       n[2].ui = index;
@@ -4747,7 +5007,7 @@ save_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte * name,
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_NAMED_PARAMETER_NV, 6);
+   n = alloc_instruction(ctx, OPCODE_PROGRAM_NAMED_PARAMETER_NV, 6);
    if (n) {
       GLubyte *nameCopy = (GLubyte *) _mesa_malloc(len);
       if (!nameCopy) {
@@ -4806,7 +5066,7 @@ save_ActiveStencilFaceEXT(GLenum face)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_ACTIVE_STENCIL_FACE_EXT, 1);
+   n = alloc_instruction(ctx, OPCODE_ACTIVE_STENCIL_FACE_EXT, 1);
    if (n) {
       n[1].e = face;
    }
@@ -4823,7 +5083,7 @@ save_DepthBoundsEXT(GLclampd zmin, GLclampd zmax)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_DEPTH_BOUNDS_EXT, 2);
+   n = alloc_instruction(ctx, OPCODE_DEPTH_BOUNDS_EXT, 2);
    if (n) {
       n[1].f = (GLfloat) zmin;
       n[2].f = (GLfloat) zmax;
@@ -4846,7 +5106,7 @@ save_ProgramStringARB(GLenum target, GLenum format, GLsizei len,
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_STRING_ARB, 4);
+   n = alloc_instruction(ctx, OPCODE_PROGRAM_STRING_ARB, 4);
    if (n) {
       GLubyte *programCopy = (GLubyte *) _mesa_malloc(len);
       if (!programCopy) {
@@ -4875,7 +5135,7 @@ save_BeginQueryARB(GLenum target, GLuint id)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_BEGIN_QUERY_ARB, 2);
+   n = alloc_instruction(ctx, OPCODE_BEGIN_QUERY_ARB, 2);
    if (n) {
       n[1].e = target;
       n[2].ui = id;
@@ -4892,7 +5152,7 @@ save_EndQueryARB(GLenum target)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_END_QUERY_ARB, 1);
+   n = alloc_instruction(ctx, OPCODE_END_QUERY_ARB, 1);
    if (n) {
       n[1].e = target;
    }
@@ -4910,7 +5170,7 @@ save_DrawBuffersARB(GLsizei count, const GLenum * buffers)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_DRAW_BUFFERS_ARB, 1 + MAX_DRAW_BUFFERS);
+   n = alloc_instruction(ctx, OPCODE_DRAW_BUFFERS_ARB, 1 + MAX_DRAW_BUFFERS);
    if (n) {
       GLint i;
       n[1].i = count;
@@ -4931,7 +5191,7 @@ save_TexBumpParameterfvATI(GLenum pname, const GLfloat *param)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_TEX_BUMP_PARAMETER_ATI, 5);
+   n = alloc_instruction(ctx, OPCODE_TEX_BUMP_PARAMETER_ATI, 5);
    if (n) {
       n[1].ui = pname;
       n[2].f = param[0];
@@ -4962,7 +5222,7 @@ save_BindFragmentShaderATI(GLuint id)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_BIND_FRAGMENT_SHADER_ATI, 1);
+   n = alloc_instruction(ctx, OPCODE_BIND_FRAGMENT_SHADER_ATI, 1);
    if (n) {
       n[1].ui = id;
    }
@@ -4977,7 +5237,7 @@ save_SetFragmentShaderConstantATI(GLuint dst, const GLfloat *value)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI, 5);
+   n = alloc_instruction(ctx, OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI, 5);
    if (n) {
       n[1].ui = dst;
       n[2].f = value[0];
@@ -4997,7 +5257,7 @@ save_Attr1fNV(GLenum attr, GLfloat x)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    SAVE_FLUSH_VERTICES(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_ATTR_1F_NV, 2);
+   n = alloc_instruction(ctx, OPCODE_ATTR_1F_NV, 2);
    if (n) {
       n[1].e = attr;
       n[2].f = x;
@@ -5018,7 +5278,7 @@ save_Attr2fNV(GLenum attr, GLfloat x, GLfloat y)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    SAVE_FLUSH_VERTICES(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_ATTR_2F_NV, 3);
+   n = alloc_instruction(ctx, OPCODE_ATTR_2F_NV, 3);
    if (n) {
       n[1].e = attr;
       n[2].f = x;
@@ -5040,7 +5300,7 @@ save_Attr3fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    SAVE_FLUSH_VERTICES(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_ATTR_3F_NV, 4);
+   n = alloc_instruction(ctx, OPCODE_ATTR_3F_NV, 4);
    if (n) {
       n[1].e = attr;
       n[2].f = x;
@@ -5063,7 +5323,7 @@ save_Attr4fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    SAVE_FLUSH_VERTICES(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_ATTR_4F_NV, 5);
+   n = alloc_instruction(ctx, OPCODE_ATTR_4F_NV, 5);
    if (n) {
       n[1].e = attr;
       n[2].f = x;
@@ -5088,7 +5348,7 @@ save_Attr1fARB(GLenum attr, GLfloat x)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    SAVE_FLUSH_VERTICES(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_ATTR_1F_ARB, 2);
+   n = alloc_instruction(ctx, OPCODE_ATTR_1F_ARB, 2);
    if (n) {
       n[1].e = attr;
       n[2].f = x;
@@ -5109,7 +5369,7 @@ save_Attr2fARB(GLenum attr, GLfloat x, GLfloat y)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    SAVE_FLUSH_VERTICES(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_ATTR_2F_ARB, 3);
+   n = alloc_instruction(ctx, OPCODE_ATTR_2F_ARB, 3);
    if (n) {
       n[1].e = attr;
       n[2].f = x;
@@ -5131,7 +5391,7 @@ save_Attr3fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    SAVE_FLUSH_VERTICES(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_ATTR_3F_ARB, 4);
+   n = alloc_instruction(ctx, OPCODE_ATTR_3F_ARB, 4);
    if (n) {
       n[1].e = attr;
       n[2].f = x;
@@ -5154,7 +5414,7 @@ save_Attr4fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    SAVE_FLUSH_VERTICES(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_ATTR_4F_ARB, 5);
+   n = alloc_instruction(ctx, OPCODE_ATTR_4F_ARB, 5);
    if (n) {
       n[1].e = attr;
       n[2].f = x;
@@ -5179,7 +5439,7 @@ save_EvalCoord1f(GLfloat x)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    SAVE_FLUSH_VERTICES(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_EVAL_C1, 1);
+   n = alloc_instruction(ctx, OPCODE_EVAL_C1, 1);
    if (n) {
       n[1].f = x;
    }
@@ -5200,7 +5460,7 @@ save_EvalCoord2f(GLfloat x, GLfloat y)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    SAVE_FLUSH_VERTICES(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_EVAL_C2, 2);
+   n = alloc_instruction(ctx, OPCODE_EVAL_C2, 2);
    if (n) {
       n[1].f = x;
       n[2].f = y;
@@ -5223,7 +5483,7 @@ save_EvalPoint1(GLint x)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    SAVE_FLUSH_VERTICES(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_EVAL_P1, 1);
+   n = alloc_instruction(ctx, OPCODE_EVAL_P1, 1);
    if (n) {
       n[1].i = x;
    }
@@ -5238,7 +5498,7 @@ save_EvalPoint2(GLint x, GLint y)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    SAVE_FLUSH_VERTICES(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_EVAL_P2, 2);
+   n = alloc_instruction(ctx, OPCODE_EVAL_P2, 2);
    if (n) {
       n[1].i = x;
       n[2].i = y;
@@ -5341,7 +5601,7 @@ save_Materialfv(GLenum face, GLenum pname, const GLfloat * param)
 
    SAVE_FLUSH_VERTICES(ctx);
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_MATERIAL, 6);
+   n = alloc_instruction(ctx, OPCODE_MATERIAL, 6);
    if (n) {
       n[1].e = face;
       n[2].e = pname;
@@ -5384,7 +5644,7 @@ save_Begin(GLenum mode)
          return;
 
       SAVE_FLUSH_VERTICES(ctx);
-      n = ALLOC_INSTRUCTION(ctx, OPCODE_BEGIN, 1);
+      n = alloc_instruction(ctx, OPCODE_BEGIN, 1);
       if (n) {
          n[1].e = mode;
       }
@@ -5400,7 +5660,7 @@ save_End(void)
 {
    GET_CURRENT_CONTEXT(ctx);
    SAVE_FLUSH_VERTICES(ctx);
-   (void) ALLOC_INSTRUCTION(ctx, OPCODE_END, 0);
+   (void) alloc_instruction(ctx, OPCODE_END, 0);
    ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END;
    if (ctx->ExecuteFlag) {
       CALL_End(ctx->Exec, ());
@@ -5413,7 +5673,7 @@ save_Rectf(GLfloat a, GLfloat b, GLfloat c, GLfloat d)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    SAVE_FLUSH_VERTICES(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_RECTF, 4);
+   n = alloc_instruction(ctx, OPCODE_RECTF, 4);
    if (n) {
       n[1].f = a;
       n[2].f = b;
@@ -5827,7 +6087,7 @@ save_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_BLIT_FRAMEBUFFER, 10);
+   n = alloc_instruction(ctx, OPCODE_BLIT_FRAMEBUFFER, 10);
    if (n) {
       n[1].i = srcX0;
       n[2].i = srcY0;
@@ -5856,7 +6116,7 @@ save_ProvokingVertexEXT(GLenum mode)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_PROVOKING_VERTEX, 1);
+   n = alloc_instruction(ctx, OPCODE_PROVOKING_VERTEX, 1);
    if (n) {
       n[1].e = mode;
    }
@@ -5874,7 +6134,7 @@ save_UseProgramObjectARB(GLhandleARB program)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_USE_PROGRAM, 1);
+   n = alloc_instruction(ctx, OPCODE_USE_PROGRAM, 1);
    if (n) {
       n[1].ui = program;
    }
@@ -5890,7 +6150,7 @@ save_Uniform1fARB(GLint location, GLfloat x)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_1F, 2);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_1F, 2);
    if (n) {
       n[1].i = location;
       n[2].f = x;
@@ -5907,7 +6167,7 @@ save_Uniform2fARB(GLint location, GLfloat x, GLfloat y)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_2F, 3);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_2F, 3);
    if (n) {
       n[1].i = location;
       n[2].f = x;
@@ -5925,7 +6185,7 @@ save_Uniform3fARB(GLint location, GLfloat x, GLfloat y, GLfloat z)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_3F, 4);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_3F, 4);
    if (n) {
       n[1].i = location;
       n[2].f = x;
@@ -5944,7 +6204,7 @@ save_Uniform4fARB(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_4F, 5);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_4F, 5);
    if (n) {
       n[1].i = location;
       n[2].f = x;
@@ -5975,7 +6235,7 @@ save_Uniform1fvARB(GLint location, GLsizei count, const GLfloat *v)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_1FV, 3);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_1FV, 3);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -5992,7 +6252,7 @@ save_Uniform2fvARB(GLint location, GLsizei count, const GLfloat *v)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_2FV, 3);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_2FV, 3);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -6009,7 +6269,7 @@ save_Uniform3fvARB(GLint location, GLsizei count, const GLfloat *v)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_3FV, 3);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_3FV, 3);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -6026,7 +6286,7 @@ save_Uniform4fvARB(GLint location, GLsizei count, const GLfloat *v)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_4FV, 3);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_4FV, 3);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -6044,7 +6304,7 @@ save_Uniform1iARB(GLint location, GLint x)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_1I, 2);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_1I, 2);
    if (n) {
       n[1].i = location;
       n[2].i = x;
@@ -6060,7 +6320,7 @@ save_Uniform2iARB(GLint location, GLint x, GLint y)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_2I, 3);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_2I, 3);
    if (n) {
       n[1].i = location;
       n[2].i = x;
@@ -6077,7 +6337,7 @@ save_Uniform3iARB(GLint location, GLint x, GLint y, GLint z)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_3I, 4);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_3I, 4);
    if (n) {
       n[1].i = location;
       n[2].i = x;
@@ -6095,7 +6355,7 @@ save_Uniform4iARB(GLint location, GLint x, GLint y, GLint z, GLint w)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_4I, 5);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_4I, 5);
    if (n) {
       n[1].i = location;
       n[2].i = x;
@@ -6116,7 +6376,7 @@ save_Uniform1ivARB(GLint location, GLsizei count, const GLint *v)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_1IV, 3);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_1IV, 3);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -6133,7 +6393,7 @@ save_Uniform2ivARB(GLint location, GLsizei count, const GLint *v)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_2IV, 3);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_2IV, 3);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -6150,7 +6410,7 @@ save_Uniform3ivARB(GLint location, GLsizei count, const GLint *v)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_3IV, 3);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_3IV, 3);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -6167,7 +6427,7 @@ save_Uniform4ivARB(GLint location, GLsizei count, const GLint *v)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_4IV, 3);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_4IV, 3);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -6186,7 +6446,7 @@ save_UniformMatrix2fvARB(GLint location, GLsizei count, GLboolean transpose,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_MATRIX22, 4);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX22, 4);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -6205,7 +6465,7 @@ save_UniformMatrix3fvARB(GLint location, GLsizei count, GLboolean transpose,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_MATRIX33, 4);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX33, 4);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -6224,7 +6484,7 @@ save_UniformMatrix4fvARB(GLint location, GLsizei count, GLboolean transpose,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_MATRIX44, 4);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX44, 4);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -6244,7 +6504,7 @@ save_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_MATRIX23, 4);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX23, 4);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -6263,7 +6523,7 @@ save_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_MATRIX32, 4);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX32, 4);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -6283,7 +6543,7 @@ save_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_MATRIX24, 4);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX24, 4);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -6302,7 +6562,7 @@ save_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_MATRIX42, 4);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX42, 4);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -6322,7 +6582,7 @@ save_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_MATRIX34, 4);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX34, 4);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -6341,7 +6601,7 @@ save_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_MATRIX43, 4);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX43, 4);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -6365,7 +6625,7 @@ static void
 save_error(GLcontext *ctx, GLenum error, const char *s)
 {
    Node *n;
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_ERROR, 2);
+   n = alloc_instruction(ctx, OPCODE_ERROR, 2);
    if (n) {
       n[1].e = error;
       n[2].data = (void *) s;
@@ -6441,13 +6701,10 @@ execute_list(GLcontext *ctx, GLuint list)
 
    done = GL_FALSE;
    while (!done) {
-      OpCode opcode = n[0].opcode;
-      int i = (int) n[0].opcode - (int) OPCODE_EXT_0;
+      const OpCode opcode = n[0].opcode;
 
-      if (i >= 0 && i < (GLint) ctx->ListExt.NumOpcodes) {
-         /* this is a driver-extended opcode */
-         ctx->ListExt.Opcode[i].Execute(ctx, &n[1]);
-         n += ctx->ListExt.Opcode[i].Size;
+      if (is_ext_opcode(opcode)) {
+         n += ext_opcode_execute(ctx, n);
       }
       else {
          switch (opcode) {
@@ -6506,6 +6763,39 @@ execute_list(GLcontext *ctx, GLuint list)
          case OPCODE_CLEAR:
             CALL_Clear(ctx->Exec, (n[1].bf));
             break;
+         case OPCODE_CLEAR_BUFFER_IV:
+            {
+               GLint value[4];
+               value[0] = n[3].i;
+               value[1] = n[4].i;
+               value[2] = n[5].i;
+               value[3] = n[6].i;
+               /*CALL_ClearBufferiv(ctx->Exec, (n[1].e, n[2].i, value));*/
+            }
+            break;
+         case OPCODE_CLEAR_BUFFER_UIV:
+            {
+               GLuint value[4];
+               value[0] = n[3].ui;
+               value[1] = n[4].ui;
+               value[2] = n[5].ui;
+               value[3] = n[6].ui;
+               /*CALL_ClearBufferiv(ctx->Exec, (n[1].e, n[2].i, value));*/
+            }
+            break;
+         case OPCODE_CLEAR_BUFFER_FV:
+            {
+               GLfloat value[4];
+               value[0] = n[3].f;
+               value[1] = n[4].f;
+               value[2] = n[5].f;
+               value[3] = n[6].f;
+               /*CALL_ClearBufferfv(ctx->Exec, (n[1].e, n[2].i, value));*/
+            }
+            break;
+         case OPCODE_CLEAR_BUFFER_FI:
+            /*CALL_ClearBufferfi(ctx->Exec, (n[1].e, n[2].i, n[3].f, n[4].i));*/
+            break;
          case OPCODE_CLEAR_COLOR:
             CALL_ClearColor(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
             break;
@@ -6534,6 +6824,10 @@ execute_list(GLcontext *ctx, GLuint list)
          case OPCODE_COLOR_MASK:
             CALL_ColorMask(ctx->Exec, (n[1].b, n[2].b, n[3].b, n[4].b));
             break;
+         case OPCODE_COLOR_MASK_INDEXED:
+            CALL_ColorMaskIndexedEXT(ctx->Exec, (n[1].ui, n[2].b, n[3].b,
+                                                 n[4].b, n[5].b));
+            break;
          case OPCODE_COLOR_MATERIAL:
             CALL_ColorMaterial(ctx->Exec, (n[1].e, n[2].e));
             break;
@@ -6676,6 +6970,9 @@ execute_list(GLcontext *ctx, GLuint list)
          case OPCODE_DISABLE:
             CALL_Disable(ctx->Exec, (n[1].e));
             break;
+         case OPCODE_DISABLE_INDEXED:
+            CALL_DisableIndexedEXT(ctx->Exec, (n[1].ui, n[2].e));
+            break;
          case OPCODE_DRAW_BUFFER:
             CALL_DrawBuffer(ctx->Exec, (n[1].e));
             break;
@@ -6691,6 +6988,9 @@ execute_list(GLcontext *ctx, GLuint list)
          case OPCODE_ENABLE:
             CALL_Enable(ctx->Exec, (n[1].e));
             break;
+         case OPCODE_ENABLE_INDEXED:
+            CALL_EnableIndexedEXT(ctx->Exec, (n[1].ui, n[2].e));
+            break;
          case OPCODE_EVALMESH1:
             CALL_EvalMesh1(ctx->Exec, (n[1].e, n[2].i, n[3].i));
             break;
@@ -7583,7 +7883,7 @@ _mesa_EndList(void)
     */
    ctx->Driver.EndList(ctx);
 
-   (void) ALLOC_INSTRUCTION(ctx, OPCODE_END_OF_LIST, 0);
+   (void) alloc_instruction(ctx, OPCODE_END_OF_LIST, 0);
 
    /* Destroy old list, if any */
    destroy_list(ctx, ctx->ListState.CurrentList->Name);
@@ -8450,6 +8750,7 @@ _mesa_init_save_table(struct _glapi_table *table)
    SET_ClearStencil(table, save_ClearStencil);
    SET_ClipPlane(table, save_ClipPlane);
    SET_ColorMask(table, save_ColorMask);
+   SET_ColorMaskIndexedEXT(table, save_ColorMaskIndexed);
    SET_ColorMaterial(table, save_ColorMaterial);
    SET_CopyPixels(table, save_CopyPixels);
    SET_CullFace(table, save_CullFace);
@@ -8458,9 +8759,11 @@ _mesa_init_save_table(struct _glapi_table *table)
    SET_DepthMask(table, save_DepthMask);
    SET_DepthRange(table, save_DepthRange);
    SET_Disable(table, save_Disable);
+   SET_DisableIndexedEXT(table, save_DisableIndexed);
    SET_DrawBuffer(table, save_DrawBuffer);
    SET_DrawPixels(table, save_DrawPixels);
    SET_Enable(table, save_Enable);
+   SET_EnableIndexedEXT(table, save_EnableIndexed);
    SET_EndList(table, _mesa_EndList);
    SET_EvalMesh1(table, save_EvalMesh1);
    SET_EvalMesh2(table, save_EvalMesh2);
@@ -9004,6 +9307,19 @@ _mesa_init_save_table(struct _glapi_table *table)
 
    /* 364. GL_EXT_provoking_vertex */
    SET_ProvokingVertexEXT(table, save_ProvokingVertexEXT);
+
+   /* GL 3.0 */
+#if 0
+   SET_ClearBufferiv(table, save_ClearBufferiv);
+   SET_ClearBufferuiv(table, save_ClearBufferuiv);
+   SET_ClearBufferfv(table, save_ClearBufferfv);
+   SET_ClearBufferfi(table, save_ClearBufferfi);
+#else
+   (void) save_ClearBufferiv;
+   (void) save_ClearBufferuiv;
+   (void) save_ClearBufferfv;
+   (void) save_ClearBufferfi;
+#endif
 }
 
 
@@ -9041,13 +9357,10 @@ print_list(GLcontext *ctx, GLuint list)
 
    done = n ? GL_FALSE : GL_TRUE;
    while (!done) {
-      OpCode opcode = n[0].opcode;
-      GLint i = (GLint) n[0].opcode - (GLint) OPCODE_EXT_0;
+      const OpCode opcode = n[0].opcode;
 
-      if (i >= 0 && i < (GLint) ctx->ListExt.NumOpcodes) {
-         /* this is a driver-extended opcode */
-         ctx->ListExt.Opcode[i].Print(ctx, &n[1]);
-         n += ctx->ListExt.Opcode[i].Size;
+      if (is_ext_opcode(opcode)) {
+         n += ext_opcode_print(ctx, n);
       }
       else {
          switch (opcode) {
@@ -9425,6 +9738,9 @@ _mesa_init_display_list(GLcontext *ctx)
       tableInitialized = GL_TRUE;
    }
 
+   /* extension info */
+   ctx->ListExt = CALLOC_STRUCT(gl_list_extensions);
+
    /* Display list */
    ctx->ListState.CallDepth = 0;
    ctx->ExecuteFlag = GL_TRUE;
@@ -9439,3 +9755,11 @@ _mesa_init_display_list(GLcontext *ctx)
    _mesa_save_vtxfmt_init(&ctx->ListState.ListVtxfmt);
 #endif
 }
+
+
+void
+_mesa_free_display_list_data(GLcontext *ctx)
+{
+   free(ctx->ListExt);
+   ctx->ListExt = NULL;
+}
index af36991d5eca1cb8447b5d17a4c21989bf036c07..f37a93a7f4bf4e6631bcdc1f0f72900e2b641747 100644 (file)
@@ -61,12 +61,12 @@ extern void GLAPIENTRY _mesa_CallLists( GLsizei n, GLenum type, const GLvoid *li
 
 extern void _mesa_compile_error( GLcontext *ctx, GLenum error, const char *s );
 
-extern void *_mesa_alloc_instruction(GLcontext *ctx, GLuint opcode, GLuint sz);
+extern void *_mesa_dlist_alloc(GLcontext *ctx, GLuint opcode, GLuint sz);
 
-extern GLint _mesa_alloc_opcode( GLcontext *ctx, GLuint sz,
-                                 void (*execute)( GLcontext *, void * ),
-                                 void (*destroy)( GLcontext *, void * ),
-                                 void (*print)( GLcontext *, void * ) );
+extern GLint _mesa_dlist_alloc_opcode( GLcontext *ctx, GLuint sz,
+                                       void (*execute)( GLcontext *, void * ),
+                                       void (*destroy)( GLcontext *, void * ),
+                                       void (*print)( GLcontext *, void * ) );
 
 extern void _mesa_delete_list(GLcontext *ctx, struct gl_display_list *dlist);
 
@@ -106,5 +106,7 @@ _mesa_init_dlist_dispatch(struct _glapi_table *disp)
 
 extern void _mesa_init_display_list( GLcontext * ctx );
 
+extern void _mesa_free_display_list_data(GLcontext *ctx);
+
 
 #endif /* DLIST_H */
index 414cfad8e269ee178493bf74367c860a14245fcd..81e032081db451e69167d33f580ccf63e5f8f0e3 100644 (file)
@@ -31,7 +31,7 @@
 #include "compiler.h"
 #include "dlopen.h"
 
-#if defined(_GNU_SOURCE) && !defined(__MINGW32__)
+#if defined(_GNU_SOURCE) && !defined(__MINGW32__) && !defined(__blrts)
 #include <dlfcn.h>
 #endif
 #if defined(_WIN32)
@@ -46,7 +46,9 @@
 void *
 _mesa_dlopen(const char *libname, int flags)
 {
-#if defined(_GNU_SOURCE)
+#if defined(__blrts)
+   return NULL;
+#elif defined(_GNU_SOURCE)
    flags = RTLD_LAZY | RTLD_GLOBAL; /* Overriding flags at this time */
    return dlopen(libname, flags);
 #elif defined(__MINGW32__)
@@ -65,7 +67,9 @@ _mesa_dlopen(const char *libname, int flags)
 GenericFunc
 _mesa_dlsym(void *handle, const char *fname)
 {
-#if defined(__DJGPP__)
+#if defined(__blrts)
+   return (GenericFunc) NULL;
+#elif defined(__DJGPP__)
    /* need '_' prefix on symbol names */
    char fname2[1000];
    fname2[0] = '_';
@@ -88,7 +92,9 @@ _mesa_dlsym(void *handle, const char *fname)
 void
 _mesa_dlclose(void *handle)
 {
-#if defined(_GNU_SOURCE)
+#if defined(__blrts)
+   (void) handle;
+#elif defined(_GNU_SOURCE)
    dlclose(handle);
 #elif defined(__MINGW32__)
    FreeLibrary(handle);
index 4383aed6692de7ca54e419f4bd80acc423e6987f..cd6e881ad2d93f082c4061100ded10155cda9d5c 100644 (file)
 static void
 client_state(GLcontext *ctx, GLenum cap, GLboolean state)
 {
+   struct gl_array_object *arrayObj = ctx->Array.ArrayObj;
    GLuint flag;
    GLboolean *var;
 
    switch (cap) {
       case GL_VERTEX_ARRAY:
-         var = &ctx->Array.ArrayObj->Vertex.Enabled;
+         var = &arrayObj->Vertex.Enabled;
          flag = _NEW_ARRAY_VERTEX;
          break;
       case GL_NORMAL_ARRAY:
-         var = &ctx->Array.ArrayObj->Normal.Enabled;
+         var = &arrayObj->Normal.Enabled;
          flag = _NEW_ARRAY_NORMAL;
          break;
       case GL_COLOR_ARRAY:
-         var = &ctx->Array.ArrayObj->Color.Enabled;
+         var = &arrayObj->Color.Enabled;
          flag = _NEW_ARRAY_COLOR0;
          break;
       case GL_INDEX_ARRAY:
-         var = &ctx->Array.ArrayObj->Index.Enabled;
+         var = &arrayObj->Index.Enabled;
          flag = _NEW_ARRAY_INDEX;
          break;
       case GL_TEXTURE_COORD_ARRAY:
-         var = &ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled;
+         var = &arrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled;
          flag = _NEW_ARRAY_TEXCOORD(ctx->Array.ActiveTexture);
          break;
       case GL_EDGE_FLAG_ARRAY:
-         var = &ctx->Array.ArrayObj->EdgeFlag.Enabled;
+         var = &arrayObj->EdgeFlag.Enabled;
          flag = _NEW_ARRAY_EDGEFLAG;
          break;
       case GL_FOG_COORDINATE_ARRAY_EXT:
-         var = &ctx->Array.ArrayObj->FogCoord.Enabled;
+         var = &arrayObj->FogCoord.Enabled;
          flag = _NEW_ARRAY_FOGCOORD;
          break;
       case GL_SECONDARY_COLOR_ARRAY_EXT:
-         var = &ctx->Array.ArrayObj->SecondaryColor.Enabled;
+         var = &arrayObj->SecondaryColor.Enabled;
          flag = _NEW_ARRAY_COLOR1;
          break;
 
 #if FEATURE_point_size_array
       case GL_POINT_SIZE_ARRAY_OES:
-         var = &ctx->Array.ArrayObj->PointSize.Enabled;
+         var = &arrayObj->PointSize.Enabled;
          flag = _NEW_ARRAY_POINT_SIZE;
          break;
 #endif
@@ -120,7 +121,7 @@ client_state(GLcontext *ctx, GLenum cap, GLboolean state)
          {
             GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV;
             ASSERT(n < Elements(ctx->Array.ArrayObj->VertexAttrib));
-            var = &ctx->Array.ArrayObj->VertexAttrib[n].Enabled;
+            var = &arrayObj->VertexAttrib[n].Enabled;
             flag = _NEW_ARRAY_ATTRIB(n);
          }
          break;
@@ -277,10 +278,13 @@ _mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state)
          ctx->Eval.AutoNormal = state;
          break;
       case GL_BLEND:
-         if (ctx->Color.BlendEnabled == state)
-            return;
-         FLUSH_VERTICES(ctx, _NEW_COLOR);
-         ctx->Color.BlendEnabled = state;
+         {
+            GLbitfield newEnabled = state * ((1 << ctx->Const.MaxDrawBuffers) - 1);
+            if (newEnabled != ctx->Color.BlendEnabled) {
+               FLUSH_VERTICES(ctx, _NEW_COLOR);
+               ctx->Color.BlendEnabled = newEnabled;
+            }
+         }
          break;
 #if FEATURE_userclip
       case GL_CLIP_PLANE0:
@@ -1019,6 +1023,84 @@ _mesa_Disable( GLenum cap )
 }
 
 
+
+/**
+ * Enable/disable an indexed state var.
+ */
+void
+_mesa_set_enablei(GLcontext *ctx, GLenum cap, GLuint index, GLboolean state)
+{
+   ASSERT(state == 0 || state == 1);
+   switch (cap) {
+   case GL_BLEND:
+      if (!ctx->Extensions.EXT_draw_buffers2) {
+         goto bad_cap_error;
+      }
+      if (index >= ctx->Const.MaxDrawBuffers) {
+         _mesa_error(ctx, GL_INVALID_VALUE, "%s(index=%u)",
+                     state ? "glEnableIndexed" : "glDisableIndexed", index);
+         return;
+      }
+      if (((ctx->Color.BlendEnabled >> index) & 1) != state) {
+         FLUSH_VERTICES(ctx, _NEW_COLOR);
+         if (state)
+            ctx->Color.BlendEnabled |= (1 << index);
+         else
+            ctx->Color.BlendEnabled &= ~(1 << index);
+      }
+      break;
+   default:
+      goto bad_cap_error;
+   }
+   return;
+
+bad_cap_error:
+    _mesa_error(ctx, GL_INVALID_ENUM, "%s(cap=%s)",
+                state ? "glEnablei" : "glDisablei",
+                _mesa_lookup_enum_by_nr(cap));
+}
+
+
+void GLAPIENTRY
+_mesa_DisableIndexed( GLenum cap, GLuint index )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   ASSERT_OUTSIDE_BEGIN_END(ctx);
+   _mesa_set_enablei(ctx, cap, index, GL_FALSE);
+}
+
+
+void GLAPIENTRY
+_mesa_EnableIndexed( GLenum cap, GLuint index )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   ASSERT_OUTSIDE_BEGIN_END(ctx);
+   _mesa_set_enablei(ctx, cap, index, GL_TRUE);
+}
+
+
+GLboolean GLAPIENTRY
+_mesa_IsEnabledIndexed( GLenum cap, GLuint index )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   switch (cap) {
+   case GL_BLEND:
+      if (index >= ctx->Const.MaxDrawBuffers) {
+         _mesa_error(ctx, GL_INVALID_VALUE, "glIsEnabledIndexed(index=%u)",
+                     index);
+         return GL_FALSE;
+      }
+      return (ctx->Color.BlendEnabled >> index) & 1;
+   default:
+      _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabledIndexed(cap=%s)",
+                  _mesa_lookup_enum_by_nr(cap));
+      return GL_FALSE;
+   }
+}
+
+
+
+
 #undef CHECK_EXTENSION
 #define CHECK_EXTENSION(EXTNAME)                       \
    if (!ctx->Extensions.EXTNAME) {                     \
@@ -1065,7 +1147,7 @@ _mesa_IsEnabled( GLenum cap )
       case GL_AUTO_NORMAL:
         return ctx->Eval.AutoNormal;
       case GL_BLEND:
-         return ctx->Color.BlendEnabled;
+         return ctx->Color.BlendEnabled & 1;  /* return state for buffer[0] */
       case GL_CLIP_PLANE0:
       case GL_CLIP_PLANE1:
       case GL_CLIP_PLANE2:
index 25c90b0275ad750f74c20d46a3195c01a577dc0d..24e3181a8bae8cb6b1480e21639ba519ed8fc68d 100644 (file)
@@ -47,6 +47,18 @@ _mesa_Enable( GLenum cap );
 extern GLboolean GLAPIENTRY
 _mesa_IsEnabled( GLenum cap );
 
+extern void
+_mesa_set_enablei(GLcontext *ctx, GLenum cap, GLuint index, GLboolean state);
+
+extern void GLAPIENTRY
+_mesa_DisableIndexed( GLenum cap, GLuint index );
+
+extern void GLAPIENTRY
+_mesa_EnableIndexed( GLenum cap, GLuint index );
+
+extern GLboolean GLAPIENTRY
+_mesa_IsEnabledIndexed( GLenum cap, GLuint index );
+
 extern void GLAPIENTRY
 _mesa_EnableClientState( GLenum cap );
 
index 606d50c59adcc36ad4a177774fc855f78e37159e..2273138d23852af46fca62563684ad362d3dbeaa 100644 (file)
@@ -384,6 +384,7 @@ LONGSTRING static const char enum_string_table[] =
    "GL_DELETE_STATUS\0"
    "GL_DEPTH\0"
    "GL_DEPTH24_STENCIL8\0"
+   "GL_DEPTH24_STENCIL8_EXT\0"
    "GL_DEPTH_ATTACHMENT\0"
    "GL_DEPTH_ATTACHMENT_EXT\0"
    "GL_DEPTH_BIAS\0"
@@ -409,6 +410,7 @@ LONGSTRING static const char enum_string_table[] =
    "GL_DEPTH_SCALE\0"
    "GL_DEPTH_STENCIL\0"
    "GL_DEPTH_STENCIL_ATTACHMENT\0"
+   "GL_DEPTH_STENCIL_EXT\0"
    "GL_DEPTH_STENCIL_NV\0"
    "GL_DEPTH_STENCIL_TO_BGRA_NV\0"
    "GL_DEPTH_STENCIL_TO_RGBA_NV\0"
@@ -478,6 +480,7 @@ LONGSTRING static const char enum_string_table[] =
    "GL_DRAW_BUFFER9_ARB\0"
    "GL_DRAW_BUFFER9_ATI\0"
    "GL_DRAW_FRAMEBUFFER\0"
+   "GL_DRAW_FRAMEBUFFER_BINDING\0"
    "GL_DRAW_FRAMEBUFFER_BINDING_EXT\0"
    "GL_DRAW_FRAMEBUFFER_EXT\0"
    "GL_DRAW_PIXEL_TOKEN\0"
@@ -593,6 +596,7 @@ LONGSTRING static const char enum_string_table[] =
    "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT\0"
    "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL\0"
    "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT\0"
+   "GL_FRAMEBUFFER_BINDING\0"
    "GL_FRAMEBUFFER_BINDING_EXT\0"
    "GL_FRAMEBUFFER_COMPLETE\0"
    "GL_FRAMEBUFFER_COMPLETE_EXT\0"
@@ -601,12 +605,15 @@ LONGSTRING static const char enum_string_table[] =
    "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT\0"
    "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT\0"
    "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT\0"
+   "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER\0"
    "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT\0"
    "GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT\0"
    "GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT\0"
    "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT\0"
    "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT\0"
    "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE\0"
+   "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT\0"
+   "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER\0"
    "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT\0"
    "GL_FRAMEBUFFER_STATUS_ERROR_EXT\0"
    "GL_FRAMEBUFFER_UNDEFINED\0"
@@ -892,6 +899,7 @@ LONGSTRING static const char enum_string_table[] =
    "GL_MAX_CLIPMAP_DEPTH_SGIX\0"
    "GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX\0"
    "GL_MAX_CLIP_PLANES\0"
+   "GL_MAX_COLOR_ATTACHMENTS\0"
    "GL_MAX_COLOR_ATTACHMENTS_EXT\0"
    "GL_MAX_COLOR_MATRIX_STACK_DEPTH\0"
    "GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI\0"
@@ -947,8 +955,10 @@ LONGSTRING static const char enum_string_table[] =
    "GL_MAX_PROJECTION_STACK_DEPTH\0"
    "GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB\0"
    "GL_MAX_RECTANGLE_TEXTURE_SIZE_NV\0"
+   "GL_MAX_RENDERBUFFER_SIZE\0"
    "GL_MAX_RENDERBUFFER_SIZE_EXT\0"
    "GL_MAX_SAMPLES\0"
+   "GL_MAX_SAMPLES_EXT\0"
    "GL_MAX_SERVER_WAIT_TIMEOUT\0"
    "GL_MAX_SHININESS_NV\0"
    "GL_MAX_SPOT_EXPONENT_NV\0"
@@ -1316,17 +1326,22 @@ LONGSTRING static const char enum_string_table[] =
    "GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT\0"
    "GL_QUAD_MESH_SUN\0"
    "GL_QUAD_STRIP\0"
+   "GL_QUERY_BY_REGION_NO_WAIT_NV\0"
+   "GL_QUERY_BY_REGION_WAIT_NV\0"
    "GL_QUERY_COUNTER_BITS\0"
    "GL_QUERY_COUNTER_BITS_ARB\0"
+   "GL_QUERY_NO_WAIT_NV\0"
    "GL_QUERY_RESULT\0"
    "GL_QUERY_RESULT_ARB\0"
    "GL_QUERY_RESULT_AVAILABLE\0"
    "GL_QUERY_RESULT_AVAILABLE_ARB\0"
+   "GL_QUERY_WAIT_NV\0"
    "GL_R\0"
    "GL_R3_G3_B2\0"
    "GL_RASTER_POSITION_UNCLIPPED_IBM\0"
    "GL_READ_BUFFER\0"
    "GL_READ_FRAMEBUFFER\0"
+   "GL_READ_FRAMEBUFFER_BINDING\0"
    "GL_READ_FRAMEBUFFER_BINDING_EXT\0"
    "GL_READ_FRAMEBUFFER_EXT\0"
    "GL_READ_ONLY\0"
@@ -1345,6 +1360,7 @@ LONGSTRING static const char enum_string_table[] =
    "GL_RENDER\0"
    "GL_RENDERBUFFER\0"
    "GL_RENDERBUFFER_ALPHA_SIZE\0"
+   "GL_RENDERBUFFER_BINDING\0"
    "GL_RENDERBUFFER_BINDING_EXT\0"
    "GL_RENDERBUFFER_BLUE_SIZE\0"
    "GL_RENDERBUFFER_DEPTH_SIZE\0"
@@ -1356,6 +1372,7 @@ LONGSTRING static const char enum_string_table[] =
    "GL_RENDERBUFFER_INTERNAL_FORMAT_EXT\0"
    "GL_RENDERBUFFER_RED_SIZE\0"
    "GL_RENDERBUFFER_SAMPLES\0"
+   "GL_RENDERBUFFER_SAMPLES_EXT\0"
    "GL_RENDERBUFFER_STENCIL_SIZE\0"
    "GL_RENDERBUFFER_WIDTH\0"
    "GL_RENDERBUFFER_WIDTH_EXT\0"
@@ -1541,9 +1558,13 @@ LONGSTRING static const char enum_string_table[] =
    "GL_STENCIL_FAIL\0"
    "GL_STENCIL_FUNC\0"
    "GL_STENCIL_INDEX\0"
+   "GL_STENCIL_INDEX1\0"
+   "GL_STENCIL_INDEX16\0"
    "GL_STENCIL_INDEX16_EXT\0"
    "GL_STENCIL_INDEX1_EXT\0"
+   "GL_STENCIL_INDEX4\0"
    "GL_STENCIL_INDEX4_EXT\0"
+   "GL_STENCIL_INDEX8\0"
    "GL_STENCIL_INDEX8_EXT\0"
    "GL_STENCIL_INDEX_EXT\0"
    "GL_STENCIL_PASS_DEPTH_FAIL\0"
@@ -1761,6 +1782,7 @@ LONGSTRING static const char enum_string_table[] =
    "GL_TEXTURE_RESIDENT\0"
    "GL_TEXTURE_STACK_DEPTH\0"
    "GL_TEXTURE_STENCIL_SIZE\0"
+   "GL_TEXTURE_STENCIL_SIZE_EXT\0"
    "GL_TEXTURE_STORAGE_HINT_APPLE\0"
    "GL_TEXTURE_TOO_LARGE_EXT\0"
    "GL_TEXTURE_UNSIGNED_REMAP_MODE_NV\0"
@@ -1769,7 +1791,6 @@ LONGSTRING static const char enum_string_table[] =
    "GL_TEXTURE_WRAP_S\0"
    "GL_TEXTURE_WRAP_T\0"
    "GL_TIMEOUT_EXPIRED\0"
-   "GL_TIMEOUT_IGNORED\0"
    "GL_TIME_ELAPSED_EXT\0"
    "GL_TRACK_MATRIX_NV\0"
    "GL_TRACK_MATRIX_TRANSFORM_NV\0"
@@ -1804,6 +1825,7 @@ LONGSTRING static const char enum_string_table[] =
    "GL_UNSIGNED_INT\0"
    "GL_UNSIGNED_INT_10_10_10_2\0"
    "GL_UNSIGNED_INT_24_8\0"
+   "GL_UNSIGNED_INT_24_8_EXT\0"
    "GL_UNSIGNED_INT_24_8_NV\0"
    "GL_UNSIGNED_INT_2_10_10_10_REV\0"
    "GL_UNSIGNED_INT_8_8_8_8\0"
@@ -1900,7 +1922,7 @@ LONGSTRING static const char enum_string_table[] =
    "GL_ZOOM_Y\0"
    ;
 
-static const enum_elt all_enums[1862] =
+static const enum_elt all_enums[1884] =
 {
    {     0, 0x00000600 }, /* GL_2D */
    {     6, 0x00001407 }, /* GL_2_BYTES */
@@ -2250,1600 +2272,1622 @@ static const enum_elt all_enums[1862] =
    {  7144, 0x00008B80 }, /* GL_DELETE_STATUS */
    {  7161, 0x00001801 }, /* GL_DEPTH */
    {  7170, 0x000088F0 }, /* GL_DEPTH24_STENCIL8 */
-   {  7190, 0x00008D00 }, /* GL_DEPTH_ATTACHMENT */
-   {  7210, 0x00008D00 }, /* GL_DEPTH_ATTACHMENT_EXT */
-   {  7234, 0x00000D1F }, /* GL_DEPTH_BIAS */
-   {  7248, 0x00000D56 }, /* GL_DEPTH_BITS */
-   {  7262, 0x00008891 }, /* GL_DEPTH_BOUNDS_EXT */
-   {  7282, 0x00008890 }, /* GL_DEPTH_BOUNDS_TEST_EXT */
-   {  7307, 0x00000100 }, /* GL_DEPTH_BUFFER_BIT */
-   {  7327, 0x0000864F }, /* GL_DEPTH_CLAMP */
-   {  7342, 0x0000864F }, /* GL_DEPTH_CLAMP_NV */
-   {  7360, 0x00000B73 }, /* GL_DEPTH_CLEAR_VALUE */
-   {  7381, 0x00001902 }, /* GL_DEPTH_COMPONENT */
-   {  7400, 0x000081A5 }, /* GL_DEPTH_COMPONENT16 */
-   {  7421, 0x000081A5 }, /* GL_DEPTH_COMPONENT16_ARB */
-   {  7446, 0x000081A5 }, /* GL_DEPTH_COMPONENT16_SGIX */
-   {  7472, 0x000081A6 }, /* GL_DEPTH_COMPONENT24 */
-   {  7493, 0x000081A6 }, /* GL_DEPTH_COMPONENT24_ARB */
-   {  7518, 0x000081A6 }, /* GL_DEPTH_COMPONENT24_SGIX */
-   {  7544, 0x000081A7 }, /* GL_DEPTH_COMPONENT32 */
-   {  7565, 0x000081A7 }, /* GL_DEPTH_COMPONENT32_ARB */
-   {  7590, 0x000081A7 }, /* GL_DEPTH_COMPONENT32_SGIX */
-   {  7616, 0x00000B74 }, /* GL_DEPTH_FUNC */
-   {  7630, 0x00000B70 }, /* GL_DEPTH_RANGE */
-   {  7645, 0x00000D1E }, /* GL_DEPTH_SCALE */
-   {  7660, 0x000084F9 }, /* GL_DEPTH_STENCIL */
-   {  7677, 0x0000821A }, /* GL_DEPTH_STENCIL_ATTACHMENT */
-   {  7705, 0x000084F9 }, /* GL_DEPTH_STENCIL_NV */
-   {  7725, 0x0000886F }, /* GL_DEPTH_STENCIL_TO_BGRA_NV */
-   {  7753, 0x0000886E }, /* GL_DEPTH_STENCIL_TO_RGBA_NV */
-   {  7781, 0x00000B71 }, /* GL_DEPTH_TEST */
-   {  7795, 0x0000884B }, /* GL_DEPTH_TEXTURE_MODE */
-   {  7817, 0x0000884B }, /* GL_DEPTH_TEXTURE_MODE_ARB */
-   {  7843, 0x00000B72 }, /* GL_DEPTH_WRITEMASK */
-   {  7862, 0x00001201 }, /* GL_DIFFUSE */
-   {  7873, 0x00000BD0 }, /* GL_DITHER */
-   {  7883, 0x00000A02 }, /* GL_DOMAIN */
-   {  7893, 0x00001100 }, /* GL_DONT_CARE */
-   {  7906, 0x000086AE }, /* GL_DOT3_RGB */
-   {  7918, 0x000086AF }, /* GL_DOT3_RGBA */
-   {  7931, 0x000086AF }, /* GL_DOT3_RGBA_ARB */
-   {  7948, 0x00008741 }, /* GL_DOT3_RGBA_EXT */
-   {  7965, 0x000086AE }, /* GL_DOT3_RGB_ARB */
-   {  7981, 0x00008740 }, /* GL_DOT3_RGB_EXT */
-   {  7997, 0x0000140A }, /* GL_DOUBLE */
-   {  8007, 0x00000C32 }, /* GL_DOUBLEBUFFER */
-   {  8023, 0x00000C01 }, /* GL_DRAW_BUFFER */
-   {  8038, 0x00008825 }, /* GL_DRAW_BUFFER0 */
-   {  8054, 0x00008825 }, /* GL_DRAW_BUFFER0_ARB */
-   {  8074, 0x00008825 }, /* GL_DRAW_BUFFER0_ATI */
-   {  8094, 0x00008826 }, /* GL_DRAW_BUFFER1 */
-   {  8110, 0x0000882F }, /* GL_DRAW_BUFFER10 */
-   {  8127, 0x0000882F }, /* GL_DRAW_BUFFER10_ARB */
-   {  8148, 0x0000882F }, /* GL_DRAW_BUFFER10_ATI */
-   {  8169, 0x00008830 }, /* GL_DRAW_BUFFER11 */
-   {  8186, 0x00008830 }, /* GL_DRAW_BUFFER11_ARB */
-   {  8207, 0x00008830 }, /* GL_DRAW_BUFFER11_ATI */
-   {  8228, 0x00008831 }, /* GL_DRAW_BUFFER12 */
-   {  8245, 0x00008831 }, /* GL_DRAW_BUFFER12_ARB */
-   {  8266, 0x00008831 }, /* GL_DRAW_BUFFER12_ATI */
-   {  8287, 0x00008832 }, /* GL_DRAW_BUFFER13 */
-   {  8304, 0x00008832 }, /* GL_DRAW_BUFFER13_ARB */
-   {  8325, 0x00008832 }, /* GL_DRAW_BUFFER13_ATI */
-   {  8346, 0x00008833 }, /* GL_DRAW_BUFFER14 */
-   {  8363, 0x00008833 }, /* GL_DRAW_BUFFER14_ARB */
-   {  8384, 0x00008833 }, /* GL_DRAW_BUFFER14_ATI */
-   {  8405, 0x00008834 }, /* GL_DRAW_BUFFER15 */
-   {  8422, 0x00008834 }, /* GL_DRAW_BUFFER15_ARB */
-   {  8443, 0x00008834 }, /* GL_DRAW_BUFFER15_ATI */
-   {  8464, 0x00008826 }, /* GL_DRAW_BUFFER1_ARB */
-   {  8484, 0x00008826 }, /* GL_DRAW_BUFFER1_ATI */
-   {  8504, 0x00008827 }, /* GL_DRAW_BUFFER2 */
-   {  8520, 0x00008827 }, /* GL_DRAW_BUFFER2_ARB */
-   {  8540, 0x00008827 }, /* GL_DRAW_BUFFER2_ATI */
-   {  8560, 0x00008828 }, /* GL_DRAW_BUFFER3 */
-   {  8576, 0x00008828 }, /* GL_DRAW_BUFFER3_ARB */
-   {  8596, 0x00008828 }, /* GL_DRAW_BUFFER3_ATI */
-   {  8616, 0x00008829 }, /* GL_DRAW_BUFFER4 */
-   {  8632, 0x00008829 }, /* GL_DRAW_BUFFER4_ARB */
-   {  8652, 0x00008829 }, /* GL_DRAW_BUFFER4_ATI */
-   {  8672, 0x0000882A }, /* GL_DRAW_BUFFER5 */
-   {  8688, 0x0000882A }, /* GL_DRAW_BUFFER5_ARB */
-   {  8708, 0x0000882A }, /* GL_DRAW_BUFFER5_ATI */
-   {  8728, 0x0000882B }, /* GL_DRAW_BUFFER6 */
-   {  8744, 0x0000882B }, /* GL_DRAW_BUFFER6_ARB */
-   {  8764, 0x0000882B }, /* GL_DRAW_BUFFER6_ATI */
-   {  8784, 0x0000882C }, /* GL_DRAW_BUFFER7 */
-   {  8800, 0x0000882C }, /* GL_DRAW_BUFFER7_ARB */
-   {  8820, 0x0000882C }, /* GL_DRAW_BUFFER7_ATI */
-   {  8840, 0x0000882D }, /* GL_DRAW_BUFFER8 */
-   {  8856, 0x0000882D }, /* GL_DRAW_BUFFER8_ARB */
-   {  8876, 0x0000882D }, /* GL_DRAW_BUFFER8_ATI */
-   {  8896, 0x0000882E }, /* GL_DRAW_BUFFER9 */
-   {  8912, 0x0000882E }, /* GL_DRAW_BUFFER9_ARB */
-   {  8932, 0x0000882E }, /* GL_DRAW_BUFFER9_ATI */
-   {  8952, 0x00008CA9 }, /* GL_DRAW_FRAMEBUFFER */
-   {  8972, 0x00008CA6 }, /* GL_DRAW_FRAMEBUFFER_BINDING_EXT */
-   {  9004, 0x00008CA9 }, /* GL_DRAW_FRAMEBUFFER_EXT */
-   {  9028, 0x00000705 }, /* GL_DRAW_PIXEL_TOKEN */
-   {  9048, 0x00000304 }, /* GL_DST_ALPHA */
-   {  9061, 0x00000306 }, /* GL_DST_COLOR */
-   {  9074, 0x0000877A }, /* GL_DU8DV8_ATI */
-   {  9088, 0x00008779 }, /* GL_DUDV_ATI */
-   {  9100, 0x000088EA }, /* GL_DYNAMIC_COPY */
-   {  9116, 0x000088EA }, /* GL_DYNAMIC_COPY_ARB */
-   {  9136, 0x000088E8 }, /* GL_DYNAMIC_DRAW */
-   {  9152, 0x000088E8 }, /* GL_DYNAMIC_DRAW_ARB */
-   {  9172, 0x000088E9 }, /* GL_DYNAMIC_READ */
-   {  9188, 0x000088E9 }, /* GL_DYNAMIC_READ_ARB */
-   {  9208, 0x00000B43 }, /* GL_EDGE_FLAG */
-   {  9221, 0x00008079 }, /* GL_EDGE_FLAG_ARRAY */
-   {  9240, 0x0000889B }, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING */
-   {  9274, 0x0000889B }, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB */
-   {  9312, 0x00008093 }, /* GL_EDGE_FLAG_ARRAY_POINTER */
-   {  9339, 0x0000808C }, /* GL_EDGE_FLAG_ARRAY_STRIDE */
-   {  9365, 0x00008893 }, /* GL_ELEMENT_ARRAY_BUFFER */
-   {  9389, 0x00008895 }, /* GL_ELEMENT_ARRAY_BUFFER_BINDING */
-   {  9421, 0x00008895 }, /* GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB */
-   {  9457, 0x00001600 }, /* GL_EMISSION */
-   {  9469, 0x00002000 }, /* GL_ENABLE_BIT */
-   {  9483, 0x00000202 }, /* GL_EQUAL */
-   {  9492, 0x00001509 }, /* GL_EQUIV */
-   {  9501, 0x00010000 }, /* GL_EVAL_BIT */
-   {  9513, 0x00000800 }, /* GL_EXP */
-   {  9520, 0x00000801 }, /* GL_EXP2 */
-   {  9528, 0x00001F03 }, /* GL_EXTENSIONS */
-   {  9542, 0x00002400 }, /* GL_EYE_LINEAR */
-   {  9556, 0x00002502 }, /* GL_EYE_PLANE */
-   {  9569, 0x0000855C }, /* GL_EYE_PLANE_ABSOLUTE_NV */
-   {  9594, 0x0000855B }, /* GL_EYE_RADIAL_NV */
-   {  9611, 0x00000000 }, /* GL_FALSE */
-   {  9620, 0x00001101 }, /* GL_FASTEST */
-   {  9631, 0x00001C01 }, /* GL_FEEDBACK */
-   {  9643, 0x00000DF0 }, /* GL_FEEDBACK_BUFFER_POINTER */
-   {  9670, 0x00000DF1 }, /* GL_FEEDBACK_BUFFER_SIZE */
-   {  9694, 0x00000DF2 }, /* GL_FEEDBACK_BUFFER_TYPE */
-   {  9718, 0x00001B02 }, /* GL_FILL */
-   {  9726, 0x00008E4D }, /* GL_FIRST_VERTEX_CONVENTION */
-   {  9753, 0x00008E4D }, /* GL_FIRST_VERTEX_CONVENTION_EXT */
-   {  9784, 0x00001D00 }, /* GL_FLAT */
-   {  9792, 0x00001406 }, /* GL_FLOAT */
-   {  9801, 0x00008B5A }, /* GL_FLOAT_MAT2 */
-   {  9815, 0x00008B5A }, /* GL_FLOAT_MAT2_ARB */
-   {  9833, 0x00008B65 }, /* GL_FLOAT_MAT2x3 */
-   {  9849, 0x00008B66 }, /* GL_FLOAT_MAT2x4 */
-   {  9865, 0x00008B5B }, /* GL_FLOAT_MAT3 */
-   {  9879, 0x00008B5B }, /* GL_FLOAT_MAT3_ARB */
-   {  9897, 0x00008B67 }, /* GL_FLOAT_MAT3x2 */
-   {  9913, 0x00008B68 }, /* GL_FLOAT_MAT3x4 */
-   {  9929, 0x00008B5C }, /* GL_FLOAT_MAT4 */
-   {  9943, 0x00008B5C }, /* GL_FLOAT_MAT4_ARB */
-   {  9961, 0x00008B69 }, /* GL_FLOAT_MAT4x2 */
-   {  9977, 0x00008B6A }, /* GL_FLOAT_MAT4x3 */
-   {  9993, 0x00008B50 }, /* GL_FLOAT_VEC2 */
-   { 10007, 0x00008B50 }, /* GL_FLOAT_VEC2_ARB */
-   { 10025, 0x00008B51 }, /* GL_FLOAT_VEC3 */
-   { 10039, 0x00008B51 }, /* GL_FLOAT_VEC3_ARB */
-   { 10057, 0x00008B52 }, /* GL_FLOAT_VEC4 */
-   { 10071, 0x00008B52 }, /* GL_FLOAT_VEC4_ARB */
-   { 10089, 0x00000B60 }, /* GL_FOG */
-   { 10096, 0x00000080 }, /* GL_FOG_BIT */
-   { 10107, 0x00000B66 }, /* GL_FOG_COLOR */
-   { 10120, 0x00008451 }, /* GL_FOG_COORD */
-   { 10133, 0x00008451 }, /* GL_FOG_COORDINATE */
-   { 10151, 0x00008457 }, /* GL_FOG_COORDINATE_ARRAY */
-   { 10175, 0x0000889D }, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING */
-   { 10214, 0x0000889D }, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB */
-   { 10257, 0x00008456 }, /* GL_FOG_COORDINATE_ARRAY_POINTER */
-   { 10289, 0x00008455 }, /* GL_FOG_COORDINATE_ARRAY_STRIDE */
-   { 10320, 0x00008454 }, /* GL_FOG_COORDINATE_ARRAY_TYPE */
-   { 10349, 0x00008450 }, /* GL_FOG_COORDINATE_SOURCE */
-   { 10374, 0x00008457 }, /* GL_FOG_COORD_ARRAY */
-   { 10393, 0x0000889D }, /* GL_FOG_COORD_ARRAY_BUFFER_BINDING */
-   { 10427, 0x00008456 }, /* GL_FOG_COORD_ARRAY_POINTER */
-   { 10454, 0x00008455 }, /* GL_FOG_COORD_ARRAY_STRIDE */
-   { 10480, 0x00008454 }, /* GL_FOG_COORD_ARRAY_TYPE */
-   { 10504, 0x00008450 }, /* GL_FOG_COORD_SRC */
-   { 10521, 0x00000B62 }, /* GL_FOG_DENSITY */
-   { 10536, 0x0000855A }, /* GL_FOG_DISTANCE_MODE_NV */
-   { 10560, 0x00000B64 }, /* GL_FOG_END */
-   { 10571, 0x00000C54 }, /* GL_FOG_HINT */
-   { 10583, 0x00000B61 }, /* GL_FOG_INDEX */
-   { 10596, 0x00000B65 }, /* GL_FOG_MODE */
-   { 10608, 0x00008198 }, /* GL_FOG_OFFSET_SGIX */
-   { 10627, 0x00008199 }, /* GL_FOG_OFFSET_VALUE_SGIX */
-   { 10652, 0x00000B63 }, /* GL_FOG_START */
-   { 10665, 0x00008452 }, /* GL_FRAGMENT_DEPTH */
-   { 10683, 0x00008804 }, /* GL_FRAGMENT_PROGRAM_ARB */
-   { 10707, 0x00008B30 }, /* GL_FRAGMENT_SHADER */
-   { 10726, 0x00008B30 }, /* GL_FRAGMENT_SHADER_ARB */
-   { 10749, 0x00008B8B }, /* GL_FRAGMENT_SHADER_DERIVATIVE_HINT */
-   { 10784, 0x00008D40 }, /* GL_FRAMEBUFFER */
-   { 10799, 0x00008215 }, /* GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */
-   { 10836, 0x00008214 }, /* GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */
-   { 10872, 0x00008210 }, /* GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */
-   { 10913, 0x00008211 }, /* GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */
-   { 10954, 0x00008216 }, /* GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */
-   { 10991, 0x00008213 }, /* GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */
-   { 11028, 0x00008CD1 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */
-   { 11066, 0x00008CD1 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT */
-   { 11108, 0x00008CD0 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */
-   { 11146, 0x00008CD0 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT */
-   { 11188, 0x00008212 }, /* GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */
-   { 11223, 0x00008217 }, /* GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */
-   { 11262, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT */
-   { 11311, 0x00008CD3 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */
-   { 11359, 0x00008CD3 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT */
-   { 11411, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */
-   { 11451, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */
-   { 11495, 0x00008CD2 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */
-   { 11535, 0x00008CD2 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT */
-   { 11579, 0x00008CA6 }, /* GL_FRAMEBUFFER_BINDING_EXT */
-   { 11606, 0x00008CD5 }, /* GL_FRAMEBUFFER_COMPLETE */
-   { 11630, 0x00008CD5 }, /* GL_FRAMEBUFFER_COMPLETE_EXT */
-   { 11658, 0x00008218 }, /* GL_FRAMEBUFFER_DEFAULT */
-   { 11681, 0x00008D40 }, /* GL_FRAMEBUFFER_EXT */
-   { 11700, 0x00008CD6 }, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */
-   { 11737, 0x00008CD6 }, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT */
-   { 11778, 0x00008CD9 }, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT */
-   { 11819, 0x00008CDB }, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT */
-   { 11861, 0x00008CD8 }, /* GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT */
-   { 11912, 0x00008CDA }, /* GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT */
-   { 11950, 0x00008CD7 }, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */
-   { 11995, 0x00008CD7 }, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT */
-   { 12044, 0x00008D56 }, /* GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */
-   { 12082, 0x00008CDC }, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT */
-   { 12124, 0x00008CDE }, /* GL_FRAMEBUFFER_STATUS_ERROR_EXT */
-   { 12156, 0x00008219 }, /* GL_FRAMEBUFFER_UNDEFINED */
-   { 12181, 0x00008CDD }, /* GL_FRAMEBUFFER_UNSUPPORTED */
-   { 12208, 0x00008CDD }, /* GL_FRAMEBUFFER_UNSUPPORTED_EXT */
-   { 12239, 0x00000404 }, /* GL_FRONT */
-   { 12248, 0x00000408 }, /* GL_FRONT_AND_BACK */
-   { 12266, 0x00000B46 }, /* GL_FRONT_FACE */
-   { 12280, 0x00000400 }, /* GL_FRONT_LEFT */
-   { 12294, 0x00000401 }, /* GL_FRONT_RIGHT */
-   { 12309, 0x00008006 }, /* GL_FUNC_ADD */
-   { 12321, 0x00008006 }, /* GL_FUNC_ADD_EXT */
-   { 12337, 0x0000800B }, /* GL_FUNC_REVERSE_SUBTRACT */
-   { 12362, 0x0000800B }, /* GL_FUNC_REVERSE_SUBTRACT_EXT */
-   { 12391, 0x0000800A }, /* GL_FUNC_SUBTRACT */
-   { 12408, 0x0000800A }, /* GL_FUNC_SUBTRACT_EXT */
-   { 12429, 0x00008191 }, /* GL_GENERATE_MIPMAP */
-   { 12448, 0x00008192 }, /* GL_GENERATE_MIPMAP_HINT */
-   { 12472, 0x00008192 }, /* GL_GENERATE_MIPMAP_HINT_SGIS */
-   { 12501, 0x00008191 }, /* GL_GENERATE_MIPMAP_SGIS */
-   { 12525, 0x00000206 }, /* GL_GEQUAL */
-   { 12535, 0x00000204 }, /* GL_GREATER */
-   { 12546, 0x00001904 }, /* GL_GREEN */
-   { 12555, 0x00000D19 }, /* GL_GREEN_BIAS */
-   { 12569, 0x00000D53 }, /* GL_GREEN_BITS */
-   { 12583, 0x00000D18 }, /* GL_GREEN_SCALE */
-   { 12598, 0x00008000 }, /* GL_HINT_BIT */
-   { 12610, 0x00008024 }, /* GL_HISTOGRAM */
-   { 12623, 0x0000802B }, /* GL_HISTOGRAM_ALPHA_SIZE */
-   { 12647, 0x0000802B }, /* GL_HISTOGRAM_ALPHA_SIZE_EXT */
-   { 12675, 0x0000802A }, /* GL_HISTOGRAM_BLUE_SIZE */
-   { 12698, 0x0000802A }, /* GL_HISTOGRAM_BLUE_SIZE_EXT */
-   { 12725, 0x00008024 }, /* GL_HISTOGRAM_EXT */
-   { 12742, 0x00008027 }, /* GL_HISTOGRAM_FORMAT */
-   { 12762, 0x00008027 }, /* GL_HISTOGRAM_FORMAT_EXT */
-   { 12786, 0x00008029 }, /* GL_HISTOGRAM_GREEN_SIZE */
-   { 12810, 0x00008029 }, /* GL_HISTOGRAM_GREEN_SIZE_EXT */
-   { 12838, 0x0000802C }, /* GL_HISTOGRAM_LUMINANCE_SIZE */
-   { 12866, 0x0000802C }, /* GL_HISTOGRAM_LUMINANCE_SIZE_EXT */
-   { 12898, 0x00008028 }, /* GL_HISTOGRAM_RED_SIZE */
-   { 12920, 0x00008028 }, /* GL_HISTOGRAM_RED_SIZE_EXT */
-   { 12946, 0x0000802D }, /* GL_HISTOGRAM_SINK */
-   { 12964, 0x0000802D }, /* GL_HISTOGRAM_SINK_EXT */
-   { 12986, 0x00008026 }, /* GL_HISTOGRAM_WIDTH */
-   { 13005, 0x00008026 }, /* GL_HISTOGRAM_WIDTH_EXT */
-   { 13028, 0x0000862A }, /* GL_IDENTITY_NV */
-   { 13043, 0x00008150 }, /* GL_IGNORE_BORDER_HP */
-   { 13063, 0x00008B9B }, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES */
-   { 13103, 0x00008B9A }, /* GL_IMPLEMENTATION_COLOR_READ_TYPE_OES */
-   { 13141, 0x00001E02 }, /* GL_INCR */
-   { 13149, 0x00008507 }, /* GL_INCR_WRAP */
-   { 13162, 0x00008507 }, /* GL_INCR_WRAP_EXT */
-   { 13179, 0x00008222 }, /* GL_INDEX */
-   { 13188, 0x00008077 }, /* GL_INDEX_ARRAY */
-   { 13203, 0x00008899 }, /* GL_INDEX_ARRAY_BUFFER_BINDING */
-   { 13233, 0x00008899 }, /* GL_INDEX_ARRAY_BUFFER_BINDING_ARB */
-   { 13267, 0x00008091 }, /* GL_INDEX_ARRAY_POINTER */
-   { 13290, 0x00008086 }, /* GL_INDEX_ARRAY_STRIDE */
-   { 13312, 0x00008085 }, /* GL_INDEX_ARRAY_TYPE */
-   { 13332, 0x00000D51 }, /* GL_INDEX_BITS */
-   { 13346, 0x00000C20 }, /* GL_INDEX_CLEAR_VALUE */
-   { 13367, 0x00000BF1 }, /* GL_INDEX_LOGIC_OP */
-   { 13385, 0x00000C30 }, /* GL_INDEX_MODE */
-   { 13399, 0x00000D13 }, /* GL_INDEX_OFFSET */
-   { 13415, 0x00000D12 }, /* GL_INDEX_SHIFT */
-   { 13430, 0x00000C21 }, /* GL_INDEX_WRITEMASK */
-   { 13449, 0x00008B84 }, /* GL_INFO_LOG_LENGTH */
-   { 13468, 0x00001404 }, /* GL_INT */
-   { 13475, 0x00008049 }, /* GL_INTENSITY */
-   { 13488, 0x0000804C }, /* GL_INTENSITY12 */
-   { 13503, 0x0000804C }, /* GL_INTENSITY12_EXT */
-   { 13522, 0x0000804D }, /* GL_INTENSITY16 */
-   { 13537, 0x0000804D }, /* GL_INTENSITY16_EXT */
-   { 13556, 0x0000804A }, /* GL_INTENSITY4 */
-   { 13570, 0x0000804A }, /* GL_INTENSITY4_EXT */
-   { 13588, 0x0000804B }, /* GL_INTENSITY8 */
-   { 13602, 0x0000804B }, /* GL_INTENSITY8_EXT */
-   { 13620, 0x00008049 }, /* GL_INTENSITY_EXT */
-   { 13637, 0x00008575 }, /* GL_INTERPOLATE */
-   { 13652, 0x00008575 }, /* GL_INTERPOLATE_ARB */
-   { 13671, 0x00008575 }, /* GL_INTERPOLATE_EXT */
-   { 13690, 0x00008B53 }, /* GL_INT_VEC2 */
-   { 13702, 0x00008B53 }, /* GL_INT_VEC2_ARB */
-   { 13718, 0x00008B54 }, /* GL_INT_VEC3 */
-   { 13730, 0x00008B54 }, /* GL_INT_VEC3_ARB */
-   { 13746, 0x00008B55 }, /* GL_INT_VEC4 */
-   { 13758, 0x00008B55 }, /* GL_INT_VEC4_ARB */
-   { 13774, 0x00000500 }, /* GL_INVALID_ENUM */
-   { 13790, 0x00000506 }, /* GL_INVALID_FRAMEBUFFER_OPERATION */
-   { 13823, 0x00000506 }, /* GL_INVALID_FRAMEBUFFER_OPERATION_EXT */
-   { 13860, 0x00000502 }, /* GL_INVALID_OPERATION */
-   { 13881, 0x00000501 }, /* GL_INVALID_VALUE */
-   { 13898, 0x0000862B }, /* GL_INVERSE_NV */
-   { 13912, 0x0000862D }, /* GL_INVERSE_TRANSPOSE_NV */
-   { 13936, 0x0000150A }, /* GL_INVERT */
-   { 13946, 0x00001E00 }, /* GL_KEEP */
-   { 13954, 0x00008E4E }, /* GL_LAST_VERTEX_CONVENTION */
-   { 13980, 0x00008E4E }, /* GL_LAST_VERTEX_CONVENTION_EXT */
-   { 14010, 0x00000406 }, /* GL_LEFT */
-   { 14018, 0x00000203 }, /* GL_LEQUAL */
-   { 14028, 0x00000201 }, /* GL_LESS */
-   { 14036, 0x00004000 }, /* GL_LIGHT0 */
-   { 14046, 0x00004001 }, /* GL_LIGHT1 */
-   { 14056, 0x00004002 }, /* GL_LIGHT2 */
-   { 14066, 0x00004003 }, /* GL_LIGHT3 */
-   { 14076, 0x00004004 }, /* GL_LIGHT4 */
-   { 14086, 0x00004005 }, /* GL_LIGHT5 */
-   { 14096, 0x00004006 }, /* GL_LIGHT6 */
-   { 14106, 0x00004007 }, /* GL_LIGHT7 */
-   { 14116, 0x00000B50 }, /* GL_LIGHTING */
-   { 14128, 0x00000040 }, /* GL_LIGHTING_BIT */
-   { 14144, 0x00000B53 }, /* GL_LIGHT_MODEL_AMBIENT */
-   { 14167, 0x000081F8 }, /* GL_LIGHT_MODEL_COLOR_CONTROL */
-   { 14196, 0x000081F8 }, /* GL_LIGHT_MODEL_COLOR_CONTROL_EXT */
-   { 14229, 0x00000B51 }, /* GL_LIGHT_MODEL_LOCAL_VIEWER */
-   { 14257, 0x00000B52 }, /* GL_LIGHT_MODEL_TWO_SIDE */
-   { 14281, 0x00001B01 }, /* GL_LINE */
-   { 14289, 0x00002601 }, /* GL_LINEAR */
-   { 14299, 0x00001208 }, /* GL_LINEAR_ATTENUATION */
-   { 14321, 0x00008170 }, /* GL_LINEAR_CLIPMAP_LINEAR_SGIX */
-   { 14351, 0x0000844F }, /* GL_LINEAR_CLIPMAP_NEAREST_SGIX */
-   { 14382, 0x00002703 }, /* GL_LINEAR_MIPMAP_LINEAR */
-   { 14406, 0x00002701 }, /* GL_LINEAR_MIPMAP_NEAREST */
-   { 14431, 0x00000001 }, /* GL_LINES */
-   { 14440, 0x00000004 }, /* GL_LINE_BIT */
-   { 14452, 0x00000002 }, /* GL_LINE_LOOP */
-   { 14465, 0x00000707 }, /* GL_LINE_RESET_TOKEN */
-   { 14485, 0x00000B20 }, /* GL_LINE_SMOOTH */
-   { 14500, 0x00000C52 }, /* GL_LINE_SMOOTH_HINT */
-   { 14520, 0x00000B24 }, /* GL_LINE_STIPPLE */
-   { 14536, 0x00000B25 }, /* GL_LINE_STIPPLE_PATTERN */
-   { 14560, 0x00000B26 }, /* GL_LINE_STIPPLE_REPEAT */
-   { 14583, 0x00000003 }, /* GL_LINE_STRIP */
-   { 14597, 0x00000702 }, /* GL_LINE_TOKEN */
-   { 14611, 0x00000B21 }, /* GL_LINE_WIDTH */
-   { 14625, 0x00000B23 }, /* GL_LINE_WIDTH_GRANULARITY */
-   { 14651, 0x00000B22 }, /* GL_LINE_WIDTH_RANGE */
-   { 14671, 0x00008B82 }, /* GL_LINK_STATUS */
-   { 14686, 0x00000B32 }, /* GL_LIST_BASE */
-   { 14699, 0x00020000 }, /* GL_LIST_BIT */
-   { 14711, 0x00000B33 }, /* GL_LIST_INDEX */
-   { 14725, 0x00000B30 }, /* GL_LIST_MODE */
-   { 14738, 0x00000101 }, /* GL_LOAD */
-   { 14746, 0x00000BF1 }, /* GL_LOGIC_OP */
-   { 14758, 0x00000BF0 }, /* GL_LOGIC_OP_MODE */
-   { 14775, 0x00008CA1 }, /* GL_LOWER_LEFT */
-   { 14789, 0x00001909 }, /* GL_LUMINANCE */
-   { 14802, 0x00008041 }, /* GL_LUMINANCE12 */
-   { 14817, 0x00008047 }, /* GL_LUMINANCE12_ALPHA12 */
-   { 14840, 0x00008047 }, /* GL_LUMINANCE12_ALPHA12_EXT */
-   { 14867, 0x00008046 }, /* GL_LUMINANCE12_ALPHA4 */
-   { 14889, 0x00008046 }, /* GL_LUMINANCE12_ALPHA4_EXT */
-   { 14915, 0x00008041 }, /* GL_LUMINANCE12_EXT */
-   { 14934, 0x00008042 }, /* GL_LUMINANCE16 */
-   { 14949, 0x00008048 }, /* GL_LUMINANCE16_ALPHA16 */
-   { 14972, 0x00008048 }, /* GL_LUMINANCE16_ALPHA16_EXT */
-   { 14999, 0x00008042 }, /* GL_LUMINANCE16_EXT */
-   { 15018, 0x0000803F }, /* GL_LUMINANCE4 */
-   { 15032, 0x00008043 }, /* GL_LUMINANCE4_ALPHA4 */
-   { 15053, 0x00008043 }, /* GL_LUMINANCE4_ALPHA4_EXT */
-   { 15078, 0x0000803F }, /* GL_LUMINANCE4_EXT */
-   { 15096, 0x00008044 }, /* GL_LUMINANCE6_ALPHA2 */
-   { 15117, 0x00008044 }, /* GL_LUMINANCE6_ALPHA2_EXT */
-   { 15142, 0x00008040 }, /* GL_LUMINANCE8 */
-   { 15156, 0x00008045 }, /* GL_LUMINANCE8_ALPHA8 */
-   { 15177, 0x00008045 }, /* GL_LUMINANCE8_ALPHA8_EXT */
-   { 15202, 0x00008040 }, /* GL_LUMINANCE8_EXT */
-   { 15220, 0x0000190A }, /* GL_LUMINANCE_ALPHA */
-   { 15239, 0x00000D90 }, /* GL_MAP1_COLOR_4 */
-   { 15255, 0x00000DD0 }, /* GL_MAP1_GRID_DOMAIN */
-   { 15275, 0x00000DD1 }, /* GL_MAP1_GRID_SEGMENTS */
-   { 15297, 0x00000D91 }, /* GL_MAP1_INDEX */
-   { 15311, 0x00000D92 }, /* GL_MAP1_NORMAL */
-   { 15326, 0x00000D93 }, /* GL_MAP1_TEXTURE_COORD_1 */
-   { 15350, 0x00000D94 }, /* GL_MAP1_TEXTURE_COORD_2 */
-   { 15374, 0x00000D95 }, /* GL_MAP1_TEXTURE_COORD_3 */
-   { 15398, 0x00000D96 }, /* GL_MAP1_TEXTURE_COORD_4 */
-   { 15422, 0x00000D97 }, /* GL_MAP1_VERTEX_3 */
-   { 15439, 0x00000D98 }, /* GL_MAP1_VERTEX_4 */
-   { 15456, 0x00008660 }, /* GL_MAP1_VERTEX_ATTRIB0_4_NV */
-   { 15484, 0x0000866A }, /* GL_MAP1_VERTEX_ATTRIB10_4_NV */
-   { 15513, 0x0000866B }, /* GL_MAP1_VERTEX_ATTRIB11_4_NV */
-   { 15542, 0x0000866C }, /* GL_MAP1_VERTEX_ATTRIB12_4_NV */
-   { 15571, 0x0000866D }, /* GL_MAP1_VERTEX_ATTRIB13_4_NV */
-   { 15600, 0x0000866E }, /* GL_MAP1_VERTEX_ATTRIB14_4_NV */
-   { 15629, 0x0000866F }, /* GL_MAP1_VERTEX_ATTRIB15_4_NV */
-   { 15658, 0x00008661 }, /* GL_MAP1_VERTEX_ATTRIB1_4_NV */
-   { 15686, 0x00008662 }, /* GL_MAP1_VERTEX_ATTRIB2_4_NV */
-   { 15714, 0x00008663 }, /* GL_MAP1_VERTEX_ATTRIB3_4_NV */
-   { 15742, 0x00008664 }, /* GL_MAP1_VERTEX_ATTRIB4_4_NV */
-   { 15770, 0x00008665 }, /* GL_MAP1_VERTEX_ATTRIB5_4_NV */
-   { 15798, 0x00008666 }, /* GL_MAP1_VERTEX_ATTRIB6_4_NV */
-   { 15826, 0x00008667 }, /* GL_MAP1_VERTEX_ATTRIB7_4_NV */
-   { 15854, 0x00008668 }, /* GL_MAP1_VERTEX_ATTRIB8_4_NV */
-   { 15882, 0x00008669 }, /* GL_MAP1_VERTEX_ATTRIB9_4_NV */
-   { 15910, 0x00000DB0 }, /* GL_MAP2_COLOR_4 */
-   { 15926, 0x00000DD2 }, /* GL_MAP2_GRID_DOMAIN */
-   { 15946, 0x00000DD3 }, /* GL_MAP2_GRID_SEGMENTS */
-   { 15968, 0x00000DB1 }, /* GL_MAP2_INDEX */
-   { 15982, 0x00000DB2 }, /* GL_MAP2_NORMAL */
-   { 15997, 0x00000DB3 }, /* GL_MAP2_TEXTURE_COORD_1 */
-   { 16021, 0x00000DB4 }, /* GL_MAP2_TEXTURE_COORD_2 */
-   { 16045, 0x00000DB5 }, /* GL_MAP2_TEXTURE_COORD_3 */
-   { 16069, 0x00000DB6 }, /* GL_MAP2_TEXTURE_COORD_4 */
-   { 16093, 0x00000DB7 }, /* GL_MAP2_VERTEX_3 */
-   { 16110, 0x00000DB8 }, /* GL_MAP2_VERTEX_4 */
-   { 16127, 0x00008670 }, /* GL_MAP2_VERTEX_ATTRIB0_4_NV */
-   { 16155, 0x0000867A }, /* GL_MAP2_VERTEX_ATTRIB10_4_NV */
-   { 16184, 0x0000867B }, /* GL_MAP2_VERTEX_ATTRIB11_4_NV */
-   { 16213, 0x0000867C }, /* GL_MAP2_VERTEX_ATTRIB12_4_NV */
-   { 16242, 0x0000867D }, /* GL_MAP2_VERTEX_ATTRIB13_4_NV */
-   { 16271, 0x0000867E }, /* GL_MAP2_VERTEX_ATTRIB14_4_NV */
-   { 16300, 0x0000867F }, /* GL_MAP2_VERTEX_ATTRIB15_4_NV */
-   { 16329, 0x00008671 }, /* GL_MAP2_VERTEX_ATTRIB1_4_NV */
-   { 16357, 0x00008672 }, /* GL_MAP2_VERTEX_ATTRIB2_4_NV */
-   { 16385, 0x00008673 }, /* GL_MAP2_VERTEX_ATTRIB3_4_NV */
-   { 16413, 0x00008674 }, /* GL_MAP2_VERTEX_ATTRIB4_4_NV */
-   { 16441, 0x00008675 }, /* GL_MAP2_VERTEX_ATTRIB5_4_NV */
-   { 16469, 0x00008676 }, /* GL_MAP2_VERTEX_ATTRIB6_4_NV */
-   { 16497, 0x00008677 }, /* GL_MAP2_VERTEX_ATTRIB7_4_NV */
-   { 16525, 0x00008678 }, /* GL_MAP2_VERTEX_ATTRIB8_4_NV */
-   { 16553, 0x00008679 }, /* GL_MAP2_VERTEX_ATTRIB9_4_NV */
-   { 16581, 0x00000D10 }, /* GL_MAP_COLOR */
-   { 16594, 0x00000010 }, /* GL_MAP_FLUSH_EXPLICIT_BIT */
-   { 16620, 0x00000008 }, /* GL_MAP_INVALIDATE_BUFFER_BIT */
-   { 16649, 0x00000004 }, /* GL_MAP_INVALIDATE_RANGE_BIT */
-   { 16677, 0x00000001 }, /* GL_MAP_READ_BIT */
-   { 16693, 0x00000D11 }, /* GL_MAP_STENCIL */
-   { 16708, 0x00000020 }, /* GL_MAP_UNSYNCHRONIZED_BIT */
-   { 16734, 0x00000002 }, /* GL_MAP_WRITE_BIT */
-   { 16751, 0x000088C0 }, /* GL_MATRIX0_ARB */
-   { 16766, 0x00008630 }, /* GL_MATRIX0_NV */
-   { 16780, 0x000088CA }, /* GL_MATRIX10_ARB */
-   { 16796, 0x000088CB }, /* GL_MATRIX11_ARB */
-   { 16812, 0x000088CC }, /* GL_MATRIX12_ARB */
-   { 16828, 0x000088CD }, /* GL_MATRIX13_ARB */
-   { 16844, 0x000088CE }, /* GL_MATRIX14_ARB */
-   { 16860, 0x000088CF }, /* GL_MATRIX15_ARB */
-   { 16876, 0x000088D0 }, /* GL_MATRIX16_ARB */
-   { 16892, 0x000088D1 }, /* GL_MATRIX17_ARB */
-   { 16908, 0x000088D2 }, /* GL_MATRIX18_ARB */
-   { 16924, 0x000088D3 }, /* GL_MATRIX19_ARB */
-   { 16940, 0x000088C1 }, /* GL_MATRIX1_ARB */
-   { 16955, 0x00008631 }, /* GL_MATRIX1_NV */
-   { 16969, 0x000088D4 }, /* GL_MATRIX20_ARB */
-   { 16985, 0x000088D5 }, /* GL_MATRIX21_ARB */
-   { 17001, 0x000088D6 }, /* GL_MATRIX22_ARB */
-   { 17017, 0x000088D7 }, /* GL_MATRIX23_ARB */
-   { 17033, 0x000088D8 }, /* GL_MATRIX24_ARB */
-   { 17049, 0x000088D9 }, /* GL_MATRIX25_ARB */
-   { 17065, 0x000088DA }, /* GL_MATRIX26_ARB */
-   { 17081, 0x000088DB }, /* GL_MATRIX27_ARB */
-   { 17097, 0x000088DC }, /* GL_MATRIX28_ARB */
-   { 17113, 0x000088DD }, /* GL_MATRIX29_ARB */
-   { 17129, 0x000088C2 }, /* GL_MATRIX2_ARB */
-   { 17144, 0x00008632 }, /* GL_MATRIX2_NV */
-   { 17158, 0x000088DE }, /* GL_MATRIX30_ARB */
-   { 17174, 0x000088DF }, /* GL_MATRIX31_ARB */
-   { 17190, 0x000088C3 }, /* GL_MATRIX3_ARB */
-   { 17205, 0x00008633 }, /* GL_MATRIX3_NV */
-   { 17219, 0x000088C4 }, /* GL_MATRIX4_ARB */
-   { 17234, 0x00008634 }, /* GL_MATRIX4_NV */
-   { 17248, 0x000088C5 }, /* GL_MATRIX5_ARB */
-   { 17263, 0x00008635 }, /* GL_MATRIX5_NV */
-   { 17277, 0x000088C6 }, /* GL_MATRIX6_ARB */
-   { 17292, 0x00008636 }, /* GL_MATRIX6_NV */
-   { 17306, 0x000088C7 }, /* GL_MATRIX7_ARB */
-   { 17321, 0x00008637 }, /* GL_MATRIX7_NV */
-   { 17335, 0x000088C8 }, /* GL_MATRIX8_ARB */
-   { 17350, 0x000088C9 }, /* GL_MATRIX9_ARB */
-   { 17365, 0x00008844 }, /* GL_MATRIX_INDEX_ARRAY_ARB */
-   { 17391, 0x00008849 }, /* GL_MATRIX_INDEX_ARRAY_POINTER_ARB */
-   { 17425, 0x00008846 }, /* GL_MATRIX_INDEX_ARRAY_SIZE_ARB */
-   { 17456, 0x00008848 }, /* GL_MATRIX_INDEX_ARRAY_STRIDE_ARB */
-   { 17489, 0x00008847 }, /* GL_MATRIX_INDEX_ARRAY_TYPE_ARB */
-   { 17520, 0x00000BA0 }, /* GL_MATRIX_MODE */
-   { 17535, 0x00008840 }, /* GL_MATRIX_PALETTE_ARB */
-   { 17557, 0x00008008 }, /* GL_MAX */
-   { 17564, 0x00008073 }, /* GL_MAX_3D_TEXTURE_SIZE */
-   { 17587, 0x000088FF }, /* GL_MAX_ARRAY_TEXTURE_LAYERS_EXT */
-   { 17619, 0x00000D35 }, /* GL_MAX_ATTRIB_STACK_DEPTH */
-   { 17645, 0x00000D3B }, /* GL_MAX_CLIENT_ATTRIB_STACK_DEPTH */
-   { 17678, 0x00008177 }, /* GL_MAX_CLIPMAP_DEPTH_SGIX */
-   { 17704, 0x00008178 }, /* GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX */
-   { 17738, 0x00000D32 }, /* GL_MAX_CLIP_PLANES */
-   { 17757, 0x00008CDF }, /* GL_MAX_COLOR_ATTACHMENTS_EXT */
-   { 17786, 0x000080B3 }, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH */
-   { 17818, 0x000080B3 }, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI */
-   { 17854, 0x00008B4D }, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS */
-   { 17890, 0x00008B4D }, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB */
-   { 17930, 0x0000801B }, /* GL_MAX_CONVOLUTION_HEIGHT */
-   { 17956, 0x0000801B }, /* GL_MAX_CONVOLUTION_HEIGHT_EXT */
-   { 17986, 0x0000801A }, /* GL_MAX_CONVOLUTION_WIDTH */
-   { 18011, 0x0000801A }, /* GL_MAX_CONVOLUTION_WIDTH_EXT */
-   { 18040, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE */
-   { 18069, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB */
-   { 18102, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS */
-   { 18122, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS_ARB */
-   { 18146, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS_ATI */
-   { 18170, 0x000080E9 }, /* GL_MAX_ELEMENTS_INDICES */
-   { 18194, 0x000080E8 }, /* GL_MAX_ELEMENTS_VERTICES */
-   { 18219, 0x00000D30 }, /* GL_MAX_EVAL_ORDER */
-   { 18237, 0x00008008 }, /* GL_MAX_EXT */
-   { 18248, 0x00008B49 }, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS */
-   { 18283, 0x00008B49 }, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB */
-   { 18322, 0x00000D31 }, /* GL_MAX_LIGHTS */
-   { 18336, 0x00000B31 }, /* GL_MAX_LIST_NESTING */
-   { 18356, 0x00008841 }, /* GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB */
-   { 18394, 0x00000D36 }, /* GL_MAX_MODELVIEW_STACK_DEPTH */
-   { 18423, 0x00000D37 }, /* GL_MAX_NAME_STACK_DEPTH */
-   { 18447, 0x00008842 }, /* GL_MAX_PALETTE_MATRICES_ARB */
-   { 18475, 0x00000D34 }, /* GL_MAX_PIXEL_MAP_TABLE */
-   { 18498, 0x000088B1 }, /* GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB */
-   { 18535, 0x0000880B }, /* GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB */
-   { 18571, 0x000088AD }, /* GL_MAX_PROGRAM_ATTRIBS_ARB */
-   { 18598, 0x000088F5 }, /* GL_MAX_PROGRAM_CALL_DEPTH_NV */
-   { 18627, 0x000088B5 }, /* GL_MAX_PROGRAM_ENV_PARAMETERS_ARB */
-   { 18661, 0x000088F4 }, /* GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */
-   { 18697, 0x000088F6 }, /* GL_MAX_PROGRAM_IF_DEPTH_NV */
-   { 18724, 0x000088A1 }, /* GL_MAX_PROGRAM_INSTRUCTIONS_ARB */
-   { 18756, 0x000088B4 }, /* GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB */
-   { 18792, 0x000088F8 }, /* GL_MAX_PROGRAM_LOOP_COUNT_NV */
-   { 18821, 0x000088F7 }, /* GL_MAX_PROGRAM_LOOP_DEPTH_NV */
-   { 18850, 0x0000862F }, /* GL_MAX_PROGRAM_MATRICES_ARB */
-   { 18878, 0x0000862E }, /* GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB */
-   { 18916, 0x000088B3 }, /* GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */
-   { 18960, 0x0000880E }, /* GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */
-   { 19003, 0x000088AF }, /* GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB */
-   { 19037, 0x000088A3 }, /* GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB */
-   { 19076, 0x000088AB }, /* GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB */
-   { 19113, 0x000088A7 }, /* GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB */
-   { 19151, 0x00008810 }, /* GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */
-   { 19194, 0x0000880F }, /* GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */
-   { 19237, 0x000088A9 }, /* GL_MAX_PROGRAM_PARAMETERS_ARB */
-   { 19267, 0x000088A5 }, /* GL_MAX_PROGRAM_TEMPORARIES_ARB */
-   { 19298, 0x0000880D }, /* GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB */
-   { 19334, 0x0000880C }, /* GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB */
-   { 19370, 0x00000D38 }, /* GL_MAX_PROJECTION_STACK_DEPTH */
-   { 19400, 0x000084F8 }, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB */
-   { 19434, 0x000084F8 }, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_NV */
-   { 19467, 0x000084E8 }, /* GL_MAX_RENDERBUFFER_SIZE_EXT */
-   { 19496, 0x00008D57 }, /* GL_MAX_SAMPLES */
-   { 19511, 0x00009111 }, /* GL_MAX_SERVER_WAIT_TIMEOUT */
-   { 19538, 0x00008504 }, /* GL_MAX_SHININESS_NV */
-   { 19558, 0x00008505 }, /* GL_MAX_SPOT_EXPONENT_NV */
-   { 19582, 0x00008871 }, /* GL_MAX_TEXTURE_COORDS */
-   { 19604, 0x00008871 }, /* GL_MAX_TEXTURE_COORDS_ARB */
-   { 19630, 0x00008872 }, /* GL_MAX_TEXTURE_IMAGE_UNITS */
-   { 19657, 0x00008872 }, /* GL_MAX_TEXTURE_IMAGE_UNITS_ARB */
-   { 19688, 0x000084FD }, /* GL_MAX_TEXTURE_LOD_BIAS */
-   { 19712, 0x000084FF }, /* GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT */
-   { 19746, 0x00000D33 }, /* GL_MAX_TEXTURE_SIZE */
-   { 19766, 0x00000D39 }, /* GL_MAX_TEXTURE_STACK_DEPTH */
-   { 19793, 0x000084E2 }, /* GL_MAX_TEXTURE_UNITS */
-   { 19814, 0x000084E2 }, /* GL_MAX_TEXTURE_UNITS_ARB */
-   { 19839, 0x0000862F }, /* GL_MAX_TRACK_MATRICES_NV */
-   { 19864, 0x0000862E }, /* GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV */
-   { 19899, 0x00008B4B }, /* GL_MAX_VARYING_FLOATS */
-   { 19921, 0x00008B4B }, /* GL_MAX_VARYING_FLOATS_ARB */
-   { 19947, 0x00008869 }, /* GL_MAX_VERTEX_ATTRIBS */
-   { 19969, 0x00008869 }, /* GL_MAX_VERTEX_ATTRIBS_ARB */
-   { 19995, 0x00008B4C }, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS */
-   { 20029, 0x00008B4C }, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */
-   { 20067, 0x00008B4A }, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS */
-   { 20100, 0x00008B4A }, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB */
-   { 20137, 0x000086A4 }, /* GL_MAX_VERTEX_UNITS_ARB */
-   { 20161, 0x00000D3A }, /* GL_MAX_VIEWPORT_DIMS */
-   { 20182, 0x00008007 }, /* GL_MIN */
-   { 20189, 0x0000802E }, /* GL_MINMAX */
-   { 20199, 0x0000802E }, /* GL_MINMAX_EXT */
-   { 20213, 0x0000802F }, /* GL_MINMAX_FORMAT */
-   { 20230, 0x0000802F }, /* GL_MINMAX_FORMAT_EXT */
-   { 20251, 0x00008030 }, /* GL_MINMAX_SINK */
-   { 20266, 0x00008030 }, /* GL_MINMAX_SINK_EXT */
-   { 20285, 0x00008007 }, /* GL_MIN_EXT */
-   { 20296, 0x00008370 }, /* GL_MIRRORED_REPEAT */
-   { 20315, 0x00008370 }, /* GL_MIRRORED_REPEAT_ARB */
-   { 20338, 0x00008370 }, /* GL_MIRRORED_REPEAT_IBM */
-   { 20361, 0x00008742 }, /* GL_MIRROR_CLAMP_ATI */
-   { 20381, 0x00008742 }, /* GL_MIRROR_CLAMP_EXT */
-   { 20401, 0x00008912 }, /* GL_MIRROR_CLAMP_TO_BORDER_EXT */
-   { 20431, 0x00008743 }, /* GL_MIRROR_CLAMP_TO_EDGE_ATI */
-   { 20459, 0x00008743 }, /* GL_MIRROR_CLAMP_TO_EDGE_EXT */
-   { 20487, 0x00001700 }, /* GL_MODELVIEW */
-   { 20500, 0x00001700 }, /* GL_MODELVIEW0_ARB */
-   { 20518, 0x0000872A }, /* GL_MODELVIEW10_ARB */
-   { 20537, 0x0000872B }, /* GL_MODELVIEW11_ARB */
-   { 20556, 0x0000872C }, /* GL_MODELVIEW12_ARB */
-   { 20575, 0x0000872D }, /* GL_MODELVIEW13_ARB */
-   { 20594, 0x0000872E }, /* GL_MODELVIEW14_ARB */
-   { 20613, 0x0000872F }, /* GL_MODELVIEW15_ARB */
-   { 20632, 0x00008730 }, /* GL_MODELVIEW16_ARB */
-   { 20651, 0x00008731 }, /* GL_MODELVIEW17_ARB */
-   { 20670, 0x00008732 }, /* GL_MODELVIEW18_ARB */
-   { 20689, 0x00008733 }, /* GL_MODELVIEW19_ARB */
-   { 20708, 0x0000850A }, /* GL_MODELVIEW1_ARB */
-   { 20726, 0x00008734 }, /* GL_MODELVIEW20_ARB */
-   { 20745, 0x00008735 }, /* GL_MODELVIEW21_ARB */
-   { 20764, 0x00008736 }, /* GL_MODELVIEW22_ARB */
-   { 20783, 0x00008737 }, /* GL_MODELVIEW23_ARB */
-   { 20802, 0x00008738 }, /* GL_MODELVIEW24_ARB */
-   { 20821, 0x00008739 }, /* GL_MODELVIEW25_ARB */
-   { 20840, 0x0000873A }, /* GL_MODELVIEW26_ARB */
-   { 20859, 0x0000873B }, /* GL_MODELVIEW27_ARB */
-   { 20878, 0x0000873C }, /* GL_MODELVIEW28_ARB */
-   { 20897, 0x0000873D }, /* GL_MODELVIEW29_ARB */
-   { 20916, 0x00008722 }, /* GL_MODELVIEW2_ARB */
-   { 20934, 0x0000873E }, /* GL_MODELVIEW30_ARB */
-   { 20953, 0x0000873F }, /* GL_MODELVIEW31_ARB */
-   { 20972, 0x00008723 }, /* GL_MODELVIEW3_ARB */
-   { 20990, 0x00008724 }, /* GL_MODELVIEW4_ARB */
-   { 21008, 0x00008725 }, /* GL_MODELVIEW5_ARB */
-   { 21026, 0x00008726 }, /* GL_MODELVIEW6_ARB */
-   { 21044, 0x00008727 }, /* GL_MODELVIEW7_ARB */
-   { 21062, 0x00008728 }, /* GL_MODELVIEW8_ARB */
-   { 21080, 0x00008729 }, /* GL_MODELVIEW9_ARB */
-   { 21098, 0x00000BA6 }, /* GL_MODELVIEW_MATRIX */
-   { 21118, 0x00008629 }, /* GL_MODELVIEW_PROJECTION_NV */
-   { 21145, 0x00000BA3 }, /* GL_MODELVIEW_STACK_DEPTH */
-   { 21170, 0x00002100 }, /* GL_MODULATE */
-   { 21182, 0x00008744 }, /* GL_MODULATE_ADD_ATI */
-   { 21202, 0x00008745 }, /* GL_MODULATE_SIGNED_ADD_ATI */
-   { 21229, 0x00008746 }, /* GL_MODULATE_SUBTRACT_ATI */
-   { 21254, 0x00000103 }, /* GL_MULT */
-   { 21262, 0x0000809D }, /* GL_MULTISAMPLE */
-   { 21277, 0x000086B2 }, /* GL_MULTISAMPLE_3DFX */
-   { 21297, 0x0000809D }, /* GL_MULTISAMPLE_ARB */
-   { 21316, 0x20000000 }, /* GL_MULTISAMPLE_BIT */
-   { 21335, 0x20000000 }, /* GL_MULTISAMPLE_BIT_3DFX */
-   { 21359, 0x20000000 }, /* GL_MULTISAMPLE_BIT_ARB */
-   { 21382, 0x00008534 }, /* GL_MULTISAMPLE_FILTER_HINT_NV */
-   { 21412, 0x00002A25 }, /* GL_N3F_V3F */
-   { 21423, 0x00000D70 }, /* GL_NAME_STACK_DEPTH */
-   { 21443, 0x0000150E }, /* GL_NAND */
-   { 21451, 0x00002600 }, /* GL_NEAREST */
-   { 21462, 0x0000844E }, /* GL_NEAREST_CLIPMAP_LINEAR_SGIX */
-   { 21493, 0x0000844D }, /* GL_NEAREST_CLIPMAP_NEAREST_SGIX */
-   { 21525, 0x00002702 }, /* GL_NEAREST_MIPMAP_LINEAR */
-   { 21550, 0x00002700 }, /* GL_NEAREST_MIPMAP_NEAREST */
-   { 21576, 0x00000200 }, /* GL_NEVER */
-   { 21585, 0x00001102 }, /* GL_NICEST */
-   { 21595, 0x00000000 }, /* GL_NONE */
-   { 21603, 0x00001505 }, /* GL_NOOP */
-   { 21611, 0x00001508 }, /* GL_NOR */
-   { 21618, 0x00000BA1 }, /* GL_NORMALIZE */
-   { 21631, 0x00008075 }, /* GL_NORMAL_ARRAY */
-   { 21647, 0x00008897 }, /* GL_NORMAL_ARRAY_BUFFER_BINDING */
-   { 21678, 0x00008897 }, /* GL_NORMAL_ARRAY_BUFFER_BINDING_ARB */
-   { 21713, 0x0000808F }, /* GL_NORMAL_ARRAY_POINTER */
-   { 21737, 0x0000807F }, /* GL_NORMAL_ARRAY_STRIDE */
-   { 21760, 0x0000807E }, /* GL_NORMAL_ARRAY_TYPE */
-   { 21781, 0x00008511 }, /* GL_NORMAL_MAP */
-   { 21795, 0x00008511 }, /* GL_NORMAL_MAP_ARB */
-   { 21813, 0x00008511 }, /* GL_NORMAL_MAP_NV */
-   { 21830, 0x00000205 }, /* GL_NOTEQUAL */
-   { 21842, 0x00000000 }, /* GL_NO_ERROR */
-   { 21854, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS */
-   { 21888, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB */
-   { 21926, 0x00008B89 }, /* GL_OBJECT_ACTIVE_ATTRIBUTES_ARB */
-   { 21958, 0x00008B8A }, /* GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB */
-   { 22000, 0x00008B86 }, /* GL_OBJECT_ACTIVE_UNIFORMS_ARB */
-   { 22030, 0x00008B87 }, /* GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB */
-   { 22070, 0x00008B85 }, /* GL_OBJECT_ATTACHED_OBJECTS_ARB */
-   { 22101, 0x00008B81 }, /* GL_OBJECT_COMPILE_STATUS_ARB */
-   { 22130, 0x00008B80 }, /* GL_OBJECT_DELETE_STATUS_ARB */
-   { 22158, 0x00008B84 }, /* GL_OBJECT_INFO_LOG_LENGTH_ARB */
-   { 22188, 0x00002401 }, /* GL_OBJECT_LINEAR */
-   { 22205, 0x00008B82 }, /* GL_OBJECT_LINK_STATUS_ARB */
-   { 22231, 0x00002501 }, /* GL_OBJECT_PLANE */
-   { 22247, 0x00008B88 }, /* GL_OBJECT_SHADER_SOURCE_LENGTH_ARB */
-   { 22282, 0x00008B4F }, /* GL_OBJECT_SUBTYPE_ARB */
-   { 22304, 0x00009112 }, /* GL_OBJECT_TYPE */
-   { 22319, 0x00008B4E }, /* GL_OBJECT_TYPE_ARB */
-   { 22338, 0x00008B83 }, /* GL_OBJECT_VALIDATE_STATUS_ARB */
-   { 22368, 0x00008165 }, /* GL_OCCLUSION_TEST_HP */
-   { 22389, 0x00008166 }, /* GL_OCCLUSION_TEST_RESULT_HP */
-   { 22417, 0x00000001 }, /* GL_ONE */
-   { 22424, 0x00008004 }, /* GL_ONE_MINUS_CONSTANT_ALPHA */
-   { 22452, 0x00008004 }, /* GL_ONE_MINUS_CONSTANT_ALPHA_EXT */
-   { 22484, 0x00008002 }, /* GL_ONE_MINUS_CONSTANT_COLOR */
-   { 22512, 0x00008002 }, /* GL_ONE_MINUS_CONSTANT_COLOR_EXT */
-   { 22544, 0x00000305 }, /* GL_ONE_MINUS_DST_ALPHA */
-   { 22567, 0x00000307 }, /* GL_ONE_MINUS_DST_COLOR */
-   { 22590, 0x00000303 }, /* GL_ONE_MINUS_SRC_ALPHA */
-   { 22613, 0x00000301 }, /* GL_ONE_MINUS_SRC_COLOR */
-   { 22636, 0x00008598 }, /* GL_OPERAND0_ALPHA */
-   { 22654, 0x00008598 }, /* GL_OPERAND0_ALPHA_ARB */
-   { 22676, 0x00008598 }, /* GL_OPERAND0_ALPHA_EXT */
-   { 22698, 0x00008590 }, /* GL_OPERAND0_RGB */
-   { 22714, 0x00008590 }, /* GL_OPERAND0_RGB_ARB */
-   { 22734, 0x00008590 }, /* GL_OPERAND0_RGB_EXT */
-   { 22754, 0x00008599 }, /* GL_OPERAND1_ALPHA */
-   { 22772, 0x00008599 }, /* GL_OPERAND1_ALPHA_ARB */
-   { 22794, 0x00008599 }, /* GL_OPERAND1_ALPHA_EXT */
-   { 22816, 0x00008591 }, /* GL_OPERAND1_RGB */
-   { 22832, 0x00008591 }, /* GL_OPERAND1_RGB_ARB */
-   { 22852, 0x00008591 }, /* GL_OPERAND1_RGB_EXT */
-   { 22872, 0x0000859A }, /* GL_OPERAND2_ALPHA */
-   { 22890, 0x0000859A }, /* GL_OPERAND2_ALPHA_ARB */
-   { 22912, 0x0000859A }, /* GL_OPERAND2_ALPHA_EXT */
-   { 22934, 0x00008592 }, /* GL_OPERAND2_RGB */
-   { 22950, 0x00008592 }, /* GL_OPERAND2_RGB_ARB */
-   { 22970, 0x00008592 }, /* GL_OPERAND2_RGB_EXT */
-   { 22990, 0x0000859B }, /* GL_OPERAND3_ALPHA_NV */
-   { 23011, 0x00008593 }, /* GL_OPERAND3_RGB_NV */
-   { 23030, 0x00001507 }, /* GL_OR */
-   { 23036, 0x00000A01 }, /* GL_ORDER */
-   { 23045, 0x0000150D }, /* GL_OR_INVERTED */
-   { 23060, 0x0000150B }, /* GL_OR_REVERSE */
-   { 23074, 0x00000505 }, /* GL_OUT_OF_MEMORY */
-   { 23091, 0x00000D05 }, /* GL_PACK_ALIGNMENT */
-   { 23109, 0x0000806C }, /* GL_PACK_IMAGE_HEIGHT */
-   { 23130, 0x00008758 }, /* GL_PACK_INVERT_MESA */
-   { 23150, 0x00000D01 }, /* GL_PACK_LSB_FIRST */
-   { 23168, 0x00000D02 }, /* GL_PACK_ROW_LENGTH */
-   { 23187, 0x0000806B }, /* GL_PACK_SKIP_IMAGES */
-   { 23207, 0x00000D04 }, /* GL_PACK_SKIP_PIXELS */
-   { 23227, 0x00000D03 }, /* GL_PACK_SKIP_ROWS */
-   { 23245, 0x00000D00 }, /* GL_PACK_SWAP_BYTES */
-   { 23264, 0x00008B92 }, /* GL_PALETTE4_R5_G6_B5_OES */
-   { 23289, 0x00008B94 }, /* GL_PALETTE4_RGB5_A1_OES */
-   { 23313, 0x00008B90 }, /* GL_PALETTE4_RGB8_OES */
-   { 23334, 0x00008B93 }, /* GL_PALETTE4_RGBA4_OES */
-   { 23356, 0x00008B91 }, /* GL_PALETTE4_RGBA8_OES */
-   { 23378, 0x00008B97 }, /* GL_PALETTE8_R5_G6_B5_OES */
-   { 23403, 0x00008B99 }, /* GL_PALETTE8_RGB5_A1_OES */
-   { 23427, 0x00008B95 }, /* GL_PALETTE8_RGB8_OES */
-   { 23448, 0x00008B98 }, /* GL_PALETTE8_RGBA4_OES */
-   { 23470, 0x00008B96 }, /* GL_PALETTE8_RGBA8_OES */
-   { 23492, 0x00000700 }, /* GL_PASS_THROUGH_TOKEN */
-   { 23514, 0x00000C50 }, /* GL_PERSPECTIVE_CORRECTION_HINT */
-   { 23545, 0x00000C79 }, /* GL_PIXEL_MAP_A_TO_A */
-   { 23565, 0x00000CB9 }, /* GL_PIXEL_MAP_A_TO_A_SIZE */
-   { 23590, 0x00000C78 }, /* GL_PIXEL_MAP_B_TO_B */
-   { 23610, 0x00000CB8 }, /* GL_PIXEL_MAP_B_TO_B_SIZE */
-   { 23635, 0x00000C77 }, /* GL_PIXEL_MAP_G_TO_G */
-   { 23655, 0x00000CB7 }, /* GL_PIXEL_MAP_G_TO_G_SIZE */
-   { 23680, 0x00000C75 }, /* GL_PIXEL_MAP_I_TO_A */
-   { 23700, 0x00000CB5 }, /* GL_PIXEL_MAP_I_TO_A_SIZE */
-   { 23725, 0x00000C74 }, /* GL_PIXEL_MAP_I_TO_B */
-   { 23745, 0x00000CB4 }, /* GL_PIXEL_MAP_I_TO_B_SIZE */
-   { 23770, 0x00000C73 }, /* GL_PIXEL_MAP_I_TO_G */
-   { 23790, 0x00000CB3 }, /* GL_PIXEL_MAP_I_TO_G_SIZE */
-   { 23815, 0x00000C70 }, /* GL_PIXEL_MAP_I_TO_I */
-   { 23835, 0x00000CB0 }, /* GL_PIXEL_MAP_I_TO_I_SIZE */
-   { 23860, 0x00000C72 }, /* GL_PIXEL_MAP_I_TO_R */
-   { 23880, 0x00000CB2 }, /* GL_PIXEL_MAP_I_TO_R_SIZE */
-   { 23905, 0x00000C76 }, /* GL_PIXEL_MAP_R_TO_R */
-   { 23925, 0x00000CB6 }, /* GL_PIXEL_MAP_R_TO_R_SIZE */
-   { 23950, 0x00000C71 }, /* GL_PIXEL_MAP_S_TO_S */
-   { 23970, 0x00000CB1 }, /* GL_PIXEL_MAP_S_TO_S_SIZE */
-   { 23995, 0x00000020 }, /* GL_PIXEL_MODE_BIT */
-   { 24013, 0x000088EB }, /* GL_PIXEL_PACK_BUFFER */
-   { 24034, 0x000088ED }, /* GL_PIXEL_PACK_BUFFER_BINDING */
-   { 24063, 0x000088ED }, /* GL_PIXEL_PACK_BUFFER_BINDING_EXT */
-   { 24096, 0x000088EB }, /* GL_PIXEL_PACK_BUFFER_EXT */
-   { 24121, 0x000088EC }, /* GL_PIXEL_UNPACK_BUFFER */
-   { 24144, 0x000088EF }, /* GL_PIXEL_UNPACK_BUFFER_BINDING */
-   { 24175, 0x000088EF }, /* GL_PIXEL_UNPACK_BUFFER_BINDING_EXT */
-   { 24210, 0x000088EC }, /* GL_PIXEL_UNPACK_BUFFER_EXT */
-   { 24237, 0x00001B00 }, /* GL_POINT */
-   { 24246, 0x00000000 }, /* GL_POINTS */
-   { 24256, 0x00000002 }, /* GL_POINT_BIT */
-   { 24269, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION */
-   { 24299, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_ARB */
-   { 24333, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_EXT */
-   { 24367, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_SGIS */
-   { 24402, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE */
-   { 24431, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_ARB */
-   { 24464, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_EXT */
-   { 24497, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_SGIS */
-   { 24531, 0x00000B11 }, /* GL_POINT_SIZE */
-   { 24545, 0x00000B13 }, /* GL_POINT_SIZE_GRANULARITY */
-   { 24571, 0x00008127 }, /* GL_POINT_SIZE_MAX */
-   { 24589, 0x00008127 }, /* GL_POINT_SIZE_MAX_ARB */
-   { 24611, 0x00008127 }, /* GL_POINT_SIZE_MAX_EXT */
-   { 24633, 0x00008127 }, /* GL_POINT_SIZE_MAX_SGIS */
-   { 24656, 0x00008126 }, /* GL_POINT_SIZE_MIN */
-   { 24674, 0x00008126 }, /* GL_POINT_SIZE_MIN_ARB */
-   { 24696, 0x00008126 }, /* GL_POINT_SIZE_MIN_EXT */
-   { 24718, 0x00008126 }, /* GL_POINT_SIZE_MIN_SGIS */
-   { 24741, 0x00000B12 }, /* GL_POINT_SIZE_RANGE */
-   { 24761, 0x00000B10 }, /* GL_POINT_SMOOTH */
-   { 24777, 0x00000C51 }, /* GL_POINT_SMOOTH_HINT */
-   { 24798, 0x00008861 }, /* GL_POINT_SPRITE */
-   { 24814, 0x00008861 }, /* GL_POINT_SPRITE_ARB */
-   { 24834, 0x00008CA0 }, /* GL_POINT_SPRITE_COORD_ORIGIN */
-   { 24863, 0x00008861 }, /* GL_POINT_SPRITE_NV */
-   { 24882, 0x00008863 }, /* GL_POINT_SPRITE_R_MODE_NV */
-   { 24908, 0x00000701 }, /* GL_POINT_TOKEN */
-   { 24923, 0x00000009 }, /* GL_POLYGON */
-   { 24934, 0x00000008 }, /* GL_POLYGON_BIT */
-   { 24949, 0x00000B40 }, /* GL_POLYGON_MODE */
-   { 24965, 0x00008039 }, /* GL_POLYGON_OFFSET_BIAS */
-   { 24988, 0x00008038 }, /* GL_POLYGON_OFFSET_FACTOR */
-   { 25013, 0x00008037 }, /* GL_POLYGON_OFFSET_FILL */
-   { 25036, 0x00002A02 }, /* GL_POLYGON_OFFSET_LINE */
-   { 25059, 0x00002A01 }, /* GL_POLYGON_OFFSET_POINT */
-   { 25083, 0x00002A00 }, /* GL_POLYGON_OFFSET_UNITS */
-   { 25107, 0x00000B41 }, /* GL_POLYGON_SMOOTH */
-   { 25125, 0x00000C53 }, /* GL_POLYGON_SMOOTH_HINT */
-   { 25148, 0x00000B42 }, /* GL_POLYGON_STIPPLE */
-   { 25167, 0x00000010 }, /* GL_POLYGON_STIPPLE_BIT */
-   { 25190, 0x00000703 }, /* GL_POLYGON_TOKEN */
-   { 25207, 0x00001203 }, /* GL_POSITION */
-   { 25219, 0x000080BB }, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS */
-   { 25251, 0x000080BB }, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI */
-   { 25287, 0x000080B7 }, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE */
-   { 25320, 0x000080B7 }, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI */
-   { 25357, 0x000080BA }, /* GL_POST_COLOR_MATRIX_BLUE_BIAS */
-   { 25388, 0x000080BA }, /* GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI */
-   { 25423, 0x000080B6 }, /* GL_POST_COLOR_MATRIX_BLUE_SCALE */
-   { 25455, 0x000080B6 }, /* GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI */
-   { 25491, 0x000080D2 }, /* GL_POST_COLOR_MATRIX_COLOR_TABLE */
-   { 25524, 0x000080B9 }, /* GL_POST_COLOR_MATRIX_GREEN_BIAS */
-   { 25556, 0x000080B9 }, /* GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI */
-   { 25592, 0x000080B5 }, /* GL_POST_COLOR_MATRIX_GREEN_SCALE */
-   { 25625, 0x000080B5 }, /* GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI */
-   { 25662, 0x000080B8 }, /* GL_POST_COLOR_MATRIX_RED_BIAS */
-   { 25692, 0x000080B8 }, /* GL_POST_COLOR_MATRIX_RED_BIAS_SGI */
-   { 25726, 0x000080B4 }, /* GL_POST_COLOR_MATRIX_RED_SCALE */
-   { 25757, 0x000080B4 }, /* GL_POST_COLOR_MATRIX_RED_SCALE_SGI */
-   { 25792, 0x00008023 }, /* GL_POST_CONVOLUTION_ALPHA_BIAS */
-   { 25823, 0x00008023 }, /* GL_POST_CONVOLUTION_ALPHA_BIAS_EXT */
-   { 25858, 0x0000801F }, /* GL_POST_CONVOLUTION_ALPHA_SCALE */
-   { 25890, 0x0000801F }, /* GL_POST_CONVOLUTION_ALPHA_SCALE_EXT */
-   { 25926, 0x00008022 }, /* GL_POST_CONVOLUTION_BLUE_BIAS */
-   { 25956, 0x00008022 }, /* GL_POST_CONVOLUTION_BLUE_BIAS_EXT */
-   { 25990, 0x0000801E }, /* GL_POST_CONVOLUTION_BLUE_SCALE */
-   { 26021, 0x0000801E }, /* GL_POST_CONVOLUTION_BLUE_SCALE_EXT */
-   { 26056, 0x000080D1 }, /* GL_POST_CONVOLUTION_COLOR_TABLE */
-   { 26088, 0x00008021 }, /* GL_POST_CONVOLUTION_GREEN_BIAS */
-   { 26119, 0x00008021 }, /* GL_POST_CONVOLUTION_GREEN_BIAS_EXT */
-   { 26154, 0x0000801D }, /* GL_POST_CONVOLUTION_GREEN_SCALE */
-   { 26186, 0x0000801D }, /* GL_POST_CONVOLUTION_GREEN_SCALE_EXT */
-   { 26222, 0x00008020 }, /* GL_POST_CONVOLUTION_RED_BIAS */
-   { 26251, 0x00008020 }, /* GL_POST_CONVOLUTION_RED_BIAS_EXT */
-   { 26284, 0x0000801C }, /* GL_POST_CONVOLUTION_RED_SCALE */
-   { 26314, 0x0000801C }, /* GL_POST_CONVOLUTION_RED_SCALE_EXT */
-   { 26348, 0x0000817B }, /* GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX */
-   { 26387, 0x00008179 }, /* GL_POST_TEXTURE_FILTER_BIAS_SGIX */
-   { 26420, 0x0000817C }, /* GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX */
-   { 26460, 0x0000817A }, /* GL_POST_TEXTURE_FILTER_SCALE_SGIX */
-   { 26494, 0x00008578 }, /* GL_PREVIOUS */
-   { 26506, 0x00008578 }, /* GL_PREVIOUS_ARB */
-   { 26522, 0x00008578 }, /* GL_PREVIOUS_EXT */
-   { 26538, 0x00008577 }, /* GL_PRIMARY_COLOR */
-   { 26555, 0x00008577 }, /* GL_PRIMARY_COLOR_ARB */
-   { 26576, 0x00008577 }, /* GL_PRIMARY_COLOR_EXT */
-   { 26597, 0x000088B0 }, /* GL_PROGRAM_ADDRESS_REGISTERS_ARB */
-   { 26630, 0x00008805 }, /* GL_PROGRAM_ALU_INSTRUCTIONS_ARB */
-   { 26662, 0x000088AC }, /* GL_PROGRAM_ATTRIBS_ARB */
-   { 26685, 0x00008677 }, /* GL_PROGRAM_BINDING_ARB */
-   { 26708, 0x0000864B }, /* GL_PROGRAM_ERROR_POSITION_ARB */
-   { 26738, 0x0000864B }, /* GL_PROGRAM_ERROR_POSITION_NV */
-   { 26767, 0x00008874 }, /* GL_PROGRAM_ERROR_STRING_ARB */
-   { 26795, 0x00008876 }, /* GL_PROGRAM_FORMAT_ARB */
-   { 26817, 0x00008875 }, /* GL_PROGRAM_FORMAT_ASCII_ARB */
-   { 26845, 0x000088A0 }, /* GL_PROGRAM_INSTRUCTIONS_ARB */
-   { 26873, 0x00008627 }, /* GL_PROGRAM_LENGTH_ARB */
-   { 26895, 0x00008627 }, /* GL_PROGRAM_LENGTH_NV */
-   { 26916, 0x000088B2 }, /* GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */
-   { 26956, 0x00008808 }, /* GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */
-   { 26995, 0x000088AE }, /* GL_PROGRAM_NATIVE_ATTRIBS_ARB */
-   { 27025, 0x000088A2 }, /* GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB */
-   { 27060, 0x000088AA }, /* GL_PROGRAM_NATIVE_PARAMETERS_ARB */
-   { 27093, 0x000088A6 }, /* GL_PROGRAM_NATIVE_TEMPORARIES_ARB */
-   { 27127, 0x0000880A }, /* GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */
-   { 27166, 0x00008809 }, /* GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */
-   { 27205, 0x00008B40 }, /* GL_PROGRAM_OBJECT_ARB */
-   { 27227, 0x000088A8 }, /* GL_PROGRAM_PARAMETERS_ARB */
-   { 27253, 0x00008644 }, /* GL_PROGRAM_PARAMETER_NV */
-   { 27277, 0x00008647 }, /* GL_PROGRAM_RESIDENT_NV */
-   { 27300, 0x00008628 }, /* GL_PROGRAM_STRING_ARB */
-   { 27322, 0x00008628 }, /* GL_PROGRAM_STRING_NV */
-   { 27343, 0x00008646 }, /* GL_PROGRAM_TARGET_NV */
-   { 27364, 0x000088A4 }, /* GL_PROGRAM_TEMPORARIES_ARB */
-   { 27391, 0x00008807 }, /* GL_PROGRAM_TEX_INDIRECTIONS_ARB */
-   { 27423, 0x00008806 }, /* GL_PROGRAM_TEX_INSTRUCTIONS_ARB */
-   { 27455, 0x000088B6 }, /* GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB */
-   { 27490, 0x00001701 }, /* GL_PROJECTION */
-   { 27504, 0x00000BA7 }, /* GL_PROJECTION_MATRIX */
-   { 27525, 0x00000BA4 }, /* GL_PROJECTION_STACK_DEPTH */
-   { 27551, 0x00008E4F }, /* GL_PROVOKING_VERTEX */
-   { 27571, 0x00008E4F }, /* GL_PROVOKING_VERTEX_EXT */
-   { 27595, 0x000080D3 }, /* GL_PROXY_COLOR_TABLE */
-   { 27616, 0x00008025 }, /* GL_PROXY_HISTOGRAM */
-   { 27635, 0x00008025 }, /* GL_PROXY_HISTOGRAM_EXT */
-   { 27658, 0x000080D5 }, /* GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE */
-   { 27697, 0x000080D4 }, /* GL_PROXY_POST_CONVOLUTION_COLOR_TABLE */
-   { 27735, 0x00008063 }, /* GL_PROXY_TEXTURE_1D */
-   { 27755, 0x00008C19 }, /* GL_PROXY_TEXTURE_1D_ARRAY_EXT */
-   { 27785, 0x00008063 }, /* GL_PROXY_TEXTURE_1D_EXT */
-   { 27809, 0x00008064 }, /* GL_PROXY_TEXTURE_2D */
-   { 27829, 0x00008C1B }, /* GL_PROXY_TEXTURE_2D_ARRAY_EXT */
-   { 27859, 0x00008064 }, /* GL_PROXY_TEXTURE_2D_EXT */
-   { 27883, 0x00008070 }, /* GL_PROXY_TEXTURE_3D */
-   { 27903, 0x000080BD }, /* GL_PROXY_TEXTURE_COLOR_TABLE_SGI */
-   { 27936, 0x0000851B }, /* GL_PROXY_TEXTURE_CUBE_MAP */
-   { 27962, 0x0000851B }, /* GL_PROXY_TEXTURE_CUBE_MAP_ARB */
-   { 27992, 0x000084F7 }, /* GL_PROXY_TEXTURE_RECTANGLE_ARB */
-   { 28023, 0x000084F7 }, /* GL_PROXY_TEXTURE_RECTANGLE_NV */
-   { 28053, 0x00002003 }, /* GL_Q */
-   { 28058, 0x00001209 }, /* GL_QUADRATIC_ATTENUATION */
-   { 28083, 0x00000007 }, /* GL_QUADS */
-   { 28092, 0x00008E4C }, /* GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */
-   { 28136, 0x00008E4C }, /* GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT */
-   { 28184, 0x00008614 }, /* GL_QUAD_MESH_SUN */
-   { 28201, 0x00000008 }, /* GL_QUAD_STRIP */
-   { 28215, 0x00008864 }, /* GL_QUERY_COUNTER_BITS */
-   { 28237, 0x00008864 }, /* GL_QUERY_COUNTER_BITS_ARB */
-   { 28263, 0x00008866 }, /* GL_QUERY_RESULT */
-   { 28279, 0x00008866 }, /* GL_QUERY_RESULT_ARB */
-   { 28299, 0x00008867 }, /* GL_QUERY_RESULT_AVAILABLE */
-   { 28325, 0x00008867 }, /* GL_QUERY_RESULT_AVAILABLE_ARB */
-   { 28355, 0x00002002 }, /* GL_R */
-   { 28360, 0x00002A10 }, /* GL_R3_G3_B2 */
-   { 28372, 0x00019262 }, /* GL_RASTER_POSITION_UNCLIPPED_IBM */
-   { 28405, 0x00000C02 }, /* GL_READ_BUFFER */
-   { 28420, 0x00008CA8 }, /* GL_READ_FRAMEBUFFER */
-   { 28440, 0x00008CAA }, /* GL_READ_FRAMEBUFFER_BINDING_EXT */
-   { 28472, 0x00008CA8 }, /* GL_READ_FRAMEBUFFER_EXT */
-   { 28496, 0x000088B8 }, /* GL_READ_ONLY */
-   { 28509, 0x000088B8 }, /* GL_READ_ONLY_ARB */
-   { 28526, 0x000088BA }, /* GL_READ_WRITE */
-   { 28540, 0x000088BA }, /* GL_READ_WRITE_ARB */
-   { 28558, 0x00001903 }, /* GL_RED */
-   { 28565, 0x00008016 }, /* GL_REDUCE */
-   { 28575, 0x00008016 }, /* GL_REDUCE_EXT */
-   { 28589, 0x00000D15 }, /* GL_RED_BIAS */
-   { 28601, 0x00000D52 }, /* GL_RED_BITS */
-   { 28613, 0x00000D14 }, /* GL_RED_SCALE */
-   { 28626, 0x00008512 }, /* GL_REFLECTION_MAP */
-   { 28644, 0x00008512 }, /* GL_REFLECTION_MAP_ARB */
-   { 28666, 0x00008512 }, /* GL_REFLECTION_MAP_NV */
-   { 28687, 0x00001C00 }, /* GL_RENDER */
-   { 28697, 0x00008D41 }, /* GL_RENDERBUFFER */
-   { 28713, 0x00008D53 }, /* GL_RENDERBUFFER_ALPHA_SIZE */
-   { 28740, 0x00008CA7 }, /* GL_RENDERBUFFER_BINDING_EXT */
-   { 28768, 0x00008D52 }, /* GL_RENDERBUFFER_BLUE_SIZE */
-   { 28794, 0x00008D54 }, /* GL_RENDERBUFFER_DEPTH_SIZE */
-   { 28821, 0x00008D41 }, /* GL_RENDERBUFFER_EXT */
-   { 28841, 0x00008D51 }, /* GL_RENDERBUFFER_GREEN_SIZE */
-   { 28868, 0x00008D43 }, /* GL_RENDERBUFFER_HEIGHT */
-   { 28891, 0x00008D43 }, /* GL_RENDERBUFFER_HEIGHT_EXT */
-   { 28918, 0x00008D44 }, /* GL_RENDERBUFFER_INTERNAL_FORMAT */
-   { 28950, 0x00008D44 }, /* GL_RENDERBUFFER_INTERNAL_FORMAT_EXT */
-   { 28986, 0x00008D50 }, /* GL_RENDERBUFFER_RED_SIZE */
-   { 29011, 0x00008CAB }, /* GL_RENDERBUFFER_SAMPLES */
-   { 29035, 0x00008D55 }, /* GL_RENDERBUFFER_STENCIL_SIZE */
-   { 29064, 0x00008D42 }, /* GL_RENDERBUFFER_WIDTH */
-   { 29086, 0x00008D42 }, /* GL_RENDERBUFFER_WIDTH_EXT */
-   { 29112, 0x00001F01 }, /* GL_RENDERER */
-   { 29124, 0x00000C40 }, /* GL_RENDER_MODE */
-   { 29139, 0x00002901 }, /* GL_REPEAT */
-   { 29149, 0x00001E01 }, /* GL_REPLACE */
-   { 29160, 0x00008062 }, /* GL_REPLACE_EXT */
-   { 29175, 0x00008153 }, /* GL_REPLICATE_BORDER_HP */
-   { 29198, 0x0000803A }, /* GL_RESCALE_NORMAL */
-   { 29216, 0x0000803A }, /* GL_RESCALE_NORMAL_EXT */
-   { 29238, 0x00000102 }, /* GL_RETURN */
-   { 29248, 0x00001907 }, /* GL_RGB */
-   { 29255, 0x00008052 }, /* GL_RGB10 */
-   { 29264, 0x00008059 }, /* GL_RGB10_A2 */
-   { 29276, 0x00008059 }, /* GL_RGB10_A2_EXT */
-   { 29292, 0x00008052 }, /* GL_RGB10_EXT */
-   { 29305, 0x00008053 }, /* GL_RGB12 */
-   { 29314, 0x00008053 }, /* GL_RGB12_EXT */
-   { 29327, 0x00008054 }, /* GL_RGB16 */
-   { 29336, 0x00008054 }, /* GL_RGB16_EXT */
-   { 29349, 0x0000804E }, /* GL_RGB2_EXT */
-   { 29361, 0x0000804F }, /* GL_RGB4 */
-   { 29369, 0x0000804F }, /* GL_RGB4_EXT */
-   { 29381, 0x000083A1 }, /* GL_RGB4_S3TC */
-   { 29394, 0x00008050 }, /* GL_RGB5 */
-   { 29402, 0x00008057 }, /* GL_RGB5_A1 */
-   { 29413, 0x00008057 }, /* GL_RGB5_A1_EXT */
-   { 29428, 0x00008050 }, /* GL_RGB5_EXT */
-   { 29440, 0x00008051 }, /* GL_RGB8 */
-   { 29448, 0x00008051 }, /* GL_RGB8_EXT */
-   { 29460, 0x00001908 }, /* GL_RGBA */
-   { 29468, 0x0000805A }, /* GL_RGBA12 */
-   { 29478, 0x0000805A }, /* GL_RGBA12_EXT */
-   { 29492, 0x0000805B }, /* GL_RGBA16 */
-   { 29502, 0x0000805B }, /* GL_RGBA16_EXT */
-   { 29516, 0x00008055 }, /* GL_RGBA2 */
-   { 29525, 0x00008055 }, /* GL_RGBA2_EXT */
-   { 29538, 0x00008056 }, /* GL_RGBA4 */
-   { 29547, 0x000083A5 }, /* GL_RGBA4_DXT5_S3TC */
-   { 29566, 0x00008056 }, /* GL_RGBA4_EXT */
-   { 29579, 0x000083A3 }, /* GL_RGBA4_S3TC */
-   { 29593, 0x00008058 }, /* GL_RGBA8 */
-   { 29602, 0x00008058 }, /* GL_RGBA8_EXT */
-   { 29615, 0x00008F97 }, /* GL_RGBA8_SNORM */
-   { 29630, 0x000083A4 }, /* GL_RGBA_DXT5_S3TC */
-   { 29648, 0x00000C31 }, /* GL_RGBA_MODE */
-   { 29661, 0x000083A2 }, /* GL_RGBA_S3TC */
-   { 29674, 0x00008F93 }, /* GL_RGBA_SNORM */
-   { 29688, 0x000083A0 }, /* GL_RGB_S3TC */
-   { 29700, 0x00008573 }, /* GL_RGB_SCALE */
-   { 29713, 0x00008573 }, /* GL_RGB_SCALE_ARB */
-   { 29730, 0x00008573 }, /* GL_RGB_SCALE_EXT */
-   { 29747, 0x00000407 }, /* GL_RIGHT */
-   { 29756, 0x00002000 }, /* GL_S */
-   { 29761, 0x00008B5D }, /* GL_SAMPLER_1D */
-   { 29775, 0x00008B61 }, /* GL_SAMPLER_1D_SHADOW */
-   { 29796, 0x00008B5E }, /* GL_SAMPLER_2D */
-   { 29810, 0x00008B62 }, /* GL_SAMPLER_2D_SHADOW */
-   { 29831, 0x00008B5F }, /* GL_SAMPLER_3D */
-   { 29845, 0x00008B60 }, /* GL_SAMPLER_CUBE */
-   { 29861, 0x000080A9 }, /* GL_SAMPLES */
-   { 29872, 0x000086B4 }, /* GL_SAMPLES_3DFX */
-   { 29888, 0x000080A9 }, /* GL_SAMPLES_ARB */
-   { 29903, 0x00008914 }, /* GL_SAMPLES_PASSED */
-   { 29921, 0x00008914 }, /* GL_SAMPLES_PASSED_ARB */
-   { 29943, 0x0000809E }, /* GL_SAMPLE_ALPHA_TO_COVERAGE */
-   { 29971, 0x0000809E }, /* GL_SAMPLE_ALPHA_TO_COVERAGE_ARB */
-   { 30003, 0x0000809F }, /* GL_SAMPLE_ALPHA_TO_ONE */
-   { 30026, 0x0000809F }, /* GL_SAMPLE_ALPHA_TO_ONE_ARB */
-   { 30053, 0x000080A8 }, /* GL_SAMPLE_BUFFERS */
-   { 30071, 0x000086B3 }, /* GL_SAMPLE_BUFFERS_3DFX */
-   { 30094, 0x000080A8 }, /* GL_SAMPLE_BUFFERS_ARB */
-   { 30116, 0x000080A0 }, /* GL_SAMPLE_COVERAGE */
-   { 30135, 0x000080A0 }, /* GL_SAMPLE_COVERAGE_ARB */
-   { 30158, 0x000080AB }, /* GL_SAMPLE_COVERAGE_INVERT */
-   { 30184, 0x000080AB }, /* GL_SAMPLE_COVERAGE_INVERT_ARB */
-   { 30214, 0x000080AA }, /* GL_SAMPLE_COVERAGE_VALUE */
-   { 30239, 0x000080AA }, /* GL_SAMPLE_COVERAGE_VALUE_ARB */
-   { 30268, 0x00080000 }, /* GL_SCISSOR_BIT */
-   { 30283, 0x00000C10 }, /* GL_SCISSOR_BOX */
-   { 30298, 0x00000C11 }, /* GL_SCISSOR_TEST */
-   { 30314, 0x0000845E }, /* GL_SECONDARY_COLOR_ARRAY */
-   { 30339, 0x0000889C }, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING */
-   { 30379, 0x0000889C }, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB */
-   { 30423, 0x0000845D }, /* GL_SECONDARY_COLOR_ARRAY_POINTER */
-   { 30456, 0x0000845A }, /* GL_SECONDARY_COLOR_ARRAY_SIZE */
-   { 30486, 0x0000845C }, /* GL_SECONDARY_COLOR_ARRAY_STRIDE */
-   { 30518, 0x0000845B }, /* GL_SECONDARY_COLOR_ARRAY_TYPE */
-   { 30548, 0x00001C02 }, /* GL_SELECT */
-   { 30558, 0x00000DF3 }, /* GL_SELECTION_BUFFER_POINTER */
-   { 30586, 0x00000DF4 }, /* GL_SELECTION_BUFFER_SIZE */
-   { 30611, 0x00008012 }, /* GL_SEPARABLE_2D */
-   { 30627, 0x000081FA }, /* GL_SEPARATE_SPECULAR_COLOR */
-   { 30654, 0x000081FA }, /* GL_SEPARATE_SPECULAR_COLOR_EXT */
-   { 30685, 0x0000150F }, /* GL_SET */
-   { 30692, 0x00008B48 }, /* GL_SHADER_OBJECT_ARB */
-   { 30713, 0x00008B88 }, /* GL_SHADER_SOURCE_LENGTH */
-   { 30737, 0x00008B4F }, /* GL_SHADER_TYPE */
-   { 30752, 0x00000B54 }, /* GL_SHADE_MODEL */
-   { 30767, 0x00008B8C }, /* GL_SHADING_LANGUAGE_VERSION */
-   { 30795, 0x000080BF }, /* GL_SHADOW_AMBIENT_SGIX */
-   { 30818, 0x000081FB }, /* GL_SHARED_TEXTURE_PALETTE_EXT */
-   { 30848, 0x00001601 }, /* GL_SHININESS */
-   { 30861, 0x00001402 }, /* GL_SHORT */
-   { 30870, 0x00009119 }, /* GL_SIGNALED */
-   { 30882, 0x00008F9C }, /* GL_SIGNED_NORMALIZED */
-   { 30903, 0x000081F9 }, /* GL_SINGLE_COLOR */
-   { 30919, 0x000081F9 }, /* GL_SINGLE_COLOR_EXT */
-   { 30939, 0x000085CC }, /* GL_SLICE_ACCUM_SUN */
-   { 30958, 0x00008C46 }, /* GL_SLUMINANCE */
-   { 30972, 0x00008C47 }, /* GL_SLUMINANCE8 */
-   { 30987, 0x00008C45 }, /* GL_SLUMINANCE8_ALPHA8 */
-   { 31009, 0x00008C44 }, /* GL_SLUMINANCE_ALPHA */
-   { 31029, 0x00001D01 }, /* GL_SMOOTH */
-   { 31039, 0x00000B23 }, /* GL_SMOOTH_LINE_WIDTH_GRANULARITY */
-   { 31072, 0x00000B22 }, /* GL_SMOOTH_LINE_WIDTH_RANGE */
-   { 31099, 0x00000B13 }, /* GL_SMOOTH_POINT_SIZE_GRANULARITY */
-   { 31132, 0x00000B12 }, /* GL_SMOOTH_POINT_SIZE_RANGE */
-   { 31159, 0x00008588 }, /* GL_SOURCE0_ALPHA */
-   { 31176, 0x00008588 }, /* GL_SOURCE0_ALPHA_ARB */
-   { 31197, 0x00008588 }, /* GL_SOURCE0_ALPHA_EXT */
-   { 31218, 0x00008580 }, /* GL_SOURCE0_RGB */
-   { 31233, 0x00008580 }, /* GL_SOURCE0_RGB_ARB */
-   { 31252, 0x00008580 }, /* GL_SOURCE0_RGB_EXT */
-   { 31271, 0x00008589 }, /* GL_SOURCE1_ALPHA */
-   { 31288, 0x00008589 }, /* GL_SOURCE1_ALPHA_ARB */
-   { 31309, 0x00008589 }, /* GL_SOURCE1_ALPHA_EXT */
-   { 31330, 0x00008581 }, /* GL_SOURCE1_RGB */
-   { 31345, 0x00008581 }, /* GL_SOURCE1_RGB_ARB */
-   { 31364, 0x00008581 }, /* GL_SOURCE1_RGB_EXT */
-   { 31383, 0x0000858A }, /* GL_SOURCE2_ALPHA */
-   { 31400, 0x0000858A }, /* GL_SOURCE2_ALPHA_ARB */
-   { 31421, 0x0000858A }, /* GL_SOURCE2_ALPHA_EXT */
-   { 31442, 0x00008582 }, /* GL_SOURCE2_RGB */
-   { 31457, 0x00008582 }, /* GL_SOURCE2_RGB_ARB */
-   { 31476, 0x00008582 }, /* GL_SOURCE2_RGB_EXT */
-   { 31495, 0x0000858B }, /* GL_SOURCE3_ALPHA_NV */
-   { 31515, 0x00008583 }, /* GL_SOURCE3_RGB_NV */
-   { 31533, 0x00001202 }, /* GL_SPECULAR */
-   { 31545, 0x00002402 }, /* GL_SPHERE_MAP */
-   { 31559, 0x00001206 }, /* GL_SPOT_CUTOFF */
-   { 31574, 0x00001204 }, /* GL_SPOT_DIRECTION */
-   { 31592, 0x00001205 }, /* GL_SPOT_EXPONENT */
-   { 31609, 0x00008588 }, /* GL_SRC0_ALPHA */
-   { 31623, 0x00008580 }, /* GL_SRC0_RGB */
-   { 31635, 0x00008589 }, /* GL_SRC1_ALPHA */
-   { 31649, 0x00008581 }, /* GL_SRC1_RGB */
-   { 31661, 0x0000858A }, /* GL_SRC2_ALPHA */
-   { 31675, 0x00008582 }, /* GL_SRC2_RGB */
-   { 31687, 0x00000302 }, /* GL_SRC_ALPHA */
-   { 31700, 0x00000308 }, /* GL_SRC_ALPHA_SATURATE */
-   { 31722, 0x00000300 }, /* GL_SRC_COLOR */
-   { 31735, 0x00008C40 }, /* GL_SRGB */
-   { 31743, 0x00008C41 }, /* GL_SRGB8 */
-   { 31752, 0x00008C43 }, /* GL_SRGB8_ALPHA8 */
-   { 31768, 0x00008C42 }, /* GL_SRGB_ALPHA */
-   { 31782, 0x00000503 }, /* GL_STACK_OVERFLOW */
-   { 31800, 0x00000504 }, /* GL_STACK_UNDERFLOW */
-   { 31819, 0x000088E6 }, /* GL_STATIC_COPY */
-   { 31834, 0x000088E6 }, /* GL_STATIC_COPY_ARB */
-   { 31853, 0x000088E4 }, /* GL_STATIC_DRAW */
-   { 31868, 0x000088E4 }, /* GL_STATIC_DRAW_ARB */
-   { 31887, 0x000088E5 }, /* GL_STATIC_READ */
-   { 31902, 0x000088E5 }, /* GL_STATIC_READ_ARB */
-   { 31921, 0x00001802 }, /* GL_STENCIL */
-   { 31932, 0x00008D20 }, /* GL_STENCIL_ATTACHMENT */
-   { 31954, 0x00008D20 }, /* GL_STENCIL_ATTACHMENT_EXT */
-   { 31980, 0x00008801 }, /* GL_STENCIL_BACK_FAIL */
-   { 32001, 0x00008801 }, /* GL_STENCIL_BACK_FAIL_ATI */
-   { 32026, 0x00008800 }, /* GL_STENCIL_BACK_FUNC */
-   { 32047, 0x00008800 }, /* GL_STENCIL_BACK_FUNC_ATI */
-   { 32072, 0x00008802 }, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL */
-   { 32104, 0x00008802 }, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI */
-   { 32140, 0x00008803 }, /* GL_STENCIL_BACK_PASS_DEPTH_PASS */
-   { 32172, 0x00008803 }, /* GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI */
-   { 32208, 0x00008CA3 }, /* GL_STENCIL_BACK_REF */
-   { 32228, 0x00008CA4 }, /* GL_STENCIL_BACK_VALUE_MASK */
-   { 32255, 0x00008CA5 }, /* GL_STENCIL_BACK_WRITEMASK */
-   { 32281, 0x00000D57 }, /* GL_STENCIL_BITS */
-   { 32297, 0x00000400 }, /* GL_STENCIL_BUFFER_BIT */
-   { 32319, 0x00000B91 }, /* GL_STENCIL_CLEAR_VALUE */
-   { 32342, 0x00000B94 }, /* GL_STENCIL_FAIL */
-   { 32358, 0x00000B92 }, /* GL_STENCIL_FUNC */
-   { 32374, 0x00001901 }, /* GL_STENCIL_INDEX */
-   { 32391, 0x00008D49 }, /* GL_STENCIL_INDEX16_EXT */
-   { 32414, 0x00008D46 }, /* GL_STENCIL_INDEX1_EXT */
-   { 32436, 0x00008D47 }, /* GL_STENCIL_INDEX4_EXT */
-   { 32458, 0x00008D48 }, /* GL_STENCIL_INDEX8_EXT */
-   { 32480, 0x00008D45 }, /* GL_STENCIL_INDEX_EXT */
-   { 32501, 0x00000B95 }, /* GL_STENCIL_PASS_DEPTH_FAIL */
-   { 32528, 0x00000B96 }, /* GL_STENCIL_PASS_DEPTH_PASS */
-   { 32555, 0x00000B97 }, /* GL_STENCIL_REF */
-   { 32570, 0x00000B90 }, /* GL_STENCIL_TEST */
-   { 32586, 0x00008910 }, /* GL_STENCIL_TEST_TWO_SIDE_EXT */
-   { 32615, 0x00000B93 }, /* GL_STENCIL_VALUE_MASK */
-   { 32637, 0x00000B98 }, /* GL_STENCIL_WRITEMASK */
-   { 32658, 0x00000C33 }, /* GL_STEREO */
-   { 32668, 0x000085BE }, /* GL_STORAGE_CACHED_APPLE */
-   { 32692, 0x000085BD }, /* GL_STORAGE_PRIVATE_APPLE */
-   { 32717, 0x000085BF }, /* GL_STORAGE_SHARED_APPLE */
-   { 32741, 0x000088E2 }, /* GL_STREAM_COPY */
-   { 32756, 0x000088E2 }, /* GL_STREAM_COPY_ARB */
-   { 32775, 0x000088E0 }, /* GL_STREAM_DRAW */
-   { 32790, 0x000088E0 }, /* GL_STREAM_DRAW_ARB */
-   { 32809, 0x000088E1 }, /* GL_STREAM_READ */
-   { 32824, 0x000088E1 }, /* GL_STREAM_READ_ARB */
-   { 32843, 0x00000D50 }, /* GL_SUBPIXEL_BITS */
-   { 32860, 0x000084E7 }, /* GL_SUBTRACT */
-   { 32872, 0x000084E7 }, /* GL_SUBTRACT_ARB */
-   { 32888, 0x00009113 }, /* GL_SYNC_CONDITION */
-   { 32906, 0x00009116 }, /* GL_SYNC_FENCE */
-   { 32920, 0x00009115 }, /* GL_SYNC_FLAGS */
-   { 32934, 0x00000001 }, /* GL_SYNC_FLUSH_COMMANDS_BIT */
-   { 32961, 0x00009117 }, /* GL_SYNC_GPU_COMMANDS_COMPLETE */
-   { 32991, 0x00009114 }, /* GL_SYNC_STATUS */
-   { 33006, 0x00002001 }, /* GL_T */
-   { 33011, 0x00002A2A }, /* GL_T2F_C3F_V3F */
-   { 33026, 0x00002A2C }, /* GL_T2F_C4F_N3F_V3F */
-   { 33045, 0x00002A29 }, /* GL_T2F_C4UB_V3F */
-   { 33061, 0x00002A2B }, /* GL_T2F_N3F_V3F */
-   { 33076, 0x00002A27 }, /* GL_T2F_V3F */
-   { 33087, 0x00002A2D }, /* GL_T4F_C4F_N3F_V4F */
-   { 33106, 0x00002A28 }, /* GL_T4F_V4F */
-   { 33117, 0x00008031 }, /* GL_TABLE_TOO_LARGE_EXT */
-   { 33140, 0x00001702 }, /* GL_TEXTURE */
-   { 33151, 0x000084C0 }, /* GL_TEXTURE0 */
-   { 33163, 0x000084C0 }, /* GL_TEXTURE0_ARB */
-   { 33179, 0x000084C1 }, /* GL_TEXTURE1 */
-   { 33191, 0x000084CA }, /* GL_TEXTURE10 */
-   { 33204, 0x000084CA }, /* GL_TEXTURE10_ARB */
-   { 33221, 0x000084CB }, /* GL_TEXTURE11 */
-   { 33234, 0x000084CB }, /* GL_TEXTURE11_ARB */
-   { 33251, 0x000084CC }, /* GL_TEXTURE12 */
-   { 33264, 0x000084CC }, /* GL_TEXTURE12_ARB */
-   { 33281, 0x000084CD }, /* GL_TEXTURE13 */
-   { 33294, 0x000084CD }, /* GL_TEXTURE13_ARB */
-   { 33311, 0x000084CE }, /* GL_TEXTURE14 */
-   { 33324, 0x000084CE }, /* GL_TEXTURE14_ARB */
-   { 33341, 0x000084CF }, /* GL_TEXTURE15 */
-   { 33354, 0x000084CF }, /* GL_TEXTURE15_ARB */
-   { 33371, 0x000084D0 }, /* GL_TEXTURE16 */
-   { 33384, 0x000084D0 }, /* GL_TEXTURE16_ARB */
-   { 33401, 0x000084D1 }, /* GL_TEXTURE17 */
-   { 33414, 0x000084D1 }, /* GL_TEXTURE17_ARB */
-   { 33431, 0x000084D2 }, /* GL_TEXTURE18 */
-   { 33444, 0x000084D2 }, /* GL_TEXTURE18_ARB */
-   { 33461, 0x000084D3 }, /* GL_TEXTURE19 */
-   { 33474, 0x000084D3 }, /* GL_TEXTURE19_ARB */
-   { 33491, 0x000084C1 }, /* GL_TEXTURE1_ARB */
-   { 33507, 0x000084C2 }, /* GL_TEXTURE2 */
-   { 33519, 0x000084D4 }, /* GL_TEXTURE20 */
-   { 33532, 0x000084D4 }, /* GL_TEXTURE20_ARB */
-   { 33549, 0x000084D5 }, /* GL_TEXTURE21 */
-   { 33562, 0x000084D5 }, /* GL_TEXTURE21_ARB */
-   { 33579, 0x000084D6 }, /* GL_TEXTURE22 */
-   { 33592, 0x000084D6 }, /* GL_TEXTURE22_ARB */
-   { 33609, 0x000084D7 }, /* GL_TEXTURE23 */
-   { 33622, 0x000084D7 }, /* GL_TEXTURE23_ARB */
-   { 33639, 0x000084D8 }, /* GL_TEXTURE24 */
-   { 33652, 0x000084D8 }, /* GL_TEXTURE24_ARB */
-   { 33669, 0x000084D9 }, /* GL_TEXTURE25 */
-   { 33682, 0x000084D9 }, /* GL_TEXTURE25_ARB */
-   { 33699, 0x000084DA }, /* GL_TEXTURE26 */
-   { 33712, 0x000084DA }, /* GL_TEXTURE26_ARB */
-   { 33729, 0x000084DB }, /* GL_TEXTURE27 */
-   { 33742, 0x000084DB }, /* GL_TEXTURE27_ARB */
-   { 33759, 0x000084DC }, /* GL_TEXTURE28 */
-   { 33772, 0x000084DC }, /* GL_TEXTURE28_ARB */
-   { 33789, 0x000084DD }, /* GL_TEXTURE29 */
-   { 33802, 0x000084DD }, /* GL_TEXTURE29_ARB */
-   { 33819, 0x000084C2 }, /* GL_TEXTURE2_ARB */
-   { 33835, 0x000084C3 }, /* GL_TEXTURE3 */
-   { 33847, 0x000084DE }, /* GL_TEXTURE30 */
-   { 33860, 0x000084DE }, /* GL_TEXTURE30_ARB */
-   { 33877, 0x000084DF }, /* GL_TEXTURE31 */
-   { 33890, 0x000084DF }, /* GL_TEXTURE31_ARB */
-   { 33907, 0x000084C3 }, /* GL_TEXTURE3_ARB */
-   { 33923, 0x000084C4 }, /* GL_TEXTURE4 */
-   { 33935, 0x000084C4 }, /* GL_TEXTURE4_ARB */
-   { 33951, 0x000084C5 }, /* GL_TEXTURE5 */
-   { 33963, 0x000084C5 }, /* GL_TEXTURE5_ARB */
-   { 33979, 0x000084C6 }, /* GL_TEXTURE6 */
-   { 33991, 0x000084C6 }, /* GL_TEXTURE6_ARB */
-   { 34007, 0x000084C7 }, /* GL_TEXTURE7 */
-   { 34019, 0x000084C7 }, /* GL_TEXTURE7_ARB */
-   { 34035, 0x000084C8 }, /* GL_TEXTURE8 */
-   { 34047, 0x000084C8 }, /* GL_TEXTURE8_ARB */
-   { 34063, 0x000084C9 }, /* GL_TEXTURE9 */
-   { 34075, 0x000084C9 }, /* GL_TEXTURE9_ARB */
-   { 34091, 0x00000DE0 }, /* GL_TEXTURE_1D */
-   { 34105, 0x00008C18 }, /* GL_TEXTURE_1D_ARRAY_EXT */
-   { 34129, 0x00000DE1 }, /* GL_TEXTURE_2D */
-   { 34143, 0x00008C1A }, /* GL_TEXTURE_2D_ARRAY_EXT */
-   { 34167, 0x0000806F }, /* GL_TEXTURE_3D */
-   { 34181, 0x0000805F }, /* GL_TEXTURE_ALPHA_SIZE */
-   { 34203, 0x0000805F }, /* GL_TEXTURE_ALPHA_SIZE_EXT */
-   { 34229, 0x0000813C }, /* GL_TEXTURE_BASE_LEVEL */
-   { 34251, 0x00008068 }, /* GL_TEXTURE_BINDING_1D */
-   { 34273, 0x00008C1C }, /* GL_TEXTURE_BINDING_1D_ARRAY_EXT */
-   { 34305, 0x00008069 }, /* GL_TEXTURE_BINDING_2D */
-   { 34327, 0x00008C1D }, /* GL_TEXTURE_BINDING_2D_ARRAY_EXT */
-   { 34359, 0x0000806A }, /* GL_TEXTURE_BINDING_3D */
-   { 34381, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP */
-   { 34409, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP_ARB */
-   { 34441, 0x000084F6 }, /* GL_TEXTURE_BINDING_RECTANGLE_ARB */
-   { 34474, 0x000084F6 }, /* GL_TEXTURE_BINDING_RECTANGLE_NV */
-   { 34506, 0x00040000 }, /* GL_TEXTURE_BIT */
-   { 34521, 0x0000805E }, /* GL_TEXTURE_BLUE_SIZE */
-   { 34542, 0x0000805E }, /* GL_TEXTURE_BLUE_SIZE_EXT */
-   { 34567, 0x00001005 }, /* GL_TEXTURE_BORDER */
-   { 34585, 0x00001004 }, /* GL_TEXTURE_BORDER_COLOR */
-   { 34609, 0x00008171 }, /* GL_TEXTURE_CLIPMAP_CENTER_SGIX */
-   { 34640, 0x00008176 }, /* GL_TEXTURE_CLIPMAP_DEPTH_SGIX */
-   { 34670, 0x00008172 }, /* GL_TEXTURE_CLIPMAP_FRAME_SGIX */
-   { 34700, 0x00008175 }, /* GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX */
-   { 34735, 0x00008173 }, /* GL_TEXTURE_CLIPMAP_OFFSET_SGIX */
-   { 34766, 0x00008174 }, /* GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX */
-   { 34804, 0x000080BC }, /* GL_TEXTURE_COLOR_TABLE_SGI */
-   { 34831, 0x000081EF }, /* GL_TEXTURE_COLOR_WRITEMASK_SGIS */
-   { 34863, 0x000080BF }, /* GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
-   { 34897, 0x0000884D }, /* GL_TEXTURE_COMPARE_FUNC */
-   { 34921, 0x0000884D }, /* GL_TEXTURE_COMPARE_FUNC_ARB */
-   { 34949, 0x0000884C }, /* GL_TEXTURE_COMPARE_MODE */
-   { 34973, 0x0000884C }, /* GL_TEXTURE_COMPARE_MODE_ARB */
-   { 35001, 0x0000819B }, /* GL_TEXTURE_COMPARE_OPERATOR_SGIX */
-   { 35034, 0x0000819A }, /* GL_TEXTURE_COMPARE_SGIX */
-   { 35058, 0x00001003 }, /* GL_TEXTURE_COMPONENTS */
-   { 35080, 0x000086A1 }, /* GL_TEXTURE_COMPRESSED */
-   { 35102, 0x000086A1 }, /* GL_TEXTURE_COMPRESSED_ARB */
-   { 35128, 0x000086A3 }, /* GL_TEXTURE_COMPRESSED_FORMATS_ARB */
-   { 35162, 0x000086A0 }, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE */
-   { 35195, 0x000086A0 }, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB */
-   { 35232, 0x000084EF }, /* GL_TEXTURE_COMPRESSION_HINT */
-   { 35260, 0x000084EF }, /* GL_TEXTURE_COMPRESSION_HINT_ARB */
-   { 35292, 0x00008078 }, /* GL_TEXTURE_COORD_ARRAY */
-   { 35315, 0x0000889A }, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING */
-   { 35353, 0x0000889A }, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB */
-   { 35395, 0x00008092 }, /* GL_TEXTURE_COORD_ARRAY_POINTER */
-   { 35426, 0x00008088 }, /* GL_TEXTURE_COORD_ARRAY_SIZE */
-   { 35454, 0x0000808A }, /* GL_TEXTURE_COORD_ARRAY_STRIDE */
-   { 35484, 0x00008089 }, /* GL_TEXTURE_COORD_ARRAY_TYPE */
-   { 35512, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP */
-   { 35532, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP_ARB */
-   { 35556, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X */
-   { 35587, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB */
-   { 35622, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y */
-   { 35653, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB */
-   { 35688, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z */
-   { 35719, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB */
-   { 35754, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X */
-   { 35785, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB */
-   { 35820, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y */
-   { 35851, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB */
-   { 35886, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z */
-   { 35917, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB */
-   { 35952, 0x000088F4 }, /* GL_TEXTURE_CUBE_MAP_SEAMLESS */
-   { 35981, 0x00008071 }, /* GL_TEXTURE_DEPTH */
-   { 35998, 0x0000884A }, /* GL_TEXTURE_DEPTH_SIZE */
-   { 36020, 0x0000884A }, /* GL_TEXTURE_DEPTH_SIZE_ARB */
-   { 36046, 0x00002300 }, /* GL_TEXTURE_ENV */
-   { 36061, 0x00002201 }, /* GL_TEXTURE_ENV_COLOR */
-   { 36082, 0x00002200 }, /* GL_TEXTURE_ENV_MODE */
-   { 36102, 0x00008500 }, /* GL_TEXTURE_FILTER_CONTROL */
-   { 36128, 0x00002500 }, /* GL_TEXTURE_GEN_MODE */
-   { 36148, 0x00000C63 }, /* GL_TEXTURE_GEN_Q */
-   { 36165, 0x00000C62 }, /* GL_TEXTURE_GEN_R */
-   { 36182, 0x00000C60 }, /* GL_TEXTURE_GEN_S */
-   { 36199, 0x00000C61 }, /* GL_TEXTURE_GEN_T */
-   { 36216, 0x0000819D }, /* GL_TEXTURE_GEQUAL_R_SGIX */
-   { 36241, 0x0000805D }, /* GL_TEXTURE_GREEN_SIZE */
-   { 36263, 0x0000805D }, /* GL_TEXTURE_GREEN_SIZE_EXT */
-   { 36289, 0x00001001 }, /* GL_TEXTURE_HEIGHT */
-   { 36307, 0x000080ED }, /* GL_TEXTURE_INDEX_SIZE_EXT */
-   { 36333, 0x00008061 }, /* GL_TEXTURE_INTENSITY_SIZE */
-   { 36359, 0x00008061 }, /* GL_TEXTURE_INTENSITY_SIZE_EXT */
-   { 36389, 0x00001003 }, /* GL_TEXTURE_INTERNAL_FORMAT */
-   { 36416, 0x0000819C }, /* GL_TEXTURE_LEQUAL_R_SGIX */
-   { 36441, 0x00008501 }, /* GL_TEXTURE_LOD_BIAS */
-   { 36461, 0x00008501 }, /* GL_TEXTURE_LOD_BIAS_EXT */
-   { 36485, 0x00008190 }, /* GL_TEXTURE_LOD_BIAS_R_SGIX */
-   { 36512, 0x0000818E }, /* GL_TEXTURE_LOD_BIAS_S_SGIX */
-   { 36539, 0x0000818F }, /* GL_TEXTURE_LOD_BIAS_T_SGIX */
-   { 36566, 0x00008060 }, /* GL_TEXTURE_LUMINANCE_SIZE */
-   { 36592, 0x00008060 }, /* GL_TEXTURE_LUMINANCE_SIZE_EXT */
-   { 36622, 0x00002800 }, /* GL_TEXTURE_MAG_FILTER */
-   { 36644, 0x00000BA8 }, /* GL_TEXTURE_MATRIX */
-   { 36662, 0x000084FE }, /* GL_TEXTURE_MAX_ANISOTROPY_EXT */
-   { 36692, 0x0000836B }, /* GL_TEXTURE_MAX_CLAMP_R_SGIX */
-   { 36720, 0x00008369 }, /* GL_TEXTURE_MAX_CLAMP_S_SGIX */
-   { 36748, 0x0000836A }, /* GL_TEXTURE_MAX_CLAMP_T_SGIX */
-   { 36776, 0x0000813D }, /* GL_TEXTURE_MAX_LEVEL */
-   { 36797, 0x0000813B }, /* GL_TEXTURE_MAX_LOD */
-   { 36816, 0x00002801 }, /* GL_TEXTURE_MIN_FILTER */
-   { 36838, 0x0000813A }, /* GL_TEXTURE_MIN_LOD */
-   { 36857, 0x00008066 }, /* GL_TEXTURE_PRIORITY */
-   { 36877, 0x000085B7 }, /* GL_TEXTURE_RANGE_LENGTH_APPLE */
-   { 36907, 0x000085B8 }, /* GL_TEXTURE_RANGE_POINTER_APPLE */
-   { 36938, 0x000084F5 }, /* GL_TEXTURE_RECTANGLE_ARB */
-   { 36963, 0x000084F5 }, /* GL_TEXTURE_RECTANGLE_NV */
-   { 36987, 0x0000805C }, /* GL_TEXTURE_RED_SIZE */
-   { 37007, 0x0000805C }, /* GL_TEXTURE_RED_SIZE_EXT */
-   { 37031, 0x00008067 }, /* GL_TEXTURE_RESIDENT */
-   { 37051, 0x00000BA5 }, /* GL_TEXTURE_STACK_DEPTH */
-   { 37074, 0x000088F1 }, /* GL_TEXTURE_STENCIL_SIZE */
-   { 37098, 0x000085BC }, /* GL_TEXTURE_STORAGE_HINT_APPLE */
-   { 37128, 0x00008065 }, /* GL_TEXTURE_TOO_LARGE_EXT */
-   { 37153, 0x0000888F }, /* GL_TEXTURE_UNSIGNED_REMAP_MODE_NV */
-   { 37187, 0x00001000 }, /* GL_TEXTURE_WIDTH */
-   { 37204, 0x00008072 }, /* GL_TEXTURE_WRAP_R */
-   { 37222, 0x00002802 }, /* GL_TEXTURE_WRAP_S */
-   { 37240, 0x00002803 }, /* GL_TEXTURE_WRAP_T */
-   { 37258, 0x0000911B }, /* GL_TIMEOUT_EXPIRED */
-   { 37277, 0xFFFFFFFFFFFFFFFF }, /* GL_TIMEOUT_IGNORED */
-   { 37296, 0x000088BF }, /* GL_TIME_ELAPSED_EXT */
-   { 37316, 0x00008648 }, /* GL_TRACK_MATRIX_NV */
-   { 37335, 0x00008649 }, /* GL_TRACK_MATRIX_TRANSFORM_NV */
-   { 37364, 0x00001000 }, /* GL_TRANSFORM_BIT */
-   { 37381, 0x000084E6 }, /* GL_TRANSPOSE_COLOR_MATRIX */
-   { 37407, 0x000084E6 }, /* GL_TRANSPOSE_COLOR_MATRIX_ARB */
-   { 37437, 0x000088B7 }, /* GL_TRANSPOSE_CURRENT_MATRIX_ARB */
-   { 37469, 0x000084E3 }, /* GL_TRANSPOSE_MODELVIEW_MATRIX */
-   { 37499, 0x000084E3 }, /* GL_TRANSPOSE_MODELVIEW_MATRIX_ARB */
-   { 37533, 0x0000862C }, /* GL_TRANSPOSE_NV */
-   { 37549, 0x000084E4 }, /* GL_TRANSPOSE_PROJECTION_MATRIX */
-   { 37580, 0x000084E4 }, /* GL_TRANSPOSE_PROJECTION_MATRIX_ARB */
-   { 37615, 0x000084E5 }, /* GL_TRANSPOSE_TEXTURE_MATRIX */
-   { 37643, 0x000084E5 }, /* GL_TRANSPOSE_TEXTURE_MATRIX_ARB */
-   { 37675, 0x00000004 }, /* GL_TRIANGLES */
-   { 37688, 0x00000006 }, /* GL_TRIANGLE_FAN */
-   { 37704, 0x00008615 }, /* GL_TRIANGLE_MESH_SUN */
-   { 37725, 0x00000005 }, /* GL_TRIANGLE_STRIP */
-   { 37743, 0x00000001 }, /* GL_TRUE */
-   { 37751, 0x00000CF5 }, /* GL_UNPACK_ALIGNMENT */
-   { 37771, 0x0000806E }, /* GL_UNPACK_IMAGE_HEIGHT */
-   { 37794, 0x00000CF1 }, /* GL_UNPACK_LSB_FIRST */
-   { 37814, 0x00000CF2 }, /* GL_UNPACK_ROW_LENGTH */
-   { 37835, 0x0000806D }, /* GL_UNPACK_SKIP_IMAGES */
-   { 37857, 0x00000CF4 }, /* GL_UNPACK_SKIP_PIXELS */
-   { 37879, 0x00000CF3 }, /* GL_UNPACK_SKIP_ROWS */
-   { 37899, 0x00000CF0 }, /* GL_UNPACK_SWAP_BYTES */
-   { 37920, 0x00009118 }, /* GL_UNSIGNALED */
-   { 37934, 0x00001401 }, /* GL_UNSIGNED_BYTE */
-   { 37951, 0x00008362 }, /* GL_UNSIGNED_BYTE_2_3_3_REV */
-   { 37978, 0x00008032 }, /* GL_UNSIGNED_BYTE_3_3_2 */
-   { 38001, 0x00001405 }, /* GL_UNSIGNED_INT */
-   { 38017, 0x00008036 }, /* GL_UNSIGNED_INT_10_10_10_2 */
-   { 38044, 0x000084FA }, /* GL_UNSIGNED_INT_24_8 */
-   { 38065, 0x000084FA }, /* GL_UNSIGNED_INT_24_8_NV */
-   { 38089, 0x00008368 }, /* GL_UNSIGNED_INT_2_10_10_10_REV */
-   { 38120, 0x00008035 }, /* GL_UNSIGNED_INT_8_8_8_8 */
-   { 38144, 0x00008367 }, /* GL_UNSIGNED_INT_8_8_8_8_REV */
-   { 38172, 0x00008C17 }, /* GL_UNSIGNED_NORMALIZED */
-   { 38195, 0x00001403 }, /* GL_UNSIGNED_SHORT */
-   { 38213, 0x00008366 }, /* GL_UNSIGNED_SHORT_1_5_5_5_REV */
-   { 38243, 0x00008033 }, /* GL_UNSIGNED_SHORT_4_4_4_4 */
-   { 38269, 0x00008365 }, /* GL_UNSIGNED_SHORT_4_4_4_4_REV */
-   { 38299, 0x00008034 }, /* GL_UNSIGNED_SHORT_5_5_5_1 */
-   { 38325, 0x00008363 }, /* GL_UNSIGNED_SHORT_5_6_5 */
-   { 38349, 0x00008364 }, /* GL_UNSIGNED_SHORT_5_6_5_REV */
-   { 38377, 0x000085BA }, /* GL_UNSIGNED_SHORT_8_8_APPLE */
-   { 38405, 0x000085BA }, /* GL_UNSIGNED_SHORT_8_8_MESA */
-   { 38432, 0x000085BB }, /* GL_UNSIGNED_SHORT_8_8_REV_APPLE */
-   { 38464, 0x000085BB }, /* GL_UNSIGNED_SHORT_8_8_REV_MESA */
-   { 38495, 0x00008CA2 }, /* GL_UPPER_LEFT */
-   { 38509, 0x00002A20 }, /* GL_V2F */
-   { 38516, 0x00002A21 }, /* GL_V3F */
-   { 38523, 0x00008B83 }, /* GL_VALIDATE_STATUS */
-   { 38542, 0x00001F00 }, /* GL_VENDOR */
-   { 38552, 0x00001F02 }, /* GL_VERSION */
-   { 38563, 0x00008074 }, /* GL_VERTEX_ARRAY */
-   { 38579, 0x000085B5 }, /* GL_VERTEX_ARRAY_BINDING */
-   { 38603, 0x000085B5 }, /* GL_VERTEX_ARRAY_BINDING_APPLE */
-   { 38633, 0x00008896 }, /* GL_VERTEX_ARRAY_BUFFER_BINDING */
-   { 38664, 0x00008896 }, /* GL_VERTEX_ARRAY_BUFFER_BINDING_ARB */
-   { 38699, 0x0000808E }, /* GL_VERTEX_ARRAY_POINTER */
-   { 38723, 0x0000807A }, /* GL_VERTEX_ARRAY_SIZE */
-   { 38744, 0x0000807C }, /* GL_VERTEX_ARRAY_STRIDE */
-   { 38767, 0x0000807B }, /* GL_VERTEX_ARRAY_TYPE */
-   { 38788, 0x00008650 }, /* GL_VERTEX_ATTRIB_ARRAY0_NV */
-   { 38815, 0x0000865A }, /* GL_VERTEX_ATTRIB_ARRAY10_NV */
-   { 38843, 0x0000865B }, /* GL_VERTEX_ATTRIB_ARRAY11_NV */
-   { 38871, 0x0000865C }, /* GL_VERTEX_ATTRIB_ARRAY12_NV */
-   { 38899, 0x0000865D }, /* GL_VERTEX_ATTRIB_ARRAY13_NV */
-   { 38927, 0x0000865E }, /* GL_VERTEX_ATTRIB_ARRAY14_NV */
-   { 38955, 0x0000865F }, /* GL_VERTEX_ATTRIB_ARRAY15_NV */
-   { 38983, 0x00008651 }, /* GL_VERTEX_ATTRIB_ARRAY1_NV */
-   { 39010, 0x00008652 }, /* GL_VERTEX_ATTRIB_ARRAY2_NV */
-   { 39037, 0x00008653 }, /* GL_VERTEX_ATTRIB_ARRAY3_NV */
-   { 39064, 0x00008654 }, /* GL_VERTEX_ATTRIB_ARRAY4_NV */
-   { 39091, 0x00008655 }, /* GL_VERTEX_ATTRIB_ARRAY5_NV */
-   { 39118, 0x00008656 }, /* GL_VERTEX_ATTRIB_ARRAY6_NV */
-   { 39145, 0x00008657 }, /* GL_VERTEX_ATTRIB_ARRAY7_NV */
-   { 39172, 0x00008658 }, /* GL_VERTEX_ATTRIB_ARRAY8_NV */
-   { 39199, 0x00008659 }, /* GL_VERTEX_ATTRIB_ARRAY9_NV */
-   { 39226, 0x0000889F }, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING */
-   { 39264, 0x0000889F }, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB */
-   { 39306, 0x00008622 }, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED */
-   { 39337, 0x00008622 }, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB */
-   { 39372, 0x0000886A }, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED */
-   { 39406, 0x0000886A }, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB */
-   { 39444, 0x00008645 }, /* GL_VERTEX_ATTRIB_ARRAY_POINTER */
-   { 39475, 0x00008645 }, /* GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB */
-   { 39510, 0x00008623 }, /* GL_VERTEX_ATTRIB_ARRAY_SIZE */
-   { 39538, 0x00008623 }, /* GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB */
-   { 39570, 0x00008624 }, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE */
-   { 39600, 0x00008624 }, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB */
-   { 39634, 0x00008625 }, /* GL_VERTEX_ATTRIB_ARRAY_TYPE */
-   { 39662, 0x00008625 }, /* GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB */
-   { 39694, 0x000086A7 }, /* GL_VERTEX_BLEND_ARB */
-   { 39714, 0x00008620 }, /* GL_VERTEX_PROGRAM_ARB */
-   { 39736, 0x0000864A }, /* GL_VERTEX_PROGRAM_BINDING_NV */
-   { 39765, 0x00008620 }, /* GL_VERTEX_PROGRAM_NV */
-   { 39786, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE */
-   { 39815, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE_ARB */
-   { 39848, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE_NV */
-   { 39880, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE */
-   { 39907, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE_ARB */
-   { 39938, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE_NV */
-   { 39968, 0x00008B31 }, /* GL_VERTEX_SHADER */
-   { 39985, 0x00008B31 }, /* GL_VERTEX_SHADER_ARB */
-   { 40006, 0x00008621 }, /* GL_VERTEX_STATE_PROGRAM_NV */
-   { 40033, 0x00000BA2 }, /* GL_VIEWPORT */
-   { 40045, 0x00000800 }, /* GL_VIEWPORT_BIT */
-   { 40061, 0x0000911D }, /* GL_WAIT_FAILED */
-   { 40076, 0x000086AD }, /* GL_WEIGHT_ARRAY_ARB */
-   { 40096, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING */
-   { 40127, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB */
-   { 40162, 0x000086AC }, /* GL_WEIGHT_ARRAY_POINTER_ARB */
-   { 40190, 0x000086AB }, /* GL_WEIGHT_ARRAY_SIZE_ARB */
-   { 40215, 0x000086AA }, /* GL_WEIGHT_ARRAY_STRIDE_ARB */
-   { 40242, 0x000086A9 }, /* GL_WEIGHT_ARRAY_TYPE_ARB */
-   { 40267, 0x000086A6 }, /* GL_WEIGHT_SUM_UNITY_ARB */
-   { 40291, 0x000081D4 }, /* GL_WRAP_BORDER_SUN */
-   { 40310, 0x000088B9 }, /* GL_WRITE_ONLY */
-   { 40324, 0x000088B9 }, /* GL_WRITE_ONLY_ARB */
-   { 40342, 0x00001506 }, /* GL_XOR */
-   { 40349, 0x000085B9 }, /* GL_YCBCR_422_APPLE */
-   { 40368, 0x00008757 }, /* GL_YCBCR_MESA */
-   { 40382, 0x00000000 }, /* GL_ZERO */
-   { 40390, 0x00000D16 }, /* GL_ZOOM_X */
-   { 40400, 0x00000D17 }, /* GL_ZOOM_Y */
+   {  7190, 0x000088F0 }, /* GL_DEPTH24_STENCIL8_EXT */
+   {  7214, 0x00008D00 }, /* GL_DEPTH_ATTACHMENT */
+   {  7234, 0x00008D00 }, /* GL_DEPTH_ATTACHMENT_EXT */
+   {  7258, 0x00000D1F }, /* GL_DEPTH_BIAS */
+   {  7272, 0x00000D56 }, /* GL_DEPTH_BITS */
+   {  7286, 0x00008891 }, /* GL_DEPTH_BOUNDS_EXT */
+   {  7306, 0x00008890 }, /* GL_DEPTH_BOUNDS_TEST_EXT */
+   {  7331, 0x00000100 }, /* GL_DEPTH_BUFFER_BIT */
+   {  7351, 0x0000864F }, /* GL_DEPTH_CLAMP */
+   {  7366, 0x0000864F }, /* GL_DEPTH_CLAMP_NV */
+   {  7384, 0x00000B73 }, /* GL_DEPTH_CLEAR_VALUE */
+   {  7405, 0x00001902 }, /* GL_DEPTH_COMPONENT */
+   {  7424, 0x000081A5 }, /* GL_DEPTH_COMPONENT16 */
+   {  7445, 0x000081A5 }, /* GL_DEPTH_COMPONENT16_ARB */
+   {  7470, 0x000081A5 }, /* GL_DEPTH_COMPONENT16_SGIX */
+   {  7496, 0x000081A6 }, /* GL_DEPTH_COMPONENT24 */
+   {  7517, 0x000081A6 }, /* GL_DEPTH_COMPONENT24_ARB */
+   {  7542, 0x000081A6 }, /* GL_DEPTH_COMPONENT24_SGIX */
+   {  7568, 0x000081A7 }, /* GL_DEPTH_COMPONENT32 */
+   {  7589, 0x000081A7 }, /* GL_DEPTH_COMPONENT32_ARB */
+   {  7614, 0x000081A7 }, /* GL_DEPTH_COMPONENT32_SGIX */
+   {  7640, 0x00000B74 }, /* GL_DEPTH_FUNC */
+   {  7654, 0x00000B70 }, /* GL_DEPTH_RANGE */
+   {  7669, 0x00000D1E }, /* GL_DEPTH_SCALE */
+   {  7684, 0x000084F9 }, /* GL_DEPTH_STENCIL */
+   {  7701, 0x0000821A }, /* GL_DEPTH_STENCIL_ATTACHMENT */
+   {  7729, 0x000084F9 }, /* GL_DEPTH_STENCIL_EXT */
+   {  7750, 0x000084F9 }, /* GL_DEPTH_STENCIL_NV */
+   {  7770, 0x0000886F }, /* GL_DEPTH_STENCIL_TO_BGRA_NV */
+   {  7798, 0x0000886E }, /* GL_DEPTH_STENCIL_TO_RGBA_NV */
+   {  7826, 0x00000B71 }, /* GL_DEPTH_TEST */
+   {  7840, 0x0000884B }, /* GL_DEPTH_TEXTURE_MODE */
+   {  7862, 0x0000884B }, /* GL_DEPTH_TEXTURE_MODE_ARB */
+   {  7888, 0x00000B72 }, /* GL_DEPTH_WRITEMASK */
+   {  7907, 0x00001201 }, /* GL_DIFFUSE */
+   {  7918, 0x00000BD0 }, /* GL_DITHER */
+   {  7928, 0x00000A02 }, /* GL_DOMAIN */
+   {  7938, 0x00001100 }, /* GL_DONT_CARE */
+   {  7951, 0x000086AE }, /* GL_DOT3_RGB */
+   {  7963, 0x000086AF }, /* GL_DOT3_RGBA */
+   {  7976, 0x000086AF }, /* GL_DOT3_RGBA_ARB */
+   {  7993, 0x00008741 }, /* GL_DOT3_RGBA_EXT */
+   {  8010, 0x000086AE }, /* GL_DOT3_RGB_ARB */
+   {  8026, 0x00008740 }, /* GL_DOT3_RGB_EXT */
+   {  8042, 0x0000140A }, /* GL_DOUBLE */
+   {  8052, 0x00000C32 }, /* GL_DOUBLEBUFFER */
+   {  8068, 0x00000C01 }, /* GL_DRAW_BUFFER */
+   {  8083, 0x00008825 }, /* GL_DRAW_BUFFER0 */
+   {  8099, 0x00008825 }, /* GL_DRAW_BUFFER0_ARB */
+   {  8119, 0x00008825 }, /* GL_DRAW_BUFFER0_ATI */
+   {  8139, 0x00008826 }, /* GL_DRAW_BUFFER1 */
+   {  8155, 0x0000882F }, /* GL_DRAW_BUFFER10 */
+   {  8172, 0x0000882F }, /* GL_DRAW_BUFFER10_ARB */
+   {  8193, 0x0000882F }, /* GL_DRAW_BUFFER10_ATI */
+   {  8214, 0x00008830 }, /* GL_DRAW_BUFFER11 */
+   {  8231, 0x00008830 }, /* GL_DRAW_BUFFER11_ARB */
+   {  8252, 0x00008830 }, /* GL_DRAW_BUFFER11_ATI */
+   {  8273, 0x00008831 }, /* GL_DRAW_BUFFER12 */
+   {  8290, 0x00008831 }, /* GL_DRAW_BUFFER12_ARB */
+   {  8311, 0x00008831 }, /* GL_DRAW_BUFFER12_ATI */
+   {  8332, 0x00008832 }, /* GL_DRAW_BUFFER13 */
+   {  8349, 0x00008832 }, /* GL_DRAW_BUFFER13_ARB */
+   {  8370, 0x00008832 }, /* GL_DRAW_BUFFER13_ATI */
+   {  8391, 0x00008833 }, /* GL_DRAW_BUFFER14 */
+   {  8408, 0x00008833 }, /* GL_DRAW_BUFFER14_ARB */
+   {  8429, 0x00008833 }, /* GL_DRAW_BUFFER14_ATI */
+   {  8450, 0x00008834 }, /* GL_DRAW_BUFFER15 */
+   {  8467, 0x00008834 }, /* GL_DRAW_BUFFER15_ARB */
+   {  8488, 0x00008834 }, /* GL_DRAW_BUFFER15_ATI */
+   {  8509, 0x00008826 }, /* GL_DRAW_BUFFER1_ARB */
+   {  8529, 0x00008826 }, /* GL_DRAW_BUFFER1_ATI */
+   {  8549, 0x00008827 }, /* GL_DRAW_BUFFER2 */
+   {  8565, 0x00008827 }, /* GL_DRAW_BUFFER2_ARB */
+   {  8585, 0x00008827 }, /* GL_DRAW_BUFFER2_ATI */
+   {  8605, 0x00008828 }, /* GL_DRAW_BUFFER3 */
+   {  8621, 0x00008828 }, /* GL_DRAW_BUFFER3_ARB */
+   {  8641, 0x00008828 }, /* GL_DRAW_BUFFER3_ATI */
+   {  8661, 0x00008829 }, /* GL_DRAW_BUFFER4 */
+   {  8677, 0x00008829 }, /* GL_DRAW_BUFFER4_ARB */
+   {  8697, 0x00008829 }, /* GL_DRAW_BUFFER4_ATI */
+   {  8717, 0x0000882A }, /* GL_DRAW_BUFFER5 */
+   {  8733, 0x0000882A }, /* GL_DRAW_BUFFER5_ARB */
+   {  8753, 0x0000882A }, /* GL_DRAW_BUFFER5_ATI */
+   {  8773, 0x0000882B }, /* GL_DRAW_BUFFER6 */
+   {  8789, 0x0000882B }, /* GL_DRAW_BUFFER6_ARB */
+   {  8809, 0x0000882B }, /* GL_DRAW_BUFFER6_ATI */
+   {  8829, 0x0000882C }, /* GL_DRAW_BUFFER7 */
+   {  8845, 0x0000882C }, /* GL_DRAW_BUFFER7_ARB */
+   {  8865, 0x0000882C }, /* GL_DRAW_BUFFER7_ATI */
+   {  8885, 0x0000882D }, /* GL_DRAW_BUFFER8 */
+   {  8901, 0x0000882D }, /* GL_DRAW_BUFFER8_ARB */
+   {  8921, 0x0000882D }, /* GL_DRAW_BUFFER8_ATI */
+   {  8941, 0x0000882E }, /* GL_DRAW_BUFFER9 */
+   {  8957, 0x0000882E }, /* GL_DRAW_BUFFER9_ARB */
+   {  8977, 0x0000882E }, /* GL_DRAW_BUFFER9_ATI */
+   {  8997, 0x00008CA9 }, /* GL_DRAW_FRAMEBUFFER */
+   {  9017, 0x00008CA6 }, /* GL_DRAW_FRAMEBUFFER_BINDING */
+   {  9045, 0x00008CA6 }, /* GL_DRAW_FRAMEBUFFER_BINDING_EXT */
+   {  9077, 0x00008CA9 }, /* GL_DRAW_FRAMEBUFFER_EXT */
+   {  9101, 0x00000705 }, /* GL_DRAW_PIXEL_TOKEN */
+   {  9121, 0x00000304 }, /* GL_DST_ALPHA */
+   {  9134, 0x00000306 }, /* GL_DST_COLOR */
+   {  9147, 0x0000877A }, /* GL_DU8DV8_ATI */
+   {  9161, 0x00008779 }, /* GL_DUDV_ATI */
+   {  9173, 0x000088EA }, /* GL_DYNAMIC_COPY */
+   {  9189, 0x000088EA }, /* GL_DYNAMIC_COPY_ARB */
+   {  9209, 0x000088E8 }, /* GL_DYNAMIC_DRAW */
+   {  9225, 0x000088E8 }, /* GL_DYNAMIC_DRAW_ARB */
+   {  9245, 0x000088E9 }, /* GL_DYNAMIC_READ */
+   {  9261, 0x000088E9 }, /* GL_DYNAMIC_READ_ARB */
+   {  9281, 0x00000B43 }, /* GL_EDGE_FLAG */
+   {  9294, 0x00008079 }, /* GL_EDGE_FLAG_ARRAY */
+   {  9313, 0x0000889B }, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING */
+   {  9347, 0x0000889B }, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB */
+   {  9385, 0x00008093 }, /* GL_EDGE_FLAG_ARRAY_POINTER */
+   {  9412, 0x0000808C }, /* GL_EDGE_FLAG_ARRAY_STRIDE */
+   {  9438, 0x00008893 }, /* GL_ELEMENT_ARRAY_BUFFER */
+   {  9462, 0x00008895 }, /* GL_ELEMENT_ARRAY_BUFFER_BINDING */
+   {  9494, 0x00008895 }, /* GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB */
+   {  9530, 0x00001600 }, /* GL_EMISSION */
+   {  9542, 0x00002000 }, /* GL_ENABLE_BIT */
+   {  9556, 0x00000202 }, /* GL_EQUAL */
+   {  9565, 0x00001509 }, /* GL_EQUIV */
+   {  9574, 0x00010000 }, /* GL_EVAL_BIT */
+   {  9586, 0x00000800 }, /* GL_EXP */
+   {  9593, 0x00000801 }, /* GL_EXP2 */
+   {  9601, 0x00001F03 }, /* GL_EXTENSIONS */
+   {  9615, 0x00002400 }, /* GL_EYE_LINEAR */
+   {  9629, 0x00002502 }, /* GL_EYE_PLANE */
+   {  9642, 0x0000855C }, /* GL_EYE_PLANE_ABSOLUTE_NV */
+   {  9667, 0x0000855B }, /* GL_EYE_RADIAL_NV */
+   {  9684, 0x00000000 }, /* GL_FALSE */
+   {  9693, 0x00001101 }, /* GL_FASTEST */
+   {  9704, 0x00001C01 }, /* GL_FEEDBACK */
+   {  9716, 0x00000DF0 }, /* GL_FEEDBACK_BUFFER_POINTER */
+   {  9743, 0x00000DF1 }, /* GL_FEEDBACK_BUFFER_SIZE */
+   {  9767, 0x00000DF2 }, /* GL_FEEDBACK_BUFFER_TYPE */
+   {  9791, 0x00001B02 }, /* GL_FILL */
+   {  9799, 0x00008E4D }, /* GL_FIRST_VERTEX_CONVENTION */
+   {  9826, 0x00008E4D }, /* GL_FIRST_VERTEX_CONVENTION_EXT */
+   {  9857, 0x00001D00 }, /* GL_FLAT */
+   {  9865, 0x00001406 }, /* GL_FLOAT */
+   {  9874, 0x00008B5A }, /* GL_FLOAT_MAT2 */
+   {  9888, 0x00008B5A }, /* GL_FLOAT_MAT2_ARB */
+   {  9906, 0x00008B65 }, /* GL_FLOAT_MAT2x3 */
+   {  9922, 0x00008B66 }, /* GL_FLOAT_MAT2x4 */
+   {  9938, 0x00008B5B }, /* GL_FLOAT_MAT3 */
+   {  9952, 0x00008B5B }, /* GL_FLOAT_MAT3_ARB */
+   {  9970, 0x00008B67 }, /* GL_FLOAT_MAT3x2 */
+   {  9986, 0x00008B68 }, /* GL_FLOAT_MAT3x4 */
+   { 10002, 0x00008B5C }, /* GL_FLOAT_MAT4 */
+   { 10016, 0x00008B5C }, /* GL_FLOAT_MAT4_ARB */
+   { 10034, 0x00008B69 }, /* GL_FLOAT_MAT4x2 */
+   { 10050, 0x00008B6A }, /* GL_FLOAT_MAT4x3 */
+   { 10066, 0x00008B50 }, /* GL_FLOAT_VEC2 */
+   { 10080, 0x00008B50 }, /* GL_FLOAT_VEC2_ARB */
+   { 10098, 0x00008B51 }, /* GL_FLOAT_VEC3 */
+   { 10112, 0x00008B51 }, /* GL_FLOAT_VEC3_ARB */
+   { 10130, 0x00008B52 }, /* GL_FLOAT_VEC4 */
+   { 10144, 0x00008B52 }, /* GL_FLOAT_VEC4_ARB */
+   { 10162, 0x00000B60 }, /* GL_FOG */
+   { 10169, 0x00000080 }, /* GL_FOG_BIT */
+   { 10180, 0x00000B66 }, /* GL_FOG_COLOR */
+   { 10193, 0x00008451 }, /* GL_FOG_COORD */
+   { 10206, 0x00008451 }, /* GL_FOG_COORDINATE */
+   { 10224, 0x00008457 }, /* GL_FOG_COORDINATE_ARRAY */
+   { 10248, 0x0000889D }, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING */
+   { 10287, 0x0000889D }, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB */
+   { 10330, 0x00008456 }, /* GL_FOG_COORDINATE_ARRAY_POINTER */
+   { 10362, 0x00008455 }, /* GL_FOG_COORDINATE_ARRAY_STRIDE */
+   { 10393, 0x00008454 }, /* GL_FOG_COORDINATE_ARRAY_TYPE */
+   { 10422, 0x00008450 }, /* GL_FOG_COORDINATE_SOURCE */
+   { 10447, 0x00008457 }, /* GL_FOG_COORD_ARRAY */
+   { 10466, 0x0000889D }, /* GL_FOG_COORD_ARRAY_BUFFER_BINDING */
+   { 10500, 0x00008456 }, /* GL_FOG_COORD_ARRAY_POINTER */
+   { 10527, 0x00008455 }, /* GL_FOG_COORD_ARRAY_STRIDE */
+   { 10553, 0x00008454 }, /* GL_FOG_COORD_ARRAY_TYPE */
+   { 10577, 0x00008450 }, /* GL_FOG_COORD_SRC */
+   { 10594, 0x00000B62 }, /* GL_FOG_DENSITY */
+   { 10609, 0x0000855A }, /* GL_FOG_DISTANCE_MODE_NV */
+   { 10633, 0x00000B64 }, /* GL_FOG_END */
+   { 10644, 0x00000C54 }, /* GL_FOG_HINT */
+   { 10656, 0x00000B61 }, /* GL_FOG_INDEX */
+   { 10669, 0x00000B65 }, /* GL_FOG_MODE */
+   { 10681, 0x00008198 }, /* GL_FOG_OFFSET_SGIX */
+   { 10700, 0x00008199 }, /* GL_FOG_OFFSET_VALUE_SGIX */
+   { 10725, 0x00000B63 }, /* GL_FOG_START */
+   { 10738, 0x00008452 }, /* GL_FRAGMENT_DEPTH */
+   { 10756, 0x00008804 }, /* GL_FRAGMENT_PROGRAM_ARB */
+   { 10780, 0x00008B30 }, /* GL_FRAGMENT_SHADER */
+   { 10799, 0x00008B30 }, /* GL_FRAGMENT_SHADER_ARB */
+   { 10822, 0x00008B8B }, /* GL_FRAGMENT_SHADER_DERIVATIVE_HINT */
+   { 10857, 0x00008D40 }, /* GL_FRAMEBUFFER */
+   { 10872, 0x00008215 }, /* GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */
+   { 10909, 0x00008214 }, /* GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */
+   { 10945, 0x00008210 }, /* GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */
+   { 10986, 0x00008211 }, /* GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */
+   { 11027, 0x00008216 }, /* GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */
+   { 11064, 0x00008213 }, /* GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */
+   { 11101, 0x00008CD1 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */
+   { 11139, 0x00008CD1 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT */
+   { 11181, 0x00008CD0 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */
+   { 11219, 0x00008CD0 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT */
+   { 11261, 0x00008212 }, /* GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */
+   { 11296, 0x00008217 }, /* GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */
+   { 11335, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT */
+   { 11384, 0x00008CD3 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */
+   { 11432, 0x00008CD3 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT */
+   { 11484, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */
+   { 11524, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */
+   { 11568, 0x00008CD2 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */
+   { 11608, 0x00008CD2 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT */
+   { 11652, 0x00008CA6 }, /* GL_FRAMEBUFFER_BINDING */
+   { 11675, 0x00008CA6 }, /* GL_FRAMEBUFFER_BINDING_EXT */
+   { 11702, 0x00008CD5 }, /* GL_FRAMEBUFFER_COMPLETE */
+   { 11726, 0x00008CD5 }, /* GL_FRAMEBUFFER_COMPLETE_EXT */
+   { 11754, 0x00008218 }, /* GL_FRAMEBUFFER_DEFAULT */
+   { 11777, 0x00008D40 }, /* GL_FRAMEBUFFER_EXT */
+   { 11796, 0x00008CD6 }, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */
+   { 11833, 0x00008CD6 }, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT */
+   { 11874, 0x00008CD9 }, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT */
+   { 11915, 0x00008CDB }, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER */
+   { 11953, 0x00008CDB }, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT */
+   { 11995, 0x00008CD8 }, /* GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT */
+   { 12046, 0x00008CDA }, /* GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT */
+   { 12084, 0x00008CD7 }, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */
+   { 12129, 0x00008CD7 }, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT */
+   { 12178, 0x00008D56 }, /* GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */
+   { 12216, 0x00008D56 }, /* GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT */
+   { 12258, 0x00008CDC }, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER */
+   { 12296, 0x00008CDC }, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT */
+   { 12338, 0x00008CDE }, /* GL_FRAMEBUFFER_STATUS_ERROR_EXT */
+   { 12370, 0x00008219 }, /* GL_FRAMEBUFFER_UNDEFINED */
+   { 12395, 0x00008CDD }, /* GL_FRAMEBUFFER_UNSUPPORTED */
+   { 12422, 0x00008CDD }, /* GL_FRAMEBUFFER_UNSUPPORTED_EXT */
+   { 12453, 0x00000404 }, /* GL_FRONT */
+   { 12462, 0x00000408 }, /* GL_FRONT_AND_BACK */
+   { 12480, 0x00000B46 }, /* GL_FRONT_FACE */
+   { 12494, 0x00000400 }, /* GL_FRONT_LEFT */
+   { 12508, 0x00000401 }, /* GL_FRONT_RIGHT */
+   { 12523, 0x00008006 }, /* GL_FUNC_ADD */
+   { 12535, 0x00008006 }, /* GL_FUNC_ADD_EXT */
+   { 12551, 0x0000800B }, /* GL_FUNC_REVERSE_SUBTRACT */
+   { 12576, 0x0000800B }, /* GL_FUNC_REVERSE_SUBTRACT_EXT */
+   { 12605, 0x0000800A }, /* GL_FUNC_SUBTRACT */
+   { 12622, 0x0000800A }, /* GL_FUNC_SUBTRACT_EXT */
+   { 12643, 0x00008191 }, /* GL_GENERATE_MIPMAP */
+   { 12662, 0x00008192 }, /* GL_GENERATE_MIPMAP_HINT */
+   { 12686, 0x00008192 }, /* GL_GENERATE_MIPMAP_HINT_SGIS */
+   { 12715, 0x00008191 }, /* GL_GENERATE_MIPMAP_SGIS */
+   { 12739, 0x00000206 }, /* GL_GEQUAL */
+   { 12749, 0x00000204 }, /* GL_GREATER */
+   { 12760, 0x00001904 }, /* GL_GREEN */
+   { 12769, 0x00000D19 }, /* GL_GREEN_BIAS */
+   { 12783, 0x00000D53 }, /* GL_GREEN_BITS */
+   { 12797, 0x00000D18 }, /* GL_GREEN_SCALE */
+   { 12812, 0x00008000 }, /* GL_HINT_BIT */
+   { 12824, 0x00008024 }, /* GL_HISTOGRAM */
+   { 12837, 0x0000802B }, /* GL_HISTOGRAM_ALPHA_SIZE */
+   { 12861, 0x0000802B }, /* GL_HISTOGRAM_ALPHA_SIZE_EXT */
+   { 12889, 0x0000802A }, /* GL_HISTOGRAM_BLUE_SIZE */
+   { 12912, 0x0000802A }, /* GL_HISTOGRAM_BLUE_SIZE_EXT */
+   { 12939, 0x00008024 }, /* GL_HISTOGRAM_EXT */
+   { 12956, 0x00008027 }, /* GL_HISTOGRAM_FORMAT */
+   { 12976, 0x00008027 }, /* GL_HISTOGRAM_FORMAT_EXT */
+   { 13000, 0x00008029 }, /* GL_HISTOGRAM_GREEN_SIZE */
+   { 13024, 0x00008029 }, /* GL_HISTOGRAM_GREEN_SIZE_EXT */
+   { 13052, 0x0000802C }, /* GL_HISTOGRAM_LUMINANCE_SIZE */
+   { 13080, 0x0000802C }, /* GL_HISTOGRAM_LUMINANCE_SIZE_EXT */
+   { 13112, 0x00008028 }, /* GL_HISTOGRAM_RED_SIZE */
+   { 13134, 0x00008028 }, /* GL_HISTOGRAM_RED_SIZE_EXT */
+   { 13160, 0x0000802D }, /* GL_HISTOGRAM_SINK */
+   { 13178, 0x0000802D }, /* GL_HISTOGRAM_SINK_EXT */
+   { 13200, 0x00008026 }, /* GL_HISTOGRAM_WIDTH */
+   { 13219, 0x00008026 }, /* GL_HISTOGRAM_WIDTH_EXT */
+   { 13242, 0x0000862A }, /* GL_IDENTITY_NV */
+   { 13257, 0x00008150 }, /* GL_IGNORE_BORDER_HP */
+   { 13277, 0x00008B9B }, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES */
+   { 13317, 0x00008B9A }, /* GL_IMPLEMENTATION_COLOR_READ_TYPE_OES */
+   { 13355, 0x00001E02 }, /* GL_INCR */
+   { 13363, 0x00008507 }, /* GL_INCR_WRAP */
+   { 13376, 0x00008507 }, /* GL_INCR_WRAP_EXT */
+   { 13393, 0x00008222 }, /* GL_INDEX */
+   { 13402, 0x00008077 }, /* GL_INDEX_ARRAY */
+   { 13417, 0x00008899 }, /* GL_INDEX_ARRAY_BUFFER_BINDING */
+   { 13447, 0x00008899 }, /* GL_INDEX_ARRAY_BUFFER_BINDING_ARB */
+   { 13481, 0x00008091 }, /* GL_INDEX_ARRAY_POINTER */
+   { 13504, 0x00008086 }, /* GL_INDEX_ARRAY_STRIDE */
+   { 13526, 0x00008085 }, /* GL_INDEX_ARRAY_TYPE */
+   { 13546, 0x00000D51 }, /* GL_INDEX_BITS */
+   { 13560, 0x00000C20 }, /* GL_INDEX_CLEAR_VALUE */
+   { 13581, 0x00000BF1 }, /* GL_INDEX_LOGIC_OP */
+   { 13599, 0x00000C30 }, /* GL_INDEX_MODE */
+   { 13613, 0x00000D13 }, /* GL_INDEX_OFFSET */
+   { 13629, 0x00000D12 }, /* GL_INDEX_SHIFT */
+   { 13644, 0x00000C21 }, /* GL_INDEX_WRITEMASK */
+   { 13663, 0x00008B84 }, /* GL_INFO_LOG_LENGTH */
+   { 13682, 0x00001404 }, /* GL_INT */
+   { 13689, 0x00008049 }, /* GL_INTENSITY */
+   { 13702, 0x0000804C }, /* GL_INTENSITY12 */
+   { 13717, 0x0000804C }, /* GL_INTENSITY12_EXT */
+   { 13736, 0x0000804D }, /* GL_INTENSITY16 */
+   { 13751, 0x0000804D }, /* GL_INTENSITY16_EXT */
+   { 13770, 0x0000804A }, /* GL_INTENSITY4 */
+   { 13784, 0x0000804A }, /* GL_INTENSITY4_EXT */
+   { 13802, 0x0000804B }, /* GL_INTENSITY8 */
+   { 13816, 0x0000804B }, /* GL_INTENSITY8_EXT */
+   { 13834, 0x00008049 }, /* GL_INTENSITY_EXT */
+   { 13851, 0x00008575 }, /* GL_INTERPOLATE */
+   { 13866, 0x00008575 }, /* GL_INTERPOLATE_ARB */
+   { 13885, 0x00008575 }, /* GL_INTERPOLATE_EXT */
+   { 13904, 0x00008B53 }, /* GL_INT_VEC2 */
+   { 13916, 0x00008B53 }, /* GL_INT_VEC2_ARB */
+   { 13932, 0x00008B54 }, /* GL_INT_VEC3 */
+   { 13944, 0x00008B54 }, /* GL_INT_VEC3_ARB */
+   { 13960, 0x00008B55 }, /* GL_INT_VEC4 */
+   { 13972, 0x00008B55 }, /* GL_INT_VEC4_ARB */
+   { 13988, 0x00000500 }, /* GL_INVALID_ENUM */
+   { 14004, 0x00000506 }, /* GL_INVALID_FRAMEBUFFER_OPERATION */
+   { 14037, 0x00000506 }, /* GL_INVALID_FRAMEBUFFER_OPERATION_EXT */
+   { 14074, 0x00000502 }, /* GL_INVALID_OPERATION */
+   { 14095, 0x00000501 }, /* GL_INVALID_VALUE */
+   { 14112, 0x0000862B }, /* GL_INVERSE_NV */
+   { 14126, 0x0000862D }, /* GL_INVERSE_TRANSPOSE_NV */
+   { 14150, 0x0000150A }, /* GL_INVERT */
+   { 14160, 0x00001E00 }, /* GL_KEEP */
+   { 14168, 0x00008E4E }, /* GL_LAST_VERTEX_CONVENTION */
+   { 14194, 0x00008E4E }, /* GL_LAST_VERTEX_CONVENTION_EXT */
+   { 14224, 0x00000406 }, /* GL_LEFT */
+   { 14232, 0x00000203 }, /* GL_LEQUAL */
+   { 14242, 0x00000201 }, /* GL_LESS */
+   { 14250, 0x00004000 }, /* GL_LIGHT0 */
+   { 14260, 0x00004001 }, /* GL_LIGHT1 */
+   { 14270, 0x00004002 }, /* GL_LIGHT2 */
+   { 14280, 0x00004003 }, /* GL_LIGHT3 */
+   { 14290, 0x00004004 }, /* GL_LIGHT4 */
+   { 14300, 0x00004005 }, /* GL_LIGHT5 */
+   { 14310, 0x00004006 }, /* GL_LIGHT6 */
+   { 14320, 0x00004007 }, /* GL_LIGHT7 */
+   { 14330, 0x00000B50 }, /* GL_LIGHTING */
+   { 14342, 0x00000040 }, /* GL_LIGHTING_BIT */
+   { 14358, 0x00000B53 }, /* GL_LIGHT_MODEL_AMBIENT */
+   { 14381, 0x000081F8 }, /* GL_LIGHT_MODEL_COLOR_CONTROL */
+   { 14410, 0x000081F8 }, /* GL_LIGHT_MODEL_COLOR_CONTROL_EXT */
+   { 14443, 0x00000B51 }, /* GL_LIGHT_MODEL_LOCAL_VIEWER */
+   { 14471, 0x00000B52 }, /* GL_LIGHT_MODEL_TWO_SIDE */
+   { 14495, 0x00001B01 }, /* GL_LINE */
+   { 14503, 0x00002601 }, /* GL_LINEAR */
+   { 14513, 0x00001208 }, /* GL_LINEAR_ATTENUATION */
+   { 14535, 0x00008170 }, /* GL_LINEAR_CLIPMAP_LINEAR_SGIX */
+   { 14565, 0x0000844F }, /* GL_LINEAR_CLIPMAP_NEAREST_SGIX */
+   { 14596, 0x00002703 }, /* GL_LINEAR_MIPMAP_LINEAR */
+   { 14620, 0x00002701 }, /* GL_LINEAR_MIPMAP_NEAREST */
+   { 14645, 0x00000001 }, /* GL_LINES */
+   { 14654, 0x00000004 }, /* GL_LINE_BIT */
+   { 14666, 0x00000002 }, /* GL_LINE_LOOP */
+   { 14679, 0x00000707 }, /* GL_LINE_RESET_TOKEN */
+   { 14699, 0x00000B20 }, /* GL_LINE_SMOOTH */
+   { 14714, 0x00000C52 }, /* GL_LINE_SMOOTH_HINT */
+   { 14734, 0x00000B24 }, /* GL_LINE_STIPPLE */
+   { 14750, 0x00000B25 }, /* GL_LINE_STIPPLE_PATTERN */
+   { 14774, 0x00000B26 }, /* GL_LINE_STIPPLE_REPEAT */
+   { 14797, 0x00000003 }, /* GL_LINE_STRIP */
+   { 14811, 0x00000702 }, /* GL_LINE_TOKEN */
+   { 14825, 0x00000B21 }, /* GL_LINE_WIDTH */
+   { 14839, 0x00000B23 }, /* GL_LINE_WIDTH_GRANULARITY */
+   { 14865, 0x00000B22 }, /* GL_LINE_WIDTH_RANGE */
+   { 14885, 0x00008B82 }, /* GL_LINK_STATUS */
+   { 14900, 0x00000B32 }, /* GL_LIST_BASE */
+   { 14913, 0x00020000 }, /* GL_LIST_BIT */
+   { 14925, 0x00000B33 }, /* GL_LIST_INDEX */
+   { 14939, 0x00000B30 }, /* GL_LIST_MODE */
+   { 14952, 0x00000101 }, /* GL_LOAD */
+   { 14960, 0x00000BF1 }, /* GL_LOGIC_OP */
+   { 14972, 0x00000BF0 }, /* GL_LOGIC_OP_MODE */
+   { 14989, 0x00008CA1 }, /* GL_LOWER_LEFT */
+   { 15003, 0x00001909 }, /* GL_LUMINANCE */
+   { 15016, 0x00008041 }, /* GL_LUMINANCE12 */
+   { 15031, 0x00008047 }, /* GL_LUMINANCE12_ALPHA12 */
+   { 15054, 0x00008047 }, /* GL_LUMINANCE12_ALPHA12_EXT */
+   { 15081, 0x00008046 }, /* GL_LUMINANCE12_ALPHA4 */
+   { 15103, 0x00008046 }, /* GL_LUMINANCE12_ALPHA4_EXT */
+   { 15129, 0x00008041 }, /* GL_LUMINANCE12_EXT */
+   { 15148, 0x00008042 }, /* GL_LUMINANCE16 */
+   { 15163, 0x00008048 }, /* GL_LUMINANCE16_ALPHA16 */
+   { 15186, 0x00008048 }, /* GL_LUMINANCE16_ALPHA16_EXT */
+   { 15213, 0x00008042 }, /* GL_LUMINANCE16_EXT */
+   { 15232, 0x0000803F }, /* GL_LUMINANCE4 */
+   { 15246, 0x00008043 }, /* GL_LUMINANCE4_ALPHA4 */
+   { 15267, 0x00008043 }, /* GL_LUMINANCE4_ALPHA4_EXT */
+   { 15292, 0x0000803F }, /* GL_LUMINANCE4_EXT */
+   { 15310, 0x00008044 }, /* GL_LUMINANCE6_ALPHA2 */
+   { 15331, 0x00008044 }, /* GL_LUMINANCE6_ALPHA2_EXT */
+   { 15356, 0x00008040 }, /* GL_LUMINANCE8 */
+   { 15370, 0x00008045 }, /* GL_LUMINANCE8_ALPHA8 */
+   { 15391, 0x00008045 }, /* GL_LUMINANCE8_ALPHA8_EXT */
+   { 15416, 0x00008040 }, /* GL_LUMINANCE8_EXT */
+   { 15434, 0x0000190A }, /* GL_LUMINANCE_ALPHA */
+   { 15453, 0x00000D90 }, /* GL_MAP1_COLOR_4 */
+   { 15469, 0x00000DD0 }, /* GL_MAP1_GRID_DOMAIN */
+   { 15489, 0x00000DD1 }, /* GL_MAP1_GRID_SEGMENTS */
+   { 15511, 0x00000D91 }, /* GL_MAP1_INDEX */
+   { 15525, 0x00000D92 }, /* GL_MAP1_NORMAL */
+   { 15540, 0x00000D93 }, /* GL_MAP1_TEXTURE_COORD_1 */
+   { 15564, 0x00000D94 }, /* GL_MAP1_TEXTURE_COORD_2 */
+   { 15588, 0x00000D95 }, /* GL_MAP1_TEXTURE_COORD_3 */
+   { 15612, 0x00000D96 }, /* GL_MAP1_TEXTURE_COORD_4 */
+   { 15636, 0x00000D97 }, /* GL_MAP1_VERTEX_3 */
+   { 15653, 0x00000D98 }, /* GL_MAP1_VERTEX_4 */
+   { 15670, 0x00008660 }, /* GL_MAP1_VERTEX_ATTRIB0_4_NV */
+   { 15698, 0x0000866A }, /* GL_MAP1_VERTEX_ATTRIB10_4_NV */
+   { 15727, 0x0000866B }, /* GL_MAP1_VERTEX_ATTRIB11_4_NV */
+   { 15756, 0x0000866C }, /* GL_MAP1_VERTEX_ATTRIB12_4_NV */
+   { 15785, 0x0000866D }, /* GL_MAP1_VERTEX_ATTRIB13_4_NV */
+   { 15814, 0x0000866E }, /* GL_MAP1_VERTEX_ATTRIB14_4_NV */
+   { 15843, 0x0000866F }, /* GL_MAP1_VERTEX_ATTRIB15_4_NV */
+   { 15872, 0x00008661 }, /* GL_MAP1_VERTEX_ATTRIB1_4_NV */
+   { 15900, 0x00008662 }, /* GL_MAP1_VERTEX_ATTRIB2_4_NV */
+   { 15928, 0x00008663 }, /* GL_MAP1_VERTEX_ATTRIB3_4_NV */
+   { 15956, 0x00008664 }, /* GL_MAP1_VERTEX_ATTRIB4_4_NV */
+   { 15984, 0x00008665 }, /* GL_MAP1_VERTEX_ATTRIB5_4_NV */
+   { 16012, 0x00008666 }, /* GL_MAP1_VERTEX_ATTRIB6_4_NV */
+   { 16040, 0x00008667 }, /* GL_MAP1_VERTEX_ATTRIB7_4_NV */
+   { 16068, 0x00008668 }, /* GL_MAP1_VERTEX_ATTRIB8_4_NV */
+   { 16096, 0x00008669 }, /* GL_MAP1_VERTEX_ATTRIB9_4_NV */
+   { 16124, 0x00000DB0 }, /* GL_MAP2_COLOR_4 */
+   { 16140, 0x00000DD2 }, /* GL_MAP2_GRID_DOMAIN */
+   { 16160, 0x00000DD3 }, /* GL_MAP2_GRID_SEGMENTS */
+   { 16182, 0x00000DB1 }, /* GL_MAP2_INDEX */
+   { 16196, 0x00000DB2 }, /* GL_MAP2_NORMAL */
+   { 16211, 0x00000DB3 }, /* GL_MAP2_TEXTURE_COORD_1 */
+   { 16235, 0x00000DB4 }, /* GL_MAP2_TEXTURE_COORD_2 */
+   { 16259, 0x00000DB5 }, /* GL_MAP2_TEXTURE_COORD_3 */
+   { 16283, 0x00000DB6 }, /* GL_MAP2_TEXTURE_COORD_4 */
+   { 16307, 0x00000DB7 }, /* GL_MAP2_VERTEX_3 */
+   { 16324, 0x00000DB8 }, /* GL_MAP2_VERTEX_4 */
+   { 16341, 0x00008670 }, /* GL_MAP2_VERTEX_ATTRIB0_4_NV */
+   { 16369, 0x0000867A }, /* GL_MAP2_VERTEX_ATTRIB10_4_NV */
+   { 16398, 0x0000867B }, /* GL_MAP2_VERTEX_ATTRIB11_4_NV */
+   { 16427, 0x0000867C }, /* GL_MAP2_VERTEX_ATTRIB12_4_NV */
+   { 16456, 0x0000867D }, /* GL_MAP2_VERTEX_ATTRIB13_4_NV */
+   { 16485, 0x0000867E }, /* GL_MAP2_VERTEX_ATTRIB14_4_NV */
+   { 16514, 0x0000867F }, /* GL_MAP2_VERTEX_ATTRIB15_4_NV */
+   { 16543, 0x00008671 }, /* GL_MAP2_VERTEX_ATTRIB1_4_NV */
+   { 16571, 0x00008672 }, /* GL_MAP2_VERTEX_ATTRIB2_4_NV */
+   { 16599, 0x00008673 }, /* GL_MAP2_VERTEX_ATTRIB3_4_NV */
+   { 16627, 0x00008674 }, /* GL_MAP2_VERTEX_ATTRIB4_4_NV */
+   { 16655, 0x00008675 }, /* GL_MAP2_VERTEX_ATTRIB5_4_NV */
+   { 16683, 0x00008676 }, /* GL_MAP2_VERTEX_ATTRIB6_4_NV */
+   { 16711, 0x00008677 }, /* GL_MAP2_VERTEX_ATTRIB7_4_NV */
+   { 16739, 0x00008678 }, /* GL_MAP2_VERTEX_ATTRIB8_4_NV */
+   { 16767, 0x00008679 }, /* GL_MAP2_VERTEX_ATTRIB9_4_NV */
+   { 16795, 0x00000D10 }, /* GL_MAP_COLOR */
+   { 16808, 0x00000010 }, /* GL_MAP_FLUSH_EXPLICIT_BIT */
+   { 16834, 0x00000008 }, /* GL_MAP_INVALIDATE_BUFFER_BIT */
+   { 16863, 0x00000004 }, /* GL_MAP_INVALIDATE_RANGE_BIT */
+   { 16891, 0x00000001 }, /* GL_MAP_READ_BIT */
+   { 16907, 0x00000D11 }, /* GL_MAP_STENCIL */
+   { 16922, 0x00000020 }, /* GL_MAP_UNSYNCHRONIZED_BIT */
+   { 16948, 0x00000002 }, /* GL_MAP_WRITE_BIT */
+   { 16965, 0x000088C0 }, /* GL_MATRIX0_ARB */
+   { 16980, 0x00008630 }, /* GL_MATRIX0_NV */
+   { 16994, 0x000088CA }, /* GL_MATRIX10_ARB */
+   { 17010, 0x000088CB }, /* GL_MATRIX11_ARB */
+   { 17026, 0x000088CC }, /* GL_MATRIX12_ARB */
+   { 17042, 0x000088CD }, /* GL_MATRIX13_ARB */
+   { 17058, 0x000088CE }, /* GL_MATRIX14_ARB */
+   { 17074, 0x000088CF }, /* GL_MATRIX15_ARB */
+   { 17090, 0x000088D0 }, /* GL_MATRIX16_ARB */
+   { 17106, 0x000088D1 }, /* GL_MATRIX17_ARB */
+   { 17122, 0x000088D2 }, /* GL_MATRIX18_ARB */
+   { 17138, 0x000088D3 }, /* GL_MATRIX19_ARB */
+   { 17154, 0x000088C1 }, /* GL_MATRIX1_ARB */
+   { 17169, 0x00008631 }, /* GL_MATRIX1_NV */
+   { 17183, 0x000088D4 }, /* GL_MATRIX20_ARB */
+   { 17199, 0x000088D5 }, /* GL_MATRIX21_ARB */
+   { 17215, 0x000088D6 }, /* GL_MATRIX22_ARB */
+   { 17231, 0x000088D7 }, /* GL_MATRIX23_ARB */
+   { 17247, 0x000088D8 }, /* GL_MATRIX24_ARB */
+   { 17263, 0x000088D9 }, /* GL_MATRIX25_ARB */
+   { 17279, 0x000088DA }, /* GL_MATRIX26_ARB */
+   { 17295, 0x000088DB }, /* GL_MATRIX27_ARB */
+   { 17311, 0x000088DC }, /* GL_MATRIX28_ARB */
+   { 17327, 0x000088DD }, /* GL_MATRIX29_ARB */
+   { 17343, 0x000088C2 }, /* GL_MATRIX2_ARB */
+   { 17358, 0x00008632 }, /* GL_MATRIX2_NV */
+   { 17372, 0x000088DE }, /* GL_MATRIX30_ARB */
+   { 17388, 0x000088DF }, /* GL_MATRIX31_ARB */
+   { 17404, 0x000088C3 }, /* GL_MATRIX3_ARB */
+   { 17419, 0x00008633 }, /* GL_MATRIX3_NV */
+   { 17433, 0x000088C4 }, /* GL_MATRIX4_ARB */
+   { 17448, 0x00008634 }, /* GL_MATRIX4_NV */
+   { 17462, 0x000088C5 }, /* GL_MATRIX5_ARB */
+   { 17477, 0x00008635 }, /* GL_MATRIX5_NV */
+   { 17491, 0x000088C6 }, /* GL_MATRIX6_ARB */
+   { 17506, 0x00008636 }, /* GL_MATRIX6_NV */
+   { 17520, 0x000088C7 }, /* GL_MATRIX7_ARB */
+   { 17535, 0x00008637 }, /* GL_MATRIX7_NV */
+   { 17549, 0x000088C8 }, /* GL_MATRIX8_ARB */
+   { 17564, 0x000088C9 }, /* GL_MATRIX9_ARB */
+   { 17579, 0x00008844 }, /* GL_MATRIX_INDEX_ARRAY_ARB */
+   { 17605, 0x00008849 }, /* GL_MATRIX_INDEX_ARRAY_POINTER_ARB */
+   { 17639, 0x00008846 }, /* GL_MATRIX_INDEX_ARRAY_SIZE_ARB */
+   { 17670, 0x00008848 }, /* GL_MATRIX_INDEX_ARRAY_STRIDE_ARB */
+   { 17703, 0x00008847 }, /* GL_MATRIX_INDEX_ARRAY_TYPE_ARB */
+   { 17734, 0x00000BA0 }, /* GL_MATRIX_MODE */
+   { 17749, 0x00008840 }, /* GL_MATRIX_PALETTE_ARB */
+   { 17771, 0x00008008 }, /* GL_MAX */
+   { 17778, 0x00008073 }, /* GL_MAX_3D_TEXTURE_SIZE */
+   { 17801, 0x000088FF }, /* GL_MAX_ARRAY_TEXTURE_LAYERS_EXT */
+   { 17833, 0x00000D35 }, /* GL_MAX_ATTRIB_STACK_DEPTH */
+   { 17859, 0x00000D3B }, /* GL_MAX_CLIENT_ATTRIB_STACK_DEPTH */
+   { 17892, 0x00008177 }, /* GL_MAX_CLIPMAP_DEPTH_SGIX */
+   { 17918, 0x00008178 }, /* GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX */
+   { 17952, 0x00000D32 }, /* GL_MAX_CLIP_PLANES */
+   { 17971, 0x00008CDF }, /* GL_MAX_COLOR_ATTACHMENTS */
+   { 17996, 0x00008CDF }, /* GL_MAX_COLOR_ATTACHMENTS_EXT */
+   { 18025, 0x000080B3 }, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH */
+   { 18057, 0x000080B3 }, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI */
+   { 18093, 0x00008B4D }, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS */
+   { 18129, 0x00008B4D }, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB */
+   { 18169, 0x0000801B }, /* GL_MAX_CONVOLUTION_HEIGHT */
+   { 18195, 0x0000801B }, /* GL_MAX_CONVOLUTION_HEIGHT_EXT */
+   { 18225, 0x0000801A }, /* GL_MAX_CONVOLUTION_WIDTH */
+   { 18250, 0x0000801A }, /* GL_MAX_CONVOLUTION_WIDTH_EXT */
+   { 18279, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE */
+   { 18308, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB */
+   { 18341, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS */
+   { 18361, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS_ARB */
+   { 18385, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS_ATI */
+   { 18409, 0x000080E9 }, /* GL_MAX_ELEMENTS_INDICES */
+   { 18433, 0x000080E8 }, /* GL_MAX_ELEMENTS_VERTICES */
+   { 18458, 0x00000D30 }, /* GL_MAX_EVAL_ORDER */
+   { 18476, 0x00008008 }, /* GL_MAX_EXT */
+   { 18487, 0x00008B49 }, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS */
+   { 18522, 0x00008B49 }, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB */
+   { 18561, 0x00000D31 }, /* GL_MAX_LIGHTS */
+   { 18575, 0x00000B31 }, /* GL_MAX_LIST_NESTING */
+   { 18595, 0x00008841 }, /* GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB */
+   { 18633, 0x00000D36 }, /* GL_MAX_MODELVIEW_STACK_DEPTH */
+   { 18662, 0x00000D37 }, /* GL_MAX_NAME_STACK_DEPTH */
+   { 18686, 0x00008842 }, /* GL_MAX_PALETTE_MATRICES_ARB */
+   { 18714, 0x00000D34 }, /* GL_MAX_PIXEL_MAP_TABLE */
+   { 18737, 0x000088B1 }, /* GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB */
+   { 18774, 0x0000880B }, /* GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB */
+   { 18810, 0x000088AD }, /* GL_MAX_PROGRAM_ATTRIBS_ARB */
+   { 18837, 0x000088F5 }, /* GL_MAX_PROGRAM_CALL_DEPTH_NV */
+   { 18866, 0x000088B5 }, /* GL_MAX_PROGRAM_ENV_PARAMETERS_ARB */
+   { 18900, 0x000088F4 }, /* GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */
+   { 18936, 0x000088F6 }, /* GL_MAX_PROGRAM_IF_DEPTH_NV */
+   { 18963, 0x000088A1 }, /* GL_MAX_PROGRAM_INSTRUCTIONS_ARB */
+   { 18995, 0x000088B4 }, /* GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB */
+   { 19031, 0x000088F8 }, /* GL_MAX_PROGRAM_LOOP_COUNT_NV */
+   { 19060, 0x000088F7 }, /* GL_MAX_PROGRAM_LOOP_DEPTH_NV */
+   { 19089, 0x0000862F }, /* GL_MAX_PROGRAM_MATRICES_ARB */
+   { 19117, 0x0000862E }, /* GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB */
+   { 19155, 0x000088B3 }, /* GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */
+   { 19199, 0x0000880E }, /* GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */
+   { 19242, 0x000088AF }, /* GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB */
+   { 19276, 0x000088A3 }, /* GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB */
+   { 19315, 0x000088AB }, /* GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB */
+   { 19352, 0x000088A7 }, /* GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB */
+   { 19390, 0x00008810 }, /* GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */
+   { 19433, 0x0000880F }, /* GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */
+   { 19476, 0x000088A9 }, /* GL_MAX_PROGRAM_PARAMETERS_ARB */
+   { 19506, 0x000088A5 }, /* GL_MAX_PROGRAM_TEMPORARIES_ARB */
+   { 19537, 0x0000880D }, /* GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB */
+   { 19573, 0x0000880C }, /* GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB */
+   { 19609, 0x00000D38 }, /* GL_MAX_PROJECTION_STACK_DEPTH */
+   { 19639, 0x000084F8 }, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB */
+   { 19673, 0x000084F8 }, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_NV */
+   { 19706, 0x000084E8 }, /* GL_MAX_RENDERBUFFER_SIZE */
+   { 19731, 0x000084E8 }, /* GL_MAX_RENDERBUFFER_SIZE_EXT */
+   { 19760, 0x00008D57 }, /* GL_MAX_SAMPLES */
+   { 19775, 0x00008D57 }, /* GL_MAX_SAMPLES_EXT */
+   { 19794, 0x00009111 }, /* GL_MAX_SERVER_WAIT_TIMEOUT */
+   { 19821, 0x00008504 }, /* GL_MAX_SHININESS_NV */
+   { 19841, 0x00008505 }, /* GL_MAX_SPOT_EXPONENT_NV */
+   { 19865, 0x00008871 }, /* GL_MAX_TEXTURE_COORDS */
+   { 19887, 0x00008871 }, /* GL_MAX_TEXTURE_COORDS_ARB */
+   { 19913, 0x00008872 }, /* GL_MAX_TEXTURE_IMAGE_UNITS */
+   { 19940, 0x00008872 }, /* GL_MAX_TEXTURE_IMAGE_UNITS_ARB */
+   { 19971, 0x000084FD }, /* GL_MAX_TEXTURE_LOD_BIAS */
+   { 19995, 0x000084FF }, /* GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT */
+   { 20029, 0x00000D33 }, /* GL_MAX_TEXTURE_SIZE */
+   { 20049, 0x00000D39 }, /* GL_MAX_TEXTURE_STACK_DEPTH */
+   { 20076, 0x000084E2 }, /* GL_MAX_TEXTURE_UNITS */
+   { 20097, 0x000084E2 }, /* GL_MAX_TEXTURE_UNITS_ARB */
+   { 20122, 0x0000862F }, /* GL_MAX_TRACK_MATRICES_NV */
+   { 20147, 0x0000862E }, /* GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV */
+   { 20182, 0x00008B4B }, /* GL_MAX_VARYING_FLOATS */
+   { 20204, 0x00008B4B }, /* GL_MAX_VARYING_FLOATS_ARB */
+   { 20230, 0x00008869 }, /* GL_MAX_VERTEX_ATTRIBS */
+   { 20252, 0x00008869 }, /* GL_MAX_VERTEX_ATTRIBS_ARB */
+   { 20278, 0x00008B4C }, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS */
+   { 20312, 0x00008B4C }, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */
+   { 20350, 0x00008B4A }, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS */
+   { 20383, 0x00008B4A }, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB */
+   { 20420, 0x000086A4 }, /* GL_MAX_VERTEX_UNITS_ARB */
+   { 20444, 0x00000D3A }, /* GL_MAX_VIEWPORT_DIMS */
+   { 20465, 0x00008007 }, /* GL_MIN */
+   { 20472, 0x0000802E }, /* GL_MINMAX */
+   { 20482, 0x0000802E }, /* GL_MINMAX_EXT */
+   { 20496, 0x0000802F }, /* GL_MINMAX_FORMAT */
+   { 20513, 0x0000802F }, /* GL_MINMAX_FORMAT_EXT */
+   { 20534, 0x00008030 }, /* GL_MINMAX_SINK */
+   { 20549, 0x00008030 }, /* GL_MINMAX_SINK_EXT */
+   { 20568, 0x00008007 }, /* GL_MIN_EXT */
+   { 20579, 0x00008370 }, /* GL_MIRRORED_REPEAT */
+   { 20598, 0x00008370 }, /* GL_MIRRORED_REPEAT_ARB */
+   { 20621, 0x00008370 }, /* GL_MIRRORED_REPEAT_IBM */
+   { 20644, 0x00008742 }, /* GL_MIRROR_CLAMP_ATI */
+   { 20664, 0x00008742 }, /* GL_MIRROR_CLAMP_EXT */
+   { 20684, 0x00008912 }, /* GL_MIRROR_CLAMP_TO_BORDER_EXT */
+   { 20714, 0x00008743 }, /* GL_MIRROR_CLAMP_TO_EDGE_ATI */
+   { 20742, 0x00008743 }, /* GL_MIRROR_CLAMP_TO_EDGE_EXT */
+   { 20770, 0x00001700 }, /* GL_MODELVIEW */
+   { 20783, 0x00001700 }, /* GL_MODELVIEW0_ARB */
+   { 20801, 0x0000872A }, /* GL_MODELVIEW10_ARB */
+   { 20820, 0x0000872B }, /* GL_MODELVIEW11_ARB */
+   { 20839, 0x0000872C }, /* GL_MODELVIEW12_ARB */
+   { 20858, 0x0000872D }, /* GL_MODELVIEW13_ARB */
+   { 20877, 0x0000872E }, /* GL_MODELVIEW14_ARB */
+   { 20896, 0x0000872F }, /* GL_MODELVIEW15_ARB */
+   { 20915, 0x00008730 }, /* GL_MODELVIEW16_ARB */
+   { 20934, 0x00008731 }, /* GL_MODELVIEW17_ARB */
+   { 20953, 0x00008732 }, /* GL_MODELVIEW18_ARB */
+   { 20972, 0x00008733 }, /* GL_MODELVIEW19_ARB */
+   { 20991, 0x0000850A }, /* GL_MODELVIEW1_ARB */
+   { 21009, 0x00008734 }, /* GL_MODELVIEW20_ARB */
+   { 21028, 0x00008735 }, /* GL_MODELVIEW21_ARB */
+   { 21047, 0x00008736 }, /* GL_MODELVIEW22_ARB */
+   { 21066, 0x00008737 }, /* GL_MODELVIEW23_ARB */
+   { 21085, 0x00008738 }, /* GL_MODELVIEW24_ARB */
+   { 21104, 0x00008739 }, /* GL_MODELVIEW25_ARB */
+   { 21123, 0x0000873A }, /* GL_MODELVIEW26_ARB */
+   { 21142, 0x0000873B }, /* GL_MODELVIEW27_ARB */
+   { 21161, 0x0000873C }, /* GL_MODELVIEW28_ARB */
+   { 21180, 0x0000873D }, /* GL_MODELVIEW29_ARB */
+   { 21199, 0x00008722 }, /* GL_MODELVIEW2_ARB */
+   { 21217, 0x0000873E }, /* GL_MODELVIEW30_ARB */
+   { 21236, 0x0000873F }, /* GL_MODELVIEW31_ARB */
+   { 21255, 0x00008723 }, /* GL_MODELVIEW3_ARB */
+   { 21273, 0x00008724 }, /* GL_MODELVIEW4_ARB */
+   { 21291, 0x00008725 }, /* GL_MODELVIEW5_ARB */
+   { 21309, 0x00008726 }, /* GL_MODELVIEW6_ARB */
+   { 21327, 0x00008727 }, /* GL_MODELVIEW7_ARB */
+   { 21345, 0x00008728 }, /* GL_MODELVIEW8_ARB */
+   { 21363, 0x00008729 }, /* GL_MODELVIEW9_ARB */
+   { 21381, 0x00000BA6 }, /* GL_MODELVIEW_MATRIX */
+   { 21401, 0x00008629 }, /* GL_MODELVIEW_PROJECTION_NV */
+   { 21428, 0x00000BA3 }, /* GL_MODELVIEW_STACK_DEPTH */
+   { 21453, 0x00002100 }, /* GL_MODULATE */
+   { 21465, 0x00008744 }, /* GL_MODULATE_ADD_ATI */
+   { 21485, 0x00008745 }, /* GL_MODULATE_SIGNED_ADD_ATI */
+   { 21512, 0x00008746 }, /* GL_MODULATE_SUBTRACT_ATI */
+   { 21537, 0x00000103 }, /* GL_MULT */
+   { 21545, 0x0000809D }, /* GL_MULTISAMPLE */
+   { 21560, 0x000086B2 }, /* GL_MULTISAMPLE_3DFX */
+   { 21580, 0x0000809D }, /* GL_MULTISAMPLE_ARB */
+   { 21599, 0x20000000 }, /* GL_MULTISAMPLE_BIT */
+   { 21618, 0x20000000 }, /* GL_MULTISAMPLE_BIT_3DFX */
+   { 21642, 0x20000000 }, /* GL_MULTISAMPLE_BIT_ARB */
+   { 21665, 0x00008534 }, /* GL_MULTISAMPLE_FILTER_HINT_NV */
+   { 21695, 0x00002A25 }, /* GL_N3F_V3F */
+   { 21706, 0x00000D70 }, /* GL_NAME_STACK_DEPTH */
+   { 21726, 0x0000150E }, /* GL_NAND */
+   { 21734, 0x00002600 }, /* GL_NEAREST */
+   { 21745, 0x0000844E }, /* GL_NEAREST_CLIPMAP_LINEAR_SGIX */
+   { 21776, 0x0000844D }, /* GL_NEAREST_CLIPMAP_NEAREST_SGIX */
+   { 21808, 0x00002702 }, /* GL_NEAREST_MIPMAP_LINEAR */
+   { 21833, 0x00002700 }, /* GL_NEAREST_MIPMAP_NEAREST */
+   { 21859, 0x00000200 }, /* GL_NEVER */
+   { 21868, 0x00001102 }, /* GL_NICEST */
+   { 21878, 0x00000000 }, /* GL_NONE */
+   { 21886, 0x00001505 }, /* GL_NOOP */
+   { 21894, 0x00001508 }, /* GL_NOR */
+   { 21901, 0x00000BA1 }, /* GL_NORMALIZE */
+   { 21914, 0x00008075 }, /* GL_NORMAL_ARRAY */
+   { 21930, 0x00008897 }, /* GL_NORMAL_ARRAY_BUFFER_BINDING */
+   { 21961, 0x00008897 }, /* GL_NORMAL_ARRAY_BUFFER_BINDING_ARB */
+   { 21996, 0x0000808F }, /* GL_NORMAL_ARRAY_POINTER */
+   { 22020, 0x0000807F }, /* GL_NORMAL_ARRAY_STRIDE */
+   { 22043, 0x0000807E }, /* GL_NORMAL_ARRAY_TYPE */
+   { 22064, 0x00008511 }, /* GL_NORMAL_MAP */
+   { 22078, 0x00008511 }, /* GL_NORMAL_MAP_ARB */
+   { 22096, 0x00008511 }, /* GL_NORMAL_MAP_NV */
+   { 22113, 0x00000205 }, /* GL_NOTEQUAL */
+   { 22125, 0x00000000 }, /* GL_NO_ERROR */
+   { 22137, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS */
+   { 22171, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB */
+   { 22209, 0x00008B89 }, /* GL_OBJECT_ACTIVE_ATTRIBUTES_ARB */
+   { 22241, 0x00008B8A }, /* GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB */
+   { 22283, 0x00008B86 }, /* GL_OBJECT_ACTIVE_UNIFORMS_ARB */
+   { 22313, 0x00008B87 }, /* GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB */
+   { 22353, 0x00008B85 }, /* GL_OBJECT_ATTACHED_OBJECTS_ARB */
+   { 22384, 0x00008B81 }, /* GL_OBJECT_COMPILE_STATUS_ARB */
+   { 22413, 0x00008B80 }, /* GL_OBJECT_DELETE_STATUS_ARB */
+   { 22441, 0x00008B84 }, /* GL_OBJECT_INFO_LOG_LENGTH_ARB */
+   { 22471, 0x00002401 }, /* GL_OBJECT_LINEAR */
+   { 22488, 0x00008B82 }, /* GL_OBJECT_LINK_STATUS_ARB */
+   { 22514, 0x00002501 }, /* GL_OBJECT_PLANE */
+   { 22530, 0x00008B88 }, /* GL_OBJECT_SHADER_SOURCE_LENGTH_ARB */
+   { 22565, 0x00008B4F }, /* GL_OBJECT_SUBTYPE_ARB */
+   { 22587, 0x00009112 }, /* GL_OBJECT_TYPE */
+   { 22602, 0x00008B4E }, /* GL_OBJECT_TYPE_ARB */
+   { 22621, 0x00008B83 }, /* GL_OBJECT_VALIDATE_STATUS_ARB */
+   { 22651, 0x00008165 }, /* GL_OCCLUSION_TEST_HP */
+   { 22672, 0x00008166 }, /* GL_OCCLUSION_TEST_RESULT_HP */
+   { 22700, 0x00000001 }, /* GL_ONE */
+   { 22707, 0x00008004 }, /* GL_ONE_MINUS_CONSTANT_ALPHA */
+   { 22735, 0x00008004 }, /* GL_ONE_MINUS_CONSTANT_ALPHA_EXT */
+   { 22767, 0x00008002 }, /* GL_ONE_MINUS_CONSTANT_COLOR */
+   { 22795, 0x00008002 }, /* GL_ONE_MINUS_CONSTANT_COLOR_EXT */
+   { 22827, 0x00000305 }, /* GL_ONE_MINUS_DST_ALPHA */
+   { 22850, 0x00000307 }, /* GL_ONE_MINUS_DST_COLOR */
+   { 22873, 0x00000303 }, /* GL_ONE_MINUS_SRC_ALPHA */
+   { 22896, 0x00000301 }, /* GL_ONE_MINUS_SRC_COLOR */
+   { 22919, 0x00008598 }, /* GL_OPERAND0_ALPHA */
+   { 22937, 0x00008598 }, /* GL_OPERAND0_ALPHA_ARB */
+   { 22959, 0x00008598 }, /* GL_OPERAND0_ALPHA_EXT */
+   { 22981, 0x00008590 }, /* GL_OPERAND0_RGB */
+   { 22997, 0x00008590 }, /* GL_OPERAND0_RGB_ARB */
+   { 23017, 0x00008590 }, /* GL_OPERAND0_RGB_EXT */
+   { 23037, 0x00008599 }, /* GL_OPERAND1_ALPHA */
+   { 23055, 0x00008599 }, /* GL_OPERAND1_ALPHA_ARB */
+   { 23077, 0x00008599 }, /* GL_OPERAND1_ALPHA_EXT */
+   { 23099, 0x00008591 }, /* GL_OPERAND1_RGB */
+   { 23115, 0x00008591 }, /* GL_OPERAND1_RGB_ARB */
+   { 23135, 0x00008591 }, /* GL_OPERAND1_RGB_EXT */
+   { 23155, 0x0000859A }, /* GL_OPERAND2_ALPHA */
+   { 23173, 0x0000859A }, /* GL_OPERAND2_ALPHA_ARB */
+   { 23195, 0x0000859A }, /* GL_OPERAND2_ALPHA_EXT */
+   { 23217, 0x00008592 }, /* GL_OPERAND2_RGB */
+   { 23233, 0x00008592 }, /* GL_OPERAND2_RGB_ARB */
+   { 23253, 0x00008592 }, /* GL_OPERAND2_RGB_EXT */
+   { 23273, 0x0000859B }, /* GL_OPERAND3_ALPHA_NV */
+   { 23294, 0x00008593 }, /* GL_OPERAND3_RGB_NV */
+   { 23313, 0x00001507 }, /* GL_OR */
+   { 23319, 0x00000A01 }, /* GL_ORDER */
+   { 23328, 0x0000150D }, /* GL_OR_INVERTED */
+   { 23343, 0x0000150B }, /* GL_OR_REVERSE */
+   { 23357, 0x00000505 }, /* GL_OUT_OF_MEMORY */
+   { 23374, 0x00000D05 }, /* GL_PACK_ALIGNMENT */
+   { 23392, 0x0000806C }, /* GL_PACK_IMAGE_HEIGHT */
+   { 23413, 0x00008758 }, /* GL_PACK_INVERT_MESA */
+   { 23433, 0x00000D01 }, /* GL_PACK_LSB_FIRST */
+   { 23451, 0x00000D02 }, /* GL_PACK_ROW_LENGTH */
+   { 23470, 0x0000806B }, /* GL_PACK_SKIP_IMAGES */
+   { 23490, 0x00000D04 }, /* GL_PACK_SKIP_PIXELS */
+   { 23510, 0x00000D03 }, /* GL_PACK_SKIP_ROWS */
+   { 23528, 0x00000D00 }, /* GL_PACK_SWAP_BYTES */
+   { 23547, 0x00008B92 }, /* GL_PALETTE4_R5_G6_B5_OES */
+   { 23572, 0x00008B94 }, /* GL_PALETTE4_RGB5_A1_OES */
+   { 23596, 0x00008B90 }, /* GL_PALETTE4_RGB8_OES */
+   { 23617, 0x00008B93 }, /* GL_PALETTE4_RGBA4_OES */
+   { 23639, 0x00008B91 }, /* GL_PALETTE4_RGBA8_OES */
+   { 23661, 0x00008B97 }, /* GL_PALETTE8_R5_G6_B5_OES */
+   { 23686, 0x00008B99 }, /* GL_PALETTE8_RGB5_A1_OES */
+   { 23710, 0x00008B95 }, /* GL_PALETTE8_RGB8_OES */
+   { 23731, 0x00008B98 }, /* GL_PALETTE8_RGBA4_OES */
+   { 23753, 0x00008B96 }, /* GL_PALETTE8_RGBA8_OES */
+   { 23775, 0x00000700 }, /* GL_PASS_THROUGH_TOKEN */
+   { 23797, 0x00000C50 }, /* GL_PERSPECTIVE_CORRECTION_HINT */
+   { 23828, 0x00000C79 }, /* GL_PIXEL_MAP_A_TO_A */
+   { 23848, 0x00000CB9 }, /* GL_PIXEL_MAP_A_TO_A_SIZE */
+   { 23873, 0x00000C78 }, /* GL_PIXEL_MAP_B_TO_B */
+   { 23893, 0x00000CB8 }, /* GL_PIXEL_MAP_B_TO_B_SIZE */
+   { 23918, 0x00000C77 }, /* GL_PIXEL_MAP_G_TO_G */
+   { 23938, 0x00000CB7 }, /* GL_PIXEL_MAP_G_TO_G_SIZE */
+   { 23963, 0x00000C75 }, /* GL_PIXEL_MAP_I_TO_A */
+   { 23983, 0x00000CB5 }, /* GL_PIXEL_MAP_I_TO_A_SIZE */
+   { 24008, 0x00000C74 }, /* GL_PIXEL_MAP_I_TO_B */
+   { 24028, 0x00000CB4 }, /* GL_PIXEL_MAP_I_TO_B_SIZE */
+   { 24053, 0x00000C73 }, /* GL_PIXEL_MAP_I_TO_G */
+   { 24073, 0x00000CB3 }, /* GL_PIXEL_MAP_I_TO_G_SIZE */
+   { 24098, 0x00000C70 }, /* GL_PIXEL_MAP_I_TO_I */
+   { 24118, 0x00000CB0 }, /* GL_PIXEL_MAP_I_TO_I_SIZE */
+   { 24143, 0x00000C72 }, /* GL_PIXEL_MAP_I_TO_R */
+   { 24163, 0x00000CB2 }, /* GL_PIXEL_MAP_I_TO_R_SIZE */
+   { 24188, 0x00000C76 }, /* GL_PIXEL_MAP_R_TO_R */
+   { 24208, 0x00000CB6 }, /* GL_PIXEL_MAP_R_TO_R_SIZE */
+   { 24233, 0x00000C71 }, /* GL_PIXEL_MAP_S_TO_S */
+   { 24253, 0x00000CB1 }, /* GL_PIXEL_MAP_S_TO_S_SIZE */
+   { 24278, 0x00000020 }, /* GL_PIXEL_MODE_BIT */
+   { 24296, 0x000088EB }, /* GL_PIXEL_PACK_BUFFER */
+   { 24317, 0x000088ED }, /* GL_PIXEL_PACK_BUFFER_BINDING */
+   { 24346, 0x000088ED }, /* GL_PIXEL_PACK_BUFFER_BINDING_EXT */
+   { 24379, 0x000088EB }, /* GL_PIXEL_PACK_BUFFER_EXT */
+   { 24404, 0x000088EC }, /* GL_PIXEL_UNPACK_BUFFER */
+   { 24427, 0x000088EF }, /* GL_PIXEL_UNPACK_BUFFER_BINDING */
+   { 24458, 0x000088EF }, /* GL_PIXEL_UNPACK_BUFFER_BINDING_EXT */
+   { 24493, 0x000088EC }, /* GL_PIXEL_UNPACK_BUFFER_EXT */
+   { 24520, 0x00001B00 }, /* GL_POINT */
+   { 24529, 0x00000000 }, /* GL_POINTS */
+   { 24539, 0x00000002 }, /* GL_POINT_BIT */
+   { 24552, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION */
+   { 24582, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_ARB */
+   { 24616, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_EXT */
+   { 24650, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_SGIS */
+   { 24685, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE */
+   { 24714, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_ARB */
+   { 24747, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_EXT */
+   { 24780, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_SGIS */
+   { 24814, 0x00000B11 }, /* GL_POINT_SIZE */
+   { 24828, 0x00000B13 }, /* GL_POINT_SIZE_GRANULARITY */
+   { 24854, 0x00008127 }, /* GL_POINT_SIZE_MAX */
+   { 24872, 0x00008127 }, /* GL_POINT_SIZE_MAX_ARB */
+   { 24894, 0x00008127 }, /* GL_POINT_SIZE_MAX_EXT */
+   { 24916, 0x00008127 }, /* GL_POINT_SIZE_MAX_SGIS */
+   { 24939, 0x00008126 }, /* GL_POINT_SIZE_MIN */
+   { 24957, 0x00008126 }, /* GL_POINT_SIZE_MIN_ARB */
+   { 24979, 0x00008126 }, /* GL_POINT_SIZE_MIN_EXT */
+   { 25001, 0x00008126 }, /* GL_POINT_SIZE_MIN_SGIS */
+   { 25024, 0x00000B12 }, /* GL_POINT_SIZE_RANGE */
+   { 25044, 0x00000B10 }, /* GL_POINT_SMOOTH */
+   { 25060, 0x00000C51 }, /* GL_POINT_SMOOTH_HINT */
+   { 25081, 0x00008861 }, /* GL_POINT_SPRITE */
+   { 25097, 0x00008861 }, /* GL_POINT_SPRITE_ARB */
+   { 25117, 0x00008CA0 }, /* GL_POINT_SPRITE_COORD_ORIGIN */
+   { 25146, 0x00008861 }, /* GL_POINT_SPRITE_NV */
+   { 25165, 0x00008863 }, /* GL_POINT_SPRITE_R_MODE_NV */
+   { 25191, 0x00000701 }, /* GL_POINT_TOKEN */
+   { 25206, 0x00000009 }, /* GL_POLYGON */
+   { 25217, 0x00000008 }, /* GL_POLYGON_BIT */
+   { 25232, 0x00000B40 }, /* GL_POLYGON_MODE */
+   { 25248, 0x00008039 }, /* GL_POLYGON_OFFSET_BIAS */
+   { 25271, 0x00008038 }, /* GL_POLYGON_OFFSET_FACTOR */
+   { 25296, 0x00008037 }, /* GL_POLYGON_OFFSET_FILL */
+   { 25319, 0x00002A02 }, /* GL_POLYGON_OFFSET_LINE */
+   { 25342, 0x00002A01 }, /* GL_POLYGON_OFFSET_POINT */
+   { 25366, 0x00002A00 }, /* GL_POLYGON_OFFSET_UNITS */
+   { 25390, 0x00000B41 }, /* GL_POLYGON_SMOOTH */
+   { 25408, 0x00000C53 }, /* GL_POLYGON_SMOOTH_HINT */
+   { 25431, 0x00000B42 }, /* GL_POLYGON_STIPPLE */
+   { 25450, 0x00000010 }, /* GL_POLYGON_STIPPLE_BIT */
+   { 25473, 0x00000703 }, /* GL_POLYGON_TOKEN */
+   { 25490, 0x00001203 }, /* GL_POSITION */
+   { 25502, 0x000080BB }, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS */
+   { 25534, 0x000080BB }, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI */
+   { 25570, 0x000080B7 }, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE */
+   { 25603, 0x000080B7 }, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI */
+   { 25640, 0x000080BA }, /* GL_POST_COLOR_MATRIX_BLUE_BIAS */
+   { 25671, 0x000080BA }, /* GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI */
+   { 25706, 0x000080B6 }, /* GL_POST_COLOR_MATRIX_BLUE_SCALE */
+   { 25738, 0x000080B6 }, /* GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI */
+   { 25774, 0x000080D2 }, /* GL_POST_COLOR_MATRIX_COLOR_TABLE */
+   { 25807, 0x000080B9 }, /* GL_POST_COLOR_MATRIX_GREEN_BIAS */
+   { 25839, 0x000080B9 }, /* GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI */
+   { 25875, 0x000080B5 }, /* GL_POST_COLOR_MATRIX_GREEN_SCALE */
+   { 25908, 0x000080B5 }, /* GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI */
+   { 25945, 0x000080B8 }, /* GL_POST_COLOR_MATRIX_RED_BIAS */
+   { 25975, 0x000080B8 }, /* GL_POST_COLOR_MATRIX_RED_BIAS_SGI */
+   { 26009, 0x000080B4 }, /* GL_POST_COLOR_MATRIX_RED_SCALE */
+   { 26040, 0x000080B4 }, /* GL_POST_COLOR_MATRIX_RED_SCALE_SGI */
+   { 26075, 0x00008023 }, /* GL_POST_CONVOLUTION_ALPHA_BIAS */
+   { 26106, 0x00008023 }, /* GL_POST_CONVOLUTION_ALPHA_BIAS_EXT */
+   { 26141, 0x0000801F }, /* GL_POST_CONVOLUTION_ALPHA_SCALE */
+   { 26173, 0x0000801F }, /* GL_POST_CONVOLUTION_ALPHA_SCALE_EXT */
+   { 26209, 0x00008022 }, /* GL_POST_CONVOLUTION_BLUE_BIAS */
+   { 26239, 0x00008022 }, /* GL_POST_CONVOLUTION_BLUE_BIAS_EXT */
+   { 26273, 0x0000801E }, /* GL_POST_CONVOLUTION_BLUE_SCALE */
+   { 26304, 0x0000801E }, /* GL_POST_CONVOLUTION_BLUE_SCALE_EXT */
+   { 26339, 0x000080D1 }, /* GL_POST_CONVOLUTION_COLOR_TABLE */
+   { 26371, 0x00008021 }, /* GL_POST_CONVOLUTION_GREEN_BIAS */
+   { 26402, 0x00008021 }, /* GL_POST_CONVOLUTION_GREEN_BIAS_EXT */
+   { 26437, 0x0000801D }, /* GL_POST_CONVOLUTION_GREEN_SCALE */
+   { 26469, 0x0000801D }, /* GL_POST_CONVOLUTION_GREEN_SCALE_EXT */
+   { 26505, 0x00008020 }, /* GL_POST_CONVOLUTION_RED_BIAS */
+   { 26534, 0x00008020 }, /* GL_POST_CONVOLUTION_RED_BIAS_EXT */
+   { 26567, 0x0000801C }, /* GL_POST_CONVOLUTION_RED_SCALE */
+   { 26597, 0x0000801C }, /* GL_POST_CONVOLUTION_RED_SCALE_EXT */
+   { 26631, 0x0000817B }, /* GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX */
+   { 26670, 0x00008179 }, /* GL_POST_TEXTURE_FILTER_BIAS_SGIX */
+   { 26703, 0x0000817C }, /* GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX */
+   { 26743, 0x0000817A }, /* GL_POST_TEXTURE_FILTER_SCALE_SGIX */
+   { 26777, 0x00008578 }, /* GL_PREVIOUS */
+   { 26789, 0x00008578 }, /* GL_PREVIOUS_ARB */
+   { 26805, 0x00008578 }, /* GL_PREVIOUS_EXT */
+   { 26821, 0x00008577 }, /* GL_PRIMARY_COLOR */
+   { 26838, 0x00008577 }, /* GL_PRIMARY_COLOR_ARB */
+   { 26859, 0x00008577 }, /* GL_PRIMARY_COLOR_EXT */
+   { 26880, 0x000088B0 }, /* GL_PROGRAM_ADDRESS_REGISTERS_ARB */
+   { 26913, 0x00008805 }, /* GL_PROGRAM_ALU_INSTRUCTIONS_ARB */
+   { 26945, 0x000088AC }, /* GL_PROGRAM_ATTRIBS_ARB */
+   { 26968, 0x00008677 }, /* GL_PROGRAM_BINDING_ARB */
+   { 26991, 0x0000864B }, /* GL_PROGRAM_ERROR_POSITION_ARB */
+   { 27021, 0x0000864B }, /* GL_PROGRAM_ERROR_POSITION_NV */
+   { 27050, 0x00008874 }, /* GL_PROGRAM_ERROR_STRING_ARB */
+   { 27078, 0x00008876 }, /* GL_PROGRAM_FORMAT_ARB */
+   { 27100, 0x00008875 }, /* GL_PROGRAM_FORMAT_ASCII_ARB */
+   { 27128, 0x000088A0 }, /* GL_PROGRAM_INSTRUCTIONS_ARB */
+   { 27156, 0x00008627 }, /* GL_PROGRAM_LENGTH_ARB */
+   { 27178, 0x00008627 }, /* GL_PROGRAM_LENGTH_NV */
+   { 27199, 0x000088B2 }, /* GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */
+   { 27239, 0x00008808 }, /* GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */
+   { 27278, 0x000088AE }, /* GL_PROGRAM_NATIVE_ATTRIBS_ARB */
+   { 27308, 0x000088A2 }, /* GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB */
+   { 27343, 0x000088AA }, /* GL_PROGRAM_NATIVE_PARAMETERS_ARB */
+   { 27376, 0x000088A6 }, /* GL_PROGRAM_NATIVE_TEMPORARIES_ARB */
+   { 27410, 0x0000880A }, /* GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */
+   { 27449, 0x00008809 }, /* GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */
+   { 27488, 0x00008B40 }, /* GL_PROGRAM_OBJECT_ARB */
+   { 27510, 0x000088A8 }, /* GL_PROGRAM_PARAMETERS_ARB */
+   { 27536, 0x00008644 }, /* GL_PROGRAM_PARAMETER_NV */
+   { 27560, 0x00008647 }, /* GL_PROGRAM_RESIDENT_NV */
+   { 27583, 0x00008628 }, /* GL_PROGRAM_STRING_ARB */
+   { 27605, 0x00008628 }, /* GL_PROGRAM_STRING_NV */
+   { 27626, 0x00008646 }, /* GL_PROGRAM_TARGET_NV */
+   { 27647, 0x000088A4 }, /* GL_PROGRAM_TEMPORARIES_ARB */
+   { 27674, 0x00008807 }, /* GL_PROGRAM_TEX_INDIRECTIONS_ARB */
+   { 27706, 0x00008806 }, /* GL_PROGRAM_TEX_INSTRUCTIONS_ARB */
+   { 27738, 0x000088B6 }, /* GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB */
+   { 27773, 0x00001701 }, /* GL_PROJECTION */
+   { 27787, 0x00000BA7 }, /* GL_PROJECTION_MATRIX */
+   { 27808, 0x00000BA4 }, /* GL_PROJECTION_STACK_DEPTH */
+   { 27834, 0x00008E4F }, /* GL_PROVOKING_VERTEX */
+   { 27854, 0x00008E4F }, /* GL_PROVOKING_VERTEX_EXT */
+   { 27878, 0x000080D3 }, /* GL_PROXY_COLOR_TABLE */
+   { 27899, 0x00008025 }, /* GL_PROXY_HISTOGRAM */
+   { 27918, 0x00008025 }, /* GL_PROXY_HISTOGRAM_EXT */
+   { 27941, 0x000080D5 }, /* GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE */
+   { 27980, 0x000080D4 }, /* GL_PROXY_POST_CONVOLUTION_COLOR_TABLE */
+   { 28018, 0x00008063 }, /* GL_PROXY_TEXTURE_1D */
+   { 28038, 0x00008C19 }, /* GL_PROXY_TEXTURE_1D_ARRAY_EXT */
+   { 28068, 0x00008063 }, /* GL_PROXY_TEXTURE_1D_EXT */
+   { 28092, 0x00008064 }, /* GL_PROXY_TEXTURE_2D */
+   { 28112, 0x00008C1B }, /* GL_PROXY_TEXTURE_2D_ARRAY_EXT */
+   { 28142, 0x00008064 }, /* GL_PROXY_TEXTURE_2D_EXT */
+   { 28166, 0x00008070 }, /* GL_PROXY_TEXTURE_3D */
+   { 28186, 0x000080BD }, /* GL_PROXY_TEXTURE_COLOR_TABLE_SGI */
+   { 28219, 0x0000851B }, /* GL_PROXY_TEXTURE_CUBE_MAP */
+   { 28245, 0x0000851B }, /* GL_PROXY_TEXTURE_CUBE_MAP_ARB */
+   { 28275, 0x000084F7 }, /* GL_PROXY_TEXTURE_RECTANGLE_ARB */
+   { 28306, 0x000084F7 }, /* GL_PROXY_TEXTURE_RECTANGLE_NV */
+   { 28336, 0x00002003 }, /* GL_Q */
+   { 28341, 0x00001209 }, /* GL_QUADRATIC_ATTENUATION */
+   { 28366, 0x00000007 }, /* GL_QUADS */
+   { 28375, 0x00008E4C }, /* GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */
+   { 28419, 0x00008E4C }, /* GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT */
+   { 28467, 0x00008614 }, /* GL_QUAD_MESH_SUN */
+   { 28484, 0x00000008 }, /* GL_QUAD_STRIP */
+   { 28498, 0x00008E16 }, /* GL_QUERY_BY_REGION_NO_WAIT_NV */
+   { 28528, 0x00008E15 }, /* GL_QUERY_BY_REGION_WAIT_NV */
+   { 28555, 0x00008864 }, /* GL_QUERY_COUNTER_BITS */
+   { 28577, 0x00008864 }, /* GL_QUERY_COUNTER_BITS_ARB */
+   { 28603, 0x00008E14 }, /* GL_QUERY_NO_WAIT_NV */
+   { 28623, 0x00008866 }, /* GL_QUERY_RESULT */
+   { 28639, 0x00008866 }, /* GL_QUERY_RESULT_ARB */
+   { 28659, 0x00008867 }, /* GL_QUERY_RESULT_AVAILABLE */
+   { 28685, 0x00008867 }, /* GL_QUERY_RESULT_AVAILABLE_ARB */
+   { 28715, 0x00008E13 }, /* GL_QUERY_WAIT_NV */
+   { 28732, 0x00002002 }, /* GL_R */
+   { 28737, 0x00002A10 }, /* GL_R3_G3_B2 */
+   { 28749, 0x00019262 }, /* GL_RASTER_POSITION_UNCLIPPED_IBM */
+   { 28782, 0x00000C02 }, /* GL_READ_BUFFER */
+   { 28797, 0x00008CA8 }, /* GL_READ_FRAMEBUFFER */
+   { 28817, 0x00008CAA }, /* GL_READ_FRAMEBUFFER_BINDING */
+   { 28845, 0x00008CAA }, /* GL_READ_FRAMEBUFFER_BINDING_EXT */
+   { 28877, 0x00008CA8 }, /* GL_READ_FRAMEBUFFER_EXT */
+   { 28901, 0x000088B8 }, /* GL_READ_ONLY */
+   { 28914, 0x000088B8 }, /* GL_READ_ONLY_ARB */
+   { 28931, 0x000088BA }, /* GL_READ_WRITE */
+   { 28945, 0x000088BA }, /* GL_READ_WRITE_ARB */
+   { 28963, 0x00001903 }, /* GL_RED */
+   { 28970, 0x00008016 }, /* GL_REDUCE */
+   { 28980, 0x00008016 }, /* GL_REDUCE_EXT */
+   { 28994, 0x00000D15 }, /* GL_RED_BIAS */
+   { 29006, 0x00000D52 }, /* GL_RED_BITS */
+   { 29018, 0x00000D14 }, /* GL_RED_SCALE */
+   { 29031, 0x00008512 }, /* GL_REFLECTION_MAP */
+   { 29049, 0x00008512 }, /* GL_REFLECTION_MAP_ARB */
+   { 29071, 0x00008512 }, /* GL_REFLECTION_MAP_NV */
+   { 29092, 0x00001C00 }, /* GL_RENDER */
+   { 29102, 0x00008D41 }, /* GL_RENDERBUFFER */
+   { 29118, 0x00008D53 }, /* GL_RENDERBUFFER_ALPHA_SIZE */
+   { 29145, 0x00008CA7 }, /* GL_RENDERBUFFER_BINDING */
+   { 29169, 0x00008CA7 }, /* GL_RENDERBUFFER_BINDING_EXT */
+   { 29197, 0x00008D52 }, /* GL_RENDERBUFFER_BLUE_SIZE */
+   { 29223, 0x00008D54 }, /* GL_RENDERBUFFER_DEPTH_SIZE */
+   { 29250, 0x00008D41 }, /* GL_RENDERBUFFER_EXT */
+   { 29270, 0x00008D51 }, /* GL_RENDERBUFFER_GREEN_SIZE */
+   { 29297, 0x00008D43 }, /* GL_RENDERBUFFER_HEIGHT */
+   { 29320, 0x00008D43 }, /* GL_RENDERBUFFER_HEIGHT_EXT */
+   { 29347, 0x00008D44 }, /* GL_RENDERBUFFER_INTERNAL_FORMAT */
+   { 29379, 0x00008D44 }, /* GL_RENDERBUFFER_INTERNAL_FORMAT_EXT */
+   { 29415, 0x00008D50 }, /* GL_RENDERBUFFER_RED_SIZE */
+   { 29440, 0x00008CAB }, /* GL_RENDERBUFFER_SAMPLES */
+   { 29464, 0x00008CAB }, /* GL_RENDERBUFFER_SAMPLES_EXT */
+   { 29492, 0x00008D55 }, /* GL_RENDERBUFFER_STENCIL_SIZE */
+   { 29521, 0x00008D42 }, /* GL_RENDERBUFFER_WIDTH */
+   { 29543, 0x00008D42 }, /* GL_RENDERBUFFER_WIDTH_EXT */
+   { 29569, 0x00001F01 }, /* GL_RENDERER */
+   { 29581, 0x00000C40 }, /* GL_RENDER_MODE */
+   { 29596, 0x00002901 }, /* GL_REPEAT */
+   { 29606, 0x00001E01 }, /* GL_REPLACE */
+   { 29617, 0x00008062 }, /* GL_REPLACE_EXT */
+   { 29632, 0x00008153 }, /* GL_REPLICATE_BORDER_HP */
+   { 29655, 0x0000803A }, /* GL_RESCALE_NORMAL */
+   { 29673, 0x0000803A }, /* GL_RESCALE_NORMAL_EXT */
+   { 29695, 0x00000102 }, /* GL_RETURN */
+   { 29705, 0x00001907 }, /* GL_RGB */
+   { 29712, 0x00008052 }, /* GL_RGB10 */
+   { 29721, 0x00008059 }, /* GL_RGB10_A2 */
+   { 29733, 0x00008059 }, /* GL_RGB10_A2_EXT */
+   { 29749, 0x00008052 }, /* GL_RGB10_EXT */
+   { 29762, 0x00008053 }, /* GL_RGB12 */
+   { 29771, 0x00008053 }, /* GL_RGB12_EXT */
+   { 29784, 0x00008054 }, /* GL_RGB16 */
+   { 29793, 0x00008054 }, /* GL_RGB16_EXT */
+   { 29806, 0x0000804E }, /* GL_RGB2_EXT */
+   { 29818, 0x0000804F }, /* GL_RGB4 */
+   { 29826, 0x0000804F }, /* GL_RGB4_EXT */
+   { 29838, 0x000083A1 }, /* GL_RGB4_S3TC */
+   { 29851, 0x00008050 }, /* GL_RGB5 */
+   { 29859, 0x00008057 }, /* GL_RGB5_A1 */
+   { 29870, 0x00008057 }, /* GL_RGB5_A1_EXT */
+   { 29885, 0x00008050 }, /* GL_RGB5_EXT */
+   { 29897, 0x00008051 }, /* GL_RGB8 */
+   { 29905, 0x00008051 }, /* GL_RGB8_EXT */
+   { 29917, 0x00001908 }, /* GL_RGBA */
+   { 29925, 0x0000805A }, /* GL_RGBA12 */
+   { 29935, 0x0000805A }, /* GL_RGBA12_EXT */
+   { 29949, 0x0000805B }, /* GL_RGBA16 */
+   { 29959, 0x0000805B }, /* GL_RGBA16_EXT */
+   { 29973, 0x00008055 }, /* GL_RGBA2 */
+   { 29982, 0x00008055 }, /* GL_RGBA2_EXT */
+   { 29995, 0x00008056 }, /* GL_RGBA4 */
+   { 30004, 0x000083A5 }, /* GL_RGBA4_DXT5_S3TC */
+   { 30023, 0x00008056 }, /* GL_RGBA4_EXT */
+   { 30036, 0x000083A3 }, /* GL_RGBA4_S3TC */
+   { 30050, 0x00008058 }, /* GL_RGBA8 */
+   { 30059, 0x00008058 }, /* GL_RGBA8_EXT */
+   { 30072, 0x00008F97 }, /* GL_RGBA8_SNORM */
+   { 30087, 0x000083A4 }, /* GL_RGBA_DXT5_S3TC */
+   { 30105, 0x00000C31 }, /* GL_RGBA_MODE */
+   { 30118, 0x000083A2 }, /* GL_RGBA_S3TC */
+   { 30131, 0x00008F93 }, /* GL_RGBA_SNORM */
+   { 30145, 0x000083A0 }, /* GL_RGB_S3TC */
+   { 30157, 0x00008573 }, /* GL_RGB_SCALE */
+   { 30170, 0x00008573 }, /* GL_RGB_SCALE_ARB */
+   { 30187, 0x00008573 }, /* GL_RGB_SCALE_EXT */
+   { 30204, 0x00000407 }, /* GL_RIGHT */
+   { 30213, 0x00002000 }, /* GL_S */
+   { 30218, 0x00008B5D }, /* GL_SAMPLER_1D */
+   { 30232, 0x00008B61 }, /* GL_SAMPLER_1D_SHADOW */
+   { 30253, 0x00008B5E }, /* GL_SAMPLER_2D */
+   { 30267, 0x00008B62 }, /* GL_SAMPLER_2D_SHADOW */
+   { 30288, 0x00008B5F }, /* GL_SAMPLER_3D */
+   { 30302, 0x00008B60 }, /* GL_SAMPLER_CUBE */
+   { 30318, 0x000080A9 }, /* GL_SAMPLES */
+   { 30329, 0x000086B4 }, /* GL_SAMPLES_3DFX */
+   { 30345, 0x000080A9 }, /* GL_SAMPLES_ARB */
+   { 30360, 0x00008914 }, /* GL_SAMPLES_PASSED */
+   { 30378, 0x00008914 }, /* GL_SAMPLES_PASSED_ARB */
+   { 30400, 0x0000809E }, /* GL_SAMPLE_ALPHA_TO_COVERAGE */
+   { 30428, 0x0000809E }, /* GL_SAMPLE_ALPHA_TO_COVERAGE_ARB */
+   { 30460, 0x0000809F }, /* GL_SAMPLE_ALPHA_TO_ONE */
+   { 30483, 0x0000809F }, /* GL_SAMPLE_ALPHA_TO_ONE_ARB */
+   { 30510, 0x000080A8 }, /* GL_SAMPLE_BUFFERS */
+   { 30528, 0x000086B3 }, /* GL_SAMPLE_BUFFERS_3DFX */
+   { 30551, 0x000080A8 }, /* GL_SAMPLE_BUFFERS_ARB */
+   { 30573, 0x000080A0 }, /* GL_SAMPLE_COVERAGE */
+   { 30592, 0x000080A0 }, /* GL_SAMPLE_COVERAGE_ARB */
+   { 30615, 0x000080AB }, /* GL_SAMPLE_COVERAGE_INVERT */
+   { 30641, 0x000080AB }, /* GL_SAMPLE_COVERAGE_INVERT_ARB */
+   { 30671, 0x000080AA }, /* GL_SAMPLE_COVERAGE_VALUE */
+   { 30696, 0x000080AA }, /* GL_SAMPLE_COVERAGE_VALUE_ARB */
+   { 30725, 0x00080000 }, /* GL_SCISSOR_BIT */
+   { 30740, 0x00000C10 }, /* GL_SCISSOR_BOX */
+   { 30755, 0x00000C11 }, /* GL_SCISSOR_TEST */
+   { 30771, 0x0000845E }, /* GL_SECONDARY_COLOR_ARRAY */
+   { 30796, 0x0000889C }, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING */
+   { 30836, 0x0000889C }, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB */
+   { 30880, 0x0000845D }, /* GL_SECONDARY_COLOR_ARRAY_POINTER */
+   { 30913, 0x0000845A }, /* GL_SECONDARY_COLOR_ARRAY_SIZE */
+   { 30943, 0x0000845C }, /* GL_SECONDARY_COLOR_ARRAY_STRIDE */
+   { 30975, 0x0000845B }, /* GL_SECONDARY_COLOR_ARRAY_TYPE */
+   { 31005, 0x00001C02 }, /* GL_SELECT */
+   { 31015, 0x00000DF3 }, /* GL_SELECTION_BUFFER_POINTER */
+   { 31043, 0x00000DF4 }, /* GL_SELECTION_BUFFER_SIZE */
+   { 31068, 0x00008012 }, /* GL_SEPARABLE_2D */
+   { 31084, 0x000081FA }, /* GL_SEPARATE_SPECULAR_COLOR */
+   { 31111, 0x000081FA }, /* GL_SEPARATE_SPECULAR_COLOR_EXT */
+   { 31142, 0x0000150F }, /* GL_SET */
+   { 31149, 0x00008B48 }, /* GL_SHADER_OBJECT_ARB */
+   { 31170, 0x00008B88 }, /* GL_SHADER_SOURCE_LENGTH */
+   { 31194, 0x00008B4F }, /* GL_SHADER_TYPE */
+   { 31209, 0x00000B54 }, /* GL_SHADE_MODEL */
+   { 31224, 0x00008B8C }, /* GL_SHADING_LANGUAGE_VERSION */
+   { 31252, 0x000080BF }, /* GL_SHADOW_AMBIENT_SGIX */
+   { 31275, 0x000081FB }, /* GL_SHARED_TEXTURE_PALETTE_EXT */
+   { 31305, 0x00001601 }, /* GL_SHININESS */
+   { 31318, 0x00001402 }, /* GL_SHORT */
+   { 31327, 0x00009119 }, /* GL_SIGNALED */
+   { 31339, 0x00008F9C }, /* GL_SIGNED_NORMALIZED */
+   { 31360, 0x000081F9 }, /* GL_SINGLE_COLOR */
+   { 31376, 0x000081F9 }, /* GL_SINGLE_COLOR_EXT */
+   { 31396, 0x000085CC }, /* GL_SLICE_ACCUM_SUN */
+   { 31415, 0x00008C46 }, /* GL_SLUMINANCE */
+   { 31429, 0x00008C47 }, /* GL_SLUMINANCE8 */
+   { 31444, 0x00008C45 }, /* GL_SLUMINANCE8_ALPHA8 */
+   { 31466, 0x00008C44 }, /* GL_SLUMINANCE_ALPHA */
+   { 31486, 0x00001D01 }, /* GL_SMOOTH */
+   { 31496, 0x00000B23 }, /* GL_SMOOTH_LINE_WIDTH_GRANULARITY */
+   { 31529, 0x00000B22 }, /* GL_SMOOTH_LINE_WIDTH_RANGE */
+   { 31556, 0x00000B13 }, /* GL_SMOOTH_POINT_SIZE_GRANULARITY */
+   { 31589, 0x00000B12 }, /* GL_SMOOTH_POINT_SIZE_RANGE */
+   { 31616, 0x00008588 }, /* GL_SOURCE0_ALPHA */
+   { 31633, 0x00008588 }, /* GL_SOURCE0_ALPHA_ARB */
+   { 31654, 0x00008588 }, /* GL_SOURCE0_ALPHA_EXT */
+   { 31675, 0x00008580 }, /* GL_SOURCE0_RGB */
+   { 31690, 0x00008580 }, /* GL_SOURCE0_RGB_ARB */
+   { 31709, 0x00008580 }, /* GL_SOURCE0_RGB_EXT */
+   { 31728, 0x00008589 }, /* GL_SOURCE1_ALPHA */
+   { 31745, 0x00008589 }, /* GL_SOURCE1_ALPHA_ARB */
+   { 31766, 0x00008589 }, /* GL_SOURCE1_ALPHA_EXT */
+   { 31787, 0x00008581 }, /* GL_SOURCE1_RGB */
+   { 31802, 0x00008581 }, /* GL_SOURCE1_RGB_ARB */
+   { 31821, 0x00008581 }, /* GL_SOURCE1_RGB_EXT */
+   { 31840, 0x0000858A }, /* GL_SOURCE2_ALPHA */
+   { 31857, 0x0000858A }, /* GL_SOURCE2_ALPHA_ARB */
+   { 31878, 0x0000858A }, /* GL_SOURCE2_ALPHA_EXT */
+   { 31899, 0x00008582 }, /* GL_SOURCE2_RGB */
+   { 31914, 0x00008582 }, /* GL_SOURCE2_RGB_ARB */
+   { 31933, 0x00008582 }, /* GL_SOURCE2_RGB_EXT */
+   { 31952, 0x0000858B }, /* GL_SOURCE3_ALPHA_NV */
+   { 31972, 0x00008583 }, /* GL_SOURCE3_RGB_NV */
+   { 31990, 0x00001202 }, /* GL_SPECULAR */
+   { 32002, 0x00002402 }, /* GL_SPHERE_MAP */
+   { 32016, 0x00001206 }, /* GL_SPOT_CUTOFF */
+   { 32031, 0x00001204 }, /* GL_SPOT_DIRECTION */
+   { 32049, 0x00001205 }, /* GL_SPOT_EXPONENT */
+   { 32066, 0x00008588 }, /* GL_SRC0_ALPHA */
+   { 32080, 0x00008580 }, /* GL_SRC0_RGB */
+   { 32092, 0x00008589 }, /* GL_SRC1_ALPHA */
+   { 32106, 0x00008581 }, /* GL_SRC1_RGB */
+   { 32118, 0x0000858A }, /* GL_SRC2_ALPHA */
+   { 32132, 0x00008582 }, /* GL_SRC2_RGB */
+   { 32144, 0x00000302 }, /* GL_SRC_ALPHA */
+   { 32157, 0x00000308 }, /* GL_SRC_ALPHA_SATURATE */
+   { 32179, 0x00000300 }, /* GL_SRC_COLOR */
+   { 32192, 0x00008C40 }, /* GL_SRGB */
+   { 32200, 0x00008C41 }, /* GL_SRGB8 */
+   { 32209, 0x00008C43 }, /* GL_SRGB8_ALPHA8 */
+   { 32225, 0x00008C42 }, /* GL_SRGB_ALPHA */
+   { 32239, 0x00000503 }, /* GL_STACK_OVERFLOW */
+   { 32257, 0x00000504 }, /* GL_STACK_UNDERFLOW */
+   { 32276, 0x000088E6 }, /* GL_STATIC_COPY */
+   { 32291, 0x000088E6 }, /* GL_STATIC_COPY_ARB */
+   { 32310, 0x000088E4 }, /* GL_STATIC_DRAW */
+   { 32325, 0x000088E4 }, /* GL_STATIC_DRAW_ARB */
+   { 32344, 0x000088E5 }, /* GL_STATIC_READ */
+   { 32359, 0x000088E5 }, /* GL_STATIC_READ_ARB */
+   { 32378, 0x00001802 }, /* GL_STENCIL */
+   { 32389, 0x00008D20 }, /* GL_STENCIL_ATTACHMENT */
+   { 32411, 0x00008D20 }, /* GL_STENCIL_ATTACHMENT_EXT */
+   { 32437, 0x00008801 }, /* GL_STENCIL_BACK_FAIL */
+   { 32458, 0x00008801 }, /* GL_STENCIL_BACK_FAIL_ATI */
+   { 32483, 0x00008800 }, /* GL_STENCIL_BACK_FUNC */
+   { 32504, 0x00008800 }, /* GL_STENCIL_BACK_FUNC_ATI */
+   { 32529, 0x00008802 }, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL */
+   { 32561, 0x00008802 }, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI */
+   { 32597, 0x00008803 }, /* GL_STENCIL_BACK_PASS_DEPTH_PASS */
+   { 32629, 0x00008803 }, /* GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI */
+   { 32665, 0x00008CA3 }, /* GL_STENCIL_BACK_REF */
+   { 32685, 0x00008CA4 }, /* GL_STENCIL_BACK_VALUE_MASK */
+   { 32712, 0x00008CA5 }, /* GL_STENCIL_BACK_WRITEMASK */
+   { 32738, 0x00000D57 }, /* GL_STENCIL_BITS */
+   { 32754, 0x00000400 }, /* GL_STENCIL_BUFFER_BIT */
+   { 32776, 0x00000B91 }, /* GL_STENCIL_CLEAR_VALUE */
+   { 32799, 0x00000B94 }, /* GL_STENCIL_FAIL */
+   { 32815, 0x00000B92 }, /* GL_STENCIL_FUNC */
+   { 32831, 0x00001901 }, /* GL_STENCIL_INDEX */
+   { 32848, 0x00008D46 }, /* GL_STENCIL_INDEX1 */
+   { 32866, 0x00008D49 }, /* GL_STENCIL_INDEX16 */
+   { 32885, 0x00008D49 }, /* GL_STENCIL_INDEX16_EXT */
+   { 32908, 0x00008D46 }, /* GL_STENCIL_INDEX1_EXT */
+   { 32930, 0x00008D47 }, /* GL_STENCIL_INDEX4 */
+   { 32948, 0x00008D47 }, /* GL_STENCIL_INDEX4_EXT */
+   { 32970, 0x00008D48 }, /* GL_STENCIL_INDEX8 */
+   { 32988, 0x00008D48 }, /* GL_STENCIL_INDEX8_EXT */
+   { 33010, 0x00008D45 }, /* GL_STENCIL_INDEX_EXT */
+   { 33031, 0x00000B95 }, /* GL_STENCIL_PASS_DEPTH_FAIL */
+   { 33058, 0x00000B96 }, /* GL_STENCIL_PASS_DEPTH_PASS */
+   { 33085, 0x00000B97 }, /* GL_STENCIL_REF */
+   { 33100, 0x00000B90 }, /* GL_STENCIL_TEST */
+   { 33116, 0x00008910 }, /* GL_STENCIL_TEST_TWO_SIDE_EXT */
+   { 33145, 0x00000B93 }, /* GL_STENCIL_VALUE_MASK */
+   { 33167, 0x00000B98 }, /* GL_STENCIL_WRITEMASK */
+   { 33188, 0x00000C33 }, /* GL_STEREO */
+   { 33198, 0x000085BE }, /* GL_STORAGE_CACHED_APPLE */
+   { 33222, 0x000085BD }, /* GL_STORAGE_PRIVATE_APPLE */
+   { 33247, 0x000085BF }, /* GL_STORAGE_SHARED_APPLE */
+   { 33271, 0x000088E2 }, /* GL_STREAM_COPY */
+   { 33286, 0x000088E2 }, /* GL_STREAM_COPY_ARB */
+   { 33305, 0x000088E0 }, /* GL_STREAM_DRAW */
+   { 33320, 0x000088E0 }, /* GL_STREAM_DRAW_ARB */
+   { 33339, 0x000088E1 }, /* GL_STREAM_READ */
+   { 33354, 0x000088E1 }, /* GL_STREAM_READ_ARB */
+   { 33373, 0x00000D50 }, /* GL_SUBPIXEL_BITS */
+   { 33390, 0x000084E7 }, /* GL_SUBTRACT */
+   { 33402, 0x000084E7 }, /* GL_SUBTRACT_ARB */
+   { 33418, 0x00009113 }, /* GL_SYNC_CONDITION */
+   { 33436, 0x00009116 }, /* GL_SYNC_FENCE */
+   { 33450, 0x00009115 }, /* GL_SYNC_FLAGS */
+   { 33464, 0x00000001 }, /* GL_SYNC_FLUSH_COMMANDS_BIT */
+   { 33491, 0x00009117 }, /* GL_SYNC_GPU_COMMANDS_COMPLETE */
+   { 33521, 0x00009114 }, /* GL_SYNC_STATUS */
+   { 33536, 0x00002001 }, /* GL_T */
+   { 33541, 0x00002A2A }, /* GL_T2F_C3F_V3F */
+   { 33556, 0x00002A2C }, /* GL_T2F_C4F_N3F_V3F */
+   { 33575, 0x00002A29 }, /* GL_T2F_C4UB_V3F */
+   { 33591, 0x00002A2B }, /* GL_T2F_N3F_V3F */
+   { 33606, 0x00002A27 }, /* GL_T2F_V3F */
+   { 33617, 0x00002A2D }, /* GL_T4F_C4F_N3F_V4F */
+   { 33636, 0x00002A28 }, /* GL_T4F_V4F */
+   { 33647, 0x00008031 }, /* GL_TABLE_TOO_LARGE_EXT */
+   { 33670, 0x00001702 }, /* GL_TEXTURE */
+   { 33681, 0x000084C0 }, /* GL_TEXTURE0 */
+   { 33693, 0x000084C0 }, /* GL_TEXTURE0_ARB */
+   { 33709, 0x000084C1 }, /* GL_TEXTURE1 */
+   { 33721, 0x000084CA }, /* GL_TEXTURE10 */
+   { 33734, 0x000084CA }, /* GL_TEXTURE10_ARB */
+   { 33751, 0x000084CB }, /* GL_TEXTURE11 */
+   { 33764, 0x000084CB }, /* GL_TEXTURE11_ARB */
+   { 33781, 0x000084CC }, /* GL_TEXTURE12 */
+   { 33794, 0x000084CC }, /* GL_TEXTURE12_ARB */
+   { 33811, 0x000084CD }, /* GL_TEXTURE13 */
+   { 33824, 0x000084CD }, /* GL_TEXTURE13_ARB */
+   { 33841, 0x000084CE }, /* GL_TEXTURE14 */
+   { 33854, 0x000084CE }, /* GL_TEXTURE14_ARB */
+   { 33871, 0x000084CF }, /* GL_TEXTURE15 */
+   { 33884, 0x000084CF }, /* GL_TEXTURE15_ARB */
+   { 33901, 0x000084D0 }, /* GL_TEXTURE16 */
+   { 33914, 0x000084D0 }, /* GL_TEXTURE16_ARB */
+   { 33931, 0x000084D1 }, /* GL_TEXTURE17 */
+   { 33944, 0x000084D1 }, /* GL_TEXTURE17_ARB */
+   { 33961, 0x000084D2 }, /* GL_TEXTURE18 */
+   { 33974, 0x000084D2 }, /* GL_TEXTURE18_ARB */
+   { 33991, 0x000084D3 }, /* GL_TEXTURE19 */
+   { 34004, 0x000084D3 }, /* GL_TEXTURE19_ARB */
+   { 34021, 0x000084C1 }, /* GL_TEXTURE1_ARB */
+   { 34037, 0x000084C2 }, /* GL_TEXTURE2 */
+   { 34049, 0x000084D4 }, /* GL_TEXTURE20 */
+   { 34062, 0x000084D4 }, /* GL_TEXTURE20_ARB */
+   { 34079, 0x000084D5 }, /* GL_TEXTURE21 */
+   { 34092, 0x000084D5 }, /* GL_TEXTURE21_ARB */
+   { 34109, 0x000084D6 }, /* GL_TEXTURE22 */
+   { 34122, 0x000084D6 }, /* GL_TEXTURE22_ARB */
+   { 34139, 0x000084D7 }, /* GL_TEXTURE23 */
+   { 34152, 0x000084D7 }, /* GL_TEXTURE23_ARB */
+   { 34169, 0x000084D8 }, /* GL_TEXTURE24 */
+   { 34182, 0x000084D8 }, /* GL_TEXTURE24_ARB */
+   { 34199, 0x000084D9 }, /* GL_TEXTURE25 */
+   { 34212, 0x000084D9 }, /* GL_TEXTURE25_ARB */
+   { 34229, 0x000084DA }, /* GL_TEXTURE26 */
+   { 34242, 0x000084DA }, /* GL_TEXTURE26_ARB */
+   { 34259, 0x000084DB }, /* GL_TEXTURE27 */
+   { 34272, 0x000084DB }, /* GL_TEXTURE27_ARB */
+   { 34289, 0x000084DC }, /* GL_TEXTURE28 */
+   { 34302, 0x000084DC }, /* GL_TEXTURE28_ARB */
+   { 34319, 0x000084DD }, /* GL_TEXTURE29 */
+   { 34332, 0x000084DD }, /* GL_TEXTURE29_ARB */
+   { 34349, 0x000084C2 }, /* GL_TEXTURE2_ARB */
+   { 34365, 0x000084C3 }, /* GL_TEXTURE3 */
+   { 34377, 0x000084DE }, /* GL_TEXTURE30 */
+   { 34390, 0x000084DE }, /* GL_TEXTURE30_ARB */
+   { 34407, 0x000084DF }, /* GL_TEXTURE31 */
+   { 34420, 0x000084DF }, /* GL_TEXTURE31_ARB */
+   { 34437, 0x000084C3 }, /* GL_TEXTURE3_ARB */
+   { 34453, 0x000084C4 }, /* GL_TEXTURE4 */
+   { 34465, 0x000084C4 }, /* GL_TEXTURE4_ARB */
+   { 34481, 0x000084C5 }, /* GL_TEXTURE5 */
+   { 34493, 0x000084C5 }, /* GL_TEXTURE5_ARB */
+   { 34509, 0x000084C6 }, /* GL_TEXTURE6 */
+   { 34521, 0x000084C6 }, /* GL_TEXTURE6_ARB */
+   { 34537, 0x000084C7 }, /* GL_TEXTURE7 */
+   { 34549, 0x000084C7 }, /* GL_TEXTURE7_ARB */
+   { 34565, 0x000084C8 }, /* GL_TEXTURE8 */
+   { 34577, 0x000084C8 }, /* GL_TEXTURE8_ARB */
+   { 34593, 0x000084C9 }, /* GL_TEXTURE9 */
+   { 34605, 0x000084C9 }, /* GL_TEXTURE9_ARB */
+   { 34621, 0x00000DE0 }, /* GL_TEXTURE_1D */
+   { 34635, 0x00008C18 }, /* GL_TEXTURE_1D_ARRAY_EXT */
+   { 34659, 0x00000DE1 }, /* GL_TEXTURE_2D */
+   { 34673, 0x00008C1A }, /* GL_TEXTURE_2D_ARRAY_EXT */
+   { 34697, 0x0000806F }, /* GL_TEXTURE_3D */
+   { 34711, 0x0000805F }, /* GL_TEXTURE_ALPHA_SIZE */
+   { 34733, 0x0000805F }, /* GL_TEXTURE_ALPHA_SIZE_EXT */
+   { 34759, 0x0000813C }, /* GL_TEXTURE_BASE_LEVEL */
+   { 34781, 0x00008068 }, /* GL_TEXTURE_BINDING_1D */
+   { 34803, 0x00008C1C }, /* GL_TEXTURE_BINDING_1D_ARRAY_EXT */
+   { 34835, 0x00008069 }, /* GL_TEXTURE_BINDING_2D */
+   { 34857, 0x00008C1D }, /* GL_TEXTURE_BINDING_2D_ARRAY_EXT */
+   { 34889, 0x0000806A }, /* GL_TEXTURE_BINDING_3D */
+   { 34911, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP */
+   { 34939, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP_ARB */
+   { 34971, 0x000084F6 }, /* GL_TEXTURE_BINDING_RECTANGLE_ARB */
+   { 35004, 0x000084F6 }, /* GL_TEXTURE_BINDING_RECTANGLE_NV */
+   { 35036, 0x00040000 }, /* GL_TEXTURE_BIT */
+   { 35051, 0x0000805E }, /* GL_TEXTURE_BLUE_SIZE */
+   { 35072, 0x0000805E }, /* GL_TEXTURE_BLUE_SIZE_EXT */
+   { 35097, 0x00001005 }, /* GL_TEXTURE_BORDER */
+   { 35115, 0x00001004 }, /* GL_TEXTURE_BORDER_COLOR */
+   { 35139, 0x00008171 }, /* GL_TEXTURE_CLIPMAP_CENTER_SGIX */
+   { 35170, 0x00008176 }, /* GL_TEXTURE_CLIPMAP_DEPTH_SGIX */
+   { 35200, 0x00008172 }, /* GL_TEXTURE_CLIPMAP_FRAME_SGIX */
+   { 35230, 0x00008175 }, /* GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX */
+   { 35265, 0x00008173 }, /* GL_TEXTURE_CLIPMAP_OFFSET_SGIX */
+   { 35296, 0x00008174 }, /* GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX */
+   { 35334, 0x000080BC }, /* GL_TEXTURE_COLOR_TABLE_SGI */
+   { 35361, 0x000081EF }, /* GL_TEXTURE_COLOR_WRITEMASK_SGIS */
+   { 35393, 0x000080BF }, /* GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
+   { 35427, 0x0000884D }, /* GL_TEXTURE_COMPARE_FUNC */
+   { 35451, 0x0000884D }, /* GL_TEXTURE_COMPARE_FUNC_ARB */
+   { 35479, 0x0000884C }, /* GL_TEXTURE_COMPARE_MODE */
+   { 35503, 0x0000884C }, /* GL_TEXTURE_COMPARE_MODE_ARB */
+   { 35531, 0x0000819B }, /* GL_TEXTURE_COMPARE_OPERATOR_SGIX */
+   { 35564, 0x0000819A }, /* GL_TEXTURE_COMPARE_SGIX */
+   { 35588, 0x00001003 }, /* GL_TEXTURE_COMPONENTS */
+   { 35610, 0x000086A1 }, /* GL_TEXTURE_COMPRESSED */
+   { 35632, 0x000086A1 }, /* GL_TEXTURE_COMPRESSED_ARB */
+   { 35658, 0x000086A3 }, /* GL_TEXTURE_COMPRESSED_FORMATS_ARB */
+   { 35692, 0x000086A0 }, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE */
+   { 35725, 0x000086A0 }, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB */
+   { 35762, 0x000084EF }, /* GL_TEXTURE_COMPRESSION_HINT */
+   { 35790, 0x000084EF }, /* GL_TEXTURE_COMPRESSION_HINT_ARB */
+   { 35822, 0x00008078 }, /* GL_TEXTURE_COORD_ARRAY */
+   { 35845, 0x0000889A }, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING */
+   { 35883, 0x0000889A }, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB */
+   { 35925, 0x00008092 }, /* GL_TEXTURE_COORD_ARRAY_POINTER */
+   { 35956, 0x00008088 }, /* GL_TEXTURE_COORD_ARRAY_SIZE */
+   { 35984, 0x0000808A }, /* GL_TEXTURE_COORD_ARRAY_STRIDE */
+   { 36014, 0x00008089 }, /* GL_TEXTURE_COORD_ARRAY_TYPE */
+   { 36042, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP */
+   { 36062, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP_ARB */
+   { 36086, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X */
+   { 36117, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB */
+   { 36152, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y */
+   { 36183, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB */
+   { 36218, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z */
+   { 36249, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB */
+   { 36284, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X */
+   { 36315, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB */
+   { 36350, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y */
+   { 36381, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB */
+   { 36416, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z */
+   { 36447, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB */
+   { 36482, 0x000088F4 }, /* GL_TEXTURE_CUBE_MAP_SEAMLESS */
+   { 36511, 0x00008071 }, /* GL_TEXTURE_DEPTH */
+   { 36528, 0x0000884A }, /* GL_TEXTURE_DEPTH_SIZE */
+   { 36550, 0x0000884A }, /* GL_TEXTURE_DEPTH_SIZE_ARB */
+   { 36576, 0x00002300 }, /* GL_TEXTURE_ENV */
+   { 36591, 0x00002201 }, /* GL_TEXTURE_ENV_COLOR */
+   { 36612, 0x00002200 }, /* GL_TEXTURE_ENV_MODE */
+   { 36632, 0x00008500 }, /* GL_TEXTURE_FILTER_CONTROL */
+   { 36658, 0x00002500 }, /* GL_TEXTURE_GEN_MODE */
+   { 36678, 0x00000C63 }, /* GL_TEXTURE_GEN_Q */
+   { 36695, 0x00000C62 }, /* GL_TEXTURE_GEN_R */
+   { 36712, 0x00000C60 }, /* GL_TEXTURE_GEN_S */
+   { 36729, 0x00000C61 }, /* GL_TEXTURE_GEN_T */
+   { 36746, 0x0000819D }, /* GL_TEXTURE_GEQUAL_R_SGIX */
+   { 36771, 0x0000805D }, /* GL_TEXTURE_GREEN_SIZE */
+   { 36793, 0x0000805D }, /* GL_TEXTURE_GREEN_SIZE_EXT */
+   { 36819, 0x00001001 }, /* GL_TEXTURE_HEIGHT */
+   { 36837, 0x000080ED }, /* GL_TEXTURE_INDEX_SIZE_EXT */
+   { 36863, 0x00008061 }, /* GL_TEXTURE_INTENSITY_SIZE */
+   { 36889, 0x00008061 }, /* GL_TEXTURE_INTENSITY_SIZE_EXT */
+   { 36919, 0x00001003 }, /* GL_TEXTURE_INTERNAL_FORMAT */
+   { 36946, 0x0000819C }, /* GL_TEXTURE_LEQUAL_R_SGIX */
+   { 36971, 0x00008501 }, /* GL_TEXTURE_LOD_BIAS */
+   { 36991, 0x00008501 }, /* GL_TEXTURE_LOD_BIAS_EXT */
+   { 37015, 0x00008190 }, /* GL_TEXTURE_LOD_BIAS_R_SGIX */
+   { 37042, 0x0000818E }, /* GL_TEXTURE_LOD_BIAS_S_SGIX */
+   { 37069, 0x0000818F }, /* GL_TEXTURE_LOD_BIAS_T_SGIX */
+   { 37096, 0x00008060 }, /* GL_TEXTURE_LUMINANCE_SIZE */
+   { 37122, 0x00008060 }, /* GL_TEXTURE_LUMINANCE_SIZE_EXT */
+   { 37152, 0x00002800 }, /* GL_TEXTURE_MAG_FILTER */
+   { 37174, 0x00000BA8 }, /* GL_TEXTURE_MATRIX */
+   { 37192, 0x000084FE }, /* GL_TEXTURE_MAX_ANISOTROPY_EXT */
+   { 37222, 0x0000836B }, /* GL_TEXTURE_MAX_CLAMP_R_SGIX */
+   { 37250, 0x00008369 }, /* GL_TEXTURE_MAX_CLAMP_S_SGIX */
+   { 37278, 0x0000836A }, /* GL_TEXTURE_MAX_CLAMP_T_SGIX */
+   { 37306, 0x0000813D }, /* GL_TEXTURE_MAX_LEVEL */
+   { 37327, 0x0000813B }, /* GL_TEXTURE_MAX_LOD */
+   { 37346, 0x00002801 }, /* GL_TEXTURE_MIN_FILTER */
+   { 37368, 0x0000813A }, /* GL_TEXTURE_MIN_LOD */
+   { 37387, 0x00008066 }, /* GL_TEXTURE_PRIORITY */
+   { 37407, 0x000085B7 }, /* GL_TEXTURE_RANGE_LENGTH_APPLE */
+   { 37437, 0x000085B8 }, /* GL_TEXTURE_RANGE_POINTER_APPLE */
+   { 37468, 0x000084F5 }, /* GL_TEXTURE_RECTANGLE_ARB */
+   { 37493, 0x000084F5 }, /* GL_TEXTURE_RECTANGLE_NV */
+   { 37517, 0x0000805C }, /* GL_TEXTURE_RED_SIZE */
+   { 37537, 0x0000805C }, /* GL_TEXTURE_RED_SIZE_EXT */
+   { 37561, 0x00008067 }, /* GL_TEXTURE_RESIDENT */
+   { 37581, 0x00000BA5 }, /* GL_TEXTURE_STACK_DEPTH */
+   { 37604, 0x000088F1 }, /* GL_TEXTURE_STENCIL_SIZE */
+   { 37628, 0x000088F1 }, /* GL_TEXTURE_STENCIL_SIZE_EXT */
+   { 37656, 0x000085BC }, /* GL_TEXTURE_STORAGE_HINT_APPLE */
+   { 37686, 0x00008065 }, /* GL_TEXTURE_TOO_LARGE_EXT */
+   { 37711, 0x0000888F }, /* GL_TEXTURE_UNSIGNED_REMAP_MODE_NV */
+   { 37745, 0x00001000 }, /* GL_TEXTURE_WIDTH */
+   { 37762, 0x00008072 }, /* GL_TEXTURE_WRAP_R */
+   { 37780, 0x00002802 }, /* GL_TEXTURE_WRAP_S */
+   { 37798, 0x00002803 }, /* GL_TEXTURE_WRAP_T */
+   { 37816, 0x0000911B }, /* GL_TIMEOUT_EXPIRED */
+   { 37835, 0x000088BF }, /* GL_TIME_ELAPSED_EXT */
+   { 37855, 0x00008648 }, /* GL_TRACK_MATRIX_NV */
+   { 37874, 0x00008649 }, /* GL_TRACK_MATRIX_TRANSFORM_NV */
+   { 37903, 0x00001000 }, /* GL_TRANSFORM_BIT */
+   { 37920, 0x000084E6 }, /* GL_TRANSPOSE_COLOR_MATRIX */
+   { 37946, 0x000084E6 }, /* GL_TRANSPOSE_COLOR_MATRIX_ARB */
+   { 37976, 0x000088B7 }, /* GL_TRANSPOSE_CURRENT_MATRIX_ARB */
+   { 38008, 0x000084E3 }, /* GL_TRANSPOSE_MODELVIEW_MATRIX */
+   { 38038, 0x000084E3 }, /* GL_TRANSPOSE_MODELVIEW_MATRIX_ARB */
+   { 38072, 0x0000862C }, /* GL_TRANSPOSE_NV */
+   { 38088, 0x000084E4 }, /* GL_TRANSPOSE_PROJECTION_MATRIX */
+   { 38119, 0x000084E4 }, /* GL_TRANSPOSE_PROJECTION_MATRIX_ARB */
+   { 38154, 0x000084E5 }, /* GL_TRANSPOSE_TEXTURE_MATRIX */
+   { 38182, 0x000084E5 }, /* GL_TRANSPOSE_TEXTURE_MATRIX_ARB */
+   { 38214, 0x00000004 }, /* GL_TRIANGLES */
+   { 38227, 0x00000006 }, /* GL_TRIANGLE_FAN */
+   { 38243, 0x00008615 }, /* GL_TRIANGLE_MESH_SUN */
+   { 38264, 0x00000005 }, /* GL_TRIANGLE_STRIP */
+   { 38282, 0x00000001 }, /* GL_TRUE */
+   { 38290, 0x00000CF5 }, /* GL_UNPACK_ALIGNMENT */
+   { 38310, 0x0000806E }, /* GL_UNPACK_IMAGE_HEIGHT */
+   { 38333, 0x00000CF1 }, /* GL_UNPACK_LSB_FIRST */
+   { 38353, 0x00000CF2 }, /* GL_UNPACK_ROW_LENGTH */
+   { 38374, 0x0000806D }, /* GL_UNPACK_SKIP_IMAGES */
+   { 38396, 0x00000CF4 }, /* GL_UNPACK_SKIP_PIXELS */
+   { 38418, 0x00000CF3 }, /* GL_UNPACK_SKIP_ROWS */
+   { 38438, 0x00000CF0 }, /* GL_UNPACK_SWAP_BYTES */
+   { 38459, 0x00009118 }, /* GL_UNSIGNALED */
+   { 38473, 0x00001401 }, /* GL_UNSIGNED_BYTE */
+   { 38490, 0x00008362 }, /* GL_UNSIGNED_BYTE_2_3_3_REV */
+   { 38517, 0x00008032 }, /* GL_UNSIGNED_BYTE_3_3_2 */
+   { 38540, 0x00001405 }, /* GL_UNSIGNED_INT */
+   { 38556, 0x00008036 }, /* GL_UNSIGNED_INT_10_10_10_2 */
+   { 38583, 0x000084FA }, /* GL_UNSIGNED_INT_24_8 */
+   { 38604, 0x000084FA }, /* GL_UNSIGNED_INT_24_8_EXT */
+   { 38629, 0x000084FA }, /* GL_UNSIGNED_INT_24_8_NV */
+   { 38653, 0x00008368 }, /* GL_UNSIGNED_INT_2_10_10_10_REV */
+   { 38684, 0x00008035 }, /* GL_UNSIGNED_INT_8_8_8_8 */
+   { 38708, 0x00008367 }, /* GL_UNSIGNED_INT_8_8_8_8_REV */
+   { 38736, 0x00008C17 }, /* GL_UNSIGNED_NORMALIZED */
+   { 38759, 0x00001403 }, /* GL_UNSIGNED_SHORT */
+   { 38777, 0x00008366 }, /* GL_UNSIGNED_SHORT_1_5_5_5_REV */
+   { 38807, 0x00008033 }, /* GL_UNSIGNED_SHORT_4_4_4_4 */
+   { 38833, 0x00008365 }, /* GL_UNSIGNED_SHORT_4_4_4_4_REV */
+   { 38863, 0x00008034 }, /* GL_UNSIGNED_SHORT_5_5_5_1 */
+   { 38889, 0x00008363 }, /* GL_UNSIGNED_SHORT_5_6_5 */
+   { 38913, 0x00008364 }, /* GL_UNSIGNED_SHORT_5_6_5_REV */
+   { 38941, 0x000085BA }, /* GL_UNSIGNED_SHORT_8_8_APPLE */
+   { 38969, 0x000085BA }, /* GL_UNSIGNED_SHORT_8_8_MESA */
+   { 38996, 0x000085BB }, /* GL_UNSIGNED_SHORT_8_8_REV_APPLE */
+   { 39028, 0x000085BB }, /* GL_UNSIGNED_SHORT_8_8_REV_MESA */
+   { 39059, 0x00008CA2 }, /* GL_UPPER_LEFT */
+   { 39073, 0x00002A20 }, /* GL_V2F */
+   { 39080, 0x00002A21 }, /* GL_V3F */
+   { 39087, 0x00008B83 }, /* GL_VALIDATE_STATUS */
+   { 39106, 0x00001F00 }, /* GL_VENDOR */
+   { 39116, 0x00001F02 }, /* GL_VERSION */
+   { 39127, 0x00008074 }, /* GL_VERTEX_ARRAY */
+   { 39143, 0x000085B5 }, /* GL_VERTEX_ARRAY_BINDING */
+   { 39167, 0x000085B5 }, /* GL_VERTEX_ARRAY_BINDING_APPLE */
+   { 39197, 0x00008896 }, /* GL_VERTEX_ARRAY_BUFFER_BINDING */
+   { 39228, 0x00008896 }, /* GL_VERTEX_ARRAY_BUFFER_BINDING_ARB */
+   { 39263, 0x0000808E }, /* GL_VERTEX_ARRAY_POINTER */
+   { 39287, 0x0000807A }, /* GL_VERTEX_ARRAY_SIZE */
+   { 39308, 0x0000807C }, /* GL_VERTEX_ARRAY_STRIDE */
+   { 39331, 0x0000807B }, /* GL_VERTEX_ARRAY_TYPE */
+   { 39352, 0x00008650 }, /* GL_VERTEX_ATTRIB_ARRAY0_NV */
+   { 39379, 0x0000865A }, /* GL_VERTEX_ATTRIB_ARRAY10_NV */
+   { 39407, 0x0000865B }, /* GL_VERTEX_ATTRIB_ARRAY11_NV */
+   { 39435, 0x0000865C }, /* GL_VERTEX_ATTRIB_ARRAY12_NV */
+   { 39463, 0x0000865D }, /* GL_VERTEX_ATTRIB_ARRAY13_NV */
+   { 39491, 0x0000865E }, /* GL_VERTEX_ATTRIB_ARRAY14_NV */
+   { 39519, 0x0000865F }, /* GL_VERTEX_ATTRIB_ARRAY15_NV */
+   { 39547, 0x00008651 }, /* GL_VERTEX_ATTRIB_ARRAY1_NV */
+   { 39574, 0x00008652 }, /* GL_VERTEX_ATTRIB_ARRAY2_NV */
+   { 39601, 0x00008653 }, /* GL_VERTEX_ATTRIB_ARRAY3_NV */
+   { 39628, 0x00008654 }, /* GL_VERTEX_ATTRIB_ARRAY4_NV */
+   { 39655, 0x00008655 }, /* GL_VERTEX_ATTRIB_ARRAY5_NV */
+   { 39682, 0x00008656 }, /* GL_VERTEX_ATTRIB_ARRAY6_NV */
+   { 39709, 0x00008657 }, /* GL_VERTEX_ATTRIB_ARRAY7_NV */
+   { 39736, 0x00008658 }, /* GL_VERTEX_ATTRIB_ARRAY8_NV */
+   { 39763, 0x00008659 }, /* GL_VERTEX_ATTRIB_ARRAY9_NV */
+   { 39790, 0x0000889F }, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING */
+   { 39828, 0x0000889F }, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB */
+   { 39870, 0x00008622 }, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED */
+   { 39901, 0x00008622 }, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB */
+   { 39936, 0x0000886A }, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED */
+   { 39970, 0x0000886A }, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB */
+   { 40008, 0x00008645 }, /* GL_VERTEX_ATTRIB_ARRAY_POINTER */
+   { 40039, 0x00008645 }, /* GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB */
+   { 40074, 0x00008623 }, /* GL_VERTEX_ATTRIB_ARRAY_SIZE */
+   { 40102, 0x00008623 }, /* GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB */
+   { 40134, 0x00008624 }, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE */
+   { 40164, 0x00008624 }, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB */
+   { 40198, 0x00008625 }, /* GL_VERTEX_ATTRIB_ARRAY_TYPE */
+   { 40226, 0x00008625 }, /* GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB */
+   { 40258, 0x000086A7 }, /* GL_VERTEX_BLEND_ARB */
+   { 40278, 0x00008620 }, /* GL_VERTEX_PROGRAM_ARB */
+   { 40300, 0x0000864A }, /* GL_VERTEX_PROGRAM_BINDING_NV */
+   { 40329, 0x00008620 }, /* GL_VERTEX_PROGRAM_NV */
+   { 40350, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE */
+   { 40379, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE_ARB */
+   { 40412, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE_NV */
+   { 40444, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE */
+   { 40471, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE_ARB */
+   { 40502, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE_NV */
+   { 40532, 0x00008B31 }, /* GL_VERTEX_SHADER */
+   { 40549, 0x00008B31 }, /* GL_VERTEX_SHADER_ARB */
+   { 40570, 0x00008621 }, /* GL_VERTEX_STATE_PROGRAM_NV */
+   { 40597, 0x00000BA2 }, /* GL_VIEWPORT */
+   { 40609, 0x00000800 }, /* GL_VIEWPORT_BIT */
+   { 40625, 0x0000911D }, /* GL_WAIT_FAILED */
+   { 40640, 0x000086AD }, /* GL_WEIGHT_ARRAY_ARB */
+   { 40660, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING */
+   { 40691, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB */
+   { 40726, 0x000086AC }, /* GL_WEIGHT_ARRAY_POINTER_ARB */
+   { 40754, 0x000086AB }, /* GL_WEIGHT_ARRAY_SIZE_ARB */
+   { 40779, 0x000086AA }, /* GL_WEIGHT_ARRAY_STRIDE_ARB */
+   { 40806, 0x000086A9 }, /* GL_WEIGHT_ARRAY_TYPE_ARB */
+   { 40831, 0x000086A6 }, /* GL_WEIGHT_SUM_UNITY_ARB */
+   { 40855, 0x000081D4 }, /* GL_WRAP_BORDER_SUN */
+   { 40874, 0x000088B9 }, /* GL_WRITE_ONLY */
+   { 40888, 0x000088B9 }, /* GL_WRITE_ONLY_ARB */
+   { 40906, 0x00001506 }, /* GL_XOR */
+   { 40913, 0x000085B9 }, /* GL_YCBCR_422_APPLE */
+   { 40932, 0x00008757 }, /* GL_YCBCR_MESA */
+   { 40946, 0x00000000 }, /* GL_ZERO */
+   { 40954, 0x00000D16 }, /* GL_ZOOM_X */
+   { 40964, 0x00000D17 }, /* GL_ZOOM_Y */
 };
 
-static const unsigned reduced_enums[1347] =
+static const unsigned reduced_enums[1350] =
 {
-       476, /* GL_FALSE */
-       694, /* GL_LINES */
-       696, /* GL_LINE_LOOP */
-       703, /* GL_LINE_STRIP */
-      1748, /* GL_TRIANGLES */
-      1751, /* GL_TRIANGLE_STRIP */
-      1749, /* GL_TRIANGLE_FAN */
-      1275, /* GL_QUADS */
-      1279, /* GL_QUAD_STRIP */
-      1161, /* GL_POLYGON */
-      1173, /* GL_POLYGON_STIPPLE_BIT */
-      1122, /* GL_PIXEL_MODE_BIT */
-       681, /* GL_LIGHTING_BIT */
-       506, /* GL_FOG_BIT */
+       479, /* GL_FALSE */
+       701, /* GL_LINES */
+       703, /* GL_LINE_LOOP */
+       710, /* GL_LINE_STRIP */
+      1769, /* GL_TRIANGLES */
+      1772, /* GL_TRIANGLE_STRIP */
+      1770, /* GL_TRIANGLE_FAN */
+      1285, /* GL_QUADS */
+      1289, /* GL_QUAD_STRIP */
+      1171, /* GL_POLYGON */
+      1183, /* GL_POLYGON_STIPPLE_BIT */
+      1132, /* GL_PIXEL_MODE_BIT */
+       688, /* GL_LIGHTING_BIT */
+       509, /* GL_FOG_BIT */
          8, /* GL_ACCUM */
-       713, /* GL_LOAD */
-      1331, /* GL_RETURN */
-       994, /* GL_MULT */
+       720, /* GL_LOAD */
+      1348, /* GL_RETURN */
+      1004, /* GL_MULT */
         23, /* GL_ADD */
-      1010, /* GL_NEVER */
-       671, /* GL_LESS */
-       466, /* GL_EQUAL */
-       670, /* GL_LEQUAL */
-       592, /* GL_GREATER */
-      1025, /* GL_NOTEQUAL */
-       591, /* GL_GEQUAL */
+      1020, /* GL_NEVER */
+       678, /* GL_LESS */
+       469, /* GL_EQUAL */
+       677, /* GL_LEQUAL */
+       599, /* GL_GREATER */
+      1035, /* GL_NOTEQUAL */
+       598, /* GL_GEQUAL */
         47, /* GL_ALWAYS */
-      1472, /* GL_SRC_COLOR */
-      1055, /* GL_ONE_MINUS_SRC_COLOR */
-      1470, /* GL_SRC_ALPHA */
-      1054, /* GL_ONE_MINUS_SRC_ALPHA */
-       445, /* GL_DST_ALPHA */
-      1052, /* GL_ONE_MINUS_DST_ALPHA */
-       446, /* GL_DST_COLOR */
-      1053, /* GL_ONE_MINUS_DST_COLOR */
-      1471, /* GL_SRC_ALPHA_SATURATE */
-       579, /* GL_FRONT_LEFT */
-       580, /* GL_FRONT_RIGHT */
+      1489, /* GL_SRC_COLOR */
+      1065, /* GL_ONE_MINUS_SRC_COLOR */
+      1487, /* GL_SRC_ALPHA */
+      1064, /* GL_ONE_MINUS_SRC_ALPHA */
+       448, /* GL_DST_ALPHA */
+      1062, /* GL_ONE_MINUS_DST_ALPHA */
+       449, /* GL_DST_COLOR */
+      1063, /* GL_ONE_MINUS_DST_COLOR */
+      1488, /* GL_SRC_ALPHA_SATURATE */
+       586, /* GL_FRONT_LEFT */
+       587, /* GL_FRONT_RIGHT */
         69, /* GL_BACK_LEFT */
         70, /* GL_BACK_RIGHT */
-       576, /* GL_FRONT */
+       583, /* GL_FRONT */
         68, /* GL_BACK */
-       669, /* GL_LEFT */
-      1373, /* GL_RIGHT */
-       577, /* GL_FRONT_AND_BACK */
+       676, /* GL_LEFT */
+      1390, /* GL_RIGHT */
+       584, /* GL_FRONT_AND_BACK */
         63, /* GL_AUX0 */
         64, /* GL_AUX1 */
         65, /* GL_AUX2 */
         66, /* GL_AUX3 */
-       658, /* GL_INVALID_ENUM */
-       662, /* GL_INVALID_VALUE */
-       661, /* GL_INVALID_OPERATION */
-      1477, /* GL_STACK_OVERFLOW */
-      1478, /* GL_STACK_UNDERFLOW */
-      1080, /* GL_OUT_OF_MEMORY */
-       659, /* GL_INVALID_FRAMEBUFFER_OPERATION */
+       665, /* GL_INVALID_ENUM */
+       669, /* GL_INVALID_VALUE */
+       668, /* GL_INVALID_OPERATION */
+      1494, /* GL_STACK_OVERFLOW */
+      1495, /* GL_STACK_UNDERFLOW */
+      1090, /* GL_OUT_OF_MEMORY */
+       666, /* GL_INVALID_FRAMEBUFFER_OPERATION */
          0, /* GL_2D */
          2, /* GL_3D */
          3, /* GL_3D_COLOR */
          4, /* GL_3D_COLOR_TEXTURE */
          6, /* GL_4D_COLOR_TEXTURE */
-      1100, /* GL_PASS_THROUGH_TOKEN */
-      1160, /* GL_POINT_TOKEN */
-       704, /* GL_LINE_TOKEN */
-      1174, /* GL_POLYGON_TOKEN */
+      1110, /* GL_PASS_THROUGH_TOKEN */
+      1170, /* GL_POINT_TOKEN */
+       711, /* GL_LINE_TOKEN */
+      1184, /* GL_POLYGON_TOKEN */
         74, /* GL_BITMAP_TOKEN */
-       444, /* GL_DRAW_PIXEL_TOKEN */
+       447, /* GL_DRAW_PIXEL_TOKEN */
        301, /* GL_COPY_PIXEL_TOKEN */
-       697, /* GL_LINE_RESET_TOKEN */
-       469, /* GL_EXP */
-       470, /* GL_EXP2 */
+       704, /* GL_LINE_RESET_TOKEN */
+       472, /* GL_EXP */
+       473, /* GL_EXP2 */
        337, /* GL_CW */
        125, /* GL_CCW */
        146, /* GL_COEFF */
-      1077, /* GL_ORDER */
-       382, /* GL_DOMAIN */
+      1087, /* GL_ORDER */
+       384, /* GL_DOMAIN */
        311, /* GL_CURRENT_COLOR */
        314, /* GL_CURRENT_INDEX */
        320, /* GL_CURRENT_NORMAL */
@@ -3854,519 +3898,519 @@ static const unsigned reduced_enums[1347] =
        328, /* GL_CURRENT_RASTER_POSITION */
        329, /* GL_CURRENT_RASTER_POSITION_VALID */
        326, /* GL_CURRENT_RASTER_DISTANCE */
-      1153, /* GL_POINT_SMOOTH */
-      1142, /* GL_POINT_SIZE */
-      1152, /* GL_POINT_SIZE_RANGE */
-      1143, /* GL_POINT_SIZE_GRANULARITY */
-       698, /* GL_LINE_SMOOTH */
-       705, /* GL_LINE_WIDTH */
-       707, /* GL_LINE_WIDTH_RANGE */
-       706, /* GL_LINE_WIDTH_GRANULARITY */
-       700, /* GL_LINE_STIPPLE */
-       701, /* GL_LINE_STIPPLE_PATTERN */
-       702, /* GL_LINE_STIPPLE_REPEAT */
-       712, /* GL_LIST_MODE */
-       877, /* GL_MAX_LIST_NESTING */
-       709, /* GL_LIST_BASE */
-       711, /* GL_LIST_INDEX */
-      1163, /* GL_POLYGON_MODE */
-      1170, /* GL_POLYGON_SMOOTH */
-      1172, /* GL_POLYGON_STIPPLE */
-       455, /* GL_EDGE_FLAG */
+      1163, /* GL_POINT_SMOOTH */
+      1152, /* GL_POINT_SIZE */
+      1162, /* GL_POINT_SIZE_RANGE */
+      1153, /* GL_POINT_SIZE_GRANULARITY */
+       705, /* GL_LINE_SMOOTH */
+       712, /* GL_LINE_WIDTH */
+       714, /* GL_LINE_WIDTH_RANGE */
+       713, /* GL_LINE_WIDTH_GRANULARITY */
+       707, /* GL_LINE_STIPPLE */
+       708, /* GL_LINE_STIPPLE_PATTERN */
+       709, /* GL_LINE_STIPPLE_REPEAT */
+       719, /* GL_LIST_MODE */
+       885, /* GL_MAX_LIST_NESTING */
+       716, /* GL_LIST_BASE */
+       718, /* GL_LIST_INDEX */
+      1173, /* GL_POLYGON_MODE */
+      1180, /* GL_POLYGON_SMOOTH */
+      1182, /* GL_POLYGON_STIPPLE */
+       458, /* GL_EDGE_FLAG */
        304, /* GL_CULL_FACE */
        305, /* GL_CULL_FACE_MODE */
-       578, /* GL_FRONT_FACE */
-       680, /* GL_LIGHTING */
-       685, /* GL_LIGHT_MODEL_LOCAL_VIEWER */
-       686, /* GL_LIGHT_MODEL_TWO_SIDE */
-       682, /* GL_LIGHT_MODEL_AMBIENT */
-      1419, /* GL_SHADE_MODEL */
+       585, /* GL_FRONT_FACE */
+       687, /* GL_LIGHTING */
+       692, /* GL_LIGHT_MODEL_LOCAL_VIEWER */
+       693, /* GL_LIGHT_MODEL_TWO_SIDE */
+       689, /* GL_LIGHT_MODEL_AMBIENT */
+      1436, /* GL_SHADE_MODEL */
        193, /* GL_COLOR_MATERIAL_FACE */
        194, /* GL_COLOR_MATERIAL_PARAMETER */
        192, /* GL_COLOR_MATERIAL */
-       505, /* GL_FOG */
-       527, /* GL_FOG_INDEX */
-       523, /* GL_FOG_DENSITY */
-       531, /* GL_FOG_START */
-       525, /* GL_FOG_END */
-       528, /* GL_FOG_MODE */
-       507, /* GL_FOG_COLOR */
-       369, /* GL_DEPTH_RANGE */
-       376, /* GL_DEPTH_TEST */
-       379, /* GL_DEPTH_WRITEMASK */
-       357, /* GL_DEPTH_CLEAR_VALUE */
-       368, /* GL_DEPTH_FUNC */
+       508, /* GL_FOG */
+       530, /* GL_FOG_INDEX */
+       526, /* GL_FOG_DENSITY */
+       534, /* GL_FOG_START */
+       528, /* GL_FOG_END */
+       531, /* GL_FOG_MODE */
+       510, /* GL_FOG_COLOR */
+       370, /* GL_DEPTH_RANGE */
+       378, /* GL_DEPTH_TEST */
+       381, /* GL_DEPTH_WRITEMASK */
+       358, /* GL_DEPTH_CLEAR_VALUE */
+       369, /* GL_DEPTH_FUNC */
         12, /* GL_ACCUM_CLEAR_VALUE */
-      1513, /* GL_STENCIL_TEST */
-      1501, /* GL_STENCIL_CLEAR_VALUE */
-      1503, /* GL_STENCIL_FUNC */
-      1515, /* GL_STENCIL_VALUE_MASK */
-      1502, /* GL_STENCIL_FAIL */
-      1510, /* GL_STENCIL_PASS_DEPTH_FAIL */
-      1511, /* GL_STENCIL_PASS_DEPTH_PASS */
-      1512, /* GL_STENCIL_REF */
-      1516, /* GL_STENCIL_WRITEMASK */
-       846, /* GL_MATRIX_MODE */
-      1015, /* GL_NORMALIZE */
-      1842, /* GL_VIEWPORT */
-       989, /* GL_MODELVIEW_STACK_DEPTH */
-      1253, /* GL_PROJECTION_STACK_DEPTH */
-      1723, /* GL_TEXTURE_STACK_DEPTH */
-       987, /* GL_MODELVIEW_MATRIX */
-      1252, /* GL_PROJECTION_MATRIX */
-      1706, /* GL_TEXTURE_MATRIX */
+      1534, /* GL_STENCIL_TEST */
+      1518, /* GL_STENCIL_CLEAR_VALUE */
+      1520, /* GL_STENCIL_FUNC */
+      1536, /* GL_STENCIL_VALUE_MASK */
+      1519, /* GL_STENCIL_FAIL */
+      1531, /* GL_STENCIL_PASS_DEPTH_FAIL */
+      1532, /* GL_STENCIL_PASS_DEPTH_PASS */
+      1533, /* GL_STENCIL_REF */
+      1537, /* GL_STENCIL_WRITEMASK */
+       853, /* GL_MATRIX_MODE */
+      1025, /* GL_NORMALIZE */
+      1864, /* GL_VIEWPORT */
+       999, /* GL_MODELVIEW_STACK_DEPTH */
+      1263, /* GL_PROJECTION_STACK_DEPTH */
+      1744, /* GL_TEXTURE_STACK_DEPTH */
+       997, /* GL_MODELVIEW_MATRIX */
+      1262, /* GL_PROJECTION_MATRIX */
+      1727, /* GL_TEXTURE_MATRIX */
         61, /* GL_ATTRIB_STACK_DEPTH */
        136, /* GL_CLIENT_ATTRIB_STACK_DEPTH */
         43, /* GL_ALPHA_TEST */
         44, /* GL_ALPHA_TEST_FUNC */
         45, /* GL_ALPHA_TEST_REF */
-       381, /* GL_DITHER */
+       383, /* GL_DITHER */
         78, /* GL_BLEND_DST */
         87, /* GL_BLEND_SRC */
         75, /* GL_BLEND */
-       715, /* GL_LOGIC_OP_MODE */
-       632, /* GL_INDEX_LOGIC_OP */
+       722, /* GL_LOGIC_OP_MODE */
+       639, /* GL_INDEX_LOGIC_OP */
        191, /* GL_COLOR_LOGIC_OP */
         67, /* GL_AUX_BUFFERS */
-       392, /* GL_DRAW_BUFFER */
-      1289, /* GL_READ_BUFFER */
-      1400, /* GL_SCISSOR_BOX */
-      1401, /* GL_SCISSOR_TEST */
-       631, /* GL_INDEX_CLEAR_VALUE */
-       636, /* GL_INDEX_WRITEMASK */
+       394, /* GL_DRAW_BUFFER */
+      1303, /* GL_READ_BUFFER */
+      1417, /* GL_SCISSOR_BOX */
+      1418, /* GL_SCISSOR_TEST */
+       638, /* GL_INDEX_CLEAR_VALUE */
+       643, /* GL_INDEX_WRITEMASK */
        188, /* GL_COLOR_CLEAR_VALUE */
        230, /* GL_COLOR_WRITEMASK */
-       633, /* GL_INDEX_MODE */
-      1366, /* GL_RGBA_MODE */
-       391, /* GL_DOUBLEBUFFER */
-      1517, /* GL_STEREO */
-      1324, /* GL_RENDER_MODE */
-      1101, /* GL_PERSPECTIVE_CORRECTION_HINT */
-      1154, /* GL_POINT_SMOOTH_HINT */
-       699, /* GL_LINE_SMOOTH_HINT */
-      1171, /* GL_POLYGON_SMOOTH_HINT */
-       526, /* GL_FOG_HINT */
-      1687, /* GL_TEXTURE_GEN_S */
-      1688, /* GL_TEXTURE_GEN_T */
-      1686, /* GL_TEXTURE_GEN_R */
-      1685, /* GL_TEXTURE_GEN_Q */
-      1114, /* GL_PIXEL_MAP_I_TO_I */
-      1120, /* GL_PIXEL_MAP_S_TO_S */
-      1116, /* GL_PIXEL_MAP_I_TO_R */
-      1112, /* GL_PIXEL_MAP_I_TO_G */
-      1110, /* GL_PIXEL_MAP_I_TO_B */
-      1108, /* GL_PIXEL_MAP_I_TO_A */
-      1118, /* GL_PIXEL_MAP_R_TO_R */
-      1106, /* GL_PIXEL_MAP_G_TO_G */
-      1104, /* GL_PIXEL_MAP_B_TO_B */
-      1102, /* GL_PIXEL_MAP_A_TO_A */
-      1115, /* GL_PIXEL_MAP_I_TO_I_SIZE */
-      1121, /* GL_PIXEL_MAP_S_TO_S_SIZE */
-      1117, /* GL_PIXEL_MAP_I_TO_R_SIZE */
-      1113, /* GL_PIXEL_MAP_I_TO_G_SIZE */
-      1111, /* GL_PIXEL_MAP_I_TO_B_SIZE */
-      1109, /* GL_PIXEL_MAP_I_TO_A_SIZE */
-      1119, /* GL_PIXEL_MAP_R_TO_R_SIZE */
-      1107, /* GL_PIXEL_MAP_G_TO_G_SIZE */
-      1105, /* GL_PIXEL_MAP_B_TO_B_SIZE */
-      1103, /* GL_PIXEL_MAP_A_TO_A_SIZE */
-      1760, /* GL_UNPACK_SWAP_BYTES */
-      1755, /* GL_UNPACK_LSB_FIRST */
-      1756, /* GL_UNPACK_ROW_LENGTH */
-      1759, /* GL_UNPACK_SKIP_ROWS */
-      1758, /* GL_UNPACK_SKIP_PIXELS */
-      1753, /* GL_UNPACK_ALIGNMENT */
-      1089, /* GL_PACK_SWAP_BYTES */
-      1084, /* GL_PACK_LSB_FIRST */
-      1085, /* GL_PACK_ROW_LENGTH */
-      1088, /* GL_PACK_SKIP_ROWS */
-      1087, /* GL_PACK_SKIP_PIXELS */
-      1081, /* GL_PACK_ALIGNMENT */
-       793, /* GL_MAP_COLOR */
-       798, /* GL_MAP_STENCIL */
-       635, /* GL_INDEX_SHIFT */
-       634, /* GL_INDEX_OFFSET */
-      1302, /* GL_RED_SCALE */
-      1300, /* GL_RED_BIAS */
-      1860, /* GL_ZOOM_X */
-      1861, /* GL_ZOOM_Y */
-       596, /* GL_GREEN_SCALE */
-       594, /* GL_GREEN_BIAS */
+       640, /* GL_INDEX_MODE */
+      1383, /* GL_RGBA_MODE */
+       393, /* GL_DOUBLEBUFFER */
+      1538, /* GL_STEREO */
+      1341, /* GL_RENDER_MODE */
+      1111, /* GL_PERSPECTIVE_CORRECTION_HINT */
+      1164, /* GL_POINT_SMOOTH_HINT */
+       706, /* GL_LINE_SMOOTH_HINT */
+      1181, /* GL_POLYGON_SMOOTH_HINT */
+       529, /* GL_FOG_HINT */
+      1708, /* GL_TEXTURE_GEN_S */
+      1709, /* GL_TEXTURE_GEN_T */
+      1707, /* GL_TEXTURE_GEN_R */
+      1706, /* GL_TEXTURE_GEN_Q */
+      1124, /* GL_PIXEL_MAP_I_TO_I */
+      1130, /* GL_PIXEL_MAP_S_TO_S */
+      1126, /* GL_PIXEL_MAP_I_TO_R */
+      1122, /* GL_PIXEL_MAP_I_TO_G */
+      1120, /* GL_PIXEL_MAP_I_TO_B */
+      1118, /* GL_PIXEL_MAP_I_TO_A */
+      1128, /* GL_PIXEL_MAP_R_TO_R */
+      1116, /* GL_PIXEL_MAP_G_TO_G */
+      1114, /* GL_PIXEL_MAP_B_TO_B */
+      1112, /* GL_PIXEL_MAP_A_TO_A */
+      1125, /* GL_PIXEL_MAP_I_TO_I_SIZE */
+      1131, /* GL_PIXEL_MAP_S_TO_S_SIZE */
+      1127, /* GL_PIXEL_MAP_I_TO_R_SIZE */
+      1123, /* GL_PIXEL_MAP_I_TO_G_SIZE */
+      1121, /* GL_PIXEL_MAP_I_TO_B_SIZE */
+      1119, /* GL_PIXEL_MAP_I_TO_A_SIZE */
+      1129, /* GL_PIXEL_MAP_R_TO_R_SIZE */
+      1117, /* GL_PIXEL_MAP_G_TO_G_SIZE */
+      1115, /* GL_PIXEL_MAP_B_TO_B_SIZE */
+      1113, /* GL_PIXEL_MAP_A_TO_A_SIZE */
+      1781, /* GL_UNPACK_SWAP_BYTES */
+      1776, /* GL_UNPACK_LSB_FIRST */
+      1777, /* GL_UNPACK_ROW_LENGTH */
+      1780, /* GL_UNPACK_SKIP_ROWS */
+      1779, /* GL_UNPACK_SKIP_PIXELS */
+      1774, /* GL_UNPACK_ALIGNMENT */
+      1099, /* GL_PACK_SWAP_BYTES */
+      1094, /* GL_PACK_LSB_FIRST */
+      1095, /* GL_PACK_ROW_LENGTH */
+      1098, /* GL_PACK_SKIP_ROWS */
+      1097, /* GL_PACK_SKIP_PIXELS */
+      1091, /* GL_PACK_ALIGNMENT */
+       800, /* GL_MAP_COLOR */
+       805, /* GL_MAP_STENCIL */
+       642, /* GL_INDEX_SHIFT */
+       641, /* GL_INDEX_OFFSET */
+      1317, /* GL_RED_SCALE */
+      1315, /* GL_RED_BIAS */
+      1882, /* GL_ZOOM_X */
+      1883, /* GL_ZOOM_Y */
+       603, /* GL_GREEN_SCALE */
+       601, /* GL_GREEN_BIAS */
         93, /* GL_BLUE_SCALE */
         91, /* GL_BLUE_BIAS */
         42, /* GL_ALPHA_SCALE */
         40, /* GL_ALPHA_BIAS */
-       370, /* GL_DEPTH_SCALE */
-       350, /* GL_DEPTH_BIAS */
-       872, /* GL_MAX_EVAL_ORDER */
-       876, /* GL_MAX_LIGHTS */
-       855, /* GL_MAX_CLIP_PLANES */
-       922, /* GL_MAX_TEXTURE_SIZE */
-       882, /* GL_MAX_PIXEL_MAP_TABLE */
-       851, /* GL_MAX_ATTRIB_STACK_DEPTH */
-       879, /* GL_MAX_MODELVIEW_STACK_DEPTH */
-       880, /* GL_MAX_NAME_STACK_DEPTH */
-       908, /* GL_MAX_PROJECTION_STACK_DEPTH */
-       923, /* GL_MAX_TEXTURE_STACK_DEPTH */
-       937, /* GL_MAX_VIEWPORT_DIMS */
-       852, /* GL_MAX_CLIENT_ATTRIB_STACK_DEPTH */
-      1527, /* GL_SUBPIXEL_BITS */
-       630, /* GL_INDEX_BITS */
-      1301, /* GL_RED_BITS */
-       595, /* GL_GREEN_BITS */
+       371, /* GL_DEPTH_SCALE */
+       351, /* GL_DEPTH_BIAS */
+       880, /* GL_MAX_EVAL_ORDER */
+       884, /* GL_MAX_LIGHTS */
+       862, /* GL_MAX_CLIP_PLANES */
+       932, /* GL_MAX_TEXTURE_SIZE */
+       890, /* GL_MAX_PIXEL_MAP_TABLE */
+       858, /* GL_MAX_ATTRIB_STACK_DEPTH */
+       887, /* GL_MAX_MODELVIEW_STACK_DEPTH */
+       888, /* GL_MAX_NAME_STACK_DEPTH */
+       916, /* GL_MAX_PROJECTION_STACK_DEPTH */
+       933, /* GL_MAX_TEXTURE_STACK_DEPTH */
+       947, /* GL_MAX_VIEWPORT_DIMS */
+       859, /* GL_MAX_CLIENT_ATTRIB_STACK_DEPTH */
+      1548, /* GL_SUBPIXEL_BITS */
+       637, /* GL_INDEX_BITS */
+      1316, /* GL_RED_BITS */
+       602, /* GL_GREEN_BITS */
         92, /* GL_BLUE_BITS */
         41, /* GL_ALPHA_BITS */
-       351, /* GL_DEPTH_BITS */
-      1499, /* GL_STENCIL_BITS */
+       352, /* GL_DEPTH_BITS */
+      1516, /* GL_STENCIL_BITS */
         14, /* GL_ACCUM_RED_BITS */
         13, /* GL_ACCUM_GREEN_BITS */
         10, /* GL_ACCUM_BLUE_BITS */
          9, /* GL_ACCUM_ALPHA_BITS */
-      1003, /* GL_NAME_STACK_DEPTH */
+      1013, /* GL_NAME_STACK_DEPTH */
         62, /* GL_AUTO_NORMAL */
-       739, /* GL_MAP1_COLOR_4 */
-       742, /* GL_MAP1_INDEX */
-       743, /* GL_MAP1_NORMAL */
-       744, /* GL_MAP1_TEXTURE_COORD_1 */
-       745, /* GL_MAP1_TEXTURE_COORD_2 */
-       746, /* GL_MAP1_TEXTURE_COORD_3 */
-       747, /* GL_MAP1_TEXTURE_COORD_4 */
-       748, /* GL_MAP1_VERTEX_3 */
-       749, /* GL_MAP1_VERTEX_4 */
-       766, /* GL_MAP2_COLOR_4 */
-       769, /* GL_MAP2_INDEX */
-       770, /* GL_MAP2_NORMAL */
-       771, /* GL_MAP2_TEXTURE_COORD_1 */
-       772, /* GL_MAP2_TEXTURE_COORD_2 */
-       773, /* GL_MAP2_TEXTURE_COORD_3 */
-       774, /* GL_MAP2_TEXTURE_COORD_4 */
-       775, /* GL_MAP2_VERTEX_3 */
-       776, /* GL_MAP2_VERTEX_4 */
-       740, /* GL_MAP1_GRID_DOMAIN */
-       741, /* GL_MAP1_GRID_SEGMENTS */
-       767, /* GL_MAP2_GRID_DOMAIN */
-       768, /* GL_MAP2_GRID_SEGMENTS */
-      1610, /* GL_TEXTURE_1D */
-      1612, /* GL_TEXTURE_2D */
-       479, /* GL_FEEDBACK_BUFFER_POINTER */
-       480, /* GL_FEEDBACK_BUFFER_SIZE */
-       481, /* GL_FEEDBACK_BUFFER_TYPE */
-      1410, /* GL_SELECTION_BUFFER_POINTER */
-      1411, /* GL_SELECTION_BUFFER_SIZE */
-      1728, /* GL_TEXTURE_WIDTH */
-      1692, /* GL_TEXTURE_HEIGHT */
-      1647, /* GL_TEXTURE_COMPONENTS */
-      1631, /* GL_TEXTURE_BORDER_COLOR */
-      1630, /* GL_TEXTURE_BORDER */
-       383, /* GL_DONT_CARE */
-       477, /* GL_FASTEST */
-      1011, /* GL_NICEST */
+       746, /* GL_MAP1_COLOR_4 */
+       749, /* GL_MAP1_INDEX */
+       750, /* GL_MAP1_NORMAL */
+       751, /* GL_MAP1_TEXTURE_COORD_1 */
+       752, /* GL_MAP1_TEXTURE_COORD_2 */
+       753, /* GL_MAP1_TEXTURE_COORD_3 */
+       754, /* GL_MAP1_TEXTURE_COORD_4 */
+       755, /* GL_MAP1_VERTEX_3 */
+       756, /* GL_MAP1_VERTEX_4 */
+       773, /* GL_MAP2_COLOR_4 */
+       776, /* GL_MAP2_INDEX */
+       777, /* GL_MAP2_NORMAL */
+       778, /* GL_MAP2_TEXTURE_COORD_1 */
+       779, /* GL_MAP2_TEXTURE_COORD_2 */
+       780, /* GL_MAP2_TEXTURE_COORD_3 */
+       781, /* GL_MAP2_TEXTURE_COORD_4 */
+       782, /* GL_MAP2_VERTEX_3 */
+       783, /* GL_MAP2_VERTEX_4 */
+       747, /* GL_MAP1_GRID_DOMAIN */
+       748, /* GL_MAP1_GRID_SEGMENTS */
+       774, /* GL_MAP2_GRID_DOMAIN */
+       775, /* GL_MAP2_GRID_SEGMENTS */
+      1631, /* GL_TEXTURE_1D */
+      1633, /* GL_TEXTURE_2D */
+       482, /* GL_FEEDBACK_BUFFER_POINTER */
+       483, /* GL_FEEDBACK_BUFFER_SIZE */
+       484, /* GL_FEEDBACK_BUFFER_TYPE */
+      1427, /* GL_SELECTION_BUFFER_POINTER */
+      1428, /* GL_SELECTION_BUFFER_SIZE */
+      1750, /* GL_TEXTURE_WIDTH */
+      1713, /* GL_TEXTURE_HEIGHT */
+      1668, /* GL_TEXTURE_COMPONENTS */
+      1652, /* GL_TEXTURE_BORDER_COLOR */
+      1651, /* GL_TEXTURE_BORDER */
+       385, /* GL_DONT_CARE */
+       480, /* GL_FASTEST */
+      1021, /* GL_NICEST */
         48, /* GL_AMBIENT */
-       380, /* GL_DIFFUSE */
-      1459, /* GL_SPECULAR */
-      1175, /* GL_POSITION */
-      1462, /* GL_SPOT_DIRECTION */
-      1463, /* GL_SPOT_EXPONENT */
-      1461, /* GL_SPOT_CUTOFF */
+       382, /* GL_DIFFUSE */
+      1476, /* GL_SPECULAR */
+      1185, /* GL_POSITION */
+      1479, /* GL_SPOT_DIRECTION */
+      1480, /* GL_SPOT_EXPONENT */
+      1478, /* GL_SPOT_CUTOFF */
        275, /* GL_CONSTANT_ATTENUATION */
-       689, /* GL_LINEAR_ATTENUATION */
-      1274, /* GL_QUADRATIC_ATTENUATION */
+       696, /* GL_LINEAR_ATTENUATION */
+      1284, /* GL_QUADRATIC_ATTENUATION */
        244, /* GL_COMPILE */
        245, /* GL_COMPILE_AND_EXECUTE */
        120, /* GL_BYTE */
-      1762, /* GL_UNSIGNED_BYTE */
-      1424, /* GL_SHORT */
-      1773, /* GL_UNSIGNED_SHORT */
-       638, /* GL_INT */
-      1765, /* GL_UNSIGNED_INT */
-       486, /* GL_FLOAT */
+      1783, /* GL_UNSIGNED_BYTE */
+      1441, /* GL_SHORT */
+      1795, /* GL_UNSIGNED_SHORT */
+       645, /* GL_INT */
+      1786, /* GL_UNSIGNED_INT */
+       489, /* GL_FLOAT */
          1, /* GL_2_BYTES */
          5, /* GL_3_BYTES */
          7, /* GL_4_BYTES */
-       390, /* GL_DOUBLE */
+       392, /* GL_DOUBLE */
        132, /* GL_CLEAR */
         50, /* GL_AND */
         52, /* GL_AND_REVERSE */
        299, /* GL_COPY */
         51, /* GL_AND_INVERTED */
-      1013, /* GL_NOOP */
-      1856, /* GL_XOR */
-      1076, /* GL_OR */
-      1014, /* GL_NOR */
-       467, /* GL_EQUIV */
-       665, /* GL_INVERT */
-      1079, /* GL_OR_REVERSE */
+      1023, /* GL_NOOP */
+      1878, /* GL_XOR */
+      1086, /* GL_OR */
+      1024, /* GL_NOR */
+       470, /* GL_EQUIV */
+       672, /* GL_INVERT */
+      1089, /* GL_OR_REVERSE */
        300, /* GL_COPY_INVERTED */
-      1078, /* GL_OR_INVERTED */
-      1004, /* GL_NAND */
-      1415, /* GL_SET */
-       464, /* GL_EMISSION */
-      1423, /* GL_SHININESS */
+      1088, /* GL_OR_INVERTED */
+      1014, /* GL_NAND */
+      1432, /* GL_SET */
+       467, /* GL_EMISSION */
+      1440, /* GL_SHININESS */
         49, /* GL_AMBIENT_AND_DIFFUSE */
        190, /* GL_COLOR_INDEXES */
-       954, /* GL_MODELVIEW */
-      1251, /* GL_PROJECTION */
-      1545, /* GL_TEXTURE */
+       964, /* GL_MODELVIEW */
+      1261, /* GL_PROJECTION */
+      1566, /* GL_TEXTURE */
        147, /* GL_COLOR */
        346, /* GL_DEPTH */
-      1485, /* GL_STENCIL */
+      1502, /* GL_STENCIL */
        189, /* GL_COLOR_INDEX */
-      1504, /* GL_STENCIL_INDEX */
-       358, /* GL_DEPTH_COMPONENT */
-      1297, /* GL_RED */
-       593, /* GL_GREEN */
+      1521, /* GL_STENCIL_INDEX */
+       359, /* GL_DEPTH_COMPONENT */
+      1312, /* GL_RED */
+       600, /* GL_GREEN */
         90, /* GL_BLUE */
         31, /* GL_ALPHA */
-      1332, /* GL_RGB */
-      1351, /* GL_RGBA */
-       717, /* GL_LUMINANCE */
-       738, /* GL_LUMINANCE_ALPHA */
+      1349, /* GL_RGB */
+      1368, /* GL_RGBA */
+       724, /* GL_LUMINANCE */
+       745, /* GL_LUMINANCE_ALPHA */
         73, /* GL_BITMAP */
-      1131, /* GL_POINT */
-       687, /* GL_LINE */
-       482, /* GL_FILL */
-      1306, /* GL_RENDER */
-       478, /* GL_FEEDBACK */
-      1409, /* GL_SELECT */
-       485, /* GL_FLAT */
-      1434, /* GL_SMOOTH */
-       666, /* GL_KEEP */
-      1326, /* GL_REPLACE */
-       620, /* GL_INCR */
+      1141, /* GL_POINT */
+       694, /* GL_LINE */
+       485, /* GL_FILL */
+      1321, /* GL_RENDER */
+       481, /* GL_FEEDBACK */
+      1426, /* GL_SELECT */
+       488, /* GL_FLAT */
+      1451, /* GL_SMOOTH */
+       673, /* GL_KEEP */
+      1343, /* GL_REPLACE */
+       627, /* GL_INCR */
        342, /* GL_DECR */
-      1788, /* GL_VENDOR */
-      1323, /* GL_RENDERER */
-      1789, /* GL_VERSION */
-       471, /* GL_EXTENSIONS */
-      1374, /* GL_S */
-      1536, /* GL_T */
-      1286, /* GL_R */
-      1273, /* GL_Q */
-       990, /* GL_MODULATE */
+      1810, /* GL_VENDOR */
+      1340, /* GL_RENDERER */
+      1811, /* GL_VERSION */
+       474, /* GL_EXTENSIONS */
+      1391, /* GL_S */
+      1557, /* GL_T */
+      1300, /* GL_R */
+      1283, /* GL_Q */
+      1000, /* GL_MODULATE */
        341, /* GL_DECAL */
-      1682, /* GL_TEXTURE_ENV_MODE */
-      1681, /* GL_TEXTURE_ENV_COLOR */
-      1680, /* GL_TEXTURE_ENV */
-       472, /* GL_EYE_LINEAR */
-      1037, /* GL_OBJECT_LINEAR */
-      1460, /* GL_SPHERE_MAP */
-      1684, /* GL_TEXTURE_GEN_MODE */
-      1039, /* GL_OBJECT_PLANE */
-       473, /* GL_EYE_PLANE */
-      1005, /* GL_NEAREST */
-       688, /* GL_LINEAR */
-      1009, /* GL_NEAREST_MIPMAP_NEAREST */
-       693, /* GL_LINEAR_MIPMAP_NEAREST */
-      1008, /* GL_NEAREST_MIPMAP_LINEAR */
-       692, /* GL_LINEAR_MIPMAP_LINEAR */
-      1705, /* GL_TEXTURE_MAG_FILTER */
-      1713, /* GL_TEXTURE_MIN_FILTER */
-      1730, /* GL_TEXTURE_WRAP_S */
-      1731, /* GL_TEXTURE_WRAP_T */
+      1703, /* GL_TEXTURE_ENV_MODE */
+      1702, /* GL_TEXTURE_ENV_COLOR */
+      1701, /* GL_TEXTURE_ENV */
+       475, /* GL_EYE_LINEAR */
+      1047, /* GL_OBJECT_LINEAR */
+      1477, /* GL_SPHERE_MAP */
+      1705, /* GL_TEXTURE_GEN_MODE */
+      1049, /* GL_OBJECT_PLANE */
+       476, /* GL_EYE_PLANE */
+      1015, /* GL_NEAREST */
+       695, /* GL_LINEAR */
+      1019, /* GL_NEAREST_MIPMAP_NEAREST */
+       700, /* GL_LINEAR_MIPMAP_NEAREST */
+      1018, /* GL_NEAREST_MIPMAP_LINEAR */
+       699, /* GL_LINEAR_MIPMAP_LINEAR */
+      1726, /* GL_TEXTURE_MAG_FILTER */
+      1734, /* GL_TEXTURE_MIN_FILTER */
+      1752, /* GL_TEXTURE_WRAP_S */
+      1753, /* GL_TEXTURE_WRAP_T */
        126, /* GL_CLAMP */
-      1325, /* GL_REPEAT */
-      1169, /* GL_POLYGON_OFFSET_UNITS */
-      1168, /* GL_POLYGON_OFFSET_POINT */
-      1167, /* GL_POLYGON_OFFSET_LINE */
-      1287, /* GL_R3_G3_B2 */
-      1785, /* GL_V2F */
-      1786, /* GL_V3F */
+      1342, /* GL_REPEAT */
+      1179, /* GL_POLYGON_OFFSET_UNITS */
+      1178, /* GL_POLYGON_OFFSET_POINT */
+      1177, /* GL_POLYGON_OFFSET_LINE */
+      1301, /* GL_R3_G3_B2 */
+      1807, /* GL_V2F */
+      1808, /* GL_V3F */
        123, /* GL_C4UB_V2F */
        124, /* GL_C4UB_V3F */
        121, /* GL_C3F_V3F */
-      1002, /* GL_N3F_V3F */
+      1012, /* GL_N3F_V3F */
        122, /* GL_C4F_N3F_V3F */
-      1541, /* GL_T2F_V3F */
-      1543, /* GL_T4F_V4F */
-      1539, /* GL_T2F_C4UB_V3F */
-      1537, /* GL_T2F_C3F_V3F */
-      1540, /* GL_T2F_N3F_V3F */
-      1538, /* GL_T2F_C4F_N3F_V3F */
-      1542, /* GL_T4F_C4F_N3F_V4F */
+      1562, /* GL_T2F_V3F */
+      1564, /* GL_T4F_V4F */
+      1560, /* GL_T2F_C4UB_V3F */
+      1558, /* GL_T2F_C3F_V3F */
+      1561, /* GL_T2F_N3F_V3F */
+      1559, /* GL_T2F_C4F_N3F_V3F */
+      1563, /* GL_T4F_C4F_N3F_V4F */
        139, /* GL_CLIP_PLANE0 */
        140, /* GL_CLIP_PLANE1 */
        141, /* GL_CLIP_PLANE2 */
        142, /* GL_CLIP_PLANE3 */
        143, /* GL_CLIP_PLANE4 */
        144, /* GL_CLIP_PLANE5 */
-       672, /* GL_LIGHT0 */
-       673, /* GL_LIGHT1 */
-       674, /* GL_LIGHT2 */
-       675, /* GL_LIGHT3 */
-       676, /* GL_LIGHT4 */
-       677, /* GL_LIGHT5 */
-       678, /* GL_LIGHT6 */
-       679, /* GL_LIGHT7 */
-       597, /* GL_HINT_BIT */
+       679, /* GL_LIGHT0 */
+       680, /* GL_LIGHT1 */
+       681, /* GL_LIGHT2 */
+       682, /* GL_LIGHT3 */
+       683, /* GL_LIGHT4 */
+       684, /* GL_LIGHT5 */
+       685, /* GL_LIGHT6 */
+       686, /* GL_LIGHT7 */
+       604, /* GL_HINT_BIT */
        277, /* GL_CONSTANT_COLOR */
-      1050, /* GL_ONE_MINUS_CONSTANT_COLOR */
+      1060, /* GL_ONE_MINUS_CONSTANT_COLOR */
        272, /* GL_CONSTANT_ALPHA */
-      1048, /* GL_ONE_MINUS_CONSTANT_ALPHA */
+      1058, /* GL_ONE_MINUS_CONSTANT_ALPHA */
         76, /* GL_BLEND_COLOR */
-       581, /* GL_FUNC_ADD */
-       938, /* GL_MIN */
-       848, /* GL_MAX */
+       588, /* GL_FUNC_ADD */
+       948, /* GL_MIN */
+       855, /* GL_MAX */
         81, /* GL_BLEND_EQUATION */
-       585, /* GL_FUNC_SUBTRACT */
-       583, /* GL_FUNC_REVERSE_SUBTRACT */
+       592, /* GL_FUNC_SUBTRACT */
+       590, /* GL_FUNC_REVERSE_SUBTRACT */
        280, /* GL_CONVOLUTION_1D */
        281, /* GL_CONVOLUTION_2D */
-      1412, /* GL_SEPARABLE_2D */
+      1429, /* GL_SEPARABLE_2D */
        284, /* GL_CONVOLUTION_BORDER_MODE */
        288, /* GL_CONVOLUTION_FILTER_SCALE */
        286, /* GL_CONVOLUTION_FILTER_BIAS */
-      1298, /* GL_REDUCE */
+      1313, /* GL_REDUCE */
        290, /* GL_CONVOLUTION_FORMAT */
        294, /* GL_CONVOLUTION_WIDTH */
        292, /* GL_CONVOLUTION_HEIGHT */
-       863, /* GL_MAX_CONVOLUTION_WIDTH */
-       861, /* GL_MAX_CONVOLUTION_HEIGHT */
-      1208, /* GL_POST_CONVOLUTION_RED_SCALE */
-      1204, /* GL_POST_CONVOLUTION_GREEN_SCALE */
-      1199, /* GL_POST_CONVOLUTION_BLUE_SCALE */
-      1195, /* GL_POST_CONVOLUTION_ALPHA_SCALE */
-      1206, /* GL_POST_CONVOLUTION_RED_BIAS */
-      1202, /* GL_POST_CONVOLUTION_GREEN_BIAS */
-      1197, /* GL_POST_CONVOLUTION_BLUE_BIAS */
-      1193, /* GL_POST_CONVOLUTION_ALPHA_BIAS */
-       598, /* GL_HISTOGRAM */
-      1257, /* GL_PROXY_HISTOGRAM */
-       614, /* GL_HISTOGRAM_WIDTH */
-       604, /* GL_HISTOGRAM_FORMAT */
-       610, /* GL_HISTOGRAM_RED_SIZE */
-       606, /* GL_HISTOGRAM_GREEN_SIZE */
-       601, /* GL_HISTOGRAM_BLUE_SIZE */
-       599, /* GL_HISTOGRAM_ALPHA_SIZE */
-       608, /* GL_HISTOGRAM_LUMINANCE_SIZE */
-       612, /* GL_HISTOGRAM_SINK */
-       939, /* GL_MINMAX */
-       941, /* GL_MINMAX_FORMAT */
-       943, /* GL_MINMAX_SINK */
-      1544, /* GL_TABLE_TOO_LARGE_EXT */
-      1764, /* GL_UNSIGNED_BYTE_3_3_2 */
-      1775, /* GL_UNSIGNED_SHORT_4_4_4_4 */
-      1777, /* GL_UNSIGNED_SHORT_5_5_5_1 */
-      1770, /* GL_UNSIGNED_INT_8_8_8_8 */
-      1766, /* GL_UNSIGNED_INT_10_10_10_2 */
-      1166, /* GL_POLYGON_OFFSET_FILL */
-      1165, /* GL_POLYGON_OFFSET_FACTOR */
-      1164, /* GL_POLYGON_OFFSET_BIAS */
-      1329, /* GL_RESCALE_NORMAL */
+       871, /* GL_MAX_CONVOLUTION_WIDTH */
+       869, /* GL_MAX_CONVOLUTION_HEIGHT */
+      1218, /* GL_POST_CONVOLUTION_RED_SCALE */
+      1214, /* GL_POST_CONVOLUTION_GREEN_SCALE */
+      1209, /* GL_POST_CONVOLUTION_BLUE_SCALE */
+      1205, /* GL_POST_CONVOLUTION_ALPHA_SCALE */
+      1216, /* GL_POST_CONVOLUTION_RED_BIAS */
+      1212, /* GL_POST_CONVOLUTION_GREEN_BIAS */
+      1207, /* GL_POST_CONVOLUTION_BLUE_BIAS */
+      1203, /* GL_POST_CONVOLUTION_ALPHA_BIAS */
+       605, /* GL_HISTOGRAM */
+      1267, /* GL_PROXY_HISTOGRAM */
+       621, /* GL_HISTOGRAM_WIDTH */
+       611, /* GL_HISTOGRAM_FORMAT */
+       617, /* GL_HISTOGRAM_RED_SIZE */
+       613, /* GL_HISTOGRAM_GREEN_SIZE */
+       608, /* GL_HISTOGRAM_BLUE_SIZE */
+       606, /* GL_HISTOGRAM_ALPHA_SIZE */
+       615, /* GL_HISTOGRAM_LUMINANCE_SIZE */
+       619, /* GL_HISTOGRAM_SINK */
+       949, /* GL_MINMAX */
+       951, /* GL_MINMAX_FORMAT */
+       953, /* GL_MINMAX_SINK */
+      1565, /* GL_TABLE_TOO_LARGE_EXT */
+      1785, /* GL_UNSIGNED_BYTE_3_3_2 */
+      1797, /* GL_UNSIGNED_SHORT_4_4_4_4 */
+      1799, /* GL_UNSIGNED_SHORT_5_5_5_1 */
+      1792, /* GL_UNSIGNED_INT_8_8_8_8 */
+      1787, /* GL_UNSIGNED_INT_10_10_10_2 */
+      1176, /* GL_POLYGON_OFFSET_FILL */
+      1175, /* GL_POLYGON_OFFSET_FACTOR */
+      1174, /* GL_POLYGON_OFFSET_BIAS */
+      1346, /* GL_RESCALE_NORMAL */
         36, /* GL_ALPHA4 */
         38, /* GL_ALPHA8 */
         32, /* GL_ALPHA12 */
         34, /* GL_ALPHA16 */
-       728, /* GL_LUMINANCE4 */
-       734, /* GL_LUMINANCE8 */
-       718, /* GL_LUMINANCE12 */
-       724, /* GL_LUMINANCE16 */
-       729, /* GL_LUMINANCE4_ALPHA4 */
-       732, /* GL_LUMINANCE6_ALPHA2 */
-       735, /* GL_LUMINANCE8_ALPHA8 */
-       721, /* GL_LUMINANCE12_ALPHA4 */
-       719, /* GL_LUMINANCE12_ALPHA12 */
-       725, /* GL_LUMINANCE16_ALPHA16 */
-       639, /* GL_INTENSITY */
-       644, /* GL_INTENSITY4 */
-       646, /* GL_INTENSITY8 */
-       640, /* GL_INTENSITY12 */
-       642, /* GL_INTENSITY16 */
-      1341, /* GL_RGB2_EXT */
-      1342, /* GL_RGB4 */
-      1345, /* GL_RGB5 */
-      1349, /* GL_RGB8 */
-      1333, /* GL_RGB10 */
-      1337, /* GL_RGB12 */
-      1339, /* GL_RGB16 */
-      1356, /* GL_RGBA2 */
-      1358, /* GL_RGBA4 */
-      1346, /* GL_RGB5_A1 */
-      1362, /* GL_RGBA8 */
-      1334, /* GL_RGB10_A2 */
-      1352, /* GL_RGBA12 */
-      1354, /* GL_RGBA16 */
-      1720, /* GL_TEXTURE_RED_SIZE */
-      1690, /* GL_TEXTURE_GREEN_SIZE */
-      1628, /* GL_TEXTURE_BLUE_SIZE */
-      1615, /* GL_TEXTURE_ALPHA_SIZE */
-      1703, /* GL_TEXTURE_LUMINANCE_SIZE */
-      1694, /* GL_TEXTURE_INTENSITY_SIZE */
-      1327, /* GL_REPLACE_EXT */
-      1261, /* GL_PROXY_TEXTURE_1D */
-      1264, /* GL_PROXY_TEXTURE_2D */
-      1726, /* GL_TEXTURE_TOO_LARGE_EXT */
-      1715, /* GL_TEXTURE_PRIORITY */
-      1722, /* GL_TEXTURE_RESIDENT */
-      1618, /* GL_TEXTURE_BINDING_1D */
-      1620, /* GL_TEXTURE_BINDING_2D */
-      1622, /* GL_TEXTURE_BINDING_3D */
-      1086, /* GL_PACK_SKIP_IMAGES */
-      1082, /* GL_PACK_IMAGE_HEIGHT */
-      1757, /* GL_UNPACK_SKIP_IMAGES */
-      1754, /* GL_UNPACK_IMAGE_HEIGHT */
-      1614, /* GL_TEXTURE_3D */
-      1267, /* GL_PROXY_TEXTURE_3D */
-      1677, /* GL_TEXTURE_DEPTH */
-      1729, /* GL_TEXTURE_WRAP_R */
-       849, /* GL_MAX_3D_TEXTURE_SIZE */
-      1790, /* GL_VERTEX_ARRAY */
-      1016, /* GL_NORMAL_ARRAY */
+       735, /* GL_LUMINANCE4 */
+       741, /* GL_LUMINANCE8 */
+       725, /* GL_LUMINANCE12 */
+       731, /* GL_LUMINANCE16 */
+       736, /* GL_LUMINANCE4_ALPHA4 */
+       739, /* GL_LUMINANCE6_ALPHA2 */
+       742, /* GL_LUMINANCE8_ALPHA8 */
+       728, /* GL_LUMINANCE12_ALPHA4 */
+       726, /* GL_LUMINANCE12_ALPHA12 */
+       732, /* GL_LUMINANCE16_ALPHA16 */
+       646, /* GL_INTENSITY */
+       651, /* GL_INTENSITY4 */
+       653, /* GL_INTENSITY8 */
+       647, /* GL_INTENSITY12 */
+       649, /* GL_INTENSITY16 */
+      1358, /* GL_RGB2_EXT */
+      1359, /* GL_RGB4 */
+      1362, /* GL_RGB5 */
+      1366, /* GL_RGB8 */
+      1350, /* GL_RGB10 */
+      1354, /* GL_RGB12 */
+      1356, /* GL_RGB16 */
+      1373, /* GL_RGBA2 */
+      1375, /* GL_RGBA4 */
+      1363, /* GL_RGB5_A1 */
+      1379, /* GL_RGBA8 */
+      1351, /* GL_RGB10_A2 */
+      1369, /* GL_RGBA12 */
+      1371, /* GL_RGBA16 */
+      1741, /* GL_TEXTURE_RED_SIZE */
+      1711, /* GL_TEXTURE_GREEN_SIZE */
+      1649, /* GL_TEXTURE_BLUE_SIZE */
+      1636, /* GL_TEXTURE_ALPHA_SIZE */
+      1724, /* GL_TEXTURE_LUMINANCE_SIZE */
+      1715, /* GL_TEXTURE_INTENSITY_SIZE */
+      1344, /* GL_REPLACE_EXT */
+      1271, /* GL_PROXY_TEXTURE_1D */
+      1274, /* GL_PROXY_TEXTURE_2D */
+      1748, /* GL_TEXTURE_TOO_LARGE_EXT */
+      1736, /* GL_TEXTURE_PRIORITY */
+      1743, /* GL_TEXTURE_RESIDENT */
+      1639, /* GL_TEXTURE_BINDING_1D */
+      1641, /* GL_TEXTURE_BINDING_2D */
+      1643, /* GL_TEXTURE_BINDING_3D */
+      1096, /* GL_PACK_SKIP_IMAGES */
+      1092, /* GL_PACK_IMAGE_HEIGHT */
+      1778, /* GL_UNPACK_SKIP_IMAGES */
+      1775, /* GL_UNPACK_IMAGE_HEIGHT */
+      1635, /* GL_TEXTURE_3D */
+      1277, /* GL_PROXY_TEXTURE_3D */
+      1698, /* GL_TEXTURE_DEPTH */
+      1751, /* GL_TEXTURE_WRAP_R */
+       856, /* GL_MAX_3D_TEXTURE_SIZE */
+      1812, /* GL_VERTEX_ARRAY */
+      1026, /* GL_NORMAL_ARRAY */
        148, /* GL_COLOR_ARRAY */
-       624, /* GL_INDEX_ARRAY */
-      1655, /* GL_TEXTURE_COORD_ARRAY */
-       456, /* GL_EDGE_FLAG_ARRAY */
-      1796, /* GL_VERTEX_ARRAY_SIZE */
-      1798, /* GL_VERTEX_ARRAY_TYPE */
-      1797, /* GL_VERTEX_ARRAY_STRIDE */
-      1021, /* GL_NORMAL_ARRAY_TYPE */
-      1020, /* GL_NORMAL_ARRAY_STRIDE */
+       631, /* GL_INDEX_ARRAY */
+      1676, /* GL_TEXTURE_COORD_ARRAY */
+       459, /* GL_EDGE_FLAG_ARRAY */
+      1818, /* GL_VERTEX_ARRAY_SIZE */
+      1820, /* GL_VERTEX_ARRAY_TYPE */
+      1819, /* GL_VERTEX_ARRAY_STRIDE */
+      1031, /* GL_NORMAL_ARRAY_TYPE */
+      1030, /* GL_NORMAL_ARRAY_STRIDE */
        152, /* GL_COLOR_ARRAY_SIZE */
        154, /* GL_COLOR_ARRAY_TYPE */
        153, /* GL_COLOR_ARRAY_STRIDE */
-       629, /* GL_INDEX_ARRAY_TYPE */
-       628, /* GL_INDEX_ARRAY_STRIDE */
-      1659, /* GL_TEXTURE_COORD_ARRAY_SIZE */
-      1661, /* GL_TEXTURE_COORD_ARRAY_TYPE */
-      1660, /* GL_TEXTURE_COORD_ARRAY_STRIDE */
-       460, /* GL_EDGE_FLAG_ARRAY_STRIDE */
-      1795, /* GL_VERTEX_ARRAY_POINTER */
-      1019, /* GL_NORMAL_ARRAY_POINTER */
+       636, /* GL_INDEX_ARRAY_TYPE */
+       635, /* GL_INDEX_ARRAY_STRIDE */
+      1680, /* GL_TEXTURE_COORD_ARRAY_SIZE */
+      1682, /* GL_TEXTURE_COORD_ARRAY_TYPE */
+      1681, /* GL_TEXTURE_COORD_ARRAY_STRIDE */
+       463, /* GL_EDGE_FLAG_ARRAY_STRIDE */
+      1817, /* GL_VERTEX_ARRAY_POINTER */
+      1029, /* GL_NORMAL_ARRAY_POINTER */
        151, /* GL_COLOR_ARRAY_POINTER */
-       627, /* GL_INDEX_ARRAY_POINTER */
-      1658, /* GL_TEXTURE_COORD_ARRAY_POINTER */
-       459, /* GL_EDGE_FLAG_ARRAY_POINTER */
-       995, /* GL_MULTISAMPLE */
-      1386, /* GL_SAMPLE_ALPHA_TO_COVERAGE */
-      1388, /* GL_SAMPLE_ALPHA_TO_ONE */
-      1393, /* GL_SAMPLE_COVERAGE */
-      1390, /* GL_SAMPLE_BUFFERS */
-      1381, /* GL_SAMPLES */
-      1397, /* GL_SAMPLE_COVERAGE_VALUE */
-      1395, /* GL_SAMPLE_COVERAGE_INVERT */
+       634, /* GL_INDEX_ARRAY_POINTER */
+      1679, /* GL_TEXTURE_COORD_ARRAY_POINTER */
+       462, /* GL_EDGE_FLAG_ARRAY_POINTER */
+      1005, /* GL_MULTISAMPLE */
+      1403, /* GL_SAMPLE_ALPHA_TO_COVERAGE */
+      1405, /* GL_SAMPLE_ALPHA_TO_ONE */
+      1410, /* GL_SAMPLE_COVERAGE */
+      1407, /* GL_SAMPLE_BUFFERS */
+      1398, /* GL_SAMPLES */
+      1414, /* GL_SAMPLE_COVERAGE_VALUE */
+      1412, /* GL_SAMPLE_COVERAGE_INVERT */
        195, /* GL_COLOR_MATRIX */
        197, /* GL_COLOR_MATRIX_STACK_DEPTH */
-       857, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH */
-      1191, /* GL_POST_COLOR_MATRIX_RED_SCALE */
-      1187, /* GL_POST_COLOR_MATRIX_GREEN_SCALE */
-      1182, /* GL_POST_COLOR_MATRIX_BLUE_SCALE */
-      1178, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE */
-      1189, /* GL_POST_COLOR_MATRIX_RED_BIAS */
-      1185, /* GL_POST_COLOR_MATRIX_GREEN_BIAS */
-      1180, /* GL_POST_COLOR_MATRIX_BLUE_BIAS */
-      1176, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS */
-      1638, /* GL_TEXTURE_COLOR_TABLE_SGI */
-      1268, /* GL_PROXY_TEXTURE_COLOR_TABLE_SGI */
-      1640, /* GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
+       865, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH */
+      1201, /* GL_POST_COLOR_MATRIX_RED_SCALE */
+      1197, /* GL_POST_COLOR_MATRIX_GREEN_SCALE */
+      1192, /* GL_POST_COLOR_MATRIX_BLUE_SCALE */
+      1188, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE */
+      1199, /* GL_POST_COLOR_MATRIX_RED_BIAS */
+      1195, /* GL_POST_COLOR_MATRIX_GREEN_BIAS */
+      1190, /* GL_POST_COLOR_MATRIX_BLUE_BIAS */
+      1186, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS */
+      1659, /* GL_TEXTURE_COLOR_TABLE_SGI */
+      1278, /* GL_PROXY_TEXTURE_COLOR_TABLE_SGI */
+      1661, /* GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
         80, /* GL_BLEND_DST_RGB */
         89, /* GL_BLEND_SRC_RGB */
         79, /* GL_BLEND_DST_ALPHA */
         88, /* GL_BLEND_SRC_ALPHA */
        201, /* GL_COLOR_TABLE */
-      1201, /* GL_POST_CONVOLUTION_COLOR_TABLE */
-      1184, /* GL_POST_COLOR_MATRIX_COLOR_TABLE */
-      1256, /* GL_PROXY_COLOR_TABLE */
-      1260, /* GL_PROXY_POST_CONVOLUTION_COLOR_TABLE */
-      1259, /* GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE */
+      1211, /* GL_POST_CONVOLUTION_COLOR_TABLE */
+      1194, /* GL_POST_COLOR_MATRIX_COLOR_TABLE */
+      1266, /* GL_PROXY_COLOR_TABLE */
+      1270, /* GL_PROXY_POST_CONVOLUTION_COLOR_TABLE */
+      1269, /* GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE */
        225, /* GL_COLOR_TABLE_SCALE */
        205, /* GL_COLOR_TABLE_BIAS */
        210, /* GL_COLOR_TABLE_FORMAT */
@@ -4379,380 +4423,380 @@ static const unsigned reduced_enums[1347] =
        216, /* GL_COLOR_TABLE_INTENSITY_SIZE */
         71, /* GL_BGR */
         72, /* GL_BGRA */
-       871, /* GL_MAX_ELEMENTS_VERTICES */
-       870, /* GL_MAX_ELEMENTS_INDICES */
-      1693, /* GL_TEXTURE_INDEX_SIZE_EXT */
+       879, /* GL_MAX_ELEMENTS_VERTICES */
+       878, /* GL_MAX_ELEMENTS_INDICES */
+      1714, /* GL_TEXTURE_INDEX_SIZE_EXT */
        145, /* GL_CLIP_VOLUME_CLIPPING_HINT_EXT */
-      1148, /* GL_POINT_SIZE_MIN */
-      1144, /* GL_POINT_SIZE_MAX */
-      1138, /* GL_POINT_FADE_THRESHOLD_SIZE */
-      1134, /* GL_POINT_DISTANCE_ATTENUATION */
+      1158, /* GL_POINT_SIZE_MIN */
+      1154, /* GL_POINT_SIZE_MAX */
+      1148, /* GL_POINT_FADE_THRESHOLD_SIZE */
+      1144, /* GL_POINT_DISTANCE_ATTENUATION */
        127, /* GL_CLAMP_TO_BORDER */
        130, /* GL_CLAMP_TO_EDGE */
-      1714, /* GL_TEXTURE_MIN_LOD */
-      1712, /* GL_TEXTURE_MAX_LOD */
-      1617, /* GL_TEXTURE_BASE_LEVEL */
-      1711, /* GL_TEXTURE_MAX_LEVEL */
-       617, /* GL_IGNORE_BORDER_HP */
+      1735, /* GL_TEXTURE_MIN_LOD */
+      1733, /* GL_TEXTURE_MAX_LOD */
+      1638, /* GL_TEXTURE_BASE_LEVEL */
+      1732, /* GL_TEXTURE_MAX_LEVEL */
+       624, /* GL_IGNORE_BORDER_HP */
        276, /* GL_CONSTANT_BORDER_HP */
-      1328, /* GL_REPLICATE_BORDER_HP */
+      1345, /* GL_REPLICATE_BORDER_HP */
        282, /* GL_CONVOLUTION_BORDER_COLOR */
-      1045, /* GL_OCCLUSION_TEST_HP */
-      1046, /* GL_OCCLUSION_TEST_RESULT_HP */
-       690, /* GL_LINEAR_CLIPMAP_LINEAR_SGIX */
-      1632, /* GL_TEXTURE_CLIPMAP_CENTER_SGIX */
-      1634, /* GL_TEXTURE_CLIPMAP_FRAME_SGIX */
-      1636, /* GL_TEXTURE_CLIPMAP_OFFSET_SGIX */
-      1637, /* GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX */
-      1635, /* GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX */
-      1633, /* GL_TEXTURE_CLIPMAP_DEPTH_SGIX */
-       853, /* GL_MAX_CLIPMAP_DEPTH_SGIX */
-       854, /* GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX */
-      1211, /* GL_POST_TEXTURE_FILTER_BIAS_SGIX */
-      1213, /* GL_POST_TEXTURE_FILTER_SCALE_SGIX */
-      1210, /* GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX */
-      1212, /* GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX */
-      1701, /* GL_TEXTURE_LOD_BIAS_S_SGIX */
-      1702, /* GL_TEXTURE_LOD_BIAS_T_SGIX */
-      1700, /* GL_TEXTURE_LOD_BIAS_R_SGIX */
-       587, /* GL_GENERATE_MIPMAP */
-       588, /* GL_GENERATE_MIPMAP_HINT */
-       529, /* GL_FOG_OFFSET_SGIX */
-       530, /* GL_FOG_OFFSET_VALUE_SGIX */
-      1646, /* GL_TEXTURE_COMPARE_SGIX */
-      1645, /* GL_TEXTURE_COMPARE_OPERATOR_SGIX */
-      1697, /* GL_TEXTURE_LEQUAL_R_SGIX */
-      1689, /* GL_TEXTURE_GEQUAL_R_SGIX */
-       359, /* GL_DEPTH_COMPONENT16 */
-       362, /* GL_DEPTH_COMPONENT24 */
-       365, /* GL_DEPTH_COMPONENT32 */
+      1055, /* GL_OCCLUSION_TEST_HP */
+      1056, /* GL_OCCLUSION_TEST_RESULT_HP */
+       697, /* GL_LINEAR_CLIPMAP_LINEAR_SGIX */
+      1653, /* GL_TEXTURE_CLIPMAP_CENTER_SGIX */
+      1655, /* GL_TEXTURE_CLIPMAP_FRAME_SGIX */
+      1657, /* GL_TEXTURE_CLIPMAP_OFFSET_SGIX */
+      1658, /* GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX */
+      1656, /* GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX */
+      1654, /* GL_TEXTURE_CLIPMAP_DEPTH_SGIX */
+       860, /* GL_MAX_CLIPMAP_DEPTH_SGIX */
+       861, /* GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX */
+      1221, /* GL_POST_TEXTURE_FILTER_BIAS_SGIX */
+      1223, /* GL_POST_TEXTURE_FILTER_SCALE_SGIX */
+      1220, /* GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX */
+      1222, /* GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX */
+      1722, /* GL_TEXTURE_LOD_BIAS_S_SGIX */
+      1723, /* GL_TEXTURE_LOD_BIAS_T_SGIX */
+      1721, /* GL_TEXTURE_LOD_BIAS_R_SGIX */
+       594, /* GL_GENERATE_MIPMAP */
+       595, /* GL_GENERATE_MIPMAP_HINT */
+       532, /* GL_FOG_OFFSET_SGIX */
+       533, /* GL_FOG_OFFSET_VALUE_SGIX */
+      1667, /* GL_TEXTURE_COMPARE_SGIX */
+      1666, /* GL_TEXTURE_COMPARE_OPERATOR_SGIX */
+      1718, /* GL_TEXTURE_LEQUAL_R_SGIX */
+      1710, /* GL_TEXTURE_GEQUAL_R_SGIX */
+       360, /* GL_DEPTH_COMPONENT16 */
+       363, /* GL_DEPTH_COMPONENT24 */
+       366, /* GL_DEPTH_COMPONENT32 */
        306, /* GL_CULL_VERTEX_EXT */
        308, /* GL_CULL_VERTEX_OBJECT_POSITION_EXT */
        307, /* GL_CULL_VERTEX_EYE_POSITION_EXT */
-      1853, /* GL_WRAP_BORDER_SUN */
-      1639, /* GL_TEXTURE_COLOR_WRITEMASK_SGIS */
-       683, /* GL_LIGHT_MODEL_COLOR_CONTROL */
-      1427, /* GL_SINGLE_COLOR */
-      1413, /* GL_SEPARATE_SPECULAR_COLOR */
-      1422, /* GL_SHARED_TEXTURE_PALETTE_EXT */
-       540, /* GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */
-       541, /* GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */
-       548, /* GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */
-       543, /* GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */
-       539, /* GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */
-       538, /* GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */
-       542, /* GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */
-       549, /* GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */
-       560, /* GL_FRAMEBUFFER_DEFAULT */
-       573, /* GL_FRAMEBUFFER_UNDEFINED */
-       372, /* GL_DEPTH_STENCIL_ATTACHMENT */
-       623, /* GL_INDEX */
-      1763, /* GL_UNSIGNED_BYTE_2_3_3_REV */
-      1778, /* GL_UNSIGNED_SHORT_5_6_5 */
-      1779, /* GL_UNSIGNED_SHORT_5_6_5_REV */
-      1776, /* GL_UNSIGNED_SHORT_4_4_4_4_REV */
-      1774, /* GL_UNSIGNED_SHORT_1_5_5_5_REV */
-      1771, /* GL_UNSIGNED_INT_8_8_8_8_REV */
-      1769, /* GL_UNSIGNED_INT_2_10_10_10_REV */
-      1709, /* GL_TEXTURE_MAX_CLAMP_S_SGIX */
-      1710, /* GL_TEXTURE_MAX_CLAMP_T_SGIX */
-      1708, /* GL_TEXTURE_MAX_CLAMP_R_SGIX */
-       946, /* GL_MIRRORED_REPEAT */
-      1369, /* GL_RGB_S3TC */
-      1344, /* GL_RGB4_S3TC */
-      1367, /* GL_RGBA_S3TC */
-      1361, /* GL_RGBA4_S3TC */
-      1365, /* GL_RGBA_DXT5_S3TC */
-      1359, /* GL_RGBA4_DXT5_S3TC */
+      1875, /* GL_WRAP_BORDER_SUN */
+      1660, /* GL_TEXTURE_COLOR_WRITEMASK_SGIS */
+       690, /* GL_LIGHT_MODEL_COLOR_CONTROL */
+      1444, /* GL_SINGLE_COLOR */
+      1430, /* GL_SEPARATE_SPECULAR_COLOR */
+      1439, /* GL_SHARED_TEXTURE_PALETTE_EXT */
+       543, /* GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */
+       544, /* GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */
+       551, /* GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */
+       546, /* GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */
+       542, /* GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */
+       541, /* GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */
+       545, /* GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */
+       552, /* GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */
+       564, /* GL_FRAMEBUFFER_DEFAULT */
+       580, /* GL_FRAMEBUFFER_UNDEFINED */
+       373, /* GL_DEPTH_STENCIL_ATTACHMENT */
+       630, /* GL_INDEX */
+      1784, /* GL_UNSIGNED_BYTE_2_3_3_REV */
+      1800, /* GL_UNSIGNED_SHORT_5_6_5 */
+      1801, /* GL_UNSIGNED_SHORT_5_6_5_REV */
+      1798, /* GL_UNSIGNED_SHORT_4_4_4_4_REV */
+      1796, /* GL_UNSIGNED_SHORT_1_5_5_5_REV */
+      1793, /* GL_UNSIGNED_INT_8_8_8_8_REV */
+      1791, /* GL_UNSIGNED_INT_2_10_10_10_REV */
+      1730, /* GL_TEXTURE_MAX_CLAMP_S_SGIX */
+      1731, /* GL_TEXTURE_MAX_CLAMP_T_SGIX */
+      1729, /* GL_TEXTURE_MAX_CLAMP_R_SGIX */
+       956, /* GL_MIRRORED_REPEAT */
+      1386, /* GL_RGB_S3TC */
+      1361, /* GL_RGB4_S3TC */
+      1384, /* GL_RGBA_S3TC */
+      1378, /* GL_RGBA4_S3TC */
+      1382, /* GL_RGBA_DXT5_S3TC */
+      1376, /* GL_RGBA4_DXT5_S3TC */
        264, /* GL_COMPRESSED_RGB_S3TC_DXT1_EXT */
        259, /* GL_COMPRESSED_RGBA_S3TC_DXT1_EXT */
        260, /* GL_COMPRESSED_RGBA_S3TC_DXT3_EXT */
        261, /* GL_COMPRESSED_RGBA_S3TC_DXT5_EXT */
-      1007, /* GL_NEAREST_CLIPMAP_NEAREST_SGIX */
-      1006, /* GL_NEAREST_CLIPMAP_LINEAR_SGIX */
-       691, /* GL_LINEAR_CLIPMAP_NEAREST_SGIX */
-       516, /* GL_FOG_COORDINATE_SOURCE */
-       508, /* GL_FOG_COORD */
-       532, /* GL_FRAGMENT_DEPTH */
+      1017, /* GL_NEAREST_CLIPMAP_NEAREST_SGIX */
+      1016, /* GL_NEAREST_CLIPMAP_LINEAR_SGIX */
+       698, /* GL_LINEAR_CLIPMAP_NEAREST_SGIX */
+       519, /* GL_FOG_COORDINATE_SOURCE */
+       511, /* GL_FOG_COORD */
+       535, /* GL_FRAGMENT_DEPTH */
        312, /* GL_CURRENT_FOG_COORD */
-       515, /* GL_FOG_COORDINATE_ARRAY_TYPE */
-       514, /* GL_FOG_COORDINATE_ARRAY_STRIDE */
-       513, /* GL_FOG_COORDINATE_ARRAY_POINTER */
-       510, /* GL_FOG_COORDINATE_ARRAY */
+       518, /* GL_FOG_COORDINATE_ARRAY_TYPE */
+       517, /* GL_FOG_COORDINATE_ARRAY_STRIDE */
+       516, /* GL_FOG_COORDINATE_ARRAY_POINTER */
+       513, /* GL_FOG_COORDINATE_ARRAY */
        199, /* GL_COLOR_SUM */
        332, /* GL_CURRENT_SECONDARY_COLOR */
-      1406, /* GL_SECONDARY_COLOR_ARRAY_SIZE */
-      1408, /* GL_SECONDARY_COLOR_ARRAY_TYPE */
-      1407, /* GL_SECONDARY_COLOR_ARRAY_STRIDE */
-      1405, /* GL_SECONDARY_COLOR_ARRAY_POINTER */
-      1402, /* GL_SECONDARY_COLOR_ARRAY */
+      1423, /* GL_SECONDARY_COLOR_ARRAY_SIZE */
+      1425, /* GL_SECONDARY_COLOR_ARRAY_TYPE */
+      1424, /* GL_SECONDARY_COLOR_ARRAY_STRIDE */
+      1422, /* GL_SECONDARY_COLOR_ARRAY_POINTER */
+      1419, /* GL_SECONDARY_COLOR_ARRAY */
        330, /* GL_CURRENT_RASTER_SECONDARY_COLOR */
         28, /* GL_ALIASED_POINT_SIZE_RANGE */
         27, /* GL_ALIASED_LINE_WIDTH_RANGE */
-      1546, /* GL_TEXTURE0 */
-      1548, /* GL_TEXTURE1 */
-      1570, /* GL_TEXTURE2 */
-      1592, /* GL_TEXTURE3 */
-      1598, /* GL_TEXTURE4 */
-      1600, /* GL_TEXTURE5 */
-      1602, /* GL_TEXTURE6 */
-      1604, /* GL_TEXTURE7 */
-      1606, /* GL_TEXTURE8 */
-      1608, /* GL_TEXTURE9 */
-      1549, /* GL_TEXTURE10 */
-      1551, /* GL_TEXTURE11 */
-      1553, /* GL_TEXTURE12 */
-      1555, /* GL_TEXTURE13 */
-      1557, /* GL_TEXTURE14 */
-      1559, /* GL_TEXTURE15 */
-      1561, /* GL_TEXTURE16 */
-      1563, /* GL_TEXTURE17 */
-      1565, /* GL_TEXTURE18 */
-      1567, /* GL_TEXTURE19 */
-      1571, /* GL_TEXTURE20 */
-      1573, /* GL_TEXTURE21 */
-      1575, /* GL_TEXTURE22 */
-      1577, /* GL_TEXTURE23 */
-      1579, /* GL_TEXTURE24 */
-      1581, /* GL_TEXTURE25 */
-      1583, /* GL_TEXTURE26 */
-      1585, /* GL_TEXTURE27 */
-      1587, /* GL_TEXTURE28 */
-      1589, /* GL_TEXTURE29 */
-      1593, /* GL_TEXTURE30 */
-      1595, /* GL_TEXTURE31 */
+      1567, /* GL_TEXTURE0 */
+      1569, /* GL_TEXTURE1 */
+      1591, /* GL_TEXTURE2 */
+      1613, /* GL_TEXTURE3 */
+      1619, /* GL_TEXTURE4 */
+      1621, /* GL_TEXTURE5 */
+      1623, /* GL_TEXTURE6 */
+      1625, /* GL_TEXTURE7 */
+      1627, /* GL_TEXTURE8 */
+      1629, /* GL_TEXTURE9 */
+      1570, /* GL_TEXTURE10 */
+      1572, /* GL_TEXTURE11 */
+      1574, /* GL_TEXTURE12 */
+      1576, /* GL_TEXTURE13 */
+      1578, /* GL_TEXTURE14 */
+      1580, /* GL_TEXTURE15 */
+      1582, /* GL_TEXTURE16 */
+      1584, /* GL_TEXTURE17 */
+      1586, /* GL_TEXTURE18 */
+      1588, /* GL_TEXTURE19 */
+      1592, /* GL_TEXTURE20 */
+      1594, /* GL_TEXTURE21 */
+      1596, /* GL_TEXTURE22 */
+      1598, /* GL_TEXTURE23 */
+      1600, /* GL_TEXTURE24 */
+      1602, /* GL_TEXTURE25 */
+      1604, /* GL_TEXTURE26 */
+      1606, /* GL_TEXTURE27 */
+      1608, /* GL_TEXTURE28 */
+      1610, /* GL_TEXTURE29 */
+      1614, /* GL_TEXTURE30 */
+      1616, /* GL_TEXTURE31 */
         18, /* GL_ACTIVE_TEXTURE */
        133, /* GL_CLIENT_ACTIVE_TEXTURE */
-       924, /* GL_MAX_TEXTURE_UNITS */
-      1741, /* GL_TRANSPOSE_MODELVIEW_MATRIX */
-      1744, /* GL_TRANSPOSE_PROJECTION_MATRIX */
-      1746, /* GL_TRANSPOSE_TEXTURE_MATRIX */
-      1738, /* GL_TRANSPOSE_COLOR_MATRIX */
-      1528, /* GL_SUBTRACT */
-       911, /* GL_MAX_RENDERBUFFER_SIZE_EXT */
+       934, /* GL_MAX_TEXTURE_UNITS */
+      1762, /* GL_TRANSPOSE_MODELVIEW_MATRIX */
+      1765, /* GL_TRANSPOSE_PROJECTION_MATRIX */
+      1767, /* GL_TRANSPOSE_TEXTURE_MATRIX */
+      1759, /* GL_TRANSPOSE_COLOR_MATRIX */
+      1549, /* GL_SUBTRACT */
+       919, /* GL_MAX_RENDERBUFFER_SIZE */
        247, /* GL_COMPRESSED_ALPHA */
        251, /* GL_COMPRESSED_LUMINANCE */
        252, /* GL_COMPRESSED_LUMINANCE_ALPHA */
        249, /* GL_COMPRESSED_INTENSITY */
        255, /* GL_COMPRESSED_RGB */
        256, /* GL_COMPRESSED_RGBA */
-      1653, /* GL_TEXTURE_COMPRESSION_HINT */
-      1718, /* GL_TEXTURE_RECTANGLE_ARB */
-      1625, /* GL_TEXTURE_BINDING_RECTANGLE_ARB */
-      1271, /* GL_PROXY_TEXTURE_RECTANGLE_ARB */
-       909, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB */
-       371, /* GL_DEPTH_STENCIL */
-      1767, /* GL_UNSIGNED_INT_24_8 */
-       920, /* GL_MAX_TEXTURE_LOD_BIAS */
-      1707, /* GL_TEXTURE_MAX_ANISOTROPY_EXT */
-       921, /* GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT */
-      1683, /* GL_TEXTURE_FILTER_CONTROL */
-      1698, /* GL_TEXTURE_LOD_BIAS */
+      1674, /* GL_TEXTURE_COMPRESSION_HINT */
+      1739, /* GL_TEXTURE_RECTANGLE_ARB */
+      1646, /* GL_TEXTURE_BINDING_RECTANGLE_ARB */
+      1281, /* GL_PROXY_TEXTURE_RECTANGLE_ARB */
+       917, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB */
+       372, /* GL_DEPTH_STENCIL */
+      1788, /* GL_UNSIGNED_INT_24_8 */
+       930, /* GL_MAX_TEXTURE_LOD_BIAS */
+      1728, /* GL_TEXTURE_MAX_ANISOTROPY_EXT */
+       931, /* GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT */
+      1704, /* GL_TEXTURE_FILTER_CONTROL */
+      1719, /* GL_TEXTURE_LOD_BIAS */
        232, /* GL_COMBINE4 */
-       914, /* GL_MAX_SHININESS_NV */
-       915, /* GL_MAX_SPOT_EXPONENT_NV */
-       621, /* GL_INCR_WRAP */
+       924, /* GL_MAX_SHININESS_NV */
+       925, /* GL_MAX_SPOT_EXPONENT_NV */
+       628, /* GL_INCR_WRAP */
        343, /* GL_DECR_WRAP */
-       966, /* GL_MODELVIEW1_ARB */
-      1022, /* GL_NORMAL_MAP */
-      1303, /* GL_REFLECTION_MAP */
-      1662, /* GL_TEXTURE_CUBE_MAP */
-      1623, /* GL_TEXTURE_BINDING_CUBE_MAP */
-      1670, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X */
-      1664, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X */
-      1672, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y */
-      1666, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y */
-      1674, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z */
-      1668, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z */
-      1269, /* GL_PROXY_TEXTURE_CUBE_MAP */
-       865, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE */
-      1001, /* GL_MULTISAMPLE_FILTER_HINT_NV */
-       524, /* GL_FOG_DISTANCE_MODE_NV */
-       475, /* GL_EYE_RADIAL_NV */
-       474, /* GL_EYE_PLANE_ABSOLUTE_NV */
+       976, /* GL_MODELVIEW1_ARB */
+      1032, /* GL_NORMAL_MAP */
+      1318, /* GL_REFLECTION_MAP */
+      1683, /* GL_TEXTURE_CUBE_MAP */
+      1644, /* GL_TEXTURE_BINDING_CUBE_MAP */
+      1691, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X */
+      1685, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X */
+      1693, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y */
+      1687, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y */
+      1695, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z */
+      1689, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z */
+      1279, /* GL_PROXY_TEXTURE_CUBE_MAP */
+       873, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE */
+      1011, /* GL_MULTISAMPLE_FILTER_HINT_NV */
+       527, /* GL_FOG_DISTANCE_MODE_NV */
+       478, /* GL_EYE_RADIAL_NV */
+       477, /* GL_EYE_PLANE_ABSOLUTE_NV */
        231, /* GL_COMBINE */
        238, /* GL_COMBINE_RGB */
        233, /* GL_COMBINE_ALPHA */
-      1370, /* GL_RGB_SCALE */
+      1387, /* GL_RGB_SCALE */
         24, /* GL_ADD_SIGNED */
-       649, /* GL_INTERPOLATE */
+       656, /* GL_INTERPOLATE */
        271, /* GL_CONSTANT */
-      1217, /* GL_PRIMARY_COLOR */
-      1214, /* GL_PREVIOUS */
-      1442, /* GL_SOURCE0_RGB */
-      1448, /* GL_SOURCE1_RGB */
-      1454, /* GL_SOURCE2_RGB */
-      1458, /* GL_SOURCE3_RGB_NV */
-      1439, /* GL_SOURCE0_ALPHA */
-      1445, /* GL_SOURCE1_ALPHA */
-      1451, /* GL_SOURCE2_ALPHA */
-      1457, /* GL_SOURCE3_ALPHA_NV */
-      1059, /* GL_OPERAND0_RGB */
-      1065, /* GL_OPERAND1_RGB */
-      1071, /* GL_OPERAND2_RGB */
-      1075, /* GL_OPERAND3_RGB_NV */
-      1056, /* GL_OPERAND0_ALPHA */
-      1062, /* GL_OPERAND1_ALPHA */
-      1068, /* GL_OPERAND2_ALPHA */
-      1074, /* GL_OPERAND3_ALPHA_NV */
-      1791, /* GL_VERTEX_ARRAY_BINDING */
-      1716, /* GL_TEXTURE_RANGE_LENGTH_APPLE */
-      1717, /* GL_TEXTURE_RANGE_POINTER_APPLE */
-      1857, /* GL_YCBCR_422_APPLE */
-      1780, /* GL_UNSIGNED_SHORT_8_8_APPLE */
-      1782, /* GL_UNSIGNED_SHORT_8_8_REV_APPLE */
-      1725, /* GL_TEXTURE_STORAGE_HINT_APPLE */
-      1519, /* GL_STORAGE_PRIVATE_APPLE */
-      1518, /* GL_STORAGE_CACHED_APPLE */
-      1520, /* GL_STORAGE_SHARED_APPLE */
-      1429, /* GL_SLICE_ACCUM_SUN */
-      1278, /* GL_QUAD_MESH_SUN */
-      1750, /* GL_TRIANGLE_MESH_SUN */
-      1830, /* GL_VERTEX_PROGRAM_ARB */
-      1841, /* GL_VERTEX_STATE_PROGRAM_NV */
-      1817, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED */
-      1823, /* GL_VERTEX_ATTRIB_ARRAY_SIZE */
-      1825, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE */
-      1827, /* GL_VERTEX_ATTRIB_ARRAY_TYPE */
+      1227, /* GL_PRIMARY_COLOR */
+      1224, /* GL_PREVIOUS */
+      1459, /* GL_SOURCE0_RGB */
+      1465, /* GL_SOURCE1_RGB */
+      1471, /* GL_SOURCE2_RGB */
+      1475, /* GL_SOURCE3_RGB_NV */
+      1456, /* GL_SOURCE0_ALPHA */
+      1462, /* GL_SOURCE1_ALPHA */
+      1468, /* GL_SOURCE2_ALPHA */
+      1474, /* GL_SOURCE3_ALPHA_NV */
+      1069, /* GL_OPERAND0_RGB */
+      1075, /* GL_OPERAND1_RGB */
+      1081, /* GL_OPERAND2_RGB */
+      1085, /* GL_OPERAND3_RGB_NV */
+      1066, /* GL_OPERAND0_ALPHA */
+      1072, /* GL_OPERAND1_ALPHA */
+      1078, /* GL_OPERAND2_ALPHA */
+      1084, /* GL_OPERAND3_ALPHA_NV */
+      1813, /* GL_VERTEX_ARRAY_BINDING */
+      1737, /* GL_TEXTURE_RANGE_LENGTH_APPLE */
+      1738, /* GL_TEXTURE_RANGE_POINTER_APPLE */
+      1879, /* GL_YCBCR_422_APPLE */
+      1802, /* GL_UNSIGNED_SHORT_8_8_APPLE */
+      1804, /* GL_UNSIGNED_SHORT_8_8_REV_APPLE */
+      1747, /* GL_TEXTURE_STORAGE_HINT_APPLE */
+      1540, /* GL_STORAGE_PRIVATE_APPLE */
+      1539, /* GL_STORAGE_CACHED_APPLE */
+      1541, /* GL_STORAGE_SHARED_APPLE */
+      1446, /* GL_SLICE_ACCUM_SUN */
+      1288, /* GL_QUAD_MESH_SUN */
+      1771, /* GL_TRIANGLE_MESH_SUN */
+      1852, /* GL_VERTEX_PROGRAM_ARB */
+      1863, /* GL_VERTEX_STATE_PROGRAM_NV */
+      1839, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED */
+      1845, /* GL_VERTEX_ATTRIB_ARRAY_SIZE */
+      1847, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE */
+      1849, /* GL_VERTEX_ATTRIB_ARRAY_TYPE */
        334, /* GL_CURRENT_VERTEX_ATTRIB */
-      1230, /* GL_PROGRAM_LENGTH_ARB */
-      1244, /* GL_PROGRAM_STRING_ARB */
-       988, /* GL_MODELVIEW_PROJECTION_NV */
-       616, /* GL_IDENTITY_NV */
-       663, /* GL_INVERSE_NV */
-      1743, /* GL_TRANSPOSE_NV */
-       664, /* GL_INVERSE_TRANSPOSE_NV */
-       895, /* GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB */
-       894, /* GL_MAX_PROGRAM_MATRICES_ARB */
-       802, /* GL_MATRIX0_NV */
-       814, /* GL_MATRIX1_NV */
-       826, /* GL_MATRIX2_NV */
-       830, /* GL_MATRIX3_NV */
-       832, /* GL_MATRIX4_NV */
-       834, /* GL_MATRIX5_NV */
-       836, /* GL_MATRIX6_NV */
-       838, /* GL_MATRIX7_NV */
+      1240, /* GL_PROGRAM_LENGTH_ARB */
+      1254, /* GL_PROGRAM_STRING_ARB */
+       998, /* GL_MODELVIEW_PROJECTION_NV */
+       623, /* GL_IDENTITY_NV */
+       670, /* GL_INVERSE_NV */
+      1764, /* GL_TRANSPOSE_NV */
+       671, /* GL_INVERSE_TRANSPOSE_NV */
+       903, /* GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB */
+       902, /* GL_MAX_PROGRAM_MATRICES_ARB */
+       809, /* GL_MATRIX0_NV */
+       821, /* GL_MATRIX1_NV */
+       833, /* GL_MATRIX2_NV */
+       837, /* GL_MATRIX3_NV */
+       839, /* GL_MATRIX4_NV */
+       841, /* GL_MATRIX5_NV */
+       843, /* GL_MATRIX6_NV */
+       845, /* GL_MATRIX7_NV */
        318, /* GL_CURRENT_MATRIX_STACK_DEPTH_ARB */
        315, /* GL_CURRENT_MATRIX_ARB */
-      1833, /* GL_VERTEX_PROGRAM_POINT_SIZE */
-      1836, /* GL_VERTEX_PROGRAM_TWO_SIDE */
-      1242, /* GL_PROGRAM_PARAMETER_NV */
-      1821, /* GL_VERTEX_ATTRIB_ARRAY_POINTER */
-      1246, /* GL_PROGRAM_TARGET_NV */
-      1243, /* GL_PROGRAM_RESIDENT_NV */
-      1735, /* GL_TRACK_MATRIX_NV */
-      1736, /* GL_TRACK_MATRIX_TRANSFORM_NV */
-      1831, /* GL_VERTEX_PROGRAM_BINDING_NV */
-      1224, /* GL_PROGRAM_ERROR_POSITION_ARB */
-       355, /* GL_DEPTH_CLAMP */
-      1799, /* GL_VERTEX_ATTRIB_ARRAY0_NV */
-      1806, /* GL_VERTEX_ATTRIB_ARRAY1_NV */
-      1807, /* GL_VERTEX_ATTRIB_ARRAY2_NV */
-      1808, /* GL_VERTEX_ATTRIB_ARRAY3_NV */
-      1809, /* GL_VERTEX_ATTRIB_ARRAY4_NV */
-      1810, /* GL_VERTEX_ATTRIB_ARRAY5_NV */
-      1811, /* GL_VERTEX_ATTRIB_ARRAY6_NV */
-      1812, /* GL_VERTEX_ATTRIB_ARRAY7_NV */
-      1813, /* GL_VERTEX_ATTRIB_ARRAY8_NV */
-      1814, /* GL_VERTEX_ATTRIB_ARRAY9_NV */
-      1800, /* GL_VERTEX_ATTRIB_ARRAY10_NV */
-      1801, /* GL_VERTEX_ATTRIB_ARRAY11_NV */
-      1802, /* GL_VERTEX_ATTRIB_ARRAY12_NV */
-      1803, /* GL_VERTEX_ATTRIB_ARRAY13_NV */
-      1804, /* GL_VERTEX_ATTRIB_ARRAY14_NV */
-      1805, /* GL_VERTEX_ATTRIB_ARRAY15_NV */
-       750, /* GL_MAP1_VERTEX_ATTRIB0_4_NV */
-       757, /* GL_MAP1_VERTEX_ATTRIB1_4_NV */
-       758, /* GL_MAP1_VERTEX_ATTRIB2_4_NV */
-       759, /* GL_MAP1_VERTEX_ATTRIB3_4_NV */
-       760, /* GL_MAP1_VERTEX_ATTRIB4_4_NV */
-       761, /* GL_MAP1_VERTEX_ATTRIB5_4_NV */
-       762, /* GL_MAP1_VERTEX_ATTRIB6_4_NV */
-       763, /* GL_MAP1_VERTEX_ATTRIB7_4_NV */
-       764, /* GL_MAP1_VERTEX_ATTRIB8_4_NV */
-       765, /* GL_MAP1_VERTEX_ATTRIB9_4_NV */
-       751, /* GL_MAP1_VERTEX_ATTRIB10_4_NV */
-       752, /* GL_MAP1_VERTEX_ATTRIB11_4_NV */
-       753, /* GL_MAP1_VERTEX_ATTRIB12_4_NV */
-       754, /* GL_MAP1_VERTEX_ATTRIB13_4_NV */
-       755, /* GL_MAP1_VERTEX_ATTRIB14_4_NV */
-       756, /* GL_MAP1_VERTEX_ATTRIB15_4_NV */
-       777, /* GL_MAP2_VERTEX_ATTRIB0_4_NV */
-       784, /* GL_MAP2_VERTEX_ATTRIB1_4_NV */
-       785, /* GL_MAP2_VERTEX_ATTRIB2_4_NV */
-       786, /* GL_MAP2_VERTEX_ATTRIB3_4_NV */
-       787, /* GL_MAP2_VERTEX_ATTRIB4_4_NV */
-       788, /* GL_MAP2_VERTEX_ATTRIB5_4_NV */
-       789, /* GL_MAP2_VERTEX_ATTRIB6_4_NV */
-      1223, /* GL_PROGRAM_BINDING_ARB */
-       791, /* GL_MAP2_VERTEX_ATTRIB8_4_NV */
-       792, /* GL_MAP2_VERTEX_ATTRIB9_4_NV */
-       778, /* GL_MAP2_VERTEX_ATTRIB10_4_NV */
-       779, /* GL_MAP2_VERTEX_ATTRIB11_4_NV */
-       780, /* GL_MAP2_VERTEX_ATTRIB12_4_NV */
-       781, /* GL_MAP2_VERTEX_ATTRIB13_4_NV */
-       782, /* GL_MAP2_VERTEX_ATTRIB14_4_NV */
-       783, /* GL_MAP2_VERTEX_ATTRIB15_4_NV */
-      1651, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE */
-      1648, /* GL_TEXTURE_COMPRESSED */
-      1027, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS */
+      1855, /* GL_VERTEX_PROGRAM_POINT_SIZE */
+      1858, /* GL_VERTEX_PROGRAM_TWO_SIDE */
+      1252, /* GL_PROGRAM_PARAMETER_NV */
+      1843, /* GL_VERTEX_ATTRIB_ARRAY_POINTER */
+      1256, /* GL_PROGRAM_TARGET_NV */
+      1253, /* GL_PROGRAM_RESIDENT_NV */
+      1756, /* GL_TRACK_MATRIX_NV */
+      1757, /* GL_TRACK_MATRIX_TRANSFORM_NV */
+      1853, /* GL_VERTEX_PROGRAM_BINDING_NV */
+      1234, /* GL_PROGRAM_ERROR_POSITION_ARB */
+       356, /* GL_DEPTH_CLAMP */
+      1821, /* GL_VERTEX_ATTRIB_ARRAY0_NV */
+      1828, /* GL_VERTEX_ATTRIB_ARRAY1_NV */
+      1829, /* GL_VERTEX_ATTRIB_ARRAY2_NV */
+      1830, /* GL_VERTEX_ATTRIB_ARRAY3_NV */
+      1831, /* GL_VERTEX_ATTRIB_ARRAY4_NV */
+      1832, /* GL_VERTEX_ATTRIB_ARRAY5_NV */
+      1833, /* GL_VERTEX_ATTRIB_ARRAY6_NV */
+      1834, /* GL_VERTEX_ATTRIB_ARRAY7_NV */
+      1835, /* GL_VERTEX_ATTRIB_ARRAY8_NV */
+      1836, /* GL_VERTEX_ATTRIB_ARRAY9_NV */
+      1822, /* GL_VERTEX_ATTRIB_ARRAY10_NV */
+      1823, /* GL_VERTEX_ATTRIB_ARRAY11_NV */
+      1824, /* GL_VERTEX_ATTRIB_ARRAY12_NV */
+      1825, /* GL_VERTEX_ATTRIB_ARRAY13_NV */
+      1826, /* GL_VERTEX_ATTRIB_ARRAY14_NV */
+      1827, /* GL_VERTEX_ATTRIB_ARRAY15_NV */
+       757, /* GL_MAP1_VERTEX_ATTRIB0_4_NV */
+       764, /* GL_MAP1_VERTEX_ATTRIB1_4_NV */
+       765, /* GL_MAP1_VERTEX_ATTRIB2_4_NV */
+       766, /* GL_MAP1_VERTEX_ATTRIB3_4_NV */
+       767, /* GL_MAP1_VERTEX_ATTRIB4_4_NV */
+       768, /* GL_MAP1_VERTEX_ATTRIB5_4_NV */
+       769, /* GL_MAP1_VERTEX_ATTRIB6_4_NV */
+       770, /* GL_MAP1_VERTEX_ATTRIB7_4_NV */
+       771, /* GL_MAP1_VERTEX_ATTRIB8_4_NV */
+       772, /* GL_MAP1_VERTEX_ATTRIB9_4_NV */
+       758, /* GL_MAP1_VERTEX_ATTRIB10_4_NV */
+       759, /* GL_MAP1_VERTEX_ATTRIB11_4_NV */
+       760, /* GL_MAP1_VERTEX_ATTRIB12_4_NV */
+       761, /* GL_MAP1_VERTEX_ATTRIB13_4_NV */
+       762, /* GL_MAP1_VERTEX_ATTRIB14_4_NV */
+       763, /* GL_MAP1_VERTEX_ATTRIB15_4_NV */
+       784, /* GL_MAP2_VERTEX_ATTRIB0_4_NV */
+       791, /* GL_MAP2_VERTEX_ATTRIB1_4_NV */
+       792, /* GL_MAP2_VERTEX_ATTRIB2_4_NV */
+       793, /* GL_MAP2_VERTEX_ATTRIB3_4_NV */
+       794, /* GL_MAP2_VERTEX_ATTRIB4_4_NV */
+       795, /* GL_MAP2_VERTEX_ATTRIB5_4_NV */
+       796, /* GL_MAP2_VERTEX_ATTRIB6_4_NV */
+      1233, /* GL_PROGRAM_BINDING_ARB */
+       798, /* GL_MAP2_VERTEX_ATTRIB8_4_NV */
+       799, /* GL_MAP2_VERTEX_ATTRIB9_4_NV */
+       785, /* GL_MAP2_VERTEX_ATTRIB10_4_NV */
+       786, /* GL_MAP2_VERTEX_ATTRIB11_4_NV */
+       787, /* GL_MAP2_VERTEX_ATTRIB12_4_NV */
+       788, /* GL_MAP2_VERTEX_ATTRIB13_4_NV */
+       789, /* GL_MAP2_VERTEX_ATTRIB14_4_NV */
+       790, /* GL_MAP2_VERTEX_ATTRIB15_4_NV */
+      1672, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE */
+      1669, /* GL_TEXTURE_COMPRESSED */
+      1037, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS */
        269, /* GL_COMPRESSED_TEXTURE_FORMATS */
-       936, /* GL_MAX_VERTEX_UNITS_ARB */
+       946, /* GL_MAX_VERTEX_UNITS_ARB */
         22, /* GL_ACTIVE_VERTEX_UNITS_ARB */
-      1852, /* GL_WEIGHT_SUM_UNITY_ARB */
-      1829, /* GL_VERTEX_BLEND_ARB */
+      1874, /* GL_WEIGHT_SUM_UNITY_ARB */
+      1851, /* GL_VERTEX_BLEND_ARB */
        336, /* GL_CURRENT_WEIGHT_ARB */
-      1851, /* GL_WEIGHT_ARRAY_TYPE_ARB */
-      1850, /* GL_WEIGHT_ARRAY_STRIDE_ARB */
-      1849, /* GL_WEIGHT_ARRAY_SIZE_ARB */
-      1848, /* GL_WEIGHT_ARRAY_POINTER_ARB */
-      1845, /* GL_WEIGHT_ARRAY_ARB */
-       384, /* GL_DOT3_RGB */
-       385, /* GL_DOT3_RGBA */
+      1873, /* GL_WEIGHT_ARRAY_TYPE_ARB */
+      1872, /* GL_WEIGHT_ARRAY_STRIDE_ARB */
+      1871, /* GL_WEIGHT_ARRAY_SIZE_ARB */
+      1870, /* GL_WEIGHT_ARRAY_POINTER_ARB */
+      1867, /* GL_WEIGHT_ARRAY_ARB */
+       386, /* GL_DOT3_RGB */
+       387, /* GL_DOT3_RGBA */
        263, /* GL_COMPRESSED_RGB_FXT1_3DFX */
        258, /* GL_COMPRESSED_RGBA_FXT1_3DFX */
-       996, /* GL_MULTISAMPLE_3DFX */
-      1391, /* GL_SAMPLE_BUFFERS_3DFX */
-      1382, /* GL_SAMPLES_3DFX */
-       977, /* GL_MODELVIEW2_ARB */
-       980, /* GL_MODELVIEW3_ARB */
-       981, /* GL_MODELVIEW4_ARB */
-       982, /* GL_MODELVIEW5_ARB */
-       983, /* GL_MODELVIEW6_ARB */
-       984, /* GL_MODELVIEW7_ARB */
-       985, /* GL_MODELVIEW8_ARB */
-       986, /* GL_MODELVIEW9_ARB */
-       956, /* GL_MODELVIEW10_ARB */
-       957, /* GL_MODELVIEW11_ARB */
-       958, /* GL_MODELVIEW12_ARB */
-       959, /* GL_MODELVIEW13_ARB */
-       960, /* GL_MODELVIEW14_ARB */
-       961, /* GL_MODELVIEW15_ARB */
-       962, /* GL_MODELVIEW16_ARB */
-       963, /* GL_MODELVIEW17_ARB */
-       964, /* GL_MODELVIEW18_ARB */
-       965, /* GL_MODELVIEW19_ARB */
-       967, /* GL_MODELVIEW20_ARB */
-       968, /* GL_MODELVIEW21_ARB */
-       969, /* GL_MODELVIEW22_ARB */
-       970, /* GL_MODELVIEW23_ARB */
-       971, /* GL_MODELVIEW24_ARB */
-       972, /* GL_MODELVIEW25_ARB */
-       973, /* GL_MODELVIEW26_ARB */
-       974, /* GL_MODELVIEW27_ARB */
-       975, /* GL_MODELVIEW28_ARB */
-       976, /* GL_MODELVIEW29_ARB */
-       978, /* GL_MODELVIEW30_ARB */
-       979, /* GL_MODELVIEW31_ARB */
-       389, /* GL_DOT3_RGB_EXT */
-       387, /* GL_DOT3_RGBA_EXT */
-       950, /* GL_MIRROR_CLAMP_EXT */
-       953, /* GL_MIRROR_CLAMP_TO_EDGE_EXT */
-       991, /* GL_MODULATE_ADD_ATI */
-       992, /* GL_MODULATE_SIGNED_ADD_ATI */
-       993, /* GL_MODULATE_SUBTRACT_ATI */
-      1858, /* GL_YCBCR_MESA */
-      1083, /* GL_PACK_INVERT_MESA */
+      1006, /* GL_MULTISAMPLE_3DFX */
+      1408, /* GL_SAMPLE_BUFFERS_3DFX */
+      1399, /* GL_SAMPLES_3DFX */
+       987, /* GL_MODELVIEW2_ARB */
+       990, /* GL_MODELVIEW3_ARB */
+       991, /* GL_MODELVIEW4_ARB */
+       992, /* GL_MODELVIEW5_ARB */
+       993, /* GL_MODELVIEW6_ARB */
+       994, /* GL_MODELVIEW7_ARB */
+       995, /* GL_MODELVIEW8_ARB */
+       996, /* GL_MODELVIEW9_ARB */
+       966, /* GL_MODELVIEW10_ARB */
+       967, /* GL_MODELVIEW11_ARB */
+       968, /* GL_MODELVIEW12_ARB */
+       969, /* GL_MODELVIEW13_ARB */
+       970, /* GL_MODELVIEW14_ARB */
+       971, /* GL_MODELVIEW15_ARB */
+       972, /* GL_MODELVIEW16_ARB */
+       973, /* GL_MODELVIEW17_ARB */
+       974, /* GL_MODELVIEW18_ARB */
+       975, /* GL_MODELVIEW19_ARB */
+       977, /* GL_MODELVIEW20_ARB */
+       978, /* GL_MODELVIEW21_ARB */
+       979, /* GL_MODELVIEW22_ARB */
+       980, /* GL_MODELVIEW23_ARB */
+       981, /* GL_MODELVIEW24_ARB */
+       982, /* GL_MODELVIEW25_ARB */
+       983, /* GL_MODELVIEW26_ARB */
+       984, /* GL_MODELVIEW27_ARB */
+       985, /* GL_MODELVIEW28_ARB */
+       986, /* GL_MODELVIEW29_ARB */
+       988, /* GL_MODELVIEW30_ARB */
+       989, /* GL_MODELVIEW31_ARB */
+       391, /* GL_DOT3_RGB_EXT */
+       389, /* GL_DOT3_RGBA_EXT */
+       960, /* GL_MIRROR_CLAMP_EXT */
+       963, /* GL_MIRROR_CLAMP_TO_EDGE_EXT */
+      1001, /* GL_MODULATE_ADD_ATI */
+      1002, /* GL_MODULATE_SIGNED_ADD_ATI */
+      1003, /* GL_MODULATE_SUBTRACT_ATI */
+      1880, /* GL_YCBCR_MESA */
+      1093, /* GL_PACK_INVERT_MESA */
        339, /* GL_DEBUG_OBJECT_MESA */
        340, /* GL_DEBUG_PRINT_MESA */
        338, /* GL_DEBUG_ASSERT_MESA */
@@ -4762,292 +4806,292 @@ static const unsigned reduced_enums[1347] =
        117, /* GL_BUMP_ROT_MATRIX_SIZE_ATI */
        115, /* GL_BUMP_NUM_TEX_UNITS_ATI */
        119, /* GL_BUMP_TEX_UNITS_ATI */
-       448, /* GL_DUDV_ATI */
-       447, /* GL_DU8DV8_ATI */
+       451, /* GL_DUDV_ATI */
+       450, /* GL_DU8DV8_ATI */
        114, /* GL_BUMP_ENVMAP_ATI */
        118, /* GL_BUMP_TARGET_ATI */
-      1490, /* GL_STENCIL_BACK_FUNC */
-      1488, /* GL_STENCIL_BACK_FAIL */
-      1492, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL */
-      1494, /* GL_STENCIL_BACK_PASS_DEPTH_PASS */
-       533, /* GL_FRAGMENT_PROGRAM_ARB */
-      1221, /* GL_PROGRAM_ALU_INSTRUCTIONS_ARB */
-      1249, /* GL_PROGRAM_TEX_INSTRUCTIONS_ARB */
-      1248, /* GL_PROGRAM_TEX_INDIRECTIONS_ARB */
-      1233, /* GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */
-      1239, /* GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */
-      1238, /* GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */
-       884, /* GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB */
-       907, /* GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB */
-       906, /* GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB */
-       897, /* GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */
-       903, /* GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */
-       902, /* GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */
-       867, /* GL_MAX_DRAW_BUFFERS */
-       393, /* GL_DRAW_BUFFER0 */
-       396, /* GL_DRAW_BUFFER1 */
-       417, /* GL_DRAW_BUFFER2 */
-       420, /* GL_DRAW_BUFFER3 */
-       423, /* GL_DRAW_BUFFER4 */
-       426, /* GL_DRAW_BUFFER5 */
-       429, /* GL_DRAW_BUFFER6 */
-       432, /* GL_DRAW_BUFFER7 */
-       435, /* GL_DRAW_BUFFER8 */
-       438, /* GL_DRAW_BUFFER9 */
-       397, /* GL_DRAW_BUFFER10 */
-       400, /* GL_DRAW_BUFFER11 */
-       403, /* GL_DRAW_BUFFER12 */
-       406, /* GL_DRAW_BUFFER13 */
-       409, /* GL_DRAW_BUFFER14 */
-       412, /* GL_DRAW_BUFFER15 */
+      1507, /* GL_STENCIL_BACK_FUNC */
+      1505, /* GL_STENCIL_BACK_FAIL */
+      1509, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL */
+      1511, /* GL_STENCIL_BACK_PASS_DEPTH_PASS */
+       536, /* GL_FRAGMENT_PROGRAM_ARB */
+      1231, /* GL_PROGRAM_ALU_INSTRUCTIONS_ARB */
+      1259, /* GL_PROGRAM_TEX_INSTRUCTIONS_ARB */
+      1258, /* GL_PROGRAM_TEX_INDIRECTIONS_ARB */
+      1243, /* GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */
+      1249, /* GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */
+      1248, /* GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */
+       892, /* GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB */
+       915, /* GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB */
+       914, /* GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB */
+       905, /* GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */
+       911, /* GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */
+       910, /* GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */
+       875, /* GL_MAX_DRAW_BUFFERS */
+       395, /* GL_DRAW_BUFFER0 */
+       398, /* GL_DRAW_BUFFER1 */
+       419, /* GL_DRAW_BUFFER2 */
+       422, /* GL_DRAW_BUFFER3 */
+       425, /* GL_DRAW_BUFFER4 */
+       428, /* GL_DRAW_BUFFER5 */
+       431, /* GL_DRAW_BUFFER6 */
+       434, /* GL_DRAW_BUFFER7 */
+       437, /* GL_DRAW_BUFFER8 */
+       440, /* GL_DRAW_BUFFER9 */
+       399, /* GL_DRAW_BUFFER10 */
+       402, /* GL_DRAW_BUFFER11 */
+       405, /* GL_DRAW_BUFFER12 */
+       408, /* GL_DRAW_BUFFER13 */
+       411, /* GL_DRAW_BUFFER14 */
+       414, /* GL_DRAW_BUFFER15 */
         82, /* GL_BLEND_EQUATION_ALPHA */
-       847, /* GL_MATRIX_PALETTE_ARB */
-       878, /* GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB */
-       881, /* GL_MAX_PALETTE_MATRICES_ARB */
+       854, /* GL_MATRIX_PALETTE_ARB */
+       886, /* GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB */
+       889, /* GL_MAX_PALETTE_MATRICES_ARB */
        321, /* GL_CURRENT_PALETTE_MATRIX_ARB */
-       841, /* GL_MATRIX_INDEX_ARRAY_ARB */
+       848, /* GL_MATRIX_INDEX_ARRAY_ARB */
        316, /* GL_CURRENT_MATRIX_INDEX_ARB */
-       843, /* GL_MATRIX_INDEX_ARRAY_SIZE_ARB */
-       845, /* GL_MATRIX_INDEX_ARRAY_TYPE_ARB */
-       844, /* GL_MATRIX_INDEX_ARRAY_STRIDE_ARB */
-       842, /* GL_MATRIX_INDEX_ARRAY_POINTER_ARB */
-      1678, /* GL_TEXTURE_DEPTH_SIZE */
-       377, /* GL_DEPTH_TEXTURE_MODE */
-      1643, /* GL_TEXTURE_COMPARE_MODE */
-      1641, /* GL_TEXTURE_COMPARE_FUNC */
+       850, /* GL_MATRIX_INDEX_ARRAY_SIZE_ARB */
+       852, /* GL_MATRIX_INDEX_ARRAY_TYPE_ARB */
+       851, /* GL_MATRIX_INDEX_ARRAY_STRIDE_ARB */
+       849, /* GL_MATRIX_INDEX_ARRAY_POINTER_ARB */
+      1699, /* GL_TEXTURE_DEPTH_SIZE */
+       379, /* GL_DEPTH_TEXTURE_MODE */
+      1664, /* GL_TEXTURE_COMPARE_MODE */
+      1662, /* GL_TEXTURE_COMPARE_FUNC */
        242, /* GL_COMPARE_R_TO_TEXTURE */
-      1155, /* GL_POINT_SPRITE */
+      1165, /* GL_POINT_SPRITE */
        296, /* GL_COORD_REPLACE */
-      1159, /* GL_POINT_SPRITE_R_MODE_NV */
-      1280, /* GL_QUERY_COUNTER_BITS */
+      1169, /* GL_POINT_SPRITE_R_MODE_NV */
+      1292, /* GL_QUERY_COUNTER_BITS */
        323, /* GL_CURRENT_QUERY */
-      1282, /* GL_QUERY_RESULT */
-      1284, /* GL_QUERY_RESULT_AVAILABLE */
-       930, /* GL_MAX_VERTEX_ATTRIBS */
-      1819, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED */
-       375, /* GL_DEPTH_STENCIL_TO_RGBA_NV */
-       374, /* GL_DEPTH_STENCIL_TO_BGRA_NV */
-       916, /* GL_MAX_TEXTURE_COORDS */
-       918, /* GL_MAX_TEXTURE_IMAGE_UNITS */
-      1226, /* GL_PROGRAM_ERROR_STRING_ARB */
-      1228, /* GL_PROGRAM_FORMAT_ASCII_ARB */
-      1227, /* GL_PROGRAM_FORMAT_ARB */
-      1727, /* GL_TEXTURE_UNSIGNED_REMAP_MODE_NV */
-       353, /* GL_DEPTH_BOUNDS_TEST_EXT */
-       352, /* GL_DEPTH_BOUNDS_EXT */
+      1295, /* GL_QUERY_RESULT */
+      1297, /* GL_QUERY_RESULT_AVAILABLE */
+       940, /* GL_MAX_VERTEX_ATTRIBS */
+      1841, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED */
+       377, /* GL_DEPTH_STENCIL_TO_RGBA_NV */
+       376, /* GL_DEPTH_STENCIL_TO_BGRA_NV */
+       926, /* GL_MAX_TEXTURE_COORDS */
+       928, /* GL_MAX_TEXTURE_IMAGE_UNITS */
+      1236, /* GL_PROGRAM_ERROR_STRING_ARB */
+      1238, /* GL_PROGRAM_FORMAT_ASCII_ARB */
+      1237, /* GL_PROGRAM_FORMAT_ARB */
+      1749, /* GL_TEXTURE_UNSIGNED_REMAP_MODE_NV */
+       354, /* GL_DEPTH_BOUNDS_TEST_EXT */
+       353, /* GL_DEPTH_BOUNDS_EXT */
         53, /* GL_ARRAY_BUFFER */
-       461, /* GL_ELEMENT_ARRAY_BUFFER */
+       464, /* GL_ELEMENT_ARRAY_BUFFER */
         54, /* GL_ARRAY_BUFFER_BINDING */
-       462, /* GL_ELEMENT_ARRAY_BUFFER_BINDING */
-      1793, /* GL_VERTEX_ARRAY_BUFFER_BINDING */
-      1017, /* GL_NORMAL_ARRAY_BUFFER_BINDING */
+       465, /* GL_ELEMENT_ARRAY_BUFFER_BINDING */
+      1815, /* GL_VERTEX_ARRAY_BUFFER_BINDING */
+      1027, /* GL_NORMAL_ARRAY_BUFFER_BINDING */
        149, /* GL_COLOR_ARRAY_BUFFER_BINDING */
-       625, /* GL_INDEX_ARRAY_BUFFER_BINDING */
-      1656, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING */
-       457, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING */
-      1403, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING */
-       511, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING */
-      1846, /* GL_WEIGHT_ARRAY_BUFFER_BINDING */
-      1815, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING */
-      1229, /* GL_PROGRAM_INSTRUCTIONS_ARB */
-       890, /* GL_MAX_PROGRAM_INSTRUCTIONS_ARB */
-      1235, /* GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB */
-       899, /* GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB */
-      1247, /* GL_PROGRAM_TEMPORARIES_ARB */
-       905, /* GL_MAX_PROGRAM_TEMPORARIES_ARB */
-      1237, /* GL_PROGRAM_NATIVE_TEMPORARIES_ARB */
-       901, /* GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB */
-      1241, /* GL_PROGRAM_PARAMETERS_ARB */
-       904, /* GL_MAX_PROGRAM_PARAMETERS_ARB */
-      1236, /* GL_PROGRAM_NATIVE_PARAMETERS_ARB */
-       900, /* GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB */
-      1222, /* GL_PROGRAM_ATTRIBS_ARB */
-       885, /* GL_MAX_PROGRAM_ATTRIBS_ARB */
-      1234, /* GL_PROGRAM_NATIVE_ATTRIBS_ARB */
-       898, /* GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB */
-      1220, /* GL_PROGRAM_ADDRESS_REGISTERS_ARB */
-       883, /* GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB */
-      1232, /* GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */
-       896, /* GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */
-       891, /* GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB */
-       887, /* GL_MAX_PROGRAM_ENV_PARAMETERS_ARB */
-      1250, /* GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB */
-      1740, /* GL_TRANSPOSE_CURRENT_MATRIX_ARB */
-      1293, /* GL_READ_ONLY */
-      1854, /* GL_WRITE_ONLY */
-      1295, /* GL_READ_WRITE */
+       632, /* GL_INDEX_ARRAY_BUFFER_BINDING */
+      1677, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING */
+       460, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING */
+      1420, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING */
+       514, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING */
+      1868, /* GL_WEIGHT_ARRAY_BUFFER_BINDING */
+      1837, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING */
+      1239, /* GL_PROGRAM_INSTRUCTIONS_ARB */
+       898, /* GL_MAX_PROGRAM_INSTRUCTIONS_ARB */
+      1245, /* GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB */
+       907, /* GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB */
+      1257, /* GL_PROGRAM_TEMPORARIES_ARB */
+       913, /* GL_MAX_PROGRAM_TEMPORARIES_ARB */
+      1247, /* GL_PROGRAM_NATIVE_TEMPORARIES_ARB */
+       909, /* GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB */
+      1251, /* GL_PROGRAM_PARAMETERS_ARB */
+       912, /* GL_MAX_PROGRAM_PARAMETERS_ARB */
+      1246, /* GL_PROGRAM_NATIVE_PARAMETERS_ARB */
+       908, /* GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB */
+      1232, /* GL_PROGRAM_ATTRIBS_ARB */
+       893, /* GL_MAX_PROGRAM_ATTRIBS_ARB */
+      1244, /* GL_PROGRAM_NATIVE_ATTRIBS_ARB */
+       906, /* GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB */
+      1230, /* GL_PROGRAM_ADDRESS_REGISTERS_ARB */
+       891, /* GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB */
+      1242, /* GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */
+       904, /* GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */
+       899, /* GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB */
+       895, /* GL_MAX_PROGRAM_ENV_PARAMETERS_ARB */
+      1260, /* GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB */
+      1761, /* GL_TRANSPOSE_CURRENT_MATRIX_ARB */
+      1308, /* GL_READ_ONLY */
+      1876, /* GL_WRITE_ONLY */
+      1310, /* GL_READ_WRITE */
        102, /* GL_BUFFER_ACCESS */
        105, /* GL_BUFFER_MAPPED */
        107, /* GL_BUFFER_MAP_POINTER */
-      1734, /* GL_TIME_ELAPSED_EXT */
-       801, /* GL_MATRIX0_ARB */
-       813, /* GL_MATRIX1_ARB */
-       825, /* GL_MATRIX2_ARB */
-       829, /* GL_MATRIX3_ARB */
-       831, /* GL_MATRIX4_ARB */
-       833, /* GL_MATRIX5_ARB */
-       835, /* GL_MATRIX6_ARB */
-       837, /* GL_MATRIX7_ARB */
-       839, /* GL_MATRIX8_ARB */
-       840, /* GL_MATRIX9_ARB */
-       803, /* GL_MATRIX10_ARB */
-       804, /* GL_MATRIX11_ARB */
-       805, /* GL_MATRIX12_ARB */
-       806, /* GL_MATRIX13_ARB */
-       807, /* GL_MATRIX14_ARB */
-       808, /* GL_MATRIX15_ARB */
-       809, /* GL_MATRIX16_ARB */
-       810, /* GL_MATRIX17_ARB */
-       811, /* GL_MATRIX18_ARB */
-       812, /* GL_MATRIX19_ARB */
-       815, /* GL_MATRIX20_ARB */
-       816, /* GL_MATRIX21_ARB */
-       817, /* GL_MATRIX22_ARB */
-       818, /* GL_MATRIX23_ARB */
-       819, /* GL_MATRIX24_ARB */
-       820, /* GL_MATRIX25_ARB */
-       821, /* GL_MATRIX26_ARB */
-       822, /* GL_MATRIX27_ARB */
-       823, /* GL_MATRIX28_ARB */
-       824, /* GL_MATRIX29_ARB */
-       827, /* GL_MATRIX30_ARB */
-       828, /* GL_MATRIX31_ARB */
-      1523, /* GL_STREAM_DRAW */
-      1525, /* GL_STREAM_READ */
-      1521, /* GL_STREAM_COPY */
-      1481, /* GL_STATIC_DRAW */
-      1483, /* GL_STATIC_READ */
-      1479, /* GL_STATIC_COPY */
-       451, /* GL_DYNAMIC_DRAW */
-       453, /* GL_DYNAMIC_READ */
-       449, /* GL_DYNAMIC_COPY */
-      1123, /* GL_PIXEL_PACK_BUFFER */
-      1127, /* GL_PIXEL_UNPACK_BUFFER */
-      1124, /* GL_PIXEL_PACK_BUFFER_BINDING */
-      1128, /* GL_PIXEL_UNPACK_BUFFER_BINDING */
+      1755, /* GL_TIME_ELAPSED_EXT */
+       808, /* GL_MATRIX0_ARB */
+       820, /* GL_MATRIX1_ARB */
+       832, /* GL_MATRIX2_ARB */
+       836, /* GL_MATRIX3_ARB */
+       838, /* GL_MATRIX4_ARB */
+       840, /* GL_MATRIX5_ARB */
+       842, /* GL_MATRIX6_ARB */
+       844, /* GL_MATRIX7_ARB */
+       846, /* GL_MATRIX8_ARB */
+       847, /* GL_MATRIX9_ARB */
+       810, /* GL_MATRIX10_ARB */
+       811, /* GL_MATRIX11_ARB */
+       812, /* GL_MATRIX12_ARB */
+       813, /* GL_MATRIX13_ARB */
+       814, /* GL_MATRIX14_ARB */
+       815, /* GL_MATRIX15_ARB */
+       816, /* GL_MATRIX16_ARB */
+       817, /* GL_MATRIX17_ARB */
+       818, /* GL_MATRIX18_ARB */
+       819, /* GL_MATRIX19_ARB */
+       822, /* GL_MATRIX20_ARB */
+       823, /* GL_MATRIX21_ARB */
+       824, /* GL_MATRIX22_ARB */
+       825, /* GL_MATRIX23_ARB */
+       826, /* GL_MATRIX24_ARB */
+       827, /* GL_MATRIX25_ARB */
+       828, /* GL_MATRIX26_ARB */
+       829, /* GL_MATRIX27_ARB */
+       830, /* GL_MATRIX28_ARB */
+       831, /* GL_MATRIX29_ARB */
+       834, /* GL_MATRIX30_ARB */
+       835, /* GL_MATRIX31_ARB */
+      1544, /* GL_STREAM_DRAW */
+      1546, /* GL_STREAM_READ */
+      1542, /* GL_STREAM_COPY */
+      1498, /* GL_STATIC_DRAW */
+      1500, /* GL_STATIC_READ */
+      1496, /* GL_STATIC_COPY */
+       454, /* GL_DYNAMIC_DRAW */
+       456, /* GL_DYNAMIC_READ */
+       452, /* GL_DYNAMIC_COPY */
+      1133, /* GL_PIXEL_PACK_BUFFER */
+      1137, /* GL_PIXEL_UNPACK_BUFFER */
+      1134, /* GL_PIXEL_PACK_BUFFER_BINDING */
+      1138, /* GL_PIXEL_UNPACK_BUFFER_BINDING */
        347, /* GL_DEPTH24_STENCIL8 */
-      1724, /* GL_TEXTURE_STENCIL_SIZE */
-      1676, /* GL_TEXTURE_CUBE_MAP_SEAMLESS */
-       886, /* GL_MAX_PROGRAM_CALL_DEPTH_NV */
-       889, /* GL_MAX_PROGRAM_IF_DEPTH_NV */
-       893, /* GL_MAX_PROGRAM_LOOP_DEPTH_NV */
-       892, /* GL_MAX_PROGRAM_LOOP_COUNT_NV */
-       850, /* GL_MAX_ARRAY_TEXTURE_LAYERS_EXT */
-      1514, /* GL_STENCIL_TEST_TWO_SIDE_EXT */
+      1745, /* GL_TEXTURE_STENCIL_SIZE */
+      1697, /* GL_TEXTURE_CUBE_MAP_SEAMLESS */
+       894, /* GL_MAX_PROGRAM_CALL_DEPTH_NV */
+       897, /* GL_MAX_PROGRAM_IF_DEPTH_NV */
+       901, /* GL_MAX_PROGRAM_LOOP_DEPTH_NV */
+       900, /* GL_MAX_PROGRAM_LOOP_COUNT_NV */
+       857, /* GL_MAX_ARRAY_TEXTURE_LAYERS_EXT */
+      1535, /* GL_STENCIL_TEST_TWO_SIDE_EXT */
         17, /* GL_ACTIVE_STENCIL_FACE_EXT */
-       951, /* GL_MIRROR_CLAMP_TO_BORDER_EXT */
-      1384, /* GL_SAMPLES_PASSED */
+       961, /* GL_MIRROR_CLAMP_TO_BORDER_EXT */
+      1401, /* GL_SAMPLES_PASSED */
        109, /* GL_BUFFER_SERIALIZED_MODIFY_APPLE */
        104, /* GL_BUFFER_FLUSHING_UNMAP_APPLE */
-       534, /* GL_FRAGMENT_SHADER */
-      1839, /* GL_VERTEX_SHADER */
-      1240, /* GL_PROGRAM_OBJECT_ARB */
-      1416, /* GL_SHADER_OBJECT_ARB */
-       874, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS */
-       934, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS */
-       928, /* GL_MAX_VARYING_FLOATS */
-       932, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS */
-       859, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS */
-      1043, /* GL_OBJECT_TYPE_ARB */
-      1418, /* GL_SHADER_TYPE */
-       499, /* GL_FLOAT_VEC2 */
-       501, /* GL_FLOAT_VEC3 */
-       503, /* GL_FLOAT_VEC4 */
-       652, /* GL_INT_VEC2 */
-       654, /* GL_INT_VEC3 */
-       656, /* GL_INT_VEC4 */
+       537, /* GL_FRAGMENT_SHADER */
+      1861, /* GL_VERTEX_SHADER */
+      1250, /* GL_PROGRAM_OBJECT_ARB */
+      1433, /* GL_SHADER_OBJECT_ARB */
+       882, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS */
+       944, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS */
+       938, /* GL_MAX_VARYING_FLOATS */
+       942, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS */
+       867, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS */
+      1053, /* GL_OBJECT_TYPE_ARB */
+      1435, /* GL_SHADER_TYPE */
+       502, /* GL_FLOAT_VEC2 */
+       504, /* GL_FLOAT_VEC3 */
+       506, /* GL_FLOAT_VEC4 */
+       659, /* GL_INT_VEC2 */
+       661, /* GL_INT_VEC3 */
+       663, /* GL_INT_VEC4 */
         94, /* GL_BOOL */
         96, /* GL_BOOL_VEC2 */
         98, /* GL_BOOL_VEC3 */
        100, /* GL_BOOL_VEC4 */
-       487, /* GL_FLOAT_MAT2 */
-       491, /* GL_FLOAT_MAT3 */
-       495, /* GL_FLOAT_MAT4 */
-      1375, /* GL_SAMPLER_1D */
-      1377, /* GL_SAMPLER_2D */
-      1379, /* GL_SAMPLER_3D */
-      1380, /* GL_SAMPLER_CUBE */
-      1376, /* GL_SAMPLER_1D_SHADOW */
-      1378, /* GL_SAMPLER_2D_SHADOW */
-       489, /* GL_FLOAT_MAT2x3 */
-       490, /* GL_FLOAT_MAT2x4 */
-       493, /* GL_FLOAT_MAT3x2 */
-       494, /* GL_FLOAT_MAT3x4 */
-       497, /* GL_FLOAT_MAT4x2 */
-       498, /* GL_FLOAT_MAT4x3 */
+       490, /* GL_FLOAT_MAT2 */
+       494, /* GL_FLOAT_MAT3 */
+       498, /* GL_FLOAT_MAT4 */
+      1392, /* GL_SAMPLER_1D */
+      1394, /* GL_SAMPLER_2D */
+      1396, /* GL_SAMPLER_3D */
+      1397, /* GL_SAMPLER_CUBE */
+      1393, /* GL_SAMPLER_1D_SHADOW */
+      1395, /* GL_SAMPLER_2D_SHADOW */
+       492, /* GL_FLOAT_MAT2x3 */
+       493, /* GL_FLOAT_MAT2x4 */
+       496, /* GL_FLOAT_MAT3x2 */
+       497, /* GL_FLOAT_MAT3x4 */
+       500, /* GL_FLOAT_MAT4x2 */
+       501, /* GL_FLOAT_MAT4x3 */
        345, /* GL_DELETE_STATUS */
        246, /* GL_COMPILE_STATUS */
-       708, /* GL_LINK_STATUS */
-      1787, /* GL_VALIDATE_STATUS */
-       637, /* GL_INFO_LOG_LENGTH */
+       715, /* GL_LINK_STATUS */
+      1809, /* GL_VALIDATE_STATUS */
+       644, /* GL_INFO_LOG_LENGTH */
         56, /* GL_ATTACHED_SHADERS */
         20, /* GL_ACTIVE_UNIFORMS */
         21, /* GL_ACTIVE_UNIFORM_MAX_LENGTH */
-      1417, /* GL_SHADER_SOURCE_LENGTH */
+      1434, /* GL_SHADER_SOURCE_LENGTH */
         15, /* GL_ACTIVE_ATTRIBUTES */
         16, /* GL_ACTIVE_ATTRIBUTE_MAX_LENGTH */
-       536, /* GL_FRAGMENT_SHADER_DERIVATIVE_HINT */
-      1420, /* GL_SHADING_LANGUAGE_VERSION */
+       539, /* GL_FRAGMENT_SHADER_DERIVATIVE_HINT */
+      1437, /* GL_SHADING_LANGUAGE_VERSION */
        322, /* GL_CURRENT_PROGRAM */
-      1092, /* GL_PALETTE4_RGB8_OES */
-      1094, /* GL_PALETTE4_RGBA8_OES */
-      1090, /* GL_PALETTE4_R5_G6_B5_OES */
-      1093, /* GL_PALETTE4_RGBA4_OES */
-      1091, /* GL_PALETTE4_RGB5_A1_OES */
-      1097, /* GL_PALETTE8_RGB8_OES */
-      1099, /* GL_PALETTE8_RGBA8_OES */
-      1095, /* GL_PALETTE8_R5_G6_B5_OES */
-      1098, /* GL_PALETTE8_RGBA4_OES */
-      1096, /* GL_PALETTE8_RGB5_A1_OES */
-       619, /* GL_IMPLEMENTATION_COLOR_READ_TYPE_OES */
-       618, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES */
-      1772, /* GL_UNSIGNED_NORMALIZED */
-      1611, /* GL_TEXTURE_1D_ARRAY_EXT */
-      1262, /* GL_PROXY_TEXTURE_1D_ARRAY_EXT */
-      1613, /* GL_TEXTURE_2D_ARRAY_EXT */
-      1265, /* GL_PROXY_TEXTURE_2D_ARRAY_EXT */
-      1619, /* GL_TEXTURE_BINDING_1D_ARRAY_EXT */
-      1621, /* GL_TEXTURE_BINDING_2D_ARRAY_EXT */
-      1473, /* GL_SRGB */
-      1474, /* GL_SRGB8 */
-      1476, /* GL_SRGB_ALPHA */
-      1475, /* GL_SRGB8_ALPHA8 */
-      1433, /* GL_SLUMINANCE_ALPHA */
-      1432, /* GL_SLUMINANCE8_ALPHA8 */
-      1430, /* GL_SLUMINANCE */
-      1431, /* GL_SLUMINANCE8 */
+      1102, /* GL_PALETTE4_RGB8_OES */
+      1104, /* GL_PALETTE4_RGBA8_OES */
+      1100, /* GL_PALETTE4_R5_G6_B5_OES */
+      1103, /* GL_PALETTE4_RGBA4_OES */
+      1101, /* GL_PALETTE4_RGB5_A1_OES */
+      1107, /* GL_PALETTE8_RGB8_OES */
+      1109, /* GL_PALETTE8_RGBA8_OES */
+      1105, /* GL_PALETTE8_R5_G6_B5_OES */
+      1108, /* GL_PALETTE8_RGBA4_OES */
+      1106, /* GL_PALETTE8_RGB5_A1_OES */
+       626, /* GL_IMPLEMENTATION_COLOR_READ_TYPE_OES */
+       625, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES */
+      1794, /* GL_UNSIGNED_NORMALIZED */
+      1632, /* GL_TEXTURE_1D_ARRAY_EXT */
+      1272, /* GL_PROXY_TEXTURE_1D_ARRAY_EXT */
+      1634, /* GL_TEXTURE_2D_ARRAY_EXT */
+      1275, /* GL_PROXY_TEXTURE_2D_ARRAY_EXT */
+      1640, /* GL_TEXTURE_BINDING_1D_ARRAY_EXT */
+      1642, /* GL_TEXTURE_BINDING_2D_ARRAY_EXT */
+      1490, /* GL_SRGB */
+      1491, /* GL_SRGB8 */
+      1493, /* GL_SRGB_ALPHA */
+      1492, /* GL_SRGB8_ALPHA8 */
+      1450, /* GL_SLUMINANCE_ALPHA */
+      1449, /* GL_SLUMINANCE8_ALPHA8 */
+      1447, /* GL_SLUMINANCE */
+      1448, /* GL_SLUMINANCE8 */
        267, /* GL_COMPRESSED_SRGB */
        268, /* GL_COMPRESSED_SRGB_ALPHA */
        265, /* GL_COMPRESSED_SLUMINANCE */
        266, /* GL_COMPRESSED_SLUMINANCE_ALPHA */
-      1157, /* GL_POINT_SPRITE_COORD_ORIGIN */
-       716, /* GL_LOWER_LEFT */
-      1784, /* GL_UPPER_LEFT */
-      1496, /* GL_STENCIL_BACK_REF */
-      1497, /* GL_STENCIL_BACK_VALUE_MASK */
-      1498, /* GL_STENCIL_BACK_WRITEMASK */
-       442, /* GL_DRAW_FRAMEBUFFER_BINDING_EXT */
-      1309, /* GL_RENDERBUFFER_BINDING_EXT */
-      1290, /* GL_READ_FRAMEBUFFER */
-       441, /* GL_DRAW_FRAMEBUFFER */
-      1291, /* GL_READ_FRAMEBUFFER_BINDING_EXT */
-      1319, /* GL_RENDERBUFFER_SAMPLES */
-       546, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */
-       544, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */
-       555, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */
-       551, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */
-       553, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */
-       558, /* GL_FRAMEBUFFER_COMPLETE */
-       562, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */
-       568, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */
-       566, /* GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT */
-       564, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT */
-       567, /* GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT */
-       565, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT */
-       571, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT */
-       574, /* GL_FRAMEBUFFER_UNSUPPORTED */
-       572, /* GL_FRAMEBUFFER_STATUS_ERROR_EXT */
-       856, /* GL_MAX_COLOR_ATTACHMENTS_EXT */
+      1167, /* GL_POINT_SPRITE_COORD_ORIGIN */
+       723, /* GL_LOWER_LEFT */
+      1806, /* GL_UPPER_LEFT */
+      1513, /* GL_STENCIL_BACK_REF */
+      1514, /* GL_STENCIL_BACK_VALUE_MASK */
+      1515, /* GL_STENCIL_BACK_WRITEMASK */
+       444, /* GL_DRAW_FRAMEBUFFER_BINDING */
+      1324, /* GL_RENDERBUFFER_BINDING */
+      1304, /* GL_READ_FRAMEBUFFER */
+       443, /* GL_DRAW_FRAMEBUFFER */
+      1305, /* GL_READ_FRAMEBUFFER_BINDING */
+      1335, /* GL_RENDERBUFFER_SAMPLES */
+       549, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */
+       547, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */
+       558, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */
+       554, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */
+       556, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */
+       562, /* GL_FRAMEBUFFER_COMPLETE */
+       566, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */
+       573, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */
+       571, /* GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT */
+       568, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT */
+       572, /* GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT */
+       569, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER */
+       577, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER */
+       581, /* GL_FRAMEBUFFER_UNSUPPORTED */
+       579, /* GL_FRAMEBUFFER_STATUS_ERROR_EXT */
+       863, /* GL_MAX_COLOR_ATTACHMENTS */
        155, /* GL_COLOR_ATTACHMENT0 */
        157, /* GL_COLOR_ATTACHMENT1 */
        171, /* GL_COLOR_ATTACHMENT2 */
@@ -5064,57 +5108,60 @@ static const unsigned reduced_enums[1347] =
        164, /* GL_COLOR_ATTACHMENT13 */
        166, /* GL_COLOR_ATTACHMENT14 */
        168, /* GL_COLOR_ATTACHMENT15 */
-       348, /* GL_DEPTH_ATTACHMENT */
-      1486, /* GL_STENCIL_ATTACHMENT */
-       537, /* GL_FRAMEBUFFER */
-      1307, /* GL_RENDERBUFFER */
-      1321, /* GL_RENDERBUFFER_WIDTH */
-      1314, /* GL_RENDERBUFFER_HEIGHT */
-      1316, /* GL_RENDERBUFFER_INTERNAL_FORMAT */
-      1509, /* GL_STENCIL_INDEX_EXT */
-      1506, /* GL_STENCIL_INDEX1_EXT */
-      1507, /* GL_STENCIL_INDEX4_EXT */
-      1508, /* GL_STENCIL_INDEX8_EXT */
-      1505, /* GL_STENCIL_INDEX16_EXT */
-      1318, /* GL_RENDERBUFFER_RED_SIZE */
-      1313, /* GL_RENDERBUFFER_GREEN_SIZE */
-      1310, /* GL_RENDERBUFFER_BLUE_SIZE */
-      1308, /* GL_RENDERBUFFER_ALPHA_SIZE */
-      1311, /* GL_RENDERBUFFER_DEPTH_SIZE */
-      1320, /* GL_RENDERBUFFER_STENCIL_SIZE */
-       570, /* GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */
-       912, /* GL_MAX_SAMPLES */
-      1276, /* GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */
-       483, /* GL_FIRST_VERTEX_CONVENTION */
-       667, /* GL_LAST_VERTEX_CONVENTION */
-      1254, /* GL_PROVOKING_VERTEX */
+       349, /* GL_DEPTH_ATTACHMENT */
+      1503, /* GL_STENCIL_ATTACHMENT */
+       540, /* GL_FRAMEBUFFER */
+      1322, /* GL_RENDERBUFFER */
+      1338, /* GL_RENDERBUFFER_WIDTH */
+      1330, /* GL_RENDERBUFFER_HEIGHT */
+      1332, /* GL_RENDERBUFFER_INTERNAL_FORMAT */
+      1530, /* GL_STENCIL_INDEX_EXT */
+      1522, /* GL_STENCIL_INDEX1 */
+      1526, /* GL_STENCIL_INDEX4 */
+      1528, /* GL_STENCIL_INDEX8 */
+      1523, /* GL_STENCIL_INDEX16 */
+      1334, /* GL_RENDERBUFFER_RED_SIZE */
+      1329, /* GL_RENDERBUFFER_GREEN_SIZE */
+      1326, /* GL_RENDERBUFFER_BLUE_SIZE */
+      1323, /* GL_RENDERBUFFER_ALPHA_SIZE */
+      1327, /* GL_RENDERBUFFER_DEPTH_SIZE */
+      1337, /* GL_RENDERBUFFER_STENCIL_SIZE */
+       575, /* GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */
+       921, /* GL_MAX_SAMPLES */
+      1299, /* GL_QUERY_WAIT_NV */
+      1294, /* GL_QUERY_NO_WAIT_NV */
+      1291, /* GL_QUERY_BY_REGION_WAIT_NV */
+      1290, /* GL_QUERY_BY_REGION_NO_WAIT_NV */
+      1286, /* GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */
+       486, /* GL_FIRST_VERTEX_CONVENTION */
+       674, /* GL_LAST_VERTEX_CONVENTION */
+      1264, /* GL_PROVOKING_VERTEX */
        302, /* GL_COPY_READ_BUFFER */
        303, /* GL_COPY_WRITE_BUFFER */
-      1368, /* GL_RGBA_SNORM */
-      1364, /* GL_RGBA8_SNORM */
-      1426, /* GL_SIGNED_NORMALIZED */
-       913, /* GL_MAX_SERVER_WAIT_TIMEOUT */
-      1042, /* GL_OBJECT_TYPE */
-      1530, /* GL_SYNC_CONDITION */
-      1535, /* GL_SYNC_STATUS */
-      1532, /* GL_SYNC_FLAGS */
-      1531, /* GL_SYNC_FENCE */
-      1534, /* GL_SYNC_GPU_COMMANDS_COMPLETE */
-      1761, /* GL_UNSIGNALED */
-      1425, /* GL_SIGNALED */
+      1385, /* GL_RGBA_SNORM */
+      1381, /* GL_RGBA8_SNORM */
+      1443, /* GL_SIGNED_NORMALIZED */
+       923, /* GL_MAX_SERVER_WAIT_TIMEOUT */
+      1052, /* GL_OBJECT_TYPE */
+      1551, /* GL_SYNC_CONDITION */
+      1556, /* GL_SYNC_STATUS */
+      1553, /* GL_SYNC_FLAGS */
+      1552, /* GL_SYNC_FENCE */
+      1555, /* GL_SYNC_GPU_COMMANDS_COMPLETE */
+      1782, /* GL_UNSIGNALED */
+      1442, /* GL_SIGNALED */
         46, /* GL_ALREADY_SIGNALED */
-      1732, /* GL_TIMEOUT_EXPIRED */
+      1754, /* GL_TIMEOUT_EXPIRED */
        270, /* GL_CONDITION_SATISFIED */
-      1844, /* GL_WAIT_FAILED */
-       468, /* GL_EVAL_BIT */
-      1288, /* GL_RASTER_POSITION_UNCLIPPED_IBM */
-       710, /* GL_LIST_BIT */
-      1627, /* GL_TEXTURE_BIT */
-      1399, /* GL_SCISSOR_BIT */
+      1866, /* GL_WAIT_FAILED */
+       471, /* GL_EVAL_BIT */
+      1302, /* GL_RASTER_POSITION_UNCLIPPED_IBM */
+       717, /* GL_LIST_BIT */
+      1648, /* GL_TEXTURE_BIT */
+      1416, /* GL_SCISSOR_BIT */
         29, /* GL_ALL_ATTRIB_BITS */
-       998, /* GL_MULTISAMPLE_BIT */
+      1008, /* GL_MULTISAMPLE_BIT */
         30, /* GL_ALL_CLIENT_ATTRIB_BITS */
-      1733, /* GL_TIMEOUT_IGNORED */
 };
 
 typedef int (*cfunc)(const void *, const void *);
index 54cf37c5f48f6b79ca19278dc3154314480fbed5..5fc0b1cfde2bd713f99d635ccfac96d6c4909d06 100644 (file)
@@ -103,9 +103,11 @@ static const struct {
    { OFF, "GL_EXT_convolution",                F(EXT_convolution) },
    { ON,  "GL_EXT_copy_texture",               F(EXT_copy_texture) },
    { OFF, "GL_EXT_depth_bounds_test",          F(EXT_depth_bounds_test) },
+   { OFF, "GL_EXT_draw_buffers2",              F(EXT_draw_buffers2) },
    { ON,  "GL_EXT_draw_range_elements",        F(EXT_draw_range_elements) },
-   { OFF, "GL_EXT_framebuffer_object",         F(EXT_framebuffer_object) },
    { OFF, "GL_EXT_framebuffer_blit",           F(EXT_framebuffer_blit) },
+   { OFF, "GL_EXT_framebuffer_multisample",    F(EXT_framebuffer_multisample) },
+   { OFF, "GL_EXT_framebuffer_object",         F(EXT_framebuffer_object) },
    { OFF, "GL_EXT_fog_coord",                  F(EXT_fog_coord) },
    { OFF, "GL_EXT_gpu_program_parameters",     F(EXT_gpu_program_parameters) },
    { OFF, "GL_EXT_histogram",                  F(EXT_histogram) },
@@ -165,10 +167,12 @@ static const struct {
    { OFF, "GL_MESA_ycbcr_texture",             F(MESA_ycbcr_texture) },
    { ON,  "GL_MESA_window_pos",                F(ARB_window_pos) },
    { OFF, "GL_NV_blend_square",                F(NV_blend_square) },
+   { OFF, "GL_NV_conditional_render",          F(NV_conditional_render) },
    { OFF, "GL_NV_depth_clamp",                 F(ARB_depth_clamp) },
    { OFF, "GL_NV_fragment_program",            F(NV_fragment_program) },
    { OFF, "GL_NV_fragment_program_option",     F(NV_fragment_program_option) },
    { ON,  "GL_NV_light_max_exponent",          F(NV_light_max_exponent) },
+   { OFF, "GL_NV_packed_depth_stencil",        F(EXT_packed_depth_stencil) },
    { OFF, "GL_NV_point_sprite",                F(NV_point_sprite) },
    { OFF, "GL_NV_texture_env_combine4",        F(NV_texture_env_combine4) },
    { OFF, "GL_NV_texture_rectangle",           F(NV_texture_rectangle) },
@@ -267,12 +271,16 @@ _mesa_enable_sw_extensions(GLcontext *ctx)
    ctx->Extensions.EXT_blend_subtract = GL_TRUE;
    ctx->Extensions.EXT_convolution = GL_TRUE;
    ctx->Extensions.EXT_depth_bounds_test = GL_TRUE;
+   ctx->Extensions.EXT_draw_buffers2 = GL_TRUE;
    ctx->Extensions.EXT_fog_coord = GL_TRUE;
 #if FEATURE_EXT_framebuffer_object
    ctx->Extensions.EXT_framebuffer_object = GL_TRUE;
 #endif
 #if FEATURE_EXT_framebuffer_blit
    ctx->Extensions.EXT_framebuffer_blit = GL_TRUE;
+#endif
+#if FEATURE_ARB_framebuffer_object
+   ctx->Extensions.EXT_framebuffer_multisample = GL_TRUE;
 #endif
    ctx->Extensions.EXT_histogram = GL_TRUE;
    /*ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;*/
@@ -304,6 +312,7 @@ _mesa_enable_sw_extensions(GLcontext *ctx)
    ctx->Extensions.MESA_texture_array = GL_TRUE;
    ctx->Extensions.MESA_ycbcr_texture = GL_TRUE;
    ctx->Extensions.NV_blend_square = GL_TRUE;
+   ctx->Extensions.NV_conditional_render = GL_TRUE;
    /*ctx->Extensions.NV_light_max_exponent = GL_TRUE;*/
    ctx->Extensions.NV_point_sprite = GL_TRUE;
    ctx->Extensions.NV_texture_env_combine4 = GL_TRUE;
@@ -517,20 +526,34 @@ _mesa_disable_extension( GLcontext *ctx, const char *name )
 }
 
 
+/**
+ * Check if the i-th extension is enabled.
+ */
+static GLboolean
+extension_enabled(GLcontext *ctx, GLuint index)
+{
+   const GLboolean *base = (const GLboolean *) &ctx->Extensions;
+   if (!default_extensions[index].flag_offset ||
+       *(base + default_extensions[index].flag_offset)) {
+      return GL_TRUE;
+   }
+   else {
+      return GL_FALSE;
+   }
+}
+
+
 /**
  * Test if the named extension is enabled in this context.
  */
 GLboolean
 _mesa_extension_is_enabled( GLcontext *ctx, const char *name )
 {
-   const GLboolean *base = (const GLboolean *) &ctx->Extensions;
    GLuint i;
 
    for (i = 0 ; i < Elements(default_extensions) ; i++) {
       if (_mesa_strcmp(default_extensions[i].name, name) == 0) {
-         if (!default_extensions[i].flag_offset)
-            return GL_TRUE;
-         return *(base + default_extensions[i].flag_offset);
+         return extension_enabled(ctx, i);
       }
    }
    return GL_FALSE;
@@ -638,7 +661,6 @@ _mesa_init_extensions( GLcontext *ctx )
 GLubyte *
 _mesa_make_extension_string( GLcontext *ctx )
 {
-   const GLboolean *base = (const GLboolean *) &ctx->Extensions;
    const char *extraExt = get_extension_override(ctx);
    GLuint extStrLen = 0;
    char *s;
@@ -646,8 +668,7 @@ _mesa_make_extension_string( GLcontext *ctx )
 
    /* first, compute length of the extension string */
    for (i = 0 ; i < Elements(default_extensions) ; i++) {
-      if (!default_extensions[i].flag_offset ||
-          *(base + default_extensions[i].flag_offset)) {
+      if (extension_enabled(ctx, i)) {
          extStrLen += (GLuint)_mesa_strlen(default_extensions[i].name) + 1;
       }
    }
@@ -663,8 +684,7 @@ _mesa_make_extension_string( GLcontext *ctx )
    /* second, build the extension string */
    extStrLen = 0;
    for (i = 0 ; i < Elements(default_extensions) ; i++) {
-      if (!default_extensions[i].flag_offset ||
-          *(base + default_extensions[i].flag_offset)) {
+      if (extension_enabled(ctx, i)) {
          GLuint len = (GLuint)_mesa_strlen(default_extensions[i].name);
          _mesa_memcpy(s + extStrLen, default_extensions[i].name, len);
          extStrLen += len;
@@ -683,3 +703,48 @@ _mesa_make_extension_string( GLcontext *ctx )
 
    return (GLubyte *) s;
 }
+
+
+/**
+ * Return number of enabled extensions.
+ */
+GLuint
+_mesa_get_extension_count(GLcontext *ctx)
+{
+   GLuint i;
+
+   /* only count once */
+   if (!ctx->Extensions.Count) {
+      for (i = 0; i < Elements(default_extensions); i++) {
+         if (extension_enabled(ctx, i)) {
+            ctx->Extensions.Count++;
+         }
+      }
+   }
+
+   if (0)
+      _mesa_debug(ctx, "%u of %d extensions enabled\n", ctx->Extensions.Count,
+                  Elements(default_extensions));
+
+   return ctx->Extensions.Count;
+}
+
+
+/**
+ * Return name of i-th enabled extension
+ */
+const GLubyte *
+_mesa_get_enabled_extension(GLcontext *ctx, GLuint index)
+{
+   GLuint i;
+
+   for (i = 0; i < Elements(default_extensions); i++) {
+      if (extension_enabled(ctx, i)) {
+         if (index == 0)
+            return (const GLubyte *) default_extensions[i].name;
+         index--;
+      }
+   }
+
+   return NULL;
+}
index 05ad859a27ef595a252818aafe4e7606faa4e2e0..a25472440d621f6941b80b433496f0aa1817d3ff 100644 (file)
@@ -64,6 +64,13 @@ extern void _mesa_init_extensions(GLcontext *ctx);
 
 extern GLubyte *_mesa_make_extension_string(GLcontext *ctx);
 
+extern GLuint
+_mesa_get_extension_count(GLcontext *ctx);
+
+extern const GLubyte *
+_mesa_get_enabled_extension(GLcontext *ctx, GLuint index);
+
+
 #else
 
 /** No-op */
index 6e767bb24d1c1b9a1d0d8257d8803b578f0fc2f6..7b3599f93227c8a97c92f55d9d8c3e02056b0ab9 100644 (file)
@@ -34,7 +34,9 @@
 
 #include "buffers.h"
 #include "context.h"
+#include "enums.h"
 #include "fbobject.h"
+#include "formats.h"
 #include "framebuffer.h"
 #include "hash.h"
 #include "macros.h"
@@ -50,6 +52,9 @@
 /** Set this to 1 to help debug FBO incompleteness problems */
 #define DEBUG_FBO 0
 
+/** Set this to 1 to debug/log glBlitFramebuffer() calls */
+#define DEBUG_BLIT 0
+
 
 /**
  * Notes:
@@ -228,9 +233,13 @@ _mesa_set_texture_attachment(GLcontext *ctx,
    if (att->Texture == texObj) {
       /* re-attaching same texture */
       ASSERT(att->Type == GL_TEXTURE);
+      if (ctx->Driver.FinishRenderTexture)
+        ctx->Driver.FinishRenderTexture(ctx, att);
    }
    else {
       /* new attachment */
+      if (ctx->Driver.FinishRenderTexture && att->Texture)
+        ctx->Driver.FinishRenderTexture(ctx, att);
       _mesa_remove_attachment(ctx, att);
       att->Type = GL_TEXTURE;
       assert(!att->Texture);
@@ -239,12 +248,7 @@ _mesa_set_texture_attachment(GLcontext *ctx,
 
    /* always update these fields */
    att->TextureLevel = level;
-   if (IS_CUBE_FACE(texTarget)) {
-      att->CubeMapFace = texTarget - GL_TEXTURE_CUBE_MAP_POSITIVE_X;
-   }
-   else {
-      att->CubeMapFace = 0;
-   }
+   att->CubeMapFace = _mesa_tex_target_to_face(texTarget);
    att->Zoffset = zoffset;
    att->Complete = GL_FALSE;
 
@@ -357,6 +361,7 @@ test_attachment_completeness(const GLcontext *ctx, GLenum format,
    if (att->Type == GL_TEXTURE) {
       const struct gl_texture_object *texObj = att->Texture;
       struct gl_texture_image *texImage;
+      GLenum baseFormat;
 
       if (!texObj) {
          att_incomplete("no texobj");
@@ -383,26 +388,28 @@ test_attachment_completeness(const GLcontext *ctx, GLenum format,
          return;
       }
 
+      baseFormat = _mesa_get_format_base_format(texImage->TexFormat);
+
       if (format == GL_COLOR) {
-         if (texImage->TexFormat->BaseFormat != GL_RGB &&
-             texImage->TexFormat->BaseFormat != GL_RGBA) {
+         if (baseFormat != GL_RGB &&
+             baseFormat != GL_RGBA) {
             att_incomplete("bad format");
             att->Complete = GL_FALSE;
             return;
          }
-         if (texImage->TexFormat->TexelBytes == 0) {
+         if (_mesa_is_format_compressed(texImage->TexFormat)) {
             att_incomplete("compressed internalformat");
             att->Complete = GL_FALSE;
             return;
          }
       }
       else if (format == GL_DEPTH) {
-         if (texImage->TexFormat->BaseFormat == GL_DEPTH_COMPONENT) {
+         if (baseFormat == GL_DEPTH_COMPONENT) {
             /* OK */
          }
          else if (ctx->Extensions.EXT_packed_depth_stencil &&
                   ctx->Extensions.ARB_depth_texture &&
-                  texImage->TexFormat->BaseFormat == GL_DEPTH_STENCIL_EXT) {
+                  baseFormat == GL_DEPTH_STENCIL_EXT) {
             /* OK */
          }
          else {
@@ -413,10 +420,9 @@ test_attachment_completeness(const GLcontext *ctx, GLenum format,
       }
       else {
          ASSERT(format == GL_STENCIL);
-         ASSERT(att->Renderbuffer->StencilBits);
          if (ctx->Extensions.EXT_packed_depth_stencil &&
              ctx->Extensions.ARB_depth_texture &&
-             att->Renderbuffer->_BaseFormat == GL_DEPTH_STENCIL_EXT) {
+             baseFormat == GL_DEPTH_STENCIL_EXT) {
             /* OK */
          }
          else {
@@ -428,6 +434,9 @@ test_attachment_completeness(const GLcontext *ctx, GLenum format,
       }
    }
    else if (att->Type == GL_RENDERBUFFER_EXT) {
+      const GLenum baseFormat =
+         _mesa_get_format_base_format(att->Renderbuffer->Format);
+
       ASSERT(att->Renderbuffer);
       if (!att->Renderbuffer->InternalFormat ||
           att->Renderbuffer->Width < 1 ||
@@ -437,24 +446,19 @@ test_attachment_completeness(const GLcontext *ctx, GLenum format,
          return;
       }
       if (format == GL_COLOR) {
-         if (att->Renderbuffer->_BaseFormat != GL_RGB &&
-             att->Renderbuffer->_BaseFormat != GL_RGBA) {
+         if (baseFormat != GL_RGB &&
+             baseFormat != GL_RGBA) {
             att_incomplete("bad renderbuffer color format");
             att->Complete = GL_FALSE;
             return;
          }
-         ASSERT(att->Renderbuffer->RedBits);
-         ASSERT(att->Renderbuffer->GreenBits);
-         ASSERT(att->Renderbuffer->BlueBits);
       }
       else if (format == GL_DEPTH) {
-         if (att->Renderbuffer->_BaseFormat == GL_DEPTH_COMPONENT) {
-            ASSERT(att->Renderbuffer->DepthBits);
+         if (baseFormat == GL_DEPTH_COMPONENT) {
             /* OK */
          }
          else if (ctx->Extensions.EXT_packed_depth_stencil &&
-                  att->Renderbuffer->_BaseFormat == GL_DEPTH_STENCIL_EXT) {
-            ASSERT(att->Renderbuffer->DepthBits);
+                  baseFormat == GL_DEPTH_STENCIL_EXT) {
             /* OK */
          }
          else {
@@ -465,13 +469,11 @@ test_attachment_completeness(const GLcontext *ctx, GLenum format,
       }
       else {
          assert(format == GL_STENCIL);
-         if (att->Renderbuffer->_BaseFormat == GL_STENCIL_INDEX) {
-            ASSERT(att->Renderbuffer->StencilBits);
+         if (baseFormat == GL_STENCIL_INDEX) {
             /* OK */
          }
          else if (ctx->Extensions.EXT_packed_depth_stencil &&
-                  att->Renderbuffer->_BaseFormat == GL_DEPTH_STENCIL_EXT) {
-            ASSERT(att->Renderbuffer->StencilBits);
+                  baseFormat == GL_DEPTH_STENCIL_EXT) {
             /* OK */
          }
          else {
@@ -652,6 +654,8 @@ _mesa_test_framebuffer_completeness(GLcontext *ctx, struct gl_framebuffer *fb)
          return;
       }
    }
+#else
+   (void) j;
 #endif
 
    if (numImages == 0) {
@@ -712,12 +716,13 @@ _mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer)
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    if (target != GL_RENDERBUFFER_EXT) {
-         _mesa_error(ctx, GL_INVALID_ENUM,
-                  "glBindRenderbufferEXT(target)");
+      _mesa_error(ctx, GL_INVALID_ENUM, "glBindRenderbufferEXT(target)");
       return;
    }
 
-   FLUSH_CURRENT(ctx, _NEW_BUFFERS);
+   /* No need to flush here since the render buffer binding has no
+    * effect on rendering state.
+    */
 
    if (renderbuffer) {
       newRb = _mesa_lookup_renderbuffer(ctx, renderbuffer);
@@ -971,42 +976,27 @@ renderbuffer_storage(GLenum target, GLenum internalFormat,
    }
 
    /* These MUST get set by the AllocStorage func */
-   rb->_ActualFormat = 0;
-   rb->RedBits =
-   rb->GreenBits =
-   rb->BlueBits =
-   rb->AlphaBits =
-   rb->IndexBits =
-   rb->DepthBits =
-   rb->StencilBits = 0;
+   rb->Format = MESA_FORMAT_NONE;
    rb->NumSamples = samples;
 
    /* Now allocate the storage */
    ASSERT(rb->AllocStorage);
    if (rb->AllocStorage(ctx, rb, internalFormat, width, height)) {
       /* No error - check/set fields now */
-      assert(rb->_ActualFormat);
+      assert(rb->Format != MESA_FORMAT_NONE);
       assert(rb->Width == (GLuint) width);
       assert(rb->Height == (GLuint) height);
-      assert(rb->RedBits || rb->GreenBits || rb->BlueBits || rb->AlphaBits ||
-             rb->DepthBits || rb->StencilBits || rb->IndexBits);
       rb->InternalFormat = internalFormat;
-      rb->_BaseFormat = baseFormat;
+      rb->_BaseFormat = _mesa_base_fbo_format(ctx, internalFormat);
+      assert(rb->_BaseFormat != 0);
    }
    else {
       /* Probably ran out of memory - clear the fields */
       rb->Width = 0;
       rb->Height = 0;
+      rb->Format = MESA_FORMAT_NONE;
       rb->InternalFormat = GL_NONE;
-      rb->_ActualFormat = GL_NONE;
       rb->_BaseFormat = GL_NONE;
-      rb->RedBits =
-      rb->GreenBits =
-      rb->BlueBits =
-      rb->AlphaBits =
-      rb->IndexBits =
-      rb->DepthBits =
-      rb->StencilBits =
       rb->NumSamples = 0;
    }
 
@@ -1019,6 +1009,53 @@ renderbuffer_storage(GLenum target, GLenum internalFormat,
 }
 
 
+/**
+ * Helper function for _mesa_GetRenderbufferParameterivEXT() and
+ * _mesa_GetFramebufferAttachmentParameterivEXT()
+ * We have to be careful to respect the base format.  For example, if a
+ * renderbuffer/texture was created with internalFormat=GL_RGB but the
+ * driver actually chose a GL_RGBA format, when the user queries ALPHA_SIZE
+ * we need to return zero.
+ */
+static GLint
+get_component_bits(GLenum pname, GLenum baseFormat, gl_format format)
+{
+   switch (pname) {
+   case GL_RENDERBUFFER_RED_SIZE_EXT:
+   case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
+   case GL_RENDERBUFFER_GREEN_SIZE_EXT:
+   case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
+   case GL_RENDERBUFFER_BLUE_SIZE_EXT:
+   case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
+      if (baseFormat == GL_RGB || baseFormat == GL_RGBA)
+         return _mesa_get_format_bits(format, pname);
+      else
+         return 0;
+   case GL_RENDERBUFFER_ALPHA_SIZE_EXT:
+   case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
+      if (baseFormat == GL_RGBA || baseFormat == GL_ALPHA)
+         return _mesa_get_format_bits(format, pname);
+      else
+         return 0;
+   case GL_RENDERBUFFER_DEPTH_SIZE_EXT:
+   case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
+      if (baseFormat == GL_DEPTH_COMPONENT || baseFormat == GL_DEPTH_STENCIL)
+         return _mesa_get_format_bits(format, pname);
+      else
+         return 0;
+   case GL_RENDERBUFFER_STENCIL_SIZE_EXT:
+   case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
+      if (baseFormat == GL_STENCIL_INDEX || baseFormat == GL_DEPTH_STENCIL)
+         return _mesa_get_format_bits(format, pname);
+      else
+         return 0;
+   default:
+      return 0;
+   }
+}
+
+
+
 void GLAPIENTRY
 _mesa_RenderbufferStorageEXT(GLenum target, GLenum internalFormat,
                              GLsizei width, GLsizei height)
@@ -1062,7 +1099,9 @@ _mesa_GetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint *params)
       return;
    }
 
-   FLUSH_VERTICES(ctx, _NEW_BUFFERS);
+   /* No need to flush here since we're just quering state which is
+    * not effected by rendering.
+    */
 
    switch (pname) {
    case GL_RENDERBUFFER_WIDTH_EXT:
@@ -1075,22 +1114,12 @@ _mesa_GetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint *params)
       *params = rb->InternalFormat;
       return;
    case GL_RENDERBUFFER_RED_SIZE_EXT:
-      *params = rb->RedBits;
-      break;
    case GL_RENDERBUFFER_GREEN_SIZE_EXT:
-      *params = rb->GreenBits;
-      break;
    case GL_RENDERBUFFER_BLUE_SIZE_EXT:
-      *params = rb->BlueBits;
-      break;
    case GL_RENDERBUFFER_ALPHA_SIZE_EXT:
-      *params = rb->AlphaBits;
-      break;
    case GL_RENDERBUFFER_DEPTH_SIZE_EXT:
-      *params = rb->DepthBits;
-      break;
    case GL_RENDERBUFFER_STENCIL_SIZE_EXT:
-      *params = rb->StencilBits;
+      *params = get_component_bits(pname, rb->_BaseFormat, rb->Format);
       break;
    case GL_RENDERBUFFER_SAMPLES:
       if (ctx->Extensions.ARB_framebuffer_object) {
@@ -1120,16 +1149,25 @@ _mesa_IsFramebufferEXT(GLuint framebuffer)
 }
 
 
+/**
+ * Check if any of the attachments of the given framebuffer are textures
+ * (render to texture).  Call ctx->Driver.RenderTexture() for such
+ * attachments.
+ */
 static void
 check_begin_texture_render(GLcontext *ctx, struct gl_framebuffer *fb)
 {
    GLuint i;
    ASSERT(ctx->Driver.RenderTexture);
+
+   if (fb->Name == 0)
+      return; /* can't render to texture with winsys framebuffers */
+
    for (i = 0; i < BUFFER_COUNT; i++) {
       struct gl_renderbuffer_attachment *att = fb->Attachment + i;
       struct gl_texture_object *texObj = att->Texture;
       if (texObj
-          && att->Texture->Image[att->CubeMapFace][att->TextureLevel]) {
+          && texObj->Image[att->CubeMapFace][att->TextureLevel]) {
          ctx->Driver.RenderTexture(ctx, fb, att);
       }
    }
@@ -1144,6 +1182,9 @@ check_begin_texture_render(GLcontext *ctx, struct gl_framebuffer *fb)
 static void
 check_end_texture_render(GLcontext *ctx, struct gl_framebuffer *fb)
 {
+   if (fb->Name == 0)
+      return; /* can't render to texture with winsys framebuffers */
+
    if (ctx->Driver.FinishRenderTexture) {
       GLuint i;
       for (i = 0; i < BUFFER_COUNT; i++) {
@@ -1159,7 +1200,8 @@ check_end_texture_render(GLcontext *ctx, struct gl_framebuffer *fb)
 void GLAPIENTRY
 _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer)
 {
-   struct gl_framebuffer *newFb, *newFbread;
+   struct gl_framebuffer *newDrawFb, *newReadFb;
+   struct gl_framebuffer *oldDrawFb, *oldReadFb;
    GLboolean bindReadBuf, bindDrawBuf;
    GET_CURRENT_CONTEXT(ctx);
 
@@ -1206,73 +1248,90 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer)
       return;
    }
 
-   FLUSH_CURRENT(ctx, _NEW_BUFFERS);
-
    if (framebuffer) {
       /* Binding a user-created framebuffer object */
-      newFb = _mesa_lookup_framebuffer(ctx, framebuffer);
-      if (newFb == &DummyFramebuffer) {
+      newDrawFb = _mesa_lookup_framebuffer(ctx, framebuffer);
+      if (newDrawFb == &DummyFramebuffer) {
          /* ID was reserved, but no real framebuffer object made yet */
-         newFb = NULL;
+         newDrawFb = NULL;
       }
-      else if (!newFb && ctx->Extensions.ARB_framebuffer_object) {
+      else if (!newDrawFb && ctx->Extensions.ARB_framebuffer_object) {
          /* All FBO IDs must be Gen'd */
          _mesa_error(ctx, GL_INVALID_OPERATION, "glBindFramebuffer(buffer)");
          return;
       }
 
-      if (!newFb) {
+      if (!newDrawFb) {
         /* create new framebuffer object */
-        newFb = ctx->Driver.NewFramebuffer(ctx, framebuffer);
-        if (!newFb) {
+        newDrawFb = ctx->Driver.NewFramebuffer(ctx, framebuffer);
+        if (!newDrawFb) {
            _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindFramebufferEXT");
            return;
         }
-         _mesa_HashInsert(ctx->Shared->FrameBuffers, framebuffer, newFb);
+         _mesa_HashInsert(ctx->Shared->FrameBuffers, framebuffer, newDrawFb);
       }
-      newFbread = newFb;
+      newReadFb = newDrawFb;
    }
    else {
       /* Binding the window system framebuffer (which was originally set
        * with MakeCurrent).
        */
-      newFb = ctx->WinSysDrawBuffer;
-      newFbread = ctx->WinSysReadBuffer;
+      newDrawFb = ctx->WinSysDrawBuffer;
+      newReadFb = ctx->WinSysReadBuffer;
    }
 
-   ASSERT(newFb);
-   ASSERT(newFb != &DummyFramebuffer);
+   ASSERT(newDrawFb);
+   ASSERT(newDrawFb != &DummyFramebuffer);
+
+   /* save pointers to current/old framebuffers */
+   oldDrawFb = ctx->DrawBuffer;
+   oldReadFb = ctx->ReadBuffer;
+
+   /* check if really changing bindings */
+   if (oldDrawFb == newDrawFb)
+      bindDrawBuf = GL_FALSE;
+   if (oldReadFb == newReadFb)
+      bindReadBuf = GL_FALSE;
 
    /*
     * OK, now bind the new Draw/Read framebuffers, if they're changing.
+    *
+    * We also check if we're beginning and/or ending render-to-texture.
+    * When a framebuffer with texture attachments is unbound, call
+    * ctx->Driver.FinishRenderTexture().
+    * When a framebuffer with texture attachments is bound, call
+    * ctx->Driver.RenderTexture().
+    *
+    * Note that if the ReadBuffer has texture attachments we don't consider
+    * that a render-to-texture case.
     */
-
    if (bindReadBuf) {
-      if (ctx->ReadBuffer == newFbread)
-         bindReadBuf = GL_FALSE; /* no change */
-      else
-         _mesa_reference_framebuffer(&ctx->ReadBuffer, newFbread);
+      FLUSH_VERTICES(ctx, _NEW_BUFFERS);
+
+      /* check if old readbuffer was render-to-texture */
+      check_end_texture_render(ctx, oldReadFb);
+
+      _mesa_reference_framebuffer(&ctx->ReadBuffer, newReadFb);
    }
 
    if (bindDrawBuf) {
-      /* check if old FB had any texture attachments */
-      if (ctx->DrawBuffer->Name != 0) {
-         check_end_texture_render(ctx, ctx->DrawBuffer);
-      }
+      FLUSH_VERTICES(ctx, _NEW_BUFFERS);
 
-      if (ctx->DrawBuffer == newFb)
-         bindDrawBuf = GL_FALSE; /* no change */
-      else
-         _mesa_reference_framebuffer(&ctx->DrawBuffer, newFb);
+      /* check if old read/draw buffers were render-to-texture */
+      if (!bindReadBuf)
+         check_end_texture_render(ctx, oldReadFb);
 
-      if (newFb->Name != 0) {
-         /* check if newly bound framebuffer has any texture attachments */
-         check_begin_texture_render(ctx, newFb);
-      }
+      if (oldDrawFb != oldReadFb)
+         check_end_texture_render(ctx, oldDrawFb);
+
+      /* check if newly bound framebuffer has any texture attachments */
+      check_begin_texture_render(ctx, newDrawFb);
+
+      _mesa_reference_framebuffer(&ctx->DrawBuffer, newDrawFb);
    }
 
    if ((bindDrawBuf || bindReadBuf) && ctx->Driver.BindFramebuffer) {
-      ctx->Driver.BindFramebuffer(ctx, target, newFb, newFbread);
+      ctx->Driver.BindFramebuffer(ctx, target, newDrawFb, newReadFb);
    }
 }
 
@@ -1284,7 +1343,7 @@ _mesa_DeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers)
    GET_CURRENT_CONTEXT(ctx);
 
    ASSERT_OUTSIDE_BEGIN_END(ctx);
-   FLUSH_CURRENT(ctx, _NEW_BUFFERS);
+   FLUSH_VERTICES(ctx, _NEW_BUFFERS);
 
    for (i = 0; i < n; i++) {
       if (framebuffers[i] > 0) {
@@ -1389,7 +1448,7 @@ _mesa_CheckFramebufferStatusEXT(GLenum target)
       return GL_FRAMEBUFFER_COMPLETE_EXT;
    }
 
-   FLUSH_VERTICES(ctx, _NEW_BUFFERS);
+   /* No need to flush here */
 
    if (buffer->_Status != GL_FRAMEBUFFER_COMPLETE) {
       _mesa_test_framebuffer_completeness(ctx, buffer);
@@ -1505,19 +1564,7 @@ framebuffer_texture(GLcontext *ctx, const char *caller, GLenum target,
       return;
    }
 
-   if (texObj && attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
-      /* the texture format must be depth+stencil */
-      const struct gl_texture_image *texImg;
-      texImg = texObj->Image[0][texObj->BaseLevel];
-      if (!texImg || texImg->_BaseFormat != GL_DEPTH_STENCIL) {
-         _mesa_error(ctx, GL_INVALID_OPERATION,
-                     "glFramebufferTexture%sEXT(texture is not"
-                     " DEPTH_STENCIL format)", caller);
-         return;
-      }
-   }
-
-   FLUSH_CURRENT(ctx, _NEW_BUFFERS);
+   FLUSH_VERTICES(ctx, _NEW_BUFFERS);
 
    _glthread_LOCK_MUTEX(fb->Mutex);
    if (texObj) {
@@ -1665,7 +1712,8 @@ _mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment,
    att = _mesa_get_attachment(ctx, fb, attachment);
    if (att == NULL) {
       _mesa_error(ctx, GL_INVALID_ENUM,
-                 "glFramebufferRenderbufferEXT(attachment)");
+                  "glFramebufferRenderbufferEXT(invalid attachment %s)",
+                  _mesa_lookup_enum_by_nr(attachment));
       return;
    }
 
@@ -1673,7 +1721,8 @@ _mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment,
       rb = _mesa_lookup_renderbuffer(ctx, renderbuffer);
       if (!rb) {
         _mesa_error(ctx, GL_INVALID_OPERATION,
-                    "glFramebufferRenderbufferEXT(renderbuffer)");
+                    "glFramebufferRenderbufferEXT(non-existant"
+                     " renderbuffer %u)", renderbuffer);
         return;
       }
    }
@@ -1684,7 +1733,9 @@ _mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment,
 
    if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
       /* make sure the renderbuffer is a depth/stencil format */
-      if (rb->_BaseFormat != GL_DEPTH_STENCIL) {
+      const GLenum baseFormat =
+         _mesa_get_format_base_format(att->Renderbuffer->Format);
+      if (baseFormat != GL_DEPTH_STENCIL) {
          _mesa_error(ctx, GL_INVALID_OPERATION,
                      "glFramebufferRenderbufferEXT(renderbuffer"
                      " is not DEPTH_STENCIL format)");
@@ -1693,7 +1744,7 @@ _mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment,
    }
 
 
-   FLUSH_CURRENT(ctx, _NEW_BUFFERS);
+   FLUSH_VERTICES(ctx, _NEW_BUFFERS);
 
    assert(ctx->Driver.FramebufferRenderbuffer);
    ctx->Driver.FramebufferRenderbuffer(ctx, fb, attachment, rb);
@@ -1769,7 +1820,7 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
       }
    }
 
-   FLUSH_CURRENT(ctx, _NEW_BUFFERS);
+   /* No need to flush here */
 
    switch (pname) {
    case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT:
@@ -1830,7 +1881,7 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
                      "glGetFramebufferAttachmentParameterivEXT(pname)");
       }
       else {
-         *params = att->Renderbuffer->ColorEncoding;
+         *params = _mesa_get_format_color_encoding(att->Renderbuffer->Format);
       }
       return;
    case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
@@ -1840,61 +1891,44 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
          return;
       }
       else {
-         *params = att->Renderbuffer->ComponentType;
+         gl_format format = att->Renderbuffer->Format;
+         if (format == MESA_FORMAT_CI8 || format == MESA_FORMAT_S8) {
+            /* special cases */
+            *params = GL_INDEX;
+         }
+         else {
+            *params = _mesa_get_format_datatype(format);
+         }
       }
       return;
    case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
-      if (!ctx->Extensions.ARB_framebuffer_object) {
-         _mesa_error(ctx, GL_INVALID_ENUM,
-                     "glGetFramebufferAttachmentParameterivEXT(pname)");
-      }
-      else {
-         *params = att->Renderbuffer->RedBits;
-      }
-      return;
    case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
-      if (!ctx->Extensions.ARB_framebuffer_object) {
-         _mesa_error(ctx, GL_INVALID_ENUM,
-                     "glGetFramebufferAttachmentParameterivEXT(pname)");
-      }
-      else {
-         *params = att->Renderbuffer->GreenBits;
-      }
-      return;
    case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
-      if (!ctx->Extensions.ARB_framebuffer_object) {
-         _mesa_error(ctx, GL_INVALID_ENUM,
-                     "glGetFramebufferAttachmentParameterivEXT(pname)");
-      }
-      else {
-         *params = att->Renderbuffer->BlueBits;
-      }
-      return;
    case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
-      if (!ctx->Extensions.ARB_framebuffer_object) {
-         _mesa_error(ctx, GL_INVALID_ENUM,
-                     "glGetFramebufferAttachmentParameterivEXT(pname)");
-      }
-      else {
-         *params = att->Renderbuffer->AlphaBits;
-      }
-      return;
    case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
+   case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
       if (!ctx->Extensions.ARB_framebuffer_object) {
          _mesa_error(ctx, GL_INVALID_ENUM,
                      "glGetFramebufferAttachmentParameterivEXT(pname)");
       }
-      else {
-         *params = att->Renderbuffer->DepthBits;
+      else if (att->Texture) {
+         const struct gl_texture_image *texImage =
+            _mesa_select_tex_image(ctx, att->Texture, att->Texture->Target,
+                                   att->TextureLevel);
+         if (texImage) {
+            *params = get_component_bits(pname, texImage->_BaseFormat,
+                                         texImage->TexFormat);
+         }
+         else {
+            *params = 0;
+         }
       }
-      return;
-   case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
-      if (!ctx->Extensions.ARB_framebuffer_object) {
-         _mesa_error(ctx, GL_INVALID_ENUM,
-                     "glGetFramebufferAttachmentParameterivEXT(pname)");
+      else if (att->Renderbuffer) {
+         *params = get_component_bits(pname, att->Renderbuffer->_BaseFormat,
+                                      att->Renderbuffer->Format);
       }
       else {
-         *params = att->Renderbuffer->StencilBits;
+         *params = 0;
       }
       return;
    default:
@@ -1908,7 +1942,6 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
 void GLAPIENTRY
 _mesa_GenerateMipmapEXT(GLenum target)
 {
-   struct gl_texture_unit *texUnit;
    struct gl_texture_object *texObj;
    GET_CURRENT_CONTEXT(ctx);
 
@@ -1927,8 +1960,12 @@ _mesa_GenerateMipmapEXT(GLenum target)
       return;
    }
 
-   texUnit = _mesa_get_current_tex_unit(ctx);
-   texObj = _mesa_select_tex_object(ctx, texUnit, target);
+   texObj = _mesa_get_current_tex_object(ctx, target);
+
+   if (texObj->BaseLevel >= texObj->MaxLevel) {
+      /* nothing to do */
+      return;
+   }
 
    _mesa_lock_texture(ctx, texObj);
    if (target == GL_TEXTURE_CUBE_MAP) {
@@ -1946,6 +1983,20 @@ _mesa_GenerateMipmapEXT(GLenum target)
 
 
 #if FEATURE_EXT_framebuffer_blit
+
+static const struct gl_renderbuffer_attachment *
+find_attachment(const struct gl_framebuffer *fb, const struct gl_renderbuffer *rb)
+{
+   GLuint i;
+   for (i = 0; i < Elements(fb->Attachment); i++) {
+      if (fb->Attachment[i].Renderbuffer == rb)
+         return &fb->Attachment[i];
+   }
+   return NULL;
+}
+
+
+
 /**
  * Blit rectangular region, optionally from one framebuffer to another.
  *
@@ -2021,7 +2072,8 @@ _mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
       struct gl_renderbuffer *drawRb = drawFb->_StencilBuffer;
       if (!readRb ||
           !drawRb ||
-          readRb->StencilBits != drawRb->StencilBits) {
+          _mesa_get_format_bits(readRb->Format, GL_STENCIL_BITS) != 
+          _mesa_get_format_bits(drawRb->Format, GL_STENCIL_BITS)) {
          _mesa_error(ctx, GL_INVALID_OPERATION,
                      "glBlitFramebufferEXT(stencil buffer size mismatch");
          return;
@@ -2033,7 +2085,8 @@ _mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
       struct gl_renderbuffer *drawRb = drawFb->_DepthBuffer;
       if (!readRb ||
           !drawRb ||
-          readRb->DepthBits != drawRb->DepthBits) {
+          _mesa_get_format_bits(readRb->Format, GL_DEPTH_BITS) != 
+          _mesa_get_format_bits(drawRb->Format, GL_DEPTH_BITS)) {
          _mesa_error(ctx, GL_INVALID_OPERATION,
                      "glBlitFramebufferEXT(depth buffer size mismatch");
          return;
@@ -2061,7 +2114,7 @@ _mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
       /* color formats must match */
       if (colorReadRb &&
           colorDrawRb &&
-          colorReadRb->_ActualFormat != colorDrawRb->_ActualFormat) {
+          colorReadRb->Format != colorDrawRb->Format) {
          _mesa_error(ctx, GL_INVALID_OPERATION,
                 "glBlitFramebufferEXT(bad src/dst multisample pixel formats");
          return;
@@ -2073,6 +2126,44 @@ _mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
       return;
    }
 
+   /* Debug code */
+   if (DEBUG_BLIT) {
+      _mesa_printf("glBlitFramebuffer(%d, %d, %d, %d,  %d, %d, %d, %d,"
+                   " 0x%x, 0x%x)\n",
+                   srcX0, srcY0, srcX1, srcY1,
+                   dstX0, dstY0, dstX1, dstY1,
+                   mask, filter);
+      if (colorReadRb) {
+         const struct gl_renderbuffer_attachment *att;
+
+         att = find_attachment(readFb, colorReadRb);
+         _mesa_printf("  Src FBO %u  RB %u (%dx%d)  ",
+                      readFb->Name, colorReadRb->Name,
+                      colorReadRb->Width, colorReadRb->Height);
+         if (att && att->Texture) {
+            _mesa_printf("Tex %u  tgt 0x%x  level %u  face %u",
+                         att->Texture->Name,
+                         att->Texture->Target,
+                         att->TextureLevel,
+                         att->CubeMapFace);
+         }
+         _mesa_printf("\n");
+
+         att = find_attachment(drawFb, colorDrawRb);
+         _mesa_printf("  Dst FBO %u  RB %u (%dx%d)  ",
+                      drawFb->Name, colorDrawRb->Name,
+                      colorDrawRb->Width, colorDrawRb->Height);
+         if (att && att->Texture) {
+            _mesa_printf("Tex %u  tgt 0x%x  level %u  face %u",
+                         att->Texture->Name,
+                         att->Texture->Target,
+                         att->TextureLevel,
+                         att->CubeMapFace);
+         }
+         _mesa_printf("\n");
+      }
+   }
+
    ASSERT(ctx->Driver.BlitFramebuffer);
    ctx->Driver.BlitFramebuffer(ctx,
                                srcX0, srcY0, srcX1, srcY1,
index 356476e35a5c5b90408a9f971ee4c103935a7e1b..2d1db29cbfe556398c737b6c9c6fa23af8ce44e9 100644 (file)
@@ -357,7 +357,7 @@ static struct ureg get_temp( struct tnl_program *p )
    int bit = _mesa_ffs( ~p->temp_in_use );
    if (!bit) {
       _mesa_problem(NULL, "%s: out of temporaries\n", __FILE__);
-      _mesa_exit(1);
+      exit(1);
    }
 
    if ((GLuint) bit > p->program->Base.NumTemporaries)
@@ -438,7 +438,7 @@ static struct ureg register_input( struct tnl_program *p, GLuint input )
  */
 static struct ureg register_output( struct tnl_program *p, GLuint output )
 {
-   p->program->Base.OutputsWritten |= (1<<output);
+   p->program->Base.OutputsWritten |= BITFIELD64_BIT(output);
    return make_ureg(PROGRAM_OUTPUT, output);
 }
 
@@ -523,7 +523,6 @@ static void emit_dst( struct prog_dst_register *dst,
    dst->CondMask = COND_TR;  /* always pass cond test */
    dst->CondSwizzle = SWIZZLE_NOOP;
    dst->CondSrc = 0;
-   dst->pad = 0;
    /* Check that bitfield sizes aren't exceeded */
    ASSERT(dst->Index == reg.idx);
 }
index 4323d3db8206a19c57a038f482e67164bd57d04d..269ff3f8b993bf5a33e11df4aec7bae83ac3f978 100644 (file)
 void GLAPIENTRY
 _mesa_Fogf(GLenum pname, GLfloat param)
 {
-   _mesa_Fogfv(pname, &param);
+   GLfloat fparam[4];
+   fparam[0] = param;
+   fparam[1] = fparam[2] = fparam[3] = 0.0F;
+   _mesa_Fogfv(pname, fparam);
 }
 
 
 void GLAPIENTRY
 _mesa_Fogi(GLenum pname, GLint param )
 {
-   GLfloat fparam = (GLfloat) param;
-   _mesa_Fogfv(pname, &fparam);
+   GLfloat fparam[4];
+   fparam[0] = (GLfloat) param;
+   fparam[1] = fparam[2] = fparam[3] = 0.0F;
+   _mesa_Fogfv(pname, fparam);
 }
 
 
diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
new file mode 100644 (file)
index 0000000..5983f00
--- /dev/null
@@ -0,0 +1,1159 @@
+/*
+ * Mesa 3-D graphics library
+ * Version:  7.7
+ *
+ * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
+ * Copyright (c) 2008-2009  VMware, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include "imports.h"
+#include "formats.h"
+#include "config.h"
+#include "texstore.h"
+
+
+/**
+ * Information about texture formats.
+ */
+struct gl_format_info
+{
+   gl_format Name;
+
+   /** text name for debugging */
+   const char *StrName;
+
+   /**
+    * Base format is one of GL_RGB, GL_RGBA, GL_ALPHA, GL_LUMINANCE,
+    * GL_LUMINANCE_ALPHA, GL_INTENSITY, GL_YCBCR_MESA, GL_COLOR_INDEX,
+    * GL_DEPTH_COMPONENT, GL_STENCIL_INDEX, GL_DEPTH_STENCIL.
+    */
+   GLenum BaseFormat;
+
+   /**
+    * Logical data type: one of  GL_UNSIGNED_NORMALIZED, GL_SIGNED_NORMALED,
+    * GL_UNSIGNED_INT, GL_SIGNED_INT, GL_FLOAT.
+    */
+   GLenum DataType;
+
+   GLubyte RedBits;
+   GLubyte GreenBits;
+   GLubyte BlueBits;
+   GLubyte AlphaBits;
+   GLubyte LuminanceBits;
+   GLubyte IntensityBits;
+   GLubyte IndexBits;
+   GLubyte DepthBits;
+   GLubyte StencilBits;
+
+   /**
+    * To describe compressed formats.  If not compressed, Width=Height=1.
+    */
+   GLubyte BlockWidth, BlockHeight;
+   GLubyte BytesPerBlock;
+};
+
+
+/**
+ * Info about each format.
+ * These must be in the same order as the MESA_FORMAT_* enums so that
+ * we can do lookups without searching.
+ */
+static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
+{
+   {
+      MESA_FORMAT_NONE,            /* Name */
+      "MESA_FORMAT_NONE",          /* StrName */
+      GL_NONE,                     /* BaseFormat */
+      GL_NONE,                     /* DataType */
+      0, 0, 0, 0,                  /* Red/Green/Blue/AlphaBits */
+      0, 0, 0, 0, 0,               /* Lum/Int/Index/Depth/StencilBits */
+      0, 0, 0                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_RGBA8888,        /* Name */
+      "MESA_FORMAT_RGBA8888",      /* StrName */
+      GL_RGBA,                     /* BaseFormat */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
+      8, 8, 8, 8,                  /* Red/Green/Blue/AlphaBits */
+      0, 0, 0, 0, 0,               /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 4                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_RGBA8888_REV,    /* Name */
+      "MESA_FORMAT_RGBA8888_REV",  /* StrName */
+      GL_RGBA,                     /* BaseFormat */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
+      8, 8, 8, 8,                  /* Red/Green/Blue/AlphaBits */
+      0, 0, 0, 0, 0,               /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 4                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_ARGB8888,        /* Name */
+      "MESA_FORMAT_ARGB8888",      /* StrName */
+      GL_RGBA,                     /* BaseFormat */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
+      8, 8, 8, 8,                  /* Red/Green/Blue/AlphaBits */
+      0, 0, 0, 0, 0,               /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 4                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_ARGB8888_REV,    /* Name */
+      "MESA_FORMAT_ARGB8888_REV",  /* StrName */
+      GL_RGBA,                     /* BaseFormat */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
+      8, 8, 8, 8,                  /* Red/Green/Blue/AlphaBits */
+      0, 0, 0, 0, 0,               /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 4                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_XRGB8888,        /* Name */
+      "MESA_FORMAT_XRGB8888",      /* StrName */
+      GL_RGB,                      /* BaseFormat */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
+      8, 8, 8, 0,                  /* Red/Green/Blue/AlphaBits */
+      0, 0, 0, 0, 0,               /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 4                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_XRGB8888_REV,    /* Name */
+      "MESA_FORMAT_XRGB8888_REV",  /* StrName */
+      GL_RGB,                      /* BaseFormat */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
+      8, 8, 8, 0,                  /* Red/Green/Blue/AlphaBits */
+      0, 0, 0, 0, 0,               /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 4                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_RGB888,          /* Name */
+      "MESA_FORMAT_RGB888",        /* StrName */
+      GL_RGB,                      /* BaseFormat */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
+      8, 8, 8, 0,                  /* Red/Green/Blue/AlphaBits */
+      0, 0, 0, 0, 0,               /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 3                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_BGR888,          /* Name */
+      "MESA_FORMAT_BGR888",        /* StrName */
+      GL_RGB,                      /* BaseFormat */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
+      8, 8, 8, 0,                  /* Red/Green/Blue/AlphaBits */
+      0, 0, 0, 0, 0,               /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 3                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_RGB565,          /* Name */
+      "MESA_FORMAT_RGB565",        /* StrName */
+      GL_RGB,                      /* BaseFormat */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
+      5, 6, 5, 0,                  /* Red/Green/Blue/AlphaBits */
+      0, 0, 0, 0, 0,               /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 2                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_RGB565_REV,      /* Name */
+      "MESA_FORMAT_RGB565_REV",    /* StrName */
+      GL_RGB,                      /* BaseFormat */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
+      5, 6, 5, 0,                  /* Red/Green/Blue/AlphaBits */
+      0, 0, 0, 0, 0,               /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 2                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_ARGB4444,        /* Name */
+      "MESA_FORMAT_ARGB4444",      /* StrName */
+      GL_RGBA,                     /* BaseFormat */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
+      4, 4, 4, 4,                  /* Red/Green/Blue/AlphaBits */
+      0, 0, 0, 0, 0,               /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 2                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_ARGB4444_REV,    /* Name */
+      "MESA_FORMAT_ARGB4444_REV",  /* StrName */
+      GL_RGBA,                     /* BaseFormat */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
+      4, 4, 4, 4,                  /* Red/Green/Blue/AlphaBits */
+      0, 0, 0, 0, 0,               /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 2                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_RGBA5551,        /* Name */
+      "MESA_FORMAT_RGBA5551",      /* StrName */
+      GL_RGBA,                     /* BaseFormat */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
+      5, 5, 5, 1,                  /* Red/Green/Blue/AlphaBits */
+      0, 0, 0, 0, 0,               /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 2                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_ARGB1555,        /* Name */
+      "MESA_FORMAT_ARGB1555",      /* StrName */
+      GL_RGBA,                     /* BaseFormat */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
+      5, 5, 5, 1,                  /* Red/Green/Blue/AlphaBits */
+      0, 0, 0, 0, 0,               /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 2                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_ARGB1555_REV,    /* Name */
+      "MESA_FORMAT_ARGB1555_REV",  /* StrName */
+      GL_RGBA,                     /* BaseFormat */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
+      5, 5, 5, 1,                  /* Red/Green/Blue/AlphaBits */
+      0, 0, 0, 0, 0,               /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 2                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_AL88,            /* Name */
+      "MESA_FORMAT_AL88",          /* StrName */
+      GL_LUMINANCE_ALPHA,          /* BaseFormat */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
+      0, 0, 0, 8,                  /* Red/Green/Blue/AlphaBits */
+      8, 0, 0, 0, 0,               /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 2                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_AL88_REV,        /* Name */
+      "MESA_FORMAT_AL88_REV",      /* StrName */
+      GL_LUMINANCE_ALPHA,          /* BaseFormat */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
+      0, 0, 0, 8,                  /* Red/Green/Blue/AlphaBits */
+      8, 0, 0, 0, 0,               /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 2                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_AL1616,          /* Name */
+      "MESA_FORMAT_AL1616",        /* StrName */
+      GL_LUMINANCE_ALPHA,          /* BaseFormat */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
+      0, 0, 0, 16,                 /* Red/Green/Blue/AlphaBits */
+      16, 0, 0, 0, 0,              /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 4                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_AL1616_REV,      /* Name */
+      "MESA_FORMAT_AL1616_REV",    /* StrName */
+      GL_LUMINANCE_ALPHA,          /* BaseFormat */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
+      0, 0, 0, 16,                 /* Red/Green/Blue/AlphaBits */
+      16, 0, 0, 0, 0,              /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 4                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_RGB332,          /* Name */
+      "MESA_FORMAT_RGB332",        /* StrName */
+      GL_RGB,                      /* BaseFormat */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
+      3, 3, 2, 0,                  /* Red/Green/Blue/AlphaBits */
+      0, 0, 0, 0, 0,               /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 1                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_A8,              /* Name */
+      "MESA_FORMAT_A8",            /* StrName */
+      GL_ALPHA,                    /* BaseFormat */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
+      0, 0, 0, 8,                  /* Red/Green/Blue/AlphaBits */
+      0, 0, 0, 0, 0,               /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 1                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_L8,              /* Name */
+      "MESA_FORMAT_L8",            /* StrName */
+      GL_LUMINANCE,                /* BaseFormat */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
+      0, 0, 0, 0,                  /* Red/Green/Blue/AlphaBits */
+      8, 0, 0, 0, 0,               /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 1                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_I8,              /* Name */
+      "MESA_FORMAT_I8",            /* StrName */
+      GL_INTENSITY,                /* BaseFormat */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
+      0, 0, 0, 0,                  /* Red/Green/Blue/AlphaBits */
+      0, 8, 0, 0, 0,               /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 1                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_CI8,             /* Name */
+      "MESA_FORMAT_CI8",           /* StrName */
+      GL_COLOR_INDEX,              /* BaseFormat */
+      GL_UNSIGNED_INT,             /* DataType */
+      0, 0, 0, 0,                  /* Red/Green/Blue/AlphaBits */
+      0, 0, 8, 0, 0,               /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 1                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_YCBCR,           /* Name */
+      "MESA_FORMAT_YCBCR",         /* StrName */
+      GL_YCBCR_MESA,               /* BaseFormat */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
+      0, 0, 0, 0,                  /* Red/Green/Blue/AlphaBits */
+      0, 0, 0, 0, 0,               /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 2                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_YCBCR_REV,       /* Name */
+      "MESA_FORMAT_YCBCR_REV",     /* StrName */
+      GL_YCBCR_MESA,               /* BaseFormat */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
+      0, 0, 0, 0,                  /* Red/Green/Blue/AlphaBits */
+      0, 0, 0, 0, 0,               /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 2                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_Z24_S8,          /* Name */
+      "MESA_FORMAT_Z24_S8",        /* StrName */
+      GL_DEPTH_STENCIL,            /* BaseFormat */
+      GL_UNSIGNED_INT,             /* DataType */
+      0, 0, 0, 0,                  /* Red/Green/Blue/AlphaBits */
+      0, 0, 0, 24, 8,              /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 4                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_S8_Z24,          /* Name */
+      "MESA_FORMAT_S8_Z24",        /* StrName */
+      GL_DEPTH_STENCIL,            /* BaseFormat */
+      GL_UNSIGNED_INT,             /* DataType */
+      0, 0, 0, 0,                  /* Red/Green/Blue/AlphaBits */
+      0, 0, 0, 24, 8,              /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 4                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_Z16,             /* Name */
+      "MESA_FORMAT_Z16",           /* StrName */
+      GL_DEPTH_COMPONENT,          /* BaseFormat */
+      GL_UNSIGNED_INT,             /* DataType */
+      0, 0, 0, 0,                  /* Red/Green/Blue/AlphaBits */
+      0, 0, 0, 16, 0,              /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 2                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_X8_Z24,          /* Name */
+      "MESA_FORMAT_X8_Z24",        /* StrName */
+      GL_DEPTH_COMPONENT,          /* BaseFormat */
+      GL_UNSIGNED_INT,             /* DataType */
+      0, 0, 0, 0,                  /* Red/Green/Blue/AlphaBits */
+      0, 0, 0, 24, 0,              /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 4                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_Z24_X8,          /* Name */
+      "MESA_FORMAT_Z24_X8",        /* StrName */
+      GL_DEPTH_COMPONENT,          /* BaseFormat */
+      GL_UNSIGNED_INT,             /* DataType */
+      0, 0, 0, 0,                  /* Red/Green/Blue/AlphaBits */
+      0, 0, 0, 24, 0,              /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 4                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_Z32,             /* Name */
+      "MESA_FORMAT_Z32",           /* StrName */
+      GL_DEPTH_COMPONENT,          /* BaseFormat */
+      GL_UNSIGNED_INT,             /* DataType */
+      0, 0, 0, 0,                  /* Red/Green/Blue/AlphaBits */
+      0, 0, 0, 32, 0,              /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 4                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_S8,              /* Name */
+      "MESA_FORMAT_S8",            /* StrName */
+      GL_STENCIL_INDEX,            /* BaseFormat */
+      GL_UNSIGNED_INT,             /* DataType */
+      0, 0, 0, 0,                  /* Red/Green/Blue/AlphaBits */
+      0, 0, 0, 0, 8,               /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 1                      /* BlockWidth/Height,Bytes */
+   },
+   {
+      MESA_FORMAT_SRGB8,
+      "MESA_FORMAT_SRGB8",
+      GL_RGB,
+      GL_UNSIGNED_NORMALIZED,
+      8, 8, 8, 0,
+      0, 0, 0, 0, 0,
+      1, 1, 3
+   },
+   {
+      MESA_FORMAT_SRGBA8,
+      "MESA_FORMAT_SRGBA8",
+      GL_RGBA,
+      GL_UNSIGNED_NORMALIZED,    
+      8, 8, 8, 8,
+      0, 0, 0, 0, 0,
+      1, 1, 4
+   },
+   {
+      MESA_FORMAT_SARGB8,
+      "MESA_FORMAT_SARGB8",
+      GL_RGBA,
+      GL_UNSIGNED_NORMALIZED,    
+      8, 8, 8, 8,
+      0, 0, 0, 0, 0,
+      1, 1, 4
+   },
+   {
+      MESA_FORMAT_SL8,
+      "MESA_FORMAT_SL8",
+      GL_LUMINANCE,
+      GL_UNSIGNED_NORMALIZED,    
+      0, 0, 0, 0,
+      8, 0, 0, 0, 0,
+      1, 1, 1
+   },
+   {
+      MESA_FORMAT_SLA8,
+      "MESA_FORMAT_SLA8",
+      GL_LUMINANCE_ALPHA,
+      GL_UNSIGNED_NORMALIZED,    
+      0, 0, 0, 8,
+      8, 0, 0, 0, 0,
+      1, 1, 2
+   },
+   {
+      MESA_FORMAT_SRGB_DXT1,       /* Name */
+      "MESA_FORMAT_SRGB_DXT1",     /* StrName */
+      GL_RGB,                      /* BaseFormat */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
+      4, 4, 4, 0,                  /* approx Red/Green/Blue/AlphaBits */
+      0, 0, 0, 0, 0,               /* Lum/Int/Index/Depth/StencilBits */
+      4, 4, 8                      /* 8 bytes per 4x4 block */
+   },
+   {
+      MESA_FORMAT_SRGBA_DXT1,
+      "MESA_FORMAT_SRGBA_DXT1",
+      GL_RGBA,
+      GL_UNSIGNED_NORMALIZED,
+      4, 4, 4, 4,
+      0, 0, 0, 0, 0,
+      4, 4, 8                      /* 8 bytes per 4x4 block */
+   },
+   {
+      MESA_FORMAT_SRGBA_DXT3,
+      "MESA_FORMAT_SRGBA_DXT3",
+      GL_RGBA,
+      GL_UNSIGNED_NORMALIZED,
+      4, 4, 4, 4,
+      0, 0, 0, 0, 0,
+      4, 4, 16                     /* 16 bytes per 4x4 block */
+   },
+   {
+      MESA_FORMAT_SRGBA_DXT5,
+      "MESA_FORMAT_SRGBA_DXT5",
+      GL_RGBA,
+      GL_UNSIGNED_NORMALIZED,
+      4, 4, 4, 4,
+      0, 0, 0, 0, 0,
+      4, 4, 16                     /* 16 bytes per 4x4 block */
+   },
+
+   {
+      MESA_FORMAT_RGB_FXT1,
+      "MESA_FORMAT_RGB_FXT1",
+      GL_RGB,
+      GL_UNSIGNED_NORMALIZED,
+      4, 4, 4, 0,                  /* approx Red/Green/BlueBits */
+      0, 0, 0, 0, 0,
+      8, 4, 16                     /* 16 bytes per 8x4 block */
+   },
+   {
+      MESA_FORMAT_RGBA_FXT1,
+      "MESA_FORMAT_RGBA_FXT1",
+      GL_RGBA,
+      GL_UNSIGNED_NORMALIZED,
+      4, 4, 4, 1,                  /* approx Red/Green/Blue/AlphaBits */
+      0, 0, 0, 0, 0,
+      8, 4, 16                     /* 16 bytes per 8x4 block */
+   },
+
+   {
+      MESA_FORMAT_RGB_DXT1,        /* Name */
+      "MESA_FORMAT_RGB_DXT1",      /* StrName */
+      GL_RGB,                      /* BaseFormat */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
+      4, 4, 4, 0,                  /* approx Red/Green/Blue/AlphaBits */
+      0, 0, 0, 0, 0,               /* Lum/Int/Index/Depth/StencilBits */
+      4, 4, 8                      /* 8 bytes per 4x4 block */
+   },
+   {
+      MESA_FORMAT_RGBA_DXT1,
+      "MESA_FORMAT_RGBA_DXT1",
+      GL_RGBA,
+      GL_UNSIGNED_NORMALIZED,    
+      4, 4, 4, 4,
+      0, 0, 0, 0, 0,
+      4, 4, 8                      /* 8 bytes per 4x4 block */
+   },
+   {
+      MESA_FORMAT_RGBA_DXT3,
+      "MESA_FORMAT_RGBA_DXT3",
+      GL_RGBA,
+      GL_UNSIGNED_NORMALIZED,    
+      4, 4, 4, 4,
+      0, 0, 0, 0, 0,
+      4, 4, 16                     /* 16 bytes per 4x4 block */
+   },
+   {
+      MESA_FORMAT_RGBA_DXT5,
+      "MESA_FORMAT_RGBA_DXT5",
+      GL_RGBA,
+      GL_UNSIGNED_NORMALIZED,    
+      4, 4, 4, 4,
+      0, 0, 0, 0, 0,
+      4, 4, 16                     /* 16 bytes per 4x4 block */
+   },
+   {
+      MESA_FORMAT_RGBA_FLOAT32,
+      "MESA_FORMAT_RGBA_FLOAT32",
+      GL_RGBA,
+      GL_FLOAT,
+      32, 32, 32, 32,
+      0, 0, 0, 0, 0,
+      1, 1, 16
+   },
+   {
+      MESA_FORMAT_RGBA_FLOAT16,
+      "MESA_FORMAT_RGBA_FLOAT16",
+      GL_RGBA,
+      GL_FLOAT,
+      16, 16, 16, 16,
+      0, 0, 0, 0, 0,
+      1, 1, 8
+   },
+   {
+      MESA_FORMAT_RGB_FLOAT32,
+      "MESA_FORMAT_RGB_FLOAT32",
+      GL_RGB,
+      GL_FLOAT,
+      32, 32, 32, 0,
+      0, 0, 0, 0, 0,
+      1, 1, 12
+   },
+   {
+      MESA_FORMAT_RGB_FLOAT16,
+      "MESA_FORMAT_RGB_FLOAT16",
+      GL_RGB,
+      GL_FLOAT,
+      16, 16, 16, 0,
+      0, 0, 0, 0, 0,
+      1, 1, 6
+   },
+   {
+      MESA_FORMAT_ALPHA_FLOAT32,
+      "MESA_FORMAT_ALPHA_FLOAT32",
+      GL_ALPHA,
+      GL_FLOAT,
+      0, 0, 0, 32,
+      0, 0, 0, 0, 0,
+      1, 1, 4
+   },
+   {
+      MESA_FORMAT_ALPHA_FLOAT16,
+      "MESA_FORMAT_ALPHA_FLOAT16",
+      GL_ALPHA,
+      GL_FLOAT,
+      0, 0, 0, 16,
+      0, 0, 0, 0, 0,
+      1, 1, 2
+   },
+   {
+      MESA_FORMAT_LUMINANCE_FLOAT32,
+      "MESA_FORMAT_LUMINANCE_FLOAT32",
+      GL_ALPHA,
+      GL_FLOAT,
+      0, 0, 0, 0,
+      32, 0, 0, 0, 0,
+      1, 1, 4
+   },
+   {
+      MESA_FORMAT_LUMINANCE_FLOAT16,
+      "MESA_FORMAT_LUMINANCE_FLOAT16",
+      GL_ALPHA,
+      GL_FLOAT,
+      0, 0, 0, 0,
+      16, 0, 0, 0, 0,
+      1, 1, 2
+   },
+   {
+      MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32,
+      "MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32",
+      GL_LUMINANCE_ALPHA,
+      GL_FLOAT,
+      0, 0, 0, 32,
+      32, 0, 0, 0, 0,
+      1, 1, 8
+   },
+   {
+      MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16,
+      "MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16",
+      GL_LUMINANCE_ALPHA,
+      GL_FLOAT,
+      0, 0, 0, 16,
+      16, 0, 0, 0, 0,
+      1, 1, 4
+   },
+   {
+      MESA_FORMAT_INTENSITY_FLOAT32,
+      "MESA_FORMAT_INTENSITY_FLOAT32",
+      GL_INTENSITY,
+      GL_FLOAT,
+      0, 0, 0, 0,
+      0, 32, 0, 0, 0,
+      1, 1, 4
+   },
+   {
+      MESA_FORMAT_INTENSITY_FLOAT16,
+      "MESA_FORMAT_INTENSITY_FLOAT16",
+      GL_INTENSITY,
+      GL_FLOAT,
+      0, 0, 0, 0,
+      0, 16, 0, 0, 0,
+      1, 1, 2
+   },
+   {
+      MESA_FORMAT_DUDV8,
+      "MESA_FORMAT_DUDV8",
+      GL_DUDV_ATI,
+      GL_SIGNED_NORMALIZED,
+      0, 0, 0, 0,
+      0, 0, 0, 0, 0,
+      1, 1, 2
+   },
+   {
+      MESA_FORMAT_SIGNED_RGBA8888,
+      "MESA_FORMAT_SIGNED_RGBA8888",
+      GL_RGBA,
+      GL_SIGNED_NORMALIZED,
+      8, 8, 8, 8,
+      0, 0, 0, 0, 0,
+      1, 1, 4
+   },
+   {
+      MESA_FORMAT_SIGNED_RGBA8888_REV,
+      "MESA_FORMAT_SIGNED_RGBA8888_REV",
+      GL_RGBA,
+      GL_SIGNED_NORMALIZED,
+      8, 8, 8, 8,
+      0, 0, 0, 0, 0,
+      1, 1, 4
+   },
+   {
+      MESA_FORMAT_SIGNED_RGBA_16,
+      "MESA_FORMAT_SIGNED_RGBA_16",
+      GL_RGBA,
+      GL_SIGNED_NORMALIZED,
+      16, 16, 16, 16,
+      0, 0, 0, 0, 0,
+      1, 1, 8
+   }
+};
+
+
+
+static const struct gl_format_info *
+_mesa_get_format_info(gl_format format)
+{
+   const struct gl_format_info *info = &format_info[format];
+   assert(info->Name == format);
+   return info;
+}
+
+
+/** Return string name of format (for debugging) */
+const char *
+_mesa_get_format_name(gl_format format)
+{
+   const struct gl_format_info *info = _mesa_get_format_info(format);
+   ASSERT(info->BytesPerBlock);
+   return info->StrName;
+}
+
+
+
+/**
+ * Return bytes needed to store a block of pixels in the given format.
+ * Normally, a block is 1x1 (a single pixel).  But for compressed formats
+ * a block may be 4x4 or 8x4, etc.
+ */
+GLuint
+_mesa_get_format_bytes(gl_format format)
+{
+   const struct gl_format_info *info = _mesa_get_format_info(format);
+   ASSERT(info->BytesPerBlock);
+   return info->BytesPerBlock;
+}
+
+
+/**
+ * Return bits per component for the given format.
+ * \param format  one of MESA_FORMAT_x
+ * \param pname  the component, such as GL_RED_BITS, GL_TEXTURE_BLUE_BITS, etc.
+ */
+GLint
+_mesa_get_format_bits(gl_format format, GLenum pname)
+{
+   const struct gl_format_info *info = _mesa_get_format_info(format);
+
+   switch (pname) {
+   case GL_RED_BITS:
+   case GL_TEXTURE_RED_SIZE:
+   case GL_RENDERBUFFER_RED_SIZE_EXT:
+   case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
+      return info->RedBits;
+   case GL_GREEN_BITS:
+   case GL_TEXTURE_GREEN_SIZE:
+   case GL_RENDERBUFFER_GREEN_SIZE_EXT:
+   case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
+      return info->GreenBits;
+   case GL_BLUE_BITS:
+   case GL_TEXTURE_BLUE_SIZE:
+   case GL_RENDERBUFFER_BLUE_SIZE_EXT:
+   case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
+      return info->BlueBits;
+   case GL_ALPHA_BITS:
+   case GL_TEXTURE_ALPHA_SIZE:
+   case GL_RENDERBUFFER_ALPHA_SIZE_EXT:
+   case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
+      return info->AlphaBits;
+   case GL_TEXTURE_INTENSITY_SIZE:
+      return info->IntensityBits;
+   case GL_TEXTURE_LUMINANCE_SIZE:
+      return info->LuminanceBits;
+   case GL_INDEX_BITS:
+   case GL_TEXTURE_INDEX_SIZE_EXT:
+      return info->IndexBits;
+   case GL_DEPTH_BITS:
+   case GL_TEXTURE_DEPTH_SIZE_ARB:
+   case GL_RENDERBUFFER_DEPTH_SIZE_EXT:
+   case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
+      return info->DepthBits;
+   case GL_STENCIL_BITS:
+   case GL_TEXTURE_STENCIL_SIZE_EXT:
+   case GL_RENDERBUFFER_STENCIL_SIZE_EXT:
+   case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
+      return info->StencilBits;
+   default:
+      _mesa_problem(NULL, "bad pname in _mesa_get_format_bits()");
+      return 0;
+   }
+}
+
+
+/**
+ * Return the data type (or more specifically, the data representation)
+ * for the given format.
+ * The return value will be one of:
+ *    GL_UNSIGNED_NORMALIZED = unsigned int representing [0,1]
+ *    GL_SIGNED_NORMALIZED = signed int representing [-1, 1]
+ *    GL_UNSIGNED_INT = an ordinary unsigned integer
+ *    GL_FLOAT = an ordinary float
+ */
+GLenum
+_mesa_get_format_datatype(gl_format format)
+{
+   const struct gl_format_info *info = _mesa_get_format_info(format);
+   return info->DataType;
+}
+
+
+/**
+ * Return the basic format for the given type.  The result will be
+ * one of GL_RGB, GL_RGBA, GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA,
+ * GL_INTENSITY, GL_YCBCR_MESA, GL_COLOR_INDEX, GL_DEPTH_COMPONENT,
+ * GL_STENCIL_INDEX, GL_DEPTH_STENCIL.
+ */
+GLenum
+_mesa_get_format_base_format(gl_format format)
+{
+   const struct gl_format_info *info = _mesa_get_format_info(format);
+   return info->BaseFormat;
+}
+
+
+/**
+ * Return the block size (in pixels) for the given format.  Normally
+ * the block size is 1x1.  But compressed formats will have block sizes
+ * of 4x4 or 8x4 pixels, etc.
+ * \param bw  returns block width in pixels
+ * \param bh  returns block height in pixels
+ */
+void
+_mesa_get_format_block_size(gl_format format, GLuint *bw, GLuint *bh)
+{
+   const struct gl_format_info *info = _mesa_get_format_info(format);
+   *bw = info->BlockWidth;
+   *bh = info->BlockHeight;
+}
+
+
+/** Is the given format a compressed format? */
+GLboolean
+_mesa_is_format_compressed(gl_format format)
+{
+   const struct gl_format_info *info = _mesa_get_format_info(format);
+   return info->BlockWidth > 1 || info->BlockHeight > 1;
+}
+
+
+/**
+ * Return color encoding for given format.
+ * \return GL_LINEAR or GL_SRGB
+ */
+GLenum
+_mesa_get_format_color_encoding(gl_format format)
+{
+   /* XXX this info should be encoded in gl_format_info */
+   switch (format) {
+   case MESA_FORMAT_SRGB8:
+   case MESA_FORMAT_SRGBA8:
+   case MESA_FORMAT_SARGB8:
+   case MESA_FORMAT_SL8:
+   case MESA_FORMAT_SLA8:
+   case MESA_FORMAT_SRGB_DXT1:
+   case MESA_FORMAT_SRGBA_DXT1:
+   case MESA_FORMAT_SRGBA_DXT3:
+   case MESA_FORMAT_SRGBA_DXT5:
+      return GL_SRGB;
+   default:
+      return GL_LINEAR;
+   }
+}
+
+
+/**
+ * Return number of bytes needed to store an image of the given size
+ * in the given format.
+ */
+GLuint
+_mesa_format_image_size(gl_format format, GLsizei width,
+                        GLsizei height, GLsizei depth)
+{
+   const struct gl_format_info *info = _mesa_get_format_info(format);
+   /* Strictly speaking, a conditional isn't needed here */
+   if (info->BlockWidth > 1 || info->BlockHeight > 1) {
+      /* compressed format */
+      const GLuint bw = info->BlockWidth, bh = info->BlockHeight;
+      const GLuint wblocks = (width + bw - 1) / bw;
+      const GLuint hblocks = (height + bh - 1) / bh;
+      const GLuint sz = wblocks * hblocks * info->BytesPerBlock;
+      return sz;
+   }
+   else {
+      /* non-compressed */
+      const GLuint sz = width * height * depth * info->BytesPerBlock;
+      return sz;
+   }
+}
+
+
+
+GLint
+_mesa_format_row_stride(gl_format format, GLsizei width)
+{
+   const struct gl_format_info *info = _mesa_get_format_info(format);
+   /* Strictly speaking, a conditional isn't needed here */
+   if (info->BlockWidth > 1 || info->BlockHeight > 1) {
+      /* compressed format */
+      const GLuint bw = info->BlockWidth;
+      const GLuint wblocks = (width + bw - 1) / bw;
+      const GLint stride = wblocks * info->BytesPerBlock;
+      return stride;
+   }
+   else {
+      const GLint stride = width * info->BytesPerBlock;
+      return stride;
+   }
+}
+
+
+
+/**
+ * Do sanity checking of the format info table.
+ */
+void
+_mesa_test_formats(void)
+{
+   GLuint i;
+
+   assert(Elements(format_info) == MESA_FORMAT_COUNT);
+
+   for (i = 0; i < MESA_FORMAT_COUNT; i++) {
+      const struct gl_format_info *info = _mesa_get_format_info(i);
+      assert(info);
+
+      assert(info->Name == i);
+
+      if (info->Name == MESA_FORMAT_NONE)
+         continue;
+
+      if (info->BlockWidth == 1 && info->BlockHeight == 1) {
+         if (info->RedBits > 0) {
+            GLuint t = info->RedBits + info->GreenBits
+               + info->BlueBits + info->AlphaBits;
+            assert(t / 8 == info->BytesPerBlock);
+            (void) t;
+         }
+      }
+
+      assert(info->DataType == GL_UNSIGNED_NORMALIZED ||
+             info->DataType == GL_SIGNED_NORMALIZED ||
+             info->DataType == GL_UNSIGNED_INT ||
+             info->DataType == GL_FLOAT);
+
+      if (info->BaseFormat == GL_RGB) {
+         assert(info->RedBits > 0);
+         assert(info->GreenBits > 0);
+         assert(info->BlueBits > 0);
+         assert(info->AlphaBits == 0);
+         assert(info->LuminanceBits == 0);
+         assert(info->IntensityBits == 0);
+      }
+      else if (info->BaseFormat == GL_RGBA) {
+         assert(info->RedBits > 0);
+         assert(info->GreenBits > 0);
+         assert(info->BlueBits > 0);
+         assert(info->AlphaBits > 0);
+         assert(info->LuminanceBits == 0);
+         assert(info->IntensityBits == 0);
+      }
+      else if (info->BaseFormat == GL_LUMINANCE) {
+         assert(info->RedBits == 0);
+         assert(info->GreenBits == 0);
+         assert(info->BlueBits == 0);
+         assert(info->AlphaBits == 0);
+         assert(info->LuminanceBits > 0);
+         assert(info->IntensityBits == 0);
+      }
+      else if (info->BaseFormat == GL_INTENSITY) {
+         assert(info->RedBits == 0);
+         assert(info->GreenBits == 0);
+         assert(info->BlueBits == 0);
+         assert(info->AlphaBits == 0);
+         assert(info->LuminanceBits == 0);
+         assert(info->IntensityBits > 0);
+      }
+
+   }
+}
+
+
+
+/**
+ * Return datatype and number of components per texel for the given gl_format.
+ * Only used for mipmap generation code.
+ */
+void
+_mesa_format_to_type_and_comps(gl_format format,
+                               GLenum *datatype, GLuint *comps)
+{
+   switch (format) {
+   case MESA_FORMAT_RGBA8888:
+   case MESA_FORMAT_RGBA8888_REV:
+   case MESA_FORMAT_ARGB8888:
+   case MESA_FORMAT_ARGB8888_REV:
+   case MESA_FORMAT_XRGB8888:
+      *datatype = GL_UNSIGNED_BYTE;
+      *comps = 4;
+      return;
+   case MESA_FORMAT_RGB888:
+   case MESA_FORMAT_BGR888:
+      *datatype = GL_UNSIGNED_BYTE;
+      *comps = 3;
+      return;
+   case MESA_FORMAT_RGB565:
+   case MESA_FORMAT_RGB565_REV:
+      *datatype = GL_UNSIGNED_SHORT_5_6_5;
+      *comps = 3;
+      return;
+
+   case MESA_FORMAT_ARGB4444:
+   case MESA_FORMAT_ARGB4444_REV:
+      *datatype = GL_UNSIGNED_SHORT_4_4_4_4;
+      *comps = 4;
+      return;
+
+   case MESA_FORMAT_ARGB1555:
+   case MESA_FORMAT_ARGB1555_REV:
+      *datatype = GL_UNSIGNED_SHORT_1_5_5_5_REV;
+      *comps = 4;
+      return;
+
+   case MESA_FORMAT_AL88:
+   case MESA_FORMAT_AL88_REV:
+      *datatype = GL_UNSIGNED_BYTE;
+      *comps = 2;
+      return;
+
+   case MESA_FORMAT_AL1616:
+   case MESA_FORMAT_AL1616_REV:
+      *datatype = GL_UNSIGNED_SHORT;
+      *comps = 2;
+      return;
+
+   case MESA_FORMAT_RGB332:
+      *datatype = GL_UNSIGNED_BYTE_3_3_2;
+      *comps = 3;
+      return;
+
+   case MESA_FORMAT_A8:
+   case MESA_FORMAT_L8:
+   case MESA_FORMAT_I8:
+   case MESA_FORMAT_CI8:
+      *datatype = GL_UNSIGNED_BYTE;
+      *comps = 1;
+      return;
+
+   case MESA_FORMAT_YCBCR:
+   case MESA_FORMAT_YCBCR_REV:
+      *datatype = GL_UNSIGNED_SHORT;
+      *comps = 2;
+      return;
+
+   case MESA_FORMAT_Z24_S8:
+      *datatype = GL_UNSIGNED_INT;
+      *comps = 1; /* XXX OK? */
+      return;
+
+   case MESA_FORMAT_S8_Z24:
+      *datatype = GL_UNSIGNED_INT;
+      *comps = 1; /* XXX OK? */
+      return;
+
+   case MESA_FORMAT_Z16:
+      *datatype = GL_UNSIGNED_SHORT;
+      *comps = 1;
+      return;
+
+   case MESA_FORMAT_X8_Z24:
+      *datatype = GL_UNSIGNED_INT;
+      *comps = 1;
+      return;
+
+   case MESA_FORMAT_Z24_X8:
+      *datatype = GL_UNSIGNED_INT;
+      *comps = 1;
+      return;
+
+   case MESA_FORMAT_Z32:
+      *datatype = GL_UNSIGNED_INT;
+      *comps = 1;
+      return;
+
+   case MESA_FORMAT_DUDV8:
+      *datatype = GL_BYTE;
+      *comps = 2;
+      return;
+
+   case MESA_FORMAT_SIGNED_RGBA8888:
+   case MESA_FORMAT_SIGNED_RGBA8888_REV:
+      *datatype = GL_BYTE;
+      *comps = 4;
+      return;
+   case MESA_FORMAT_SIGNED_RGBA_16:
+      *datatype = GL_SHORT;
+      *comps = 4;
+      return;
+
+#if FEATURE_EXT_texture_sRGB
+   case MESA_FORMAT_SRGB8:
+      *datatype = GL_UNSIGNED_BYTE;
+      *comps = 3;
+      return;
+   case MESA_FORMAT_SRGBA8:
+   case MESA_FORMAT_SARGB8:
+      *datatype = GL_UNSIGNED_BYTE;
+      *comps = 4;
+      return;
+   case MESA_FORMAT_SL8:
+      *datatype = GL_UNSIGNED_BYTE;
+      *comps = 1;
+      return;
+   case MESA_FORMAT_SLA8:
+      *datatype = GL_UNSIGNED_BYTE;
+      *comps = 2;
+      return;
+#endif
+
+#if FEATURE_texture_fxt1
+   case MESA_FORMAT_RGB_FXT1:
+   case MESA_FORMAT_RGBA_FXT1:
+#endif
+#if FEATURE_texture_s3tc
+   case MESA_FORMAT_RGB_DXT1:
+   case MESA_FORMAT_RGBA_DXT1:
+   case MESA_FORMAT_RGBA_DXT3:
+   case MESA_FORMAT_RGBA_DXT5:
+#if FEATURE_EXT_texture_sRGB
+   case MESA_FORMAT_SRGB_DXT1:
+   case MESA_FORMAT_SRGBA_DXT1:
+   case MESA_FORMAT_SRGBA_DXT3:
+   case MESA_FORMAT_SRGBA_DXT5:
+#endif
+      /* XXX generate error instead? */
+      *datatype = GL_UNSIGNED_BYTE;
+      *comps = 0;
+      return;
+#endif
+
+   case MESA_FORMAT_RGBA_FLOAT32:
+      *datatype = GL_FLOAT;
+      *comps = 4;
+      return;
+   case MESA_FORMAT_RGBA_FLOAT16:
+      *datatype = GL_HALF_FLOAT_ARB;
+      *comps = 4;
+      return;
+   case MESA_FORMAT_RGB_FLOAT32:
+      *datatype = GL_FLOAT;
+      *comps = 3;
+      return;
+   case MESA_FORMAT_RGB_FLOAT16:
+      *datatype = GL_HALF_FLOAT_ARB;
+      *comps = 3;
+      return;
+   case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32:
+      *datatype = GL_FLOAT;
+      *comps = 2;
+      return;
+   case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16:
+      *datatype = GL_HALF_FLOAT_ARB;
+      *comps = 2;
+      return;
+   case MESA_FORMAT_ALPHA_FLOAT32:
+   case MESA_FORMAT_LUMINANCE_FLOAT32:
+   case MESA_FORMAT_INTENSITY_FLOAT32:
+      *datatype = GL_FLOAT;
+      *comps = 1;
+      return;
+   case MESA_FORMAT_ALPHA_FLOAT16:
+   case MESA_FORMAT_LUMINANCE_FLOAT16:
+   case MESA_FORMAT_INTENSITY_FLOAT16:
+      *datatype = GL_HALF_FLOAT_ARB;
+      *comps = 1;
+      return;
+
+   default:
+      _mesa_problem(NULL, "bad format in _mesa_format_to_type_and_comps");
+      *datatype = 0;
+      *comps = 1;
+   }
+}
diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h
new file mode 100644 (file)
index 0000000..0eeeb8b
--- /dev/null
@@ -0,0 +1,185 @@
+/*
+ * Mesa 3-D graphics library
+ * Version:  7.7
+ *
+ * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
+ * Copyright (c) 2008-2009  VMware, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * Authors:
+ *   Brian Paul
+ */
+
+
+#ifndef FORMATS_H
+#define FORMATS_H
+
+
+#include "main/mtypes.h"
+
+
+
+/**
+ * Mesa texture/renderbuffer image formats.
+ */
+typedef enum
+{
+   MESA_FORMAT_NONE = 0,
+
+   /** 
+    * \name Basic hardware formats
+    */
+   /*@{*/
+                               /* msb <------ TEXEL BITS -----------> lsb */
+                               /* ---- ---- ---- ---- ---- ---- ---- ---- */
+   MESA_FORMAT_RGBA8888,       /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */
+   MESA_FORMAT_RGBA8888_REV,   /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */
+   MESA_FORMAT_ARGB8888,       /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */
+   MESA_FORMAT_ARGB8888_REV,   /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */
+   MESA_FORMAT_XRGB8888,       /* xxxx xxxx RRRR RRRR GGGG GGGG BBBB BBBB */
+   MESA_FORMAT_XRGB8888_REV,   /* BBBB BBBB GGGG GGGG RRRR RRRR xxxx xxxx */
+   MESA_FORMAT_RGB888,         /*           RRRR RRRR GGGG GGGG BBBB BBBB */
+   MESA_FORMAT_BGR888,         /*           BBBB BBBB GGGG GGGG RRRR RRRR */
+   MESA_FORMAT_RGB565,         /*                     RRRR RGGG GGGB BBBB */
+   MESA_FORMAT_RGB565_REV,     /*                     GGGB BBBB RRRR RGGG */
+   MESA_FORMAT_ARGB4444,       /*                     AAAA RRRR GGGG BBBB */
+   MESA_FORMAT_ARGB4444_REV,   /*                     GGGG BBBB AAAA RRRR */
+   MESA_FORMAT_RGBA5551,        /*                     RRRR RGGG GGBB BBBA */
+   MESA_FORMAT_ARGB1555,       /*                     ARRR RRGG GGGB BBBB */
+   MESA_FORMAT_ARGB1555_REV,   /*                     GGGB BBBB ARRR RRGG */
+   MESA_FORMAT_AL88,           /*                     AAAA AAAA LLLL LLLL */
+   MESA_FORMAT_AL88_REV,       /*                     LLLL LLLL AAAA AAAA */
+   MESA_FORMAT_AL1616,          /* AAAA AAAA AAAA AAAA LLLL LLLL LLLL LLLL */
+   MESA_FORMAT_AL1616_REV,      /* LLLL LLLL LLLL LLLL AAAA AAAA AAAA AAAA */
+   MESA_FORMAT_RGB332,         /*                               RRRG GGBB */
+   MESA_FORMAT_A8,             /*                               AAAA AAAA */
+   MESA_FORMAT_L8,             /*                               LLLL LLLL */
+   MESA_FORMAT_I8,             /*                               IIII IIII */
+   MESA_FORMAT_CI8,            /*                               CCCC CCCC */
+   MESA_FORMAT_YCBCR,          /*                     YYYY YYYY UorV UorV */
+   MESA_FORMAT_YCBCR_REV,      /*                     UorV UorV YYYY YYYY */
+   MESA_FORMAT_Z24_S8,          /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ SSSS SSSS */
+   MESA_FORMAT_S8_Z24,          /* SSSS SSSS ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */
+   MESA_FORMAT_Z16,             /*                     ZZZZ ZZZZ ZZZZ ZZZZ */
+   MESA_FORMAT_X8_Z24,          /* xxxx xxxx ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */
+   MESA_FORMAT_Z24_X8,          /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ xxxx xxxx */
+   MESA_FORMAT_Z32,             /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */
+   MESA_FORMAT_S8,              /*                               SSSS SSSS */
+   /*@}*/
+
+   /**
+    * \name 8-bit/channel sRGB formats
+    */
+   /*@{*/
+   MESA_FORMAT_SRGB8,
+   MESA_FORMAT_SRGBA8,
+   MESA_FORMAT_SARGB8,
+   MESA_FORMAT_SL8,
+   MESA_FORMAT_SLA8,
+   MESA_FORMAT_SRGB_DXT1,
+   MESA_FORMAT_SRGBA_DXT1,
+   MESA_FORMAT_SRGBA_DXT3,
+   MESA_FORMAT_SRGBA_DXT5,
+   /*@}*/
+
+   /**
+    * \name Compressed texture formats.
+    */
+   /*@{*/
+   MESA_FORMAT_RGB_FXT1,
+   MESA_FORMAT_RGBA_FXT1,
+   MESA_FORMAT_RGB_DXT1,
+   MESA_FORMAT_RGBA_DXT1,
+   MESA_FORMAT_RGBA_DXT3,
+   MESA_FORMAT_RGBA_DXT5,
+   /*@}*/
+
+   /**
+    * \name Floating point texture formats.
+    */
+   /*@{*/
+   MESA_FORMAT_RGBA_FLOAT32,
+   MESA_FORMAT_RGBA_FLOAT16,
+   MESA_FORMAT_RGB_FLOAT32,
+   MESA_FORMAT_RGB_FLOAT16,
+   MESA_FORMAT_ALPHA_FLOAT32,
+   MESA_FORMAT_ALPHA_FLOAT16,
+   MESA_FORMAT_LUMINANCE_FLOAT32,
+   MESA_FORMAT_LUMINANCE_FLOAT16,
+   MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32,
+   MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16,
+   MESA_FORMAT_INTENSITY_FLOAT32,
+   MESA_FORMAT_INTENSITY_FLOAT16,
+   /*@}*/
+
+   /**
+    * \name Signed fixed point texture formats.
+    */
+   /*@{*/
+   MESA_FORMAT_DUDV8,
+   MESA_FORMAT_SIGNED_RGBA8888,
+   MESA_FORMAT_SIGNED_RGBA8888_REV,
+   MESA_FORMAT_SIGNED_RGBA_16,
+   /*@}*/
+
+   MESA_FORMAT_COUNT
+} gl_format;
+
+
+extern const char *
+_mesa_get_format_name(gl_format format);
+
+extern GLuint
+_mesa_get_format_bytes(gl_format format);
+
+extern GLint
+_mesa_get_format_bits(gl_format format, GLenum pname);
+
+extern GLenum
+_mesa_get_format_datatype(gl_format format);
+
+extern GLenum
+_mesa_get_format_base_format(gl_format format);
+
+extern void
+_mesa_get_format_block_size(gl_format format, GLuint *bw, GLuint *bh);
+
+extern GLboolean
+_mesa_is_format_compressed(gl_format format);
+
+extern GLenum
+_mesa_get_format_color_encoding(gl_format format);
+
+extern GLuint
+_mesa_format_image_size(gl_format format, GLsizei width,
+                        GLsizei height, GLsizei depth);
+
+extern GLint
+_mesa_format_row_stride(gl_format format, GLsizei width);
+
+extern void
+_mesa_format_to_type_and_comps(gl_format format,
+                               GLenum *datatype, GLuint *comps);
+
+extern void
+_mesa_test_formats(void);
+
+#endif /* FORMATS_H */
index dc79b8ca61ad763b4de571cdb379172843e1e2b7..d958dbf7d48a76d33f2303d0dd18ec9f2ac992ea 100644 (file)
@@ -35,6 +35,7 @@
 #include "buffers.h"
 #include "context.h"
 #include "depthstencil.h"
+#include "formats.h"
 #include "macros.h"
 #include "mtypes.h"
 #include "fbobject.h"
@@ -281,7 +282,6 @@ _mesa_resize_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb,
          struct gl_renderbuffer *rb = att->Renderbuffer;
          /* only resize if size is changing */
          if (rb->Width != width || rb->Height != height) {
-            /* could just as well pass rb->_ActualFormat here */
             if (rb->AllocStorage(ctx, rb, rb->InternalFormat, width, height)) {
                ASSERT(rb->Width == width);
                ASSERT(rb->Height == height);
@@ -523,19 +523,22 @@ _mesa_update_framebuffer_visual(struct gl_framebuffer *fb)
    for (i = 0; i < BUFFER_COUNT; i++) {
       if (fb->Attachment[i].Renderbuffer) {
          const struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer;
-         if (rb->_BaseFormat == GL_RGBA || rb->_BaseFormat == GL_RGB) {
-            fb->Visual.redBits = rb->RedBits;
-            fb->Visual.greenBits = rb->GreenBits;
-            fb->Visual.blueBits = rb->BlueBits;
-            fb->Visual.alphaBits = rb->AlphaBits;
+         const GLenum baseFormat = _mesa_get_format_base_format(rb->Format);
+         const gl_format fmt = rb->Format;
+         
+         if (baseFormat == GL_RGBA || baseFormat == GL_RGB) {
+            fb->Visual.redBits = _mesa_get_format_bits(fmt, GL_RED_BITS);
+            fb->Visual.greenBits = _mesa_get_format_bits(fmt, GL_GREEN_BITS);
+            fb->Visual.blueBits = _mesa_get_format_bits(fmt, GL_BLUE_BITS);
+            fb->Visual.alphaBits = _mesa_get_format_bits(fmt, GL_ALPHA_BITS);
             fb->Visual.rgbBits = fb->Visual.redBits
                + fb->Visual.greenBits + fb->Visual.blueBits;
             fb->Visual.floatMode = GL_FALSE;
             fb->Visual.samples = rb->NumSamples;
             break;
          }
-         else if (rb->_BaseFormat == GL_COLOR_INDEX) {
-            fb->Visual.indexBits = rb->IndexBits;
+         else if (baseFormat == GL_COLOR_INDEX) {
+            fb->Visual.indexBits = _mesa_get_format_bits(fmt, GL_INDEX_BITS);
             fb->Visual.rgbMode = GL_FALSE;
             break;
          }
@@ -543,27 +546,30 @@ _mesa_update_framebuffer_visual(struct gl_framebuffer *fb)
    }
 
    if (fb->Attachment[BUFFER_DEPTH].Renderbuffer) {
+      const struct gl_renderbuffer *rb =
+         fb->Attachment[BUFFER_DEPTH].Renderbuffer;
+      const gl_format fmt = rb->Format;
       fb->Visual.haveDepthBuffer = GL_TRUE;
-      fb->Visual.depthBits
-         = fb->Attachment[BUFFER_DEPTH].Renderbuffer->DepthBits;
+      fb->Visual.depthBits = _mesa_get_format_bits(fmt, GL_DEPTH_BITS);
    }
 
    if (fb->Attachment[BUFFER_STENCIL].Renderbuffer) {
+      const struct gl_renderbuffer *rb =
+         fb->Attachment[BUFFER_STENCIL].Renderbuffer;
+      const gl_format fmt = rb->Format;
       fb->Visual.haveStencilBuffer = GL_TRUE;
-      fb->Visual.stencilBits
-         = fb->Attachment[BUFFER_STENCIL].Renderbuffer->StencilBits;
+      fb->Visual.stencilBits = _mesa_get_format_bits(fmt, GL_STENCIL_BITS);
    }
 
    if (fb->Attachment[BUFFER_ACCUM].Renderbuffer) {
+      const struct gl_renderbuffer *rb =
+         fb->Attachment[BUFFER_ACCUM].Renderbuffer;
+      const gl_format fmt = rb->Format;
       fb->Visual.haveAccumBuffer = GL_TRUE;
-      fb->Visual.accumRedBits
-         = fb->Attachment[BUFFER_ACCUM].Renderbuffer->RedBits;
-      fb->Visual.accumGreenBits
-         = fb->Attachment[BUFFER_ACCUM].Renderbuffer->GreenBits;
-      fb->Visual.accumBlueBits
-         = fb->Attachment[BUFFER_ACCUM].Renderbuffer->BlueBits;
-      fb->Visual.accumAlphaBits
-         = fb->Attachment[BUFFER_ACCUM].Renderbuffer->AlphaBits;
+      fb->Visual.accumRedBits = _mesa_get_format_bits(fmt, GL_RED_BITS);
+      fb->Visual.accumGreenBits = _mesa_get_format_bits(fmt, GL_GREEN_BITS);
+      fb->Visual.accumBlueBits = _mesa_get_format_bits(fmt, GL_BLUE_BITS);
+      fb->Visual.accumAlphaBits = _mesa_get_format_bits(fmt, GL_ALPHA_BITS);
    }
 
    compute_depth_max(fb);
@@ -592,11 +598,11 @@ _mesa_update_depth_buffer(GLcontext *ctx,
 
    depthRb = fb->Attachment[attIndex].Renderbuffer;
 
-   if (depthRb && depthRb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT) {
+   if (depthRb && depthRb->_BaseFormat == GL_DEPTH_STENCIL) {
       /* The attached depth buffer is a GL_DEPTH_STENCIL renderbuffer */
       if (!fb->_DepthBuffer
           || fb->_DepthBuffer->Wrapped != depthRb
-          || fb->_DepthBuffer->_BaseFormat != GL_DEPTH_COMPONENT) {
+          || _mesa_get_format_base_format(fb->_DepthBuffer->Format) != GL_DEPTH_COMPONENT) {
          /* need to update wrapper */
          struct gl_renderbuffer *wrapper
             = _mesa_new_z24_renderbuffer_wrapper(ctx, depthRb);
@@ -633,11 +639,11 @@ _mesa_update_stencil_buffer(GLcontext *ctx,
 
    stencilRb = fb->Attachment[attIndex].Renderbuffer;
 
-   if (stencilRb && stencilRb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT) {
+   if (stencilRb && stencilRb->_BaseFormat == GL_DEPTH_STENCIL) {
       /* The attached stencil buffer is a GL_DEPTH_STENCIL renderbuffer */
       if (!fb->_StencilBuffer
           || fb->_StencilBuffer->Wrapped != stencilRb
-          || fb->_StencilBuffer->_BaseFormat != GL_STENCIL_INDEX) {
+          || _mesa_get_format_base_format(fb->_StencilBuffer->Format) != GL_STENCIL_INDEX) {
          /* need to update wrapper */
          struct gl_renderbuffer *wrapper
             = _mesa_new_s8_renderbuffer_wrapper(ctx, stencilRb);
@@ -854,30 +860,32 @@ _mesa_source_buffer_exists(GLcontext *ctx, GLenum format)
       if (ctx->ReadBuffer->_ColorReadBuffer == NULL) {
          return GL_FALSE;
       }
-      ASSERT(ctx->ReadBuffer->_ColorReadBuffer->RedBits > 0 ||
-             ctx->ReadBuffer->_ColorReadBuffer->IndexBits > 0);
+      ASSERT(_mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_RED_BITS) > 0 ||
+             _mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_INDEX_BITS) > 0);
       break;
    case GL_DEPTH:
    case GL_DEPTH_COMPONENT:
       if (!att[BUFFER_DEPTH].Renderbuffer) {
          return GL_FALSE;
       }
-      ASSERT(att[BUFFER_DEPTH].Renderbuffer->DepthBits > 0);
+      /*ASSERT(att[BUFFER_DEPTH].Renderbuffer->DepthBits > 0);*/
       break;
    case GL_STENCIL:
    case GL_STENCIL_INDEX:
       if (!att[BUFFER_STENCIL].Renderbuffer) {
          return GL_FALSE;
       }
-      ASSERT(att[BUFFER_STENCIL].Renderbuffer->StencilBits > 0);
+      /*ASSERT(att[BUFFER_STENCIL].Renderbuffer->StencilBits > 0);*/
       break;
    case GL_DEPTH_STENCIL_EXT:
       if (!att[BUFFER_DEPTH].Renderbuffer ||
           !att[BUFFER_STENCIL].Renderbuffer) {
          return GL_FALSE;
       }
+      /*
       ASSERT(att[BUFFER_DEPTH].Renderbuffer->DepthBits > 0);
       ASSERT(att[BUFFER_STENCIL].Renderbuffer->StencilBits > 0);
+      */
       break;
    default:
       _mesa_problem(ctx,
@@ -932,22 +940,24 @@ _mesa_dest_buffer_exists(GLcontext *ctx, GLenum format)
       if (!att[BUFFER_DEPTH].Renderbuffer) {
          return GL_FALSE;
       }
-      ASSERT(att[BUFFER_DEPTH].Renderbuffer->DepthBits > 0);
+      /*ASSERT(att[BUFFER_DEPTH].Renderbuffer->DepthBits > 0);*/
       break;
    case GL_STENCIL:
    case GL_STENCIL_INDEX:
       if (!att[BUFFER_STENCIL].Renderbuffer) {
          return GL_FALSE;
       }
-      ASSERT(att[BUFFER_STENCIL].Renderbuffer->StencilBits > 0);
+      /*ASSERT(att[BUFFER_STENCIL].Renderbuffer->StencilBits > 0);*/
       break;
    case GL_DEPTH_STENCIL_EXT:
       if (!att[BUFFER_DEPTH].Renderbuffer ||
           !att[BUFFER_STENCIL].Renderbuffer) {
          return GL_FALSE;
       }
+      /*
       ASSERT(att[BUFFER_DEPTH].Renderbuffer->DepthBits > 0);
       ASSERT(att[BUFFER_STENCIL].Renderbuffer->StencilBits > 0);
+      */
       break;
    default:
       _mesa_problem(ctx,
@@ -959,3 +969,29 @@ _mesa_dest_buffer_exists(GLcontext *ctx, GLenum format)
    /* OK */
    return GL_TRUE;
 }
+
+GLenum
+_mesa_get_color_read_format(GLcontext *ctx)
+{
+   switch (ctx->ReadBuffer->_ColorReadBuffer->Format) {
+   case MESA_FORMAT_ARGB8888:
+      return GL_BGRA;
+   case MESA_FORMAT_RGB565:
+      return GL_BGR;
+   default:
+      return GL_RGBA;
+   }
+}
+
+GLenum
+_mesa_get_color_read_type(GLcontext *ctx)
+{
+   switch (ctx->ReadBuffer->_ColorReadBuffer->Format) {
+   case MESA_FORMAT_ARGB8888:
+      return GL_UNSIGNED_BYTE;
+   case MESA_FORMAT_RGB565:
+      return GL_UNSIGNED_SHORT_5_6_5_REV;
+   default:
+      return GL_UNSIGNED_BYTE;
+   }
+}
index 45a4703ba993ed7c9f2c1dfdfada0e4064c03d32..ef21dd98e83e85cac83287285656dcfa82b6626b 100644 (file)
@@ -81,5 +81,10 @@ _mesa_source_buffer_exists(GLcontext *ctx, GLenum format);
 extern GLboolean
 _mesa_dest_buffer_exists(GLcontext *ctx, GLenum format);
 
+extern GLenum
+_mesa_get_color_read_type(GLcontext *ctx);
+
+extern GLenum
+_mesa_get_color_read_format(GLcontext *ctx);
 
 #endif /* FRAMEBUFFER_H */
index a6e004a8166cf62411636f4d6ca676f87b1734e8..22cf75f79de43c0f1297b2e33472d9850e8b0be5 100644 (file)
@@ -13,6 +13,7 @@
 #include "mtypes.h"
 #include "state.h"
 #include "texcompress.h"
+#include "framebuffer.h"
 
 
 #define FLOAT_TO_BOOLEAN(X)   ( (X) ? GL_TRUE : GL_FALSE )
@@ -131,7 +132,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
          params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.numAuxBuffers);
          break;
       case GL_BLEND:
-         params[0] = ctx->Color.BlendEnabled;
+         params[0] = (ctx->Color.BlendEnabled & 1);
          break;
       case GL_BLEND_DST:
          params[0] = ENUM_TO_BOOLEAN(ctx->Color.BlendDstRGB);
@@ -209,10 +210,10 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
          params[0] = ENUM_TO_BOOLEAN(ctx->Light.ColorMaterialMode);
          break;
       case GL_COLOR_WRITEMASK:
-         params[0] = INT_TO_BOOLEAN(ctx->Color.ColorMask[RCOMP] ? 1 : 0);
-         params[1] = INT_TO_BOOLEAN(ctx->Color.ColorMask[GCOMP] ? 1 : 0);
-         params[2] = INT_TO_BOOLEAN(ctx->Color.ColorMask[BCOMP] ? 1 : 0);
-         params[3] = INT_TO_BOOLEAN(ctx->Color.ColorMask[ACOMP] ? 1 : 0);
+         params[0] = INT_TO_BOOLEAN(ctx->Color.ColorMask[0][RCOMP] ? 1 : 0);
+         params[1] = INT_TO_BOOLEAN(ctx->Color.ColorMask[0][GCOMP] ? 1 : 0);
+         params[2] = INT_TO_BOOLEAN(ctx->Color.ColorMask[0][BCOMP] ? 1 : 0);
+         params[3] = INT_TO_BOOLEAN(ctx->Color.ColorMask[0][ACOMP] ? 1 : 0);
          break;
       case GL_CULL_FACE:
          params[0] = ctx->Polygon.CullFlag;
@@ -1767,11 +1768,11 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
          break;
       case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES:
          CHECK_EXT1(OES_read_format, "GetBooleanv");
-         params[0] = INT_TO_BOOLEAN(ctx->Const.ColorReadType);
+         params[0] = INT_TO_BOOLEAN(_mesa_get_color_read_type(ctx));
          break;
       case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES:
          CHECK_EXT1(OES_read_format, "GetBooleanv");
-         params[0] = INT_TO_BOOLEAN(ctx->Const.ColorReadFormat);
+         params[0] = INT_TO_BOOLEAN(_mesa_get_color_read_format(ctx));
          break;
       case GL_NUM_FRAGMENT_REGISTERS_ATI:
          CHECK_EXT1(ATI_fragment_shader, "GetBooleanv");
@@ -1876,7 +1877,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
          break;
       case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB:
          CHECK_EXT1(ARB_vertex_shader, "GetBooleanv");
-         params[0] = INT_TO_BOOLEAN(MAX_COMBINED_TEXTURE_IMAGE_UNITS);
+         params[0] = INT_TO_BOOLEAN(ctx->Const.MaxCombinedTextureImageUnits);
          break;
       case GL_CURRENT_PROGRAM:
          CHECK_EXT1(ARB_shader_objects, "GetBooleanv");
@@ -1898,6 +1899,15 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
          CHECK_EXT1(ARB_sync, "GetBooleanv");
          params[0] = INT64_TO_BOOLEAN(ctx->Const.MaxServerWaitTimeout);
          break;
+      case GL_NUM_EXTENSIONS:
+         params[0] = INT_TO_BOOLEAN(_mesa_get_extension_count(ctx));
+         break;
+      case GL_MAJOR_VERSION:
+         params[0] = INT_TO_BOOLEAN(ctx->VersionMajor);
+         break;
+      case GL_MINOR_VERSION:
+         params[0] = INT_TO_BOOLEAN(ctx->VersionMinor);
+         break;
       default:
          _mesa_error(ctx, GL_INVALID_ENUM, "glGetBooleanv(pname=0x%x)", pname);
    }
@@ -1966,7 +1976,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
          params[0] = (GLfloat)(ctx->DrawBuffer->Visual.numAuxBuffers);
          break;
       case GL_BLEND:
-         params[0] = BOOLEAN_TO_FLOAT(ctx->Color.BlendEnabled);
+         params[0] = BOOLEAN_TO_FLOAT((ctx->Color.BlendEnabled & 1));
          break;
       case GL_BLEND_DST:
          params[0] = ENUM_TO_FLOAT(ctx->Color.BlendDstRGB);
@@ -2044,10 +2054,10 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
          params[0] = ENUM_TO_FLOAT(ctx->Light.ColorMaterialMode);
          break;
       case GL_COLOR_WRITEMASK:
-         params[0] = (GLfloat)(ctx->Color.ColorMask[RCOMP] ? 1 : 0);
-         params[1] = (GLfloat)(ctx->Color.ColorMask[GCOMP] ? 1 : 0);
-         params[2] = (GLfloat)(ctx->Color.ColorMask[BCOMP] ? 1 : 0);
-         params[3] = (GLfloat)(ctx->Color.ColorMask[ACOMP] ? 1 : 0);
+         params[0] = (GLfloat)(ctx->Color.ColorMask[0][RCOMP] ? 1 : 0);
+         params[1] = (GLfloat)(ctx->Color.ColorMask[0][GCOMP] ? 1 : 0);
+         params[2] = (GLfloat)(ctx->Color.ColorMask[0][BCOMP] ? 1 : 0);
+         params[3] = (GLfloat)(ctx->Color.ColorMask[0][ACOMP] ? 1 : 0);
          break;
       case GL_CULL_FACE:
          params[0] = BOOLEAN_TO_FLOAT(ctx->Polygon.CullFlag);
@@ -3602,11 +3612,11 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
          break;
       case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES:
          CHECK_EXT1(OES_read_format, "GetFloatv");
-         params[0] = (GLfloat)(ctx->Const.ColorReadType);
+         params[0] = (GLfloat)(_mesa_get_color_read_type(ctx));
          break;
       case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES:
          CHECK_EXT1(OES_read_format, "GetFloatv");
-         params[0] = (GLfloat)(ctx->Const.ColorReadFormat);
+         params[0] = (GLfloat)(_mesa_get_color_read_format(ctx));
          break;
       case GL_NUM_FRAGMENT_REGISTERS_ATI:
          CHECK_EXT1(ATI_fragment_shader, "GetFloatv");
@@ -3711,7 +3721,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
          break;
       case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB:
          CHECK_EXT1(ARB_vertex_shader, "GetFloatv");
-         params[0] = (GLfloat)(MAX_COMBINED_TEXTURE_IMAGE_UNITS);
+         params[0] = (GLfloat)(ctx->Const.MaxCombinedTextureImageUnits);
          break;
       case GL_CURRENT_PROGRAM:
          CHECK_EXT1(ARB_shader_objects, "GetFloatv");
@@ -3733,6 +3743,15 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
          CHECK_EXT1(ARB_sync, "GetFloatv");
          params[0] = (GLfloat)(ctx->Const.MaxServerWaitTimeout);
          break;
+      case GL_NUM_EXTENSIONS:
+         params[0] = (GLfloat)(_mesa_get_extension_count(ctx));
+         break;
+      case GL_MAJOR_VERSION:
+         params[0] = (GLfloat)(ctx->VersionMajor);
+         break;
+      case GL_MINOR_VERSION:
+         params[0] = (GLfloat)(ctx->VersionMinor);
+         break;
       default:
          _mesa_error(ctx, GL_INVALID_ENUM, "glGetFloatv(pname=0x%x)", pname);
    }
@@ -3801,7 +3820,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
          params[0] = ctx->DrawBuffer->Visual.numAuxBuffers;
          break;
       case GL_BLEND:
-         params[0] = BOOLEAN_TO_INT(ctx->Color.BlendEnabled);
+         params[0] = BOOLEAN_TO_INT((ctx->Color.BlendEnabled & 1));
          break;
       case GL_BLEND_DST:
          params[0] = ENUM_TO_INT(ctx->Color.BlendDstRGB);
@@ -3879,10 +3898,10 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
          params[0] = ENUM_TO_INT(ctx->Light.ColorMaterialMode);
          break;
       case GL_COLOR_WRITEMASK:
-         params[0] = ctx->Color.ColorMask[RCOMP] ? 1 : 0;
-         params[1] = ctx->Color.ColorMask[GCOMP] ? 1 : 0;
-         params[2] = ctx->Color.ColorMask[BCOMP] ? 1 : 0;
-         params[3] = ctx->Color.ColorMask[ACOMP] ? 1 : 0;
+         params[0] = ctx->Color.ColorMask[0][RCOMP] ? 1 : 0;
+         params[1] = ctx->Color.ColorMask[0][GCOMP] ? 1 : 0;
+         params[2] = ctx->Color.ColorMask[0][BCOMP] ? 1 : 0;
+         params[3] = ctx->Color.ColorMask[0][ACOMP] ? 1 : 0;
          break;
       case GL_CULL_FACE:
          params[0] = BOOLEAN_TO_INT(ctx->Polygon.CullFlag);
@@ -5437,11 +5456,11 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
          break;
       case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES:
          CHECK_EXT1(OES_read_format, "GetIntegerv");
-         params[0] = ctx->Const.ColorReadType;
+         params[0] = _mesa_get_color_read_type(ctx);
          break;
       case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES:
          CHECK_EXT1(OES_read_format, "GetIntegerv");
-         params[0] = ctx->Const.ColorReadFormat;
+         params[0] = _mesa_get_color_read_format(ctx);
          break;
       case GL_NUM_FRAGMENT_REGISTERS_ATI:
          CHECK_EXT1(ATI_fragment_shader, "GetIntegerv");
@@ -5546,7 +5565,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
          break;
       case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB:
          CHECK_EXT1(ARB_vertex_shader, "GetIntegerv");
-         params[0] = MAX_COMBINED_TEXTURE_IMAGE_UNITS;
+         params[0] = ctx->Const.MaxCombinedTextureImageUnits;
          break;
       case GL_CURRENT_PROGRAM:
          CHECK_EXT1(ARB_shader_objects, "GetIntegerv");
@@ -5568,6 +5587,15 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
          CHECK_EXT1(ARB_sync, "GetIntegerv");
          params[0] = INT64_TO_INT(ctx->Const.MaxServerWaitTimeout);
          break;
+      case GL_NUM_EXTENSIONS:
+         params[0] = _mesa_get_extension_count(ctx);
+         break;
+      case GL_MAJOR_VERSION:
+         params[0] = ctx->VersionMajor;
+         break;
+      case GL_MINOR_VERSION:
+         params[0] = ctx->VersionMinor;
+         break;
       default:
          _mesa_error(ctx, GL_INVALID_ENUM, "glGetIntegerv(pname=0x%x)", pname);
    }
@@ -5592,16 +5620,16 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
 
    switch (pname) {
       case GL_ACCUM_RED_BITS:
-         params[0] = ctx->DrawBuffer->Visual.accumRedBits;
+         params[0] = (GLint64)(ctx->DrawBuffer->Visual.accumRedBits);
          break;
       case GL_ACCUM_GREEN_BITS:
-         params[0] = ctx->DrawBuffer->Visual.accumGreenBits;
+         params[0] = (GLint64)(ctx->DrawBuffer->Visual.accumGreenBits);
          break;
       case GL_ACCUM_BLUE_BITS:
-         params[0] = ctx->DrawBuffer->Visual.accumBlueBits;
+         params[0] = (GLint64)(ctx->DrawBuffer->Visual.accumBlueBits);
          break;
       case GL_ACCUM_ALPHA_BITS:
-         params[0] = ctx->DrawBuffer->Visual.accumAlphaBits;
+         params[0] = (GLint64)(ctx->DrawBuffer->Visual.accumAlphaBits);
          break;
       case GL_ACCUM_CLEAR_VALUE:
          params[0] = FLOAT_TO_INT64(ctx->Accum.ClearColor[0]);
@@ -5613,7 +5641,7 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          params[0] = IROUND64(ctx->Pixel.AlphaBias);
          break;
       case GL_ALPHA_BITS:
-         params[0] = ctx->DrawBuffer->Visual.alphaBits;
+         params[0] = (GLint64)(ctx->DrawBuffer->Visual.alphaBits);
          break;
       case GL_ALPHA_SCALE:
          params[0] = IROUND64(ctx->Pixel.AlphaScale);
@@ -5628,16 +5656,16 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          params[0] = FLOAT_TO_INT64(ctx->Color.AlphaRef);
          break;
       case GL_ATTRIB_STACK_DEPTH:
-         params[0] = ctx->AttribStackDepth;
+         params[0] = (GLint64)(ctx->AttribStackDepth);
          break;
       case GL_AUTO_NORMAL:
          params[0] = BOOLEAN_TO_INT64(ctx->Eval.AutoNormal);
          break;
       case GL_AUX_BUFFERS:
-         params[0] = ctx->DrawBuffer->Visual.numAuxBuffers;
+         params[0] = (GLint64)(ctx->DrawBuffer->Visual.numAuxBuffers);
          break;
       case GL_BLEND:
-         params[0] = BOOLEAN_TO_INT64(ctx->Color.BlendEnabled);
+         params[0] = BOOLEAN_TO_INT64((ctx->Color.BlendEnabled & 1));
          break;
       case GL_BLEND_DST:
          params[0] = ENUM_TO_INT64(ctx->Color.BlendDstRGB);
@@ -5673,13 +5701,13 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          params[0] = IROUND64(ctx->Pixel.BlueBias);
          break;
       case GL_BLUE_BITS:
-         params[0] = ctx->DrawBuffer->Visual.blueBits;
+         params[0] = (GLint64)(ctx->DrawBuffer->Visual.blueBits);
          break;
       case GL_BLUE_SCALE:
          params[0] = IROUND64(ctx->Pixel.BlueScale);
          break;
       case GL_CLIENT_ATTRIB_STACK_DEPTH:
-         params[0] = ctx->ClientAttribStackDepth;
+         params[0] = (GLint64)(ctx->ClientAttribStackDepth);
          break;
       case GL_CLIP_PLANE0:
          params[0] = BOOLEAN_TO_INT64((ctx->Transform.ClipPlanesEnabled >> 0) & 1);
@@ -5715,10 +5743,10 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          params[0] = ENUM_TO_INT64(ctx->Light.ColorMaterialMode);
          break;
       case GL_COLOR_WRITEMASK:
-         params[0] = ctx->Color.ColorMask[RCOMP] ? 1 : 0;
-         params[1] = ctx->Color.ColorMask[GCOMP] ? 1 : 0;
-         params[2] = ctx->Color.ColorMask[BCOMP] ? 1 : 0;
-         params[3] = ctx->Color.ColorMask[ACOMP] ? 1 : 0;
+         params[0] = (GLint64)(ctx->Color.ColorMask[0][RCOMP] ? 1 : 0);
+         params[1] = (GLint64)(ctx->Color.ColorMask[0][GCOMP] ? 1 : 0);
+         params[2] = (GLint64)(ctx->Color.ColorMask[0][BCOMP] ? 1 : 0);
+         params[3] = (GLint64)(ctx->Color.ColorMask[0][ACOMP] ? 1 : 0);
          break;
       case GL_CULL_FACE:
          params[0] = BOOLEAN_TO_INT64(ctx->Polygon.CullFlag);
@@ -5799,7 +5827,7 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          params[0] = IROUND64(ctx->Pixel.DepthBias);
          break;
       case GL_DEPTH_BITS:
-         params[0] = ctx->DrawBuffer->Visual.depthBits;
+         params[0] = (GLint64)(ctx->DrawBuffer->Visual.depthBits);
          break;
       case GL_DEPTH_CLEAR_VALUE:
          params[0] = FLOAT_TO_INT64(((GLfloat) ctx->Depth.Clear));
@@ -5836,7 +5864,7 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          }
          break;
       case GL_FEEDBACK_BUFFER_SIZE:
-         params[0] = ctx->Feedback.BufferSize;
+         params[0] = (GLint64)(ctx->Feedback.BufferSize);
          break;
       case GL_FEEDBACK_BUFFER_TYPE:
          params[0] = ENUM_TO_INT64(ctx->Feedback.Type);
@@ -5875,28 +5903,28 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          params[0] = IROUND64(ctx->Pixel.GreenBias);
          break;
       case GL_GREEN_BITS:
-         params[0] = ctx->DrawBuffer->Visual.greenBits;
+         params[0] = (GLint64)(ctx->DrawBuffer->Visual.greenBits);
          break;
       case GL_GREEN_SCALE:
          params[0] = IROUND64(ctx->Pixel.GreenScale);
          break;
       case GL_INDEX_BITS:
-         params[0] = ctx->DrawBuffer->Visual.indexBits;
+         params[0] = (GLint64)(ctx->DrawBuffer->Visual.indexBits);
          break;
       case GL_INDEX_CLEAR_VALUE:
-         params[0] = ctx->Color.ClearIndex;
+         params[0] = (GLint64)(ctx->Color.ClearIndex);
          break;
       case GL_INDEX_MODE:
          params[0] = BOOLEAN_TO_INT64(!ctx->DrawBuffer->Visual.rgbMode);
          break;
       case GL_INDEX_OFFSET:
-         params[0] = ctx->Pixel.IndexOffset;
+         params[0] = (GLint64)(ctx->Pixel.IndexOffset);
          break;
       case GL_INDEX_SHIFT:
-         params[0] = ctx->Pixel.IndexShift;
+         params[0] = (GLint64)(ctx->Pixel.IndexShift);
          break;
       case GL_INDEX_WRITEMASK:
-         params[0] = ctx->Color.IndexMask;
+         params[0] = (GLint64)(ctx->Color.IndexMask);
          break;
       case GL_LIGHT0:
          params[0] = BOOLEAN_TO_INT64(ctx->Light.Light[0].Enabled);
@@ -5950,10 +5978,10 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          params[0] = BOOLEAN_TO_INT64(ctx->Line.StippleFlag);
          break;
       case GL_LINE_STIPPLE_PATTERN:
-         params[0] = ctx->Line.StipplePattern;
+         params[0] = (GLint64)(ctx->Line.StipplePattern);
          break;
       case GL_LINE_STIPPLE_REPEAT:
-         params[0] = ctx->Line.StippleFactor;
+         params[0] = (GLint64)(ctx->Line.StippleFactor);
          break;
       case GL_LINE_WIDTH:
          params[0] = IROUND64(ctx->Line.Width);
@@ -5970,10 +5998,10 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          params[1] = IROUND64(ctx->Const.MaxLineWidth);
          break;
       case GL_LIST_BASE:
-         params[0] = ctx->List.ListBase;
+         params[0] = (GLint64)(ctx->List.ListBase);
          break;
       case GL_LIST_INDEX:
-         params[0] = (ctx->ListState.CurrentList ? ctx->ListState.CurrentList->Name : 0);
+         params[0] = (GLint64)((ctx->ListState.CurrentList ? ctx->ListState.CurrentList->Name : 0));
          break;
       case GL_LIST_MODE:
          {
@@ -6004,7 +6032,7 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          params[1] = IROUND64(ctx->Eval.MapGrid1u2);
          break;
       case GL_MAP1_GRID_SEGMENTS:
-         params[0] = ctx->Eval.MapGrid1un;
+         params[0] = (GLint64)(ctx->Eval.MapGrid1un);
          break;
       case GL_MAP1_INDEX:
          params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map1Index);
@@ -6040,8 +6068,8 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          params[3] = IROUND64(ctx->Eval.MapGrid2v2);
          break;
       case GL_MAP2_GRID_SEGMENTS:
-         params[0] = ctx->Eval.MapGrid2un;
-         params[1] = ctx->Eval.MapGrid2vn;
+         params[0] = (GLint64)(ctx->Eval.MapGrid2un);
+         params[1] = (GLint64)(ctx->Eval.MapGrid2vn);
          break;
       case GL_MAP2_INDEX:
          params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map2Index);
@@ -6077,53 +6105,53 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          params[0] = ENUM_TO_INT64(ctx->Transform.MatrixMode);
          break;
       case GL_MAX_ATTRIB_STACK_DEPTH:
-         params[0] = MAX_ATTRIB_STACK_DEPTH;
+         params[0] = (GLint64)(MAX_ATTRIB_STACK_DEPTH);
          break;
       case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH:
-         params[0] = MAX_CLIENT_ATTRIB_STACK_DEPTH;
+         params[0] = (GLint64)(MAX_CLIENT_ATTRIB_STACK_DEPTH);
          break;
       case GL_MAX_CLIP_PLANES:
-         params[0] = ctx->Const.MaxClipPlanes;
+         params[0] = (GLint64)(ctx->Const.MaxClipPlanes);
          break;
       case GL_MAX_ELEMENTS_VERTICES:
-         params[0] = ctx->Const.MaxArrayLockSize;
+         params[0] = (GLint64)(ctx->Const.MaxArrayLockSize);
          break;
       case GL_MAX_ELEMENTS_INDICES:
-         params[0] = ctx->Const.MaxArrayLockSize;
+         params[0] = (GLint64)(ctx->Const.MaxArrayLockSize);
          break;
       case GL_MAX_EVAL_ORDER:
-         params[0] = MAX_EVAL_ORDER;
+         params[0] = (GLint64)(MAX_EVAL_ORDER);
          break;
       case GL_MAX_LIGHTS:
-         params[0] = ctx->Const.MaxLights;
+         params[0] = (GLint64)(ctx->Const.MaxLights);
          break;
       case GL_MAX_LIST_NESTING:
-         params[0] = MAX_LIST_NESTING;
+         params[0] = (GLint64)(MAX_LIST_NESTING);
          break;
       case GL_MAX_MODELVIEW_STACK_DEPTH:
-         params[0] = MAX_MODELVIEW_STACK_DEPTH;
+         params[0] = (GLint64)(MAX_MODELVIEW_STACK_DEPTH);
          break;
       case GL_MAX_NAME_STACK_DEPTH:
-         params[0] = MAX_NAME_STACK_DEPTH;
+         params[0] = (GLint64)(MAX_NAME_STACK_DEPTH);
          break;
       case GL_MAX_PIXEL_MAP_TABLE:
-         params[0] = MAX_PIXEL_MAP_TABLE;
+         params[0] = (GLint64)(MAX_PIXEL_MAP_TABLE);
          break;
       case GL_MAX_PROJECTION_STACK_DEPTH:
-         params[0] = MAX_PROJECTION_STACK_DEPTH;
+         params[0] = (GLint64)(MAX_PROJECTION_STACK_DEPTH);
          break;
       case GL_MAX_TEXTURE_SIZE:
-         params[0] = 1 << (ctx->Const.MaxTextureLevels - 1);
+         params[0] = (GLint64)(1 << (ctx->Const.MaxTextureLevels - 1));
          break;
       case GL_MAX_3D_TEXTURE_SIZE:
-         params[0] = 1 << (ctx->Const.Max3DTextureLevels - 1);
+         params[0] = (GLint64)(1 << (ctx->Const.Max3DTextureLevels - 1));
          break;
       case GL_MAX_TEXTURE_STACK_DEPTH:
-         params[0] = MAX_TEXTURE_STACK_DEPTH;
+         params[0] = (GLint64)(MAX_TEXTURE_STACK_DEPTH);
          break;
       case GL_MAX_VIEWPORT_DIMS:
-         params[0] = ctx->Const.MaxViewportWidth;
-         params[1] = ctx->Const.MaxViewportHeight;
+         params[0] = (GLint64)(ctx->Const.MaxViewportWidth);
+         params[1] = (GLint64)(ctx->Const.MaxViewportHeight);
          break;
       case GL_MODELVIEW_MATRIX:
          {
@@ -6147,37 +6175,37 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          }
          break;
       case GL_MODELVIEW_STACK_DEPTH:
-         params[0] = ctx->ModelviewMatrixStack.Depth + 1;
+         params[0] = (GLint64)(ctx->ModelviewMatrixStack.Depth + 1);
          break;
       case GL_NAME_STACK_DEPTH:
-         params[0] = ctx->Select.NameStackDepth;
+         params[0] = (GLint64)(ctx->Select.NameStackDepth);
          break;
       case GL_NORMALIZE:
          params[0] = BOOLEAN_TO_INT64(ctx->Transform.Normalize);
          break;
       case GL_PACK_ALIGNMENT:
-         params[0] = ctx->Pack.Alignment;
+         params[0] = (GLint64)(ctx->Pack.Alignment);
          break;
       case GL_PACK_LSB_FIRST:
          params[0] = BOOLEAN_TO_INT64(ctx->Pack.LsbFirst);
          break;
       case GL_PACK_ROW_LENGTH:
-         params[0] = ctx->Pack.RowLength;
+         params[0] = (GLint64)(ctx->Pack.RowLength);
          break;
       case GL_PACK_SKIP_PIXELS:
-         params[0] = ctx->Pack.SkipPixels;
+         params[0] = (GLint64)(ctx->Pack.SkipPixels);
          break;
       case GL_PACK_SKIP_ROWS:
-         params[0] = ctx->Pack.SkipRows;
+         params[0] = (GLint64)(ctx->Pack.SkipRows);
          break;
       case GL_PACK_SWAP_BYTES:
          params[0] = BOOLEAN_TO_INT64(ctx->Pack.SwapBytes);
          break;
       case GL_PACK_SKIP_IMAGES_EXT:
-         params[0] = ctx->Pack.SkipImages;
+         params[0] = (GLint64)(ctx->Pack.SkipImages);
          break;
       case GL_PACK_IMAGE_HEIGHT_EXT:
-         params[0] = ctx->Pack.ImageHeight;
+         params[0] = (GLint64)(ctx->Pack.ImageHeight);
          break;
       case GL_PACK_INVERT_MESA:
          params[0] = BOOLEAN_TO_INT64(ctx->Pack.Invert);
@@ -6186,34 +6214,34 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          params[0] = ENUM_TO_INT64(ctx->Hint.PerspectiveCorrection);
          break;
       case GL_PIXEL_MAP_A_TO_A_SIZE:
-         params[0] = ctx->PixelMaps.AtoA.Size;
+         params[0] = (GLint64)(ctx->PixelMaps.AtoA.Size);
          break;
       case GL_PIXEL_MAP_B_TO_B_SIZE:
-         params[0] = ctx->PixelMaps.BtoB.Size;
+         params[0] = (GLint64)(ctx->PixelMaps.BtoB.Size);
          break;
       case GL_PIXEL_MAP_G_TO_G_SIZE:
-         params[0] = ctx->PixelMaps.GtoG.Size;
+         params[0] = (GLint64)(ctx->PixelMaps.GtoG.Size);
          break;
       case GL_PIXEL_MAP_I_TO_A_SIZE:
-         params[0] = ctx->PixelMaps.ItoA.Size;
+         params[0] = (GLint64)(ctx->PixelMaps.ItoA.Size);
          break;
       case GL_PIXEL_MAP_I_TO_B_SIZE:
-         params[0] = ctx->PixelMaps.ItoB.Size;
+         params[0] = (GLint64)(ctx->PixelMaps.ItoB.Size);
          break;
       case GL_PIXEL_MAP_I_TO_G_SIZE:
-         params[0] = ctx->PixelMaps.ItoG.Size;
+         params[0] = (GLint64)(ctx->PixelMaps.ItoG.Size);
          break;
       case GL_PIXEL_MAP_I_TO_I_SIZE:
-         params[0] = ctx->PixelMaps.ItoI.Size;
+         params[0] = (GLint64)(ctx->PixelMaps.ItoI.Size);
          break;
       case GL_PIXEL_MAP_I_TO_R_SIZE:
-         params[0] = ctx->PixelMaps.ItoR.Size;
+         params[0] = (GLint64)(ctx->PixelMaps.ItoR.Size);
          break;
       case GL_PIXEL_MAP_R_TO_R_SIZE:
-         params[0] = ctx->PixelMaps.RtoR.Size;
+         params[0] = (GLint64)(ctx->PixelMaps.RtoR.Size);
          break;
       case GL_PIXEL_MAP_S_TO_S_SIZE:
-         params[0] = ctx->PixelMaps.StoS.Size;
+         params[0] = (GLint64)(ctx->PixelMaps.StoS.Size);
          break;
       case GL_POINT_SIZE:
          params[0] = IROUND64(ctx->Point.Size);
@@ -6302,7 +6330,7 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          }
          break;
       case GL_PROJECTION_STACK_DEPTH:
-         params[0] = ctx->ProjectionMatrixStack.Depth + 1;
+         params[0] = (GLint64)(ctx->ProjectionMatrixStack.Depth + 1);
          break;
       case GL_READ_BUFFER:
          params[0] = ENUM_TO_INT64(ctx->ReadBuffer->ColorReadBuffer);
@@ -6311,7 +6339,7 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          params[0] = IROUND64(ctx->Pixel.RedBias);
          break;
       case GL_RED_BITS:
-         params[0] = ctx->DrawBuffer->Visual.redBits;
+         params[0] = (GLint64)(ctx->DrawBuffer->Visual.redBits);
          break;
       case GL_RED_SCALE:
          params[0] = IROUND64(ctx->Pixel.RedScale);
@@ -6326,16 +6354,16 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          params[0] = BOOLEAN_TO_INT64(ctx->DrawBuffer->Visual.rgbMode);
          break;
       case GL_SCISSOR_BOX:
-         params[0] = ctx->Scissor.X;
-         params[1] = ctx->Scissor.Y;
-         params[2] = ctx->Scissor.Width;
-         params[3] = ctx->Scissor.Height;
+         params[0] = (GLint64)(ctx->Scissor.X);
+         params[1] = (GLint64)(ctx->Scissor.Y);
+         params[2] = (GLint64)(ctx->Scissor.Width);
+         params[3] = (GLint64)(ctx->Scissor.Height);
          break;
       case GL_SCISSOR_TEST:
          params[0] = BOOLEAN_TO_INT64(ctx->Scissor.Enabled);
          break;
       case GL_SELECTION_BUFFER_SIZE:
-         params[0] = ctx->Select.BufferSize;
+         params[0] = (GLint64)(ctx->Select.BufferSize);
          break;
       case GL_SHADE_MODEL:
          params[0] = ENUM_TO_INT64(ctx->Light.ShadeModel);
@@ -6344,10 +6372,10 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          params[0] = BOOLEAN_TO_INT64(ctx->Texture.SharedPalette);
          break;
       case GL_STENCIL_BITS:
-         params[0] = ctx->DrawBuffer->Visual.stencilBits;
+         params[0] = (GLint64)(ctx->DrawBuffer->Visual.stencilBits);
          break;
       case GL_STENCIL_CLEAR_VALUE:
-         params[0] = ctx->Stencil.Clear;
+         params[0] = (GLint64)(ctx->Stencil.Clear);
          break;
       case GL_STENCIL_FAIL:
          params[0] = ENUM_TO_INT64(ctx->Stencil.FailFunc[ctx->Stencil.ActiveFace]);
@@ -6362,22 +6390,22 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          params[0] = ENUM_TO_INT64(ctx->Stencil.ZPassFunc[ctx->Stencil.ActiveFace]);
          break;
       case GL_STENCIL_REF:
-         params[0] = ctx->Stencil.Ref[ctx->Stencil.ActiveFace];
+         params[0] = (GLint64)(ctx->Stencil.Ref[ctx->Stencil.ActiveFace]);
          break;
       case GL_STENCIL_TEST:
          params[0] = BOOLEAN_TO_INT64(ctx->Stencil.Enabled);
          break;
       case GL_STENCIL_VALUE_MASK:
-         params[0] = ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace];
+         params[0] = (GLint64)(ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace]);
          break;
       case GL_STENCIL_WRITEMASK:
-         params[0] = ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace];
+         params[0] = (GLint64)(ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace]);
          break;
       case GL_STEREO:
          params[0] = BOOLEAN_TO_INT64(ctx->DrawBuffer->Visual.stereoMode);
          break;
       case GL_SUBPIXEL_BITS:
-         params[0] = ctx->Const.SubPixelBits;
+         params[0] = (GLint64)(ctx->Const.SubPixelBits);
          break;
       case GL_TEXTURE_1D:
          params[0] = BOOLEAN_TO_INT64(_mesa_IsEnabled(GL_TEXTURE_1D));
@@ -6397,21 +6425,21 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          params[0] = BOOLEAN_TO_INT64(_mesa_IsEnabled(GL_TEXTURE_2D_ARRAY_EXT));
          break;
       case GL_TEXTURE_BINDING_1D:
-         params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_1D_INDEX]->Name;
+         params[0] = (GLint64)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_1D_INDEX]->Name);
          break;
       case GL_TEXTURE_BINDING_2D:
-         params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_INDEX]->Name;
+         params[0] = (GLint64)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_INDEX]->Name);
          break;
       case GL_TEXTURE_BINDING_3D:
-         params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_3D_INDEX]->Name;
+         params[0] = (GLint64)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_3D_INDEX]->Name);
          break;
       case GL_TEXTURE_BINDING_1D_ARRAY_EXT:
          CHECK_EXT1(MESA_texture_array, "GetInteger64v");
-         params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_1D_ARRAY_INDEX]->Name;
+         params[0] = (GLint64)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_1D_ARRAY_INDEX]->Name);
          break;
       case GL_TEXTURE_BINDING_2D_ARRAY_EXT:
          CHECK_EXT1(MESA_texture_array, "GetInteger64v");
-         params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_ARRAY_INDEX]->Name;
+         params[0] = (GLint64)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_ARRAY_INDEX]->Name);
          break;
       case GL_TEXTURE_GEN_S:
          params[0] = BOOLEAN_TO_INT64(((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0));
@@ -6447,40 +6475,40 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          }
          break;
       case GL_TEXTURE_STACK_DEPTH:
-         params[0] = ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Depth + 1;
+         params[0] = (GLint64)(ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Depth + 1);
          break;
       case GL_UNPACK_ALIGNMENT:
-         params[0] = ctx->Unpack.Alignment;
+         params[0] = (GLint64)(ctx->Unpack.Alignment);
          break;
       case GL_UNPACK_LSB_FIRST:
          params[0] = BOOLEAN_TO_INT64(ctx->Unpack.LsbFirst);
          break;
       case GL_UNPACK_ROW_LENGTH:
-         params[0] = ctx->Unpack.RowLength;
+         params[0] = (GLint64)(ctx->Unpack.RowLength);
          break;
       case GL_UNPACK_SKIP_PIXELS:
-         params[0] = ctx->Unpack.SkipPixels;
+         params[0] = (GLint64)(ctx->Unpack.SkipPixels);
          break;
       case GL_UNPACK_SKIP_ROWS:
-         params[0] = ctx->Unpack.SkipRows;
+         params[0] = (GLint64)(ctx->Unpack.SkipRows);
          break;
       case GL_UNPACK_SWAP_BYTES:
          params[0] = BOOLEAN_TO_INT64(ctx->Unpack.SwapBytes);
          break;
       case GL_UNPACK_SKIP_IMAGES_EXT:
-         params[0] = ctx->Unpack.SkipImages;
+         params[0] = (GLint64)(ctx->Unpack.SkipImages);
          break;
       case GL_UNPACK_IMAGE_HEIGHT_EXT:
-         params[0] = ctx->Unpack.ImageHeight;
+         params[0] = (GLint64)(ctx->Unpack.ImageHeight);
          break;
       case GL_UNPACK_CLIENT_STORAGE_APPLE:
          params[0] = BOOLEAN_TO_INT64(ctx->Unpack.ClientStorage);
          break;
       case GL_VIEWPORT:
-         params[0] = ctx->Viewport.X;
-         params[1] = ctx->Viewport.Y;
-         params[2] = ctx->Viewport.Width;
-         params[3] = ctx->Viewport.Height;
+         params[0] = (GLint64)(ctx->Viewport.X);
+         params[1] = (GLint64)(ctx->Viewport.Y);
+         params[2] = (GLint64)(ctx->Viewport.Width);
+         params[3] = (GLint64)(ctx->Viewport.Height);
          break;
       case GL_ZOOM_X:
          params[0] = IROUND64(ctx->Pixel.ZoomX);
@@ -6492,16 +6520,16 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->Vertex.Enabled);
          break;
       case GL_VERTEX_ARRAY_SIZE:
-         params[0] = ctx->Array.ArrayObj->Vertex.Size;
+         params[0] = (GLint64)(ctx->Array.ArrayObj->Vertex.Size);
          break;
       case GL_VERTEX_ARRAY_TYPE:
          params[0] = ENUM_TO_INT64(ctx->Array.ArrayObj->Vertex.Type);
          break;
       case GL_VERTEX_ARRAY_STRIDE:
-         params[0] = ctx->Array.ArrayObj->Vertex.Stride;
+         params[0] = (GLint64)(ctx->Array.ArrayObj->Vertex.Stride);
          break;
       case GL_VERTEX_ARRAY_COUNT_EXT:
-         params[0] = 0;
+         params[0] = (GLint64)(0);
          break;
       case GL_NORMAL_ARRAY:
          params[0] = ENUM_TO_INT64(ctx->Array.ArrayObj->Normal.Enabled);
@@ -6510,25 +6538,25 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          params[0] = ENUM_TO_INT64(ctx->Array.ArrayObj->Normal.Type);
          break;
       case GL_NORMAL_ARRAY_STRIDE:
-         params[0] = ctx->Array.ArrayObj->Normal.Stride;
+         params[0] = (GLint64)(ctx->Array.ArrayObj->Normal.Stride);
          break;
       case GL_NORMAL_ARRAY_COUNT_EXT:
-         params[0] = 0;
+         params[0] = (GLint64)(0);
          break;
       case GL_COLOR_ARRAY:
          params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->Color.Enabled);
          break;
       case GL_COLOR_ARRAY_SIZE:
-         params[0] = ctx->Array.ArrayObj->Color.Size;
+         params[0] = (GLint64)(ctx->Array.ArrayObj->Color.Size);
          break;
       case GL_COLOR_ARRAY_TYPE:
          params[0] = ENUM_TO_INT64(ctx->Array.ArrayObj->Color.Type);
          break;
       case GL_COLOR_ARRAY_STRIDE:
-         params[0] = ctx->Array.ArrayObj->Color.Stride;
+         params[0] = (GLint64)(ctx->Array.ArrayObj->Color.Stride);
          break;
       case GL_COLOR_ARRAY_COUNT_EXT:
-         params[0] = 0;
+         params[0] = (GLint64)(0);
          break;
       case GL_INDEX_ARRAY:
          params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->Index.Enabled);
@@ -6537,46 +6565,46 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          params[0] = ENUM_TO_INT64(ctx->Array.ArrayObj->Index.Type);
          break;
       case GL_INDEX_ARRAY_STRIDE:
-         params[0] = ctx->Array.ArrayObj->Index.Stride;
+         params[0] = (GLint64)(ctx->Array.ArrayObj->Index.Stride);
          break;
       case GL_INDEX_ARRAY_COUNT_EXT:
-         params[0] = 0;
+         params[0] = (GLint64)(0);
          break;
       case GL_TEXTURE_COORD_ARRAY:
          params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled);
          break;
       case GL_TEXTURE_COORD_ARRAY_SIZE:
-         params[0] = ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Size;
+         params[0] = (GLint64)(ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Size);
          break;
       case GL_TEXTURE_COORD_ARRAY_TYPE:
          params[0] = ENUM_TO_INT64(ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Type);
          break;
       case GL_TEXTURE_COORD_ARRAY_STRIDE:
-         params[0] = ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Stride;
+         params[0] = (GLint64)(ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Stride);
          break;
       case GL_TEXTURE_COORD_ARRAY_COUNT_EXT:
-         params[0] = 0;
+         params[0] = (GLint64)(0);
          break;
       case GL_EDGE_FLAG_ARRAY:
          params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->EdgeFlag.Enabled);
          break;
       case GL_EDGE_FLAG_ARRAY_STRIDE:
-         params[0] = ctx->Array.ArrayObj->EdgeFlag.Stride;
+         params[0] = (GLint64)(ctx->Array.ArrayObj->EdgeFlag.Stride);
          break;
       case GL_EDGE_FLAG_ARRAY_COUNT_EXT:
-         params[0] = 0;
+         params[0] = (GLint64)(0);
          break;
       case GL_MAX_TEXTURE_UNITS_ARB:
          CHECK_EXT1(ARB_multitexture, "GetInteger64v");
-         params[0] = ctx->Const.MaxTextureUnits;
+         params[0] = (GLint64)(ctx->Const.MaxTextureUnits);
          break;
       case GL_ACTIVE_TEXTURE_ARB:
          CHECK_EXT1(ARB_multitexture, "GetInteger64v");
-         params[0] = GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit;
+         params[0] = (GLint64)(GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit);
          break;
       case GL_CLIENT_ACTIVE_TEXTURE_ARB:
          CHECK_EXT1(ARB_multitexture, "GetInteger64v");
-         params[0] = GL_TEXTURE0_ARB + ctx->Array.ActiveTexture;
+         params[0] = (GLint64)(GL_TEXTURE0_ARB + ctx->Array.ActiveTexture);
          break;
       case GL_TEXTURE_CUBE_MAP_ARB:
          CHECK_EXT1(ARB_texture_cube_map, "GetInteger64v");
@@ -6584,17 +6612,17 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          break;
       case GL_TEXTURE_BINDING_CUBE_MAP_ARB:
          CHECK_EXT1(ARB_texture_cube_map, "GetInteger64v");
-         params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_CUBE_INDEX]->Name;
+         params[0] = (GLint64)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_CUBE_INDEX]->Name);
          break;
       case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB:
          CHECK_EXT1(ARB_texture_cube_map, "GetInteger64v");
-         params[0] = (1 << (ctx->Const.MaxCubeTextureLevels - 1));
+         params[0] = (GLint64)((1 << (ctx->Const.MaxCubeTextureLevels - 1)));
          break;
       case GL_TEXTURE_COMPRESSION_HINT_ARB:
-         params[0] = ctx->Hint.TextureCompression;
+         params[0] = (GLint64)(ctx->Hint.TextureCompression);
          break;
       case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB:
-         params[0] = _mesa_get_compressed_formats(ctx, NULL, GL_FALSE);
+         params[0] = (GLint64)(_mesa_get_compressed_formats(ctx, NULL, GL_FALSE));
          break;
       case GL_COMPRESSED_TEXTURE_FORMATS_ARB:
          {
@@ -6607,11 +6635,11 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          break;
       case GL_ARRAY_ELEMENT_LOCK_FIRST_EXT:
          CHECK_EXT1(EXT_compiled_vertex_array, "GetInteger64v");
-         params[0] = ctx->Array.LockFirst;
+         params[0] = (GLint64)(ctx->Array.LockFirst);
          break;
       case GL_ARRAY_ELEMENT_LOCK_COUNT_EXT:
          CHECK_EXT1(EXT_compiled_vertex_array, "GetInteger64v");
-         params[0] = ctx->Array.LockCount;
+         params[0] = (GLint64)(ctx->Array.LockCount);
          break;
       case GL_TRANSPOSE_COLOR_MATRIX_ARB:
          {
@@ -6719,10 +6747,10 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          }
          break;
       case GL_COLOR_MATRIX_STACK_DEPTH_SGI:
-         params[0] = ctx->ColorMatrixStack.Depth + 1;
+         params[0] = (GLint64)(ctx->ColorMatrixStack.Depth + 1);
          break;
       case GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI:
-         params[0] = MAX_COLOR_STACK_DEPTH;
+         params[0] = (GLint64)(MAX_COLOR_STACK_DEPTH);
          break;
       case GL_POST_COLOR_MATRIX_RED_SCALE_SGI:
          params[0] = IROUND64(ctx->Pixel.PostColorMatrixScale[0]);
@@ -6840,11 +6868,11 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          break;
       case GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT:
          CHECK_EXT1(EXT_secondary_color, "GetInteger64v");
-         params[0] = ctx->Array.ArrayObj->SecondaryColor.Stride;
+         params[0] = (GLint64)(ctx->Array.ArrayObj->SecondaryColor.Stride);
          break;
       case GL_SECONDARY_COLOR_ARRAY_SIZE_EXT:
          CHECK_EXT1(EXT_secondary_color, "GetInteger64v");
-         params[0] = ctx->Array.ArrayObj->SecondaryColor.Size;
+         params[0] = (GLint64)(ctx->Array.ArrayObj->SecondaryColor.Size);
          break;
       case GL_CURRENT_FOG_COORDINATE_EXT:
          CHECK_EXT1(EXT_fog_coord, "GetInteger64v");
@@ -6863,7 +6891,7 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          break;
       case GL_FOG_COORDINATE_ARRAY_STRIDE_EXT:
          CHECK_EXT1(EXT_fog_coord, "GetInteger64v");
-         params[0] = ctx->Array.ArrayObj->FogCoord.Stride;
+         params[0] = (GLint64)(ctx->Array.ArrayObj->FogCoord.Stride);
          break;
       case GL_FOG_COORDINATE_SOURCE_EXT:
          CHECK_EXT1(EXT_fog_coord, "GetInteger64v");
@@ -6896,10 +6924,10 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          params[0] = BOOLEAN_TO_INT64(ctx->Multisample.SampleCoverageInvert);
          break;
       case GL_SAMPLE_BUFFERS_ARB:
-         params[0] = ctx->DrawBuffer->Visual.sampleBuffers;
+         params[0] = (GLint64)(ctx->DrawBuffer->Visual.sampleBuffers);
          break;
       case GL_SAMPLES_ARB:
-         params[0] = ctx->DrawBuffer->Visual.samples;
+         params[0] = (GLint64)(ctx->DrawBuffer->Visual.samples);
          break;
       case GL_RASTER_POSITION_UNCLIPPED_IBM:
          CHECK_EXT1(IBM_rasterpos_clip, "GetInteger64v");
@@ -6923,7 +6951,7 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          break;
       case GL_VERTEX_PROGRAM_BINDING_NV:
          CHECK_EXT1(NV_vertex_program, "GetInteger64v");
-         params[0] = (ctx->VertexProgram.Current ? ctx->VertexProgram.Current->Base.Id : 0);
+         params[0] = (GLint64)((ctx->VertexProgram.Current ? ctx->VertexProgram.Current->Base.Id : 0));
          break;
       case GL_VERTEX_ATTRIB_ARRAY0_NV:
          CHECK_EXT1(NV_vertex_program, "GetInteger64v");
@@ -7059,11 +7087,11 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          break;
       case GL_FRAGMENT_PROGRAM_BINDING_NV:
          CHECK_EXT1(NV_fragment_program, "GetInteger64v");
-         params[0] = ctx->FragmentProgram.Current ? ctx->FragmentProgram.Current->Base.Id : 0;
+         params[0] = (GLint64)(ctx->FragmentProgram.Current ? ctx->FragmentProgram.Current->Base.Id : 0);
          break;
       case GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV:
          CHECK_EXT1(NV_fragment_program, "GetInteger64v");
-         params[0] = MAX_NV_FRAGMENT_PROGRAM_PARAMS;
+         params[0] = (GLint64)(MAX_NV_FRAGMENT_PROGRAM_PARAMS);
          break;
       case GL_TEXTURE_RECTANGLE_NV:
          CHECK_EXT1(NV_texture_rectangle, "GetInteger64v");
@@ -7071,11 +7099,11 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          break;
       case GL_TEXTURE_BINDING_RECTANGLE_NV:
          CHECK_EXT1(NV_texture_rectangle, "GetInteger64v");
-         params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_RECT_INDEX]->Name;
+         params[0] = (GLint64)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_RECT_INDEX]->Name);
          break;
       case GL_MAX_RECTANGLE_TEXTURE_SIZE_NV:
          CHECK_EXT1(NV_texture_rectangle, "GetInteger64v");
-         params[0] = ctx->Const.MaxTextureRectSize;
+         params[0] = (GLint64)(ctx->Const.MaxTextureRectSize);
          break;
       case GL_STENCIL_TEST_TWO_SIDE_EXT:
          CHECK_EXT1(EXT_stencil_two_side, "GetInteger64v");
@@ -7094,42 +7122,42 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          params[0] = IROUND64(ctx->Const.MaxSpotExponent);
          break;
       case GL_ARRAY_BUFFER_BINDING_ARB:
-         params[0] = ctx->Array.ArrayBufferObj->Name;
+         params[0] = (GLint64)(ctx->Array.ArrayBufferObj->Name);
          break;
       case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB:
-         params[0] = ctx->Array.ArrayObj->Vertex.BufferObj->Name;
+         params[0] = (GLint64)(ctx->Array.ArrayObj->Vertex.BufferObj->Name);
          break;
       case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB:
-         params[0] = ctx->Array.ArrayObj->Normal.BufferObj->Name;
+         params[0] = (GLint64)(ctx->Array.ArrayObj->Normal.BufferObj->Name);
          break;
       case GL_COLOR_ARRAY_BUFFER_BINDING_ARB:
-         params[0] = ctx->Array.ArrayObj->Color.BufferObj->Name;
+         params[0] = (GLint64)(ctx->Array.ArrayObj->Color.BufferObj->Name);
          break;
       case GL_INDEX_ARRAY_BUFFER_BINDING_ARB:
-         params[0] = ctx->Array.ArrayObj->Index.BufferObj->Name;
+         params[0] = (GLint64)(ctx->Array.ArrayObj->Index.BufferObj->Name);
          break;
       case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB:
-         params[0] = ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].BufferObj->Name;
+         params[0] = (GLint64)(ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].BufferObj->Name);
          break;
       case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB:
-         params[0] = ctx->Array.ArrayObj->EdgeFlag.BufferObj->Name;
+         params[0] = (GLint64)(ctx->Array.ArrayObj->EdgeFlag.BufferObj->Name);
          break;
       case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB:
-         params[0] = ctx->Array.ArrayObj->SecondaryColor.BufferObj->Name;
+         params[0] = (GLint64)(ctx->Array.ArrayObj->SecondaryColor.BufferObj->Name);
          break;
       case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB:
-         params[0] = ctx->Array.ArrayObj->FogCoord.BufferObj->Name;
+         params[0] = (GLint64)(ctx->Array.ArrayObj->FogCoord.BufferObj->Name);
          break;
       case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB:
-         params[0] = ctx->Array.ElementArrayBufferObj->Name;
+         params[0] = (GLint64)(ctx->Array.ElementArrayBufferObj->Name);
          break;
       case GL_PIXEL_PACK_BUFFER_BINDING_EXT:
          CHECK_EXT1(EXT_pixel_buffer_object, "GetInteger64v");
-         params[0] = ctx->Pack.BufferObj->Name;
+         params[0] = (GLint64)(ctx->Pack.BufferObj->Name);
          break;
       case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT:
          CHECK_EXT1(EXT_pixel_buffer_object, "GetInteger64v");
-         params[0] = ctx->Unpack.BufferObj->Name;
+         params[0] = (GLint64)(ctx->Unpack.BufferObj->Name);
          break;
       case GL_VERTEX_PROGRAM_ARB:
          CHECK_EXT2(ARB_vertex_program, NV_vertex_program, "GetInteger64v");
@@ -7145,11 +7173,11 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          break;
       case GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB:
          CHECK_EXT3(ARB_vertex_program, ARB_fragment_program, NV_vertex_program, "GetInteger64v");
-         params[0] = ctx->Const.MaxProgramMatrixStackDepth;
+         params[0] = (GLint64)(ctx->Const.MaxProgramMatrixStackDepth);
          break;
       case GL_MAX_PROGRAM_MATRICES_ARB:
          CHECK_EXT3(ARB_vertex_program, ARB_fragment_program, NV_vertex_program, "GetInteger64v");
-         params[0] = ctx->Const.MaxProgramMatrices;
+         params[0] = (GLint64)(ctx->Const.MaxProgramMatrices);
          break;
       case GL_CURRENT_MATRIX_STACK_DEPTH_ARB:
          CHECK_EXT3(ARB_vertex_program, ARB_fragment_program, NV_vertex_program, "GetInteger64v");
@@ -7201,11 +7229,11 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          break;
       case GL_MAX_VERTEX_ATTRIBS_ARB:
          CHECK_EXT1(ARB_vertex_program, "GetInteger64v");
-         params[0] = ctx->Const.VertexProgram.MaxAttribs;
+         params[0] = (GLint64)(ctx->Const.VertexProgram.MaxAttribs);
          break;
       case GL_PROGRAM_ERROR_POSITION_ARB:
          CHECK_EXT4(NV_vertex_program, ARB_vertex_program, NV_fragment_program, ARB_fragment_program, "GetInteger64v");
-         params[0] = ctx->Program.ErrorPos;
+         params[0] = (GLint64)(ctx->Program.ErrorPos);
          break;
       case GL_FRAGMENT_PROGRAM_ARB:
          CHECK_EXT1(ARB_fragment_program, "GetInteger64v");
@@ -7213,11 +7241,11 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          break;
       case GL_MAX_TEXTURE_COORDS_ARB:
          CHECK_EXT2(ARB_fragment_program, NV_fragment_program, "GetInteger64v");
-         params[0] = ctx->Const.MaxTextureCoordUnits;
+         params[0] = (GLint64)(ctx->Const.MaxTextureCoordUnits);
          break;
       case GL_MAX_TEXTURE_IMAGE_UNITS_ARB:
          CHECK_EXT2(ARB_fragment_program, NV_fragment_program, "GetInteger64v");
-         params[0] = ctx->Const.MaxTextureImageUnits;
+         params[0] = (GLint64)(ctx->Const.MaxTextureImageUnits);
          break;
       case GL_DEPTH_BOUNDS_TEST_EXT:
          CHECK_EXT1(EXT_depth_bounds_test, "GetInteger64v");
@@ -7233,7 +7261,7 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          params[0] = BOOLEAN_TO_INT64(ctx->Transform.DepthClamp);
          break;
       case GL_MAX_DRAW_BUFFERS_ARB:
-         params[0] = ctx->Const.MaxDrawBuffers;
+         params[0] = (GLint64)(ctx->Const.MaxDrawBuffers);
          break;
       case GL_DRAW_BUFFER0_ARB:
          params[0] = ENUM_TO_INT64(ctx->DrawBuffer->ColorDrawBuffer[0]);
@@ -7273,31 +7301,31 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          break;
       case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES:
          CHECK_EXT1(OES_read_format, "GetInteger64v");
-         params[0] = ctx->Const.ColorReadType;
+         params[0] = (GLint64)(_mesa_get_color_read_type(ctx));
          break;
       case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES:
          CHECK_EXT1(OES_read_format, "GetInteger64v");
-         params[0] = ctx->Const.ColorReadFormat;
+         params[0] = (GLint64)(_mesa_get_color_read_format(ctx));
          break;
       case GL_NUM_FRAGMENT_REGISTERS_ATI:
          CHECK_EXT1(ATI_fragment_shader, "GetInteger64v");
-         params[0] = 6;
+         params[0] = (GLint64)(6);
          break;
       case GL_NUM_FRAGMENT_CONSTANTS_ATI:
          CHECK_EXT1(ATI_fragment_shader, "GetInteger64v");
-         params[0] = 8;
+         params[0] = (GLint64)(8);
          break;
       case GL_NUM_PASSES_ATI:
          CHECK_EXT1(ATI_fragment_shader, "GetInteger64v");
-         params[0] = 2;
+         params[0] = (GLint64)(2);
          break;
       case GL_NUM_INSTRUCTIONS_PER_PASS_ATI:
          CHECK_EXT1(ATI_fragment_shader, "GetInteger64v");
-         params[0] = 8;
+         params[0] = (GLint64)(8);
          break;
       case GL_NUM_INSTRUCTIONS_TOTAL_ATI:
          CHECK_EXT1(ATI_fragment_shader, "GetInteger64v");
-         params[0] = 16;
+         params[0] = (GLint64)(16);
          break;
       case GL_COLOR_ALPHA_PAIRING_ATI:
          CHECK_EXT1(ATI_fragment_shader, "GetInteger64v");
@@ -7305,23 +7333,23 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          break;
       case GL_NUM_LOOPBACK_COMPONENTS_ATI:
          CHECK_EXT1(ATI_fragment_shader, "GetInteger64v");
-         params[0] = 3;
+         params[0] = (GLint64)(3);
          break;
       case GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI:
          CHECK_EXT1(ATI_fragment_shader, "GetInteger64v");
-         params[0] = 3;
+         params[0] = (GLint64)(3);
          break;
       case GL_STENCIL_BACK_FUNC:
          params[0] = ENUM_TO_INT64(ctx->Stencil.Function[1]);
          break;
       case GL_STENCIL_BACK_VALUE_MASK:
-         params[0] = ctx->Stencil.ValueMask[1];
+         params[0] = (GLint64)(ctx->Stencil.ValueMask[1]);
          break;
       case GL_STENCIL_BACK_WRITEMASK:
-         params[0] = ctx->Stencil.WriteMask[1];
+         params[0] = (GLint64)(ctx->Stencil.WriteMask[1]);
          break;
       case GL_STENCIL_BACK_REF:
-         params[0] = ctx->Stencil.Ref[1];
+         params[0] = (GLint64)(ctx->Stencil.Ref[1]);
          break;
       case GL_STENCIL_BACK_FAIL:
          params[0] = ENUM_TO_INT64(ctx->Stencil.FailFunc[1]);
@@ -7334,23 +7362,23 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          break;
       case GL_FRAMEBUFFER_BINDING_EXT:
          CHECK_EXT1(EXT_framebuffer_object, "GetInteger64v");
-         params[0] = ctx->DrawBuffer->Name;
+         params[0] = (GLint64)(ctx->DrawBuffer->Name);
          break;
       case GL_RENDERBUFFER_BINDING_EXT:
          CHECK_EXT1(EXT_framebuffer_object, "GetInteger64v");
-         params[0] = ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0;
+         params[0] = (GLint64)(ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0);
          break;
       case GL_MAX_COLOR_ATTACHMENTS_EXT:
          CHECK_EXT1(EXT_framebuffer_object, "GetInteger64v");
-         params[0] = ctx->Const.MaxColorAttachments;
+         params[0] = (GLint64)(ctx->Const.MaxColorAttachments);
          break;
       case GL_MAX_RENDERBUFFER_SIZE_EXT:
          CHECK_EXT1(EXT_framebuffer_object, "GetInteger64v");
-         params[0] = ctx->Const.MaxRenderbufferSize;
+         params[0] = (GLint64)(ctx->Const.MaxRenderbufferSize);
          break;
       case GL_READ_FRAMEBUFFER_BINDING_EXT:
          CHECK_EXT1(EXT_framebuffer_blit, "GetInteger64v");
-         params[0] = ctx->ReadBuffer->Name;
+         params[0] = (GLint64)(ctx->ReadBuffer->Name);
          break;
       case GL_PROVOKING_VERTEX_EXT:
          CHECK_EXT1(EXT_provoking_vertex, "GetInteger64v");
@@ -7362,7 +7390,7 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          break;
       case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB:
          CHECK_EXT1(ARB_fragment_shader, "GetInteger64v");
-         params[0] = ctx->Const.FragmentProgram.MaxUniformComponents;
+         params[0] = (GLint64)(ctx->Const.FragmentProgram.MaxUniformComponents);
          break;
       case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB:
          CHECK_EXT1(ARB_fragment_shader, "GetInteger64v");
@@ -7370,31 +7398,31 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          break;
       case GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB:
          CHECK_EXT1(ARB_vertex_shader, "GetInteger64v");
-         params[0] = ctx->Const.VertexProgram.MaxUniformComponents;
+         params[0] = (GLint64)(ctx->Const.VertexProgram.MaxUniformComponents);
          break;
       case GL_MAX_VARYING_FLOATS_ARB:
          CHECK_EXT1(ARB_vertex_shader, "GetInteger64v");
-         params[0] = ctx->Const.MaxVarying * 4;
+         params[0] = (GLint64)(ctx->Const.MaxVarying * 4);
          break;
       case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB:
          CHECK_EXT1(ARB_vertex_shader, "GetInteger64v");
-         params[0] = ctx->Const.MaxVertexTextureImageUnits;
+         params[0] = (GLint64)(ctx->Const.MaxVertexTextureImageUnits);
          break;
       case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB:
          CHECK_EXT1(ARB_vertex_shader, "GetInteger64v");
-         params[0] = MAX_COMBINED_TEXTURE_IMAGE_UNITS;
+         params[0] = (GLint64)(ctx->Const.MaxCombinedTextureImageUnits);
          break;
       case GL_CURRENT_PROGRAM:
          CHECK_EXT1(ARB_shader_objects, "GetInteger64v");
-         params[0] = ctx->Shader.CurrentProgram ? ctx->Shader.CurrentProgram->Name : 0;
+         params[0] = (GLint64)(ctx->Shader.CurrentProgram ? ctx->Shader.CurrentProgram->Name : 0);
          break;
       case GL_MAX_SAMPLES:
          CHECK_EXT1(ARB_framebuffer_object, "GetInteger64v");
-         params[0] = ctx->Const.MaxSamples;
+         params[0] = (GLint64)(ctx->Const.MaxSamples);
          break;
       case GL_VERTEX_ARRAY_BINDING_APPLE:
          CHECK_EXT1(APPLE_vertex_array_object, "GetInteger64v");
-         params[0] = ctx->Array.ArrayObj->Name;
+         params[0] = (GLint64)(ctx->Array.ArrayObj->Name);
          break;
       case GL_TEXTURE_CUBE_MAP_SEAMLESS:
          CHECK_EXT1(ARB_seamless_cube_map, "GetInteger64v");
@@ -7404,6 +7432,15 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          CHECK_EXT1(ARB_sync, "GetInteger64v");
          params[0] = ctx->Const.MaxServerWaitTimeout;
          break;
+      case GL_NUM_EXTENSIONS:
+         params[0] = (GLint64)(_mesa_get_extension_count(ctx));
+         break;
+      case GL_MAJOR_VERSION:
+         params[0] = (GLint64)(ctx->VersionMajor);
+         break;
+      case GL_MINOR_VERSION:
+         params[0] = (GLint64)(ctx->VersionMinor);
+         break;
       default:
          _mesa_error(ctx, GL_INVALID_ENUM, "glGetInteger64v(pname=0x%x)", pname);
    }
@@ -7433,3 +7470,110 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params )
       params[i] = (GLdouble) values[i];
 }
 
+void GLAPIENTRY
+_mesa_GetBooleanIndexedv( GLenum pname, GLuint index, GLboolean *params )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+   if (!params)
+      return;
+
+   if (ctx->NewState)
+      _mesa_update_state(ctx);
+
+   switch (pname) {
+      case GL_BLEND:
+         CHECK_EXT1(EXT_draw_buffers2, "GetBooleanIndexedv");
+         if (index >= ctx->Const.MaxDrawBuffers) {
+            _mesa_error(ctx, GL_INVALID_VALUE, "glGetBooleanIndexedv(index=%u), index", pname);
+         }
+         params[0] = INT_TO_BOOLEAN(((ctx->Color.BlendEnabled >> index) & 1));
+         break;
+      case GL_COLOR_WRITEMASK:
+         CHECK_EXT1(EXT_draw_buffers2, "GetBooleanIndexedv");
+         if (index >= ctx->Const.MaxDrawBuffers) {
+            _mesa_error(ctx, GL_INVALID_VALUE, "glGetBooleanIndexedv(index=%u), index", pname);
+         }
+         params[0] = INT_TO_BOOLEAN(ctx->Color.ColorMask[index][RCOMP] ? 1 : 0);
+         params[1] = INT_TO_BOOLEAN(ctx->Color.ColorMask[index][GCOMP] ? 1 : 0);
+         params[2] = INT_TO_BOOLEAN(ctx->Color.ColorMask[index][BCOMP] ? 1 : 0);
+         params[3] = INT_TO_BOOLEAN(ctx->Color.ColorMask[index][ACOMP] ? 1 : 0);
+         break;
+      default:
+         _mesa_error(ctx, GL_INVALID_ENUM, "glGetBooleanIndexedv(pname=0x%x)", pname);
+   }
+}
+
+void GLAPIENTRY
+_mesa_GetIntegerIndexedv( GLenum pname, GLuint index, GLint *params )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+   if (!params)
+      return;
+
+   if (ctx->NewState)
+      _mesa_update_state(ctx);
+
+   switch (pname) {
+      case GL_BLEND:
+         CHECK_EXT1(EXT_draw_buffers2, "GetIntegerIndexedv");
+         if (index >= ctx->Const.MaxDrawBuffers) {
+            _mesa_error(ctx, GL_INVALID_VALUE, "glGetIntegerIndexedv(index=%u), index", pname);
+         }
+         params[0] = ((ctx->Color.BlendEnabled >> index) & 1);
+         break;
+      case GL_COLOR_WRITEMASK:
+         CHECK_EXT1(EXT_draw_buffers2, "GetIntegerIndexedv");
+         if (index >= ctx->Const.MaxDrawBuffers) {
+            _mesa_error(ctx, GL_INVALID_VALUE, "glGetIntegerIndexedv(index=%u), index", pname);
+         }
+         params[0] = ctx->Color.ColorMask[index][RCOMP] ? 1 : 0;
+         params[1] = ctx->Color.ColorMask[index][GCOMP] ? 1 : 0;
+         params[2] = ctx->Color.ColorMask[index][BCOMP] ? 1 : 0;
+         params[3] = ctx->Color.ColorMask[index][ACOMP] ? 1 : 0;
+         break;
+      default:
+         _mesa_error(ctx, GL_INVALID_ENUM, "glGetIntegerIndexedv(pname=0x%x)", pname);
+   }
+}
+
+#if FEATURE_ARB_sync
+void GLAPIENTRY
+_mesa_GetInteger64Indexedv( GLenum pname, GLuint index, GLint64 *params )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+   if (!params)
+      return;
+
+   if (ctx->NewState)
+      _mesa_update_state(ctx);
+
+   switch (pname) {
+      case GL_BLEND:
+         CHECK_EXT1(EXT_draw_buffers2, "GetInteger64Indexedv");
+         if (index >= ctx->Const.MaxDrawBuffers) {
+            _mesa_error(ctx, GL_INVALID_VALUE, "glGetInteger64Indexedv(index=%u), index", pname);
+         }
+         params[0] = (GLint64)(((ctx->Color.BlendEnabled >> index) & 1));
+         break;
+      case GL_COLOR_WRITEMASK:
+         CHECK_EXT1(EXT_draw_buffers2, "GetInteger64Indexedv");
+         if (index >= ctx->Const.MaxDrawBuffers) {
+            _mesa_error(ctx, GL_INVALID_VALUE, "glGetInteger64Indexedv(index=%u), index", pname);
+         }
+         params[0] = (GLint64)(ctx->Color.ColorMask[index][RCOMP] ? 1 : 0);
+         params[1] = (GLint64)(ctx->Color.ColorMask[index][GCOMP] ? 1 : 0);
+         params[2] = (GLint64)(ctx->Color.ColorMask[index][BCOMP] ? 1 : 0);
+         params[3] = (GLint64)(ctx->Color.ColorMask[index][ACOMP] ? 1 : 0);
+         break;
+      default:
+         _mesa_error(ctx, GL_INVALID_ENUM, "glGetInteger64Indexedv(pname=0x%x)", pname);
+   }
+}
+#endif /* FEATURE_ARB_sync */
+
index 77a9a7d04b4f8654d51109cd76cd032f90a17f80..cc426fc0f6109e4cf4d757b371798b1ea73d4c96 100644 (file)
@@ -50,12 +50,24 @@ _mesa_GetIntegerv( GLenum pname, GLint *params );
 extern void GLAPIENTRY
 _mesa_GetInteger64v( GLenum pname, GLint64 *params );
 
+extern void GLAPIENTRY
+_mesa_GetBooleanIndexedv( GLenum pname, GLuint index, GLboolean *params );
+
+extern void GLAPIENTRY
+_mesa_GetIntegerIndexedv( GLenum pname, GLuint index, GLint *params );
+
+extern void GLAPIENTRY
+_mesa_GetInteger64Indexedv( GLenum pname, GLuint index, GLint64 *params );
+
 extern void GLAPIENTRY
 _mesa_GetPointerv( GLenum pname, GLvoid **params );
 
 extern const GLubyte * GLAPIENTRY
 _mesa_GetString( GLenum name );
 
+extern const GLubyte * GLAPIENTRY
+_mesa_GetStringi(GLenum name, GLuint index);
+
 extern GLenum GLAPIENTRY
 _mesa_GetError( void );
 
index 364d8c55c45c291f8228dede5db6005038b2aeeb..b0beb5920754e1e3541701a0f8fdc5520a3d1f87 100644 (file)
@@ -82,7 +82,7 @@ StateVars = [
        ( "GL_AUTO_NORMAL", GLboolean, ["ctx->Eval.AutoNormal"], "", None ),
        ( "GL_AUX_BUFFERS", GLint, ["ctx->DrawBuffer->Visual.numAuxBuffers"],
          "", None ),
-       ( "GL_BLEND", GLboolean, ["ctx->Color.BlendEnabled"], "", None ),
+       ( "GL_BLEND", GLboolean, ["(ctx->Color.BlendEnabled & 1)"], "", None ),
        ( "GL_BLEND_DST", GLenum, ["ctx->Color.BlendDstRGB"], "", None ),
        ( "GL_BLEND_SRC", GLenum, ["ctx->Color.BlendSrcRGB"], "", None ),
        ( "GL_BLEND_SRC_RGB_EXT", GLenum, ["ctx->Color.BlendSrcRGB"], "", None ),
@@ -126,10 +126,10 @@ StateVars = [
        ( "GL_COLOR_MATERIAL_PARAMETER", GLenum,
          ["ctx->Light.ColorMaterialMode"], "", None ),
        ( "GL_COLOR_WRITEMASK", GLint,
-         [ "ctx->Color.ColorMask[RCOMP] ? 1 : 0",
-               "ctx->Color.ColorMask[GCOMP] ? 1 : 0",
-               "ctx->Color.ColorMask[BCOMP] ? 1 : 0",
-               "ctx->Color.ColorMask[ACOMP] ? 1 : 0" ], "", None ),
+         [ "ctx->Color.ColorMask[0][RCOMP] ? 1 : 0",
+               "ctx->Color.ColorMask[0][GCOMP] ? 1 : 0",
+               "ctx->Color.ColorMask[0][BCOMP] ? 1 : 0",
+               "ctx->Color.ColorMask[0][ACOMP] ? 1 : 0" ], "", None ),
        ( "GL_CULL_FACE", GLboolean, ["ctx->Polygon.CullFlag"], "", None ),
        ( "GL_CULL_FACE_MODE", GLenum, ["ctx->Polygon.CullFaceMode"], "", None ),
        ( "GL_CURRENT_COLOR", GLfloatN,
@@ -942,9 +942,9 @@ StateVars = [
 
        # GL_OES_read_format
        ( "GL_IMPLEMENTATION_COLOR_READ_TYPE_OES", GLint,
-         ["ctx->Const.ColorReadType"], "", ["OES_read_format"] ),
+         ["_mesa_get_color_read_type(ctx)"], "", ["OES_read_format"] ),
        ( "GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES", GLint,
-         ["ctx->Const.ColorReadFormat"], "", ["OES_read_format"] ),
+         ["_mesa_get_color_read_format(ctx)"], "", ["OES_read_format"] ),
 
        # GL_ATI_fragment_shader
        ( "GL_NUM_FRAGMENT_REGISTERS_ATI", GLint, ["6"], "", ["ATI_fragment_shader"] ),
@@ -1006,7 +1006,7 @@ StateVars = [
        ( "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB", GLint,
          ["ctx->Const.MaxVertexTextureImageUnits"], "", ["ARB_vertex_shader"] ),
        ( "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB", GLint,
-         ["MAX_COMBINED_TEXTURE_IMAGE_UNITS"], "", ["ARB_vertex_shader"] ),
+         ["ctx->Const.MaxCombinedTextureImageUnits"], "", ["ARB_vertex_shader"] ),
 
        # GL_ARB_shader_objects
        # Actually, this token isn't part of GL_ARB_shader_objects, but is
@@ -1030,9 +1030,29 @@ StateVars = [
        # GL_ARB_sync
        ( "GL_MAX_SERVER_WAIT_TIMEOUT", GLint64, ["ctx->Const.MaxServerWaitTimeout"], "",
          ["ARB_sync"] ),
+
+       # GL3
+       ( "GL_NUM_EXTENSIONS", GLint, ["_mesa_get_extension_count(ctx)"], "", None ),
+       ( "GL_MAJOR_VERSION", GLint, ["ctx->VersionMajor"], "", None ),
+       ( "GL_MINOR_VERSION", GLint, ["ctx->VersionMinor"], "", None )
+]
+
+
+# These are queried via glGetIntegetIndexdvEXT() or glGetIntegeri_v()
+IndexedStateVars = [
+       ( "GL_BLEND", GLint, ["((ctx->Color.BlendEnabled >> index) & 1)"],
+         "ctx->Const.MaxDrawBuffers", ["EXT_draw_buffers2"] ),
+       ( "GL_COLOR_WRITEMASK", GLint,
+         [ "ctx->Color.ColorMask[index][RCOMP] ? 1 : 0",
+               "ctx->Color.ColorMask[index][GCOMP] ? 1 : 0",
+               "ctx->Color.ColorMask[index][BCOMP] ? 1 : 0",
+               "ctx->Color.ColorMask[index][ACOMP] ? 1 : 0" ],
+         "ctx->Const.MaxDrawBuffers", ["EXT_draw_buffers2"] ),
+       # XXX more to come...
 ]
 
 
+
 def ConversionFunc(fromType, toType):
        """Return the name of the macro to convert between two data types."""
        if fromType == toType:
@@ -1046,7 +1066,7 @@ def ConversionFunc(fromType, toType):
        elif fromType == GLint and toType == GLfloat: # but not GLfloatN!
                return "(GLfloat)"
        elif fromType == GLint and toType == GLint64:
-               return ""
+               return "(GLint64)"
        elif fromType == GLint64 and toType == GLfloat: # but not GLfloatN!
                return "(GLfloat)"
        else:
@@ -1059,7 +1079,7 @@ def ConversionFunc(fromType, toType):
                return fromStr + "_TO_" + toStr
 
 
-def EmitGetFunction(stateVars, returnType):
+def EmitGetFunction(stateVars, returnType, indexed):
        """Emit the code to implement glGetBooleanv, glGetIntegerv or glGetFloatv."""
        assert (returnType == GLboolean or
                        returnType == GLint or
@@ -1068,22 +1088,35 @@ def EmitGetFunction(stateVars, returnType):
 
        strType = TypeStrings[returnType]
        # Capitalize first letter of return type
-       if returnType == GLint:
-               function = "GetIntegerv"
-       elif returnType == GLboolean:
-               function = "GetBooleanv"
-       elif returnType == GLfloat:
-               function = "GetFloatv"
-       elif returnType == GLint64:
-               function = "GetInteger64v"
+       if indexed:
+               if returnType == GLint:
+                       function = "GetIntegerIndexedv"
+               elif returnType == GLboolean:
+                       function = "GetBooleanIndexedv"
+               elif returnType == GLint64:
+                       function = "GetInteger64Indexedv"
+               else:
+                       function = "Foo"
        else:
-               abort()
+               if returnType == GLint:
+                       function = "GetIntegerv"
+               elif returnType == GLboolean:
+                       function = "GetBooleanv"
+               elif returnType == GLfloat:
+                       function = "GetFloatv"
+               elif returnType == GLint64:
+                       function = "GetInteger64v"
+               else:
+                       abort()
 
        if returnType == GLint64:
                print "#if FEATURE_ARB_sync"
 
        print "void GLAPIENTRY"
-       print "_mesa_%s( GLenum pname, %s *params )" % (function, strType)
+       if indexed:
+               print "_mesa_%s( GLenum pname, GLuint index, %s *params )" % (function, strType)
+       else:
+               print "_mesa_%s( GLenum pname, %s *params )" % (function, strType)
        print "{"
        print "   GET_CURRENT_CONTEXT(ctx);"
        print "   ASSERT_OUTSIDE_BEGIN_END(ctx);"
@@ -1094,13 +1127,20 @@ def EmitGetFunction(stateVars, returnType):
        print "   if (ctx->NewState)"
        print "      _mesa_update_state(ctx);"
        print ""
-       print "   if (ctx->Driver.%s &&" % function
-       print "       ctx->Driver.%s(ctx, pname, params))" % function
-       print "      return;"
-       print ""
+       if indexed == 0:
+               print "   if (ctx->Driver.%s &&" % function
+               print "       ctx->Driver.%s(ctx, pname, params))" % function
+               print "      return;"
+               print ""
        print "   switch (pname) {"
 
-       for (name, varType, state, optionalCode, extensions) in stateVars:
+       for state in stateVars:
+               if indexed:
+                       (name, varType, state, indexMax, extensions) = state
+                       optionalCode = 0
+               else:
+                       (name, varType, state, optionalCode, extensions) = state
+                       indexMax = 0
                print "      case " + name + ":"
                if extensions:
                        if len(extensions) == 1:
@@ -1116,6 +1156,11 @@ def EmitGetFunction(stateVars, returnType):
                                assert len(extensions) == 4
                                print ('         CHECK_EXT4(%s, %s, %s, %s, "%s");' %
                                           (extensions[0], extensions[1], extensions[2], extensions[3], function))
+               if indexMax:
+                       print ('         if (index >= %s) {' % indexMax)
+                       print ('            _mesa_error(ctx, GL_INVALID_VALUE, "gl%s(index=%%u), index", pname);' % function)
+                       print ('         }')
+
                conversion = ConversionFunc(varType, returnType)
                if optionalCode:
                        optionalCode = string.replace(optionalCode, "CONVERSION", conversion);  
@@ -1159,6 +1204,7 @@ def EmitHeader():
 #include "mtypes.h"
 #include "state.h"
 #include "texcompress.h"
+#include "framebuffer.h"
 
 
 #define FLOAT_TO_BOOLEAN(X)   ( (X) ? GL_TRUE : GL_FALSE )
@@ -1248,9 +1294,13 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params )
 
 EmitHeader()
 # XXX Maybe sort the StateVars list
-EmitGetFunction(StateVars, GLboolean)
-EmitGetFunction(StateVars, GLfloat)
-EmitGetFunction(StateVars, GLint)
-EmitGetFunction(StateVars, GLint64)
+EmitGetFunction(StateVars, GLboolean, 0)
+EmitGetFunction(StateVars, GLfloat, 0)
+EmitGetFunction(StateVars, GLint, 0)
+EmitGetFunction(StateVars, GLint64, 0)
 EmitGetDoublev()
 
+EmitGetFunction(IndexedStateVars, GLboolean, 1)
+EmitGetFunction(IndexedStateVars, GLint, 1)
+EmitGetFunction(IndexedStateVars, GLint64, 1)
+
index 6599ed9698d88f91ce28035fbd1a60f4175b3fab..e76a790d0a0d4b73e691f5f9b7e33558a7250596 100644 (file)
 #include "extensions.h"
 
 
-/**
- * Examine enabled GL extensions to determine GL version.
- * \return version string
- */
-static const char *
-compute_version(const GLcontext *ctx)
-{
-   static const char *version_1_2 = "1.2 Mesa " MESA_VERSION_STRING;
-   static const char *version_1_3 = "1.3 Mesa " MESA_VERSION_STRING;
-   static const char *version_1_4 = "1.4 Mesa " MESA_VERSION_STRING;
-   static const char *version_1_5 = "1.5 Mesa " MESA_VERSION_STRING;
-   static const char *version_2_0 = "2.0 Mesa " MESA_VERSION_STRING;
-   static const char *version_2_1 = "2.1 Mesa " MESA_VERSION_STRING;
-
-   const GLboolean ver_1_3 = (ctx->Extensions.ARB_multisample &&
-                              ctx->Extensions.ARB_multitexture &&
-                              ctx->Extensions.ARB_texture_border_clamp &&
-                              ctx->Extensions.ARB_texture_compression &&
-                              ctx->Extensions.ARB_texture_cube_map &&
-                              ctx->Extensions.EXT_texture_env_add &&
-                              ctx->Extensions.ARB_texture_env_combine &&
-                              ctx->Extensions.ARB_texture_env_dot3);
-   const GLboolean ver_1_4 = (ver_1_3 &&
-                              ctx->Extensions.ARB_depth_texture &&
-                              ctx->Extensions.ARB_shadow &&
-                              ctx->Extensions.ARB_texture_env_crossbar &&
-                              ctx->Extensions.ARB_texture_mirrored_repeat &&
-                              ctx->Extensions.ARB_window_pos &&
-                              ctx->Extensions.EXT_blend_color &&
-                              ctx->Extensions.EXT_blend_func_separate &&
-                              ctx->Extensions.EXT_blend_minmax &&
-                              ctx->Extensions.EXT_blend_subtract &&
-                              ctx->Extensions.EXT_fog_coord &&
-                              ctx->Extensions.EXT_multi_draw_arrays &&
-                              ctx->Extensions.EXT_point_parameters &&
-                              ctx->Extensions.EXT_secondary_color &&
-                              ctx->Extensions.EXT_stencil_wrap &&
-                              ctx->Extensions.EXT_texture_lod_bias &&
-                              ctx->Extensions.SGIS_generate_mipmap);
-   const GLboolean ver_1_5 = (ver_1_4 &&
-                              ctx->Extensions.ARB_occlusion_query &&
-                              ctx->Extensions.ARB_vertex_buffer_object &&
-                              ctx->Extensions.EXT_shadow_funcs);
-   const GLboolean ver_2_0 = (ver_1_5 &&
-                              ctx->Extensions.ARB_draw_buffers &&
-                              ctx->Extensions.ARB_point_sprite &&
-                              ctx->Extensions.ARB_shader_objects &&
-                              ctx->Extensions.ARB_vertex_shader &&
-                              ctx->Extensions.ARB_fragment_shader &&
-                              ctx->Extensions.ARB_texture_non_power_of_two &&
-                              ctx->Extensions.EXT_blend_equation_separate &&
-
-                             /* Technically, 2.0 requires the functionality
-                              * of the EXT version.  Enable 2.0 if either
-                              * extension is available, and assume that a
-                              * driver that only exposes the ATI extension
-                              * will fallback to software when necessary.
-                              */
-                             (ctx->Extensions.EXT_stencil_two_side
-                              || ctx->Extensions.ATI_separate_stencil));
-   const GLboolean ver_2_1 = (ver_2_0 &&
-                              ctx->Extensions.ARB_shading_language_120 &&
-                              ctx->Extensions.EXT_pixel_buffer_object &&
-                              ctx->Extensions.EXT_texture_sRGB);
-   if (ver_2_1)
-      return version_2_1;
-   if (ver_2_0)
-      return version_2_0;
-   if (ver_1_5)
-      return version_1_5;
-   if (ver_1_4)
-      return version_1_4;
-   if (ver_1_3)
-      return version_1_3;
-   return version_1_2;
-}
-
-
-
 /**
  * Query string-valued state.  The return value should _not_ be freed by
  * the caller.
@@ -149,7 +70,7 @@ _mesa_GetString( GLenum name )
       case GL_RENDERER:
          return (const GLubyte *) renderer;
       case GL_VERSION:
-         return (const GLubyte *) compute_version(ctx);
+         return (const GLubyte *) ctx->VersionString;
       case GL_EXTENSIONS:
          if (!ctx->Extensions.String)
             ctx->Extensions.String = _mesa_make_extension_string(ctx);
@@ -183,6 +104,34 @@ _mesa_GetString( GLenum name )
 }
 
 
+/**
+ * GL3
+ */
+const GLubyte * GLAPIENTRY
+_mesa_GetStringi(GLenum name, GLuint index)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   if (!ctx)
+      return NULL;
+
+   ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, NULL);
+
+   switch (name) {
+   case GL_EXTENSIONS:
+      if (index >= _mesa_get_extension_count(ctx)) {
+         _mesa_error(ctx, GL_INVALID_VALUE, "glGetStringi(index=%u)", index);
+         return (const GLubyte *) 0;
+      }
+      return _mesa_get_enabled_extension(ctx, index);
+   default:
+      _mesa_error( ctx, GL_INVALID_ENUM, "glGetString" );
+      return (const GLubyte *) 0;
+   }
+}
+
+
+
 /**
  * Return pointer-valued state, such as a vertex array pointer.
  *
index 87816d313296d6fdea0ef0aed66bacd4d32b3bd1..c7304e8dd75064c4dcc12189309698f2e1eb91f9 100644 (file)
@@ -189,16 +189,17 @@ pack_histogram( GLcontext *ctx,
          {
             /* temporarily store as GLuints */
             GLuint temp[4*HISTOGRAM_TABLE_SIZE];
-            GLhalfARB *dst = (GLhalfARB *) destination;
+            GLuint *dst = temp;
+            GLhalfARB *half = (GLhalfARB *) destination;
             GLuint i;
             /* get GLuint values */
             PACK_MACRO(GLuint);
             /* convert to GLhalf */
             for (i = 0; i < n * comps; i++) {
-               dst[i] = _mesa_float_to_half((GLfloat) temp[i]);
+               half[i] = _mesa_float_to_half((GLfloat) temp[i]);
             }
             if (packing->SwapBytes) {
-               _mesa_swap2((GLushort *) dst, n * comps);
+               _mesa_swap2((GLushort *) half, n * comps);
             }
          }
          break;
index 139e56a96be037a21fd249ec35d1c1b7c7c46d80..fc278bb8afae59a77be1ddba5e7a1b1df4609b6d 100644 (file)
@@ -33,6 +33,7 @@
 #include "glheader.h"
 #include "colormac.h"
 #include "context.h"
+#include "enums.h"
 #include "image.h"
 #include "imports.h"
 #include "macros.h"
@@ -3228,6 +3229,7 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
           srcFormat == GL_RGBA ||
           srcFormat == GL_BGRA ||
           srcFormat == GL_ABGR_EXT ||
+          srcFormat == GL_DU8DV8_ATI ||
           srcFormat == GL_DUDV_ATI);
 
    ASSERT(srcType == GL_UNSIGNED_BYTE ||
@@ -3343,6 +3345,7 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
          aComp = 0;
          stride = 4;
          break;
+      case GL_DU8DV8_ATI:
       case GL_DUDV_ATI:
          redIndex = 0;
          greenIndex = 1;
@@ -3351,7 +3354,8 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
          stride = 2;
          break;
       default:
-         _mesa_problem(NULL, "bad srcFormat in extract float data");
+         _mesa_problem(NULL, "bad srcFormat %s in extract float data",
+                       _mesa_lookup_enum_by_nr(srcFormat));
          return;
    }
 
index 6ffaddcde96e7f1996736847ac9eb49b4c48b958..def045269c58647c0bd005fd9ab9875d55d24b36 100644 (file)
 #include "context.h"
 #include "version.h"
 
+#ifdef _GNU_SOURCE
+#include <locale.h>
+#ifdef __APPLE__
+#include <xlocale.h>
+#endif
+#endif
+
 
 #define MAXSTRING 4000  /* for vsnprintf() */
 
@@ -101,8 +108,8 @@ _mesa_align_malloc(size_t bytes, unsigned long alignment)
 {
 #if defined(HAVE_POSIX_MEMALIGN)
    void *mem;
-
-   (void) posix_memalign(& mem, alignment, bytes);
+   int err = posix_memalign(& mem, alignment, bytes);
+   (void) err;
    return mem;
 #elif defined(_WIN32) && defined(_MSC_VER)
    return _aligned_malloc(bytes, alignment);
@@ -453,7 +460,7 @@ _mesa_inv_sqrtf(float n)
 #if 0 /* not used, see below -BP */
         float r3, x3, y3;
 #endif
-        union { float f; unsigned int i; } u;
+        fi_type u;
         unsigned int magic;
 
         /*
@@ -622,11 +629,15 @@ _mesa_ffsll(int64_t val)
 unsigned int
 _mesa_bitcount(unsigned int n)
 {
+#if defined(__GNUC__)
+   return __builtin_popcount(n);
+#else
    unsigned int bits;
    for (bits = 0; n > 0; n = n >> 1) {
       bits += (n & 1);
    }
    return bits;
+#endif
 }
 
 
@@ -638,10 +649,10 @@ _mesa_bitcount(unsigned int n)
 GLhalfARB
 _mesa_float_to_half(float val)
 {
-   const int flt = *((int *) (void *) &val);
-   const int flt_m = flt & 0x7fffff;
-   const int flt_e = (flt >> 23) & 0xff;
-   const int flt_s = (flt >> 31) & 0x1;
+   const fi_type fi = {val};
+   const int flt_m = fi.i & 0x7fffff;
+   const int flt_e = (fi.i >> 23) & 0xff;
+   const int flt_s = (fi.i >> 31) & 0x1;
    int s, e, m = 0;
    GLhalfARB result;
    
@@ -728,7 +739,8 @@ _mesa_half_to_float(GLhalfARB val)
    const int m = val & 0x3ff;
    const int e = (val >> 10) & 0x1f;
    const int s = (val >> 15) & 0x1;
-   int flt_m, flt_e, flt_s, flt;
+   int flt_m, flt_e, flt_s;
+   fi_type fi;
    float result;
 
    /* sign bit */
@@ -763,8 +775,8 @@ _mesa_half_to_float(GLhalfARB val)
       flt_m = m << 13;
    }
 
-   flt = (flt_s << 31) | (flt_e << 23) | flt_m;
-   result = *((float *) (void *) &flt);
+   fi.i = (flt_s << 31) | (flt_e << 23) | flt_m;
+   result = fi.f;
    return result;
 }
 
@@ -908,7 +920,15 @@ _mesa_atoi(const char *s)
 double
 _mesa_strtod( const char *s, char **end )
 {
+#ifdef _GNU_SOURCE
+   static locale_t loc = NULL;
+   if (!loc) {
+      loc = newlocale(LC_CTYPE_MASK, "C", NULL);
+   }
+   return strtod_l(s, end, loc);
+#else
    return strtod(s, end);
+#endif
 }
 
 /** Compute simple checksum/hash for a string */
@@ -919,9 +939,9 @@ _mesa_str_checksum(const char *str)
    unsigned int sum, i;
    const char *c;
    sum = i = 1;
-   for (c = str; *c; c++)
+   for (c = str; *c; c++, i++)
       sum += *c * (i % 100);
-   return sum;
+   return sum + i;
 }
 
 
@@ -1219,13 +1239,3 @@ _mesa_debug( const GLcontext *ctx, const char *fmtString, ... )
 }
 
 /*@}*/
-
-
-/**
- * Wrapper for exit().
- */
-void
-_mesa_exit( int status )
-{
-   exit(status);
-}
index 7d4012a85609b1addab2e0e2793d661f1a8d2802..b01fe5b0ab98d55f551b5be93d56114c3bab58c2 100644 (file)
@@ -618,10 +618,6 @@ _mesa_error( __GLcontext *ctx, GLenum error, const char *fmtString, ... );
 extern void
 _mesa_debug( const __GLcontext *ctx, const char *fmtString, ... );
 
-extern void 
-_mesa_exit( int status );
-
-
 #ifdef __cplusplus
 }
 #endif
index 10c89f436888c748ce2598924cc2c9bd4dffa4c6..654faa5c770d1202638a9dee0858b877a2fdfc0f 100644 (file)
@@ -206,7 +206,10 @@ _mesa_light(GLcontext *ctx, GLuint lnum, GLenum pname, const GLfloat *params)
 void GLAPIENTRY
 _mesa_Lightf( GLenum light, GLenum pname, GLfloat param )
 {
-   _mesa_Lightfv( light, pname, &param );
+   GLfloat fparam[4];
+   fparam[0] = param;
+   fparam[1] = fparam[2] = fparam[3] = 0.0F;
+   _mesa_Lightfv( light, pname, fparam );
 }
 
 
@@ -285,7 +288,10 @@ _mesa_Lightfv( GLenum light, GLenum pname, const GLfloat *params )
 void GLAPIENTRY
 _mesa_Lighti( GLenum light, GLenum pname, GLint param )
 {
-   _mesa_Lightiv( light, pname, &param );
+   GLint iparam[4];
+   iparam[0] = param;
+   iparam[1] = iparam[2] = iparam[3] = 0;
+   _mesa_Lightiv( light, pname, iparam );
 }
 
 
@@ -537,14 +543,20 @@ _mesa_LightModeliv( GLenum pname, const GLint *params )
 void GLAPIENTRY
 _mesa_LightModeli( GLenum pname, GLint param )
 {
-   _mesa_LightModeliv( pname, &param );
+   GLint iparam[4];
+   iparam[0] = param;
+   iparam[1] = iparam[2] = iparam[3] = 0;
+   _mesa_LightModeliv( pname, iparam );
 }
 
 
 void GLAPIENTRY
 _mesa_LightModelf( GLenum pname, GLfloat param )
 {
-   _mesa_LightModelfv( pname, &param );
+   GLfloat fparam[4];
+   fparam[0] = param;
+   fparam[1] = fparam[2] = fparam[3] = 0.0F;
+   _mesa_LightModelfv( pname, fparam );
 }
 
 
@@ -636,7 +648,7 @@ _mesa_update_material( GLcontext *ctx, GLuint bitmask )
    struct gl_light *light, *list = &ctx->Light.EnabledList;
    GLfloat (*mat)[4] = ctx->Light.Material.Attrib;
 
-   if (MESA_VERBOSE&VERBOSE_IMMEDIATE
+   if (MESA_VERBOSE & VERBOSE_MATERIAL
       _mesa_debug(ctx, "_mesa_update_material, mask 0x%x\n", bitmask);
 
    if (!bitmask)
index 3d9a1aba98d13a8e37e545e9f982f9a61dd54928..55578adf836c874e7ec606a57e9b5f0228059570 100644 (file)
@@ -202,17 +202,12 @@ do {                                \
 #endif
 
 /**
- * Copy a 4-element float vector (avoid using FPU registers)
- * XXX Could use two 64-bit moves on 64-bit systems
+ * Copy a 4-element float vector
+ * memcpy seems to be most efficient
  */
 #define COPY_4FV( DST, SRC )                  \
 do {                                          \
-   const GLuint *_s = (const GLuint *) (SRC); \
-   GLuint *_d = (GLuint *) (DST);             \
-   _d[0] = _s[0];                             \
-   _d[1] = _s[1];                             \
-   _d[2] = _s[2];                             \
-   _d[3] = _s[3];                             \
+   _mesa_memcpy(DST, SRC, sizeof(GLfloat) * 4);       \
 } while (0)
 
 /** Copy \p SZ elements into a 4-element vector */
@@ -631,12 +626,6 @@ do {                                    \
 /** Clamp X to [MIN,MAX] */
 #define CLAMP( X, MIN, MAX )  ( (X)<(MIN) ? (MIN) : ((X)>(MAX) ? (MAX) : (X)) )
 
-/** Assign X to CLAMP(X, MIN, MAX) */
-#define CLAMP_SELF(x, mn, mx)  \
-   ( (x)<(mn) ? ((x) = (mn)) : ((x)>(mx) ? ((x)=(mx)) : (x)) )
-
-
-
 /** Minimum of two values: */
 #define MIN2( A, B )   ( (A)<(B) ? (A) : (B) )
 
index c2fb8404b1656bab2c55d639db4bf1bb081bcadc..4e68bc15d8a5b85751d62f183ef7f8edb8fdce34 100644 (file)
  * enabled or not.
  */
 
+#ifdef IN_DRI_DRIVER
+#define FEATURE_remap_table 1
+#else
+#define FEATURE_remap_table 0
+#endif
+
 #define FEATURE_accum  _HAVE_FULL_GL
 #define FEATURE_arrayelt  _HAVE_FULL_GL
 #define FEATURE_attrib_stack  _HAVE_FULL_GL
index c3928fa513f00e06e21a46a4e78d6cdde4a8c8bd..7350c7a3d2cf3933db86ffd54a182815b8bcb956 100644 (file)
  */
 
 #include "imports.h"
+#include "formats.h"
 #include "mipmap.h"
 #include "texcompress.h"
-#include "texformat.h"
 #include "teximage.h"
+#include "texstore.h"
 #include "image.h"
 
 
@@ -1493,7 +1494,7 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
                       struct gl_texture_object *texObj)
 {
    const struct gl_texture_image *srcImage;
-   const struct gl_texture_format *convertFormat;
+   gl_format convertFormat;
    const GLubyte *srcData = NULL;
    GLubyte *dstData = NULL;
    GLint level, maxLevels;
@@ -1508,7 +1509,8 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
    ASSERT(maxLevels > 0);  /* bad target */
 
    /* Find convertFormat - the format that do_row() will process */
-   if (srcImage->IsCompressed) {
+
+   if (_mesa_is_format_compressed(srcImage->TexFormat)) {
       /* setup for compressed textures - need to allocate temporary
        * image buffers to hold uncompressed images.
        */
@@ -1520,11 +1522,11 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
              texObj->Target == GL_TEXTURE_CUBE_MAP_ARB);
 
       if (srcImage->_BaseFormat == GL_RGB) {
-         convertFormat = &_mesa_texformat_rgb;
+         convertFormat = MESA_FORMAT_RGB888;
          components = 3;
       }
       else if (srcImage->_BaseFormat == GL_RGBA) {
-         convertFormat = &_mesa_texformat_rgba;
+         convertFormat = MESA_FORMAT_RGBA8888;
          components = 4;
       }
       else {
@@ -1588,7 +1590,11 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
                                          &dstWidth, &dstHeight, &dstDepth);
       if (!nextLevel) {
          /* all done */
-         break;
+         if (_mesa_is_format_compressed(srcImage->TexFormat)) {
+            _mesa_free((void *) srcData);
+            _mesa_free(dstData);
+         }
+         return;
       }
 
       /* get dest gl_texture_image */
@@ -1609,25 +1615,17 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
       dstImage->TexFormat = srcImage->TexFormat;
       dstImage->FetchTexelc = srcImage->FetchTexelc;
       dstImage->FetchTexelf = srcImage->FetchTexelf;
-      dstImage->IsCompressed = srcImage->IsCompressed;
-      if (dstImage->IsCompressed) {
-         dstImage->CompressedSize
-            = ctx->Driver.CompressedTextureSize(ctx, dstImage->Width,
-                                              dstImage->Height,
-                                              dstImage->Depth,
-                                              dstImage->TexFormat->MesaFormat);
-         ASSERT(dstImage->CompressedSize > 0);
-      }
-
-      ASSERT(dstImage->TexFormat);
-      ASSERT(dstImage->FetchTexelc);
-      ASSERT(dstImage->FetchTexelf);
 
       /* Alloc new teximage data buffer.
        * Setup src and dest data pointers.
        */
-      if (dstImage->IsCompressed) {
-         dstImage->Data = _mesa_alloc_texmemory(dstImage->CompressedSize);
+      if (_mesa_is_format_compressed(dstImage->TexFormat)) {
+         GLuint dstCompressedSize = 
+            _mesa_format_image_size(dstImage->TexFormat, dstImage->Width,
+                                    dstImage->Height, dstImage->Depth);
+         ASSERT(dstCompressedSize > 0);
+
+         dstImage->Data = _mesa_alloc_texmemory(dstCompressedSize);
          if (!dstImage->Data) {
             _mesa_error(ctx, GL_OUT_OF_MEMORY, "generating mipmaps");
             return;
@@ -1637,7 +1635,7 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
          ASSERT(dstData);
       }
       else {
-         bytesPerTexel = dstImage->TexFormat->TexelBytes;
+         bytesPerTexel = _mesa_get_format_bytes(dstImage->TexFormat);
          ASSERT(dstWidth * dstHeight * dstDepth * bytesPerTexel > 0);
          dstImage->Data = _mesa_alloc_texmemory(dstWidth * dstHeight
                                                 * dstDepth * bytesPerTexel);
@@ -1649,6 +1647,10 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
          dstData = (GLubyte *) dstImage->Data;
       }
 
+      ASSERT(dstImage->TexFormat);
+      ASSERT(dstImage->FetchTexelc);
+      ASSERT(dstImage->FetchTexelf);
+
       _mesa_generate_mipmap_level(target, datatype, comps, border,
                                   srcWidth, srcHeight, srcDepth, 
                                   srcData, srcImage->RowStride,
@@ -1656,22 +1658,24 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
                                   dstData, dstImage->RowStride);
 
 
-      if (dstImage->IsCompressed) {
+      if (_mesa_is_format_compressed(dstImage->TexFormat)) {
          GLubyte *temp;
          /* compress image from dstData into dstImage->Data */
-         const GLenum srcFormat = convertFormat->BaseFormat;
+         const GLenum srcFormat = _mesa_get_format_base_format(convertFormat);
          GLint dstRowStride
-            = _mesa_compressed_row_stride(dstImage->TexFormat->MesaFormat, dstWidth);
+            = _mesa_format_row_stride(dstImage->TexFormat, dstWidth);
          ASSERT(srcFormat == GL_RGB || srcFormat == GL_RGBA);
-         dstImage->TexFormat->StoreImage(ctx, 2, dstImage->_BaseFormat,
-                                         dstImage->TexFormat,
-                                         dstImage->Data,
-                                         0, 0, 0, /* dstX/Y/Zoffset */
-                                         dstRowStride, 0, /* strides */
-                                         dstWidth, dstHeight, 1, /* size */
-                                         srcFormat, CHAN_TYPE,
-                                         dstData, /* src data, actually */
-                                         &ctx->DefaultPacking);
+
+         _mesa_texstore(ctx, 2, dstImage->_BaseFormat,
+                        dstImage->TexFormat,
+                        dstImage->Data,
+                        0, 0, 0, /* dstX/Y/Zoffset */
+                        dstRowStride, 0, /* strides */
+                        dstWidth, dstHeight, 1, /* size */
+                        srcFormat, CHAN_TYPE,
+                        dstData, /* src data, actually */
+                        &ctx->DefaultPacking);
+
          /* swap src and dest pointers */
          temp = (GLubyte *) srcData;
          srcData = dstData;
@@ -1679,12 +1683,6 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
       }
 
    } /* loop over mipmap levels */
-
-   if (srcImage->IsCompressed) {
-      /* free uncompressed image buffers */
-      _mesa_free((void *) srcData);
-      _mesa_free(dstData);
-   }
 }
 
 
index d005064645418e52a711a42f4463b19deff4a292..5227565f8769f495c0f5a784d7f6e05ce8686e37 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Mesa 3-D graphics library
- * Version:  7.5
+ * Version:  7.7
  *
  * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
  * Copyright (C) 2009  VMware, Inc.  All Rights Reserved.
 #endif
 
 
+/**
+ * \name 64-bit extension of GLbitfield.
+ */
+/*@{*/
+typedef GLuint64 GLbitfield64;
+
+#define BITFIELD64_ONE         1ULL
+#define BITFIELD64_ALLONES     ~0ULL
+
+/** Set a single bit */
+#define BITFIELD64_BIT(b)      (BITFIELD64_ONE << (b))
+
+/** Set a mask of the least significant \c b bits */
+#define BITFIELD64_MASK(b)     (((b) >= 64) ? BITFIELD64_ALLONES : \
+                               (BITFIELD64_BIT(b) - 1))
+
+/**
+ * Set all bits from l (low bit) to h (high bit), inclusive.
+ *
+ * \note \C BITFIELD_64_RANGE(0, 63) return 64 set bits.
+ */
+#define BITFIELD64_RANGE(l, h) (BITFIELD64_MASK((h) + 1) & ~BITFIELD64_MASK(l))
+/*@}*/
+
+
 /**
  * \name Some forward type declarations
  */
 /*@{*/
 struct _mesa_HashTable;
 struct gl_attrib_node;
+struct gl_list_extensions;
 struct gl_meta_state;
 struct gl_pixelstore_attrib;
 struct gl_program_cache;
@@ -207,7 +233,7 @@ typedef enum
    VERT_RESULT_BFC0 = 13,
    VERT_RESULT_BFC1 = 14,
    VERT_RESULT_EDGE = 15,
-   VERT_RESULT_VAR0 = 16  /**< shader varying */,
+   VERT_RESULT_VAR0 = 16,  /**< shader varying */
    VERT_RESULT_MAX = (VERT_RESULT_VAR0 + MAX_VARYING)
 } gl_vert_result;
 
@@ -538,7 +564,7 @@ struct gl_colorbuffer_attrib
    GLclampf ClearColor[4];             /**< Color to use for glClear */
 
    GLuint IndexMask;                   /**< Color index write mask */
-   GLubyte ColorMask[4];               /**< Each flag is 0xff or 0x0 */
+   GLubyte ColorMask[MAX_DRAW_BUFFERS][4];/**< Each flag is 0xff or 0x0 */
 
    GLenum DrawBuffer[MAX_DRAW_BUFFERS];        /**< Which buffer to draw into */
 
@@ -555,7 +581,7 @@ struct gl_colorbuffer_attrib
     * \name Blending
     */
    /*@{*/
-   GLboolean BlendEnabled;             /**< Blending enabled flag */
+   GLbitfield BlendEnabled;            /**< Per-buffer blend enable flags */
    GLenum BlendSrcRGB;                 /**< Blending source operator */
    GLenum BlendDstRGB;                 /**< Blending destination operator */
    GLenum BlendSrcA;                   /**< GL_INGR_blend_func_separate */
@@ -819,29 +845,6 @@ struct gl_list_attrib
 };
 
 
-/**
- * Used by device drivers to hook new commands into display lists.
- */
-struct gl_list_instruction
-{
-   GLuint Size;
-   void (*Execute)( GLcontext *ctx, void *data );
-   void (*Destroy)( GLcontext *ctx, void *data );
-   void (*Print)( GLcontext *ctx, void *data );
-};
-
-#define MAX_DLIST_EXT_OPCODES 16
-
-/**
- * Used by device drivers to hook new commands into display lists.
- */
-struct gl_list_extensions
-{
-   struct gl_list_instruction Opcode[MAX_DLIST_EXT_OPCODES];
-   GLuint NumOpcodes;
-};
-
-
 /**
  * Multisample attribute group (GL_MULTISAMPLE_BIT).
  */
@@ -1136,104 +1139,21 @@ typedef void (*StoreTexelFunc)(struct gl_texture_image *texImage,
                                const void *texel);
 
 
-/**
- * This macro defines the (many) parameters to the texstore functions.
- * \param dims  either 1 or 2 or 3
- * \param baseInternalFormat  user-specified base internal format
- * \param dstFormat  destination Mesa texture format
- * \param dstAddr  destination image address
- * \param dstX/Y/Zoffset  destination x/y/z offset (ala TexSubImage), in texels
- * \param dstRowStride  destination image row stride, in bytes
- * \param dstImageOffsets  offset of each 2D slice within 3D texture, in texels
- * \param srcWidth/Height/Depth  source image size, in pixels
- * \param srcFormat  incoming image format
- * \param srcType  incoming image data type
- * \param srcAddr  source image address
- * \param srcPacking  source image packing parameters
- */
-#define TEXSTORE_PARAMS \
-       GLcontext *ctx, GLuint dims, \
-       GLenum baseInternalFormat, \
-       const struct gl_texture_format *dstFormat, \
-       GLvoid *dstAddr, \
-       GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, \
-       GLint dstRowStride, const GLuint *dstImageOffsets, \
-       GLint srcWidth, GLint srcHeight, GLint srcDepth, \
-       GLenum srcFormat, GLenum srcType, \
-       const GLvoid *srcAddr, \
-       const struct gl_pixelstore_attrib *srcPacking
-
-
-
-/**
- * Texture image storage function.
- */
-typedef GLboolean (*StoreTexImageFunc)(TEXSTORE_PARAMS);
-
-
-/**
- * Texture format record 
- */
-struct gl_texture_format
-{
-   GLint MesaFormat;           /**< One of the MESA_FORMAT_* values */
-
-   GLenum BaseFormat;          /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
-                                *   GL_LUMINANCE, GL_LUMINANCE_ALPHA,
-                                *   GL_INTENSITY, GL_COLOR_INDEX or
-                                *   GL_DEPTH_COMPONENT.
-                                */
-   GLenum DataType;            /**< GL_FLOAT or GL_UNSIGNED_NORMALIZED_ARB */
-
-   /**
-    * Bits per texel component.  These are just rough approximations
-    * for compressed texture formats.
-    */
-   /*@{*/
-   GLubyte RedBits;
-   GLubyte GreenBits;
-   GLubyte BlueBits;
-   GLubyte AlphaBits;
-   GLubyte LuminanceBits;
-   GLubyte IntensityBits;
-   GLubyte IndexBits;
-   GLubyte DepthBits;
-   GLubyte StencilBits;        /**< GL_EXT_packed_depth_stencil */
-   /*@}*/
-
-   GLuint TexelBytes;          /**< Bytes per texel, 0 if compressed format */
-
-   StoreTexImageFunc StoreImage;
-
-   /**
-    * \name Texel fetch function pointers
-    */
-   /*@{*/
-   FetchTexelFuncC FetchTexel1D;
-   FetchTexelFuncC FetchTexel2D;
-   FetchTexelFuncC FetchTexel3D;
-   FetchTexelFuncF FetchTexel1Df;
-   FetchTexelFuncF FetchTexel2Df;
-   FetchTexelFuncF FetchTexel3Df;
-   /*@}*/
-
-   StoreTexelFunc StoreTexel;
-};
-
-
 /**
  * Texture image state.  Describes the dimensions of a texture image,
  * the texel format and pointers to Texel Fetch functions.
  */
 struct gl_texture_image
 {
+   GLint InternalFormat;       /**< Internal format as given by the user */
    GLenum _BaseFormat;         /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
                                 *   GL_LUMINANCE, GL_LUMINANCE_ALPHA,
                                 *   GL_INTENSITY, GL_COLOR_INDEX,
                                 *   GL_DEPTH_COMPONENT or GL_DEPTH_STENCIL_EXT
                                  *   only. Used for choosing TexEnv arithmetic.
                                 */
-   GLint InternalFormat;       /**< Internal format as given by the user */
+   GLuint TexFormat;            /**< The actual format: MESA_FORMAT_x */
+
    GLuint Border;              /**< 0 or 1 */
    GLuint Width;               /**< = 2^WidthLog2 + 2*Border */
    GLuint Height;              /**< = 2^HeightLog2 + 2*Border */
@@ -1251,16 +1171,11 @@ struct gl_texture_image
    GLboolean IsClientData;     /**< Data owned by client? */
    GLboolean _IsPowerOfTwo;    /**< Are all dimensions powers of two? */
 
-   const struct gl_texture_format *TexFormat;
-
    struct gl_texture_object *TexObject;  /**< Pointer back to parent object */
 
    FetchTexelFuncC FetchTexelc;        /**< GLchan texel fetch function pointer */
    FetchTexelFuncF FetchTexelf;        /**< Float texel fetch function pointer */
 
-   GLboolean IsCompressed;     /**< GL_ARB_texture_compression */
-   GLuint CompressedSize;      /**< GL_ARB_texture_compression */
-
    GLuint RowStride;           /**< Padded width in units of texels */
    GLuint *ImageOffsets;        /**< if 3D texture: array [Depth] of offsets to
                                      each 2D slice in 'Data', in texels */
@@ -1302,7 +1217,11 @@ struct gl_texture_object
    GLuint Name;                        /**< the user-visible texture object ID */
    GLenum Target;               /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
    GLfloat Priority;           /**< in [0,1] */
-   GLfloat BorderColor[4];     /**< unclamped */
+   union {
+      GLfloat f[4];
+      GLuint ui[4];
+      GLint i[4];
+   } BorderColor;               /**< Interpreted according to texture format */
    GLenum WrapS;               /**< S-axis texture image wrap mode */
    GLenum WrapT;               /**< T-axis texture image wrap mode */
    GLenum WrapR;               /**< R-axis texture image wrap mode */
@@ -1780,7 +1699,7 @@ struct gl_program
    struct prog_instruction *Instructions;
 
    GLbitfield InputsRead;     /**< Bitmask of which input regs are read */
-   GLbitfield OutputsWritten; /**< Bitmask of which output regs are written to */
+   GLbitfield64 OutputsWritten; /**< Bitmask of which output regs are written */
    GLbitfield InputFlags[MAX_PROGRAM_INPUTS];   /**< PROG_PARAM_BIT_x flags */
    GLbitfield OutputFlags[MAX_PROGRAM_OUTPUTS]; /**< PROG_PARAM_BIT_x flags */
    GLbitfield TexturesUsed[MAX_TEXTURE_UNITS];  /**< TEXTURE_x_BIT bitmask */
@@ -1939,10 +1858,10 @@ struct ati_fragment_shader
    struct atifs_instruction *Instructions[2];
    struct atifs_setupinst *SetupInst[2];
    GLfloat Constants[8][4];
-   GLbitfield LocalConstDef;  /** Indicates which constants have been set */
+   GLbitfield LocalConstDef;  /**< Indicates which constants have been set */
    GLubyte numArithInstr[2];
    GLubyte regsAssigned[2];
-   GLubyte NumPasses;         /** 1 or 2 */
+   GLubyte NumPasses;         /**< 1 or 2 */
    GLubyte cur_pass;
    GLubyte last_optype;
    GLboolean interpinp1;
@@ -1956,7 +1875,7 @@ struct ati_fragment_shader
 struct gl_ati_fragment_shader_state
 {
    GLboolean Enabled;
-   GLboolean _Enabled;                      /** enabled and valid shader? */
+   GLboolean _Enabled;                  /**< enabled and valid shader? */
    GLboolean Compiling;
    GLfloat GlobalConstants[8][4];
    struct ati_fragment_shader *Current;
@@ -1984,6 +1903,10 @@ struct gl_query_state
    struct _mesa_HashTable *QueryObjects;
    struct gl_query_object *CurrentOcclusionObject; /* GL_ARB_occlusion_query */
    struct gl_query_object *CurrentTimerObject;     /* GL_EXT_timer_query */
+
+   /** GL_NV_conditional_render */
+   struct gl_query_object *CondRenderQuery;
+   GLenum CondRenderMode;
 };
 
 
@@ -2068,6 +1991,7 @@ struct gl_shader_program
 #define GLSL_UNIFORMS 0x10  /**< Print glUniform calls */
 #define GLSL_NOP_VERT 0x20  /**< Force no-op vertex shaders */
 #define GLSL_NOP_FRAG 0x40  /**< Force no-op fragment shaders */
+#define GLSL_USE_PROG 0x80  /**< Log glUseProgram calls */
 
 
 /**
@@ -2178,20 +2102,12 @@ struct gl_renderbuffer
    GLuint Name;
    GLint RefCount;
    GLuint Width, Height;
+
    GLenum InternalFormat; /**< The user-specified format */
-   GLenum _ActualFormat;  /**< The driver-chosen format */
    GLenum _BaseFormat;    /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or
                                GL_STENCIL_INDEX. */
-   GLenum ColorEncoding; /**< GL_LINEAR or GL_SRGB */
-   GLenum ComponentType; /**< GL_FLOAT, GL_INT, GL_UNSIGNED_INT,
-                              GL_UNSIGNED_NORMALIZED or GL_INDEX */
-   GLubyte RedBits;      /**< Bits of red per pixel */
-   GLubyte GreenBits;
-   GLubyte BlueBits;
-   GLubyte AlphaBits;
-   GLubyte IndexBits;
-   GLubyte DepthBits;
-   GLubyte StencilBits;
+   GLuint Format;         /**< The actual format: MESA_FORMAT_x */
+
    GLubyte NumSamples;
 
    GLenum DataType;      /**< Type of values passed to the Get/Put functions */
@@ -2411,6 +2327,7 @@ struct gl_constants
    GLuint MaxTextureCoordUnits;
    GLuint MaxTextureImageUnits;
    GLuint MaxVertexTextureImageUnits;
+   GLuint MaxCombinedTextureImageUnits;
    GLuint MaxTextureUnits;           /**< = MIN(CoordUnits, ImageUnits) */
    GLfloat MaxTextureMaxAnisotropy;  /**< GL_EXT_texture_filter_anisotropic */
    GLfloat MaxTextureLodBias;        /**< GL_EXT_texture_lod_bias */
@@ -2447,9 +2364,6 @@ struct gl_constants
 
    GLuint MaxDrawBuffers;    /**< GL_ARB_draw_buffers */
 
-   GLenum ColorReadFormat;   /**< GL_OES_read_format */
-   GLenum ColorReadType;     /**< GL_OES_read_format */
-
    GLuint MaxColorAttachments;   /**< GL_EXT_framebuffer_object */
    GLuint MaxRenderbufferSize;   /**< GL_EXT_framebuffer_object */
    GLuint MaxSamples;            /**< GL_ARB_framebuffer_object */
@@ -2528,10 +2442,12 @@ struct gl_extensions
    GLboolean EXT_compiled_vertex_array;
    GLboolean EXT_copy_texture;
    GLboolean EXT_depth_bounds_test;
+   GLboolean EXT_draw_buffers2;
    GLboolean EXT_draw_range_elements;
-   GLboolean EXT_framebuffer_object;
    GLboolean EXT_fog_coord;
    GLboolean EXT_framebuffer_blit;
+   GLboolean EXT_framebuffer_multisample;
+   GLboolean EXT_framebuffer_object;
    GLboolean EXT_gpu_program_parameters;
    GLboolean EXT_histogram;
    GLboolean EXT_multi_draw_arrays;
@@ -2584,6 +2500,7 @@ struct gl_extensions
    GLboolean MESA_texture_array;
    GLboolean MESA_texture_signed_rgba;
    GLboolean NV_blend_square;
+   GLboolean NV_conditional_render;
    GLboolean NV_fragment_program;
    GLboolean NV_fragment_program_option;
    GLboolean NV_light_max_exponent;
@@ -2604,6 +2521,8 @@ struct gl_extensions
    GLboolean S3_s3tc;
    /** The extension string */
    const GLubyte *String;
+   /** Number of supported extensions */
+   GLuint Count;
 };
 
 
@@ -2945,6 +2864,10 @@ struct __GLcontextRec
    /** Extension information */
    struct gl_extensions Extensions;
 
+   /** Version info */
+   GLuint VersionMajor, VersionMinor;
+   char *VersionString;
+
    /** \name State attribute stack (for glPush/PopAttrib) */
    /*@{*/
    GLuint AttribStackDepth;
@@ -3061,7 +2984,7 @@ struct __GLcontextRec
    struct gl_shine_tab *_ShineTabList;  /**< MRU list of inactive shine tables */
    /**@}*/
 
-   struct gl_list_extensions ListExt; /**< driver dlist extensions */
+   struct gl_list_extensions *ListExt; /**< driver dlist extensions */
 
    /** \name For debugging/development only */
    /*@{*/
@@ -3117,11 +3040,12 @@ extern int MESA_DEBUG_FLAGS;
 #endif
 
 
+/** The MESA_VERBOSE var is a bitmask of these flags */
 enum _verbose
 {
    VERBOSE_VARRAY              = 0x0001,
    VERBOSE_TEXTURE             = 0x0002,
-   VERBOSE_IMMEDIATE           = 0x0004,
+   VERBOSE_MATERIAL            = 0x0004,
    VERBOSE_PIPELINE            = 0x0008,
    VERBOSE_DRIVER              = 0x0010,
    VERBOSE_STATE               = 0x0020,
@@ -3131,9 +3055,12 @@ enum _verbose
    VERBOSE_PRIMS               = 0x0400,
    VERBOSE_VERTS               = 0x0800,
    VERBOSE_DISASSEM            = 0x1000,
+   VERBOSE_DRAW                 = 0x2000,
+   VERBOSE_SWAPBUFFERS          = 0x4000
 };
 
 
+/** The MESA_DEBUG_FLAGS var is a bitmask of these flags */
 enum _debug
 {
    DEBUG_ALWAYS_FLUSH          = 0x1
index 4c8fc1f72e0dfa239185f30df6ebb131a1e4d13d..dcaeccd90d4df4747320fae12024ee7f9065295d 100644 (file)
@@ -69,8 +69,10 @@ _mesa_PointSize( GLfloat size )
 void GLAPIENTRY
 _mesa_PointParameteri( GLenum pname, GLint param )
 {
-   const GLfloat value = (GLfloat) param;
-   _mesa_PointParameterfv(pname, &value);
+   GLfloat p[3];
+   p[0] = (GLfloat) param;
+   p[1] = p[2] = 0.0F;
+   _mesa_PointParameterfv(pname, p);
 }
 
 
@@ -90,7 +92,10 @@ _mesa_PointParameteriv( GLenum pname, const GLint *params )
 void GLAPIENTRY
 _mesa_PointParameterf( GLenum pname, GLfloat param)
 {
-   _mesa_PointParameterfv(pname, &param);
+   GLfloat p[3];
+   p[0] = param;
+   p[1] = p[2] = 0.0F;
+   _mesa_PointParameterfv(pname, p);
 }
 
 
@@ -200,7 +205,12 @@ _mesa_PointParameterfv( GLenum pname, const GLfloat *params)
          }
          break;
       case GL_POINT_SPRITE_COORD_ORIGIN:
-         if (ctx->Extensions.ARB_point_sprite || ctx->Extensions.NV_point_sprite) {
+        /* This is not completely correct.  GL_POINT_SPRITE_COORD_ORIGIN was
+         * added to point sprites when the extension was merged into OpenGL
+         * 2.0.  It is expected that an implementation supporting OpenGL 1.4
+         * and GL_ARB_point_sprite will generate an error here.
+         */
+         if (ctx->Extensions.ARB_point_sprite) {
             GLenum value = (GLenum) params[0];
             if (value != GL_LOWER_LEFT && value != GL_UPPER_LEFT) {
                _mesa_error(ctx, GL_INVALID_VALUE,
index f6eb4ee7e1b11ea547ee5def8bd46091a2ad93d8..387a82fc9dff1f9a6d78bb24cf8ec90b08e3103f 100644 (file)
@@ -118,15 +118,6 @@ _mesa_delete_query(GLcontext *ctx, struct gl_query_object *q)
 }
 
 
-static struct gl_query_object *
-lookup_query_object(GLcontext *ctx, GLuint id)
-{
-   return (struct gl_query_object *)
-      _mesa_HashLookup(ctx->Query.QueryObjects, id);
-}
-
-
-
 void
 _mesa_init_query_object_functions(struct dd_function_table *driver)
 {
@@ -196,7 +187,7 @@ _mesa_DeleteQueriesARB(GLsizei n, const GLuint *ids)
 
    for (i = 0; i < n; i++) {
       if (ids[i] > 0) {
-         struct gl_query_object *q = lookup_query_object(ctx, ids[i]);
+         struct gl_query_object *q = _mesa_lookup_query_object(ctx, ids[i]);
          if (q) {
             ASSERT(!q->Active); /* should be caught earlier */
             _mesa_HashRemove(ctx->Query.QueryObjects, ids[i]);
@@ -213,7 +204,7 @@ _mesa_IsQueryARB(GLuint id)
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
 
-   if (id && lookup_query_object(ctx, id))
+   if (id && _mesa_lookup_query_object(ctx, id))
       return GL_TRUE;
    else
       return GL_FALSE;
@@ -260,7 +251,7 @@ _mesa_BeginQueryARB(GLenum target, GLuint id)
       return;
    }
 
-   q = lookup_query_object(ctx, id);
+   q = _mesa_lookup_query_object(ctx, id);
    if (!q) {
       /* create new object */
       q = ctx->Driver.NewQueryObject(ctx, id);
@@ -386,7 +377,7 @@ _mesa_GetQueryObjectivARB(GLuint id, GLenum pname, GLint *params)
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    if (id)
-      q = lookup_query_object(ctx, id);
+      q = _mesa_lookup_query_object(ctx, id);
 
    if (!q || q->Active) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
@@ -426,7 +417,7 @@ _mesa_GetQueryObjectuivARB(GLuint id, GLenum pname, GLuint *params)
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    if (id)
-      q = lookup_query_object(ctx, id);
+      q = _mesa_lookup_query_object(ctx, id);
 
    if (!q || q->Active) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
@@ -469,7 +460,7 @@ _mesa_GetQueryObjecti64vEXT(GLuint id, GLenum pname, GLint64EXT *params)
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    if (id)
-      q = lookup_query_object(ctx, id);
+      q = _mesa_lookup_query_object(ctx, id);
 
    if (!q || q->Active) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
@@ -506,7 +497,7 @@ _mesa_GetQueryObjectui64vEXT(GLuint id, GLenum pname, GLuint64EXT *params)
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    if (id)
-      q = lookup_query_object(ctx, id);
+      q = _mesa_lookup_query_object(ctx, id);
 
    if (!q || q->Active) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
index 6cf3c76d74dafb5397e724099ea2b8f8c5ebc753..ba8b5dd0029e8ba3231ff98a1da3ad11d3338c6a 100644 (file)
@@ -28,6 +28,7 @@
 
 
 #include "main/mtypes.h"
+#include "main/hash.h"
 
 
 #if FEATURE_queryobj
       (driver)->CheckQuery     = impl ## CheckQuery;     \
    } while (0)
 
+
+static INLINE struct gl_query_object *
+_mesa_lookup_query_object(GLcontext *ctx, GLuint id)
+{
+   return (struct gl_query_object *)
+      _mesa_HashLookup(ctx->Query.QueryObjects, id);
+}
+
+
 extern void GLAPIENTRY
 _mesa_GenQueriesARB(GLsizei n, GLuint *ids);
 
index c1ac0606c863092a170d4ed60d603d0536c0efa4..1060c5796edd636986e882b7c398da44d6dd2ea0 100644 (file)
@@ -218,14 +218,10 @@ _mesa_new_renderbuffer_16wrap8(GLcontext *ctx, struct gl_renderbuffer *rb8)
       _glthread_UNLOCK_MUTEX(rb8->Mutex);
 
       rb16->InternalFormat = rb8->InternalFormat;
-      rb16->_ActualFormat = rb8->_ActualFormat;
+      rb16->Format = rb8->Format; /* XXX is this right? */
       rb16->_BaseFormat = rb8->_BaseFormat;
       rb16->DataType = GL_UNSIGNED_SHORT;
       /* Note: passing through underlying bits/channel */
-      rb16->RedBits = rb8->RedBits;
-      rb16->GreenBits = rb8->GreenBits;
-      rb16->BlueBits = rb8->BlueBits;
-      rb16->AlphaBits = rb8->AlphaBits;
       rb16->Wrapped = rb8;
 
       rb16->AllocStorage = AllocStorage_wrapper;
@@ -385,14 +381,10 @@ _mesa_new_renderbuffer_32wrap8(GLcontext *ctx, struct gl_renderbuffer *rb8)
       _glthread_UNLOCK_MUTEX(rb8->Mutex);
 
       rb32->InternalFormat = rb8->InternalFormat;
-      rb32->_ActualFormat = rb8->_ActualFormat;
+      rb32->Format = rb8->Format;  /* XXX is this right? */
       rb32->_BaseFormat = rb8->_BaseFormat;
       rb32->DataType = GL_FLOAT;
       /* Note: passing through underlying bits/channel */
-      rb32->RedBits = rb8->RedBits;
-      rb32->GreenBits = rb8->GreenBits;
-      rb32->BlueBits = rb8->BlueBits;
-      rb32->AlphaBits = rb8->AlphaBits;
       rb32->Wrapped = rb8;
 
       rb32->AllocStorage = AllocStorage_wrapper;
@@ -552,14 +544,10 @@ _mesa_new_renderbuffer_32wrap16(GLcontext *ctx, struct gl_renderbuffer *rb16)
       _glthread_UNLOCK_MUTEX(rb16->Mutex);
 
       rb32->InternalFormat = rb16->InternalFormat;
-      rb32->_ActualFormat = rb16->_ActualFormat;
+      rb32->Format = rb16->Format;  /* XXX is this right? */
       rb32->_BaseFormat = rb16->_BaseFormat;
       rb32->DataType = GL_FLOAT;
       /* Note: passing through underlying bits/channel */
-      rb32->RedBits = rb16->RedBits;
-      rb32->GreenBits = rb16->GreenBits;
-      rb32->BlueBits = rb16->BlueBits;
-      rb32->AlphaBits = rb16->AlphaBits;
       rb32->Wrapped = rb16;
 
       rb32->AllocStorage = AllocStorage_wrapper;
diff --git a/src/mesa/main/remap.c b/src/mesa/main/remap.c
new file mode 100644 (file)
index 0000000..0385ae8
--- /dev/null
@@ -0,0 +1,216 @@
+/*
+ * Mesa 3-D graphics library
+ * Version:  7.7
+ *
+ * Copyright (C) 2009 Chia-I Wu <olv@0xlab.org>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION 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 remap.c
+ * Remap table management.
+ *
+ * Entries in the dispatch table are either static or dynamic.  The
+ * dispatch table is shared by mesa core and glapi.  When they are
+ * built separately, it is possible that a static entry in mesa core
+ * is dynamic, or assigned a different static offset, in glapi.  The
+ * remap table is in charge of mapping a static entry in mesa core to
+ * a dynamic entry, or the corresponding static entry, in glapi.
+ */
+
+#include "remap.h"
+#include "imports.h"
+
+#include "glapi/dispatch.h"
+
+
+#if FEATURE_remap_table
+
+
+#define need_MESA_remap_table
+#include "remap_helper.h"
+
+#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
+#define MAX_ENTRY_POINTS 16
+
+
+/* this is global for quick access */
+int driDispatchRemapTable[driDispatchRemapTable_size];
+
+
+/**
+ * Return the spec string associated with the given function index.
+ * The index is available from including remap_helper.h.
+ *
+ * \param func_index an opaque function index.
+ *
+ * \return the spec string associated with the function index, or NULL.
+ */
+const char *
+_mesa_get_function_spec(GLint func_index)
+{
+   if (func_index < ARRAY_SIZE(_mesa_function_pool))
+      return _mesa_function_pool + func_index;
+   else
+      return NULL;
+}
+
+
+/**
+ * Map a function by its spec.  The function will be added to glapi,
+ * and the dispatch offset will be returned.
+ *
+ * \param spec a '\0'-separated string array specifying a function.
+ *        It begins with the parameter signature of the function,
+ *        followed by the names of the entry points.  An empty entry
+ *        point name terminates the array.
+ *
+ * \return the offset of the (re-)mapped function in the dispatch
+ *         table, or -1.
+ */
+GLint
+_mesa_map_function_spec(const char *spec)
+{
+   const char *signature;
+   const char *names[MAX_ENTRY_POINTS + 1];
+   GLint num_names = 0;
+
+   if (!spec)
+      return -1;
+
+   signature = spec;
+   spec += strlen(spec) + 1;
+
+   /* spec is terminated by an empty string */
+   while (*spec) {
+      names[num_names] = spec;
+      num_names++;
+      if (num_names >= MAX_ENTRY_POINTS)
+         break;
+      spec += strlen(spec) + 1;
+   }
+   if (!num_names)
+      return -1;
+
+   names[num_names] = NULL;
+
+   /* add the entry points to the dispatch table */
+   return _glapi_add_dispatch(names, signature);
+}
+
+
+/**
+ * Map an array of functions.  This is a convenient function for
+ * use with arrays available from including remap_helper.h.
+ *
+ * Note that the dispatch offsets of the functions are not returned.
+ * If they are needed, _mesa_map_function_spec() should be used.
+ *
+ * \param func_array an array of function remaps.
+ */
+void
+_mesa_map_function_array(const struct gl_function_remap *func_array)
+{
+   GLint i;
+
+   if (!func_array)
+      return;
+
+   for (i = 0; func_array[i].func_index != -1; i++) {
+      const char *spec;
+      GLint offset;
+
+      spec = _mesa_get_function_spec(func_array[i].func_index);
+      if (!spec) {
+         _mesa_problem(NULL, "invalid function index %d",
+                       func_array[i].func_index);
+         continue;
+      }
+
+      offset = _mesa_map_function_spec(spec);
+      /* error checks */
+      if (offset < 0) {
+         const char *name = spec + strlen(spec) + 1;
+         _mesa_warning(NULL, "failed to remap %s", name);
+      }
+      else if (func_array[i].dispatch_offset >= 0 &&
+               offset != func_array[i].dispatch_offset) {
+         const char *name = spec + strlen(spec) + 1;
+         _mesa_problem(NULL, "%s should be mapped to %d, not %d",
+                       name, func_array[i].dispatch_offset, offset);
+      }
+   }
+}
+
+
+/**
+ * Map the functions which are already static.
+ *
+ * When a extension function are incorporated into the ABI, the
+ * extension suffix is usually stripped.  Mapping such functions
+ * makes sure the alternative names are available.
+ *
+ * Note that functions mapped by _mesa_init_remap_table() are
+ * excluded.
+ */
+void
+_mesa_map_static_functions(void)
+{
+   /* Remap static functions which have alternative names and are in the ABI.
+    * This is to be on the safe side.  glapi should have defined those names.
+    */
+   _mesa_map_function_array(MESA_alt_functions);
+}
+
+
+/**
+ * Initialize the remap table.  This is called in one_time_init().
+ * The remap table needs to be initialized before calling the
+ * CALL/GET/SET macros defined in glapi/dispatch.h.
+ */
+void
+_mesa_init_remap_table(void)
+{
+   static GLboolean initialized = GL_FALSE;
+   GLint i;
+
+   if (initialized)
+      return;
+   initialized = GL_TRUE;
+
+   /* initialize the remap table */
+   for (i = 0; i < ARRAY_SIZE(driDispatchRemapTable); i++) {
+      GLint offset;
+      const char *spec;
+
+      /* sanity check */
+      ASSERT(i == MESA_remap_table_functions[i].remap_index);
+      spec = _mesa_function_pool + MESA_remap_table_functions[i].pool_index;
+
+      offset = _mesa_map_function_spec(spec);
+      /* store the dispatch offset in the remap table */
+      driDispatchRemapTable[i] = offset;
+      if (offset < 0)
+         _mesa_warning(NULL, "failed to remap index %d", i);
+   }
+}
+
+
+#endif /* FEATURE_remap_table */
diff --git a/src/mesa/main/remap.h b/src/mesa/main/remap.h
new file mode 100644 (file)
index 0000000..7fb56e3
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Mesa 3-D graphics library
+ * Version:  7.7
+ *
+ * Copyright (C) 2009 Chia-I Wu <olv@0xlab.org>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION 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 REMAP_H
+#define REMAP_H
+
+
+#include "main/mtypes.h"
+
+struct gl_function_remap;
+
+
+#if FEATURE_remap_table
+
+extern int
+driDispatchRemapTable[];
+
+extern const char *
+_mesa_get_function_spec(GLint func_index);
+
+extern GLint
+_mesa_map_function_spec(const char *spec);
+
+extern void
+_mesa_map_function_array(const struct gl_function_remap *func_array);
+
+extern void
+_mesa_map_static_functions(void);
+
+extern void
+_mesa_init_remap_table(void);
+
+#else /* FEATURE_remap_table */
+
+static INLINE const char *
+_mesa_get_function_spec(GLint func_index)
+{
+   return NULL;
+}
+
+static INLINE GLint
+_mesa_map_function_spec(const char *spec)
+{
+   return -1;
+}
+
+static INLINE void
+_mesa_map_function_array(const struct gl_function_remap *func_array)
+{
+}
+
+static INLINE void
+_mesa_map_static_functions(void)
+{
+}
+
+static INLINE void
+_mesa_init_remap_table(void)
+{
+}
+
+#endif /* FEATURE_remap_table */
+
+
+#endif /* REMAP_H */
diff --git a/src/mesa/main/remap_helper.h b/src/mesa/main/remap_helper.h
new file mode 100644 (file)
index 0000000..fe2bebd
--- /dev/null
@@ -0,0 +1,5945 @@
+/* DO NOT EDIT - This file generated automatically by remap_helper.py (from Mesa) script */
+
+/*
+ * Copyright (C) 2009 Chia-I Wu <olv@0xlab.org>
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and 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
+ * Chia-I Wu,
+ * 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 "glapi/dispatch.h"
+
+struct gl_function_remap {
+   GLint func_index;
+   GLint dispatch_offset; /* for sanity check */
+};
+
+/* this is internal to remap.c */
+#ifdef need_MESA_remap_table
+
+static const char _mesa_function_pool[] =
+   /* _mesa_function_pool[0]: MapGrid1d (offset 224) */
+   "idd\0"
+   "glMapGrid1d\0"
+   "\0"
+   /* _mesa_function_pool[17]: UniformMatrix3fvARB (will be remapped) */
+   "iiip\0"
+   "glUniformMatrix3fv\0"
+   "glUniformMatrix3fvARB\0"
+   "\0"
+   /* _mesa_function_pool[64]: MapGrid1f (offset 225) */
+   "iff\0"
+   "glMapGrid1f\0"
+   "\0"
+   /* _mesa_function_pool[81]: RasterPos4i (offset 82) */
+   "iiii\0"
+   "glRasterPos4i\0"
+   "\0"
+   /* _mesa_function_pool[101]: RasterPos4d (offset 78) */
+   "dddd\0"
+   "glRasterPos4d\0"
+   "\0"
+   /* _mesa_function_pool[121]: NewList (dynamic) */
+   "ii\0"
+   "glNewList\0"
+   "\0"
+   /* _mesa_function_pool[135]: RasterPos4f (offset 80) */
+   "ffff\0"
+   "glRasterPos4f\0"
+   "\0"
+   /* _mesa_function_pool[155]: LoadIdentity (offset 290) */
+   "\0"
+   "glLoadIdentity\0"
+   "\0"
+   /* _mesa_function_pool[172]: SampleCoverageARB (will be remapped) */
+   "fi\0"
+   "glSampleCoverage\0"
+   "glSampleCoverageARB\0"
+   "\0"
+   /* _mesa_function_pool[213]: ConvolutionFilter1D (offset 348) */
+   "iiiiip\0"
+   "glConvolutionFilter1D\0"
+   "glConvolutionFilter1DEXT\0"
+   "\0"
+   /* _mesa_function_pool[268]: BeginQueryARB (will be remapped) */
+   "ii\0"
+   "glBeginQuery\0"
+   "glBeginQueryARB\0"
+   "\0"
+   /* _mesa_function_pool[301]: RasterPos3dv (offset 71) */
+   "p\0"
+   "glRasterPos3dv\0"
+   "\0"
+   /* _mesa_function_pool[319]: PointParameteriNV (will be remapped) */
+   "ii\0"
+   "glPointParameteri\0"
+   "glPointParameteriNV\0"
+   "\0"
+   /* _mesa_function_pool[361]: GetProgramiv (will be remapped) */
+   "iip\0"
+   "glGetProgramiv\0"
+   "\0"
+   /* _mesa_function_pool[381]: MultiTexCoord3sARB (offset 398) */
+   "iiii\0"
+   "glMultiTexCoord3s\0"
+   "glMultiTexCoord3sARB\0"
+   "\0"
+   /* _mesa_function_pool[426]: SecondaryColor3iEXT (will be remapped) */
+   "iii\0"
+   "glSecondaryColor3i\0"
+   "glSecondaryColor3iEXT\0"
+   "\0"
+   /* _mesa_function_pool[472]: WindowPos3fMESA (will be remapped) */
+   "fff\0"
+   "glWindowPos3f\0"
+   "glWindowPos3fARB\0"
+   "glWindowPos3fMESA\0"
+   "\0"
+   /* _mesa_function_pool[526]: TexCoord1iv (offset 99) */
+   "p\0"
+   "glTexCoord1iv\0"
+   "\0"
+   /* _mesa_function_pool[543]: TexCoord4sv (offset 125) */
+   "p\0"
+   "glTexCoord4sv\0"
+   "\0"
+   /* _mesa_function_pool[560]: RasterPos4s (offset 84) */
+   "iiii\0"
+   "glRasterPos4s\0"
+   "\0"
+   /* _mesa_function_pool[580]: PixelTexGenParameterfvSGIS (will be remapped) */
+   "ip\0"
+   "glPixelTexGenParameterfvSGIS\0"
+   "\0"
+   /* _mesa_function_pool[613]: ActiveTextureARB (offset 374) */
+   "i\0"
+   "glActiveTexture\0"
+   "glActiveTextureARB\0"
+   "\0"
+   /* _mesa_function_pool[651]: BlitFramebufferEXT (will be remapped) */
+   "iiiiiiiiii\0"
+   "glBlitFramebuffer\0"
+   "glBlitFramebufferEXT\0"
+   "\0"
+   /* _mesa_function_pool[702]: TexCoord1f (offset 96) */
+   "f\0"
+   "glTexCoord1f\0"
+   "\0"
+   /* _mesa_function_pool[718]: TexCoord1d (offset 94) */
+   "d\0"
+   "glTexCoord1d\0"
+   "\0"
+   /* _mesa_function_pool[734]: VertexAttrib4ubvNV (will be remapped) */
+   "ip\0"
+   "glVertexAttrib4ubvNV\0"
+   "\0"
+   /* _mesa_function_pool[759]: TexCoord1i (offset 98) */
+   "i\0"
+   "glTexCoord1i\0"
+   "\0"
+   /* _mesa_function_pool[775]: GetProgramNamedParameterdvNV (will be remapped) */
+   "iipp\0"
+   "glGetProgramNamedParameterdvNV\0"
+   "\0"
+   /* _mesa_function_pool[812]: Histogram (offset 367) */
+   "iiii\0"
+   "glHistogram\0"
+   "glHistogramEXT\0"
+   "\0"
+   /* _mesa_function_pool[845]: TexCoord1s (offset 100) */
+   "i\0"
+   "glTexCoord1s\0"
+   "\0"
+   /* _mesa_function_pool[861]: GetMapfv (offset 267) */
+   "iip\0"
+   "glGetMapfv\0"
+   "\0"
+   /* _mesa_function_pool[877]: EvalCoord1f (offset 230) */
+   "f\0"
+   "glEvalCoord1f\0"
+   "\0"
+   /* _mesa_function_pool[894]: TexImage4DSGIS (dynamic) */
+   "iiiiiiiiiip\0"
+   "glTexImage4DSGIS\0"
+   "\0"
+   /* _mesa_function_pool[924]: PolygonStipple (offset 175) */
+   "p\0"
+   "glPolygonStipple\0"
+   "\0"
+   /* _mesa_function_pool[944]: WindowPos2dvMESA (will be remapped) */
+   "p\0"
+   "glWindowPos2dv\0"
+   "glWindowPos2dvARB\0"
+   "glWindowPos2dvMESA\0"
+   "\0"
+   /* _mesa_function_pool[999]: ReplacementCodeuiColor3fVertex3fvSUN (dynamic) */
+   "ppp\0"
+   "glReplacementCodeuiColor3fVertex3fvSUN\0"
+   "\0"
+   /* _mesa_function_pool[1043]: BlendEquationSeparateEXT (will be remapped) */
+   "ii\0"
+   "glBlendEquationSeparate\0"
+   "glBlendEquationSeparateEXT\0"
+   "glBlendEquationSeparateATI\0"
+   "\0"
+   /* _mesa_function_pool[1125]: ListParameterfSGIX (dynamic) */
+   "iif\0"
+   "glListParameterfSGIX\0"
+   "\0"
+   /* _mesa_function_pool[1151]: SecondaryColor3bEXT (will be remapped) */
+   "iii\0"
+   "glSecondaryColor3b\0"
+   "glSecondaryColor3bEXT\0"
+   "\0"
+   /* _mesa_function_pool[1197]: TexCoord4fColor4fNormal3fVertex4fvSUN (dynamic) */
+   "pppp\0"
+   "glTexCoord4fColor4fNormal3fVertex4fvSUN\0"
+   "\0"
+   /* _mesa_function_pool[1243]: GetPixelMapfv (offset 271) */
+   "ip\0"
+   "glGetPixelMapfv\0"
+   "\0"
+   /* _mesa_function_pool[1263]: Color3uiv (offset 22) */
+   "p\0"
+   "glColor3uiv\0"
+   "\0"
+   /* _mesa_function_pool[1278]: IsEnabled (offset 286) */
+   "i\0"
+   "glIsEnabled\0"
+   "\0"
+   /* _mesa_function_pool[1293]: VertexAttrib4svNV (will be remapped) */
+   "ip\0"
+   "glVertexAttrib4svNV\0"
+   "\0"
+   /* _mesa_function_pool[1317]: EvalCoord2fv (offset 235) */
+   "p\0"
+   "glEvalCoord2fv\0"
+   "\0"
+   /* _mesa_function_pool[1335]: GetBufferSubDataARB (will be remapped) */
+   "iiip\0"
+   "glGetBufferSubData\0"
+   "glGetBufferSubDataARB\0"
+   "\0"
+   /* _mesa_function_pool[1382]: BufferSubDataARB (will be remapped) */
+   "iiip\0"
+   "glBufferSubData\0"
+   "glBufferSubDataARB\0"
+   "\0"
+   /* _mesa_function_pool[1423]: TexCoord2fColor4ubVertex3fvSUN (dynamic) */
+   "ppp\0"
+   "glTexCoord2fColor4ubVertex3fvSUN\0"
+   "\0"
+   /* _mesa_function_pool[1461]: AttachShader (will be remapped) */
+   "ii\0"
+   "glAttachShader\0"
+   "\0"
+   /* _mesa_function_pool[1480]: VertexAttrib2fARB (will be remapped) */
+   "iff\0"
+   "glVertexAttrib2f\0"
+   "glVertexAttrib2fARB\0"
+   "\0"
+   /* _mesa_function_pool[1522]: GetDebugLogLengthMESA (dynamic) */
+   "iii\0"
+   "glGetDebugLogLengthMESA\0"
+   "\0"
+   /* _mesa_function_pool[1551]: GetMapiv (offset 268) */
+   "iip\0"
+   "glGetMapiv\0"
+   "\0"
+   /* _mesa_function_pool[1567]: VertexAttrib3fARB (will be remapped) */
+   "ifff\0"
+   "glVertexAttrib3f\0"
+   "glVertexAttrib3fARB\0"
+   "\0"
+   /* _mesa_function_pool[1610]: Indexubv (offset 316) */
+   "p\0"
+   "glIndexubv\0"
+   "\0"
+   /* _mesa_function_pool[1624]: GetQueryivARB (will be remapped) */
+   "iip\0"
+   "glGetQueryiv\0"
+   "glGetQueryivARB\0"
+   "\0"
+   /* _mesa_function_pool[1658]: TexImage3D (offset 371) */
+   "iiiiiiiiip\0"
+   "glTexImage3D\0"
+   "glTexImage3DEXT\0"
+   "\0"
+   /* _mesa_function_pool[1699]: ReplacementCodeuiVertex3fvSUN (dynamic) */
+   "pp\0"
+   "glReplacementCodeuiVertex3fvSUN\0"
+   "\0"
+   /* _mesa_function_pool[1735]: EdgeFlagPointer (offset 312) */
+   "ip\0"
+   "glEdgeFlagPointer\0"
+   "\0"
+   /* _mesa_function_pool[1757]: Color3ubv (offset 20) */
+   "p\0"
+   "glColor3ubv\0"
+   "\0"
+   /* _mesa_function_pool[1772]: GetQueryObjectivARB (will be remapped) */
+   "iip\0"
+   "glGetQueryObjectiv\0"
+   "glGetQueryObjectivARB\0"
+   "\0"
+   /* _mesa_function_pool[1818]: Vertex3dv (offset 135) */
+   "p\0"
+   "glVertex3dv\0"
+   "\0"
+   /* _mesa_function_pool[1833]: ReplacementCodeuiTexCoord2fVertex3fvSUN (dynamic) */
+   "ppp\0"
+   "glReplacementCodeuiTexCoord2fVertex3fvSUN\0"
+   "\0"
+   /* _mesa_function_pool[1880]: CompressedTexSubImage2DARB (will be remapped) */
+   "iiiiiiiip\0"
+   "glCompressedTexSubImage2D\0"
+   "glCompressedTexSubImage2DARB\0"
+   "\0"
+   /* _mesa_function_pool[1946]: CombinerOutputNV (will be remapped) */
+   "iiiiiiiiii\0"
+   "glCombinerOutputNV\0"
+   "\0"
+   /* _mesa_function_pool[1977]: VertexAttribs3fvNV (will be remapped) */
+   "iip\0"
+   "glVertexAttribs3fvNV\0"
+   "\0"
+   /* _mesa_function_pool[2003]: Uniform2fARB (will be remapped) */
+   "iff\0"
+   "glUniform2f\0"
+   "glUniform2fARB\0"
+   "\0"
+   /* _mesa_function_pool[2035]: LightModeliv (offset 166) */
+   "ip\0"
+   "glLightModeliv\0"
+   "\0"
+   /* _mesa_function_pool[2054]: VertexAttrib1svARB (will be remapped) */
+   "ip\0"
+   "glVertexAttrib1sv\0"
+   "glVertexAttrib1svARB\0"
+   "\0"
+   /* _mesa_function_pool[2097]: VertexAttribs1dvNV (will be remapped) */
+   "iip\0"
+   "glVertexAttribs1dvNV\0"
+   "\0"
+   /* _mesa_function_pool[2123]: Uniform2ivARB (will be remapped) */
+   "iip\0"
+   "glUniform2iv\0"
+   "glUniform2ivARB\0"
+   "\0"
+   /* _mesa_function_pool[2157]: GetImageTransformParameterfvHP (dynamic) */
+   "iip\0"
+   "glGetImageTransformParameterfvHP\0"
+   "\0"
+   /* _mesa_function_pool[2195]: Normal3bv (offset 53) */
+   "p\0"
+   "glNormal3bv\0"
+   "\0"
+   /* _mesa_function_pool[2210]: TexGeniv (offset 193) */
+   "iip\0"
+   "glTexGeniv\0"
+   "\0"
+   /* _mesa_function_pool[2226]: WeightubvARB (dynamic) */
+   "ip\0"
+   "glWeightubvARB\0"
+   "\0"
+   /* _mesa_function_pool[2245]: VertexAttrib1fvNV (will be remapped) */
+   "ip\0"
+   "glVertexAttrib1fvNV\0"
+   "\0"
+   /* _mesa_function_pool[2269]: Vertex3iv (offset 139) */
+   "p\0"
+   "glVertex3iv\0"
+   "\0"
+   /* _mesa_function_pool[2284]: CopyConvolutionFilter1D (offset 354) */
+   "iiiii\0"
+   "glCopyConvolutionFilter1D\0"
+   "glCopyConvolutionFilter1DEXT\0"
+   "\0"
+   /* _mesa_function_pool[2346]: ReplacementCodeuiNormal3fVertex3fSUN (dynamic) */
+   "iffffff\0"
+   "glReplacementCodeuiNormal3fVertex3fSUN\0"
+   "\0"
+   /* _mesa_function_pool[2394]: DeleteSync (will be remapped) */
+   "i\0"
+   "glDeleteSync\0"
+   "\0"
+   /* _mesa_function_pool[2410]: FragmentMaterialfvSGIX (dynamic) */
+   "iip\0"
+   "glFragmentMaterialfvSGIX\0"
+   "\0"
+   /* _mesa_function_pool[2440]: BlendColor (offset 336) */
+   "ffff\0"
+   "glBlendColor\0"
+   "glBlendColorEXT\0"
+   "\0"
+   /* _mesa_function_pool[2475]: UniformMatrix4fvARB (will be remapped) */
+   "iiip\0"
+   "glUniformMatrix4fv\0"
+   "glUniformMatrix4fvARB\0"
+   "\0"
+   /* _mesa_function_pool[2522]: DeleteVertexArraysAPPLE (will be remapped) */
+   "ip\0"
+   "glDeleteVertexArrays\0"
+   "glDeleteVertexArraysAPPLE\0"
+   "\0"
+   /* _mesa_function_pool[2573]: ReadInstrumentsSGIX (dynamic) */
+   "i\0"
+   "glReadInstrumentsSGIX\0"
+   "\0"
+   /* _mesa_function_pool[2598]: CallLists (offset 3) */
+   "iip\0"
+   "glCallLists\0"
+   "\0"
+   /* _mesa_function_pool[2615]: UniformMatrix2x4fv (will be remapped) */
+   "iiip\0"
+   "glUniformMatrix2x4fv\0"
+   "\0"
+   /* _mesa_function_pool[2642]: Color4ubVertex3fvSUN (dynamic) */
+   "pp\0"
+   "glColor4ubVertex3fvSUN\0"
+   "\0"
+   /* _mesa_function_pool[2669]: Normal3iv (offset 59) */
+   "p\0"
+   "glNormal3iv\0"
+   "\0"
+   /* _mesa_function_pool[2684]: PassThrough (offset 199) */
+   "f\0"
+   "glPassThrough\0"
+   "\0"
+   /* _mesa_function_pool[2701]: FramebufferTextureLayerEXT (will be remapped) */
+   "iiiii\0"
+   "glFramebufferTextureLayer\0"
+   "glFramebufferTextureLayerEXT\0"
+   "\0"
+   /* _mesa_function_pool[2763]: GetListParameterfvSGIX (dynamic) */
+   "iip\0"
+   "glGetListParameterfvSGIX\0"
+   "\0"
+   /* _mesa_function_pool[2793]: Viewport (offset 305) */
+   "iiii\0"
+   "glViewport\0"
+   "\0"
+   /* _mesa_function_pool[2810]: VertexAttrib4NusvARB (will be remapped) */
+   "ip\0"
+   "glVertexAttrib4Nusv\0"
+   "glVertexAttrib4NusvARB\0"
+   "\0"
+   /* _mesa_function_pool[2857]: WindowPos4svMESA (will be remapped) */
+   "p\0"
+   "glWindowPos4svMESA\0"
+   "\0"
+   /* _mesa_function_pool[2879]: CreateProgramObjectARB (will be remapped) */
+   "\0"
+   "glCreateProgramObjectARB\0"
+   "\0"
+   /* _mesa_function_pool[2906]: FragmentLightModelivSGIX (dynamic) */
+   "ip\0"
+   "glFragmentLightModelivSGIX\0"
+   "\0"
+   /* _mesa_function_pool[2937]: UniformMatrix4x3fv (will be remapped) */
+   "iiip\0"
+   "glUniformMatrix4x3fv\0"
+   "\0"
+   /* _mesa_function_pool[2964]: PrioritizeTextures (offset 331) */
+   "ipp\0"
+   "glPrioritizeTextures\0"
+   "glPrioritizeTexturesEXT\0"
+   "\0"
+   /* _mesa_function_pool[3014]: AsyncMarkerSGIX (dynamic) */
+   "i\0"
+   "glAsyncMarkerSGIX\0"
+   "\0"
+   /* _mesa_function_pool[3035]: GlobalAlphaFactorubSUN (dynamic) */
+   "i\0"
+   "glGlobalAlphaFactorubSUN\0"
+   "\0"
+   /* _mesa_function_pool[3063]: ClearDebugLogMESA (dynamic) */
+   "iii\0"
+   "glClearDebugLogMESA\0"
+   "\0"
+   /* _mesa_function_pool[3088]: ResetHistogram (offset 369) */
+   "i\0"
+   "glResetHistogram\0"
+   "glResetHistogramEXT\0"
+   "\0"
+   /* _mesa_function_pool[3128]: GetProgramNamedParameterfvNV (will be remapped) */
+   "iipp\0"
+   "glGetProgramNamedParameterfvNV\0"
+   "\0"
+   /* _mesa_function_pool[3165]: PointParameterfEXT (will be remapped) */
+   "if\0"
+   "glPointParameterf\0"
+   "glPointParameterfARB\0"
+   "glPointParameterfEXT\0"
+   "glPointParameterfSGIS\0"
+   "\0"
+   /* _mesa_function_pool[3251]: LoadIdentityDeformationMapSGIX (dynamic) */
+   "i\0"
+   "glLoadIdentityDeformationMapSGIX\0"
+   "\0"
+   /* _mesa_function_pool[3287]: GenFencesNV (will be remapped) */
+   "ip\0"
+   "glGenFencesNV\0"
+   "\0"
+   /* _mesa_function_pool[3305]: ImageTransformParameterfHP (dynamic) */
+   "iif\0"
+   "glImageTransformParameterfHP\0"
+   "\0"
+   /* _mesa_function_pool[3339]: MatrixIndexusvARB (dynamic) */
+   "ip\0"
+   "glMatrixIndexusvARB\0"
+   "\0"
+   /* _mesa_function_pool[3363]: DrawElementsBaseVertex (will be remapped) */
+   "iiipi\0"
+   "glDrawElementsBaseVertex\0"
+   "\0"
+   /* _mesa_function_pool[3395]: DisableVertexAttribArrayARB (will be remapped) */
+   "i\0"
+   "glDisableVertexAttribArray\0"
+   "glDisableVertexAttribArrayARB\0"
+   "\0"
+   /* _mesa_function_pool[3455]: TexCoord2sv (offset 109) */
+   "p\0"
+   "glTexCoord2sv\0"
+   "\0"
+   /* _mesa_function_pool[3472]: Vertex4dv (offset 143) */
+   "p\0"
+   "glVertex4dv\0"
+   "\0"
+   /* _mesa_function_pool[3487]: StencilMaskSeparate (will be remapped) */
+   "ii\0"
+   "glStencilMaskSeparate\0"
+   "\0"
+   /* _mesa_function_pool[3513]: ProgramLocalParameter4dARB (will be remapped) */
+   "iidddd\0"
+   "glProgramLocalParameter4dARB\0"
+   "\0"
+   /* _mesa_function_pool[3550]: CompressedTexImage3DARB (will be remapped) */
+   "iiiiiiiip\0"
+   "glCompressedTexImage3D\0"
+   "glCompressedTexImage3DARB\0"
+   "\0"
+   /* _mesa_function_pool[3610]: Color3sv (offset 18) */
+   "p\0"
+   "glColor3sv\0"
+   "\0"
+   /* _mesa_function_pool[3624]: GetConvolutionParameteriv (offset 358) */
+   "iip\0"
+   "glGetConvolutionParameteriv\0"
+   "glGetConvolutionParameterivEXT\0"
+   "\0"
+   /* _mesa_function_pool[3688]: VertexAttrib1fARB (will be remapped) */
+   "if\0"
+   "glVertexAttrib1f\0"
+   "glVertexAttrib1fARB\0"
+   "\0"
+   /* _mesa_function_pool[3729]: Vertex2dv (offset 127) */
+   "p\0"
+   "glVertex2dv\0"
+   "\0"
+   /* _mesa_function_pool[3744]: TestFenceNV (will be remapped) */
+   "i\0"
+   "glTestFenceNV\0"
+   "\0"
+   /* _mesa_function_pool[3761]: MultiTexCoord1fvARB (offset 379) */
+   "ip\0"
+   "glMultiTexCoord1fv\0"
+   "glMultiTexCoord1fvARB\0"
+   "\0"
+   /* _mesa_function_pool[3806]: TexCoord3iv (offset 115) */
+   "p\0"
+   "glTexCoord3iv\0"
+   "\0"
+   /* _mesa_function_pool[3823]: ColorFragmentOp2ATI (will be remapped) */
+   "iiiiiiiiii\0"
+   "glColorFragmentOp2ATI\0"
+   "\0"
+   /* _mesa_function_pool[3857]: SecondaryColorPointerListIBM (dynamic) */
+   "iiipi\0"
+   "glSecondaryColorPointerListIBM\0"
+   "\0"
+   /* _mesa_function_pool[3895]: GetPixelTexGenParameterivSGIS (will be remapped) */
+   "ip\0"
+   "glGetPixelTexGenParameterivSGIS\0"
+   "\0"
+   /* _mesa_function_pool[3931]: Color3fv (offset 14) */
+   "p\0"
+   "glColor3fv\0"
+   "\0"
+   /* _mesa_function_pool[3945]: VertexAttrib4fNV (will be remapped) */
+   "iffff\0"
+   "glVertexAttrib4fNV\0"
+   "\0"
+   /* _mesa_function_pool[3971]: ReplacementCodeubSUN (dynamic) */
+   "i\0"
+   "glReplacementCodeubSUN\0"
+   "\0"
+   /* _mesa_function_pool[3997]: FinishAsyncSGIX (dynamic) */
+   "p\0"
+   "glFinishAsyncSGIX\0"
+   "\0"
+   /* _mesa_function_pool[4018]: GetDebugLogMESA (dynamic) */
+   "iiiipp\0"
+   "glGetDebugLogMESA\0"
+   "\0"
+   /* _mesa_function_pool[4044]: FogCoorddEXT (will be remapped) */
+   "d\0"
+   "glFogCoordd\0"
+   "glFogCoorddEXT\0"
+   "\0"
+   /* _mesa_function_pool[4074]: BeginConditionalRenderNV (will be remapped) */
+   "ii\0"
+   "glBeginConditionalRenderNV\0"
+   "\0"
+   /* _mesa_function_pool[4105]: Color4ubVertex3fSUN (dynamic) */
+   "iiiifff\0"
+   "glColor4ubVertex3fSUN\0"
+   "\0"
+   /* _mesa_function_pool[4136]: FogCoordfEXT (will be remapped) */
+   "f\0"
+   "glFogCoordf\0"
+   "glFogCoordfEXT\0"
+   "\0"
+   /* _mesa_function_pool[4166]: PointSize (offset 173) */
+   "f\0"
+   "glPointSize\0"
+   "\0"
+   /* _mesa_function_pool[4181]: TexCoord2fVertex3fSUN (dynamic) */
+   "fffff\0"
+   "glTexCoord2fVertex3fSUN\0"
+   "\0"
+   /* _mesa_function_pool[4212]: PopName (offset 200) */
+   "\0"
+   "glPopName\0"
+   "\0"
+   /* _mesa_function_pool[4224]: GlobalAlphaFactoriSUN (dynamic) */
+   "i\0"
+   "glGlobalAlphaFactoriSUN\0"
+   "\0"
+   /* _mesa_function_pool[4251]: VertexAttrib2dNV (will be remapped) */
+   "idd\0"
+   "glVertexAttrib2dNV\0"
+   "\0"
+   /* _mesa_function_pool[4275]: GetProgramInfoLog (will be remapped) */
+   "iipp\0"
+   "glGetProgramInfoLog\0"
+   "\0"
+   /* _mesa_function_pool[4301]: VertexAttrib4NbvARB (will be remapped) */
+   "ip\0"
+   "glVertexAttrib4Nbv\0"
+   "glVertexAttrib4NbvARB\0"
+   "\0"
+   /* _mesa_function_pool[4346]: GetActiveAttribARB (will be remapped) */
+   "iiipppp\0"
+   "glGetActiveAttrib\0"
+   "glGetActiveAttribARB\0"
+   "\0"
+   /* _mesa_function_pool[4394]: Vertex4sv (offset 149) */
+   "p\0"
+   "glVertex4sv\0"
+   "\0"
+   /* _mesa_function_pool[4409]: VertexAttrib4ubNV (will be remapped) */
+   "iiiii\0"
+   "glVertexAttrib4ubNV\0"
+   "\0"
+   /* _mesa_function_pool[4436]: TextureRangeAPPLE (will be remapped) */
+   "iip\0"
+   "glTextureRangeAPPLE\0"
+   "\0"
+   /* _mesa_function_pool[4461]: GetTexEnvfv (offset 276) */
+   "iip\0"
+   "glGetTexEnvfv\0"
+   "\0"
+   /* _mesa_function_pool[4480]: TexCoord2fColor4fNormal3fVertex3fSUN (dynamic) */
+   "ffffffffffff\0"
+   "glTexCoord2fColor4fNormal3fVertex3fSUN\0"
+   "\0"
+   /* _mesa_function_pool[4533]: Indexub (offset 315) */
+   "i\0"
+   "glIndexub\0"
+   "\0"
+   /* _mesa_function_pool[4546]: TexEnvi (offset 186) */
+   "iii\0"
+   "glTexEnvi\0"
+   "\0"
+   /* _mesa_function_pool[4561]: GetClipPlane (offset 259) */
+   "ip\0"
+   "glGetClipPlane\0"
+   "\0"
+   /* _mesa_function_pool[4580]: CombinerParameterfvNV (will be remapped) */
+   "ip\0"
+   "glCombinerParameterfvNV\0"
+   "\0"
+   /* _mesa_function_pool[4608]: VertexAttribs3dvNV (will be remapped) */
+   "iip\0"
+   "glVertexAttribs3dvNV\0"
+   "\0"
+   /* _mesa_function_pool[4634]: VertexAttribs4fvNV (will be remapped) */
+   "iip\0"
+   "glVertexAttribs4fvNV\0"
+   "\0"
+   /* _mesa_function_pool[4660]: VertexArrayRangeNV (will be remapped) */
+   "ip\0"
+   "glVertexArrayRangeNV\0"
+   "\0"
+   /* _mesa_function_pool[4685]: FragmentLightiSGIX (dynamic) */
+   "iii\0"
+   "glFragmentLightiSGIX\0"
+   "\0"
+   /* _mesa_function_pool[4711]: PolygonOffsetEXT (will be remapped) */
+   "ff\0"
+   "glPolygonOffsetEXT\0"
+   "\0"
+   /* _mesa_function_pool[4734]: PollAsyncSGIX (dynamic) */
+   "p\0"
+   "glPollAsyncSGIX\0"
+   "\0"
+   /* _mesa_function_pool[4753]: DeleteFragmentShaderATI (will be remapped) */
+   "i\0"
+   "glDeleteFragmentShaderATI\0"
+   "\0"
+   /* _mesa_function_pool[4782]: Scaled (offset 301) */
+   "ddd\0"
+   "glScaled\0"
+   "\0"
+   /* _mesa_function_pool[4796]: Scalef (offset 302) */
+   "fff\0"
+   "glScalef\0"
+   "\0"
+   /* _mesa_function_pool[4810]: TexCoord2fNormal3fVertex3fvSUN (dynamic) */
+   "ppp\0"
+   "glTexCoord2fNormal3fVertex3fvSUN\0"
+   "\0"
+   /* _mesa_function_pool[4848]: MultTransposeMatrixdARB (will be remapped) */
+   "p\0"
+   "glMultTransposeMatrixd\0"
+   "glMultTransposeMatrixdARB\0"
+   "\0"
+   /* _mesa_function_pool[4900]: AlphaFunc (offset 240) */
+   "if\0"
+   "glAlphaFunc\0"
+   "\0"
+   /* _mesa_function_pool[4916]: WindowPos2svMESA (will be remapped) */
+   "p\0"
+   "glWindowPos2sv\0"
+   "glWindowPos2svARB\0"
+   "glWindowPos2svMESA\0"
+   "\0"
+   /* _mesa_function_pool[4971]: EdgeFlag (offset 41) */
+   "i\0"
+   "glEdgeFlag\0"
+   "\0"
+   /* _mesa_function_pool[4985]: TexCoord2iv (offset 107) */
+   "p\0"
+   "glTexCoord2iv\0"
+   "\0"
+   /* _mesa_function_pool[5002]: CompressedTexImage1DARB (will be remapped) */
+   "iiiiiip\0"
+   "glCompressedTexImage1D\0"
+   "glCompressedTexImage1DARB\0"
+   "\0"
+   /* _mesa_function_pool[5060]: Rotated (offset 299) */
+   "dddd\0"
+   "glRotated\0"
+   "\0"
+   /* _mesa_function_pool[5076]: VertexAttrib2sNV (will be remapped) */
+   "iii\0"
+   "glVertexAttrib2sNV\0"
+   "\0"
+   /* _mesa_function_pool[5100]: ReadPixels (offset 256) */
+   "iiiiiip\0"
+   "glReadPixels\0"
+   "\0"
+   /* _mesa_function_pool[5122]: EdgeFlagv (offset 42) */
+   "p\0"
+   "glEdgeFlagv\0"
+   "\0"
+   /* _mesa_function_pool[5137]: NormalPointerListIBM (dynamic) */
+   "iipi\0"
+   "glNormalPointerListIBM\0"
+   "\0"
+   /* _mesa_function_pool[5166]: IndexPointerEXT (will be remapped) */
+   "iiip\0"
+   "glIndexPointerEXT\0"
+   "\0"
+   /* _mesa_function_pool[5190]: Color4iv (offset 32) */
+   "p\0"
+   "glColor4iv\0"
+   "\0"
+   /* _mesa_function_pool[5204]: TexParameterf (offset 178) */
+   "iif\0"
+   "glTexParameterf\0"
+   "\0"
+   /* _mesa_function_pool[5225]: TexParameteri (offset 180) */
+   "iii\0"
+   "glTexParameteri\0"
+   "\0"
+   /* _mesa_function_pool[5246]: NormalPointerEXT (will be remapped) */
+   "iiip\0"
+   "glNormalPointerEXT\0"
+   "\0"
+   /* _mesa_function_pool[5271]: MultiTexCoord3dARB (offset 392) */
+   "iddd\0"
+   "glMultiTexCoord3d\0"
+   "glMultiTexCoord3dARB\0"
+   "\0"
+   /* _mesa_function_pool[5316]: MultiTexCoord2iARB (offset 388) */
+   "iii\0"
+   "glMultiTexCoord2i\0"
+   "glMultiTexCoord2iARB\0"
+   "\0"
+   /* _mesa_function_pool[5360]: DrawPixels (offset 257) */
+   "iiiip\0"
+   "glDrawPixels\0"
+   "\0"
+   /* _mesa_function_pool[5380]: ReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (dynamic) */
+   "iffffffff\0"
+   "glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN\0"
+   "\0"
+   /* _mesa_function_pool[5440]: MultiTexCoord2svARB (offset 391) */
+   "ip\0"
+   "glMultiTexCoord2sv\0"
+   "glMultiTexCoord2svARB\0"
+   "\0"
+   /* _mesa_function_pool[5485]: ReplacementCodeubvSUN (dynamic) */
+   "p\0"
+   "glReplacementCodeubvSUN\0"
+   "\0"
+   /* _mesa_function_pool[5512]: Uniform3iARB (will be remapped) */
+   "iiii\0"
+   "glUniform3i\0"
+   "glUniform3iARB\0"
+   "\0"
+   /* _mesa_function_pool[5545]: GetFragmentMaterialfvSGIX (dynamic) */
+   "iip\0"
+   "glGetFragmentMaterialfvSGIX\0"
+   "\0"
+   /* _mesa_function_pool[5578]: GetShaderInfoLog (will be remapped) */
+   "iipp\0"
+   "glGetShaderInfoLog\0"
+   "\0"
+   /* _mesa_function_pool[5603]: WeightivARB (dynamic) */
+   "ip\0"
+   "glWeightivARB\0"
+   "\0"
+   /* _mesa_function_pool[5621]: PollInstrumentsSGIX (dynamic) */
+   "p\0"
+   "glPollInstrumentsSGIX\0"
+   "\0"
+   /* _mesa_function_pool[5646]: GlobalAlphaFactordSUN (dynamic) */
+   "d\0"
+   "glGlobalAlphaFactordSUN\0"
+   "\0"
+   /* _mesa_function_pool[5673]: GetFinalCombinerInputParameterfvNV (will be remapped) */
+   "iip\0"
+   "glGetFinalCombinerInputParameterfvNV\0"
+   "\0"
+   /* _mesa_function_pool[5715]: GenerateMipmapEXT (will be remapped) */
+   "i\0"
+   "glGenerateMipmap\0"
+   "glGenerateMipmapEXT\0"
+   "\0"
+   /* _mesa_function_pool[5755]: GenLists (offset 5) */
+   "i\0"
+   "glGenLists\0"
+   "\0"
+   /* _mesa_function_pool[5769]: SetFragmentShaderConstantATI (will be remapped) */
+   "ip\0"
+   "glSetFragmentShaderConstantATI\0"
+   "\0"
+   /* _mesa_function_pool[5804]: GetMapAttribParameterivNV (dynamic) */
+   "iiip\0"
+   "glGetMapAttribParameterivNV\0"
+   "\0"
+   /* _mesa_function_pool[5838]: CreateShaderObjectARB (will be remapped) */
+   "i\0"
+   "glCreateShaderObjectARB\0"
+   "\0"
+   /* _mesa_function_pool[5865]: GetSharpenTexFuncSGIS (dynamic) */
+   "ip\0"
+   "glGetSharpenTexFuncSGIS\0"
+   "\0"
+   /* _mesa_function_pool[5893]: BufferDataARB (will be remapped) */
+   "iipi\0"
+   "glBufferData\0"
+   "glBufferDataARB\0"
+   "\0"
+   /* _mesa_function_pool[5928]: FlushVertexArrayRangeNV (will be remapped) */
+   "\0"
+   "glFlushVertexArrayRangeNV\0"
+   "\0"
+   /* _mesa_function_pool[5956]: MapGrid2d (offset 226) */
+   "iddidd\0"
+   "glMapGrid2d\0"
+   "\0"
+   /* _mesa_function_pool[5976]: MapGrid2f (offset 227) */
+   "iffiff\0"
+   "glMapGrid2f\0"
+   "\0"
+   /* _mesa_function_pool[5996]: SampleMapATI (will be remapped) */
+   "iii\0"
+   "glSampleMapATI\0"
+   "\0"
+   /* _mesa_function_pool[6016]: VertexPointerEXT (will be remapped) */
+   "iiiip\0"
+   "glVertexPointerEXT\0"
+   "\0"
+   /* _mesa_function_pool[6042]: GetTexFilterFuncSGIS (dynamic) */
+   "iip\0"
+   "glGetTexFilterFuncSGIS\0"
+   "\0"
+   /* _mesa_function_pool[6070]: Scissor (offset 176) */
+   "iiii\0"
+   "glScissor\0"
+   "\0"
+   /* _mesa_function_pool[6086]: Fogf (offset 153) */
+   "if\0"
+   "glFogf\0"
+   "\0"
+   /* _mesa_function_pool[6097]: GetCombinerOutputParameterfvNV (will be remapped) */
+   "iiip\0"
+   "glGetCombinerOutputParameterfvNV\0"
+   "\0"
+   /* _mesa_function_pool[6136]: TexSubImage1D (offset 332) */
+   "iiiiiip\0"
+   "glTexSubImage1D\0"
+   "glTexSubImage1DEXT\0"
+   "\0"
+   /* _mesa_function_pool[6180]: VertexAttrib1sARB (will be remapped) */
+   "ii\0"
+   "glVertexAttrib1s\0"
+   "glVertexAttrib1sARB\0"
+   "\0"
+   /* _mesa_function_pool[6221]: FenceSync (will be remapped) */
+   "ii\0"
+   "glFenceSync\0"
+   "\0"
+   /* _mesa_function_pool[6237]: Color4usv (offset 40) */
+   "p\0"
+   "glColor4usv\0"
+   "\0"
+   /* _mesa_function_pool[6252]: Fogi (offset 155) */
+   "ii\0"
+   "glFogi\0"
+   "\0"
+   /* _mesa_function_pool[6263]: DepthRange (offset 288) */
+   "dd\0"
+   "glDepthRange\0"
+   "\0"
+   /* _mesa_function_pool[6280]: RasterPos3iv (offset 75) */
+   "p\0"
+   "glRasterPos3iv\0"
+   "\0"
+   /* _mesa_function_pool[6298]: FinalCombinerInputNV (will be remapped) */
+   "iiii\0"
+   "glFinalCombinerInputNV\0"
+   "\0"
+   /* _mesa_function_pool[6327]: TexCoord2i (offset 106) */
+   "ii\0"
+   "glTexCoord2i\0"
+   "\0"
+   /* _mesa_function_pool[6344]: PixelMapfv (offset 251) */
+   "iip\0"
+   "glPixelMapfv\0"
+   "\0"
+   /* _mesa_function_pool[6362]: Color4ui (offset 37) */
+   "iiii\0"
+   "glColor4ui\0"
+   "\0"
+   /* _mesa_function_pool[6379]: RasterPos3s (offset 76) */
+   "iii\0"
+   "glRasterPos3s\0"
+   "\0"
+   /* _mesa_function_pool[6398]: Color3usv (offset 24) */
+   "p\0"
+   "glColor3usv\0"
+   "\0"
+   /* _mesa_function_pool[6413]: FlushRasterSGIX (dynamic) */
+   "\0"
+   "glFlushRasterSGIX\0"
+   "\0"
+   /* _mesa_function_pool[6433]: TexCoord2f (offset 104) */
+   "ff\0"
+   "glTexCoord2f\0"
+   "\0"
+   /* _mesa_function_pool[6450]: ReplacementCodeuiTexCoord2fVertex3fSUN (dynamic) */
+   "ifffff\0"
+   "glReplacementCodeuiTexCoord2fVertex3fSUN\0"
+   "\0"
+   /* _mesa_function_pool[6499]: TexCoord2d (offset 102) */
+   "dd\0"
+   "glTexCoord2d\0"
+   "\0"
+   /* _mesa_function_pool[6516]: RasterPos3d (offset 70) */
+   "ddd\0"
+   "glRasterPos3d\0"
+   "\0"
+   /* _mesa_function_pool[6535]: RasterPos3f (offset 72) */
+   "fff\0"
+   "glRasterPos3f\0"
+   "\0"
+   /* _mesa_function_pool[6554]: Uniform1fARB (will be remapped) */
+   "if\0"
+   "glUniform1f\0"
+   "glUniform1fARB\0"
+   "\0"
+   /* _mesa_function_pool[6585]: AreTexturesResident (offset 322) */
+   "ipp\0"
+   "glAreTexturesResident\0"
+   "glAreTexturesResidentEXT\0"
+   "\0"
+   /* _mesa_function_pool[6637]: TexCoord2s (offset 108) */
+   "ii\0"
+   "glTexCoord2s\0"
+   "\0"
+   /* _mesa_function_pool[6654]: StencilOpSeparate (will be remapped) */
+   "iiii\0"
+   "glStencilOpSeparate\0"
+   "glStencilOpSeparateATI\0"
+   "\0"
+   /* _mesa_function_pool[6703]: ColorTableParameteriv (offset 341) */
+   "iip\0"
+   "glColorTableParameteriv\0"
+   "glColorTableParameterivSGI\0"
+   "\0"
+   /* _mesa_function_pool[6759]: FogCoordPointerListIBM (dynamic) */
+   "iipi\0"
+   "glFogCoordPointerListIBM\0"
+   "\0"
+   /* _mesa_function_pool[6790]: WindowPos3dMESA (will be remapped) */
+   "ddd\0"
+   "glWindowPos3d\0"
+   "glWindowPos3dARB\0"
+   "glWindowPos3dMESA\0"
+   "\0"
+   /* _mesa_function_pool[6844]: Color4us (offset 39) */
+   "iiii\0"
+   "glColor4us\0"
+   "\0"
+   /* _mesa_function_pool[6861]: PointParameterfvEXT (will be remapped) */
+   "ip\0"
+   "glPointParameterfv\0"
+   "glPointParameterfvARB\0"
+   "glPointParameterfvEXT\0"
+   "glPointParameterfvSGIS\0"
+   "\0"
+   /* _mesa_function_pool[6951]: Color3bv (offset 10) */
+   "p\0"
+   "glColor3bv\0"
+   "\0"
+   /* _mesa_function_pool[6965]: WindowPos2fvMESA (will be remapped) */
+   "p\0"
+   "glWindowPos2fv\0"
+   "glWindowPos2fvARB\0"
+   "glWindowPos2fvMESA\0"
+   "\0"
+   /* _mesa_function_pool[7020]: SecondaryColor3bvEXT (will be remapped) */
+   "p\0"
+   "glSecondaryColor3bv\0"
+   "glSecondaryColor3bvEXT\0"
+   "\0"
+   /* _mesa_function_pool[7066]: VertexPointerListIBM (dynamic) */
+   "iiipi\0"
+   "glVertexPointerListIBM\0"
+   "\0"
+   /* _mesa_function_pool[7096]: GetProgramLocalParameterfvARB (will be remapped) */
+   "iip\0"
+   "glGetProgramLocalParameterfvARB\0"
+   "\0"
+   /* _mesa_function_pool[7133]: FragmentMaterialfSGIX (dynamic) */
+   "iif\0"
+   "glFragmentMaterialfSGIX\0"
+   "\0"
+   /* _mesa_function_pool[7162]: TexCoord2fNormal3fVertex3fSUN (dynamic) */
+   "ffffffff\0"
+   "glTexCoord2fNormal3fVertex3fSUN\0"
+   "\0"
+   /* _mesa_function_pool[7204]: RenderbufferStorageEXT (will be remapped) */
+   "iiii\0"
+   "glRenderbufferStorage\0"
+   "glRenderbufferStorageEXT\0"
+   "\0"
+   /* _mesa_function_pool[7257]: IsFenceNV (will be remapped) */
+   "i\0"
+   "glIsFenceNV\0"
+   "\0"
+   /* _mesa_function_pool[7272]: AttachObjectARB (will be remapped) */
+   "ii\0"
+   "glAttachObjectARB\0"
+   "\0"
+   /* _mesa_function_pool[7294]: GetFragmentLightivSGIX (dynamic) */
+   "iip\0"
+   "glGetFragmentLightivSGIX\0"
+   "\0"
+   /* _mesa_function_pool[7324]: UniformMatrix2fvARB (will be remapped) */
+   "iiip\0"
+   "glUniformMatrix2fv\0"
+   "glUniformMatrix2fvARB\0"
+   "\0"
+   /* _mesa_function_pool[7371]: MultiTexCoord2fARB (offset 386) */
+   "iff\0"
+   "glMultiTexCoord2f\0"
+   "glMultiTexCoord2fARB\0"
+   "\0"
+   /* _mesa_function_pool[7415]: ColorTable (offset 339) */
+   "iiiiip\0"
+   "glColorTable\0"
+   "glColorTableSGI\0"
+   "glColorTableEXT\0"
+   "\0"
+   /* _mesa_function_pool[7468]: IndexPointer (offset 314) */
+   "iip\0"
+   "glIndexPointer\0"
+   "\0"
+   /* _mesa_function_pool[7488]: Accum (offset 213) */
+   "if\0"
+   "glAccum\0"
+   "\0"
+   /* _mesa_function_pool[7500]: GetTexImage (offset 281) */
+   "iiiip\0"
+   "glGetTexImage\0"
+   "\0"
+   /* _mesa_function_pool[7521]: MapControlPointsNV (dynamic) */
+   "iiiiiiiip\0"
+   "glMapControlPointsNV\0"
+   "\0"
+   /* _mesa_function_pool[7553]: ConvolutionFilter2D (offset 349) */
+   "iiiiiip\0"
+   "glConvolutionFilter2D\0"
+   "glConvolutionFilter2DEXT\0"
+   "\0"
+   /* _mesa_function_pool[7609]: Finish (offset 216) */
+   "\0"
+   "glFinish\0"
+   "\0"
+   /* _mesa_function_pool[7620]: MapParameterfvNV (dynamic) */
+   "iip\0"
+   "glMapParameterfvNV\0"
+   "\0"
+   /* _mesa_function_pool[7644]: ClearStencil (offset 207) */
+   "i\0"
+   "glClearStencil\0"
+   "\0"
+   /* _mesa_function_pool[7662]: VertexAttrib3dvARB (will be remapped) */
+   "ip\0"
+   "glVertexAttrib3dv\0"
+   "glVertexAttrib3dvARB\0"
+   "\0"
+   /* _mesa_function_pool[7705]: HintPGI (dynamic) */
+   "ii\0"
+   "glHintPGI\0"
+   "\0"
+   /* _mesa_function_pool[7719]: ConvolutionParameteriv (offset 353) */
+   "iip\0"
+   "glConvolutionParameteriv\0"
+   "glConvolutionParameterivEXT\0"
+   "\0"
+   /* _mesa_function_pool[7777]: Color4s (offset 33) */
+   "iiii\0"
+   "glColor4s\0"
+   "\0"
+   /* _mesa_function_pool[7793]: InterleavedArrays (offset 317) */
+   "iip\0"
+   "glInterleavedArrays\0"
+   "\0"
+   /* _mesa_function_pool[7818]: RasterPos2fv (offset 65) */
+   "p\0"
+   "glRasterPos2fv\0"
+   "\0"
+   /* _mesa_function_pool[7836]: TexCoord1fv (offset 97) */
+   "p\0"
+   "glTexCoord1fv\0"
+   "\0"
+   /* _mesa_function_pool[7853]: Vertex2d (offset 126) */
+   "dd\0"
+   "glVertex2d\0"
+   "\0"
+   /* _mesa_function_pool[7868]: CullParameterdvEXT (will be remapped) */
+   "ip\0"
+   "glCullParameterdvEXT\0"
+   "\0"
+   /* _mesa_function_pool[7893]: ProgramNamedParameter4fNV (will be remapped) */
+   "iipffff\0"
+   "glProgramNamedParameter4fNV\0"
+   "\0"
+   /* _mesa_function_pool[7930]: Color3fVertex3fSUN (dynamic) */
+   "ffffff\0"
+   "glColor3fVertex3fSUN\0"
+   "\0"
+   /* _mesa_function_pool[7959]: ProgramEnvParameter4fvARB (will be remapped) */
+   "iip\0"
+   "glProgramEnvParameter4fvARB\0"
+   "glProgramParameter4fvNV\0"
+   "\0"
+   /* _mesa_function_pool[8016]: Color4i (offset 31) */
+   "iiii\0"
+   "glColor4i\0"
+   "\0"
+   /* _mesa_function_pool[8032]: Color4f (offset 29) */
+   "ffff\0"
+   "glColor4f\0"
+   "\0"
+   /* _mesa_function_pool[8048]: RasterPos4fv (offset 81) */
+   "p\0"
+   "glRasterPos4fv\0"
+   "\0"
+   /* _mesa_function_pool[8066]: Color4d (offset 27) */
+   "dddd\0"
+   "glColor4d\0"
+   "\0"
+   /* _mesa_function_pool[8082]: ClearIndex (offset 205) */
+   "f\0"
+   "glClearIndex\0"
+   "\0"
+   /* _mesa_function_pool[8098]: Color4b (offset 25) */
+   "iiii\0"
+   "glColor4b\0"
+   "\0"
+   /* _mesa_function_pool[8114]: LoadMatrixd (offset 292) */
+   "p\0"
+   "glLoadMatrixd\0"
+   "\0"
+   /* _mesa_function_pool[8131]: FragmentLightModeliSGIX (dynamic) */
+   "ii\0"
+   "glFragmentLightModeliSGIX\0"
+   "\0"
+   /* _mesa_function_pool[8161]: RasterPos2dv (offset 63) */
+   "p\0"
+   "glRasterPos2dv\0"
+   "\0"
+   /* _mesa_function_pool[8179]: ConvolutionParameterfv (offset 351) */
+   "iip\0"
+   "glConvolutionParameterfv\0"
+   "glConvolutionParameterfvEXT\0"
+   "\0"
+   /* _mesa_function_pool[8237]: TbufferMask3DFX (dynamic) */
+   "i\0"
+   "glTbufferMask3DFX\0"
+   "\0"
+   /* _mesa_function_pool[8258]: GetTexGendv (offset 278) */
+   "iip\0"
+   "glGetTexGendv\0"
+   "\0"
+   /* _mesa_function_pool[8277]: ColorMaskIndexedEXT (will be remapped) */
+   "iiiii\0"
+   "glColorMaskIndexedEXT\0"
+   "\0"
+   /* _mesa_function_pool[8306]: LoadProgramNV (will be remapped) */
+   "iiip\0"
+   "glLoadProgramNV\0"
+   "\0"
+   /* _mesa_function_pool[8328]: WaitSync (will be remapped) */
+   "iii\0"
+   "glWaitSync\0"
+   "\0"
+   /* _mesa_function_pool[8344]: EndList (offset 1) */
+   "\0"
+   "glEndList\0"
+   "\0"
+   /* _mesa_function_pool[8356]: VertexAttrib4fvNV (will be remapped) */
+   "ip\0"
+   "glVertexAttrib4fvNV\0"
+   "\0"
+   /* _mesa_function_pool[8380]: GetAttachedObjectsARB (will be remapped) */
+   "iipp\0"
+   "glGetAttachedObjectsARB\0"
+   "\0"
+   /* _mesa_function_pool[8410]: Uniform3fvARB (will be remapped) */
+   "iip\0"
+   "glUniform3fv\0"
+   "glUniform3fvARB\0"
+   "\0"
+   /* _mesa_function_pool[8444]: EvalCoord1fv (offset 231) */
+   "p\0"
+   "glEvalCoord1fv\0"
+   "\0"
+   /* _mesa_function_pool[8462]: DrawRangeElements (offset 338) */
+   "iiiiip\0"
+   "glDrawRangeElements\0"
+   "glDrawRangeElementsEXT\0"
+   "\0"
+   /* _mesa_function_pool[8513]: EvalMesh2 (offset 238) */
+   "iiiii\0"
+   "glEvalMesh2\0"
+   "\0"
+   /* _mesa_function_pool[8532]: Vertex4fv (offset 145) */
+   "p\0"
+   "glVertex4fv\0"
+   "\0"
+   /* _mesa_function_pool[8547]: SpriteParameterfvSGIX (dynamic) */
+   "ip\0"
+   "glSpriteParameterfvSGIX\0"
+   "\0"
+   /* _mesa_function_pool[8575]: CheckFramebufferStatusEXT (will be remapped) */
+   "i\0"
+   "glCheckFramebufferStatus\0"
+   "glCheckFramebufferStatusEXT\0"
+   "\0"
+   /* _mesa_function_pool[8631]: GlobalAlphaFactoruiSUN (dynamic) */
+   "i\0"
+   "glGlobalAlphaFactoruiSUN\0"
+   "\0"
+   /* _mesa_function_pool[8659]: GetHandleARB (will be remapped) */
+   "i\0"
+   "glGetHandleARB\0"
+   "\0"
+   /* _mesa_function_pool[8677]: GetVertexAttribivARB (will be remapped) */
+   "iip\0"
+   "glGetVertexAttribiv\0"
+   "glGetVertexAttribivARB\0"
+   "\0"
+   /* _mesa_function_pool[8725]: GetCombinerInputParameterfvNV (will be remapped) */
+   "iiiip\0"
+   "glGetCombinerInputParameterfvNV\0"
+   "\0"
+   /* _mesa_function_pool[8764]: CreateProgram (will be remapped) */
+   "\0"
+   "glCreateProgram\0"
+   "\0"
+   /* _mesa_function_pool[8782]: LoadTransposeMatrixdARB (will be remapped) */
+   "p\0"
+   "glLoadTransposeMatrixd\0"
+   "glLoadTransposeMatrixdARB\0"
+   "\0"
+   /* _mesa_function_pool[8834]: GetMinmax (offset 364) */
+   "iiiip\0"
+   "glGetMinmax\0"
+   "glGetMinmaxEXT\0"
+   "\0"
+   /* _mesa_function_pool[8868]: StencilFuncSeparate (will be remapped) */
+   "iiii\0"
+   "glStencilFuncSeparate\0"
+   "\0"
+   /* _mesa_function_pool[8896]: SecondaryColor3sEXT (will be remapped) */
+   "iii\0"
+   "glSecondaryColor3s\0"
+   "glSecondaryColor3sEXT\0"
+   "\0"
+   /* _mesa_function_pool[8942]: Color3fVertex3fvSUN (dynamic) */
+   "pp\0"
+   "glColor3fVertex3fvSUN\0"
+   "\0"
+   /* _mesa_function_pool[8968]: Normal3fv (offset 57) */
+   "p\0"
+   "glNormal3fv\0"
+   "\0"
+   /* _mesa_function_pool[8983]: GlobalAlphaFactorbSUN (dynamic) */
+   "i\0"
+   "glGlobalAlphaFactorbSUN\0"
+   "\0"
+   /* _mesa_function_pool[9010]: Color3us (offset 23) */
+   "iii\0"
+   "glColor3us\0"
+   "\0"
+   /* _mesa_function_pool[9026]: ImageTransformParameterfvHP (dynamic) */
+   "iip\0"
+   "glImageTransformParameterfvHP\0"
+   "\0"
+   /* _mesa_function_pool[9061]: VertexAttrib4ivARB (will be remapped) */
+   "ip\0"
+   "glVertexAttrib4iv\0"
+   "glVertexAttrib4ivARB\0"
+   "\0"
+   /* _mesa_function_pool[9104]: End (offset 43) */
+   "\0"
+   "glEnd\0"
+   "\0"
+   /* _mesa_function_pool[9112]: VertexAttrib3fNV (will be remapped) */
+   "ifff\0"
+   "glVertexAttrib3fNV\0"
+   "\0"
+   /* _mesa_function_pool[9137]: VertexAttribs2dvNV (will be remapped) */
+   "iip\0"
+   "glVertexAttribs2dvNV\0"
+   "\0"
+   /* _mesa_function_pool[9163]: GetQueryObjectui64vEXT (will be remapped) */
+   "iip\0"
+   "glGetQueryObjectui64vEXT\0"
+   "\0"
+   /* _mesa_function_pool[9193]: MultiTexCoord3fvARB (offset 395) */
+   "ip\0"
+   "glMultiTexCoord3fv\0"
+   "glMultiTexCoord3fvARB\0"
+   "\0"
+   /* _mesa_function_pool[9238]: SecondaryColor3dEXT (will be remapped) */
+   "ddd\0"
+   "glSecondaryColor3d\0"
+   "glSecondaryColor3dEXT\0"
+   "\0"
+   /* _mesa_function_pool[9284]: Color3ub (offset 19) */
+   "iii\0"
+   "glColor3ub\0"
+   "\0"
+   /* _mesa_function_pool[9300]: GetProgramParameterfvNV (will be remapped) */
+   "iiip\0"
+   "glGetProgramParameterfvNV\0"
+   "\0"
+   /* _mesa_function_pool[9332]: TangentPointerEXT (dynamic) */
+   "iip\0"
+   "glTangentPointerEXT\0"
+   "\0"
+   /* _mesa_function_pool[9357]: Color4fNormal3fVertex3fvSUN (dynamic) */
+   "ppp\0"
+   "glColor4fNormal3fVertex3fvSUN\0"
+   "\0"
+   /* _mesa_function_pool[9392]: GetInstrumentsSGIX (dynamic) */
+   "\0"
+   "glGetInstrumentsSGIX\0"
+   "\0"
+   /* _mesa_function_pool[9415]: Color3ui (offset 21) */
+   "iii\0"
+   "glColor3ui\0"
+   "\0"
+   /* _mesa_function_pool[9431]: EvalMapsNV (dynamic) */
+   "ii\0"
+   "glEvalMapsNV\0"
+   "\0"
+   /* _mesa_function_pool[9448]: TexSubImage2D (offset 333) */
+   "iiiiiiiip\0"
+   "glTexSubImage2D\0"
+   "glTexSubImage2DEXT\0"
+   "\0"
+   /* _mesa_function_pool[9494]: FragmentLightivSGIX (dynamic) */
+   "iip\0"
+   "glFragmentLightivSGIX\0"
+   "\0"
+   /* _mesa_function_pool[9521]: GetTexParameterPointervAPPLE (will be remapped) */
+   "iip\0"
+   "glGetTexParameterPointervAPPLE\0"
+   "\0"
+   /* _mesa_function_pool[9557]: TexGenfv (offset 191) */
+   "iip\0"
+   "glTexGenfv\0"
+   "\0"
+   /* _mesa_function_pool[9573]: PixelTransformParameterfvEXT (dynamic) */
+   "iip\0"
+   "glPixelTransformParameterfvEXT\0"
+   "\0"
+   /* _mesa_function_pool[9609]: VertexAttrib4bvARB (will be remapped) */
+   "ip\0"
+   "glVertexAttrib4bv\0"
+   "glVertexAttrib4bvARB\0"
+   "\0"
+   /* _mesa_function_pool[9652]: AlphaFragmentOp2ATI (will be remapped) */
+   "iiiiiiiii\0"
+   "glAlphaFragmentOp2ATI\0"
+   "\0"
+   /* _mesa_function_pool[9685]: GetIntegerIndexedvEXT (will be remapped) */
+   "iip\0"
+   "glGetIntegerIndexedvEXT\0"
+   "\0"
+   /* _mesa_function_pool[9714]: MultiTexCoord4sARB (offset 406) */
+   "iiiii\0"
+   "glMultiTexCoord4s\0"
+   "glMultiTexCoord4sARB\0"
+   "\0"
+   /* _mesa_function_pool[9760]: GetFragmentMaterialivSGIX (dynamic) */
+   "iip\0"
+   "glGetFragmentMaterialivSGIX\0"
+   "\0"
+   /* _mesa_function_pool[9793]: WindowPos4dMESA (will be remapped) */
+   "dddd\0"
+   "glWindowPos4dMESA\0"
+   "\0"
+   /* _mesa_function_pool[9817]: WeightPointerARB (dynamic) */
+   "iiip\0"
+   "glWeightPointerARB\0"
+   "\0"
+   /* _mesa_function_pool[9842]: WindowPos2dMESA (will be remapped) */
+   "dd\0"
+   "glWindowPos2d\0"
+   "glWindowPos2dARB\0"
+   "glWindowPos2dMESA\0"
+   "\0"
+   /* _mesa_function_pool[9895]: FramebufferTexture3DEXT (will be remapped) */
+   "iiiiii\0"
+   "glFramebufferTexture3D\0"
+   "glFramebufferTexture3DEXT\0"
+   "\0"
+   /* _mesa_function_pool[9952]: BlendEquation (offset 337) */
+   "i\0"
+   "glBlendEquation\0"
+   "glBlendEquationEXT\0"
+   "\0"
+   /* _mesa_function_pool[9990]: VertexAttrib3dNV (will be remapped) */
+   "iddd\0"
+   "glVertexAttrib3dNV\0"
+   "\0"
+   /* _mesa_function_pool[10015]: VertexAttrib3dARB (will be remapped) */
+   "iddd\0"
+   "glVertexAttrib3d\0"
+   "glVertexAttrib3dARB\0"
+   "\0"
+   /* _mesa_function_pool[10058]: ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (dynamic) */
+   "ppppp\0"
+   "glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN\0"
+   "\0"
+   /* _mesa_function_pool[10122]: VertexAttrib4fARB (will be remapped) */
+   "iffff\0"
+   "glVertexAttrib4f\0"
+   "glVertexAttrib4fARB\0"
+   "\0"
+   /* _mesa_function_pool[10166]: GetError (offset 261) */
+   "\0"
+   "glGetError\0"
+   "\0"
+   /* _mesa_function_pool[10179]: IndexFuncEXT (dynamic) */
+   "if\0"
+   "glIndexFuncEXT\0"
+   "\0"
+   /* _mesa_function_pool[10198]: TexCoord3dv (offset 111) */
+   "p\0"
+   "glTexCoord3dv\0"
+   "\0"
+   /* _mesa_function_pool[10215]: Indexdv (offset 45) */
+   "p\0"
+   "glIndexdv\0"
+   "\0"
+   /* _mesa_function_pool[10228]: FramebufferTexture2DEXT (will be remapped) */
+   "iiiii\0"
+   "glFramebufferTexture2D\0"
+   "glFramebufferTexture2DEXT\0"
+   "\0"
+   /* _mesa_function_pool[10284]: Normal3s (offset 60) */
+   "iii\0"
+   "glNormal3s\0"
+   "\0"
+   /* _mesa_function_pool[10300]: PushName (offset 201) */
+   "i\0"
+   "glPushName\0"
+   "\0"
+   /* _mesa_function_pool[10314]: MultiTexCoord2dvARB (offset 385) */
+   "ip\0"
+   "glMultiTexCoord2dv\0"
+   "glMultiTexCoord2dvARB\0"
+   "\0"
+   /* _mesa_function_pool[10359]: CullParameterfvEXT (will be remapped) */
+   "ip\0"
+   "glCullParameterfvEXT\0"
+   "\0"
+   /* _mesa_function_pool[10384]: Normal3i (offset 58) */
+   "iii\0"
+   "glNormal3i\0"
+   "\0"
+   /* _mesa_function_pool[10400]: ProgramNamedParameter4fvNV (will be remapped) */
+   "iipp\0"
+   "glProgramNamedParameter4fvNV\0"
+   "\0"
+   /* _mesa_function_pool[10435]: SecondaryColorPointerEXT (will be remapped) */
+   "iiip\0"
+   "glSecondaryColorPointer\0"
+   "glSecondaryColorPointerEXT\0"
+   "\0"
+   /* _mesa_function_pool[10492]: VertexAttrib4fvARB (will be remapped) */
+   "ip\0"
+   "glVertexAttrib4fv\0"
+   "glVertexAttrib4fvARB\0"
+   "\0"
+   /* _mesa_function_pool[10535]: ColorPointerListIBM (dynamic) */
+   "iiipi\0"
+   "glColorPointerListIBM\0"
+   "\0"
+   /* _mesa_function_pool[10564]: GetActiveUniformARB (will be remapped) */
+   "iiipppp\0"
+   "glGetActiveUniform\0"
+   "glGetActiveUniformARB\0"
+   "\0"
+   /* _mesa_function_pool[10614]: ImageTransformParameteriHP (dynamic) */
+   "iii\0"
+   "glImageTransformParameteriHP\0"
+   "\0"
+   /* _mesa_function_pool[10648]: Normal3b (offset 52) */
+   "iii\0"
+   "glNormal3b\0"
+   "\0"
+   /* _mesa_function_pool[10664]: Normal3d (offset 54) */
+   "ddd\0"
+   "glNormal3d\0"
+   "\0"
+   /* _mesa_function_pool[10680]: Normal3f (offset 56) */
+   "fff\0"
+   "glNormal3f\0"
+   "\0"
+   /* _mesa_function_pool[10696]: MultiTexCoord1svARB (offset 383) */
+   "ip\0"
+   "glMultiTexCoord1sv\0"
+   "glMultiTexCoord1svARB\0"
+   "\0"
+   /* _mesa_function_pool[10741]: Indexi (offset 48) */
+   "i\0"
+   "glIndexi\0"
+   "\0"
+   /* _mesa_function_pool[10753]: EndQueryARB (will be remapped) */
+   "i\0"
+   "glEndQuery\0"
+   "glEndQueryARB\0"
+   "\0"
+   /* _mesa_function_pool[10781]: DeleteFencesNV (will be remapped) */
+   "ip\0"
+   "glDeleteFencesNV\0"
+   "\0"
+   /* _mesa_function_pool[10802]: DeformationMap3dSGIX (dynamic) */
+   "iddiiddiiddiip\0"
+   "glDeformationMap3dSGIX\0"
+   "\0"
+   /* _mesa_function_pool[10841]: DepthMask (offset 211) */
+   "i\0"
+   "glDepthMask\0"
+   "\0"
+   /* _mesa_function_pool[10856]: IsShader (will be remapped) */
+   "i\0"
+   "glIsShader\0"
+   "\0"
+   /* _mesa_function_pool[10870]: Indexf (offset 46) */
+   "f\0"
+   "glIndexf\0"
+   "\0"
+   /* _mesa_function_pool[10882]: GetImageTransformParameterivHP (dynamic) */
+   "iip\0"
+   "glGetImageTransformParameterivHP\0"
+   "\0"
+   /* _mesa_function_pool[10920]: Indexd (offset 44) */
+   "d\0"
+   "glIndexd\0"
+   "\0"
+   /* _mesa_function_pool[10932]: GetMaterialiv (offset 270) */
+   "iip\0"
+   "glGetMaterialiv\0"
+   "\0"
+   /* _mesa_function_pool[10953]: StencilOp (offset 244) */
+   "iii\0"
+   "glStencilOp\0"
+   "\0"
+   /* _mesa_function_pool[10970]: WindowPos4ivMESA (will be remapped) */
+   "p\0"
+   "glWindowPos4ivMESA\0"
+   "\0"
+   /* _mesa_function_pool[10992]: MultiTexCoord3svARB (offset 399) */
+   "ip\0"
+   "glMultiTexCoord3sv\0"
+   "glMultiTexCoord3svARB\0"
+   "\0"
+   /* _mesa_function_pool[11037]: TexEnvfv (offset 185) */
+   "iip\0"
+   "glTexEnvfv\0"
+   "\0"
+   /* _mesa_function_pool[11053]: MultiTexCoord4iARB (offset 404) */
+   "iiiii\0"
+   "glMultiTexCoord4i\0"
+   "glMultiTexCoord4iARB\0"
+   "\0"
+   /* _mesa_function_pool[11099]: Indexs (offset 50) */
+   "i\0"
+   "glIndexs\0"
+   "\0"
+   /* _mesa_function_pool[11111]: Binormal3ivEXT (dynamic) */
+   "p\0"
+   "glBinormal3ivEXT\0"
+   "\0"
+   /* _mesa_function_pool[11131]: ResizeBuffersMESA (will be remapped) */
+   "\0"
+   "glResizeBuffersMESA\0"
+   "\0"
+   /* _mesa_function_pool[11153]: GetUniformivARB (will be remapped) */
+   "iip\0"
+   "glGetUniformiv\0"
+   "glGetUniformivARB\0"
+   "\0"
+   /* _mesa_function_pool[11191]: PixelTexGenParameteriSGIS (will be remapped) */
+   "ii\0"
+   "glPixelTexGenParameteriSGIS\0"
+   "\0"
+   /* _mesa_function_pool[11223]: VertexPointervINTEL (dynamic) */
+   "iip\0"
+   "glVertexPointervINTEL\0"
+   "\0"
+   /* _mesa_function_pool[11250]: Vertex2i (offset 130) */
+   "ii\0"
+   "glVertex2i\0"
+   "\0"
+   /* _mesa_function_pool[11265]: LoadMatrixf (offset 291) */
+   "p\0"
+   "glLoadMatrixf\0"
+   "\0"
+   /* _mesa_function_pool[11282]: Vertex2f (offset 128) */
+   "ff\0"
+   "glVertex2f\0"
+   "\0"
+   /* _mesa_function_pool[11297]: ReplacementCodeuiColor4fNormal3fVertex3fvSUN (dynamic) */
+   "pppp\0"
+   "glReplacementCodeuiColor4fNormal3fVertex3fvSUN\0"
+   "\0"
+   /* _mesa_function_pool[11350]: Color4bv (offset 26) */
+   "p\0"
+   "glColor4bv\0"
+   "\0"
+   /* _mesa_function_pool[11364]: VertexPointer (offset 321) */
+   "iiip\0"
+   "glVertexPointer\0"
+   "\0"
+   /* _mesa_function_pool[11386]: SecondaryColor3uiEXT (will be remapped) */
+   "iii\0"
+   "glSecondaryColor3ui\0"
+   "glSecondaryColor3uiEXT\0"
+   "\0"
+   /* _mesa_function_pool[11434]: StartInstrumentsSGIX (dynamic) */
+   "\0"
+   "glStartInstrumentsSGIX\0"
+   "\0"
+   /* _mesa_function_pool[11459]: SecondaryColor3usvEXT (will be remapped) */
+   "p\0"
+   "glSecondaryColor3usv\0"
+   "glSecondaryColor3usvEXT\0"
+   "\0"
+   /* _mesa_function_pool[11507]: VertexAttrib2fvNV (will be remapped) */
+   "ip\0"
+   "glVertexAttrib2fvNV\0"
+   "\0"
+   /* _mesa_function_pool[11531]: ProgramLocalParameter4dvARB (will be remapped) */
+   "iip\0"
+   "glProgramLocalParameter4dvARB\0"
+   "\0"
+   /* _mesa_function_pool[11566]: DeleteLists (offset 4) */
+   "ii\0"
+   "glDeleteLists\0"
+   "\0"
+   /* _mesa_function_pool[11584]: LogicOp (offset 242) */
+   "i\0"
+   "glLogicOp\0"
+   "\0"
+   /* _mesa_function_pool[11597]: MatrixIndexuivARB (dynamic) */
+   "ip\0"
+   "glMatrixIndexuivARB\0"
+   "\0"
+   /* _mesa_function_pool[11621]: Vertex2s (offset 132) */
+   "ii\0"
+   "glVertex2s\0"
+   "\0"
+   /* _mesa_function_pool[11636]: RenderbufferStorageMultisample (will be remapped) */
+   "iiiii\0"
+   "glRenderbufferStorageMultisample\0"
+   "glRenderbufferStorageMultisampleEXT\0"
+   "\0"
+   /* _mesa_function_pool[11712]: TexCoord4fv (offset 121) */
+   "p\0"
+   "glTexCoord4fv\0"
+   "\0"
+   /* _mesa_function_pool[11729]: Tangent3sEXT (dynamic) */
+   "iii\0"
+   "glTangent3sEXT\0"
+   "\0"
+   /* _mesa_function_pool[11749]: GlobalAlphaFactorfSUN (dynamic) */
+   "f\0"
+   "glGlobalAlphaFactorfSUN\0"
+   "\0"
+   /* _mesa_function_pool[11776]: MultiTexCoord3iARB (offset 396) */
+   "iiii\0"
+   "glMultiTexCoord3i\0"
+   "glMultiTexCoord3iARB\0"
+   "\0"
+   /* _mesa_function_pool[11821]: IsProgram (will be remapped) */
+   "i\0"
+   "glIsProgram\0"
+   "\0"
+   /* _mesa_function_pool[11836]: TexCoordPointerListIBM (dynamic) */
+   "iiipi\0"
+   "glTexCoordPointerListIBM\0"
+   "\0"
+   /* _mesa_function_pool[11868]: GlobalAlphaFactorusSUN (dynamic) */
+   "i\0"
+   "glGlobalAlphaFactorusSUN\0"
+   "\0"
+   /* _mesa_function_pool[11896]: VertexAttrib2dvNV (will be remapped) */
+   "ip\0"
+   "glVertexAttrib2dvNV\0"
+   "\0"
+   /* _mesa_function_pool[11920]: FramebufferRenderbufferEXT (will be remapped) */
+   "iiii\0"
+   "glFramebufferRenderbuffer\0"
+   "glFramebufferRenderbufferEXT\0"
+   "\0"
+   /* _mesa_function_pool[11981]: VertexAttrib1dvNV (will be remapped) */
+   "ip\0"
+   "glVertexAttrib1dvNV\0"
+   "\0"
+   /* _mesa_function_pool[12005]: GenTextures (offset 328) */
+   "ip\0"
+   "glGenTextures\0"
+   "glGenTexturesEXT\0"
+   "\0"
+   /* _mesa_function_pool[12040]: SetFenceNV (will be remapped) */
+   "ii\0"
+   "glSetFenceNV\0"
+   "\0"
+   /* _mesa_function_pool[12057]: FramebufferTexture1DEXT (will be remapped) */
+   "iiiii\0"
+   "glFramebufferTexture1D\0"
+   "glFramebufferTexture1DEXT\0"
+   "\0"
+   /* _mesa_function_pool[12113]: GetCombinerOutputParameterivNV (will be remapped) */
+   "iiip\0"
+   "glGetCombinerOutputParameterivNV\0"
+   "\0"
+   /* _mesa_function_pool[12152]: PixelTexGenParameterivSGIS (will be remapped) */
+   "ip\0"
+   "glPixelTexGenParameterivSGIS\0"
+   "\0"
+   /* _mesa_function_pool[12185]: TextureNormalEXT (dynamic) */
+   "i\0"
+   "glTextureNormalEXT\0"
+   "\0"
+   /* _mesa_function_pool[12207]: IndexPointerListIBM (dynamic) */
+   "iipi\0"
+   "glIndexPointerListIBM\0"
+   "\0"
+   /* _mesa_function_pool[12235]: WeightfvARB (dynamic) */
+   "ip\0"
+   "glWeightfvARB\0"
+   "\0"
+   /* _mesa_function_pool[12253]: RasterPos2sv (offset 69) */
+   "p\0"
+   "glRasterPos2sv\0"
+   "\0"
+   /* _mesa_function_pool[12271]: Color4ubv (offset 36) */
+   "p\0"
+   "glColor4ubv\0"
+   "\0"
+   /* _mesa_function_pool[12286]: DrawBuffer (offset 202) */
+   "i\0"
+   "glDrawBuffer\0"
+   "\0"
+   /* _mesa_function_pool[12302]: TexCoord2fv (offset 105) */
+   "p\0"
+   "glTexCoord2fv\0"
+   "\0"
+   /* _mesa_function_pool[12319]: WindowPos4fMESA (will be remapped) */
+   "ffff\0"
+   "glWindowPos4fMESA\0"
+   "\0"
+   /* _mesa_function_pool[12343]: TexCoord1sv (offset 101) */
+   "p\0"
+   "glTexCoord1sv\0"
+   "\0"
+   /* _mesa_function_pool[12360]: WindowPos3dvMESA (will be remapped) */
+   "p\0"
+   "glWindowPos3dv\0"
+   "glWindowPos3dvARB\0"
+   "glWindowPos3dvMESA\0"
+   "\0"
+   /* _mesa_function_pool[12415]: DepthFunc (offset 245) */
+   "i\0"
+   "glDepthFunc\0"
+   "\0"
+   /* _mesa_function_pool[12430]: PixelMapusv (offset 253) */
+   "iip\0"
+   "glPixelMapusv\0"
+   "\0"
+   /* _mesa_function_pool[12449]: GetQueryObjecti64vEXT (will be remapped) */
+   "iip\0"
+   "glGetQueryObjecti64vEXT\0"
+   "\0"
+   /* _mesa_function_pool[12478]: MultiTexCoord1dARB (offset 376) */
+   "id\0"
+   "glMultiTexCoord1d\0"
+   "glMultiTexCoord1dARB\0"
+   "\0"
+   /* _mesa_function_pool[12521]: PointParameterivNV (will be remapped) */
+   "ip\0"
+   "glPointParameteriv\0"
+   "glPointParameterivNV\0"
+   "\0"
+   /* _mesa_function_pool[12565]: BlendFunc (offset 241) */
+   "ii\0"
+   "glBlendFunc\0"
+   "\0"
+   /* _mesa_function_pool[12581]: Uniform2fvARB (will be remapped) */
+   "iip\0"
+   "glUniform2fv\0"
+   "glUniform2fvARB\0"
+   "\0"
+   /* _mesa_function_pool[12615]: BufferParameteriAPPLE (will be remapped) */
+   "iii\0"
+   "glBufferParameteriAPPLE\0"
+   "\0"
+   /* _mesa_function_pool[12644]: MultiTexCoord3dvARB (offset 393) */
+   "ip\0"
+   "glMultiTexCoord3dv\0"
+   "glMultiTexCoord3dvARB\0"
+   "\0"
+   /* _mesa_function_pool[12689]: ReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (dynamic) */
+   "pppp\0"
+   "glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN\0"
+   "\0"
+   /* _mesa_function_pool[12745]: DeleteObjectARB (will be remapped) */
+   "i\0"
+   "glDeleteObjectARB\0"
+   "\0"
+   /* _mesa_function_pool[12766]: MatrixIndexPointerARB (dynamic) */
+   "iiip\0"
+   "glMatrixIndexPointerARB\0"
+   "\0"
+   /* _mesa_function_pool[12796]: ProgramNamedParameter4dvNV (will be remapped) */
+   "iipp\0"
+   "glProgramNamedParameter4dvNV\0"
+   "\0"
+   /* _mesa_function_pool[12831]: Tangent3fvEXT (dynamic) */
+   "p\0"
+   "glTangent3fvEXT\0"
+   "\0"
+   /* _mesa_function_pool[12850]: Flush (offset 217) */
+   "\0"
+   "glFlush\0"
+   "\0"
+   /* _mesa_function_pool[12860]: Color4uiv (offset 38) */
+   "p\0"
+   "glColor4uiv\0"
+   "\0"
+   /* _mesa_function_pool[12875]: GenVertexArrays (will be remapped) */
+   "ip\0"
+   "glGenVertexArrays\0"
+   "\0"
+   /* _mesa_function_pool[12897]: RasterPos3sv (offset 77) */
+   "p\0"
+   "glRasterPos3sv\0"
+   "\0"
+   /* _mesa_function_pool[12915]: BindFramebufferEXT (will be remapped) */
+   "ii\0"
+   "glBindFramebuffer\0"
+   "glBindFramebufferEXT\0"
+   "\0"
+   /* _mesa_function_pool[12958]: ReferencePlaneSGIX (dynamic) */
+   "p\0"
+   "glReferencePlaneSGIX\0"
+   "\0"
+   /* _mesa_function_pool[12982]: PushAttrib (offset 219) */
+   "i\0"
+   "glPushAttrib\0"
+   "\0"
+   /* _mesa_function_pool[12998]: RasterPos2i (offset 66) */
+   "ii\0"
+   "glRasterPos2i\0"
+   "\0"
+   /* _mesa_function_pool[13016]: ValidateProgramARB (will be remapped) */
+   "i\0"
+   "glValidateProgram\0"
+   "glValidateProgramARB\0"
+   "\0"
+   /* _mesa_function_pool[13058]: TexParameteriv (offset 181) */
+   "iip\0"
+   "glTexParameteriv\0"
+   "\0"
+   /* _mesa_function_pool[13080]: UnlockArraysEXT (will be remapped) */
+   "\0"
+   "glUnlockArraysEXT\0"
+   "\0"
+   /* _mesa_function_pool[13100]: TexCoord2fColor3fVertex3fSUN (dynamic) */
+   "ffffffff\0"
+   "glTexCoord2fColor3fVertex3fSUN\0"
+   "\0"
+   /* _mesa_function_pool[13141]: WindowPos3fvMESA (will be remapped) */
+   "p\0"
+   "glWindowPos3fv\0"
+   "glWindowPos3fvARB\0"
+   "glWindowPos3fvMESA\0"
+   "\0"
+   /* _mesa_function_pool[13196]: RasterPos2f (offset 64) */
+   "ff\0"
+   "glRasterPos2f\0"
+   "\0"
+   /* _mesa_function_pool[13214]: VertexAttrib1svNV (will be remapped) */
+   "ip\0"
+   "glVertexAttrib1svNV\0"
+   "\0"
+   /* _mesa_function_pool[13238]: RasterPos2d (offset 62) */
+   "dd\0"
+   "glRasterPos2d\0"
+   "\0"
+   /* _mesa_function_pool[13256]: RasterPos3fv (offset 73) */
+   "p\0"
+   "glRasterPos3fv\0"
+   "\0"
+   /* _mesa_function_pool[13274]: CopyTexSubImage3D (offset 373) */
+   "iiiiiiiii\0"
+   "glCopyTexSubImage3D\0"
+   "glCopyTexSubImage3DEXT\0"
+   "\0"
+   /* _mesa_function_pool[13328]: VertexAttrib2dARB (will be remapped) */
+   "idd\0"
+   "glVertexAttrib2d\0"
+   "glVertexAttrib2dARB\0"
+   "\0"
+   /* _mesa_function_pool[13370]: Color4ub (offset 35) */
+   "iiii\0"
+   "glColor4ub\0"
+   "\0"
+   /* _mesa_function_pool[13387]: GetInteger64v (will be remapped) */
+   "ip\0"
+   "glGetInteger64v\0"
+   "\0"
+   /* _mesa_function_pool[13407]: TextureColorMaskSGIS (dynamic) */
+   "iiii\0"
+   "glTextureColorMaskSGIS\0"
+   "\0"
+   /* _mesa_function_pool[13436]: RasterPos2s (offset 68) */
+   "ii\0"
+   "glRasterPos2s\0"
+   "\0"
+   /* _mesa_function_pool[13454]: GetColorTable (offset 343) */
+   "iiip\0"
+   "glGetColorTable\0"
+   "glGetColorTableSGI\0"
+   "glGetColorTableEXT\0"
+   "\0"
+   /* _mesa_function_pool[13514]: SelectBuffer (offset 195) */
+   "ip\0"
+   "glSelectBuffer\0"
+   "\0"
+   /* _mesa_function_pool[13533]: Indexiv (offset 49) */
+   "p\0"
+   "glIndexiv\0"
+   "\0"
+   /* _mesa_function_pool[13546]: TexCoord3i (offset 114) */
+   "iii\0"
+   "glTexCoord3i\0"
+   "\0"
+   /* _mesa_function_pool[13564]: CopyColorTable (offset 342) */
+   "iiiii\0"
+   "glCopyColorTable\0"
+   "glCopyColorTableSGI\0"
+   "\0"
+   /* _mesa_function_pool[13608]: GetHistogramParameterfv (offset 362) */
+   "iip\0"
+   "glGetHistogramParameterfv\0"
+   "glGetHistogramParameterfvEXT\0"
+   "\0"
+   /* _mesa_function_pool[13668]: Frustum (offset 289) */
+   "dddddd\0"
+   "glFrustum\0"
+   "\0"
+   /* _mesa_function_pool[13686]: GetString (offset 275) */
+   "i\0"
+   "glGetString\0"
+   "\0"
+   /* _mesa_function_pool[13701]: ColorPointervINTEL (dynamic) */
+   "iip\0"
+   "glColorPointervINTEL\0"
+   "\0"
+   /* _mesa_function_pool[13727]: TexEnvf (offset 184) */
+   "iif\0"
+   "glTexEnvf\0"
+   "\0"
+   /* _mesa_function_pool[13742]: TexCoord3d (offset 110) */
+   "ddd\0"
+   "glTexCoord3d\0"
+   "\0"
+   /* _mesa_function_pool[13760]: AlphaFragmentOp1ATI (will be remapped) */
+   "iiiiii\0"
+   "glAlphaFragmentOp1ATI\0"
+   "\0"
+   /* _mesa_function_pool[13790]: TexCoord3f (offset 112) */
+   "fff\0"
+   "glTexCoord3f\0"
+   "\0"
+   /* _mesa_function_pool[13808]: MultiTexCoord3ivARB (offset 397) */
+   "ip\0"
+   "glMultiTexCoord3iv\0"
+   "glMultiTexCoord3ivARB\0"
+   "\0"
+   /* _mesa_function_pool[13853]: MultiTexCoord2sARB (offset 390) */
+   "iii\0"
+   "glMultiTexCoord2s\0"
+   "glMultiTexCoord2sARB\0"
+   "\0"
+   /* _mesa_function_pool[13897]: VertexAttrib1dvARB (will be remapped) */
+   "ip\0"
+   "glVertexAttrib1dv\0"
+   "glVertexAttrib1dvARB\0"
+   "\0"
+   /* _mesa_function_pool[13940]: DeleteTextures (offset 327) */
+   "ip\0"
+   "glDeleteTextures\0"
+   "glDeleteTexturesEXT\0"
+   "\0"
+   /* _mesa_function_pool[13981]: TexCoordPointerEXT (will be remapped) */
+   "iiiip\0"
+   "glTexCoordPointerEXT\0"
+   "\0"
+   /* _mesa_function_pool[14009]: TexSubImage4DSGIS (dynamic) */
+   "iiiiiiiiiiiip\0"
+   "glTexSubImage4DSGIS\0"
+   "\0"
+   /* _mesa_function_pool[14044]: TexCoord3s (offset 116) */
+   "iii\0"
+   "glTexCoord3s\0"
+   "\0"
+   /* _mesa_function_pool[14062]: GetTexLevelParameteriv (offset 285) */
+   "iiip\0"
+   "glGetTexLevelParameteriv\0"
+   "\0"
+   /* _mesa_function_pool[14093]: CombinerStageParameterfvNV (dynamic) */
+   "iip\0"
+   "glCombinerStageParameterfvNV\0"
+   "\0"
+   /* _mesa_function_pool[14127]: StopInstrumentsSGIX (dynamic) */
+   "i\0"
+   "glStopInstrumentsSGIX\0"
+   "\0"
+   /* _mesa_function_pool[14152]: TexCoord4fColor4fNormal3fVertex4fSUN (dynamic) */
+   "fffffffffffffff\0"
+   "glTexCoord4fColor4fNormal3fVertex4fSUN\0"
+   "\0"
+   /* _mesa_function_pool[14208]: ClearAccum (offset 204) */
+   "ffff\0"
+   "glClearAccum\0"
+   "\0"
+   /* _mesa_function_pool[14227]: DeformSGIX (dynamic) */
+   "i\0"
+   "glDeformSGIX\0"
+   "\0"
+   /* _mesa_function_pool[14243]: GetVertexAttribfvARB (will be remapped) */
+   "iip\0"
+   "glGetVertexAttribfv\0"
+   "glGetVertexAttribfvARB\0"
+   "\0"
+   /* _mesa_function_pool[14291]: SecondaryColor3ivEXT (will be remapped) */
+   "p\0"
+   "glSecondaryColor3iv\0"
+   "glSecondaryColor3ivEXT\0"
+   "\0"
+   /* _mesa_function_pool[14337]: TexCoord4iv (offset 123) */
+   "p\0"
+   "glTexCoord4iv\0"
+   "\0"
+   /* _mesa_function_pool[14354]: UniformMatrix4x2fv (will be remapped) */
+   "iiip\0"
+   "glUniformMatrix4x2fv\0"
+   "\0"
+   /* _mesa_function_pool[14381]: GetDetailTexFuncSGIS (dynamic) */
+   "ip\0"
+   "glGetDetailTexFuncSGIS\0"
+   "\0"
+   /* _mesa_function_pool[14408]: GetCombinerStageParameterfvNV (dynamic) */
+   "iip\0"
+   "glGetCombinerStageParameterfvNV\0"
+   "\0"
+   /* _mesa_function_pool[14445]: PolygonOffset (offset 319) */
+   "ff\0"
+   "glPolygonOffset\0"
+   "\0"
+   /* _mesa_function_pool[14465]: BindVertexArray (will be remapped) */
+   "i\0"
+   "glBindVertexArray\0"
+   "\0"
+   /* _mesa_function_pool[14486]: Color4ubVertex2fvSUN (dynamic) */
+   "pp\0"
+   "glColor4ubVertex2fvSUN\0"
+   "\0"
+   /* _mesa_function_pool[14513]: Rectd (offset 86) */
+   "dddd\0"
+   "glRectd\0"
+   "\0"
+   /* _mesa_function_pool[14527]: TexFilterFuncSGIS (dynamic) */
+   "iiip\0"
+   "glTexFilterFuncSGIS\0"
+   "\0"
+   /* _mesa_function_pool[14553]: SampleMaskSGIS (will be remapped) */
+   "fi\0"
+   "glSampleMaskSGIS\0"
+   "glSampleMaskEXT\0"
+   "\0"
+   /* _mesa_function_pool[14590]: GetAttribLocationARB (will be remapped) */
+   "ip\0"
+   "glGetAttribLocation\0"
+   "glGetAttribLocationARB\0"
+   "\0"
+   /* _mesa_function_pool[14637]: RasterPos3i (offset 74) */
+   "iii\0"
+   "glRasterPos3i\0"
+   "\0"
+   /* _mesa_function_pool[14656]: VertexAttrib4ubvARB (will be remapped) */
+   "ip\0"
+   "glVertexAttrib4ubv\0"
+   "glVertexAttrib4ubvARB\0"
+   "\0"
+   /* _mesa_function_pool[14701]: DetailTexFuncSGIS (dynamic) */
+   "iip\0"
+   "glDetailTexFuncSGIS\0"
+   "\0"
+   /* _mesa_function_pool[14726]: Normal3fVertex3fSUN (dynamic) */
+   "ffffff\0"
+   "glNormal3fVertex3fSUN\0"
+   "\0"
+   /* _mesa_function_pool[14756]: CopyTexImage2D (offset 324) */
+   "iiiiiiii\0"
+   "glCopyTexImage2D\0"
+   "glCopyTexImage2DEXT\0"
+   "\0"
+   /* _mesa_function_pool[14803]: GetBufferPointervARB (will be remapped) */
+   "iip\0"
+   "glGetBufferPointerv\0"
+   "glGetBufferPointervARB\0"
+   "\0"
+   /* _mesa_function_pool[14851]: ProgramEnvParameter4fARB (will be remapped) */
+   "iiffff\0"
+   "glProgramEnvParameter4fARB\0"
+   "glProgramParameter4fNV\0"
+   "\0"
+   /* _mesa_function_pool[14909]: Uniform3ivARB (will be remapped) */
+   "iip\0"
+   "glUniform3iv\0"
+   "glUniform3ivARB\0"
+   "\0"
+   /* _mesa_function_pool[14943]: Lightfv (offset 160) */
+   "iip\0"
+   "glLightfv\0"
+   "\0"
+   /* _mesa_function_pool[14958]: ClearDepth (offset 208) */
+   "d\0"
+   "glClearDepth\0"
+   "\0"
+   /* _mesa_function_pool[14974]: GetFenceivNV (will be remapped) */
+   "iip\0"
+   "glGetFenceivNV\0"
+   "\0"
+   /* _mesa_function_pool[14994]: WindowPos4dvMESA (will be remapped) */
+   "p\0"
+   "glWindowPos4dvMESA\0"
+   "\0"
+   /* _mesa_function_pool[15016]: ColorSubTable (offset 346) */
+   "iiiiip\0"
+   "glColorSubTable\0"
+   "glColorSubTableEXT\0"
+   "\0"
+   /* _mesa_function_pool[15059]: Color4fv (offset 30) */
+   "p\0"
+   "glColor4fv\0"
+   "\0"
+   /* _mesa_function_pool[15073]: MultiTexCoord4ivARB (offset 405) */
+   "ip\0"
+   "glMultiTexCoord4iv\0"
+   "glMultiTexCoord4ivARB\0"
+   "\0"
+   /* _mesa_function_pool[15118]: ProgramLocalParameters4fvEXT (will be remapped) */
+   "iiip\0"
+   "glProgramLocalParameters4fvEXT\0"
+   "\0"
+   /* _mesa_function_pool[15155]: ColorPointer (offset 308) */
+   "iiip\0"
+   "glColorPointer\0"
+   "\0"
+   /* _mesa_function_pool[15176]: Rects (offset 92) */
+   "iiii\0"
+   "glRects\0"
+   "\0"
+   /* _mesa_function_pool[15190]: GetMapAttribParameterfvNV (dynamic) */
+   "iiip\0"
+   "glGetMapAttribParameterfvNV\0"
+   "\0"
+   /* _mesa_function_pool[15224]: Lightiv (offset 162) */
+   "iip\0"
+   "glLightiv\0"
+   "\0"
+   /* _mesa_function_pool[15239]: VertexAttrib4sARB (will be remapped) */
+   "iiiii\0"
+   "glVertexAttrib4s\0"
+   "glVertexAttrib4sARB\0"
+   "\0"
+   /* _mesa_function_pool[15283]: GetQueryObjectuivARB (will be remapped) */
+   "iip\0"
+   "glGetQueryObjectuiv\0"
+   "glGetQueryObjectuivARB\0"
+   "\0"
+   /* _mesa_function_pool[15331]: GetTexParameteriv (offset 283) */
+   "iip\0"
+   "glGetTexParameteriv\0"
+   "\0"
+   /* _mesa_function_pool[15356]: MapParameterivNV (dynamic) */
+   "iip\0"
+   "glMapParameterivNV\0"
+   "\0"
+   /* _mesa_function_pool[15380]: GenRenderbuffersEXT (will be remapped) */
+   "ip\0"
+   "glGenRenderbuffers\0"
+   "glGenRenderbuffersEXT\0"
+   "\0"
+   /* _mesa_function_pool[15425]: VertexAttrib2dvARB (will be remapped) */
+   "ip\0"
+   "glVertexAttrib2dv\0"
+   "glVertexAttrib2dvARB\0"
+   "\0"
+   /* _mesa_function_pool[15468]: EdgeFlagPointerEXT (will be remapped) */
+   "iip\0"
+   "glEdgeFlagPointerEXT\0"
+   "\0"
+   /* _mesa_function_pool[15494]: VertexAttribs2svNV (will be remapped) */
+   "iip\0"
+   "glVertexAttribs2svNV\0"
+   "\0"
+   /* _mesa_function_pool[15520]: WeightbvARB (dynamic) */
+   "ip\0"
+   "glWeightbvARB\0"
+   "\0"
+   /* _mesa_function_pool[15538]: VertexAttrib2fvARB (will be remapped) */
+   "ip\0"
+   "glVertexAttrib2fv\0"
+   "glVertexAttrib2fvARB\0"
+   "\0"
+   /* _mesa_function_pool[15581]: GetBufferParameterivARB (will be remapped) */
+   "iip\0"
+   "glGetBufferParameteriv\0"
+   "glGetBufferParameterivARB\0"
+   "\0"
+   /* _mesa_function_pool[15635]: Rectdv (offset 87) */
+   "pp\0"
+   "glRectdv\0"
+   "\0"
+   /* _mesa_function_pool[15648]: ListParameteriSGIX (dynamic) */
+   "iii\0"
+   "glListParameteriSGIX\0"
+   "\0"
+   /* _mesa_function_pool[15674]: ReplacementCodeuiColor4fNormal3fVertex3fSUN (dynamic) */
+   "iffffffffff\0"
+   "glReplacementCodeuiColor4fNormal3fVertex3fSUN\0"
+   "\0"
+   /* _mesa_function_pool[15733]: InstrumentsBufferSGIX (dynamic) */
+   "ip\0"
+   "glInstrumentsBufferSGIX\0"
+   "\0"
+   /* _mesa_function_pool[15761]: VertexAttrib4NivARB (will be remapped) */
+   "ip\0"
+   "glVertexAttrib4Niv\0"
+   "glVertexAttrib4NivARB\0"
+   "\0"
+   /* _mesa_function_pool[15806]: GetAttachedShaders (will be remapped) */
+   "iipp\0"
+   "glGetAttachedShaders\0"
+   "\0"
+   /* _mesa_function_pool[15833]: GenVertexArraysAPPLE (will be remapped) */
+   "ip\0"
+   "glGenVertexArraysAPPLE\0"
+   "\0"
+   /* _mesa_function_pool[15860]: Materialiv (offset 172) */
+   "iip\0"
+   "glMaterialiv\0"
+   "\0"
+   /* _mesa_function_pool[15878]: PushClientAttrib (offset 335) */
+   "i\0"
+   "glPushClientAttrib\0"
+   "\0"
+   /* _mesa_function_pool[15900]: ProgramEnvParameters4fvEXT (will be remapped) */
+   "iiip\0"
+   "glProgramEnvParameters4fvEXT\0"
+   "\0"
+   /* _mesa_function_pool[15935]: TexCoord2fColor4fNormal3fVertex3fvSUN (dynamic) */
+   "pppp\0"
+   "glTexCoord2fColor4fNormal3fVertex3fvSUN\0"
+   "\0"
+   /* _mesa_function_pool[15981]: WindowPos2iMESA (will be remapped) */
+   "ii\0"
+   "glWindowPos2i\0"
+   "glWindowPos2iARB\0"
+   "glWindowPos2iMESA\0"
+   "\0"
+   /* _mesa_function_pool[16034]: SecondaryColor3fvEXT (will be remapped) */
+   "p\0"
+   "glSecondaryColor3fv\0"
+   "glSecondaryColor3fvEXT\0"
+   "\0"
+   /* _mesa_function_pool[16080]: PolygonMode (offset 174) */
+   "ii\0"
+   "glPolygonMode\0"
+   "\0"
+   /* _mesa_function_pool[16098]: CompressedTexSubImage1DARB (will be remapped) */
+   "iiiiiip\0"
+   "glCompressedTexSubImage1D\0"
+   "glCompressedTexSubImage1DARB\0"
+   "\0"
+   /* _mesa_function_pool[16162]: GetVertexAttribivNV (will be remapped) */
+   "iip\0"
+   "glGetVertexAttribivNV\0"
+   "\0"
+   /* _mesa_function_pool[16189]: GetProgramStringARB (will be remapped) */
+   "iip\0"
+   "glGetProgramStringARB\0"
+   "\0"
+   /* _mesa_function_pool[16216]: TexBumpParameterfvATI (will be remapped) */
+   "ip\0"
+   "glTexBumpParameterfvATI\0"
+   "\0"
+   /* _mesa_function_pool[16244]: CompileShaderARB (will be remapped) */
+   "i\0"
+   "glCompileShader\0"
+   "glCompileShaderARB\0"
+   "\0"
+   /* _mesa_function_pool[16282]: DeleteShader (will be remapped) */
+   "i\0"
+   "glDeleteShader\0"
+   "\0"
+   /* _mesa_function_pool[16300]: DisableClientState (offset 309) */
+   "i\0"
+   "glDisableClientState\0"
+   "\0"
+   /* _mesa_function_pool[16324]: TexGeni (offset 192) */
+   "iii\0"
+   "glTexGeni\0"
+   "\0"
+   /* _mesa_function_pool[16339]: TexGenf (offset 190) */
+   "iif\0"
+   "glTexGenf\0"
+   "\0"
+   /* _mesa_function_pool[16354]: Uniform3fARB (will be remapped) */
+   "ifff\0"
+   "glUniform3f\0"
+   "glUniform3fARB\0"
+   "\0"
+   /* _mesa_function_pool[16387]: TexGend (offset 188) */
+   "iid\0"
+   "glTexGend\0"
+   "\0"
+   /* _mesa_function_pool[16402]: ListParameterfvSGIX (dynamic) */
+   "iip\0"
+   "glListParameterfvSGIX\0"
+   "\0"
+   /* _mesa_function_pool[16429]: GetPolygonStipple (offset 274) */
+   "p\0"
+   "glGetPolygonStipple\0"
+   "\0"
+   /* _mesa_function_pool[16452]: Tangent3dvEXT (dynamic) */
+   "p\0"
+   "glTangent3dvEXT\0"
+   "\0"
+   /* _mesa_function_pool[16471]: GetVertexAttribfvNV (will be remapped) */
+   "iip\0"
+   "glGetVertexAttribfvNV\0"
+   "\0"
+   /* _mesa_function_pool[16498]: WindowPos3sMESA (will be remapped) */
+   "iii\0"
+   "glWindowPos3s\0"
+   "glWindowPos3sARB\0"
+   "glWindowPos3sMESA\0"
+   "\0"
+   /* _mesa_function_pool[16552]: VertexAttrib2svNV (will be remapped) */
+   "ip\0"
+   "glVertexAttrib2svNV\0"
+   "\0"
+   /* _mesa_function_pool[16576]: VertexAttribs1fvNV (will be remapped) */
+   "iip\0"
+   "glVertexAttribs1fvNV\0"
+   "\0"
+   /* _mesa_function_pool[16602]: TexCoord2fVertex3fvSUN (dynamic) */
+   "pp\0"
+   "glTexCoord2fVertex3fvSUN\0"
+   "\0"
+   /* _mesa_function_pool[16631]: WindowPos4sMESA (will be remapped) */
+   "iiii\0"
+   "glWindowPos4sMESA\0"
+   "\0"
+   /* _mesa_function_pool[16655]: VertexAttrib4NuivARB (will be remapped) */
+   "ip\0"
+   "glVertexAttrib4Nuiv\0"
+   "glVertexAttrib4NuivARB\0"
+   "\0"
+   /* _mesa_function_pool[16702]: ClientActiveTextureARB (offset 375) */
+   "i\0"
+   "glClientActiveTexture\0"
+   "glClientActiveTextureARB\0"
+   "\0"
+   /* _mesa_function_pool[16752]: PixelTexGenSGIX (will be remapped) */
+   "i\0"
+   "glPixelTexGenSGIX\0"
+   "\0"
+   /* _mesa_function_pool[16773]: ReplacementCodeusvSUN (dynamic) */
+   "p\0"
+   "glReplacementCodeusvSUN\0"
+   "\0"
+   /* _mesa_function_pool[16800]: Uniform4fARB (will be remapped) */
+   "iffff\0"
+   "glUniform4f\0"
+   "glUniform4fARB\0"
+   "\0"
+   /* _mesa_function_pool[16834]: Color4sv (offset 34) */
+   "p\0"
+   "glColor4sv\0"
+   "\0"
+   /* _mesa_function_pool[16848]: FlushMappedBufferRange (will be remapped) */
+   "iii\0"
+   "glFlushMappedBufferRange\0"
+   "\0"
+   /* _mesa_function_pool[16878]: IsProgramNV (will be remapped) */
+   "i\0"
+   "glIsProgramARB\0"
+   "glIsProgramNV\0"
+   "\0"
+   /* _mesa_function_pool[16910]: FlushMappedBufferRangeAPPLE (will be remapped) */
+   "iii\0"
+   "glFlushMappedBufferRangeAPPLE\0"
+   "\0"
+   /* _mesa_function_pool[16945]: PixelZoom (offset 246) */
+   "ff\0"
+   "glPixelZoom\0"
+   "\0"
+   /* _mesa_function_pool[16961]: ReplacementCodePointerSUN (dynamic) */
+   "iip\0"
+   "glReplacementCodePointerSUN\0"
+   "\0"
+   /* _mesa_function_pool[16994]: ProgramEnvParameter4dARB (will be remapped) */
+   "iidddd\0"
+   "glProgramEnvParameter4dARB\0"
+   "glProgramParameter4dNV\0"
+   "\0"
+   /* _mesa_function_pool[17052]: ColorTableParameterfv (offset 340) */
+   "iip\0"
+   "glColorTableParameterfv\0"
+   "glColorTableParameterfvSGI\0"
+   "\0"
+   /* _mesa_function_pool[17108]: FragmentLightModelfSGIX (dynamic) */
+   "if\0"
+   "glFragmentLightModelfSGIX\0"
+   "\0"
+   /* _mesa_function_pool[17138]: Binormal3bvEXT (dynamic) */
+   "p\0"
+   "glBinormal3bvEXT\0"
+   "\0"
+   /* _mesa_function_pool[17158]: PixelMapuiv (offset 252) */
+   "iip\0"
+   "glPixelMapuiv\0"
+   "\0"
+   /* _mesa_function_pool[17177]: Color3dv (offset 12) */
+   "p\0"
+   "glColor3dv\0"
+   "\0"
+   /* _mesa_function_pool[17191]: IsTexture (offset 330) */
+   "i\0"
+   "glIsTexture\0"
+   "glIsTextureEXT\0"
+   "\0"
+   /* _mesa_function_pool[17221]: VertexWeightfvEXT (dynamic) */
+   "p\0"
+   "glVertexWeightfvEXT\0"
+   "\0"
+   /* _mesa_function_pool[17244]: VertexAttrib1dARB (will be remapped) */
+   "id\0"
+   "glVertexAttrib1d\0"
+   "glVertexAttrib1dARB\0"
+   "\0"
+   /* _mesa_function_pool[17285]: ImageTransformParameterivHP (dynamic) */
+   "iip\0"
+   "glImageTransformParameterivHP\0"
+   "\0"
+   /* _mesa_function_pool[17320]: TexCoord4i (offset 122) */
+   "iiii\0"
+   "glTexCoord4i\0"
+   "\0"
+   /* _mesa_function_pool[17339]: DeleteQueriesARB (will be remapped) */
+   "ip\0"
+   "glDeleteQueries\0"
+   "glDeleteQueriesARB\0"
+   "\0"
+   /* _mesa_function_pool[17378]: Color4ubVertex2fSUN (dynamic) */
+   "iiiiff\0"
+   "glColor4ubVertex2fSUN\0"
+   "\0"
+   /* _mesa_function_pool[17408]: FragmentColorMaterialSGIX (dynamic) */
+   "ii\0"
+   "glFragmentColorMaterialSGIX\0"
+   "\0"
+   /* _mesa_function_pool[17440]: CurrentPaletteMatrixARB (dynamic) */
+   "i\0"
+   "glCurrentPaletteMatrixARB\0"
+   "\0"
+   /* _mesa_function_pool[17469]: GetMapdv (offset 266) */
+   "iip\0"
+   "glGetMapdv\0"
+   "\0"
+   /* _mesa_function_pool[17485]: SamplePatternSGIS (will be remapped) */
+   "i\0"
+   "glSamplePatternSGIS\0"
+   "glSamplePatternEXT\0"
+   "\0"
+   /* _mesa_function_pool[17527]: PixelStoref (offset 249) */
+   "if\0"
+   "glPixelStoref\0"
+   "\0"
+   /* _mesa_function_pool[17545]: IsQueryARB (will be remapped) */
+   "i\0"
+   "glIsQuery\0"
+   "glIsQueryARB\0"
+   "\0"
+   /* _mesa_function_pool[17571]: ReplacementCodeuiColor4ubVertex3fSUN (dynamic) */
+   "iiiiifff\0"
+   "glReplacementCodeuiColor4ubVertex3fSUN\0"
+   "\0"
+   /* _mesa_function_pool[17620]: PixelStorei (offset 250) */
+   "ii\0"
+   "glPixelStorei\0"
+   "\0"
+   /* _mesa_function_pool[17638]: VertexAttrib4usvARB (will be remapped) */
+   "ip\0"
+   "glVertexAttrib4usv\0"
+   "glVertexAttrib4usvARB\0"
+   "\0"
+   /* _mesa_function_pool[17683]: LinkProgramARB (will be remapped) */
+   "i\0"
+   "glLinkProgram\0"
+   "glLinkProgramARB\0"
+   "\0"
+   /* _mesa_function_pool[17717]: VertexAttrib2fNV (will be remapped) */
+   "iff\0"
+   "glVertexAttrib2fNV\0"
+   "\0"
+   /* _mesa_function_pool[17741]: ShaderSourceARB (will be remapped) */
+   "iipp\0"
+   "glShaderSource\0"
+   "glShaderSourceARB\0"
+   "\0"
+   /* _mesa_function_pool[17780]: FragmentMaterialiSGIX (dynamic) */
+   "iii\0"
+   "glFragmentMaterialiSGIX\0"
+   "\0"
+   /* _mesa_function_pool[17809]: EvalCoord2dv (offset 233) */
+   "p\0"
+   "glEvalCoord2dv\0"
+   "\0"
+   /* _mesa_function_pool[17827]: VertexAttrib3svARB (will be remapped) */
+   "ip\0"
+   "glVertexAttrib3sv\0"
+   "glVertexAttrib3svARB\0"
+   "\0"
+   /* _mesa_function_pool[17870]: ColorMaterial (offset 151) */
+   "ii\0"
+   "glColorMaterial\0"
+   "\0"
+   /* _mesa_function_pool[17890]: CompressedTexSubImage3DARB (will be remapped) */
+   "iiiiiiiiiip\0"
+   "glCompressedTexSubImage3D\0"
+   "glCompressedTexSubImage3DARB\0"
+   "\0"
+   /* _mesa_function_pool[17958]: WindowPos2ivMESA (will be remapped) */
+   "p\0"
+   "glWindowPos2iv\0"
+   "glWindowPos2ivARB\0"
+   "glWindowPos2ivMESA\0"
+   "\0"
+   /* _mesa_function_pool[18013]: IsFramebufferEXT (will be remapped) */
+   "i\0"
+   "glIsFramebuffer\0"
+   "glIsFramebufferEXT\0"
+   "\0"
+   /* _mesa_function_pool[18051]: Uniform4ivARB (will be remapped) */
+   "iip\0"
+   "glUniform4iv\0"
+   "glUniform4ivARB\0"
+   "\0"
+   /* _mesa_function_pool[18085]: GetVertexAttribdvARB (will be remapped) */
+   "iip\0"
+   "glGetVertexAttribdv\0"
+   "glGetVertexAttribdvARB\0"
+   "\0"
+   /* _mesa_function_pool[18133]: TexBumpParameterivATI (will be remapped) */
+   "ip\0"
+   "glTexBumpParameterivATI\0"
+   "\0"
+   /* _mesa_function_pool[18161]: GetSeparableFilter (offset 359) */
+   "iiippp\0"
+   "glGetSeparableFilter\0"
+   "glGetSeparableFilterEXT\0"
+   "\0"
+   /* _mesa_function_pool[18214]: Binormal3dEXT (dynamic) */
+   "ddd\0"
+   "glBinormal3dEXT\0"
+   "\0"
+   /* _mesa_function_pool[18235]: SpriteParameteriSGIX (dynamic) */
+   "ii\0"
+   "glSpriteParameteriSGIX\0"
+   "\0"
+   /* _mesa_function_pool[18262]: RequestResidentProgramsNV (will be remapped) */
+   "ip\0"
+   "glRequestResidentProgramsNV\0"
+   "\0"
+   /* _mesa_function_pool[18294]: TagSampleBufferSGIX (dynamic) */
+   "\0"
+   "glTagSampleBufferSGIX\0"
+   "\0"
+   /* _mesa_function_pool[18318]: ReplacementCodeusSUN (dynamic) */
+   "i\0"
+   "glReplacementCodeusSUN\0"
+   "\0"
+   /* _mesa_function_pool[18344]: FeedbackBuffer (offset 194) */
+   "iip\0"
+   "glFeedbackBuffer\0"
+   "\0"
+   /* _mesa_function_pool[18366]: RasterPos2iv (offset 67) */
+   "p\0"
+   "glRasterPos2iv\0"
+   "\0"
+   /* _mesa_function_pool[18384]: TexImage1D (offset 182) */
+   "iiiiiiip\0"
+   "glTexImage1D\0"
+   "\0"
+   /* _mesa_function_pool[18407]: ListParameterivSGIX (dynamic) */
+   "iip\0"
+   "glListParameterivSGIX\0"
+   "\0"
+   /* _mesa_function_pool[18434]: MultiDrawElementsEXT (will be remapped) */
+   "ipipi\0"
+   "glMultiDrawElements\0"
+   "glMultiDrawElementsEXT\0"
+   "\0"
+   /* _mesa_function_pool[18484]: Color3s (offset 17) */
+   "iii\0"
+   "glColor3s\0"
+   "\0"
+   /* _mesa_function_pool[18499]: Uniform1ivARB (will be remapped) */
+   "iip\0"
+   "glUniform1iv\0"
+   "glUniform1ivARB\0"
+   "\0"
+   /* _mesa_function_pool[18533]: WindowPos2sMESA (will be remapped) */
+   "ii\0"
+   "glWindowPos2s\0"
+   "glWindowPos2sARB\0"
+   "glWindowPos2sMESA\0"
+   "\0"
+   /* _mesa_function_pool[18586]: WeightusvARB (dynamic) */
+   "ip\0"
+   "glWeightusvARB\0"
+   "\0"
+   /* _mesa_function_pool[18605]: TexCoordPointer (offset 320) */
+   "iiip\0"
+   "glTexCoordPointer\0"
+   "\0"
+   /* _mesa_function_pool[18629]: FogCoordPointerEXT (will be remapped) */
+   "iip\0"
+   "glFogCoordPointer\0"
+   "glFogCoordPointerEXT\0"
+   "\0"
+   /* _mesa_function_pool[18673]: IndexMaterialEXT (dynamic) */
+   "ii\0"
+   "glIndexMaterialEXT\0"
+   "\0"
+   /* _mesa_function_pool[18696]: Color3i (offset 15) */
+   "iii\0"
+   "glColor3i\0"
+   "\0"
+   /* _mesa_function_pool[18711]: FrontFace (offset 157) */
+   "i\0"
+   "glFrontFace\0"
+   "\0"
+   /* _mesa_function_pool[18726]: EvalCoord2d (offset 232) */
+   "dd\0"
+   "glEvalCoord2d\0"
+   "\0"
+   /* _mesa_function_pool[18744]: SecondaryColor3ubvEXT (will be remapped) */
+   "p\0"
+   "glSecondaryColor3ubv\0"
+   "glSecondaryColor3ubvEXT\0"
+   "\0"
+   /* _mesa_function_pool[18792]: EvalCoord2f (offset 234) */
+   "ff\0"
+   "glEvalCoord2f\0"
+   "\0"
+   /* _mesa_function_pool[18810]: VertexAttrib4dvARB (will be remapped) */
+   "ip\0"
+   "glVertexAttrib4dv\0"
+   "glVertexAttrib4dvARB\0"
+   "\0"
+   /* _mesa_function_pool[18853]: BindAttribLocationARB (will be remapped) */
+   "iip\0"
+   "glBindAttribLocation\0"
+   "glBindAttribLocationARB\0"
+   "\0"
+   /* _mesa_function_pool[18903]: Color3b (offset 9) */
+   "iii\0"
+   "glColor3b\0"
+   "\0"
+   /* _mesa_function_pool[18918]: MultiTexCoord2dARB (offset 384) */
+   "idd\0"
+   "glMultiTexCoord2d\0"
+   "glMultiTexCoord2dARB\0"
+   "\0"
+   /* _mesa_function_pool[18962]: ExecuteProgramNV (will be remapped) */
+   "iip\0"
+   "glExecuteProgramNV\0"
+   "\0"
+   /* _mesa_function_pool[18986]: Color3f (offset 13) */
+   "fff\0"
+   "glColor3f\0"
+   "\0"
+   /* _mesa_function_pool[19001]: LightEnviSGIX (dynamic) */
+   "ii\0"
+   "glLightEnviSGIX\0"
+   "\0"
+   /* _mesa_function_pool[19021]: Color3d (offset 11) */
+   "ddd\0"
+   "glColor3d\0"
+   "\0"
+   /* _mesa_function_pool[19036]: Normal3dv (offset 55) */
+   "p\0"
+   "glNormal3dv\0"
+   "\0"
+   /* _mesa_function_pool[19051]: Lightf (offset 159) */
+   "iif\0"
+   "glLightf\0"
+   "\0"
+   /* _mesa_function_pool[19065]: ReplacementCodeuiSUN (dynamic) */
+   "i\0"
+   "glReplacementCodeuiSUN\0"
+   "\0"
+   /* _mesa_function_pool[19091]: MatrixMode (offset 293) */
+   "i\0"
+   "glMatrixMode\0"
+   "\0"
+   /* _mesa_function_pool[19107]: GetPixelMapusv (offset 273) */
+   "ip\0"
+   "glGetPixelMapusv\0"
+   "\0"
+   /* _mesa_function_pool[19128]: Lighti (offset 161) */
+   "iii\0"
+   "glLighti\0"
+   "\0"
+   /* _mesa_function_pool[19142]: VertexAttribPointerNV (will be remapped) */
+   "iiiip\0"
+   "glVertexAttribPointerNV\0"
+   "\0"
+   /* _mesa_function_pool[19173]: GetBooleanIndexedvEXT (will be remapped) */
+   "iip\0"
+   "glGetBooleanIndexedvEXT\0"
+   "\0"
+   /* _mesa_function_pool[19202]: GetFramebufferAttachmentParameterivEXT (will be remapped) */
+   "iiip\0"
+   "glGetFramebufferAttachmentParameteriv\0"
+   "glGetFramebufferAttachmentParameterivEXT\0"
+   "\0"
+   /* _mesa_function_pool[19287]: PixelTransformParameterfEXT (dynamic) */
+   "iif\0"
+   "glPixelTransformParameterfEXT\0"
+   "\0"
+   /* _mesa_function_pool[19322]: MultiTexCoord4dvARB (offset 401) */
+   "ip\0"
+   "glMultiTexCoord4dv\0"
+   "glMultiTexCoord4dvARB\0"
+   "\0"
+   /* _mesa_function_pool[19367]: PixelTransformParameteriEXT (dynamic) */
+   "iii\0"
+   "glPixelTransformParameteriEXT\0"
+   "\0"
+   /* _mesa_function_pool[19402]: GetDoublev (offset 260) */
+   "ip\0"
+   "glGetDoublev\0"
+   "\0"
+   /* _mesa_function_pool[19419]: MultMatrixd (offset 295) */
+   "p\0"
+   "glMultMatrixd\0"
+   "\0"
+   /* _mesa_function_pool[19436]: MultMatrixf (offset 294) */
+   "p\0"
+   "glMultMatrixf\0"
+   "\0"
+   /* _mesa_function_pool[19453]: TexCoord2fColor4ubVertex3fSUN (dynamic) */
+   "ffiiiifff\0"
+   "glTexCoord2fColor4ubVertex3fSUN\0"
+   "\0"
+   /* _mesa_function_pool[19496]: Uniform1iARB (will be remapped) */
+   "ii\0"
+   "glUniform1i\0"
+   "glUniform1iARB\0"
+   "\0"
+   /* _mesa_function_pool[19527]: VertexAttribPointerARB (will be remapped) */
+   "iiiiip\0"
+   "glVertexAttribPointer\0"
+   "glVertexAttribPointerARB\0"
+   "\0"
+   /* _mesa_function_pool[19582]: SharpenTexFuncSGIS (dynamic) */
+   "iip\0"
+   "glSharpenTexFuncSGIS\0"
+   "\0"
+   /* _mesa_function_pool[19608]: MultiTexCoord4fvARB (offset 403) */
+   "ip\0"
+   "glMultiTexCoord4fv\0"
+   "glMultiTexCoord4fvARB\0"
+   "\0"
+   /* _mesa_function_pool[19653]: UniformMatrix2x3fv (will be remapped) */
+   "iiip\0"
+   "glUniformMatrix2x3fv\0"
+   "\0"
+   /* _mesa_function_pool[19680]: TrackMatrixNV (will be remapped) */
+   "iiii\0"
+   "glTrackMatrixNV\0"
+   "\0"
+   /* _mesa_function_pool[19702]: CombinerParameteriNV (will be remapped) */
+   "ii\0"
+   "glCombinerParameteriNV\0"
+   "\0"
+   /* _mesa_function_pool[19729]: DeleteAsyncMarkersSGIX (dynamic) */
+   "ii\0"
+   "glDeleteAsyncMarkersSGIX\0"
+   "\0"
+   /* _mesa_function_pool[19758]: IsAsyncMarkerSGIX (dynamic) */
+   "i\0"
+   "glIsAsyncMarkerSGIX\0"
+   "\0"
+   /* _mesa_function_pool[19781]: FrameZoomSGIX (dynamic) */
+   "i\0"
+   "glFrameZoomSGIX\0"
+   "\0"
+   /* _mesa_function_pool[19800]: Normal3fVertex3fvSUN (dynamic) */
+   "pp\0"
+   "glNormal3fVertex3fvSUN\0"
+   "\0"
+   /* _mesa_function_pool[19827]: RasterPos4sv (offset 85) */
+   "p\0"
+   "glRasterPos4sv\0"
+   "\0"
+   /* _mesa_function_pool[19845]: VertexAttrib4NsvARB (will be remapped) */
+   "ip\0"
+   "glVertexAttrib4Nsv\0"
+   "glVertexAttrib4NsvARB\0"
+   "\0"
+   /* _mesa_function_pool[19890]: VertexAttrib3fvARB (will be remapped) */
+   "ip\0"
+   "glVertexAttrib3fv\0"
+   "glVertexAttrib3fvARB\0"
+   "\0"
+   /* _mesa_function_pool[19933]: ClearColor (offset 206) */
+   "ffff\0"
+   "glClearColor\0"
+   "\0"
+   /* _mesa_function_pool[19952]: GetSynciv (will be remapped) */
+   "iiipp\0"
+   "glGetSynciv\0"
+   "\0"
+   /* _mesa_function_pool[19971]: DeleteFramebuffersEXT (will be remapped) */
+   "ip\0"
+   "glDeleteFramebuffers\0"
+   "glDeleteFramebuffersEXT\0"
+   "\0"
+   /* _mesa_function_pool[20020]: GlobalAlphaFactorsSUN (dynamic) */
+   "i\0"
+   "glGlobalAlphaFactorsSUN\0"
+   "\0"
+   /* _mesa_function_pool[20047]: IsEnabledIndexedEXT (will be remapped) */
+   "ii\0"
+   "glIsEnabledIndexedEXT\0"
+   "\0"
+   /* _mesa_function_pool[20073]: TexEnviv (offset 187) */
+   "iip\0"
+   "glTexEnviv\0"
+   "\0"
+   /* _mesa_function_pool[20089]: TexSubImage3D (offset 372) */
+   "iiiiiiiiiip\0"
+   "glTexSubImage3D\0"
+   "glTexSubImage3DEXT\0"
+   "\0"
+   /* _mesa_function_pool[20137]: Tangent3fEXT (dynamic) */
+   "fff\0"
+   "glTangent3fEXT\0"
+   "\0"
+   /* _mesa_function_pool[20157]: SecondaryColor3uivEXT (will be remapped) */
+   "p\0"
+   "glSecondaryColor3uiv\0"
+   "glSecondaryColor3uivEXT\0"
+   "\0"
+   /* _mesa_function_pool[20205]: MatrixIndexubvARB (dynamic) */
+   "ip\0"
+   "glMatrixIndexubvARB\0"
+   "\0"
+   /* _mesa_function_pool[20229]: Color4fNormal3fVertex3fSUN (dynamic) */
+   "ffffffffff\0"
+   "glColor4fNormal3fVertex3fSUN\0"
+   "\0"
+   /* _mesa_function_pool[20270]: PixelTexGenParameterfSGIS (will be remapped) */
+   "if\0"
+   "glPixelTexGenParameterfSGIS\0"
+   "\0"
+   /* _mesa_function_pool[20302]: CreateShader (will be remapped) */
+   "i\0"
+   "glCreateShader\0"
+   "\0"
+   /* _mesa_function_pool[20320]: GetColorTableParameterfv (offset 344) */
+   "iip\0"
+   "glGetColorTableParameterfv\0"
+   "glGetColorTableParameterfvSGI\0"
+   "glGetColorTableParameterfvEXT\0"
+   "\0"
+   /* _mesa_function_pool[20412]: FragmentLightModelfvSGIX (dynamic) */
+   "ip\0"
+   "glFragmentLightModelfvSGIX\0"
+   "\0"
+   /* _mesa_function_pool[20443]: Bitmap (offset 8) */
+   "iiffffp\0"
+   "glBitmap\0"
+   "\0"
+   /* _mesa_function_pool[20461]: MultiTexCoord3fARB (offset 394) */
+   "ifff\0"
+   "glMultiTexCoord3f\0"
+   "glMultiTexCoord3fARB\0"
+   "\0"
+   /* _mesa_function_pool[20506]: GetTexLevelParameterfv (offset 284) */
+   "iiip\0"
+   "glGetTexLevelParameterfv\0"
+   "\0"
+   /* _mesa_function_pool[20537]: GetPixelTexGenParameterfvSGIS (will be remapped) */
+   "ip\0"
+   "glGetPixelTexGenParameterfvSGIS\0"
+   "\0"
+   /* _mesa_function_pool[20573]: GenFramebuffersEXT (will be remapped) */
+   "ip\0"
+   "glGenFramebuffers\0"
+   "glGenFramebuffersEXT\0"
+   "\0"
+   /* _mesa_function_pool[20616]: GetProgramParameterdvNV (will be remapped) */
+   "iiip\0"
+   "glGetProgramParameterdvNV\0"
+   "\0"
+   /* _mesa_function_pool[20648]: Vertex2sv (offset 133) */
+   "p\0"
+   "glVertex2sv\0"
+   "\0"
+   /* _mesa_function_pool[20663]: GetIntegerv (offset 263) */
+   "ip\0"
+   "glGetIntegerv\0"
+   "\0"
+   /* _mesa_function_pool[20681]: IsVertexArrayAPPLE (will be remapped) */
+   "i\0"
+   "glIsVertexArray\0"
+   "glIsVertexArrayAPPLE\0"
+   "\0"
+   /* _mesa_function_pool[20721]: FragmentLightfvSGIX (dynamic) */
+   "iip\0"
+   "glFragmentLightfvSGIX\0"
+   "\0"
+   /* _mesa_function_pool[20748]: DetachShader (will be remapped) */
+   "ii\0"
+   "glDetachShader\0"
+   "\0"
+   /* _mesa_function_pool[20767]: VertexAttrib4NubARB (will be remapped) */
+   "iiiii\0"
+   "glVertexAttrib4Nub\0"
+   "glVertexAttrib4NubARB\0"
+   "\0"
+   /* _mesa_function_pool[20815]: GetProgramEnvParameterfvARB (will be remapped) */
+   "iip\0"
+   "glGetProgramEnvParameterfvARB\0"
+   "\0"
+   /* _mesa_function_pool[20850]: GetTrackMatrixivNV (will be remapped) */
+   "iiip\0"
+   "glGetTrackMatrixivNV\0"
+   "\0"
+   /* _mesa_function_pool[20877]: VertexAttrib3svNV (will be remapped) */
+   "ip\0"
+   "glVertexAttrib3svNV\0"
+   "\0"
+   /* _mesa_function_pool[20901]: Uniform4fvARB (will be remapped) */
+   "iip\0"
+   "glUniform4fv\0"
+   "glUniform4fvARB\0"
+   "\0"
+   /* _mesa_function_pool[20935]: MultTransposeMatrixfARB (will be remapped) */
+   "p\0"
+   "glMultTransposeMatrixf\0"
+   "glMultTransposeMatrixfARB\0"
+   "\0"
+   /* _mesa_function_pool[20987]: GetTexEnviv (offset 277) */
+   "iip\0"
+   "glGetTexEnviv\0"
+   "\0"
+   /* _mesa_function_pool[21006]: ColorFragmentOp1ATI (will be remapped) */
+   "iiiiiii\0"
+   "glColorFragmentOp1ATI\0"
+   "\0"
+   /* _mesa_function_pool[21037]: GetUniformfvARB (will be remapped) */
+   "iip\0"
+   "glGetUniformfv\0"
+   "glGetUniformfvARB\0"
+   "\0"
+   /* _mesa_function_pool[21075]: PopClientAttrib (offset 334) */
+   "\0"
+   "glPopClientAttrib\0"
+   "\0"
+   /* _mesa_function_pool[21095]: ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (dynamic) */
+   "iffffffffffff\0"
+   "glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN\0"
+   "\0"
+   /* _mesa_function_pool[21166]: DetachObjectARB (will be remapped) */
+   "ii\0"
+   "glDetachObjectARB\0"
+   "\0"
+   /* _mesa_function_pool[21188]: VertexBlendARB (dynamic) */
+   "i\0"
+   "glVertexBlendARB\0"
+   "\0"
+   /* _mesa_function_pool[21208]: WindowPos3iMESA (will be remapped) */
+   "iii\0"
+   "glWindowPos3i\0"
+   "glWindowPos3iARB\0"
+   "glWindowPos3iMESA\0"
+   "\0"
+   /* _mesa_function_pool[21262]: SeparableFilter2D (offset 360) */
+   "iiiiiipp\0"
+   "glSeparableFilter2D\0"
+   "glSeparableFilter2DEXT\0"
+   "\0"
+   /* _mesa_function_pool[21315]: ReplacementCodeuiColor4ubVertex3fvSUN (dynamic) */
+   "ppp\0"
+   "glReplacementCodeuiColor4ubVertex3fvSUN\0"
+   "\0"
+   /* _mesa_function_pool[21360]: Map1d (offset 220) */
+   "iddiip\0"
+   "glMap1d\0"
+   "\0"
+   /* _mesa_function_pool[21376]: Map1f (offset 221) */
+   "iffiip\0"
+   "glMap1f\0"
+   "\0"
+   /* _mesa_function_pool[21392]: CompressedTexImage2DARB (will be remapped) */
+   "iiiiiiip\0"
+   "glCompressedTexImage2D\0"
+   "glCompressedTexImage2DARB\0"
+   "\0"
+   /* _mesa_function_pool[21451]: ArrayElement (offset 306) */
+   "i\0"
+   "glArrayElement\0"
+   "glArrayElementEXT\0"
+   "\0"
+   /* _mesa_function_pool[21487]: TexImage2D (offset 183) */
+   "iiiiiiiip\0"
+   "glTexImage2D\0"
+   "\0"
+   /* _mesa_function_pool[21511]: DepthBoundsEXT (will be remapped) */
+   "dd\0"
+   "glDepthBoundsEXT\0"
+   "\0"
+   /* _mesa_function_pool[21532]: ProgramParameters4fvNV (will be remapped) */
+   "iiip\0"
+   "glProgramParameters4fvNV\0"
+   "\0"
+   /* _mesa_function_pool[21563]: DeformationMap3fSGIX (dynamic) */
+   "iffiiffiiffiip\0"
+   "glDeformationMap3fSGIX\0"
+   "\0"
+   /* _mesa_function_pool[21602]: GetProgramivNV (will be remapped) */
+   "iip\0"
+   "glGetProgramivNV\0"
+   "\0"
+   /* _mesa_function_pool[21624]: GetMinmaxParameteriv (offset 366) */
+   "iip\0"
+   "glGetMinmaxParameteriv\0"
+   "glGetMinmaxParameterivEXT\0"
+   "\0"
+   /* _mesa_function_pool[21678]: PixelTransferf (offset 247) */
+   "if\0"
+   "glPixelTransferf\0"
+   "\0"
+   /* _mesa_function_pool[21699]: CopyTexImage1D (offset 323) */
+   "iiiiiii\0"
+   "glCopyTexImage1D\0"
+   "glCopyTexImage1DEXT\0"
+   "\0"
+   /* _mesa_function_pool[21745]: PushMatrix (offset 298) */
+   "\0"
+   "glPushMatrix\0"
+   "\0"
+   /* _mesa_function_pool[21760]: Fogiv (offset 156) */
+   "ip\0"
+   "glFogiv\0"
+   "\0"
+   /* _mesa_function_pool[21772]: TexCoord1dv (offset 95) */
+   "p\0"
+   "glTexCoord1dv\0"
+   "\0"
+   /* _mesa_function_pool[21789]: AlphaFragmentOp3ATI (will be remapped) */
+   "iiiiiiiiiiii\0"
+   "glAlphaFragmentOp3ATI\0"
+   "\0"
+   /* _mesa_function_pool[21825]: PixelTransferi (offset 248) */
+   "ii\0"
+   "glPixelTransferi\0"
+   "\0"
+   /* _mesa_function_pool[21846]: GetVertexAttribdvNV (will be remapped) */
+   "iip\0"
+   "glGetVertexAttribdvNV\0"
+   "\0"
+   /* _mesa_function_pool[21873]: VertexAttrib3fvNV (will be remapped) */
+   "ip\0"
+   "glVertexAttrib3fvNV\0"
+   "\0"
+   /* _mesa_function_pool[21897]: Rotatef (offset 300) */
+   "ffff\0"
+   "glRotatef\0"
+   "\0"
+   /* _mesa_function_pool[21913]: GetFinalCombinerInputParameterivNV (will be remapped) */
+   "iip\0"
+   "glGetFinalCombinerInputParameterivNV\0"
+   "\0"
+   /* _mesa_function_pool[21955]: Vertex3i (offset 138) */
+   "iii\0"
+   "glVertex3i\0"
+   "\0"
+   /* _mesa_function_pool[21971]: Vertex3f (offset 136) */
+   "fff\0"
+   "glVertex3f\0"
+   "\0"
+   /* _mesa_function_pool[21987]: Clear (offset 203) */
+   "i\0"
+   "glClear\0"
+   "\0"
+   /* _mesa_function_pool[21998]: Vertex3d (offset 134) */
+   "ddd\0"
+   "glVertex3d\0"
+   "\0"
+   /* _mesa_function_pool[22014]: GetMapParameterivNV (dynamic) */
+   "iip\0"
+   "glGetMapParameterivNV\0"
+   "\0"
+   /* _mesa_function_pool[22041]: Uniform4iARB (will be remapped) */
+   "iiiii\0"
+   "glUniform4i\0"
+   "glUniform4iARB\0"
+   "\0"
+   /* _mesa_function_pool[22075]: ReadBuffer (offset 254) */
+   "i\0"
+   "glReadBuffer\0"
+   "\0"
+   /* _mesa_function_pool[22091]: ConvolutionParameteri (offset 352) */
+   "iii\0"
+   "glConvolutionParameteri\0"
+   "glConvolutionParameteriEXT\0"
+   "\0"
+   /* _mesa_function_pool[22147]: Ortho (offset 296) */
+   "dddddd\0"
+   "glOrtho\0"
+   "\0"
+   /* _mesa_function_pool[22163]: Binormal3sEXT (dynamic) */
+   "iii\0"
+   "glBinormal3sEXT\0"
+   "\0"
+   /* _mesa_function_pool[22184]: ListBase (offset 6) */
+   "i\0"
+   "glListBase\0"
+   "\0"
+   /* _mesa_function_pool[22198]: Vertex3s (offset 140) */
+   "iii\0"
+   "glVertex3s\0"
+   "\0"
+   /* _mesa_function_pool[22214]: ConvolutionParameterf (offset 350) */
+   "iif\0"
+   "glConvolutionParameterf\0"
+   "glConvolutionParameterfEXT\0"
+   "\0"
+   /* _mesa_function_pool[22270]: GetColorTableParameteriv (offset 345) */
+   "iip\0"
+   "glGetColorTableParameteriv\0"
+   "glGetColorTableParameterivSGI\0"
+   "glGetColorTableParameterivEXT\0"
+   "\0"
+   /* _mesa_function_pool[22362]: ProgramEnvParameter4dvARB (will be remapped) */
+   "iip\0"
+   "glProgramEnvParameter4dvARB\0"
+   "glProgramParameter4dvNV\0"
+   "\0"
+   /* _mesa_function_pool[22419]: ShadeModel (offset 177) */
+   "i\0"
+   "glShadeModel\0"
+   "\0"
+   /* _mesa_function_pool[22435]: VertexAttribs2fvNV (will be remapped) */
+   "iip\0"
+   "glVertexAttribs2fvNV\0"
+   "\0"
+   /* _mesa_function_pool[22461]: Rectiv (offset 91) */
+   "pp\0"
+   "glRectiv\0"
+   "\0"
+   /* _mesa_function_pool[22474]: UseProgramObjectARB (will be remapped) */
+   "i\0"
+   "glUseProgram\0"
+   "glUseProgramObjectARB\0"
+   "\0"
+   /* _mesa_function_pool[22512]: GetMapParameterfvNV (dynamic) */
+   "iip\0"
+   "glGetMapParameterfvNV\0"
+   "\0"
+   /* _mesa_function_pool[22539]: EndConditionalRenderNV (will be remapped) */
+   "\0"
+   "glEndConditionalRenderNV\0"
+   "\0"
+   /* _mesa_function_pool[22566]: PassTexCoordATI (will be remapped) */
+   "iii\0"
+   "glPassTexCoordATI\0"
+   "\0"
+   /* _mesa_function_pool[22589]: DeleteProgram (will be remapped) */
+   "i\0"
+   "glDeleteProgram\0"
+   "\0"
+   /* _mesa_function_pool[22608]: Tangent3ivEXT (dynamic) */
+   "p\0"
+   "glTangent3ivEXT\0"
+   "\0"
+   /* _mesa_function_pool[22627]: Tangent3dEXT (dynamic) */
+   "ddd\0"
+   "glTangent3dEXT\0"
+   "\0"
+   /* _mesa_function_pool[22647]: SecondaryColor3dvEXT (will be remapped) */
+   "p\0"
+   "glSecondaryColor3dv\0"
+   "glSecondaryColor3dvEXT\0"
+   "\0"
+   /* _mesa_function_pool[22693]: Vertex2fv (offset 129) */
+   "p\0"
+   "glVertex2fv\0"
+   "\0"
+   /* _mesa_function_pool[22708]: MultiDrawArraysEXT (will be remapped) */
+   "ippi\0"
+   "glMultiDrawArrays\0"
+   "glMultiDrawArraysEXT\0"
+   "\0"
+   /* _mesa_function_pool[22753]: BindRenderbufferEXT (will be remapped) */
+   "ii\0"
+   "glBindRenderbuffer\0"
+   "glBindRenderbufferEXT\0"
+   "\0"
+   /* _mesa_function_pool[22798]: MultiTexCoord4dARB (offset 400) */
+   "idddd\0"
+   "glMultiTexCoord4d\0"
+   "glMultiTexCoord4dARB\0"
+   "\0"
+   /* _mesa_function_pool[22844]: Vertex3sv (offset 141) */
+   "p\0"
+   "glVertex3sv\0"
+   "\0"
+   /* _mesa_function_pool[22859]: SecondaryColor3usEXT (will be remapped) */
+   "iii\0"
+   "glSecondaryColor3us\0"
+   "glSecondaryColor3usEXT\0"
+   "\0"
+   /* _mesa_function_pool[22907]: ProgramLocalParameter4fvARB (will be remapped) */
+   "iip\0"
+   "glProgramLocalParameter4fvARB\0"
+   "\0"
+   /* _mesa_function_pool[22942]: DeleteProgramsNV (will be remapped) */
+   "ip\0"
+   "glDeleteProgramsARB\0"
+   "glDeleteProgramsNV\0"
+   "\0"
+   /* _mesa_function_pool[22985]: EvalMesh1 (offset 236) */
+   "iii\0"
+   "glEvalMesh1\0"
+   "\0"
+   /* _mesa_function_pool[23002]: MultiTexCoord1sARB (offset 382) */
+   "ii\0"
+   "glMultiTexCoord1s\0"
+   "glMultiTexCoord1sARB\0"
+   "\0"
+   /* _mesa_function_pool[23045]: ReplacementCodeuiColor3fVertex3fSUN (dynamic) */
+   "iffffff\0"
+   "glReplacementCodeuiColor3fVertex3fSUN\0"
+   "\0"
+   /* _mesa_function_pool[23092]: GetVertexAttribPointervNV (will be remapped) */
+   "iip\0"
+   "glGetVertexAttribPointerv\0"
+   "glGetVertexAttribPointervARB\0"
+   "glGetVertexAttribPointervNV\0"
+   "\0"
+   /* _mesa_function_pool[23180]: DisableIndexedEXT (will be remapped) */
+   "ii\0"
+   "glDisableIndexedEXT\0"
+   "\0"
+   /* _mesa_function_pool[23204]: MultiTexCoord1dvARB (offset 377) */
+   "ip\0"
+   "glMultiTexCoord1dv\0"
+   "glMultiTexCoord1dvARB\0"
+   "\0"
+   /* _mesa_function_pool[23249]: Uniform2iARB (will be remapped) */
+   "iii\0"
+   "glUniform2i\0"
+   "glUniform2iARB\0"
+   "\0"
+   /* _mesa_function_pool[23281]: Vertex2iv (offset 131) */
+   "p\0"
+   "glVertex2iv\0"
+   "\0"
+   /* _mesa_function_pool[23296]: GetProgramStringNV (will be remapped) */
+   "iip\0"
+   "glGetProgramStringNV\0"
+   "\0"
+   /* _mesa_function_pool[23322]: ColorPointerEXT (will be remapped) */
+   "iiiip\0"
+   "glColorPointerEXT\0"
+   "\0"
+   /* _mesa_function_pool[23347]: LineWidth (offset 168) */
+   "f\0"
+   "glLineWidth\0"
+   "\0"
+   /* _mesa_function_pool[23362]: MapBufferARB (will be remapped) */
+   "ii\0"
+   "glMapBuffer\0"
+   "glMapBufferARB\0"
+   "\0"
+   /* _mesa_function_pool[23393]: MultiDrawElementsBaseVertex (will be remapped) */
+   "ipipip\0"
+   "glMultiDrawElementsBaseVertex\0"
+   "\0"
+   /* _mesa_function_pool[23431]: Binormal3svEXT (dynamic) */
+   "p\0"
+   "glBinormal3svEXT\0"
+   "\0"
+   /* _mesa_function_pool[23451]: ApplyTextureEXT (dynamic) */
+   "i\0"
+   "glApplyTextureEXT\0"
+   "\0"
+   /* _mesa_function_pool[23472]: TexGendv (offset 189) */
+   "iip\0"
+   "glTexGendv\0"
+   "\0"
+   /* _mesa_function_pool[23488]: EnableIndexedEXT (will be remapped) */
+   "ii\0"
+   "glEnableIndexedEXT\0"
+   "\0"
+   /* _mesa_function_pool[23511]: TextureMaterialEXT (dynamic) */
+   "ii\0"
+   "glTextureMaterialEXT\0"
+   "\0"
+   /* _mesa_function_pool[23536]: TextureLightEXT (dynamic) */
+   "i\0"
+   "glTextureLightEXT\0"
+   "\0"
+   /* _mesa_function_pool[23557]: ResetMinmax (offset 370) */
+   "i\0"
+   "glResetMinmax\0"
+   "glResetMinmaxEXT\0"
+   "\0"
+   /* _mesa_function_pool[23591]: SpriteParameterfSGIX (dynamic) */
+   "if\0"
+   "glSpriteParameterfSGIX\0"
+   "\0"
+   /* _mesa_function_pool[23618]: EnableClientState (offset 313) */
+   "i\0"
+   "glEnableClientState\0"
+   "\0"
+   /* _mesa_function_pool[23641]: VertexAttrib4sNV (will be remapped) */
+   "iiiii\0"
+   "glVertexAttrib4sNV\0"
+   "\0"
+   /* _mesa_function_pool[23667]: GetConvolutionParameterfv (offset 357) */
+   "iip\0"
+   "glGetConvolutionParameterfv\0"
+   "glGetConvolutionParameterfvEXT\0"
+   "\0"
+   /* _mesa_function_pool[23731]: VertexAttribs4dvNV (will be remapped) */
+   "iip\0"
+   "glVertexAttribs4dvNV\0"
+   "\0"
+   /* _mesa_function_pool[23757]: MultiModeDrawArraysIBM (will be remapped) */
+   "pppii\0"
+   "glMultiModeDrawArraysIBM\0"
+   "\0"
+   /* _mesa_function_pool[23789]: VertexAttrib4dARB (will be remapped) */
+   "idddd\0"
+   "glVertexAttrib4d\0"
+   "glVertexAttrib4dARB\0"
+   "\0"
+   /* _mesa_function_pool[23833]: GetTexBumpParameterfvATI (will be remapped) */
+   "ip\0"
+   "glGetTexBumpParameterfvATI\0"
+   "\0"
+   /* _mesa_function_pool[23864]: ProgramNamedParameter4dNV (will be remapped) */
+   "iipdddd\0"
+   "glProgramNamedParameter4dNV\0"
+   "\0"
+   /* _mesa_function_pool[23901]: GetMaterialfv (offset 269) */
+   "iip\0"
+   "glGetMaterialfv\0"
+   "\0"
+   /* _mesa_function_pool[23922]: VertexWeightfEXT (dynamic) */
+   "f\0"
+   "glVertexWeightfEXT\0"
+   "\0"
+   /* _mesa_function_pool[23944]: Binormal3fEXT (dynamic) */
+   "fff\0"
+   "glBinormal3fEXT\0"
+   "\0"
+   /* _mesa_function_pool[23965]: CallList (offset 2) */
+   "i\0"
+   "glCallList\0"
+   "\0"
+   /* _mesa_function_pool[23979]: Materialfv (offset 170) */
+   "iip\0"
+   "glMaterialfv\0"
+   "\0"
+   /* _mesa_function_pool[23997]: TexCoord3fv (offset 113) */
+   "p\0"
+   "glTexCoord3fv\0"
+   "\0"
+   /* _mesa_function_pool[24014]: FogCoordfvEXT (will be remapped) */
+   "p\0"
+   "glFogCoordfv\0"
+   "glFogCoordfvEXT\0"
+   "\0"
+   /* _mesa_function_pool[24046]: MultiTexCoord1ivARB (offset 381) */
+   "ip\0"
+   "glMultiTexCoord1iv\0"
+   "glMultiTexCoord1ivARB\0"
+   "\0"
+   /* _mesa_function_pool[24091]: SecondaryColor3ubEXT (will be remapped) */
+   "iii\0"
+   "glSecondaryColor3ub\0"
+   "glSecondaryColor3ubEXT\0"
+   "\0"
+   /* _mesa_function_pool[24139]: MultiTexCoord2ivARB (offset 389) */
+   "ip\0"
+   "glMultiTexCoord2iv\0"
+   "glMultiTexCoord2ivARB\0"
+   "\0"
+   /* _mesa_function_pool[24184]: FogFuncSGIS (dynamic) */
+   "ip\0"
+   "glFogFuncSGIS\0"
+   "\0"
+   /* _mesa_function_pool[24202]: CopyTexSubImage2D (offset 326) */
+   "iiiiiiii\0"
+   "glCopyTexSubImage2D\0"
+   "glCopyTexSubImage2DEXT\0"
+   "\0"
+   /* _mesa_function_pool[24255]: GetObjectParameterivARB (will be remapped) */
+   "iip\0"
+   "glGetObjectParameterivARB\0"
+   "\0"
+   /* _mesa_function_pool[24286]: Color3iv (offset 16) */
+   "p\0"
+   "glColor3iv\0"
+   "\0"
+   /* _mesa_function_pool[24300]: TexCoord4fVertex4fSUN (dynamic) */
+   "ffffffff\0"
+   "glTexCoord4fVertex4fSUN\0"
+   "\0"
+   /* _mesa_function_pool[24334]: DrawElements (offset 311) */
+   "iiip\0"
+   "glDrawElements\0"
+   "\0"
+   /* _mesa_function_pool[24355]: BindVertexArrayAPPLE (will be remapped) */
+   "i\0"
+   "glBindVertexArrayAPPLE\0"
+   "\0"
+   /* _mesa_function_pool[24381]: GetProgramLocalParameterdvARB (will be remapped) */
+   "iip\0"
+   "glGetProgramLocalParameterdvARB\0"
+   "\0"
+   /* _mesa_function_pool[24418]: GetHistogramParameteriv (offset 363) */
+   "iip\0"
+   "glGetHistogramParameteriv\0"
+   "glGetHistogramParameterivEXT\0"
+   "\0"
+   /* _mesa_function_pool[24478]: MultiTexCoord1iARB (offset 380) */
+   "ii\0"
+   "glMultiTexCoord1i\0"
+   "glMultiTexCoord1iARB\0"
+   "\0"
+   /* _mesa_function_pool[24521]: GetConvolutionFilter (offset 356) */
+   "iiip\0"
+   "glGetConvolutionFilter\0"
+   "glGetConvolutionFilterEXT\0"
+   "\0"
+   /* _mesa_function_pool[24576]: GetProgramivARB (will be remapped) */
+   "iip\0"
+   "glGetProgramivARB\0"
+   "\0"
+   /* _mesa_function_pool[24599]: BlendFuncSeparateEXT (will be remapped) */
+   "iiii\0"
+   "glBlendFuncSeparate\0"
+   "glBlendFuncSeparateEXT\0"
+   "glBlendFuncSeparateINGR\0"
+   "\0"
+   /* _mesa_function_pool[24672]: MapBufferRange (will be remapped) */
+   "iiii\0"
+   "glMapBufferRange\0"
+   "\0"
+   /* _mesa_function_pool[24695]: ProgramParameters4dvNV (will be remapped) */
+   "iiip\0"
+   "glProgramParameters4dvNV\0"
+   "\0"
+   /* _mesa_function_pool[24726]: TexCoord2fColor3fVertex3fvSUN (dynamic) */
+   "ppp\0"
+   "glTexCoord2fColor3fVertex3fvSUN\0"
+   "\0"
+   /* _mesa_function_pool[24763]: EvalPoint2 (offset 239) */
+   "ii\0"
+   "glEvalPoint2\0"
+   "\0"
+   /* _mesa_function_pool[24780]: EvalPoint1 (offset 237) */
+   "i\0"
+   "glEvalPoint1\0"
+   "\0"
+   /* _mesa_function_pool[24796]: Binormal3dvEXT (dynamic) */
+   "p\0"
+   "glBinormal3dvEXT\0"
+   "\0"
+   /* _mesa_function_pool[24816]: PopMatrix (offset 297) */
+   "\0"
+   "glPopMatrix\0"
+   "\0"
+   /* _mesa_function_pool[24830]: FinishFenceNV (will be remapped) */
+   "i\0"
+   "glFinishFenceNV\0"
+   "\0"
+   /* _mesa_function_pool[24849]: GetFogFuncSGIS (dynamic) */
+   "p\0"
+   "glGetFogFuncSGIS\0"
+   "\0"
+   /* _mesa_function_pool[24869]: GetUniformLocationARB (will be remapped) */
+   "ip\0"
+   "glGetUniformLocation\0"
+   "glGetUniformLocationARB\0"
+   "\0"
+   /* _mesa_function_pool[24918]: SecondaryColor3fEXT (will be remapped) */
+   "fff\0"
+   "glSecondaryColor3f\0"
+   "glSecondaryColor3fEXT\0"
+   "\0"
+   /* _mesa_function_pool[24964]: GetTexGeniv (offset 280) */
+   "iip\0"
+   "glGetTexGeniv\0"
+   "\0"
+   /* _mesa_function_pool[24983]: CombinerInputNV (will be remapped) */
+   "iiiiii\0"
+   "glCombinerInputNV\0"
+   "\0"
+   /* _mesa_function_pool[25009]: VertexAttrib3sARB (will be remapped) */
+   "iiii\0"
+   "glVertexAttrib3s\0"
+   "glVertexAttrib3sARB\0"
+   "\0"
+   /* _mesa_function_pool[25052]: ReplacementCodeuiNormal3fVertex3fvSUN (dynamic) */
+   "ppp\0"
+   "glReplacementCodeuiNormal3fVertex3fvSUN\0"
+   "\0"
+   /* _mesa_function_pool[25097]: Map2d (offset 222) */
+   "iddiiddiip\0"
+   "glMap2d\0"
+   "\0"
+   /* _mesa_function_pool[25117]: Map2f (offset 223) */
+   "iffiiffiip\0"
+   "glMap2f\0"
+   "\0"
+   /* _mesa_function_pool[25137]: ProgramStringARB (will be remapped) */
+   "iiip\0"
+   "glProgramStringARB\0"
+   "\0"
+   /* _mesa_function_pool[25162]: Vertex4s (offset 148) */
+   "iiii\0"
+   "glVertex4s\0"
+   "\0"
+   /* _mesa_function_pool[25179]: TexCoord4fVertex4fvSUN (dynamic) */
+   "pp\0"
+   "glTexCoord4fVertex4fvSUN\0"
+   "\0"
+   /* _mesa_function_pool[25208]: VertexAttrib3sNV (will be remapped) */
+   "iiii\0"
+   "glVertexAttrib3sNV\0"
+   "\0"
+   /* _mesa_function_pool[25233]: VertexAttrib1fNV (will be remapped) */
+   "if\0"
+   "glVertexAttrib1fNV\0"
+   "\0"
+   /* _mesa_function_pool[25256]: Vertex4f (offset 144) */
+   "ffff\0"
+   "glVertex4f\0"
+   "\0"
+   /* _mesa_function_pool[25273]: EvalCoord1d (offset 228) */
+   "d\0"
+   "glEvalCoord1d\0"
+   "\0"
+   /* _mesa_function_pool[25290]: Vertex4d (offset 142) */
+   "dddd\0"
+   "glVertex4d\0"
+   "\0"
+   /* _mesa_function_pool[25307]: RasterPos4dv (offset 79) */
+   "p\0"
+   "glRasterPos4dv\0"
+   "\0"
+   /* _mesa_function_pool[25325]: FragmentLightfSGIX (dynamic) */
+   "iif\0"
+   "glFragmentLightfSGIX\0"
+   "\0"
+   /* _mesa_function_pool[25351]: GetCompressedTexImageARB (will be remapped) */
+   "iip\0"
+   "glGetCompressedTexImage\0"
+   "glGetCompressedTexImageARB\0"
+   "\0"
+   /* _mesa_function_pool[25407]: GetTexGenfv (offset 279) */
+   "iip\0"
+   "glGetTexGenfv\0"
+   "\0"
+   /* _mesa_function_pool[25426]: Vertex4i (offset 146) */
+   "iiii\0"
+   "glVertex4i\0"
+   "\0"
+   /* _mesa_function_pool[25443]: VertexWeightPointerEXT (dynamic) */
+   "iiip\0"
+   "glVertexWeightPointerEXT\0"
+   "\0"
+   /* _mesa_function_pool[25474]: GetHistogram (offset 361) */
+   "iiiip\0"
+   "glGetHistogram\0"
+   "glGetHistogramEXT\0"
+   "\0"
+   /* _mesa_function_pool[25514]: ActiveStencilFaceEXT (will be remapped) */
+   "i\0"
+   "glActiveStencilFaceEXT\0"
+   "\0"
+   /* _mesa_function_pool[25540]: StencilFuncSeparateATI (will be remapped) */
+   "iiii\0"
+   "glStencilFuncSeparateATI\0"
+   "\0"
+   /* _mesa_function_pool[25571]: Materialf (offset 169) */
+   "iif\0"
+   "glMaterialf\0"
+   "\0"
+   /* _mesa_function_pool[25588]: GetShaderSourceARB (will be remapped) */
+   "iipp\0"
+   "glGetShaderSource\0"
+   "glGetShaderSourceARB\0"
+   "\0"
+   /* _mesa_function_pool[25633]: IglooInterfaceSGIX (dynamic) */
+   "ip\0"
+   "glIglooInterfaceSGIX\0"
+   "\0"
+   /* _mesa_function_pool[25658]: Materiali (offset 171) */
+   "iii\0"
+   "glMateriali\0"
+   "\0"
+   /* _mesa_function_pool[25675]: VertexAttrib4dNV (will be remapped) */
+   "idddd\0"
+   "glVertexAttrib4dNV\0"
+   "\0"
+   /* _mesa_function_pool[25701]: MultiModeDrawElementsIBM (will be remapped) */
+   "ppipii\0"
+   "glMultiModeDrawElementsIBM\0"
+   "\0"
+   /* _mesa_function_pool[25736]: Indexsv (offset 51) */
+   "p\0"
+   "glIndexsv\0"
+   "\0"
+   /* _mesa_function_pool[25749]: MultiTexCoord4svARB (offset 407) */
+   "ip\0"
+   "glMultiTexCoord4sv\0"
+   "glMultiTexCoord4svARB\0"
+   "\0"
+   /* _mesa_function_pool[25794]: LightModelfv (offset 164) */
+   "ip\0"
+   "glLightModelfv\0"
+   "\0"
+   /* _mesa_function_pool[25813]: TexCoord2dv (offset 103) */
+   "p\0"
+   "glTexCoord2dv\0"
+   "\0"
+   /* _mesa_function_pool[25830]: GenQueriesARB (will be remapped) */
+   "ip\0"
+   "glGenQueries\0"
+   "glGenQueriesARB\0"
+   "\0"
+   /* _mesa_function_pool[25863]: EvalCoord1dv (offset 229) */
+   "p\0"
+   "glEvalCoord1dv\0"
+   "\0"
+   /* _mesa_function_pool[25881]: ReplacementCodeuiVertex3fSUN (dynamic) */
+   "ifff\0"
+   "glReplacementCodeuiVertex3fSUN\0"
+   "\0"
+   /* _mesa_function_pool[25918]: Translated (offset 303) */
+   "ddd\0"
+   "glTranslated\0"
+   "\0"
+   /* _mesa_function_pool[25936]: Translatef (offset 304) */
+   "fff\0"
+   "glTranslatef\0"
+   "\0"
+   /* _mesa_function_pool[25954]: StencilMask (offset 209) */
+   "i\0"
+   "glStencilMask\0"
+   "\0"
+   /* _mesa_function_pool[25971]: Tangent3iEXT (dynamic) */
+   "iii\0"
+   "glTangent3iEXT\0"
+   "\0"
+   /* _mesa_function_pool[25991]: GetLightiv (offset 265) */
+   "iip\0"
+   "glGetLightiv\0"
+   "\0"
+   /* _mesa_function_pool[26009]: DrawMeshArraysSUN (dynamic) */
+   "iiii\0"
+   "glDrawMeshArraysSUN\0"
+   "\0"
+   /* _mesa_function_pool[26035]: IsList (offset 287) */
+   "i\0"
+   "glIsList\0"
+   "\0"
+   /* _mesa_function_pool[26047]: IsSync (will be remapped) */
+   "i\0"
+   "glIsSync\0"
+   "\0"
+   /* _mesa_function_pool[26059]: RenderMode (offset 196) */
+   "i\0"
+   "glRenderMode\0"
+   "\0"
+   /* _mesa_function_pool[26075]: GetMapControlPointsNV (dynamic) */
+   "iiiiiip\0"
+   "glGetMapControlPointsNV\0"
+   "\0"
+   /* _mesa_function_pool[26108]: DrawBuffersARB (will be remapped) */
+   "ip\0"
+   "glDrawBuffers\0"
+   "glDrawBuffersARB\0"
+   "glDrawBuffersATI\0"
+   "\0"
+   /* _mesa_function_pool[26160]: ProgramLocalParameter4fARB (will be remapped) */
+   "iiffff\0"
+   "glProgramLocalParameter4fARB\0"
+   "\0"
+   /* _mesa_function_pool[26197]: SpriteParameterivSGIX (dynamic) */
+   "ip\0"
+   "glSpriteParameterivSGIX\0"
+   "\0"
+   /* _mesa_function_pool[26225]: ProvokingVertexEXT (will be remapped) */
+   "i\0"
+   "glProvokingVertexEXT\0"
+   "glProvokingVertex\0"
+   "\0"
+   /* _mesa_function_pool[26267]: MultiTexCoord1fARB (offset 378) */
+   "if\0"
+   "glMultiTexCoord1f\0"
+   "glMultiTexCoord1fARB\0"
+   "\0"
+   /* _mesa_function_pool[26310]: LoadName (offset 198) */
+   "i\0"
+   "glLoadName\0"
+   "\0"
+   /* _mesa_function_pool[26324]: VertexAttribs4ubvNV (will be remapped) */
+   "iip\0"
+   "glVertexAttribs4ubvNV\0"
+   "\0"
+   /* _mesa_function_pool[26351]: WeightsvARB (dynamic) */
+   "ip\0"
+   "glWeightsvARB\0"
+   "\0"
+   /* _mesa_function_pool[26369]: Uniform1fvARB (will be remapped) */
+   "iip\0"
+   "glUniform1fv\0"
+   "glUniform1fvARB\0"
+   "\0"
+   /* _mesa_function_pool[26403]: CopyTexSubImage1D (offset 325) */
+   "iiiiii\0"
+   "glCopyTexSubImage1D\0"
+   "glCopyTexSubImage1DEXT\0"
+   "\0"
+   /* _mesa_function_pool[26454]: CullFace (offset 152) */
+   "i\0"
+   "glCullFace\0"
+   "\0"
+   /* _mesa_function_pool[26468]: BindTexture (offset 307) */
+   "ii\0"
+   "glBindTexture\0"
+   "glBindTextureEXT\0"
+   "\0"
+   /* _mesa_function_pool[26503]: BeginFragmentShaderATI (will be remapped) */
+   "\0"
+   "glBeginFragmentShaderATI\0"
+   "\0"
+   /* _mesa_function_pool[26530]: MultiTexCoord4fARB (offset 402) */
+   "iffff\0"
+   "glMultiTexCoord4f\0"
+   "glMultiTexCoord4fARB\0"
+   "\0"
+   /* _mesa_function_pool[26576]: VertexAttribs3svNV (will be remapped) */
+   "iip\0"
+   "glVertexAttribs3svNV\0"
+   "\0"
+   /* _mesa_function_pool[26602]: StencilFunc (offset 243) */
+   "iii\0"
+   "glStencilFunc\0"
+   "\0"
+   /* _mesa_function_pool[26621]: CopyPixels (offset 255) */
+   "iiiii\0"
+   "glCopyPixels\0"
+   "\0"
+   /* _mesa_function_pool[26641]: Rectsv (offset 93) */
+   "pp\0"
+   "glRectsv\0"
+   "\0"
+   /* _mesa_function_pool[26654]: ReplacementCodeuivSUN (dynamic) */
+   "p\0"
+   "glReplacementCodeuivSUN\0"
+   "\0"
+   /* _mesa_function_pool[26681]: EnableVertexAttribArrayARB (will be remapped) */
+   "i\0"
+   "glEnableVertexAttribArray\0"
+   "glEnableVertexAttribArrayARB\0"
+   "\0"
+   /* _mesa_function_pool[26739]: NormalPointervINTEL (dynamic) */
+   "ip\0"
+   "glNormalPointervINTEL\0"
+   "\0"
+   /* _mesa_function_pool[26765]: CopyConvolutionFilter2D (offset 355) */
+   "iiiiii\0"
+   "glCopyConvolutionFilter2D\0"
+   "glCopyConvolutionFilter2DEXT\0"
+   "\0"
+   /* _mesa_function_pool[26828]: WindowPos3ivMESA (will be remapped) */
+   "p\0"
+   "glWindowPos3iv\0"
+   "glWindowPos3ivARB\0"
+   "glWindowPos3ivMESA\0"
+   "\0"
+   /* _mesa_function_pool[26883]: CopyBufferSubData (will be remapped) */
+   "iiiii\0"
+   "glCopyBufferSubData\0"
+   "\0"
+   /* _mesa_function_pool[26910]: NormalPointer (offset 318) */
+   "iip\0"
+   "glNormalPointer\0"
+   "\0"
+   /* _mesa_function_pool[26931]: TexParameterfv (offset 179) */
+   "iip\0"
+   "glTexParameterfv\0"
+   "\0"
+   /* _mesa_function_pool[26953]: IsBufferARB (will be remapped) */
+   "i\0"
+   "glIsBuffer\0"
+   "glIsBufferARB\0"
+   "\0"
+   /* _mesa_function_pool[26981]: WindowPos4iMESA (will be remapped) */
+   "iiii\0"
+   "glWindowPos4iMESA\0"
+   "\0"
+   /* _mesa_function_pool[27005]: VertexAttrib4uivARB (will be remapped) */
+   "ip\0"
+   "glVertexAttrib4uiv\0"
+   "glVertexAttrib4uivARB\0"
+   "\0"
+   /* _mesa_function_pool[27050]: Tangent3bvEXT (dynamic) */
+   "p\0"
+   "glTangent3bvEXT\0"
+   "\0"
+   /* _mesa_function_pool[27069]: UniformMatrix3x4fv (will be remapped) */
+   "iiip\0"
+   "glUniformMatrix3x4fv\0"
+   "\0"
+   /* _mesa_function_pool[27096]: ClipPlane (offset 150) */
+   "ip\0"
+   "glClipPlane\0"
+   "\0"
+   /* _mesa_function_pool[27112]: Recti (offset 90) */
+   "iiii\0"
+   "glRecti\0"
+   "\0"
+   /* _mesa_function_pool[27126]: DrawRangeElementsBaseVertex (will be remapped) */
+   "iiiiipi\0"
+   "glDrawRangeElementsBaseVertex\0"
+   "\0"
+   /* _mesa_function_pool[27165]: TexCoordPointervINTEL (dynamic) */
+   "iip\0"
+   "glTexCoordPointervINTEL\0"
+   "\0"
+   /* _mesa_function_pool[27194]: DeleteBuffersARB (will be remapped) */
+   "ip\0"
+   "glDeleteBuffers\0"
+   "glDeleteBuffersARB\0"
+   "\0"
+   /* _mesa_function_pool[27233]: WindowPos4fvMESA (will be remapped) */
+   "p\0"
+   "glWindowPos4fvMESA\0"
+   "\0"
+   /* _mesa_function_pool[27255]: GetPixelMapuiv (offset 272) */
+   "ip\0"
+   "glGetPixelMapuiv\0"
+   "\0"
+   /* _mesa_function_pool[27276]: Rectf (offset 88) */
+   "ffff\0"
+   "glRectf\0"
+   "\0"
+   /* _mesa_function_pool[27290]: VertexAttrib1sNV (will be remapped) */
+   "ii\0"
+   "glVertexAttrib1sNV\0"
+   "\0"
+   /* _mesa_function_pool[27313]: Indexfv (offset 47) */
+   "p\0"
+   "glIndexfv\0"
+   "\0"
+   /* _mesa_function_pool[27326]: SecondaryColor3svEXT (will be remapped) */
+   "p\0"
+   "glSecondaryColor3sv\0"
+   "glSecondaryColor3svEXT\0"
+   "\0"
+   /* _mesa_function_pool[27372]: LoadTransposeMatrixfARB (will be remapped) */
+   "p\0"
+   "glLoadTransposeMatrixf\0"
+   "glLoadTransposeMatrixfARB\0"
+   "\0"
+   /* _mesa_function_pool[27424]: GetPointerv (offset 329) */
+   "ip\0"
+   "glGetPointerv\0"
+   "glGetPointervEXT\0"
+   "\0"
+   /* _mesa_function_pool[27459]: Tangent3bEXT (dynamic) */
+   "iii\0"
+   "glTangent3bEXT\0"
+   "\0"
+   /* _mesa_function_pool[27479]: CombinerParameterfNV (will be remapped) */
+   "if\0"
+   "glCombinerParameterfNV\0"
+   "\0"
+   /* _mesa_function_pool[27506]: IndexMask (offset 212) */
+   "i\0"
+   "glIndexMask\0"
+   "\0"
+   /* _mesa_function_pool[27521]: BindProgramNV (will be remapped) */
+   "ii\0"
+   "glBindProgramARB\0"
+   "glBindProgramNV\0"
+   "\0"
+   /* _mesa_function_pool[27558]: VertexAttrib4svARB (will be remapped) */
+   "ip\0"
+   "glVertexAttrib4sv\0"
+   "glVertexAttrib4svARB\0"
+   "\0"
+   /* _mesa_function_pool[27601]: GetFloatv (offset 262) */
+   "ip\0"
+   "glGetFloatv\0"
+   "\0"
+   /* _mesa_function_pool[27617]: CreateDebugObjectMESA (dynamic) */
+   "\0"
+   "glCreateDebugObjectMESA\0"
+   "\0"
+   /* _mesa_function_pool[27643]: GetShaderiv (will be remapped) */
+   "iip\0"
+   "glGetShaderiv\0"
+   "\0"
+   /* _mesa_function_pool[27662]: ClientWaitSync (will be remapped) */
+   "iii\0"
+   "glClientWaitSync\0"
+   "\0"
+   /* _mesa_function_pool[27684]: TexCoord4s (offset 124) */
+   "iiii\0"
+   "glTexCoord4s\0"
+   "\0"
+   /* _mesa_function_pool[27703]: TexCoord3sv (offset 117) */
+   "p\0"
+   "glTexCoord3sv\0"
+   "\0"
+   /* _mesa_function_pool[27720]: BindFragmentShaderATI (will be remapped) */
+   "i\0"
+   "glBindFragmentShaderATI\0"
+   "\0"
+   /* _mesa_function_pool[27747]: PopAttrib (offset 218) */
+   "\0"
+   "glPopAttrib\0"
+   "\0"
+   /* _mesa_function_pool[27761]: Fogfv (offset 154) */
+   "ip\0"
+   "glFogfv\0"
+   "\0"
+   /* _mesa_function_pool[27773]: UnmapBufferARB (will be remapped) */
+   "i\0"
+   "glUnmapBuffer\0"
+   "glUnmapBufferARB\0"
+   "\0"
+   /* _mesa_function_pool[27807]: InitNames (offset 197) */
+   "\0"
+   "glInitNames\0"
+   "\0"
+   /* _mesa_function_pool[27821]: Normal3sv (offset 61) */
+   "p\0"
+   "glNormal3sv\0"
+   "\0"
+   /* _mesa_function_pool[27836]: Minmax (offset 368) */
+   "iii\0"
+   "glMinmax\0"
+   "glMinmaxEXT\0"
+   "\0"
+   /* _mesa_function_pool[27862]: TexCoord4d (offset 118) */
+   "dddd\0"
+   "glTexCoord4d\0"
+   "\0"
+   /* _mesa_function_pool[27881]: TexCoord4f (offset 120) */
+   "ffff\0"
+   "glTexCoord4f\0"
+   "\0"
+   /* _mesa_function_pool[27900]: FogCoorddvEXT (will be remapped) */
+   "p\0"
+   "glFogCoorddv\0"
+   "glFogCoorddvEXT\0"
+   "\0"
+   /* _mesa_function_pool[27932]: FinishTextureSUNX (dynamic) */
+   "\0"
+   "glFinishTextureSUNX\0"
+   "\0"
+   /* _mesa_function_pool[27954]: GetFragmentLightfvSGIX (dynamic) */
+   "iip\0"
+   "glGetFragmentLightfvSGIX\0"
+   "\0"
+   /* _mesa_function_pool[27984]: Binormal3fvEXT (dynamic) */
+   "p\0"
+   "glBinormal3fvEXT\0"
+   "\0"
+   /* _mesa_function_pool[28004]: GetBooleanv (offset 258) */
+   "ip\0"
+   "glGetBooleanv\0"
+   "\0"
+   /* _mesa_function_pool[28022]: ColorFragmentOp3ATI (will be remapped) */
+   "iiiiiiiiiiiii\0"
+   "glColorFragmentOp3ATI\0"
+   "\0"
+   /* _mesa_function_pool[28059]: Hint (offset 158) */
+   "ii\0"
+   "glHint\0"
+   "\0"
+   /* _mesa_function_pool[28070]: Color4dv (offset 28) */
+   "p\0"
+   "glColor4dv\0"
+   "\0"
+   /* _mesa_function_pool[28084]: VertexAttrib2svARB (will be remapped) */
+   "ip\0"
+   "glVertexAttrib2sv\0"
+   "glVertexAttrib2svARB\0"
+   "\0"
+   /* _mesa_function_pool[28127]: AreProgramsResidentNV (will be remapped) */
+   "ipp\0"
+   "glAreProgramsResidentNV\0"
+   "\0"
+   /* _mesa_function_pool[28156]: WindowPos3svMESA (will be remapped) */
+   "p\0"
+   "glWindowPos3sv\0"
+   "glWindowPos3svARB\0"
+   "glWindowPos3svMESA\0"
+   "\0"
+   /* _mesa_function_pool[28211]: CopyColorSubTable (offset 347) */
+   "iiiii\0"
+   "glCopyColorSubTable\0"
+   "glCopyColorSubTableEXT\0"
+   "\0"
+   /* _mesa_function_pool[28261]: WeightdvARB (dynamic) */
+   "ip\0"
+   "glWeightdvARB\0"
+   "\0"
+   /* _mesa_function_pool[28279]: DeleteRenderbuffersEXT (will be remapped) */
+   "ip\0"
+   "glDeleteRenderbuffers\0"
+   "glDeleteRenderbuffersEXT\0"
+   "\0"
+   /* _mesa_function_pool[28330]: VertexAttrib4NubvARB (will be remapped) */
+   "ip\0"
+   "glVertexAttrib4Nubv\0"
+   "glVertexAttrib4NubvARB\0"
+   "\0"
+   /* _mesa_function_pool[28377]: VertexAttrib3dvNV (will be remapped) */
+   "ip\0"
+   "glVertexAttrib3dvNV\0"
+   "\0"
+   /* _mesa_function_pool[28401]: GetObjectParameterfvARB (will be remapped) */
+   "iip\0"
+   "glGetObjectParameterfvARB\0"
+   "\0"
+   /* _mesa_function_pool[28432]: Vertex4iv (offset 147) */
+   "p\0"
+   "glVertex4iv\0"
+   "\0"
+   /* _mesa_function_pool[28447]: GetProgramEnvParameterdvARB (will be remapped) */
+   "iip\0"
+   "glGetProgramEnvParameterdvARB\0"
+   "\0"
+   /* _mesa_function_pool[28482]: TexCoord4dv (offset 119) */
+   "p\0"
+   "glTexCoord4dv\0"
+   "\0"
+   /* _mesa_function_pool[28499]: LockArraysEXT (will be remapped) */
+   "ii\0"
+   "glLockArraysEXT\0"
+   "\0"
+   /* _mesa_function_pool[28519]: Begin (offset 7) */
+   "i\0"
+   "glBegin\0"
+   "\0"
+   /* _mesa_function_pool[28530]: LightModeli (offset 165) */
+   "ii\0"
+   "glLightModeli\0"
+   "\0"
+   /* _mesa_function_pool[28548]: Rectfv (offset 89) */
+   "pp\0"
+   "glRectfv\0"
+   "\0"
+   /* _mesa_function_pool[28561]: LightModelf (offset 163) */
+   "if\0"
+   "glLightModelf\0"
+   "\0"
+   /* _mesa_function_pool[28579]: GetTexParameterfv (offset 282) */
+   "iip\0"
+   "glGetTexParameterfv\0"
+   "\0"
+   /* _mesa_function_pool[28604]: GetLightfv (offset 264) */
+   "iip\0"
+   "glGetLightfv\0"
+   "\0"
+   /* _mesa_function_pool[28622]: PixelTransformParameterivEXT (dynamic) */
+   "iip\0"
+   "glPixelTransformParameterivEXT\0"
+   "\0"
+   /* _mesa_function_pool[28658]: BinormalPointerEXT (dynamic) */
+   "iip\0"
+   "glBinormalPointerEXT\0"
+   "\0"
+   /* _mesa_function_pool[28684]: VertexAttrib1dNV (will be remapped) */
+   "id\0"
+   "glVertexAttrib1dNV\0"
+   "\0"
+   /* _mesa_function_pool[28707]: GetCombinerInputParameterivNV (will be remapped) */
+   "iiiip\0"
+   "glGetCombinerInputParameterivNV\0"
+   "\0"
+   /* _mesa_function_pool[28746]: Disable (offset 214) */
+   "i\0"
+   "glDisable\0"
+   "\0"
+   /* _mesa_function_pool[28759]: MultiTexCoord2fvARB (offset 387) */
+   "ip\0"
+   "glMultiTexCoord2fv\0"
+   "glMultiTexCoord2fvARB\0"
+   "\0"
+   /* _mesa_function_pool[28804]: GetRenderbufferParameterivEXT (will be remapped) */
+   "iip\0"
+   "glGetRenderbufferParameteriv\0"
+   "glGetRenderbufferParameterivEXT\0"
+   "\0"
+   /* _mesa_function_pool[28870]: CombinerParameterivNV (will be remapped) */
+   "ip\0"
+   "glCombinerParameterivNV\0"
+   "\0"
+   /* _mesa_function_pool[28898]: GenFragmentShadersATI (will be remapped) */
+   "i\0"
+   "glGenFragmentShadersATI\0"
+   "\0"
+   /* _mesa_function_pool[28925]: DrawArrays (offset 310) */
+   "iii\0"
+   "glDrawArrays\0"
+   "glDrawArraysEXT\0"
+   "\0"
+   /* _mesa_function_pool[28959]: WeightuivARB (dynamic) */
+   "ip\0"
+   "glWeightuivARB\0"
+   "\0"
+   /* _mesa_function_pool[28978]: VertexAttrib2sARB (will be remapped) */
+   "iii\0"
+   "glVertexAttrib2s\0"
+   "glVertexAttrib2sARB\0"
+   "\0"
+   /* _mesa_function_pool[29020]: ColorMask (offset 210) */
+   "iiii\0"
+   "glColorMask\0"
+   "\0"
+   /* _mesa_function_pool[29038]: GenAsyncMarkersSGIX (dynamic) */
+   "i\0"
+   "glGenAsyncMarkersSGIX\0"
+   "\0"
+   /* _mesa_function_pool[29063]: Tangent3svEXT (dynamic) */
+   "p\0"
+   "glTangent3svEXT\0"
+   "\0"
+   /* _mesa_function_pool[29082]: GetListParameterivSGIX (dynamic) */
+   "iip\0"
+   "glGetListParameterivSGIX\0"
+   "\0"
+   /* _mesa_function_pool[29112]: BindBufferARB (will be remapped) */
+   "ii\0"
+   "glBindBuffer\0"
+   "glBindBufferARB\0"
+   "\0"
+   /* _mesa_function_pool[29145]: GetInfoLogARB (will be remapped) */
+   "iipp\0"
+   "glGetInfoLogARB\0"
+   "\0"
+   /* _mesa_function_pool[29167]: RasterPos4iv (offset 83) */
+   "p\0"
+   "glRasterPos4iv\0"
+   "\0"
+   /* _mesa_function_pool[29185]: Enable (offset 215) */
+   "i\0"
+   "glEnable\0"
+   "\0"
+   /* _mesa_function_pool[29197]: LineStipple (offset 167) */
+   "ii\0"
+   "glLineStipple\0"
+   "\0"
+   /* _mesa_function_pool[29215]: VertexAttribs4svNV (will be remapped) */
+   "iip\0"
+   "glVertexAttribs4svNV\0"
+   "\0"
+   /* _mesa_function_pool[29241]: EdgeFlagPointerListIBM (dynamic) */
+   "ipi\0"
+   "glEdgeFlagPointerListIBM\0"
+   "\0"
+   /* _mesa_function_pool[29271]: UniformMatrix3x2fv (will be remapped) */
+   "iiip\0"
+   "glUniformMatrix3x2fv\0"
+   "\0"
+   /* _mesa_function_pool[29298]: GetMinmaxParameterfv (offset 365) */
+   "iip\0"
+   "glGetMinmaxParameterfv\0"
+   "glGetMinmaxParameterfvEXT\0"
+   "\0"
+   /* _mesa_function_pool[29352]: VertexAttrib1fvARB (will be remapped) */
+   "ip\0"
+   "glVertexAttrib1fv\0"
+   "glVertexAttrib1fvARB\0"
+   "\0"
+   /* _mesa_function_pool[29395]: GenBuffersARB (will be remapped) */
+   "ip\0"
+   "glGenBuffers\0"
+   "glGenBuffersARB\0"
+   "\0"
+   /* _mesa_function_pool[29428]: VertexAttribs1svNV (will be remapped) */
+   "iip\0"
+   "glVertexAttribs1svNV\0"
+   "\0"
+   /* _mesa_function_pool[29454]: Vertex3fv (offset 137) */
+   "p\0"
+   "glVertex3fv\0"
+   "\0"
+   /* _mesa_function_pool[29469]: GetTexBumpParameterivATI (will be remapped) */
+   "ip\0"
+   "glGetTexBumpParameterivATI\0"
+   "\0"
+   /* _mesa_function_pool[29500]: Binormal3bEXT (dynamic) */
+   "iii\0"
+   "glBinormal3bEXT\0"
+   "\0"
+   /* _mesa_function_pool[29521]: FragmentMaterialivSGIX (dynamic) */
+   "iip\0"
+   "glFragmentMaterialivSGIX\0"
+   "\0"
+   /* _mesa_function_pool[29551]: IsRenderbufferEXT (will be remapped) */
+   "i\0"
+   "glIsRenderbuffer\0"
+   "glIsRenderbufferEXT\0"
+   "\0"
+   /* _mesa_function_pool[29591]: GenProgramsNV (will be remapped) */
+   "ip\0"
+   "glGenProgramsARB\0"
+   "glGenProgramsNV\0"
+   "\0"
+   /* _mesa_function_pool[29628]: VertexAttrib4dvNV (will be remapped) */
+   "ip\0"
+   "glVertexAttrib4dvNV\0"
+   "\0"
+   /* _mesa_function_pool[29652]: EndFragmentShaderATI (will be remapped) */
+   "\0"
+   "glEndFragmentShaderATI\0"
+   "\0"
+   /* _mesa_function_pool[29677]: Binormal3iEXT (dynamic) */
+   "iii\0"
+   "glBinormal3iEXT\0"
+   "\0"
+   /* _mesa_function_pool[29698]: WindowPos2fMESA (will be remapped) */
+   "ff\0"
+   "glWindowPos2f\0"
+   "glWindowPos2fARB\0"
+   "glWindowPos2fMESA\0"
+   "\0"
+   ;
+
+/* these functions need to be remapped */
+static const struct {
+   GLint pool_index;
+   GLint remap_index;
+} MESA_remap_table_functions[] = {
+   {  1461, AttachShader_remap_index },
+   {  8764, CreateProgram_remap_index },
+   { 20302, CreateShader_remap_index },
+   { 22589, DeleteProgram_remap_index },
+   { 16282, DeleteShader_remap_index },
+   { 20748, DetachShader_remap_index },
+   { 15806, GetAttachedShaders_remap_index },
+   {  4275, GetProgramInfoLog_remap_index },
+   {   361, GetProgramiv_remap_index },
+   {  5578, GetShaderInfoLog_remap_index },
+   { 27643, GetShaderiv_remap_index },
+   { 11821, IsProgram_remap_index },
+   { 10856, IsShader_remap_index },
+   {  8868, StencilFuncSeparate_remap_index },
+   {  3487, StencilMaskSeparate_remap_index },
+   {  6654, StencilOpSeparate_remap_index },
+   { 19653, UniformMatrix2x3fv_remap_index },
+   {  2615, UniformMatrix2x4fv_remap_index },
+   { 29271, UniformMatrix3x2fv_remap_index },
+   { 27069, UniformMatrix3x4fv_remap_index },
+   { 14354, UniformMatrix4x2fv_remap_index },
+   {  2937, UniformMatrix4x3fv_remap_index },
+   {  8782, LoadTransposeMatrixdARB_remap_index },
+   { 27372, LoadTransposeMatrixfARB_remap_index },
+   {  4848, MultTransposeMatrixdARB_remap_index },
+   { 20935, MultTransposeMatrixfARB_remap_index },
+   {   172, SampleCoverageARB_remap_index },
+   {  5002, CompressedTexImage1DARB_remap_index },
+   { 21392, CompressedTexImage2DARB_remap_index },
+   {  3550, CompressedTexImage3DARB_remap_index },
+   { 16098, CompressedTexSubImage1DARB_remap_index },
+   {  1880, CompressedTexSubImage2DARB_remap_index },
+   { 17890, CompressedTexSubImage3DARB_remap_index },
+   { 25351, GetCompressedTexImageARB_remap_index },
+   {  3395, DisableVertexAttribArrayARB_remap_index },
+   { 26681, EnableVertexAttribArrayARB_remap_index },
+   { 28447, GetProgramEnvParameterdvARB_remap_index },
+   { 20815, GetProgramEnvParameterfvARB_remap_index },
+   { 24381, GetProgramLocalParameterdvARB_remap_index },
+   {  7096, GetProgramLocalParameterfvARB_remap_index },
+   { 16189, GetProgramStringARB_remap_index },
+   { 24576, GetProgramivARB_remap_index },
+   { 18085, GetVertexAttribdvARB_remap_index },
+   { 14243, GetVertexAttribfvARB_remap_index },
+   {  8677, GetVertexAttribivARB_remap_index },
+   { 16994, ProgramEnvParameter4dARB_remap_index },
+   { 22362, ProgramEnvParameter4dvARB_remap_index },
+   { 14851, ProgramEnvParameter4fARB_remap_index },
+   {  7959, ProgramEnvParameter4fvARB_remap_index },
+   {  3513, ProgramLocalParameter4dARB_remap_index },
+   { 11531, ProgramLocalParameter4dvARB_remap_index },
+   { 26160, ProgramLocalParameter4fARB_remap_index },
+   { 22907, ProgramLocalParameter4fvARB_remap_index },
+   { 25137, ProgramStringARB_remap_index },
+   { 17244, VertexAttrib1dARB_remap_index },
+   { 13897, VertexAttrib1dvARB_remap_index },
+   {  3688, VertexAttrib1fARB_remap_index },
+   { 29352, VertexAttrib1fvARB_remap_index },
+   {  6180, VertexAttrib1sARB_remap_index },
+   {  2054, VertexAttrib1svARB_remap_index },
+   { 13328, VertexAttrib2dARB_remap_index },
+   { 15425, VertexAttrib2dvARB_remap_index },
+   {  1480, VertexAttrib2fARB_remap_index },
+   { 15538, VertexAttrib2fvARB_remap_index },
+   { 28978, VertexAttrib2sARB_remap_index },
+   { 28084, VertexAttrib2svARB_remap_index },
+   { 10015, VertexAttrib3dARB_remap_index },
+   {  7662, VertexAttrib3dvARB_remap_index },
+   {  1567, VertexAttrib3fARB_remap_index },
+   { 19890, VertexAttrib3fvARB_remap_index },
+   { 25009, VertexAttrib3sARB_remap_index },
+   { 17827, VertexAttrib3svARB_remap_index },
+   {  4301, VertexAttrib4NbvARB_remap_index },
+   { 15761, VertexAttrib4NivARB_remap_index },
+   { 19845, VertexAttrib4NsvARB_remap_index },
+   { 20767, VertexAttrib4NubARB_remap_index },
+   { 28330, VertexAttrib4NubvARB_remap_index },
+   { 16655, VertexAttrib4NuivARB_remap_index },
+   {  2810, VertexAttrib4NusvARB_remap_index },
+   {  9609, VertexAttrib4bvARB_remap_index },
+   { 23789, VertexAttrib4dARB_remap_index },
+   { 18810, VertexAttrib4dvARB_remap_index },
+   { 10122, VertexAttrib4fARB_remap_index },
+   { 10492, VertexAttrib4fvARB_remap_index },
+   {  9061, VertexAttrib4ivARB_remap_index },
+   { 15239, VertexAttrib4sARB_remap_index },
+   { 27558, VertexAttrib4svARB_remap_index },
+   { 14656, VertexAttrib4ubvARB_remap_index },
+   { 27005, VertexAttrib4uivARB_remap_index },
+   { 17638, VertexAttrib4usvARB_remap_index },
+   { 19527, VertexAttribPointerARB_remap_index },
+   { 29112, BindBufferARB_remap_index },
+   {  5893, BufferDataARB_remap_index },
+   {  1382, BufferSubDataARB_remap_index },
+   { 27194, DeleteBuffersARB_remap_index },
+   { 29395, GenBuffersARB_remap_index },
+   { 15581, GetBufferParameterivARB_remap_index },
+   { 14803, GetBufferPointervARB_remap_index },
+   {  1335, GetBufferSubDataARB_remap_index },
+   { 26953, IsBufferARB_remap_index },
+   { 23362, MapBufferARB_remap_index },
+   { 27773, UnmapBufferARB_remap_index },
+   {   268, BeginQueryARB_remap_index },
+   { 17339, DeleteQueriesARB_remap_index },
+   { 10753, EndQueryARB_remap_index },
+   { 25830, GenQueriesARB_remap_index },
+   {  1772, GetQueryObjectivARB_remap_index },
+   { 15283, GetQueryObjectuivARB_remap_index },
+   {  1624, GetQueryivARB_remap_index },
+   { 17545, IsQueryARB_remap_index },
+   {  7272, AttachObjectARB_remap_index },
+   { 16244, CompileShaderARB_remap_index },
+   {  2879, CreateProgramObjectARB_remap_index },
+   {  5838, CreateShaderObjectARB_remap_index },
+   { 12745, DeleteObjectARB_remap_index },
+   { 21166, DetachObjectARB_remap_index },
+   { 10564, GetActiveUniformARB_remap_index },
+   {  8380, GetAttachedObjectsARB_remap_index },
+   {  8659, GetHandleARB_remap_index },
+   { 29145, GetInfoLogARB_remap_index },
+   { 28401, GetObjectParameterfvARB_remap_index },
+   { 24255, GetObjectParameterivARB_remap_index },
+   { 25588, GetShaderSourceARB_remap_index },
+   { 24869, GetUniformLocationARB_remap_index },
+   { 21037, GetUniformfvARB_remap_index },
+   { 11153, GetUniformivARB_remap_index },
+   { 17683, LinkProgramARB_remap_index },
+   { 17741, ShaderSourceARB_remap_index },
+   {  6554, Uniform1fARB_remap_index },
+   { 26369, Uniform1fvARB_remap_index },
+   { 19496, Uniform1iARB_remap_index },
+   { 18499, Uniform1ivARB_remap_index },
+   {  2003, Uniform2fARB_remap_index },
+   { 12581, Uniform2fvARB_remap_index },
+   { 23249, Uniform2iARB_remap_index },
+   {  2123, Uniform2ivARB_remap_index },
+   { 16354, Uniform3fARB_remap_index },
+   {  8410, Uniform3fvARB_remap_index },
+   {  5512, Uniform3iARB_remap_index },
+   { 14909, Uniform3ivARB_remap_index },
+   { 16800, Uniform4fARB_remap_index },
+   { 20901, Uniform4fvARB_remap_index },
+   { 22041, Uniform4iARB_remap_index },
+   { 18051, Uniform4ivARB_remap_index },
+   {  7324, UniformMatrix2fvARB_remap_index },
+   {    17, UniformMatrix3fvARB_remap_index },
+   {  2475, UniformMatrix4fvARB_remap_index },
+   { 22474, UseProgramObjectARB_remap_index },
+   { 13016, ValidateProgramARB_remap_index },
+   { 18853, BindAttribLocationARB_remap_index },
+   {  4346, GetActiveAttribARB_remap_index },
+   { 14590, GetAttribLocationARB_remap_index },
+   { 26108, DrawBuffersARB_remap_index },
+   { 11636, RenderbufferStorageMultisample_remap_index },
+   { 16848, FlushMappedBufferRange_remap_index },
+   { 24672, MapBufferRange_remap_index },
+   { 14465, BindVertexArray_remap_index },
+   { 12875, GenVertexArrays_remap_index },
+   { 26883, CopyBufferSubData_remap_index },
+   { 27662, ClientWaitSync_remap_index },
+   {  2394, DeleteSync_remap_index },
+   {  6221, FenceSync_remap_index },
+   { 13387, GetInteger64v_remap_index },
+   { 19952, GetSynciv_remap_index },
+   { 26047, IsSync_remap_index },
+   {  8328, WaitSync_remap_index },
+   {  3363, DrawElementsBaseVertex_remap_index },
+   { 27126, DrawRangeElementsBaseVertex_remap_index },
+   { 23393, MultiDrawElementsBaseVertex_remap_index },
+   {  4711, PolygonOffsetEXT_remap_index },
+   { 20537, GetPixelTexGenParameterfvSGIS_remap_index },
+   {  3895, GetPixelTexGenParameterivSGIS_remap_index },
+   { 20270, PixelTexGenParameterfSGIS_remap_index },
+   {   580, PixelTexGenParameterfvSGIS_remap_index },
+   { 11191, PixelTexGenParameteriSGIS_remap_index },
+   { 12152, PixelTexGenParameterivSGIS_remap_index },
+   { 14553, SampleMaskSGIS_remap_index },
+   { 17485, SamplePatternSGIS_remap_index },
+   { 23322, ColorPointerEXT_remap_index },
+   { 15468, EdgeFlagPointerEXT_remap_index },
+   {  5166, IndexPointerEXT_remap_index },
+   {  5246, NormalPointerEXT_remap_index },
+   { 13981, TexCoordPointerEXT_remap_index },
+   {  6016, VertexPointerEXT_remap_index },
+   {  3165, PointParameterfEXT_remap_index },
+   {  6861, PointParameterfvEXT_remap_index },
+   { 28499, LockArraysEXT_remap_index },
+   { 13080, UnlockArraysEXT_remap_index },
+   {  7868, CullParameterdvEXT_remap_index },
+   { 10359, CullParameterfvEXT_remap_index },
+   {  1151, SecondaryColor3bEXT_remap_index },
+   {  7020, SecondaryColor3bvEXT_remap_index },
+   {  9238, SecondaryColor3dEXT_remap_index },
+   { 22647, SecondaryColor3dvEXT_remap_index },
+   { 24918, SecondaryColor3fEXT_remap_index },
+   { 16034, SecondaryColor3fvEXT_remap_index },
+   {   426, SecondaryColor3iEXT_remap_index },
+   { 14291, SecondaryColor3ivEXT_remap_index },
+   {  8896, SecondaryColor3sEXT_remap_index },
+   { 27326, SecondaryColor3svEXT_remap_index },
+   { 24091, SecondaryColor3ubEXT_remap_index },
+   { 18744, SecondaryColor3ubvEXT_remap_index },
+   { 11386, SecondaryColor3uiEXT_remap_index },
+   { 20157, SecondaryColor3uivEXT_remap_index },
+   { 22859, SecondaryColor3usEXT_remap_index },
+   { 11459, SecondaryColor3usvEXT_remap_index },
+   { 10435, SecondaryColorPointerEXT_remap_index },
+   { 22708, MultiDrawArraysEXT_remap_index },
+   { 18434, MultiDrawElementsEXT_remap_index },
+   { 18629, FogCoordPointerEXT_remap_index },
+   {  4044, FogCoorddEXT_remap_index },
+   { 27900, FogCoorddvEXT_remap_index },
+   {  4136, FogCoordfEXT_remap_index },
+   { 24014, FogCoordfvEXT_remap_index },
+   { 16752, PixelTexGenSGIX_remap_index },
+   { 24599, BlendFuncSeparateEXT_remap_index },
+   {  5928, FlushVertexArrayRangeNV_remap_index },
+   {  4660, VertexArrayRangeNV_remap_index },
+   { 24983, CombinerInputNV_remap_index },
+   {  1946, CombinerOutputNV_remap_index },
+   { 27479, CombinerParameterfNV_remap_index },
+   {  4580, CombinerParameterfvNV_remap_index },
+   { 19702, CombinerParameteriNV_remap_index },
+   { 28870, CombinerParameterivNV_remap_index },
+   {  6298, FinalCombinerInputNV_remap_index },
+   {  8725, GetCombinerInputParameterfvNV_remap_index },
+   { 28707, GetCombinerInputParameterivNV_remap_index },
+   {  6097, GetCombinerOutputParameterfvNV_remap_index },
+   { 12113, GetCombinerOutputParameterivNV_remap_index },
+   {  5673, GetFinalCombinerInputParameterfvNV_remap_index },
+   { 21913, GetFinalCombinerInputParameterivNV_remap_index },
+   { 11131, ResizeBuffersMESA_remap_index },
+   {  9842, WindowPos2dMESA_remap_index },
+   {   944, WindowPos2dvMESA_remap_index },
+   { 29698, WindowPos2fMESA_remap_index },
+   {  6965, WindowPos2fvMESA_remap_index },
+   { 15981, WindowPos2iMESA_remap_index },
+   { 17958, WindowPos2ivMESA_remap_index },
+   { 18533, WindowPos2sMESA_remap_index },
+   {  4916, WindowPos2svMESA_remap_index },
+   {  6790, WindowPos3dMESA_remap_index },
+   { 12360, WindowPos3dvMESA_remap_index },
+   {   472, WindowPos3fMESA_remap_index },
+   { 13141, WindowPos3fvMESA_remap_index },
+   { 21208, WindowPos3iMESA_remap_index },
+   { 26828, WindowPos3ivMESA_remap_index },
+   { 16498, WindowPos3sMESA_remap_index },
+   { 28156, WindowPos3svMESA_remap_index },
+   {  9793, WindowPos4dMESA_remap_index },
+   { 14994, WindowPos4dvMESA_remap_index },
+   { 12319, WindowPos4fMESA_remap_index },
+   { 27233, WindowPos4fvMESA_remap_index },
+   { 26981, WindowPos4iMESA_remap_index },
+   { 10970, WindowPos4ivMESA_remap_index },
+   { 16631, WindowPos4sMESA_remap_index },
+   {  2857, WindowPos4svMESA_remap_index },
+   { 23757, MultiModeDrawArraysIBM_remap_index },
+   { 25701, MultiModeDrawElementsIBM_remap_index },
+   { 10781, DeleteFencesNV_remap_index },
+   { 24830, FinishFenceNV_remap_index },
+   {  3287, GenFencesNV_remap_index },
+   { 14974, GetFenceivNV_remap_index },
+   {  7257, IsFenceNV_remap_index },
+   { 12040, SetFenceNV_remap_index },
+   {  3744, TestFenceNV_remap_index },
+   { 28127, AreProgramsResidentNV_remap_index },
+   { 27521, BindProgramNV_remap_index },
+   { 22942, DeleteProgramsNV_remap_index },
+   { 18962, ExecuteProgramNV_remap_index },
+   { 29591, GenProgramsNV_remap_index },
+   { 20616, GetProgramParameterdvNV_remap_index },
+   {  9300, GetProgramParameterfvNV_remap_index },
+   { 23296, GetProgramStringNV_remap_index },
+   { 21602, GetProgramivNV_remap_index },
+   { 20850, GetTrackMatrixivNV_remap_index },
+   { 23092, GetVertexAttribPointervNV_remap_index },
+   { 21846, GetVertexAttribdvNV_remap_index },
+   { 16471, GetVertexAttribfvNV_remap_index },
+   { 16162, GetVertexAttribivNV_remap_index },
+   { 16878, IsProgramNV_remap_index },
+   {  8306, LoadProgramNV_remap_index },
+   { 24695, ProgramParameters4dvNV_remap_index },
+   { 21532, ProgramParameters4fvNV_remap_index },
+   { 18262, RequestResidentProgramsNV_remap_index },
+   { 19680, TrackMatrixNV_remap_index },
+   { 28684, VertexAttrib1dNV_remap_index },
+   { 11981, VertexAttrib1dvNV_remap_index },
+   { 25233, VertexAttrib1fNV_remap_index },
+   {  2245, VertexAttrib1fvNV_remap_index },
+   { 27290, VertexAttrib1sNV_remap_index },
+   { 13214, VertexAttrib1svNV_remap_index },
+   {  4251, VertexAttrib2dNV_remap_index },
+   { 11896, VertexAttrib2dvNV_remap_index },
+   { 17717, VertexAttrib2fNV_remap_index },
+   { 11507, VertexAttrib2fvNV_remap_index },
+   {  5076, VertexAttrib2sNV_remap_index },
+   { 16552, VertexAttrib2svNV_remap_index },
+   {  9990, VertexAttrib3dNV_remap_index },
+   { 28377, VertexAttrib3dvNV_remap_index },
+   {  9112, VertexAttrib3fNV_remap_index },
+   { 21873, VertexAttrib3fvNV_remap_index },
+   { 25208, VertexAttrib3sNV_remap_index },
+   { 20877, VertexAttrib3svNV_remap_index },
+   { 25675, VertexAttrib4dNV_remap_index },
+   { 29628, VertexAttrib4dvNV_remap_index },
+   {  3945, VertexAttrib4fNV_remap_index },
+   {  8356, VertexAttrib4fvNV_remap_index },
+   { 23641, VertexAttrib4sNV_remap_index },
+   {  1293, VertexAttrib4svNV_remap_index },
+   {  4409, VertexAttrib4ubNV_remap_index },
+   {   734, VertexAttrib4ubvNV_remap_index },
+   { 19142, VertexAttribPointerNV_remap_index },
+   {  2097, VertexAttribs1dvNV_remap_index },
+   { 16576, VertexAttribs1fvNV_remap_index },
+   { 29428, VertexAttribs1svNV_remap_index },
+   {  9137, VertexAttribs2dvNV_remap_index },
+   { 22435, VertexAttribs2fvNV_remap_index },
+   { 15494, VertexAttribs2svNV_remap_index },
+   {  4608, VertexAttribs3dvNV_remap_index },
+   {  1977, VertexAttribs3fvNV_remap_index },
+   { 26576, VertexAttribs3svNV_remap_index },
+   { 23731, VertexAttribs4dvNV_remap_index },
+   {  4634, VertexAttribs4fvNV_remap_index },
+   { 29215, VertexAttribs4svNV_remap_index },
+   { 26324, VertexAttribs4ubvNV_remap_index },
+   { 23833, GetTexBumpParameterfvATI_remap_index },
+   { 29469, GetTexBumpParameterivATI_remap_index },
+   { 16216, TexBumpParameterfvATI_remap_index },
+   { 18133, TexBumpParameterivATI_remap_index },
+   { 13760, AlphaFragmentOp1ATI_remap_index },
+   {  9652, AlphaFragmentOp2ATI_remap_index },
+   { 21789, AlphaFragmentOp3ATI_remap_index },
+   { 26503, BeginFragmentShaderATI_remap_index },
+   { 27720, BindFragmentShaderATI_remap_index },
+   { 21006, ColorFragmentOp1ATI_remap_index },
+   {  3823, ColorFragmentOp2ATI_remap_index },
+   { 28022, ColorFragmentOp3ATI_remap_index },
+   {  4753, DeleteFragmentShaderATI_remap_index },
+   { 29652, EndFragmentShaderATI_remap_index },
+   { 28898, GenFragmentShadersATI_remap_index },
+   { 22566, PassTexCoordATI_remap_index },
+   {  5996, SampleMapATI_remap_index },
+   {  5769, SetFragmentShaderConstantATI_remap_index },
+   {   319, PointParameteriNV_remap_index },
+   { 12521, PointParameterivNV_remap_index },
+   { 25514, ActiveStencilFaceEXT_remap_index },
+   { 24355, BindVertexArrayAPPLE_remap_index },
+   {  2522, DeleteVertexArraysAPPLE_remap_index },
+   { 15833, GenVertexArraysAPPLE_remap_index },
+   { 20681, IsVertexArrayAPPLE_remap_index },
+   {   775, GetProgramNamedParameterdvNV_remap_index },
+   {  3128, GetProgramNamedParameterfvNV_remap_index },
+   { 23864, ProgramNamedParameter4dNV_remap_index },
+   { 12796, ProgramNamedParameter4dvNV_remap_index },
+   {  7893, ProgramNamedParameter4fNV_remap_index },
+   { 10400, ProgramNamedParameter4fvNV_remap_index },
+   { 21511, DepthBoundsEXT_remap_index },
+   {  1043, BlendEquationSeparateEXT_remap_index },
+   { 12915, BindFramebufferEXT_remap_index },
+   { 22753, BindRenderbufferEXT_remap_index },
+   {  8575, CheckFramebufferStatusEXT_remap_index },
+   { 19971, DeleteFramebuffersEXT_remap_index },
+   { 28279, DeleteRenderbuffersEXT_remap_index },
+   { 11920, FramebufferRenderbufferEXT_remap_index },
+   { 12057, FramebufferTexture1DEXT_remap_index },
+   { 10228, FramebufferTexture2DEXT_remap_index },
+   {  9895, FramebufferTexture3DEXT_remap_index },
+   { 20573, GenFramebuffersEXT_remap_index },
+   { 15380, GenRenderbuffersEXT_remap_index },
+   {  5715, GenerateMipmapEXT_remap_index },
+   { 19202, GetFramebufferAttachmentParameterivEXT_remap_index },
+   { 28804, GetRenderbufferParameterivEXT_remap_index },
+   { 18013, IsFramebufferEXT_remap_index },
+   { 29551, IsRenderbufferEXT_remap_index },
+   {  7204, RenderbufferStorageEXT_remap_index },
+   {   651, BlitFramebufferEXT_remap_index },
+   { 12615, BufferParameteriAPPLE_remap_index },
+   { 16910, FlushMappedBufferRangeAPPLE_remap_index },
+   {  2701, FramebufferTextureLayerEXT_remap_index },
+   {  8277, ColorMaskIndexedEXT_remap_index },
+   { 23180, DisableIndexedEXT_remap_index },
+   { 23488, EnableIndexedEXT_remap_index },
+   { 19173, GetBooleanIndexedvEXT_remap_index },
+   {  9685, GetIntegerIndexedvEXT_remap_index },
+   { 20047, IsEnabledIndexedEXT_remap_index },
+   {  4074, BeginConditionalRenderNV_remap_index },
+   { 22539, EndConditionalRenderNV_remap_index },
+   { 26225, ProvokingVertexEXT_remap_index },
+   {  9521, GetTexParameterPointervAPPLE_remap_index },
+   {  4436, TextureRangeAPPLE_remap_index },
+   { 25540, StencilFuncSeparateATI_remap_index },
+   { 15900, ProgramEnvParameters4fvEXT_remap_index },
+   { 15118, ProgramLocalParameters4fvEXT_remap_index },
+   { 12449, GetQueryObjecti64vEXT_remap_index },
+   {  9163, GetQueryObjectui64vEXT_remap_index },
+   {    -1, -1 }
+};
+
+/* these functions are in the ABI, but have alternative names */
+static const struct gl_function_remap MESA_alt_functions[] = {
+   /* from GL_EXT_blend_color */
+   {  2440, _gloffset_BlendColor },
+   /* from GL_EXT_blend_minmax */
+   {  9952, _gloffset_BlendEquation },
+   /* from GL_EXT_color_subtable */
+   { 15016, _gloffset_ColorSubTable },
+   { 28211, _gloffset_CopyColorSubTable },
+   /* from GL_EXT_convolution */
+   {   213, _gloffset_ConvolutionFilter1D },
+   {  2284, _gloffset_CopyConvolutionFilter1D },
+   {  3624, _gloffset_GetConvolutionParameteriv },
+   {  7553, _gloffset_ConvolutionFilter2D },
+   {  7719, _gloffset_ConvolutionParameteriv },
+   {  8179, _gloffset_ConvolutionParameterfv },
+   { 18161, _gloffset_GetSeparableFilter },
+   { 21262, _gloffset_SeparableFilter2D },
+   { 22091, _gloffset_ConvolutionParameteri },
+   { 22214, _gloffset_ConvolutionParameterf },
+   { 23667, _gloffset_GetConvolutionParameterfv },
+   { 24521, _gloffset_GetConvolutionFilter },
+   { 26765, _gloffset_CopyConvolutionFilter2D },
+   /* from GL_EXT_copy_texture */
+   { 13274, _gloffset_CopyTexSubImage3D },
+   { 14756, _gloffset_CopyTexImage2D },
+   { 21699, _gloffset_CopyTexImage1D },
+   { 24202, _gloffset_CopyTexSubImage2D },
+   { 26403, _gloffset_CopyTexSubImage1D },
+   /* from GL_EXT_draw_range_elements */
+   {  8462, _gloffset_DrawRangeElements },
+   /* from GL_EXT_histogram */
+   {   812, _gloffset_Histogram },
+   {  3088, _gloffset_ResetHistogram },
+   {  8834, _gloffset_GetMinmax },
+   { 13608, _gloffset_GetHistogramParameterfv },
+   { 21624, _gloffset_GetMinmaxParameteriv },
+   { 23557, _gloffset_ResetMinmax },
+   { 24418, _gloffset_GetHistogramParameteriv },
+   { 25474, _gloffset_GetHistogram },
+   { 27836, _gloffset_Minmax },
+   { 29298, _gloffset_GetMinmaxParameterfv },
+   /* from GL_EXT_paletted_texture */
+   {  7415, _gloffset_ColorTable },
+   { 13454, _gloffset_GetColorTable },
+   { 20320, _gloffset_GetColorTableParameterfv },
+   { 22270, _gloffset_GetColorTableParameteriv },
+   /* from GL_EXT_subtexture */
+   {  6136, _gloffset_TexSubImage1D },
+   {  9448, _gloffset_TexSubImage2D },
+   /* from GL_EXT_texture3D */
+   {  1658, _gloffset_TexImage3D },
+   { 20089, _gloffset_TexSubImage3D },
+   /* from GL_EXT_texture_object */
+   {  2964, _gloffset_PrioritizeTextures },
+   {  6585, _gloffset_AreTexturesResident },
+   { 12005, _gloffset_GenTextures },
+   { 13940, _gloffset_DeleteTextures },
+   { 17191, _gloffset_IsTexture },
+   { 26468, _gloffset_BindTexture },
+   /* from GL_EXT_vertex_array */
+   { 21451, _gloffset_ArrayElement },
+   { 27424, _gloffset_GetPointerv },
+   { 28925, _gloffset_DrawArrays },
+   /* from GL_SGI_color_table */
+   {  6703, _gloffset_ColorTableParameteriv },
+   {  7415, _gloffset_ColorTable },
+   { 13454, _gloffset_GetColorTable },
+   { 13564, _gloffset_CopyColorTable },
+   { 17052, _gloffset_ColorTableParameterfv },
+   { 20320, _gloffset_GetColorTableParameterfv },
+   { 22270, _gloffset_GetColorTableParameteriv },
+   /* from GL_VERSION_1_3 */
+   {   381, _gloffset_MultiTexCoord3sARB },
+   {   613, _gloffset_ActiveTextureARB },
+   {  3761, _gloffset_MultiTexCoord1fvARB },
+   {  5271, _gloffset_MultiTexCoord3dARB },
+   {  5316, _gloffset_MultiTexCoord2iARB },
+   {  5440, _gloffset_MultiTexCoord2svARB },
+   {  7371, _gloffset_MultiTexCoord2fARB },
+   {  9193, _gloffset_MultiTexCoord3fvARB },
+   {  9714, _gloffset_MultiTexCoord4sARB },
+   { 10314, _gloffset_MultiTexCoord2dvARB },
+   { 10696, _gloffset_MultiTexCoord1svARB },
+   { 10992, _gloffset_MultiTexCoord3svARB },
+   { 11053, _gloffset_MultiTexCoord4iARB },
+   { 11776, _gloffset_MultiTexCoord3iARB },
+   { 12478, _gloffset_MultiTexCoord1dARB },
+   { 12644, _gloffset_MultiTexCoord3dvARB },
+   { 13808, _gloffset_MultiTexCoord3ivARB },
+   { 13853, _gloffset_MultiTexCoord2sARB },
+   { 15073, _gloffset_MultiTexCoord4ivARB },
+   { 16702, _gloffset_ClientActiveTextureARB },
+   { 18918, _gloffset_MultiTexCoord2dARB },
+   { 19322, _gloffset_MultiTexCoord4dvARB },
+   { 19608, _gloffset_MultiTexCoord4fvARB },
+   { 20461, _gloffset_MultiTexCoord3fARB },
+   { 22798, _gloffset_MultiTexCoord4dARB },
+   { 23002, _gloffset_MultiTexCoord1sARB },
+   { 23204, _gloffset_MultiTexCoord1dvARB },
+   { 24046, _gloffset_MultiTexCoord1ivARB },
+   { 24139, _gloffset_MultiTexCoord2ivARB },
+   { 24478, _gloffset_MultiTexCoord1iARB },
+   { 25749, _gloffset_MultiTexCoord4svARB },
+   { 26267, _gloffset_MultiTexCoord1fARB },
+   { 26530, _gloffset_MultiTexCoord4fARB },
+   { 28759, _gloffset_MultiTexCoord2fvARB },
+   {    -1, -1 }
+};
+
+#endif /* need_MESA_remap_table */
+
+#if defined(need_GL_3DFX_tbuffer)
+static const struct gl_function_remap GL_3DFX_tbuffer_functions[] = {
+   {  8237, -1 }, /* TbufferMask3DFX */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_APPLE_flush_buffer_range)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_APPLE_flush_buffer_range_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_APPLE_texture_range)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_APPLE_texture_range_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_APPLE_vertex_array_object)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_APPLE_vertex_array_object_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_ARB_copy_buffer)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_ARB_copy_buffer_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_ARB_draw_buffers)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_ARB_draw_buffers_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_ARB_draw_elements_base_vertex)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_ARB_draw_elements_base_vertex_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_ARB_framebuffer_object)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_ARB_framebuffer_object_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_ARB_map_buffer_range)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_ARB_map_buffer_range_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_ARB_matrix_palette)
+static const struct gl_function_remap GL_ARB_matrix_palette_functions[] = {
+   {  3339, -1 }, /* MatrixIndexusvARB */
+   { 11597, -1 }, /* MatrixIndexuivARB */
+   { 12766, -1 }, /* MatrixIndexPointerARB */
+   { 17440, -1 }, /* CurrentPaletteMatrixARB */
+   { 20205, -1 }, /* MatrixIndexubvARB */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_ARB_multisample)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_ARB_multisample_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_ARB_occlusion_query)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_ARB_occlusion_query_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_ARB_point_parameters)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_ARB_point_parameters_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_ARB_provoking_vertex)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_ARB_provoking_vertex_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_ARB_shader_objects_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_ARB_sync)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_ARB_sync_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_ARB_texture_compression)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_ARB_texture_compression_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_ARB_transpose_matrix)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_ARB_transpose_matrix_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_ARB_vertex_array_object)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_ARB_vertex_array_object_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_ARB_vertex_blend)
+static const struct gl_function_remap GL_ARB_vertex_blend_functions[] = {
+   {  2226, -1 }, /* WeightubvARB */
+   {  5603, -1 }, /* WeightivARB */
+   {  9817, -1 }, /* WeightPointerARB */
+   { 12235, -1 }, /* WeightfvARB */
+   { 15520, -1 }, /* WeightbvARB */
+   { 18586, -1 }, /* WeightusvARB */
+   { 21188, -1 }, /* VertexBlendARB */
+   { 26351, -1 }, /* WeightsvARB */
+   { 28261, -1 }, /* WeightdvARB */
+   { 28959, -1 }, /* WeightuivARB */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_ARB_vertex_buffer_object)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_ARB_vertex_buffer_object_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_ARB_vertex_program_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_ARB_vertex_shader)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_ARB_vertex_shader_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_ARB_window_pos)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_ARB_window_pos_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_ATI_blend_equation_separate)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_ATI_blend_equation_separate_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_ATI_draw_buffers)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_ATI_draw_buffers_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_ATI_envmap_bumpmap)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_ATI_envmap_bumpmap_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_ATI_fragment_shader)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_ATI_fragment_shader_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_ATI_separate_stencil)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_ATI_separate_stencil_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_blend_color)
+static const struct gl_function_remap GL_EXT_blend_color_functions[] = {
+   {  2440, _gloffset_BlendColor },
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_blend_equation_separate)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_EXT_blend_equation_separate_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_blend_func_separate)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_EXT_blend_func_separate_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_blend_minmax)
+static const struct gl_function_remap GL_EXT_blend_minmax_functions[] = {
+   {  9952, _gloffset_BlendEquation },
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_color_subtable)
+static const struct gl_function_remap GL_EXT_color_subtable_functions[] = {
+   { 15016, _gloffset_ColorSubTable },
+   { 28211, _gloffset_CopyColorSubTable },
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_compiled_vertex_array)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_EXT_compiled_vertex_array_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_convolution)
+static const struct gl_function_remap GL_EXT_convolution_functions[] = {
+   {   213, _gloffset_ConvolutionFilter1D },
+   {  2284, _gloffset_CopyConvolutionFilter1D },
+   {  3624, _gloffset_GetConvolutionParameteriv },
+   {  7553, _gloffset_ConvolutionFilter2D },
+   {  7719, _gloffset_ConvolutionParameteriv },
+   {  8179, _gloffset_ConvolutionParameterfv },
+   { 18161, _gloffset_GetSeparableFilter },
+   { 21262, _gloffset_SeparableFilter2D },
+   { 22091, _gloffset_ConvolutionParameteri },
+   { 22214, _gloffset_ConvolutionParameterf },
+   { 23667, _gloffset_GetConvolutionParameterfv },
+   { 24521, _gloffset_GetConvolutionFilter },
+   { 26765, _gloffset_CopyConvolutionFilter2D },
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_coordinate_frame)
+static const struct gl_function_remap GL_EXT_coordinate_frame_functions[] = {
+   {  9332, -1 }, /* TangentPointerEXT */
+   { 11111, -1 }, /* Binormal3ivEXT */
+   { 11729, -1 }, /* Tangent3sEXT */
+   { 12831, -1 }, /* Tangent3fvEXT */
+   { 16452, -1 }, /* Tangent3dvEXT */
+   { 17138, -1 }, /* Binormal3bvEXT */
+   { 18214, -1 }, /* Binormal3dEXT */
+   { 20137, -1 }, /* Tangent3fEXT */
+   { 22163, -1 }, /* Binormal3sEXT */
+   { 22608, -1 }, /* Tangent3ivEXT */
+   { 22627, -1 }, /* Tangent3dEXT */
+   { 23431, -1 }, /* Binormal3svEXT */
+   { 23944, -1 }, /* Binormal3fEXT */
+   { 24796, -1 }, /* Binormal3dvEXT */
+   { 25971, -1 }, /* Tangent3iEXT */
+   { 27050, -1 }, /* Tangent3bvEXT */
+   { 27459, -1 }, /* Tangent3bEXT */
+   { 27984, -1 }, /* Binormal3fvEXT */
+   { 28658, -1 }, /* BinormalPointerEXT */
+   { 29063, -1 }, /* Tangent3svEXT */
+   { 29500, -1 }, /* Binormal3bEXT */
+   { 29677, -1 }, /* Binormal3iEXT */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_copy_texture)
+static const struct gl_function_remap GL_EXT_copy_texture_functions[] = {
+   { 13274, _gloffset_CopyTexSubImage3D },
+   { 14756, _gloffset_CopyTexImage2D },
+   { 21699, _gloffset_CopyTexImage1D },
+   { 24202, _gloffset_CopyTexSubImage2D },
+   { 26403, _gloffset_CopyTexSubImage1D },
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_cull_vertex)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_EXT_cull_vertex_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_depth_bounds_test)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_EXT_depth_bounds_test_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_draw_buffers2)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_EXT_draw_buffers2_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_draw_range_elements)
+static const struct gl_function_remap GL_EXT_draw_range_elements_functions[] = {
+   {  8462, _gloffset_DrawRangeElements },
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_fog_coord)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_EXT_fog_coord_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_framebuffer_blit)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_EXT_framebuffer_blit_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_framebuffer_multisample)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_EXT_framebuffer_multisample_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_framebuffer_object)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_EXT_framebuffer_object_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_gpu_program_parameters)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_EXT_gpu_program_parameters_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_histogram)
+static const struct gl_function_remap GL_EXT_histogram_functions[] = {
+   {   812, _gloffset_Histogram },
+   {  3088, _gloffset_ResetHistogram },
+   {  8834, _gloffset_GetMinmax },
+   { 13608, _gloffset_GetHistogramParameterfv },
+   { 21624, _gloffset_GetMinmaxParameteriv },
+   { 23557, _gloffset_ResetMinmax },
+   { 24418, _gloffset_GetHistogramParameteriv },
+   { 25474, _gloffset_GetHistogram },
+   { 27836, _gloffset_Minmax },
+   { 29298, _gloffset_GetMinmaxParameterfv },
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_index_func)
+static const struct gl_function_remap GL_EXT_index_func_functions[] = {
+   { 10179, -1 }, /* IndexFuncEXT */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_index_material)
+static const struct gl_function_remap GL_EXT_index_material_functions[] = {
+   { 18673, -1 }, /* IndexMaterialEXT */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_light_texture)
+static const struct gl_function_remap GL_EXT_light_texture_functions[] = {
+   { 23451, -1 }, /* ApplyTextureEXT */
+   { 23511, -1 }, /* TextureMaterialEXT */
+   { 23536, -1 }, /* TextureLightEXT */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_multi_draw_arrays)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_EXT_multi_draw_arrays_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_multisample)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_EXT_multisample_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_paletted_texture)
+static const struct gl_function_remap GL_EXT_paletted_texture_functions[] = {
+   {  7415, _gloffset_ColorTable },
+   { 13454, _gloffset_GetColorTable },
+   { 20320, _gloffset_GetColorTableParameterfv },
+   { 22270, _gloffset_GetColorTableParameteriv },
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_pixel_transform)
+static const struct gl_function_remap GL_EXT_pixel_transform_functions[] = {
+   {  9573, -1 }, /* PixelTransformParameterfvEXT */
+   { 19287, -1 }, /* PixelTransformParameterfEXT */
+   { 19367, -1 }, /* PixelTransformParameteriEXT */
+   { 28622, -1 }, /* PixelTransformParameterivEXT */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_point_parameters)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_EXT_point_parameters_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_polygon_offset)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_EXT_polygon_offset_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_provoking_vertex)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_EXT_provoking_vertex_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_secondary_color)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_EXT_secondary_color_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_stencil_two_side)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_EXT_stencil_two_side_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_subtexture)
+static const struct gl_function_remap GL_EXT_subtexture_functions[] = {
+   {  6136, _gloffset_TexSubImage1D },
+   {  9448, _gloffset_TexSubImage2D },
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_texture3D)
+static const struct gl_function_remap GL_EXT_texture3D_functions[] = {
+   {  1658, _gloffset_TexImage3D },
+   { 20089, _gloffset_TexSubImage3D },
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_texture_array)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_EXT_texture_array_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_texture_object)
+static const struct gl_function_remap GL_EXT_texture_object_functions[] = {
+   {  2964, _gloffset_PrioritizeTextures },
+   {  6585, _gloffset_AreTexturesResident },
+   { 12005, _gloffset_GenTextures },
+   { 13940, _gloffset_DeleteTextures },
+   { 17191, _gloffset_IsTexture },
+   { 26468, _gloffset_BindTexture },
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_texture_perturb_normal)
+static const struct gl_function_remap GL_EXT_texture_perturb_normal_functions[] = {
+   { 12185, -1 }, /* TextureNormalEXT */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_timer_query)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_EXT_timer_query_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_vertex_array)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_EXT_vertex_array_functions[] = {
+   { 21451, _gloffset_ArrayElement },
+   { 27424, _gloffset_GetPointerv },
+   { 28925, _gloffset_DrawArrays },
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_EXT_vertex_weighting)
+static const struct gl_function_remap GL_EXT_vertex_weighting_functions[] = {
+   { 17221, -1 }, /* VertexWeightfvEXT */
+   { 23922, -1 }, /* VertexWeightfEXT */
+   { 25443, -1 }, /* VertexWeightPointerEXT */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_HP_image_transform)
+static const struct gl_function_remap GL_HP_image_transform_functions[] = {
+   {  2157, -1 }, /* GetImageTransformParameterfvHP */
+   {  3305, -1 }, /* ImageTransformParameterfHP */
+   {  9026, -1 }, /* ImageTransformParameterfvHP */
+   { 10614, -1 }, /* ImageTransformParameteriHP */
+   { 10882, -1 }, /* GetImageTransformParameterivHP */
+   { 17285, -1 }, /* ImageTransformParameterivHP */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_IBM_multimode_draw_arrays)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_IBM_multimode_draw_arrays_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_IBM_vertex_array_lists)
+static const struct gl_function_remap GL_IBM_vertex_array_lists_functions[] = {
+   {  3857, -1 }, /* SecondaryColorPointerListIBM */
+   {  5137, -1 }, /* NormalPointerListIBM */
+   {  6759, -1 }, /* FogCoordPointerListIBM */
+   {  7066, -1 }, /* VertexPointerListIBM */
+   { 10535, -1 }, /* ColorPointerListIBM */
+   { 11836, -1 }, /* TexCoordPointerListIBM */
+   { 12207, -1 }, /* IndexPointerListIBM */
+   { 29241, -1 }, /* EdgeFlagPointerListIBM */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_INGR_blend_func_separate)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_INGR_blend_func_separate_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_INTEL_parallel_arrays)
+static const struct gl_function_remap GL_INTEL_parallel_arrays_functions[] = {
+   { 11223, -1 }, /* VertexPointervINTEL */
+   { 13701, -1 }, /* ColorPointervINTEL */
+   { 26739, -1 }, /* NormalPointervINTEL */
+   { 27165, -1 }, /* TexCoordPointervINTEL */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_MESA_resize_buffers)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_MESA_resize_buffers_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_MESA_shader_debug)
+static const struct gl_function_remap GL_MESA_shader_debug_functions[] = {
+   {  1522, -1 }, /* GetDebugLogLengthMESA */
+   {  3063, -1 }, /* ClearDebugLogMESA */
+   {  4018, -1 }, /* GetDebugLogMESA */
+   { 27617, -1 }, /* CreateDebugObjectMESA */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_MESA_window_pos)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_MESA_window_pos_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_NV_condtitional_render)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_NV_condtitional_render_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_NV_evaluators)
+static const struct gl_function_remap GL_NV_evaluators_functions[] = {
+   {  5804, -1 }, /* GetMapAttribParameterivNV */
+   {  7521, -1 }, /* MapControlPointsNV */
+   {  7620, -1 }, /* MapParameterfvNV */
+   {  9431, -1 }, /* EvalMapsNV */
+   { 15190, -1 }, /* GetMapAttribParameterfvNV */
+   { 15356, -1 }, /* MapParameterivNV */
+   { 22014, -1 }, /* GetMapParameterivNV */
+   { 22512, -1 }, /* GetMapParameterfvNV */
+   { 26075, -1 }, /* GetMapControlPointsNV */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_NV_fence)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_NV_fence_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_NV_fragment_program)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_NV_fragment_program_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_NV_point_sprite)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_NV_point_sprite_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_NV_register_combiners)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_NV_register_combiners_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_NV_register_combiners2)
+static const struct gl_function_remap GL_NV_register_combiners2_functions[] = {
+   { 14093, -1 }, /* CombinerStageParameterfvNV */
+   { 14408, -1 }, /* GetCombinerStageParameterfvNV */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_NV_vertex_array_range)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_NV_vertex_array_range_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_NV_vertex_program_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_PGI_misc_hints)
+static const struct gl_function_remap GL_PGI_misc_hints_functions[] = {
+   {  7705, -1 }, /* HintPGI */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_SGIS_detail_texture)
+static const struct gl_function_remap GL_SGIS_detail_texture_functions[] = {
+   { 14381, -1 }, /* GetDetailTexFuncSGIS */
+   { 14701, -1 }, /* DetailTexFuncSGIS */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_SGIS_fog_function)
+static const struct gl_function_remap GL_SGIS_fog_function_functions[] = {
+   { 24184, -1 }, /* FogFuncSGIS */
+   { 24849, -1 }, /* GetFogFuncSGIS */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_SGIS_multisample)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_SGIS_multisample_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_SGIS_pixel_texture)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_SGIS_pixel_texture_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_SGIS_point_parameters)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_SGIS_point_parameters_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_SGIS_sharpen_texture)
+static const struct gl_function_remap GL_SGIS_sharpen_texture_functions[] = {
+   {  5865, -1 }, /* GetSharpenTexFuncSGIS */
+   { 19582, -1 }, /* SharpenTexFuncSGIS */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_SGIS_texture4D)
+static const struct gl_function_remap GL_SGIS_texture4D_functions[] = {
+   {   894, -1 }, /* TexImage4DSGIS */
+   { 14009, -1 }, /* TexSubImage4DSGIS */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_SGIS_texture_color_mask)
+static const struct gl_function_remap GL_SGIS_texture_color_mask_functions[] = {
+   { 13407, -1 }, /* TextureColorMaskSGIS */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_SGIS_texture_filter4)
+static const struct gl_function_remap GL_SGIS_texture_filter4_functions[] = {
+   {  6042, -1 }, /* GetTexFilterFuncSGIS */
+   { 14527, -1 }, /* TexFilterFuncSGIS */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_SGIX_async)
+static const struct gl_function_remap GL_SGIX_async_functions[] = {
+   {  3014, -1 }, /* AsyncMarkerSGIX */
+   {  3997, -1 }, /* FinishAsyncSGIX */
+   {  4734, -1 }, /* PollAsyncSGIX */
+   { 19729, -1 }, /* DeleteAsyncMarkersSGIX */
+   { 19758, -1 }, /* IsAsyncMarkerSGIX */
+   { 29038, -1 }, /* GenAsyncMarkersSGIX */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_SGIX_flush_raster)
+static const struct gl_function_remap GL_SGIX_flush_raster_functions[] = {
+   {  6413, -1 }, /* FlushRasterSGIX */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_SGIX_fragment_lighting)
+static const struct gl_function_remap GL_SGIX_fragment_lighting_functions[] = {
+   {  2410, -1 }, /* FragmentMaterialfvSGIX */
+   {  2906, -1 }, /* FragmentLightModelivSGIX */
+   {  4685, -1 }, /* FragmentLightiSGIX */
+   {  5545, -1 }, /* GetFragmentMaterialfvSGIX */
+   {  7133, -1 }, /* FragmentMaterialfSGIX */
+   {  7294, -1 }, /* GetFragmentLightivSGIX */
+   {  8131, -1 }, /* FragmentLightModeliSGIX */
+   {  9494, -1 }, /* FragmentLightivSGIX */
+   {  9760, -1 }, /* GetFragmentMaterialivSGIX */
+   { 17108, -1 }, /* FragmentLightModelfSGIX */
+   { 17408, -1 }, /* FragmentColorMaterialSGIX */
+   { 17780, -1 }, /* FragmentMaterialiSGIX */
+   { 19001, -1 }, /* LightEnviSGIX */
+   { 20412, -1 }, /* FragmentLightModelfvSGIX */
+   { 20721, -1 }, /* FragmentLightfvSGIX */
+   { 25325, -1 }, /* FragmentLightfSGIX */
+   { 27954, -1 }, /* GetFragmentLightfvSGIX */
+   { 29521, -1 }, /* FragmentMaterialivSGIX */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_SGIX_framezoom)
+static const struct gl_function_remap GL_SGIX_framezoom_functions[] = {
+   { 19781, -1 }, /* FrameZoomSGIX */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_SGIX_igloo_interface)
+static const struct gl_function_remap GL_SGIX_igloo_interface_functions[] = {
+   { 25633, -1 }, /* IglooInterfaceSGIX */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_SGIX_instruments)
+static const struct gl_function_remap GL_SGIX_instruments_functions[] = {
+   {  2573, -1 }, /* ReadInstrumentsSGIX */
+   {  5621, -1 }, /* PollInstrumentsSGIX */
+   {  9392, -1 }, /* GetInstrumentsSGIX */
+   { 11434, -1 }, /* StartInstrumentsSGIX */
+   { 14127, -1 }, /* StopInstrumentsSGIX */
+   { 15733, -1 }, /* InstrumentsBufferSGIX */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_SGIX_list_priority)
+static const struct gl_function_remap GL_SGIX_list_priority_functions[] = {
+   {  1125, -1 }, /* ListParameterfSGIX */
+   {  2763, -1 }, /* GetListParameterfvSGIX */
+   { 15648, -1 }, /* ListParameteriSGIX */
+   { 16402, -1 }, /* ListParameterfvSGIX */
+   { 18407, -1 }, /* ListParameterivSGIX */
+   { 29082, -1 }, /* GetListParameterivSGIX */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_SGIX_pixel_texture)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_SGIX_pixel_texture_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_SGIX_polynomial_ffd)
+static const struct gl_function_remap GL_SGIX_polynomial_ffd_functions[] = {
+   {  3251, -1 }, /* LoadIdentityDeformationMapSGIX */
+   { 10802, -1 }, /* DeformationMap3dSGIX */
+   { 14227, -1 }, /* DeformSGIX */
+   { 21563, -1 }, /* DeformationMap3fSGIX */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_SGIX_reference_plane)
+static const struct gl_function_remap GL_SGIX_reference_plane_functions[] = {
+   { 12958, -1 }, /* ReferencePlaneSGIX */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_SGIX_sprite)
+static const struct gl_function_remap GL_SGIX_sprite_functions[] = {
+   {  8547, -1 }, /* SpriteParameterfvSGIX */
+   { 18235, -1 }, /* SpriteParameteriSGIX */
+   { 23591, -1 }, /* SpriteParameterfSGIX */
+   { 26197, -1 }, /* SpriteParameterivSGIX */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_SGIX_tag_sample_buffer)
+static const struct gl_function_remap GL_SGIX_tag_sample_buffer_functions[] = {
+   { 18294, -1 }, /* TagSampleBufferSGIX */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_SGI_color_table)
+static const struct gl_function_remap GL_SGI_color_table_functions[] = {
+   {  6703, _gloffset_ColorTableParameteriv },
+   {  7415, _gloffset_ColorTable },
+   { 13454, _gloffset_GetColorTable },
+   { 13564, _gloffset_CopyColorTable },
+   { 17052, _gloffset_ColorTableParameterfv },
+   { 20320, _gloffset_GetColorTableParameterfv },
+   { 22270, _gloffset_GetColorTableParameteriv },
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_SUNX_constant_data)
+static const struct gl_function_remap GL_SUNX_constant_data_functions[] = {
+   { 27932, -1 }, /* FinishTextureSUNX */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_SUN_global_alpha)
+static const struct gl_function_remap GL_SUN_global_alpha_functions[] = {
+   {  3035, -1 }, /* GlobalAlphaFactorubSUN */
+   {  4224, -1 }, /* GlobalAlphaFactoriSUN */
+   {  5646, -1 }, /* GlobalAlphaFactordSUN */
+   {  8631, -1 }, /* GlobalAlphaFactoruiSUN */
+   {  8983, -1 }, /* GlobalAlphaFactorbSUN */
+   { 11749, -1 }, /* GlobalAlphaFactorfSUN */
+   { 11868, -1 }, /* GlobalAlphaFactorusSUN */
+   { 20020, -1 }, /* GlobalAlphaFactorsSUN */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_SUN_mesh_array)
+static const struct gl_function_remap GL_SUN_mesh_array_functions[] = {
+   { 26009, -1 }, /* DrawMeshArraysSUN */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_SUN_triangle_list)
+static const struct gl_function_remap GL_SUN_triangle_list_functions[] = {
+   {  3971, -1 }, /* ReplacementCodeubSUN */
+   {  5485, -1 }, /* ReplacementCodeubvSUN */
+   { 16773, -1 }, /* ReplacementCodeusvSUN */
+   { 16961, -1 }, /* ReplacementCodePointerSUN */
+   { 18318, -1 }, /* ReplacementCodeusSUN */
+   { 19065, -1 }, /* ReplacementCodeuiSUN */
+   { 26654, -1 }, /* ReplacementCodeuivSUN */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const struct gl_function_remap GL_SUN_vertex_functions[] = {
+   {   999, -1 }, /* ReplacementCodeuiColor3fVertex3fvSUN */
+   {  1197, -1 }, /* TexCoord4fColor4fNormal3fVertex4fvSUN */
+   {  1423, -1 }, /* TexCoord2fColor4ubVertex3fvSUN */
+   {  1699, -1 }, /* ReplacementCodeuiVertex3fvSUN */
+   {  1833, -1 }, /* ReplacementCodeuiTexCoord2fVertex3fvSUN */
+   {  2346, -1 }, /* ReplacementCodeuiNormal3fVertex3fSUN */
+   {  2642, -1 }, /* Color4ubVertex3fvSUN */
+   {  4105, -1 }, /* Color4ubVertex3fSUN */
+   {  4181, -1 }, /* TexCoord2fVertex3fSUN */
+   {  4480, -1 }, /* TexCoord2fColor4fNormal3fVertex3fSUN */
+   {  4810, -1 }, /* TexCoord2fNormal3fVertex3fvSUN */
+   {  5380, -1 }, /* ReplacementCodeuiTexCoord2fNormal3fVertex3fSUN */
+   {  6450, -1 }, /* ReplacementCodeuiTexCoord2fVertex3fSUN */
+   {  7162, -1 }, /* TexCoord2fNormal3fVertex3fSUN */
+   {  7930, -1 }, /* Color3fVertex3fSUN */
+   {  8942, -1 }, /* Color3fVertex3fvSUN */
+   {  9357, -1 }, /* Color4fNormal3fVertex3fvSUN */
+   { 10058, -1 }, /* ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN */
+   { 11297, -1 }, /* ReplacementCodeuiColor4fNormal3fVertex3fvSUN */
+   { 12689, -1 }, /* ReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN */
+   { 13100, -1 }, /* TexCoord2fColor3fVertex3fSUN */
+   { 14152, -1 }, /* TexCoord4fColor4fNormal3fVertex4fSUN */
+   { 14486, -1 }, /* Color4ubVertex2fvSUN */
+   { 14726, -1 }, /* Normal3fVertex3fSUN */
+   { 15674, -1 }, /* ReplacementCodeuiColor4fNormal3fVertex3fSUN */
+   { 15935, -1 }, /* TexCoord2fColor4fNormal3fVertex3fvSUN */
+   { 16602, -1 }, /* TexCoord2fVertex3fvSUN */
+   { 17378, -1 }, /* Color4ubVertex2fSUN */
+   { 17571, -1 }, /* ReplacementCodeuiColor4ubVertex3fSUN */
+   { 19453, -1 }, /* TexCoord2fColor4ubVertex3fSUN */
+   { 19800, -1 }, /* Normal3fVertex3fvSUN */
+   { 20229, -1 }, /* Color4fNormal3fVertex3fSUN */
+   { 21095, -1 }, /* ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN */
+   { 21315, -1 }, /* ReplacementCodeuiColor4ubVertex3fvSUN */
+   { 23045, -1 }, /* ReplacementCodeuiColor3fVertex3fSUN */
+   { 24300, -1 }, /* TexCoord4fVertex4fSUN */
+   { 24726, -1 }, /* TexCoord2fColor3fVertex3fvSUN */
+   { 25052, -1 }, /* ReplacementCodeuiNormal3fVertex3fvSUN */
+   { 25179, -1 }, /* TexCoord4fVertex4fvSUN */
+   { 25881, -1 }, /* ReplacementCodeuiVertex3fSUN */
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_VERSION_1_3_functions[] = {
+   {   381, _gloffset_MultiTexCoord3sARB },
+   {   613, _gloffset_ActiveTextureARB },
+   {  3761, _gloffset_MultiTexCoord1fvARB },
+   {  5271, _gloffset_MultiTexCoord3dARB },
+   {  5316, _gloffset_MultiTexCoord2iARB },
+   {  5440, _gloffset_MultiTexCoord2svARB },
+   {  7371, _gloffset_MultiTexCoord2fARB },
+   {  9193, _gloffset_MultiTexCoord3fvARB },
+   {  9714, _gloffset_MultiTexCoord4sARB },
+   { 10314, _gloffset_MultiTexCoord2dvARB },
+   { 10696, _gloffset_MultiTexCoord1svARB },
+   { 10992, _gloffset_MultiTexCoord3svARB },
+   { 11053, _gloffset_MultiTexCoord4iARB },
+   { 11776, _gloffset_MultiTexCoord3iARB },
+   { 12478, _gloffset_MultiTexCoord1dARB },
+   { 12644, _gloffset_MultiTexCoord3dvARB },
+   { 13808, _gloffset_MultiTexCoord3ivARB },
+   { 13853, _gloffset_MultiTexCoord2sARB },
+   { 15073, _gloffset_MultiTexCoord4ivARB },
+   { 16702, _gloffset_ClientActiveTextureARB },
+   { 18918, _gloffset_MultiTexCoord2dARB },
+   { 19322, _gloffset_MultiTexCoord4dvARB },
+   { 19608, _gloffset_MultiTexCoord4fvARB },
+   { 20461, _gloffset_MultiTexCoord3fARB },
+   { 22798, _gloffset_MultiTexCoord4dARB },
+   { 23002, _gloffset_MultiTexCoord1sARB },
+   { 23204, _gloffset_MultiTexCoord1dvARB },
+   { 24046, _gloffset_MultiTexCoord1ivARB },
+   { 24139, _gloffset_MultiTexCoord2ivARB },
+   { 24478, _gloffset_MultiTexCoord1iARB },
+   { 25749, _gloffset_MultiTexCoord4svARB },
+   { 26267, _gloffset_MultiTexCoord1fARB },
+   { 26530, _gloffset_MultiTexCoord4fARB },
+   { 28759, _gloffset_MultiTexCoord2fvARB },
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_VERSION_1_4)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_VERSION_1_4_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_VERSION_1_5)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_VERSION_1_5_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_VERSION_2_0)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_VERSION_2_0_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
+#if defined(need_GL_VERSION_2_1)
+/* functions defined in MESA_remap_table_functions are excluded */
+static const struct gl_function_remap GL_VERSION_2_1_functions[] = {
+   {    -1, -1 }
+};
+#endif
+
index 38be8266e05c5bd6df0fa3e83e3f7525bbb0af84..3bb062bae2a3364230c88f025353a350c4ca7b17 100644 (file)
@@ -43,6 +43,8 @@
 #include "glheader.h"
 #include "imports.h"
 #include "context.h"
+#include "fbobject.h"
+#include "formats.h"
 #include "mtypes.h"
 #include "fbobject.h"
 #include "renderbuffer.h"
@@ -72,7 +74,7 @@ get_pointer_ubyte(GLcontext *ctx, struct gl_renderbuffer *rb,
    if (!rb->Data)
       return NULL;
    ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
-   /* Can't assert _ActualFormat since these funcs may be used for serveral
+   /* Can't assert rb->Format since these funcs may be used for serveral
     * different formats (GL_ALPHA8, GL_STENCIL_INDEX8, etc).
     */
    return (GLubyte *) rb->Data + y * rb->Width + x;
@@ -448,7 +450,7 @@ static void *
 get_pointer_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb,
                    GLint x, GLint y)
 {
-   ASSERT(rb->_ActualFormat == GL_RGB8);
+   ASSERT(rb->Format == MESA_FORMAT_RGB888);
    /* No direct access since this buffer is RGB but caller will be
     * treating it as if it were RGBA.
     */
@@ -463,7 +465,7 @@ get_row_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
    const GLubyte *src = (const GLubyte *) rb->Data + 3 * (y * rb->Width + x);
    GLubyte *dst = (GLubyte *) values;
    GLuint i;
-   ASSERT(rb->_ActualFormat == GL_RGB8);
+   ASSERT(rb->Format == MESA_FORMAT_RGB888);
    ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
    for (i = 0; i < count; i++) {
       dst[i * 4 + 0] = src[i * 3 + 0];
@@ -480,7 +482,7 @@ get_values_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
 {
    GLubyte *dst = (GLubyte *) values;
    GLuint i;
-   ASSERT(rb->_ActualFormat == GL_RGB8);
+   ASSERT(rb->Format == MESA_FORMAT_RGB888);
    ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
    for (i = 0; i < count; i++) {
       const GLubyte *src
@@ -501,7 +503,7 @@ put_row_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
    const GLubyte *src = (const GLubyte *) values;
    GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->Width + x);
    GLuint i;
-   ASSERT(rb->_ActualFormat == GL_RGB8);
+   ASSERT(rb->Format == MESA_FORMAT_RGB888);
    ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
    for (i = 0; i < count; i++) {
       if (!mask || mask[i]) {
@@ -521,7 +523,7 @@ put_row_rgb_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
    const GLubyte *src = (const GLubyte *) values;
    GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->Width + x);
    GLuint i;
-   ASSERT(rb->_ActualFormat == GL_RGB8);
+   ASSERT(rb->Format == MESA_FORMAT_RGB888);
    ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
    for (i = 0; i < count; i++) {
       if (!mask || mask[i]) {
@@ -542,7 +544,7 @@ put_mono_row_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
    const GLubyte val1 = ((const GLubyte *) value)[1];
    const GLubyte val2 = ((const GLubyte *) value)[2];
    GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->Width + x);
-   ASSERT(rb->_ActualFormat == GL_RGB8);
+   ASSERT(rb->Format == MESA_FORMAT_RGB888);
    ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
    if (!mask && val0 == val1 && val1 == val2) {
       /* optimized case */
@@ -569,7 +571,7 @@ put_values_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
    /* note: incoming values are RGB+A! */
    const GLubyte *src = (const GLubyte *) values;
    GLuint i;
-   ASSERT(rb->_ActualFormat == GL_RGB8);
+   ASSERT(rb->Format == MESA_FORMAT_RGB888);
    ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
    for (i = 0; i < count; i++) {
       if (!mask || mask[i]) {
@@ -592,7 +594,7 @@ put_mono_values_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb,
    const GLubyte val1 = ((const GLubyte *) value)[1];
    const GLubyte val2 = ((const GLubyte *) value)[2];
    GLuint i;
-   ASSERT(rb->_ActualFormat == GL_RGB8);
+   ASSERT(rb->Format == MESA_FORMAT_RGB888);
    ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
    for (i = 0; i < count; i++) {
       if (!mask || mask[i]) {
@@ -617,7 +619,7 @@ get_pointer_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb,
    if (!rb->Data)
       return NULL;
    ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
-   ASSERT(rb->_ActualFormat == GL_RGBA8);
+   ASSERT(rb->Format == MESA_FORMAT_RGBA8888);
    return (GLubyte *) rb->Data + 4 * (y * rb->Width + x);
 }
 
@@ -628,7 +630,7 @@ get_row_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
 {
    const GLubyte *src = (const GLubyte *) rb->Data + 4 * (y * rb->Width + x);
    ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
-   ASSERT(rb->_ActualFormat == GL_RGBA8);
+   ASSERT(rb->Format == MESA_FORMAT_RGBA8888);
    _mesa_memcpy(values, src, 4 * count * sizeof(GLubyte));
 }
 
@@ -641,7 +643,7 @@ get_values_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
    GLuint *dst = (GLuint *) values;
    GLuint i;
    ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
-   ASSERT(rb->_ActualFormat == GL_RGBA8);
+   ASSERT(rb->Format == MESA_FORMAT_RGBA8888);
    for (i = 0; i < count; i++) {
       const GLuint *src = (GLuint *) rb->Data + (y[i] * rb->Width + x[i]);
       dst[i] = *src;
@@ -657,7 +659,7 @@ put_row_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
    const GLuint *src = (const GLuint *) values;
    GLuint *dst = (GLuint *) rb->Data + (y * rb->Width + x);
    ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
-   ASSERT(rb->_ActualFormat == GL_RGBA8);
+   ASSERT(rb->Format == MESA_FORMAT_RGBA8888);
    if (mask) {
       GLuint i;
       for (i = 0; i < count; i++) {
@@ -681,7 +683,7 @@ put_row_rgb_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
    GLubyte *dst = (GLubyte *) rb->Data + 4 * (y * rb->Width + x);
    GLuint i;
    ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
-   ASSERT(rb->_ActualFormat == GL_RGBA8);
+   ASSERT(rb->Format == MESA_FORMAT_RGBA8888);
    for (i = 0; i < count; i++) {
       if (!mask || mask[i]) {
          dst[i * 4 + 0] = src[i * 3 + 0];
@@ -701,7 +703,7 @@ put_mono_row_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
    const GLuint val = *((const GLuint *) value);
    GLuint *dst = (GLuint *) rb->Data + (y * rb->Width + x);
    ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
-   ASSERT(rb->_ActualFormat == GL_RGBA8);
+   ASSERT(rb->Format == MESA_FORMAT_RGBA8888);
    if (!mask && val == 0) {
       /* common case */
       _mesa_bzero(dst, count * 4 * sizeof(GLubyte));
@@ -735,7 +737,7 @@ put_values_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
    const GLuint *src = (const GLuint *) values;
    GLuint i;
    ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
-   ASSERT(rb->_ActualFormat == GL_RGBA8);
+   ASSERT(rb->Format == MESA_FORMAT_RGBA8888);
    for (i = 0; i < count; i++) {
       if (!mask || mask[i]) {
          GLuint *dst = (GLuint *) rb->Data + (y[i] * rb->Width + x[i]);
@@ -754,7 +756,7 @@ put_mono_values_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb,
    const GLuint val = *((const GLuint *) value);
    GLuint i;
    ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
-   ASSERT(rb->_ActualFormat == GL_RGBA8);
+   ASSERT(rb->Format == MESA_FORMAT_RGBA8888);
    for (i = 0; i < count; i++) {
       if (!mask || mask[i]) {
          GLuint *dst = (GLuint *) rb->Data + (y[i] * rb->Width + x[i]);
@@ -947,15 +949,6 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
 {
    GLuint pixelSize;
 
-   /* first clear these fields */
-   rb->RedBits =
-   rb->GreenBits =
-   rb->BlueBits =
-   rb->AlphaBits =
-   rb->IndexBits =
-   rb->DepthBits =
-   rb->StencilBits = 0;
-
    switch (internalFormat) {
    case GL_RGB:
    case GL_R3_G3_B2:
@@ -965,8 +958,7 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
    case GL_RGB10:
    case GL_RGB12:
    case GL_RGB16:
-      rb->_ActualFormat = GL_RGB8;
-      rb->_BaseFormat = GL_RGB;
+      rb->Format = MESA_FORMAT_RGB888;
       rb->DataType = GL_UNSIGNED_BYTE;
       rb->GetPointer = get_pointer_ubyte3;
       rb->GetRow = get_row_ubyte3;
@@ -976,10 +968,6 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
       rb->PutMonoRow = put_mono_row_ubyte3;
       rb->PutValues = put_values_ubyte3;
       rb->PutMonoValues = put_mono_values_ubyte3;
-      rb->RedBits   = 8 * sizeof(GLubyte);
-      rb->GreenBits = 8 * sizeof(GLubyte);
-      rb->BlueBits  = 8 * sizeof(GLubyte);
-      rb->AlphaBits = 0;
       pixelSize = 3 * sizeof(GLubyte);
       break;
    case GL_RGBA:
@@ -987,8 +975,11 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
    case GL_RGBA4:
    case GL_RGB5_A1:
    case GL_RGBA8:
-      rb->_ActualFormat = GL_RGBA8;
-      rb->_BaseFormat = GL_RGBA;
+#if 1
+   case GL_RGB10_A2:
+   case GL_RGBA12:
+#endif
+      rb->Format = MESA_FORMAT_RGBA8888;
       rb->DataType = GL_UNSIGNED_BYTE;
       rb->GetPointer = get_pointer_ubyte4;
       rb->GetRow = get_row_ubyte4;
@@ -998,18 +989,12 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
       rb->PutMonoRow = put_mono_row_ubyte4;
       rb->PutValues = put_values_ubyte4;
       rb->PutMonoValues = put_mono_values_ubyte4;
-      rb->RedBits   = 8 * sizeof(GLubyte);
-      rb->GreenBits = 8 * sizeof(GLubyte);
-      rb->BlueBits  = 8 * sizeof(GLubyte);
-      rb->AlphaBits = 8 * sizeof(GLubyte);
       pixelSize = 4 * sizeof(GLubyte);
       break;
-   case GL_RGB10_A2:
-   case GL_RGBA12:
    case GL_RGBA16:
-      rb->_ActualFormat = GL_RGBA16;
-      rb->_BaseFormat = GL_RGBA;
-      rb->DataType = GL_UNSIGNED_SHORT;
+      /* for accum buffer */
+      rb->Format = MESA_FORMAT_SIGNED_RGBA_16;
+      rb->DataType = GL_SHORT;
       rb->GetPointer = get_pointer_ushort4;
       rb->GetRow = get_row_ushort4;
       rb->GetValues = get_values_ushort4;
@@ -1018,16 +1003,11 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
       rb->PutMonoRow = put_mono_row_ushort4;
       rb->PutValues = put_values_ushort4;
       rb->PutMonoValues = put_mono_values_ushort4;
-      rb->RedBits   = 8 * sizeof(GLushort);
-      rb->GreenBits = 8 * sizeof(GLushort);
-      rb->BlueBits  = 8 * sizeof(GLushort);
-      rb->AlphaBits = 8 * sizeof(GLushort);
       pixelSize = 4 * sizeof(GLushort);
       break;
-#if 00
+#if 0
    case GL_ALPHA8:
-      rb->_ActualFormat = GL_ALPHA8;
-      rb->_BaseFormat = GL_RGBA; /* Yes, not GL_ALPHA! */
+      rb->Format = MESA_FORMAT_A8;
       rb->DataType = GL_UNSIGNED_BYTE;
       rb->GetPointer = get_pointer_alpha8;
       rb->GetRow = get_row_alpha8;
@@ -1037,10 +1017,6 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
       rb->PutMonoRow = put_mono_row_alpha8;
       rb->PutValues = put_values_alpha8;
       rb->PutMonoValues = put_mono_values_alpha8;
-      rb->RedBits   = 0; /*red*/
-      rb->GreenBits = 0; /*green*/
-      rb->BlueBits  = 0; /*blue*/
-      rb->AlphaBits = 8 * sizeof(GLubyte);
       pixelSize = sizeof(GLubyte);
       break;
 #endif
@@ -1048,8 +1024,8 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
    case GL_STENCIL_INDEX1_EXT:
    case GL_STENCIL_INDEX4_EXT:
    case GL_STENCIL_INDEX8_EXT:
-      rb->_ActualFormat = GL_STENCIL_INDEX8_EXT;
-      rb->_BaseFormat = GL_STENCIL_INDEX;
+   case GL_STENCIL_INDEX16_EXT:
+      rb->Format = MESA_FORMAT_S8;
       rb->DataType = GL_UNSIGNED_BYTE;
       rb->GetPointer = get_pointer_ubyte;
       rb->GetRow = get_row_ubyte;
@@ -1059,28 +1035,11 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
       rb->PutMonoRow = put_mono_row_ubyte;
       rb->PutValues = put_values_ubyte;
       rb->PutMonoValues = put_mono_values_ubyte;
-      rb->StencilBits = 8 * sizeof(GLubyte);
       pixelSize = sizeof(GLubyte);
       break;
-   case GL_STENCIL_INDEX16_EXT:
-      rb->_ActualFormat = GL_STENCIL_INDEX16_EXT;
-      rb->_BaseFormat = GL_STENCIL_INDEX;
-      rb->DataType = GL_UNSIGNED_SHORT;
-      rb->GetPointer = get_pointer_ushort;
-      rb->GetRow = get_row_ushort;
-      rb->GetValues = get_values_ushort;
-      rb->PutRow = put_row_ushort;
-      rb->PutRowRGB = NULL;
-      rb->PutMonoRow = put_mono_row_ushort;
-      rb->PutValues = put_values_ushort;
-      rb->PutMonoValues = put_mono_values_ushort;
-      rb->StencilBits = 8 * sizeof(GLushort);
-      pixelSize = sizeof(GLushort);
-      break;
    case GL_DEPTH_COMPONENT:
    case GL_DEPTH_COMPONENT16:
-      rb->_ActualFormat = GL_DEPTH_COMPONENT16;
-      rb->_BaseFormat = GL_DEPTH_COMPONENT;
+      rb->Format = MESA_FORMAT_Z16;
       rb->DataType = GL_UNSIGNED_SHORT;
       rb->GetPointer = get_pointer_ushort;
       rb->GetRow = get_row_ushort;
@@ -1090,12 +1049,22 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
       rb->PutMonoRow = put_mono_row_ushort;
       rb->PutValues = put_values_ushort;
       rb->PutMonoValues = put_mono_values_ushort;
-      rb->DepthBits = 8 * sizeof(GLushort);
       pixelSize = sizeof(GLushort);
       break;
    case GL_DEPTH_COMPONENT24:
+      rb->DataType = GL_UNSIGNED_INT;
+      rb->GetPointer = get_pointer_uint;
+      rb->GetRow = get_row_uint;
+      rb->GetValues = get_values_uint;
+      rb->PutRow = put_row_uint;
+      rb->PutRowRGB = NULL;
+      rb->PutMonoRow = put_mono_row_uint;
+      rb->PutValues = put_values_uint;
+      rb->PutMonoValues = put_mono_values_uint;
+      rb->Format = MESA_FORMAT_X8_Z24;
+      pixelSize = sizeof(GLuint);
+      break;
    case GL_DEPTH_COMPONENT32:
-      rb->_BaseFormat = GL_DEPTH_COMPONENT;
       rb->DataType = GL_UNSIGNED_INT;
       rb->GetPointer = get_pointer_uint;
       rb->GetRow = get_row_uint;
@@ -1105,20 +1074,12 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
       rb->PutMonoRow = put_mono_row_uint;
       rb->PutValues = put_values_uint;
       rb->PutMonoValues = put_mono_values_uint;
-      if (internalFormat == GL_DEPTH_COMPONENT24) {
-         rb->_ActualFormat = GL_DEPTH_COMPONENT24;
-         rb->DepthBits = 24;
-      }
-      else {
-         rb->_ActualFormat = GL_DEPTH_COMPONENT32;
-         rb->DepthBits = 32;
-      }
+      rb->Format = MESA_FORMAT_Z32;
       pixelSize = sizeof(GLuint);
       break;
    case GL_DEPTH_STENCIL_EXT:
    case GL_DEPTH24_STENCIL8_EXT:
-      rb->_ActualFormat = GL_DEPTH24_STENCIL8_EXT;
-      rb->_BaseFormat = GL_DEPTH_STENCIL_EXT;
+      rb->Format = MESA_FORMAT_Z24_S8;
       rb->DataType = GL_UNSIGNED_INT_24_8_EXT;
       rb->GetPointer = get_pointer_uint;
       rb->GetRow = get_row_uint;
@@ -1128,13 +1089,12 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
       rb->PutMonoRow = put_mono_row_uint;
       rb->PutValues = put_values_uint;
       rb->PutMonoValues = put_mono_values_uint;
-      rb->DepthBits = 24;
-      rb->StencilBits = 8;
       pixelSize = sizeof(GLuint);
       break;
    case GL_COLOR_INDEX8_EXT:
-      rb->_ActualFormat = GL_COLOR_INDEX8_EXT;
-      rb->_BaseFormat = GL_COLOR_INDEX;
+   case GL_COLOR_INDEX16_EXT:
+   case COLOR_INDEX32:
+      rb->Format = MESA_FORMAT_CI8;
       rb->DataType = GL_UNSIGNED_BYTE;
       rb->GetPointer = get_pointer_ubyte;
       rb->GetRow = get_row_ubyte;
@@ -1144,39 +1104,8 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
       rb->PutMonoRow = put_mono_row_ubyte;
       rb->PutValues = put_values_ubyte;
       rb->PutMonoValues = put_mono_values_ubyte;
-      rb->IndexBits = 8 * sizeof(GLubyte);
       pixelSize = sizeof(GLubyte);
       break;
-   case GL_COLOR_INDEX16_EXT:
-      rb->_ActualFormat = GL_COLOR_INDEX16_EXT;
-      rb->_BaseFormat = GL_COLOR_INDEX;
-      rb->DataType = GL_UNSIGNED_SHORT;
-      rb->GetPointer = get_pointer_ushort;
-      rb->GetRow = get_row_ushort;
-      rb->GetValues = get_values_ushort;
-      rb->PutRow = put_row_ushort;
-      rb->PutRowRGB = NULL;
-      rb->PutMonoRow = put_mono_row_ushort;
-      rb->PutValues = put_values_ushort;
-      rb->PutMonoValues = put_mono_values_ushort;
-      rb->IndexBits = 8 * sizeof(GLushort);
-      pixelSize = sizeof(GLushort);
-      break;
-   case COLOR_INDEX32:
-      rb->_ActualFormat = COLOR_INDEX32;
-      rb->_BaseFormat = GL_COLOR_INDEX;
-      rb->DataType = GL_UNSIGNED_INT;
-      rb->GetPointer = get_pointer_uint;
-      rb->GetRow = get_row_uint;
-      rb->GetValues = get_values_uint;
-      rb->PutRow = put_row_uint;
-      rb->PutRowRGB = NULL;
-      rb->PutMonoRow = put_mono_row_uint;
-      rb->PutValues = put_values_uint;
-      rb->PutMonoValues = put_mono_values_uint;
-      rb->IndexBits = 8 * sizeof(GLuint);
-      pixelSize = sizeof(GLuint);
-      break;
    default:
       _mesa_problem(ctx, "Bad internalFormat in _mesa_soft_renderbuffer_storage");
       return GL_FALSE;
@@ -1213,6 +1142,7 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
 
    rb->Width = width;
    rb->Height = height;
+   rb->_BaseFormat = _mesa_base_fbo_format(ctx, rb->InternalFormat);
 
    return GL_TRUE;
 }
@@ -1239,7 +1169,7 @@ alloc_storage_alpha8(GLcontext *ctx, struct gl_renderbuffer *arb,
                      GLenum internalFormat, GLuint width, GLuint height)
 {
    ASSERT(arb != arb->Wrapped);
-   ASSERT(arb->_ActualFormat == GL_ALPHA8);
+   ASSERT(arb->Format == MESA_FORMAT_A8);
 
    /* first, pass the call to the wrapped RGB buffer */
    if (!arb->Wrapped->AllocStorage(ctx, arb->Wrapped, internalFormat,
@@ -1439,8 +1369,8 @@ put_mono_values_alpha8(GLcontext *ctx, struct gl_renderbuffer *arb,
 static void
 copy_buffer_alpha8(struct gl_renderbuffer* dst, struct gl_renderbuffer* src)
 {
-   ASSERT(dst->_ActualFormat == GL_ALPHA8);
-   ASSERT(src->_ActualFormat == GL_ALPHA8);
+   ASSERT(dst->Format == MESA_FORMAT_A8);
+   ASSERT(src->Format == MESA_FORMAT_A8);
    ASSERT(dst->Width == src->Width);
    ASSERT(dst->Height == src->Height);
 
@@ -1486,16 +1416,7 @@ _mesa_init_renderbuffer(struct gl_renderbuffer *rb, GLuint name)
    rb->Width = 0;
    rb->Height = 0;
    rb->InternalFormat = GL_NONE;
-   rb->_ActualFormat = GL_NONE;
-   rb->_BaseFormat = GL_NONE;
-
-   rb->ComponentType = GL_UNSIGNED_NORMALIZED; /* ARB_fbo */
-   rb->ColorEncoding = GL_LINEAR; /* ARB_fbo */
-
-   rb->RedBits = rb->GreenBits = rb->BlueBits = rb->AlphaBits = 0;
-   rb->IndexBits = 0;
-   rb->DepthBits = 0;
-   rb->StencilBits = 0;
+   rb->Format = MESA_FORMAT_NONE;
 
    rb->DataType = GL_NONE;
    rb->Data = NULL;
@@ -1612,18 +1533,15 @@ _mesa_add_color_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb,
 
       if (rgbBits <= 8) {
          if (alphaBits)
-            rb->_ActualFormat = GL_RGBA8;
+            rb->Format = MESA_FORMAT_RGBA8888;
          else
-            rb->_ActualFormat = GL_RGB8;
+            rb->Format = MESA_FORMAT_RGB888;
       }
       else {
          assert(rgbBits <= 16);
-         if (alphaBits)
-            rb->_ActualFormat = GL_RGBA16;
-         else
-            rb->_ActualFormat = GL_RGBA16; /* don't really have RGB16 yet */
+         rb->Format = MESA_FORMAT_NONE; /*XXX RGBA16;*/
       }
-      rb->InternalFormat = rb->_ActualFormat;
+      rb->InternalFormat = GL_RGBA;
 
       rb->AllocStorage = _mesa_soft_renderbuffer_storage;
       _mesa_add_renderbuffer(fb, b, rb);
@@ -1677,15 +1595,9 @@ _mesa_add_color_index_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb,
          return GL_FALSE;
       }
 
-      if (indexBits <= 8) {
-         /* only support GLuint for now */
-         /*rb->InternalFormat = GL_COLOR_INDEX8_EXT;*/
-         rb->_ActualFormat = COLOR_INDEX32;
-      }
-      else {
-         rb->_ActualFormat = COLOR_INDEX32;
-      }
-      rb->InternalFormat = rb->_ActualFormat;
+      assert(indexBits <= 8);
+      rb->Format = MESA_FORMAT_CI8;
+      rb->InternalFormat = GL_COLOR_INDEX;
 
       rb->AllocStorage = _mesa_soft_renderbuffer_storage;
       _mesa_add_renderbuffer(fb, b, rb);
@@ -1758,8 +1670,7 @@ _mesa_add_alpha_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb,
        * values.
        */
       arb->InternalFormat = arb->Wrapped->InternalFormat;
-      arb->_ActualFormat  = GL_ALPHA8;
-      arb->_BaseFormat    = arb->Wrapped->_BaseFormat;
+      arb->Format         = MESA_FORMAT_A8;
       arb->DataType       = arb->Wrapped->DataType;
       arb->AllocStorage   = alloc_storage_alpha8;
       arb->Delete         = delete_renderbuffer_alpha8;
@@ -1833,15 +1744,17 @@ _mesa_add_depth_renderbuffer(GLcontext *ctx, struct gl_framebuffer *fb,
    }
 
    if (depthBits <= 16) {
-      rb->_ActualFormat = GL_DEPTH_COMPONENT16;
+      rb->Format = MESA_FORMAT_Z16;
+      rb->InternalFormat = GL_DEPTH_COMPONENT16;
    }
    else if (depthBits <= 24) {
-      rb->_ActualFormat = GL_DEPTH_COMPONENT24;
+      rb->Format = MESA_FORMAT_X8_Z24;
+      rb->InternalFormat = GL_DEPTH_COMPONENT24;
    }
    else {
-      rb->_ActualFormat = GL_DEPTH_COMPONENT32;
+      rb->Format = MESA_FORMAT_Z32;
+      rb->InternalFormat = GL_DEPTH_COMPONENT32;
    }
-   rb->InternalFormat = rb->_ActualFormat;
 
    rb->AllocStorage = _mesa_soft_renderbuffer_storage;
    _mesa_add_renderbuffer(fb, BUFFER_DEPTH, rb);
@@ -1878,14 +1791,9 @@ _mesa_add_stencil_renderbuffer(GLcontext *ctx, struct gl_framebuffer *fb,
       return GL_FALSE;
    }
 
-   if (stencilBits <= 8) {
-      rb->_ActualFormat = GL_STENCIL_INDEX8_EXT;
-   }
-   else {
-      /* not really supported (see s_stencil.c code) */
-      rb->_ActualFormat = GL_STENCIL_INDEX16_EXT;
-   }
-   rb->InternalFormat = rb->_ActualFormat;
+   assert(stencilBits <= 8);
+   rb->Format = MESA_FORMAT_S8;
+   rb->InternalFormat = GL_STENCIL_INDEX8;
 
    rb->AllocStorage = _mesa_soft_renderbuffer_storage;
    _mesa_add_renderbuffer(fb, BUFFER_STENCIL, rb);
@@ -1923,7 +1831,7 @@ _mesa_add_accum_renderbuffer(GLcontext *ctx, struct gl_framebuffer *fb,
       return GL_FALSE;
    }
 
-   rb->_ActualFormat = GL_RGBA16;
+   rb->Format = MESA_FORMAT_SIGNED_RGBA_16;
    rb->InternalFormat = GL_RGBA16;
    rb->AllocStorage = _mesa_soft_renderbuffer_storage;
    _mesa_add_renderbuffer(fb, BUFFER_ACCUM, rb);
@@ -1955,7 +1863,7 @@ _mesa_add_aux_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb,
       return GL_FALSE;
    }
 
-   assert(numBuffers < MAX_AUX_BUFFERS);
+   assert(numBuffers <= MAX_AUX_BUFFERS);
 
    for (i = 0; i < numBuffers; i++) {
       struct gl_renderbuffer *rb = _mesa_new_renderbuffer(ctx, 0);
@@ -1967,13 +1875,9 @@ _mesa_add_aux_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb,
          return GL_FALSE;
       }
 
-      if (colorBits <= 8) {
-         rb->_ActualFormat = GL_RGBA8;
-      }
-      else {
-         rb->_ActualFormat = GL_RGBA16;
-      }
-      rb->InternalFormat = rb->_ActualFormat;
+      assert (colorBits <= 8);
+      rb->Format = MESA_FORMAT_RGBA8888;
+      rb->InternalFormat = GL_RGBA;
 
       rb->AllocStorage = _mesa_soft_renderbuffer_storage;
       _mesa_add_renderbuffer(fb, BUFFER_AUX0 + i, rb);
@@ -2071,6 +1975,8 @@ void
 _mesa_add_renderbuffer(struct gl_framebuffer *fb,
                        GLuint bufferName, struct gl_renderbuffer *rb)
 {
+   GLenum baseFormat;
+
    assert(fb);
    assert(rb);
    assert(bufferName < BUFFER_COUNT);
@@ -2095,7 +2001,8 @@ _mesa_add_renderbuffer(struct gl_framebuffer *fb,
     * and the device driver is expecting 8-bit values (GLubyte), we can
     * use a "renderbuffer adaptor/wrapper" to do the necessary conversions.
     */
-   if (rb->_BaseFormat == GL_RGBA) {
+   baseFormat = _mesa_get_format_base_format(rb->Format);
+   if (baseFormat == GL_RGBA) {
       if (CHAN_BITS == 16 && rb->DataType == GL_UNSIGNED_BYTE) {
          GET_CURRENT_CONTEXT(ctx);
          rb = _mesa_new_renderbuffer_16wrap8(ctx, rb);
@@ -2202,7 +2109,7 @@ _mesa_new_depthstencil_renderbuffer(GLcontext *ctx, GLuint name)
 
    /* init fields not covered by _mesa_new_renderbuffer() */
    dsrb->InternalFormat = GL_DEPTH24_STENCIL8_EXT;
-   dsrb->_ActualFormat = GL_DEPTH24_STENCIL8_EXT;
+   dsrb->Format = MESA_FORMAT_Z24_S8;
    dsrb->AllocStorage = _mesa_soft_renderbuffer_storage;
 
    return dsrb;
index bc76b912913a08083294f7b3917c5112eec70a83..d0dc7e551c92fd77d09c8905e75721b1424489b7 100644 (file)
 #include "glheader.h"
 #include "context.h"
 #include "shaders.h"
+#include "shader/shader_api.h"
+
+
+/** Define this to enable shader substitution (see below) */
+#define SHADER_SUBST 0
+
 
 
 /**
@@ -388,7 +394,6 @@ _mesa_read_shader(const char *fname)
    int len;
 
    if (!f) {
-      _mesa_fprintf(stderr, "Unable to open shader file %s\n", fname);
       return NULL;
    }
 
@@ -401,16 +406,10 @@ _mesa_read_shader(const char *fname)
    shader = _mesa_strdup(buffer);
    free(buffer);
 
-   if (0) {
-      _mesa_fprintf(stderr, "Read shader %s:\n", fname);
-      _mesa_fprintf(stderr, "%s\n", shader);
-   }
-
    return shader;
 }
 
 
-
 /**
  * Called via glShaderSource() and glShaderSourceARB() API functions.
  * Basically, concatenate the source code strings into one long string
@@ -424,6 +423,7 @@ _mesa_ShaderSourceARB(GLhandleARB shaderObj, GLsizei count,
    GLint *offsets;
    GLsizei i, totalLength;
    GLcharARB *source;
+   GLuint checksum;
 
    if (!shaderObj || string == NULL) {
       _mesa_error(ctx, GL_INVALID_VALUE, "glShaderSourceARB");
@@ -475,22 +475,35 @@ _mesa_ShaderSourceARB(GLhandleARB shaderObj, GLsizei count,
    source[totalLength - 1] = '\0';
    source[totalLength - 2] = '\0';
 
-#if 0
-   if (0) {
+   if (SHADER_SUBST) {
+      /* Compute the shader's source code checksum then try to open a file
+       * named newshader_<CHECKSUM>.  If it exists, use it in place of the
+       * original shader source code.  For debugging.
+       */
+      char filename[100];
       GLcharARB *newSource;
 
-      newSource = _mesa_read_shader("newshader.frag");
+      checksum = _mesa_str_checksum(source);
+
+      sprintf(filename, "newshader_%d", checksum);
+
+      newSource = _mesa_read_shader(filename);
       if (newSource) {
+         _mesa_fprintf(stderr, "Mesa: Replacing shader %u chksum=%d with %s\n",
+                       shaderObj, checksum, filename);
          _mesa_free(source);
          source = newSource;
       }
-   }
-#else
-   (void) _mesa_read_shader;
-#endif
+   }      
 
    ctx->Driver.ShaderSource(ctx, shaderObj, source);
 
+   if (SHADER_SUBST) {
+      struct gl_shader *sh = _mesa_lookup_shader(ctx, shaderObj);
+      if (sh)
+         sh->SourceChecksum = checksum; /* save original checksum */
+   }
+
    _mesa_free(offsets);
 }
 
index c1b8c7675a27be612bf0d81451381efa68807941..a4f1926ab3789d11351f242fd60a88de3688ab82 100644 (file)
 #include "imports.h"
 #include "colormac.h"
 #include "context.h"
+#include "formats.h"
 #include "image.h"
 #include "mipmap.h"
 #include "texcompress.h"
-#include "texformat.h"
 #include "texstore.h"
 
 
@@ -113,250 +113,121 @@ _mesa_get_compressed_formats(GLcontext *ctx, GLint *formats, GLboolean all)
 }
 
 
-
-/**
- * Return number of bytes needed to store a texture of the given size
- * using the specified compressed format.
- * This is called via the ctx->Driver.CompressedTextureSize function,
- * unless a device driver overrides it.
- *
- * \param width texture width in texels.
- * \param height texture height in texels.
- * \param depth texture depth in texels.
- * \param mesaFormat  one of the MESA_FORMAT_* compressed formats
- *
- * \return size in bytes, or zero if bad format
- */
-GLuint
-_mesa_compressed_texture_size( GLcontext *ctx,
-                               GLsizei width, GLsizei height, GLsizei depth,
-                               GLuint mesaFormat )
-{
-   GLuint size;
-
-   ASSERT(depth == 1);
-   (void) depth;
-   (void) size;
-
-   switch (mesaFormat) {
-#if FEATURE_texture_fxt1
-   case MESA_FORMAT_RGB_FXT1:
-   case MESA_FORMAT_RGBA_FXT1:
-      /* round up width to next multiple of 8, height to next multiple of 4 */
-      width = (width + 7) & ~7;
-      height = (height + 3) & ~3;
-      /* 16 bytes per 8x4 tile of RGB[A] texels */
-      size = width * height / 2;
-      /* Textures smaller than 8x4 will effectively be made into 8x4 and
-       * take 16 bytes.
-       */
-      return size;
-#endif
-#if FEATURE_texture_s3tc
-   case MESA_FORMAT_RGB_DXT1:
-   case MESA_FORMAT_RGBA_DXT1:
-#if FEATURE_EXT_texture_sRGB
-   case MESA_FORMAT_SRGB_DXT1:
-   case MESA_FORMAT_SRGBA_DXT1:
-#endif
-      /* round up width, height to next multiple of 4 */
-      width = (width + 3) & ~3;
-      height = (height + 3) & ~3;
-      /* 8 bytes per 4x4 tile of RGB[A] texels */
-      size = width * height / 2;
-      /* Textures smaller than 4x4 will effectively be made into 4x4 and
-       * take 8 bytes.
-       */
-      return size;
-   case MESA_FORMAT_RGBA_DXT3:
-   case MESA_FORMAT_RGBA_DXT5:
-#if FEATURE_EXT_texture_sRGB
-   case MESA_FORMAT_SRGBA_DXT3:
-   case MESA_FORMAT_SRGBA_DXT5:
-#endif
-      /* round up width, height to next multiple of 4 */
-      width = (width + 3) & ~3;
-      height = (height + 3) & ~3;
-      /* 16 bytes per 4x4 tile of RGBA texels */
-      size = width * height; /* simple! */
-      /* Textures smaller than 4x4 will effectively be made into 4x4 and
-       * take 16 bytes.
-       */
-      return size;
-#endif
-   default:
-      _mesa_problem(ctx, "bad mesaFormat in _mesa_compressed_texture_size");
-      return 0;
-   }
-}
-
-
 /**
- * As above, but format is specified by a GLenum (GL_COMPRESSED_*) token.
- *
- * Note: This function CAN NOT return a padded hardware texture size.
- * That's why we don't call the ctx->Driver.CompressedTextureSize() function.
- *
- * We use this function to validate the <imageSize> parameter
- * of glCompressedTex[Sub]Image1/2/3D(), which must be an exact match.
+ * Convert a compressed MESA_FORMAT_x to a GLenum.
  */
-GLuint
-_mesa_compressed_texture_size_glenum(GLcontext *ctx,
-                                     GLsizei width, GLsizei height,
-                                     GLsizei depth, GLenum glformat)
+gl_format
+_mesa_glenum_to_compressed_format(GLenum format)
 {
-   GLuint mesaFormat;
-
-   switch (glformat) {
-#if FEATURE_texture_fxt1
+   switch (format) {
    case GL_COMPRESSED_RGB_FXT1_3DFX:
-      mesaFormat = MESA_FORMAT_RGB_FXT1;
-      break;
+      return MESA_FORMAT_RGB_FXT1;
    case GL_COMPRESSED_RGBA_FXT1_3DFX:
-      mesaFormat = MESA_FORMAT_RGBA_FXT1;
-      break;
-#endif
-#if FEATURE_texture_s3tc
+      return MESA_FORMAT_RGBA_FXT1;
+
    case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
    case GL_RGB_S3TC:
-      mesaFormat = MESA_FORMAT_RGB_DXT1;
-      break;
+      return MESA_FORMAT_RGB_DXT1;
    case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
    case GL_RGB4_S3TC:
-      mesaFormat = MESA_FORMAT_RGBA_DXT1;
-      break;
+      return MESA_FORMAT_RGBA_DXT1;
    case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
    case GL_RGBA_S3TC:
-      mesaFormat = MESA_FORMAT_RGBA_DXT3;
-      break;
+      return MESA_FORMAT_RGBA_DXT3;
    case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
    case GL_RGBA4_S3TC:
-      mesaFormat = MESA_FORMAT_RGBA_DXT5;
-      break;
-#if FEATURE_EXT_texture_sRGB
+      return MESA_FORMAT_RGBA_DXT5;
+
    case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
-      mesaFormat = MESA_FORMAT_SRGB_DXT1;
-      break;
+      return MESA_FORMAT_SRGB_DXT1;
    case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
-      mesaFormat = MESA_FORMAT_SRGBA_DXT1;
-      break;
+      return MESA_FORMAT_SRGBA_DXT1;
    case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
-      mesaFormat = MESA_FORMAT_SRGBA_DXT3;
-      break;
+      return MESA_FORMAT_SRGBA_DXT3;
    case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
-      mesaFormat = MESA_FORMAT_SRGBA_DXT5;
-      break;
-#endif
-#endif
+      return MESA_FORMAT_SRGBA_DXT5;
+
    default:
-      return 0;
+      return MESA_FORMAT_NONE;
    }
-
-   return _mesa_compressed_texture_size(ctx, width, height, depth, mesaFormat);
 }
 
 
-/*
- * Compute the bytes per row in a compressed texture image.
- * We use this for computing the destination address for sub-texture updates.
- * \param mesaFormat  one of the MESA_FORMAT_* compressed formats
- * \param width  image width in pixels
- * \return stride, in bytes, between rows for compressed image
+/**
+ * Given a compressed MESA_FORMAT_x value, return the corresponding
+ * GLenum for that format.
+ * This is needed for glGetTexLevelParameter(GL_TEXTURE_INTERNAL_FORMAT)
+ * which must return the specific texture format used when the user might
+ * have originally specified a generic compressed format in their
+ * glTexImage2D() call.
+ * For non-compressed textures, we always return the user-specified
+ * internal format unchanged.
  */
-GLint
-_mesa_compressed_row_stride(GLuint mesaFormat, GLsizei width)
+GLenum
+_mesa_compressed_format_to_glenum(GLcontext *ctx, GLuint mesaFormat)
 {
-   GLint stride;
-
    switch (mesaFormat) {
 #if FEATURE_texture_fxt1
    case MESA_FORMAT_RGB_FXT1:
+      return GL_COMPRESSED_RGB_FXT1_3DFX;
    case MESA_FORMAT_RGBA_FXT1:
-      stride = ((width + 7) / 8) * 16; /* 16 bytes per 8x4 tile */
-      break;
+      return GL_COMPRESSED_RGBA_FXT1_3DFX;
 #endif
 #if FEATURE_texture_s3tc
    case MESA_FORMAT_RGB_DXT1:
+      return GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
    case MESA_FORMAT_RGBA_DXT1:
-#if FEATURE_EXT_texture_sRGB
-   case MESA_FORMAT_SRGB_DXT1:
-   case MESA_FORMAT_SRGBA_DXT1:
-#endif
-      stride = ((width + 3) / 4) * 8; /* 8 bytes per 4x4 tile */
-      break;
+      return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
    case MESA_FORMAT_RGBA_DXT3:
+      return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
    case MESA_FORMAT_RGBA_DXT5:
+      return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
 #if FEATURE_EXT_texture_sRGB
+   case MESA_FORMAT_SRGB_DXT1:
+      return GL_COMPRESSED_SRGB_S3TC_DXT1_EXT;
+   case MESA_FORMAT_SRGBA_DXT1:
+      return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;
    case MESA_FORMAT_SRGBA_DXT3:
+      return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;
    case MESA_FORMAT_SRGBA_DXT5:
+      return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;
 #endif
-      stride = ((width + 3) / 4) * 16; /* 16 bytes per 4x4 tile */
-      break;
 #endif
    default:
-      _mesa_problem(NULL, "bad mesaFormat in _mesa_compressed_row_stride");
+      _mesa_problem(ctx, "Unexpected mesa texture format in"
+                    " _mesa_compressed_format_to_glenum()");
       return 0;
    }
-
-   return stride;
 }
 
 
 /*
  * Return the address of the pixel at (col, row, img) in a
  * compressed texture image.
- * \param col, row, img - image position (3D)
+ * \param col, row, img - image position (3D), should be a multiple of the
+ *                        format's block size.
  * \param format - compressed image format
- * \param width - image width
+ * \param width - image width (stride) in pixels
  * \param image - the image address
- * \return address of pixel at (row, col)
+ * \return address of pixel at (row, col, img)
  */
 GLubyte *
 _mesa_compressed_image_address(GLint col, GLint row, GLint img,
-                               GLuint mesaFormat,
+                               gl_format mesaFormat,
                                GLsizei width, const GLubyte *image)
 {
-   GLubyte *addr;
+   /* XXX only 2D images implemented, not 3D */
+   const GLuint blockSize = _mesa_get_format_bytes(mesaFormat);
+   GLuint bw, bh;
+   GLint offset;
 
-   (void) img;
+   _mesa_get_format_block_size(mesaFormat, &bw, &bh);
 
-   /* We try to spot a "complete" subtexture "above" ROW, COL;
-    * this texture is given by appropriate rounding of WIDTH x ROW.
-    * Then we just add the amount left (usually on the left).
-    *
-    * Example for X*Y microtiles (Z bytes each)
-    * offset = Z * (((width + X - 1) / X) * (row / Y) + col / X);
-    */
+   ASSERT(col % bw == 0);
+   ASSERT(row % bh == 0);
 
-   switch (mesaFormat) {
-#if FEATURE_texture_fxt1
-   case MESA_FORMAT_RGB_FXT1:
-   case MESA_FORMAT_RGBA_FXT1:
-      addr = (GLubyte *) image + 16 * (((width + 7) / 8) * (row / 4) + col / 8);
-      break;
-#endif
-#if FEATURE_texture_s3tc
-   case MESA_FORMAT_RGB_DXT1:
-   case MESA_FORMAT_RGBA_DXT1:
-#if FEATURE_EXT_texture_sRGB
-   case MESA_FORMAT_SRGB_DXT1:
-   case MESA_FORMAT_SRGBA_DXT1:
-#endif
-      addr = (GLubyte *) image + 8 * (((width + 3) / 4) * (row / 4) + col / 4);
-      break;
-   case MESA_FORMAT_RGBA_DXT3:
-   case MESA_FORMAT_RGBA_DXT5:
-#if FEATURE_EXT_texture_sRGB
-   case MESA_FORMAT_SRGBA_DXT3:
-   case MESA_FORMAT_SRGBA_DXT5:
-#endif
-      addr = (GLubyte *) image + 16 * (((width + 3) / 4) * (row / 4) + col / 4);
-      break;
-#endif
-   default:
-      _mesa_problem(NULL, "bad mesaFormat in _mesa_compressed_image_address");
-      addr = NULL;
-   }
+   offset = ((width + bw - 1) / bw) * (row / bh) + col / bw;
+   offset *= blockSize;
 
-   return addr;
+   return (GLubyte *) image + offset;
 }
index 44f33382228961abdcb11126c0b342dc208955a3..5e73a3149bddf6979f6ba985034ddef7b3359e67 100644 (file)
 #define TEXCOMPRESS_H
 
 #include "mtypes.h"
+#include "formats.h"
 
 #if _HAVE_FULL_GL
 
 extern GLuint
 _mesa_get_compressed_formats(GLcontext *ctx, GLint *formats, GLboolean all);
 
-extern GLuint
-_mesa_compressed_texture_size( GLcontext *ctx,
-                               GLsizei width, GLsizei height, GLsizei depth,
-                               GLuint mesaFormat );
-
-extern GLuint
-_mesa_compressed_texture_size_glenum(GLcontext *ctx,
-                                     GLsizei width, GLsizei height,
-                                     GLsizei depth, GLenum glformat);
-
-extern GLint
-_mesa_compressed_row_stride(GLuint mesaFormat, GLsizei width);
+extern gl_format
+_mesa_glenum_to_compressed_format(GLenum format);
 
+extern GLenum
+_mesa_compressed_format_to_glenum(GLcontext *ctx, GLuint mesaFormat);
 
 extern GLubyte *
 _mesa_compressed_image_address(GLint col, GLint row, GLint img,
-                               GLuint mesaFormat,
+                               gl_format mesaFormat,
                                GLsizei width, const GLubyte *image);
 
-
-extern void
-_mesa_init_texture_s3tc( GLcontext *ctx );
-
-extern void
-_mesa_init_texture_fxt1( GLcontext *ctx );
-
-
 #else /* _HAVE_FULL_GL */
 
 /* no-op macros */
 #define _mesa_get_compressed_formats( c, f ) 0
-#define _mesa_compressed_texture_size( c, w, h, d, f ) 0
-#define _mesa_compressed_texture_size_glenum( c, w, h, d, f ) 0
-#define _mesa_compressed_row_stride( f, w) 0
 #define _mesa_compressed_image_address(c, r, i, f, w, i2 ) 0
 #define _mesa_compress_teximage( c, w, h, sF, s, sRS, dF, d, drs ) ((void)0)
 
index fc151605c9e32319e9a05eba6f1dbeb206536969..85becb80d2a30b3239f5950d76eb477887b5a432 100644 (file)
 #include "image.h"
 #include "mipmap.h"
 #include "texcompress.h"
-#include "texformat.h"
+#include "texcompress_fxt1.h"
 #include "texstore.h"
 
 
+#if FEATURE_texture_fxt1
+
+
 static void
 fxt1_encode (GLuint width, GLuint height, GLint comps,
              const void *source, GLint srcRowStride,
@@ -52,20 +55,10 @@ fxt1_decode_1 (const void *texture, GLint stride,
 
 
 /**
- * Called during context initialization.
- */
-void
-_mesa_init_texture_fxt1( GLcontext *ctx )
-{
-   (void) ctx;
-}
-
-
-/**
- * Called via TexFormat->StoreImage to store an RGB_FXT1 texture.
+ * Store user's image in rgb_fxt1 format.
  */
-static GLboolean
-texstore_rgb_fxt1(TEXSTORE_PARAMS)
+GLboolean
+_mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS)
 {
    const GLchan *pixels;
    GLint srcRowStride;
@@ -73,7 +66,7 @@ texstore_rgb_fxt1(TEXSTORE_PARAMS)
    const GLint texWidth = dstRowStride * 8 / 16; /* a bit of a hack */
    const GLchan *tempImage = NULL;
 
-   ASSERT(dstFormat == &_mesa_texformat_rgb_fxt1);
+   ASSERT(dstFormat == MESA_FORMAT_RGB_FXT1);
    ASSERT(dstXoffset % 8 == 0);
    ASSERT(dstYoffset % 4 == 0);
    ASSERT(dstZoffset     == 0);
@@ -87,7 +80,7 @@ texstore_rgb_fxt1(TEXSTORE_PARAMS)
       /* convert image to RGB/GLchan */
       tempImage = _mesa_make_temp_chan_image(ctx, dims,
                                              baseInternalFormat,
-                                             dstFormat->BaseFormat,
+                                             _mesa_get_format_base_format(dstFormat),
                                              srcWidth, srcHeight, srcDepth,
                                              srcFormat, srcType, srcAddr,
                                              srcPacking);
@@ -105,7 +98,7 @@ texstore_rgb_fxt1(TEXSTORE_PARAMS)
    }
 
    dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
-                                        dstFormat->MesaFormat,
+                                        dstFormat,
                                         texWidth, (GLubyte *) dstAddr);
 
    fxt1_encode(srcWidth, srcHeight, 3, pixels, srcRowStride,
@@ -119,10 +112,10 @@ texstore_rgb_fxt1(TEXSTORE_PARAMS)
 
 
 /**
- * Called via TexFormat->StoreImage to store an RGBA_FXT1 texture.
+ * Store user's image in rgba_fxt1 format.
  */
-static GLboolean
-texstore_rgba_fxt1(TEXSTORE_PARAMS)
+GLboolean
+_mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS)
 {
    const GLchan *pixels;
    GLint srcRowStride;
@@ -130,7 +123,7 @@ texstore_rgba_fxt1(TEXSTORE_PARAMS)
    GLint texWidth = dstRowStride * 8 / 16; /* a bit of a hack */
    const GLchan *tempImage = NULL;
 
-   ASSERT(dstFormat == &_mesa_texformat_rgba_fxt1);
+   ASSERT(dstFormat == MESA_FORMAT_RGBA_FXT1);
    ASSERT(dstXoffset % 8 == 0);
    ASSERT(dstYoffset % 4 == 0);
    ASSERT(dstZoffset     == 0);
@@ -144,7 +137,7 @@ texstore_rgba_fxt1(TEXSTORE_PARAMS)
       /* convert image to RGBA/GLchan */
       tempImage = _mesa_make_temp_chan_image(ctx, dims,
                                              baseInternalFormat,
-                                             dstFormat->BaseFormat,
+                                             _mesa_get_format_base_format(dstFormat),
                                              srcWidth, srcHeight, srcDepth,
                                              srcFormat, srcType, srcAddr,
                                              srcPacking);
@@ -162,7 +155,7 @@ texstore_rgba_fxt1(TEXSTORE_PARAMS)
    }
 
    dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
-                                        dstFormat->MesaFormat,
+                                        dstFormat,
                                         texWidth, (GLubyte *) dstAddr);
 
    fxt1_encode(srcWidth, srcHeight, 4, pixels, srcRowStride,
@@ -175,18 +168,9 @@ texstore_rgba_fxt1(TEXSTORE_PARAMS)
 }
 
 
-static void
-fetch_texel_2d_rgba_fxt1( const struct gl_texture_image *texImage,
-                          GLint i, GLint j, GLint k, GLchan *texel )
-{
-   (void) k;
-   fxt1_decode_1(texImage->Data, texImage->RowStride, i, j, texel);
-}
-
-
-static void
-fetch_texel_2d_f_rgba_fxt1( const struct gl_texture_image *texImage,
-                            GLint i, GLint j, GLint k, GLfloat *texel )
+void
+_mesa_fetch_texel_2d_f_rgba_fxt1( const struct gl_texture_image *texImage,
+                                  GLint i, GLint j, GLint k, GLfloat *texel )
 {
    /* just sample as GLchan and convert to float here */
    GLchan rgba[4];
@@ -199,19 +183,9 @@ fetch_texel_2d_f_rgba_fxt1( const struct gl_texture_image *texImage,
 }
 
 
-static void
-fetch_texel_2d_rgb_fxt1( const struct gl_texture_image *texImage,
-                         GLint i, GLint j, GLint k, GLchan *texel )
-{
-   (void) k;
-   fxt1_decode_1(texImage->Data, texImage->RowStride, i, j, texel);
-   texel[ACOMP] = 255;
-}
-
-
-static void
-fetch_texel_2d_f_rgb_fxt1( const struct gl_texture_image *texImage,
-                           GLint i, GLint j, GLint k, GLfloat *texel )
+void
+_mesa_fetch_texel_2d_f_rgb_fxt1( const struct gl_texture_image *texImage,
+                                 GLint i, GLint j, GLint k, GLfloat *texel )
 {
    /* just sample as GLchan and convert to float here */
    GLchan rgba[4];
@@ -225,55 +199,6 @@ fetch_texel_2d_f_rgb_fxt1( const struct gl_texture_image *texImage,
 
 
 
-const struct gl_texture_format _mesa_texformat_rgb_fxt1 = {
-   MESA_FORMAT_RGB_FXT1,               /* MesaFormat */
-   GL_RGB,                             /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   4, /*approx*/                       /* RedBits */
-   4, /*approx*/                       /* GreenBits */
-   4, /*approx*/                       /* BlueBits */
-   0,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   0,                                  /* TexelBytes */
-   texstore_rgb_fxt1,                  /* StoreTexImageFunc */
-   NULL, /*impossible*/                /* FetchTexel1D */
-   fetch_texel_2d_rgb_fxt1,            /* FetchTexel2D */
-   NULL, /*impossible*/                /* FetchTexel3D */
-   NULL, /*impossible*/                /* FetchTexel1Df */
-   fetch_texel_2d_f_rgb_fxt1,          /* FetchTexel2Df */
-   NULL, /*impossible*/                /* FetchTexel3Df */
-   NULL                                        /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_rgba_fxt1 = {
-   MESA_FORMAT_RGBA_FXT1,              /* MesaFormat */
-   GL_RGBA,                            /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   4, /*approx*/                       /* RedBits */
-   4, /*approx*/                       /* GreenBits */
-   4, /*approx*/                       /* BlueBits */
-   1, /*approx*/                       /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   0,                                  /* TexelBytes */
-   texstore_rgba_fxt1,                 /* StoreTexImageFunc */
-   NULL, /*impossible*/                /* FetchTexel1D */
-   fetch_texel_2d_rgba_fxt1,           /* FetchTexel2D */
-   NULL, /*impossible*/                /* FetchTexel3D */
-   NULL, /*impossible*/                /* FetchTexel1Df */
-   fetch_texel_2d_f_rgba_fxt1,                 /* FetchTexel2Df */
-   NULL, /*impossible*/                /* FetchTexel3Df */
-   NULL                                        /* StoreTexel */
-};
-
-
 /***************************************************************************\
  * FXT1 encoder
  *
@@ -1722,3 +1647,6 @@ fxt1_decode_1 (const void *texture, GLint stride, /* in pixels */
 
    decode_1[mode](code, t, rgba);
 }
+
+
+#endif /* FEATURE_texture_fxt1 */
diff --git a/src/mesa/main/texcompress_fxt1.h b/src/mesa/main/texcompress_fxt1.h
new file mode 100644 (file)
index 0000000..d63ca71
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Mesa 3-D graphics library
+ * Version:  7.1
+ *
+ * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef TEXCOMPRESS_FXT1_H
+#define TEXCOMPRESS_FXT1_H
+
+#include "main/mtypes.h"
+#include "texstore.h"
+
+#if FEATURE_texture_fxt1
+
+extern GLboolean
+_mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS);
+
+extern GLboolean
+_mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS);
+
+extern void
+_mesa_fetch_texel_2d_f_rgba_fxt1(const struct gl_texture_image *texImage,
+                                 GLint i, GLint j, GLint k, GLfloat *texel);
+
+extern void
+_mesa_fetch_texel_2d_f_rgb_fxt1(const struct gl_texture_image *texImage,
+                                GLint i, GLint j, GLint k, GLfloat *texel);
+
+#else /* FEATURE_texture_fxt1 */
+
+/* these are used only in texstore_funcs[] */
+#define _mesa_texstore_rgb_fxt1 NULL
+#define _mesa_texstore_rgba_fxt1 NULL
+
+/* these are used only in texfetch_funcs[] */
+#define _mesa_fetch_texel_2d_f_rgba_fxt1 NULL
+#define _mesa_fetch_texel_2d_f_rgb_fxt1 NULL
+
+#endif /* FEATURE_texture_fxt1 */
+
+#endif /* TEXCOMPRESS_FXT1_H */
index a1c0f18f36f6ba6e131dbaae41da0ff4d6f3dfa7..b271a539a72706e04af4a53c545f8b5f482acc0d 100644 (file)
 #include "dlopen.h"
 #include "image.h"
 #include "texcompress.h"
-#include "texformat.h"
+#include "texcompress_s3tc.h"
 #include "texstore.h"
 
+
+#if FEATURE_texture_s3tc
+
+
 #ifdef __MINGW32__
 #define DXTN_LIBNAME "dxtn.dll"
 #define RTLD_LAZY 0
@@ -153,10 +157,10 @@ _mesa_init_texture_s3tc( GLcontext *ctx )
 }
 
 /**
- * Called via TexFormat->StoreImage to store an RGB_DXT1 texture.
+ * Store user's image in rgb_dxt1 format.
  */
-static GLboolean
-texstore_rgb_dxt1(TEXSTORE_PARAMS)
+GLboolean
+_mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS)
 {
    const GLchan *pixels;
    GLint srcRowStride;
@@ -164,7 +168,7 @@ texstore_rgb_dxt1(TEXSTORE_PARAMS)
    const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */
    const GLchan *tempImage = NULL;
 
-   ASSERT(dstFormat == &_mesa_texformat_rgb_dxt1);
+   ASSERT(dstFormat == MESA_FORMAT_RGB_DXT1);
    ASSERT(dstXoffset % 4 == 0);
    ASSERT(dstYoffset % 4 == 0);
    ASSERT(dstZoffset % 4 == 0);
@@ -178,7 +182,7 @@ texstore_rgb_dxt1(TEXSTORE_PARAMS)
       /* convert image to RGB/GLchan */
       tempImage = _mesa_make_temp_chan_image(ctx, dims,
                                              baseInternalFormat,
-                                             dstFormat->BaseFormat,
+                                             _mesa_get_format_base_format(dstFormat),
                                              srcWidth, srcHeight, srcDepth,
                                              srcFormat, srcType, srcAddr,
                                              srcPacking);
@@ -196,7 +200,7 @@ texstore_rgb_dxt1(TEXSTORE_PARAMS)
    }
 
    dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
-                                        dstFormat->MesaFormat,
+                                        dstFormat,
                                         texWidth, (GLubyte *) dstAddr);
 
    if (ext_tx_compress_dxtn) {
@@ -216,10 +220,10 @@ texstore_rgb_dxt1(TEXSTORE_PARAMS)
 
 
 /**
- * Called via TexFormat->StoreImage to store an RGBA_DXT1 texture.
+ * Store user's image in rgba_dxt1 format.
  */
-static GLboolean
-texstore_rgba_dxt1(TEXSTORE_PARAMS)
+GLboolean
+_mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS)
 {
    const GLchan *pixels;
    GLint srcRowStride;
@@ -227,7 +231,7 @@ texstore_rgba_dxt1(TEXSTORE_PARAMS)
    const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */
    const GLchan *tempImage = NULL;
 
-   ASSERT(dstFormat == &_mesa_texformat_rgba_dxt1);
+   ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT1);
    ASSERT(dstXoffset % 4 == 0);
    ASSERT(dstYoffset % 4 == 0);
    ASSERT(dstZoffset % 4 == 0);
@@ -241,7 +245,7 @@ texstore_rgba_dxt1(TEXSTORE_PARAMS)
       /* convert image to RGBA/GLchan */
       tempImage = _mesa_make_temp_chan_image(ctx, dims,
                                              baseInternalFormat,
-                                             dstFormat->BaseFormat,
+                                             _mesa_get_format_base_format(dstFormat),
                                              srcWidth, srcHeight, srcDepth,
                                              srcFormat, srcType, srcAddr,
                                              srcPacking);
@@ -259,7 +263,7 @@ texstore_rgba_dxt1(TEXSTORE_PARAMS)
    }
 
    dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
-                                        dstFormat->MesaFormat,
+                                        dstFormat,
                                         texWidth, (GLubyte *) dstAddr);
    if (ext_tx_compress_dxtn) {
       (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels,
@@ -278,10 +282,10 @@ texstore_rgba_dxt1(TEXSTORE_PARAMS)
 
 
 /**
- * Called via TexFormat->StoreImage to store an RGBA_DXT3 texture.
+ * Store user's image in rgba_dxt3 format.
  */
-static GLboolean
-texstore_rgba_dxt3(TEXSTORE_PARAMS)
+GLboolean
+_mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS)
 {
    const GLchan *pixels;
    GLint srcRowStride;
@@ -289,7 +293,7 @@ texstore_rgba_dxt3(TEXSTORE_PARAMS)
    const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */
    const GLchan *tempImage = NULL;
 
-   ASSERT(dstFormat == &_mesa_texformat_rgba_dxt3);
+   ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT3);
    ASSERT(dstXoffset % 4 == 0);
    ASSERT(dstYoffset % 4 == 0);
    ASSERT(dstZoffset % 4 == 0);
@@ -303,7 +307,7 @@ texstore_rgba_dxt3(TEXSTORE_PARAMS)
       /* convert image to RGBA/GLchan */
       tempImage = _mesa_make_temp_chan_image(ctx, dims,
                                              baseInternalFormat,
-                                             dstFormat->BaseFormat,
+                                             _mesa_get_format_base_format(dstFormat),
                                              srcWidth, srcHeight, srcDepth,
                                              srcFormat, srcType, srcAddr,
                                              srcPacking);
@@ -320,7 +324,7 @@ texstore_rgba_dxt3(TEXSTORE_PARAMS)
    }
 
    dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
-                                        dstFormat->MesaFormat,
+                                        dstFormat,
                                         texWidth, (GLubyte *) dstAddr);
    if (ext_tx_compress_dxtn) {
       (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels,
@@ -339,10 +343,10 @@ texstore_rgba_dxt3(TEXSTORE_PARAMS)
 
 
 /**
- * Called via TexFormat->StoreImage to store an RGBA_DXT5 texture.
+ * Store user's image in rgba_dxt5 format.
  */
-static GLboolean
-texstore_rgba_dxt5(TEXSTORE_PARAMS)
+GLboolean
+_mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS)
 {
    const GLchan *pixels;
    GLint srcRowStride;
@@ -350,7 +354,7 @@ texstore_rgba_dxt5(TEXSTORE_PARAMS)
    const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */
    const GLchan *tempImage = NULL;
 
-   ASSERT(dstFormat == &_mesa_texformat_rgba_dxt5);
+   ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT5);
    ASSERT(dstXoffset % 4 == 0);
    ASSERT(dstYoffset % 4 == 0);
    ASSERT(dstZoffset % 4 == 0);
@@ -364,7 +368,7 @@ texstore_rgba_dxt5(TEXSTORE_PARAMS)
       /* convert image to RGBA/GLchan */
       tempImage = _mesa_make_temp_chan_image(ctx, dims,
                                              baseInternalFormat,
-                                             dstFormat->BaseFormat,
+                                            _mesa_get_format_base_format(dstFormat),
                                              srcWidth, srcHeight, srcDepth,
                                              srcFormat, srcType, srcAddr,
                                              srcPacking);
@@ -381,7 +385,7 @@ texstore_rgba_dxt5(TEXSTORE_PARAMS)
    }
 
    dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
-                                        dstFormat->MesaFormat,
+                                        dstFormat,
                                         texWidth, (GLubyte *) dstAddr);
    if (ext_tx_compress_dxtn) {
       (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels,
@@ -414,9 +418,9 @@ fetch_texel_2d_rgb_dxt1( const struct gl_texture_image *texImage,
 }
 
 
-static void
-fetch_texel_2d_f_rgb_dxt1( const struct gl_texture_image *texImage,
-                            GLint i, GLint j, GLint k, GLfloat *texel )
+void
+_mesa_fetch_texel_2d_f_rgb_dxt1(const struct gl_texture_image *texImage,
+                                GLint i, GLint j, GLint k, GLfloat *texel)
 {
    /* just sample as GLchan and convert to float here */
    GLchan rgba[4];
@@ -442,9 +446,9 @@ fetch_texel_2d_rgba_dxt1( const struct gl_texture_image *texImage,
 }
 
 
-static void
-fetch_texel_2d_f_rgba_dxt1( const struct gl_texture_image *texImage,
-                            GLint i, GLint j, GLint k, GLfloat *texel )
+void
+_mesa_fetch_texel_2d_f_rgba_dxt1(const struct gl_texture_image *texImage,
+                                 GLint i, GLint j, GLint k, GLfloat *texel)
 {
    /* just sample as GLchan and convert to float here */
    GLchan rgba[4];
@@ -471,9 +475,9 @@ fetch_texel_2d_rgba_dxt3( const struct gl_texture_image *texImage,
 }
 
 
-static void
-fetch_texel_2d_f_rgba_dxt3( const struct gl_texture_image *texImage,
-                            GLint i, GLint j, GLint k, GLfloat *texel )
+void
+_mesa_fetch_texel_2d_f_rgba_dxt3(const struct gl_texture_image *texImage,
+                                 GLint i, GLint j, GLint k, GLfloat *texel)
 {
    /* just sample as GLchan and convert to float here */
    GLchan rgba[4];
@@ -499,9 +503,9 @@ fetch_texel_2d_rgba_dxt5( const struct gl_texture_image *texImage,
 }
 
 
-static void
-fetch_texel_2d_f_rgba_dxt5( const struct gl_texture_image *texImage,
-                            GLint i, GLint j, GLint k, GLfloat *texel )
+void
+_mesa_fetch_texel_2d_f_rgba_dxt5(const struct gl_texture_image *texImage,
+                                 GLint i, GLint j, GLint k, GLfloat *texel)
 {
    /* just sample as GLchan and convert to float here */
    GLchan rgba[4];
@@ -513,9 +517,9 @@ fetch_texel_2d_f_rgba_dxt5( const struct gl_texture_image *texImage,
 }
 
 #if FEATURE_EXT_texture_sRGB
-static void
-fetch_texel_2d_f_srgb_dxt1( const struct gl_texture_image *texImage,
-                            GLint i, GLint j, GLint k, GLfloat *texel )
+void
+_mesa_fetch_texel_2d_f_srgb_dxt1( const struct gl_texture_image *texImage,
+                                  GLint i, GLint j, GLint k, GLfloat *texel )
 {
    /* just sample as GLchan and convert to float here */
    GLchan rgba[4];
@@ -526,9 +530,9 @@ fetch_texel_2d_f_srgb_dxt1( const struct gl_texture_image *texImage,
    texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
 }
 
-static void
-fetch_texel_2d_f_srgba_dxt1( const struct gl_texture_image *texImage,
-                             GLint i, GLint j, GLint k, GLfloat *texel )
+void
+_mesa_fetch_texel_2d_f_srgba_dxt1(const struct gl_texture_image *texImage,
+                                  GLint i, GLint j, GLint k, GLfloat *texel)
 {
    /* just sample as GLchan and convert to float here */
    GLchan rgba[4];
@@ -539,9 +543,9 @@ fetch_texel_2d_f_srgba_dxt1( const struct gl_texture_image *texImage,
    texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
 }
 
-static void
-fetch_texel_2d_f_srgba_dxt3( const struct gl_texture_image *texImage,
-                             GLint i, GLint j, GLint k, GLfloat *texel )
+void
+_mesa_fetch_texel_2d_f_srgba_dxt3(const struct gl_texture_image *texImage,
+                                  GLint i, GLint j, GLint k, GLfloat *texel)
 {
    /* just sample as GLchan and convert to float here */
    GLchan rgba[4];
@@ -552,9 +556,9 @@ fetch_texel_2d_f_srgba_dxt3( const struct gl_texture_image *texImage,
    texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
 }
 
-static void
-fetch_texel_2d_f_srgba_dxt5( const struct gl_texture_image *texImage,
-                             GLint i, GLint j, GLint k, GLfloat *texel )
+void
+_mesa_fetch_texel_2d_f_srgba_dxt5(const struct gl_texture_image *texImage,
+                                  GLint i, GLint j, GLint k, GLfloat *texel)
 {
    /* just sample as GLchan and convert to float here */
    GLchan rgba[4];
@@ -564,198 +568,7 @@ fetch_texel_2d_f_srgba_dxt5( const struct gl_texture_image *texImage,
    texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]);
    texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
 }
-#endif
+#endif /* FEATURE_EXT_texture_sRGB */
 
-const struct gl_texture_format _mesa_texformat_rgb_dxt1 = {
-   MESA_FORMAT_RGB_DXT1,               /* MesaFormat */
-   GL_RGB,                             /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   4, /*approx*/                       /* RedBits */
-   4, /*approx*/                       /* GreenBits */
-   4, /*approx*/                       /* BlueBits */
-   0,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   0,                                  /* TexelBytes */
-   texstore_rgb_dxt1,                  /* StoreTexImageFunc */
-   NULL, /*impossible*/                /* FetchTexel1D */
-   fetch_texel_2d_rgb_dxt1,            /* FetchTexel2D */
-   NULL, /*impossible*/                /* FetchTexel3D */
-   NULL, /*impossible*/                /* FetchTexel1Df */
-   fetch_texel_2d_f_rgb_dxt1,          /* FetchTexel2Df */
-   NULL, /*impossible*/                /* FetchTexel3Df */
-   NULL                                        /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_rgba_dxt1 = {
-   MESA_FORMAT_RGBA_DXT1,              /* MesaFormat */
-   GL_RGBA,                            /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   4, /*approx*/                       /* RedBits */
-   4, /*approx*/                       /* GreenBits */
-   4, /*approx*/                       /* BlueBits */
-   1, /*approx*/                       /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   0,                                  /* TexelBytes */
-   texstore_rgba_dxt1,                 /* StoreTexImageFunc */
-   NULL, /*impossible*/                /* FetchTexel1D */
-   fetch_texel_2d_rgba_dxt1,           /* FetchTexel2D */
-   NULL, /*impossible*/                /* FetchTexel3D */
-   NULL, /*impossible*/                /* FetchTexel1Df */
-   fetch_texel_2d_f_rgba_dxt1,                 /* FetchTexel2Df */
-   NULL, /*impossible*/                /* FetchTexel3Df */
-   NULL                                        /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_rgba_dxt3 = {
-   MESA_FORMAT_RGBA_DXT3,              /* MesaFormat */
-   GL_RGBA,                            /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   4, /*approx*/                       /* RedBits */
-   4, /*approx*/                       /* GreenBits */
-   4, /*approx*/                       /* BlueBits */
-   4, /*approx*/                       /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   0,                                  /* TexelBytes */
-   texstore_rgba_dxt3,                 /* StoreTexImageFunc */
-   NULL, /*impossible*/                /* FetchTexel1D */
-   fetch_texel_2d_rgba_dxt3,           /* FetchTexel2D */
-   NULL, /*impossible*/                /* FetchTexel3D */
-   NULL, /*impossible*/                /* FetchTexel1Df */
-   fetch_texel_2d_f_rgba_dxt3,                 /* FetchTexel2Df */
-   NULL, /*impossible*/                /* FetchTexel3Df */
-   NULL                                        /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_rgba_dxt5 = {
-   MESA_FORMAT_RGBA_DXT5,              /* MesaFormat */
-   GL_RGBA,                            /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   4,/*approx*/                                /* RedBits */
-   4,/*approx*/                                /* GreenBits */
-   4,/*approx*/                                /* BlueBits */
-   4,/*approx*/                                /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   0,                                  /* TexelBytes */
-   texstore_rgba_dxt5,                 /* StoreTexImageFunc */
-   NULL, /*impossible*/                /* FetchTexel1D */
-   fetch_texel_2d_rgba_dxt5,           /* FetchTexel2D */
-   NULL, /*impossible*/                /* FetchTexel3D */
-   NULL, /*impossible*/                /* FetchTexel1Df */
-   fetch_texel_2d_f_rgba_dxt5,                 /* FetchTexel2Df */
-   NULL, /*impossible*/                /* FetchTexel3Df */
-   NULL                                        /* StoreTexel */
-};
 
-#if FEATURE_EXT_texture_sRGB
-const struct gl_texture_format _mesa_texformat_srgb_dxt1 = {
-   MESA_FORMAT_SRGB_DXT1,              /* MesaFormat */
-   GL_RGB,                             /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   4, /*approx*/                       /* RedBits */
-   4, /*approx*/                       /* GreenBits */
-   4, /*approx*/                       /* BlueBits */
-   0,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   0,                                  /* TexelBytes */
-   texstore_rgb_dxt1,                  /* StoreTexImageFunc */
-   NULL, /*impossible*/                /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL, /*impossible*/                /* FetchTexel3D */
-   NULL, /*impossible*/                /* FetchTexel1Df */
-   fetch_texel_2d_f_srgb_dxt1,                 /* FetchTexel2Df */
-   NULL, /*impossible*/                /* FetchTexel3Df */
-   NULL                                        /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_srgba_dxt1 = {
-   MESA_FORMAT_SRGBA_DXT1,             /* MesaFormat */
-   GL_RGBA,                            /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   4, /*approx*/                       /* RedBits */
-   4, /*approx*/                       /* GreenBits */
-   4, /*approx*/                       /* BlueBits */
-   1, /*approx*/                       /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   0,                                  /* TexelBytes */
-   texstore_rgba_dxt1,                 /* StoreTexImageFunc */
-   NULL, /*impossible*/                /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL, /*impossible*/                /* FetchTexel3D */
-   NULL, /*impossible*/                /* FetchTexel1Df */
-   fetch_texel_2d_f_srgba_dxt1,        /* FetchTexel2Df */
-   NULL, /*impossible*/                /* FetchTexel3Df */
-   NULL                                        /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_srgba_dxt3 = {
-   MESA_FORMAT_SRGBA_DXT3,             /* MesaFormat */
-   GL_RGBA,                            /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   4, /*approx*/                       /* RedBits */
-   4, /*approx*/                       /* GreenBits */
-   4, /*approx*/                       /* BlueBits */
-   4, /*approx*/                       /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   0,                                  /* TexelBytes */
-   texstore_rgba_dxt3,                 /* StoreTexImageFunc */
-   NULL, /*impossible*/                /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL, /*impossible*/                /* FetchTexel3D */
-   NULL, /*impossible*/                /* FetchTexel1Df */
-   fetch_texel_2d_f_srgba_dxt3,        /* FetchTexel2Df */
-   NULL, /*impossible*/                /* FetchTexel3Df */
-   NULL                                        /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_srgba_dxt5 = {
-   MESA_FORMAT_SRGBA_DXT5,             /* MesaFormat */
-   GL_RGBA,                            /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   4,/*approx*/                                /* RedBits */
-   4,/*approx*/                                /* GreenBits */
-   4,/*approx*/                                /* BlueBits */
-   4,/*approx*/                                /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   0,                                  /* TexelBytes */
-   texstore_rgba_dxt5,                 /* StoreTexImageFunc */
-   NULL, /*impossible*/                /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL, /*impossible*/                /* FetchTexel3D */
-   NULL, /*impossible*/                /* FetchTexel1Df */
-   fetch_texel_2d_f_srgba_dxt5,        /* FetchTexel2Df */
-   NULL, /*impossible*/                /* FetchTexel3Df */
-   NULL                                        /* StoreTexel */
-};
-#endif
+#endif /* FEATURE_texture_s3tc */
diff --git a/src/mesa/main/texcompress_s3tc.h b/src/mesa/main/texcompress_s3tc.h
new file mode 100644 (file)
index 0000000..2e7688d
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * Mesa 3-D graphics library
+ * Version:  7.1
+ *
+ * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef TEXCOMPRESS_S3TC_H
+#define TEXCOMPRESS_S3TC_H
+
+#include "main/mtypes.h"
+#include "texstore.h"
+
+
+#if FEATURE_texture_s3tc
+
+extern GLboolean
+_mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS);
+
+extern GLboolean
+_mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS);
+
+extern GLboolean
+_mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS);
+
+extern GLboolean
+_mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS);
+
+extern void
+_mesa_fetch_texel_2d_f_rgb_dxt1(const struct gl_texture_image *texImage,
+                                GLint i, GLint j, GLint k, GLfloat *texel);
+
+extern void
+_mesa_fetch_texel_2d_f_rgba_dxt1(const struct gl_texture_image *texImage,
+                                 GLint i, GLint j, GLint k, GLfloat *texel);
+
+extern void
+_mesa_fetch_texel_2d_f_rgba_dxt3(const struct gl_texture_image *texImage,
+                                 GLint i, GLint j, GLint k, GLfloat *texel);
+
+extern void
+_mesa_fetch_texel_2d_f_rgba_dxt5(const struct gl_texture_image *texImage,
+                                 GLint i, GLint j, GLint k, GLfloat *texel);
+
+extern void
+_mesa_fetch_texel_2d_f_srgb_dxt1(const struct gl_texture_image *texImage,
+                                 GLint i, GLint j, GLint k, GLfloat *texel);
+
+extern void
+_mesa_fetch_texel_2d_f_srgba_dxt1(const struct gl_texture_image *texImage,
+                                  GLint i, GLint j, GLint k, GLfloat *texel);
+
+extern void
+_mesa_fetch_texel_2d_f_srgba_dxt3(const struct gl_texture_image *texImage,
+                                  GLint i, GLint j, GLint k, GLfloat *texel);
+
+extern void
+_mesa_fetch_texel_2d_f_srgba_dxt5(const struct gl_texture_image *texImage,
+                                  GLint i, GLint j, GLint k, GLfloat *texel);
+
+extern void
+_mesa_init_texture_s3tc(GLcontext *ctx);
+
+#else /* FEATURE_texture_s3tc */
+
+/* these are used only in texstore_funcs[] */
+#define _mesa_texstore_rgb_dxt1 NULL
+#define _mesa_texstore_rgba_dxt1 NULL
+#define _mesa_texstore_rgba_dxt3 NULL
+#define _mesa_texstore_rgba_dxt5 NULL
+
+/* these are used only in texfetch_funcs[] */
+#define _mesa_fetch_texel_2d_f_rgb_dxt1 NULL
+#define _mesa_fetch_texel_2d_f_rgba_dxt1 NULL
+#define _mesa_fetch_texel_2d_f_rgba_dxt3 NULL
+#define _mesa_fetch_texel_2d_f_rgba_dxt5 NULL
+#define _mesa_fetch_texel_2d_f_srgb_dxt1 NULL
+#define _mesa_fetch_texel_2d_f_srgba_dxt1 NULL
+#define _mesa_fetch_texel_2d_f_srgba_dxt3 NULL
+#define _mesa_fetch_texel_2d_f_srgba_dxt5 NULL
+
+static INLINE void
+_mesa_init_texture_s3tc(GLcontext *ctx)
+{
+}
+
+#endif /* FEATURE_texture_s3tc */
+
+#endif /* TEXCOMPRESS_S3TC_H */
index 6d86a4275cc4c05b82a764fbe3435454b18cdfd0..4442fb8cf8e9877a55bc085d313bcdb2a1d6f3ce 100644 (file)
@@ -598,7 +598,10 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
 void GLAPIENTRY
 _mesa_TexEnvf( GLenum target, GLenum pname, GLfloat param )
 {
-   _mesa_TexEnvfv( target, pname, &param );
+   GLfloat p[4];
+   p[0] = param;
+   p[1] = p[2] = p[3] = 0.0;
+   _mesa_TexEnvfv( target, pname, p );
 }
 
 
index d7e77e759e096a578916764876bfb755e05324b1..499b7330d0a35ffcfe0a67b834a7f843f09c151d 100644 (file)
@@ -367,7 +367,7 @@ static GLbitfield get_fp_input_mask( GLcontext *ctx )
    else {
       /* calculate from vp->outputs */
       struct gl_vertex_program *vprog;
-      GLbitfield vp_outputs;
+      GLbitfield64 vp_outputs;
 
       /* Choose GLSL vertex shader over ARB vertex program.  Need this
        * since vertex shader state validation comes after fragment state
@@ -606,7 +606,7 @@ static struct ureg get_temp( struct texenv_fragment_program *p )
 
    if (!bit) {
       _mesa_problem(NULL, "%s: out of temporaries\n", __FILE__);
-      _mesa_exit(1);
+      exit(1);
    }
 
    if ((GLuint) bit > p->program->Base.NumTemporaries)
@@ -634,7 +634,7 @@ static struct ureg get_tex_temp( struct texenv_fragment_program *p )
 
    if (!bit) {
       _mesa_problem(NULL, "%s: out of temporaries\n", __FILE__);
-      _mesa_exit(1);
+      exit(1);
    }
 
    if ((GLuint) bit > p->program->Base.NumTemporaries)
@@ -1040,8 +1040,6 @@ static struct ureg emit_combine( struct texenv_fragment_program *p,
 
    assert(nr <= MAX_COMBINER_TERMS);
 
-   tmp = undef; /* silence warning (bug 5318) */
-
    for (i = 0; i < nr; i++)
       src[i] = emit_combine_source( p, mask, unit, opt[i].Source, opt[i].Operand );
 
diff --git a/src/mesa/main/texfetch.c b/src/mesa/main/texfetch.c
new file mode 100644 (file)
index 0000000..b370394
--- /dev/null
@@ -0,0 +1,693 @@
+/*
+ * Mesa 3-D graphics library
+ * Version:  7.7
+ *
+ * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
+ * Copyright (c) 2009  VMware, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION 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 texfetch.c
+ *
+ * Texel fetch/store functions
+ *
+ * \author Gareth Hughes
+ */
+
+
+#include "colormac.h"
+#include "context.h"
+#include "texcompress.h"
+#include "texcompress_fxt1.h"
+#include "texcompress_s3tc.h"
+#include "texfetch.h"
+
+
+/**
+ * Convert an 8-bit sRGB value from non-linear space to a
+ * linear RGB value in [0, 1].
+ * Implemented with a 256-entry lookup table.
+ */
+static INLINE GLfloat
+nonlinear_to_linear(GLubyte cs8)
+{
+   static GLfloat table[256];
+   static GLboolean tableReady = GL_FALSE;
+   if (!tableReady) {
+      /* compute lookup table now */
+      GLuint i;
+      for (i = 0; i < 256; i++) {
+         const GLfloat cs = UBYTE_TO_FLOAT(i);
+         if (cs <= 0.04045) {
+            table[i] = cs / 12.92f;
+         }
+         else {
+            table[i] = (GLfloat) _mesa_pow((cs + 0.055) / 1.055, 2.4);
+         }
+      }
+      tableReady = GL_TRUE;
+   }
+   return table[cs8];
+}
+
+
+
+/* Texel fetch routines for all supported formats
+ */
+#define DIM 1
+#include "texfetch_tmp.h"
+
+#define DIM 2
+#include "texfetch_tmp.h"
+
+#define DIM 3
+#include "texfetch_tmp.h"
+
+/**
+ * Null texel fetch function.
+ *
+ * Have to have this so the FetchTexel function pointer is never NULL.
+ */
+static void fetch_null_texelf( const struct gl_texture_image *texImage,
+                               GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   (void) texImage; (void) i; (void) j; (void) k;
+   texel[RCOMP] = 0.0;
+   texel[GCOMP] = 0.0;
+   texel[BCOMP] = 0.0;
+   texel[ACOMP] = 0.0;
+   _mesa_warning(NULL, "fetch_null_texelf() called!");
+}
+
+static void store_null_texel(struct gl_texture_image *texImage,
+                             GLint i, GLint j, GLint k, const void *texel)
+{
+   (void) texImage;
+   (void) i;
+   (void) j;
+   (void) k;
+   (void) texel;
+   /* no-op */
+}
+
+
+
+/**
+ * Table to map MESA_FORMAT_ to texel fetch/store funcs.
+ * XXX this is somewhat temporary.
+ */
+static struct {
+   GLuint Name;
+   FetchTexelFuncF Fetch1D;
+   FetchTexelFuncF Fetch2D;
+   FetchTexelFuncF Fetch3D;
+   StoreTexelFunc StoreTexel;
+}
+texfetch_funcs[MESA_FORMAT_COUNT] =
+{
+   {
+      MESA_FORMAT_SRGB8,
+      fetch_texel_1d_srgb8,
+      fetch_texel_2d_srgb8,
+      fetch_texel_3d_srgb8,
+      store_texel_srgb8
+   },
+   {
+      MESA_FORMAT_SRGBA8,
+      fetch_texel_1d_srgba8,
+      fetch_texel_2d_srgba8,
+      fetch_texel_3d_srgba8,
+      store_texel_srgba8
+   },
+   {
+      MESA_FORMAT_SARGB8,
+      fetch_texel_1d_sargb8,
+      fetch_texel_2d_sargb8,
+      fetch_texel_3d_sargb8,
+      store_texel_sargb8
+   },
+   {
+      MESA_FORMAT_SL8,
+      fetch_texel_1d_sl8,
+      fetch_texel_2d_sl8,
+      fetch_texel_3d_sl8,
+      store_texel_sl8
+   },
+   {
+      MESA_FORMAT_SLA8,
+      fetch_texel_1d_sla8,
+      fetch_texel_2d_sla8,
+      fetch_texel_3d_sla8,
+      store_texel_sla8
+   },
+   {
+      MESA_FORMAT_RGB_FXT1,
+      NULL,
+      _mesa_fetch_texel_2d_f_rgb_fxt1,
+      NULL,
+      NULL
+   },
+   {
+      MESA_FORMAT_RGBA_FXT1,
+      NULL,
+      _mesa_fetch_texel_2d_f_rgba_fxt1,
+      NULL,
+      NULL
+   },
+   {
+      MESA_FORMAT_RGB_DXT1,
+      NULL,
+      _mesa_fetch_texel_2d_f_rgb_dxt1,
+      NULL,
+      NULL
+   },
+   {
+      MESA_FORMAT_RGBA_DXT1,
+      NULL,
+      _mesa_fetch_texel_2d_f_rgba_dxt1,
+      NULL,
+      NULL
+   },
+   {
+      MESA_FORMAT_RGBA_DXT3,
+      NULL,
+      _mesa_fetch_texel_2d_f_rgba_dxt3,
+      NULL,
+      NULL
+   },
+   {
+      MESA_FORMAT_RGBA_DXT5,
+      NULL,
+      _mesa_fetch_texel_2d_f_rgba_dxt5,
+      NULL,
+      NULL
+   },
+   {
+      MESA_FORMAT_SRGB_DXT1,
+      NULL,
+      _mesa_fetch_texel_2d_f_srgb_dxt1,
+      NULL,
+      NULL
+   },
+   {
+      MESA_FORMAT_SRGBA_DXT1,
+      NULL,
+      _mesa_fetch_texel_2d_f_srgba_dxt1,
+      NULL,
+      NULL
+   },
+   {
+      MESA_FORMAT_SRGBA_DXT3,
+      NULL,
+      _mesa_fetch_texel_2d_f_srgba_dxt3,
+      NULL,
+      NULL
+   },
+   {
+      MESA_FORMAT_SRGBA_DXT5,
+      NULL,
+      _mesa_fetch_texel_2d_f_srgba_dxt5,
+      NULL,
+      NULL
+   },
+   {
+      MESA_FORMAT_RGBA_FLOAT32,
+      fetch_texel_1d_f_rgba_f32,
+      fetch_texel_2d_f_rgba_f32,
+      fetch_texel_3d_f_rgba_f32,
+      store_texel_rgba_f32
+   },
+   {
+      MESA_FORMAT_RGBA_FLOAT16,
+      fetch_texel_1d_f_rgba_f16,
+      fetch_texel_2d_f_rgba_f16,
+      fetch_texel_3d_f_rgba_f16,
+      store_texel_rgba_f16
+   },
+   {
+      MESA_FORMAT_RGB_FLOAT32,
+      fetch_texel_1d_f_rgb_f32,
+      fetch_texel_2d_f_rgb_f32,
+      fetch_texel_3d_f_rgb_f32,
+      store_texel_rgb_f32
+   },
+   {
+      MESA_FORMAT_RGB_FLOAT16,
+      fetch_texel_1d_f_rgb_f16,
+      fetch_texel_2d_f_rgb_f16,
+      fetch_texel_3d_f_rgb_f16,
+      store_texel_rgb_f16
+   },
+   {
+      MESA_FORMAT_ALPHA_FLOAT32,
+      fetch_texel_1d_f_alpha_f32,
+      fetch_texel_2d_f_alpha_f32,
+      fetch_texel_3d_f_alpha_f32,
+      store_texel_alpha_f32
+   },
+   {
+      MESA_FORMAT_ALPHA_FLOAT16,
+      fetch_texel_1d_f_alpha_f16,
+      fetch_texel_2d_f_alpha_f16,
+      fetch_texel_3d_f_alpha_f16,
+      store_texel_alpha_f16
+   },
+   {
+      MESA_FORMAT_LUMINANCE_FLOAT32,
+      fetch_texel_1d_f_luminance_f32,
+      fetch_texel_2d_f_luminance_f32,
+      fetch_texel_3d_f_luminance_f32,
+      store_texel_luminance_f32
+   },
+   {
+      MESA_FORMAT_LUMINANCE_FLOAT16,
+      fetch_texel_1d_f_luminance_f16,
+      fetch_texel_2d_f_luminance_f16,
+      fetch_texel_3d_f_luminance_f16,
+      store_texel_luminance_f16
+   },
+   {
+      MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32,
+      fetch_texel_1d_f_luminance_alpha_f32,
+      fetch_texel_2d_f_luminance_alpha_f32,
+      fetch_texel_3d_f_luminance_alpha_f32,
+      store_texel_luminance_alpha_f32
+   },
+   {
+      MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16,
+      fetch_texel_1d_f_luminance_alpha_f16,
+      fetch_texel_2d_f_luminance_alpha_f16,
+      fetch_texel_3d_f_luminance_alpha_f16,
+      store_texel_luminance_alpha_f16
+   },
+   {
+      MESA_FORMAT_INTENSITY_FLOAT32,
+      fetch_texel_1d_f_intensity_f32,
+      fetch_texel_2d_f_intensity_f32,
+      fetch_texel_3d_f_intensity_f32,
+      store_texel_intensity_f32
+   },
+   {
+      MESA_FORMAT_INTENSITY_FLOAT16,
+      fetch_texel_1d_f_intensity_f16,
+      fetch_texel_2d_f_intensity_f16,
+      fetch_texel_3d_f_intensity_f16,
+      store_texel_intensity_f16
+   },
+   {
+      MESA_FORMAT_DUDV8,
+      fetch_texel_1d_dudv8,
+      fetch_texel_2d_dudv8,
+      fetch_texel_3d_dudv8,
+      NULL
+   },
+   {
+      MESA_FORMAT_SIGNED_RGBA8888,
+      fetch_texel_1d_signed_rgba8888,
+      fetch_texel_2d_signed_rgba8888,
+      fetch_texel_3d_signed_rgba8888,
+      store_texel_signed_rgba8888
+   },
+   {
+      MESA_FORMAT_SIGNED_RGBA8888_REV,
+      fetch_texel_1d_signed_rgba8888_rev,
+      fetch_texel_2d_signed_rgba8888_rev,
+      fetch_texel_3d_signed_rgba8888_rev,
+      store_texel_signed_rgba8888_rev
+   },
+   {
+      MESA_FORMAT_SIGNED_RGBA_16,
+      NULL, /* XXX to do */
+      NULL,
+      NULL,
+      NULL
+   },
+   {
+      MESA_FORMAT_RGBA8888,
+      fetch_texel_1d_f_rgba8888,
+      fetch_texel_2d_f_rgba8888,
+      fetch_texel_3d_f_rgba8888,
+      store_texel_rgba8888
+   },
+   {
+      MESA_FORMAT_RGBA8888_REV,
+      fetch_texel_1d_f_rgba8888_rev,
+      fetch_texel_2d_f_rgba8888_rev,
+      fetch_texel_3d_f_rgba8888_rev,
+      store_texel_rgba8888_rev
+   },
+   {
+      MESA_FORMAT_ARGB8888,
+      fetch_texel_1d_f_argb8888,
+      fetch_texel_2d_f_argb8888,
+      fetch_texel_3d_f_argb8888,
+      store_texel_argb8888
+   },
+   {
+      MESA_FORMAT_ARGB8888_REV,
+      fetch_texel_1d_f_argb8888_rev,
+      fetch_texel_2d_f_argb8888_rev,
+      fetch_texel_3d_f_argb8888_rev,
+      store_texel_argb8888_rev
+   },
+   {
+      MESA_FORMAT_XRGB8888,
+      fetch_texel_1d_f_xrgb8888,
+      fetch_texel_2d_f_xrgb8888,
+      fetch_texel_3d_f_xrgb8888,
+      store_texel_xrgb8888
+   },
+   {
+      MESA_FORMAT_XRGB8888_REV,
+      fetch_texel_1d_f_xrgb8888_rev,
+      fetch_texel_2d_f_xrgb8888_rev,
+      fetch_texel_3d_f_xrgb8888_rev,
+      store_texel_xrgb8888_rev,
+   },
+   {
+      MESA_FORMAT_RGB888,
+      fetch_texel_1d_f_rgb888,
+      fetch_texel_2d_f_rgb888,
+      fetch_texel_3d_f_rgb888,
+      store_texel_rgb888
+   },
+   {
+      MESA_FORMAT_BGR888,
+      fetch_texel_1d_f_bgr888,
+      fetch_texel_2d_f_bgr888,
+      fetch_texel_3d_f_bgr888,
+      store_texel_bgr888
+   },
+   {
+      MESA_FORMAT_RGB565,
+      fetch_texel_1d_f_rgb565,
+      fetch_texel_2d_f_rgb565,
+      fetch_texel_3d_f_rgb565,
+      store_texel_rgb565
+   },
+   {
+      MESA_FORMAT_RGB565_REV,
+      fetch_texel_1d_f_rgb565_rev,
+      fetch_texel_2d_f_rgb565_rev,
+      fetch_texel_3d_f_rgb565_rev,
+      store_texel_rgb565_rev
+   },
+   {
+      MESA_FORMAT_ARGB4444,
+      fetch_texel_1d_f_argb4444,
+      fetch_texel_2d_f_argb4444,
+      fetch_texel_3d_f_argb4444,
+      store_texel_argb4444
+   },
+   {
+      MESA_FORMAT_ARGB4444_REV,
+      fetch_texel_1d_f_argb4444_rev,
+      fetch_texel_2d_f_argb4444_rev,
+      fetch_texel_3d_f_argb4444_rev,
+      store_texel_argb4444_rev
+   },
+   {
+      MESA_FORMAT_RGBA5551,
+      fetch_texel_1d_f_rgba5551,
+      fetch_texel_2d_f_rgba5551,
+      fetch_texel_3d_f_rgba5551,
+      store_texel_rgba5551
+   },
+   {
+      MESA_FORMAT_ARGB1555,
+      fetch_texel_1d_f_argb1555,
+      fetch_texel_2d_f_argb1555,
+      fetch_texel_3d_f_argb1555,
+      store_texel_argb1555
+   },
+   {
+      MESA_FORMAT_ARGB1555_REV,
+      fetch_texel_1d_f_argb1555_rev,
+      fetch_texel_2d_f_argb1555_rev,
+      fetch_texel_3d_f_argb1555_rev,
+      store_texel_argb1555_rev
+   },
+   {
+      MESA_FORMAT_AL88,
+      fetch_texel_1d_f_al88,
+      fetch_texel_2d_f_al88,
+      fetch_texel_3d_f_al88,
+      store_texel_al88
+   },
+   {
+      MESA_FORMAT_AL88_REV,
+      fetch_texel_1d_f_al88_rev,
+      fetch_texel_2d_f_al88_rev,
+      fetch_texel_3d_f_al88_rev,
+      store_texel_al88_rev
+   },
+   {
+      MESA_FORMAT_AL1616,
+      fetch_texel_1d_f_al1616,
+      fetch_texel_2d_f_al1616,
+      fetch_texel_3d_f_al1616,
+      store_texel_al1616
+   },
+   {
+      MESA_FORMAT_AL1616_REV,
+      fetch_texel_1d_f_al1616_rev,
+      fetch_texel_2d_f_al1616_rev,
+      fetch_texel_3d_f_al1616_rev,
+      store_texel_al1616_rev
+   },
+   {
+      MESA_FORMAT_RGB332,
+      fetch_texel_1d_f_rgb332,
+      fetch_texel_2d_f_rgb332,
+      fetch_texel_3d_f_rgb332,
+      store_texel_rgb332
+   },
+   {
+      MESA_FORMAT_A8,
+      fetch_texel_1d_f_a8,
+      fetch_texel_2d_f_a8,
+      fetch_texel_3d_f_a8,
+      store_texel_a8
+   },
+   {
+      MESA_FORMAT_L8,
+      fetch_texel_1d_f_l8,
+      fetch_texel_2d_f_l8,
+      fetch_texel_3d_f_l8,
+      store_texel_l8
+   },
+   {
+      MESA_FORMAT_I8,
+      fetch_texel_1d_f_i8,
+      fetch_texel_2d_f_i8,
+      fetch_texel_3d_f_i8,
+      store_texel_i8
+   },
+   {
+      MESA_FORMAT_CI8,
+      fetch_texel_1d_f_ci8,
+      fetch_texel_2d_f_ci8,
+      fetch_texel_3d_f_ci8,
+      store_texel_ci8
+   },
+   {
+      MESA_FORMAT_YCBCR,
+      fetch_texel_1d_f_ycbcr,
+      fetch_texel_2d_f_ycbcr,
+      fetch_texel_3d_f_ycbcr,
+      store_texel_ycbcr
+   },
+   {
+      MESA_FORMAT_YCBCR_REV,
+      fetch_texel_1d_f_ycbcr_rev,
+      fetch_texel_2d_f_ycbcr_rev,
+      fetch_texel_3d_f_ycbcr_rev,
+      store_texel_ycbcr_rev
+   },
+   {
+      MESA_FORMAT_Z24_S8,
+      fetch_texel_1d_f_z24_s8,
+      fetch_texel_2d_f_z24_s8,
+      fetch_texel_3d_f_z24_s8,
+      store_texel_z24_s8
+   },
+   {
+      MESA_FORMAT_S8_Z24,
+      fetch_texel_1d_f_s8_z24,
+      fetch_texel_2d_f_s8_z24,
+      fetch_texel_3d_f_s8_z24,
+      store_texel_s8_z24
+   },
+   {
+      MESA_FORMAT_Z16,
+      fetch_texel_1d_f_z16,
+      fetch_texel_2d_f_z16,
+      fetch_texel_3d_f_z16,
+      store_texel_z16
+   },
+   {
+      MESA_FORMAT_X8_Z24,
+      fetch_texel_1d_f_s8_z24,
+      fetch_texel_2d_f_s8_z24,
+      fetch_texel_3d_f_s8_z24,
+      store_texel_s8_z24
+   },
+   {
+      MESA_FORMAT_Z24_X8,
+      fetch_texel_1d_f_z24_s8,
+      fetch_texel_2d_f_z24_s8,
+      fetch_texel_3d_f_z24_s8,
+      store_texel_z24_s8
+   },
+   {
+      MESA_FORMAT_Z32,
+      fetch_texel_1d_f_z32,
+      fetch_texel_2d_f_z32,
+      fetch_texel_3d_f_z32,
+      store_texel_z32
+   }
+};
+
+
+static FetchTexelFuncF
+_mesa_get_texel_fetch_func(gl_format format, GLuint dims)
+{
+   FetchTexelFuncF f = NULL;
+   GLuint i;
+   /* XXX replace loop with direct table lookup */
+   for (i = 0; i < MESA_FORMAT_COUNT; i++) {
+      if (texfetch_funcs[i].Name == format) {
+         switch (dims) {
+         case 1:
+            f = texfetch_funcs[i].Fetch1D;
+            break;
+         case 2:
+            f = texfetch_funcs[i].Fetch2D;
+            break;
+         case 3:
+            f = texfetch_funcs[i].Fetch3D;
+            break;
+         }
+         if (!f)
+            f = fetch_null_texelf;
+         return f;
+      }
+   }
+   return NULL;
+}
+
+
+StoreTexelFunc
+_mesa_get_texel_store_func(gl_format format)
+{
+   GLuint i;
+   /* XXX replace loop with direct table lookup */
+   for (i = 0; i < MESA_FORMAT_COUNT; i++) {
+      if (texfetch_funcs[i].Name == format) {
+         if (texfetch_funcs[i].StoreTexel)
+            return texfetch_funcs[i].StoreTexel;
+         else
+            return store_null_texel;
+      }
+   }
+   return NULL;
+}
+
+
+
+/**
+ * Adaptor for fetching a GLchan texel from a float-valued texture.
+ */
+static void
+fetch_texel_float_to_chan(const struct gl_texture_image *texImage,
+                          GLint i, GLint j, GLint k, GLchan *texelOut)
+{
+   GLfloat temp[4];
+   GLenum baseFormat = _mesa_get_format_base_format(texImage->TexFormat);
+
+   ASSERT(texImage->FetchTexelf);
+   texImage->FetchTexelf(texImage, i, j, k, temp);
+   if (baseFormat == GL_DEPTH_COMPONENT ||
+       baseFormat == GL_DEPTH_STENCIL_EXT) {
+      /* just one channel */
+      UNCLAMPED_FLOAT_TO_CHAN(texelOut[0], temp[0]);
+   }
+   else {
+      /* four channels */
+      UNCLAMPED_FLOAT_TO_CHAN(texelOut[0], temp[0]);
+      UNCLAMPED_FLOAT_TO_CHAN(texelOut[1], temp[1]);
+      UNCLAMPED_FLOAT_TO_CHAN(texelOut[2], temp[2]);
+      UNCLAMPED_FLOAT_TO_CHAN(texelOut[3], temp[3]);
+   }
+}
+
+
+#if 0
+/**
+ * Adaptor for fetching a float texel from a GLchan-valued texture.
+ */
+static void
+fetch_texel_chan_to_float(const struct gl_texture_image *texImage,
+                          GLint i, GLint j, GLint k, GLfloat *texelOut)
+{
+   GLchan temp[4];
+   GLenum baseFormat = _mesa_get_format_base_format(texImage->TexFormat);
+
+   ASSERT(texImage->FetchTexelc);
+   texImage->FetchTexelc(texImage, i, j, k, temp);
+   if (baseFormat == GL_DEPTH_COMPONENT ||
+       baseFormat == GL_DEPTH_STENCIL_EXT) {
+      /* just one channel */
+      texelOut[0] = CHAN_TO_FLOAT(temp[0]);
+   }
+   else {
+      /* four channels */
+      texelOut[0] = CHAN_TO_FLOAT(temp[0]);
+      texelOut[1] = CHAN_TO_FLOAT(temp[1]);
+      texelOut[2] = CHAN_TO_FLOAT(temp[2]);
+      texelOut[3] = CHAN_TO_FLOAT(temp[3]);
+   }
+}
+#endif
+
+
+/**
+ * Initialize the texture image's FetchTexelc and FetchTexelf methods.
+ */
+void
+_mesa_set_fetch_functions(struct gl_texture_image *texImage, GLuint dims)
+{
+   ASSERT(dims == 1 || dims == 2 || dims == 3);
+   ASSERT(texImage->TexFormat);
+
+   if (!texImage->FetchTexelf) {
+      texImage->FetchTexelf =
+         _mesa_get_texel_fetch_func(texImage->TexFormat, dims);
+   }
+
+   /* now check if we need to use a float/chan adaptor */
+   if (!texImage->FetchTexelc) {
+      texImage->FetchTexelc = fetch_texel_float_to_chan;
+   }
+
+   ASSERT(texImage->FetchTexelc);
+   ASSERT(texImage->FetchTexelf);
+}
diff --git a/src/mesa/main/texfetch.h b/src/mesa/main/texfetch.h
new file mode 100644 (file)
index 0000000..ef13bf2
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Mesa 3-D graphics library
+ * Version:  7.7
+ *
+ * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
+ * Copyright (c) 2009 VMware, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION 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 TEXFETCH_H
+#define TEXFETCH_H
+
+#include "mtypes.h"
+#include "formats.h"
+
+
+extern StoreTexelFunc
+_mesa_get_texel_store_func(gl_format format);
+
+extern void
+_mesa_set_fetch_functions(struct gl_texture_image *texImage, GLuint dims);
+
+#endif
diff --git a/src/mesa/main/texfetch_tmp.h b/src/mesa/main/texfetch_tmp.h
new file mode 100644 (file)
index 0000000..e6772c8
--- /dev/null
@@ -0,0 +1,1394 @@
+/*
+ * Mesa 3-D graphics library
+ * Version:  7.7
+ *
+ * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
+ * Copyright (c) 2008-2009  VMware, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION 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 texfetch_tmp.h
+ * Texel fetch functions template.
+ * 
+ * This template file is used by texfetch.c to generate texel fetch functions
+ * for 1-D, 2-D and 3-D texture images. 
+ *
+ * It should be expanded by defining \p DIM as the number texture dimensions
+ * (1, 2 or 3).  According to the value of \p DIM a series of macros is defined
+ * for the texel lookup in the gl_texture_image::Data.
+ * 
+ * \author Gareth Hughes
+ * \author Brian Paul
+ */
+
+
+#if DIM == 1
+
+#define TEXEL_ADDR( type, image, i, j, k, size ) \
+       ((void) (j), (void) (k), ((type *)(image)->Data + (i) * (size)))
+
+#define FETCH(x) fetch_texel_1d_##x
+
+#elif DIM == 2
+
+#define TEXEL_ADDR( type, image, i, j, k, size )                       \
+       ((void) (k),                                                    \
+        ((type *)(image)->Data + ((image)->RowStride * (j) + (i)) * (size)))
+
+#define FETCH(x) fetch_texel_2d_##x
+
+#elif DIM == 3
+
+#define TEXEL_ADDR( type, image, i, j, k, size )                       \
+       ((type *)(image)->Data + ((image)->ImageOffsets[k]              \
+             + (image)->RowStride * (j) + (i)) * (size))
+
+#define FETCH(x) fetch_texel_3d_##x
+
+#else
+#error illegal number of texture dimensions
+#endif
+
+
+/* MESA_FORMAT_Z32 ***********************************************************/
+
+/* Fetch depth texel from 1D, 2D or 3D 32-bit depth texture,
+ * returning 1 GLfloat.
+ * Note: no GLchan version of this function.
+ */
+static void FETCH(f_z32)( const struct gl_texture_image *texImage,
+                          GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   texel[0] = src[0] * (1.0F / 0xffffffff);
+}
+
+#if DIM == 3
+static void store_texel_z32(struct gl_texture_image *texImage,
+                            GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLuint *depth = (const GLuint *) texel;
+   GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   dst[0] = *depth;
+}
+#endif
+
+
+/* MESA_FORMAT_Z16 ***********************************************************/
+
+/* Fetch depth texel from 1D, 2D or 3D 16-bit depth texture,
+ * returning 1 GLfloat.
+ * Note: no GLchan version of this function.
+ */
+static void FETCH(f_z16)(const struct gl_texture_image *texImage,
+                         GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+   texel[0] = src[0] * (1.0F / 65535.0F);
+}
+
+#if DIM == 3
+static void store_texel_z16(struct gl_texture_image *texImage,
+                            GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLushort *depth = (const GLushort *) texel;
+   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+   dst[0] = *depth;
+}
+#endif
+
+
+/* MESA_FORMAT_RGBA_F32 ******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT32 texture, returning 4 GLfloats.
+ */
+static void FETCH(f_rgba_f32)( const struct gl_texture_image *texImage,
+                               GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 4);
+   texel[RCOMP] = src[0];
+   texel[GCOMP] = src[1];
+   texel[BCOMP] = src[2];
+   texel[ACOMP] = src[3];
+}
+
+#if DIM == 3
+static void store_texel_rgba_f32(struct gl_texture_image *texImage,
+                                 GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLfloat *depth = (const GLfloat *) texel;
+   GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
+   dst[0] = depth[RCOMP];
+   dst[1] = depth[GCOMP];
+   dst[2] = depth[BCOMP];
+   dst[3] = depth[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_RGBA_F16 ******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT16 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_rgba_f16)( const struct gl_texture_image *texImage,
+                               GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 4);
+   texel[RCOMP] = _mesa_half_to_float(src[0]);
+   texel[GCOMP] = _mesa_half_to_float(src[1]);
+   texel[BCOMP] = _mesa_half_to_float(src[2]);
+   texel[ACOMP] = _mesa_half_to_float(src[3]);
+}
+
+#if DIM == 3
+static void store_texel_rgba_f16(struct gl_texture_image *texImage,
+                                 GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLfloat *depth = (const GLfloat *) texel;
+   GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
+   dst[0] = _mesa_float_to_half(*depth);
+}
+#endif
+
+/* MESA_FORMAT_RGB_F32 *******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D RGB_FLOAT32 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_rgb_f32)( const struct gl_texture_image *texImage,
+                              GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 3);
+   texel[RCOMP] = src[0];
+   texel[GCOMP] = src[1];
+   texel[BCOMP] = src[2];
+   texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_rgb_f32(struct gl_texture_image *texImage,
+                                 GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLfloat *depth = (const GLfloat *) texel;
+   GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
+   dst[0] = *depth;
+}
+#endif
+
+
+/* MESA_FORMAT_RGB_F16 *******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D RGB_FLOAT16 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_rgb_f16)( const struct gl_texture_image *texImage,
+                              GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 3);
+   texel[RCOMP] = _mesa_half_to_float(src[0]);
+   texel[GCOMP] = _mesa_half_to_float(src[1]);
+   texel[BCOMP] = _mesa_half_to_float(src[2]);
+   texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_rgb_f16(struct gl_texture_image *texImage,
+                                GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLfloat *depth = (const GLfloat *) texel;
+   GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
+   dst[0] = _mesa_float_to_half(*depth);
+}
+#endif
+
+
+/* MESA_FORMAT_ALPHA_F32 *****************************************************/
+
+/* Fetch texel from 1D, 2D or 3D ALPHA_FLOAT32 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_alpha_f32)( const struct gl_texture_image *texImage,
+                              GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
+   texel[RCOMP] =
+   texel[GCOMP] =
+   texel[BCOMP] = 0.0F;
+   texel[ACOMP] = src[0];
+}
+
+#if DIM == 3
+static void store_texel_alpha_f32(struct gl_texture_image *texImage,
+                                  GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLfloat *rgba = (const GLfloat *) texel;
+   GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
+   dst[0] = rgba[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_ALPHA_F32 *****************************************************/
+
+/* Fetch texel from 1D, 2D or 3D ALPHA_FLOAT16 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_alpha_f16)( const struct gl_texture_image *texImage,
+                              GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
+   texel[RCOMP] =
+   texel[GCOMP] =
+   texel[BCOMP] = 0.0F;
+   texel[ACOMP] = _mesa_half_to_float(src[0]);
+}
+
+#if DIM == 3
+static void store_texel_alpha_f16(struct gl_texture_image *texImage,
+                                  GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLfloat *rgba = (const GLfloat *) texel;
+   GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
+   dst[0] = _mesa_float_to_half(rgba[ACOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_LUMINANCE_F32 *************************************************/
+
+/* Fetch texel from 1D, 2D or 3D LUMINANCE_FLOAT32 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_luminance_f32)( const struct gl_texture_image *texImage,
+                                    GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
+   texel[RCOMP] =
+   texel[GCOMP] =
+   texel[BCOMP] = src[0];
+   texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_luminance_f32(struct gl_texture_image *texImage,
+                                  GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLfloat *rgba = (const GLfloat *) texel;
+   GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
+   dst[0] = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_LUMINANCE_F16 *************************************************/
+
+/* Fetch texel from 1D, 2D or 3D LUMINANCE_FLOAT16 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_luminance_f16)( const struct gl_texture_image *texImage,
+                                    GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
+   texel[RCOMP] =
+   texel[GCOMP] =
+   texel[BCOMP] = _mesa_half_to_float(src[0]);
+   texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_luminance_f16(struct gl_texture_image *texImage,
+                                  GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLfloat *rgba = (const GLfloat *) texel;
+   GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
+   dst[0] = _mesa_float_to_half(rgba[RCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_LUMINANCE_ALPHA_F32 *******************************************/
+
+/* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT32 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_luminance_alpha_f32)( const struct gl_texture_image *texImage,
+                                    GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
+   texel[RCOMP] =
+   texel[GCOMP] =
+   texel[BCOMP] = src[0];
+   texel[ACOMP] = src[1];
+}
+
+#if DIM == 3
+static void store_texel_luminance_alpha_f32(struct gl_texture_image *texImage,
+                                  GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLfloat *rgba = (const GLfloat *) texel;
+   GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
+   dst[0] = rgba[RCOMP];
+   dst[1] = rgba[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_LUMINANCE_ALPHA_F16 *******************************************/
+
+/* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT16 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_luminance_alpha_f16)( const struct gl_texture_image *texImage,
+                                    GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 2);
+   texel[RCOMP] =
+   texel[GCOMP] =
+   texel[BCOMP] = _mesa_half_to_float(src[0]);
+   texel[ACOMP] = _mesa_half_to_float(src[1]);
+}
+
+#if DIM == 3
+static void store_texel_luminance_alpha_f16(struct gl_texture_image *texImage,
+                                  GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLfloat *rgba = (const GLfloat *) texel;
+   GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 2);
+   dst[0] = _mesa_float_to_half(rgba[RCOMP]);
+   dst[1] = _mesa_float_to_half(rgba[ACOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_INTENSITY_F32 *************************************************/
+
+/* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT32 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_intensity_f32)( const struct gl_texture_image *texImage,
+                                    GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
+   texel[RCOMP] =
+   texel[GCOMP] =
+   texel[BCOMP] =
+   texel[ACOMP] = src[0];
+}
+
+#if DIM == 3
+static void store_texel_intensity_f32(struct gl_texture_image *texImage,
+                                  GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLfloat *rgba = (const GLfloat *) texel;
+   GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
+   dst[0] = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_INTENSITY_F16 *************************************************/
+
+/* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT16 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_intensity_f16)( const struct gl_texture_image *texImage,
+                                    GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
+   texel[RCOMP] =
+   texel[GCOMP] =
+   texel[BCOMP] =
+   texel[ACOMP] = _mesa_half_to_float(src[0]);
+}
+
+#if DIM == 3
+static void store_texel_intensity_f16(struct gl_texture_image *texImage,
+                                  GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLfloat *rgba = (const GLfloat *) texel;
+   GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
+   dst[0] = _mesa_float_to_half(rgba[RCOMP]);
+}
+#endif
+
+
+
+
+/*
+ * Begin Hardware formats
+ */
+
+/* MESA_FORMAT_RGBA8888 ******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D rgba8888 texture, return 4 GLfloats */
+static void FETCH(f_rgba8888)( const struct gl_texture_image *texImage,
+                               GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 24)        );
+   texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
+   texel[BCOMP] = UBYTE_TO_FLOAT( (s >>  8) & 0xff );
+   texel[ACOMP] = UBYTE_TO_FLOAT( (s      ) & 0xff );
+}
+
+
+
+#if DIM == 3
+static void store_texel_rgba8888(struct gl_texture_image *texImage,
+                                 GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLubyte *rgba = (const GLubyte *) texel;
+   GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_RGBA888_REV ***************************************************/
+
+/* Fetch texel from 1D, 2D or 3D abgr8888 texture, return 4 GLchans */
+static void FETCH(f_rgba8888_rev)( const struct gl_texture_image *texImage,
+                                   GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   texel[RCOMP] = UBYTE_TO_FLOAT( (s      ) & 0xff );
+   texel[GCOMP] = UBYTE_TO_FLOAT( (s >>  8) & 0xff );
+   texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
+   texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24)        );
+}
+
+#if DIM == 3
+static void store_texel_rgba8888_rev(struct gl_texture_image *texImage,
+                                  GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLubyte *rgba = (const GLubyte *) texel;
+   GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   *dst = PACK_COLOR_8888_REV(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_ARGB8888 ******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D argb8888 texture, return 4 GLchans */
+static void FETCH(f_argb8888)( const struct gl_texture_image *texImage,
+                               GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
+   texel[GCOMP] = UBYTE_TO_FLOAT( (s >>  8) & 0xff );
+   texel[BCOMP] = UBYTE_TO_FLOAT( (s      ) & 0xff );
+   texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24)        );
+}
+
+#if DIM == 3
+static void store_texel_argb8888(struct gl_texture_image *texImage,
+                                 GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLubyte *rgba = (const GLubyte *) texel;
+   GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   *dst = PACK_COLOR_8888(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_ARGB8888_REV **************************************************/
+
+/* Fetch texel from 1D, 2D or 3D argb8888_rev texture, return 4 GLfloats */
+static void FETCH(f_argb8888_rev)( const struct gl_texture_image *texImage,
+                                   GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   texel[RCOMP] = UBYTE_TO_FLOAT( (s >>  8) & 0xff );
+   texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
+   texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 24)        );
+   texel[ACOMP] = UBYTE_TO_FLOAT( (s      ) & 0xff );
+}
+
+#if DIM == 3
+static void store_texel_argb8888_rev(struct gl_texture_image *texImage,
+                                  GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLubyte *rgba = (const GLubyte *) texel;
+   GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   *dst = PACK_COLOR_8888(rgba[BCOMP], rgba[GCOMP], rgba[RCOMP], rgba[ACOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_XRGB8888 ******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D xrgb8888 texture, return 4 GLchans */
+static void FETCH(f_xrgb8888)( const struct gl_texture_image *texImage,
+                               GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
+   texel[GCOMP] = UBYTE_TO_FLOAT( (s >>  8) & 0xff );
+   texel[BCOMP] = UBYTE_TO_FLOAT( (s      ) & 0xff );
+   texel[ACOMP] = 1.0f;
+}
+
+#if DIM == 3
+static void store_texel_xrgb8888(struct gl_texture_image *texImage,
+                                 GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLubyte *rgba = (const GLubyte *) texel;
+   GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   *dst = PACK_COLOR_8888(0xff, rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_XRGB8888_REV **************************************************/
+
+/* Fetch texel from 1D, 2D or 3D xrgb8888_rev texture, return 4 GLfloats */
+static void FETCH(f_xrgb8888_rev)( const struct gl_texture_image *texImage,
+                                   GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   texel[RCOMP] = UBYTE_TO_FLOAT( (s >>  8) & 0xff );
+   texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
+   texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 24)        );
+   texel[ACOMP] = 1.0f;
+}
+
+#if DIM == 3
+static void store_texel_xrgb8888_rev(struct gl_texture_image *texImage,
+                                     GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLubyte *rgba = (const GLubyte *) texel;
+   GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   *dst = PACK_COLOR_8888(rgba[BCOMP], rgba[GCOMP], rgba[RCOMP], 0xff);
+}
+#endif
+
+
+/* MESA_FORMAT_RGB888 ********************************************************/
+
+/* Fetch texel from 1D, 2D or 3D rgb888 texture, return 4 GLchans */
+static void FETCH(f_rgb888)( const struct gl_texture_image *texImage,
+                             GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
+   texel[RCOMP] = UBYTE_TO_FLOAT( src[2] );
+   texel[GCOMP] = UBYTE_TO_FLOAT( src[1] );
+   texel[BCOMP] = UBYTE_TO_FLOAT( src[0] );
+   texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_rgb888(struct gl_texture_image *texImage,
+                               GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLubyte *rgba = (const GLubyte *) texel;
+   GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
+   dst[0] = rgba[BCOMP];
+   dst[1] = rgba[GCOMP];
+   dst[2] = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_BGR888 ********************************************************/
+
+/* Fetch texel from 1D, 2D or 3D bgr888 texture, return 4 GLchans */
+static void FETCH(f_bgr888)( const struct gl_texture_image *texImage,
+                             GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
+   texel[RCOMP] = UBYTE_TO_FLOAT( src[0] );
+   texel[GCOMP] = UBYTE_TO_FLOAT( src[1] );
+   texel[BCOMP] = UBYTE_TO_FLOAT( src[2] );
+   texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_bgr888(struct gl_texture_image *texImage,
+                               GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLubyte *rgba = (const GLubyte *) texel;
+   GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
+   dst[0] = rgba[RCOMP];
+   dst[1] = rgba[GCOMP];
+   dst[2] = rgba[BCOMP];
+}
+#endif
+
+
+/* use color expansion like (g << 2) | (g >> 4) (does somewhat random rounding)
+   instead of slow (g << 2) * 255 / 252 (always rounds down) */
+
+/* MESA_FORMAT_RGB565 ********************************************************/
+
+/* Fetch texel from 1D, 2D or 3D rgb565 texture, return 4 GLchans */
+static void FETCH(f_rgb565)( const struct gl_texture_image *texImage,
+                             GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+   const GLushort s = *src;
+   texel[RCOMP] = ((s >> 11) & 0x1f) * (1.0F / 31.0F);
+   texel[GCOMP] = ((s >> 5 ) & 0x3f) * (1.0F / 63.0F);
+   texel[BCOMP] = ((s      ) & 0x1f) * (1.0F / 31.0F);
+   texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_rgb565(struct gl_texture_image *texImage,
+                               GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLubyte *rgba = (const GLubyte *) texel;
+   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+   *dst = PACK_COLOR_565(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_RGB565_REV ****************************************************/
+
+/* Fetch texel from 1D, 2D or 3D rgb565_rev texture, return 4 GLchans */
+static void FETCH(f_rgb565_rev)( const struct gl_texture_image *texImage,
+                                 GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+   const GLushort s = (*src >> 8) | (*src << 8); /* byte swap */
+   texel[RCOMP] = UBYTE_TO_FLOAT( ((s >> 8) & 0xf8) | ((s >> 13) & 0x7) );
+   texel[GCOMP] = UBYTE_TO_FLOAT( ((s >> 3) & 0xfc) | ((s >>  9) & 0x3) );
+   texel[BCOMP] = UBYTE_TO_FLOAT( ((s << 3) & 0xf8) | ((s >>  2) & 0x7) );
+   texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_rgb565_rev(struct gl_texture_image *texImage,
+                                  GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLubyte *rgba = (const GLubyte *) texel;
+   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+   *dst = PACK_COLOR_565(rgba[BCOMP], rgba[GCOMP], rgba[RCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_ARGB4444 ******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D argb444 texture, return 4 GLchans */
+static void FETCH(f_argb4444)( const struct gl_texture_image *texImage,
+                               GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+   const GLushort s = *src;
+   texel[RCOMP] = ((s >>  8) & 0xf) * (1.0F / 15.0F);
+   texel[GCOMP] = ((s >>  4) & 0xf) * (1.0F / 15.0F);
+   texel[BCOMP] = ((s      ) & 0xf) * (1.0F / 15.0F);
+   texel[ACOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F);
+}
+
+#if DIM == 3
+static void store_texel_argb4444(struct gl_texture_image *texImage,
+                                 GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLubyte *rgba = (const GLubyte *) texel;
+   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+   *dst = PACK_COLOR_4444(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_ARGB4444_REV **************************************************/
+
+/* Fetch texel from 1D, 2D or 3D argb4444_rev texture, return 4 GLchans */
+static void FETCH(f_argb4444_rev)( const struct gl_texture_image *texImage,
+                                   GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+   texel[RCOMP] = ((s      ) & 0xf) * (1.0F / 15.0F);
+   texel[GCOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F);
+   texel[BCOMP] = ((s >>  8) & 0xf) * (1.0F / 15.0F);
+   texel[ACOMP] = ((s >>  4) & 0xf) * (1.0F / 15.0F);
+}
+
+#if DIM == 3
+static void store_texel_argb4444_rev(struct gl_texture_image *texImage,
+                                 GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLubyte *rgba = (const GLubyte *) texel;
+   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+   *dst = PACK_COLOR_4444(rgba[ACOMP], rgba[BCOMP], rgba[GCOMP], rgba[RCOMP]);
+}
+#endif
+
+/* MESA_FORMAT_RGBA5551 ******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */
+static void FETCH(f_rgba5551)( const struct gl_texture_image *texImage,
+                               GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+   const GLushort s = *src;
+   texel[RCOMP] = ((s >> 11) & 0x1f) * (1.0F / 31.0F);
+   texel[GCOMP] = ((s >>  6) & 0x1f) * (1.0F / 31.0F);
+   texel[BCOMP] = ((s >>  1) & 0x1f) * (1.0F / 31.0F);
+   texel[ACOMP] = ((s      ) & 0x01) * 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_rgba5551(struct gl_texture_image *texImage,
+                                 GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLubyte *rgba = (const GLubyte *) texel;
+   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+   *dst = PACK_COLOR_5551(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
+}
+#endif
+
+/* MESA_FORMAT_ARGB1555 ******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */
+static void FETCH(f_argb1555)( const struct gl_texture_image *texImage,
+                            GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+   const GLushort s = *src;
+   texel[RCOMP] = ((s >> 10) & 0x1f) * (1.0F / 31.0F);
+   texel[GCOMP] = ((s >>  5) & 0x1f) * (1.0F / 31.0F);
+   texel[BCOMP] = ((s >>  0) & 0x1f) * (1.0F / 31.0F);
+   texel[ACOMP] = ((s >> 15) & 0x01) * 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_argb1555(struct gl_texture_image *texImage,
+                                 GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLubyte *rgba = (const GLubyte *) texel;
+   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+   *dst = PACK_COLOR_1555(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_ARGB1555_REV **************************************************/
+
+/* Fetch texel from 1D, 2D or 3D argb1555_rev texture, return 4 GLchans */
+static void FETCH(f_argb1555_rev)( const struct gl_texture_image *texImage,
+                                   GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+   const GLushort s = (*src << 8) | (*src >> 8); /* byteswap */
+   texel[RCOMP] = UBYTE_TO_FLOAT( ((s >>  7) & 0xf8) | ((s >> 12) & 0x7) );
+   texel[GCOMP] = UBYTE_TO_FLOAT( ((s >>  2) & 0xf8) | ((s >>  7) & 0x7) );
+   texel[BCOMP] = UBYTE_TO_FLOAT( ((s <<  3) & 0xf8) | ((s >>  2) & 0x7) );
+   texel[ACOMP] = UBYTE_TO_FLOAT( ((s >> 15) & 0x01) * 255 );
+}
+
+#if DIM == 3
+static void store_texel_argb1555_rev(struct gl_texture_image *texImage,
+                                 GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLubyte *rgba = (const GLubyte *) texel;
+   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+   *dst = PACK_COLOR_1555_REV(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_AL88 **********************************************************/
+
+/* Fetch texel from 1D, 2D or 3D al88 texture, return 4 GLchans */
+static void FETCH(f_al88)( const struct gl_texture_image *texImage,
+                           GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+   texel[RCOMP] = 
+   texel[GCOMP] = 
+   texel[BCOMP] = UBYTE_TO_FLOAT( s & 0xff );
+   texel[ACOMP] = UBYTE_TO_FLOAT( s >> 8 );
+}
+
+#if DIM == 3
+static void store_texel_al88(struct gl_texture_image *texImage,
+                             GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLubyte *rgba = (const GLubyte *) texel;
+   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+   *dst = PACK_COLOR_88(rgba[ACOMP], rgba[RCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_AL88_REV ******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D al88_rev texture, return 4 GLchans */
+static void FETCH(f_al88_rev)( const struct gl_texture_image *texImage,
+                               GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+   texel[RCOMP] = 
+   texel[GCOMP] = 
+   texel[BCOMP] = UBYTE_TO_FLOAT( s >> 8 );
+   texel[ACOMP] = UBYTE_TO_FLOAT( s & 0xff );
+}
+
+#if DIM == 3
+static void store_texel_al88_rev(struct gl_texture_image *texImage,
+                                 GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLubyte *rgba = (const GLubyte *) texel;
+   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+   *dst = PACK_COLOR_88(rgba[RCOMP], rgba[ACOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_AL1616 ********************************************************/
+
+/* Fetch texel from 1D, 2D or 3D al1616 texture, return 4 GLchans */
+static void FETCH(f_al1616)( const struct gl_texture_image *texImage,
+                            GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   texel[RCOMP] =
+   texel[GCOMP] =
+   texel[BCOMP] = USHORT_TO_FLOAT( s & 0xffff );
+   texel[ACOMP] = USHORT_TO_FLOAT( s >> 16 );
+}
+
+#if DIM == 3
+static void store_texel_al1616(struct gl_texture_image *texImage,
+                             GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLushort *rgba = (const GLushort *) texel;
+   GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   *dst = PACK_COLOR_1616(rgba[ACOMP], rgba[RCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_AL1616_REV ****************************************************/
+
+/* Fetch texel from 1D, 2D or 3D al1616_rev texture, return 4 GLchans */
+static void FETCH(f_al1616_rev)( const struct gl_texture_image *texImage,
+                                GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   texel[RCOMP] =
+   texel[GCOMP] =
+   texel[BCOMP] = USHORT_TO_FLOAT( s >> 16 );
+   texel[ACOMP] = USHORT_TO_FLOAT( s & 0xffff );
+}
+
+#if DIM == 3
+static void store_texel_al1616_rev(struct gl_texture_image *texImage,
+                                  GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLushort *rgba = (const GLushort *) texel;
+   GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   *dst = PACK_COLOR_1616(rgba[RCOMP], rgba[ACOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_RGB332 ********************************************************/
+
+/* Fetch texel from 1D, 2D or 3D rgb332 texture, return 4 GLchans */
+static void FETCH(f_rgb332)( const struct gl_texture_image *texImage,
+                             GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
+   const GLubyte s = *src;
+   texel[RCOMP] = ((s >> 5) & 0x7) * (1.0F / 7.0F);
+   texel[GCOMP] = ((s >> 2) & 0x7) * (1.0F / 7.0F);
+   texel[BCOMP] = ((s     ) & 0x3) * (1.0F / 3.0F);
+   texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_rgb332(struct gl_texture_image *texImage,
+                               GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLubyte *rgba = (const GLubyte *) texel;
+   GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
+   *dst = PACK_COLOR_332(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_A8 ************************************************************/
+
+/* Fetch texel from 1D, 2D or 3D a8 texture, return 4 GLchans */
+static void FETCH(f_a8)( const struct gl_texture_image *texImage,
+                         GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
+   texel[RCOMP] =
+   texel[GCOMP] =
+   texel[BCOMP] = 0.0F;
+   texel[ACOMP] = UBYTE_TO_FLOAT( src[0] );
+}
+
+#if DIM == 3
+static void store_texel_a8(struct gl_texture_image *texImage,
+                           GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLubyte *rgba = (const GLubyte *) texel;
+   GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
+   *dst = rgba[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_L8 ************************************************************/
+
+/* Fetch texel from 1D, 2D or 3D l8 texture, return 4 GLchans */
+static void FETCH(f_l8)( const struct gl_texture_image *texImage,
+                         GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
+   texel[RCOMP] =
+   texel[GCOMP] =
+   texel[BCOMP] = UBYTE_TO_FLOAT( src[0] );
+   texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_l8(struct gl_texture_image *texImage,
+                           GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLubyte *rgba = (const GLubyte *) texel;
+   GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
+   *dst = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_I8 ************************************************************/
+
+/* Fetch texel from 1D, 2D or 3D i8 texture, return 4 GLchans */
+static void FETCH(f_i8)( const struct gl_texture_image *texImage,
+                         GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
+   texel[RCOMP] =
+   texel[GCOMP] =
+   texel[BCOMP] =
+   texel[ACOMP] = UBYTE_TO_FLOAT( src[0] );
+}
+
+#if DIM == 3
+static void store_texel_i8(struct gl_texture_image *texImage,
+                           GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLubyte *rgba = (const GLubyte *) texel;
+   GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
+   *dst = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_CI8 ***********************************************************/
+
+/* Fetch CI texel from 1D, 2D or 3D ci8 texture, lookup the index in a
+ * color table, and return 4 GLchans.
+ */
+static void FETCH(f_ci8)( const struct gl_texture_image *texImage,
+                          GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
+   const struct gl_color_table *palette;
+   GLuint index;
+   GET_CURRENT_CONTEXT(ctx);
+
+   if (ctx->Texture.SharedPalette) {
+      palette = &ctx->Texture.Palette;
+   }
+   else {
+      palette = &texImage->TexObject->Palette;
+   }
+   if (palette->Size == 0)
+      return; /* undefined results */
+
+   /* Mask the index against size of palette to avoid going out of bounds */
+   index = (*src) & (palette->Size - 1);
+
+   {
+      const GLfloat *table = palette->TableF;
+      switch (palette->_BaseFormat) {
+      case GL_ALPHA:
+         texel[RCOMP] =
+         texel[GCOMP] =
+         texel[BCOMP] = 0.0F;
+         texel[ACOMP] = table[index];
+         break;
+      case GL_LUMINANCE:
+         texel[RCOMP] =
+         texel[GCOMP] =
+         texel[BCOMP] = table[index];
+         texel[ACOMP] = 1.0F;
+         break;
+      case GL_INTENSITY:
+         texel[RCOMP] =
+         texel[GCOMP] =
+         texel[BCOMP] =
+         texel[ACOMP] = table[index];
+         break;
+      case GL_LUMINANCE_ALPHA:
+         texel[RCOMP] =
+         texel[GCOMP] =
+         texel[BCOMP] = table[index * 2 + 0];
+         texel[ACOMP] = table[index * 2 + 1];
+         break;
+      case GL_RGB:
+         texel[RCOMP] = table[index * 3 + 0];
+         texel[GCOMP] = table[index * 3 + 1];
+         texel[BCOMP] = table[index * 3 + 2];
+         texel[ACOMP] = 1.0F;
+         break;
+      case GL_RGBA:
+         texel[RCOMP] = table[index * 4 + 0];
+         texel[GCOMP] = table[index * 4 + 1];
+         texel[BCOMP] = table[index * 4 + 2];
+         texel[ACOMP] = table[index * 4 + 3];
+         break;
+      default:
+         _mesa_problem(ctx, "Bad palette format in fetch_texel_ci8");
+         return;
+      }
+   }
+}
+
+#if DIM == 3
+static void store_texel_ci8(struct gl_texture_image *texImage,
+                            GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLubyte *index = (const GLubyte *) texel;
+   GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
+   *dst = *index;
+}
+#endif
+
+
+/* Fetch texel from 1D, 2D or 3D srgb8 texture, return 4 GLfloats */
+/* Note: component order is same as for MESA_FORMAT_RGB888 */
+static void FETCH(srgb8)(const struct gl_texture_image *texImage,
+                         GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
+   texel[RCOMP] = nonlinear_to_linear(src[2]);
+   texel[GCOMP] = nonlinear_to_linear(src[1]);
+   texel[BCOMP] = nonlinear_to_linear(src[0]);
+   texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_srgb8(struct gl_texture_image *texImage,
+                              GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLubyte *rgba = (const GLubyte *) texel;
+   GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
+   dst[0] = rgba[BCOMP]; /* no conversion */
+   dst[1] = rgba[GCOMP];
+   dst[2] = rgba[RCOMP];
+}
+#endif
+
+/* Fetch texel from 1D, 2D or 3D srgba8 texture, return 4 GLfloats */
+static void FETCH(srgba8)(const struct gl_texture_image *texImage,
+                          GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   texel[RCOMP] = nonlinear_to_linear( (s >> 24) );
+   texel[GCOMP] = nonlinear_to_linear( (s >> 16) & 0xff );
+   texel[BCOMP] = nonlinear_to_linear( (s >>  8) & 0xff );
+   texel[ACOMP] = UBYTE_TO_FLOAT( (s      ) & 0xff ); /* linear! */
+}
+
+#if DIM == 3
+static void store_texel_srgba8(struct gl_texture_image *texImage,
+                               GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLubyte *rgba = (const GLubyte *) texel;
+   GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
+}
+#endif
+
+/* Fetch texel from 1D, 2D or 3D sargb8 texture, return 4 GLfloats */
+static void FETCH(sargb8)(const struct gl_texture_image *texImage,
+                          GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   texel[RCOMP] = nonlinear_to_linear( (s >> 16) & 0xff );
+   texel[GCOMP] = nonlinear_to_linear( (s >>  8) & 0xff );
+   texel[BCOMP] = nonlinear_to_linear( (s      ) & 0xff );
+   texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) ); /* linear! */
+}
+
+#if DIM == 3
+static void store_texel_sargb8(struct gl_texture_image *texImage,
+                               GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLubyte *rgba = (const GLubyte *) texel;
+   GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   *dst = PACK_COLOR_8888(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+}
+#endif
+
+/* Fetch texel from 1D, 2D or 3D sl8 texture, return 4 GLfloats */
+static void FETCH(sl8)(const struct gl_texture_image *texImage,
+                       GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
+   texel[RCOMP] = 
+   texel[GCOMP] = 
+   texel[BCOMP] = nonlinear_to_linear(src[0]);
+   texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_sl8(struct gl_texture_image *texImage,
+                            GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLubyte *rgba = (const GLubyte *) texel;
+   GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
+   dst[0] = rgba[RCOMP];
+}
+#endif
+
+/* Fetch texel from 1D, 2D or 3D sla8 texture, return 4 GLfloats */
+static void FETCH(sla8)(const struct gl_texture_image *texImage,
+                       GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 2);
+   texel[RCOMP] =
+   texel[GCOMP] =
+   texel[BCOMP] = nonlinear_to_linear(src[0]);
+   texel[ACOMP] = UBYTE_TO_FLOAT(src[1]); /* linear */
+}
+
+#if DIM == 3
+static void store_texel_sla8(struct gl_texture_image *texImage,
+                            GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLubyte *rgba = (const GLubyte *) texel;
+   GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 2);
+   dst[0] = rgba[RCOMP];
+   dst[1] = rgba[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_DUDV8 ********************************************************/
+
+/* this format by definition produces 0,0,0,1 as rgba values,
+   however we'll return the dudv values as rg and fix up elsewhere */
+static void FETCH(dudv8)(const struct gl_texture_image *texImage,
+                         GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLbyte *src = TEXEL_ADDR(GLbyte, texImage, i, j, k, 2);
+   texel[RCOMP] = BYTE_TO_FLOAT(src[0]);
+   texel[GCOMP] = BYTE_TO_FLOAT(src[1]);
+   texel[BCOMP] = 0;
+   texel[ACOMP] = 0;
+}
+
+/* MESA_FORMAT_SIGNED_RGBA8888 ***********************************************/
+
+static void FETCH(signed_rgba8888)( const struct gl_texture_image *texImage,
+                                   GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   texel[RCOMP] = BYTE_TO_FLOAT_TEX( (s >> 24)        );
+   texel[GCOMP] = BYTE_TO_FLOAT_TEX( (s >> 16) & 0xff );
+   texel[BCOMP] = BYTE_TO_FLOAT_TEX( (s >>  8) & 0xff );
+   texel[ACOMP] = BYTE_TO_FLOAT_TEX( (s      ) & 0xff );
+}
+
+#if DIM == 3
+static void store_texel_signed_rgba8888(struct gl_texture_image *texImage,
+                                        GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLbyte *rgba = (const GLbyte *) texel;
+   GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
+}
+#endif
+
+static void FETCH(signed_rgba8888_rev)( const struct gl_texture_image *texImage,
+                                        GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   texel[RCOMP] = BYTE_TO_FLOAT_TEX( (s      ) & 0xff );
+   texel[GCOMP] = BYTE_TO_FLOAT_TEX( (s >>  8) & 0xff );
+   texel[BCOMP] = BYTE_TO_FLOAT_TEX( (s >> 16) & 0xff );
+   texel[ACOMP] = BYTE_TO_FLOAT_TEX( (s >> 24)        );
+}
+
+#if DIM == 3
+static void store_texel_signed_rgba8888_rev(struct gl_texture_image *texImage,
+                                            GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLubyte *rgba = (const GLubyte *) texel;
+   GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   *dst = PACK_COLOR_8888_REV(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
+}
+#endif
+
+
+
+/* MESA_FORMAT_YCBCR *********************************************************/
+
+/* Fetch texel from 1D, 2D or 3D ycbcr texture, return 4 GLfloats.
+ * We convert YCbCr to RGB here.
+ */
+static void FETCH(f_ycbcr)( const struct gl_texture_image *texImage,
+                            GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLushort *src0 = TEXEL_ADDR(GLushort, texImage, (i & ~1), j, k, 1); /* even */
+   const GLushort *src1 = src0 + 1;                               /* odd */
+   const GLubyte y0 = (*src0 >> 8) & 0xff;  /* luminance */
+   const GLubyte cb = *src0 & 0xff;         /* chroma U */
+   const GLubyte y1 = (*src1 >> 8) & 0xff;  /* luminance */
+   const GLubyte cr = *src1 & 0xff;         /* chroma V */
+   const GLubyte y = (i & 1) ? y1 : y0;     /* choose even/odd luminance */
+   GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128);
+   GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128);
+   GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128);
+   r *= (1.0F / 255.0F);
+   g *= (1.0F / 255.0F);
+   b *= (1.0F / 255.0F);
+   texel[RCOMP] = CLAMP(r, 0.0F, 1.0F);
+   texel[GCOMP] = CLAMP(g, 0.0F, 1.0F);
+   texel[BCOMP] = CLAMP(b, 0.0F, 1.0F);
+   texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_ycbcr(struct gl_texture_image *texImage,
+                              GLint i, GLint j, GLint k, const void *texel)
+{
+   (void) texImage;
+   (void) i;
+   (void) j;
+   (void) k;
+   (void) texel;
+   /* XXX to do */
+}
+#endif
+
+
+/* MESA_FORMAT_YCBCR_REV *****************************************************/
+
+/* Fetch texel from 1D, 2D or 3D ycbcr_rev texture, return 4 GLfloats.
+ * We convert YCbCr to RGB here.
+ */
+static void FETCH(f_ycbcr_rev)( const struct gl_texture_image *texImage,
+                                GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLushort *src0 = TEXEL_ADDR(GLushort, texImage, (i & ~1), j, k, 1); /* even */
+   const GLushort *src1 = src0 + 1;                               /* odd */
+   const GLubyte y0 = *src0 & 0xff;         /* luminance */
+   const GLubyte cr = (*src0 >> 8) & 0xff;  /* chroma V */
+   const GLubyte y1 = *src1 & 0xff;         /* luminance */
+   const GLubyte cb = (*src1 >> 8) & 0xff;  /* chroma U */
+   const GLubyte y = (i & 1) ? y1 : y0;     /* choose even/odd luminance */
+   GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128);
+   GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128);
+   GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128);
+   r *= (1.0F / 255.0F);
+   g *= (1.0F / 255.0F);
+   b *= (1.0F / 255.0F);
+   texel[RCOMP] = CLAMP(r, 0.0F, 1.0F);
+   texel[GCOMP] = CLAMP(g, 0.0F, 1.0F);
+   texel[BCOMP] = CLAMP(b, 0.0F, 1.0F);
+   texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_ycbcr_rev(struct gl_texture_image *texImage,
+                                  GLint i, GLint j, GLint k, const void *texel)
+{
+   (void) texImage;
+   (void) i;
+   (void) j;
+   (void) k;
+   (void) texel;
+   /* XXX to do */
+}
+#endif
+
+
+/* MESA_TEXFORMAT_Z24_S8 ***************************************************/
+
+static void FETCH(f_z24_s8)( const struct gl_texture_image *texImage,
+                             GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   /* only return Z, not stencil data */
+   const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   const GLfloat scale = 1.0F / (GLfloat) 0xffffff;
+   texel[0] = ((*src) >> 8) * scale;
+   ASSERT(texImage->TexFormat == MESA_FORMAT_Z24_S8);
+   ASSERT(texel[0] >= 0.0F);
+   ASSERT(texel[0] <= 1.0F);
+}
+
+#if DIM == 3
+static void store_texel_z24_s8(struct gl_texture_image *texImage,
+                               GLint i, GLint j, GLint k, const void *texel)
+{
+   /* only store Z, not stencil */
+   GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   GLfloat depth = *((GLfloat *) texel);
+   GLuint zi = ((GLuint) (depth * 0xffffff)) << 8;
+   *dst = zi | (*dst & 0xff);
+}
+#endif
+
+
+/* MESA_TEXFORMAT_S8_Z24 ***************************************************/
+
+static void FETCH(f_s8_z24)( const struct gl_texture_image *texImage,
+                             GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   /* only return Z, not stencil data */
+   const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   const GLfloat scale = 1.0F / (GLfloat) 0xffffff;
+   texel[0] = ((*src) & 0x00ffffff) * scale;
+   ASSERT(texImage->TexFormat == MESA_FORMAT_S8_Z24);
+   ASSERT(texel[0] >= 0.0F);
+   ASSERT(texel[0] <= 1.0F);
+}
+
+#if DIM == 3
+static void store_texel_s8_z24(struct gl_texture_image *texImage,
+                               GLint i, GLint j, GLint k, const void *texel)
+{
+   /* only store Z, not stencil */
+   GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   GLfloat depth = *((GLfloat *) texel);
+   GLuint zi = (GLuint) (depth * 0xffffff);
+   *dst = zi | (*dst & 0xff000000);
+}
+#endif
+
+
+#undef TEXEL_ADDR
+#undef DIM
+#undef FETCH
index c709004784b624d15664a5bf6d9982429cdf9bc9..1a374e7bee51ecffb144c5322c3d6ed6e7e7a411 100644 (file)
@@ -1,9 +1,9 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.1
+ * Version:  7.7
  *
- * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
- * Copyright (c) 2008 VMware, Inc.
+ * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
+ * Copyright (c) 2008-2009 VMware, Inc.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
  * Texture formats.
  *
  * \author Gareth Hughes
+ * \author Brian Paul
  */
 
 
-#include "colormac.h"
 #include "context.h"
+#include "texcompress.h"
+#include "texcompress_fxt1.h"
+#include "texcompress_s3tc.h"
 #include "texformat.h"
-#include "texstore.h"
-
-
-#if FEATURE_EXT_texture_sRGB
-
-/**
- * Convert an 8-bit sRGB value from non-linear space to a
- * linear RGB value in [0, 1].
- * Implemented with a 256-entry lookup table.
- */
-static INLINE GLfloat
-nonlinear_to_linear(GLubyte cs8)
-{
-   static GLfloat table[256];
-   static GLboolean tableReady = GL_FALSE;
-   if (!tableReady) {
-      /* compute lookup table now */
-      GLuint i;
-      for (i = 0; i < 256; i++) {
-         const GLfloat cs = UBYTE_TO_FLOAT(i);
-         if (cs <= 0.04045) {
-            table[i] = cs / 12.92f;
-         }
-         else {
-            table[i] = (GLfloat) _mesa_pow((cs + 0.055) / 1.055, 2.4);
-         }
-      }
-      tableReady = GL_TRUE;
-   }
-   return table[cs8];
-}
-
-
-#endif /* FEATURE_EXT_texture_sRGB */
-
-
-/* Texel fetch routines for all supported formats
- */
-#define DIM 1
-#include "texformat_tmp.h"
-
-#define DIM 2
-#include "texformat_tmp.h"
-
-#define DIM 3
-#include "texformat_tmp.h"
-
-/**
- * Null texel fetch function.
- *
- * Have to have this so the FetchTexel function pointer is never NULL.
- */
-static void fetch_null_texel( const struct gl_texture_image *texImage,
-                             GLint i, GLint j, GLint k, GLchan *texel )
-{
-   (void) texImage; (void) i; (void) j; (void) k;
-   texel[RCOMP] = 0;
-   texel[GCOMP] = 0;
-   texel[BCOMP] = 0;
-   texel[ACOMP] = 0;
-   _mesa_warning(NULL, "fetch_null_texel() called!");
-}
-
-static void fetch_null_texelf( const struct gl_texture_image *texImage,
-                               GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   (void) texImage; (void) i; (void) j; (void) k;
-   texel[RCOMP] = 0.0;
-   texel[GCOMP] = 0.0;
-   texel[BCOMP] = 0.0;
-   texel[ACOMP] = 0.0;
-   _mesa_warning(NULL, "fetch_null_texelf() called!");
-}
-
-static void store_null_texel(struct gl_texture_image *texImage,
-                             GLint i, GLint j, GLint k, const void *texel)
-{
-   (void) texImage;
-   (void) i;
-   (void) j;
-   (void) k;
-   (void) texel;
-   /* no-op */
-}
-
-
-/**
- * Notes about the predefined gl_texture_formats:
- *
- * 1. There are 1D, 2D and 3D functions for fetching texels from texture
- *    images, returning both GLchan values and GLfloat values.  (six
- *    functions in total)
- *    You don't have to provide both the GLchan and GLfloat functions;
- *    just one or the other is OK.  Mesa will use an "adaptor" to convert
- *    between GLchan/GLfloat when needed.
- *    Since the adaptors have small performance penalty, we provide both
- *    GLchan and GLfloat functions for some common formats like RGB, RGBA.
- */
-
-
-/***************************************************************/
-/** \name Default GLchan-based formats */
-/*@{*/
-
-const struct gl_texture_format _mesa_texformat_rgba = {
-   MESA_FORMAT_RGBA,                   /* MesaFormat */
-   GL_RGBA,                            /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   CHAN_BITS,                          /* RedBits */
-   CHAN_BITS,                          /* GreenBits */
-   CHAN_BITS,                          /* BlueBits */
-   CHAN_BITS,                          /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   4 * sizeof(GLchan),                 /* TexelBytes */
-   _mesa_texstore_rgba,                        /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_rgba,              /* FetchTexel1Df */
-   fetch_texel_2d_f_rgba,              /* FetchTexel2Df */
-   fetch_texel_3d_f_rgba,              /* FetchTexel3Df */
-   store_texel_rgba                    /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_rgb = {
-   MESA_FORMAT_RGB,                    /* MesaFormat */
-   GL_RGB,                             /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   CHAN_BITS,                          /* RedBits */
-   CHAN_BITS,                          /* GreenBits */
-   CHAN_BITS,                          /* BlueBits */
-   0,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   3 * sizeof(GLchan),                 /* TexelBytes */
-   _mesa_texstore_rgba,/*yes*/         /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_rgb,               /* FetchTexel1Df */
-   fetch_texel_2d_f_rgb,               /* FetchTexel2Df */
-   fetch_texel_3d_f_rgb,               /* FetchTexel3Df */
-   store_texel_rgb                     /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_alpha = {
-   MESA_FORMAT_ALPHA,                  /* MesaFormat */
-   GL_ALPHA,                           /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   0,                                  /* RedBits */
-   0,                                  /* GreenBits */
-   0,                                  /* BlueBits */
-   CHAN_BITS,                          /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   sizeof(GLchan),                     /* TexelBytes */
-   _mesa_texstore_rgba,/*yes*/         /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_alpha,             /* FetchTexel1Df */
-   fetch_texel_2d_f_alpha,             /* FetchTexel2Df */
-   fetch_texel_3d_f_alpha,             /* FetchTexel3Df */
-   store_texel_alpha                   /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_luminance = {
-   MESA_FORMAT_LUMINANCE,              /* MesaFormat */
-   GL_LUMINANCE,                       /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   0,                                  /* RedBits */
-   0,                                  /* GreenBits */
-   0,                                  /* BlueBits */
-   0,                                  /* AlphaBits */
-   CHAN_BITS,                          /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   sizeof(GLchan),                     /* TexelBytes */
-   _mesa_texstore_rgba,/*yes*/         /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_luminance,         /* FetchTexel1Df */
-   fetch_texel_2d_f_luminance,         /* FetchTexel2Df */
-   fetch_texel_3d_f_luminance,         /* FetchTexel3Df */
-   store_texel_luminance               /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_luminance_alpha = {
-   MESA_FORMAT_LUMINANCE_ALPHA,                /* MesaFormat */
-   GL_LUMINANCE_ALPHA,                 /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   0,                                  /* RedBits */
-   0,                                  /* GreenBits */
-   0,                                  /* BlueBits */
-   CHAN_BITS,                          /* AlphaBits */
-   CHAN_BITS,                          /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   2 * sizeof(GLchan),                 /* TexelBytes */
-   _mesa_texstore_rgba,/*yes*/         /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_luminance_alpha,   /* FetchTexel1Df */
-   fetch_texel_2d_f_luminance_alpha,   /* FetchTexel2Df */
-   fetch_texel_3d_f_luminance_alpha,   /* FetchTexel3Df */
-   store_texel_luminance_alpha         /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_intensity = {
-   MESA_FORMAT_INTENSITY,              /* MesaFormat */
-   GL_INTENSITY,                       /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   0,                                  /* RedBits */
-   0,                                  /* GreenBits */
-   0,                                  /* BlueBits */
-   0,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   CHAN_BITS,                          /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   sizeof(GLchan),                     /* TexelBytes */
-   _mesa_texstore_rgba,/*yes*/         /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_intensity,         /* FetchTexel1Df */
-   fetch_texel_2d_f_intensity,         /* FetchTexel2Df */
-   fetch_texel_3d_f_intensity,         /* FetchTexel3Df */
-   store_texel_intensity               /* StoreTexel */
-};
-
-
-#if FEATURE_EXT_texture_sRGB
-
-const struct gl_texture_format _mesa_texformat_srgb8 = {
-   MESA_FORMAT_SRGB8,                  /* MesaFormat */
-   GL_RGB,                             /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   8,                                  /* RedBits */
-   8,                                  /* GreenBits */
-   8,                                  /* BlueBits */
-   0,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   3,                                  /* TexelBytes */
-   _mesa_texstore_srgb8,               /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_srgb8,               /* FetchTexel1Df */
-   fetch_texel_2d_srgb8,               /* FetchTexel2Df */
-   fetch_texel_3d_srgb8,               /* FetchTexel3Df */
-   store_texel_srgb8                   /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_srgba8 = {
-   MESA_FORMAT_SRGBA8,                 /* MesaFormat */
-   GL_RGBA,                            /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   8,                                  /* RedBits */
-   8,                                  /* GreenBits */
-   8,                                  /* BlueBits */
-   8,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   4,                                  /* TexelBytes */
-   _mesa_texstore_srgba8,              /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_srgba8,              /* FetchTexel1Df */
-   fetch_texel_2d_srgba8,              /* FetchTexel2Df */
-   fetch_texel_3d_srgba8,              /* FetchTexel3Df */
-   store_texel_srgba8                  /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_sargb8 = {
-   MESA_FORMAT_SARGB8,                 /* MesaFormat */
-   GL_RGBA,                            /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   8,                                  /* RedBits */
-   8,                                  /* GreenBits */
-   8,                                  /* BlueBits */
-   8,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   4,                                  /* TexelBytes */
-   _mesa_texstore_sargb8,              /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_sargb8,              /* FetchTexel1Df */
-   fetch_texel_2d_sargb8,              /* FetchTexel2Df */
-   fetch_texel_3d_sargb8,              /* FetchTexel3Df */
-   store_texel_sargb8                  /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_sl8 = {
-   MESA_FORMAT_SL8,                    /* MesaFormat */
-   GL_LUMINANCE,                       /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   0,                                  /* RedBits */
-   0,                                  /* GreenBits */
-   0,                                  /* BlueBits */
-   0,                                  /* AlphaBits */
-   8,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   1,                                  /* TexelBytes */
-   _mesa_texstore_sl8,                 /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_sl8,                 /* FetchTexel1Df */
-   fetch_texel_2d_sl8,                 /* FetchTexel2Df */
-   fetch_texel_3d_sl8,                 /* FetchTexel3Df */
-   store_texel_sl8                     /* StoreTexel */
-};
-
-/* Note: this format name looks like a misnomer, make it sal8? */
-const struct gl_texture_format _mesa_texformat_sla8 = {
-   MESA_FORMAT_SLA8,                   /* MesaFormat */
-   GL_LUMINANCE_ALPHA,                 /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   0,                                  /* RedBits */
-   0,                                  /* GreenBits */
-   0,                                  /* BlueBits */
-   8,                                  /* AlphaBits */
-   8,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   2,                                  /* TexelBytes */
-   _mesa_texstore_sla8,                        /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_sla8,                        /* FetchTexel1Df */
-   fetch_texel_2d_sla8,                        /* FetchTexel2Df */
-   fetch_texel_3d_sla8,                        /* FetchTexel3Df */
-   store_texel_sla8                    /* StoreTexel */
-};
-
-#endif /* FEATURE_EXT_texture_sRGB */
-
-const struct gl_texture_format _mesa_texformat_rgba_float32 = {
-   MESA_FORMAT_RGBA_FLOAT32,           /* MesaFormat */
-   GL_RGBA,                            /* BaseFormat */
-   GL_FLOAT,                           /* DataType */
-   8 * sizeof(GLfloat),                        /* RedBits */
-   8 * sizeof(GLfloat),                        /* GreenBits */
-   8 * sizeof(GLfloat),                        /* BlueBits */
-   8 * sizeof(GLfloat),                        /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   4 * sizeof(GLfloat),                        /* TexelBytes */
-   _mesa_texstore_rgba_float32,                /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel1D */
-   fetch_texel_1d_f_rgba_f32,          /* FetchTexel1Df */
-   fetch_texel_2d_f_rgba_f32,          /* FetchTexel2Df */
-   fetch_texel_3d_f_rgba_f32,          /* FetchTexel3Df */
-   store_texel_rgba_f32                        /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_rgba_float16 = {
-   MESA_FORMAT_RGBA_FLOAT16,           /* MesaFormat */
-   GL_RGBA,                            /* BaseFormat */
-   GL_FLOAT,                           /* DataType */
-   8 * sizeof(GLhalfARB),              /* RedBits */
-   8 * sizeof(GLhalfARB),              /* GreenBits */
-   8 * sizeof(GLhalfARB),              /* BlueBits */
-   8 * sizeof(GLhalfARB),              /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   4 * sizeof(GLhalfARB),              /* TexelBytes */
-   _mesa_texstore_rgba_float16,                /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel1D */
-   fetch_texel_1d_f_rgba_f16,          /* FetchTexel1Df */
-   fetch_texel_2d_f_rgba_f16,          /* FetchTexel2Df */
-   fetch_texel_3d_f_rgba_f16,          /* FetchTexel3Df */
-   store_texel_rgba_f16                        /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_rgb_float32 = {
-   MESA_FORMAT_RGB_FLOAT32,            /* MesaFormat */
-   GL_RGB,                             /* BaseFormat */
-   GL_FLOAT,                           /* DataType */
-   8 * sizeof(GLfloat),                        /* RedBits */
-   8 * sizeof(GLfloat),                        /* GreenBits */
-   8 * sizeof(GLfloat),                        /* BlueBits */
-   0,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   3 * sizeof(GLfloat),                        /* TexelBytes */
-   _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel1D */
-   fetch_texel_1d_f_rgb_f32,           /* FetchTexel1Df */
-   fetch_texel_2d_f_rgb_f32,           /* FetchTexel2Df */
-   fetch_texel_3d_f_rgb_f32,           /* FetchTexel3Df */
-   store_texel_rgb_f32                 /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_rgb_float16 = {
-   MESA_FORMAT_RGB_FLOAT16,            /* MesaFormat */
-   GL_RGB,                             /* BaseFormat */
-   GL_FLOAT,                           /* DataType */
-   8 * sizeof(GLhalfARB),              /* RedBits */
-   8 * sizeof(GLhalfARB),              /* GreenBits */
-   8 * sizeof(GLhalfARB),              /* BlueBits */
-   0,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   3 * sizeof(GLhalfARB),              /* TexelBytes */
-   _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel1D */
-   fetch_texel_1d_f_rgb_f16,           /* FetchTexel1Df */
-   fetch_texel_2d_f_rgb_f16,           /* FetchTexel2Df */
-   fetch_texel_3d_f_rgb_f16,           /* FetchTexel3Df */
-   store_texel_rgb_f16                 /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_alpha_float32 = {
-   MESA_FORMAT_ALPHA_FLOAT32,          /* MesaFormat */
-   GL_ALPHA,                           /* BaseFormat */
-   GL_FLOAT,                           /* DataType */
-   0,                                  /* RedBits */
-   0,                                  /* GreenBits */
-   0,                                  /* BlueBits */
-   8 * sizeof(GLfloat),                        /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   1 * sizeof(GLfloat),                        /* TexelBytes */
-   _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel1D */
-   fetch_texel_1d_f_alpha_f32,         /* FetchTexel1Df */
-   fetch_texel_2d_f_alpha_f32,         /* FetchTexel2Df */
-   fetch_texel_3d_f_alpha_f32,         /* FetchTexel3Df */
-   store_texel_alpha_f32               /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_alpha_float16 = {
-   MESA_FORMAT_ALPHA_FLOAT16,          /* MesaFormat */
-   GL_ALPHA,                           /* BaseFormat */
-   GL_FLOAT,                           /* DataType */
-   0,                                  /* RedBits */
-   0,                                  /* GreenBits */
-   0,                                  /* BlueBits */
-   8 * sizeof(GLhalfARB),              /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   1 * sizeof(GLhalfARB),              /* TexelBytes */
-   _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel1D */
-   fetch_texel_1d_f_alpha_f16,         /* FetchTexel1Df */
-   fetch_texel_2d_f_alpha_f16,         /* FetchTexel2Df */
-   fetch_texel_3d_f_alpha_f16,         /* FetchTexel3Df */
-   store_texel_alpha_f16               /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_luminance_float32 = {
-   MESA_FORMAT_LUMINANCE_FLOAT32,      /* MesaFormat */
-   GL_LUMINANCE,                       /* BaseFormat */
-   GL_FLOAT,                           /* DataType */
-   0,                                  /* RedBits */
-   0,                                  /* GreenBits */
-   0,                                  /* BlueBits */
-   0,                                  /* AlphaBits */
-   8 * sizeof(GLfloat),                        /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   1 * sizeof(GLfloat),                        /* TexelBytes */
-   _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_luminance_f32,     /* FetchTexel1Df */
-   fetch_texel_2d_f_luminance_f32,     /* FetchTexel2Df */
-   fetch_texel_3d_f_luminance_f32,     /* FetchTexel3Df */
-   store_texel_luminance_f32           /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_luminance_float16 = {
-   MESA_FORMAT_LUMINANCE_FLOAT16,      /* MesaFormat */
-   GL_LUMINANCE,                       /* BaseFormat */
-   GL_FLOAT,                           /* DataType */
-   0,                                  /* RedBits */
-   0,                                  /* GreenBits */
-   0,                                  /* BlueBits */
-   0,                                  /* AlphaBits */
-   8 * sizeof(GLhalfARB),              /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   1 * sizeof(GLhalfARB),              /* TexelBytes */
-   _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_luminance_f16,     /* FetchTexel1Df */
-   fetch_texel_2d_f_luminance_f16,     /* FetchTexel2Df */
-   fetch_texel_3d_f_luminance_f16,     /* FetchTexel3Df */
-   store_texel_luminance_f16           /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_luminance_alpha_float32 = {
-   MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32,        /* MesaFormat */
-   GL_LUMINANCE_ALPHA,                 /* BaseFormat */
-   GL_FLOAT,                           /* DataType */
-   0,                                  /* RedBits */
-   0,                                  /* GreenBits */
-   0,                                  /* BlueBits */
-   8 * sizeof(GLfloat),                        /* AlphaBits */
-   8 * sizeof(GLfloat),                        /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   2 * sizeof(GLfloat),                        /* TexelBytes */
-   _mesa_texstore_rgba_float32,                /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_luminance_alpha_f32,/* FetchTexel1Df */
-   fetch_texel_2d_f_luminance_alpha_f32,/* FetchTexel2Df */
-   fetch_texel_3d_f_luminance_alpha_f32,/* FetchTexel3Df */
-   store_texel_luminance_alpha_f32     /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_luminance_alpha_float16 = {
-   MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16,        /* MesaFormat */
-   GL_LUMINANCE_ALPHA,                 /* BaseFormat */
-   GL_FLOAT,                           /* DataType */
-   0,                                  /* RedBits */
-   0,                                  /* GreenBits */
-   0,                                  /* BlueBits */
-   8 * sizeof(GLhalfARB),              /* AlphaBits */
-   8 * sizeof(GLhalfARB),              /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   2 * sizeof(GLhalfARB),              /* TexelBytes */
-   _mesa_texstore_rgba_float16,                /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_luminance_alpha_f16,/* FetchTexel1Df */
-   fetch_texel_2d_f_luminance_alpha_f16,/* FetchTexel2Df */
-   fetch_texel_3d_f_luminance_alpha_f16,/* FetchTexel3Df */
-   store_texel_luminance_alpha_f16     /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_intensity_float32 = {
-   MESA_FORMAT_INTENSITY_FLOAT32,      /* MesaFormat */
-   GL_INTENSITY,                       /* BaseFormat */
-   GL_FLOAT,                           /* DataType */
-   0,                                  /* RedBits */
-   0,                                  /* GreenBits */
-   0,                                  /* BlueBits */
-   0,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   8 * sizeof(GLfloat),                        /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   1 * sizeof(GLfloat),                        /* TexelBytes */
-   _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_intensity_f32,     /* FetchTexel1Df */
-   fetch_texel_2d_f_intensity_f32,     /* FetchTexel2Df */
-   fetch_texel_3d_f_intensity_f32,     /* FetchTexel3Df */
-   store_texel_intensity_f32           /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_intensity_float16 = {
-   MESA_FORMAT_INTENSITY_FLOAT16,      /* MesaFormat */
-   GL_INTENSITY,                       /* BaseFormat */
-   GL_FLOAT,                           /* DataType */
-   0,                                  /* RedBits */
-   0,                                  /* GreenBits */
-   0,                                  /* BlueBits */
-   0,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   8 * sizeof(GLhalfARB),              /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   1 * sizeof(GLhalfARB),              /* TexelBytes */
-   _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_intensity_f16,     /* FetchTexel1Df */
-   fetch_texel_2d_f_intensity_f16,     /* FetchTexel2Df */
-   fetch_texel_3d_f_intensity_f16,     /* FetchTexel3Df */
-   store_texel_intensity_f16           /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_dudv8 = {
-   MESA_FORMAT_DUDV8,                  /* MesaFormat */
-   GL_DUDV_ATI,                                /* BaseFormat */
-   GL_SIGNED_NORMALIZED,               /* DataType */
-   /* maybe should add dudvBits field, but spec seems to be
-      lacking the ability to query with GetTexLevelParameter anyway */
-   0,                                  /* RedBits */
-   0,                                  /* GreenBits */
-   0,                                  /* BlueBits */
-   0,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   2,                                  /* TexelBytes */
-   _mesa_texstore_dudv8,               /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_dudv8,               /* FetchTexel1Df */
-   fetch_texel_2d_dudv8,               /* FetchTexel2Df */
-   fetch_texel_3d_dudv8,               /* FetchTexel3Df */
-   NULL                                        /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_signed_rgba8888 = {
-   MESA_FORMAT_SIGNED_RGBA8888,                /* MesaFormat */
-   GL_RGBA,                            /* BaseFormat */
-   GL_SIGNED_NORMALIZED,               /* DataType */
-   8,                                  /* RedBits */
-   8,                                  /* GreenBits */
-   8,                                  /* BlueBits */
-   8,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   4,                                  /* TexelBytes */
-   _mesa_texstore_signed_rgba8888,     /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_signed_rgba8888,     /* FetchTexel1Df */
-   fetch_texel_2d_signed_rgba8888,     /* FetchTexel2Df */
-   fetch_texel_3d_signed_rgba8888,     /* FetchTexel3Df */
-   store_texel_signed_rgba8888         /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_signed_rgba8888_rev = {
-   MESA_FORMAT_SIGNED_RGBA8888_REV,    /* MesaFormat */
-   GL_RGBA,                            /* BaseFormat */
-   GL_SIGNED_NORMALIZED,               /* DataType */
-   8,                                  /* RedBits */
-   8,                                  /* GreenBits */
-   8,                                  /* BlueBits */
-   8,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   4,                                  /* TexelBytes */
-   _mesa_texstore_signed_rgba8888,     /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_signed_rgba8888_rev, /* FetchTexel1Df */
-   fetch_texel_2d_signed_rgba8888_rev, /* FetchTexel2Df */
-   fetch_texel_3d_signed_rgba8888_rev, /* FetchTexel3Df */
-   store_texel_signed_rgba8888_rev             /* StoreTexel */
-};
-
-/*@}*/
-
-
-/***************************************************************/
-/** \name Hardware formats */
-/*@{*/
-
-const struct gl_texture_format _mesa_texformat_rgba8888 = {
-   MESA_FORMAT_RGBA8888,               /* MesaFormat */
-   GL_RGBA,                            /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   8,                                  /* RedBits */
-   8,                                  /* GreenBits */
-   8,                                  /* BlueBits */
-   8,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   4,                                  /* TexelBytes */
-   _mesa_texstore_rgba8888,            /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_rgba8888,          /* FetchTexel1Df */
-   fetch_texel_2d_f_rgba8888,          /* FetchTexel2Df */
-   fetch_texel_3d_f_rgba8888,          /* FetchTexel3Df */
-   store_texel_rgba8888                        /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_rgba8888_rev = {
-   MESA_FORMAT_RGBA8888_REV,           /* MesaFormat */
-   GL_RGBA,                            /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   8,                                  /* RedBits */
-   8,                                  /* GreenBits */
-   8,                                  /* BlueBits */
-   8,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   4,                                  /* TexelBytes */
-   _mesa_texstore_rgba8888,            /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_rgba8888_rev,      /* FetchTexel1Df */
-   fetch_texel_2d_f_rgba8888_rev,      /* FetchTexel2Df */
-   fetch_texel_3d_f_rgba8888_rev,      /* FetchTexel3Df */
-   store_texel_rgba8888_rev            /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_argb8888 = {
-   MESA_FORMAT_ARGB8888,               /* MesaFormat */
-   GL_RGBA,                            /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   8,                                  /* RedBits */
-   8,                                  /* GreenBits */
-   8,                                  /* BlueBits */
-   8,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   4,                                  /* TexelBytes */
-   _mesa_texstore_argb8888,            /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_argb8888,          /* FetchTexel1Df */
-   fetch_texel_2d_f_argb8888,          /* FetchTexel2Df */
-   fetch_texel_3d_f_argb8888,          /* FetchTexel3Df */
-   store_texel_argb8888                        /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_argb8888_rev = {
-   MESA_FORMAT_ARGB8888_REV,           /* MesaFormat */
-   GL_RGBA,                            /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   8,                                  /* RedBits */
-   8,                                  /* GreenBits */
-   8,                                  /* BlueBits */
-   8,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   4,                                  /* TexelBytes */
-   _mesa_texstore_argb8888,            /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_argb8888_rev,      /* FetchTexel1Df */
-   fetch_texel_2d_f_argb8888_rev,      /* FetchTexel2Df */
-   fetch_texel_3d_f_argb8888_rev,      /* FetchTexel3Df */
-   store_texel_argb8888_rev            /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_rgb888 = {
-   MESA_FORMAT_RGB888,                 /* MesaFormat */
-   GL_RGB,                             /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   8,                                  /* RedBits */
-   8,                                  /* GreenBits */
-   8,                                  /* BlueBits */
-   0,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   3,                                  /* TexelBytes */
-   _mesa_texstore_rgb888,              /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_rgb888,            /* FetchTexel1Df */
-   fetch_texel_2d_f_rgb888,            /* FetchTexel2Df */
-   fetch_texel_3d_f_rgb888,            /* FetchTexel3Df */
-   store_texel_rgb888                  /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_bgr888 = {
-   MESA_FORMAT_BGR888,                 /* MesaFormat */
-   GL_RGB,                             /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   8,                                  /* RedBits */
-   8,                                  /* GreenBits */
-   8,                                  /* BlueBits */
-   0,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   3,                                  /* TexelBytes */
-   _mesa_texstore_bgr888,              /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_bgr888,            /* FetchTexel1Df */
-   fetch_texel_2d_f_bgr888,            /* FetchTexel2Df */
-   fetch_texel_3d_f_bgr888,            /* FetchTexel3Df */
-   store_texel_bgr888                  /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_rgb565 = {
-   MESA_FORMAT_RGB565,                 /* MesaFormat */
-   GL_RGB,                             /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   5,                                  /* RedBits */
-   6,                                  /* GreenBits */
-   5,                                  /* BlueBits */
-   0,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   2,                                  /* TexelBytes */
-   _mesa_texstore_rgb565,              /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_rgb565,            /* FetchTexel1Df */
-   fetch_texel_2d_f_rgb565,            /* FetchTexel2Df */
-   fetch_texel_3d_f_rgb565,            /* FetchTexel3Df */
-   store_texel_rgb565                  /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_rgb565_rev = {
-   MESA_FORMAT_RGB565_REV,             /* MesaFormat */
-   GL_RGB,                             /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   5,                                  /* RedBits */
-   6,                                  /* GreenBits */
-   5,                                  /* BlueBits */
-   0,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   2,                                  /* TexelBytes */
-   _mesa_texstore_rgb565,              /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_rgb565_rev,                /* FetchTexel1Df */
-   fetch_texel_2d_f_rgb565_rev,                /* FetchTexel2Df */
-   fetch_texel_3d_f_rgb565_rev,                /* FetchTexel3Df */
-   store_texel_rgb565_rev              /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_rgba4444 = {
-   MESA_FORMAT_RGBA4444,               /* MesaFormat */
-   GL_RGBA,                            /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   4,                                  /* RedBits */
-   4,                                  /* GreenBits */
-   4,                                  /* BlueBits */
-   4,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   2,                                  /* TexelBytes */
-   _mesa_texstore_rgba4444,            /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_rgba4444,          /* FetchTexel1Df */
-   fetch_texel_2d_f_rgba4444,          /* FetchTexel2Df */
-   fetch_texel_3d_f_rgba4444,          /* FetchTexel3Df */
-   store_texel_rgba4444                        /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_argb4444 = {
-   MESA_FORMAT_ARGB4444,               /* MesaFormat */
-   GL_RGBA,                            /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   4,                                  /* RedBits */
-   4,                                  /* GreenBits */
-   4,                                  /* BlueBits */
-   4,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   2,                                  /* TexelBytes */
-   _mesa_texstore_argb4444,            /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_argb4444,          /* FetchTexel1Df */
-   fetch_texel_2d_f_argb4444,          /* FetchTexel2Df */
-   fetch_texel_3d_f_argb4444,          /* FetchTexel3Df */
-   store_texel_argb4444                        /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_argb4444_rev = {
-   MESA_FORMAT_ARGB4444_REV,           /* MesaFormat */
-   GL_RGBA,                            /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   4,                                  /* RedBits */
-   4,                                  /* GreenBits */
-   4,                                  /* BlueBits */
-   4,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   2,                                  /* TexelBytes */
-   _mesa_texstore_argb4444,            /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_argb4444_rev,      /* FetchTexel1Df */
-   fetch_texel_2d_f_argb4444_rev,      /* FetchTexel2Df */
-   fetch_texel_3d_f_argb4444_rev,      /* FetchTexel3Df */
-   store_texel_argb4444_rev            /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_rgba5551 = {
-   MESA_FORMAT_RGBA5551,               /* MesaFormat */
-   GL_RGBA,                            /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   5,                                  /* RedBits */
-   5,                                  /* GreenBits */
-   5,                                  /* BlueBits */
-   1,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   2,                                  /* TexelBytes */
-   _mesa_texstore_rgba5551,            /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_rgba5551,          /* FetchTexel1Df */
-   fetch_texel_2d_f_rgba5551,          /* FetchTexel2Df */
-   fetch_texel_3d_f_rgba5551,          /* FetchTexel3Df */
-   store_texel_rgba5551                        /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_argb1555 = {
-   MESA_FORMAT_ARGB1555,               /* MesaFormat */
-   GL_RGBA,                            /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   5,                                  /* RedBits */
-   5,                                  /* GreenBits */
-   5,                                  /* BlueBits */
-   1,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   2,                                  /* TexelBytes */
-   _mesa_texstore_argb1555,            /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_argb1555,          /* FetchTexel1Df */
-   fetch_texel_2d_f_argb1555,          /* FetchTexel2Df */
-   fetch_texel_3d_f_argb1555,          /* FetchTexel3Df */
-   store_texel_argb1555                        /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_argb1555_rev = {
-   MESA_FORMAT_ARGB1555_REV,           /* MesaFormat */
-   GL_RGBA,                            /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   5,                                  /* RedBits */
-   5,                                  /* GreenBits */
-   5,                                  /* BlueBits */
-   1,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   2,                                  /* TexelBytes */
-   _mesa_texstore_argb1555,            /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_argb1555_rev,      /* FetchTexel1Df */
-   fetch_texel_2d_f_argb1555_rev,      /* FetchTexel2Df */
-   fetch_texel_3d_f_argb1555_rev,      /* FetchTexel3Df */
-   store_texel_argb1555_rev            /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_al88 = {
-   MESA_FORMAT_AL88,                   /* MesaFormat */
-   GL_LUMINANCE_ALPHA,                 /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   0,                                  /* RedBits */
-   0,                                  /* GreenBits */
-   0,                                  /* BlueBits */
-   8,                                  /* AlphaBits */
-   8,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   2,                                  /* TexelBytes */
-   _mesa_texstore_al88,                        /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_al88,              /* FetchTexel1Df */
-   fetch_texel_2d_f_al88,              /* FetchTexel2Df */
-   fetch_texel_3d_f_al88,              /* FetchTexel3Df */
-   store_texel_al88                    /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_al88_rev = {
-   MESA_FORMAT_AL88_REV,               /* MesaFormat */
-   GL_LUMINANCE_ALPHA,                 /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   0,                                  /* RedBits */
-   0,                                  /* GreenBits */
-   0,                                  /* BlueBits */
-   8,                                  /* AlphaBits */
-   8,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   2,                                  /* TexelBytes */
-   _mesa_texstore_al88,                        /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_al88_rev,          /* FetchTexel1Df */
-   fetch_texel_2d_f_al88_rev,          /* FetchTexel2Df */
-   fetch_texel_3d_f_al88_rev,          /* FetchTexel3Df */
-   store_texel_al88_rev                        /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_rgb332 = {
-   MESA_FORMAT_RGB332,                 /* MesaFormat */
-   GL_RGB,                             /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   3,                                  /* RedBits */
-   3,                                  /* GreenBits */
-   2,                                  /* BlueBits */
-   0,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   1,                                  /* TexelBytes */
-   _mesa_texstore_rgb332,              /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_rgb332,            /* FetchTexel1Df */
-   fetch_texel_2d_f_rgb332,            /* FetchTexel2Df */
-   fetch_texel_3d_f_rgb332,            /* FetchTexel3Df */
-   store_texel_rgb332                  /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_a8 = {
-   MESA_FORMAT_A8,                     /* MesaFormat */
-   GL_ALPHA,                           /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   0,                                  /* RedBits */
-   0,                                  /* GreenBits */
-   0,                                  /* BlueBits */
-   8,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   1,                                  /* TexelBytes */
-   _mesa_texstore_a8,                  /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_a8,                        /* FetchTexel1Df */
-   fetch_texel_2d_f_a8,                        /* FetchTexel2Df */
-   fetch_texel_3d_f_a8,                        /* FetchTexel3Df */
-   store_texel_a8                      /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_l8 = {
-   MESA_FORMAT_L8,                     /* MesaFormat */
-   GL_LUMINANCE,                       /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   0,                                  /* RedBits */
-   0,                                  /* GreenBits */
-   0,                                  /* BlueBits */
-   0,                                  /* AlphaBits */
-   8,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   1,                                  /* TexelBytes */
-   _mesa_texstore_a8,/*yes*/           /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_l8,                        /* FetchTexel1Df */
-   fetch_texel_2d_f_l8,                        /* FetchTexel2Df */
-   fetch_texel_3d_f_l8,                        /* FetchTexel3Df */
-   store_texel_l8                      /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_i8 = {
-   MESA_FORMAT_I8,                     /* MesaFormat */
-   GL_INTENSITY,                       /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   0,                                  /* RedBits */
-   0,                                  /* GreenBits */
-   0,                                  /* BlueBits */
-   0,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   8,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   1,                                  /* TexelBytes */
-   _mesa_texstore_a8,/*yes*/           /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_i8,                        /* FetchTexel1Df */
-   fetch_texel_2d_f_i8,                        /* FetchTexel2Df */
-   fetch_texel_3d_f_i8,                        /* FetchTexel3Df */
-   store_texel_i8                      /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_ci8 = {
-   MESA_FORMAT_CI8,                    /* MesaFormat */
-   GL_COLOR_INDEX,                     /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   0,                                  /* RedBits */
-   0,                                  /* GreenBits */
-   0,                                  /* BlueBits */
-   0,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   8,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   1,                                  /* TexelBytes */
-   _mesa_texstore_ci8,                 /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_ci8,               /* FetchTexel1Df */
-   fetch_texel_2d_f_ci8,               /* FetchTexel2Df */
-   fetch_texel_3d_f_ci8,               /* FetchTexel3Df */
-   store_texel_ci8                     /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_ycbcr = {
-   MESA_FORMAT_YCBCR,                  /* MesaFormat */
-   GL_YCBCR_MESA,                      /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   0,                                  /* RedBits */
-   0,                                  /* GreenBits */
-   0,                                  /* BlueBits */
-   0,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   2,                                  /* TexelBytes */
-   _mesa_texstore_ycbcr,               /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_ycbcr,             /* FetchTexel1Df */
-   fetch_texel_2d_f_ycbcr,             /* FetchTexel2Df */
-   fetch_texel_3d_f_ycbcr,             /* FetchTexel3Df */
-   store_texel_ycbcr                   /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_ycbcr_rev = {
-   MESA_FORMAT_YCBCR_REV,              /* MesaFormat */
-   GL_YCBCR_MESA,                      /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   0,                                  /* RedBits */
-   0,                                  /* GreenBits */
-   0,                                  /* BlueBits */
-   0,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   2,                                  /* TexelBytes */
-   _mesa_texstore_ycbcr,               /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_ycbcr_rev,         /* FetchTexel1Df */
-   fetch_texel_2d_f_ycbcr_rev,         /* FetchTexel2Df */
-   fetch_texel_3d_f_ycbcr_rev,         /* FetchTexel3Df */
-   store_texel_ycbcr_rev               /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_z24_s8 = {
-   MESA_FORMAT_Z24_S8,                 /* MesaFormat */
-   GL_DEPTH_STENCIL_EXT,               /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   0,                                  /* RedBits */
-   0,                                  /* GreenBits */
-   0,                                  /* BlueBits */
-   0,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   24,                                 /* DepthBits */
-   8,                                  /* StencilBits */
-   4,                                  /* TexelBytes */
-   _mesa_texstore_z24_s8,              /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_z24_s8,            /* FetchTexel1Df */
-   fetch_texel_2d_f_z24_s8,            /* FetchTexel2Df */
-   fetch_texel_3d_f_z24_s8,            /* FetchTexel3Df */
-   store_texel_z24_s8                  /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_s8_z24 = {
-   MESA_FORMAT_S8_Z24,                 /* MesaFormat */
-   GL_DEPTH_STENCIL_EXT,               /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   0,                                  /* RedBits */
-   0,                                  /* GreenBits */
-   0,                                  /* BlueBits */
-   0,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   24,                                 /* DepthBits */
-   8,                                  /* StencilBits */
-   4,                                  /* TexelBytes */
-   _mesa_texstore_s8_z24,              /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel2D */
-   NULL,                               /* FetchTexel3D */
-   fetch_texel_1d_f_s8_z24,            /* FetchTexel1Df */
-   fetch_texel_2d_f_s8_z24,            /* FetchTexel2Df */
-   fetch_texel_3d_f_s8_z24,            /* FetchTexel3Df */
-   store_texel_s8_z24                  /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_z16 = {
-   MESA_FORMAT_Z16,                    /* MesaFormat */
-   GL_DEPTH_COMPONENT,                 /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   0,                                  /* RedBits */
-   0,                                  /* GreenBits */
-   0,                                  /* BlueBits */
-   0,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   sizeof(GLushort) * 8,               /* DepthBits */
-   0,                                  /* StencilBits */
-   sizeof(GLushort),                   /* TexelBytes */
-   _mesa_texstore_z16,                 /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel1D */
-   fetch_texel_1d_f_z16,               /* FetchTexel1Df */
-   fetch_texel_2d_f_z16,               /* FetchTexel2Df */
-   fetch_texel_3d_f_z16,               /* FetchTexel3Df */
-   store_texel_z16                     /* StoreTexel */
-};
-
-const struct gl_texture_format _mesa_texformat_z32 = {
-   MESA_FORMAT_Z32,                    /* MesaFormat */
-   GL_DEPTH_COMPONENT,                 /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   0,                                  /* RedBits */
-   0,                                  /* GreenBits */
-   0,                                  /* BlueBits */
-   0,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   sizeof(GLuint) * 8,                 /* DepthBits */
-   0,                                  /* StencilBits */
-   sizeof(GLuint),                     /* TexelBytes */
-   _mesa_texstore_z32,                 /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel1D */
-   NULL,                               /* FetchTexel1D */
-   fetch_texel_1d_f_z32,               /* FetchTexel1Df */
-   fetch_texel_2d_f_z32,               /* FetchTexel2Df */
-   fetch_texel_3d_f_z32,               /* FetchTexel3Df */
-   store_texel_z32                     /* StoreTexel */
-};
-
-/*@}*/
-
-
-/***************************************************************/
-/** \name Null format (useful for proxy textures) */
-/*@{*/
-
-const struct gl_texture_format _mesa_null_texformat = {
-   -1,                                 /* MesaFormat */
-   0,                                  /* BaseFormat */
-   GL_NONE,                            /* DataType */
-   0,                                  /* RedBits */
-   0,                                  /* GreenBits */
-   0,                                  /* BlueBits */
-   0,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   0,                                  /* StencilBits */
-   0,                                  /* TexelBytes */
-   NULL,                               /* StoreTexImageFunc */
-   fetch_null_texel,                   /* FetchTexel1D */
-   fetch_null_texel,                   /* FetchTexel2D */
-   fetch_null_texel,                   /* FetchTexel3D */
-   fetch_null_texelf,                  /* FetchTexel1Df */
-   fetch_null_texelf,                  /* FetchTexel2Df */
-   fetch_null_texelf,                  /* FetchTexel3Df */
-   store_null_texel                    /* StoreTexel */
-};
-
-/*@}*/
 
 
 /**
@@ -1475,7 +55,7 @@ const struct gl_texture_format _mesa_null_texformat = {
  * This is called via dd_function_table::ChooseTextureFormat.  Hardware drivers
  * will typically override this function with a specialized version.
  */
-const struct gl_texture_format *
+gl_format
 _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
                          GLenum format, GLenum type )
 {
@@ -1489,15 +69,14 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
       case GL_RGB10_A2:
       case GL_RGBA12:
       case GL_RGBA16:
-         return &_mesa_texformat_rgba;
       case GL_RGBA8:
-         return &_mesa_texformat_rgba8888;
+         return MESA_FORMAT_RGBA8888;
       case GL_RGB5_A1:
-         return &_mesa_texformat_argb1555;
+         return MESA_FORMAT_ARGB1555;
       case GL_RGBA2:
-         return &_mesa_texformat_argb4444_rev; /* just to test another format*/
+         return MESA_FORMAT_ARGB4444_REV; /* just to test another format*/
       case GL_RGBA4:
-         return &_mesa_texformat_argb4444;
+         return MESA_FORMAT_ARGB4444;
 
       /* RGB formats */
       case 3:
@@ -1505,24 +84,22 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
       case GL_RGB10:
       case GL_RGB12:
       case GL_RGB16:
-         return &_mesa_texformat_rgb;
       case GL_RGB8:
-         return &_mesa_texformat_rgb888;
+         return MESA_FORMAT_RGB888;
       case GL_R3_G3_B2:
-         return &_mesa_texformat_rgb332;
+         return MESA_FORMAT_RGB332;
       case GL_RGB4:
-         return &_mesa_texformat_rgb565_rev; /* just to test another format */
+         return MESA_FORMAT_RGB565_REV; /* just to test another format */
       case GL_RGB5:
-         return &_mesa_texformat_rgb565;
+         return MESA_FORMAT_RGB565;
 
       /* Alpha formats */
       case GL_ALPHA:
       case GL_ALPHA4:
       case GL_ALPHA12:
       case GL_ALPHA16:
-         return &_mesa_texformat_alpha;
       case GL_ALPHA8:
-         return &_mesa_texformat_a8;
+         return MESA_FORMAT_A8;
 
       /* Luminance formats */
       case 1:
@@ -1530,29 +107,28 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
       case GL_LUMINANCE4:
       case GL_LUMINANCE12:
       case GL_LUMINANCE16:
-         return &_mesa_texformat_luminance;
       case GL_LUMINANCE8:
-         return &_mesa_texformat_l8;
+         return MESA_FORMAT_L8;
 
       /* Luminance/Alpha formats */
       case 2:
       case GL_LUMINANCE_ALPHA:
       case GL_LUMINANCE4_ALPHA4:
       case GL_LUMINANCE6_ALPHA2:
+      case GL_LUMINANCE8_ALPHA8:
+         return MESA_FORMAT_AL88;
+
       case GL_LUMINANCE12_ALPHA4:
       case GL_LUMINANCE12_ALPHA12:
       case GL_LUMINANCE16_ALPHA16:
-         return &_mesa_texformat_luminance_alpha;
-      case GL_LUMINANCE8_ALPHA8:
-         return &_mesa_texformat_al88;
+         return MESA_FORMAT_AL1616;
 
       case GL_INTENSITY:
       case GL_INTENSITY4:
       case GL_INTENSITY12:
       case GL_INTENSITY16:
-         return &_mesa_texformat_intensity;
       case GL_INTENSITY8:
-         return &_mesa_texformat_i8;
+         return MESA_FORMAT_I8;
 
       case GL_COLOR_INDEX:
       case GL_COLOR_INDEX1_EXT:
@@ -1561,7 +137,7 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
       case GL_COLOR_INDEX12_EXT:
       case GL_COLOR_INDEX16_EXT:
       case GL_COLOR_INDEX8_EXT:
-         return &_mesa_texformat_ci8;
+         return MESA_FORMAT_CI8;
 
       default:
          ; /* fallthrough */
@@ -1572,9 +148,9 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
          case GL_DEPTH_COMPONENT:
          case GL_DEPTH_COMPONENT24:
          case GL_DEPTH_COMPONENT32:
-            return &_mesa_texformat_z32;
+            return MESA_FORMAT_Z32;
          case GL_DEPTH_COMPONENT16:
-            return &_mesa_texformat_z16;
+            return MESA_FORMAT_Z16;
          default:
             ; /* fallthrough */
       }
@@ -1582,35 +158,27 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
 
    switch (internalFormat) {
       case GL_COMPRESSED_ALPHA_ARB:
-         return &_mesa_texformat_alpha;
+         return MESA_FORMAT_A8;
       case GL_COMPRESSED_LUMINANCE_ARB:
-         return &_mesa_texformat_luminance;
+         return MESA_FORMAT_L8;
       case GL_COMPRESSED_LUMINANCE_ALPHA_ARB:
-         return &_mesa_texformat_luminance_alpha;
+         return MESA_FORMAT_AL88;
       case GL_COMPRESSED_INTENSITY_ARB:
-         return &_mesa_texformat_intensity;
+         return MESA_FORMAT_I8;
       case GL_COMPRESSED_RGB_ARB:
-#if FEATURE_texture_fxt1
-         if (ctx->Extensions.TDFX_texture_compression_FXT1)
-            return &_mesa_texformat_rgb_fxt1;
-#endif
-#if FEATURE_texture_s3tc
          if (ctx->Extensions.EXT_texture_compression_s3tc ||
              ctx->Extensions.S3_s3tc)
-            return &_mesa_texformat_rgb_dxt1;
-#endif
-         return &_mesa_texformat_rgb;
-      case GL_COMPRESSED_RGBA_ARB:
-#if FEATURE_texture_fxt1
+            return MESA_FORMAT_RGB_DXT1;
          if (ctx->Extensions.TDFX_texture_compression_FXT1)
-            return &_mesa_texformat_rgba_fxt1;
-#endif
-#if FEATURE_texture_s3tc
+            return MESA_FORMAT_RGB_FXT1;
+         return MESA_FORMAT_RGB888;
+      case GL_COMPRESSED_RGBA_ARB:
          if (ctx->Extensions.EXT_texture_compression_s3tc ||
              ctx->Extensions.S3_s3tc)
-            return &_mesa_texformat_rgba_dxt3; /* Not rgba_dxt1, see spec */
-#endif
-         return &_mesa_texformat_rgba;
+            return MESA_FORMAT_RGBA_DXT3; /* Not rgba_dxt1, see spec */
+         if (ctx->Extensions.TDFX_texture_compression_FXT1)
+            return MESA_FORMAT_RGBA_FXT1;
+         return MESA_FORMAT_RGBA8888;
       default:
          ; /* fallthrough */
    }
@@ -1618,9 +186,9 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
    if (ctx->Extensions.MESA_ycbcr_texture) {
       if (internalFormat == GL_YCBCR_MESA) {
          if (type == GL_UNSIGNED_SHORT_8_8_MESA)
-            return &_mesa_texformat_ycbcr;
+            return MESA_FORMAT_YCBCR;
          else
-            return &_mesa_texformat_ycbcr_rev;
+            return MESA_FORMAT_YCBCR_REV;
       }
    }
 
@@ -1628,9 +196,9 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
    if (ctx->Extensions.TDFX_texture_compression_FXT1) {
       switch (internalFormat) {
          case GL_COMPRESSED_RGB_FXT1_3DFX:
-            return &_mesa_texformat_rgb_fxt1;
+            return MESA_FORMAT_RGB_FXT1;
          case GL_COMPRESSED_RGBA_FXT1_3DFX:
-            return &_mesa_texformat_rgba_fxt1;
+            return MESA_FORMAT_RGBA_FXT1;
          default:
             ; /* fallthrough */
       }
@@ -1641,13 +209,13 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
    if (ctx->Extensions.EXT_texture_compression_s3tc) {
       switch (internalFormat) {
          case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
-            return &_mesa_texformat_rgb_dxt1;
+            return MESA_FORMAT_RGB_DXT1;
          case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
-            return &_mesa_texformat_rgba_dxt1;
+            return MESA_FORMAT_RGBA_DXT1;
          case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
-            return &_mesa_texformat_rgba_dxt3;
+            return MESA_FORMAT_RGBA_DXT3;
          case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
-            return &_mesa_texformat_rgba_dxt5;
+            return MESA_FORMAT_RGBA_DXT5;
          default:
             ; /* fallthrough */
       }
@@ -1657,10 +225,10 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
       switch (internalFormat) {
          case GL_RGB_S3TC:
          case GL_RGB4_S3TC:
-            return &_mesa_texformat_rgb_dxt1;
+            return MESA_FORMAT_RGB_DXT1;
          case GL_RGBA_S3TC:
          case GL_RGBA4_S3TC:
-            return &_mesa_texformat_rgba_dxt3;
+            return MESA_FORMAT_RGBA_DXT3;
          default:
             ; /* fallthrough */
       }
@@ -1670,29 +238,29 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
    if (ctx->Extensions.ARB_texture_float) {
       switch (internalFormat) {
          case GL_ALPHA16F_ARB:
-            return &_mesa_texformat_alpha_float16;
+            return MESA_FORMAT_ALPHA_FLOAT16;
          case GL_ALPHA32F_ARB:
-            return &_mesa_texformat_alpha_float32;
+            return MESA_FORMAT_ALPHA_FLOAT32;
          case GL_LUMINANCE16F_ARB:
-            return &_mesa_texformat_luminance_float16;
+            return MESA_FORMAT_LUMINANCE_FLOAT16;
          case GL_LUMINANCE32F_ARB:
-            return &_mesa_texformat_luminance_float32;
+            return MESA_FORMAT_LUMINANCE_FLOAT32;
          case GL_LUMINANCE_ALPHA16F_ARB:
-            return &_mesa_texformat_luminance_alpha_float16;
+            return MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16;
          case GL_LUMINANCE_ALPHA32F_ARB:
-            return &_mesa_texformat_luminance_alpha_float32;
+            return MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32;
          case GL_INTENSITY16F_ARB:
-            return &_mesa_texformat_intensity_float16;
+            return MESA_FORMAT_INTENSITY_FLOAT16;
          case GL_INTENSITY32F_ARB:
-            return &_mesa_texformat_intensity_float32;
+            return MESA_FORMAT_INTENSITY_FLOAT32;
          case GL_RGB16F_ARB:
-            return &_mesa_texformat_rgb_float16;
+            return MESA_FORMAT_RGB_FLOAT16;
          case GL_RGB32F_ARB:
-            return &_mesa_texformat_rgb_float32;
+            return MESA_FORMAT_RGB_FLOAT32;
          case GL_RGBA16F_ARB:
-            return &_mesa_texformat_rgba_float16;
+            return MESA_FORMAT_RGBA_FLOAT16;
          case GL_RGBA32F_ARB:
-            return &_mesa_texformat_rgba_float32;
+            return MESA_FORMAT_RGBA_FLOAT32;
          default:
             ; /* fallthrough */
       }
@@ -1702,7 +270,7 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
       switch (internalFormat) {
          case GL_DEPTH_STENCIL_EXT:
          case GL_DEPTH24_STENCIL8_EXT:
-            return &_mesa_texformat_z24_s8;
+            return MESA_FORMAT_Z24_S8;
          default:
             ; /* fallthrough */
       }
@@ -1712,7 +280,7 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
       switch (internalFormat) {
          case GL_DUDV_ATI:
          case GL_DU8DV8_ATI:
-            return &_mesa_texformat_dudv8;
+            return MESA_FORMAT_DUDV8;
          default:
             ; /* fallthrough */
       }
@@ -1722,7 +290,7 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
       switch (internalFormat) {
          case GL_RGBA_SNORM:
          case GL_RGBA8_SNORM:
-            return &_mesa_texformat_signed_rgba8888;
+            return MESA_FORMAT_SIGNED_RGBA8888;
          default:
             ; /* fallthrough */
       }
@@ -1734,48 +302,48 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
       switch (internalFormat) {
          case GL_SRGB_EXT:
          case GL_SRGB8_EXT:
-            return &_mesa_texformat_srgb8;
+            return MESA_FORMAT_SRGB8;
          case GL_SRGB_ALPHA_EXT:
          case GL_SRGB8_ALPHA8_EXT:
-            return &_mesa_texformat_srgba8;
+            return MESA_FORMAT_SRGBA8;
          case GL_SLUMINANCE_EXT:
          case GL_SLUMINANCE8_EXT:
-            return &_mesa_texformat_sl8;
+            return MESA_FORMAT_SL8;
          case GL_SLUMINANCE_ALPHA_EXT:
          case GL_SLUMINANCE8_ALPHA8_EXT:
-            return &_mesa_texformat_sla8;
+            return MESA_FORMAT_SLA8;
          case GL_COMPRESSED_SLUMINANCE_EXT:
-            return &_mesa_texformat_sl8;
+            return MESA_FORMAT_SL8;
          case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT:
-            return &_mesa_texformat_sla8;
+            return MESA_FORMAT_SLA8;
          case GL_COMPRESSED_SRGB_EXT:
 #if FEATURE_texture_s3tc
             if (ctx->Extensions.EXT_texture_compression_s3tc)
-               return &_mesa_texformat_srgb_dxt1;
+               return MESA_FORMAT_SRGB_DXT1;
 #endif
-            return &_mesa_texformat_srgb8;
+            return MESA_FORMAT_SRGB8;
          case GL_COMPRESSED_SRGB_ALPHA_EXT:
 #if FEATURE_texture_s3tc
             if (ctx->Extensions.EXT_texture_compression_s3tc)
-               return &_mesa_texformat_srgba_dxt3; /* Not srgba_dxt1, see spec */
+               return MESA_FORMAT_SRGBA_DXT3; /* Not srgba_dxt1, see spec */
 #endif
-            return &_mesa_texformat_srgba8;
+            return MESA_FORMAT_SRGBA8;
 #if FEATURE_texture_s3tc
          case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
             if (ctx->Extensions.EXT_texture_compression_s3tc)
-               return &_mesa_texformat_srgb_dxt1;
+               return MESA_FORMAT_SRGB_DXT1;
             break;
          case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
             if (ctx->Extensions.EXT_texture_compression_s3tc)
-               return &_mesa_texformat_srgba_dxt1;
+               return MESA_FORMAT_SRGBA_DXT1;
             break;
          case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
             if (ctx->Extensions.EXT_texture_compression_s3tc)
-               return &_mesa_texformat_srgba_dxt3;
+               return MESA_FORMAT_SRGBA_DXT3;
             break;
          case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
             if (ctx->Extensions.EXT_texture_compression_s3tc)
-               return &_mesa_texformat_srgba_dxt5;
+               return MESA_FORMAT_SRGBA_DXT5;
             break;
 #endif
          default:
@@ -1785,205 +353,6 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
 #endif /* FEATURE_EXT_texture_sRGB */
 
    _mesa_problem(ctx, "unexpected format in _mesa_choose_tex_format()");
-   return NULL;
+   return MESA_FORMAT_NONE;
 }
 
-
-
-/**
- * Return datatype and number of components per texel for the
- * given gl_texture_format.
- */
-void
-_mesa_format_to_type_and_comps(const struct gl_texture_format *format,
-                               GLenum *datatype, GLuint *comps)
-{
-   switch (format->MesaFormat) {
-   case MESA_FORMAT_RGBA8888:
-   case MESA_FORMAT_RGBA8888_REV:
-   case MESA_FORMAT_ARGB8888:
-   case MESA_FORMAT_ARGB8888_REV:
-      *datatype = CHAN_TYPE;
-      *comps = 4;
-      return;
-   case MESA_FORMAT_RGB888:
-   case MESA_FORMAT_BGR888:
-      *datatype = GL_UNSIGNED_BYTE;
-      *comps = 3;
-      return;
-   case MESA_FORMAT_RGB565:
-   case MESA_FORMAT_RGB565_REV:
-      *datatype = GL_UNSIGNED_SHORT_5_6_5;
-      *comps = 3;
-      return;
-
-   case MESA_FORMAT_ARGB4444:
-   case MESA_FORMAT_ARGB4444_REV:
-      *datatype = GL_UNSIGNED_SHORT_4_4_4_4;
-      *comps = 4;
-      return;
-
-   case MESA_FORMAT_ARGB1555:
-   case MESA_FORMAT_ARGB1555_REV:
-      *datatype = GL_UNSIGNED_SHORT_1_5_5_5_REV;
-      *comps = 4;
-      return;
-
-   case MESA_FORMAT_AL88:
-   case MESA_FORMAT_AL88_REV:
-      *datatype = GL_UNSIGNED_BYTE;
-      *comps = 2;
-      return;
-   case MESA_FORMAT_RGB332:
-      *datatype = GL_UNSIGNED_BYTE_3_3_2;
-      *comps = 3;
-      return;
-
-   case MESA_FORMAT_A8:
-   case MESA_FORMAT_L8:
-   case MESA_FORMAT_I8:
-   case MESA_FORMAT_CI8:
-      *datatype = GL_UNSIGNED_BYTE;
-      *comps = 1;
-      return;
-
-   case MESA_FORMAT_YCBCR:
-   case MESA_FORMAT_YCBCR_REV:
-      *datatype = GL_UNSIGNED_SHORT;
-      *comps = 2;
-      return;
-
-   case MESA_FORMAT_Z24_S8:
-      *datatype = GL_UNSIGNED_INT;
-      *comps = 1; /* XXX OK? */
-      return;
-
-   case MESA_FORMAT_S8_Z24:
-      *datatype = GL_UNSIGNED_INT;
-      *comps = 1; /* XXX OK? */
-      return;
-
-   case MESA_FORMAT_Z16:
-      *datatype = GL_UNSIGNED_SHORT;
-      *comps = 1;
-      return;
-
-   case MESA_FORMAT_Z32:
-      *datatype = GL_UNSIGNED_INT;
-      *comps = 1;
-      return;
-
-   case MESA_FORMAT_DUDV8:
-      *datatype = GL_BYTE;
-      *comps = 2;
-      return;
-
-   case MESA_FORMAT_SIGNED_RGBA8888:
-   case MESA_FORMAT_SIGNED_RGBA8888_REV:
-      *datatype = GL_BYTE;
-      *comps = 4;
-      return;
-
-#if FEATURE_EXT_texture_sRGB
-   case MESA_FORMAT_SRGB8:
-      *datatype = GL_UNSIGNED_BYTE;
-      *comps = 3;
-      return;
-   case MESA_FORMAT_SRGBA8:
-   case MESA_FORMAT_SARGB8:
-      *datatype = GL_UNSIGNED_BYTE;
-      *comps = 4;
-      return;
-   case MESA_FORMAT_SL8:
-      *datatype = GL_UNSIGNED_BYTE;
-      *comps = 1;
-      return;
-   case MESA_FORMAT_SLA8:
-      *datatype = GL_UNSIGNED_BYTE;
-      *comps = 2;
-      return;
-#endif
-
-#if FEATURE_texture_fxt1
-   case MESA_FORMAT_RGB_FXT1:
-   case MESA_FORMAT_RGBA_FXT1:
-#endif
-#if FEATURE_texture_s3tc
-   case MESA_FORMAT_RGB_DXT1:
-   case MESA_FORMAT_RGBA_DXT1:
-   case MESA_FORMAT_RGBA_DXT3:
-   case MESA_FORMAT_RGBA_DXT5:
-#if FEATURE_EXT_texture_sRGB
-   case MESA_FORMAT_SRGB_DXT1:
-   case MESA_FORMAT_SRGBA_DXT1:
-   case MESA_FORMAT_SRGBA_DXT3:
-   case MESA_FORMAT_SRGBA_DXT5:
-#endif
-      /* XXX generate error instead? */
-      *datatype = GL_UNSIGNED_BYTE;
-      *comps = 0;
-      return;
-#endif
-
-   case MESA_FORMAT_RGBA:
-      *datatype = CHAN_TYPE;
-      *comps = 4;
-      return;
-   case MESA_FORMAT_RGB:
-      *datatype = CHAN_TYPE;
-      *comps = 3;
-      return;
-   case MESA_FORMAT_LUMINANCE_ALPHA:
-      *datatype = CHAN_TYPE;
-      *comps = 2;
-      return;
-   case MESA_FORMAT_ALPHA:
-   case MESA_FORMAT_LUMINANCE:
-   case MESA_FORMAT_INTENSITY:
-      *datatype = CHAN_TYPE;
-      *comps = 1;
-      return;
-
-   case MESA_FORMAT_RGBA_FLOAT32:
-      *datatype = GL_FLOAT;
-      *comps = 4;
-      return;
-   case MESA_FORMAT_RGBA_FLOAT16:
-      *datatype = GL_HALF_FLOAT_ARB;
-      *comps = 4;
-      return;
-   case MESA_FORMAT_RGB_FLOAT32:
-      *datatype = GL_FLOAT;
-      *comps = 3;
-      return;
-   case MESA_FORMAT_RGB_FLOAT16:
-      *datatype = GL_HALF_FLOAT_ARB;
-      *comps = 3;
-      return;
-   case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32:
-      *datatype = GL_FLOAT;
-      *comps = 2;
-      return;
-   case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16:
-      *datatype = GL_HALF_FLOAT_ARB;
-      *comps = 2;
-      return;
-   case MESA_FORMAT_ALPHA_FLOAT32:
-   case MESA_FORMAT_LUMINANCE_FLOAT32:
-   case MESA_FORMAT_INTENSITY_FLOAT32:
-      *datatype = GL_FLOAT;
-      *comps = 1;
-      return;
-   case MESA_FORMAT_ALPHA_FLOAT16:
-   case MESA_FORMAT_LUMINANCE_FLOAT16:
-   case MESA_FORMAT_INTENSITY_FLOAT16:
-      *datatype = GL_HALF_FLOAT_ARB;
-      *comps = 1;
-      return;
-
-   default:
-      _mesa_problem(NULL, "bad format in _mesa_format_to_type_and_comps");
-      *datatype = 0;
-      *comps = 1;
-   }
-}
index 5aa1d756cbcdb6824c5493324511af486facdb9d..bda5fd6d8ce24f1cdb455bb692a11aeec6742da9 100644 (file)
@@ -1,9 +1,9 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.1
+ * Version:  7.75
  *
- * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
- * Copyright (c) 2008 VMware, Inc.
+ * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
+ * Copyright (c) 2008-2009 VMware, Inc.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
-
-/**
- * \file texformat.h
- * Texture formats definitions.
- *
- * \author Gareth Hughes
- */
-
-
 #ifndef TEXFORMAT_H
 #define TEXFORMAT_H
 
 
 #include "mtypes.h"
+#include "formats.h"
 
 
-/**
- * Mesa internal texture image formats.
- * All texture images are stored in one of these formats.
- *
- * NOTE: when you add a new format, be sure to update the do_row()
- * function in texstore.c used for auto mipmap generation.
- */
-enum _format {
-   /** 
-    * \name Hardware-friendly formats.  
-    *
-    * Drivers can override the default formats and convert texture images to
-    * one of these as required.  The driver's
-    * dd_function_table::ChooseTextureFormat function will choose one of these
-    * formats.
-    *
-    * \note In the default case, some of these formats will be duplicates of
-    * the generic formats listed below.  However, these formats guarantee their
-    * internal component sizes, while GLchan may vary between GLubyte, GLushort
-    * and GLfloat.
-    */
-   /*@{*/
-                               /* msb <------ TEXEL BITS -----------> lsb */
-                               /* ---- ---- ---- ---- ---- ---- ---- ---- */
-   MESA_FORMAT_RGBA8888,       /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */
-   MESA_FORMAT_RGBA8888_REV,   /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */
-   MESA_FORMAT_ARGB8888,       /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */
-   MESA_FORMAT_ARGB8888_REV,   /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */
-   MESA_FORMAT_RGB888,         /*           RRRR RRRR GGGG GGGG BBBB BBBB */
-   MESA_FORMAT_BGR888,         /*           BBBB BBBB GGGG GGGG RRRR RRRR */
-   MESA_FORMAT_RGB565,         /*                     RRRR RGGG GGGB BBBB */
-   MESA_FORMAT_RGB565_REV,     /*                     GGGB BBBB RRRR RGGG */
-   MESA_FORMAT_RGBA4444,        /*                     RRRR GGGG BBBB AAAA */
-   MESA_FORMAT_ARGB4444,       /*                     AAAA RRRR GGGG BBBB */
-   MESA_FORMAT_ARGB4444_REV,   /*                     GGGG BBBB AAAA RRRR */
-   MESA_FORMAT_RGBA5551,        /*                     RRRR RGGG GGBB BBBA */
-   MESA_FORMAT_ARGB1555,       /*                     ARRR RRGG GGGB BBBB */
-   MESA_FORMAT_ARGB1555_REV,   /*                     GGGB BBBB ARRR RRGG */
-   MESA_FORMAT_AL88,           /*                     AAAA AAAA LLLL LLLL */
-   MESA_FORMAT_AL88_REV,       /*                     LLLL LLLL AAAA AAAA */
-   MESA_FORMAT_RGB332,         /*                               RRRG GGBB */
-   MESA_FORMAT_A8,             /*                               AAAA AAAA */
-   MESA_FORMAT_L8,             /*                               LLLL LLLL */
-   MESA_FORMAT_I8,             /*                               IIII IIII */
-   MESA_FORMAT_CI8,            /*                               CCCC CCCC */
-   MESA_FORMAT_YCBCR,          /*                     YYYY YYYY UorV UorV */
-   MESA_FORMAT_YCBCR_REV,      /*                     UorV UorV YYYY YYYY */
-   MESA_FORMAT_Z24_S8,          /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ SSSS SSSS */
-   MESA_FORMAT_S8_Z24,          /* SSSS SSSS ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */
-   MESA_FORMAT_Z16,             /*                     ZZZZ ZZZZ ZZZZ ZZZZ */
-   MESA_FORMAT_Z32,             /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */
-   /*@}*/
-
-#if FEATURE_EXT_texture_sRGB
-   /**
-    * \name 8-bit/channel sRGB formats
-    */
-   /*@{*/
-   MESA_FORMAT_SRGB8,
-   MESA_FORMAT_SRGBA8,
-   MESA_FORMAT_SARGB8,
-   MESA_FORMAT_SL8,
-   MESA_FORMAT_SLA8,
-#if FEATURE_texture_s3tc
-   MESA_FORMAT_SRGB_DXT1,
-   MESA_FORMAT_SRGBA_DXT1,
-   MESA_FORMAT_SRGBA_DXT3,
-   MESA_FORMAT_SRGBA_DXT5,
-#endif
-   /*@}*/
-#endif
-
-   /**
-    * \name Compressed texture formats.
-    */
-   /*@{*/
-#if FEATURE_texture_fxt1
-   MESA_FORMAT_RGB_FXT1,
-   MESA_FORMAT_RGBA_FXT1,
-#endif
-#if FEATURE_texture_s3tc
-   MESA_FORMAT_RGB_DXT1,
-   MESA_FORMAT_RGBA_DXT1,
-   MESA_FORMAT_RGBA_DXT3,
-   MESA_FORMAT_RGBA_DXT5,
-#endif
-   /*@}*/
-
-   /**
-    * \name Generic GLchan-based formats.
-    *
-    * Software-oriented texture formats.  Texels are arrays of GLchan
-    * values so there are no byte order issues.
-    *
-    * \note Because these are based on the GLchan data type, one cannot assume
-    * 8 bits per channel with these formats.  If you require GLubyte channels,
-    * use one of the hardware formats above.
-    */
-   /*@{*/
-   MESA_FORMAT_RGBA,
-   MESA_FORMAT_RGB,
-   MESA_FORMAT_ALPHA,
-   MESA_FORMAT_LUMINANCE,
-   MESA_FORMAT_LUMINANCE_ALPHA,
-   MESA_FORMAT_INTENSITY,
-   /*@}*/
-
-   /**
-    * \name Floating point texture formats.
-    */
-   /*@{*/
-   MESA_FORMAT_RGBA_FLOAT32,
-   MESA_FORMAT_RGBA_FLOAT16,
-   MESA_FORMAT_RGB_FLOAT32,
-   MESA_FORMAT_RGB_FLOAT16,
-   MESA_FORMAT_ALPHA_FLOAT32,
-   MESA_FORMAT_ALPHA_FLOAT16,
-   MESA_FORMAT_LUMINANCE_FLOAT32,
-   MESA_FORMAT_LUMINANCE_FLOAT16,
-   MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32,
-   MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16,
-   MESA_FORMAT_INTENSITY_FLOAT32,
-   MESA_FORMAT_INTENSITY_FLOAT16,
-   /*@}*/
-
-   /**
-    * \name Signed fixed point texture formats.
-    */
-   /*@{*/
-   MESA_FORMAT_DUDV8,
-   MESA_FORMAT_SIGNED_RGBA8888,
-   MESA_FORMAT_SIGNED_RGBA8888_REV
-   /*@}*/
-};
-
-
-/** GLchan-valued formats */
-/*@{*/
-extern const struct gl_texture_format _mesa_texformat_rgba;
-extern const struct gl_texture_format _mesa_texformat_rgb;
-extern const struct gl_texture_format _mesa_texformat_alpha;
-extern const struct gl_texture_format _mesa_texformat_luminance;
-extern const struct gl_texture_format _mesa_texformat_luminance_alpha;
-extern const struct gl_texture_format _mesa_texformat_intensity;
-/*@}*/
-
-#if FEATURE_EXT_texture_sRGB
-/** sRGB (nonlinear) formats */
-/*@{*/
-extern const struct gl_texture_format _mesa_texformat_srgb8;
-extern const struct gl_texture_format _mesa_texformat_srgba8;
-extern const struct gl_texture_format _mesa_texformat_sargb8;
-extern const struct gl_texture_format _mesa_texformat_sl8;
-extern const struct gl_texture_format _mesa_texformat_sla8;
-#if FEATURE_texture_s3tc
-extern const struct gl_texture_format _mesa_texformat_srgb_dxt1;
-extern const struct gl_texture_format _mesa_texformat_srgba_dxt1;
-extern const struct gl_texture_format _mesa_texformat_srgba_dxt3;
-extern const struct gl_texture_format _mesa_texformat_srgba_dxt5;
-#endif
-/*@}*/
-#endif
-
-/** Floating point texture formats */
-/*@{*/
-extern const struct gl_texture_format _mesa_texformat_rgba_float32;
-extern const struct gl_texture_format _mesa_texformat_rgba_float16;
-extern const struct gl_texture_format _mesa_texformat_rgb_float32;
-extern const struct gl_texture_format _mesa_texformat_rgb_float16;
-extern const struct gl_texture_format _mesa_texformat_alpha_float32;
-extern const struct gl_texture_format _mesa_texformat_alpha_float16;
-extern const struct gl_texture_format _mesa_texformat_luminance_float32;
-extern const struct gl_texture_format _mesa_texformat_luminance_float16;
-extern const struct gl_texture_format _mesa_texformat_luminance_alpha_float32;
-extern const struct gl_texture_format _mesa_texformat_luminance_alpha_float16;
-extern const struct gl_texture_format _mesa_texformat_intensity_float32;
-extern const struct gl_texture_format _mesa_texformat_intensity_float16;
-/*@}*/
-
-/** Signed fixed point texture formats */
-/*@{*/
-extern const struct gl_texture_format _mesa_texformat_dudv8;
-extern const struct gl_texture_format _mesa_texformat_signed_rgba8888;
-extern const struct gl_texture_format _mesa_texformat_signed_rgba8888_rev;
-/*@}*/
-
-/** \name Assorted hardware-friendly formats */
-/*@{*/
-extern const struct gl_texture_format _mesa_texformat_rgba8888;
-extern const struct gl_texture_format _mesa_texformat_rgba8888_rev;
-extern const struct gl_texture_format _mesa_texformat_argb8888;
-extern const struct gl_texture_format _mesa_texformat_argb8888_rev;
-extern const struct gl_texture_format _mesa_texformat_rgb888;
-extern const struct gl_texture_format _mesa_texformat_bgr888;
-extern const struct gl_texture_format _mesa_texformat_rgb565;
-extern const struct gl_texture_format _mesa_texformat_rgb565_rev;
-extern const struct gl_texture_format _mesa_texformat_rgba4444;
-extern const struct gl_texture_format _mesa_texformat_argb4444;
-extern const struct gl_texture_format _mesa_texformat_argb4444_rev;
-extern const struct gl_texture_format _mesa_texformat_argb1555;
-extern const struct gl_texture_format _mesa_texformat_argb1555_rev;
-extern const struct gl_texture_format _mesa_texformat_rgba5551;
-extern const struct gl_texture_format _mesa_texformat_al88;
-extern const struct gl_texture_format _mesa_texformat_al88_rev;
-extern const struct gl_texture_format _mesa_texformat_rgb332;
-extern const struct gl_texture_format _mesa_texformat_a8;
-extern const struct gl_texture_format _mesa_texformat_l8;
-extern const struct gl_texture_format _mesa_texformat_i8;
-extern const struct gl_texture_format _mesa_texformat_ci8;
-extern const struct gl_texture_format _mesa_texformat_z24_s8;
-extern const struct gl_texture_format _mesa_texformat_s8_z24;
-extern const struct gl_texture_format _mesa_texformat_z16;
-extern const struct gl_texture_format _mesa_texformat_z32;
-/*@}*/
-
-/** \name YCbCr formats */
-/*@{*/
-extern const struct gl_texture_format _mesa_texformat_ycbcr;
-extern const struct gl_texture_format _mesa_texformat_ycbcr_rev;
-/*@}*/
-
-/** \name Compressed formats */
-/*@{*/
-#if FEATURE_texture_fxt1
-extern const struct gl_texture_format _mesa_texformat_rgb_fxt1;
-extern const struct gl_texture_format _mesa_texformat_rgba_fxt1;
-#endif
-#if FEATURE_texture_s3tc
-extern const struct gl_texture_format _mesa_texformat_rgb_dxt1;
-extern const struct gl_texture_format _mesa_texformat_rgba_dxt1;
-extern const struct gl_texture_format _mesa_texformat_rgba_dxt3;
-extern const struct gl_texture_format _mesa_texformat_rgba_dxt5;
-#endif
-/*@}*/
-
-/** \name The null format */
-/*@{*/
-extern const struct gl_texture_format _mesa_null_texformat;
-/*@}*/
-
-
-extern const struct gl_texture_format *
+extern gl_format
 _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
                          GLenum format, GLenum type );
 
 
-extern void
-_mesa_format_to_type_and_comps(const struct gl_texture_format *format,
-                               GLenum *datatype, GLuint *comps);
-
-
 #endif
diff --git a/src/mesa/main/texformat_tmp.h b/src/mesa/main/texformat_tmp.h
deleted file mode 100644 (file)
index eb160de..0000000
+++ /dev/null
@@ -1,1474 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version:  6.5.1
- *
- * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
- * Copyright (c) 2008 VMware, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-
-/**
- * \file texformat_tmp.h
- * Texel fetch functions template.
- * 
- * This template file is used by texformat.c to generate texel fetch functions
- * for 1-D, 2-D and 3-D texture images. 
- *
- * It should be expanded by defining \p DIM as the number texture dimensions
- * (1, 2 or 3).  According to the value of \p DIM a series of macros is defined
- * for the texel lookup in the gl_texture_image::Data.
- * 
- * \sa texformat.c and FetchTexel.
- * 
- * \author Gareth Hughes
- * \author Brian Paul
- */
-
-
-#if DIM == 1
-
-#define TEXEL_ADDR( type, image, i, j, k, size ) \
-       ((void) (j), (void) (k), ((type *)(image)->Data + (i) * (size)))
-
-#define FETCH(x) fetch_texel_1d_##x
-
-#elif DIM == 2
-
-#define TEXEL_ADDR( type, image, i, j, k, size )                       \
-       ((void) (k),                                                    \
-        ((type *)(image)->Data + ((image)->RowStride * (j) + (i)) * (size)))
-
-#define FETCH(x) fetch_texel_2d_##x
-
-#elif DIM == 3
-
-#define TEXEL_ADDR( type, image, i, j, k, size )                       \
-       ((type *)(image)->Data + ((image)->ImageOffsets[k]              \
-             + (image)->RowStride * (j) + (i)) * (size))
-
-#define FETCH(x) fetch_texel_3d_##x
-
-#else
-#error illegal number of texture dimensions
-#endif
-
-
-/* MESA_FORMAT_RGBA **********************************************************/
-
-/* Fetch texel from 1D, 2D or 3D RGBA texture, returning 4 GLfloats */
-static void FETCH(f_rgba)( const struct gl_texture_image *texImage,
-                           GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLchan *src = TEXEL_ADDR(GLchan, texImage, i, j, k, 4);
-   texel[RCOMP] = CHAN_TO_FLOAT(src[0]);
-   texel[GCOMP] = CHAN_TO_FLOAT(src[1]);
-   texel[BCOMP] = CHAN_TO_FLOAT(src[2]);
-   texel[ACOMP] = CHAN_TO_FLOAT(src[3]);
-}
-
-#if DIM == 3
-/* Store a GLchan RGBA texel */
-static void store_texel_rgba(struct gl_texture_image *texImage,
-                             GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLchan *rgba = (const GLchan *) texel;
-   GLchan *dst = TEXEL_ADDR(GLchan, texImage, i, j, k, 4);
-   dst[0] = rgba[RCOMP];
-   dst[1] = rgba[GCOMP];
-   dst[2] = rgba[BCOMP];
-   dst[3] = rgba[ACOMP];
-}
-#endif
-
-/* MESA_FORMAT_RGB ***********************************************************/
-
-/* Fetch texel from 1D, 2D or 3D RGB texture, returning 4 GLfloats */
-static void FETCH(f_rgb)( const struct gl_texture_image *texImage,
-                          GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLchan *src = TEXEL_ADDR(GLchan, texImage, i, j, k, 3);
-   texel[RCOMP] = CHAN_TO_FLOAT(src[0]);
-   texel[GCOMP] = CHAN_TO_FLOAT(src[1]);
-   texel[BCOMP] = CHAN_TO_FLOAT(src[2]);
-   texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_rgb(struct gl_texture_image *texImage,
-                            GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLchan *rgba = (const GLchan *) texel;
-   GLchan *dst = TEXEL_ADDR(GLchan, texImage, i, j, k, 3);
-   dst[0] = rgba[RCOMP];
-   dst[1] = rgba[GCOMP];
-   dst[2] = rgba[BCOMP];
-}
-#endif
-
-/* MESA_FORMAT_ALPHA *********************************************************/
-
-/* Fetch texel from 1D, 2D or 3D ALPHA texture, returning 4 GLchans */
-static void FETCH(f_alpha)( const struct gl_texture_image *texImage,
-                         GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLchan *src = TEXEL_ADDR(GLchan, texImage, i, j, k, 1);
-   texel[RCOMP] =
-   texel[GCOMP] =
-   texel[BCOMP] = 0.0F;
-   texel[ACOMP] = CHAN_TO_FLOAT(src[0]);
-}
-
-#if DIM == 3
-static void store_texel_alpha(struct gl_texture_image *texImage,
-                              GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLchan *rgba = (const GLchan *) texel;
-   GLchan *dst = TEXEL_ADDR(GLchan, texImage, i, j, k, 1);
-   dst[0] = rgba[ACOMP];
-}
-#endif
-
-/* MESA_FORMAT_LUMINANCE *****************************************************/
-
-/* Fetch texel from 1D, 2D or 3D LUMIN texture, returning 4 GLchans */
-static void FETCH(f_luminance)( const struct gl_texture_image *texImage,
-                                GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLchan *src = TEXEL_ADDR(GLchan, texImage, i, j, k, 1);
-   texel[RCOMP] =
-   texel[GCOMP] =
-   texel[BCOMP] = CHAN_TO_FLOAT(src[0]);
-   texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_luminance(struct gl_texture_image *texImage,
-                                  GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLchan *rgba = (const GLchan *) texel;
-   GLchan *dst = TEXEL_ADDR(GLchan, texImage, i, j, k, 1);
-   dst[0] = rgba[RCOMP];
-}
-#endif
-
-/* MESA_FORMAT_LUMINANCE_ALPHA ***********************************************/
-
-/* Fetch texel from 1D, 2D or 3D L_A texture, returning 4 GLchans */
-static void FETCH(f_luminance_alpha)(const struct gl_texture_image *texImage,
-                                     GLint i, GLint j, GLint k, GLfloat *texel)
-{
-   const GLchan *src = TEXEL_ADDR(GLchan, texImage, i, j, k, 2);
-   texel[RCOMP] =
-   texel[GCOMP] =
-   texel[BCOMP] = CHAN_TO_FLOAT(src[0]);
-   texel[ACOMP] = CHAN_TO_FLOAT(src[1]);
-}
-
-#if DIM == 3
-static void store_texel_luminance_alpha(struct gl_texture_image *texImage,
-                                  GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLchan *rgba = (const GLchan *) texel;
-   GLchan *dst = TEXEL_ADDR(GLchan, texImage, i, j, k, 2);
-   dst[0] = rgba[RCOMP];
-   dst[1] = rgba[ACOMP];
-}
-#endif
-
-/* MESA_FORMAT_INTENSITY *****************************************************/
-
-/* Fetch texel from 1D, 2D or 3D INT. texture, returning 4 GLchans */
-static void FETCH(f_intensity)( const struct gl_texture_image *texImage,
-                                GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLchan *src = TEXEL_ADDR(GLchan, texImage, i, j, k, 1);
-   texel[RCOMP] =
-   texel[GCOMP] =
-   texel[BCOMP] =
-   texel[ACOMP] = CHAN_TO_FLOAT(src[0]);
-}
-
-#if DIM == 3
-static void store_texel_intensity(struct gl_texture_image *texImage,
-                                  GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLchan *rgba = (const GLchan *) texel;
-   GLchan *dst = TEXEL_ADDR(GLchan, texImage, i, j, k, 1);
-   dst[0] = rgba[RCOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_Z32 ***********************************************************/
-
-/* Fetch depth texel from 1D, 2D or 3D 32-bit depth texture,
- * returning 1 GLfloat.
- * Note: no GLchan version of this function.
- */
-static void FETCH(f_z32)( const struct gl_texture_image *texImage,
-                          GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
-   texel[0] = src[0] * (1.0F / 0xffffffff);
-}
-
-#if DIM == 3
-static void store_texel_z32(struct gl_texture_image *texImage,
-                            GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLuint *depth = (const GLuint *) texel;
-   GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
-   dst[0] = *depth;
-}
-#endif
-
-
-/* MESA_FORMAT_Z16 ***********************************************************/
-
-/* Fetch depth texel from 1D, 2D or 3D 16-bit depth texture,
- * returning 1 GLfloat.
- * Note: no GLchan version of this function.
- */
-static void FETCH(f_z16)(const struct gl_texture_image *texImage,
-                         GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
-   texel[0] = src[0] * (1.0F / 65535.0F);
-}
-
-#if DIM == 3
-static void store_texel_z16(struct gl_texture_image *texImage,
-                            GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLushort *depth = (const GLushort *) texel;
-   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
-   dst[0] = *depth;
-}
-#endif
-
-
-/* MESA_FORMAT_RGBA_F32 ******************************************************/
-
-/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT32 texture, returning 4 GLfloats.
- */
-static void FETCH(f_rgba_f32)( const struct gl_texture_image *texImage,
-                               GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 4);
-   texel[RCOMP] = src[0];
-   texel[GCOMP] = src[1];
-   texel[BCOMP] = src[2];
-   texel[ACOMP] = src[3];
-}
-
-#if DIM == 3
-static void store_texel_rgba_f32(struct gl_texture_image *texImage,
-                                 GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLfloat *depth = (const GLfloat *) texel;
-   GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
-   dst[0] = depth[RCOMP];
-   dst[1] = depth[GCOMP];
-   dst[2] = depth[BCOMP];
-   dst[3] = depth[ACOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_RGBA_F16 ******************************************************/
-
-/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT16 texture,
- * returning 4 GLfloats.
- */
-static void FETCH(f_rgba_f16)( const struct gl_texture_image *texImage,
-                               GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 4);
-   texel[RCOMP] = _mesa_half_to_float(src[0]);
-   texel[GCOMP] = _mesa_half_to_float(src[1]);
-   texel[BCOMP] = _mesa_half_to_float(src[2]);
-   texel[ACOMP] = _mesa_half_to_float(src[3]);
-}
-
-#if DIM == 3
-static void store_texel_rgba_f16(struct gl_texture_image *texImage,
-                                 GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLfloat *depth = (const GLfloat *) texel;
-   GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
-   dst[0] = _mesa_float_to_half(*depth);
-}
-#endif
-
-/* MESA_FORMAT_RGB_F32 *******************************************************/
-
-/* Fetch texel from 1D, 2D or 3D RGB_FLOAT32 texture,
- * returning 4 GLfloats.
- */
-static void FETCH(f_rgb_f32)( const struct gl_texture_image *texImage,
-                              GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 3);
-   texel[RCOMP] = src[0];
-   texel[GCOMP] = src[1];
-   texel[BCOMP] = src[2];
-   texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_rgb_f32(struct gl_texture_image *texImage,
-                                 GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLfloat *depth = (const GLfloat *) texel;
-   GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
-   dst[0] = *depth;
-}
-#endif
-
-
-/* MESA_FORMAT_RGB_F16 *******************************************************/
-
-/* Fetch texel from 1D, 2D or 3D RGB_FLOAT16 texture,
- * returning 4 GLfloats.
- */
-static void FETCH(f_rgb_f16)( const struct gl_texture_image *texImage,
-                              GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 3);
-   texel[RCOMP] = _mesa_half_to_float(src[0]);
-   texel[GCOMP] = _mesa_half_to_float(src[1]);
-   texel[BCOMP] = _mesa_half_to_float(src[2]);
-   texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_rgb_f16(struct gl_texture_image *texImage,
-                                GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLfloat *depth = (const GLfloat *) texel;
-   GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
-   dst[0] = _mesa_float_to_half(*depth);
-}
-#endif
-
-
-/* MESA_FORMAT_ALPHA_F32 *****************************************************/
-
-/* Fetch texel from 1D, 2D or 3D ALPHA_FLOAT32 texture,
- * returning 4 GLfloats.
- */
-static void FETCH(f_alpha_f32)( const struct gl_texture_image *texImage,
-                              GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
-   texel[RCOMP] =
-   texel[GCOMP] =
-   texel[BCOMP] = 0.0F;
-   texel[ACOMP] = src[0];
-}
-
-#if DIM == 3
-static void store_texel_alpha_f32(struct gl_texture_image *texImage,
-                                  GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLfloat *rgba = (const GLfloat *) texel;
-   GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
-   dst[0] = rgba[ACOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_ALPHA_F32 *****************************************************/
-
-/* Fetch texel from 1D, 2D or 3D ALPHA_FLOAT16 texture,
- * returning 4 GLfloats.
- */
-static void FETCH(f_alpha_f16)( const struct gl_texture_image *texImage,
-                              GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
-   texel[RCOMP] =
-   texel[GCOMP] =
-   texel[BCOMP] = 0.0F;
-   texel[ACOMP] = _mesa_half_to_float(src[0]);
-}
-
-#if DIM == 3
-static void store_texel_alpha_f16(struct gl_texture_image *texImage,
-                                  GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLfloat *rgba = (const GLfloat *) texel;
-   GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
-   dst[0] = _mesa_float_to_half(rgba[ACOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_LUMINANCE_F32 *************************************************/
-
-/* Fetch texel from 1D, 2D or 3D LUMINANCE_FLOAT32 texture,
- * returning 4 GLfloats.
- */
-static void FETCH(f_luminance_f32)( const struct gl_texture_image *texImage,
-                                    GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
-   texel[RCOMP] =
-   texel[GCOMP] =
-   texel[BCOMP] = src[0];
-   texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_luminance_f32(struct gl_texture_image *texImage,
-                                  GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLfloat *rgba = (const GLfloat *) texel;
-   GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
-   dst[0] = rgba[RCOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_LUMINANCE_F16 *************************************************/
-
-/* Fetch texel from 1D, 2D or 3D LUMINANCE_FLOAT16 texture,
- * returning 4 GLfloats.
- */
-static void FETCH(f_luminance_f16)( const struct gl_texture_image *texImage,
-                                    GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
-   texel[RCOMP] =
-   texel[GCOMP] =
-   texel[BCOMP] = _mesa_half_to_float(src[0]);
-   texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_luminance_f16(struct gl_texture_image *texImage,
-                                  GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLfloat *rgba = (const GLfloat *) texel;
-   GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
-   dst[0] = _mesa_float_to_half(rgba[RCOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_LUMINANCE_ALPHA_F32 *******************************************/
-
-/* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT32 texture,
- * returning 4 GLfloats.
- */
-static void FETCH(f_luminance_alpha_f32)( const struct gl_texture_image *texImage,
-                                    GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
-   texel[RCOMP] =
-   texel[GCOMP] =
-   texel[BCOMP] = src[0];
-   texel[ACOMP] = src[1];
-}
-
-#if DIM == 3
-static void store_texel_luminance_alpha_f32(struct gl_texture_image *texImage,
-                                  GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLfloat *rgba = (const GLfloat *) texel;
-   GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
-   dst[0] = rgba[RCOMP];
-   dst[1] = rgba[ACOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_LUMINANCE_ALPHA_F16 *******************************************/
-
-/* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT16 texture,
- * returning 4 GLfloats.
- */
-static void FETCH(f_luminance_alpha_f16)( const struct gl_texture_image *texImage,
-                                    GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 2);
-   texel[RCOMP] =
-   texel[GCOMP] =
-   texel[BCOMP] = _mesa_half_to_float(src[0]);
-   texel[ACOMP] = _mesa_half_to_float(src[1]);
-}
-
-#if DIM == 3
-static void store_texel_luminance_alpha_f16(struct gl_texture_image *texImage,
-                                  GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLfloat *rgba = (const GLfloat *) texel;
-   GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 2);
-   dst[0] = _mesa_float_to_half(rgba[RCOMP]);
-   dst[1] = _mesa_float_to_half(rgba[ACOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_INTENSITY_F32 *************************************************/
-
-/* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT32 texture,
- * returning 4 GLfloats.
- */
-static void FETCH(f_intensity_f32)( const struct gl_texture_image *texImage,
-                                    GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
-   texel[RCOMP] =
-   texel[GCOMP] =
-   texel[BCOMP] =
-   texel[ACOMP] = src[0];
-}
-
-#if DIM == 3
-static void store_texel_intensity_f32(struct gl_texture_image *texImage,
-                                  GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLfloat *rgba = (const GLfloat *) texel;
-   GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
-   dst[0] = rgba[RCOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_INTENSITY_F16 *************************************************/
-
-/* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT16 texture,
- * returning 4 GLfloats.
- */
-static void FETCH(f_intensity_f16)( const struct gl_texture_image *texImage,
-                                    GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
-   texel[RCOMP] =
-   texel[GCOMP] =
-   texel[BCOMP] =
-   texel[ACOMP] = _mesa_half_to_float(src[0]);
-}
-
-#if DIM == 3
-static void store_texel_intensity_f16(struct gl_texture_image *texImage,
-                                  GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLfloat *rgba = (const GLfloat *) texel;
-   GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
-   dst[0] = _mesa_float_to_half(rgba[RCOMP]);
-}
-#endif
-
-
-
-
-/*
- * Begin Hardware formats
- */
-
-/* MESA_FORMAT_RGBA8888 ******************************************************/
-
-/* Fetch texel from 1D, 2D or 3D rgba8888 texture, return 4 GLfloats */
-static void FETCH(f_rgba8888)( const struct gl_texture_image *texImage,
-                               GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
-   texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 24)        );
-   texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
-   texel[BCOMP] = UBYTE_TO_FLOAT( (s >>  8) & 0xff );
-   texel[ACOMP] = UBYTE_TO_FLOAT( (s      ) & 0xff );
-}
-
-
-
-#if DIM == 3
-static void store_texel_rgba8888(struct gl_texture_image *texImage,
-                                 GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLubyte *rgba = (const GLubyte *) texel;
-   GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
-   *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_RGBA888_REV ***************************************************/
-
-/* Fetch texel from 1D, 2D or 3D abgr8888 texture, return 4 GLchans */
-static void FETCH(f_rgba8888_rev)( const struct gl_texture_image *texImage,
-                                   GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
-   texel[RCOMP] = UBYTE_TO_FLOAT( (s      ) & 0xff );
-   texel[GCOMP] = UBYTE_TO_FLOAT( (s >>  8) & 0xff );
-   texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
-   texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24)        );
-}
-
-#if DIM == 3
-static void store_texel_rgba8888_rev(struct gl_texture_image *texImage,
-                                  GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLubyte *rgba = (const GLubyte *) texel;
-   GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
-   *dst = PACK_COLOR_8888_REV(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_ARGB8888 ******************************************************/
-
-/* Fetch texel from 1D, 2D or 3D argb8888 texture, return 4 GLchans */
-static void FETCH(f_argb8888)( const struct gl_texture_image *texImage,
-                               GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
-   texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
-   texel[GCOMP] = UBYTE_TO_FLOAT( (s >>  8) & 0xff );
-   texel[BCOMP] = UBYTE_TO_FLOAT( (s      ) & 0xff );
-   texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24)        );
-}
-
-#if DIM == 3
-static void store_texel_argb8888(struct gl_texture_image *texImage,
-                                 GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLubyte *rgba = (const GLubyte *) texel;
-   GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
-   *dst = PACK_COLOR_8888(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_ARGB8888_REV **************************************************/
-
-/* Fetch texel from 1D, 2D or 3D argb8888_rev texture, return 4 GLfloats */
-static void FETCH(f_argb8888_rev)( const struct gl_texture_image *texImage,
-                                   GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
-   texel[RCOMP] = UBYTE_TO_FLOAT( (s >>  8) & 0xff );
-   texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
-   texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 24)        );
-   texel[ACOMP] = UBYTE_TO_FLOAT( (s      ) & 0xff );
-}
-
-#if DIM == 3
-static void store_texel_argb8888_rev(struct gl_texture_image *texImage,
-                                  GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLubyte *rgba = (const GLubyte *) texel;
-   GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
-   *dst = PACK_COLOR_8888(rgba[BCOMP], rgba[GCOMP], rgba[RCOMP], rgba[ACOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_RGB888 ********************************************************/
-
-/* Fetch texel from 1D, 2D or 3D rgb888 texture, return 4 GLchans */
-static void FETCH(f_rgb888)( const struct gl_texture_image *texImage,
-                             GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
-   texel[RCOMP] = UBYTE_TO_FLOAT( src[2] );
-   texel[GCOMP] = UBYTE_TO_FLOAT( src[1] );
-   texel[BCOMP] = UBYTE_TO_FLOAT( src[0] );
-   texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_rgb888(struct gl_texture_image *texImage,
-                               GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLubyte *rgba = (const GLubyte *) texel;
-   GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
-   dst[0] = rgba[BCOMP];
-   dst[1] = rgba[GCOMP];
-   dst[2] = rgba[RCOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_BGR888 ********************************************************/
-
-/* Fetch texel from 1D, 2D or 3D bgr888 texture, return 4 GLchans */
-static void FETCH(f_bgr888)( const struct gl_texture_image *texImage,
-                             GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
-   texel[RCOMP] = UBYTE_TO_FLOAT( src[0] );
-   texel[GCOMP] = UBYTE_TO_FLOAT( src[1] );
-   texel[BCOMP] = UBYTE_TO_FLOAT( src[2] );
-   texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_bgr888(struct gl_texture_image *texImage,
-                               GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLubyte *rgba = (const GLubyte *) texel;
-   GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
-   dst[0] = rgba[RCOMP];
-   dst[1] = rgba[GCOMP];
-   dst[2] = rgba[BCOMP];
-}
-#endif
-
-
-/* use color expansion like (g << 2) | (g >> 4) (does somewhat random rounding)
-   instead of slow (g << 2) * 255 / 252 (always rounds down) */
-
-/* MESA_FORMAT_RGB565 ********************************************************/
-
-/* Fetch texel from 1D, 2D or 3D rgb565 texture, return 4 GLchans */
-static void FETCH(f_rgb565)( const struct gl_texture_image *texImage,
-                             GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
-   const GLushort s = *src;
-   texel[RCOMP] = ((s >> 11) & 0x1f) * (1.0F / 31.0F);
-   texel[GCOMP] = ((s >> 5 ) & 0x3f) * (1.0F / 63.0F);
-   texel[BCOMP] = ((s      ) & 0x1f) * (1.0F / 31.0F);
-   texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_rgb565(struct gl_texture_image *texImage,
-                               GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLubyte *rgba = (const GLubyte *) texel;
-   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
-   *dst = PACK_COLOR_565(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_RGB565_REV ****************************************************/
-
-/* Fetch texel from 1D, 2D or 3D rgb565_rev texture, return 4 GLchans */
-static void FETCH(f_rgb565_rev)( const struct gl_texture_image *texImage,
-                                 GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
-   const GLushort s = (*src >> 8) | (*src << 8); /* byte swap */
-   texel[RCOMP] = UBYTE_TO_FLOAT( ((s >> 8) & 0xf8) | ((s >> 13) & 0x7) );
-   texel[GCOMP] = UBYTE_TO_FLOAT( ((s >> 3) & 0xfc) | ((s >>  9) & 0x3) );
-   texel[BCOMP] = UBYTE_TO_FLOAT( ((s << 3) & 0xf8) | ((s >>  2) & 0x7) );
-   texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_rgb565_rev(struct gl_texture_image *texImage,
-                                  GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLubyte *rgba = (const GLubyte *) texel;
-   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
-   *dst = PACK_COLOR_565(rgba[BCOMP], rgba[GCOMP], rgba[RCOMP]);
-}
-#endif
-
-/* MESA_FORMAT_RGBA4444 ******************************************************/
-
-/* Fetch texel from 1D, 2D or 3D argb444 texture, return 4 GLchans */
-static void FETCH(f_rgba4444)( const struct gl_texture_image *texImage,
-                               GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
-   const GLushort s = *src;
-   texel[RCOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F);
-   texel[GCOMP] = ((s >>  8) & 0xf) * (1.0F / 15.0F);
-   texel[BCOMP] = ((s >>  4) & 0xf) * (1.0F / 15.0F);
-   texel[ACOMP] = ((s      ) & 0xf) * (1.0F / 15.0F);
-}
-
-#if DIM == 3
-static void store_texel_rgba4444(struct gl_texture_image *texImage,
-                                 GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLubyte *rgba = (const GLubyte *) texel;
-   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
-   *dst = PACK_COLOR_4444(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_ARGB4444 ******************************************************/
-
-/* Fetch texel from 1D, 2D or 3D argb444 texture, return 4 GLchans */
-static void FETCH(f_argb4444)( const struct gl_texture_image *texImage,
-                               GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
-   const GLushort s = *src;
-   texel[RCOMP] = ((s >>  8) & 0xf) * (1.0F / 15.0F);
-   texel[GCOMP] = ((s >>  4) & 0xf) * (1.0F / 15.0F);
-   texel[BCOMP] = ((s      ) & 0xf) * (1.0F / 15.0F);
-   texel[ACOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F);
-}
-
-#if DIM == 3
-static void store_texel_argb4444(struct gl_texture_image *texImage,
-                                 GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLubyte *rgba = (const GLubyte *) texel;
-   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
-   *dst = PACK_COLOR_4444(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_ARGB4444_REV **************************************************/
-
-/* Fetch texel from 1D, 2D or 3D argb4444_rev texture, return 4 GLchans */
-static void FETCH(f_argb4444_rev)( const struct gl_texture_image *texImage,
-                                   GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
-   texel[RCOMP] = ((s      ) & 0xf) * (1.0F / 15.0F);
-   texel[GCOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F);
-   texel[BCOMP] = ((s >>  8) & 0xf) * (1.0F / 15.0F);
-   texel[ACOMP] = ((s >>  4) & 0xf) * (1.0F / 15.0F);
-}
-
-#if DIM == 3
-static void store_texel_argb4444_rev(struct gl_texture_image *texImage,
-                                 GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLubyte *rgba = (const GLubyte *) texel;
-   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
-   *dst = PACK_COLOR_4444(rgba[ACOMP], rgba[BCOMP], rgba[GCOMP], rgba[RCOMP]);
-}
-#endif
-
-/* MESA_FORMAT_RGBA5551 ******************************************************/
-
-/* Fetch texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */
-static void FETCH(f_rgba5551)( const struct gl_texture_image *texImage,
-                               GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
-   const GLushort s = *src;
-   texel[RCOMP] = ((s >> 11) & 0x1f) * (1.0F / 31.0F);
-   texel[GCOMP] = ((s >>  6) & 0x1f) * (1.0F / 31.0F);
-   texel[BCOMP] = ((s >>  1) & 0x1f) * (1.0F / 31.0F);
-   texel[ACOMP] = ((s      ) & 0x01) * 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_rgba5551(struct gl_texture_image *texImage,
-                                 GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLubyte *rgba = (const GLubyte *) texel;
-   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
-   *dst = PACK_COLOR_5551(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
-}
-#endif
-
-/* MESA_FORMAT_ARGB1555 ******************************************************/
-
-/* Fetch texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */
-static void FETCH(f_argb1555)( const struct gl_texture_image *texImage,
-                            GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
-   const GLushort s = *src;
-   texel[RCOMP] = ((s >> 10) & 0x1f) * (1.0F / 31.0F);
-   texel[GCOMP] = ((s >>  5) & 0x1f) * (1.0F / 31.0F);
-   texel[BCOMP] = ((s >>  0) & 0x1f) * (1.0F / 31.0F);
-   texel[ACOMP] = ((s >> 15) & 0x01) * 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_argb1555(struct gl_texture_image *texImage,
-                                 GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLubyte *rgba = (const GLubyte *) texel;
-   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
-   *dst = PACK_COLOR_1555(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_ARGB1555_REV **************************************************/
-
-/* Fetch texel from 1D, 2D or 3D argb1555_rev texture, return 4 GLchans */
-static void FETCH(f_argb1555_rev)( const struct gl_texture_image *texImage,
-                                   GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
-   const GLushort s = (*src << 8) | (*src >> 8); /* byteswap */
-   texel[RCOMP] = UBYTE_TO_FLOAT( ((s >>  7) & 0xf8) | ((s >> 12) & 0x7) );
-   texel[GCOMP] = UBYTE_TO_FLOAT( ((s >>  2) & 0xf8) | ((s >>  7) & 0x7) );
-   texel[BCOMP] = UBYTE_TO_FLOAT( ((s <<  3) & 0xf8) | ((s >>  2) & 0x7) );
-   texel[ACOMP] = UBYTE_TO_FLOAT( ((s >> 15) & 0x01) * 255 );
-}
-
-#if DIM == 3
-static void store_texel_argb1555_rev(struct gl_texture_image *texImage,
-                                 GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLubyte *rgba = (const GLubyte *) texel;
-   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
-   *dst = PACK_COLOR_1555_REV(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_AL88 **********************************************************/
-
-/* Fetch texel from 1D, 2D or 3D al88 texture, return 4 GLchans */
-static void FETCH(f_al88)( const struct gl_texture_image *texImage,
-                           GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
-   texel[RCOMP] = 
-   texel[GCOMP] = 
-   texel[BCOMP] = UBYTE_TO_FLOAT( s & 0xff );
-   texel[ACOMP] = UBYTE_TO_FLOAT( s >> 8 );
-}
-
-#if DIM == 3
-static void store_texel_al88(struct gl_texture_image *texImage,
-                             GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLubyte *rgba = (const GLubyte *) texel;
-   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
-   *dst = PACK_COLOR_88(rgba[ACOMP], rgba[RCOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_AL88_REV ******************************************************/
-
-/* Fetch texel from 1D, 2D or 3D al88_rev texture, return 4 GLchans */
-static void FETCH(f_al88_rev)( const struct gl_texture_image *texImage,
-                               GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
-   texel[RCOMP] = 
-   texel[GCOMP] = 
-   texel[BCOMP] = UBYTE_TO_FLOAT( s >> 8 );
-   texel[ACOMP] = UBYTE_TO_FLOAT( s & 0xff );
-}
-
-#if DIM == 3
-static void store_texel_al88_rev(struct gl_texture_image *texImage,
-                                 GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLubyte *rgba = (const GLubyte *) texel;
-   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
-   *dst = PACK_COLOR_88(rgba[RCOMP], rgba[ACOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_RGB332 ********************************************************/
-
-/* Fetch texel from 1D, 2D or 3D rgb332 texture, return 4 GLchans */
-static void FETCH(f_rgb332)( const struct gl_texture_image *texImage,
-                             GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
-   const GLubyte s = *src;
-   texel[RCOMP] = ((s >> 5) & 0x7) * (1.0F / 7.0F);
-   texel[GCOMP] = ((s >> 2) & 0x7) * (1.0F / 7.0F);
-   texel[BCOMP] = ((s     ) & 0x3) * (1.0F / 3.0F);
-   texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_rgb332(struct gl_texture_image *texImage,
-                               GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLubyte *rgba = (const GLubyte *) texel;
-   GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
-   *dst = PACK_COLOR_332(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_A8 ************************************************************/
-
-/* Fetch texel from 1D, 2D or 3D a8 texture, return 4 GLchans */
-static void FETCH(f_a8)( const struct gl_texture_image *texImage,
-                         GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
-   texel[RCOMP] =
-   texel[GCOMP] =
-   texel[BCOMP] = 0.0F;
-   texel[ACOMP] = UBYTE_TO_FLOAT( src[0] );
-}
-
-#if DIM == 3
-static void store_texel_a8(struct gl_texture_image *texImage,
-                           GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLubyte *rgba = (const GLubyte *) texel;
-   GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
-   *dst = rgba[ACOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_L8 ************************************************************/
-
-/* Fetch texel from 1D, 2D or 3D l8 texture, return 4 GLchans */
-static void FETCH(f_l8)( const struct gl_texture_image *texImage,
-                         GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
-   texel[RCOMP] =
-   texel[GCOMP] =
-   texel[BCOMP] = UBYTE_TO_FLOAT( src[0] );
-   texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_l8(struct gl_texture_image *texImage,
-                           GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLubyte *rgba = (const GLubyte *) texel;
-   GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
-   *dst = rgba[RCOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_I8 ************************************************************/
-
-/* Fetch texel from 1D, 2D or 3D i8 texture, return 4 GLchans */
-static void FETCH(f_i8)( const struct gl_texture_image *texImage,
-                         GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
-   texel[RCOMP] =
-   texel[GCOMP] =
-   texel[BCOMP] =
-   texel[ACOMP] = UBYTE_TO_FLOAT( src[0] );
-}
-
-#if DIM == 3
-static void store_texel_i8(struct gl_texture_image *texImage,
-                           GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLubyte *rgba = (const GLubyte *) texel;
-   GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
-   *dst = rgba[RCOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_CI8 ***********************************************************/
-
-/* Fetch CI texel from 1D, 2D or 3D ci8 texture, lookup the index in a
- * color table, and return 4 GLchans.
- */
-static void FETCH(f_ci8)( const struct gl_texture_image *texImage,
-                          GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
-   const struct gl_color_table *palette;
-   GLuint index;
-   GET_CURRENT_CONTEXT(ctx);
-
-   if (ctx->Texture.SharedPalette) {
-      palette = &ctx->Texture.Palette;
-   }
-   else {
-      palette = &texImage->TexObject->Palette;
-   }
-   if (palette->Size == 0)
-      return; /* undefined results */
-
-   /* Mask the index against size of palette to avoid going out of bounds */
-   index = (*src) & (palette->Size - 1);
-
-   {
-      const GLfloat *table = palette->TableF;
-      switch (palette->_BaseFormat) {
-      case GL_ALPHA:
-         texel[RCOMP] =
-         texel[GCOMP] =
-         texel[BCOMP] = 0.0F;
-         texel[ACOMP] = table[index];
-         break;
-      case GL_LUMINANCE:
-         texel[RCOMP] =
-         texel[GCOMP] =
-         texel[BCOMP] = table[index];
-         texel[ACOMP] = 1.0F;
-         break;
-      case GL_INTENSITY:
-         texel[RCOMP] =
-         texel[GCOMP] =
-         texel[BCOMP] =
-         texel[ACOMP] = table[index];
-         break;
-      case GL_LUMINANCE_ALPHA:
-         texel[RCOMP] =
-         texel[GCOMP] =
-         texel[BCOMP] = table[index * 2 + 0];
-         texel[ACOMP] = table[index * 2 + 1];
-         break;
-      case GL_RGB:
-         texel[RCOMP] = table[index * 3 + 0];
-         texel[GCOMP] = table[index * 3 + 1];
-         texel[BCOMP] = table[index * 3 + 2];
-         texel[ACOMP] = 1.0F;
-         break;
-      case GL_RGBA:
-         texel[RCOMP] = table[index * 4 + 0];
-         texel[GCOMP] = table[index * 4 + 1];
-         texel[BCOMP] = table[index * 4 + 2];
-         texel[ACOMP] = table[index * 4 + 3];
-         break;
-      default:
-         _mesa_problem(ctx, "Bad palette format in fetch_texel_ci8");
-         return;
-      }
-   }
-}
-
-#if DIM == 3
-static void store_texel_ci8(struct gl_texture_image *texImage,
-                            GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLubyte *index = (const GLubyte *) texel;
-   GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
-   *dst = *index;
-}
-#endif
-
-
-#if FEATURE_EXT_texture_sRGB
-
-/* Fetch texel from 1D, 2D or 3D srgb8 texture, return 4 GLfloats */
-/* Note: component order is same as for MESA_FORMAT_RGB888 */
-static void FETCH(srgb8)(const struct gl_texture_image *texImage,
-                         GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
-   texel[RCOMP] = nonlinear_to_linear(src[2]);
-   texel[GCOMP] = nonlinear_to_linear(src[1]);
-   texel[BCOMP] = nonlinear_to_linear(src[0]);
-   texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_srgb8(struct gl_texture_image *texImage,
-                              GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLubyte *rgba = (const GLubyte *) texel;
-   GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
-   dst[0] = rgba[BCOMP]; /* no conversion */
-   dst[1] = rgba[GCOMP];
-   dst[2] = rgba[RCOMP];
-}
-#endif
-
-/* Fetch texel from 1D, 2D or 3D srgba8 texture, return 4 GLfloats */
-static void FETCH(srgba8)(const struct gl_texture_image *texImage,
-                          GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
-   texel[RCOMP] = nonlinear_to_linear( (s >> 24) );
-   texel[GCOMP] = nonlinear_to_linear( (s >> 16) & 0xff );
-   texel[BCOMP] = nonlinear_to_linear( (s >>  8) & 0xff );
-   texel[ACOMP] = UBYTE_TO_FLOAT( (s      ) & 0xff ); /* linear! */
-}
-
-#if DIM == 3
-static void store_texel_srgba8(struct gl_texture_image *texImage,
-                               GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLubyte *rgba = (const GLubyte *) texel;
-   GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
-   *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
-}
-#endif
-
-/* Fetch texel from 1D, 2D or 3D sargb8 texture, return 4 GLfloats */
-static void FETCH(sargb8)(const struct gl_texture_image *texImage,
-                          GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
-   texel[RCOMP] = nonlinear_to_linear( (s >> 16) & 0xff );
-   texel[GCOMP] = nonlinear_to_linear( (s >>  8) & 0xff );
-   texel[BCOMP] = nonlinear_to_linear( (s      ) & 0xff );
-   texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) ); /* linear! */
-}
-
-#if DIM == 3
-static void store_texel_sargb8(struct gl_texture_image *texImage,
-                               GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLubyte *rgba = (const GLubyte *) texel;
-   GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
-   *dst = PACK_COLOR_8888(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
-}
-#endif
-
-/* Fetch texel from 1D, 2D or 3D sl8 texture, return 4 GLfloats */
-static void FETCH(sl8)(const struct gl_texture_image *texImage,
-                       GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
-   texel[RCOMP] = 
-   texel[GCOMP] = 
-   texel[BCOMP] = nonlinear_to_linear(src[0]);
-   texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_sl8(struct gl_texture_image *texImage,
-                            GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLubyte *rgba = (const GLubyte *) texel;
-   GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
-   dst[0] = rgba[RCOMP];
-}
-#endif
-
-/* Fetch texel from 1D, 2D or 3D sla8 texture, return 4 GLfloats */
-static void FETCH(sla8)(const struct gl_texture_image *texImage,
-                       GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 2);
-   texel[RCOMP] =
-   texel[GCOMP] =
-   texel[BCOMP] = nonlinear_to_linear(src[0]);
-   texel[ACOMP] = UBYTE_TO_FLOAT(src[1]); /* linear */
-}
-
-#if DIM == 3
-static void store_texel_sla8(struct gl_texture_image *texImage,
-                            GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLubyte *rgba = (const GLubyte *) texel;
-   GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 2);
-   dst[0] = rgba[RCOMP];
-   dst[1] = rgba[ACOMP];
-}
-#endif
-
-#endif /* FEATURE_EXT_texture_sRGB */
-
-
-/* MESA_FORMAT_DUDV8 ********************************************************/
-
-/* this format by definition produces 0,0,0,1 as rgba values,
-   however we'll return the dudv values as rg and fix up elsewhere */
-static void FETCH(dudv8)(const struct gl_texture_image *texImage,
-                         GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLbyte *src = TEXEL_ADDR(GLbyte, texImage, i, j, k, 2);
-   texel[RCOMP] = BYTE_TO_FLOAT(src[0]);
-   texel[GCOMP] = BYTE_TO_FLOAT(src[1]);
-   texel[BCOMP] = 0;
-   texel[ACOMP] = 0;
-}
-
-/* MESA_FORMAT_SIGNED_RGBA8888 ***********************************************/
-
-static void FETCH(signed_rgba8888)( const struct gl_texture_image *texImage,
-                                   GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
-   texel[RCOMP] = BYTE_TO_FLOAT_TEX( (s >> 24)        );
-   texel[GCOMP] = BYTE_TO_FLOAT_TEX( (s >> 16) & 0xff );
-   texel[BCOMP] = BYTE_TO_FLOAT_TEX( (s >>  8) & 0xff );
-   texel[ACOMP] = BYTE_TO_FLOAT_TEX( (s      ) & 0xff );
-}
-
-#if DIM == 3
-static void store_texel_signed_rgba8888(struct gl_texture_image *texImage,
-                                        GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLbyte *rgba = (const GLbyte *) texel;
-   GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
-   *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
-}
-#endif
-
-static void FETCH(signed_rgba8888_rev)( const struct gl_texture_image *texImage,
-                                        GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
-   texel[RCOMP] = BYTE_TO_FLOAT_TEX( (s      ) & 0xff );
-   texel[GCOMP] = BYTE_TO_FLOAT_TEX( (s >>  8) & 0xff );
-   texel[BCOMP] = BYTE_TO_FLOAT_TEX( (s >> 16) & 0xff );
-   texel[ACOMP] = BYTE_TO_FLOAT_TEX( (s >> 24)        );
-}
-
-#if DIM == 3
-static void store_texel_signed_rgba8888_rev(struct gl_texture_image *texImage,
-                                            GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLubyte *rgba = (const GLubyte *) texel;
-   GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
-   *dst = PACK_COLOR_8888_REV(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
-}
-#endif
-
-
-
-/* MESA_FORMAT_YCBCR *********************************************************/
-
-/* Fetch texel from 1D, 2D or 3D ycbcr texture, return 4 GLfloats.
- * We convert YCbCr to RGB here.
- */
-static void FETCH(f_ycbcr)( const struct gl_texture_image *texImage,
-                            GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLushort *src0 = TEXEL_ADDR(GLushort, texImage, (i & ~1), j, k, 1); /* even */
-   const GLushort *src1 = src0 + 1;                               /* odd */
-   const GLubyte y0 = (*src0 >> 8) & 0xff;  /* luminance */
-   const GLubyte cb = *src0 & 0xff;         /* chroma U */
-   const GLubyte y1 = (*src1 >> 8) & 0xff;  /* luminance */
-   const GLubyte cr = *src1 & 0xff;         /* chroma V */
-   const GLubyte y = (i & 1) ? y1 : y0;     /* choose even/odd luminance */
-   GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128);
-   GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128);
-   GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128);
-   r *= (1.0F / 255.0F);
-   g *= (1.0F / 255.0F);
-   b *= (1.0F / 255.0F);
-   texel[RCOMP] = CLAMP(r, 0.0F, 1.0F);
-   texel[GCOMP] = CLAMP(g, 0.0F, 1.0F);
-   texel[BCOMP] = CLAMP(b, 0.0F, 1.0F);
-   texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_ycbcr(struct gl_texture_image *texImage,
-                              GLint i, GLint j, GLint k, const void *texel)
-{
-   (void) texImage;
-   (void) i;
-   (void) j;
-   (void) k;
-   (void) texel;
-   /* XXX to do */
-}
-#endif
-
-
-/* MESA_FORMAT_YCBCR_REV *****************************************************/
-
-/* Fetch texel from 1D, 2D or 3D ycbcr_rev texture, return 4 GLfloats.
- * We convert YCbCr to RGB here.
- */
-static void FETCH(f_ycbcr_rev)( const struct gl_texture_image *texImage,
-                                GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLushort *src0 = TEXEL_ADDR(GLushort, texImage, (i & ~1), j, k, 1); /* even */
-   const GLushort *src1 = src0 + 1;                               /* odd */
-   const GLubyte y0 = *src0 & 0xff;         /* luminance */
-   const GLubyte cr = (*src0 >> 8) & 0xff;  /* chroma V */
-   const GLubyte y1 = *src1 & 0xff;         /* luminance */
-   const GLubyte cb = (*src1 >> 8) & 0xff;  /* chroma U */
-   const GLubyte y = (i & 1) ? y1 : y0;     /* choose even/odd luminance */
-   GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128);
-   GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128);
-   GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128);
-   r *= (1.0F / 255.0F);
-   g *= (1.0F / 255.0F);
-   b *= (1.0F / 255.0F);
-   texel[RCOMP] = CLAMP(r, 0.0F, 1.0F);
-   texel[GCOMP] = CLAMP(g, 0.0F, 1.0F);
-   texel[BCOMP] = CLAMP(b, 0.0F, 1.0F);
-   texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_ycbcr_rev(struct gl_texture_image *texImage,
-                                  GLint i, GLint j, GLint k, const void *texel)
-{
-   (void) texImage;
-   (void) i;
-   (void) j;
-   (void) k;
-   (void) texel;
-   /* XXX to do */
-}
-#endif
-
-
-/* MESA_TEXFORMAT_Z24_S8 ***************************************************/
-
-static void FETCH(f_z24_s8)( const struct gl_texture_image *texImage,
-                             GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   /* only return Z, not stencil data */
-   const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
-   const GLfloat scale = 1.0F / (GLfloat) 0xffffff;
-   texel[0] = ((*src) >> 8) * scale;
-   ASSERT(texImage->TexFormat->MesaFormat == MESA_FORMAT_Z24_S8);
-   ASSERT(texel[0] >= 0.0F);
-   ASSERT(texel[0] <= 1.0F);
-}
-
-#if DIM == 3
-static void store_texel_z24_s8(struct gl_texture_image *texImage,
-                               GLint i, GLint j, GLint k, const void *texel)
-{
-   /* only store Z, not stencil */
-   GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
-   GLfloat depth = *((GLfloat *) texel);
-   GLuint zi = ((GLuint) (depth * 0xffffff)) << 8;
-   *dst = zi | (*dst & 0xff);
-}
-#endif
-
-
-/* MESA_TEXFORMAT_S8_Z24 ***************************************************/
-
-static void FETCH(f_s8_z24)( const struct gl_texture_image *texImage,
-                             GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   /* only return Z, not stencil data */
-   const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
-   const GLfloat scale = 1.0F / (GLfloat) 0xffffff;
-   texel[0] = ((*src) & 0x00ffffff) * scale;
-   ASSERT(texImage->TexFormat->MesaFormat == MESA_FORMAT_S8_Z24);
-   ASSERT(texel[0] >= 0.0F);
-   ASSERT(texel[0] <= 1.0F);
-}
-
-#if DIM == 3
-static void store_texel_s8_z24(struct gl_texture_image *texImage,
-                               GLint i, GLint j, GLint k, const void *texel)
-{
-   /* only store Z, not stencil */
-   GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
-   GLfloat depth = *((GLfloat *) texel);
-   GLuint zi = (GLuint) (depth * 0xffffff);
-   *dst = zi | (*dst & 0xff000000);
-}
-#endif
-
-
-#undef TEXEL_ADDR
-#undef DIM
-#undef FETCH
index 733e129fcfe12c7918c4ba14559e63f078db603f..be4e03bc56c328d98d3027b24d0cd277ffecfcf7 100644 (file)
@@ -186,8 +186,10 @@ _mesa_TexGeniv(GLenum coord, GLenum pname, const GLint *params )
 static void GLAPIENTRY
 _mesa_TexGend(GLenum coord, GLenum pname, GLdouble param )
 {
-   GLfloat p = (GLfloat) param;
-   _mesa_TexGenfv( coord, pname, &p );
+   GLfloat p[4];
+   p[0] = (GLfloat) param;
+   p[1] = p[2] = p[3] = 0.0F;
+   _mesa_TexGenfv( coord, pname, p );
 }
 
 
@@ -211,14 +213,20 @@ _mesa_TexGendv(GLenum coord, GLenum pname, const GLdouble *params )
 static void GLAPIENTRY
 _mesa_TexGenf( GLenum coord, GLenum pname, GLfloat param )
 {
-   _mesa_TexGenfv(coord, pname, &param);
+   GLfloat p[4];
+   p[0] = param;
+   p[1] = p[2] = p[3] = 0.0F;
+   _mesa_TexGenfv(coord, pname, p);
 }
 
 
 void GLAPIENTRY
 _mesa_TexGeni( GLenum coord, GLenum pname, GLint param )
 {
-   _mesa_TexGeniv( coord, pname, &param );
+   GLint p[4];
+   p[0] = param;
+   p[1] = p[2] = p[3] = 0;
+   _mesa_TexGeniv( coord, pname, p );
 }
 
 
index 14d6fc76590c7ba3223793d389ebcf5da3f27402..d786c41d2ebb0fc9e2c74203e1b159ee73bc8741 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Mesa 3-D graphics library
- * Version:  7.5
+ * Version:  7.7
  *
  * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
  * Copyright (c) 2009 VMware, Inc.
 
 #include "glheader.h"
 #include "bufferobj.h"
+#include "enums.h"
 #include "context.h"
+#include "formats.h"
 #include "image.h"
 #include "texcompress.h"
-#include "texformat.h"
 #include "texgetimage.h"
 #include "teximage.h"
 #include "texstate.h"
 
 #if FEATURE_EXT_texture_sRGB
 
-/**
- * Test if given texture image is an sRGB format.
- */
-static GLboolean
-is_srgb_teximage(const struct gl_texture_image *texImage)
-{
-   switch (texImage->TexFormat->MesaFormat) {
-   case MESA_FORMAT_SRGB8:
-   case MESA_FORMAT_SRGBA8:
-   case MESA_FORMAT_SARGB8:
-   case MESA_FORMAT_SL8:
-   case MESA_FORMAT_SLA8:
-   case MESA_FORMAT_SRGB_DXT1:
-   case MESA_FORMAT_SRGBA_DXT1:
-   case MESA_FORMAT_SRGBA_DXT3:
-   case MESA_FORMAT_SRGBA_DXT5:
-      return GL_TRUE;
-   default:
-      return GL_FALSE;
-   }
-}
-
-
 /**
  * Convert a float value from linear space to a
  * non-linear sRGB value in [0, 255].
@@ -107,9 +85,358 @@ type_with_negative_values(GLenum type)
 }
 
 
+/**
+ * glGetTexImage for color index pixels.
+ */
+static void
+get_tex_color_index(GLcontext *ctx, GLuint dimensions,
+                    GLenum format, GLenum type, GLvoid *pixels,
+                    const struct gl_texture_image *texImage)
+{
+   const GLint width = texImage->Width;
+   const GLint height = texImage->Height;
+   const GLint depth = texImage->Depth;
+   const GLuint indexBits =
+      _mesa_get_format_bits(texImage->TexFormat, GL_TEXTURE_INDEX_SIZE_EXT);
+   const GLbitfield transferOps = 0x0;
+   GLint img, row, col;
+
+   for (img = 0; img < depth; img++) {
+      for (row = 0; row < height; row++) {
+         GLuint indexRow[MAX_WIDTH] = { 0 };
+         void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels,
+                                          width, height, format, type,
+                                          img, row, 0);
+         assert(dest);
+
+         if (indexBits == 8) {
+            const GLubyte *src = (const GLubyte *) texImage->Data;
+            src += width * (img * texImage->Height + row);
+            for (col = 0; col < width; col++) {
+               indexRow[col] = src[col];
+            }
+         }
+         else if (indexBits == 16) {
+            const GLushort *src = (const GLushort *) texImage->Data;
+            src += width * (img * texImage->Height + row);
+            for (col = 0; col < width; col++) {
+               indexRow[col] = src[col];
+            }
+         }
+         else {
+            _mesa_problem(ctx, "Color index problem in _mesa_GetTexImage");
+         }
+         _mesa_pack_index_span(ctx, width, type, dest,
+                               indexRow, &ctx->Pack, transferOps);
+      }
+   }
+}
+
+
+/**
+ * glGetTexImage for depth/Z pixels.
+ */
+static void
+get_tex_depth(GLcontext *ctx, GLuint dimensions,
+              GLenum format, GLenum type, GLvoid *pixels,
+              const struct gl_texture_image *texImage)
+{
+   const GLint width = texImage->Width;
+   const GLint height = texImage->Height;
+   const GLint depth = texImage->Depth;
+   GLint img, row, col;
+
+   for (img = 0; img < depth; img++) {
+      for (row = 0; row < height; row++) {
+         GLfloat depthRow[MAX_WIDTH];
+         void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels,
+                                          width, height, format, type,
+                                          img, row, 0);
+         assert(dest);
+
+         for (col = 0; col < width; col++) {
+            texImage->FetchTexelf(texImage, col, row, img, depthRow + col);
+         }
+         _mesa_pack_depth_span(ctx, width, dest, type, depthRow, &ctx->Pack);
+      }
+   }
+}
+
+
+/**
+ * glGetTexImage for depth/stencil pixels.
+ */
+static void
+get_tex_depth_stencil(GLcontext *ctx, GLuint dimensions,
+                      GLenum format, GLenum type, GLvoid *pixels,
+                      const struct gl_texture_image *texImage)
+{
+   const GLint width = texImage->Width;
+   const GLint height = texImage->Height;
+   const GLint depth = texImage->Depth;
+   const GLuint *src = (const GLuint *) texImage->Data;
+   GLint img, row;
+
+   for (img = 0; img < depth; img++) {
+      for (row = 0; row < height; row++) {
+         void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels,
+                                          width, height, format, type,
+                                          img, row, 0);
+         _mesa_memcpy(dest, src, width * sizeof(GLuint));
+         if (ctx->Pack.SwapBytes) {
+            _mesa_swap4((GLuint *) dest, width);
+         }
+
+         src += width * row + width * height * img;
+      }
+   }
+}
+
+
+/**
+ * glGetTexImage for YCbCr pixels.
+ */
+static void
+get_tex_ycbcr(GLcontext *ctx, GLuint dimensions,
+              GLenum format, GLenum type, GLvoid *pixels,
+              const struct gl_texture_image *texImage)
+{
+   const GLint width = texImage->Width;
+   const GLint height = texImage->Height;
+   const GLint depth = texImage->Depth;
+   const GLint rowstride = texImage->RowStride;
+   const GLushort *src = (const GLushort *) texImage->Data;
+   GLint img, row;
+
+   for (img = 0; img < depth; img++) {
+      for (row = 0; row < height; row++) {
+         void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels,
+                                          width, height, format, type,
+                                          img, row, 0);
+         _mesa_memcpy(dest, src, width * sizeof(GLushort));
+
+         /* check for byte swapping */
+         if ((texImage->TexFormat == MESA_FORMAT_YCBCR
+              && type == GL_UNSIGNED_SHORT_8_8_REV_MESA) ||
+             (texImage->TexFormat == MESA_FORMAT_YCBCR_REV
+              && type == GL_UNSIGNED_SHORT_8_8_MESA)) {
+            if (!ctx->Pack.SwapBytes)
+               _mesa_swap2((GLushort *) dest, width);
+         }
+         else if (ctx->Pack.SwapBytes) {
+            _mesa_swap2((GLushort *) dest, width);
+         }
+
+         src += rowstride;
+      }
+   }
+}
+
+
+/**
+ * glGetTexImagefor sRGB pixels;
+ */
+static void
+get_tex_srgb(GLcontext *ctx, GLuint dimensions,
+             GLenum format, GLenum type, GLvoid *pixels,
+             const struct gl_texture_image *texImage)
+{
+   const GLint width = texImage->Width;
+   const GLint height = texImage->Height;
+   const GLint depth = texImage->Depth;
+   const GLbitfield transferOps = 0x0;
+   GLint img, row;
+
+   for (img = 0; img < depth; img++) {
+      for (row = 0; row < height; row++) {
+         void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels,
+                                          width, height, format, type,
+                                          img, row, 0);
+
+         GLfloat rgba[MAX_WIDTH][4];
+         GLint col;
+
+         /* convert row to RGBA format */
+         for (col = 0; col < width; col++) {
+            texImage->FetchTexelf(texImage, col, row, img, rgba[col]);
+            if (texImage->_BaseFormat == GL_LUMINANCE) {
+               rgba[col][RCOMP] = linear_to_nonlinear(rgba[col][RCOMP]);
+               rgba[col][GCOMP] = 0.0;
+               rgba[col][BCOMP] = 0.0;
+            }
+            else if (texImage->_BaseFormat == GL_LUMINANCE_ALPHA) {
+               rgba[col][RCOMP] = linear_to_nonlinear(rgba[col][RCOMP]);
+               rgba[col][GCOMP] = 0.0;
+               rgba[col][BCOMP] = 0.0;
+            }
+            else if (texImage->_BaseFormat == GL_RGB ||
+                     texImage->_BaseFormat == GL_RGBA) {
+               rgba[col][RCOMP] = linear_to_nonlinear(rgba[col][RCOMP]);
+               rgba[col][GCOMP] = linear_to_nonlinear(rgba[col][GCOMP]);
+               rgba[col][BCOMP] = linear_to_nonlinear(rgba[col][BCOMP]);
+            }
+         }
+         _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba,
+                                    format, type, dest,
+                                    &ctx->Pack, transferOps);
+      }
+   }
+}
+
+
+/**
+ * glGetTexImagefor RGBA, Luminance, etc. pixels.
+ * This is the slow way since we use texture sampling.
+ */
+static void
+get_tex_rgba(GLcontext *ctx, GLuint dimensions,
+             GLenum format, GLenum type, GLvoid *pixels,
+             const struct gl_texture_image *texImage)
+{
+   const GLint width = texImage->Width;
+   const GLint height = texImage->Height;
+   const GLint depth = texImage->Depth;
+   /* Normally, no pixel transfer ops are performed during glGetTexImage.
+    * The only possible exception is component clamping to [0,1].
+    */
+   GLbitfield transferOps = 0x0;
+   GLint img, row;
+
+   for (img = 0; img < depth; img++) {
+      for (row = 0; row < height; row++) {
+         void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels,
+                                          width, height, format, type,
+                                          img, row, 0);
+         GLfloat rgba[MAX_WIDTH][4];
+         GLint col;
+         GLenum dataType = _mesa_get_format_datatype(texImage->TexFormat);
+
+         /* clamp does not apply to GetTexImage (final conversion)?
+          * Looks like we need clamp though when going from format
+          * containing negative values to unsigned format.
+          */
+         if (format == GL_LUMINANCE || format == GL_LUMINANCE_ALPHA) {
+            transferOps |= IMAGE_CLAMP_BIT;
+         }
+         else if (!type_with_negative_values(type) &&
+                  (dataType == GL_FLOAT ||
+                   dataType == GL_SIGNED_NORMALIZED)) {
+            transferOps |= IMAGE_CLAMP_BIT;
+         }
+
+         for (col = 0; col < width; col++) {
+            texImage->FetchTexelf(texImage, col, row, img, rgba[col]);
+            if (texImage->_BaseFormat == GL_ALPHA) {
+               rgba[col][RCOMP] = 0.0F;
+               rgba[col][GCOMP] = 0.0F;
+               rgba[col][BCOMP] = 0.0F;
+            }
+            else if (texImage->_BaseFormat == GL_LUMINANCE) {
+               rgba[col][GCOMP] = 0.0F;
+               rgba[col][BCOMP] = 0.0F;
+               rgba[col][ACOMP] = 1.0F;
+            }
+            else if (texImage->_BaseFormat == GL_LUMINANCE_ALPHA) {
+               rgba[col][GCOMP] = 0.0F;
+               rgba[col][BCOMP] = 0.0F;
+            }
+            else if (texImage->_BaseFormat == GL_INTENSITY) {
+               rgba[col][GCOMP] = 0.0F;
+               rgba[col][BCOMP] = 0.0F;
+               rgba[col][ACOMP] = 1.0F;
+            }
+         }
+         _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba,
+                                    format, type, dest,
+                                    &ctx->Pack, transferOps);
+      }
+   }
+}
+
+
+/**
+ * Try to do glGetTexImage() with simple memcpy().
+ * \return GL_TRUE if done, GL_FALSE otherwise
+ */
+static GLboolean
+get_tex_memcpy(GLcontext *ctx, GLenum format, GLenum type, GLvoid *pixels,
+               const struct gl_texture_object *texObj,
+               const struct gl_texture_image *texImage)
+{
+   GLboolean memCopy = GL_FALSE;
+
+   /* Texture image should have been mapped already */
+   assert(texImage->Data);
+
+   /*
+    * Check if the src/dst formats are compatible.
+    * Also note that GL's pixel transfer ops don't apply to glGetTexImage()
+    * so we don't have to worry about those.
+    * XXX more format combinations could be supported here.
+    */
+   if ((texObj->Target == GL_TEXTURE_1D ||
+        texObj->Target == GL_TEXTURE_2D ||
+        texObj->Target == GL_TEXTURE_RECTANGLE ||
+        (texObj->Target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X &&
+         texObj->Target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z))) {
+      if (texImage->TexFormat == MESA_FORMAT_ARGB8888 &&
+          format == GL_BGRA &&
+          type == GL_UNSIGNED_BYTE &&
+          !ctx->Pack.SwapBytes &&
+          _mesa_little_endian()) {
+         memCopy = GL_TRUE;
+      }
+      else if (texImage->TexFormat == MESA_FORMAT_AL88 &&
+               format == GL_LUMINANCE_ALPHA &&
+               type == GL_UNSIGNED_BYTE &&
+               !ctx->Pack.SwapBytes &&
+               _mesa_little_endian()) {
+         memCopy = GL_TRUE;
+      }
+      else if (texImage->TexFormat == MESA_FORMAT_L8 &&
+               format == GL_LUMINANCE &&
+               type == GL_UNSIGNED_BYTE) {
+         memCopy = GL_TRUE;
+      }
+      else if (texImage->TexFormat == MESA_FORMAT_A8 &&
+               format == GL_ALPHA &&
+               type == GL_UNSIGNED_BYTE) {
+         memCopy = GL_TRUE;
+      }
+   }
+
+   if (memCopy) {
+      const GLuint bpp = _mesa_get_format_bytes(texImage->TexFormat);
+      const GLuint bytesPerRow = texImage->Width * bpp;
+      GLubyte *dst =
+         _mesa_image_address2d(&ctx->Pack, pixels, texImage->Width,
+                               texImage->Height, format, type, 0, 0);
+      const GLint dstRowStride =
+         _mesa_image_row_stride(&ctx->Pack, texImage->Width, format, type);
+      const GLubyte *src = texImage->Data;
+      const GLint srcRowStride = texImage->RowStride * bpp;
+      GLuint row;
+
+      if (bytesPerRow == dstRowStride && bytesPerRow == srcRowStride) {
+         memcpy(dst, src, bytesPerRow * texImage->Height);
+      }
+      else {
+         for (row = 0; row < texImage->Height; row++) {
+            memcpy(dst, src, bytesPerRow);
+            dst += dstRowStride;
+            src += srcRowStride;
+         }
+      }
+   }
+
+   return memCopy;
+}
+
+
 /**
  * This is the software fallback for Driver.GetTexImage().
  * All error checking will have been done before this routine is called.
+ * The texture image must be mapped.
  */
 void
 _mesa_get_teximage(GLcontext *ctx, GLenum target, GLint level,
@@ -117,7 +444,21 @@ _mesa_get_teximage(GLcontext *ctx, GLenum target, GLint level,
                    struct gl_texture_object *texObj,
                    struct gl_texture_image *texImage)
 {
-   const GLuint dimensions = (target == GL_TEXTURE_3D) ? 3 : 2;
+   GLuint dimensions;
+
+   /* If we get here, the texture image should be mapped */
+   assert(texImage->Data);
+
+   switch (target) {
+   case GL_TEXTURE_1D:
+      dimensions = 1;
+      break;
+   case GL_TEXTURE_3D:
+      dimensions = 3;
+      break;
+   default:
+      dimensions = 2;
+   }
 
    if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
       /* Packing texture image into a PBO.
@@ -130,8 +471,8 @@ _mesa_get_teximage(GLcontext *ctx, GLenum target, GLint level,
          ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
                                GL_WRITE_ONLY_ARB, ctx->Pack.BufferObj);
       if (!buf) {
-         /* buffer is already mapped - that's an error */
-         _mesa_error(ctx, GL_INVALID_OPERATION,"glGetTexImage(PBO is mapped)");
+         /* out of memory or other unexpected error */
+         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage(map PBO failed)");
          return;
       }
       /* <pixels> was an offset into the PBO.
@@ -139,164 +480,27 @@ _mesa_get_teximage(GLcontext *ctx, GLenum target, GLint level,
        */
       pixels = ADD_POINTERS(buf, pixels);
    }
-   else if (!pixels) {
-      /* not an error */
-      return;
-   }
 
-   {
-      const GLint width = texImage->Width;
-      const GLint height = texImage->Height;
-      const GLint depth = texImage->Depth;
-      GLint img, row;
-      for (img = 0; img < depth; img++) {
-         for (row = 0; row < height; row++) {
-            /* compute destination address in client memory */
-            GLvoid *dest = _mesa_image_address( dimensions, &ctx->Pack, pixels,
-                                                width, height, format, type,
-                                                img, row, 0);
-            assert(dest);
-
-            if (format == GL_COLOR_INDEX) {
-               GLuint indexRow[MAX_WIDTH];
-               GLint col;
-               /* Can't use FetchTexel here because that returns RGBA */
-               if (texImage->TexFormat->IndexBits == 8) {
-                  const GLubyte *src = (const GLubyte *) texImage->Data;
-                  src += width * (img * texImage->Height + row);
-                  for (col = 0; col < width; col++) {
-                     indexRow[col] = src[col];
-                  }
-               }
-               else if (texImage->TexFormat->IndexBits == 16) {
-                  const GLushort *src = (const GLushort *) texImage->Data;
-                  src += width * (img * texImage->Height + row);
-                  for (col = 0; col < width; col++) {
-                     indexRow[col] = src[col];
-                  }
-               }
-               else {
-                  _mesa_problem(ctx,
-                                "Color index problem in _mesa_GetTexImage");
-               }
-               _mesa_pack_index_span(ctx, width, type, dest,
-                                     indexRow, &ctx->Pack,
-                                     0 /* no image transfer */);
-            }
-            else if (format == GL_DEPTH_COMPONENT) {
-               GLfloat depthRow[MAX_WIDTH];
-               GLint col;
-               for (col = 0; col < width; col++) {
-                  (*texImage->FetchTexelf)(texImage, col, row, img,
-                                           depthRow + col);
-               }
-               _mesa_pack_depth_span(ctx, width, dest, type,
-                                     depthRow, &ctx->Pack);
-            }
-            else if (format == GL_DEPTH_STENCIL_EXT) {
-               /* XXX Note: we're bypassing texImage->FetchTexel()! */
-               const GLuint *src = (const GLuint *) texImage->Data;
-               src += width * row + width * height * img;
-               _mesa_memcpy(dest, src, width * sizeof(GLuint));
-               if (ctx->Pack.SwapBytes) {
-                  _mesa_swap4((GLuint *) dest, width);
-               }
-            }
-            else if (format == GL_YCBCR_MESA) {
-               /* No pixel transfer */
-               const GLint rowstride = texImage->RowStride;
-               MEMCPY(dest,
-                      (const GLushort *) texImage->Data + row * rowstride,
-                      width * sizeof(GLushort));
-               /* check for byte swapping */
-               if ((texImage->TexFormat->MesaFormat == MESA_FORMAT_YCBCR
-                    && type == GL_UNSIGNED_SHORT_8_8_REV_MESA) ||
-                   (texImage->TexFormat->MesaFormat == MESA_FORMAT_YCBCR_REV
-                    && type == GL_UNSIGNED_SHORT_8_8_MESA)) {
-                  if (!ctx->Pack.SwapBytes)
-                     _mesa_swap2((GLushort *) dest, width);
-               }
-               else if (ctx->Pack.SwapBytes) {
-                  _mesa_swap2((GLushort *) dest, width);
-               }
-            }
-#if FEATURE_EXT_texture_sRGB
-            else if (is_srgb_teximage(texImage)) {
-               /* special case this since need to backconvert values */
-               /* convert row to RGBA format */
-               GLfloat rgba[MAX_WIDTH][4];
-               GLint col;
-               GLbitfield transferOps = 0x0;
-
-               for (col = 0; col < width; col++) {
-                  (*texImage->FetchTexelf)(texImage, col, row, img, rgba[col]);
-                  if (texImage->_BaseFormat == GL_LUMINANCE) {
-                     rgba[col][RCOMP] = linear_to_nonlinear(rgba[col][RCOMP]);
-                     rgba[col][GCOMP] = 0.0;
-                     rgba[col][BCOMP] = 0.0;
-                  }
-                  else if (texImage->_BaseFormat == GL_LUMINANCE_ALPHA) {
-                     rgba[col][RCOMP] = linear_to_nonlinear(rgba[col][RCOMP]);
-                     rgba[col][GCOMP] = 0.0;
-                     rgba[col][BCOMP] = 0.0;
-                  }
-                  else if (texImage->_BaseFormat == GL_RGB ||
-                     texImage->_BaseFormat == GL_RGBA) {
-                     rgba[col][RCOMP] = linear_to_nonlinear(rgba[col][RCOMP]);
-                     rgba[col][GCOMP] = linear_to_nonlinear(rgba[col][GCOMP]);
-                     rgba[col][BCOMP] = linear_to_nonlinear(rgba[col][BCOMP]);
-                  }
-               }
-               _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba,
-                                          format, type, dest,
-                                          &ctx->Pack, transferOps);
-            }
-#endif /* FEATURE_EXT_texture_sRGB */
-            else {
-               /* general case:  convert row to RGBA format */
-               GLfloat rgba[MAX_WIDTH][4];
-               GLint col;
-               GLbitfield transferOps = 0x0;
-
-               /* clamp does not apply to GetTexImage (final conversion)?
-                * Looks like we need clamp though when going from format
-                * containing negative values to unsigned format.
-                */
-               if (format == GL_LUMINANCE || format == GL_LUMINANCE_ALPHA)
-                  transferOps |= IMAGE_CLAMP_BIT;
-               else if (!type_with_negative_values(type) &&
-                        (texImage->TexFormat->DataType == GL_FLOAT ||
-                         texImage->TexFormat->DataType == GL_SIGNED_NORMALIZED))
-                  transferOps |= IMAGE_CLAMP_BIT;
-
-               for (col = 0; col < width; col++) {
-                  (*texImage->FetchTexelf)(texImage, col, row, img, rgba[col]);
-                  if (texImage->_BaseFormat == GL_ALPHA) {
-                     rgba[col][RCOMP] = 0.0;
-                     rgba[col][GCOMP] = 0.0;
-                     rgba[col][BCOMP] = 0.0;
-                  }
-                  else if (texImage->_BaseFormat == GL_LUMINANCE) {
-                     rgba[col][GCOMP] = 0.0;
-                     rgba[col][BCOMP] = 0.0;
-                     rgba[col][ACOMP] = 1.0;
-                  }
-                  else if (texImage->_BaseFormat == GL_LUMINANCE_ALPHA) {
-                     rgba[col][GCOMP] = 0.0;
-                     rgba[col][BCOMP] = 0.0;
-                  }
-                  else if (texImage->_BaseFormat == GL_INTENSITY) {
-                     rgba[col][GCOMP] = 0.0;
-                     rgba[col][BCOMP] = 0.0;
-                     rgba[col][ACOMP] = 1.0;
-                  }
-               }
-               _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba,
-                                          format, type, dest,
-                                          &ctx->Pack, transferOps);
-            } /* format */
-         } /* row */
-      } /* img */
+   if (get_tex_memcpy(ctx, format, type, pixels, texObj, texImage)) {
+      /* all done */
+   }
+   else if (format == GL_COLOR_INDEX) {
+      get_tex_color_index(ctx, dimensions, format, type, pixels, texImage);
+   }
+   else if (format == GL_DEPTH_COMPONENT) {
+      get_tex_depth(ctx, dimensions, format, type, pixels, texImage);
+   }
+   else if (format == GL_DEPTH_STENCIL_EXT) {
+      get_tex_depth_stencil(ctx, dimensions, format, type, pixels, texImage);
+   }
+   else if (format == GL_YCBCR_MESA) {
+      get_tex_ycbcr(ctx, dimensions, format, type, pixels, texImage);
+   }
+   else if (_mesa_get_format_color_encoding(texImage->TexFormat) == GL_SRGB) {
+      get_tex_srgb(ctx, dimensions, format, type, pixels, texImage);
+   }
+   else {
+      get_tex_rgba(ctx, dimensions, format, type, pixels, texImage);
    }
 
    if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
@@ -317,40 +521,44 @@ _mesa_get_compressed_teximage(GLcontext *ctx, GLenum target, GLint level,
                               struct gl_texture_object *texObj,
                               struct gl_texture_image *texImage)
 {
-   GLuint size;
+   const GLuint row_stride = _mesa_format_row_stride(texImage->TexFormat,
+                                                     texImage->Width);
+   const GLuint row_stride_stored = _mesa_format_row_stride(texImage->TexFormat,
+                                                            texImage->RowStride);
+   GLuint i;
 
    if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
       /* pack texture image into a PBO */
-      GLubyte *buf;
-      if ((const GLubyte *) img + texImage->CompressedSize >
-          (const GLubyte *) ctx->Pack.BufferObj->Size) {
-         _mesa_error(ctx, GL_INVALID_OPERATION,
-                     "glGetCompressedTexImage(invalid PBO access)");
-         return;
-      }
-      buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
-                                              GL_WRITE_ONLY_ARB,
-                                              ctx->Pack.BufferObj);
+      GLubyte *buf = (GLubyte *)
+         ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
+                               GL_WRITE_ONLY_ARB, ctx->Pack.BufferObj);
       if (!buf) {
-         /* buffer is already mapped - that's an error */
-         _mesa_error(ctx, GL_INVALID_OPERATION,
-                     "glGetCompressedTexImage(PBO is mapped)");
+         /* out of memory or other unexpected error */
+         _mesa_error(ctx, GL_OUT_OF_MEMORY,
+                     "glGetCompresssedTexImage(map PBO failed)");
          return;
       }
       img = ADD_POINTERS(buf, img);
    }
-   else if (!img) {
-      /* not an error */
-      return;
-   }
 
-   /* don't use texImage->CompressedSize since that may be padded out */
-   size = _mesa_compressed_texture_size(ctx, texImage->Width, texImage->Height,
-                                        texImage->Depth,
-                                        texImage->TexFormat->MesaFormat);
+   /* no pixelstore or pixel transfer, but respect stride */
 
-   /* just memcpy, no pixelstore or pixel transfer */
-   _mesa_memcpy(img, texImage->Data, size);
+   if (row_stride == row_stride_stored) {
+      const GLuint size = _mesa_format_image_size(texImage->TexFormat,
+                                                  texImage->Width,
+                                                  texImage->Height,
+                                                  texImage->Depth);
+      _mesa_memcpy(img, texImage->Data, size);
+   }
+   else {
+      GLuint bw, bh;
+      _mesa_get_format_block_size(texImage->TexFormat, &bw, &bh);
+      for (i = 0; i < (texImage->Height + bh - 1) / bh; i++) {
+         memcpy((GLubyte *)img + i * row_stride,
+                (GLubyte *)texImage->Data + i * row_stride_stored,
+                row_stride);
+      }
+   }
 
    if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
       ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
@@ -368,10 +576,10 @@ static GLboolean
 getteximage_error_check(GLcontext *ctx, GLenum target, GLint level,
                         GLenum format, GLenum type, GLvoid *pixels )
 {
-   const struct gl_texture_unit *texUnit;
    struct gl_texture_object *texObj;
    struct gl_texture_image *texImage;
    const GLuint maxLevels = _mesa_max_texture_levels(ctx, target);
+   GLenum baseFormat;
 
    if (maxLevels == 0) {
       _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(target=0x%x)", target);
@@ -421,8 +629,7 @@ getteximage_error_check(GLcontext *ctx, GLenum target, GLint level,
       return GL_TRUE;
    }
 
-   texUnit = _mesa_get_current_tex_unit(ctx);
-   texObj = _mesa_select_tex_object(ctx, texUnit, target);
+   texObj = _mesa_get_current_tex_object(ctx, target);
 
    if (!texObj || _mesa_is_proxy_texture(target)) {
       _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(target)");
@@ -434,40 +641,42 @@ getteximage_error_check(GLcontext *ctx, GLenum target, GLint level,
       /* out of memory */
       return GL_TRUE;
    }
+
+   baseFormat = _mesa_get_format_base_format(texImage->TexFormat);
       
    /* Make sure the requested image format is compatible with the
     * texture's format.  Note that a color index texture can be converted
     * to RGBA so that combo is allowed.
     */
    if (_mesa_is_color_format(format)
-       && !_mesa_is_color_format(texImage->TexFormat->BaseFormat)
-       && !_mesa_is_index_format(texImage->TexFormat->BaseFormat)) {
+       && !_mesa_is_color_format(baseFormat)
+       && !_mesa_is_index_format(baseFormat)) {
       _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)");
       return GL_TRUE;
    }
    else if (_mesa_is_index_format(format)
-            && !_mesa_is_index_format(texImage->TexFormat->BaseFormat)) {
+            && !_mesa_is_index_format(baseFormat)) {
       _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)");
       return GL_TRUE;
    }
    else if (_mesa_is_depth_format(format)
-            && !_mesa_is_depth_format(texImage->TexFormat->BaseFormat)
-            && !_mesa_is_depthstencil_format(texImage->TexFormat->BaseFormat)) {
+            && !_mesa_is_depth_format(baseFormat)
+            && !_mesa_is_depthstencil_format(baseFormat)) {
       _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)");
       return GL_TRUE;
    }
    else if (_mesa_is_ycbcr_format(format)
-            && !_mesa_is_ycbcr_format(texImage->TexFormat->BaseFormat)) {
+            && !_mesa_is_ycbcr_format(baseFormat)) {
       _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)");
       return GL_TRUE;
    }
    else if (_mesa_is_depthstencil_format(format)
-            && !_mesa_is_depthstencil_format(texImage->TexFormat->BaseFormat)) {
+            && !_mesa_is_depthstencil_format(baseFormat)) {
       _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)");
       return GL_TRUE;
    }
    else if (_mesa_is_dudv_format(format)
-            && !_mesa_is_dudv_format(texImage->TexFormat->BaseFormat)) {
+            && !_mesa_is_dudv_format(baseFormat)) {
       _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)");
       return GL_TRUE;
    }
@@ -479,7 +688,14 @@ getteximage_error_check(GLcontext *ctx, GLenum target, GLint level,
                                      texImage->Height, texImage->Depth,
                                      format, type, pixels)) {
          _mesa_error(ctx, GL_INVALID_OPERATION,
-                     "glGetTexImage(invalid PBO access)");
+                     "glGetTexImage(out of bounds PBO write)");
+         return GL_TRUE;
+      }
+
+      /* PBO should not be mapped */
+      if (_mesa_bufferobj_mapped(ctx->Pack.BufferObj)) {
+         _mesa_error(ctx, GL_INVALID_OPERATION,
+                     "glGetTexImage(PBO is mapped)");
          return GL_TRUE;
       }
    }
@@ -502,8 +718,8 @@ void GLAPIENTRY
 _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
                    GLenum type, GLvoid *pixels )
 {
-   const struct gl_texture_unit *texUnit;
    struct gl_texture_object *texObj;
+   struct gl_texture_image *texImage;
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
 
@@ -511,15 +727,25 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
       return;
    }
 
-   texUnit = _mesa_get_current_tex_unit(ctx);
-   texObj = _mesa_select_tex_object(ctx, texUnit, target);
+   if (!_mesa_is_bufferobj(ctx->Pack.BufferObj) && !pixels) {
+      /* not an error, do nothing */
+      return;
+   }
+
+   texObj = _mesa_get_current_tex_object(ctx, target);
+   texImage = _mesa_select_tex_image(ctx, texObj, target, level);
+
+   if (MESA_VERBOSE & (VERBOSE_API | VERBOSE_TEXTURE)) {
+      _mesa_debug(ctx, "glGetTexImage(tex %u) format = %s, w=%d, h=%d,"
+                  " dstFmt=0x%x, dstType=0x%x\n",
+                  texObj->Name,
+                  _mesa_get_format_name(texImage->TexFormat),
+                  texImage->Width, texImage->Height,
+                  format, type);
+   }
 
    _mesa_lock_texture(ctx, texObj);
    {
-      struct gl_texture_image *texImage =
-         _mesa_select_tex_image(ctx, texObj, target, level);
-
-      /* typically, this will call _mesa_get_teximage() */
       ctx->Driver.GetTexImage(ctx, target, level, format, type, pixels,
                               texObj, texImage);
    }
@@ -527,55 +753,119 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
 }
 
 
+
+/**
+ * Do error checking for a glGetCompressedTexImage() call.
+ * \return GL_TRUE if any error, GL_FALSE if no errors.
+ */
+static GLboolean
+getcompressedteximage_error_check(GLcontext *ctx, GLenum target, GLint level,
+                                  GLvoid *img)
+{
+   struct gl_texture_object *texObj;
+   struct gl_texture_image *texImage;
+   const GLuint maxLevels = _mesa_max_texture_levels(ctx, target);
+
+   if (maxLevels == 0) {
+      _mesa_error(ctx, GL_INVALID_ENUM, "glGetCompressedTexImage(target=0x%x)",
+                  target);
+      return GL_TRUE;
+   }
+
+   if (level < 0 || level >= maxLevels) {
+      _mesa_error(ctx, GL_INVALID_VALUE,
+                  "glGetCompressedTexImageARB(bad level = %d)", level);
+      return GL_TRUE;
+   }
+
+   if (_mesa_is_proxy_texture(target)) {
+      _mesa_error(ctx, GL_INVALID_ENUM,
+                  "glGetCompressedTexImageARB(bad target = %s)",
+                  _mesa_lookup_enum_by_nr(target));
+      return GL_TRUE;
+   }
+
+   texObj = _mesa_get_current_tex_object(ctx, target);
+   if (!texObj) {
+      _mesa_error(ctx, GL_INVALID_ENUM, "glGetCompressedTexImageARB(target)");
+      return GL_TRUE;
+   }
+
+   texImage = _mesa_select_tex_image(ctx, texObj, target, level);
+
+   if (!texImage) {
+      /* probably invalid mipmap level */
+      _mesa_error(ctx, GL_INVALID_VALUE,
+                  "glGetCompressedTexImageARB(level)");
+      return GL_TRUE;
+   }
+
+   if (!_mesa_is_format_compressed(texImage->TexFormat)) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glGetCompressedTexImageARB(texture is not compressed)");
+      return GL_TRUE;
+   }
+
+   if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
+      GLuint compressedSize;
+
+      /* make sure PBO is not mapped */
+      if (_mesa_bufferobj_mapped(ctx->Pack.BufferObj)) {
+         _mesa_error(ctx, GL_INVALID_OPERATION,
+                     "glGetCompressedTexImage(PBO is mapped)");
+         return GL_TRUE;
+      }
+
+      compressedSize = _mesa_format_image_size(texImage->TexFormat,
+                                               texImage->Width,
+                                               texImage->Height,
+                                               texImage->Depth);
+
+      /* do bounds checking on PBO write */
+      if ((const GLubyte *) img + compressedSize >
+          (const GLubyte *) ctx->Pack.BufferObj->Size) {
+         _mesa_error(ctx, GL_INVALID_OPERATION,
+                     "glGetCompressedTexImage(out of bounds PBO write)");
+         return GL_TRUE;
+      }
+   }
+
+   return GL_FALSE;
+}
+
+
 void GLAPIENTRY
 _mesa_GetCompressedTexImageARB(GLenum target, GLint level, GLvoid *img)
 {
-   const struct gl_texture_unit *texUnit;
    struct gl_texture_object *texObj;
    struct gl_texture_image *texImage;
-   GLint maxLevels;
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
 
-   texUnit = _mesa_get_current_tex_unit(ctx);
-   texObj = _mesa_select_tex_object(ctx, texUnit, target);
-   if (!texObj) {
-      _mesa_error(ctx, GL_INVALID_ENUM, "glGetCompressedTexImageARB");
+   if (getcompressedteximage_error_check(ctx, target, level, img)) {
       return;
    }
 
-   maxLevels = _mesa_max_texture_levels(ctx, target);
-   ASSERT(maxLevels > 0); /* 0 indicates bad target, caught above */
-
-   if (level < 0 || level >= maxLevels) {
-      _mesa_error(ctx, GL_INVALID_VALUE, "glGetCompressedTexImageARB(level)");
+   if (_mesa_is_bufferobj(ctx->Pack.BufferObj) && !img) {
+      /* not an error, do nothing */
       return;
    }
 
-   if (_mesa_is_proxy_texture(target)) {
-      _mesa_error(ctx, GL_INVALID_ENUM, "glGetCompressedTexImageARB(target)");
-      return;
+   texObj = _mesa_get_current_tex_object(ctx, target);
+   texImage = _mesa_select_tex_image(ctx, texObj, target, level);
+
+   if (MESA_VERBOSE & (VERBOSE_API | VERBOSE_TEXTURE)) {
+      _mesa_debug(ctx,
+                  "glGetCompressedTexImage(tex %u) format = %s, w=%d, h=%d\n",
+                  texObj->Name,
+                  _mesa_get_format_name(texImage->TexFormat),
+                  texImage->Width, texImage->Height);
    }
 
    _mesa_lock_texture(ctx, texObj);
    {
-      texImage = _mesa_select_tex_image(ctx, texObj, target, level);
-      if (texImage) {
-         if (texImage->IsCompressed) {
-            /* this typically calls _mesa_get_compressed_teximage() */
-            ctx->Driver.GetCompressedTexImage(ctx, target, level, img,
-                                              texObj, texImage);
-         }
-         else {
-            _mesa_error(ctx, GL_INVALID_OPERATION,
-                        "glGetCompressedTexImageARB");
-         }
-      }
-      else {
-         /* probably invalid mipmap level */
-         _mesa_error(ctx, GL_INVALID_VALUE,
-                     "glGetCompressedTexImageARB(level)");
-      }
+      ctx->Driver.GetCompressedTexImage(ctx, target, level, img,
+                                        texObj, texImage);
    }
    _mesa_unlock_texture(ctx, texObj);
 }
index 465da6b0469abd36a7676d08a0320e49e2e91975..b946f3c69d7e846f9dc6c09ac60b377d4c82d62f 100644 (file)
@@ -43,7 +43,7 @@
 #include "macros.h"
 #include "state.h"
 #include "texcompress.h"
-#include "texformat.h"
+#include "texfetch.h"
 #include "teximage.h"
 #include "texstate.h"
 #include "texstore.h"
@@ -82,63 +82,6 @@ _mesa_free_texmemory(void *m)
 }
 
 
-
-
-#if 0
-static void PrintTexture(GLcontext *ctx, const struct gl_texture_image *img)
-{
-#if CHAN_TYPE != GL_UNSIGNED_BYTE
-   _mesa_problem(NULL, "PrintTexture not supported");
-#else
-   GLuint i, j, c;
-   const GLubyte *data = (const GLubyte *) img->Data;
-
-   if (!data) {
-      _mesa_printf("No texture data\n");
-      return;
-   }
-
-   switch (img->Format) {
-      case GL_ALPHA:
-      case GL_LUMINANCE:
-      case GL_INTENSITY:
-      case GL_COLOR_INDEX:
-         c = 1;
-         break;
-      case GL_LUMINANCE_ALPHA:
-         c = 2;
-         break;
-      case GL_RGB:
-         c = 3;
-         break;
-      case GL_RGBA:
-         c = 4;
-         break;
-      default:
-         _mesa_problem(NULL, "error in PrintTexture\n");
-         return;
-   }
-
-   for (i = 0; i < img->Height; i++) {
-      for (j = 0; j < img->Width; j++) {
-         if (c==1)
-            _mesa_printf("%02x  ", data[0]);
-         else if (c==2)
-            _mesa_printf("%02x%02x  ", data[0], data[1]);
-         else if (c==3)
-            _mesa_printf("%02x%02x%02x  ", data[0], data[1], data[2]);
-         else if (c==4)
-            _mesa_printf("%02x%02x%02x%02x  ", data[0], data[1], data[2], data[3]);
-         data += (img->RowStride - img->Width) * c;
-      }
-      /* XXX use img->ImageStride here */
-      _mesa_printf("\n");
-   }
-#endif
-}
-#endif
-
-
 /*
  * Compute floor(log_base_2(n)).
  * If n < 0 return -1.
@@ -639,6 +582,17 @@ _mesa_select_tex_object(GLcontext *ctx, const struct gl_texture_unit *texUnit,
 }
 
 
+/**
+ * Return pointer to texture object for given target on current texture unit.
+ */
+struct gl_texture_object *
+_mesa_get_current_tex_object(GLcontext *ctx, GLenum target)
+{
+   struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
+   return _mesa_select_tex_object(ctx, texUnit, target);
+}
+
+
 /**
  * Get a texture image pointer from a texture object, given a texture
  * target and mipmap level.  The target and level parameters should
@@ -900,11 +854,9 @@ clear_teximage_fields(struct gl_texture_image *img)
    img->HeightLog2 = 0;
    img->DepthLog2 = 0;
    img->Data = NULL;
-   img->TexFormat = &_mesa_null_texformat;
+   img->TexFormat = MESA_FORMAT_NONE;
    img->FetchTexelc = NULL;
    img->FetchTexelf = NULL;
-   img->IsCompressed = 0;
-   img->CompressedSize = 0;
 }
 
 
@@ -967,9 +919,6 @@ _mesa_init_teximage_fields(GLcontext *ctx, GLenum target,
 
    img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2);
 
-   img->IsCompressed = GL_FALSE;
-   img->CompressedSize = 0;
-
    if ((width == 1 || _mesa_is_pow_two(img->Width2)) &&
        (height == 1 || _mesa_is_pow_two(img->Height2)) &&
        (depth == 1 || _mesa_is_pow_two(img->Depth2)))
@@ -1002,6 +951,9 @@ _mesa_init_teximage_fields(GLcontext *ctx, GLenum target,
       img->HeightScale = (GLfloat) img->Height;
       img->DepthScale = (GLfloat) img->Depth;
    }
+
+   img->FetchTexelc = NULL;
+   img->FetchTexelf = NULL;
 }
 
 
@@ -1315,8 +1267,8 @@ texture_error_check( GLcontext *ctx, GLenum target,
    if (_mesa_base_tex_format(ctx, internalFormat) < 0) {
       if (!isProxy) {
          _mesa_error(ctx, GL_INVALID_VALUE,
-                     "glTexImage%dD(internalFormat=0x%x)",
-                     dimensions, internalFormat);
+                     "glTexImage%dD(internalFormat=%s)",
+                     dimensions, _mesa_lookup_enum_by_nr(internalFormat));
       }
       return GL_TRUE;
    }
@@ -1528,6 +1480,11 @@ subtexture_error_check( GLcontext *ctx, GLuint dimensions,
    return GL_FALSE;
 }
 
+
+/**
+ * Do second part of glTexSubImage which depends on the destination texture.
+ * \return GL_TRUE if error recorded, GL_FALSE otherwise
+ */
 static GLboolean
 subtexture_error_check2( GLcontext *ctx, GLuint dimensions,
                         GLenum target, GLint level,
@@ -1575,41 +1532,35 @@ subtexture_error_check2( GLcontext *ctx, GLuint dimensions,
       }
    }
 
-#if FEATURE_EXT_texture_sRGB
-   if (destTex->InternalFormat == GL_COMPRESSED_SRGB_S3TC_DXT1_EXT ||
-       destTex->InternalFormat == GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT ||
-       destTex->InternalFormat == GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT ||
-       destTex->InternalFormat == GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT) {
-      if ((width & 0x3) || (height & 0x3) ||
-          (xoffset & 0x3) || (yoffset & 0x3))
-         _mesa_error(ctx, GL_INVALID_OPERATION,
-                     "glTexSubImage%dD(size or offset not multiple of 4)",
-                     dimensions);
-      return GL_TRUE;
-   }
-#endif
+   if (_mesa_is_format_compressed(destTex->TexFormat)) {
+      GLuint bw, bh;
 
-   if (destTex->IsCompressed) {
       if (!target_can_be_compressed(ctx, target)) {
          _mesa_error(ctx, GL_INVALID_ENUM,
-                     "glTexSubImage%D(target)", dimensions);
+                     "glTexSubImage%D(target=%s)", dimensions,
+                     _mesa_lookup_enum_by_nr(target));
          return GL_TRUE;
       }
-      /* offset must be multiple of 4 */
-      if ((xoffset & 3) || (yoffset & 3)) {
+
+      /* do tests which depend on compression block size */
+      _mesa_get_format_block_size(destTex->TexFormat, &bw, &bh);
+
+      /* offset must be multiple of block size */
+      if ((xoffset % bw != 0) || (yoffset % bh != 0)) {
          _mesa_error(ctx, GL_INVALID_OPERATION,
-                     "glTexSubImage%D(xoffset or yoffset)", dimensions);
+                     "glTexSubImage%D(xoffset = %d, yoffset = %d)",
+                     dimensions, xoffset, yoffset);
          return GL_TRUE;
       }
-      /* size must be multiple of 4 or equal to whole texture size */
-      if ((width & 3) && (GLuint) width != destTex->Width) {
+      /* size must be multiple of bw by bh or equal to whole texture size */
+      if ((width % bw != 0) && (GLuint) width != destTex->Width) {
          _mesa_error(ctx, GL_INVALID_OPERATION,
-                     "glTexSubImage%D(width)", dimensions);
+                     "glTexSubImage%D(width = %d)", dimensions, width);
          return GL_TRUE;
       }         
-      if ((height & 3) && (GLuint) height != destTex->Height) {
+      if ((height % bh != 0) && (GLuint) height != destTex->Height) {
          _mesa_error(ctx, GL_INVALID_OPERATION,
-                     "glTexSubImage%D(width)", dimensions);
+                     "glTexSubImage%D(height = %d)", dimensions, height);
          return GL_TRUE;
       }         
    }
@@ -1951,7 +1902,7 @@ copytexsubimage_error_check2( GLcontext *ctx, GLuint dimensions,
       }
    }
 
-   if (teximage->IsCompressed) {
+   if (_mesa_is_format_compressed(teximage->TexFormat)) {
       if (!target_can_be_compressed(ctx, target)) {
          _mesa_error(ctx, GL_INVALID_ENUM,
                      "glCopyTexSubImage%d(target)", dimensions);
@@ -2084,7 +2035,9 @@ check_gen_mipmap(GLcontext *ctx, GLenum target,
                  struct gl_texture_object *texObj, GLint level)
 {
    ASSERT(target != GL_TEXTURE_CUBE_MAP);
-   if (texObj->GenerateMipmap && level == texObj->BaseLevel) {
+   if (texObj->GenerateMipmap &&
+       level == texObj->BaseLevel &&
+       level < texObj->MaxLevel) {
       ASSERT(ctx->Driver.GenerateMipmap);
       ctx->Driver.GenerateMipmap(ctx, target, texObj);
    }
@@ -2164,7 +2117,6 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat,
 
    if (target == GL_TEXTURE_1D) {
       /* non-proxy target */
-      struct gl_texture_unit *texUnit;
       struct gl_texture_object *texObj;
       struct gl_texture_image *texImage;
       const GLuint face = _mesa_tex_target_to_face(target);
@@ -2177,8 +2129,7 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat,
       if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
         _mesa_update_state(ctx);
 
-      texUnit = _mesa_get_current_tex_unit(ctx);
-      texObj = _mesa_select_tex_object(ctx, texUnit, target);
+      texObj = _mesa_get_current_tex_object(ctx, target);
       _mesa_lock_texture(ctx, texObj);
       {
         texImage = _mesa_get_tex_image(ctx, texObj, target, level);
@@ -2197,6 +2148,12 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat,
                                        postConvWidth, 1, 1,
                                        border, internalFormat);
 
+            /* Choose actual texture format */
+            texImage->TexFormat =
+               ctx->Driver.ChooseTextureFormat(ctx, internalFormat,
+                                               format, type);
+            ASSERT(texImage->TexFormat != MESA_FORMAT_NONE);
+
             /* Give the texture to the driver.  <pixels> may be null. */
             ASSERT(ctx->Driver.TexImage1D);
             ctx->Driver.TexImage1D(ctx, target, level, internalFormat,
@@ -2205,6 +2162,8 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat,
 
             ASSERT(texImage->TexFormat);
 
+            _mesa_set_fetch_functions(texImage, 1);
+
             check_gen_mipmap(ctx, target, texObj, level);
 
             update_fbo_texture(ctx, texObj, face, level);
@@ -2232,8 +2191,8 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat,
          _mesa_init_teximage_fields(ctx, target, texImage,
                                     postConvWidth, 1, 1,
                                     border, internalFormat);
-         texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
-                                          internalFormat, format, type);
+         texImage->TexFormat =
+            ctx->Driver.ChooseTextureFormat(ctx, internalFormat, format, type);
       }
    }
    else {
@@ -2278,7 +2237,6 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
        (ctx->Extensions.MESA_texture_array &&
         target == GL_TEXTURE_1D_ARRAY_EXT)) {
       /* non-proxy target */
-      struct gl_texture_unit *texUnit;
       struct gl_texture_object *texObj;
       struct gl_texture_image *texImage;
       const GLuint face = _mesa_tex_target_to_face(target);
@@ -2292,8 +2250,7 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
       if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
         _mesa_update_state(ctx);
 
-      texUnit = _mesa_get_current_tex_unit(ctx);
-      texObj = _mesa_select_tex_object(ctx, texUnit, target);
+      texObj = _mesa_get_current_tex_object(ctx, target);
       _mesa_lock_texture(ctx, texObj);
       {
         texImage = _mesa_get_tex_image(ctx, texObj, target, level);
@@ -2311,6 +2268,12 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
                                        postConvWidth, postConvHeight, 1,
                                        border, internalFormat);
 
+            /* Choose actual texture format */
+            texImage->TexFormat =
+               ctx->Driver.ChooseTextureFormat(ctx, internalFormat,
+                                               format, type);
+            ASSERT(texImage->TexFormat != MESA_FORMAT_NONE);
+
             /* Give the texture to the driver.  <pixels> may be null. */
             ASSERT(ctx->Driver.TexImage2D);
             ctx->Driver.TexImage2D(ctx, target, level, internalFormat,
@@ -2319,6 +2282,8 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
 
             ASSERT(texImage->TexFormat);
 
+            _mesa_set_fetch_functions(texImage, 2);
+
             check_gen_mipmap(ctx, target, texObj, level);
 
             update_fbo_texture(ctx, texObj, face, level);
@@ -2352,8 +2317,8 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
          _mesa_init_teximage_fields(ctx, target, texImage,
                                     postConvWidth, postConvHeight, 1,
                                     border, internalFormat);
-         texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
-                                          internalFormat, format, type);
+         texImage->TexFormat =
+            ctx->Driver.ChooseTextureFormat(ctx, internalFormat, format, type);
       }
    }
    else {
@@ -2389,7 +2354,6 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat,
        (ctx->Extensions.MESA_texture_array &&
         target == GL_TEXTURE_2D_ARRAY_EXT)) {
       /* non-proxy target */
-      struct gl_texture_unit *texUnit;
       struct gl_texture_object *texObj;
       struct gl_texture_image *texImage;
       const GLuint face = _mesa_tex_target_to_face(target);
@@ -2402,8 +2366,7 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat,
       if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
         _mesa_update_state(ctx);
 
-      texUnit = _mesa_get_current_tex_unit(ctx);
-      texObj = _mesa_select_tex_object(ctx, texUnit, target);
+      texObj = _mesa_get_current_tex_object(ctx, target);
       _mesa_lock_texture(ctx, texObj);
       {
         texImage = _mesa_get_tex_image(ctx, texObj, target, level);
@@ -2421,6 +2384,12 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat,
                                        width, height, depth,
                                        border, internalFormat);
 
+            /* Choose actual texture format */
+            texImage->TexFormat =
+               ctx->Driver.ChooseTextureFormat(ctx, internalFormat,
+                                               format, type);
+            ASSERT(texImage->TexFormat != MESA_FORMAT_NONE);
+
             /* Give the texture to the driver.  <pixels> may be null. */
             ASSERT(ctx->Driver.TexImage3D);
             ctx->Driver.TexImage3D(ctx, target, level, internalFormat,
@@ -2429,6 +2398,8 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat,
 
             ASSERT(texImage->TexFormat);
 
+            _mesa_set_fetch_functions(texImage, 3);
+
             check_gen_mipmap(ctx, target, texObj, level);
 
             update_fbo_texture(ctx, texObj, face, level);
@@ -2456,8 +2427,8 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat,
          /* no error, set the tex image parameters */
          _mesa_init_teximage_fields(ctx, target, texImage, width, height,
                                     depth, border, internalFormat);
-         texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
-                                          internalFormat, format, type);
+         texImage->TexFormat =
+            ctx->Driver.ChooseTextureFormat(ctx, internalFormat, format, type);
       }
    }
    else {
@@ -2486,9 +2457,8 @@ _mesa_TexSubImage1D( GLenum target, GLint level,
                      const GLvoid *pixels )
 {
    GLsizei postConvWidth = width;
-   struct gl_texture_unit *texUnit;
    struct gl_texture_object *texObj;
-   struct gl_texture_image *texImage = NULL;
+   struct gl_texture_image *texImage;
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
 
@@ -2514,8 +2484,7 @@ _mesa_TexSubImage1D( GLenum target, GLint level,
    }
 
 
-   texUnit = _mesa_get_current_tex_unit(ctx);
-   texObj = _mesa_select_tex_object(ctx, texUnit, target);
+   texObj = _mesa_get_current_tex_object(ctx, target);
    assert(texObj);
 
    _mesa_lock_texture(ctx, texObj);
@@ -2553,7 +2522,6 @@ _mesa_TexSubImage2D( GLenum target, GLint level,
                      const GLvoid *pixels )
 {
    GLsizei postConvWidth = width, postConvHeight = height;
-   struct gl_texture_unit *texUnit;
    struct gl_texture_object *texObj;
    struct gl_texture_image *texImage;
    GET_CURRENT_CONTEXT(ctx);
@@ -2582,8 +2550,7 @@ _mesa_TexSubImage2D( GLenum target, GLint level,
       return;   /* error was detected */
    }
 
-   texUnit = _mesa_get_current_tex_unit(ctx);
-   texObj = _mesa_select_tex_object(ctx, texUnit, target);
+   texObj = _mesa_get_current_tex_object(ctx, target);
 
    _mesa_lock_texture(ctx, texObj);
    {
@@ -2621,7 +2588,6 @@ _mesa_TexSubImage3D( GLenum target, GLint level,
                      GLenum format, GLenum type,
                      const GLvoid *pixels )
 {
-   struct gl_texture_unit *texUnit;
    struct gl_texture_object *texObj;
    struct gl_texture_image *texImage;
    GET_CURRENT_CONTEXT(ctx);
@@ -2642,8 +2608,7 @@ _mesa_TexSubImage3D( GLenum target, GLint level,
       return;   /* error was detected */
    }
 
-   texUnit = _mesa_get_current_tex_unit(ctx);
-   texObj = _mesa_select_tex_object(ctx, texUnit, target);
+   texObj = _mesa_get_current_tex_object(ctx, target);
 
    _mesa_lock_texture(ctx, texObj);
    {
@@ -2684,7 +2649,6 @@ _mesa_CopyTexImage1D( GLenum target, GLint level,
                       GLint x, GLint y,
                       GLsizei width, GLint border )
 {
-   struct gl_texture_unit *texUnit;
    struct gl_texture_object *texObj;
    struct gl_texture_image *texImage;
    GLsizei postConvWidth = width;
@@ -2711,8 +2675,7 @@ _mesa_CopyTexImage1D( GLenum target, GLint level,
                                postConvWidth, 1, border))
       return;
 
-   texUnit = _mesa_get_current_tex_unit(ctx);
-   texObj = _mesa_select_tex_object(ctx, texUnit, target);
+   texObj = _mesa_get_current_tex_object(ctx, target);
 
    _mesa_lock_texture(ctx, texObj);
    {
@@ -2731,12 +2694,20 @@ _mesa_CopyTexImage1D( GLenum target, GLint level,
          _mesa_init_teximage_fields(ctx, target, texImage, postConvWidth, 1, 1,
                                     border, internalFormat);
 
+         /* Choose actual texture format */
+         texImage->TexFormat =
+            ctx->Driver.ChooseTextureFormat(ctx, internalFormat,
+                                            GL_NONE, GL_NONE);
+         ASSERT(texImage->TexFormat != MESA_FORMAT_NONE);
+
          ASSERT(ctx->Driver.CopyTexImage1D);
          ctx->Driver.CopyTexImage1D(ctx, target, level, internalFormat,
                                     x, y, width, border);
 
          ASSERT(texImage->TexFormat);
 
+         _mesa_set_fetch_functions(texImage, 1);
+
          check_gen_mipmap(ctx, target, texObj, level);
 
          update_fbo_texture(ctx, texObj, face, level);
@@ -2756,7 +2727,6 @@ _mesa_CopyTexImage2D( GLenum target, GLint level, GLenum internalFormat,
                       GLint x, GLint y, GLsizei width, GLsizei height,
                       GLint border )
 {
-   struct gl_texture_unit *texUnit;
    struct gl_texture_object *texObj;
    struct gl_texture_image *texImage;
    GLsizei postConvWidth = width, postConvHeight = height;
@@ -2784,8 +2754,7 @@ _mesa_CopyTexImage2D( GLenum target, GLint level, GLenum internalFormat,
                                postConvWidth, postConvHeight, border))
       return;
 
-   texUnit = _mesa_get_current_tex_unit(ctx);
-   texObj = _mesa_select_tex_object(ctx, texUnit, target);
+   texObj = _mesa_get_current_tex_object(ctx, target);
 
    _mesa_lock_texture(ctx, texObj);
    {
@@ -2806,12 +2775,20 @@ _mesa_CopyTexImage2D( GLenum target, GLint level, GLenum internalFormat,
                                     postConvWidth, postConvHeight, 1,
                                     border, internalFormat);
 
+         /* Choose actual texture format */
+         texImage->TexFormat =
+            ctx->Driver.ChooseTextureFormat(ctx, internalFormat,
+                                            GL_NONE, GL_NONE);
+         ASSERT(texImage->TexFormat != MESA_FORMAT_NONE);
+
          ASSERT(ctx->Driver.CopyTexImage2D);
          ctx->Driver.CopyTexImage2D(ctx, target, level, internalFormat,
                                     x, y, width, height, border);
 
          ASSERT(texImage->TexFormat);
 
+         _mesa_set_fetch_functions(texImage, 2);
+
          check_gen_mipmap(ctx, target, texObj, level);
 
          update_fbo_texture(ctx, texObj, face, level);
@@ -2829,7 +2806,6 @@ void GLAPIENTRY
 _mesa_CopyTexSubImage1D( GLenum target, GLint level,
                          GLint xoffset, GLint x, GLint y, GLsizei width )
 {
-   struct gl_texture_unit *texUnit;
    struct gl_texture_object *texObj;
    struct gl_texture_image *texImage;
    GLsizei postConvWidth = width;
@@ -2850,8 +2826,7 @@ _mesa_CopyTexSubImage1D( GLenum target, GLint level,
    if (copytexsubimage_error_check1(ctx, 1, target, level))
       return;
 
-   texUnit = _mesa_get_current_tex_unit(ctx);
-   texObj = _mesa_select_tex_object(ctx, texUnit, target);
+   texObj = _mesa_get_current_tex_object(ctx, target);
 
    _mesa_lock_texture(ctx, texObj);
    {
@@ -2894,7 +2869,6 @@ _mesa_CopyTexSubImage2D( GLenum target, GLint level,
                          GLint xoffset, GLint yoffset,
                          GLint x, GLint y, GLsizei width, GLsizei height )
 {
-   struct gl_texture_unit *texUnit;
    struct gl_texture_object *texObj;
    struct gl_texture_image *texImage;
    GLsizei postConvWidth = width, postConvHeight = height;
@@ -2912,8 +2886,7 @@ _mesa_CopyTexSubImage2D( GLenum target, GLint level,
    if (copytexsubimage_error_check1(ctx, 2, target, level))
       return;
 
-   texUnit = _mesa_get_current_tex_unit(ctx);
-   texObj = _mesa_select_tex_object(ctx, texUnit, target);
+   texObj = _mesa_get_current_tex_object(ctx, target);
 
    _mesa_lock_texture(ctx, texObj);
    {
@@ -2959,7 +2932,6 @@ _mesa_CopyTexSubImage3D( GLenum target, GLint level,
                          GLint xoffset, GLint yoffset, GLint zoffset,
                          GLint x, GLint y, GLsizei width, GLsizei height )
 {
-   struct gl_texture_unit *texUnit;
    struct gl_texture_object *texObj;
    struct gl_texture_image *texImage;
    GLsizei postConvWidth = width, postConvHeight = height;
@@ -2977,8 +2949,7 @@ _mesa_CopyTexSubImage3D( GLenum target, GLint level,
    if (copytexsubimage_error_check1(ctx, 3, target, level))
       return;
 
-   texUnit = _mesa_get_current_tex_unit(ctx);
-   texObj = _mesa_select_tex_object(ctx, texUnit, target);
+   texObj = _mesa_get_current_tex_object(ctx, target);
 
    _mesa_lock_texture(ctx, texObj);
    {
@@ -3026,6 +2997,29 @@ _mesa_CopyTexSubImage3D( GLenum target, GLint level,
 /**********************************************************************/
 
 
+/**
+ * Return expected size of a compressed texture.
+ */
+static GLuint
+compressed_tex_size(GLsizei width, GLsizei height, GLsizei depth,
+                    GLenum glformat)
+{
+   gl_format mesaFormat = _mesa_glenum_to_compressed_format(glformat);
+   return _mesa_format_image_size(mesaFormat, width, height, depth);
+}
+
+
+/*
+ * Return compressed texture block size, in pixels.
+ */
+static void
+get_compressed_block_size(GLenum glformat, GLuint *bw, GLuint *bh)
+{
+   gl_format mesaFormat = _mesa_glenum_to_compressed_format(glformat);
+   _mesa_get_format_block_size(mesaFormat, bw, bh);
+}
+
+
 /**
  * Error checking for glCompressedTexImage[123]D().
  * \return error code or GL_NO_ERROR.
@@ -3108,8 +3102,7 @@ compressed_texture_error_check(GLcontext *ctx, GLint dimensions,
    if (level < 0 || level >= maxLevels)
       return GL_INVALID_VALUE;
 
-   expectedSize = _mesa_compressed_texture_size_glenum(ctx, width, height,
-                                                       depth, internalFormat);
+   expectedSize = compressed_tex_size(width, height, depth, internalFormat);
    if (expectedSize != imageSize)
       return GL_INVALID_VALUE;
 
@@ -3142,6 +3135,7 @@ compressed_subtexture_error_check(GLcontext *ctx, GLint dimensions,
                                   GLenum format, GLsizei imageSize)
 {
    GLint expectedSize, maxLevels = 0, maxTextureSize;
+   GLuint bw, bh;
    (void) zoffset;
 
    if (dimensions == 1) {
@@ -3191,20 +3185,21 @@ compressed_subtexture_error_check(GLcontext *ctx, GLint dimensions,
    if (level < 0 || level >= maxLevels)
       return GL_INVALID_VALUE;
 
-   /* XXX these tests are specific to the compressed format.
-    * this code should be generalized in some way.
+   /*
+    * do checks which depend on compression block size
     */
-   if ((xoffset & 3) != 0 || (yoffset & 3) != 0)
+   get_compressed_block_size(format, &bw, &bh);
+
+   if ((xoffset % bw != 0) || (yoffset % bh != 0))
       return GL_INVALID_VALUE;
 
-   if ((width & 3) != 0 && width != 2 && width != 1)
+   if ((width % bw != 0) && width != 2 && width != 1)
       return GL_INVALID_VALUE;
 
-   if ((height & 3) != 0 && height != 2 && height != 1)
+   if ((height % bh != 0) && height != 2 && height != 1)
       return GL_INVALID_VALUE;
 
-   expectedSize = _mesa_compressed_texture_size_glenum(ctx, width, height,
-                                                       depth, format);
+   expectedSize = compressed_tex_size(width, height, depth, format);
    if (expectedSize != imageSize)
       return GL_INVALID_VALUE;
 
@@ -3212,6 +3207,55 @@ compressed_subtexture_error_check(GLcontext *ctx, GLint dimensions,
 }
 
 
+/**
+ * Do second part of glCompressedTexSubImage error checking.
+ * \return GL_TRUE if error found, GL_FALSE otherwise.
+ */
+static GLboolean
+compressed_subtexture_error_check2(GLcontext *ctx, GLuint dims,
+                                   GLsizei width, GLsizei height,
+                                   GLsizei depth, GLenum format,
+                                   struct gl_texture_image *texImage)
+{
+
+   if ((GLint) format != texImage->InternalFormat) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glCompressedTexSubImage%uD(format=0x%x)", dims, format);
+      return GL_TRUE;
+   }
+
+   if (((width == 1 || width == 2) &&
+        (GLuint) width != texImage->Width) ||
+       (width > texImage->Width)) {
+      _mesa_error(ctx, GL_INVALID_VALUE,
+                  "glCompressedTexSubImage%uD(width=%d)", dims, width);
+      return GL_TRUE;
+   }
+
+   if (dims >= 2) {
+      if (((height == 1 || height == 2) &&
+           (GLuint) height != texImage->Height) ||
+          (height > texImage->Height)) {
+         _mesa_error(ctx, GL_INVALID_VALUE,
+                     "glCompressedTexSubImage%uD(height=%d)", dims, height);
+         return GL_TRUE;
+      }
+   }
+
+   if (dims >= 3) {
+      if (((depth == 1 || depth == 2) &&
+           (GLuint) depth != texImage->Depth) ||
+          (depth > texImage->Depth)) {
+         _mesa_error(ctx, GL_INVALID_VALUE,
+                     "glCompressedTexSubImage%uD(depth=%d)", dims, depth);
+         return GL_TRUE;
+      }
+   }
+
+   return GL_FALSE;
+}
+
+
 
 void GLAPIENTRY
 _mesa_CompressedTexImage1DARB(GLenum target, GLint level,
@@ -3230,7 +3274,6 @@ _mesa_CompressedTexImage1DARB(GLenum target, GLint level,
 
    if (target == GL_TEXTURE_1D) {
       /* non-proxy target */
-      struct gl_texture_unit *texUnit;
       struct gl_texture_object *texObj;
       struct gl_texture_image *texImage;
       GLenum error = compressed_texture_error_check(ctx, 1, target, level,
@@ -3240,8 +3283,7 @@ _mesa_CompressedTexImage1DARB(GLenum target, GLint level,
          return;
       }
 
-      texUnit = _mesa_get_current_tex_unit(ctx);
-      texObj = _mesa_select_tex_object(ctx, texUnit, target);
+      texObj = _mesa_get_current_tex_object(ctx, target);
 
       _mesa_lock_texture(ctx, texObj);
       {
@@ -3258,12 +3300,20 @@ _mesa_CompressedTexImage1DARB(GLenum target, GLint level,
             _mesa_init_teximage_fields(ctx, target, texImage, width, 1, 1,
                                        border, internalFormat);
 
+            /* Choose actual texture format */
+            texImage->TexFormat =
+               ctx->Driver.ChooseTextureFormat(ctx, internalFormat,
+                                               GL_NONE, GL_NONE);
+            ASSERT(texImage->TexFormat != MESA_FORMAT_NONE);
+
             ASSERT(ctx->Driver.CompressedTexImage1D);
             ctx->Driver.CompressedTexImage1D(ctx, target, level,
                                              internalFormat, width, border,
                                              imageSize, data,
                                              texObj, texImage);
 
+            _mesa_set_fetch_functions(texImage, 1);
+
             check_gen_mipmap(ctx, target, texObj, level);
 
             /* state update */
@@ -3292,11 +3342,10 @@ _mesa_CompressedTexImage1DARB(GLenum target, GLint level,
       }
       else {
          /* store the teximage parameters */
-         struct gl_texture_unit *texUnit;
          struct gl_texture_object *texObj;
          struct gl_texture_image *texImage;
-         texUnit = _mesa_get_current_tex_unit(ctx);
-        texObj = _mesa_select_tex_object(ctx, texUnit, target);
+
+         texObj = _mesa_get_current_tex_object(ctx, target);
 
         _mesa_lock_texture(ctx, texObj);
         {
@@ -3334,9 +3383,9 @@ _mesa_CompressedTexImage2DARB(GLenum target, GLint level,
         target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
         target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB)) {
       /* non-proxy target */
-      struct gl_texture_unit *texUnit;
       struct gl_texture_object *texObj;
       struct gl_texture_image *texImage;
+
       GLenum error = compressed_texture_error_check(ctx, 2, target, level,
                           internalFormat, width, height, 1, border, imageSize);
       if (error) {
@@ -3344,8 +3393,7 @@ _mesa_CompressedTexImage2DARB(GLenum target, GLint level,
          return;
       }
 
-      texUnit = _mesa_get_current_tex_unit(ctx);
-      texObj = _mesa_select_tex_object(ctx, texUnit, target);
+      texObj = _mesa_get_current_tex_object(ctx, target);
 
       _mesa_lock_texture(ctx, texObj);
       {
@@ -3362,12 +3410,20 @@ _mesa_CompressedTexImage2DARB(GLenum target, GLint level,
             _mesa_init_teximage_fields(ctx, target, texImage, width, height, 1,
                                        border, internalFormat);
 
+            /* Choose actual texture format */
+            texImage->TexFormat =
+               ctx->Driver.ChooseTextureFormat(ctx, internalFormat,
+                                               GL_NONE, GL_NONE);
+            ASSERT(texImage->TexFormat != MESA_FORMAT_NONE);
+
             ASSERT(ctx->Driver.CompressedTexImage2D);
             ctx->Driver.CompressedTexImage2D(ctx, target, level,
                                              internalFormat, width, height,
                                              border, imageSize, data,
                                              texObj, texImage);
 
+            _mesa_set_fetch_functions(texImage, 2);
+
             check_gen_mipmap(ctx, target, texObj, level);
 
             /* state update */
@@ -3398,11 +3454,10 @@ _mesa_CompressedTexImage2DARB(GLenum target, GLint level,
       }
       else {
          /* store the teximage parameters */
-         struct gl_texture_unit *texUnit;
          struct gl_texture_object *texObj;
          struct gl_texture_image *texImage;
-         texUnit = _mesa_get_current_tex_unit(ctx);
-        texObj = _mesa_select_tex_object(ctx, texUnit, target);
+
+         texObj = _mesa_get_current_tex_object(ctx, target);
 
         _mesa_lock_texture(ctx, texObj);
         {
@@ -3437,7 +3492,6 @@ _mesa_CompressedTexImage3DARB(GLenum target, GLint level,
 
    if (target == GL_TEXTURE_3D) {
       /* non-proxy target */
-      struct gl_texture_unit *texUnit;
       struct gl_texture_object *texObj;
       struct gl_texture_image *texImage;
       GLenum error = compressed_texture_error_check(ctx, 3, target, level,
@@ -3447,8 +3501,8 @@ _mesa_CompressedTexImage3DARB(GLenum target, GLint level,
          return;
       }
 
-      texUnit = _mesa_get_current_tex_unit(ctx);
-      texObj = _mesa_select_tex_object(ctx, texUnit, target);
+      texObj = _mesa_get_current_tex_object(ctx, target);
+
       _mesa_lock_texture(ctx, texObj);
       {
         texImage = _mesa_get_tex_image(ctx, texObj, target, level);
@@ -3465,6 +3519,12 @@ _mesa_CompressedTexImage3DARB(GLenum target, GLint level,
                                        width, height, depth,
                                        border, internalFormat);
 
+            /* Choose actual texture format */
+            texImage->TexFormat =
+               ctx->Driver.ChooseTextureFormat(ctx, internalFormat,
+                                               GL_NONE, GL_NONE);
+            ASSERT(texImage->TexFormat != MESA_FORMAT_NONE);
+
             ASSERT(ctx->Driver.CompressedTexImage3D);
             ctx->Driver.CompressedTexImage3D(ctx, target, level,
                                              internalFormat,
@@ -3472,6 +3532,8 @@ _mesa_CompressedTexImage3DARB(GLenum target, GLint level,
                                              border, imageSize, data,
                                              texObj, texImage);
 
+            _mesa_set_fetch_functions(texImage, 3);
+
             check_gen_mipmap(ctx, target, texObj, level);
 
             /* state update */
@@ -3500,11 +3562,11 @@ _mesa_CompressedTexImage3DARB(GLenum target, GLint level,
       }
       else {
          /* store the teximage parameters */
-         struct gl_texture_unit *texUnit;
          struct gl_texture_object *texObj;
          struct gl_texture_image *texImage;
-         texUnit = _mesa_get_current_tex_unit(ctx);
-        texObj = _mesa_select_tex_object(ctx, texUnit, target);
+
+         texObj = _mesa_get_current_tex_object(ctx, target);
+
         _mesa_lock_texture(ctx, texObj);
         {
            texImage = _mesa_select_tex_image(ctx, texObj, target, level);
@@ -3521,50 +3583,71 @@ _mesa_CompressedTexImage3DARB(GLenum target, GLint level,
 }
 
 
-void GLAPIENTRY
-_mesa_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
-                                 GLsizei width, GLenum format,
-                                 GLsizei imageSize, const GLvoid *data)
+/**
+ * Common helper for glCompressedTexSubImage1/2/3D().
+ */
+static void
+compressed_tex_sub_image(GLuint dims, GLenum target, GLint level,
+                         GLint xoffset, GLint yoffset, GLint zoffset,
+                         GLsizei width, GLsizei height, GLsizei depth,
+                         GLenum format, GLsizei imageSize, const GLvoid *data)
 {
-   struct gl_texture_unit *texUnit;
    struct gl_texture_object *texObj;
    struct gl_texture_image *texImage;
    GLenum error;
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
 
-   error = compressed_subtexture_error_check(ctx, 1, target, level,
+   error = compressed_subtexture_error_check(ctx, dims, target, level,
                                              xoffset, 0, 0, /* pos */
-                                             width, 1, 1,   /* size */
+                                             width, height, depth,   /* size */
                                              format, imageSize);
    if (error) {
-      _mesa_error(ctx, error, "glCompressedTexSubImage1D");
+      _mesa_error(ctx, error, "glCompressedTexSubImage%uD", dims);
       return;
    }
 
-   texUnit = _mesa_get_current_tex_unit(ctx);
-   texObj = _mesa_select_tex_object(ctx, texUnit, target);
+   texObj = _mesa_get_current_tex_object(ctx, target);
 
    _mesa_lock_texture(ctx, texObj);
    {
       texImage = _mesa_select_tex_image(ctx, texObj, target, level);
       assert(texImage);
 
-      if ((GLint) format != texImage->InternalFormat) {
-        _mesa_error(ctx, GL_INVALID_OPERATION,
-                    "glCompressedTexSubImage1D(format)");
-      }
-      else if ((width == 1 || width == 2) &&
-               (GLuint) width != texImage->Width) {
-        _mesa_error(ctx, GL_INVALID_VALUE,
-                     "glCompressedTexSubImage1D(width)");
+      if (compressed_subtexture_error_check2(ctx, dims, width, height, depth,
+                                             format, texImage)) {
+         /* error was recorded */
       }
-      else if (width > 0) {
-         if (ctx->Driver.CompressedTexSubImage1D) {
-            ctx->Driver.CompressedTexSubImage1D(ctx, target, level,
-                                                xoffset, width,
-                                                format, imageSize, data,
-                                                texObj, texImage);
+      else if (width > 0 && height > 0 && depth > 0) {
+         switch (dims) {
+         case 1:
+            if (ctx->Driver.CompressedTexSubImage1D) {
+               ctx->Driver.CompressedTexSubImage1D(ctx, target, level,
+                                                   xoffset, width,
+                                                   format, imageSize, data,
+                                                   texObj, texImage);
+            }
+            break;
+         case 2:
+            if (ctx->Driver.CompressedTexSubImage2D) {
+               ctx->Driver.CompressedTexSubImage2D(ctx, target, level,
+                                                   xoffset, yoffset,
+                                                   width, height,
+                                                   format, imageSize, data,
+                                                   texObj, texImage);
+            }
+            break;
+         case 3:
+            if (ctx->Driver.CompressedTexSubImage3D) {
+               ctx->Driver.CompressedTexSubImage3D(ctx, target, level,
+                                                   xoffset, yoffset, zoffset,
+                                                   width, height, depth,
+                                                   format, imageSize, data,
+                                                   texObj, texImage);
+            }
+            break;
+         default:
+            ;
          }
 
          check_gen_mipmap(ctx, target, texObj, level);
@@ -3576,61 +3659,24 @@ _mesa_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
 }
 
 
+void GLAPIENTRY
+_mesa_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
+                                 GLsizei width, GLenum format,
+                                 GLsizei imageSize, const GLvoid *data)
+{
+   compressed_tex_sub_image(1, target, level, xoffset, 0, 0, width, 1, 1,
+                            format, imageSize, data);
+}
+
+
 void GLAPIENTRY
 _mesa_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
                                  GLint yoffset, GLsizei width, GLsizei height,
                                  GLenum format, GLsizei imageSize,
                                  const GLvoid *data)
 {
-   struct gl_texture_unit *texUnit;
-   struct gl_texture_object *texObj;
-   struct gl_texture_image *texImage;
-   GLenum error;
-   GET_CURRENT_CONTEXT(ctx);
-   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
-
-   error = compressed_subtexture_error_check(ctx, 2, target, level,
-                                             xoffset, yoffset, 0, /* pos */
-                                             width, height, 1,    /* size */
-                                             format, imageSize);
-   if (error) {
-      /* XXX proxy target? */
-      _mesa_error(ctx, error, "glCompressedTexSubImage2D");
-      return;
-   }
-
-   texUnit = _mesa_get_current_tex_unit(ctx);
-   texObj = _mesa_select_tex_object(ctx, texUnit, target);
-
-   _mesa_lock_texture(ctx, texObj);
-   {
-      texImage = _mesa_select_tex_image(ctx, texObj, target, level);
-      assert(texImage);
-
-      if ((GLint) format != texImage->InternalFormat) {
-        _mesa_error(ctx, GL_INVALID_OPERATION,
-                    "glCompressedTexSubImage2D(format)");
-      }
-      else if (((width == 1 || width == 2)
-                && (GLuint) width != texImage->Width) ||
-               ((height == 1 || height == 2)
-                && (GLuint) height != texImage->Height)) {
-        _mesa_error(ctx, GL_INVALID_VALUE, "glCompressedTexSubImage2D(size)");
-      }
-      else if (width > 0 && height > 0) {
-         if (ctx->Driver.CompressedTexSubImage2D) {
-            ctx->Driver.CompressedTexSubImage2D(ctx, target, level,
-                                               xoffset, yoffset, width, height,
-                                               format, imageSize, data,
-                                               texObj, texImage);
-         }
-
-         check_gen_mipmap(ctx, target, texObj, level);
-
-         ctx->NewState |= _NEW_TEXTURE;
-      }
-   }
-   _mesa_unlock_texture(ctx, texObj);
+   compressed_tex_sub_image(2, target, level, xoffset, yoffset, 0,
+                            width, height, 1, format, imageSize, data);
 }
 
 
@@ -3640,57 +3686,8 @@ _mesa_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
                                  GLsizei height, GLsizei depth, GLenum format,
                                  GLsizei imageSize, const GLvoid *data)
 {
-   struct gl_texture_unit *texUnit;
-   struct gl_texture_object *texObj;
-   struct gl_texture_image *texImage;
-   GLenum error;
-   GET_CURRENT_CONTEXT(ctx);
-   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
-
-   error = compressed_subtexture_error_check(ctx, 3, target, level,
-                                             xoffset, yoffset, zoffset,/*pos*/
-                                             width, height, depth, /*size*/
-                                             format, imageSize);
-   if (error) {
-      _mesa_error(ctx, error, "glCompressedTexSubImage3D");
-      return;
-   }
-
-   texUnit = _mesa_get_current_tex_unit(ctx);
-   texObj = _mesa_select_tex_object(ctx, texUnit, target);
-
-   _mesa_lock_texture(ctx, texObj);
-   {
-      texImage = _mesa_select_tex_image(ctx, texObj, target, level);
-      assert(texImage);
-
-      if ((GLint) format != texImage->InternalFormat) {
-        _mesa_error(ctx, GL_INVALID_OPERATION,
-                    "glCompressedTexSubImage3D(format)");
-      }
-      else if (((width == 1 || width == 2)
-                && (GLuint) width != texImage->Width) ||
-               ((height == 1 || height == 2)
-                && (GLuint) height != texImage->Height) ||
-               ((depth == 1 || depth == 2)
-                && (GLuint) depth != texImage->Depth)) {
-        _mesa_error(ctx, GL_INVALID_VALUE, "glCompressedTexSubImage3D(size)");
-      }
-      else if (width > 0 && height > 0 && depth > 0) {
-         if (ctx->Driver.CompressedTexSubImage3D) {
-            ctx->Driver.CompressedTexSubImage3D(ctx, target, level,
-                                               xoffset, yoffset, zoffset,
-                                               width, height, depth,
-                                               format, imageSize, data,
-                                               texObj, texImage);
-         }
-
-         check_gen_mipmap(ctx, target, texObj, level);
-
-         ctx->NewState |= _NEW_TEXTURE;
-      }
-   }
-   _mesa_unlock_texture(ctx, texObj);
+   compressed_tex_sub_image(3, target, level, xoffset, yoffset, zoffset,
+                            width, height, depth, format, imageSize, data);
 }
 
 
index 094177da79d2ef6efd6c1259fdf304510647a2df..97c901831902b421f926b0559af18a1837f07bff 100644 (file)
@@ -86,6 +86,9 @@ extern struct gl_texture_object *
 _mesa_select_tex_object(GLcontext *ctx, const struct gl_texture_unit *texUnit,
                         GLenum target);
 
+extern struct gl_texture_object *
+_mesa_get_current_tex_object(GLcontext *ctx, GLenum target);
+
 
 extern struct gl_texture_image *
 _mesa_select_tex_image(GLcontext *ctx, const struct gl_texture_object *texObj,
index 8fd5eaa266142bec6be22adbd7e76ccb159ebc49..7f0a246025ab1d7319b93f5eb423aa460c13375d 100644 (file)
@@ -33,6 +33,7 @@
 #include "context.h"
 #include "enums.h"
 #include "fbobject.h"
+#include "formats.h"
 #include "hash.h"
 #include "imports.h"
 #include "macros.h"
@@ -227,10 +228,10 @@ _mesa_copy_texture_object( struct gl_texture_object *dest,
    dest->Target = src->Target;
    dest->Name = src->Name;
    dest->Priority = src->Priority;
-   dest->BorderColor[0] = src->BorderColor[0];
-   dest->BorderColor[1] = src->BorderColor[1];
-   dest->BorderColor[2] = src->BorderColor[2];
-   dest->BorderColor[3] = src->BorderColor[3];
+   dest->BorderColor.f[0] = src->BorderColor.f[0];
+   dest->BorderColor.f[1] = src->BorderColor.f[1];
+   dest->BorderColor.f[2] = src->BorderColor.f[2];
+   dest->BorderColor.f[3] = src->BorderColor.f[3];
    dest->WrapS = src->WrapS;
    dest->WrapT = src->WrapT;
    dest->WrapR = src->WrapR;
@@ -414,7 +415,7 @@ _mesa_test_texobj_completeness( const GLcontext *ctx,
    /* Detect cases where the application set the base level to an invalid
     * value.
     */
-   if ((baseLevel < 0) || (baseLevel > MAX_TEXTURE_LEVELS)) {
+   if ((baseLevel < 0) || (baseLevel >= MAX_TEXTURE_LEVELS)) {
       char s[100];
       _mesa_sprintf(s, "base level = %d is invalid", baseLevel);
       incomplete(t, s);
@@ -740,6 +741,10 @@ _mesa_get_fallback_texture(GLcontext *ctx)
       _mesa_init_teximage_fields(ctx, GL_TEXTURE_2D, texImage,
                                     8, 8, 1, 0, GL_RGBA); 
 
+      texImage->TexFormat =
+         ctx->Driver.ChooseTextureFormat(ctx, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE);
+      ASSERT(texImage->TexFormat != MESA_FORMAT_NONE);
+
       /* set image data */
       ctx->Driver.TexImage2D(ctx, GL_TEXTURE_2D, 0, GL_RGBA,
                              8, 8, 0,
@@ -935,7 +940,8 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *textures)
 /**
  * Convert a GL texture target enum such as GL_TEXTURE_2D or GL_TEXTURE_3D
  * into the corresponding Mesa texture target index.
- * Return -1 if target is invalid.
+ * Note that proxy targets are not valid here.
+ * \return TEXTURE_x_INDEX or -1 if target is invalid
  */
 static GLint
 target_enum_to_index(GLenum target)
@@ -1098,8 +1104,6 @@ _mesa_PrioritizeTextures( GLsizei n, const GLuint *texName,
          struct gl_texture_object *t = _mesa_lookup_texture(ctx, texName[i]);
          if (t) {
             t->Priority = CLAMP( priorities[i], 0.0F, 1.0F );
-           if (ctx->Driver.PrioritizeTexture)
-              ctx->Driver.PrioritizeTexture( ctx, t, t->Priority );
          }
       }
    }
index b2fbe2205ba591aa2c81f8f20b03d556c66938d4..d917e21e744a3b76d5dfb6e8bfb29c870691ec2f 100644 (file)
 
 
 #include "main/glheader.h"
+#include "main/colormac.h"
 #include "main/context.h"
 #include "main/enums.h"
-#include "main/colormac.h"
+#include "main/formats.h"
 #include "main/macros.h"
 #include "main/texcompress.h"
 #include "main/texparam.h"
@@ -77,15 +78,19 @@ validate_texture_wrap_mode(GLcontext * ctx, GLenum target, GLenum wrap)
 
 /**
  * Get current texture object for given target.
- * Return NULL if any error.
+ * Return NULL if any error (and record the error).
+ * Note that this is different from _mesa_select_tex_object() in that proxy
+ * targets are not accepted.
+ * Only the glGetTexLevelParameter() functions accept proxy targets.
  */
 static struct gl_texture_object *
-get_texobj(GLcontext *ctx, GLenum target)
+get_texobj(GLcontext *ctx, GLenum target, GLboolean get)
 {
    struct gl_texture_unit *texUnit;
 
    if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureImageUnits) {
-      _mesa_error(ctx, GL_INVALID_OPERATION, "glTexParameter(current unit)");
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "gl%sTexParameter(current unit)", get ? "Get" : "");
       return NULL;
    }
 
@@ -122,7 +127,8 @@ get_texobj(GLcontext *ctx, GLenum target)
       ;
    }
 
-   _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(target)");
+   _mesa_error(ctx, GL_INVALID_ENUM,
+                  "gl%sTexParameter(target)", get ? "Get" : "");
    return NULL;
 }
 
@@ -505,10 +511,10 @@ set_tex_parameterf(GLcontext *ctx,
 
    case GL_TEXTURE_BORDER_COLOR:
       flush(ctx, texObj);
-      texObj->BorderColor[RCOMP] = params[0];
-      texObj->BorderColor[GCOMP] = params[1];
-      texObj->BorderColor[BCOMP] = params[2];
-      texObj->BorderColor[ACOMP] = params[3];
+      texObj->BorderColor.f[RCOMP] = params[0];
+      texObj->BorderColor.f[GCOMP] = params[1];
+      texObj->BorderColor.f[BCOMP] = params[2];
+      texObj->BorderColor.f[ACOMP] = params[3];
       return GL_TRUE;
 
    default:
@@ -526,7 +532,7 @@ _mesa_TexParameterf(GLenum target, GLenum pname, GLfloat param)
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
-   texObj = get_texobj(ctx, target);
+   texObj = get_texobj(ctx, target, GL_FALSE);
    if (!texObj)
       return;
 
@@ -544,13 +550,20 @@ _mesa_TexParameterf(GLenum target, GLenum pname, GLfloat param)
    case GL_DEPTH_TEXTURE_MODE_ARB:
       {
          /* convert float param to int */
-         GLint p = (GLint) param;
-         need_update = set_tex_parameteri(ctx, texObj, pname, &p);
+         GLint p[4];
+         p[0] = (GLint) param;
+         p[1] = p[2] = p[3] = 0;
+         need_update = set_tex_parameteri(ctx, texObj, pname, p);
       }
       break;
    default:
-      /* this will generate an error if pname is illegal */
-      need_update = set_tex_parameterf(ctx, texObj, pname, &param);
+      {
+         /* this will generate an error if pname is illegal */
+         GLfloat p[4];
+         p[0] = param;
+         p[1] = p[2] = p[3] = 0.0F;
+         need_update = set_tex_parameterf(ctx, texObj, pname, p);
+      }
    }
 
    if (ctx->Driver.TexParameter && need_update) {
@@ -567,7 +580,7 @@ _mesa_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params)
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
-   texObj = get_texobj(ctx, target);
+   texObj = get_texobj(ctx, target, GL_FALSE);
    if (!texObj)
       return;
 
@@ -585,8 +598,10 @@ _mesa_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params)
    case GL_DEPTH_TEXTURE_MODE_ARB:
       {
          /* convert float param to int */
-         GLint p = (GLint) params[0];
-         need_update = set_tex_parameteri(ctx, texObj, pname, &p);
+         GLint p[4];
+         p[0] = (GLint) params[0];
+         p[1] = p[2] = p[3] = 0;
+         need_update = set_tex_parameteri(ctx, texObj, pname, p);
       }
       break;
 
@@ -599,7 +614,7 @@ _mesa_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params)
          iparams[1] = (GLint) params[1];
          iparams[2] = (GLint) params[2];
          iparams[3] = (GLint) params[3];
-         need_update = set_tex_parameteri(ctx, target, iparams);
+         need_update = set_tex_parameteri(ctx, texObj, pname, iparams);
       }
       break;
 #endif
@@ -623,7 +638,7 @@ _mesa_TexParameteri(GLenum target, GLenum pname, GLint param)
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
-   texObj = get_texobj(ctx, target);
+   texObj = get_texobj(ctx, target, GL_FALSE);
    if (!texObj)
       return;
 
@@ -635,14 +650,21 @@ _mesa_TexParameteri(GLenum target, GLenum pname, GLint param)
    case GL_TEXTURE_LOD_BIAS:
    case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB:
       {
-         GLfloat fparam = (GLfloat) param;
+         GLfloat fparam[4];
+         fparam[0] = (GLfloat) param;
+         fparam[1] = fparam[2] = fparam[3] = 0.0F;
          /* convert int param to float */
-         need_update = set_tex_parameterf(ctx, texObj, pname, &fparam);
+         need_update = set_tex_parameterf(ctx, texObj, pname, fparam);
       }
       break;
    default:
       /* this will generate an error if pname is illegal */
-      need_update = set_tex_parameteri(ctx, texObj, pname, &param);
+      {
+         GLint iparam[4];
+         iparam[0] = param;
+         iparam[1] = iparam[2] = iparam[3] = 0;
+         need_update = set_tex_parameteri(ctx, texObj, pname, iparam);
+      }
    }
 
    if (ctx->Driver.TexParameter && need_update) {
@@ -660,7 +682,7 @@ _mesa_TexParameteriv(GLenum target, GLenum pname, const GLint *params)
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
-   texObj = get_texobj(ctx, target);
+   texObj = get_texobj(ctx, target, GL_FALSE);
    if (!texObj)
       return;
 
@@ -684,8 +706,10 @@ _mesa_TexParameteriv(GLenum target, GLenum pname, const GLint *params)
    case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB:
       {
          /* convert int param to float */
-         GLfloat fparam = (GLfloat) params[0];
-         need_update = set_tex_parameterf(ctx, texObj, pname, &fparam);
+         GLfloat fparams[4];
+         fparams[0] = (GLfloat) params[0];
+         fparams[1] = fparams[2] = fparams[3] = 0.0F;
+         need_update = set_tex_parameterf(ctx, texObj, pname, fparams);
       }
       break;
    default:
@@ -707,6 +731,68 @@ _mesa_TexParameteriv(GLenum target, GLenum pname, const GLint *params)
 }
 
 
+/**
+ * Set tex parameter to integer value(s).  Primarily intended to set
+ * integer-valued texture border color (for integer-valued textures).
+ * New in GL 3.0.
+ */
+void GLAPIENTRY
+_mesa_TexParameterIiv(GLenum target, GLenum pname, const GLint *params)
+{
+   struct gl_texture_object *texObj;
+   GET_CURRENT_CONTEXT(ctx);
+   ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+   texObj = get_texobj(ctx, target, GL_FALSE);
+   if (!texObj)
+      return;
+
+   switch (pname) {
+   case GL_TEXTURE_BORDER_COLOR:
+      FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+      /* set the integer-valued border color */
+      COPY_4V(texObj->BorderColor.i, params);
+      break;
+   default:
+      _mesa_TexParameteriv(target, pname, params);
+      break;
+   }
+   /* XXX no driver hook for TexParameterIiv() yet */
+}
+
+
+/**
+ * Set tex parameter to unsigned integer value(s).  Primarily intended to set
+ * uint-valued texture border color (for integer-valued textures).
+ * New in GL 3.0
+ */
+void GLAPIENTRY
+_mesa_TexParameterIuiv(GLenum target, GLenum pname, const GLuint *params)
+{
+   struct gl_texture_object *texObj;
+   GET_CURRENT_CONTEXT(ctx);
+   ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+   texObj = get_texobj(ctx, target, GL_FALSE);
+   if (!texObj)
+      return;
+
+   switch (pname) {
+   case GL_TEXTURE_BORDER_COLOR:
+      FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+      /* set the unsigned integer-valued border color */
+      COPY_4V(texObj->BorderColor.ui, params);
+      break;
+   default:
+      _mesa_TexParameteriv(target, pname, (const GLint *) params);
+      break;
+   }
+   /* XXX no driver hook for TexParameterIuiv() yet */
+}
+
+
+
+
 void GLAPIENTRY
 _mesa_GetTexLevelParameterfv( GLenum target, GLint level,
                               GLenum pname, GLfloat *params )
@@ -726,6 +812,7 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
    const struct gl_texture_image *img = NULL;
    GLboolean isProxy;
    GLint maxLevels;
+   gl_format texFormat;
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
@@ -763,6 +850,8 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
       goto out;
    }
 
+   texFormat = img->TexFormat;
+
    isProxy = _mesa_is_proxy_texture(target);
 
    switch (pname) {
@@ -776,26 +865,23 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
          *params = img->Depth;
          break;
       case GL_TEXTURE_INTERNAL_FORMAT:
-         *params = img->InternalFormat;
+         if (_mesa_is_format_compressed(img->TexFormat)) {
+            /* need to return the actual compressed format */
+            *params = _mesa_compressed_format_to_glenum(ctx, img->TexFormat);
+         }
+         else {
+            /* return the user's requested internal format */
+            *params = img->InternalFormat;
+         }
          break;
       case GL_TEXTURE_BORDER:
          *params = img->Border;
          break;
       case GL_TEXTURE_RED_SIZE:
-         if (img->_BaseFormat == GL_RGB || img->_BaseFormat == GL_RGBA)
-            *params = img->TexFormat->RedBits;
-         else
-            *params = 0;
-         break;
       case GL_TEXTURE_GREEN_SIZE:
-         if (img->_BaseFormat == GL_RGB || img->_BaseFormat == GL_RGBA)
-            *params = img->TexFormat->GreenBits;
-         else
-            *params = 0;
-         break;
       case GL_TEXTURE_BLUE_SIZE:
          if (img->_BaseFormat == GL_RGB || img->_BaseFormat == GL_RGBA)
-            *params = img->TexFormat->BlueBits;
+            *params = _mesa_get_format_bits(texFormat, pname);
          else
             *params = 0;
          break;
@@ -803,36 +889,44 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
          if (img->_BaseFormat == GL_ALPHA ||
              img->_BaseFormat == GL_LUMINANCE_ALPHA ||
              img->_BaseFormat == GL_RGBA)
-            *params = img->TexFormat->AlphaBits;
+            *params = _mesa_get_format_bits(texFormat, pname);
          else
             *params = 0;
          break;
       case GL_TEXTURE_INTENSITY_SIZE:
          if (img->_BaseFormat != GL_INTENSITY)
             *params = 0;
-         else if (img->TexFormat->IntensityBits > 0)
-            *params = img->TexFormat->IntensityBits;
-         else /* intensity probably stored as rgb texture */
-            *params = MIN2(img->TexFormat->RedBits, img->TexFormat->GreenBits);
+         else {
+            *params = _mesa_get_format_bits(texFormat, pname);
+            if (*params == 0) {
+               /* intensity probably stored as rgb texture */
+               *params = MIN2(_mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE),
+                              _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE));
+            }
+         }
          break;
       case GL_TEXTURE_LUMINANCE_SIZE:
          if (img->_BaseFormat != GL_LUMINANCE &&
              img->_BaseFormat != GL_LUMINANCE_ALPHA)
             *params = 0;
-         else if (img->TexFormat->LuminanceBits > 0)
-            *params = img->TexFormat->LuminanceBits;
-         else /* luminance probably stored as rgb texture */
-            *params = MIN2(img->TexFormat->RedBits, img->TexFormat->GreenBits);
+         else {
+            *params = _mesa_get_format_bits(texFormat, pname);
+            if (*params == 0) {
+               /* luminance probably stored as rgb texture */
+               *params = MIN2(_mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE),
+                              _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE));
+            }
+         }
          break;
       case GL_TEXTURE_INDEX_SIZE_EXT:
          if (img->_BaseFormat == GL_COLOR_INDEX)
-            *params = img->TexFormat->IndexBits;
+            *params = _mesa_get_format_bits(texFormat, pname);
          else
             *params = 0;
          break;
       case GL_TEXTURE_DEPTH_SIZE_ARB:
          if (ctx->Extensions.ARB_depth_texture)
-            *params = img->TexFormat->DepthBits;
+            *params = _mesa_get_format_bits(texFormat, pname);
          else
             _mesa_error(ctx, GL_INVALID_ENUM,
                         "glGetTexLevelParameter[if]v(pname)");
@@ -840,7 +934,7 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
       case GL_TEXTURE_STENCIL_SIZE_EXT:
          if (ctx->Extensions.EXT_packed_depth_stencil ||
              ctx->Extensions.ARB_framebuffer_object) {
-            *params = img->TexFormat->StencilBits;
+            *params = _mesa_get_format_bits(texFormat, pname);
          }
          else {
             _mesa_error(ctx, GL_INVALID_ENUM,
@@ -850,13 +944,9 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
 
       /* GL_ARB_texture_compression */
       case GL_TEXTURE_COMPRESSED_IMAGE_SIZE:
-        if (img->IsCompressed && !isProxy) {
-           /* Don't use ctx->Driver.CompressedTextureSize() since that
-            * may returned a padded hardware size.
-            */
-           *params = _mesa_compressed_texture_size(ctx, img->Width,
-                                                   img->Height, img->Depth,
-                                                   img->TexFormat->MesaFormat);
+        if (_mesa_is_format_compressed(img->TexFormat) && !isProxy) {
+            *params = _mesa_format_image_size(texFormat, img->Width,
+                                              img->Height, img->Depth);
         }
         else {
            _mesa_error(ctx, GL_INVALID_OPERATION,
@@ -864,13 +954,14 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
         }
          break;
       case GL_TEXTURE_COMPRESSED:
-         *params = (GLint) img->IsCompressed;
+         *params = (GLint) _mesa_is_format_compressed(img->TexFormat);
          break;
 
       /* GL_ARB_texture_float */
       case GL_TEXTURE_RED_TYPE_ARB:
          if (ctx->Extensions.ARB_texture_float) {
-            *params = img->TexFormat->RedBits ? img->TexFormat->DataType : GL_NONE;
+            *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE) ?
+               _mesa_get_format_datatype(texFormat) : GL_NONE;
          }
          else {
             _mesa_error(ctx, GL_INVALID_ENUM,
@@ -879,7 +970,8 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
          break;
       case GL_TEXTURE_GREEN_TYPE_ARB:
          if (ctx->Extensions.ARB_texture_float) {
-            *params = img->TexFormat->GreenBits ? img->TexFormat->DataType : GL_NONE;
+            *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE) ?
+               _mesa_get_format_datatype(texFormat) : GL_NONE;
          }
          else {
             _mesa_error(ctx, GL_INVALID_ENUM,
@@ -888,7 +980,8 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
          break;
       case GL_TEXTURE_BLUE_TYPE_ARB:
          if (ctx->Extensions.ARB_texture_float) {
-            *params = img->TexFormat->BlueBits ? img->TexFormat->DataType : GL_NONE;
+            *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_BLUE_SIZE) ?
+               _mesa_get_format_datatype(texFormat) : GL_NONE;
          }
          else {
             _mesa_error(ctx, GL_INVALID_ENUM,
@@ -897,7 +990,8 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
          break;
       case GL_TEXTURE_ALPHA_TYPE_ARB:
          if (ctx->Extensions.ARB_texture_float) {
-            *params = img->TexFormat->AlphaBits ? img->TexFormat->DataType : GL_NONE;
+            *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_ALPHA_SIZE) ?
+               _mesa_get_format_datatype(texFormat) : GL_NONE;
          }
          else {
             _mesa_error(ctx, GL_INVALID_ENUM,
@@ -906,7 +1000,8 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
          break;
       case GL_TEXTURE_LUMINANCE_TYPE_ARB:
          if (ctx->Extensions.ARB_texture_float) {
-            *params = img->TexFormat->LuminanceBits ? img->TexFormat->DataType : GL_NONE;
+            *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_LUMINANCE_SIZE) ?
+               _mesa_get_format_datatype(texFormat) : GL_NONE;
          }
          else {
             _mesa_error(ctx, GL_INVALID_ENUM,
@@ -915,7 +1010,8 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
          break;
       case GL_TEXTURE_INTENSITY_TYPE_ARB:
          if (ctx->Extensions.ARB_texture_float) {
-            *params = img->TexFormat->IntensityBits ? img->TexFormat->DataType : GL_NONE;
+            *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_INTENSITY_SIZE) ?
+               _mesa_get_format_datatype(texFormat) : GL_NONE;
          }
          else {
             _mesa_error(ctx, GL_INVALID_ENUM,
@@ -924,7 +1020,8 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
          break;
       case GL_TEXTURE_DEPTH_TYPE_ARB:
          if (ctx->Extensions.ARB_texture_float) {
-            *params = img->TexFormat->DepthBits ? img->TexFormat->DataType : GL_NONE;
+            *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_DEPTH_SIZE) ?
+               _mesa_get_format_datatype(texFormat) : GL_NONE;
          }
          else {
             _mesa_error(ctx, GL_INVALID_ENUM,
@@ -946,25 +1043,14 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
 void GLAPIENTRY
 _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
 {
-   struct gl_texture_unit *texUnit;
    struct gl_texture_object *obj;
    GLboolean error = GL_FALSE;
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
-   if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureImageUnits) {
-      _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "glGetTexParameterfv(current unit)");
-      return;
-   }
-
-   texUnit = _mesa_get_current_tex_unit(ctx);
-
-   obj = _mesa_select_tex_object(ctx, texUnit, target);
-   if (!obj) {
-      _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexParameterfv(target)");
+   obj = get_texobj(ctx, target, GL_TRUE);
+   if (!obj)
       return;
-   }
 
    _mesa_lock_texture(ctx, obj);
    switch (pname) {
@@ -984,10 +1070,10 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
          *params = ENUM_TO_FLOAT(obj->WrapR);
          break;
       case GL_TEXTURE_BORDER_COLOR:
-         params[0] = CLAMP(obj->BorderColor[0], 0.0F, 1.0F);
-         params[1] = CLAMP(obj->BorderColor[1], 0.0F, 1.0F);
-         params[2] = CLAMP(obj->BorderColor[2], 0.0F, 1.0F);
-         params[3] = CLAMP(obj->BorderColor[3], 0.0F, 1.0F);
+         params[0] = CLAMP(obj->BorderColor.f[0], 0.0F, 1.0F);
+         params[1] = CLAMP(obj->BorderColor.f[1], 0.0F, 1.0F);
+         params[2] = CLAMP(obj->BorderColor.f[2], 0.0F, 1.0F);
+         params[3] = CLAMP(obj->BorderColor.f[3], 0.0F, 1.0F);
          break;
       case GL_TEXTURE_RESIDENT:
          {
@@ -1113,26 +1199,16 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
 void GLAPIENTRY
 _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
 {
-   struct gl_texture_unit *texUnit;
    struct gl_texture_object *obj;
    GLboolean error = GL_FALSE;
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
-   if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureImageUnits) {
-      _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "glGetTexParameteriv(current unit)");
-      return;
-   }
-
-   texUnit = _mesa_get_current_tex_unit(ctx);
-
-   obj = _mesa_select_tex_object(ctx, texUnit, target);
-   if (!obj) {
-      _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexParameteriv(target)");
-      return;
-   }
+    obj = get_texobj(ctx, target, GL_TRUE);
+    if (!obj)
+       return;
 
+   _mesa_lock_texture(ctx, obj);
    switch (pname) {
       case GL_TEXTURE_MAG_FILTER:
          *params = (GLint) obj->MagFilter;
@@ -1152,10 +1228,10 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
       case GL_TEXTURE_BORDER_COLOR:
          {
             GLfloat b[4];
-            b[0] = CLAMP(obj->BorderColor[0], 0.0F, 1.0F);
-            b[1] = CLAMP(obj->BorderColor[1], 0.0F, 1.0F);
-            b[2] = CLAMP(obj->BorderColor[2], 0.0F, 1.0F);
-            b[3] = CLAMP(obj->BorderColor[3], 0.0F, 1.0F);
+            b[0] = CLAMP(obj->BorderColor.f[0], 0.0F, 1.0F);
+            b[1] = CLAMP(obj->BorderColor.f[1], 0.0F, 1.0F);
+            b[2] = CLAMP(obj->BorderColor.f[2], 0.0F, 1.0F);
+            b[3] = CLAMP(obj->BorderColor.f[3], 0.0F, 1.0F);
             params[0] = FLOAT_TO_INT(b[0]);
             params[1] = FLOAT_TO_INT(b[1]);
             params[2] = FLOAT_TO_INT(b[2]);
@@ -1283,3 +1359,53 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
 
    _mesa_unlock_texture(ctx, obj);
 }
+
+
+/** New in GL 3.0 */
+void GLAPIENTRY
+_mesa_GetTexParameterIiv(GLenum target, GLenum pname, GLint *params)
+{
+   struct gl_texture_object *texObj;
+   GET_CURRENT_CONTEXT(ctx);
+   ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+   texObj = get_texobj(ctx, target, GL_TRUE);
+   
+   switch (pname) {
+   case GL_TEXTURE_BORDER_COLOR:
+      COPY_4V(params, texObj->BorderColor.i);
+      break;
+   default:
+      _mesa_GetTexParameteriv(target, pname, params);
+   }
+}
+
+
+/** New in GL 3.0 */
+void GLAPIENTRY
+_mesa_GetTexParameterIuiv(GLenum target, GLenum pname, GLuint *params)
+{
+   struct gl_texture_object *texObj;
+   GET_CURRENT_CONTEXT(ctx);
+   ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+   texObj = get_texobj(ctx, target, GL_TRUE);
+   
+   switch (pname) {
+   case GL_TEXTURE_BORDER_COLOR:
+      COPY_4V(params, texObj->BorderColor.i);
+      break;
+   default:
+      {
+         GLint ip[4];
+         _mesa_GetTexParameteriv(target, pname, ip);
+         params[0] = ip[0];
+         if (pname == GL_TEXTURE_SWIZZLE_RGBA_EXT || 
+             pname == GL_TEXTURE_CROP_RECT_OES) {
+            params[1] = ip[1];
+            params[2] = ip[2];
+            params[3] = ip[3];
+         }
+      }
+   }
+}
index 454b96350ee1448e23abb324d0175b348fbec678..19b4116c0b6fdf756781a2382eca23f94e8e3fcc 100644 (file)
@@ -44,6 +44,11 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params );
 extern void GLAPIENTRY
 _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params );
 
+extern void GLAPIENTRY
+_mesa_GetTexParameterIiv(GLenum target, GLenum pname, GLint *params);
+
+extern void GLAPIENTRY
+_mesa_GetTexParameterIuiv(GLenum target, GLenum pname, GLuint *params);
 
 
 extern void GLAPIENTRY
@@ -60,4 +65,11 @@ extern void GLAPIENTRY
 _mesa_TexParameteriv( GLenum target, GLenum pname, const GLint *params );
 
 
+extern void GLAPIENTRY
+_mesa_TexParameterIiv(GLenum target, GLenum pname, const GLint *params);
+
+extern void GLAPIENTRY
+_mesa_TexParameterIuiv(GLenum target, GLenum pname, const GLuint *params);
+
+
 #endif /* TEXPARAM_H */
index 53be83b05cee23974f3aa20ff8a3c627e3c7a742..cf603d46d86e370f0f24b8c6dca682b01c814b7b 100644 (file)
@@ -1,7 +1,8 @@
 
 #include "context.h"
+#include "colormac.h"
 #include "fbobject.h"
-#include "texformat.h"
+#include "texfetch.h"
 #include "texrender.h"
 #include "renderbuffer.h"
 
@@ -46,7 +47,9 @@ texture_get_row(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
    if (rb->DataType == CHAN_TYPE) {
       GLchan *rgbaOut = (GLchan *) values;
       for (i = 0; i < count; i++) {
-         trb->TexImage->FetchTexelc(trb->TexImage, x + i, y, z, rgbaOut + 4 * i);
+         GLfloat rgba[4];
+         trb->TexImage->FetchTexelf(trb->TexImage, x + i, y, z, rgba);
+         UNCLAMPED_FLOAT_TO_RGBA_CHAN(rgbaOut + 4 * i, rgba);
       }
    }
    else if (rb->DataType == GL_UNSIGNED_SHORT) {
@@ -100,8 +103,10 @@ texture_get_values(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
    if (rb->DataType == CHAN_TYPE) {
       GLchan *rgbaOut = (GLchan *) values;
       for (i = 0; i < count; i++) {
-         trb->TexImage->FetchTexelc(trb->TexImage, x[i], y[i] + trb->Yoffset,
-                                   z, rgbaOut + 4 * i);
+         GLfloat rgba[4];
+         trb->TexImage->FetchTexelf(trb->TexImage, x[i], y[i] + trb->Yoffset,
+                                   z, rgba);
+         UNCLAMPED_FLOAT_TO_RGBA_CHAN(rgbaOut + 4 * i, rgba);
       }
    }
    else if (rb->DataType == GL_UNSIGNED_SHORT) {
@@ -469,7 +474,7 @@ update_wrapper(GLcontext *ctx, const struct gl_renderbuffer_attachment *att)
    trb->TexImage = att->Texture->Image[att->CubeMapFace][att->TextureLevel];
    ASSERT(trb->TexImage);
 
-   trb->Store = trb->TexImage->TexFormat->StoreTexel;
+   trb->Store = _mesa_get_texel_store_func(trb->TexImage->TexFormat);
    if (!trb->Store) {
       /* we'll never draw into some textures (compressed formats) */
       trb->Store = store_nop;
@@ -488,37 +493,24 @@ update_wrapper(GLcontext *ctx, const struct gl_renderbuffer_attachment *att)
    trb->Base.Height = trb->TexImage->Height;
    trb->Base.InternalFormat = trb->TexImage->InternalFormat;
    /* XXX may need more special cases here */
-   if (trb->TexImage->TexFormat->MesaFormat == MESA_FORMAT_Z24_S8) {
-      trb->Base._ActualFormat = GL_DEPTH24_STENCIL8_EXT;
+   if (trb->TexImage->TexFormat == MESA_FORMAT_Z24_S8) {
+      trb->Base.Format = MESA_FORMAT_Z24_S8;
       trb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT;
    }
-   else if (trb->TexImage->TexFormat->MesaFormat == MESA_FORMAT_Z16) {
-      trb->Base._ActualFormat = GL_DEPTH_COMPONENT;
+   else if (trb->TexImage->TexFormat == MESA_FORMAT_Z16) {
+      trb->Base.Format = MESA_FORMAT_Z16;
       trb->Base.DataType = GL_UNSIGNED_SHORT;
    }
-   else if (trb->TexImage->TexFormat->MesaFormat == MESA_FORMAT_Z32) {
-      trb->Base._ActualFormat = GL_DEPTH_COMPONENT;
+   else if (trb->TexImage->TexFormat == MESA_FORMAT_Z32) {
+      trb->Base.Format = MESA_FORMAT_Z32;
       trb->Base.DataType = GL_UNSIGNED_INT;
    }
    else {
-      trb->Base._ActualFormat = trb->TexImage->InternalFormat;
+      trb->Base.Format = trb->TexImage->TexFormat;
       trb->Base.DataType = CHAN_TYPE;
    }
-   trb->Base._BaseFormat = trb->TexImage->TexFormat->BaseFormat;
-#if 0
-   /* fix/avoid this assertion someday */
-   ASSERT(trb->Base._BaseFormat == GL_RGB ||
-          trb->Base._BaseFormat == GL_RGBA ||
-          trb->Base._BaseFormat == GL_DEPTH_COMPONENT);
-#endif
    trb->Base.Data = trb->TexImage->Data;
-
-   trb->Base.RedBits = trb->TexImage->TexFormat->RedBits;
-   trb->Base.GreenBits = trb->TexImage->TexFormat->GreenBits;
-   trb->Base.BlueBits = trb->TexImage->TexFormat->BlueBits;
-   trb->Base.AlphaBits = trb->TexImage->TexFormat->AlphaBits;
-   trb->Base.DepthBits = trb->TexImage->TexFormat->DepthBits;
-   trb->Base.StencilBits = trb->TexImage->TexFormat->StencilBits;
+   trb->Base._BaseFormat = _mesa_base_fbo_format(ctx, trb->Base.InternalFormat);
 }
 
 
index 43f26873e0f4849246b1ebbf937cc6270399ed4f..c735e18affbea16ba73ad52025d556dc3c8cef38 100644 (file)
@@ -307,10 +307,6 @@ _mesa_ActiveTextureARB(GLenum texture)
       /* update current stack pointer */
       ctx->CurrentStack = &ctx->TextureMatrixStack[texUnit];
    }
-
-   if (ctx->Driver.ActiveTexture) {
-      (*ctx->Driver.ActiveTexture)( ctx, (GLuint) texUnit );
-   }
 }
 
 
@@ -322,11 +318,18 @@ _mesa_ClientActiveTextureARB(GLenum texture)
    GLuint texUnit = texture - GL_TEXTURE0;
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
+   if (MESA_VERBOSE & (VERBOSE_API | VERBOSE_TEXTURE))
+      _mesa_debug(ctx, "glClientActiveTexture %s\n",
+                  _mesa_lookup_enum_by_nr(texture));
+
    if (texUnit >= ctx->Const.MaxTextureCoordUnits) {
       _mesa_error(ctx, GL_INVALID_ENUM, "glClientActiveTexture(texture)");
       return;
    }
 
+   if (ctx->Array.ActiveTexture == texUnit)
+      return;
+
    FLUSH_VERTICES(ctx, _NEW_ARRAY);
    ctx->Array.ActiveTexture = texUnit;
 }
@@ -360,9 +363,6 @@ update_texture_matrices( GLcontext *ctx )
         if (ctx->Texture.Unit[u]._ReallyEnabled &&
             ctx->TextureMatrixStack[u].Top->type != MATRIX_IDENTITY)
            ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(u);
-
-        if (ctx->Driver.TextureMatrix)
-           ctx->Driver.TextureMatrix( ctx, u, ctx->TextureMatrixStack[u].Top);
       }
    }
 }
index f553a898f9e695611c4eb80e13021636e0a5e299..792c83141ec67e813c91fbe5db56cf0fbc941740 100644 (file)
@@ -62,7 +62,8 @@
 #include "mipmap.h"
 #include "imports.h"
 #include "texcompress.h"
-#include "texformat.h"
+#include "texcompress_fxt1.h"
+#include "texcompress_s3tc.h"
 #include "teximage.h"
 #include "texstore.h"
 #include "enums.h"
@@ -74,6 +75,12 @@ enum {
 };
 
 
+/**
+ * Texture image storage function.
+ */
+typedef GLboolean (*StoreTexImageFunc)(TEXSTORE_PARAMS);
+
+
 /**
  * Return GL_TRUE if the given image format is one that be converted
  * to another format by swizzling.
@@ -270,16 +277,6 @@ compute_component_mapping(GLenum inFormat, GLenum outFormat,
 }
 
 
-#if !FEATURE_convolve
-static void
-_mesa_adjust_image_for_convolution(GLcontext *ctx, GLuint dims,
-                                   GLsizei *srcWidth, GLsizei *srcHeight)
-{
-   /* no-op */
-}
-#endif
-
-
 /**
  * Make a temporary (color) texture image with GLfloat components.
  * Apply all needed pixel unpacking and pixel transfer operations.
@@ -346,7 +343,7 @@ make_temp_float_image(GLcontext *ctx, GLuint dims,
       const GLuint postConvTransferOps
          = (transferOps & IMAGE_POST_CONVOLUTION_BITS) | IMAGE_CLAMP_BIT;
       GLint img, row;
-      GLint convWidth, convHeight;
+      GLint convWidth = srcWidth, convHeight = srcHeight;
       GLfloat *convImage;
 
       /* pre-convolution image buffer (3D) */
@@ -431,8 +428,8 @@ make_temp_float_image(GLcontext *ctx, GLuint dims,
    else {
       /* no convolution */
       const GLint components = _mesa_components_in_format(logicalBaseFormat);
-      const GLint srcStride = _mesa_image_row_stride(srcPacking,
-                                                 srcWidth, srcFormat, srcType);
+      const GLint srcStride =
+         _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
       GLfloat *dst;
       GLint img, row;
 
@@ -587,19 +584,22 @@ _mesa_make_temp_chan_image(GLcontext *ctx, GLuint dims,
    /* unpack and transfer the source image */
    tempImage = (GLchan *) _mesa_malloc(srcWidth * srcHeight * srcDepth
                                        * components * sizeof(GLchan));
-   if (!tempImage)
+   if (!tempImage) {
+      if (freeSrcImage) {
+         _mesa_free((void *) srcAddr);
+      }
       return NULL;
+   }
 
    dst = tempImage;
    for (img = 0; img < srcDepth; img++) {
-      const GLint srcStride = _mesa_image_row_stride(srcPacking,
-                                                     srcWidth, srcFormat,
-                                                     srcType);
-      const GLubyte *src
-         = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr,
-                                                 srcWidth, srcHeight,
-                                                 srcFormat, srcType,
-                                                 img, 0, 0);
+      const GLint srcStride =
+         _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
+      const GLubyte *src =
+         (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr,
+                                               srcWidth, srcHeight,
+                                               srcFormat, srcType,
+                                               img, 0, 0);
       for (row = 0; row < srcHeight; row++) {
          _mesa_unpack_color_span_chan(ctx, srcWidth, logicalBaseFormat, dst,
                                       srcFormat, srcType, src, srcPacking,
@@ -924,7 +924,7 @@ _mesa_swizzle_ubyte_image(GLcontext *ctx,
 static void
 memcpy_texture(GLcontext *ctx,
               GLuint dimensions,
-               const struct gl_texture_format *dstFormat,
+               gl_format dstFormat,
                GLvoid *dstAddr,
                GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
                GLint dstRowStride,
@@ -940,7 +940,8 @@ memcpy_texture(GLcontext *ctx,
                                       srcWidth, srcHeight, srcFormat, srcType);
    const GLubyte *srcImage = (const GLubyte *) _mesa_image_address(dimensions,
         srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
-   const GLint bytesPerRow = srcWidth * dstFormat->TexelBytes;
+   const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+   const GLint bytesPerRow = srcWidth * texelBytes;
 
 #if 0
    /* XXX update/re-enable for dstImageOffsets array */
@@ -949,7 +950,7 @@ memcpy_texture(GLcontext *ctx,
    GLubyte *dstImage = (GLubyte *) dstAddr
                      + dstZoffset * dstImageStride
                      + dstYoffset * dstRowStride
-                     + dstXoffset * dstFormat->TexelBytes;
+                     + dstXoffset * texelBytes;
 
    if (dstRowStride == srcRowStride &&
        dstRowStride == bytesPerRow &&
@@ -980,9 +981,9 @@ memcpy_texture(GLcontext *ctx,
    for (img = 0; img < srcDepth; img++) {
       const GLubyte *srcRow = srcImage;
       GLubyte *dstRow = (GLubyte *) dstAddr
-         + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+         + dstImageOffsets[dstZoffset + img] * texelBytes
          + dstYoffset * dstRowStride
-         + dstXoffset * dstFormat->TexelBytes;
+         + dstXoffset * texelBytes;
       for (row = 0; row < srcHeight; row++) {
          ctx->Driver.TextureMemCpy(dstRow, srcRow, bytesPerRow);
          dstRow += dstRowStride;
@@ -995,38 +996,23 @@ memcpy_texture(GLcontext *ctx,
 
 
 /**
- * Store an image in any of the formats:
- *   _mesa_texformat_rgba
- *   _mesa_texformat_rgb
- *   _mesa_texformat_alpha
- *   _mesa_texformat_luminance
- *   _mesa_texformat_luminance_alpha
- *   _mesa_texformat_intensity
- * 
+ * Store a 32-bit integer depth component texture image.
  */
-GLboolean
-_mesa_texstore_rgba(TEXSTORE_PARAMS)
+static GLboolean
+_mesa_texstore_z32(TEXSTORE_PARAMS)
 {
-   const GLint components = _mesa_components_in_format(baseInternalFormat);
-
-   ASSERT(dstFormat == &_mesa_texformat_rgba ||
-          dstFormat == &_mesa_texformat_rgb ||
-          dstFormat == &_mesa_texformat_alpha ||
-          dstFormat == &_mesa_texformat_luminance ||
-          dstFormat == &_mesa_texformat_luminance_alpha ||
-          dstFormat == &_mesa_texformat_intensity);
-   ASSERT(baseInternalFormat == GL_RGBA ||
-          baseInternalFormat == GL_RGB ||
-          baseInternalFormat == GL_ALPHA ||
-          baseInternalFormat == GL_LUMINANCE ||
-          baseInternalFormat == GL_LUMINANCE_ALPHA ||
-          baseInternalFormat == GL_INTENSITY);
-   ASSERT(dstFormat->TexelBytes == components * sizeof(GLchan));
+   const GLuint depthScale = 0xffffffff;
+   const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+   (void) dims;
+   ASSERT(dstFormat == MESA_FORMAT_Z32);
+   ASSERT(texelBytes == sizeof(GLuint));
 
-   if (!ctx->_ImageTransferState &&
+   if (ctx->Pixel.DepthScale == 1.0f &&
+       ctx->Pixel.DepthBias == 0.0f &&
        !srcPacking->SwapBytes &&
-       baseInternalFormat == srcFormat &&
-       srcType == CHAN_TYPE) {
+       baseInternalFormat == GL_DEPTH_COMPONENT &&
+       srcFormat == GL_DEPTH_COMPONENT &&
+       srcType == GL_UNSIGNED_INT) {
       /* simple memcpy path */
       memcpy_texture(ctx, dims,
                      dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
@@ -1035,160 +1021,92 @@ _mesa_texstore_rgba(TEXSTORE_PARAMS)
                      srcWidth, srcHeight, srcDepth, srcFormat, srcType,
                      srcAddr, srcPacking);
    }
-   else if (!ctx->_ImageTransferState &&
-            !srcPacking->SwapBytes &&
-            dstFormat == &_mesa_texformat_rgb &&
-            srcFormat == GL_RGBA &&
-            srcType == CHAN_TYPE) {
-      /* extract RGB from RGBA */
-      GLint img, row, col;
+   else {
+      /* general path */
+      GLint img, row;
       for (img = 0; img < srcDepth; img++) {
-         GLchan *dstImage = (GLchan *)
-            ((GLubyte *) dstAddr
-             + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
-             + dstYoffset * dstRowStride
-             + dstXoffset * dstFormat->TexelBytes);
-
-         const GLint srcRowStride = _mesa_image_row_stride(srcPacking,
-                                                 srcWidth, srcFormat, srcType);
-         GLchan *srcRow = (GLchan *) _mesa_image_address(dims, srcPacking,
-                  srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
-         GLchan *dstRow = dstImage;
+         GLubyte *dstRow = (GLubyte *) dstAddr
+            + dstImageOffsets[dstZoffset + img] * texelBytes
+            + dstYoffset * dstRowStride
+            + dstXoffset * texelBytes;
          for (row = 0; row < srcHeight; row++) {
-            for (col = 0; col < srcWidth; col++) {
-               dstRow[col * 3 + RCOMP] = srcRow[col * 4 + RCOMP];
-               dstRow[col * 3 + GCOMP] = srcRow[col * 4 + GCOMP];
-               dstRow[col * 3 + BCOMP] = srcRow[col * 4 + BCOMP];
-            }
-            dstRow += dstRowStride / sizeof(GLchan);
-            srcRow = (GLchan *) ((GLubyte *) srcRow + srcRowStride);
+            const GLvoid *src = _mesa_image_address(dims, srcPacking,
+                srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
+            _mesa_unpack_depth_span(ctx, srcWidth,
+                                    GL_UNSIGNED_INT, (GLuint *) dstRow,
+                                    depthScale, srcType, src, srcPacking);
+            dstRow += dstRowStride;
          }
       }
    }
-   else if (!ctx->_ImageTransferState &&
-           CHAN_TYPE == GL_UNSIGNED_BYTE &&
-           (srcType == GL_UNSIGNED_BYTE ||
-            srcType == GL_UNSIGNED_INT_8_8_8_8 ||
-            srcType == GL_UNSIGNED_INT_8_8_8_8_REV) &&
-           can_swizzle(baseInternalFormat) &&
-           can_swizzle(srcFormat)) {
+   return GL_TRUE;
+}
 
-      const GLubyte *dstmap;
-      GLuint components;
 
-      /* dstmap - how to swizzle from RGBA to dst format:
-       */
-      if (dstFormat == &_mesa_texformat_rgba) {
-        dstmap = mappings[IDX_RGBA].from_rgba;
-        components = 4;
-      }
-      else if (dstFormat == &_mesa_texformat_rgb) {
-        dstmap = mappings[IDX_RGB].from_rgba;
-        components = 3;
-      }
-      else if (dstFormat == &_mesa_texformat_alpha) {
-        dstmap = mappings[IDX_ALPHA].from_rgba;
-        components = 1;
-      }
-      else if (dstFormat == &_mesa_texformat_luminance) {
-        dstmap = mappings[IDX_LUMINANCE].from_rgba;
-        components = 1;
-      }
-      else if (dstFormat == &_mesa_texformat_luminance_alpha) {
-        dstmap = mappings[IDX_LUMINANCE_ALPHA].from_rgba;
-        components = 2;
-      }
-      else if (dstFormat == &_mesa_texformat_intensity) {
-        dstmap = mappings[IDX_INTENSITY].from_rgba;
-        components = 1;
-      }
-      else {
-         _mesa_problem(ctx, "Unexpected dstFormat in _mesa_texstore_rgba");
-         return GL_FALSE;
-      }
+/**
+ * Store a 24-bit integer depth component texture image.
+ */
+static GLboolean
+_mesa_texstore_x8_z24(TEXSTORE_PARAMS)
+{
+   const GLuint depthScale = 0xffffff;
+   const GLuint texelBytes = 4;
 
-      _mesa_swizzle_ubyte_image(ctx, dims,
-                               srcFormat,
-                               srcType,
-                               baseInternalFormat,
-                               dstmap, components,
-                               dstAddr, dstXoffset, dstYoffset, dstZoffset,
-                               dstRowStride, dstImageOffsets,
-                               srcWidth, srcHeight, srcDepth, srcAddr,
-                               srcPacking);      
-   }
-   else {
+   (void) dims;
+   ASSERT(dstFormat == MESA_FORMAT_X8_Z24);
+
+   {
       /* general path */
-      const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
-                                                 baseInternalFormat,
-                                                 dstFormat->BaseFormat,
-                                                 srcWidth, srcHeight, srcDepth,
-                                                 srcFormat, srcType, srcAddr,
-                                                 srcPacking);
-      const GLchan *src = tempImage;
-      GLint bytesPerRow;
       GLint img, row;
-      if (!tempImage)
-         return GL_FALSE;
-      _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
-      bytesPerRow = srcWidth * components * sizeof(GLchan);
       for (img = 0; img < srcDepth; img++) {
          GLubyte *dstRow = (GLubyte *) dstAddr
-            + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+            + dstImageOffsets[dstZoffset + img] * texelBytes
             + dstYoffset * dstRowStride
-            + dstXoffset * dstFormat->TexelBytes;
+            + dstXoffset * texelBytes;
          for (row = 0; row < srcHeight; row++) {
-            _mesa_memcpy(dstRow, src, bytesPerRow);
+            const GLvoid *src = _mesa_image_address(dims, srcPacking,
+                srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
+            _mesa_unpack_depth_span(ctx, srcWidth,
+                                    GL_UNSIGNED_INT, (GLuint *) dstRow,
+                                    depthScale, srcType, src, srcPacking);
             dstRow += dstRowStride;
-            src += srcWidth * components;
          }
       }
-
-      _mesa_free((void *) tempImage);
    }
    return GL_TRUE;
 }
 
 
 /**
- * Store a 32-bit integer depth component texture image.
+ * Store a 24-bit integer depth component texture image.
  */
-GLboolean
-_mesa_texstore_z32(TEXSTORE_PARAMS)
+static GLboolean
+_mesa_texstore_z24_x8(TEXSTORE_PARAMS)
 {
-   const GLuint depthScale = 0xffffffff;
+   const GLuint depthScale = 0xffffff;
+   const GLuint texelBytes = 4;
+
    (void) dims;
-   ASSERT(dstFormat == &_mesa_texformat_z32);
-   ASSERT(dstFormat->TexelBytes == sizeof(GLuint));
+   ASSERT(dstFormat == MESA_FORMAT_Z24_X8);
 
-   if (ctx->Pixel.DepthScale == 1.0f &&
-       ctx->Pixel.DepthBias == 0.0f &&
-       !srcPacking->SwapBytes &&
-       baseInternalFormat == GL_DEPTH_COMPONENT &&
-       srcFormat == GL_DEPTH_COMPONENT &&
-       srcType == GL_UNSIGNED_INT) {
-      /* simple memcpy path */
-      memcpy_texture(ctx, dims,
-                     dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
-                     dstRowStride,
-                     dstImageOffsets,
-                     srcWidth, srcHeight, srcDepth, srcFormat, srcType,
-                     srcAddr, srcPacking);
-   }
-   else {
+   {
       /* general path */
       GLint img, row;
       for (img = 0; img < srcDepth; img++) {
          GLubyte *dstRow = (GLubyte *) dstAddr
-            + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+            + dstImageOffsets[dstZoffset + img] * texelBytes
             + dstYoffset * dstRowStride
-            + dstXoffset * dstFormat->TexelBytes;
+            + dstXoffset * texelBytes;
          for (row = 0; row < srcHeight; row++) {
             const GLvoid *src = _mesa_image_address(dims, srcPacking,
                 srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
+            GLuint *dst = (GLuint *) dstRow;
+            GLint i;
             _mesa_unpack_depth_span(ctx, srcWidth,
-                                    GL_UNSIGNED_INT, (GLuint *) dstRow,
+                                    GL_UNSIGNED_INT, dst,
                                     depthScale, srcType, src, srcPacking);
+            for (i = 0; i < srcWidth; i++)
+               dst[i] <<= 8;
             dstRow += dstRowStride;
          }
       }
@@ -1196,18 +1114,18 @@ _mesa_texstore_z32(TEXSTORE_PARAMS)
    return GL_TRUE;
 }
 
-#define STRIDE_3D 0
 
 /**
  * Store a 16-bit integer depth component texture image.
  */
-GLboolean
+static GLboolean
 _mesa_texstore_z16(TEXSTORE_PARAMS)
 {
    const GLuint depthScale = 0xffff;
+   const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
    (void) dims;
-   ASSERT(dstFormat == &_mesa_texformat_z16);
-   ASSERT(dstFormat->TexelBytes == sizeof(GLushort));
+   ASSERT(dstFormat == MESA_FORMAT_Z16);
+   ASSERT(texelBytes == sizeof(GLushort));
 
    if (ctx->Pixel.DepthScale == 1.0f &&
        ctx->Pixel.DepthBias == 0.0f &&
@@ -1228,9 +1146,9 @@ _mesa_texstore_z16(TEXSTORE_PARAMS)
       GLint img, row;
       for (img = 0; img < srcDepth; img++) {
          GLubyte *dstRow = (GLubyte *) dstAddr
-            + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+            + dstImageOffsets[dstZoffset + img] * texelBytes
             + dstYoffset * dstRowStride
-            + dstXoffset * dstFormat->TexelBytes;
+            + dstXoffset * texelBytes;
          for (row = 0; row < srcHeight; row++) {
             const GLvoid *src = _mesa_image_address(dims, srcPacking,
                 srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
@@ -1249,16 +1167,19 @@ _mesa_texstore_z16(TEXSTORE_PARAMS)
 /**
  * Store an rgb565 or rgb565_rev texture image.
  */
-GLboolean
+static GLboolean
 _mesa_texstore_rgb565(TEXSTORE_PARAMS)
 {
-   ASSERT(dstFormat == &_mesa_texformat_rgb565 ||
-          dstFormat == &_mesa_texformat_rgb565_rev);
-   ASSERT(dstFormat->TexelBytes == 2);
+   const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+   const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
+
+   ASSERT(dstFormat == MESA_FORMAT_RGB565 ||
+          dstFormat == MESA_FORMAT_RGB565_REV);
+   ASSERT(texelBytes == 2);
 
    if (!ctx->_ImageTransferState &&
        !srcPacking->SwapBytes &&
-       dstFormat == &_mesa_texformat_rgb565 &&
+       dstFormat == MESA_FORMAT_RGB565 &&
        baseInternalFormat == GL_RGB &&
        srcFormat == GL_RGB &&
        srcType == GL_UNSIGNED_SHORT_5_6_5) {
@@ -1277,20 +1198,20 @@ _mesa_texstore_rgb565(TEXSTORE_PARAMS)
             srcType == GL_UNSIGNED_BYTE &&
             dims == 2) {
       /* do optimized tex store */
-      const GLint srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth,
-                                                        srcFormat, srcType);
+      const GLint srcRowStride =
+         _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
       const GLubyte *src = (const GLubyte *)
          _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight,
                              srcFormat, srcType, 0, 0, 0);
       GLubyte *dst = (GLubyte *) dstAddr
                    + dstYoffset * dstRowStride
-                   + dstXoffset * dstFormat->TexelBytes;
+                   + dstXoffset * texelBytes;
       GLint row, col;
       for (row = 0; row < srcHeight; row++) {
          const GLubyte *srcUB = (const GLubyte *) src;
          GLushort *dstUS = (GLushort *) dst;
          /* check for byteswapped format */
-         if (dstFormat == &_mesa_texformat_rgb565) {
+         if (dstFormat == MESA_FORMAT_RGB565) {
             for (col = 0; col < srcWidth; col++) {
                dstUS[col] = PACK_COLOR_565( srcUB[0], srcUB[1], srcUB[2] );
                srcUB += 3;
@@ -1310,7 +1231,7 @@ _mesa_texstore_rgb565(TEXSTORE_PARAMS)
       /* general path */
       const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
                                                  baseInternalFormat,
-                                                 dstFormat->BaseFormat,
+                                                 baseFormat,
                                                  srcWidth, srcHeight, srcDepth,
                                                  srcFormat, srcType, srcAddr,
                                                  srcPacking);
@@ -1321,13 +1242,13 @@ _mesa_texstore_rgb565(TEXSTORE_PARAMS)
       _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
       for (img = 0; img < srcDepth; img++) {
          GLubyte *dstRow = (GLubyte *) dstAddr
-            + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+            + dstImageOffsets[dstZoffset + img] * texelBytes
             + dstYoffset * dstRowStride
-            + dstXoffset * dstFormat->TexelBytes;
+            + dstXoffset * texelBytes;
          for (row = 0; row < srcHeight; row++) {
             GLushort *dstUS = (GLushort *) dstRow;
             /* check for byteswapped format */
-            if (dstFormat == &_mesa_texformat_rgb565) {
+            if (dstFormat == MESA_FORMAT_RGB565) {
                for (col = 0; col < srcWidth; col++) {
                   dstUS[col] = PACK_COLOR_565( CHAN_TO_UBYTE(src[RCOMP]),
                                                CHAN_TO_UBYTE(src[GCOMP]),
@@ -1355,18 +1276,20 @@ _mesa_texstore_rgb565(TEXSTORE_PARAMS)
 /**
  * Store a texture in MESA_FORMAT_RGBA8888 or MESA_FORMAT_RGBA8888_REV.
  */
-GLboolean
+static GLboolean
 _mesa_texstore_rgba8888(TEXSTORE_PARAMS)
 {
    const GLboolean littleEndian = _mesa_little_endian();
+   const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+   const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
 
-   ASSERT(dstFormat == &_mesa_texformat_rgba8888 ||
-          dstFormat == &_mesa_texformat_rgba8888_rev);
-   ASSERT(dstFormat->TexelBytes == 4);
+   ASSERT(dstFormat == MESA_FORMAT_RGBA8888 ||
+          dstFormat == MESA_FORMAT_RGBA8888_REV);
+   ASSERT(texelBytes == 4);
 
    if (!ctx->_ImageTransferState &&
        !srcPacking->SwapBytes &&
-       dstFormat == &_mesa_texformat_rgba8888 &&
+       dstFormat == MESA_FORMAT_RGBA8888 &&
        baseInternalFormat == GL_RGBA &&
       ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8) ||
        (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
@@ -1382,7 +1305,7 @@ _mesa_texstore_rgba8888(TEXSTORE_PARAMS)
    }
    else if (!ctx->_ImageTransferState &&
        !srcPacking->SwapBytes &&
-       dstFormat == &_mesa_texformat_rgba8888_rev &&
+       dstFormat == MESA_FORMAT_RGBA8888_REV &&
        baseInternalFormat == GL_RGBA &&
       ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) ||
        (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && littleEndian) ||
@@ -1407,8 +1330,8 @@ _mesa_texstore_rgba8888(TEXSTORE_PARAMS)
 
       /* dstmap - how to swizzle from RGBA to dst format:
        */
-      if ((littleEndian && dstFormat == &_mesa_texformat_rgba8888) ||
-         (!littleEndian && dstFormat == &_mesa_texformat_rgba8888_rev)) {
+      if ((littleEndian && dstFormat == MESA_FORMAT_RGBA8888) ||
+         (!littleEndian && dstFormat == MESA_FORMAT_RGBA8888_REV)) {
         dstmap[3] = 0;
         dstmap[2] = 1;
         dstmap[1] = 2;
@@ -1435,7 +1358,7 @@ _mesa_texstore_rgba8888(TEXSTORE_PARAMS)
       /* general path */
       const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
                                                  baseInternalFormat,
-                                                 dstFormat->BaseFormat,
+                                                 baseFormat,
                                                  srcWidth, srcHeight, srcDepth,
                                                  srcFormat, srcType, srcAddr,
                                                  srcPacking);
@@ -1446,12 +1369,12 @@ _mesa_texstore_rgba8888(TEXSTORE_PARAMS)
       _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
       for (img = 0; img < srcDepth; img++) {
          GLubyte *dstRow = (GLubyte *) dstAddr
-            + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+            + dstImageOffsets[dstZoffset + img] * texelBytes
             + dstYoffset * dstRowStride
-            + dstXoffset * dstFormat->TexelBytes;
+            + dstXoffset * texelBytes;
          for (row = 0; row < srcHeight; row++) {
             GLuint *dstUI = (GLuint *) dstRow;
-            if (dstFormat == &_mesa_texformat_rgba8888) {
+            if (dstFormat == MESA_FORMAT_RGBA8888) {
                for (col = 0; col < srcWidth; col++) {
                   dstUI[col] = PACK_COLOR_8888( CHAN_TO_UBYTE(src[RCOMP]),
                                                 CHAN_TO_UBYTE(src[GCOMP]),
@@ -1478,18 +1401,23 @@ _mesa_texstore_rgba8888(TEXSTORE_PARAMS)
 }
 
 
-GLboolean
+static GLboolean
 _mesa_texstore_argb8888(TEXSTORE_PARAMS)
 {
    const GLboolean littleEndian = _mesa_little_endian();
+   const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+   const GLenum baseFormat = GL_RGBA;
 
-   ASSERT(dstFormat == &_mesa_texformat_argb8888 ||
-          dstFormat == &_mesa_texformat_argb8888_rev);
-   ASSERT(dstFormat->TexelBytes == 4);
+   ASSERT(dstFormat == MESA_FORMAT_ARGB8888 ||
+          dstFormat == MESA_FORMAT_ARGB8888_REV ||
+          dstFormat == MESA_FORMAT_XRGB8888 ||
+          dstFormat == MESA_FORMAT_XRGB8888_REV );
+   ASSERT(texelBytes == 4);
 
    if (!ctx->_ImageTransferState &&
        !srcPacking->SwapBytes &&
-       dstFormat == &_mesa_texformat_argb8888 &&
+       (dstFormat == MESA_FORMAT_ARGB8888 ||
+        dstFormat == MESA_FORMAT_XRGB8888) &&
        baseInternalFormat == GL_RGBA &&
        srcFormat == GL_BGRA &&
        ((srcType == GL_UNSIGNED_BYTE && littleEndian) ||
@@ -1504,7 +1432,8 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
    }
    else if (!ctx->_ImageTransferState &&
        !srcPacking->SwapBytes &&
-       dstFormat == &_mesa_texformat_argb8888_rev &&
+       (dstFormat == MESA_FORMAT_ARGB8888_REV ||
+        dstFormat == MESA_FORMAT_XRGB8888_REV) &&
        baseInternalFormat == GL_RGBA &&
        srcFormat == GL_BGRA &&
        ((srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
@@ -1519,21 +1448,22 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
    }
    else if (!ctx->_ImageTransferState &&
             !srcPacking->SwapBytes &&
-           dstFormat == &_mesa_texformat_argb8888 &&
+           (dstFormat == MESA_FORMAT_ARGB8888 ||
+             dstFormat == MESA_FORMAT_XRGB8888) &&
             srcFormat == GL_RGB &&
            (baseInternalFormat == GL_RGBA ||
             baseInternalFormat == GL_RGB) &&
             srcType == GL_UNSIGNED_BYTE) {
       int img, row, col;
       for (img = 0; img < srcDepth; img++) {
-         const GLint srcRowStride = _mesa_image_row_stride(srcPacking,
-                                                 srcWidth, srcFormat, srcType);
+         const GLint srcRowStride =
+            _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
          GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,
                   srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
          GLubyte *dstRow = (GLubyte *) dstAddr
-            + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+            + dstImageOffsets[dstZoffset + img] * texelBytes
             + dstYoffset * dstRowStride
-            + dstXoffset * dstFormat->TexelBytes;
+            + dstXoffset * texelBytes;
          for (row = 0; row < srcHeight; row++) {
             GLuint *d4 = (GLuint *) dstRow;
             for (col = 0; col < srcWidth; col++) {
@@ -1549,7 +1479,7 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
    }
    else if (!ctx->_ImageTransferState &&
             !srcPacking->SwapBytes &&
-           dstFormat == &_mesa_texformat_argb8888 &&
+           dstFormat == MESA_FORMAT_ARGB8888 &&
             srcFormat == GL_RGBA &&
            baseInternalFormat == GL_RGBA &&
             srcType == GL_UNSIGNED_BYTE) {
@@ -1562,14 +1492,14 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
        * Strangely the same isn't required for the RGB path, above.
        */
       for (img = 0; img < srcDepth; img++) {
-         const GLint srcRowStride = _mesa_image_row_stride(srcPacking,
-                                                 srcWidth, srcFormat, srcType);
+         const GLint srcRowStride =
+            _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
          GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,
                   srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
          GLubyte *dstRow = (GLubyte *) dstAddr
-            + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+            + dstImageOffsets[dstZoffset + img] * texelBytes
             + dstYoffset * dstRowStride
-            + dstXoffset * dstFormat->TexelBytes;
+            + dstXoffset * texelBytes;
          for (row = 0; row < srcHeight; row++) {
             GLuint *d4 = (GLuint *) dstRow;
             for (col = 0; col < srcWidth; col++) {
@@ -1594,16 +1524,20 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
 
       /* dstmap - how to swizzle from RGBA to dst format:
        */
-      if ((littleEndian && dstFormat == &_mesa_texformat_argb8888) ||
-         (!littleEndian && dstFormat == &_mesa_texformat_argb8888_rev)) {
+      if ((littleEndian && dstFormat == MESA_FORMAT_ARGB8888) ||
+          (littleEndian && dstFormat == MESA_FORMAT_XRGB8888) ||
+         (!littleEndian && dstFormat == MESA_FORMAT_ARGB8888_REV) ||
+         (!littleEndian && dstFormat == MESA_FORMAT_XRGB8888_REV)) {
         dstmap[3] = 3;         /* alpha */
         dstmap[2] = 0;         /* red */
         dstmap[1] = 1;         /* green */
         dstmap[0] = 2;         /* blue */
       }
       else {
-        assert((littleEndian && dstFormat == &_mesa_texformat_argb8888_rev) ||
-               (!littleEndian && dstFormat == &_mesa_texformat_argb8888));
+        assert((littleEndian && dstFormat == MESA_FORMAT_ARGB8888_REV) ||
+               (!littleEndian && dstFormat == MESA_FORMAT_ARGB8888) ||
+               (littleEndian && dstFormat == MESA_FORMAT_XRGB8888_REV) ||
+               (!littleEndian && dstFormat == MESA_FORMAT_XRGB8888));
         dstmap[3] = 2;
         dstmap[2] = 1;
         dstmap[1] = 0;
@@ -1626,7 +1560,7 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
       /* general path */
       const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
                                                  baseInternalFormat,
-                                                 dstFormat->BaseFormat,
+                                                 baseFormat,
                                                  srcWidth, srcHeight, srcDepth,
                                                  srcFormat, srcType, srcAddr,
                                                  srcPacking);
@@ -1637,12 +1571,12 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
       _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
       for (img = 0; img < srcDepth; img++) {
          GLubyte *dstRow = (GLubyte *) dstAddr
-            + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+            + dstImageOffsets[dstZoffset + img] * texelBytes
             + dstYoffset * dstRowStride
-            + dstXoffset * dstFormat->TexelBytes;
+            + dstXoffset * texelBytes;
          for (row = 0; row < srcHeight; row++) {
             GLuint *dstUI = (GLuint *) dstRow;
-            if (dstFormat == &_mesa_texformat_argb8888) {
+            if (dstFormat == MESA_FORMAT_ARGB8888) {
                for (col = 0; col < srcWidth; col++) {
                   dstUI[col] = PACK_COLOR_8888( CHAN_TO_UBYTE(src[ACOMP]),
                                                 CHAN_TO_UBYTE(src[RCOMP]),
@@ -1651,6 +1585,15 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
                   src += 4;
                }
             }
+            else if (dstFormat == MESA_FORMAT_XRGB8888) {
+               for (col = 0; col < srcWidth; col++) {
+                  dstUI[col] = PACK_COLOR_8888( 0xff,
+                                                CHAN_TO_UBYTE(src[RCOMP]),
+                                                CHAN_TO_UBYTE(src[GCOMP]),
+                                                CHAN_TO_UBYTE(src[BCOMP]) );
+                  src += 4;
+               }
+            }
             else {
                for (col = 0; col < srcWidth; col++) {
                   dstUI[col] = PACK_COLOR_8888_REV( CHAN_TO_UBYTE(src[ACOMP]),
@@ -1669,13 +1612,15 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
 }
 
 
-GLboolean
+static GLboolean
 _mesa_texstore_rgb888(TEXSTORE_PARAMS)
 {
    const GLboolean littleEndian = _mesa_little_endian();
+   const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+   const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
 
-   ASSERT(dstFormat == &_mesa_texformat_rgb888);
-   ASSERT(dstFormat->TexelBytes == 3);
+   ASSERT(dstFormat == MESA_FORMAT_RGB888);
+   ASSERT(texelBytes == 3);
 
    if (!ctx->_ImageTransferState &&
        !srcPacking->SwapBytes &&
@@ -1698,14 +1643,14 @@ _mesa_texstore_rgb888(TEXSTORE_PARAMS)
       /* extract RGB from RGBA */
       GLint img, row, col;
       for (img = 0; img < srcDepth; img++) {
-         const GLint srcRowStride = _mesa_image_row_stride(srcPacking,
-                                                 srcWidth, srcFormat, srcType);
+         const GLint srcRowStride =
+            _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
          GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,
                   srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
          GLubyte *dstRow = (GLubyte *) dstAddr
-            + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+            + dstImageOffsets[dstZoffset + img] * texelBytes
             + dstYoffset * dstRowStride
-            + dstXoffset * dstFormat->TexelBytes;
+            + dstXoffset * texelBytes;
          for (row = 0; row < srcHeight; row++) {
             for (col = 0; col < srcWidth; col++) {
                dstRow[col * 3 + 0] = srcRow[col * 4 + BCOMP];
@@ -1745,7 +1690,7 @@ _mesa_texstore_rgb888(TEXSTORE_PARAMS)
       /* general path */
       const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
                                                  baseInternalFormat,
-                                                 dstFormat->BaseFormat,
+                                                 baseFormat,
                                                  srcWidth, srcHeight, srcDepth,
                                                  srcFormat, srcType, srcAddr,
                                                  srcPacking);
@@ -1756,9 +1701,9 @@ _mesa_texstore_rgb888(TEXSTORE_PARAMS)
       _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
       for (img = 0; img < srcDepth; img++) {
          GLubyte *dstRow = (GLubyte *) dstAddr
-            + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+            + dstImageOffsets[dstZoffset + img] * texelBytes
             + dstYoffset * dstRowStride
-            + dstXoffset * dstFormat->TexelBytes;
+            + dstXoffset * texelBytes;
          for (row = 0; row < srcHeight; row++) {
 #if 0
             if (littleEndian) {
@@ -1794,13 +1739,15 @@ _mesa_texstore_rgb888(TEXSTORE_PARAMS)
 }
 
 
-GLboolean
+static GLboolean
 _mesa_texstore_bgr888(TEXSTORE_PARAMS)
 {
    const GLboolean littleEndian = _mesa_little_endian();
+   const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+   const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
 
-   ASSERT(dstFormat == &_mesa_texformat_bgr888);
-   ASSERT(dstFormat->TexelBytes == 3);
+   ASSERT(dstFormat == MESA_FORMAT_BGR888);
+   ASSERT(texelBytes == 3);
 
    if (!ctx->_ImageTransferState &&
        !srcPacking->SwapBytes &&
@@ -1823,14 +1770,14 @@ _mesa_texstore_bgr888(TEXSTORE_PARAMS)
       /* extract BGR from RGBA */
       int img, row, col;
       for (img = 0; img < srcDepth; img++) {
-         const GLint srcRowStride = _mesa_image_row_stride(srcPacking,
-                                                 srcWidth, srcFormat, srcType);
+         const GLint srcRowStride =
+            _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
          GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,
                   srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
          GLubyte *dstRow = (GLubyte *) dstAddr
-            + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+            + dstImageOffsets[dstZoffset + img] * texelBytes
             + dstYoffset * dstRowStride
-            + dstXoffset * dstFormat->TexelBytes;
+            + dstXoffset * texelBytes;
          for (row = 0; row < srcHeight; row++) {
             for (col = 0; col < srcWidth; col++) {
                dstRow[col * 3 + 0] = srcRow[col * 4 + RCOMP];
@@ -1870,7 +1817,7 @@ _mesa_texstore_bgr888(TEXSTORE_PARAMS)
       /* general path */
       const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
                                                  baseInternalFormat,
-                                                 dstFormat->BaseFormat,
+                                                 baseFormat,
                                                  srcWidth, srcHeight, srcDepth,
                                                  srcFormat, srcType, srcAddr,
                                                  srcPacking);
@@ -1881,9 +1828,9 @@ _mesa_texstore_bgr888(TEXSTORE_PARAMS)
       _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
       for (img = 0; img < srcDepth; img++) {
          GLubyte *dstRow = (GLubyte *) dstAddr
-            + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+            + dstImageOffsets[dstZoffset + img] * texelBytes
             + dstYoffset * dstRowStride
-            + dstXoffset * dstFormat->TexelBytes;
+            + dstXoffset * texelBytes;
          for (row = 0; row < srcHeight; row++) {
             for (col = 0; col < srcWidth; col++) {
                dstRow[col * 3 + 0] = CHAN_TO_UBYTE(src[RCOMP]);
@@ -1899,71 +1846,20 @@ _mesa_texstore_bgr888(TEXSTORE_PARAMS)
    return GL_TRUE;
 }
 
-GLboolean
-_mesa_texstore_rgba4444(TEXSTORE_PARAMS)
-{
-   ASSERT(dstFormat == &_mesa_texformat_rgba4444);
-   ASSERT(dstFormat->TexelBytes == 2);
 
-   if (!ctx->_ImageTransferState &&
-       !srcPacking->SwapBytes &&
-       dstFormat == &_mesa_texformat_rgba4444 &&
-       baseInternalFormat == GL_RGBA &&
-       srcFormat == GL_RGBA &&
-       srcType == GL_UNSIGNED_SHORT_4_4_4_4){
-      /* simple memcpy path */
-      memcpy_texture(ctx, dims,
-                     dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
-                     dstRowStride,
-                     dstImageOffsets,
-                     srcWidth, srcHeight, srcDepth, srcFormat, srcType,
-                     srcAddr, srcPacking);
-   }
-   else {
-      /* general path */
-      const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
-                                                 baseInternalFormat,
-                                                 dstFormat->BaseFormat,
-                                                 srcWidth, srcHeight, srcDepth,
-                                                 srcFormat, srcType, srcAddr,
-                                                 srcPacking);
-      const GLchan *src = tempImage;
-      GLint img, row, col;
-      if (!tempImage)
-         return GL_FALSE;
-      _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
-      for (img = 0; img < srcDepth; img++) {
-         GLubyte *dstRow = (GLubyte *) dstAddr
-            + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
-            + dstYoffset * dstRowStride
-            + dstXoffset * dstFormat->TexelBytes;
-         for (row = 0; row < srcHeight; row++) {
-            GLushort *dstUS = (GLushort *) dstRow;
-           for (col = 0; col < srcWidth; col++) {
-             dstUS[col] = PACK_COLOR_4444( CHAN_TO_UBYTE(src[RCOMP]),
-                                           CHAN_TO_UBYTE(src[GCOMP]),
-                                           CHAN_TO_UBYTE(src[BCOMP]),
-                                           CHAN_TO_UBYTE(src[ACOMP]) );
-             src += 4;
-            }
-            dstRow += dstRowStride;
-         }
-      }
-      _mesa_free((void *) tempImage);
-   }
-   return GL_TRUE;
-}
-
-GLboolean
+static GLboolean
 _mesa_texstore_argb4444(TEXSTORE_PARAMS)
 {
-   ASSERT(dstFormat == &_mesa_texformat_argb4444 ||
-          dstFormat == &_mesa_texformat_argb4444_rev);
-   ASSERT(dstFormat->TexelBytes == 2);
+   const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+   const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
+
+   ASSERT(dstFormat == MESA_FORMAT_ARGB4444 ||
+          dstFormat == MESA_FORMAT_ARGB4444_REV);
+   ASSERT(texelBytes == 2);
 
    if (!ctx->_ImageTransferState &&
        !srcPacking->SwapBytes &&
-       dstFormat == &_mesa_texformat_argb4444 &&
+       dstFormat == MESA_FORMAT_ARGB4444 &&
        baseInternalFormat == GL_RGBA &&
        srcFormat == GL_BGRA &&
        srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV) {
@@ -1979,7 +1875,7 @@ _mesa_texstore_argb4444(TEXSTORE_PARAMS)
       /* general path */
       const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
                                                  baseInternalFormat,
-                                                 dstFormat->BaseFormat,
+                                                 baseFormat,
                                                  srcWidth, srcHeight, srcDepth,
                                                  srcFormat, srcType, srcAddr,
                                                  srcPacking);
@@ -1990,12 +1886,12 @@ _mesa_texstore_argb4444(TEXSTORE_PARAMS)
       _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
       for (img = 0; img < srcDepth; img++) {
          GLubyte *dstRow = (GLubyte *) dstAddr
-            + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+            + dstImageOffsets[dstZoffset + img] * texelBytes
             + dstYoffset * dstRowStride
-            + dstXoffset * dstFormat->TexelBytes;
+            + dstXoffset * texelBytes;
          for (row = 0; row < srcHeight; row++) {
             GLushort *dstUS = (GLushort *) dstRow;
-            if (dstFormat == &_mesa_texformat_argb4444) {
+            if (dstFormat == MESA_FORMAT_ARGB4444) {
                for (col = 0; col < srcWidth; col++) {
                   dstUS[col] = PACK_COLOR_4444( CHAN_TO_UBYTE(src[ACOMP]),
                                                 CHAN_TO_UBYTE(src[RCOMP]),
@@ -2021,15 +1917,18 @@ _mesa_texstore_argb4444(TEXSTORE_PARAMS)
    return GL_TRUE;
 }
 
-GLboolean
+static GLboolean
 _mesa_texstore_rgba5551(TEXSTORE_PARAMS)
 {
-   ASSERT(dstFormat == &_mesa_texformat_rgba5551);
-   ASSERT(dstFormat->TexelBytes == 2);
+   const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+   const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
+
+   ASSERT(dstFormat == MESA_FORMAT_RGBA5551);
+   ASSERT(texelBytes == 2);
 
    if (!ctx->_ImageTransferState &&
        !srcPacking->SwapBytes &&
-       dstFormat == &_mesa_texformat_rgba5551 &&
+       dstFormat == MESA_FORMAT_RGBA5551 &&
        baseInternalFormat == GL_RGBA &&
        srcFormat == GL_RGBA &&
        srcType == GL_UNSIGNED_SHORT_5_5_5_1) {
@@ -2045,7 +1944,7 @@ _mesa_texstore_rgba5551(TEXSTORE_PARAMS)
       /* general path */
       const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
                                                  baseInternalFormat,
-                                                 dstFormat->BaseFormat,
+                                                 baseFormat,
                                                  srcWidth, srcHeight, srcDepth,
                                                  srcFormat, srcType, srcAddr,
                                                  srcPacking);
@@ -2056,9 +1955,9 @@ _mesa_texstore_rgba5551(TEXSTORE_PARAMS)
       _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
       for (img = 0; img < srcDepth; img++) {
          GLubyte *dstRow = (GLubyte *) dstAddr
-            + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+            + dstImageOffsets[dstZoffset + img] * texelBytes
             + dstYoffset * dstRowStride
-            + dstXoffset * dstFormat->TexelBytes;
+            + dstXoffset * texelBytes;
          for (row = 0; row < srcHeight; row++) {
             GLushort *dstUS = (GLushort *) dstRow;
            for (col = 0; col < srcWidth; col++) {
@@ -2076,16 +1975,19 @@ _mesa_texstore_rgba5551(TEXSTORE_PARAMS)
    return GL_TRUE;
 }
 
-GLboolean
+static GLboolean
 _mesa_texstore_argb1555(TEXSTORE_PARAMS)
 {
-   ASSERT(dstFormat == &_mesa_texformat_argb1555 ||
-          dstFormat == &_mesa_texformat_argb1555_rev);
-   ASSERT(dstFormat->TexelBytes == 2);
+   const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+   const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
+
+   ASSERT(dstFormat == MESA_FORMAT_ARGB1555 ||
+          dstFormat == MESA_FORMAT_ARGB1555_REV);
+   ASSERT(texelBytes == 2);
 
    if (!ctx->_ImageTransferState &&
        !srcPacking->SwapBytes &&
-       dstFormat == &_mesa_texformat_argb1555 &&
+       dstFormat == MESA_FORMAT_ARGB1555 &&
        baseInternalFormat == GL_RGBA &&
        srcFormat == GL_BGRA &&
        srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV) {
@@ -2101,7 +2003,7 @@ _mesa_texstore_argb1555(TEXSTORE_PARAMS)
       /* general path */
       const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
                                                  baseInternalFormat,
-                                                 dstFormat->BaseFormat,
+                                                 baseFormat,
                                                  srcWidth, srcHeight, srcDepth,
                                                  srcFormat, srcType, srcAddr,
                                                  srcPacking);
@@ -2112,12 +2014,12 @@ _mesa_texstore_argb1555(TEXSTORE_PARAMS)
       _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
       for (img = 0; img < srcDepth; img++) {
          GLubyte *dstRow = (GLubyte *) dstAddr
-            + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+            + dstImageOffsets[dstZoffset + img] * texelBytes
             + dstYoffset * dstRowStride
-            + dstXoffset * dstFormat->TexelBytes;
+            + dstXoffset * texelBytes;
          for (row = 0; row < srcHeight; row++) {
             GLushort *dstUS = (GLushort *) dstRow;
-            if (dstFormat == &_mesa_texformat_argb1555) {
+            if (dstFormat == MESA_FORMAT_ARGB1555) {
                for (col = 0; col < srcWidth; col++) {
                   dstUS[col] = PACK_COLOR_1555( CHAN_TO_UBYTE(src[ACOMP]),
                                                 CHAN_TO_UBYTE(src[RCOMP]),
@@ -2144,18 +2046,20 @@ _mesa_texstore_argb1555(TEXSTORE_PARAMS)
 }
 
 
-GLboolean
+static GLboolean
 _mesa_texstore_al88(TEXSTORE_PARAMS)
 {
    const GLboolean littleEndian = _mesa_little_endian();
+   const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+   const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
 
-   ASSERT(dstFormat == &_mesa_texformat_al88 ||
-          dstFormat == &_mesa_texformat_al88_rev);
-   ASSERT(dstFormat->TexelBytes == 2);
+   ASSERT(dstFormat == MESA_FORMAT_AL88 ||
+          dstFormat == MESA_FORMAT_AL88_REV);
+   ASSERT(texelBytes == 2);
 
    if (!ctx->_ImageTransferState &&
        !srcPacking->SwapBytes &&
-       dstFormat == &_mesa_texformat_al88 &&
+       dstFormat == MESA_FORMAT_AL88 &&
        baseInternalFormat == GL_LUMINANCE_ALPHA &&
        srcFormat == GL_LUMINANCE_ALPHA &&
        srcType == GL_UNSIGNED_BYTE &&
@@ -2178,8 +2082,8 @@ _mesa_texstore_al88(TEXSTORE_PARAMS)
 
       /* dstmap - how to swizzle from RGBA to dst format:
        */
-      if ((littleEndian && dstFormat == &_mesa_texformat_al88) ||
-         (!littleEndian && dstFormat == &_mesa_texformat_al88_rev)) {
+      if ((littleEndian && dstFormat == MESA_FORMAT_AL88) ||
+         (!littleEndian && dstFormat == MESA_FORMAT_AL88_REV)) {
         dstmap[0] = 0;
         dstmap[1] = 3;
       }
@@ -2204,7 +2108,7 @@ _mesa_texstore_al88(TEXSTORE_PARAMS)
       /* general path */
       const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
                                                  baseInternalFormat,
-                                                 dstFormat->BaseFormat,
+                                                 baseFormat,
                                                  srcWidth, srcHeight, srcDepth,
                                                  srcFormat, srcType, srcAddr,
                                                  srcPacking);
@@ -2215,12 +2119,12 @@ _mesa_texstore_al88(TEXSTORE_PARAMS)
       _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
       for (img = 0; img < srcDepth; img++) {
          GLubyte *dstRow = (GLubyte *) dstAddr
-            + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+            + dstImageOffsets[dstZoffset + img] * texelBytes
             + dstYoffset * dstRowStride
-            + dstXoffset * dstFormat->TexelBytes;
+            + dstXoffset * texelBytes;
          for (row = 0; row < srcHeight; row++) {
             GLushort *dstUS = (GLushort *) dstRow;
-            if (dstFormat == &_mesa_texformat_al88) {
+            if (dstFormat == MESA_FORMAT_AL88) {
                for (col = 0; col < srcWidth; col++) {
                   /* src[0] is luminance, src[1] is alpha */
                  dstUS[col] = PACK_COLOR_88( CHAN_TO_UBYTE(src[1]),
@@ -2245,11 +2149,89 @@ _mesa_texstore_al88(TEXSTORE_PARAMS)
 }
 
 
-GLboolean
+static GLboolean
+_mesa_texstore_al1616(TEXSTORE_PARAMS)
+{
+   const GLboolean littleEndian = _mesa_little_endian();
+   const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+   const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
+
+   ASSERT(dstFormat == MESA_FORMAT_AL1616 ||
+          dstFormat == MESA_FORMAT_AL1616_REV);
+   ASSERT(texelBytes == 4);
+
+   if (!ctx->_ImageTransferState &&
+       !srcPacking->SwapBytes &&
+       dstFormat == MESA_FORMAT_AL1616 &&
+       baseInternalFormat == GL_LUMINANCE_ALPHA &&
+       srcFormat == GL_LUMINANCE_ALPHA &&
+       srcType == GL_UNSIGNED_SHORT &&
+       littleEndian) {
+      /* simple memcpy path */
+      memcpy_texture(ctx, dims,
+                     dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+                     dstRowStride,
+                     dstImageOffsets,
+                     srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+                     srcAddr, srcPacking);
+   }
+   else {
+      /* general path */
+      const GLfloat *tempImage = make_temp_float_image(ctx, dims,
+                                                 baseInternalFormat,
+                                                 baseFormat,
+                                                 srcWidth, srcHeight, srcDepth,
+                                                 srcFormat, srcType, srcAddr,
+                                                 srcPacking);
+      const GLfloat *src = tempImage;
+      GLint img, row, col;
+      if (!tempImage)
+         return GL_FALSE;
+      _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+      for (img = 0; img < srcDepth; img++) {
+         GLubyte *dstRow = (GLubyte *) dstAddr
+            + dstImageOffsets[dstZoffset + img] * texelBytes
+            + dstYoffset * dstRowStride
+            + dstXoffset * texelBytes;
+         for (row = 0; row < srcHeight; row++) {
+            GLuint *dstUI = (GLuint *) dstRow;
+            if (dstFormat == MESA_FORMAT_AL1616) {
+               for (col = 0; col < srcWidth; col++) {
+                 GLushort l, a;
+
+                 UNCLAMPED_FLOAT_TO_USHORT(l, src[0]);
+                 UNCLAMPED_FLOAT_TO_USHORT(a, src[1]);
+                 dstUI[col] = PACK_COLOR_1616(a, l);
+                 src += 2;
+               }
+            }
+            else {
+               for (col = 0; col < srcWidth; col++) {
+                 GLushort l, a;
+
+                 UNCLAMPED_FLOAT_TO_USHORT(l, src[0]);
+                 UNCLAMPED_FLOAT_TO_USHORT(a, src[1]);
+                 dstUI[col] = PACK_COLOR_1616_REV(a, l);
+                 src += 2;
+               }
+            }
+            dstRow += dstRowStride;
+         }
+      }
+      _mesa_free((void *) tempImage);
+   }
+   return GL_TRUE;
+}
+
+
+static GLboolean
 _mesa_texstore_rgb332(TEXSTORE_PARAMS)
 {
-   ASSERT(dstFormat == &_mesa_texformat_rgb332);
-   ASSERT(dstFormat->TexelBytes == 1);
+   const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+   const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
+
+   ASSERT(dstFormat == MESA_FORMAT_RGB332);
+   ASSERT(texelBytes == 1);
 
    if (!ctx->_ImageTransferState &&
        !srcPacking->SwapBytes &&
@@ -2267,7 +2249,7 @@ _mesa_texstore_rgb332(TEXSTORE_PARAMS)
       /* general path */
       const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
                                                  baseInternalFormat,
-                                                 dstFormat->BaseFormat,
+                                                 baseFormat,
                                                  srcWidth, srcHeight, srcDepth,
                                                  srcFormat, srcType, srcAddr,
                                                  srcPacking);
@@ -2278,9 +2260,9 @@ _mesa_texstore_rgb332(TEXSTORE_PARAMS)
       _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
       for (img = 0; img < srcDepth; img++) {
          GLubyte *dstRow = (GLubyte *) dstAddr
-            + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+            + dstImageOffsets[dstZoffset + img] * texelBytes
             + dstYoffset * dstRowStride
-            + dstXoffset * dstFormat->TexelBytes;
+            + dstXoffset * texelBytes;
          for (row = 0; row < srcHeight; row++) {
             for (col = 0; col < srcWidth; col++) {
                dstRow[col] = PACK_COLOR_332( CHAN_TO_UBYTE(src[RCOMP]),
@@ -2300,13 +2282,16 @@ _mesa_texstore_rgb332(TEXSTORE_PARAMS)
 /**
  * Texstore for _mesa_texformat_a8, _mesa_texformat_l8, _mesa_texformat_i8.
  */
-GLboolean
+static GLboolean
 _mesa_texstore_a8(TEXSTORE_PARAMS)
 {
-   ASSERT(dstFormat == &_mesa_texformat_a8 ||
-          dstFormat == &_mesa_texformat_l8 ||
-          dstFormat == &_mesa_texformat_i8);
-   ASSERT(dstFormat->TexelBytes == 1);
+   const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+   const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
+
+   ASSERT(dstFormat == MESA_FORMAT_A8 ||
+          dstFormat == MESA_FORMAT_L8 ||
+          dstFormat == MESA_FORMAT_I8);
+   ASSERT(texelBytes == 1);
 
    if (!ctx->_ImageTransferState &&
        !srcPacking->SwapBytes &&
@@ -2329,7 +2314,7 @@ _mesa_texstore_a8(TEXSTORE_PARAMS)
 
       /* dstmap - how to swizzle from RGBA to dst format:
        */
-      if (dstFormat == &_mesa_texformat_a8) {
+      if (dstFormat == MESA_FORMAT_A8) {
         dstmap[0] = 3;
       }
       else {
@@ -2353,7 +2338,7 @@ _mesa_texstore_a8(TEXSTORE_PARAMS)
       /* general path */
       const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
                                                  baseInternalFormat,
-                                                 dstFormat->BaseFormat,
+                                                 baseFormat,
                                                  srcWidth, srcHeight, srcDepth,
                                                  srcFormat, srcType, srcAddr,
                                                  srcPacking);
@@ -2364,9 +2349,9 @@ _mesa_texstore_a8(TEXSTORE_PARAMS)
       _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
       for (img = 0; img < srcDepth; img++) {
          GLubyte *dstRow = (GLubyte *) dstAddr
-            + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+            + dstImageOffsets[dstZoffset + img] * texelBytes
             + dstYoffset * dstRowStride
-            + dstXoffset * dstFormat->TexelBytes;
+            + dstXoffset * texelBytes;
          for (row = 0; row < srcHeight; row++) {
             for (col = 0; col < srcWidth; col++) {
                dstRow[col] = CHAN_TO_UBYTE(src[col]);
@@ -2382,12 +2367,14 @@ _mesa_texstore_a8(TEXSTORE_PARAMS)
 
 
 
-GLboolean
+static GLboolean
 _mesa_texstore_ci8(TEXSTORE_PARAMS)
 {
+   const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+
    (void) dims; (void) baseInternalFormat;
-   ASSERT(dstFormat == &_mesa_texformat_ci8);
-   ASSERT(dstFormat->TexelBytes == 1);
+   ASSERT(dstFormat == MESA_FORMAT_CI8);
+   ASSERT(texelBytes == 1);
    ASSERT(baseInternalFormat == GL_COLOR_INDEX);
 
    if (!ctx->_ImageTransferState &&
@@ -2407,9 +2394,9 @@ _mesa_texstore_ci8(TEXSTORE_PARAMS)
       GLint img, row;
       for (img = 0; img < srcDepth; img++) {
          GLubyte *dstRow = (GLubyte *) dstAddr
-            + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+            + dstImageOffsets[dstZoffset + img] * texelBytes
             + dstYoffset * dstRowStride
-            + dstXoffset * dstFormat->TexelBytes;
+            + dstXoffset * texelBytes;
          for (row = 0; row < srcHeight; row++) {
             const GLvoid *src = _mesa_image_address(dims, srcPacking,
                 srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
@@ -2425,17 +2412,19 @@ _mesa_texstore_ci8(TEXSTORE_PARAMS)
 
 
 /**
- * Texstore for _mesa_texformat_ycbcr or _mesa_texformat_ycbcr_rev.
+ * Texstore for _mesa_texformat_ycbcr or _mesa_texformat_ycbcr_REV.
  */
-GLboolean
+static GLboolean
 _mesa_texstore_ycbcr(TEXSTORE_PARAMS)
 {
    const GLboolean littleEndian = _mesa_little_endian();
+   const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+
    (void) ctx; (void) dims; (void) baseInternalFormat;
 
-   ASSERT((dstFormat == &_mesa_texformat_ycbcr) ||
-          (dstFormat == &_mesa_texformat_ycbcr_rev));
-   ASSERT(dstFormat->TexelBytes == 2);
+   ASSERT((dstFormat == MESA_FORMAT_YCBCR) ||
+          (dstFormat == MESA_FORMAT_YCBCR_REV));
+   ASSERT(texelBytes == 2);
    ASSERT(ctx->Extensions.MESA_ycbcr_texture);
    ASSERT(srcFormat == GL_YCBCR_MESA);
    ASSERT((srcType == GL_UNSIGNED_SHORT_8_8_MESA) ||
@@ -2454,14 +2443,14 @@ _mesa_texstore_ycbcr(TEXSTORE_PARAMS)
    /* XXX the logic here _might_ be wrong */
    if (srcPacking->SwapBytes ^
        (srcType == GL_UNSIGNED_SHORT_8_8_REV_MESA) ^
-       (dstFormat == &_mesa_texformat_ycbcr_rev) ^
+       (dstFormat == MESA_FORMAT_YCBCR_REV) ^
        !littleEndian) {
       GLint img, row;
       for (img = 0; img < srcDepth; img++) {
          GLubyte *dstRow = (GLubyte *) dstAddr
-            + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+            + dstImageOffsets[dstZoffset + img] * texelBytes
             + dstYoffset * dstRowStride
-            + dstXoffset * dstFormat->TexelBytes;
+            + dstXoffset * texelBytes;
          for (row = 0; row < srcHeight; row++) {
             _mesa_swap2((GLushort *) dstRow, srcWidth);
             dstRow += dstRowStride;
@@ -2471,13 +2460,14 @@ _mesa_texstore_ycbcr(TEXSTORE_PARAMS)
    return GL_TRUE;
 }
 
-GLboolean
+static GLboolean
 _mesa_texstore_dudv8(TEXSTORE_PARAMS)
 {
    const GLboolean littleEndian = _mesa_little_endian();
+   const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
 
-   ASSERT(dstFormat == &_mesa_texformat_dudv8);
-   ASSERT(dstFormat->TexelBytes == 2);
+   ASSERT(dstFormat == MESA_FORMAT_DUDV8);
+   ASSERT(texelBytes == 2);
    ASSERT(ctx->Extensions.ATI_envmap_bumpmap);
    ASSERT((srcFormat == GL_DU8DV8_ATI) ||
          (srcFormat == GL_DUDV_ATI));
@@ -2523,8 +2513,8 @@ _mesa_texstore_dudv8(TEXSTORE_PARAMS)
    else {
       /* general path - note this is defined for 2d textures only */
       const GLint components = _mesa_components_in_format(baseInternalFormat);
-      const GLint srcStride = _mesa_image_row_stride(srcPacking,
-                                                 srcWidth, srcFormat, srcType);
+      const GLint srcStride = _mesa_image_row_stride(srcPacking, srcWidth,
+                                                     srcFormat, srcType);
       GLbyte *tempImage, *dst, *src;
       GLint row;
 
@@ -2550,11 +2540,11 @@ _mesa_texstore_dudv8(TEXSTORE_PARAMS)
       src = tempImage;
       dst = (GLbyte *) dstAddr
             + dstYoffset * dstRowStride
-            + dstXoffset * dstFormat->TexelBytes;
+            + dstXoffset * texelBytes;
       for (row = 0; row < srcHeight; row++) {
-         memcpy(dst, src, srcWidth * dstFormat->TexelBytes);
+         memcpy(dst, src, srcWidth * texelBytes);
          dst += dstRowStride;
-         src += srcWidth * dstFormat->TexelBytes;
+         src += srcWidth * texelBytes;
       }
       _mesa_free((void *) tempImage);
    }
@@ -2564,18 +2554,20 @@ _mesa_texstore_dudv8(TEXSTORE_PARAMS)
 /**
  * Store a texture in MESA_FORMAT_SIGNED_RGBA8888 or MESA_FORMAT_SIGNED_RGBA8888_REV
  */
-GLboolean
+static GLboolean
 _mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS)
 {
    const GLboolean littleEndian = _mesa_little_endian();
+   const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+   const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
 
-   ASSERT(dstFormat == &_mesa_texformat_signed_rgba8888 ||
-          dstFormat == &_mesa_texformat_signed_rgba8888_rev);
-   ASSERT(dstFormat->TexelBytes == 4);
+   ASSERT(dstFormat == MESA_FORMAT_SIGNED_RGBA8888 ||
+          dstFormat == MESA_FORMAT_SIGNED_RGBA8888_REV);
+   ASSERT(texelBytes == 4);
 
    if (!ctx->_ImageTransferState &&
        !srcPacking->SwapBytes &&
-       dstFormat == &_mesa_texformat_signed_rgba8888 &&
+       dstFormat == MESA_FORMAT_SIGNED_RGBA8888 &&
        baseInternalFormat == GL_RGBA &&
       ((srcFormat == GL_RGBA && srcType == GL_BYTE && !littleEndian) ||
        (srcFormat == GL_ABGR_EXT && srcType == GL_BYTE && littleEndian))) {
@@ -2589,7 +2581,7 @@ _mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS)
    }
    else if (!ctx->_ImageTransferState &&
        !srcPacking->SwapBytes &&
-       dstFormat == &_mesa_texformat_signed_rgba8888_rev &&
+       dstFormat == MESA_FORMAT_SIGNED_RGBA8888_REV &&
        baseInternalFormat == GL_RGBA &&
       ((srcFormat == GL_RGBA && srcType == GL_BYTE && littleEndian) ||
        (srcFormat == GL_ABGR_EXT && srcType == GL_BYTE && !littleEndian))) {
@@ -2610,8 +2602,8 @@ _mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS)
 
       /* dstmap - how to swizzle from RGBA to dst format:
        */
-      if ((littleEndian && dstFormat == &_mesa_texformat_signed_rgba8888) ||
-         (!littleEndian && dstFormat == &_mesa_texformat_signed_rgba8888_rev)) {
+      if ((littleEndian && dstFormat == MESA_FORMAT_SIGNED_RGBA8888) ||
+         (!littleEndian && dstFormat == MESA_FORMAT_SIGNED_RGBA8888_REV)) {
         dstmap[3] = 0;
         dstmap[2] = 1;
         dstmap[1] = 2;
@@ -2638,7 +2630,7 @@ _mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS)
       /* general path */
       const GLfloat *tempImage = make_temp_float_image(ctx, dims,
                                                  baseInternalFormat,
-                                                 dstFormat->BaseFormat,
+                                                 baseFormat,
                                                  srcWidth, srcHeight, srcDepth,
                                                  srcFormat, srcType, srcAddr,
                                                  srcPacking);
@@ -2649,12 +2641,12 @@ _mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS)
       _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
       for (img = 0; img < srcDepth; img++) {
          GLubyte *dstRow = (GLubyte *) dstAddr
-            + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+            + dstImageOffsets[dstZoffset + img] * texelBytes
             + dstYoffset * dstRowStride
-            + dstXoffset * dstFormat->TexelBytes;
+            + dstXoffset * texelBytes;
          for (row = 0; row < srcHeight; row++) {
             GLuint *dstUI = (GLuint *) dstRow;
-            if (dstFormat == &_mesa_texformat_signed_rgba8888) {
+            if (dstFormat == MESA_FORMAT_SIGNED_RGBA8888) {
                for (col = 0; col < srcWidth; col++) {
                   dstUI[col] = PACK_COLOR_8888( FLOAT_TO_BYTE_TEX(srcRow[RCOMP]),
                                                 FLOAT_TO_BYTE_TEX(srcRow[GCOMP]),
@@ -2683,7 +2675,7 @@ _mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS)
 /**
  * Store a combined depth/stencil texture image.
  */
-GLboolean
+static GLboolean
 _mesa_texstore_z24_s8(TEXSTORE_PARAMS)
 {
    const GLfloat depthScale = (GLfloat) 0xffffff;
@@ -2692,7 +2684,7 @@ _mesa_texstore_z24_s8(TEXSTORE_PARAMS)
       / sizeof(GLuint);
    GLint img, row;
 
-   ASSERT(dstFormat == &_mesa_texformat_z24_s8);
+   ASSERT(dstFormat == MESA_FORMAT_Z24_S8);
    ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT || srcFormat == GL_DEPTH_COMPONENT);
    ASSERT(srcFormat != GL_DEPTH_STENCIL_EXT || srcType == GL_UNSIGNED_INT_24_8_EXT);
 
@@ -2784,7 +2776,7 @@ _mesa_texstore_z24_s8(TEXSTORE_PARAMS)
 /**
  * Store a combined depth/stencil texture image.
  */
-GLboolean
+static GLboolean
 _mesa_texstore_s8_z24(TEXSTORE_PARAMS)
 {
    const GLuint depthScale = 0xffffff;
@@ -2793,7 +2785,7 @@ _mesa_texstore_s8_z24(TEXSTORE_PARAMS)
       / sizeof(GLuint);
    GLint img, row;
 
-   ASSERT(dstFormat == &_mesa_texformat_s8_z24);
+   ASSERT(dstFormat == MESA_FORMAT_S8_Z24);
    ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT || srcFormat == GL_DEPTH_COMPONENT);
    ASSERT(srcFormat != GL_DEPTH_STENCIL_EXT || srcType == GL_UNSIGNED_INT_24_8_EXT);
 
@@ -2873,24 +2865,26 @@ _mesa_texstore_s8_z24(TEXSTORE_PARAMS)
  *   _mesa_texformat_luminance_alpha_float32
  *   _mesa_texformat_intensity_float32
  */
-GLboolean
+static GLboolean
 _mesa_texstore_rgba_float32(TEXSTORE_PARAMS)
 {
-   const GLint components = _mesa_components_in_format(dstFormat->BaseFormat);
-
-   ASSERT(dstFormat == &_mesa_texformat_rgba_float32 ||
-          dstFormat == &_mesa_texformat_rgb_float32 ||
-          dstFormat == &_mesa_texformat_alpha_float32 ||
-          dstFormat == &_mesa_texformat_luminance_float32 ||
-          dstFormat == &_mesa_texformat_luminance_alpha_float32 ||
-          dstFormat == &_mesa_texformat_intensity_float32);
+   const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+   const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
+   const GLint components = _mesa_components_in_format(baseFormat);
+
+   ASSERT(dstFormat == MESA_FORMAT_RGBA_FLOAT32 ||
+          dstFormat == MESA_FORMAT_RGB_FLOAT32 ||
+          dstFormat == MESA_FORMAT_ALPHA_FLOAT32 ||
+          dstFormat == MESA_FORMAT_LUMINANCE_FLOAT32 ||
+          dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32 ||
+          dstFormat == MESA_FORMAT_INTENSITY_FLOAT32);
    ASSERT(baseInternalFormat == GL_RGBA ||
           baseInternalFormat == GL_RGB ||
           baseInternalFormat == GL_ALPHA ||
           baseInternalFormat == GL_LUMINANCE ||
           baseInternalFormat == GL_LUMINANCE_ALPHA ||
           baseInternalFormat == GL_INTENSITY);
-   ASSERT(dstFormat->TexelBytes == components * sizeof(GLfloat));
+   ASSERT(texelBytes == components * sizeof(GLfloat));
 
    if (!ctx->_ImageTransferState &&
        !srcPacking->SwapBytes &&
@@ -2908,7 +2902,7 @@ _mesa_texstore_rgba_float32(TEXSTORE_PARAMS)
       /* general path */
       const GLfloat *tempImage = make_temp_float_image(ctx, dims,
                                                  baseInternalFormat,
-                                                 dstFormat->BaseFormat,
+                                                 baseFormat,
                                                  srcWidth, srcHeight, srcDepth,
                                                  srcFormat, srcType, srcAddr,
                                                  srcPacking);
@@ -2921,9 +2915,9 @@ _mesa_texstore_rgba_float32(TEXSTORE_PARAMS)
       bytesPerRow = srcWidth * components * sizeof(GLfloat);
       for (img = 0; img < srcDepth; img++) {
          GLubyte *dstRow = (GLubyte *) dstAddr
-            + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+            + dstImageOffsets[dstZoffset + img] * texelBytes
             + dstYoffset * dstRowStride
-            + dstXoffset * dstFormat->TexelBytes;
+            + dstXoffset * texelBytes;
          for (row = 0; row < srcHeight; row++) {
             _mesa_memcpy(dstRow, srcRow, bytesPerRow);
             dstRow += dstRowStride;
@@ -2940,24 +2934,26 @@ _mesa_texstore_rgba_float32(TEXSTORE_PARAMS)
 /**
  * As above, but store 16-bit floats.
  */
-GLboolean
+static GLboolean
 _mesa_texstore_rgba_float16(TEXSTORE_PARAMS)
 {
-   const GLint components = _mesa_components_in_format(dstFormat->BaseFormat);
-
-   ASSERT(dstFormat == &_mesa_texformat_rgba_float16 ||
-          dstFormat == &_mesa_texformat_rgb_float16 ||
-          dstFormat == &_mesa_texformat_alpha_float16 ||
-          dstFormat == &_mesa_texformat_luminance_float16 ||
-          dstFormat == &_mesa_texformat_luminance_alpha_float16 ||
-          dstFormat == &_mesa_texformat_intensity_float16);
+   const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+   const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
+   const GLint components = _mesa_components_in_format(baseFormat);
+
+   ASSERT(dstFormat == MESA_FORMAT_RGBA_FLOAT16 ||
+          dstFormat == MESA_FORMAT_RGB_FLOAT16 ||
+          dstFormat == MESA_FORMAT_ALPHA_FLOAT16 ||
+          dstFormat == MESA_FORMAT_LUMINANCE_FLOAT16 ||
+          dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16 ||
+          dstFormat == MESA_FORMAT_INTENSITY_FLOAT16);
    ASSERT(baseInternalFormat == GL_RGBA ||
           baseInternalFormat == GL_RGB ||
           baseInternalFormat == GL_ALPHA ||
           baseInternalFormat == GL_LUMINANCE ||
           baseInternalFormat == GL_LUMINANCE_ALPHA ||
           baseInternalFormat == GL_INTENSITY);
-   ASSERT(dstFormat->TexelBytes == components * sizeof(GLhalfARB));
+   ASSERT(texelBytes == components * sizeof(GLhalfARB));
 
    if (!ctx->_ImageTransferState &&
        !srcPacking->SwapBytes &&
@@ -2975,7 +2971,7 @@ _mesa_texstore_rgba_float16(TEXSTORE_PARAMS)
       /* general path */
       const GLfloat *tempImage = make_temp_float_image(ctx, dims,
                                                  baseInternalFormat,
-                                                 dstFormat->BaseFormat,
+                                                 baseFormat,
                                                  srcWidth, srcHeight, srcDepth,
                                                  srcFormat, srcType, srcAddr,
                                                  srcPacking);
@@ -2986,9 +2982,9 @@ _mesa_texstore_rgba_float16(TEXSTORE_PARAMS)
       _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
       for (img = 0; img < srcDepth; img++) {
          GLubyte *dstRow = (GLubyte *) dstAddr
-            + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+            + dstImageOffsets[dstZoffset + img] * texelBytes
             + dstYoffset * dstRowStride
-            + dstXoffset * dstFormat->TexelBytes;
+            + dstXoffset * texelBytes;
          for (row = 0; row < srcHeight; row++) {
             GLhalfARB *dstTexel = (GLhalfARB *) dstRow;
             GLint i;
@@ -3007,20 +3003,18 @@ _mesa_texstore_rgba_float16(TEXSTORE_PARAMS)
 
 
 #if FEATURE_EXT_texture_sRGB
-GLboolean
+static GLboolean
 _mesa_texstore_srgb8(TEXSTORE_PARAMS)
 {
-   const struct gl_texture_format *newDstFormat;
-   StoreTexImageFunc store;
+   gl_format newDstFormat;
    GLboolean k;
 
-   ASSERT(dstFormat == &_mesa_texformat_srgb8);
+   ASSERT(dstFormat == MESA_FORMAT_SRGB8);
 
    /* reuse normal rgb texstore code */
-   newDstFormat = &_mesa_texformat_rgb888;
-   store = _mesa_texstore_rgb888;
+   newDstFormat = MESA_FORMAT_RGB888;
 
-   k = store(ctx, dims, baseInternalFormat,
+   k = _mesa_texstore_rgb888(ctx, dims, baseInternalFormat,
              newDstFormat, dstAddr,
              dstXoffset, dstYoffset, dstZoffset,
              dstRowStride, dstImageOffsets,
@@ -3031,17 +3025,16 @@ _mesa_texstore_srgb8(TEXSTORE_PARAMS)
 }
 
 
-GLboolean
+static GLboolean
 _mesa_texstore_srgba8(TEXSTORE_PARAMS)
 {
-   const struct gl_texture_format *newDstFormat;
+   gl_format newDstFormat;
    GLboolean k;
 
-   ASSERT(dstFormat == &_mesa_texformat_srgba8);
+   ASSERT(dstFormat == MESA_FORMAT_SRGBA8);
 
    /* reuse normal rgba texstore code */
-   newDstFormat = &_mesa_texformat_rgba8888;
-
+   newDstFormat = MESA_FORMAT_RGBA8888;
    k = _mesa_texstore_rgba8888(ctx, dims, baseInternalFormat,
                                newDstFormat, dstAddr,
                                dstXoffset, dstYoffset, dstZoffset,
@@ -3053,16 +3046,16 @@ _mesa_texstore_srgba8(TEXSTORE_PARAMS)
 }
 
 
-GLboolean
+static GLboolean
 _mesa_texstore_sargb8(TEXSTORE_PARAMS)
 {
-   const struct gl_texture_format *newDstFormat;
+   gl_format newDstFormat;
    GLboolean k;
 
-   ASSERT(dstFormat == &_mesa_texformat_sargb8);
+   ASSERT(dstFormat == MESA_FORMAT_SARGB8);
 
    /* reuse normal rgba texstore code */
-   newDstFormat = &_mesa_texformat_argb8888;
+   newDstFormat = MESA_FORMAT_ARGB8888;
 
    k = _mesa_texstore_argb8888(ctx, dims, baseInternalFormat,
                                newDstFormat, dstAddr,
@@ -3075,15 +3068,15 @@ _mesa_texstore_sargb8(TEXSTORE_PARAMS)
 }
 
 
-GLboolean
+static GLboolean
 _mesa_texstore_sl8(TEXSTORE_PARAMS)
 {
-   const struct gl_texture_format *newDstFormat;
+   gl_format newDstFormat;
    GLboolean k;
 
-   ASSERT(dstFormat == &_mesa_texformat_sl8);
+   ASSERT(dstFormat == MESA_FORMAT_SL8);
 
-   newDstFormat = &_mesa_texformat_l8;
+   newDstFormat = MESA_FORMAT_L8;
 
    /* _mesa_textore_a8 handles luminance8 too */
    k = _mesa_texstore_a8(ctx, dims, baseInternalFormat,
@@ -3097,16 +3090,16 @@ _mesa_texstore_sl8(TEXSTORE_PARAMS)
 }
 
 
-GLboolean
+static GLboolean
 _mesa_texstore_sla8(TEXSTORE_PARAMS)
 {
-   const struct gl_texture_format *newDstFormat;
+   gl_format newDstFormat;
    GLboolean k;
 
-   ASSERT(dstFormat == &_mesa_texformat_sla8);
+   ASSERT(dstFormat == MESA_FORMAT_SLA8);
 
    /* reuse normal luminance/alpha texstore code */
-   newDstFormat = &_mesa_texformat_al88;
+   newDstFormat = MESA_FORMAT_AL88;
 
    k = _mesa_texstore_al88(ctx, dims, baseInternalFormat,
                            newDstFormat, dstAddr,
@@ -3118,9 +3111,160 @@ _mesa_texstore_sla8(TEXSTORE_PARAMS)
    return k;
 }
 
+#else
+
+/* these are used only in texstore_funcs[] below */
+#define _mesa_texstore_srgb8 NULL
+#define _mesa_texstore_srgba8 NULL
+#define _mesa_texstore_sargb8 NULL
+#define _mesa_texstore_sl8 NULL
+#define _mesa_texstore_sla8 NULL
+
 #endif /* FEATURE_EXT_texture_sRGB */
 
 
+
+
+/**
+ * Table mapping MESA_FORMAT_8 to _mesa_texstore_*()
+ * XXX this is somewhat temporary.
+ */
+static const struct {
+   gl_format Name;
+   StoreTexImageFunc Store;
+}
+texstore_funcs[MESA_FORMAT_COUNT] =
+{
+   { MESA_FORMAT_NONE, NULL },
+   { MESA_FORMAT_RGBA8888, _mesa_texstore_rgba8888 },
+   { MESA_FORMAT_RGBA8888_REV, _mesa_texstore_rgba8888 },
+   { MESA_FORMAT_ARGB8888, _mesa_texstore_argb8888 },
+   { MESA_FORMAT_ARGB8888_REV, _mesa_texstore_argb8888 },
+   { MESA_FORMAT_XRGB8888, _mesa_texstore_argb8888 },
+   { MESA_FORMAT_XRGB8888_REV, _mesa_texstore_argb8888 },
+   { MESA_FORMAT_RGB888, _mesa_texstore_rgb888 },
+   { MESA_FORMAT_BGR888, _mesa_texstore_bgr888 },
+   { MESA_FORMAT_RGB565, _mesa_texstore_rgb565 },
+   { MESA_FORMAT_RGB565_REV, _mesa_texstore_rgb565 },
+   { MESA_FORMAT_ARGB4444, _mesa_texstore_argb4444 },
+   { MESA_FORMAT_ARGB4444_REV, _mesa_texstore_argb4444 },
+   { MESA_FORMAT_RGBA5551, _mesa_texstore_rgba5551 },
+   { MESA_FORMAT_ARGB1555, _mesa_texstore_argb1555 },
+   { MESA_FORMAT_ARGB1555_REV, _mesa_texstore_argb1555 },
+   { MESA_FORMAT_AL88, _mesa_texstore_al88 },
+   { MESA_FORMAT_AL88_REV, _mesa_texstore_al88 },
+   { MESA_FORMAT_AL1616, _mesa_texstore_al1616 },
+   { MESA_FORMAT_AL1616_REV, _mesa_texstore_al1616 },
+   { MESA_FORMAT_RGB332, _mesa_texstore_rgb332 },
+   { MESA_FORMAT_A8, _mesa_texstore_a8 },
+   { MESA_FORMAT_L8, _mesa_texstore_a8 },
+   { MESA_FORMAT_I8, _mesa_texstore_a8 },
+   { MESA_FORMAT_CI8, _mesa_texstore_ci8 },
+   { MESA_FORMAT_YCBCR, _mesa_texstore_ycbcr },
+   { MESA_FORMAT_YCBCR_REV, _mesa_texstore_ycbcr },
+   { MESA_FORMAT_Z24_S8, _mesa_texstore_z24_s8 },
+   { MESA_FORMAT_S8_Z24, _mesa_texstore_s8_z24 },
+   { MESA_FORMAT_Z16, _mesa_texstore_z16 },
+   { MESA_FORMAT_X8_Z24, _mesa_texstore_x8_z24 },
+   { MESA_FORMAT_Z24_X8, _mesa_texstore_z24_x8 },
+   { MESA_FORMAT_Z32, _mesa_texstore_z32 },
+   { MESA_FORMAT_S8, NULL/*_mesa_texstore_s8*/ },
+   { MESA_FORMAT_SRGB8, _mesa_texstore_srgb8 },
+   { MESA_FORMAT_SRGBA8, _mesa_texstore_srgba8 },
+   { MESA_FORMAT_SARGB8, _mesa_texstore_sargb8 },
+   { MESA_FORMAT_SL8, _mesa_texstore_sl8 },
+   { MESA_FORMAT_SLA8, _mesa_texstore_sla8 },
+   { MESA_FORMAT_SRGB_DXT1, _mesa_texstore_rgb_dxt1 },
+   { MESA_FORMAT_SRGBA_DXT1, _mesa_texstore_rgba_dxt1 },
+   { MESA_FORMAT_SRGBA_DXT3, _mesa_texstore_rgba_dxt3 },
+   { MESA_FORMAT_SRGBA_DXT5, _mesa_texstore_rgba_dxt5 },
+   { MESA_FORMAT_RGB_FXT1, _mesa_texstore_rgb_fxt1 },
+   { MESA_FORMAT_RGBA_FXT1, _mesa_texstore_rgba_fxt1 },
+   { MESA_FORMAT_RGB_DXT1, _mesa_texstore_rgb_dxt1 },
+   { MESA_FORMAT_RGBA_DXT1, _mesa_texstore_rgba_dxt1 },
+   { MESA_FORMAT_RGBA_DXT3, _mesa_texstore_rgba_dxt3 },
+   { MESA_FORMAT_RGBA_DXT5, _mesa_texstore_rgba_dxt5 },
+   { MESA_FORMAT_RGBA_FLOAT32, _mesa_texstore_rgba_float32 },
+   { MESA_FORMAT_RGBA_FLOAT16, _mesa_texstore_rgba_float16 },
+   { MESA_FORMAT_RGB_FLOAT32, _mesa_texstore_rgba_float32 },
+   { MESA_FORMAT_RGB_FLOAT16, _mesa_texstore_rgba_float16 },
+   { MESA_FORMAT_ALPHA_FLOAT32, _mesa_texstore_rgba_float32 },
+   { MESA_FORMAT_ALPHA_FLOAT16, _mesa_texstore_rgba_float16 },
+   { MESA_FORMAT_LUMINANCE_FLOAT32, _mesa_texstore_rgba_float32 },
+   { MESA_FORMAT_LUMINANCE_FLOAT16, _mesa_texstore_rgba_float16 },
+   { MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, _mesa_texstore_rgba_float32 },
+   { MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, _mesa_texstore_rgba_float16 },
+   { MESA_FORMAT_INTENSITY_FLOAT32, _mesa_texstore_rgba_float32 },
+   { MESA_FORMAT_INTENSITY_FLOAT16, _mesa_texstore_rgba_float16 },
+   { MESA_FORMAT_DUDV8, _mesa_texstore_dudv8 },
+   { MESA_FORMAT_SIGNED_RGBA8888, _mesa_texstore_signed_rgba8888 },
+   { MESA_FORMAT_SIGNED_RGBA8888_REV, _mesa_texstore_signed_rgba8888 },
+   { MESA_FORMAT_SIGNED_RGBA_16, NULL },
+};
+
+
+static GLboolean
+_mesa_texstore_null(TEXSTORE_PARAMS)
+{
+   (void) ctx; (void) dims;
+   (void) baseInternalFormat;
+   (void) dstFormat;
+   (void) dstAddr;
+   (void) dstXoffset; (void) dstYoffset; (void) dstZoffset;
+   (void) dstRowStride; (void) dstImageOffsets;
+   (void) srcWidth; (void) srcHeight; (void) srcDepth;
+   (void) srcFormat; (void) srcType;
+   (void) srcAddr;
+   (void) srcPacking;
+
+   /* should never happen */
+   _mesa_problem(NULL, "_mesa_texstore_null() is called");
+   return GL_FALSE;
+}
+
+
+/**
+ * Return the StoreTexImageFunc pointer to store an image in the given format.
+ */
+static StoreTexImageFunc
+_mesa_get_texstore_func(gl_format format)
+{
+#ifdef DEBUG
+   GLuint i;
+   for (i = 0; i < MESA_FORMAT_COUNT; i++) {
+      ASSERT(texstore_funcs[i].Name == i);
+   }
+#endif
+   ASSERT(texstore_funcs[format].Name == format);
+
+   if (texstore_funcs[format].Store)
+      return texstore_funcs[format].Store;
+   else
+      return _mesa_texstore_null;
+}
+
+
+/**
+ * Store user data into texture memory.
+ * Called via glTex[Sub]Image1/2/3D()
+ */
+GLboolean
+_mesa_texstore(TEXSTORE_PARAMS)
+{
+   StoreTexImageFunc storeImage;
+   GLboolean success;
+
+   storeImage = _mesa_get_texstore_func(dstFormat);
+
+   success = storeImage(ctx, dims, baseInternalFormat,
+                        dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+                        dstRowStride, dstImageOffsets,
+                        srcWidth, srcHeight, srcDepth,
+                        srcFormat, srcType, srcAddr, srcPacking);
+   return success;
+}
+
+
 /**
  * Check if an unpack PBO is active prior to fetching a texture image.
  * If so, do bounds checking and map the buffer into main memory.
@@ -3209,113 +3353,23 @@ _mesa_unmap_teximage_pbo(GLcontext *ctx,
 }
 
 
-
-/**
- * Adaptor for fetching a GLchan texel from a float-valued texture.
- */
-static void
-fetch_texel_float_to_chan(const struct gl_texture_image *texImage,
-                          GLint i, GLint j, GLint k, GLchan *texelOut)
+/** Return texture size in bytes */
+static GLuint
+texture_size(const struct gl_texture_image *texImage)
 {
-   GLfloat temp[4];
-   ASSERT(texImage->FetchTexelf);
-   texImage->FetchTexelf(texImage, i, j, k, temp);
-   if (texImage->TexFormat->BaseFormat == GL_DEPTH_COMPONENT ||
-       texImage->TexFormat->BaseFormat == GL_DEPTH_STENCIL_EXT) {
-      /* just one channel */
-      UNCLAMPED_FLOAT_TO_CHAN(texelOut[0], temp[0]);
-   }
-   else {
-      /* four channels */
-      UNCLAMPED_FLOAT_TO_CHAN(texelOut[0], temp[0]);
-      UNCLAMPED_FLOAT_TO_CHAN(texelOut[1], temp[1]);
-      UNCLAMPED_FLOAT_TO_CHAN(texelOut[2], temp[2]);
-      UNCLAMPED_FLOAT_TO_CHAN(texelOut[3], temp[3]);
-   }
+   GLuint sz = _mesa_format_image_size(texImage->TexFormat, texImage->Width,
+                                       texImage->Height, texImage->Depth);
+   return sz;
 }
 
 
-/**
- * Adaptor for fetching a float texel from a GLchan-valued texture.
- */
-static void
-fetch_texel_chan_to_float(const struct gl_texture_image *texImage,
-                          GLint i, GLint j, GLint k, GLfloat *texelOut)
+/** Return row stride in bytes */
+static GLuint
+texture_row_stride(const struct gl_texture_image *texImage)
 {
-   GLchan temp[4];
-   ASSERT(texImage->FetchTexelc);
-   texImage->FetchTexelc(texImage, i, j, k, temp);
-   if (texImage->TexFormat->BaseFormat == GL_DEPTH_COMPONENT ||
-       texImage->TexFormat->BaseFormat == GL_DEPTH_STENCIL_EXT) {
-      /* just one channel */
-      texelOut[0] = CHAN_TO_FLOAT(temp[0]);
-   }
-   else {
-      /* four channels */
-      texelOut[0] = CHAN_TO_FLOAT(temp[0]);
-      texelOut[1] = CHAN_TO_FLOAT(temp[1]);
-      texelOut[2] = CHAN_TO_FLOAT(temp[2]);
-      texelOut[3] = CHAN_TO_FLOAT(temp[3]);
-   }
-}
-
-
-/**
- * Initialize the texture image's FetchTexelc and FetchTexelf methods.
- */
-void
-_mesa_set_fetch_functions(struct gl_texture_image *texImage, GLuint dims)
-{
-   ASSERT(dims == 1 || dims == 2 || dims == 3);
-   ASSERT(texImage->TexFormat);
-
-   switch (dims) {
-   case 1:
-      texImage->FetchTexelc = texImage->TexFormat->FetchTexel1D;
-      texImage->FetchTexelf = texImage->TexFormat->FetchTexel1Df;
-      break;
-   case 2:
-      texImage->FetchTexelc = texImage->TexFormat->FetchTexel2D;
-      texImage->FetchTexelf = texImage->TexFormat->FetchTexel2Df;
-      break;
-   case 3:
-      texImage->FetchTexelc = texImage->TexFormat->FetchTexel3D;
-      texImage->FetchTexelf = texImage->TexFormat->FetchTexel3Df;
-      break;
-   default:
-      ;
-   }
-
-   /* now check if we need to use a float/chan adaptor */
-   if (!texImage->FetchTexelc) {
-      texImage->FetchTexelc = fetch_texel_float_to_chan;
-   }
-   else if (!texImage->FetchTexelf) {
-      texImage->FetchTexelf = fetch_texel_chan_to_float;
-   }
-
-
-   ASSERT(texImage->FetchTexelc);
-   ASSERT(texImage->FetchTexelf);
-}
-
-
-static void
-compute_texture_size(GLcontext *ctx, struct gl_texture_image *texImage)
-{
-   if (texImage->TexFormat->TexelBytes == 0) {
-      /* must be a compressed format */
-      texImage->IsCompressed = GL_TRUE;
-      texImage->CompressedSize =
-         ctx->Driver.CompressedTextureSize(ctx, texImage->Width,
-                                           texImage->Height, texImage->Depth,
-                                           texImage->TexFormat->MesaFormat);
-   }
-   else {
-      /* non-compressed format */
-      texImage->IsCompressed = GL_FALSE;
-      texImage->CompressedSize = 0;
-   }
+   GLuint stride = _mesa_format_row_stride(texImage->TexFormat,
+                                           texImage->Width);
+   return stride;
 }
 
 
@@ -3337,21 +3391,11 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
                        struct gl_texture_object *texObj,
                        struct gl_texture_image *texImage)
 {
-   GLint sizeInBytes;
+   GLuint sizeInBytes;
    (void) border;
 
-   texImage->TexFormat
-      = ctx->Driver.ChooseTextureFormat(ctx, internalFormat, format, type);
-   ASSERT(texImage->TexFormat);
-
-   _mesa_set_fetch_functions(texImage, 1);
-   compute_texture_size(ctx, texImage);
-
    /* allocate memory */
-   if (texImage->IsCompressed)
-      sizeInBytes = texImage->CompressedSize;
-   else
-      sizeInBytes = texImage->Width * texImage->TexFormat->TexelBytes;
+   sizeInBytes = texture_size(texImage);
    texImage->Data = _mesa_alloc_texmemory(sizeInBytes);
    if (!texImage->Data) {
       _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
@@ -3368,16 +3412,14 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
    }
    else {
       const GLint dstRowStride = 0;
-      GLboolean success;
-      ASSERT(texImage->TexFormat->StoreImage);
-      success = texImage->TexFormat->StoreImage(ctx, 1, texImage->_BaseFormat,
-                                                texImage->TexFormat,
-                                                texImage->Data,
-                                                0, 0, 0,  /* dstX/Y/Zoffset */
-                                                dstRowStride,
-                                                texImage->ImageOffsets,
-                                                width, 1, 1,
-                                                format, type, pixels, packing);
+      GLboolean success = _mesa_texstore(ctx, 1, texImage->_BaseFormat,
+                                         texImage->TexFormat,
+                                         texImage->Data,
+                                         0, 0, 0,  /* dstX/Y/Zoffset */
+                                         dstRowStride,
+                                         texImage->ImageOffsets,
+                                         width, 1, 1,
+                                         format, type, pixels, packing);
       if (!success) {
          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
       }
@@ -3406,23 +3448,11 @@ _mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level,
                        struct gl_texture_object *texObj,
                        struct gl_texture_image *texImage)
 {
-   GLint texelBytes, sizeInBytes;
+   GLuint sizeInBytes;
    (void) border;
 
-   texImage->TexFormat
-      = ctx->Driver.ChooseTextureFormat(ctx, internalFormat, format, type);
-   ASSERT(texImage->TexFormat);
-
-   _mesa_set_fetch_functions(texImage, 2);
-   compute_texture_size(ctx, texImage);
-
-   texelBytes = texImage->TexFormat->TexelBytes;
-
    /* allocate memory */
-   if (texImage->IsCompressed)
-      sizeInBytes = texImage->CompressedSize;
-   else
-      sizeInBytes = texImage->Width * texImage->Height * texelBytes;
+   sizeInBytes = texture_size(texImage);
    texImage->Data = _mesa_alloc_texmemory(sizeInBytes);
    if (!texImage->Data) {
       _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
@@ -3438,24 +3468,15 @@ _mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level,
       return;
    }
    else {
-      GLint dstRowStride;
-      GLboolean success;
-      if (texImage->IsCompressed) {
-         dstRowStride
-            = _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat, width);
-      }
-      else {
-         dstRowStride = texImage->RowStride * texImage->TexFormat->TexelBytes;
-      }
-      ASSERT(texImage->TexFormat->StoreImage);
-      success = texImage->TexFormat->StoreImage(ctx, 2, texImage->_BaseFormat,
-                                                texImage->TexFormat,
-                                                texImage->Data,
-                                                0, 0, 0,  /* dstX/Y/Zoffset */
-                                                dstRowStride,
-                                                texImage->ImageOffsets,
-                                                width, height, 1,
-                                                format, type, pixels, packing);
+      GLint dstRowStride = texture_row_stride(texImage);
+      GLboolean success = _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+                                         texImage->TexFormat,
+                                         texImage->Data,
+                                         0, 0, 0,  /* dstX/Y/Zoffset */
+                                         dstRowStride,
+                                         texImage->ImageOffsets,
+                                         width, height, 1,
+                                         format, type, pixels, packing);
       if (!success) {
          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
       }
@@ -3480,23 +3501,11 @@ _mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level,
                        struct gl_texture_object *texObj,
                        struct gl_texture_image *texImage)
 {
-   GLint texelBytes, sizeInBytes;
+   GLuint sizeInBytes;
    (void) border;
 
-   texImage->TexFormat
-      = ctx->Driver.ChooseTextureFormat(ctx, internalFormat, format, type);
-   ASSERT(texImage->TexFormat);
-
-   _mesa_set_fetch_functions(texImage, 3);
-   compute_texture_size(ctx, texImage);
-
-   texelBytes = texImage->TexFormat->TexelBytes;
-
    /* allocate memory */
-   if (texImage->IsCompressed)
-      sizeInBytes = texImage->CompressedSize;
-   else
-      sizeInBytes = width * height * depth * texelBytes;
+   sizeInBytes = texture_size(texImage);
    texImage->Data = _mesa_alloc_texmemory(sizeInBytes);
    if (!texImage->Data) {
       _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");
@@ -3512,24 +3521,15 @@ _mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level,
       return;
    }
    else {
-      GLint dstRowStride;
-      GLboolean success;
-      if (texImage->IsCompressed) {
-         dstRowStride
-            = _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat, width);
-      }
-      else {
-         dstRowStride = texImage->RowStride * texImage->TexFormat->TexelBytes;
-      }
-      ASSERT(texImage->TexFormat->StoreImage);
-      success = texImage->TexFormat->StoreImage(ctx, 3, texImage->_BaseFormat,
-                                                texImage->TexFormat,
-                                                texImage->Data,
-                                                0, 0, 0,  /* dstX/Y/Zoffset */
-                                                dstRowStride,
-                                                texImage->ImageOffsets,
-                                                width, height, depth,
-                                                format, type, pixels, packing);
+      GLint dstRowStride = texture_row_stride(texImage);
+      GLboolean success = _mesa_texstore(ctx, 3, texImage->_BaseFormat,
+                                         texImage->TexFormat,
+                                         texImage->Data,
+                                         0, 0, 0,  /* dstX/Y/Zoffset */
+                                         dstRowStride,
+                                         texImage->ImageOffsets,
+                                         width, height, depth,
+                                         format, type, pixels, packing);
       if (!success) {
          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");
       }
@@ -3561,16 +3561,14 @@ _mesa_store_texsubimage1d(GLcontext *ctx, GLenum target, GLint level,
 
    {
       const GLint dstRowStride = 0;
-      GLboolean success;
-      ASSERT(texImage->TexFormat->StoreImage);
-      success = texImage->TexFormat->StoreImage(ctx, 1, texImage->_BaseFormat,
-                                                texImage->TexFormat,
-                                                texImage->Data,
-                                                xoffset, 0, 0,  /* offsets */
-                                                dstRowStride,
-                                                texImage->ImageOffsets,
-                                                width, 1, 1,
-                                                format, type, pixels, packing);
+      GLboolean success = _mesa_texstore(ctx, 1, texImage->_BaseFormat,
+                                         texImage->TexFormat,
+                                         texImage->Data,
+                                         xoffset, 0, 0,  /* offsets */
+                                         dstRowStride,
+                                         texImage->ImageOffsets,
+                                         width, 1, 1,
+                                         format, type, pixels, packing);
       if (!success) {
          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage1D");
       }
@@ -3601,24 +3599,15 @@ _mesa_store_texsubimage2d(GLcontext *ctx, GLenum target, GLint level,
       return;
 
    {
-      GLint dstRowStride = 0;
-      GLboolean success;
-      if (texImage->IsCompressed) {
-         dstRowStride = _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat,
-                                                    texImage->Width);
-      }
-      else {
-         dstRowStride = texImage->RowStride * texImage->TexFormat->TexelBytes;
-      }
-      ASSERT(texImage->TexFormat->StoreImage);
-      success = texImage->TexFormat->StoreImage(ctx, 2, texImage->_BaseFormat,
-                                                texImage->TexFormat,
-                                                texImage->Data,
-                                                xoffset, yoffset, 0,
-                                                dstRowStride,
-                                                texImage->ImageOffsets,
-                                                width, height, 1,
-                                                format, type, pixels, packing);
+      GLint dstRowStride = texture_row_stride(texImage);
+      GLboolean success = _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+                                         texImage->TexFormat,
+                                         texImage->Data,
+                                         xoffset, yoffset, 0,
+                                         dstRowStride,
+                                         texImage->ImageOffsets,
+                                         width, height, 1,
+                                         format, type, pixels, packing);
       if (!success) {
          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D");
       }
@@ -3649,24 +3638,15 @@ _mesa_store_texsubimage3d(GLcontext *ctx, GLenum target, GLint level,
       return;
 
    {
-      GLint dstRowStride;
-      GLboolean success;
-      if (texImage->IsCompressed) {
-         dstRowStride = _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat,
-                                                    texImage->Width);
-      }
-      else {
-         dstRowStride = texImage->RowStride * texImage->TexFormat->TexelBytes;
-      }
-      ASSERT(texImage->TexFormat->StoreImage);
-      success = texImage->TexFormat->StoreImage(ctx, 3, texImage->_BaseFormat,
-                                                texImage->TexFormat,
-                                                texImage->Data,
-                                                xoffset, yoffset, zoffset,
-                                                dstRowStride,
-                                                texImage->ImageOffsets,
-                                                width, height, depth,
-                                                format, type, pixels, packing);
+      GLint dstRowStride = texture_row_stride(texImage);
+      GLboolean success = _mesa_texstore(ctx, 3, texImage->_BaseFormat,
+                                         texImage->TexFormat,
+                                         texImage->Data,
+                                         xoffset, yoffset, zoffset,
+                                         dstRowStride,
+                                         texImage->ImageOffsets,
+                                         width, height, depth,
+                                         format, type, pixels, packing);
       if (!success) {
          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage3D");
       }
@@ -3722,13 +3702,6 @@ _mesa_store_compressed_teximage2d(GLcontext *ctx, GLenum target, GLint level,
    ASSERT(texImage->Depth == 1);
    ASSERT(texImage->Data == NULL); /* was freed in glCompressedTexImage2DARB */
 
-   texImage->TexFormat
-      = ctx->Driver.ChooseTextureFormat(ctx, internalFormat, 0, 0);
-   ASSERT(texImage->TexFormat);
-
-   _mesa_set_fetch_functions(texImage, 2);
-   compute_texture_size(ctx, texImage);
-
    /* allocate storage */
    texImage->Data = _mesa_alloc_texmemory(imageSize);
    if (!texImage->Data) {
@@ -3743,7 +3716,6 @@ _mesa_store_compressed_teximage2d(GLcontext *ctx, GLenum target, GLint level,
       return;
 
    /* copy the data */
-   ASSERT(texImage->CompressedSize == (GLuint) imageSize);
    MEMCPY(texImage->Data, data, imageSize);
 
    _mesa_unmap_teximage_pbo(ctx, &ctx->Unpack);
@@ -3816,15 +3788,20 @@ _mesa_store_compressed_texsubimage2d(GLcontext *ctx, GLenum target,
    GLint i, rows;
    GLubyte *dest;
    const GLubyte *src;
-   const GLuint mesaFormat = texImage->TexFormat->MesaFormat;
+   const gl_format texFormat = texImage->TexFormat;
+   const GLint destWidth = texImage->Width;
+   GLuint bw, bh;
+
+   _mesa_get_format_block_size(texFormat, &bw, &bh);
 
+   (void) level;
    (void) format;
 
    /* these should have been caught sooner */
-   ASSERT((width & 3) == 0 || width == 2 || width == 1);
-   ASSERT((height & 3) == 0 || height == 2 || height == 1);
-   ASSERT((xoffset & 3) == 0);
-   ASSERT((yoffset & 3) == 0);
+   ASSERT((width % bw) == 0 || width == 2 || width == 1);
+   ASSERT((height % bh) == 0 || height == 2 || height == 1);
+   ASSERT((xoffset % bw) == 0);
+   ASSERT((yoffset % bh) == 0);
 
    /* get pointer to src pixels (may be in a pbo which we'll map here) */
    data = _mesa_validate_pbo_compressed_teximage(ctx, imageSize, data,
@@ -3833,18 +3810,18 @@ _mesa_store_compressed_texsubimage2d(GLcontext *ctx, GLenum target,
    if (!data)
       return;
 
-   srcRowStride = _mesa_compressed_row_stride(mesaFormat, width);
+   srcRowStride = _mesa_format_row_stride(texFormat, width);
    src = (const GLubyte *) data;
 
-   destRowStride = _mesa_compressed_row_stride(mesaFormat, texImage->Width);
+   destRowStride = _mesa_format_row_stride(texFormat, destWidth);
    dest = _mesa_compressed_image_address(xoffset, yoffset, 0,
-                                         texImage->TexFormat->MesaFormat,
-                                         texImage->Width,
+                                         texFormat, destWidth,
                                          (GLubyte *) texImage->Data);
 
-   bytesPerRow = srcRowStride;
-   rows = height / 4;
+   bytesPerRow = srcRowStride;  /* bytes per row of blocks */
+   rows = height / bh;  /* rows in blocks */
 
+   /* copy rows of blocks */
    for (i = 0; i < rows; i++) {
       MEMCPY(dest, src, bytesPerRow);
       dest += destRowStride;
index 313f2d6a598fb7aa2db95c645e54e869d05f0753..3211086dd6307de07925d41594c2e58150f90647 100644 (file)
 
 
 #include "mtypes.h"
+#include "formats.h"
 
 
-extern GLboolean _mesa_texstore_rgba(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_color_index(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_rgba8888(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_argb8888(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_rgb888(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_bgr888(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_rgb565(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_rgb565_rev(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_rgba4444(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_argb4444(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_argb4444_rev(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_rgba5551(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_argb1555(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_argb1555_rev(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_al88(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_al88_rev(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_rgb332(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_a8(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_ci8(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_ycbcr(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_z24_s8(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_s8_z24(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_z16(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_z32(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_rgba_float32(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_rgba_float16(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS);
-#if FEATURE_EXT_texture_sRGB
-extern GLboolean _mesa_texstore_srgb8(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_srgba8(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_sargb8(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_sl8(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_sla8(TEXSTORE_PARAMS);
-#endif
-extern GLboolean _mesa_texstore_dudv8(TEXSTORE_PARAMS);
-extern GLboolean _mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS);
+/**
+ * This macro defines the (many) parameters to the texstore functions.
+ * \param dims  either 1 or 2 or 3
+ * \param baseInternalFormat  user-specified base internal format
+ * \param dstFormat  destination Mesa texture format
+ * \param dstAddr  destination image address
+ * \param dstX/Y/Zoffset  destination x/y/z offset (ala TexSubImage), in texels
+ * \param dstRowStride  destination image row stride, in bytes
+ * \param dstImageOffsets  offset of each 2D slice within 3D texture, in texels
+ * \param srcWidth/Height/Depth  source image size, in pixels
+ * \param srcFormat  incoming image format
+ * \param srcType  incoming image data type
+ * \param srcAddr  source image address
+ * \param srcPacking  source image packing parameters
+ */
+#define TEXSTORE_PARAMS \
+       GLcontext *ctx, GLuint dims, \
+       GLenum baseInternalFormat, \
+       gl_format dstFormat, \
+       GLvoid *dstAddr, \
+       GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, \
+       GLint dstRowStride, const GLuint *dstImageOffsets, \
+       GLint srcWidth, GLint srcHeight, GLint srcDepth, \
+       GLenum srcFormat, GLenum srcType, \
+       const GLvoid *srcAddr, \
+       const struct gl_pixelstore_attrib *srcPacking
+
+
+extern GLboolean
+_mesa_texstore(TEXSTORE_PARAMS);
+
 
 extern GLchan *
 _mesa_make_temp_chan_image(GLcontext *ctx, GLuint dims,
@@ -91,10 +82,6 @@ _mesa_make_temp_chan_image(GLcontext *ctx, GLuint dims,
                            const struct gl_pixelstore_attrib *srcPacking);
 
 
-extern void
-_mesa_set_fetch_functions(struct gl_texture_image *texImage, GLuint dims);
-
-
 extern void
 _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
                        GLint internalFormat,
index 6cd2a2f4f64649d80b2483a81a8f8f15999d6ddc..c2193074cdfc23d215d8f77b6bca5331050980cc 100644 (file)
@@ -51,9 +51,8 @@
  * \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
- * \return GL_TRUE if no error, GL_FALSE if error
  */
-static GLboolean
+static void
 update_array(GLcontext *ctx, struct gl_client_array *array,
              GLbitfield dirtyBit, GLsizei elementSize,
              GLint size, GLenum type, GLenum format,
@@ -68,7 +67,7 @@ update_array(GLcontext *ctx, struct gl_client_array *array,
        */
       _mesa_error(ctx, GL_INVALID_OPERATION,
                   "glVertex/Normal/EtcPointer(non-VBO array)");
-      return GL_FALSE;
+      return;
    }
 
    array->Size = size;
@@ -85,8 +84,6 @@ update_array(GLcontext *ctx, struct gl_client_array *array,
 
    ctx->NewState |= _NEW_ARRAY;
    ctx->Array.NewState |= dirtyBit;
-
-   return GL_TRUE;
 }
 
 
@@ -140,12 +137,8 @@ _mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
          return;
    }
 
-   if (!update_array(ctx, &ctx->Array.ArrayObj->Vertex, _NEW_ARRAY_VERTEX,
-                     elementSize, size, type, GL_RGBA, stride, GL_FALSE, ptr))
-      return;
-
-   if (ctx->Driver.VertexPointer)
-      ctx->Driver.VertexPointer( ctx, size, type, stride, ptr );
+   update_array(ctx, &ctx->Array.ArrayObj->Vertex, _NEW_ARRAY_VERTEX,
+                elementSize, size, type, GL_RGBA, stride, GL_FALSE, ptr);
 }
 
 
@@ -192,12 +185,8 @@ _mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr )
          return;
    }
 
-   if (!update_array(ctx, &ctx->Array.ArrayObj->Normal, _NEW_ARRAY_NORMAL,
-                     elementSize, 3, type, GL_RGBA, stride, GL_TRUE, ptr))
-      return;
-
-   if (ctx->Driver.NormalPointer)
-      ctx->Driver.NormalPointer( ctx, type, stride, ptr );
+   update_array(ctx, &ctx->Array.ArrayObj->Normal, _NEW_ARRAY_NORMAL,
+                elementSize, 3, type, GL_RGBA, stride, GL_TRUE, ptr);
 }
 
 
@@ -272,12 +261,8 @@ _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
          return;
    }
 
-   if (!update_array(ctx, &ctx->Array.ArrayObj->Color, _NEW_ARRAY_COLOR0,
-                     elementSize, size, type, format, stride, GL_TRUE, ptr))
-      return;
-
-   if (ctx->Driver.ColorPointer)
-      ctx->Driver.ColorPointer( ctx, size, type, stride, ptr );
+   update_array(ctx, &ctx->Array.ArrayObj->Color, _NEW_ARRAY_COLOR0,
+                elementSize, size, type, format, stride, GL_TRUE, ptr);
 }
 
 
@@ -305,12 +290,8 @@ _mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr)
          return;
    }
 
-   if (!update_array(ctx, &ctx->Array.ArrayObj->FogCoord, _NEW_ARRAY_FOGCOORD,
-                     elementSize, 1, type, GL_RGBA, stride, GL_FALSE, ptr))
-      return;
-
-   if (ctx->Driver.FogCoordPointer)
-      ctx->Driver.FogCoordPointer( ctx, type, stride, ptr );
+   update_array(ctx, &ctx->Array.ArrayObj->FogCoord, _NEW_ARRAY_FOGCOORD,
+                elementSize, 1, type, GL_RGBA, stride, GL_FALSE, ptr);
 }
 
 
@@ -347,12 +328,8 @@ _mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
          return;
    }
 
-   if (!update_array(ctx, &ctx->Array.ArrayObj->Index, _NEW_ARRAY_INDEX,
-                     elementSize, 1, type, GL_RGBA, stride, GL_FALSE, ptr))
-      return;
-
-   if (ctx->Driver.IndexPointer)
-      ctx->Driver.IndexPointer( ctx, type, stride, ptr );
+   update_array(ctx, &ctx->Array.ArrayObj->Index, _NEW_ARRAY_INDEX,
+                elementSize, 1, type, GL_RGBA, stride, GL_FALSE, ptr);
 }
 
 
@@ -423,13 +400,8 @@ _mesa_SecondaryColorPointerEXT(GLint size, GLenum type,
          return;
    }
 
-   if (!update_array(ctx, &ctx->Array.ArrayObj->SecondaryColor,
-                     _NEW_ARRAY_COLOR1, elementSize, size, type,
-                     format, stride, GL_TRUE, ptr))
-      return;
-
-   if (ctx->Driver.SecondaryColorPointer)
-      ctx->Driver.SecondaryColorPointer( ctx, size, type, stride, ptr );
+   update_array(ctx, &ctx->Array.ArrayObj->SecondaryColor, _NEW_ARRAY_COLOR1,
+                elementSize, size, type, format, stride, GL_TRUE, ptr);
 }
 
 
@@ -485,13 +457,9 @@ _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
          return;
    }
 
-   if (!update_array(ctx, &ctx->Array.ArrayObj->TexCoord[unit],
-                     _NEW_ARRAY_TEXCOORD(unit),
-                     elementSize, size, type, GL_RGBA, stride, GL_FALSE, ptr))
-      return;
-
-   if (ctx->Driver.TexCoordPointer)
-      ctx->Driver.TexCoordPointer( ctx, size, type, stride, ptr );
+   update_array(ctx, &ctx->Array.ArrayObj->TexCoord[unit],
+                _NEW_ARRAY_TEXCOORD(unit),
+                elementSize, size, type, GL_RGBA, stride, GL_FALSE, ptr);
 }
 
 
@@ -506,13 +474,9 @@ _mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr)
       return;
    }
 
-   if (!update_array(ctx, &ctx->Array.ArrayObj->EdgeFlag, _NEW_ARRAY_EDGEFLAG,
-                     sizeof(GLboolean), 1, GL_UNSIGNED_BYTE, GL_RGBA,
-                     stride, GL_FALSE, ptr))
-      return;
-
-   if (ctx->Driver.EdgeFlagPointer)
-      ctx->Driver.EdgeFlagPointer( ctx, stride, ptr );
+   update_array(ctx, &ctx->Array.ArrayObj->EdgeFlag, _NEW_ARRAY_EDGEFLAG,
+                sizeof(GLboolean), 1, GL_UNSIGNED_BYTE, GL_RGBA,
+                stride, GL_FALSE, ptr);
 }
 
 
@@ -620,13 +584,9 @@ _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type,
          return;
    }
 
-   if (!update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index],
-                     _NEW_ARRAY_ATTRIB(index),
-                     elementSize, size, type, format, stride, normalized, ptr))
-      return;
-
-   if (ctx->Driver.VertexAttribPointer)
-      ctx->Driver.VertexAttribPointer( ctx, index, size, type, stride, ptr );
+   update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index],
+                _NEW_ARRAY_ATTRIB(index),
+                elementSize, size, type, format, stride, normalized, ptr);
 }
 #endif
 
@@ -720,13 +680,9 @@ _mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type,
          return;
    }
 
-   if (!update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index],
-                     _NEW_ARRAY_ATTRIB(index),
-                     elementSize, size, type, format, stride, normalized, ptr))
-      return;
-
-   if (ctx->Driver.VertexAttribPointer)
-      ctx->Driver.VertexAttribPointer(ctx, index, size, type, stride, ptr);
+   update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index],
+                _NEW_ARRAY_ATTRIB(index),
+                elementSize, size, type, format, stride, normalized, ptr);
 }
 #endif
 
@@ -989,9 +945,6 @@ _mesa_LockArraysEXT(GLint first, GLsizei count)
 
    ctx->NewState |= _NEW_ARRAY;
    ctx->Array.NewState |= _NEW_ARRAY_ALL;
-
-   if (ctx->Driver.LockArraysEXT)
-      ctx->Driver.LockArraysEXT( ctx, first, count );
 }
 
 
@@ -1013,9 +966,6 @@ _mesa_UnlockArraysEXT( void )
    ctx->Array.LockCount = 0;
    ctx->NewState |= _NEW_ARRAY;
    ctx->Array.NewState |= _NEW_ARRAY_ALL;
-
-   if (ctx->Driver.UnlockArraysEXT)
-      ctx->Driver.UnlockArraysEXT( ctx );
 }
 
 
diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c
new file mode 100644 (file)
index 0000000..9d23c57
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 2010  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, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION 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 "context.h"
+#include "version.h"
+
+
+
+/**
+ * Examine enabled GL extensions to determine GL version.
+ * Return major and minor version numbers.
+ */
+static void
+compute_version(const GLcontext *ctx, GLuint *major, GLuint *minor)
+{
+   const GLboolean ver_1_3 = (ctx->Extensions.ARB_multisample &&
+                              ctx->Extensions.ARB_multitexture &&
+                              ctx->Extensions.ARB_texture_border_clamp &&
+                              ctx->Extensions.ARB_texture_compression &&
+                              ctx->Extensions.ARB_texture_cube_map &&
+                              ctx->Extensions.EXT_texture_env_add &&
+                              ctx->Extensions.ARB_texture_env_combine &&
+                              ctx->Extensions.ARB_texture_env_dot3);
+   const GLboolean ver_1_4 = (ver_1_3 &&
+                              ctx->Extensions.ARB_depth_texture &&
+                              ctx->Extensions.ARB_shadow &&
+                              ctx->Extensions.ARB_texture_env_crossbar &&
+                              ctx->Extensions.ARB_texture_mirrored_repeat &&
+                              ctx->Extensions.ARB_window_pos &&
+                              ctx->Extensions.EXT_blend_color &&
+                              ctx->Extensions.EXT_blend_func_separate &&
+                              ctx->Extensions.EXT_blend_minmax &&
+                              ctx->Extensions.EXT_blend_subtract &&
+                              ctx->Extensions.EXT_fog_coord &&
+                              ctx->Extensions.EXT_multi_draw_arrays &&
+                              ctx->Extensions.EXT_point_parameters &&
+                              ctx->Extensions.EXT_secondary_color &&
+                              ctx->Extensions.EXT_stencil_wrap &&
+                              ctx->Extensions.EXT_texture_lod_bias &&
+                              ctx->Extensions.SGIS_generate_mipmap);
+   const GLboolean ver_1_5 = (ver_1_4 &&
+                              ctx->Extensions.ARB_occlusion_query &&
+                              ctx->Extensions.ARB_vertex_buffer_object &&
+                              ctx->Extensions.EXT_shadow_funcs);
+   const GLboolean ver_2_0 = (ver_1_5 &&
+                              ctx->Extensions.ARB_draw_buffers &&
+                              ctx->Extensions.ARB_point_sprite &&
+                              ctx->Extensions.ARB_shader_objects &&
+                              ctx->Extensions.ARB_vertex_shader &&
+                              ctx->Extensions.ARB_fragment_shader &&
+                              ctx->Extensions.ARB_texture_non_power_of_two &&
+                              ctx->Extensions.EXT_blend_equation_separate &&
+
+                             /* Technically, 2.0 requires the functionality
+                              * of the EXT version.  Enable 2.0 if either
+                              * extension is available, and assume that a
+                              * driver that only exposes the ATI extension
+                              * will fallback to software when necessary.
+                              */
+                             (ctx->Extensions.EXT_stencil_two_side
+                              || ctx->Extensions.ATI_separate_stencil));
+   const GLboolean ver_2_1 = (ver_2_0 &&
+                              ctx->Extensions.ARB_shading_language_120 &&
+                              ctx->Extensions.EXT_pixel_buffer_object &&
+                              ctx->Extensions.EXT_texture_sRGB);
+   if (ver_2_1) {
+      *major = 2;
+      *minor = 1;
+   }
+   else if (ver_2_0) {
+      *major = 2;
+      *minor = 0;
+   }
+   else if (ver_1_5) {
+      *major = 1;
+      *minor = 5;
+   }
+   else if (ver_1_4) {
+      *major = 1;
+      *minor = 4;
+   }
+   else if (ver_1_3) {
+      *major = 1;
+      *minor = 3;
+   }
+   else {
+      *major = 1;
+      *minor = 2;
+   }
+}
+
+
+/**
+ * Set the context's VersionMajor, VersionMinor, VersionString fields.
+ * This should only be called once as part of context initialization.
+ */
+void
+_mesa_compute_version(GLcontext *ctx)
+{
+   static const int max = 100;
+
+   compute_version(ctx, &ctx->VersionMajor, &ctx->VersionMinor);
+   
+   ctx->VersionString = (char *) _mesa_malloc(max);
+   if (ctx->VersionString) {
+      _mesa_snprintf(ctx->VersionString, max, "%u.%u Mesa " MESA_VERSION_STRING,
+                     ctx->VersionMajor, ctx->VersionMinor);
+   }
+}
index 0cae1860a338d93ff5c84ac620c8f18a75456d7d..d521569f8d31eb5c7b08c501e386dfdc3b3e82b5 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Mesa 3-D graphics library
- * Version:  7.7
+ * Version:  7.8
  *
  * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
  * Copyright (C) 2009  VMware, Inc.  All Rights Reserved.
 #define VERSION_H
 
 
+#include "mtypes.h"
+
+
 /* Mesa version */
 #define MESA_MAJOR 7
-#define MESA_MINOR 7
+#define MESA_MINOR 8
 #define MESA_PATCH 0
-#define MESA_VERSION_STRING "7.7-devel"
+#define MESA_VERSION_STRING "7.8-devel"
 
 /* To make version comparison easy */
 #define MESA_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
@@ -50,4 +53,8 @@
 #define OPENGL_VERSION_CODE OPENGL_VERSION(OPENGL_MAJOR, OPENGL_MINOR, OPENGL_PATCH)
 
 
+extern void
+_mesa_compute_version(GLcontext *ctx);
+
+
 #endif /* VERSION_H */
index d56a2bb95ea5f2c718f45b596fde13296d98ca4d..ae636fb24fba68a373122e6646196a3b68f567d0 100644 (file)
@@ -30,7 +30,6 @@
 #endif
 
 #include "glapi/dispatch.h"
-#include "glapi/glapioffsets.h"
 
 static void GLAPIENTRY TAG(ArrayElement)( GLint i )
 {
index 89c632e7d59d1370379551a592c65bf0ecaab472..f9b26d804717469797b9ef68442ac69becfdea6c 100644 (file)
@@ -230,7 +230,7 @@ static int test_norm_function( normal_func func, int mtype, long *cycles )
          case VAR:
             break;
          default:
-            _mesa_exit(1);
+            exit(1);
          }
       }
    }
index 05ee4f563eb7a2fe8b40bb8c1ab76e03a882da98..a09be71020ea90bcec8629347669c9ad3755236b 100644 (file)
@@ -56,7 +56,6 @@ having three separate program parameter arrays.
 #include "main/context.h"
 #include "main/macros.h"
 #include "main/mtypes.h"
-#include "shader/grammar/grammar_mesa.h"
 #include "arbprogparse.h"
 #include "program.h"
 #include "programopt.h"
@@ -87,6 +86,9 @@ _mesa_parse_arb_fragment_program(GLcontext* ctx, GLenum target,
       return;
    }
 
+   if (program->Base.String != NULL)
+      _mesa_free(program->Base.String);
+
    /* Copy the relevant contents of the arb_program struct into the
     * fragment_program struct.
     */
@@ -178,6 +180,9 @@ _mesa_parse_arb_vertex_program(GLcontext *ctx, GLenum target,
       return;
    }
 
+   if (program->Base.String != NULL)
+      _mesa_free(program->Base.String);
+
    /* Copy the relevant contents of the arb_program struct into the 
     * vertex_program struct.
     */
index 4d8cff070012b46abae9d082679e86d7af31b8dc..eb537cd1b99bc1e9a3987c7f9063e5a5052ac40f 100644 (file)
@@ -37,6 +37,8 @@
 #include "main/mtypes.h"
 #include "arbprogram.h"
 #include "arbprogparse.h"
+#include "nvfragparse.h"
+#include "nvvertparse.h"
 #include "program.h"
 
 
@@ -428,36 +430,66 @@ void GLAPIENTRY
 _mesa_ProgramStringARB(GLenum target, GLenum format, GLsizei len,
                        const GLvoid *string)
 {
+   struct gl_program *base;
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    FLUSH_VERTICES(ctx, _NEW_PROGRAM);
 
+   if (!ctx->Extensions.ARB_vertex_program
+       && !ctx->Extensions.ARB_fragment_program) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glProgramStringARB()");
+      return;
+   }
+
    if (format != GL_PROGRAM_FORMAT_ASCII_ARB) {
       _mesa_error(ctx, GL_INVALID_ENUM, "glProgramStringARB(format)");
       return;
    }
 
+   /* The first couple cases are complicated.  The same enum value is used for
+    * ARB and NV vertex programs.  If the target is a vertex program, parse it
+    * using the ARB grammar if the string starts with "!!ARB" or if
+    * NV_vertex_program is not supported.
+    */
    if (target == GL_VERTEX_PROGRAM_ARB
-       && ctx->Extensions.ARB_vertex_program) {
+       && ctx->Extensions.ARB_vertex_program
+       && ((strncmp(string, "!!ARB", 5) == 0)
+          || !ctx->Extensions.NV_vertex_program)) {
       struct gl_vertex_program *prog = ctx->VertexProgram.Current;
       _mesa_parse_arb_vertex_program(ctx, target, string, len, prog);
-      
-      if (ctx->Program.ErrorPos == -1 && ctx->Driver.ProgramStringNotify)
-        ctx->Driver.ProgramStringNotify( ctx, target, &prog->Base );
+
+      base = & prog->Base;
+   }
+   else if ((target == GL_VERTEX_PROGRAM_ARB
+            || target == GL_VERTEX_STATE_PROGRAM_NV)
+           && ctx->Extensions.NV_vertex_program) {
+      struct gl_vertex_program *prog = ctx->VertexProgram.Current;
+      _mesa_parse_nv_vertex_program(ctx, target, string, len, prog);
+
+      base = & prog->Base;
    }
    else if (target == GL_FRAGMENT_PROGRAM_ARB
             && ctx->Extensions.ARB_fragment_program) {
       struct gl_fragment_program *prog = ctx->FragmentProgram.Current;
       _mesa_parse_arb_fragment_program(ctx, target, string, len, prog);
 
-      if (ctx->Program.ErrorPos == -1 && ctx->Driver.ProgramStringNotify)
-        ctx->Driver.ProgramStringNotify( ctx, target, &prog->Base );
+      base = & prog->Base;
+   }
+   else if (target == GL_FRAGMENT_PROGRAM_NV
+            && ctx->Extensions.NV_fragment_program) {
+      struct gl_fragment_program *prog = ctx->FragmentProgram.Current;
+      _mesa_parse_nv_fragment_program(ctx, target, string, len, prog);
+
+      base = & prog->Base;
    }
    else {
       _mesa_error(ctx, GL_INVALID_ENUM, "glProgramStringARB(target)");
       return;
    }
+
+   if (ctx->Program.ErrorPos == -1 && ctx->Driver.ProgramStringNotify)
+      ctx->Driver.ProgramStringNotify( ctx, target, base );
 }
 
 
index ac087d415c5df2f829c5bf80bd8d8e946b978fa0..e04a05b22fff0ca5ccf7c6d2300293f11b52f3b0 100644 (file)
@@ -290,9 +290,11 @@ _mesa_DeleteFragmentShaderATI(GLuint id)
 
       /* The ID is immediately available for re-use now */
       _mesa_HashRemove(ctx->Shared->ATIShaders, id);
-      prog->RefCount--;
-      if (prog->RefCount <= 0) {
-         _mesa_free(prog);
+      if (prog) {
+        prog->RefCount--;
+        if (prog->RefCount <= 0) {
+           _mesa_free(prog);
+        }
       }
    }
 }
index 19bafd483021ff3e0eed7d4f40a86c9faaa98777..59730020d0c0b5e5e2ff9e419fabb2efa3c26d31 100644 (file)
@@ -16,7 +16,7 @@
 
 VPATH = RCS
 
-INCDIR = [---.include],[.grammar],[-.main],[-.glapi],[.slang]
+INCDIR = [---.include],[-.main],[-.glapi],[.slang]
 LIBDIR = [---.lib]
 CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1,"__extension__=")/name=(as_is,short)/float=ieee/ieee=denorm
 
@@ -64,8 +64,6 @@ all :
        $(MMS)$(MMSQUALIFIERS) $(LIBDIR)$(GL_LIB)
        set def [.slang]
        $(MMS)$(MMSQUALIFIERS)
-       set def [-.grammar]
-       $(MMS)$(MMSQUALIFIERS)
        set def [-]
 
 # Make the library
diff --git a/src/mesa/shader/grammar/grammar.c b/src/mesa/shader/grammar/grammar.c
deleted file mode 100644 (file)
index a977596..0000000
+++ /dev/null
@@ -1,3178 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version:  6.6
- *
- * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/**
- * \file grammar.c
- * syntax parsing engine
- * \author Michal Krol
- */
-
-#ifndef GRAMMAR_PORT_BUILD
-#error Do not build this file directly, build your grammar_XXX.c instead, which includes this file
-#endif
-
-/*
-*/
-
-/*
-    INTRODUCTION
-    ------------
-
-    The task is to check the syntax of an input string. Input string is a stream of ASCII
-    characters terminated with a null-character ('\0'). Checking it using C language is
-    difficult and hard to implement without bugs. It is hard to maintain and make changes when
-    the syntax changes.
-
-    This is because of a high redundancy of the C code. Large blocks of code are duplicated with
-    only small changes. Even use of macros does not solve the problem because macros cannot
-    erase the complexity of the problem.
-
-    The resolution is to create a new language that will be highly oriented to our task. Once
-    we describe a particular syntax, we are done. We can then focus on the code that implements
-    the language. The size and complexity of it is relatively small than the code that directly
-    checks the syntax.
-
-    First, we must implement our new language. Here, the language is implemented in C, but it
-    could also be implemented in any other language. The code is listed below. We must take
-    a good care that it is bug free. This is simple because the code is simple and clean.
-
-    Next, we must describe the syntax of our new language in itself. Once created and checked
-    manually that it is correct, we can use it to check another scripts.
-
-    Note that our new language loading code does not have to check the syntax. It is because we
-    assume that the script describing itself is correct, and other scripts can be syntactically
-    checked by the former script. The loading code must only do semantic checking which leads us to
-    simple resolving references.
-
-    THE LANGUAGE
-    ------------
-
-    Here I will describe the syntax of the new language (further called "Synek"). It is mainly a
-    sequence of declarations terminated by a semicolon. The declaration consists of a symbol,
-    which is an identifier, and its definition. A definition is in turn a sequence of specifiers
-    connected with ".and" or ".or" operator. These operators cannot be mixed together in a one
-    definition. Specifier can be a symbol, string, character, character range or a special
-    keyword ".true" or ".false".
-
-    On the very beginning of the script there is a declaration of a root symbol and is in the form:
-        .syntax <root_symbol>;
-    The <root_symbol> must be on of the symbols in declaration sequence. The syntax is correct if
-    the root symbol evaluates to true. A symbol evaluates to true if the definition associated with
-    the symbol evaluates to true. Definition evaluation depends on the operator used to connect
-    specifiers in the definition. If ".and" operator is used, definition evaluates to true if and
-    only if all the specifiers evaluate to true. If ".or" operator is used, definition evalutes to
-    true if any of the specifiers evaluates to true. If definition contains only one specifier,
-    it is evaluated as if it was connected with ".true" keyword by ".and" operator.
-
-    If specifier is a ".true" keyword, it always evaluates to true.
-
-    If specifier is a ".false" keyword, it always evaluates to false. Specifier evaluates to false
-    when it does not evaluate to true.
-
-    Character range specifier is in the form:
-        '<first_character>' - '<second_character>'
-    If specifier is a character range, it evaluates to true if character in the stream is greater
-    or equal to <first_character> and less or equal to <second_character>. In that situation 
-    the stream pointer is advanced to point to next character in the stream. All C-style escape
-    sequences are supported although trigraph sequences are not. The comparisions are performed
-    on 8-bit unsigned integers.
-
-    Character specifier is in the form:
-        '<single_character>'
-    It evaluates to true if the following character range specifier evaluates to true:
-        '<single_character>' - '<single_character>'
-
-    String specifier is in the form:
-        "<string>"
-    Let N be the number of characters in <string>. Let <string>[i] designate i-th character in
-    <string>. Then the string specifier evaluates to true if and only if for i in the range [0, N)
-    the following character specifier evaluates to true:
-        '<string>[i]'
-    If <string>[i] is a quotation mark, '<string>[i]' is replaced with '\<string>[i]'.
-
-    Symbol specifier can be optionally preceded by a ".loop" keyword in the form:
-        .loop <symbol>                  (1)
-    where <symbol> is defined as follows:
-        <symbol> <definition>;          (2)
-    Construction (1) is replaced by the following code:
-        <symbol$1>
-    and declaration (2) is replaced by the following:
-        <symbol$1> <symbol$2> .or .true;
-        <symbol$2> <symbol> .and <symbol$1>;
-        <symbol> <definition>;
-
-    Synek supports also a register mechanizm. User can, in its SYN file, declare a number of
-    registers that can be accessed in the syn body. Each reg has its name and a default value.
-    The register is one byte wide. The C code can change the default value by calling
-    grammar_set_reg8() with grammar id, register name and a new value. As we know, each rule is
-    a sequence of specifiers joined with .and or .or operator. And now each specifier can be
-    prefixed with a condition expression in a form ".if (<reg_name> <operator> <hex_literal>)"
-    where <operator> can be == or !=. If the condition evaluates to false, the specifier
-    evaluates to .false. Otherwise it evalutes to the specifier.
-
-    ESCAPE SEQUENCES
-    ----------------
-
-    Synek supports all escape sequences in character specifiers. The mapping table is listed below.
-    All occurences of the characters in the first column are replaced with the corresponding
-    character in the second column.
-
-        Escape sequence         Represents
-    ------------------------------------------------------------------------------------------------
-        \a                      Bell (alert)
-        \b                      Backspace
-        \f                      Formfeed
-        \n                      New line
-        \r                      Carriage return
-        \t                      Horizontal tab
-        \v                      Vertical tab
-        \'                      Single quotation mark
-        \"                      Double quotation mark
-        \\                      Backslash
-        \?                      Literal question mark
-        \ooo                    ASCII character in octal notation
-        \xhhh                   ASCII character in hexadecimal notation
-    ------------------------------------------------------------------------------------------------
-
-    RAISING ERRORS
-    --------------
-
-    Any specifier can be followed by a special construction that is executed when the specifier
-    evaluates to false. The construction is in the form:
-        .error <ERROR_TEXT>
-    <ERROR_TEXT> is an identifier declared earlier by error text declaration. The declaration is
-    in the form:
-        .errtext <ERROR_TEXT> "<error_desc>"
-    When specifier evaluates to false and this construction is present, parsing is stopped
-    immediately and <error_desc> is returned as a result of parsing. The error position is also
-    returned and it is meant as an offset from the beggining of the stream to the character that
-    was valid so far. Example:
-
-        (**** syntax script ****)
-
-        .syntax program;
-        .errtext MISSING_SEMICOLON      "missing ';'"
-        program         declaration .and .loop space .and ';' .error MISSING_SEMICOLON .and
-                        .loop space .and '\0';
-        declaration     "declare" .and .loop space .and identifier;
-        space           ' ';
-
-        (**** sample code ****)
-
-        declare foo ,
-
-    In the example above checking the sample code will result in error message "missing ';'" and
-    error position 12. The sample code is not correct. Note the presence of '\0' specifier to
-    assure that there is no code after semicolon - only spaces.
-    <error_desc> can optionally contain identifier surrounded by dollar signs $. In such a case,
-    the identifier and dollar signs are replaced by a string retrieved by invoking symbol with
-    the identifier name. The starting position is the error position. The lenght of the resulting
-    string is the position after invoking the symbol.
-
-    PRODUCTION
-    ----------
-
-    Synek not only checks the syntax but it can also produce (emit) bytes associated with specifiers
-    that evaluate to true. That is, every specifier and optional error construction can be followed
-    by a number of emit constructions that are in the form:
-        .emit <parameter>
-    <paramater> can be a HEX number, identifier, a star * or a dollar $. HEX number is preceded by
-    0x or 0X. If <parameter> is an identifier, it must be earlier declared by emit code declaration
-    in the form:
-        .emtcode <identifier> <hex_number>
-
-    When given specifier evaluates to true, all emits associated with the specifier are output
-    in order they were declared. A star means that last-read character should be output instead
-    of constant value. Example:
-
-        (**** syntax script ****)
-
-        .syntax foobar;
-        .emtcode WORD_FOO       0x01
-        .emtcode WORD_BAR       0x02
-        foobar      FOO .emit WORD_FOO .or BAR .emit WORD_BAR .or .true .emit 0x00;
-        FOO         "foo" .and SPACE;
-        BAR         "bar" .and SPACE;
-        SPACE       ' ' .or '\0';
-
-        (**** sample text 1 ****)
-
-        foo
-
-        (**** sample text 2 ****)
-
-        foobar
-
-    For both samples the result will be one-element array. For first sample text it will be
-    value 1, for second - 0. Note that every text will be accepted because of presence of
-    .true as an alternative.
-
-    Another example:
-
-        (**** syntax script ****)
-
-        .syntax declaration;
-        .emtcode VARIABLE       0x01
-        declaration     "declare" .and .loop space .and
-                        identifier .emit VARIABLE .and          (1)
-                        .true .emit 0x00 .and                   (2)
-                        .loop space .and ';';
-        space           ' ' .or '\t';
-        identifier      .loop id_char .emit *;                  (3)
-        id_char         'a'-'z' .or 'A'-'Z' .or '_';
-
-        (**** sample code ****)
-
-        declare    fubar;
-
-    In specifier (1) symbol <identifier> is followed by .emit VARIABLE. If it evaluates to
-    true, VARIABLE constant and then production of the symbol is output. Specifier (2) is used
-    to terminate the string with null to signal when the string ends. Specifier (3) outputs
-    all characters that make declared identifier. The result of sample code will be the
-    following array:
-        { 1, 'f', 'u', 'b', 'a', 'r', 0 }
-
-    If .emit is followed by dollar $, it means that current position should be output. Current
-    position is a 32-bit unsigned integer distance from the very beginning of the parsed string to
-    first character consumed by the specifier associated with the .emit instruction. Current
-    position is stored in the output buffer in Little-Endian convention (the lowest byte comes
-    first).
-*/
-
-#include <stdio.h>
-
-static void mem_free (void **);
-
-/*
-    internal error messages
-*/
-static const byte *OUT_OF_MEMORY =          (byte *) "internal error 1001: out of physical memory";
-static const byte *UNRESOLVED_REFERENCE =   (byte *) "internal error 1002: unresolved reference '$'";
-static const byte *INVALID_GRAMMAR_ID =     (byte *) "internal error 1003: invalid grammar object";
-static const byte *INVALID_REGISTER_NAME =  (byte *) "internal error 1004: invalid register name: '$'";
-/*static const byte *DUPLICATE_IDENTIFIER =   (byte *) "internal error 1005: identifier '$' already defined";*/
-static const byte *UNREFERENCED_IDENTIFIER =(byte *) "internal error 1006: unreferenced identifier '$'";
-
-static const byte *error_message = NULL;    /* points to one of the error messages above */
-static byte *error_param = NULL;        /* this is inserted into error_message in place of $ */
-static int error_position = -1;
-
-static byte *unknown = (byte *) "???";
-
-static void clear_last_error (void)
-{
-    /* reset error message */
-    error_message = NULL;
-
-    /* free error parameter - if error_param is a "???" don't free it - it's static */
-    if (error_param != unknown)
-        mem_free ((void **) (void *) &error_param);
-    else
-        error_param = NULL;
-
-    /* reset error position */
-    error_position = -1;
-}
-
-static void set_last_error (const byte *msg, byte *param, int pos)
-{
-    /* error message can be set only once */
-    if (error_message != NULL)
-    {
-        mem_free ((void **) (void *) &param);
-        return;
-    }
-
-    error_message = msg;
-
-    /* if param is NULL, set error_param to unknown ("???") */
-    /* note: do not try to strdup the "???" - it may be that we are here because of */
-    /* out of memory error so strdup can fail */
-    if (param != NULL)
-        error_param = param;
-    else
-        error_param = unknown;
-
-    error_position = pos;
-}
-
-/*
-    memory management routines
-*/
-static void *mem_alloc (size_t size)
-{
-    void *ptr = grammar_alloc_malloc (size);
-    if (ptr == NULL)
-        set_last_error (OUT_OF_MEMORY, NULL, -1);
-    return ptr;
-}
-
-static void *mem_copy (void *dst, const void *src, size_t size)
-{
-    return grammar_memory_copy (dst, src, size);
-}
-
-static void mem_free (void **ptr)
-{
-    grammar_alloc_free (*ptr);
-    *ptr = NULL;
-}
-
-static void *mem_realloc (void *ptr, size_t old_size, size_t new_size)
-{
-    void *ptr2 = grammar_alloc_realloc (ptr, old_size, new_size);
-    if (ptr2 == NULL)
-        set_last_error (OUT_OF_MEMORY, NULL, -1);
-    return ptr2;
-}
-
-static byte *str_copy_n (byte *dst, const byte *src, size_t max_len)
-{
-    return grammar_string_copy_n (dst, src, max_len);
-}
-
-static byte *str_duplicate (const byte *str)
-{
-    byte *new_str = grammar_string_duplicate (str);
-    if (new_str == NULL)
-        set_last_error (OUT_OF_MEMORY, NULL, -1);
-    return new_str;
-}
-
-static int str_equal (const byte *str1, const byte *str2)
-{
-    return grammar_string_compare (str1, str2) == 0;
-}
-
-static int str_equal_n (const byte *str1, const byte *str2, unsigned int n)
-{
-    return grammar_string_compare_n (str1, str2, n) == 0;
-}
-
-static int
-str_length (const byte *str)
-{
-   return (int) (grammar_string_length (str));
-}
-
-/*
-    useful macros
-*/
-#define GRAMMAR_IMPLEMENT_LIST_APPEND(_Ty)\
-    static void _Ty##_append (_Ty **x, _Ty *nx) {\
-        while (*x) x = &(**x).next;\
-        *x = nx;\
-    }
-
-/*
-    string to byte map typedef
-*/
-typedef struct map_byte_
-{
-    byte *key;
-    byte data;
-    struct map_byte_ *next;
-} map_byte;
-
-static void map_byte_create (map_byte **ma)
-{
-    *ma = (map_byte *) mem_alloc (sizeof (map_byte));
-    if (*ma)
-    {
-        (**ma).key = NULL;
-        (**ma).data = '\0';
-        (**ma).next = NULL;
-    }
-}
-
-static void map_byte_destroy (map_byte **ma)
-{
-    if (*ma)
-    {
-        map_byte_destroy (&(**ma).next);
-        mem_free ((void **) &(**ma).key);
-        mem_free ((void **) ma);
-    }
-}
-
-GRAMMAR_IMPLEMENT_LIST_APPEND(map_byte)
-
-/*
-    searches the map for the specified key,
-    returns pointer to the element with the specified key if it exists
-    returns NULL otherwise
-*/
-static map_byte *map_byte_locate (map_byte **ma, const byte *key)
-{
-    while (*ma)
-    {
-        if (str_equal ((**ma).key, key))
-            return *ma;
-
-        ma = &(**ma).next;
-    }
-
-    set_last_error (UNRESOLVED_REFERENCE, str_duplicate (key), -1);
-    return NULL;
-}
-
-/*
-    searches the map for specified key,
-    if the key is matched, *data is filled with data associated with the key,
-    returns 0 if the key is matched,
-    returns 1 otherwise
-*/
-static int map_byte_find (map_byte **ma, const byte *key, byte *data)
-{
-    map_byte *found = map_byte_locate (ma, key);
-    if (found != NULL)
-    {
-        *data = found->data;
-
-        return 0;
-    }
-
-    return 1;
-}
-
-/*
-    regbyte context typedef
-
-    Each regbyte consists of its name and a default value. These are static and created at
-    grammar script compile-time, for example the following line:
-        .regbyte vertex_blend      0x00
-    adds a new regbyte named "vertex_blend" to the static list and initializes it to 0.
-    When the script is executed, this regbyte can be accessed by name for read and write. When a
-    particular regbyte is written, a new regbyte_ctx entry is added to the top of the regbyte_ctx
-    stack. The new entry contains information abot which regbyte it references and its new value.
-    When a given regbyte is accessed for read, the stack is searched top-down to find an
-    entry that references the regbyte. The first matching entry is used to return the current
-    value it holds. If no entry is found, the default value is returned.
-*/
-typedef struct regbyte_ctx_
-{
-    map_byte *m_regbyte;
-    byte m_current_value;
-    struct regbyte_ctx_ *m_prev;
-} regbyte_ctx;
-
-static void regbyte_ctx_create (regbyte_ctx **re)
-{
-    *re = (regbyte_ctx *) mem_alloc (sizeof (regbyte_ctx));
-    if (*re)
-    {
-        (**re).m_regbyte = NULL;
-        (**re).m_prev = NULL;
-    }
-}
-
-static void regbyte_ctx_destroy (regbyte_ctx **re)
-{
-    if (*re)
-    {
-        mem_free ((void **) re);
-    }
-}
-
-static byte regbyte_ctx_extract (regbyte_ctx **re, map_byte *reg)
-{
-    /* first lookup in the register stack */
-    while (*re != NULL)
-    {
-        if ((**re).m_regbyte == reg)
-            return (**re).m_current_value;
-
-        re = &(**re).m_prev;
-    }
-
-    /* if not found - return the default value */
-    return reg->data;
-}
-
-/*
-    emit type typedef
-*/
-typedef enum emit_type_
-{
-    et_byte,            /* explicit number */
-    et_stream,          /* eaten character */
-    et_position         /* current position */
-} emit_type;
-
-/*
-    emit destination typedef
-*/
-typedef enum emit_dest_
-{
-    ed_output,          /* write to the output buffer */
-    ed_regbyte          /* write a particular regbyte */
-} emit_dest;
-
-/*
-    emit typedef
-*/
-typedef struct emit_
-{
-    emit_dest m_emit_dest;
-    emit_type m_emit_type;      /* ed_output */
-    byte m_byte;                /* et_byte */
-    map_byte *m_regbyte;        /* ed_regbyte */
-    byte *m_regname;            /* ed_regbyte - temporary */
-    struct emit_ *m_next;
-} emit;
-
-static void emit_create (emit **em)
-{
-    *em = (emit *) mem_alloc (sizeof (emit));
-    if (*em)
-    {
-        (**em).m_emit_dest = ed_output;
-        (**em).m_emit_type = et_byte;
-        (**em).m_byte = '\0';
-        (**em).m_regbyte = NULL;
-        (**em).m_regname = NULL;
-        (**em).m_next = NULL;
-    }
-}
-
-static void emit_destroy (emit **em)
-{
-    if (*em)
-    {
-        emit_destroy (&(**em).m_next);
-        mem_free ((void **) &(**em).m_regname);
-        mem_free ((void **) em);
-    }
-}
-
-static unsigned int emit_size (emit *_E)
-{
-    unsigned int n = 0;
-
-    while (_E != NULL)
-    {
-        if (_E->m_emit_dest == ed_output)
-        {
-            if (_E->m_emit_type == et_position)
-                n += 4;     /* position is a 32-bit unsigned integer */
-            else
-                n++;
-        }
-        _E = _E->m_next;
-    }
-
-    return n;
-}
-
-static int emit_push (emit *_E, byte *_P, byte c, unsigned int _Pos, regbyte_ctx **_Ctx)
-{
-    while (_E != NULL)
-    {
-        if (_E->m_emit_dest == ed_output)
-        {
-            if (_E->m_emit_type == et_byte)
-                *_P++ = _E->m_byte;
-            else if (_E->m_emit_type == et_stream)
-                *_P++ = c;
-            else /* _Em->type == et_position */
-            {
-                *_P++ = (byte) (_Pos);
-                *_P++ = (byte) (_Pos >> 8);
-                *_P++ = (byte) (_Pos >> 16);
-                *_P++ = (byte) (_Pos >> 24);
-            }
-        }
-        else
-        {
-            regbyte_ctx *new_rbc;
-            regbyte_ctx_create (&new_rbc);
-            if (new_rbc == NULL)
-                return 1;
-
-            new_rbc->m_prev = *_Ctx;
-            new_rbc->m_regbyte = _E->m_regbyte;
-            *_Ctx = new_rbc;
-
-            if (_E->m_emit_type == et_byte)
-                new_rbc->m_current_value = _E->m_byte;
-            else if (_E->m_emit_type == et_stream)
-                new_rbc->m_current_value = c;
-        }
-
-        _E = _E->m_next;
-    }
-
-    return 0;
-}
-
-/*
-    error typedef
-*/
-typedef struct error_
-{
-    byte *m_text;
-    byte *m_token_name;
-    struct rule_ *m_token;
-} error;
-
-static void error_create (error **er)
-{
-    *er = (error *) mem_alloc (sizeof (error));
-    if (*er)
-    {
-        (**er).m_text = NULL;
-        (**er).m_token_name = NULL;
-        (**er).m_token = NULL;
-    }
-}
-
-static void error_destroy (error **er)
-{
-    if (*er)
-    {
-        mem_free ((void **) &(**er).m_text);
-        mem_free ((void **) &(**er).m_token_name);
-        mem_free ((void **) er);
-    }
-}
-
-struct dict_;
-
-static byte *
-error_get_token (error *, struct dict_ *, const byte *, int);
-
-/*
-    condition operand type typedef
-*/
-typedef enum cond_oper_type_
-{
-    cot_byte,               /* constant 8-bit unsigned integer */
-    cot_regbyte             /* pointer to byte register containing the current value */
-} cond_oper_type;
-
-/*
-    condition operand typedef
-*/
-typedef struct cond_oper_
-{
-    cond_oper_type m_type;
-    byte m_byte;            /* cot_byte */
-    map_byte *m_regbyte;    /* cot_regbyte */
-    byte *m_regname;        /* cot_regbyte - temporary */
-} cond_oper;
-
-/*
-    condition type typedef
-*/
-typedef enum cond_type_
-{
-    ct_equal,
-    ct_not_equal
-} cond_type;
-
-/*
-    condition typedef
-*/
-typedef struct cond_
-{
-    cond_type m_type;
-    cond_oper m_operands[2];
-} cond;
-
-static void cond_create (cond **co)
-{
-    *co = (cond *) mem_alloc (sizeof (cond));
-    if (*co)
-    {
-        (**co).m_operands[0].m_regname = NULL;
-        (**co).m_operands[1].m_regname = NULL;
-    }
-}
-
-static void cond_destroy (cond **co)
-{
-    if (*co)
-    {
-        mem_free ((void **) &(**co).m_operands[0].m_regname);
-        mem_free ((void **) &(**co).m_operands[1].m_regname);
-        mem_free ((void **) co);
-    }
-}
-
-/*
-    specifier type typedef
-*/
-typedef enum spec_type_
-{
-    st_false,
-    st_true,
-    st_byte,
-    st_byte_range,
-    st_string,
-    st_identifier,
-    st_identifier_loop,
-    st_debug
-} spec_type;
-
-/*
-    specifier typedef
-*/
-typedef struct spec_
-{
-    spec_type m_spec_type;
-    byte m_byte[2];                 /* st_byte, st_byte_range */
-    byte *m_string;                 /* st_string */
-    struct rule_ *m_rule;           /* st_identifier, st_identifier_loop */
-    emit *m_emits;
-    error *m_errtext;
-    cond *m_cond;
-    struct spec_ *next;
-} spec;
-
-static void spec_create (spec **sp)
-{
-    *sp = (spec *) mem_alloc (sizeof (spec));
-    if (*sp)
-    {
-        (**sp).m_spec_type = st_false;
-        (**sp).m_byte[0] = '\0';
-        (**sp).m_byte[1] = '\0';
-        (**sp).m_string = NULL;
-        (**sp).m_rule = NULL;
-        (**sp).m_emits = NULL;
-        (**sp).m_errtext = NULL;
-        (**sp).m_cond = NULL;
-        (**sp).next = NULL;
-    }
-}
-
-static void spec_destroy (spec **sp)
-{
-    if (*sp)
-    {
-        spec_destroy (&(**sp).next);
-        emit_destroy (&(**sp).m_emits);
-        error_destroy (&(**sp).m_errtext);
-        mem_free ((void **) &(**sp).m_string);
-        cond_destroy (&(**sp).m_cond);
-        mem_free ((void **) sp);
-    }
-}
-
-GRAMMAR_IMPLEMENT_LIST_APPEND(spec)
-
-/*
-    operator typedef
-*/
-typedef enum oper_
-{
-    op_none,
-    op_and,
-    op_or
-} oper;
-
-/*
-    rule typedef
-*/
-typedef struct rule_
-{
-    oper m_oper;
-    spec *m_specs;
-    struct rule_ *next;
-    int m_referenced;
-} rule;
-
-static void rule_create (rule **ru)
-{
-    *ru = (rule *) mem_alloc (sizeof (rule));
-    if (*ru)
-    {
-        (**ru).m_oper = op_none;
-        (**ru).m_specs = NULL;
-        (**ru).next = NULL;
-        (**ru).m_referenced = 0;
-    }
-}
-
-static void rule_destroy (rule **ru)
-{
-    if (*ru)
-    {
-        rule_destroy (&(**ru).next);
-        spec_destroy (&(**ru).m_specs);
-        mem_free ((void **) ru);
-    }
-}
-
-GRAMMAR_IMPLEMENT_LIST_APPEND(rule)
-
-/*
-    returns unique grammar id
-*/
-static grammar next_valid_grammar_id (void)
-{
-    static grammar id = 0;
-
-    return ++id;
-}
-
-/*
-    dictionary typedef
-*/
-typedef struct dict_
-{
-    rule *m_rulez;
-    rule *m_syntax;
-    rule *m_string;
-    map_byte *m_regbytes;
-    grammar m_id;
-    struct dict_ *next;
-} dict;
-
-static void dict_create (dict **di)
-{
-    *di = (dict *) mem_alloc (sizeof (dict));
-    if (*di)
-    {
-        (**di).m_rulez = NULL;
-        (**di).m_syntax = NULL;
-        (**di).m_string = NULL;
-        (**di).m_regbytes = NULL;
-        (**di).m_id = next_valid_grammar_id ();
-        (**di).next = NULL;
-    }
-}
-
-static void dict_destroy (dict **di)
-{
-    if (*di)
-    {
-        rule_destroy (&(**di).m_rulez);
-        map_byte_destroy (&(**di).m_regbytes);
-        mem_free ((void **) di);
-    }
-}
-
-GRAMMAR_IMPLEMENT_LIST_APPEND(dict)
-
-static void dict_find (dict **di, grammar key, dict **data)
-{
-    while (*di)
-    {
-        if ((**di).m_id == key)
-        {
-            *data = *di;
-            return;
-        }
-
-        di = &(**di).next;
-    }
-
-    *data = NULL;
-}
-
-static dict *g_dicts = NULL;
-
-/*
-    byte array typedef
-*/
-typedef struct barray_
-{
-    byte *data;
-    unsigned int len;
-} barray;
-
-static void barray_create (barray **ba)
-{
-    *ba = (barray *) mem_alloc (sizeof (barray));
-    if (*ba)
-    {
-        (**ba).data = NULL;
-        (**ba).len = 0;
-    }
-}
-
-static void barray_destroy (barray **ba)
-{
-    if (*ba)
-    {
-        mem_free ((void **) &(**ba).data);
-        mem_free ((void **) ba);
-    }
-}
-
-/*
-    reallocates byte array to requested size,
-    returns 0 on success,
-    returns 1 otherwise
-*/
-static int barray_resize (barray **ba, unsigned int nlen)
-{
-    byte *new_pointer;
-
-    if (nlen == 0)
-    {
-        mem_free ((void **) &(**ba).data);
-        (**ba).data = NULL;
-        (**ba).len = 0;
-
-        return 0;
-    }
-    else
-    {
-        new_pointer = (byte *) mem_realloc ((**ba).data, (**ba).len * sizeof (byte),
-            nlen * sizeof (byte));
-        if (new_pointer)
-        {
-            (**ba).data = new_pointer;
-            (**ba).len = nlen;
-
-            return 0;
-        }
-    }
-
-    return 1;
-}
-
-/*
-    adds byte array pointed by *nb to the end of array pointed by *ba,
-    returns 0 on success,
-    returns 1 otherwise
-*/
-static int barray_append (barray **ba, barray **nb)
-{
-    const unsigned int len = (**ba).len;
-
-    if (barray_resize (ba, (**ba).len + (**nb).len))
-        return 1;
-
-    mem_copy ((**ba).data + len, (**nb).data, (**nb).len);
-
-    return 0;
-}
-
-/*
-    adds emit chain pointed by em to the end of array pointed by *ba,
-    returns 0 on success,
-    returns 1 otherwise
-*/
-static int barray_push (barray **ba, emit *em, byte c, unsigned int pos, regbyte_ctx **rbc)
-{
-    unsigned int count = emit_size (em);
-
-    if (barray_resize (ba, (**ba).len + count))
-        return 1;
-
-    return emit_push (em, (**ba).data + ((**ba).len - count), c, pos, rbc);
-}
-
-/*
-    byte pool typedef
-*/
-typedef struct bytepool_
-{
-    byte *_F;
-    unsigned int _Siz;
-} bytepool;
-
-static void bytepool_destroy (bytepool **by)
-{
-    if (*by != NULL)
-    {
-        mem_free ((void **) &(**by)._F);
-        mem_free ((void **) by);
-    }
-}
-
-static void bytepool_create (bytepool **by, int len)
-{
-    *by = (bytepool *) (mem_alloc (sizeof (bytepool)));
-    if (*by != NULL)
-    {
-        (**by)._F = (byte *) (mem_alloc (sizeof (byte) * len));
-        (**by)._Siz = len;
-
-        if ((**by)._F == NULL)
-            bytepool_destroy (by);
-    }
-}
-
-static int bytepool_reserve (bytepool *by, unsigned int n)
-{
-    byte *_P;
-
-    if (n <= by->_Siz)
-        return 0;
-
-    /* byte pool can only grow and at least by doubling its size */
-    n = n >= by->_Siz * 2 ? n : by->_Siz * 2;
-
-    /* reallocate the memory and adjust pointers to the new memory location */
-    _P = (byte *) (mem_realloc (by->_F, sizeof (byte) * by->_Siz, sizeof (byte) * n));
-    if (_P != NULL)
-    {
-        by->_F = _P;
-        by->_Siz = n;
-        return 0;
-    }
-
-    return 1;
-}
-
-/*
-    string to string map typedef
-*/
-typedef struct map_str_
-{
-    byte *key;
-    byte *data;
-    struct map_str_ *next;
-} map_str;
-
-static void map_str_create (map_str **ma)
-{
-    *ma = (map_str *) mem_alloc (sizeof (map_str));
-    if (*ma)
-    {
-        (**ma).key = NULL;
-        (**ma).data = NULL;
-        (**ma).next = NULL;
-    }
-}
-
-static void map_str_destroy (map_str **ma)
-{
-    if (*ma)
-    {
-        map_str_destroy (&(**ma).next);
-        mem_free ((void **) &(**ma).key);
-        mem_free ((void **) &(**ma).data);
-        mem_free ((void **) ma);
-    }
-}
-
-GRAMMAR_IMPLEMENT_LIST_APPEND(map_str)
-
-/*
-    searches the map for specified key,
-    if the key is matched, *data is filled with data associated with the key,
-    returns 0 if the key is matched,
-    returns 1 otherwise
-*/
-static int map_str_find (map_str **ma, const byte *key, byte **data)
-{
-    while (*ma)
-    {
-        if (str_equal ((**ma).key, key))
-        {
-            *data = str_duplicate ((**ma).data);
-            if (*data == NULL)
-                return 1;
-
-            return 0;
-        }
-
-        ma = &(**ma).next;
-    }
-
-    set_last_error (UNRESOLVED_REFERENCE, str_duplicate (key), -1);
-    return 1;
-}
-
-/*
-    string to rule map typedef
-*/
-typedef struct map_rule_
-{
-    byte *key;
-    rule *data;
-    struct map_rule_ *next;
-} map_rule;
-
-static void map_rule_create (map_rule **ma)
-{
-    *ma = (map_rule *) mem_alloc (sizeof (map_rule));
-    if (*ma)
-    {
-        (**ma).key = NULL;
-        (**ma).data = NULL;
-        (**ma).next = NULL;
-    }
-}
-
-static void map_rule_destroy (map_rule **ma)
-{
-    if (*ma)
-    {
-        map_rule_destroy (&(**ma).next);
-        mem_free ((void **) &(**ma).key);
-        mem_free ((void **) ma);
-    }
-}
-
-GRAMMAR_IMPLEMENT_LIST_APPEND(map_rule)
-
-/*
-    searches the map for specified key,
-    if the key is matched, *data is filled with data associated with the key,
-    returns 0 if the is matched,
-    returns 1 otherwise
-*/
-static int map_rule_find (map_rule **ma, const byte *key, rule **data)
-{
-    while (*ma)
-    {
-        if (str_equal ((**ma).key, key))
-        {
-            *data = (**ma).data;
-
-            return 0;
-        }
-
-        ma = &(**ma).next;
-    }
-
-    set_last_error (UNRESOLVED_REFERENCE, str_duplicate (key), -1);
-    return 1;
-}
-
-/*
-    returns 1 if given character is a white space,
-    returns 0 otherwise
-*/
-static int is_space (byte c)
-{
-    return c == ' ' || c == '\t' || c == '\n' || c == '\r';
-}
-
-/*
-    advances text pointer by 1 if character pointed by *text is a space,
-    returns 1 if a space has been eaten,
-    returns 0 otherwise
-*/
-static int eat_space (const byte **text)
-{
-    if (is_space (**text))
-    {
-        (*text)++;
-
-        return 1;
-    }
-
-    return 0;
-}
-
-/*
-    returns 1 if text points to C-style comment start string,
-    returns 0 otherwise
-*/
-static int is_comment_start (const byte *text)
-{
-    return text[0] == '/' && text[1] == '*';
-}
-
-/*
-    advances text pointer to first character after C-style comment block - if any,
-    returns 1 if C-style comment block has been encountered and eaten,
-    returns 0 otherwise
-*/
-static int eat_comment (const byte **text)
-{
-    if (is_comment_start (*text))
-    {
-        /* *text points to comment block - skip two characters to enter comment body */
-        *text += 2;
-        /* skip any character except consecutive '*' and '/' */
-        while (!((*text)[0] == '*' && (*text)[1] == '/'))
-            (*text)++;
-        /* skip those two terminating characters */
-        *text += 2;
-
-        return 1;
-    }
-
-    return 0;
-}
-
-/*
-    advances text pointer to first character that is neither space nor C-style comment block
-*/
-static void eat_spaces (const byte **text)
-{
-    while (eat_space (text) || eat_comment (text))
-        ;
-}
-
-/*
-    resizes string pointed by *ptr to successfully add character c to the end of the string,
-    returns 0 on success,
-    returns 1 otherwise
-*/
-static int string_grow (byte **ptr, unsigned int *len, byte c)
-{
-    /* reallocate the string in 16-byte increments */
-    if ((*len & 0x0F) == 0x0F || *ptr == NULL)
-    {
-        byte *tmp = (byte *) mem_realloc (*ptr, ((*len + 1) & ~0x0F) * sizeof (byte),
-            ((*len + 1 + 0x10) & ~0x0F) * sizeof (byte));
-        if (tmp == NULL)
-            return 1;
-
-        *ptr = tmp;
-    }
-
-    if (c)
-    {
-        /* append given character */
-        (*ptr)[*len] = c;
-        (*len)++;
-    }
-    (*ptr)[*len] = '\0';
-
-    return 0;
-}
-
-/*
-    returns 1 if given character is a valid identifier character a-z, A-Z, 0-9 or _
-    returns 0 otherwise
-*/
-static int is_identifier (byte c)
-{
-    return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_';
-}
-
-/*
-    copies characters from *text to *id until non-identifier character is encountered,
-    assumes that *id points to NULL object - caller is responsible for later freeing the string,
-    text pointer is advanced to point past the copied identifier,
-    returns 0 if identifier was successfully copied,
-    returns 1 otherwise
-*/
-static int get_identifier (const byte **text, byte **id)
-{
-    const byte *t = *text;
-    byte *p = NULL;
-    unsigned int len = 0;
-
-    if (string_grow (&p, &len, '\0'))
-        return 1;
-
-    /* loop while next character in buffer is valid for identifiers */
-    while (is_identifier (*t))
-    {
-        if (string_grow (&p, &len, *t++))
-        {
-            mem_free ((void **) (void *) &p);
-            return 1;
-        }
-    }
-
-    *text = t;
-    *id = p;
-
-    return 0;
-}
-
-/*
-    converts sequence of DEC digits pointed by *text until non-DEC digit is encountered,
-    advances text pointer past the converted sequence,
-    returns the converted value
-*/
-static unsigned int dec_convert (const byte **text)
-{
-    unsigned int value = 0;
-
-    while (**text >= '0' && **text <= '9')
-    {
-        value = value * 10 + **text - '0';
-        (*text)++;
-    }
-
-    return value;
-}
-
-/*
-    returns 1 if given character is HEX digit 0-9, A-F or a-f,
-    returns 0 otherwise
-*/
-static int is_hex (byte c)
-{
-    return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f');
-}
-
-/*
-    returns value of passed character as if it was HEX digit
-*/
-static unsigned int hex2dec (byte c)
-{
-    if (c >= '0' && c <= '9')
-        return c - '0';
-    if (c >= 'A' && c <= 'F')
-        return c - 'A' + 10;
-    return c - 'a' + 10;
-}
-
-/*
-    converts sequence of HEX digits pointed by *text until non-HEX digit is encountered,
-    advances text pointer past the converted sequence,
-    returns the converted value
-*/
-static unsigned int hex_convert (const byte **text)
-{
-    unsigned int value = 0;
-
-    while (is_hex (**text))
-    {
-        value = value * 0x10 + hex2dec (**text);
-        (*text)++;
-    }
-
-    return value;
-}
-
-/*
-    returns 1 if given character is OCT digit 0-7,
-    returns 0 otherwise
-*/
-static int is_oct (byte c)
-{
-    return c >= '0' && c <= '7';
-}
-
-/*
-    returns value of passed character as if it was OCT digit
-*/
-static int oct2dec (byte c)
-{
-    return c - '0';
-}
-
-static byte get_escape_sequence (const byte **text)
-{
-    int value = 0;
-
-    /* skip '\' character */
-    (*text)++;
-
-    switch (*(*text)++)
-    {
-    case '\'':
-        return '\'';
-    case '"':
-        return '\"';
-    case '?':
-        return '\?';
-    case '\\':
-        return '\\';
-    case 'a':
-        return '\a';
-    case 'b':
-        return '\b';
-    case 'f':
-        return '\f';
-    case 'n':
-        return '\n';
-    case 'r':
-        return '\r';
-    case 't':
-        return '\t';
-    case 'v':
-        return '\v';
-    case 'x':
-        return (byte) hex_convert (text);
-    }
-
-    (*text)--;
-    if (is_oct (**text))
-    {
-        value = oct2dec (*(*text)++);
-        if (is_oct (**text))
-        {
-            value = value * 010 + oct2dec (*(*text)++);
-            if (is_oct (**text))
-                value = value * 010 + oct2dec (*(*text)++);
-        }
-    }
-
-    return (byte) value;
-}
-
-/*
-    copies characters from *text to *str until " or ' character is encountered,
-    assumes that *str points to NULL object - caller is responsible for later freeing the string,
-    assumes that *text points to " or ' character that starts the string,
-    text pointer is advanced to point past the " or ' character,
-    returns 0 if string was successfully copied,
-    returns 1 otherwise
-*/
-static int get_string (const byte **text, byte **str)
-{
-    const byte *t = *text;
-    byte *p = NULL;
-    unsigned int len = 0;
-    byte term_char;
-
-    if (string_grow (&p, &len, '\0'))
-        return 1;
-
-    /* read " or ' character that starts the string */
-    term_char = *t++;
-    /* while next character is not the terminating character */
-    while (*t && *t != term_char)
-    {
-        byte c;
-
-        if (*t == '\\')
-            c = get_escape_sequence (&t);
-        else
-            c = *t++;
-
-        if (string_grow (&p, &len, c))
-        {
-            mem_free ((void **) (void *) &p);
-            return 1;
-        }
-    }
-    /* skip " or ' character that ends the string */
-    t++;
-
-    *text = t;
-    *str = p;
-    return 0;
-}
-
-/*
-    gets emit code, the syntax is:
-    ".emtcode" " " <symbol> " " (("0x" | "0X") <hex_value>) | <dec_value> | <character>
-    assumes that *text already points to <symbol>,
-    returns 0 if emit code is successfully read,
-    returns 1 otherwise
-*/
-static int get_emtcode (const byte **text, map_byte **ma)
-{
-    const byte *t = *text;
-    map_byte *m = NULL;
-
-    map_byte_create (&m);
-    if (m == NULL)
-        return 1;
-
-    if (get_identifier (&t, &m->key))
-    {
-        map_byte_destroy (&m);
-        return 1;
-    }
-    eat_spaces (&t);
-
-    if (*t == '\'')
-    {
-        byte *c;
-
-        if (get_string (&t, &c))
-        {
-            map_byte_destroy (&m);
-            return 1;
-        }
-
-        m->data = (byte) c[0];
-        mem_free ((void **) (void *) &c);
-    }
-    else if (t[0] == '0' && (t[1] == 'x' || t[1] == 'X'))
-    {
-        /* skip HEX "0x" or "0X" prefix */
-        t += 2;
-        m->data = (byte) hex_convert (&t);
-    }
-    else
-    {
-        m->data = (byte) dec_convert (&t);
-    }
-
-    eat_spaces (&t);
-
-    *text = t;
-    *ma = m;
-    return 0;
-}
-
-/*
-    gets regbyte declaration, the syntax is:
-    ".regbyte" " " <symbol> " " (("0x" | "0X") <hex_value>) | <dec_value> | <character>
-    assumes that *text already points to <symbol>,
-    returns 0 if regbyte is successfully read,
-    returns 1 otherwise
-*/
-static int get_regbyte (const byte **text, map_byte **ma)
-{
-    /* pass it to the emtcode parser as it has the same syntax starting at <symbol> */
-    return get_emtcode (text, ma);
-}
-
-/*
-    returns 0 on success,
-    returns 1 otherwise
-*/
-static int get_errtext (const byte **text, map_str **ma)
-{
-    const byte *t = *text;
-    map_str *m = NULL;
-
-    map_str_create (&m);
-    if (m == NULL)
-        return 1;
-
-    if (get_identifier (&t, &m->key))
-    {
-        map_str_destroy (&m);
-        return 1;
-    }
-    eat_spaces (&t);
-
-    if (get_string (&t, &m->data))
-    {
-        map_str_destroy (&m);
-        return 1;
-    }
-    eat_spaces (&t);
-
-    *text = t;
-    *ma = m;
-    return 0;
-}
-
-/*
-    returns 0 on success,
-    returns 1 otherwise,
-*/
-static int get_error (const byte **text, error **er, map_str *maps)
-{
-    const byte *t = *text;
-    byte *temp = NULL;
-
-    if (*t != '.')
-        return 0;
-
-    t++;
-    if (get_identifier (&t, &temp))
-        return 1;
-    eat_spaces (&t);
-
-    if (!str_equal ((byte *) "error", temp))
-    {
-        mem_free ((void **) (void *) &temp);
-        return 0;
-    }
-
-    mem_free ((void **) (void *) &temp);
-
-    error_create (er);
-    if (*er == NULL)
-        return 1;
-
-    if (*t == '\"')
-    {
-        if (get_string (&t, &(**er).m_text))
-        {
-            error_destroy (er);
-            return 1;
-        }
-        eat_spaces (&t);
-    }
-    else
-    {
-        if (get_identifier (&t, &temp))
-        {
-            error_destroy (er);
-            return 1;
-        }
-        eat_spaces (&t);
-
-        if (map_str_find (&maps, temp, &(**er).m_text))
-        {
-            mem_free ((void **) (void *) &temp);
-            error_destroy (er);
-            return 1;
-        }
-
-        mem_free ((void **) (void *) &temp);
-    }
-
-    /* try to extract "token" from "...$token$..." */
-    {
-        byte *processed = NULL;
-        unsigned int len = 0;
-      int i = 0;
-
-        if (string_grow (&processed, &len, '\0'))
-        {
-            error_destroy (er);
-            return 1;
-        }
-
-        while (i < str_length ((**er).m_text))
-        {
-            /* check if the dollar sign is repeated - if so skip it */
-            if ((**er).m_text[i] == '$' && (**er).m_text[i + 1] == '$')
-            {
-                if (string_grow (&processed, &len, '$'))
-                {
-                    mem_free ((void **) (void *) &processed);
-                    error_destroy (er);
-                    return 1;
-                }
-
-                i += 2;
-            }
-            else if ((**er).m_text[i] != '$')
-            {
-                if (string_grow (&processed, &len, (**er).m_text[i]))
-                {
-                    mem_free ((void **) (void *) &processed);
-                    error_destroy (er);
-                    return 1;
-                }
-
-                i++;
-            }
-            else
-            {
-                if (string_grow (&processed, &len, '$'))
-                {
-                    mem_free ((void **) (void *) &processed);
-                    error_destroy (er);
-                    return 1;
-                }
-
-                {
-                    /* length of token being extracted */
-                    unsigned int tlen = 0;
-
-                    if (string_grow (&(**er).m_token_name, &tlen, '\0'))
-                    {
-                        mem_free ((void **) (void *) &processed);
-                        error_destroy (er);
-                        return 1;
-                    }
-
-                    /* skip the dollar sign */
-                    i++;
-
-                    while ((**er).m_text[i] != '$')
-                    {
-                        if (string_grow (&(**er).m_token_name, &tlen, (**er).m_text[i]))
-                        {
-                            mem_free ((void **) (void *) &processed);
-                            error_destroy (er);
-                            return 1;
-                        }
-
-                        i++;
-                    }
-
-                    /* skip the dollar sign */
-                    i++;
-                }
-            }
-        }
-
-        mem_free ((void **) &(**er).m_text);
-        (**er).m_text = processed;
-    }
-
-    *text = t;
-    return 0;
-}
-
-/*
-    returns 0 on success,
-    returns 1 otherwise,
-*/
-static int get_emits (const byte **text, emit **em, map_byte *mapb)
-{
-    const byte *t = *text;
-    byte *temp = NULL;
-    emit *e = NULL;
-    emit_dest dest;
-
-    if (*t != '.')
-        return 0;
-
-    t++;
-    if (get_identifier (&t, &temp))
-        return 1;
-    eat_spaces (&t);
-
-    /* .emit */
-    if (str_equal ((byte *) "emit", temp))
-        dest = ed_output;
-    /* .load */
-    else if (str_equal ((byte *) "load", temp))
-        dest = ed_regbyte;
-    else
-    {
-        mem_free ((void **) (void *) &temp);
-        return 0;
-    }
-
-    mem_free ((void **) (void *) &temp);
-
-    emit_create (&e);
-    if (e == NULL)
-        return 1;
-
-    e->m_emit_dest = dest;
-
-    if (dest == ed_regbyte)
-    {
-        if (get_identifier (&t, &e->m_regname))
-        {
-            emit_destroy (&e);
-            return 1;
-        }
-        eat_spaces (&t);
-    }
-
-    /* 0xNN */
-    if (*t == '0' && (t[1] == 'x' || t[1] == 'X'))
-    {
-        t += 2;
-        e->m_byte = (byte) hex_convert (&t);
-
-        e->m_emit_type = et_byte;
-    }
-    /* NNN */
-    else if (*t >= '0' && *t <= '9')
-    {
-        e->m_byte = (byte) dec_convert (&t);
-
-        e->m_emit_type = et_byte;
-    }
-    /* * */
-    else if (*t == '*')
-    {
-        t++;
-
-        e->m_emit_type = et_stream;
-    }
-    /* $ */
-    else if (*t == '$')
-    {
-        t++;
-
-        e->m_emit_type = et_position;
-    }
-    /* 'c' */
-    else if (*t == '\'')
-    {
-        if (get_string (&t, &temp))
-        {
-            emit_destroy (&e);
-            return 1;
-        }
-        e->m_byte = (byte) temp[0];
-
-        mem_free ((void **) (void *) &temp);
-
-        e->m_emit_type = et_byte;
-    }
-    else
-    {
-        if (get_identifier (&t, &temp))
-        {
-            emit_destroy (&e);
-            return 1;
-        }
-
-        if (map_byte_find (&mapb, temp, &e->m_byte))
-        {
-            mem_free ((void **) (void *) &temp);
-            emit_destroy (&e);
-            return 1;
-        }
-
-        mem_free ((void **) (void *) &temp);
-
-        e->m_emit_type = et_byte;
-    }
-
-    eat_spaces (&t);
-
-    if (get_emits (&t, &e->m_next, mapb))
-    {
-        emit_destroy (&e);
-        return 1;
-    }
-
-    *text = t;
-    *em = e;
-    return 0;
-}
-
-/*
-    returns 0 on success,
-    returns 1 otherwise,
-*/
-static int get_spec (const byte **text, spec **sp, map_str *maps, map_byte *mapb)
-{
-    const byte *t = *text;
-    spec *s = NULL;
-
-    spec_create (&s);
-    if (s == NULL)
-        return 1;
-
-    /* first - read optional .if statement */
-    if (*t == '.')
-    {
-        const byte *u = t;
-        byte *keyword = NULL;
-
-        /* skip the dot */
-        u++;
-
-        if (get_identifier (&u, &keyword))
-        {
-            spec_destroy (&s);
-            return 1;
-        }
-
-        /* .if */
-        if (str_equal ((byte *) "if", keyword))
-        {
-            cond_create (&s->m_cond);
-            if (s->m_cond == NULL)
-            {
-                spec_destroy (&s);
-                return 1;
-            }
-
-            /* skip the left paren */
-            eat_spaces (&u);
-            u++;
-
-            /* get the left operand */
-            eat_spaces (&u);
-            if (get_identifier (&u, &s->m_cond->m_operands[0].m_regname))
-            {
-                spec_destroy (&s);
-                return 1;
-            }
-            s->m_cond->m_operands[0].m_type = cot_regbyte;
-
-            /* get the operator (!= or ==) */
-            eat_spaces (&u);
-            if (*u == '!')
-                s->m_cond->m_type = ct_not_equal;
-            else
-                s->m_cond->m_type = ct_equal;
-            u += 2;
-            eat_spaces (&u);
-
-            if (u[0] == '0' && (u[1] == 'x' || u[1] == 'X'))
-            {
-                /* skip the 0x prefix */
-                u += 2;
-
-                /* get the right operand */
-                s->m_cond->m_operands[1].m_byte = hex_convert (&u);
-                s->m_cond->m_operands[1].m_type = cot_byte;
-            }
-            else /*if (*u >= '0' && *u <= '9')*/
-            {
-                /* get the right operand */
-                s->m_cond->m_operands[1].m_byte = dec_convert (&u);
-                s->m_cond->m_operands[1].m_type = cot_byte;
-            }
-
-            /* skip the right paren */
-            eat_spaces (&u);
-            u++;
-
-            eat_spaces (&u);
-
-            t = u;
-        }
-
-        mem_free ((void **) (void *) &keyword);
-    }
-
-    if (*t == '\'')
-    {
-        byte *temp = NULL;
-
-        if (get_string (&t, &temp))
-        {
-            spec_destroy (&s);
-            return 1;
-        }
-        eat_spaces (&t);
-
-        if (*t == '-')
-        {
-            byte *temp2 = NULL;
-
-            /* skip the '-' character */
-            t++;
-            eat_spaces (&t);
-
-            if (get_string (&t, &temp2))
-            {
-                mem_free ((void **) (void *) &temp);
-                spec_destroy (&s);
-                return 1;
-            }
-            eat_spaces (&t);
-
-            s->m_spec_type = st_byte_range;
-            s->m_byte[0] = *temp;
-            s->m_byte[1] = *temp2;
-
-            mem_free ((void **) (void *) &temp2);
-        }
-        else
-        {
-            s->m_spec_type = st_byte;
-            *s->m_byte = *temp;
-        }
-
-        mem_free ((void **) (void *) &temp);
-    }
-    else if (*t == '"')
-    {
-        if (get_string (&t, &s->m_string))
-        {
-            spec_destroy (&s);
-            return 1;
-        }
-        eat_spaces (&t);
-
-        s->m_spec_type = st_string;
-    }
-    else if (*t == '.')
-    {
-        byte *keyword = NULL;
-
-        /* skip the dot */
-        t++;
-
-        if (get_identifier (&t, &keyword))
-        {
-            spec_destroy (&s);
-            return 1;
-        }
-        eat_spaces (&t);
-
-        /* .true */
-        if (str_equal ((byte *) "true", keyword))
-        {
-            s->m_spec_type = st_true;
-        }
-        /* .false */
-        else if (str_equal ((byte *) "false", keyword))
-        {
-            s->m_spec_type = st_false;
-        }
-        /* .debug */
-        else if (str_equal ((byte *) "debug", keyword))
-        {
-            s->m_spec_type = st_debug;
-        }
-        /* .loop */
-        else if (str_equal ((byte *) "loop", keyword))
-        {
-            if (get_identifier (&t, &s->m_string))
-            {
-                mem_free ((void **) (void *) &keyword);
-                spec_destroy (&s);
-                return 1;
-            }
-            eat_spaces (&t);
-
-            s->m_spec_type = st_identifier_loop;
-        }
-        mem_free ((void **) (void *) &keyword);
-    }
-    else
-    {
-        if (get_identifier (&t, &s->m_string))
-        {
-            spec_destroy (&s);
-            return 1;
-        }
-        eat_spaces (&t);
-
-        s->m_spec_type = st_identifier;
-    }
-
-    if (get_error (&t, &s->m_errtext, maps))
-    {
-        spec_destroy (&s);
-        return 1;
-    }
-
-    if (get_emits (&t, &s->m_emits, mapb))
-    {
-        spec_destroy (&s);
-        return 1;
-    }
-
-    *text = t;
-    *sp = s;
-    return 0;
-}
-
-/*
-    returns 0 on success,
-    returns 1 otherwise,
-*/
-static int get_rule (const byte **text, rule **ru, map_str *maps, map_byte *mapb)
-{
-    const byte *t = *text;
-    rule *r = NULL;
-
-    rule_create (&r);
-    if (r == NULL)
-        return 1;
-
-    if (get_spec (&t, &r->m_specs, maps, mapb))
-    {
-        rule_destroy (&r);
-        return 1;
-    }
-
-    while (*t != ';')
-    {
-        byte *op = NULL;
-        spec *sp = NULL;
-
-        /* skip the dot that precedes "and" or "or" */
-        t++;
-
-        /* read "and" or "or" keyword */
-        if (get_identifier (&t, &op))
-        {
-            rule_destroy (&r);
-            return 1;
-        }
-        eat_spaces (&t);
-
-        if (r->m_oper == op_none)
-        {
-            /* .and */
-            if (str_equal ((byte *) "and", op))
-                r->m_oper = op_and;
-            /* .or */
-            else
-                r->m_oper = op_or;
-        }
-
-        mem_free ((void **) (void *) &op);
-
-        if (get_spec (&t, &sp, maps, mapb))
-        {
-            rule_destroy (&r);
-            return 1;
-        }
-
-        spec_append (&r->m_specs, sp);
-    }
-
-    /* skip the semicolon */
-    t++;
-    eat_spaces (&t);
-
-    *text = t;
-    *ru = r;
-    return 0;
-}
-
-/*
-    returns 0 on success,
-    returns 1 otherwise,
-*/
-static int update_dependency (map_rule *mapr, byte *symbol, rule **ru)
-{
-    if (map_rule_find (&mapr, symbol, ru))
-        return 1;
-
-    (**ru).m_referenced = 1;
-
-    return 0;
-}
-
-/*
-    returns 0 on success,
-    returns 1 otherwise,
-*/
-static int update_dependencies (dict *di, map_rule *mapr, byte **syntax_symbol,
-    byte **string_symbol, map_byte *regbytes)
-{
-    rule *rulez = di->m_rulez;
-
-    /* update dependecies for the root and lexer symbols */
-    if (update_dependency (mapr, *syntax_symbol, &di->m_syntax) ||
-        (*string_symbol != NULL && update_dependency (mapr, *string_symbol, &di->m_string)))
-        return 1;
-
-    mem_free ((void **) syntax_symbol);
-    mem_free ((void **) string_symbol);
-
-    /* update dependecies for the rest of the rules */
-    while (rulez)
-    {
-        spec *sp = rulez->m_specs;
-
-        /* iterate through all the specifiers */
-        while (sp)
-        {
-            /* update dependency for identifier */
-            if (sp->m_spec_type == st_identifier || sp->m_spec_type == st_identifier_loop)
-            {
-                if (update_dependency (mapr, sp->m_string, &sp->m_rule))
-                    return 1;
-
-                mem_free ((void **) &sp->m_string);
-            }
-
-            /* some errtexts reference to a rule */
-            if (sp->m_errtext && sp->m_errtext->m_token_name)
-            {
-                if (update_dependency (mapr, sp->m_errtext->m_token_name, &sp->m_errtext->m_token))
-                    return 1;
-
-                mem_free ((void **) &sp->m_errtext->m_token_name);
-            }
-
-            /* update dependency for condition */
-            if (sp->m_cond)
-            {
-                int i;
-                for (i = 0; i < 2; i++)
-                    if (sp->m_cond->m_operands[i].m_type == cot_regbyte)
-                    {
-                        sp->m_cond->m_operands[i].m_regbyte = map_byte_locate (&regbytes,
-                            sp->m_cond->m_operands[i].m_regname);
-
-                        if (sp->m_cond->m_operands[i].m_regbyte == NULL)
-                            return 1;
-
-                        mem_free ((void **) &sp->m_cond->m_operands[i].m_regname);
-                    }
-            }
-
-            /* update dependency for all .load instructions */
-            if (sp->m_emits)
-            {
-                emit *em = sp->m_emits;
-                while (em != NULL)
-                {
-                    if (em->m_emit_dest == ed_regbyte)
-                    {
-                        em->m_regbyte = map_byte_locate (&regbytes, em->m_regname);
-
-                        if (em->m_regbyte == NULL)
-                            return 1;
-
-                        mem_free ((void **) &em->m_regname);
-                    }
-
-                    em = em->m_next;
-                }
-            }
-
-            sp = sp->next;
-        }
-
-        rulez = rulez->next;
-    }
-
-    /* check for unreferenced symbols */
-    rulez = di->m_rulez;
-    while (rulez != NULL)
-    {
-        if (!rulez->m_referenced)
-        {
-            map_rule *ma = mapr;
-            while (ma)
-            {
-                if (ma->data == rulez)
-                {
-                    set_last_error (UNREFERENCED_IDENTIFIER, str_duplicate (ma->key), -1);
-                    return 1;
-                }
-                ma = ma->next;
-            }
-        }
-        rulez = rulez->next;
-    }
-
-    return 0;
-}
-
-static int satisfies_condition (cond *co, regbyte_ctx *ctx)
-{
-    byte values[2];
-    int i;
-
-    if (co == NULL)
-        return 1;
-
-    for (i = 0; i < 2; i++)
-        switch (co->m_operands[i].m_type)
-        {
-        case cot_byte:
-            values[i] = co->m_operands[i].m_byte;
-            break;
-        case cot_regbyte:
-            values[i] = regbyte_ctx_extract (&ctx, co->m_operands[i].m_regbyte);
-            break;
-        }
-
-    switch (co->m_type)
-    {
-    case ct_equal:
-        return values[0] == values[1];
-    case ct_not_equal:
-        return values[0] != values[1];
-    }
-
-    return 0;
-}
-
-static void free_regbyte_ctx_stack (regbyte_ctx *top, regbyte_ctx *limit)
-{
-    while (top != limit)
-    {
-        regbyte_ctx *rbc = top->m_prev;
-        regbyte_ctx_destroy (&top);
-        top = rbc;
-    }
-}
-
-typedef enum match_result_
-{
-    mr_not_matched,     /* the examined string does not match */
-    mr_matched,         /* the examined string matches */
-    mr_error_raised,    /* mr_not_matched + error has been raised */
-    mr_dont_emit,       /* used by identifier loops only */
-    mr_internal_error   /* an internal error has occured such as out of memory */
-} match_result;
-
-/*
- * This function does the main job. It parses the text and generates output data.
- */
-static match_result
-match (dict *di, const byte *text, int *index, rule *ru, barray **ba, int filtering_string,
-       regbyte_ctx **rbc)
-{
-   int ind = *index;
-    match_result status = mr_not_matched;
-    spec *sp = ru->m_specs;
-    regbyte_ctx *ctx = *rbc;
-
-    /* for every specifier in the rule */
-    while (sp)
-    {
-      int i, len, save_ind = ind;
-        barray *array = NULL;
-
-        if (satisfies_condition (sp->m_cond, ctx))
-        {
-            switch (sp->m_spec_type)
-            {
-            case st_identifier:
-                barray_create (&array);
-                if (array == NULL)
-                {
-                    free_regbyte_ctx_stack (ctx, *rbc);
-                    return mr_internal_error;
-                }
-
-                status = match (di, text, &ind, sp->m_rule, &array, filtering_string, &ctx);
-
-                if (status == mr_internal_error)
-                {
-                    free_regbyte_ctx_stack (ctx, *rbc);
-                    barray_destroy (&array);
-                    return mr_internal_error;
-                }
-                break;
-            case st_string:
-                len = str_length (sp->m_string);
-
-                /* prefilter the stream */
-                if (!filtering_string && di->m_string)
-                {
-                    barray *ba;
-               int filter_index = 0;
-                    match_result result;
-                    regbyte_ctx *null_ctx = NULL;
-
-                    barray_create (&ba);
-                    if (ba == NULL)
-                    {
-                        free_regbyte_ctx_stack (ctx, *rbc);
-                        return mr_internal_error;
-                    }
-
-                    result = match (di, text + ind, &filter_index, di->m_string, &ba, 1, &null_ctx);
-
-                    if (result == mr_internal_error)
-                    {
-                        free_regbyte_ctx_stack (ctx, *rbc);
-                        barray_destroy (&ba);
-                        return mr_internal_error;
-                    }
-
-                    if (result != mr_matched)
-                    {
-                        barray_destroy (&ba);
-                        status = mr_not_matched;
-                        break;
-                    }
-
-                    barray_destroy (&ba);
-
-                    if (filter_index != len || !str_equal_n (sp->m_string, text + ind, len))
-                    {
-                        status = mr_not_matched;
-                        break;
-                    }
-
-                    status = mr_matched;
-                    ind += len;
-                }
-                else
-                {
-                    status = mr_matched;
-                    for (i = 0; status == mr_matched && i < len; i++)
-                        if (text[ind + i] != sp->m_string[i])
-                            status = mr_not_matched;
-
-                    if (status == mr_matched)
-                        ind += len;
-                }
-                break;
-            case st_byte:
-                status = text[ind] == *sp->m_byte ? mr_matched : mr_not_matched;
-                if (status == mr_matched)
-                    ind++;
-                break;
-            case st_byte_range:
-                status = (text[ind] >= sp->m_byte[0] && text[ind] <= sp->m_byte[1]) ?
-                    mr_matched : mr_not_matched;
-                if (status == mr_matched)
-                    ind++;
-                break;
-            case st_true:
-                status = mr_matched;
-                break;
-            case st_false:
-                status = mr_not_matched;
-                break;
-            case st_debug:
-                status = ru->m_oper == op_and ? mr_matched : mr_not_matched;
-                break;
-            case st_identifier_loop:
-                barray_create (&array);
-                if (array == NULL)
-                {
-                    free_regbyte_ctx_stack (ctx, *rbc);
-                    return mr_internal_error;
-                }
-
-                status = mr_dont_emit;
-                for (;;)
-                {
-                    match_result result;
-
-                    save_ind = ind;
-                    result = match (di, text, &ind, sp->m_rule, &array, filtering_string, &ctx);
-
-                    if (result == mr_error_raised)
-                    {
-                        status = result;
-                        break;
-                    }
-                    else if (result == mr_matched)
-                    {
-                        if (barray_push (ba, sp->m_emits, text[ind - 1], save_ind, &ctx) ||
-                            barray_append (ba, &array))
-                        {
-                            free_regbyte_ctx_stack (ctx, *rbc);
-                            barray_destroy (&array);
-                            return mr_internal_error;
-                        }
-                        barray_destroy (&array);
-                        barray_create (&array);
-                        if (array == NULL)
-                        {
-                            free_regbyte_ctx_stack (ctx, *rbc);
-                            return mr_internal_error;
-                        }
-                    }
-                    else if (result == mr_internal_error)
-                    {
-                        free_regbyte_ctx_stack (ctx, *rbc);
-                        barray_destroy (&array);
-                        return mr_internal_error;
-                    }
-                    else
-                        break;
-                }
-                break;
-            }
-        }
-        else
-        {
-            status = mr_not_matched;
-        }
-
-        if (status == mr_error_raised)
-        {
-            free_regbyte_ctx_stack (ctx, *rbc);
-            barray_destroy (&array);
-
-            return mr_error_raised;
-        }
-
-        if (ru->m_oper == op_and && status != mr_matched && status != mr_dont_emit)
-        {
-            free_regbyte_ctx_stack (ctx, *rbc);
-            barray_destroy (&array);
-
-            if (sp->m_errtext)
-            {
-                set_last_error (sp->m_errtext->m_text, error_get_token (sp->m_errtext, di, text,
-                    ind), ind);
-
-                return mr_error_raised;
-            }
-
-            return mr_not_matched;
-        }
-
-        if (status == mr_matched)
-        {
-            if (sp->m_emits)
-                if (barray_push (ba, sp->m_emits, text[ind - 1], save_ind, &ctx))
-                {
-                    free_regbyte_ctx_stack (ctx, *rbc);
-                    barray_destroy (&array);
-                    return mr_internal_error;
-                }
-
-            if (array)
-                if (barray_append (ba, &array))
-                {
-                    free_regbyte_ctx_stack (ctx, *rbc);
-                    barray_destroy (&array);
-                    return mr_internal_error;
-                }
-        }
-
-        barray_destroy (&array);
-
-        /* if the rule operator is a logical or, we pick up the first matching specifier */
-        if (ru->m_oper == op_or && (status == mr_matched || status == mr_dont_emit))
-        {
-            *index = ind;
-            *rbc = ctx;
-            return mr_matched;
-        }
-
-        sp = sp->next;
-    }
-
-    /* everything went fine - all specifiers match up */
-    if (ru->m_oper == op_and && (status == mr_matched || status == mr_dont_emit))
-    {
-        *index = ind;
-        *rbc = ctx;
-        return mr_matched;
-    }
-
-    free_regbyte_ctx_stack (ctx, *rbc);
-    return mr_not_matched;
-}
-
-static match_result
-fast_match (dict *di, const byte *text, int *index, rule *ru, int *_PP, bytepool *_BP,
-            int filtering_string, regbyte_ctx **rbc)
-{
-   int ind = *index;
-    int _P = filtering_string ? 0 : *_PP;
-    int _P2;
-    match_result status = mr_not_matched;
-    spec *sp = ru->m_specs;
-    regbyte_ctx *ctx = *rbc;
-
-    /* for every specifier in the rule */
-    while (sp)
-    {
-      int i, len, save_ind = ind;
-
-        _P2 = _P + (sp->m_emits ? emit_size (sp->m_emits) : 0);
-        if (bytepool_reserve (_BP, _P2))
-        {
-            free_regbyte_ctx_stack (ctx, *rbc);
-            return mr_internal_error;
-        }
-
-        if (satisfies_condition (sp->m_cond, ctx))
-        {
-            switch (sp->m_spec_type)
-            {
-            case st_identifier:
-                status = fast_match (di, text, &ind, sp->m_rule, &_P2, _BP, filtering_string, &ctx);
-
-                if (status == mr_internal_error)
-                {
-                    free_regbyte_ctx_stack (ctx, *rbc);
-                    return mr_internal_error;
-                }
-                break;
-            case st_string:
-                len = str_length (sp->m_string);
-
-                /* prefilter the stream */
-                if (!filtering_string && di->m_string)
-                {
-               int filter_index = 0;
-                    match_result result;
-                    regbyte_ctx *null_ctx = NULL;
-
-                    result = fast_match (di, text + ind, &filter_index, di->m_string, NULL, _BP, 1, &null_ctx);
-
-                    if (result == mr_internal_error)
-                    {
-                        free_regbyte_ctx_stack (ctx, *rbc);
-                        return mr_internal_error;
-                    }
-
-                    if (result != mr_matched)
-                    {
-                        status = mr_not_matched;
-                        break;
-                    }
-
-                    if (filter_index != len || !str_equal_n (sp->m_string, text + ind, len))
-                    {
-                        status = mr_not_matched;
-                        break;
-                    }
-
-                    status = mr_matched;
-                    ind += len;
-                }
-                else
-                {
-                    status = mr_matched;
-                    for (i = 0; status == mr_matched && i < len; i++)
-                        if (text[ind + i] != sp->m_string[i])
-                            status = mr_not_matched;
-
-                    if (status == mr_matched)
-                        ind += len;
-                }
-                break;
-            case st_byte:
-                status = text[ind] == *sp->m_byte ? mr_matched : mr_not_matched;
-                if (status == mr_matched)
-                    ind++;
-                break;
-            case st_byte_range:
-                status = (text[ind] >= sp->m_byte[0] && text[ind] <= sp->m_byte[1]) ?
-                    mr_matched : mr_not_matched;
-                if (status == mr_matched)
-                    ind++;
-                break;
-            case st_true:
-                status = mr_matched;
-                break;
-            case st_false:
-                status = mr_not_matched;
-                break;
-            case st_debug:
-                status = ru->m_oper == op_and ? mr_matched : mr_not_matched;
-                break;
-            case st_identifier_loop:
-                status = mr_dont_emit;
-                for (;;)
-                {
-                    match_result result;
-
-                    save_ind = ind;
-                    result = fast_match (di, text, &ind, sp->m_rule, &_P2, _BP, filtering_string, &ctx);
-
-                    if (result == mr_error_raised)
-                    {
-                        status = result;
-                        break;
-                    }
-                    else if (result == mr_matched)
-                    {
-                        if (!filtering_string)
-                        {
-                            if (sp->m_emits != NULL)
-                            {
-                                if (emit_push (sp->m_emits, _BP->_F + _P, text[ind - 1], save_ind, &ctx))
-                                {
-                                    free_regbyte_ctx_stack (ctx, *rbc);
-                                    return mr_internal_error;
-                                }
-                            }
-
-                            _P = _P2;
-                            _P2 += sp->m_emits ? emit_size (sp->m_emits) : 0;
-                            if (bytepool_reserve (_BP, _P2))
-                            {
-                                free_regbyte_ctx_stack (ctx, *rbc);
-                                return mr_internal_error;
-                            }
-                        }
-                    }
-                    else if (result == mr_internal_error)
-                    {
-                        free_regbyte_ctx_stack (ctx, *rbc);
-                        return mr_internal_error;
-                    }
-                    else
-                        break;
-                }
-                break;
-            }
-        }
-        else
-        {
-            status = mr_not_matched;
-        }
-
-        if (status == mr_error_raised)
-        {
-            free_regbyte_ctx_stack (ctx, *rbc);
-
-            return mr_error_raised;
-        }
-
-        if (ru->m_oper == op_and && status != mr_matched && status != mr_dont_emit)
-        {
-            free_regbyte_ctx_stack (ctx, *rbc);
-
-            if (sp->m_errtext)
-            {
-                set_last_error (sp->m_errtext->m_text, error_get_token (sp->m_errtext, di, text,
-                    ind), ind);
-
-                return mr_error_raised;
-            }
-
-            return mr_not_matched;
-        }
-
-        if (status == mr_matched)
-        {
-            if (sp->m_emits != NULL) {
-                const byte ch = (ind <= 0) ? 0 : text[ind - 1];
-                if (emit_push (sp->m_emits, _BP->_F + _P, ch, save_ind, &ctx))
-                {
-                    free_regbyte_ctx_stack (ctx, *rbc);
-                    return mr_internal_error;
-                }
-
-           }
-           _P = _P2;
-        }
-
-        /* if the rule operator is a logical or, we pick up the first matching specifier */
-        if (ru->m_oper == op_or && (status == mr_matched || status == mr_dont_emit))
-        {
-            *index = ind;
-            *rbc = ctx;
-            if (!filtering_string)
-                *_PP = _P;
-            return mr_matched;
-        }
-
-        sp = sp->next;
-    }
-
-    /* everything went fine - all specifiers match up */
-    if (ru->m_oper == op_and && (status == mr_matched || status == mr_dont_emit))
-    {
-        *index = ind;
-        *rbc = ctx;
-        if (!filtering_string)
-            *_PP = _P;
-        return mr_matched;
-    }
-
-    free_regbyte_ctx_stack (ctx, *rbc);
-    return mr_not_matched;
-}
-
-static byte *
-error_get_token (error *er, dict *di, const byte *text, int ind)
-{
-    byte *str = NULL;
-
-    if (er->m_token)
-    {
-        barray *ba;
-      int filter_index = 0;
-        regbyte_ctx *ctx = NULL;
-
-        barray_create (&ba);
-        if (ba != NULL)
-        {
-            if (match (di, text + ind, &filter_index, er->m_token, &ba, 0, &ctx) == mr_matched &&
-                filter_index)
-            {
-                str = (byte *) mem_alloc (filter_index + 1);
-                if (str != NULL)
-                {
-                    str_copy_n (str, text + ind, filter_index);
-                    str[filter_index] = '\0';
-                }
-            }
-            barray_destroy (&ba);
-        }
-    }
-
-    return str;
-}
-
-typedef struct grammar_load_state_
-{
-    dict *di;
-    byte *syntax_symbol;
-    byte *string_symbol;
-    map_str *maps;
-    map_byte *mapb;
-    map_rule *mapr;
-} grammar_load_state;
-
-static void grammar_load_state_create (grammar_load_state **gr)
-{
-    *gr = (grammar_load_state *) mem_alloc (sizeof (grammar_load_state));
-    if (*gr)
-    {
-        (**gr).di = NULL;
-        (**gr).syntax_symbol = NULL;
-        (**gr).string_symbol = NULL;
-        (**gr).maps = NULL;
-        (**gr).mapb = NULL;
-        (**gr).mapr = NULL;
-    }
-}
-
-static void grammar_load_state_destroy (grammar_load_state **gr)
-{
-    if (*gr)
-    {
-        dict_destroy (&(**gr).di);
-        mem_free ((void **) &(**gr).syntax_symbol);
-        mem_free ((void **) &(**gr).string_symbol);
-        map_str_destroy (&(**gr).maps);
-        map_byte_destroy (&(**gr).mapb);
-        map_rule_destroy (&(**gr).mapr);
-        mem_free ((void **) gr);
-    }
-}
-
-
-static void error_msg(int line, const char *msg)
-{
-   fprintf(stderr, "Error in grammar_load_from_text() at line %d: %s\n", line, msg);
-}
-
-
-/*
-    the API
-*/
-grammar grammar_load_from_text (const byte *text)
-{
-    grammar_load_state *g = NULL;
-    grammar id = 0;
-
-    clear_last_error ();
-
-    grammar_load_state_create (&g);
-    if (g == NULL) {
-        error_msg(__LINE__, "");
-        return 0;
-    }
-
-    dict_create (&g->di);
-    if (g->di == NULL)
-    {
-        grammar_load_state_destroy (&g);
-        error_msg(__LINE__, "");
-        return 0;
-    }
-
-    eat_spaces (&text);
-
-    /* skip ".syntax" keyword */
-    text += 7;
-    eat_spaces (&text);
-
-    /* retrieve root symbol */
-    if (get_identifier (&text, &g->syntax_symbol))
-    {
-        grammar_load_state_destroy (&g);
-        error_msg(__LINE__, "");
-        return 0;
-    }
-    eat_spaces (&text);
-
-    /* skip semicolon */
-    text++;
-    eat_spaces (&text);
-
-    while (*text)
-    {
-        byte *symbol = NULL;
-        int is_dot = *text == '.';
-
-        if (is_dot)
-            text++;
-
-        if (get_identifier (&text, &symbol))
-        {
-            grammar_load_state_destroy (&g);
-            error_msg(__LINE__, "");
-            return 0;
-        }
-        eat_spaces (&text);
-
-        /* .emtcode */
-        if (is_dot && str_equal (symbol, (byte *) "emtcode"))
-        {
-            map_byte *ma = NULL;
-
-            mem_free ((void **) (void *) &symbol);
-
-            if (get_emtcode (&text, &ma))
-            {
-                grammar_load_state_destroy (&g);
-                error_msg(__LINE__, "");
-                return 0;
-            }
-
-            map_byte_append (&g->mapb, ma);
-        }
-        /* .regbyte */
-        else if (is_dot && str_equal (symbol, (byte *) "regbyte"))
-        {
-            map_byte *ma = NULL;
-
-            mem_free ((void **) (void *) &symbol);
-
-            if (get_regbyte (&text, &ma))
-            {
-                grammar_load_state_destroy (&g);
-                error_msg(__LINE__, "");
-                return 0;
-            }
-
-            map_byte_append (&g->di->m_regbytes, ma);
-        }
-        /* .errtext */
-        else if (is_dot && str_equal (symbol, (byte *) "errtext"))
-        {
-            map_str *ma = NULL;
-
-            mem_free ((void **) (void *) &symbol);
-
-            if (get_errtext (&text, &ma))
-            {
-                grammar_load_state_destroy (&g);
-                error_msg(__LINE__, "");
-                return 0;
-            }
-
-            map_str_append (&g->maps, ma);
-        }
-        /* .string */
-        else if (is_dot && str_equal (symbol, (byte *) "string"))
-        {
-            mem_free ((void **) (void *) &symbol);
-
-            if (g->di->m_string != NULL)
-            {
-                grammar_load_state_destroy (&g);
-                error_msg(__LINE__, "");
-                return 0;
-            }
-
-            if (get_identifier (&text, &g->string_symbol))
-            {
-                grammar_load_state_destroy (&g);
-                error_msg(__LINE__, "");
-                return 0;
-            }
-
-            /* skip semicolon */
-            eat_spaces (&text);
-            text++;
-            eat_spaces (&text);
-        }
-        else
-        {
-            rule *ru = NULL;
-            map_rule *ma = NULL;
-
-            if (get_rule (&text, &ru, g->maps, g->mapb))
-            {
-                grammar_load_state_destroy (&g);
-                error_msg(__LINE__, "");
-                return 0;
-            }
-
-            rule_append (&g->di->m_rulez, ru);
-
-            /* if a rule consist of only one specifier, give it an ".and" operator */
-            if (ru->m_oper == op_none)
-                ru->m_oper = op_and;
-
-            map_rule_create (&ma);
-            if (ma == NULL)
-            {
-                grammar_load_state_destroy (&g);
-                error_msg(__LINE__, "");
-                return 0;
-            }
-
-            ma->key = symbol;
-            ma->data = ru;
-            map_rule_append (&g->mapr, ma);
-        }
-    }
-
-    if (update_dependencies (g->di, g->mapr, &g->syntax_symbol, &g->string_symbol,
-        g->di->m_regbytes))
-    {
-        grammar_load_state_destroy (&g);
-        error_msg(__LINE__, "update_dependencies() failed");
-        return 0;
-    }
-
-    dict_append (&g_dicts, g->di);
-    id = g->di->m_id;
-    g->di = NULL;
-
-    grammar_load_state_destroy (&g);
-
-    return id;
-}
-
-int grammar_set_reg8 (grammar id, const byte *name, byte value)
-{
-    dict *di = NULL;
-    map_byte *reg = NULL;
-
-    clear_last_error ();
-
-    dict_find (&g_dicts, id, &di);
-    if (di == NULL)
-    {
-        set_last_error (INVALID_GRAMMAR_ID, NULL, -1);
-        return 0;
-    }
-
-    reg = map_byte_locate (&di->m_regbytes, name);
-    if (reg == NULL)
-    {
-        set_last_error (INVALID_REGISTER_NAME, str_duplicate (name), -1);
-        return 0;
-    }
-
-    reg->data = value;
-    return 1;
-}
-
-/*
-    internal checking function used by both grammar_check and grammar_fast_check functions
-*/
-static int _grammar_check (grammar id, const byte *text, byte **prod, unsigned int *size,
-    unsigned int estimate_prod_size, int use_fast_path)
-{
-    dict *di = NULL;
-   int index = 0;
-
-    clear_last_error ();
-
-    dict_find (&g_dicts, id, &di);
-    if (di == NULL)
-    {
-        set_last_error (INVALID_GRAMMAR_ID, NULL, -1);
-        return 0;
-    }
-
-    *prod = NULL;
-    *size = 0;
-
-    if (use_fast_path)
-    {
-        regbyte_ctx *rbc = NULL;
-        bytepool *bp = NULL;
-        int _P = 0;
-
-        bytepool_create (&bp, estimate_prod_size);
-        if (bp == NULL)
-            return 0;
-
-        if (fast_match (di, text, &index, di->m_syntax, &_P, bp, 0, &rbc) != mr_matched)
-        {
-            bytepool_destroy (&bp);
-            free_regbyte_ctx_stack (rbc, NULL);
-            return 0;
-        }
-
-        free_regbyte_ctx_stack (rbc, NULL);
-
-        *prod = bp->_F;
-        *size = _P;
-        bp->_F = NULL;
-        bytepool_destroy (&bp);
-    }
-    else
-    {
-        regbyte_ctx *rbc = NULL;
-        barray *ba = NULL;
-
-        barray_create (&ba);
-        if (ba == NULL)
-            return 0;
-
-        if (match (di, text, &index, di->m_syntax, &ba, 0, &rbc) != mr_matched)
-        {
-            barray_destroy (&ba);
-            free_regbyte_ctx_stack (rbc, NULL);
-            return 0;
-        }
-
-        free_regbyte_ctx_stack (rbc, NULL);
-
-        *prod = (byte *) mem_alloc (ba->len * sizeof (byte));
-        if (*prod == NULL)
-        {
-            barray_destroy (&ba);
-            return 0;
-        }
-
-        mem_copy (*prod, ba->data, ba->len * sizeof (byte));
-        *size = ba->len;
-        barray_destroy (&ba);
-    }
-
-    return 1;
-}
-
-int grammar_check (grammar id, const byte *text, byte **prod, unsigned int *size)
-{
-    return _grammar_check (id, text, prod, size, 0, 0);
-}
-
-int grammar_fast_check (grammar id, const byte *text, byte **prod, unsigned int *size,
-    unsigned int estimate_prod_size)
-{
-    return _grammar_check (id, text, prod, size, estimate_prod_size, 1);
-}
-
-int grammar_destroy (grammar id)
-{
-    dict **di = &g_dicts;
-
-    clear_last_error ();
-
-    while (*di != NULL)
-    {
-        if ((**di).m_id == id)
-        {
-            dict *tmp = *di;
-            *di = (**di).next;
-            dict_destroy (&tmp);
-            return 1;
-        }
-
-        di = &(**di).next;
-    }
-
-    set_last_error (INVALID_GRAMMAR_ID, NULL, -1);
-    return 0;
-}
-
-static void append_character (const char x, byte *text, int *dots_made, int *len, int size)
-{
-    if (*dots_made == 0)
-    {
-        if (*len < size - 1)
-        {
-            text[(*len)++] = x;
-            text[*len] = '\0';
-        }
-        else
-        {
-            int i;
-            for (i = 0; i < 3; i++)
-                if (--(*len) >= 0)
-                    text[*len] = '.';
-            *dots_made = 1;
-        }
-    }
-}
-
-void grammar_get_last_error (byte *text, unsigned int size, int *pos)
-{
-    int len = 0, dots_made = 0;
-    const byte *p = error_message;
-
-    *text = '\0';
-
-    if (p)
-    {
-        while (*p)
-        {
-            if (*p == '$')
-            {
-                const byte *r = error_param;
-
-                while (*r)
-                {
-                    append_character (*r++, text, &dots_made, &len, (int) size);
-                }
-
-                p++;
-            }
-            else
-            {
-                append_character (*p++, text, &dots_made, &len, size);
-            }
-        }
-    }
-
-    *pos = error_position;
-}
diff --git a/src/mesa/shader/grammar/grammar.h b/src/mesa/shader/grammar/grammar.h
deleted file mode 100644 (file)
index 591e38a..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version:  6.2
- *
- * Copyright (C) 1999-2004  Brian Paul   All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#ifndef GRAMMAR_H
-#define GRAMMAR_H
-
-
-#ifndef GRAMMAR_PORT_INCLUDE
-#error Do not include this file directly, include your grammar_XXX.h instead
-#endif
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void grammar_alloc_free (void *);
-void *grammar_alloc_malloc (size_t);
-void *grammar_alloc_realloc (void *, size_t, size_t);
-void *grammar_memory_copy (void *, const void *, size_t);
-int grammar_string_compare (const byte *, const byte *);
-int grammar_string_compare_n (const byte *, const byte *, size_t);
-byte *grammar_string_copy (byte *, const byte *);
-byte *grammar_string_copy_n (byte *, const byte *, size_t);
-byte *grammar_string_duplicate (const byte *);
-unsigned int grammar_string_length (const byte *);
-
-/*
-    loads grammar script from null-terminated ASCII <text>
-    returns unique grammar id to grammar object
-    returns 0 if an error occurs (call grammar_get_last_error to retrieve the error text)
-*/
-grammar grammar_load_from_text (const byte *text);
-
-/*
-    sets a new <value> to a register <name> for grammar <id>
-    returns 0 on error (call grammar_get_last_error to retrieve the error text)
-    returns 1 on success
-*/
-int grammar_set_reg8 (grammar id, const byte *name, byte value);
-
-/*
-    this function is obsolete, use only for debugging purposes
-
-    checks if a null-terminated <text> matches given grammar <id>
-    returns 0 on error (call grammar_get_last_error to retrieve the error text)
-    returns 1 on success, the <prod> points to newly allocated buffer with production and <size>
-    is filled with the production size
-    call grammar_alloc_free to free the memory block pointed by <prod>
-*/
-int grammar_check (grammar id, const byte *text, byte **prod, unsigned int *size);
-
-/*
-    does the same what grammar_check does but much more (approx. 4 times) faster
-    use this function instead of grammar_check
-    <estimate_prod_size> is a hint - the initial production buffer size will be of this size,
-    but if more room is needed it will be safely resized; set it to 0x1000 or so
-*/
-int grammar_fast_check (grammar id, const byte *text, byte **prod, unsigned int *size,
-    unsigned int estimate_prod_size);
-
-/*
-    destroys grammar object identified by <id>
-    returns 0 on error (call grammar_get_last_error to retrieve the error text)
-    returns 1 on success
-*/
-int grammar_destroy (grammar id);
-
-/*
-    retrieves last grammar error reported either by grammar_load_from_text, grammar_check
-    or grammar_destroy
-    the user allocated <text> buffer receives error description, <pos> points to error position,
-    <size> is the size of the text buffer to fill in - it must be at least 4 bytes long,
-*/
-void grammar_get_last_error (byte *text, unsigned int size, int *pos);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
diff --git a/src/mesa/shader/grammar/grammar.syn b/src/mesa/shader/grammar/grammar.syn
deleted file mode 100644 (file)
index 5d99f65..0000000
+++ /dev/null
@@ -1,567 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version:  6.2
- *
- * Copyright (C) 1999-2004  Brian Paul   All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
- /**
- * \file grammar.syn
- * syntax of .syn script - used to validate other syntax files
- * \author Michal Krol
- */
-.syntax grammar;
-
-/* declaration */
-.emtcode DECLARATION_END                            0
-.emtcode DECLARATION_EMITCODE                       1
-.emtcode DECLARATION_ERRORTEXT                      2
-.emtcode DECLARATION_REGBYTE                        3
-.emtcode DECLARATION_LEXER                          4
-.emtcode DECLARATION_RULE                           5
-
-/* specifier */
-.emtcode SPECIFIER_END                              0
-.emtcode SPECIFIER_AND_TAG                          1
-.emtcode SPECIFIER_OR_TAG                           2
-.emtcode SPECIFIER_CHARACTER_RANGE                  3
-.emtcode SPECIFIER_CHARACTER                        4
-.emtcode SPECIFIER_STRING                           5
-.emtcode SPECIFIER_IDENTIFIER                       6
-.emtcode SPECIFIER_TRUE                             7
-.emtcode SPECIFIER_FALSE                            8
-.emtcode SPECIFIER_DEBUG                            9
-
-/* identifier */
-.emtcode IDENTIFIER_SIMPLE                          0
-.emtcode IDENTIFIER_LOOP                            1
-
-/* error */
-.emtcode ERROR_NOT_PRESENT                          0
-.emtcode ERROR_PRESENT                              1
-
-/* emit */
-.emtcode EMIT_NULL                                  0
-.emtcode EMIT_INTEGER                               1
-.emtcode EMIT_IDENTIFIER                            2
-.emtcode EMIT_CHARACTER                             3
-.emtcode EMIT_LAST_CHARACTER                        4
-.emtcode EMIT_CURRENT_POSITION                      5
-
-.errtext INVALID_GRAMMAR                            "internal error 2001: invalid grammar script"
-.errtext SYNTAX_EXPECTED                            "internal error 2002: '.syntax' keyword expected"
-.errtext IDENTIFIER_EXPECTED                        "internal error 2003: identifier expected"
-.errtext MISSING_SEMICOLON                          "internal error 2004: missing ';'"
-.errtext INTEGER_EXPECTED                           "internal error 2005: integer value expected"
-.errtext STRING_EXPECTED                            "internal error 2006: string expected"
-
-/*
-    <grammar>                           ::= ".syntax" <identifier> ";" <declaration_list>
-*/
-grammar
-    grammar_1 .error INVALID_GRAMMAR;
-grammar_1
-    optional_space .and ".syntax" .error SYNTAX_EXPECTED .and space .and identifier .and
-    semicolon .and declaration_list .and optional_space .and '\0' .emit DECLARATION_END;
-
-/*
-    <optional_space>                    ::= <space>
-                                          | ""
-*/
-optional_space
-    space .or .true;
-
-/*
-    <space>                             ::= <single_space> <single_space>*
-*/
-space
-    single_space .and .loop single_space;
-
-/*
-    <single_space>                      ::= <white_char>
-                                          | <comment_block>
-*/
-single_space
-    white_char .or comment_block;
-
-/*
-    <white_char>                        ::= " " 
-                                          | "\t"
-                                          | "\n"
-                                          | "\r"
-*/
-white_char
-    ' ' .or '\t' .or '\n' .or '\r';
-
-/*
-    <comment_block>                     ::= "/" "*" <comment_rest>
-*/
-comment_block
-    '/' .and '*' .and comment_rest;
-
-/*
-    <comment_rest>                      ::= <comment_char_no_star>* <comment_end>
-                                          | <comment_char_no_star>* "*" <comment_rest>
-*/
-comment_rest
-    .loop comment_char_no_star .and comment_rest_1;
-comment_rest_1
-    comment_end .or comment_rest_2;
-comment_rest_2
-    '*' .and comment_rest;
-
-/*
-    <comment_char_no_star>              ::= All ASCII characters except "*" and "\0"
-*/
-comment_char_no_star
-    '\x2B'-'\xFF' .or '\x01'-'\x29';
-
-/*
-    <comment_end>                       ::= "*" "/"
-*/
-comment_end
-    '*' .and '/';
-
-/*
-    <identifier>                        ::= <identifier>
-*/
-identifier
-    identifier_ne .error IDENTIFIER_EXPECTED;
-
-/*
-    <identifier_ne>                     ::= <first_idchar> <follow_idchar>*
-*/
-identifier_ne
-    first_idchar .emit * .and .loop follow_idchar .emit * .and .true .emit '\0';
-
-/*
-    <first_idchar>                      ::= "a"-"z"
-                                          | "A"-"Z"
-                                          | "_"
-*/
-first_idchar
-    'a'-'z' .or 'A'-'Z' .or '_';
-
-/*
-    <follow_idchar>                     ::= <first_idchar>
-                                          | <digit_dec>
-*/
-follow_idchar
-    first_idchar .or digit_dec;
-
-/*
-    <digit_dec>                         ::= "0"-"9"
-*/
-digit_dec
-    '0'-'9';
-
-/*
-    <semicolon>                         ::= ";"
-*/
-semicolon
-    optional_space .and ';' .error MISSING_SEMICOLON .and optional_space;
-
-/*
-    <declaration_list>                  ::= <declaration>
-                                          | <declaration_list> <declaration>
-*/
-declaration_list
-    declaration .and .loop declaration;
-
-/*
-    <declaration>                       ::= <emitcode_definition>
-                                          | <errortext_definition>
-                                          | <lexer_definition>
-                                          | <rule_definition>
-*/
-declaration
-    emitcode_definition .emit DECLARATION_EMITCODE .or
-    errortext_definition .emit DECLARATION_ERRORTEXT .or
-    regbyte_definition .emit DECLARATION_REGBYTE .or
-    lexer_definition .emit DECLARATION_LEXER .or
-    rule_definition .emit DECLARATION_RULE;
-
-/*
-    <emitcode_definition>               ::= ".emtcode" <identifier> <integer>
-*/
-emitcode_definition
-    ".emtcode" .and space .and identifier .and space .and integer .and space_or_null;
-
-/*
-    <integer>                           ::= <integer_ne>
-*/
-integer
-    integer_ne .error INTEGER_EXPECTED;
-
-/*
-    <integer_ne>                        ::= <hex_integer>
-                                          | <dec_integer>
-*/
-integer_ne
-    hex_integer .emit 0x10 .or dec_integer .emit 10;
-
-/*
-    <hex_integer>                       :: <hex_prefix> <digit_hex> <digit_hex>*
-*/
-hex_integer
-    hex_prefix .and digit_hex .emit * .and .loop digit_hex .emit * .and .true .emit '\0';
-
-/*
-    <hex_prefix>                        ::= "0x"
-                                          | "0X"
-*/
-hex_prefix
-    '0' .and hex_prefix_1;
-hex_prefix_1
-    'x' .or 'X';
-
-/*
-    <digit_hex>                         ::= "0"-"9"
-                                          | "a"-"f"
-                                          | "A"-"F"
-*/
-digit_hex
-    '0'-'9' .or 'a'-'f' .or 'A'-'F';
-
-/*
-    <dec_integer>                       :: <digit_dec> <digit_dec>*
-*/
-dec_integer
-    digit_dec .emit * .and .loop digit_dec .emit * .and .true .emit '\0';
-
-/*
-    <space_or_null>                     ::= <space>
-                                          | "\0"
-*/
-space_or_null
-    space .or '\0';
-
-/*
-    <errortext_definition>              ::= ".errtext" <identifier> <string>
-*/
-errortext_definition
-    ".errtext" .and space .and identifier .and space .and string .and space_or_null;
-
-/*
-    <string>                            ::= <string_ne>
-*/
-string
-    string_ne .error STRING_EXPECTED;
-
-/*
-    <string_ne>                         ::= "\"" <string_char_double_quotes> "\""
-*/
-string_ne
-    '"' .and .loop string_char_double_quotes .and '"' .emit '\0';
-
-/*
-    <string_char_double_quotes>         ::= <escape_sequence>
-                                          | <string_char>
-                                          | "\'"
-*/
-string_char_double_quotes
-    escape_sequence .or string_char .emit * .or '\'' .emit *;
-
-/*
-    <string_char>                       ::= All ASCII characters except "\'", "\"", "\n", "\r",
-                                            "\0" and "\\"
-*/
-string_char
-    '\x5D'-'\xFF' .or '\x28'-'\x5B' .or '\x23'-'\x26' .or '\x0E'-'\x21' .or '\x0B'-'\x0C' .or
-    '\x01'-'\x09';
-
-/*
-    <escape_sequence>                   ::= "\\" <escape_code>
-*/
-escape_sequence
-    '\\' .emit * .and escape_code;
-
-/*
-    <escape_code>                       ::= <simple_escape_code>
-                                          | <hex_escape_code>
-                                          | <oct_escape_code>
-*/
-escape_code
-    simple_escape_code .emit * .or hex_escape_code .or oct_escape_code;
-
-/*
-    <simple_escape_code>                ::= "\'"
-                                          | "\""
-                                          | "?"
-                                          | "\\"
-                                          | "a"
-                                          | "b"
-                                          | "f"
-                                          | "n"
-                                          | "r"
-                                          | "t"
-                                          | "v"
-*/
-simple_escape_code
-    '\'' .or '"' .or '?' .or '\\' .or 'a' .or 'b' .or 'f' .or 'n' .or 'r' .or 't' .or 'v';
-
-/*
-    <hex_escape_code>                   ::= "x" <digit_hex> <digit_hex>*
-*/
-hex_escape_code
-    'x' .emit * .and digit_hex .emit * .and .loop digit_hex .emit *;
-
-/*
-    <oct_escape_code>                   ::= <digit_oct> <optional_digit_oct> <optional_digit_oct>
-*/
-oct_escape_code
-    digit_oct .emit * .and optional_digit_oct .and optional_digit_oct;
-
-/*
-    <digit_oct>                         ::= "0"-"7"
-*/
-digit_oct
-    '0'-'7';
-
-/*
-    <optional_digit_oct>                ::= <digit_oct>
-                                          | ""
-*/
-optional_digit_oct
-    digit_oct .emit * .or .true;
-
-/*
-    <regbyte_definition>                ::= ".regbyte" <identifier> <integer>
-*/
-regbyte_definition
-    ".regbyte" .and space .and identifier .and space .and integer .and space_or_null;
-
-/*
-    <lexer_definition>                  ::= ".string" <identifier> ";"
-*/
-lexer_definition
-    ".string" .and space .and identifier .and semicolon;
-
-/*
-    <rule_definition>                   ::= <identifier_ne> <definition>
-*/
-rule_definition
-    identifier_ne .and space .and definition;
-
-/*
-    <definition>                        ::= <specifier> <optional_specifiers_and_or> ";"
-*/
-definition
-    specifier .and optional_specifiers_and_or .and semicolon .emit SPECIFIER_END;
-
-/*
-    <optional_specifiers_and_or>        ::= <and_specifiers>
-                                          | <or_specifiers>
-                                          | ""
-*/
-optional_specifiers_and_or
-    and_specifiers .emit SPECIFIER_AND_TAG .or or_specifiers .emit SPECIFIER_OR_TAG .or .true;
-
-/*
-    <specifier>                         ::= <specifier_condition> <specifier_rule>
-*/
-specifier
-    specifier_condition .and optional_space .and specifier_rule;
-
-/*
-    <specifier_condition>               ::= ".if" "(" <left_operand> <operator> <right_operand> ")"
-*/
-specifier_condition
-    specifier_condition_1 .or .true;
-specifier_condition_1
-    ".if" .and optional_space .and '(' .and optional_space .and left_operand .and operator .and
-    right_operand .and optional_space .and ')';
-
-/*
-    <left_operand>                      ::= <identifier>
-*/
-left_operand
-    identifier;
-
-/*
-    <operator>                          ::= "!="
-                                          | "=="
-*/
-operator
-    operator_1 .or operator_2;
-operator_1
-    optional_space .and '!' .and '=' .and optional_space;
-operator_2
-    optional_space .and '=' .and '=' .and optional_space;
-
-/*
-    <right_operand>                     ::= <integer>
-*/
-right_operand
-    integer;
-
-/*
-    <specifier_rule>                    ::= <character_range> <optional_error> <emit>*
-                                          | <character> <optional_error> <emit>*
-                                          | <string> <optional_error> <emit>*
-                                          | ".true" <optional_error> <emit>*
-                                          | ".false" <optional_error> <emit>*
-                                          | ".debug" <optional_error> <emit>*
-                                          | <advanced_identifier> <optional_error> <emit>*
-*/
-specifier_rule
-    specifier_rule_1 .and optional_error .and .loop emit .and .true .emit EMIT_NULL;
-specifier_rule_1
-    character_range .emit SPECIFIER_CHARACTER_RANGE .or
-    character .emit SPECIFIER_CHARACTER .or
-    string_ne .emit SPECIFIER_STRING .or
-    ".true" .emit SPECIFIER_TRUE .or
-    ".false" .emit SPECIFIER_FALSE .or
-    ".debug" .emit SPECIFIER_DEBUG .or
-    advanced_identifier .emit SPECIFIER_IDENTIFIER;
-
-/*
-    <character>                         ::= "\'" <string_char_single_quotes "\'"
-*/
-character
-    '\'' .and string_char_single_quotes .and '\'' .emit '\0';
-
-/*
-    <string_char_single_quotes>         ::= <escape_sequence>
-                                          | <string_char>
-                                          | "\""
-*/
-string_char_single_quotes
-    escape_sequence .or string_char .emit * .or '"' .emit *;
-
-/*
-    <character_range>                   ::= <character> "-" <character>
-*/
-character_range
-    character .and optional_space .and '-' .and optional_space .and character;
-
-/*
-    <advanced_identifier>               ::= <optional_loop> <identifier>
-*/
-advanced_identifier
-    optional_loop .and identifier;
-
-/*
-    <optional_loop>                     ::= ".loop"
-                                          | ""
-*/
-optional_loop
-    optional_loop_1 .emit IDENTIFIER_LOOP .or .true .emit IDENTIFIER_SIMPLE;
-optional_loop_1
-    ".loop" .and space;
-
-/*
-    <optional_error>                    ::= <error>
-                                          | ""
-*/
-optional_error
-    error .emit ERROR_PRESENT .or .true .emit ERROR_NOT_PRESENT;
-
-/*
-    <error>                             :: ".error" <identifier>
-*/
-error
-    space .and ".error" .and space .and identifier;
-
-/*
-    <emit>                              ::= <emit_output>
-                                          | <emit_regbyte>
-*/
-emit
-    emit_output .or emit_regbyte;
-
-/*
-    <emit_output>                       ::= ".emit" <emit_param>
-*/
-emit_output
-    space .and ".emit" .and space .and emit_param;
-
-/*
-    <emit_param>                        ::= <integer>
-                                          | <identifier>
-                                          | <character>
-                                          | "*"
-                                          | "$"
-*/
-emit_param
-    integer_ne .emit EMIT_INTEGER .or
-    identifier_ne .emit EMIT_IDENTIFIER .or
-    character .emit EMIT_CHARACTER .or
-    '*' .emit EMIT_LAST_CHARACTER .or
-    '$' .emit EMIT_CURRENT_POSITION;
-
-/*
-    <emit_regbyte>                      ::= ".load" <identifier> <emit_param>
-*/
-emit_regbyte
-    space .and ".load" .and space .and identifier .and space .and emit_param;
-
-/*
-    <and_specifiers>                    ::= <and_specifier> <and_specifier>*
-*/
-and_specifiers
-    and_specifier .and .loop and_specifier;
-
-/*
-    <or_specifiers>                     ::= <or_specifier> <or_specifier>*
-*/
-or_specifiers
-    or_specifier .and .loop or_specifier;
-
-/*
-    <and_specifier>                     ::= ".and" <specifier>
-*/
-and_specifier
-    space .and ".and" .and space .and specifier;
-
-/*
-    <or_specifier>                      ::= ".or" <specifier>
-*/
-or_specifier
-    space .and ".or" .and space .and specifier;
-
-
-.string __string_filter;
-
-/*
-    <__string_filter>                   ::= <__first_identifier_char> <__next_identifier_char>*
-*/
-__string_filter
-    __first_identifier_char .and .loop __next_identifier_char;
-
-/*
-    <__first_identifier_char>           ::= "a"-"z"
-                                          | "A"-"Z"
-                                          | "_"
-                                          | "."
-*/
-__first_identifier_char
-    'a'-'z' .or 'A'-'Z' .or '_' .or '.';
-
-/*
-    <__next_identifier_char>            ::= "a"-"z"
-                                          | "A"-"Z"
-                                          | "_"
-                                          | "0"-"9"
-*/
-__next_identifier_char
-    'a'-'z' .or 'A'-'Z' .or '_' .or '0'-'9';
-
diff --git a/src/mesa/shader/grammar/grammar_crt.c b/src/mesa/shader/grammar/grammar_crt.c
deleted file mode 100644 (file)
index d2c95d1..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-#include "grammar_crt.h"
-
-#define GRAMMAR_PORT_BUILD 1
-#include "grammar.c"
-#undef GRAMMAR_PORT_BUILD
-
-
-void grammar_alloc_free (void *ptr)
-{
-    free (ptr);
-}
-
-void *grammar_alloc_malloc (size_t size)
-{
-    return malloc (size);
-}
-
-void *grammar_alloc_realloc (void *ptr, size_t old_size, size_t size)
-{
-    return realloc (ptr, size);
-}
-
-void *grammar_memory_copy (void *dst, const void * src, size_t size)
-{
-    return memcpy (dst, src, size);
-}
-
-int grammar_string_compare (const byte *str1, const byte *str2)
-{
-    return strcmp ((const char *) str1, (const char *) str2);
-}
-
-int grammar_string_compare_n (const byte *str1, const byte *str2, size_t n)
-{
-    return strncmp ((const char *) str1, (const char *) str2, n);
-}
-
-byte *grammar_string_copy (byte *dst, const byte *src)
-{
-    return (byte *) strcpy ((char *) dst, (const char *) src);
-}
-
-byte *grammar_string_copy_n (byte *dst, const byte *src, size_t n)
-{
-    return (byte *) strncpy ((char *) dst, (const char *) src, n);
-}
-
-unsigned int grammar_string_length (const byte *str)
-{
-    return strlen ((const char *) str);
-}
-
-byte *grammar_string_duplicate (const byte *src)
-{
-    const unsigned int size = grammar_string_length (src);
-    byte *str = grammar_alloc_malloc (size + 1);
-    if (str != NULL)
-    {
-        grammar_memory_copy (str, src, size);
-        str[size] = '\0';
-    }
-    return str;
-}
-
diff --git a/src/mesa/shader/grammar/grammar_crt.h b/src/mesa/shader/grammar/grammar_crt.h
deleted file mode 100644 (file)
index 492711e..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef GRAMMAR_CRT_H
-#define GRAMMAR_CRT_H
-
-
-#include <stdlib.h>
-#include <malloc.h>
-#include <string.h>
-
-
-typedef unsigned long grammar;
-typedef unsigned char byte;
-
-
-#define GRAMMAR_PORT_INCLUDE 1
-#include "grammar.h"
-#undef GRAMMAR_PORT_INCLUDE
-
-
-#endif
-
diff --git a/src/mesa/shader/grammar/grammar_mesa.c b/src/mesa/shader/grammar/grammar_mesa.c
deleted file mode 100644 (file)
index eb96250..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version:  6.1
- *
- * Copyright (C) 1999-2004  Brian Paul   All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/**
- * \file grammar_mesa.c
- * mesa3d port to syntax parsing engine
- * \author Michal Krol
- */
-
-#include "grammar_mesa.h"
-
-#define GRAMMAR_PORT_BUILD 1
-#include "grammar.c"
-#undef GRAMMAR_PORT_BUILD
-
-
-void grammar_alloc_free (void *ptr)
-{
-    _mesa_free (ptr);
-}
-
-void *grammar_alloc_malloc (size_t size)
-{
-    return _mesa_malloc (size);
-}
-
-void *grammar_alloc_realloc (void *ptr, size_t old_size, size_t size)
-{
-    return _mesa_realloc (ptr, old_size, size);
-}
-
-void *grammar_memory_copy (void *dst, const void * src, size_t size)
-{
-    return _mesa_memcpy (dst, src, size);
-}
-
-int grammar_string_compare (const byte *str1, const byte *str2)
-{
-    return _mesa_strcmp ((const char *) str1, (const char *) str2);
-}
-
-int grammar_string_compare_n (const byte *str1, const byte *str2, size_t n)
-{
-    return _mesa_strncmp ((const char *) str1, (const char *) str2, n);
-}
-
-byte *grammar_string_copy (byte *dst, const byte *src)
-{
-    return (byte *) _mesa_strcpy ((char *) dst, (const char *) src);
-}
-
-byte *grammar_string_copy_n (byte *dst, const byte *src, size_t n)
-{
-    return (byte *) _mesa_strncpy ((char *) dst, (const char *) src, n);
-}
-
-byte *grammar_string_duplicate (const byte *src)
-{
-    return (byte *) _mesa_strdup ((const char *) src);
-}
-
-unsigned int grammar_string_length (const byte *str)
-{
-    return (unsigned int)_mesa_strlen ((const char *) str);
-}
-
diff --git a/src/mesa/shader/grammar/grammar_mesa.h b/src/mesa/shader/grammar/grammar_mesa.h
deleted file mode 100644 (file)
index 6c92c58..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version:  6.1
- *
- * Copyright (C) 1999-2004  Brian Paul   All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#ifndef GRAMMAR_MESA_H
-#define GRAMMAR_MESA_H
-
-
-#include "main/imports.h"
-/* NOTE: include Mesa 3-D specific headers here */
-
-
-typedef GLuint grammar;
-typedef GLubyte byte;
-
-
-#define GRAMMAR_PORT_INCLUDE 1
-#include "grammar.h"
-#undef GRAMMAR_PORT_INCLUDE
-
-
-#endif
-
diff --git a/src/mesa/shader/grammar/grammar_syn.h b/src/mesa/shader/grammar/grammar_syn.h
deleted file mode 100644 (file)
index 840a1ab..0000000
+++ /dev/null
@@ -1,202 +0,0 @@
-".syntax grammar;\n"
-".emtcode DECLARATION_END 0\n"
-".emtcode DECLARATION_EMITCODE 1\n"
-".emtcode DECLARATION_ERRORTEXT 2\n"
-".emtcode DECLARATION_REGBYTE 3\n"
-".emtcode DECLARATION_LEXER 4\n"
-".emtcode DECLARATION_RULE 5\n"
-".emtcode SPECIFIER_END 0\n"
-".emtcode SPECIFIER_AND_TAG 1\n"
-".emtcode SPECIFIER_OR_TAG 2\n"
-".emtcode SPECIFIER_CHARACTER_RANGE 3\n"
-".emtcode SPECIFIER_CHARACTER 4\n"
-".emtcode SPECIFIER_STRING 5\n"
-".emtcode SPECIFIER_IDENTIFIER 6\n"
-".emtcode SPECIFIER_TRUE 7\n"
-".emtcode SPECIFIER_FALSE 8\n"
-".emtcode SPECIFIER_DEBUG 9\n"
-".emtcode IDENTIFIER_SIMPLE 0\n"
-".emtcode IDENTIFIER_LOOP 1\n"
-".emtcode ERROR_NOT_PRESENT 0\n"
-".emtcode ERROR_PRESENT 1\n"
-".emtcode EMIT_NULL 0\n"
-".emtcode EMIT_INTEGER 1\n"
-".emtcode EMIT_IDENTIFIER 2\n"
-".emtcode EMIT_CHARACTER 3\n"
-".emtcode EMIT_LAST_CHARACTER 4\n"
-".emtcode EMIT_CURRENT_POSITION 5\n"
-".errtext INVALID_GRAMMAR \"internal error 2001: invalid grammar script\"\n"
-".errtext SYNTAX_EXPECTED \"internal error 2002: '.syntax' keyword expected\"\n"
-".errtext IDENTIFIER_EXPECTED \"internal error 2003: identifier expected\"\n"
-".errtext MISSING_SEMICOLON \"internal error 2004: missing ';'\"\n"
-".errtext INTEGER_EXPECTED \"internal error 2005: integer value expected\"\n"
-".errtext STRING_EXPECTED \"internal error 2006: string expected\"\n"
-"grammar\n"
-" grammar_1 .error INVALID_GRAMMAR;\n"
-"grammar_1\n"
-" optional_space .and \".syntax\" .error SYNTAX_EXPECTED .and space .and identifier .and\n"
-" semicolon .and declaration_list .and optional_space .and '\\0' .emit DECLARATION_END;\n"
-"optional_space\n"
-" space .or .true;\n"
-"space\n"
-" single_space .and .loop single_space;\n"
-"single_space\n"
-" white_char .or comment_block;\n"
-"white_char\n"
-" ' ' .or '\\t' .or '\\n' .or '\\r';\n"
-"comment_block\n"
-" '/' .and '*' .and comment_rest;\n"
-"comment_rest\n"
-" .loop comment_char_no_star .and comment_rest_1;\n"
-"comment_rest_1\n"
-" comment_end .or comment_rest_2;\n"
-"comment_rest_2\n"
-" '*' .and comment_rest;\n"
-"comment_char_no_star\n"
-" '\\x2B'-'\\xFF' .or '\\x01'-'\\x29';\n"
-"comment_end\n"
-" '*' .and '/';\n"
-"identifier\n"
-" identifier_ne .error IDENTIFIER_EXPECTED;\n"
-"identifier_ne\n"
-" first_idchar .emit * .and .loop follow_idchar .emit * .and .true .emit '\\0';\n"
-"first_idchar\n"
-" 'a'-'z' .or 'A'-'Z' .or '_';\n"
-"follow_idchar\n"
-" first_idchar .or digit_dec;\n"
-"digit_dec\n"
-" '0'-'9';\n"
-"semicolon\n"
-" optional_space .and ';' .error MISSING_SEMICOLON .and optional_space;\n"
-"declaration_list\n"
-" declaration .and .loop declaration;\n"
-"declaration\n"
-" emitcode_definition .emit DECLARATION_EMITCODE .or\n"
-" errortext_definition .emit DECLARATION_ERRORTEXT .or\n"
-" regbyte_definition .emit DECLARATION_REGBYTE .or\n"
-" lexer_definition .emit DECLARATION_LEXER .or\n"
-" rule_definition .emit DECLARATION_RULE;\n"
-"emitcode_definition\n"
-" \".emtcode\" .and space .and identifier .and space .and integer .and space_or_null;\n"
-"integer\n"
-" integer_ne .error INTEGER_EXPECTED;\n"
-"integer_ne\n"
-" hex_integer .emit 0x10 .or dec_integer .emit 10;\n"
-"hex_integer\n"
-" hex_prefix .and digit_hex .emit * .and .loop digit_hex .emit * .and .true .emit '\\0';\n"
-"hex_prefix\n"
-" '0' .and hex_prefix_1;\n"
-"hex_prefix_1\n"
-" 'x' .or 'X';\n"
-"digit_hex\n"
-" '0'-'9' .or 'a'-'f' .or 'A'-'F';\n"
-"dec_integer\n"
-" digit_dec .emit * .and .loop digit_dec .emit * .and .true .emit '\\0';\n"
-"space_or_null\n"
-" space .or '\\0';\n"
-"errortext_definition\n"
-" \".errtext\" .and space .and identifier .and space .and string .and space_or_null;\n"
-"string\n"
-" string_ne .error STRING_EXPECTED;\n"
-"string_ne\n"
-" '\"' .and .loop string_char_double_quotes .and '\"' .emit '\\0';\n"
-"string_char_double_quotes\n"
-" escape_sequence .or string_char .emit * .or '\\'' .emit *;\n"
-"string_char\n"
-" '\\x5D'-'\\xFF' .or '\\x28'-'\\x5B' .or '\\x23'-'\\x26' .or '\\x0E'-'\\x21' .or '\\x0B'-'\\x0C' .or\n"
-" '\\x01'-'\\x09';\n"
-"escape_sequence\n"
-" '\\\\' .emit * .and escape_code;\n"
-"escape_code\n"
-" simple_escape_code .emit * .or hex_escape_code .or oct_escape_code;\n"
-"simple_escape_code\n"
-" '\\'' .or '\"' .or '?' .or '\\\\' .or 'a' .or 'b' .or 'f' .or 'n' .or 'r' .or 't' .or 'v';\n"
-"hex_escape_code\n"
-" 'x' .emit * .and digit_hex .emit * .and .loop digit_hex .emit *;\n"
-"oct_escape_code\n"
-" digit_oct .emit * .and optional_digit_oct .and optional_digit_oct;\n"
-"digit_oct\n"
-" '0'-'7';\n"
-"optional_digit_oct\n"
-" digit_oct .emit * .or .true;\n"
-"regbyte_definition\n"
-" \".regbyte\" .and space .and identifier .and space .and integer .and space_or_null;\n"
-"lexer_definition\n"
-" \".string\" .and space .and identifier .and semicolon;\n"
-"rule_definition\n"
-" identifier_ne .and space .and definition;\n"
-"definition\n"
-" specifier .and optional_specifiers_and_or .and semicolon .emit SPECIFIER_END;\n"
-"optional_specifiers_and_or\n"
-" and_specifiers .emit SPECIFIER_AND_TAG .or or_specifiers .emit SPECIFIER_OR_TAG .or .true;\n"
-"specifier\n"
-" specifier_condition .and optional_space .and specifier_rule;\n"
-"specifier_condition\n"
-" specifier_condition_1 .or .true;\n"
-"specifier_condition_1\n"
-" \".if\" .and optional_space .and '(' .and optional_space .and left_operand .and operator .and\n"
-" right_operand .and optional_space .and ')';\n"
-"left_operand\n"
-" identifier;\n"
-"operator\n"
-" operator_1 .or operator_2;\n"
-"operator_1\n"
-" optional_space .and '!' .and '=' .and optional_space;\n"
-"operator_2\n"
-" optional_space .and '=' .and '=' .and optional_space;\n"
-"right_operand\n"
-" integer;\n"
-"specifier_rule\n"
-" specifier_rule_1 .and optional_error .and .loop emit .and .true .emit EMIT_NULL;\n"
-"specifier_rule_1\n"
-" character_range .emit SPECIFIER_CHARACTER_RANGE .or\n"
-" character .emit SPECIFIER_CHARACTER .or\n"
-" string_ne .emit SPECIFIER_STRING .or\n"
-" \".true\" .emit SPECIFIER_TRUE .or\n"
-" \".false\" .emit SPECIFIER_FALSE .or\n"
-" \".debug\" .emit SPECIFIER_DEBUG .or\n"
-" advanced_identifier .emit SPECIFIER_IDENTIFIER;\n"
-"character\n"
-" '\\'' .and string_char_single_quotes .and '\\'' .emit '\\0';\n"
-"string_char_single_quotes\n"
-" escape_sequence .or string_char .emit * .or '\"' .emit *;\n"
-"character_range\n"
-" character .and optional_space .and '-' .and optional_space .and character;\n"
-"advanced_identifier\n"
-" optional_loop .and identifier;\n"
-"optional_loop\n"
-" optional_loop_1 .emit IDENTIFIER_LOOP .or .true .emit IDENTIFIER_SIMPLE;\n"
-"optional_loop_1\n"
-" \".loop\" .and space;\n"
-"optional_error\n"
-" error .emit ERROR_PRESENT .or .true .emit ERROR_NOT_PRESENT;\n"
-"error\n"
-" space .and \".error\" .and space .and identifier;\n"
-"emit\n"
-" emit_output .or emit_regbyte;\n"
-"emit_output\n"
-" space .and \".emit\" .and space .and emit_param;\n"
-"emit_param\n"
-" integer_ne .emit EMIT_INTEGER .or\n"
-" identifier_ne .emit EMIT_IDENTIFIER .or\n"
-" character .emit EMIT_CHARACTER .or\n"
-" '*' .emit EMIT_LAST_CHARACTER .or\n"
-" '$' .emit EMIT_CURRENT_POSITION;\n"
-"emit_regbyte\n"
-" space .and \".load\" .and space .and identifier .and space .and emit_param;\n"
-"and_specifiers\n"
-" and_specifier .and .loop and_specifier;\n"
-"or_specifiers\n"
-" or_specifier .and .loop or_specifier;\n"
-"and_specifier\n"
-" space .and \".and\" .and space .and specifier;\n"
-"or_specifier\n"
-" space .and \".or\" .and space .and specifier;\n"
-".string __string_filter;\n"
-"__string_filter\n"
-" __first_identifier_char .and .loop __next_identifier_char;\n"
-"__first_identifier_char\n"
-" 'a'-'z' .or 'A'-'Z' .or '_' .or '.';\n"
-"__next_identifier_char\n"
-" 'a'-'z' .or 'A'-'Z' .or '_' .or '0'-'9';\n"
-""
index 881179f9d850dbae5402d5b26c0bc0f41a602fc1..e89a2564d76ce125663f0328bc1c5dd5f9cdc010 100644 (file)
  *
  * \author Ian Romanick <ian.d.romanick@intel.com>
  */
-#include <stdlib.h>
-#include <string.h>
-
-#include <assert.h>
 
 #include "main/imports.h"
 #include "main/simple_list.h"
index 3c86913fdfccc5ff32f36ecba7c00c86a7ba3b46..68543ae2e1282e6167bd9ccede29f3f67afba5d7 100644 (file)
@@ -1042,6 +1042,7 @@ static yyconst flex_int16_t yy_chk[1368] =
  * DEALINGS IN THE SOFTWARE.
  */
 #include "main/glheader.h"
+#include "main/imports.h"
 #include "prog_instruction.h"
 #include "prog_statevars.h"
 
@@ -1160,7 +1161,7 @@ handle_ident(struct asm_parser_state *state, const char *text, YYSTYPE *lval)
    } while(0);
 
 #define YY_EXTRA_TYPE struct asm_parser_state *
-#line 1164 "lex.yy.c"
+#line 1165 "lex.yy.c"
 
 #define INITIAL 0
 
@@ -1406,10 +1407,10 @@ YY_DECL
        register int yy_act;
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
-#line 156 "program_lexer.l"
+#line 157 "program_lexer.l"
 
 
-#line 1413 "lex.yy.c"
+#line 1414 "lex.yy.c"
 
     yylval = yylval_param;
 
@@ -1498,17 +1499,17 @@ do_action:      /* This label is used only to access EOF actions. */
 
 case 1:
 YY_RULE_SETUP
-#line 158 "program_lexer.l"
+#line 159 "program_lexer.l"
 { return ARBvp_10; }
        YY_BREAK
 case 2:
 YY_RULE_SETUP
-#line 159 "program_lexer.l"
+#line 160 "program_lexer.l"
 { return ARBfp_10; }
        YY_BREAK
 case 3:
 YY_RULE_SETUP
-#line 160 "program_lexer.l"
+#line 161 "program_lexer.l"
 {
    yylval->integer = at_address;
    return_token_or_IDENTIFIER(require_ARB_vp, ADDRESS);
@@ -1516,692 +1517,692 @@ YY_RULE_SETUP
        YY_BREAK
 case 4:
 YY_RULE_SETUP
-#line 164 "program_lexer.l"
+#line 165 "program_lexer.l"
 { return ALIAS; }
        YY_BREAK
 case 5:
 YY_RULE_SETUP
-#line 165 "program_lexer.l"
+#line 166 "program_lexer.l"
 { return ATTRIB; }
        YY_BREAK
 case 6:
 YY_RULE_SETUP
-#line 166 "program_lexer.l"
+#line 167 "program_lexer.l"
 { return END; }
        YY_BREAK
 case 7:
 YY_RULE_SETUP
-#line 167 "program_lexer.l"
+#line 168 "program_lexer.l"
 { return OPTION; }
        YY_BREAK
 case 8:
 YY_RULE_SETUP
-#line 168 "program_lexer.l"
+#line 169 "program_lexer.l"
 { return OUTPUT; }
        YY_BREAK
 case 9:
 YY_RULE_SETUP
-#line 169 "program_lexer.l"
+#line 170 "program_lexer.l"
 { return PARAM; }
        YY_BREAK
 case 10:
 YY_RULE_SETUP
-#line 170 "program_lexer.l"
+#line 171 "program_lexer.l"
 { yylval->integer = at_temp; return TEMP; }
        YY_BREAK
 case 11:
 YY_RULE_SETUP
-#line 172 "program_lexer.l"
+#line 173 "program_lexer.l"
 { return_opcode(             1, VECTOR_OP, ABS, 3); }
        YY_BREAK
 case 12:
 YY_RULE_SETUP
-#line 173 "program_lexer.l"
+#line 174 "program_lexer.l"
 { return_opcode(             1, BIN_OP, ADD, 3); }
        YY_BREAK
 case 13:
 YY_RULE_SETUP
-#line 174 "program_lexer.l"
+#line 175 "program_lexer.l"
 { return_opcode(require_ARB_vp, ARL, ARL, 3); }
        YY_BREAK
 case 14:
 YY_RULE_SETUP
-#line 176 "program_lexer.l"
+#line 177 "program_lexer.l"
 { return_opcode(require_ARB_fp, TRI_OP, CMP, 3); }
        YY_BREAK
 case 15:
 YY_RULE_SETUP
-#line 177 "program_lexer.l"
+#line 178 "program_lexer.l"
 { return_opcode(require_ARB_fp, SCALAR_OP, COS, 3); }
        YY_BREAK
 case 16:
 YY_RULE_SETUP
-#line 179 "program_lexer.l"
+#line 180 "program_lexer.l"
 { return_opcode(require_NV_fp,  VECTOR_OP, DDX, 3); }
        YY_BREAK
 case 17:
 YY_RULE_SETUP
-#line 180 "program_lexer.l"
+#line 181 "program_lexer.l"
 { return_opcode(require_NV_fp,  VECTOR_OP, DDY, 3); }
        YY_BREAK
 case 18:
 YY_RULE_SETUP
-#line 181 "program_lexer.l"
+#line 182 "program_lexer.l"
 { return_opcode(             1, BIN_OP, DP3, 3); }
        YY_BREAK
 case 19:
 YY_RULE_SETUP
-#line 182 "program_lexer.l"
+#line 183 "program_lexer.l"
 { return_opcode(             1, BIN_OP, DP4, 3); }
        YY_BREAK
 case 20:
 YY_RULE_SETUP
-#line 183 "program_lexer.l"
+#line 184 "program_lexer.l"
 { return_opcode(             1, BIN_OP, DPH, 3); }
        YY_BREAK
 case 21:
 YY_RULE_SETUP
-#line 184 "program_lexer.l"
+#line 185 "program_lexer.l"
 { return_opcode(             1, BIN_OP, DST, 3); }
        YY_BREAK
 case 22:
 YY_RULE_SETUP
-#line 186 "program_lexer.l"
+#line 187 "program_lexer.l"
 { return_opcode(             1, SCALAR_OP, EX2, 3); }
        YY_BREAK
 case 23:
 YY_RULE_SETUP
-#line 187 "program_lexer.l"
+#line 188 "program_lexer.l"
 { return_opcode(require_ARB_vp, SCALAR_OP, EXP, 3); }
        YY_BREAK
 case 24:
 YY_RULE_SETUP
-#line 189 "program_lexer.l"
+#line 190 "program_lexer.l"
 { return_opcode(             1, VECTOR_OP, FLR, 3); }
        YY_BREAK
 case 25:
 YY_RULE_SETUP
-#line 190 "program_lexer.l"
+#line 191 "program_lexer.l"
 { return_opcode(             1, VECTOR_OP, FRC, 3); }
        YY_BREAK
 case 26:
 YY_RULE_SETUP
-#line 192 "program_lexer.l"
+#line 193 "program_lexer.l"
 { return_opcode(require_ARB_fp, KIL, KIL, 3); }
        YY_BREAK
 case 27:
 YY_RULE_SETUP
-#line 194 "program_lexer.l"
+#line 195 "program_lexer.l"
 { return_opcode(             1, VECTOR_OP, LIT, 3); }
        YY_BREAK
 case 28:
 YY_RULE_SETUP
-#line 195 "program_lexer.l"
+#line 196 "program_lexer.l"
 { return_opcode(             1, SCALAR_OP, LG2, 3); }
        YY_BREAK
 case 29:
 YY_RULE_SETUP
-#line 196 "program_lexer.l"
+#line 197 "program_lexer.l"
 { return_opcode(require_ARB_vp, SCALAR_OP, LOG, 3); }
        YY_BREAK
 case 30:
 YY_RULE_SETUP
-#line 197 "program_lexer.l"
+#line 198 "program_lexer.l"
 { return_opcode(require_ARB_fp, TRI_OP, LRP, 3); }
        YY_BREAK
 case 31:
 YY_RULE_SETUP
-#line 199 "program_lexer.l"
+#line 200 "program_lexer.l"
 { return_opcode(             1, TRI_OP, MAD, 3); }
        YY_BREAK
 case 32:
 YY_RULE_SETUP
-#line 200 "program_lexer.l"
+#line 201 "program_lexer.l"
 { return_opcode(             1, BIN_OP, MAX, 3); }
        YY_BREAK
 case 33:
 YY_RULE_SETUP
-#line 201 "program_lexer.l"
+#line 202 "program_lexer.l"
 { return_opcode(             1, BIN_OP, MIN, 3); }
        YY_BREAK
 case 34:
 YY_RULE_SETUP
-#line 202 "program_lexer.l"
+#line 203 "program_lexer.l"
 { return_opcode(             1, VECTOR_OP, MOV, 3); }
        YY_BREAK
 case 35:
 YY_RULE_SETUP
-#line 203 "program_lexer.l"
+#line 204 "program_lexer.l"
 { return_opcode(             1, BIN_OP, MUL, 3); }
        YY_BREAK
 case 36:
 YY_RULE_SETUP
-#line 205 "program_lexer.l"
+#line 206 "program_lexer.l"
 { return_opcode(require_NV_fp,  VECTOR_OP, PK2H, 4); }
        YY_BREAK
 case 37:
 YY_RULE_SETUP
-#line 206 "program_lexer.l"
+#line 207 "program_lexer.l"
 { return_opcode(require_NV_fp,  VECTOR_OP, PK2US, 5); }
        YY_BREAK
 case 38:
 YY_RULE_SETUP
-#line 207 "program_lexer.l"
+#line 208 "program_lexer.l"
 { return_opcode(require_NV_fp,  VECTOR_OP, PK4B, 4); }
        YY_BREAK
 case 39:
 YY_RULE_SETUP
-#line 208 "program_lexer.l"
+#line 209 "program_lexer.l"
 { return_opcode(require_NV_fp,  VECTOR_OP, PK4UB, 5); }
        YY_BREAK
 case 40:
 YY_RULE_SETUP
-#line 209 "program_lexer.l"
+#line 210 "program_lexer.l"
 { return_opcode(             1, BINSC_OP, POW, 3); }
        YY_BREAK
 case 41:
 YY_RULE_SETUP
-#line 211 "program_lexer.l"
+#line 212 "program_lexer.l"
 { return_opcode(             1, SCALAR_OP, RCP, 3); }
        YY_BREAK
 case 42:
 YY_RULE_SETUP
-#line 212 "program_lexer.l"
+#line 213 "program_lexer.l"
 { return_opcode(require_NV_fp,  BIN_OP,    RFL, 3); }
        YY_BREAK
 case 43:
 YY_RULE_SETUP
-#line 213 "program_lexer.l"
+#line 214 "program_lexer.l"
 { return_opcode(             1, SCALAR_OP, RSQ, 3); }
        YY_BREAK
 case 44:
 YY_RULE_SETUP
-#line 215 "program_lexer.l"
+#line 216 "program_lexer.l"
 { return_opcode(require_ARB_fp, SCALAR_OP, SCS, 3); }
        YY_BREAK
 case 45:
 YY_RULE_SETUP
-#line 216 "program_lexer.l"
+#line 217 "program_lexer.l"
 { return_opcode(require_NV_fp,  BIN_OP, SEQ, 3); }
        YY_BREAK
 case 46:
 YY_RULE_SETUP
-#line 217 "program_lexer.l"
+#line 218 "program_lexer.l"
 { return_opcode(require_NV_fp,  BIN_OP, SFL, 3); }
        YY_BREAK
 case 47:
 YY_RULE_SETUP
-#line 218 "program_lexer.l"
+#line 219 "program_lexer.l"
 { return_opcode(             1, BIN_OP, SGE, 3); }
        YY_BREAK
 case 48:
 YY_RULE_SETUP
-#line 219 "program_lexer.l"
+#line 220 "program_lexer.l"
 { return_opcode(require_NV_fp,  BIN_OP, SGT, 3); }
        YY_BREAK
 case 49:
 YY_RULE_SETUP
-#line 220 "program_lexer.l"
+#line 221 "program_lexer.l"
 { return_opcode(require_ARB_fp, SCALAR_OP, SIN, 3); }
        YY_BREAK
 case 50:
 YY_RULE_SETUP
-#line 221 "program_lexer.l"
+#line 222 "program_lexer.l"
 { return_opcode(require_NV_fp,  BIN_OP, SLE, 3); }
        YY_BREAK
 case 51:
 YY_RULE_SETUP
-#line 222 "program_lexer.l"
+#line 223 "program_lexer.l"
 { return_opcode(             1, BIN_OP, SLT, 3); }
        YY_BREAK
 case 52:
 YY_RULE_SETUP
-#line 223 "program_lexer.l"
+#line 224 "program_lexer.l"
 { return_opcode(require_NV_fp,  BIN_OP, SNE, 3); }
        YY_BREAK
 case 53:
 YY_RULE_SETUP
-#line 224 "program_lexer.l"
+#line 225 "program_lexer.l"
 { return_opcode(require_NV_fp,  BIN_OP, STR, 3); }
        YY_BREAK
 case 54:
 YY_RULE_SETUP
-#line 225 "program_lexer.l"
+#line 226 "program_lexer.l"
 { return_opcode(             1, BIN_OP, SUB, 3); }
        YY_BREAK
 case 55:
 YY_RULE_SETUP
-#line 226 "program_lexer.l"
+#line 227 "program_lexer.l"
 { return_opcode(             1, SWZ, SWZ, 3); }
        YY_BREAK
 case 56:
 YY_RULE_SETUP
-#line 228 "program_lexer.l"
+#line 229 "program_lexer.l"
 { return_opcode(require_ARB_fp, SAMPLE_OP, TEX, 3); }
        YY_BREAK
 case 57:
 YY_RULE_SETUP
-#line 229 "program_lexer.l"
+#line 230 "program_lexer.l"
 { return_opcode(require_ARB_fp, SAMPLE_OP, TXB, 3); }
        YY_BREAK
 case 58:
 YY_RULE_SETUP
-#line 230 "program_lexer.l"
+#line 231 "program_lexer.l"
 { return_opcode(require_NV_fp,  TXD_OP, TXD, 3); }
        YY_BREAK
 case 59:
 YY_RULE_SETUP
-#line 231 "program_lexer.l"
+#line 232 "program_lexer.l"
 { return_opcode(require_ARB_fp, SAMPLE_OP, TXP, 3); }
        YY_BREAK
 case 60:
 YY_RULE_SETUP
-#line 233 "program_lexer.l"
+#line 234 "program_lexer.l"
 { return_opcode(require_NV_fp,  SCALAR_OP, UP2H, 4); }
        YY_BREAK
 case 61:
 YY_RULE_SETUP
-#line 234 "program_lexer.l"
+#line 235 "program_lexer.l"
 { return_opcode(require_NV_fp,  SCALAR_OP, UP2US, 5); }
        YY_BREAK
 case 62:
 YY_RULE_SETUP
-#line 235 "program_lexer.l"
+#line 236 "program_lexer.l"
 { return_opcode(require_NV_fp,  SCALAR_OP, UP4B, 4); }
        YY_BREAK
 case 63:
 YY_RULE_SETUP
-#line 236 "program_lexer.l"
+#line 237 "program_lexer.l"
 { return_opcode(require_NV_fp,  SCALAR_OP, UP4UB, 5); }
        YY_BREAK
 case 64:
 YY_RULE_SETUP
-#line 238 "program_lexer.l"
+#line 239 "program_lexer.l"
 { return_opcode(require_NV_fp,  TRI_OP, X2D, 3); }
        YY_BREAK
 case 65:
 YY_RULE_SETUP
-#line 239 "program_lexer.l"
+#line 240 "program_lexer.l"
 { return_opcode(             1, BIN_OP, XPD, 3); }
        YY_BREAK
 case 66:
 YY_RULE_SETUP
-#line 241 "program_lexer.l"
+#line 242 "program_lexer.l"
 { return_token_or_IDENTIFIER(require_ARB_vp, VERTEX); }
        YY_BREAK
 case 67:
 YY_RULE_SETUP
-#line 242 "program_lexer.l"
+#line 243 "program_lexer.l"
 { return_token_or_IDENTIFIER(require_ARB_fp, FRAGMENT); }
        YY_BREAK
 case 68:
 YY_RULE_SETUP
-#line 243 "program_lexer.l"
+#line 244 "program_lexer.l"
 { return PROGRAM; }
        YY_BREAK
 case 69:
 YY_RULE_SETUP
-#line 244 "program_lexer.l"
+#line 245 "program_lexer.l"
 { return STATE; }
        YY_BREAK
 case 70:
 YY_RULE_SETUP
-#line 245 "program_lexer.l"
+#line 246 "program_lexer.l"
 { return RESULT; }
        YY_BREAK
 case 71:
 YY_RULE_SETUP
-#line 247 "program_lexer.l"
+#line 248 "program_lexer.l"
 { return AMBIENT; }
        YY_BREAK
 case 72:
 YY_RULE_SETUP
-#line 248 "program_lexer.l"
+#line 249 "program_lexer.l"
 { return ATTENUATION; }
        YY_BREAK
 case 73:
 YY_RULE_SETUP
-#line 249 "program_lexer.l"
+#line 250 "program_lexer.l"
 { return BACK; }
        YY_BREAK
 case 74:
 YY_RULE_SETUP
-#line 250 "program_lexer.l"
+#line 251 "program_lexer.l"
 { return_token_or_DOT(require_ARB_vp, CLIP); }
        YY_BREAK
 case 75:
 YY_RULE_SETUP
-#line 251 "program_lexer.l"
+#line 252 "program_lexer.l"
 { return COLOR; }
        YY_BREAK
 case 76:
 YY_RULE_SETUP
-#line 252 "program_lexer.l"
+#line 253 "program_lexer.l"
 { return_token_or_DOT(require_ARB_fp, DEPTH); }
        YY_BREAK
 case 77:
 YY_RULE_SETUP
-#line 253 "program_lexer.l"
+#line 254 "program_lexer.l"
 { return DIFFUSE; }
        YY_BREAK
 case 78:
 YY_RULE_SETUP
-#line 254 "program_lexer.l"
+#line 255 "program_lexer.l"
 { return DIRECTION; }
        YY_BREAK
 case 79:
 YY_RULE_SETUP
-#line 255 "program_lexer.l"
+#line 256 "program_lexer.l"
 { return EMISSION; }
        YY_BREAK
 case 80:
 YY_RULE_SETUP
-#line 256 "program_lexer.l"
+#line 257 "program_lexer.l"
 { return ENV; }
        YY_BREAK
 case 81:
 YY_RULE_SETUP
-#line 257 "program_lexer.l"
+#line 258 "program_lexer.l"
 { return EYE; }
        YY_BREAK
 case 82:
 YY_RULE_SETUP
-#line 258 "program_lexer.l"
+#line 259 "program_lexer.l"
 { return FOGCOORD; }
        YY_BREAK
 case 83:
 YY_RULE_SETUP
-#line 259 "program_lexer.l"
+#line 260 "program_lexer.l"
 { return FOG; }
        YY_BREAK
 case 84:
 YY_RULE_SETUP
-#line 260 "program_lexer.l"
+#line 261 "program_lexer.l"
 { return FRONT; }
        YY_BREAK
 case 85:
 YY_RULE_SETUP
-#line 261 "program_lexer.l"
+#line 262 "program_lexer.l"
 { return HALF; }
        YY_BREAK
 case 86:
 YY_RULE_SETUP
-#line 262 "program_lexer.l"
+#line 263 "program_lexer.l"
 { return INVERSE; }
        YY_BREAK
 case 87:
 YY_RULE_SETUP
-#line 263 "program_lexer.l"
+#line 264 "program_lexer.l"
 { return INVTRANS; }
        YY_BREAK
 case 88:
 YY_RULE_SETUP
-#line 264 "program_lexer.l"
+#line 265 "program_lexer.l"
 { return LIGHT; }
        YY_BREAK
 case 89:
 YY_RULE_SETUP
-#line 265 "program_lexer.l"
+#line 266 "program_lexer.l"
 { return LIGHTMODEL; }
        YY_BREAK
 case 90:
 YY_RULE_SETUP
-#line 266 "program_lexer.l"
+#line 267 "program_lexer.l"
 { return LIGHTPROD; }
        YY_BREAK
 case 91:
 YY_RULE_SETUP
-#line 267 "program_lexer.l"
+#line 268 "program_lexer.l"
 { return LOCAL; }
        YY_BREAK
 case 92:
 YY_RULE_SETUP
-#line 268 "program_lexer.l"
+#line 269 "program_lexer.l"
 { return MATERIAL; }
        YY_BREAK
 case 93:
 YY_RULE_SETUP
-#line 269 "program_lexer.l"
+#line 270 "program_lexer.l"
 { return MAT_PROGRAM; }
        YY_BREAK
 case 94:
 YY_RULE_SETUP
-#line 270 "program_lexer.l"
+#line 271 "program_lexer.l"
 { return MATRIX; }
        YY_BREAK
 case 95:
 YY_RULE_SETUP
-#line 271 "program_lexer.l"
+#line 272 "program_lexer.l"
 { return_token_or_DOT(require_ARB_vp, MATRIXINDEX); }
        YY_BREAK
 case 96:
 YY_RULE_SETUP
-#line 272 "program_lexer.l"
+#line 273 "program_lexer.l"
 { return MODELVIEW; }
        YY_BREAK
 case 97:
 YY_RULE_SETUP
-#line 273 "program_lexer.l"
+#line 274 "program_lexer.l"
 { return MVP; }
        YY_BREAK
 case 98:
 YY_RULE_SETUP
-#line 274 "program_lexer.l"
+#line 275 "program_lexer.l"
 { return_token_or_DOT(require_ARB_vp, NORMAL); }
        YY_BREAK
 case 99:
 YY_RULE_SETUP
-#line 275 "program_lexer.l"
+#line 276 "program_lexer.l"
 { return OBJECT; }
        YY_BREAK
 case 100:
 YY_RULE_SETUP
-#line 276 "program_lexer.l"
+#line 277 "program_lexer.l"
 { return PALETTE; }
        YY_BREAK
 case 101:
 YY_RULE_SETUP
-#line 277 "program_lexer.l"
+#line 278 "program_lexer.l"
 { return PARAMS; }
        YY_BREAK
 case 102:
 YY_RULE_SETUP
-#line 278 "program_lexer.l"
+#line 279 "program_lexer.l"
 { return PLANE; }
        YY_BREAK
 case 103:
 YY_RULE_SETUP
-#line 279 "program_lexer.l"
+#line 280 "program_lexer.l"
 { return_token_or_DOT(require_ARB_vp, POINT_TOK); }
        YY_BREAK
 case 104:
 YY_RULE_SETUP
-#line 280 "program_lexer.l"
+#line 281 "program_lexer.l"
 { return_token_or_DOT(require_ARB_vp, POINTSIZE); }
        YY_BREAK
 case 105:
 YY_RULE_SETUP
-#line 281 "program_lexer.l"
+#line 282 "program_lexer.l"
 { return POSITION; }
        YY_BREAK
 case 106:
 YY_RULE_SETUP
-#line 282 "program_lexer.l"
+#line 283 "program_lexer.l"
 { return PRIMARY; }
        YY_BREAK
 case 107:
 YY_RULE_SETUP
-#line 283 "program_lexer.l"
+#line 284 "program_lexer.l"
 { return PROJECTION; }
        YY_BREAK
 case 108:
 YY_RULE_SETUP
-#line 284 "program_lexer.l"
+#line 285 "program_lexer.l"
 { return_token_or_DOT(require_ARB_fp, RANGE); }
        YY_BREAK
 case 109:
 YY_RULE_SETUP
-#line 285 "program_lexer.l"
+#line 286 "program_lexer.l"
 { return ROW; }
        YY_BREAK
 case 110:
 YY_RULE_SETUP
-#line 286 "program_lexer.l"
+#line 287 "program_lexer.l"
 { return SCENECOLOR; }
        YY_BREAK
 case 111:
 YY_RULE_SETUP
-#line 287 "program_lexer.l"
+#line 288 "program_lexer.l"
 { return SECONDARY; }
        YY_BREAK
 case 112:
 YY_RULE_SETUP
-#line 288 "program_lexer.l"
+#line 289 "program_lexer.l"
 { return SHININESS; }
        YY_BREAK
 case 113:
 YY_RULE_SETUP
-#line 289 "program_lexer.l"
+#line 290 "program_lexer.l"
 { return_token_or_DOT(require_ARB_vp, SIZE_TOK); }
        YY_BREAK
 case 114:
 YY_RULE_SETUP
-#line 290 "program_lexer.l"
+#line 291 "program_lexer.l"
 { return SPECULAR; }
        YY_BREAK
 case 115:
 YY_RULE_SETUP
-#line 291 "program_lexer.l"
+#line 292 "program_lexer.l"
 { return SPOT; }
        YY_BREAK
 case 116:
 YY_RULE_SETUP
-#line 292 "program_lexer.l"
+#line 293 "program_lexer.l"
 { return TEXCOORD; }
        YY_BREAK
 case 117:
 YY_RULE_SETUP
-#line 293 "program_lexer.l"
+#line 294 "program_lexer.l"
 { return_token_or_DOT(require_ARB_fp, TEXENV); }
        YY_BREAK
 case 118:
 YY_RULE_SETUP
-#line 294 "program_lexer.l"
+#line 295 "program_lexer.l"
 { return_token_or_DOT(require_ARB_vp, TEXGEN); }
        YY_BREAK
 case 119:
 YY_RULE_SETUP
-#line 295 "program_lexer.l"
+#line 296 "program_lexer.l"
 { return_token_or_DOT(require_ARB_vp, TEXGEN_Q); }
        YY_BREAK
 case 120:
 YY_RULE_SETUP
-#line 296 "program_lexer.l"
+#line 297 "program_lexer.l"
 { return_token_or_DOT(require_ARB_vp, TEXGEN_S); }
        YY_BREAK
 case 121:
 YY_RULE_SETUP
-#line 297 "program_lexer.l"
+#line 298 "program_lexer.l"
 { return_token_or_DOT(require_ARB_vp, TEXGEN_T); }
        YY_BREAK
 case 122:
 YY_RULE_SETUP
-#line 298 "program_lexer.l"
+#line 299 "program_lexer.l"
 { return TEXTURE; }
        YY_BREAK
 case 123:
 YY_RULE_SETUP
-#line 299 "program_lexer.l"
+#line 300 "program_lexer.l"
 { return TRANSPOSE; }
        YY_BREAK
 case 124:
 YY_RULE_SETUP
-#line 300 "program_lexer.l"
+#line 301 "program_lexer.l"
 { return_token_or_DOT(require_ARB_vp, VTXATTRIB); }
        YY_BREAK
 case 125:
 YY_RULE_SETUP
-#line 301 "program_lexer.l"
+#line 302 "program_lexer.l"
 { return_token_or_DOT(require_ARB_vp, WEIGHT); }
        YY_BREAK
 case 126:
 YY_RULE_SETUP
-#line 303 "program_lexer.l"
+#line 304 "program_lexer.l"
 { return_token_or_IDENTIFIER(require_ARB_fp, TEXTURE_UNIT); }
        YY_BREAK
 case 127:
 YY_RULE_SETUP
-#line 304 "program_lexer.l"
+#line 305 "program_lexer.l"
 { return_token_or_IDENTIFIER(require_ARB_fp, TEX_1D); }
        YY_BREAK
 case 128:
 YY_RULE_SETUP
-#line 305 "program_lexer.l"
+#line 306 "program_lexer.l"
 { return_token_or_IDENTIFIER(require_ARB_fp, TEX_2D); }
        YY_BREAK
 case 129:
 YY_RULE_SETUP
-#line 306 "program_lexer.l"
+#line 307 "program_lexer.l"
 { return_token_or_IDENTIFIER(require_ARB_fp, TEX_3D); }
        YY_BREAK
 case 130:
 YY_RULE_SETUP
-#line 307 "program_lexer.l"
+#line 308 "program_lexer.l"
 { return_token_or_IDENTIFIER(require_ARB_fp, TEX_CUBE); }
        YY_BREAK
 case 131:
 YY_RULE_SETUP
-#line 308 "program_lexer.l"
+#line 309 "program_lexer.l"
 { return_token_or_IDENTIFIER(require_ARB_fp && require_rect, TEX_RECT); }
        YY_BREAK
 case 132:
 YY_RULE_SETUP
-#line 309 "program_lexer.l"
+#line 310 "program_lexer.l"
 { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow, TEX_SHADOW1D); }
        YY_BREAK
 case 133:
 YY_RULE_SETUP
-#line 310 "program_lexer.l"
+#line 311 "program_lexer.l"
 { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow, TEX_SHADOW2D); }
        YY_BREAK
 case 134:
 YY_RULE_SETUP
-#line 311 "program_lexer.l"
+#line 312 "program_lexer.l"
 { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_rect, TEX_SHADOWRECT); }
        YY_BREAK
 case 135:
 YY_RULE_SETUP
-#line 312 "program_lexer.l"
+#line 313 "program_lexer.l"
 { return_token_or_IDENTIFIER(require_ARB_fp && require_texarray, TEX_ARRAY1D); }
        YY_BREAK
 case 136:
 YY_RULE_SETUP
-#line 313 "program_lexer.l"
+#line 314 "program_lexer.l"
 { return_token_or_IDENTIFIER(require_ARB_fp && require_texarray, TEX_ARRAY2D); }
        YY_BREAK
 case 137:
 YY_RULE_SETUP
-#line 314 "program_lexer.l"
+#line 315 "program_lexer.l"
 { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_texarray, TEX_ARRAYSHADOW1D); }
        YY_BREAK
 case 138:
 YY_RULE_SETUP
-#line 315 "program_lexer.l"
+#line 316 "program_lexer.l"
 { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_texarray, TEX_ARRAYSHADOW2D); }
        YY_BREAK
 case 139:
 YY_RULE_SETUP
-#line 317 "program_lexer.l"
+#line 318 "program_lexer.l"
 { return handle_ident(yyextra, yytext, yylval); }
        YY_BREAK
 case 140:
 YY_RULE_SETUP
-#line 319 "program_lexer.l"
+#line 320 "program_lexer.l"
 { return DOT_DOT; }
        YY_BREAK
 case 141:
 YY_RULE_SETUP
-#line 321 "program_lexer.l"
+#line 322 "program_lexer.l"
 {
    yylval->integer = strtol(yytext, NULL, 10);
    return INTEGER;
@@ -2209,9 +2210,9 @@ YY_RULE_SETUP
        YY_BREAK
 case 142:
 YY_RULE_SETUP
-#line 325 "program_lexer.l"
+#line 326 "program_lexer.l"
 {
-   yylval->real = strtod(yytext, NULL);
+   yylval->real = _mesa_strtod(yytext, NULL);
    return REAL;
 }
        YY_BREAK
@@ -2221,31 +2222,31 @@ case 143:
 yyg->yy_c_buf_p = yy_cp -= 1;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 329 "program_lexer.l"
+#line 330 "program_lexer.l"
 {
-   yylval->real = strtod(yytext, NULL);
+   yylval->real = _mesa_strtod(yytext, NULL);
    return REAL;
 }
        YY_BREAK
 case 144:
 YY_RULE_SETUP
-#line 333 "program_lexer.l"
+#line 334 "program_lexer.l"
 {
-   yylval->real = strtod(yytext, NULL);
+   yylval->real = _mesa_strtod(yytext, NULL);
    return REAL;
 }
        YY_BREAK
 case 145:
 YY_RULE_SETUP
-#line 337 "program_lexer.l"
+#line 338 "program_lexer.l"
 {
-   yylval->real = strtod(yytext, NULL);
+   yylval->real = _mesa_strtod(yytext, NULL);
    return REAL;
 }
        YY_BREAK
 case 146:
 YY_RULE_SETUP
-#line 342 "program_lexer.l"
+#line 343 "program_lexer.l"
 {
    yylval->swiz_mask.swizzle = SWIZZLE_NOOP;
    yylval->swiz_mask.mask = WRITEMASK_XYZW;
@@ -2254,7 +2255,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 147:
 YY_RULE_SETUP
-#line 348 "program_lexer.l"
+#line 349 "program_lexer.l"
 {
    yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
    yylval->swiz_mask.mask = WRITEMASK_XY
@@ -2264,7 +2265,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 148:
 YY_RULE_SETUP
-#line 354 "program_lexer.l"
+#line 355 "program_lexer.l"
 {
    yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
    yylval->swiz_mask.mask = WRITEMASK_XZW;
@@ -2273,7 +2274,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 149:
 YY_RULE_SETUP
-#line 359 "program_lexer.l"
+#line 360 "program_lexer.l"
 {
    yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
    yylval->swiz_mask.mask = WRITEMASK_YZW;
@@ -2282,7 +2283,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 150:
 YY_RULE_SETUP
-#line 365 "program_lexer.l"
+#line 366 "program_lexer.l"
 {
    yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
    yylval->swiz_mask.mask = WRITEMASK_X
@@ -2292,7 +2293,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 151:
 YY_RULE_SETUP
-#line 371 "program_lexer.l"
+#line 372 "program_lexer.l"
 {
    yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
    yylval->swiz_mask.mask = WRITEMASK_Y
@@ -2302,7 +2303,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 152:
 YY_RULE_SETUP
-#line 377 "program_lexer.l"
+#line 378 "program_lexer.l"
 {
    yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
    yylval->swiz_mask.mask = WRITEMASK_ZW;
@@ -2311,7 +2312,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 153:
 YY_RULE_SETUP
-#line 383 "program_lexer.l"
+#line 384 "program_lexer.l"
 {
    const unsigned s = swiz_from_char(yytext[1]);
    yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(s, s, s, s);
@@ -2321,7 +2322,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 154:
 YY_RULE_SETUP
-#line 390 "program_lexer.l"
+#line 391 "program_lexer.l"
 {
    yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(swiz_from_char(yytext[1]),
                                            swiz_from_char(yytext[2]),
@@ -2333,7 +2334,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 155:
 YY_RULE_SETUP
-#line 399 "program_lexer.l"
+#line 400 "program_lexer.l"
 {
    yylval->swiz_mask.swizzle = SWIZZLE_NOOP;
    yylval->swiz_mask.mask = WRITEMASK_XYZW;
@@ -2342,7 +2343,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 156:
 YY_RULE_SETUP
-#line 405 "program_lexer.l"
+#line 406 "program_lexer.l"
 {
    yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
    yylval->swiz_mask.mask = WRITEMASK_XY
@@ -2352,7 +2353,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 157:
 YY_RULE_SETUP
-#line 411 "program_lexer.l"
+#line 412 "program_lexer.l"
 {
    yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
    yylval->swiz_mask.mask = WRITEMASK_XZW;
@@ -2361,7 +2362,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 158:
 YY_RULE_SETUP
-#line 416 "program_lexer.l"
+#line 417 "program_lexer.l"
 {
    yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
    yylval->swiz_mask.mask = WRITEMASK_YZW;
@@ -2370,7 +2371,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 159:
 YY_RULE_SETUP
-#line 422 "program_lexer.l"
+#line 423 "program_lexer.l"
 {
    yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
    yylval->swiz_mask.mask = WRITEMASK_X
@@ -2380,7 +2381,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 160:
 YY_RULE_SETUP
-#line 428 "program_lexer.l"
+#line 429 "program_lexer.l"
 {
    yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
    yylval->swiz_mask.mask = WRITEMASK_Y
@@ -2390,7 +2391,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 161:
 YY_RULE_SETUP
-#line 434 "program_lexer.l"
+#line 435 "program_lexer.l"
 {
    yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
    yylval->swiz_mask.mask = WRITEMASK_ZW;
@@ -2399,7 +2400,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 162:
 YY_RULE_SETUP
-#line 440 "program_lexer.l"
+#line 441 "program_lexer.l"
 {
    const unsigned s = swiz_from_char(yytext[1]);
    yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(s, s, s, s);
@@ -2409,7 +2410,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 163:
 YY_RULE_SETUP
-#line 448 "program_lexer.l"
+#line 449 "program_lexer.l"
 {
    if (require_ARB_vp) {
       return TEXGEN_R;
@@ -2423,7 +2424,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 164:
 YY_RULE_SETUP
-#line 459 "program_lexer.l"
+#line 460 "program_lexer.l"
 {
    yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(swiz_from_char(yytext[1]),
                                            swiz_from_char(yytext[2]),
@@ -2435,13 +2436,13 @@ YY_RULE_SETUP
        YY_BREAK
 case 165:
 YY_RULE_SETUP
-#line 468 "program_lexer.l"
+#line 469 "program_lexer.l"
 { return DOT; }
        YY_BREAK
 case 166:
 /* rule 166 can match eol */
 YY_RULE_SETUP
-#line 470 "program_lexer.l"
+#line 471 "program_lexer.l"
 {
    yylloc->first_line++;
    yylloc->first_column = 1;
@@ -2452,7 +2453,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 167:
 YY_RULE_SETUP
-#line 477 "program_lexer.l"
+#line 478 "program_lexer.l"
 /* eat whitespace */ ;
        YY_BREAK
 case 168:
@@ -2460,20 +2461,20 @@ case 168:
 yyg->yy_c_buf_p = yy_cp -= 1;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 478 "program_lexer.l"
+#line 479 "program_lexer.l"
 /* eat comments */ ;
        YY_BREAK
 case 169:
 YY_RULE_SETUP
-#line 479 "program_lexer.l"
+#line 480 "program_lexer.l"
 { return yytext[0]; }
        YY_BREAK
 case 170:
 YY_RULE_SETUP
-#line 480 "program_lexer.l"
+#line 481 "program_lexer.l"
 ECHO;
        YY_BREAK
-#line 2477 "lex.yy.c"
+#line 2478 "lex.yy.c"
 case YY_STATE_EOF(INITIAL):
        yyterminate();
 
@@ -3648,7 +3649,7 @@ void yyfree (void * ptr , yyscan_t yyscanner)
 
 #define YYTABLES_NAME "yytables"
 
-#line 480 "program_lexer.l"
+#line 481 "program_lexer.l"
 
 
 
index 0fd55524abf19e03807a5342f12491ed4ddd55ae..b739a6aa07c951e57bd9838159149beb07aa2597 100644 (file)
@@ -217,6 +217,12 @@ MatchInstruction(const GLubyte *token)
    const struct instruction_pattern *inst;
    struct instruction_pattern result;
 
+   result.name = NULL;
+   result.opcode = MAX_OPCODE; /* i.e. invalid instruction */
+   result.inputs = 0;
+   result.outputs = 0;
+   result.suffixes = 0;
+
    for (inst = Instructions; inst->name; inst++) {
       if (_mesa_strncmp((const char *) token, inst->name, 3) == 0) {
          /* matched! */
@@ -247,7 +253,7 @@ MatchInstruction(const GLubyte *token)
          return result;
       }
    }
-   result.opcode = MAX_OPCODE; /* i.e. invalid instruction */
+
    return result;
 }
 
index 471a7358a2f4bc3aa34c275ad4739281cc80624b..fd6cbb0f40972c11b8cf49d535d041fa422f0a19 100644 (file)
@@ -47,6 +47,7 @@
 #include "prog_instruction.h"
 #include "nvfragparse.h"
 #include "nvvertparse.h"
+#include "arbprogparse.h"
 #include "nvprogram.h"
 
 
@@ -595,6 +596,12 @@ _mesa_LoadProgramNV(GLenum target, GLuint id, GLsizei len,
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
+   if (!ctx->Extensions.NV_vertex_program
+       && !ctx->Extensions.NV_fragment_program) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glLoadProgramNV()");
+      return;
+   }
+
    if (id == 0) {
       _mesa_error(ctx, GL_INVALID_VALUE, "glLoadProgramNV(id)");
       return;
@@ -627,7 +634,13 @@ _mesa_LoadProgramNV(GLenum target, GLuint id, GLsizei len,
          }
          _mesa_HashInsert(ctx->Shared->Programs, id, vprog);
       }
-      _mesa_parse_nv_vertex_program(ctx, target, program, len, vprog);
+
+      if (ctx->Extensions.ARB_vertex_program
+         && (strncmp((char *) program, "!!ARB", 5) == 0)) {
+        _mesa_parse_arb_vertex_program(ctx, target, program, len, vprog);
+      } else {
+        _mesa_parse_nv_vertex_program(ctx, target, program, len, vprog);
+      }
    }
    else if (target == GL_FRAGMENT_PROGRAM_NV
             && ctx->Extensions.NV_fragment_program) {
@@ -643,6 +656,20 @@ _mesa_LoadProgramNV(GLenum target, GLuint id, GLsizei len,
       }
       _mesa_parse_nv_fragment_program(ctx, target, program, len, fprog);
    }
+   else if (target == GL_FRAGMENT_PROGRAM_ARB
+            && ctx->Extensions.ARB_fragment_program) {
+      struct gl_fragment_program *fprog = (struct gl_fragment_program *) prog;
+      if (!fprog || prog == &_mesa_DummyProgram) {
+         fprog = (struct gl_fragment_program *)
+            ctx->Driver.NewProgram(ctx, target, id);
+         if (!fprog) {
+            _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV");
+            return;
+         }
+         _mesa_HashInsert(ctx->Shared->Programs, id, fprog);
+      }
+      _mesa_parse_arb_fragment_program(ctx, target, program, len, fprog);
+   }
    else {
       _mesa_error(ctx, GL_INVALID_ENUM, "glLoadProgramNV(target)");
    }
index 192d39aed1ee40ac7f3e4bf8aa8c8b68f6e5fb84..7f034520cd474ff967af35748107074fdfc3f15c 100644 (file)
  * Set x to positive or negative infinity.
  */
 #if defined(USE_IEEE) || defined(_WIN32)
-#define SET_POS_INFINITY(x)  ( *((GLuint *) (void *)&x) = 0x7F800000 )
-#define SET_NEG_INFINITY(x)  ( *((GLuint *) (void *)&x) = 0xFF800000 )
+#define SET_POS_INFINITY(x)                  \
+   do {                                      \
+         fi_type fi;                         \
+         fi.i = 0x7F800000;                  \
+         x = fi.f;                           \
+   } while (0)
+#define SET_NEG_INFINITY(x)                  \
+   do {                                      \
+         fi_type fi;                         \
+         fi.i = 0xFF800000;                  \
+         x = fi.f;                           \
+   } while (0)
 #elif defined(VMS)
 #define SET_POS_INFINITY(x)  x = __MAXFLOAT
 #define SET_NEG_INFINITY(x)  x = -__MAXFLOAT
@@ -674,9 +684,13 @@ _mesa_execute_program(GLcontext * ctx,
          break;
       case OPCODE_BGNLOOP:
          /* no-op */
+         ASSERT(program->Instructions[inst->BranchTarget].Opcode
+                == OPCODE_ENDLOOP);
          break;
       case OPCODE_ENDLOOP:
          /* subtract 1 here since pc is incremented by for(pc) loop */
+         ASSERT(program->Instructions[inst->BranchTarget].Opcode
+                == OPCODE_BGNLOOP);
          pc = inst->BranchTarget - 1;   /* go to matching BNGLOOP */
          break;
       case OPCODE_BGNSUB:      /* begin subroutine */
@@ -684,12 +698,26 @@ _mesa_execute_program(GLcontext * ctx,
       case OPCODE_ENDSUB:      /* end subroutine */
          break;
       case OPCODE_BRA:         /* branch (conditional) */
-         /* fall-through */
+         if (eval_condition(machine, inst)) {
+            /* take branch */
+            /* Subtract 1 here since we'll do pc++ below */
+            pc = inst->BranchTarget - 1;
+         }
+         break;
       case OPCODE_BRK:         /* break out of loop (conditional) */
-         /* fall-through */
+         ASSERT(program->Instructions[inst->BranchTarget].Opcode
+                == OPCODE_ENDLOOP);
+         if (eval_condition(machine, inst)) {
+            /* break out of loop */
+            /* pc++ at end of for-loop will put us after the ENDLOOP inst */
+            pc = inst->BranchTarget;
+         }
+         break;
       case OPCODE_CONT:        /* continue loop (conditional) */
+         ASSERT(program->Instructions[inst->BranchTarget].Opcode
+                == OPCODE_ENDLOOP);
          if (eval_condition(machine, inst)) {
-            /* take branch */
+            /* continue at ENDLOOP */
             /* Subtract 1 here since we'll do pc++ at end of for-loop */
             pc = inst->BranchTarget - 1;
          }
@@ -882,6 +910,10 @@ _mesa_execute_program(GLcontext * ctx,
       case OPCODE_IF:
          {
             GLboolean cond;
+            ASSERT(program->Instructions[inst->BranchTarget].Opcode
+                   == OPCODE_ELSE ||
+                   program->Instructions[inst->BranchTarget].Opcode
+                   == OPCODE_ENDIF);
             /* eval condition */
             if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) {
                GLfloat a[4];
@@ -901,14 +933,16 @@ _mesa_execute_program(GLcontext * ctx,
             else {
                /* go to the instruction after ELSE or ENDIF */
                assert(inst->BranchTarget >= 0);
-               pc = inst->BranchTarget - 1;
+               pc = inst->BranchTarget;
             }
          }
          break;
       case OPCODE_ELSE:
          /* goto ENDIF */
+         ASSERT(program->Instructions[inst->BranchTarget].Opcode
+                == OPCODE_ENDIF);
          assert(inst->BranchTarget >= 0);
-         pc = inst->BranchTarget - 1;
+         pc = inst->BranchTarget;
          break;
       case OPCODE_ENDIF:
          /* nothing */
@@ -1635,11 +1669,12 @@ _mesa_execute_program(GLcontext * ctx,
       case OPCODE_UP2H:        /* unpack two 16-bit floats */
          {
             GLfloat a[4], result[4];
-            const GLuint *rawBits = (const GLuint *) a;
+            fi_type fi;
             GLhalfNV hx, hy;
             fetch_vector1(&inst->SrcReg[0], machine, a);
-            hx = rawBits[0] & 0xffff;
-            hy = rawBits[0] >> 16;
+            fi.f = a[0];
+            hx = fi.i & 0xffff;
+            hy = fi.i >> 16;
             result[0] = result[2] = _mesa_half_to_float(hx);
             result[1] = result[3] = _mesa_half_to_float(hy);
             store_vector4(inst, machine, result);
@@ -1648,11 +1683,12 @@ _mesa_execute_program(GLcontext * ctx,
       case OPCODE_UP2US:       /* unpack two GLushorts */
          {
             GLfloat a[4], result[4];
-            const GLuint *rawBits = (const GLuint *) a;
+            fi_type fi;
             GLushort usx, usy;
             fetch_vector1(&inst->SrcReg[0], machine, a);
-            usx = rawBits[0] & 0xffff;
-            usy = rawBits[0] >> 16;
+            fi.f = a[0];
+            usx = fi.i & 0xffff;
+            usy = fi.i >> 16;
             result[0] = result[2] = usx * (1.0f / 65535.0f);
             result[1] = result[3] = usy * (1.0f / 65535.0f);
             store_vector4(inst, machine, result);
@@ -1661,24 +1697,26 @@ _mesa_execute_program(GLcontext * ctx,
       case OPCODE_UP4B:        /* unpack four GLbytes */
          {
             GLfloat a[4], result[4];
-            const GLuint *rawBits = (const GLuint *) a;
+            fi_type fi;
             fetch_vector1(&inst->SrcReg[0], machine, a);
-            result[0] = (((rawBits[0] >> 0) & 0xff) - 128) / 127.0F;
-            result[1] = (((rawBits[0] >> 8) & 0xff) - 128) / 127.0F;
-            result[2] = (((rawBits[0] >> 16) & 0xff) - 128) / 127.0F;
-            result[3] = (((rawBits[0] >> 24) & 0xff) - 128) / 127.0F;
+            fi.f = a[0];
+            result[0] = (((fi.i >> 0) & 0xff) - 128) / 127.0F;
+            result[1] = (((fi.i >> 8) & 0xff) - 128) / 127.0F;
+            result[2] = (((fi.i >> 16) & 0xff) - 128) / 127.0F;
+            result[3] = (((fi.i >> 24) & 0xff) - 128) / 127.0F;
             store_vector4(inst, machine, result);
          }
          break;
       case OPCODE_UP4UB:       /* unpack four GLubytes */
          {
             GLfloat a[4], result[4];
-            const GLuint *rawBits = (const GLuint *) a;
+            fi_type fi;
             fetch_vector1(&inst->SrcReg[0], machine, a);
-            result[0] = ((rawBits[0] >> 0) & 0xff) / 255.0F;
-            result[1] = ((rawBits[0] >> 8) & 0xff) / 255.0F;
-            result[2] = ((rawBits[0] >> 16) & 0xff) / 255.0F;
-            result[3] = ((rawBits[0] >> 24) & 0xff) / 255.0F;
+            fi.f = a[0];
+            result[0] = ((fi.i >> 0) & 0xff) / 255.0F;
+            result[1] = ((fi.i >> 8) & 0xff) / 255.0F;
+            result[2] = ((fi.i >> 16) & 0xff) / 255.0F;
+            result[3] = ((fi.i >> 24) & 0xff) / 255.0F;
             store_vector4(inst, machine, result);
          }
          break;
index 1c687bc16cfffce591f59979df31f0262b6242c2..224350caac6c33efcecae83cb57a77a9d044e792 100644 (file)
@@ -312,7 +312,6 @@ struct prog_dst_register
     */
    GLuint CondSrc:1;
    /*@}*/
-   GLuint pad:28;
 };
 
 
index 9d937488e37250a9b883d16b77e9e28fdbb99566..83d119e031ea24637dd8b830cdbe93453f3f3cf3 100644 (file)
 
 static GLboolean dbg = GL_FALSE;
 
+/* Returns the mask of channels read from the given srcreg in this instruction.
+ */
+static GLuint
+get_src_arg_mask(const struct prog_instruction *inst, int arg)
+{
+   int writemask = inst->DstReg.WriteMask;
+
+   if (inst->CondUpdate)
+      writemask = WRITEMASK_XYZW;
+
+   switch (inst->Opcode) {
+   case OPCODE_MOV:
+   case OPCODE_ABS:
+   case OPCODE_ADD:
+   case OPCODE_MUL:
+   case OPCODE_SUB:
+      return writemask;
+   case OPCODE_RCP:
+   case OPCODE_SIN:
+   case OPCODE_COS:
+   case OPCODE_RSQ:
+   case OPCODE_POW:
+   case OPCODE_EX2:
+      return WRITEMASK_X;
+   case OPCODE_DP2:
+      return WRITEMASK_XY;
+   case OPCODE_DP3:
+   case OPCODE_XPD:
+      return WRITEMASK_XYZ;
+   default:
+      return WRITEMASK_XYZW;
+   }
+}
 
 /**
  * In 'prog' remove instruction[i] if removeFlags[i] == TRUE.
@@ -74,6 +107,11 @@ remove_instructions(struct gl_program *prog, const GLboolean *removeFlags)
          }
       }
    }
+   /* Finish removing if the first instruction was to be removed. */
+   if (removeCount > 0) {
+      GLint removeStart = removeEnd - removeCount + 1;
+      _mesa_delete_instructions(prog, removeStart, removeCount);
+   }
    return totalRemoved;
 }
 
@@ -187,11 +225,10 @@ _mesa_consolidate_registers(struct gl_program *prog)
 static void
 _mesa_remove_dead_code(struct gl_program *prog)
 {
-   GLboolean tempWritten[MAX_PROGRAM_TEMPS], tempRead[MAX_PROGRAM_TEMPS];
+   GLboolean tempRead[MAX_PROGRAM_TEMPS][4];
    GLboolean *removeInst; /* per-instruction removal flag */
-   GLuint i, rem;
+   GLuint i, rem = 0, comp;
 
-   memset(tempWritten, 0, sizeof(tempWritten));
    memset(tempRead, 0, sizeof(tempRead));
 
    if (dbg) {
@@ -212,16 +249,37 @@ _mesa_remove_dead_code(struct gl_program *prog)
       for (j = 0; j < numSrc; j++) {
          if (inst->SrcReg[j].File == PROGRAM_TEMPORARY) {
             const GLuint index = inst->SrcReg[j].Index;
+            GLuint read_mask;
             ASSERT(index < MAX_PROGRAM_TEMPS);
+           read_mask = get_src_arg_mask(inst, j);
 
             if (inst->SrcReg[j].RelAddr) {
                if (dbg)
                   _mesa_printf("abort remove dead code (indirect temp)\n");
-               _mesa_free(removeInst);
-               return;
+               goto done;
             }
 
-            tempRead[index] = GL_TRUE;
+           for (comp = 0; comp < 4; comp++) {
+              GLuint swz = (inst->SrcReg[j].Swizzle >> (3 * comp)) & 0x7;
+
+              if ((read_mask & (1 << comp)) == 0)
+                 continue;
+
+              switch (swz) {
+              case SWIZZLE_X:
+                 tempRead[index][0] = GL_TRUE;
+                 break;
+              case SWIZZLE_Y:
+                 tempRead[index][1] = GL_TRUE;
+                 break;
+              case SWIZZLE_Z:
+                 tempRead[index][2] = GL_TRUE;
+                 break;
+              case SWIZZLE_W:
+                 tempRead[index][3] = GL_TRUE;
+                 break;
+              }
+           }
          }
       }
 
@@ -233,50 +291,63 @@ _mesa_remove_dead_code(struct gl_program *prog)
          if (inst->DstReg.RelAddr) {
             if (dbg)
                _mesa_printf("abort remove dead code (indirect temp)\n");
-            _mesa_free(removeInst);
-            return;
+            goto done;
          }
 
-         tempWritten[index] = GL_TRUE;
          if (inst->CondUpdate) {
             /* If we're writing to this register and setting condition
              * codes we cannot remove the instruction.  Prevent removal
              * by setting the 'read' flag.
              */
-            tempRead[index] = GL_TRUE;
+            tempRead[index][0] = GL_TRUE;
+            tempRead[index][1] = GL_TRUE;
+            tempRead[index][2] = GL_TRUE;
+            tempRead[index][3] = GL_TRUE;
          }
       }
    }
 
-   if (dbg) {
-      for (i = 0; i < MAX_PROGRAM_TEMPS; i++) {
-         if (tempWritten[i] && !tempRead[i])
-            _mesa_printf("Remove writes to tmp %u\n", i);
-      }
-   }
-
    /* find instructions that write to dead registers, flag for removal */
    for (i = 0; i < prog->NumInstructions; i++) {
-      const struct prog_instruction *inst = prog->Instructions + i;
-      if (inst->DstReg.File == PROGRAM_TEMPORARY) {
-         GLint index = inst->DstReg.Index;
-         removeInst[i] = (tempWritten[index] && !tempRead[index]);
-         if (dbg && removeInst[i]) {
-            _mesa_printf("Remove inst %u: ", i);
-            _mesa_print_instruction(inst);
-         }
+      struct prog_instruction *inst = prog->Instructions + i;
+      const GLuint numDst = _mesa_num_inst_dst_regs(inst->Opcode);
+
+      if (numDst != 0 && inst->DstReg.File == PROGRAM_TEMPORARY) {
+         GLint chan, index = inst->DstReg.Index;
+
+        for (chan = 0; chan < 4; chan++) {
+           if (!tempRead[index][chan] &&
+               inst->DstReg.WriteMask & (1 << chan)) {
+              if (dbg) {
+                 _mesa_printf("Remove writemask on %u.%c\n", i,
+                              chan == 3 ? 'w' : 'x' + chan);
+              }
+              inst->DstReg.WriteMask &= ~(1 << chan);
+              rem++;
+           }
+        }
+
+        if (inst->DstReg.WriteMask == 0) {
+           /* If we cleared all writes, the instruction can be removed. */
+           if (dbg)
+              _mesa_printf("Remove instruction %u: \n", i);
+           removeInst[i] = GL_TRUE;
+        }
       }
    }
 
    /* now remove the instructions which aren't needed */
    rem = remove_instructions(prog, removeInst);
 
-   _mesa_free(removeInst);
-
    if (dbg) {
-      _mesa_printf("Optimize: End dead code removal.  %u instructions removed\n", rem);
+      _mesa_printf("Optimize: End dead code removal.\n");
+      _mesa_printf("  %u channel writes removed\n", rem);
+      _mesa_printf("  %u instructions removed\n", rem);
       /*_mesa_print_program(prog);*/
    }
+
+done:
+   _mesa_free(removeInst);
 }
 
 
@@ -325,6 +396,132 @@ find_next_temp_use(const struct gl_program *prog, GLuint start, GLuint index)
    return END;
 }
 
+static GLboolean _mesa_is_flow_control_opcode(enum prog_opcode opcode)
+{
+   switch (opcode) {
+   case OPCODE_BGNLOOP:
+   case OPCODE_BGNSUB:
+   case OPCODE_BRA:
+   case OPCODE_CAL:
+   case OPCODE_CONT:
+   case OPCODE_IF:
+   case OPCODE_ELSE:
+   case OPCODE_END:
+   case OPCODE_ENDIF:
+   case OPCODE_ENDLOOP:
+   case OPCODE_ENDSUB:
+   case OPCODE_RET:
+      return GL_TRUE;
+   default:
+      return GL_FALSE;
+   }
+}
+
+/**
+ * Try to remove use of extraneous MOV instructions, to free them up for dead
+ * code removal.
+ */
+static void
+_mesa_remove_extra_move_use(struct gl_program *prog)
+{
+   GLuint i, j;
+
+   if (dbg) {
+      _mesa_printf("Optimize: Begin remove extra move use\n");
+      _mesa_print_program(prog);
+   }
+
+   /*
+    * Look for sequences such as this:
+    *    MOV tmpX, arg0;
+    *    ...
+    *    FOO tmpY, tmpX, arg1;
+    * and convert into:
+    *    MOV tmpX, arg0;
+    *    ...
+    *    FOO tmpY, arg0, arg1;
+    */
+
+   for (i = 0; i + 1 < prog->NumInstructions; i++) {
+      const struct prog_instruction *mov = prog->Instructions + i;
+
+      if (mov->Opcode != OPCODE_MOV ||
+         mov->DstReg.File != PROGRAM_TEMPORARY ||
+         mov->DstReg.RelAddr ||
+         mov->DstReg.CondMask != COND_TR ||
+         mov->SaturateMode != SATURATE_OFF ||
+         mov->SrcReg[0].RelAddr)
+        continue;
+
+      /* Walk through remaining instructions until the or src reg gets
+       * rewritten or we get into some flow-control, eliminating the use of
+       * this MOV.
+       */
+      for (j = i + 1; j < prog->NumInstructions; j++) {
+        struct prog_instruction *inst2 = prog->Instructions + j;
+        int arg;
+
+        if (_mesa_is_flow_control_opcode(inst2->Opcode))
+            break;
+
+        /* First rewrite this instruction's args if appropriate. */
+        for (arg = 0; arg < _mesa_num_inst_src_regs(inst2->Opcode); arg++) {
+           int comp;
+           int read_mask = get_src_arg_mask(inst2, arg);
+
+           if (inst2->SrcReg[arg].File != mov->DstReg.File ||
+               inst2->SrcReg[arg].Index != mov->DstReg.Index ||
+               inst2->SrcReg[arg].RelAddr ||
+               inst2->SrcReg[arg].Abs)
+              continue;
+
+           /* Check that all the sources for this arg of inst2 come from inst1
+            * or constants.
+            */
+           for (comp = 0; comp < 4; comp++) {
+              int src_swz = GET_SWZ(inst2->SrcReg[arg].Swizzle, comp);
+
+              /* If the MOV didn't write that channel, can't use it. */
+              if ((read_mask & (1 << comp)) &&
+                  src_swz <= SWIZZLE_W &&
+                  (mov->DstReg.WriteMask & (1 << src_swz)) == 0)
+                 break;
+           }
+           if (comp != 4)
+              continue;
+
+           /* Adjust the swizzles of inst2 to point at MOV's source */
+           for (comp = 0; comp < 4; comp++) {
+              int inst2_swz = GET_SWZ(inst2->SrcReg[arg].Swizzle, comp);
+
+              if (inst2_swz <= SWIZZLE_W) {
+                 GLuint s = GET_SWZ(mov->SrcReg[0].Swizzle, inst2_swz);
+                 inst2->SrcReg[arg].Swizzle &= ~(7 << (3 * comp));
+                 inst2->SrcReg[arg].Swizzle |= s << (3 * comp);
+                 inst2->SrcReg[arg].Negate ^= (((mov->SrcReg[0].Negate >>
+                                                 inst2_swz) & 0x1) << comp);
+              }
+           }
+           inst2->SrcReg[arg].File = mov->SrcReg[0].File;
+           inst2->SrcReg[arg].Index = mov->SrcReg[0].Index;
+        }
+
+        /* If this instruction overwrote part of the move, our time is up. */
+        if ((inst2->DstReg.File == mov->DstReg.File &&
+             (inst2->DstReg.RelAddr ||
+              inst2->DstReg.Index == mov->DstReg.Index)) ||
+            (inst2->DstReg.File == mov->SrcReg[0].File &&
+             (inst2->DstReg.RelAddr ||
+              inst2->DstReg.Index == mov->SrcReg[0].Index)))
+           break;
+      }
+   }
+
+   if (dbg) {
+      _mesa_printf("Optimize: End remove extra move use.\n");
+      /*_mesa_print_program(prog);*/
+   }
+}
 
 /**
  * Try to remove extraneous MOV instructions from the given program.
@@ -823,6 +1020,8 @@ _mesa_reallocate_registers(struct gl_program *prog)
 void
 _mesa_optimize_program(GLcontext *ctx, struct gl_program *program)
 {
+   _mesa_remove_extra_move_use(program);
+
    if (1)
       _mesa_remove_dead_code(program);
 
index 2f029b02e50a61bb13efce004d08dec75ca472cc..5822510701bd88dac446cdccb4062f38cc3074e2 100644 (file)
@@ -230,9 +230,8 @@ _mesa_add_named_constant(struct gl_program_parameter_list *paramList,
  * Add a new unnamed constant to the parameter list.  This will be used
  * when a fragment/vertex program contains something like this:
  *    MOV r, { 0, 1, 2, 3 };
- * We'll search the parameter list for an existing instance of the
- * constant.  If swizzleOut is non-null, we'll try swizzling when
- * looking for a match.
+ * If swizzleOut is non-null we'll search the parameter list for an
+ * existing instance of the constant which matches with a swizzle.
  *
  * \param paramList  the parameter list
  * \param values  four float values
@@ -248,7 +247,8 @@ _mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList,
    ASSERT(size >= 1);
    ASSERT(size <= 4);
 
-   if (_mesa_lookup_parameter_constant(paramList, values,
+   if (swizzleOut &&
+       _mesa_lookup_parameter_constant(paramList, values,
                                        size, &pos, swizzleOut)) {
       return pos;
    }
@@ -500,7 +500,7 @@ GLfloat *
 _mesa_lookup_parameter_value(const struct gl_program_parameter_list *paramList,
                              GLsizei nameLen, const char *name)
 {
-   GLuint i = _mesa_lookup_parameter_index(paramList, nameLen, name);
+   GLint i = _mesa_lookup_parameter_index(paramList, nameLen, name);
    if (i < 0)
       return NULL;
    else
index 1c37b3a7a5a04396dbd23153a32fc619dd2a1e47..a8885738321d64390fa938bbb87b919bb8a79c7b 100644 (file)
@@ -72,14 +72,11 @@ copy_indirect_accessed_array(struct gl_program_parameter_list *src,
                             unsigned first, unsigned count)
 {
    const int base = dst->NumParameters;
-   unsigned i;
-   unsigned j;
-
+   unsigned i, j;
 
    for (i = first; i < (first + count); i++) {
       struct gl_program_parameter *curr = & src->Parameters[i];
 
-
       if (curr->Type == PROGRAM_CONSTANT) {
         j = dst->NumParameters;
       } else {
@@ -93,10 +90,15 @@ copy_indirect_accessed_array(struct gl_program_parameter_list *src,
 
       assert(j == dst->NumParameters);
 
+      /* copy src parameter [i] to dest parameter [j] */
       memcpy(& dst->Parameters[j], curr,
             sizeof(dst->Parameters[j]));
       memcpy(dst->ParameterValues[j], src->ParameterValues[i],
             sizeof(GLfloat) * 4);
+
+      /* Pointer to the string name was copied.  Null-out src param name
+       * to prevent double free later.
+       */
       curr->Name = NULL;
 
       dst->NumParameters++;
@@ -117,11 +119,9 @@ _mesa_layout_parameters(struct asm_parser_state *state)
    struct asm_instruction *inst;
    unsigned i;
 
-
    layout =
       _mesa_new_parameter_list_sized(state->prog->Parameters->NumParameters);
 
-
    /* PASS 1:  Move any parameters that are accessed indirectly from the
     * original parameter list to the new parameter list.
     */
@@ -155,7 +155,6 @@ _mesa_layout_parameters(struct asm_parser_state *state)
       }
    }
 
-
    /* PASS 2:  Move any parameters that are not accessed indirectly from the
     * original parameter list to the new parameter list.
     */
@@ -165,7 +164,6 @@ _mesa_layout_parameters(struct asm_parser_state *state)
         const int idx = inst->SrcReg[i].Base.Index;
         unsigned swizzle = SWIZZLE_NOOP;
 
-
         /* All relative addressed operands were processed on the first
          * pass.  Just skip them here.
          */
@@ -173,7 +171,6 @@ _mesa_layout_parameters(struct asm_parser_state *state)
            continue;
         }
 
-
         if ((inst->SrcReg[i].Base.File <= PROGRAM_VARYING )
             || (inst->SrcReg[i].Base.File >= PROGRAM_WRITE_ONLY)) {
            continue;
@@ -209,7 +206,6 @@ _mesa_layout_parameters(struct asm_parser_state *state)
       }
    }
 
-
    _mesa_free_parameter_list(state->prog->Parameters);
    state->prog->Parameters = layout;
 
index b71735aa80e88a971152f1aba1f81672746fe9ed..9f9789e010c7bc778d0fa28c11d331445b999b38 100644 (file)
@@ -788,7 +788,7 @@ _mesa_fprint_program_opt(FILE *f,
       else if (mode == PROG_PRINT_NV)
          _mesa_fprintf(f, "!!VP1.0\n");
       else
-         _mesa_fprintf(f, "# Vertex Program/Shader\n");
+         _mesa_fprintf(f, "# Vertex Program/Shader %u\n", prog->Id);
       break;
    case GL_FRAGMENT_PROGRAM_ARB:
    case GL_FRAGMENT_PROGRAM_NV:
@@ -797,7 +797,7 @@ _mesa_fprint_program_opt(FILE *f,
       else if (mode == PROG_PRINT_NV)
          _mesa_fprintf(f, "!!FP1.0\n");
       else
-         _mesa_fprintf(f, "# Fragment Program/Shader\n");
+         _mesa_fprintf(f, "# Fragment Program/Shader %u\n", prog->Id);
       break;
    }
 
@@ -821,17 +821,19 @@ _mesa_print_program(const struct gl_program *prog)
 
 
 /**
- * Return binary representation of value (as a string).
+ * Return binary representation of 64-bit value (as a string).
  * Insert a comma to separate each group of 8 bits.
+ * Note we return a pointer to local static storage so this is not
+ * re-entrant, etc.
  * XXX move to imports.[ch] if useful elsewhere.
  */
 static const char *
-binary(GLbitfield val)
+binary(GLbitfield64 val)
 {
-   static char buf[50];
+   static char buf[80];
    GLint i, len = 0;
-   for (i = 31; i >= 0; --i) {
-      if (val & (1 << i))
+   for (i = 63; i >= 0; --i) {
+      if (val & (1ULL << i))
          buf[len++] = '1';
       else if (len > 0 || i == 0)
          buf[len++] = '0';
@@ -855,7 +857,7 @@ _mesa_fprint_program_parameters(FILE *f,
 
    _mesa_fprintf(f, "InputsRead: 0x%x (0b%s)\n",
                  prog->InputsRead, binary(prog->InputsRead));
-   _mesa_fprintf(f, "OutputsWritten: 0x%x (0b%s)\n",
+   _mesa_fprintf(f, "OutputsWritten: 0x%llx (0b%s)\n",
                  prog->OutputsWritten, binary(prog->OutputsWritten));
    _mesa_fprintf(f, "NumInstructions=%d\n", prog->NumInstructions);
    _mesa_fprintf(f, "NumTemporaries=%d\n", prog->NumTemporaries);
@@ -906,7 +908,8 @@ _mesa_fprint_parameter_list(FILE *f,
    if (!list)
       return;
 
-   _mesa_fprintf(f, "param list %p\n", (void *) list);
+   if (0)
+      _mesa_fprintf(f, "param list %p\n", (void *) list);
    _mesa_fprintf(f, "dirty state flags: 0x%x\n", list->StateFlags);
    for (i = 0; i < list->NumParameters; i++){
       struct gl_program_parameter *param = list->Parameters + i;
index 532adf4d3600c1350e443c9ad135da4fcde6ddf7..6b8d94e66142354c0a09ef86e88e120372c496bd 100644 (file)
@@ -806,9 +806,17 @@ _mesa_find_free_register(const struct gl_program *prog, GLuint regFile)
       const struct prog_instruction *inst = prog->Instructions + i;
       const GLuint n = _mesa_num_inst_src_regs(inst->Opcode);
 
-      for (k = 0; k < n; k++) {
-         if (inst->SrcReg[k].File == regFile) {
-            used[inst->SrcReg[k].Index] = GL_TRUE;
+      /* check dst reg first */
+      if (inst->DstReg.File == regFile) {
+         used[inst->DstReg.Index] = GL_TRUE;
+      }
+      else {
+         /* check src regs otherwise */
+         for (k = 0; k < n; k++) {
+            if (inst->SrcReg[k].File == regFile) {
+               used[inst->SrcReg[k].Index] = GL_TRUE;
+               break;
+            }
          }
       }
    }
index 8498c3d8fc084ac2124f54e27987e930896bf971..e2acb3c0c9601751a6febdde0937618d2d6f48db 100644 (file)
@@ -22,6 +22,7 @@
  * DEALINGS IN THE SOFTWARE.
  */
 #include "main/glheader.h"
+#include "main/imports.h"
 #include "prog_instruction.h"
 #include "prog_statevars.h"
 
@@ -323,19 +324,19 @@ ARRAYSHADOW2D             { return_token_or_IDENTIFIER(require_ARB_fp && require
    return INTEGER;
 }
 {num}?{frac}{exp}?        {
-   yylval->real = strtod(yytext, NULL);
+   yylval->real = _mesa_strtod(yytext, NULL);
    return REAL;
 }
 {num}"."/[^.]             {
-   yylval->real = strtod(yytext, NULL);
+   yylval->real = _mesa_strtod(yytext, NULL);
    return REAL;
 }
 {num}{exp}                {
-   yylval->real = strtod(yytext, NULL);
+   yylval->real = _mesa_strtod(yytext, NULL);
    return REAL;
 }
 {num}"."{exp}             {
-   yylval->real = strtod(yytext, NULL);
+   yylval->real = _mesa_strtod(yytext, NULL);
    return REAL;
 }
 
index c0f50147bd97478e30acb0d1753b14312bc537f7..b12dcee9dfa0e816d270f68976be12285b22e1fd 100644 (file)
@@ -123,7 +123,8 @@ static int initialize_symbol_from_param(struct gl_program *prog,
     struct asm_symbol *param_var, const gl_state_index tokens[STATE_LENGTH]);
 
 static int initialize_symbol_from_const(struct gl_program *prog,
-    struct asm_symbol *param_var, const struct asm_vector *vec);
+    struct asm_symbol *param_var, const struct asm_vector *vec,
+    GLboolean allowSwizzle);
 
 static int yyparse(struct asm_parser_state *state);
 
@@ -137,8 +138,17 @@ static int validate_inputs(struct YYLTYPE *locp,
 
 static void init_dst_reg(struct prog_dst_register *r);
 
+static void set_dst_reg(struct prog_dst_register *r,
+                        gl_register_file file, GLint index);
+
 static void init_src_reg(struct asm_src_register *r);
 
+static void set_src_reg(struct asm_src_register *r,
+                        gl_register_file file, GLint index);
+
+static void set_src_reg_swz(struct asm_src_register *r,
+                            gl_register_file file, GLint index, GLuint swizzle);
+
 static void asm_instruction_set_operands(struct asm_instruction *inst,
     const struct prog_dst_register *dst, const struct asm_src_register *src0,
     const struct asm_src_register *src1, const struct asm_src_register *src2);
@@ -179,7 +189,7 @@ static struct asm_instruction *asm_instruction_copy_ctor(
 
 
 /* Line 189 of yacc.c  */
-#line 183 "program_parse.tab.c"
+#line 193 "program_parse.tab.c"
 
 /* Enabling traces.  */
 #ifndef YYDEBUG
@@ -321,7 +331,7 @@ typedef union YYSTYPE
 {
 
 /* Line 214 of yacc.c  */
-#line 116 "program_parse.y"
+#line 126 "program_parse.y"
 
    struct asm_instruction *inst;
    struct asm_symbol *sym;
@@ -350,7 +360,7 @@ typedef union YYSTYPE
 
 
 /* Line 214 of yacc.c  */
-#line 354 "program_parse.tab.c"
+#line 364 "program_parse.tab.c"
 } YYSTYPE;
 # define YYSTYPE_IS_TRIVIAL 1
 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
@@ -374,14 +384,14 @@ typedef struct YYLTYPE
 /* Copy the second part of user declarations.  */
 
 /* Line 264 of yacc.c  */
-#line 261 "program_parse.y"
+#line 271 "program_parse.y"
 
 extern int yylex(YYSTYPE *yylval_param, YYLTYPE *yylloc_param,
     void *yyscanner);
 
 
 /* Line 264 of yacc.c  */
-#line 385 "program_parse.tab.c"
+#line 395 "program_parse.tab.c"
 
 #ifdef short
 # undef short
@@ -782,35 +792,35 @@ static const yytype_int16 yyrhs[] =
 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
 static const yytype_uint16 yyrline[] =
 {
-       0,   268,   268,   271,   279,   291,   292,   295,   317,   318,
-     321,   336,   339,   344,   351,   352,   353,   354,   355,   356,
-     357,   360,   361,   362,   365,   371,   377,   383,   390,   396,
-     403,   447,   452,   462,   506,   512,   513,   514,   515,   516,
-     517,   518,   519,   520,   521,   522,   523,   526,   538,   546,
-     563,   570,   589,   600,   620,   645,   654,   687,   694,   709,
-     759,   801,   812,   833,   843,   849,   880,   897,   897,   899,
-     906,   918,   919,   920,   923,   937,   951,   969,   980,   992,
-     994,   995,   996,   997,  1000,  1000,  1000,  1000,  1001,  1004,
-    1008,  1013,  1020,  1027,  1034,  1057,  1080,  1081,  1082,  1083,
-    1084,  1085,  1088,  1106,  1110,  1116,  1120,  1124,  1128,  1137,
-    1146,  1150,  1155,  1161,  1172,  1172,  1173,  1175,  1179,  1183,
-    1187,  1193,  1193,  1195,  1211,  1234,  1237,  1248,  1254,  1260,
-    1261,  1268,  1274,  1280,  1288,  1294,  1300,  1308,  1314,  1320,
-    1328,  1329,  1332,  1333,  1334,  1335,  1336,  1337,  1338,  1339,
-    1340,  1341,  1342,  1345,  1354,  1358,  1362,  1368,  1377,  1381,
-    1385,  1394,  1398,  1404,  1410,  1417,  1422,  1430,  1440,  1442,
-    1450,  1456,  1460,  1464,  1470,  1481,  1490,  1494,  1499,  1503,
-    1507,  1511,  1517,  1524,  1528,  1534,  1542,  1553,  1560,  1564,
-    1570,  1580,  1591,  1595,  1613,  1622,  1625,  1631,  1635,  1639,
-    1645,  1656,  1661,  1666,  1671,  1676,  1681,  1689,  1692,  1697,
-    1710,  1718,  1729,  1737,  1737,  1739,  1739,  1741,  1751,  1756,
-    1763,  1773,  1782,  1787,  1794,  1804,  1814,  1826,  1826,  1827,
-    1827,  1829,  1839,  1847,  1857,  1865,  1873,  1882,  1893,  1897,
-    1903,  1904,  1905,  1908,  1908,  1911,  1946,  1950,  1950,  1953,
-    1959,  1967,  1980,  1989,  1998,  2002,  2011,  2020,  2031,  2038,
-    2043,  2052,  2064,  2067,  2076,  2087,  2088,  2089,  2092,  2093,
-    2094,  2097,  2098,  2101,  2102,  2105,  2106,  2109,  2120,  2131,
-    2142,  2163,  2164
+       0,   278,   278,   281,   289,   301,   302,   305,   329,   330,
+     333,   348,   351,   356,   363,   364,   365,   366,   367,   368,
+     369,   372,   373,   374,   377,   383,   389,   395,   402,   408,
+     415,   459,   464,   474,   518,   524,   525,   526,   527,   528,
+     529,   530,   531,   532,   533,   534,   535,   538,   550,   558,
+     575,   582,   601,   612,   632,   657,   664,   697,   704,   719,
+     774,   817,   826,   847,   857,   861,   890,   909,   909,   911,
+     918,   930,   931,   932,   935,   949,   963,   983,   994,  1006,
+    1008,  1009,  1010,  1011,  1014,  1014,  1014,  1014,  1015,  1018,
+    1022,  1027,  1034,  1041,  1048,  1071,  1094,  1095,  1096,  1097,
+    1098,  1099,  1102,  1121,  1125,  1131,  1135,  1139,  1143,  1152,
+    1161,  1165,  1170,  1176,  1187,  1187,  1188,  1190,  1194,  1198,
+    1202,  1208,  1208,  1210,  1228,  1254,  1257,  1268,  1274,  1280,
+    1281,  1288,  1294,  1300,  1308,  1314,  1320,  1328,  1334,  1340,
+    1348,  1349,  1352,  1353,  1354,  1355,  1356,  1357,  1358,  1359,
+    1360,  1361,  1362,  1365,  1374,  1378,  1382,  1388,  1397,  1401,
+    1405,  1414,  1418,  1424,  1430,  1437,  1442,  1450,  1460,  1462,
+    1470,  1476,  1480,  1484,  1490,  1501,  1510,  1514,  1519,  1523,
+    1527,  1531,  1537,  1544,  1548,  1554,  1562,  1573,  1580,  1584,
+    1590,  1600,  1611,  1615,  1633,  1642,  1645,  1651,  1655,  1659,
+    1665,  1676,  1681,  1686,  1691,  1696,  1701,  1709,  1712,  1717,
+    1730,  1738,  1749,  1757,  1757,  1759,  1759,  1761,  1771,  1776,
+    1783,  1793,  1802,  1807,  1814,  1824,  1834,  1846,  1846,  1847,
+    1847,  1849,  1859,  1867,  1877,  1885,  1893,  1902,  1913,  1917,
+    1923,  1924,  1925,  1928,  1928,  1931,  1966,  1970,  1970,  1973,
+    1980,  1989,  2003,  2012,  2021,  2025,  2034,  2043,  2054,  2061,
+    2066,  2075,  2087,  2090,  2099,  2110,  2111,  2112,  2115,  2116,
+    2117,  2120,  2121,  2124,  2125,  2128,  2129,  2132,  2143,  2154,
+    2165,  2191,  2192
 };
 #endif
 
@@ -2119,7 +2129,7 @@ yyreduce:
         case 3:
 
 /* Line 1455 of yacc.c  */
-#line 272 "program_parse.y"
+#line 282 "program_parse.y"
     {
           if (state->prog->Target != GL_VERTEX_PROGRAM_ARB) {
              yyerror(& (yylsp[(1) - (1)]), state, "invalid fragment program header");
@@ -2132,7 +2142,7 @@ yyreduce:
   case 4:
 
 /* Line 1455 of yacc.c  */
-#line 280 "program_parse.y"
+#line 290 "program_parse.y"
     {
           if (state->prog->Target != GL_FRAGMENT_PROGRAM_ARB) {
              yyerror(& (yylsp[(1) - (1)]), state, "invalid vertex program header");
@@ -2147,7 +2157,7 @@ yyreduce:
   case 7:
 
 /* Line 1455 of yacc.c  */
-#line 296 "program_parse.y"
+#line 306 "program_parse.y"
     {
           int valid = 0;
 
@@ -2158,6 +2168,8 @@ yyreduce:
           }
 
 
+          free((yyvsp[(2) - (3)].string));
+
           if (!valid) {
              const char *const err_str = (state->mode == ARB_vertex)
                 ? "invalid ARB vertex program option"
@@ -2172,7 +2184,7 @@ yyreduce:
   case 10:
 
 /* Line 1455 of yacc.c  */
-#line 322 "program_parse.y"
+#line 334 "program_parse.y"
     {
           if ((yyvsp[(1) - (2)].inst) != NULL) {
              if (state->inst_tail == NULL) {
@@ -2192,7 +2204,7 @@ yyreduce:
   case 12:
 
 /* Line 1455 of yacc.c  */
-#line 340 "program_parse.y"
+#line 352 "program_parse.y"
     {
           (yyval.inst) = (yyvsp[(1) - (1)].inst);
           state->prog->NumAluInstructions++;
@@ -2202,7 +2214,7 @@ yyreduce:
   case 13:
 
 /* Line 1455 of yacc.c  */
-#line 345 "program_parse.y"
+#line 357 "program_parse.y"
     {
           (yyval.inst) = (yyvsp[(1) - (1)].inst);
           state->prog->NumTexInstructions++;
@@ -2212,7 +2224,7 @@ yyreduce:
   case 24:
 
 /* Line 1455 of yacc.c  */
-#line 366 "program_parse.y"
+#line 378 "program_parse.y"
     {
           (yyval.inst) = asm_instruction_ctor(OPCODE_ARL, & (yyvsp[(2) - (4)].dst_reg), & (yyvsp[(4) - (4)].src_reg), NULL, NULL);
        ;}
@@ -2221,7 +2233,7 @@ yyreduce:
   case 25:
 
 /* Line 1455 of yacc.c  */
-#line 372 "program_parse.y"
+#line 384 "program_parse.y"
     {
           (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (4)].temp_inst), & (yyvsp[(2) - (4)].dst_reg), & (yyvsp[(4) - (4)].src_reg), NULL, NULL);
        ;}
@@ -2230,7 +2242,7 @@ yyreduce:
   case 26:
 
 /* Line 1455 of yacc.c  */
-#line 378 "program_parse.y"
+#line 390 "program_parse.y"
     {
           (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (4)].temp_inst), & (yyvsp[(2) - (4)].dst_reg), & (yyvsp[(4) - (4)].src_reg), NULL, NULL);
        ;}
@@ -2239,7 +2251,7 @@ yyreduce:
   case 27:
 
 /* Line 1455 of yacc.c  */
-#line 384 "program_parse.y"
+#line 396 "program_parse.y"
     {
           (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (6)].temp_inst), & (yyvsp[(2) - (6)].dst_reg), & (yyvsp[(4) - (6)].src_reg), & (yyvsp[(6) - (6)].src_reg), NULL);
        ;}
@@ -2248,7 +2260,7 @@ yyreduce:
   case 28:
 
 /* Line 1455 of yacc.c  */
-#line 391 "program_parse.y"
+#line 403 "program_parse.y"
     {
           (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (6)].temp_inst), & (yyvsp[(2) - (6)].dst_reg), & (yyvsp[(4) - (6)].src_reg), & (yyvsp[(6) - (6)].src_reg), NULL);
        ;}
@@ -2257,7 +2269,7 @@ yyreduce:
   case 29:
 
 /* Line 1455 of yacc.c  */
-#line 398 "program_parse.y"
+#line 410 "program_parse.y"
     {
           (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (8)].temp_inst), & (yyvsp[(2) - (8)].dst_reg), & (yyvsp[(4) - (8)].src_reg), & (yyvsp[(6) - (8)].src_reg), & (yyvsp[(8) - (8)].src_reg));
        ;}
@@ -2266,7 +2278,7 @@ yyreduce:
   case 30:
 
 /* Line 1455 of yacc.c  */
-#line 404 "program_parse.y"
+#line 416 "program_parse.y"
     {
           (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (8)].temp_inst), & (yyvsp[(2) - (8)].dst_reg), & (yyvsp[(4) - (8)].src_reg), NULL, NULL);
           if ((yyval.inst) != NULL) {
@@ -2313,7 +2325,7 @@ yyreduce:
   case 31:
 
 /* Line 1455 of yacc.c  */
-#line 448 "program_parse.y"
+#line 460 "program_parse.y"
     {
           (yyval.inst) = asm_instruction_ctor(OPCODE_KIL, NULL, & (yyvsp[(2) - (2)].src_reg), NULL, NULL);
           state->fragment.UsesKill = 1;
@@ -2323,7 +2335,7 @@ yyreduce:
   case 32:
 
 /* Line 1455 of yacc.c  */
-#line 453 "program_parse.y"
+#line 465 "program_parse.y"
     {
           (yyval.inst) = asm_instruction_ctor(OPCODE_KIL_NV, NULL, NULL, NULL, NULL);
           (yyval.inst)->Base.DstReg.CondMask = (yyvsp[(2) - (2)].dst_reg).CondMask;
@@ -2336,7 +2348,7 @@ yyreduce:
   case 33:
 
 /* Line 1455 of yacc.c  */
-#line 463 "program_parse.y"
+#line 475 "program_parse.y"
     {
           (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (12)].temp_inst), & (yyvsp[(2) - (12)].dst_reg), & (yyvsp[(4) - (12)].src_reg), & (yyvsp[(6) - (12)].src_reg), & (yyvsp[(8) - (12)].src_reg));
           if ((yyval.inst) != NULL) {
@@ -2383,7 +2395,7 @@ yyreduce:
   case 34:
 
 /* Line 1455 of yacc.c  */
-#line 507 "program_parse.y"
+#line 519 "program_parse.y"
     {
           (yyval.integer) = (yyvsp[(2) - (2)].integer);
        ;}
@@ -2392,91 +2404,91 @@ yyreduce:
   case 35:
 
 /* Line 1455 of yacc.c  */
-#line 512 "program_parse.y"
+#line 524 "program_parse.y"
     { (yyval.integer) = TEXTURE_1D_INDEX; ;}
     break;
 
   case 36:
 
 /* Line 1455 of yacc.c  */
-#line 513 "program_parse.y"
+#line 525 "program_parse.y"
     { (yyval.integer) = TEXTURE_2D_INDEX; ;}
     break;
 
   case 37:
 
 /* Line 1455 of yacc.c  */
-#line 514 "program_parse.y"
+#line 526 "program_parse.y"
     { (yyval.integer) = TEXTURE_3D_INDEX; ;}
     break;
 
   case 38:
 
 /* Line 1455 of yacc.c  */
-#line 515 "program_parse.y"
+#line 527 "program_parse.y"
     { (yyval.integer) = TEXTURE_CUBE_INDEX; ;}
     break;
 
   case 39:
 
 /* Line 1455 of yacc.c  */
-#line 516 "program_parse.y"
+#line 528 "program_parse.y"
     { (yyval.integer) = TEXTURE_RECT_INDEX; ;}
     break;
 
   case 40:
 
 /* Line 1455 of yacc.c  */
-#line 517 "program_parse.y"
+#line 529 "program_parse.y"
     { (yyval.integer) = -TEXTURE_1D_INDEX; ;}
     break;
 
   case 41:
 
 /* Line 1455 of yacc.c  */
-#line 518 "program_parse.y"
+#line 530 "program_parse.y"
     { (yyval.integer) = -TEXTURE_2D_INDEX; ;}
     break;
 
   case 42:
 
 /* Line 1455 of yacc.c  */
-#line 519 "program_parse.y"
+#line 531 "program_parse.y"
     { (yyval.integer) = -TEXTURE_RECT_INDEX; ;}
     break;
 
   case 43:
 
 /* Line 1455 of yacc.c  */
-#line 520 "program_parse.y"
+#line 532 "program_parse.y"
     { (yyval.integer) = TEXTURE_1D_ARRAY_INDEX; ;}
     break;
 
   case 44:
 
 /* Line 1455 of yacc.c  */
-#line 521 "program_parse.y"
+#line 533 "program_parse.y"
     { (yyval.integer) = TEXTURE_2D_ARRAY_INDEX; ;}
     break;
 
   case 45:
 
 /* Line 1455 of yacc.c  */
-#line 522 "program_parse.y"
+#line 534 "program_parse.y"
     { (yyval.integer) = -TEXTURE_1D_ARRAY_INDEX; ;}
     break;
 
   case 46:
 
 /* Line 1455 of yacc.c  */
-#line 523 "program_parse.y"
+#line 535 "program_parse.y"
     { (yyval.integer) = -TEXTURE_2D_ARRAY_INDEX; ;}
     break;
 
   case 47:
 
 /* Line 1455 of yacc.c  */
-#line 527 "program_parse.y"
+#line 539 "program_parse.y"
     {
           /* FIXME: Is this correct?  Should the extenedSwizzle be applied
            * FIXME: to the existing swizzle?
@@ -2491,7 +2503,7 @@ yyreduce:
   case 48:
 
 /* Line 1455 of yacc.c  */
-#line 539 "program_parse.y"
+#line 551 "program_parse.y"
     {
           (yyval.src_reg) = (yyvsp[(2) - (2)].src_reg);
 
@@ -2504,7 +2516,7 @@ yyreduce:
   case 49:
 
 /* Line 1455 of yacc.c  */
-#line 547 "program_parse.y"
+#line 559 "program_parse.y"
     {
           (yyval.src_reg) = (yyvsp[(3) - (4)].src_reg);
 
@@ -2524,7 +2536,7 @@ yyreduce:
   case 50:
 
 /* Line 1455 of yacc.c  */
-#line 564 "program_parse.y"
+#line 576 "program_parse.y"
     {
           (yyval.src_reg) = (yyvsp[(1) - (2)].src_reg);
 
@@ -2536,7 +2548,7 @@ yyreduce:
   case 51:
 
 /* Line 1455 of yacc.c  */
-#line 571 "program_parse.y"
+#line 583 "program_parse.y"
     {
           struct asm_symbol temp_sym;
 
@@ -2547,18 +2559,18 @@ yyreduce:
 
           memset(& temp_sym, 0, sizeof(temp_sym));
           temp_sym.param_binding_begin = ~0;
-          initialize_symbol_from_const(state->prog, & temp_sym, & (yyvsp[(1) - (1)].vector));
+          initialize_symbol_from_const(state->prog, & temp_sym, & (yyvsp[(1) - (1)].vector), GL_TRUE);
 
-          init_src_reg(& (yyval.src_reg));
-          (yyval.src_reg).Base.File = PROGRAM_CONSTANT;
-          (yyval.src_reg).Base.Index = temp_sym.param_binding_begin;
+          set_src_reg_swz(& (yyval.src_reg), PROGRAM_CONSTANT,
+                           temp_sym.param_binding_begin,
+                           temp_sym.param_binding_swizzle);
        ;}
     break;
 
   case 52:
 
 /* Line 1455 of yacc.c  */
-#line 590 "program_parse.y"
+#line 602 "program_parse.y"
     {
           (yyval.src_reg) = (yyvsp[(2) - (3)].src_reg);
 
@@ -2574,7 +2586,7 @@ yyreduce:
   case 53:
 
 /* Line 1455 of yacc.c  */
-#line 601 "program_parse.y"
+#line 613 "program_parse.y"
     {
           (yyval.src_reg) = (yyvsp[(3) - (5)].src_reg);
 
@@ -2596,7 +2608,7 @@ yyreduce:
   case 54:
 
 /* Line 1455 of yacc.c  */
-#line 621 "program_parse.y"
+#line 633 "program_parse.y"
     {
           (yyval.dst_reg) = (yyvsp[(1) - (3)].dst_reg);
           (yyval.dst_reg).WriteMask = (yyvsp[(2) - (3)].swiz_mask).mask;
@@ -2616,7 +2628,7 @@ yyreduce:
                 YYERROR;
              }
 
-             state->prog->OutputsWritten |= (1U << (yyval.dst_reg).Index);
+             state->prog->OutputsWritten |= BITFIELD64_BIT((yyval.dst_reg).Index);
           }
        ;}
     break;
@@ -2624,11 +2636,9 @@ yyreduce:
   case 55:
 
 /* Line 1455 of yacc.c  */
-#line 646 "program_parse.y"
+#line 658 "program_parse.y"
     {
-          init_dst_reg(& (yyval.dst_reg));
-          (yyval.dst_reg).File = PROGRAM_ADDRESS;
-          (yyval.dst_reg).Index = 0;
+          set_dst_reg(& (yyval.dst_reg), PROGRAM_ADDRESS, 0);
           (yyval.dst_reg).WriteMask = (yyvsp[(2) - (2)].swiz_mask).mask;
        ;}
     break;
@@ -2636,7 +2646,7 @@ yyreduce:
   case 56:
 
 /* Line 1455 of yacc.c  */
-#line 655 "program_parse.y"
+#line 665 "program_parse.y"
     {
           const unsigned xyzw_valid =
              ((yyvsp[(1) - (7)].ext_swizzle).xyzw_valid << 0)
@@ -2672,7 +2682,7 @@ yyreduce:
   case 57:
 
 /* Line 1455 of yacc.c  */
-#line 688 "program_parse.y"
+#line 698 "program_parse.y"
     {
           (yyval.ext_swizzle) = (yyvsp[(2) - (2)].ext_swizzle);
           (yyval.ext_swizzle).negate = ((yyvsp[(1) - (2)].negate)) ? 1 : 0;
@@ -2682,7 +2692,7 @@ yyreduce:
   case 58:
 
 /* Line 1455 of yacc.c  */
-#line 695 "program_parse.y"
+#line 705 "program_parse.y"
     {
           if (((yyvsp[(1) - (1)].integer) != 0) && ((yyvsp[(1) - (1)].integer) != 1)) {
              yyerror(& (yylsp[(1) - (1)]), state, "invalid extended swizzle selector");
@@ -2702,14 +2712,19 @@ yyreduce:
   case 59:
 
 /* Line 1455 of yacc.c  */
-#line 710 "program_parse.y"
+#line 720 "program_parse.y"
     {
+          char s;
+
           if (strlen((yyvsp[(1) - (1)].string)) > 1) {
              yyerror(& (yylsp[(1) - (1)]), state, "invalid extended swizzle selector");
              YYERROR;
           }
 
-          switch ((yyvsp[(1) - (1)].string)[0]) {
+          s = (yyvsp[(1) - (1)].string)[0];
+          free((yyvsp[(1) - (1)].string));
+
+          switch (s) {
           case 'x':
              (yyval.ext_swizzle).swz = SWIZZLE_X;
              (yyval.ext_swizzle).xyzw_valid = 1;
@@ -2755,11 +2770,13 @@ yyreduce:
   case 60:
 
 /* Line 1455 of yacc.c  */
-#line 760 "program_parse.y"
+#line 775 "program_parse.y"
     {
           struct asm_symbol *const s = (struct asm_symbol *)
              _mesa_symbol_table_find_symbol(state->st, 0, (yyvsp[(1) - (1)].string));
 
+          free((yyvsp[(1) - (1)].string));
+
           if (s == NULL) {
              yyerror(& (yylsp[(1) - (1)]), state, "invalid operand variable");
              YYERROR;
@@ -2775,16 +2792,15 @@ yyreduce:
           init_src_reg(& (yyval.src_reg));
           switch (s->type) {
           case at_temp:
-             (yyval.src_reg).Base.File = PROGRAM_TEMPORARY;
-             (yyval.src_reg).Base.Index = s->temp_binding;
+             set_src_reg(& (yyval.src_reg), PROGRAM_TEMPORARY, s->temp_binding);
              break;
           case at_param:
-             (yyval.src_reg).Base.File = s->param_binding_type;
-             (yyval.src_reg).Base.Index = s->param_binding_begin;
+              set_src_reg_swz(& (yyval.src_reg), s->param_binding_type,
+                              s->param_binding_begin,
+                              s->param_binding_swizzle);
              break;
           case at_attrib:
-             (yyval.src_reg).Base.File = PROGRAM_INPUT;
-             (yyval.src_reg).Base.Index = s->attrib_binding;
+             set_src_reg(& (yyval.src_reg), PROGRAM_INPUT, s->attrib_binding);
              state->prog->InputsRead |= (1U << (yyval.src_reg).Base.Index);
 
              if (!validate_inputs(& (yylsp[(1) - (1)]), state)) {
@@ -2802,11 +2818,9 @@ yyreduce:
   case 61:
 
 /* Line 1455 of yacc.c  */
-#line 802 "program_parse.y"
+#line 818 "program_parse.y"
     {
-          init_src_reg(& (yyval.src_reg));
-          (yyval.src_reg).Base.File = PROGRAM_INPUT;
-          (yyval.src_reg).Base.Index = (yyvsp[(1) - (1)].attrib);
+          set_src_reg(& (yyval.src_reg), PROGRAM_INPUT, (yyvsp[(1) - (1)].attrib));
           state->prog->InputsRead |= (1U << (yyval.src_reg).Base.Index);
 
           if (!validate_inputs(& (yylsp[(1) - (1)]), state)) {
@@ -2818,7 +2832,7 @@ yyreduce:
   case 62:
 
 /* Line 1455 of yacc.c  */
-#line 813 "program_parse.y"
+#line 827 "program_parse.y"
     {
           if (! (yyvsp[(3) - (4)].src_reg).Base.RelAddr
               && ((unsigned) (yyvsp[(3) - (4)].src_reg).Base.Index >= (yyvsp[(1) - (4)].sym)->param_binding_length)) {
@@ -2844,35 +2858,35 @@ yyreduce:
   case 63:
 
 /* Line 1455 of yacc.c  */
-#line 834 "program_parse.y"
+#line 848 "program_parse.y"
     {
-          init_src_reg(& (yyval.src_reg));
-          (yyval.src_reg).Base.File = ((yyvsp[(1) - (1)].temp_sym).name != NULL) 
+           gl_register_file file = ((yyvsp[(1) - (1)].temp_sym).name != NULL) 
              ? (yyvsp[(1) - (1)].temp_sym).param_binding_type
              : PROGRAM_CONSTANT;
-          (yyval.src_reg).Base.Index = (yyvsp[(1) - (1)].temp_sym).param_binding_begin;
+           set_src_reg_swz(& (yyval.src_reg), file, (yyvsp[(1) - (1)].temp_sym).param_binding_begin,
+                           (yyvsp[(1) - (1)].temp_sym).param_binding_swizzle);
        ;}
     break;
 
   case 64:
 
 /* Line 1455 of yacc.c  */
-#line 844 "program_parse.y"
+#line 858 "program_parse.y"
     {
-          init_dst_reg(& (yyval.dst_reg));
-          (yyval.dst_reg).File = PROGRAM_OUTPUT;
-          (yyval.dst_reg).Index = (yyvsp[(1) - (1)].result);
+          set_dst_reg(& (yyval.dst_reg), PROGRAM_OUTPUT, (yyvsp[(1) - (1)].result));
        ;}
     break;
 
   case 65:
 
 /* Line 1455 of yacc.c  */
-#line 850 "program_parse.y"
+#line 862 "program_parse.y"
     {
           struct asm_symbol *const s = (struct asm_symbol *)
              _mesa_symbol_table_find_symbol(state->st, 0, (yyvsp[(1) - (1)].string));
 
+          free((yyvsp[(1) - (1)].string));
+
           if (s == NULL) {
              yyerror(& (yylsp[(1) - (1)]), state, "invalid operand variable");
              YYERROR;
@@ -2881,19 +2895,15 @@ yyreduce:
              YYERROR;
           }
 
-          init_dst_reg(& (yyval.dst_reg));
           switch (s->type) {
           case at_temp:
-             (yyval.dst_reg).File = PROGRAM_TEMPORARY;
-             (yyval.dst_reg).Index = s->temp_binding;
+             set_dst_reg(& (yyval.dst_reg), PROGRAM_TEMPORARY, s->temp_binding);
              break;
           case at_output:
-             (yyval.dst_reg).File = PROGRAM_OUTPUT;
-             (yyval.dst_reg).Index = s->output_binding;
+             set_dst_reg(& (yyval.dst_reg), PROGRAM_OUTPUT, s->output_binding);
              break;
           default:
-             (yyval.dst_reg).File = s->param_binding_type;
-             (yyval.dst_reg).Index = s->param_binding_begin;
+             set_dst_reg(& (yyval.dst_reg), s->param_binding_type, s->param_binding_begin);
              break;
           }
        ;}
@@ -2902,11 +2912,13 @@ yyreduce:
   case 66:
 
 /* Line 1455 of yacc.c  */
-#line 881 "program_parse.y"
+#line 891 "program_parse.y"
     {
           struct asm_symbol *const s = (struct asm_symbol *)
              _mesa_symbol_table_find_symbol(state->st, 0, (yyvsp[(1) - (1)].string));
 
+          free((yyvsp[(1) - (1)].string));
+
           if (s == NULL) {
              yyerror(& (yylsp[(1) - (1)]), state, "invalid operand variable");
              YYERROR;
@@ -2922,7 +2934,7 @@ yyreduce:
   case 69:
 
 /* Line 1455 of yacc.c  */
-#line 900 "program_parse.y"
+#line 912 "program_parse.y"
     {
           init_src_reg(& (yyval.src_reg));
           (yyval.src_reg).Base.Index = (yyvsp[(1) - (1)].integer);
@@ -2932,7 +2944,7 @@ yyreduce:
   case 70:
 
 /* Line 1455 of yacc.c  */
-#line 907 "program_parse.y"
+#line 919 "program_parse.y"
     {
           /* FINISHME: Add support for multiple address registers.
            */
@@ -2947,28 +2959,28 @@ yyreduce:
   case 71:
 
 /* Line 1455 of yacc.c  */
-#line 918 "program_parse.y"
+#line 930 "program_parse.y"
     { (yyval.integer) = 0; ;}
     break;
 
   case 72:
 
 /* Line 1455 of yacc.c  */
-#line 919 "program_parse.y"
+#line 931 "program_parse.y"
     { (yyval.integer) = (yyvsp[(2) - (2)].integer); ;}
     break;
 
   case 73:
 
 /* Line 1455 of yacc.c  */
-#line 920 "program_parse.y"
+#line 932 "program_parse.y"
     { (yyval.integer) = -(yyvsp[(2) - (2)].integer); ;}
     break;
 
   case 74:
 
 /* Line 1455 of yacc.c  */
-#line 924 "program_parse.y"
+#line 936 "program_parse.y"
     {
           if (((yyvsp[(1) - (1)].integer) < 0) || ((yyvsp[(1) - (1)].integer) > 63)) {
               char s[100];
@@ -2985,7 +2997,7 @@ yyreduce:
   case 75:
 
 /* Line 1455 of yacc.c  */
-#line 938 "program_parse.y"
+#line 950 "program_parse.y"
     {
           if (((yyvsp[(1) - (1)].integer) < 0) || ((yyvsp[(1) - (1)].integer) > 64)) {
               char s[100];
@@ -3002,11 +3014,13 @@ yyreduce:
   case 76:
 
 /* Line 1455 of yacc.c  */
-#line 952 "program_parse.y"
+#line 964 "program_parse.y"
     {
           struct asm_symbol *const s = (struct asm_symbol *)
              _mesa_symbol_table_find_symbol(state->st, 0, (yyvsp[(1) - (1)].string));
 
+          free((yyvsp[(1) - (1)].string));
+
           if (s == NULL) {
              yyerror(& (yylsp[(1) - (1)]), state, "invalid array member");
              YYERROR;
@@ -3023,7 +3037,7 @@ yyreduce:
   case 77:
 
 /* Line 1455 of yacc.c  */
-#line 970 "program_parse.y"
+#line 984 "program_parse.y"
     {
           if ((yyvsp[(1) - (1)].swiz_mask).mask != WRITEMASK_X) {
              yyerror(& (yylsp[(1) - (1)]), state, "invalid address component selector");
@@ -3037,7 +3051,7 @@ yyreduce:
   case 78:
 
 /* Line 1455 of yacc.c  */
-#line 981 "program_parse.y"
+#line 995 "program_parse.y"
     {
           if ((yyvsp[(1) - (1)].swiz_mask).mask != WRITEMASK_X) {
              yyerror(& (yylsp[(1) - (1)]), state,
@@ -3052,21 +3066,21 @@ yyreduce:
   case 83:
 
 /* Line 1455 of yacc.c  */
-#line 997 "program_parse.y"
+#line 1011 "program_parse.y"
     { (yyval.swiz_mask).swizzle = SWIZZLE_NOOP; (yyval.swiz_mask).mask = WRITEMASK_XYZW; ;}
     break;
 
   case 88:
 
 /* Line 1455 of yacc.c  */
-#line 1001 "program_parse.y"
+#line 1015 "program_parse.y"
     { (yyval.swiz_mask).swizzle = SWIZZLE_NOOP; (yyval.swiz_mask).mask = WRITEMASK_XYZW; ;}
     break;
 
   case 89:
 
 /* Line 1455 of yacc.c  */
-#line 1005 "program_parse.y"
+#line 1019 "program_parse.y"
     {
           (yyval.dst_reg) = (yyvsp[(2) - (3)].dst_reg);
        ;}
@@ -3075,7 +3089,7 @@ yyreduce:
   case 90:
 
 /* Line 1455 of yacc.c  */
-#line 1009 "program_parse.y"
+#line 1023 "program_parse.y"
     {
           (yyval.dst_reg) = (yyvsp[(2) - (3)].dst_reg);
        ;}
@@ -3084,7 +3098,7 @@ yyreduce:
   case 91:
 
 /* Line 1455 of yacc.c  */
-#line 1013 "program_parse.y"
+#line 1027 "program_parse.y"
     {
           (yyval.dst_reg).CondMask = COND_TR;
           (yyval.dst_reg).CondSwizzle = SWIZZLE_NOOP;
@@ -3095,7 +3109,7 @@ yyreduce:
   case 92:
 
 /* Line 1455 of yacc.c  */
-#line 1021 "program_parse.y"
+#line 1035 "program_parse.y"
     {
           (yyval.dst_reg) = (yyvsp[(1) - (2)].dst_reg);
           (yyval.dst_reg).CondSwizzle = (yyvsp[(2) - (2)].swiz_mask).swizzle;
@@ -3105,7 +3119,7 @@ yyreduce:
   case 93:
 
 /* Line 1455 of yacc.c  */
-#line 1028 "program_parse.y"
+#line 1042 "program_parse.y"
     {
           (yyval.dst_reg) = (yyvsp[(1) - (2)].dst_reg);
           (yyval.dst_reg).CondSwizzle = (yyvsp[(2) - (2)].swiz_mask).swizzle;
@@ -3115,7 +3129,7 @@ yyreduce:
   case 94:
 
 /* Line 1455 of yacc.c  */
-#line 1035 "program_parse.y"
+#line 1049 "program_parse.y"
     {
           const int cond = _mesa_parse_cc((yyvsp[(1) - (1)].string));
           if ((cond == 0) || ((yyvsp[(1) - (1)].string)[2] != '\0')) {
@@ -3141,7 +3155,7 @@ yyreduce:
   case 95:
 
 /* Line 1455 of yacc.c  */
-#line 1058 "program_parse.y"
+#line 1072 "program_parse.y"
     {
           const int cond = _mesa_parse_cc((yyvsp[(1) - (1)].string));
           if ((cond == 0) || ((yyvsp[(1) - (1)].string)[2] != '\0')) {
@@ -3167,12 +3181,13 @@ yyreduce:
   case 102:
 
 /* Line 1455 of yacc.c  */
-#line 1089 "program_parse.y"
+#line 1103 "program_parse.y"
     {
           struct asm_symbol *const s =
              declare_variable(state, (yyvsp[(2) - (4)].string), at_attrib, & (yylsp[(2) - (4)]));
 
           if (s == NULL) {
+             free((yyvsp[(2) - (4)].string));
              YYERROR;
           } else {
              s->attrib_binding = (yyvsp[(4) - (4)].attrib);
@@ -3188,7 +3203,7 @@ yyreduce:
   case 103:
 
 /* Line 1455 of yacc.c  */
-#line 1107 "program_parse.y"
+#line 1122 "program_parse.y"
     {
           (yyval.attrib) = (yyvsp[(2) - (2)].attrib);
        ;}
@@ -3197,7 +3212,7 @@ yyreduce:
   case 104:
 
 /* Line 1455 of yacc.c  */
-#line 1111 "program_parse.y"
+#line 1126 "program_parse.y"
     {
           (yyval.attrib) = (yyvsp[(2) - (2)].attrib);
        ;}
@@ -3206,7 +3221,7 @@ yyreduce:
   case 105:
 
 /* Line 1455 of yacc.c  */
-#line 1117 "program_parse.y"
+#line 1132 "program_parse.y"
     {
           (yyval.attrib) = VERT_ATTRIB_POS;
        ;}
@@ -3215,7 +3230,7 @@ yyreduce:
   case 106:
 
 /* Line 1455 of yacc.c  */
-#line 1121 "program_parse.y"
+#line 1136 "program_parse.y"
     {
           (yyval.attrib) = VERT_ATTRIB_WEIGHT;
        ;}
@@ -3224,7 +3239,7 @@ yyreduce:
   case 107:
 
 /* Line 1455 of yacc.c  */
-#line 1125 "program_parse.y"
+#line 1140 "program_parse.y"
     {
           (yyval.attrib) = VERT_ATTRIB_NORMAL;
        ;}
@@ -3233,7 +3248,7 @@ yyreduce:
   case 108:
 
 /* Line 1455 of yacc.c  */
-#line 1129 "program_parse.y"
+#line 1144 "program_parse.y"
     {
           if (!state->ctx->Extensions.EXT_secondary_color) {
              yyerror(& (yylsp[(2) - (2)]), state, "GL_EXT_secondary_color not supported");
@@ -3247,7 +3262,7 @@ yyreduce:
   case 109:
 
 /* Line 1455 of yacc.c  */
-#line 1138 "program_parse.y"
+#line 1153 "program_parse.y"
     {
           if (!state->ctx->Extensions.EXT_fog_coord) {
              yyerror(& (yylsp[(1) - (1)]), state, "GL_EXT_fog_coord not supported");
@@ -3261,7 +3276,7 @@ yyreduce:
   case 110:
 
 /* Line 1455 of yacc.c  */
-#line 1147 "program_parse.y"
+#line 1162 "program_parse.y"
     {
           (yyval.attrib) = VERT_ATTRIB_TEX0 + (yyvsp[(2) - (2)].integer);
        ;}
@@ -3270,7 +3285,7 @@ yyreduce:
   case 111:
 
 /* Line 1455 of yacc.c  */
-#line 1151 "program_parse.y"
+#line 1166 "program_parse.y"
     {
           yyerror(& (yylsp[(1) - (4)]), state, "GL_ARB_matrix_palette not supported");
           YYERROR;
@@ -3280,7 +3295,7 @@ yyreduce:
   case 112:
 
 /* Line 1455 of yacc.c  */
-#line 1156 "program_parse.y"
+#line 1171 "program_parse.y"
     {
           (yyval.attrib) = VERT_ATTRIB_GENERIC0 + (yyvsp[(3) - (4)].integer);
        ;}
@@ -3289,7 +3304,7 @@ yyreduce:
   case 113:
 
 /* Line 1455 of yacc.c  */
-#line 1162 "program_parse.y"
+#line 1177 "program_parse.y"
     {
           if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->limits->MaxAttribs) {
              yyerror(& (yylsp[(1) - (1)]), state, "invalid vertex attribute reference");
@@ -3303,7 +3318,7 @@ yyreduce:
   case 117:
 
 /* Line 1455 of yacc.c  */
-#line 1176 "program_parse.y"
+#line 1191 "program_parse.y"
     {
           (yyval.attrib) = FRAG_ATTRIB_WPOS;
        ;}
@@ -3312,7 +3327,7 @@ yyreduce:
   case 118:
 
 /* Line 1455 of yacc.c  */
-#line 1180 "program_parse.y"
+#line 1195 "program_parse.y"
     {
           (yyval.attrib) = FRAG_ATTRIB_COL0 + (yyvsp[(2) - (2)].integer);
        ;}
@@ -3321,7 +3336,7 @@ yyreduce:
   case 119:
 
 /* Line 1455 of yacc.c  */
-#line 1184 "program_parse.y"
+#line 1199 "program_parse.y"
     {
           (yyval.attrib) = FRAG_ATTRIB_FOGC;
        ;}
@@ -3330,7 +3345,7 @@ yyreduce:
   case 120:
 
 /* Line 1455 of yacc.c  */
-#line 1188 "program_parse.y"
+#line 1203 "program_parse.y"
     {
           (yyval.attrib) = FRAG_ATTRIB_TEX0 + (yyvsp[(2) - (2)].integer);
        ;}
@@ -3339,17 +3354,19 @@ yyreduce:
   case 123:
 
 /* Line 1455 of yacc.c  */
-#line 1196 "program_parse.y"
+#line 1211 "program_parse.y"
     {
           struct asm_symbol *const s =
              declare_variable(state, (yyvsp[(2) - (3)].string), at_param, & (yylsp[(2) - (3)]));
 
           if (s == NULL) {
+             free((yyvsp[(2) - (3)].string));
              YYERROR;
           } else {
              s->param_binding_type = (yyvsp[(3) - (3)].temp_sym).param_binding_type;
              s->param_binding_begin = (yyvsp[(3) - (3)].temp_sym).param_binding_begin;
              s->param_binding_length = (yyvsp[(3) - (3)].temp_sym).param_binding_length;
+              s->param_binding_swizzle = SWIZZLE_XYZW;
              s->param_is_array = 0;
           }
        ;}
@@ -3358,9 +3375,10 @@ yyreduce:
   case 124:
 
 /* Line 1455 of yacc.c  */
-#line 1212 "program_parse.y"
+#line 1229 "program_parse.y"
     {
           if (((yyvsp[(4) - (6)].integer) != 0) && ((unsigned) (yyvsp[(4) - (6)].integer) != (yyvsp[(6) - (6)].temp_sym).param_binding_length)) {
+             free((yyvsp[(2) - (6)].string));
              yyerror(& (yylsp[(4) - (6)]), state, 
                      "parameter array size and number of bindings must match");
              YYERROR;
@@ -3369,11 +3387,13 @@ yyreduce:
                 declare_variable(state, (yyvsp[(2) - (6)].string), (yyvsp[(6) - (6)].temp_sym).type, & (yylsp[(2) - (6)]));
 
              if (s == NULL) {
+                free((yyvsp[(2) - (6)].string));
                 YYERROR;
              } else {
                 s->param_binding_type = (yyvsp[(6) - (6)].temp_sym).param_binding_type;
                 s->param_binding_begin = (yyvsp[(6) - (6)].temp_sym).param_binding_begin;
                 s->param_binding_length = (yyvsp[(6) - (6)].temp_sym).param_binding_length;
+                 s->param_binding_swizzle = SWIZZLE_XYZW;
                 s->param_is_array = 1;
              }
           }
@@ -3383,7 +3403,7 @@ yyreduce:
   case 125:
 
 /* Line 1455 of yacc.c  */
-#line 1234 "program_parse.y"
+#line 1254 "program_parse.y"
     {
           (yyval.integer) = 0;
        ;}
@@ -3392,9 +3412,9 @@ yyreduce:
   case 126:
 
 /* Line 1455 of yacc.c  */
-#line 1238 "program_parse.y"
+#line 1258 "program_parse.y"
     {
-          if (((yyvsp[(1) - (1)].integer) < 1) || ((unsigned) (yyvsp[(1) - (1)].integer) >= state->limits->MaxParameters)) {
+          if (((yyvsp[(1) - (1)].integer) < 1) || ((unsigned) (yyvsp[(1) - (1)].integer) > state->limits->MaxParameters)) {
              yyerror(& (yylsp[(1) - (1)]), state, "invalid parameter array size");
              YYERROR;
           } else {
@@ -3406,7 +3426,7 @@ yyreduce:
   case 127:
 
 /* Line 1455 of yacc.c  */
-#line 1249 "program_parse.y"
+#line 1269 "program_parse.y"
     {
           (yyval.temp_sym) = (yyvsp[(2) - (2)].temp_sym);
        ;}
@@ -3415,7 +3435,7 @@ yyreduce:
   case 128:
 
 /* Line 1455 of yacc.c  */
-#line 1255 "program_parse.y"
+#line 1275 "program_parse.y"
     {
           (yyval.temp_sym) = (yyvsp[(3) - (4)].temp_sym);
        ;}
@@ -3424,7 +3444,7 @@ yyreduce:
   case 130:
 
 /* Line 1455 of yacc.c  */
-#line 1262 "program_parse.y"
+#line 1282 "program_parse.y"
     {
           (yyvsp[(1) - (3)].temp_sym).param_binding_length += (yyvsp[(3) - (3)].temp_sym).param_binding_length;
           (yyval.temp_sym) = (yyvsp[(1) - (3)].temp_sym);
@@ -3434,7 +3454,7 @@ yyreduce:
   case 131:
 
 /* Line 1455 of yacc.c  */
-#line 1269 "program_parse.y"
+#line 1289 "program_parse.y"
     {
           memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym)));
           (yyval.temp_sym).param_binding_begin = ~0;
@@ -3445,7 +3465,7 @@ yyreduce:
   case 132:
 
 /* Line 1455 of yacc.c  */
-#line 1275 "program_parse.y"
+#line 1295 "program_parse.y"
     {
           memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym)));
           (yyval.temp_sym).param_binding_begin = ~0;
@@ -3456,18 +3476,18 @@ yyreduce:
   case 133:
 
 /* Line 1455 of yacc.c  */
-#line 1281 "program_parse.y"
+#line 1301 "program_parse.y"
     {
           memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym)));
           (yyval.temp_sym).param_binding_begin = ~0;
-          initialize_symbol_from_const(state->prog, & (yyval.temp_sym), & (yyvsp[(1) - (1)].vector));
+          initialize_symbol_from_const(state->prog, & (yyval.temp_sym), & (yyvsp[(1) - (1)].vector), GL_TRUE);
        ;}
     break;
 
   case 134:
 
 /* Line 1455 of yacc.c  */
-#line 1289 "program_parse.y"
+#line 1309 "program_parse.y"
     {
           memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym)));
           (yyval.temp_sym).param_binding_begin = ~0;
@@ -3478,7 +3498,7 @@ yyreduce:
   case 135:
 
 /* Line 1455 of yacc.c  */
-#line 1295 "program_parse.y"
+#line 1315 "program_parse.y"
     {
           memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym)));
           (yyval.temp_sym).param_binding_begin = ~0;
@@ -3489,18 +3509,18 @@ yyreduce:
   case 136:
 
 /* Line 1455 of yacc.c  */
-#line 1301 "program_parse.y"
+#line 1321 "program_parse.y"
     {
           memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym)));
           (yyval.temp_sym).param_binding_begin = ~0;
-          initialize_symbol_from_const(state->prog, & (yyval.temp_sym), & (yyvsp[(1) - (1)].vector));
+          initialize_symbol_from_const(state->prog, & (yyval.temp_sym), & (yyvsp[(1) - (1)].vector), GL_TRUE);
        ;}
     break;
 
   case 137:
 
 /* Line 1455 of yacc.c  */
-#line 1309 "program_parse.y"
+#line 1329 "program_parse.y"
     {
           memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym)));
           (yyval.temp_sym).param_binding_begin = ~0;
@@ -3511,7 +3531,7 @@ yyreduce:
   case 138:
 
 /* Line 1455 of yacc.c  */
-#line 1315 "program_parse.y"
+#line 1335 "program_parse.y"
     {
           memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym)));
           (yyval.temp_sym).param_binding_begin = ~0;
@@ -3522,109 +3542,109 @@ yyreduce:
   case 139:
 
 /* Line 1455 of yacc.c  */
-#line 1321 "program_parse.y"
+#line 1341 "program_parse.y"
     {
           memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym)));
           (yyval.temp_sym).param_binding_begin = ~0;
-          initialize_symbol_from_const(state->prog, & (yyval.temp_sym), & (yyvsp[(1) - (1)].vector));
+          initialize_symbol_from_const(state->prog, & (yyval.temp_sym), & (yyvsp[(1) - (1)].vector), GL_FALSE);
        ;}
     break;
 
   case 140:
 
 /* Line 1455 of yacc.c  */
-#line 1328 "program_parse.y"
+#line 1348 "program_parse.y"
     { memcpy((yyval.state), (yyvsp[(1) - (1)].state), sizeof((yyval.state))); ;}
     break;
 
   case 141:
 
 /* Line 1455 of yacc.c  */
-#line 1329 "program_parse.y"
+#line 1349 "program_parse.y"
     { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;}
     break;
 
   case 142:
 
 /* Line 1455 of yacc.c  */
-#line 1332 "program_parse.y"
+#line 1352 "program_parse.y"
     { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;}
     break;
 
   case 143:
 
 /* Line 1455 of yacc.c  */
-#line 1333 "program_parse.y"
+#line 1353 "program_parse.y"
     { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;}
     break;
 
   case 144:
 
 /* Line 1455 of yacc.c  */
-#line 1334 "program_parse.y"
+#line 1354 "program_parse.y"
     { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;}
     break;
 
   case 145:
 
 /* Line 1455 of yacc.c  */
-#line 1335 "program_parse.y"
+#line 1355 "program_parse.y"
     { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;}
     break;
 
   case 146:
 
 /* Line 1455 of yacc.c  */
-#line 1336 "program_parse.y"
+#line 1356 "program_parse.y"
     { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;}
     break;
 
   case 147:
 
 /* Line 1455 of yacc.c  */
-#line 1337 "program_parse.y"
+#line 1357 "program_parse.y"
     { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;}
     break;
 
   case 148:
 
 /* Line 1455 of yacc.c  */
-#line 1338 "program_parse.y"
+#line 1358 "program_parse.y"
     { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;}
     break;
 
   case 149:
 
 /* Line 1455 of yacc.c  */
-#line 1339 "program_parse.y"
+#line 1359 "program_parse.y"
     { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;}
     break;
 
   case 150:
 
 /* Line 1455 of yacc.c  */
-#line 1340 "program_parse.y"
+#line 1360 "program_parse.y"
     { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;}
     break;
 
   case 151:
 
 /* Line 1455 of yacc.c  */
-#line 1341 "program_parse.y"
+#line 1361 "program_parse.y"
     { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;}
     break;
 
   case 152:
 
 /* Line 1455 of yacc.c  */
-#line 1342 "program_parse.y"
+#line 1362 "program_parse.y"
     { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;}
     break;
 
   case 153:
 
 /* Line 1455 of yacc.c  */
-#line 1346 "program_parse.y"
+#line 1366 "program_parse.y"
     {
           memset((yyval.state), 0, sizeof((yyval.state)));
           (yyval.state)[0] = STATE_MATERIAL;
@@ -3636,7 +3656,7 @@ yyreduce:
   case 154:
 
 /* Line 1455 of yacc.c  */
-#line 1355 "program_parse.y"
+#line 1375 "program_parse.y"
     {
           (yyval.integer) = (yyvsp[(1) - (1)].integer);
        ;}
@@ -3645,7 +3665,7 @@ yyreduce:
   case 155:
 
 /* Line 1455 of yacc.c  */
-#line 1359 "program_parse.y"
+#line 1379 "program_parse.y"
     {
           (yyval.integer) = STATE_EMISSION;
        ;}
@@ -3654,7 +3674,7 @@ yyreduce:
   case 156:
 
 /* Line 1455 of yacc.c  */
-#line 1363 "program_parse.y"
+#line 1383 "program_parse.y"
     {
           (yyval.integer) = STATE_SHININESS;
        ;}
@@ -3663,7 +3683,7 @@ yyreduce:
   case 157:
 
 /* Line 1455 of yacc.c  */
-#line 1369 "program_parse.y"
+#line 1389 "program_parse.y"
     {
           memset((yyval.state), 0, sizeof((yyval.state)));
           (yyval.state)[0] = STATE_LIGHT;
@@ -3675,7 +3695,7 @@ yyreduce:
   case 158:
 
 /* Line 1455 of yacc.c  */
-#line 1378 "program_parse.y"
+#line 1398 "program_parse.y"
     {
           (yyval.integer) = (yyvsp[(1) - (1)].integer);
        ;}
@@ -3684,7 +3704,7 @@ yyreduce:
   case 159:
 
 /* Line 1455 of yacc.c  */
-#line 1382 "program_parse.y"
+#line 1402 "program_parse.y"
     {
           (yyval.integer) = STATE_POSITION;
        ;}
@@ -3693,7 +3713,7 @@ yyreduce:
   case 160:
 
 /* Line 1455 of yacc.c  */
-#line 1386 "program_parse.y"
+#line 1406 "program_parse.y"
     {
           if (!state->ctx->Extensions.EXT_point_parameters) {
              yyerror(& (yylsp[(1) - (1)]), state, "GL_ARB_point_parameters not supported");
@@ -3707,7 +3727,7 @@ yyreduce:
   case 161:
 
 /* Line 1455 of yacc.c  */
-#line 1395 "program_parse.y"
+#line 1415 "program_parse.y"
     {
           (yyval.integer) = (yyvsp[(2) - (2)].integer);
        ;}
@@ -3716,7 +3736,7 @@ yyreduce:
   case 162:
 
 /* Line 1455 of yacc.c  */
-#line 1399 "program_parse.y"
+#line 1419 "program_parse.y"
     {
           (yyval.integer) = STATE_HALF_VECTOR;
        ;}
@@ -3725,7 +3745,7 @@ yyreduce:
   case 163:
 
 /* Line 1455 of yacc.c  */
-#line 1405 "program_parse.y"
+#line 1425 "program_parse.y"
     {
           (yyval.integer) = STATE_SPOT_DIRECTION;
        ;}
@@ -3734,7 +3754,7 @@ yyreduce:
   case 164:
 
 /* Line 1455 of yacc.c  */
-#line 1411 "program_parse.y"
+#line 1431 "program_parse.y"
     {
           (yyval.state)[0] = (yyvsp[(2) - (2)].state)[0];
           (yyval.state)[1] = (yyvsp[(2) - (2)].state)[1];
@@ -3744,7 +3764,7 @@ yyreduce:
   case 165:
 
 /* Line 1455 of yacc.c  */
-#line 1418 "program_parse.y"
+#line 1438 "program_parse.y"
     {
           memset((yyval.state), 0, sizeof((yyval.state)));
           (yyval.state)[0] = STATE_LIGHTMODEL_AMBIENT;
@@ -3754,7 +3774,7 @@ yyreduce:
   case 166:
 
 /* Line 1455 of yacc.c  */
-#line 1423 "program_parse.y"
+#line 1443 "program_parse.y"
     {
           memset((yyval.state), 0, sizeof((yyval.state)));
           (yyval.state)[0] = STATE_LIGHTMODEL_SCENECOLOR;
@@ -3765,7 +3785,7 @@ yyreduce:
   case 167:
 
 /* Line 1455 of yacc.c  */
-#line 1431 "program_parse.y"
+#line 1451 "program_parse.y"
     {
           memset((yyval.state), 0, sizeof((yyval.state)));
           (yyval.state)[0] = STATE_LIGHTPROD;
@@ -3778,7 +3798,7 @@ yyreduce:
   case 169:
 
 /* Line 1455 of yacc.c  */
-#line 1443 "program_parse.y"
+#line 1463 "program_parse.y"
     {
           memset((yyval.state), 0, sizeof((yyval.state)));
           (yyval.state)[0] = (yyvsp[(3) - (3)].integer);
@@ -3789,7 +3809,7 @@ yyreduce:
   case 170:
 
 /* Line 1455 of yacc.c  */
-#line 1451 "program_parse.y"
+#line 1471 "program_parse.y"
     {
           (yyval.integer) = STATE_TEXENV_COLOR;
        ;}
@@ -3798,7 +3818,7 @@ yyreduce:
   case 171:
 
 /* Line 1455 of yacc.c  */
-#line 1457 "program_parse.y"
+#line 1477 "program_parse.y"
     {
           (yyval.integer) = STATE_AMBIENT;
        ;}
@@ -3807,7 +3827,7 @@ yyreduce:
   case 172:
 
 /* Line 1455 of yacc.c  */
-#line 1461 "program_parse.y"
+#line 1481 "program_parse.y"
     {
           (yyval.integer) = STATE_DIFFUSE;
        ;}
@@ -3816,7 +3836,7 @@ yyreduce:
   case 173:
 
 /* Line 1455 of yacc.c  */
-#line 1465 "program_parse.y"
+#line 1485 "program_parse.y"
     {
           (yyval.integer) = STATE_SPECULAR;
        ;}
@@ -3825,7 +3845,7 @@ yyreduce:
   case 174:
 
 /* Line 1455 of yacc.c  */
-#line 1471 "program_parse.y"
+#line 1491 "program_parse.y"
     {
           if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->MaxLights) {
              yyerror(& (yylsp[(1) - (1)]), state, "invalid light selector");
@@ -3839,7 +3859,7 @@ yyreduce:
   case 175:
 
 /* Line 1455 of yacc.c  */
-#line 1482 "program_parse.y"
+#line 1502 "program_parse.y"
     {
           memset((yyval.state), 0, sizeof((yyval.state)));
           (yyval.state)[0] = STATE_TEXGEN;
@@ -3851,7 +3871,7 @@ yyreduce:
   case 176:
 
 /* Line 1455 of yacc.c  */
-#line 1491 "program_parse.y"
+#line 1511 "program_parse.y"
     {
           (yyval.integer) = STATE_TEXGEN_EYE_S;
        ;}
@@ -3860,7 +3880,7 @@ yyreduce:
   case 177:
 
 /* Line 1455 of yacc.c  */
-#line 1495 "program_parse.y"
+#line 1515 "program_parse.y"
     {
           (yyval.integer) = STATE_TEXGEN_OBJECT_S;
        ;}
@@ -3869,7 +3889,7 @@ yyreduce:
   case 178:
 
 /* Line 1455 of yacc.c  */
-#line 1500 "program_parse.y"
+#line 1520 "program_parse.y"
     {
           (yyval.integer) = STATE_TEXGEN_EYE_S - STATE_TEXGEN_EYE_S;
        ;}
@@ -3878,7 +3898,7 @@ yyreduce:
   case 179:
 
 /* Line 1455 of yacc.c  */
-#line 1504 "program_parse.y"
+#line 1524 "program_parse.y"
     {
           (yyval.integer) = STATE_TEXGEN_EYE_T - STATE_TEXGEN_EYE_S;
        ;}
@@ -3887,7 +3907,7 @@ yyreduce:
   case 180:
 
 /* Line 1455 of yacc.c  */
-#line 1508 "program_parse.y"
+#line 1528 "program_parse.y"
     {
           (yyval.integer) = STATE_TEXGEN_EYE_R - STATE_TEXGEN_EYE_S;
        ;}
@@ -3896,7 +3916,7 @@ yyreduce:
   case 181:
 
 /* Line 1455 of yacc.c  */
-#line 1512 "program_parse.y"
+#line 1532 "program_parse.y"
     {
           (yyval.integer) = STATE_TEXGEN_EYE_Q - STATE_TEXGEN_EYE_S;
        ;}
@@ -3905,7 +3925,7 @@ yyreduce:
   case 182:
 
 /* Line 1455 of yacc.c  */
-#line 1518 "program_parse.y"
+#line 1538 "program_parse.y"
     {
           memset((yyval.state), 0, sizeof((yyval.state)));
           (yyval.state)[0] = (yyvsp[(2) - (2)].integer);
@@ -3915,7 +3935,7 @@ yyreduce:
   case 183:
 
 /* Line 1455 of yacc.c  */
-#line 1525 "program_parse.y"
+#line 1545 "program_parse.y"
     {
           (yyval.integer) = STATE_FOG_COLOR;
        ;}
@@ -3924,7 +3944,7 @@ yyreduce:
   case 184:
 
 /* Line 1455 of yacc.c  */
-#line 1529 "program_parse.y"
+#line 1549 "program_parse.y"
     {
           (yyval.integer) = STATE_FOG_PARAMS;
        ;}
@@ -3933,7 +3953,7 @@ yyreduce:
   case 185:
 
 /* Line 1455 of yacc.c  */
-#line 1535 "program_parse.y"
+#line 1555 "program_parse.y"
     {
           memset((yyval.state), 0, sizeof((yyval.state)));
           (yyval.state)[0] = STATE_CLIPPLANE;
@@ -3944,7 +3964,7 @@ yyreduce:
   case 186:
 
 /* Line 1455 of yacc.c  */
-#line 1543 "program_parse.y"
+#line 1563 "program_parse.y"
     {
           if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->MaxClipPlanes) {
              yyerror(& (yylsp[(1) - (1)]), state, "invalid clip plane selector");
@@ -3958,7 +3978,7 @@ yyreduce:
   case 187:
 
 /* Line 1455 of yacc.c  */
-#line 1554 "program_parse.y"
+#line 1574 "program_parse.y"
     {
           memset((yyval.state), 0, sizeof((yyval.state)));
           (yyval.state)[0] = (yyvsp[(2) - (2)].integer);
@@ -3968,7 +3988,7 @@ yyreduce:
   case 188:
 
 /* Line 1455 of yacc.c  */
-#line 1561 "program_parse.y"
+#line 1581 "program_parse.y"
     {
           (yyval.integer) = STATE_POINT_SIZE;
        ;}
@@ -3977,7 +3997,7 @@ yyreduce:
   case 189:
 
 /* Line 1455 of yacc.c  */
-#line 1565 "program_parse.y"
+#line 1585 "program_parse.y"
     {
           (yyval.integer) = STATE_POINT_ATTENUATION;
        ;}
@@ -3986,7 +4006,7 @@ yyreduce:
   case 190:
 
 /* Line 1455 of yacc.c  */
-#line 1571 "program_parse.y"
+#line 1591 "program_parse.y"
     {
           (yyval.state)[0] = (yyvsp[(1) - (5)].state)[0];
           (yyval.state)[1] = (yyvsp[(1) - (5)].state)[1];
@@ -3999,7 +4019,7 @@ yyreduce:
   case 191:
 
 /* Line 1455 of yacc.c  */
-#line 1581 "program_parse.y"
+#line 1601 "program_parse.y"
     {
           (yyval.state)[0] = (yyvsp[(1) - (2)].state)[0];
           (yyval.state)[1] = (yyvsp[(1) - (2)].state)[1];
@@ -4012,7 +4032,7 @@ yyreduce:
   case 192:
 
 /* Line 1455 of yacc.c  */
-#line 1591 "program_parse.y"
+#line 1611 "program_parse.y"
     {
           (yyval.state)[2] = 0;
           (yyval.state)[3] = 3;
@@ -4022,7 +4042,7 @@ yyreduce:
   case 193:
 
 /* Line 1455 of yacc.c  */
-#line 1596 "program_parse.y"
+#line 1616 "program_parse.y"
     {
           /* It seems logical that the matrix row range specifier would have
            * to specify a range or more than one row (i.e., $5 > $3).
@@ -4043,7 +4063,7 @@ yyreduce:
   case 194:
 
 /* Line 1455 of yacc.c  */
-#line 1614 "program_parse.y"
+#line 1634 "program_parse.y"
     {
           (yyval.state)[0] = (yyvsp[(2) - (3)].state)[0];
           (yyval.state)[1] = (yyvsp[(2) - (3)].state)[1];
@@ -4054,7 +4074,7 @@ yyreduce:
   case 195:
 
 /* Line 1455 of yacc.c  */
-#line 1622 "program_parse.y"
+#line 1642 "program_parse.y"
     {
           (yyval.integer) = 0;
        ;}
@@ -4063,7 +4083,7 @@ yyreduce:
   case 196:
 
 /* Line 1455 of yacc.c  */
-#line 1626 "program_parse.y"
+#line 1646 "program_parse.y"
     {
           (yyval.integer) = (yyvsp[(1) - (1)].integer);
        ;}
@@ -4072,7 +4092,7 @@ yyreduce:
   case 197:
 
 /* Line 1455 of yacc.c  */
-#line 1632 "program_parse.y"
+#line 1652 "program_parse.y"
     {
           (yyval.integer) = STATE_MATRIX_INVERSE;
        ;}
@@ -4081,7 +4101,7 @@ yyreduce:
   case 198:
 
 /* Line 1455 of yacc.c  */
-#line 1636 "program_parse.y"
+#line 1656 "program_parse.y"
     {
           (yyval.integer) = STATE_MATRIX_TRANSPOSE;
        ;}
@@ -4090,7 +4110,7 @@ yyreduce:
   case 199:
 
 /* Line 1455 of yacc.c  */
-#line 1640 "program_parse.y"
+#line 1660 "program_parse.y"
     {
           (yyval.integer) = STATE_MATRIX_INVTRANS;
        ;}
@@ -4099,7 +4119,7 @@ yyreduce:
   case 200:
 
 /* Line 1455 of yacc.c  */
-#line 1646 "program_parse.y"
+#line 1666 "program_parse.y"
     {
           if ((yyvsp[(1) - (1)].integer) > 3) {
              yyerror(& (yylsp[(1) - (1)]), state, "invalid matrix row reference");
@@ -4113,7 +4133,7 @@ yyreduce:
   case 201:
 
 /* Line 1455 of yacc.c  */
-#line 1657 "program_parse.y"
+#line 1677 "program_parse.y"
     {
           (yyval.state)[0] = STATE_MODELVIEW_MATRIX;
           (yyval.state)[1] = (yyvsp[(2) - (2)].integer);
@@ -4123,7 +4143,7 @@ yyreduce:
   case 202:
 
 /* Line 1455 of yacc.c  */
-#line 1662 "program_parse.y"
+#line 1682 "program_parse.y"
     {
           (yyval.state)[0] = STATE_PROJECTION_MATRIX;
           (yyval.state)[1] = 0;
@@ -4133,7 +4153,7 @@ yyreduce:
   case 203:
 
 /* Line 1455 of yacc.c  */
-#line 1667 "program_parse.y"
+#line 1687 "program_parse.y"
     {
           (yyval.state)[0] = STATE_MVP_MATRIX;
           (yyval.state)[1] = 0;
@@ -4143,7 +4163,7 @@ yyreduce:
   case 204:
 
 /* Line 1455 of yacc.c  */
-#line 1672 "program_parse.y"
+#line 1692 "program_parse.y"
     {
           (yyval.state)[0] = STATE_TEXTURE_MATRIX;
           (yyval.state)[1] = (yyvsp[(2) - (2)].integer);
@@ -4153,7 +4173,7 @@ yyreduce:
   case 205:
 
 /* Line 1455 of yacc.c  */
-#line 1677 "program_parse.y"
+#line 1697 "program_parse.y"
     {
           yyerror(& (yylsp[(1) - (4)]), state, "GL_ARB_matrix_palette not supported");
           YYERROR;
@@ -4163,7 +4183,7 @@ yyreduce:
   case 206:
 
 /* Line 1455 of yacc.c  */
-#line 1682 "program_parse.y"
+#line 1702 "program_parse.y"
     {
           (yyval.state)[0] = STATE_PROGRAM_MATRIX;
           (yyval.state)[1] = (yyvsp[(3) - (4)].integer);
@@ -4173,7 +4193,7 @@ yyreduce:
   case 207:
 
 /* Line 1455 of yacc.c  */
-#line 1689 "program_parse.y"
+#line 1709 "program_parse.y"
     {
           (yyval.integer) = 0;
        ;}
@@ -4182,7 +4202,7 @@ yyreduce:
   case 208:
 
 /* Line 1455 of yacc.c  */
-#line 1693 "program_parse.y"
+#line 1713 "program_parse.y"
     {
           (yyval.integer) = (yyvsp[(2) - (3)].integer);
        ;}
@@ -4191,7 +4211,7 @@ yyreduce:
   case 209:
 
 /* Line 1455 of yacc.c  */
-#line 1698 "program_parse.y"
+#line 1718 "program_parse.y"
     {
           /* Since GL_ARB_vertex_blend isn't supported, only modelview matrix
            * zero is valid.
@@ -4208,7 +4228,7 @@ yyreduce:
   case 210:
 
 /* Line 1455 of yacc.c  */
-#line 1711 "program_parse.y"
+#line 1731 "program_parse.y"
     {
           /* Since GL_ARB_matrix_palette isn't supported, just let any value
            * through here.  The error will be generated later.
@@ -4220,7 +4240,7 @@ yyreduce:
   case 211:
 
 /* Line 1455 of yacc.c  */
-#line 1719 "program_parse.y"
+#line 1739 "program_parse.y"
     {
           if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->MaxProgramMatrices) {
              yyerror(& (yylsp[(1) - (1)]), state, "invalid program matrix selector");
@@ -4234,7 +4254,7 @@ yyreduce:
   case 212:
 
 /* Line 1455 of yacc.c  */
-#line 1730 "program_parse.y"
+#line 1750 "program_parse.y"
     {
           memset((yyval.state), 0, sizeof((yyval.state)));
           (yyval.state)[0] = STATE_DEPTH_RANGE;
@@ -4244,7 +4264,7 @@ yyreduce:
   case 217:
 
 /* Line 1455 of yacc.c  */
-#line 1742 "program_parse.y"
+#line 1762 "program_parse.y"
     {
           memset((yyval.state), 0, sizeof((yyval.state)));
           (yyval.state)[0] = state->state_param_enum;
@@ -4257,7 +4277,7 @@ yyreduce:
   case 218:
 
 /* Line 1455 of yacc.c  */
-#line 1752 "program_parse.y"
+#line 1772 "program_parse.y"
     {
           (yyval.state)[0] = (yyvsp[(1) - (1)].integer);
           (yyval.state)[1] = (yyvsp[(1) - (1)].integer);
@@ -4267,7 +4287,7 @@ yyreduce:
   case 219:
 
 /* Line 1455 of yacc.c  */
-#line 1757 "program_parse.y"
+#line 1777 "program_parse.y"
     {
           (yyval.state)[0] = (yyvsp[(1) - (3)].integer);
           (yyval.state)[1] = (yyvsp[(3) - (3)].integer);
@@ -4277,7 +4297,7 @@ yyreduce:
   case 220:
 
 /* Line 1455 of yacc.c  */
-#line 1764 "program_parse.y"
+#line 1784 "program_parse.y"
     {
           memset((yyval.state), 0, sizeof((yyval.state)));
           (yyval.state)[0] = state->state_param_enum;
@@ -4290,7 +4310,7 @@ yyreduce:
   case 221:
 
 /* Line 1455 of yacc.c  */
-#line 1774 "program_parse.y"
+#line 1794 "program_parse.y"
     {
           memset((yyval.state), 0, sizeof((yyval.state)));
           (yyval.state)[0] = state->state_param_enum;
@@ -4303,7 +4323,7 @@ yyreduce:
   case 222:
 
 /* Line 1455 of yacc.c  */
-#line 1783 "program_parse.y"
+#line 1803 "program_parse.y"
     {
           (yyval.state)[0] = (yyvsp[(1) - (1)].integer);
           (yyval.state)[1] = (yyvsp[(1) - (1)].integer);
@@ -4313,7 +4333,7 @@ yyreduce:
   case 223:
 
 /* Line 1455 of yacc.c  */
-#line 1788 "program_parse.y"
+#line 1808 "program_parse.y"
     {
           (yyval.state)[0] = (yyvsp[(1) - (3)].integer);
           (yyval.state)[1] = (yyvsp[(3) - (3)].integer);
@@ -4323,7 +4343,7 @@ yyreduce:
   case 224:
 
 /* Line 1455 of yacc.c  */
-#line 1795 "program_parse.y"
+#line 1815 "program_parse.y"
     {
           memset((yyval.state), 0, sizeof((yyval.state)));
           (yyval.state)[0] = state->state_param_enum;
@@ -4336,7 +4356,7 @@ yyreduce:
   case 225:
 
 /* Line 1455 of yacc.c  */
-#line 1805 "program_parse.y"
+#line 1825 "program_parse.y"
     {
           if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->limits->MaxEnvParams) {
              yyerror(& (yylsp[(1) - (1)]), state, "invalid environment parameter reference");
@@ -4349,7 +4369,7 @@ yyreduce:
   case 226:
 
 /* Line 1455 of yacc.c  */
-#line 1815 "program_parse.y"
+#line 1835 "program_parse.y"
     {
           if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->limits->MaxLocalParams) {
              yyerror(& (yylsp[(1) - (1)]), state, "invalid local parameter reference");
@@ -4362,7 +4382,7 @@ yyreduce:
   case 231:
 
 /* Line 1455 of yacc.c  */
-#line 1830 "program_parse.y"
+#line 1850 "program_parse.y"
     {
           (yyval.vector).count = 4;
           (yyval.vector).data[0] = (yyvsp[(1) - (1)].real);
@@ -4375,7 +4395,7 @@ yyreduce:
   case 232:
 
 /* Line 1455 of yacc.c  */
-#line 1840 "program_parse.y"
+#line 1860 "program_parse.y"
     {
           (yyval.vector).count = 1;
           (yyval.vector).data[0] = (yyvsp[(1) - (1)].real);
@@ -4388,7 +4408,7 @@ yyreduce:
   case 233:
 
 /* Line 1455 of yacc.c  */
-#line 1848 "program_parse.y"
+#line 1868 "program_parse.y"
     {
           (yyval.vector).count = 1;
           (yyval.vector).data[0] = (float) (yyvsp[(1) - (1)].integer);
@@ -4401,7 +4421,7 @@ yyreduce:
   case 234:
 
 /* Line 1455 of yacc.c  */
-#line 1858 "program_parse.y"
+#line 1878 "program_parse.y"
     {
           (yyval.vector).count = 4;
           (yyval.vector).data[0] = (yyvsp[(2) - (3)].real);
@@ -4414,7 +4434,7 @@ yyreduce:
   case 235:
 
 /* Line 1455 of yacc.c  */
-#line 1866 "program_parse.y"
+#line 1886 "program_parse.y"
     {
           (yyval.vector).count = 4;
           (yyval.vector).data[0] = (yyvsp[(2) - (5)].real);
@@ -4427,7 +4447,7 @@ yyreduce:
   case 236:
 
 /* Line 1455 of yacc.c  */
-#line 1875 "program_parse.y"
+#line 1895 "program_parse.y"
     {
           (yyval.vector).count = 4;
           (yyval.vector).data[0] = (yyvsp[(2) - (7)].real);
@@ -4440,7 +4460,7 @@ yyreduce:
   case 237:
 
 /* Line 1455 of yacc.c  */
-#line 1884 "program_parse.y"
+#line 1904 "program_parse.y"
     {
           (yyval.vector).count = 4;
           (yyval.vector).data[0] = (yyvsp[(2) - (9)].real);
@@ -4453,7 +4473,7 @@ yyreduce:
   case 238:
 
 /* Line 1455 of yacc.c  */
-#line 1894 "program_parse.y"
+#line 1914 "program_parse.y"
     {
           (yyval.real) = ((yyvsp[(1) - (2)].negate)) ? -(yyvsp[(2) - (2)].real) : (yyvsp[(2) - (2)].real);
        ;}
@@ -4462,7 +4482,7 @@ yyreduce:
   case 239:
 
 /* Line 1455 of yacc.c  */
-#line 1898 "program_parse.y"
+#line 1918 "program_parse.y"
     {
           (yyval.real) = (float)(((yyvsp[(1) - (2)].negate)) ? -(yyvsp[(2) - (2)].integer) : (yyvsp[(2) - (2)].integer));
        ;}
@@ -4471,35 +4491,35 @@ yyreduce:
   case 240:
 
 /* Line 1455 of yacc.c  */
-#line 1903 "program_parse.y"
+#line 1923 "program_parse.y"
     { (yyval.negate) = FALSE; ;}
     break;
 
   case 241:
 
 /* Line 1455 of yacc.c  */
-#line 1904 "program_parse.y"
+#line 1924 "program_parse.y"
     { (yyval.negate) = TRUE;  ;}
     break;
 
   case 242:
 
 /* Line 1455 of yacc.c  */
-#line 1905 "program_parse.y"
+#line 1925 "program_parse.y"
     { (yyval.negate) = FALSE; ;}
     break;
 
   case 243:
 
 /* Line 1455 of yacc.c  */
-#line 1908 "program_parse.y"
+#line 1928 "program_parse.y"
     { (yyval.integer) = (yyvsp[(2) - (2)].integer); ;}
     break;
 
   case 245:
 
 /* Line 1455 of yacc.c  */
-#line 1912 "program_parse.y"
+#line 1932 "program_parse.y"
     {
           /* NV_fragment_program_option defines the size qualifiers in a
            * fairly broken way.  "SHORT" or "LONG" can optionally be used
@@ -4538,7 +4558,7 @@ yyreduce:
   case 246:
 
 /* Line 1455 of yacc.c  */
-#line 1946 "program_parse.y"
+#line 1966 "program_parse.y"
     {
        ;}
     break;
@@ -4546,16 +4566,17 @@ yyreduce:
   case 247:
 
 /* Line 1455 of yacc.c  */
-#line 1950 "program_parse.y"
+#line 1970 "program_parse.y"
     { (yyval.integer) = (yyvsp[(1) - (1)].integer); ;}
     break;
 
   case 249:
 
 /* Line 1455 of yacc.c  */
-#line 1954 "program_parse.y"
+#line 1974 "program_parse.y"
     {
           if (!declare_variable(state, (yyvsp[(3) - (3)].string), (yyvsp[(0) - (3)].integer), & (yylsp[(3) - (3)]))) {
+             free((yyvsp[(3) - (3)].string));
              YYERROR;
           }
        ;}
@@ -4564,9 +4585,10 @@ yyreduce:
   case 250:
 
 /* Line 1455 of yacc.c  */
-#line 1960 "program_parse.y"
+#line 1981 "program_parse.y"
     {
           if (!declare_variable(state, (yyvsp[(1) - (1)].string), (yyvsp[(0) - (1)].integer), & (yylsp[(1) - (1)]))) {
+             free((yyvsp[(1) - (1)].string));
              YYERROR;
           }
        ;}
@@ -4575,12 +4597,13 @@ yyreduce:
   case 251:
 
 /* Line 1455 of yacc.c  */
-#line 1968 "program_parse.y"
+#line 1990 "program_parse.y"
     {
           struct asm_symbol *const s =
              declare_variable(state, (yyvsp[(3) - (5)].string), at_output, & (yylsp[(3) - (5)]));
 
           if (s == NULL) {
+             free((yyvsp[(3) - (5)].string));
              YYERROR;
           } else {
              s->output_binding = (yyvsp[(5) - (5)].result);
@@ -4591,7 +4614,7 @@ yyreduce:
   case 252:
 
 /* Line 1455 of yacc.c  */
-#line 1981 "program_parse.y"
+#line 2004 "program_parse.y"
     {
           if (state->mode == ARB_vertex) {
              (yyval.result) = VERT_RESULT_HPOS;
@@ -4605,7 +4628,7 @@ yyreduce:
   case 253:
 
 /* Line 1455 of yacc.c  */
-#line 1990 "program_parse.y"
+#line 2013 "program_parse.y"
     {
           if (state->mode == ARB_vertex) {
              (yyval.result) = VERT_RESULT_FOGC;
@@ -4619,7 +4642,7 @@ yyreduce:
   case 254:
 
 /* Line 1455 of yacc.c  */
-#line 1999 "program_parse.y"
+#line 2022 "program_parse.y"
     {
           (yyval.result) = (yyvsp[(2) - (2)].result);
        ;}
@@ -4628,7 +4651,7 @@ yyreduce:
   case 255:
 
 /* Line 1455 of yacc.c  */
-#line 2003 "program_parse.y"
+#line 2026 "program_parse.y"
     {
           if (state->mode == ARB_vertex) {
              (yyval.result) = VERT_RESULT_PSIZ;
@@ -4642,7 +4665,7 @@ yyreduce:
   case 256:
 
 /* Line 1455 of yacc.c  */
-#line 2012 "program_parse.y"
+#line 2035 "program_parse.y"
     {
           if (state->mode == ARB_vertex) {
              (yyval.result) = VERT_RESULT_TEX0 + (yyvsp[(3) - (3)].integer);
@@ -4656,7 +4679,7 @@ yyreduce:
   case 257:
 
 /* Line 1455 of yacc.c  */
-#line 2021 "program_parse.y"
+#line 2044 "program_parse.y"
     {
           if (state->mode == ARB_fragment) {
              (yyval.result) = FRAG_RESULT_DEPTH;
@@ -4670,7 +4693,7 @@ yyreduce:
   case 258:
 
 /* Line 1455 of yacc.c  */
-#line 2032 "program_parse.y"
+#line 2055 "program_parse.y"
     {
           (yyval.result) = (yyvsp[(2) - (3)].integer) + (yyvsp[(3) - (3)].integer);
        ;}
@@ -4679,7 +4702,7 @@ yyreduce:
   case 259:
 
 /* Line 1455 of yacc.c  */
-#line 2038 "program_parse.y"
+#line 2061 "program_parse.y"
     {
           (yyval.integer) = (state->mode == ARB_vertex)
              ? VERT_RESULT_COL0
@@ -4690,7 +4713,7 @@ yyreduce:
   case 260:
 
 /* Line 1455 of yacc.c  */
-#line 2044 "program_parse.y"
+#line 2067 "program_parse.y"
     {
           if (state->mode == ARB_vertex) {
              (yyval.integer) = VERT_RESULT_COL0;
@@ -4704,7 +4727,7 @@ yyreduce:
   case 261:
 
 /* Line 1455 of yacc.c  */
-#line 2053 "program_parse.y"
+#line 2076 "program_parse.y"
     {
           if (state->mode == ARB_vertex) {
              (yyval.integer) = VERT_RESULT_BFC0;
@@ -4718,7 +4741,7 @@ yyreduce:
   case 262:
 
 /* Line 1455 of yacc.c  */
-#line 2064 "program_parse.y"
+#line 2087 "program_parse.y"
     {
           (yyval.integer) = 0; 
        ;}
@@ -4727,7 +4750,7 @@ yyreduce:
   case 263:
 
 /* Line 1455 of yacc.c  */
-#line 2068 "program_parse.y"
+#line 2091 "program_parse.y"
     {
           if (state->mode == ARB_vertex) {
              (yyval.integer) = 0;
@@ -4741,7 +4764,7 @@ yyreduce:
   case 264:
 
 /* Line 1455 of yacc.c  */
-#line 2077 "program_parse.y"
+#line 2100 "program_parse.y"
     {
           if (state->mode == ARB_vertex) {
              (yyval.integer) = 1;
@@ -4755,91 +4778,91 @@ yyreduce:
   case 265:
 
 /* Line 1455 of yacc.c  */
-#line 2087 "program_parse.y"
+#line 2110 "program_parse.y"
     { (yyval.integer) = 0; ;}
     break;
 
   case 266:
 
 /* Line 1455 of yacc.c  */
-#line 2088 "program_parse.y"
+#line 2111 "program_parse.y"
     { (yyval.integer) = 0; ;}
     break;
 
   case 267:
 
 /* Line 1455 of yacc.c  */
-#line 2089 "program_parse.y"
+#line 2112 "program_parse.y"
     { (yyval.integer) = 1; ;}
     break;
 
   case 268:
 
 /* Line 1455 of yacc.c  */
-#line 2092 "program_parse.y"
+#line 2115 "program_parse.y"
     { (yyval.integer) = 0; ;}
     break;
 
   case 269:
 
 /* Line 1455 of yacc.c  */
-#line 2093 "program_parse.y"
+#line 2116 "program_parse.y"
     { (yyval.integer) = 0; ;}
     break;
 
   case 270:
 
 /* Line 1455 of yacc.c  */
-#line 2094 "program_parse.y"
+#line 2117 "program_parse.y"
     { (yyval.integer) = 1; ;}
     break;
 
   case 271:
 
 /* Line 1455 of yacc.c  */
-#line 2097 "program_parse.y"
+#line 2120 "program_parse.y"
     { (yyval.integer) = 0; ;}
     break;
 
   case 272:
 
 /* Line 1455 of yacc.c  */
-#line 2098 "program_parse.y"
+#line 2121 "program_parse.y"
     { (yyval.integer) = (yyvsp[(2) - (3)].integer); ;}
     break;
 
   case 273:
 
 /* Line 1455 of yacc.c  */
-#line 2101 "program_parse.y"
+#line 2124 "program_parse.y"
     { (yyval.integer) = 0; ;}
     break;
 
   case 274:
 
 /* Line 1455 of yacc.c  */
-#line 2102 "program_parse.y"
+#line 2125 "program_parse.y"
     { (yyval.integer) = (yyvsp[(2) - (3)].integer); ;}
     break;
 
   case 275:
 
 /* Line 1455 of yacc.c  */
-#line 2105 "program_parse.y"
+#line 2128 "program_parse.y"
     { (yyval.integer) = 0; ;}
     break;
 
   case 276:
 
 /* Line 1455 of yacc.c  */
-#line 2106 "program_parse.y"
+#line 2129 "program_parse.y"
     { (yyval.integer) = (yyvsp[(2) - (3)].integer); ;}
     break;
 
   case 277:
 
 /* Line 1455 of yacc.c  */
-#line 2110 "program_parse.y"
+#line 2133 "program_parse.y"
     {
           if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->MaxTextureCoordUnits) {
              yyerror(& (yylsp[(1) - (1)]), state, "invalid texture coordinate unit selector");
@@ -4853,7 +4876,7 @@ yyreduce:
   case 278:
 
 /* Line 1455 of yacc.c  */
-#line 2121 "program_parse.y"
+#line 2144 "program_parse.y"
     {
           if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->MaxTextureImageUnits) {
              yyerror(& (yylsp[(1) - (1)]), state, "invalid texture image unit selector");
@@ -4867,7 +4890,7 @@ yyreduce:
   case 279:
 
 /* Line 1455 of yacc.c  */
-#line 2132 "program_parse.y"
+#line 2155 "program_parse.y"
     {
           if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->MaxTextureUnits) {
              yyerror(& (yylsp[(1) - (1)]), state, "invalid texture unit selector");
@@ -4881,18 +4904,23 @@ yyreduce:
   case 280:
 
 /* Line 1455 of yacc.c  */
-#line 2143 "program_parse.y"
+#line 2166 "program_parse.y"
     {
           struct asm_symbol *exist = (struct asm_symbol *)
              _mesa_symbol_table_find_symbol(state->st, 0, (yyvsp[(2) - (4)].string));
           struct asm_symbol *target = (struct asm_symbol *)
              _mesa_symbol_table_find_symbol(state->st, 0, (yyvsp[(4) - (4)].string));
 
+          free((yyvsp[(4) - (4)].string));
 
           if (exist != NULL) {
-             yyerror(& (yylsp[(2) - (4)]), state, "redeclared identifier");
+             char m[1000];
+             _mesa_snprintf(m, sizeof(m), "redeclared identifier: %s", (yyvsp[(2) - (4)].string));
+             free((yyvsp[(2) - (4)].string));
+             yyerror(& (yylsp[(2) - (4)]), state, m);
              YYERROR;
           } else if (target == NULL) {
+             free((yyvsp[(2) - (4)].string));
              yyerror(& (yylsp[(4) - (4)]), state,
                      "undefined variable binding in ALIAS statement");
              YYERROR;
@@ -4905,7 +4933,7 @@ yyreduce:
 
 
 /* Line 1455 of yacc.c  */
-#line 4909 "program_parse.tab.c"
+#line 4937 "program_parse.tab.c"
       default: break;
     }
   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -5124,7 +5152,7 @@ yyreturn:
 
 
 /* Line 1675 of yacc.c  */
-#line 2167 "program_parse.y"
+#line 2195 "program_parse.y"
 
 
 void
@@ -5224,6 +5252,28 @@ init_dst_reg(struct prog_dst_register *r)
 }
 
 
+/** Like init_dst_reg() but set the File and Index fields. */
+void
+set_dst_reg(struct prog_dst_register *r, gl_register_file file, GLint index)
+{
+   const GLint maxIndex = 1 << INST_INDEX_BITS;
+   const GLint minIndex = 0;
+   ASSERT(index >= minIndex);
+   (void) minIndex;
+   ASSERT(index <= maxIndex);
+   (void) maxIndex;
+   ASSERT(file == PROGRAM_TEMPORARY ||
+         file == PROGRAM_ADDRESS ||
+         file == PROGRAM_OUTPUT);
+   memset(r, 0, sizeof(*r));
+   r->File = file;
+   r->Index = index;
+   r->WriteMask = WRITEMASK_XYZW;
+   r->CondMask = COND_TR;
+   r->CondSwizzle = SWIZZLE_NOOP;
+}
+
+
 void
 init_src_reg(struct asm_src_register *r)
 {
@@ -5234,6 +5284,35 @@ init_src_reg(struct asm_src_register *r)
 }
 
 
+/** Like init_src_reg() but set the File and Index fields.
+ * \return GL_TRUE if a valid src register, GL_FALSE otherwise
+ */
+void
+set_src_reg(struct asm_src_register *r, gl_register_file file, GLint index)
+{
+   set_src_reg_swz(r, file, index, SWIZZLE_XYZW);
+}
+
+
+void
+set_src_reg_swz(struct asm_src_register *r, gl_register_file file, GLint index,
+                GLuint swizzle)
+{
+   const GLint maxIndex = (1 << INST_INDEX_BITS) - 1;
+   const GLint minIndex = -(1 << INST_INDEX_BITS);
+   ASSERT(file < PROGRAM_FILE_MAX);
+   ASSERT(index >= minIndex);
+   (void) minIndex;
+   ASSERT(index <= maxIndex);
+   (void) maxIndex;
+   memset(r, 0, sizeof(*r));
+   r->Base.File = file;
+   r->Base.Index = index;
+   r->Base.Swizzle = swizzle;
+   r->Symbol = NULL;
+}
+
+
 /**
  * Validate the set of inputs used by a program
  *
@@ -5361,15 +5440,20 @@ initialize_symbol_from_state(struct gl_program *prog,
         state_tokens[2] = state_tokens[3] = row;
 
         idx = add_state_reference(prog->Parameters, state_tokens);
-        if (param_var->param_binding_begin == ~0U)
+        if (param_var->param_binding_begin == ~0U) {
            param_var->param_binding_begin = idx;
+            param_var->param_binding_swizzle = SWIZZLE_XYZW;
+         }
+
         param_var->param_binding_length++;
       }
    }
    else {
       idx = add_state_reference(prog->Parameters, state_tokens);
-      if (param_var->param_binding_begin == ~0U)
+      if (param_var->param_binding_begin == ~0U) {
         param_var->param_binding_begin = idx;
+         param_var->param_binding_swizzle = SWIZZLE_XYZW;
+      }
       param_var->param_binding_length++;
    }
 
@@ -5393,9 +5477,12 @@ initialize_symbol_from_param(struct gl_program *prog,
    assert((state_tokens[1] == STATE_ENV)
          || (state_tokens[1] == STATE_LOCAL));
 
+   /*
+    * The param type is STATE_VAR.  The program parameter entry will
+    * effectively be a pointer into the LOCAL or ENV parameter array.
+    */
    param_var->type = at_param;
-   param_var->param_binding_type = (state_tokens[1] == STATE_ENV)
-     ? PROGRAM_ENV_PARAM : PROGRAM_LOCAL_PARAM;
+   param_var->param_binding_type = PROGRAM_STATE_VAR;
 
    /* If we are adding a STATE_ENV or STATE_LOCAL that has multiple elements,
     * we need to unroll it and call add_state_reference() for each row
@@ -5409,15 +5496,19 @@ initialize_symbol_from_param(struct gl_program *prog,
         state_tokens[2] = state_tokens[3] = row;
 
         idx = add_state_reference(prog->Parameters, state_tokens);
-        if (param_var->param_binding_begin == ~0U)
+        if (param_var->param_binding_begin == ~0U) {
            param_var->param_binding_begin = idx;
+            param_var->param_binding_swizzle = SWIZZLE_XYZW;
+         }
         param_var->param_binding_length++;
       }
    }
    else {
       idx = add_state_reference(prog->Parameters, state_tokens);
-      if (param_var->param_binding_begin == ~0U)
+      if (param_var->param_binding_begin == ~0U) {
         param_var->param_binding_begin = idx;
+         param_var->param_binding_swizzle = SWIZZLE_XYZW;
+      }
       param_var->param_binding_length++;
    }
 
@@ -5425,20 +5516,34 @@ initialize_symbol_from_param(struct gl_program *prog,
 }
 
 
+/**
+ * Put a float/vector constant/literal into the parameter list.
+ * \param param_var  returns info about the parameter/constant's location,
+ *                   binding, type, etc.
+ * \param vec  the vector/constant to add
+ * \param allowSwizzle  if true, try to consolidate constants which only differ
+ *                      by a swizzle.  We don't want to do this when building
+ *                      arrays of constants that may be indexed indirectly.
+ * \return index of the constant in the parameter list.
+ */
 int
 initialize_symbol_from_const(struct gl_program *prog,
                             struct asm_symbol *param_var, 
-                            const struct asm_vector *vec)
+                            const struct asm_vector *vec,
+                             GLboolean allowSwizzle)
 {
-   const int idx = _mesa_add_parameter(prog->Parameters, PROGRAM_CONSTANT,
-                                      NULL, vec->count, GL_NONE, vec->data,
-                                      NULL, 0x0);
+   unsigned swizzle;
+   const int idx = _mesa_add_unnamed_constant(prog->Parameters,
+                                              vec->data, vec->count,
+                                              allowSwizzle ? &swizzle : NULL);
 
    param_var->type = at_param;
    param_var->param_binding_type = PROGRAM_CONSTANT;
 
-   if (param_var->param_binding_begin == ~0U)
+   if (param_var->param_binding_begin == ~0U) {
       param_var->param_binding_begin = idx;
+      param_var->param_binding_swizzle = allowSwizzle ? swizzle : SWIZZLE_XYZW;
+   }
    param_var->param_binding_length++;
 
    return idx;
index 860b6f886e962801c761b52bb9cc1ed13613b1f6..045241d9e77d551d053516e6c22a0727963c6d8f 100644 (file)
@@ -154,7 +154,7 @@ typedef union YYSTYPE
 {
 
 /* Line 1676 of yacc.c  */
-#line 116 "program_parse.y"
+#line 126 "program_parse.y"
 
    struct asm_instruction *inst;
    struct asm_symbol *sym;
index 9703e8e670f599b7b4cae91b79097435f8a06d90..5c5d8d759088449c13360f6922b3ce2e592183ad 100644 (file)
@@ -52,7 +52,8 @@ static int initialize_symbol_from_param(struct gl_program *prog,
     struct asm_symbol *param_var, const gl_state_index tokens[STATE_LENGTH]);
 
 static int initialize_symbol_from_const(struct gl_program *prog,
-    struct asm_symbol *param_var, const struct asm_vector *vec);
+    struct asm_symbol *param_var, const struct asm_vector *vec,
+    GLboolean allowSwizzle);
 
 static int yyparse(struct asm_parser_state *state);
 
@@ -66,8 +67,17 @@ static int validate_inputs(struct YYLTYPE *locp,
 
 static void init_dst_reg(struct prog_dst_register *r);
 
+static void set_dst_reg(struct prog_dst_register *r,
+                        gl_register_file file, GLint index);
+
 static void init_src_reg(struct asm_src_register *r);
 
+static void set_src_reg(struct asm_src_register *r,
+                        gl_register_file file, GLint index);
+
+static void set_src_reg_swz(struct asm_src_register *r,
+                            gl_register_file file, GLint index, GLuint swizzle);
+
 static void asm_instruction_set_operands(struct asm_instruction *inst,
     const struct prog_dst_register *dst, const struct asm_src_register *src0,
     const struct asm_src_register *src1, const struct asm_src_register *src2);
@@ -303,6 +313,8 @@ option: OPTION string ';'
           }
 
 
+          free($2);
+
           if (!valid) {
              const char *const err_str = (state->mode == ARB_vertex)
                 ? "invalid ARB vertex program option"
@@ -578,11 +590,11 @@ scalarUse:  srcReg scalarSuffix
 
           memset(& temp_sym, 0, sizeof(temp_sym));
           temp_sym.param_binding_begin = ~0;
-          initialize_symbol_from_const(state->prog, & temp_sym, & $1);
+          initialize_symbol_from_const(state->prog, & temp_sym, & $1, GL_TRUE);
 
-          init_src_reg(& $$);
-          $$.Base.File = PROGRAM_CONSTANT;
-          $$.Base.Index = temp_sym.param_binding_begin;
+          set_src_reg_swz(& $$, PROGRAM_CONSTANT,
+                           temp_sym.param_binding_begin,
+                           temp_sym.param_binding_swizzle);
        }
        ;
 
@@ -637,16 +649,14 @@ maskedDstReg: dstReg optionalMask optionalCcMask
                 YYERROR;
              }
 
-             state->prog->OutputsWritten |= (1U << $$.Index);
+             state->prog->OutputsWritten |= BITFIELD64_BIT($$.Index);
           }
        }
        ;
 
 maskedAddrReg: addrReg addrWriteMask
        {
-          init_dst_reg(& $$);
-          $$.File = PROGRAM_ADDRESS;
-          $$.Index = 0;
+          set_dst_reg(& $$, PROGRAM_ADDRESS, 0);
           $$.WriteMask = $2.mask;
        }
        ;
@@ -708,12 +718,17 @@ extSwizSel: INTEGER
        }
        | string
        {
+          char s;
+
           if (strlen($1) > 1) {
              yyerror(& @1, state, "invalid extended swizzle selector");
              YYERROR;
           }
 
-          switch ($1[0]) {
+          s = $1[0];
+          free($1);
+
+          switch (s) {
           case 'x':
              $$.swz = SWIZZLE_X;
              $$.xyzw_valid = 1;
@@ -761,6 +776,8 @@ srcReg: USED_IDENTIFIER /* temporaryReg | progParamSingle */
           struct asm_symbol *const s = (struct asm_symbol *)
              _mesa_symbol_table_find_symbol(state->st, 0, $1);
 
+          free($1);
+
           if (s == NULL) {
              yyerror(& @1, state, "invalid operand variable");
              YYERROR;
@@ -776,16 +793,15 @@ srcReg: USED_IDENTIFIER /* temporaryReg | progParamSingle */
           init_src_reg(& $$);
           switch (s->type) {
           case at_temp:
-             $$.Base.File = PROGRAM_TEMPORARY;
-             $$.Base.Index = s->temp_binding;
+             set_src_reg(& $$, PROGRAM_TEMPORARY, s->temp_binding);
              break;
           case at_param:
-             $$.Base.File = s->param_binding_type;
-             $$.Base.Index = s->param_binding_begin;
+              set_src_reg_swz(& $$, s->param_binding_type,
+                              s->param_binding_begin,
+                              s->param_binding_swizzle);
              break;
           case at_attrib:
-             $$.Base.File = PROGRAM_INPUT;
-             $$.Base.Index = s->attrib_binding;
+             set_src_reg(& $$, PROGRAM_INPUT, s->attrib_binding);
              state->prog->InputsRead |= (1U << $$.Base.Index);
 
              if (!validate_inputs(& @1, state)) {
@@ -800,9 +816,7 @@ srcReg: USED_IDENTIFIER /* temporaryReg | progParamSingle */
        }
        | attribBinding
        {
-          init_src_reg(& $$);
-          $$.Base.File = PROGRAM_INPUT;
-          $$.Base.Index = $1;
+          set_src_reg(& $$, PROGRAM_INPUT, $1);
           state->prog->InputsRead |= (1U << $$.Base.Index);
 
           if (!validate_inputs(& @1, state)) {
@@ -832,25 +846,25 @@ srcReg: USED_IDENTIFIER /* temporaryReg | progParamSingle */
        }
        | paramSingleItemUse
        {
-          init_src_reg(& $$);
-          $$.Base.File = ($1.name != NULL) 
+           gl_register_file file = ($1.name != NULL) 
              ? $1.param_binding_type
              : PROGRAM_CONSTANT;
-          $$.Base.Index = $1.param_binding_begin;
+           set_src_reg_swz(& $$, file, $1.param_binding_begin,
+                           $1.param_binding_swizzle);
        }
        ;
 
 dstReg: resultBinding
        {
-          init_dst_reg(& $$);
-          $$.File = PROGRAM_OUTPUT;
-          $$.Index = $1;
+          set_dst_reg(& $$, PROGRAM_OUTPUT, $1);
        }
        | USED_IDENTIFIER /* temporaryReg | vertexResultReg */
        {
           struct asm_symbol *const s = (struct asm_symbol *)
              _mesa_symbol_table_find_symbol(state->st, 0, $1);
 
+          free($1);
+
           if (s == NULL) {
              yyerror(& @1, state, "invalid operand variable");
              YYERROR;
@@ -859,19 +873,15 @@ dstReg: resultBinding
              YYERROR;
           }
 
-          init_dst_reg(& $$);
           switch (s->type) {
           case at_temp:
-             $$.File = PROGRAM_TEMPORARY;
-             $$.Index = s->temp_binding;
+             set_dst_reg(& $$, PROGRAM_TEMPORARY, s->temp_binding);
              break;
           case at_output:
-             $$.File = PROGRAM_OUTPUT;
-             $$.Index = s->output_binding;
+             set_dst_reg(& $$, PROGRAM_OUTPUT, s->output_binding);
              break;
           default:
-             $$.File = s->param_binding_type;
-             $$.Index = s->param_binding_begin;
+             set_dst_reg(& $$, s->param_binding_type, s->param_binding_begin);
              break;
           }
        }
@@ -882,6 +892,8 @@ progParamArray: USED_IDENTIFIER
           struct asm_symbol *const s = (struct asm_symbol *)
              _mesa_symbol_table_find_symbol(state->st, 0, $1);
 
+          free($1);
+
           if (s == NULL) {
              yyerror(& @1, state, "invalid operand variable");
              YYERROR;
@@ -953,6 +965,8 @@ addrReg: USED_IDENTIFIER
           struct asm_symbol *const s = (struct asm_symbol *)
              _mesa_symbol_table_find_symbol(state->st, 0, $1);
 
+          free($1);
+
           if (s == NULL) {
              yyerror(& @1, state, "invalid array member");
              YYERROR;
@@ -1091,6 +1105,7 @@ ATTRIB_statement: ATTRIB IDENTIFIER '=' attribBinding
              declare_variable(state, $2, at_attrib, & @2);
 
           if (s == NULL) {
+             free($2);
              YYERROR;
           } else {
              s->attrib_binding = $4;
@@ -1198,11 +1213,13 @@ PARAM_singleStmt: PARAM IDENTIFIER paramSingleInit
              declare_variable(state, $2, at_param, & @2);
 
           if (s == NULL) {
+             free($2);
              YYERROR;
           } else {
              s->param_binding_type = $3.param_binding_type;
              s->param_binding_begin = $3.param_binding_begin;
              s->param_binding_length = $3.param_binding_length;
+              s->param_binding_swizzle = SWIZZLE_XYZW;
              s->param_is_array = 0;
           }
        }
@@ -1211,6 +1228,7 @@ PARAM_singleStmt: PARAM IDENTIFIER paramSingleInit
 PARAM_multipleStmt: PARAM IDENTIFIER '[' optArraySize ']' paramMultipleInit
        {
           if (($4 != 0) && ((unsigned) $4 != $6.param_binding_length)) {
+             free($2);
              yyerror(& @4, state, 
                      "parameter array size and number of bindings must match");
              YYERROR;
@@ -1219,11 +1237,13 @@ PARAM_multipleStmt: PARAM IDENTIFIER '[' optArraySize ']' paramMultipleInit
                 declare_variable(state, $2, $6.type, & @2);
 
              if (s == NULL) {
+                free($2);
                 YYERROR;
              } else {
                 s->param_binding_type = $6.param_binding_type;
                 s->param_binding_begin = $6.param_binding_begin;
                 s->param_binding_length = $6.param_binding_length;
+                 s->param_binding_swizzle = SWIZZLE_XYZW;
                 s->param_is_array = 1;
              }
           }
@@ -1236,7 +1256,7 @@ optArraySize:
        }
        | INTEGER
         {
-          if (($1 < 1) || ((unsigned) $1 >= state->limits->MaxParameters)) {
+          if (($1 < 1) || ((unsigned) $1 > state->limits->MaxParameters)) {
              yyerror(& @1, state, "invalid parameter array size");
              YYERROR;
           } else {
@@ -1281,7 +1301,7 @@ paramSingleItemDecl: stateSingleItem
        {
           memset(& $$, 0, sizeof($$));
           $$.param_binding_begin = ~0;
-          initialize_symbol_from_const(state->prog, & $$, & $1);
+          initialize_symbol_from_const(state->prog, & $$, & $1, GL_TRUE);
        }
        ;
 
@@ -1301,7 +1321,7 @@ paramSingleItemUse: stateSingleItem
        {
           memset(& $$, 0, sizeof($$));
           $$.param_binding_begin = ~0;
-          initialize_symbol_from_const(state->prog, & $$, & $1);
+          initialize_symbol_from_const(state->prog, & $$, & $1, GL_TRUE);
        }
        ;
 
@@ -1321,7 +1341,7 @@ paramMultipleItem: stateMultipleItem
        {
           memset(& $$, 0, sizeof($$));
           $$.param_binding_begin = ~0;
-          initialize_symbol_from_const(state->prog, & $$, & $1);
+          initialize_symbol_from_const(state->prog, & $$, & $1, GL_FALSE);
        }
        ;
 
@@ -1953,12 +1973,14 @@ ADDRESS_statement: ADDRESS { $<integer>$ = $1; } varNameList
 varNameList: varNameList ',' IDENTIFIER
        {
           if (!declare_variable(state, $3, $<integer>0, & @3)) {
+             free($3);
              YYERROR;
           }
        }
        | IDENTIFIER
        {
           if (!declare_variable(state, $1, $<integer>0, & @1)) {
+             free($1);
              YYERROR;
           }
        }
@@ -1970,6 +1992,7 @@ OUTPUT_statement: optVarSize OUTPUT IDENTIFIER '=' resultBinding
              declare_variable(state, $3, at_output, & @3);
 
           if (s == NULL) {
+             free($3);
              YYERROR;
           } else {
              s->output_binding = $5;
@@ -2146,11 +2169,16 @@ ALIAS_statement: ALIAS IDENTIFIER '=' USED_IDENTIFIER
           struct asm_symbol *target = (struct asm_symbol *)
              _mesa_symbol_table_find_symbol(state->st, 0, $4);
 
+          free($4);
 
           if (exist != NULL) {
-             yyerror(& @2, state, "redeclared identifier");
+             char m[1000];
+             _mesa_snprintf(m, sizeof(m), "redeclared identifier: %s", $2);
+             free($2);
+             yyerror(& @2, state, m);
              YYERROR;
           } else if (target == NULL) {
+             free($2);
              yyerror(& @4, state,
                      "undefined variable binding in ALIAS statement");
              YYERROR;
@@ -2263,6 +2291,28 @@ init_dst_reg(struct prog_dst_register *r)
 }
 
 
+/** Like init_dst_reg() but set the File and Index fields. */
+void
+set_dst_reg(struct prog_dst_register *r, gl_register_file file, GLint index)
+{
+   const GLint maxIndex = 1 << INST_INDEX_BITS;
+   const GLint minIndex = 0;
+   ASSERT(index >= minIndex);
+   (void) minIndex;
+   ASSERT(index <= maxIndex);
+   (void) maxIndex;
+   ASSERT(file == PROGRAM_TEMPORARY ||
+         file == PROGRAM_ADDRESS ||
+         file == PROGRAM_OUTPUT);
+   memset(r, 0, sizeof(*r));
+   r->File = file;
+   r->Index = index;
+   r->WriteMask = WRITEMASK_XYZW;
+   r->CondMask = COND_TR;
+   r->CondSwizzle = SWIZZLE_NOOP;
+}
+
+
 void
 init_src_reg(struct asm_src_register *r)
 {
@@ -2273,6 +2323,35 @@ init_src_reg(struct asm_src_register *r)
 }
 
 
+/** Like init_src_reg() but set the File and Index fields.
+ * \return GL_TRUE if a valid src register, GL_FALSE otherwise
+ */
+void
+set_src_reg(struct asm_src_register *r, gl_register_file file, GLint index)
+{
+   set_src_reg_swz(r, file, index, SWIZZLE_XYZW);
+}
+
+
+void
+set_src_reg_swz(struct asm_src_register *r, gl_register_file file, GLint index,
+                GLuint swizzle)
+{
+   const GLint maxIndex = (1 << INST_INDEX_BITS) - 1;
+   const GLint minIndex = -(1 << INST_INDEX_BITS);
+   ASSERT(file < PROGRAM_FILE_MAX);
+   ASSERT(index >= minIndex);
+   (void) minIndex;
+   ASSERT(index <= maxIndex);
+   (void) maxIndex;
+   memset(r, 0, sizeof(*r));
+   r->Base.File = file;
+   r->Base.Index = index;
+   r->Base.Swizzle = swizzle;
+   r->Symbol = NULL;
+}
+
+
 /**
  * Validate the set of inputs used by a program
  *
@@ -2400,15 +2479,20 @@ initialize_symbol_from_state(struct gl_program *prog,
         state_tokens[2] = state_tokens[3] = row;
 
         idx = add_state_reference(prog->Parameters, state_tokens);
-        if (param_var->param_binding_begin == ~0U)
+        if (param_var->param_binding_begin == ~0U) {
            param_var->param_binding_begin = idx;
+            param_var->param_binding_swizzle = SWIZZLE_XYZW;
+         }
+
         param_var->param_binding_length++;
       }
    }
    else {
       idx = add_state_reference(prog->Parameters, state_tokens);
-      if (param_var->param_binding_begin == ~0U)
+      if (param_var->param_binding_begin == ~0U) {
         param_var->param_binding_begin = idx;
+         param_var->param_binding_swizzle = SWIZZLE_XYZW;
+      }
       param_var->param_binding_length++;
    }
 
@@ -2432,9 +2516,12 @@ initialize_symbol_from_param(struct gl_program *prog,
    assert((state_tokens[1] == STATE_ENV)
          || (state_tokens[1] == STATE_LOCAL));
 
+   /*
+    * The param type is STATE_VAR.  The program parameter entry will
+    * effectively be a pointer into the LOCAL or ENV parameter array.
+    */
    param_var->type = at_param;
-   param_var->param_binding_type = (state_tokens[1] == STATE_ENV)
-     ? PROGRAM_ENV_PARAM : PROGRAM_LOCAL_PARAM;
+   param_var->param_binding_type = PROGRAM_STATE_VAR;
 
    /* If we are adding a STATE_ENV or STATE_LOCAL that has multiple elements,
     * we need to unroll it and call add_state_reference() for each row
@@ -2448,15 +2535,19 @@ initialize_symbol_from_param(struct gl_program *prog,
         state_tokens[2] = state_tokens[3] = row;
 
         idx = add_state_reference(prog->Parameters, state_tokens);
-        if (param_var->param_binding_begin == ~0U)
+        if (param_var->param_binding_begin == ~0U) {
            param_var->param_binding_begin = idx;
+            param_var->param_binding_swizzle = SWIZZLE_XYZW;
+         }
         param_var->param_binding_length++;
       }
    }
    else {
       idx = add_state_reference(prog->Parameters, state_tokens);
-      if (param_var->param_binding_begin == ~0U)
+      if (param_var->param_binding_begin == ~0U) {
         param_var->param_binding_begin = idx;
+         param_var->param_binding_swizzle = SWIZZLE_XYZW;
+      }
       param_var->param_binding_length++;
    }
 
@@ -2464,20 +2555,34 @@ initialize_symbol_from_param(struct gl_program *prog,
 }
 
 
+/**
+ * Put a float/vector constant/literal into the parameter list.
+ * \param param_var  returns info about the parameter/constant's location,
+ *                   binding, type, etc.
+ * \param vec  the vector/constant to add
+ * \param allowSwizzle  if true, try to consolidate constants which only differ
+ *                      by a swizzle.  We don't want to do this when building
+ *                      arrays of constants that may be indexed indirectly.
+ * \return index of the constant in the parameter list.
+ */
 int
 initialize_symbol_from_const(struct gl_program *prog,
                             struct asm_symbol *param_var, 
-                            const struct asm_vector *vec)
+                            const struct asm_vector *vec,
+                             GLboolean allowSwizzle)
 {
-   const int idx = _mesa_add_parameter(prog->Parameters, PROGRAM_CONSTANT,
-                                      NULL, vec->count, GL_NONE, vec->data,
-                                      NULL, 0x0);
+   unsigned swizzle;
+   const int idx = _mesa_add_unnamed_constant(prog->Parameters,
+                                              vec->data, vec->count,
+                                              allowSwizzle ? &swizzle : NULL);
 
    param_var->type = at_param;
    param_var->param_binding_type = PROGRAM_CONSTANT;
 
-   if (param_var->param_binding_begin == ~0U)
+   if (param_var->param_binding_begin == ~0U) {
       param_var->param_binding_begin = idx;
+      param_var->param_binding_swizzle = allowSwizzle ? swizzle : SWIZZLE_XYZW;
+   }
    param_var->param_binding_length++;
 
    return idx;
index bce6041381f985347d3d9532d67e755ffb06ecb0..69396ca2c0f48ccc358426bf15587f0fe4714b7d 100644 (file)
@@ -35,7 +35,7 @@ enum asm_type {
    at_attrib,
    at_param,
    at_temp,
-   at_output,
+   at_output
 };
 
 struct asm_symbol {
@@ -56,6 +56,12 @@ struct asm_symbol {
     */
    unsigned param_binding_begin;
 
+   /**
+    * Constants put into the parameter list may be swizzled.  This
+    * field contain's the symbol's swizzle. (SWIZZLE_X/Y/Z/W)
+    */
+   unsigned param_binding_swizzle;
+
    /* This is how many entries in the the program_parameter_list we take up
     * with our state tokens or constants. Note that this is _not_ the same as
     * the number of param registers we eventually use.
index 3b8529592ddf622ef5a127057fc19aeff8b3bcad..9514545709d5262e09a7c9842e668fbfa948c422 100644 (file)
@@ -109,7 +109,7 @@ _mesa_insert_mvp_dp4_code(GLcontext *ctx, struct gl_vertex_program *vprog)
    vprog->Base.Instructions = newInst;
    vprog->Base.NumInstructions = newLen;
    vprog->Base.InputsRead |= VERT_BIT_POS;
-   vprog->Base.OutputsWritten |= (1 << VERT_RESULT_HPOS);
+   vprog->Base.OutputsWritten |= BITFIELD64_BIT(VERT_RESULT_HPOS);
 }
 
 
@@ -211,7 +211,7 @@ _mesa_insert_mvp_mad_code(GLcontext *ctx, struct gl_vertex_program *vprog)
    vprog->Base.Instructions = newInst;
    vprog->Base.NumInstructions = newLen;
    vprog->Base.InputsRead |= VERT_BIT_POS;
-   vprog->Base.OutputsWritten |= (1 << VERT_RESULT_HPOS);
+   vprog->Base.OutputsWritten |= BITFIELD64_BIT(VERT_RESULT_HPOS);
 }
 
 
@@ -528,15 +528,11 @@ _mesa_remove_output_reads(struct gl_program *prog, gl_register_file type)
    /* look for instructions which write to the varying vars identified above */
    for (i = 0; i < prog->NumInstructions; i++) {
       struct prog_instruction *inst = prog->Instructions + i;
-      const GLuint numSrc = _mesa_num_inst_src_regs(inst->Opcode);
-      GLuint j;
-      for (j = 0; j < numSrc; j++) {
-         if (inst->DstReg.File == type &&
-             outputMap[inst->DstReg.Index] >= 0) {
-            /* change inst to write to the temp reg, instead of the varying */
-            inst->DstReg.File = PROGRAM_TEMPORARY;
-            inst->DstReg.Index = outputMap[inst->DstReg.Index];
-         }
+      if (inst->DstReg.File == type &&
+          outputMap[inst->DstReg.Index] >= 0) {
+         /* change inst to write to the temp reg, instead of the varying */
+         inst->DstReg.File = PROGRAM_TEMPORARY;
+         inst->DstReg.Index = outputMap[inst->DstReg.Index];
       }
    }
 
@@ -613,7 +609,7 @@ _mesa_nop_fragment_program(GLcontext *ctx, struct gl_fragment_program *prog)
    prog->Base.Instructions = inst;
    prog->Base.NumInstructions = 2;
    prog->Base.InputsRead = 1 << inputAttr;
-   prog->Base.OutputsWritten = 1 << FRAG_RESULT_COLOR;
+   prog->Base.OutputsWritten = BITFIELD64_BIT(FRAG_RESULT_COLOR);
 }
 
 
@@ -657,7 +653,7 @@ _mesa_nop_vertex_program(GLcontext *ctx, struct gl_vertex_program *prog)
    prog->Base.Instructions = inst;
    prog->Base.NumInstructions = 2;
    prog->Base.InputsRead = 1 << inputAttr;
-   prog->Base.OutputsWritten = 1 << VERT_RESULT_COL0;
+   prog->Base.OutputsWritten = BITFIELD64_BIT(VERT_RESULT_COL0);
 
    /*
     * Now insert code to do standard modelview/projection transformation.
index ce196493231ad9b59dd701e072ad09bea64cfc01..453cd3964afe6919eabfb0509fb02d900894b412 100644 (file)
@@ -390,6 +390,8 @@ get_shader_flags(void)
          flags |= GLSL_OPT;
       if (_mesa_strstr(env, "uniform"))
          flags |= GLSL_UNIFORMS;
+      if (_mesa_strstr(env, "useprog"))
+         flags |= GLSL_USE_PROG;
    }
 
    return flags;
@@ -1496,6 +1498,41 @@ _mesa_link_program(GLcontext *ctx, GLuint program)
 }
 
 
+/**
+ * Print basic shader info (for debug).
+ */
+static void
+print_shader_info(const struct gl_shader_program *shProg)
+{
+   GLuint i;
+
+   _mesa_printf("Mesa: glUseProgram(%u)\n", shProg->Name);
+   for (i = 0; i < shProg->NumShaders; i++) {
+      const char *s;
+      switch (shProg->Shaders[i]->Type) {
+      case GL_VERTEX_SHADER:
+         s = "vertex";
+         break;
+      case GL_FRAGMENT_SHADER:
+         s = "fragment";
+         break;
+      case GL_GEOMETRY_SHADER:
+         s = "geometry";
+         break;
+      default:
+         s = "";
+      }
+      _mesa_printf("  %s shader %u, checksum %u\n", s, 
+                   shProg->Shaders[i]->Name,
+                   shProg->Shaders[i]->SourceChecksum);
+   }
+   if (shProg->VertexProgram)
+      _mesa_printf("  vert prog %u\n", shProg->VertexProgram->Base.Id);
+   if (shProg->FragmentProgram)
+      _mesa_printf("  frag prog %u\n", shProg->FragmentProgram->Base.Id);
+}
+
+
 /**
  * Called via ctx->Driver.UseProgram()
  */
@@ -1510,8 +1547,6 @@ _mesa_use_program(GLcontext *ctx, GLuint program)
       return;
    }
 
-   FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
-
    if (program) {
       shProg = _mesa_lookup_shader_program_err(ctx, program, "glUseProgram");
       if (!shProg) {
@@ -1524,26 +1559,18 @@ _mesa_use_program(GLcontext *ctx, GLuint program)
       }
 
       /* debug code */
-      if (0) {
-         GLuint i;
-         _mesa_printf("Use Shader %u\n", shProg->Name);
-         for (i = 0; i < shProg->NumShaders; i++) {
-            _mesa_printf(" shader %u, type 0x%x, checksum %u\n",
-                         shProg->Shaders[i]->Name,
-                         shProg->Shaders[i]->Type,
-                         shProg->Shaders[i]->SourceChecksum);
-         }
-         if (shProg->VertexProgram)
-            printf(" vert prog %u\n", shProg->VertexProgram->Base.Id);
-         if (shProg->FragmentProgram)
-            printf(" frag prog %u\n", shProg->FragmentProgram->Base.Id);
+      if (ctx->Shader.Flags & GLSL_USE_PROG) {
+         print_shader_info(shProg);
       }
    }
    else {
       shProg = NULL;
    }
 
-   _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentProgram, shProg);
+   if (ctx->Shader.CurrentProgram != shProg) {
+      FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
+      _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentProgram, shProg);
+   }
 }
 
 
index 6eefbcf5bdd73d426c5eaef312de376d61614f6e..674b786ac086c10389666aabb289bf74e5ef6692 100644 (file)
 
 VPATH = RCS
 
-INCDIR = [----.include],[--.main],[--.glapi],[-.slang],[-.grammar],[-]
+INCDIR = [----.include],[--.main],[--.glapi],[-.slang],[-]
 LIBDIR = [----.lib]
 CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)/float=ieee/ieee=denorm
 
 SOURCES = \
-       slang_compile.c,slang_preprocess.c
+       slang_compile.c
 
 OBJECTS = slang_builtin.obj,slang_codegen.obj,slang_compile.obj,\
        slang_compile_function.obj,slang_compile_operation.obj,\
@@ -59,7 +59,6 @@ slang_library_noise.obj : slang_library_noise.c
 slang_link.obj : slang_link.c
 slang_log.obj : slang_log.c
 slang_mem.obj : slang_mem.c
-slang_preprocess.obj : slang_preprocess.c
 slang_print.obj : slang_print.c
 slang_simplify.obj : slang_simplify.c
 slang_storage.obj : slang_storage.c
diff --git a/src/mesa/shader/slang/library/.gitignore b/src/mesa/shader/slang/library/.gitignore
new file mode 100644 (file)
index 0000000..02a89fc
--- /dev/null
@@ -0,0 +1 @@
+*_gc.h
index 0e03fac2ee176ad8c296acf752785b1c3bac8869..c6964512bfec548cf1f14e5d82a42429e0a3d231 100644 (file)
@@ -4,9 +4,7 @@ TOP = ../../../../..
 
 include $(TOP)/configs/current
 
-INCDIR = $(TOP)/include
-
-LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)
+GLSL_CL = $(TOP)/src/glsl/apps/compile
 
 #
 # targets
@@ -14,41 +12,13 @@ LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)
 
 .PHONY: default clean
 
-default: syntax builtin
+default: builtin
 
 clean:
-       -rm -f syn_to_c gc_to_bin *_syn.h *_gc.h
-
-syntax: slang_pp_directives_syn.h slang_pp_expression_syn.h slang_shader_syn.h slang_pp_version_syn.h
+       -rm -f *_gc.h
 
 builtin: builtin_110 builtin_120
 
-#
-# executables
-#
-
-syn_to_c: syn_to_c.c
-       $(CC) syn_to_c.c -o syn_to_c
-
-gc_to_bin: gc_to_bin.c slang_shader_syn.h
-       $(CC) gc_to_bin.c -o gc_to_bin
-
-#
-# syntax scripts
-#
-
-slang_pp_directives_syn.h: syn_to_c slang_pp_directives.syn
-       ./syn_to_c slang_pp_directives.syn > slang_pp_directives_syn.h
-
-slang_pp_expression_syn.h: syn_to_c slang_pp_expression.syn
-       ./syn_to_c slang_pp_expression.syn > slang_pp_expression_syn.h
-
-slang_shader_syn.h: syn_to_c slang_shader.syn
-       ./syn_to_c slang_shader.syn > slang_shader_syn.h
-
-slang_pp_version_syn.h: syn_to_c slang_pp_version.syn
-       ./syn_to_c slang_pp_version.syn > slang_pp_version_syn.h
-
 #
 # builtin library sources
 #
@@ -58,24 +28,24 @@ builtin_110: slang_common_builtin_gc.h slang_core_gc.h slang_fragment_builtin_gc
 builtin_120: slang_120_core_gc.h slang_builtin_120_common_gc.h slang_builtin_120_fragment_gc.h
 
 
-slang_120_core_gc.h: gc_to_bin slang_120_core.gc
-       ./gc_to_bin 1 slang_120_core.gc slang_120_core_gc.h
+slang_120_core_gc.h: slang_120_core.gc
+       $(GLSL_CL) fragment slang_120_core.gc slang_120_core_gc.h
 
-slang_builtin_120_common_gc.h: gc_to_bin slang_builtin_120_common.gc
-       ./gc_to_bin 1 slang_builtin_120_common.gc slang_builtin_120_common_gc.h
+slang_builtin_120_common_gc.h: slang_builtin_120_common.gc
+       $(GLSL_CL) fragment slang_builtin_120_common.gc slang_builtin_120_common_gc.h
 
-slang_builtin_120_fragment_gc.h: gc_to_bin slang_builtin_120_fragment.gc
-       ./gc_to_bin 1 slang_builtin_120_fragment.gc slang_builtin_120_fragment_gc.h
+slang_builtin_120_fragment_gc.h: slang_builtin_120_fragment.gc
+       $(GLSL_CL) fragment slang_builtin_120_fragment.gc slang_builtin_120_fragment_gc.h
 
-slang_common_builtin_gc.h: gc_to_bin slang_common_builtin.gc
-       ./gc_to_bin 1 slang_common_builtin.gc slang_common_builtin_gc.h
+slang_common_builtin_gc.h: slang_common_builtin.gc
+       $(GLSL_CL) fragment slang_common_builtin.gc slang_common_builtin_gc.h
 
-slang_core_gc.h: gc_to_bin slang_core.gc
-       ./gc_to_bin 1 slang_core.gc slang_core_gc.h
+slang_core_gc.h: slang_core.gc
+       $(GLSL_CL) fragment slang_core.gc slang_core_gc.h
 
-slang_fragment_builtin_gc.h: gc_to_bin slang_fragment_builtin.gc
-       ./gc_to_bin 1 slang_fragment_builtin.gc slang_fragment_builtin_gc.h
+slang_fragment_builtin_gc.h: slang_fragment_builtin.gc
+       $(GLSL_CL) fragment slang_fragment_builtin.gc slang_fragment_builtin_gc.h
 
-slang_vertex_builtin_gc.h: gc_to_bin slang_vertex_builtin.gc
-       ./gc_to_bin 2 slang_vertex_builtin.gc slang_vertex_builtin_gc.h
+slang_vertex_builtin_gc.h: slang_vertex_builtin.gc
+       $(GLSL_CL) vertex slang_vertex_builtin.gc slang_vertex_builtin_gc.h
 
diff --git a/src/mesa/shader/slang/library/SConscript b/src/mesa/shader/slang/library/SConscript
new file mode 100644 (file)
index 0000000..ef13114
--- /dev/null
@@ -0,0 +1,52 @@
+#######################################################################
+# SConscript for GLSL builtin library
+
+Import('*')
+
+env = env.Clone()
+
+# See also http://www.scons.org/wiki/UsingCodeGenerators
+
+def glsl_compile_emitter(target, source, env):
+       env.Depends(target, glsl_compile)
+       return (target, source)
+bld_frag = Builder(
+       action = glsl_compile[0].abspath + ' fragment $SOURCE $TARGET',
+       emitter = glsl_compile_emitter,
+       suffix = '.gc',
+       src_suffix = '_gc.h')
+       
+bld_vert = Builder(
+       action = glsl_compile[0].abspath + ' vertex $SOURCE $TARGET',
+       emitter = glsl_compile_emitter,
+       suffix = '.gc',
+       src_suffix = '_gc.h')
+
+env['BUILDERS']['bld_frag'] = bld_frag
+env['BUILDERS']['bld_vert'] = bld_vert
+
+# Generate GLSL builtin library binaries
+env.bld_frag(
+       '#src/mesa/shader/slang/library/slang_core_gc.h',
+       '#src/mesa/shader/slang/library/slang_core.gc')
+env.bld_frag(
+       '#src/mesa/shader/slang/library/slang_common_builtin_gc.h',
+       '#src/mesa/shader/slang/library/slang_common_builtin.gc')
+env.bld_frag(
+       '#src/mesa/shader/slang/library/slang_fragment_builtin_gc.h',
+       '#src/mesa/shader/slang/library/slang_fragment_builtin.gc')
+env.bld_vert(
+       '#src/mesa/shader/slang/library/slang_vertex_builtin_gc.h',
+       '#src/mesa/shader/slang/library/slang_vertex_builtin.gc')
+
+# Generate GLSL 1.20 builtin library binaries
+env.bld_frag(
+       '#src/mesa/shader/slang/library/slang_120_core_gc.h',
+       '#src/mesa/shader/slang/library/slang_120_core.gc')
+env.bld_frag(
+       '#src/mesa/shader/slang/library/slang_builtin_120_common_gc.h',
+       '#src/mesa/shader/slang/library/slang_builtin_120_common.gc')
+env.bld_frag(
+       '#src/mesa/shader/slang/library/slang_builtin_120_fragment_gc.h',
+       '#src/mesa/shader/slang/library/slang_builtin_120_fragment.gc')
diff --git a/src/mesa/shader/slang/library/gc_to_bin.c b/src/mesa/shader/slang/library/gc_to_bin.c
deleted file mode 100644 (file)
index 8aef7b5..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-#include "../../grammar/grammar_crt.h"
-#include "../../grammar/grammar_crt.c"
-#include <stdlib.h>
-#include <stdio.h>
-
-static const char *slang_shader_syn =
-#include "slang_shader_syn.h"
-;
-
-static int gc_to_bin (grammar id, const char *in, const char *out)
-{
-       FILE *f;
-       byte *source, *prod;
-       unsigned int size, i, line = 0;
-
-       printf ("Precompiling %s\n", in);
-
-       f = fopen (in, "r");
-       if (f == NULL)
-               return 1;
-       fseek (f, 0, SEEK_END);
-       size = ftell (f);
-       fseek (f, 0, SEEK_SET);
-       source = (byte *) grammar_alloc_malloc (size + 1);
-       source[fread (source, 1, size, f)] = '\0';
-       fclose (f);
-
-       if (!grammar_fast_check (id, source, &prod, &size, 65536))
-       {
-               grammar_alloc_free (source);
-               return 1;
-       }
-
-       f = fopen (out, "w");
-       fprintf (f, "\n");
-       fprintf (f, "/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED FROM THE FOLLOWING FILE: */\n");
-       fprintf (f, "/* %s */\n", in);
-       fprintf (f, "\n");
-       for (i = 0; i < size; i++)
-       {
-               unsigned int a;
-               if (prod[i] < 10)
-                       a = 1;
-               else if (prod[i] < 100)
-                       a = 2;
-               else
-                       a = 3;
-               if (i < size - 1)
-                       a++;
-               if (line + a >= 100)
-               {
-                       fprintf (f, "\n");
-                       line = 0;
-               }
-               line += a;
-               fprintf (f, "%d", prod[i]);
-               if (i < size - 1)
-                       fprintf (f, ",");
-       }
-       fprintf (f, "\n");
-       fclose (f);
-       grammar_alloc_free (prod);
-   return 0;
-}
-
-int main (int argc, char *argv[])
-{
-   grammar id;
-
-   id = grammar_load_from_text ((const byte *) slang_shader_syn);
-   if (id == 0) {
-      fprintf(stderr, "Error loading grammar from text\n");
-      return 1;
-   }
-   grammar_set_reg8 (id, (const byte *) "parsing_builtin", 1);
-   grammar_set_reg8 (id, (const byte *) "shader_type", atoi (argv[1]));
-   if (gc_to_bin (id, argv[2], argv[3])) {
-      fprintf(stderr, "Error in gc_to_bin %s %s\n", argv[2], argv[3]);
-      grammar_destroy (id);
-      return 1;
-   }
-   grammar_destroy (id);
-   return 0;
-}
-
diff --git a/src/mesa/shader/slang/library/slang_120_core_gc.h b/src/mesa/shader/slang/library/slang_120_core_gc.h
deleted file mode 100644 (file)
index 1fdbddf..0000000
+++ /dev/null
@@ -1,764 +0,0 @@
-
-/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED FROM THE FOLLOWING FILE: */
-/* slang_120_core.gc */
-
-5,1,90,95,0,0,26,0,1,1,1,0,0,9,0,102,48,48,0,0,1,1,0,0,9,0,102,49,48,0,0,1,1,0,0,9,0,102,50,48,0,0,
-1,1,0,0,9,0,102,48,49,0,0,1,1,0,0,9,0,102,49,49,0,0,1,1,0,0,9,0,102,50,49,0,0,0,1,9,18,95,95,114,
-101,116,86,97,108,0,16,8,48,0,57,59,120,0,18,102,48,48,0,20,0,9,18,95,95,114,101,116,86,97,108,0,
-16,8,48,0,57,59,121,0,18,102,49,48,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,59,122,0,
-18,102,50,48,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,59,120,0,18,102,48,49,0,20,0,
-9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,59,121,0,18,102,49,49,0,20,0,9,18,95,95,114,101,
-116,86,97,108,0,16,10,49,0,57,59,122,0,18,102,50,49,0,20,0,0,1,90,95,0,0,26,0,1,1,1,0,0,9,0,102,0,
-0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,50,120,51,0,0,18,102,0,0,17,48,0,48,0,0,0,
-17,48,0,48,0,0,0,17,48,0,48,0,0,0,18,102,0,0,17,48,0,48,0,0,0,0,20,0,0,1,90,95,0,0,26,0,1,1,1,0,0,
-5,0,105,0,0,0,1,3,2,90,95,1,0,9,0,1,102,0,2,58,102,108,111,97,116,0,0,18,105,0,0,0,0,0,9,18,95,95,
-114,101,116,86,97,108,0,58,109,97,116,50,120,51,0,0,18,102,0,0,0,20,0,0,1,90,95,0,0,26,0,1,1,1,0,0,
-1,0,98,0,0,0,1,3,2,90,95,1,0,9,0,1,102,0,2,58,102,108,111,97,116,0,0,18,98,0,0,0,0,0,9,18,95,95,
-114,101,116,86,97,108,0,58,109,97,116,50,120,51,0,0,18,102,0,0,0,20,0,0,1,90,95,0,0,26,0,1,1,1,0,0,
-11,0,99,48,0,0,1,1,0,0,11,0,99,49,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,99,48,
-0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,99,49,0,20,0,0,1,90,95,0,0,28,0,1,1,1,0,
-0,9,0,102,48,48,0,0,1,1,0,0,9,0,102,49,48,0,0,1,1,0,0,9,0,102,50,48,0,0,1,1,0,0,9,0,102,51,48,0,0,
-1,1,0,0,9,0,102,48,49,0,0,1,1,0,0,9,0,102,49,49,0,0,1,1,0,0,9,0,102,50,49,0,0,1,1,0,0,9,0,102,51,
-49,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,59,120,0,18,102,48,48,0,20,0,9,18,95,95,
-114,101,116,86,97,108,0,16,8,48,0,57,59,121,0,18,102,49,48,0,20,0,9,18,95,95,114,101,116,86,97,108,
-0,16,8,48,0,57,59,122,0,18,102,50,48,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,59,119,
-0,18,102,51,48,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,59,120,0,18,102,48,49,0,20,
-0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,59,121,0,18,102,49,49,0,20,0,9,18,95,95,114,101,
-116,86,97,108,0,16,10,49,0,57,59,122,0,18,102,50,49,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,
-10,49,0,57,59,119,0,18,102,51,49,0,20,0,0,1,90,95,0,0,28,0,1,1,1,0,0,9,0,102,0,0,0,1,9,18,95,95,
-114,101,116,86,97,108,0,58,109,97,116,50,120,52,0,0,18,102,0,0,17,48,0,48,0,0,0,17,48,0,48,0,0,0,
-17,48,0,48,0,0,0,17,48,0,48,0,0,0,18,102,0,0,17,48,0,48,0,0,0,17,48,0,48,0,0,0,0,20,0,0,1,90,95,0,
-0,28,0,1,1,1,0,0,5,0,105,0,0,0,1,3,2,90,95,1,0,9,0,1,102,0,2,58,102,108,111,97,116,0,0,18,105,0,0,
-0,0,0,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,50,120,52,0,0,18,102,0,0,0,20,0,0,1,90,95,0,
-0,28,0,1,1,1,0,0,1,0,98,0,0,0,1,3,2,90,95,1,0,9,0,1,102,0,2,58,102,108,111,97,116,0,0,18,98,0,0,0,
-0,0,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,50,120,52,0,0,18,102,0,0,0,20,0,0,1,90,95,0,0,
-28,0,1,1,1,0,0,12,0,99,48,0,0,1,1,0,0,12,0,99,49,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,
-48,0,57,18,99,48,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,99,49,0,20,0,0,1,90,95,
-0,0,27,0,1,1,1,0,0,9,0,102,48,48,0,0,1,1,0,0,9,0,102,49,48,0,0,1,1,0,0,9,0,102,48,49,0,0,1,1,0,0,9,
-0,102,49,49,0,0,1,1,0,0,9,0,102,48,50,0,0,1,1,0,0,9,0,102,49,50,0,0,0,1,9,18,95,95,114,101,116,86,
-97,108,0,16,8,48,0,57,59,120,0,18,102,48,48,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,
-59,121,0,18,102,49,48,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,59,120,0,18,102,48,
-49,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,59,121,0,18,102,49,49,0,20,0,9,18,95,95,
-114,101,116,86,97,108,0,16,10,50,0,57,59,120,0,18,102,48,50,0,20,0,9,18,95,95,114,101,116,86,97,
-108,0,16,10,50,0,57,59,121,0,18,102,49,50,0,20,0,0,1,90,95,0,0,27,0,1,1,1,0,0,9,0,102,0,0,0,1,9,18,
-95,95,114,101,116,86,97,108,0,58,109,97,116,51,120,50,0,0,18,102,0,0,17,48,0,48,0,0,0,17,48,0,48,0,
-0,0,18,102,0,0,17,48,0,48,0,0,0,17,48,0,48,0,0,0,0,20,0,0,1,90,95,0,0,27,0,1,1,1,0,0,5,0,105,0,0,0,
-1,3,2,90,95,1,0,9,0,1,102,0,2,58,102,108,111,97,116,0,0,18,105,0,0,0,0,0,9,18,95,95,114,101,116,86,
-97,108,0,58,109,97,116,51,120,50,0,0,18,102,0,0,0,20,0,0,1,90,95,0,0,27,0,1,1,1,0,0,1,0,98,0,0,0,1,
-3,2,90,95,1,0,9,0,1,102,0,2,58,102,108,111,97,116,0,0,18,98,0,0,0,0,0,9,18,95,95,114,101,116,86,97,
-108,0,58,109,97,116,51,120,50,0,0,18,102,0,0,0,20,0,0,1,90,95,0,0,27,0,1,1,1,0,0,10,0,99,48,0,0,1,
-1,0,0,10,0,99,49,0,0,1,1,0,0,10,0,99,50,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,
-99,48,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,99,49,0,20,0,9,18,95,95,114,101,
-116,86,97,108,0,16,10,50,0,57,18,99,50,0,20,0,0,1,90,95,0,0,30,0,1,1,1,0,0,9,0,102,48,48,0,0,1,1,0,
-0,9,0,102,49,48,0,0,1,1,0,0,9,0,102,50,48,0,0,1,1,0,0,9,0,102,51,48,0,0,1,1,0,0,9,0,102,48,49,0,0,
-1,1,0,0,9,0,102,49,49,0,0,1,1,0,0,9,0,102,50,49,0,0,1,1,0,0,9,0,102,51,49,0,0,1,1,0,0,9,0,102,48,
-50,0,0,1,1,0,0,9,0,102,49,50,0,0,1,1,0,0,9,0,102,50,50,0,0,1,1,0,0,9,0,102,51,50,0,0,0,1,9,18,95,
-95,114,101,116,86,97,108,0,16,8,48,0,57,59,120,0,18,102,48,48,0,20,0,9,18,95,95,114,101,116,86,97,
-108,0,16,8,48,0,57,59,121,0,18,102,49,48,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,59,
-122,0,18,102,50,48,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,59,119,0,18,102,51,48,0,
-20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,59,120,0,18,102,48,49,0,20,0,9,18,95,95,114,
-101,116,86,97,108,0,16,10,49,0,57,59,121,0,18,102,49,49,0,20,0,9,18,95,95,114,101,116,86,97,108,0,
-16,10,49,0,57,59,122,0,18,102,50,49,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,59,119,
-0,18,102,51,49,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,59,120,0,18,102,48,50,0,20,
-0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,59,121,0,18,102,49,50,0,20,0,9,18,95,95,114,101,
-116,86,97,108,0,16,10,50,0,57,59,122,0,18,102,50,50,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,
-10,50,0,57,59,119,0,18,102,51,50,0,20,0,0,1,90,95,0,0,30,0,1,1,1,0,0,9,0,102,0,0,0,1,9,18,95,95,
-114,101,116,86,97,108,0,58,109,97,116,51,120,52,0,0,18,102,0,0,17,48,0,48,0,0,0,17,48,0,48,0,0,0,
-17,48,0,48,0,0,0,17,48,0,48,0,0,0,18,102,0,0,17,48,0,48,0,0,0,17,48,0,48,0,0,0,17,48,0,48,0,0,0,17,
-48,0,48,0,0,0,18,102,0,0,17,48,0,48,0,0,0,0,20,0,0,1,90,95,0,0,30,0,1,1,1,0,0,5,0,105,0,0,0,1,3,2,
-90,95,1,0,9,0,1,102,0,2,58,102,108,111,97,116,0,0,18,105,0,0,0,0,0,9,18,95,95,114,101,116,86,97,
-108,0,58,109,97,116,51,120,52,0,0,18,102,0,0,0,20,0,0,1,90,95,0,0,30,0,1,1,1,0,0,1,0,98,0,0,0,1,3,
-2,90,95,1,0,9,0,1,102,0,2,58,102,108,111,97,116,0,0,18,98,0,0,0,0,0,9,18,95,95,114,101,116,86,97,
-108,0,58,109,97,116,51,120,52,0,0,18,102,0,0,0,20,0,0,1,90,95,0,0,30,0,1,1,1,0,0,12,0,99,48,0,0,1,
-1,0,0,12,0,99,49,0,0,1,1,0,0,12,0,99,50,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,
-99,48,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,99,49,0,20,0,9,18,95,95,114,101,
-116,86,97,108,0,16,10,50,0,57,18,99,50,0,20,0,0,1,90,95,0,0,29,0,1,1,1,0,0,9,0,102,48,48,0,0,1,1,0,
-0,9,0,102,49,48,0,0,1,1,0,0,9,0,102,48,49,0,0,1,1,0,0,9,0,102,49,49,0,0,1,1,0,0,9,0,102,48,50,0,0,
-1,1,0,0,9,0,102,49,50,0,0,1,1,0,0,9,0,102,48,51,0,0,1,1,0,0,9,0,102,49,51,0,0,0,1,9,18,95,95,114,
-101,116,86,97,108,0,16,8,48,0,57,59,120,0,18,102,48,48,0,20,0,9,18,95,95,114,101,116,86,97,108,0,
-16,8,48,0,57,59,121,0,18,102,49,48,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,59,120,
-0,18,102,48,49,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,59,121,0,18,102,49,49,0,20,
-0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,59,120,0,18,102,48,50,0,20,0,9,18,95,95,114,101,
-116,86,97,108,0,16,10,50,0,57,59,121,0,18,102,49,50,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,
-10,51,0,57,59,120,0,18,102,48,51,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,51,0,57,59,121,0,
-18,102,49,51,0,20,0,0,1,90,95,0,0,29,0,1,1,1,0,0,9,0,102,0,0,0,1,9,18,95,95,114,101,116,86,97,108,
-0,58,109,97,116,52,120,50,0,0,18,102,0,0,17,48,0,48,0,0,0,17,48,0,48,0,0,0,16,10,52,0,0,17,48,0,48,
-0,0,0,17,48,0,48,0,0,0,17,48,0,48,0,0,0,17,48,0,48,0,0,0,0,20,0,0,1,90,95,0,0,29,0,1,1,1,0,0,5,0,
-105,0,0,0,1,3,2,90,95,1,0,9,0,1,102,0,2,58,102,108,111,97,116,0,0,18,105,0,0,0,0,0,9,18,95,95,114,
-101,116,86,97,108,0,58,109,97,116,52,120,50,0,0,18,102,0,0,0,20,0,0,1,90,95,0,0,29,0,1,1,1,0,0,1,0,
-98,0,0,0,1,3,2,90,95,1,0,9,0,1,102,0,2,58,102,108,111,97,116,0,0,18,98,0,0,0,0,0,9,18,95,95,114,
-101,116,86,97,108,0,58,109,97,116,52,120,50,0,0,18,102,0,0,0,20,0,0,1,90,95,0,0,29,0,1,1,1,0,0,10,
-0,99,48,0,0,1,1,0,0,10,0,99,49,0,0,1,1,0,0,10,0,99,50,0,0,1,1,0,0,10,0,99,51,0,0,0,1,9,18,95,95,
-114,101,116,86,97,108,0,16,8,48,0,57,18,99,48,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,
-57,18,99,49,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,99,50,0,20,0,9,18,95,95,114,
-101,116,86,97,108,0,16,10,51,0,57,18,99,51,0,20,0,0,1,90,95,0,0,31,0,1,1,1,0,0,9,0,102,48,48,0,0,1,
-1,0,0,9,0,102,49,48,0,0,1,1,0,0,9,0,102,50,48,0,0,1,1,0,0,9,0,102,48,49,0,0,1,1,0,0,9,0,102,49,49,
-0,0,1,1,0,0,9,0,102,50,49,0,0,1,1,0,0,9,0,102,48,50,0,0,1,1,0,0,9,0,102,49,50,0,0,1,1,0,0,9,0,102,
-50,50,0,0,1,1,0,0,9,0,102,48,51,0,0,1,1,0,0,9,0,102,49,51,0,0,1,1,0,0,9,0,102,50,51,0,0,0,1,9,18,
-95,95,114,101,116,86,97,108,0,16,8,48,0,57,59,120,0,18,102,48,48,0,20,0,9,18,95,95,114,101,116,86,
-97,108,0,16,8,48,0,57,59,121,0,18,102,49,48,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,
-59,122,0,18,102,50,48,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,59,120,0,18,102,48,
-49,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,59,121,0,18,102,49,49,0,20,0,9,18,95,95,
-114,101,116,86,97,108,0,16,10,49,0,57,59,122,0,18,102,50,49,0,20,0,9,18,95,95,114,101,116,86,97,
-108,0,16,10,50,0,57,59,120,0,18,102,48,50,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,
-59,121,0,18,102,49,50,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,59,122,0,18,102,50,
-50,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,51,0,57,59,120,0,18,102,48,51,0,20,0,9,18,95,95,
-114,101,116,86,97,108,0,16,10,51,0,57,59,121,0,18,102,49,51,0,20,0,9,18,95,95,114,101,116,86,97,
-108,0,16,10,51,0,57,59,122,0,18,102,50,51,0,20,0,0,1,90,95,0,0,31,0,1,1,1,0,0,9,0,102,0,0,0,1,9,18,
-95,95,114,101,116,86,97,108,0,58,109,97,116,52,120,51,0,0,18,102,0,0,17,48,0,48,0,0,0,17,48,0,48,0,
-0,0,17,48,0,48,0,0,0,18,102,0,0,17,48,0,48,0,0,0,17,48,0,48,0,0,0,17,48,0,48,0,0,0,18,102,0,0,17,
-48,0,48,0,0,0,17,48,0,48,0,0,0,17,48,0,48,0,0,0,0,20,0,0,1,90,95,0,0,31,0,1,1,1,0,0,5,0,105,0,0,0,
-1,3,2,90,95,1,0,9,0,1,102,0,2,58,102,108,111,97,116,0,0,18,105,0,0,0,0,0,9,18,95,95,114,101,116,86,
-97,108,0,58,109,97,116,52,120,51,0,0,18,102,0,0,0,20,0,0,1,90,95,0,0,31,0,1,1,1,0,0,1,0,98,0,0,0,1,
-3,2,90,95,1,0,9,0,1,102,0,2,58,102,108,111,97,116,0,0,18,98,0,0,0,0,0,9,18,95,95,114,101,116,86,97,
-108,0,58,109,97,116,52,120,51,0,0,18,102,0,0,0,20,0,0,1,90,95,0,0,31,0,1,1,1,0,0,11,0,99,48,0,0,1,
-1,0,0,11,0,99,49,0,0,1,1,0,0,11,0,99,50,0,0,1,1,0,0,11,0,99,51,0,0,0,1,9,18,95,95,114,101,116,86,
-97,108,0,16,8,48,0,57,18,99,48,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,99,49,0,
-20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,99,50,0,20,0,9,18,95,95,114,101,116,86,97,
-108,0,16,10,51,0,57,18,99,51,0,20,0,0,1,90,95,0,0,13,0,1,1,1,0,0,13,0,109,0,0,0,1,9,18,95,95,114,
-101,116,86,97,108,0,18,109,0,20,0,0,1,90,95,0,0,13,0,1,1,1,0,0,27,0,109,0,0,0,1,9,18,95,95,114,101,
-116,86,97,108,0,58,109,97,116,50,0,0,18,109,0,16,8,48,0,57,0,18,109,0,16,10,49,0,57,0,0,20,0,0,1,
-90,95,0,0,13,0,1,1,1,0,0,29,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,50,0,0,
-18,109,0,16,8,48,0,57,0,18,109,0,16,10,49,0,57,0,0,20,0,0,1,90,95,0,0,13,0,1,1,1,0,0,26,0,109,0,0,
-0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,50,0,0,18,109,0,16,8,48,0,57,59,120,121,0,0,
-18,109,0,16,10,49,0,57,59,120,121,0,0,0,20,0,0,1,90,95,0,0,13,0,1,1,1,0,0,28,0,109,0,0,0,1,9,18,95,
-95,114,101,116,86,97,108,0,58,109,97,116,50,0,0,18,109,0,16,8,48,0,57,59,120,121,0,0,18,109,0,16,
-10,49,0,57,59,120,121,0,0,0,20,0,0,1,90,95,0,0,13,0,1,1,1,0,0,14,0,109,0,0,0,1,9,18,95,95,114,101,
-116,86,97,108,0,58,109,97,116,50,0,0,18,109,0,16,8,48,0,57,59,120,121,0,0,18,109,0,16,10,49,0,57,
-59,120,121,0,0,0,20,0,0,1,90,95,0,0,13,0,1,1,1,0,0,30,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,
-108,0,58,109,97,116,50,0,0,18,109,0,16,8,48,0,57,59,120,121,0,0,18,109,0,16,10,49,0,57,59,120,121,
-0,0,0,20,0,0,1,90,95,0,0,13,0,1,1,1,0,0,31,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,
-97,116,50,0,0,18,109,0,16,8,48,0,57,59,120,121,0,0,18,109,0,16,10,49,0,57,59,120,121,0,0,0,20,0,0,
-1,90,95,0,0,13,0,1,1,1,0,0,15,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,50,0,
-0,18,109,0,16,8,48,0,57,59,120,121,0,0,18,109,0,16,10,49,0,57,59,120,121,0,0,0,20,0,0,1,90,95,0,0,
-26,0,1,1,1,0,0,26,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,109,0,20,0,0,1,90,95,0,0,26,
-0,1,1,1,0,0,14,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,50,120,51,0,0,18,109,
-0,16,8,48,0,57,0,18,109,0,16,10,49,0,57,0,0,20,0,0,1,90,95,0,0,26,0,1,1,1,0,0,31,0,109,0,0,0,1,9,
-18,95,95,114,101,116,86,97,108,0,58,109,97,116,50,120,51,0,0,18,109,0,16,8,48,0,57,0,18,109,0,16,
-10,49,0,57,0,0,20,0,0,1,90,95,0,0,26,0,1,1,1,0,0,28,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,
-0,58,109,97,116,50,120,51,0,0,18,109,0,16,8,48,0,57,59,120,121,122,0,0,18,109,0,16,10,49,0,57,59,
-120,121,122,0,0,0,20,0,0,1,90,95,0,0,26,0,1,1,1,0,0,30,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,
-108,0,58,109,97,116,50,120,51,0,0,18,109,0,16,8,48,0,57,59,120,121,122,0,0,18,109,0,16,10,49,0,57,
-59,120,121,122,0,0,0,20,0,0,1,90,95,0,0,26,0,1,1,1,0,0,15,0,109,0,0,0,1,9,18,95,95,114,101,116,86,
-97,108,0,58,109,97,116,50,120,51,0,0,18,109,0,16,8,48,0,57,59,120,121,122,0,0,18,109,0,16,10,49,0,
-57,59,120,121,122,0,0,0,20,0,0,1,90,95,0,0,26,0,1,1,1,0,0,13,0,109,0,0,0,1,9,18,95,95,114,101,116,
-86,97,108,0,58,109,97,116,50,120,51,0,0,18,109,0,16,8,48,0,57,59,120,0,0,18,109,0,16,8,48,0,57,59,
-121,0,0,17,48,0,48,0,0,0,18,109,0,16,10,49,0,57,59,120,0,0,18,109,0,16,10,49,0,57,59,121,0,0,17,48,
-0,48,0,0,0,0,20,0,0,1,90,95,0,0,26,0,1,1,1,0,0,27,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,
-58,109,97,116,50,120,51,0,0,18,109,0,16,8,48,0,57,59,120,0,0,18,109,0,16,8,48,0,57,59,121,0,0,17,
-48,0,48,0,0,0,18,109,0,16,10,49,0,57,59,120,0,0,18,109,0,16,10,49,0,57,59,121,0,0,17,48,0,48,0,0,0,
-0,20,0,0,1,90,95,0,0,26,0,1,1,1,0,0,29,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,
-116,50,120,51,0,0,18,109,0,16,8,48,0,57,59,120,0,0,18,109,0,16,8,48,0,57,59,121,0,0,17,48,0,48,0,0,
-0,18,109,0,16,10,49,0,57,59,120,0,0,18,109,0,16,10,49,0,57,59,121,0,0,17,48,0,48,0,0,0,0,20,0,0,1,
-90,95,0,0,28,0,1,1,1,0,0,28,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,109,0,20,0,0,1,90,
-95,0,0,28,0,1,1,1,0,0,30,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,50,120,52,
-0,0,18,109,0,16,8,48,0,57,0,18,109,0,16,10,49,0,57,0,0,20,0,0,1,90,95,0,0,28,0,1,1,1,0,0,15,0,109,
-0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,50,120,52,0,0,18,109,0,16,8,48,0,57,0,18,
-109,0,16,10,49,0,57,0,0,20,0,0,1,90,95,0,0,28,0,1,1,1,0,0,26,0,109,0,0,0,1,9,18,95,95,114,101,116,
-86,97,108,0,58,109,97,116,50,120,52,0,0,18,109,0,16,8,48,0,57,59,120,0,0,18,109,0,16,8,48,0,57,59,
-121,0,0,18,109,0,16,8,48,0,57,59,122,0,0,17,48,0,48,0,0,0,18,109,0,16,10,49,0,57,59,120,0,0,18,109,
-0,16,10,49,0,57,59,121,0,0,18,109,0,16,10,49,0,57,59,122,0,0,17,48,0,48,0,0,0,0,20,0,0,1,90,95,0,0,
-28,0,1,1,1,0,0,14,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,50,120,52,0,0,18,
-109,0,16,8,48,0,57,59,120,0,0,18,109,0,16,8,48,0,57,59,121,0,0,18,109,0,16,8,48,0,57,59,122,0,0,17,
-48,0,48,0,0,0,18,109,0,16,10,49,0,57,59,120,0,0,18,109,0,16,10,49,0,57,59,121,0,0,18,109,0,16,10,
-49,0,57,59,122,0,0,17,48,0,48,0,0,0,0,20,0,0,1,90,95,0,0,28,0,1,1,1,0,0,31,0,109,0,0,0,1,9,18,95,
-95,114,101,116,86,97,108,0,58,109,97,116,50,120,52,0,0,18,109,0,16,8,48,0,57,59,120,0,0,18,109,0,
-16,8,48,0,57,59,121,0,0,18,109,0,16,8,48,0,57,59,122,0,0,17,48,0,48,0,0,0,18,109,0,16,10,49,0,57,
-59,120,0,0,18,109,0,16,10,49,0,57,59,121,0,0,18,109,0,16,10,49,0,57,59,122,0,0,17,48,0,48,0,0,0,0,
-20,0,0,1,90,95,0,0,28,0,1,1,1,0,0,13,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,
-116,50,120,52,0,0,18,109,0,16,8,48,0,57,59,120,0,0,18,109,0,16,10,49,0,57,59,121,0,0,17,48,0,48,0,
-0,0,17,48,0,48,0,0,0,18,109,0,16,10,49,0,57,59,120,0,0,18,109,0,16,10,49,0,57,59,121,0,0,17,48,0,
-48,0,0,0,17,48,0,48,0,0,0,0,20,0,0,1,90,95,0,0,28,0,1,1,1,0,0,27,0,109,0,0,0,1,9,18,95,95,114,101,
-116,86,97,108,0,58,109,97,116,50,120,52,0,0,18,109,0,16,8,48,0,57,59,120,0,0,18,109,0,16,8,48,0,57,
-59,121,0,0,17,48,0,48,0,0,0,17,48,0,48,0,0,0,18,109,0,16,10,49,0,57,59,120,0,0,18,109,0,16,10,49,0,
-57,59,121,0,0,17,48,0,48,0,0,0,17,48,0,48,0,0,0,0,20,0,0,1,90,95,0,0,28,0,1,1,1,0,0,29,0,109,0,0,0,
-1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,50,120,52,0,0,18,109,0,16,8,48,0,57,59,120,0,0,
-18,109,0,16,8,48,0,57,59,121,0,0,17,48,0,48,0,0,0,17,48,0,48,0,0,0,18,109,0,16,10,49,0,57,59,120,0,
-0,18,109,0,16,10,49,0,57,59,121,0,0,17,48,0,48,0,0,0,17,48,0,48,0,0,0,0,20,0,0,1,90,95,0,0,27,0,1,
-1,1,0,0,27,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,109,0,20,0,0,1,90,95,0,0,27,0,1,1,1,
-0,0,29,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,51,120,50,0,0,18,109,0,16,8,
-48,0,57,0,18,109,0,16,10,49,0,57,0,18,109,0,16,10,50,0,57,0,0,20,0,0,1,90,95,0,0,27,0,1,1,1,0,0,14,
-0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,51,120,50,0,0,18,109,0,16,8,48,0,57,
-0,18,109,0,16,10,49,0,57,0,18,109,0,16,10,50,0,57,0,0,20,0,0,1,90,95,0,0,27,0,1,1,1,0,0,30,0,109,0,
-0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,51,120,50,0,0,18,109,0,16,8,48,0,57,59,120,
-0,0,18,109,0,16,8,48,0,57,59,121,0,0,18,109,0,16,10,49,0,57,59,120,0,0,18,109,0,16,10,49,0,57,59,
-121,0,0,18,109,0,16,10,50,0,57,59,120,0,0,18,109,0,16,10,50,0,57,59,121,0,0,0,20,0,0,1,90,95,0,0,
-27,0,1,1,1,0,0,31,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,51,120,50,0,0,18,
-109,0,16,8,48,0,57,59,120,0,0,18,109,0,16,8,48,0,57,59,121,0,0,18,109,0,16,10,49,0,57,59,120,0,0,
-18,109,0,16,10,49,0,57,59,121,0,0,18,109,0,16,10,50,0,57,59,120,0,0,18,109,0,16,10,50,0,57,59,121,
-0,0,0,20,0,0,1,90,95,0,0,27,0,1,1,1,0,0,15,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,
-97,116,51,120,50,0,0,18,109,0,16,8,48,0,57,59,120,0,0,18,109,0,16,8,48,0,57,59,121,0,0,18,109,0,16,
-10,49,0,57,59,120,0,0,18,109,0,16,10,49,0,57,59,121,0,0,17,48,0,48,0,0,0,17,48,0,48,0,0,0,0,20,0,0,
-1,90,95,0,0,27,0,1,1,1,0,0,13,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,51,
-120,50,0,0,18,109,0,16,8,48,0,57,0,18,109,0,16,10,49,0,57,0,58,118,101,99,50,0,0,17,48,0,48,0,0,0,
-0,0,0,20,0,0,1,90,95,0,0,27,0,1,1,1,0,0,26,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,
-97,116,51,120,50,0,0,18,109,0,16,8,48,0,57,59,120,0,0,18,109,0,16,8,48,0,57,59,121,0,0,18,109,0,16,
-10,49,0,57,59,120,0,0,18,109,0,16,10,49,0,57,59,121,0,0,17,48,0,48,0,0,0,17,48,0,48,0,0,0,0,20,0,0,
-1,90,95,0,0,27,0,1,1,1,0,0,28,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,51,
-120,50,0,0,18,109,0,16,8,48,0,57,59,120,0,0,18,109,0,16,8,48,0,57,59,121,0,0,18,109,0,16,10,49,0,
-57,59,120,0,0,18,109,0,16,10,49,0,57,59,121,0,0,17,48,0,48,0,0,0,17,48,0,48,0,0,0,0,20,0,0,1,90,95,
-0,0,14,0,1,1,1,0,0,14,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,109,0,20,0,0,1,90,95,0,0,
-14,0,1,1,1,0,0,31,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,51,0,0,18,109,0,
-16,8,48,0,57,0,18,109,0,16,10,49,0,57,0,18,109,0,16,10,50,0,57,0,0,20,0,0,1,90,95,0,0,14,0,1,1,1,0,
-0,30,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,51,0,0,18,109,0,16,8,48,0,57,
-59,120,121,122,0,0,18,109,0,16,10,49,0,57,59,120,121,122,0,0,18,109,0,16,10,50,0,57,59,120,121,122,
-0,0,0,20,0,0,1,90,95,0,0,14,0,1,1,1,0,0,15,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,
-97,116,51,0,0,18,109,0,16,8,48,0,57,59,120,121,122,0,0,18,109,0,16,10,49,0,57,59,120,121,122,0,0,
-18,109,0,16,10,50,0,57,59,120,121,122,0,0,0,20,0,0,1,90,95,0,0,14,0,1,1,1,0,0,26,0,109,0,0,0,1,9,
-18,95,95,114,101,116,86,97,108,0,58,109,97,116,51,0,0,18,109,0,16,8,48,0,57,0,18,109,0,16,10,49,0,
-57,0,17,48,0,0,0,0,17,48,0,0,0,0,17,49,0,0,0,0,0,20,0,0,1,90,95,0,0,14,0,1,1,1,0,0,28,0,109,0,0,0,
-1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,51,0,0,18,109,0,16,8,48,0,57,59,120,121,122,0,0,
-18,109,0,16,10,49,0,57,59,120,121,122,0,0,17,48,0,0,0,0,17,48,0,0,0,0,17,49,0,0,0,0,0,20,0,0,1,90,
-95,0,0,14,0,1,1,1,0,0,27,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,51,0,0,18,
-109,0,16,8,48,0,57,0,17,48,0,0,0,0,18,109,0,16,10,49,0,57,0,17,48,0,0,0,0,18,109,0,16,10,50,0,57,0,
-17,49,0,0,0,0,0,20,0,0,1,90,95,0,0,14,0,1,1,1,0,0,29,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,
-108,0,58,109,97,116,51,0,0,18,109,0,16,8,48,0,57,0,17,48,0,0,0,0,18,109,0,16,10,49,0,57,0,17,48,0,
-0,0,0,18,109,0,16,10,50,0,57,0,17,49,0,0,0,0,0,20,0,0,1,90,95,0,0,14,0,1,1,1,0,0,13,0,109,0,0,0,1,
-9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,51,0,0,18,109,0,16,8,48,0,57,0,17,48,0,0,0,0,18,
-109,0,16,10,49,0,57,0,17,48,0,0,0,0,17,48,0,0,0,0,17,48,0,0,0,0,17,49,0,0,0,0,0,20,0,0,1,90,95,0,0,
-30,0,1,1,1,0,0,30,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,109,0,20,0,0,1,90,95,0,0,30,
-0,1,1,1,0,0,15,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,51,120,52,0,0,18,109,
-0,16,8,48,0,57,0,18,109,0,16,10,49,0,57,0,18,109,0,16,10,50,0,57,0,0,20,0,0,1,90,95,0,0,30,0,1,1,1,
-0,0,14,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,51,120,52,0,0,18,109,0,16,8,
-48,0,57,0,17,48,0,0,0,0,18,109,0,16,10,49,0,57,0,17,48,0,0,0,0,18,109,0,16,10,50,0,57,0,17,48,0,0,
-0,0,0,20,0,0,1,90,95,0,0,30,0,1,1,1,0,0,31,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,
-97,116,51,120,52,0,0,18,109,0,16,8,48,0,57,0,17,48,0,0,0,0,18,109,0,16,10,49,0,57,0,17,48,0,0,0,0,
-18,109,0,16,10,50,0,57,0,17,48,0,0,0,0,0,20,0,0,1,90,95,0,0,30,0,1,1,1,0,0,28,0,109,0,0,0,1,9,18,
-95,95,114,101,116,86,97,108,0,58,109,97,116,51,120,52,0,0,18,109,0,16,8,48,0,57,0,18,109,0,16,10,
-49,0,57,0,17,48,0,0,0,0,17,48,0,0,0,0,17,49,0,0,0,0,17,48,0,0,0,0,0,20,0,0,1,90,95,0,0,30,0,1,1,1,
-0,0,26,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,51,120,52,0,0,18,109,0,16,8,
-48,0,57,0,17,48,0,0,0,0,18,109,0,16,10,49,0,57,0,17,48,0,0,0,0,17,48,0,0,0,0,17,48,0,0,0,0,17,49,0,
-0,0,0,17,48,0,0,0,0,0,20,0,0,1,90,95,0,0,30,0,1,1,1,0,0,27,0,109,0,0,0,1,9,18,95,95,114,101,116,86,
-97,108,0,58,109,97,116,51,120,52,0,0,18,109,0,16,8,48,0,57,0,17,48,0,0,0,0,17,48,0,0,0,0,18,109,0,
-16,10,49,0,57,0,17,48,0,0,0,0,17,48,0,0,0,0,18,109,0,16,10,50,0,57,0,17,49,0,0,0,0,17,48,0,0,0,0,0,
-20,0,0,1,90,95,0,0,30,0,1,1,1,0,0,29,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,
-116,51,120,52,0,0,18,109,0,16,8,48,0,57,0,17,48,0,0,0,0,17,48,0,0,0,0,18,109,0,16,10,49,0,57,0,17,
-48,0,0,0,0,17,48,0,0,0,0,18,109,0,16,10,50,0,57,0,17,49,0,0,0,0,17,48,0,0,0,0,0,20,0,0,1,90,95,0,0,
-30,0,1,1,1,0,0,13,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,51,120,52,0,0,18,
-109,0,16,8,48,0,57,0,17,48,0,0,0,0,17,48,0,0,0,0,18,109,0,16,10,49,0,57,0,17,48,0,0,0,0,17,48,0,0,
-0,0,17,48,0,0,0,0,17,48,0,0,0,0,17,49,0,0,0,0,17,48,0,0,0,0,0,20,0,0,1,90,95,0,0,29,0,1,1,1,0,0,29,
-0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,109,0,20,0,0,1,90,95,0,0,29,0,1,1,1,0,0,31,0,
-109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,52,120,50,0,0,18,109,0,16,8,48,0,57,
-59,120,121,0,0,18,109,0,16,10,49,0,57,59,120,121,0,0,18,109,0,16,10,50,0,57,59,120,121,0,0,18,109,
-0,16,10,51,0,57,59,120,121,0,0,0,20,0,0,1,90,95,0,0,29,0,1,1,1,0,0,15,0,109,0,0,0,1,9,18,95,95,114,
-101,116,86,97,108,0,58,109,97,116,52,120,50,0,0,18,109,0,16,8,48,0,57,59,120,121,0,0,18,109,0,16,
-10,49,0,57,59,120,121,0,0,18,109,0,16,10,50,0,57,59,120,121,0,0,18,109,0,16,10,51,0,57,59,120,121,
-0,0,0,20,0,0,1,90,95,0,0,29,0,1,1,1,0,0,27,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,
-97,116,52,120,50,0,0,18,109,0,16,8,48,0,57,0,18,109,0,16,10,49,0,57,0,17,48,0,0,0,0,17,48,0,0,0,0,
-0,20,0,0,1,90,95,0,0,29,0,1,1,1,0,0,14,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,
-116,52,120,50,0,0,18,109,0,16,8,48,0,57,59,120,121,0,0,18,109,0,16,10,49,0,57,59,120,121,0,0,18,
-109,0,16,10,50,0,57,59,120,121,0,0,17,48,0,0,0,0,17,48,0,0,0,0,0,20,0,0,1,90,95,0,0,29,0,1,1,1,0,0,
-30,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,52,120,50,0,0,18,109,0,16,8,48,0,
-57,59,120,121,0,0,18,109,0,16,10,49,0,57,59,120,121,0,0,18,109,0,16,10,50,0,57,59,120,121,0,0,17,
-48,0,0,0,0,17,48,0,0,0,0,0,20,0,0,1,90,95,0,0,29,0,1,1,1,0,0,13,0,109,0,0,0,1,9,18,95,95,114,101,
-116,86,97,108,0,58,109,97,116,52,120,50,0,0,18,109,0,16,8,48,0,57,0,18,109,0,16,10,49,0,57,0,17,48,
-0,0,0,0,17,48,0,0,0,0,17,48,0,0,0,0,17,48,0,0,0,0,0,20,0,0,1,90,95,0,0,29,0,1,1,1,0,0,26,0,109,0,0,
-0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,52,120,50,0,0,18,109,0,16,8,48,0,57,59,120,
-121,0,0,18,109,0,16,10,49,0,57,59,120,121,0,0,17,48,0,0,0,0,17,48,0,0,0,0,17,48,0,0,0,0,17,48,0,0,
-0,0,0,20,0,0,1,90,95,0,0,29,0,1,1,1,0,0,28,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,
-97,116,52,120,50,0,0,18,109,0,16,8,48,0,57,59,120,121,0,0,18,109,0,16,10,49,0,57,59,120,121,0,0,17,
-48,0,0,0,0,17,48,0,0,0,0,17,48,0,0,0,0,17,48,0,0,0,0,0,20,0,0,1,90,95,0,0,31,0,1,1,1,0,0,31,0,109,
-0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,109,0,20,0,0,1,90,95,0,0,31,0,1,1,1,0,0,15,0,109,0,0,
-0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,52,120,51,0,0,18,109,0,16,8,48,0,57,59,120,
-121,122,0,0,18,109,0,16,10,49,0,57,59,120,121,122,0,0,18,109,0,16,10,50,0,57,59,120,121,122,0,0,18,
-109,0,16,10,51,0,57,59,120,121,122,0,0,0,20,0,0,1,90,95,0,0,31,0,1,1,1,0,0,14,0,109,0,0,0,1,9,18,
-95,95,114,101,116,86,97,108,0,58,109,97,116,52,120,51,0,0,18,109,0,16,8,48,0,57,0,18,109,0,16,10,
-49,0,57,0,18,109,0,16,10,50,0,57,0,17,48,0,0,0,0,17,48,0,0,0,0,17,48,0,0,0,0,0,20,0,0,1,90,95,0,0,
-31,0,1,1,1,0,0,30,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,52,120,51,0,0,18,
-109,0,16,8,48,0,57,59,120,121,122,0,0,18,109,0,16,10,49,0,57,59,120,121,122,0,0,18,109,0,16,10,50,
-0,57,59,120,121,122,0,0,17,48,0,0,0,0,17,48,0,0,0,0,17,48,0,0,0,0,0,20,0,0,1,90,95,0,0,31,0,1,1,1,
-0,0,29,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,52,120,51,0,0,18,109,0,16,8,
-48,0,57,0,17,48,0,0,0,0,18,109,0,16,10,49,0,57,0,17,48,0,0,0,0,18,109,0,16,10,50,0,57,0,17,49,0,0,
-0,0,18,109,0,16,10,51,0,57,0,17,48,0,0,0,0,0,20,0,0,1,90,95,0,0,31,0,1,1,1,0,0,26,0,109,0,0,0,1,9,
-18,95,95,114,101,116,86,97,108,0,58,109,97,116,52,120,51,0,0,18,109,0,16,8,48,0,57,0,18,109,0,16,
-10,49,0,57,0,17,48,0,0,0,0,17,48,0,0,0,0,17,49,0,0,0,0,17,48,0,0,0,0,17,48,0,0,0,0,17,48,0,0,0,0,0,
-20,0,0,1,90,95,0,0,31,0,1,1,1,0,0,27,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,
-116,52,120,51,0,0,18,109,0,16,8,48,0,57,0,17,48,0,0,0,0,18,109,0,16,10,49,0,57,0,17,48,0,0,0,0,18,
-109,0,16,10,50,0,57,0,17,49,0,0,0,0,17,48,0,0,0,0,17,48,0,0,0,0,17,48,0,0,0,0,0,20,0,0,1,90,95,0,0,
-31,0,1,1,1,0,0,28,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,52,120,51,0,0,18,
-109,0,16,8,48,0,57,59,120,121,122,0,0,18,109,0,16,10,49,0,57,59,120,121,122,0,0,17,48,0,0,0,0,17,
-48,0,0,0,0,17,49,0,0,0,0,17,48,0,0,0,0,17,48,0,0,0,0,17,48,0,0,0,0,0,20,0,0,1,90,95,0,0,31,0,1,1,1,
-0,0,13,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,52,120,51,0,0,18,109,0,16,8,
-48,0,57,0,17,48,0,0,0,0,18,109,0,16,10,49,0,57,0,17,48,0,0,0,0,17,48,0,0,0,0,17,48,0,0,0,0,17,49,0,
-0,0,0,17,48,0,0,0,0,17,48,0,0,0,0,17,48,0,0,0,0,0,20,0,0,1,90,95,0,0,15,0,1,1,1,0,0,15,0,109,0,0,0,
-1,9,18,95,95,114,101,116,86,97,108,0,18,109,0,20,0,0,1,90,95,0,0,15,0,1,1,1,0,0,30,0,109,0,0,0,1,9,
-18,95,95,114,101,116,86,97,108,0,58,109,97,116,52,0,0,18,109,0,16,8,48,0,57,0,18,109,0,16,10,49,0,
-57,0,18,109,0,16,10,50,0,57,0,17,48,0,0,0,0,17,48,0,0,0,0,17,48,0,0,0,0,17,49,0,0,0,0,0,20,0,0,1,
-90,95,0,0,15,0,1,1,1,0,0,31,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,52,0,0,
-18,109,0,16,8,48,0,57,0,17,48,0,0,0,0,18,109,0,16,10,49,0,57,0,17,48,0,0,0,0,18,109,0,16,10,50,0,
-57,0,17,48,0,0,0,0,18,109,0,16,10,51,0,57,0,17,49,0,0,0,0,0,20,0,0,1,90,95,0,0,15,0,1,1,1,0,0,28,0,
-109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,52,0,0,18,109,0,16,8,48,0,57,0,18,109,
-0,16,10,49,0,57,0,17,48,0,0,0,0,17,48,0,0,0,0,17,49,0,0,0,0,17,48,0,0,0,0,17,48,0,0,0,0,17,48,0,0,
-0,0,17,48,0,0,0,0,17,49,0,0,0,0,0,20,0,0,1,90,95,0,0,15,0,1,1,1,0,0,29,0,109,0,0,0,1,9,18,95,95,
-114,101,116,86,97,108,0,58,109,97,116,52,0,0,18,109,0,16,8,48,0,57,0,17,48,0,0,0,0,17,48,0,0,0,0,
-18,109,0,16,10,49,0,57,0,17,48,0,0,0,0,17,48,0,0,0,0,18,109,0,16,10,50,0,57,0,17,49,0,0,0,0,17,48,
-0,0,0,0,18,109,0,16,10,51,0,57,0,17,48,0,0,0,0,17,49,0,0,0,0,0,20,0,0,1,90,95,0,0,15,0,1,1,1,0,0,
-14,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,52,0,0,18,109,0,16,8,48,0,57,0,
-17,48,0,0,0,0,18,109,0,16,10,49,0,57,0,17,48,0,0,0,0,18,109,0,16,10,50,0,57,0,17,48,0,0,0,0,17,48,
-0,0,0,0,17,48,0,0,0,0,17,48,0,0,0,0,17,49,0,0,0,0,0,20,0,0,1,90,95,0,0,15,0,1,1,1,0,0,26,0,109,0,0,
-0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,52,0,0,18,109,0,16,8,48,0,57,0,17,48,0,0,0,0,
-18,109,0,16,10,49,0,57,0,17,48,0,0,0,0,17,48,0,0,0,0,17,48,0,0,0,0,17,49,0,0,0,0,17,48,0,0,0,0,17,
-48,0,0,0,0,17,48,0,0,0,0,17,48,0,0,0,0,17,49,0,0,0,0,0,20,0,0,1,90,95,0,0,15,0,1,1,1,0,0,27,0,109,
-0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,52,0,0,18,109,0,16,8,48,0,57,0,17,48,0,0,
-0,0,17,48,0,0,0,0,18,109,0,16,10,49,0,57,0,17,48,0,0,0,0,17,48,0,0,0,0,18,109,0,16,10,50,0,57,0,17,
-49,0,0,0,0,17,48,0,0,0,0,17,48,0,0,0,0,17,48,0,0,0,0,17,48,0,0,0,0,17,49,0,0,0,0,0,20,0,0,1,90,95,
-0,0,15,0,1,1,1,0,0,13,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,109,97,116,52,0,0,18,109,
-0,16,8,48,0,57,0,17,48,0,0,0,0,17,48,0,0,0,0,18,109,0,16,10,49,0,57,0,17,48,0,0,0,0,17,48,0,0,0,0,
-17,48,0,0,0,0,17,48,0,0,0,0,17,49,0,0,0,0,17,48,0,0,0,0,17,48,0,0,0,0,17,48,0,0,0,0,17,48,0,0,0,0,
-17,49,0,0,0,0,0,20,0,0,1,90,95,0,0,0,0,2,1,1,0,2,0,26,0,109,0,0,1,1,0,0,26,0,110,0,0,0,1,9,18,109,
-0,16,8,48,0,57,18,110,0,16,8,48,0,57,21,0,9,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,21,0,0,1,
-90,95,0,0,0,0,2,1,1,0,2,0,28,0,109,0,0,1,1,0,0,28,0,110,0,0,0,1,9,18,109,0,16,8,48,0,57,18,110,0,
-16,8,48,0,57,21,0,9,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,21,0,0,1,90,95,0,0,0,0,2,1,1,0,2,
-0,27,0,109,0,0,1,1,0,0,27,0,110,0,0,0,1,9,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,21,0,9,18,
-109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,21,0,9,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,21,
-0,0,1,90,95,0,0,0,0,2,1,1,0,2,0,30,0,109,0,0,1,1,0,0,30,0,110,0,0,0,1,9,18,109,0,16,8,48,0,57,18,
-110,0,16,8,48,0,57,21,0,9,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,21,0,9,18,109,0,16,10,50,0,
-57,18,110,0,16,10,50,0,57,21,0,0,1,90,95,0,0,0,0,2,1,1,0,2,0,29,0,109,0,0,1,1,0,0,29,0,110,0,0,0,1,
-9,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,21,0,9,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,
-21,0,9,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,21,0,9,18,109,0,16,10,51,0,57,18,110,0,16,10,
-51,0,57,21,0,0,1,90,95,0,0,0,0,2,1,1,0,2,0,31,0,109,0,0,1,1,0,0,31,0,110,0,0,0,1,9,18,109,0,16,8,
-48,0,57,18,110,0,16,8,48,0,57,21,0,9,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,21,0,9,18,109,0,
-16,10,50,0,57,18,110,0,16,10,50,0,57,21,0,9,18,109,0,16,10,51,0,57,18,110,0,16,10,51,0,57,21,0,0,1,
-90,95,0,0,0,0,2,2,1,0,2,0,26,0,109,0,0,1,1,0,0,26,0,110,0,0,0,1,9,18,109,0,16,8,48,0,57,18,110,0,
-16,8,48,0,57,22,0,9,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,22,0,0,1,90,95,0,0,0,0,2,2,1,0,2,
-0,28,0,109,0,0,1,1,0,0,28,0,110,0,0,0,1,9,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,22,0,9,18,
-109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,22,0,0,1,90,95,0,0,0,0,2,2,1,0,2,0,27,0,109,0,0,1,1,0,0,
-27,0,110,0,0,0,1,9,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,22,0,9,18,109,0,16,10,49,0,57,18,
-110,0,16,10,49,0,57,22,0,9,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,22,0,0,1,90,95,0,0,0,0,2,
-2,1,0,2,0,30,0,109,0,0,1,1,0,0,30,0,110,0,0,0,1,9,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,22,0,
-9,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,22,0,9,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,
-57,22,0,0,1,90,95,0,0,0,0,2,2,1,0,2,0,29,0,109,0,0,1,1,0,0,29,0,110,0,0,0,1,9,18,109,0,16,8,48,0,
-57,18,110,0,16,8,48,0,57,22,0,9,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,22,0,9,18,109,0,16,
-10,50,0,57,18,110,0,16,10,50,0,57,22,0,9,18,109,0,16,10,51,0,57,18,110,0,16,10,51,0,57,22,0,0,1,90,
-95,0,0,0,0,2,2,1,0,2,0,31,0,109,0,0,1,1,0,0,31,0,110,0,0,0,1,9,18,109,0,16,8,48,0,57,18,110,0,16,8,
-48,0,57,22,0,9,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,22,0,9,18,109,0,16,10,50,0,57,18,110,
-0,16,10,50,0,57,22,0,9,18,109,0,16,10,51,0,57,18,110,0,16,10,51,0,57,22,0,0,1,90,95,0,0,0,0,2,4,1,
-0,2,0,26,0,109,0,0,1,1,0,0,26,0,110,0,0,0,1,9,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,24,0,9,
-18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,24,0,0,1,90,95,0,0,0,0,2,4,1,0,2,0,28,0,109,0,0,1,1,
-0,0,28,0,110,0,0,0,1,9,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,24,0,9,18,109,0,16,10,49,0,57,
-18,110,0,16,10,49,0,57,24,0,0,1,90,95,0,0,0,0,2,4,1,0,2,0,27,0,109,0,0,1,1,0,0,27,0,110,0,0,0,1,9,
-18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,24,0,9,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,
-24,0,9,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,24,0,0,1,90,95,0,0,0,0,2,4,1,0,2,0,30,0,109,0,
-0,1,1,0,0,30,0,110,0,0,0,1,9,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,24,0,9,18,109,0,16,10,49,
-0,57,18,110,0,16,10,49,0,57,24,0,9,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,24,0,0,1,90,95,0,
-0,0,0,2,4,1,0,2,0,29,0,109,0,0,1,1,0,0,29,0,110,0,0,0,1,9,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,
-57,24,0,9,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,24,0,9,18,109,0,16,10,50,0,57,18,110,0,16,
-10,50,0,57,24,0,9,18,109,0,16,10,51,0,57,18,110,0,16,10,51,0,57,24,0,0,1,90,95,0,0,0,0,2,4,1,0,2,0,
-31,0,109,0,0,1,1,0,0,31,0,110,0,0,0,1,9,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,24,0,9,18,109,
-0,16,10,49,0,57,18,110,0,16,10,49,0,57,24,0,9,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,24,0,9,
-18,109,0,16,10,51,0,57,18,110,0,16,10,51,0,57,24,0,0,1,90,95,0,0,11,0,2,21,1,1,0,0,26,0,109,0,0,1,
-1,0,0,10,0,118,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,18,118,0,59,120,0,18,109,0,16,8,
-48,0,57,59,120,0,48,18,118,0,59,121,0,18,109,0,16,10,49,0,57,59,120,0,48,46,20,0,9,18,95,95,114,
-101,116,86,97,108,0,59,121,0,18,118,0,59,120,0,18,109,0,16,8,48,0,57,59,121,0,48,18,118,0,59,121,0,
-18,109,0,16,10,49,0,57,59,121,0,48,46,20,0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,18,118,0,59,
-120,0,18,109,0,16,8,48,0,57,59,122,0,48,18,118,0,59,121,0,18,109,0,16,10,49,0,57,59,122,0,48,46,20,
-0,0,1,90,95,0,0,12,0,2,21,1,1,0,0,28,0,109,0,0,1,1,0,0,10,0,118,0,0,0,1,9,18,95,95,114,101,116,86,
-97,108,0,59,120,0,18,118,0,59,120,0,18,109,0,16,8,48,0,57,59,120,0,48,18,118,0,59,121,0,18,109,0,
-16,10,49,0,57,59,120,0,48,46,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,18,118,0,59,120,0,18,
-109,0,16,8,48,0,57,59,121,0,48,18,118,0,59,121,0,18,109,0,16,10,49,0,57,59,121,0,48,46,20,0,9,18,
-95,95,114,101,116,86,97,108,0,59,122,0,18,118,0,59,120,0,18,109,0,16,8,48,0,57,59,122,0,48,18,118,
-0,59,121,0,18,109,0,16,10,49,0,57,59,122,0,48,46,20,0,9,18,95,95,114,101,116,86,97,108,0,59,119,0,
-18,118,0,59,120,0,18,109,0,16,8,48,0,57,59,119,0,48,18,118,0,59,121,0,18,109,0,16,10,49,0,57,59,
-119,0,48,46,20,0,0,1,90,95,0,0,10,0,2,21,1,1,0,0,27,0,109,0,0,1,1,0,0,11,0,118,0,0,0,1,9,18,95,95,
-114,101,116,86,97,108,0,59,120,0,18,118,0,59,120,0,18,109,0,16,8,48,0,57,59,120,0,48,18,118,0,59,
-121,0,18,109,0,16,10,49,0,57,59,120,0,48,46,18,118,0,59,122,0,18,109,0,16,10,50,0,57,59,120,0,48,
-46,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,18,118,0,59,120,0,18,109,0,16,8,48,0,57,59,121,
-0,48,18,118,0,59,121,0,18,109,0,16,10,49,0,57,59,121,0,48,46,18,118,0,59,122,0,18,109,0,16,10,50,0,
-57,59,121,0,48,46,20,0,0,1,90,95,0,0,12,0,2,21,1,1,0,0,30,0,109,0,0,1,1,0,0,11,0,118,0,0,0,1,9,18,
-95,95,114,101,116,86,97,108,0,59,120,0,18,118,0,59,120,0,18,109,0,16,8,48,0,57,59,120,0,48,18,118,
-0,59,121,0,18,109,0,16,10,49,0,57,59,120,0,48,46,18,118,0,59,122,0,18,109,0,16,10,50,0,57,59,120,0,
-48,46,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,18,118,0,59,120,0,18,109,0,16,8,48,0,57,59,
-121,0,48,18,118,0,59,121,0,18,109,0,16,10,49,0,57,59,121,0,48,46,18,118,0,59,122,0,18,109,0,16,10,
-50,0,57,59,121,0,48,46,20,0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,18,118,0,59,120,0,18,109,0,
-16,8,48,0,57,59,122,0,48,18,118,0,59,121,0,18,109,0,16,10,49,0,57,59,122,0,48,46,18,118,0,59,122,0,
-18,109,0,16,10,50,0,57,59,122,0,48,46,20,0,9,18,95,95,114,101,116,86,97,108,0,59,119,0,18,118,0,59,
-120,0,18,109,0,16,8,48,0,57,59,119,0,48,18,118,0,59,121,0,18,109,0,16,10,49,0,57,59,119,0,48,46,18,
-118,0,59,122,0,18,109,0,16,10,50,0,57,59,119,0,48,46,20,0,0,1,90,95,0,0,10,0,2,21,1,1,0,0,29,0,109,
-0,0,1,1,0,0,12,0,118,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,18,118,0,59,120,0,18,109,
-0,16,8,48,0,57,59,120,0,48,18,118,0,59,121,0,18,109,0,16,10,49,0,57,59,120,0,48,46,18,118,0,59,122,
-0,18,109,0,16,10,50,0,57,59,120,0,48,46,18,118,0,59,119,0,18,109,0,16,10,51,0,57,59,120,0,48,46,20,
-0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,18,118,0,59,120,0,18,109,0,16,8,48,0,57,59,121,0,48,
-18,118,0,59,121,0,18,109,0,16,10,49,0,57,59,121,0,48,46,18,118,0,59,122,0,18,109,0,16,10,50,0,57,
-59,121,0,48,46,18,118,0,59,119,0,18,109,0,16,10,51,0,57,59,121,0,48,46,20,0,0,1,90,95,0,0,11,0,2,
-21,1,1,0,0,31,0,109,0,0,1,1,0,0,12,0,118,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,18,
-118,0,59,120,0,18,109,0,16,8,48,0,57,59,120,0,48,18,118,0,59,121,0,18,109,0,16,10,49,0,57,59,120,0,
-48,46,18,118,0,59,122,0,18,109,0,16,10,50,0,57,59,120,0,48,46,18,118,0,59,119,0,18,109,0,16,10,51,
-0,57,59,120,0,48,46,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,18,118,0,59,120,0,18,109,0,16,
-8,48,0,57,59,121,0,48,18,118,0,59,121,0,18,109,0,16,10,49,0,57,59,121,0,48,46,18,118,0,59,122,0,18,
-109,0,16,10,50,0,57,59,121,0,48,46,18,118,0,59,119,0,18,109,0,16,10,51,0,57,59,121,0,48,46,20,0,9,
-18,95,95,114,101,116,86,97,108,0,59,122,0,18,118,0,59,120,0,18,109,0,16,8,48,0,57,59,122,0,48,18,
-118,0,59,121,0,18,109,0,16,10,49,0,57,59,122,0,48,46,18,118,0,59,122,0,18,109,0,16,10,50,0,57,59,
-122,0,48,46,18,118,0,59,119,0,18,109,0,16,10,51,0,57,59,122,0,48,46,20,0,0,1,90,95,0,0,27,0,2,21,1,
-1,0,0,13,0,109,0,0,1,1,0,0,27,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,
-0,18,110,0,16,8,48,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,18,110,0,
-16,10,49,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,109,0,18,110,0,16,10,50,
-0,57,48,20,0,0,1,90,95,0,0,29,0,2,21,1,1,0,0,13,0,109,0,0,1,1,0,0,29,0,110,0,0,0,1,9,18,95,95,114,
-101,116,86,97,108,0,16,8,48,0,57,18,109,0,18,110,0,16,8,48,0,57,48,20,0,9,18,95,95,114,101,116,86,
-97,108,0,16,10,49,0,57,18,109,0,18,110,0,16,10,49,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,
-16,10,50,0,57,18,109,0,18,110,0,16,10,50,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,51,
-0,57,18,109,0,18,110,0,16,10,51,0,57,48,20,0,0,1,90,95,0,0,26,0,2,21,1,1,0,0,26,0,109,0,0,1,1,0,0,
-13,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,18,110,0,16,8,48,0,57,48,
-20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,18,110,0,16,10,49,0,57,48,20,0,0,1,
-90,95,0,0,14,0,2,21,1,1,0,0,26,0,109,0,0,1,1,0,0,27,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,108,
-0,16,8,48,0,57,18,109,0,18,110,0,16,8,48,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,
-0,57,18,109,0,18,110,0,16,10,49,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,
-109,0,18,110,0,16,10,50,0,57,48,20,0,0,1,90,95,0,0,31,0,2,21,1,1,0,0,26,0,109,0,0,1,1,0,0,29,0,110,
-0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,18,110,0,16,8,48,0,57,48,20,0,9,
-18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,18,110,0,16,10,49,0,57,48,20,0,9,18,95,95,
-114,101,116,86,97,108,0,16,10,50,0,57,18,109,0,18,110,0,16,10,50,0,57,48,20,0,9,18,95,95,114,101,
-116,86,97,108,0,16,10,51,0,57,18,109,0,18,110,0,16,10,51,0,57,48,20,0,0,1,90,95,0,0,28,0,2,21,1,1,
-0,0,28,0,109,0,0,1,1,0,0,13,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,
-18,110,0,16,8,48,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,18,110,0,
-16,10,49,0,57,48,20,0,0,1,90,95,0,0,30,0,2,21,1,1,0,0,28,0,109,0,0,1,1,0,0,27,0,110,0,0,0,1,9,18,
-95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,18,110,0,16,8,48,0,57,48,20,0,9,18,95,95,114,
-101,116,86,97,108,0,16,10,49,0,57,18,109,0,18,110,0,16,10,49,0,57,48,20,0,9,18,95,95,114,101,116,
-86,97,108,0,16,10,50,0,57,18,109,0,18,110,0,16,10,50,0,57,48,20,0,0,1,90,95,0,0,15,0,2,21,1,1,0,0,
-28,0,109,0,0,1,1,0,0,29,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,18,
-110,0,16,8,48,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,18,110,0,16,
-10,49,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,109,0,18,110,0,16,10,50,0,
-57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,51,0,57,18,109,0,18,110,0,16,10,51,0,57,48,20,
-0,0,1,90,95,0,0,13,0,2,21,1,1,0,0,27,0,109,0,0,1,1,0,0,26,0,110,0,0,0,1,9,18,95,95,114,101,116,86,
-97,108,0,16,8,48,0,57,18,109,0,18,110,0,16,8,48,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,
-10,49,0,57,18,109,0,18,110,0,16,10,49,0,57,48,20,0,0,1,90,95,0,0,27,0,2,21,1,1,0,0,27,0,109,0,0,1,
-1,0,0,14,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,18,110,0,16,8,48,0,
-57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,18,110,0,16,10,49,0,57,48,20,
-0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,109,0,18,110,0,16,10,50,0,57,48,20,0,0,1,90,
-95,0,0,29,0,2,21,1,1,0,0,27,0,109,0,0,1,1,0,0,31,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,
-16,8,48,0,57,18,109,0,18,110,0,16,8,48,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,
-57,18,109,0,18,110,0,16,10,49,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,109,
-0,18,110,0,16,10,50,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,51,0,57,18,109,0,18,110,
-0,16,10,51,0,57,48,20,0,0,1,90,95,0,0,26,0,2,21,1,1,0,0,14,0,109,0,0,1,1,0,0,26,0,110,0,0,0,1,9,18,
-95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,18,110,0,16,8,48,0,57,48,20,0,9,18,95,95,114,
-101,116,86,97,108,0,16,10,49,0,57,18,109,0,18,110,0,16,10,49,0,57,48,20,0,0,1,90,95,0,0,31,0,2,21,
-1,1,0,0,14,0,109,0,0,1,1,0,0,31,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,
-109,0,18,110,0,16,8,48,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,18,
-110,0,16,10,49,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,109,0,18,110,0,16,
-10,50,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,51,0,57,18,109,0,18,110,0,16,10,51,0,
-57,48,20,0,0,1,90,95,0,0,28,0,2,21,1,1,0,0,30,0,109,0,0,1,1,0,0,26,0,110,0,0,0,1,9,18,95,95,114,
-101,116,86,97,108,0,16,8,48,0,57,18,109,0,18,110,0,16,8,48,0,57,48,20,0,9,18,95,95,114,101,116,86,
-97,108,0,16,10,49,0,57,18,109,0,18,110,0,16,10,49,0,57,48,20,0,0,1,90,95,0,0,30,0,2,21,1,1,0,0,30,
-0,109,0,0,1,1,0,0,14,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,18,110,
-0,16,8,48,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,18,110,0,16,10,49,
-0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,109,0,18,110,0,16,10,50,0,57,48,
-20,0,0,1,90,95,0,0,15,0,2,21,1,1,0,0,30,0,109,0,0,1,1,0,0,31,0,110,0,0,0,1,9,18,95,95,114,101,116,
-86,97,108,0,16,8,48,0,57,18,109,0,18,110,0,16,8,48,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,
-16,10,49,0,57,18,109,0,18,110,0,16,10,49,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,
-0,57,18,109,0,18,110,0,16,10,50,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,51,0,57,18,
-109,0,18,110,0,16,10,51,0,57,48,20,0,0,1,90,95,0,0,13,0,2,21,1,1,0,0,29,0,109,0,0,1,1,0,0,28,0,110,
-0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,18,110,0,16,8,48,0,57,48,20,0,9,
-18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,18,110,0,16,10,49,0,57,48,20,0,0,1,90,95,0,
-0,27,0,2,21,1,1,0,0,29,0,109,0,0,1,1,0,0,30,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,
-48,0,57,18,109,0,18,110,0,16,8,48,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,
-109,0,18,110,0,16,10,49,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,109,0,18,
-110,0,16,10,50,0,57,48,20,0,0,1,90,95,0,0,29,0,2,21,1,1,0,0,29,0,109,0,0,1,1,0,0,15,0,110,0,0,0,1,
-9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,18,110,0,16,8,48,0,57,48,20,0,9,18,95,95,
-114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,18,110,0,16,10,49,0,57,48,20,0,9,18,95,95,114,101,
-116,86,97,108,0,16,10,50,0,57,18,109,0,18,110,0,16,10,50,0,57,48,20,0,9,18,95,95,114,101,116,86,97,
-108,0,16,10,51,0,57,18,109,0,18,110,0,16,10,51,0,57,48,20,0,0,1,90,95,0,0,26,0,2,21,1,1,0,0,31,0,
-109,0,0,1,1,0,0,28,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,18,110,0,
-16,8,48,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,18,110,0,16,10,49,0,
-57,48,20,0,0,1,90,95,0,0,14,0,2,21,1,1,0,0,31,0,109,0,0,1,1,0,0,30,0,110,0,0,0,1,9,18,95,95,114,
-101,116,86,97,108,0,16,8,48,0,57,18,109,0,18,110,0,16,8,48,0,57,48,20,0,9,18,95,95,114,101,116,86,
-97,108,0,16,10,49,0,57,18,109,0,18,110,0,16,10,49,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,
-16,10,50,0,57,18,109,0,18,110,0,16,10,50,0,57,48,20,0,0,1,90,95,0,0,31,0,2,21,1,1,0,0,31,0,109,0,0,
-1,1,0,0,15,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,18,110,0,16,8,48,
-0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,18,110,0,16,10,49,0,57,48,
-20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,109,0,18,110,0,16,10,50,0,57,48,20,0,9,18,
-95,95,114,101,116,86,97,108,0,16,10,51,0,57,18,109,0,18,110,0,16,10,51,0,57,48,20,0,0,1,90,95,0,0,
-28,0,2,21,1,1,0,0,15,0,109,0,0,1,1,0,0,28,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,
-0,57,18,109,0,18,110,0,16,8,48,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,
-109,0,18,110,0,16,10,49,0,57,48,20,0,0,1,90,95,0,0,30,0,2,21,1,1,0,0,15,0,109,0,0,1,1,0,0,30,0,110,
-0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,18,110,0,16,8,48,0,57,48,20,0,9,
-18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,18,110,0,16,10,49,0,57,48,20,0,9,18,95,95,
-114,101,116,86,97,108,0,16,10,50,0,57,18,109,0,18,110,0,16,10,50,0,57,48,20,0,0,1,90,95,0,0,0,0,2,
-3,1,0,2,0,26,0,109,0,0,1,1,0,0,13,0,110,0,0,0,1,9,18,109,0,18,109,0,18,110,0,48,20,0,0,1,90,95,0,0,
-0,0,2,3,1,0,2,0,28,0,109,0,0,1,1,0,0,13,0,110,0,0,0,1,9,18,109,0,18,109,0,18,110,0,48,20,0,0,1,90,
-95,0,0,0,0,2,3,1,0,2,0,27,0,109,0,0,1,1,0,0,14,0,110,0,0,0,1,9,18,109,0,18,109,0,18,110,0,48,20,0,
-0,1,90,95,0,0,0,0,2,3,1,0,2,0,30,0,109,0,0,1,1,0,0,14,0,110,0,0,0,1,9,18,109,0,18,109,0,18,110,0,
-48,20,0,0,1,90,95,0,0,0,0,2,3,1,0,2,0,29,0,109,0,0,1,1,0,0,15,0,110,0,0,0,1,9,18,109,0,18,109,0,18,
-110,0,48,20,0,0,1,90,95,0,0,0,0,2,3,1,0,2,0,31,0,109,0,0,1,1,0,0,15,0,110,0,0,0,1,9,18,109,0,18,
-109,0,18,110,0,48,20,0,0,1,90,95,0,0,11,0,2,21,1,1,0,0,10,0,118,0,0,1,1,0,0,27,0,109,0,0,0,1,9,18,
-95,95,114,101,116,86,97,108,0,59,120,0,58,100,111,116,0,0,18,118,0,0,18,109,0,16,8,48,0,57,0,0,20,
-0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,58,100,111,116,0,0,18,118,0,0,18,109,0,16,10,49,0,57,
-0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,58,100,111,116,0,0,18,118,0,0,18,109,0,16,10,
-50,0,57,0,0,20,0,0,1,90,95,0,0,12,0,2,21,1,1,0,0,10,0,118,0,0,1,1,0,0,29,0,109,0,0,0,1,9,18,95,95,
-114,101,116,86,97,108,0,59,120,0,58,100,111,116,0,0,18,118,0,0,18,109,0,16,8,48,0,57,0,0,20,0,9,18,
-95,95,114,101,116,86,97,108,0,59,121,0,58,100,111,116,0,0,18,118,0,0,18,109,0,16,10,49,0,57,0,0,20,
-0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,58,100,111,116,0,0,18,118,0,0,18,109,0,16,10,50,0,57,
-0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,119,0,58,100,111,116,0,0,18,118,0,0,18,109,0,16,10,
-51,0,57,0,0,20,0,0,1,90,95,0,0,10,0,2,21,1,1,0,0,11,0,118,0,0,1,1,0,0,26,0,109,0,0,0,1,9,18,95,95,
-114,101,116,86,97,108,0,59,120,0,58,100,111,116,0,0,18,118,0,0,18,109,0,16,8,48,0,57,0,0,20,0,9,18,
-95,95,114,101,116,86,97,108,0,59,121,0,58,100,111,116,0,0,18,118,0,0,18,109,0,16,10,49,0,57,0,0,20,
-0,0,1,90,95,0,0,12,0,2,21,1,1,0,0,11,0,118,0,0,1,1,0,0,31,0,109,0,0,0,1,9,18,95,95,114,101,116,86,
-97,108,0,59,120,0,58,100,111,116,0,0,18,118,0,0,18,109,0,16,8,48,0,57,0,0,20,0,9,18,95,95,114,101,
-116,86,97,108,0,59,121,0,58,100,111,116,0,0,18,118,0,0,18,109,0,16,10,49,0,57,0,0,20,0,9,18,95,95,
-114,101,116,86,97,108,0,59,122,0,58,100,111,116,0,0,18,118,0,0,18,109,0,16,10,50,0,57,0,0,20,0,9,
-18,95,95,114,101,116,86,97,108,0,59,119,0,58,100,111,116,0,0,18,118,0,0,18,109,0,16,10,51,0,57,0,0,
-20,0,0,1,90,95,0,0,10,0,2,21,1,1,0,0,12,0,118,0,0,1,1,0,0,28,0,109,0,0,0,1,9,18,95,95,114,101,116,
-86,97,108,0,59,120,0,58,100,111,116,0,0,18,118,0,0,18,109,0,16,8,48,0,57,0,0,20,0,9,18,95,95,114,
-101,116,86,97,108,0,59,121,0,58,100,111,116,0,0,18,118,0,0,18,109,0,16,10,49,0,57,0,0,20,0,0,1,90,
-95,0,0,11,0,2,21,1,1,0,0,12,0,118,0,0,1,1,0,0,30,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,
-59,120,0,58,100,111,116,0,0,18,118,0,0,18,109,0,16,8,48,0,57,0,0,20,0,9,18,95,95,114,101,116,86,97,
-108,0,59,121,0,58,100,111,116,0,0,18,118,0,0,18,109,0,16,10,49,0,57,0,0,20,0,9,18,95,95,114,101,
-116,86,97,108,0,59,122,0,58,100,111,116,0,0,18,118,0,0,18,109,0,16,10,50,0,57,0,0,20,0,0,1,90,95,0,
-0,0,0,2,1,1,0,2,0,26,0,109,0,0,1,1,0,0,9,0,97,0,0,0,1,9,18,109,0,16,8,48,0,57,18,97,0,21,0,9,18,
-109,0,16,10,49,0,57,18,97,0,21,0,0,1,90,95,0,0,0,0,2,1,1,0,2,0,28,0,109,0,0,1,1,0,0,9,0,97,0,0,0,1,
-9,18,109,0,16,8,48,0,57,18,97,0,21,0,9,18,109,0,16,10,49,0,57,18,97,0,21,0,0,1,90,95,0,0,0,0,2,1,1,
-0,2,0,27,0,109,0,0,1,1,0,0,9,0,97,0,0,0,1,9,18,109,0,16,8,48,0,57,18,97,0,21,0,9,18,109,0,16,10,49,
-0,57,18,97,0,21,0,9,18,109,0,16,10,50,0,57,18,97,0,21,0,0,1,90,95,0,0,0,0,2,1,1,0,2,0,30,0,109,0,0,
-1,1,0,0,9,0,97,0,0,0,1,9,18,109,0,16,8,48,0,57,18,97,0,21,0,9,18,109,0,16,10,49,0,57,18,97,0,21,0,
-9,18,109,0,16,10,50,0,57,18,97,0,21,0,0,1,90,95,0,0,0,0,2,1,1,0,2,0,29,0,109,0,0,1,1,0,0,9,0,97,0,
-0,0,1,9,18,109,0,16,8,48,0,57,18,97,0,21,0,9,18,109,0,16,10,49,0,57,18,97,0,21,0,9,18,109,0,16,10,
-50,0,57,18,97,0,21,0,9,18,109,0,16,10,51,0,57,18,97,0,21,0,0,1,90,95,0,0,0,0,2,1,1,0,2,0,31,0,109,
-0,0,1,1,0,0,9,0,97,0,0,0,1,9,18,109,0,16,8,48,0,57,18,97,0,21,0,9,18,109,0,16,10,49,0,57,18,97,0,
-21,0,9,18,109,0,16,10,50,0,57,18,97,0,21,0,9,18,109,0,16,10,51,0,57,18,97,0,21,0,0,1,90,95,0,0,0,0,
-2,2,1,0,2,0,26,0,109,0,0,1,1,0,0,9,0,97,0,0,0,1,9,18,109,0,16,8,48,0,57,18,97,0,22,0,9,18,109,0,16,
-10,49,0,57,18,97,0,22,0,0,1,90,95,0,0,0,0,2,2,1,0,2,0,28,0,109,0,0,1,1,0,0,9,0,97,0,0,0,1,9,18,109,
-0,16,8,48,0,57,18,97,0,22,0,9,18,109,0,16,10,49,0,57,18,97,0,22,0,0,1,90,95,0,0,0,0,2,2,1,0,2,0,27,
-0,109,0,0,1,1,0,0,9,0,97,0,0,0,1,9,18,109,0,16,8,48,0,57,18,97,0,22,0,9,18,109,0,16,10,49,0,57,18,
-97,0,22,0,9,18,109,0,16,10,50,0,57,18,97,0,22,0,0,1,90,95,0,0,0,0,2,2,1,0,2,0,30,0,109,0,0,1,1,0,0,
-9,0,97,0,0,0,1,9,18,109,0,16,8,48,0,57,18,97,0,22,0,9,18,109,0,16,10,49,0,57,18,97,0,22,0,9,18,109,
-0,16,10,50,0,57,18,97,0,22,0,0,1,90,95,0,0,0,0,2,2,1,0,2,0,29,0,109,0,0,1,1,0,0,9,0,97,0,0,0,1,9,
-18,109,0,16,8,48,0,57,18,97,0,22,0,9,18,109,0,16,10,49,0,57,18,97,0,22,0,9,18,109,0,16,10,50,0,57,
-18,97,0,22,0,9,18,109,0,16,10,51,0,57,18,97,0,22,0,0,1,90,95,0,0,0,0,2,2,1,0,2,0,31,0,109,0,0,1,1,
-0,0,9,0,97,0,0,0,1,9,18,109,0,16,8,48,0,57,18,97,0,22,0,9,18,109,0,16,10,49,0,57,18,97,0,22,0,9,18,
-109,0,16,10,50,0,57,18,97,0,22,0,9,18,109,0,16,10,51,0,57,18,97,0,22,0,0,1,90,95,0,0,0,0,2,3,1,0,2,
-0,26,0,109,0,0,1,1,0,0,9,0,97,0,0,0,1,9,18,109,0,16,8,48,0,57,18,97,0,23,0,9,18,109,0,16,10,49,0,
-57,18,97,0,23,0,0,1,90,95,0,0,0,0,2,3,1,0,2,0,28,0,109,0,0,1,1,0,0,9,0,97,0,0,0,1,9,18,109,0,16,8,
-48,0,57,18,97,0,23,0,9,18,109,0,16,10,49,0,57,18,97,0,23,0,0,1,90,95,0,0,0,0,2,3,1,0,2,0,27,0,109,
-0,0,1,1,0,0,9,0,97,0,0,0,1,9,18,109,0,16,8,48,0,57,18,97,0,23,0,9,18,109,0,16,10,49,0,57,18,97,0,
-23,0,9,18,109,0,16,10,50,0,57,18,97,0,23,0,0,1,90,95,0,0,0,0,2,3,1,0,2,0,30,0,109,0,0,1,1,0,0,9,0,
-97,0,0,0,1,9,18,109,0,16,8,48,0,57,18,97,0,23,0,9,18,109,0,16,10,49,0,57,18,97,0,23,0,9,18,109,0,
-16,10,50,0,57,18,97,0,23,0,0,1,90,95,0,0,0,0,2,3,1,0,2,0,29,0,109,0,0,1,1,0,0,9,0,97,0,0,0,1,9,18,
-109,0,16,8,48,0,57,18,97,0,23,0,9,18,109,0,16,10,49,0,57,18,97,0,23,0,9,18,109,0,16,10,50,0,57,18,
-97,0,23,0,9,18,109,0,16,10,51,0,57,18,97,0,23,0,0,1,90,95,0,0,0,0,2,3,1,0,2,0,31,0,109,0,0,1,1,0,0,
-9,0,97,0,0,0,1,9,18,109,0,16,8,48,0,57,18,97,0,23,0,9,18,109,0,16,10,49,0,57,18,97,0,23,0,9,18,109,
-0,16,10,50,0,57,18,97,0,23,0,9,18,109,0,16,10,51,0,57,18,97,0,23,0,0,1,90,95,0,0,0,0,2,4,1,0,2,0,
-26,0,109,0,0,1,1,0,0,9,0,97,0,0,0,1,9,18,109,0,16,8,48,0,57,18,97,0,24,0,9,18,109,0,16,10,49,0,57,
-18,97,0,24,0,0,1,90,95,0,0,0,0,2,4,1,0,2,0,28,0,109,0,0,1,1,0,0,9,0,97,0,0,0,1,9,18,109,0,16,8,48,
-0,57,18,97,0,24,0,9,18,109,0,16,10,49,0,57,18,97,0,24,0,0,1,90,95,0,0,0,0,2,4,1,0,2,0,27,0,109,0,0,
-1,1,0,0,9,0,97,0,0,0,1,9,18,109,0,16,8,48,0,57,18,97,0,24,0,9,18,109,0,16,10,49,0,57,18,97,0,24,0,
-9,18,109,0,16,10,50,0,57,18,97,0,24,0,0,1,90,95,0,0,0,0,2,4,1,0,2,0,30,0,109,0,0,1,1,0,0,9,0,97,0,
-0,0,1,9,18,109,0,16,8,48,0,57,18,97,0,24,0,9,18,109,0,16,10,49,0,57,18,97,0,24,0,9,18,109,0,16,10,
-50,0,57,18,97,0,24,0,0,1,90,95,0,0,0,0,2,4,1,0,2,0,29,0,109,0,0,1,1,0,0,9,0,97,0,0,0,1,9,18,109,0,
-16,8,48,0,57,18,97,0,24,0,9,18,109,0,16,10,49,0,57,18,97,0,24,0,9,18,109,0,16,10,50,0,57,18,97,0,
-24,0,9,18,109,0,16,10,51,0,57,18,97,0,24,0,0,1,90,95,0,0,0,0,2,4,1,0,2,0,31,0,109,0,0,1,1,0,0,9,0,
-97,0,0,0,1,9,18,109,0,16,8,48,0,57,18,97,0,24,0,9,18,109,0,16,10,49,0,57,18,97,0,24,0,9,18,109,0,
-16,10,50,0,57,18,97,0,24,0,9,18,109,0,16,10,51,0,57,18,97,0,24,0,0,1,90,95,0,0,26,0,2,26,1,1,0,0,
-26,0,109,0,0,1,1,0,0,26,0,110,0,0,0,1,8,58,109,97,116,50,120,51,0,0,18,109,0,16,8,48,0,57,18,110,0,
-16,8,48,0,57,46,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,46,0,0,0,0,1,90,95,0,0,28,0,2,26,1,
-1,0,0,28,0,109,0,0,1,1,0,0,28,0,110,0,0,0,1,8,58,109,97,116,50,120,52,0,0,18,109,0,16,8,48,0,57,18,
-110,0,16,8,48,0,57,46,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,46,0,0,0,0,1,90,95,0,0,27,0,
-2,26,1,1,0,0,27,0,109,0,0,1,1,0,0,27,0,110,0,0,0,1,8,58,109,97,116,51,120,50,0,0,18,109,0,16,8,48,
-0,57,18,110,0,16,8,48,0,57,46,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,46,0,18,109,0,16,10,
-50,0,57,18,110,0,16,10,50,0,57,46,0,0,0,0,1,90,95,0,0,30,0,2,26,1,1,0,0,30,0,109,0,0,1,1,0,0,30,0,
-110,0,0,0,1,8,58,109,97,116,51,120,52,0,0,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,46,0,18,109,
-0,16,10,49,0,57,18,110,0,16,10,49,0,57,46,0,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,46,0,0,0,
-0,1,90,95,0,0,29,0,2,26,1,1,0,0,29,0,109,0,0,1,1,0,0,29,0,110,0,0,0,1,8,58,109,97,116,52,120,50,0,
-0,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,46,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,
-46,0,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,46,0,18,109,0,16,10,51,0,57,18,110,0,16,10,51,0,
-57,46,0,0,0,0,1,90,95,0,0,31,0,2,26,1,1,0,0,31,0,109,0,0,1,1,0,0,31,0,110,0,0,0,1,8,58,109,97,116,
-52,120,51,0,0,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,46,0,18,109,0,16,10,49,0,57,18,110,0,16,
-10,49,0,57,46,0,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,46,0,18,109,0,16,10,51,0,57,18,110,0,
-16,10,51,0,57,46,0,0,0,0,1,90,95,0,0,26,0,2,27,1,1,0,0,26,0,109,0,0,1,1,0,0,26,0,110,0,0,0,1,8,58,
-109,97,116,50,120,51,0,0,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,47,0,18,109,0,16,10,49,0,57,
-18,110,0,16,10,49,0,57,47,0,0,0,0,1,90,95,0,0,28,0,2,27,1,1,0,0,28,0,109,0,0,1,1,0,0,28,0,110,0,0,
-0,1,8,58,109,97,116,50,120,52,0,0,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,47,0,18,109,0,16,10,
-49,0,57,18,110,0,16,10,49,0,57,47,0,0,0,0,1,90,95,0,0,27,0,2,27,1,1,0,0,27,0,109,0,0,1,1,0,0,27,0,
-110,0,0,0,1,8,58,109,97,116,51,120,50,0,0,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,47,0,18,109,
-0,16,10,49,0,57,18,110,0,16,10,49,0,57,47,0,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,47,0,0,0,
-0,1,90,95,0,0,30,0,2,27,1,1,0,0,30,0,109,0,0,1,1,0,0,30,0,110,0,0,0,1,8,58,109,97,116,51,120,52,0,
-0,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,47,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,
-47,0,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,47,0,0,0,0,1,90,95,0,0,29,0,2,27,1,1,0,0,29,0,
-109,0,0,1,1,0,0,29,0,110,0,0,0,1,8,58,109,97,116,52,120,50,0,0,18,109,0,16,8,48,0,57,18,110,0,16,8,
-48,0,57,47,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,47,0,18,109,0,16,10,50,0,57,18,110,0,16,
-10,50,0,57,47,0,18,109,0,16,10,51,0,57,18,110,0,16,10,51,0,57,47,0,0,0,0,1,90,95,0,0,31,0,2,27,1,1,
-0,0,31,0,109,0,0,1,1,0,0,31,0,110,0,0,0,1,8,58,109,97,116,52,120,51,0,0,18,109,0,16,8,48,0,57,18,
-110,0,16,8,48,0,57,47,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,47,0,18,109,0,16,10,50,0,57,
-18,110,0,16,10,50,0,57,47,0,18,109,0,16,10,51,0,57,18,110,0,16,10,51,0,57,47,0,0,0,0,1,90,95,0,0,
-26,0,2,22,1,1,0,0,26,0,109,0,0,1,1,0,0,26,0,110,0,0,0,1,8,58,109,97,116,50,120,51,0,0,18,109,0,16,
-8,48,0,57,18,110,0,16,8,48,0,57,49,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,49,0,0,0,0,1,90,
-95,0,0,28,0,2,22,1,1,0,0,28,0,109,0,0,1,1,0,0,28,0,110,0,0,0,1,8,58,109,97,116,50,120,52,0,0,18,
-109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,49,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,49,0,0,
-0,0,1,90,95,0,0,27,0,2,22,1,1,0,0,27,0,109,0,0,1,1,0,0,27,0,110,0,0,0,1,8,58,109,97,116,51,120,50,
-0,0,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,49,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,
-49,0,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,49,0,0,0,0,1,90,95,0,0,30,0,2,22,1,1,0,0,30,0,
-109,0,0,1,1,0,0,30,0,110,0,0,0,1,8,58,109,97,116,51,120,52,0,0,18,109,0,16,8,48,0,57,18,110,0,16,8,
-48,0,57,49,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,49,0,18,109,0,16,10,50,0,57,18,110,0,16,
-10,50,0,57,49,0,0,0,0,1,90,95,0,0,29,0,2,22,1,1,0,0,29,0,109,0,0,1,1,0,0,29,0,110,0,0,0,1,8,58,109,
-97,116,52,120,50,0,0,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,49,0,18,109,0,16,10,49,0,57,18,
-110,0,16,10,49,0,57,49,0,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,49,0,18,109,0,16,10,51,0,57,
-18,110,0,16,10,51,0,57,49,0,0,0,0,1,90,95,0,0,31,0,2,22,1,1,0,0,31,0,109,0,0,1,1,0,0,31,0,110,0,0,
-0,1,8,58,109,97,116,52,120,51,0,0,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,49,0,18,109,0,16,10,
-49,0,57,18,110,0,16,10,49,0,57,49,0,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,49,0,18,109,0,16,
-10,51,0,57,18,110,0,16,10,51,0,57,49,0,0,0,0,1,90,95,0,0,26,0,2,26,1,1,0,0,9,0,97,0,0,1,1,0,0,26,0,
-110,0,0,0,1,8,58,109,97,116,50,120,51,0,0,18,97,0,18,110,0,16,8,48,0,57,46,0,18,97,0,18,110,0,16,
-10,49,0,57,46,0,0,0,0,1,90,95,0,0,26,0,2,26,1,1,0,0,26,0,109,0,0,1,1,0,0,9,0,98,0,0,0,1,8,58,109,
-97,116,50,120,51,0,0,18,109,0,16,8,48,0,57,18,98,0,46,0,18,109,0,16,10,49,0,57,18,98,0,46,0,0,0,0,
-1,90,95,0,0,28,0,2,26,1,1,0,0,9,0,97,0,0,1,1,0,0,28,0,110,0,0,0,1,8,58,109,97,116,50,120,52,0,0,18,
-97,0,18,110,0,16,8,48,0,57,46,0,18,97,0,18,110,0,16,10,49,0,57,46,0,0,0,0,1,90,95,0,0,28,0,2,26,1,
-1,0,0,28,0,109,0,0,1,1,0,0,9,0,98,0,0,0,1,8,58,109,97,116,50,120,52,0,0,18,109,0,16,8,48,0,57,18,
-98,0,46,0,18,109,0,16,10,49,0,57,18,98,0,46,0,0,0,0,1,90,95,0,0,27,0,2,26,1,1,0,0,9,0,97,0,0,1,1,0,
-0,27,0,110,0,0,0,1,8,58,109,97,116,51,120,50,0,0,18,97,0,18,110,0,16,8,48,0,57,46,0,18,97,0,18,110,
-0,16,10,49,0,57,46,0,18,97,0,18,110,0,16,10,50,0,57,46,0,0,0,0,1,90,95,0,0,27,0,2,26,1,1,0,0,27,0,
-109,0,0,1,1,0,0,9,0,98,0,0,0,1,8,58,109,97,116,51,120,50,0,0,18,109,0,16,8,48,0,57,18,98,0,46,0,18,
-109,0,16,10,49,0,57,18,98,0,46,0,18,109,0,16,10,50,0,57,18,98,0,46,0,0,0,0,1,90,95,0,0,30,0,2,26,1,
-1,0,0,9,0,97,0,0,1,1,0,0,30,0,110,0,0,0,1,8,58,109,97,116,51,120,52,0,0,18,97,0,18,110,0,16,8,48,0,
-57,46,0,18,97,0,18,110,0,16,10,49,0,57,46,0,18,97,0,18,110,0,16,10,50,0,57,46,0,0,0,0,1,90,95,0,0,
-30,0,2,26,1,1,0,0,30,0,109,0,0,1,1,0,0,9,0,98,0,0,0,1,8,58,109,97,116,51,120,52,0,0,18,109,0,16,8,
-48,0,57,18,98,0,46,0,18,109,0,16,10,49,0,57,18,98,0,46,0,18,109,0,16,10,50,0,57,18,98,0,46,0,0,0,0,
-1,90,95,0,0,29,0,2,26,1,1,0,0,29,0,109,0,0,1,1,0,0,9,0,98,0,0,0,1,8,58,109,97,116,52,120,50,0,0,18,
-109,0,16,8,48,0,57,18,98,0,46,0,18,109,0,16,10,49,0,57,18,98,0,46,0,18,109,0,16,10,50,0,57,18,98,0,
-46,0,18,109,0,16,10,51,0,57,18,98,0,46,0,0,0,0,1,90,95,0,0,29,0,2,26,1,1,0,0,9,0,97,0,0,1,1,0,0,29,
-0,110,0,0,0,1,8,58,109,97,116,52,120,50,0,0,18,97,0,18,110,0,16,8,48,0,57,46,0,18,97,0,18,110,0,16,
-10,49,0,57,46,0,18,97,0,18,110,0,16,10,50,0,57,46,0,18,97,0,18,110,0,16,10,51,0,57,46,0,0,0,0,1,90,
-95,0,0,31,0,2,26,1,1,0,0,31,0,109,0,0,1,1,0,0,9,0,98,0,0,0,1,8,58,109,97,116,52,120,51,0,0,18,109,
-0,16,8,48,0,57,18,98,0,46,0,18,109,0,16,10,49,0,57,18,98,0,46,0,18,109,0,16,10,50,0,57,18,98,0,46,
-0,18,109,0,16,10,51,0,57,18,98,0,46,0,0,0,0,1,90,95,0,0,31,0,2,26,1,1,0,0,9,0,97,0,0,1,1,0,0,31,0,
-110,0,0,0,1,8,58,109,97,116,52,120,51,0,0,18,97,0,18,110,0,16,8,48,0,57,46,0,18,97,0,18,110,0,16,
-10,49,0,57,46,0,18,97,0,18,110,0,16,10,50,0,57,46,0,18,97,0,18,110,0,16,10,51,0,57,46,0,0,0,0,1,90,
-95,0,0,26,0,2,27,1,1,0,0,9,0,97,0,0,1,1,0,0,26,0,110,0,0,0,1,8,58,109,97,116,50,120,51,0,0,18,97,0,
-18,110,0,16,8,48,0,57,47,0,18,97,0,18,110,0,16,10,49,0,57,47,0,0,0,0,1,90,95,0,0,26,0,2,27,1,1,0,0,
-26,0,109,0,0,1,1,0,0,9,0,98,0,0,0,1,8,58,109,97,116,50,120,51,0,0,18,109,0,16,8,48,0,57,18,98,0,47,
-0,18,109,0,16,10,49,0,57,18,98,0,47,0,0,0,0,1,90,95,0,0,28,0,2,27,1,1,0,0,9,0,97,0,0,1,1,0,0,28,0,
-110,0,0,0,1,8,58,109,97,116,50,120,52,0,0,18,97,0,18,110,0,16,8,48,0,57,47,0,18,97,0,18,110,0,16,
-10,49,0,57,47,0,0,0,0,1,90,95,0,0,28,0,2,27,1,1,0,0,28,0,109,0,0,1,1,0,0,9,0,98,0,0,0,1,8,58,109,
-97,116,50,120,52,0,0,18,109,0,16,8,48,0,57,18,98,0,47,0,18,109,0,16,10,49,0,57,18,98,0,47,0,0,0,0,
-1,90,95,0,0,27,0,2,27,1,1,0,0,9,0,97,0,0,1,1,0,0,27,0,110,0,0,0,1,8,58,109,97,116,51,120,50,0,0,18,
-97,0,18,110,0,16,8,48,0,57,47,0,18,97,0,18,110,0,16,10,49,0,57,47,0,18,97,0,18,110,0,16,10,50,0,57,
-47,0,0,0,0,1,90,95,0,0,27,0,2,27,1,1,0,0,27,0,109,0,0,1,1,0,0,9,0,98,0,0,0,1,8,58,109,97,116,51,
-120,50,0,0,18,109,0,16,8,48,0,57,18,98,0,47,0,18,109,0,16,10,49,0,57,18,98,0,47,0,18,109,0,16,10,
-50,0,57,18,98,0,47,0,0,0,0,1,90,95,0,0,30,0,2,27,1,1,0,0,9,0,97,0,0,1,1,0,0,30,0,110,0,0,0,1,8,58,
-109,97,116,51,120,52,0,0,18,97,0,18,110,0,16,8,48,0,57,47,0,18,97,0,18,110,0,16,10,49,0,57,47,0,18,
-97,0,18,110,0,16,10,50,0,57,47,0,0,0,0,1,90,95,0,0,30,0,2,27,1,1,0,0,30,0,109,0,0,1,1,0,0,9,0,98,0,
-0,0,1,8,58,109,97,116,51,120,52,0,0,18,109,0,16,8,48,0,57,18,98,0,47,0,18,109,0,16,10,49,0,57,18,
-98,0,47,0,18,109,0,16,10,50,0,57,18,98,0,47,0,0,0,0,1,90,95,0,0,29,0,2,27,1,1,0,0,29,0,109,0,0,1,1,
-0,0,9,0,98,0,0,0,1,8,58,109,97,116,52,120,50,0,0,18,109,0,16,8,48,0,57,18,98,0,47,0,18,109,0,16,10,
-49,0,57,18,98,0,47,0,18,109,0,16,10,50,0,57,18,98,0,47,0,18,109,0,16,10,51,0,57,18,98,0,47,0,0,0,0,
-1,90,95,0,0,29,0,2,27,1,1,0,0,9,0,97,0,0,1,1,0,0,29,0,110,0,0,0,1,8,58,109,97,116,52,120,50,0,0,18,
-97,0,18,110,0,16,8,48,0,57,47,0,18,97,0,18,110,0,16,10,49,0,57,47,0,18,97,0,18,110,0,16,10,50,0,57,
-47,0,18,97,0,18,110,0,16,10,51,0,57,47,0,0,0,0,1,90,95,0,0,31,0,2,27,1,1,0,0,31,0,109,0,0,1,1,0,0,
-9,0,98,0,0,0,1,8,58,109,97,116,52,120,51,0,0,18,109,0,16,8,48,0,57,18,98,0,47,0,18,109,0,16,10,49,
-0,57,18,98,0,47,0,18,109,0,16,10,50,0,57,18,98,0,47,0,18,109,0,16,10,51,0,57,18,98,0,47,0,0,0,0,1,
-90,95,0,0,31,0,2,27,1,1,0,0,9,0,97,0,0,1,1,0,0,31,0,110,0,0,0,1,8,58,109,97,116,52,120,51,0,0,18,
-97,0,18,110,0,16,8,48,0,57,47,0,18,97,0,18,110,0,16,10,49,0,57,47,0,18,97,0,18,110,0,16,10,50,0,57,
-47,0,18,97,0,18,110,0,16,10,51,0,57,47,0,0,0,0,1,90,95,0,0,26,0,2,21,1,1,0,0,9,0,97,0,0,1,1,0,0,26,
-0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,97,0,18,110,0,16,8,48,0,57,48,20,
-0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,97,0,18,110,0,16,10,49,0,57,48,20,0,0,1,90,
-95,0,0,26,0,2,21,1,1,0,0,26,0,109,0,0,1,1,0,0,9,0,98,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,
-8,48,0,57,18,109,0,16,8,48,0,57,18,98,0,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,
-18,109,0,16,10,49,0,57,18,98,0,48,20,0,0,1,90,95,0,0,28,0,2,21,1,1,0,0,9,0,97,0,0,1,1,0,0,28,0,110,
-0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,97,0,18,110,0,16,8,48,0,57,48,20,0,9,18,
-95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,97,0,18,110,0,16,10,49,0,57,48,20,0,0,1,90,95,0,0,
-28,0,2,21,1,1,0,0,28,0,109,0,0,1,1,0,0,9,0,98,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,
-57,18,109,0,16,8,48,0,57,18,98,0,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,
-16,10,49,0,57,18,98,0,48,20,0,0,1,90,95,0,0,27,0,2,21,1,1,0,0,9,0,97,0,0,1,1,0,0,27,0,110,0,0,0,1,
-9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,97,0,18,110,0,16,8,48,0,57,48,20,0,9,18,95,95,
-114,101,116,86,97,108,0,16,10,49,0,57,18,97,0,18,110,0,16,10,49,0,57,48,20,0,9,18,95,95,114,101,
-116,86,97,108,0,16,10,50,0,57,18,97,0,18,110,0,16,10,50,0,57,48,20,0,0,1,90,95,0,0,27,0,2,21,1,1,0,
-0,27,0,109,0,0,1,1,0,0,9,0,98,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,16,
-8,48,0,57,18,98,0,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,16,10,49,0,57,
-18,98,0,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,109,0,16,10,50,0,57,18,98,0,48,
-20,0,0,1,90,95,0,0,30,0,2,21,1,1,0,0,9,0,97,0,0,1,1,0,0,30,0,110,0,0,0,1,9,18,95,95,114,101,116,86,
-97,108,0,16,8,48,0,57,18,97,0,18,110,0,16,8,48,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,
-10,49,0,57,18,97,0,18,110,0,16,10,49,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,
-18,97,0,18,110,0,16,10,50,0,57,48,20,0,0,1,90,95,0,0,30,0,2,21,1,1,0,0,30,0,109,0,0,1,1,0,0,9,0,98,
-0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,16,8,48,0,57,18,98,0,48,20,0,9,18,
-95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,16,10,49,0,57,18,98,0,48,20,0,9,18,95,95,114,
-101,116,86,97,108,0,16,10,50,0,57,18,109,0,16,10,50,0,57,18,98,0,48,20,0,0,1,90,95,0,0,29,0,2,21,1,
-1,0,0,29,0,109,0,0,1,1,0,0,9,0,98,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,
-16,8,48,0,57,18,98,0,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,16,10,49,0,
-57,18,98,0,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,109,0,16,10,50,0,57,18,98,0,
-48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,51,0,57,18,109,0,16,10,51,0,57,18,98,0,48,20,0,0,
-1,90,95,0,0,29,0,2,21,1,1,0,0,9,0,97,0,0,1,1,0,0,29,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,108,
-0,16,8,48,0,57,18,97,0,18,110,0,16,8,48,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,
-57,18,97,0,18,110,0,16,10,49,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,97,0,
-18,110,0,16,10,50,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,51,0,57,18,97,0,18,110,0,
-16,10,51,0,57,48,20,0,0,1,90,95,0,0,31,0,2,21,1,1,0,0,31,0,109,0,0,1,1,0,0,9,0,98,0,0,0,1,9,18,95,
-95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,16,8,48,0,57,18,98,0,48,20,0,9,18,95,95,114,101,
-116,86,97,108,0,16,10,49,0,57,18,109,0,16,10,49,0,57,18,98,0,48,20,0,9,18,95,95,114,101,116,86,97,
-108,0,16,10,50,0,57,18,109,0,16,10,50,0,57,18,98,0,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,
-10,51,0,57,18,109,0,16,10,51,0,57,18,98,0,48,20,0,0,1,90,95,0,0,31,0,2,21,1,1,0,0,9,0,97,0,0,1,1,0,
-0,31,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,97,0,18,110,0,16,8,48,0,57,
-48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,97,0,18,110,0,16,10,49,0,57,48,20,0,9,
-18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,97,0,18,110,0,16,10,50,0,57,48,20,0,9,18,95,95,
-114,101,116,86,97,108,0,16,10,51,0,57,18,97,0,18,110,0,16,10,51,0,57,48,20,0,0,1,90,95,0,0,26,0,2,
-22,1,1,0,0,9,0,97,0,0,1,1,0,0,26,0,110,0,0,0,1,3,2,90,95,1,0,9,0,1,105,110,118,0,2,17,49,0,48,0,0,
-18,97,0,49,0,0,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,105,110,118,0,18,110,0,16,8,48,0,
-57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,105,110,118,0,18,110,0,16,10,49,0,
-57,48,20,0,0,1,90,95,0,0,26,0,2,22,1,1,0,0,26,0,109,0,0,1,1,0,0,9,0,98,0,0,0,1,3,2,90,95,1,0,9,0,1,
-105,110,118,0,2,17,49,0,48,0,0,18,98,0,49,0,0,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,
-109,0,16,8,48,0,57,18,105,110,118,0,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,
-109,0,16,10,49,0,57,18,105,110,118,0,48,20,0,0,1,90,95,0,0,28,0,2,22,1,1,0,0,9,0,97,0,0,1,1,0,0,28,
-0,110,0,0,0,1,3,2,90,95,1,0,9,0,1,105,110,118,0,2,17,49,0,48,0,0,18,97,0,49,0,0,9,18,95,95,114,101,
-116,86,97,108,0,16,8,48,0,57,18,105,110,118,0,18,110,0,16,8,48,0,57,48,20,0,9,18,95,95,114,101,116,
-86,97,108,0,16,10,49,0,57,18,105,110,118,0,18,110,0,16,10,49,0,57,48,20,0,0,1,90,95,0,0,28,0,2,22,
-1,1,0,0,28,0,109,0,0,1,1,0,0,9,0,98,0,0,0,1,3,2,90,95,1,0,9,0,1,105,110,118,0,2,17,49,0,48,0,0,18,
-98,0,49,0,0,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,16,8,48,0,57,18,105,110,118,0,
-48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,16,10,49,0,57,18,105,110,118,0,
-48,20,0,0,1,90,95,0,0,27,0,2,22,1,1,0,0,9,0,97,0,0,1,1,0,0,27,0,110,0,0,0,1,3,2,90,95,1,0,9,0,1,
-105,110,118,0,2,17,49,0,48,0,0,18,97,0,49,0,0,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,
-105,110,118,0,18,110,0,16,8,48,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,
-105,110,118,0,18,110,0,16,10,49,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,
-105,110,118,0,18,110,0,16,10,50,0,57,48,20,0,0,1,90,95,0,0,27,0,2,22,1,1,0,0,27,0,109,0,0,1,1,0,0,
-9,0,98,0,0,0,1,3,2,90,95,1,0,9,0,1,105,110,118,0,2,17,49,0,48,0,0,18,98,0,49,0,0,9,18,95,95,114,
-101,116,86,97,108,0,16,8,48,0,57,18,109,0,16,8,48,0,57,18,105,110,118,0,48,20,0,9,18,95,95,114,101,
-116,86,97,108,0,16,10,49,0,57,18,109,0,16,10,49,0,57,18,105,110,118,0,48,20,0,9,18,95,95,114,101,
-116,86,97,108,0,16,10,50,0,57,18,109,0,16,10,50,0,57,18,105,110,118,0,48,20,0,0,1,90,95,0,0,30,0,2,
-22,1,1,0,0,9,0,97,0,0,1,1,0,0,30,0,110,0,0,0,1,3,2,90,95,1,0,9,0,1,105,110,118,0,2,17,49,0,48,0,0,
-18,97,0,49,0,0,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,105,110,118,0,18,110,0,16,8,48,0,
-57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,105,110,118,0,18,110,0,16,10,49,0,
-57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,105,110,118,0,18,110,0,16,10,50,0,
-57,48,20,0,0,1,90,95,0,0,30,0,2,22,1,1,0,0,30,0,109,0,0,1,1,0,0,9,0,98,0,0,0,1,3,2,90,95,1,0,9,0,1,
-105,110,118,0,2,17,49,0,48,0,0,18,98,0,49,0,0,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,
-109,0,16,8,48,0,57,18,105,110,118,0,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,
-109,0,16,10,49,0,57,18,105,110,118,0,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,
-109,0,16,10,50,0,57,18,105,110,118,0,48,20,0,0,1,90,95,0,0,29,0,2,22,1,1,0,0,29,0,109,0,0,1,1,0,0,
-9,0,98,0,0,0,1,3,2,90,95,1,0,9,0,1,105,110,118,0,2,17,49,0,48,0,0,18,98,0,49,0,0,9,18,95,95,114,
-101,116,86,97,108,0,16,8,48,0,57,18,109,0,16,8,48,0,57,18,105,110,118,0,48,20,0,9,18,95,95,114,101,
-116,86,97,108,0,16,10,49,0,57,18,109,0,16,10,49,0,57,18,105,110,118,0,48,20,0,9,18,95,95,114,101,
-116,86,97,108,0,16,10,50,0,57,18,109,0,16,10,50,0,57,18,105,110,118,0,48,20,0,9,18,95,95,114,101,
-116,86,97,108,0,16,10,51,0,57,18,109,0,16,10,51,0,57,18,105,110,118,0,48,20,0,0,1,90,95,0,0,29,0,2,
-22,1,1,0,0,9,0,97,0,0,1,1,0,0,29,0,110,0,0,0,1,3,2,90,95,1,0,9,0,1,105,110,118,0,2,17,49,0,48,0,0,
-18,97,0,49,0,0,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,105,110,118,0,18,110,0,16,8,48,0,
-57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,105,110,118,0,18,110,0,16,10,49,0,
-57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,105,110,118,0,18,110,0,16,10,50,0,
-57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,51,0,57,18,105,110,118,0,18,110,0,16,10,51,0,
-57,48,20,0,0,1,90,95,0,0,31,0,2,22,1,1,0,0,31,0,109,0,0,1,1,0,0,9,0,98,0,0,0,1,3,2,90,95,1,0,9,0,1,
-105,110,118,0,2,17,49,0,48,0,0,18,98,0,49,0,0,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,
-109,0,16,8,48,0,57,18,105,110,118,0,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,
-109,0,16,10,49,0,57,18,105,110,118,0,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,
-109,0,16,10,50,0,57,18,105,110,118,0,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,51,0,57,18,
-109,0,16,10,51,0,57,18,105,110,118,0,48,20,0,0,1,90,95,0,0,31,0,2,22,1,1,0,0,9,0,97,0,0,1,1,0,0,31,
-0,110,0,0,0,1,3,2,90,95,1,0,9,0,1,105,110,118,0,2,17,49,0,48,0,0,18,97,0,49,0,0,9,18,95,95,114,101,
-116,86,97,108,0,16,8,48,0,57,18,105,110,118,0,18,110,0,16,8,48,0,57,48,20,0,9,18,95,95,114,101,116,
-86,97,108,0,16,10,49,0,57,18,105,110,118,0,18,110,0,16,10,49,0,57,48,20,0,9,18,95,95,114,101,116,
-86,97,108,0,16,10,50,0,57,18,105,110,118,0,18,110,0,16,10,50,0,57,48,20,0,9,18,95,95,114,101,116,
-86,97,108,0,16,10,51,0,57,18,105,110,118,0,18,110,0,16,10,51,0,57,48,20,0,0,1,90,95,0,0,26,0,2,27,
-1,1,0,0,26,0,109,0,0,0,1,8,58,109,97,116,50,120,51,0,0,18,109,0,16,8,48,0,57,54,0,18,109,0,16,10,
-49,0,57,54,0,0,0,0,1,90,95,0,0,28,0,2,27,1,1,0,0,28,0,109,0,0,0,1,8,58,109,97,116,50,120,52,0,0,18,
-109,0,16,8,48,0,57,54,0,18,109,0,16,10,49,0,57,54,0,0,0,0,1,90,95,0,0,27,0,2,27,1,1,0,0,27,0,109,0,
-0,0,1,8,58,109,97,116,51,120,50,0,0,18,109,0,16,8,48,0,57,54,0,18,109,0,16,10,49,0,57,54,0,18,109,
-0,16,10,50,0,57,54,0,0,0,0,1,90,95,0,0,30,0,2,27,1,1,0,0,30,0,109,0,0,0,1,8,58,109,97,116,51,120,
-52,0,0,18,109,0,16,8,48,0,57,54,0,18,109,0,16,10,49,0,57,54,0,18,109,0,16,10,50,0,57,54,0,0,0,0,1,
-90,95,0,0,29,0,2,27,1,1,0,0,29,0,109,0,0,0,1,8,58,109,97,116,52,120,50,0,0,18,109,0,16,8,48,0,57,
-54,0,18,109,0,16,10,49,0,57,54,0,18,109,0,16,10,50,0,57,54,0,18,109,0,16,10,51,0,57,54,0,0,0,0,1,
-90,95,0,0,31,0,2,27,1,1,0,0,31,0,109,0,0,0,1,8,58,109,97,116,52,120,51,0,0,18,109,0,16,8,48,0,57,
-54,0,18,109,0,16,10,49,0,57,54,0,18,109,0,16,10,50,0,57,54,0,18,109,0,16,10,51,0,57,54,0,0,0,0,1,
-90,95,0,0,0,0,2,25,1,0,2,0,26,0,109,0,0,0,1,9,18,109,0,16,8,48,0,57,52,0,9,18,109,0,16,10,49,0,57,
-52,0,0,1,90,95,0,0,0,0,2,25,1,0,2,0,28,0,109,0,0,0,1,9,18,109,0,16,8,48,0,57,52,0,9,18,109,0,16,10,
-49,0,57,52,0,0,1,90,95,0,0,0,0,2,25,1,0,2,0,27,0,109,0,0,0,1,9,18,109,0,16,8,48,0,57,52,0,9,18,109,
-0,16,10,49,0,57,52,0,9,18,109,0,16,10,50,0,57,52,0,0,1,90,95,0,0,0,0,2,25,1,0,2,0,30,0,109,0,0,0,1,
-9,18,109,0,16,8,48,0,57,52,0,9,18,109,0,16,10,49,0,57,52,0,9,18,109,0,16,10,50,0,57,52,0,0,1,90,95,
-0,0,0,0,2,25,1,0,2,0,29,0,109,0,0,0,1,9,18,109,0,16,8,48,0,57,52,0,9,18,109,0,16,10,49,0,57,52,0,9,
-18,109,0,16,10,50,0,57,52,0,9,18,109,0,16,10,51,0,57,52,0,0,1,90,95,0,0,0,0,2,25,1,0,2,0,31,0,109,
-0,0,0,1,9,18,109,0,16,8,48,0,57,52,0,9,18,109,0,16,10,49,0,57,52,0,9,18,109,0,16,10,50,0,57,52,0,9,
-18,109,0,16,10,51,0,57,52,0,0,1,90,95,0,0,0,0,2,24,1,0,2,0,26,0,109,0,0,0,1,9,18,109,0,16,8,48,0,
-57,51,0,9,18,109,0,16,10,49,0,57,51,0,0,1,90,95,0,0,0,0,2,24,1,0,2,0,28,0,109,0,0,0,1,9,18,109,0,
-16,8,48,0,57,51,0,9,18,109,0,16,10,49,0,57,51,0,0,1,90,95,0,0,0,0,2,24,1,0,2,0,27,0,109,0,0,0,1,9,
-18,109,0,16,8,48,0,57,51,0,9,18,109,0,16,10,49,0,57,51,0,9,18,109,0,16,10,50,0,57,51,0,0,1,90,95,0,
-0,0,0,2,24,1,0,2,0,30,0,109,0,0,0,1,9,18,109,0,16,8,48,0,57,51,0,9,18,109,0,16,10,49,0,57,51,0,9,
-18,109,0,16,10,50,0,57,51,0,0,1,90,95,0,0,0,0,2,24,1,0,2,0,29,0,109,0,0,0,1,9,18,109,0,16,8,48,0,
-57,51,0,9,18,109,0,16,10,49,0,57,51,0,9,18,109,0,16,10,50,0,57,51,0,9,18,109,0,16,10,51,0,57,51,0,
-0,1,90,95,0,0,0,0,2,24,1,0,2,0,31,0,109,0,0,0,1,9,18,109,0,16,8,48,0,57,51,0,9,18,109,0,16,10,49,0,
-57,51,0,9,18,109,0,16,10,50,0,57,51,0,9,18,109,0,16,10,51,0,57,51,0,0,0
diff --git a/src/mesa/shader/slang/library/slang_builtin_120_common_gc.h b/src/mesa/shader/slang/library/slang_builtin_120_common_gc.h
deleted file mode 100644 (file)
index c397b9f..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-
-/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED FROM THE FOLLOWING FILE: */
-/* slang_builtin_120_common.gc */
-
-5,1,90,95,0,0,26,0,0,109,97,116,114,105,120,67,111,109,112,77,117,108,116,0,1,0,0,0,26,0,109,0,0,1,
-0,0,0,26,0,110,0,0,0,1,8,58,109,97,116,50,120,51,0,0,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,
-48,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,48,0,0,0,0,1,90,95,0,0,28,0,0,109,97,116,114,
-105,120,67,111,109,112,77,117,108,116,0,1,0,0,0,28,0,109,0,0,1,0,0,0,28,0,110,0,0,0,1,8,58,109,97,
-116,50,120,52,0,0,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,48,0,18,109,0,16,10,49,0,57,18,110,0,
-16,10,49,0,57,48,0,0,0,0,1,90,95,0,0,27,0,0,109,97,116,114,105,120,67,111,109,112,77,117,108,116,0,
-1,0,0,0,27,0,109,0,0,1,0,0,0,27,0,110,0,0,0,1,8,58,109,97,116,51,120,50,0,0,18,109,0,16,8,48,0,57,
-18,110,0,16,8,48,0,57,48,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,48,0,18,109,0,16,10,50,0,
-57,18,110,0,16,10,50,0,57,48,0,0,0,0,1,90,95,0,0,30,0,0,109,97,116,114,105,120,67,111,109,112,77,
-117,108,116,0,1,0,0,0,30,0,109,0,0,1,0,0,0,30,0,110,0,0,0,1,8,58,109,97,116,51,120,52,0,0,18,109,0,
-16,8,48,0,57,18,110,0,16,8,48,0,57,48,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,48,0,18,109,
-0,16,10,50,0,57,18,110,0,16,10,50,0,57,48,0,0,0,0,1,90,95,0,0,29,0,0,109,97,116,114,105,120,67,111,
-109,112,77,117,108,116,0,1,0,0,0,29,0,109,0,0,1,0,0,0,29,0,110,0,0,0,1,8,58,109,97,116,52,120,50,0,
-0,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,48,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,
-48,0,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,48,0,18,109,0,16,10,51,0,57,18,110,0,16,10,51,0,
-57,48,0,0,0,0,1,90,95,0,0,31,0,0,109,97,116,114,105,120,67,111,109,112,77,117,108,116,0,1,0,0,0,31,
-0,109,0,0,1,0,0,0,31,0,110,0,0,0,1,8,58,109,97,116,52,120,51,0,0,18,109,0,16,8,48,0,57,18,110,0,16,
-8,48,0,57,48,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,48,0,18,109,0,16,10,50,0,57,18,110,0,
-16,10,50,0,57,48,0,18,109,0,16,10,51,0,57,18,110,0,16,10,51,0,57,48,0,0,0,0,1,90,95,0,0,13,0,0,111,
-117,116,101,114,80,114,111,100,117,99,116,0,1,0,0,0,10,0,99,0,0,1,0,0,0,10,0,114,0,0,0,1,8,58,109,
-97,116,50,0,0,18,99,0,59,120,0,18,114,0,59,120,0,48,0,18,99,0,59,121,0,18,114,0,59,120,0,48,0,18,
-99,0,59,120,0,18,114,0,59,121,0,48,0,18,99,0,59,121,0,18,114,0,59,121,0,48,0,0,0,0,1,90,95,0,0,14,
-0,0,111,117,116,101,114,80,114,111,100,117,99,116,0,1,0,0,0,11,0,99,0,0,1,0,0,0,11,0,114,0,0,0,1,8,
-58,109,97,116,51,0,0,18,99,0,59,120,0,18,114,0,59,120,0,48,0,18,99,0,59,121,0,18,114,0,59,120,0,48,
-0,18,99,0,59,122,0,18,114,0,59,120,0,48,0,18,99,0,59,120,0,18,114,0,59,121,0,48,0,18,99,0,59,121,0,
-18,114,0,59,121,0,48,0,18,99,0,59,122,0,18,114,0,59,121,0,48,0,18,99,0,59,120,0,18,114,0,59,122,0,
-48,0,18,99,0,59,121,0,18,114,0,59,122,0,48,0,18,99,0,59,122,0,18,114,0,59,122,0,48,0,0,0,0,1,90,95,
-0,0,15,0,0,111,117,116,101,114,80,114,111,100,117,99,116,0,1,0,0,0,12,0,99,0,0,1,0,0,0,12,0,114,0,
-0,0,1,8,58,109,97,116,52,0,0,18,99,0,59,120,0,18,114,0,59,120,0,48,0,18,99,0,59,121,0,18,114,0,59,
-120,0,48,0,18,99,0,59,122,0,18,114,0,59,120,0,48,0,18,99,0,59,119,0,18,114,0,59,120,0,48,0,18,99,0,
-59,120,0,18,114,0,59,121,0,48,0,18,99,0,59,121,0,18,114,0,59,121,0,48,0,18,99,0,59,122,0,18,114,0,
-59,121,0,48,0,18,99,0,59,119,0,18,114,0,59,121,0,48,0,18,99,0,59,120,0,18,114,0,59,122,0,48,0,18,
-99,0,59,121,0,18,114,0,59,122,0,48,0,18,99,0,59,122,0,18,114,0,59,122,0,48,0,18,99,0,59,119,0,18,
-114,0,59,122,0,48,0,18,99,0,59,120,0,18,114,0,59,119,0,48,0,18,99,0,59,121,0,18,114,0,59,119,0,48,
-0,18,99,0,59,122,0,18,114,0,59,119,0,48,0,18,99,0,59,119,0,18,114,0,59,119,0,48,0,0,0,0,1,90,95,0,
-0,26,0,0,111,117,116,101,114,80,114,111,100,117,99,116,0,1,0,0,0,11,0,99,0,0,1,0,0,0,10,0,114,0,0,
-0,1,8,58,109,97,116,50,120,51,0,0,18,99,0,59,120,0,18,114,0,59,120,0,48,0,18,99,0,59,121,0,18,114,
-0,59,120,0,48,0,18,99,0,59,122,0,18,114,0,59,120,0,48,0,18,99,0,59,120,0,18,114,0,59,121,0,48,0,18,
-99,0,59,121,0,18,114,0,59,121,0,48,0,18,99,0,59,122,0,18,114,0,59,121,0,48,0,0,0,0,1,90,95,0,0,27,
-0,0,111,117,116,101,114,80,114,111,100,117,99,116,0,1,0,0,0,10,0,99,0,0,1,0,0,0,11,0,114,0,0,0,1,8,
-58,109,97,116,51,120,50,0,0,18,99,0,59,120,0,18,114,0,59,120,0,48,0,18,99,0,59,121,0,18,114,0,59,
-120,0,48,0,18,99,0,59,120,0,18,114,0,59,121,0,48,0,18,99,0,59,121,0,18,114,0,59,121,0,48,0,18,99,0,
-59,120,0,18,114,0,59,122,0,48,0,18,99,0,59,121,0,18,114,0,59,122,0,48,0,0,0,0,1,90,95,0,0,28,0,0,
-111,117,116,101,114,80,114,111,100,117,99,116,0,1,0,0,0,12,0,99,0,0,1,0,0,0,10,0,114,0,0,0,1,8,58,
-109,97,116,50,120,52,0,0,18,99,0,59,120,0,18,114,0,59,120,0,48,0,18,99,0,59,121,0,18,114,0,59,120,
-0,48,0,18,99,0,59,122,0,18,114,0,59,120,0,48,0,18,99,0,59,119,0,18,114,0,59,120,0,48,0,18,99,0,59,
-120,0,18,114,0,59,121,0,48,0,18,99,0,59,121,0,18,114,0,59,121,0,48,0,18,99,0,59,122,0,18,114,0,59,
-121,0,48,0,18,99,0,59,119,0,18,114,0,59,121,0,48,0,0,0,0,1,90,95,0,0,29,0,0,111,117,116,101,114,80,
-114,111,100,117,99,116,0,1,0,0,0,10,0,99,0,0,1,0,0,0,12,0,114,0,0,0,1,8,58,109,97,116,52,120,50,0,
-0,18,99,0,59,120,0,18,114,0,59,120,0,48,0,18,99,0,59,121,0,18,114,0,59,120,0,48,0,18,99,0,59,120,0,
-18,114,0,59,121,0,48,0,18,99,0,59,121,0,18,114,0,59,121,0,48,0,18,99,0,59,120,0,18,114,0,59,122,0,
-48,0,18,99,0,59,121,0,18,114,0,59,122,0,48,0,18,99,0,59,120,0,18,114,0,59,119,0,48,0,18,99,0,59,
-121,0,18,114,0,59,119,0,48,0,0,0,0,1,90,95,0,0,30,0,0,111,117,116,101,114,80,114,111,100,117,99,
-116,0,1,0,0,0,12,0,99,0,0,1,0,0,0,11,0,114,0,0,0,1,8,58,109,97,116,51,120,52,0,0,18,99,0,59,120,0,
-18,114,0,59,120,0,48,0,18,99,0,59,121,0,18,114,0,59,120,0,48,0,18,99,0,59,122,0,18,114,0,59,120,0,
-48,0,18,99,0,59,119,0,18,114,0,59,120,0,48,0,18,99,0,59,120,0,18,114,0,59,121,0,48,0,18,99,0,59,
-121,0,18,114,0,59,121,0,48,0,18,99,0,59,122,0,18,114,0,59,121,0,48,0,18,99,0,59,119,0,18,114,0,59,
-121,0,48,0,18,99,0,59,120,0,18,114,0,59,122,0,48,0,18,99,0,59,121,0,18,114,0,59,122,0,48,0,18,99,0,
-59,122,0,18,114,0,59,122,0,48,0,18,99,0,59,119,0,18,114,0,59,122,0,48,0,0,0,0,1,90,95,0,0,31,0,0,
-111,117,116,101,114,80,114,111,100,117,99,116,0,1,0,0,0,11,0,99,0,0,1,0,0,0,12,0,114,0,0,0,1,8,58,
-109,97,116,52,120,51,0,0,18,99,0,59,120,0,18,114,0,59,120,0,48,0,18,99,0,59,121,0,18,114,0,59,120,
-0,48,0,18,99,0,59,122,0,18,114,0,59,120,0,48,0,18,99,0,59,120,0,18,114,0,59,121,0,48,0,18,99,0,59,
-121,0,18,114,0,59,121,0,48,0,18,99,0,59,122,0,18,114,0,59,121,0,48,0,18,99,0,59,120,0,18,114,0,59,
-122,0,48,0,18,99,0,59,121,0,18,114,0,59,122,0,48,0,18,99,0,59,122,0,18,114,0,59,122,0,48,0,18,99,0,
-59,120,0,18,114,0,59,119,0,48,0,18,99,0,59,121,0,18,114,0,59,119,0,48,0,18,99,0,59,122,0,18,114,0,
-59,119,0,48,0,0,0,0,1,90,95,0,0,13,0,0,116,114,97,110,115,112,111,115,101,0,1,0,0,0,13,0,109,0,0,0,
-1,8,58,109,97,116,50,0,0,18,109,0,16,8,48,0,57,59,120,0,0,18,109,0,16,10,49,0,57,59,120,0,0,18,109,
-0,16,8,48,0,57,59,121,0,0,18,109,0,16,10,49,0,57,59,121,0,0,0,0,0,1,90,95,0,0,14,0,0,116,114,97,
-110,115,112,111,115,101,0,1,0,0,0,14,0,109,0,0,0,1,8,58,109,97,116,51,0,0,18,109,0,16,8,48,0,57,59,
-120,0,0,18,109,0,16,10,49,0,57,59,120,0,0,18,109,0,16,10,50,0,57,59,120,0,0,18,109,0,16,8,48,0,57,
-59,121,0,0,18,109,0,16,10,49,0,57,59,121,0,0,18,109,0,16,10,50,0,57,59,121,0,0,18,109,0,16,8,48,0,
-57,59,122,0,0,18,109,0,16,10,49,0,57,59,122,0,0,18,109,0,16,10,50,0,57,59,122,0,0,0,0,0,1,90,95,0,
-0,15,0,0,116,114,97,110,115,112,111,115,101,0,1,0,0,0,15,0,109,0,0,0,1,8,58,109,97,116,52,0,0,18,
-109,0,16,8,48,0,57,59,120,0,0,18,109,0,16,10,49,0,57,59,120,0,0,18,109,0,16,10,50,0,57,59,120,0,0,
-18,109,0,16,10,51,0,57,59,120,0,0,18,109,0,16,8,48,0,57,59,121,0,0,18,109,0,16,10,49,0,57,59,121,0,
-0,18,109,0,16,10,50,0,57,59,121,0,0,18,109,0,16,10,51,0,57,59,121,0,0,18,109,0,16,8,48,0,57,59,122,
-0,0,18,109,0,16,10,49,0,57,59,122,0,0,18,109,0,16,10,50,0,57,59,122,0,0,18,109,0,16,10,51,0,57,59,
-122,0,0,18,109,0,16,8,48,0,57,59,119,0,0,18,109,0,16,10,49,0,57,59,119,0,0,18,109,0,16,10,50,0,57,
-59,119,0,0,18,109,0,16,10,51,0,57,59,119,0,0,0,0,0,1,90,95,0,0,26,0,0,116,114,97,110,115,112,111,
-115,101,0,1,0,0,0,27,0,109,0,0,0,1,8,58,109,97,116,50,120,51,0,0,18,109,0,16,8,48,0,57,59,120,0,0,
-18,109,0,16,10,49,0,57,59,120,0,0,18,109,0,16,10,50,0,57,59,120,0,0,18,109,0,16,8,48,0,57,59,121,0,
-0,18,109,0,16,10,49,0,57,59,121,0,0,18,109,0,16,10,50,0,57,59,121,0,0,0,0,0,1,90,95,0,0,27,0,0,116,
-114,97,110,115,112,111,115,101,0,1,0,0,0,26,0,109,0,0,0,1,8,58,109,97,116,51,120,50,0,0,18,109,0,
-16,8,48,0,57,59,120,0,0,18,109,0,16,10,49,0,57,59,120,0,0,18,109,0,16,8,48,0,57,59,121,0,0,18,109,
-0,16,10,49,0,57,59,121,0,0,18,109,0,16,8,48,0,57,59,122,0,0,18,109,0,16,10,49,0,57,59,122,0,0,0,0,
-0,1,90,95,0,0,28,0,0,116,114,97,110,115,112,111,115,101,0,1,0,0,0,29,0,109,0,0,0,1,8,58,109,97,116,
-50,120,52,0,0,18,109,0,16,8,48,0,57,59,120,0,0,18,109,0,16,10,49,0,57,59,120,0,0,18,109,0,16,10,50,
-0,57,59,120,0,0,18,109,0,16,10,51,0,57,59,120,0,0,18,109,0,16,8,48,0,57,59,121,0,0,18,109,0,16,10,
-49,0,57,59,121,0,0,18,109,0,16,10,50,0,57,59,121,0,0,18,109,0,16,10,51,0,57,59,121,0,0,0,0,0,1,90,
-95,0,0,29,0,0,116,114,97,110,115,112,111,115,101,0,1,0,0,0,28,0,109,0,0,0,1,8,58,109,97,116,52,120,
-50,0,0,18,109,0,16,8,48,0,57,59,120,0,0,18,109,0,16,10,49,0,57,59,120,0,0,18,109,0,16,8,48,0,57,59,
-121,0,0,18,109,0,16,10,49,0,57,59,121,0,0,18,109,0,16,8,48,0,57,59,122,0,0,18,109,0,16,10,49,0,57,
-59,122,0,0,18,109,0,16,8,48,0,57,59,119,0,0,18,109,0,16,10,49,0,57,59,119,0,0,0,0,0,1,90,95,0,0,30,
-0,0,116,114,97,110,115,112,111,115,101,0,1,0,0,0,31,0,109,0,0,0,1,8,58,109,97,116,51,120,52,0,0,18,
-109,0,16,8,48,0,57,59,120,0,0,18,109,0,16,10,49,0,57,59,120,0,0,18,109,0,16,10,50,0,57,59,120,0,0,
-18,109,0,16,10,51,0,57,59,120,0,0,18,109,0,16,8,48,0,57,59,121,0,0,18,109,0,16,10,49,0,57,59,121,0,
-0,18,109,0,16,10,50,0,57,59,121,0,0,18,109,0,16,10,51,0,57,59,121,0,0,18,109,0,16,8,48,0,57,59,122,
-0,0,18,109,0,16,10,49,0,57,59,122,0,0,18,109,0,16,10,50,0,57,59,122,0,0,18,109,0,16,10,51,0,57,59,
-122,0,0,0,0,0,1,90,95,0,0,31,0,0,116,114,97,110,115,112,111,115,101,0,1,0,0,0,30,0,109,0,0,0,1,8,
-58,109,97,116,52,120,51,0,0,18,109,0,16,8,48,0,57,59,120,0,0,18,109,0,16,10,49,0,57,59,120,0,0,18,
-109,0,16,10,50,0,57,59,120,0,0,18,109,0,16,8,48,0,57,59,121,0,0,18,109,0,16,10,49,0,57,59,121,0,0,
-18,109,0,16,10,50,0,57,59,121,0,0,18,109,0,16,8,48,0,57,59,122,0,0,18,109,0,16,10,49,0,57,59,122,0,
-0,18,109,0,16,10,50,0,57,59,122,0,0,18,109,0,16,8,48,0,57,59,119,0,0,18,109,0,16,10,49,0,57,59,119,
-0,0,18,109,0,16,10,50,0,57,59,119,0,0,0,0,0,0
diff --git a/src/mesa/shader/slang/library/slang_builtin_120_fragment_gc.h b/src/mesa/shader/slang/library/slang_builtin_120_fragment_gc.h
deleted file mode 100644 (file)
index add3b5a..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-
-/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED FROM THE FOLLOWING FILE: */
-/* slang_builtin_120_fragment.gc */
-
-5,2,2,90,95,3,0,10,0,1,103,108,95,80,111,105,110,116,67,111,111,114,100,0,0,0,0
diff --git a/src/mesa/shader/slang/library/slang_common_builtin_gc.h b/src/mesa/shader/slang/library/slang_common_builtin_gc.h
deleted file mode 100644 (file)
index 3c3666e..0000000
+++ /dev/null
@@ -1,880 +0,0 @@
-
-/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED FROM THE FOLLOWING FILE: */
-/* slang_common_builtin.gc */
-
-5,2,2,90,95,1,0,5,0,1,103,108,95,77,97,120,76,105,103,104,116,115,0,2,16,10,56,0,0,0,2,2,90,95,1,0,
-5,0,1,103,108,95,77,97,120,67,108,105,112,80,108,97,110,101,115,0,2,16,10,54,0,0,0,2,2,90,95,1,0,5,
-0,1,103,108,95,77,97,120,84,101,120,116,117,114,101,85,110,105,116,115,0,2,16,10,56,0,0,0,2,2,90,
-95,1,0,5,0,1,103,108,95,77,97,120,84,101,120,116,117,114,101,67,111,111,114,100,115,0,2,16,10,56,0,
-0,0,2,2,90,95,1,0,5,0,1,103,108,95,77,97,120,86,101,114,116,101,120,65,116,116,114,105,98,115,0,2,
-16,10,49,54,0,0,0,2,2,90,95,1,0,5,0,1,103,108,95,77,97,120,86,101,114,116,101,120,85,110,105,102,
-111,114,109,67,111,109,112,111,110,101,110,116,115,0,2,16,10,53,49,50,0,0,0,2,2,90,95,1,0,5,0,1,
-103,108,95,77,97,120,86,97,114,121,105,110,103,70,108,111,97,116,115,0,2,16,10,51,50,0,0,0,2,2,90,
-95,1,0,5,0,1,103,108,95,77,97,120,86,101,114,116,101,120,84,101,120,116,117,114,101,73,109,97,103,
-101,85,110,105,116,115,0,2,16,8,48,0,0,0,2,2,90,95,1,0,5,0,1,103,108,95,77,97,120,67,111,109,98,
-105,110,101,100,84,101,120,116,117,114,101,73,109,97,103,101,85,110,105,116,115,0,2,16,10,50,0,0,0,
-2,2,90,95,1,0,5,0,1,103,108,95,77,97,120,84,101,120,116,117,114,101,73,109,97,103,101,85,110,105,
-116,115,0,2,16,10,50,0,0,0,2,2,90,95,1,0,5,0,1,103,108,95,77,97,120,70,114,97,103,109,101,110,116,
-85,110,105,102,111,114,109,67,111,109,112,111,110,101,110,116,115,0,2,16,10,54,52,0,0,0,2,2,90,95,
-1,0,5,0,1,103,108,95,77,97,120,68,114,97,119,66,117,102,102,101,114,115,0,2,16,10,49,0,0,0,2,2,90,
-95,4,0,15,0,1,103,108,95,77,111,100,101,108,86,105,101,119,77,97,116,114,105,120,0,0,0,2,2,90,95,4,
-0,15,0,1,103,108,95,80,114,111,106,101,99,116,105,111,110,77,97,116,114,105,120,0,0,0,2,2,90,95,4,
-0,15,0,1,103,108,95,77,111,100,101,108,86,105,101,119,80,114,111,106,101,99,116,105,111,110,77,97,
-116,114,105,120,0,0,0,2,2,90,95,4,0,15,0,1,103,108,95,84,101,120,116,117,114,101,77,97,116,114,105,
-120,0,3,18,103,108,95,77,97,120,84,101,120,116,117,114,101,67,111,111,114,100,115,0,0,0,2,2,90,95,
-4,0,14,0,1,103,108,95,78,111,114,109,97,108,77,97,116,114,105,120,0,0,0,2,2,90,95,4,0,15,0,1,103,
-108,95,77,111,100,101,108,86,105,101,119,77,97,116,114,105,120,73,110,118,101,114,115,101,0,0,0,2,
-2,90,95,4,0,15,0,1,103,108,95,80,114,111,106,101,99,116,105,111,110,77,97,116,114,105,120,73,110,
-118,101,114,115,101,0,0,0,2,2,90,95,4,0,15,0,1,103,108,95,77,111,100,101,108,86,105,101,119,80,114,
-111,106,101,99,116,105,111,110,77,97,116,114,105,120,73,110,118,101,114,115,101,0,0,0,2,2,90,95,4,
-0,15,0,1,103,108,95,84,101,120,116,117,114,101,77,97,116,114,105,120,73,110,118,101,114,115,101,0,
-3,18,103,108,95,77,97,120,84,101,120,116,117,114,101,67,111,111,114,100,115,0,0,0,2,2,90,95,4,0,15,
-0,1,103,108,95,77,111,100,101,108,86,105,101,119,77,97,116,114,105,120,84,114,97,110,115,112,111,
-115,101,0,0,0,2,2,90,95,4,0,15,0,1,103,108,95,80,114,111,106,101,99,116,105,111,110,77,97,116,114,
-105,120,84,114,97,110,115,112,111,115,101,0,0,0,2,2,90,95,4,0,15,0,1,103,108,95,77,111,100,101,108,
-86,105,101,119,80,114,111,106,101,99,116,105,111,110,77,97,116,114,105,120,84,114,97,110,115,112,
-111,115,101,0,0,0,2,2,90,95,4,0,15,0,1,103,108,95,84,101,120,116,117,114,101,77,97,116,114,105,120,
-84,114,97,110,115,112,111,115,101,0,3,18,103,108,95,77,97,120,84,101,120,116,117,114,101,67,111,
-111,114,100,115,0,0,0,2,2,90,95,4,0,15,0,1,103,108,95,77,111,100,101,108,86,105,101,119,77,97,116,
-114,105,120,73,110,118,101,114,115,101,84,114,97,110,115,112,111,115,101,0,0,0,2,2,90,95,4,0,15,0,
-1,103,108,95,80,114,111,106,101,99,116,105,111,110,77,97,116,114,105,120,73,110,118,101,114,115,
-101,84,114,97,110,115,112,111,115,101,0,0,0,2,2,90,95,4,0,15,0,1,103,108,95,77,111,100,101,108,86,
-105,101,119,80,114,111,106,101,99,116,105,111,110,77,97,116,114,105,120,73,110,118,101,114,115,101,
-84,114,97,110,115,112,111,115,101,0,0,0,2,2,90,95,4,0,15,0,1,103,108,95,84,101,120,116,117,114,101,
-77,97,116,114,105,120,73,110,118,101,114,115,101,84,114,97,110,115,112,111,115,101,0,3,18,103,108,
-95,77,97,120,84,101,120,116,117,114,101,67,111,111,114,100,115,0,0,0,2,2,90,95,4,0,9,0,1,103,108,
-95,78,111,114,109,97,108,83,99,97,108,101,0,0,0,2,2,90,95,0,0,24,103,108,95,68,101,112,116,104,82,
-97,110,103,101,80,97,114,97,109,101,116,101,114,115,0,9,0,110,101,97,114,0,0,0,1,9,0,102,97,114,0,
-0,0,1,9,0,100,105,102,102,0,0,0,0,0,0,0,2,2,90,95,4,0,25,103,108,95,68,101,112,116,104,82,97,110,
-103,101,80,97,114,97,109,101,116,101,114,115,0,0,1,103,108,95,68,101,112,116,104,82,97,110,103,101,
-0,0,0,2,2,90,95,4,0,12,0,1,103,108,95,67,108,105,112,80,108,97,110,101,0,3,18,103,108,95,77,97,120,
-67,108,105,112,80,108,97,110,101,115,0,0,0,2,2,90,95,0,0,24,103,108,95,80,111,105,110,116,80,97,
-114,97,109,101,116,101,114,115,0,9,0,115,105,122,101,0,0,0,1,9,0,115,105,122,101,77,105,110,0,0,0,
-1,9,0,115,105,122,101,77,97,120,0,0,0,1,9,0,102,97,100,101,84,104,114,101,115,104,111,108,100,83,
-105,122,101,0,0,0,1,9,0,100,105,115,116,97,110,99,101,67,111,110,115,116,97,110,116,65,116,116,101,
-110,117,97,116,105,111,110,0,0,0,1,9,0,100,105,115,116,97,110,99,101,76,105,110,101,97,114,65,116,
-116,101,110,117,97,116,105,111,110,0,0,0,1,9,0,100,105,115,116,97,110,99,101,81,117,97,100,114,97,
-116,105,99,65,116,116,101,110,117,97,116,105,111,110,0,0,0,0,0,0,0,2,2,90,95,4,0,25,103,108,95,80,
-111,105,110,116,80,97,114,97,109,101,116,101,114,115,0,0,1,103,108,95,80,111,105,110,116,0,0,0,2,2,
-90,95,0,0,24,103,108,95,77,97,116,101,114,105,97,108,80,97,114,97,109,101,116,101,114,115,0,12,0,
-101,109,105,115,115,105,111,110,0,0,0,1,12,0,97,109,98,105,101,110,116,0,0,0,1,12,0,100,105,102,
-102,117,115,101,0,0,0,1,12,0,115,112,101,99,117,108,97,114,0,0,0,1,9,0,115,104,105,110,105,110,101,
-115,115,0,0,0,0,0,0,0,2,2,90,95,4,0,25,103,108,95,77,97,116,101,114,105,97,108,80,97,114,97,109,
-101,116,101,114,115,0,0,1,103,108,95,70,114,111,110,116,77,97,116,101,114,105,97,108,0,0,0,2,2,90,
-95,4,0,25,103,108,95,77,97,116,101,114,105,97,108,80,97,114,97,109,101,116,101,114,115,0,0,1,103,
-108,95,66,97,99,107,77,97,116,101,114,105,97,108,0,0,0,2,2,90,95,0,0,24,103,108,95,76,105,103,104,
-116,83,111,117,114,99,101,80,97,114,97,109,101,116,101,114,115,0,12,0,97,109,98,105,101,110,116,0,
-0,0,1,12,0,100,105,102,102,117,115,101,0,0,0,1,12,0,115,112,101,99,117,108,97,114,0,0,0,1,12,0,112,
-111,115,105,116,105,111,110,0,0,0,1,12,0,104,97,108,102,86,101,99,116,111,114,0,0,0,1,11,0,115,112,
-111,116,68,105,114,101,99,116,105,111,110,0,0,0,1,9,0,115,112,111,116,67,111,115,67,117,116,111,
-102,102,0,0,0,1,9,0,99,111,110,115,116,97,110,116,65,116,116,101,110,117,97,116,105,111,110,0,0,0,
-1,9,0,108,105,110,101,97,114,65,116,116,101,110,117,97,116,105,111,110,0,0,0,1,9,0,113,117,97,100,
-114,97,116,105,99,65,116,116,101,110,117,97,116,105,111,110,0,0,0,1,9,0,115,112,111,116,69,120,112,
-111,110,101,110,116,0,0,0,1,9,0,115,112,111,116,67,117,116,111,102,102,0,0,0,0,0,0,0,2,2,90,95,4,0,
-25,103,108,95,76,105,103,104,116,83,111,117,114,99,101,80,97,114,97,109,101,116,101,114,115,0,0,1,
-103,108,95,76,105,103,104,116,83,111,117,114,99,101,0,3,18,103,108,95,77,97,120,76,105,103,104,116,
-115,0,0,0,2,2,90,95,0,0,24,103,108,95,76,105,103,104,116,77,111,100,101,108,80,97,114,97,109,101,
-116,101,114,115,0,12,0,97,109,98,105,101,110,116,0,0,0,0,0,0,0,2,2,90,95,4,0,25,103,108,95,76,105,
-103,104,116,77,111,100,101,108,80,97,114,97,109,101,116,101,114,115,0,0,1,103,108,95,76,105,103,
-104,116,77,111,100,101,108,0,0,0,2,2,90,95,0,0,24,103,108,95,76,105,103,104,116,77,111,100,101,108,
-80,114,111,100,117,99,116,115,0,12,0,115,99,101,110,101,67,111,108,111,114,0,0,0,0,0,0,0,2,2,90,95,
-4,0,25,103,108,95,76,105,103,104,116,77,111,100,101,108,80,114,111,100,117,99,116,115,0,0,1,103,
-108,95,70,114,111,110,116,76,105,103,104,116,77,111,100,101,108,80,114,111,100,117,99,116,0,0,0,2,
-2,90,95,4,0,25,103,108,95,76,105,103,104,116,77,111,100,101,108,80,114,111,100,117,99,116,115,0,0,
-1,103,108,95,66,97,99,107,76,105,103,104,116,77,111,100,101,108,80,114,111,100,117,99,116,0,0,0,2,
-2,90,95,0,0,24,103,108,95,76,105,103,104,116,80,114,111,100,117,99,116,115,0,12,0,97,109,98,105,
-101,110,116,0,0,0,1,12,0,100,105,102,102,117,115,101,0,0,0,1,12,0,115,112,101,99,117,108,97,114,0,
-0,0,0,0,0,0,2,2,90,95,4,0,25,103,108,95,76,105,103,104,116,80,114,111,100,117,99,116,115,0,0,1,103,
-108,95,70,114,111,110,116,76,105,103,104,116,80,114,111,100,117,99,116,0,3,18,103,108,95,77,97,120,
-76,105,103,104,116,115,0,0,0,2,2,90,95,4,0,25,103,108,95,76,105,103,104,116,80,114,111,100,117,99,
-116,115,0,0,1,103,108,95,66,97,99,107,76,105,103,104,116,80,114,111,100,117,99,116,0,3,18,103,108,
-95,77,97,120,76,105,103,104,116,115,0,0,0,2,2,90,95,4,0,12,0,1,103,108,95,84,101,120,116,117,114,
-101,69,110,118,67,111,108,111,114,0,3,18,103,108,95,77,97,120,84,101,120,116,117,114,101,73,109,97,
-103,101,85,110,105,116,115,0,0,0,2,2,90,95,4,0,12,0,1,103,108,95,69,121,101,80,108,97,110,101,83,0,
-3,18,103,108,95,77,97,120,84,101,120,116,117,114,101,67,111,111,114,100,115,0,0,0,2,2,90,95,4,0,12,
-0,1,103,108,95,69,121,101,80,108,97,110,101,84,0,3,18,103,108,95,77,97,120,84,101,120,116,117,114,
-101,67,111,111,114,100,115,0,0,0,2,2,90,95,4,0,12,0,1,103,108,95,69,121,101,80,108,97,110,101,82,0,
-3,18,103,108,95,77,97,120,84,101,120,116,117,114,101,67,111,111,114,100,115,0,0,0,2,2,90,95,4,0,12,
-0,1,103,108,95,69,121,101,80,108,97,110,101,81,0,3,18,103,108,95,77,97,120,84,101,120,116,117,114,
-101,67,111,111,114,100,115,0,0,0,2,2,90,95,4,0,12,0,1,103,108,95,79,98,106,101,99,116,80,108,97,
-110,101,83,0,3,18,103,108,95,77,97,120,84,101,120,116,117,114,101,67,111,111,114,100,115,0,0,0,2,2,
-90,95,4,0,12,0,1,103,108,95,79,98,106,101,99,116,80,108,97,110,101,84,0,3,18,103,108,95,77,97,120,
-84,101,120,116,117,114,101,67,111,111,114,100,115,0,0,0,2,2,90,95,4,0,12,0,1,103,108,95,79,98,106,
-101,99,116,80,108,97,110,101,82,0,3,18,103,108,95,77,97,120,84,101,120,116,117,114,101,67,111,111,
-114,100,115,0,0,0,2,2,90,95,4,0,12,0,1,103,108,95,79,98,106,101,99,116,80,108,97,110,101,81,0,3,18,
-103,108,95,77,97,120,84,101,120,116,117,114,101,67,111,111,114,100,115,0,0,0,2,2,90,95,0,0,24,103,
-108,95,70,111,103,80,97,114,97,109,101,116,101,114,115,0,12,0,99,111,108,111,114,0,0,0,1,9,0,100,
-101,110,115,105,116,121,0,0,0,1,9,0,115,116,97,114,116,0,0,0,1,9,0,101,110,100,0,0,0,1,9,0,115,99,
-97,108,101,0,0,0,0,0,0,0,2,2,90,95,4,0,25,103,108,95,70,111,103,80,97,114,97,109,101,116,101,114,
-115,0,0,1,103,108,95,70,111,103,0,0,0,1,90,95,0,0,9,0,0,114,97,100,105,97,110,115,0,1,1,0,0,9,0,
-100,101,103,0,0,0,1,3,2,90,95,1,0,9,0,1,99,0,2,17,51,0,49,52,49,53,57,50,54,0,0,17,49,56,48,0,48,0,
-0,49,0,0,4,118,101,99,52,95,109,117,108,116,105,112,108,121,0,18,95,95,114,101,116,86,97,108,0,0,
-18,100,101,103,0,0,18,99,0,0,0,0,1,90,95,0,0,10,0,0,114,97,100,105,97,110,115,0,1,1,0,0,10,0,100,
-101,103,0,0,0,1,3,2,90,95,1,0,9,0,1,99,0,2,17,51,0,49,52,49,53,57,50,54,0,0,17,49,56,48,0,48,0,0,
-49,0,0,4,118,101,99,52,95,109,117,108,116,105,112,108,121,0,18,95,95,114,101,116,86,97,108,0,59,
-120,121,0,0,18,100,101,103,0,59,120,121,0,0,18,99,0,59,120,120,0,0,0,0,1,90,95,0,0,11,0,0,114,97,
-100,105,97,110,115,0,1,1,0,0,11,0,100,101,103,0,0,0,1,3,2,90,95,1,0,9,0,1,99,0,2,17,51,0,49,52,49,
-53,57,50,54,0,0,17,49,56,48,0,48,0,0,49,0,0,4,118,101,99,52,95,109,117,108,116,105,112,108,121,0,
-18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,100,101,103,0,59,120,121,122,0,0,18,99,0,59,
-120,120,120,0,0,0,0,1,90,95,0,0,12,0,0,114,97,100,105,97,110,115,0,1,1,0,0,12,0,100,101,103,0,0,0,
-1,3,2,90,95,1,0,9,0,1,99,0,2,17,51,0,49,52,49,53,57,50,54,0,0,17,49,56,48,0,48,0,0,49,0,0,4,118,
-101,99,52,95,109,117,108,116,105,112,108,121,0,18,95,95,114,101,116,86,97,108,0,0,18,100,101,103,0,
-0,18,99,0,59,120,120,120,120,0,0,0,0,1,90,95,0,0,9,0,0,100,101,103,114,101,101,115,0,1,1,0,0,9,0,
-114,97,100,0,0,0,1,3,2,90,95,1,0,9,0,1,99,0,2,17,49,56,48,0,48,0,0,17,51,0,49,52,49,53,57,50,54,0,
-0,49,0,0,4,118,101,99,52,95,109,117,108,116,105,112,108,121,0,18,95,95,114,101,116,86,97,108,0,0,
-18,114,97,100,0,0,18,99,0,0,0,0,1,90,95,0,0,10,0,0,100,101,103,114,101,101,115,0,1,1,0,0,10,0,114,
-97,100,0,0,0,1,3,2,90,95,1,0,9,0,1,99,0,2,17,49,56,48,0,48,0,0,17,51,0,49,52,49,53,57,50,54,0,0,49,
-0,0,4,118,101,99,52,95,109,117,108,116,105,112,108,121,0,18,95,95,114,101,116,86,97,108,0,59,120,
-121,0,0,18,114,97,100,0,59,120,121,0,0,18,99,0,59,120,120,0,0,0,0,1,90,95,0,0,11,0,0,100,101,103,
-114,101,101,115,0,1,1,0,0,11,0,114,97,100,0,0,0,1,3,2,90,95,1,0,9,0,1,99,0,2,17,49,56,48,0,48,0,0,
-17,51,0,49,52,49,53,57,50,54,0,0,49,0,0,4,118,101,99,52,95,109,117,108,116,105,112,108,121,0,18,95,
-95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,114,97,100,0,59,120,121,122,0,0,18,99,0,59,120,
-120,120,0,0,0,0,1,90,95,0,0,12,0,0,100,101,103,114,101,101,115,0,1,1,0,0,12,0,114,97,100,0,0,0,1,3,
-2,90,95,1,0,9,0,1,99,0,2,17,49,56,48,0,48,0,0,17,51,0,49,52,49,53,57,50,54,0,0,49,0,0,4,118,101,99,
-52,95,109,117,108,116,105,112,108,121,0,18,95,95,114,101,116,86,97,108,0,0,18,114,97,100,0,0,18,99,
-0,59,120,120,120,120,0,0,0,0,1,90,95,0,0,9,0,0,115,105,110,0,1,1,0,0,9,0,114,97,100,105,97,110,115,
-0,0,0,1,4,102,108,111,97,116,95,115,105,110,101,0,18,95,95,114,101,116,86,97,108,0,0,18,114,97,100,
-105,97,110,115,0,0,0,0,1,90,95,0,0,10,0,0,115,105,110,0,1,1,0,0,10,0,114,97,100,105,97,110,115,0,0,
-0,1,4,102,108,111,97,116,95,115,105,110,101,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,114,
-97,100,105,97,110,115,0,59,120,0,0,0,4,102,108,111,97,116,95,115,105,110,101,0,18,95,95,114,101,
-116,86,97,108,0,59,121,0,0,18,114,97,100,105,97,110,115,0,59,121,0,0,0,0,1,90,95,0,0,11,0,0,115,
-105,110,0,1,1,0,0,11,0,114,97,100,105,97,110,115,0,0,0,1,4,102,108,111,97,116,95,115,105,110,101,0,
-18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,114,97,100,105,97,110,115,0,59,120,0,0,0,4,102,108,
-111,97,116,95,115,105,110,101,0,18,95,95,114,101,116,86,97,108,0,59,121,0,0,18,114,97,100,105,97,
-110,115,0,59,121,0,0,0,4,102,108,111,97,116,95,115,105,110,101,0,18,95,95,114,101,116,86,97,108,0,
-59,122,0,0,18,114,97,100,105,97,110,115,0,59,122,0,0,0,0,1,90,95,0,0,12,0,0,115,105,110,0,1,1,0,0,
-12,0,114,97,100,105,97,110,115,0,0,0,1,4,102,108,111,97,116,95,115,105,110,101,0,18,95,95,114,101,
-116,86,97,108,0,59,120,0,0,18,114,97,100,105,97,110,115,0,59,120,0,0,0,4,102,108,111,97,116,95,115,
-105,110,101,0,18,95,95,114,101,116,86,97,108,0,59,121,0,0,18,114,97,100,105,97,110,115,0,59,121,0,
-0,0,4,102,108,111,97,116,95,115,105,110,101,0,18,95,95,114,101,116,86,97,108,0,59,122,0,0,18,114,
-97,100,105,97,110,115,0,59,122,0,0,0,4,102,108,111,97,116,95,115,105,110,101,0,18,95,95,114,101,
-116,86,97,108,0,59,119,0,0,18,114,97,100,105,97,110,115,0,59,119,0,0,0,0,1,90,95,0,0,9,0,0,99,111,
-115,0,1,1,0,0,9,0,114,97,100,105,97,110,115,0,0,0,1,4,102,108,111,97,116,95,99,111,115,105,110,101,
-0,18,95,95,114,101,116,86,97,108,0,0,18,114,97,100,105,97,110,115,0,0,0,0,1,90,95,0,0,10,0,0,99,
-111,115,0,1,1,0,0,10,0,114,97,100,105,97,110,115,0,0,0,1,4,102,108,111,97,116,95,99,111,115,105,
-110,101,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,114,97,100,105,97,110,115,0,59,120,0,0,0,
-4,102,108,111,97,116,95,99,111,115,105,110,101,0,18,95,95,114,101,116,86,97,108,0,59,121,0,0,18,
-114,97,100,105,97,110,115,0,59,121,0,0,0,0,1,90,95,0,0,11,0,0,99,111,115,0,1,1,0,0,11,0,114,97,100,
-105,97,110,115,0,0,0,1,4,102,108,111,97,116,95,99,111,115,105,110,101,0,18,95,95,114,101,116,86,97,
-108,0,59,120,0,0,18,114,97,100,105,97,110,115,0,59,120,0,0,0,4,102,108,111,97,116,95,99,111,115,
-105,110,101,0,18,95,95,114,101,116,86,97,108,0,59,121,0,0,18,114,97,100,105,97,110,115,0,59,121,0,
-0,0,4,102,108,111,97,116,95,99,111,115,105,110,101,0,18,95,95,114,101,116,86,97,108,0,59,122,0,0,
-18,114,97,100,105,97,110,115,0,59,122,0,0,0,0,1,90,95,0,0,12,0,0,99,111,115,0,1,1,0,0,12,0,114,97,
-100,105,97,110,115,0,0,0,1,4,102,108,111,97,116,95,99,111,115,105,110,101,0,18,95,95,114,101,116,
-86,97,108,0,59,120,0,0,18,114,97,100,105,97,110,115,0,59,120,0,0,0,4,102,108,111,97,116,95,99,111,
-115,105,110,101,0,18,95,95,114,101,116,86,97,108,0,59,121,0,0,18,114,97,100,105,97,110,115,0,59,
-121,0,0,0,4,102,108,111,97,116,95,99,111,115,105,110,101,0,18,95,95,114,101,116,86,97,108,0,59,122,
-0,0,18,114,97,100,105,97,110,115,0,59,122,0,0,0,4,102,108,111,97,116,95,99,111,115,105,110,101,0,
-18,95,95,114,101,116,86,97,108,0,59,119,0,0,18,114,97,100,105,97,110,115,0,59,119,0,0,0,0,1,90,95,
-0,0,9,0,0,116,97,110,0,1,1,0,0,9,0,97,110,103,108,101,0,0,0,1,3,2,90,95,1,0,9,0,1,115,0,2,58,115,
-105,110,0,0,18,97,110,103,108,101,0,0,0,0,0,3,2,90,95,1,0,9,0,1,99,0,2,58,99,111,115,0,0,18,97,110,
-103,108,101,0,0,0,0,0,8,18,115,0,18,99,0,49,0,0,1,90,95,0,0,10,0,0,116,97,110,0,1,1,0,0,10,0,97,
-110,103,108,101,0,0,0,1,3,2,90,95,1,0,10,0,1,115,0,2,58,115,105,110,0,0,18,97,110,103,108,101,0,0,
-0,0,0,3,2,90,95,1,0,10,0,1,99,0,2,58,99,111,115,0,0,18,97,110,103,108,101,0,0,0,0,0,8,18,115,0,18,
-99,0,49,0,0,1,90,95,0,0,11,0,0,116,97,110,0,1,1,0,0,11,0,97,110,103,108,101,0,0,0,1,3,2,90,95,1,0,
-11,0,1,115,0,2,58,115,105,110,0,0,18,97,110,103,108,101,0,0,0,0,0,3,2,90,95,1,0,11,0,1,99,0,2,58,
-99,111,115,0,0,18,97,110,103,108,101,0,0,0,0,0,8,18,115,0,18,99,0,49,0,0,1,90,95,0,0,12,0,0,116,97,
-110,0,1,1,0,0,12,0,97,110,103,108,101,0,0,0,1,3,2,90,95,1,0,12,0,1,115,0,2,58,115,105,110,0,0,18,
-97,110,103,108,101,0,0,0,0,0,3,2,90,95,1,0,12,0,1,99,0,2,58,99,111,115,0,0,18,97,110,103,108,101,0,
-0,0,0,0,8,18,115,0,18,99,0,49,0,0,1,90,95,0,0,9,0,0,97,115,105,110,0,1,1,0,0,9,0,120,0,0,0,1,3,2,
-90,95,1,0,9,0,1,97,48,0,2,17,49,0,53,55,48,55,50,56,56,0,0,0,0,3,2,90,95,1,0,9,0,1,97,49,0,2,17,48,
-0,50,49,50,49,49,52,52,0,0,54,0,0,3,2,90,95,1,0,9,0,1,97,50,0,2,17,48,0,48,55,52,50,54,49,48,0,0,0,
-0,3,2,90,95,1,0,9,0,1,104,97,108,102,80,105,0,2,17,51,0,49,52,49,53,57,50,54,0,0,17,48,0,53,0,0,48,
-0,0,3,2,90,95,1,0,9,0,1,121,0,2,58,97,98,115,0,0,18,120,0,0,0,0,0,9,18,95,95,114,101,116,86,97,108,
-0,18,104,97,108,102,80,105,0,58,115,113,114,116,0,0,17,49,0,48,0,0,18,121,0,47,0,0,18,97,48,0,18,
-121,0,18,97,49,0,18,97,50,0,18,121,0,48,46,48,46,48,47,58,115,105,103,110,0,0,18,120,0,0,0,48,20,0,
-0,1,90,95,0,0,10,0,0,97,115,105,110,0,1,1,0,0,10,0,118,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,
-59,120,0,58,97,115,105,110,0,0,18,118,0,59,120,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,
-121,0,58,97,115,105,110,0,0,18,118,0,59,121,0,0,0,20,0,0,1,90,95,0,0,11,0,0,97,115,105,110,0,1,1,0,
-0,11,0,118,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,58,97,115,105,110,0,0,18,118,0,59,
-120,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,58,97,115,105,110,0,0,18,118,0,59,121,0,
-0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,58,97,115,105,110,0,0,18,118,0,59,122,0,0,0,
-20,0,0,1,90,95,0,0,12,0,0,97,115,105,110,0,1,1,0,0,12,0,118,0,0,0,1,9,18,95,95,114,101,116,86,97,
-108,0,59,120,0,58,97,115,105,110,0,0,18,118,0,59,120,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,
-59,121,0,58,97,115,105,110,0,0,18,118,0,59,121,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,
-122,0,58,97,115,105,110,0,0,18,118,0,59,122,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,119,0,
-58,97,115,105,110,0,0,18,118,0,59,119,0,0,0,20,0,0,1,90,95,0,0,9,0,0,97,99,111,115,0,1,1,0,0,9,0,
-120,0,0,0,1,3,2,90,95,1,0,9,0,1,104,97,108,102,80,105,0,2,17,51,0,49,52,49,53,57,50,54,0,0,17,48,0,
-53,0,0,48,0,0,9,18,95,95,114,101,116,86,97,108,0,18,104,97,108,102,80,105,0,58,97,115,105,110,0,0,
-18,120,0,0,0,47,20,0,0,1,90,95,0,0,10,0,0,97,99,111,115,0,1,1,0,0,10,0,118,0,0,0,1,9,18,95,95,114,
-101,116,86,97,108,0,59,120,0,58,97,99,111,115,0,0,18,118,0,59,120,0,0,0,20,0,9,18,95,95,114,101,
-116,86,97,108,0,59,121,0,58,97,99,111,115,0,0,18,118,0,59,121,0,0,0,20,0,0,1,90,95,0,0,11,0,0,97,
-99,111,115,0,1,1,0,0,11,0,118,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,58,97,99,111,115,
-0,0,18,118,0,59,120,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,58,97,99,111,115,0,0,18,
-118,0,59,121,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,58,97,99,111,115,0,0,18,118,0,
-59,122,0,0,0,20,0,0,1,90,95,0,0,12,0,0,97,99,111,115,0,1,1,0,0,12,0,118,0,0,0,1,9,18,95,95,114,101,
-116,86,97,108,0,59,120,0,58,97,99,111,115,0,0,18,118,0,59,120,0,0,0,20,0,9,18,95,95,114,101,116,86,
-97,108,0,59,121,0,58,97,99,111,115,0,0,18,118,0,59,121,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,
-0,59,122,0,58,97,99,111,115,0,0,18,118,0,59,122,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,
-119,0,58,97,99,111,115,0,0,18,118,0,59,119,0,0,0,20,0,0,1,90,95,0,0,9,0,0,97,116,97,110,0,1,1,0,0,
-9,0,120,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,97,115,105,110,0,0,18,120,0,58,105,110,118,
-101,114,115,101,115,113,114,116,0,0,18,120,0,18,120,0,48,17,49,0,48,0,0,46,0,0,48,0,0,20,0,0,1,90,
-95,0,0,10,0,0,97,116,97,110,0,1,1,0,0,10,0,121,95,111,118,101,114,95,120,0,0,0,1,9,18,95,95,114,
-101,116,86,97,108,0,59,120,0,58,97,116,97,110,0,0,18,121,95,111,118,101,114,95,120,0,59,120,0,0,0,
-20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,58,97,116,97,110,0,0,18,121,95,111,118,101,114,95,
-120,0,59,121,0,0,0,20,0,0,1,90,95,0,0,11,0,0,97,116,97,110,0,1,1,0,0,11,0,121,95,111,118,101,114,
-95,120,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,58,97,116,97,110,0,0,18,121,95,111,118,
-101,114,95,120,0,59,120,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,58,97,116,97,110,0,
-0,18,121,95,111,118,101,114,95,120,0,59,121,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,
-58,97,116,97,110,0,0,18,121,95,111,118,101,114,95,120,0,59,122,0,0,0,20,0,0,1,90,95,0,0,12,0,0,97,
-116,97,110,0,1,1,0,0,12,0,121,95,111,118,101,114,95,120,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,
-59,120,0,58,97,116,97,110,0,0,18,121,95,111,118,101,114,95,120,0,59,120,0,0,0,20,0,9,18,95,95,114,
-101,116,86,97,108,0,59,121,0,58,97,116,97,110,0,0,18,121,95,111,118,101,114,95,120,0,59,121,0,0,0,
-20,0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,58,97,116,97,110,0,0,18,121,95,111,118,101,114,95,
-120,0,59,122,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,119,0,58,97,116,97,110,0,0,18,121,95,
-111,118,101,114,95,120,0,59,119,0,0,0,20,0,0,1,90,95,0,0,9,0,0,97,116,97,110,0,1,1,0,0,9,0,121,0,0,
-1,1,0,0,9,0,120,0,0,0,1,3,2,90,95,0,0,9,0,1,114,0,0,0,10,58,97,98,115,0,0,18,120,0,0,0,17,49,0,48,
-0,45,52,0,41,0,2,9,18,114,0,58,97,116,97,110,0,0,18,121,0,18,120,0,49,0,0,20,0,10,18,120,0,17,48,0,
-48,0,0,40,0,2,9,18,114,0,18,114,0,58,115,105,103,110,0,0,18,121,0,0,0,17,51,0,49,52,49,53,57,51,0,
-0,48,46,20,0,0,9,14,0,0,2,9,18,114,0,58,115,105,103,110,0,0,18,121,0,0,0,17,49,0,53,55,48,55,57,54,
-53,0,0,48,20,0,0,8,18,114,0,0,0,1,90,95,0,0,10,0,0,97,116,97,110,0,1,1,0,0,10,0,117,0,0,1,1,0,0,10,
-0,118,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,58,97,116,97,110,0,0,18,117,0,59,120,0,0,
-18,118,0,59,120,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,58,97,116,97,110,0,0,18,117,
-0,59,121,0,0,18,118,0,59,121,0,0,0,20,0,0,1,90,95,0,0,11,0,0,97,116,97,110,0,1,1,0,0,11,0,117,0,0,
-1,1,0,0,11,0,118,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,58,97,116,97,110,0,0,18,117,0,
-59,120,0,0,18,118,0,59,120,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,58,97,116,97,110,
-0,0,18,117,0,59,121,0,0,18,118,0,59,121,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,58,
-97,116,97,110,0,0,18,117,0,59,122,0,0,18,118,0,59,122,0,0,0,20,0,0,1,90,95,0,0,12,0,0,97,116,97,
-110,0,1,1,0,0,12,0,117,0,0,1,1,0,0,12,0,118,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,58,
-97,116,97,110,0,0,18,117,0,59,120,0,0,18,118,0,59,120,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,
-0,59,121,0,58,97,116,97,110,0,0,18,117,0,59,121,0,0,18,118,0,59,121,0,0,0,20,0,9,18,95,95,114,101,
-116,86,97,108,0,59,122,0,58,97,116,97,110,0,0,18,117,0,59,122,0,0,18,118,0,59,122,0,0,0,20,0,9,18,
-95,95,114,101,116,86,97,108,0,59,119,0,58,97,116,97,110,0,0,18,117,0,59,119,0,0,18,118,0,59,119,0,
-0,0,20,0,0,1,90,95,0,0,9,0,0,112,111,119,0,1,1,0,0,9,0,97,0,0,1,1,0,0,9,0,98,0,0,0,1,4,102,108,111,
-97,116,95,112,111,119,101,114,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,98,0,0,0,0,1,90,95,
-0,0,10,0,0,112,111,119,0,1,1,0,0,10,0,97,0,0,1,1,0,0,10,0,98,0,0,0,1,4,102,108,111,97,116,95,112,
-111,119,101,114,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,97,0,59,120,0,0,18,98,0,59,120,0,
-0,0,4,102,108,111,97,116,95,112,111,119,101,114,0,18,95,95,114,101,116,86,97,108,0,59,121,0,0,18,
-97,0,59,121,0,0,18,98,0,59,121,0,0,0,0,1,90,95,0,0,11,0,0,112,111,119,0,1,1,0,0,11,0,97,0,0,1,1,0,
-0,11,0,98,0,0,0,1,4,102,108,111,97,116,95,112,111,119,101,114,0,18,95,95,114,101,116,86,97,108,0,
-59,120,0,0,18,97,0,59,120,0,0,18,98,0,59,120,0,0,0,4,102,108,111,97,116,95,112,111,119,101,114,0,
-18,95,95,114,101,116,86,97,108,0,59,121,0,0,18,97,0,59,121,0,0,18,98,0,59,121,0,0,0,4,102,108,111,
-97,116,95,112,111,119,101,114,0,18,95,95,114,101,116,86,97,108,0,59,122,0,0,18,97,0,59,122,0,0,18,
-98,0,59,122,0,0,0,0,1,90,95,0,0,12,0,0,112,111,119,0,1,1,0,0,12,0,97,0,0,1,1,0,0,12,0,98,0,0,0,1,4,
-102,108,111,97,116,95,112,111,119,101,114,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,97,0,59,
-120,0,0,18,98,0,59,120,0,0,0,4,102,108,111,97,116,95,112,111,119,101,114,0,18,95,95,114,101,116,86,
-97,108,0,59,121,0,0,18,97,0,59,121,0,0,18,98,0,59,121,0,0,0,4,102,108,111,97,116,95,112,111,119,
-101,114,0,18,95,95,114,101,116,86,97,108,0,59,122,0,0,18,97,0,59,122,0,0,18,98,0,59,122,0,0,0,4,
-102,108,111,97,116,95,112,111,119,101,114,0,18,95,95,114,101,116,86,97,108,0,59,119,0,0,18,97,0,59,
-119,0,0,18,98,0,59,119,0,0,0,0,1,90,95,0,0,9,0,0,101,120,112,0,1,1,0,0,9,0,97,0,0,0,1,3,2,90,95,0,
-0,9,0,1,116,0,2,18,97,0,17,49,0,52,52,50,54,57,53,48,50,0,0,48,0,0,4,102,108,111,97,116,95,101,120,
-112,50,0,18,95,95,114,101,116,86,97,108,0,0,18,116,0,0,0,0,1,90,95,0,0,10,0,0,101,120,112,0,1,1,0,
-0,10,0,97,0,0,0,1,3,2,90,95,0,0,10,0,1,116,0,2,18,97,0,17,49,0,52,52,50,54,57,53,48,50,0,0,48,0,0,
-4,102,108,111,97,116,95,101,120,112,50,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,116,0,59,
-120,0,0,0,4,102,108,111,97,116,95,101,120,112,50,0,18,95,95,114,101,116,86,97,108,0,59,121,0,0,18,
-116,0,59,121,0,0,0,0,1,90,95,0,0,11,0,0,101,120,112,0,1,1,0,0,11,0,97,0,0,0,1,3,2,90,95,0,0,11,0,1,
-116,0,2,18,97,0,17,49,0,52,52,50,54,57,53,48,50,0,0,48,0,0,4,102,108,111,97,116,95,101,120,112,50,
-0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,116,0,59,120,0,0,0,4,102,108,111,97,116,95,101,
-120,112,50,0,18,95,95,114,101,116,86,97,108,0,59,121,0,0,18,116,0,59,121,0,0,0,4,102,108,111,97,
-116,95,101,120,112,50,0,18,95,95,114,101,116,86,97,108,0,59,122,0,0,18,116,0,59,122,0,0,0,0,1,90,
-95,0,0,12,0,0,101,120,112,0,1,1,0,0,12,0,97,0,0,0,1,3,2,90,95,0,0,12,0,1,116,0,2,18,97,0,17,49,0,
-52,52,50,54,57,53,48,50,0,0,48,0,0,4,102,108,111,97,116,95,101,120,112,50,0,18,95,95,114,101,116,
-86,97,108,0,59,120,0,0,18,116,0,59,120,0,0,0,4,102,108,111,97,116,95,101,120,112,50,0,18,95,95,114,
-101,116,86,97,108,0,59,121,0,0,18,116,0,59,121,0,0,0,4,102,108,111,97,116,95,101,120,112,50,0,18,
-95,95,114,101,116,86,97,108,0,59,122,0,0,18,116,0,59,122,0,0,0,4,102,108,111,97,116,95,101,120,112,
-50,0,18,95,95,114,101,116,86,97,108,0,59,119,0,0,18,116,0,59,119,0,0,0,0,1,90,95,0,0,9,0,0,108,111,
-103,50,0,1,1,0,0,9,0,120,0,0,0,1,4,102,108,111,97,116,95,108,111,103,50,0,18,95,95,114,101,116,86,
-97,108,0,0,18,120,0,0,0,0,1,90,95,0,0,10,0,0,108,111,103,50,0,1,1,0,0,10,0,118,0,0,0,1,4,102,108,
-111,97,116,95,108,111,103,50,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,118,0,59,120,0,0,0,4,
-102,108,111,97,116,95,108,111,103,50,0,18,95,95,114,101,116,86,97,108,0,59,121,0,0,18,118,0,59,121,
-0,0,0,0,1,90,95,0,0,11,0,0,108,111,103,50,0,1,1,0,0,11,0,118,0,0,0,1,4,102,108,111,97,116,95,108,
-111,103,50,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,118,0,59,120,0,0,0,4,102,108,111,97,
-116,95,108,111,103,50,0,18,95,95,114,101,116,86,97,108,0,59,121,0,0,18,118,0,59,121,0,0,0,4,102,
-108,111,97,116,95,108,111,103,50,0,18,95,95,114,101,116,86,97,108,0,59,122,0,0,18,118,0,59,122,0,0,
-0,0,1,90,95,0,0,12,0,0,108,111,103,50,0,1,1,0,0,12,0,118,0,0,0,1,4,102,108,111,97,116,95,108,111,
-103,50,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,118,0,59,120,0,0,0,4,102,108,111,97,116,95,
-108,111,103,50,0,18,95,95,114,101,116,86,97,108,0,59,121,0,0,18,118,0,59,121,0,0,0,4,102,108,111,
-97,116,95,108,111,103,50,0,18,95,95,114,101,116,86,97,108,0,59,122,0,0,18,118,0,59,122,0,0,0,4,102,
-108,111,97,116,95,108,111,103,50,0,18,95,95,114,101,116,86,97,108,0,59,119,0,0,18,118,0,59,119,0,0,
-0,0,1,90,95,0,0,9,0,0,108,111,103,0,1,1,0,0,9,0,120,0,0,0,1,3,2,90,95,1,0,9,0,1,99,0,2,17,48,0,54,
-57,51,49,52,55,49,56,49,0,0,0,0,8,58,108,111,103,50,0,0,18,120,0,0,0,18,99,0,48,0,0,1,90,95,0,0,10,
-0,0,108,111,103,0,1,1,0,0,10,0,118,0,0,0,1,3,2,90,95,1,0,9,0,1,99,0,2,17,48,0,54,57,51,49,52,55,49,
-56,49,0,0,0,0,8,58,108,111,103,50,0,0,18,118,0,0,0,18,99,0,48,0,0,1,90,95,0,0,11,0,0,108,111,103,0,
-1,1,0,0,11,0,118,0,0,0,1,3,2,90,95,1,0,9,0,1,99,0,2,17,48,0,54,57,51,49,52,55,49,56,49,0,0,0,0,8,
-58,108,111,103,50,0,0,18,118,0,0,0,18,99,0,48,0,0,1,90,95,0,0,12,0,0,108,111,103,0,1,1,0,0,12,0,
-118,0,0,0,1,3,2,90,95,1,0,9,0,1,99,0,2,17,48,0,54,57,51,49,52,55,49,56,49,0,0,0,0,8,58,108,111,103,
-50,0,0,18,118,0,0,0,18,99,0,48,0,0,1,90,95,0,0,9,0,0,101,120,112,50,0,1,1,0,0,9,0,97,0,0,0,1,4,102,
-108,111,97,116,95,101,120,112,50,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,0,0,1,90,95,0,0,10,
-0,0,101,120,112,50,0,1,1,0,0,10,0,97,0,0,0,1,4,102,108,111,97,116,95,101,120,112,50,0,18,95,95,114,
-101,116,86,97,108,0,59,120,0,0,18,97,0,59,120,0,0,0,4,102,108,111,97,116,95,101,120,112,50,0,18,95,
-95,114,101,116,86,97,108,0,59,121,0,0,18,97,0,59,121,0,0,0,0,1,90,95,0,0,11,0,0,101,120,112,50,0,1,
-1,0,0,11,0,97,0,0,0,1,4,102,108,111,97,116,95,101,120,112,50,0,18,95,95,114,101,116,86,97,108,0,59,
-120,0,0,18,97,0,59,120,0,0,0,4,102,108,111,97,116,95,101,120,112,50,0,18,95,95,114,101,116,86,97,
-108,0,59,121,0,0,18,97,0,59,121,0,0,0,4,102,108,111,97,116,95,101,120,112,50,0,18,95,95,114,101,
-116,86,97,108,0,59,122,0,0,18,97,0,59,122,0,0,0,0,1,90,95,0,0,12,0,0,101,120,112,50,0,1,1,0,0,12,0,
-97,0,0,0,1,4,102,108,111,97,116,95,101,120,112,50,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,
-97,0,59,120,0,0,0,4,102,108,111,97,116,95,101,120,112,50,0,18,95,95,114,101,116,86,97,108,0,59,121,
-0,0,18,97,0,59,121,0,0,0,4,102,108,111,97,116,95,101,120,112,50,0,18,95,95,114,101,116,86,97,108,0,
-59,122,0,0,18,97,0,59,122,0,0,0,4,102,108,111,97,116,95,101,120,112,50,0,18,95,95,114,101,116,86,
-97,108,0,59,119,0,0,18,97,0,59,119,0,0,0,0,1,90,95,0,0,9,0,0,115,113,114,116,0,1,1,0,0,9,0,120,0,0,
-0,1,3,2,90,95,1,0,9,0,1,110,120,0,2,18,120,0,54,0,0,3,2,90,95,0,0,9,0,1,114,0,0,0,4,102,108,111,97,
-116,95,114,115,113,0,18,114,0,0,18,120,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,114,0,0,18,
-114,0,0,0,4,118,101,99,52,95,99,109,112,0,18,95,95,114,101,116,86,97,108,0,0,18,110,120,0,0,18,114,
-0,0,17,48,0,48,0,0,0,0,0,1,90,95,0,0,10,0,0,115,113,114,116,0,1,1,0,0,10,0,120,0,0,0,1,3,2,90,95,1,
-0,10,0,1,110,120,0,2,18,120,0,54,0,1,1,122,101,114,111,0,2,58,118,101,99,50,0,0,17,48,0,48,0,0,0,0,
-0,0,3,2,90,95,0,0,10,0,1,114,0,0,0,4,102,108,111,97,116,95,114,115,113,0,18,114,0,59,120,0,0,18,
-120,0,59,120,0,0,0,4,102,108,111,97,116,95,114,115,113,0,18,114,0,59,121,0,0,18,120,0,59,121,0,0,0,
-4,102,108,111,97,116,95,114,99,112,0,18,114,0,59,120,0,0,18,114,0,59,120,0,0,0,4,102,108,111,97,
-116,95,114,99,112,0,18,114,0,59,121,0,0,18,114,0,59,121,0,0,0,4,118,101,99,52,95,99,109,112,0,18,
-95,95,114,101,116,86,97,108,0,0,18,110,120,0,0,18,114,0,0,18,122,101,114,111,0,0,0,0,1,90,95,0,0,
-11,0,0,115,113,114,116,0,1,1,0,0,11,0,120,0,0,0,1,3,2,90,95,1,0,11,0,1,110,120,0,2,18,120,0,54,0,1,
-1,122,101,114,111,0,2,58,118,101,99,51,0,0,17,48,0,48,0,0,0,0,0,0,3,2,90,95,0,0,11,0,1,114,0,0,0,4,
-102,108,111,97,116,95,114,115,113,0,18,114,0,59,120,0,0,18,120,0,59,120,0,0,0,4,102,108,111,97,116,
-95,114,115,113,0,18,114,0,59,121,0,0,18,120,0,59,121,0,0,0,4,102,108,111,97,116,95,114,115,113,0,
-18,114,0,59,122,0,0,18,120,0,59,122,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,114,0,59,120,0,0,
-18,114,0,59,120,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,114,0,59,121,0,0,18,114,0,59,121,0,0,
-0,4,102,108,111,97,116,95,114,99,112,0,18,114,0,59,122,0,0,18,114,0,59,122,0,0,0,4,118,101,99,52,
-95,99,109,112,0,18,95,95,114,101,116,86,97,108,0,0,18,110,120,0,0,18,114,0,0,18,122,101,114,111,0,
-0,0,0,1,90,95,0,0,12,0,0,115,113,114,116,0,1,1,0,0,12,0,120,0,0,0,1,3,2,90,95,1,0,12,0,1,110,120,0,
-2,18,120,0,54,0,1,1,122,101,114,111,0,2,58,118,101,99,52,0,0,17,48,0,48,0,0,0,0,0,0,3,2,90,95,0,0,
-12,0,1,114,0,0,0,4,102,108,111,97,116,95,114,115,113,0,18,114,0,59,120,0,0,18,120,0,59,120,0,0,0,4,
-102,108,111,97,116,95,114,115,113,0,18,114,0,59,121,0,0,18,120,0,59,121,0,0,0,4,102,108,111,97,116,
-95,114,115,113,0,18,114,0,59,122,0,0,18,120,0,59,122,0,0,0,4,102,108,111,97,116,95,114,115,113,0,
-18,114,0,59,119,0,0,18,120,0,59,119,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,114,0,59,120,0,0,
-18,114,0,59,120,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,114,0,59,121,0,0,18,114,0,59,121,0,0,
-0,4,102,108,111,97,116,95,114,99,112,0,18,114,0,59,122,0,0,18,114,0,59,122,0,0,0,4,102,108,111,97,
-116,95,114,99,112,0,18,114,0,59,119,0,0,18,114,0,59,119,0,0,0,4,118,101,99,52,95,99,109,112,0,18,
-95,95,114,101,116,86,97,108,0,0,18,110,120,0,0,18,114,0,0,18,122,101,114,111,0,0,0,0,1,90,95,0,0,9,
-0,0,105,110,118,101,114,115,101,115,113,114,116,0,1,1,0,0,9,0,120,0,0,0,1,4,102,108,111,97,116,95,
-114,115,113,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,120,0,0,0,0,1,90,95,0,0,10,0,0,105,
-110,118,101,114,115,101,115,113,114,116,0,1,1,0,0,10,0,118,0,0,0,1,4,102,108,111,97,116,95,114,115,
-113,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,118,0,59,120,0,0,0,4,102,108,111,97,116,95,
-114,115,113,0,18,95,95,114,101,116,86,97,108,0,59,121,0,0,18,118,0,59,121,0,0,0,0,1,90,95,0,0,11,0,
-0,105,110,118,101,114,115,101,115,113,114,116,0,1,1,0,0,11,0,118,0,0,0,1,4,102,108,111,97,116,95,
-114,115,113,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,118,0,59,120,0,0,0,4,102,108,111,97,
-116,95,114,115,113,0,18,95,95,114,101,116,86,97,108,0,59,121,0,0,18,118,0,59,121,0,0,0,4,102,108,
-111,97,116,95,114,115,113,0,18,95,95,114,101,116,86,97,108,0,59,122,0,0,18,118,0,59,122,0,0,0,0,1,
-90,95,0,0,12,0,0,105,110,118,101,114,115,101,115,113,114,116,0,1,1,0,0,12,0,118,0,0,0,1,4,102,108,
-111,97,116,95,114,115,113,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,118,0,59,120,0,0,0,4,
-102,108,111,97,116,95,114,115,113,0,18,95,95,114,101,116,86,97,108,0,59,121,0,0,18,118,0,59,121,0,
-0,0,4,102,108,111,97,116,95,114,115,113,0,18,95,95,114,101,116,86,97,108,0,59,122,0,0,18,118,0,59,
-122,0,0,0,4,102,108,111,97,116,95,114,115,113,0,18,95,95,114,101,116,86,97,108,0,59,119,0,0,18,118,
-0,59,119,0,0,0,0,1,90,95,0,0,9,0,0,110,111,114,109,97,108,105,122,101,0,1,1,0,0,9,0,120,0,0,0,1,9,
-18,95,95,114,101,116,86,97,108,0,17,49,0,48,0,0,20,0,0,1,90,95,0,0,10,0,0,110,111,114,109,97,108,
-105,122,101,0,1,1,0,0,10,0,118,0,0,0,1,3,2,90,95,1,0,9,0,1,115,0,2,58,105,110,118,101,114,115,101,
-115,113,114,116,0,0,58,100,111,116,0,0,18,118,0,0,18,118,0,0,0,0,0,0,0,4,118,101,99,52,95,109,117,
-108,116,105,112,108,121,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,118,0,0,18,115,0,0,0,
-0,1,90,95,0,0,11,0,0,110,111,114,109,97,108,105,122,101,0,1,1,0,0,11,0,118,0,0,0,1,3,2,90,95,0,0,9,
-0,1,116,109,112,0,0,0,4,118,101,99,51,95,100,111,116,0,18,116,109,112,0,0,18,118,0,0,18,118,0,0,0,
-4,102,108,111,97,116,95,114,115,113,0,18,116,109,112,0,0,18,116,109,112,0,0,0,4,118,101,99,52,95,
-109,117,108,116,105,112,108,121,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,118,0,0,
-18,116,109,112,0,0,0,0,1,90,95,0,0,12,0,0,110,111,114,109,97,108,105,122,101,0,1,1,0,0,12,0,118,0,
-0,0,1,3,2,90,95,0,0,9,0,1,116,109,112,0,0,0,4,118,101,99,52,95,100,111,116,0,18,116,109,112,0,0,18,
-118,0,0,18,118,0,0,0,4,102,108,111,97,116,95,114,115,113,0,18,116,109,112,0,0,18,116,109,112,0,0,0,
-4,118,101,99,52,95,109,117,108,116,105,112,108,121,0,18,95,95,114,101,116,86,97,108,0,59,120,121,
-122,0,0,18,118,0,0,18,116,109,112,0,0,0,0,1,90,95,0,0,9,0,0,97,98,115,0,1,1,0,0,9,0,97,0,0,0,1,4,
-118,101,99,52,95,97,98,115,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,0,0,1,90,95,0,0,10,0,0,
-97,98,115,0,1,1,0,0,10,0,97,0,0,0,1,4,118,101,99,52,95,97,98,115,0,18,95,95,114,101,116,86,97,108,
-0,59,120,121,0,0,18,97,0,0,0,0,1,90,95,0,0,11,0,0,97,98,115,0,1,1,0,0,11,0,97,0,0,0,1,4,118,101,99,
-52,95,97,98,115,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,97,0,0,0,0,1,90,95,0,0,12,
-0,0,97,98,115,0,1,1,0,0,12,0,97,0,0,0,1,4,118,101,99,52,95,97,98,115,0,18,95,95,114,101,116,86,97,
-108,0,0,18,97,0,0,0,0,1,90,95,0,0,9,0,0,115,105,103,110,0,1,1,0,0,9,0,120,0,0,0,1,3,2,90,95,0,0,9,
-0,1,112,0,0,1,1,110,0,0,0,4,118,101,99,52,95,115,103,116,0,18,112,0,0,18,120,0,0,17,48,0,48,0,0,0,
-0,4,118,101,99,52,95,115,103,116,0,18,110,0,0,17,48,0,48,0,0,0,18,120,0,0,0,4,118,101,99,52,95,115,
-117,98,116,114,97,99,116,0,18,95,95,114,101,116,86,97,108,0,0,18,112,0,0,18,110,0,0,0,0,1,90,95,0,
-0,10,0,0,115,105,103,110,0,1,1,0,0,10,0,118,0,0,0,1,3,2,90,95,0,0,10,0,1,112,0,0,1,1,110,0,0,0,4,
-118,101,99,52,95,115,103,116,0,18,112,0,59,120,121,0,0,18,118,0,0,17,48,0,48,0,0,0,0,4,118,101,99,
-52,95,115,103,116,0,18,110,0,59,120,121,0,0,17,48,0,48,0,0,0,18,118,0,0,0,4,118,101,99,52,95,115,
-117,98,116,114,97,99,116,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,112,0,0,18,110,0,0,0,
-0,1,90,95,0,0,11,0,0,115,105,103,110,0,1,1,0,0,11,0,118,0,0,0,1,3,2,90,95,0,0,11,0,1,112,0,0,1,1,
-110,0,0,0,4,118,101,99,52,95,115,103,116,0,18,112,0,59,120,121,122,0,0,18,118,0,0,17,48,0,48,0,0,0,
-0,4,118,101,99,52,95,115,103,116,0,18,110,0,59,120,121,122,0,0,17,48,0,48,0,0,0,18,118,0,0,0,4,118,
-101,99,52,95,115,117,98,116,114,97,99,116,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,
-112,0,0,18,110,0,0,0,0,1,90,95,0,0,12,0,0,115,105,103,110,0,1,1,0,0,12,0,118,0,0,0,1,3,2,90,95,0,0,
-12,0,1,112,0,0,1,1,110,0,0,0,4,118,101,99,52,95,115,103,116,0,18,112,0,0,18,118,0,0,17,48,0,48,0,0,
-0,0,4,118,101,99,52,95,115,103,116,0,18,110,0,0,17,48,0,48,0,0,0,18,118,0,0,0,4,118,101,99,52,95,
-115,117,98,116,114,97,99,116,0,18,95,95,114,101,116,86,97,108,0,0,18,112,0,0,18,110,0,0,0,0,1,90,
-95,0,0,9,0,0,102,108,111,111,114,0,1,1,0,0,9,0,97,0,0,0,1,4,118,101,99,52,95,102,108,111,111,114,0,
-18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,0,0,1,90,95,0,0,10,0,0,102,108,111,111,114,0,1,1,0,0,
-10,0,97,0,0,0,1,4,118,101,99,52,95,102,108,111,111,114,0,18,95,95,114,101,116,86,97,108,0,59,120,
-121,0,0,18,97,0,0,0,0,1,90,95,0,0,11,0,0,102,108,111,111,114,0,1,1,0,0,11,0,97,0,0,0,1,4,118,101,
-99,52,95,102,108,111,111,114,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,97,0,0,0,0,1,
-90,95,0,0,12,0,0,102,108,111,111,114,0,1,1,0,0,12,0,97,0,0,0,1,4,118,101,99,52,95,102,108,111,111,
-114,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,0,0,1,90,95,0,0,9,0,0,99,101,105,108,0,1,1,0,0,
-9,0,97,0,0,0,1,3,2,90,95,0,0,9,0,1,98,0,2,18,97,0,54,0,0,4,118,101,99,52,95,102,108,111,111,114,0,
-18,98,0,0,18,98,0,0,0,9,18,95,95,114,101,116,86,97,108,0,18,98,0,54,20,0,0,1,90,95,0,0,10,0,0,99,
-101,105,108,0,1,1,0,0,10,0,97,0,0,0,1,3,2,90,95,0,0,10,0,1,98,0,2,18,97,0,54,0,0,4,118,101,99,52,
-95,102,108,111,111,114,0,18,98,0,0,18,98,0,0,0,9,18,95,95,114,101,116,86,97,108,0,59,120,121,0,18,
-98,0,54,20,0,0,1,90,95,0,0,11,0,0,99,101,105,108,0,1,1,0,0,11,0,97,0,0,0,1,3,2,90,95,0,0,11,0,1,98,
-0,2,18,97,0,54,0,0,4,118,101,99,52,95,102,108,111,111,114,0,18,98,0,0,18,98,0,0,0,9,18,95,95,114,
-101,116,86,97,108,0,59,120,121,122,0,18,98,0,54,20,0,0,1,90,95,0,0,12,0,0,99,101,105,108,0,1,1,0,0,
-12,0,97,0,0,0,1,3,2,90,95,0,0,12,0,1,98,0,2,18,97,0,54,0,0,4,118,101,99,52,95,102,108,111,111,114,
-0,18,98,0,0,18,98,0,0,0,9,18,95,95,114,101,116,86,97,108,0,18,98,0,54,20,0,0,1,90,95,0,0,9,0,0,102,
-114,97,99,116,0,1,1,0,0,9,0,97,0,0,0,1,4,118,101,99,52,95,102,114,97,99,0,18,95,95,114,101,116,86,
-97,108,0,0,18,97,0,0,0,0,1,90,95,0,0,10,0,0,102,114,97,99,116,0,1,1,0,0,10,0,97,0,0,0,1,4,118,101,
-99,52,95,102,114,97,99,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,97,0,0,0,0,1,90,95,0,0,
-11,0,0,102,114,97,99,116,0,1,1,0,0,11,0,97,0,0,0,1,4,118,101,99,52,95,102,114,97,99,0,18,95,95,114,
-101,116,86,97,108,0,59,120,121,122,0,0,18,97,0,0,0,0,1,90,95,0,0,12,0,0,102,114,97,99,116,0,1,1,0,
-0,12,0,97,0,0,0,1,4,118,101,99,52,95,102,114,97,99,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,
-0,0,1,90,95,0,0,9,0,0,109,111,100,0,1,1,0,0,9,0,97,0,0,1,1,0,0,9,0,98,0,0,0,1,3,2,90,95,0,0,9,0,1,
-111,110,101,79,118,101,114,66,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,111,110,101,79,118,101,
-114,66,0,0,18,98,0,0,0,9,18,95,95,114,101,116,86,97,108,0,18,97,0,18,98,0,58,102,108,111,111,114,0,
-0,18,97,0,18,111,110,101,79,118,101,114,66,0,48,0,0,48,47,20,0,0,1,90,95,0,0,10,0,0,109,111,100,0,
-1,1,0,0,10,0,97,0,0,1,1,0,0,9,0,98,0,0,0,1,3,2,90,95,0,0,9,0,1,111,110,101,79,118,101,114,66,0,0,0,
-4,102,108,111,97,116,95,114,99,112,0,18,111,110,101,79,118,101,114,66,0,0,18,98,0,0,0,9,18,95,95,
-114,101,116,86,97,108,0,59,120,121,0,18,97,0,18,98,0,58,102,108,111,111,114,0,0,18,97,0,18,111,110,
-101,79,118,101,114,66,0,48,0,0,48,47,20,0,0,1,90,95,0,0,11,0,0,109,111,100,0,1,1,0,0,11,0,97,0,0,1,
-1,0,0,9,0,98,0,0,0,1,3,2,90,95,0,0,9,0,1,111,110,101,79,118,101,114,66,0,0,0,4,102,108,111,97,116,
-95,114,99,112,0,18,111,110,101,79,118,101,114,66,0,0,18,98,0,0,0,9,18,95,95,114,101,116,86,97,108,
-0,59,120,121,122,0,18,97,0,18,98,0,58,102,108,111,111,114,0,0,18,97,0,18,111,110,101,79,118,101,
-114,66,0,48,0,0,48,47,20,0,0,1,90,95,0,0,12,0,0,109,111,100,0,1,1,0,0,12,0,97,0,0,1,1,0,0,9,0,98,0,
-0,0,1,3,2,90,95,0,0,9,0,1,111,110,101,79,118,101,114,66,0,0,0,4,102,108,111,97,116,95,114,99,112,0,
-18,111,110,101,79,118,101,114,66,0,0,18,98,0,0,0,9,18,95,95,114,101,116,86,97,108,0,18,97,0,18,98,
-0,58,102,108,111,111,114,0,0,18,97,0,18,111,110,101,79,118,101,114,66,0,48,0,0,48,47,20,0,0,1,90,
-95,0,0,10,0,0,109,111,100,0,1,1,0,0,10,0,97,0,0,1,1,0,0,10,0,98,0,0,0,1,3,2,90,95,0,0,10,0,1,111,
-110,101,79,118,101,114,66,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,111,110,101,79,118,101,114,
-66,0,59,120,0,0,18,98,0,59,120,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,111,110,101,79,118,
-101,114,66,0,59,121,0,0,18,98,0,59,121,0,0,0,9,18,95,95,114,101,116,86,97,108,0,18,97,0,18,98,0,58,
-102,108,111,111,114,0,0,18,97,0,18,111,110,101,79,118,101,114,66,0,48,0,0,48,47,20,0,0,1,90,95,0,0,
-11,0,0,109,111,100,0,1,1,0,0,11,0,97,0,0,1,1,0,0,11,0,98,0,0,0,1,3,2,90,95,0,0,11,0,1,111,110,101,
-79,118,101,114,66,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,111,110,101,79,118,101,114,66,0,59,
-120,0,0,18,98,0,59,120,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,111,110,101,79,118,101,114,66,
-0,59,121,0,0,18,98,0,59,121,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,111,110,101,79,118,101,
-114,66,0,59,122,0,0,18,98,0,59,122,0,0,0,9,18,95,95,114,101,116,86,97,108,0,18,97,0,18,98,0,58,102,
-108,111,111,114,0,0,18,97,0,18,111,110,101,79,118,101,114,66,0,48,0,0,48,47,20,0,0,1,90,95,0,0,12,
-0,0,109,111,100,0,1,1,0,0,12,0,97,0,0,1,1,0,0,12,0,98,0,0,0,1,3,2,90,95,0,0,12,0,1,111,110,101,79,
-118,101,114,66,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,111,110,101,79,118,101,114,66,0,59,
-120,0,0,18,98,0,59,120,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,111,110,101,79,118,101,114,66,
-0,59,121,0,0,18,98,0,59,121,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,111,110,101,79,118,101,
-114,66,0,59,122,0,0,18,98,0,59,122,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,111,110,101,79,
-118,101,114,66,0,59,119,0,0,18,98,0,59,119,0,0,0,9,18,95,95,114,101,116,86,97,108,0,18,97,0,18,98,
-0,58,102,108,111,111,114,0,0,18,97,0,18,111,110,101,79,118,101,114,66,0,48,0,0,48,47,20,0,0,1,90,
-95,0,0,9,0,0,109,105,110,0,1,1,0,0,9,0,97,0,0,1,1,0,0,9,0,98,0,0,0,1,4,118,101,99,52,95,109,105,
-110,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,98,0,0,0,0,1,90,95,0,0,10,0,0,109,105,110,0,
-1,1,0,0,10,0,97,0,0,1,1,0,0,10,0,98,0,0,0,1,4,118,101,99,52,95,109,105,110,0,18,95,95,114,101,116,
-86,97,108,0,59,120,121,0,0,18,97,0,59,120,121,0,0,18,98,0,59,120,121,0,0,0,0,1,90,95,0,0,11,0,0,
-109,105,110,0,1,1,0,0,11,0,97,0,0,1,1,0,0,11,0,98,0,0,0,1,4,118,101,99,52,95,109,105,110,0,18,95,
-95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,97,0,59,120,121,122,0,0,18,98,0,59,120,121,122,0,
-0,0,0,1,90,95,0,0,12,0,0,109,105,110,0,1,1,0,0,12,0,97,0,0,1,1,0,0,12,0,98,0,0,0,1,4,118,101,99,52,
-95,109,105,110,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,98,0,0,0,0,1,90,95,0,0,10,0,0,109,
-105,110,0,1,1,0,0,10,0,97,0,0,1,1,0,0,9,0,98,0,0,0,1,4,118,101,99,52,95,109,105,110,0,18,95,95,114,
-101,116,86,97,108,0,0,18,97,0,59,120,121,0,0,18,98,0,0,0,0,1,90,95,0,0,11,0,0,109,105,110,0,1,1,0,
-0,11,0,97,0,0,1,1,0,0,9,0,98,0,0,0,1,4,118,101,99,52,95,109,105,110,0,18,95,95,114,101,116,86,97,
-108,0,0,18,97,0,59,120,121,122,0,0,18,98,0,0,0,0,1,90,95,0,0,12,0,0,109,105,110,0,1,1,0,0,12,0,97,
-0,0,1,1,0,0,9,0,98,0,0,0,1,4,118,101,99,52,95,109,105,110,0,18,95,95,114,101,116,86,97,108,0,0,18,
-97,0,0,18,98,0,0,0,0,1,90,95,0,0,9,0,0,109,97,120,0,1,1,0,0,9,0,97,0,0,1,1,0,0,9,0,98,0,0,0,1,4,
-118,101,99,52,95,109,97,120,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,98,0,0,0,0,1,90,95,0,
-0,10,0,0,109,97,120,0,1,1,0,0,10,0,97,0,0,1,1,0,0,10,0,98,0,0,0,1,4,118,101,99,52,95,109,97,120,0,
-18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,97,0,59,120,121,0,0,18,98,0,59,120,121,0,0,0,0,
-1,90,95,0,0,11,0,0,109,97,120,0,1,1,0,0,11,0,97,0,0,1,1,0,0,11,0,98,0,0,0,1,4,118,101,99,52,95,109,
-97,120,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,97,0,59,120,121,122,0,0,18,98,0,59,
-120,121,122,0,0,0,0,1,90,95,0,0,12,0,0,109,97,120,0,1,1,0,0,12,0,97,0,0,1,1,0,0,12,0,98,0,0,0,1,4,
-118,101,99,52,95,109,97,120,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,98,0,0,0,0,1,90,95,0,
-0,10,0,0,109,97,120,0,1,1,0,0,10,0,97,0,0,1,1,0,0,9,0,98,0,0,0,1,4,118,101,99,52,95,109,97,120,0,
-18,95,95,114,101,116,86,97,108,0,0,18,97,0,59,120,121,0,0,18,98,0,0,0,0,1,90,95,0,0,11,0,0,109,97,
-120,0,1,1,0,0,11,0,97,0,0,1,1,0,0,9,0,98,0,0,0,1,4,118,101,99,52,95,109,97,120,0,18,95,95,114,101,
-116,86,97,108,0,0,18,97,0,59,120,121,122,0,0,18,98,0,0,0,0,1,90,95,0,0,12,0,0,109,97,120,0,1,1,0,0,
-12,0,97,0,0,1,1,0,0,9,0,98,0,0,0,1,4,118,101,99,52,95,109,97,120,0,18,95,95,114,101,116,86,97,108,
-0,0,18,97,0,0,18,98,0,0,0,0,1,90,95,0,0,9,0,0,99,108,97,109,112,0,1,1,0,0,9,0,118,97,108,0,0,1,1,0,
-0,9,0,109,105,110,86,97,108,0,0,1,1,0,0,9,0,109,97,120,86,97,108,0,0,0,1,4,118,101,99,52,95,99,108,
-97,109,112,0,18,95,95,114,101,116,86,97,108,0,0,18,118,97,108,0,0,18,109,105,110,86,97,108,0,0,18,
-109,97,120,86,97,108,0,0,0,0,1,90,95,0,0,10,0,0,99,108,97,109,112,0,1,1,0,0,10,0,118,97,108,0,0,1,
-1,0,0,9,0,109,105,110,86,97,108,0,0,1,1,0,0,9,0,109,97,120,86,97,108,0,0,0,1,4,118,101,99,52,95,99,
-108,97,109,112,0,18,95,95,114,101,116,86,97,108,0,0,18,118,97,108,0,0,18,109,105,110,86,97,108,0,0,
-18,109,97,120,86,97,108,0,0,0,0,1,90,95,0,0,11,0,0,99,108,97,109,112,0,1,1,0,0,11,0,118,97,108,0,0,
-1,1,0,0,9,0,109,105,110,86,97,108,0,0,1,1,0,0,9,0,109,97,120,86,97,108,0,0,0,1,4,118,101,99,52,95,
-99,108,97,109,112,0,18,95,95,114,101,116,86,97,108,0,0,18,118,97,108,0,0,18,109,105,110,86,97,108,
-0,0,18,109,97,120,86,97,108,0,0,0,0,1,90,95,0,0,12,0,0,99,108,97,109,112,0,1,1,0,0,12,0,118,97,108,
-0,0,1,1,0,0,9,0,109,105,110,86,97,108,0,0,1,1,0,0,9,0,109,97,120,86,97,108,0,0,0,1,4,118,101,99,52,
-95,99,108,97,109,112,0,18,95,95,114,101,116,86,97,108,0,0,18,118,97,108,0,0,18,109,105,110,86,97,
-108,0,0,18,109,97,120,86,97,108,0,0,0,0,1,90,95,0,0,10,0,0,99,108,97,109,112,0,1,1,0,0,10,0,118,97,
-108,0,0,1,1,0,0,10,0,109,105,110,86,97,108,0,0,1,1,0,0,10,0,109,97,120,86,97,108,0,0,0,1,4,118,101,
-99,52,95,99,108,97,109,112,0,18,95,95,114,101,116,86,97,108,0,0,18,118,97,108,0,0,18,109,105,110,
-86,97,108,0,0,18,109,97,120,86,97,108,0,0,0,0,1,90,95,0,0,11,0,0,99,108,97,109,112,0,1,1,0,0,11,0,
-118,97,108,0,0,1,1,0,0,11,0,109,105,110,86,97,108,0,0,1,1,0,0,11,0,109,97,120,86,97,108,0,0,0,1,4,
-118,101,99,52,95,99,108,97,109,112,0,18,95,95,114,101,116,86,97,108,0,0,18,118,97,108,0,0,18,109,
-105,110,86,97,108,0,0,18,109,97,120,86,97,108,0,0,0,0,1,90,95,0,0,12,0,0,99,108,97,109,112,0,1,1,0,
-0,12,0,118,97,108,0,0,1,1,0,0,12,0,109,105,110,86,97,108,0,0,1,1,0,0,12,0,109,97,120,86,97,108,0,0,
-0,1,4,118,101,99,52,95,99,108,97,109,112,0,18,95,95,114,101,116,86,97,108,0,0,18,118,97,108,0,0,18,
-109,105,110,86,97,108,0,0,18,109,97,120,86,97,108,0,0,0,0,1,90,95,0,0,9,0,0,109,105,120,0,1,1,0,0,
-9,0,120,0,0,1,1,0,0,9,0,121,0,0,1,1,0,0,9,0,97,0,0,0,1,4,118,101,99,52,95,108,114,112,0,18,95,95,
-114,101,116,86,97,108,0,0,18,97,0,0,18,121,0,0,18,120,0,0,0,0,1,90,95,0,0,10,0,0,109,105,120,0,1,1,
-0,0,10,0,120,0,0,1,1,0,0,10,0,121,0,0,1,1,0,0,9,0,97,0,0,0,1,4,118,101,99,52,95,108,114,112,0,18,
-95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,121,0,0,18,120,0,0,0,0,1,90,95,0,0,11,0,0,109,105,120,
-0,1,1,0,0,11,0,120,0,0,1,1,0,0,11,0,121,0,0,1,1,0,0,9,0,97,0,0,0,1,4,118,101,99,52,95,108,114,112,
-0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,121,0,0,18,120,0,0,0,0,1,90,95,0,0,12,0,0,109,
-105,120,0,1,1,0,0,12,0,120,0,0,1,1,0,0,12,0,121,0,0,1,1,0,0,9,0,97,0,0,0,1,4,118,101,99,52,95,108,
-114,112,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,121,0,0,18,120,0,0,0,0,1,90,95,0,0,10,0,
-0,109,105,120,0,1,1,0,0,10,0,120,0,0,1,1,0,0,10,0,121,0,0,1,1,0,0,10,0,97,0,0,0,1,4,118,101,99,52,
-95,108,114,112,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,121,0,0,18,120,0,0,0,0,1,90,95,0,
-0,11,0,0,109,105,120,0,1,1,0,0,11,0,120,0,0,1,1,0,0,11,0,121,0,0,1,1,0,0,11,0,97,0,0,0,1,4,118,101,
-99,52,95,108,114,112,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,121,0,0,18,120,0,0,0,0,1,90,
-95,0,0,12,0,0,109,105,120,0,1,1,0,0,12,0,120,0,0,1,1,0,0,12,0,121,0,0,1,1,0,0,12,0,97,0,0,0,1,4,
-118,101,99,52,95,108,114,112,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,121,0,0,18,120,0,0,
-0,0,1,90,95,0,0,9,0,0,115,116,101,112,0,1,1,0,0,9,0,101,100,103,101,0,0,1,1,0,0,9,0,120,0,0,0,1,4,
-118,101,99,52,95,115,103,101,0,18,95,95,114,101,116,86,97,108,0,0,18,120,0,0,18,101,100,103,101,0,
-0,0,0,1,90,95,0,0,10,0,0,115,116,101,112,0,1,1,0,0,10,0,101,100,103,101,0,0,1,1,0,0,10,0,120,0,0,0,
-1,4,118,101,99,52,95,115,103,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,120,0,0,18,
-101,100,103,101,0,0,0,0,1,90,95,0,0,11,0,0,115,116,101,112,0,1,1,0,0,11,0,101,100,103,101,0,0,1,1,
-0,0,11,0,120,0,0,0,1,4,118,101,99,52,95,115,103,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,
-122,0,0,18,120,0,0,18,101,100,103,101,0,0,0,0,1,90,95,0,0,12,0,0,115,116,101,112,0,1,1,0,0,12,0,
-101,100,103,101,0,0,1,1,0,0,12,0,120,0,0,0,1,4,118,101,99,52,95,115,103,101,0,18,95,95,114,101,116,
-86,97,108,0,0,18,120,0,0,18,101,100,103,101,0,0,0,0,1,90,95,0,0,10,0,0,115,116,101,112,0,1,1,0,0,9,
-0,101,100,103,101,0,0,1,1,0,0,10,0,118,0,0,0,1,4,118,101,99,52,95,115,103,101,0,18,95,95,114,101,
-116,86,97,108,0,59,120,121,0,0,18,118,0,0,18,101,100,103,101,0,0,0,0,1,90,95,0,0,11,0,0,115,116,
-101,112,0,1,1,0,0,9,0,101,100,103,101,0,0,1,1,0,0,11,0,118,0,0,0,1,4,118,101,99,52,95,115,103,101,
-0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,118,0,0,18,101,100,103,101,0,0,0,0,1,90,
-95,0,0,12,0,0,115,116,101,112,0,1,1,0,0,9,0,101,100,103,101,0,0,1,1,0,0,12,0,118,0,0,0,1,4,118,101,
-99,52,95,115,103,101,0,18,95,95,114,101,116,86,97,108,0,0,18,118,0,0,18,101,100,103,101,0,0,0,0,1,
-90,95,0,0,9,0,0,115,109,111,111,116,104,115,116,101,112,0,1,1,0,0,9,0,101,100,103,101,48,0,0,1,1,0,
-0,9,0,101,100,103,101,49,0,0,1,1,0,0,9,0,120,0,0,0,1,3,2,90,95,0,0,9,0,1,116,0,2,58,99,108,97,109,
-112,0,0,18,120,0,18,101,100,103,101,48,0,47,18,101,100,103,101,49,0,18,101,100,103,101,48,0,47,49,
-0,17,48,0,48,0,0,0,17,49,0,48,0,0,0,0,0,0,8,18,116,0,18,116,0,48,17,51,0,48,0,0,17,50,0,48,0,0,18,
-116,0,48,47,48,0,0,1,90,95,0,0,10,0,0,115,109,111,111,116,104,115,116,101,112,0,1,1,0,0,10,0,101,
-100,103,101,48,0,0,1,1,0,0,10,0,101,100,103,101,49,0,0,1,1,0,0,10,0,118,0,0,0,1,3,2,90,95,0,0,10,0,
-1,116,0,2,58,99,108,97,109,112,0,0,18,118,0,18,101,100,103,101,48,0,47,18,101,100,103,101,49,0,18,
-101,100,103,101,48,0,47,49,0,17,48,0,48,0,0,0,17,49,0,48,0,0,0,0,0,0,8,18,116,0,18,116,0,48,17,51,
-0,48,0,0,17,50,0,48,0,0,18,116,0,48,47,48,0,0,1,90,95,0,0,11,0,0,115,109,111,111,116,104,115,116,
-101,112,0,1,1,0,0,11,0,101,100,103,101,48,0,0,1,1,0,0,11,0,101,100,103,101,49,0,0,1,1,0,0,11,0,118,
-0,0,0,1,3,2,90,95,0,0,11,0,1,116,0,2,58,99,108,97,109,112,0,0,18,118,0,18,101,100,103,101,48,0,47,
-18,101,100,103,101,49,0,18,101,100,103,101,48,0,47,49,0,17,48,0,48,0,0,0,17,49,0,48,0,0,0,0,0,0,8,
-18,116,0,18,116,0,48,17,51,0,48,0,0,17,50,0,48,0,0,18,116,0,48,47,48,0,0,1,90,95,0,0,12,0,0,115,
-109,111,111,116,104,115,116,101,112,0,1,1,0,0,12,0,101,100,103,101,48,0,0,1,1,0,0,12,0,101,100,103,
-101,49,0,0,1,1,0,0,12,0,118,0,0,0,1,3,2,90,95,0,0,12,0,1,116,0,2,58,99,108,97,109,112,0,0,18,118,0,
-18,101,100,103,101,48,0,47,18,101,100,103,101,49,0,18,101,100,103,101,48,0,47,49,0,17,48,0,48,0,0,
-0,17,49,0,48,0,0,0,0,0,0,8,18,116,0,18,116,0,48,17,51,0,48,0,0,17,50,0,48,0,0,18,116,0,48,47,48,0,
-0,1,90,95,0,0,10,0,0,115,109,111,111,116,104,115,116,101,112,0,1,1,0,0,9,0,101,100,103,101,48,0,0,
-1,1,0,0,9,0,101,100,103,101,49,0,0,1,1,0,0,10,0,118,0,0,0,1,3,2,90,95,0,0,10,0,1,116,0,2,58,99,108,
-97,109,112,0,0,18,118,0,18,101,100,103,101,48,0,47,18,101,100,103,101,49,0,18,101,100,103,101,48,0,
-47,49,0,17,48,0,48,0,0,0,17,49,0,48,0,0,0,0,0,0,8,18,116,0,18,116,0,48,17,51,0,48,0,0,17,50,0,48,0,
-0,18,116,0,48,47,48,0,0,1,90,95,0,0,11,0,0,115,109,111,111,116,104,115,116,101,112,0,1,1,0,0,9,0,
-101,100,103,101,48,0,0,1,1,0,0,9,0,101,100,103,101,49,0,0,1,1,0,0,11,0,118,0,0,0,1,3,2,90,95,0,0,
-11,0,1,116,0,2,58,99,108,97,109,112,0,0,18,118,0,18,101,100,103,101,48,0,47,18,101,100,103,101,49,
-0,18,101,100,103,101,48,0,47,49,0,17,48,0,48,0,0,0,17,49,0,48,0,0,0,0,0,0,8,18,116,0,18,116,0,48,
-17,51,0,48,0,0,17,50,0,48,0,0,18,116,0,48,47,48,0,0,1,90,95,0,0,12,0,0,115,109,111,111,116,104,115,
-116,101,112,0,1,1,0,0,9,0,101,100,103,101,48,0,0,1,1,0,0,9,0,101,100,103,101,49,0,0,1,1,0,0,12,0,
-118,0,0,0,1,3,2,90,95,0,0,12,0,1,116,0,2,58,99,108,97,109,112,0,0,18,118,0,18,101,100,103,101,48,0,
-47,18,101,100,103,101,49,0,18,101,100,103,101,48,0,47,49,0,17,48,0,48,0,0,0,17,49,0,48,0,0,0,0,0,0,
-8,18,116,0,18,116,0,48,17,51,0,48,0,0,17,50,0,48,0,0,18,116,0,48,47,48,0,0,1,90,95,0,0,9,0,0,108,
-101,110,103,116,104,0,1,1,0,0,9,0,120,0,0,0,1,8,58,97,98,115,0,0,18,120,0,0,0,0,0,1,90,95,0,0,9,0,
-0,108,101,110,103,116,104,0,1,1,0,0,10,0,118,0,0,0,1,3,2,90,95,0,0,9,0,1,114,0,0,0,3,2,90,95,1,0,9,
-0,1,112,0,2,58,100,111,116,0,0,18,118,0,0,18,118,0,0,0,0,0,4,102,108,111,97,116,95,114,115,113,0,
-18,114,0,0,18,112,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,95,95,114,101,116,86,97,108,0,59,
-120,0,0,18,114,0,0,0,0,1,90,95,0,0,9,0,0,108,101,110,103,116,104,0,1,1,0,0,11,0,118,0,0,0,1,3,2,90,
-95,0,0,9,0,1,114,0,0,0,3,2,90,95,1,0,9,0,1,112,0,2,58,100,111,116,0,0,18,118,0,0,18,118,0,0,0,0,0,
-4,102,108,111,97,116,95,114,115,113,0,18,114,0,0,18,112,0,0,0,4,102,108,111,97,116,95,114,99,112,0,
-18,95,95,114,101,116,86,97,108,0,0,18,114,0,0,0,0,1,90,95,0,0,9,0,0,108,101,110,103,116,104,0,1,1,
-0,0,12,0,118,0,0,0,1,3,2,90,95,0,0,9,0,1,114,0,0,0,3,2,90,95,1,0,9,0,1,112,0,2,58,100,111,116,0,0,
-18,118,0,0,18,118,0,0,0,0,0,4,102,108,111,97,116,95,114,115,113,0,18,114,0,0,18,112,0,0,0,4,102,
-108,111,97,116,95,114,99,112,0,18,95,95,114,101,116,86,97,108,0,0,18,114,0,0,0,0,1,90,95,0,0,9,0,0,
-100,105,115,116,97,110,99,101,0,1,1,0,0,9,0,120,0,0,1,1,0,0,9,0,121,0,0,0,1,3,2,90,95,1,0,9,0,1,
-100,0,2,18,120,0,18,121,0,47,0,0,9,18,95,95,114,101,116,86,97,108,0,58,108,101,110,103,116,104,0,0,
-18,100,0,0,0,20,0,0,1,90,95,0,0,9,0,0,100,105,115,116,97,110,99,101,0,1,1,0,0,10,0,118,0,0,1,1,0,0,
-10,0,117,0,0,0,1,3,2,90,95,1,0,10,0,1,100,50,0,2,18,118,0,18,117,0,47,0,0,9,18,95,95,114,101,116,
-86,97,108,0,58,108,101,110,103,116,104,0,0,18,100,50,0,0,0,20,0,0,1,90,95,0,0,9,0,0,100,105,115,
-116,97,110,99,101,0,1,1,0,0,11,0,118,0,0,1,1,0,0,11,0,117,0,0,0,1,3,2,90,95,1,0,11,0,1,100,51,0,2,
-18,118,0,18,117,0,47,0,0,9,18,95,95,114,101,116,86,97,108,0,58,108,101,110,103,116,104,0,0,18,100,
-51,0,0,0,20,0,0,1,90,95,0,0,9,0,0,100,105,115,116,97,110,99,101,0,1,1,0,0,12,0,118,0,0,1,1,0,0,12,
-0,117,0,0,0,1,3,2,90,95,1,0,12,0,1,100,52,0,2,18,118,0,18,117,0,47,0,0,9,18,95,95,114,101,116,86,
-97,108,0,58,108,101,110,103,116,104,0,0,18,100,52,0,0,0,20,0,0,1,90,95,0,0,11,0,0,99,114,111,115,
-115,0,1,1,0,0,11,0,118,0,0,1,1,0,0,11,0,117,0,0,0,1,4,118,101,99,51,95,99,114,111,115,115,0,18,95,
-95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,118,0,0,18,117,0,0,0,0,1,90,95,0,0,9,0,0,102,97,
-99,101,102,111,114,119,97,114,100,0,1,1,0,0,9,0,78,0,0,1,1,0,0,9,0,73,0,0,1,1,0,0,9,0,78,114,101,
-102,0,0,0,1,3,2,90,95,1,0,9,0,1,100,0,2,58,100,111,116,0,0,18,78,114,101,102,0,0,18,73,0,0,0,0,0,3,
-2,90,95,0,0,9,0,1,115,0,0,0,4,118,101,99,52,95,115,103,116,0,18,115,0,0,17,48,0,48,0,0,0,18,100,0,
-0,0,8,58,109,105,120,0,0,18,78,0,54,0,18,78,0,0,18,115,0,0,0,0,0,1,90,95,0,0,10,0,0,102,97,99,101,
-102,111,114,119,97,114,100,0,1,1,0,0,10,0,78,0,0,1,1,0,0,10,0,73,0,0,1,1,0,0,10,0,78,114,101,102,0,
-0,0,1,3,2,90,95,1,0,9,0,1,100,0,2,58,100,111,116,0,0,18,78,114,101,102,0,0,18,73,0,0,0,0,0,3,2,90,
-95,0,0,9,0,1,115,0,0,0,4,118,101,99,52,95,115,103,116,0,18,115,0,0,17,48,0,48,0,0,0,18,100,0,0,0,8,
-58,109,105,120,0,0,18,78,0,54,0,18,78,0,0,18,115,0,0,0,0,0,1,90,95,0,0,11,0,0,102,97,99,101,102,
-111,114,119,97,114,100,0,1,1,0,0,11,0,78,0,0,1,1,0,0,11,0,73,0,0,1,1,0,0,11,0,78,114,101,102,0,0,0,
-1,3,2,90,95,1,0,9,0,1,100,0,2,58,100,111,116,0,0,18,78,114,101,102,0,0,18,73,0,0,0,0,0,3,2,90,95,0,
-0,9,0,1,115,0,0,0,4,118,101,99,52,95,115,103,116,0,18,115,0,0,17,48,0,48,0,0,0,18,100,0,0,0,8,58,
-109,105,120,0,0,18,78,0,54,0,18,78,0,0,18,115,0,0,0,0,0,1,90,95,0,0,12,0,0,102,97,99,101,102,111,
-114,119,97,114,100,0,1,1,0,0,12,0,78,0,0,1,1,0,0,12,0,73,0,0,1,1,0,0,12,0,78,114,101,102,0,0,0,1,3,
-2,90,95,1,0,9,0,1,100,0,2,58,100,111,116,0,0,18,78,114,101,102,0,0,18,73,0,0,0,0,0,3,2,90,95,0,0,9,
-0,1,115,0,0,0,4,118,101,99,52,95,115,103,116,0,18,115,0,0,17,48,0,48,0,0,0,18,100,0,0,0,8,58,109,
-105,120,0,0,18,78,0,54,0,18,78,0,0,18,115,0,0,0,0,0,1,90,95,0,0,9,0,0,114,101,102,108,101,99,116,0,
-1,1,0,0,9,0,73,0,0,1,1,0,0,9,0,78,0,0,0,1,8,18,73,0,17,50,0,48,0,0,58,100,111,116,0,0,18,78,0,0,18,
-73,0,0,0,48,18,78,0,48,47,0,0,1,90,95,0,0,10,0,0,114,101,102,108,101,99,116,0,1,1,0,0,10,0,73,0,0,
-1,1,0,0,10,0,78,0,0,0,1,8,18,73,0,17,50,0,48,0,0,58,100,111,116,0,0,18,78,0,0,18,73,0,0,0,48,18,78,
-0,48,47,0,0,1,90,95,0,0,11,0,0,114,101,102,108,101,99,116,0,1,1,0,0,11,0,73,0,0,1,1,0,0,11,0,78,0,
-0,0,1,8,18,73,0,17,50,0,48,0,0,58,100,111,116,0,0,18,78,0,0,18,73,0,0,0,48,18,78,0,48,47,0,0,1,90,
-95,0,0,12,0,0,114,101,102,108,101,99,116,0,1,1,0,0,12,0,73,0,0,1,1,0,0,12,0,78,0,0,0,1,8,18,73,0,
-17,50,0,48,0,0,58,100,111,116,0,0,18,78,0,0,18,73,0,0,0,48,18,78,0,48,47,0,0,1,90,95,0,0,9,0,0,114,
-101,102,114,97,99,116,0,1,1,0,0,9,0,73,0,0,1,1,0,0,9,0,78,0,0,1,1,0,0,9,0,101,116,97,0,0,0,1,3,2,
-90,95,0,0,9,0,1,110,95,100,111,116,95,105,0,2,58,100,111,116,0,0,18,78,0,0,18,73,0,0,0,0,0,3,2,90,
-95,0,0,9,0,1,107,0,2,17,49,0,48,0,0,18,101,116,97,0,18,101,116,97,0,48,17,49,0,48,0,0,18,110,95,
-100,111,116,95,105,0,18,110,95,100,111,116,95,105,0,48,47,48,47,0,0,3,2,90,95,0,0,9,0,1,114,101,
-116,118,97,108,0,0,0,10,18,107,0,17,48,0,48,0,0,40,0,9,18,114,101,116,118,97,108,0,17,48,0,48,0,0,
-20,0,9,18,114,101,116,118,97,108,0,18,101,116,97,0,18,73,0,48,18,101,116,97,0,18,110,95,100,111,
-116,95,105,0,48,58,115,113,114,116,0,0,18,107,0,0,0,46,18,78,0,48,47,20,0,8,18,114,101,116,118,97,
-108,0,0,0,1,90,95,0,0,10,0,0,114,101,102,114,97,99,116,0,1,1,0,0,10,0,73,0,0,1,1,0,0,10,0,78,0,0,1,
-1,0,0,9,0,101,116,97,0,0,0,1,3,2,90,95,0,0,9,0,1,110,95,100,111,116,95,105,0,2,58,100,111,116,0,0,
-18,78,0,0,18,73,0,0,0,0,0,3,2,90,95,0,0,9,0,1,107,0,2,17,49,0,48,0,0,18,101,116,97,0,18,101,116,97,
-0,48,17,49,0,48,0,0,18,110,95,100,111,116,95,105,0,18,110,95,100,111,116,95,105,0,48,47,48,47,0,0,
-3,2,90,95,0,0,10,0,1,114,101,116,118,97,108,0,0,0,10,18,107,0,17,48,0,48,0,0,40,0,9,18,114,101,116,
-118,97,108,0,58,118,101,99,50,0,0,17,48,0,48,0,0,0,0,20,0,9,18,114,101,116,118,97,108,0,18,101,116,
-97,0,18,73,0,48,18,101,116,97,0,18,110,95,100,111,116,95,105,0,48,58,115,113,114,116,0,0,18,107,0,
-0,0,46,18,78,0,48,47,20,0,8,18,114,101,116,118,97,108,0,0,0,1,90,95,0,0,11,0,0,114,101,102,114,97,
-99,116,0,1,1,0,0,11,0,73,0,0,1,1,0,0,11,0,78,0,0,1,1,0,0,9,0,101,116,97,0,0,0,1,3,2,90,95,0,0,9,0,
-1,110,95,100,111,116,95,105,0,2,58,100,111,116,0,0,18,78,0,0,18,73,0,0,0,0,0,3,2,90,95,0,0,9,0,1,
-107,0,2,17,49,0,48,0,0,18,101,116,97,0,18,101,116,97,0,48,17,49,0,48,0,0,18,110,95,100,111,116,95,
-105,0,18,110,95,100,111,116,95,105,0,48,47,48,47,0,0,3,2,90,95,0,0,11,0,1,114,101,116,118,97,108,0,
-0,0,10,18,107,0,17,48,0,48,0,0,40,0,9,18,114,101,116,118,97,108,0,58,118,101,99,51,0,0,17,48,0,48,
-0,0,0,0,20,0,9,18,114,101,116,118,97,108,0,18,101,116,97,0,18,73,0,48,18,101,116,97,0,18,110,95,
-100,111,116,95,105,0,48,58,115,113,114,116,0,0,18,107,0,0,0,46,18,78,0,48,47,20,0,8,18,114,101,116,
-118,97,108,0,0,0,1,90,95,0,0,12,0,0,114,101,102,114,97,99,116,0,1,1,0,0,12,0,73,0,0,1,1,0,0,12,0,
-78,0,0,1,1,0,0,9,0,101,116,97,0,0,0,1,3,2,90,95,0,0,9,0,1,110,95,100,111,116,95,105,0,2,58,100,111,
-116,0,0,18,78,0,0,18,73,0,0,0,0,0,3,2,90,95,0,0,9,0,1,107,0,2,17,49,0,48,0,0,18,101,116,97,0,18,
-101,116,97,0,48,17,49,0,48,0,0,18,110,95,100,111,116,95,105,0,18,110,95,100,111,116,95,105,0,48,47,
-48,47,0,0,3,2,90,95,0,0,12,0,1,114,101,116,118,97,108,0,0,0,10,18,107,0,17,48,0,48,0,0,40,0,9,18,
-114,101,116,118,97,108,0,58,118,101,99,52,0,0,17,48,0,48,0,0,0,0,20,0,9,18,114,101,116,118,97,108,
-0,18,101,116,97,0,18,73,0,48,18,101,116,97,0,18,110,95,100,111,116,95,105,0,48,58,115,113,114,116,
-0,0,18,107,0,0,0,46,18,78,0,48,47,20,0,8,18,114,101,116,118,97,108,0,0,0,1,90,95,0,0,13,0,0,109,97,
-116,114,105,120,67,111,109,112,77,117,108,116,0,1,0,0,0,13,0,109,0,0,1,0,0,0,13,0,110,0,0,0,1,8,58,
-109,97,116,50,0,0,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,48,0,18,109,0,16,10,49,0,57,18,110,0,
-16,10,49,0,57,48,0,0,0,0,1,90,95,0,0,14,0,0,109,97,116,114,105,120,67,111,109,112,77,117,108,116,0,
-1,0,0,0,14,0,109,0,0,1,0,0,0,14,0,110,0,0,0,1,8,58,109,97,116,51,0,0,18,109,0,16,8,48,0,57,18,110,
-0,16,8,48,0,57,48,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,48,0,18,109,0,16,10,50,0,57,18,
-110,0,16,10,50,0,57,48,0,0,0,0,1,90,95,0,0,15,0,0,109,97,116,114,105,120,67,111,109,112,77,117,108,
-116,0,1,0,0,0,15,0,109,0,0,1,0,0,0,15,0,110,0,0,0,1,8,58,109,97,116,52,0,0,18,109,0,16,8,48,0,57,
-18,110,0,16,8,48,0,57,48,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,48,0,18,109,0,16,10,50,0,
-57,18,110,0,16,10,50,0,57,48,0,18,109,0,16,10,51,0,57,18,110,0,16,10,51,0,57,48,0,0,0,0,1,90,95,0,
-0,2,0,0,108,101,115,115,84,104,97,110,0,1,1,0,0,10,0,117,0,0,1,1,0,0,10,0,118,0,0,0,1,4,118,101,99,
-52,95,115,108,116,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,117,0,0,18,118,0,0,0,0,1,90,
-95,0,0,3,0,0,108,101,115,115,84,104,97,110,0,1,1,0,0,11,0,117,0,0,1,1,0,0,11,0,118,0,0,0,1,4,118,
-101,99,52,95,115,108,116,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,117,0,0,18,118,0,
-0,0,0,1,90,95,0,0,4,0,0,108,101,115,115,84,104,97,110,0,1,1,0,0,12,0,117,0,0,1,1,0,0,12,0,118,0,0,
-0,1,4,118,101,99,52,95,115,108,116,0,18,95,95,114,101,116,86,97,108,0,0,18,117,0,0,18,118,0,0,0,0,
-1,90,95,0,0,2,0,0,108,101,115,115,84,104,97,110,0,1,1,0,0,6,0,117,0,0,1,1,0,0,6,0,118,0,0,0,1,4,
-118,101,99,52,95,115,108,116,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,117,0,0,18,118,0,
-0,0,0,1,90,95,0,0,3,0,0,108,101,115,115,84,104,97,110,0,1,1,0,0,7,0,117,0,0,1,1,0,0,7,0,118,0,0,0,
-1,4,118,101,99,52,95,115,108,116,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,117,0,0,
-18,118,0,0,0,0,1,90,95,0,0,4,0,0,108,101,115,115,84,104,97,110,0,1,1,0,0,8,0,117,0,0,1,1,0,0,8,0,
-118,0,0,0,1,4,118,101,99,52,95,115,108,116,0,18,95,95,114,101,116,86,97,108,0,0,18,117,0,0,18,118,
-0,0,0,0,1,90,95,0,0,2,0,0,108,101,115,115,84,104,97,110,69,113,117,97,108,0,1,1,0,0,10,0,117,0,0,1,
-1,0,0,10,0,118,0,0,0,1,4,118,101,99,52,95,115,108,101,0,18,95,95,114,101,116,86,97,108,0,59,120,
-121,0,0,18,117,0,0,18,118,0,0,0,0,1,90,95,0,0,3,0,0,108,101,115,115,84,104,97,110,69,113,117,97,
-108,0,1,1,0,0,11,0,117,0,0,1,1,0,0,11,0,118,0,0,0,1,4,118,101,99,52,95,115,108,101,0,18,95,95,114,
-101,116,86,97,108,0,59,120,121,122,0,0,18,117,0,0,18,118,0,0,0,0,1,90,95,0,0,4,0,0,108,101,115,115,
-84,104,97,110,69,113,117,97,108,0,1,1,0,0,12,0,117,0,0,1,1,0,0,12,0,118,0,0,0,1,4,118,101,99,52,95,
-115,108,101,0,18,95,95,114,101,116,86,97,108,0,0,18,117,0,0,18,118,0,0,0,0,1,90,95,0,0,2,0,0,108,
-101,115,115,84,104,97,110,69,113,117,97,108,0,1,1,0,0,6,0,117,0,0,1,1,0,0,6,0,118,0,0,0,1,4,118,
-101,99,52,95,115,108,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,117,0,0,18,118,0,0,0,
-0,1,90,95,0,0,3,0,0,108,101,115,115,84,104,97,110,69,113,117,97,108,0,1,1,0,0,7,0,117,0,0,1,1,0,0,
-7,0,118,0,0,0,1,4,118,101,99,52,95,115,108,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,
-0,18,117,0,0,18,118,0,0,0,0,1,90,95,0,0,4,0,0,108,101,115,115,84,104,97,110,69,113,117,97,108,0,1,
-1,0,0,8,0,117,0,0,1,1,0,0,8,0,118,0,0,0,1,4,118,101,99,52,95,115,108,101,0,18,95,95,114,101,116,86,
-97,108,0,0,18,117,0,0,18,118,0,0,0,0,1,90,95,0,0,2,0,0,103,114,101,97,116,101,114,84,104,97,110,0,
-1,1,0,0,10,0,117,0,0,1,1,0,0,10,0,118,0,0,0,1,4,118,101,99,52,95,115,103,116,0,18,95,95,114,101,
-116,86,97,108,0,59,120,121,0,0,18,117,0,0,18,118,0,0,0,0,1,90,95,0,0,3,0,0,103,114,101,97,116,101,
-114,84,104,97,110,0,1,1,0,0,11,0,117,0,0,1,1,0,0,11,0,118,0,0,0,1,4,118,101,99,52,95,115,103,116,0,
-18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,117,0,0,18,118,0,0,0,0,1,90,95,0,0,4,0,0,
-103,114,101,97,116,101,114,84,104,97,110,0,1,1,0,0,12,0,117,0,0,1,1,0,0,12,0,118,0,0,0,1,4,118,101,
-99,52,95,115,103,116,0,18,95,95,114,101,116,86,97,108,0,0,18,117,0,0,18,118,0,0,0,0,1,90,95,0,0,2,
-0,0,103,114,101,97,116,101,114,84,104,97,110,0,1,1,0,0,6,0,117,0,0,1,1,0,0,6,0,118,0,0,0,1,4,118,
-101,99,52,95,115,103,116,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,117,0,59,120,121,0,0,
-18,118,0,59,120,121,0,0,0,0,1,90,95,0,0,3,0,0,103,114,101,97,116,101,114,84,104,97,110,0,1,1,0,0,7,
-0,117,0,0,1,1,0,0,7,0,118,0,0,0,1,4,118,101,99,52,95,115,103,116,0,18,95,95,114,101,116,86,97,108,
-0,59,120,121,122,0,0,18,117,0,0,18,118,0,0,0,0,1,90,95,0,0,4,0,0,103,114,101,97,116,101,114,84,104,
-97,110,0,1,1,0,0,8,0,117,0,0,1,1,0,0,8,0,118,0,0,0,1,4,118,101,99,52,95,115,103,116,0,18,95,95,114,
-101,116,86,97,108,0,0,18,117,0,0,18,118,0,0,0,0,1,90,95,0,0,2,0,0,103,114,101,97,116,101,114,84,
-104,97,110,69,113,117,97,108,0,1,1,0,0,10,0,117,0,0,1,1,0,0,10,0,118,0,0,0,1,4,118,101,99,52,95,
-115,103,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,117,0,0,18,118,0,0,0,0,1,90,95,0,
-0,3,0,0,103,114,101,97,116,101,114,84,104,97,110,69,113,117,97,108,0,1,1,0,0,11,0,117,0,0,1,1,0,0,
-11,0,118,0,0,0,1,4,118,101,99,52,95,115,103,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,
-0,0,18,117,0,0,18,118,0,0,0,0,1,90,95,0,0,4,0,0,103,114,101,97,116,101,114,84,104,97,110,69,113,
-117,97,108,0,1,1,0,0,12,0,117,0,0,1,1,0,0,12,0,118,0,0,0,1,4,118,101,99,52,95,115,103,101,0,18,95,
-95,114,101,116,86,97,108,0,0,18,117,0,0,18,118,0,0,0,0,1,90,95,0,0,2,0,0,103,114,101,97,116,101,
-114,84,104,97,110,69,113,117,97,108,0,1,1,0,0,6,0,117,0,0,1,1,0,0,6,0,118,0,0,0,1,4,118,101,99,52,
-95,115,103,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,117,0,0,18,118,0,0,0,0,1,90,95,
-0,0,3,0,0,103,114,101,97,116,101,114,84,104,97,110,69,113,117,97,108,0,1,1,0,0,7,0,117,0,0,1,1,0,0,
-7,0,118,0,0,0,1,4,118,101,99,52,95,115,103,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,
-0,18,117,0,0,18,118,0,0,0,0,1,90,95,0,0,4,0,0,103,114,101,97,116,101,114,84,104,97,110,69,113,117,
-97,108,0,1,1,0,0,8,0,117,0,0,1,1,0,0,8,0,118,0,0,0,1,4,118,101,99,52,95,115,103,101,0,18,95,95,114,
-101,116,86,97,108,0,0,18,117,0,0,18,118,0,0,0,0,1,90,95,0,0,2,0,0,101,113,117,97,108,0,1,1,0,0,10,
-0,117,0,0,1,1,0,0,10,0,118,0,0,0,1,4,118,101,99,52,95,115,101,113,0,18,95,95,114,101,116,86,97,108,
-0,59,120,121,0,0,18,117,0,0,18,118,0,0,0,0,1,90,95,0,0,3,0,0,101,113,117,97,108,0,1,1,0,0,11,0,117,
-0,0,1,1,0,0,11,0,118,0,0,0,1,4,118,101,99,52,95,115,101,113,0,18,95,95,114,101,116,86,97,108,0,59,
-120,121,122,0,0,18,117,0,0,18,118,0,0,0,0,1,90,95,0,0,4,0,0,101,113,117,97,108,0,1,1,0,0,12,0,117,
-0,0,1,1,0,0,12,0,118,0,0,0,1,4,118,101,99,52,95,115,101,113,0,18,95,95,114,101,116,86,97,108,0,0,
-18,117,0,0,18,118,0,0,0,0,1,90,95,0,0,2,0,0,101,113,117,97,108,0,1,1,0,0,6,0,117,0,0,1,1,0,0,6,0,
-118,0,0,0,1,4,118,101,99,52,95,115,101,113,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,
-117,0,0,18,118,0,0,0,0,1,90,95,0,0,3,0,0,101,113,117,97,108,0,1,1,0,0,7,0,117,0,0,1,1,0,0,7,0,118,
-0,0,0,1,4,118,101,99,52,95,115,101,113,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,
-117,0,0,18,118,0,0,0,0,1,90,95,0,0,4,0,0,101,113,117,97,108,0,1,1,0,0,8,0,117,0,0,1,1,0,0,8,0,118,
-0,0,0,1,4,118,101,99,52,95,115,101,113,0,18,95,95,114,101,116,86,97,108,0,0,18,117,0,0,18,118,0,0,
-0,0,1,90,95,0,0,2,0,0,101,113,117,97,108,0,1,1,0,0,2,0,117,0,0,1,1,0,0,2,0,118,0,0,0,1,4,118,101,
-99,52,95,115,101,113,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,117,0,0,18,118,0,0,0,0,1,
-90,95,0,0,3,0,0,101,113,117,97,108,0,1,1,0,0,3,0,117,0,0,1,1,0,0,3,0,118,0,0,0,1,4,118,101,99,52,
-95,115,101,113,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,117,0,0,18,118,0,0,0,0,1,
-90,95,0,0,4,0,0,101,113,117,97,108,0,1,1,0,0,4,0,117,0,0,1,1,0,0,4,0,118,0,0,0,1,4,118,101,99,52,
-95,115,101,113,0,18,95,95,114,101,116,86,97,108,0,0,18,117,0,0,18,118,0,0,0,0,1,90,95,0,0,2,0,0,
-110,111,116,69,113,117,97,108,0,1,1,0,0,10,0,117,0,0,1,1,0,0,10,0,118,0,0,0,1,4,118,101,99,52,95,
-115,110,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,117,0,0,18,118,0,0,0,0,1,90,95,0,
-0,3,0,0,110,111,116,69,113,117,97,108,0,1,1,0,0,11,0,117,0,0,1,1,0,0,11,0,118,0,0,0,1,4,118,101,99,
-52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,117,0,0,18,118,0,0,0,0,
-1,90,95,0,0,4,0,0,110,111,116,69,113,117,97,108,0,1,1,0,0,12,0,117,0,0,1,1,0,0,12,0,118,0,0,0,1,4,
-118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,0,18,117,0,0,18,118,0,0,0,0,1,90,
-95,0,0,2,0,0,110,111,116,69,113,117,97,108,0,1,1,0,0,6,0,117,0,0,1,1,0,0,6,0,118,0,0,0,1,4,118,101,
-99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,117,0,0,18,118,0,0,0,0,1,
-90,95,0,0,3,0,0,110,111,116,69,113,117,97,108,0,1,1,0,0,7,0,117,0,0,1,1,0,0,7,0,118,0,0,0,1,4,118,
-101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,117,0,0,18,118,0,
-0,0,0,1,90,95,0,0,4,0,0,110,111,116,69,113,117,97,108,0,1,1,0,0,8,0,117,0,0,1,1,0,0,8,0,118,0,0,0,
-1,4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,0,18,117,0,0,18,118,0,0,0,0,1,
-90,95,0,0,2,0,0,110,111,116,69,113,117,97,108,0,1,1,0,0,2,0,117,0,0,1,1,0,0,2,0,118,0,0,0,1,4,118,
-101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,117,0,0,18,118,0,0,0,
-0,1,90,95,0,0,3,0,0,110,111,116,69,113,117,97,108,0,1,1,0,0,3,0,117,0,0,1,1,0,0,3,0,118,0,0,0,1,4,
-118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,117,0,0,18,
-118,0,0,0,0,1,90,95,0,0,4,0,0,110,111,116,69,113,117,97,108,0,1,1,0,0,4,0,117,0,0,1,1,0,0,4,0,118,
-0,0,0,1,4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,0,18,117,0,0,18,118,0,0,
-0,0,1,90,95,0,0,1,0,0,97,110,121,0,1,1,0,0,2,0,118,0,0,0,1,3,2,90,95,0,0,9,0,1,115,117,109,0,0,0,4,
-118,101,99,52,95,97,100,100,0,18,115,117,109,0,59,120,0,0,18,118,0,59,120,0,0,18,118,0,59,121,0,0,
-0,4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,115,117,109,0,59,
-120,0,0,17,48,0,48,0,0,0,0,0,1,90,95,0,0,1,0,0,97,110,121,0,1,1,0,0,3,0,118,0,0,0,1,3,2,90,95,0,0,
-9,0,1,115,117,109,0,0,0,4,118,101,99,52,95,97,100,100,0,18,115,117,109,0,59,120,0,0,18,118,0,59,
-120,0,0,18,118,0,59,121,0,0,0,4,118,101,99,52,95,97,100,100,0,18,115,117,109,0,59,120,0,0,18,115,
-117,109,0,59,120,0,0,18,118,0,59,122,0,0,0,4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,
-86,97,108,0,59,120,0,0,18,115,117,109,0,59,120,0,0,17,48,0,48,0,0,0,0,0,1,90,95,0,0,1,0,0,97,110,
-121,0,1,1,0,0,4,0,118,0,0,0,1,3,2,90,95,0,0,9,0,1,115,117,109,0,0,0,4,118,101,99,52,95,97,100,100,
-0,18,115,117,109,0,59,120,0,0,18,118,0,59,120,0,0,18,118,0,59,121,0,0,0,4,118,101,99,52,95,97,100,
-100,0,18,115,117,109,0,59,120,0,0,18,115,117,109,0,59,120,0,0,18,118,0,59,122,0,0,0,4,118,101,99,
-52,95,97,100,100,0,18,115,117,109,0,59,120,0,0,18,115,117,109,0,59,120,0,0,18,118,0,59,119,0,0,0,4,
-118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,115,117,109,0,59,120,
-0,0,17,48,0,48,0,0,0,0,0,1,90,95,0,0,1,0,0,97,108,108,0,1,1,0,0,2,0,118,0,0,0,1,3,2,90,95,0,0,9,0,
-1,112,114,111,100,0,0,0,4,118,101,99,52,95,109,117,108,116,105,112,108,121,0,18,112,114,111,100,0,
-0,18,118,0,59,120,0,0,18,118,0,59,121,0,0,0,4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,
-86,97,108,0,0,18,112,114,111,100,0,0,17,48,0,48,0,0,0,0,0,1,90,95,0,0,1,0,0,97,108,108,0,1,1,0,0,3,
-0,118,0,0,0,1,3,2,90,95,0,0,9,0,1,112,114,111,100,0,0,0,4,118,101,99,52,95,109,117,108,116,105,112,
-108,121,0,18,112,114,111,100,0,0,18,118,0,59,120,0,0,18,118,0,59,121,0,0,0,4,118,101,99,52,95,109,
-117,108,116,105,112,108,121,0,18,112,114,111,100,0,0,18,112,114,111,100,0,0,18,118,0,59,122,0,0,0,
-4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,0,18,112,114,111,100,0,0,17,48,0,
-48,0,0,0,0,0,1,90,95,0,0,1,0,0,97,108,108,0,1,1,0,0,4,0,118,0,0,0,1,3,2,90,95,0,0,9,0,1,112,114,
-111,100,0,0,0,4,118,101,99,52,95,109,117,108,116,105,112,108,121,0,18,112,114,111,100,0,0,18,118,0,
-59,120,0,0,18,118,0,59,121,0,0,0,4,118,101,99,52,95,109,117,108,116,105,112,108,121,0,18,112,114,
-111,100,0,0,18,112,114,111,100,0,0,18,118,0,59,122,0,0,0,4,118,101,99,52,95,109,117,108,116,105,
-112,108,121,0,18,112,114,111,100,0,0,18,112,114,111,100,0,0,18,118,0,59,119,0,0,0,4,118,101,99,52,
-95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,0,18,112,114,111,100,0,0,17,48,0,48,0,0,0,0,0,1,
-90,95,0,0,2,0,0,110,111,116,0,1,1,0,0,2,0,118,0,0,0,1,4,118,101,99,52,95,115,101,113,0,18,95,95,
-114,101,116,86,97,108,0,59,120,121,0,0,18,118,0,0,17,48,0,48,0,0,0,0,0,1,90,95,0,0,3,0,0,110,111,
-116,0,1,1,0,0,3,0,118,0,0,0,1,4,118,101,99,52,95,115,101,113,0,18,95,95,114,101,116,86,97,108,0,59,
-120,121,122,0,0,18,118,0,0,17,48,0,48,0,0,0,0,0,1,90,95,0,0,4,0,0,110,111,116,0,1,1,0,0,4,0,118,0,
-0,0,1,4,118,101,99,52,95,115,101,113,0,18,95,95,114,101,116,86,97,108,0,0,18,118,0,0,17,48,0,48,0,
-0,0,0,0,1,90,95,0,0,12,0,0,116,101,120,116,117,114,101,49,68,0,1,1,0,0,16,0,115,97,109,112,108,101,
-114,0,0,1,1,0,0,9,0,99,111,111,114,100,0,0,0,1,4,118,101,99,52,95,116,101,120,95,49,100,0,18,95,95,
-114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,0,0,0,1,90,95,
-0,0,12,0,0,116,101,120,116,117,114,101,49,68,80,114,111,106,0,1,1,0,0,16,0,115,97,109,112,108,101,
-114,0,0,1,1,0,0,10,0,99,111,111,114,100,0,0,0,1,4,118,101,99,52,95,116,101,120,95,49,100,95,112,
-114,111,106,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,
-114,100,0,59,120,121,121,121,0,0,0,0,1,90,95,0,0,12,0,0,116,101,120,116,117,114,101,49,68,80,114,
-111,106,0,1,1,0,0,16,0,115,97,109,112,108,101,114,0,0,1,1,0,0,12,0,99,111,111,114,100,0,0,0,1,4,
-118,101,99,52,95,116,101,120,95,49,100,95,112,114,111,106,0,18,95,95,114,101,116,86,97,108,0,0,18,
-115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,0,0,0,1,90,95,0,0,12,0,0,116,101,120,116,
-117,114,101,50,68,0,1,1,0,0,17,0,115,97,109,112,108,101,114,0,0,1,1,0,0,10,0,99,111,111,114,100,0,
-0,0,1,4,118,101,99,52,95,116,101,120,95,50,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,
-112,108,101,114,0,0,18,99,111,111,114,100,0,0,0,0,1,90,95,0,0,12,0,0,116,101,120,116,117,114,101,
-50,68,80,114,111,106,0,1,1,0,0,17,0,115,97,109,112,108,101,114,0,0,1,1,0,0,11,0,99,111,111,114,100,
-0,0,0,1,4,118,101,99,52,95,116,101,120,95,50,100,95,112,114,111,106,0,18,95,95,114,101,116,86,97,
-108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,59,120,121,122,122,0,0,0,0,1,90,
-95,0,0,12,0,0,116,101,120,116,117,114,101,50,68,80,114,111,106,0,1,1,0,0,17,0,115,97,109,112,108,
-101,114,0,0,1,1,0,0,12,0,99,111,111,114,100,0,0,0,1,4,118,101,99,52,95,116,101,120,95,50,100,95,
-112,114,111,106,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,
-111,114,100,0,0,0,0,1,90,95,0,0,12,0,0,116,101,120,116,117,114,101,51,68,0,1,1,0,0,18,0,115,97,109,
-112,108,101,114,0,0,1,1,0,0,11,0,99,111,111,114,100,0,0,0,1,4,118,101,99,52,95,116,101,120,95,51,
-100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,
-0,0,0,1,90,95,0,0,12,0,0,116,101,120,116,117,114,101,51,68,80,114,111,106,0,1,1,0,0,18,0,115,97,
-109,112,108,101,114,0,0,1,1,0,0,12,0,99,111,111,114,100,0,0,0,1,4,118,101,99,52,95,116,101,120,95,
-51,100,95,112,114,111,106,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,
-18,99,111,111,114,100,0,0,0,0,1,90,95,0,0,12,0,0,116,101,120,116,117,114,101,67,117,98,101,0,1,1,0,
-0,19,0,115,97,109,112,108,101,114,0,0,1,1,0,0,11,0,99,111,111,114,100,0,0,0,1,4,118,101,99,52,95,
-116,101,120,95,99,117,98,101,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,
-0,18,99,111,111,114,100,0,0,0,0,1,90,95,0,0,12,0,0,115,104,97,100,111,119,49,68,0,1,1,0,0,20,0,115,
-97,109,112,108,101,114,0,0,1,1,0,0,11,0,99,111,111,114,100,0,0,0,1,4,118,101,99,52,95,116,101,120,
-95,49,100,95,115,104,97,100,111,119,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,
-114,0,0,18,99,111,111,114,100,0,0,0,0,1,90,95,0,0,12,0,0,115,104,97,100,111,119,49,68,80,114,111,
-106,0,1,1,0,0,20,0,115,97,109,112,108,101,114,0,0,1,1,0,0,12,0,99,111,111,114,100,0,0,0,1,4,118,
-101,99,52,95,116,101,120,95,49,100,95,112,114,111,106,95,115,104,97,100,111,119,0,18,95,95,114,101,
-116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,0,0,0,1,90,95,0,0,12,0,
-0,115,104,97,100,111,119,50,68,0,1,1,0,0,21,0,115,97,109,112,108,101,114,0,0,1,1,0,0,11,0,99,111,
-111,114,100,0,0,0,1,4,118,101,99,52,95,116,101,120,95,50,100,95,115,104,97,100,111,119,0,18,95,95,
-114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,0,0,0,1,90,95,
-0,0,12,0,0,115,104,97,100,111,119,50,68,80,114,111,106,0,1,1,0,0,21,0,115,97,109,112,108,101,114,0,
-0,1,1,0,0,12,0,99,111,111,114,100,0,0,0,1,4,118,101,99,52,95,116,101,120,95,50,100,95,112,114,111,
-106,95,115,104,97,100,111,119,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,
-0,18,99,111,111,114,100,0,0,0,0,1,90,95,0,0,12,0,0,116,101,120,116,117,114,101,50,68,82,101,99,116,
-0,1,1,0,0,22,0,115,97,109,112,108,101,114,0,0,1,1,0,0,10,0,99,111,111,114,100,0,0,0,1,4,118,101,99,
-52,95,116,101,120,95,114,101,99,116,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,
-114,0,0,18,99,111,111,114,100,0,0,0,0,1,90,95,0,0,12,0,0,116,101,120,116,117,114,101,50,68,82,101,
-99,116,80,114,111,106,0,1,1,0,0,22,0,115,97,109,112,108,101,114,0,0,1,1,0,0,11,0,99,111,111,114,
-100,0,0,0,1,4,118,101,99,52,95,116,101,120,95,114,101,99,116,95,112,114,111,106,0,18,95,95,114,101,
-116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,59,120,121,122,122,0,0,
-0,0,1,90,95,0,0,12,0,0,116,101,120,116,117,114,101,50,68,82,101,99,116,80,114,111,106,0,1,1,0,0,22,
-0,115,97,109,112,108,101,114,0,0,1,1,0,0,12,0,99,111,111,114,100,0,0,0,1,4,118,101,99,52,95,116,
-101,120,95,114,101,99,116,95,112,114,111,106,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,
-112,108,101,114,0,0,18,99,99,111,111,114,100,0,0,0,0,1,90,95,0,0,12,0,0,115,104,97,100,111,119,50,
-68,82,101,99,116,0,1,1,0,0,23,0,115,97,109,112,108,101,114,0,0,1,1,0,0,11,0,99,111,111,114,100,0,0,
-0,1,4,118,101,99,52,95,116,101,120,95,114,101,99,116,95,115,104,97,100,111,119,0,18,95,95,114,101,
-116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,0,0,0,1,90,95,0,0,12,0,
-0,115,104,97,100,111,119,50,68,82,101,99,116,80,114,111,106,0,1,1,0,0,23,0,115,97,109,112,108,101,
-114,0,0,1,1,0,0,12,0,99,111,111,114,100,0,0,0,1,4,118,101,99,52,95,116,101,120,95,114,101,99,116,
-95,112,114,111,106,95,115,104,97,100,111,119,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,
-112,108,101,114,0,0,18,99,111,111,114,100,0,0,0,0,1,90,95,0,0,9,0,0,110,111,105,115,101,49,0,1,1,0,
-0,9,0,120,0,0,0,1,4,102,108,111,97,116,95,110,111,105,115,101,49,0,18,95,95,114,101,116,86,97,108,
-0,0,18,120,0,0,0,0,1,90,95,0,0,9,0,0,110,111,105,115,101,49,0,1,1,0,0,10,0,120,0,0,0,1,4,102,108,
-111,97,116,95,110,111,105,115,101,50,0,18,95,95,114,101,116,86,97,108,0,0,18,120,0,0,0,0,1,90,95,0,
-0,9,0,0,110,111,105,115,101,49,0,1,1,0,0,11,0,120,0,0,0,1,4,102,108,111,97,116,95,110,111,105,115,
-101,51,0,18,95,95,114,101,116,86,97,108,0,0,18,120,0,0,0,0,1,90,95,0,0,9,0,0,110,111,105,115,101,
-49,0,1,1,0,0,12,0,120,0,0,0,1,4,102,108,111,97,116,95,110,111,105,115,101,52,0,18,95,95,114,101,
-116,86,97,108,0,0,18,120,0,0,0,0,1,90,95,0,0,10,0,0,110,111,105,115,101,50,0,1,1,0,0,9,0,120,0,0,0,
-1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,58,110,111,105,115,101,49,0,0,18,120,0,0,0,20,0,9,18,
-95,95,114,101,116,86,97,108,0,59,121,0,58,110,111,105,115,101,49,0,0,18,120,0,17,49,57,0,51,52,0,0,
-46,0,0,20,0,0,1,90,95,0,0,10,0,0,110,111,105,115,101,50,0,1,1,0,0,10,0,120,0,0,0,1,9,18,95,95,114,
-101,116,86,97,108,0,59,120,0,58,110,111,105,115,101,49,0,0,18,120,0,0,0,20,0,9,18,95,95,114,101,
-116,86,97,108,0,59,121,0,58,110,111,105,115,101,49,0,0,18,120,0,58,118,101,99,50,0,0,17,49,57,0,51,
-52,0,0,0,17,55,0,54,54,0,0,0,0,46,0,0,20,0,0,1,90,95,0,0,10,0,0,110,111,105,115,101,50,0,1,1,0,0,
-11,0,120,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,58,110,111,105,115,101,49,0,0,18,120,
-0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,58,110,111,105,115,101,49,0,0,18,120,0,58,
-118,101,99,51,0,0,17,49,57,0,51,52,0,0,0,17,55,0,54,54,0,0,0,17,51,0,50,51,0,0,0,0,46,0,0,20,0,0,1,
-90,95,0,0,10,0,0,110,111,105,115,101,50,0,1,1,0,0,12,0,120,0,0,0,1,9,18,95,95,114,101,116,86,97,
-108,0,59,120,0,58,110,111,105,115,101,49,0,0,18,120,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,
-59,121,0,58,110,111,105,115,101,49,0,0,18,120,0,58,118,101,99,52,0,0,17,49,57,0,51,52,0,0,0,17,55,
-0,54,54,0,0,0,17,51,0,50,51,0,0,0,17,50,0,55,55,0,0,0,0,46,0,0,20,0,0,1,90,95,0,0,11,0,0,110,111,
-105,115,101,51,0,1,1,0,0,9,0,120,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,58,110,111,
-105,115,101,49,0,0,18,120,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,58,110,111,105,
-115,101,49,0,0,18,120,0,17,49,57,0,51,52,0,0,46,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,122,
-0,58,110,111,105,115,101,49,0,0,18,120,0,17,53,0,52,55,0,0,46,0,0,20,0,0,1,90,95,0,0,11,0,0,110,
-111,105,115,101,51,0,1,1,0,0,10,0,120,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,58,110,
-111,105,115,101,49,0,0,18,120,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,58,110,111,
-105,115,101,49,0,0,18,120,0,58,118,101,99,50,0,0,17,49,57,0,51,52,0,0,0,17,55,0,54,54,0,0,0,0,46,0,
-0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,58,110,111,105,115,101,49,0,0,18,120,0,58,118,
-101,99,50,0,0,17,53,0,52,55,0,0,0,17,49,55,0,56,53,0,0,0,0,46,0,0,20,0,0,1,90,95,0,0,11,0,0,110,
-111,105,115,101,51,0,1,1,0,0,11,0,120,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,58,110,
-111,105,115,101,49,0,0,18,120,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,58,110,111,
-105,115,101,49,0,0,18,120,0,58,118,101,99,51,0,0,17,49,57,0,51,52,0,0,0,17,55,0,54,54,0,0,0,17,51,
-0,50,51,0,0,0,0,46,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,58,110,111,105,115,101,49,
-0,0,18,120,0,58,118,101,99,51,0,0,17,53,0,52,55,0,0,0,17,49,55,0,56,53,0,0,0,17,49,49,0,48,52,0,0,
-0,0,46,0,0,20,0,0,1,90,95,0,0,11,0,0,110,111,105,115,101,51,0,1,1,0,0,12,0,120,0,0,0,1,9,18,95,95,
-114,101,116,86,97,108,0,59,120,0,58,110,111,105,115,101,49,0,0,18,120,0,0,0,20,0,9,18,95,95,114,
-101,116,86,97,108,0,59,121,0,58,110,111,105,115,101,49,0,0,18,120,0,58,118,101,99,52,0,0,17,49,57,
-0,51,52,0,0,0,17,55,0,54,54,0,0,0,17,51,0,50,51,0,0,0,17,50,0,55,55,0,0,0,0,46,0,0,20,0,9,18,95,95,
-114,101,116,86,97,108,0,59,122,0,58,110,111,105,115,101,49,0,0,18,120,0,58,118,101,99,52,0,0,17,53,
-0,52,55,0,0,0,17,49,55,0,56,53,0,0,0,17,49,49,0,48,52,0,0,0,17,49,51,0,49,57,0,0,0,0,46,0,0,20,0,0,
-1,90,95,0,0,12,0,0,110,111,105,115,101,52,0,1,1,0,0,9,0,120,0,0,0,1,9,18,95,95,114,101,116,86,97,
-108,0,59,120,0,58,110,111,105,115,101,49,0,0,18,120,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,
-59,121,0,58,110,111,105,115,101,49,0,0,18,120,0,17,49,57,0,51,52,0,0,46,0,0,20,0,9,18,95,95,114,
-101,116,86,97,108,0,59,122,0,58,110,111,105,115,101,49,0,0,18,120,0,17,53,0,52,55,0,0,46,0,0,20,0,
-9,18,95,95,114,101,116,86,97,108,0,59,119,0,58,110,111,105,115,101,49,0,0,18,120,0,17,50,51,0,53,
-52,0,0,46,0,0,20,0,0,1,90,95,0,0,12,0,0,110,111,105,115,101,52,0,1,1,0,0,10,0,120,0,0,0,1,9,18,95,
-95,114,101,116,86,97,108,0,59,120,0,58,110,111,105,115,101,49,0,0,18,120,0,0,0,20,0,9,18,95,95,114,
-101,116,86,97,108,0,59,121,0,58,110,111,105,115,101,49,0,0,18,120,0,58,118,101,99,50,0,0,17,49,57,
-0,51,52,0,0,0,17,55,0,54,54,0,0,0,0,46,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,58,110,
-111,105,115,101,49,0,0,18,120,0,58,118,101,99,50,0,0,17,53,0,52,55,0,0,0,17,49,55,0,56,53,0,0,0,0,
-46,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,119,0,58,110,111,105,115,101,49,0,0,18,120,0,58,
-118,101,99,50,0,0,17,50,51,0,53,52,0,0,0,17,50,57,0,49,49,0,0,0,0,46,0,0,20,0,0,1,90,95,0,0,12,0,0,
-110,111,105,115,101,52,0,1,1,0,0,11,0,120,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,58,
-110,111,105,115,101,49,0,0,18,120,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,58,110,
-111,105,115,101,49,0,0,18,120,0,58,118,101,99,51,0,0,17,49,57,0,51,52,0,0,0,17,55,0,54,54,0,0,0,17,
-51,0,50,51,0,0,0,0,46,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,58,110,111,105,115,101,
-49,0,0,18,120,0,58,118,101,99,51,0,0,17,53,0,52,55,0,0,0,17,49,55,0,56,53,0,0,0,17,49,49,0,48,52,0,
-0,0,0,46,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,119,0,58,110,111,105,115,101,49,0,0,18,120,
-0,58,118,101,99,51,0,0,17,50,51,0,53,52,0,0,0,17,50,57,0,49,49,0,0,0,17,51,49,0,57,49,0,0,0,0,46,0,
-0,20,0,0,1,90,95,0,0,12,0,0,110,111,105,115,101,52,0,1,1,0,0,12,0,120,0,0,0,1,9,18,95,95,114,101,
-116,86,97,108,0,59,120,0,58,110,111,105,115,101,49,0,0,18,120,0,0,0,20,0,9,18,95,95,114,101,116,86,
-97,108,0,59,121,0,58,110,111,105,115,101,49,0,0,18,120,0,58,118,101,99,52,0,0,17,49,57,0,51,52,0,0,
-0,17,55,0,54,54,0,0,0,17,51,0,50,51,0,0,0,17,50,0,55,55,0,0,0,0,46,0,0,20,0,9,18,95,95,114,101,116,
-86,97,108,0,59,122,0,58,110,111,105,115,101,49,0,0,18,120,0,58,118,101,99,52,0,0,17,53,0,52,55,0,0,
-0,17,49,55,0,56,53,0,0,0,17,49,49,0,48,52,0,0,0,17,49,51,0,49,57,0,0,0,0,46,0,0,20,0,9,18,95,95,
-114,101,116,86,97,108,0,59,119,0,58,110,111,105,115,101,49,0,0,18,120,0,58,118,101,99,52,0,0,17,50,
-51,0,53,52,0,0,0,17,50,57,0,49,49,0,0,0,17,51,49,0,57,49,0,0,0,17,51,55,0,52,56,0,0,0,0,46,0,0,20,
-0,0,0
diff --git a/src/mesa/shader/slang/library/slang_core_gc.h b/src/mesa/shader/slang/library/slang_core_gc.h
deleted file mode 100644 (file)
index b3d3e87..0000000
+++ /dev/null
@@ -1,869 +0,0 @@
-
-/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED FROM THE FOLLOWING FILE: */
-/* slang_core.gc */
-
-5,1,90,95,0,0,5,0,1,1,1,0,0,9,0,102,0,0,0,1,4,118,101,99,52,95,116,111,95,105,118,101,99,52,0,18,
-95,95,114,101,116,86,97,108,0,0,18,102,0,0,0,0,1,90,95,0,0,5,0,1,1,1,0,0,1,0,98,0,0,0,1,9,18,95,95,
-114,101,116,86,97,108,0,18,98,0,20,0,0,1,90,95,0,0,5,0,1,1,1,0,0,5,0,105,0,0,0,1,9,18,95,95,114,
-101,116,86,97,108,0,18,105,0,20,0,0,1,90,95,0,0,1,0,1,1,1,0,0,5,0,105,0,0,0,1,4,118,101,99,52,95,
-115,110,101,0,18,95,95,114,101,116,86,97,108,0,0,18,105,0,0,17,48,0,48,0,0,0,0,0,1,90,95,0,0,1,0,1,
-1,1,0,0,9,0,102,0,0,0,1,4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,0,18,102,
-0,0,17,48,0,48,0,0,0,0,0,1,90,95,0,0,1,0,1,1,1,0,0,1,0,98,0,0,0,1,9,18,95,95,114,101,116,86,97,108,
-0,18,98,0,20,0,0,1,90,95,0,0,9,0,1,1,1,0,0,5,0,105,0,0,0,1,4,105,118,101,99,52,95,116,111,95,118,
-101,99,52,0,18,95,95,114,101,116,86,97,108,0,0,18,105,0,0,0,0,1,90,95,0,0,9,0,1,1,1,0,0,1,0,98,0,0,
-0,1,4,105,118,101,99,52,95,116,111,95,118,101,99,52,0,18,95,95,114,101,116,86,97,108,0,0,18,98,0,0,
-0,0,1,90,95,0,0,9,0,1,1,1,0,0,9,0,102,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,102,0,20,0,0,1,
-90,95,0,0,10,0,1,1,1,0,0,9,0,120,0,0,1,1,0,0,9,0,121,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,
-120,0,18,120,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,18,121,0,20,0,0,1,90,95,0,0,10,0,1,
-1,1,0,0,9,0,102,0,0,0,1,4,118,101,99,52,95,109,111,118,101,0,18,95,95,114,101,116,86,97,108,0,59,
-120,121,0,0,18,102,0,0,0,0,1,90,95,0,0,10,0,1,1,1,0,0,5,0,105,0,0,0,1,4,105,118,101,99,52,95,116,
-111,95,118,101,99,52,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,105,0,0,0,0,1,90,95,0,0,
-10,0,1,1,1,0,0,1,0,98,0,0,0,1,4,105,118,101,99,52,95,116,111,95,118,101,99,52,0,18,95,95,114,101,
-116,86,97,108,0,59,120,121,0,0,18,98,0,0,0,0,1,90,95,0,0,10,0,1,1,1,0,0,2,0,98,0,0,0,1,4,105,118,
-101,99,52,95,116,111,95,118,101,99,52,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,98,0,0,
-0,0,1,90,95,0,0,10,0,1,1,1,0,0,11,0,118,0,0,0,1,4,118,101,99,52,95,109,111,118,101,0,18,95,95,114,
-101,116,86,97,108,0,59,120,121,0,0,18,118,0,59,120,121,0,0,0,0,1,90,95,0,0,10,0,1,1,1,0,0,12,0,118,
-0,0,0,1,4,118,101,99,52,95,109,111,118,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,
-118,0,59,120,121,0,0,0,0,1,90,95,0,0,11,0,1,1,1,0,0,9,0,120,0,0,1,1,0,0,9,0,121,0,0,1,1,0,0,9,0,
-122,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,18,120,0,20,0,9,18,95,95,114,101,116,86,97,
-108,0,59,121,0,18,121,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,18,122,0,20,0,0,1,90,95,0,
-0,11,0,1,1,1,0,0,9,0,102,0,0,0,1,4,118,101,99,52,95,109,111,118,101,0,18,95,95,114,101,116,86,97,
-108,0,59,120,121,122,0,0,18,102,0,0,0,0,1,90,95,0,0,11,0,1,1,1,0,0,5,0,105,0,0,0,1,4,105,118,101,
-99,52,95,116,111,95,118,101,99,52,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,105,0,0,
-0,0,1,90,95,0,0,11,0,1,1,1,0,0,1,0,98,0,0,0,1,4,105,118,101,99,52,95,116,111,95,118,101,99,52,0,18,
-95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,98,0,0,0,0,1,90,95,0,0,11,0,1,1,1,0,0,3,0,98,0,
-0,0,1,4,105,118,101,99,52,95,116,111,95,118,101,99,52,0,18,95,95,114,101,116,86,97,108,0,59,120,
-121,122,0,0,18,98,0,0,0,0,1,90,95,0,0,11,0,1,1,1,0,0,12,0,118,0,0,0,1,4,118,101,99,52,95,109,111,
-118,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,118,0,0,0,0,1,90,95,0,0,12,0,1,1,
-1,0,0,9,0,120,0,0,1,1,0,0,9,0,121,0,0,1,1,0,0,9,0,122,0,0,1,1,0,0,9,0,119,0,0,0,1,9,18,95,95,114,
-101,116,86,97,108,0,59,120,0,18,120,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,18,121,0,20,
-0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,18,122,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,
-119,0,18,119,0,20,0,0,1,90,95,0,0,12,0,1,1,1,0,0,9,0,102,0,0,0,1,4,118,101,99,52,95,109,111,118,
-101,0,18,95,95,114,101,116,86,97,108,0,0,18,102,0,0,0,0,1,90,95,0,0,12,0,1,1,1,0,0,5,0,105,0,0,0,1,
-4,105,118,101,99,52,95,116,111,95,118,101,99,52,0,18,95,95,114,101,116,86,97,108,0,0,18,105,0,0,0,
-0,1,90,95,0,0,12,0,1,1,1,0,0,1,0,98,0,0,0,1,4,105,118,101,99,52,95,116,111,95,118,101,99,52,0,18,
-95,95,114,101,116,86,97,108,0,0,18,98,0,0,0,0,1,90,95,0,0,12,0,1,1,1,0,0,4,0,98,0,0,0,1,4,105,118,
-101,99,52,95,116,111,95,118,101,99,52,0,18,95,95,114,101,116,86,97,108,0,0,18,98,0,0,0,0,1,90,95,0,
-0,12,0,1,1,1,0,0,8,0,105,0,0,0,1,4,105,118,101,99,52,95,116,111,95,118,101,99,52,0,18,95,95,114,
-101,116,86,97,108,0,0,18,105,0,0,0,0,1,90,95,0,0,12,0,1,1,1,0,0,11,0,118,51,0,0,1,1,0,0,9,0,102,0,
-0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,18,118,51,0,20,0,9,18,95,95,114,101,116,
-86,97,108,0,59,119,0,18,102,0,20,0,0,1,90,95,0,0,12,0,1,1,1,0,0,10,0,118,50,0,0,1,1,0,0,9,0,102,49,
-0,0,1,1,0,0,9,0,102,50,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,121,0,18,118,50,0,20,0,9,
-18,95,95,114,101,116,86,97,108,0,59,122,0,18,102,49,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,
-119,0,18,102,50,0,20,0,0,1,90,95,0,0,6,0,1,1,1,0,0,5,0,105,0,0,1,1,0,0,5,0,106,0,0,0,1,9,18,95,95,
-114,101,116,86,97,108,0,59,120,0,18,105,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,18,106,
-0,20,0,0,1,90,95,0,0,6,0,1,1,1,0,0,5,0,105,0,0,0,1,4,118,101,99,52,95,109,111,118,101,0,18,95,95,
-114,101,116,86,97,108,0,59,120,121,0,0,18,105,0,0,0,0,1,90,95,0,0,6,0,1,1,1,0,0,9,0,102,0,0,0,1,4,
-118,101,99,52,95,116,111,95,105,118,101,99,52,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,
-102,0,0,0,0,1,90,95,0,0,6,0,1,1,1,0,0,1,0,98,0,0,0,1,4,118,101,99,52,95,116,111,95,105,118,101,99,
-52,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,98,0,0,0,0,1,90,95,0,0,7,0,1,1,1,0,0,5,0,
-105,0,0,1,1,0,0,5,0,106,0,0,1,1,0,0,5,0,107,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,18,
-105,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,18,106,0,20,0,9,18,95,95,114,101,116,86,97,
-108,0,59,122,0,18,107,0,20,0,0,1,90,95,0,0,7,0,1,1,1,0,0,5,0,105,0,0,0,1,4,118,101,99,52,95,109,
-111,118,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,105,0,0,0,0,1,90,95,0,0,7,0,1,
-1,1,0,0,9,0,102,0,0,0,1,4,118,101,99,52,95,116,111,95,105,118,101,99,52,0,18,95,95,114,101,116,86,
-97,108,0,59,120,121,122,0,0,18,102,0,0,0,0,1,90,95,0,0,7,0,1,1,1,0,0,1,0,98,0,0,0,1,4,118,101,99,
-52,95,109,111,118,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,98,0,0,0,0,1,90,95,
-0,0,8,0,1,1,1,0,0,5,0,120,0,0,1,1,0,0,5,0,121,0,0,1,1,0,0,5,0,122,0,0,1,1,0,0,5,0,119,0,0,0,1,9,18,
-95,95,114,101,116,86,97,108,0,59,120,0,18,120,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,
-18,121,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,18,122,0,20,0,9,18,95,95,114,101,116,86,
-97,108,0,59,119,0,18,119,0,20,0,0,1,90,95,0,0,8,0,1,1,1,0,0,5,0,105,0,0,0,1,4,118,101,99,52,95,109,
-111,118,101,0,18,95,95,114,101,116,86,97,108,0,0,18,105,0,0,0,0,1,90,95,0,0,8,0,1,1,1,0,0,9,0,102,
-0,0,0,1,4,118,101,99,52,95,116,111,95,105,118,101,99,52,0,18,95,95,114,101,116,86,97,108,0,0,18,
-102,0,0,0,0,1,90,95,0,0,8,0,1,1,1,0,0,1,0,98,0,0,0,1,4,118,101,99,52,95,116,111,95,105,118,101,99,
-52,0,18,95,95,114,101,116,86,97,108,0,0,18,98,0,0,0,0,1,90,95,0,0,2,0,1,1,1,0,0,1,0,98,49,0,0,1,1,
-0,0,1,0,98,50,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,18,98,49,0,20,0,9,18,95,95,114,
-101,116,86,97,108,0,59,121,0,18,98,50,0,20,0,0,1,90,95,0,0,2,0,1,1,1,0,0,5,0,105,49,0,0,1,1,0,0,5,
-0,105,50,0,0,0,1,4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,
-105,49,0,0,17,48,0,48,0,0,0,0,4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,59,
-121,0,0,18,105,50,0,0,17,48,0,48,0,0,0,0,0,1,90,95,0,0,2,0,1,1,1,0,0,1,0,98,0,0,0,1,4,118,101,99,
-52,95,109,111,118,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,98,0,0,0,0,1,90,95,0,0,
-2,0,1,1,1,0,0,9,0,102,0,0,0,1,4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,59,
-120,121,0,0,18,102,0,0,17,48,0,48,0,0,0,0,0,1,90,95,0,0,2,0,1,1,1,0,0,5,0,105,0,0,0,1,4,118,101,99,
-52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,105,0,0,17,48,0,48,0,0,0,0,
-0,1,90,95,0,0,2,0,1,1,1,0,0,10,0,118,0,0,0,1,4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,
-86,97,108,0,59,120,121,0,0,18,118,0,0,17,48,0,48,0,0,0,0,0,1,90,95,0,0,2,0,1,1,1,0,0,6,0,118,0,0,0,
-1,4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,118,0,0,17,
-48,0,48,0,0,0,0,0,1,90,95,0,0,3,0,1,1,1,0,0,1,0,98,49,0,0,1,1,0,0,1,0,98,50,0,0,1,1,0,0,1,0,98,51,
-0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,18,98,49,0,20,0,9,18,95,95,114,101,116,86,97,
-108,0,59,121,0,18,98,50,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,18,98,51,0,20,0,0,1,90,
-95,0,0,3,0,1,1,1,0,0,9,0,102,49,0,0,1,1,0,0,9,0,102,50,0,0,1,1,0,0,9,0,102,51,0,0,0,1,4,118,101,99,
-52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,102,49,0,0,17,48,0,48,0,0,0,0,4,
-118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,59,121,0,0,18,102,50,0,0,17,48,0,
-48,0,0,0,0,4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,59,122,0,0,18,102,51,
-0,0,17,48,0,48,0,0,0,0,0,1,90,95,0,0,3,0,1,1,1,0,0,1,0,98,0,0,0,1,4,118,101,99,52,95,109,111,118,
-101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,98,0,0,0,0,1,90,95,0,0,3,0,1,1,1,0,0,
-9,0,102,0,0,0,1,4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,
-0,18,102,0,0,17,48,0,48,0,0,0,0,0,1,90,95,0,0,3,0,1,1,1,0,0,5,0,105,0,0,0,1,4,118,101,99,52,95,115,
-110,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,105,0,0,17,48,0,48,0,0,0,0,0,1,90,
-95,0,0,3,0,1,1,1,0,0,11,0,118,0,0,0,1,4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,
-108,0,59,120,121,122,0,0,18,118,0,0,17,48,0,48,0,0,0,0,0,1,90,95,0,0,3,0,1,1,1,0,0,7,0,118,0,0,0,1,
-4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,118,0,0,17,
-48,0,48,0,0,0,0,0,1,90,95,0,0,4,0,1,1,1,0,0,1,0,98,49,0,0,1,1,0,0,1,0,98,50,0,0,1,1,0,0,1,0,98,51,
-0,0,1,1,0,0,1,0,98,52,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,18,98,49,0,20,0,9,18,95,
-95,114,101,116,86,97,108,0,59,121,0,18,98,50,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,18,
-98,51,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,119,0,18,98,52,0,20,0,0,1,90,95,0,0,4,0,1,1,1,0,
-0,9,0,102,49,0,0,1,1,0,0,9,0,102,50,0,0,1,1,0,0,9,0,102,51,0,0,1,1,0,0,9,0,102,52,0,0,0,1,3,2,90,
-95,1,0,9,0,1,122,101,114,111,0,2,17,48,0,48,0,0,0,0,4,118,101,99,52,95,115,110,101,0,18,95,95,114,
-101,116,86,97,108,0,59,120,0,0,18,102,49,0,0,18,122,101,114,111,0,0,0,4,118,101,99,52,95,115,110,
-101,0,18,95,95,114,101,116,86,97,108,0,59,121,0,0,18,102,50,0,0,18,122,101,114,111,0,0,0,4,118,101,
-99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,59,122,0,0,18,102,51,0,0,18,122,101,114,
-111,0,0,0,4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,59,119,0,0,18,102,52,0,
-0,18,122,101,114,111,0,0,0,0,1,90,95,0,0,4,0,1,1,1,0,0,1,0,98,0,0,0,1,4,118,101,99,52,95,109,111,
-118,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,119,0,0,18,98,0,0,0,0,1,90,95,0,0,4,0,1,
-1,1,0,0,9,0,102,0,0,0,1,4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,59,120,
-121,122,119,0,0,18,102,0,0,17,48,0,48,0,0,0,0,0,1,90,95,0,0,4,0,1,1,1,0,0,5,0,105,0,0,0,1,4,118,
-101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,119,0,0,18,105,0,0,17,
-48,0,48,0,0,0,0,0,1,90,95,0,0,4,0,1,1,1,0,0,12,0,118,0,0,0,1,4,118,101,99,52,95,115,110,101,0,18,
-95,95,114,101,116,86,97,108,0,59,120,121,122,119,0,0,18,118,0,0,17,48,0,48,0,0,0,0,0,1,90,95,0,0,4,
-0,1,1,1,0,0,8,0,118,0,0,0,1,4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,59,
-120,121,122,119,0,0,18,118,0,0,17,48,0,48,0,0,0,0,0,1,90,95,0,0,13,0,1,1,1,0,0,9,0,109,48,48,0,0,1,
-1,0,0,9,0,109,49,48,0,0,1,1,0,0,9,0,109,48,49,0,0,1,1,0,0,9,0,109,49,49,0,0,0,1,9,18,95,95,114,101,
-116,86,97,108,0,16,8,48,0,57,59,120,0,18,109,48,48,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,8,
-48,0,57,59,121,0,18,109,49,48,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,59,120,0,18,
-109,48,49,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,59,121,0,18,109,49,49,0,20,0,0,1,
-90,95,0,0,13,0,1,1,1,0,0,9,0,102,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,59,120,0,
-18,102,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,59,121,0,17,48,0,48,0,0,20,0,9,18,95,
-95,114,101,116,86,97,108,0,16,10,49,0,57,59,120,0,17,48,0,48,0,0,20,0,9,18,95,95,114,101,116,86,97,
-108,0,16,10,49,0,57,59,121,0,18,102,0,20,0,0,1,90,95,0,0,13,0,1,1,1,0,0,5,0,105,0,0,0,1,8,58,109,
-97,116,50,0,0,58,102,108,111,97,116,0,0,18,105,0,0,0,0,0,0,0,1,90,95,0,0,13,0,1,1,1,0,0,1,0,98,0,0,
-0,1,8,58,109,97,116,50,0,0,58,102,108,111,97,116,0,0,18,98,0,0,0,0,0,0,0,1,90,95,0,0,13,0,1,1,1,0,
-0,10,0,99,48,0,0,1,1,0,0,10,0,99,49,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,99,
-48,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,99,49,0,20,0,0,1,90,95,0,0,14,0,1,1,
-1,0,0,9,0,109,48,48,0,0,1,1,0,0,9,0,109,49,48,0,0,1,1,0,0,9,0,109,50,48,0,0,1,1,0,0,9,0,109,48,49,
-0,0,1,1,0,0,9,0,109,49,49,0,0,1,1,0,0,9,0,109,50,49,0,0,1,1,0,0,9,0,109,48,50,0,0,1,1,0,0,9,0,109,
-49,50,0,0,1,1,0,0,9,0,109,50,50,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,59,120,0,
-18,109,48,48,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,59,121,0,18,109,49,48,0,20,0,9,
-18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,59,122,0,18,109,50,48,0,20,0,9,18,95,95,114,101,116,
-86,97,108,0,16,10,49,0,57,59,120,0,18,109,48,49,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,
-0,57,59,121,0,18,109,49,49,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,59,122,0,18,109,
-50,49,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,59,120,0,18,109,48,50,0,20,0,9,18,95,
-95,114,101,116,86,97,108,0,16,10,50,0,57,59,121,0,18,109,49,50,0,20,0,9,18,95,95,114,101,116,86,97,
-108,0,16,10,50,0,57,59,122,0,18,109,50,50,0,20,0,0,1,90,95,0,0,14,0,1,1,1,0,0,9,0,102,0,0,0,1,3,2,
-90,95,0,0,10,0,1,118,0,2,58,118,101,99,50,0,0,18,102,0,0,17,48,0,48,0,0,0,0,0,0,9,18,95,95,114,101,
-116,86,97,108,0,16,8,48,0,57,18,118,0,59,120,121,121,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,
-10,49,0,57,18,118,0,59,121,120,121,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,118,
-0,59,121,121,120,0,20,0,0,1,90,95,0,0,14,0,1,1,1,0,0,5,0,105,0,0,0,1,8,58,109,97,116,51,0,0,58,102,
-108,111,97,116,0,0,18,105,0,0,0,0,0,0,0,1,90,95,0,0,14,0,1,1,1,0,0,1,0,98,0,0,0,1,8,58,109,97,116,
-51,0,0,58,102,108,111,97,116,0,0,18,98,0,0,0,0,0,0,0,1,90,95,0,0,14,0,1,1,1,0,0,11,0,99,48,0,0,1,1,
-0,0,11,0,99,49,0,0,1,1,0,0,11,0,99,50,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,
-99,48,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,99,49,0,20,0,9,18,95,95,114,101,
-116,86,97,108,0,16,10,50,0,57,18,99,50,0,20,0,0,1,90,95,0,0,15,0,1,1,1,0,0,9,0,109,48,48,0,0,1,1,0,
-0,9,0,109,49,48,0,0,1,1,0,0,9,0,109,50,48,0,0,1,1,0,0,9,0,109,51,48,0,0,1,1,0,0,9,0,109,48,49,0,0,
-1,1,0,0,9,0,109,49,49,0,0,1,1,0,0,9,0,109,50,49,0,0,1,1,0,0,9,0,109,51,49,0,0,1,1,0,0,9,0,109,48,
-50,0,0,1,1,0,0,9,0,109,49,50,0,0,1,1,0,0,9,0,109,50,50,0,0,1,1,0,0,9,0,109,51,50,0,0,1,1,0,0,9,0,
-109,48,51,0,0,1,1,0,0,9,0,109,49,51,0,0,1,1,0,0,9,0,109,50,51,0,0,1,1,0,0,9,0,109,51,51,0,0,0,1,9,
-18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,59,120,0,18,109,48,48,0,20,0,9,18,95,95,114,101,116,
-86,97,108,0,16,8,48,0,57,59,121,0,18,109,49,48,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,
-57,59,122,0,18,109,50,48,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,59,119,0,18,109,51,
-48,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,59,120,0,18,109,48,49,0,20,0,9,18,95,95,
-114,101,116,86,97,108,0,16,10,49,0,57,59,121,0,18,109,49,49,0,20,0,9,18,95,95,114,101,116,86,97,
-108,0,16,10,49,0,57,59,122,0,18,109,50,49,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,
-59,119,0,18,109,51,49,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,59,120,0,18,109,48,
-50,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,59,121,0,18,109,49,50,0,20,0,9,18,95,95,
-114,101,116,86,97,108,0,16,10,50,0,57,59,122,0,18,109,50,50,0,20,0,9,18,95,95,114,101,116,86,97,
-108,0,16,10,50,0,57,59,119,0,18,109,51,50,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,51,0,57,
-59,120,0,18,109,48,51,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,51,0,57,59,121,0,18,109,49,
-51,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,51,0,57,59,122,0,18,109,50,51,0,20,0,9,18,95,95,
-114,101,116,86,97,108,0,16,10,51,0,57,59,119,0,18,109,51,51,0,20,0,0,1,90,95,0,0,15,0,1,1,1,0,0,9,
-0,102,0,0,0,1,3,2,90,95,0,0,10,0,1,118,0,2,58,118,101,99,50,0,0,18,102,0,0,17,48,0,48,0,0,0,0,0,0,
-9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,118,0,59,120,121,121,121,0,20,0,9,18,95,95,114,
-101,116,86,97,108,0,16,10,49,0,57,18,118,0,59,121,120,121,121,0,20,0,9,18,95,95,114,101,116,86,97,
-108,0,16,10,50,0,57,18,118,0,59,121,121,120,121,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,51,
-0,57,18,118,0,59,121,121,121,120,0,20,0,0,1,90,95,0,0,15,0,1,1,1,0,0,5,0,105,0,0,0,1,8,58,109,97,
-116,52,0,0,58,102,108,111,97,116,0,0,18,105,0,0,0,0,0,0,0,1,90,95,0,0,15,0,1,1,1,0,0,1,0,98,0,0,0,
-1,8,58,109,97,116,52,0,0,58,102,108,111,97,116,0,0,18,98,0,0,0,0,0,0,0,1,90,95,0,0,15,0,1,1,1,0,0,
-12,0,99,48,0,0,1,1,0,0,12,0,99,49,0,0,1,1,0,0,12,0,99,50,0,0,1,1,0,0,12,0,99,51,0,0,0,1,9,18,95,95,
-114,101,116,86,97,108,0,16,8,48,0,57,18,99,48,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,
-57,18,99,49,0,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,99,50,0,20,0,9,18,95,95,114,
-101,116,86,97,108,0,16,10,51,0,57,18,99,51,0,20,0,0,1,90,95,0,0,5,0,2,26,1,1,0,0,5,0,97,0,0,1,1,0,
-0,5,0,98,0,0,0,1,4,118,101,99,52,95,97,100,100,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,
-98,0,0,0,0,1,90,95,0,0,5,0,2,27,1,1,0,0,5,0,97,0,0,1,1,0,0,5,0,98,0,0,0,1,4,118,101,99,52,95,115,
-117,98,116,114,97,99,116,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,98,0,0,0,0,1,90,95,0,0,
-5,0,2,21,1,1,0,0,5,0,97,0,0,1,1,0,0,5,0,98,0,0,0,1,4,118,101,99,52,95,109,117,108,116,105,112,108,
-121,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,98,0,0,0,0,1,90,95,0,0,5,0,2,22,1,1,0,0,5,0,
-97,0,0,1,1,0,0,5,0,98,0,0,0,1,3,2,90,95,0,0,9,0,1,98,73,110,118,0,0,1,1,120,0,0,0,4,102,108,111,97,
-116,95,114,99,112,0,18,98,73,110,118,0,0,18,98,0,0,0,4,118,101,99,52,95,109,117,108,116,105,112,
-108,121,0,18,120,0,0,18,97,0,0,18,98,73,110,118,0,0,0,4,118,101,99,52,95,116,111,95,105,118,101,99,
-52,0,18,95,95,114,101,116,86,97,108,0,0,18,120,0,0,0,0,1,90,95,0,0,6,0,2,26,1,1,0,0,6,0,97,0,0,1,1,
-0,0,6,0,98,0,0,0,1,4,118,101,99,52,95,97,100,100,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,
-98,0,0,0,0,1,90,95,0,0,6,0,2,27,1,1,0,0,6,0,97,0,0,1,1,0,0,6,0,98,0,0,0,1,4,118,101,99,52,95,115,
-117,98,116,114,97,99,116,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,98,0,0,0,0,1,90,95,0,0,
-6,0,2,21,1,1,0,0,6,0,97,0,0,1,1,0,0,6,0,98,0,0,0,1,4,118,101,99,52,95,109,117,108,116,105,112,108,
-121,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,98,0,0,0,0,1,90,95,0,0,6,0,2,22,1,1,0,0,6,0,
-97,0,0,1,1,0,0,6,0,98,0,0,0,1,3,2,90,95,0,0,10,0,1,98,73,110,118,0,0,1,1,120,0,0,0,4,102,108,111,
-97,116,95,114,99,112,0,18,98,73,110,118,0,59,120,0,0,18,98,0,59,120,0,0,0,4,102,108,111,97,116,95,
-114,99,112,0,18,98,73,110,118,0,59,121,0,0,18,98,0,59,121,0,0,0,4,118,101,99,52,95,109,117,108,116,
-105,112,108,121,0,18,120,0,0,18,97,0,0,18,98,73,110,118,0,0,0,4,118,101,99,52,95,116,111,95,105,
-118,101,99,52,0,18,95,95,114,101,116,86,97,108,0,0,18,120,0,0,0,0,1,90,95,0,0,7,0,2,26,1,1,0,0,7,0,
-97,0,0,1,1,0,0,7,0,98,0,0,0,1,4,118,101,99,52,95,97,100,100,0,18,95,95,114,101,116,86,97,108,0,0,
-18,97,0,0,18,98,0,0,0,0,1,90,95,0,0,7,0,2,27,1,1,0,0,7,0,97,0,0,1,1,0,0,7,0,98,0,0,0,1,4,118,101,
-99,52,95,115,117,98,116,114,97,99,116,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,98,0,0,0,0,
-1,90,95,0,0,7,0,2,21,1,1,0,0,7,0,97,0,0,1,1,0,0,7,0,98,0,0,0,1,4,118,101,99,52,95,109,117,108,116,
-105,112,108,121,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,98,0,0,0,0,1,90,95,0,0,7,0,2,22,
-1,1,0,0,7,0,97,0,0,1,1,0,0,7,0,98,0,0,0,1,3,2,90,95,0,0,11,0,1,98,73,110,118,0,0,1,1,120,0,0,0,4,
-102,108,111,97,116,95,114,99,112,0,18,98,73,110,118,0,59,120,0,0,18,98,0,59,120,0,0,0,4,102,108,
-111,97,116,95,114,99,112,0,18,98,73,110,118,0,59,121,0,0,18,98,0,59,121,0,0,0,4,102,108,111,97,116,
-95,114,99,112,0,18,98,73,110,118,0,59,122,0,0,18,98,0,59,122,0,0,0,4,118,101,99,52,95,109,117,108,
-116,105,112,108,121,0,18,120,0,0,18,97,0,0,18,98,73,110,118,0,0,0,4,118,101,99,52,95,116,111,95,
-105,118,101,99,52,0,18,95,95,114,101,116,86,97,108,0,0,18,120,0,0,0,0,1,90,95,0,0,8,0,2,26,1,1,0,0,
-8,0,97,0,0,1,1,0,0,8,0,98,0,0,0,1,4,118,101,99,52,95,97,100,100,0,18,95,95,114,101,116,86,97,108,0,
-0,18,97,0,0,18,98,0,0,0,0,1,90,95,0,0,8,0,2,27,1,1,0,0,8,0,97,0,0,1,1,0,0,8,0,98,0,0,0,1,4,118,101,
-99,52,95,115,117,98,116,114,97,99,116,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,98,0,0,0,0,
-1,90,95,0,0,8,0,2,21,1,1,0,0,8,0,97,0,0,1,1,0,0,8,0,98,0,0,0,1,4,118,101,99,52,95,109,117,108,116,
-105,112,108,121,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,98,0,0,0,0,1,90,95,0,0,8,0,2,22,
-1,1,0,0,8,0,97,0,0,1,1,0,0,8,0,98,0,0,0,1,3,2,90,95,0,0,12,0,1,98,73,110,118,0,0,1,1,120,0,0,0,4,
-102,108,111,97,116,95,114,99,112,0,18,98,73,110,118,0,59,120,0,0,18,98,0,59,120,0,0,0,4,102,108,
-111,97,116,95,114,99,112,0,18,98,73,110,118,0,59,121,0,0,18,98,0,59,121,0,0,0,4,102,108,111,97,116,
-95,114,99,112,0,18,98,73,110,118,0,59,122,0,0,18,98,0,59,122,0,0,0,4,102,108,111,97,116,95,114,99,
-112,0,18,98,73,110,118,0,59,119,0,0,18,98,0,59,119,0,0,0,4,118,101,99,52,95,109,117,108,116,105,
-112,108,121,0,18,120,0,0,18,97,0,0,18,98,73,110,118,0,0,0,4,118,101,99,52,95,116,111,95,105,118,
-101,99,52,0,18,95,95,114,101,116,86,97,108,0,0,18,120,0,0,0,0,1,90,95,0,0,9,0,2,26,1,1,0,0,9,0,97,
-0,0,1,1,0,0,9,0,98,0,0,0,1,4,118,101,99,52,95,97,100,100,0,18,95,95,114,101,116,86,97,108,0,0,18,
-97,0,0,18,98,0,0,0,0,1,90,95,0,0,9,0,2,27,1,1,0,0,9,0,97,0,0,1,1,0,0,9,0,98,0,0,0,1,4,118,101,99,
-52,95,115,117,98,116,114,97,99,116,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,98,0,0,0,0,1,
-90,95,0,0,9,0,2,21,1,1,0,0,9,0,97,0,0,1,1,0,0,9,0,98,0,0,0,1,4,118,101,99,52,95,109,117,108,116,
-105,112,108,121,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,98,0,0,0,0,1,90,95,0,0,9,0,2,22,
-1,1,0,0,9,0,97,0,0,1,1,0,0,9,0,98,0,0,0,1,3,2,90,95,0,0,9,0,1,98,73,110,118,0,0,0,4,102,108,111,97,
-116,95,114,99,112,0,18,98,73,110,118,0,59,120,0,0,18,98,0,0,0,4,118,101,99,52,95,109,117,108,116,
-105,112,108,121,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,98,73,110,118,0,0,0,0,1,90,95,0,
-0,10,0,2,26,1,1,0,0,10,0,118,0,0,1,1,0,0,10,0,117,0,0,0,1,4,118,101,99,52,95,97,100,100,0,18,95,95,
-114,101,116,86,97,108,0,59,120,121,0,0,18,118,0,0,18,117,0,0,0,0,1,90,95,0,0,10,0,2,27,1,1,0,0,10,
-0,118,0,0,1,1,0,0,10,0,117,0,0,0,1,4,118,101,99,52,95,115,117,98,116,114,97,99,116,0,18,95,95,114,
-101,116,86,97,108,0,59,120,121,0,0,18,118,0,0,18,117,0,0,0,0,1,90,95,0,0,10,0,2,21,1,1,0,0,10,0,
-118,0,0,1,1,0,0,10,0,117,0,0,0,1,4,118,101,99,52,95,109,117,108,116,105,112,108,121,0,18,95,95,114,
-101,116,86,97,108,0,59,120,121,0,0,18,118,0,0,18,117,0,0,0,0,1,90,95,0,0,10,0,2,22,1,1,0,0,10,0,
-118,0,0,1,1,0,0,10,0,117,0,0,0,1,3,2,90,95,0,0,10,0,1,119,0,0,0,4,102,108,111,97,116,95,114,99,112,
-0,18,119,0,59,120,0,0,18,117,0,59,120,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,119,0,59,121,0,
-0,18,117,0,59,121,0,0,0,4,118,101,99,52,95,109,117,108,116,105,112,108,121,0,18,95,95,114,101,116,
-86,97,108,0,59,120,121,0,0,18,118,0,0,18,119,0,0,0,0,1,90,95,0,0,11,0,2,26,1,1,0,0,11,0,118,0,0,1,
-1,0,0,11,0,117,0,0,0,1,4,118,101,99,52,95,97,100,100,0,18,95,95,114,101,116,86,97,108,0,59,120,121,
-122,0,0,18,118,0,0,18,117,0,0,0,0,1,90,95,0,0,11,0,2,27,1,1,0,0,11,0,118,0,0,1,1,0,0,11,0,117,0,0,
-0,1,4,118,101,99,52,95,115,117,98,116,114,97,99,116,0,18,95,95,114,101,116,86,97,108,0,59,120,121,
-122,0,0,18,118,0,0,18,117,0,0,0,0,1,90,95,0,0,11,0,2,21,1,1,0,0,11,0,118,0,0,1,1,0,0,11,0,117,0,0,
-0,1,4,118,101,99,52,95,109,117,108,116,105,112,108,121,0,18,95,95,114,101,116,86,97,108,0,59,120,
-121,122,0,0,18,118,0,0,18,117,0,0,0,0,1,90,95,0,0,11,0,2,22,1,1,0,0,11,0,118,0,0,1,1,0,0,11,0,117,
-0,0,0,1,3,2,90,95,0,0,11,0,1,119,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,119,0,59,120,0,0,18,
-117,0,59,120,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,119,0,59,121,0,0,18,117,0,59,121,0,0,0,
-4,102,108,111,97,116,95,114,99,112,0,18,119,0,59,122,0,0,18,117,0,59,122,0,0,0,4,118,101,99,52,95,
-109,117,108,116,105,112,108,121,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,118,0,0,
-18,119,0,0,0,0,1,90,95,0,0,12,0,2,26,1,1,0,0,12,0,118,0,0,1,1,0,0,12,0,117,0,0,0,1,4,118,101,99,52,
-95,97,100,100,0,18,95,95,114,101,116,86,97,108,0,0,18,118,0,0,18,117,0,0,0,0,1,90,95,0,0,12,0,2,27,
-1,1,0,0,12,0,118,0,0,1,1,0,0,12,0,117,0,0,0,1,4,118,101,99,52,95,115,117,98,116,114,97,99,116,0,18,
-95,95,114,101,116,86,97,108,0,0,18,118,0,0,18,117,0,0,0,0,1,90,95,0,0,12,0,2,21,1,1,0,0,12,0,118,0,
-0,1,1,0,0,12,0,117,0,0,0,1,4,118,101,99,52,95,109,117,108,116,105,112,108,121,0,18,95,95,114,101,
-116,86,97,108,0,0,18,118,0,0,18,117,0,0,0,0,1,90,95,0,0,12,0,2,22,1,1,0,0,12,0,118,0,0,1,1,0,0,12,
-0,117,0,0,0,1,3,2,90,95,0,0,12,0,1,119,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,119,0,59,120,
-0,0,18,117,0,59,120,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,119,0,59,121,0,0,18,117,0,59,121,
-0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,119,0,59,122,0,0,18,117,0,59,122,0,0,0,4,102,108,111,
-97,116,95,114,99,112,0,18,119,0,59,119,0,0,18,117,0,59,119,0,0,0,4,118,101,99,52,95,109,117,108,
-116,105,112,108,121,0,18,95,95,114,101,116,86,97,108,0,0,18,118,0,0,18,119,0,0,0,0,1,90,95,0,0,10,
-0,2,26,1,1,0,0,9,0,97,0,0,1,1,0,0,10,0,117,0,0,0,1,4,118,101,99,52,95,97,100,100,0,18,95,95,114,
-101,116,86,97,108,0,59,120,121,0,0,18,97,0,0,18,117,0,59,120,121,0,0,0,0,1,90,95,0,0,10,0,2,26,1,1,
-0,0,10,0,118,0,0,1,1,0,0,9,0,98,0,0,0,1,4,118,101,99,52,95,97,100,100,0,18,95,95,114,101,116,86,97,
-108,0,59,120,121,0,0,18,118,0,59,120,121,0,0,18,98,0,0,0,0,1,90,95,0,0,10,0,2,27,1,1,0,0,9,0,97,0,
-0,1,1,0,0,10,0,117,0,0,0,1,4,118,101,99,52,95,115,117,98,116,114,97,99,116,0,18,95,95,114,101,116,
-86,97,108,0,59,120,121,0,0,18,97,0,0,18,117,0,59,120,121,0,0,0,0,1,90,95,0,0,10,0,2,27,1,1,0,0,10,
-0,118,0,0,1,1,0,0,9,0,98,0,0,0,1,4,118,101,99,52,95,115,117,98,116,114,97,99,116,0,18,95,95,114,
-101,116,86,97,108,0,59,120,121,0,0,18,118,0,59,120,121,0,0,18,98,0,0,0,0,1,90,95,0,0,10,0,2,21,1,1,
-0,0,9,0,97,0,0,1,1,0,0,10,0,117,0,0,0,1,4,118,101,99,52,95,109,117,108,116,105,112,108,121,0,18,95,
-95,114,101,116,86,97,108,0,59,120,121,0,0,18,97,0,0,18,117,0,59,120,121,0,0,0,0,1,90,95,0,0,10,0,2,
-21,1,1,0,0,10,0,118,0,0,1,1,0,0,9,0,98,0,0,0,1,4,118,101,99,52,95,109,117,108,116,105,112,108,121,
-0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,118,0,59,120,121,0,0,18,98,0,0,0,0,1,90,95,0,
-0,10,0,2,22,1,1,0,0,9,0,97,0,0,1,1,0,0,10,0,117,0,0,0,1,3,2,90,95,0,0,10,0,1,105,110,118,85,0,0,0,
-4,102,108,111,97,116,95,114,99,112,0,18,105,110,118,85,0,59,120,0,0,18,117,0,59,120,0,0,0,4,102,
-108,111,97,116,95,114,99,112,0,18,105,110,118,85,0,59,121,0,0,18,117,0,59,121,0,0,0,4,118,101,99,
-52,95,109,117,108,116,105,112,108,121,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,97,0,0,
-18,105,110,118,85,0,59,120,121,0,0,0,0,1,90,95,0,0,10,0,2,22,1,1,0,0,10,0,118,0,0,1,1,0,0,9,0,98,0,
-0,0,1,3,2,90,95,0,0,9,0,1,105,110,118,66,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,105,110,118,
-66,0,0,18,98,0,0,0,4,118,101,99,52,95,109,117,108,116,105,112,108,121,0,18,95,95,114,101,116,86,97,
-108,0,59,120,121,0,0,18,118,0,59,120,121,0,0,18,105,110,118,66,0,0,0,0,1,90,95,0,0,11,0,2,26,1,1,0,
-0,9,0,97,0,0,1,1,0,0,11,0,117,0,0,0,1,4,118,101,99,52,95,97,100,100,0,18,95,95,114,101,116,86,97,
-108,0,59,120,121,122,0,0,18,97,0,0,18,117,0,59,120,121,122,0,0,0,0,1,90,95,0,0,11,0,2,26,1,1,0,0,
-11,0,118,0,0,1,1,0,0,9,0,98,0,0,0,1,4,118,101,99,52,95,97,100,100,0,18,95,95,114,101,116,86,97,108,
-0,59,120,121,122,0,0,18,118,0,59,120,121,122,0,0,18,98,0,0,0,0,1,90,95,0,0,11,0,2,27,1,1,0,0,9,0,
-97,0,0,1,1,0,0,11,0,117,0,0,0,1,4,118,101,99,52,95,115,117,98,116,114,97,99,116,0,18,95,95,114,101,
-116,86,97,108,0,59,120,121,122,0,0,18,97,0,0,18,117,0,59,120,121,122,0,0,0,0,1,90,95,0,0,11,0,2,27,
-1,1,0,0,11,0,118,0,0,1,1,0,0,9,0,98,0,0,0,1,4,118,101,99,52,95,115,117,98,116,114,97,99,116,0,18,
-95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,118,0,59,120,121,122,0,0,18,98,0,0,0,0,1,90,95,
-0,0,11,0,2,21,1,1,0,0,9,0,97,0,0,1,1,0,0,11,0,117,0,0,0,1,4,118,101,99,52,95,109,117,108,116,105,
-112,108,121,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,97,0,0,18,117,0,59,120,121,
-122,0,0,0,0,1,90,95,0,0,11,0,2,21,1,1,0,0,11,0,118,0,0,1,1,0,0,9,0,98,0,0,0,1,4,118,101,99,52,95,
-109,117,108,116,105,112,108,121,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,118,0,59,
-120,121,122,0,0,18,98,0,0,0,0,1,90,95,0,0,11,0,2,22,1,1,0,0,9,0,97,0,0,1,1,0,0,11,0,117,0,0,0,1,3,
-2,90,95,0,0,11,0,1,105,110,118,85,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,105,110,118,85,0,
-59,120,0,0,18,117,0,59,120,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,105,110,118,85,0,59,121,0,
-0,18,117,0,59,121,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,105,110,118,85,0,59,122,0,0,18,117,
-0,59,122,0,0,0,4,118,101,99,52,95,109,117,108,116,105,112,108,121,0,18,95,95,114,101,116,86,97,108,
-0,59,120,121,122,0,0,18,97,0,0,18,105,110,118,85,0,59,120,121,122,0,0,0,0,1,90,95,0,0,11,0,2,22,1,
-1,0,0,11,0,118,0,0,1,1,0,0,9,0,98,0,0,0,1,3,2,90,95,0,0,9,0,1,105,110,118,66,0,0,0,4,102,108,111,
-97,116,95,114,99,112,0,18,105,110,118,66,0,0,18,98,0,0,0,4,118,101,99,52,95,109,117,108,116,105,
-112,108,121,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,118,0,59,120,121,122,0,0,18,
-105,110,118,66,0,0,0,0,1,90,95,0,0,12,0,2,26,1,1,0,0,9,0,97,0,0,1,1,0,0,12,0,117,0,0,0,1,4,118,101,
-99,52,95,97,100,100,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,117,0,0,0,0,1,90,95,0,0,12,0,
-2,26,1,1,0,0,12,0,118,0,0,1,1,0,0,9,0,98,0,0,0,1,4,118,101,99,52,95,97,100,100,0,18,95,95,114,101,
-116,86,97,108,0,0,18,118,0,0,18,98,0,0,0,0,1,90,95,0,0,12,0,2,27,1,1,0,0,9,0,97,0,0,1,1,0,0,12,0,
-117,0,0,0,1,4,118,101,99,52,95,115,117,98,116,114,97,99,116,0,18,95,95,114,101,116,86,97,108,0,0,
-18,97,0,0,18,117,0,0,0,0,1,90,95,0,0,12,0,2,27,1,1,0,0,12,0,118,0,0,1,1,0,0,9,0,98,0,0,0,1,4,118,
-101,99,52,95,115,117,98,116,114,97,99,116,0,18,95,95,114,101,116,86,97,108,0,0,18,118,0,0,18,98,0,
-0,0,0,1,90,95,0,0,12,0,2,21,1,1,0,0,9,0,97,0,0,1,1,0,0,12,0,117,0,0,0,1,4,118,101,99,52,95,109,117,
-108,116,105,112,108,121,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,117,0,0,0,0,1,90,95,0,0,
-12,0,2,21,1,1,0,0,12,0,118,0,0,1,1,0,0,9,0,98,0,0,0,1,4,118,101,99,52,95,109,117,108,116,105,112,
-108,121,0,18,95,95,114,101,116,86,97,108,0,0,18,118,0,0,18,98,0,0,0,0,1,90,95,0,0,12,0,2,22,1,1,0,
-0,9,0,97,0,0,1,1,0,0,12,0,117,0,0,0,1,3,2,90,95,0,0,12,0,1,105,110,118,85,0,0,0,4,102,108,111,97,
-116,95,114,99,112,0,18,105,110,118,85,0,59,120,0,0,18,117,0,59,120,0,0,0,4,102,108,111,97,116,95,
-114,99,112,0,18,105,110,118,85,0,59,121,0,0,18,117,0,59,121,0,0,0,4,102,108,111,97,116,95,114,99,
-112,0,18,105,110,118,85,0,59,122,0,0,18,117,0,59,122,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,
-105,110,118,85,0,59,119,0,0,18,117,0,59,119,0,0,0,4,118,101,99,52,95,109,117,108,116,105,112,108,
-121,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,105,110,118,85,0,0,0,0,1,90,95,0,0,12,0,2,22,
-1,1,0,0,12,0,118,0,0,1,1,0,0,9,0,98,0,0,0,1,3,2,90,95,0,0,9,0,1,105,110,118,66,0,0,0,4,102,108,111,
-97,116,95,114,99,112,0,18,105,110,118,66,0,0,18,98,0,0,0,4,118,101,99,52,95,109,117,108,116,105,
-112,108,121,0,18,95,95,114,101,116,86,97,108,0,0,18,118,0,0,18,105,110,118,66,0,0,0,0,1,90,95,0,0,
-6,0,2,26,1,1,0,0,5,0,97,0,0,1,1,0,0,6,0,117,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,105,118,
-101,99,50,0,0,18,97,0,0,0,18,117,0,46,20,0,0,1,90,95,0,0,6,0,2,26,1,1,0,0,6,0,118,0,0,1,1,0,0,5,0,
-98,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,118,0,58,105,118,101,99,50,0,0,18,98,0,0,0,46,20,
-0,0,1,90,95,0,0,6,0,2,27,1,1,0,0,5,0,97,0,0,1,1,0,0,6,0,117,0,0,0,1,9,18,95,95,114,101,116,86,97,
-108,0,58,105,118,101,99,50,0,0,18,97,0,0,0,18,117,0,47,20,0,0,1,90,95,0,0,6,0,2,27,1,1,0,0,6,0,118,
-0,0,1,1,0,0,5,0,98,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,118,0,58,105,118,101,99,50,0,0,18,
-98,0,0,0,47,20,0,0,1,90,95,0,0,6,0,2,21,1,1,0,0,5,0,97,0,0,1,1,0,0,6,0,117,0,0,0,1,9,18,95,95,114,
-101,116,86,97,108,0,58,105,118,101,99,50,0,0,18,97,0,0,0,18,117,0,48,20,0,0,1,90,95,0,0,6,0,2,21,1,
-1,0,0,6,0,118,0,0,1,1,0,0,5,0,98,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,118,0,58,105,118,
-101,99,50,0,0,18,98,0,0,0,48,20,0,0,1,90,95,0,0,6,0,2,22,1,1,0,0,5,0,97,0,0,1,1,0,0,6,0,117,0,0,0,
-1,9,18,95,95,114,101,116,86,97,108,0,58,105,118,101,99,50,0,0,18,97,0,0,0,18,117,0,49,20,0,0,1,90,
-95,0,0,6,0,2,22,1,1,0,0,6,0,118,0,0,1,1,0,0,5,0,98,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,
-118,0,58,105,118,101,99,50,0,0,18,98,0,0,0,49,20,0,0,1,90,95,0,0,7,0,2,26,1,1,0,0,5,0,97,0,0,1,1,0,
-0,7,0,117,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,105,118,101,99,51,0,0,18,97,0,0,0,18,117,0,
-46,20,0,0,1,90,95,0,0,7,0,2,26,1,1,0,0,7,0,118,0,0,1,1,0,0,5,0,98,0,0,0,1,9,18,95,95,114,101,116,
-86,97,108,0,18,118,0,58,105,118,101,99,51,0,0,18,98,0,0,0,46,20,0,0,1,90,95,0,0,7,0,2,27,1,1,0,0,5,
-0,97,0,0,1,1,0,0,7,0,117,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,105,118,101,99,51,0,0,18,97,
-0,0,0,18,117,0,47,20,0,0,1,90,95,0,0,7,0,2,27,1,1,0,0,7,0,118,0,0,1,1,0,0,5,0,98,0,0,0,1,9,18,95,
-95,114,101,116,86,97,108,0,18,118,0,58,105,118,101,99,51,0,0,18,98,0,0,0,47,20,0,0,1,90,95,0,0,7,0,
-2,21,1,1,0,0,5,0,97,0,0,1,1,0,0,7,0,117,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,105,118,101,
-99,51,0,0,18,97,0,0,0,18,117,0,48,20,0,0,1,90,95,0,0,7,0,2,21,1,1,0,0,7,0,118,0,0,1,1,0,0,5,0,98,0,
-0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,118,0,58,105,118,101,99,51,0,0,18,98,0,0,0,48,20,0,0,1,
-90,95,0,0,7,0,2,22,1,1,0,0,5,0,97,0,0,1,1,0,0,7,0,117,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,
-58,105,118,101,99,51,0,0,18,97,0,0,0,18,117,0,49,20,0,0,1,90,95,0,0,7,0,2,22,1,1,0,0,7,0,118,0,0,1,
-1,0,0,5,0,98,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,118,0,58,105,118,101,99,51,0,0,18,98,0,
-0,0,49,20,0,0,1,90,95,0,0,8,0,2,26,1,1,0,0,5,0,97,0,0,1,1,0,0,8,0,117,0,0,0,1,9,18,95,95,114,101,
-116,86,97,108,0,58,105,118,101,99,52,0,0,18,97,0,0,0,18,117,0,46,20,0,0,1,90,95,0,0,8,0,2,26,1,1,0,
-0,8,0,118,0,0,1,1,0,0,5,0,98,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,118,0,58,105,118,101,99,
-52,0,0,18,98,0,0,0,46,20,0,0,1,90,95,0,0,8,0,2,27,1,1,0,0,5,0,97,0,0,1,1,0,0,8,0,117,0,0,0,1,9,18,
-95,95,114,101,116,86,97,108,0,58,105,118,101,99,52,0,0,18,97,0,0,0,18,117,0,47,20,0,0,1,90,95,0,0,
-8,0,2,27,1,1,0,0,8,0,118,0,0,1,1,0,0,5,0,98,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,118,0,58,
-105,118,101,99,52,0,0,18,98,0,0,0,47,20,0,0,1,90,95,0,0,8,0,2,21,1,1,0,0,5,0,97,0,0,1,1,0,0,8,0,
-117,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,105,118,101,99,52,0,0,18,97,0,0,0,18,117,0,48,20,
-0,0,1,90,95,0,0,8,0,2,21,1,1,0,0,8,0,118,0,0,1,1,0,0,5,0,98,0,0,0,1,9,18,95,95,114,101,116,86,97,
-108,0,18,118,0,58,105,118,101,99,52,0,0,18,98,0,0,0,48,20,0,0,1,90,95,0,0,8,0,2,22,1,1,0,0,5,0,97,
-0,0,1,1,0,0,8,0,117,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,58,105,118,101,99,52,0,0,18,97,0,0,
-0,18,117,0,49,20,0,0,1,90,95,0,0,8,0,2,22,1,1,0,0,8,0,118,0,0,1,1,0,0,5,0,98,0,0,0,1,9,18,95,95,
-114,101,116,86,97,108,0,18,118,0,58,105,118,101,99,52,0,0,18,98,0,0,0,49,20,0,0,1,90,95,0,0,5,0,2,
-27,1,1,0,0,5,0,97,0,0,0,1,4,118,101,99,52,95,110,101,103,97,116,101,0,18,95,95,114,101,116,86,97,
-108,0,59,120,0,0,18,97,0,0,0,0,1,90,95,0,0,6,0,2,27,1,1,0,0,6,0,118,0,0,0,1,4,118,101,99,52,95,110,
-101,103,97,116,101,0,18,95,95,114,101,116,86,97,108,0,0,18,118,0,0,0,0,1,90,95,0,0,7,0,2,27,1,1,0,
-0,7,0,118,0,0,0,1,4,118,101,99,52,95,110,101,103,97,116,101,0,18,95,95,114,101,116,86,97,108,0,0,
-18,118,0,0,0,0,1,90,95,0,0,8,0,2,27,1,1,0,0,8,0,118,0,0,0,1,4,118,101,99,52,95,110,101,103,97,116,
-101,0,18,95,95,114,101,116,86,97,108,0,0,18,118,0,0,0,0,1,90,95,0,0,9,0,2,27,1,1,0,0,9,0,97,0,0,0,
-1,4,118,101,99,52,95,110,101,103,97,116,101,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,97,0,
-0,0,0,1,90,95,0,0,10,0,2,27,1,1,0,0,10,0,118,0,0,0,1,4,118,101,99,52,95,110,101,103,97,116,101,0,
-18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,118,0,59,120,121,0,0,0,0,1,90,95,0,0,11,0,2,27,
-1,1,0,0,11,0,118,0,0,0,1,4,118,101,99,52,95,110,101,103,97,116,101,0,18,95,95,114,101,116,86,97,
-108,0,59,120,121,122,0,0,18,118,0,59,120,121,122,0,0,0,0,1,90,95,0,0,12,0,2,27,1,1,0,0,12,0,118,0,
-0,0,1,4,118,101,99,52,95,110,101,103,97,116,101,0,18,95,95,114,101,116,86,97,108,0,0,18,118,0,0,0,
-0,1,90,95,0,0,13,0,2,27,1,1,0,0,13,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,
-18,109,0,16,8,48,0,57,54,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,16,10,49,0,
-57,54,20,0,0,1,90,95,0,0,14,0,2,27,1,1,0,0,14,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,
-8,48,0,57,18,109,0,16,8,48,0,57,54,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,
-16,10,49,0,57,54,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,109,0,16,10,50,0,57,54,
-20,0,0,1,90,95,0,0,15,0,2,27,1,1,0,0,15,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,
-57,18,109,0,16,8,48,0,57,54,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,16,10,
-49,0,57,54,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,109,0,16,10,50,0,57,54,20,0,9,
-18,95,95,114,101,116,86,97,108,0,16,10,51,0,57,18,109,0,16,10,51,0,57,54,20,0,0,1,90,95,0,0,9,0,0,
-100,111,116,0,1,1,0,0,9,0,97,0,0,1,1,0,0,9,0,98,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,97,0,
-18,98,0,48,20,0,0,1,90,95,0,0,9,0,0,100,111,116,0,1,1,0,0,10,0,97,0,0,1,1,0,0,10,0,98,0,0,0,1,9,18,
-95,95,114,101,116,86,97,108,0,18,97,0,59,120,0,18,98,0,59,120,0,48,18,97,0,59,121,0,18,98,0,59,121,
-0,48,46,20,0,0,1,90,95,0,0,9,0,0,100,111,116,0,1,1,0,0,11,0,97,0,0,1,1,0,0,11,0,98,0,0,0,1,4,118,
-101,99,51,95,100,111,116,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,98,0,0,0,0,1,90,95,0,0,
-9,0,0,100,111,116,0,1,1,0,0,12,0,97,0,0,1,1,0,0,12,0,98,0,0,0,1,4,118,101,99,52,95,100,111,116,0,
-18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,98,0,0,0,0,1,90,95,0,0,5,0,2,1,1,0,2,0,5,0,97,0,0,
-1,1,0,0,5,0,98,0,0,0,1,9,18,97,0,18,97,0,18,98,0,46,20,0,8,18,97,0,0,0,1,90,95,0,0,5,0,2,2,1,0,2,0,
-5,0,97,0,0,1,1,0,0,5,0,98,0,0,0,1,9,18,97,0,18,97,0,18,98,0,47,20,0,8,18,97,0,0,0,1,90,95,0,0,5,0,
-2,3,1,0,2,0,5,0,97,0,0,1,1,0,0,5,0,98,0,0,0,1,9,18,97,0,18,97,0,18,98,0,48,20,0,8,18,97,0,0,0,1,90,
-95,0,0,5,0,2,4,1,0,2,0,5,0,97,0,0,1,1,0,0,5,0,98,0,0,0,1,9,18,97,0,18,97,0,18,98,0,49,20,0,8,18,97,
-0,0,0,1,90,95,0,0,6,0,2,1,1,0,2,0,6,0,118,0,0,1,1,0,0,6,0,117,0,0,0,1,9,18,118,0,18,118,0,18,117,0,
-46,20,0,8,18,118,0,0,0,1,90,95,0,0,6,0,2,2,1,0,2,0,6,0,118,0,0,1,1,0,0,6,0,117,0,0,0,1,9,18,118,0,
-18,118,0,18,117,0,47,20,0,8,18,118,0,0,0,1,90,95,0,0,6,0,2,3,1,0,2,0,6,0,118,0,0,1,1,0,0,6,0,117,0,
-0,0,1,9,18,118,0,18,118,0,18,117,0,48,20,0,8,18,118,0,0,0,1,90,95,0,0,6,0,2,4,1,0,2,0,6,0,118,0,0,
-1,1,0,0,6,0,117,0,0,0,1,9,18,118,0,18,118,0,18,117,0,49,20,0,8,18,118,0,0,0,1,90,95,0,0,7,0,2,1,1,
-0,2,0,7,0,118,0,0,1,1,0,0,7,0,117,0,0,0,1,9,18,118,0,18,118,0,18,117,0,46,20,0,8,18,118,0,0,0,1,90,
-95,0,0,7,0,2,2,1,0,2,0,7,0,118,0,0,1,1,0,0,7,0,117,0,0,0,1,9,18,118,0,18,118,0,18,117,0,47,20,0,8,
-18,118,0,0,0,1,90,95,0,0,7,0,2,3,1,0,2,0,7,0,118,0,0,1,1,0,0,7,0,117,0,0,0,1,9,18,118,0,18,118,0,
-18,117,0,48,20,0,8,18,118,0,0,0,1,90,95,0,0,7,0,2,4,1,0,2,0,7,0,118,0,0,1,1,0,0,7,0,117,0,0,0,1,9,
-18,118,0,18,118,0,18,117,0,49,20,0,8,18,118,0,0,0,1,90,95,0,0,8,0,2,1,1,0,2,0,8,0,118,0,0,1,1,0,0,
-8,0,117,0,0,0,1,9,18,118,0,18,118,0,18,117,0,46,20,0,8,18,118,0,0,0,1,90,95,0,0,8,0,2,2,1,0,2,0,8,
-0,118,0,0,1,1,0,0,8,0,117,0,0,0,1,9,18,118,0,18,118,0,18,117,0,47,20,0,8,18,118,0,0,0,1,90,95,0,0,
-8,0,2,3,1,0,2,0,8,0,118,0,0,1,1,0,0,8,0,117,0,0,0,1,9,18,118,0,18,118,0,18,117,0,48,20,0,8,18,118,
-0,0,0,1,90,95,0,0,8,0,2,4,1,0,2,0,8,0,118,0,0,1,1,0,0,8,0,117,0,0,0,1,9,18,118,0,18,118,0,18,117,0,
-49,20,0,8,18,118,0,0,0,1,90,95,0,0,9,0,2,1,1,0,2,0,9,0,97,0,0,1,1,0,0,9,0,98,0,0,0,1,9,18,97,0,18,
-97,0,18,98,0,46,20,0,8,18,97,0,0,0,1,90,95,0,0,9,0,2,2,1,0,2,0,9,0,97,0,0,1,1,0,0,9,0,98,0,0,0,1,9,
-18,97,0,18,97,0,18,98,0,47,20,0,8,18,97,0,0,0,1,90,95,0,0,9,0,2,3,1,0,2,0,9,0,97,0,0,1,1,0,0,9,0,
-98,0,0,0,1,9,18,97,0,18,97,0,18,98,0,48,20,0,8,18,97,0,0,0,1,90,95,0,0,9,0,2,4,1,0,2,0,9,0,97,0,0,
-1,1,0,0,9,0,98,0,0,0,1,9,18,97,0,18,97,0,18,98,0,49,20,0,8,18,97,0,0,0,1,90,95,0,0,10,0,2,1,1,0,2,
-0,10,0,118,0,0,1,1,0,0,10,0,117,0,0,0,1,9,18,118,0,18,118,0,18,117,0,46,20,0,8,18,118,0,0,0,1,90,
-95,0,0,10,0,2,2,1,0,2,0,10,0,118,0,0,1,1,0,0,10,0,117,0,0,0,1,9,18,118,0,18,118,0,18,117,0,47,20,0,
-8,18,118,0,0,0,1,90,95,0,0,10,0,2,3,1,0,2,0,10,0,118,0,0,1,1,0,0,10,0,117,0,0,0,1,9,18,118,0,18,
-118,0,18,117,0,48,20,0,8,18,118,0,0,0,1,90,95,0,0,10,0,2,4,1,0,2,0,10,0,118,0,0,1,1,0,0,10,0,117,0,
-0,0,1,9,18,118,0,18,118,0,18,117,0,49,20,0,8,18,118,0,0,0,1,90,95,0,0,11,0,2,1,1,0,2,0,11,0,118,0,
-0,1,1,0,0,11,0,117,0,0,0,1,9,18,118,0,18,118,0,18,117,0,46,20,0,8,18,118,0,0,0,1,90,95,0,0,11,0,2,
-2,1,0,2,0,11,0,118,0,0,1,1,0,0,11,0,117,0,0,0,1,9,18,118,0,18,118,0,18,117,0,47,20,0,8,18,118,0,0,
-0,1,90,95,0,0,11,0,2,3,1,0,2,0,11,0,118,0,0,1,1,0,0,11,0,117,0,0,0,1,9,18,118,0,18,118,0,18,117,0,
-48,20,0,8,18,118,0,0,0,1,90,95,0,0,11,0,2,4,1,0,2,0,11,0,118,0,0,1,1,0,0,11,0,117,0,0,0,1,9,18,118,
-0,18,118,0,18,117,0,49,20,0,8,18,118,0,0,0,1,90,95,0,0,12,0,2,1,1,0,2,0,12,0,118,0,0,1,1,0,0,12,0,
-117,0,0,0,1,9,18,118,0,18,118,0,18,117,0,46,20,0,8,18,118,0,0,0,1,90,95,0,0,12,0,2,2,1,0,2,0,12,0,
-118,0,0,1,1,0,0,12,0,117,0,0,0,1,9,18,118,0,18,118,0,18,117,0,47,20,0,8,18,118,0,0,0,1,90,95,0,0,
-12,0,2,3,1,0,2,0,12,0,118,0,0,1,1,0,0,12,0,117,0,0,0,1,9,18,118,0,18,118,0,18,117,0,48,20,0,8,18,
-118,0,0,0,1,90,95,0,0,12,0,2,4,1,0,2,0,12,0,118,0,0,1,1,0,0,12,0,117,0,0,0,1,9,18,118,0,18,118,0,
-18,117,0,49,20,0,8,18,118,0,0,0,1,90,95,0,0,6,0,2,1,1,0,2,0,6,0,118,0,0,1,1,0,0,5,0,97,0,0,0,1,9,
-18,118,0,18,118,0,58,105,118,101,99,50,0,0,18,97,0,0,0,46,20,0,8,18,118,0,0,0,1,90,95,0,0,6,0,2,2,
-1,0,2,0,6,0,118,0,0,1,1,0,0,5,0,97,0,0,0,1,9,18,118,0,18,118,0,58,105,118,101,99,50,0,0,18,97,0,0,
-0,47,20,0,8,18,118,0,0,0,1,90,95,0,0,6,0,2,3,1,0,2,0,6,0,118,0,0,1,1,0,0,5,0,97,0,0,0,1,9,18,118,0,
-18,118,0,58,105,118,101,99,50,0,0,18,97,0,0,0,48,20,0,8,18,118,0,0,0,1,90,95,0,0,6,0,2,4,1,0,2,0,6,
-0,118,0,0,1,1,0,0,5,0,97,0,0,0,1,9,18,118,0,18,118,0,58,105,118,101,99,50,0,0,18,97,0,0,0,49,20,0,
-8,18,118,0,0,0,1,90,95,0,0,7,0,2,1,1,0,2,0,7,0,118,0,0,1,1,0,0,5,0,97,0,0,0,1,9,18,118,0,18,118,0,
-58,105,118,101,99,51,0,0,18,97,0,0,0,46,20,0,8,18,118,0,0,0,1,90,95,0,0,7,0,2,2,1,0,2,0,7,0,118,0,
-0,1,1,0,0,5,0,97,0,0,0,1,9,18,118,0,18,118,0,58,105,118,101,99,51,0,0,18,97,0,0,0,47,20,0,8,18,118,
-0,0,0,1,90,95,0,0,7,0,2,3,1,0,2,0,7,0,118,0,0,1,1,0,0,5,0,97,0,0,0,1,9,18,118,0,18,118,0,58,105,
-118,101,99,51,0,0,18,97,0,0,0,48,20,0,8,18,118,0,0,0,1,90,95,0,0,8,0,2,4,1,0,2,0,7,0,118,0,0,1,1,0,
-0,5,0,97,0,0,0,1,9,18,118,0,18,118,0,58,105,118,101,99,51,0,0,18,97,0,0,0,49,20,0,8,18,118,0,0,0,1,
-90,95,0,0,8,0,2,1,1,0,2,0,8,0,118,0,0,1,1,0,0,5,0,97,0,0,0,1,9,18,118,0,18,118,0,58,105,118,101,99,
-52,0,0,18,97,0,0,0,46,20,0,8,18,118,0,0,0,1,90,95,0,0,8,0,2,2,1,0,2,0,8,0,118,0,0,1,1,0,0,5,0,97,0,
-0,0,1,9,18,118,0,18,118,0,58,105,118,101,99,52,0,0,18,97,0,0,0,47,20,0,8,18,118,0,0,0,1,90,95,0,0,
-8,0,2,3,1,0,2,0,8,0,118,0,0,1,1,0,0,5,0,97,0,0,0,1,9,18,118,0,18,118,0,58,105,118,101,99,52,0,0,18,
-97,0,0,0,48,20,0,8,18,118,0,0,0,1,90,95,0,0,8,0,2,4,1,0,2,0,8,0,118,0,0,1,1,0,0,5,0,97,0,0,0,1,9,
-18,118,0,18,118,0,58,105,118,101,99,52,0,0,18,97,0,0,0,49,20,0,8,18,118,0,0,0,1,90,95,0,0,10,0,2,1,
-1,0,2,0,10,0,118,0,0,1,1,0,0,9,0,97,0,0,0,1,9,18,118,0,18,118,0,58,118,101,99,50,0,0,18,97,0,0,0,
-46,20,0,8,18,118,0,0,0,1,90,95,0,0,10,0,2,2,1,0,2,0,10,0,118,0,0,1,1,0,0,9,0,97,0,0,0,1,9,18,118,0,
-18,118,0,58,118,101,99,50,0,0,18,97,0,0,0,47,20,0,8,18,118,0,0,0,1,90,95,0,0,10,0,2,3,1,0,2,0,10,0,
-118,0,0,1,1,0,0,9,0,97,0,0,0,1,9,18,118,0,18,118,0,58,118,101,99,50,0,0,18,97,0,0,0,48,20,0,8,18,
-118,0,0,0,1,90,95,0,0,10,0,2,4,1,0,2,0,10,0,118,0,0,1,1,0,0,9,0,97,0,0,0,1,9,18,118,0,18,118,0,58,
-118,101,99,50,0,0,18,97,0,0,0,49,20,0,8,18,118,0,0,0,1,90,95,0,0,11,0,2,1,1,0,2,0,11,0,118,0,0,1,1,
-0,0,9,0,97,0,0,0,1,9,18,118,0,18,118,0,58,118,101,99,51,0,0,18,97,0,0,0,46,20,0,8,18,118,0,0,0,1,
-90,95,0,0,11,0,2,2,1,0,2,0,11,0,118,0,0,1,1,0,0,9,0,97,0,0,0,1,9,18,118,0,18,118,0,58,118,101,99,
-51,0,0,18,97,0,0,0,47,20,0,8,18,118,0,0,0,1,90,95,0,0,11,0,2,3,1,0,2,0,11,0,118,0,0,1,1,0,0,9,0,97,
-0,0,0,1,9,18,118,0,18,118,0,58,118,101,99,51,0,0,18,97,0,0,0,48,20,0,8,18,118,0,0,0,1,90,95,0,0,11,
-0,2,4,1,0,2,0,11,0,118,0,0,1,1,0,0,9,0,97,0,0,0,1,9,18,118,0,18,118,0,58,118,101,99,51,0,0,18,97,0,
-0,0,49,20,0,8,18,118,0,0,0,1,90,95,0,0,12,0,2,1,1,0,2,0,12,0,118,0,0,1,1,0,0,9,0,97,0,0,0,1,9,18,
-118,0,18,118,0,58,118,101,99,52,0,0,18,97,0,0,0,46,20,0,8,18,118,0,0,0,1,90,95,0,0,12,0,2,2,1,0,2,
-0,12,0,118,0,0,1,1,0,0,9,0,97,0,0,0,1,9,18,118,0,18,118,0,58,118,101,99,52,0,0,18,97,0,0,0,47,20,0,
-8,18,118,0,0,0,1,90,95,0,0,12,0,2,3,1,0,2,0,12,0,118,0,0,1,1,0,0,9,0,97,0,0,0,1,9,18,118,0,18,118,
-0,58,118,101,99,52,0,0,18,97,0,0,0,48,20,0,8,18,118,0,0,0,1,90,95,0,0,12,0,2,4,1,0,2,0,12,0,118,0,
-0,1,1,0,0,9,0,97,0,0,0,1,9,18,118,0,18,118,0,58,118,101,99,52,0,0,18,97,0,0,0,49,20,0,8,18,118,0,0,
-0,1,90,95,0,0,13,0,2,26,1,1,0,0,13,0,109,0,0,1,1,0,0,13,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,
-108,0,16,8,48,0,57,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,46,20,0,9,18,95,95,114,101,116,86,
-97,108,0,16,10,49,0,57,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,46,20,0,0,1,90,95,0,0,13,0,2,
-27,1,1,0,0,13,0,109,0,0,1,1,0,0,13,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,
-18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,47,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,
-57,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,47,20,0,0,1,90,95,0,0,13,0,2,21,1,1,0,0,13,0,109,
-0,0,1,1,0,0,13,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,16,8,48,0,57,
-18,110,0,16,8,48,0,57,59,120,120,0,48,18,109,0,16,10,49,0,57,18,110,0,16,8,48,0,57,59,121,121,0,48,
-46,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,16,8,48,0,57,18,110,0,16,10,49,0,
-57,59,120,120,0,48,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,59,121,121,0,48,46,20,0,0,1,90,95,
-0,0,13,0,2,22,1,1,0,0,13,0,109,0,0,1,1,0,0,13,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,
-8,48,0,57,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,49,20,0,9,18,95,95,114,101,116,86,97,108,0,
-16,10,49,0,57,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,49,20,0,0,1,90,95,0,0,14,0,2,26,1,1,0,
-0,14,0,109,0,0,1,1,0,0,14,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,
-16,8,48,0,57,18,110,0,16,8,48,0,57,46,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,109,
-0,16,10,49,0,57,18,110,0,16,10,49,0,57,46,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,
-109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,46,20,0,0,1,90,95,0,0,14,0,2,27,1,1,0,0,14,0,109,0,0,1,
-1,0,0,14,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,16,8,48,0,57,18,
-110,0,16,8,48,0,57,47,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,16,10,49,0,57,
-18,110,0,16,10,49,0,57,47,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,109,0,16,10,50,
-0,57,18,110,0,16,10,50,0,57,47,20,0,0,1,90,95,0,0,14,0,2,21,1,1,0,0,14,0,109,0,0,1,1,0,0,14,0,110,
-0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,
-57,59,120,120,120,0,48,18,109,0,16,10,49,0,57,18,110,0,16,8,48,0,57,59,121,121,121,0,48,46,18,109,
-0,16,10,50,0,57,18,110,0,16,8,48,0,57,59,122,122,122,0,48,46,20,0,9,18,95,95,114,101,116,86,97,108,
-0,16,10,49,0,57,18,109,0,16,8,48,0,57,18,110,0,16,10,49,0,57,59,120,120,120,0,48,18,109,0,16,10,49,
-0,57,18,110,0,16,10,49,0,57,59,121,121,121,0,48,46,18,109,0,16,10,50,0,57,18,110,0,16,10,49,0,57,
-59,122,122,122,0,48,46,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,109,0,16,8,48,0,57,
-18,110,0,16,10,50,0,57,59,120,120,120,0,48,18,109,0,16,10,49,0,57,18,110,0,16,10,50,0,57,59,121,
-121,121,0,48,46,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,59,122,122,122,0,48,46,20,0,0,1,90,
-95,0,0,14,0,2,22,1,1,0,0,14,0,109,0,0,1,1,0,0,14,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,
-16,8,48,0,57,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,49,20,0,9,18,95,95,114,101,116,86,97,108,
-0,16,10,49,0,57,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,49,20,0,9,18,95,95,114,101,116,86,97,
-108,0,16,10,50,0,57,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,49,20,0,0,1,90,95,0,0,15,0,2,26,
-1,1,0,0,15,0,109,0,0,1,1,0,0,15,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,
-109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,46,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,
-18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,46,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,
-0,57,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,46,20,0,9,18,95,95,114,101,116,86,97,108,0,16,
-10,51,0,57,18,109,0,16,10,51,0,57,18,110,0,16,10,51,0,57,46,20,0,0,1,90,95,0,0,15,0,2,27,1,1,0,0,
-15,0,109,0,0,1,1,0,0,15,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,16,
-8,48,0,57,18,110,0,16,8,48,0,57,47,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,
-16,10,49,0,57,18,110,0,16,10,49,0,57,47,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,
-109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,47,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,51,0,
-57,18,109,0,16,10,51,0,57,18,110,0,16,10,51,0,57,47,20,0,0,1,90,95,0,0,15,0,2,21,1,1,0,0,15,0,109,
-0,0,1,1,0,0,15,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,16,8,48,0,57,
-18,110,0,16,8,48,0,57,59,120,120,120,120,0,48,18,109,0,16,10,49,0,57,18,110,0,16,8,48,0,57,59,121,
-121,121,121,0,48,46,18,109,0,16,10,50,0,57,18,110,0,16,8,48,0,57,59,122,122,122,122,0,48,46,18,109,
-0,16,10,51,0,57,18,110,0,16,8,48,0,57,59,119,119,119,119,0,48,46,20,0,9,18,95,95,114,101,116,86,97,
-108,0,16,10,49,0,57,18,109,0,16,8,48,0,57,18,110,0,16,10,49,0,57,59,120,120,120,120,0,48,18,109,0,
-16,10,49,0,57,18,110,0,16,10,49,0,57,59,121,121,121,121,0,48,46,18,109,0,16,10,50,0,57,18,110,0,16,
-10,49,0,57,59,122,122,122,122,0,48,46,18,109,0,16,10,51,0,57,18,110,0,16,10,49,0,57,59,119,119,119,
-119,0,48,46,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,109,0,16,8,48,0,57,18,110,0,
-16,10,50,0,57,59,120,120,120,120,0,48,18,109,0,16,10,49,0,57,18,110,0,16,10,50,0,57,59,121,121,121,
-121,0,48,46,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,59,122,122,122,122,0,48,46,18,109,0,16,
-10,51,0,57,18,110,0,16,10,50,0,57,59,119,119,119,119,0,48,46,20,0,9,18,95,95,114,101,116,86,97,108,
-0,16,10,51,0,57,18,109,0,16,8,48,0,57,18,110,0,16,10,51,0,57,59,120,120,120,120,0,48,18,109,0,16,
-10,49,0,57,18,110,0,16,10,51,0,57,59,121,121,121,121,0,48,46,18,109,0,16,10,50,0,57,18,110,0,16,10,
-51,0,57,59,122,122,122,122,0,48,46,18,109,0,16,10,51,0,57,18,110,0,16,10,51,0,57,59,119,119,119,
-119,0,48,46,20,0,0,1,90,95,0,0,15,0,2,22,1,1,0,0,15,0,109,0,0,1,1,0,0,15,0,110,0,0,0,1,9,18,95,95,
-114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,49,20,0,9,18,95,
-95,114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,49,20,0,9,
-18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,49,20,
-0,9,18,95,95,114,101,116,86,97,108,0,16,10,51,0,57,18,109,0,16,10,51,0,57,18,110,0,16,10,51,0,57,
-49,20,0,0,1,90,95,0,0,13,0,2,26,1,1,0,0,9,0,97,0,0,1,1,0,0,13,0,110,0,0,0,1,9,18,95,95,114,101,116,
-86,97,108,0,16,8,48,0,57,18,97,0,18,110,0,16,8,48,0,57,46,20,0,9,18,95,95,114,101,116,86,97,108,0,
-16,10,49,0,57,18,97,0,18,110,0,16,10,49,0,57,46,20,0,0,1,90,95,0,0,13,0,2,26,1,1,0,0,13,0,109,0,0,
-1,1,0,0,9,0,98,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,16,8,48,0,57,18,98,
-0,46,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,16,10,49,0,57,18,98,0,46,20,0,
-0,1,90,95,0,0,13,0,2,27,1,1,0,0,9,0,97,0,0,1,1,0,0,13,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,
-108,0,16,8,48,0,57,18,97,0,18,110,0,16,8,48,0,57,47,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,
-49,0,57,18,97,0,18,110,0,16,10,49,0,57,47,20,0,0,1,90,95,0,0,13,0,2,27,1,1,0,0,13,0,109,0,0,1,1,0,
-0,9,0,98,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,16,8,48,0,57,18,98,0,47,
-20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,16,10,49,0,57,18,98,0,47,20,0,0,1,
-90,95,0,0,13,0,2,21,1,1,0,0,9,0,97,0,0,1,1,0,0,13,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,
-16,8,48,0,57,18,97,0,18,110,0,16,8,48,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,
-57,18,97,0,18,110,0,16,10,49,0,57,48,20,0,0,1,90,95,0,0,13,0,2,21,1,1,0,0,13,0,109,0,0,1,1,0,0,9,0,
-98,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,16,8,48,0,57,18,98,0,48,20,0,9,
-18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,16,10,49,0,57,18,98,0,48,20,0,0,1,90,95,0,
-0,13,0,2,22,1,1,0,0,9,0,97,0,0,1,1,0,0,13,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,
-0,57,18,97,0,18,110,0,16,8,48,0,57,49,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,97,
-0,18,110,0,16,10,49,0,57,49,20,0,0,1,90,95,0,0,13,0,2,22,1,1,0,0,13,0,109,0,0,1,1,0,0,9,0,98,0,0,0,
-1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,16,8,48,0,57,18,98,0,49,20,0,9,18,95,95,
-114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,16,10,49,0,57,18,98,0,49,20,0,0,1,90,95,0,0,14,0,2,
-26,1,1,0,0,9,0,97,0,0,1,1,0,0,14,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,
-97,0,18,110,0,16,8,48,0,57,46,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,97,0,18,110,
-0,16,10,49,0,57,46,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,97,0,18,110,0,16,10,50,
-0,57,46,20,0,0,1,90,95,0,0,14,0,2,26,1,1,0,0,14,0,109,0,0,1,1,0,0,9,0,98,0,0,0,1,9,18,95,95,114,
-101,116,86,97,108,0,16,8,48,0,57,18,109,0,16,8,48,0,57,18,98,0,46,20,0,9,18,95,95,114,101,116,86,
-97,108,0,16,10,49,0,57,18,109,0,16,10,49,0,57,18,98,0,46,20,0,9,18,95,95,114,101,116,86,97,108,0,
-16,10,50,0,57,18,109,0,16,10,50,0,57,18,98,0,46,20,0,0,1,90,95,0,0,14,0,2,27,1,1,0,0,9,0,97,0,0,1,
-1,0,0,14,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,97,0,18,110,0,16,8,48,0,
-57,47,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,97,0,18,110,0,16,10,49,0,57,47,20,0,
-9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,97,0,18,110,0,16,10,50,0,57,47,20,0,0,1,90,95,
-0,0,14,0,2,27,1,1,0,0,14,0,109,0,0,1,1,0,0,9,0,98,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,
-48,0,57,18,109,0,16,8,48,0,57,18,98,0,47,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,
-109,0,16,10,49,0,57,18,98,0,47,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,109,0,16,
-10,50,0,57,18,98,0,47,20,0,0,1,90,95,0,0,14,0,2,21,1,1,0,0,9,0,97,0,0,1,1,0,0,14,0,110,0,0,0,1,9,
-18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,97,0,18,110,0,16,8,48,0,57,48,20,0,9,18,95,95,114,
-101,116,86,97,108,0,16,10,49,0,57,18,97,0,18,110,0,16,10,49,0,57,48,20,0,9,18,95,95,114,101,116,86,
-97,108,0,16,10,50,0,57,18,97,0,18,110,0,16,10,50,0,57,48,20,0,0,1,90,95,0,0,14,0,2,21,1,1,0,0,14,0,
-109,0,0,1,1,0,0,9,0,98,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,16,8,48,0,
-57,18,98,0,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,16,10,49,0,57,18,98,0,
-48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,109,0,16,10,50,0,57,18,98,0,48,20,0,0,
-1,90,95,0,0,14,0,2,22,1,1,0,0,9,0,97,0,0,1,1,0,0,14,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,108,
-0,16,8,48,0,57,18,97,0,18,110,0,16,8,48,0,57,49,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,
-57,18,97,0,18,110,0,16,10,49,0,57,49,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,97,0,
-18,110,0,16,10,50,0,57,49,20,0,0,1,90,95,0,0,14,0,2,22,1,1,0,0,14,0,109,0,0,1,1,0,0,9,0,98,0,0,0,1,
-9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,16,8,48,0,57,18,98,0,49,20,0,9,18,95,95,
-114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,16,10,49,0,57,18,98,0,49,20,0,9,18,95,95,114,101,
-116,86,97,108,0,16,10,50,0,57,18,109,0,16,10,50,0,57,18,98,0,49,20,0,0,1,90,95,0,0,15,0,2,26,1,1,0,
-0,9,0,97,0,0,1,1,0,0,15,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,97,0,18,
-110,0,16,8,48,0,57,46,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,97,0,18,110,0,16,10,
-49,0,57,46,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,97,0,18,110,0,16,10,50,0,57,46,
-20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,51,0,57,18,97,0,18,110,0,16,10,51,0,57,46,20,0,0,1,
-90,95,0,0,15,0,2,26,1,1,0,0,15,0,109,0,0,1,1,0,0,9,0,98,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,
-16,8,48,0,57,18,109,0,16,8,48,0,57,18,98,0,46,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,
-57,18,109,0,16,10,49,0,57,18,98,0,46,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,109,
-0,16,10,50,0,57,18,98,0,46,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,51,0,57,18,109,0,16,10,51,
-0,57,18,98,0,46,20,0,0,1,90,95,0,0,15,0,2,27,1,1,0,0,9,0,97,0,0,1,1,0,0,15,0,110,0,0,0,1,9,18,95,
-95,114,101,116,86,97,108,0,16,8,48,0,57,18,97,0,18,110,0,16,8,48,0,57,47,20,0,9,18,95,95,114,101,
-116,86,97,108,0,16,10,49,0,57,18,97,0,18,110,0,16,10,49,0,57,47,20,0,9,18,95,95,114,101,116,86,97,
-108,0,16,10,50,0,57,18,97,0,18,110,0,16,10,50,0,57,47,20,0,9,18,95,95,114,101,116,86,97,108,0,16,
-10,51,0,57,18,97,0,18,110,0,16,10,51,0,57,47,20,0,0,1,90,95,0,0,15,0,2,27,1,1,0,0,15,0,109,0,0,1,1,
-0,0,9,0,98,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,16,8,48,0,57,18,98,0,
-47,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,16,10,49,0,57,18,98,0,47,20,0,9,
-18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,109,0,16,10,50,0,57,18,98,0,47,20,0,9,18,95,95,
-114,101,116,86,97,108,0,16,10,51,0,57,18,109,0,16,10,51,0,57,18,98,0,47,20,0,0,1,90,95,0,0,15,0,2,
-21,1,1,0,0,9,0,97,0,0,1,1,0,0,15,0,110,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,
-97,0,18,110,0,16,8,48,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,97,0,18,110,
-0,16,10,49,0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,97,0,18,110,0,16,10,50,
-0,57,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,51,0,57,18,97,0,18,110,0,16,10,51,0,57,48,20,
-0,0,1,90,95,0,0,15,0,2,21,1,1,0,0,15,0,109,0,0,1,1,0,0,9,0,98,0,0,0,1,9,18,95,95,114,101,116,86,97,
-108,0,16,8,48,0,57,18,109,0,16,8,48,0,57,18,98,0,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,
-49,0,57,18,109,0,16,10,49,0,57,18,98,0,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,
-109,0,16,10,50,0,57,18,98,0,48,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,51,0,57,18,109,0,16,
-10,51,0,57,18,98,0,48,20,0,0,1,90,95,0,0,15,0,2,22,1,1,0,0,9,0,97,0,0,1,1,0,0,15,0,110,0,0,0,1,9,
-18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,97,0,18,110,0,16,8,48,0,57,49,20,0,9,18,95,95,114,
-101,116,86,97,108,0,16,10,49,0,57,18,97,0,18,110,0,16,10,49,0,57,49,20,0,9,18,95,95,114,101,116,86,
-97,108,0,16,10,50,0,57,18,97,0,18,110,0,16,10,50,0,57,49,20,0,9,18,95,95,114,101,116,86,97,108,0,
-16,10,51,0,57,18,97,0,18,110,0,16,10,51,0,57,49,20,0,0,1,90,95,0,0,15,0,2,22,1,1,0,0,15,0,109,0,0,
-1,1,0,0,9,0,98,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,16,8,48,0,57,18,109,0,16,8,48,0,57,18,98,
-0,49,20,0,9,18,95,95,114,101,116,86,97,108,0,16,10,49,0,57,18,109,0,16,10,49,0,57,18,98,0,49,20,0,
-9,18,95,95,114,101,116,86,97,108,0,16,10,50,0,57,18,109,0,16,10,50,0,57,18,98,0,49,20,0,9,18,95,95,
-114,101,116,86,97,108,0,16,10,51,0,57,18,109,0,16,10,51,0,57,18,98,0,49,20,0,0,1,90,95,0,0,10,0,2,
-21,1,1,0,0,13,0,109,0,0,1,1,0,0,10,0,118,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,109,0,16,8,
-48,0,57,18,118,0,59,120,120,0,48,18,109,0,16,10,49,0,57,18,118,0,59,121,121,0,48,46,20,0,0,1,90,95,
-0,0,10,0,2,21,1,1,0,0,10,0,118,0,0,1,1,0,0,13,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,
-120,0,58,100,111,116,0,0,18,118,0,0,18,109,0,16,8,48,0,57,0,0,20,0,9,18,95,95,114,101,116,86,97,
-108,0,59,121,0,58,100,111,116,0,0,18,118,0,0,18,109,0,16,10,49,0,57,0,0,20,0,0,1,90,95,0,0,11,0,2,
-21,1,1,0,0,14,0,109,0,0,1,1,0,0,11,0,118,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,109,0,16,8,
-48,0,57,18,118,0,59,120,120,120,0,48,18,109,0,16,10,49,0,57,18,118,0,59,121,121,121,0,48,46,18,109,
-0,16,10,50,0,57,18,118,0,59,122,122,122,0,48,46,20,0,0,1,90,95,0,0,11,0,2,21,1,1,0,0,11,0,118,0,0,
-1,1,0,0,14,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,58,100,111,116,0,0,18,118,0,0,
-18,109,0,16,8,48,0,57,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,58,100,111,116,0,0,18,
-118,0,0,18,109,0,16,10,49,0,57,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,58,100,111,116,
-0,0,18,118,0,0,18,109,0,16,10,50,0,57,0,0,20,0,0,1,90,95,0,0,12,0,2,21,1,1,0,0,15,0,109,0,0,1,1,0,
-0,12,0,118,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,109,0,16,8,48,0,57,18,118,0,59,120,120,
-120,120,0,48,18,109,0,16,10,49,0,57,18,118,0,59,121,121,121,121,0,48,46,18,109,0,16,10,50,0,57,18,
-118,0,59,122,122,122,122,0,48,46,18,109,0,16,10,51,0,57,18,118,0,59,119,119,119,119,0,48,46,20,0,0,
-1,90,95,0,0,12,0,2,21,1,1,0,0,12,0,118,0,0,1,1,0,0,15,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,
-108,0,59,120,0,58,100,111,116,0,0,18,118,0,0,18,109,0,16,8,48,0,57,0,0,20,0,9,18,95,95,114,101,116,
-86,97,108,0,59,121,0,58,100,111,116,0,0,18,118,0,0,18,109,0,16,10,49,0,57,0,0,20,0,9,18,95,95,114,
-101,116,86,97,108,0,59,122,0,58,100,111,116,0,0,18,118,0,0,18,109,0,16,10,50,0,57,0,0,20,0,9,18,95,
-95,114,101,116,86,97,108,0,59,119,0,58,100,111,116,0,0,18,118,0,0,18,109,0,16,10,51,0,57,0,0,20,0,
-0,1,90,95,0,0,13,0,2,1,1,0,2,0,13,0,109,0,0,1,1,0,0,13,0,110,0,0,0,1,9,18,109,0,16,8,48,0,57,18,
-109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,46,20,0,9,18,109,0,16,10,49,0,57,18,109,0,16,10,49,0,57,
-18,110,0,16,10,49,0,57,46,20,0,8,18,109,0,0,0,1,90,95,0,0,13,0,2,2,1,0,2,0,13,0,109,0,0,1,1,0,0,13,
-0,110,0,0,0,1,9,18,109,0,16,8,48,0,57,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,47,20,0,9,18,109,
-0,16,10,49,0,57,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,47,20,0,8,18,109,0,0,0,1,90,95,0,0,
-13,0,2,3,1,0,2,0,13,0,109,0,0,1,1,0,0,13,0,110,0,0,0,1,9,18,109,0,18,109,0,18,110,0,48,20,0,8,18,
-109,0,0,0,1,90,95,0,0,13,0,2,4,1,0,2,0,13,0,109,0,0,1,1,0,0,13,0,110,0,0,0,1,9,18,109,0,16,8,48,0,
-57,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,49,20,0,9,18,109,0,16,10,49,0,57,18,109,0,16,10,49,
-0,57,18,110,0,16,10,49,0,57,49,20,0,8,18,109,0,0,0,1,90,95,0,0,14,0,2,1,1,0,2,0,14,0,109,0,0,1,1,0,
-0,14,0,110,0,0,0,1,9,18,109,0,16,8,48,0,57,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,46,20,0,9,
-18,109,0,16,10,49,0,57,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,46,20,0,9,18,109,0,16,10,50,0,
-57,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,46,20,0,8,18,109,0,0,0,1,90,95,0,0,14,0,2,2,1,0,2,
-0,14,0,109,0,0,1,1,0,0,14,0,110,0,0,0,1,9,18,109,0,16,8,48,0,57,18,109,0,16,8,48,0,57,18,110,0,16,
-8,48,0,57,47,20,0,9,18,109,0,16,10,49,0,57,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,47,20,0,9,
-18,109,0,16,10,50,0,57,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,47,20,0,8,18,109,0,0,0,1,90,
-95,0,0,14,0,2,3,1,0,2,0,14,0,109,0,0,1,1,0,0,14,0,110,0,0,0,1,9,18,109,0,18,109,0,18,110,0,48,20,0,
-8,18,109,0,0,0,1,90,95,0,0,14,0,2,4,1,0,2,0,14,0,109,0,0,1,1,0,0,14,0,110,0,0,0,1,9,18,109,0,16,8,
-48,0,57,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,49,20,0,9,18,109,0,16,10,49,0,57,18,109,0,16,
-10,49,0,57,18,110,0,16,10,49,0,57,49,20,0,9,18,109,0,16,10,50,0,57,18,109,0,16,10,50,0,57,18,110,0,
-16,10,50,0,57,49,20,0,8,18,109,0,0,0,1,90,95,0,0,15,0,2,1,1,0,2,0,15,0,109,0,0,1,1,0,0,15,0,110,0,
-0,0,1,9,18,109,0,16,8,48,0,57,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,46,20,0,9,18,109,0,16,10,
-49,0,57,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,46,20,0,9,18,109,0,16,10,50,0,57,18,109,0,16,
-10,50,0,57,18,110,0,16,10,50,0,57,46,20,0,9,18,109,0,16,10,51,0,57,18,109,0,16,10,51,0,57,18,110,0,
-16,10,51,0,57,46,20,0,8,18,109,0,0,0,1,90,95,0,0,15,0,2,2,1,0,2,0,15,0,109,0,0,1,1,0,0,15,0,110,0,
-0,0,1,9,18,109,0,16,8,48,0,57,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,47,20,0,9,18,109,0,16,10,
-49,0,57,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,47,20,0,9,18,109,0,16,10,50,0,57,18,109,0,16,
-10,50,0,57,18,110,0,16,10,50,0,57,47,20,0,9,18,109,0,16,10,51,0,57,18,109,0,16,10,51,0,57,18,110,0,
-16,10,51,0,57,47,20,0,8,18,109,0,0,0,1,90,95,0,0,15,0,2,3,1,0,2,0,15,0,109,0,0,1,1,0,0,15,0,110,0,
-0,0,1,9,18,109,0,18,109,0,18,110,0,48,20,0,8,18,109,0,0,0,1,90,95,0,0,15,0,2,4,1,0,2,0,15,0,109,0,
-0,1,1,0,0,15,0,110,0,0,0,1,9,18,109,0,16,8,48,0,57,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,49,
-20,0,9,18,109,0,16,10,49,0,57,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,49,20,0,9,18,109,0,16,
-10,50,0,57,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,49,20,0,9,18,109,0,16,10,51,0,57,18,109,0,
-16,10,51,0,57,18,110,0,16,10,51,0,57,49,20,0,8,18,109,0,0,0,1,90,95,0,0,13,0,2,1,1,0,2,0,13,0,109,
-0,0,1,1,0,0,9,0,97,0,0,0,1,3,2,90,95,0,0,10,0,1,118,0,2,58,118,101,99,50,0,0,18,97,0,0,0,0,0,9,18,
-109,0,16,8,48,0,57,18,109,0,16,8,48,0,57,18,118,0,46,20,0,9,18,109,0,16,10,49,0,57,18,109,0,16,10,
-49,0,57,18,118,0,46,20,0,8,18,109,0,0,0,1,90,95,0,0,13,0,2,2,1,0,2,0,13,0,109,0,0,1,1,0,0,9,0,97,0,
-0,0,1,3,2,90,95,0,0,10,0,1,118,0,2,58,118,101,99,50,0,0,18,97,0,0,0,0,0,9,18,109,0,16,8,48,0,57,18,
-109,0,16,8,48,0,57,18,118,0,47,20,0,9,18,109,0,16,10,49,0,57,18,109,0,16,10,49,0,57,18,118,0,47,20,
-0,8,18,109,0,0,0,1,90,95,0,0,13,0,2,3,1,0,2,0,13,0,109,0,0,1,1,0,0,9,0,97,0,0,0,1,3,2,90,95,0,0,10,
-0,1,118,0,2,58,118,101,99,50,0,0,18,97,0,0,0,0,0,9,18,109,0,16,8,48,0,57,18,109,0,16,8,48,0,57,18,
-118,0,48,20,0,9,18,109,0,16,10,49,0,57,18,109,0,16,10,49,0,57,18,118,0,48,20,0,8,18,109,0,0,0,1,90,
-95,0,0,13,0,2,4,1,0,2,0,13,0,109,0,0,1,1,0,0,9,0,97,0,0,0,1,3,2,90,95,0,0,10,0,1,118,0,2,58,118,
-101,99,50,0,0,17,49,0,48,0,0,18,97,0,49,0,0,0,0,9,18,109,0,16,8,48,0,57,18,109,0,16,8,48,0,57,18,
-118,0,48,20,0,9,18,109,0,16,10,49,0,57,18,109,0,16,10,49,0,57,18,118,0,48,20,0,8,18,109,0,0,0,1,90,
-95,0,0,14,0,2,1,1,0,2,0,14,0,109,0,0,1,1,0,0,9,0,97,0,0,0,1,3,2,90,95,0,0,11,0,1,118,0,2,58,118,
-101,99,51,0,0,18,97,0,0,0,0,0,9,18,109,0,16,8,48,0,57,18,109,0,16,8,48,0,57,18,118,0,46,20,0,9,18,
-109,0,16,10,49,0,57,18,109,0,16,10,49,0,57,18,118,0,46,20,0,9,18,109,0,16,10,50,0,57,18,109,0,16,
-10,50,0,57,18,118,0,46,20,0,8,18,109,0,0,0,1,90,95,0,0,14,0,2,2,1,0,2,0,14,0,109,0,0,1,1,0,0,9,0,
-97,0,0,0,1,3,2,90,95,0,0,11,0,1,118,0,2,58,118,101,99,51,0,0,18,97,0,0,0,0,0,9,18,109,0,16,8,48,0,
-57,18,109,0,16,8,48,0,57,18,118,0,47,20,0,9,18,109,0,16,10,49,0,57,18,109,0,16,10,49,0,57,18,118,0,
-47,20,0,9,18,109,0,16,10,50,0,57,18,109,0,16,10,50,0,57,18,118,0,47,20,0,8,18,109,0,0,0,1,90,95,0,
-0,14,0,2,3,1,0,2,0,14,0,109,0,0,1,1,0,0,9,0,97,0,0,0,1,3,2,90,95,0,0,11,0,1,118,0,2,58,118,101,99,
-51,0,0,18,97,0,0,0,0,0,9,18,109,0,16,8,48,0,57,18,109,0,16,8,48,0,57,18,118,0,48,20,0,9,18,109,0,
-16,10,49,0,57,18,109,0,16,10,49,0,57,18,118,0,48,20,0,9,18,109,0,16,10,50,0,57,18,109,0,16,10,50,0,
-57,18,118,0,48,20,0,8,18,109,0,0,0,1,90,95,0,0,14,0,2,4,1,0,2,0,14,0,109,0,0,1,1,0,0,9,0,97,0,0,0,
-1,3,2,90,95,0,0,11,0,1,118,0,2,58,118,101,99,51,0,0,17,49,0,48,0,0,18,97,0,49,0,0,0,0,9,18,109,0,
-16,8,48,0,57,18,109,0,16,8,48,0,57,18,118,0,48,20,0,9,18,109,0,16,10,49,0,57,18,109,0,16,10,49,0,
-57,18,118,0,48,20,0,9,18,109,0,16,10,50,0,57,18,109,0,16,10,50,0,57,18,118,0,48,20,0,8,18,109,0,0,
-0,1,90,95,0,0,15,0,2,1,1,0,2,0,15,0,109,0,0,1,1,0,0,9,0,97,0,0,0,1,3,2,90,95,0,0,12,0,1,118,0,2,58,
-118,101,99,52,0,0,18,97,0,0,0,0,0,9,18,109,0,16,8,48,0,57,18,109,0,16,8,48,0,57,18,118,0,46,20,0,9,
-18,109,0,16,10,49,0,57,18,109,0,16,10,49,0,57,18,118,0,46,20,0,9,18,109,0,16,10,50,0,57,18,109,0,
-16,10,50,0,57,18,118,0,46,20,0,9,18,109,0,16,10,51,0,57,18,109,0,16,10,51,0,57,18,118,0,46,20,0,8,
-18,109,0,0,0,1,90,95,0,0,15,0,2,2,1,0,2,0,15,0,109,0,0,1,1,0,0,9,0,97,0,0,0,1,3,2,90,95,0,0,12,0,1,
-118,0,2,58,118,101,99,52,0,0,18,97,0,0,0,0,0,9,18,109,0,16,8,48,0,57,18,109,0,16,8,48,0,57,18,118,
-0,47,20,0,9,18,109,0,16,10,49,0,57,18,109,0,16,10,49,0,57,18,118,0,47,20,0,9,18,109,0,16,10,50,0,
-57,18,109,0,16,10,50,0,57,18,118,0,47,20,0,9,18,109,0,16,10,51,0,57,18,109,0,16,10,51,0,57,18,118,
-0,47,20,0,8,18,109,0,0,0,1,90,95,0,0,15,0,2,3,1,0,2,0,15,0,109,0,0,1,1,0,0,9,0,97,0,0,0,1,3,2,90,
-95,0,0,12,0,1,118,0,2,58,118,101,99,52,0,0,18,97,0,0,0,0,0,9,18,109,0,16,8,48,0,57,18,109,0,16,8,
-48,0,57,18,118,0,48,20,0,9,18,109,0,16,10,49,0,57,18,109,0,16,10,49,0,57,18,118,0,48,20,0,9,18,109,
-0,16,10,50,0,57,18,109,0,16,10,50,0,57,18,118,0,48,20,0,9,18,109,0,16,10,51,0,57,18,109,0,16,10,51,
-0,57,18,118,0,48,20,0,8,18,109,0,0,0,1,90,95,0,0,15,0,2,4,1,0,2,0,15,0,109,0,0,1,1,0,0,9,0,97,0,0,
-0,1,3,2,90,95,0,0,12,0,1,118,0,2,58,118,101,99,52,0,0,17,49,0,48,0,0,18,97,0,49,0,0,0,0,9,18,109,0,
-16,8,48,0,57,18,109,0,16,8,48,0,57,18,118,0,48,20,0,9,18,109,0,16,10,49,0,57,18,109,0,16,10,49,0,
-57,18,118,0,48,20,0,9,18,109,0,16,10,50,0,57,18,109,0,16,10,50,0,57,18,118,0,48,20,0,9,18,109,0,16,
-10,51,0,57,18,109,0,16,10,51,0,57,18,118,0,48,20,0,8,18,109,0,0,0,1,90,95,0,0,10,0,2,3,1,0,2,0,10,
-0,118,0,0,1,1,0,0,13,0,109,0,0,0,1,9,18,118,0,18,118,0,18,109,0,48,20,0,8,18,118,0,0,0,1,90,95,0,0,
-11,0,2,3,1,0,2,0,11,0,118,0,0,1,1,0,0,14,0,109,0,0,0,1,9,18,118,0,18,118,0,18,109,0,48,20,0,8,18,
-118,0,0,0,1,90,95,0,0,12,0,2,3,1,0,2,0,12,0,118,0,0,1,1,0,0,15,0,109,0,0,0,1,9,18,118,0,18,118,0,
-18,109,0,48,20,0,8,18,118,0,0,0,1,90,95,0,0,5,0,2,25,1,0,2,0,5,0,97,0,0,0,1,9,18,97,0,18,97,0,16,
-10,49,0,47,20,0,9,18,95,95,114,101,116,86,97,108,0,18,97,0,20,0,0,1,90,95,0,0,6,0,2,25,1,0,2,0,6,0,
-118,0,0,0,1,9,18,118,0,18,118,0,58,105,118,101,99,50,0,0,16,10,49,0,0,0,47,20,0,9,18,95,95,114,101,
-116,86,97,108,0,18,118,0,20,0,0,1,90,95,0,0,7,0,2,25,1,0,2,0,7,0,118,0,0,0,1,9,18,118,0,18,118,0,
-58,105,118,101,99,51,0,0,16,10,49,0,0,0,47,20,0,9,18,95,95,114,101,116,86,97,108,0,18,118,0,20,0,0,
-1,90,95,0,0,8,0,2,25,1,0,2,0,8,0,118,0,0,0,1,9,18,118,0,18,118,0,58,105,118,101,99,52,0,0,16,10,49,
-0,0,0,47,20,0,9,18,95,95,114,101,116,86,97,108,0,18,118,0,20,0,0,1,90,95,0,0,9,0,2,25,1,0,2,0,9,0,
-97,0,0,0,1,9,18,97,0,18,97,0,17,49,0,48,0,0,47,20,0,9,18,95,95,114,101,116,86,97,108,0,18,97,0,20,
-0,0,1,90,95,0,0,10,0,2,25,1,0,2,0,10,0,118,0,0,0,1,9,18,118,0,18,118,0,58,118,101,99,50,0,0,17,49,
-0,48,0,0,0,0,47,20,0,9,18,95,95,114,101,116,86,97,108,0,18,118,0,20,0,0,1,90,95,0,0,11,0,2,25,1,0,
-2,0,11,0,118,0,0,0,1,9,18,118,0,18,118,0,58,118,101,99,51,0,0,17,49,0,48,0,0,0,0,47,20,0,9,18,95,
-95,114,101,116,86,97,108,0,18,118,0,20,0,0,1,90,95,0,0,12,0,2,25,1,0,2,0,12,0,118,0,0,0,1,9,18,118,
-0,18,118,0,58,118,101,99,52,0,0,17,49,0,48,0,0,0,0,47,20,0,9,18,95,95,114,101,116,86,97,108,0,18,
-118,0,20,0,0,1,90,95,0,0,13,0,2,25,1,0,2,0,13,0,109,0,0,0,1,9,18,109,0,16,8,48,0,57,18,109,0,16,8,
-48,0,57,58,118,101,99,50,0,0,17,49,0,48,0,0,0,0,47,20,0,9,18,109,0,16,10,49,0,57,18,109,0,16,10,49,
-0,57,58,118,101,99,50,0,0,17,49,0,48,0,0,0,0,47,20,0,9,18,95,95,114,101,116,86,97,108,0,18,109,0,
-20,0,0,1,90,95,0,0,14,0,2,25,1,0,2,0,14,0,109,0,0,0,1,9,18,109,0,16,8,48,0,57,18,109,0,16,8,48,0,
-57,58,118,101,99,51,0,0,17,49,0,48,0,0,0,0,47,20,0,9,18,109,0,16,10,49,0,57,18,109,0,16,10,49,0,57,
-58,118,101,99,51,0,0,17,49,0,48,0,0,0,0,47,20,0,9,18,109,0,16,10,50,0,57,18,109,0,16,10,50,0,57,58,
-118,101,99,51,0,0,17,49,0,48,0,0,0,0,47,20,0,9,18,95,95,114,101,116,86,97,108,0,18,109,0,20,0,0,1,
-90,95,0,0,15,0,2,25,1,0,2,0,15,0,109,0,0,0,1,9,18,109,0,16,8,48,0,57,18,109,0,16,8,48,0,57,58,118,
-101,99,52,0,0,17,49,0,48,0,0,0,0,47,20,0,9,18,109,0,16,10,49,0,57,18,109,0,16,10,49,0,57,58,118,
-101,99,52,0,0,17,49,0,48,0,0,0,0,47,20,0,9,18,109,0,16,10,50,0,57,18,109,0,16,10,50,0,57,58,118,
-101,99,52,0,0,17,49,0,48,0,0,0,0,47,20,0,9,18,109,0,16,10,51,0,57,18,109,0,16,10,51,0,57,58,118,
-101,99,52,0,0,17,49,0,48,0,0,0,0,47,20,0,9,18,95,95,114,101,116,86,97,108,0,18,109,0,20,0,0,1,90,
-95,0,0,5,0,2,24,1,0,2,0,5,0,97,0,0,0,1,9,18,97,0,18,97,0,16,10,49,0,46,20,0,9,18,95,95,114,101,116,
-86,97,108,0,18,97,0,20,0,0,1,90,95,0,0,6,0,2,24,1,0,2,0,6,0,118,0,0,0,1,9,18,118,0,18,118,0,58,105,
-118,101,99,50,0,0,16,10,49,0,0,0,46,20,0,9,18,95,95,114,101,116,86,97,108,0,18,118,0,20,0,0,1,90,
-95,0,0,7,0,2,24,1,0,2,0,7,0,118,0,0,0,1,9,18,118,0,18,118,0,58,105,118,101,99,51,0,0,16,10,49,0,0,
-0,46,20,0,9,18,95,95,114,101,116,86,97,108,0,18,118,0,20,0,0,1,90,95,0,0,8,0,2,24,1,0,2,0,8,0,118,
-0,0,0,1,9,18,118,0,18,118,0,58,105,118,101,99,52,0,0,16,10,49,0,0,0,46,20,0,9,18,95,95,114,101,116,
-86,97,108,0,18,118,0,20,0,0,1,90,95,0,0,9,0,2,24,1,0,2,0,9,0,97,0,0,0,1,9,18,97,0,18,97,0,17,49,0,
-48,0,0,46,20,0,9,18,95,95,114,101,116,86,97,108,0,18,97,0,20,0,0,1,90,95,0,0,10,0,2,24,1,0,2,0,10,
-0,118,0,0,0,1,9,18,118,0,18,118,0,58,118,101,99,50,0,0,17,49,0,48,0,0,0,0,46,20,0,9,18,95,95,114,
-101,116,86,97,108,0,18,118,0,20,0,0,1,90,95,0,0,11,0,2,24,1,0,2,0,11,0,118,0,0,0,1,9,18,118,0,18,
-118,0,58,118,101,99,51,0,0,17,49,0,48,0,0,0,0,46,20,0,9,18,95,95,114,101,116,86,97,108,0,18,118,0,
-20,0,0,1,90,95,0,0,12,0,2,24,1,0,2,0,12,0,118,0,0,0,1,9,18,118,0,18,118,0,58,118,101,99,52,0,0,17,
-49,0,48,0,0,0,0,46,20,0,9,18,95,95,114,101,116,86,97,108,0,18,118,0,20,0,0,1,90,95,0,0,13,0,2,24,1,
-0,2,0,13,0,109,0,0,0,1,9,18,109,0,16,8,48,0,57,18,109,0,16,8,48,0,57,58,118,101,99,50,0,0,17,49,0,
-48,0,0,0,0,46,20,0,9,18,109,0,16,10,49,0,57,18,109,0,16,10,49,0,57,58,118,101,99,50,0,0,17,49,0,48,
-0,0,0,0,46,20,0,9,18,95,95,114,101,116,86,97,108,0,18,109,0,20,0,0,1,90,95,0,0,14,0,2,24,1,0,2,0,
-14,0,109,0,0,0,1,9,18,109,0,16,8,48,0,57,18,109,0,16,8,48,0,57,58,118,101,99,51,0,0,17,49,0,48,0,0,
-0,0,46,20,0,9,18,109,0,16,10,49,0,57,18,109,0,16,10,49,0,57,58,118,101,99,51,0,0,17,49,0,48,0,0,0,
-0,46,20,0,9,18,109,0,16,10,50,0,57,18,109,0,16,10,50,0,57,58,118,101,99,51,0,0,17,49,0,48,0,0,0,0,
-46,20,0,9,18,95,95,114,101,116,86,97,108,0,18,109,0,20,0,0,1,90,95,0,0,15,0,2,24,1,0,2,0,15,0,109,
-0,0,0,1,9,18,109,0,16,8,48,0,57,18,109,0,16,8,48,0,57,58,118,101,99,52,0,0,17,49,0,48,0,0,0,0,46,
-20,0,9,18,109,0,16,10,49,0,57,18,109,0,16,10,49,0,57,58,118,101,99,52,0,0,17,49,0,48,0,0,0,0,46,20,
-0,9,18,109,0,16,10,50,0,57,18,109,0,16,10,50,0,57,58,118,101,99,52,0,0,17,49,0,48,0,0,0,0,46,20,0,
-9,18,109,0,16,10,51,0,57,18,109,0,16,10,51,0,57,58,118,101,99,52,0,0,17,49,0,48,0,0,0,0,46,20,0,9,
-18,95,95,114,101,116,86,97,108,0,18,109,0,20,0,0,1,90,95,0,0,5,0,0,95,95,112,111,115,116,68,101,99,
-114,0,1,0,2,0,5,0,97,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,97,0,20,0,9,18,97,0,18,97,0,16,
-10,49,0,47,20,0,0,1,90,95,0,0,6,0,0,95,95,112,111,115,116,68,101,99,114,0,1,0,2,0,6,0,118,0,0,0,1,
-9,18,95,95,114,101,116,86,97,108,0,18,118,0,20,0,9,18,118,0,18,118,0,58,105,118,101,99,50,0,0,16,
-10,49,0,0,0,47,20,0,0,1,90,95,0,0,7,0,0,95,95,112,111,115,116,68,101,99,114,0,1,0,2,0,7,0,118,0,0,
-0,1,9,18,95,95,114,101,116,86,97,108,0,18,118,0,20,0,9,18,118,0,18,118,0,58,105,118,101,99,51,0,0,
-16,10,49,0,0,0,47,20,0,0,1,90,95,0,0,8,0,0,95,95,112,111,115,116,68,101,99,114,0,1,0,2,0,8,0,118,0,
-0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,118,0,20,0,9,18,118,0,18,118,0,58,105,118,101,99,52,0,
-0,16,10,49,0,0,0,47,20,0,0,1,90,95,0,0,9,0,0,95,95,112,111,115,116,68,101,99,114,0,1,0,2,0,9,0,97,
-0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,97,0,20,0,9,18,97,0,18,97,0,17,49,0,48,0,0,47,20,0,0,
-1,90,95,0,0,10,0,0,95,95,112,111,115,116,68,101,99,114,0,1,0,2,0,10,0,118,0,0,0,1,9,18,95,95,114,
-101,116,86,97,108,0,18,118,0,20,0,9,18,118,0,18,118,0,58,118,101,99,50,0,0,17,49,0,48,0,0,0,0,47,
-20,0,0,1,90,95,0,0,11,0,0,95,95,112,111,115,116,68,101,99,114,0,1,0,2,0,11,0,118,0,0,0,1,9,18,95,
-95,114,101,116,86,97,108,0,18,118,0,20,0,9,18,118,0,18,118,0,58,118,101,99,51,0,0,17,49,0,48,0,0,0,
-0,47,20,0,0,1,90,95,0,0,12,0,0,95,95,112,111,115,116,68,101,99,114,0,1,0,2,0,12,0,118,0,0,0,1,9,18,
-95,95,114,101,116,86,97,108,0,18,118,0,20,0,9,18,118,0,18,118,0,58,118,101,99,52,0,0,17,49,0,48,0,
-0,0,0,47,20,0,0,1,90,95,0,0,13,0,0,95,95,112,111,115,116,68,101,99,114,0,1,0,2,0,13,0,109,0,0,0,1,
-9,18,95,95,114,101,116,86,97,108,0,18,109,0,20,0,9,18,109,0,16,8,48,0,57,18,109,0,16,8,48,0,57,58,
-118,101,99,50,0,0,17,49,0,48,0,0,0,0,47,20,0,9,18,109,0,16,10,49,0,57,18,109,0,16,10,49,0,57,58,
-118,101,99,50,0,0,17,49,0,48,0,0,0,0,47,20,0,0,1,90,95,0,0,14,0,0,95,95,112,111,115,116,68,101,99,
-114,0,1,0,2,0,14,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,109,0,20,0,9,18,109,0,16,8,48,
-0,57,18,109,0,16,8,48,0,57,58,118,101,99,51,0,0,17,49,0,48,0,0,0,0,47,20,0,9,18,109,0,16,10,49,0,
-57,18,109,0,16,10,49,0,57,58,118,101,99,51,0,0,17,49,0,48,0,0,0,0,47,20,0,9,18,109,0,16,10,50,0,57,
-18,109,0,16,10,50,0,57,58,118,101,99,51,0,0,17,49,0,48,0,0,0,0,47,20,0,0,1,90,95,0,0,15,0,0,95,95,
-112,111,115,116,68,101,99,114,0,1,0,2,0,15,0,109,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,109,
-0,20,0,9,18,109,0,16,8,48,0,57,18,109,0,16,8,48,0,57,58,118,101,99,52,0,0,17,49,0,48,0,0,0,0,47,20,
-0,9,18,109,0,16,10,49,0,57,18,109,0,16,10,49,0,57,58,118,101,99,52,0,0,17,49,0,48,0,0,0,0,47,20,0,
-9,18,109,0,16,10,50,0,57,18,109,0,16,10,50,0,57,58,118,101,99,52,0,0,17,49,0,48,0,0,0,0,47,20,0,9,
-18,109,0,16,10,51,0,57,18,109,0,16,10,51,0,57,58,118,101,99,52,0,0,17,49,0,48,0,0,0,0,47,20,0,0,1,
-90,95,0,0,9,0,0,95,95,112,111,115,116,73,110,99,114,0,1,0,2,0,9,0,97,0,0,0,1,9,18,95,95,114,101,
-116,86,97,108,0,18,97,0,20,0,9,18,97,0,18,97,0,16,10,49,0,46,20,0,0,1,90,95,0,0,10,0,0,95,95,112,
-111,115,116,73,110,99,114,0,1,0,2,0,10,0,118,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,118,0,
-20,0,9,18,118,0,18,118,0,58,118,101,99,50,0,0,17,49,0,48,0,0,0,0,46,20,0,0,1,90,95,0,0,11,0,0,95,
-95,112,111,115,116,73,110,99,114,0,1,0,2,0,11,0,118,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,
-118,0,20,0,9,18,118,0,18,118,0,58,118,101,99,51,0,0,17,49,0,48,0,0,0,0,46,20,0,0,1,90,95,0,0,12,0,
-0,95,95,112,111,115,116,73,110,99,114,0,1,0,2,0,12,0,118,0,0,0,1,9,18,95,95,114,101,116,86,97,108,
-0,18,118,0,20,0,9,18,118,0,18,118,0,58,118,101,99,52,0,0,17,49,0,48,0,0,0,0,46,20,0,0,1,90,95,0,0,
-5,0,0,95,95,112,111,115,116,73,110,99,114,0,1,0,2,0,5,0,97,0,0,0,1,9,18,95,95,114,101,116,86,97,
-108,0,18,97,0,20,0,9,18,97,0,18,97,0,16,10,49,0,46,20,0,0,1,90,95,0,0,6,0,0,95,95,112,111,115,116,
-73,110,99,114,0,1,0,2,0,6,0,118,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,118,0,20,0,9,18,118,
-0,18,118,0,58,105,118,101,99,50,0,0,16,10,49,0,0,0,46,20,0,0,1,90,95,0,0,7,0,0,95,95,112,111,115,
-116,73,110,99,114,0,1,0,2,0,7,0,118,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,118,0,20,0,9,18,
-118,0,18,118,0,58,105,118,101,99,51,0,0,16,10,49,0,0,0,46,20,0,0,1,90,95,0,0,8,0,0,95,95,112,111,
-115,116,73,110,99,114,0,1,0,2,0,8,0,118,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,118,0,20,0,9,
-18,118,0,18,118,0,58,105,118,101,99,51,0,0,16,10,49,0,0,0,46,20,0,0,1,90,95,0,0,13,0,0,95,95,112,
-111,115,116,73,110,99,114,0,1,0,2,0,13,0,109,0,0,0,1,3,2,90,95,0,0,13,0,1,110,0,2,18,109,0,0,0,9,
-18,109,0,16,8,48,0,57,18,109,0,16,8,48,0,57,58,118,101,99,50,0,0,17,49,0,48,0,0,0,0,46,20,0,9,18,
-109,0,16,10,49,0,57,18,109,0,16,10,49,0,57,58,118,101,99,50,0,0,17,49,0,48,0,0,0,0,46,20,0,8,18,
-110,0,0,0,1,90,95,0,0,14,0,0,95,95,112,111,115,116,73,110,99,114,0,1,0,2,0,14,0,109,0,0,0,1,3,2,90,
-95,0,0,14,0,1,110,0,2,18,109,0,0,0,9,18,109,0,16,8,48,0,57,18,109,0,16,8,48,0,57,58,118,101,99,51,
-0,0,17,49,0,48,0,0,0,0,46,20,0,9,18,109,0,16,10,49,0,57,18,109,0,16,10,49,0,57,58,118,101,99,51,0,
-0,17,49,0,48,0,0,0,0,46,20,0,9,18,109,0,16,10,50,0,57,18,109,0,16,10,50,0,57,58,118,101,99,51,0,0,
-17,49,0,48,0,0,0,0,46,20,0,8,18,110,0,0,0,1,90,95,0,0,15,0,0,95,95,112,111,115,116,73,110,99,114,0,
-1,0,2,0,15,0,109,0,0,0,1,3,2,90,95,0,0,15,0,1,110,0,2,18,109,0,0,0,9,18,109,0,16,8,48,0,57,18,109,
-0,16,8,48,0,57,58,118,101,99,52,0,0,17,49,0,48,0,0,0,0,46,20,0,9,18,109,0,16,10,49,0,57,18,109,0,
-16,10,49,0,57,58,118,101,99,52,0,0,17,49,0,48,0,0,0,0,46,20,0,9,18,109,0,16,10,50,0,57,18,109,0,16,
-10,50,0,57,58,118,101,99,52,0,0,17,49,0,48,0,0,0,0,46,20,0,9,18,109,0,16,10,51,0,57,18,109,0,16,10,
-51,0,57,58,118,101,99,52,0,0,17,49,0,48,0,0,0,0,46,20,0,8,18,110,0,0,0,1,90,95,0,0,1,0,2,15,1,1,0,
-0,9,0,97,0,0,1,1,0,0,9,0,98,0,0,0,1,4,118,101,99,52,95,115,103,116,0,18,95,95,114,101,116,86,97,
-108,0,59,120,0,0,18,98,0,0,18,97,0,0,0,0,1,90,95,0,0,1,0,2,15,1,1,0,0,5,0,97,0,0,1,1,0,0,5,0,98,0,
-0,0,1,8,58,102,108,111,97,116,0,0,18,97,0,0,0,58,102,108,111,97,116,0,0,18,98,0,0,0,40,0,0,1,90,95,
-0,0,1,0,2,16,1,1,0,0,9,0,97,0,0,1,1,0,0,9,0,98,0,0,0,1,3,2,90,95,0,0,1,0,1,99,0,0,0,4,102,108,111,
-97,116,95,108,101,115,115,0,18,99,0,0,18,98,0,0,18,97,0,0,0,8,18,99,0,0,0,1,90,95,0,0,1,0,2,16,1,1,
-0,0,5,0,97,0,0,1,1,0,0,5,0,98,0,0,0,1,8,58,102,108,111,97,116,0,0,18,97,0,0,0,58,102,108,111,97,
-116,0,0,18,98,0,0,0,41,0,0,1,90,95,0,0,1,0,2,18,1,1,0,0,9,0,97,0,0,1,1,0,0,9,0,98,0,0,0,1,3,2,90,
-95,0,0,1,0,1,103,0,0,1,1,101,0,0,0,4,102,108,111,97,116,95,108,101,115,115,0,18,103,0,0,18,98,0,0,
-18,97,0,0,0,4,102,108,111,97,116,95,101,113,117,97,108,0,18,101,0,0,18,97,0,0,18,98,0,0,0,8,18,103,
-0,18,101,0,32,0,0,1,90,95,0,0,1,0,2,18,1,1,0,0,5,0,97,0,0,1,1,0,0,5,0,98,0,0,0,1,8,58,102,108,111,
-97,116,0,0,18,97,0,0,0,58,102,108,111,97,116,0,0,18,98,0,0,0,43,0,0,1,90,95,0,0,1,0,2,17,1,1,0,0,9,
-0,97,0,0,1,1,0,0,9,0,98,0,0,0,1,3,2,90,95,0,0,1,0,1,103,0,0,1,1,101,0,0,0,4,102,108,111,97,116,95,
-108,101,115,115,0,18,103,0,0,18,97,0,0,18,98,0,0,0,4,102,108,111,97,116,95,101,113,117,97,108,0,18,
-101,0,0,18,97,0,0,18,98,0,0,0,8,18,103,0,18,101,0,32,0,0,1,90,95,0,0,1,0,2,17,1,1,0,0,5,0,97,0,0,1,
-1,0,0,5,0,98,0,0,0,1,8,58,102,108,111,97,116,0,0,18,97,0,0,0,58,102,108,111,97,116,0,0,18,98,0,0,0,
-42,0,0,1,90,95,0,0,0,0,0,112,114,105,110,116,77,69,83,65,0,1,1,0,0,9,0,102,0,0,0,1,4,102,108,111,
-97,116,95,112,114,105,110,116,0,18,102,0,0,0,0,1,90,95,0,0,0,0,0,112,114,105,110,116,77,69,83,65,0,
-1,1,0,0,5,0,105,0,0,0,1,4,105,110,116,95,112,114,105,110,116,0,18,105,0,0,0,0,1,90,95,0,0,0,0,0,
-112,114,105,110,116,77,69,83,65,0,1,1,0,0,1,0,98,0,0,0,1,4,98,111,111,108,95,112,114,105,110,116,0,
-18,98,0,0,0,0,1,90,95,0,0,0,0,0,112,114,105,110,116,77,69,83,65,0,1,1,0,0,10,0,118,0,0,0,1,9,58,
-112,114,105,110,116,77,69,83,65,0,0,18,118,0,59,120,0,0,0,0,9,58,112,114,105,110,116,77,69,83,65,0,
-0,18,118,0,59,121,0,0,0,0,0,1,90,95,0,0,0,0,0,112,114,105,110,116,77,69,83,65,0,1,1,0,0,11,0,118,0,
-0,0,1,9,58,112,114,105,110,116,77,69,83,65,0,0,18,118,0,59,120,0,0,0,0,9,58,112,114,105,110,116,77,
-69,83,65,0,0,18,118,0,59,121,0,0,0,0,9,58,112,114,105,110,116,77,69,83,65,0,0,18,118,0,59,122,0,0,
-0,0,0,1,90,95,0,0,0,0,0,112,114,105,110,116,77,69,83,65,0,1,1,0,0,12,0,118,0,0,0,1,9,58,112,114,
-105,110,116,77,69,83,65,0,0,18,118,0,59,120,0,0,0,0,9,58,112,114,105,110,116,77,69,83,65,0,0,18,
-118,0,59,121,0,0,0,0,9,58,112,114,105,110,116,77,69,83,65,0,0,18,118,0,59,122,0,0,0,0,9,58,112,114,
-105,110,116,77,69,83,65,0,0,18,118,0,59,119,0,0,0,0,0,1,90,95,0,0,0,0,0,112,114,105,110,116,77,69,
-83,65,0,1,1,0,0,6,0,118,0,0,0,1,9,58,112,114,105,110,116,77,69,83,65,0,0,18,118,0,59,120,0,0,0,0,9,
-58,112,114,105,110,116,77,69,83,65,0,0,18,118,0,59,121,0,0,0,0,0,1,90,95,0,0,0,0,0,112,114,105,110,
-116,77,69,83,65,0,1,1,0,0,7,0,118,0,0,0,1,9,58,112,114,105,110,116,77,69,83,65,0,0,18,118,0,59,120,
-0,0,0,0,9,58,112,114,105,110,116,77,69,83,65,0,0,18,118,0,59,121,0,0,0,0,9,58,112,114,105,110,116,
-77,69,83,65,0,0,18,118,0,59,122,0,0,0,0,0,1,90,95,0,0,0,0,0,112,114,105,110,116,77,69,83,65,0,1,1,
-0,0,8,0,118,0,0,0,1,9,58,112,114,105,110,116,77,69,83,65,0,0,18,118,0,59,120,0,0,0,0,9,58,112,114,
-105,110,116,77,69,83,65,0,0,18,118,0,59,121,0,0,0,0,9,58,112,114,105,110,116,77,69,83,65,0,0,18,
-118,0,59,122,0,0,0,0,9,58,112,114,105,110,116,77,69,83,65,0,0,18,118,0,59,119,0,0,0,0,0,1,90,95,0,
-0,0,0,0,112,114,105,110,116,77,69,83,65,0,1,1,0,0,2,0,118,0,0,0,1,9,58,112,114,105,110,116,77,69,
-83,65,0,0,18,118,0,59,120,0,0,0,0,9,58,112,114,105,110,116,77,69,83,65,0,0,18,118,0,59,121,0,0,0,0,
-0,1,90,95,0,0,0,0,0,112,114,105,110,116,77,69,83,65,0,1,1,0,0,3,0,118,0,0,0,1,9,58,112,114,105,110,
-116,77,69,83,65,0,0,18,118,0,59,120,0,0,0,0,9,58,112,114,105,110,116,77,69,83,65,0,0,18,118,0,59,
-121,0,0,0,0,9,58,112,114,105,110,116,77,69,83,65,0,0,18,118,0,59,122,0,0,0,0,0,1,90,95,0,0,0,0,0,
-112,114,105,110,116,77,69,83,65,0,1,1,0,0,4,0,118,0,0,0,1,9,58,112,114,105,110,116,77,69,83,65,0,0,
-18,118,0,59,120,0,0,0,0,9,58,112,114,105,110,116,77,69,83,65,0,0,18,118,0,59,121,0,0,0,0,9,58,112,
-114,105,110,116,77,69,83,65,0,0,18,118,0,59,122,0,0,0,0,9,58,112,114,105,110,116,77,69,83,65,0,0,
-18,118,0,59,119,0,0,0,0,0,1,90,95,0,0,0,0,0,112,114,105,110,116,77,69,83,65,0,1,1,0,0,13,0,109,0,0,
-0,1,9,58,112,114,105,110,116,77,69,83,65,0,0,18,109,0,16,8,48,0,57,0,0,0,9,58,112,114,105,110,116,
-77,69,83,65,0,0,18,109,0,16,10,49,0,57,0,0,0,0,1,90,95,0,0,0,0,0,112,114,105,110,116,77,69,83,65,0,
-1,1,0,0,14,0,109,0,0,0,1,9,58,112,114,105,110,116,77,69,83,65,0,0,18,109,0,16,8,48,0,57,0,0,0,9,58,
-112,114,105,110,116,77,69,83,65,0,0,18,109,0,16,10,49,0,57,0,0,0,9,58,112,114,105,110,116,77,69,83,
-65,0,0,18,109,0,16,10,50,0,57,0,0,0,0,1,90,95,0,0,0,0,0,112,114,105,110,116,77,69,83,65,0,1,1,0,0,
-15,0,109,0,0,0,1,9,58,112,114,105,110,116,77,69,83,65,0,0,18,109,0,16,8,48,0,57,0,0,0,9,58,112,114,
-105,110,116,77,69,83,65,0,0,18,109,0,16,10,49,0,57,0,0,0,9,58,112,114,105,110,116,77,69,83,65,0,0,
-18,109,0,16,10,50,0,57,0,0,0,9,58,112,114,105,110,116,77,69,83,65,0,0,18,109,0,16,10,51,0,57,0,0,0,
-0,1,90,95,0,0,0,0,0,112,114,105,110,116,77,69,83,65,0,1,1,0,0,16,0,101,0,0,0,1,4,105,110,116,95,
-112,114,105,110,116,0,18,101,0,0,0,0,1,90,95,0,0,0,0,0,112,114,105,110,116,77,69,83,65,0,1,1,0,0,
-17,0,101,0,0,0,1,4,105,110,116,95,112,114,105,110,116,0,18,101,0,0,0,0,1,90,95,0,0,0,0,0,112,114,
-105,110,116,77,69,83,65,0,1,1,0,0,18,0,101,0,0,0,1,4,105,110,116,95,112,114,105,110,116,0,18,101,0,
-0,0,0,1,90,95,0,0,0,0,0,112,114,105,110,116,77,69,83,65,0,1,1,0,0,19,0,101,0,0,0,1,4,105,110,116,
-95,112,114,105,110,116,0,18,101,0,0,0,0,1,90,95,0,0,0,0,0,112,114,105,110,116,77,69,83,65,0,1,1,0,
-0,20,0,101,0,0,0,1,4,105,110,116,95,112,114,105,110,116,0,18,101,0,0,0,0,1,90,95,0,0,0,0,0,112,114,
-105,110,116,77,69,83,65,0,1,1,0,0,21,0,101,0,0,0,1,4,105,110,116,95,112,114,105,110,116,0,18,101,0,
-0,0,0,0
diff --git a/src/mesa/shader/slang/library/slang_fragment_builtin_gc.h b/src/mesa/shader/slang/library/slang_fragment_builtin_gc.h
deleted file mode 100644 (file)
index c5a1cce..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-
-/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED FROM THE FOLLOWING FILE: */
-/* slang_fragment_builtin.gc */
-
-5,2,2,90,95,6,0,12,0,1,103,108,95,70,114,97,103,67,111,111,114,100,0,0,0,2,2,90,95,6,0,1,0,1,103,
-108,95,70,114,111,110,116,70,97,99,105,110,103,0,0,0,2,2,90,95,5,0,12,0,1,103,108,95,70,114,97,103,
-67,111,108,111,114,0,0,0,2,2,90,95,5,0,12,0,1,103,108,95,70,114,97,103,68,97,116,97,0,3,18,103,108,
-95,77,97,120,68,114,97,119,66,117,102,102,101,114,115,0,0,0,2,2,90,95,5,0,9,0,1,103,108,95,70,114,
-97,103,68,101,112,116,104,0,0,0,2,2,90,95,3,0,12,0,1,103,108,95,67,111,108,111,114,0,0,0,2,2,90,95,
-3,0,12,0,1,103,108,95,83,101,99,111,110,100,97,114,121,67,111,108,111,114,0,0,0,2,2,90,95,3,0,12,0,
-1,103,108,95,84,101,120,67,111,111,114,100,0,3,18,103,108,95,77,97,120,84,101,120,116,117,114,101,
-67,111,111,114,100,115,0,0,0,2,2,90,95,3,0,9,0,1,103,108,95,70,111,103,70,114,97,103,67,111,111,
-114,100,0,0,0,1,90,95,0,0,12,0,0,116,101,120,116,117,114,101,49,68,0,1,1,0,0,16,0,115,97,109,112,
-108,101,114,0,0,1,1,0,0,9,0,99,111,111,114,100,0,0,1,1,0,0,9,0,98,105,97,115,0,0,0,1,3,2,90,95,0,0,
-12,0,1,99,111,111,114,100,52,0,0,0,9,18,99,111,111,114,100,52,0,59,120,0,18,99,111,111,114,100,0,
-20,0,9,18,99,111,111,114,100,52,0,59,119,0,18,98,105,97,115,0,20,0,4,118,101,99,52,95,116,101,120,
-95,49,100,95,98,105,97,115,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,
-18,99,111,111,114,100,52,0,0,0,0,1,90,95,0,0,12,0,0,116,101,120,116,117,114,101,49,68,80,114,111,
-106,0,1,1,0,0,16,0,115,97,109,112,108,101,114,0,0,1,1,0,0,10,0,99,111,111,114,100,0,0,1,1,0,0,9,0,
-98,105,97,115,0,0,0,1,3,2,90,95,0,0,12,0,1,112,99,111,111,114,100,0,0,0,9,18,112,99,111,111,114,
-100,0,59,120,0,18,99,111,111,114,100,0,59,120,0,18,99,111,111,114,100,0,59,121,0,49,20,0,9,18,112,
-99,111,111,114,100,0,59,119,0,18,98,105,97,115,0,20,0,4,118,101,99,52,95,116,101,120,95,49,100,95,
-98,105,97,115,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,112,99,111,
-111,114,100,0,0,0,0,1,90,95,0,0,12,0,0,116,101,120,116,117,114,101,49,68,80,114,111,106,0,1,1,0,0,
-16,0,115,97,109,112,108,101,114,0,0,1,1,0,0,12,0,99,111,111,114,100,0,0,1,1,0,0,9,0,98,105,97,115,
-0,0,0,1,3,2,90,95,0,0,12,0,1,112,99,111,111,114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,0,
-18,99,111,111,114,100,0,59,120,0,18,99,111,111,114,100,0,59,122,0,49,20,0,9,18,112,99,111,111,114,
-100,0,59,119,0,18,98,105,97,115,0,20,0,4,118,101,99,52,95,116,101,120,95,49,100,95,98,105,97,115,0,
-18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,112,99,111,111,114,100,0,0,
-0,0,1,90,95,0,0,12,0,0,116,101,120,116,117,114,101,50,68,0,1,1,0,0,17,0,115,97,109,112,108,101,114,
-0,0,1,1,0,0,10,0,99,111,111,114,100,0,0,1,1,0,0,9,0,98,105,97,115,0,0,0,1,3,2,90,95,0,0,12,0,1,99,
-111,111,114,100,52,0,0,0,9,18,99,111,111,114,100,52,0,59,120,121,0,18,99,111,111,114,100,0,59,120,
-121,0,20,0,9,18,99,111,111,114,100,52,0,59,119,0,18,98,105,97,115,0,20,0,4,118,101,99,52,95,116,
-101,120,95,50,100,95,98,105,97,115,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,
-114,0,0,18,99,111,111,114,100,52,0,0,0,0,1,90,95,0,0,12,0,0,116,101,120,116,117,114,101,50,68,80,
-114,111,106,0,1,1,0,0,17,0,115,97,109,112,108,101,114,0,0,1,1,0,0,11,0,99,111,111,114,100,0,0,1,1,
-0,0,9,0,98,105,97,115,0,0,0,1,3,2,90,95,0,0,12,0,1,112,99,111,111,114,100,0,0,0,9,18,112,99,111,
-111,114,100,0,59,120,121,0,18,99,111,111,114,100,0,59,120,121,0,18,99,111,111,114,100,0,59,122,0,
-49,20,0,9,18,112,99,111,111,114,100,0,59,119,0,18,98,105,97,115,0,20,0,4,118,101,99,52,95,116,101,
-120,95,50,100,95,98,105,97,115,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,
-0,0,18,112,99,111,111,114,100,0,0,0,0,1,90,95,0,0,12,0,0,116,101,120,116,117,114,101,50,68,80,114,
-111,106,0,1,1,0,0,17,0,115,97,109,112,108,101,114,0,0,1,1,0,0,12,0,99,111,111,114,100,0,0,1,1,0,0,
-9,0,98,105,97,115,0,0,0,1,3,2,90,95,0,0,12,0,1,112,99,111,111,114,100,0,0,0,9,18,112,99,111,111,
-114,100,0,59,120,121,0,18,99,111,111,114,100,0,59,120,121,0,18,99,111,111,114,100,0,59,119,0,49,20,
-0,9,18,112,99,111,111,114,100,0,59,119,0,18,98,105,97,115,0,20,0,4,118,101,99,52,95,116,101,120,95,
-50,100,95,98,105,97,115,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,
-112,99,111,111,114,100,0,0,0,0,1,90,95,0,0,12,0,0,116,101,120,116,117,114,101,51,68,0,1,1,0,0,18,0,
-115,97,109,112,108,101,114,0,0,1,1,0,0,11,0,99,111,111,114,100,0,0,1,1,0,0,9,0,98,105,97,115,0,0,0,
-1,3,2,90,95,0,0,12,0,1,99,111,111,114,100,52,0,0,0,9,18,99,111,111,114,100,52,0,59,120,121,122,0,
-18,99,111,111,114,100,0,59,120,121,122,0,20,0,9,18,99,111,111,114,100,52,0,59,119,0,18,98,105,97,
-115,0,20,0,4,118,101,99,52,95,116,101,120,95,51,100,95,98,105,97,115,0,18,95,95,114,101,116,86,97,
-108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,52,0,0,0,0,1,90,95,0,0,12,0,0,116,
-101,120,116,117,114,101,51,68,80,114,111,106,0,1,1,0,0,18,0,115,97,109,112,108,101,114,0,0,1,1,0,0,
-12,0,99,111,111,114,100,0,0,1,1,0,0,9,0,98,105,97,115,0,0,0,1,3,2,90,95,0,0,12,0,1,112,99,111,111,
-114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,121,122,0,18,99,111,111,114,100,0,59,120,121,
-122,0,18,99,111,111,114,100,0,59,119,0,49,20,0,9,18,112,99,111,111,114,100,0,59,119,0,18,98,105,97,
-115,0,20,0,4,118,101,99,52,95,116,101,120,95,51,100,95,98,105,97,115,0,18,95,95,114,101,116,86,97,
-108,0,0,18,115,97,109,112,108,101,114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,90,95,0,0,12,0,0,116,
-101,120,116,117,114,101,67,117,98,101,0,1,1,0,0,19,0,115,97,109,112,108,101,114,0,0,1,1,0,0,11,0,
-99,111,111,114,100,0,0,1,1,0,0,9,0,98,105,97,115,0,0,0,1,3,2,90,95,0,0,12,0,1,99,111,111,114,100,
-52,0,0,0,9,18,99,111,111,114,100,52,0,59,120,121,122,0,18,99,111,111,114,100,0,20,0,9,18,99,111,
-111,114,100,52,0,59,119,0,18,98,105,97,115,0,20,0,4,118,101,99,52,95,116,101,120,95,99,117,98,101,
-0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,52,0,
-0,0,0,1,90,95,0,0,12,0,0,115,104,97,100,111,119,49,68,0,1,1,0,0,20,0,115,97,109,112,108,101,114,0,
-0,1,1,0,0,11,0,99,111,111,114,100,0,0,1,1,0,0,9,0,98,105,97,115,0,0,0,1,3,2,90,95,0,0,12,0,1,99,
-111,111,114,100,52,0,0,0,9,18,99,111,111,114,100,52,0,59,120,121,122,0,18,99,111,111,114,100,0,20,
-0,9,18,99,111,111,114,100,52,0,59,119,0,18,98,105,97,115,0,20,0,4,118,101,99,52,95,116,101,120,95,
-49,100,95,98,105,97,115,95,115,104,97,100,111,119,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,
-109,112,108,101,114,0,0,18,99,111,111,114,100,52,0,0,0,0,1,90,95,0,0,12,0,0,115,104,97,100,111,119,
-49,68,80,114,111,106,0,1,1,0,0,20,0,115,97,109,112,108,101,114,0,0,1,1,0,0,12,0,99,111,111,114,100,
-0,0,1,1,0,0,9,0,98,105,97,115,0,0,0,1,3,2,90,95,0,0,12,0,1,112,99,111,111,114,100,0,0,0,9,18,112,
-99,111,111,114,100,0,59,120,0,18,99,111,111,114,100,0,59,120,0,18,99,111,111,114,100,0,59,119,0,49,
-20,0,9,18,112,99,111,111,114,100,0,59,122,0,18,99,111,111,114,100,0,59,122,0,20,0,9,18,112,99,111,
-111,114,100,0,59,119,0,18,98,105,97,115,0,20,0,4,118,101,99,52,95,116,101,120,95,49,100,95,98,105,
-97,115,95,115,104,97,100,111,119,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,
-114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,90,95,0,0,12,0,0,115,104,97,100,111,119,50,68,0,1,1,0,
-0,21,0,115,97,109,112,108,101,114,0,0,1,1,0,0,11,0,99,111,111,114,100,0,0,1,1,0,0,9,0,98,105,97,
-115,0,0,0,1,3,2,90,95,0,0,12,0,1,99,111,111,114,100,52,0,0,0,9,18,99,111,111,114,100,52,0,59,120,
-121,122,0,18,99,111,111,114,100,0,20,0,9,18,99,111,111,114,100,52,0,59,119,0,18,98,105,97,115,0,20,
-0,4,118,101,99,52,95,116,101,120,95,50,100,95,98,105,97,115,95,115,104,97,100,111,119,0,18,95,95,
-114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,52,0,0,0,0,1,90,
-95,0,0,12,0,0,115,104,97,100,111,119,50,68,80,114,111,106,0,1,1,0,0,21,0,115,97,109,112,108,101,
-114,0,0,1,1,0,0,12,0,99,111,111,114,100,0,0,1,1,0,0,9,0,98,105,97,115,0,0,0,1,3,2,90,95,0,0,12,0,1,
-112,99,111,111,114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,121,0,18,99,111,111,114,100,0,59,
-120,121,0,18,99,111,111,114,100,0,59,119,0,49,20,0,9,18,112,99,111,111,114,100,0,59,122,0,18,99,
-111,111,114,100,0,59,122,0,20,0,9,18,112,99,111,111,114,100,0,59,119,0,18,98,105,97,115,0,20,0,4,
-118,101,99,52,95,116,101,120,95,50,100,95,98,105,97,115,95,115,104,97,100,111,119,0,18,95,95,114,
-101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,90,95,
-0,0,9,0,0,100,70,100,120,0,1,1,0,0,9,0,112,0,0,0,1,4,118,101,99,52,95,100,100,120,0,18,95,95,114,
-101,116,86,97,108,0,59,120,0,0,18,112,0,59,120,120,120,120,0,0,0,0,1,90,95,0,0,10,0,0,100,70,100,
-120,0,1,1,0,0,10,0,112,0,0,0,1,4,118,101,99,52,95,100,100,120,0,18,95,95,114,101,116,86,97,108,0,
-59,120,121,0,0,18,112,0,59,120,121,121,121,0,0,0,0,1,90,95,0,0,11,0,0,100,70,100,120,0,1,1,0,0,11,
-0,112,0,0,0,1,4,118,101,99,52,95,100,100,120,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,
-18,112,0,59,120,121,122,122,0,0,0,0,1,90,95,0,0,12,0,0,100,70,100,120,0,1,1,0,0,12,0,112,0,0,0,1,4,
-118,101,99,52,95,100,100,120,0,18,95,95,114,101,116,86,97,108,0,0,18,112,0,0,0,0,1,90,95,0,0,9,0,0,
-100,70,100,121,0,1,1,0,0,9,0,112,0,0,0,1,4,118,101,99,52,95,100,100,121,0,18,95,95,114,101,116,86,
-97,108,0,59,120,0,0,18,112,0,59,120,120,120,120,0,0,0,0,1,90,95,0,0,10,0,0,100,70,100,121,0,1,1,0,
-0,10,0,112,0,0,0,1,4,118,101,99,52,95,100,100,121,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,
-0,18,112,0,59,120,121,121,121,0,0,0,0,1,90,95,0,0,11,0,0,100,70,100,121,0,1,1,0,0,11,0,112,0,0,0,1,
-4,118,101,99,52,95,100,100,121,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,112,0,59,
-120,121,122,122,0,0,0,0,1,90,95,0,0,12,0,0,100,70,100,121,0,1,1,0,0,12,0,112,0,0,0,1,4,118,101,99,
-52,95,100,100,121,0,18,95,95,114,101,116,86,97,108,0,0,18,112,0,0,0,0,1,90,95,0,0,9,0,0,102,119,
-105,100,116,104,0,1,1,0,0,9,0,112,0,0,0,1,8,58,97,98,115,0,0,58,100,70,100,120,0,0,18,112,0,0,0,0,
-0,58,97,98,115,0,0,58,100,70,100,121,0,0,18,112,0,0,0,0,0,46,0,0,1,90,95,0,0,10,0,0,102,119,105,
-100,116,104,0,1,1,0,0,10,0,112,0,0,0,1,8,58,97,98,115,0,0,58,100,70,100,120,0,0,18,112,0,0,0,0,0,
-58,97,98,115,0,0,58,100,70,100,121,0,0,18,112,0,0,0,0,0,46,0,0,1,90,95,0,0,11,0,0,102,119,105,100,
-116,104,0,1,1,0,0,11,0,112,0,0,0,1,8,58,97,98,115,0,0,58,100,70,100,120,0,0,18,112,0,0,0,0,0,58,97,
-98,115,0,0,58,100,70,100,121,0,0,18,112,0,0,0,0,0,46,0,0,1,90,95,0,0,12,0,0,102,119,105,100,116,
-104,0,1,1,0,0,12,0,112,0,0,0,1,8,58,97,98,115,0,0,58,100,70,100,120,0,0,18,112,0,0,0,0,0,58,97,98,
-115,0,0,58,100,70,100,121,0,0,18,112,0,0,0,0,0,46,0,0,0
diff --git a/src/mesa/shader/slang/library/slang_pp_directives.syn b/src/mesa/shader/slang/library/slang_pp_directives.syn
deleted file mode 100644 (file)
index b51d168..0000000
+++ /dev/null
@@ -1,405 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version:  6.6
- *
- * Copyright (C) 2006  Brian Paul   All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/**
- * \file slang_pp_directives.syn
- * slang preprocessor directives parser
- * \author Michal Krol
- */
-
-.syntax source;
-
-/*
- * This syntax script preprocesses a GLSL shader.
- * It is assumed, that the #version directive has been parsed. Separate pass for parsing
- * version gives better control on behavior depending on the version number given.
- *
- * The output is a source string with comments and directives removed. White spaces and comments
- * are replaced with on or more spaces. All new-lines are preserved and converted to Linux format.
- * Directives are escaped with a null character. The end of the source string is marked by
- * two consecutive null characters. The consumer is responsible for executing the escaped
- * directives, removing dead portions of code and expanding macros.
- */
-
-.emtcode ESCAPE_TOKEN 0
-
-/*
- * The TOKEN_* symbols follow the ESCAPE_TOKEN.
- *
- * NOTE:
- * There is no TOKEN_IFDEF and neither is TOKEN_IFNDEF. They are handled with TOKEN_IF and
- * operator defined.
- * The "#ifdef SYMBOL" is replaced with "#if defined SYMBOL"
- * The "#ifndef SYMBOL" is replaced with "#if !defined SYMBOL"
- */
-.emtcode TOKEN_END       0
-.emtcode TOKEN_DEFINE    1
-.emtcode TOKEN_UNDEF     2
-.emtcode TOKEN_IF        3
-.emtcode TOKEN_ELSE      4
-.emtcode TOKEN_ELIF      5
-.emtcode TOKEN_ENDIF     6
-.emtcode TOKEN_ERROR     7
-.emtcode TOKEN_PRAGMA    8
-.emtcode TOKEN_EXTENSION 9
-.emtcode TOKEN_LINE      10
-
-/*
- * The PARAM_* symbols follow the TOKEN_DEFINE.
- */
-.emtcode PARAM_END       0
-.emtcode PARAM_PARAMETER 1
-
-/*
- * The BEHAVIOR_* symbols follow the TOKEN_EXTENSION.
- */
-.emtcode BEHAVIOR_REQUIRE 1
-.emtcode BEHAVIOR_ENABLE  2
-.emtcode BEHAVIOR_WARN    3
-.emtcode BEHAVIOR_DISABLE 4
-
-/*
- * The PRAGMA_* symbols follow TOKEN_PRAGMA
- */
-.emtcode PRAGMA_NO_PARAM 0
-.emtcode PRAGMA_PARAM    1
-
-source
-   optional_directive .and .loop source_element .and '\0' .emit ESCAPE_TOKEN .emit TOKEN_END;
-
-source_element
-   c_style_comment_block .or cpp_style_comment_block .or new_line_directive .or source_token;
-
-c_style_comment_block
-   '/' .and '*' .and c_style_comment_rest .and .true .emit ' ';
-
-c_style_comment_rest
-   .loop c_style_comment_body .and c_style_comment_end;
-
-c_style_comment_body
-   c_style_comment_char_nostar .or c_style_comment_char_star_noslashstar;
-
-c_style_comment_char_nostar
-   new_line .or '\x2B'-'\xFF' .or '\x01'-'\x29';
-
-c_style_comment_char_star_noslashstar
-   '*' .and c_style_comment_char_star_noslashstar_1;
-c_style_comment_char_star_noslashstar_1
-   c_style_comment_char_noslashstar .or c_style_comment_char_star_noslashstar;
-
-c_style_comment_char_noslashstar
-   new_line .or '\x30'-'\xFF' .or '\x01'-'\x29' .or '\x2B'-'\x2E';
-
-c_style_comment_end
-   '*' .and .loop c_style_comment_char_star .and '/';
-
-c_style_comment_char_star
-   '*';
-
-cpp_style_comment_block
-   '/' .and '/' .and cpp_style_comment_block_1;
-cpp_style_comment_block_1
-   cpp_style_comment_block_2 .or cpp_style_comment_block_3;
-cpp_style_comment_block_2
-   .loop cpp_style_comment_char .and new_line_directive;
-cpp_style_comment_block_3
-   .loop cpp_style_comment_char;
-
-cpp_style_comment_char
-   '\x0E'-'\xFF' .or '\x01'-'\x09' .or '\x0B'-'\x0C';
-
-new_line_directive
-   new_line .and optional_directive;
-
-new_line
-   generic_new_line .emit '\n';
-
-generic_new_line
-   carriage_return_line_feed .or line_feed_carriage_return .or '\n' .or '\r';
-
-carriage_return_line_feed
-   '\r' .and '\n';
-
-line_feed_carriage_return
-   '\n' .and '\r';
-
-optional_directive
-   directive .emit ESCAPE_TOKEN .or .true;
-
-directive
-   dir_define .emit TOKEN_DEFINE .or
-   dir_undef .emit TOKEN_UNDEF .or
-   dir_if .emit TOKEN_IF .or
-   dir_ifdef .emit TOKEN_IF .emit 'd' .emit 'e' .emit 'f' .emit 'i' .emit 'n' .emit 'e' .emit 'd'
-             .emit ' ' .or
-   dir_ifndef .emit TOKEN_IF .emit '!' .emit 'd' .emit 'e' .emit 'f' .emit 'i' .emit 'n' .emit 'e'
-              .emit 'd' .emit ' ' .or
-   dir_else .emit TOKEN_ELSE .or
-   dir_elif .emit TOKEN_ELIF .or
-   dir_endif .emit TOKEN_ENDIF .or
-   dir_ext .emit TOKEN_EXTENSION .or
-   dir_pragma .emit TOKEN_PRAGMA .or
-   dir_line .emit TOKEN_LINE;
-
-dir_define
-   optional_space .and '#' .and optional_space .and "define" .and symbol .and opt_parameters .and
-   definition;
-
-dir_undef
-   optional_space .and '#' .and optional_space .and "undef" .and symbol;
-
-dir_if
-   optional_space .and '#' .and optional_space .and "if" .and expression;
-
-dir_ifdef
-   optional_space .and '#' .and optional_space .and "ifdef" .and symbol;
-
-dir_ifndef
-   optional_space .and '#' .and optional_space .and "ifndef" .and symbol;
-
-dir_else
-   optional_space .and '#' .and optional_space .and "else";
-
-dir_elif
-   optional_space .and '#' .and optional_space .and "elif" .and expression;
-
-dir_endif
-   optional_space .and '#' .and optional_space .and "endif";
-
-dir_ext
-   optional_space .and '#' .and optional_space .and "extension" .and space .and extension_name .and
-   optional_space .and ':' .and optional_space .and extension_behavior;
-
-dir_line
-   optional_space .and '#' .and optional_space .and "line" .and expression;
-
-dir_pragma
-   optional_space .and '#' .and optional_space .and "pragma" .and symbol .and opt_pragma_param;
-
-
-opt_pragma_param
-   pragma_param .or .true .emit PRAGMA_NO_PARAM;
-
-pragma_param
-   optional_space .and '(' .emit PRAGMA_PARAM .and optional_space .and symbol_no_space .and optional_space .and ')';
-
-symbol_no_space
-   symbol_character .emit * .and .loop symbol_character2 .emit * .and .true .emit '\0';
-
-symbol
-   space .and symbol_character .emit * .and .loop symbol_character2 .emit * .and .true .emit '\0';
-
-opt_parameters
-   parameters .or .true .emit PARAM_END;
-
-parameters
-   '(' .and parameters_1 .and optional_space .and ')' .emit PARAM_END;
-parameters_1
-   parameters_2 .or .true;
-parameters_2
-   parameter .emit PARAM_PARAMETER .and .loop parameters_3;
-parameters_3
-   optional_space .and ',' .and parameter .emit PARAM_PARAMETER;
-
-parameter
-   optional_space .and symbol_character .emit * .and .loop symbol_character2 .emit * .and
-   .true .emit '\0';
-
-definition
-   .loop definition_character .emit * .and .true .emit '\0';
-
-definition_character
-   '\x0E'-'\xFF' .or '\x01'-'\x09' .or '\x0B'-'\x0C';
-
-expression
-   expression_element .and .loop expression_element .and .true .emit '\0';
-
-expression_element
-   expression_character .emit *;
-
-expression_character
-   '\x0E'-'\xFF' .or '\x01'-'\x09' .or '\x0B'-'\x0C';
-
-extension_name
-   symbol_character .emit * .and .loop symbol_character2 .emit * .and .true .emit '\0';
-
-extension_behavior
-   "require" .emit BEHAVIOR_REQUIRE .or
-   "enable" .emit BEHAVIOR_ENABLE .or
-   "warn" .emit BEHAVIOR_WARN .or
-   "disable" .emit BEHAVIOR_DISABLE;
-
-optional_space
-   .loop single_space;
-
-space
-   single_space .and .loop single_space;
-
-single_space
-   ' ' .or '\t';
-
-source_token
-   space .emit ' ' .or complex_token .or source_token_1;
-source_token_1
-   simple_token .emit ' ' .and .true .emit ' ';
-
-/*
- * All possible tokens.
- */
-
-complex_token
-   identifier .or number;
-
-simple_token
-   increment .or decrement .or lequal .or gequal .or equal .or nequal .or and .or xor .or or .or
-   addto .or subtractfrom .or multiplyto .or divideto .or other;
-
-identifier
-   identifier_char1 .emit * .and .loop identifier_char2 .emit *;
-identifier_char1
-   'a'-'z' .or 'A'-'Z' .or '_';
-identifier_char2
-   'a'-'z' .or 'A'-'Z' .or '0'-'9' .or '_';
-
-number
-   float .or integer;
-
-digit_oct
-   '0'-'7';
-
-digit_dec
-   '0'-'9';
-
-digit_hex
-   '0'-'9' .or 'A'-'F' .or 'a'-'f';
-
-float
-   float_1 .or float_2;
-float_1
-   float_fractional_constant .and float_optional_exponent_part;
-float_2
-   float_digit_sequence .and float_exponent_part;
-
-float_fractional_constant
-   float_fractional_constant_1 .or float_fractional_constant_2 .or float_fractional_constant_3;
-float_fractional_constant_1
-   float_digit_sequence .and '.' .emit '.' .and float_digit_sequence;
-float_fractional_constant_2
-   float_digit_sequence .and '.' .emit '.';
-float_fractional_constant_3
-   '.' .emit '.' .and float_digit_sequence;
-
-float_optional_exponent_part
-   float_exponent_part .or .true;
-
-float_digit_sequence
-   digit_dec .emit * .and .loop digit_dec .emit *;
-
-float_exponent_part
-   float_exponent_part_1 .or float_exponent_part_2;
-float_exponent_part_1
-   'e' .emit 'e' .and float_optional_sign .and float_digit_sequence;
-float_exponent_part_2
-   'E' .emit 'E' .and float_optional_sign .and float_digit_sequence;
-
-float_optional_sign
-   '+' .emit '+' .or '-' .emit '-' .or .true;
-
-integer
-   integer_hex .or integer_oct .or integer_dec;
-
-integer_hex
-   '0' .emit '0' .and integer_hex_1 .emit * .and digit_hex .emit * .and
-   .loop digit_hex .emit *;
-integer_hex_1
-   'x' .or 'X';
-
-integer_oct
-   '0' .emit '0' .and .loop digit_oct .emit *;
-
-integer_dec
-   digit_dec .emit * .and .loop digit_dec .emit *;
-
-increment
-   '+' .emit * .and '+' .emit *;
-
-decrement
-   '-' .emit * .and '-' .emit *;
-
-lequal
-   '<' .emit * .and '=' .emit *;
-
-gequal
-   '>' .emit * .and '=' .emit *;
-
-equal
-   '=' .emit * .and '=' .emit *;
-
-nequal
-   '!' .emit * .and '=' .emit *;
-
-and
-   '&' .emit * .and '&' .emit *;
-
-xor
-   '^' .emit * .and '^' .emit *;
-
-or
-   '|' .emit * .and '|' .emit *;
-
-addto
-   '+' .emit * .and '=' .emit *;
-
-subtractfrom
-   '-' .emit * .and '=' .emit *;
-
-multiplyto
-   '*' .emit * .and '=' .emit *;
-
-divideto
-   '/' .emit * .and '=' .emit *;
-
-/*
- * All characters except '\0' and '#'.
- */
-other
-   '\x24'-'\xFF' .emit * .or '\x01'-'\x22' .emit *;
-
-symbol_character
-   'A'-'Z' .or 'a'-'z' .or '_';
-
-symbol_character2
-   'A'-'Z' .or 'a'-'z' .or '0'-'9' .or '_';
-
-.string string_lexer;
-
-string_lexer
-   lex_first_identifier_character .and .loop lex_next_identifier_character;
-
-lex_first_identifier_character
-   'a'-'z' .or 'A'-'Z' .or '_';
-
-lex_next_identifier_character
-   'a'-'z' .or 'A'-'Z' .or '0'-'9' .or '_';
-
diff --git a/src/mesa/shader/slang/library/slang_pp_directives_syn.h b/src/mesa/shader/slang/library/slang_pp_directives_syn.h
deleted file mode 100644 (file)
index 430f8d8..0000000
+++ /dev/null
@@ -1,250 +0,0 @@
-
-/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED FROM THE .syn FILE */
-
-".syntax source;\n"
-".emtcode ESCAPE_TOKEN 0\n"
-".emtcode TOKEN_END 0\n"
-".emtcode TOKEN_DEFINE 1\n"
-".emtcode TOKEN_UNDEF 2\n"
-".emtcode TOKEN_IF 3\n"
-".emtcode TOKEN_ELSE 4\n"
-".emtcode TOKEN_ELIF 5\n"
-".emtcode TOKEN_ENDIF 6\n"
-".emtcode TOKEN_ERROR 7\n"
-".emtcode TOKEN_PRAGMA 8\n"
-".emtcode TOKEN_EXTENSION 9\n"
-".emtcode TOKEN_LINE 10\n"
-".emtcode PARAM_END 0\n"
-".emtcode PARAM_PARAMETER 1\n"
-".emtcode BEHAVIOR_REQUIRE 1\n"
-".emtcode BEHAVIOR_ENABLE 2\n"
-".emtcode BEHAVIOR_WARN 3\n"
-".emtcode BEHAVIOR_DISABLE 4\n"
-".emtcode PRAGMA_NO_PARAM 0\n"
-".emtcode PRAGMA_PARAM 1\n"
-"source\n"
-" optional_directive .and .loop source_element .and '\\0' .emit ESCAPE_TOKEN .emit TOKEN_END;\n"
-"source_element\n"
-" c_style_comment_block .or cpp_style_comment_block .or new_line_directive .or source_token;\n"
-"c_style_comment_block\n"
-" '/' .and '*' .and c_style_comment_rest .and .true .emit ' ';\n"
-"c_style_comment_rest\n"
-" .loop c_style_comment_body .and c_style_comment_end;\n"
-"c_style_comment_body\n"
-" c_style_comment_char_nostar .or c_style_comment_char_star_noslashstar;\n"
-"c_style_comment_char_nostar\n"
-" new_line .or '\\x2B'-'\\xFF' .or '\\x01'-'\\x29';\n"
-"c_style_comment_char_star_noslashstar\n"
-" '*' .and c_style_comment_char_star_noslashstar_1;\n"
-"c_style_comment_char_star_noslashstar_1\n"
-" c_style_comment_char_noslashstar .or c_style_comment_char_star_noslashstar;\n"
-"c_style_comment_char_noslashstar\n"
-" new_line .or '\\x30'-'\\xFF' .or '\\x01'-'\\x29' .or '\\x2B'-'\\x2E';\n"
-"c_style_comment_end\n"
-" '*' .and .loop c_style_comment_char_star .and '/';\n"
-"c_style_comment_char_star\n"
-" '*';\n"
-"cpp_style_comment_block\n"
-" '/' .and '/' .and cpp_style_comment_block_1;\n"
-"cpp_style_comment_block_1\n"
-" cpp_style_comment_block_2 .or cpp_style_comment_block_3;\n"
-"cpp_style_comment_block_2\n"
-" .loop cpp_style_comment_char .and new_line_directive;\n"
-"cpp_style_comment_block_3\n"
-" .loop cpp_style_comment_char;\n"
-"cpp_style_comment_char\n"
-" '\\x0E'-'\\xFF' .or '\\x01'-'\\x09' .or '\\x0B'-'\\x0C';\n"
-"new_line_directive\n"
-" new_line .and optional_directive;\n"
-"new_line\n"
-" generic_new_line .emit '\\n';\n"
-"generic_new_line\n"
-" carriage_return_line_feed .or line_feed_carriage_return .or '\\n' .or '\\r';\n"
-"carriage_return_line_feed\n"
-" '\\r' .and '\\n';\n"
-"line_feed_carriage_return\n"
-" '\\n' .and '\\r';\n"
-"optional_directive\n"
-" directive .emit ESCAPE_TOKEN .or .true;\n"
-"directive\n"
-" dir_define .emit TOKEN_DEFINE .or\n"
-" dir_undef .emit TOKEN_UNDEF .or\n"
-" dir_if .emit TOKEN_IF .or\n"
-" dir_ifdef .emit TOKEN_IF .emit 'd' .emit 'e' .emit 'f' .emit 'i' .emit 'n' .emit 'e' .emit 'd'\n"
-" .emit ' ' .or\n"
-" dir_ifndef .emit TOKEN_IF .emit '!' .emit 'd' .emit 'e' .emit 'f' .emit 'i' .emit 'n' .emit 'e'\n"
-" .emit 'd' .emit ' ' .or\n"
-" dir_else .emit TOKEN_ELSE .or\n"
-" dir_elif .emit TOKEN_ELIF .or\n"
-" dir_endif .emit TOKEN_ENDIF .or\n"
-" dir_ext .emit TOKEN_EXTENSION .or\n"
-" dir_pragma .emit TOKEN_PRAGMA .or\n"
-" dir_line .emit TOKEN_LINE;\n"
-"dir_define\n"
-" optional_space .and '#' .and optional_space .and \"define\" .and symbol .and opt_parameters .and\n"
-" definition;\n"
-"dir_undef\n"
-" optional_space .and '#' .and optional_space .and \"undef\" .and symbol;\n"
-"dir_if\n"
-" optional_space .and '#' .and optional_space .and \"if\" .and expression;\n"
-"dir_ifdef\n"
-" optional_space .and '#' .and optional_space .and \"ifdef\" .and symbol;\n"
-"dir_ifndef\n"
-" optional_space .and '#' .and optional_space .and \"ifndef\" .and symbol;\n"
-"dir_else\n"
-" optional_space .and '#' .and optional_space .and \"else\";\n"
-"dir_elif\n"
-" optional_space .and '#' .and optional_space .and \"elif\" .and expression;\n"
-"dir_endif\n"
-" optional_space .and '#' .and optional_space .and \"endif\";\n"
-"dir_ext\n"
-" optional_space .and '#' .and optional_space .and \"extension\" .and space .and extension_name .and\n"
-" optional_space .and ':' .and optional_space .and extension_behavior;\n"
-"dir_line\n"
-" optional_space .and '#' .and optional_space .and \"line\" .and expression;\n"
-"dir_pragma\n"
-" optional_space .and '#' .and optional_space .and \"pragma\" .and symbol .and opt_pragma_param;\n"
-"opt_pragma_param\n"
-" pragma_param .or .true .emit PRAGMA_NO_PARAM;\n"
-"pragma_param\n"
-" optional_space .and '(' .emit PRAGMA_PARAM .and optional_space .and symbol_no_space .and optional_space .and ')';\n"
-"symbol_no_space\n"
-" symbol_character .emit * .and .loop symbol_character2 .emit * .and .true .emit '\\0';\n"
-"symbol\n"
-" space .and symbol_character .emit * .and .loop symbol_character2 .emit * .and .true .emit '\\0';\n"
-"opt_parameters\n"
-" parameters .or .true .emit PARAM_END;\n"
-"parameters\n"
-" '(' .and parameters_1 .and optional_space .and ')' .emit PARAM_END;\n"
-"parameters_1\n"
-" parameters_2 .or .true;\n"
-"parameters_2\n"
-" parameter .emit PARAM_PARAMETER .and .loop parameters_3;\n"
-"parameters_3\n"
-" optional_space .and ',' .and parameter .emit PARAM_PARAMETER;\n"
-"parameter\n"
-" optional_space .and symbol_character .emit * .and .loop symbol_character2 .emit * .and\n"
-" .true .emit '\\0';\n"
-"definition\n"
-" .loop definition_character .emit * .and .true .emit '\\0';\n"
-"definition_character\n"
-" '\\x0E'-'\\xFF' .or '\\x01'-'\\x09' .or '\\x0B'-'\\x0C';\n"
-"expression\n"
-" expression_element .and .loop expression_element .and .true .emit '\\0';\n"
-"expression_element\n"
-" expression_character .emit *;\n"
-"expression_character\n"
-" '\\x0E'-'\\xFF' .or '\\x01'-'\\x09' .or '\\x0B'-'\\x0C';\n"
-"extension_name\n"
-" symbol_character .emit * .and .loop symbol_character2 .emit * .and .true .emit '\\0';\n"
-"extension_behavior\n"
-" \"require\" .emit BEHAVIOR_REQUIRE .or\n"
-" \"enable\" .emit BEHAVIOR_ENABLE .or\n"
-" \"warn\" .emit BEHAVIOR_WARN .or\n"
-" \"disable\" .emit BEHAVIOR_DISABLE;\n"
-"optional_space\n"
-" .loop single_space;\n"
-"space\n"
-" single_space .and .loop single_space;\n"
-"single_space\n"
-" ' ' .or '\\t';\n"
-"source_token\n"
-" space .emit ' ' .or complex_token .or source_token_1;\n"
-"source_token_1\n"
-" simple_token .emit ' ' .and .true .emit ' ';\n"
-"complex_token\n"
-" identifier .or number;\n"
-"simple_token\n"
-" increment .or decrement .or lequal .or gequal .or equal .or nequal .or and .or xor .or or .or\n"
-" addto .or subtractfrom .or multiplyto .or divideto .or other;\n"
-"identifier\n"
-" identifier_char1 .emit * .and .loop identifier_char2 .emit *;\n"
-"identifier_char1\n"
-" 'a'-'z' .or 'A'-'Z' .or '_';\n"
-"identifier_char2\n"
-" 'a'-'z' .or 'A'-'Z' .or '0'-'9' .or '_';\n"
-"number\n"
-" float .or integer;\n"
-"digit_oct\n"
-" '0'-'7';\n"
-"digit_dec\n"
-" '0'-'9';\n"
-"digit_hex\n"
-" '0'-'9' .or 'A'-'F' .or 'a'-'f';\n"
-"float\n"
-" float_1 .or float_2;\n"
-"float_1\n"
-" float_fractional_constant .and float_optional_exponent_part;\n"
-"float_2\n"
-" float_digit_sequence .and float_exponent_part;\n"
-"float_fractional_constant\n"
-" float_fractional_constant_1 .or float_fractional_constant_2 .or float_fractional_constant_3;\n"
-"float_fractional_constant_1\n"
-" float_digit_sequence .and '.' .emit '.' .and float_digit_sequence;\n"
-"float_fractional_constant_2\n"
-" float_digit_sequence .and '.' .emit '.';\n"
-"float_fractional_constant_3\n"
-" '.' .emit '.' .and float_digit_sequence;\n"
-"float_optional_exponent_part\n"
-" float_exponent_part .or .true;\n"
-"float_digit_sequence\n"
-" digit_dec .emit * .and .loop digit_dec .emit *;\n"
-"float_exponent_part\n"
-" float_exponent_part_1 .or float_exponent_part_2;\n"
-"float_exponent_part_1\n"
-" 'e' .emit 'e' .and float_optional_sign .and float_digit_sequence;\n"
-"float_exponent_part_2\n"
-" 'E' .emit 'E' .and float_optional_sign .and float_digit_sequence;\n"
-"float_optional_sign\n"
-" '+' .emit '+' .or '-' .emit '-' .or .true;\n"
-"integer\n"
-" integer_hex .or integer_oct .or integer_dec;\n"
-"integer_hex\n"
-" '0' .emit '0' .and integer_hex_1 .emit * .and digit_hex .emit * .and\n"
-" .loop digit_hex .emit *;\n"
-"integer_hex_1\n"
-" 'x' .or 'X';\n"
-"integer_oct\n"
-" '0' .emit '0' .and .loop digit_oct .emit *;\n"
-"integer_dec\n"
-" digit_dec .emit * .and .loop digit_dec .emit *;\n"
-"increment\n"
-" '+' .emit * .and '+' .emit *;\n"
-"decrement\n"
-" '-' .emit * .and '-' .emit *;\n"
-"lequal\n"
-" '<' .emit * .and '=' .emit *;\n"
-"gequal\n"
-" '>' .emit * .and '=' .emit *;\n"
-"equal\n"
-" '=' .emit * .and '=' .emit *;\n"
-"nequal\n"
-" '!' .emit * .and '=' .emit *;\n"
-"and\n"
-" '&' .emit * .and '&' .emit *;\n"
-"xor\n"
-" '^' .emit * .and '^' .emit *;\n"
-"or\n"
-" '|' .emit * .and '|' .emit *;\n"
-"addto\n"
-" '+' .emit * .and '=' .emit *;\n"
-"subtractfrom\n"
-" '-' .emit * .and '=' .emit *;\n"
-"multiplyto\n"
-" '*' .emit * .and '=' .emit *;\n"
-"divideto\n"
-" '/' .emit * .and '=' .emit *;\n"
-"other\n"
-" '\\x24'-'\\xFF' .emit * .or '\\x01'-'\\x22' .emit *;\n"
-"symbol_character\n"
-" 'A'-'Z' .or 'a'-'z' .or '_';\n"
-"symbol_character2\n"
-" 'A'-'Z' .or 'a'-'z' .or '0'-'9' .or '_';\n"
-".string string_lexer;\n"
-"string_lexer\n"
-" lex_first_identifier_character .and .loop lex_next_identifier_character;\n"
-"lex_first_identifier_character\n"
-" 'a'-'z' .or 'A'-'Z' .or '_';\n"
-"lex_next_identifier_character\n"
-" 'a'-'z' .or 'A'-'Z' .or '0'-'9' .or '_';\n"
-""
diff --git a/src/mesa/shader/slang/library/slang_pp_expression.syn b/src/mesa/shader/slang/library/slang_pp_expression.syn
deleted file mode 100644 (file)
index bfdb220..0000000
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version:  6.6
- *
- * Copyright (C) 2006  Brian Paul   All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/**
- * \file slang_pp_expression.syn
- * slang preprocessor expression parser
- * \author Michal Krol
- */
-
-/*
- * Parses one or two (optional) expressions on literal integer constants. Those expressions come
- * from #if #elif and #line directives. The preprocessor already parsed those directives and
- * expanded the expression (expressions). All occurences of the operator "defined" are already
- * replaced with either "0" or "1" literals.
- */
-
-.syntax expression;
-
-/*
- * Those separate individual expressions.
- * For #if/#elif case it is: EXP_EXPRESSION ... EXP_END
- * For #line case it may be: EXP_EXPRESSION ... EXP_EXPRESSION ... EXP_END
- */
-.emtcode EXP_END        0
-.emtcode EXP_EXPRESSION 1
-
-.emtcode OP_END          0
-.emtcode OP_PUSHINT      1
-.emtcode OP_LOGICALOR    2
-.emtcode OP_LOGICALAND   3
-.emtcode OP_OR           4
-.emtcode OP_XOR          5
-.emtcode OP_AND          6
-.emtcode OP_EQUAL        7
-.emtcode OP_NOTEQUAL     8
-.emtcode OP_LESSEQUAL    9
-.emtcode OP_GREATEREQUAL 10
-.emtcode OP_LESS         11
-.emtcode OP_GREATER      12
-.emtcode OP_LEFTSHIFT    13
-.emtcode OP_RIGHTSHIFT   14
-.emtcode OP_ADD          15
-.emtcode OP_SUBTRACT     16
-.emtcode OP_MULTIPLY     17
-.emtcode OP_DIVIDE       18
-.emtcode OP_MODULUS      19
-.emtcode OP_PLUS         20
-.emtcode OP_MINUS        21
-.emtcode OP_NEGATE       22
-.emtcode OP_COMPLEMENT   23
-
-expression
-   first_expression .and optional_second_expression .and optional_space .and '\0' .emit EXP_END;
-
-first_expression
-   optional_space .and logical_or_expression .emit EXP_EXPRESSION .and .true .emit OP_END;
-
-optional_second_expression
-   second_expression .or .true;
-
-second_expression
-   space .and logical_or_expression .emit EXP_EXPRESSION .and .true .emit OP_END;
-
-logical_or_expression
-   logical_and_expression .and .loop logical_or_expression_1;
-logical_or_expression_1
-   barbar .and logical_and_expression .and .true .emit OP_LOGICALOR;
-
-logical_and_expression
-   or_expression .and .loop logical_and_expression_1;
-logical_and_expression_1
-   ampersandampersand .and or_expression .and .true .emit OP_LOGICALAND;
-
-or_expression
-   xor_expression .and .loop or_expression_1;
-or_expression_1
-   bar .and xor_expression .and .true .emit OP_OR;
-
-xor_expression
-    and_expression .and .loop xor_expression_1;
-xor_expression_1
-    caret .and and_expression .and .true .emit OP_XOR;
-
-and_expression
-    equality_expression .and .loop and_expression_1;
-and_expression_1
-    ampersand .and equality_expression .and .true .emit OP_AND;
-
-equality_expression
-    relational_expression .and .loop equality_expression_1;
-equality_expression_1
-    equality_expression_2 .or equality_expression_3;
-equality_expression_2
-    equalsequals .and relational_expression .and .true .emit OP_EQUAL;
-equality_expression_3
-    bangequals .and relational_expression .and .true .emit OP_NOTEQUAL;
-
-relational_expression
-    shift_expression .and .loop relational_expression_1;
-relational_expression_1
-    relational_expression_2 .or relational_expression_3 .or relational_expression_4 .or
-    relational_expression_5;
-relational_expression_2
-    lessequals .and shift_expression .and .true .emit OP_LESSEQUAL;
-relational_expression_3
-    greaterequals .and shift_expression .and .true .emit OP_GREATEREQUAL;
-relational_expression_4
-    less .and shift_expression .and .true .emit OP_LESS;
-relational_expression_5
-    greater .and shift_expression .and .true .emit OP_GREATER;
-
-shift_expression
-    additive_expression .and .loop shift_expression_1;
-shift_expression_1
-    shift_expression_2 .or shift_expression_3;
-shift_expression_2
-    lessless .and additive_expression .and .true .emit OP_LEFTSHIFT;
-shift_expression_3
-    greatergreater .and additive_expression .and .true .emit OP_RIGHTSHIFT;
-
-additive_expression
-    multiplicative_expression .and .loop additive_expression_1;
-additive_expression_1
-    additive_expression_2 .or additive_expression_3;
-additive_expression_2
-    plus .and multiplicative_expression .and .true .emit OP_ADD;
-additive_expression_3
-    dash .and multiplicative_expression .and .true .emit OP_SUBTRACT;
-
-multiplicative_expression
-    unary_expression .and .loop multiplicative_expression_1;
-multiplicative_expression_1
-    multiplicative_expression_2 .or multiplicative_expression_3 .or multiplicative_expression_4;
-multiplicative_expression_2
-    star .and unary_expression .and .true .emit OP_MULTIPLY;
-multiplicative_expression_3
-    slash .and unary_expression .and .true .emit OP_DIVIDE;
-multiplicative_expression_4
-    percent .and unary_expression .and .true .emit OP_MODULUS;
-
-unary_expression
-    primary_expression .or unary_expression_1 .or unary_expression_2 .or unary_expression_3 .or
-    unary_expression_4;
-unary_expression_1
-    plus .and unary_expression .and .true .emit OP_PLUS;
-unary_expression_2
-    dash .and unary_expression .and .true .emit OP_MINUS;
-unary_expression_3
-    bang .and unary_expression .and .true .emit OP_NEGATE;
-unary_expression_4
-    tilda .and unary_expression .and .true .emit OP_COMPLEMENT;
-
-primary_expression
-   intconstant .or primary_expression_1;
-primary_expression_1
-   lparen .and logical_or_expression .and rparen;
-
-intconstant
-   integer .emit OP_PUSHINT;
-
-integer
-   integer_dec;
-
-integer_dec
-   digit_dec .emit 10 .emit * .and .loop digit_dec .emit * .and .true .emit '\0';
-
-digit_dec
-   '0'-'9';
-
-optional_space
-   .loop single_space;
-
-space
-   single_space .and .loop single_space;
-
-single_space
-   ' ' .or '\t';
-
-ampersand
-   optional_space .and '&' .and optional_space;
-
-ampersandampersand
-   optional_space .and '&' .and '&' .and optional_space;
-
-bang
-   optional_space .and '!' .and optional_space;
-
-bangequals
-   optional_space .and '!' .and '=' .and optional_space;
-
-bar
-   optional_space .and '|' .and optional_space;
-
-barbar
-   optional_space .and '|' .and '|' .and optional_space;
-
-caret
-   optional_space .and '^' .and optional_space;
-
-dash
-   optional_space .and '-' .and optional_space;
-
-equalsequals
-   optional_space .and '=' .and '=' .and optional_space;
-
-greater
-   optional_space .and '>' .and optional_space;
-
-greaterequals
-   optional_space .and '>' .and '=' .and optional_space;
-
-greatergreater
-   optional_space .and '>' .and '>' .and optional_space;
-
-less
-   optional_space .and '<' .and optional_space;
-
-lessequals
-   optional_space .and '<' .and '=' .and optional_space;
-
-lessless
-   optional_space .and '<' .and '<' .and optional_space;
-
-lparen
-   optional_space .and '(' .and optional_space;
-
-percent
-   optional_space .and '%' .and optional_space;
-
-plus
-   optional_space .and '+' .and optional_space;
-
-rparen
-   optional_space .and ')' .and optional_space;
-
-slash
-   optional_space .and '/' .and optional_space;
-
-star
-   optional_space .and '*' .and optional_space;
-
-tilda
-   optional_space .and '~' .and optional_space;
-
diff --git a/src/mesa/shader/slang/library/slang_pp_expression_syn.h b/src/mesa/shader/slang/library/slang_pp_expression_syn.h
deleted file mode 100644 (file)
index f3e9ef6..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-
-/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED FROM THE .syn FILE */
-
-".syntax expression;\n"
-".emtcode EXP_END 0\n"
-".emtcode EXP_EXPRESSION 1\n"
-".emtcode OP_END 0\n"
-".emtcode OP_PUSHINT 1\n"
-".emtcode OP_LOGICALOR 2\n"
-".emtcode OP_LOGICALAND 3\n"
-".emtcode OP_OR 4\n"
-".emtcode OP_XOR 5\n"
-".emtcode OP_AND 6\n"
-".emtcode OP_EQUAL 7\n"
-".emtcode OP_NOTEQUAL 8\n"
-".emtcode OP_LESSEQUAL 9\n"
-".emtcode OP_GREATEREQUAL 10\n"
-".emtcode OP_LESS 11\n"
-".emtcode OP_GREATER 12\n"
-".emtcode OP_LEFTSHIFT 13\n"
-".emtcode OP_RIGHTSHIFT 14\n"
-".emtcode OP_ADD 15\n"
-".emtcode OP_SUBTRACT 16\n"
-".emtcode OP_MULTIPLY 17\n"
-".emtcode OP_DIVIDE 18\n"
-".emtcode OP_MODULUS 19\n"
-".emtcode OP_PLUS 20\n"
-".emtcode OP_MINUS 21\n"
-".emtcode OP_NEGATE 22\n"
-".emtcode OP_COMPLEMENT 23\n"
-"expression\n"
-" first_expression .and optional_second_expression .and optional_space .and '\\0' .emit EXP_END;\n"
-"first_expression\n"
-" optional_space .and logical_or_expression .emit EXP_EXPRESSION .and .true .emit OP_END;\n"
-"optional_second_expression\n"
-" second_expression .or .true;\n"
-"second_expression\n"
-" space .and logical_or_expression .emit EXP_EXPRESSION .and .true .emit OP_END;\n"
-"logical_or_expression\n"
-" logical_and_expression .and .loop logical_or_expression_1;\n"
-"logical_or_expression_1\n"
-" barbar .and logical_and_expression .and .true .emit OP_LOGICALOR;\n"
-"logical_and_expression\n"
-" or_expression .and .loop logical_and_expression_1;\n"
-"logical_and_expression_1\n"
-" ampersandampersand .and or_expression .and .true .emit OP_LOGICALAND;\n"
-"or_expression\n"
-" xor_expression .and .loop or_expression_1;\n"
-"or_expression_1\n"
-" bar .and xor_expression .and .true .emit OP_OR;\n"
-"xor_expression\n"
-" and_expression .and .loop xor_expression_1;\n"
-"xor_expression_1\n"
-" caret .and and_expression .and .true .emit OP_XOR;\n"
-"and_expression\n"
-" equality_expression .and .loop and_expression_1;\n"
-"and_expression_1\n"
-" ampersand .and equality_expression .and .true .emit OP_AND;\n"
-"equality_expression\n"
-" relational_expression .and .loop equality_expression_1;\n"
-"equality_expression_1\n"
-" equality_expression_2 .or equality_expression_3;\n"
-"equality_expression_2\n"
-" equalsequals .and relational_expression .and .true .emit OP_EQUAL;\n"
-"equality_expression_3\n"
-" bangequals .and relational_expression .and .true .emit OP_NOTEQUAL;\n"
-"relational_expression\n"
-" shift_expression .and .loop relational_expression_1;\n"
-"relational_expression_1\n"
-" relational_expression_2 .or relational_expression_3 .or relational_expression_4 .or\n"
-" relational_expression_5;\n"
-"relational_expression_2\n"
-" lessequals .and shift_expression .and .true .emit OP_LESSEQUAL;\n"
-"relational_expression_3\n"
-" greaterequals .and shift_expression .and .true .emit OP_GREATEREQUAL;\n"
-"relational_expression_4\n"
-" less .and shift_expression .and .true .emit OP_LESS;\n"
-"relational_expression_5\n"
-" greater .and shift_expression .and .true .emit OP_GREATER;\n"
-"shift_expression\n"
-" additive_expression .and .loop shift_expression_1;\n"
-"shift_expression_1\n"
-" shift_expression_2 .or shift_expression_3;\n"
-"shift_expression_2\n"
-" lessless .and additive_expression .and .true .emit OP_LEFTSHIFT;\n"
-"shift_expression_3\n"
-" greatergreater .and additive_expression .and .true .emit OP_RIGHTSHIFT;\n"
-"additive_expression\n"
-" multiplicative_expression .and .loop additive_expression_1;\n"
-"additive_expression_1\n"
-" additive_expression_2 .or additive_expression_3;\n"
-"additive_expression_2\n"
-" plus .and multiplicative_expression .and .true .emit OP_ADD;\n"
-"additive_expression_3\n"
-" dash .and multiplicative_expression .and .true .emit OP_SUBTRACT;\n"
-"multiplicative_expression\n"
-" unary_expression .and .loop multiplicative_expression_1;\n"
-"multiplicative_expression_1\n"
-" multiplicative_expression_2 .or multiplicative_expression_3 .or multiplicative_expression_4;\n"
-"multiplicative_expression_2\n"
-" star .and unary_expression .and .true .emit OP_MULTIPLY;\n"
-"multiplicative_expression_3\n"
-" slash .and unary_expression .and .true .emit OP_DIVIDE;\n"
-"multiplicative_expression_4\n"
-" percent .and unary_expression .and .true .emit OP_MODULUS;\n"
-"unary_expression\n"
-" primary_expression .or unary_expression_1 .or unary_expression_2 .or unary_expression_3 .or\n"
-" unary_expression_4;\n"
-"unary_expression_1\n"
-" plus .and unary_expression .and .true .emit OP_PLUS;\n"
-"unary_expression_2\n"
-" dash .and unary_expression .and .true .emit OP_MINUS;\n"
-"unary_expression_3\n"
-" bang .and unary_expression .and .true .emit OP_NEGATE;\n"
-"unary_expression_4\n"
-" tilda .and unary_expression .and .true .emit OP_COMPLEMENT;\n"
-"primary_expression\n"
-" intconstant .or primary_expression_1;\n"
-"primary_expression_1\n"
-" lparen .and logical_or_expression .and rparen;\n"
-"intconstant\n"
-" integer .emit OP_PUSHINT;\n"
-"integer\n"
-" integer_dec;\n"
-"integer_dec\n"
-" digit_dec .emit 10 .emit * .and .loop digit_dec .emit * .and .true .emit '\\0';\n"
-"digit_dec\n"
-" '0'-'9';\n"
-"optional_space\n"
-" .loop single_space;\n"
-"space\n"
-" single_space .and .loop single_space;\n"
-"single_space\n"
-" ' ' .or '\\t';\n"
-"ampersand\n"
-" optional_space .and '&' .and optional_space;\n"
-"ampersandampersand\n"
-" optional_space .and '&' .and '&' .and optional_space;\n"
-"bang\n"
-" optional_space .and '!' .and optional_space;\n"
-"bangequals\n"
-" optional_space .and '!' .and '=' .and optional_space;\n"
-"bar\n"
-" optional_space .and '|' .and optional_space;\n"
-"barbar\n"
-" optional_space .and '|' .and '|' .and optional_space;\n"
-"caret\n"
-" optional_space .and '^' .and optional_space;\n"
-"dash\n"
-" optional_space .and '-' .and optional_space;\n"
-"equalsequals\n"
-" optional_space .and '=' .and '=' .and optional_space;\n"
-"greater\n"
-" optional_space .and '>' .and optional_space;\n"
-"greaterequals\n"
-" optional_space .and '>' .and '=' .and optional_space;\n"
-"greatergreater\n"
-" optional_space .and '>' .and '>' .and optional_space;\n"
-"less\n"
-" optional_space .and '<' .and optional_space;\n"
-"lessequals\n"
-" optional_space .and '<' .and '=' .and optional_space;\n"
-"lessless\n"
-" optional_space .and '<' .and '<' .and optional_space;\n"
-"lparen\n"
-" optional_space .and '(' .and optional_space;\n"
-"percent\n"
-" optional_space .and '%' .and optional_space;\n"
-"plus\n"
-" optional_space .and '+' .and optional_space;\n"
-"rparen\n"
-" optional_space .and ')' .and optional_space;\n"
-"slash\n"
-" optional_space .and '/' .and optional_space;\n"
-"star\n"
-" optional_space .and '*' .and optional_space;\n"
-"tilda\n"
-" optional_space .and '~' .and optional_space;\n"
-""
diff --git a/src/mesa/shader/slang/library/slang_pp_version.syn b/src/mesa/shader/slang/library/slang_pp_version.syn
deleted file mode 100644 (file)
index 3fe1a57..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version:  6.6
- *
- * Copyright (C) 2005-2006  Brian Paul   All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/**
- * \file slang_pp_version.syn
- * slang #version directive syntax
- * \author Michal Krol
- */
-
-.syntax version_directive;
-
-version_directive
-       version_directive_1;
-version_directive_1
-       prior_optional_spaces .and optional_version_directive .and .true .emit $;
-
-optional_version_directive
-       version_directive_body .or .true .emit 10 .emit 1;
-
-version_directive_body
-       '#' .and optional_space .and "version" .and space .and version_number .and optional_space .and
-       new_line;
-
-version_number
-       version_number_100 .or version_number_110 .or version_number_120;
-
-version_number_100
-       leading_zeroes .and "100" .emit 0 .emit 1;
-
-version_number_110
-       leading_zeroes .and "110" .emit 10 .emit 1;
-
-version_number_120
-       leading_zeroes .and "120" .emit 20 .emit 1;
-
-leading_zeroes
-       .loop zero;
-
-zero
-       '0';
-
-space
-    single_space .and .loop single_space;
-
-optional_space
-    .loop single_space;
-
-single_space
-    ' ' .or '\t';
-
-prior_optional_spaces
-       .loop prior_space;
-
-prior_space
-       c_style_comment_block .or cpp_style_comment_block .or space .or new_line;
-
-c_style_comment_block
-    '/' .and '*' .and c_style_comment_rest;
-
-c_style_comment_rest
-    .loop c_style_comment_char_no_star .and c_style_comment_rest_1;
-c_style_comment_rest_1
-    c_style_comment_end .or c_style_comment_rest_2;
-c_style_comment_rest_2
-    '*' .and c_style_comment_rest;
-
-c_style_comment_char_no_star
-    '\x2B'-'\xFF' .or '\x01'-'\x29';
-
-c_style_comment_end
-    '*' .and '/';
-
-cpp_style_comment_block
-    '/' .and '/' .and cpp_style_comment_block_1;
-cpp_style_comment_block_1
-    cpp_style_comment_block_2 .or cpp_style_comment_block_3;
-cpp_style_comment_block_2
-    .loop cpp_style_comment_char .and new_line;
-cpp_style_comment_block_3
-    .loop cpp_style_comment_char;
-
-cpp_style_comment_char
-    '\x0E'-'\xFF' .or '\x01'-'\x09' .or '\x0B'-'\x0C';
-
-new_line
-    cr_lf .or lf_cr .or '\n' .or '\r';
-
-cr_lf
-    '\r' .and '\n';
-
-lf_cr
-       '\n' .and '\r';
-
-.string __string_filter;
-
-__string_filter
-    .loop __identifier_char;
-
-__identifier_char
-    'a'-'z' .or 'A'-'Z' .or '_' .or '0'-'9';
-
diff --git a/src/mesa/shader/slang/library/slang_pp_version_syn.h b/src/mesa/shader/slang/library/slang_pp_version_syn.h
deleted file mode 100644 (file)
index 54aee3f..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-
-/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED FROM THE .syn FILE */
-
-".syntax version_directive;\n"
-"version_directive\n"
-"      version_directive_1;\n"
-"version_directive_1\n"
-"      prior_optional_spaces .and optional_version_directive .and .true .emit $;\n"
-"optional_version_directive\n"
-"      version_directive_body .or .true .emit 10 .emit 1;\n"
-"version_directive_body\n"
-"      '#' .and optional_space .and \"version\" .and space .and version_number .and optional_space .and\n"
-"      new_line;\n"
-"version_number\n"
-"      version_number_100 .or version_number_110 .or version_number_120;\n"
-"version_number_100\n"
-"      leading_zeroes .and \"100\" .emit 0 .emit 1;\n"
-"version_number_110\n"
-"      leading_zeroes .and \"110\" .emit 10 .emit 1;\n"
-"version_number_120\n"
-"      leading_zeroes .and \"120\" .emit 20 .emit 1;\n"
-"leading_zeroes\n"
-"      .loop zero;\n"
-"zero\n"
-"      '0';\n"
-"space\n"
-" single_space .and .loop single_space;\n"
-"optional_space\n"
-" .loop single_space;\n"
-"single_space\n"
-" ' ' .or '\\t';\n"
-"prior_optional_spaces\n"
-"      .loop prior_space;\n"
-"prior_space\n"
-"      c_style_comment_block .or cpp_style_comment_block .or space .or new_line;\n"
-"c_style_comment_block\n"
-" '/' .and '*' .and c_style_comment_rest;\n"
-"c_style_comment_rest\n"
-" .loop c_style_comment_char_no_star .and c_style_comment_rest_1;\n"
-"c_style_comment_rest_1\n"
-" c_style_comment_end .or c_style_comment_rest_2;\n"
-"c_style_comment_rest_2\n"
-" '*' .and c_style_comment_rest;\n"
-"c_style_comment_char_no_star\n"
-" '\\x2B'-'\\xFF' .or '\\x01'-'\\x29';\n"
-"c_style_comment_end\n"
-" '*' .and '/';\n"
-"cpp_style_comment_block\n"
-" '/' .and '/' .and cpp_style_comment_block_1;\n"
-"cpp_style_comment_block_1\n"
-" cpp_style_comment_block_2 .or cpp_style_comment_block_3;\n"
-"cpp_style_comment_block_2\n"
-" .loop cpp_style_comment_char .and new_line;\n"
-"cpp_style_comment_block_3\n"
-" .loop cpp_style_comment_char;\n"
-"cpp_style_comment_char\n"
-" '\\x0E'-'\\xFF' .or '\\x01'-'\\x09' .or '\\x0B'-'\\x0C';\n"
-"new_line\n"
-" cr_lf .or lf_cr .or '\\n' .or '\\r';\n"
-"cr_lf\n"
-" '\\r' .and '\\n';\n"
-"lf_cr\n"
-"      '\\n' .and '\\r';\n"
-".string __string_filter;\n"
-"__string_filter\n"
-" .loop __identifier_char;\n"
-"__identifier_char\n"
-" 'a'-'z' .or 'A'-'Z' .or '_' .or '0'-'9';\n"
-""
diff --git a/src/mesa/shader/slang/library/slang_shader.syn b/src/mesa/shader/slang/library/slang_shader.syn
deleted file mode 100644 (file)
index cc5c70a..0000000
+++ /dev/null
@@ -1,1716 +0,0 @@
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 2004-2006  Brian Paul   All Rights Reserved.
- * Copyright (C) 2008 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, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/*
- * \file slang_shader.syn
- * slang vertex/fragment shader syntax
- * \author Michal Krol
- */
-
-/*
- * usage:
- *   syn2c slang_shader.syn > slang_shader_syn.h
- *
- * when modifying or extending this file, several things must be taken into
- * consideration:
- *
- * - when adding new operators that were marked as reserved in the
- *   initial specification, one must only uncomment particular lines of
- *   code that refer to operators being added;
- *
- * - when adding new shader targets, one must reserve a new value for
- *   shader_type register and use it in .if constructs for symbols that
- *   are exclusive for that shader;
- *
- * - some symbols mimic output of other symbols - the best example is
- *   the "for" construct: expression "for (foo(); ; bar())" is seen as
- *   "for (foo(); true; bar())" by the output processor - hence, special
- *   care must be taken when rearranging output of essential symbols;
- *
- * - order of single-quoted tokens does matter in alternatives - so do not
- *   parse "<" operator before "<<" and "<<" before "<<=";
- *
- * - all double-quoted tokens are internally preprocessed to eliminate
- *   problems with parsing strings that are prefixes of other strings,
- *   like "sampler1D" and "sampler1DShadow";
- */
-
-.syntax translation_unit;
-
-/* revision number - increment after each change affecting emitted output */
-.emtcode REVISION                                   5
-
-/* external declaration (or precision or invariant stmt) */
-.emtcode EXTERNAL_NULL                              0
-.emtcode EXTERNAL_FUNCTION_DEFINITION               1
-.emtcode EXTERNAL_DECLARATION                       2
-.emtcode DEFAULT_PRECISION                          3
-.emtcode INVARIANT_STMT                             4
-
-/* precision */
-.emtcode PRECISION_DEFAULT                          0
-.emtcode PRECISION_LOW                              1
-.emtcode PRECISION_MEDIUM                           2
-.emtcode PRECISION_HIGH                             3
-
-/* declaration */
-.emtcode DECLARATION_FUNCTION_PROTOTYPE             1
-.emtcode DECLARATION_INIT_DECLARATOR_LIST           2
-
-/* function type */
-.emtcode FUNCTION_ORDINARY                          0
-.emtcode FUNCTION_CONSTRUCTOR                       1
-.emtcode FUNCTION_OPERATOR                          2
-
-/* function call type */
-.emtcode FUNCTION_CALL_NONARRAY                     0
-.emtcode FUNCTION_CALL_ARRAY                        1
-
-/* operator type */
-.emtcode OPERATOR_ADDASSIGN                         1
-.emtcode OPERATOR_SUBASSIGN                         2
-.emtcode OPERATOR_MULASSIGN                         3
-.emtcode OPERATOR_DIVASSIGN                         4
-/*.emtcode OPERATOR_MODASSIGN                         5*/
-/*.emtcode OPERATOR_LSHASSIGN                         6*/
-/*.emtcode OPERATOR_RSHASSIGN                         7*/
-/*.emtcode OPERATOR_ORASSIGN                          8*/
-/*.emtcode OPERATOR_XORASSIGN                         9*/
-/*.emtcode OPERATOR_ANDASSIGN                         10*/
-.emtcode OPERATOR_LOGICALXOR                        11
-/*.emtcode OPERATOR_BITOR                             12*/
-/*.emtcode OPERATOR_BITXOR                            13*/
-/*.emtcode OPERATOR_BITAND                            14*/
-.emtcode OPERATOR_LESS                              15
-.emtcode OPERATOR_GREATER                           16
-.emtcode OPERATOR_LESSEQUAL                         17
-.emtcode OPERATOR_GREATEREQUAL                      18
-/*.emtcode OPERATOR_LSHIFT                            19*/
-/*.emtcode OPERATOR_RSHIFT                            20*/
-.emtcode OPERATOR_MULTIPLY                          21
-.emtcode OPERATOR_DIVIDE                            22
-/*.emtcode OPERATOR_MODULUS                           23*/
-.emtcode OPERATOR_INCREMENT                         24
-.emtcode OPERATOR_DECREMENT                         25
-.emtcode OPERATOR_PLUS                              26
-.emtcode OPERATOR_MINUS                             27
-/*.emtcode OPERATOR_COMPLEMENT                        28*/
-.emtcode OPERATOR_NOT                               29
-
-/* init declarator list */
-.emtcode DECLARATOR_NONE                            0
-.emtcode DECLARATOR_NEXT                            1
-
-/* variable declaration */
-.emtcode VARIABLE_NONE                              0
-.emtcode VARIABLE_IDENTIFIER                        1
-.emtcode VARIABLE_INITIALIZER                       2
-.emtcode VARIABLE_ARRAY_EXPLICIT                    3
-.emtcode VARIABLE_ARRAY_UNKNOWN                     4
-
-/* type qualifier */
-.emtcode TYPE_QUALIFIER_NONE                        0
-.emtcode TYPE_QUALIFIER_CONST                       1
-.emtcode TYPE_QUALIFIER_ATTRIBUTE                   2
-.emtcode TYPE_QUALIFIER_VARYING                     3
-.emtcode TYPE_QUALIFIER_UNIFORM                     4
-.emtcode TYPE_QUALIFIER_FIXEDOUTPUT                 5
-.emtcode TYPE_QUALIFIER_FIXEDINPUT                  6
-
-/* invariant qualifier */
-.emtcode TYPE_VARIANT                               90
-.emtcode TYPE_INVARIANT                             91
-
-/* centroid qualifier */
-.emtcode TYPE_CENTER                                95
-.emtcode TYPE_CENTROID                              96
-
-/* type specifier */
-.emtcode TYPE_SPECIFIER_VOID                        0
-.emtcode TYPE_SPECIFIER_BOOL                        1
-.emtcode TYPE_SPECIFIER_BVEC2                       2
-.emtcode TYPE_SPECIFIER_BVEC3                       3
-.emtcode TYPE_SPECIFIER_BVEC4                       4
-.emtcode TYPE_SPECIFIER_INT                         5
-.emtcode TYPE_SPECIFIER_IVEC2                       6
-.emtcode TYPE_SPECIFIER_IVEC3                       7
-.emtcode TYPE_SPECIFIER_IVEC4                       8
-.emtcode TYPE_SPECIFIER_FLOAT                       9
-.emtcode TYPE_SPECIFIER_VEC2                        10
-.emtcode TYPE_SPECIFIER_VEC3                        11
-.emtcode TYPE_SPECIFIER_VEC4                        12
-.emtcode TYPE_SPECIFIER_MAT2                        13
-.emtcode TYPE_SPECIFIER_MAT3                        14
-.emtcode TYPE_SPECIFIER_MAT4                        15
-.emtcode TYPE_SPECIFIER_SAMPLER1D                   16
-.emtcode TYPE_SPECIFIER_SAMPLER2D                   17
-.emtcode TYPE_SPECIFIER_SAMPLER3D                   18
-.emtcode TYPE_SPECIFIER_SAMPLERCUBE                 19
-.emtcode TYPE_SPECIFIER_SAMPLER1DSHADOW             20
-.emtcode TYPE_SPECIFIER_SAMPLER2DSHADOW             21
-.emtcode TYPE_SPECIFIER_SAMPLER2DRECT               22
-.emtcode TYPE_SPECIFIER_SAMPLER2DRECTSHADOW         23
-.emtcode TYPE_SPECIFIER_STRUCT                      24
-.emtcode TYPE_SPECIFIER_TYPENAME                    25
-
-/* OpenGL 2.1 */
-.emtcode TYPE_SPECIFIER_MAT23                       26
-.emtcode TYPE_SPECIFIER_MAT32                       27
-.emtcode TYPE_SPECIFIER_MAT24                       28
-.emtcode TYPE_SPECIFIER_MAT42                       29
-.emtcode TYPE_SPECIFIER_MAT34                       30
-.emtcode TYPE_SPECIFIER_MAT43                       31
-
-/* type specifier array */
-.emtcode TYPE_SPECIFIER_NONARRAY                    0
-.emtcode TYPE_SPECIFIER_ARRAY                       1
-
-/* structure field */
-.emtcode FIELD_NONE                                 0
-.emtcode FIELD_NEXT                                 1
-.emtcode FIELD_ARRAY                                2
-
-/* operation */
-.emtcode OP_END                                     0
-.emtcode OP_BLOCK_BEGIN_NO_NEW_SCOPE                1
-.emtcode OP_BLOCK_BEGIN_NEW_SCOPE                   2
-.emtcode OP_DECLARE                                 3
-.emtcode OP_ASM                                     4
-.emtcode OP_BREAK                                   5
-.emtcode OP_CONTINUE                                6
-.emtcode OP_DISCARD                                 7
-.emtcode OP_RETURN                                  8
-.emtcode OP_EXPRESSION                              9
-.emtcode OP_IF                                      10
-.emtcode OP_WHILE                                   11
-.emtcode OP_DO                                      12
-.emtcode OP_FOR                                     13
-.emtcode OP_PUSH_VOID                               14
-.emtcode OP_PUSH_BOOL                               15
-.emtcode OP_PUSH_INT                                16
-.emtcode OP_PUSH_FLOAT                              17
-.emtcode OP_PUSH_IDENTIFIER                         18
-.emtcode OP_SEQUENCE                                19
-.emtcode OP_ASSIGN                                  20
-.emtcode OP_ADDASSIGN                               21
-.emtcode OP_SUBASSIGN                               22
-.emtcode OP_MULASSIGN                               23
-.emtcode OP_DIVASSIGN                               24
-/*.emtcode OP_MODASSIGN                               25*/
-/*.emtcode OP_LSHASSIGN                               26*/
-/*.emtcode OP_RSHASSIGN                               27*/
-/*.emtcode OP_ORASSIGN                                28*/
-/*.emtcode OP_XORASSIGN                               29*/
-/*.emtcode OP_ANDASSIGN                               30*/
-.emtcode OP_SELECT                                  31
-.emtcode OP_LOGICALOR                               32
-.emtcode OP_LOGICALXOR                              33
-.emtcode OP_LOGICALAND                              34
-/*.emtcode OP_BITOR                                   35*/
-/*.emtcode OP_BITXOR                                  36*/
-/*.emtcode OP_BITAND                                  37*/
-.emtcode OP_EQUAL                                   38
-.emtcode OP_NOTEQUAL                                39
-.emtcode OP_LESS                                    40
-.emtcode OP_GREATER                                 41
-.emtcode OP_LESSEQUAL                               42
-.emtcode OP_GREATEREQUAL                            43
-/*.emtcode OP_LSHIFT                                  44*/
-/*.emtcode OP_RSHIFT                                  45*/
-.emtcode OP_ADD                                     46
-.emtcode OP_SUBTRACT                                47
-.emtcode OP_MULTIPLY                                48
-.emtcode OP_DIVIDE                                  49
-/*.emtcode OP_MODULUS                                 50*/
-.emtcode OP_PREINCREMENT                            51
-.emtcode OP_PREDECREMENT                            52
-.emtcode OP_PLUS                                    53
-.emtcode OP_MINUS                                   54
-/*.emtcode OP_COMPLEMENT                              55*/
-.emtcode OP_NOT                                     56
-.emtcode OP_SUBSCRIPT                               57
-.emtcode OP_CALL                                    58
-.emtcode OP_FIELD                                   59
-.emtcode OP_POSTINCREMENT                           60
-.emtcode OP_POSTDECREMENT                           61
-.emtcode OP_PRECISION                               62
-.emtcode OP_METHOD                                  63
-
-/* parameter qualifier */
-.emtcode PARAM_QUALIFIER_IN                         0
-.emtcode PARAM_QUALIFIER_OUT                        1
-.emtcode PARAM_QUALIFIER_INOUT                      2
-
-/* function parameter */
-.emtcode PARAMETER_NONE                             0
-.emtcode PARAMETER_NEXT                             1
-
-/* function parameter array presence */
-.emtcode PARAMETER_ARRAY_NOT_PRESENT                0
-.emtcode PARAMETER_ARRAY_PRESENT                    1
-
-/* INVALID_EXTERNAL_DECLARATION seems to be reported when there's */
-/* any syntax errors... */
-.errtext INVALID_EXTERNAL_DECLARATION               "2001: Syntax error."
-.errtext INVALID_OPERATOR_OVERRIDE                  "2002: Invalid operator override."
-.errtext LBRACE_EXPECTED                            "2003: '{' expected but '$err_token$' found."
-.errtext LPAREN_EXPECTED                            "2004: '(' expected but '$err_token$' found."
-.errtext RPAREN_EXPECTED                            "2005: ')' expected but '$err_token$' found."
-.errtext INVALID_PRECISION                          "2006: Invalid precision specifier '$err_token$'."
-.errtext INVALID_PRECISION_TYPE                     "2007: Invalid precision type '$err_token$'."
-
-
-/*
- * tells whether the shader that is being parsed is a built-in shader or not
- *  0 - normal behaviour
- *  1 - accepts constructor and operator definitions and __asm statements
- * the implementation will set it to 1 when compiling internal built-in shaders
- */
-.regbyte parsing_builtin                            0
-
-/*
- * holds the type of the shader being parsed; possible values are
- * listed below.
- *   FRAGMENT_SHADER            1
- *   VERTEX_SHADER              2
- * shader type is set by the caller before parsing
- */
-.regbyte shader_type                                0
-
-/*
- * <variable_identifier> ::= <identifier>
- */
-variable_identifier
-    identifier .emit OP_PUSH_IDENTIFIER;
-
-/*
- *  <primary_expression> ::= <variable_identifier>
- *                         | <intconstant>
- *                         | <floatconstant>
- *                         | <boolconstant>
- *                         | "(" <expression> ")"
- */
-primary_expression
-    floatconstant .or boolconstant .or intconstant .or variable_identifier .or primary_expression_1;
-primary_expression_1
-    lparen .and expression .and rparen;
-
-/*
- * <postfix_expression> ::= <primary_expression>
- *                        | <postfix_expression> "[" <integer_expression> "]"
- *                        | <function_call>
- *                        | <postfix_expression> "." <field_selection>
- *                        | <postfix_expression> "++"
- *                        | <postfix_expression> "--"
- */
-postfix_expression
-    postfix_expression_1 .and .loop postfix_expression_2;
-postfix_expression_1
-    function_call .or primary_expression;
-postfix_expression_2
-    postfix_expression_3 .or postfix_expression_4 .or
-    plusplus .emit OP_POSTINCREMENT .or
-    minusminus .emit OP_POSTDECREMENT;
-postfix_expression_3
-    lbracket .and integer_expression .and rbracket .emit OP_SUBSCRIPT;
-postfix_expression_4
-    dot .and field_selection .emit OP_FIELD;
-
-/*
- * <integer_expression> ::= <expression>
- */
-integer_expression
-    expression;
-
-/*
- * <function_call> ::= <function_call_generic>
- */
-function_call
-    function_call_or_method;
-
-/*
- * <function_call_or_method> ::= <regular_function_call>
- *                             | <postfix_expression> "." <function_call_generic>
- */
-function_call_or_method
-    regular_function_call .or method_call;
-
-/*
- * <method_call> ::= <identifier> "." <function_call_generic>
- */
-method_call
-    identifier .emit OP_METHOD .and dot .and function_call_generic .and .true .emit OP_END;
-
-/*
- * <regular_function_call> ::= <function_call_generic>
- */
-regular_function_call
-    function_call_generic .emit OP_CALL .and .true .emit OP_END;
-
-/*
- * <function_call_generic> ::= <function_call_header_with_parameters> ")"
- *                           | <function_call_header_no_parameters> ")"
- */
-function_call_generic
-    function_call_generic_1 .or function_call_generic_2;
-function_call_generic_1
-    function_call_header_with_parameters .and rparen .error RPAREN_EXPECTED;
-function_call_generic_2
-    function_call_header_no_parameters .and rparen .error RPAREN_EXPECTED;
-
-/*
- * <function_call_header_no_parameters>::= <function_call_header> "void"
- *                                        | <function_call_header>
- */
-function_call_header_no_parameters
-    function_call_header .and function_call_header_no_parameters_1;
-function_call_header_no_parameters_1
-    "void" .or .true;
-
-/*
- * <function_call_header_with_parameters> ::= <function_call_header> <assignment_expression>
- *                                          | <function_call_header_with_parameters> "," <assignment_expression>
- */
-function_call_header_with_parameters
-    function_call_header .and assignment_expression .and .true .emit OP_END .and
-    .loop function_call_header_with_parameters_1;
-function_call_header_with_parameters_1
-    comma .and assignment_expression .and .true .emit OP_END;
-
-/*
- * <function_call_header> ::= <function_identifier> "("
- */
-function_call_header
-    function_identifier .and lparen;
-
-/*
- * <function_identifier> ::= <constructor_identifier>
- *                         | <identifier>
- *                         | <type_specifier>
- *
- * note: <constructor_identifier> and <type_specifier> have been deleted
- */
-function_identifier
-    identifier .and function_identifier_opt_array;
-function_identifier_opt_array
-    function_identifier_array .emit FUNCTION_CALL_ARRAY .or
-    .true .emit FUNCTION_CALL_NONARRAY;
-function_identifier_array
-    lbracket .and constant_expression .and rbracket;
-
-/*
- * <unary_expression> ::= <postfix_expression>
- *                      | "++" <unary_expression>
- *                      | "--" <unary_expression>
- *                      | <unary_operator> <unary_expression>
- *
- * <unary_operator>   ::= "+"
- *                      | "-"
- *                      | "!"
- *                      | "~" // reserved
- */
-unary_expression
-    postfix_expression .or unary_expression_1 .or unary_expression_2 .or unary_expression_3 .or
-    unary_expression_4 .or unary_expression_5/* .or unary_expression_6*/;
-unary_expression_1
-    plusplus .and unary_expression .and .true .emit OP_PREINCREMENT;
-unary_expression_2
-    minusminus .and unary_expression .and .true .emit OP_PREDECREMENT;
-unary_expression_3
-    plus .and unary_expression .and .true .emit OP_PLUS;
-unary_expression_4
-    minus .and unary_expression .and .true .emit OP_MINUS;
-unary_expression_5
-    bang .and unary_expression .and .true .emit OP_NOT;
-/*unary_expression_6
-    tilde .and unary_expression .and .true .emit OP_COMPLEMENT;*/
-
-/*
- * <multiplicative_expression> ::= <unary_expression>
- *                               | <multiplicative_expression> "*" <unary_expression>
- *                               | <multiplicative_expression> "/" <unary_expression>
- *                               | <multiplicative_expression> "%" <unary_expression> // reserved
- */
-multiplicative_expression
-    unary_expression .and .loop multiplicative_expression_1;
-multiplicative_expression_1
-    multiplicative_expression_2 .or multiplicative_expression_3/* .or multiplicative_expression_4*/;
-multiplicative_expression_2
-    star .and unary_expression .and .true .emit OP_MULTIPLY;
-multiplicative_expression_3
-    slash .and unary_expression .and .true .emit OP_DIVIDE;
-/*multiplicative_expression_4
-    percent .and unary_expression .and .true .emit OP_MODULUS;*/
-
-/*
- * <additive_expression> ::= <multiplicative_expression>
- *                         | <additive_expression> "+" <multiplicative_expression>
- *                         | <additive_expression> "-" <multiplicative_expression>
- */
-additive_expression
-    multiplicative_expression .and .loop additive_expression_1;
-additive_expression_1
-    additive_expression_2 .or additive_expression_3;
-additive_expression_2
-    plus .and multiplicative_expression .and .true .emit OP_ADD;
-additive_expression_3
-    minus .and multiplicative_expression .and .true .emit OP_SUBTRACT;
-
-/*
- * <shift_expression> ::= <additive_expression>
- *                      | <shift_expression> "<<" <additive_expression> // reserved
- *                      | <shift_expression> ">>" <additive_expression> // reserved
- */
-shift_expression
-    additive_expression/* .and .loop shift_expression_1*/;
-/*shift_expression_1
-    shift_expression_2 .or shift_expression_3;*/
-/*shift_expression_2
-    lessless .and additive_expression .and .true .emit OP_LSHIFT;*/
-/*shift_expression_3
-    greatergreater .and additive_expression .and .true .emit OP_RSHIFT;*/
-
-/*
- * <relational_expression> ::= <shift_expression>
- *                           | <relational_expression> "<" <shift_expression>
- *                           | <relational_expression> ">" <shift_expression>
- *                           | <relational_expression> "<=" <shift_expression>
- *                           | <relational_expression> ">=" <shift_expression>
- */
-relational_expression
-    shift_expression .and .loop relational_expression_1;
-relational_expression_1
-    relational_expression_2 .or relational_expression_3 .or relational_expression_4 .or
-    relational_expression_5;
-relational_expression_2
-    lessequals .and shift_expression .and .true .emit OP_LESSEQUAL;
-relational_expression_3
-    greaterequals .and shift_expression .and .true .emit OP_GREATEREQUAL;
-relational_expression_4
-    less .and shift_expression .and .true .emit OP_LESS;
-relational_expression_5
-    greater .and shift_expression .and .true .emit OP_GREATER;
-
-/*
- * <equality_expression> ::= <relational_expression>
- *                         | <equality_expression> "==" <relational_expression>
- *                         | <equality_expression> "!=" <relational_expression>
- */
-equality_expression
-    relational_expression .and .loop equality_expression_1;
-equality_expression_1
-    equality_expression_2 .or equality_expression_3;
-equality_expression_2
-    equalsequals .and relational_expression .and .true .emit OP_EQUAL;
-equality_expression_3
-    bangequals .and relational_expression .and .true .emit OP_NOTEQUAL;
-
-/*
- * <and_expression> ::= <equality_expression>
- *                    | <and_expression> "&" <equality_expression> // reserved
- */
-and_expression
-    equality_expression/* .and .loop and_expression_1*/;
-/*and_expression_1
-    ampersand .and equality_expression .and .true .emit OP_BITAND;*/
-
-/*
- * <exclusive_or_expression> ::= <and_expression>
- *                             | <exclusive_or_expression> "^" <and_expression> // reserved
- */
-exclusive_or_expression
-    and_expression/* .and .loop exclusive_or_expression_1*/;
-/*exclusive_or_expression_1
-    caret .and and_expression .and .true .emit OP_BITXOR;*/
-
-/*
- * <inclusive_or_expression> ::= <exclusive_or_expression>
- *                             | <inclusive_or_expression> "|" <exclusive_or_expression> // reserved
- */
-inclusive_or_expression
-    exclusive_or_expression/* .and .loop inclusive_or_expression_1*/;
-/*inclusive_or_expression_1
-    bar .and exclusive_or_expression .and .true .emit OP_BITOR;*/
-
-/*
- * <logical_and_expression> ::= <inclusive_or_expression>
- *                            | <logical_and_expression> "&&" <inclusive_or_expression>
- */
-logical_and_expression
-    inclusive_or_expression .and .loop logical_and_expression_1;
-logical_and_expression_1
-    ampersandampersand .and inclusive_or_expression .and .true .emit OP_LOGICALAND;
-
-/*
- * <logical_xor_expression> ::= <logical_and_expression>
- *                            | <logical_xor_expression> "^^" <logical_and_expression>
- */
-logical_xor_expression
-    logical_and_expression .and .loop logical_xor_expression_1;
-logical_xor_expression_1
-    caretcaret .and logical_and_expression .and .true .emit OP_LOGICALXOR;
-
-/*
- * <logical_or_expression> ::= <logical_xor_expression>
- *                           | <logical_or_expression> "||" <logical_xor_expression>
- */
-logical_or_expression
-    logical_xor_expression .and .loop logical_or_expression_1;
-logical_or_expression_1
-    barbar .and logical_xor_expression .and .true .emit OP_LOGICALOR;
-
-/*
- * <conditional_expression> ::= <logical_or_expression>
- *                            | <logical_or_expression> "?" <expression> ":" <conditional_expression>
- */
-conditional_expression
-    logical_or_expression .and .loop conditional_expression_1;
-conditional_expression_1
-    question .and expression .and colon .and conditional_expression .and .true .emit OP_SELECT;
-
-/*
- * <assignment_expression> ::= <conditional_expression>
- *                           | <unary_expression> <assignment_operator> <assignment_expression>
- *
- * <assignment_operator> ::= "="
- *                         | "*="
- *                         | "/="
- *                         | "+="
- *                         | "-="
- *                         | "%=" // reserved
- *                         | "<<=" // reserved
- *                         | ">>=" // reserved
- *                         | "&=" // reserved
- *                         | "^=" // reserved
- *                         | "|=" // reserved
- */
-assignment_expression
-    assignment_expression_1 .or assignment_expression_2 .or assignment_expression_3 .or
-    assignment_expression_4 .or assignment_expression_5/* .or assignment_expression_6 .or
-    assignment_expression_7 .or assignment_expression_8 .or assignment_expression_9 .or
-    assignment_expression_10 .or assignment_expression_11*/ .or conditional_expression;
-assignment_expression_1
-    unary_expression .and equals .and assignment_expression .and .true .emit OP_ASSIGN;
-assignment_expression_2
-    unary_expression .and starequals .and assignment_expression .and .true .emit OP_MULASSIGN;
-assignment_expression_3
-    unary_expression .and slashequals .and assignment_expression .and .true .emit OP_DIVASSIGN;
-assignment_expression_4
-    unary_expression .and plusequals .and assignment_expression .and .true .emit OP_ADDASSIGN;
-assignment_expression_5
-    unary_expression .and minusequals .and assignment_expression .and .true .emit OP_SUBASSIGN;
-/*assignment_expression_6
-    unary_expression .and percentequals .and assignment_expression .and .true .emit OP_MODASSIGN;*/
-/*assignment_expression_7
-    unary_expression .and lesslessequals .and assignment_expression .and .true .emit OP_LSHASSIGN;*/
-/*assignment_expression_8
-    unary_expression .and greatergreaterequals .and assignment_expression .and
-    .true .emit OP_RSHASSIGN;*/
-/*assignment_expression_9
-    unary_expression .and ampersandequals .and assignment_expression .and .true .emit OP_ANDASSIGN;*/
-/*assignment_expression_10
-    unary_expression .and caretequals .and assignment_expression .and .true .emit OP_XORASSIGN;*/
-/*assignment_expression_11
-    unary_expression .and barequals .and assignment_expression .and .true .emit OP_ORASSIGN;*/
-
-/*
- * <expression> ::= <assignment_expression>
- *                | <expression> "," <assignment_expression>
- */
-expression
-    assignment_expression .and .loop expression_1;
-expression_1
-    comma .and assignment_expression .and .true .emit OP_SEQUENCE;
-
-/*
- * <constant_expression> ::= <conditional_expression>
- */
-constant_expression
-    conditional_expression .and .true .emit OP_END;
-
-/*
- * <declaration> ::= <function_prototype> ";"
- *                 | <init_declarator_list> ";"
- */
-declaration
-    declaration_1 .or declaration_2;
-declaration_1
-    function_prototype .emit DECLARATION_FUNCTION_PROTOTYPE .and semicolon;
-declaration_2
-    init_declarator_list .emit DECLARATION_INIT_DECLARATOR_LIST .and semicolon;
-
-/*
- * <function_prototype> ::= <function_header> "void" ")"
- *                        | <function_declarator> ")"
- */
-function_prototype
-    function_prototype_1 .or function_prototype_2;
-function_prototype_1
-    function_header .and "void" .and rparen .error RPAREN_EXPECTED .emit PARAMETER_NONE;
-function_prototype_2
-    function_declarator .and rparen .error RPAREN_EXPECTED .emit PARAMETER_NONE;
-
-/*
- * <function_declarator> ::= <function_header>
- *                         | <function_header_with_parameters>
- */
-function_declarator
-    function_header_with_parameters .or function_header;
-
-/*
- * <function_header_with_parameters> ::= <function_header> <parameter_declaration>
- *                                     | <function_header_with_parameters> ","
- *                                       <parameter_declaration>
- */
-function_header_with_parameters
-    function_header .and parameter_declaration .and .loop function_header_with_parameters_1;
-function_header_with_parameters_1
-    comma .and parameter_declaration;
-
-/*
- * <function_header> ::= <fully_specified_type> <identifier> "("
- */
-function_header
-    function_header_nospace .or function_header_space;
-function_header_space
-    fully_specified_type_space .and space .and function_decl_identifier .and lparen;
-function_header_nospace
-    fully_specified_type_nospace .and function_decl_identifier .and lparen;
-
-/*
- * <function_decl_identifier> ::= "__constructor"
- *                              | <__operator>
- *                              | <identifier>
- *
- * note: this is an extension to the standard language specification.
- * normally slang disallows operator and constructor prototypes and definitions
- */
-function_decl_identifier
-    .if (parsing_builtin != 0) __operator .emit FUNCTION_OPERATOR .or
-    .if (parsing_builtin != 0) "__constructor" .emit FUNCTION_CONSTRUCTOR .or
-    identifier .emit FUNCTION_ORDINARY;
-
-/*
- * <__operator> ::= "__operator" <overriden_op>
- *
- * note: this is an extension to the standard language specification.
- * normally slang disallows operator prototypes and definitions
- */
-__operator
-    "__operator" .and overriden_operator .error INVALID_OPERATOR_OVERRIDE;
-
-/*
- * <overriden_op> ::= "="
- *                  | "+="
- *                  | "-="
- *                  | "*="
- *                  | "/="
- *                  | "%=" // reserved
- *                  | "<<=" // reserved
- *                  | ">>=" // reserved
- *                  | "&=" // reserved
- *                  | "^=" // reserved
- *                  | "|=" // reserved
- *                  | "^^"
- *                  | "|" // reserved
- *                  | "^" // reserved
- *                  | "&" // reserved
- *                  | "=="
- *                  | "!="
- *                  | "<"
- *                  | ">"
- *                  | "<="
- *                  | ">="
- *                  | "<<" // reserved
- *                  | ">>" // reserved
- *                  | "*"
- *                  | "/"
- *                  | "%" // reserved
- *                  | "++"
- *                  | "--"
- *                  | "+"
- *                  | "-"
- *                  | "~" // reserved
- *                  | "!"
- *
- * note: this is an extension to the standard language specification.
- * normally slang disallows operator prototypes and definitions
- */
-overriden_operator
-    plusplus .emit OPERATOR_INCREMENT .or
-    plusequals .emit OPERATOR_ADDASSIGN .or
-    plus .emit OPERATOR_PLUS .or
-    minusminus .emit OPERATOR_DECREMENT .or
-    minusequals .emit OPERATOR_SUBASSIGN .or
-    minus .emit OPERATOR_MINUS .or
-    bang .emit OPERATOR_NOT .or
-    starequals .emit OPERATOR_MULASSIGN .or
-    star .emit OPERATOR_MULTIPLY .or
-    slashequals .emit OPERATOR_DIVASSIGN .or
-    slash .emit OPERATOR_DIVIDE .or
-    lessequals .emit OPERATOR_LESSEQUAL .or
-    /*lesslessequals .emit OPERATOR_LSHASSIGN .or*/
-    /*lessless .emit OPERATOR_LSHIFT .or*/
-    less .emit OPERATOR_LESS .or
-    greaterequals .emit OPERATOR_GREATEREQUAL .or
-    /*greatergreaterequals .emit OPERATOR_RSHASSIGN .or*/
-    /*greatergreater .emit OPERATOR_RSHIFT .or*/
-    greater .emit OPERATOR_GREATER .or
-    /*percentequals .emit OPERATOR_MODASSIGN .or*/
-    /*percent .emit OPERATOR_MODULUS .or*/
-    /*ampersandequals .emit OPERATOR_ANDASSIGN */
-    /*ampersand .emit OPERATOR_BITAND .or*/
-    /*barequals .emit OPERATOR_ORASSIGN .or*/
-    /*bar .emit OPERATOR_BITOR .or*/
-    /*tilde .emit OPERATOR_COMPLEMENT .or*/
-    /*caretequals .emit OPERATOR_XORASSIGN .or*/
-    caretcaret .emit OPERATOR_LOGICALXOR /*.or
-    caret .emit OPERATOR_BITXOR*/;
-
-/*
- * <parameter_declarator> ::= <type_specifier> <identifier>
- *                          | <type_specifier> <identifier> "[" <constant_expression> "]"
- */
-parameter_declarator
-    parameter_declarator_nospace .or parameter_declarator_space;
-parameter_declarator_nospace
-    type_specifier_nospace .and identifier .and parameter_declarator_1;
-parameter_declarator_space
-    type_specifier_space .and space .and identifier .and parameter_declarator_1;
-parameter_declarator_1
-    parameter_declarator_2 .emit PARAMETER_ARRAY_PRESENT .or
-    .true .emit PARAMETER_ARRAY_NOT_PRESENT;
-parameter_declarator_2
-    lbracket .and constant_expression .and rbracket;
-
-/*
- * <parameter_declaration> ::= <type_qualifier> <parameter_qualifier>
- *                             <precision> <parameter_declarator>
- *                           | <type_qualifier> <parameter_qualifier>
- *                             <precision> <parameter_type_specifier>
- *                           | <type_qualifier> <parameter_qualifier>
- *                             <parameter_declarator>
- *                           | <type_qualifier> <parameter_qualifier>
- *                             <parameter_type_specifier>
- *                           | <parameter_qualifier> <precision>
- *                             <parameter_declarator>
- *                           | <parameter_qualifier> <precision>
- *                             <parameter_type_specifier>
- *                           | <parameter_qualifier> <parameter_declarator>
- *                           | <parameter_qualifier> <parameter_type_specifier>
- */
-parameter_declaration
-    parameter_declaration_1 .emit PARAMETER_NEXT;
-parameter_declaration_1
-    parameter_declaration_2 .or parameter_declaration_3;
-parameter_declaration_2
-    type_qualifier .and space .and parameter_qualifier .and parameter_declaration_4;
-parameter_declaration_3
-    parameter_qualifier .emit TYPE_QUALIFIER_NONE .and parameter_declaration_4;
-parameter_declaration_4
-    parameter_declaration_optprec .and parameter_declaration_rest;
-parameter_declaration_optprec
-    parameter_declaration_prec .or .true .emit PRECISION_DEFAULT;
-parameter_declaration_prec
-    precision .and space;
-parameter_declaration_rest
-    parameter_declarator .or parameter_type_specifier;
-
-/*
- * <parameter_qualifier> ::= "in"
- *                         | "out"
- *                         | "inout"
- *                         | ""
- */
-parameter_qualifier
-    parameter_qualifier_1 .or .true .emit PARAM_QUALIFIER_IN;
-parameter_qualifier_1
-    parameter_qualifier_2 .and space;
-parameter_qualifier_2
-    "in" .emit PARAM_QUALIFIER_IN .or
-    "out" .emit PARAM_QUALIFIER_OUT .or
-    "inout" .emit PARAM_QUALIFIER_INOUT;
-
-/*
- * <parameter_type_specifier> ::= <type_specifier>
- *                              | <type_specifier> "[" <constant_expression> "]"
- */
-parameter_type_specifier
-    parameter_type_specifier_1 .and .true .emit '\0' .and parameter_type_specifier_2;
-parameter_type_specifier_1
-    type_specifier_nospace .or type_specifier_space;
-parameter_type_specifier_2
-    parameter_type_specifier_3 .emit PARAMETER_ARRAY_PRESENT .or
-    .true .emit PARAMETER_ARRAY_NOT_PRESENT;
-parameter_type_specifier_3
-    lbracket .and constant_expression .and rbracket;
-
-/*
- * <init_declarator_list> ::= <single_declaration>
- *                          | <init_declarator_list> "," <identifier>
- *                          | <init_declarator_list> "," <identifier> "[" "]"
- *                          | <init_declarator_list> "," <identifier> "[" <constant_expression> "]"
- *                          | <init_declarator_list> "," <identifier> "=" <initializer>
- */
-init_declarator_list
-    single_declaration .and .loop init_declarator_list_1 .emit DECLARATOR_NEXT .and
-    .true .emit DECLARATOR_NONE;
-init_declarator_list_1
-    comma .and identifier .emit VARIABLE_IDENTIFIER .and init_declarator_list_2;
-init_declarator_list_2
-    init_declarator_list_3 .or init_declarator_list_4 .or .true .emit VARIABLE_NONE;
-init_declarator_list_3
-    equals .and initializer .emit VARIABLE_INITIALIZER;
-init_declarator_list_4
-    lbracket .and init_declarator_list_5 .and rbracket;
-init_declarator_list_5
-    constant_expression .emit VARIABLE_ARRAY_EXPLICIT .or .true .emit VARIABLE_ARRAY_UNKNOWN;
-
-/*
- * <single_declaration> ::= <fully_specified_type>
- *                        | <fully_specified_type> <identifier>
- *                        | <fully_specified_type> <identifier> "[" "]"
- *                        | <fully_specified_type> <identifier> "[" <constant_expression> "]"
- *                        | <fully_specified_type> <identifier> "=" <initializer>
- */
-single_declaration
-    single_declaration_nospace .or single_declaration_space;
-single_declaration_space
-    fully_specified_type_space .and single_declaration_space_1;
-single_declaration_nospace
-    fully_specified_type_nospace .and single_declaration_nospace_1;
-single_declaration_space_1
-    single_declaration_space_2 .emit VARIABLE_IDENTIFIER .or .true .emit VARIABLE_NONE;
-single_declaration_nospace_1
-    single_declaration_nospace_2 .emit VARIABLE_IDENTIFIER .or .true .emit VARIABLE_NONE;
-single_declaration_space_2
-    space .and identifier .and single_declaration_3;
-single_declaration_nospace_2
-    identifier .and single_declaration_3;
-single_declaration_3
-    single_declaration_4 .or single_declaration_5 .or .true .emit VARIABLE_NONE;
-single_declaration_4
-    equals .and initializer .emit VARIABLE_INITIALIZER;
-single_declaration_5
-    lbracket .and single_declaration_6 .and rbracket;
-single_declaration_6
-    constant_expression .emit VARIABLE_ARRAY_EXPLICIT .or .true .emit VARIABLE_ARRAY_UNKNOWN;
-
-/*
- * <fully_specified_type> ::= <opt_invariant> <opt_centroid> <opt_qualifer> <opt_precision> <type_specifier>
- *
- * Example: "invariant varying highp vec3"
- */
-fully_specified_type_space
-    fully_specified_type_optinvariant .and fully_specified_type_optcentroid .and fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier_space;
-fully_specified_type_nospace
-    fully_specified_type_optinvariant .and fully_specified_type_optcentroid .and fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier_nospace;
-fully_specified_type_optinvariant
-    fully_specified_type_invariant .or .true .emit TYPE_VARIANT;
-fully_specified_type_invariant
-    invariant_qualifier .and space;
-fully_specified_type_optcentroid
-    fully_specified_type_centroid .or .true .emit TYPE_CENTER;
-fully_specified_type_centroid
-    centroid_qualifier .and space;
-fully_specified_type_optqual
-    fully_specified_type_qual .or .true .emit TYPE_QUALIFIER_NONE;
-fully_specified_type_qual
-    type_qualifier .and space;
-fully_specified_type_optprec
-    fully_specified_type_prec .or .true .emit PRECISION_DEFAULT;
-fully_specified_type_prec
-    precision .and space;
-
-/*
- * <invariant_qualifier> ::= "invariant"
- */
-invariant_qualifier
-    "invariant" .emit TYPE_INVARIANT;
-
-centroid_qualifier
-    "centroid" .emit TYPE_CENTROID;
-
-
-/*
- * <type_qualifier> ::= "const"
- *                    | "attribute" // Vertex only.
- *                    | "varying"
- *                    | "uniform"
- *                    | "__fixed_output"
- *                    | "__fixed_input"
- *
- * note: this is an extension to the standard language specification,
- * normally slang disallows __fixed_output and __fixed_input type qualifiers
- */
-type_qualifier
-    "const" .emit TYPE_QUALIFIER_CONST .or
-    .if (shader_type == 2) "attribute" .emit TYPE_QUALIFIER_ATTRIBUTE .or
-    "varying" .emit TYPE_QUALIFIER_VARYING .or
-    "uniform" .emit TYPE_QUALIFIER_UNIFORM .or
-    .if (parsing_builtin != 0) "__fixed_output" .emit TYPE_QUALIFIER_FIXEDOUTPUT .or
-    .if (parsing_builtin != 0) "__fixed_input" .emit TYPE_QUALIFIER_FIXEDINPUT;
-
-/*
- * <type_specifier_nonarray> ::= "void"
- *                             | "float"
- *                             | "int"
- *                             | "bool"
- *                             | "vec2"
- *                             | "vec3"
- *                             | "vec4"
- *                             | "bvec2"
- *                             | "bvec3"
- *                             | "bvec4"
- *                             | "ivec2"
- *                             | "ivec3"
- *                             | "ivec4"
- *                             | "mat2"
- *                             | "mat3"
- *                             | "mat4"
- *                             | "mat2x3"
- *                             | "mat3x2"
- *                             | "mat2x4"
- *                             | "mat4x2"
- *                             | "mat3x4"
- *                             | "mat4x3"
- *                             | "sampler1D"
- *                             | "sampler2D"
- *                             | "sampler3D"
- *                             | "samplerCube"
- *                             | "sampler1DShadow"
- *                             | "sampler2DShadow"
- *                             | "sampler2DRect"
- *                             | "sampler2DRectShadow"
- *                             | <struct_specifier>
- *                             | <type_name>
- */
-type_specifier_nonarray_space
-    "void" .emit TYPE_SPECIFIER_VOID .or
-    "float" .emit TYPE_SPECIFIER_FLOAT .or
-    "int" .emit TYPE_SPECIFIER_INT .or
-    "bool" .emit TYPE_SPECIFIER_BOOL .or
-    "vec2" .emit TYPE_SPECIFIER_VEC2 .or
-    "vec3" .emit TYPE_SPECIFIER_VEC3 .or
-    "vec4" .emit TYPE_SPECIFIER_VEC4 .or
-    "bvec2" .emit TYPE_SPECIFIER_BVEC2 .or
-    "bvec3" .emit TYPE_SPECIFIER_BVEC3 .or
-    "bvec4" .emit TYPE_SPECIFIER_BVEC4 .or
-    "ivec2" .emit TYPE_SPECIFIER_IVEC2 .or
-    "ivec3" .emit TYPE_SPECIFIER_IVEC3 .or
-    "ivec4" .emit TYPE_SPECIFIER_IVEC4 .or
-    "mat2" .emit TYPE_SPECIFIER_MAT2 .or
-    "mat3" .emit TYPE_SPECIFIER_MAT3 .or
-    "mat4" .emit TYPE_SPECIFIER_MAT4 .or
-    "mat2x3" .emit TYPE_SPECIFIER_MAT23 .or
-    "mat3x2" .emit TYPE_SPECIFIER_MAT32 .or
-    "mat2x4" .emit TYPE_SPECIFIER_MAT24 .or
-    "mat4x2" .emit TYPE_SPECIFIER_MAT42 .or
-    "mat3x4" .emit TYPE_SPECIFIER_MAT34 .or
-    "mat4x3" .emit TYPE_SPECIFIER_MAT43 .or
-    "sampler1D" .emit TYPE_SPECIFIER_SAMPLER1D .or
-    "sampler2D" .emit TYPE_SPECIFIER_SAMPLER2D .or
-    "sampler3D" .emit TYPE_SPECIFIER_SAMPLER3D .or
-    "samplerCube" .emit TYPE_SPECIFIER_SAMPLERCUBE .or
-    "sampler1DShadow" .emit TYPE_SPECIFIER_SAMPLER1DSHADOW .or
-    "sampler2DShadow" .emit TYPE_SPECIFIER_SAMPLER2DSHADOW .or
-    "sampler2DRect" .emit TYPE_SPECIFIER_SAMPLER2DRECT .or
-    "sampler2DRectShadow" .emit TYPE_SPECIFIER_SAMPLER2DRECTSHADOW .or
-    type_name .emit TYPE_SPECIFIER_TYPENAME;
-type_specifier_nonarray_nospace
-    struct_specifier .emit TYPE_SPECIFIER_STRUCT;
-type_specifier_nonarray
-    type_specifier_nonarray_nospace .or type_specifier_nonarray_space;
-
-/*
- * <type_specifier> ::= <type_specifier_nonarray>
- *                    | <type_specifier_nonarray> "[" <constant_expression> "]"
- */
-type_specifier_space
-    type_specifier_nonarray_space .and .true .emit TYPE_SPECIFIER_NONARRAY;
-type_specifier_nospace
-    type_specifier_nospace_array .or type_specifier_nospace_1;
-type_specifier_nospace_1
-    type_specifier_nonarray_nospace .and .true .emit TYPE_SPECIFIER_NONARRAY;
-type_specifier_nospace_array
-    type_specifier_nonarray .and lbracket .emit TYPE_SPECIFIER_ARRAY .and constant_expression .and rbracket;
-
-/*
- * <struct_specifier> ::= "struct" <identifier> "{" <struct_declaration_list> "}"
- *                      | "struct" "{" <struct_declaration_list> "}"
- */
-struct_specifier
-    "struct" .and struct_specifier_1 .and optional_space .and lbrace .error LBRACE_EXPECTED .and
-    struct_declaration_list .and rbrace .emit FIELD_NONE;
-struct_specifier_1
-    struct_specifier_2 .or .true .emit '\0';
-struct_specifier_2
-    space .and identifier;
-
-/*
- * <struct_declaration_list> ::= <struct_declaration>
- *                             | <struct_declaration_list> <struct_declaration>
- */
-struct_declaration_list
-    struct_declaration .and .loop struct_declaration .emit FIELD_NEXT;
-
-/*
- * <struct_declaration> ::= <type_specifier> <struct_declarator_list> ";"
- */
-struct_declaration
-    struct_declaration_nospace .or struct_declaration_space;
-struct_declaration_space
-    type_specifier_space .and space .and struct_declarator_list .and semicolon .emit FIELD_NONE;
-struct_declaration_nospace
-    type_specifier_nospace .and struct_declarator_list .and semicolon .emit FIELD_NONE;
-
-/*
- * <struct_declarator_list> ::= <struct_declarator>
- *                            | <struct_declarator_list> "," <struct_declarator>
- */
-struct_declarator_list
-    struct_declarator .and .loop struct_declarator_list_1 .emit FIELD_NEXT;
-struct_declarator_list_1
-    comma .and struct_declarator;
-
-/*
- * <struct_declarator> ::= <identifier>
- *                       | <identifier> "[" <constant_expression> "]"
- */
-struct_declarator
-    identifier .and struct_declarator_1;
-struct_declarator_1
-    struct_declarator_2 .emit FIELD_ARRAY .or .true .emit FIELD_NONE;
-struct_declarator_2
-    lbracket .and constant_expression .and rbracket;
-
-/*
- * <initializer> ::= <assignment_expression>
- */
-initializer
-    assignment_expression .and .true .emit OP_END;
-
-/*
- * <declaration_statement> ::= <declaration>
- */
-declaration_statement
-    declaration;
-
-/*
- * <statement> ::= <compound_statement>
- *               | <simple_statement>
- */
-statement
-    compound_statement .or simple_statement;
-statement_space
-    compound_statement .or statement_space_1;
-statement_space_1
-    space .and simple_statement;
-
-/*
- * <simple_statement> ::= <__asm_statement>
- *                      | <selection_statement>
- *                      | <iteration_statement>
- *                      | <jump_statement>
- *                      | <expression_statement>
- *                      | <declaration_statement>
- *
- * note: this is an extension to the standard language specification.
- * normally slang disallows use of __asm statements
- */
-simple_statement
-    .if (parsing_builtin != 0) __asm_statement .emit OP_ASM .or
-    selection_statement .or
-    iteration_statement .or
-    precision_stmt .emit OP_PRECISION .or
-    jump_statement .or
-    expression_statement .emit OP_EXPRESSION .or
-    declaration_statement .emit OP_DECLARE;
-
-/*
- * <compound_statement> ::= "{" "}"
- *                        | "{" <statement_list> "}"
- */
-compound_statement
-    compound_statement_1 .emit OP_BLOCK_BEGIN_NEW_SCOPE .and .true .emit OP_END;
-compound_statement_1
-    compound_statement_2 .or compound_statement_3;
-compound_statement_2
-    lbrace .and rbrace;
-compound_statement_3
-    lbrace .and statement_list .and rbrace;
-
-/*
- * <compound_statement_no_new_scope> ::= "{" "}"
- *                                     | "{" <statement_list> "}"
- */
-compound_statement_no_new_scope
-    compound_statement_no_new_scope_1 .emit OP_BLOCK_BEGIN_NO_NEW_SCOPE .and .true .emit OP_END;
-compound_statement_no_new_scope_1
-    compound_statement_no_new_scope_2 .or compound_statement_no_new_scope_3;
-compound_statement_no_new_scope_2
-    lbrace .and rbrace;
-compound_statement_no_new_scope_3
-    lbrace .and statement_list .and rbrace;
-
-
-/*
- * <statement_list> ::= <statement>
- *                    | <statement_list> <statement>
- */
-statement_list
-    statement .and .loop statement;
-
-/*
- * <expression_statement> ::= ";"
- *                          | <expression> ";"
- */
-expression_statement
-    expression_statement_1 .or expression_statement_2;
-expression_statement_1
-    semicolon .emit OP_PUSH_VOID .emit OP_END;
-expression_statement_2
-    expression .and semicolon .emit OP_END;
-
-/*
- * <selection_statement> ::= "if" "(" <expression> ")" <selection_rest_statement>
- */
-selection_statement
-    "if" .emit OP_IF .and lparen .error LPAREN_EXPECTED .and expression .and
-    rparen .error RPAREN_EXPECTED .emit OP_END .and selection_rest_statement;
-
-/*
- * <selection_rest_statement> ::= <statement> "else" <statement>
- *                              | <statement>
- */
-selection_rest_statement
-    statement .and selection_rest_statement_1;
-selection_rest_statement_1
-    selection_rest_statement_2 .or .true .emit OP_EXPRESSION .emit OP_PUSH_VOID .emit OP_END;
-selection_rest_statement_2
-    "else" .and optional_space .and statement;
-
-/*
- * <condition> ::= <expression>
- *               | <fully_specified_type> <identifier> "=" <initializer>
- *
- * note: if <condition_1> is executed, the emit format must
- * match <declaration> emit format
- */
-condition
-    condition_1 .emit OP_DECLARE .emit DECLARATION_INIT_DECLARATOR_LIST .or
-    condition_3 .emit OP_EXPRESSION;
-condition_1
-    condition_1_nospace .or condition_1_space;
-condition_1_nospace
-    fully_specified_type_nospace .and condition_2;
-condition_1_space
-    fully_specified_type_space .and space .and condition_2;
-condition_2
-    identifier .emit VARIABLE_IDENTIFIER .and equals .emit VARIABLE_INITIALIZER .and
-    initializer .and .true .emit DECLARATOR_NONE;
-condition_3
-    expression .and .true .emit OP_END;
-
-/*
- * <iteration_statement> ::= "while" "(" <condition> ")" <statement>
- *                         | "do" <statement> "while" "(" <expression> ")" ";"
- *                         | "for" "(" <for_init_statement> <for_rest_statement> ")" <statement>
- */
-iteration_statement
-    iteration_statement_1 .or iteration_statement_2 .or iteration_statement_3;
-iteration_statement_1
-    "while" .emit OP_WHILE .and lparen .error LPAREN_EXPECTED .and condition .and
-    rparen .error RPAREN_EXPECTED .and statement;
-iteration_statement_2
-    "do" .emit OP_DO .and statement_space .and "while" .and lparen .error LPAREN_EXPECTED .and
-    expression .and rparen .error RPAREN_EXPECTED .emit OP_END .and semicolon;
-iteration_statement_3
-    "for" .emit OP_FOR .and lparen .error LPAREN_EXPECTED .and for_init_statement .and
-    for_rest_statement .and rparen .error RPAREN_EXPECTED .and statement;
-
-/*
- * <for_init_statement> ::= <expression_statement>
- *                        | <declaration_statement>
- */
-for_init_statement
-    expression_statement .emit OP_EXPRESSION .or declaration_statement .emit OP_DECLARE;
-
-/*
- * <conditionopt> ::= <condition>
- *                  | ""
- *
- * note: <conditionopt> is used only by "for" statement.
- * if <condition> is ommitted, parser simulates default behaviour,
- * that is simulates "true" expression
- */
-conditionopt
-    condition .or
-    .true .emit OP_EXPRESSION .emit OP_PUSH_BOOL .emit 2 .emit '1' .emit '\0' .emit OP_END;
-
-/*
- * <for_rest_statement> ::= <conditionopt> ";"
- *                        | <conditionopt> ";" <expression>
- */
-for_rest_statement
-    conditionopt .and semicolon .and for_rest_statement_1;
-for_rest_statement_1
-    for_rest_statement_2 .or .true .emit OP_PUSH_VOID .emit OP_END;
-for_rest_statement_2
-    expression .and .true .emit OP_END;
-
-/*
- * <jump_statement> ::= "continue" ";"
- *                    | "break" ";"
- *                    | "return" ";"
- *                    | "return" <expression> ";"
- *                    | "discard" ";" // Fragment shader only.
- */
-jump_statement
-    jump_statement_1 .or jump_statement_2 .or jump_statement_3 .or jump_statement_4 .or
-    .if (shader_type == 1) jump_statement_5;
-jump_statement_1
-    "continue" .and semicolon .emit OP_CONTINUE;
-jump_statement_2
-    "break" .and semicolon .emit OP_BREAK;
-jump_statement_3
-    "return" .emit OP_RETURN .and optional_space .and expression .and semicolon .emit OP_END;
-jump_statement_4
-    "return" .emit OP_RETURN .and semicolon .emit OP_PUSH_VOID .emit OP_END;
-jump_statement_5
-    "discard" .and semicolon .emit OP_DISCARD;
-
-/*
- * <__asm_statement> ::= "__asm" <identifier> <asm_arguments> ";"
- *
- * note: this is an extension to the standard language specification.
- * normally slang disallows __asm statements
- */
-__asm_statement
-    "__asm" .and space .and identifier .and space .and asm_arguments .and semicolon .emit OP_END;
-
-/*
- * <asm_arguments> ::= <asm_argument>
- *                   | <asm_arguments> "," <asm_argument>
- *
- * note: this is an extension to the standard language specification.
- * normally slang disallows __asm statements
- */
-asm_arguments
-    asm_argument .and .true .emit OP_END .and .loop asm_arguments_1;
-asm_arguments_1
-    comma .and asm_argument .and .true .emit OP_END;
-
-/*
- * <asm_argument> ::= <variable_identifier>
- *                  | <floatconstant>
- *
- * note: this is an extension to the standard language specification.
- * normally slang disallows __asm statements
- */
-asm_argument
-    var_with_field .or
-    variable_identifier .or
-    floatconstant;
-
-var_with_field
-    variable_identifier .and dot .and field_selection .emit OP_FIELD;
-
-
-/*
- * <translation_unit> ::= <external_declaration>
- *                      | <translation_unit> <external_declaration>
- */
-translation_unit
-    optional_space .emit REVISION .and external_declaration .error INVALID_EXTERNAL_DECLARATION .and
-    .loop external_declaration .and optional_space .and
-    '\0' .error INVALID_EXTERNAL_DECLARATION .emit EXTERNAL_NULL;
-
-
-/*
- * <external_declaration> ::= <function_definition>
- *                          | <declaration>
- */
-external_declaration
-    precision_stmt .emit DEFAULT_PRECISION .or
-    function_definition .emit EXTERNAL_FUNCTION_DEFINITION .or
-    invariant_stmt .emit INVARIANT_STMT .or
-    declaration .emit EXTERNAL_DECLARATION;
-
-
-/*
- * <precision_stmt> ::= "precision" <precision> <prectype>
- */
-precision_stmt
-    "precision" .and space .and precision .error INVALID_PRECISION .and space .and prectype .error INVALID_PRECISION_TYPE .and semicolon;
-
-/*
- * <precision> ::= "lowp"
- *               | "mediump"
- *               | "highp"
- */
-precision
-    "lowp" .emit PRECISION_LOW .or
-    "mediump" .emit PRECISION_MEDIUM .or
-    "highp" .emit PRECISION_HIGH;
-
-/*
- * <prectype> ::= "int"
- *              | "float"
- *              | "a sampler type"
- */
-prectype
-    "int" .emit TYPE_SPECIFIER_INT .or
-    "float" .emit TYPE_SPECIFIER_FLOAT .or
-    "sampler1D" .emit TYPE_SPECIFIER_SAMPLER1D .or
-    "sampler2D" .emit TYPE_SPECIFIER_SAMPLER2D .or
-    "sampler3D" .emit TYPE_SPECIFIER_SAMPLER3D .or
-    "samplerCube" .emit TYPE_SPECIFIER_SAMPLERCUBE .or
-    "sampler1DShadow" .emit TYPE_SPECIFIER_SAMPLER1DSHADOW .or
-    "sampler2DShadow" .emit TYPE_SPECIFIER_SAMPLER2DSHADOW .or
-    "sampler2DRect" .emit TYPE_SPECIFIER_SAMPLER2DRECT .or
-    "sampler2DRectShadow" .emit TYPE_SPECIFIER_SAMPLER2DRECTSHADOW;
-
-
-/*
- * <invariant_stmt> ::= "invariant" identifier;
- */
-invariant_stmt
-    "invariant" .and space .and identifier .and semicolon;
-
-
-/*
- * <function_definition> :: <function_prototype> <compound_statement_no_new_scope>
- */
-function_definition
-    function_prototype .and compound_statement_no_new_scope;
-
-
-
-/*
- * helper rules, not part of the official language syntax
- */
-
-digit_oct
-    '0'-'7';
-
-digit_dec
-    '0'-'9';
-
-digit_hex
-    '0'-'9' .or 'A'-'F' .or 'a'-'f';
-
-id_character_first
-    'a'-'z' .or 'A'-'Z' .or '_';
-
-id_character_next
-    id_character_first .or digit_dec;
-
-identifier
-    id_character_first .emit * .and .loop id_character_next .emit * .and .true .emit '\0';
-
-float
-    float_1 .or float_2 .or float_3;
-float_1
-    float_fractional_constant .and float_optional_exponent_part .and optional_f_suffix;
-float_2
-    float_digit_sequence .and .true .emit '\0' .and float_exponent_part .and optional_f_suffix;
-float_3
-    float_digit_sequence .and .true .emit '\0' .and 'f' .emit '\0';
-
-float_fractional_constant
-    float_fractional_constant_1 .or float_fractional_constant_2 .or float_fractional_constant_3;
-float_fractional_constant_1
-    float_digit_sequence .and '.' .and float_digit_sequence;
-float_fractional_constant_2
-    float_digit_sequence .and '.' .and .true .emit '\0';
-float_fractional_constant_3
-    '.' .emit '\0' .and float_digit_sequence;
-
-float_optional_exponent_part
-    float_exponent_part .or .true .emit '\0';
-
-float_digit_sequence
-    digit_dec .emit * .and .loop digit_dec .emit * .and .true .emit '\0';
-
-float_exponent_part
-    float_exponent_part_1 .or float_exponent_part_2;
-float_exponent_part_1
-    'e' .and float_optional_sign .and float_digit_sequence;
-float_exponent_part_2
-    'E' .and float_optional_sign .and float_digit_sequence;
-
-float_optional_sign
-    float_sign .or .true;
-
-float_sign
-    '+' .or '-' .emit '-';
-
-optional_f_suffix
-    'f' .or .true;
-
-
-integer
-    integer_hex .or integer_oct .or integer_dec;
-
-integer_hex
-    '0' .and integer_hex_1 .emit 0x10 .and digit_hex .emit * .and .loop digit_hex .emit * .and
-    .true .emit '\0';
-integer_hex_1
-    'x' .or 'X';
-
-integer_oct
-    '0' .emit 8 .emit * .and .loop digit_oct .emit * .and .true .emit '\0';
-
-integer_dec
-    digit_dec .emit 10 .emit * .and .loop digit_dec .emit * .and .true .emit '\0';
-
-boolean
-    "true" .emit 2 .emit '1' .emit '\0' .or
-    "false" .emit 2 .emit '0' .emit '\0';
-
-type_name
-    identifier;
-
-field_selection
-    identifier;
-
-floatconstant
-    float .emit OP_PUSH_FLOAT;
-
-intconstant
-    integer .emit OP_PUSH_INT;
-
-boolconstant
-    boolean .emit OP_PUSH_BOOL;
-
-optional_space
-    .loop single_space;
-
-space
-    single_space .and .loop single_space;
-
-single_space
-    white_char .or c_style_comment_block .or cpp_style_comment_block;
-
-white_char
-    ' ' .or '\t' .or new_line .or '\v' .or '\f';
-
-new_line
-    cr_lf .or lf_cr .or '\n' .or '\r';
-
-cr_lf
-    '\r' .and '\n';
-
-lf_cr
-    '\n' .and '\r';
-
-c_style_comment_block
-    '/' .and '*' .and c_style_comment_rest;
-
-c_style_comment_rest
-    .loop c_style_comment_char_no_star .and c_style_comment_rest_1;
-c_style_comment_rest_1
-    c_style_comment_end .or c_style_comment_rest_2;
-c_style_comment_rest_2
-    '*' .and c_style_comment_rest;
-
-c_style_comment_char_no_star
-    '\x2B'-'\xFF' .or '\x01'-'\x29';
-
-c_style_comment_end
-    '*' .and '/';
-
-cpp_style_comment_block
-    '/' .and '/' .and cpp_style_comment_block_1;
-cpp_style_comment_block_1
-    cpp_style_comment_block_2 .or cpp_style_comment_block_3;
-cpp_style_comment_block_2
-    .loop cpp_style_comment_char .and new_line;
-cpp_style_comment_block_3
-    .loop cpp_style_comment_char;
-
-cpp_style_comment_char
-    '\x0E'-'\xFF' .or '\x01'-'\x09' .or '\x0B'-'\x0C';
-
-/* lexical rules */
-
-/*ampersand
-    optional_space .and '&' .and optional_space;*/
-
-ampersandampersand
-    optional_space .and '&' .and '&' .and optional_space;
-
-/*ampersandequals
-    optional_space .and '&' .and '=' .and optional_space;*/
-
-/*bar
-    optional_space .and '|' .and optional_space;*/
-
-barbar
-    optional_space .and '|' .and '|' .and optional_space;
-
-/*barequals
-    optional_space .and '|' .and '=' .and optional_space;*/
-
-bang
-    optional_space .and '!' .and optional_space;
-
-bangequals
-    optional_space .and '!' .and '=' .and optional_space;
-
-/*caret
-    optional_space .and '^' .and optional_space;*/
-
-caretcaret
-    optional_space .and '^' .and '^' .and optional_space;
-
-/*caretequals
-    optional_space .and '^' .and '=' .and optional_space;*/
-
-colon
-    optional_space .and ':' .and optional_space;
-
-comma
-    optional_space .and ',' .and optional_space;
-
-dot
-    optional_space .and '.' .and optional_space;
-
-equals
-    optional_space .and '=' .and optional_space;
-
-equalsequals
-    optional_space .and '=' .and '=' .and optional_space;
-
-greater
-    optional_space .and '>' .and optional_space;
-
-greaterequals
-    optional_space .and '>' .and '=' .and optional_space;
-
-/*greatergreater
-    optional_space .and '>' .and '>' .and optional_space;*/
-
-/*greatergreaterequals
-    optional_space .and '>' .and '>' .and '=' .and optional_space;*/
-
-lbrace
-    optional_space .and '{' .and optional_space;
-
-lbracket
-    optional_space .and '[' .and optional_space;
-
-less
-    optional_space .and '<' .and optional_space;
-
-lessequals
-    optional_space .and '<' .and '=' .and optional_space;
-
-/*lessless
-    optional_space .and '<' .and '<' .and optional_space;*/
-
-/*lesslessequals
-    optional_space .and '<' .and '<' .and '=' .and optional_space;*/
-
-lparen
-    optional_space .and '(' .and optional_space;
-
-minus
-    optional_space .and '-' .and optional_space;
-
-minusequals
-    optional_space .and '-' .and '=' .and optional_space;
-
-minusminus
-    optional_space .and '-' .and '-' .and optional_space;
-
-/*percent
-    optional_space .and '%' .and optional_space;*/
-
-/*percentequals
-    optional_space .and '%' .and '=' .and optional_space;*/
-
-plus
-    optional_space .and '+' .and optional_space;
-
-plusequals
-    optional_space .and '+' .and '=' .and optional_space;
-
-plusplus
-    optional_space .and '+' .and '+' .and optional_space;
-
-question
-    optional_space .and '?' .and optional_space;
-
-rbrace
-    optional_space .and '}' .and optional_space;
-
-rbracket
-    optional_space .and ']' .and optional_space;
-
-rparen
-    optional_space .and ')' .and optional_space;
-
-semicolon
-    optional_space .and ';' .and optional_space;
-
-slash
-    optional_space .and '/' .and optional_space;
-
-slashequals
-    optional_space .and '/' .and '=' .and optional_space;
-
-star
-    optional_space .and '*' .and optional_space;
-
-starequals
-    optional_space .and '*' .and '=' .and optional_space;
-
-/*tilde
-    optional_space .and '~' .and optional_space;*/
-
-/* string rules - these are used internally by the parser when parsing quoted strings */
-
-.string string_lexer;
-
-string_lexer
-    lex_first_identifier_character .and .loop lex_next_identifier_character;
-
-lex_first_identifier_character
-    'a'-'z' .or 'A'-'Z' .or '_';
-
-lex_next_identifier_character
-    'a'-'z' .or 'A'-'Z' .or '0'-'9' .or '_';
-
-/* error rules - these are used by error messages */
-
-err_token
-    '~' .or '`' .or '!' .or '@' .or '#' .or '$' .or '%' .or '^' .or '&' .or '*' .or '(' .or ')' .or
-    '-' .or '+' .or '=' .or '|' .or '\\' .or '[' .or ']' .or '{' .or '}' .or ':' .or ';' .or '"' .or
-    '\'' .or '<' .or ',' .or '>' .or '.' .or '/' .or '?' .or err_identifier;
-
-err_identifier
-    id_character_first .and .loop id_character_next;
-
diff --git a/src/mesa/shader/slang/library/slang_shader_syn.h b/src/mesa/shader/slang/library/slang_shader_syn.h
deleted file mode 100644 (file)
index 6a38297..0000000
+++ /dev/null
@@ -1,866 +0,0 @@
-
-/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED FROM THE .syn FILE */
-
-".syntax translation_unit;\n"
-".emtcode REVISION 5\n"
-".emtcode EXTERNAL_NULL 0\n"
-".emtcode EXTERNAL_FUNCTION_DEFINITION 1\n"
-".emtcode EXTERNAL_DECLARATION 2\n"
-".emtcode DEFAULT_PRECISION 3\n"
-".emtcode INVARIANT_STMT 4\n"
-".emtcode PRECISION_DEFAULT 0\n"
-".emtcode PRECISION_LOW 1\n"
-".emtcode PRECISION_MEDIUM 2\n"
-".emtcode PRECISION_HIGH 3\n"
-".emtcode DECLARATION_FUNCTION_PROTOTYPE 1\n"
-".emtcode DECLARATION_INIT_DECLARATOR_LIST 2\n"
-".emtcode FUNCTION_ORDINARY 0\n"
-".emtcode FUNCTION_CONSTRUCTOR 1\n"
-".emtcode FUNCTION_OPERATOR 2\n"
-".emtcode FUNCTION_CALL_NONARRAY 0\n"
-".emtcode FUNCTION_CALL_ARRAY 1\n"
-".emtcode OPERATOR_ADDASSIGN 1\n"
-".emtcode OPERATOR_SUBASSIGN 2\n"
-".emtcode OPERATOR_MULASSIGN 3\n"
-".emtcode OPERATOR_DIVASSIGN 4\n"
-".emtcode OPERATOR_LOGICALXOR 11\n"
-".emtcode OPERATOR_LESS 15\n"
-".emtcode OPERATOR_GREATER 16\n"
-".emtcode OPERATOR_LESSEQUAL 17\n"
-".emtcode OPERATOR_GREATEREQUAL 18\n"
-".emtcode OPERATOR_MULTIPLY 21\n"
-".emtcode OPERATOR_DIVIDE 22\n"
-".emtcode OPERATOR_INCREMENT 24\n"
-".emtcode OPERATOR_DECREMENT 25\n"
-".emtcode OPERATOR_PLUS 26\n"
-".emtcode OPERATOR_MINUS 27\n"
-".emtcode OPERATOR_NOT 29\n"
-".emtcode DECLARATOR_NONE 0\n"
-".emtcode DECLARATOR_NEXT 1\n"
-".emtcode VARIABLE_NONE 0\n"
-".emtcode VARIABLE_IDENTIFIER 1\n"
-".emtcode VARIABLE_INITIALIZER 2\n"
-".emtcode VARIABLE_ARRAY_EXPLICIT 3\n"
-".emtcode VARIABLE_ARRAY_UNKNOWN 4\n"
-".emtcode TYPE_QUALIFIER_NONE 0\n"
-".emtcode TYPE_QUALIFIER_CONST 1\n"
-".emtcode TYPE_QUALIFIER_ATTRIBUTE 2\n"
-".emtcode TYPE_QUALIFIER_VARYING 3\n"
-".emtcode TYPE_QUALIFIER_UNIFORM 4\n"
-".emtcode TYPE_QUALIFIER_FIXEDOUTPUT 5\n"
-".emtcode TYPE_QUALIFIER_FIXEDINPUT 6\n"
-".emtcode TYPE_VARIANT 90\n"
-".emtcode TYPE_INVARIANT 91\n"
-".emtcode TYPE_CENTER 95\n"
-".emtcode TYPE_CENTROID 96\n"
-".emtcode TYPE_SPECIFIER_VOID 0\n"
-".emtcode TYPE_SPECIFIER_BOOL 1\n"
-".emtcode TYPE_SPECIFIER_BVEC2 2\n"
-".emtcode TYPE_SPECIFIER_BVEC3 3\n"
-".emtcode TYPE_SPECIFIER_BVEC4 4\n"
-".emtcode TYPE_SPECIFIER_INT 5\n"
-".emtcode TYPE_SPECIFIER_IVEC2 6\n"
-".emtcode TYPE_SPECIFIER_IVEC3 7\n"
-".emtcode TYPE_SPECIFIER_IVEC4 8\n"
-".emtcode TYPE_SPECIFIER_FLOAT 9\n"
-".emtcode TYPE_SPECIFIER_VEC2 10\n"
-".emtcode TYPE_SPECIFIER_VEC3 11\n"
-".emtcode TYPE_SPECIFIER_VEC4 12\n"
-".emtcode TYPE_SPECIFIER_MAT2 13\n"
-".emtcode TYPE_SPECIFIER_MAT3 14\n"
-".emtcode TYPE_SPECIFIER_MAT4 15\n"
-".emtcode TYPE_SPECIFIER_SAMPLER1D 16\n"
-".emtcode TYPE_SPECIFIER_SAMPLER2D 17\n"
-".emtcode TYPE_SPECIFIER_SAMPLER3D 18\n"
-".emtcode TYPE_SPECIFIER_SAMPLERCUBE 19\n"
-".emtcode TYPE_SPECIFIER_SAMPLER1DSHADOW 20\n"
-".emtcode TYPE_SPECIFIER_SAMPLER2DSHADOW 21\n"
-".emtcode TYPE_SPECIFIER_SAMPLER2DRECT 22\n"
-".emtcode TYPE_SPECIFIER_SAMPLER2DRECTSHADOW 23\n"
-".emtcode TYPE_SPECIFIER_STRUCT 24\n"
-".emtcode TYPE_SPECIFIER_TYPENAME 25\n"
-".emtcode TYPE_SPECIFIER_MAT23 26\n"
-".emtcode TYPE_SPECIFIER_MAT32 27\n"
-".emtcode TYPE_SPECIFIER_MAT24 28\n"
-".emtcode TYPE_SPECIFIER_MAT42 29\n"
-".emtcode TYPE_SPECIFIER_MAT34 30\n"
-".emtcode TYPE_SPECIFIER_MAT43 31\n"
-".emtcode TYPE_SPECIFIER_NONARRAY 0\n"
-".emtcode TYPE_SPECIFIER_ARRAY 1\n"
-".emtcode FIELD_NONE 0\n"
-".emtcode FIELD_NEXT 1\n"
-".emtcode FIELD_ARRAY 2\n"
-".emtcode OP_END 0\n"
-".emtcode OP_BLOCK_BEGIN_NO_NEW_SCOPE 1\n"
-".emtcode OP_BLOCK_BEGIN_NEW_SCOPE 2\n"
-".emtcode OP_DECLARE 3\n"
-".emtcode OP_ASM 4\n"
-".emtcode OP_BREAK 5\n"
-".emtcode OP_CONTINUE 6\n"
-".emtcode OP_DISCARD 7\n"
-".emtcode OP_RETURN 8\n"
-".emtcode OP_EXPRESSION 9\n"
-".emtcode OP_IF 10\n"
-".emtcode OP_WHILE 11\n"
-".emtcode OP_DO 12\n"
-".emtcode OP_FOR 13\n"
-".emtcode OP_PUSH_VOID 14\n"
-".emtcode OP_PUSH_BOOL 15\n"
-".emtcode OP_PUSH_INT 16\n"
-".emtcode OP_PUSH_FLOAT 17\n"
-".emtcode OP_PUSH_IDENTIFIER 18\n"
-".emtcode OP_SEQUENCE 19\n"
-".emtcode OP_ASSIGN 20\n"
-".emtcode OP_ADDASSIGN 21\n"
-".emtcode OP_SUBASSIGN 22\n"
-".emtcode OP_MULASSIGN 23\n"
-".emtcode OP_DIVASSIGN 24\n"
-".emtcode OP_SELECT 31\n"
-".emtcode OP_LOGICALOR 32\n"
-".emtcode OP_LOGICALXOR 33\n"
-".emtcode OP_LOGICALAND 34\n"
-".emtcode OP_EQUAL 38\n"
-".emtcode OP_NOTEQUAL 39\n"
-".emtcode OP_LESS 40\n"
-".emtcode OP_GREATER 41\n"
-".emtcode OP_LESSEQUAL 42\n"
-".emtcode OP_GREATEREQUAL 43\n"
-".emtcode OP_ADD 46\n"
-".emtcode OP_SUBTRACT 47\n"
-".emtcode OP_MULTIPLY 48\n"
-".emtcode OP_DIVIDE 49\n"
-".emtcode OP_PREINCREMENT 51\n"
-".emtcode OP_PREDECREMENT 52\n"
-".emtcode OP_PLUS 53\n"
-".emtcode OP_MINUS 54\n"
-".emtcode OP_NOT 56\n"
-".emtcode OP_SUBSCRIPT 57\n"
-".emtcode OP_CALL 58\n"
-".emtcode OP_FIELD 59\n"
-".emtcode OP_POSTINCREMENT 60\n"
-".emtcode OP_POSTDECREMENT 61\n"
-".emtcode OP_PRECISION 62\n"
-".emtcode OP_METHOD 63\n"
-".emtcode PARAM_QUALIFIER_IN 0\n"
-".emtcode PARAM_QUALIFIER_OUT 1\n"
-".emtcode PARAM_QUALIFIER_INOUT 2\n"
-".emtcode PARAMETER_NONE 0\n"
-".emtcode PARAMETER_NEXT 1\n"
-".emtcode PARAMETER_ARRAY_NOT_PRESENT 0\n"
-".emtcode PARAMETER_ARRAY_PRESENT 1\n"
-".errtext INVALID_EXTERNAL_DECLARATION \"2001: Syntax error.\"\n"
-".errtext INVALID_OPERATOR_OVERRIDE \"2002: Invalid operator override.\"\n"
-".errtext LBRACE_EXPECTED \"2003: '{' expected but '$err_token$' found.\"\n"
-".errtext LPAREN_EXPECTED \"2004: '(' expected but '$err_token$' found.\"\n"
-".errtext RPAREN_EXPECTED \"2005: ')' expected but '$err_token$' found.\"\n"
-".errtext INVALID_PRECISION \"2006: Invalid precision specifier '$err_token$'.\"\n"
-".errtext INVALID_PRECISION_TYPE \"2007: Invalid precision type '$err_token$'.\"\n"
-".regbyte parsing_builtin 0\n"
-".regbyte shader_type 0\n"
-"variable_identifier\n"
-" identifier .emit OP_PUSH_IDENTIFIER;\n"
-"primary_expression\n"
-" floatconstant .or boolconstant .or intconstant .or variable_identifier .or primary_expression_1;\n"
-"primary_expression_1\n"
-" lparen .and expression .and rparen;\n"
-"postfix_expression\n"
-" postfix_expression_1 .and .loop postfix_expression_2;\n"
-"postfix_expression_1\n"
-" function_call .or primary_expression;\n"
-"postfix_expression_2\n"
-" postfix_expression_3 .or postfix_expression_4 .or\n"
-" plusplus .emit OP_POSTINCREMENT .or\n"
-" minusminus .emit OP_POSTDECREMENT;\n"
-"postfix_expression_3\n"
-" lbracket .and integer_expression .and rbracket .emit OP_SUBSCRIPT;\n"
-"postfix_expression_4\n"
-" dot .and field_selection .emit OP_FIELD;\n"
-"integer_expression\n"
-" expression;\n"
-"function_call\n"
-" function_call_or_method;\n"
-"function_call_or_method\n"
-" regular_function_call .or method_call;\n"
-"method_call\n"
-" identifier .emit OP_METHOD .and dot .and function_call_generic .and .true .emit OP_END;\n"
-"regular_function_call\n"
-" function_call_generic .emit OP_CALL .and .true .emit OP_END;\n"
-"function_call_generic\n"
-" function_call_generic_1 .or function_call_generic_2;\n"
-"function_call_generic_1\n"
-" function_call_header_with_parameters .and rparen .error RPAREN_EXPECTED;\n"
-"function_call_generic_2\n"
-" function_call_header_no_parameters .and rparen .error RPAREN_EXPECTED;\n"
-"function_call_header_no_parameters\n"
-" function_call_header .and function_call_header_no_parameters_1;\n"
-"function_call_header_no_parameters_1\n"
-" \"void\" .or .true;\n"
-"function_call_header_with_parameters\n"
-" function_call_header .and assignment_expression .and .true .emit OP_END .and\n"
-" .loop function_call_header_with_parameters_1;\n"
-"function_call_header_with_parameters_1\n"
-" comma .and assignment_expression .and .true .emit OP_END;\n"
-"function_call_header\n"
-" function_identifier .and lparen;\n"
-"function_identifier\n"
-" identifier .and function_identifier_opt_array;\n"
-"function_identifier_opt_array\n"
-" function_identifier_array .emit FUNCTION_CALL_ARRAY .or\n"
-" .true .emit FUNCTION_CALL_NONARRAY;\n"
-"function_identifier_array\n"
-" lbracket .and constant_expression .and rbracket;\n"
-"unary_expression\n"
-" postfix_expression .or unary_expression_1 .or unary_expression_2 .or unary_expression_3 .or\n"
-" unary_expression_4 .or unary_expression_5;\n"
-"unary_expression_1\n"
-" plusplus .and unary_expression .and .true .emit OP_PREINCREMENT;\n"
-"unary_expression_2\n"
-" minusminus .and unary_expression .and .true .emit OP_PREDECREMENT;\n"
-"unary_expression_3\n"
-" plus .and unary_expression .and .true .emit OP_PLUS;\n"
-"unary_expression_4\n"
-" minus .and unary_expression .and .true .emit OP_MINUS;\n"
-"unary_expression_5\n"
-" bang .and unary_expression .and .true .emit OP_NOT;\n"
-"multiplicative_expression\n"
-" unary_expression .and .loop multiplicative_expression_1;\n"
-"multiplicative_expression_1\n"
-" multiplicative_expression_2 .or multiplicative_expression_3;\n"
-"multiplicative_expression_2\n"
-" star .and unary_expression .and .true .emit OP_MULTIPLY;\n"
-"multiplicative_expression_3\n"
-" slash .and unary_expression .and .true .emit OP_DIVIDE;\n"
-"additive_expression\n"
-" multiplicative_expression .and .loop additive_expression_1;\n"
-"additive_expression_1\n"
-" additive_expression_2 .or additive_expression_3;\n"
-"additive_expression_2\n"
-" plus .and multiplicative_expression .and .true .emit OP_ADD;\n"
-"additive_expression_3\n"
-" minus .and multiplicative_expression .and .true .emit OP_SUBTRACT;\n"
-"shift_expression\n"
-" additive_expression;\n"
-"relational_expression\n"
-" shift_expression .and .loop relational_expression_1;\n"
-"relational_expression_1\n"
-" relational_expression_2 .or relational_expression_3 .or relational_expression_4 .or\n"
-" relational_expression_5;\n"
-"relational_expression_2\n"
-" lessequals .and shift_expression .and .true .emit OP_LESSEQUAL;\n"
-"relational_expression_3\n"
-" greaterequals .and shift_expression .and .true .emit OP_GREATEREQUAL;\n"
-"relational_expression_4\n"
-" less .and shift_expression .and .true .emit OP_LESS;\n"
-"relational_expression_5\n"
-" greater .and shift_expression .and .true .emit OP_GREATER;\n"
-"equality_expression\n"
-" relational_expression .and .loop equality_expression_1;\n"
-"equality_expression_1\n"
-" equality_expression_2 .or equality_expression_3;\n"
-"equality_expression_2\n"
-" equalsequals .and relational_expression .and .true .emit OP_EQUAL;\n"
-"equality_expression_3\n"
-" bangequals .and relational_expression .and .true .emit OP_NOTEQUAL;\n"
-"and_expression\n"
-" equality_expression;\n"
-"exclusive_or_expression\n"
-" and_expression;\n"
-"inclusive_or_expression\n"
-" exclusive_or_expression;\n"
-"logical_and_expression\n"
-" inclusive_or_expression .and .loop logical_and_expression_1;\n"
-"logical_and_expression_1\n"
-" ampersandampersand .and inclusive_or_expression .and .true .emit OP_LOGICALAND;\n"
-"logical_xor_expression\n"
-" logical_and_expression .and .loop logical_xor_expression_1;\n"
-"logical_xor_expression_1\n"
-" caretcaret .and logical_and_expression .and .true .emit OP_LOGICALXOR;\n"
-"logical_or_expression\n"
-" logical_xor_expression .and .loop logical_or_expression_1;\n"
-"logical_or_expression_1\n"
-" barbar .and logical_xor_expression .and .true .emit OP_LOGICALOR;\n"
-"conditional_expression\n"
-" logical_or_expression .and .loop conditional_expression_1;\n"
-"conditional_expression_1\n"
-" question .and expression .and colon .and conditional_expression .and .true .emit OP_SELECT;\n"
-"assignment_expression\n"
-" assignment_expression_1 .or assignment_expression_2 .or assignment_expression_3 .or\n"
-" assignment_expression_4 .or assignment_expression_5 .or conditional_expression;\n"
-"assignment_expression_1\n"
-" unary_expression .and equals .and assignment_expression .and .true .emit OP_ASSIGN;\n"
-"assignment_expression_2\n"
-" unary_expression .and starequals .and assignment_expression .and .true .emit OP_MULASSIGN;\n"
-"assignment_expression_3\n"
-" unary_expression .and slashequals .and assignment_expression .and .true .emit OP_DIVASSIGN;\n"
-"assignment_expression_4\n"
-" unary_expression .and plusequals .and assignment_expression .and .true .emit OP_ADDASSIGN;\n"
-"assignment_expression_5\n"
-" unary_expression .and minusequals .and assignment_expression .and .true .emit OP_SUBASSIGN;\n"
-"expression\n"
-" assignment_expression .and .loop expression_1;\n"
-"expression_1\n"
-" comma .and assignment_expression .and .true .emit OP_SEQUENCE;\n"
-"constant_expression\n"
-" conditional_expression .and .true .emit OP_END;\n"
-"declaration\n"
-" declaration_1 .or declaration_2;\n"
-"declaration_1\n"
-" function_prototype .emit DECLARATION_FUNCTION_PROTOTYPE .and semicolon;\n"
-"declaration_2\n"
-" init_declarator_list .emit DECLARATION_INIT_DECLARATOR_LIST .and semicolon;\n"
-"function_prototype\n"
-" function_prototype_1 .or function_prototype_2;\n"
-"function_prototype_1\n"
-" function_header .and \"void\" .and rparen .error RPAREN_EXPECTED .emit PARAMETER_NONE;\n"
-"function_prototype_2\n"
-" function_declarator .and rparen .error RPAREN_EXPECTED .emit PARAMETER_NONE;\n"
-"function_declarator\n"
-" function_header_with_parameters .or function_header;\n"
-"function_header_with_parameters\n"
-" function_header .and parameter_declaration .and .loop function_header_with_parameters_1;\n"
-"function_header_with_parameters_1\n"
-" comma .and parameter_declaration;\n"
-"function_header\n"
-" function_header_nospace .or function_header_space;\n"
-"function_header_space\n"
-" fully_specified_type_space .and space .and function_decl_identifier .and lparen;\n"
-"function_header_nospace\n"
-" fully_specified_type_nospace .and function_decl_identifier .and lparen;\n"
-"function_decl_identifier\n"
-" .if (parsing_builtin != 0) __operator .emit FUNCTION_OPERATOR .or\n"
-" .if (parsing_builtin != 0) \"__constructor\" .emit FUNCTION_CONSTRUCTOR .or\n"
-" identifier .emit FUNCTION_ORDINARY;\n"
-"__operator\n"
-" \"__operator\" .and overriden_operator .error INVALID_OPERATOR_OVERRIDE;\n"
-"overriden_operator\n"
-" plusplus .emit OPERATOR_INCREMENT .or\n"
-" plusequals .emit OPERATOR_ADDASSIGN .or\n"
-" plus .emit OPERATOR_PLUS .or\n"
-" minusminus .emit OPERATOR_DECREMENT .or\n"
-" minusequals .emit OPERATOR_SUBASSIGN .or\n"
-" minus .emit OPERATOR_MINUS .or\n"
-" bang .emit OPERATOR_NOT .or\n"
-" starequals .emit OPERATOR_MULASSIGN .or\n"
-" star .emit OPERATOR_MULTIPLY .or\n"
-" slashequals .emit OPERATOR_DIVASSIGN .or\n"
-" slash .emit OPERATOR_DIVIDE .or\n"
-" lessequals .emit OPERATOR_LESSEQUAL .or\n"
-" \n"
-" \n"
-" less .emit OPERATOR_LESS .or\n"
-" greaterequals .emit OPERATOR_GREATEREQUAL .or\n"
-" \n"
-" \n"
-" greater .emit OPERATOR_GREATER .or\n"
-" \n"
-" \n"
-" \n"
-" \n"
-" \n"
-" \n"
-" \n"
-" \n"
-" caretcaret .emit OPERATOR_LOGICALXOR ;\n"
-"parameter_declarator\n"
-" parameter_declarator_nospace .or parameter_declarator_space;\n"
-"parameter_declarator_nospace\n"
-" type_specifier_nospace .and identifier .and parameter_declarator_1;\n"
-"parameter_declarator_space\n"
-" type_specifier_space .and space .and identifier .and parameter_declarator_1;\n"
-"parameter_declarator_1\n"
-" parameter_declarator_2 .emit PARAMETER_ARRAY_PRESENT .or\n"
-" .true .emit PARAMETER_ARRAY_NOT_PRESENT;\n"
-"parameter_declarator_2\n"
-" lbracket .and constant_expression .and rbracket;\n"
-"parameter_declaration\n"
-" parameter_declaration_1 .emit PARAMETER_NEXT;\n"
-"parameter_declaration_1\n"
-" parameter_declaration_2 .or parameter_declaration_3;\n"
-"parameter_declaration_2\n"
-" type_qualifier .and space .and parameter_qualifier .and parameter_declaration_4;\n"
-"parameter_declaration_3\n"
-" parameter_qualifier .emit TYPE_QUALIFIER_NONE .and parameter_declaration_4;\n"
-"parameter_declaration_4\n"
-" parameter_declaration_optprec .and parameter_declaration_rest;\n"
-"parameter_declaration_optprec\n"
-" parameter_declaration_prec .or .true .emit PRECISION_DEFAULT;\n"
-"parameter_declaration_prec\n"
-" precision .and space;\n"
-"parameter_declaration_rest\n"
-" parameter_declarator .or parameter_type_specifier;\n"
-"parameter_qualifier\n"
-" parameter_qualifier_1 .or .true .emit PARAM_QUALIFIER_IN;\n"
-"parameter_qualifier_1\n"
-" parameter_qualifier_2 .and space;\n"
-"parameter_qualifier_2\n"
-" \"in\" .emit PARAM_QUALIFIER_IN .or\n"
-" \"out\" .emit PARAM_QUALIFIER_OUT .or\n"
-" \"inout\" .emit PARAM_QUALIFIER_INOUT;\n"
-"parameter_type_specifier\n"
-" parameter_type_specifier_1 .and .true .emit '\\0' .and parameter_type_specifier_2;\n"
-"parameter_type_specifier_1\n"
-" type_specifier_nospace .or type_specifier_space;\n"
-"parameter_type_specifier_2\n"
-" parameter_type_specifier_3 .emit PARAMETER_ARRAY_PRESENT .or\n"
-" .true .emit PARAMETER_ARRAY_NOT_PRESENT;\n"
-"parameter_type_specifier_3\n"
-" lbracket .and constant_expression .and rbracket;\n"
-"init_declarator_list\n"
-" single_declaration .and .loop init_declarator_list_1 .emit DECLARATOR_NEXT .and\n"
-" .true .emit DECLARATOR_NONE;\n"
-"init_declarator_list_1\n"
-" comma .and identifier .emit VARIABLE_IDENTIFIER .and init_declarator_list_2;\n"
-"init_declarator_list_2\n"
-" init_declarator_list_3 .or init_declarator_list_4 .or .true .emit VARIABLE_NONE;\n"
-"init_declarator_list_3\n"
-" equals .and initializer .emit VARIABLE_INITIALIZER;\n"
-"init_declarator_list_4\n"
-" lbracket .and init_declarator_list_5 .and rbracket;\n"
-"init_declarator_list_5\n"
-" constant_expression .emit VARIABLE_ARRAY_EXPLICIT .or .true .emit VARIABLE_ARRAY_UNKNOWN;\n"
-"single_declaration\n"
-" single_declaration_nospace .or single_declaration_space;\n"
-"single_declaration_space\n"
-" fully_specified_type_space .and single_declaration_space_1;\n"
-"single_declaration_nospace\n"
-" fully_specified_type_nospace .and single_declaration_nospace_1;\n"
-"single_declaration_space_1\n"
-" single_declaration_space_2 .emit VARIABLE_IDENTIFIER .or .true .emit VARIABLE_NONE;\n"
-"single_declaration_nospace_1\n"
-" single_declaration_nospace_2 .emit VARIABLE_IDENTIFIER .or .true .emit VARIABLE_NONE;\n"
-"single_declaration_space_2\n"
-" space .and identifier .and single_declaration_3;\n"
-"single_declaration_nospace_2\n"
-" identifier .and single_declaration_3;\n"
-"single_declaration_3\n"
-" single_declaration_4 .or single_declaration_5 .or .true .emit VARIABLE_NONE;\n"
-"single_declaration_4\n"
-" equals .and initializer .emit VARIABLE_INITIALIZER;\n"
-"single_declaration_5\n"
-" lbracket .and single_declaration_6 .and rbracket;\n"
-"single_declaration_6\n"
-" constant_expression .emit VARIABLE_ARRAY_EXPLICIT .or .true .emit VARIABLE_ARRAY_UNKNOWN;\n"
-"fully_specified_type_space\n"
-" fully_specified_type_optinvariant .and fully_specified_type_optcentroid .and fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier_space;\n"
-"fully_specified_type_nospace\n"
-" fully_specified_type_optinvariant .and fully_specified_type_optcentroid .and fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier_nospace;\n"
-"fully_specified_type_optinvariant\n"
-" fully_specified_type_invariant .or .true .emit TYPE_VARIANT;\n"
-"fully_specified_type_invariant\n"
-" invariant_qualifier .and space;\n"
-"fully_specified_type_optcentroid\n"
-" fully_specified_type_centroid .or .true .emit TYPE_CENTER;\n"
-"fully_specified_type_centroid\n"
-" centroid_qualifier .and space;\n"
-"fully_specified_type_optqual\n"
-" fully_specified_type_qual .or .true .emit TYPE_QUALIFIER_NONE;\n"
-"fully_specified_type_qual\n"
-" type_qualifier .and space;\n"
-"fully_specified_type_optprec\n"
-" fully_specified_type_prec .or .true .emit PRECISION_DEFAULT;\n"
-"fully_specified_type_prec\n"
-" precision .and space;\n"
-"invariant_qualifier\n"
-" \"invariant\" .emit TYPE_INVARIANT;\n"
-"centroid_qualifier\n"
-" \"centroid\" .emit TYPE_CENTROID;\n"
-"type_qualifier\n"
-" \"const\" .emit TYPE_QUALIFIER_CONST .or\n"
-" .if (shader_type == 2) \"attribute\" .emit TYPE_QUALIFIER_ATTRIBUTE .or\n"
-" \"varying\" .emit TYPE_QUALIFIER_VARYING .or\n"
-" \"uniform\" .emit TYPE_QUALIFIER_UNIFORM .or\n"
-" .if (parsing_builtin != 0) \"__fixed_output\" .emit TYPE_QUALIFIER_FIXEDOUTPUT .or\n"
-" .if (parsing_builtin != 0) \"__fixed_input\" .emit TYPE_QUALIFIER_FIXEDINPUT;\n"
-"type_specifier_nonarray_space\n"
-" \"void\" .emit TYPE_SPECIFIER_VOID .or\n"
-" \"float\" .emit TYPE_SPECIFIER_FLOAT .or\n"
-" \"int\" .emit TYPE_SPECIFIER_INT .or\n"
-" \"bool\" .emit TYPE_SPECIFIER_BOOL .or\n"
-" \"vec2\" .emit TYPE_SPECIFIER_VEC2 .or\n"
-" \"vec3\" .emit TYPE_SPECIFIER_VEC3 .or\n"
-" \"vec4\" .emit TYPE_SPECIFIER_VEC4 .or\n"
-" \"bvec2\" .emit TYPE_SPECIFIER_BVEC2 .or\n"
-" \"bvec3\" .emit TYPE_SPECIFIER_BVEC3 .or\n"
-" \"bvec4\" .emit TYPE_SPECIFIER_BVEC4 .or\n"
-" \"ivec2\" .emit TYPE_SPECIFIER_IVEC2 .or\n"
-" \"ivec3\" .emit TYPE_SPECIFIER_IVEC3 .or\n"
-" \"ivec4\" .emit TYPE_SPECIFIER_IVEC4 .or\n"
-" \"mat2\" .emit TYPE_SPECIFIER_MAT2 .or\n"
-" \"mat3\" .emit TYPE_SPECIFIER_MAT3 .or\n"
-" \"mat4\" .emit TYPE_SPECIFIER_MAT4 .or\n"
-" \"mat2x3\" .emit TYPE_SPECIFIER_MAT23 .or\n"
-" \"mat3x2\" .emit TYPE_SPECIFIER_MAT32 .or\n"
-" \"mat2x4\" .emit TYPE_SPECIFIER_MAT24 .or\n"
-" \"mat4x2\" .emit TYPE_SPECIFIER_MAT42 .or\n"
-" \"mat3x4\" .emit TYPE_SPECIFIER_MAT34 .or\n"
-" \"mat4x3\" .emit TYPE_SPECIFIER_MAT43 .or\n"
-" \"sampler1D\" .emit TYPE_SPECIFIER_SAMPLER1D .or\n"
-" \"sampler2D\" .emit TYPE_SPECIFIER_SAMPLER2D .or\n"
-" \"sampler3D\" .emit TYPE_SPECIFIER_SAMPLER3D .or\n"
-" \"samplerCube\" .emit TYPE_SPECIFIER_SAMPLERCUBE .or\n"
-" \"sampler1DShadow\" .emit TYPE_SPECIFIER_SAMPLER1DSHADOW .or\n"
-" \"sampler2DShadow\" .emit TYPE_SPECIFIER_SAMPLER2DSHADOW .or\n"
-" \"sampler2DRect\" .emit TYPE_SPECIFIER_SAMPLER2DRECT .or\n"
-" \"sampler2DRectShadow\" .emit TYPE_SPECIFIER_SAMPLER2DRECTSHADOW .or\n"
-" type_name .emit TYPE_SPECIFIER_TYPENAME;\n"
-"type_specifier_nonarray_nospace\n"
-" struct_specifier .emit TYPE_SPECIFIER_STRUCT;\n"
-"type_specifier_nonarray\n"
-" type_specifier_nonarray_nospace .or type_specifier_nonarray_space;\n"
-"type_specifier_space\n"
-" type_specifier_nonarray_space .and .true .emit TYPE_SPECIFIER_NONARRAY;\n"
-"type_specifier_nospace\n"
-" type_specifier_nospace_array .or type_specifier_nospace_1;\n"
-"type_specifier_nospace_1\n"
-" type_specifier_nonarray_nospace .and .true .emit TYPE_SPECIFIER_NONARRAY;\n"
-"type_specifier_nospace_array\n"
-" type_specifier_nonarray .and lbracket .emit TYPE_SPECIFIER_ARRAY .and constant_expression .and rbracket;\n"
-"struct_specifier\n"
-" \"struct\" .and struct_specifier_1 .and optional_space .and lbrace .error LBRACE_EXPECTED .and\n"
-" struct_declaration_list .and rbrace .emit FIELD_NONE;\n"
-"struct_specifier_1\n"
-" struct_specifier_2 .or .true .emit '\\0';\n"
-"struct_specifier_2\n"
-" space .and identifier;\n"
-"struct_declaration_list\n"
-" struct_declaration .and .loop struct_declaration .emit FIELD_NEXT;\n"
-"struct_declaration\n"
-" struct_declaration_nospace .or struct_declaration_space;\n"
-"struct_declaration_space\n"
-" type_specifier_space .and space .and struct_declarator_list .and semicolon .emit FIELD_NONE;\n"
-"struct_declaration_nospace\n"
-" type_specifier_nospace .and struct_declarator_list .and semicolon .emit FIELD_NONE;\n"
-"struct_declarator_list\n"
-" struct_declarator .and .loop struct_declarator_list_1 .emit FIELD_NEXT;\n"
-"struct_declarator_list_1\n"
-" comma .and struct_declarator;\n"
-"struct_declarator\n"
-" identifier .and struct_declarator_1;\n"
-"struct_declarator_1\n"
-" struct_declarator_2 .emit FIELD_ARRAY .or .true .emit FIELD_NONE;\n"
-"struct_declarator_2\n"
-" lbracket .and constant_expression .and rbracket;\n"
-"initializer\n"
-" assignment_expression .and .true .emit OP_END;\n"
-"declaration_statement\n"
-" declaration;\n"
-"statement\n"
-" compound_statement .or simple_statement;\n"
-"statement_space\n"
-" compound_statement .or statement_space_1;\n"
-"statement_space_1\n"
-" space .and simple_statement;\n"
-"simple_statement\n"
-" .if (parsing_builtin != 0) __asm_statement .emit OP_ASM .or\n"
-" selection_statement .or\n"
-" iteration_statement .or\n"
-" precision_stmt .emit OP_PRECISION .or\n"
-" jump_statement .or\n"
-" expression_statement .emit OP_EXPRESSION .or\n"
-" declaration_statement .emit OP_DECLARE;\n"
-"compound_statement\n"
-" compound_statement_1 .emit OP_BLOCK_BEGIN_NEW_SCOPE .and .true .emit OP_END;\n"
-"compound_statement_1\n"
-" compound_statement_2 .or compound_statement_3;\n"
-"compound_statement_2\n"
-" lbrace .and rbrace;\n"
-"compound_statement_3\n"
-" lbrace .and statement_list .and rbrace;\n"
-"compound_statement_no_new_scope\n"
-" compound_statement_no_new_scope_1 .emit OP_BLOCK_BEGIN_NO_NEW_SCOPE .and .true .emit OP_END;\n"
-"compound_statement_no_new_scope_1\n"
-" compound_statement_no_new_scope_2 .or compound_statement_no_new_scope_3;\n"
-"compound_statement_no_new_scope_2\n"
-" lbrace .and rbrace;\n"
-"compound_statement_no_new_scope_3\n"
-" lbrace .and statement_list .and rbrace;\n"
-"statement_list\n"
-" statement .and .loop statement;\n"
-"expression_statement\n"
-" expression_statement_1 .or expression_statement_2;\n"
-"expression_statement_1\n"
-" semicolon .emit OP_PUSH_VOID .emit OP_END;\n"
-"expression_statement_2\n"
-" expression .and semicolon .emit OP_END;\n"
-"selection_statement\n"
-" \"if\" .emit OP_IF .and lparen .error LPAREN_EXPECTED .and expression .and\n"
-" rparen .error RPAREN_EXPECTED .emit OP_END .and selection_rest_statement;\n"
-"selection_rest_statement\n"
-" statement .and selection_rest_statement_1;\n"
-"selection_rest_statement_1\n"
-" selection_rest_statement_2 .or .true .emit OP_EXPRESSION .emit OP_PUSH_VOID .emit OP_END;\n"
-"selection_rest_statement_2\n"
-" \"else\" .and optional_space .and statement;\n"
-"condition\n"
-" condition_1 .emit OP_DECLARE .emit DECLARATION_INIT_DECLARATOR_LIST .or\n"
-" condition_3 .emit OP_EXPRESSION;\n"
-"condition_1\n"
-" condition_1_nospace .or condition_1_space;\n"
-"condition_1_nospace\n"
-" fully_specified_type_nospace .and condition_2;\n"
-"condition_1_space\n"
-" fully_specified_type_space .and space .and condition_2;\n"
-"condition_2\n"
-" identifier .emit VARIABLE_IDENTIFIER .and equals .emit VARIABLE_INITIALIZER .and\n"
-" initializer .and .true .emit DECLARATOR_NONE;\n"
-"condition_3\n"
-" expression .and .true .emit OP_END;\n"
-"iteration_statement\n"
-" iteration_statement_1 .or iteration_statement_2 .or iteration_statement_3;\n"
-"iteration_statement_1\n"
-" \"while\" .emit OP_WHILE .and lparen .error LPAREN_EXPECTED .and condition .and\n"
-" rparen .error RPAREN_EXPECTED .and statement;\n"
-"iteration_statement_2\n"
-" \"do\" .emit OP_DO .and statement_space .and \"while\" .and lparen .error LPAREN_EXPECTED .and\n"
-" expression .and rparen .error RPAREN_EXPECTED .emit OP_END .and semicolon;\n"
-"iteration_statement_3\n"
-" \"for\" .emit OP_FOR .and lparen .error LPAREN_EXPECTED .and for_init_statement .and\n"
-" for_rest_statement .and rparen .error RPAREN_EXPECTED .and statement;\n"
-"for_init_statement\n"
-" expression_statement .emit OP_EXPRESSION .or declaration_statement .emit OP_DECLARE;\n"
-"conditionopt\n"
-" condition .or\n"
-" .true .emit OP_EXPRESSION .emit OP_PUSH_BOOL .emit 2 .emit '1' .emit '\\0' .emit OP_END;\n"
-"for_rest_statement\n"
-" conditionopt .and semicolon .and for_rest_statement_1;\n"
-"for_rest_statement_1\n"
-" for_rest_statement_2 .or .true .emit OP_PUSH_VOID .emit OP_END;\n"
-"for_rest_statement_2\n"
-" expression .and .true .emit OP_END;\n"
-"jump_statement\n"
-" jump_statement_1 .or jump_statement_2 .or jump_statement_3 .or jump_statement_4 .or\n"
-" .if (shader_type == 1) jump_statement_5;\n"
-"jump_statement_1\n"
-" \"continue\" .and semicolon .emit OP_CONTINUE;\n"
-"jump_statement_2\n"
-" \"break\" .and semicolon .emit OP_BREAK;\n"
-"jump_statement_3\n"
-" \"return\" .emit OP_RETURN .and optional_space .and expression .and semicolon .emit OP_END;\n"
-"jump_statement_4\n"
-" \"return\" .emit OP_RETURN .and semicolon .emit OP_PUSH_VOID .emit OP_END;\n"
-"jump_statement_5\n"
-" \"discard\" .and semicolon .emit OP_DISCARD;\n"
-"__asm_statement\n"
-" \"__asm\" .and space .and identifier .and space .and asm_arguments .and semicolon .emit OP_END;\n"
-"asm_arguments\n"
-" asm_argument .and .true .emit OP_END .and .loop asm_arguments_1;\n"
-"asm_arguments_1\n"
-" comma .and asm_argument .and .true .emit OP_END;\n"
-"asm_argument\n"
-" var_with_field .or\n"
-" variable_identifier .or\n"
-" floatconstant;\n"
-"var_with_field\n"
-" variable_identifier .and dot .and field_selection .emit OP_FIELD;\n"
-"translation_unit\n"
-" optional_space .emit REVISION .and external_declaration .error INVALID_EXTERNAL_DECLARATION .and\n"
-" .loop external_declaration .and optional_space .and\n"
-" '\\0' .error INVALID_EXTERNAL_DECLARATION .emit EXTERNAL_NULL;\n"
-"external_declaration\n"
-" precision_stmt .emit DEFAULT_PRECISION .or\n"
-" function_definition .emit EXTERNAL_FUNCTION_DEFINITION .or\n"
-" invariant_stmt .emit INVARIANT_STMT .or\n"
-" declaration .emit EXTERNAL_DECLARATION;\n"
-"precision_stmt\n"
-" \"precision\" .and space .and precision .error INVALID_PRECISION .and space .and prectype .error INVALID_PRECISION_TYPE .and semicolon;\n"
-"precision\n"
-" \"lowp\" .emit PRECISION_LOW .or\n"
-" \"mediump\" .emit PRECISION_MEDIUM .or\n"
-" \"highp\" .emit PRECISION_HIGH;\n"
-"prectype\n"
-" \"int\" .emit TYPE_SPECIFIER_INT .or\n"
-" \"float\" .emit TYPE_SPECIFIER_FLOAT .or\n"
-" \"sampler1D\" .emit TYPE_SPECIFIER_SAMPLER1D .or\n"
-" \"sampler2D\" .emit TYPE_SPECIFIER_SAMPLER2D .or\n"
-" \"sampler3D\" .emit TYPE_SPECIFIER_SAMPLER3D .or\n"
-" \"samplerCube\" .emit TYPE_SPECIFIER_SAMPLERCUBE .or\n"
-" \"sampler1DShadow\" .emit TYPE_SPECIFIER_SAMPLER1DSHADOW .or\n"
-" \"sampler2DShadow\" .emit TYPE_SPECIFIER_SAMPLER2DSHADOW .or\n"
-" \"sampler2DRect\" .emit TYPE_SPECIFIER_SAMPLER2DRECT .or\n"
-" \"sampler2DRectShadow\" .emit TYPE_SPECIFIER_SAMPLER2DRECTSHADOW;\n"
-"invariant_stmt\n"
-" \"invariant\" .and space .and identifier .and semicolon;\n"
-"function_definition\n"
-" function_prototype .and compound_statement_no_new_scope;\n"
-"digit_oct\n"
-" '0'-'7';\n"
-"digit_dec\n"
-" '0'-'9';\n"
-"digit_hex\n"
-" '0'-'9' .or 'A'-'F' .or 'a'-'f';\n"
-"id_character_first\n"
-" 'a'-'z' .or 'A'-'Z' .or '_';\n"
-"id_character_next\n"
-" id_character_first .or digit_dec;\n"
-"identifier\n"
-" id_character_first .emit * .and .loop id_character_next .emit * .and .true .emit '\\0';\n"
-"float\n"
-" float_1 .or float_2 .or float_3;\n"
-"float_1\n"
-" float_fractional_constant .and float_optional_exponent_part .and optional_f_suffix;\n"
-"float_2\n"
-" float_digit_sequence .and .true .emit '\\0' .and float_exponent_part .and optional_f_suffix;\n"
-"float_3\n"
-" float_digit_sequence .and .true .emit '\\0' .and 'f' .emit '\\0';\n"
-"float_fractional_constant\n"
-" float_fractional_constant_1 .or float_fractional_constant_2 .or float_fractional_constant_3;\n"
-"float_fractional_constant_1\n"
-" float_digit_sequence .and '.' .and float_digit_sequence;\n"
-"float_fractional_constant_2\n"
-" float_digit_sequence .and '.' .and .true .emit '\\0';\n"
-"float_fractional_constant_3\n"
-" '.' .emit '\\0' .and float_digit_sequence;\n"
-"float_optional_exponent_part\n"
-" float_exponent_part .or .true .emit '\\0';\n"
-"float_digit_sequence\n"
-" digit_dec .emit * .and .loop digit_dec .emit * .and .true .emit '\\0';\n"
-"float_exponent_part\n"
-" float_exponent_part_1 .or float_exponent_part_2;\n"
-"float_exponent_part_1\n"
-" 'e' .and float_optional_sign .and float_digit_sequence;\n"
-"float_exponent_part_2\n"
-" 'E' .and float_optional_sign .and float_digit_sequence;\n"
-"float_optional_sign\n"
-" float_sign .or .true;\n"
-"float_sign\n"
-" '+' .or '-' .emit '-';\n"
-"optional_f_suffix\n"
-" 'f' .or .true;\n"
-"integer\n"
-" integer_hex .or integer_oct .or integer_dec;\n"
-"integer_hex\n"
-" '0' .and integer_hex_1 .emit 0x10 .and digit_hex .emit * .and .loop digit_hex .emit * .and\n"
-" .true .emit '\\0';\n"
-"integer_hex_1\n"
-" 'x' .or 'X';\n"
-"integer_oct\n"
-" '0' .emit 8 .emit * .and .loop digit_oct .emit * .and .true .emit '\\0';\n"
-"integer_dec\n"
-" digit_dec .emit 10 .emit * .and .loop digit_dec .emit * .and .true .emit '\\0';\n"
-"boolean\n"
-" \"true\" .emit 2 .emit '1' .emit '\\0' .or\n"
-" \"false\" .emit 2 .emit '0' .emit '\\0';\n"
-"type_name\n"
-" identifier;\n"
-"field_selection\n"
-" identifier;\n"
-"floatconstant\n"
-" float .emit OP_PUSH_FLOAT;\n"
-"intconstant\n"
-" integer .emit OP_PUSH_INT;\n"
-"boolconstant\n"
-" boolean .emit OP_PUSH_BOOL;\n"
-"optional_space\n"
-" .loop single_space;\n"
-"space\n"
-" single_space .and .loop single_space;\n"
-"single_space\n"
-" white_char .or c_style_comment_block .or cpp_style_comment_block;\n"
-"white_char\n"
-" ' ' .or '\\t' .or new_line .or '\\v' .or '\\f';\n"
-"new_line\n"
-" cr_lf .or lf_cr .or '\\n' .or '\\r';\n"
-"cr_lf\n"
-" '\\r' .and '\\n';\n"
-"lf_cr\n"
-" '\\n' .and '\\r';\n"
-"c_style_comment_block\n"
-" '/' .and '*' .and c_style_comment_rest;\n"
-"c_style_comment_rest\n"
-" .loop c_style_comment_char_no_star .and c_style_comment_rest_1;\n"
-"c_style_comment_rest_1\n"
-" c_style_comment_end .or c_style_comment_rest_2;\n"
-"c_style_comment_rest_2\n"
-" '*' .and c_style_comment_rest;\n"
-"c_style_comment_char_no_star\n"
-" '\\x2B'-'\\xFF' .or '\\x01'-'\\x29';\n"
-"c_style_comment_end\n"
-" '*' .and '/';\n"
-"cpp_style_comment_block\n"
-" '/' .and '/' .and cpp_style_comment_block_1;\n"
-"cpp_style_comment_block_1\n"
-" cpp_style_comment_block_2 .or cpp_style_comment_block_3;\n"
-"cpp_style_comment_block_2\n"
-" .loop cpp_style_comment_char .and new_line;\n"
-"cpp_style_comment_block_3\n"
-" .loop cpp_style_comment_char;\n"
-"cpp_style_comment_char\n"
-" '\\x0E'-'\\xFF' .or '\\x01'-'\\x09' .or '\\x0B'-'\\x0C';\n"
-"ampersandampersand\n"
-" optional_space .and '&' .and '&' .and optional_space;\n"
-"barbar\n"
-" optional_space .and '|' .and '|' .and optional_space;\n"
-"bang\n"
-" optional_space .and '!' .and optional_space;\n"
-"bangequals\n"
-" optional_space .and '!' .and '=' .and optional_space;\n"
-"caretcaret\n"
-" optional_space .and '^' .and '^' .and optional_space;\n"
-"colon\n"
-" optional_space .and ':' .and optional_space;\n"
-"comma\n"
-" optional_space .and ',' .and optional_space;\n"
-"dot\n"
-" optional_space .and '.' .and optional_space;\n"
-"equals\n"
-" optional_space .and '=' .and optional_space;\n"
-"equalsequals\n"
-" optional_space .and '=' .and '=' .and optional_space;\n"
-"greater\n"
-" optional_space .and '>' .and optional_space;\n"
-"greaterequals\n"
-" optional_space .and '>' .and '=' .and optional_space;\n"
-"lbrace\n"
-" optional_space .and '{' .and optional_space;\n"
-"lbracket\n"
-" optional_space .and '[' .and optional_space;\n"
-"less\n"
-" optional_space .and '<' .and optional_space;\n"
-"lessequals\n"
-" optional_space .and '<' .and '=' .and optional_space;\n"
-"lparen\n"
-" optional_space .and '(' .and optional_space;\n"
-"minus\n"
-" optional_space .and '-' .and optional_space;\n"
-"minusequals\n"
-" optional_space .and '-' .and '=' .and optional_space;\n"
-"minusminus\n"
-" optional_space .and '-' .and '-' .and optional_space;\n"
-"plus\n"
-" optional_space .and '+' .and optional_space;\n"
-"plusequals\n"
-" optional_space .and '+' .and '=' .and optional_space;\n"
-"plusplus\n"
-" optional_space .and '+' .and '+' .and optional_space;\n"
-"question\n"
-" optional_space .and '?' .and optional_space;\n"
-"rbrace\n"
-" optional_space .and '}' .and optional_space;\n"
-"rbracket\n"
-" optional_space .and ']' .and optional_space;\n"
-"rparen\n"
-" optional_space .and ')' .and optional_space;\n"
-"semicolon\n"
-" optional_space .and ';' .and optional_space;\n"
-"slash\n"
-" optional_space .and '/' .and optional_space;\n"
-"slashequals\n"
-" optional_space .and '/' .and '=' .and optional_space;\n"
-"star\n"
-" optional_space .and '*' .and optional_space;\n"
-"starequals\n"
-" optional_space .and '*' .and '=' .and optional_space;\n"
-".string string_lexer;\n"
-"string_lexer\n"
-" lex_first_identifier_character .and .loop lex_next_identifier_character;\n"
-"lex_first_identifier_character\n"
-" 'a'-'z' .or 'A'-'Z' .or '_';\n"
-"lex_next_identifier_character\n"
-" 'a'-'z' .or 'A'-'Z' .or '0'-'9' .or '_';\n"
-"err_token\n"
-" '~' .or '`' .or '!' .or '@' .or '#' .or '$' .or '%' .or '^' .or '&' .or '*' .or '(' .or ')' .or\n"
-" '-' .or '+' .or '=' .or '|' .or '\\\\' .or '[' .or ']' .or '{' .or '}' .or ':' .or ';' .or '\"' .or\n"
-" '\\'' .or '<' .or ',' .or '>' .or '.' .or '/' .or '?' .or err_identifier;\n"
-"err_identifier\n"
-" id_character_first .and .loop id_character_next;\n"
-""
diff --git a/src/mesa/shader/slang/library/slang_version.syn b/src/mesa/shader/slang/library/slang_version.syn
deleted file mode 100644 (file)
index aaf8bef..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version:  6.3
- *
- * Copyright (C) 2005  Brian Paul   All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/**
- * \file slang_version.syn
- * slang #version directive syntax
- * \author Michal Krol
- */
-
-.syntax version_directive;
-
-version_directive
-       version_directive_1 .and .loop version_directive_2;
-version_directive_1
-       prior_optional_spaces .and optional_version_directive .and .true .emit $;
-version_directive_2
-       prior_optional_spaces .and version_directive_body .and .true .emit $;
-
-optional_version_directive
-       version_directive_body .or .true .emit 10 .emit 1;
-
-version_directive_body
-       '#' .and optional_space .and "version" .and space .and version_number .and optional_space .and
-       new_line;
-
-version_number
-       version_number_110;
-
-version_number_110
-       leading_zeroes .and "110" .emit 10 .emit 1;
-
-leading_zeroes
-       .loop zero;
-
-zero
-       '0';
-
-space
-    single_space .and .loop single_space;
-
-optional_space
-    .loop single_space;
-
-single_space
-    ' ' .or '\t';
-
-prior_optional_spaces
-       .loop prior_space;
-
-prior_space
-       c_style_comment_block .or cpp_style_comment_block .or space .or new_line;
-
-c_style_comment_block
-    '/' .and '*' .and c_style_comment_rest;
-
-c_style_comment_rest
-    .loop c_style_comment_char_no_star .and c_style_comment_rest_1;
-c_style_comment_rest_1
-    c_style_comment_end .or c_style_comment_rest_2;
-c_style_comment_rest_2
-    '*' .and c_style_comment_rest;
-
-c_style_comment_char_no_star
-    '\x2B'-'\xFF' .or '\x01'-'\x29';
-
-c_style_comment_end
-    '*' .and '/';
-
-cpp_style_comment_block
-    '/' .and '/' .and cpp_style_comment_block_1;
-cpp_style_comment_block_1
-    cpp_style_comment_block_2 .or cpp_style_comment_block_3;
-cpp_style_comment_block_2
-    .loop cpp_style_comment_char .and new_line;
-cpp_style_comment_block_3
-    .loop cpp_style_comment_char;
-
-cpp_style_comment_char
-    '\x0E'-'\xFF' .or '\x01'-'\x09' .or '\x0B'-'\x0C';
-
-new_line
-    cr_lf .or lf_cr .or '\n' .or '\r';
-
-cr_lf
-    '\r' .and '\n';
-
-lf_cr
-       '\n' .and '\r';
-
-.string __string_filter;
-
-__string_filter
-    .loop __identifier_char;
-
-__identifier_char
-    'a'-'z' .or 'A'-'Z' .or '_' .or '0'-'9';
-
diff --git a/src/mesa/shader/slang/library/slang_vertex_builtin_gc.h b/src/mesa/shader/slang/library/slang_vertex_builtin_gc.h
deleted file mode 100644 (file)
index e5a252b..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-
-/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED FROM THE FOLLOWING FILE: */
-/* slang_vertex_builtin.gc */
-
-5,2,2,90,95,5,0,12,0,1,103,108,95,80,111,115,105,116,105,111,110,0,0,0,2,2,90,95,5,0,9,0,1,103,108,
-95,80,111,105,110,116,83,105,122,101,0,0,0,2,2,90,95,5,0,12,0,1,103,108,95,67,108,105,112,86,101,
-114,116,101,120,0,0,0,2,2,90,95,2,0,12,0,1,103,108,95,67,111,108,111,114,0,0,0,2,2,90,95,2,0,12,0,
-1,103,108,95,83,101,99,111,110,100,97,114,121,67,111,108,111,114,0,0,0,2,2,90,95,2,0,11,0,1,103,
-108,95,78,111,114,109,97,108,0,0,0,2,2,90,95,2,0,12,0,1,103,108,95,86,101,114,116,101,120,0,0,0,2,
-2,90,95,2,0,12,0,1,103,108,95,77,117,108,116,105,84,101,120,67,111,111,114,100,48,0,0,0,2,2,90,95,
-2,0,12,0,1,103,108,95,77,117,108,116,105,84,101,120,67,111,111,114,100,49,0,0,0,2,2,90,95,2,0,12,0,
-1,103,108,95,77,117,108,116,105,84,101,120,67,111,111,114,100,50,0,0,0,2,2,90,95,2,0,12,0,1,103,
-108,95,77,117,108,116,105,84,101,120,67,111,111,114,100,51,0,0,0,2,2,90,95,2,0,12,0,1,103,108,95,
-77,117,108,116,105,84,101,120,67,111,111,114,100,52,0,0,0,2,2,90,95,2,0,12,0,1,103,108,95,77,117,
-108,116,105,84,101,120,67,111,111,114,100,53,0,0,0,2,2,90,95,2,0,12,0,1,103,108,95,77,117,108,116,
-105,84,101,120,67,111,111,114,100,54,0,0,0,2,2,90,95,2,0,12,0,1,103,108,95,77,117,108,116,105,84,
-101,120,67,111,111,114,100,55,0,0,0,2,2,90,95,2,0,9,0,1,103,108,95,70,111,103,67,111,111,114,100,0,
-0,0,2,2,90,95,3,0,12,0,1,103,108,95,70,114,111,110,116,67,111,108,111,114,0,0,0,2,2,90,95,3,0,12,0,
-1,103,108,95,66,97,99,107,67,111,108,111,114,0,0,0,2,2,90,95,3,0,12,0,1,103,108,95,70,114,111,110,
-116,83,101,99,111,110,100,97,114,121,67,111,108,111,114,0,0,0,2,2,90,95,3,0,12,0,1,103,108,95,66,
-97,99,107,83,101,99,111,110,100,97,114,121,67,111,108,111,114,0,0,0,2,2,90,95,3,0,12,0,1,103,108,
-95,84,101,120,67,111,111,114,100,0,3,18,103,108,95,77,97,120,84,101,120,116,117,114,101,67,111,111,
-114,100,115,0,0,0,2,2,90,95,3,0,9,0,1,103,108,95,70,111,103,70,114,97,103,67,111,111,114,100,0,0,0,
-1,90,95,0,0,12,0,0,102,116,114,97,110,115,102,111,114,109,0,0,1,9,18,95,95,114,101,116,86,97,108,0,
-18,103,108,95,77,111,100,101,108,86,105,101,119,80,114,111,106,101,99,116,105,111,110,77,97,116,
-114,105,120,0,16,8,48,0,57,18,103,108,95,86,101,114,116,101,120,0,59,120,120,120,120,0,48,18,103,
-108,95,77,111,100,101,108,86,105,101,119,80,114,111,106,101,99,116,105,111,110,77,97,116,114,105,
-120,0,16,10,49,0,57,18,103,108,95,86,101,114,116,101,120,0,59,121,121,121,121,0,48,46,18,103,108,
-95,77,111,100,101,108,86,105,101,119,80,114,111,106,101,99,116,105,111,110,77,97,116,114,105,120,0,
-16,10,50,0,57,18,103,108,95,86,101,114,116,101,120,0,59,122,122,122,122,0,48,46,18,103,108,95,77,
-111,100,101,108,86,105,101,119,80,114,111,106,101,99,116,105,111,110,77,97,116,114,105,120,0,16,10,
-51,0,57,18,103,108,95,86,101,114,116,101,120,0,59,119,119,119,119,0,48,46,20,0,0,1,90,95,0,0,12,0,
-0,116,101,120,116,117,114,101,49,68,76,111,100,0,1,1,0,0,16,0,115,97,109,112,108,101,114,0,0,1,1,0,
-0,9,0,99,111,111,114,100,0,0,1,1,0,0,9,0,108,111,100,0,0,0,1,3,2,90,95,0,0,12,0,1,99,111,111,114,
-100,52,0,0,0,9,18,99,111,111,114,100,52,0,59,120,0,18,99,111,111,114,100,0,20,0,9,18,99,111,111,
-114,100,52,0,59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,95,49,100,95,98,105,97,
-115,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,
-52,0,0,0,0,1,90,95,0,0,12,0,0,116,101,120,116,117,114,101,49,68,80,114,111,106,76,111,100,0,1,1,0,
-0,16,0,115,97,109,112,108,101,114,0,0,1,1,0,0,10,0,99,111,111,114,100,0,0,1,1,0,0,9,0,108,111,100,
-0,0,0,1,3,2,90,95,0,0,12,0,1,112,99,111,111,114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,0,
-18,99,111,111,114,100,0,59,120,0,18,99,111,111,114,100,0,59,121,0,49,20,0,9,18,112,99,111,111,114,
-100,0,59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,95,49,100,95,98,105,97,115,0,
-18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,112,99,111,111,114,100,0,0,
-0,0,1,90,95,0,0,12,0,0,116,101,120,116,117,114,101,49,68,80,114,111,106,76,111,100,0,1,1,0,0,16,0,
-115,97,109,112,108,101,114,0,0,1,1,0,0,12,0,99,111,111,114,100,0,0,1,1,0,0,9,0,108,111,100,0,0,0,1,
-3,2,90,95,0,0,12,0,1,112,99,111,111,114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,0,18,99,111,
-111,114,100,0,59,120,0,18,99,111,111,114,100,0,59,122,0,49,20,0,9,18,112,99,111,111,114,100,0,59,
-119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,95,49,100,95,98,105,97,115,0,18,95,95,
-114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,90,
-95,0,0,12,0,0,116,101,120,116,117,114,101,50,68,76,111,100,0,1,1,0,0,17,0,115,97,109,112,108,101,
-114,0,0,1,1,0,0,10,0,99,111,111,114,100,0,0,1,1,0,0,9,0,108,111,100,0,0,0,1,3,2,90,95,0,0,12,0,1,
-99,111,111,114,100,52,0,0,0,9,18,99,111,111,114,100,52,0,59,120,121,0,18,99,111,111,114,100,0,59,
-120,121,0,20,0,9,18,99,111,111,114,100,52,0,59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,
-101,120,95,50,100,95,98,105,97,115,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,
-114,0,0,18,99,111,111,114,100,52,0,0,0,0,1,90,95,0,0,12,0,0,116,101,120,116,117,114,101,50,68,80,
-114,111,106,76,111,100,0,1,1,0,0,17,0,115,97,109,112,108,101,114,0,0,1,1,0,0,11,0,99,111,111,114,
-100,0,0,1,1,0,0,9,0,108,111,100,0,0,0,1,3,2,90,95,0,0,12,0,1,112,99,111,111,114,100,0,0,0,9,18,112,
-99,111,111,114,100,0,59,120,121,0,18,99,111,111,114,100,0,59,120,121,0,18,99,111,111,114,100,0,59,
-122,0,49,20,0,9,18,112,99,111,111,114,100,0,59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,
-101,120,95,50,100,95,98,105,97,115,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,
-114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,90,95,0,0,12,0,0,116,101,120,116,117,114,101,50,68,80,
-114,111,106,76,111,100,0,1,1,0,0,17,0,115,97,109,112,108,101,114,0,0,1,1,0,0,12,0,99,111,111,114,
-100,0,0,1,1,0,0,9,0,108,111,100,0,0,0,1,3,2,90,95,0,0,12,0,1,112,99,111,111,114,100,0,0,0,9,18,112,
-99,111,111,114,100,0,59,120,121,0,18,99,111,111,114,100,0,59,120,121,0,18,99,111,111,114,100,0,59,
-122,0,49,20,0,9,18,112,99,111,111,114,100,0,59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,
-101,120,95,50,100,95,98,105,97,115,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,
-114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,90,95,0,0,12,0,0,116,101,120,116,117,114,101,51,68,76,
-111,100,0,1,1,0,0,18,0,115,97,109,112,108,101,114,0,0,1,1,0,0,11,0,99,111,111,114,100,0,0,1,1,0,0,
-9,0,108,111,100,0,0,0,1,3,2,90,95,0,0,12,0,1,99,111,111,114,100,52,0,0,0,9,18,99,111,111,114,100,
-52,0,59,120,121,122,0,18,99,111,111,114,100,0,59,120,121,122,0,20,0,9,18,99,111,111,114,100,52,0,
-59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,95,51,100,95,98,105,97,115,0,18,95,
-95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,52,0,0,0,0,1,
-90,95,0,0,12,0,0,116,101,120,116,117,114,101,51,68,80,114,111,106,76,111,100,0,1,1,0,0,18,0,115,97,
-109,112,108,101,114,0,0,1,1,0,0,12,0,99,111,111,114,100,0,0,1,1,0,0,9,0,108,111,100,0,0,0,1,3,2,90,
-95,0,0,12,0,1,112,99,111,111,114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,121,122,0,18,99,
-111,111,114,100,0,59,120,121,122,0,18,99,111,111,114,100,0,59,119,0,49,20,0,9,18,112,99,111,111,
-114,100,0,59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,95,51,100,95,98,105,97,115,
-0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,112,99,111,111,114,100,0,
-0,0,0,1,90,95,0,0,12,0,0,116,101,120,116,117,114,101,67,117,98,101,76,111,100,0,1,1,0,0,19,0,115,
-97,109,112,108,101,114,0,0,1,1,0,0,11,0,99,111,111,114,100,0,0,1,1,0,0,9,0,108,111,100,0,0,0,1,3,2,
-90,95,0,0,12,0,1,99,111,111,114,100,52,0,0,0,9,18,99,111,111,114,100,52,0,59,120,121,122,0,18,99,
-111,111,114,100,0,20,0,9,18,99,111,111,114,100,52,0,59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,
-95,116,101,120,95,99,117,98,101,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,
-0,0,18,99,111,111,114,100,52,0,0,0,0,1,90,95,0,0,12,0,0,115,104,97,100,111,119,49,68,76,111,100,0,
-1,1,0,0,20,0,115,97,109,112,108,101,114,0,0,1,1,0,0,11,0,99,111,111,114,100,0,0,1,1,0,0,9,0,108,
-111,100,0,0,0,1,3,2,90,95,0,0,12,0,1,99,111,111,114,100,52,0,0,0,9,18,99,111,111,114,100,52,0,59,
-120,121,122,0,18,99,111,111,114,100,0,20,0,9,18,99,111,111,114,100,52,0,59,119,0,18,108,111,100,0,
-20,0,4,118,101,99,52,95,116,101,120,95,49,100,95,98,105,97,115,95,115,104,97,100,111,119,0,18,95,
-95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,52,0,0,0,0,1,
-90,95,0,0,12,0,0,115,104,97,100,111,119,49,68,80,114,111,106,76,111,100,0,1,1,0,0,20,0,115,97,109,
-112,108,101,114,0,0,1,1,0,0,12,0,99,111,111,114,100,0,0,1,1,0,0,9,0,108,111,100,0,0,0,1,3,2,90,95,
-0,0,12,0,1,112,99,111,111,114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,0,18,99,111,111,114,
-100,0,59,120,0,18,99,111,111,114,100,0,59,119,0,49,20,0,9,18,112,99,111,111,114,100,0,59,122,0,18,
-99,111,111,114,100,0,59,122,0,20,0,9,18,112,99,111,111,114,100,0,59,119,0,18,108,111,100,0,20,0,4,
-118,101,99,52,95,116,101,120,95,49,100,95,98,105,97,115,95,115,104,97,100,111,119,0,18,95,95,114,
-101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,90,95,
-0,0,12,0,0,115,104,97,100,111,119,50,68,76,111,100,0,1,1,0,0,21,0,115,97,109,112,108,101,114,0,0,1,
-1,0,0,11,0,99,111,111,114,100,0,0,1,1,0,0,9,0,108,111,100,0,0,0,1,3,2,90,95,0,0,12,0,1,99,111,111,
-114,100,52,0,0,0,9,18,99,111,111,114,100,52,0,59,120,121,122,0,18,99,111,111,114,100,0,20,0,9,18,
-99,111,111,114,100,52,0,59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,95,50,100,95,
-98,105,97,115,95,115,104,97,100,111,119,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,
-101,114,0,0,18,99,111,111,114,100,52,0,0,0,0,1,90,95,0,0,12,0,0,115,104,97,100,111,119,50,68,80,
-114,111,106,76,111,100,0,1,1,0,0,21,0,115,97,109,112,108,101,114,0,0,1,1,0,0,12,0,99,111,111,114,
-100,0,0,1,1,0,0,9,0,108,111,100,0,0,0,1,3,2,90,95,0,0,12,0,1,112,99,111,111,114,100,0,0,0,9,18,112,
-99,111,111,114,100,0,59,120,121,0,18,99,111,111,114,100,0,59,120,121,0,18,99,111,111,114,100,0,59,
-119,0,49,20,0,9,18,112,99,111,111,114,100,0,59,122,0,18,99,111,111,114,100,0,59,122,0,20,0,9,18,
-112,99,111,111,114,100,0,59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,95,50,100,
-95,98,105,97,115,95,115,104,97,100,111,119,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,
-108,101,114,0,0,18,112,99,111,111,114,100,0,0,0,0,0
diff --git a/src/mesa/shader/slang/library/syn_to_c.c b/src/mesa/shader/slang/library/syn_to_c.c
deleted file mode 100644 (file)
index f997edf..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-#include <stdio.h>
-
-static int was_space = 0;
-static int first_char = 1;
-
-static void put_char (int c)
-{
-   if (c == '\n') {
-      if (!first_char) {
-         fputs ("\\n\"\n\"", stdout);
-         first_char = 1;
-      }
-   }
-   else {
-      first_char = 0;
-      if (c == '\\')
-         fputs ("\\\\", stdout);
-      else if (c == '\"')
-         fputs ("\\\"", stdout);
-      else if (!was_space || !(c == ' ' || c == '\t'))
-         fputc (c, stdout);
-      was_space = (c == ' ' || c == '\t');
-   }
-}
-
-int main (int argc, char *argv[])
-{
-   int c;
-   FILE *f;
-
-   if (argc == 1)
-      return 1;
-   f = fopen (argv[1], "r");
-   if (f == NULL)
-      return 1;
-
-   fputs ("\n", stdout);
-   fputs ("/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED FROM THE .syn FILE */\n", stdout);
-   fputs ("\n", stdout);
-   fputs ("\"", stdout);
-   c = getc (f);
-   while (c != EOF) {
-      if (c == '/') {
-         int c2 = getc (f);
-         if (c2 == '*') {
-            was_space = 0;
-            c = getc (f);
-            for (;;) {
-               if (c == '*') {
-                  c2 = getc (f);
-                  if (c2 == '/')
-                     break;
-               }
-               c = getc (f);
-            }
-         }
-         else {
-            put_char (c);
-            put_char (c2);
-         }
-      }
-      else {
-         put_char (c);
-      }
-      c = getc (f);
-   }
-   fputs ("\"\n", stdout);
-
-   fclose (f);
-   return 0;
-}
-
index 344dfdc6804d70a79a038a31bbf0e015f0c22719..372a9acdd03116ca34a298ec35c351b0af6ba5e7 100644 (file)
@@ -925,7 +925,7 @@ gen_return_with_expression(slang_assemble_ctx *A, slang_operation *oper)
       slang_operation_copy(rhs, &oper->children[0]);
    }
 
-   ///blockOper->locals->outer_scope = oper->locals->outer_scope;
+   /*blockOper->locals->outer_scope = oper->locals->outer_scope;*/
 
    /*slang_print_tree(blockOper, 0);*/
 
@@ -3763,6 +3763,14 @@ _slang_gen_var_decl(slang_assemble_ctx *A, slang_variable *var,
 #endif
       }
 
+      if (var->type.qualifier == SLANG_QUAL_UNIFORM &&
+          !A->allow_uniform_initializers) {
+         slang_info_log_error(A->log,
+                              "initializer for uniform %s not allowed",
+                              varName);
+         return NULL;
+      }
+
       /* IR for the variable we're initializing */
       varRef = new_var(A, var);
       if (!varRef) {
@@ -4241,14 +4249,15 @@ _slang_gen_assignment(slang_assemble_ctx * A, slang_operation *oper)
 
    if (oper->children[0].type == SLANG_OPER_IDENTIFIER) {
       /* Check that var is writeable */
+      const char *varName = (char *) oper->children[0].a_id;
       slang_variable *var
          = _slang_variable_locate(oper->children[0].locals,
                                   oper->children[0].a_id, GL_TRUE);
       if (!var) {
-         slang_info_log_error(A->log, "undefined variable '%s'",
-                              (char *) oper->children[0].a_id);
+         slang_info_log_error(A->log, "undefined variable '%s'", varName);
          return NULL;
       }
+
       if (var->type.qualifier == SLANG_QUAL_CONST ||
           var->type.qualifier == SLANG_QUAL_ATTRIBUTE ||
           var->type.qualifier == SLANG_QUAL_UNIFORM ||
@@ -4256,7 +4265,7 @@ _slang_gen_assignment(slang_assemble_ctx * A, slang_operation *oper)
            A->program->Target == GL_FRAGMENT_PROGRAM_ARB)) {
          slang_info_log_error(A->log,
                               "illegal assignment to read-only variable '%s'",
-                              (char *) oper->children[0].a_id);
+                              varName);
          return NULL;
       }
 
index ee3be55a459a8e47c05686b0b7eeb131d3e4dff8..461633fe346fb9a0f84bc246410656703bb405bf 100644 (file)
@@ -42,6 +42,7 @@ typedef struct slang_assemble_ctx_
    struct gl_sl_pragmas *pragmas;
    slang_var_table *vartable;
    slang_info_log *log;
+   GLboolean allow_uniform_initializers;
 
    /* current loop stack */
    const slang_operation *LoopOperStack[MAX_LOOP_DEPTH];
index a2708884437a906ccd4918837599859c485906f3..6499cfcb2fea6df802ed322c3afc703b8cdd13ff 100644 (file)
 #include "shader/prog_optimize.h"
 #include "shader/prog_print.h"
 #include "shader/prog_parameter.h"
-#include "shader/grammar/grammar_mesa.h"
+#include "../../glsl/pp/sl_pp_public.h"
+#include "../../glsl/cl/sl_cl_parse.h"
 #include "slang_codegen.h"
 #include "slang_compile.h"
-#include "slang_preprocess.h"
 #include "slang_storage.h"
 #include "slang_emit.h"
 #include "slang_log.h"
@@ -128,7 +128,7 @@ _slang_code_object_dtr(slang_code_object * self)
 
 typedef struct slang_parse_ctx_
 {
-   const byte *I;
+   const unsigned char *I;
    slang_info_log *L;
    int parsing_builtin;
    GLboolean global_scope;   /**< Is object being declared a global? */
@@ -183,23 +183,103 @@ parse_identifier(slang_parse_ctx * C)
    return slang_atom_pool_atom(C->atoms, id);
 }
 
+static int
+is_hex_digit(char c)
+{
+   return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');
+}
+
+static int
+parse_general_number(slang_parse_ctx *ctx, float *number)
+{
+   char *flt = NULL;
+
+   if (*ctx->I == '0') {
+      int value = 0;
+      const unsigned char *pi;
+
+      if (ctx->I[1] == 'x' || ctx->I[1] == 'X') {
+         ctx->I += 2;
+         if (!is_hex_digit(*ctx->I)) {
+            return 0;
+         }
+         do {
+            int digit;
+
+            if (*ctx->I >= '0' && *ctx->I <= '9') {
+               digit = (int)(*ctx->I - '0');
+            } else if (*ctx->I >= 'a' && *ctx->I <= 'f') {
+               digit = (int)(*ctx->I - 'a') + 10;
+            } else {
+               digit = (int)(*ctx->I - 'A') + 10;
+            }
+            value = value * 0x10 + digit;
+            ctx->I++;
+         } while (is_hex_digit(*ctx->I));
+         if (*ctx->I != '\0') {
+            return 0;
+         }
+         ctx->I++;
+         *number = (float)value;
+         return 1;
+      }
+
+      pi = ctx->I;
+      pi++;
+      while (*pi >= '0' && *pi <= '7') {
+         int digit;
+
+         digit = (int)(*pi - '0');
+         value = value * 010 + digit;
+         pi++;
+      }
+      if (*pi == '\0') {
+         pi++;
+         ctx->I = pi;
+         *number = (float)value;
+         return 1;
+      }
+   }
+
+   parse_identifier_str(ctx, &flt);
+   flt = strdup(flt);
+   if (!flt) {
+      return 0;
+   }
+   if (flt[strlen(flt) - 1] == 'f' || flt[strlen(flt) - 1] == 'F') {
+      flt[strlen(flt) - 1] = '\0';
+   }
+   *number = (float)_mesa_strtod(flt, (char **)NULL);
+   free(flt);
+
+   return 1;
+}
+
 static int
 parse_number(slang_parse_ctx * C, int *number)
 {
    const int radix = (int) (*C->I++);
-   *number = 0;
-   while (*C->I != '\0') {
-      int digit;
-      if (*C->I >= '0' && *C->I <= '9')
-         digit = (int) (*C->I - '0');
-      else if (*C->I >= 'A' && *C->I <= 'Z')
-         digit = (int) (*C->I - 'A') + 10;
-      else
-         digit = (int) (*C->I - 'a') + 10;
-      *number = *number * radix + digit;
+
+   if (radix == 1) {
+      float f = 0.0f;
+
+      parse_general_number(C, &f);
+      *number = (int)f;
+   } else {
+      *number = 0;
+      while (*C->I != '\0') {
+         int digit;
+         if (*C->I >= '0' && *C->I <= '9')
+            digit = (int) (*C->I - '0');
+         else if (*C->I >= 'A' && *C->I <= 'Z')
+            digit = (int) (*C->I - 'A') + 10;
+         else
+            digit = (int) (*C->I - 'a') + 10;
+         *number = *number * radix + digit;
+         C->I++;
+      }
       C->I++;
    }
-   C->I++;
    if (*number > 65535)
       slang_info_log_warning(C->L, "%d: literal integer overflow.", *number);
    return 1;
@@ -208,32 +288,37 @@ parse_number(slang_parse_ctx * C, int *number)
 static int
 parse_float(slang_parse_ctx * C, float *number)
 {
-   char *integral = NULL;
-   char *fractional = NULL;
-   char *exponent = NULL;
-   char *whole = NULL;
-
-   parse_identifier_str(C, &integral);
-   parse_identifier_str(C, &fractional);
-   parse_identifier_str(C, &exponent);
-
-   whole = (char *) _slang_alloc((_mesa_strlen(integral) +
-                                  _mesa_strlen(fractional) +
-                                  _mesa_strlen(exponent) + 3) * sizeof(char));
-   if (whole == NULL) {
-      slang_info_log_memory(C->L);
-      RETURN0;
-   }
+   if (*C->I == 1) {
+      C->I++;
+      parse_general_number(C, number);
+   } else {
+      char *integral = NULL;
+      char *fractional = NULL;
+      char *exponent = NULL;
+      char *whole = NULL;
+
+      parse_identifier_str(C, &integral);
+      parse_identifier_str(C, &fractional);
+      parse_identifier_str(C, &exponent);
+
+      whole = (char *) _slang_alloc((_mesa_strlen(integral) +
+                                     _mesa_strlen(fractional) +
+                                     _mesa_strlen(exponent) + 3) * sizeof(char));
+      if (whole == NULL) {
+         slang_info_log_memory(C->L);
+         RETURN0;
+      }
 
-   slang_string_copy(whole, integral);
-   slang_string_concat(whole, ".");
-   slang_string_concat(whole, fractional);
-   slang_string_concat(whole, "E");
-   slang_string_concat(whole, exponent);
+      slang_string_copy(whole, integral);
+      slang_string_concat(whole, ".");
+      slang_string_concat(whole, fractional);
+      slang_string_concat(whole, "E");
+      slang_string_concat(whole, exponent);
 
-   *number = (float) (_mesa_strtod(whole, (char **) NULL));
+      *number = (float) (_mesa_strtod(whole, (char **) NULL));
 
-   _slang_free(whole);
+      _slang_free(whole);
+   }
 
    return 1;
 }
@@ -2058,6 +2143,7 @@ parse_init_declarator(slang_parse_ctx * C, slang_output_ctx * O,
    if (C->global_scope) {
       slang_assemble_ctx A;
       memset(&A, 0, sizeof(slang_assemble_ctx));
+      A.allow_uniform_initializers = C->version > 110;
       A.atoms = C->atoms;
       A.space.funcs = O->funs;
       A.space.structs = O->structs;
@@ -2077,6 +2163,7 @@ parse_init_declarator(slang_parse_ctx * C, slang_output_ctx * O,
       if (var->initializer != NULL) {
          slang_assemble_ctx A;
          memset(&A, 0, sizeof(slang_assemble_ctx));
+         A.allow_uniform_initializers = C->version > 110;
          A.atoms = C->atoms;
          A.space.funcs = O->funs;
          A.space.structs = O->structs;
@@ -2434,6 +2521,7 @@ parse_code_unit(slang_parse_ctx * C, slang_code_unit * unit,
       A.vartable = o.vartable;
       A.EmitContReturn = ctx->Shader.EmitContReturn;
       A.log = C->L;
+      A.allow_uniform_initializers = C->version > 110;
 
       /* main() takes no parameters */
       if (mainFunc->param_count > 0) {
@@ -2455,7 +2543,7 @@ parse_code_unit(slang_parse_ctx * C, slang_code_unit * unit,
 }
 
 static GLboolean
-compile_binary(const byte * prod, slang_code_unit * unit,
+compile_binary(const unsigned char * prod, slang_code_unit * unit,
                GLuint version,
                slang_unit_type type, slang_info_log * infolog,
                slang_code_unit * builtin, slang_code_unit * downlink,
@@ -2488,17 +2576,56 @@ compile_binary(const byte * prod, slang_code_unit * unit,
 }
 
 static GLboolean
-compile_with_grammar(grammar id, const char *source, slang_code_unit * unit,
-                     slang_unit_type type, slang_info_log * infolog,
-                     slang_code_unit * builtin,
+compile_with_grammar(const char *source,
+                     slang_code_unit *unit,
+                     slang_unit_type type,
+                     slang_info_log *infolog,
+                     slang_code_unit *builtin,
                      struct gl_shader *shader,
-                     const struct gl_extensions *extensions,
-                     struct gl_sl_pragmas *pragmas)
+                     struct gl_sl_pragmas *pragmas,
+                     unsigned int shader_type,
+                     unsigned int parsing_builtin)
 {
-   byte *prod;
-   GLuint size, start, version;
-   slang_string preprocessed;
-   GLuint maxVersion;
+   struct sl_pp_purify_options options;
+   struct sl_pp_context *context;
+   unsigned char *prod;
+   GLuint size;
+   unsigned int version;
+   unsigned int maxVersion;
+   int result;
+   char errmsg[200] = "";
+
+   assert(shader_type == 1 || shader_type == 2);
+
+   memset(&options, 0, sizeof(options));
+
+   context = sl_pp_context_create(source, &options);
+   if (!context) {
+      slang_info_log_error(infolog, "out of memory");
+      return GL_FALSE;
+   }
+
+   if (sl_pp_version(context, &version)) {
+      slang_info_log_error(infolog, "%s", sl_pp_context_error_message(context));
+      sl_pp_context_destroy(context);
+      return GL_FALSE;
+   }
+
+   if (sl_pp_context_add_extension(context, "ARB_draw_buffers", "GL_ARB_draw_buffers") ||
+       sl_pp_context_add_extension(context, "ARB_texture_rectangle", "GL_ARB_texture_rectangle")) {
+      slang_info_log_error(infolog, "%s", sl_pp_context_error_message(context));
+      sl_pp_context_destroy(context);
+      return GL_FALSE;
+   }
+
+#if FEATURE_es2_glsl
+   if (sl_pp_context_add_predefined(context, "GL_ES", "1") ||
+       sl_pp_context_add_predefined(context, "GL_FRAGMENT_PRECISION_HIGH", "1")) {
+      slang_info_log_error(infolog, "%s", sl_pp_context_error_message(context));
+      sl_pp_context_destroy(context);
+      return GL_FALSE;
+   }
+#endif
 
 #if FEATURE_ARB_shading_language_120
    maxVersion = 120;
@@ -2508,36 +2635,30 @@ compile_with_grammar(grammar id, const char *source, slang_code_unit * unit,
    maxVersion = 110;
 #endif
 
-   /* First retrieve the version number. */
-   if (!_slang_preprocess_version(source, &version, &start, infolog))
-      return GL_FALSE;
-
-   if (version > maxVersion) {
+   if (version > maxVersion ||
+       (version != 100 && version != 110 && version != 120)) {
       slang_info_log_error(infolog,
                            "language version %.2f is not supported.",
                            version * 0.01);
-      return GL_FALSE;
-   }
-
-   /* Now preprocess the source string. */
-   slang_string_init(&preprocessed);
-   if (!_slang_preprocess_directives(&preprocessed, &source[start],
-                                     infolog, extensions, pragmas)) {
-      slang_string_free(&preprocessed);
-      slang_info_log_error(infolog, "failed to preprocess the source.");
+      sl_pp_context_destroy(context);
       return GL_FALSE;
    }
 
    /* Finally check the syntax and generate its binary representation. */
-   if (!grammar_fast_check(id,
-                           (const byte *) (slang_string_cstr(&preprocessed)),
-                           &prod, &size, 65536)) {
-      char buf[1024];
-      GLint pos;
-
-      slang_string_free(&preprocessed);
-      grammar_get_last_error((byte *) (buf), sizeof(buf), &pos);
-      slang_info_log_error(infolog, buf);
+   result = sl_cl_compile(context,
+                          shader_type,
+                          parsing_builtin,
+                          &prod,
+                          &size,
+                          errmsg,
+                          sizeof(errmsg));
+
+   sl_pp_context_destroy(context);
+
+   if (result) {
+      /*GLint pos;*/
+
+      slang_info_log_error(infolog, errmsg);
       /* syntax error (possibly in library code) */
 #if 0
       {
@@ -2551,77 +2672,64 @@ compile_with_grammar(grammar id, const char *source, slang_code_unit * unit,
 #endif
       return GL_FALSE;
    }
-   slang_string_free(&preprocessed);
 
    /* Syntax is okay - translate it to internal representation. */
    if (!compile_binary(prod, unit, version, type, infolog, builtin,
                        &builtin[SLANG_BUILTIN_TOTAL - 1],
                        shader)) {
-      grammar_alloc_free(prod);
+      free(prod);
       return GL_FALSE;
    }
-   grammar_alloc_free(prod);
+   free(prod);
    return GL_TRUE;
 }
 
-LONGSTRING static const char *slang_shader_syn =
-#include "library/slang_shader_syn.h"
-   ;
-
-static const byte slang_core_gc[] = {
+static const unsigned char slang_core_gc[] = {
 #include "library/slang_core_gc.h"
 };
 
-static const byte slang_120_core_gc[] = {
+static const unsigned char slang_120_core_gc[] = {
 #include "library/slang_120_core_gc.h"
 };
 
-static const byte slang_120_fragment_gc[] = {
+static const unsigned char slang_120_fragment_gc[] = {
 #include "library/slang_builtin_120_fragment_gc.h"
 };
 
-static const byte slang_common_builtin_gc[] = {
+static const unsigned char slang_common_builtin_gc[] = {
 #include "library/slang_common_builtin_gc.h"
 };
 
-static const byte slang_fragment_builtin_gc[] = {
+static const unsigned char slang_fragment_builtin_gc[] = {
 #include "library/slang_fragment_builtin_gc.h"
 };
 
-static const byte slang_vertex_builtin_gc[] = {
+static const unsigned char slang_vertex_builtin_gc[] = {
 #include "library/slang_vertex_builtin_gc.h"
 };
 
 static GLboolean
-compile_object(grammar * id, const char *source, slang_code_object * object,
-               slang_unit_type type, slang_info_log * infolog,
+compile_object(const char *source,
+               slang_code_object *object,
+               slang_unit_type type,
+               slang_info_log *infolog,
                struct gl_shader *shader,
-               const struct gl_extensions *extensions,
                struct gl_sl_pragmas *pragmas)
 {
    slang_code_unit *builtins = NULL;
    GLuint base_version = 110;
-
-   /* load GLSL grammar */
-   *id = grammar_load_from_text((const byte *) (slang_shader_syn));
-   if (*id == 0) {
-      byte buf[1024];
-      int pos;
-
-      grammar_get_last_error(buf, 1024, &pos);
-      slang_info_log_error(infolog, (const char *) (buf));
-      return GL_FALSE;
-   }
+   unsigned int shader_type;
+   unsigned int parsing_builtin;
 
    /* set shader type - the syntax is slightly different for different shaders */
-   if (type == SLANG_UNIT_FRAGMENT_SHADER
-       || type == SLANG_UNIT_FRAGMENT_BUILTIN)
-      grammar_set_reg8(*id, (const byte *) "shader_type", 1);
-   else
-      grammar_set_reg8(*id, (const byte *) "shader_type", 2);
+   if (type == SLANG_UNIT_FRAGMENT_SHADER || type == SLANG_UNIT_FRAGMENT_BUILTIN) {
+      shader_type = 1;
+   } else {
+      shader_type = 2;
+   }
 
    /* enable language extensions */
-   grammar_set_reg8(*id, (const byte *) "parsing_builtin", 1);
+   parsing_builtin = 1;
 
    /* if parsing user-specified shader, load built-in library */
    if (type == SLANG_UNIT_FRAGMENT_SHADER || type == SLANG_UNIT_VERTEX_SHADER) {
@@ -2686,51 +2794,24 @@ compile_object(grammar * id, const char *source, slang_code_object * object,
       }
 
       /* disable language extensions */
-#if NEW_SLANG /* allow-built-ins */
-      grammar_set_reg8(*id, (const byte *) "parsing_builtin", 1);
-#else
-      grammar_set_reg8(*id, (const byte *) "parsing_builtin", 0);
-#endif
+      parsing_builtin = 0;
+
       builtins = object->builtin;
    }
 
    /* compile the actual shader - pass-in built-in library for external shader */
-   return compile_with_grammar(*id, source, &object->unit, type, infolog,
-                               builtins, shader, extensions, pragmas);
-}
-
-
-static GLboolean
-compile_shader(GLcontext *ctx, slang_code_object * object,
-               slang_unit_type type, slang_info_log * infolog,
-               struct gl_shader *shader)
-{
-   GLboolean success;
-   grammar id = 0;
-
-#if 0 /* for debug */
-   _mesa_printf("********* COMPILE SHADER ***********\n");
-   _mesa_printf("%s\n", shader->Source);
-   _mesa_printf("************************************\n");
-#endif
-
-   assert(shader->Program);
-
-   _slang_code_object_dtr(object);
-   _slang_code_object_ctr(object);
-
-   success = compile_object(&id, shader->Source, object, type, infolog, shader,
-                            &ctx->Extensions, &shader->Pragmas);
-   if (id != 0)
-      grammar_destroy(id);
-   if (!success)
-      return GL_FALSE;
-
-   return GL_TRUE;
+   return compile_with_grammar(source,
+                               &object->unit,
+                               type,
+                               infolog,
+                               builtins,
+                               shader,
+                               pragmas,
+                               shader_type,
+                               parsing_builtin);
 }
 
 
-
 GLboolean
 _slang_compile(GLcontext *ctx, struct gl_shader *shader)
 {
@@ -2738,6 +2819,7 @@ _slang_compile(GLcontext *ctx, struct gl_shader *shader)
    slang_info_log info_log;
    slang_code_object obj;
    slang_unit_type type;
+   GLenum progTarget;
 
    if (shader->Type == GL_VERTEX_SHADER) {
       type = SLANG_UNIT_VERTEX_SHADER;
@@ -2754,22 +2836,28 @@ _slang_compile(GLcontext *ctx, struct gl_shader *shader)
 
    shader->Main = GL_FALSE;
 
-   if (!shader->Program) {
-      GLenum progTarget;
-      if (shader->Type == GL_VERTEX_SHADER)
-         progTarget = GL_VERTEX_PROGRAM_ARB;
-      else
-         progTarget = GL_FRAGMENT_PROGRAM_ARB;
-      shader->Program = ctx->Driver.NewProgram(ctx, progTarget, 1);
-      shader->Program->Parameters = _mesa_new_parameter_list();
-      shader->Program->Varying = _mesa_new_parameter_list();
-      shader->Program->Attributes = _mesa_new_parameter_list();
-   }
+   /* free the shader's old instructions, etc */
+   _mesa_reference_program(ctx, &shader->Program, NULL);
+
+   /* allocate new GPU program, parameter lists, etc. */
+   if (shader->Type == GL_VERTEX_SHADER)
+      progTarget = GL_VERTEX_PROGRAM_ARB;
+   else
+      progTarget = GL_FRAGMENT_PROGRAM_ARB;
+   shader->Program = ctx->Driver.NewProgram(ctx, progTarget, 1);
+   shader->Program->Parameters = _mesa_new_parameter_list();
+   shader->Program->Varying = _mesa_new_parameter_list();
+   shader->Program->Attributes = _mesa_new_parameter_list();
 
    slang_info_log_construct(&info_log);
    _slang_code_object_ctr(&obj);
 
-   success = compile_shader(ctx, &obj, type, &info_log, shader);
+   success = compile_object(shader->Source,
+                            &obj,
+                            type,
+                            &info_log,
+                            shader,
+                            &shader->Pragmas);
 
    /* free shader's prev info log */
    if (shader->InfoLog) {
index 3e2bdbc91ffa5a79a16fd35dc2f8807c3cf81ab3..3a15d9d3ab588591d9cd86549a3daeaa458baae2 100644 (file)
@@ -46,12 +46,14 @@ slang_operation_construct(slang_operation * oper)
    oper->literal_size = 1;
    oper->array_constructor = GL_FALSE;
    oper->a_id = SLANG_ATOM_NULL;
+   oper->a_obj = SLANG_ATOM_NULL;
    oper->locals = _slang_variable_scope_new(NULL);
    if (oper->locals == NULL)
       return GL_FALSE;
    _slang_variable_scope_ctr(oper->locals);
    oper->fun = NULL;
    oper->var = NULL;
+   oper->label = NULL;
    return GL_TRUE;
 }
 
index 58f1edeed85f4b8199c6501f18238d8cddb464ae..1f15c1989637aecb1860a2da3d20372b7833ee78 100644 (file)
@@ -127,7 +127,6 @@ typedef struct slang_operation_
     * indicate such.  num_children indicates number of elements.
     */
    GLboolean array_constructor;
-   double x;
 } slang_operation;
 
 
index 3af301eacdf1e448aa8e3eb78d78de0c941b1161..ce3f6ab7ea274d0b2b0117e7aeebdddfa24b7c12 100644 (file)
@@ -81,8 +81,8 @@ new_subroutine(slang_emit_info *emitInfo, GLuint *id)
 
    emitInfo->Subroutines = (struct gl_program **)
       _mesa_realloc(emitInfo->Subroutines,
-                    n * sizeof(struct gl_program),
-                    (n + 1) * sizeof(struct gl_program));
+                    n * sizeof(struct gl_program *),
+                    (n + 1) * sizeof(struct gl_program *));
    emitInfo->Subroutines[n] = ctx->Driver.NewProgram(ctx, emitInfo->prog->Target, 0);
    emitInfo->Subroutines[n]->Parameters = emitInfo->prog->Parameters;
    emitInfo->NumSubroutines++;
@@ -195,6 +195,9 @@ alloc_node_storage(slang_emit_info *emitInfo, slang_ir_node *n,
    if (!n->Store) {
       assert(defaultSize > 0);
       n->Store = _slang_new_ir_storage(PROGRAM_TEMPORARY, -1, defaultSize);
+      if (!n->Store) {
+         return GL_FALSE;
+      }
    }
 
    /* now allocate actual register(s).  I.e. set n->Store->Index >= 0 */
@@ -431,6 +434,9 @@ new_instruction(slang_emit_info *emitInfo, gl_inst_opcode opcode)
          _mesa_realloc_instructions(prog->Instructions,
                                     prog->NumInstructions,
                                     emitInfo->MaxInstructions);
+      if (!prog->Instructions) {
+         return NULL;
+      }
    }
 
    inst = prog->Instructions + prog->NumInstructions;
@@ -451,12 +457,14 @@ emit_arl_load(slang_emit_info *emitInfo,
               gl_register_file file, GLint index, GLuint swizzle)
 {
    struct prog_instruction *inst = new_instruction(emitInfo, OPCODE_ARL);
-   inst->SrcReg[0].File = file;
-   inst->SrcReg[0].Index = index;
-   inst->SrcReg[0].Swizzle = fix_swizzle(swizzle);
-   inst->DstReg.File = PROGRAM_ADDRESS;
-   inst->DstReg.Index = 0;
-   inst->DstReg.WriteMask = WRITEMASK_X;
+   if (inst) {
+      inst->SrcReg[0].File = file;
+      inst->SrcReg[0].Index = index;
+      inst->SrcReg[0].Swizzle = fix_swizzle(swizzle);
+      inst->DstReg.File = PROGRAM_ADDRESS;
+      inst->DstReg.Index = 0;
+      inst->DstReg.WriteMask = WRITEMASK_X;
+   }
    return inst;
 }
 
@@ -543,6 +551,9 @@ emit_instruction(slang_emit_info *emitInfo,
                                        &srcRelAddr,
                                        NULL,
                                        NULL);
+               if (!inst) {
+                  return NULL;
+               }
 
                src[i] = &newSrc[i];
             }
@@ -765,7 +776,9 @@ static struct prog_instruction *
 emit_comment(slang_emit_info *emitInfo, const char *comment)
 {
    struct prog_instruction *inst = new_instruction(emitInfo, OPCODE_NOP);
-   inst_comment(inst, comment);
+   if (inst) {
+      inst_comment(inst, comment);
+   }
    return inst;
 }
 
@@ -792,7 +805,9 @@ emit_arith(slang_emit_info *emitInfo, slang_ir_node *n)
       emit(emitInfo, n->Children[0]->Children[0]);  /* A */
       emit(emitInfo, n->Children[0]->Children[1]);  /* B */
       emit(emitInfo, n->Children[1]);  /* C */
-      alloc_node_storage(emitInfo, n, -1);  /* dest */
+      if (!alloc_node_storage(emitInfo, n, -1)) {  /* dest */
+         return NULL;
+      }
 
       inst = emit_instruction(emitInfo,
                               OPCODE_MAD,
@@ -813,7 +828,9 @@ emit_arith(slang_emit_info *emitInfo, slang_ir_node *n)
       emit(emitInfo, n->Children[0]);  /* A */
       emit(emitInfo, n->Children[1]->Children[0]);  /* B */
       emit(emitInfo, n->Children[1]->Children[1]);  /* C */
-      alloc_node_storage(emitInfo, n, -1);  /* dest */
+      if (!alloc_node_storage(emitInfo, n, -1)) {  /* dest */
+         return NULL;
+      }
 
       inst = emit_instruction(emitInfo,
                               OPCODE_MAD,
@@ -839,7 +856,9 @@ emit_arith(slang_emit_info *emitInfo, slang_ir_node *n)
    }
 
    /* result storage */
-   alloc_node_storage(emitInfo, n, -1);
+   if (!alloc_node_storage(emitInfo, n, -1)) {
+      return NULL;
+   }
 
    inst = emit_instruction(emitInfo,
                            info->InstOpcode,
@@ -932,6 +951,9 @@ emit_compare(slang_emit_info *emitInfo, slang_ir_node *n)
                               n->Children[0]->Store,
                               n->Children[1]->Store,
                               NULL);
+      if (!inst) {
+         return NULL;
+      }
       inst_comment(inst, "Compare values");
 
       /* Compute val = DOT(temp, temp)  (reduction) */
@@ -941,6 +963,9 @@ emit_compare(slang_emit_info *emitInfo, slang_ir_node *n)
                               &tempStore,
                               &tempStore,
                               NULL);
+      if (!inst) {
+         return NULL;
+      }
       inst->SrcReg[0].Swizzle = inst->SrcReg[1].Swizzle = swizzle; /*override*/
       inst_comment(inst, "Reduce vec to bool");
 
@@ -956,6 +981,9 @@ emit_compare(slang_emit_info *emitInfo, slang_ir_node *n)
                                  n->Store,
                                  &zero,
                                  NULL);
+         if (!inst) {
+            return NULL;
+         }
          inst_comment(inst, "Invert true/false");
       }
    }
@@ -985,6 +1013,9 @@ emit_compare(slang_emit_info *emitInfo, slang_ir_node *n)
                                     &srcStore0,
                                     &srcStore1,
                                     NULL);
+            if (!inst) {
+               return NULL;
+            }
             inst_comment(inst, "Begin struct/array comparison");
          }
          else {
@@ -994,12 +1025,18 @@ emit_compare(slang_emit_info *emitInfo, slang_ir_node *n)
                                     &srcStore0,
                                     &srcStore1,
                                     NULL);
+            if (!inst) {
+               return NULL;
+            }
             /* ADD accTemp, accTemp, sneTemp; # like logical-OR */
             inst = emit_instruction(emitInfo, OPCODE_ADD,
                                     &accTemp, /* dest */
                                     &accTemp,
                                     &sneTemp,
                                     NULL);
+            if (!inst) {
+               return NULL;
+            }
          }
       }
 
@@ -1009,6 +1046,9 @@ emit_compare(slang_emit_info *emitInfo, slang_ir_node *n)
                               &accTemp,
                               &accTemp,
                               NULL);
+      if (!inst) {
+         return NULL;
+      }
       inst_comment(inst, "End struct/array comparison");
 
       if (n->Opcode == IR_EQUAL) {
@@ -1020,6 +1060,9 @@ emit_compare(slang_emit_info *emitInfo, slang_ir_node *n)
                                  n->Store,
                                  &zero,
                                  NULL);
+         if (!inst) {
+            return NULL;
+         }
          inst_comment(inst, "Invert true/false");
       }
 
@@ -1093,7 +1136,9 @@ emit_clamp(slang_emit_info *emitInfo, slang_ir_node *n)
     * the intermediate result.  Use a temp register instead.
     */
    _mesa_bzero(&tmpNode, sizeof(tmpNode));
-   alloc_node_storage(emitInfo, &tmpNode, n->Store->Size);
+   if (!alloc_node_storage(emitInfo, &tmpNode, n->Store->Size)) {
+      return NULL;
+   }
 
    /* tmp = max(ch[0], ch[1]) */
    inst = emit_instruction(emitInfo, OPCODE_MAX,
@@ -1101,6 +1146,9 @@ emit_clamp(slang_emit_info *emitInfo, slang_ir_node *n)
                            n->Children[0]->Store,
                            n->Children[1]->Store,
                            NULL);
+   if (!inst) {
+      return NULL;
+   }
 
    /* n->dest = min(tmp, ch[2]) */
    inst = emit_instruction(emitInfo, OPCODE_MIN,
@@ -1135,7 +1183,9 @@ emit_negation(slang_emit_info *emitInfo, slang_ir_node *n)
                            n->Children[0]->Store,
                            NULL,
                            NULL);
-   inst->SrcReg[0].Negate = NEGATE_XYZW;
+   if (inst) {
+      inst->SrcReg[0].Negate = NEGATE_XYZW;
+   }
    return inst;
 }
 
@@ -1191,6 +1241,9 @@ emit_fcall(slang_emit_info *emitInfo, slang_ir_node *n)
        * really just a NOP to attach the label to.
        */
       inst = new_instruction(emitInfo, OPCODE_BGNSUB);
+      if (!inst) {
+         return NULL;
+      }
       inst_comment(inst, n->Label->Name);
    }
 
@@ -1202,10 +1255,16 @@ emit_fcall(slang_emit_info *emitInfo, slang_ir_node *n)
    inst = prev_instruction(emitInfo);
    if (inst && inst->Opcode != OPCODE_RET) {
       inst = new_instruction(emitInfo, OPCODE_RET);
+      if (!inst) {
+         return NULL;
+      }
    }
 
    if (emitInfo->EmitBeginEndSub) {
       inst = new_instruction(emitInfo, OPCODE_ENDSUB);
+      if (!inst) {
+         return NULL;
+      }
       inst_comment(inst, n->Label->Name);
    }
 
@@ -1215,6 +1274,9 @@ emit_fcall(slang_emit_info *emitInfo, slang_ir_node *n)
 
    /* emit the function call */
    inst = new_instruction(emitInfo, OPCODE_CAL);
+   if (!inst) {
+      return NULL;
+   }
    /* The branch target is just the subroutine number (changed later) */
    inst->BranchTarget = subroutineId;
    inst_comment(inst, n->Label->Name);
@@ -1235,7 +1297,9 @@ emit_return(slang_emit_info *emitInfo, slang_ir_node *n)
    assert(n->Opcode == IR_RETURN);
    assert(n->Label);
    inst = new_instruction(emitInfo, OPCODE_RET);
-   inst->DstReg.CondMask = COND_TR;  /* always return */
+   if (inst) {
+      inst->DstReg.CondMask = COND_TR;  /* always return */
+   }
    return inst;
 }
 
@@ -1249,6 +1313,9 @@ emit_kill(slang_emit_info *emitInfo)
     * Note that ARB-KILL depends on sign of vector operand.
     */
    inst = new_instruction(emitInfo, OPCODE_KIL_NV);
+   if (!inst) {
+      return NULL;
+   }
    inst->DstReg.CondMask = COND_TR;  /* always kill */
 
    assert(emitInfo->prog->Target == GL_FRAGMENT_PROGRAM_ARB);
@@ -1321,6 +1388,9 @@ emit_tex(slang_emit_info *emitInfo, slang_ir_node *n)
                            n->Children[1]->Store,
                            NULL,
                            NULL);
+   if (!inst) {
+      return NULL;
+   }
 
    inst->TexShadow = shadow;
 
@@ -1423,6 +1493,9 @@ emit_copy(slang_emit_info *emitInfo, slang_ir_node *n)
                                     &srcStore,
                                     NULL,
                                     NULL);
+            if (!inst) {
+               return NULL;
+            }
             inst_comment(inst, "IR_COPY block");
             srcStore.Index++;
             dstStore.Index++;
@@ -1438,6 +1511,9 @@ emit_copy(slang_emit_info *emitInfo, slang_ir_node *n)
                                  n->Children[1]->Store,
                                  NULL,
                                  NULL);
+         if (!inst) {
+            return NULL;
+         }
          dstAnnot = storage_annotation(n->Children[0], emitInfo->prog);
          srcAnnot = storage_annotation(n->Children[1], emitInfo->prog);
          inst->Comment = instruction_annotation(inst->Opcode, dstAnnot,
@@ -1499,6 +1575,9 @@ emit_cond(slang_emit_info *emitInfo, slang_ir_node *n)
                                  n->Children[0]->Store,
                                  NULL,
                                  NULL);
+         if (!inst) {
+            return NULL;
+         }
          inst->CondUpdate = GL_TRUE;
          inst_comment(inst, "COND expr");
          _slang_free_temp(emitInfo->vt, n->Store);
@@ -1561,6 +1640,9 @@ emit_not(slang_emit_info *emitInfo, slang_ir_node *n)
                            n->Children[0]->Store,
                            &zero,
                            NULL);
+   if (!inst) {
+      return NULL;
+   }
    inst_comment(inst, "NOT");
 
    free_node_storage(emitInfo->vt, n->Children[0]);
@@ -1600,8 +1682,10 @@ emit_if(slang_emit_info *emitInfo, slang_ir_node *n)
    if (emitInfo->EmitHighLevelInstructions) {
       if (emitInfo->EmitCondCodes) {
          /* IF condcode THEN ... */
-         struct prog_instruction *ifInst;
-         ifInst = new_instruction(emitInfo, OPCODE_IF);
+         struct prog_instruction *ifInst = new_instruction(emitInfo, OPCODE_IF);
+         if (!ifInst) {
+            return NULL;
+         }
          ifInst->DstReg.CondMask = COND_NE;  /* if cond is non-zero */
          /* only test the cond code (1 of 4) that was updated by the
           * previous instruction.
@@ -1609,17 +1693,25 @@ emit_if(slang_emit_info *emitInfo, slang_ir_node *n)
          ifInst->DstReg.CondSwizzle = writemask_to_swizzle(condWritemask);
       }
       else {
+         struct prog_instruction *inst;
+
          /* IF src[0] THEN ... */
-         emit_instruction(emitInfo, OPCODE_IF,
-                          NULL, /* dst */
-                          n->Children[0]->Store, /* op0 */
-                          NULL,
-                          NULL);
+         inst = emit_instruction(emitInfo, OPCODE_IF,
+                                 NULL, /* dst */
+                                 n->Children[0]->Store, /* op0 */
+                                 NULL,
+                                 NULL);
+         if (!inst) {
+            return NULL;
+         }
       }
    }
    else {
       /* conditional jump to else, or endif */
       struct prog_instruction *ifInst = new_instruction(emitInfo, OPCODE_BRA);
+      if (!ifInst) {
+         return NULL;
+      }
       ifInst->DstReg.CondMask = COND_EQ;  /* BRA if cond is zero */
       inst_comment(ifInst, "if zero");
       ifInst->DstReg.CondSwizzle = writemask_to_swizzle(condWritemask);
@@ -1632,16 +1724,22 @@ emit_if(slang_emit_info *emitInfo, slang_ir_node *n)
       /* have else body */
       elseInstLoc = prog->NumInstructions;
       if (emitInfo->EmitHighLevelInstructions) {
-         (void) new_instruction(emitInfo, OPCODE_ELSE);
+         struct prog_instruction *inst = new_instruction(emitInfo, OPCODE_ELSE);
+         if (!inst) {
+            return NULL;
+         }
+         prog->Instructions[ifInstLoc].BranchTarget = prog->NumInstructions - 1;
       }
       else {
          /* jump to endif instruction */
-         struct prog_instruction *inst;
-         inst = new_instruction(emitInfo, OPCODE_BRA);
+         struct prog_instruction *inst = new_instruction(emitInfo, OPCODE_BRA);
+         if (!inst) {
+            return NULL;
+         }
          inst_comment(inst, "else");
          inst->DstReg.CondMask = COND_TR;  /* always branch */
+         prog->Instructions[ifInstLoc].BranchTarget = prog->NumInstructions;
       }
-      prog->Instructions[ifInstLoc].BranchTarget = prog->NumInstructions;
       emit(emitInfo, n->Children[2]);
    }
    else {
@@ -1650,11 +1748,20 @@ emit_if(slang_emit_info *emitInfo, slang_ir_node *n)
    }
 
    if (emitInfo->EmitHighLevelInstructions) {
-      (void) new_instruction(emitInfo, OPCODE_ENDIF);
+      struct prog_instruction *inst = new_instruction(emitInfo, OPCODE_ENDIF);
+      if (!inst) {
+         return NULL;
+      }
    }
 
-   if (n->Children[2]) {
-      prog->Instructions[elseInstLoc].BranchTarget = prog->NumInstructions;
+   if (elseInstLoc) {
+      /* point ELSE instruction BranchTarget at ENDIF */
+      if (emitInfo->EmitHighLevelInstructions) {
+         prog->Instructions[elseInstLoc].BranchTarget = prog->NumInstructions - 1;
+      }
+      else {
+         prog->Instructions[elseInstLoc].BranchTarget = prog->NumInstructions;
+      }
    }
    return NULL;
 }
@@ -1671,7 +1778,10 @@ emit_loop(slang_emit_info *emitInfo, slang_ir_node *n)
    /* emit OPCODE_BGNLOOP */
    beginInstLoc = prog->NumInstructions;
    if (emitInfo->EmitHighLevelInstructions) {
-      (void) new_instruction(emitInfo, OPCODE_BGNLOOP);
+      struct prog_instruction *inst = new_instruction(emitInfo, OPCODE_BGNLOOP);
+      if (!inst) {
+         return NULL;
+      }
    }
 
    /* body */
@@ -1689,10 +1799,16 @@ emit_loop(slang_emit_info *emitInfo, slang_ir_node *n)
    if (emitInfo->EmitHighLevelInstructions) {
       /* emit OPCODE_ENDLOOP */
       endInst = new_instruction(emitInfo, OPCODE_ENDLOOP);
+      if (!endInst) {
+         return NULL;
+      }
    }
    else {
       /* emit unconditional BRA-nch */
       endInst = new_instruction(emitInfo, OPCODE_BRA);
+      if (!endInst) {
+         return NULL;
+      }
       endInst->DstReg.CondMask = COND_TR;  /* always true */
    }
    /* ENDLOOP's BranchTarget points to the BGNLOOP inst */
@@ -1705,7 +1821,7 @@ emit_loop(slang_emit_info *emitInfo, slang_ir_node *n)
 
    /* Done emitting loop code.  Now walk over the loop's linked list of
     * BREAK and CONT nodes, filling in their BranchTarget fields (which
-    * will point to the ENDLOOP+1 or BGNLOOP instructions, respectively).
+    * will point to the corresponding ENDLOOP instruction.
     */
    for (ir = n->List; ir; ir = ir->List) {
       struct prog_instruction *inst = prog->Instructions + ir->InstLocation;
@@ -1714,8 +1830,13 @@ emit_loop(slang_emit_info *emitInfo, slang_ir_node *n)
           ir->Opcode == IR_BREAK_IF_TRUE) {
          assert(inst->Opcode == OPCODE_BRK ||
                 inst->Opcode == OPCODE_BRA);
-         /* go to instruction after end of loop */
-         inst->BranchTarget = endInstLoc + 1;
+         /* go to instruction at end of loop */
+         if (emitInfo->EmitHighLevelInstructions) {
+            inst->BranchTarget = endInstLoc;
+         }
+         else {
+            inst->BranchTarget = endInstLoc + 1;
+         }
       }
       else {
          assert(ir->Opcode == IR_CONT ||
@@ -1762,7 +1883,9 @@ emit_cont_break(slang_emit_info *emitInfo, slang_ir_node *n)
    }
    n->InstLocation = emitInfo->prog->NumInstructions;
    inst = new_instruction(emitInfo, opcode);
-   inst->DstReg.CondMask = COND_TR;  /* always true */
+   if (inst) {
+      inst->DstReg.CondMask = COND_TR;  /* always true */
+   }
    return inst;
 }
 
@@ -1798,8 +1921,10 @@ emit_cont_break_if_true(slang_emit_info *emitInfo, slang_ir_node *n)
           */
          const GLuint condWritemask = inst->DstReg.WriteMask;
          inst = new_instruction(emitInfo, opcode);
-         inst->DstReg.CondMask = COND_NE;
-         inst->DstReg.CondSwizzle = writemask_to_swizzle(condWritemask);
+         if (inst) {
+            inst->DstReg.CondMask = COND_NE;
+            inst->DstReg.CondSwizzle = writemask_to_swizzle(condWritemask);
+         }
          return inst;
       }
       else {
@@ -1814,13 +1939,22 @@ emit_cont_break_if_true(slang_emit_info *emitInfo, slang_ir_node *n)
                                  n->Children[0]->Store,
                                  NULL,
                                  NULL);
+         if (!inst) {
+            return NULL;
+         }
          n->InstLocation = emitInfo->prog->NumInstructions;
 
          inst = new_instruction(emitInfo, opcode);
+         if (!inst) {
+            return NULL;
+         }
          inst = new_instruction(emitInfo, OPCODE_ENDIF);
+         if (!inst) {
+            return NULL;
+         }
 
          emitInfo->prog->Instructions[ifInstLoc].BranchTarget
-            = emitInfo->prog->NumInstructions;
+            = emitInfo->prog->NumInstructions - 1;
          return inst;
       }
    }
@@ -1828,8 +1962,10 @@ emit_cont_break_if_true(slang_emit_info *emitInfo, slang_ir_node *n)
       const GLuint condWritemask = inst->DstReg.WriteMask;
       assert(emitInfo->EmitCondCodes);
       inst = new_instruction(emitInfo, OPCODE_BRA);
-      inst->DstReg.CondMask = COND_NE;
-      inst->DstReg.CondSwizzle = writemask_to_swizzle(condWritemask);
+      if (inst) {
+         inst->DstReg.CondMask = COND_NE;
+         inst->DstReg.CondSwizzle = writemask_to_swizzle(condWritemask);
+      }
       return inst;
    }
 }
@@ -1976,6 +2112,9 @@ emit_array_element(slang_emit_info *emitInfo, slang_ir_node *n)
                                  indexStore, /* the index */
                                  &elemSizeStore,
                                  NULL);
+         if (!inst) {
+            return NULL;
+         }
 
          indexStore = indexTemp;
       }
@@ -2002,6 +2141,9 @@ emit_array_element(slang_emit_info *emitInfo, slang_ir_node *n)
                                  indexStore,     /* the index */
                                  &indirectArray, /* indirect array base */
                                  NULL);
+         if (!inst) {
+            return NULL;
+         }
 
          indexStore = indexTemp;
       }
@@ -2201,7 +2343,9 @@ emit(slang_emit_info *emitInfo, slang_ir_node *n)
 
    if (n->Comment) {
       inst = new_instruction(emitInfo, OPCODE_NOP);
-      inst->Comment = _mesa_strdup(n->Comment);
+      if (inst) {
+         inst->Comment = _mesa_strdup(n->Comment);
+      }
       inst = NULL;
    }
 
@@ -2503,6 +2647,9 @@ _slang_emit_code(slang_ir_node *n, slang_var_table *vt,
    if (withEnd) {
       struct prog_instruction *inst;
       inst = new_instruction(&emitInfo, OPCODE_END);
+      if (!inst) {
+         return GL_FALSE;
+      }
    }
 
    _slang_resolve_subroutines(&emitInfo);
index 71038d2d94efc80623e73de55b9ad8e3ac95502d..ed27821a951bd0320acfb2aefcc63662512fcf4a 100644 (file)
@@ -104,7 +104,7 @@ link_varying_vars(GLcontext *ctx,
    GLuint *map, i, firstVarying, newFile;
    GLbitfield *inOutFlags;
 
-   map = (GLuint *) malloc(prog->Varying->NumParameters * sizeof(GLuint));
+   map = (GLuint *) _mesa_malloc(prog->Varying->NumParameters * sizeof(GLuint));
    if (!map)
       return GL_FALSE;
 
@@ -135,6 +135,7 @@ link_varying_vars(GLcontext *ctx,
             &shProg->Varying->Parameters[j];
          if (var->Size != v->Size) {
             link_error(shProg, "mismatched varying variable types");
+            _mesa_free(map);
             return GL_FALSE;
          }
          if (!bits_agree(var->Flags, v->Flags, PROG_PARAM_BIT_CENTROID)) {
@@ -142,6 +143,7 @@ link_varying_vars(GLcontext *ctx,
             _mesa_snprintf(msg, sizeof(msg),
                            "centroid modifier mismatch for '%s'", var->Name);
             link_error(shProg, msg);
+            _mesa_free(map);
             return GL_FALSE;
          }
          if (!bits_agree(var->Flags, v->Flags, PROG_PARAM_BIT_INVARIANT)) {
@@ -149,6 +151,7 @@ link_varying_vars(GLcontext *ctx,
             _mesa_snprintf(msg, sizeof(msg),
                            "invariant modifier mismatch for '%s'", var->Name);
             link_error(shProg, msg);
+            _mesa_free(map);
             return GL_FALSE;
          }
       }
@@ -160,6 +163,7 @@ link_varying_vars(GLcontext *ctx,
 
       if (shProg->Varying->NumParameters > ctx->Const.MaxVarying) {
          link_error(shProg, "Too many varying variables");
+         _mesa_free(map);
          return GL_FALSE;
       }
 
@@ -199,7 +203,7 @@ link_varying_vars(GLcontext *ctx,
       }
    }
 
-   free(map);
+   _mesa_free(map);
 
    /* these will get recomputed before linking is completed */
    prog->InputsRead = 0x0;
@@ -511,7 +515,7 @@ _slang_update_inputs_outputs(struct gl_program *prog)
       }
 
       if (inst->DstReg.File == PROGRAM_OUTPUT) {
-         prog->OutputsWritten |= 1 << inst->DstReg.Index;
+         prog->OutputsWritten |= BITFIELD64_BIT(inst->DstReg.Index);
          if (inst->DstReg.RelAddr) {
             /* If the output attribute is indexed with relative addressing
              * we know that it must be a varying or texcoord such as
@@ -524,14 +528,17 @@ _slang_update_inputs_outputs(struct gl_program *prog)
             if (prog->Target == GL_VERTEX_PROGRAM_ARB) {
                if (inst->DstReg.Index == VERT_RESULT_TEX0) {
                   /* mark all texcoord outputs as written */
-                  const GLbitfield mask =
-                     ((1 << MAX_TEXTURE_COORD_UNITS) - 1) << VERT_RESULT_TEX0;
+                  const GLbitfield64 mask =
+                    BITFIELD64_RANGE(VERT_RESULT_TEX0,
+                                     (VERT_RESULT_TEX0
+                                      + MAX_TEXTURE_COORD_UNITS - 1));
                   prog->OutputsWritten |= mask;
                }
                else if (inst->DstReg.Index == VERT_RESULT_VAR0) {
                   /* mark all generic varying outputs as written */
-                  const GLbitfield mask =
-                     ((1 << MAX_VARYING) - 1) << VERT_RESULT_VAR0;
+                  const GLbitfield64 mask =
+                    BITFIELD64_RANGE(VERT_RESULT_VAR0,
+                                     (VERT_RESULT_VAR0 + MAX_VARYING - 1));
                   prog->OutputsWritten |= mask;
                }
             }
@@ -583,11 +590,16 @@ concat_shaders(struct gl_shader_program *shProg, GLenum shaderType)
 {
    struct gl_shader *newShader;
    const struct gl_shader *firstShader = NULL;
-   GLuint shaderLengths[100];
+   GLuint *shaderLengths;
    GLchar *source;
    GLuint totalLen = 0, len = 0;
    GLuint i;
 
+   shaderLengths = (GLuint *)_mesa_malloc(shProg->NumShaders * sizeof(GLuint));
+   if (!shaderLengths) {
+      return NULL;
+   }
+
    /* compute total size of new shader source code */
    for (i = 0; i < shProg->NumShaders; i++) {
       const struct gl_shader *shader = shProg->Shaders[i];
@@ -599,12 +611,16 @@ concat_shaders(struct gl_shader_program *shProg, GLenum shaderType)
       }
    }
 
-   if (totalLen == 0)
+   if (totalLen == 0) {
+      _mesa_free(shaderLengths);
       return NULL;
+   }
 
    source = (GLchar *) _mesa_malloc(totalLen + 1);
-   if (!source)
+   if (!source) {
+      _mesa_free(shaderLengths);
       return NULL;
+   }
 
    /* concatenate shaders */
    for (i = 0; i < shProg->NumShaders; i++) {
@@ -619,9 +635,16 @@ concat_shaders(struct gl_shader_program *shProg, GLenum shaderType)
    _mesa_printf("---NEW CONCATENATED SHADER---:\n%s\n------------\n", source);
    */
 
+   _mesa_free(shaderLengths);
+
    remove_extra_version_directives(source);
 
    newShader = CALLOC_STRUCT(gl_shader);
+   if (!newShader) {
+      _mesa_free(source);
+      return NULL;
+   }
+
    newShader->Type = shaderType;
    newShader->Source = source;
    newShader->Pragmas = firstShader->Pragmas;
@@ -803,7 +826,8 @@ _slang_link(GLcontext *ctx,
    if (shProg->VertexProgram) {
       _slang_update_inputs_outputs(&shProg->VertexProgram->Base);
       _slang_count_temporaries(&shProg->VertexProgram->Base);
-      if (!(shProg->VertexProgram->Base.OutputsWritten & (1 << VERT_RESULT_HPOS))) {
+      if (!(shProg->VertexProgram->Base.OutputsWritten
+           & BITFIELD64_BIT(VERT_RESULT_HPOS))) {
          /* the vertex program did not compute a vertex position */
          link_error(shProg,
                     "gl_Position was not written by vertex shader\n");
@@ -821,7 +845,7 @@ _slang_link(GLcontext *ctx,
    if (shProg->FragmentProgram) {
       const GLbitfield varyingRead
          = shProg->FragmentProgram->Base.InputsRead >> FRAG_ATTRIB_VAR0;
-      const GLbitfield varyingWritten = shProg->VertexProgram ?
+      const GLbitfield64 varyingWritten = shProg->VertexProgram ?
          shProg->VertexProgram->Base.OutputsWritten >> VERT_RESULT_VAR0 : 0x0;
       if ((varyingRead & varyingWritten) != varyingRead) {
          link_error(shProg,
@@ -832,9 +856,10 @@ _slang_link(GLcontext *ctx,
 
    /* check that gl_FragColor and gl_FragData are not both written to */
    if (shProg->FragmentProgram) {
-      GLbitfield outputsWritten = shProg->FragmentProgram->Base.OutputsWritten;
-      if ((outputsWritten & ((1 << FRAG_RESULT_COLOR))) &&
-          (outputsWritten >= (1 << FRAG_RESULT_DATA0))) {
+      const GLbitfield64 outputsWritten =
+        shProg->FragmentProgram->Base.OutputsWritten;
+      if ((outputsWritten & BITFIELD64_BIT(FRAG_RESULT_COLOR)) &&
+          (outputsWritten >= BITFIELD64_BIT(FRAG_RESULT_DATA0))) {
          link_error(shProg, "Fragment program cannot write both gl_FragColor"
                     " and gl_FragData[].\n");
          return;
diff --git a/src/mesa/shader/slang/slang_preprocess.c b/src/mesa/shader/slang/slang_preprocess.c
deleted file mode 100644 (file)
index e9a24cc..0000000
+++ /dev/null
@@ -1,1406 +0,0 @@
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 2005-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"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/**
- * \file slang_preprocess.c
- * slang preprocessor
- * \author Michal Krol
- */
-
-#include "main/imports.h"
-#include "shader/grammar/grammar_mesa.h"
-#include "slang_preprocess.h"
-
-LONGSTRING static const char *slang_pp_directives_syn =
-#include "library/slang_pp_directives_syn.h"
-;
-
-LONGSTRING static const char *slang_pp_expression_syn =
-#include "library/slang_pp_expression_syn.h"
-;
-
-LONGSTRING static const char *slang_pp_version_syn =
-#include "library/slang_pp_version_syn.h"
-;
-
-static GLvoid
-grammar_error_to_log (slang_info_log *log)
-{
-   char buf[1024];
-   GLint pos;
-
-   grammar_get_last_error ((byte *) (buf), sizeof (buf), &pos);
-   if (buf[0] == 0) {
-      _mesa_snprintf(buf, sizeof(buf), "Preprocessor error");
-   }
-   slang_info_log_error (log, buf);
-}
-
-GLboolean
-_slang_preprocess_version (const char *text, GLuint *version, GLuint *eaten, slang_info_log *log)
-{
-   grammar id;
-   byte *prod, *I;
-   unsigned int size;
-
-   id = grammar_load_from_text ((const byte *) (slang_pp_version_syn));
-   if (id == 0) {
-      grammar_error_to_log (log);
-      return GL_FALSE;
-   }
-
-   if (!grammar_fast_check (id, (const byte *) (text), &prod, &size, 8)) {
-      grammar_error_to_log (log);
-      grammar_destroy (id);
-      return GL_FALSE;
-   }
-
-   /* there can be multiple #version directives - grab the last one */
-   I = &prod[size - 6];
-   *version = (GLuint) (I[0]) + (GLuint) (I[1]) * 100;
-   *eaten = (GLuint) (I[2]) + ((GLuint) (I[3]) << 8) + ((GLuint) (I[4]) << 16) + ((GLuint) (I[5]) << 24);
-
-   grammar_destroy (id);
-   grammar_alloc_free (prod);
-   return GL_TRUE;
-}
-
-/*
- * The preprocessor does the following work.
- * 1. Remove comments. Each comment block is replaced with a single space and if the
- *    block contains new-lines, they are preserved. This ensures that line numbers
- *    stay the same and if a comment block delimits two tokens, the are delitmited
- *    by the space after comment removal.
- * 2. Remove preprocessor directives from the source string, checking their syntax and
- *    executing them if appropriate. Again, new-lines are preserved.
- * 3. Expand macros.
- * 4. Tokenize the source string by ensuring there is at least one space between every
- *    two adjacent tokens.
- */
-
-#define PP_ANNOTATE 0
-
-static GLvoid
-pp_annotate (slang_string *output, const char *fmt, ...)
-{
-#if PP_ANNOTATE
-   va_list va;
-   char buffer[1024];
-
-   va_start (va, fmt);
-   _mesa_vsprintf (buffer, fmt, va);
-   va_end (va);
-   slang_string_pushs (output, buffer, _mesa_strlen (buffer));
-#else
-   (GLvoid) (output);
-   (GLvoid) (fmt);
-#endif
-}
-
- /*
- * The expression is executed on a fixed-sized stack. The PUSH macro makes a runtime
- * check if the stack is not overflown by too complex expressions. In that situation the
- * GLSL preprocessor should report internal compiler error.
- * The BINARYDIV makes a runtime check if the divider is not 0. If it is, it reports
- * compilation error.
- */
-
-#define EXECUTION_STACK_SIZE 1024
-
-#define PUSH(x)\
-   do {\
-      if (sp == 0) {\
-         slang_info_log_error (elog, "internal compiler error: preprocessor execution stack overflow.");\
-         return GL_FALSE;\
-      }\
-      stack[--sp] = x;\
-   } while (GL_FALSE)
-
-#define POP(x)\
-   do {\
-      assert (sp < EXECUTION_STACK_SIZE);\
-      x = stack[sp++];\
-   } while (GL_FALSE)
-
-#define BINARY(op)\
-   do {\
-      GLint a, b;\
-      POP(b);\
-      POP(a);\
-      PUSH(a op b);\
-   } while (GL_FALSE)
-
-#define BINARYDIV(op)\
-   do {\
-      GLint a, b;\
-      POP(b);\
-      POP(a);\
-      if (b == 0) {\
-         slang_info_log_error (elog, "division by zero in preprocessor expression.");\
-         return GL_FALSE;\
-      }\
-      PUSH(a op b);\
-   } while (GL_FALSE)
-
-#define UNARY(op)\
-   do {\
-      GLint a;\
-      POP(a);\
-      PUSH(op a);\
-   } while (GL_FALSE)
-
-#define OP_END          0
-#define OP_PUSHINT      1
-#define OP_LOGICALOR    2
-#define OP_LOGICALAND   3
-#define OP_OR           4
-#define OP_XOR          5
-#define OP_AND          6
-#define OP_EQUAL        7
-#define OP_NOTEQUAL     8
-#define OP_LESSEQUAL    9
-#define OP_GREATEREQUAL 10
-#define OP_LESS         11
-#define OP_GREATER      12
-#define OP_LEFTSHIFT    13
-#define OP_RIGHTSHIFT   14
-#define OP_ADD          15
-#define OP_SUBTRACT     16
-#define OP_MULTIPLY     17
-#define OP_DIVIDE       18
-#define OP_MODULUS      19
-#define OP_PLUS         20
-#define OP_MINUS        21
-#define OP_NEGATE       22
-#define OP_COMPLEMENT   23
-
-static GLboolean
-execute_expression (slang_string *output, const byte *code, GLuint *pi, GLint *result,
-                    slang_info_log *elog)
-{
-   GLuint i = *pi;
-   GLint stack[EXECUTION_STACK_SIZE];
-   GLuint sp = EXECUTION_STACK_SIZE;
-
-   while (code[i] != OP_END) {
-      switch (code[i++]) {
-         case OP_PUSHINT:
-            i++;
-            PUSH(_mesa_atoi ((const char *) (&code[i])));
-            i += _mesa_strlen ((const char *) (&code[i])) + 1;
-            break;
-         case OP_LOGICALOR:
-            BINARY(||);
-            break;
-         case OP_LOGICALAND:
-            BINARY(&&);
-            break;
-         case OP_OR:
-            BINARY(|);
-            break;
-         case OP_XOR:
-            BINARY(^);
-            break;
-         case OP_AND:
-            BINARY(&);
-            break;
-         case OP_EQUAL:
-            BINARY(==);
-            break;
-         case OP_NOTEQUAL:
-            BINARY(!=);
-            break;
-         case OP_LESSEQUAL:
-            BINARY(<=);
-            break;
-         case OP_GREATEREQUAL:
-            BINARY(>=);
-            break;
-         case OP_LESS:
-            BINARY(<);
-            break;
-         case OP_GREATER:
-            BINARY(>);
-            break;
-         case OP_LEFTSHIFT:
-            BINARY(<<);
-            break;
-         case OP_RIGHTSHIFT:
-            BINARY(>>);
-            break;
-         case OP_ADD:
-            BINARY(+);
-            break;
-         case OP_SUBTRACT:
-            BINARY(-);
-            break;
-         case OP_MULTIPLY:
-            BINARY(*);
-            break;
-         case OP_DIVIDE:
-            BINARYDIV(/);
-            break;
-         case OP_MODULUS:
-            BINARYDIV(%);
-            break;
-         case OP_PLUS:
-            UNARY(+);
-            break;
-         case OP_MINUS:
-            UNARY(-);
-            break;
-         case OP_NEGATE:
-            UNARY(!);
-            break;
-         case OP_COMPLEMENT:
-            UNARY(~);
-            break;
-         default:
-            assert (0);
-      }
-   }
-
-   /* Write-back the index skipping the OP_END. */
-   *pi = i + 1;
-
-   /* There should be exactly one value left on the stack. This is our result. */
-   POP(*result);
-   pp_annotate (output, "%d ", *result);
-   assert (sp == EXECUTION_STACK_SIZE);
-   return GL_TRUE;
-}
-
-/*
- * Function execute_expressions() executes up to 2 expressions. The second expression is there
- * for the #line directive which takes 1 or 2 expressions that indicate line and file numbers.
- * If it fails, it returns 0. If it succeeds, it returns the number of executed expressions.
- */
-
-#define EXP_END        0
-#define EXP_EXPRESSION 1
-
-static GLuint
-execute_expressions (slang_string *output, grammar eid, const byte *expr, GLint results[2],
-                     slang_info_log *elog)
-{
-   GLint success;
-   byte *code;
-   GLuint size, count = 0;
-
-   success = grammar_fast_check (eid, expr, &code, &size, 64);
-   if (success) {
-      GLuint i = 0;
-
-      while (code[i++] == EXP_EXPRESSION) {
-         assert (count < 2);
-
-         if (!execute_expression (output, code, &i, &results[count], elog)) {
-            count = 0;
-            break;
-         }
-         count++;
-      }
-      grammar_alloc_free (code);
-   }
-   else {
-      slang_info_log_error (elog, "syntax error in preprocessor expression.");\
-   }
-   return count;
-}
-
-/*
- * The pp_symbol structure is used to hold macro definitions and macro formal parameters. The
- * pp_symbols strcture is a collection of pp_symbol. It is used both for storing macro formal
- * parameters and all global macro definitions. Making this unification wastes some memory,
- * becuse macro formal parameters don't need further lists of symbols. We lose 8 bytes per
- * formal parameter here, but making this we can use the same code to substitute macro parameters
- * as well as macros in the source string.
- */
-
-typedef struct
-{
-   struct pp_symbol_ *symbols;
-   GLuint count;
-} pp_symbols;
-
-static GLvoid
-pp_symbols_init (pp_symbols *self)
-{
-   self->symbols = NULL;
-   self->count = 0;
-}
-
-static GLvoid
-pp_symbols_free (pp_symbols *);
-
-typedef struct pp_symbol_
-{
-   slang_string name;
-   slang_string replacement;
-   pp_symbols parameters;
-} pp_symbol;
-
-static GLvoid
-pp_symbol_init (pp_symbol *self)
-{
-   slang_string_init (&self->name);
-   slang_string_init (&self->replacement);
-   pp_symbols_init (&self->parameters);
-}
-
-static GLvoid
-pp_symbol_free (pp_symbol *self)
-{
-   slang_string_free (&self->name);
-   slang_string_free (&self->replacement);
-   pp_symbols_free (&self->parameters);
-}
-
-static GLvoid
-pp_symbol_reset (pp_symbol *self)
-{
-   /* Leave symbol name intact. */
-   slang_string_reset (&self->replacement);
-   pp_symbols_free (&self->parameters);
-   pp_symbols_init (&self->parameters);
-}
-
-static GLvoid
-pp_symbols_free (pp_symbols *self)
-{
-   GLuint i;
-
-   for (i = 0; i < self->count; i++)
-      pp_symbol_free (&self->symbols[i]);
-   _mesa_free (self->symbols);
-}
-
-static pp_symbol *
-pp_symbols_push (pp_symbols *self)
-{
-   self->symbols = (pp_symbol *) (_mesa_realloc (self->symbols, self->count * sizeof (pp_symbol),
-                                                 (self->count + 1) * sizeof (pp_symbol)));
-   if (self->symbols == NULL)
-      return NULL;
-   pp_symbol_init (&self->symbols[self->count]);
-   return &self->symbols[self->count++];
-}
-
-static GLboolean
-pp_symbols_erase (pp_symbols *self, pp_symbol *symbol)
-{
-   assert (symbol >= self->symbols && symbol < self->symbols + self->count);
-
-   self->count--;
-   pp_symbol_free (symbol);
-   if (symbol < self->symbols + self->count)
-      _mesa_memcpy (symbol, symbol + 1, sizeof (pp_symbol) * (self->symbols + self->count - symbol));
-   self->symbols = (pp_symbol *) (_mesa_realloc (self->symbols, (self->count + 1) * sizeof (pp_symbol),
-                                                 self->count * sizeof (pp_symbol)));
-   return self->symbols != NULL;
-}
-
-static pp_symbol *
-pp_symbols_find (pp_symbols *self, const char *name)
-{
-   GLuint i;
-
-   for (i = 0; i < self->count; i++)
-      if (_mesa_strcmp (name, slang_string_cstr (&self->symbols[i].name)) == 0)
-         return &self->symbols[i];
-   return NULL;
-}
-
-/*
- * The condition context of a single #if/#else/#endif level. Those can be nested, so there
- * is a stack of condition contexts.
- * There is a special global context on the bottom of the stack. It is there to simplify
- * context handling.
- */
-
-typedef struct
-{
-   GLboolean current;         /* The condition value of this level. */
-   GLboolean effective;       /* The effective product of current condition, outer level conditions
-                               * and position within #if-#else-#endif sections. */
-   GLboolean else_allowed;    /* TRUE if in #if-#else section, FALSE if in #else-#endif section
-                               * and for global context. */
-   GLboolean endif_required;  /* FALSE for global context only. */
-} pp_cond_ctx;
-
-/* Should be enuff. */
-#define CONDITION_STACK_SIZE 64
-
-typedef struct
-{
-   pp_cond_ctx stack[CONDITION_STACK_SIZE];
-   pp_cond_ctx *top;
-} pp_cond_stack;
-
-static GLboolean
-pp_cond_stack_push (pp_cond_stack *self, slang_info_log *elog)
-{
-   if (self->top == self->stack) {
-      slang_info_log_error (elog, "internal compiler error: preprocessor condition stack overflow.");
-      return GL_FALSE;
-   }
-   self->top--;
-   return GL_TRUE;
-}
-
-static GLvoid
-pp_cond_stack_reevaluate (pp_cond_stack *self)
-{
-   /* There must be at least 2 conditions on the stack - one global and one being evaluated. */
-   assert (self->top <= &self->stack[CONDITION_STACK_SIZE - 2]);
-
-   self->top->effective = self->top->current && self->top[1].effective;
-}
-
-
-/**
- * Extension enables through #extension directive.
- * NOTE: Currently, only enable/disable state is stored.
- */
-typedef struct
-{
-   GLboolean ARB_draw_buffers;
-   GLboolean ARB_texture_rectangle;
-} pp_ext;
-
-
-/**
- * Disable all extensions. Called at startup and on #extension all: disable.
- */
-static GLvoid
-pp_ext_disable_all(pp_ext *self)
-{
-   _mesa_memset(self, 0, sizeof(self));
-}
-
-
-/**
- * Called during preprocessor initialization to set the initial enable/disable
- * state of extensions.
- */
-static GLvoid
-pp_ext_init(pp_ext *self, const struct gl_extensions *extensions)
-{
-   pp_ext_disable_all (self);
-   self->ARB_draw_buffers = GL_TRUE;
-   if (extensions->NV_texture_rectangle)
-      self->ARB_texture_rectangle = GL_TRUE;
-}
-
-/**
- * Called in response to #extension directives to enable/disable
- * the named extension.
- */
-static GLboolean
-pp_ext_set(pp_ext *self, const char *name, GLboolean enable)
-{
-   if (_mesa_strcmp (name, "GL_ARB_draw_buffers") == 0)
-      self->ARB_draw_buffers = enable;
-   else if (_mesa_strcmp (name, "GL_ARB_texture_rectangle") == 0)
-      self->ARB_texture_rectangle = enable;
-   else
-      return GL_FALSE;
-   return GL_TRUE;
-}
-
-
-/**
- * Called in response to #pragma.  For example, "#pragma debug(on)" would
- * call this function as pp_pragma("debug", "on").
- * \return GL_TRUE if pragma is valid, GL_FALSE if invalid
- */
-static GLboolean
-pp_pragma(struct gl_sl_pragmas *pragmas, const char *pragma, const char *param)
-{
-#if 0
-   printf("#pragma %s %s\n", pragma, param);
-#endif
-   if (_mesa_strcmp(pragma, "optimize") == 0) {
-      if (!param)
-         return GL_FALSE; /* missing required param */
-      if (_mesa_strcmp(param, "on") == 0) {
-         if (!pragmas->IgnoreOptimize)
-            pragmas->Optimize = GL_TRUE;
-      }
-      else if (_mesa_strcmp(param, "off") == 0) {
-         if (!pragmas->IgnoreOptimize)
-            pragmas->Optimize = GL_FALSE;
-      }
-      else {
-         return GL_FALSE; /* invalid param */
-      }
-   }
-   else if (_mesa_strcmp(pragma, "debug") == 0) {
-      if (!param)
-         return GL_FALSE; /* missing required param */
-      if (_mesa_strcmp(param, "on") == 0) {
-         if (!pragmas->IgnoreDebug)
-            pragmas->Debug = GL_TRUE;
-      }
-      else if (_mesa_strcmp(param, "off") == 0) {
-         if (!pragmas->IgnoreDebug)
-            pragmas->Debug = GL_FALSE;
-      }
-      else {
-         return GL_FALSE; /* invalid param */
-      }
-   }
-   /* all other pragmas are silently ignored */
-   return GL_TRUE;
-}
-
-
-/**
- * The state of preprocessor: current line, file and version number, list
- * of all defined macros and the #if/#endif context.
- */
-typedef struct
-{
-   GLint line;
-   GLint file;
-   GLint version;
-   pp_symbols symbols;
-   pp_ext ext;
-   slang_info_log *elog;
-   pp_cond_stack cond;
-} pp_state;
-
-static GLvoid
-pp_state_init (pp_state *self, slang_info_log *elog,
-               const struct gl_extensions *extensions)
-{
-   self->line = 0;
-   self->file = 1;
-#if FEATURE_es2_glsl
-   self->version = 100;
-#else
-   self->version = 110;
-#endif
-   pp_symbols_init (&self->symbols);
-   pp_ext_init (&self->ext, extensions);
-   self->elog = elog;
-
-   /* Initialize condition stack and create the global context. */
-   self->cond.top = &self->cond.stack[CONDITION_STACK_SIZE - 1];
-   self->cond.top->current = GL_TRUE;
-   self->cond.top->effective = GL_TRUE;
-   self->cond.top->else_allowed = GL_FALSE;
-   self->cond.top->endif_required = GL_FALSE;
-}
-
-static GLvoid
-pp_state_free (pp_state *self)
-{
-   pp_symbols_free (&self->symbols);
-}
-
-#define IS_FIRST_ID_CHAR(x) (((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z') || (x) == '_')
-#define IS_NEXT_ID_CHAR(x) (IS_FIRST_ID_CHAR(x) || ((x) >= '0' && (x) <= '9'))
-#define IS_WHITE(x) ((x) == ' ' || (x) == '\n')
-#define IS_NULL(x) ((x) == '\0')
-
-#define SKIP_WHITE(x) do { while (IS_WHITE(*(x))) (x)++; } while (GL_FALSE)
-
-typedef struct
-{
-   slang_string *output;
-   const char *input;
-   pp_state *state;
-} expand_state;
-
-static GLboolean
-expand_defined (expand_state *e, slang_string *buffer)
-{
-   GLboolean in_paren = GL_FALSE;
-   const char *id;
-
-   /* Parse the optional opening parenthesis. */
-   SKIP_WHITE(e->input);
-   if (*e->input == '(') {
-      e->input++;
-      in_paren = GL_TRUE;
-      SKIP_WHITE(e->input);
-   }
-
-   /* Parse operand. */
-   if (!IS_FIRST_ID_CHAR(*e->input)) {
-      slang_info_log_error (e->state->elog,
-                            "preprocess error: identifier expected after operator 'defined'.");
-      return GL_FALSE;
-   }
-   slang_string_reset (buffer);
-   slang_string_pushc (buffer, *e->input++);
-   while (IS_NEXT_ID_CHAR(*e->input))
-      slang_string_pushc (buffer, *e->input++);
-   id = slang_string_cstr (buffer);
-
-   /* Check if the operand is defined. Output 1 if it is defined, output 0 if not. */
-   if (pp_symbols_find (&e->state->symbols, id) == NULL)
-      slang_string_pushs (e->output, " 0 ", 3);
-   else
-      slang_string_pushs (e->output, " 1 ", 3);
-
-   /* Parse the closing parentehesis if the opening one was there. */
-   if (in_paren) {
-      SKIP_WHITE(e->input);
-      if (*e->input != ')') {
-         slang_info_log_error (e->state->elog, "preprocess error: ')' expected.");
-         return GL_FALSE;
-      }
-      e->input++;
-      SKIP_WHITE(e->input);
-   }
-   return GL_TRUE;
-}
-
-static GLboolean
-expand (expand_state *, pp_symbols *);
-
-static GLboolean
-expand_symbol (expand_state *e, pp_symbol *symbol)
-{
-   expand_state es;
-
-   /* If the macro has some parameters, we need to parse them. */
-   if (symbol->parameters.count != 0) {
-      GLuint i;
-
-      /* Parse the opening parenthesis. */
-      SKIP_WHITE(e->input);
-      if (*e->input != '(') {
-         slang_info_log_error (e->state->elog, "preprocess error: '(' expected.");
-         return GL_FALSE;
-      }
-      e->input++;
-      SKIP_WHITE(e->input);
-
-      /* Parse macro actual parameters. This can be anything, separated by a colon.
-       */
-      for (i = 0; i < symbol->parameters.count; i++) {
-         GLuint nested_paren_count = 0; /* track number of nested parentheses */
-
-         if (*e->input == ')') {
-            slang_info_log_error (e->state->elog, "preprocess error: unexpected ')'.");
-            return GL_FALSE;
-         }
-
-         /* Eat all characters up to the comma or closing parentheses. */
-         pp_symbol_reset (&symbol->parameters.symbols[i]);
-         while (!IS_NULL(*e->input)) {
-            /* Exit loop only when all nested parens have been eaten. */
-            if (nested_paren_count == 0 && (*e->input == ',' || *e->input == ')'))
-               break;
-
-            /* Actually count nested parens here. */
-            if (*e->input == '(')
-               nested_paren_count++;
-            else if (*e->input == ')')
-               nested_paren_count--;
-
-            slang_string_pushc (&symbol->parameters.symbols[i].replacement, *e->input++);
-         }
-
-         /* If it was not the last paremeter, skip the comma. Otherwise, skip the
-          * closing parentheses. */
-         if (i + 1 == symbol->parameters.count) {
-            /* This is the last paremeter - skip the closing parentheses. */
-            if (*e->input != ')') {
-               slang_info_log_error (e->state->elog, "preprocess error: ')' expected.");
-               return GL_FALSE;
-            }
-            e->input++;
-            SKIP_WHITE(e->input);
-         }
-         else {
-            /* Skip the separating comma. */
-            if (*e->input != ',') {
-               slang_info_log_error (e->state->elog, "preprocess error: ',' expected.");
-               return GL_FALSE;
-            }
-            e->input++;
-            SKIP_WHITE(e->input);
-         }
-      }
-   }
-
-   /* Expand the macro. Use its parameters as a priority symbol list to expand
-    * macro parameters correctly. */
-   es.output = e->output;
-   es.input = slang_string_cstr (&symbol->replacement);
-   es.state = e->state;
-   slang_string_pushc (e->output, ' ');
-   if (!expand (&es, &symbol->parameters))
-      return GL_FALSE;
-   slang_string_pushc (e->output, ' ');
-   return GL_TRUE;
-}
-
-/*
- * Function expand() expands source text from <input> to <output>. The expansion is made using
- * the list passed in <symbols> parameter. It allows us to expand macro formal parameters with
- * actual parameters. The global list of symbols from pp state is used when doing a recursive
- * call of expand().
- */
-
-static GLboolean
-expand (expand_state *e, pp_symbols *symbols)
-{
-   while (!IS_NULL(*e->input)) {
-      if (IS_FIRST_ID_CHAR(*e->input)) {
-         slang_string buffer;
-         const char *id;
-
-         /* Parse the identifier. */
-         slang_string_init (&buffer);
-         slang_string_pushc (&buffer, *e->input++);
-         while (IS_NEXT_ID_CHAR(*e->input))
-            slang_string_pushc (&buffer, *e->input++);
-         id = slang_string_cstr (&buffer);
-
-         /* Now check if the identifier is special in some way. The "defined" identifier is
-          * actually an operator that we must handle here and expand it either to " 0 " or " 1 ".
-          * The other identifiers start with "__" and we expand it to appropriate values
-          * taken from the preprocessor state. */
-         if (_mesa_strcmp (id, "defined") == 0) {
-            if (!expand_defined (e, &buffer))
-               return GL_FALSE;
-         }
-         else if (_mesa_strcmp (id, "__LINE__") == 0) {
-            slang_string_pushc (e->output, ' ');
-            slang_string_pushi (e->output, e->state->line);
-            slang_string_pushc (e->output, ' ');
-         }
-         else if (_mesa_strcmp (id, "__FILE__") == 0) {
-            slang_string_pushc (e->output, ' ');
-            slang_string_pushi (e->output, e->state->file);
-            slang_string_pushc (e->output, ' ');
-         }
-         else if (_mesa_strcmp (id, "__VERSION__") == 0) {
-            slang_string_pushc (e->output, ' ');
-            slang_string_pushi (e->output, e->state->version);
-            slang_string_pushc (e->output, ' ');
-         }
-#if FEATURE_es2_glsl
-         else if (_mesa_strcmp (id, "GL_ES") == 0 ||
-                  _mesa_strcmp (id, "GL_FRAGMENT_PRECISION_HIGH") == 0) {
-            slang_string_pushc (e->output, ' ');
-            slang_string_pushi (e->output, '1');
-            slang_string_pushc (e->output, ' ');
-         }
-#endif
-         else {
-            pp_symbol *symbol;
-
-            /* The list of symbols from <symbols> take precedence over the list from <state>.
-             * Note that in some cases this is the same list so avoid double look-up. */
-            symbol = pp_symbols_find (symbols, id);
-            if (symbol == NULL && symbols != &e->state->symbols)
-               symbol = pp_symbols_find (&e->state->symbols, id);
-
-            /* If the symbol was found, recursively expand its definition. */
-            if (symbol != NULL) {
-               if (!expand_symbol (e, symbol)) {
-                  slang_string_free (&buffer);
-                  return GL_FALSE;
-               }
-            }
-            else {
-               slang_string_push (e->output, &buffer);
-            }
-         }
-         slang_string_free (&buffer);
-      }
-      else if (IS_WHITE(*e->input)) {
-         slang_string_pushc (e->output, *e->input++);
-      }
-      else {
-         while (!IS_WHITE(*e->input) && !IS_NULL(*e->input) && !IS_FIRST_ID_CHAR(*e->input))
-            slang_string_pushc (e->output, *e->input++);
-      }
-   }
-   return GL_TRUE;
-}
-
-static GLboolean
-parse_if (slang_string *output, const byte *prod, GLuint *pi, GLint *result, pp_state *state,
-          grammar eid)
-{
-   const char *text;
-   GLuint len;
-
-   text = (const char *) (&prod[*pi]);
-   len = _mesa_strlen (text);
-
-   if (state->cond.top->effective) {
-      slang_string expr;
-      GLuint count;
-      GLint results[2];
-      expand_state es;
-
-      /* Expand the expression. */
-      slang_string_init (&expr);
-      es.output = &expr;
-      es.input = text;
-      es.state = state;
-      if (!expand (&es, &state->symbols))
-         return GL_FALSE;
-
-      /* Execute the expression. */
-      count = execute_expressions (output, eid, (const byte *) (slang_string_cstr (&expr)),
-                                   results, state->elog);
-      slang_string_free (&expr);
-      if (count != 1)
-         return GL_FALSE;
-      *result = results[0];
-   }
-   else {
-      /* The directive is dead. */
-      *result = 0;
-   }
-
-   *pi += len + 1;
-   return GL_TRUE;
-}
-
-#define ESCAPE_TOKEN 0
-
-#define TOKEN_END       0
-#define TOKEN_DEFINE    1
-#define TOKEN_UNDEF     2
-#define TOKEN_IF        3
-#define TOKEN_ELSE      4
-#define TOKEN_ELIF      5
-#define TOKEN_ENDIF     6
-#define TOKEN_ERROR     7
-#define TOKEN_PRAGMA    8
-#define TOKEN_EXTENSION 9
-#define TOKEN_LINE      10
-
-#define PARAM_END       0
-#define PARAM_PARAMETER 1
-
-#define BEHAVIOR_REQUIRE 1
-#define BEHAVIOR_ENABLE  2
-#define BEHAVIOR_WARN    3
-#define BEHAVIOR_DISABLE 4
-
-#define PRAGMA_NO_PARAM  0
-#define PRAGMA_PARAM     1
-
-
-static GLboolean
-preprocess_source (slang_string *output, const char *source,
-                   grammar pid, grammar eid,
-                   slang_info_log *elog,
-                   const struct gl_extensions *extensions,
-                   struct gl_sl_pragmas *pragmas)
-{
-   static const char *predefined[] = {
-      "__FILE__",
-      "__LINE__",
-      "__VERSION__",
-#if FEATURE_es2_glsl
-      "GL_ES",
-      "GL_FRAGMENT_PRECISION_HIGH",
-#endif
-      NULL
-   };
-   byte *prod;
-   GLuint size, i;
-   pp_state state;
-
-   if (!grammar_fast_check (pid, (const byte *) (source), &prod, &size, 65536)) {
-      grammar_error_to_log (elog);
-      return GL_FALSE;
-   }
-
-   pp_state_init (&state, elog, extensions);
-
-   /* add the predefined symbols to the symbol table */
-   for (i = 0; predefined[i]; i++) {
-      pp_symbol *symbol = NULL;
-      symbol = pp_symbols_push(&state.symbols);
-      assert(symbol);
-      slang_string_pushs(&symbol->name,
-                         predefined[i], _mesa_strlen(predefined[i]));
-   }
-
-   i = 0;
-   while (i < size) {
-      if (prod[i] != ESCAPE_TOKEN) {
-         if (state.cond.top->effective) {
-            slang_string input;
-            expand_state es;
-
-            /* Eat only one line of source code to expand it.
-             * FIXME: This approach has one drawback. If a macro with parameters spans across
-             *        multiple lines, the preprocessor will raise an error. */
-            slang_string_init (&input);
-            while (prod[i] != '\0' && prod[i] != '\n')
-               slang_string_pushc (&input, prod[i++]);
-            if (prod[i] != '\0')
-               slang_string_pushc (&input, prod[i++]);
-
-            /* Increment line number. */
-            state.line++;
-
-            es.output = output;
-            es.input = slang_string_cstr (&input);
-            es.state = &state;
-            if (!expand (&es, &state.symbols))
-               goto error;
-
-            slang_string_free (&input);
-         }
-         else {
-            /* Condition stack is disabled - keep track on line numbers and output only newlines. */
-            if (prod[i] == '\n') {
-               state.line++;
-               /*pp_annotate (output, "%c", prod[i]);*/
-            }
-            else {
-               /*pp_annotate (output, "%c", prod[i]);*/
-            }
-            i++;
-         }
-      }
-      else {
-         const char *id;
-         GLuint idlen;
-         GLubyte token;
-
-         i++;
-         token = prod[i++];
-         switch (token) {
-
-         case TOKEN_END:
-            /* End of source string.
-               * Check if all #ifs have been terminated by matching #endifs.
-               * On condition stack there should be only the global condition context. */
-            if (state.cond.top->endif_required) {
-               slang_info_log_error (elog, "end of source without matching #endif.");
-               return GL_FALSE;
-            }
-            break;
-
-         case TOKEN_DEFINE:
-            {
-               pp_symbol *symbol = NULL;
-
-               /* Parse macro name. */
-               id = (const char *) (&prod[i]);
-               idlen = _mesa_strlen (id);
-               if (state.cond.top->effective) {
-                  pp_annotate (output, "// #define %s(", id);
-
-                  /* If the symbol is already defined, override it. */
-                  symbol = pp_symbols_find (&state.symbols, id);
-                  if (symbol == NULL) {
-                     symbol = pp_symbols_push (&state.symbols);
-                     if (symbol == NULL)
-                        goto error;
-                     slang_string_pushs (&symbol->name, id, idlen);
-                  }
-                  else {
-                     pp_symbol_reset (symbol);
-                  }
-               }
-               i += idlen + 1;
-
-               /* Parse optional macro parameters. */
-               while (prod[i++] != PARAM_END) {
-                  pp_symbol *param;
-
-                  id = (const char *) (&prod[i]);
-                  idlen = _mesa_strlen (id);
-                  if (state.cond.top->effective) {
-                     pp_annotate (output, "%s, ", id);
-                     param = pp_symbols_push (&symbol->parameters);
-                     if (param == NULL)
-                        goto error;
-                     slang_string_pushs (&param->name, id, idlen);
-                  }
-                  i += idlen + 1;
-               }
-
-               /* Parse macro replacement. */
-               id = (const char *) (&prod[i]);
-               idlen = _mesa_strlen (id);
-               if (state.cond.top->effective) {
-                  slang_string replacement;
-                  expand_state es;
-
-                  pp_annotate (output, ") %s", id);
-
-                  slang_string_init(&replacement);
-                  slang_string_pushs(&replacement, id, idlen);
-
-                  /* Expand macro replacement. */
-                  es.output = &symbol->replacement;
-                  es.input = slang_string_cstr(&replacement);
-                  es.state = &state;
-                  if (!expand(&es, &state.symbols)) {
-                     slang_string_free(&replacement);
-                     goto error;
-                  }
-                  slang_string_free(&replacement);
-               }
-               i += idlen + 1;
-            }
-            break;
-
-         case TOKEN_UNDEF:
-            id = (const char *) (&prod[i]);
-            i += _mesa_strlen (id) + 1;
-            if (state.cond.top->effective) {
-               pp_symbol *symbol;
-
-               pp_annotate (output, "// #undef %s", id);
-               /* Try to find symbol with given name and remove it. */
-               symbol = pp_symbols_find (&state.symbols, id);
-               if (symbol != NULL)
-                  if (!pp_symbols_erase (&state.symbols, symbol))
-                     goto error;
-            }
-            break;
-
-         case TOKEN_IF:
-            {
-               GLint result;
-
-               /* Parse #if expression end execute it. */
-               pp_annotate (output, "// #if ");
-               if (!parse_if (output, prod, &i, &result, &state, eid))
-                  goto error;
-
-               /* Push new condition on the stack. */
-               if (!pp_cond_stack_push (&state.cond, state.elog))
-                  goto error;
-               state.cond.top->current = result ? GL_TRUE : GL_FALSE;
-               state.cond.top->else_allowed = GL_TRUE;
-               state.cond.top->endif_required = GL_TRUE;
-               pp_cond_stack_reevaluate (&state.cond);
-            }
-            break;
-
-         case TOKEN_ELSE:
-            /* Check if #else is alloved here. */
-            if (!state.cond.top->else_allowed) {
-               slang_info_log_error (elog, "#else without matching #if.");
-               goto error;
-            }
-
-            /* Negate current condition and reevaluate it. */
-            state.cond.top->current = !state.cond.top->current;
-            state.cond.top->else_allowed = GL_FALSE;
-            pp_cond_stack_reevaluate (&state.cond);
-            if (state.cond.top->effective)
-               pp_annotate (output, "// #else");
-            break;
-
-         case TOKEN_ELIF:
-            /* Check if #elif is alloved here. */
-            if (!state.cond.top->else_allowed) {
-               slang_info_log_error (elog, "#elif without matching #if.");
-               goto error;
-            }
-
-            /* Negate current condition and reevaluate it. */
-            state.cond.top->current = !state.cond.top->current;
-            pp_cond_stack_reevaluate (&state.cond);
-
-            if (state.cond.top->effective)
-               pp_annotate (output, "// #elif ");
-
-            {
-               GLint result;
-
-               /* Parse #elif expression end execute it. */
-               if (!parse_if (output, prod, &i, &result, &state, eid))
-                  goto error;
-
-               /* Update current condition and reevaluate it. */
-               state.cond.top->current = result ? GL_TRUE : GL_FALSE;
-               pp_cond_stack_reevaluate (&state.cond);
-            }
-            break;
-
-         case TOKEN_ENDIF:
-            /* Check if #endif is alloved here. */
-            if (!state.cond.top->endif_required) {
-               slang_info_log_error (elog, "#endif without matching #if.");
-               goto error;
-            }
-
-            /* Pop the condition off the stack. */
-            state.cond.top++;
-            if (state.cond.top->effective)
-               pp_annotate (output, "// #endif");
-            break;
-
-         case TOKEN_EXTENSION:
-            /* Parse the extension name. */
-            id = (const char *) (&prod[i]);
-            i += _mesa_strlen (id) + 1;
-            if (state.cond.top->effective)
-               pp_annotate (output, "// #extension %s: ", id);
-
-            /* Parse and apply extension behavior. */
-            if (state.cond.top->effective) {
-               switch (prod[i++]) {
-
-               case BEHAVIOR_REQUIRE:
-                  pp_annotate (output, "require");
-                  if (!pp_ext_set (&state.ext, id, GL_TRUE)) {
-                     if (_mesa_strcmp (id, "all") == 0) {
-                        slang_info_log_error (elog, "require: bad behavior for #extension all.");
-                        goto error;
-                     }
-                     else {
-                        slang_info_log_error (elog, "%s: required extension is not supported.", id);
-                        goto error;
-                     }
-                  }
-                  break;
-
-               case BEHAVIOR_ENABLE:
-                  pp_annotate (output, "enable");
-                  if (!pp_ext_set (&state.ext, id, GL_TRUE)) {
-                     if (_mesa_strcmp (id, "all") == 0) {
-                        slang_info_log_error (elog, "enable: bad behavior for #extension all.");
-                        goto error;
-                     }
-                     else {
-                        slang_info_log_warning (elog, "%s: enabled extension is not supported.", id);
-                     }
-                  }
-                  break;
-
-               case BEHAVIOR_WARN:
-                  pp_annotate (output, "warn");
-                  if (!pp_ext_set (&state.ext, id, GL_TRUE)) {
-                     if (_mesa_strcmp (id, "all") != 0) {
-                        slang_info_log_warning (elog, "%s: enabled extension is not supported.", id);
-                     }
-                  }
-                  break;
-
-               case BEHAVIOR_DISABLE:
-                  pp_annotate (output, "disable");
-                  if (!pp_ext_set (&state.ext, id, GL_FALSE)) {
-                     if (_mesa_strcmp (id, "all") == 0) {
-                        pp_ext_disable_all (&state.ext);
-                     }
-                     else {
-                        slang_info_log_warning (elog, "%s: disabled extension is not supported.", id);
-                     }
-                  }
-                  break;
-
-               default:
-                  assert (0);
-               }
-            }
-            break;
-
-         case TOKEN_PRAGMA:
-            {
-               GLint have_param;
-               const char *pragma, *param;
-
-               pragma = (const char *) (&prod[i]);
-               i += _mesa_strlen(pragma) + 1;
-               have_param = (prod[i++] == PRAGMA_PARAM);
-               if (have_param) {
-                  param = (const char *) (&prod[i]);
-                  i += _mesa_strlen(param) + 1;
-               }
-               else {
-                  param = NULL;
-               }
-               pp_pragma(pragmas, pragma, param);
-            }
-            break;
-
-         case TOKEN_LINE:
-            id = (const char *) (&prod[i]);
-            i += _mesa_strlen (id) + 1;
-
-            if (state.cond.top->effective) {
-               slang_string buffer;
-               GLuint count;
-               GLint results[2];
-               expand_state es;
-
-               slang_string_init (&buffer);
-               state.line++;
-               es.output = &buffer;
-               es.input = id;
-               es.state = &state;
-               if (!expand (&es, &state.symbols))
-                  goto error;
-
-               pp_annotate (output, "// #line ");
-               count = execute_expressions (output, eid,
-                                             (const byte *) (slang_string_cstr (&buffer)),
-                                             results, state.elog);
-               slang_string_free (&buffer);
-               if (count == 0)
-                  goto error;
-
-               state.line = results[0] - 1;
-               if (count == 2)
-                  state.file = results[1];
-            }
-            break;
-         }
-      }
-   }
-
-   /* Check for missing #endifs. */
-   if (state.cond.top->endif_required) {
-      slang_info_log_error (elog, "#endif expected but end of source found.");
-      goto error;
-   }
-
-   grammar_alloc_free(prod);
-   pp_state_free (&state);
-   return GL_TRUE;
-
-error:
-   grammar_alloc_free(prod);
-   pp_state_free (&state);
-   return GL_FALSE;
-}
-
-
-/**
- * Remove the continuation characters from the input string.
- * This is the very first step in preprocessing and is effective
- * even inside comment blocks.
- * If there is a whitespace between a backslash and a newline,
- * this is not considered as a line continuation.
- * \return GL_TRUE for success, GL_FALSE otherwise.
- */
-static GLboolean
-_slang_preprocess_backslashes(slang_string *output,
-                              const char *input)
-{
-   while (*input) {
-      if (input[0] == '\\') {
-         /* If a newline follows, eat the backslash and the newline. */
-         if (input[1] == '\r') {
-            if (input[2] == '\n') {
-               input += 3;
-            } else {
-               input += 2;
-            }
-         } else if (input[1] == '\n') {
-            if (input[2] == '\r') {
-               input += 3;
-            } else {
-               input += 2;
-            }
-         } else {
-            /* Leave the backslash alone. */
-            slang_string_pushc(output, *input++);
-         }
-      } else {
-         slang_string_pushc(output, *input++);
-      }
-   }
-   return GL_TRUE;
-}
-
-
-/**
- * Run preprocessor on source code.
- * \param extensions  indicates which GL extensions are enabled
- * \param output  the post-process results
- * \param input  the input text
- * \param elog  log to record warnings, errors
- * \param extensions  out extension settings
- * \param pragmas  in/out #pragma settings
- * \return GL_TRUE for success, GL_FALSE for error
- */
-GLboolean
-_slang_preprocess_directives(slang_string *output,
-                             const char *input,
-                             slang_info_log *elog,
-                             const struct gl_extensions *extensions,
-                             struct gl_sl_pragmas *pragmas)
-{
-   grammar pid, eid;
-   GLboolean success;
-   slang_string without_backslashes;
-
-   pid = grammar_load_from_text ((const byte *) (slang_pp_directives_syn));
-   if (pid == 0) {
-      grammar_error_to_log (elog);
-      return GL_FALSE;
-   }
-   eid = grammar_load_from_text ((const byte *) (slang_pp_expression_syn));
-   if (eid == 0) {
-      grammar_error_to_log (elog);
-      grammar_destroy (pid);
-      return GL_FALSE;
-   }
-
-   slang_string_init(&without_backslashes);
-   success = _slang_preprocess_backslashes(&without_backslashes, input);
-
-   if (0) {
-      _mesa_printf("Pre-processed shader:\n");
-      _mesa_printf("%s", slang_string_cstr(&without_backslashes));
-      _mesa_printf("----------------------\n");
-   }
-
-   if (success) {
-      success = preprocess_source(output,
-                                  slang_string_cstr(&without_backslashes),
-                                  pid,
-                                  eid,
-                                  elog,
-                                  extensions,
-                                  pragmas);
-   }
-
-   slang_string_free(&without_backslashes);
-   grammar_destroy (eid);
-   grammar_destroy (pid);
-
-   if (0) {
-      _mesa_printf("Post-processed shader:\n");
-      _mesa_printf("%s", slang_string_cstr(output));
-      _mesa_printf("----------------------\n");
-   }
-
-   return success;
-}
-
diff --git a/src/mesa/shader/slang/slang_preprocess.h b/src/mesa/shader/slang/slang_preprocess.h
deleted file mode 100644 (file)
index f344820..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 2005-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"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION 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 SLANG_PREPROCESS_H
-#define SLANG_PREPROCESS_H
-
-#include "slang_compile.h"
-#include "slang_log.h"
-
-
-extern GLboolean
-_slang_preprocess_version (const char *, GLuint *, GLuint *, slang_info_log *);
-
-extern GLboolean
-_slang_preprocess_directives(slang_string *output, const char *input,
-                             slang_info_log *,
-                             const struct gl_extensions *extensions,
-                             struct gl_sl_pragmas *pragmas);
-
-#endif /* SLANG_PREPROCESS_H */
index b8a21f642cb1375cf5938c26bb51e45e534e33b4..13b9ca3c877c73860a24adf5fd7021e3f553b183 100644 (file)
@@ -84,10 +84,11 @@ _slang_lookup_constant(const char *name)
    for (i = 0; info[i].Name; i++) {
       if (strcmp(info[i].Name, name) == 0) {
          /* found */
-         GLint value = -1;
-         _mesa_GetIntegerv(info[i].Token, &value);
-         ASSERT(value >= 0);  /* sanity check that glGetFloatv worked */
-         return value;
+         GLint values[16];
+         values[0] = -1;
+         _mesa_GetIntegerv(info[i].Token, values);
+         ASSERT(values[0] >= 0);  /* sanity check that glGetFloatv worked */
+         return values[0];
       }
    }
    return -1;
index a4ebacc093661e825ee796046a68a41d178f4e1a..e07e3a226a517ce5d7d677f7afa2305687cb17fd 100644 (file)
@@ -311,10 +311,10 @@ _slang_free_temp(slang_var_table *vt, slang_ir_storage *store)
 {
    struct table *t = vt->Top;
    GLuint i;
-   GLuint r = store->Index;
+   GLint r = store->Index;
    assert(store->Size > 0);
    assert(r >= 0);
-   assert(r + store->Size <= vt->MaxRegisters * 4);
+   assert((GLuint)r + store->Size <= vt->MaxRegisters * 4);
    if (dbg) printf("Free temp sz %d at %d.%s (level %d) store %p\n",
                    store->Size, r,
                    _mesa_swizzle_string(store->Swizzle, 0, 0),
index 7a9aa7b8f653c8d47fc3f7066b1f68447cf33a87..1f6d9b844d622d8c641c53e878be5f9c0d5a445a 100644 (file)
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  * DEALINGS IN THE SOFTWARE.
  */
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <assert.h>
 
+#include "main/imports.h"
 #include "symbol_table.h"
 #include "hash_table.h"
 
@@ -73,6 +69,9 @@ struct symbol {
 /**
  */
 struct symbol_header {
+    /** Linkage in list of all headers in a given symbol table. */
+    struct symbol_header *next;
+
     /** Symbol name. */
     const char *name;
 
@@ -102,6 +101,9 @@ struct _mesa_symbol_table {
 
     /** Top of scope stack. */
     struct scope_level *current_scope;
+
+    /** List of all symbol headers in the table. */
+    struct symbol_header *hdr;
 };
 
 
@@ -301,6 +303,8 @@ _mesa_symbol_table_add_symbol(struct _mesa_symbol_table *table,
         hdr->name = name;
 
         hash_table_insert(table->ht, hdr, name);
+       hdr->next = table->hdr;
+       table->hdr = hdr;
     }
 
     check_symbol_table(table);
@@ -341,10 +345,18 @@ _mesa_symbol_table_ctor(void)
 void
 _mesa_symbol_table_dtor(struct _mesa_symbol_table *table)
 {
+   struct symbol_header *hdr;
+   struct symbol_header *next;
+
    while (table->current_scope != NULL) {
       _mesa_symbol_table_pop_scope(table);
    }
 
+   for (hdr = table->hdr; hdr != NULL; hdr = next) {
+       next = hdr->next;
+       _mesa_free(hdr);
+   }
+
    hash_table_dtor(table->ht);
    free(table);
 }
index 7107538cee732c20d5767c143f77aa34f7cc22be..c42f61af5ead3f9f5c87584dac5cca5f95fe96d9 100644 (file)
@@ -15,6 +15,7 @@ MAIN_SOURCES = \
        main/clear.c \
        main/clip.c \
        main/colortab.c \
+       main/condrender.c \
        main/context.c \
        main/convolve.c \
        main/cpuinfo.c \
@@ -33,6 +34,7 @@ MAIN_SOURCES = \
        main/feedback.c \
        main/ffvertex_prog.c \
        main/fog.c \
+       main/formats.c \
        main/framebuffer.c \
        main/get.c \
        main/getstring.c \
@@ -55,6 +57,7 @@ MAIN_SOURCES = \
        main/rastpos.c \
        main/rbadaptors.c \
        main/readpix.c \
+       main/remap.c \
        main/renderbuffer.c \
        main/scissor.c \
        main/shaders.c \
@@ -67,6 +70,7 @@ MAIN_SOURCES = \
        main/texcompress_fxt1.c \
        main/texenv.c \
        main/texenvprogram.c \
+       main/texfetch.c \
        main/texformat.c \
        main/texgen.c \
        main/texgetimage.c \
@@ -77,6 +81,7 @@ MAIN_SOURCES = \
        main/texstate.c \
        main/texstore.c \
        main/varray.c \
+       main/version.c \
        main/viewport.c \
        main/vtxfmt.c
 
@@ -187,8 +192,8 @@ STATETRACKER_SOURCES = \
        state_tracker/st_cb_blit.c \
        state_tracker/st_cb_bufferobjects.c \
        state_tracker/st_cb_clear.c \
+       state_tracker/st_cb_condrender.c \
        state_tracker/st_cb_flush.c \
-       state_tracker/st_cb_get.c \
        state_tracker/st_cb_drawpixels.c \
        state_tracker/st_cb_fbo.c \
        state_tracker/st_cb_feedback.c \
@@ -216,7 +221,6 @@ SHADER_SOURCES = \
        shader/arbprogparse.c \
        shader/arbprogram.c \
        shader/atifragshader.c \
-       shader/grammar/grammar_mesa.c \
        shader/hash_table.c \
        shader/lex.yy.c \
        shader/nvfragparse.c \
@@ -253,7 +257,6 @@ SLANG_SOURCES =     \
        shader/slang/slang_link.c       \
        shader/slang/slang_log.c        \
        shader/slang/slang_mem.c        \
-       shader/slang/slang_preprocess.c \
        shader/slang/slang_print.c      \
        shader/slang/slang_simplify.c   \
        shader/slang/slang_storage.c    \
@@ -363,6 +366,12 @@ GLAPI_OBJECTS = \
 COMMON_DRIVER_OBJECTS = $(COMMON_DRIVER_SOURCES:.c=.o)
 
 
+### Other archives/libraries
+
+GLSL_LIBS = \
+       $(TOP)/src/glsl/pp/libglslpp.a \
+       $(TOP)/src/glsl/cl/libglslcl.a
+
 
 ### Include directories
 
index aaa17e6a3b9d694d8fdef094dd33807f3a48a6a5..9b0f8027ebb87e4b2695eb316165a89863993250 100644 (file)
@@ -1014,21 +1014,29 @@ gl_dispatch_functions_start:
        GL_STUB(gl_dispatch_stub_785, _gloffset_FlushMappedBufferRangeAPPLE)
        HIDDEN(gl_dispatch_stub_785)
        GL_STUB(glFramebufferTextureLayerEXT, _gloffset_FramebufferTextureLayerEXT)
+       GL_STUB(glColorMaskIndexedEXT, _gloffset_ColorMaskIndexedEXT)
+       GL_STUB(glDisableIndexedEXT, _gloffset_DisableIndexedEXT)
+       GL_STUB(glEnableIndexedEXT, _gloffset_EnableIndexedEXT)
+       GL_STUB(glGetBooleanIndexedvEXT, _gloffset_GetBooleanIndexedvEXT)
+       GL_STUB(glGetIntegerIndexedvEXT, _gloffset_GetIntegerIndexedvEXT)
+       GL_STUB(glIsEnabledIndexedEXT, _gloffset_IsEnabledIndexedEXT)
+       GL_STUB(glBeginConditionalRenderNV, _gloffset_BeginConditionalRenderNV)
+       GL_STUB(glEndConditionalRenderNV, _gloffset_EndConditionalRenderNV)
        GL_STUB(glProvokingVertexEXT, _gloffset_ProvokingVertexEXT)
-       GL_STUB(gl_dispatch_stub_788, _gloffset_GetTexParameterPointervAPPLE)
-       HIDDEN(gl_dispatch_stub_788)
-       GL_STUB(gl_dispatch_stub_789, _gloffset_TextureRangeAPPLE)
-       HIDDEN(gl_dispatch_stub_789)
-       GL_STUB(gl_dispatch_stub_790, _gloffset_StencilFuncSeparateATI)
-       HIDDEN(gl_dispatch_stub_790)
-       GL_STUB(gl_dispatch_stub_791, _gloffset_ProgramEnvParameters4fvEXT)
-       HIDDEN(gl_dispatch_stub_791)
-       GL_STUB(gl_dispatch_stub_792, _gloffset_ProgramLocalParameters4fvEXT)
-       HIDDEN(gl_dispatch_stub_792)
-       GL_STUB(gl_dispatch_stub_793, _gloffset_GetQueryObjecti64vEXT)
-       HIDDEN(gl_dispatch_stub_793)
-       GL_STUB(gl_dispatch_stub_794, _gloffset_GetQueryObjectui64vEXT)
-       HIDDEN(gl_dispatch_stub_794)
+       GL_STUB(gl_dispatch_stub_796, _gloffset_GetTexParameterPointervAPPLE)
+       HIDDEN(gl_dispatch_stub_796)
+       GL_STUB(gl_dispatch_stub_797, _gloffset_TextureRangeAPPLE)
+       HIDDEN(gl_dispatch_stub_797)
+       GL_STUB(gl_dispatch_stub_798, _gloffset_StencilFuncSeparateATI)
+       HIDDEN(gl_dispatch_stub_798)
+       GL_STUB(gl_dispatch_stub_799, _gloffset_ProgramEnvParameters4fvEXT)
+       HIDDEN(gl_dispatch_stub_799)
+       GL_STUB(gl_dispatch_stub_800, _gloffset_ProgramLocalParameters4fvEXT)
+       HIDDEN(gl_dispatch_stub_800)
+       GL_STUB(gl_dispatch_stub_801, _gloffset_GetQueryObjecti64vEXT)
+       HIDDEN(gl_dispatch_stub_801)
+       GL_STUB(gl_dispatch_stub_802, _gloffset_GetQueryObjectui64vEXT)
+       HIDDEN(gl_dispatch_stub_802)
        GL_STUB_ALIAS(glArrayElementEXT, glArrayElement)
        GL_STUB_ALIAS(glBindTextureEXT, glBindTexture)
        GL_STUB_ALIAS(glDrawArraysEXT, glDrawArrays)
@@ -1272,6 +1280,7 @@ gl_dispatch_functions_start:
        GL_STUB_ALIAS(glGetAttribLocation, glGetAttribLocationARB)
        GL_STUB_ALIAS(glDrawBuffers, glDrawBuffersARB)
        GL_STUB_ALIAS(glDrawBuffersATI, glDrawBuffersARB)
+       GL_STUB_ALIAS(glRenderbufferStorageMultisampleEXT, glRenderbufferStorageMultisample)
        GL_STUB_ALIAS(glPointParameterf, glPointParameterfEXT)
        GL_STUB_ALIAS(glPointParameterfARB, glPointParameterfEXT)
        GL_STUB_ALIAS(glPointParameterfSGIS, glPointParameterfEXT)
index f2b9674bf2d7b28185764eaa1b5a8339d2d9b94e..2a7cce41e5ad78b19e44df54432295121d9c1836 100644 (file)
@@ -17,7 +17,7 @@
 
 #include "sparc_matrix.h"
 
-#if defined(SVR4) || defined(__SVR4) || defined(__svr4__)
+#if defined(SVR4) || defined(__SVR4) || defined(__svr4__) || defined(__arch64__)
        /* Solaris requires this for 64-bit. */
         .register %g2, #scratch
         .register %g3, #scratch
index ca15ce1b474c5165ceb3cd2303ef28af10014d1f..73df44d1988ef8cf6e94fde0019193b700fecdbd 100644 (file)
@@ -46,7 +46,8 @@ static const struct st_tracked_state *atoms[] =
    &st_update_clip,
 
    &st_finalize_textures,
-   &st_update_shader,
+   &st_update_fp,
+   &st_update_vp,
 
    &st_update_rasterizer,
    &st_update_polygon_stipple,
@@ -137,7 +138,7 @@ void st_validate_state( struct st_context *st )
    if (state->st == 0)
       return;
 
-//   _mesa_printf("%s %x/%x\n", __FUNCTION__, state->mesa, state->st);
+   /*_mesa_printf("%s %x/%x\n", __FUNCTION__, state->mesa, state->st);*/
 
    if (1) {
       /* Debug version which enforces various sanity checks on the
@@ -152,7 +153,7 @@ void st_validate_state( struct st_context *st )
         const struct st_tracked_state *atom = atoms[i];
         struct st_state_flags generated;
         
-//      _mesa_printf("atom %s %x/%x\n", atom->name, atom->dirty.mesa, atom->dirty.st);
+        /*_mesa_printf("atom %s %x/%x\n", atom->name, atom->dirty.mesa, atom->dirty.st);*/
 
         if (!(atom->dirty.mesa || atom->dirty.st) ||
             !atom->update) {
@@ -162,7 +163,7 @@ void st_validate_state( struct st_context *st )
 
         if (check_state(state, &atom->dirty)) {
            atoms[i]->update( st );
-//         _mesa_printf("after: %x\n", atom->dirty.mesa);
+           /*_mesa_printf("after: %x\n", atom->dirty.mesa);*/
         }
 
         accumulate_state(&examined, &atom->dirty);
@@ -175,7 +176,7 @@ void st_validate_state( struct st_context *st )
         assert(!check_state(&examined, &generated));
         prev = *state;
       }
-//      _mesa_printf("\n");
+      /*_mesa_printf("\n");*/
 
    }
    else {
index c7cffd85c8a89d03b2c729622108e29bce2077a8..f34b49203b226f4c8f2ea03417687d9c15aa4c15 100644 (file)
@@ -47,7 +47,8 @@ void st_validate_state( struct st_context *st );
 extern const struct st_tracked_state st_update_framebuffer;
 extern const struct st_tracked_state st_update_clip;
 extern const struct st_tracked_state st_update_depth_stencil_alpha;
-extern const struct st_tracked_state st_update_shader;
+extern const struct st_tracked_state st_update_fp;
+extern const struct st_tracked_state st_update_vp;
 extern const struct st_tracked_state st_update_rasterizer;
 extern const struct st_tracked_state st_update_polygon_stipple;
 extern const struct st_tracked_state st_update_viewport;
index 35c09c3e08fa1b36fbf3012f164908eb1410e7f3..43e62c29f3e4fc65a70f687f056f811436c35848 100644 (file)
@@ -200,13 +200,13 @@ update_blend( struct st_context *st )
    }
 
    /* Colormask - maybe reverse these bits? */
-   if (st->ctx->Color.ColorMask[0])
+   if (st->ctx->Color.ColorMask[0][0])
       blend->colormask |= PIPE_MASK_R;
-   if (st->ctx->Color.ColorMask[1])
+   if (st->ctx->Color.ColorMask[0][1])
       blend->colormask |= PIPE_MASK_G;
-   if (st->ctx->Color.ColorMask[2])
+   if (st->ctx->Color.ColorMask[0][2])
       blend->colormask |= PIPE_MASK_B;
-   if (st->ctx->Color.ColorMask[3])
+   if (st->ctx->Color.ColorMask[0][3])
       blend->colormask |= PIPE_MASK_A;
 
    if (st->ctx->Color.DitherFlag)
index 5209a6a0c9c668703dc87ebe52e9612a10efd452..8ca4335e3307f2e90bf541a197635e6f417a57af 100644 (file)
@@ -39,6 +39,8 @@
 #include "pipe/p_context.h"
 #include "pipe/p_inlines.h"
 #include "cso_cache/cso_context.h"
+#include "util/u_rect.h"
+#include "util/u_math.h"
 
 
 
@@ -63,8 +65,8 @@ update_renderbuffer_surface(struct st_context *st,
       GLuint level;
       /* find matching mipmap level size */
       for (level = 0; level <= texture->last_level; level++) {
-         if (texture->width[level] == rtt_width &&
-             texture->height[level] == rtt_height) {
+         if (u_minify(texture->width0, level) == rtt_width &&
+             u_minify(texture->height0, level) == rtt_height) {
 
             pipe_surface_reference(&strb->surface, NULL);
 
@@ -162,10 +164,17 @@ update_framebuffer_state( struct st_context *st )
          (void) st_get_framebuffer_surface(stfb, ST_SURFACE_FRONT_LEFT, &surf_front);
          (void) st_get_framebuffer_surface(stfb, ST_SURFACE_BACK_LEFT, &surf_back);
 
-         st->pipe->surface_copy(st->pipe,
-                                surf_front, 0, 0,  /* dest */
-                                surf_back, 0, 0,   /* src */
-                                fb->Width, fb->Height);
+         if (st->pipe->surface_copy) {
+            st->pipe->surface_copy(st->pipe,
+                                   surf_front, 0, 0,  /* dest */
+                                   surf_back, 0, 0,   /* src */
+                                   fb->Width, fb->Height);
+         } else {
+            util_surface_copy(st->pipe, FALSE,
+                              surf_front, 0, 0,
+                              surf_back, 0, 0,
+                              fb->Width, fb->Height);
+         }
       }
       /* we're assuming we'll really draw to the front buffer */
       st->frontbuffer_status = FRONT_STATUS_DIRTY;
index babfcc87b4ab8e2081df7166e683faa290890b36..6a5854e9ba5b4d0a4d0122cd776afd228ec5f627 100644 (file)
@@ -145,7 +145,7 @@ load_color_map_texture(GLcontext *ctx, struct pipe_texture *pt)
    const GLuint gSize = ctx->PixelMaps.GtoG.Size;
    const GLuint bSize = ctx->PixelMaps.BtoB.Size;
    const GLuint aSize = ctx->PixelMaps.AtoA.Size;
-   const uint texSize = pt->width[0];
+   const uint texSize = pt->width0;
    uint *dest;
    uint i, j;
 
@@ -162,12 +162,14 @@ load_color_map_texture(GLcontext *ctx, struct pipe_texture *pt)
     */
    for (i = 0; i < texSize; i++) {
       for (j = 0; j < texSize; j++) {
+         union util_color uc;
          int k = (i * texSize + j);
          ubyte r = ctx->PixelMaps.RtoR.Map8[j * rSize / texSize];
          ubyte g = ctx->PixelMaps.GtoG.Map8[i * gSize / texSize];
          ubyte b = ctx->PixelMaps.BtoB.Map8[j * bSize / texSize];
          ubyte a = ctx->PixelMaps.AtoA.Map8[i * aSize / texSize];
-         util_pack_color_ub(r, g, b, a, pt->format, dest + k);
+         util_pack_color_ub(r, g, b, a, pt->format, &uc);
+         *(dest + k) = uc.ui;
       }
    }
 
index 50ce82811c567c31da8a53df1c34e57dd4b2225e..7b84a86ba485d35762b8888cec48c776760c7b8b 100644 (file)
@@ -208,15 +208,11 @@ update_samplers(struct st_context *st)
             assert(sampler->min_lod <= sampler->max_lod);
          }
 
-         xlate_border_color(texobj->BorderColor,
-                            teximg ? teximg->TexFormat->BaseFormat : GL_RGBA,
+         xlate_border_color(texobj->BorderColor.f,
+                            teximg ? teximg->_BaseFormat : GL_RGBA,
                             sampler->border_color);
 
         sampler->max_anisotropy = texobj->MaxAnisotropy;
-         if (sampler->max_anisotropy > 1.0) {
-            sampler->min_img_filter = PIPE_TEX_FILTER_ANISO;
-            sampler->mag_img_filter = PIPE_TEX_FILTER_ANISO;
-         }
 
          /* only care about ARB_shadow, not SGI shadow */
          if (texobj->CompareMode == GL_COMPARE_R_TO_TEXTURE) {
@@ -229,14 +225,23 @@ update_samplers(struct st_context *st)
 
          /*printf("%s su=%u non-null\n", __FUNCTION__, su);*/
          cso_single_sampler(st->cso_context, su, sampler);
+         if (su < st->ctx->Const.MaxVertexTextureImageUnits) {
+            cso_single_vertex_sampler(st->cso_context, su, sampler);
+         }
       }
       else {
          /*printf("%s su=%u null\n", __FUNCTION__, su);*/
          cso_single_sampler(st->cso_context, su, NULL);
+         if (su < st->ctx->Const.MaxVertexTextureImageUnits) {
+            cso_single_vertex_sampler(st->cso_context, su, NULL);
+         }
       }
    }
 
    cso_single_sampler_done(st->cso_context);
+   if (st->ctx->Const.MaxVertexTextureImageUnits > 0) {
+      cso_single_vertex_sampler_done(st->cso_context);
+   }
 }
 
 
index ee649be885e2fa882ea5e80685796eb93a00c2cd..46c8cbb30987596c3269b7c4b39854eb97a9cb36 100644 (file)
 #include "st_mesa_to_tgsi.h"
 
 
-/**
- * This represents a vertex program, especially translated to match
- * the inputs of a particular fragment shader.
- */
-struct translated_vertex_program
-{
-   struct st_vertex_program *master;
-
-   /** The fragment shader "signature" this vertex shader is meant for: */
-   GLbitfield frag_inputs;
-
-   /** Compared against master vertex program's serialNo: */
-   GLuint serialNo;
-
-   /** Maps VERT_RESULT_x to slot */
-   GLuint output_to_slot[VERT_RESULT_MAX];
-   ubyte output_to_semantic_name[VERT_RESULT_MAX];
-   ubyte output_to_semantic_index[VERT_RESULT_MAX];
-
-   /** Pointer to the translated vertex program */
-   struct st_vertex_program *vp;
 
-   struct translated_vertex_program *next;  /**< next in linked list */
-};
-
-
-
-/**
- * Given a vertex program output attribute, return the corresponding
- * fragment program input attribute.
- * \return -1 for vertex outputs that have no corresponding fragment input
- */
-static GLint
-vp_out_to_fp_in(GLuint vertResult)
-{
-   if (vertResult >= VERT_RESULT_TEX0 &&
-       vertResult < VERT_RESULT_TEX0 + MAX_TEXTURE_COORD_UNITS)
-      return FRAG_ATTRIB_TEX0 + (vertResult - VERT_RESULT_TEX0);
-
-   if (vertResult >= VERT_RESULT_VAR0 &&
-       vertResult < VERT_RESULT_VAR0 + MAX_VARYING)
-      return FRAG_ATTRIB_VAR0 + (vertResult - VERT_RESULT_VAR0);
-
-   switch (vertResult) {
-   case VERT_RESULT_HPOS:
-      return FRAG_ATTRIB_WPOS;
-   case VERT_RESULT_COL0:
-      return FRAG_ATTRIB_COL0;
-   case VERT_RESULT_COL1:
-      return FRAG_ATTRIB_COL1;
-   case VERT_RESULT_FOGC:
-      return FRAG_ATTRIB_FOGC;
-   default:
-      /* Back-face colors, edge flags, etc */
-      return -1;
-   }
-}
 
 
-/**
- * Find a translated vertex program that corresponds to stvp and
- * has outputs matched to stfp's inputs.
- * This performs vertex and fragment translation (to TGSI) when needed.
+/*
+ * Translate fragment program if needed.
  */
-static struct translated_vertex_program *
-find_translated_vp(struct st_context *st,
-                   struct st_vertex_program *stvp,
-                   struct st_fragment_program *stfp)
+static void
+translate_fp(struct st_context *st,
+             struct st_fragment_program *stfp)
 {
-   static const GLuint UNUSED = ~0;
-   struct translated_vertex_program *xvp;
    const GLbitfield fragInputsRead = stfp->Base.Base.InputsRead;
 
-   /*
-    * Translate fragment program if needed.
-    */
    if (!stfp->state.tokens) {
       GLuint inAttr, numIn = 0;
 
@@ -141,7 +77,7 @@ find_translated_vp(struct st_context *st,
             numIn++;
          }
          else {
-            stfp->input_to_slot[inAttr] = UNUSED;
+            stfp->input_to_slot[inAttr] = -1;
          }
       }
 
@@ -151,170 +87,74 @@ find_translated_vp(struct st_context *st,
 
       st_translate_fragment_program(st, stfp, stfp->input_to_slot);
    }
+}
 
 
-   /* See if we've got a translated vertex program whose outputs match
-    * the fragment program's inputs.
-    * XXX This could be a hash lookup, using InputsRead as the key.
-    */
-   for (xvp = stfp->vertex_programs; xvp; xvp = xvp->next) {
-      if (xvp->master == stvp && xvp->frag_inputs == fragInputsRead) {
-         break;
-      }
-   }
-
-   /* No?  Allocate translated vp object now */
-   if (!xvp) {
-      xvp = ST_CALLOC_STRUCT(translated_vertex_program);
-      xvp->frag_inputs = fragInputsRead;
-      xvp->master = stvp;
-
-      xvp->next = stfp->vertex_programs;
-      stfp->vertex_programs = xvp;
-   }
 
-   /* See if we need to translate vertex program to TGSI form */
-   if (xvp->serialNo != stvp->serialNo) {
-      GLuint outAttr;
-      const GLbitfield outputsWritten = stvp->Base.Base.OutputsWritten;
-      GLuint numVpOuts = 0;
-      GLboolean emitPntSize = GL_FALSE, emitBFC0 = GL_FALSE, emitBFC1 = GL_FALSE;
-      GLbitfield usedGenerics = 0x0;
-      GLbitfield usedOutputSlots = 0x0;
-
-      /* Compute mapping of vertex program outputs to slots, which depends
-       * on the fragment program's input->slot mapping.
-       */
-      for (outAttr = 0; outAttr < VERT_RESULT_MAX; outAttr++) {
-         /* set defaults: */
-         xvp->output_to_slot[outAttr] = UNUSED;
-         xvp->output_to_semantic_name[outAttr] = TGSI_SEMANTIC_COUNT;
-         xvp->output_to_semantic_index[outAttr] = 99;
-
-         if (outAttr == VERT_RESULT_HPOS) {
-            /* always put xformed position into slot zero */
-            GLuint slot = 0;
-            xvp->output_to_slot[VERT_RESULT_HPOS] = slot;
-            xvp->output_to_semantic_name[outAttr] = TGSI_SEMANTIC_POSITION;
-            xvp->output_to_semantic_index[outAttr] = 0;
-            numVpOuts++;
-            usedOutputSlots |= (1 << slot);
-         }
-         else if (outputsWritten & (1 << outAttr)) {
-            /* see if the frag prog wants this vert output */
-            GLint fpInAttrib = vp_out_to_fp_in(outAttr);
-            if (fpInAttrib >= 0) {
-               GLuint fpInSlot = stfp->input_to_slot[fpInAttrib];
-               if (fpInSlot != ~0) {
-                  /* match this vp output to the fp input */
-                  GLuint vpOutSlot = stfp->input_map[fpInSlot];
-                  xvp->output_to_slot[outAttr] = vpOutSlot;
-                  xvp->output_to_semantic_name[outAttr] = stfp->input_semantic_name[fpInSlot];
-                  xvp->output_to_semantic_index[outAttr] = stfp->input_semantic_index[fpInSlot];
-                  numVpOuts++;
-                  usedOutputSlots |= (1 << vpOutSlot);
-               }
-               else {
-#if 0 /*debug*/
-                  printf("VP output %d not used by FP\n", outAttr);
-#endif
-               }
-            }
-            else if (outAttr == VERT_RESULT_PSIZ)
-               emitPntSize = GL_TRUE;
-            else if (outAttr == VERT_RESULT_BFC0)
-               emitBFC0 = GL_TRUE;
-            else if (outAttr == VERT_RESULT_BFC1)
-               emitBFC1 = GL_TRUE;
-         }
-#if 0 /*debug*/
-         printf("assign vp output_to_slot[%d] = %d\n", outAttr, 
-                xvp->output_to_slot[outAttr]);
-#endif
-      }
+/**
+ * Find a translated vertex program that corresponds to stvp and
+ * has outputs matched to stfp's inputs.
+ * This performs vertex and fragment translation (to TGSI) when needed.
+ */
+static struct st_vp_varient *
+find_translated_vp(struct st_context *st,
+                   struct st_vertex_program *stvp )
+{
+   struct st_vp_varient *vpv;
+   struct st_vp_varient_key key;
 
-      /* must do these last */
-      if (emitPntSize) {
-         GLuint slot = numVpOuts++;
-         xvp->output_to_slot[VERT_RESULT_PSIZ] = slot;
-         xvp->output_to_semantic_name[VERT_RESULT_PSIZ] = TGSI_SEMANTIC_PSIZE;
-         xvp->output_to_semantic_index[VERT_RESULT_PSIZ] = 0;
-         usedOutputSlots |= (1 << slot);
-      }
-      if (emitBFC0) {
-         GLuint slot = numVpOuts++;
-         xvp->output_to_slot[VERT_RESULT_BFC0] = slot;
-         xvp->output_to_semantic_name[VERT_RESULT_BFC0] = TGSI_SEMANTIC_COLOR;
-         xvp->output_to_semantic_index[VERT_RESULT_BFC0] = 0;
-         usedOutputSlots |= (1 << slot);
-      }
-      if (emitBFC1) {
-         GLuint slot = numVpOuts++;
-         xvp->output_to_slot[VERT_RESULT_BFC1] = slot;
-         xvp->output_to_semantic_name[VERT_RESULT_BFC1] = TGSI_SEMANTIC_COLOR;
-         xvp->output_to_semantic_index[VERT_RESULT_BFC1] = 1;
-         usedOutputSlots |= (1 << slot);
-      }
+   /* Nothing in our key yet.  This will change:
+    */
+   memset(&key, 0, sizeof key);
+
+   /* When this is true, we will add an extra input to the vertex
+    * shader translation (for edgeflags), an extra output with
+    * edgeflag semantics, and extend the vertex shader to pass through
+    * the input to the output.  We'll need to use similar logic to set
+    * up the extra vertex_element input for edgeflags.
+    * _NEW_POLYGON, ST_NEW_EDGEFLAGS_DATA
+    */
+   key.passthrough_edgeflags = (st->vertdata_edgeflags && (
+                                st->ctx->Polygon.FrontMode != GL_FILL ||
+                                st->ctx->Polygon.BackMode != GL_FILL));
 
-      /* build usedGenerics mask */
-      usedGenerics = 0x0;
-      for (outAttr = 0; outAttr < VERT_RESULT_MAX; outAttr++) {
-         if (xvp->output_to_semantic_name[outAttr] == TGSI_SEMANTIC_GENERIC) {
-            usedGenerics |= (1 << xvp->output_to_semantic_index[outAttr]);
-         }
-      }
 
-      /* For each vertex program output that doesn't match up to a fragment
-       * program input, map the vertex program output to a free slot and
-       * free generic attribute.
+   /* Do we need to throw away old translations after a change in the
+    * GL program string?
+    */
+   if (stvp->serialNo != stvp->lastSerialNo) {
+      /* These may have changed if the program string changed.
        */
-      for (outAttr = 0; outAttr < VERT_RESULT_MAX; outAttr++) {
-         if (outputsWritten & (1 << outAttr)) {
-            if (xvp->output_to_slot[outAttr] == UNUSED) {
-               GLint freeGeneric = _mesa_ffs(~usedGenerics) - 1;
-               GLint freeSlot = _mesa_ffs(~usedOutputSlots) - 1;
-               usedGenerics |= (1 << freeGeneric);
-               usedOutputSlots |= (1 << freeSlot);
-               xvp->output_to_slot[outAttr] = freeSlot;
-               xvp->output_to_semantic_name[outAttr] = TGSI_SEMANTIC_GENERIC;
-               xvp->output_to_semantic_index[outAttr] = freeGeneric;
-            }
-         }
+      st_prepare_vertex_program( st, stvp );
 
-#if 0 /*debug*/
-         printf("vp output_to_slot[%d] = %d\n", outAttr, 
-                xvp->output_to_slot[outAttr]);
-#endif
+      /* We are now up-to-date:
+       */
+      stvp->lastSerialNo = stvp->serialNo;
+   }
+   
+   /* See if we've got a translated vertex program whose outputs match
+    * the fragment program's inputs.
+    */
+   for (vpv = stvp->varients; vpv; vpv = vpv->next) {
+      if (memcmp(&vpv->key, &key, sizeof key) == 0) {
+         break;
       }
+   }
 
-      assert(stvp->Base.Base.NumInstructions > 1);
-
-      st_translate_vertex_program(st, stvp, xvp->output_to_slot,
-                                  xvp->output_to_semantic_name,
-                                  xvp->output_to_semantic_index);
-
-      xvp->vp = stvp;
-
-      /* translated VP is up to date now */
-      xvp->serialNo = stvp->serialNo;
+   /* No?  Perform new translation here. */
+   if (!vpv) {
+      vpv = st_translate_vertex_program(st, stvp, &key);
+      if (!vpv)
+         return NULL;
+      
+      vpv->next = stvp->varients;
+      stvp->varients = vpv;
    }
 
-   return xvp;
+   return vpv;
 }
 
 
-void
-st_free_translated_vertex_programs(struct st_context *st,
-                                   struct translated_vertex_program *xvp)
-{
-   struct translated_vertex_program *next;
-
-   while (xvp) {
-      next = xvp->next;
-      _mesa_free(xvp);
-      xvp = next;
-   }
-}
 
 
 static void *
@@ -328,32 +168,19 @@ get_passthrough_fs(struct st_context *st)
    return st->passthrough_fs;
 }
 
-
 static void
-update_linkage( struct st_context *st )
+update_fp( struct st_context *st )
 {
-   struct st_vertex_program *stvp;
    struct st_fragment_program *stfp;
-   struct translated_vertex_program *xvp;
-
-   /* find active shader and params -- Should be covered by
-    * ST_NEW_VERTEX_PROGRAM
-    */
-   assert(st->ctx->VertexProgram._Current);
-   stvp = st_vertex_program(st->ctx->VertexProgram._Current);
-   assert(stvp->Base.Base.Target == GL_VERTEX_PROGRAM_ARB);
 
    assert(st->ctx->FragmentProgram._Current);
    stfp = st_fragment_program(st->ctx->FragmentProgram._Current);
    assert(stfp->Base.Base.Target == GL_FRAGMENT_PROGRAM_ARB);
 
-   xvp = find_translated_vp(st, stvp, stfp);
+   translate_fp(st, stfp);
 
-   st_reference_vertprog(st, &st->vp, stvp);
    st_reference_fragprog(st, &st->fp, stfp);
 
-   cso_set_vertex_shader_handle(st->cso_context, stvp->driver_shader);
-
    if (st->missing_textures) {
       /* use a pass-through frag shader that uses no textures */
       void *fs = get_passthrough_fs(st);
@@ -362,16 +189,48 @@ update_linkage( struct st_context *st )
    else {
       cso_set_fragment_shader_handle(st->cso_context, stfp->driver_shader);
    }
+}
+
+const struct st_tracked_state st_update_fp = {
+   "st_update_fp",                                     /* name */
+   {                                                   /* dirty */
+      0,                                               /* mesa */
+      ST_NEW_FRAGMENT_PROGRAM                           /* st */
+   },
+   update_fp                                   /* update */
+};
+
+
+
+
+static void
+update_vp( struct st_context *st )
+{
+   struct st_vertex_program *stvp;
 
-   st->vertex_result_to_slot = xvp->output_to_slot;
+   /* find active shader and params -- Should be covered by
+    * ST_NEW_VERTEX_PROGRAM
+    */
+   assert(st->ctx->VertexProgram._Current);
+   stvp = st_vertex_program(st->ctx->VertexProgram._Current);
+   assert(stvp->Base.Base.Target == GL_VERTEX_PROGRAM_ARB);
+
+   st->vp_varient = find_translated_vp(st, stvp);
+
+   st_reference_vertprog(st, &st->vp, stvp);
+
+   cso_set_vertex_shader_handle(st->cso_context, 
+                                st->vp_varient->driver_shader);
+
+   st->vertex_result_to_slot = stvp->result_to_output;
 }
 
 
-const struct st_tracked_state st_update_shader = {
-   "st_update_shader",                                 /* name */
+const struct st_tracked_state st_update_vp = {
+   "st_update_vp",                                     /* name */
    {                                                   /* dirty */
-      0,                                               /* mesa */
-      ST_NEW_VERTEX_PROGRAM | ST_NEW_FRAGMENT_PROGRAM  /* st */
+      _NEW_POLYGON,                                    /* mesa */
+      ST_NEW_VERTEX_PROGRAM | ST_NEW_EDGEFLAGS_DATA    /* st */
    },
-   update_linkage                                      /* update */
+   update_vp                                   /* update */
 };
index 4d4f97da7ed37b87717ca854cb5bfc9bf925de47..0b68447d2122364daf4ab5402ddfac344faba5af 100644 (file)
@@ -32,6 +32,8 @@
   */
  
 
+#include "main/macros.h"
+
 #include "st_context.h"
 #include "st_atom.h"
 #include "st_texture.h"
@@ -99,6 +101,12 @@ update_textures(struct st_context *st)
    cso_set_sampler_textures(st->cso_context,
                             st->state.num_textures,
                             st->state.sampler_texture);
+   if (st->ctx->Const.MaxVertexTextureImageUnits > 0) {
+      cso_set_vertex_sampler_textures(st->cso_context,
+                                      MIN2(st->state.num_textures,
+                                           st->ctx->Const.MaxVertexTextureImageUnits),
+                                      st->state.sampler_texture);
+   }
 }
 
 
index a6b9765452a1cb41939f9e27779769aed3903f10..da7b97d3253c78b702a7ff664e0c3ea6b30c1955 100644 (file)
@@ -229,7 +229,7 @@ accum_return(GLcontext *ctx, GLfloat value,
 {
    struct pipe_context *pipe = ctx->st->pipe;
    struct pipe_screen *screen = pipe->screen;
-   const GLubyte *colormask = ctx->Color.ColorMask;
+   const GLubyte *colormask = ctx->Color.ColorMask[0];
    enum pipe_transfer_usage usage;
    struct pipe_transfer *color_trans;
    size_t stride = acc_strb->stride;
index a22fa68299bf18806defba6c8c7c4883c7263a0d..1bdeaccda3e1d83ae4e6432a6c36166c01fb7b21 100644 (file)
@@ -169,11 +169,6 @@ make_bitmap_fragment_program(GLcontext *ctx, GLuint samplerIndex)
    stfp = (struct st_fragment_program *) p;
    stfp->Base.UsesKill = GL_TRUE;
 
-   /* No need to send this incomplete program down to hardware:
-    *
-    * st_translate_fragment_program(ctx->st, stfp, NULL);
-    */
-
    return stfp;
 }
 
@@ -526,7 +521,7 @@ reset_cache(struct st_context *st)
    struct pipe_screen *screen = pipe->screen;
    struct bitmap_cache *cache = st->bitmap.cache;
 
-   //memset(cache->buffer, 0xff, sizeof(cache->buffer));
+   /*memset(cache->buffer, 0xff, sizeof(cache->buffer));*/
    cache->empty = GL_TRUE;
 
    cache->xmin = 1000000;
index 5626e25323e89d0ace01e80eda92e328687374ae..563615ed0d10b9b982ba2e3cbabc78f749011d10 100644 (file)
@@ -64,6 +64,7 @@ st_destroy_blit(struct st_context *st)
 }
 
 
+#if FEATURE_EXT_framebuffer_blit
 static void
 st_BlitFramebuffer(GLcontext *ctx,
                    GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
@@ -206,6 +207,7 @@ st_BlitFramebuffer(GLcontext *ctx,
       }
    }
 }
+#endif /* FEATURE_EXT_framebuffer_blit */
 
 
 
index 8e09d0b9324152ebb196665c949e314d10d48adc..0102d8a6f7d42047d8e35af6e4c26eb426041b97 100644 (file)
@@ -103,6 +103,17 @@ st_bufferobj_subdata(GLcontext *ctx,
    ASSERT(size >= 0);
    ASSERT(offset + size <= obj->Size);
 
+   if (!size)
+      return;
+
+   /*
+    * According to ARB_vertex_buffer_object specification, if data is null,
+    * then the contents of the buffer object's data store is undefined. We just
+    * ignore, and leave it unchanged.
+    */
+   if (!data)
+      return;
+
    st_cond_flush_pipe_buffer_write(st_context(ctx), st_obj->buffer,
                                   offset, size, data);
 }
@@ -125,6 +136,9 @@ st_bufferobj_get_subdata(GLcontext *ctx,
    ASSERT(size >= 0);
    ASSERT(offset + size <= obj->Size);
 
+   if (!size)
+      return;
+
    st_cond_flush_pipe_buffer_read(st_context(ctx), st_obj->buffer,
                                  offset, size, data);
 }
@@ -170,15 +184,19 @@ st_bufferobj_data(GLcontext *ctx,
 
    pipe_buffer_reference( &st_obj->buffer, NULL );
 
-   st_obj->buffer = pipe_buffer_create( pipe->screen, 32, buffer_usage, size );
+   if (size != 0) {
+      st_obj->buffer = pipe_buffer_create(pipe->screen, 32, buffer_usage, size);
+
+      if (!st_obj->buffer) {
+         return GL_FALSE;
+      }
 
-   if (!st_obj->buffer) {
-      return GL_FALSE;
+      if (data)
+         st_no_flush_pipe_buffer_write(st_context(ctx), st_obj->buffer, 0,
+                                      size, data);
+      return GL_TRUE;
    }
 
-   if (data)
-      st_no_flush_pipe_buffer_write(st_context(ctx), st_obj->buffer, 0,
-                                   size, data);
    return GL_TRUE;
 }
 
@@ -218,6 +236,13 @@ st_bufferobj_map(GLcontext *ctx, GLenum target, GLenum access,
 }
 
 
+/**
+ * Dummy data whose's pointer is used for zero length ranges.
+ */
+static long
+st_bufferobj_zero_length_range = 0;
+
+
 /**
  * Called via glMapBufferRange().
  */
@@ -239,6 +264,9 @@ st_bufferobj_map_range(GLcontext *ctx, GLenum target,
    if (access & GL_MAP_FLUSH_EXPLICIT_BIT)
       flags |= PIPE_BUFFER_USAGE_FLUSH_EXPLICIT;
    
+   if (access & GL_MAP_UNSYNCHRONIZED_BIT)
+      flags |= PIPE_BUFFER_USAGE_UNSYNCHRONIZED;
+
    /* ... other flags ...
     */
 
@@ -250,14 +278,26 @@ st_bufferobj_map_range(GLcontext *ctx, GLenum target,
    assert(offset < obj->Size);
    assert(offset + length <= obj->Size);
 
-   obj->Pointer = pipe_buffer_map_range(pipe->screen, st_obj->buffer, offset, length, flags);
+   /*
+    * We go out of way here to hide the degenerate yet valid case of zero
+    * length range from the pipe driver.
+    */
+   if (!length) {
+      obj->Pointer = &st_bufferobj_zero_length_range;
+   }
+   else {
+      obj->Pointer = pipe_buffer_map_range(pipe->screen, st_obj->buffer, offset, length, flags);
+      if (obj->Pointer) {
+         obj->Pointer = (ubyte *) obj->Pointer + offset;
+      }
+   }
+   
    if (obj->Pointer) {
-      obj->Pointer = (ubyte *) obj->Pointer + offset;
       obj->Offset = offset;
       obj->Length = length;
       obj->AccessFlags = access;
    }
-   
+
    return obj->Pointer;
 }
 
@@ -275,6 +315,9 @@ st_bufferobj_flush_mapped_range(GLcontext *ctx, GLenum target,
    assert(length >= 0);
    assert(offset + length <= obj->Length);
    
+   if (!length)
+      return;
+
    pipe_buffer_flush_mapped_range(pipe->screen, st_obj->buffer, 
                                   obj->Offset + offset, length);
 }
@@ -289,7 +332,9 @@ st_bufferobj_unmap(GLcontext *ctx, GLenum target, struct gl_buffer_object *obj)
    struct pipe_context *pipe = st_context(ctx)->pipe;
    struct st_buffer_object *st_obj = st_buffer_object(obj);
 
-   pipe_buffer_unmap(pipe->screen, st_obj->buffer);
+   if(obj->Length)
+      pipe_buffer_unmap(pipe->screen, st_obj->buffer);
+
    obj->Pointer = NULL;
    obj->Offset = 0;
    obj->Length = 0;
@@ -312,6 +357,9 @@ st_copy_buffer_subdata(GLcontext *ctx,
    struct st_buffer_object *dstObj = st_buffer_object(dst);
    ubyte *srcPtr, *dstPtr;
 
+   if(!size)
+      return;
+
    /* buffer should not already be mapped */
    assert(!src->Pointer);
    assert(!dst->Pointer);
index 36510720a4c1f37d196cc19052bd702d10bf8d6e..192d765f45335a9846b3dcbf59fca93972c28857 100644 (file)
@@ -34,6 +34,7 @@
   */
 
 #include "main/glheader.h"
+#include "main/formats.h"
 #include "main/macros.h"
 #include "shader/prog_instruction.h"
 #include "st_context.h"
@@ -51,6 +52,7 @@
 #include "pipe/p_inlines.h"
 #include "pipe/p_state.h"
 #include "pipe/p_defines.h"
+#include "util/u_format.h"
 #include "util/u_pack_color.h"
 #include "util/u_simple_shaders.h"
 #include "util/u_draw_quad.h"
@@ -230,13 +232,13 @@ clear_with_quad(GLcontext *ctx,
       blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
       blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
       if (color) {
-         if (ctx->Color.ColorMask[0])
+         if (ctx->Color.ColorMask[0][0])
             blend.colormask |= PIPE_MASK_R;
-         if (ctx->Color.ColorMask[1])
+         if (ctx->Color.ColorMask[0][1])
             blend.colormask |= PIPE_MASK_G;
-         if (ctx->Color.ColorMask[2])
+         if (ctx->Color.ColorMask[0][2])
             blend.colormask |= PIPE_MASK_B;
-         if (ctx->Color.ColorMask[3])
+         if (ctx->Color.ColorMask[0][3])
             blend.colormask |= PIPE_MASK_A;
          if (st->ctx->Color.DitherFlag)
             blend.dither = 1;
@@ -298,10 +300,10 @@ check_clear_color_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
         ctx->Scissor.Height < rb->Height))
       return TRUE;
 
-   if (!ctx->Color.ColorMask[0] ||
-       !ctx->Color.ColorMask[1] ||
-       !ctx->Color.ColorMask[2] ||
-       !ctx->Color.ColorMask[3])
+   if (!ctx->Color.ColorMask[0][0] ||
+       !ctx->Color.ColorMask[0][1] ||
+       !ctx->Color.ColorMask[0][2] ||
+       !ctx->Color.ColorMask[0][3])
       return TRUE;
 
    return FALSE;
@@ -311,10 +313,14 @@ check_clear_color_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
 static INLINE GLboolean
 check_clear_depth_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
 {
-   const GLuint stencilMax = (1 << rb->StencilBits) - 1;
+   const GLuint stencilMax = 0xff;
    GLboolean maskStencil
       = (ctx->Stencil.WriteMask[0] & stencilMax) != stencilMax;
 
+   assert(rb->Format == MESA_FORMAT_S8 ||
+          rb->Format == MESA_FORMAT_Z24_S8 ||
+          rb->Format == MESA_FORMAT_S8_Z24);
+
    if (ctx->Scissor.Enabled &&
        (ctx->Scissor.X != 0 ||
         ctx->Scissor.Y != 0 ||
@@ -336,7 +342,7 @@ static INLINE GLboolean
 check_clear_depth_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
 {
    const struct st_renderbuffer *strb = st_renderbuffer(rb);
-   const GLboolean isDS = pf_is_depth_and_stencil(strb->surface->format);
+   const GLboolean isDS = util_format_is_depth_and_stencil(strb->surface->format);
 
    if (ctx->Scissor.Enabled &&
        (ctx->Scissor.X != 0 ||
@@ -360,11 +366,15 @@ static INLINE GLboolean
 check_clear_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
 {
    const struct st_renderbuffer *strb = st_renderbuffer(rb);
-   const GLboolean isDS = pf_is_depth_and_stencil(strb->surface->format);
-   const GLuint stencilMax = (1 << rb->StencilBits) - 1;
+   const GLboolean isDS = util_format_is_depth_and_stencil(strb->surface->format);
+   const GLuint stencilMax = 0xff;
    const GLboolean maskStencil
       = (ctx->Stencil.WriteMask[0] & stencilMax) != stencilMax;
 
+   assert(rb->Format == MESA_FORMAT_S8 ||
+          rb->Format == MESA_FORMAT_Z24_S8 ||
+          rb->Format == MESA_FORMAT_S8_Z24);
+
    if (maskStencil) 
       return TRUE;
 
diff --git a/src/mesa/state_tracker/st_cb_condrender.c b/src/mesa/state_tracker/st_cb_condrender.c
new file mode 100644 (file)
index 0000000..780b40c
--- /dev/null
@@ -0,0 +1,95 @@
+/**************************************************************************
+ * 
+ * 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 THE 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.
+ * 
+ **************************************************************************/
+
+
+/**
+ * glBegin/EndCondtionalRender functions
+ *
+ * \author Brian Paul
+ */
+
+
+#include "main/imports.h"
+#include "main/context.h"
+
+#include "pipe/p_context.h"
+#include "pipe/p_defines.h"
+#include "st_context.h"
+#include "st_cb_queryobj.h"
+#include "st_cb_condrender.h"
+
+
+/**
+ * Called via ctx->Driver.BeginConditionalRender()
+ */
+static void
+st_BeginConditionalRender(GLcontext *ctx, struct gl_query_object *q,
+                          GLenum mode)
+{
+   struct st_query_object *stq = st_query_object(q);
+   struct pipe_context *pipe = ctx->st->pipe;
+   uint m;
+
+   switch (mode) {
+   case GL_QUERY_WAIT:
+      m = PIPE_RENDER_COND_WAIT;
+      break;
+   case GL_QUERY_NO_WAIT:
+      m = PIPE_RENDER_COND_NO_WAIT;
+      break;
+   case GL_QUERY_BY_REGION_WAIT:
+      m = PIPE_RENDER_COND_BY_REGION_WAIT;
+      break;
+   case GL_QUERY_BY_REGION_NO_WAIT:
+      m = PIPE_RENDER_COND_BY_REGION_NO_WAIT;
+      break;
+   default:
+      assert(0 && "bad mode in st_BeginConditionalRender");
+   }
+
+   pipe->render_condition(pipe, stq->pq, m);
+}
+
+
+/**
+ * Called via ctx->Driver.BeginConditionalRender()
+ */
+static void
+st_EndConditionalRender(GLcontext *ctx, struct gl_query_object *q)
+{
+   struct pipe_context *pipe = ctx->st->pipe;
+   (void) q;
+   pipe->render_condition(pipe, NULL, 0);
+}
+
+
+
+void st_init_cond_render_functions(struct dd_function_table *functions)
+{
+   functions->BeginConditionalRender = st_BeginConditionalRender;
+   functions->EndConditionalRender = st_EndConditionalRender;
+}
diff --git a/src/mesa/state_tracker/st_cb_condrender.h b/src/mesa/state_tracker/st_cb_condrender.h
new file mode 100644 (file)
index 0000000..891f1cb
--- /dev/null
@@ -0,0 +1,35 @@
+/**************************************************************************
+ * 
+ * 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 THE 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.
+ * 
+ **************************************************************************/
+
+#ifndef ST_CB_CONDRENDER_H
+#define ST_CB_CONDRENDER_H
+
+
+extern void st_init_cond_render_functions(struct dd_function_table *functions);
+
+
+#endif
index 5c3413f9056d7fd64edd280aeb911633bdff18a6..7c664267d4e49d59936b4441f5689abe13bf8670 100644 (file)
@@ -35,6 +35,7 @@
 #include "main/bufferobj.h"
 #include "main/macros.h"
 #include "main/texformat.h"
+#include "main/texstore.h"
 #include "main/state.h"
 #include "shader/program.h"
 #include "shader/prog_parameter.h"
 #include "pipe/p_context.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_inlines.h"
+#include "tgsi/tgsi_ureg.h"
 #include "util/u_tile.h"
 #include "util/u_draw_quad.h"
+#include "util/u_format.h"
 #include "util/u_math.h"
+#include "util/u_rect.h"
 #include "shader/prog_instruction.h"
 #include "cso_cache/cso_context.h"
 
@@ -234,78 +238,41 @@ make_fragment_shader_z(struct st_context *st)
  * Create a simple vertex shader that just passes through the
  * vertex position and texcoord (and optionally, color).
  */
-static struct st_vertex_program *
-st_make_passthrough_vertex_shader(struct st_context *st, GLboolean passColor)
+static void *
+st_make_passthrough_vertex_shader(struct st_context *st, 
+                                  GLboolean passColor)
 {
-   GLcontext *ctx = st->ctx;
-   struct st_vertex_program *stvp;
-   struct gl_program *p;
-   GLuint ic = 0;
-
-   if (st->drawpix.vert_shaders[passColor])
-      return st->drawpix.vert_shaders[passColor];
-
-   /*
-    * Create shader now
-    */
-   p = ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0);
-   if (!p)
-      return NULL;
-
-   if (passColor)
-      p->NumInstructions = 4;
-   else
-      p->NumInstructions = 3;
-
-   p->Instructions = _mesa_alloc_instructions(p->NumInstructions);
-   if (!p->Instructions) {
-      ctx->Driver.DeleteProgram(ctx, p);
-      return NULL;
-   }
-   _mesa_init_instructions(p->Instructions, p->NumInstructions);
-   /* MOV result.pos, vertex.pos; */
-   p->Instructions[0].Opcode = OPCODE_MOV;
-   p->Instructions[0].DstReg.File = PROGRAM_OUTPUT;
-   p->Instructions[0].DstReg.Index = VERT_RESULT_HPOS;
-   p->Instructions[0].SrcReg[0].File = PROGRAM_INPUT;
-   p->Instructions[0].SrcReg[0].Index = VERT_ATTRIB_POS;
-   /* MOV result.texcoord0, vertex.texcoord0; */
-   p->Instructions[1].Opcode = OPCODE_MOV;
-   p->Instructions[1].DstReg.File = PROGRAM_OUTPUT;
-   p->Instructions[1].DstReg.Index = VERT_RESULT_TEX0;
-   p->Instructions[1].SrcReg[0].File = PROGRAM_INPUT;
-   p->Instructions[1].SrcReg[0].Index = VERT_ATTRIB_TEX0;
-   ic = 2;
-   if (passColor) {
-      /* MOV result.color0, vertex.color0; */
-      p->Instructions[ic].Opcode = OPCODE_MOV;
-      p->Instructions[ic].DstReg.File = PROGRAM_OUTPUT;
-      p->Instructions[ic].DstReg.Index = VERT_RESULT_COL0;
-      p->Instructions[ic].SrcReg[0].File = PROGRAM_INPUT;
-      p->Instructions[ic].SrcReg[0].Index = VERT_ATTRIB_COLOR0;
-      ic++;
-   }
-
-   /* END; */
-   p->Instructions[ic].Opcode = OPCODE_END;
-   ic++;
-
-   assert(ic == p->NumInstructions);
+   if (!st->drawpix.vert_shaders[passColor]) {
+      struct ureg_program *ureg = 
+         ureg_create( TGSI_PROCESSOR_VERTEX );
+
+      if (ureg == NULL)
+         return NULL;
+
+      /* MOV result.pos, vertex.pos; */
+      ureg_MOV(ureg, 
+               ureg_DECL_output( ureg, TGSI_SEMANTIC_POSITION, 0 ),
+               ureg_DECL_vs_input( ureg, 0 ));
+      
+      /* MOV result.texcoord0, vertex.texcoord0; */
+      ureg_MOV(ureg, 
+               ureg_DECL_output( ureg, TGSI_SEMANTIC_GENERIC, 0 ),
+               ureg_DECL_vs_input( ureg, 1 ));
+      
+      if (passColor) {
+         /* MOV result.color0, vertex.color0; */
+         ureg_MOV(ureg, 
+                  ureg_DECL_output( ureg, TGSI_SEMANTIC_COLOR, 0 ),
+                  ureg_DECL_vs_input( ureg, 2 ));
+      }
 
-   p->InputsRead = VERT_BIT_POS | VERT_BIT_TEX0;
-   p->OutputsWritten = ((1 << VERT_RESULT_TEX0) |
-                        (1 << VERT_RESULT_HPOS));
-   if (passColor) {
-      p->InputsRead |= VERT_BIT_COLOR0;
-      p->OutputsWritten |= (1 << VERT_RESULT_COL0);
+      ureg_END( ureg );
+      
+      st->drawpix.vert_shaders[passColor] = 
+         ureg_create_shader_and_destroy( ureg, st->pipe );
    }
 
-   stvp = (struct st_vertex_program *) p;
-   st_translate_vertex_program(st, stvp, NULL, NULL, NULL);
-
-   st->drawpix.vert_shaders[passColor] = stvp;
-
-   return stvp;
+   return st->drawpix.vert_shaders[passColor];
 }
 
 
@@ -338,7 +305,7 @@ make_texture(struct st_context *st,
    GLcontext *ctx = st->ctx;
    struct pipe_context *pipe = st->pipe;
    struct pipe_screen *screen = pipe->screen;
-   const struct gl_texture_format *mformat;
+   gl_format mformat;
    struct pipe_texture *pt;
    enum pipe_format pipeFormat;
    GLuint cpp;
@@ -350,7 +317,7 @@ make_texture(struct st_context *st,
    mformat = st_ChooseTextureFormat(ctx, baseFormat, format, type);
    assert(mformat);
 
-   pipeFormat = st_mesa_format_to_pipe_format(mformat->MesaFormat);
+   pipeFormat = st_mesa_format_to_pipe_format(mformat);
    assert(pipeFormat);
    cpp = st_sizeof_format(pipeFormat);
 
@@ -403,21 +370,22 @@ make_texture(struct st_context *st,
       /* map texture transfer */
       dest = screen->transfer_map(screen, transfer);
 
+
       /* Put image into texture transfer.
        * Note that the image is actually going to be upside down in
        * the texture.  We deal with that with texcoords.
        */
-      success = mformat->StoreImage(ctx, 2,           /* dims */
-                                    baseFormat,       /* baseInternalFormat */
-                                    mformat,          /* gl_texture_format */
-                                    dest,             /* dest */
-                                    0, 0, 0,          /* dstX/Y/Zoffset */
-                                    transfer->stride, /* dstRowStride, bytes */
-                                    &dstImageOffsets, /* dstImageOffsets */
-                                    width, height, 1, /* size */
-                                    format, type,     /* src format/type */
-                                    pixels,           /* data source */
-                                    unpack);
+      success = _mesa_texstore(ctx, 2,           /* dims */
+                               baseFormat,       /* baseInternalFormat */
+                               mformat,          /* gl_format */
+                               dest,             /* dest */
+                               0, 0, 0,          /* dstX/Y/Zoffset */
+                               transfer->stride, /* dstRowStride, bytes */
+                               &dstImageOffsets, /* dstImageOffsets */
+                               width, height, 1, /* size */
+                               format, type,     /* src format/type */
+                               pixels,           /* data source */
+                               unpack);
 
       /* unmap */
       screen->transfer_unmap(screen, transfer);
@@ -536,8 +504,8 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
                    GLsizei width, GLsizei height,
                    GLfloat zoomX, GLfloat zoomY,
                    struct pipe_texture *pt,
-                   struct st_vertex_program *stvp,
-                   struct st_fragment_program *stfp,
+                   void *driver_vp,
+                   void *driver_fp,
                    const GLfloat *color,
                    GLboolean invertTex)
 {
@@ -572,10 +540,10 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
    }
 
    /* fragment shader state: TEX lookup program */
-   cso_set_fragment_shader_handle(cso, stfp->driver_shader);
+   cso_set_fragment_shader_handle(cso, driver_fp);
 
    /* vertex shader state: position + texcoord pass-through */
-   cso_set_vertex_shader_handle(cso, stvp->driver_shader);
+   cso_set_vertex_shader_handle(cso, driver_vp);
 
 
    /* texture sampling state: */
@@ -618,10 +586,10 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
       struct pipe_texture *textures[2];
       textures[0] = pt;
       textures[1] = st->pixel_xfer.pixelmap_texture;
-      pipe->set_sampler_textures(pipe, 2, textures);
+      pipe->set_fragment_sampler_textures(pipe, 2, textures);
    }
    else {
-      pipe->set_sampler_textures(pipe, 1, &pt);
+      pipe->set_fragment_sampler_textures(pipe, 1, &pt);
    }
 
    /* Compute window coords (y=0=bottom) with pixel zoom.
@@ -634,8 +602,8 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
    y1 = y + height * ctx->Pixel.ZoomY;
 
    draw_quad(ctx, x0, y0, z, x1, y1, color, invertTex,
-            (GLfloat) width / pt->width[0],
-            (GLfloat) height / pt->height[0]);
+            (GLfloat) width / pt->width0,
+            (GLfloat) height / pt->height0);
 
    /* restore state */
    cso_restore_rasterizer(cso);
@@ -662,6 +630,15 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
    const GLboolean zoom = ctx->Pixel.ZoomX != 1.0 || ctx->Pixel.ZoomY != 1.0;
    GLint skipPixels;
    ubyte *stmap;
+   struct gl_pixelstore_attrib clippedUnpack = *unpack;
+
+   if (!zoom) {
+      if (!_mesa_clip_drawpixels(ctx, &x, &y, &width, &height,
+                                 &clippedUnpack)) {
+         /* totally clipped */
+         return;
+      }
+   }
 
    strb = st_renderbuffer(ctx->DrawBuffer->
                           Attachment[BUFFER_STENCIL].Renderbuffer);
@@ -671,7 +648,7 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
    }
 
    if(format != GL_DEPTH_STENCIL && 
-      pf_get_component_bits( strb->format, PIPE_FORMAT_COMP_Z ) != 0)
+      util_format_get_component_bits(strb->format, UTIL_FORMAT_COLORSPACE_ZS, 0) != 0)
       usage = PIPE_TRANSFER_READ_WRITE;
    else
       usage = PIPE_TRANSFER_WRITE;
@@ -682,7 +659,7 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
 
    stmap = screen->transfer_map(screen, pt);
 
-   pixels = _mesa_map_pbo_source(ctx, unpack, pixels);
+   pixels = _mesa_map_pbo_source(ctx, &clippedUnpack, pixels);
    assert(pixels);
 
    /* if width > MAX_WIDTH, have to process image in chunks */
@@ -695,17 +672,18 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
          GLubyte sValues[MAX_WIDTH];
          GLuint zValues[MAX_WIDTH];
          GLenum destType = GL_UNSIGNED_BYTE;
-         const GLvoid *source = _mesa_image_address2d(unpack, pixels,
+         const GLvoid *source = _mesa_image_address2d(&clippedUnpack, pixels,
                                                       width, height,
                                                       format, type,
                                                       row, skipPixels);
          _mesa_unpack_stencil_span(ctx, spanWidth, destType, sValues,
-                                   type, source, unpack,
+                                   type, source, &clippedUnpack,
                                    ctx->_ImageTransferState);
 
          if (format == GL_DEPTH_STENCIL) {
             _mesa_unpack_depth_span(ctx, spanWidth, GL_UNSIGNED_INT, zValues,
-                                    (1 << 24) - 1, type, source, unpack);
+                                    (1 << 24) - 1, type, source,
+                                    &clippedUnpack);
          }
 
          if (zoom) {
@@ -724,7 +702,7 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
             }
 
             /* now pack the stencil (and Z) values in the dest format */
-            switch (pt->format) {
+            switch (pt->texture->format) {
             case PIPE_FORMAT_S8_UNORM:
                {
                   ubyte *dest = stmap + spanY * pt->stride + spanX;
@@ -776,7 +754,7 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
       skipPixels += spanWidth;
    }
 
-   _mesa_unmap_pbo_source(ctx, unpack);
+   _mesa_unmap_pbo_source(ctx, &clippedUnpack);
 
    /* unmap the stencil buffer */
    screen->transfer_unmap(screen, pt);
@@ -793,7 +771,7 @@ st_DrawPixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
               const struct gl_pixelstore_attrib *unpack, const GLvoid *pixels)
 {
    struct st_fragment_program *stfp;
-   struct st_vertex_program *stvp;
+   void *driver_vp;
    struct st_context *st = st_context(ctx);
    struct pipe_surface *ps;
    const GLfloat *color;
@@ -813,13 +791,13 @@ st_DrawPixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
    if (format == GL_DEPTH_COMPONENT) {
       ps = st->state.framebuffer.zsbuf;
       stfp = make_fragment_shader_z(st);
-      stvp = st_make_passthrough_vertex_shader(st, GL_TRUE);
+      driver_vp = st_make_passthrough_vertex_shader(st, GL_TRUE);
       color = ctx->Current.RasterColor;
    }
    else {
       ps = st->state.framebuffer.cbufs[0];
       stfp = combined_drawpix_fragment_program(ctx);
-      stvp = st_make_passthrough_vertex_shader(st, GL_FALSE);
+      driver_vp = st_make_passthrough_vertex_shader(st, GL_FALSE);
       color = NULL;
    }
 
@@ -830,7 +808,10 @@ st_DrawPixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
       if (pt) {
          draw_textured_quad(ctx, x, y, ctx->Current.RasterPos[2],
                             width, height, ctx->Pixel.ZoomX, ctx->Pixel.ZoomY,
-                            pt, stvp, stfp, color, GL_FALSE);
+                            pt, 
+                            driver_vp, 
+                            stfp->driver_shader,
+                            color, GL_FALSE);
          pipe_texture_reference(&pt, NULL);
       }
    }
@@ -862,7 +843,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
                           GL_STENCIL_INDEX, GL_UNSIGNED_BYTE,
                           &ctx->DefaultPacking, buffer);
 
-   if(pf_get_component_bits( rbDraw->format, PIPE_FORMAT_COMP_Z ) != 0)
+   if(util_format_get_component_bits(rbDraw->format, UTIL_FORMAT_COLORSPACE_ZS, 0) != 0)
       usage = PIPE_TRANSFER_READ_WRITE;
    else
       usage = PIPE_TRANSFER_WRITE;
@@ -876,8 +857,8 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
                                           usage, dstx, dsty,
                                           width, height);
 
-   assert(ptDraw->block.width == 1);
-   assert(ptDraw->block.height == 1);
+   assert(util_format_get_blockwidth(ptDraw->texture->format) == 1);
+   assert(util_format_get_blockheight(ptDraw->texture->format) == 1);
 
    /* map the stencil buffer */
    drawMap = screen->transfer_map(screen, ptDraw);
@@ -898,7 +879,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
       dst = drawMap + y * ptDraw->stride;
       src = buffer + i * width;
 
-      switch (ptDraw->format) {
+      switch (ptDraw->texture->format) {
       case PIPE_FORMAT_S8Z24_UNORM:
          {
             uint *dst4 = (uint *) dst;
@@ -947,7 +928,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
    struct pipe_context *pipe = st->pipe;
    struct pipe_screen *screen = pipe->screen;
    struct st_renderbuffer *rbRead;
-   struct st_vertex_program *stvp;
+   void *driver_vp;
    struct st_fragment_program *stfp;
    struct pipe_texture *pt;
    GLfloat *color;
@@ -996,14 +977,14 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
       rbRead = st_get_color_read_renderbuffer(ctx);
       color = NULL;
       stfp = combined_drawpix_fragment_program(ctx);
-      stvp = st_make_passthrough_vertex_shader(st, GL_FALSE);
+      driver_vp = st_make_passthrough_vertex_shader(st, GL_FALSE);
    }
    else {
       assert(type == GL_DEPTH);
       rbRead = st_renderbuffer(ctx->ReadBuffer->_DepthBuffer);
       color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
       stfp = make_fragment_shader_z(st);
-      stvp = st_make_passthrough_vertex_shader(st, GL_TRUE);
+      driver_vp = st_make_passthrough_vertex_shader(st, GL_TRUE);
    }
 
    srcFormat = rbRead->texture->format;
@@ -1075,11 +1056,19 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
                                        PIPE_BUFFER_USAGE_GPU_READ);
       struct pipe_surface *psTex = screen->get_tex_surface(screen, pt, 0, 0, 0, 
                                       PIPE_BUFFER_USAGE_GPU_WRITE );
-      pipe->surface_copy(pipe,
-                        psTex, /* dest */
-                        0, 0, /* destx/y */
-                        psRead,
-                        srcx, srcy, width, height);
+      if (pipe->surface_copy) {
+         pipe->surface_copy(pipe,
+                            psTex, /* dest */
+                            0, 0, /* destx/y */
+                            psRead,
+                            srcx, srcy, width, height);
+      } else {
+         util_surface_copy(pipe, FALSE,
+                           psTex,
+                           0, 0,
+                           psRead,
+                           srcx, srcy, width, height);
+      }
       pipe_surface_reference(&psRead, NULL); 
       pipe_surface_reference(&psTex, NULL);
    }
@@ -1095,7 +1084,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
       if (ST_DEBUG & DEBUG_FALLBACK)
          debug_printf("%s: fallback processing\n", __FUNCTION__);
 
-      if (type == GL_DEPTH && pf_is_depth_and_stencil(pt->format))
+      if (type == GL_DEPTH && util_format_is_depth_and_stencil(pt->format))
          transfer_usage = PIPE_TRANSFER_READ_WRITE;
       else
          transfer_usage = PIPE_TRANSFER_WRITE;
@@ -1127,7 +1116,10 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
    /* draw textured quad */
    draw_textured_quad(ctx, dstx, dsty, ctx->Current.RasterPos[2],
                       width, height, ctx->Pixel.ZoomX, ctx->Pixel.ZoomY,
-                      pt, stvp, stfp, color, GL_TRUE);
+                      pt, 
+                      driver_vp, 
+                      stfp->driver_shader,
+                      color, GL_TRUE);
 
    pipe_texture_reference(&pt, NULL);
 }
index 864f5d3ca3f2617092d3489da2d4c1ff3ef4f671..45ce34a85f7e58ba46bc08f88459563dfff53cd6 100644 (file)
@@ -49,6 +49,8 @@
 #include "st_public.h"
 #include "st_texture.h"
 
+#include "util/u_format.h"
+#include "util/u_rect.h"
 
 
 /**
@@ -64,13 +66,7 @@ init_renderbuffer_bits(struct st_renderbuffer *strb,
       assert( 0 );
    }
 
-   strb->Base._ActualFormat = info.base_format;
-   strb->Base.RedBits = info.red_bits;
-   strb->Base.GreenBits = info.green_bits;
-   strb->Base.BlueBits = info.blue_bits;
-   strb->Base.AlphaBits = info.alpha_bits;
-   strb->Base.DepthBits = info.depth_bits;
-   strb->Base.StencilBits = info.stencil_bits;
+   strb->Base.Format = info.mesa_format;
    strb->Base.DataType = st_format_datatype(pipeFormat);
 
    return info.size;
@@ -103,16 +99,14 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
    strb->defined = GL_FALSE;  /* undefined contents now */
 
    if(strb->software) {
-      struct pipe_format_block block;
       size_t size;
       
       _mesa_free(strb->data);
 
       assert(strb->format != PIPE_FORMAT_NONE);
-      pf_get_block(strb->format, &block);
       
-      strb->stride = pf_get_stride(&block, width);
-      size = pf_get_2d_size(&block, strb->stride, height);
+      strb->stride = util_format_get_stride(strb->format, width);
+      size = util_format_get_2d_size(strb->format, strb->stride, height);
       
       strb->data = _mesa_malloc(size);
       
@@ -132,13 +126,12 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
       memset(&template, 0, sizeof(template));
       template.target = PIPE_TEXTURE_2D;
       template.format = format;
-      pf_get_block(format, &template.block);
-      template.width[0] = width;
-      template.height[0] = height;
-      template.depth[0] = 1;
+      template.width0 = width;
+      template.height0 = height;
+      template.depth0 = 1;
       template.last_level = 0;
       template.nr_samples = rb->NumSamples;
-      if (pf_is_depth_stencil(format)) {
+      if (util_format_is_depth_or_stencil(format)) {
          template.tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL;
       }
       else {
@@ -270,30 +263,24 @@ st_new_renderbuffer_fb(enum pipe_format format, int samples, boolean sw)
    case PIPE_FORMAT_A4R4G4B4_UNORM:
    case PIPE_FORMAT_R5G6B5_UNORM:
       strb->Base.InternalFormat = GL_RGBA;
-      strb->Base._BaseFormat = GL_RGBA;
       break;
    case PIPE_FORMAT_Z16_UNORM:
       strb->Base.InternalFormat = GL_DEPTH_COMPONENT16;
-      strb->Base._BaseFormat = GL_DEPTH_COMPONENT;
       break;
    case PIPE_FORMAT_Z32_UNORM:
       strb->Base.InternalFormat = GL_DEPTH_COMPONENT32;
-      strb->Base._BaseFormat = GL_DEPTH_COMPONENT;
       break;
    case PIPE_FORMAT_S8Z24_UNORM:
    case PIPE_FORMAT_Z24S8_UNORM:
    case PIPE_FORMAT_X8Z24_UNORM:
    case PIPE_FORMAT_Z24X8_UNORM:
       strb->Base.InternalFormat = GL_DEPTH24_STENCIL8_EXT;
-      strb->Base._BaseFormat = GL_DEPTH_STENCIL_EXT;
       break;
    case PIPE_FORMAT_S8_UNORM:
       strb->Base.InternalFormat = GL_STENCIL_INDEX8_EXT;
-      strb->Base._BaseFormat = GL_STENCIL_INDEX;
       break;
    case PIPE_FORMAT_R16G16B16A16_SNORM:
       strb->Base.InternalFormat = GL_RGBA16;
-      strb->Base._BaseFormat = GL_RGBA;
       break;
    default:
       _mesa_problem(NULL,
@@ -387,7 +374,7 @@ st_render_texture(GLcontext *ctx,
    rb->_BaseFormat = texImage->_BaseFormat;
    /*printf("***** render to texture level %d: %d x %d\n", att->TextureLevel, rb->Width, rb->Height);*/
 
-   /*printf("***** pipe texture %d x %d\n", pt->width[0], pt->height[0]);*/
+   /*printf("***** pipe texture %d x %d\n", pt->width0, pt->height0);*/
 
    pipe_texture_reference( &strb->texture, pt );
 
@@ -538,10 +525,17 @@ copy_back_to_front(struct st_context *st,
    (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);
+      if (st->pipe->surface_copy) {
+         st->pipe->surface_copy(st->pipe,
+                                surf_front, 0, 0,  /* dest */
+                                surf_back, 0, 0,   /* src */
+                                fb->Width, fb->Height);
+      } else {
+         util_surface_copy(st->pipe, FALSE,
+                           surf_front, 0, 0,
+                           surf_back, 0, 0,
+                           fb->Width, fb->Height);
+      }
    }
 }
 
diff --git a/src/mesa/state_tracker/st_cb_get.c b/src/mesa/state_tracker/st_cb_get.c
deleted file mode 100644 (file)
index e7d7f03..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/**************************************************************************
- * 
- * 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.
- * 
- **************************************************************************/
-
-
-/**
- * glGet functions
- *
- * \author Brian Paul
- */
-
-#include "main/imports.h"
-#include "main/context.h"
-
-#include "pipe/p_defines.h"
-
-#include "st_cb_fbo.h"
-#include "st_cb_get.h"
-
-
-
-/**
- * Examine the current color read buffer format to determine
- * which GL pixel format/type combo is the best match.
- */
-static void
-get_preferred_read_format_type(GLcontext *ctx, GLint *format, GLint *type)
-{
-   struct gl_framebuffer *fb = ctx->ReadBuffer;
-   struct st_renderbuffer *strb = st_renderbuffer(fb->_ColorReadBuffer);
-
-   /* defaults */
-   *format = ctx->Const.ColorReadFormat;
-   *type = ctx->Const.ColorReadType;
-
-   if (strb) {
-      /* XXX could add more cases here... */
-      if (strb->format == PIPE_FORMAT_A8R8G8B8_UNORM) {
-         *format = GL_BGRA;
-         if (_mesa_little_endian())
-            *type = GL_UNSIGNED_INT_8_8_8_8_REV;
-         else
-            *type = GL_UNSIGNED_INT_8_8_8_8;
-      }
-   }
-}
-
-
-/**
- * We only intercept the OES preferred ReadPixels format/type.
- * Everything else goes to the default _mesa_GetIntegerv.
- */
-static GLboolean 
-st_GetIntegerv(GLcontext *ctx, GLenum pname, GLint *params)
-{
-   GLint dummy;
-
-   switch (pname) {
-   case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES:
-      get_preferred_read_format_type(ctx, &dummy, params);
-      return GL_TRUE;
-   case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES:
-      get_preferred_read_format_type(ctx, params, &dummy);
-      return GL_TRUE;
-   default:
-      return GL_FALSE;
-   }
-}
-
-
-void st_init_get_functions(struct dd_function_table *functions)
-{
-   functions->GetIntegerv = st_GetIntegerv;
-}
diff --git a/src/mesa/state_tracker/st_cb_get.h b/src/mesa/state_tracker/st_cb_get.h
deleted file mode 100644 (file)
index 8e9f3e9..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/**************************************************************************
- * 
- * 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 ST_CB_GET_H
-#define ST_CB_GET_H
-
-
-extern void
-st_init_get_functions(struct dd_function_table *functions);
-
-
-#endif
index b2d5c39a3a0d139676432de96616e482d7308e57..8c276f8128edb2046d2d02346a46112826ac803f 100644 (file)
@@ -138,24 +138,7 @@ st_delete_program(GLcontext *ctx, struct gl_program *prog)
    case GL_VERTEX_PROGRAM_ARB:
       {
          struct st_vertex_program *stvp = (struct st_vertex_program *) prog;
-
-         if (stvp->driver_shader) {
-            cso_delete_vertex_shader(st->cso_context, stvp->driver_shader);
-            stvp->driver_shader = NULL;
-         }
-
-         if (stvp->draw_shader) {
-#if FEATURE_feedback || FEATURE_drawpix
-            /* this would only have been allocated for the RasterPos path */
-            draw_delete_vertex_shader(st->draw, stvp->draw_shader);
-            stvp->draw_shader = NULL;
-#endif
-         }
-
-         if (stvp->state.tokens) {
-            st_free_tokens(stvp->state.tokens);
-            stvp->state.tokens = NULL;
-         }
+         st_vp_release_varients( st, stvp );
       }
       break;
    case GL_FRAGMENT_PROGRAM_ARB:
@@ -177,8 +160,6 @@ st_delete_program(GLcontext *ctx, struct gl_program *prog)
             _mesa_reference_program(ctx, &prg, NULL);
             stfp->bitmap_program = NULL;
          }
-
-         st_free_translated_vertex_programs(st, stfp->vertex_programs);
       }
       break;
    default:
@@ -219,8 +200,6 @@ static void st_program_string_notify( GLcontext *ctx,
          stfp->state.tokens = NULL;
       }
 
-      stfp->param_state = stfp->Base.Base.Parameters->StateFlags;
-
       if (st->fp == stfp)
         st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM;
    }
@@ -229,25 +208,7 @@ static void st_program_string_notify( GLcontext *ctx,
 
       stvp->serialNo++;
 
-      if (stvp->driver_shader) {
-         cso_delete_vertex_shader(st->cso_context, stvp->driver_shader);
-         stvp->driver_shader = NULL;
-      }
-
-      if (stvp->draw_shader) {
-#if FEATURE_feedback || FEATURE_drawpix
-         /* this would only have been allocated for the RasterPos path */
-         draw_delete_vertex_shader(st->draw, stvp->draw_shader);
-         stvp->draw_shader = NULL;
-#endif
-      }
-
-      if (stvp->state.tokens) {
-         st_free_tokens(stvp->state.tokens);
-         stvp->state.tokens = NULL;
-      }
-
-      stvp->param_state = stvp->Base.Base.Parameters->StateFlags;
+      st_vp_release_varients( st, stvp );
 
       if (st->vp == stvp)
         st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
index dcf4c38eb615d22f6f66bfcbecc253041edb9f34..10629e92254453e2f2f5a6049195ae1a5a1cce59 100644 (file)
 #include "st_public.h"
 
 
-struct st_query_object
-{
-   struct gl_query_object base;
-   struct pipe_query *pq;
-};
-
-
-/**
- * Cast wrapper
- */
-static struct st_query_object *
-st_query_object(struct gl_query_object *q)
-{
-   return (struct st_query_object *) q;
-}
-
-
 static struct gl_query_object *
 st_NewQueryObject(GLcontext *ctx, GLuint id)
 {
index 9220a212b60c7af3cde7195fd8328622938539a6..fa256b71824606ca0bdd8086c43b2b0865789b08 100644 (file)
 #define ST_CB_QUERYOBJ_H
 
 
+/**
+ * Subclass of gl_query_object
+ */
+struct st_query_object
+{
+   struct gl_query_object base;
+   struct pipe_query *pq;
+};
+
+
+/**
+ * Cast wrapper
+ */
+static INLINE struct st_query_object *
+st_query_object(struct gl_query_object *q)
+{
+   return (struct st_query_object *) q;
+}
+
+
+
 extern void
 st_init_query_functions(struct dd_function_table *functions);
 
index 772bb3bb69e9184e320dcdcbe3e48ca788be4be9..6fa7bb64f2eb2cf16ce906ef58faebccae264329 100644 (file)
@@ -103,7 +103,7 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
       }
 
       /* get stencil (and Z) values */
-      switch (pt->format) {
+      switch (pt->texture->format) {
       case PIPE_FORMAT_S8_UNORM:
          {
             const ubyte *src = stmap + srcY * pt->stride;
@@ -243,7 +243,7 @@ st_fast_readpixels(GLcontext *ctx, struct st_renderbuffer *strb,
       GLint row, col, dy, dstStride;
 
       if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) {
-         y = strb->texture->height[0] - y - height;
+         y = strb->texture->height0 - y - height;
       }
 
       trans = st_cond_flush_get_tex_transfer(st_context(ctx), strb->texture,
@@ -431,8 +431,8 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
       const GLint dstStride = _mesa_image_row_stride(&clippedPacking, width,
                                                      format, type);
 
-      if (trans->format == PIPE_FORMAT_S8Z24_UNORM ||
-          trans->format == PIPE_FORMAT_X8Z24_UNORM) {
+      if (trans->texture->format == PIPE_FORMAT_S8Z24_UNORM ||
+          trans->texture->format == PIPE_FORMAT_X8Z24_UNORM) {
          if (format == GL_DEPTH_COMPONENT) {
             for (i = 0; i < height; i++) {
                GLuint ztemp[MAX_WIDTH];
@@ -463,8 +463,8 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
             }
          }
       }
-      else if (trans->format == PIPE_FORMAT_Z24S8_UNORM ||
-               trans->format == PIPE_FORMAT_Z24X8_UNORM) {
+      else if (trans->texture->format == PIPE_FORMAT_Z24S8_UNORM ||
+               trans->texture->format == PIPE_FORMAT_Z24X8_UNORM) {
          if (format == GL_DEPTH_COMPONENT) {
             for (i = 0; i < height; i++) {
                GLuint ztemp[MAX_WIDTH];
@@ -490,7 +490,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
             }
          }
       }
-      else if (trans->format == PIPE_FORMAT_Z16_UNORM) {
+      else if (trans->texture->format == PIPE_FORMAT_Z16_UNORM) {
          for (i = 0; i < height; i++) {
             GLushort ztemp[MAX_WIDTH];
             GLfloat zfloat[MAX_WIDTH];
@@ -505,7 +505,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
             dst += dstStride;
          }
       }
-      else if (trans->format == PIPE_FORMAT_Z32_UNORM) {
+      else if (trans->texture->format == PIPE_FORMAT_Z32_UNORM) {
          for (i = 0; i < height; i++) {
             GLuint ztemp[MAX_WIDTH];
             GLfloat zfloat[MAX_WIDTH];
index b9437871063695afb264e6278ec13a2be72eeb2c..0cec23f2b3cd728988a56fa0a618ab9bf2cd4233 100644 (file)
 #include "main/convolve.h"
 #endif
 #include "main/enums.h"
+#include "main/formats.h"
 #include "main/image.h"
 #include "main/imports.h"
 #include "main/macros.h"
 #include "main/mipmap.h"
 #include "main/pixel.h"
 #include "main/texcompress.h"
+#include "main/texfetch.h"
 #include "main/texformat.h"
 #include "main/texgetimage.h"
 #include "main/teximage.h"
@@ -60,6 +62,7 @@
 #include "pipe/p_shader_tokens.h"
 #include "util/u_tile.h"
 #include "util/u_blit.h"
+#include "util/u_format.h"
 #include "util/u_surface.h"
 #include "util/u_math.h"
 
@@ -91,51 +94,6 @@ gl_target_to_pipe(GLenum target)
 }
 
 
-/**
- * Return nominal bytes per texel for a compressed format, 0 for non-compressed
- * format.
- */
-static GLuint
-compressed_num_bytes(GLuint mesaFormat)
-{
-   switch(mesaFormat) {
-#if FEATURE_texture_fxt1
-   case MESA_FORMAT_RGB_FXT1:
-   case MESA_FORMAT_RGBA_FXT1:
-#endif
-#if FEATURE_texture_s3tc
-   case MESA_FORMAT_RGB_DXT1:
-   case MESA_FORMAT_RGBA_DXT1:
-      return 2;
-   case MESA_FORMAT_RGBA_DXT3:
-   case MESA_FORMAT_RGBA_DXT5:
-      return 4;
-#endif
-   default:
-      return 0;
-   }
-}
-
-
-static GLboolean
-is_compressed_mesa_format(const struct gl_texture_format *format)
-{
-   switch (format->MesaFormat) {
-   case MESA_FORMAT_RGB_DXT1:
-   case MESA_FORMAT_RGBA_DXT1:
-   case MESA_FORMAT_RGBA_DXT3:
-   case MESA_FORMAT_RGBA_DXT5:
-   case MESA_FORMAT_SRGB_DXT1:
-   case MESA_FORMAT_SRGBA_DXT1:
-   case MESA_FORMAT_SRGBA_DXT3:
-   case MESA_FORMAT_SRGBA_DXT5:
-      return GL_TRUE;
-   default:
-      return GL_FALSE;
-   }
-}
-
-
 /** called via ctx->Driver.NewTextureImage() */
 static struct gl_texture_image *
 st_NewTextureImage(GLcontext * ctx)
@@ -247,7 +205,7 @@ static GLuint
 default_usage(enum pipe_format fmt)
 {
    GLuint usage = PIPE_TEXTURE_USAGE_SAMPLER;
-   if (pf_is_depth_stencil(fmt))
+   if (util_format_is_depth_or_stencil(fmt))
       usage |= PIPE_TEXTURE_USAGE_DEPTH_STENCIL;
    else
       usage |= PIPE_TEXTURE_USAGE_RENDER_TARGET;
@@ -342,7 +300,7 @@ guess_and_alloc_texture(struct st_context *st,
       lastLevel = firstLevel + MAX2(MAX2(l2width, l2height), l2depth);
    }
 
-   fmt = st_mesa_format_to_pipe_format(stImage->base.TexFormat->MesaFormat);
+   fmt = st_mesa_format_to_pipe_format(stImage->base.TexFormat);
 
    usage = default_usage(fmt);
 
@@ -415,14 +373,13 @@ compress_with_blit(GLcontext * ctx,
    const GLuint dstImageOffsets[1] = {0};
    struct st_texture_image *stImage = st_texture_image(texImage);
    struct pipe_screen *screen = ctx->st->pipe->screen;
-   const struct gl_texture_format *mesa_format;
+   gl_format mesa_format;
    struct pipe_texture templ;
    struct pipe_texture *src_tex;
    struct pipe_surface *dst_surface;
    struct pipe_transfer *tex_xfer;
    void *map;
 
-
    if (!stImage->pt) {
       /* XXX: Can this happen? Should we assert? */
       return GL_FALSE;
@@ -448,11 +405,10 @@ compress_with_blit(GLcontext * ctx,
     */
    memset(&templ, 0, sizeof(templ));
    templ.target = PIPE_TEXTURE_2D;
-   templ.format = st_mesa_format_to_pipe_format(mesa_format->MesaFormat);
-   pf_get_block(templ.format, &templ.block);
-   templ.width[0] = width;
-   templ.height[0] = height;
-   templ.depth[0] = 1;
+   templ.format = st_mesa_format_to_pipe_format(mesa_format);
+   templ.width0 = width;
+   templ.height0 = height;
+   templ.depth0 = 1;
    templ.last_level = 0;
    templ.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER;
    src_tex = screen->texture_create(screen, &templ);
@@ -468,15 +424,15 @@ compress_with_blit(GLcontext * ctx,
                                             0, 0, width, height); /* x, y, w, h */
    map = screen->transfer_map(screen, tex_xfer);
 
-   mesa_format->StoreImage(ctx, 2, GL_RGBA, mesa_format,
-                           map,              /* dest ptr */
-                           0, 0, 0,          /* dest x/y/z offset */
-                           tex_xfer->stride, /* dest row stride (bytes) */
-                           dstImageOffsets,  /* image offsets (for 3D only) */
-                           width, height, 1, /* size */
-                           format, type,     /* source format/type */
-                           pixels,           /* source data */
-                           unpack);          /* source data packing */
+   _mesa_texstore(ctx, 2, GL_RGBA, mesa_format,
+                  map,              /* dest ptr */
+                  0, 0, 0,          /* dest x/y/z offset */
+                  tex_xfer->stride, /* dest row stride (bytes) */
+                  dstImageOffsets,  /* image offsets (for 3D only) */
+                  width, height, 1, /* size */
+                  format, type,     /* source format/type */
+                  pixels,           /* source data */
+                  unpack);          /* source data packing */
 
    screen->transfer_unmap(screen, tex_xfer);
    screen->tex_transfer_destroy(tex_xfer);
@@ -558,23 +514,14 @@ st_TexImage(GLcontext * ctx,
    }
 #endif
 
-   /* choose the texture format */
-   texImage->TexFormat = st_ChooseTextureFormat(ctx, internalFormat,
-                                                format, type);
-
    _mesa_set_fetch_functions(texImage, dims);
 
-   if (texImage->TexFormat->TexelBytes == 0) {
+   if (_mesa_is_format_compressed(texImage->TexFormat)) {
       /* must be a compressed format */
       texelBytes = 0;
-      texImage->IsCompressed = GL_TRUE;
-      texImage->CompressedSize =
-        ctx->Driver.CompressedTextureSize(ctx, texImage->Width,
-                                          texImage->Height, texImage->Depth,
-                                          texImage->TexFormat->MesaFormat);
    }
    else {
-      texelBytes = texImage->TexFormat->TexelBytes;
+      texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
       
       /* Minimum pitch of 32 bytes */
       if (postConvWidth * texelBytes < 32) {
@@ -671,7 +618,7 @@ st_TexImage(GLcontext * ctx,
     */
    if (!compressed_src &&
        !ctx->Mesa_DXTn &&
-       is_compressed_mesa_format(texImage->TexFormat) &&
+       _mesa_is_format_compressed(texImage->TexFormat) &&
        screen->is_format_supported(screen,
                                    stImage->pt->format,
                                    stImage->pt->target,
@@ -687,7 +634,7 @@ st_TexImage(GLcontext * ctx,
 
    if (stImage->pt) {
       if (format == GL_DEPTH_COMPONENT &&
-          pf_is_depth_and_stencil(stImage->pt->format))
+          util_format_is_depth_and_stencil(stImage->pt->format))
          transfer_usage = PIPE_TRANSFER_READ_WRITE;
       else
          transfer_usage = PIPE_TRANSFER_WRITE;
@@ -701,10 +648,12 @@ st_TexImage(GLcontext * ctx,
    }
    else {
       /* Allocate regular memory and store the image there temporarily.   */
-      if (texImage->IsCompressed) {
-         sizeInBytes = texImage->CompressedSize;
-         dstRowStride =
-            _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat, width);
+      if (_mesa_is_format_compressed(texImage->TexFormat)) {
+         sizeInBytes = _mesa_format_image_size(texImage->TexFormat,
+                                               texImage->Width,
+                                               texImage->Height,
+                                               texImage->Depth);
+         dstRowStride = _mesa_format_row_stride(texImage->TexFormat, width);
          assert(dims != 3);
       }
       else {
@@ -740,15 +689,15 @@ st_TexImage(GLcontext * ctx,
       const GLubyte *src = (const GLubyte *) pixels;
 
       for (i = 0; i < depth; i++) {
-        if (!texImage->TexFormat->StoreImage(ctx, dims, 
-                                             texImage->_BaseFormat, 
-                                             texImage->TexFormat, 
-                                             texImage->Data,
-                                             0, 0, 0, /* dstX/Y/Zoffset */
-                                             dstRowStride,
-                                             texImage->ImageOffsets,
-                                             width, height, 1,
-                                             format, type, src, unpack)) {
+        if (!_mesa_texstore(ctx, dims, 
+                             texImage->_BaseFormat, 
+                             texImage->TexFormat, 
+                             texImage->Data,
+                             0, 0, 0, /* dstX/Y/Zoffset */
+                             dstRowStride,
+                             texImage->ImageOffsets,
+                             width, height, 1,
+                             format, type, src, unpack)) {
            _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
         }
 
@@ -884,7 +833,7 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level,
    /* copy/pack data into user buffer */
    if (st_equal_formats(stImage->pt->format, format, type)) {
       /* memcpy */
-      const uint bytesPerRow = width * pf_get_size(stImage->pt->format);
+      const uint bytesPerRow = width * util_format_get_blocksize(stImage->pt->format);
       ubyte *map = screen->transfer_map(screen, tex_xfer);
       GLuint row;
       for (row = 0; row < height; row++) {
@@ -941,7 +890,7 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level,
    GLubyte *dest;
 
    if (stImage->pt &&
-       pf_is_compressed(stImage->pt->format) &&
+       util_format_is_compressed(stImage->pt->format) &&
        !compressed_dst) {
       /* Need to decompress the texture.
        * We'll do this by rendering a textured quad.
@@ -966,7 +915,7 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level,
                                             PIPE_TRANSFER_READ, 0, 0,
                                             stImage->base.Width,
                                             stImage->base.Height);
-      texImage->RowStride = stImage->transfer->stride / stImage->pt->block.size;
+      texImage->RowStride = stImage->transfer->stride / util_format_get_blocksize(stImage->pt->format);
    }
    else {
       /* Otherwise, the image should actually be stored in
@@ -1072,7 +1021,7 @@ st_TexSubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level,
    /* See if we can do texture compression with a blit/render.
     */
    if (!ctx->Mesa_DXTn &&
-       is_compressed_mesa_format(texImage->TexFormat) &&
+       _mesa_is_format_compressed(texImage->TexFormat) &&
        screen->is_format_supported(screen,
                                    stImage->pt->format,
                                    stImage->pt->target,
@@ -1092,7 +1041,7 @@ st_TexSubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level,
       unsigned face = _mesa_tex_target_to_face(target);
 
       if (format == GL_DEPTH_COMPONENT &&
-          pf_is_depth_and_stencil(stImage->pt->format))
+          util_format_is_depth_and_stencil(stImage->pt->format))
          transfer_usage = PIPE_TRANSFER_READ_WRITE;
       else
          transfer_usage = PIPE_TRANSFER_WRITE;
@@ -1114,14 +1063,14 @@ st_TexSubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level,
    dstRowStride = stImage->transfer->stride;
 
    for (i = 0; i < depth; i++) {
-      if (!texImage->TexFormat->StoreImage(ctx, dims, texImage->_BaseFormat,
-                                          texImage->TexFormat,
-                                          texImage->Data,
-                                          0, 0, 0,
-                                          dstRowStride,
-                                          texImage->ImageOffsets,
-                                          width, height, 1,
-                                          format, type, src, packing)) {
+      if (!_mesa_texstore(ctx, dims, texImage->_BaseFormat,
+                          texImage->TexFormat,
+                          texImage->Data,
+                          0, 0, 0,
+                          dstRowStride,
+                          texImage->ImageOffsets,
+                          width, height, 1,
+                          format, type, src, packing)) {
         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage");
       }
 
@@ -1141,7 +1090,7 @@ st_TexSubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level,
 done:
    _mesa_unmap_teximage_pbo(ctx, packing);
 
-   if (stImage->pt) {
+   if (stImage->pt && texImage->Data) {
       st_texture_image_unmap(ctx->st, stImage);
       texImage->Data = NULL;
    }
@@ -1214,10 +1163,10 @@ st_CompressedTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
                            struct gl_texture_image *texImage)
 {
    struct st_texture_image *stImage = st_texture_image(texImage);
-   struct pipe_format_block block;
    int srcBlockStride;
    int dstBlockStride;
    int y;
+   enum pipe_format pformat= stImage->pt->format;
 
    if (stImage->pt) {
       unsigned face = _mesa_tex_target_to_face(target);
@@ -1229,8 +1178,7 @@ st_CompressedTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
                                             xoffset, yoffset,
                                             width, height);
       
-      block = stImage->pt->block;
-      srcBlockStride = pf_get_stride(&block, width);
+      srcBlockStride = util_format_get_stride(pformat, width);
       dstBlockStride = stImage->transfer->stride;
    } else {
       assert(stImage->pt);
@@ -1244,16 +1192,16 @@ st_CompressedTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
       return;
    }
 
-   assert(xoffset % block.width == 0);
-   assert(yoffset % block.height == 0);
-   assert(width % block.width == 0);
-   assert(height % block.height == 0);
+   assert(xoffset % util_format_get_blockwidth(pformat) == 0);
+   assert(yoffset % util_format_get_blockheight(pformat) == 0);
+   assert(width % util_format_get_blockwidth(pformat) == 0);
+   assert(height % util_format_get_blockheight(pformat) == 0);
 
-   for (y = 0; y < height; y += block.height) {
+   for (y = 0; y < height; y += util_format_get_blockheight(pformat)) {
       /* don't need to adjust for xoffset and yoffset as st_texture_image_map does that */
-      const char *src = (const char*)data + srcBlockStride * pf_get_nblocksy(&block, y);
-      char *dst = (char*)texImage->Data + dstBlockStride * pf_get_nblocksy(&block, y);
-      memcpy(dst, src, pf_get_stride(&block, width));
+      const char *src = (const char*)data + srcBlockStride * util_format_get_nblocksy(pformat, y);
+      char *dst = (char*)texImage->Data + dstBlockStride * util_format_get_nblocksy(pformat, y);
+      memcpy(dst, src, util_format_get_stride(pformat, width));
    }
 
    if (stImage->pt) {
@@ -1315,8 +1263,9 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level,
                                               srcX, srcY,
                                               width, height);
 
-   if (baseFormat == GL_DEPTH_COMPONENT &&
-       pf_is_depth_and_stencil(stImage->pt->format))
+   if ((baseFormat == GL_DEPTH_COMPONENT ||
+        baseFormat == GL_DEPTH_STENCIL) &&
+       util_format_is_depth_and_stencil(stImage->pt->format))
       transfer_usage = PIPE_TRANSFER_READ_WRITE;
    else
       transfer_usage = PIPE_TRANSFER_WRITE;
@@ -1328,7 +1277,7 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level,
                                   destX, destY, width, height);
 
    if (baseFormat == GL_DEPTH_COMPONENT ||
-       baseFormat == GL_DEPTH24_STENCIL8) {
+       baseFormat == GL_DEPTH_STENCIL) {
       const GLboolean scaleOrBias = (ctx->Pixel.DepthScale != 1.0F ||
                                      ctx->Pixel.DepthBias != 0.0F);
       GLint row, yStep;
@@ -1380,16 +1329,16 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level,
           * is actually RGBA but the user created the texture as GL_RGB we
           * need to fill-in/override the alpha channel with 1.0.
           */
-         texImage->TexFormat->StoreImage(ctx, dims,
-                                         texImage->_BaseFormat, 
-                                         texImage->TexFormat, 
-                                         texDest,
-                                         0, 0, 0,
-                                         dstRowStride,
-                                         texImage->ImageOffsets,
-                                         width, height, 1,
-                                         GL_RGBA, GL_FLOAT, tempSrc, /* src */
-                                         &unpack);
+         _mesa_texstore(ctx, dims,
+                        texImage->_BaseFormat, 
+                        texImage->TexFormat, 
+                        texDest,
+                        0, 0, 0,
+                        dstRowStride,
+                        texImage->ImageOffsets,
+                        width, height, 1,
+                        GL_RGBA, GL_FLOAT, tempSrc, /* src */
+                        &unpack);
       }
       else {
          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage");
@@ -1408,8 +1357,8 @@ static unsigned
 compatible_src_dst_formats(const struct gl_renderbuffer *src,
                            const struct gl_texture_image *dst)
 {
-   const GLenum srcFormat = src->_BaseFormat;
-   const GLenum dstLogicalFormat = dst->_BaseFormat;
+   const GLenum srcFormat = _mesa_get_format_base_format(src->Format);
+   const GLenum dstLogicalFormat = _mesa_get_format_base_format(dst->TexFormat);
 
    if (srcFormat == dstLogicalFormat) {
       /* This is the same as matching_base_formats, which should
@@ -1461,7 +1410,7 @@ st_copy_texsubimage(GLcontext *ctx,
    struct gl_texture_image *texImage =
       _mesa_select_tex_image(ctx, texObj, target, level);
    struct st_texture_image *stImage = st_texture_image(texImage);
-   const GLenum texBaseFormat = texImage->InternalFormat;
+   const GLenum texBaseFormat = texImage->_BaseFormat;
    struct gl_framebuffer *fb = ctx->ReadBuffer;
    struct st_renderbuffer *strb;
    struct pipe_context *pipe = ctx->st->pipe;
@@ -1482,12 +1431,9 @@ st_copy_texsubimage(GLcontext *ctx,
 
    /* determine if copying depth or color data */
    if (texBaseFormat == GL_DEPTH_COMPONENT ||
-       texBaseFormat == GL_DEPTH24_STENCIL8) {
+       texBaseFormat == GL_DEPTH_STENCIL) {
       strb = st_renderbuffer(fb->_DepthBuffer);
    }
-   else if (texBaseFormat == GL_DEPTH_STENCIL_EXT) {
-      strb = st_renderbuffer(fb->_StencilBuffer);
-   }
    else {
       /* texBaseFormat == GL_RGB, GL_RGBA, GL_ALPHA, etc */
       strb = st_renderbuffer(fb->_ColorReadBuffer);
@@ -1541,12 +1487,15 @@ st_copy_texsubimage(GLcontext *ctx,
     * framebuffer's alpha values).  We can't do that with the blit or
     * textured-quad paths.
     */
-   matching_base_formats = (strb->Base._BaseFormat == texImage->_BaseFormat);
+   matching_base_formats =
+      (_mesa_get_format_base_format(strb->Base.Format) ==
+       _mesa_get_format_base_format(texImage->TexFormat));
    format_writemask = compatible_src_dst_formats(&strb->Base, texImage);
 
    if (ctx->_ImageTransferState == 0x0) {
 
-      if (matching_base_formats && 
+      if (pipe->surface_copy &&
+          matching_base_formats &&
           src_format == dest_format &&
           !do_flip) 
       {
@@ -1570,6 +1519,8 @@ st_copy_texsubimage(GLcontext *ctx,
          use_fallback = GL_FALSE;
       }
       else if (format_writemask &&
+               texBaseFormat != GL_DEPTH_COMPONENT &&
+               texBaseFormat != GL_DEPTH_STENCIL &&
                screen->is_format_supported(screen, src_format,
                                            PIPE_TEXTURE_2D, 
                                            PIPE_TEXTURE_USAGE_SAMPLER,
@@ -1727,8 +1678,6 @@ copy_image_data_to_texture(struct st_context *st,
       pipe_texture_reference(&stImage->pt, NULL);
    }
    else if (stImage->base.Data) {
-      assert(stImage->base.Data != NULL);
-
       /* More straightforward upload.  
        */
 
@@ -1742,10 +1691,10 @@ copy_image_data_to_texture(struct st_context *st,
                             dstLevel,
                             stImage->base.Data,
                             stImage->base.RowStride * 
-                            stObj->pt->block.size,
+                            util_format_get_blocksize(stObj->pt->format),
                             stImage->base.RowStride *
                             stImage->base.Height *
-                            stObj->pt->block.size);
+                            util_format_get_blocksize(stObj->pt->format));
       _mesa_align_free(stImage->base.Data);
       stImage->base.Data = NULL;
    }
@@ -1767,7 +1716,7 @@ st_finalize_texture(GLcontext *ctx,
 {
    struct st_texture_object *stObj = st_texture_object(tObj);
    const GLuint nr_faces = (stObj->base.Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
-   GLuint cpp, face;
+   GLuint blockSize, face;
    struct st_texture_image *firstImage;
 
    *needFlush = GL_FALSE;
@@ -1799,28 +1748,21 @@ st_finalize_texture(GLcontext *ctx,
       pipe_texture_reference(&stObj->pt, firstImage->pt);
    }
 
-   /* FIXME: determine format block instead of cpp */
-   if (firstImage->base.IsCompressed) {
-      cpp = compressed_num_bytes(firstImage->base.TexFormat->MesaFormat);
-   }
-   else {
-      cpp = firstImage->base.TexFormat->TexelBytes;
-   }
+   /* bytes per pixel block (blocks are usually 1x1) */
+   blockSize = _mesa_get_format_bytes(firstImage->base.TexFormat);
 
    /* If we already have a gallium texture, check that it matches the texture
     * object's format, target, size, num_levels, etc.
     */
    if (stObj->pt) {
       const enum pipe_format fmt =
-         st_mesa_format_to_pipe_format(firstImage->base.TexFormat->MesaFormat);
+         st_mesa_format_to_pipe_format(firstImage->base.TexFormat);
       if (stObj->pt->target != gl_target_to_pipe(stObj->base.Target) ||
           stObj->pt->format != fmt ||
           stObj->pt->last_level < stObj->lastLevel ||
-          stObj->pt->width[0] != firstImage->base.Width2 ||
-          stObj->pt->height[0] != firstImage->base.Height2 ||
-          stObj->pt->depth[0] != firstImage->base.Depth2 ||
-          /* Nominal bytes per pixel: */
-          stObj->pt->block.size / stObj->pt->block.width != cpp)
+          stObj->pt->width0 != firstImage->base.Width2 ||
+          stObj->pt->height0 != firstImage->base.Height2 ||
+          stObj->pt->depth0 != firstImage->base.Depth2)
       {
          pipe_texture_reference(&stObj->pt, NULL);
          ctx->st->dirty.st |= ST_NEW_FRAMEBUFFER;
@@ -1831,7 +1773,7 @@ st_finalize_texture(GLcontext *ctx,
     */
    if (!stObj->pt) {
       const enum pipe_format fmt =
-         st_mesa_format_to_pipe_format(firstImage->base.TexFormat->MesaFormat);
+         st_mesa_format_to_pipe_format(firstImage->base.TexFormat);
       GLuint usage = default_usage(fmt);
 
       stObj->pt = st_texture_create(ctx->st,
@@ -1948,7 +1890,6 @@ st_init_texture_functions(struct dd_function_table *functions)
    /* compressed texture functions */
    functions->CompressedTexImage2D = st_CompressedTexImage2D;
    functions->GetCompressedTexImage = st_GetCompressedTexImage;
-   functions->CompressedTextureSize = _mesa_compressed_texture_size;
 
    functions->NewTextureObject = st_NewTextureObject;
    functions->NewTextureImage = st_NewTextureImage;
index f0eddafd331dc127b4c7e259d0898e79641b6e1a..e4f18c842ca79e8472638ac48e2f72ef24984c76 100644 (file)
@@ -43,6 +43,7 @@
 #include "st_cb_blit.h"
 #include "st_cb_bufferobjects.h"
 #include "st_cb_clear.h"
+#include "st_cb_condrender.h"
 #if FEATURE_drawpix
 #include "st_cb_drawpixels.h"
 #include "st_cb_rasterpos.h"
@@ -51,7 +52,6 @@
 #include "st_cb_drawtex.h"
 #endif
 #include "st_cb_fbo.h"
-#include "st_cb_get.h"
 #if FEATURE_feedback
 #include "st_cb_feedback.h"
 #endif
@@ -331,7 +331,6 @@ void st_init_driver_functions(struct dd_function_table *functions)
    st_init_rasterpos_functions(functions);
 #endif
    st_init_fbo_functions(functions);
-   st_init_get_functions(functions);
 #if FEATURE_feedback
    st_init_feedback_functions(functions);
 #endif
@@ -339,6 +338,7 @@ void st_init_driver_functions(struct dd_function_table *functions)
 #if FEATURE_queryobj
    st_init_query_functions(functions);
 #endif
+   st_init_cond_render_functions(functions);
    st_init_readpixels_functions(functions);
    st_init_texture_functions(functions);
    st_init_flush_functions(functions);
index 18adb35e8721403b7217450823366ad73229cf09..831909a3f8fb6e07acd56239952cdb2a72eb6e6d 100644 (file)
@@ -55,6 +55,7 @@ struct bitmap_cache;
 #define ST_NEW_FRAGMENT_PROGRAM        0x2
 #define ST_NEW_VERTEX_PROGRAM          0x4
 #define ST_NEW_FRAMEBUFFER             0x8
+#define ST_NEW_EDGEFLAGS_DATA          0x10
 
 
 struct st_state_flags {
@@ -120,6 +121,7 @@ struct st_context
    struct st_state_flags dirty;
 
    GLboolean missing_textures;
+   GLboolean vertdata_edgeflags;
 
    /** Mapping from VERT_RESULT_x to post-transformed vertex slot */
    const GLuint *vertex_result_to_slot;
@@ -127,6 +129,8 @@ struct st_context
    struct st_vertex_program *vp;    /**< Currently bound vertex program */
    struct st_fragment_program *fp;  /**< Currently bound fragment program */
 
+   struct st_vp_varient *vp_varient;
+
    struct gl_texture_object *default_texture;
 
    struct {
index 3009cde9d5181c44c08546330121381790570a74..6e699ca5522477336456be0eacdeda12be9b2ef8 100644 (file)
@@ -86,7 +86,8 @@ st_print_current(void)
    }
 #endif
 
-   tgsi_dump( st->vp->state.tokens, 0 );
+   if (st->vp->varients)
+      tgsi_dump( st->vp->varients[0].state.tokens, 0 );
    if (st->vp->Base.Base.Parameters)
       _mesa_print_parameter_list(st->vp->Base.Base.Parameters);
 
index c76bff91819d7da2a978042ced88f04c3fdd4457..e54f21be6009c7a1051127df9aeb68f1843c7a61 100644 (file)
  * 
  **************************************************************************/
 
- /*
-  * Authors:
-  *   Keith Whitwell <keith@tungstengraphics.com>
-  */
+/*
+ * This file implements the st_draw_vbo() function which is called from
+ * Mesa's VBO module.  All point/line/triangle rendering is done through
+ * this function whether the user called glBegin/End, glDrawArrays,
+ * glDrawElements, glEvalMesh, or glCalList, etc.
+ *
+ * We basically convert the VBO's vertex attribute/array information into
+ * Gallium vertex state, bind the vertex buffer objects and call
+ * pipe->draw_elements(), pipe->draw_range_elements() or pipe->draw_arrays().
+ *
+ * Authors:
+ *   Keith Whitwell <keith@tungstengraphics.com>
+ */
+
 
 #include "main/imports.h"
 #include "main/image.h"
@@ -207,59 +217,7 @@ st_pipe_vertex_format(GLenum type, GLuint size, GLenum format,
 }
 
 
-/*
- * If edge flags are needed, setup an bitvector of flags and call
- * pipe->set_edgeflags().
- * XXX memleak: need to free the returned pointer at some point
- */
-static void *
-setup_edgeflags(GLcontext *ctx, GLenum primMode, GLint start, GLint count,
-                const struct gl_client_array *array)
-{
-   struct pipe_context *pipe = ctx->st->pipe;
-
-   if ((primMode == GL_TRIANGLES ||
-        primMode == GL_QUADS ||
-        primMode == GL_POLYGON) &&
-       (ctx->Polygon.FrontMode != GL_FILL ||
-        ctx->Polygon.BackMode != GL_FILL)) {
-      /* need edge flags */
-      GLint i;
-      unsigned *vec;
-      struct st_buffer_object *stobj = st_buffer_object(array->BufferObj);
-      ubyte *map;
-
-      if (!stobj || stobj->Base.Name == 0) {
-         /* edge flags are not in a VBO */
-         return NULL;
-      }
-
-      vec = (unsigned *) _mesa_calloc(sizeof(unsigned) * ((count + 31) / 32));
-      if (!vec)
-         return NULL;
-
-      map = pipe_buffer_map(pipe->screen, stobj->buffer, PIPE_BUFFER_USAGE_CPU_READ);
-      map = ADD_POINTERS(map, array->Ptr);
-
-      for (i = 0; i < count; i++) {
-         if (*((float *) map))
-            vec[i/32] |= 1 << (i % 32);
-
-         map += array->StrideB;
-      }
-
-      pipe_buffer_unmap(pipe->screen, stobj->buffer);
 
-      pipe->set_edgeflags(pipe, vec);
-
-      return vec;
-   }
-   else {
-      /* edge flags not needed */
-      pipe->set_edgeflags(pipe, NULL);
-      return NULL;
-   }
-}
 
 
 /**
@@ -269,6 +227,7 @@ setup_edgeflags(GLcontext *ctx, GLenum primMode, GLint start, GLint count,
  */
 static GLboolean
 is_interleaved_arrays(const struct st_vertex_program *vp,
+                      const struct st_vp_varient *vpv,
                       const struct gl_client_array **arrays,
                       GLboolean *userSpace)
 {
@@ -278,7 +237,7 @@ is_interleaved_arrays(const struct st_vertex_program *vp,
    GLuint num_client_arrays = 0;
    const GLubyte *client_addr = NULL;
 
-   for (attr = 0; attr < vp->num_inputs; attr++) {
+   for (attr = 0; attr < vpv->num_inputs; attr++) {
       const GLuint mesaAttr = vp->index_to_input[attr];
       const struct gl_buffer_object *bufObj = arrays[mesaAttr]->BufferObj;
       const GLsizei stride = arrays[mesaAttr]->StrideB; /* in bytes */
@@ -311,7 +270,7 @@ is_interleaved_arrays(const struct st_vertex_program *vp,
       }
    }
 
-   *userSpace = (num_client_arrays == vp->num_inputs);
+   *userSpace = (num_client_arrays == vpv->num_inputs);
    /* printf("user space: %d (%d %d)\n", (int) *userSpace,num_client_arrays,vp->num_inputs); */
 
    return GL_TRUE;
@@ -323,15 +282,16 @@ is_interleaved_arrays(const struct st_vertex_program *vp,
  */
 static void
 get_arrays_bounds(const struct st_vertex_program *vp,
-                       const struct gl_client_array **arrays,
-                       GLuint max_index,
-                       const GLubyte **low, const GLubyte **high)
+                  const struct st_vp_varient *vpv,
+                  const struct gl_client_array **arrays,
+                  GLuint max_index,
+                  const GLubyte **low, const GLubyte **high)
 {
    const GLubyte *low_addr = NULL;
    const GLubyte *high_addr = NULL;
    GLuint attr;
 
-   for (attr = 0; attr < vp->num_inputs; attr++) {
+   for (attr = 0; attr < vpv->num_inputs; attr++) {
       const GLuint mesaAttr = vp->index_to_input[attr];
       const GLint stride = arrays[mesaAttr]->StrideB;
       const GLubyte *start = arrays[mesaAttr]->Ptr;
@@ -363,6 +323,7 @@ get_arrays_bounds(const struct st_vertex_program *vp,
 static void
 setup_interleaved_attribs(GLcontext *ctx,
                           const struct st_vertex_program *vp,
+                          const struct st_vp_varient *vpv,
                           const struct gl_client_array **arrays,
                           GLuint max_index,
                           GLboolean userSpace,
@@ -371,9 +332,9 @@ setup_interleaved_attribs(GLcontext *ctx,
 {
    struct pipe_context *pipe = ctx->st->pipe;
    GLuint attr;
-   const GLubyte *offset0;
+   const GLubyte *offset0 = NULL;
 
-   for (attr = 0; attr < vp->num_inputs; attr++) {
+   for (attr = 0; attr < vpv->num_inputs; attr++) {
       const GLuint mesaAttr = vp->index_to_input[attr];
       struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj;
       struct st_buffer_object *stobj = st_buffer_object(bufobj);
@@ -384,7 +345,7 @@ setup_interleaved_attribs(GLcontext *ctx,
       if (attr == 0) {
          const GLubyte *low, *high;
 
-         get_arrays_bounds(vp, arrays, max_index, &low, &high);
+         get_arrays_bounds(vp, vpv, arrays, max_index, &low, &high);
          /*printf("buffer range: %p %p  %d\n", low, high, high-low);*/
 
          offset0 = low;
@@ -425,6 +386,7 @@ setup_interleaved_attribs(GLcontext *ctx,
 static void
 setup_non_interleaved_attribs(GLcontext *ctx,
                               const struct st_vertex_program *vp,
+                              const struct st_vp_varient *vpv,
                               const struct gl_client_array **arrays,
                               GLuint max_index,
                               GLboolean *userSpace,
@@ -434,7 +396,7 @@ setup_non_interleaved_attribs(GLcontext *ctx,
    struct pipe_context *pipe = ctx->st->pipe;
    GLuint attr;
 
-   for (attr = 0; attr < vp->num_inputs; attr++) {
+   for (attr = 0; attr < vpv->num_inputs; attr++) {
       const GLuint mesaAttr = vp->index_to_input[attr];
       struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj;
       GLsizei stride = arrays[mesaAttr]->StrideB;
@@ -528,6 +490,20 @@ check_uniforms(GLcontext *ctx)
 }
 
 
+static unsigned translate_prim( GLcontext *ctx,
+                                unsigned prim )
+{
+   /* Avoid quadstrips if it's easy to do so:
+    */
+   if (prim == GL_QUAD_STRIP &&
+       ctx->Light.ShadeModel != GL_FLAT &&
+       ctx->Polygon.FrontMode == GL_FILL &&
+       ctx->Polygon.BackMode == GL_FILL)
+      prim = GL_TRIANGLE_STRIP;
+
+   return prim;
+}
+
 /**
  * This function gets plugged into the VBO module and is called when
  * we have something to render.
@@ -545,25 +521,36 @@ st_draw_vbo(GLcontext *ctx,
 {
    struct pipe_context *pipe = ctx->st->pipe;
    const struct st_vertex_program *vp;
+   const struct st_vp_varient *vpv;
    const struct pipe_shader_state *vs;
    struct pipe_vertex_buffer vbuffer[PIPE_MAX_SHADER_INPUTS];
    GLuint attr;
    struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS];
    unsigned num_vbuffers, num_velements;
-   GLboolean userSpace;
+   GLboolean userSpace = GL_FALSE;
+   GLboolean vertDataEdgeFlags;
 
    /* Gallium probably doesn't want this in some cases. */
    if (!index_bounds_valid)
-      vbo_get_minmax_index(ctx, prims, ib, &min_index, &max_index);
+      if (!vbo_all_varyings_in_vbos(arrays))
+        vbo_get_minmax_index(ctx, prims, ib, &min_index, &max_index);
 
    /* sanity check for pointer arithmetic below */
    assert(sizeof(arrays[0]->Ptr[0]) == 1);
 
+   vertDataEdgeFlags = arrays[VERT_ATTRIB_EDGEFLAG]->BufferObj &&
+                       arrays[VERT_ATTRIB_EDGEFLAG]->BufferObj->Name;
+   if (vertDataEdgeFlags != ctx->st->vertdata_edgeflags) {
+      ctx->st->vertdata_edgeflags = vertDataEdgeFlags;
+      ctx->st->dirty.st |= ST_NEW_EDGEFLAGS_DATA;
+   }
+
    st_validate_state(ctx->st);
 
    /* must get these after state validation! */
    vp = ctx->st->vp;
-   vs = &ctx->st->vp->state;
+   vpv = ctx->st->vp_varient;
+   vs = &vpv->state;
 
 #if 0
    if (MESA_VERBOSE & VERBOSE_GLSL) {
@@ -576,21 +563,21 @@ st_draw_vbo(GLcontext *ctx,
    /*
     * Setup the vbuffer[] and velements[] arrays.
     */
-   if (is_interleaved_arrays(vp, arrays, &userSpace)) {
+   if (is_interleaved_arrays(vp, vpv, arrays, &userSpace)) {
       /*printf("Draw interleaved\n");*/
-      setup_interleaved_attribs(ctx, vp, arrays, max_index, userSpace,
+      setup_interleaved_attribs(ctx, vp, vpv, arrays, max_index, userSpace,
                                 vbuffer, velements);
       num_vbuffers = 1;
-      num_velements = vp->num_inputs;
+      num_velements = vpv->num_inputs;
       if (num_velements == 0)
          num_vbuffers = 0;
    }
    else {
       /*printf("Draw non-interleaved\n");*/
-      setup_non_interleaved_attribs(ctx, vp, arrays, max_index,
+      setup_non_interleaved_attribs(ctx, vp, vpv, arrays, max_index,
                                     &userSpace, vbuffer, velements);
-      num_vbuffers = vp->num_inputs;
-      num_velements = vp->num_inputs;
+      num_vbuffers = vpv->num_inputs;
+      num_velements = vpv->num_inputs;
    }
 
 #if 0
@@ -623,6 +610,7 @@ st_draw_vbo(GLcontext *ctx,
       struct gl_buffer_object *bufobj = ib->obj;
       struct pipe_buffer *indexBuf = NULL;
       unsigned indexSize, indexOffset, i;
+      unsigned prim;
 
       switch (ib->type) {
       case GL_UNSIGNED_INT:
@@ -661,24 +649,20 @@ st_draw_vbo(GLcontext *ctx,
           * through to driver & draw module.  These interfaces still
           * need a bit of work...
           */
-         setup_edgeflags(ctx, prims[i].mode,
-                         prims[i].start + indexOffset, prims[i].count,
-                         arrays[VERT_ATTRIB_EDGEFLAG]);
+         prim = translate_prim( ctx, prims[i].mode );
 
          pipe->draw_range_elements(pipe, indexBuf, indexSize,
                                    min_index,
                                    max_index,
-                                   prims[i].mode,
+                                   prim,
                                    prims[i].start + indexOffset, prims[i].count);
       }
       else {
          for (i = 0; i < nr_prims; i++) {
-            setup_edgeflags(ctx, prims[i].mode,
-                            prims[i].start + indexOffset, prims[i].count,
-                            arrays[VERT_ATTRIB_EDGEFLAG]);
+            prim = translate_prim( ctx, prims[i].mode );
             
             pipe->draw_elements(pipe, indexBuf, indexSize,
-                                prims[i].mode,
+                                prim,
                                 prims[i].start + indexOffset, prims[i].count);
          }
       }
@@ -688,12 +672,12 @@ st_draw_vbo(GLcontext *ctx,
    else {
       /* non-indexed */
       GLuint i;
+      GLuint prim;
+
       for (i = 0; i < nr_prims; i++) {
-         setup_edgeflags(ctx, prims[i].mode,
-                         prims[i].start, prims[i].count,
-                         arrays[VERT_ATTRIB_EDGEFLAG]);
+         prim = translate_prim( ctx, prims[i].mode );
 
-         pipe->draw_arrays(pipe, prims[i].mode, prims[i].start, prims[i].count);
+         pipe->draw_arrays(pipe, prim, prims[i].start, prims[i].count);
       }
    }
 
index b2d682ef640c52cedad1b4fdd39714f0725de683..cfc0caac983e37fb96175718e16356442fd8cca1 100644 (file)
@@ -120,10 +120,10 @@ st_feedback_draw_vbo(GLcontext *ctx,
 
    /* must get these after state validation! */
    vp = ctx->st->vp;
-   vs = &st->vp->state;
+   vs = &st->vp_varient->state;
 
-   if (!st->vp->draw_shader) {
-      st->vp->draw_shader = draw_create_vertex_shader(draw, vs);
+   if (!st->vp_varient->draw_shader) {
+      st->vp_varient->draw_shader = draw_create_vertex_shader(draw, vs);
    }
 
    /*
@@ -136,7 +136,7 @@ st_feedback_draw_vbo(GLcontext *ctx,
    draw_set_viewport_state(draw, &st->state.viewport);
    draw_set_clip_state(draw, &st->state.clip);
    draw_set_rasterizer_state(draw, &st->state.rasterizer);
-   draw_bind_vertex_shader(draw, st->vp->draw_shader);
+   draw_bind_vertex_shader(draw, st->vp_varient->draw_shader);
    set_feedback_vertex_format(ctx);
 
    /* loop over TGSI shader inputs to determine vertex buffer
@@ -241,7 +241,8 @@ st_feedback_draw_vbo(GLcontext *ctx,
    mapped_constants = pipe_buffer_map(pipe->screen,
                                       st->state.constants[PIPE_SHADER_VERTEX].buffer,
                                       PIPE_BUFFER_USAGE_CPU_READ);
-   draw_set_mapped_constant_buffer(st->draw, mapped_constants,
+   draw_set_mapped_constant_buffer(st->draw, PIPE_SHADER_VERTEX,
+                                   mapped_constants,
                                    st->state.constants[PIPE_SHADER_VERTEX].buffer->size);
 
 
index 3f835d38dd5138624b4e2902de324d1d86289c20..35e08749df7fc023e727db02c1e7aced4d763a51 100644 (file)
@@ -92,6 +92,10 @@ void st_init_limits(struct st_context *st)
       = _min(screen->get_param(screen, PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS),
              MAX_VERTEX_TEXTURE_IMAGE_UNITS);
 
+   c->MaxCombinedTextureImageUnits
+      = _min(screen->get_param(screen, PIPE_CAP_MAX_COMBINED_SAMPLERS),
+             MAX_COMBINED_TEXTURE_IMAGE_UNITS);
+
    c->MaxTextureCoordUnits
       = _min(c->MaxTextureImageUnits, MAX_TEXTURE_COORD_UNITS);
 
@@ -284,6 +288,7 @@ void st_init_extensions(struct st_context *st)
                                    PIPE_TEXTURE_2D, 
                                    PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
       ctx->Extensions.EXT_texture_compression_s3tc = GL_TRUE;
+      ctx->Extensions.S3_s3tc = GL_TRUE;
    }
 
    /* ycbcr support */
@@ -301,4 +306,8 @@ void st_init_extensions(struct st_context *st)
       /* we support always support GL_EXT_framebuffer_blit */
       ctx->Extensions.ARB_framebuffer_object = GL_TRUE;
    }
+
+   if (st->pipe->render_condition) {
+      ctx->Extensions.NV_conditional_render = GL_TRUE;
+   }
 }
index 3e0db374144454f1f9923b3997b35f8056ad680a..d00b67a279ecd098d1fc4441f05461d91d72304d 100644 (file)
 #include "pipe/p_context.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_screen.h"
+#include "util/u_format.h"
 #include "st_context.h"
 #include "st_format.h"
 
-static GLuint
-format_bits(
-   pipe_format_rgbazs_t  info,
-   GLuint comp )
-{
-   return pf_get_component_bits( (enum pipe_format) info, comp );
-}
 
 static GLuint
-format_max_bits(
-   pipe_format_rgbazs_t  info )
+format_max_bits(enum pipe_format format)
 {
-   GLuint   size = format_bits( info, PIPE_FORMAT_COMP_R );
+   GLuint size = util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0);
 
-   size = MAX2( size, format_bits( info, PIPE_FORMAT_COMP_G ) );
-   size = MAX2( size, format_bits( info, PIPE_FORMAT_COMP_B ) );
-   size = MAX2( size, format_bits( info, PIPE_FORMAT_COMP_A ) );
-   size = MAX2( size, format_bits( info, PIPE_FORMAT_COMP_Z ) );
-   size = MAX2( size, format_bits( info, PIPE_FORMAT_COMP_S ) );
+   size = MAX2(size, util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 1));
+   size = MAX2(size, util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 2));
+   size = MAX2(size, util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 3));
+   size = MAX2(size, util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 0));
+   size = MAX2(size, util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 1));
    return size;
 }
 
 static GLuint
-format_size(
-   pipe_format_rgbazs_t  info )
+format_size(enum pipe_format format)
 {
    return
-      format_bits( info, PIPE_FORMAT_COMP_R ) +
-      format_bits( info, PIPE_FORMAT_COMP_G ) +
-      format_bits( info, PIPE_FORMAT_COMP_B ) +
-      format_bits( info, PIPE_FORMAT_COMP_A ) +
-      format_bits( info, PIPE_FORMAT_COMP_Z ) +
-      format_bits( info, PIPE_FORMAT_COMP_S );
+      util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0) +
+      util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 1) +
+      util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 2) +
+      util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 3) +
+      util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 0) +
+      util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 1);
 }
 
 /*
@@ -86,11 +78,13 @@ format_size(
 GLboolean
 st_get_format_info(enum pipe_format format, struct pipe_format_info *pinfo)
 {
-   if (pf_layout(format) == PIPE_FORMAT_LAYOUT_RGBAZS) {
-      pipe_format_rgbazs_t info;
+   const struct util_format_description *desc;
 
-      info = format;
+   desc = util_format_description(format);
+   assert(desc);
 
+   if (desc->layout == UTIL_FORMAT_LAYOUT_ARITH ||
+       desc->layout == UTIL_FORMAT_LAYOUT_ARRAY) {
 #if 0
       printf("%s\n", pf_name( format ) );
 #endif
@@ -99,25 +93,27 @@ st_get_format_info(enum pipe_format format, struct pipe_format_info *pinfo)
       if (format == PIPE_FORMAT_A1R5G5B5_UNORM || format == PIPE_FORMAT_R5G6B5_UNORM) {
          pinfo->datatype = GL_UNSIGNED_SHORT;
       }
+      else if (format == PIPE_FORMAT_S8Z24_UNORM ||
+               format == PIPE_FORMAT_Z24S8_UNORM) {
+         pinfo->datatype = GL_UNSIGNED_INT_24_8;
+      }
       else {
-         GLuint size;
-
-         size = format_max_bits( info );
+         const GLuint size = format_max_bits(format);
          if (size == 8) {
-            if (pf_type(info) == PIPE_FORMAT_TYPE_UNORM)
+            if (desc->channel[0].type == UTIL_FORMAT_TYPE_UNSIGNED)
                pinfo->datatype = GL_UNSIGNED_BYTE;
             else
                pinfo->datatype = GL_BYTE;
          }
          else if (size == 16) {
-            if (pf_type(info) == PIPE_FORMAT_TYPE_UNORM)
+            if (desc->channel[0].type == UTIL_FORMAT_TYPE_UNSIGNED)
                pinfo->datatype = GL_UNSIGNED_SHORT;
             else
                pinfo->datatype = GL_SHORT;
          }
          else {
             assert( size <= 32 );
-            if (pf_type(info) == PIPE_FORMAT_TYPE_UNORM)
+            if (desc->channel[0].type == UTIL_FORMAT_TYPE_UNSIGNED)
                pinfo->datatype = GL_UNSIGNED_INT;
             else
                pinfo->datatype = GL_INT;
@@ -125,23 +121,23 @@ st_get_format_info(enum pipe_format format, struct pipe_format_info *pinfo)
       }
 
       /* Component bits */
-      pinfo->red_bits = format_bits( info, PIPE_FORMAT_COMP_R );
-      pinfo->green_bits = format_bits( info, PIPE_FORMAT_COMP_G );
-      pinfo->blue_bits = format_bits( info, PIPE_FORMAT_COMP_B );
-      pinfo->alpha_bits = format_bits( info, PIPE_FORMAT_COMP_A );
-      pinfo->depth_bits = format_bits( info, PIPE_FORMAT_COMP_Z );
-      pinfo->stencil_bits = format_bits( info, PIPE_FORMAT_COMP_S );
+      pinfo->red_bits = util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0);
+      pinfo->green_bits = util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 1);
+      pinfo->blue_bits = util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 2);
+      pinfo->alpha_bits = util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 3);
+      pinfo->depth_bits = util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 0);
+      pinfo->stencil_bits = util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 1);
       pinfo->luminance_bits = 0;
       pinfo->intensity_bits = 0;
 
       /* Format size */
-      pinfo->size = format_size( info ) / 8;
+      pinfo->size = format_size(format) / 8;
 
       /* Luminance & Intensity bits */
-      if( pf_swizzle_x(info) == PIPE_FORMAT_COMP_R &&
-          pf_swizzle_y(info) == PIPE_FORMAT_COMP_R &&
-          pf_swizzle_z(info) == PIPE_FORMAT_COMP_R ) {
-         if( pf_swizzle_w(info) == PIPE_FORMAT_COMP_R ) {
+      if (desc->swizzle[0] == UTIL_FORMAT_SWIZZLE_X &&
+          desc->swizzle[1] == UTIL_FORMAT_SWIZZLE_X &&
+          desc->swizzle[2] == UTIL_FORMAT_SWIZZLE_X) {
+         if (desc->swizzle[3] == UTIL_FORMAT_SWIZZLE_X) {
             pinfo->intensity_bits = pinfo->red_bits;
          }
          else {
@@ -150,24 +146,10 @@ st_get_format_info(enum pipe_format format, struct pipe_format_info *pinfo)
          pinfo->red_bits = 0;
       }
 
-      /* Base format */
-      if (pinfo->depth_bits) {
-         if (pinfo->stencil_bits) {
-            pinfo->base_format = GL_DEPTH_STENCIL_EXT;
-         }
-         else {
-            pinfo->base_format = GL_DEPTH_COMPONENT;
-         }
-      }
-      else if (pinfo->stencil_bits) {
-         pinfo->base_format = GL_STENCIL_INDEX;
-      }
-      else {
-         pinfo->base_format = GL_RGBA;
-      }
+      pinfo->mesa_format = st_pipe_format_to_mesa_format(format);
    }
-   else if (pf_layout(format) == PIPE_FORMAT_LAYOUT_YCBCR) {
-      pinfo->base_format = GL_YCBCR_MESA;
+   else if (desc->layout == UTIL_FORMAT_LAYOUT_YUV) {
+      pinfo->mesa_format = MESA_FORMAT_YCBCR;
       pinfo->datatype = GL_UNSIGNED_SHORT;
       pinfo->size = 2; /* two bytes per "texel" */
    }
@@ -224,13 +206,15 @@ st_format_datatype(enum pipe_format format)
 
 
 enum pipe_format
-st_mesa_format_to_pipe_format(GLuint mesaFormat)
+st_mesa_format_to_pipe_format(gl_format mesaFormat)
 {
    switch (mesaFormat) {
       /* fix this */
    case MESA_FORMAT_ARGB8888_REV:
    case MESA_FORMAT_ARGB8888:
       return PIPE_FORMAT_A8R8G8B8_UNORM;
+   case MESA_FORMAT_XRGB8888:
+      return PIPE_FORMAT_X8R8G8B8_UNORM;
    case MESA_FORMAT_ARGB1555:
       return PIPE_FORMAT_A1R5G5B5_UNORM;
    case MESA_FORMAT_ARGB4444:
@@ -293,6 +277,90 @@ st_mesa_format_to_pipe_format(GLuint mesaFormat)
    }
 }
 
+
+gl_format
+st_pipe_format_to_mesa_format(enum pipe_format pipeFormat)
+{
+   switch (pipeFormat) {
+   case PIPE_FORMAT_A8R8G8B8_UNORM:
+      return MESA_FORMAT_ARGB8888;
+   case PIPE_FORMAT_X8R8G8B8_UNORM:
+      return MESA_FORMAT_XRGB8888;
+   case PIPE_FORMAT_B8G8R8A8_UNORM:
+      return MESA_FORMAT_ARGB8888_REV;
+   case PIPE_FORMAT_A1R5G5B5_UNORM:
+      return MESA_FORMAT_ARGB1555;
+   case PIPE_FORMAT_A4R4G4B4_UNORM:
+      return MESA_FORMAT_ARGB4444;
+   case PIPE_FORMAT_R5G6B5_UNORM:
+      return MESA_FORMAT_RGB565;
+   case PIPE_FORMAT_A8L8_UNORM:
+      return MESA_FORMAT_AL88;
+   case PIPE_FORMAT_A8_UNORM:
+      return MESA_FORMAT_A8;
+   case PIPE_FORMAT_L8_UNORM:
+      return MESA_FORMAT_L8;
+   case PIPE_FORMAT_I8_UNORM:
+      return MESA_FORMAT_I8;
+   case PIPE_FORMAT_Z16_UNORM:
+      return MESA_FORMAT_Z16;
+   case PIPE_FORMAT_Z32_UNORM:
+      return MESA_FORMAT_Z32;
+   case PIPE_FORMAT_Z24X8_UNORM:
+      return MESA_FORMAT_Z24_X8;
+   case PIPE_FORMAT_Z24S8_UNORM:
+      return MESA_FORMAT_Z24_S8;
+   case PIPE_FORMAT_X8Z24_UNORM:
+      return MESA_FORMAT_X8_Z24;
+   case PIPE_FORMAT_S8Z24_UNORM:
+      return MESA_FORMAT_S8_Z24;
+   case PIPE_FORMAT_S8_UNORM:
+      return MESA_FORMAT_S8;
+
+   case PIPE_FORMAT_YCBCR:
+      return MESA_FORMAT_YCBCR;
+   case PIPE_FORMAT_R16G16B16A16_SNORM:
+      return MESA_FORMAT_SIGNED_RGBA_16;
+
+#if FEATURE_texture_s3tc
+   case PIPE_FORMAT_DXT1_RGB:
+      return MESA_FORMAT_RGB_DXT1;
+   case PIPE_FORMAT_DXT1_RGBA:
+      return MESA_FORMAT_RGBA_DXT1;
+   case PIPE_FORMAT_DXT3_RGBA:
+      return MESA_FORMAT_RGBA_DXT3;
+   case PIPE_FORMAT_DXT5_RGBA:
+      return MESA_FORMAT_RGBA_DXT5;
+#if FEATURE_EXT_texture_sRGB
+   case PIPE_FORMAT_DXT1_SRGB:
+      return MESA_FORMAT_SRGB_DXT1;
+   case PIPE_FORMAT_DXT1_SRGBA:
+      return MESA_FORMAT_SRGBA_DXT1;
+   case PIPE_FORMAT_DXT3_SRGBA:
+      return MESA_FORMAT_SRGBA_DXT3;
+   case PIPE_FORMAT_DXT5_SRGBA:
+      return MESA_FORMAT_SRGBA_DXT5;
+#endif
+#endif
+#if FEATURE_EXT_texture_sRGB
+   case PIPE_FORMAT_A8L8_SRGB:
+      return MESA_FORMAT_SLA8;
+   case PIPE_FORMAT_L8_SRGB:
+      return MESA_FORMAT_SL8;
+   case PIPE_FORMAT_R8G8B8_SRGB:
+      return MESA_FORMAT_SRGB8;
+   case PIPE_FORMAT_R8G8B8A8_SRGB:
+      return MESA_FORMAT_SRGBA8;
+   case PIPE_FORMAT_A8R8G8B8_SRGB:
+      return MESA_FORMAT_SARGB8;
+#endif
+   default:
+      assert(0);
+      return 0;
+   }
+}
+
+
 /**
  * Find an RGBA format supported by the context/winsys.
  */
@@ -317,6 +385,33 @@ default_rgba_format(struct pipe_screen *screen,
    return PIPE_FORMAT_NONE;
 }
 
+/**
+ * Find an RGB format supported by the context/winsys.
+ */
+static enum pipe_format
+default_rgb_format(struct pipe_screen *screen, 
+                   enum pipe_texture_target target,
+                   unsigned tex_usage, 
+                   unsigned geom_flags)
+{
+   static const enum pipe_format colorFormats[] = {
+      PIPE_FORMAT_X8R8G8B8_UNORM,
+      PIPE_FORMAT_B8G8R8X8_UNORM,
+      PIPE_FORMAT_R8G8B8X8_UNORM,
+      PIPE_FORMAT_A8R8G8B8_UNORM,
+      PIPE_FORMAT_B8G8R8A8_UNORM,
+      PIPE_FORMAT_R8G8B8A8_UNORM,
+      PIPE_FORMAT_R5G6B5_UNORM
+   };
+   uint i;
+   for (i = 0; i < Elements(colorFormats); i++) {
+      if (screen->is_format_supported( screen, colorFormats[i], target, tex_usage, geom_flags )) {
+         return colorFormats[i];
+      }
+   }
+   return PIPE_FORMAT_NONE;
+}
+
 /**
  * Find an sRGBA format supported by the context/winsys.
  */
@@ -401,13 +496,14 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
    case 4:
    case GL_RGBA:
    case GL_COMPRESSED_RGBA:
-   case 3:
-   case GL_RGB:
-   case GL_COMPRESSED_RGB:
    case GL_RGBA8:
    case GL_RGB10_A2:
    case GL_RGBA12:
       return default_rgba_format( screen, target, tex_usage, geom_flags );
+   case 3:
+   case GL_RGB:
+   case GL_COMPRESSED_RGB:
+      return default_rgb_format( screen, target, tex_usage, geom_flags );
    case GL_RGBA16:
       if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET)
          return default_deep_rgba_format( screen, target, tex_usage, geom_flags );
@@ -429,7 +525,7 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
    case GL_RGB10:
    case GL_RGB12:
    case GL_RGB16:
-      return default_rgba_format( screen, target, tex_usage, geom_flags );
+      return default_rgb_format( screen, target, tex_usage, geom_flags );
 
    case GL_RGB5:
    case GL_RGB4:
@@ -629,74 +725,78 @@ st_choose_renderbuffer_format(struct pipe_screen *screen,
 }
 
 
-static const struct gl_texture_format *
+static gl_format
 translate_gallium_format_to_mesa_format(enum pipe_format format)
 {
    switch (format) {
    case PIPE_FORMAT_A8R8G8B8_UNORM:
-      return &_mesa_texformat_argb8888;
+      return MESA_FORMAT_ARGB8888;
+   case PIPE_FORMAT_X8R8G8B8_UNORM:
+      return MESA_FORMAT_XRGB8888;
    case PIPE_FORMAT_A1R5G5B5_UNORM:
-      return &_mesa_texformat_argb1555;
+      return MESA_FORMAT_ARGB1555;
    case PIPE_FORMAT_A4R4G4B4_UNORM:
-      return &_mesa_texformat_argb4444;
+      return MESA_FORMAT_ARGB4444;
    case PIPE_FORMAT_R5G6B5_UNORM:
-      return &_mesa_texformat_rgb565;
+      return MESA_FORMAT_RGB565;
    case PIPE_FORMAT_A8L8_UNORM:
-      return &_mesa_texformat_al88;
+      return MESA_FORMAT_AL88;
    case PIPE_FORMAT_A8_UNORM:
-      return &_mesa_texformat_a8;
+      return MESA_FORMAT_A8;
    case PIPE_FORMAT_L8_UNORM:
-      return &_mesa_texformat_l8;
+      return MESA_FORMAT_L8;
    case PIPE_FORMAT_I8_UNORM:
-      return &_mesa_texformat_i8;
+      return MESA_FORMAT_I8;
    case PIPE_FORMAT_Z16_UNORM:
-      return &_mesa_texformat_z16;
+      return MESA_FORMAT_Z16;
    case PIPE_FORMAT_Z32_UNORM:
-      return &_mesa_texformat_z32;
+      return MESA_FORMAT_Z32;
    case PIPE_FORMAT_Z24S8_UNORM:
-      return &_mesa_texformat_z24_s8;
+      return MESA_FORMAT_Z24_S8;
+   case PIPE_FORMAT_X8Z24_UNORM:
+      return MESA_FORMAT_X8_Z24;
    case PIPE_FORMAT_S8Z24_UNORM:
-      return &_mesa_texformat_s8_z24;
+      return MESA_FORMAT_S8_Z24;
    case PIPE_FORMAT_YCBCR:
-      return &_mesa_texformat_ycbcr;
+      return MESA_FORMAT_YCBCR;
    case PIPE_FORMAT_YCBCR_REV:
-      return &_mesa_texformat_ycbcr_rev;
+      return MESA_FORMAT_YCBCR_REV;
 #if FEATURE_texture_s3tc
    case PIPE_FORMAT_DXT1_RGB:
-      return &_mesa_texformat_rgb_dxt1;
+      return MESA_FORMAT_RGB_DXT1;
    case PIPE_FORMAT_DXT1_RGBA:
-      return &_mesa_texformat_rgba_dxt1;
+      return MESA_FORMAT_RGBA_DXT1;
    case PIPE_FORMAT_DXT3_RGBA:
-      return &_mesa_texformat_rgba_dxt3;
+      return MESA_FORMAT_RGBA_DXT3;
    case PIPE_FORMAT_DXT5_RGBA:
-      return &_mesa_texformat_rgba_dxt5;
+      return MESA_FORMAT_RGBA_DXT5;
 #if FEATURE_EXT_texture_sRGB
    case PIPE_FORMAT_DXT1_SRGB:
-      return &_mesa_texformat_srgb_dxt1;
+      return MESA_FORMAT_SRGB_DXT1;
    case PIPE_FORMAT_DXT1_SRGBA:
-      return &_mesa_texformat_srgba_dxt1;
+      return MESA_FORMAT_SRGBA_DXT1;
    case PIPE_FORMAT_DXT3_SRGBA:
-      return &_mesa_texformat_srgba_dxt3;
+      return MESA_FORMAT_SRGBA_DXT3;
    case PIPE_FORMAT_DXT5_SRGBA:
-      return &_mesa_texformat_srgba_dxt5;
+      return MESA_FORMAT_SRGBA_DXT5;
 #endif
 #endif
 #if FEATURE_EXT_texture_sRGB
    case PIPE_FORMAT_A8L8_SRGB:
-      return &_mesa_texformat_sla8;
+      return MESA_FORMAT_SLA8;
    case PIPE_FORMAT_L8_SRGB:
-      return &_mesa_texformat_sl8;
+      return MESA_FORMAT_SL8;
    case PIPE_FORMAT_R8G8B8_SRGB:
-      return &_mesa_texformat_srgb8;
+      return MESA_FORMAT_SRGB8;
    case PIPE_FORMAT_R8G8B8A8_SRGB:
-      return &_mesa_texformat_srgba8;
+      return MESA_FORMAT_SRGBA8;
    case PIPE_FORMAT_A8R8G8B8_SRGB:
-      return &_mesa_texformat_sargb8;
+      return MESA_FORMAT_SARGB8;
 #endif
    /* XXX add additional cases */
    default:
       assert(0);
-      return NULL;
+      return MESA_FORMAT_NONE;
    }
 }
 
@@ -704,7 +804,7 @@ translate_gallium_format_to_mesa_format(enum pipe_format format)
 /**
  * Called via ctx->Driver.chooseTextureFormat().
  */
-const struct gl_texture_format *
+gl_format
 st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat,
                        GLenum format, GLenum type)
 {
@@ -716,7 +816,7 @@ st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat,
    pFormat = st_choose_format(ctx->st->pipe->screen, internalFormat,
                               PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_SAMPLER);
    if (pFormat == PIPE_FORMAT_NONE)
-      return NULL;
+      return MESA_FORMAT_NONE;
 
    return translate_gallium_format_to_mesa_format(pFormat);
 }
index e4a788c89bb2343a712bd36147f9caec6b046ea5..7cddf5aa66a7c4fe5e0ea7a2ddb7a000cf627308 100644 (file)
 #ifndef ST_FORMAT_H
 #define ST_FORMAT_H
 
+#include "main/formats.h"
 
 struct pipe_format_info
 {
    enum pipe_format format;
-   GLenum base_format;
+   gl_format mesa_format;
    GLenum datatype;
    GLubyte red_bits;
    GLubyte green_bits;
@@ -60,7 +61,10 @@ st_format_datatype(enum pipe_format format);
 
 
 extern enum pipe_format
-st_mesa_format_to_pipe_format(GLuint mesaFormat);
+st_mesa_format_to_pipe_format(gl_format mesaFormat);
+
+extern gl_format
+st_pipe_format_to_mesa_format(enum pipe_format pipeFormat);
 
 
 extern enum pipe_format
@@ -72,7 +76,7 @@ st_choose_renderbuffer_format(struct pipe_screen *screen,
                               GLenum internalFormat);
 
 
-extern const struct gl_texture_format *
+extern gl_format
 st_ChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
                        GLenum format, GLenum type);
 
index 5c0d335d62d14af55fd9a6750ece0d0304e3f062..a5d1ae3b034388dd713b35ee0ae7d82e20d84366 100644 (file)
@@ -52,6 +52,7 @@ st_create_framebuffer( const __GLcontextModes *visual,
    struct st_framebuffer *stfb = ST_CALLOC_STRUCT(st_framebuffer);
    if (stfb) {
       int samples = st_get_msaa();
+      int i;
 
       if (visual->sampleBuffers)
          samples = visual->samples;
@@ -119,6 +120,12 @@ st_create_framebuffer( const __GLcontextModes *visual,
          _mesa_add_renderbuffer(&stfb->Base, BUFFER_ACCUM, accumRb);
       }
 
+      for (i = 0; i < visual->numAuxBuffers; i++) {
+         struct gl_renderbuffer *aux
+            = st_new_renderbuffer_fb(colorFormat, 0, FALSE);
+         _mesa_add_renderbuffer(&stfb->Base, BUFFER_AUX0 + i, aux);
+      }
+
       stfb->Base.Initialized = GL_TRUE;
       stfb->InitWidth = width;
       stfb->InitHeight = height;
index 16ca2771b0fc93c975aadb9659c8cfc84932cd65..2c283d464ae40e63e216fbfb8ca7aa879419d6bb 100644 (file)
@@ -37,7 +37,9 @@
 #include "pipe/p_context.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_inlines.h"
+#include "util/u_format.h"
 #include "util/u_gen_mipmap.h"
+#include "util/u_math.h"
 
 #include "cso_cache/cso_cache.h"
 #include "cso_cache/cso_context.h"
@@ -133,29 +135,33 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target,
       srcTrans = st_cond_flush_get_tex_transfer(st_context(ctx), pt, face,
                                                srcLevel, zslice,
                                                PIPE_TRANSFER_READ, 0, 0,
-                                               pt->width[srcLevel],
-                                               pt->height[srcLevel]);
+                                               u_minify(pt->width0, srcLevel),
+                                               u_minify(pt->height0, srcLevel));
 
       dstTrans = st_cond_flush_get_tex_transfer(st_context(ctx), pt, face,
                                                dstLevel, zslice,
                                                PIPE_TRANSFER_WRITE, 0, 0,
-                                               pt->width[dstLevel],
-                                               pt->height[dstLevel]);
+                                               u_minify(pt->width0, dstLevel),
+                                               u_minify(pt->height0, dstLevel));
 
       srcData = (ubyte *) screen->transfer_map(screen, srcTrans);
       dstData = (ubyte *) screen->transfer_map(screen, dstTrans);
 
-      srcStride = srcTrans->stride / srcTrans->block.size;
-      dstStride = dstTrans->stride / dstTrans->block.size;
+      srcStride = srcTrans->stride / util_format_get_blocksize(srcTrans->texture->format);
+      dstStride = dstTrans->stride / util_format_get_blocksize(dstTrans->texture->format);
 
       _mesa_generate_mipmap_level(target, datatype, comps,
-                   0 /*border*/,
-                   pt->width[srcLevel], pt->height[srcLevel], pt->depth[srcLevel],
-                   srcData,
-                   srcStride, /* stride in texels */
-                   pt->width[dstLevel], pt->height[dstLevel], pt->depth[dstLevel],
-                   dstData,
-                   dstStride); /* stride in texels */
+                                  0 /*border*/,
+                                  u_minify(pt->width0, srcLevel),
+                                  u_minify(pt->height0, srcLevel),
+                                  u_minify(pt->depth0, srcLevel),
+                                  srcData,
+                                  srcStride, /* stride in texels */
+                                  u_minify(pt->width0, dstLevel),
+                                  u_minify(pt->height0, dstLevel),
+                                  u_minify(pt->depth0, dstLevel),
+                                  dstData,
+                                  dstStride); /* stride in texels */
 
       screen->transfer_unmap(screen, srcTrans);
       screen->transfer_unmap(screen, dstTrans);
@@ -219,6 +225,9 @@ st_generate_mipmap(GLcontext *ctx, GLenum target,
    /* find expected last mipmap level */
    lastLevel = compute_num_levels(ctx, texObj, target) - 1;
 
+   if (lastLevel == 0)
+      return;
+
    if (pt->last_level < lastLevel) {
       /* The current gallium texture doesn't have space for all the
        * mipmap levels we need to generate.  So allocate a new texture.
@@ -232,9 +241,9 @@ st_generate_mipmap(GLcontext *ctx, GLenum target,
                                     oldTex->target,
                                     oldTex->format,
                                     lastLevel,
-                                    oldTex->width[0],
-                                    oldTex->height[0],
-                                    oldTex->depth[0],
+                                    oldTex->width0,
+                                    oldTex->height0,
+                                    oldTex->depth0,
                                     oldTex->tex_usage);
 
       /* The texture isn't in a "complete" state yet so set the expected
@@ -269,9 +278,9 @@ st_generate_mipmap(GLcontext *ctx, GLenum target,
          = _mesa_get_tex_image(ctx, texObj, target, srcLevel);
       struct gl_texture_image *dstImage;
       struct st_texture_image *stImage;
-      uint dstWidth = pt->width[dstLevel];
-      uint dstHeight = pt->height[dstLevel];
-      uint dstDepth = pt->depth[dstLevel];
+      uint dstWidth = u_minify(pt->width0, dstLevel);
+      uint dstHeight = u_minify(pt->height0, dstLevel);
+      uint dstDepth = u_minify(pt->depth0, dstLevel); 
       uint border = srcImage->Border;
 
       dstImage = _mesa_get_tex_image(ctx, texObj, target, dstLevel);
index 70d7c4fee2e40bc67a6d94b1140d5ec9de2a9372..e788008dfe1d337c3e0bfbb7e02a21afde99c3c2 100644 (file)
@@ -160,13 +160,14 @@ dst_register( struct st_translate *t,
 static struct ureg_src
 src_register( struct st_translate *t,
               gl_register_file file,
-              GLuint index )
+              GLint index )
 {
    switch( file ) {
    case PROGRAM_UNDEFINED:
       return ureg_src_undef();
 
    case PROGRAM_TEMPORARY:
+      ASSERT(index >= 0);
       if (ureg_dst_is_undef(t->temps[index]))
          t->temps[index] = ureg_DECL_temporary( t->ureg );
       return ureg_src(t->temps[index]);
@@ -174,9 +175,15 @@ src_register( struct st_translate *t,
    case PROGRAM_STATE_VAR:
    case PROGRAM_NAMED_PARAM:
    case PROGRAM_ENV_PARAM:
+   case PROGRAM_LOCAL_PARAM:
    case PROGRAM_UNIFORM:
-   case PROGRAM_CONSTANT:       /* ie, immediate */
+      ASSERT(index >= 0);
       return t->constants[index];
+   case PROGRAM_CONSTANT:       /* ie, immediate */
+      if (index < 0)
+         return ureg_DECL_constant( t->ureg, 0 );
+      else
+         return t->constants[index];
 
    case PROGRAM_INPUT:
       return t->inputs[t->inputMapping[index]];
@@ -263,9 +270,14 @@ translate_src( struct st_translate *t,
    if (SrcReg->Abs) 
       src = ureg_abs(src);
 
-   if (SrcReg->RelAddr) 
+   if (SrcReg->RelAddr) {
       src = ureg_src_indirect( src, ureg_src(t->address[0]));
-   
+      /* If SrcReg->Index was negative, it was set to zero in
+       * src_register().  Reassign it now.
+       */
+      src.Index = SrcReg->Index;
+   }
+
    return src;
 }
 
@@ -278,7 +290,7 @@ static struct ureg_src swizzle_4v( struct ureg_src src,
 
 
 /**
- * Translate SWZ instructions into a single MAD.  EG:
+ * Translate a SWZ instruction into a MOV, MUL or MAD instruction.  EG:
  *
  *   SWZ dst, src.x-y10 
  * 
@@ -396,6 +408,23 @@ static void emit_swz( struct st_translate *t,
 }
 
 
+/**
+ * Negate the value of DDY to match GL semantics where (0,0) is the
+ * lower-left corner of the window.
+ * Note that the GL_ARB_fragment_coord_conventions extension will
+ * effect this someday.
+ */
+static void emit_ddy( struct st_translate *t,
+                      struct ureg_dst dst,
+                      const struct prog_src_register *SrcReg )
+{
+   struct ureg_program *ureg = t->ureg;
+   struct ureg_src src = translate_src( t, SrcReg );
+   src = ureg_negate( src );
+   ureg_DDY( ureg, dst, src );
+}
+
+
 
 static unsigned
 translate_opcode( unsigned op )
@@ -481,14 +510,6 @@ translate_opcode( unsigned op )
       return TGSI_OPCODE_MOV;
    case OPCODE_MUL:
       return TGSI_OPCODE_MUL;
-   case OPCODE_NOISE1:
-      return TGSI_OPCODE_NOISE1;
-   case OPCODE_NOISE2:
-      return TGSI_OPCODE_NOISE2;
-   case OPCODE_NOISE3:
-      return TGSI_OPCODE_NOISE3;
-   case OPCODE_NOISE4:
-      return TGSI_OPCODE_NOISE4;
    case OPCODE_NOP:
       return TGSI_OPCODE_NOP;
    case OPCODE_NRM3:
@@ -523,8 +544,6 @@ translate_opcode( unsigned op )
       return TGSI_OPCODE_SSG;
    case OPCODE_SUB:
       return TGSI_OPCODE_SUB;
-   case OPCODE_SWZ:
-      return TGSI_OPCODE_SWZ;
    case OPCODE_TEX:
       return TGSI_OPCODE_TEX;
    case OPCODE_TXB:
@@ -616,6 +635,23 @@ compile_instruction(
                  src, num_src );
       break;
 
+   case OPCODE_NOISE1:
+   case OPCODE_NOISE2:
+   case OPCODE_NOISE3:
+   case OPCODE_NOISE4:
+      /* At some point, a motivated person could add a better
+       * implementation of noise.  Currently not even the nvidia
+       * binary drivers do anything more than this.  In any case, the
+       * place to do this is in the GL state tracker, not the poor
+       * driver.
+       */
+      ureg_MOV( ureg, dst[0], ureg_imm1f(ureg, 0.5) );
+      break;
+                
+   case OPCODE_DDY:
+      emit_ddy( t, dst[0], &inst->SrcReg[0] );
+      break;
+
    default:
       ureg_insn( ureg, 
                  translate_opcode( inst->Opcode ), 
@@ -670,6 +706,41 @@ emit_inverted_wpos( struct st_translate *t,
 }
 
 
+/**
+ * OpenGL's fragment gl_FrontFace input is 1 for front-facing, 0 for back.
+ * TGSI uses +1 for front, -1 for back.
+ * This function converts the TGSI value to the GL value.  Simply clamping/
+ * saturating the value to [0,1] does the job.
+ */
+static void
+emit_face_var( struct st_translate *t,
+               const struct gl_program *program )
+{
+   struct ureg_program *ureg = t->ureg;
+   struct ureg_dst face_temp = ureg_DECL_temporary( ureg );
+   struct ureg_src face_input = t->inputs[t->inputMapping[FRAG_ATTRIB_FACE]];
+
+   /* MOV_SAT face_temp, input[face]
+    */
+   face_temp = ureg_saturate( face_temp );
+   ureg_MOV( ureg, face_temp, face_input );
+
+   /* Use face_temp as face input from here on:
+    */
+   t->inputs[t->inputMapping[FRAG_ATTRIB_FACE]] = ureg_src(face_temp);
+}
+
+static void
+emit_edgeflags( struct st_translate *t,
+                 const struct gl_program *program )
+{
+   struct ureg_program *ureg = t->ureg;
+   struct ureg_dst edge_dst = t->outputs[t->outputMapping[VERT_RESULT_EDGE]];
+   struct ureg_src edge_src = t->inputs[t->inputMapping[VERT_ATTRIB_EDGEFLAG]];
+
+   ureg_MOV( ureg, edge_dst, edge_src );
+}
+
 /**
  * Translate Mesa program to TGSI format.
  * \param program  the program to translate
@@ -689,26 +760,24 @@ emit_inverted_wpos( struct st_translate *t,
  *
  * \return  array of translated tokens, caller's responsibility to free
  */
-const struct tgsi_token *
+enum pipe_error
 st_translate_mesa_program(
    GLcontext *ctx,
    uint procType,
+   struct ureg_program *ureg,
    const struct gl_program *program,
    GLuint numInputs,
    const GLuint inputMapping[],
    const ubyte inputSemanticName[],
    const ubyte inputSemanticIndex[],
    const GLuint interpMode[],
-   const GLbitfield inputFlags[],
    GLuint numOutputs,
    const GLuint outputMapping[],
    const ubyte outputSemanticName[],
    const ubyte outputSemanticIndex[],
-   const GLbitfield outputFlags[] )
+   boolean passthrough_edgeflags )
 {
    struct st_translate translate, *t;
-   struct ureg_program *ureg;
-   const struct tgsi_token *tokens = NULL;
    unsigned i;
 
    t = &translate;
@@ -717,11 +786,7 @@ st_translate_mesa_program(
    t->procType = procType;
    t->inputMapping = inputMapping;
    t->outputMapping = outputMapping;
-   t->ureg = ureg_create( procType );
-   if (t->ureg == NULL)
-      return NULL;
-
-   ureg = t->ureg;
+   t->ureg = ureg;
 
    /*_mesa_print_program(program);*/
 
@@ -743,6 +808,10 @@ st_translate_mesa_program(
          emit_inverted_wpos( t, program );
       }
 
+      if (program->InputsRead & FRAG_BIT_FACE) {
+         emit_face_var( t, program );
+      }
+
       /*
        * Declare output attributes.
        */
@@ -777,6 +846,8 @@ st_translate_mesa_program(
                                            outputSemanticName[i],
                                            outputSemanticIndex[i] );
       }
+      if (passthrough_edgeflags)
+         emit_edgeflags( t, program );
    }
 
    /* Declare address register.
@@ -800,6 +871,7 @@ st_translate_mesa_program(
       for (i = 0; i < program->Parameters->NumParameters; i++) {
          switch (program->Parameters->Parameters[i].Type) {
          case PROGRAM_ENV_PARAM:
+         case PROGRAM_LOCAL_PARAM:
          case PROGRAM_STATE_VAR:
          case PROGRAM_NAMED_PARAM:
          case PROGRAM_UNIFORM:
@@ -848,8 +920,7 @@ st_translate_mesa_program(
                         t->insn[t->labels[i].branch_target] );
    }
 
-   tokens = ureg_get_tokens( ureg, NULL );
-   ureg_destroy( ureg );
+   return PIPE_OK;
 
 out:
    FREE(t->insn);
@@ -858,17 +929,9 @@ out:
 
    if (t->error) {
       debug_printf("%s: translate error flag set\n", __FUNCTION__);
-      FREE((void *)tokens);
-      tokens = NULL;
-   }
-
-   if (!tokens) {
-      debug_printf("%s: failed to translate Mesa program:\n", __FUNCTION__);
-      _mesa_print_program(program);
-      debug_assert(0);
    }
 
-   return tokens;
+   return PIPE_ERROR_OUT_OF_MEMORY;
 }
 
 
index c0d1ff59e1f9f76c7c193ebb6e1c24d08c3f0afa..e3c5bd1d94db6e3d6f2e78cab0306e2146d9ac88 100644 (file)
@@ -30,6 +30,7 @@
 #define ST_MESA_TO_TGSI_H
 
 #include "main/mtypes.h"
+#include "tgsi/tgsi_ureg.h"
 
 
 #if defined __cplusplus
@@ -39,22 +40,22 @@ extern "C" {
 struct tgsi_token;
 struct gl_program;
 
-const struct tgsi_token *
+enum pipe_error
 st_translate_mesa_program(
    GLcontext *ctx,
    uint procType,
+   struct ureg_program *ureg,
    const struct gl_program *program,
    GLuint numInputs,
    const GLuint inputMapping[],
    const ubyte inputSemanticName[],
    const ubyte inputSemanticIndex[],
    const GLuint interpMode[],
-   const GLbitfield inputFlags[],
    GLuint numOutputs,
    const GLuint outputMapping[],
    const ubyte outputSemanticName[],
    const ubyte outputSemanticIndex[],
-   const GLbitfield outputFlags[] );
+   boolean passthrough_edgeflags );
 
 void
 st_free_tokens(const struct tgsi_token *tokens);
index a9be80ce8f31be68bae8b197ad40e3397d5c4439..6a869fae90443455d20b01c90ecc96b43838629e 100644 (file)
 #include "cso_cache/cso_context.h"
 
 
+
+/**
+ * Clean out any old compilations:
+ */
+void
+st_vp_release_varients( struct st_context *st,
+                        struct st_vertex_program *stvp )
+{
+   struct st_vp_varient *vpv;
+
+   for (vpv = stvp->varients; vpv; ) {
+      struct st_vp_varient *next = vpv->next;
+
+      if (vpv->driver_shader) 
+         cso_delete_vertex_shader(st->cso_context, vpv->driver_shader);
+      
+      if (vpv->draw_shader)
+         draw_delete_vertex_shader( st->draw, vpv->draw_shader );
+      
+      if (vpv->state.tokens)
+         st_free_tokens(vpv->state.tokens);
+      
+      FREE( vpv );
+
+      vpv = next;
+   }
+
+   stvp->varients = NULL;
+}
+
+
+
+
 /**
  * Translate a Mesa vertex shader into a TGSI shader.
  * \param outputMapping  to map vertex program output registers (VERT_RESULT_x)
  * \return  pointer to cached pipe_shader object.
  */
 void
-st_translate_vertex_program(struct st_context *st,
-                            struct st_vertex_program *stvp,
-                            const GLuint outputMapping[],
-                            const ubyte *outputSemanticName,
-                            const ubyte *outputSemanticIndex)
+st_prepare_vertex_program(struct st_context *st,
+                            struct st_vertex_program *stvp)
 {
-   struct pipe_context *pipe = st->pipe;
-   GLuint defaultOutputMapping[VERT_RESULT_MAX];
-   GLuint attr, i;
-   GLuint num_generic = 0;
-
-   ubyte vs_input_semantic_name[PIPE_MAX_SHADER_INPUTS];
-   ubyte vs_input_semantic_index[PIPE_MAX_SHADER_INPUTS];
-   uint vs_num_inputs = 0;
-
-   ubyte vs_output_semantic_name[PIPE_MAX_SHADER_OUTPUTS];
-   ubyte vs_output_semantic_index[PIPE_MAX_SHADER_OUTPUTS];
-   uint vs_num_outputs = 0;
-
-   GLbitfield input_flags[MAX_PROGRAM_INPUTS];
-   GLbitfield output_flags[MAX_PROGRAM_OUTPUTS];
+   GLuint attr;
 
-//   memset(&vs, 0, sizeof(vs));
-   memset(input_flags, 0, sizeof(input_flags));
-   memset(output_flags, 0, sizeof(output_flags));
+   stvp->num_inputs = 0;
+   stvp->num_outputs = 0;
 
    if (stvp->Base.IsPositionInvariant)
       _mesa_insert_mvp_code(st->ctx, &stvp->Base);
 
+   assert(stvp->Base.Base.NumInstructions > 1);
+
    /*
     * Determine number of inputs, the mappings between VERT_ATTRIB_x
     * and TGSI generic input indexes, plus input attrib semantic info.
     */
    for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
       if (stvp->Base.Base.InputsRead & (1 << attr)) {
-         const GLuint slot = vs_num_inputs;
-
-         vs_num_inputs++;
-
-         stvp->input_to_index[attr] = slot;
-         stvp->index_to_input[slot] = attr;
-
-         switch (attr) {
-         case VERT_ATTRIB_POS:
-            vs_input_semantic_name[slot] = TGSI_SEMANTIC_POSITION;
-            vs_input_semantic_index[slot] = 0;
-            break;
-         case VERT_ATTRIB_WEIGHT:
-            /* fall-through */
-         case VERT_ATTRIB_NORMAL:
-            /* just label as a generic */
-            vs_input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
-            vs_input_semantic_index[slot] = 0;
-            break;
-         case VERT_ATTRIB_COLOR0:
-            vs_input_semantic_name[slot] = TGSI_SEMANTIC_COLOR;
-            vs_input_semantic_index[slot] = 0;
-            break;
-         case VERT_ATTRIB_COLOR1:
-            vs_input_semantic_name[slot] = TGSI_SEMANTIC_COLOR;
-            vs_input_semantic_index[slot] = 1;
-            break;
-         case VERT_ATTRIB_FOG:
-            vs_input_semantic_name[slot] = TGSI_SEMANTIC_FOG;
-            vs_input_semantic_index[slot] = 0;
-            break;
-         case VERT_ATTRIB_POINT_SIZE:
-            vs_input_semantic_name[slot] = TGSI_SEMANTIC_PSIZE;
-            vs_input_semantic_index[slot] = 0;
-            break;
-         case VERT_ATTRIB_TEX0:
-         case VERT_ATTRIB_TEX1:
-         case VERT_ATTRIB_TEX2:
-         case VERT_ATTRIB_TEX3:
-         case VERT_ATTRIB_TEX4:
-         case VERT_ATTRIB_TEX5:
-         case VERT_ATTRIB_TEX6:
-         case VERT_ATTRIB_TEX7:
-            assert(slot < Elements(vs_input_semantic_name));
-            vs_input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
-            vs_input_semantic_index[slot] = num_generic++;
-            break;
-         case VERT_ATTRIB_GENERIC0:
-         case VERT_ATTRIB_GENERIC1:
-         case VERT_ATTRIB_GENERIC2:
-         case VERT_ATTRIB_GENERIC3:
-         case VERT_ATTRIB_GENERIC4:
-         case VERT_ATTRIB_GENERIC5:
-         case VERT_ATTRIB_GENERIC6:
-         case VERT_ATTRIB_GENERIC7:
-         case VERT_ATTRIB_GENERIC8:
-         case VERT_ATTRIB_GENERIC9:
-         case VERT_ATTRIB_GENERIC10:
-         case VERT_ATTRIB_GENERIC11:
-         case VERT_ATTRIB_GENERIC12:
-         case VERT_ATTRIB_GENERIC13:
-         case VERT_ATTRIB_GENERIC14:
-         case VERT_ATTRIB_GENERIC15:
-            assert(attr < VERT_ATTRIB_MAX);
-            assert(slot < Elements(vs_input_semantic_name));
-            vs_input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
-            vs_input_semantic_index[slot] = num_generic++;
-            break;
-         default:
-            assert(0);
-         }
-
-         input_flags[slot] = stvp->Base.Base.InputFlags[attr];
-      }
-   }
-
-#if 0
-   if (outputMapping && outputSemanticName) {
-      printf("VERT_RESULT  written  out_slot  semantic_name  semantic_index\n");
-      for (attr = 0; attr < VERT_RESULT_MAX; attr++) {
-         printf("    %-2d          %c       %3d          %2d              %2d\n",
-                attr, 
-                ((stvp->Base.Base.OutputsWritten & (1 << attr)) ? 'Y' : ' '),
-                outputMapping[attr],
-                outputSemanticName[attr],
-                outputSemanticIndex[attr]);
+         stvp->input_to_index[attr] = stvp->num_inputs;
+         stvp->index_to_input[stvp->num_inputs] = attr;
+         stvp->num_inputs++;
       }
    }
-#endif
-
-   /* initialize output semantics to defaults */
-   for (i = 0; i < PIPE_MAX_SHADER_OUTPUTS; i++) {
-      assert(i < Elements(vs_output_semantic_name));
-      vs_output_semantic_name[i] = TGSI_SEMANTIC_GENERIC;
-      vs_output_semantic_index[i] = 0;
-      output_flags[i] = 0x0;
-   }
+   /* bit of a hack, presetup potentially unused edgeflag input */
+   stvp->input_to_index[VERT_ATTRIB_EDGEFLAG] = stvp->num_inputs;
+   stvp->index_to_input[stvp->num_inputs] = VERT_ATTRIB_EDGEFLAG;
 
-   num_generic = 0;
-   /*
-    * Determine number of outputs, the (default) output register
-    * mapping and the semantic information for each output.
+   /* Compute mapping of vertex program outputs to slots.
     */
    for (attr = 0; attr < VERT_RESULT_MAX; attr++) {
-      if (stvp->Base.Base.OutputsWritten & (1 << attr)) {
-         GLuint slot;
-
-         /* XXX
-          * Pass in the fragment program's input's semantic info.
-          * Use the generic semantic indexes from there, instead of
-          * guessing below.
-          */
-
-         if (outputMapping) {
-            slot = outputMapping[attr];
-            assert(slot != ~0);
-         }
-         else {
-            slot = vs_num_outputs;
-            vs_num_outputs++;
-            defaultOutputMapping[attr] = slot;
-         }
+      if ((stvp->Base.Base.OutputsWritten & (1 << attr)) == 0) {
+         stvp->result_to_output[attr] = ~0;
+      }
+      else {
+         unsigned slot = stvp->num_outputs++;
+
+         stvp->result_to_output[attr] = slot;
 
          switch (attr) {
          case VERT_RESULT_HPOS:
-            assert(slot == 0);
-            vs_output_semantic_name[slot] = TGSI_SEMANTIC_POSITION;
-            vs_output_semantic_index[slot] = 0;
+            stvp->output_semantic_name[slot] = TGSI_SEMANTIC_POSITION;
+            stvp->output_semantic_index[slot] = 0;
             break;
          case VERT_RESULT_COL0:
-            vs_output_semantic_name[slot] = TGSI_SEMANTIC_COLOR;
-            vs_output_semantic_index[slot] = 0;
+            stvp->output_semantic_name[slot] = TGSI_SEMANTIC_COLOR;
+            stvp->output_semantic_index[slot] = 0;
             break;
          case VERT_RESULT_COL1:
-            vs_output_semantic_name[slot] = TGSI_SEMANTIC_COLOR;
-            vs_output_semantic_index[slot] = 1;
+            stvp->output_semantic_name[slot] = TGSI_SEMANTIC_COLOR;
+            stvp->output_semantic_index[slot] = 1;
             break;
          case VERT_RESULT_BFC0:
-            vs_output_semantic_name[slot] = TGSI_SEMANTIC_BCOLOR;
-            vs_output_semantic_index[slot] = 0;
+            stvp->output_semantic_name[slot] = TGSI_SEMANTIC_BCOLOR;
+            stvp->output_semantic_index[slot] = 0;
             break;
          case VERT_RESULT_BFC1:
-            vs_output_semantic_name[slot] = TGSI_SEMANTIC_BCOLOR;
-            vs_output_semantic_index[slot] = 1;
+            stvp->output_semantic_name[slot] = TGSI_SEMANTIC_BCOLOR;
+            stvp->output_semantic_index[slot] = 1;
             break;
          case VERT_RESULT_FOGC:
-            vs_output_semantic_name[slot] = TGSI_SEMANTIC_FOG;
-            vs_output_semantic_index[slot] = 0;
+            stvp->output_semantic_name[slot] = TGSI_SEMANTIC_FOG;
+            stvp->output_semantic_index[slot] = 0;
             break;
          case VERT_RESULT_PSIZ:
-            vs_output_semantic_name[slot] = TGSI_SEMANTIC_PSIZE;
-            vs_output_semantic_index[slot] = 0;
+            stvp->output_semantic_name[slot] = TGSI_SEMANTIC_PSIZE;
+            stvp->output_semantic_index[slot] = 0;
             break;
          case VERT_RESULT_EDGE:
             assert(0);
             break;
+
          case VERT_RESULT_TEX0:
          case VERT_RESULT_TEX1:
          case VERT_RESULT_TEX2:
@@ -257,92 +171,79 @@ st_translate_vertex_program(struct st_context *st,
          case VERT_RESULT_TEX5:
          case VERT_RESULT_TEX6:
          case VERT_RESULT_TEX7:
-            /* fall-through */
+            stvp->output_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
+            stvp->output_semantic_index[slot] = attr - VERT_RESULT_TEX0;
+            break;
+
          case VERT_RESULT_VAR0:
-            /* fall-through */
          default:
-            assert(slot < Elements(vs_output_semantic_name));
-            if (outputSemanticName) {
-               /* use provided semantic into */
-               assert(outputSemanticName[attr] != TGSI_SEMANTIC_COUNT);
-               vs_output_semantic_name[slot] = outputSemanticName[attr];
-               vs_output_semantic_index[slot] = outputSemanticIndex[attr];
-            }
-            else {
-               /* use default semantic info */
-               vs_output_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
-               vs_output_semantic_index[slot] = num_generic++;
-            }
+            assert(attr < VERT_RESULT_MAX);
+            stvp->output_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
+            stvp->output_semantic_index[slot] = (FRAG_ATTRIB_VAR0 - 
+                                                FRAG_ATTRIB_TEX0 +
+                                                attr - 
+                                                VERT_RESULT_VAR0);
+            break;
          }
-
-         assert(slot < Elements(output_flags));
-         output_flags[slot] = stvp->Base.Base.OutputFlags[attr];
       }
    }
+   /* similar hack to above, presetup potentially unused edgeflag output */
+   stvp->result_to_output[VERT_RESULT_EDGE] = stvp->num_outputs;
+   stvp->output_semantic_name[stvp->num_outputs] = TGSI_SEMANTIC_EDGEFLAG;
+   stvp->output_semantic_index[stvp->num_outputs] = 0;
+}
 
-   if (outputMapping) {
-      /* find max output slot referenced to compute vs_num_outputs */
-      GLuint maxSlot = 0;
-      for (attr = 0; attr < VERT_RESULT_MAX; attr++) {
-         if (outputMapping[attr] != ~0 && outputMapping[attr] > maxSlot)
-            maxSlot = outputMapping[attr];
-      }
-      vs_num_outputs = maxSlot + 1;
-   }
-   else {
-      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) {
-      st_free_tokens(stvp->state.tokens);
-      stvp->state.tokens = NULL;
-   }
-   if (stvp->driver_shader) {
-      cso_delete_vertex_shader(st->cso_context, stvp->driver_shader);
-      stvp->driver_shader = NULL;
+struct st_vp_varient *
+st_translate_vertex_program(struct st_context *st,
+                            struct st_vertex_program *stvp,
+                            const struct st_vp_varient_key *key)
+{
+   struct st_vp_varient *vpv = CALLOC_STRUCT(st_vp_varient);
+   struct pipe_context *pipe = st->pipe;
+   struct ureg_program *ureg;
+   enum pipe_error error;
+   unsigned num_outputs;
+
+   ureg = ureg_create( TGSI_PROCESSOR_VERTEX );
+   if (ureg == NULL)
+      return NULL;
+
+   vpv->num_inputs = stvp->num_inputs;
+   num_outputs = stvp->num_outputs;
+   if (key->passthrough_edgeflags) {
+      vpv->num_inputs++;
+      num_outputs++;
    }
 
-   stvp->state.tokens = 
+   error = 
       st_translate_mesa_program(st->ctx,
                                 TGSI_PROCESSOR_VERTEX,
+                                ureg,
                                 &stvp->Base.Base,
                                 /* inputs */
-                                vs_num_inputs,
+                                vpv->num_inputs,
                                 stvp->input_to_index,
-                                vs_input_semantic_name,
-                                vs_input_semantic_index,
+                                NULL, /* input semantic name */
+                                NULL, /* input semantic index */
                                 NULL,
-                                input_flags,
                                 /* outputs */
-                                vs_num_outputs,
-                                outputMapping,
-                                vs_output_semantic_name,
-                                vs_output_semantic_index,
-                                output_flags );
+                                num_outputs,
+                                stvp->result_to_output,
+                                stvp->output_semantic_name,
+                                stvp->output_semantic_index,
+                                key->passthrough_edgeflags );
 
-   stvp->num_inputs = vs_num_inputs;
-   stvp->driver_shader = pipe->create_vs_state(pipe, &stvp->state);
+   if (error)
+      goto fail;
+
+   vpv->state.tokens = ureg_get_tokens( ureg, NULL );
+   if (!vpv->state.tokens)
+      goto fail;
+
+   ureg_destroy( ureg );
+
+   vpv->driver_shader = pipe->create_vs_state(pipe, &vpv->state);
 
    if ((ST_DEBUG & DEBUG_TGSI) && (ST_DEBUG & DEBUG_MESA)) {
       _mesa_print_program(&stvp->Base.Base);
@@ -350,9 +251,19 @@ st_translate_vertex_program(struct st_context *st,
    }
 
    if (ST_DEBUG & DEBUG_TGSI) {
-      tgsi_dump( stvp->state.tokens, 0 );
+      tgsi_dump( vpv->state.tokens, 0 );
       debug_printf("\n");
    }
+
+   return vpv;
+
+fail:
+   debug_printf("%s: failed to translate Mesa program:\n", __FUNCTION__);
+   _mesa_print_program(&stvp->Base.Base);
+   debug_assert(0);
+
+   ureg_destroy( ureg );
+   return NULL;
 }
 
 
@@ -373,9 +284,10 @@ st_translate_fragment_program(struct st_context *st,
    GLuint defaultInputMapping[FRAG_ATTRIB_MAX];
    GLuint interpMode[16];  /* XXX size? */
    GLuint attr;
+   enum pipe_error error;
    const GLbitfield inputsRead = stfp->Base.Base.InputsRead;
+   struct ureg_program *ureg;
    GLuint vslot = 0;
-   GLuint num_generic = 0;
 
    uint fs_num_inputs = 0;
 
@@ -383,13 +295,6 @@ st_translate_fragment_program(struct st_context *st,
    ubyte fs_output_semantic_index[PIPE_MAX_SHADER_OUTPUTS];
    uint fs_num_outputs = 0;
 
-   GLbitfield input_flags[MAX_PROGRAM_INPUTS];
-   GLbitfield output_flags[MAX_PROGRAM_OUTPUTS];
-
-//   memset(&fs, 0, sizeof(fs));
-   memset(input_flags, 0, sizeof(input_flags));
-   memset(output_flags, 0, sizeof(output_flags));
-
    /* which vertex output goes to the first fragment input: */
    if (inputsRead & FRAG_BIT_WPOS)
       vslot = 0;
@@ -432,14 +337,25 @@ st_translate_fragment_program(struct st_context *st,
             break;
          case FRAG_ATTRIB_FACE:
             stfp->input_semantic_name[slot] = TGSI_SEMANTIC_FACE;
-            stfp->input_semantic_index[slot] = num_generic++;
+            stfp->input_semantic_index[slot] = 0;
             interpMode[slot] = TGSI_INTERPOLATE_CONSTANT;
             break;
-         case FRAG_ATTRIB_PNTC:
-            stfp->input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
-            stfp->input_semantic_index[slot] = num_generic++;
-            interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE;
-            break;
+
+            /* In most cases, there is nothing special about these
+             * inputs, so adopt a convention to use the generic
+             * semantic name and the mesa FRAG_ATTRIB_ number as the
+             * index. 
+             * 
+             * All that is required is that the vertex shader labels
+             * its own outputs similarly, and that the vertex shader
+             * generates at least every output required by the
+             * fragment shader plus fixed-function hardware (such as
+             * BFC).
+             * 
+             * There is no requirement that semantic indexes start at
+             * zero or be restricted to a particular range -- nobody
+             * should be building tables based on semantic index.
+             */
          case FRAG_ATTRIB_TEX0:
          case FRAG_ATTRIB_TEX1:
          case FRAG_ATTRIB_TEX2:
@@ -448,19 +364,18 @@ st_translate_fragment_program(struct st_context *st,
          case FRAG_ATTRIB_TEX5:
          case FRAG_ATTRIB_TEX6:
          case FRAG_ATTRIB_TEX7:
-            stfp->input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
-            stfp->input_semantic_index[slot] = num_generic++;
-            interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE;
-            break;
+         case FRAG_ATTRIB_PNTC:
          case FRAG_ATTRIB_VAR0:
-            /* fall-through */
          default:
+            /* Actually, let's try and zero-base this just for
+             * readability of the generated TGSI.
+             */
+            assert(attr >= FRAG_ATTRIB_TEX0);
+            stfp->input_semantic_index[slot] = (attr - FRAG_ATTRIB_TEX0);
             stfp->input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
-            stfp->input_semantic_index[slot] = num_generic++;
             interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE;
+            break;
          }
-
-         input_flags[slot] = stfp->Base.Base.InputFlags[attr];
       }
    }
 
@@ -469,7 +384,7 @@ st_translate_fragment_program(struct st_context *st,
     */
    {
       uint numColors = 0;
-      GLbitfield outputsWritten = stfp->Base.Base.OutputsWritten;
+      GLbitfield64 outputsWritten = stfp->Base.Base.OutputsWritten;
 
       /* if z is written, emit that first */
       if (outputsWritten & (1 << FRAG_RESULT_DEPTH)) {
@@ -498,8 +413,6 @@ st_translate_fragment_program(struct st_context *st,
                break;
             }
 
-            output_flags[fs_num_outputs] = stfp->Base.Base.OutputFlags[attr];
-
             fs_num_outputs++;
          }
       }
@@ -508,9 +421,15 @@ st_translate_fragment_program(struct st_context *st,
    if (!inputMapping)
       inputMapping = defaultInputMapping;
 
-   stfp->state.tokens = 
+   ureg = ureg_create( TGSI_PROCESSOR_FRAGMENT );
+   if (ureg == NULL)
+      return;
+
+
+   error = 
       st_translate_mesa_program(st->ctx,
                                 TGSI_PROCESSOR_FRAGMENT,
+                                ureg,
                                 &stfp->Base.Base,
                                 /* inputs */
                                 fs_num_inputs,
@@ -518,14 +437,14 @@ st_translate_fragment_program(struct st_context *st,
                                 stfp->input_semantic_name,
                                 stfp->input_semantic_index,
                                 interpMode,
-                                input_flags,
                                 /* outputs */
                                 fs_num_outputs,
                                 outputMapping,
                                 fs_output_semantic_name,
-                                fs_output_semantic_index,
-                                output_flags );
+                                fs_output_semantic_index, FALSE );
 
+   stfp->state.tokens = ureg_get_tokens( ureg, NULL );
+   ureg_destroy( ureg );
    stfp->driver_shader = pipe->create_fs_state(pipe, &stfp->state);
 
    if ((ST_DEBUG & DEBUG_TGSI) && (ST_DEBUG & DEBUG_MESA)) {
index e2e5eddef22c170bc0e86de2dcca2d928d42a012..6b9a9226df583b0de95b340d1ab59a5dacafd384 100644 (file)
@@ -64,41 +64,73 @@ struct st_fragment_program
    struct pipe_shader_state state;
    void *driver_shader;
 
-   GLuint param_state;
-
-   /** List of vertex programs which have been translated such that their
-    * outputs match this fragment program's inputs.
-    */
-   struct translated_vertex_program *vertex_programs;
-
    /** Program prefixed with glBitmap prologue */
    struct st_fragment_program *bitmap_program;
    uint bitmap_sampler;
 };
 
 
+
+struct st_vp_varient_key
+{
+   boolean passthrough_edgeflags;
+};
+
+
+/**
+ * This represents a vertex program, especially translated to match
+ * the inputs of a particular fragment shader.
+ */
+struct st_vp_varient
+{
+   /* Parameters which generated this translated version of a vertex
+    * shader:
+    */
+   struct st_vp_varient_key key;
+
+   /** TGSI tokens -- why?
+    */
+   struct pipe_shader_state state;
+
+   /** Driver's compiled shader */
+   void *driver_shader;
+
+   /** For using our private draw module (glRasterPos) */
+   struct draw_vertex_shader *draw_shader;
+
+   /** Next in linked list */
+   struct st_vp_varient *next;  
+
+   /** similar to that in st_vertex_program, but with information about edgeflags too */
+   GLuint num_inputs;
+};
+
+
+
+
 /**
  * Derived from Mesa gl_fragment_program:
  */
 struct st_vertex_program
 {
    struct gl_vertex_program Base;  /**< The Mesa vertex program */
-   GLuint serialNo;
+   GLuint serialNo, lastSerialNo;
 
    /** maps a Mesa VERT_ATTRIB_x to a packed TGSI input index */
    GLuint input_to_index[VERT_ATTRIB_MAX];
    /** maps a TGSI input index back to a Mesa VERT_ATTRIB_x */
    GLuint index_to_input[PIPE_MAX_SHADER_INPUTS];
-
    GLuint num_inputs;
 
-   struct pipe_shader_state state;
-   void *driver_shader;
+   /** Maps VERT_RESULT_x to slot */
+   GLuint result_to_output[VERT_RESULT_MAX];
+   ubyte output_semantic_name[VERT_RESULT_MAX];
+   ubyte output_semantic_index[VERT_RESULT_MAX];
+   GLuint num_outputs;
 
-   /** For using our private draw module (glRasterPos) */
-   struct draw_vertex_shader *draw_shader;
-
-   GLuint param_state;
+   /** List of translated varients of this vertex program.
+    */
+   struct st_vp_varient *varients;
 };
 
 
@@ -143,13 +175,21 @@ st_translate_fragment_program(struct st_context *st,
                               const GLuint inputMapping[]);
 
 
+/* Called after program string change, discard all previous
+ * compilation results.
+ */
 extern void
+st_prepare_vertex_program(struct st_context *st,
+                          struct st_vertex_program *stvp);
+
+extern struct st_vp_varient *
 st_translate_vertex_program(struct st_context *st,
-                            struct st_vertex_program *vp,
-                            const GLuint vert_output_to_slot[],
-                            const ubyte *fs_input_semantic_name,
-                            const ubyte *fs_input_semantic_index);
+                            struct st_vertex_program *stvp,
+                            const struct st_vp_varient_key *key);
 
+void
+st_vp_release_varients( struct st_context *st,
+                        struct st_vertex_program *stvp );
 
 extern void
 st_print_shaders(GLcontext *ctx);
index ba8d1e8cc160c4b6543a8aec946e738ceaf17fed..8a3e4cd3ac3d3807e6b67f0b83ee5e3c7d14e720 100644 (file)
@@ -32,8 +32,9 @@
 #include "st_cb_fbo.h"
 #include "st_inlines.h"
 #include "main/enums.h"
-#include "main/texobj.h"
+#include "main/texfetch.h"
 #include "main/teximage.h"
+#include "main/texobj.h"
 #include "main/texstore.h"
 
 #undef Elements  /* fix re-defined macro warning */
@@ -42,7 +43,9 @@
 #include "pipe/p_context.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_inlines.h"
+#include "util/u_format.h"
 #include "util/u_rect.h"
+#include "util/u_math.h"
 
 
 #define DBG if(0) printf
@@ -99,10 +102,9 @@ st_texture_create(struct st_context *st,
    pt.target = target;
    pt.format = format;
    pt.last_level = last_level;
-   pt.width[0] = width0;
-   pt.height[0] = height0;
-   pt.depth[0] = depth0;
-   pf_get_block(format, &pt.block);
+   pt.width0 = width0;
+   pt.height0 = height0;
+   pt.depth0 = depth0;
    pt.tex_usage = usage;
 
    newtex = screen->texture_create(screen, &pt);
@@ -128,15 +130,15 @@ st_texture_match_image(const struct pipe_texture *pt,
 
    /* Check if this image's format matches the established texture's format.
     */
-   if (st_mesa_format_to_pipe_format(image->TexFormat->MesaFormat) != pt->format)
+   if (st_mesa_format_to_pipe_format(image->TexFormat) != pt->format)
       return GL_FALSE;
 
    /* Test if this image's size matches what's expected in the
     * established texture.
     */
-   if (image->Width != pt->width[level] ||
-       image->Height != pt->height[level] ||
-       image->Depth != pt->depth[level])
+   if (image->Width != u_minify(pt->width0, level) ||
+       image->Height != u_minify(pt->height0, level) ||
+       image->Depth != u_minify(pt->depth0, level))
       return GL_FALSE;
 
    return GL_TRUE;
@@ -240,8 +242,9 @@ st_surface_data(struct pipe_context *pipe,
    struct pipe_screen *screen = pipe->screen;
    void *map = screen->transfer_map(screen, dst);
 
+   assert(dst->texture);
    util_copy_rect(map,
-                  &dst->block,
+                  dst->texture->format,
                   dst->stride,
                   dstx, dsty, 
                   width, height, 
@@ -264,7 +267,7 @@ st_texture_image_data(struct st_context *st,
 {
    struct pipe_context *pipe = st->pipe;
    struct pipe_screen *screen = pipe->screen;
-   GLuint depth = dst->depth[level];
+   GLuint depth = u_minify(dst->depth0, level);
    GLuint i;
    const GLubyte *srcUB = src;
    struct pipe_transfer *dst_transfer;
@@ -274,15 +277,16 @@ st_texture_image_data(struct st_context *st,
    for (i = 0; i < depth; i++) {
       dst_transfer = st_no_flush_get_tex_transfer(st, dst, face, level, i,
                                                  PIPE_TRANSFER_WRITE, 0, 0,
-                                                 dst->width[level],
-                                                 dst->height[level]);
+                                                 u_minify(dst->width0, level),
+                                                  u_minify(dst->height0, level));
 
       st_surface_data(pipe, dst_transfer,
                      0, 0,                             /* dstx, dsty */
                      srcUB,
                      src_row_stride,
                      0, 0,                             /* source x, y */
-                     dst->width[level], dst->height[level]);       /* width, height */
+                     u_minify(dst->width0, level),
+                      u_minify(dst->height0, level));      /* width, height */
 
       screen->tex_transfer_destroy(dst_transfer);
 
@@ -300,9 +304,9 @@ st_texture_image_copy(struct pipe_context *pipe,
                       GLuint face)
 {
    struct pipe_screen *screen = pipe->screen;
-   GLuint width = dst->width[dstLevel];
-   GLuint height = dst->height[dstLevel];
-   GLuint depth = dst->depth[dstLevel];
+   GLuint width = u_minify(dst->width0, dstLevel); 
+   GLuint height = u_minify(dst->height0, dstLevel); 
+   GLuint depth = u_minify(dst->depth0, dstLevel); 
    struct pipe_surface *src_surface;
    struct pipe_surface *dst_surface;
    GLuint i;
@@ -312,13 +316,13 @@ st_texture_image_copy(struct pipe_context *pipe,
 
       /* find src texture level of needed size */
       for (srcLevel = 0; srcLevel <= src->last_level; srcLevel++) {
-         if (src->width[srcLevel] == width &&
-             src->height[srcLevel] == height) {
+         if (u_minify(src->width0, srcLevel) == width &&
+             u_minify(src->height0, srcLevel) == height) {
             break;
          }
       }
-      assert(src->width[srcLevel] == width);
-      assert(src->height[srcLevel] == height);
+      assert(u_minify(src->width0, srcLevel) == width);
+      assert(u_minify(src->height0, srcLevel) == height);
 
 #if 0
       {
@@ -342,12 +346,21 @@ st_texture_image_copy(struct pipe_context *pipe,
       src_surface = screen->get_tex_surface(screen, src, face, srcLevel, i,
                                             PIPE_BUFFER_USAGE_GPU_READ);
 
-      pipe->surface_copy(pipe,
-                        dst_surface,
-                        0, 0, /* destX, Y */
-                        src_surface,
-                        0, 0, /* srcX, Y */
-                        width, height);
+      if (pipe->surface_copy) {
+         pipe->surface_copy(pipe,
+                           dst_surface,
+                           0, 0, /* destX, Y */
+                           src_surface,
+                           0, 0, /* srcX, Y */
+                           width, height);
+      } else {
+         util_surface_copy(pipe, FALSE,
+                          dst_surface,
+                          0, 0, /* destX, Y */
+                          src_surface,
+                          0, 0, /* srcX, Y */
+                          width, height);
+      }
 
       pipe_surface_reference(&src_surface, NULL);
       pipe_surface_reference(&dst_surface, NULL);
@@ -393,7 +406,7 @@ st_bind_texture_surface(struct pipe_surface *ps, int target, int level,
    }
 
    /* map pipe format to base format for now */
-   if (pf_get_component_bits(format, PIPE_FORMAT_COMP_A) > 0)
+   if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 3) > 0)
       internalFormat = GL_RGBA;
    else
       internalFormat = GL_RGB;
@@ -578,5 +591,5 @@ st_teximage_flush_before_map(struct st_context *st,
 
    if (referenced && ((referenced & PIPE_REFERENCED_FOR_WRITE) ||
                      (usage & PIPE_TRANSFER_WRITE)))
-      st_flush(st, PIPE_FLUSH_RENDER_CACHE, NULL);
+      st->pipe->flush(st->pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
 }
index c6c7dbf5cf0e32082f3c8739c0488b43f45d5cd2..0e0876efcba78afa8d4225d950b92ddfeb697b7d 100644 (file)
@@ -436,10 +436,6 @@ accum_return(GLcontext *ctx, GLfloat value,
    struct gl_renderbuffer *accumRb = fb->Attachment[BUFFER_ACCUM].Renderbuffer;
    const GLboolean directAccess
       = (accumRb->GetPointer(ctx, accumRb, 0, 0) != NULL);
-   const GLboolean masking = (!ctx->Color.ColorMask[RCOMP] ||
-                              !ctx->Color.ColorMask[GCOMP] ||
-                              !ctx->Color.ColorMask[BCOMP] ||
-                              !ctx->Color.ColorMask[ACOMP]);
 
    static GLchan multTable[32768];
    static GLfloat prevMult = 0.0;
@@ -527,8 +523,12 @@ accum_return(GLcontext *ctx, GLfloat value,
          /* store colors */
          for (buffer = 0; buffer < fb->_NumColorDrawBuffers; buffer++) {
             struct gl_renderbuffer *rb = fb->_ColorDrawBuffers[buffer];
+            const GLboolean masking = (!ctx->Color.ColorMask[buffer][RCOMP] ||
+                                       !ctx->Color.ColorMask[buffer][GCOMP] ||
+                                       !ctx->Color.ColorMask[buffer][BCOMP] ||
+                                       !ctx->Color.ColorMask[buffer][ACOMP]);
             if (masking) {
-               _swrast_mask_rgba_span(ctx, rb, &span);
+               _swrast_mask_rgba_span(ctx, rb, &span, buffer);
             }
             rb->PutRow(ctx, rb, width, xpos, ypos + i, span.array->rgba, NULL);
          }
index 5fefae6c42b38ce1cf3928acd3a68ce11b42c363..e88ff1912392eb349c1f8e9dcf21bab2cb698d26 100644 (file)
@@ -279,7 +279,7 @@ handle_sample_op(GLcontext * ctx, struct atifs_machine *machine,
 /* sample from unit idx using texinst->src as coords */
    GLuint swizzle = texinst->swizzle;
    GLuint coord_source = texinst->src;
-   GLfloat tex_coords[4];
+   GLfloat tex_coords[4] = { 0 };
 
    if (coord_source >= GL_TEXTURE0_ARB && coord_source <= GL_TEXTURE7_ARB) {
       coord_source -= GL_TEXTURE0_ARB;
index 3dbdf2a61a88ea8011838bb170e3e009aea66d0b..46c63aa6458e36256ff8bd41a63d43a53bd301f2 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "main/glheader.h"
 #include "main/bufferobj.h"
+#include "main/condrender.h"
 #include "main/image.h"
 #include "main/macros.h"
 #include "main/pixel.h"
@@ -56,6 +57,9 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py,
 
    ASSERT(ctx->RenderMode == GL_RENDER);
 
+   if (!_mesa_check_conditional_render(ctx))
+      return; /* don't draw */
+
    bitmap = (const GLubyte *) _mesa_map_pbo_source(ctx, unpack, bitmap);
    if (!bitmap)
       return;
index 8303e4debc75dcb5b15c18543f40232c4e2e04c3..f73ac78ae26d6c67ba1745a3f3cac2348b05ab1a 100644 (file)
@@ -24,6 +24,7 @@
 
 
 #include "main/glheader.h"
+#include "main/condrender.h"
 #include "main/image.h"
 #include "main/macros.h"
 #include "s_context.h"
@@ -567,6 +568,9 @@ _swrast_BlitFramebuffer(GLcontext *ctx,
    };
    GLint i;
 
+   if (!_mesa_check_conditional_render(ctx))
+      return; /* don't clear */
+
    if (!ctx->DrawBuffer->_NumColorDrawBuffers)
       return;
 
index 35080fd3945f65d2388dc43ddda3eec21b7583c3..21167a64b3dad8eca6cf7b923cb5928cfe2f575b 100644 (file)
@@ -24,6 +24,8 @@
 
 #include "main/glheader.h"
 #include "main/colormac.h"
+#include "main/condrender.h"
+#include "main/formats.h"
 #include "main/macros.h"
 #include "main/imports.h"
 #include "main/mtypes.h"
@@ -39,7 +41,8 @@
  * Clear the color buffer when glColorMask is in effect.
  */
 static void
-clear_rgba_buffer_with_masking(GLcontext *ctx, struct gl_renderbuffer *rb)
+clear_rgba_buffer_with_masking(GLcontext *ctx, struct gl_renderbuffer *rb,
+                               GLuint buf)
 {
    const GLint x = ctx->DrawBuffer->_Xmin;
    const GLint y = ctx->DrawBuffer->_Ymin;
@@ -94,7 +97,7 @@ clear_rgba_buffer_with_masking(GLcontext *ctx, struct gl_renderbuffer *rb)
    for (i = 0; i < height; i++) {
       span.x = x;
       span.y = y + i;
-      _swrast_mask_rgba_span(ctx, rb, &span);
+      _swrast_mask_rgba_span(ctx, rb, &span, buf);
       /* write masked row */
       rb->PutRow(ctx, rb, width, x, y + i, span.array->rgba, NULL);
    }
@@ -144,7 +147,7 @@ clear_ci_buffer_with_masking(GLcontext *ctx, struct gl_renderbuffer *rb)
  * Clear an rgba color buffer without channel masking.
  */
 static void
-clear_rgba_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
+clear_rgba_buffer(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint buf)
 {
    const GLint x = ctx->DrawBuffer->_Xmin;
    const GLint y = ctx->DrawBuffer->_Ymin;
@@ -157,10 +160,10 @@ clear_rgba_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
 
    ASSERT(ctx->Visual.rgbMode);
 
-   ASSERT(ctx->Color.ColorMask[0] &&
-          ctx->Color.ColorMask[1] &&
-          ctx->Color.ColorMask[2] &&
-          ctx->Color.ColorMask[3]);             
+   ASSERT(ctx->Color.ColorMask[buf][0] &&
+          ctx->Color.ColorMask[buf][1] &&
+          ctx->Color.ColorMask[buf][2] &&
+          ctx->Color.ColorMask[buf][3]);             
 
    ASSERT(rb->PutMonoRow);
 
@@ -211,9 +214,6 @@ clear_ci_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
 
    ASSERT(!ctx->Visual.rgbMode);
 
-   ASSERT((ctx->Color.IndexMask & ((1 << rb->IndexBits) - 1))
-          == (GLuint) ((1 << rb->IndexBits) - 1));
-
    ASSERT(rb->PutMonoRow);
 
    /* setup clear value */
@@ -248,43 +248,24 @@ clear_ci_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
 static void
 clear_color_buffers(GLcontext *ctx)
 {
-   GLboolean masking;
    GLuint buf;
 
-   if (ctx->Visual.rgbMode) {
-      if (ctx->Color.ColorMask[0] && 
-          ctx->Color.ColorMask[1] && 
-          ctx->Color.ColorMask[2] && 
-          ctx->Color.ColorMask[3]) {
-         masking = GL_FALSE;
-      }
-      else {
-         masking = GL_TRUE;
-      }
-   }
-   else {
-      struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0];
-      const GLuint indexBits = (1 << rb->IndexBits) - 1;
-      if ((ctx->Color.IndexMask & indexBits) == indexBits) {
-         masking = GL_FALSE;
-      }
-      else {
-         masking = GL_TRUE;
-      }
-   }
-
    for (buf = 0; buf < ctx->DrawBuffer->_NumColorDrawBuffers; buf++) {
       struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[buf];
       if (ctx->Visual.rgbMode) {
-         if (masking) {
-            clear_rgba_buffer_with_masking(ctx, rb);
+         if (ctx->Color.ColorMask[buf][0] == 0 || 
+             ctx->Color.ColorMask[buf][1] == 0 || 
+             ctx->Color.ColorMask[buf][2] == 0 || 
+             ctx->Color.ColorMask[buf][3] == 0) {
+            clear_rgba_buffer_with_masking(ctx, rb, buf);
          }
          else {
-            clear_rgba_buffer(ctx, rb);
+            clear_rgba_buffer(ctx, rb, buf);
          }
       }
       else {
-         if (masking) {
+         const GLuint indexMask = (1 << _mesa_get_format_bits(rb->Format, GL_INDEX_BITS)) - 1;
+         if ((ctx->Color.IndexMask & indexMask) != indexMask) {
             clear_ci_buffer_with_masking(ctx, rb);
          }
          else {
@@ -320,6 +301,9 @@ _swrast_Clear(GLcontext *ctx, GLbitfield buffers)
    }
 #endif
 
+   if (!_mesa_check_conditional_render(ctx))
+      return; /* don't clear */
+
    swrast_render_start(ctx);
 
    /* do software clearing here */
index abf00085651b98658231befe1ee12ff909805923..f9092c215a720d4916fdd47aaa2f9866ff52905b 100644 (file)
@@ -55,6 +55,7 @@ _swrast_update_rasterflags( GLcontext *ctx )
 {
    SWcontext *swrast = SWRAST_CONTEXT(ctx);
    GLbitfield rasterMask = 0;
+   GLuint i;
 
    if (ctx->Color.AlphaEnabled)           rasterMask |= ALPHATEST_BIT;
    if (ctx->Color.BlendEnabled)           rasterMask |= BLEND_BIT;
@@ -63,8 +64,15 @@ _swrast_update_rasterflags( GLcontext *ctx )
    if (ctx->Scissor.Enabled)              rasterMask |= CLIP_BIT;
    if (ctx->Stencil._Enabled)             rasterMask |= STENCIL_BIT;
    if (ctx->Visual.rgbMode) {
-      const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
-      if (colorMask != 0xffffffff)        rasterMask |= MASKING_BIT;
+      for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
+         if (!ctx->Color.ColorMask[i][0] ||
+             !ctx->Color.ColorMask[i][1] ||
+             !ctx->Color.ColorMask[i][2] ||
+             !ctx->Color.ColorMask[i][3]) {
+            rasterMask |= MASKING_BIT;
+            break;
+         }
+      }
       if (ctx->Color._LogicOpEnabled)     rasterMask |= LOGIC_OP_BIT;
       if (ctx->Texture._EnabledUnits)     rasterMask |= TEXTURE_BIT;
    }
@@ -92,13 +100,23 @@ _swrast_update_rasterflags( GLcontext *ctx )
       /* more than one color buffer designated for writing (or zero buffers) */
       rasterMask |= MULTI_DRAW_BIT;
    }
-   else if (ctx->Visual.rgbMode && *((GLuint *) ctx->Color.ColorMask) == 0) {
-      rasterMask |= MULTI_DRAW_BIT; /* all RGBA channels disabled */
-   }
    else if (!ctx->Visual.rgbMode && ctx->Color.IndexMask==0) {
       rasterMask |= MULTI_DRAW_BIT; /* all color index bits disabled */
    }
 
+   if (ctx->Visual.rgbMode) {
+      for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
+         if (ctx->Color.ColorMask[i][0] +
+             ctx->Color.ColorMask[i][1] +
+             ctx->Color.ColorMask[i][2] +
+             ctx->Color.ColorMask[i][3] == 0) {
+            rasterMask |= MULTI_DRAW_BIT; /* all RGBA channels disabled */
+            break;
+         }
+      }
+   }
+
+
    if (ctx->FragmentProgram._Current) {
       rasterMask |= FRAGPROG_BIT;
    }
index 5ecfb1e90a97bd0116855c7653dc5b938f982e97..986b6aff4f081d0bd2764e6e8308a3f1dd4bd4d8 100644 (file)
@@ -26,6 +26,7 @@
 #include "main/glheader.h"
 #include "main/context.h"
 #include "main/colormac.h"
+#include "main/condrender.h"
 #include "main/convolve.h"
 #include "main/histogram.h"
 #include "main/image.h"
@@ -901,6 +902,9 @@ _swrast_CopyPixels( GLcontext *ctx,
    SWcontext *swrast = SWRAST_CONTEXT(ctx);
    swrast_render_start(ctx);
       
+   if (!_mesa_check_conditional_render(ctx))
+      return; /* don't copy */
+
    if (swrast->NewState)
       _swrast_validate_derived( ctx );
 
index 17e00dda4ff49a9134062dbf7b6bec5c4e1e1b68..c37a54eb3eb4fd85bef03a742774dabf23b69955 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "main/glheader.h"
 #include "main/context.h"
+#include "main/formats.h"
 #include "main/macros.h"
 #include "main/imports.h"
 #include "main/fbobject.h"
@@ -505,22 +506,32 @@ _swrast_depth_clamp_span( GLcontext *ctx, SWspan *span )
    struct gl_renderbuffer *rb = fb->_DepthBuffer;
    const GLuint count = span->end;
    GLuint *zValues = span->array->z;
-   GLuint near, far;
+   GLuint min, max;
+   GLfloat min_f, max_f;
    int i;
 
+   if (ctx->Viewport.Near < ctx->Viewport.Far) {
+      min_f = ctx->Viewport.Near;
+      max_f = ctx->Viewport.Far;
+   } else {
+      min_f = ctx->Viewport.Far;
+      max_f = ctx->Viewport.Near;
+   }
+
    if (rb->DataType == GL_UNSIGNED_SHORT) {
-      near = FLOAT_TO_UINT(ctx->Viewport.Near);
-      far = FLOAT_TO_UINT(ctx->Viewport.Far);
+      CLAMPED_FLOAT_TO_USHORT(min, min_f);
+      CLAMPED_FLOAT_TO_USHORT(max, max_f);
    } else {
       assert(rb->DataType == GL_UNSIGNED_INT);
-      CLAMPED_FLOAT_TO_USHORT(near, ctx->Viewport.Near);
-      CLAMPED_FLOAT_TO_USHORT(far, ctx->Viewport.Far);
+      min = FLOAT_TO_UINT(min_f);
+      max = FLOAT_TO_UINT(max_f);
    }
+
    for (i = 0; i < count; i++) {
-      if (zValues[i] < near)
-        zValues[i] = near;
-      if (zValues[i] > far)
-        zValues[i] = far;
+      if (zValues[i] < min)
+        zValues[i] = min;
+      if (zValues[i] > max)
+        zValues[i] = max;
    }
 }
 
@@ -1299,12 +1310,16 @@ void
 _swrast_read_depth_span_uint( GLcontext *ctx, struct gl_renderbuffer *rb,
                               GLint n, GLint x, GLint y, GLuint depth[] )
 {
+   GLuint depthBits;
+
    if (!rb) {
       /* really only doing this to prevent FP exceptions later */
       _mesa_bzero(depth, n * sizeof(GLuint));
       return;
    }
 
+   depthBits = _mesa_get_format_bits(rb->Format, GL_DEPTH_BITS);
+
    ASSERT(rb->_BaseFormat == GL_DEPTH_COMPONENT);
 
    if (y < 0 || y >= (GLint) rb->Height ||
@@ -1336,8 +1351,8 @@ _swrast_read_depth_span_uint( GLcontext *ctx, struct gl_renderbuffer *rb,
 
    if (rb->DataType == GL_UNSIGNED_INT) {
       rb->GetRow(ctx, rb, n, x, y, depth);
-      if (rb->DepthBits < 32) {
-         GLuint shift = 32 - rb->DepthBits;
+      if (depthBits < 32) {
+         GLuint shift = 32 - depthBits;
          GLint i;
          for (i = 0; i < n; i++) {
             GLuint z = depth[i];
@@ -1349,14 +1364,14 @@ _swrast_read_depth_span_uint( GLcontext *ctx, struct gl_renderbuffer *rb,
       GLushort temp[MAX_WIDTH];
       GLint i;
       rb->GetRow(ctx, rb, n, x, y, temp);
-      if (rb->DepthBits == 16) {
+      if (depthBits == 16) {
          for (i = 0; i < n; i++) {
             GLuint z = temp[i];
             depth[i] = (z << 16) | z;
          }
       }
       else {
-         GLuint shift = 16 - rb->DepthBits;
+         GLuint shift = 16 - depthBits;
          for (i = 0; i < n; i++) {
             GLuint z = temp[i];
             depth[i] = (z << (shift + 16)) | (z << shift); /* XXX lsb bits? */
index 6970b2e9cb522ae2f4c05fbba373a674a07dabf3..55a4c4c3c610615041a4b75d784f44e22a8a96e5 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "main/glheader.h"
 #include "main/bufferobj.h"
+#include "main/condrender.h"
 #include "main/context.h"
 #include "main/convolve.h"
 #include "main/image.h"
@@ -831,6 +832,9 @@ _swrast_DrawPixels( GLcontext *ctx,
    SWcontext *swrast = SWRAST_CONTEXT(ctx);
    GLboolean save_vp_override = ctx->VertexProgram._Overriden;
 
+   if (!_mesa_check_conditional_render(ctx))
+      return; /* don't draw */
+
    /* We are creating fragments directly, without going through vertex
     * programs.
     *
index 77a77f0bcbb0e838bb1b6d646985ca72c734333c..a22d34415d5a7c0ff7dc1069861c67c9f198782a 100644 (file)
@@ -190,7 +190,7 @@ run_program(GLcontext *ctx, SWspan *span, GLuint start, GLuint end)
 {
    SWcontext *swrast = SWRAST_CONTEXT(ctx);
    const struct gl_fragment_program *program = ctx->FragmentProgram._Current;
-   const GLbitfield outputsWritten = program->Base.OutputsWritten;
+   const GLbitfield64 outputsWritten = program->Base.OutputsWritten;
    struct gl_program_machine *machine = &swrast->FragProgMachine;
    GLuint i;
 
@@ -201,7 +201,7 @@ run_program(GLcontext *ctx, SWspan *span, GLuint start, GLuint end)
          if (_mesa_execute_program(ctx, &program->Base, machine)) {
 
             /* Store result color */
-            if (outputsWritten & (1 << FRAG_RESULT_COLOR)) {
+           if (outputsWritten & BITFIELD64_BIT(FRAG_RESULT_COLOR)) {
                COPY_4V(span->array->attribs[FRAG_ATTRIB_COL0][i],
                        machine->Outputs[FRAG_RESULT_COLOR]);
             }
@@ -212,7 +212,7 @@ run_program(GLcontext *ctx, SWspan *span, GLuint start, GLuint end)
                 */
                GLuint buf;
                for (buf = 0; buf < ctx->DrawBuffer->_NumColorDrawBuffers; buf++) {
-                  if (outputsWritten & (1 << (FRAG_RESULT_DATA0 + buf))) {
+                  if (outputsWritten & BITFIELD64_BIT(FRAG_RESULT_DATA0 + buf)) {
                      COPY_4V(span->array->attribs[FRAG_ATTRIB_COL0 + buf][i],
                              machine->Outputs[FRAG_RESULT_DATA0 + buf]);
                   }
@@ -220,7 +220,7 @@ run_program(GLcontext *ctx, SWspan *span, GLuint start, GLuint end)
             }
 
             /* Store result depth/z */
-            if (outputsWritten & (1 << FRAG_RESULT_DEPTH)) {
+            if (outputsWritten & BITFIELD64_BIT(FRAG_RESULT_DEPTH)) {
                const GLfloat depth = machine->Outputs[FRAG_RESULT_DEPTH][2];
                if (depth <= 0.0)
                   span->array->z[i] = 0;
@@ -256,12 +256,12 @@ _swrast_exec_fragment_program( GLcontext *ctx, SWspan *span )
 
    run_program(ctx, span, 0, span->end);
 
-   if (program->Base.OutputsWritten & (1 << FRAG_RESULT_COLOR)) {
+   if (program->Base.OutputsWritten & BITFIELD64_BIT(FRAG_RESULT_COLOR)) {
       span->interpMask &= ~SPAN_RGBA;
       span->arrayMask |= SPAN_RGBA;
    }
 
-   if (program->Base.OutputsWritten & (1 << FRAG_RESULT_DEPTH)) {
+   if (program->Base.OutputsWritten & BITFIELD64_BIT(FRAG_RESULT_DEPTH)) {
       span->interpMask &= ~SPAN_Z;
       span->arrayMask |= SPAN_Z;
    }
index df779b0739218d897d353cd6d7d43fa50c6f701c..69c2feb6da899e713bcca55405375e2ae6328b22 100644 (file)
@@ -41,7 +41,7 @@
  */
 void
 _swrast_mask_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb,
-                       SWspan *span)
+                       SWspan *span, GLuint buf)
 {
    const GLuint n = span->end;
    void *rbPixels;
@@ -58,7 +58,7 @@ _swrast_mask_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb,
     */
    if (span->array->ChanType == GL_UNSIGNED_BYTE) {
       /* treat 4xGLubyte as 1xGLuint */
-      const GLuint srcMask = *((GLuint *) ctx->Color.ColorMask);
+      const GLuint srcMask = *((GLuint *) ctx->Color.ColorMask[buf]);
       const GLuint dstMask = ~srcMask;
       const GLuint *dst = (const GLuint *) rbPixels;
       GLuint *src = (GLuint *) span->array->rgba8;
@@ -70,10 +70,10 @@ _swrast_mask_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb,
    else if (span->array->ChanType == GL_UNSIGNED_SHORT) {
       /* 2-byte components */
       /* XXX try to use 64-bit arithmetic someday */
-      const GLushort rMask = ctx->Color.ColorMask[RCOMP] ? 0xffff : 0x0;
-      const GLushort gMask = ctx->Color.ColorMask[GCOMP] ? 0xffff : 0x0;
-      const GLushort bMask = ctx->Color.ColorMask[BCOMP] ? 0xffff : 0x0;
-      const GLushort aMask = ctx->Color.ColorMask[ACOMP] ? 0xffff : 0x0;
+      const GLushort rMask = ctx->Color.ColorMask[buf][RCOMP] ? 0xffff : 0x0;
+      const GLushort gMask = ctx->Color.ColorMask[buf][GCOMP] ? 0xffff : 0x0;
+      const GLushort bMask = ctx->Color.ColorMask[buf][BCOMP] ? 0xffff : 0x0;
+      const GLushort aMask = ctx->Color.ColorMask[buf][ACOMP] ? 0xffff : 0x0;
       const GLushort (*dst)[4] = (const GLushort (*)[4]) rbPixels;
       GLushort (*src)[4] = span->array->rgba16;
       GLuint i;
@@ -86,10 +86,10 @@ _swrast_mask_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb,
    }
    else {
       /* 4-byte components */
-      const GLuint rMask = ctx->Color.ColorMask[RCOMP] ? ~0x0 : 0x0;
-      const GLuint gMask = ctx->Color.ColorMask[GCOMP] ? ~0x0 : 0x0;
-      const GLuint bMask = ctx->Color.ColorMask[BCOMP] ? ~0x0 : 0x0;
-      const GLuint aMask = ctx->Color.ColorMask[ACOMP] ? ~0x0 : 0x0;
+      const GLuint rMask = ctx->Color.ColorMask[buf][RCOMP] ? ~0x0 : 0x0;
+      const GLuint gMask = ctx->Color.ColorMask[buf][GCOMP] ? ~0x0 : 0x0;
+      const GLuint bMask = ctx->Color.ColorMask[buf][BCOMP] ? ~0x0 : 0x0;
+      const GLuint aMask = ctx->Color.ColorMask[buf][ACOMP] ? ~0x0 : 0x0;
       const GLuint (*dst)[4] = (const GLuint (*)[4]) rbPixels;
       GLuint (*src)[4] = (GLuint (*)[4]) span->array->attribs[FRAG_ATTRIB_COL0];
       GLuint i;
index 3260ca34e324a9e5d1418c4943fc68e826a9b5e3..fed47f8cfbed84f930ed2440d49d622aea52366f 100644 (file)
@@ -32,7 +32,7 @@
 
 extern void
 _swrast_mask_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb,
-                       SWspan *span);
+                       SWspan *span, GLuint buf);
 
 
 extern void
index a1aeb2e01fbb8882685595e49f7a2287b11c5636..44a11cd6dd28cebd7f64272f70bcd74f445c8420 100644 (file)
@@ -29,6 +29,7 @@
 #include "main/convolve.h"
 #include "main/context.h"
 #include "main/feedback.h"
+#include "main/formats.h"
 #include "main/image.h"
 #include "main/macros.h"
 #include "main/imports.h"
@@ -107,7 +108,7 @@ read_depth_pixels( GLcontext *ctx,
        && !biasOrScale && !packing->SwapBytes) {
       /* Special case: directly read 16-bit unsigned depth values. */
       GLint j;
-      ASSERT(rb->InternalFormat == GL_DEPTH_COMPONENT16);
+      ASSERT(rb->Format == MESA_FORMAT_Z16);
       ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
       for (j = 0; j < height; j++, y++) {
          void *dest =_mesa_image_address2d(packing, pixels, width, height,
@@ -119,8 +120,12 @@ read_depth_pixels( GLcontext *ctx,
             && !biasOrScale && !packing->SwapBytes) {
       /* Special case: directly read 24-bit unsigned depth values. */
       GLint j;
-      ASSERT(rb->InternalFormat == GL_DEPTH_COMPONENT24);
-      ASSERT(rb->DataType == GL_UNSIGNED_INT);
+      ASSERT(rb->Format == MESA_FORMAT_X8_Z24 ||
+             rb->Format == MESA_FORMAT_S8_Z24 ||
+             rb->Format == MESA_FORMAT_Z24_X8 ||
+             rb->Format == MESA_FORMAT_Z24_S8);
+      ASSERT(rb->DataType == GL_UNSIGNED_INT ||
+             rb->DataType == GL_UNSIGNED_INT_24_8);
       for (j = 0; j < height; j++, y++) {
          GLuint *dest = (GLuint *)
             _mesa_image_address2d(packing, pixels, width, height,
@@ -128,9 +133,18 @@ read_depth_pixels( GLcontext *ctx,
          GLint k;
          rb->GetRow(ctx, rb, width, x, y, dest);
          /* convert range from 24-bit to 32-bit */
-         for (k = 0; k < width; k++) {
-            /* Note: put MSByte of 24-bit value into LSByte */
-            dest[k] = (dest[k] << 8) | ((dest[k] >> 16) & 0xff);
+         if (rb->Format == MESA_FORMAT_X8_Z24 ||
+             rb->Format == MESA_FORMAT_S8_Z24) {
+            for (k = 0; k < width; k++) {
+               /* Note: put MSByte of 24-bit value into LSByte */
+               dest[k] = (dest[k] << 8) | ((dest[k] >> 16) & 0xff);
+            }
+         }
+         else {
+            for (k = 0; k < width; k++) {
+               /* Note: fill in LSByte by replication */
+               dest[k] = dest[k] | ((dest[k] >> 8) & 0xff);
+            }
          }
       }
    }
@@ -138,7 +152,7 @@ read_depth_pixels( GLcontext *ctx,
             && !biasOrScale && !packing->SwapBytes) {
       /* Special case: directly read 32-bit unsigned depth values. */
       GLint j;
-      ASSERT(rb->InternalFormat == GL_DEPTH_COMPONENT32);
+      ASSERT(rb->Format == MESA_FORMAT_Z32);
       ASSERT(rb->DataType == GL_UNSIGNED_INT);
       for (j = 0; j < height; j++, y++) {
          void *dest = _mesa_image_address2d(packing, pixels, width, height,
index 704230d1d7bc190b7059eea5102003672e539f4a..4ea9547cd9203c84521df1612cbcf5a30248c707 100644 (file)
@@ -880,14 +880,14 @@ _swrast_write_index_span( GLcontext *ctx, SWspan *span)
       stipple_polygon_span(ctx, span);
    }
 
-   if (ctx->Transform.DepthClamp)
-      _swrast_depth_clamp_span(ctx, span);
-
    /* Stencil and Z testing */
    if (ctx->Stencil._Enabled || ctx->Depth.Test) {
       if (!(span->arrayMask & SPAN_Z))
          _swrast_span_interpolate_z(ctx, span);
 
+      if (ctx->Transform.DepthClamp)
+        _swrast_depth_clamp_span(ctx, span);
+
       if (ctx->Stencil._Enabled) {
          if (!_swrast_stencil_and_ztest_span(ctx, span)) {
             span->arrayMask = origArrayMask;
@@ -1278,7 +1278,7 @@ void
 _swrast_write_rgba_span( GLcontext *ctx, SWspan *span)
 {
    const SWcontext *swrast = SWRAST_CONTEXT(ctx);
-   const GLuint colorMask = *((GLuint *) ctx->Color.ColorMask);
+   const GLuint *colorMask = (GLuint *) ctx->Color.ColorMask;
    const GLbitfield origInterpMask = span->interpMask;
    const GLbitfield origArrayMask = span->arrayMask;
    const GLbitfield origArrayAttribs = span->arrayAttribs;
@@ -1356,6 +1356,10 @@ _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 (ctx->Transform.DepthClamp)
+        _swrast_depth_clamp_span(ctx, span);
+
       if (ctx->Stencil._Enabled) {
          /* Combined Z/stencil tests */
          if (!_swrast_stencil_and_ztest_span(ctx, span)) {
@@ -1385,7 +1389,7 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span)
    /* We had to wait until now to check for glColorMask(0,0,0,0) because of
     * the occlusion test.
     */
-   if (colorMask == 0x0) {
+   if (fb->_NumColorDrawBuffers == 1 && colorMask[0] == 0x0) {
       /* no colors to write */
       goto end;
    }
@@ -1475,12 +1479,12 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span)
             if (ctx->Color._LogicOpEnabled) {
                _swrast_logicop_rgba_span(ctx, rb, span);
             }
-            else if (ctx->Color.BlendEnabled) {
+            else if ((ctx->Color.BlendEnabled >> buf) & 1) {
                _swrast_blend_span(ctx, rb, span);
             }
 
-            if (colorMask != 0xffffffff) {
-               _swrast_mask_rgba_span(ctx, rb, span);
+            if (colorMask[buf] != 0xffffffff) {
+               _swrast_mask_rgba_span(ctx, rb, span, buf);
             }
 
             if (span->arrayMask & SPAN_XY) {
@@ -1762,9 +1766,7 @@ _swrast_get_row(GLcontext *ctx, struct gl_renderbuffer *rb,
 
 
 /**
- * Get RGBA pixels from the given renderbuffer.  Put the pixel colors into
- * the span's specular color arrays.  The specular color arrays should no
- * longer be needed by time this function is called.
+ * Get RGBA pixels from the given renderbuffer.
  * Used by blending, logicop and masking functions.
  * \return pointer to the colors we read.
  */
@@ -1775,10 +1777,8 @@ _swrast_get_dest_rgba(GLcontext *ctx, struct gl_renderbuffer *rb,
    const GLuint pixelSize = RGBA_PIXEL_SIZE(span->array->ChanType);
    void *rbPixels;
 
-   /*
-    * Point rbPixels to a temporary space (use specular color arrays).
-    */
-   rbPixels = span->array->attribs[FRAG_ATTRIB_COL1];
+   /* Point rbPixels to a temporary space */
+   rbPixels = span->array->attribs[FRAG_ATTRIB_MAX - 1];
 
    /* Get destination values from renderbuffer */
    if (span->arrayMask & SPAN_XY) {
index 004d4e05ae523db41237d1679c2d08b3522658f1..76b65cc755e4c9bb1f058a3e2d2228ebb6be9bd6 100644 (file)
@@ -745,30 +745,30 @@ get_border_color(const struct gl_texture_object *tObj,
                  const struct gl_texture_image *img,
                  GLfloat rgba[4])
 {
-   switch (img->TexFormat->BaseFormat) {
+   switch (img->_BaseFormat) {
    case GL_RGB:
-      rgba[0] = tObj->BorderColor[0];
-      rgba[1] = tObj->BorderColor[1];
-      rgba[2] = tObj->BorderColor[2];
+      rgba[0] = tObj->BorderColor.f[0];
+      rgba[1] = tObj->BorderColor.f[1];
+      rgba[2] = tObj->BorderColor.f[2];
       rgba[3] = 1.0F;
       break;
    case GL_ALPHA:
       rgba[0] = rgba[1] = rgba[2] = 0.0;
-      rgba[3] = tObj->BorderColor[3];
+      rgba[3] = tObj->BorderColor.f[3];
       break;
    case GL_LUMINANCE:
-      rgba[0] = rgba[1] = rgba[2] = tObj->BorderColor[0];
+      rgba[0] = rgba[1] = rgba[2] = tObj->BorderColor.f[0];
       rgba[3] = 1.0;
       break;
    case GL_LUMINANCE_ALPHA:
-      rgba[0] = rgba[1] = rgba[2] = tObj->BorderColor[0];
-      rgba[3] = tObj->BorderColor[3];
+      rgba[0] = rgba[1] = rgba[2] = tObj->BorderColor.f[0];
+      rgba[3] = tObj->BorderColor.f[3];
       break;
    case GL_INTENSITY:
-      rgba[0] = rgba[1] = rgba[2] = rgba[3] = tObj->BorderColor[0];
+      rgba[0] = rgba[1] = rgba[2] = rgba[3] = tObj->BorderColor.f[0];
       break;
    default:
-      COPY_4V(rgba, tObj->BorderColor);
+      COPY_4V(rgba, tObj->BorderColor.f);
    }
 }
 
@@ -1152,7 +1152,7 @@ sample_2d_linear_repeat(GLcontext *ctx,
    ASSERT(tObj->WrapS == GL_REPEAT);
    ASSERT(tObj->WrapT == GL_REPEAT);
    ASSERT(img->Border == 0);
-   ASSERT(img->TexFormat->BaseFormat != GL_COLOR_INDEX);
+   ASSERT(img->_BaseFormat != GL_COLOR_INDEX);
    ASSERT(img->_IsPowerOfTwo);
 
    linear_repeat_texel_location(width,  texcoord[0], &i0, &i1, &wi);
@@ -1343,17 +1343,17 @@ opt_sample_rgb_2d(GLcontext *ctx,
    ASSERT(tObj->WrapS==GL_REPEAT);
    ASSERT(tObj->WrapT==GL_REPEAT);
    ASSERT(img->Border==0);
-   ASSERT(img->TexFormat->MesaFormat==MESA_FORMAT_RGB);
+   ASSERT(img->TexFormat == MESA_FORMAT_RGB888);
    ASSERT(img->_IsPowerOfTwo);
 
    for (k=0; k<n; k++) {
       GLint i = IFLOOR(texcoords[k][0] * width) & colMask;
       GLint j = IFLOOR(texcoords[k][1] * height) & rowMask;
       GLint pos = (j << shift) | i;
-      GLchan *texel = ((GLchan *) img->Data) + 3*pos;
-      rgba[k][RCOMP] = CHAN_TO_FLOAT(texel[0]);
-      rgba[k][GCOMP] = CHAN_TO_FLOAT(texel[1]);
-      rgba[k][BCOMP] = CHAN_TO_FLOAT(texel[2]);
+      GLubyte *texel = ((GLubyte *) img->Data) + 3*pos;
+      rgba[k][RCOMP] = UBYTE_TO_FLOAT(texel[2]);
+      rgba[k][GCOMP] = UBYTE_TO_FLOAT(texel[1]);
+      rgba[k][BCOMP] = UBYTE_TO_FLOAT(texel[0]);
    }
 }
 
@@ -1384,18 +1384,18 @@ opt_sample_rgba_2d(GLcontext *ctx,
    ASSERT(tObj->WrapS==GL_REPEAT);
    ASSERT(tObj->WrapT==GL_REPEAT);
    ASSERT(img->Border==0);
-   ASSERT(img->TexFormat->MesaFormat==MESA_FORMAT_RGBA);
+   ASSERT(img->TexFormat == MESA_FORMAT_RGBA8888);
    ASSERT(img->_IsPowerOfTwo);
 
    for (i = 0; i < n; i++) {
       const GLint col = IFLOOR(texcoords[i][0] * width) & colMask;
       const GLint row = IFLOOR(texcoords[i][1] * height) & rowMask;
       const GLint pos = (row << shift) | col;
-      const GLchan *texel = ((GLchan *) img->Data) + (pos << 2);    /* pos*4 */
-      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]);
+      const GLuint texel = *((GLuint *) img->Data + pos);
+      rgba[i][RCOMP] = UBYTE_TO_FLOAT( (texel >> 24)        );
+      rgba[i][GCOMP] = UBYTE_TO_FLOAT( (texel >> 16) & 0xff );
+      rgba[i][BCOMP] = UBYTE_TO_FLOAT( (texel >>  8) & 0xff );
+      rgba[i][ACOMP] = UBYTE_TO_FLOAT( (texel      ) & 0xff );
    }
 }
 
@@ -1414,7 +1414,7 @@ sample_lambda_2d(GLcontext *ctx,
    const GLboolean repeatNoBorderPOT = (tObj->WrapS == GL_REPEAT)
       && (tObj->WrapT == GL_REPEAT)
       && (tImg->Border == 0 && (tImg->Width == tImg->RowStride))
-      && (tImg->TexFormat->BaseFormat != GL_COLOR_INDEX)
+      && (tImg->_BaseFormat != GL_COLOR_INDEX)
       && tImg->_IsPowerOfTwo;
 
    ASSERT(lambda != NULL);
@@ -1427,12 +1427,12 @@ sample_lambda_2d(GLcontext *ctx,
       switch (tObj->MinFilter) {
       case GL_NEAREST:
          if (repeatNoBorderPOT) {
-            switch (tImg->TexFormat->MesaFormat) {
-            case MESA_FORMAT_RGB:
+            switch (tImg->TexFormat) {
+            case MESA_FORMAT_RGB888:
                opt_sample_rgb_2d(ctx, tObj, m, texcoords + minStart,
                                  NULL, rgba + minStart);
                break;
-            case MESA_FORMAT_RGBA:
+            case MESA_FORMAT_RGBA8888:
               opt_sample_rgba_2d(ctx, tObj, m, texcoords + minStart,
                                   NULL, rgba + minStart);
                break;
@@ -1484,12 +1484,12 @@ sample_lambda_2d(GLcontext *ctx,
       switch (tObj->MagFilter) {
       case GL_NEAREST:
          if (repeatNoBorderPOT) {
-            switch (tImg->TexFormat->MesaFormat) {
-            case MESA_FORMAT_RGB:
+            switch (tImg->TexFormat) {
+            case MESA_FORMAT_RGB888:
                opt_sample_rgb_2d(ctx, tObj, m, texcoords + magStart,
                                  NULL, rgba + magStart);
                break;
-            case MESA_FORMAT_RGBA:
+            case MESA_FORMAT_RGBA8888:
               opt_sample_rgba_2d(ctx, tObj, m, texcoords + magStart,
                                   NULL, rgba + magStart);
                break;
@@ -2152,7 +2152,7 @@ sample_nearest_rect(GLcontext *ctx,
    ASSERT(tObj->WrapT == GL_CLAMP ||
           tObj->WrapT == GL_CLAMP_TO_EDGE ||
           tObj->WrapT == GL_CLAMP_TO_BORDER);
-   ASSERT(img->TexFormat->BaseFormat != GL_COLOR_INDEX);
+   ASSERT(img->_BaseFormat != GL_COLOR_INDEX);
 
    for (i = 0; i < n; i++) {
       GLint row, col;
@@ -2186,7 +2186,7 @@ sample_linear_rect(GLcontext *ctx,
    ASSERT(tObj->WrapT == GL_CLAMP ||
           tObj->WrapT == GL_CLAMP_TO_EDGE ||
           tObj->WrapT == GL_CLAMP_TO_BORDER);
-   ASSERT(img->TexFormat->BaseFormat != GL_COLOR_INDEX);
+   ASSERT(img->_BaseFormat != GL_COLOR_INDEX);
 
    for (i = 0; i < n; i++) {
       GLint i0, j0, i1, j1;
@@ -2331,7 +2331,7 @@ sample_2d_array_linear(GLcontext *ctx,
    array = clamp_rect_coord_nearest(tObj->WrapR, texcoord[2], depth);
 
    if (array < 0 || array >= depth) {
-      COPY_4V(rgba, tObj->BorderColor);
+      COPY_4V(rgba, tObj->BorderColor.f);
    }
    else {
       if (img->Border) {
@@ -2973,8 +2973,8 @@ sample_depth_texture( GLcontext *ctx,
 
    (void) lambda;
 
-   ASSERT(img->TexFormat->BaseFormat == GL_DEPTH_COMPONENT ||
-          img->TexFormat->BaseFormat == GL_DEPTH_STENCIL_EXT);
+   ASSERT(img->_BaseFormat == GL_DEPTH_COMPONENT ||
+          img->_BaseFormat == GL_DEPTH_STENCIL_EXT);
 
    ASSERT(tObj->Target == GL_TEXTURE_1D ||
           tObj->Target == GL_TEXTURE_2D ||
@@ -3002,7 +3002,7 @@ sample_depth_texture( GLcontext *ctx,
             img->FetchTexelf(img, col, row, slice, &depthSample);
          }
          else {
-            depthSample = tObj->BorderColor[0];
+            depthSample = tObj->BorderColor.f[0];
          }
 
          result = shadow_compare(function, texcoords[i][compare_coord],
@@ -3053,21 +3053,21 @@ sample_depth_texture( GLcontext *ctx,
          }
 
          if (slice < 0 || slice >= (GLint) depth) {
-            depth00 = tObj->BorderColor[0];
-            depth01 = tObj->BorderColor[0];
-            depth10 = tObj->BorderColor[0];
-            depth11 = tObj->BorderColor[0];
+            depth00 = tObj->BorderColor.f[0];
+            depth01 = tObj->BorderColor.f[0];
+            depth10 = tObj->BorderColor.f[0];
+            depth11 = tObj->BorderColor.f[0];
          }
          else {
             /* get four depth samples from the texture */
             if (useBorderTexel & (I0BIT | J0BIT)) {
-               depth00 = tObj->BorderColor[0];
+               depth00 = tObj->BorderColor.f[0];
             }
             else {
                img->FetchTexelf(img, i0, j0, slice, &depth00);
             }
             if (useBorderTexel & (I1BIT | J0BIT)) {
-               depth10 = tObj->BorderColor[0];
+               depth10 = tObj->BorderColor.f[0];
             }
             else {
                img->FetchTexelf(img, i1, j0, slice, &depth10);
@@ -3075,13 +3075,13 @@ sample_depth_texture( GLcontext *ctx,
 
             if (tObj->Target != GL_TEXTURE_1D_ARRAY_EXT) {
                if (useBorderTexel & (I0BIT | J1BIT)) {
-                  depth01 = tObj->BorderColor[0];
+                  depth01 = tObj->BorderColor.f[0];
                }
                else {
                   img->FetchTexelf(img, i0, j1, slice, &depth01);
                }
                if (useBorderTexel & (I1BIT | J1BIT)) {
-                  depth11 = tObj->BorderColor[0];
+                  depth11 = tObj->BorderColor.f[0];
                }
                else {
                   img->FetchTexelf(img, i1, j1, slice, &depth11);
@@ -3137,7 +3137,7 @@ null_sample_func( GLcontext *ctx,
       rgba[i][RCOMP] = 0;
       rgba[i][GCOMP] = 0;
       rgba[i][BCOMP] = 0;
-      rgba[i][ACOMP] = CHAN_MAX;
+      rgba[i][ACOMP] = 1.0;
    }
 }
 
@@ -3154,7 +3154,7 @@ _swrast_choose_texture_sample_func( GLcontext *ctx,
    }
    else {
       const GLboolean needLambda = (GLboolean) (t->MinFilter != t->MagFilter);
-      const GLenum format = t->Image[0][t->BaseLevel]->TexFormat->BaseFormat;
+      const GLenum format = t->Image[0][t->BaseLevel]->_BaseFormat;
 
       switch (t->Target) {
       case GL_TEXTURE_1D:
@@ -3189,14 +3189,14 @@ _swrast_choose_texture_sample_func( GLcontext *ctx,
                 t->WrapT == GL_REPEAT &&
                 img->_IsPowerOfTwo &&
                 img->Border == 0 &&
-                img->TexFormat->MesaFormat == MESA_FORMAT_RGB) {
+                img->TexFormat == MESA_FORMAT_RGB888) {
                return &opt_sample_rgb_2d;
             }
             else if (t->WrapS == GL_REPEAT &&
                      t->WrapT == GL_REPEAT &&
                      img->_IsPowerOfTwo &&
                      img->Border == 0 &&
-                     img->TexFormat->MesaFormat == MESA_FORMAT_RGBA) {
+                     img->TexFormat == MESA_FORMAT_RGBA8888) {
                return &opt_sample_rgba_2d;
             }
             else {
index 1ab0e19f922860013e6aae57381dea6db7d88e51..11184b72ce37f4cc9eb15994d5b8861696082606 100644 (file)
@@ -134,22 +134,24 @@ _swrast_culltriangle( GLcontext *ctx,
 
 #define SETUP_CODE                                                     \
    struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0]; \
-   struct gl_texture_object *obj =                                     \
+   const struct gl_texture_object *obj =                               \
       ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX];               \
-   const GLint b = obj->BaseLevel;                                     \
-   const GLfloat twidth = (GLfloat) obj->Image[0][b]->Width;           \
-   const GLfloat theight = (GLfloat) obj->Image[0][b]->Height;         \
-   const GLint twidth_log2 = obj->Image[0][b]->WidthLog2;              \
-   const GLchan *texture = (const GLchan *) obj->Image[0][b]->Data;    \
-   const GLint smask = obj->Image[0][b]->Width - 1;                    \
-   const GLint tmask = obj->Image[0][b]->Height - 1;                   \
+   const struct gl_texture_image *texImg =                             \
+      obj->Image[0][obj->BaseLevel];                                   \
+   const GLfloat twidth = (GLfloat) texImg->Width;                     \
+   const GLfloat theight = (GLfloat) texImg->Height;                   \
+   const GLint twidth_log2 = texImg->WidthLog2;                                \
+   const GLubyte *texture = (const GLubyte *) texImg->Data;            \
+   const GLint smask = texImg->Width - 1;                              \
+   const GLint tmask = texImg->Height - 1;                             \
+   ASSERT(texImg->TexFormat == MESA_FORMAT_RGB888);                    \
    if (!rb || !texture) {                                              \
       return;                                                          \
    }
 
 #define RENDER_SPAN( span )                                            \
    GLuint i;                                                           \
-   GLchan rgb[MAX_WIDTH][3];                                           \
+   GLubyte rgb[MAX_WIDTH][3];                                          \
    span.intTex[0] -= FIXED_HALF; /* off-by-one error? */               \
    span.intTex[1] -= FIXED_HALF;                                       \
    for (i = 0; i < span.end; i++) {                                    \
@@ -157,9 +159,9 @@ _swrast_culltriangle( GLcontext *ctx,
       GLint t = FixedToInt(span.intTex[1]) & tmask;                    \
       GLint pos = (t << twidth_log2) + s;                              \
       pos = pos + pos + pos;  /* multiply by 3 */                      \
-      rgb[i][RCOMP] = texture[pos];                                    \
+      rgb[i][RCOMP] = texture[pos+2];                                  \
       rgb[i][GCOMP] = texture[pos+1];                                  \
-      rgb[i][BCOMP] = texture[pos+2];                                  \
+      rgb[i][BCOMP] = texture[pos+0];                                  \
       span.intTex[0] += span.intTexStep[0];                            \
       span.intTex[1] += span.intTexStep[1];                            \
    }                                                                   \
@@ -186,22 +188,24 @@ _swrast_culltriangle( GLcontext *ctx,
 
 #define SETUP_CODE                                                     \
    struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0]; \
-   struct gl_texture_object *obj =                                     \
+   const struct gl_texture_object *obj =                               \
       ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX];               \
-   const GLint b = obj->BaseLevel;                                     \
-   const GLfloat twidth = (GLfloat) obj->Image[0][b]->Width;           \
-   const GLfloat theight = (GLfloat) obj->Image[0][b]->Height;         \
-   const GLint twidth_log2 = obj->Image[0][b]->WidthLog2;              \
-   const GLchan *texture = (const GLchan *) obj->Image[0][b]->Data;    \
-   const GLint smask = obj->Image[0][b]->Width - 1;                    \
-   const GLint tmask = obj->Image[0][b]->Height - 1;                   \
+   const struct gl_texture_image *texImg =                             \
+       obj->Image[0][obj->BaseLevel];                                  \
+   const GLfloat twidth = (GLfloat) texImg->Width;                     \
+   const GLfloat theight = (GLfloat) texImg->Height;                   \
+   const GLint twidth_log2 = texImg->WidthLog2;                                \
+   const GLubyte *texture = (const GLubyte *) texImg->Data;            \
+   const GLint smask = texImg->Width - 1;                              \
+   const GLint tmask = texImg->Height - 1;                             \
+   ASSERT(texImg->TexFormat == MESA_FORMAT_RGB888);                    \
    if (!rb || !texture) {                                              \
       return;                                                          \
    }
 
 #define RENDER_SPAN( span )                                            \
    GLuint i;                                                           \
-   GLchan rgb[MAX_WIDTH][3];                                           \
+   GLubyte rgb[MAX_WIDTH][3];                                          \
    span.intTex[0] -= FIXED_HALF; /* off-by-one error? */               \
    span.intTex[1] -= FIXED_HALF;                                       \
    for (i = 0; i < span.end; i++) {                                    \
@@ -211,9 +215,9 @@ _swrast_culltriangle( GLcontext *ctx,
          GLint t = FixedToInt(span.intTex[1]) & tmask;                 \
          GLint pos = (t << twidth_log2) + s;                           \
          pos = pos + pos + pos;  /* multiply by 3 */                   \
-         rgb[i][RCOMP] = texture[pos];                                 \
+         rgb[i][RCOMP] = texture[pos+2];                               \
          rgb[i][GCOMP] = texture[pos+1];                               \
-         rgb[i][BCOMP] = texture[pos+2];                               \
+         rgb[i][BCOMP] = texture[pos+0];                               \
          zRow[i] = z;                                                  \
          span.array->mask[i] = 1;                                      \
       }                                                                        \
@@ -276,25 +280,29 @@ affine_span(GLcontext *ctx, SWspan *span,
     * unused variables (for instance tf,sf,ti,si in case of GL_NEAREST).
     */
 
-#define NEAREST_RGB                    \
-   sample[RCOMP] = tex00[RCOMP];       \
-   sample[GCOMP] = tex00[GCOMP];       \
-   sample[BCOMP] = tex00[BCOMP];       \
-   sample[ACOMP] = CHAN_MAX
+#define NEAREST_RGB            \
+   sample[RCOMP] = tex00[2];   \
+   sample[GCOMP] = tex00[1];   \
+   sample[BCOMP] = tex00[0];   \
+   sample[ACOMP] = CHAN_MAX;
 
 #define LINEAR_RGB                                                     \
-   sample[RCOMP] = ilerp_2d(sf, tf, tex00[0], tex01[0], tex10[0], tex11[0]);\
+   sample[RCOMP] = ilerp_2d(sf, tf, tex00[2], tex01[2], tex10[2], tex11[2]);\
    sample[GCOMP] = ilerp_2d(sf, tf, tex00[1], tex01[1], tex10[1], tex11[1]);\
-   sample[BCOMP] = ilerp_2d(sf, tf, tex00[2], tex01[2], tex10[2], tex11[2]);\
+   sample[BCOMP] = ilerp_2d(sf, tf, tex00[0], tex01[0], tex10[0], tex11[0]);\
    sample[ACOMP] = CHAN_MAX;
 
-#define NEAREST_RGBA  COPY_CHAN4(sample, tex00)
+#define NEAREST_RGBA  \
+   sample[RCOMP] = tex00[3];   \
+   sample[GCOMP] = tex00[2];   \
+   sample[BCOMP] = tex00[1];   \
+   sample[ACOMP] = tex00[0];
 
 #define LINEAR_RGBA                                                    \
-   sample[RCOMP] = ilerp_2d(sf, tf, tex00[0], tex01[0], tex10[0], tex11[0]);\
-   sample[GCOMP] = ilerp_2d(sf, tf, tex00[1], tex01[1], tex10[1], tex11[1]);\
-   sample[BCOMP] = ilerp_2d(sf, tf, tex00[2], tex01[2], tex10[2], tex11[2]);\
-   sample[ACOMP] = ilerp_2d(sf, tf, tex00[3], tex01[3], tex10[3], tex11[3])
+   sample[RCOMP] = ilerp_2d(sf, tf, tex00[3], tex01[3], tex10[3], tex11[3]);\
+   sample[GCOMP] = ilerp_2d(sf, tf, tex00[2], tex01[2], tex10[2], tex11[2]);\
+   sample[BCOMP] = ilerp_2d(sf, tf, tex00[1], tex01[1], tex10[1], tex11[1]);\
+   sample[ACOMP] = ilerp_2d(sf, tf, tex00[0], tex01[0], tex10[0], tex11[0])
 
 #define MODULATE                                                         \
    dest[RCOMP] = span->red   * (sample[RCOMP] + 1u) >> (FIXED_SHIFT + 8); \
@@ -345,7 +353,11 @@ affine_span(GLcontext *ctx, SWspan *span,
    dest[2] = sample[2];                        \
    dest[3] = FixedToInt(span->alpha);
 
-#define NEAREST_RGBA_REPLACE  COPY_CHAN4(dest, tex00)
+#define NEAREST_RGBA_REPLACE  \
+   dest[RCOMP] = tex00[3]; \
+   dest[GCOMP] = tex00[2]; \
+   dest[BCOMP] = tex00[1]; \
+   dest[ACOMP] = tex00[0]
 
 #define SPAN_NEAREST(DO_TEX, COMPS)                                    \
        for (i = 0; i < span->end; i++) {                               \
@@ -406,7 +418,7 @@ affine_span(GLcontext *ctx, SWspan *span,
    switch (info->filter) {
    case GL_NEAREST:
       switch (info->format) {
-      case GL_RGB:
+      case MESA_FORMAT_RGB888:
          switch (info->envmode) {
          case GL_MODULATE:
             SPAN_NEAREST(NEAREST_RGB;MODULATE,3);
@@ -426,7 +438,7 @@ affine_span(GLcontext *ctx, SWspan *span,
             return;
          }
          break;
-      case GL_RGBA:
+      case MESA_FORMAT_RGBA8888:
          switch(info->envmode) {
          case GL_MODULATE:
             SPAN_NEAREST(NEAREST_RGBA;MODULATE,4);
@@ -455,7 +467,7 @@ affine_span(GLcontext *ctx, SWspan *span,
       span->intTex[0] -= FIXED_HALF;
       span->intTex[1] -= FIXED_HALF;
       switch (info->format) {
-      case GL_RGB:
+      case MESA_FORMAT_RGB888:
          switch (info->envmode) {
          case GL_MODULATE:
             SPAN_LINEAR(LINEAR_RGB;MODULATE,3);
@@ -475,7 +487,7 @@ affine_span(GLcontext *ctx, SWspan *span,
             return;
          }
          break;
-      case GL_RGBA:
+      case MESA_FORMAT_RGBA8888:
          switch (info->envmode) {
          case GL_MODULATE:
             SPAN_LINEAR(LINEAR_RGBA;MODULATE,4);
@@ -528,18 +540,22 @@ affine_span(GLcontext *ctx, SWspan *span,
 #define SETUP_CODE                                                     \
    struct affine_info info;                                            \
    struct gl_texture_unit *unit = ctx->Texture.Unit+0;                 \
-   struct gl_texture_object *obj =                                     \
+   const struct gl_texture_object *obj =                               \
       ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX];               \
-   const GLint b = obj->BaseLevel;                                     \
-   const GLfloat twidth = (GLfloat) obj->Image[0][b]->Width;           \
-   const GLfloat theight = (GLfloat) obj->Image[0][b]->Height;         \
-   info.texture = (const GLchan *) obj->Image[0][b]->Data;             \
-   info.twidth_log2 = obj->Image[0][b]->WidthLog2;                     \
-   info.smask = obj->Image[0][b]->Width - 1;                           \
-   info.tmask = obj->Image[0][b]->Height - 1;                          \
-   info.format = obj->Image[0][b]->_BaseFormat;                                \
+   const struct gl_texture_image *texImg =                             \
+      obj->Image[0][obj->BaseLevel];                                   \
+   const GLfloat twidth = (GLfloat) texImg->Width;                     \
+   const GLfloat theight = (GLfloat) texImg->Height;                   \
+   info.texture = (const GLchan *) texImg->Data;                       \
+   info.twidth_log2 = texImg->WidthLog2;                               \
+   info.smask = texImg->Width - 1;                                     \
+   info.tmask = texImg->Height - 1;                                    \
+   info.format = texImg->TexFormat;                                    \
    info.filter = obj->MinFilter;                                       \
    info.envmode = unit->EnvMode;                                       \
+   info.er = 0;                                        \
+   info.eg = 0;                                        \
+   info.eb = 0;                                        \
    span.arrayMask |= SPAN_RGBA;                                                \
                                                                        \
    if (info.envmode == GL_BLEND) {                                     \
@@ -555,25 +571,17 @@ affine_span(GLcontext *ctx, SWspan *span,
    }                                                                   \
                                                                        \
    switch (info.format) {                                              \
-   case GL_ALPHA:                                                      \
-   case GL_LUMINANCE:                                                  \
-   case GL_INTENSITY:                                                  \
-      info.tbytesline = obj->Image[0][b]->Width;                       \
-      break;                                                           \
-   case GL_LUMINANCE_ALPHA:                                            \
-      info.tbytesline = obj->Image[0][b]->Width * 2;                   \
+   case MESA_FORMAT_RGB888:                                            \
+      info.tbytesline = texImg->Width * 3;                             \
       break;                                                           \
-   case GL_RGB:                                                                \
-      info.tbytesline = obj->Image[0][b]->Width * 3;                   \
-      break;                                                           \
-   case GL_RGBA:                                                       \
-      info.tbytesline = obj->Image[0][b]->Width * 4;                   \
+   case MESA_FORMAT_RGBA8888:                                          \
+      info.tbytesline = texImg->Width * 4;                             \
       break;                                                           \
    default:                                                            \
       _mesa_problem(NULL, "Bad texture format in affine_texture_triangle");\
       return;                                                          \
    }                                                                   \
-   info.tsize = obj->Image[0][b]->Height * info.tbytesline;
+   info.tsize = texImg->Height * info.tbytesline;
 
 #define RENDER_SPAN( span )   affine_span(ctx, &span, &info);
 
@@ -680,7 +688,7 @@ fast_persp_span(GLcontext *ctx, SWspan *span,
    switch (info->filter) {
    case GL_NEAREST:
       switch (info->format) {
-      case GL_RGB:
+      case MESA_FORMAT_RGB888:
          switch (info->envmode) {
          case GL_MODULATE:
             SPAN_NEAREST(NEAREST_RGB;MODULATE,3);
@@ -700,7 +708,7 @@ fast_persp_span(GLcontext *ctx, SWspan *span,
             return;
          }
          break;
-      case GL_RGBA:
+      case MESA_FORMAT_RGBA8888:
          switch(info->envmode) {
          case GL_MODULATE:
             SPAN_NEAREST(NEAREST_RGBA;MODULATE,4);
@@ -727,7 +735,7 @@ fast_persp_span(GLcontext *ctx, SWspan *span,
 
    case GL_LINEAR:
       switch (info->format) {
-      case GL_RGB:
+      case MESA_FORMAT_RGB888:
          switch (info->envmode) {
          case GL_MODULATE:
             SPAN_LINEAR(LINEAR_RGB;MODULATE,3);
@@ -747,7 +755,7 @@ fast_persp_span(GLcontext *ctx, SWspan *span,
             return;
          }
          break;
-      case GL_RGBA:
+      case MESA_FORMAT_RGBA8888:
          switch (info->envmode) {
          case GL_MODULATE:
             SPAN_LINEAR(LINEAR_RGBA;MODULATE,4);
@@ -799,16 +807,20 @@ fast_persp_span(GLcontext *ctx, SWspan *span,
 #define SETUP_CODE                                                     \
    struct persp_info info;                                             \
    const struct gl_texture_unit *unit = ctx->Texture.Unit+0;           \
-   struct gl_texture_object *obj =                                     \
+   const struct gl_texture_object *obj =                               \
       ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX];               \
-   const GLint b = obj->BaseLevel;                                     \
-   info.texture = (const GLchan *) obj->Image[0][b]->Data;             \
-   info.twidth_log2 = obj->Image[0][b]->WidthLog2;                     \
-   info.smask = obj->Image[0][b]->Width - 1;                           \
-   info.tmask = obj->Image[0][b]->Height - 1;                          \
-   info.format = obj->Image[0][b]->_BaseFormat;                                \
+   const struct gl_texture_image *texImg =                             \
+      obj->Image[0][obj->BaseLevel];                                   \
+   info.texture = (const GLchan *) texImg->Data;                       \
+   info.twidth_log2 = texImg->WidthLog2;                               \
+   info.smask = texImg->Width - 1;                                     \
+   info.tmask = texImg->Height - 1;                                    \
+   info.format = texImg->TexFormat;                                    \
    info.filter = obj->MinFilter;                                       \
    info.envmode = unit->EnvMode;                                       \
+   info.er = 0;                                        \
+   info.eg = 0;                                        \
+   info.eb = 0;                                        \
                                                                        \
    if (info.envmode == GL_BLEND) {                                     \
       /* potential off-by-one error here? (1.0f -> 2048 -> 0) */       \
@@ -823,25 +835,17 @@ fast_persp_span(GLcontext *ctx, SWspan *span,
    }                                                                   \
                                                                        \
    switch (info.format) {                                              \
-   case GL_ALPHA:                                                      \
-   case GL_LUMINANCE:                                                  \
-   case GL_INTENSITY:                                                  \
-      info.tbytesline = obj->Image[0][b]->Width;                       \
-      break;                                                           \
-   case GL_LUMINANCE_ALPHA:                                            \
-      info.tbytesline = obj->Image[0][b]->Width * 2;                   \
-      break;                                                           \
-   case GL_RGB:                                                                \
-      info.tbytesline = obj->Image[0][b]->Width * 3;                   \
+   case MESA_FORMAT_RGB888:                                            \
+      info.tbytesline = texImg->Width * 3;                             \
       break;                                                           \
-   case GL_RGBA:                                                       \
-      info.tbytesline = obj->Image[0][b]->Width * 4;                   \
+   case MESA_FORMAT_RGBA8888:                                          \
+      info.tbytesline = texImg->Width * 4;                             \
       break;                                                           \
    default:                                                            \
       _mesa_problem(NULL, "Bad texture format in persp_textured_triangle");\
       return;                                                          \
    }                                                                   \
-   info.tsize = obj->Image[0][b]->Height * info.tbytesline;
+   info.tsize = texImg->Height * info.tbytesline;
 
 #define RENDER_SPAN( span )                    \
    span.interpMask &= ~SPAN_RGBA;              \
@@ -883,7 +887,7 @@ fast_persp_span(GLcontext *ctx, SWspan *span,
       return;                                                          \
    }
 #define RENDER_SPAN( span )                                            \
-   if (rb->DepthBits <= 16) {                                          \
+   if (rb->Format == MESA_FORMAT_Z16) {                                        \
       GLuint i;                                                                \
       const GLushort *zRow = (const GLushort *)                                \
          rb->GetPointer(ctx, rb, span.x, span.y);                      \
@@ -1026,10 +1030,10 @@ _swrast_choose_triangle( GLcontext *ctx )
           ctx->Depth.Func == GL_LESS &&
           !ctx->Stencil._Enabled) {
          if ((rgbmode &&
-              ctx->Color.ColorMask[0] == 0 &&
-              ctx->Color.ColorMask[1] == 0 &&
-              ctx->Color.ColorMask[2] == 0 &&
-              ctx->Color.ColorMask[3] == 0)
+              ctx->Color.ColorMask[0][0] == 0 &&
+              ctx->Color.ColorMask[0][1] == 0 &&
+              ctx->Color.ColorMask[0][2] == 0 &&
+              ctx->Color.ColorMask[0][3] == 0)
              ||
              (!rgbmode && ctx->Color.IndexMask == 0)) {
             USE(occlusion_zless_triangle);
@@ -1055,19 +1059,20 @@ _swrast_choose_triangle( GLcontext *ctx )
          const struct gl_texture_object *texObj2D;
          const struct gl_texture_image *texImg;
          GLenum minFilter, magFilter, envMode;
-         GLint format;
+         gl_format format;
          texObj2D = ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX];
 
          texImg = texObj2D ? texObj2D->Image[0][texObj2D->BaseLevel] : NULL;
-         format = texImg ? texImg->TexFormat->MesaFormat : -1;
-         minFilter = texObj2D ? texObj2D->MinFilter : (GLenum) 0;
-         magFilter = texObj2D ? texObj2D->MagFilter : (GLenum) 0;
+         format = texImg ? texImg->TexFormat : MESA_FORMAT_NONE;
+         minFilter = texObj2D ? texObj2D->MinFilter : GL_NONE;
+         magFilter = texObj2D ? texObj2D->MagFilter : GL_NONE;
          envMode = ctx->Texture.Unit[0].EnvMode;
 
          /* First see if we can use an optimized 2-D texture function */
          if (ctx->Texture._EnabledCoordUnits == 0x1
              && !ctx->FragmentProgram._Current
              && !ctx->ATIFragmentShader._Enabled
+             && ctx->Texture._EnabledUnits == 0x1
              && ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT
              && texObj2D->WrapS == GL_REPEAT
              && texObj2D->WrapT == GL_REPEAT
@@ -1075,7 +1080,7 @@ _swrast_choose_triangle( GLcontext *ctx )
              && texImg->_IsPowerOfTwo
              && texImg->Border == 0
              && texImg->Width == texImg->RowStride
-             && (format == MESA_FORMAT_RGB || format == MESA_FORMAT_RGBA)
+             && (format == MESA_FORMAT_RGB888 || format == MESA_FORMAT_RGBA8888)
              && minFilter == magFilter
              && ctx->Light.Model.ColorControl == GL_SINGLE_COLOR
              && !swrast->_FogEnabled
@@ -1083,7 +1088,7 @@ _swrast_choose_triangle( GLcontext *ctx )
              && ctx->Texture.Unit[0].EnvMode != GL_COMBINE4_NV) {
            if (ctx->Hint.PerspectiveCorrection==GL_FASTEST) {
               if (minFilter == GL_NEAREST
-                  && format == MESA_FORMAT_RGB
+                  && format == MESA_FORMAT_RGB888
                   && (envMode == GL_REPLACE || envMode == GL_DECAL)
                   && ((swrast->_RasterMask == (DEPTH_BIT | TEXTURE_BIT)
                        && ctx->Depth.Func == GL_LESS
@@ -1102,7 +1107,15 @@ _swrast_choose_triangle( GLcontext *ctx )
 #if CHAN_BITS != 8
                   USE(general_triangle);
 #else
-                  USE(affine_textured_triangle);
+                  if (format == MESA_FORMAT_RGBA8888 && !_mesa_little_endian()) {
+                     /* We only handle RGBA8888 correctly on little endian
+                      * in the optimized code above.
+                      */
+                     USE(general_triangle);
+                  }
+                  else {
+                     USE(affine_textured_triangle);
+                 }
 #endif
               }
            }
index 724b5e94fa55faebd63a083fe0624abc35ea1630..8484aab5a93fd7f86f7438e54c0e685aad59fa07 100644 (file)
@@ -41,9 +41,9 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
    GLenum mode = GL_FILL;
    GLuint facing = 0;
    GLchan saved_color[3][4];
-   GLfloat saved_col0[3][4];
-   GLfloat saved_spec[3][4];
-   GLfloat saved_index[3];
+   GLfloat saved_col0[3][4] = { { 0 } };
+   GLfloat saved_spec[3][4] = { { 0 } };
+   GLfloat saved_index[3] = { 0 };
 
    v[0] = &verts[e0];
    v[1] = &verts[e1];
@@ -67,8 +67,8 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
         if (facing == 1) {
            if (IND & SS_TWOSIDE_BIT) {
               if (IND & SS_RGBA_BIT) {
-                  if (VB->ColorPtr[1]) {
-                     GLfloat (*vbcolor)[4] = VB->ColorPtr[1]->data;
+                  if (VB->BackfaceColorPtr) {
+                     GLfloat (*vbcolor)[4] = VB->BackfaceColorPtr->data;
 
                      if (swsetup->intColors) {
                         COPY_CHAN4(saved_color[0], v[0]->color);
@@ -81,7 +81,7 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
                         COPY_4V(saved_col0[2], v[2]->attrib[FRAG_ATTRIB_COL0]);
                      }
 
-                     if (VB->ColorPtr[1]->stride) {
+                     if (VB->BackfaceColorPtr->stride) {
                         if (swsetup->intColors) {
                            SS_COLOR(v[0]->color, vbcolor[e0]);
                            SS_COLOR(v[1]->color, vbcolor[e1]);
@@ -108,14 +108,14 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
                      }
                   }
 
-                 if (VB->SecondaryColorPtr[1]) {
-                    GLfloat (*vbspec)[4] = VB->SecondaryColorPtr[1]->data;
+                 if (VB->BackfaceSecondaryColorPtr) {
+                    GLfloat (*vbspec)[4] = VB->BackfaceSecondaryColorPtr->data;
 
                     COPY_4V(saved_spec[0], v[0]->attrib[FRAG_ATTRIB_COL1]);
                     COPY_4V(saved_spec[1], v[1]->attrib[FRAG_ATTRIB_COL1]);
                     COPY_4V(saved_spec[2], v[2]->attrib[FRAG_ATTRIB_COL1]);
 
-                    if (VB->SecondaryColorPtr[1]->stride) {
+                    if (VB->BackfaceSecondaryColorPtr->stride) {
                        SS_SPEC(v[0]->attrib[FRAG_ATTRIB_COL1], vbspec[e0]);
                        SS_SPEC(v[1]->attrib[FRAG_ATTRIB_COL1], vbspec[e1]);
                        SS_SPEC(v[2]->attrib[FRAG_ATTRIB_COL1], vbspec[e2]);
@@ -127,7 +127,7 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
                     }
                  }
               } else {
-                 GLfloat *vbindex = (GLfloat *)VB->IndexPtr[1]->data;
+                 GLfloat *vbindex = (GLfloat *)VB->BackfaceIndexPtr->data;
                  saved_index[0] = v[0]->attrib[FRAG_ATTRIB_CI][0];
                  saved_index[1] = v[1]->attrib[FRAG_ATTRIB_CI][0];
                  saved_index[2] = v[2]->attrib[FRAG_ATTRIB_CI][0];
@@ -200,7 +200,7 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
    if (IND & SS_TWOSIDE_BIT) {
       if (facing == 1) {
         if (IND & SS_RGBA_BIT) {
-            if (VB->ColorPtr[1]) {
+            if (VB->BackfaceColorPtr) {
                if (swsetup->intColors) {
                   COPY_CHAN4(v[0]->color, saved_color[0]);
                   COPY_CHAN4(v[1]->color, saved_color[1]);
@@ -213,7 +213,7 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
                }
             }
 
-           if (VB->SecondaryColorPtr[1]) {
+           if (VB->BackfaceSecondaryColorPtr) {
               COPY_4V(v[0]->attrib[FRAG_ATTRIB_COL1], saved_spec[0]);
               COPY_4V(v[1]->attrib[FRAG_ATTRIB_COL1], saved_spec[1]);
               COPY_4V(v[2]->attrib[FRAG_ATTRIB_COL1], saved_spec[2]);
index f2771cde09566bec0288669246d98f520661a9a0..db21b4589de6a2a4fed94a73f930c43bf30697c2 100644 (file)
@@ -171,7 +171,7 @@ _tnl_InvalidateState( GLcontext *ctx, GLuint new_state )
    if (vp) {
       GLuint i;
       for (i = 0; i < MAX_VARYING; i++) {
-         if (vp->Base.OutputsWritten & (1 << (VERT_RESULT_VAR0 + i))) {
+        if (vp->Base.OutputsWritten & BITFIELD64_BIT(VERT_RESULT_VAR0 + i)) {
             RENDERINPUTS_SET(tnl->render_inputs_bitset,
                              _TNL_ATTRIB_GENERIC(i));
          }
index 6137c2d2fe52220f6c9e862e5f5a282f79264664..ebaae6335b942d906bacce86ae0dc9ac08d21a50 100644 (file)
@@ -198,26 +198,23 @@ struct vertex_buffer
     */
    GLuint Count;  /**< Number of vertices currently in buffer */
 
-   /* Pointers to current data.
-    * XXX some of these fields alias AttribPtr below and should be removed
-    * such as NormalPtr, TexCoordPtr, FogCoordPtr, etc.
+   /* Pointers to current data.  Most of the data is in AttribPtr -- all of
+    * it that is one of VERT_ATTRIB_X.  For things only produced by TNL,
+    * such as backface color or eye-space coordinates, they are stored
+    * here.
     */
    GLuint      *Elts;                          
-   GLvector4f  *ObjPtr;                                /* _TNL_BIT_POS */
    GLvector4f  *EyePtr;                                /* _TNL_BIT_POS */
    GLvector4f  *ClipPtr;                       /* _TNL_BIT_POS */
    GLvector4f  *NdcPtr;                         /* _TNL_BIT_POS */
    GLubyte     ClipOrMask;                     /* _TNL_BIT_POS */
    GLubyte     ClipAndMask;                    /* _TNL_BIT_POS */
    GLubyte     *ClipMask;                      /* _TNL_BIT_POS */
-   GLvector4f  *NormalPtr;                     /* _TNL_BIT_NORMAL */
    GLfloat     *NormalLengthPtr;               /* _TNL_BIT_NORMAL */
    GLboolean   *EdgeFlag;                      /* _TNL_BIT_EDGEFLAG */
-   GLvector4f  *TexCoordPtr[MAX_TEXTURE_COORD_UNITS]; /* VERT_TEX_0..n */
-   GLvector4f  *IndexPtr[2];                   /* _TNL_BIT_INDEX */
-   GLvector4f  *ColorPtr[2];                   /* _TNL_BIT_COLOR0 */
-   GLvector4f  *SecondaryColorPtr[2];           /* _TNL_BIT_COLOR1 */
-   GLvector4f  *FogCoordPtr;                   /* _TNL_BIT_FOG */
+   GLvector4f  *BackfaceIndexPtr;
+   GLvector4f  *BackfaceColorPtr;
+   GLvector4f  *BackfaceSecondaryColorPtr;
 
    const struct _mesa_prim  *Primitive;                      
    GLuint      PrimitiveCount;       
@@ -402,11 +399,6 @@ struct tnl_device_driver
    /* Alert tnl-aware drivers of changes to material.
     */
 
-   void (*NotifyInputChanges)(GLcontext *ctx, GLuint bitmask);
-   /* Alert tnl-aware drivers of changes to size and stride of input
-    * arrays.
-    */
-
    /***
     *** Rendering -- These functions called only from t_vb_render.c
     ***/
index 04fa106300351cf97e52f420621b91275041a3e0..d31b29b9b40b193187edbd6db903ab2a98c5936e 100644 (file)
@@ -26,6 +26,7 @@
  */
 
 #include "main/glheader.h"
+#include "main/condrender.h"
 #include "main/context.h"
 #include "main/imports.h"
 #include "main/state.h"
@@ -251,22 +252,10 @@ static void bind_inputs( GLcontext *ctx,
     */
    VB->Count = count;
 
-
-   /* Legacy pointers -- remove one day.
-    */
-   VB->ObjPtr = VB->AttribPtr[_TNL_ATTRIB_POS];
-   VB->NormalPtr = VB->AttribPtr[_TNL_ATTRIB_NORMAL];
-   VB->ColorPtr[0] = VB->AttribPtr[_TNL_ATTRIB_COLOR0];
-   VB->ColorPtr[1] = NULL;
-   VB->IndexPtr[0] = VB->AttribPtr[_TNL_ATTRIB_COLOR_INDEX];
-   VB->IndexPtr[1] = NULL;
-   VB->SecondaryColorPtr[0] = VB->AttribPtr[_TNL_ATTRIB_COLOR1];
-   VB->SecondaryColorPtr[1] = NULL;
-   VB->FogCoordPtr = VB->AttribPtr[_TNL_ATTRIB_FOG];
-
-   for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
-      VB->TexCoordPtr[i] = VB->AttribPtr[_TNL_ATTRIB_TEX0 + i];
-   }
+   /* These should perhaps be part of _TNL_ATTRIB_* */
+   VB->BackfaceColorPtr = NULL;
+   VB->BackfaceIndexPtr = NULL;
+   VB->BackfaceSecondaryColorPtr = NULL;
 
    /* Clipping and drawing code still requires this to be a packed
     * array of ubytes which can be written into.  TODO: Fix and
@@ -398,6 +387,9 @@ void _tnl_draw_prims( GLcontext *ctx,
    GLuint max_basevertex = prim->basevertex;
    GLuint i;
 
+   if (!_mesa_check_conditional_render(ctx))
+      return; /* don't draw */
+
    for (i = 1; i < nr_prims; i++)
       max_basevertex = MAX2(max_basevertex, prim[i].basevertex);
 
index 357ef1e24b5bf4914fe2b3e3b4e31d86eb314ae3..01b30babb4828b4c8ebcdee8babea9dfba790086 100644 (file)
@@ -86,10 +86,6 @@ static GLuint check_input_changes( GLcontext *ctx )
       }
    }
 
-   if (tnl->pipeline.input_changes &&
-      tnl->Driver.NotifyInputChanges) 
-      tnl->Driver.NotifyInputChanges( ctx, tnl->pipeline.input_changes );
-
    return tnl->pipeline.input_changes;
 }
 
index f3a7bd49f40189a4ca81ebc92e0365a9d315138a..4a0e6ad4f997cad65803b2e6663f6339d48bf25e 100644 (file)
@@ -156,7 +156,7 @@ run_fog_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
       GLuint i;
       GLfloat *coord;
       /* Fog is computed from vertex or fragment Z values */
-      /* source = VB->ObjPtr or VB->EyePtr coords */
+      /* source = VB->AttribPtr[_TNL_ATTRIB_POS] or VB->EyePtr coords */
       /* dest = VB->AttribPtr[_TNL_ATTRIB_FOG] = fog stage private storage */
       VB->AttribPtr[_TNL_ATTRIB_FOG] = &store->fogcoord;
 
@@ -176,11 +176,12 @@ run_fog_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
         /* Full eye coords weren't required, just calculate the
          * eye Z values.
          */
-        _mesa_dotprod_tab[VB->ObjPtr->size]( (GLfloat *) input->data,
-                                             4 * sizeof(GLfloat),
-                                             VB->ObjPtr, plane );
+        _mesa_dotprod_tab[VB->AttribPtr[_TNL_ATTRIB_POS]->size]
+           ( (GLfloat *) input->data,
+             4 * sizeof(GLfloat),
+             VB->AttribPtr[_TNL_ATTRIB_POS], plane );
 
-        input->count = VB->ObjPtr->count;
+        input->count = VB->AttribPtr[_TNL_ATTRIB_POS]->count;
 
         /* make sure coords are really positive
            NOTE should avoid going through array twice */
@@ -213,7 +214,7 @@ run_fog_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
       /* input->count may be one if glFogCoord was only called once
        * before glBegin.  But we need to compute fog for all vertices.
        */
-      input->count = VB->ObjPtr->count;
+      input->count = VB->AttribPtr[_TNL_ATTRIB_POS]->count;
 
       VB->AttribPtr[_TNL_ATTRIB_FOG] = &store->fogcoord;  /* dest data */
    }
@@ -227,7 +228,6 @@ run_fog_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
       VB->AttribPtr[_TNL_ATTRIB_FOG] = input;
    }
 
-   VB->FogCoordPtr = VB->AttribPtr[_TNL_ATTRIB_FOG];
    return GL_TRUE;
 }
 
index f47f99397c9ad29bf59664884f66325f1d25d879..8a0fe63fd8b75ab60feaa3042c883ae093aa79b8 100644 (file)
@@ -127,7 +127,7 @@ prepare_materials(GLcontext *ctx,
       const GLuint bitmask = ctx->Light.ColorMaterialBitmask;
       for (i = 0 ; i < MAT_ATTRIB_MAX ; i++)
         if (bitmask & (1<<i))
-           VB->AttribPtr[_TNL_ATTRIB_MAT_FRONT_AMBIENT + i] = VB->ColorPtr[0];
+           VB->AttribPtr[_TNL_ATTRIB_MAT_FRONT_AMBIENT + i] = VB->AttribPtr[_TNL_ATTRIB_COLOR0];
    }
 
    /* Now, for each material attribute that's tracking vertex color, save
@@ -200,7 +200,7 @@ static GLboolean run_lighting( GLcontext *ctx,
    struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    struct vertex_buffer *VB = &tnl->vb;
-   GLvector4f *input = ctx->_NeedEyeCoords ? VB->EyePtr : VB->ObjPtr;
+   GLvector4f *input = ctx->_NeedEyeCoords ? VB->EyePtr : VB->AttribPtr[_TNL_ATTRIB_POS];
    GLuint idx;
 
    if (!ctx->Light.Enabled || ctx->VertexProgram._Current)
@@ -208,13 +208,13 @@ static GLboolean run_lighting( GLcontext *ctx,
 
    /* Make sure we can talk about position x,y and z:
     */
-   if (input->size <= 2 && input == VB->ObjPtr) {
+   if (input->size <= 2 && input == VB->AttribPtr[_TNL_ATTRIB_POS]) {
 
       _math_trans_4f( store->Input.data,
-                     VB->ObjPtr->data,
-                     VB->ObjPtr->stride,
+                     VB->AttribPtr[_TNL_ATTRIB_POS]->data,
+                     VB->AttribPtr[_TNL_ATTRIB_POS]->stride,
                      GL_FLOAT,
-                     VB->ObjPtr->size,
+                     VB->AttribPtr[_TNL_ATTRIB_POS]->size,
                      0,
                      VB->Count );
 
@@ -246,10 +246,6 @@ static GLboolean run_lighting( GLcontext *ctx,
     */
    store->light_func_tab[idx]( ctx, VB, stage, input );
 
-   VB->AttribPtr[_TNL_ATTRIB_COLOR0] = VB->ColorPtr[0];
-   VB->AttribPtr[_TNL_ATTRIB_COLOR1] = VB->SecondaryColorPtr[0];
-   VB->AttribPtr[_TNL_ATTRIB_COLOR_INDEX] = VB->IndexPtr[0];
-
    return GL_TRUE;
 }
 
index 124ca3c74fe258b21616263979db681910ffc267..4ebef2356f50e7ca459b9fff1423999778b5c553 100644 (file)
@@ -72,13 +72,13 @@ static void TAG(light_rgba_spec)( GLcontext *ctx,
    fprintf(stderr, "%s\n", __FUNCTION__ );
 #endif
 
-   VB->ColorPtr[0] = &store->LitColor[0];
-   VB->SecondaryColorPtr[0] = &store->LitSecondary[0];
+   VB->AttribPtr[_TNL_ATTRIB_COLOR0] = &store->LitColor[0];
+   VB->AttribPtr[_TNL_ATTRIB_COLOR1] = &store->LitSecondary[0];
    sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
 
 #if IDX & LIGHT_TWOSIDE
-   VB->ColorPtr[1] = &store->LitColor[1];
-   VB->SecondaryColorPtr[1] = &store->LitSecondary[1];
+   VB->BackfaceColorPtr = &store->LitColor[1];
+   VB->BackfaceSecondaryColorPtr = &store->LitSecondary[1];
    sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
 #endif
 
@@ -259,11 +259,11 @@ static void TAG(light_rgba)( GLcontext *ctx,
    fprintf(stderr, "%s\n", __FUNCTION__ );
 #endif
 
-   VB->ColorPtr[0] = &store->LitColor[0];
+   VB->AttribPtr[_TNL_ATTRIB_COLOR0] = &store->LitColor[0];
    sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
 
 #if IDX & LIGHT_TWOSIDE
-   VB->ColorPtr[1] = &store->LitColor[1];
+   VB->BackfaceColorPtr = &store->LitColor[1];
    sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
 #endif
 
@@ -449,9 +449,9 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx,
 
    (void) input;               /* doesn't refer to Eye or Obj */
 
-   VB->ColorPtr[0] = &store->LitColor[0];
+   VB->AttribPtr[_TNL_ATTRIB_COLOR0] = &store->LitColor[0];
 #if IDX & LIGHT_TWOSIDE
-   VB->ColorPtr[1] = &store->LitColor[1];
+   VB->BackfaceColorPtr = &store->LitColor[1];
 #endif
 
    if (nr > 1) {
@@ -559,9 +559,9 @@ static void TAG(light_fast_rgba)( GLcontext *ctx,
    sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
    sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
 
-   VB->ColorPtr[0] = &store->LitColor[0];
+   VB->AttribPtr[_TNL_ATTRIB_COLOR0] = &store->LitColor[0];
 #if IDX & LIGHT_TWOSIDE
-   VB->ColorPtr[1] = &store->LitColor[1];
+   VB->BackfaceColorPtr = &store->LitColor[1];
 #endif
 
    if (nr > 1) {
@@ -665,14 +665,14 @@ static void TAG(light_ci)( GLcontext *ctx,
    fprintf(stderr, "%s\n", __FUNCTION__ );
 #endif
 
-   VB->IndexPtr[0] = &store->LitIndex[0];
+   VB->AttribPtr[_TNL_ATTRIB_COLOR_INDEX] = &store->LitIndex[0];
 #if IDX & LIGHT_TWOSIDE
-   VB->IndexPtr[1] = &store->LitIndex[1];
+   VB->BackfaceIndexPtr = &store->LitIndex[1];
 #endif
 
-   indexResult[0] = (GLfloat *)VB->IndexPtr[0]->data;
+   indexResult[0] = (GLfloat *)VB->AttribPtr[_TNL_ATTRIB_COLOR_INDEX]->data;
 #if IDX & LIGHT_TWOSIDE
-   indexResult[1] = (GLfloat *)VB->IndexPtr[1]->data;
+   indexResult[1] = (GLfloat *)VB->BackfaceIndexPtr->data;
 #endif
 
    /* loop over vertices */
index a4821cc1cccf7230a53752d6012b7c591ad84032..693d3dc118d17d806c816b676fb84581fd939868 100644 (file)
@@ -79,7 +79,6 @@ run_normal_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
    }
 
    VB->AttribPtr[_TNL_ATTRIB_NORMAL] = &store->normal;
-   VB->NormalPtr = &store->normal;
 
    VB->NormalLengthPtr = NULL; /* no longer valid */
    return GL_TRUE;
index c10a27614ff9e15249155211016ea9080e38b6c2..c289cdfbaac84379d8305739979f31e8f26e8070 100644 (file)
@@ -329,7 +329,7 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage )
    /* make list of outputs to save some time below */
    numOutputs = 0;
    for (i = 0; i < VERT_RESULT_MAX; i++) {
-      if (program->Base.OutputsWritten & (1 << i)) {
+      if (program->Base.OutputsWritten & BITFIELD64_BIT(i)) {
          outputs[numOutputs++] = i;
       }
    }
@@ -407,14 +407,14 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage )
    /* Fixup fog and point size results if needed */
    if (program->IsNVProgram) {
       if (ctx->Fog.Enabled &&
-          (program->Base.OutputsWritten & (1 << VERT_RESULT_FOGC)) == 0) {
+          (program->Base.OutputsWritten & BITFIELD64_BIT(VERT_RESULT_FOGC)) == 0) {
          for (i = 0; i < VB->Count; i++) {
             store->results[VERT_RESULT_FOGC].data[i][0] = 1.0;
          }
       }
 
       if (ctx->VertexProgram.PointSizeEnabled &&
-          (program->Base.OutputsWritten & (1 << VERT_RESULT_PSIZ)) == 0) {
+          (program->Base.OutputsWritten & BITFIELD64_BIT(VERT_RESULT_PSIZ)) == 0) {
          for (i = 0; i < VB->Count; i++) {
             store->results[VERT_RESULT_PSIZ].data[i][0] = ctx->Point.Size;
          }
@@ -454,25 +454,20 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage )
       VB->ClipPtr->count = VB->Count;
    }
 
-   VB->ColorPtr[0] = &store->results[VERT_RESULT_COL0];
-   VB->ColorPtr[1] = &store->results[VERT_RESULT_BFC0];
-   VB->SecondaryColorPtr[0] = &store->results[VERT_RESULT_COL1];
-   VB->SecondaryColorPtr[1] = &store->results[VERT_RESULT_BFC1];
-   VB->FogCoordPtr = &store->results[VERT_RESULT_FOGC];
-
    VB->AttribPtr[VERT_ATTRIB_COLOR0] = &store->results[VERT_RESULT_COL0];
    VB->AttribPtr[VERT_ATTRIB_COLOR1] = &store->results[VERT_RESULT_COL1];
    VB->AttribPtr[VERT_ATTRIB_FOG] = &store->results[VERT_RESULT_FOGC];
    VB->AttribPtr[_TNL_ATTRIB_POINTSIZE] = &store->results[VERT_RESULT_PSIZ];
+   VB->BackfaceColorPtr = &store->results[VERT_RESULT_BFC0];
+   VB->BackfaceSecondaryColorPtr = &store->results[VERT_RESULT_BFC1];
 
    for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
-      VB->TexCoordPtr[i] = 
       VB->AttribPtr[_TNL_ATTRIB_TEX0 + i]
          = &store->results[VERT_RESULT_TEX0 + i];
    }
 
    for (i = 0; i < ctx->Const.MaxVarying; i++) {
-      if (program->Base.OutputsWritten & (1 << (VERT_RESULT_VAR0 + i))) {
+      if (program->Base.OutputsWritten & BITFIELD64_BIT(VERT_RESULT_VAR0 + i)) {
          /* Note: varying results get put into the generic attributes */
         VB->AttribPtr[VERT_ATTRIB_GENERIC0+i]
             = &store->results[VERT_RESULT_VAR0 + i];
index 7c1819b223cc7d6d9f100d1d507df8aff67fe153..9ef13bc96d87cadb66f2f604779b30dbf77b9c3b 100644 (file)
@@ -341,7 +341,7 @@ static void texgen( GLcontext *ctx,
    GLvector4f *in = VB->AttribPtr[VERT_ATTRIB_TEX0 + unit];
    GLvector4f *out = &store->texcoord[unit];
    const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
-   const GLvector4f *obj = VB->ObjPtr;
+   const GLvector4f *obj = VB->AttribPtr[_TNL_ATTRIB_POS];
    const GLvector4f *eye = VB->EyePtr;
    const GLvector4f *normal = VB->AttribPtr[_TNL_ATTRIB_NORMAL];
    const GLfloat *m = store->tmp_m;
@@ -498,7 +498,6 @@ static GLboolean run_texgen_stage( GLcontext *ctx,
 
         store->TexgenFunc[i]( ctx, store, i );
 
-         VB->TexCoordPtr[i] =
          VB->AttribPtr[VERT_ATTRIB_TEX0 + i] = &store->texcoord[i];
       }
    }
index 0abe8cc35dd94d39f81ec6643c2d9c917f25dc6a..83688290e59fcbe59ce6ae7028f38227c82713a1 100644 (file)
@@ -73,7 +73,6 @@ static GLboolean run_texmat_stage( GLcontext *ctx,
                              ctx->TextureMatrixStack[i].Top,
                              VB->AttribPtr[_TNL_ATTRIB_TEX0 + i]);
 
-         VB->TexCoordPtr[i] = 
         VB->AttribPtr[VERT_ATTRIB_TEX0+i] = &store->texcoord[i];
       }
    }
index 4734754ea4016dd470fdf9466a109230387f29d8..bc7e0951ec8c93c47bf011d586ceda5c6816df62 100644 (file)
@@ -152,16 +152,16 @@ static GLboolean run_vertex_stage( GLcontext *ctx,
        * Use combined ModelProject to avoid some depth artifacts
        */
       if (ctx->ModelviewMatrixStack.Top->type == MATRIX_IDENTITY)
-        VB->EyePtr = VB->ObjPtr;
+        VB->EyePtr = VB->AttribPtr[_TNL_ATTRIB_POS];
       else
         VB->EyePtr = TransformRaw( &store->eye,
                                    ctx->ModelviewMatrixStack.Top,
-                                   VB->ObjPtr);
+                                   VB->AttribPtr[_TNL_ATTRIB_POS]);
    }
 
    VB->ClipPtr = TransformRaw( &store->clip,
                               &ctx->_ModelProjectMatrix,
-                              VB->ObjPtr );
+                              VB->AttribPtr[_TNL_ATTRIB_POS] );
 
    /* Drivers expect this to be clean to element 4...
     */
index 9812f8c8081aed83eac539a36f07fa389a4fbc9b..99ddace73d13f1c39d2e06bea72dd71f16d3d62c 100644 (file)
@@ -210,7 +210,7 @@ static INLINE void insert_3f_xyw_err( const struct tnl_clipspace_attr *a, GLubyt
 {
    (void) a; (void) v; (void) in;
    DEBUG_INSERT;
-   _mesa_exit(1);
+   exit(1);
 }
 
 static INLINE void insert_3f_3( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )
@@ -1092,33 +1092,33 @@ void _tnl_generic_interp_extras( GLcontext *ctx,
 {
    struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
 
-   /* If stride is zero, ColorPtr[1] is constant across the VB, so
+   /* If stride is zero, BackfaceColorPtr is constant across the VB, so
     * there is no point interpolating between two values as they will
     * be identical.  In all other cases, this value is generated by
     * t_vb_lighttmp.h and has a stride of 4 dwords.
     */
-   if (VB->ColorPtr[1] && VB->ColorPtr[1]->stride) {
-      assert(VB->ColorPtr[1]->stride == 4 * sizeof(GLfloat));
+   if (VB->BackfaceColorPtr && VB->BackfaceColorPtr->stride) {
+      assert(VB->BackfaceColorPtr->stride == 4 * sizeof(GLfloat));
 
       INTERP_4F( t,
-                VB->ColorPtr[1]->data[dst],
-                VB->ColorPtr[1]->data[out],
-                VB->ColorPtr[1]->data[in] );
+                VB->BackfaceColorPtr->data[dst],
+                VB->BackfaceColorPtr->data[out],
+                VB->BackfaceColorPtr->data[in] );
    }
 
-   if (VB->SecondaryColorPtr[1]) {
-      assert(VB->SecondaryColorPtr[1]->stride == 4 * sizeof(GLfloat));
+   if (VB->BackfaceSecondaryColorPtr) {
+      assert(VB->BackfaceSecondaryColorPtr->stride == 4 * sizeof(GLfloat));
       
       INTERP_3F( t,
-                VB->SecondaryColorPtr[1]->data[dst],
-                VB->SecondaryColorPtr[1]->data[out],
-                VB->SecondaryColorPtr[1]->data[in] );
+                VB->BackfaceSecondaryColorPtr->data[dst],
+                VB->BackfaceSecondaryColorPtr->data[out],
+                VB->BackfaceSecondaryColorPtr->data[in] );
    }
    
-   if (VB->IndexPtr[1]) {
-      VB->IndexPtr[1]->data[dst][0] = LINTERP( t,
-                                              VB->IndexPtr[1]->data[out][0],
-                                              VB->IndexPtr[1]->data[in][0] );
+   if (VB->BackfaceIndexPtr) {
+      VB->BackfaceIndexPtr->data[dst][0] = LINTERP( t,
+                                              VB->BackfaceIndexPtr->data[out][0],
+                                              VB->BackfaceIndexPtr->data[in][0] );
    }
 
    if (VB->EdgeFlag) {
@@ -1135,18 +1135,18 @@ void _tnl_generic_copy_pv_extras( GLcontext *ctx,
 
    /* See above comment:
     */
-   if (VB->ColorPtr[1] && VB->ColorPtr[1]->stride) {
-      COPY_4FV( VB->ColorPtr[1]->data[dst], 
-               VB->ColorPtr[1]->data[src] );
+   if (VB->BackfaceColorPtr && VB->BackfaceColorPtr->stride) {
+      COPY_4FV( VB->BackfaceColorPtr->data[dst],
+               VB->BackfaceColorPtr->data[src] );
    }
 
-   if (VB->SecondaryColorPtr[1]) {
-      COPY_4FV( VB->SecondaryColorPtr[1]->data[dst], 
-               VB->SecondaryColorPtr[1]->data[src] );
+   if (VB->BackfaceSecondaryColorPtr) {
+      COPY_4FV( VB->BackfaceSecondaryColorPtr->data[dst],
+               VB->BackfaceSecondaryColorPtr->data[src] );
    }
 
-   if (VB->IndexPtr[1]) {
-      VB->IndexPtr[1]->data[dst][0] = VB->IndexPtr[1]->data[src][0];
+   if (VB->BackfaceIndexPtr) {
+      VB->BackfaceIndexPtr->data[dst][0] = VB->BackfaceIndexPtr->data[src][0];
    }
 
    _tnl_generic_copy_pv(ctx, dst, src);
index e4b535fb680aecb576f52bec6567698e11ee3ede..2424204b886f4f8e08f9fa4c8dfc4daa319967ff 100644 (file)
@@ -241,6 +241,7 @@ static void TAG(render_line_loop_verts)( GLcontext *ctx,
               tmp = ALLOC_VERTS(nr+1);
               tmp = TAG(emit_verts)( ctx, j, nr, tmp );
               tmp = TAG(emit_verts)( ctx, start, 1, tmp );
+              (void) tmp;
            }
            else {
               TAG(emit_verts)( ctx, j, nr, ALLOC_VERTS(nr) );
@@ -254,6 +255,7 @@ static void TAG(render_line_loop_verts)( GLcontext *ctx,
         tmp = ALLOC_VERTS(2);
         tmp = TAG(emit_verts)( ctx, start+1, 1, tmp );
         tmp = TAG(emit_verts)( ctx, start, 1, tmp );
+        (void) tmp;
       }
 
       FLUSH();
@@ -358,6 +360,7 @@ static void TAG(render_tri_fan_verts)( GLcontext *ctx,
         tmp = ALLOC_VERTS( nr );
         tmp = TAG(emit_verts)( ctx, start, 1, tmp );
         tmp = TAG(emit_verts)( ctx, j, nr - 1, tmp );
+        (void) tmp;
         currentsz = dmasz;
       }
 
@@ -397,6 +400,7 @@ static void TAG(render_poly_verts)( GLcontext *ctx,
         tmp = ALLOC_VERTS( nr );
         tmp = TAG(emit_verts)( ctx, start, 1, tmp );
         tmp = TAG(emit_verts)( ctx, j, nr - 1, tmp );
+        (void) tmp;
         currentsz = dmasz;
       }
 
@@ -443,7 +447,7 @@ static void TAG(render_quad_strip_verts)( GLcontext *ctx,
 
    } else if (HAVE_TRI_STRIPS && 
              ctx->Light.ShadeModel == GL_FLAT &&
-             TNL_CONTEXT(ctx)->vb.ColorPtr[0]->stride) {
+             TNL_CONTEXT(ctx)->vb.AttribPtr[_TNL_ATTRIB_COLOR0]->stride) {
       if (HAVE_ELTS) {
         LOCAL_VARS;
         int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
@@ -634,6 +638,7 @@ static void TAG(render_quads_verts)( GLcontext *ctx,
         /* Send v1, v2, v3
          */
         tmp = EMIT_VERTS(ctx, j + 1, 3, tmp);
+        (void) tmp;
       }
    }
    else {
@@ -820,6 +825,7 @@ static void TAG(render_line_loop_elts)( GLcontext *ctx,
               tmp = ALLOC_ELTS(nr+1);
               tmp = TAG(emit_elts)( ctx, elts+j, nr, tmp );
               tmp = TAG(emit_elts)( ctx, elts+start, 1, tmp );
+              (void) tmp;
            }
            else {
               TAG(emit_elts)( ctx, elts+j, nr, ALLOC_ELTS(nr) );
@@ -833,6 +839,7 @@ static void TAG(render_line_loop_elts)( GLcontext *ctx,
         tmp = ALLOC_ELTS(2);
         tmp = TAG(emit_elts)( ctx, elts+start+1, 1, tmp );
         tmp = TAG(emit_elts)( ctx, elts+start, 1, tmp );
+        (void) tmp;
       }
 
       FLUSH();
@@ -946,6 +953,7 @@ static void TAG(render_tri_fan_elts)( GLcontext *ctx,
         tmp = ALLOC_ELTS( nr );
         tmp = TAG(emit_elts)( ctx, elts+start, 1, tmp );
         tmp = TAG(emit_elts)( ctx, elts+j, nr - 1, tmp );
+        (void) tmp;
         FLUSH();
         currentsz = dmasz;
       }
@@ -983,6 +991,7 @@ static void TAG(render_poly_elts)( GLcontext *ctx,
         tmp = ALLOC_ELTS( nr );
         tmp = TAG(emit_elts)( ctx, elts+start, 1, tmp );
         tmp = TAG(emit_elts)( ctx, elts+j, nr - 1, tmp );
+        (void) tmp;
         FLUSH();
         currentsz = dmasz;
       }
@@ -1221,7 +1230,7 @@ static GLboolean TAG(validate_render)( GLcontext *ctx,
            ok = GL_TRUE;
         } else if (HAVE_TRI_STRIPS && 
                    ctx->Light.ShadeModel == GL_FLAT &&
-                   VB->ColorPtr[0]->stride != 0) {
+                   VB->AttribPtr[_TNL_ATTRIB_COLOR0]->stride != 0) {
            if (HAVE_ELTS) {
               ok = (GLint) count < GET_SUBSEQUENT_VB_MAX_ELTS();
            }
index 2380c49fdf47464a7ed400a2f170e519ebd8335a..cd225b6343eff8f240f31211385c0ef36e20a9db 100644 (file)
@@ -266,6 +266,7 @@ static void TAG(render_line_loop_verts)( GLcontext *ctx,
            if (j + nr < count) {
               ELT_TYPE *dest = ALLOC_ELTS( nr );
               dest = TAG(emit_consecutive_elts)( ctx, dest, j, nr );
+              (void) dest;
               j += nr - 1;
               CLOSE_ELTS();
            }
@@ -273,6 +274,7 @@ static void TAG(render_line_loop_verts)( GLcontext *ctx,
               ELT_TYPE *dest = ALLOC_ELTS( nr + 1 );
               dest = TAG(emit_consecutive_elts)( ctx, dest, j, nr );
               dest = TAG(emit_consecutive_elts)( ctx, dest, start, 1 );
+              (void) dest;
               j += nr;
               CLOSE_ELTS();
            }
@@ -554,6 +556,7 @@ static void TAG(render_points_elts)( GLcontext *ctx,
       nr = MIN2( dmasz, count - j );
       dest = ALLOC_ELTS( nr );
       dest = TAG(emit_elts)( ctx, dest, elts+j, nr );
+      (void) dest;
       CLOSE_ELTS();
    }
 }
@@ -590,6 +593,7 @@ static void TAG(render_lines_elts)( GLcontext *ctx,
       nr = MIN2( dmasz, count - j );
       dest = ALLOC_ELTS( nr );
       dest = TAG(emit_elts)( ctx, dest, elts+j, nr );
+      (void) dest;
       CLOSE_ELTS();
    }
 
@@ -621,6 +625,7 @@ static void TAG(render_line_strip_elts)( GLcontext *ctx,
       nr = MIN2( dmasz, count - j );
       dest = ALLOC_ELTS( nr );
       dest = TAG(emit_elts)( ctx, dest, elts+j, nr );
+      (void) dest;
       CLOSE_ELTS();
    }
 }
@@ -671,6 +676,7 @@ static void TAG(render_line_loop_elts)( GLcontext *ctx,
       j += nr - 1;
       if (j + 1 >= count && (flags & PRIM_END)) {
         dest = TAG(emit_elts)( ctx, dest, elts+start, 1 );
+        (void) dest;
       }
       CLOSE_ELTS();
    }
@@ -703,6 +709,7 @@ static void TAG(render_triangles_elts)( GLcontext *ctx,
       nr = MIN2( dmasz, count - j );
       dest = ALLOC_ELTS( nr );
       dest = TAG(emit_elts)( ctx, dest, elts+j, nr );
+      (void) dest;
       CLOSE_ELTS();
    }
 }
@@ -734,6 +741,7 @@ static void TAG(render_tri_strip_elts)( GLcontext *ctx,
 
       dest = ALLOC_ELTS( nr );
       dest = TAG(emit_elts)( ctx, dest, elts+j, nr );
+      (void) dest;
       CLOSE_ELTS();
    }
 }
@@ -759,6 +767,7 @@ static void TAG(render_tri_fan_elts)( GLcontext *ctx,
       dest = ALLOC_ELTS( nr );
       dest = TAG(emit_elts)( ctx, dest, elts+start, 1 );
       dest = TAG(emit_elts)( ctx, dest, elts+j, nr - 1 );
+      (void) dest;
       CLOSE_ELTS();
    }
 }
@@ -785,6 +794,7 @@ static void TAG(render_poly_elts)( GLcontext *ctx,
       dest = ALLOC_ELTS( nr );
       dest = TAG(emit_elts)( ctx, dest, elts+start, 1 );
       dest = TAG(emit_elts)( ctx, dest, elts+j, nr - 1 );
+      (void) dest;
       CLOSE_ELTS();
    }
 }
@@ -843,6 +853,7 @@ static void TAG(render_quad_strip_elts)( GLcontext *ctx,
            nr = MIN2( dmasz, count - j );
            dest = ALLOC_ELTS( nr );
            dest = TAG(emit_elts)( ctx, dest, elts+j, nr );
+           (void) dest;
            CLOSE_ELTS();
         }
       }
index 1ae70f4059f221c252b991e3b1dd0aa2502b8ec5..6acd837317f5dd870d2e9d613c54275f6ee0c635 100644 (file)
@@ -132,7 +132,7 @@ static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
    struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb;
    VERTEX *v[3];
    GLfloat offset = 0;
-   GLfloat z[3];
+   GLfloat z[3] = { 0 };
    GLenum mode = GL_FILL;
    GLuint facing = 0;
    LOCAL_VARS(3);
@@ -195,7 +195,7 @@ static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
                  }
               }
               else {
-                 GLfloat (*vbcolor)[4] = VB->ColorPtr[1]->data;
+                 GLfloat (*vbcolor)[4] = VB->BackfaceColorPtr->data;
                  (void) vbcolor;
 
                  if (!DO_FLAT) {
@@ -204,8 +204,8 @@ static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
                  }
                  VERT_SAVE_RGBA( 2 );
 
-                 if (VB->ColorPtr[1]->stride) {
-                    ASSERT(VB->ColorPtr[1]->stride == 4*sizeof(GLfloat));
+                 if (VB->BackfaceColorPtr->stride) {
+                    ASSERT(VB->BackfaceColorPtr->stride == 4*sizeof(GLfloat));
 
                     if (!DO_FLAT) {              
                        VERT_SET_RGBA( v[0], vbcolor[e0] );
@@ -221,9 +221,9 @@ static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
                     VERT_SET_RGBA( v[2], vbcolor[0] );
                  }
 
-                 if (HAVE_SPEC && VB->SecondaryColorPtr[1]) {
-                    GLfloat (*vbspec)[4] = VB->SecondaryColorPtr[1]->data;
-                    ASSERT(VB->SecondaryColorPtr[1]->stride == 4*sizeof(GLfloat));
+                 if (HAVE_SPEC && VB->BackfaceSecondaryColorPtr) {
+                    GLfloat (*vbspec)[4] = VB->BackfaceSecondaryColorPtr->data;
+                    ASSERT(VB->BackfaceSecondaryColorPtr->stride == 4*sizeof(GLfloat));
 
                     if (!DO_FLAT) {
                        VERT_SAVE_SPEC( 0 );
@@ -237,7 +237,7 @@ static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
               }
            }
            else {
-              GLfloat (*vbindex) = (GLfloat *)VB->IndexPtr[1]->data;
+              GLfloat (*vbindex) = (GLfloat *)VB->BackfaceIndexPtr->data;
               if (!DO_FLAT) {
                  VERT_SAVE_IND( 0 );
                  VERT_SAVE_IND( 1 );
@@ -279,7 +279,7 @@ static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
         VERT_SAVE_RGBA( 1 );
         VERT_COPY_RGBA( v[0], v[2] );
         VERT_COPY_RGBA( v[1], v[2] );
-        if (HAVE_SPEC && VB->SecondaryColorPtr[0]) {
+        if (HAVE_SPEC && VB->AttribPtr[_TNL_ATTRIB_COLOR1]) {
            VERT_SAVE_SPEC( 0 );
            VERT_SAVE_SPEC( 1 );
            VERT_COPY_SPEC( v[0], v[2] );
@@ -374,7 +374,7 @@ static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
       if (HAVE_RGBA) {
         VERT_RESTORE_RGBA( 0 );
         VERT_RESTORE_RGBA( 1 );
-        if (HAVE_SPEC && VB->SecondaryColorPtr[0]) {
+        if (HAVE_SPEC && VB->AttribPtr[_TNL_ATTRIB_COLOR1]) {
            VERT_RESTORE_SPEC( 0 );
            VERT_RESTORE_SPEC( 1 );
         }
@@ -395,7 +395,7 @@ static void TAG(quadr)( GLcontext *ctx,
    struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb;
    VERTEX *v[4];
    GLfloat offset = 0;
-   GLfloat z[4];
+   GLfloat z[4] = { 0 };
    GLenum mode = GL_FILL;
    GLuint facing = 0;
    LOCAL_VARS(4);
@@ -436,7 +436,7 @@ static void TAG(quadr)( GLcontext *ctx,
         if (DO_TWOSIDE && facing == 1)
         {
            if (HAVE_RGBA) {
-              GLfloat (*vbcolor)[4] = VB->ColorPtr[1]->data;
+              GLfloat (*vbcolor)[4] = VB->BackfaceColorPtr->data;
               (void)vbcolor;
 
               if (HAVE_BACK_COLORS) {
@@ -471,7 +471,7 @@ static void TAG(quadr)( GLcontext *ctx,
                  }
                  VERT_SAVE_RGBA( 3 );
 
-                 if (VB->ColorPtr[1]->stride) {
+                 if (VB->BackfaceColorPtr->stride) {
                     if (!DO_FLAT) {
                        VERT_SET_RGBA( v[0], vbcolor[e0] );
                        VERT_SET_RGBA( v[1], vbcolor[e1] );
@@ -488,9 +488,9 @@ static void TAG(quadr)( GLcontext *ctx,
                     VERT_SET_RGBA( v[3], vbcolor[0] );
                  }
 
-                 if (HAVE_SPEC && VB->SecondaryColorPtr[1]) {
-                    GLfloat (*vbspec)[4] = VB->SecondaryColorPtr[1]->data;
-                    ASSERT(VB->SecondaryColorPtr[1]->stride==4*sizeof(GLfloat));
+                 if (HAVE_SPEC && VB->BackfaceSecondaryColorPtr) {
+                    GLfloat (*vbspec)[4] = VB->BackfaceSecondaryColorPtr->data;
+                    ASSERT(VB->BackfaceSecondaryColorPtr->stride==4*sizeof(GLfloat));
 
                     if (!DO_FLAT) {
                        VERT_SAVE_SPEC( 0 );
@@ -506,7 +506,7 @@ static void TAG(quadr)( GLcontext *ctx,
               }
            }
            else {
-              GLfloat *vbindex = (GLfloat *)VB->IndexPtr[1]->data;
+              GLfloat *vbindex = (GLfloat *)VB->BackfaceIndexPtr->data;
               if (!DO_FLAT) {
                  VERT_SAVE_IND( 0 );
                  VERT_SAVE_IND( 1 );
@@ -553,7 +553,7 @@ static void TAG(quadr)( GLcontext *ctx,
         VERT_COPY_RGBA( v[0], v[3] );
         VERT_COPY_RGBA( v[1], v[3] );
         VERT_COPY_RGBA( v[2], v[3] );
-        if (HAVE_SPEC && VB->SecondaryColorPtr[0]) {
+        if (HAVE_SPEC && VB->AttribPtr[_TNL_ATTRIB_COLOR1]) {
            VERT_SAVE_SPEC( 0 );
            VERT_SAVE_SPEC( 1 );
            VERT_SAVE_SPEC( 2 );
@@ -659,7 +659,7 @@ static void TAG(quadr)( GLcontext *ctx,
         VERT_RESTORE_RGBA( 0 );
         VERT_RESTORE_RGBA( 1 );
         VERT_RESTORE_RGBA( 2 );
-        if (HAVE_SPEC && VB->SecondaryColorPtr[0]) {
+        if (HAVE_SPEC && VB->AttribPtr[_TNL_ATTRIB_COLOR1]) {
            VERT_RESTORE_SPEC( 0 );
            VERT_RESTORE_SPEC( 1 );
            VERT_RESTORE_SPEC( 2 );
@@ -708,7 +708,7 @@ static void TAG(line)( GLcontext *ctx, GLuint e0, GLuint e1 )
       if (HAVE_RGBA) {
         VERT_SAVE_RGBA( 0 );
         VERT_COPY_RGBA( v[0], v[1] );
-        if (HAVE_SPEC && VB->SecondaryColorPtr[0]) {
+        if (HAVE_SPEC && VB->AttribPtr[_TNL_ATTRIB_COLOR1]) {
            VERT_SAVE_SPEC( 0 );
            VERT_COPY_SPEC( v[0], v[1] );
         }
@@ -725,7 +725,7 @@ static void TAG(line)( GLcontext *ctx, GLuint e0, GLuint e1 )
       if (HAVE_RGBA) {
         VERT_RESTORE_RGBA( 0 );
 
-        if (HAVE_SPEC && VB->SecondaryColorPtr[0]) {
+        if (HAVE_SPEC && VB->AttribPtr[_TNL_ATTRIB_COLOR1]) {
            VERT_RESTORE_SPEC( 0 );
         }
       }
index b3937c29a000596a0fcd960c2a4caad5bf704b6d..a8a0a69768d3b7a304002ac6b650704c0420b919 100644 (file)
@@ -297,19 +297,19 @@ INTERP_QUALIFIER void TAG(interp_extras)( GLcontext *ctx,
    LOCALVARS
    struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
 
-   if (VB->ColorPtr[1]) {
-      assert(VB->ColorPtr[1]->stride == 4 * sizeof(GLfloat));
+   if (VB->BackfaceColorPtr) {
+      assert(VB->BackfaceColorPtr->stride == 4 * sizeof(GLfloat));
 
       INTERP_4F( t,
-                   GET_COLOR(VB->ColorPtr[1], dst),
-                   GET_COLOR(VB->ColorPtr[1], out),
-                   GET_COLOR(VB->ColorPtr[1], in) );
+                   GET_COLOR(VB->BackfaceColorPtr, dst),
+                   GET_COLOR(VB->BackfaceColorPtr, out),
+                   GET_COLOR(VB->BackfaceColorPtr, in) );
 
-      if (VB->SecondaryColorPtr[1]) {
+      if (VB->BackfaceSecondaryColorPtr) {
         INTERP_3F( t,
-                      GET_COLOR(VB->SecondaryColorPtr[1], dst),
-                      GET_COLOR(VB->SecondaryColorPtr[1], out),
-                      GET_COLOR(VB->SecondaryColorPtr[1], in) );
+                      GET_COLOR(VB->BackfaceSecondaryColorPtr, dst),
+                      GET_COLOR(VB->BackfaceSecondaryColorPtr, out),
+                      GET_COLOR(VB->BackfaceSecondaryColorPtr, in) );
       }
    }
 
@@ -326,13 +326,13 @@ INTERP_QUALIFIER void TAG(copy_pv_extras)( GLcontext *ctx,
    LOCALVARS
       struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
 
-   if (VB->ColorPtr[1]) {
-      COPY_4FV( GET_COLOR(VB->ColorPtr[1], dst), 
-               GET_COLOR(VB->ColorPtr[1], src) );
+   if (VB->BackfaceColorPtr) {
+      COPY_4FV( GET_COLOR(VB->BackfaceColorPtr, dst),
+               GET_COLOR(VB->BackfaceColorPtr, src) );
 
-      if (VB->SecondaryColorPtr[1]) {
-        COPY_4FV( GET_COLOR(VB->SecondaryColorPtr[1], dst), 
-                  GET_COLOR(VB->SecondaryColorPtr[1], src) );
+      if (VB->BackfaceSecondaryColorPtr) {
+        COPY_4FV( GET_COLOR(VB->BackfaceSecondaryColorPtr, dst),
+                  GET_COLOR(VB->BackfaceSecondaryColorPtr, src) );
       }
    }
 
index 92dd8931c33b710e3e0e9e58222fd5560a4bc0b9..85101b9ceb8eca6f1e7041d8b8d7898c9ec68144 100644 (file)
@@ -153,46 +153,46 @@ static void TAG(emit)( GLcontext *ctx,
 
    if (DO_TEX3) {
       const GLuint t3 = GET_TEXSOURCE(3);
-      tc3 = VB->TexCoordPtr[t3]->data;
-      tc3_stride = VB->TexCoordPtr[t3]->stride;
+      tc3 = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t3]->data;
+      tc3_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t3]->stride;
       if (DO_PTEX)
-        tc3_size = VB->TexCoordPtr[t3]->size;
+        tc3_size = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t3]->size;
    }
 
    if (DO_TEX2) {
       const GLuint t2 = GET_TEXSOURCE(2);
-      tc2 = VB->TexCoordPtr[t2]->data;
-      tc2_stride = VB->TexCoordPtr[t2]->stride;
+      tc2 = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t2]->data;
+      tc2_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t2]->stride;
       if (DO_PTEX)
-        tc2_size = VB->TexCoordPtr[t2]->size;
+        tc2_size = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t2]->size;
    }
 
    if (DO_TEX1) {
       const GLuint t1 = GET_TEXSOURCE(1);
-      tc1 = VB->TexCoordPtr[t1]->data;
-      tc1_stride = VB->TexCoordPtr[t1]->stride;
+      tc1 = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t1]->data;
+      tc1_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t1]->stride;
       if (DO_PTEX)
-        tc1_size = VB->TexCoordPtr[t1]->size;
+        tc1_size = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t1]->size;
    }
 
    if (DO_TEX0) {
       const GLuint t0 = GET_TEXSOURCE(0);
-      tc0_stride = VB->TexCoordPtr[t0]->stride;
-      tc0 = VB->TexCoordPtr[t0]->data;
+      tc0_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t0]->stride;
+      tc0 = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t0]->data;
       if (DO_PTEX) 
-        tc0_size = VB->TexCoordPtr[t0]->size;
+        tc0_size = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t0]->size;
    }
 
    if (DO_RGBA) {
-      col_stride = VB->ColorPtr[0]->stride;
-      col = VB->ColorPtr[0]->data;
-      col_size = VB->ColorPtr[0]->size;
+      col_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->stride;
+      col = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->data;
+      col_size = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->size;
    }
 
    if (DO_SPEC) {
-      if (VB->SecondaryColorPtr[0]) {
-        spec_stride = VB->SecondaryColorPtr[0]->stride;
-        spec = VB->SecondaryColorPtr[0]->data;
+      if (VB->AttribPtr[_TNL_ATTRIB_COLOR1]) {
+        spec_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR1]->stride;
+        spec = VB->AttribPtr[_TNL_ATTRIB_COLOR1]->data;
       } else {
         spec = (GLfloat (*)[4])ctx->Current.Attrib[VERT_ATTRIB_COLOR1];
         spec_stride = 0;
@@ -200,9 +200,9 @@ static void TAG(emit)( GLcontext *ctx,
    }
 
    if (DO_FOG) {
-      if (VB->FogCoordPtr) {
-        fog = VB->FogCoordPtr->data;
-        fog_stride = VB->FogCoordPtr->stride;
+      if (VB->AttribPtr[_TNL_ATTRIB_FOG]) {
+        fog = VB->AttribPtr[_TNL_ATTRIB_FOG]->data;
+        fog_stride = VB->AttribPtr[_TNL_ATTRIB_FOG]->stride;
       }
       else {
         static GLfloat tmp[4] = {0, 0, 0, 0};
@@ -356,9 +356,9 @@ static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end,
 
    ASSERT(stride == 4);
 
-   col = VB->ColorPtr[0]->data;
-   col_stride = VB->ColorPtr[0]->stride;
-   col_size = VB->ColorPtr[0]->size;
+   col = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->data;
+   col_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->stride;
+   col_size = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->size;
 
 /*     fprintf(stderr, "%s(small) importable %x\n",  */
 /*        __FUNCTION__, VB->importable_data); */
@@ -410,22 +410,22 @@ static GLboolean TAG(check_tex_sizes)( GLcontext *ctx )
 
    /* Force 'missing' texcoords to something valid.
     */
-   if (DO_TEX3 && VB->TexCoordPtr[2] == 0)
-      VB->TexCoordPtr[2] = VB->TexCoordPtr[3];
+   if (DO_TEX3 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + 2] == 0)
+      VB->AttribPtr[_TNL_ATTRIB_TEX0 + 2] = VB->AttribPtr[_TNL_ATTRIB_TEX0 + 3];
 
-   if (DO_TEX2 && VB->TexCoordPtr[1] == 0)
-      VB->TexCoordPtr[1] = VB->TexCoordPtr[2];
+   if (DO_TEX2 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + 1] == 0)
+      VB->AttribPtr[_TNL_ATTRIB_TEX0 + 1] = VB->AttribPtr[_TNL_ATTRIB_TEX0 + 2];
 
-   if (DO_TEX1 && VB->TexCoordPtr[0] == 0)
-      VB->TexCoordPtr[0] = VB->TexCoordPtr[1];
+   if (DO_TEX1 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + 0] == 0)
+      VB->AttribPtr[_TNL_ATTRIB_TEX0 + 0] = VB->AttribPtr[_TNL_ATTRIB_TEX0 + 1];
 
    if (DO_PTEX)
       return GL_TRUE;
    
-   if ((DO_TEX3 && VB->TexCoordPtr[GET_TEXSOURCE(3)]->size == 4) ||
-       (DO_TEX2 && VB->TexCoordPtr[GET_TEXSOURCE(2)]->size == 4) ||
-       (DO_TEX1 && VB->TexCoordPtr[GET_TEXSOURCE(1)]->size == 4) ||
-       (DO_TEX0 && VB->TexCoordPtr[GET_TEXSOURCE(0)]->size == 4))
+   if ((DO_TEX3 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + GET_TEXSOURCE(3)]->size == 4) ||
+       (DO_TEX2 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + GET_TEXSOURCE(2)]->size == 4) ||
+       (DO_TEX1 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + GET_TEXSOURCE(1)]->size == 4) ||
+       (DO_TEX0 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + GET_TEXSOURCE(0)]->size == 4))
       return GL_FALSE;
 
    return GL_TRUE;
@@ -438,14 +438,14 @@ static GLboolean TAG(check_tex_sizes)( GLcontext *ctx )
 
    /* Force 'missing' texcoords to something valid.
     */
-   if (DO_TEX3 && VB->TexCoordPtr[2] == 0)
-      VB->TexCoordPtr[2] = VB->TexCoordPtr[3];
+   if (DO_TEX3 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + 2] == 0)
+      VB->AttribPtr[_TNL_ATTRIB_TEX0 + 2] = VB->AttribPtr[_TNL_ATTRIB_TEX0 + 3];
 
-   if (DO_TEX2 && VB->TexCoordPtr[1] == 0)
-      VB->TexCoordPtr[1] = VB->TexCoordPtr[2];
+   if (DO_TEX2 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + 1] == 0)
+      VB->AttribPtr[_TNL_ATTRIB_TEX0 + 1] = VB->AttribPtr[_TNL_ATTRIB_TEX0 + 2];
 
-   if (DO_TEX1 && VB->TexCoordPtr[0] == 0)
-      VB->TexCoordPtr[0] = VB->TexCoordPtr[1];
+   if (DO_TEX1 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + 0] == 0)
+      VB->AttribPtr[_TNL_ATTRIB_TEX0 + 0] = VB->AttribPtr[_TNL_ATTRIB_TEX0 + 1];
 
    if (DO_PTEX)
       return GL_TRUE;
@@ -453,14 +453,14 @@ static GLboolean TAG(check_tex_sizes)( GLcontext *ctx )
    /* No hardware support for projective texture.  Can fake it for
     * TEX0 only.
     */
-   if ((DO_TEX3 && VB->TexCoordPtr[GET_TEXSOURCE(3)]->size == 4) ||
-       (DO_TEX2 && VB->TexCoordPtr[GET_TEXSOURCE(2)]->size == 4) ||
-       (DO_TEX1 && VB->TexCoordPtr[GET_TEXSOURCE(1)]->size == 4)) {
+   if ((DO_TEX3 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + GET_TEXSOURCE(3)]->size == 4) ||
+       (DO_TEX2 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + GET_TEXSOURCE(2)]->size == 4) ||
+       (DO_TEX1 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + GET_TEXSOURCE(1)]->size == 4)) {
       PTEX_FALLBACK();
       return GL_FALSE;
    }
 
-   if (DO_TEX0 && VB->TexCoordPtr[GET_TEXSOURCE(0)]->size == 4) {
+   if (DO_TEX0 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + GET_TEXSOURCE(0)]->size == 4) {
       if (DO_TEX1 || DO_TEX2 || DO_TEX3) {
         PTEX_FALLBACK();
       }
index 516be0995b26411c5ec7f22c5638aa61bf503f5d..98c1f363d98a64ee3fda83d79c97b06d487177ae 100644 (file)
@@ -103,7 +103,7 @@ struct vbo_exec_context
       GLubyte active_sz[VBO_ATTRIB_MAX];
 
       GLfloat *attrptr[VBO_ATTRIB_MAX]; 
-      struct gl_client_array arrays[VBO_ATTRIB_MAX];
+      struct gl_client_array arrays[VERT_ATTRIB_MAX];
 
       /* According to program mode, the values above plus current
        * values are squashed down to the 32 attributes passed to the
@@ -138,6 +138,10 @@ struct vbo_exec_context
        */
       const struct gl_client_array *inputs[VERT_ATTRIB_MAX];
    } array;
+
+#ifdef DEBUG
+   GLint flush_call_depth;
+#endif
 };
 
 
index bfa6d76886a36ad5c207895d51638e133befe5e8..f0a7eeadd0f8194a05d34929c0833ff52a066b63 100644 (file)
@@ -57,7 +57,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 static void reset_attrfv( struct vbo_exec_context *exec );
 
 
-/* Close off the last primitive, execute the buffer, restart the
+/**
+ * Close off the last primitive, execute the buffer, restart the
  * primitive.  
  */
 static void vbo_exec_wrap_buffers( struct vbo_exec_context *exec )
@@ -106,7 +107,8 @@ static void vbo_exec_wrap_buffers( struct vbo_exec_context *exec )
 }
 
 
-/* Deal with buffer wrapping where provoked by the vertex buffer
+/**
+ * Deal with buffer wrapping where provoked by the vertex buffer
  * filling up, as opposed to upgrade_vertex().
  */
 void vbo_exec_vtx_wrap( struct vbo_exec_context *exec )
@@ -135,7 +137,7 @@ void vbo_exec_vtx_wrap( struct vbo_exec_context *exec )
 }
 
 
-/*
+/**
  * Copy the active vertex's values to the ctx->Current fields.
  */
 static void vbo_exec_copy_to_current( struct vbo_exec_context *exec )
@@ -208,7 +210,8 @@ static void vbo_exec_copy_from_current( struct vbo_exec_context *exec )
 }
 
 
-/* Flush existing data, set new attrib size, replay copied vertices.
+/**
+ * Flush existing data, set new attrib size, replay copied vertices.
  */ 
 static void vbo_exec_wrap_upgrade_vertex( struct vbo_exec_context *exec,
                                          GLuint attr,
@@ -392,8 +395,7 @@ do {                                                                \
 
 
 #if FEATURE_evaluators
-/* Eval
- */
+
 static void GLAPIENTRY vbo_exec_EvalCoord1f( GLfloat u )
 {
    GET_CURRENT_CONTEXT( ctx );
@@ -492,8 +494,8 @@ static void GLAPIENTRY vbo_exec_EvalPoint2( GLint i, GLint j )
 #endif /* FEATURE_evaluators */
 
 
-/* Build a list of primitives on the fly.  Keep
- * ctx->Driver.CurrentExecPrimitive uptodate as well.
+/**
+ * Called via glBegin.
  */
 static void GLAPIENTRY vbo_exec_Begin( GLenum mode )
 {
@@ -537,6 +539,10 @@ static void GLAPIENTRY vbo_exec_Begin( GLenum mode )
       
 }
 
+
+/**
+ * Called via glEnd.
+ */
 static void GLAPIENTRY vbo_exec_End( void )
 {
    GET_CURRENT_CONTEXT( ctx ); 
@@ -784,8 +790,14 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec )
    _mesa_install_exec_vtxfmt( exec->ctx, &exec->vtxfmt );
 
    for (i = 0 ; i < VBO_ATTRIB_MAX ; i++) {
+      ASSERT(i < Elements(exec->vtx.attrsz));
       exec->vtx.attrsz[i] = 0;
+      ASSERT(i < Elements(exec->vtx.active_sz));
       exec->vtx.active_sz[i] = 0;
+   }
+   for (i = 0 ; i < VERT_ATTRIB_MAX; i++) {
+      ASSERT(i < Elements(exec->vtx.inputs));
+      ASSERT(i < Elements(exec->vtx.arrays));
       exec->vtx.inputs[i] = &exec->vtx.arrays[i];
    }
    
@@ -855,15 +867,27 @@ void vbo_exec_FlushVertices_internal( GLcontext *ctx, GLboolean unmap )
 }
 
 
-
+/**
+ * \param flags  bitmask of FLUSH_STORED_VERTICES, FLUSH_UPDATE_CURRENT
+ */
 void vbo_exec_FlushVertices( GLcontext *ctx, GLuint flags )
 {
    struct vbo_exec_context *exec = &vbo_context(ctx)->exec;
 
+#ifdef DEBUG
+   /* debug check: make sure we don't get called recursively */
+   exec->flush_call_depth++;
+   assert(exec->flush_call_depth == 1);
+#endif
+
    if (0) _mesa_printf("%s\n", __FUNCTION__);
 
    if (exec->ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) {
       if (0) _mesa_printf("%s - inside begin/end\n", __FUNCTION__);
+#ifdef DEBUG
+      exec->flush_call_depth--;
+      assert(exec->flush_call_depth == 0);
+#endif
       return;
    }
 
@@ -877,6 +901,11 @@ void vbo_exec_FlushVertices( GLcontext *ctx, GLuint flags )
    }
 
    exec->ctx->Driver.NeedFlush &= ~flags;
+
+#ifdef DEBUG
+   exec->flush_call_depth--;
+   assert(exec->flush_call_depth == 0);
+#endif
 }
 
 
index 774cffc451b861514c9c1c60170ff59a53f2120b..6de8f059b79bef03c723c6a0ec74121c0ecd412c 100644 (file)
@@ -33,6 +33,7 @@
 #include "main/api_noop.h"
 #include "main/varray.h"
 #include "main/bufferobj.h"
+#include "main/enums.h"
 #include "main/macros.h"
 #include "glapi/dispatch.h"
 
@@ -53,10 +54,9 @@ vbo_get_minmax_index(GLcontext *ctx,
    const void *indices;
 
    if (_mesa_is_bufferobj(ib->obj)) {
-      const GLvoid *map = ctx->Driver.MapBuffer(ctx,
-                                                GL_ELEMENT_ARRAY_BUFFER_ARB,
-                                                GL_READ_ONLY,
-                                                ib->obj);
+      const GLvoid *map =
+         ctx->Driver.MapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER_ARB,
+                               GL_READ_ONLY, ib->obj);
       indices = ADD_POINTERS(map, ib->ptr);
    } else {
       indices = ib->ptr;
@@ -105,9 +105,7 @@ vbo_get_minmax_index(GLcontext *ctx,
    }
 
    if (_mesa_is_bufferobj(ib->obj)) {
-      ctx->Driver.UnmapBuffer(ctx,
-                             GL_ELEMENT_ARRAY_BUFFER_ARB,
-                             ib->obj);
+      ctx->Driver.UnmapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, ib->obj);
    }
 }
 
@@ -125,10 +123,9 @@ check_array_data(GLcontext *ctx, struct gl_client_array *array,
       if (_mesa_is_bufferobj(array->BufferObj)) {
          if (!array->BufferObj->Pointer) {
             /* need to map now */
-            array->BufferObj->Pointer = ctx->Driver.MapBuffer(ctx,
-                                                              GL_ARRAY_BUFFER_ARB,
-                                                              GL_READ_ONLY,
-                                                              array->BufferObj);
+            array->BufferObj->Pointer =
+               ctx->Driver.MapBuffer(ctx, GL_ARRAY_BUFFER_ARB,
+                                     GL_READ_ONLY, array->BufferObj);
          }
          data = ADD_POINTERS(data, array->BufferObj->Pointer);
       }
@@ -149,7 +146,7 @@ check_array_data(GLcontext *ctx, struct gl_client_array *array,
                                array->Ptr, array->BufferObj->Name);
                   f[k] = 1.0; /* XXX replace the bad value! */
                }
-               //assert(!IS_INF_OR_NAN(f[k]));
+               /*assert(!IS_INF_OR_NAN(f[k]));*/
             }
          }
          break;
@@ -169,9 +166,7 @@ unmap_array_buffer(GLcontext *ctx, struct gl_client_array *array)
    if (array->Enabled &&
        _mesa_is_bufferobj(array->BufferObj) &&
        _mesa_bufferobj_mapped(array->BufferObj)) {
-      ctx->Driver.UnmapBuffer(ctx,
-                              GL_ARRAY_BUFFER_ARB,
-                              array->BufferObj);
+      ctx->Driver.UnmapBuffer(ctx, GL_ARRAY_BUFFER_ARB, array->BufferObj);
    }
 }
 
@@ -222,13 +217,13 @@ check_draw_elements_data(GLcontext *ctx, GLsizei count, GLenum elemType,
          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);
+         check_array_data(ctx, &arrayObj->VertexAttrib[k],
+                          VERT_ATTRIB_GENERIC0 + k, j);
       }
    }
 
    if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) {
-      ctx->Driver.UnmapBuffer(ctx,
-                             GL_ELEMENT_ARRAY_BUFFER_ARB,
+      ctx->Driver.UnmapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER_ARB,
                              ctx->Array.ElementArrayBufferObj);
    }
 
@@ -459,7 +454,6 @@ bind_arrays(GLcontext *ctx)
    }
    else if (exec->array.program_mode != get_program_mode(ctx) ||
            exec->array.enabled_flags != ctx->Array.ArrayObj->_Enabled) {
-      
       recalculate_input_bindings(ctx);
    }
 #else
@@ -482,6 +476,10 @@ vbo_exec_DrawArrays(GLenum mode, GLint start, GLsizei count)
    struct vbo_exec_context *exec = &vbo->exec;
    struct _mesa_prim prim[1];
 
+   if (MESA_VERBOSE & VERBOSE_DRAW)
+      _mesa_debug(ctx, "glDrawArrays(%s, %d, %d)\n",
+                  _mesa_lookup_enum_by_nr(mode), start, count);
+
    if (!_mesa_validate_DrawArrays( ctx, mode, start, count ))
       return;
 
@@ -582,11 +580,11 @@ dump_element_buffer(GLcontext *ctx, GLenum type)
       ;
    }
 
-   ctx->Driver.UnmapBuffer(ctx,
-                           GL_ELEMENT_ARRAY_BUFFER_ARB,
+   ctx->Driver.UnmapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER_ARB,
                            ctx->Array.ElementArrayBufferObj);
 }
 
+
 /* Inner support for both _mesa_DrawElements and _mesa_DrawRangeElements */
 static void
 vbo_validated_drawrangeelements(GLcontext *ctx, GLenum mode,
@@ -675,6 +673,12 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode,
    static GLuint warnCount = 0;
    GET_CURRENT_CONTEXT(ctx);
 
+   if (MESA_VERBOSE & VERBOSE_DRAW)
+      _mesa_debug(ctx,
+                "glDrawRangeElementsBaseVertex(%s, %u, %u, %d, %s, %p, %d)\n",
+                _mesa_lookup_enum_by_nr(mode), start, end, count,
+                _mesa_lookup_enum_by_nr(type), indices, basevertex);
+
    if (!_mesa_validate_DrawRangeElements( ctx, mode, start, end, count,
                                           type, indices, basevertex ))
       return;
@@ -755,12 +759,19 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode,
                                   count, type, indices, basevertex);
 }
 
+
 static void GLAPIENTRY
-vbo_exec_DrawRangeElements(GLenum mode,
-                                    GLuint start, GLuint end,
-                                    GLsizei count, GLenum type,
-                                    const GLvoid *indices)
+vbo_exec_DrawRangeElements(GLenum mode, GLuint start, GLuint end,
+                           GLsizei count, GLenum type, const GLvoid *indices)
 {
+   GET_CURRENT_CONTEXT(ctx);
+
+   if (MESA_VERBOSE & VERBOSE_DRAW)
+      _mesa_debug(ctx,
+                  "glDrawRangeElements(%s, %u, %u, %d, %s, %p)\n",
+                  _mesa_lookup_enum_by_nr(mode), start, end, count,
+                  _mesa_lookup_enum_by_nr(type), indices);
+
    vbo_exec_DrawRangeElementsBaseVertex(mode, start, end, count, type,
                                        indices, 0);
 }
@@ -772,6 +783,11 @@ vbo_exec_DrawElements(GLenum mode, GLsizei count, GLenum type,
 {
    GET_CURRENT_CONTEXT(ctx);
 
+   if (MESA_VERBOSE & VERBOSE_DRAW)
+      _mesa_debug(ctx, "glDrawElements(%s, %u, %s, %p)\n",
+                  _mesa_lookup_enum_by_nr(mode), count,
+                  _mesa_lookup_enum_by_nr(type), indices);
+
    if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices, 0 ))
       return;
 
@@ -779,12 +795,18 @@ vbo_exec_DrawElements(GLenum mode, GLsizei count, GLenum type,
                                   count, type, indices, 0);
 }
 
+
 static void GLAPIENTRY
 vbo_exec_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type,
                                const GLvoid *indices, GLint basevertex)
 {
    GET_CURRENT_CONTEXT(ctx);
 
+   if (MESA_VERBOSE & VERBOSE_DRAW)
+      _mesa_debug(ctx, "glDrawElementsBaseVertex(%s, %d, %s, %p, %d)\n",
+                  _mesa_lookup_enum_by_nr(mode), count,
+                  _mesa_lookup_enum_by_nr(type), indices, basevertex);
+
    if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices,
                                     basevertex ))
       return;
@@ -793,7 +815,8 @@ vbo_exec_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type,
                                   count, type, indices, basevertex);
 }
 
-/* Inner support for both _mesa_DrawElements and _mesa_DrawRangeElements */
+
+/** Inner support for both _mesa_DrawElements and _mesa_DrawRangeElements */
 static void
 vbo_validated_multidrawelements(GLcontext *ctx, GLenum mode,
                                const GLsizei *count, GLenum type,
@@ -928,6 +951,7 @@ vbo_validated_multidrawelements(GLcontext *ctx, GLenum mode,
    _mesa_free(prim);
 }
 
+
 static void GLAPIENTRY
 vbo_exec_MultiDrawElements(GLenum mode,
                           const GLsizei *count, GLenum type,
@@ -949,6 +973,7 @@ vbo_exec_MultiDrawElements(GLenum mode,
                                   NULL);
 }
 
+
 static void GLAPIENTRY
 vbo_exec_MultiDrawElementsBaseVertex(GLenum mode,
                                     const GLsizei *count, GLenum type,
@@ -1038,6 +1063,7 @@ _mesa_DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count,
    vbo_exec_DrawRangeElements(mode, start, end, count, type, indices);
 }
 
+
 void GLAPIENTRY
 _mesa_DrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end,
                                  GLsizei count, GLenum type,
@@ -1047,6 +1073,7 @@ _mesa_DrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end,
                                        indices, basevertex);
 }
 
+
 /* GL_EXT_multi_draw_arrays */
 void GLAPIENTRY
 _mesa_MultiDrawElementsEXT(GLenum mode, const GLsizei *count, GLenum type,
@@ -1055,6 +1082,7 @@ _mesa_MultiDrawElementsEXT(GLenum mode, const GLsizei *count, GLenum type,
    vbo_exec_MultiDrawElements(mode, count, type, indices, primcount);
 }
 
+
 void GLAPIENTRY
 _mesa_MultiDrawElementsBaseVertex(GLenum mode,
                                  const GLsizei *count, GLenum type,
index ee148df4a12c93c5aa8676106be5559bca0750d4..4f43856016cd0438c28a3215da09498940fde853 100644 (file)
@@ -175,6 +175,7 @@ vbo_exec_bind_arrays( GLcontext *ctx )
          exec->vtx.inputs[attr] = &vbo->legacy_currval[attr];
       }
       for (attr = 0; attr < MAT_ATTRIB_MAX; attr++) {
+         ASSERT(attr + 16 < Elements(exec->vtx.inputs));
          exec->vtx.inputs[attr + 16] = &vbo->mat_currval[attr];
       }
       map = vbo->map_vp_none;
@@ -187,6 +188,7 @@ vbo_exec_bind_arrays( GLcontext *ctx )
        */
       for (attr = 0; attr < 16; attr++) {
          exec->vtx.inputs[attr] = &vbo->legacy_currval[attr];
+         ASSERT(attr + 16 < Elements(exec->vtx.inputs));
          exec->vtx.inputs[attr + 16] = &vbo->generic_currval[attr];
       }
       map = vbo->map_vp_arb;
@@ -215,6 +217,8 @@ vbo_exec_bind_arrays( GLcontext *ctx )
 
       if (exec->vtx.attrsz[src]) {
          /* override the default array set above */
+         ASSERT(attr < Elements(exec->vtx.inputs));
+         ASSERT(attr < Elements(exec->vtx.arrays)); /* arrays[] */
          exec->vtx.inputs[attr] = &arrays[attr];
 
          if (_mesa_is_bufferobj(exec->vtx.bufferobj)) {
index 0c691b3a5cdc50fe2d65d8e45fe5c492e2538fa3..a7846213d0ce71a91f89ae01c84eac49a1db264f 100644 (file)
 
 static void clear_active_eval1( struct vbo_exec_context *exec, GLuint attr ) 
 {
+   assert(attr < Elements(exec->eval.map1));
    exec->eval.map1[attr].map = NULL;
 }
 
 static void clear_active_eval2( struct vbo_exec_context *exec, GLuint attr ) 
 {
+   assert(attr < Elements(exec->eval.map2));
    exec->eval.map2[attr].map = NULL;
 }
 
 static void set_active_eval1( struct vbo_exec_context *exec, GLuint attr, GLuint dim, 
                              struct gl_1d_map *map )
 {
+   assert(attr < Elements(exec->eval.map1));
    if (!exec->eval.map1[attr].map) {
       exec->eval.map1[attr].map = map;
       exec->eval.map1[attr].sz = dim;
@@ -55,6 +58,7 @@ static void set_active_eval1( struct vbo_exec_context *exec, GLuint attr, GLuint
 static void set_active_eval2( struct vbo_exec_context *exec, GLuint attr, GLuint dim, 
                              struct gl_2d_map *map )
 {
+   assert(attr < Elements(exec->eval.map2));
    if (!exec->eval.map2[attr].map) {
       exec->eval.map2[attr].map = map;
       exec->eval.map2[attr].sz = dim;
@@ -73,18 +77,6 @@ void vbo_exec_eval_update( struct vbo_exec_context *exec )
       clear_active_eval2( exec, attr );
    }
 
-   /* _NEW_PROGRAM */
-   if (ctx->VertexProgram._Enabled) {
-      for (attr = 0; attr < VBO_ATTRIB_FIRST_MATERIAL; attr++) {
-        /* _NEW_EVAL */
-        if (ctx->Eval.Map1Attrib[attr]) 
-           set_active_eval1( exec, attr, 4, &ctx->EvalMap.Map1Attrib[attr] );
-
-        if (ctx->Eval.Map2Attrib[attr]) 
-           set_active_eval2( exec, attr, 4, &ctx->EvalMap.Map2Attrib[attr] );
-      }
-   }
-
    if (ctx->Eval.Map1Color4) 
       set_active_eval1( exec, VBO_ATTRIB_COLOR0, 4, &ctx->EvalMap.Map1Color4 );
       
@@ -125,6 +117,23 @@ void vbo_exec_eval_update( struct vbo_exec_context *exec )
    else if (ctx->Eval.Map2Vertex3) 
       set_active_eval2( exec, VBO_ATTRIB_POS, 3, &ctx->EvalMap.Map2Vertex3 );
 
+   /* _NEW_PROGRAM */
+   if (ctx->VertexProgram._Enabled) {
+      /* These are the 16 evaluators which GL_NV_vertex_program defines.
+       * They alias and override the conventional vertex attributs.
+       */
+      for (attr = 0; attr < 16; attr++) {
+         /* _NEW_EVAL */
+         assert(attr < Elements(ctx->Eval.Map1Attrib));
+         if (ctx->Eval.Map1Attrib[attr]) 
+            set_active_eval1( exec, attr, 4, &ctx->EvalMap.Map1Attrib[attr] );
+
+         assert(attr < Elements(ctx->Eval.Map2Attrib));
+         if (ctx->Eval.Map2Attrib[attr]) 
+            set_active_eval2( exec, attr, 4, &ctx->EvalMap.Map2Attrib[attr] );
+      }
+   }
+
    exec->eval.recalculate_maps = 0;
 }
 
index 4da248e2b8876f51ca27737a492d5c558056e372..3f86c68b249c1679688a856e90a65a2e5e3266d7 100644 (file)
@@ -270,7 +270,7 @@ static void _save_compile_vertex_list( GLcontext *ctx )
     * being compiled.
     */
    node = (struct vbo_save_vertex_list *)
-      _mesa_alloc_instruction(ctx, save->opcode_vertex_list, sizeof(*node));
+      _mesa_dlist_alloc(ctx, save->opcode_vertex_list, sizeof(*node));
 
    if (!node)
       return;
@@ -1233,11 +1233,11 @@ void vbo_save_api_init( struct vbo_save_context *save )
    GLuint i;
 
    save->opcode_vertex_list =
-      _mesa_alloc_opcode( ctx,
-                         sizeof(struct vbo_save_vertex_list),
-                         vbo_save_playback_vertex_list,
-                         vbo_destroy_vertex_list,
-                         vbo_print_vertex_list );
+      _mesa_dlist_alloc_opcode( ctx,
+                                sizeof(struct vbo_save_vertex_list),
+                                vbo_save_playback_vertex_list,
+                                vbo_destroy_vertex_list,
+                                vbo_print_vertex_list );
 
    ctx->Driver.NotifySaveBegin = vbo_save_NotifyBegin;
 
index baa00af29a63b4ca1941cfe59380c788f555a69f..0af8893c30224902bac17138d877c8934af3114e 100644 (file)
@@ -211,7 +211,7 @@ static INLINE void insert_3f_xyw_4( const struct vf_attr *a, GLubyte *v, const G
 static INLINE void insert_3f_xyw_err( const struct vf_attr *a, GLubyte *v, const GLfloat *in )
 {
    (void) a; (void) v; (void) in;
-   _mesa_exit(1);
+   exit(1);
 }
 
 static INLINE void insert_3f_3( const struct vf_attr *a, GLubyte *v, const GLfloat *in )
index 72d0532906a3d681ad849a54711922cdd66dab1f..bc83b5a0bd586fa02b964357fa14c3a1a28700a7 100644 (file)
@@ -29800,16 +29800,24 @@ GL_PREFIX(FramebufferTextureLayerEXT):
        .size   GL_PREFIX(FramebufferTextureLayerEXT), .-GL_PREFIX(FramebufferTextureLayerEXT)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(ProvokingVertexEXT)
-       .type   GL_PREFIX(ProvokingVertexEXT), @function
-GL_PREFIX(ProvokingVertexEXT):
+       .globl  GL_PREFIX(ColorMaskIndexedEXT)
+       .type   GL_PREFIX(ColorMaskIndexedEXT), @function
+GL_PREFIX(ColorMaskIndexedEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
        movq    6296(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
+       pushq   %rsi
+       pushq   %rdx
+       pushq   %rcx
+       pushq   %r8
        call    _x86_64_get_dispatch@PLT
+       popq    %r8
+       popq    %rcx
+       popq    %rdx
+       popq    %rsi
        popq    %rdi
        movq    6296(%rax), %r11
        jmp     *%r11
@@ -29821,18 +29829,25 @@ GL_PREFIX(ProvokingVertexEXT):
        jmp     *%r11
 1:
        pushq   %rdi
+       pushq   %rsi
+       pushq   %rdx
+       pushq   %rcx
+       pushq   %r8
        call    _glapi_get_dispatch
+       popq    %r8
+       popq    %rcx
+       popq    %rdx
+       popq    %rsi
        popq    %rdi
        movq    6296(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(ProvokingVertexEXT), .-GL_PREFIX(ProvokingVertexEXT)
+       .size   GL_PREFIX(ColorMaskIndexedEXT), .-GL_PREFIX(ColorMaskIndexedEXT)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_788)
-       .type   GL_PREFIX(_dispatch_stub_788), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_788))
-GL_PREFIX(_dispatch_stub_788):
+       .globl  GL_PREFIX(DisableIndexedEXT)
+       .type   GL_PREFIX(DisableIndexedEXT), @function
+GL_PREFIX(DisableIndexedEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
        movq    6304(%rax), %r11
@@ -29840,9 +29855,9 @@ GL_PREFIX(_dispatch_stub_788):
 #elif defined(PTHREADS)
        pushq   %rdi
        pushq   %rsi
-       pushq   %rdx
+       pushq   %rbp
        call    _x86_64_get_dispatch@PLT
-       popq    %rdx
+       popq    %rbp
        popq    %rsi
        popq    %rdi
        movq    6304(%rax), %r11
@@ -29856,21 +29871,20 @@ GL_PREFIX(_dispatch_stub_788):
 1:
        pushq   %rdi
        pushq   %rsi
-       pushq   %rdx
+       pushq   %rbp
        call    _glapi_get_dispatch
-       popq    %rdx
+       popq    %rbp
        popq    %rsi
        popq    %rdi
        movq    6304(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_788), .-GL_PREFIX(_dispatch_stub_788)
+       .size   GL_PREFIX(DisableIndexedEXT), .-GL_PREFIX(DisableIndexedEXT)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_789)
-       .type   GL_PREFIX(_dispatch_stub_789), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_789))
-GL_PREFIX(_dispatch_stub_789):
+       .globl  GL_PREFIX(EnableIndexedEXT)
+       .type   GL_PREFIX(EnableIndexedEXT), @function
+GL_PREFIX(EnableIndexedEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
        movq    6312(%rax), %r11
@@ -29878,9 +29892,9 @@ GL_PREFIX(_dispatch_stub_789):
 #elif defined(PTHREADS)
        pushq   %rdi
        pushq   %rsi
-       pushq   %rdx
+       pushq   %rbp
        call    _x86_64_get_dispatch@PLT
-       popq    %rdx
+       popq    %rbp
        popq    %rsi
        popq    %rdi
        movq    6312(%rax), %r11
@@ -29894,25 +29908,307 @@ GL_PREFIX(_dispatch_stub_789):
 1:
        pushq   %rdi
        pushq   %rsi
-       pushq   %rdx
+       pushq   %rbp
        call    _glapi_get_dispatch
-       popq    %rdx
+       popq    %rbp
        popq    %rsi
        popq    %rdi
        movq    6312(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_789), .-GL_PREFIX(_dispatch_stub_789)
+       .size   GL_PREFIX(EnableIndexedEXT), .-GL_PREFIX(EnableIndexedEXT)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_790)
-       .type   GL_PREFIX(_dispatch_stub_790), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_790))
-GL_PREFIX(_dispatch_stub_790):
+       .globl  GL_PREFIX(GetBooleanIndexedvEXT)
+       .type   GL_PREFIX(GetBooleanIndexedvEXT), @function
+GL_PREFIX(GetBooleanIndexedvEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
        movq    6320(%rax), %r11
        jmp     *%r11
+#elif defined(PTHREADS)
+       pushq   %rdi
+       pushq   %rsi
+       pushq   %rdx
+       call    _x86_64_get_dispatch@PLT
+       popq    %rdx
+       popq    %rsi
+       popq    %rdi
+       movq    6320(%rax), %r11
+       jmp     *%r11
+#else
+       movq    _glapi_Dispatch(%rip), %rax
+       testq   %rax, %rax
+       je      1f
+       movq    6320(%rax), %r11
+       jmp     *%r11
+1:
+       pushq   %rdi
+       pushq   %rsi
+       pushq   %rdx
+       call    _glapi_get_dispatch
+       popq    %rdx
+       popq    %rsi
+       popq    %rdi
+       movq    6320(%rax), %r11
+       jmp     *%r11
+#endif /* defined(GLX_USE_TLS) */
+       .size   GL_PREFIX(GetBooleanIndexedvEXT), .-GL_PREFIX(GetBooleanIndexedvEXT)
+
+       .p2align        4,,15
+       .globl  GL_PREFIX(GetIntegerIndexedvEXT)
+       .type   GL_PREFIX(GetIntegerIndexedvEXT), @function
+GL_PREFIX(GetIntegerIndexedvEXT):
+#if defined(GLX_USE_TLS)
+       call    _x86_64_get_dispatch@PLT
+       movq    6328(%rax), %r11
+       jmp     *%r11
+#elif defined(PTHREADS)
+       pushq   %rdi
+       pushq   %rsi
+       pushq   %rdx
+       call    _x86_64_get_dispatch@PLT
+       popq    %rdx
+       popq    %rsi
+       popq    %rdi
+       movq    6328(%rax), %r11
+       jmp     *%r11
+#else
+       movq    _glapi_Dispatch(%rip), %rax
+       testq   %rax, %rax
+       je      1f
+       movq    6328(%rax), %r11
+       jmp     *%r11
+1:
+       pushq   %rdi
+       pushq   %rsi
+       pushq   %rdx
+       call    _glapi_get_dispatch
+       popq    %rdx
+       popq    %rsi
+       popq    %rdi
+       movq    6328(%rax), %r11
+       jmp     *%r11
+#endif /* defined(GLX_USE_TLS) */
+       .size   GL_PREFIX(GetIntegerIndexedvEXT), .-GL_PREFIX(GetIntegerIndexedvEXT)
+
+       .p2align        4,,15
+       .globl  GL_PREFIX(IsEnabledIndexedEXT)
+       .type   GL_PREFIX(IsEnabledIndexedEXT), @function
+GL_PREFIX(IsEnabledIndexedEXT):
+#if defined(GLX_USE_TLS)
+       call    _x86_64_get_dispatch@PLT
+       movq    6336(%rax), %r11
+       jmp     *%r11
+#elif defined(PTHREADS)
+       pushq   %rdi
+       pushq   %rsi
+       pushq   %rbp
+       call    _x86_64_get_dispatch@PLT
+       popq    %rbp
+       popq    %rsi
+       popq    %rdi
+       movq    6336(%rax), %r11
+       jmp     *%r11
+#else
+       movq    _glapi_Dispatch(%rip), %rax
+       testq   %rax, %rax
+       je      1f
+       movq    6336(%rax), %r11
+       jmp     *%r11
+1:
+       pushq   %rdi
+       pushq   %rsi
+       pushq   %rbp
+       call    _glapi_get_dispatch
+       popq    %rbp
+       popq    %rsi
+       popq    %rdi
+       movq    6336(%rax), %r11
+       jmp     *%r11
+#endif /* defined(GLX_USE_TLS) */
+       .size   GL_PREFIX(IsEnabledIndexedEXT), .-GL_PREFIX(IsEnabledIndexedEXT)
+
+       .p2align        4,,15
+       .globl  GL_PREFIX(BeginConditionalRenderNV)
+       .type   GL_PREFIX(BeginConditionalRenderNV), @function
+GL_PREFIX(BeginConditionalRenderNV):
+#if defined(GLX_USE_TLS)
+       call    _x86_64_get_dispatch@PLT
+       movq    6344(%rax), %r11
+       jmp     *%r11
+#elif defined(PTHREADS)
+       pushq   %rdi
+       pushq   %rsi
+       pushq   %rbp
+       call    _x86_64_get_dispatch@PLT
+       popq    %rbp
+       popq    %rsi
+       popq    %rdi
+       movq    6344(%rax), %r11
+       jmp     *%r11
+#else
+       movq    _glapi_Dispatch(%rip), %rax
+       testq   %rax, %rax
+       je      1f
+       movq    6344(%rax), %r11
+       jmp     *%r11
+1:
+       pushq   %rdi
+       pushq   %rsi
+       pushq   %rbp
+       call    _glapi_get_dispatch
+       popq    %rbp
+       popq    %rsi
+       popq    %rdi
+       movq    6344(%rax), %r11
+       jmp     *%r11
+#endif /* defined(GLX_USE_TLS) */
+       .size   GL_PREFIX(BeginConditionalRenderNV), .-GL_PREFIX(BeginConditionalRenderNV)
+
+       .p2align        4,,15
+       .globl  GL_PREFIX(EndConditionalRenderNV)
+       .type   GL_PREFIX(EndConditionalRenderNV), @function
+GL_PREFIX(EndConditionalRenderNV):
+#if defined(GLX_USE_TLS)
+       call    _x86_64_get_dispatch@PLT
+       movq    6352(%rax), %r11
+       jmp     *%r11
+#elif defined(PTHREADS)
+       pushq   %rbp
+       call    _x86_64_get_dispatch@PLT
+       popq    %rbp
+       movq    6352(%rax), %r11
+       jmp     *%r11
+#else
+       movq    _glapi_Dispatch(%rip), %rax
+       testq   %rax, %rax
+       je      1f
+       movq    6352(%rax), %r11
+       jmp     *%r11
+1:
+       pushq   %rbp
+       call    _glapi_get_dispatch
+       popq    %rbp
+       movq    6352(%rax), %r11
+       jmp     *%r11
+#endif /* defined(GLX_USE_TLS) */
+       .size   GL_PREFIX(EndConditionalRenderNV), .-GL_PREFIX(EndConditionalRenderNV)
+
+       .p2align        4,,15
+       .globl  GL_PREFIX(ProvokingVertexEXT)
+       .type   GL_PREFIX(ProvokingVertexEXT), @function
+GL_PREFIX(ProvokingVertexEXT):
+#if defined(GLX_USE_TLS)
+       call    _x86_64_get_dispatch@PLT
+       movq    6360(%rax), %r11
+       jmp     *%r11
+#elif defined(PTHREADS)
+       pushq   %rdi
+       call    _x86_64_get_dispatch@PLT
+       popq    %rdi
+       movq    6360(%rax), %r11
+       jmp     *%r11
+#else
+       movq    _glapi_Dispatch(%rip), %rax
+       testq   %rax, %rax
+       je      1f
+       movq    6360(%rax), %r11
+       jmp     *%r11
+1:
+       pushq   %rdi
+       call    _glapi_get_dispatch
+       popq    %rdi
+       movq    6360(%rax), %r11
+       jmp     *%r11
+#endif /* defined(GLX_USE_TLS) */
+       .size   GL_PREFIX(ProvokingVertexEXT), .-GL_PREFIX(ProvokingVertexEXT)
+
+       .p2align        4,,15
+       .globl  GL_PREFIX(_dispatch_stub_796)
+       .type   GL_PREFIX(_dispatch_stub_796), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_796))
+GL_PREFIX(_dispatch_stub_796):
+#if defined(GLX_USE_TLS)
+       call    _x86_64_get_dispatch@PLT
+       movq    6368(%rax), %r11
+       jmp     *%r11
+#elif defined(PTHREADS)
+       pushq   %rdi
+       pushq   %rsi
+       pushq   %rdx
+       call    _x86_64_get_dispatch@PLT
+       popq    %rdx
+       popq    %rsi
+       popq    %rdi
+       movq    6368(%rax), %r11
+       jmp     *%r11
+#else
+       movq    _glapi_Dispatch(%rip), %rax
+       testq   %rax, %rax
+       je      1f
+       movq    6368(%rax), %r11
+       jmp     *%r11
+1:
+       pushq   %rdi
+       pushq   %rsi
+       pushq   %rdx
+       call    _glapi_get_dispatch
+       popq    %rdx
+       popq    %rsi
+       popq    %rdi
+       movq    6368(%rax), %r11
+       jmp     *%r11
+#endif /* defined(GLX_USE_TLS) */
+       .size   GL_PREFIX(_dispatch_stub_796), .-GL_PREFIX(_dispatch_stub_796)
+
+       .p2align        4,,15
+       .globl  GL_PREFIX(_dispatch_stub_797)
+       .type   GL_PREFIX(_dispatch_stub_797), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_797))
+GL_PREFIX(_dispatch_stub_797):
+#if defined(GLX_USE_TLS)
+       call    _x86_64_get_dispatch@PLT
+       movq    6376(%rax), %r11
+       jmp     *%r11
+#elif defined(PTHREADS)
+       pushq   %rdi
+       pushq   %rsi
+       pushq   %rdx
+       call    _x86_64_get_dispatch@PLT
+       popq    %rdx
+       popq    %rsi
+       popq    %rdi
+       movq    6376(%rax), %r11
+       jmp     *%r11
+#else
+       movq    _glapi_Dispatch(%rip), %rax
+       testq   %rax, %rax
+       je      1f
+       movq    6376(%rax), %r11
+       jmp     *%r11
+1:
+       pushq   %rdi
+       pushq   %rsi
+       pushq   %rdx
+       call    _glapi_get_dispatch
+       popq    %rdx
+       popq    %rsi
+       popq    %rdi
+       movq    6376(%rax), %r11
+       jmp     *%r11
+#endif /* defined(GLX_USE_TLS) */
+       .size   GL_PREFIX(_dispatch_stub_797), .-GL_PREFIX(_dispatch_stub_797)
+
+       .p2align        4,,15
+       .globl  GL_PREFIX(_dispatch_stub_798)
+       .type   GL_PREFIX(_dispatch_stub_798), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_798))
+GL_PREFIX(_dispatch_stub_798):
+#if defined(GLX_USE_TLS)
+       call    _x86_64_get_dispatch@PLT
+       movq    6384(%rax), %r11
+       jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        pushq   %rsi
@@ -29925,13 +30221,13 @@ GL_PREFIX(_dispatch_stub_790):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6320(%rax), %r11
+       movq    6384(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    6320(%rax), %r11
+       movq    6384(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -29945,19 +30241,19 @@ GL_PREFIX(_dispatch_stub_790):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6320(%rax), %r11
+       movq    6384(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_790), .-GL_PREFIX(_dispatch_stub_790)
+       .size   GL_PREFIX(_dispatch_stub_798), .-GL_PREFIX(_dispatch_stub_798)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_791)
-       .type   GL_PREFIX(_dispatch_stub_791), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_791))
-GL_PREFIX(_dispatch_stub_791):
+       .globl  GL_PREFIX(_dispatch_stub_799)
+       .type   GL_PREFIX(_dispatch_stub_799), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_799))
+GL_PREFIX(_dispatch_stub_799):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    6328(%rax), %r11
+       movq    6392(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -29971,13 +30267,13 @@ GL_PREFIX(_dispatch_stub_791):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6328(%rax), %r11
+       movq    6392(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    6328(%rax), %r11
+       movq    6392(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -29991,19 +30287,19 @@ GL_PREFIX(_dispatch_stub_791):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6328(%rax), %r11
+       movq    6392(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_791), .-GL_PREFIX(_dispatch_stub_791)
+       .size   GL_PREFIX(_dispatch_stub_799), .-GL_PREFIX(_dispatch_stub_799)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_792)
-       .type   GL_PREFIX(_dispatch_stub_792), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_792))
-GL_PREFIX(_dispatch_stub_792):
+       .globl  GL_PREFIX(_dispatch_stub_800)
+       .type   GL_PREFIX(_dispatch_stub_800), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_800))
+GL_PREFIX(_dispatch_stub_800):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    6336(%rax), %r11
+       movq    6400(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -30017,13 +30313,13 @@ GL_PREFIX(_dispatch_stub_792):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6336(%rax), %r11
+       movq    6400(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    6336(%rax), %r11
+       movq    6400(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -30037,19 +30333,19 @@ GL_PREFIX(_dispatch_stub_792):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6336(%rax), %r11
+       movq    6400(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_792), .-GL_PREFIX(_dispatch_stub_792)
+       .size   GL_PREFIX(_dispatch_stub_800), .-GL_PREFIX(_dispatch_stub_800)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_793)
-       .type   GL_PREFIX(_dispatch_stub_793), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_793))
-GL_PREFIX(_dispatch_stub_793):
+       .globl  GL_PREFIX(_dispatch_stub_801)
+       .type   GL_PREFIX(_dispatch_stub_801), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_801))
+GL_PREFIX(_dispatch_stub_801):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    6344(%rax), %r11
+       movq    6408(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -30059,13 +30355,13 @@ GL_PREFIX(_dispatch_stub_793):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6344(%rax), %r11
+       movq    6408(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    6344(%rax), %r11
+       movq    6408(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -30075,19 +30371,19 @@ GL_PREFIX(_dispatch_stub_793):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6344(%rax), %r11
+       movq    6408(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_793), .-GL_PREFIX(_dispatch_stub_793)
+       .size   GL_PREFIX(_dispatch_stub_801), .-GL_PREFIX(_dispatch_stub_801)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_794)
-       .type   GL_PREFIX(_dispatch_stub_794), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_794))
-GL_PREFIX(_dispatch_stub_794):
+       .globl  GL_PREFIX(_dispatch_stub_802)
+       .type   GL_PREFIX(_dispatch_stub_802), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_802))
+GL_PREFIX(_dispatch_stub_802):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    6352(%rax), %r11
+       movq    6416(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -30097,13 +30393,13 @@ GL_PREFIX(_dispatch_stub_794):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6352(%rax), %r11
+       movq    6416(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    6352(%rax), %r11
+       movq    6416(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -30113,10 +30409,10 @@ GL_PREFIX(_dispatch_stub_794):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6352(%rax), %r11
+       movq    6416(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_794), .-GL_PREFIX(_dispatch_stub_794)
+       .size   GL_PREFIX(_dispatch_stub_802), .-GL_PREFIX(_dispatch_stub_802)
 
        .globl GL_PREFIX(ArrayElementEXT) ; .set GL_PREFIX(ArrayElementEXT), GL_PREFIX(ArrayElement)
        .globl GL_PREFIX(BindTextureEXT) ; .set GL_PREFIX(BindTextureEXT), GL_PREFIX(BindTexture)
@@ -30302,6 +30598,7 @@ GL_PREFIX(_dispatch_stub_794):
        .globl GL_PREFIX(GetAttribLocation) ; .set GL_PREFIX(GetAttribLocation), GL_PREFIX(GetAttribLocationARB)
        .globl GL_PREFIX(DrawBuffers) ; .set GL_PREFIX(DrawBuffers), GL_PREFIX(DrawBuffersARB)
        .globl GL_PREFIX(DrawBuffersATI) ; .set GL_PREFIX(DrawBuffersATI), GL_PREFIX(DrawBuffersARB)
+       .globl GL_PREFIX(RenderbufferStorageMultisampleEXT) ; .set GL_PREFIX(RenderbufferStorageMultisampleEXT), GL_PREFIX(RenderbufferStorageMultisample)
        .globl GL_PREFIX(PointParameterf) ; .set GL_PREFIX(PointParameterf), GL_PREFIX(PointParameterfEXT)
        .globl GL_PREFIX(PointParameterfARB) ; .set GL_PREFIX(PointParameterfARB), GL_PREFIX(PointParameterfEXT)
        .globl GL_PREFIX(PointParameterfv) ; .set GL_PREFIX(PointParameterfv), GL_PREFIX(PointParameterfvEXT)
index d56b701aa8c1f1a189558aa2fd76c657909fe862..14cfa910aaf28739c364436ce08869dfdd7e195a 100644 (file)
@@ -61,21 +61,11 @@ do {                                                                        \
    printf( "\n" );                                                     \
 } while (0)
 
-#if defined(__BEOS__) || defined(__HAIKU__) || defined(_LP64)
 #define OFFSET( s, t, m )                                              \
-   printf( "#define %s\t%ld\n", s, offsetof( t, m ) );
-#else
-#define OFFSET( s, t, m )                                              \
-   printf( "#define %s\t%d\n", s, offsetof( t, m ) );
-#endif
+   printf( "#define %s\t%lu\n", s, (unsigned long) offsetof( t, m ) );
 
-#if defined(__BEOS__) || defined(__HAIKU__) || defined(_LP64)
-#define SIZEOF( s, t )                                                 \
-   printf( "#define %s\t%ld\n", s, sizeof(t) );
-#else
 #define SIZEOF( s, t )                                                 \
-   printf( "#define %s\t%d\n", s, sizeof(t) );
-#endif
+   printf( "#define %s\t%lu\n", s, (unsigned long) sizeof(t) );
 
 #define DEFINE( s, d )                                                 \
    printf( "#define %s\t0x%x\n", s, d );
@@ -120,22 +110,22 @@ int main( int argc, char **argv )
    OFFSET( "VB_COUNT               ", struct vertex_buffer, Count );
    printf( "\n" );
    OFFSET( "VB_ELTS                ", struct vertex_buffer, Elts );
-   OFFSET( "VB_OBJ_PTR             ", struct vertex_buffer, ObjPtr );
+   OFFSET( "VB_OBJ_PTR             ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_POS] );
    OFFSET( "VB_EYE_PTR             ", struct vertex_buffer, EyePtr );
    OFFSET( "VB_CLIP_PTR            ", struct vertex_buffer, ClipPtr );
    OFFSET( "VB_PROJ_CLIP_PTR       ", struct vertex_buffer, NdcPtr );
    OFFSET( "VB_CLIP_OR_MASK        ", struct vertex_buffer, ClipOrMask );
    OFFSET( "VB_CLIP_MASK           ", struct vertex_buffer, ClipMask );
-   OFFSET( "VB_NORMAL_PTR          ", struct vertex_buffer, NormalPtr );
+   OFFSET( "VB_NORMAL_PTR          ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_NORMAL] );
    OFFSET( "VB_EDGE_FLAG           ", struct vertex_buffer, EdgeFlag );
-   OFFSET( "VB_TEX0_COORD_PTR      ", struct vertex_buffer, TexCoordPtr[0] );
-   OFFSET( "VB_TEX1_COORD_PTR      ", struct vertex_buffer, TexCoordPtr[1] );
-   OFFSET( "VB_TEX2_COORD_PTR      ", struct vertex_buffer, TexCoordPtr[2] );
-   OFFSET( "VB_TEX3_COORD_PTR      ", struct vertex_buffer, TexCoordPtr[3] );
-   OFFSET( "VB_INDEX_PTR           ", struct vertex_buffer, IndexPtr );
-   OFFSET( "VB_COLOR_PTR           ", struct vertex_buffer, ColorPtr );
-   OFFSET( "VB_SECONDARY_COLOR_PTR ", struct vertex_buffer, SecondaryColorPtr );
-   OFFSET( "VB_FOG_COORD_PTR       ", struct vertex_buffer, FogCoordPtr );
+   OFFSET( "VB_TEX0_COORD_PTR      ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_TEX0] );
+   OFFSET( "VB_TEX1_COORD_PTR      ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_TEX1] );
+   OFFSET( "VB_TEX2_COORD_PTR      ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_TEX2] );
+   OFFSET( "VB_TEX3_COORD_PTR      ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_TEX3] );
+   OFFSET( "VB_INDEX_PTR           ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_COLOR_INDEX] );
+   OFFSET( "VB_COLOR_PTR           ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_COLOR0] );
+   OFFSET( "VB_SECONDARY_COLOR_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_COLOR1] );
+   OFFSET( "VB_FOG_COORD_PTR       ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_FOG] );
    OFFSET( "VB_PRIMITIVE           ", struct vertex_buffer, Primitive );
    printf( "\n" );
 
index 12c77f434ecf81e92b45b53214e313b0d96e20d6..6668852514ce7982d3ffd36aa2612d13d666041a 100644 (file)
@@ -968,21 +968,29 @@ GLNAME(gl_dispatch_functions_start):
        GL_STUB(_dispatch_stub_785, _gloffset_FlushMappedBufferRangeAPPLE, _dispatch_stub_785@12)
        HIDDEN(GL_PREFIX(_dispatch_stub_785, _dispatch_stub_785@12))
        GL_STUB(FramebufferTextureLayerEXT, _gloffset_FramebufferTextureLayerEXT, FramebufferTextureLayerEXT@20)
+       GL_STUB(ColorMaskIndexedEXT, _gloffset_ColorMaskIndexedEXT, ColorMaskIndexedEXT@20)
+       GL_STUB(DisableIndexedEXT, _gloffset_DisableIndexedEXT, DisableIndexedEXT@8)
+       GL_STUB(EnableIndexedEXT, _gloffset_EnableIndexedEXT, EnableIndexedEXT@8)
+       GL_STUB(GetBooleanIndexedvEXT, _gloffset_GetBooleanIndexedvEXT, GetBooleanIndexedvEXT@12)
+       GL_STUB(GetIntegerIndexedvEXT, _gloffset_GetIntegerIndexedvEXT, GetIntegerIndexedvEXT@12)
+       GL_STUB(IsEnabledIndexedEXT, _gloffset_IsEnabledIndexedEXT, IsEnabledIndexedEXT@8)
+       GL_STUB(BeginConditionalRenderNV, _gloffset_BeginConditionalRenderNV, BeginConditionalRenderNV@8)
+       GL_STUB(EndConditionalRenderNV, _gloffset_EndConditionalRenderNV, EndConditionalRenderNV@0)
        GL_STUB(ProvokingVertexEXT, _gloffset_ProvokingVertexEXT, ProvokingVertexEXT@4)
-       GL_STUB(_dispatch_stub_788, _gloffset_GetTexParameterPointervAPPLE, _dispatch_stub_788@12)
-       HIDDEN(GL_PREFIX(_dispatch_stub_788, _dispatch_stub_788@12))
-       GL_STUB(_dispatch_stub_789, _gloffset_TextureRangeAPPLE, _dispatch_stub_789@12)
-       HIDDEN(GL_PREFIX(_dispatch_stub_789, _dispatch_stub_789@12))
-       GL_STUB(_dispatch_stub_790, _gloffset_StencilFuncSeparateATI, _dispatch_stub_790@16)
-       HIDDEN(GL_PREFIX(_dispatch_stub_790, _dispatch_stub_790@16))
-       GL_STUB(_dispatch_stub_791, _gloffset_ProgramEnvParameters4fvEXT, _dispatch_stub_791@16)
-       HIDDEN(GL_PREFIX(_dispatch_stub_791, _dispatch_stub_791@16))
-       GL_STUB(_dispatch_stub_792, _gloffset_ProgramLocalParameters4fvEXT, _dispatch_stub_792@16)
-       HIDDEN(GL_PREFIX(_dispatch_stub_792, _dispatch_stub_792@16))
-       GL_STUB(_dispatch_stub_793, _gloffset_GetQueryObjecti64vEXT, _dispatch_stub_793@12)
-       HIDDEN(GL_PREFIX(_dispatch_stub_793, _dispatch_stub_793@12))
-       GL_STUB(_dispatch_stub_794, _gloffset_GetQueryObjectui64vEXT, _dispatch_stub_794@12)
-       HIDDEN(GL_PREFIX(_dispatch_stub_794, _dispatch_stub_794@12))
+       GL_STUB(_dispatch_stub_796, _gloffset_GetTexParameterPointervAPPLE, _dispatch_stub_796@12)
+       HIDDEN(GL_PREFIX(_dispatch_stub_796, _dispatch_stub_796@12))
+       GL_STUB(_dispatch_stub_797, _gloffset_TextureRangeAPPLE, _dispatch_stub_797@12)
+       HIDDEN(GL_PREFIX(_dispatch_stub_797, _dispatch_stub_797@12))
+       GL_STUB(_dispatch_stub_798, _gloffset_StencilFuncSeparateATI, _dispatch_stub_798@16)
+       HIDDEN(GL_PREFIX(_dispatch_stub_798, _dispatch_stub_798@16))
+       GL_STUB(_dispatch_stub_799, _gloffset_ProgramEnvParameters4fvEXT, _dispatch_stub_799@16)
+       HIDDEN(GL_PREFIX(_dispatch_stub_799, _dispatch_stub_799@16))
+       GL_STUB(_dispatch_stub_800, _gloffset_ProgramLocalParameters4fvEXT, _dispatch_stub_800@16)
+       HIDDEN(GL_PREFIX(_dispatch_stub_800, _dispatch_stub_800@16))
+       GL_STUB(_dispatch_stub_801, _gloffset_GetQueryObjecti64vEXT, _dispatch_stub_801@12)
+       HIDDEN(GL_PREFIX(_dispatch_stub_801, _dispatch_stub_801@12))
+       GL_STUB(_dispatch_stub_802, _gloffset_GetQueryObjectui64vEXT, _dispatch_stub_802@12)
+       HIDDEN(GL_PREFIX(_dispatch_stub_802, _dispatch_stub_802@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)
@@ -1226,6 +1234,7 @@ GLNAME(gl_dispatch_functions_start):
        GL_STUB_ALIAS(GetAttribLocation, _gloffset_GetAttribLocationARB, GetAttribLocation@8, GetAttribLocationARB, GetAttribLocationARB@8)
        GL_STUB_ALIAS(DrawBuffers, _gloffset_DrawBuffersARB, DrawBuffers@8, DrawBuffersARB, DrawBuffersARB@8)
        GL_STUB_ALIAS(DrawBuffersATI, _gloffset_DrawBuffersARB, DrawBuffersATI@8, DrawBuffersARB, DrawBuffersARB@8)
+       GL_STUB_ALIAS(RenderbufferStorageMultisampleEXT, _gloffset_RenderbufferStorageMultisample, RenderbufferStorageMultisampleEXT@20, RenderbufferStorageMultisample, RenderbufferStorageMultisample@20)
        GL_STUB_ALIAS(PointParameterf, _gloffset_PointParameterfEXT, PointParameterf@8, PointParameterfEXT, PointParameterfEXT@8)
        GL_STUB_ALIAS(PointParameterfARB, _gloffset_PointParameterfEXT, PointParameterfARB@8, PointParameterfEXT, PointParameterfEXT@8)
        GL_STUB_ALIAS(PointParameterfSGIS, _gloffset_PointParameterfEXT, PointParameterfSGIS@8, PointParameterfEXT, PointParameterfEXT@8)
index 80144b889c72e5b41c12c6934cfeed2eab5a7295..92b1c2d902d6dae5259712054bdaae6a9bc2a0d6 100644 (file)
@@ -522,7 +522,7 @@ _generic_read_RGBA_span_RGB565_MMX:
        addl    $32,%esp
 
        sarl    $2, %ecx
-       jle     .L01            /* Bail early if the count is negative. */
+       jl      .L01            /* Bail early if the count is negative. */
        jmp     .L02
 
 .L03:
index 5aedf5b04beb16be24275f357c05908f2cf74983..647be995c128152f33aa77929c279e1f66c7aa35 100644 (file)
@@ -7,10 +7,12 @@
 #define DISASSEM 0
 #define X86_TWOB 0x0f
 
+#if 0
 static unsigned char *cptr( void (*label)() )
 {
    return (unsigned char *)(unsigned long)label;
 }
+#endif
 
 
 static void do_realloc( struct x86_function *p )
diff --git a/windows/VC6/progs/glut/glut.dsp b/windows/VC6/progs/glut/glut.dsp
deleted file mode 100644 (file)
index 0a67689..0000000
+++ /dev/null
@@ -1,333 +0,0 @@
-# Microsoft Developer Studio Project File - Name="glut" - Package Owner=<4>\r
-# Microsoft Developer Studio Generated Build File, Format Version 6.00\r
-# ** DO NOT EDIT **\r
-\r
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102\r
-\r
-CFG=glut - Win32 Debug\r
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r
-!MESSAGE use the Export Makefile command and run\r
-!MESSAGE \r
-!MESSAGE NMAKE /f "glut.mak".\r
-!MESSAGE \r
-!MESSAGE You can specify a configuration when running NMAKE\r
-!MESSAGE by defining the macro CFG on the command line. For example:\r
-!MESSAGE \r
-!MESSAGE NMAKE /f "glut.mak" CFG="glut - Win32 Debug"\r
-!MESSAGE \r
-!MESSAGE Possible choices for configuration are:\r
-!MESSAGE \r
-!MESSAGE "glut - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")\r
-!MESSAGE "glut - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")\r
-!MESSAGE \r
-\r
-# Begin Project\r
-# PROP AllowPerConfigDependencies 0\r
-# PROP Scc_ProjName ""\r
-# PROP Scc_LocalPath ""\r
-CPP=cl.exe\r
-MTL=midl.exe\r
-RSC=rc.exe\r
-\r
-!IF  "$(CFG)" == "glut - Win32 Release"\r
-\r
-# PROP BASE Use_MFC 0\r
-# PROP BASE Use_Debug_Libraries 0\r
-# PROP BASE Output_Dir "Release"\r
-# PROP BASE Intermediate_Dir "Release"\r
-# PROP BASE Target_Dir ""\r
-# PROP Use_MFC 0\r
-# PROP Use_Debug_Libraries 0\r
-# PROP Output_Dir "Release"\r
-# PROP Intermediate_Dir "Release"\r
-# PROP Ignore_Export_Lib 0\r
-# PROP Target_Dir ""\r
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "GLUT_EXPORTS" /YX /FD /c\r
-# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../../../include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_DLL" /D "_USRDLL" /D "GLUT_EXPORTS" /D "MESA" /D "BUILD_GL32" /FD /c\r
-# SUBTRACT CPP /YX\r
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32\r
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32\r
-# ADD BASE RSC /l 0x409 /d "NDEBUG"\r
-# ADD RSC /l 0x409 /d "NDEBUG"\r
-BSC32=bscmake.exe\r
-# ADD BASE BSC32 /nologo\r
-# ADD BSC32 /nologo\r
-LINK32=link.exe\r
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386\r
-# ADD LINK32 opengl32.lib glu32.lib winmm.lib msvcrt.lib oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /nodefaultlib /out:"Release/GLUT32.DLL" /libpath:"../../mesa/Release"\r
-# Begin Special Build Tool\r
-SOURCE="$(InputPath)"\r
-PostBuild_Cmds=if not exist ..\..\..\..\lib md ..\..\..\..\lib copy Release\GLUT32.LIB ..\..\..\..\lib copy Release\GLUT32.DLL ..\..\..\..\lib if exist ..\..\..\..\progs\demos copy Release\GLUT32.DLL ..\..\..\..\progs\demos\r
-# End Special Build Tool\r
-\r
-!ELSEIF  "$(CFG)" == "glut - Win32 Debug"\r
-\r
-# PROP BASE Use_MFC 0\r
-# PROP BASE Use_Debug_Libraries 1\r
-# PROP BASE Output_Dir "Debug"\r
-# PROP BASE Intermediate_Dir "Debug"\r
-# PROP BASE Target_Dir ""\r
-# PROP Use_MFC 0\r
-# PROP Use_Debug_Libraries 1\r
-# PROP Output_Dir "Debug"\r
-# PROP Intermediate_Dir "Debug"\r
-# PROP Ignore_Export_Lib 0\r
-# PROP Target_Dir ""\r
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "GLUT_EXPORTS" /YX /FD /GZ /c\r
-# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "../../../../include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_DLL" /D "_USRDLL" /D "GLUT_EXPORTS" /D "MESA" /D "BUILD_GL32" /FD /GZ /c\r
-# SUBTRACT CPP /YX\r
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32\r
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32\r
-# ADD BASE RSC /l 0x409 /d "_DEBUG"\r
-# ADD RSC /l 0x409 /d "_DEBUG"\r
-BSC32=bscmake.exe\r
-# ADD BASE BSC32 /nologo\r
-# ADD BSC32 /nologo\r
-LINK32=link.exe\r
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept\r
-# ADD LINK32 winmm.lib msvcrtd.lib oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib glu32.lib /nologo /dll /incremental:no /debug /machine:I386 /nodefaultlib /out:"Debug/GLUT32.DLL" /pdbtype:sept /libpath:"../../mesa/Debug"\r
-# Begin Special Build Tool\r
-SOURCE="$(InputPath)"\r
-PostBuild_Cmds=if not exist ..\..\..\..\lib md ..\..\..\..\lib copy Debug\GLUT32.LIB ..\..\..\..\lib   copy Debug\GLUT32.DLL ..\..\..\..\lib   if exist ..\..\..\..\progs\demos copy Debug\GLUT32.DLL ..\..\..\..\progs\demos\r
-# End Special Build Tool\r
-\r
-!ENDIF \r
-\r
-# Begin Target\r
-\r
-# Name "glut - Win32 Release"\r
-# Name "glut - Win32 Debug"\r
-# Begin Group "Source Files"\r
-\r
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_8x13.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_9x15.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_bitmap.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_bwidth.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_cindex.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_cmap.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_cursor.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_dials.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_dstr.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_event.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_ext.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_fcb.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_fullscrn.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_gamemode.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_get.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_hel10.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_hel12.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_hel18.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_init.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_input.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_joy.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_key.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_keyctrl.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_keyup.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_mesa.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_modifier.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_mroman.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_overlay.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_roman.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_shapes.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_space.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_stroke.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_swap.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_swidth.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_tablet.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_teapot.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_tr10.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_tr24.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_util.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_vidresize.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_warp.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_win.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glut_winmisc.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\win32_glx.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\win32_menu.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\win32_util.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\win32_winproc.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\win32_x11.c\r
-# End Source File\r
-# End Group\r
-# Begin Group "Header Files"\r
-\r
-# PROP Default_Filter "h;hpp;hxx;hm;inl"\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glutbitmap.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glutint.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glutstroke.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\glutwin32.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\stroke.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\win32_glx.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\..\..\src\glut\glx\win32_x11.h\r
-# End Source File\r
-# End Group\r
-# Begin Group "Resource Files"\r
-\r
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"\r
-# End Group\r
-# End Target\r
-# End Project\r
index 4d7df7417026034995f98fc50fdc557299760dfd..caee6c0ca6e2b60624ea904590f0bc47f649e558 100644 (file)
@@ -22,7 +22,7 @@
                                Name="VCCLCompilerTool"\r
                                AdditionalOptions="/Zm1000 "\r
                                InlineFunctionExpansion="1"\r
-                               AdditionalIncludeDirectories="../../../../include,../../../../src/mesa,../../../../src/mesa/glapi,../../../../src/mesa/main,../../../../src/mesa/shader,../../../../src/mesa/shader/slang,../../../../src/mesa/shader/grammar"\r
+                               AdditionalIncludeDirectories="../../../../include,../../../../src/mesa,../../../../src/mesa/glapi,../../../../src/mesa/main,../../../../src/mesa/shader,../../../../src/mesa/shader/slang"\r
                                PreprocessorDefinitions="NDEBUG,WIN32,_LIB,_DLL,BUILD_GL32,MESA_MINWARN"\r
                                StringPooling="TRUE"\r
                                RuntimeLibrary="4"\r
@@ -74,7 +74,7 @@
                                Name="VCCLCompilerTool"\r
                                AdditionalOptions="/Zm1000 "\r
                                Optimization="0"\r
-                               AdditionalIncludeDirectories="../../../../include,../../../../src/mesa,../../../../src/mesa/glapi,../../../../src/mesa/main,../../../../src/mesa/shader,../../../../src/mesa/shader/slang,../../../../src/mesa/shader/grammar"\r
+                               AdditionalIncludeDirectories="../../../../include,../../../../src/mesa,../../../../src/mesa/glapi,../../../../src/mesa/main,../../../../src/mesa/shader,../../../../src/mesa/shader/slang"\r
                                PreprocessorDefinitions="_DEBUG,WIN32,_LIB,_DLL,BUILD_GL32,MESA_MINWARN"\r
                                BasicRuntimeChecks="3"\r
                                RuntimeLibrary="5"\r
                        <File\r
                                RelativePath="..\..\..\..\src\mesa\glapi\glthread.c">\r
                        </File>\r
-                       <File\r
-                               RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar.c">\r
-                               <FileConfiguration\r
-                                       Name="Release|Win32"\r
-                                       ExcludedFromBuild="TRUE">\r
-                                       <Tool\r
-                                               Name="VCCLCompilerTool"/>\r
-                               </FileConfiguration>\r
-                               <FileConfiguration\r
-                                       Name="Debug|Win32"\r
-                                       ExcludedFromBuild="TRUE">\r
-                                       <Tool\r
-                                               Name="VCCLCompilerTool"/>\r
-                               </FileConfiguration>\r
-                       </File>\r
-                       <File\r
-                               RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar_crt.c">\r
-                               <FileConfiguration\r
-                                       Name="Debug|Win32"\r
-                                       ExcludedFromBuild="TRUE">\r
-                                       <Tool\r
-                                               Name="VCCLCompilerTool"/>\r
-                               </FileConfiguration>\r
-                       </File>\r
-                       <File\r
-                               RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar_mesa.c">\r
-                       </File>\r
                        <File\r
                                RelativePath="..\..\..\..\src\mesa\main\hash.c">\r
                        </File>\r
                        <File\r
                                RelativePath="..\..\..\..\src\mesa\main\rbadaptors.c">\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\remap.c">\r
+                       </File>\r
                        <File\r
                                RelativePath="..\..\..\..\src\mesa\main\renderbuffer.c">\r
                        </File>\r
                        <File\r
                                RelativePath="..\..\..\..\src\mesa\main\texenvprogram.c">\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texfetch.c">\r
+                       </File>\r
                        <File\r
                                RelativePath="..\..\..\..\src\mesa\main\texformat.c">\r
                        </File>\r
                        <File\r
                                RelativePath="..\..\..\..\src\mesa\glapi\glthread.h">\r
                        </File>\r
-                       <File\r
-                               RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar.h">\r
-                       </File>\r
-                       <File\r
-                               RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar_crt.h">\r
-                       </File>\r
-                       <File\r
-                               RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar_mesa.h">\r
-                       </File>\r
-                       <File\r
-                               RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar_syn.h">\r
-                       </File>\r
                        <File\r
                                RelativePath="..\..\..\..\src\mesa\main\hash.h">\r
                        </File>\r
                        <File\r
                                RelativePath="..\..\..\..\src\mesa\main\rastpos.h">\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\remap.h">\r
+                       </File>\r
                        <File\r
                                RelativePath="..\..\..\..\src\mesa\main\renderbuffer.h">\r
                        </File>\r
                        <File\r
                                RelativePath="..\..\..\..\src\mesa\main\texenvprogram.h">\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texfetch.h">\r
+                       </File>\r
                        <File\r
                                RelativePath="..\..\..\..\src\mesa\main\texformat.h">\r
                        </File>\r
                        <File\r
-                               RelativePath="..\..\..\..\src\mesa\main\texformat_tmp.h">\r
+                               RelativePath="..\..\..\..\src\mesa\main\texfetch_tmp.h">\r
                        </File>\r
                        <File\r
                                RelativePath="..\..\..\..\src\mesa\main\teximage.h">\r
index f15c4435f617b4af5399ef3ea8df41054400ca2c..05bf7d2ea0f0e1676447c1917e4522955bd69f07 100644 (file)
@@ -43,7 +43,7 @@
                                Name="VCCLCompilerTool"\r
                                AdditionalOptions="/Zm1000 "\r
                                InlineFunctionExpansion="1"\r
-                               AdditionalIncludeDirectories="../../../../include,../../../../src/mesa,../../../../src/mesa/glapi,../../../../src/mesa/main,../../../../src/mesa/shader,../../../../src/mesa/shader/slang,../../../../src/mesa/shader/grammar"\r
+                               AdditionalIncludeDirectories="../../../../include,../../../../src/mesa,../../../../src/mesa/glapi,../../../../src/mesa/main,../../../../src/mesa/shader,../../../../src/mesa/shader/slang"\r
                                PreprocessorDefinitions="NDEBUG;WIN32;_LIB;_DLL;BUILD_GL32;MESA_MINWARN;_CRT_SECURE_NO_DEPRECATE"\r
                                StringPooling="true"\r
                                RuntimeLibrary="2"\r
                                Name="VCCLCompilerTool"\r
                                AdditionalOptions="/Zm1000 "\r
                                Optimization="0"\r
-                               AdditionalIncludeDirectories="../../../../include,../../../../src/mesa,../../../../src/mesa/glapi,../../../../src/mesa/main,../../../../src/mesa/shader,../../../../src/mesa/shader/slang,../../../../src/mesa/shader/grammar"\r
+                               AdditionalIncludeDirectories="../../../../include,../../../../src/mesa,../../../../src/mesa/glapi,../../../../src/mesa/main,../../../../src/mesa/shader,../../../../src/mesa/shader/slang"\r
                                PreprocessorDefinitions="_DEBUG;WIN32;_LIB;_DLL;BUILD_GL32;MESA_MINWARN;_CRT_SECURE_NO_DEPRECATE"\r
                                BasicRuntimeChecks="3"\r
                                RuntimeLibrary="3"\r
                                WarningLevel="3"\r
                                SuppressStartupBanner="true"\r
                                DebugInformationFormat="3"\r
-                               CompileAs="0"\r
+                               CompileAs="1"\r
                                ForcedIncludeFiles="../../../../src/mesa/main/compiler.h"\r
                        />\r
                        <Tool\r
                                Name="VCCLCompilerTool"\r
                                AdditionalOptions="/Zm1000 "\r
                                Optimization="0"\r
-                               AdditionalIncludeDirectories="../../../../include,../../../../src/mesa,../../../../src/mesa/glapi,../../../../src/mesa/main,../../../../src/mesa/shader,../../../../src/mesa/shader/slang,../../../../src/mesa/shader/grammar"\r
+                               AdditionalIncludeDirectories="../../../../include,../../../../src/mesa,../../../../src/mesa/glapi,../../../../src/mesa/main,../../../../src/mesa/shader,../../../../src/mesa/shader/slang"\r
                                PreprocessorDefinitions="_DEBUG;WIN32;_LIB;BUILD_GL32;MESA_MINWARN;_CRT_SECURE_NO_DEPRECATE"\r
                                BasicRuntimeChecks="3"\r
                                RuntimeLibrary="1"\r
                                Name="VCCLCompilerTool"\r
                                AdditionalOptions="/Zm1000 "\r
                                InlineFunctionExpansion="1"\r
-                               AdditionalIncludeDirectories="../../../../include,../../../../src/mesa,../../../../src/mesa/glapi,../../../../src/mesa/main,../../../../src/mesa/shader,../../../../src/mesa/shader/slang,../../../../src/mesa/shader/grammar"\r
+                               AdditionalIncludeDirectories="../../../../include,../../../../src/mesa,../../../../src/mesa/glapi,../../../../src/mesa/main,../../../../src/mesa/shader,../../../../src/mesa/shader/slang"\r
                                PreprocessorDefinitions="NDEBUG;WIN32;_LIB;BUILD_GL32;MESA_MINWARN;_CRT_SECURE_NO_DEPRECATE"\r
                                StringPooling="true"\r
                                RuntimeLibrary="0"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar.c"\r
+                               RelativePath="..\..\..\..\src\mesa\main\hash.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\hash_table.c"\r
                                >\r
-                               <FileConfiguration\r
-                                       Name="Release|Win32"\r
-                                       ExcludedFromBuild="true"\r
-                                       >\r
-                                       <Tool\r
-                                               Name="VCCLCompilerTool"\r
-                                       />\r
-                               </FileConfiguration>\r
-                               <FileConfiguration\r
-                                       Name="Debug|Win32"\r
-                                       ExcludedFromBuild="true"\r
-                                       >\r
-                                       <Tool\r
-                                               Name="VCCLCompilerTool"\r
-                                       />\r
-                               </FileConfiguration>\r
-                               <FileConfiguration\r
-                                       Name="Debug Static CRT|Win32"\r
-                                       ExcludedFromBuild="true"\r
-                                       >\r
-                                       <Tool\r
-                                               Name="VCCLCompilerTool"\r
-                                       />\r
-                               </FileConfiguration>\r
-                               <FileConfiguration\r
-                                       Name="Release Static CRT|Win32"\r
-                                       ExcludedFromBuild="true"\r
-                                       >\r
-                                       <Tool\r
-                                               Name="VCCLCompilerTool"\r
-                                       />\r
-                               </FileConfiguration>\r
                        </File>\r
                        <File\r
-                               RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar_crt.c"\r
+                               RelativePath="..\..\..\..\src\mesa\main\hint.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\histogram.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\image.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\imports.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\lex.yy.c"\r
                                >\r
                                <FileConfiguration\r
                                        Name="Release|Win32"\r
-                                       ExcludedFromBuild="true"\r
                                        >\r
                                        <Tool\r
                                                Name="VCCLCompilerTool"\r
+                                               PreprocessorDefinitions="YY_NO_UNISTD_H;YY_USE_CONST;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"\r
                                        />\r
                                </FileConfiguration>\r
                                <FileConfiguration\r
                                        Name="Debug|Win32"\r
-                                       ExcludedFromBuild="true"\r
                                        >\r
                                        <Tool\r
                                                Name="VCCLCompilerTool"\r
+                                               PreprocessorDefinitions="YY_NO_UNISTD_H;YY_USE_CONST;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"\r
                                        />\r
                                </FileConfiguration>\r
                                <FileConfiguration\r
                                        Name="Debug Static CRT|Win32"\r
-                                       ExcludedFromBuild="true"\r
                                        >\r
                                        <Tool\r
                                                Name="VCCLCompilerTool"\r
+                                               PreprocessorDefinitions="YY_NO_UNISTD_H;YY_USE_CONST;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"\r
                                        />\r
                                </FileConfiguration>\r
                                <FileConfiguration\r
                                        Name="Release Static CRT|Win32"\r
-                                       ExcludedFromBuild="true"\r
                                        >\r
                                        <Tool\r
                                                Name="VCCLCompilerTool"\r
+                                               PreprocessorDefinitions="YY_NO_UNISTD_H;YY_USE_CONST;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"\r
                                        />\r
                                </FileConfiguration>\r
                        </File>\r
-                       <File\r
-                               RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar_mesa.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath="..\..\..\..\src\mesa\main\hash.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath="..\..\..\..\src\mesa\main\hint.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath="..\..\..\..\src\mesa\main\histogram.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath="..\..\..\..\src\mesa\main\image.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath="..\..\..\..\src\mesa\main\imports.c"\r
-                               >\r
-                       </File>\r
                        <File\r
                                RelativePath="..\..\..\..\src\mesa\main\light.c"\r
                                >\r
                                RelativePath="..\..\..\..\src\mesa\shader\prog_parameter.c"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\prog_parameter_layout.c"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="..\..\..\..\src\mesa\shader\prog_print.c"\r
                                >\r
                                RelativePath="..\..\..\..\src\mesa\shader\program.c"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\program_parse.tab.c"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Release|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               PreprocessorDefinitions="YYMALLOC=malloc;YYFREE=free"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               PreprocessorDefinitions="YYMALLOC=malloc;YYFREE=free"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Debug Static CRT|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               PreprocessorDefinitions="YYMALLOC=malloc;YYFREE=free"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Release Static CRT|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               PreprocessorDefinitions="YYMALLOC=malloc;YYFREE=free"\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\program_parse_extra.c"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="..\..\..\..\src\mesa\shader\programopt.c"\r
                                >\r
                                RelativePath="..\..\..\..\src\mesa\main\readpix.c"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\remap.c"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="..\..\..\..\src\mesa\main\renderbuffer.c"\r
                                >\r
                                RelativePath="..\..\..\..\src\mesa\main\stencil.c"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\symbol_table.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\syncobj.c"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="..\..\..\..\src\mesa\tnl\t_context.c"\r
                                >\r
                                RelativePath="..\..\..\..\src\mesa\main\texenvprogram.c"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texfetch.c"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="..\..\..\..\src\mesa\main\texformat.c"\r
                                >\r
                                RelativePath="..\..\..\..\src\mesa\main\viewport.c"\r
                                >\r
                        </File>\r
-                       <File\r
-                               RelativePath="..\..\..\..\src\mesa\main\vsnprintf.c"\r
-                               >\r
-                               <FileConfiguration\r
-                                       Name="Release|Win32"\r
-                                       ExcludedFromBuild="true"\r
-                                       >\r
-                                       <Tool\r
-                                               Name="VCCLCompilerTool"\r
-                                       />\r
-                               </FileConfiguration>\r
-                               <FileConfiguration\r
-                                       Name="Debug|Win32"\r
-                                       ExcludedFromBuild="true"\r
-                                       >\r
-                                       <Tool\r
-                                               Name="VCCLCompilerTool"\r
-                                       />\r
-                               </FileConfiguration>\r
-                               <FileConfiguration\r
-                                       Name="Debug Static CRT|Win32"\r
-                                       ExcludedFromBuild="true"\r
-                                       >\r
-                                       <Tool\r
-                                               Name="VCCLCompilerTool"\r
-                                       />\r
-                               </FileConfiguration>\r
-                               <FileConfiguration\r
-                                       Name="Release Static CRT|Win32"\r
-                                       ExcludedFromBuild="true"\r
-                                       >\r
-                                       <Tool\r
-                                               Name="VCCLCompilerTool"\r
-                                       />\r
-                               </FileConfiguration>\r
-                       </File>\r
                        <File\r
                                RelativePath="..\..\..\..\src\mesa\main\vtxfmt.c"\r
                                >\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar.h"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar_crt.h"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar_mesa.h"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar_syn.h"\r
+                               RelativePath="..\..\..\..\src\mesa\main\hash.h"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\..\..\..\src\mesa\main\hash.h"\r
+                               RelativePath="..\..\..\..\src\mesa\shader\hash_table.h"\r
                                >\r
                        </File>\r
                        <File\r
                                RelativePath="..\..\..\..\src\mesa\shader\prog_parameter.h"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\prog_parameter_layout.h"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="..\..\..\..\src\mesa\shader\prog_print.h"\r
                                >\r
                                RelativePath="..\..\..\..\src\mesa\shader\program.h"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\program_parse.tab.h"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="..\..\..\..\src\mesa\shader\programopt.h"\r
                                >\r
                                RelativePath="..\..\..\..\src\mesa\main\readpix.h"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\remap.h"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="..\..\..\..\src\mesa\main\renderbuffer.h"\r
                                >\r
                                RelativePath="..\..\..\..\src\mesa\swrast_setup\swrast_setup.h"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\symbol_table.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\syncobj.h"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="..\..\..\..\src\mesa\tnl\t_context.h"\r
                                >\r
                                RelativePath="..\..\..\..\src\mesa\main\texenvprogram.h"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texfetch.h"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="..\..\..\..\src\mesa\main\texformat.h"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\..\..\..\src\mesa\main\texformat_tmp.h"\r
+                               RelativePath="..\..\..\..\src\mesa\main\texfetch_tmp.h"\r
                                >\r
                        </File>\r
                        <File\r